From 87fb9c542fb930d1c4f14d81952f5dc5829cb31b Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Fri, 4 Mar 2016 22:26:34 +0100 Subject: [PATCH 0001/1304] build: Fix dependency generation for go binaries The way depsgen works is that it recursively gets all the dependencies of a given module (say, github.com/coreos/rkt/rkt), filters the dependencies to eliminate packages outside the repository (basically packages from Go standard library), and then gets the files of all those filtered deps and the module. Filtering was done by simply checking if an import path of a dependency had a specific prefix, namely a name of the repository (in our case the repo name is github.com/coreos/rkt). This worked fine until we stopped rewriting our imports. It is because rewritten imports always had the prefix we wanted (github.com/coreos/rkt/Godeps/_workspace/etc/etc) and now they do not. In effect, we were getting the files of all the dependencies that are a part of the repository (like github.com/coreos/rkt/stage0). So now, instead of checking ImportPath of a dependency, we check its Dir and check if it is a direct or indirect subdirectory of the repo. --- tools/depsgen/gocmd.go | 56 ++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/tools/depsgen/gocmd.go b/tools/depsgen/gocmd.go index c6badcfc9f..d15f70b4be 100644 --- a/tools/depsgen/gocmd.go +++ b/tools/depsgen/gocmd.go @@ -16,6 +16,7 @@ package main import ( "bytes" + "fmt" "os/exec" "path" "path/filepath" @@ -98,32 +99,36 @@ func goGetArgs(args []string) (string, string, string, goDepsMode) { // goGetPackageDeps returns a list of files that are used to build a // module in a given repo. func goGetPackageDeps(repo, module string) []string { - pkg := path.Join(repo, module) - deps := []string{pkg} - for _, d := range goGetDeps(pkg) { - if strings.HasPrefix(d, repo) { - deps = append(deps, d) - } - } - return goGetFiles(repo, deps) + dir, deps := goGetDeps(repo, module) + return goGetFiles(dir, deps) } -// goGetDeps gets all dependencies, direct or indirect, of a given -// package. -func goGetDeps(pkg string) []string { - rawDeps := goRun(goList([]string{"Deps"}, []string{pkg})) - // we expect only one line - if len(rawDeps) != 1 { - return []string{} +// goGetDeps gets the directory of a given repo and the all +// dependencies, direct or indirect, of a given module in the repo. +func goGetDeps(repo, module string) (string, []string) { + pkg := path.Join(repo, module) + rawTuples := goRun(goList([]string{"Dir", "Deps"}, []string{pkg})) + if len(rawTuples) != 1 { + common.Die("Expected to get only one line from go list for a single package") } - return goSliceRawSlice(rawDeps[0]) + tuple := goSliceRawTuple(rawTuples[0]) + dir := tuple[0] + if module != "." { + dirsToStrip := 1 + strings.Count(module, "/") + for i := 0; i < dirsToStrip; i++ { + dir = filepath.Dir(dir) + } + } + dir = filepath.Clean(dir) + deps := goSliceRawSlice(tuple[1]) + return dir, append([]string{pkg}, deps...) } // goGetFiles returns a list of files that are in given packages. File -// paths are "relative" to passed repo. -func goGetFiles(repo string, pkgs []string) []string { +// paths are relative to a given directory. +func goGetFiles(dir string, pkgs []string) []string { params := []string{ - "ImportPath", + "Dir", "GoFiles", "CgoFiles", } @@ -131,10 +136,19 @@ func goGetFiles(repo string, pkgs []string) []string { rawTuples := goRun(goList(params, pkgs)) for _, raw := range rawTuples { tuple := goSliceRawTuple(raw) - module := strings.TrimPrefix(tuple[0], repo+"/") + moduleDir := filepath.Clean(tuple[0]) + dirSep := fmt.Sprintf("%s%c", dir, filepath.Separator) + moduleDirSep := fmt.Sprintf("%s%c", moduleDir, filepath.Separator) + if !strings.HasPrefix(moduleDirSep, dirSep) { + continue + } + relModuleDir, err := filepath.Rel(dir, moduleDir) + if err != nil { + common.Die("Could not make a relative path from %q to %q, even if they have the same prefix", moduleDir, dir) + } files := append(goSliceRawSlice(tuple[1]), goSliceRawSlice(tuple[2])...) for i := 0; i < len(files); i++ { - files[i] = filepath.Join(module, files[i]) + files[i] = filepath.Join(relModuleDir, files[i]) } allFiles = append(allFiles, files...) } From 574a54180b589969a37dd0df2289d7ee410df6ec Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Thu, 17 Mar 2016 08:54:47 +0100 Subject: [PATCH 0002/1304] *: drop support for go1.4 --- .travis.yml | 1 - Documentation/dependencies.md | 2 +- Documentation/getting-started-guide.md | 8 ----- configure.ac | 42 ++++++++------------------ pkg/log/log.go | 7 ----- tests/cloudinit/centos.cloudinit | 17 ++++++----- 6 files changed, 24 insertions(+), 53 deletions(-) diff --git a/.travis.yml b/.travis.yml index db7dcaa744..4ca1563148 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ language: go go: - - 1.4.2 - 1.5.3 - 1.6 diff --git a/Documentation/dependencies.md b/Documentation/dependencies.md index 1aef0544d9..d55d1a8469 100644 --- a/Documentation/dependencies.md +++ b/Documentation/dependencies.md @@ -7,7 +7,7 @@ For the most part the codebase is self-contained (e.g. all dependencies are vend ### Basic * GNU Make -* Go 1.4+ (ideally 1.5.3 or later) +* Go 1.5.3 or later * autoconf * aclocal (usually a part of automake) * bash diff --git a/Documentation/getting-started-guide.md b/Documentation/getting-started-guide.md index a5e1ddb7f4..98f654447d 100644 --- a/Documentation/getting-started-guide.md +++ b/Documentation/getting-started-guide.md @@ -27,14 +27,6 @@ func main() { Next we need to build our application. We are going to statically link our app so we can ship an App Container Image with no external dependencies. -With [Go 1.4](https://github.com/golang/go/issues/9344#issuecomment-69944514): - -``` -$ CGO_ENABLED=0 GOOS=linux go build -o hello -a -installsuffix cgo . -``` - -or with Go 1.5: - ``` $ CGO_ENABLED=0 GOOS=linux go build -o hello -a -tags netgo -ldflags '-w' . ``` diff --git a/configure.ac b/configure.ac index cc97a81eb2..1b798b71c5 100644 --- a/configure.ac +++ b/configure.ac @@ -596,20 +596,14 @@ dnl for [ and ]. m4_define([DIGITS],[@<:@0-9@:>@]) m4_define([ALNUM],[@<:@a-z0-9@:>@]) -dnl Detect go version. Go 1.4 support only "-X variable 'value'" -dnl format of assigning values to variables via linker flags. Go 1.5 -dnl deprecates this format in favor of "-X 'variable=value'" -dnl format. Drop this ugliness when we drop support for Go 1.4. -dnl Successfully parse versions like "go1.5", "go1.5.3", "go1.6rc1", -dnl "devel +66330d8 Wed Jan 13 23:40:13 2016 +0000". +dnl Detect go version. Successfully parse versions like "go1.5", +dnl "go1.5.3", "go1.6rc1", "devel +66330d8 Wed Jan 13 23:40:13 2016 +dnl +0000". GO_VERSION_OUTPUT=`"${ABS_GO}" version` GO_VERSION=`AS_ECHO(["${GO_VERSION_OUTPUT}"]) | sed -e 's/^go version \(.*\) ALNUM*\/ALNUM*$/\1/'` AS_CASE([$GO_VERSION], [devel*], - [AC_MSG_WARN([* Using development version of go, all bets are off]) - RKT_XF() { - AS_ECHO(["-X '$1=$2'"]) - }], + [AC_MSG_WARN([* Using development version of go, all bets are off])], [go*], [GO_VERSION=`AS_ECHO(["${GO_VERSION}"]) | sed -e 's/^go\(.*\)/\1/'` GO_MAJOR=`AS_ECHO(["${GO_VERSION}"]) | grep -o '^DIGITS\+'` @@ -622,18 +616,9 @@ AS_CASE([$GO_VERSION], GO_BEST_MINOR=5 AC_MSG_CHECKING([whether we have go ${GO_BEST_MAJOR}.${GO_BEST_MINOR} or newer]) AS_IF([test "${GO_MAJOR}" -gt "${GO_BEST_MAJOR}" || test "${GO_MAJOR}" -eq "${GO_BEST_MAJOR}" -a "${GO_MINOR}" -ge "${GO_BEST_MINOR}"], - [AC_MSG_RESULT([yes]) - RKT_XF() { - AS_ECHO(["-X '$1=$2'"]) - }], + [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) - AC_MSG_CHECKING([whether we have go 1.4]) - AS_IF([test "${GO_MAJOR}" -eq "1" -a "${GO_MINOR}" -eq "4"], - [AC_MSG_RESULT([yes]) - RKT_XF() { - AS_ECHO(["-X $1 '$2'"]) - }], - [AC_MSG_ERROR([*** go is too old (${GO_VERSION})])])]) + AC_MSG_ERROR([*** go is too old (${GO_VERSION})])]) AC_MSG_CHECKING([whether we have a go version without CVE-2015-8618]) AS_IF([test "${GO_MAJOR}" -eq "1" -a "${GO_MINOR}" -eq "5" -a "${GO_MICRO}" -lt "3"], @@ -644,14 +629,13 @@ AS_CASE([$GO_VERSION], [AC_MSG_WARN([* ${insecure_go_warning}])])], [AC_MSG_RESULT([yes])])], [AC_MSG_ERROR([*** Could not parse the output of go version])]) - -RKT_STAGE1_DEFAULT_NAME_LDFLAGS=`RKT_XF main.buildDefaultStage1Name "${RKT_STAGE1_DEFAULT_NAME}"` -RKT_STAGE1_DEFAULT_VERSION_LDFLAGS=`RKT_XF main.buildDefaultStage1Version "${RKT_STAGE1_DEFAULT_VERSION}"` -RKT_STAGE1_DEFAULT_LOCATION_LDFLAGS=`RKT_XF main.buildDefaultStage1ImageLoc "${RKT_STAGE1_DEFAULT_LOCATION}"` -RKT_STAGE1_DEFAULT_IMAGE_FILENAME_LDFLAGS=`RKT_XF main.buildDefaultStage1ImageInRktDir "${RKT_STAGE1_DEFAULT_IMAGE_FILENAME_IN_RKT_DIRECTORY}"` -RKT_STAGE1_DEFAULT_IMAGES_DIRECTORY_LDFLAGS=`RKT_XF main.buildDefaultStage1ImagesDir "${RKT_STAGE1_DEFAULT_IMAGES_DIR}"` -RKT_VERSION_LDFLAGS=`RKT_XF github.com/coreos/rkt/version.Version "${RKT_VERSION}"` -RKT_FEATURES_LDFLAGS=`RKT_XF main.rktFeatures "${RKT_FEATURES}"` +RKT_STAGE1_DEFAULT_NAME_LDFLAGS="-X 'main.buildDefaultStage1Name=${RKT_STAGE1_DEFAULT_NAME}'" +RKT_STAGE1_DEFAULT_VERSION_LDFLAGS="-X 'main.buildDefaultStage1Version=${RKT_STAGE1_DEFAULT_VERSION}'" +RKT_STAGE1_DEFAULT_LOCATION_LDFLAGS="-X 'main.buildDefaultStage1ImageLoc=${RKT_STAGE1_DEFAULT_LOCATION}'" +RKT_STAGE1_DEFAULT_IMAGE_FILENAME_LDFLAGS="-X 'main.buildDefaultStage1ImageInRktDir=${RKT_STAGE1_DEFAULT_IMAGE_FILENAME_IN_RKT_DIRECTORY}'" +RKT_STAGE1_DEFAULT_IMAGES_DIRECTORY_LDFLAGS="-X 'main.buildDefaultStage1ImagesDir=${RKT_STAGE1_DEFAULT_IMAGES_DIR}'" +RKT_VERSION_LDFLAGS="-X 'github.com/coreos/rkt/version.Version=${RKT_VERSION}'" +RKT_FEATURES_LDFLAGS="-X 'main.rktFeatures=${RKT_FEATURES}'" #### SUBSTITUTIONS diff --git a/pkg/log/log.go b/pkg/log/log.go index ac951acdf0..479b1ac69c 100644 --- a/pkg/log/log.go +++ b/pkg/log/log.go @@ -58,13 +58,6 @@ func NewLogSet(prefix string, debug bool) (stderr, diagnostic, stdout *Logger) { // SetDebug sets the debug flag to the value of b func (l *Logger) SetDebug(b bool) { l.debug = b } -// SetOutput sets the output destination for Logger. -// FIXME: We can get rid of this once rkt drops support for 1.4. -func (l *Logger) SetOutput(w io.Writer) { - // No SetOutput exposed in go 1.4. - *l = *New(w, l.Prefix(), l.debug) -} - // SetFlags is a wrapper around log.SetFlags that adds and removes, ": " to and // from a prefix. This is needed because ": " is only added by golang's log // package if either of the Lshortfile or Llongfile flags are set. diff --git a/tests/cloudinit/centos.cloudinit b/tests/cloudinit/centos.cloudinit index 4d4cb67f94..3f4a7e5142 100644 --- a/tests/cloudinit/centos.cloudinit +++ b/tests/cloudinit/centos.cloudinit @@ -12,14 +12,17 @@ groupadd rkt gpasswd -a centos rkt #yum update -y -yum -y -v install epel-release # Needed for golang-vet and golang-cover yum -y -v groupinstall "Development Tools" -yum -y -v install wget squashfs-tools patch glibc-static gnupg golang libacl-devel golang-vet golang-cover - -# # No need to do that with CentOS's go1.4.2 -# # https://github.com/coreos/rkt/pull/1877#issuecomment-169614067 -# GOPATH=/tmp /usr/bin/go get golang.org/x/tools/cmd/vet -# GOPATH=/tmp /usr/bin/go get golang.org/x/tools/cmd/cover +yum -y -v install wget squashfs-tools patch glibc-static gnupg libacl-devel + +pushd /tmp +wget https://storage.googleapis.com/golang/go1.5.3.linux-amd64.tar.gz +popd +tar -C /usr/local -xzf /tmp/go1.5.3.linux-amd64.tar.gz +ln -s /usr/local/go/bin/go /usr/local/bin/go +ln -s /usr/local/go/bin/godoc /usr/local/bin/godoc +ln -s /usr/local/go/bin/gofmt /usr/local/bin/gofmt +export GOROOT=/usr/local/go /usr/sbin/setenforce 0 From 2f39baa87ec0c95f200767ada9c758c72f7a974a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Fri, 18 Mar 2016 16:09:08 +0100 Subject: [PATCH 0003/1304] version: bump to v1.2.0+git --- configure.ac | 2 +- scripts/acbuild-rkt-builder.sh | 2 +- scripts/build-rir.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index e7f3d5a34b..0091edb1c2 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.63]) -AC_INIT([rkt], [1.2.0], [https://github.com/coreos/rkt/issues]) +AC_INIT([rkt], [1.2.0+git], [https://github.com/coreos/rkt/issues]) AC_DEFUN([RKT_CHECK_PROG], [AS_VAR_IF([$1], [], diff --git a/scripts/acbuild-rkt-builder.sh b/scripts/acbuild-rkt-builder.sh index 342b15ce08..536f342713 100755 --- a/scripts/acbuild-rkt-builder.sh +++ b/scripts/acbuild-rkt-builder.sh @@ -25,7 +25,7 @@ ACI_NAME=${ACI_NAME:-"coreos.com/rkt/builder"} BUILDDIR=/opt/build-rkt SRC_DIR=/opt/rkt ACI_GOPATH=/go -VERSION=${VERSION:-"v1.2.0"} +VERSION=${VERSION:-"v1.2.0+git"} echo "Version: $VERSION" echo "Building $ACI_FILE" diff --git a/scripts/build-rir.sh b/scripts/build-rir.sh index b98c5a50bb..577bf1ea21 100755 --- a/scripts/build-rir.sh +++ b/scripts/build-rir.sh @@ -4,7 +4,7 @@ set -xe SRC_DIR=${SRC_DIR:-$PWD} BUILDDIR=${BUILDDIR:-$PWD/build-rir} -RKT_BUILDER_ACI=${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.2.0} +RKT_BUILDER_ACI=${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.2.0+git} mkdir -p $BUILDDIR From 164e2ebb1a2092fc4b713950d3b0f4a5eb89847a Mon Sep 17 00:00:00 2001 From: Yifan Gu Date: Fri, 18 Mar 2016 16:22:50 -0700 Subject: [PATCH 0004/1304] stage1/prepare-app: Do not error out if symlinks exits. If /dev/ptmx or /dev/log already exists in the image, leave it as is instead of overriding it. --- Documentation/app-environment.md | 2 +- stage1/prepare-app/prepare-app.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/app-environment.md b/Documentation/app-environment.md index 077bab40ac..e20a1f3fbf 100644 --- a/Documentation/app-environment.md +++ b/Documentation/app-environment.md @@ -21,4 +21,4 @@ Since rkt v1.2.0, rkt gives access to systemd-journald's sockets in the /run/sys #### /dev/log -Since rkt v1.2.0, /dev/log is created as a symlink to /run/systemd/journal/dev-log. +Since rkt v1.2.0, if /dev/log does not exist in the image, it will be created as a symlink to /run/systemd/journal/dev-log. diff --git a/stage1/prepare-app/prepare-app.c b/stage1/prepare-app/prepare-app.c index 27db950336..30d88173f5 100644 --- a/stage1/prepare-app/prepare-app.c +++ b/stage1/prepare-app/prepare-app.c @@ -283,13 +283,13 @@ int main(int argc, char *argv[]) /* /dev/ptmx -> /dev/pts/ptmx */ exit_if(snprintf(to, sizeof(to), "%s/dev/ptmx", root) >= sizeof(to), "Path too long: \"%s\"", to); - pexit_if(symlink("/dev/pts/ptmx", to) == -1, + pexit_if(symlink("/dev/pts/ptmx", to) == -1 && errno != EEXIST, "Failed to create /dev/ptmx symlink"); /* /dev/log -> /run/systemd/journal/dev-log */ exit_if(snprintf(to, sizeof(to), "%s/dev/log", root) >= sizeof(to), "Path too long: \"%s\"", to); - pexit_if(symlink("/run/systemd/journal/dev-log", to) == -1, + pexit_if(symlink("/run/systemd/journal/dev-log", to) == -1 && errno != EEXIST, "Failed to create /dev/log symlink"); return EXIT_SUCCESS; From dc741e9b3e3d8e096530756f84c9468f07282f47 Mon Sep 17 00:00:00 2001 From: David Castillo Date: Sat, 19 Mar 2016 00:40:50 -0500 Subject: [PATCH 0005/1304] docs: fix typos in hacking guide. --- Documentation/hacking.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/hacking.md b/Documentation/hacking.md index 059a480296..c6d1009a4f 100644 --- a/Documentation/hacking.md +++ b/Documentation/hacking.md @@ -7,7 +7,7 @@ For more information on the rkt internals, see the [`devel`](devel/) documentati ## Building rkt -rkt should be able to be built on any modern Linux system. +You should be able build rkt on any modern Linux system. For the most part the codebase is self-contained (e.g. all dependencies are vendored), but assembly of the stage1 requires some other tools to be installed on the system. Please see [the list of the build-time dependencies](dependencies.md#build-time-dependencies). Once the dependenciess have been satisfied you can build rkt by running the following commands: @@ -225,7 +225,7 @@ rkt attempts to offer consistent and structured error output. To achieve this, w ### Wrapping errors -rkt uses the errwrap package to structure errors. This allows us to manages how we output errors. You can wrap errors by doing the following. +rkt uses the errwrap package to structure errors. This allows us to manage how we output errors. You can wrap errors by doing the following. ``` err := funcReturningSomeError() From 5cb76ddc10b7f2dc55d4f1a1fdb03f33f97db48c Mon Sep 17 00:00:00 2001 From: David Castillo Date: Sun, 20 Mar 2016 13:22:50 -0500 Subject: [PATCH 0006/1304] docs: fix typo in hacking.md. --- Documentation/hacking.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/hacking.md b/Documentation/hacking.md index c6d1009a4f..cb00f46970 100644 --- a/Documentation/hacking.md +++ b/Documentation/hacking.md @@ -10,7 +10,7 @@ For more information on the rkt internals, see the [`devel`](devel/) documentati You should be able build rkt on any modern Linux system. For the most part the codebase is self-contained (e.g. all dependencies are vendored), but assembly of the stage1 requires some other tools to be installed on the system. Please see [the list of the build-time dependencies](dependencies.md#build-time-dependencies). -Once the dependenciess have been satisfied you can build rkt by running the following commands: +Once the dependencies have been satisfied you can build rkt by running the following commands: ``` git clone https://github.com/coreos/rkt.git @@ -258,7 +258,7 @@ Here, the prefix is an empty string and debug is set to `false`. ## Finishing Up -At this point, you should be good to PR. +At this point, you should be good to submit a PR. As well as a simple sanity check that the code actually builds and tests pass, here are some things to look out for: - `git status Godeps/` should show only a minimal and relevant change (i.e. only the dependencies you actually intended to touch). - `git diff Godeps/` should be free of any changes to import paths within the vendored dependencies From 812506598fcbef69c036edf4e2edecf344f7ef8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Mon, 21 Mar 2016 14:08:48 +0100 Subject: [PATCH 0007/1304] Godeps: bump go-systemd to v5 --- Godeps/Godeps.json | 16 +++--- .../coreos/go-systemd/dbus/methods.go | 54 +++++++++++++++---- .../github.com/coreos/go-systemd/util/util.go | 16 +++++- 3 files changed, 66 insertions(+), 20 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index edda092aa1..c34c51d13a 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -226,23 +226,23 @@ }, { "ImportPath": "github.com/coreos/go-systemd/activation", - "Comment": "v4-15-ga831f36", - "Rev": "a831f36d09de8f095c28eeee839df52e9de5031f" + "Comment": "v5", + "Rev": "7b2428fec40033549c68f54e26e89e7ca9a9ce31" }, { "ImportPath": "github.com/coreos/go-systemd/dbus", - "Comment": "v4-15-ga831f36", - "Rev": "a831f36d09de8f095c28eeee839df52e9de5031f" + "Comment": "v5", + "Rev": "7b2428fec40033549c68f54e26e89e7ca9a9ce31" }, { "ImportPath": "github.com/coreos/go-systemd/unit", - "Comment": "v4-15-ga831f36", - "Rev": "a831f36d09de8f095c28eeee839df52e9de5031f" + "Comment": "v5", + "Rev": "7b2428fec40033549c68f54e26e89e7ca9a9ce31" }, { "ImportPath": "github.com/coreos/go-systemd/util", - "Comment": "v4-15-ga831f36", - "Rev": "a831f36d09de8f095c28eeee839df52e9de5031f" + "Comment": "v5", + "Rev": "7b2428fec40033549c68f54e26e89e7ca9a9ce31" }, { "ImportPath": "github.com/coreos/go-tspi/attestation", diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/methods.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/methods.go index ab614c7c63..f9552a3380 100644 --- a/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/methods.go +++ b/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/methods.go @@ -221,6 +221,19 @@ func (c *Conn) GetUnitTypeProperty(unit string, unitType string, propertyName st return c.getProperty(unit, "org.freedesktop.systemd1."+unitType, propertyName) } +type UnitStatus struct { + Name string // The primary unit name as string + Description string // The human readable description string + LoadState string // The load state (i.e. whether the unit file has been loaded successfully) + ActiveState string // The active state (i.e. whether the unit is currently started or not) + SubState string // The sub state (a more fine-grained version of the active state that is specific to the unit type, which the active state is not) + Followed string // A unit that is being followed in its state by this unit, if there is any, otherwise the empty string. + Path dbus.ObjectPath // The unit object path + JobId uint32 // If there is a job queued for the job unit the numeric job id, 0 otherwise + JobType string // The job type as string + JobPath dbus.ObjectPath // The job object path +} + // ListUnits returns an array with all currently loaded units. Note that // units may be known by multiple names at the same time, and hence there might // be more unit names loaded than actual units behind them. @@ -250,17 +263,36 @@ func (c *Conn) ListUnits() ([]UnitStatus, error) { return status, nil } -type UnitStatus struct { - Name string // The primary unit name as string - Description string // The human readable description string - LoadState string // The load state (i.e. whether the unit file has been loaded successfully) - ActiveState string // The active state (i.e. whether the unit is currently started or not) - SubState string // The sub state (a more fine-grained version of the active state that is specific to the unit type, which the active state is not) - Followed string // A unit that is being followed in its state by this unit, if there is any, otherwise the empty string. - Path dbus.ObjectPath // The unit object path - JobId uint32 // If there is a job queued for the job unit the numeric job id, 0 otherwise - JobType string // The job type as string - JobPath dbus.ObjectPath // The job object path +type UnitFile struct { + Path string + Type string +} + +// ListUnitFiles returns an array of all available units on disk. +func (c *Conn) ListUnitFiles() ([]UnitFile, error) { + result := make([][]interface{}, 0) + err := c.sysobj.Call("org.freedesktop.systemd1.Manager.ListUnitFiles", 0).Store(&result) + if err != nil { + return nil, err + } + + resultInterface := make([]interface{}, len(result)) + for i := range result { + resultInterface[i] = result[i] + } + + files := make([]UnitFile, len(result)) + fileInterface := make([]interface{}, len(files)) + for i := range files { + fileInterface[i] = &files[i] + } + + err = dbus.Store(resultInterface, fileInterface...) + if err != nil { + return nil, err + } + + return files, nil } type LinkUnitFileChange EnableUnitFileChange diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/util/util.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/util/util.go index 0863665774..f9f0b2a35a 100644 --- a/Godeps/_workspace/src/github.com/coreos/go-systemd/util/util.go +++ b/Godeps/_workspace/src/github.com/coreos/go-systemd/util/util.go @@ -60,7 +60,9 @@ import "C" import ( "errors" "fmt" + "io/ioutil" "os" + "strings" "syscall" "unsafe" ) @@ -244,7 +246,7 @@ func CurrentUnitName() (unit string, err error) { } // IsRunningSystemd checks whether the host was booted with systemd as its init -// system. This functions similar to systemd's `sd_booted(3)`: internally, it +// system. This functions similarly to systemd's `sd_booted(3)`: internally, it // checks whether /run/systemd/system/ exists and is a directory. // http://www.freedesktop.org/software/systemd/man/sd_booted.html func IsRunningSystemd() bool { @@ -254,3 +256,15 @@ func IsRunningSystemd() bool { } return fi.IsDir() } + +// GetMachineID returns a host's 128-bit machine ID as a string. This functions +// similarly to systemd's `sd_id128_get_machine`: internally, it simply reads +// the contents of /etc/machine-id +// http://www.freedesktop.org/software/systemd/man/sd_id128_get_machine.html +func GetMachineID() (string, error) { + machineID, err := ioutil.ReadFile("/etc/machine-id") + if err != nil { + return "", fmt.Errorf("failed to read /etc/machine-id: %v", err) + } + return strings.TrimSpace(string(machineID)), nil +} From 0502fa06dce78b232352d28f578a2b2a7971eb49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Mon, 21 Mar 2016 14:15:37 +0100 Subject: [PATCH 0008/1304] stage1/init: remove unnecessary arg to systemd Since v222, systemd-shutdown follows `--log-target` so we don't need to pass `--log-level=warning` anymore. --- stage1/init/init.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/stage1/init/init.go b/stage1/init/init.go index f7bc046d0c..6d09258f29 100644 --- a/stage1/init/init.go +++ b/stage1/init/init.go @@ -430,9 +430,7 @@ func getArgsEnv(p *stage1commontypes.Pod, flavor string, debug bool, n *networki args = append(args, "--default-standard-output=tty") // redirect all service logs straight to tty if !debug { args = append(args, "--log-target=null") // silence systemd output inside pod - // TODO remove --log-level=warning when we update stage1 to systemd v222 - args = append(args, "--log-level=warning") // limit log output (systemd-shutdown ignores --log-target) - args = append(args, "--show-status=0") // silence systemd initialization status output + args = append(args, "--show-status=0") // silence systemd initialization status output } return args, env, nil From fe5033e5caa3392c59d83f23dca5f21c3a38241b Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Tue, 22 Mar 2016 17:51:19 +0100 Subject: [PATCH 0009/1304] docs: update rktnetes link --- Documentation/using-rkt-with-kubernetes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/using-rkt-with-kubernetes.md b/Documentation/using-rkt-with-kubernetes.md index e24d2925ec..6b8124aeba 100644 --- a/Documentation/using-rkt-with-kubernetes.md +++ b/Documentation/using-rkt-with-kubernetes.md @@ -14,9 +14,9 @@ The kubelet provides several flags to use rkt as the container runtime: - `--rkt-path` sets the rkt binary path. - `--rkt-stage1-image` sets the stage1 image path. -The [getting started with rkt guide][] in the Kubernetes repository provides more detailed information about how to launch a kubernetes cluster with rkt, how to debug it, and more. +The [getting started with rkt guide][] in the upstream Kubernetes documentation provides more detailed information about how to launch a kubernetes cluster with rkt, how to debug it, and more. -[getting started with rkt guide]: https://github.com/kubernetes/kubernetes/blob/master/docs/getting-started-guides/rkt/README.md +[getting started with rkt guide]: http://kubernetes.io/docs/getting-started-guides/rkt/ ### Current Status From a085e84bed0d14af5202f815d72da445f3acaa3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Mon, 21 Mar 2016 17:19:22 +0100 Subject: [PATCH 0010/1304] CHANGELOG: v1.2.1 --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c2b949bab0..89fbe458f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## v1.2.1 + +This release fixes a couple of bugs we missed in 1.2.0. + +#### Bug fixes + +- Do not error out if `/dev/ptmx` or `/dev/log` exist ([#2302](https://github.com/coreos/rkt/pull/2302)). +- Vendor a release of go-systemd instead of current master ([#2306](https://github.com/coreos/rkt/pull/2306)). + ## v1.2.0 This release is an incremental release with numerous bug fixes. From 585b6ef69c008ac7af449b94964007e4c217bd04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Mon, 21 Mar 2016 17:19:56 +0100 Subject: [PATCH 0011/1304] version: bump to v1.2.1 --- Documentation/getting-started-ubuntu.md | 6 +++--- Documentation/running-fly-stage1.md | 2 +- Documentation/running-lkvm-stage1.md | 2 +- Documentation/subcommands/prepare.md | 2 +- Documentation/subcommands/version.md | 2 +- Documentation/trying-out-rkt.md | 6 +++--- configure.ac | 2 +- scripts/acbuild-rkt-builder.sh | 2 +- scripts/build-rir.sh | 2 +- tests/empty-image/manifest | 2 +- tests/image/manifest | 2 +- tests/rkt_exec_test.go | 2 +- tests/rkt_image_cat_manifest_test.go | 2 +- tests/rkt_image_export_test.go | 2 +- tests/rkt_image_render_test.go | 2 +- tests/rkt_os_arch_test.go | 2 +- 16 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Documentation/getting-started-ubuntu.md b/Documentation/getting-started-ubuntu.md index ba17acd952..86672711a7 100644 --- a/Documentation/getting-started-ubuntu.md +++ b/Documentation/getting-started-ubuntu.md @@ -15,9 +15,9 @@ vagrant up --provider virtualbox vagrant ssh sudo -s -wget https://github.com/coreos/rkt/releases/download/v1.2.0/rkt-v1.2.0.tar.gz -tar xzvf rkt-v1.2.0.tar.gz -cd rkt-v1.2.0 +wget https://github.com/coreos/rkt/releases/download/v1.2.1/rkt-v1.2.1.tar.gz +tar xzvf rkt-v1.2.1.tar.gz +cd rkt-v1.2.1 ./rkt help ``` diff --git a/Documentation/running-fly-stage1.md b/Documentation/running-fly-stage1.md index dd2dfe7e89..97f792e037 100644 --- a/Documentation/running-fly-stage1.md +++ b/Documentation/running-fly-stage1.md @@ -60,7 +60,7 @@ $ ./autogen.sh && ./configure --with-stage1-flavors=fly && make ``` For more details about configure parameters, see the [configure script parameters documentation](build-configure.md). -This will build the rkt binary and the stage1-fly.aci in `build-rkt-1.2.0+git/bin/`. +This will build the rkt binary and the stage1-fly.aci in `build-rkt-1.2.1+git/bin/`. ### Selecting stage1 at runtime diff --git a/Documentation/running-lkvm-stage1.md b/Documentation/running-lkvm-stage1.md index cda5a325ad..e7e554d3b0 100644 --- a/Documentation/running-lkvm-stage1.md +++ b/Documentation/running-lkvm-stage1.md @@ -13,7 +13,7 @@ $ ./autogen.sh && ./configure --with-stage1-flavors=kvm && make ``` For more details about configure parameters, see [configure script parameters documentation](build-configure.md). -This will build the rkt binary and the LKVM stage1-kvm.aci in `build-rkt-1.2.0+git/bin/`. +This will build the rkt binary and the LKVM stage1-kvm.aci in `build-rkt-1.2.1+git/bin/`. Provided you have hardware virtualization support and the [kernel KVM module](http://www.linux-kvm.org/page/Getting_the_kvm_kernel_modules) loaded (refer to your distribution for instructions), you can then run an image like you would normally do with rkt: diff --git a/Documentation/subcommands/prepare.md b/Documentation/subcommands/prepare.md index b578d3ee93..2cc71d0e02 100644 --- a/Documentation/subcommands/prepare.md +++ b/Documentation/subcommands/prepare.md @@ -14,7 +14,7 @@ Therefore, the supported arguments are mostly the same as in `run` except runtim ``` # rkt prepare coreos.com/etcd:v2.0.10 rkt prepare coreos.com/etcd:v2.0.10 -rkt: using image from local store for image name coreos.com/rkt/stage1-coreos:1.2.0 +rkt: using image from local store for image name coreos.com/rkt/stage1-coreos:1.2.1 rkt: searching for app image coreos.com/etcd:v2.0.10 rkt: remote fetching from url https://github.com/coreos/etcd/releases/download/v2.0.10/etcd-v2.0.10-linux-amd64.aci prefix: "coreos.com/etcd" diff --git a/Documentation/subcommands/version.md b/Documentation/subcommands/version.md index 91162e1c7e..905dba5666 100644 --- a/Documentation/subcommands/version.md +++ b/Documentation/subcommands/version.md @@ -6,7 +6,7 @@ This command prints the rkt version, the appc version rkt is built against, and ``` $ rkt version -rkt Version: 1.2.0 +rkt Version: 1.2.1 appc Version: 0.7.4 Go Version: go1.5.3 Go OS/Arch: linux/amd64 diff --git a/Documentation/trying-out-rkt.md b/Documentation/trying-out-rkt.md index 21492bb0be..909c515bbb 100644 --- a/Documentation/trying-out-rkt.md +++ b/Documentation/trying-out-rkt.md @@ -10,9 +10,9 @@ rkt consists of a single CLI tool, and is currently supported on amd64 Linux. A To download the rkt binary, simply grab the latest release directly from GitHub: ``` -wget https://github.com/coreos/rkt/releases/download/v1.2.0/rkt-v1.2.0.tar.gz -tar xzvf rkt-v1.2.0.tar.gz -cd rkt-v1.2.0 +wget https://github.com/coreos/rkt/releases/download/v1.2.1/rkt-v1.2.1.tar.gz +tar xzvf rkt-v1.2.1.tar.gz +cd rkt-v1.2.1 ./rkt help ``` diff --git a/configure.ac b/configure.ac index 0091edb1c2..c16ded3aba 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.63]) -AC_INIT([rkt], [1.2.0+git], [https://github.com/coreos/rkt/issues]) +AC_INIT([rkt], [1.2.1], [https://github.com/coreos/rkt/issues]) AC_DEFUN([RKT_CHECK_PROG], [AS_VAR_IF([$1], [], diff --git a/scripts/acbuild-rkt-builder.sh b/scripts/acbuild-rkt-builder.sh index 536f342713..36b17a7e60 100755 --- a/scripts/acbuild-rkt-builder.sh +++ b/scripts/acbuild-rkt-builder.sh @@ -25,7 +25,7 @@ ACI_NAME=${ACI_NAME:-"coreos.com/rkt/builder"} BUILDDIR=/opt/build-rkt SRC_DIR=/opt/rkt ACI_GOPATH=/go -VERSION=${VERSION:-"v1.2.0+git"} +VERSION=${VERSION:-"v1.2.1"} echo "Version: $VERSION" echo "Building $ACI_FILE" diff --git a/scripts/build-rir.sh b/scripts/build-rir.sh index 577bf1ea21..3ab2375f72 100755 --- a/scripts/build-rir.sh +++ b/scripts/build-rir.sh @@ -4,7 +4,7 @@ set -xe SRC_DIR=${SRC_DIR:-$PWD} BUILDDIR=${BUILDDIR:-$PWD/build-rir} -RKT_BUILDER_ACI=${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.2.0+git} +RKT_BUILDER_ACI=${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.2.1} mkdir -p $BUILDDIR diff --git a/tests/empty-image/manifest b/tests/empty-image/manifest index aec1b5fbf0..09c7e908ef 100644 --- a/tests/empty-image/manifest +++ b/tests/empty-image/manifest @@ -5,7 +5,7 @@ "labels": [ { "name": "version", - "value": "1.2.0" + "value": "1.2.1" }, { "name": "arch", diff --git a/tests/image/manifest b/tests/image/manifest index 36af2cccc0..73913d743b 100644 --- a/tests/image/manifest +++ b/tests/image/manifest @@ -5,7 +5,7 @@ "labels": [ { "name": "version", - "value": "1.2.0" + "value": "1.2.1" }, { "name": "arch", diff --git a/tests/rkt_exec_test.go b/tests/rkt_exec_test.go index 5e3eb50d2c..9696bacd81 100644 --- a/tests/rkt_exec_test.go +++ b/tests/rkt_exec_test.go @@ -24,7 +24,7 @@ import ( ) const ( - noappManifestStr = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"coreos.com/rkt-inspect","labels":[{"name":"version","value":"1.2.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}]}` + noappManifestStr = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"coreos.com/rkt-inspect","labels":[{"name":"version","value":"1.2.1"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}]}` ) func TestRunOverrideExec(t *testing.T) { diff --git a/tests/rkt_image_cat_manifest_test.go b/tests/rkt_image_cat_manifest_test.go index 5ddd3b1952..72dd1e5948 100644 --- a/tests/rkt_image_cat_manifest_test.go +++ b/tests/rkt_image_cat_manifest_test.go @@ -27,7 +27,7 @@ import ( const ( // The expected image manifest of the 'rkt-inspect-image-cat-manifest.aci'. - manifestTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.2.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.2.1"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageCatManifest tests 'rkt image cat-manifest', it will: diff --git a/tests/rkt_image_export_test.go b/tests/rkt_image_export_test.go index 1e93222ab1..fd48d7a8f2 100644 --- a/tests/rkt_image_export_test.go +++ b/tests/rkt_image_export_test.go @@ -26,7 +26,7 @@ import ( ) const ( - manifestExportTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.2.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestExportTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.2.1"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageExport tests 'rkt image export', it will import some existing diff --git a/tests/rkt_image_render_test.go b/tests/rkt_image_render_test.go index cfc4e2b78b..8abba1a4e2 100644 --- a/tests/rkt_image_render_test.go +++ b/tests/rkt_image_render_test.go @@ -26,7 +26,7 @@ import ( ) const ( - manifestRenderTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.2.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"dependencies":[{"imageName":"coreos.com/rkt-inspect"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestRenderTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.2.1"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"dependencies":[{"imageName":"coreos.com/rkt-inspect"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageRender tests 'rkt image render', it will import some existing empty diff --git a/tests/rkt_os_arch_test.go b/tests/rkt_os_arch_test.go index 6f4cb5c187..ef5165ffad 100644 --- a/tests/rkt_os_arch_test.go +++ b/tests/rkt_os_arch_test.go @@ -25,7 +25,7 @@ import ( ) const ( - manifestOSArchTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.2.0"}ARCH_OS],"app":{"exec":["/inspect", "--print-msg=HelloWorld"],"user":"0","group":"0","workingDirectory":"/"}}` + manifestOSArchTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.2.1"}ARCH_OS],"app":{"exec":["/inspect", "--print-msg=HelloWorld"],"user":"0","group":"0","workingDirectory":"/"}}` ) type osArchTest struct { From 2c055c690eaaa05f53717fc7a9e7cfa4efd85279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Mon, 21 Mar 2016 17:19:56 +0100 Subject: [PATCH 0012/1304] version: bump to v1.2.1+git --- configure.ac | 2 +- scripts/acbuild-rkt-builder.sh | 2 +- scripts/build-rir.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index c16ded3aba..d0d0fa5d38 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.63]) -AC_INIT([rkt], [1.2.1], [https://github.com/coreos/rkt/issues]) +AC_INIT([rkt], [1.2.1+git], [https://github.com/coreos/rkt/issues]) AC_DEFUN([RKT_CHECK_PROG], [AS_VAR_IF([$1], [], diff --git a/scripts/acbuild-rkt-builder.sh b/scripts/acbuild-rkt-builder.sh index 36b17a7e60..1e5ef7a12a 100755 --- a/scripts/acbuild-rkt-builder.sh +++ b/scripts/acbuild-rkt-builder.sh @@ -25,7 +25,7 @@ ACI_NAME=${ACI_NAME:-"coreos.com/rkt/builder"} BUILDDIR=/opt/build-rkt SRC_DIR=/opt/rkt ACI_GOPATH=/go -VERSION=${VERSION:-"v1.2.1"} +VERSION=${VERSION:-"v1.2.1+git"} echo "Version: $VERSION" echo "Building $ACI_FILE" diff --git a/scripts/build-rir.sh b/scripts/build-rir.sh index 3ab2375f72..8db2ec9076 100755 --- a/scripts/build-rir.sh +++ b/scripts/build-rir.sh @@ -4,7 +4,7 @@ set -xe SRC_DIR=${SRC_DIR:-$PWD} BUILDDIR=${BUILDDIR:-$PWD/build-rir} -RKT_BUILDER_ACI=${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.2.1} +RKT_BUILDER_ACI=${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.2.1+git} mkdir -p $BUILDDIR From 423f233fe49ff67f1dc2cb86fbccda9be10ed953 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Wed, 23 Mar 2016 12:03:25 +0100 Subject: [PATCH 0013/1304] tests: aws: update Fedora images Fedora images get published on AWS again. It broke in February, and was repaired yesterday. We can now test on more recent images. --- tests/aws.sh | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/tests/aws.sh b/tests/aws.sh index 302ba69ea0..7d55cff9f5 100755 --- a/tests/aws.sh +++ b/tests/aws.sh @@ -47,21 +47,16 @@ if [ "$DISTRO" = "fedora-22" ] ; then # https://apps.fedoraproject.org/datagrepper/raw?category=fedimg # Sources: https://github.com/fedora-infra/fedimg/blob/develop/bin/list-the-amis.py - # Fedora-Cloud-Base-22-20151026.x86_64-eu-central-1-HVM-standard-0 was deleted - - # Fedora-Cloud-Base-22-20150521.x86_64-eu-central-1-HVM-standard-0 - AMI=ami-a88eb0b5 + # Fedora-Cloud-Base-22-20160218.x86_64-eu-central-1-HVM-standard-0 + AMI=ami-7a1b0116 AWS_USER=fedora elif [ "$DISTRO" = "fedora-23" ] ; then - # Fedora-Cloud-Base-23-20160129.x86_64-eu-central-1-HVM-standard-0 - AMI=ami-4d3e2621 + # Fedora-Cloud-Base-23-20160323.x86_64-eu-central-1-HVM-standard-0 + AMI=ami-d59670ba AWS_USER=fedora elif [ "$DISTRO" = "fedora-rawhide" ] ; then - # rawhide is currently broken - # Error: nothing provides libpsl.so.0()(64bit) needed by wget-1.17.1-1.fc24.x86_64 - - # Fedora-Cloud-Base-rawhide-20160127.x86_64-eu-central-1-HVM-standard-0 - AMI=ami-877068eb + # Fedora-Cloud-Base-Rawhide-20160321.0.x86_64-eu-central-1-HVM-standard-0 + AMI=ami-69967006 AWS_USER=fedora elif [ "$DISTRO" = "ubuntu-1604" ] ; then # https://cloud-images.ubuntu.com/locator/ec2/ From 16c36d92ffc715c595a670be191128b9c62d80e3 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Wed, 23 Mar 2016 13:41:18 +0100 Subject: [PATCH 0014/1304] tests: aws: add workarounds for Fedora Fedora-Rawhide: keep SELinux enabled but disable overlayfs. --- tests/aws.sh | 15 ++++++++++++++- tests/cloudinit/fedora.cloudinit | 16 +++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/tests/aws.sh b/tests/aws.sh index 7d55cff9f5..5e1953cf79 100755 --- a/tests/aws.sh +++ b/tests/aws.sh @@ -50,14 +50,25 @@ if [ "$DISTRO" = "fedora-22" ] ; then # Fedora-Cloud-Base-22-20160218.x86_64-eu-central-1-HVM-standard-0 AMI=ami-7a1b0116 AWS_USER=fedora + + # Workarounds + DISABLE_SELINUX=true elif [ "$DISTRO" = "fedora-23" ] ; then # Fedora-Cloud-Base-23-20160323.x86_64-eu-central-1-HVM-standard-0 AMI=ami-d59670ba AWS_USER=fedora + + # Workarounds + DISABLE_SELINUX=true elif [ "$DISTRO" = "fedora-rawhide" ] ; then # Fedora-Cloud-Base-Rawhide-20160321.0.x86_64-eu-central-1-HVM-standard-0 AMI=ami-69967006 AWS_USER=fedora + + # Workarounds + # systemd in stage1 does not have the fixes for SELinux yet + FLAVOR=host + DISABLE_OVERLAY=true elif [ "$DISTRO" = "ubuntu-1604" ] ; then # https://cloud-images.ubuntu.com/locator/ec2/ # ubuntu/images-milestone/hvm/ubuntu-xenial-alpha2-amd64-server-20160125 @@ -89,6 +100,8 @@ CLOUDINIT=$(mktemp --tmpdir rkt-cloudinit.XXXXXXXXXX) sed -e "s#@GIT_URL@#${GIT_URL}#g" \ -e "s#@GIT_BRANCH@#${GIT_BRANCH}#g" \ -e "s#@FLAVOR@#${FLAVOR}#g" \ + -e "s#@DISABLE_SELINUX@#${DISABLE_SELINUX}#g" \ + -e "s#@DISABLE_OVERLAY@#${DISABLE_OVERLAY}#g" \ < $CLOUDINIT_IN >> $CLOUDINIT INSTANCE_ID=$(aws ec2 run-instances \ @@ -96,7 +109,7 @@ INSTANCE_ID=$(aws ec2 run-instances \ --count 1 \ --key-name $KEY_PAIR_NAME \ --security-groups $SECURITY_GROUP \ - --instance-type t2.micro \ + --instance-type m4.large \ --instance-initiated-shutdown-behavior terminate \ --user-data file://$CLOUDINIT \ --output text \ diff --git a/tests/cloudinit/fedora.cloudinit b/tests/cloudinit/fedora.cloudinit index b9a5d4051b..eabe16a70c 100644 --- a/tests/cloudinit/fedora.cloudinit +++ b/tests/cloudinit/fedora.cloudinit @@ -1,7 +1,14 @@ #!/bin/bash -# Workarounds on Fedora -/usr/sbin/setenforce 0 +if [ "@DISABLE_OVERLAY@" = true ] ; then + # Workaround for SELinux: do not use overlay fs + /sbin/rmmod overlay || true + mv /lib/modules/`uname -r`/kernel/fs/overlayfs/overlay.ko.xz /root/overlay.ko.xz-disabled +fi + +if [ "@DISABLE_SELINUX@" = true ] ; then + /usr/sbin/setenforce 0 +fi cat > /var/tmp/rkt-test.sh < Date: Mon, 21 Mar 2016 14:43:09 +0100 Subject: [PATCH 0015/1304] stage1: update to systemd v225 on the coreos flavor --- stage1/usr_from_coreos/coreos-common.mk | 4 ++-- stage1/usr_from_coreos/manifest.d/bash.manifest | 8 ++++---- .../usr_from_coreos/manifest.d/systemd.manifest | 16 ++++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/stage1/usr_from_coreos/coreos-common.mk b/stage1/usr_from_coreos/coreos-common.mk index add1b2ecff..72197709e7 100644 --- a/stage1/usr_from_coreos/coreos-common.mk +++ b/stage1/usr_from_coreos/coreos-common.mk @@ -9,9 +9,9 @@ _CCN_INCLUDED_ := x $(call setup-tmp-dir,CCN_TMPDIR) # systemd version in coreos image -CCN_SYSTEMD_VERSION := v222 +CCN_SYSTEMD_VERSION := v225 # coreos image version -CCN_IMG_RELEASE := 794.1.0 +CCN_IMG_RELEASE := 991.0.0 # coreos image URL CCN_IMG_URL := http://alpha.release.core-os.net/amd64-usr/$(CCN_IMG_RELEASE)/coreos_production_pxe_image.cpio.gz # path to downloaded pxe image diff --git a/stage1/usr_from_coreos/manifest.d/bash.manifest b/stage1/usr_from_coreos/manifest.d/bash.manifest index 523f4c0fa7..a74b266609 100644 --- a/stage1/usr_from_coreos/manifest.d/bash.manifest +++ b/stage1/usr_from_coreos/manifest.d/bash.manifest @@ -1,9 +1,9 @@ bin/bash -lib64/ld-2.20.so +lib64/ld-2.21.so lib64/ld-linux-x86-64.so.2 -lib64/libc-2.20.so +lib64/libc-2.21.so lib64/libc.so.6 -lib64/libdl-2.20.so +lib64/libdl-2.21.so lib64/libdl.so lib64/libdl.so.2 lib64/libncurses.so @@ -11,4 +11,4 @@ lib64/libncurses.so.5 lib64/libncurses.so.5.9 lib64/libreadline.so lib64/libreadline.so.6 -lib64/libreadline.so.6.2 +lib64/libreadline.so.6.3 diff --git a/stage1/usr_from_coreos/manifest.d/systemd.manifest b/stage1/usr_from_coreos/manifest.d/systemd.manifest index f91829d2d2..8ba84bfc19 100644 --- a/stage1/usr_from_coreos/manifest.d/systemd.manifest +++ b/stage1/usr_from_coreos/manifest.d/systemd.manifest @@ -20,7 +20,7 @@ bin/systemd-sysusers bin/systemd-tmpfiles bin/systemd-tty-ask-password-agent lib -lib64/ld-2.20.so +lib64/ld-2.21.so lib64/ld-linux-x86-64.so.2 lib64/libattr.so lib64/libattr.so.1 @@ -31,16 +31,16 @@ lib64/libaudit.so.1.0.0 lib64/libblkid.so lib64/libblkid.so.1 lib64/libblkid.so.1.1.0 -lib64/libc-2.20.so +lib64/libc-2.21.so lib64/libcap.so lib64/libcap.so.2 -lib64/libcap.so.2.22 +lib64/libcap.so.2.24 lib64/libc.so.6 lib64/libgcc_s.so lib64/libgcc_s.so.1 lib64/libgcrypt.so -lib64/libgcrypt.so.11 -lib64/libgcrypt.so.11.8.2 +lib64/libgcrypt.so.20 +lib64/libgcrypt.so.20.0.3 lib64/libgpg-error.so lib64/libgpg-error.so.0 lib64/libgpg-error.so.0.10.0 @@ -52,7 +52,7 @@ lib64/libip4tc.so.0 lib64/libip4tc.so.0.1.0 lib64/libkmod.so lib64/libkmod.so.2 -lib64/libkmod.so.2.2.5 +lib64/libkmod.so.2.2.11 lib64/liblzma.so lib64/liblzma.so.5 lib64/liblzma.so.5.0.8 @@ -62,10 +62,10 @@ lib64/libmount.so.1.1.0 lib64/libpcre.so lib64/libpcre.so.1 lib64/libpcre.so.1.2.4 -lib64/libpthread-2.20.so +lib64/libpthread-2.21.so lib64/libpthread.so lib64/libpthread.so.0 -lib64/librt-2.20.so +lib64/librt-2.21.so lib64/librt.so lib64/librt.so.1 lib64/libseccomp.so From f5fd7b7c1c08f152385b2e83a06e1ca851a0a0e8 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Thu, 17 Mar 2016 14:34:13 +0100 Subject: [PATCH 0016/1304] stage1: exit code: use systemctl exit on coreos flavor The exit status can be propagated from apps by using "systemctl exit" since systemd v227. rkt checks the systemd version to know whether it can use "systemctl exit". However, systemd from coreos is back porting the patches, so we skip the systemd version check on the coreos flavor. See https://github.com/coreos/rkt/issues/1460 --- stage1/init/common/pod.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index 44954e1a1d..d108023eb6 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -472,7 +472,7 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b } func writeShutdownService(p *stage1commontypes.Pod) error { - _, systemdVersion, err := GetFlavor(p) + flavor, systemdVersion, err := GetFlavor(p) if err != nil { return err } @@ -493,7 +493,10 @@ func writeShutdownService(p *stage1commontypes.Pod) error { // This can happen, for example, when building rkt with: // // ./configure --with-stage1-flavors=src --with-stage1-systemd-version=master - if systemdVersion != 0 && systemdVersion < 227 { + // + // The patches for the "exit" verb are backported to the "coreos" flavor, so + // don't rely on the systemd version on the "coreos" flavor. + if flavor != "coreos" && systemdVersion != 0 && systemdVersion < 227 { shutdownVerb = "halt" } From 862953ce0fbf0808e327643fd614fa4ba117fe8b Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Fri, 18 Mar 2016 17:35:32 +0100 Subject: [PATCH 0017/1304] tests: exit code: don't return 42 without reason Now that the exit code is propagated from the app to rkt, returning 42 from /inspect would make the rkt command fails. The API service tests don't actually test the exit code, so it is safe to remove that. --- tests/rkt_api_service_bench_test.go | 2 +- tests/rkt_api_service_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/rkt_api_service_bench_test.go b/tests/rkt_api_service_bench_test.go index b006283d92..1104efdbbb 100644 --- a/tests/rkt_api_service_bench_test.go +++ b/tests/rkt_api_service_bench_test.go @@ -32,7 +32,7 @@ func setup() (*testutils.RktRunCtx, *gexpect.ExpectSubprocess, v1alpha.PublicAPI ctx := testutils.NewRktRunCtx() svc := startAPIService(t, ctx) c, conn := newAPIClientOrFail(t, "localhost:15441") - imagePath := patchTestACI("rkt-inspect-print.aci", "--exec=/inspect --print-msg=HELLO_API --exit-code=42") + imagePath := patchTestACI("rkt-inspect-print.aci", "--exec=/inspect --print-msg=HELLO_API") return ctx, svc, c, conn, imagePath } diff --git a/tests/rkt_api_service_test.go b/tests/rkt_api_service_test.go index e051fca5a0..9bb3c0d729 100644 --- a/tests/rkt_api_service_test.go +++ b/tests/rkt_api_service_test.go @@ -284,7 +284,7 @@ func TestAPIServiceListInspectPods(t *testing.T) { t.Errorf("Unexpected result: %v, should see zero pods", resp.Pods) } - patches := []string{"--exec=/inspect --print-msg=HELLO_API --exit-code=42"} + patches := []string{"--exec=/inspect --print-msg=HELLO_API --exit-code=0"} imageHash := patchImportAndFetchHash("rkt-inspect-print.aci", patches, t, ctx) imgID, err := types.NewHash(imageHash) if err != nil { From 4b4cb769d6d6602117bff47538f6cbb269f003cd Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Fri, 18 Mar 2016 18:22:59 +0100 Subject: [PATCH 0018/1304] tests: exit code: fix TestDNS --- tests/rkt_dns_test.go | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/tests/rkt_dns_test.go b/tests/rkt_dns_test.go index 4c4e173fb3..6d80ff9e1c 100644 --- a/tests/rkt_dns_test.go +++ b/tests/rkt_dns_test.go @@ -30,38 +30,45 @@ func TestDNS(t *testing.T) { defer ctx.Cleanup() for _, tt := range []struct { - paramDNS string - expectedLine string + paramDNS string + expectedLine string + expectedError bool }{ { - paramDNS: "", - expectedLine: "Cannot read file", + paramDNS: "", + expectedLine: "Cannot read file", + expectedError: true, }, { - paramDNS: "--dns=8.8.4.4", - expectedLine: "nameserver 8.8.4.4", + paramDNS: "--dns=8.8.4.4", + expectedLine: "nameserver 8.8.4.4", + expectedError: false, }, { - paramDNS: "--dns=8.8.8.8 --dns=8.8.4.4", - expectedLine: "nameserver 8.8.8.8", + paramDNS: "--dns=8.8.8.8 --dns=8.8.4.4", + expectedLine: "nameserver 8.8.8.8", + expectedError: false, }, { - paramDNS: "--dns=8.8.8.8 --dns=8.8.4.4 --dns-search=search.com --dns-opt=debug", - expectedLine: "nameserver 8.8.4.4", + paramDNS: "--dns=8.8.8.8 --dns=8.8.4.4 --dns-search=search.com --dns-opt=debug", + expectedLine: "nameserver 8.8.4.4", + expectedError: false, }, { - paramDNS: "--dns-search=foo.com --dns-search=bar.com", - expectedLine: "search foo.com bar.com", + paramDNS: "--dns-search=foo.com --dns-search=bar.com", + expectedLine: "search foo.com bar.com", + expectedError: false, }, { - paramDNS: "--dns-opt=debug --dns-opt=use-vc --dns-opt=rotate", - expectedLine: "options debug use-vc rotate", + paramDNS: "--dns-opt=debug --dns-opt=use-vc --dns-opt=rotate", + expectedLine: "options debug use-vc rotate", + expectedError: false, }, } { rktCmd := fmt.Sprintf(`%s --insecure-options=image run --set-env=FILE=/etc/resolv.conf %s %s`, ctx.Cmd(), tt.paramDNS, imageFile) t.Logf("%s\n", rktCmd) - runRktAndCheckOutput(t, rktCmd, tt.expectedLine, false) + runRktAndCheckOutput(t, rktCmd, tt.expectedLine, tt.expectedError) } } From 101b53e770476d497827218232208c37d5220353 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Fri, 18 Mar 2016 18:26:29 +0100 Subject: [PATCH 0019/1304] tests: exit code: fix TestExitCodeSimple, TestExitCodeWithSeveralApps --- tests/rkt_exit_test.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/rkt_exit_test.go b/tests/rkt_exit_test.go index 91fb9586e3..90dfc5e9a3 100644 --- a/tests/rkt_exit_test.go +++ b/tests/rkt_exit_test.go @@ -35,7 +35,7 @@ func TestExitCodeSimple(t *testing.T) { cmd := fmt.Sprintf(`%s --debug --insecure-options=image run --mds-register=false %s`, ctx.Cmd(), imageFile) t.Logf("%s\n", cmd) - spawnAndWaitOrFail(t, cmd, 0) + spawnAndWaitOrFail(t, cmd, i) checkAppStatus(t, ctx, false, "rkt-inspect", fmt.Sprintf("status=%d", i)) } } @@ -71,10 +71,8 @@ func TestExitCodeWithSeveralApps(t *testing.T) { } t.Logf("Waiting pod termination\n") - // Currently we have systemd v222 in the coreos flavor which doesn't - // include the exit status propagation code. - // TODO(iaguis): we should expect 5 as the exit status when we update to v229 - waitOrFail(t, child, 0) + // Since systend v227, the exit status is propagated from the app to rkt + waitOrFail(t, child, 5) t.Logf("Check final status\n") From ae5fac8797233954e47597f4d347b93fd6027cc7 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Fri, 18 Mar 2016 18:33:14 +0100 Subject: [PATCH 0020/1304] tests: exit code: fix TestNonRootReadInfo --- tests/rkt_non_root_test.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/rkt_non_root_test.go b/tests/rkt_non_root_test.go index fc97a8cd7e..cc3c920ffd 100644 --- a/tests/rkt_non_root_test.go +++ b/tests/rkt_non_root_test.go @@ -47,19 +47,18 @@ func TestNonRootReadInfo(t *testing.T) { // Launch some pods, this creates the environment for later testing. imgs := []struct { - name string - msg string - exitCode string - imgFile string + name string + msg string + imgFile string }{ - {name: "inspect-1", msg: "foo-1", exitCode: "1"}, - {name: "inspect-2", msg: "foo-2", exitCode: "2"}, - {name: "inspect-3", msg: "foo-3", exitCode: "3"}, + {name: "inspect-1", msg: "foo-1"}, + {name: "inspect-2", msg: "foo-2"}, + {name: "inspect-3", msg: "foo-3"}, } for i, img := range imgs { imgName := fmt.Sprintf("rkt-%s.aci", img.name) - imgs[i].imgFile = patchTestACI(imgName, fmt.Sprintf("--name=%s", img.name), fmt.Sprintf("--exec=/inspect --print-msg=%s --exit-code=%s", img.msg, img.exitCode)) + imgs[i].imgFile = patchTestACI(imgName, fmt.Sprintf("--name=%s", img.name), fmt.Sprintf("--exec=/inspect --print-msg=%s --exit-code=0", img.msg)) defer os.Remove(imgs[i].imgFile) } From b5b353913843219c9df9027fe3e8cbc2423c3ee1 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Fri, 18 Mar 2016 18:35:09 +0100 Subject: [PATCH 0021/1304] tests: exit code: TestRktListCreatedStarted --- tests/rkt_list_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/rkt_list_test.go b/tests/rkt_list_test.go index 0605f7f982..3727440825 100644 --- a/tests/rkt_list_test.go +++ b/tests/rkt_list_test.go @@ -139,7 +139,7 @@ func getCreationStartTime(t *testing.T, ctx *testutils.RktRunCtx, imageID string func TestRktListCreatedStarted(t *testing.T) { const imgName = "rkt-list-creation-start-time-test" - image := patchTestACI(fmt.Sprintf("%s.aci", imgName), fmt.Sprintf("--exec=/inspect ")) + image := patchTestACI(fmt.Sprintf("%s.aci", imgName), fmt.Sprintf("--exec=/inspect --exit-code=0")) defer os.Remove(image) imageHash := getHashOrPanic(image) From ef04d7d8384a0b04f8a2fbfab234fc51efc6fa50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Mon, 21 Mar 2016 15:50:53 +0100 Subject: [PATCH 0022/1304] Revert "tests: fix TestVolumes on systemd-git-master" This reverts commit e9238f9254a8b91389ab0f67586deb22bcc22c9c. Now that we updated to v225 on flavor coreos, We don't support old systemd versions so we can actually check for the exit status everywhere. --- tests/inspect/inspect.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/inspect/inspect.go b/tests/inspect/inspect.go index 88139a6e44..8e218181ea 100644 --- a/tests/inspect/inspect.go +++ b/tests/inspect/inspect.go @@ -232,9 +232,8 @@ func main() { err := ioutil.WriteFile(fileName, []byte(content), 0600) if err != nil { - // This error message is tested in TestVolumes fmt.Fprintf(os.Stderr, "Cannot write to file %q: %v\n", fileName, err) - os.Exit(0) + os.Exit(1) } } From af8d8c746bba55b9abb46fb42bda8fe5be35b7d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Mon, 21 Mar 2016 15:21:05 +0100 Subject: [PATCH 0023/1304] functional tests: check for exit status on TestPodManifest --- tests/rkt_run_pod_manifest_test.go | 61 +++++++++++++----------------- 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/tests/rkt_run_pod_manifest_test.go b/tests/rkt_run_pod_manifest_test.go index acbf8140a4..f9aeca0686 100644 --- a/tests/rkt_run_pod_manifest_test.go +++ b/tests/rkt_run_pod_manifest_test.go @@ -109,7 +109,7 @@ func TestPodManifest(t *testing.T) { // [image name]:[image patches] images []imagePatch podManifest *schema.PodManifest - shouldSucceed bool + expectedExit int expectedResult string cgroup string }{ @@ -130,7 +130,7 @@ func TestPodManifest(t *testing.T) { }, }, }, - true, + 0, `'"[$]`, "", }, @@ -154,7 +154,7 @@ func TestPodManifest(t *testing.T) { }, }, }, - true, + 0, "dir1", "", }, @@ -191,7 +191,7 @@ func TestPodManifest(t *testing.T) { }, }, }, - true, + 0, "empty:foo", "", }, @@ -227,7 +227,7 @@ func TestPodManifest(t *testing.T) { }, }, }, - true, + 0, "(?s)/dir1: mode: d--x-w--wx.*" + "/dir1: user: 9991.*" + "/dir1: group: 9992", "", }, @@ -258,7 +258,7 @@ func TestPodManifest(t *testing.T) { {"dir1", "host", tmpdir, nil, nil, nil, nil}, }, }, - true, + 0, "host:foo", "", }, @@ -289,7 +289,7 @@ func TestPodManifest(t *testing.T) { {"dir1", "host", tmpdir, nil, nil, nil, nil}, }, }, - false, + 1, `Cannot write to file "/dir1/file": open /dir1/file: read-only file system`, "", }, @@ -322,7 +322,7 @@ func TestPodManifest(t *testing.T) { {"dir1", "host", tmpdir, &boolTrue, nil, nil, nil}, }, }, - false, + 1, `Cannot write to file "/dir1/file": open /dir1/file: read-only file system`, "", }, @@ -354,7 +354,7 @@ func TestPodManifest(t *testing.T) { {"dir1", "host", tmpdir, nil, nil, nil, nil}, }, }, - true, + 0, "host:bar", "", }, @@ -377,7 +377,7 @@ func TestPodManifest(t *testing.T) { {"dir1", "host", tmpdir, nil, nil, nil, nil}, }, }, - true, + 0, "host:baz", "", }, @@ -402,7 +402,7 @@ func TestPodManifest(t *testing.T) { {"dir1", "host", tmpdir, &boolFalse, nil, nil, nil}, }, }, - true, + 0, "host:zaz", "", }, @@ -426,7 +426,7 @@ func TestPodManifest(t *testing.T) { {"dir1", "host", tmpdir, &boolTrue, nil, nil, nil}, }, }, - false, + 1, `Cannot write to file "/dir1/file": open /dir1/file: read-only file system`, "", }, @@ -453,7 +453,7 @@ func TestPodManifest(t *testing.T) { }, }, }, - true, + 0, `CPU Quota: 100`, "cpu", }, @@ -481,7 +481,7 @@ func TestPodManifest(t *testing.T) { }, }, }, - true, + 0, `Memory Limit: 4194304`, "memory", }, @@ -528,7 +528,7 @@ func TestPodManifest(t *testing.T) { {"dir", "host", tmpdir, nil, nil, nil, nil}, }, }, - true, + 0, "host:foo", "", }, @@ -552,7 +552,7 @@ func TestPodManifest(t *testing.T) { }, }, }, - true, + 0, fmt.Sprintf("%v=disabled", capability.CAP_NET_ADMIN.String()), "", }, @@ -582,7 +582,7 @@ func TestPodManifest(t *testing.T) { }, }, }, - true, + 0, fmt.Sprintf("%v=enabled", capability.CAP_NET_ADMIN.String()), "", }, @@ -603,7 +603,7 @@ func TestPodManifest(t *testing.T) { }, }, }, - true, + 0, "User: uid=1000 euid=1000 gid=100 egid=100", "", }, @@ -624,7 +624,7 @@ func TestPodManifest(t *testing.T) { }, }, }, - true, + 0, "User: uid=1000 euid=1000 gid=100 egid=100", "", }, @@ -645,7 +645,7 @@ func TestPodManifest(t *testing.T) { }, }, }, - false, + 2, `"user2" user not found`, "", }, @@ -666,7 +666,7 @@ func TestPodManifest(t *testing.T) { }, }, }, - false, + 2, `"group2" group not found`, "", }, @@ -687,7 +687,7 @@ func TestPodManifest(t *testing.T) { }, }, }, - true, + 0, "User: uid=0 euid=0 gid=0 egid=0", "", }, @@ -708,7 +708,7 @@ func TestPodManifest(t *testing.T) { }, }, }, - false, + 2, `no such file or directory`, "", }, @@ -729,7 +729,7 @@ func TestPodManifest(t *testing.T) { }, }, }, - false, + 2, `no such file or directory`, "", }, @@ -772,11 +772,7 @@ func TestPodManifest(t *testing.T) { t.Fatalf("Expected %q but not found: %v\n%s", tt.expectedResult, err, out) } } - if err := child.Wait(); err != nil { - if tt.shouldSucceed { - t.Fatalf("rkt didn't terminate correctly: %v", err) - } - } + waitOrFail(t, child, tt.expectedExit) verifyHostFile(t, tmpdir, "file", i, tt.expectedResult) // 2. Test 'rkt prepare' + 'rkt run-prepared'. @@ -793,11 +789,8 @@ func TestPodManifest(t *testing.T) { t.Fatalf("Expected %q but not found: %v\n%s", tt.expectedResult, err, out) } } - if err := child.Wait(); err != nil { - if tt.shouldSucceed { - t.Fatalf("rkt didn't terminate correctly: %v", err) - } - } + + waitOrFail(t, child, tt.expectedExit) verifyHostFile(t, tmpdir, "file", i, tt.expectedResult) // we run the garbage collector and remove the imported images to save From 64744b5ec4539267b4b467d56372803787e76013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Mon, 21 Mar 2016 15:49:39 +0100 Subject: [PATCH 0024/1304] functional tests: test for exit code on TestVolumes --- tests/rkt_volume_test.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/rkt_volume_test.go b/tests/rkt_volume_test.go index 4994862e19..4077bd45b8 100644 --- a/tests/rkt_volume_test.go +++ b/tests/rkt_volume_test.go @@ -27,56 +27,67 @@ import ( ) var volTests = []struct { - rktCmd string - expect string + rktCmd string + expect string + expectedExit int }{ // Check that we can read files in the ACI { `/bin/sh -c "export FILE=/dir1/file ; ^RKT_BIN^ --debug --insecure-options=image run --mds-register=false --inherit-env=true ^READ_FILE^"`, `<<>>`, + 0, }, // Check that we can read files from a volume (both ro and rw) { `/bin/sh -c "export FILE=/dir1/file ; ^RKT_BIN^ --debug --insecure-options=image run --mds-register=false --inherit-env=true --volume=dir1,kind=host,source=^TMPDIR^ --mount=volume=dir1,target=dir1 ^VOL_RW_READ_FILE^"`, `<<>>`, + 0, }, { `/bin/sh -c "export FILE=/dir1/file ; ^RKT_BIN^ --debug --insecure-options=image run --mds-register=false --inherit-env=true --volume=dir1,kind=host,source=^TMPDIR^ --mount=volume=dir1,target=dir1 ^VOL_RO_READ_FILE^"`, `<<>>`, + 0, }, // Check that we can write to files in the ACI { `/bin/sh -c "export FILE=/dir1/file CONTENT=1 ; ^RKT_BIN^ --debug --insecure-options=image run --mds-register=false --inherit-env=true ^WRITE_FILE^"`, `<<<1>>>`, + 0, }, // Check that we can write files to a volume (both ro and rw) { `/bin/sh -c "export FILE=/dir1/file CONTENT=2 ; ^RKT_BIN^ --debug --insecure-options=image run --mds-register=false --inherit-env=true --volume=dir1,kind=host,source=^TMPDIR^ --mount=volume=dir1,target=dir1 ^VOL_RW_WRITE_FILE^"`, `<<<2>>>`, + 0, }, { `/bin/sh -c "export FILE=/dir1/file CONTENT=3 ; ^RKT_BIN^ --debug --insecure-options=image run --mds-register=false --inherit-env=true --volume=dir1,kind=host,source=^TMPDIR^ --mount=volume=dir1,target=dir1 ^VOL_RO_WRITE_FILE^"`, `Cannot write to file "/dir1/file": open /dir1/file: read-only file system`, + 1, }, // Check that the volume still contains the file previously written { `/bin/sh -c "export FILE=/dir1/file ; ^RKT_BIN^ --debug --insecure-options=image run --mds-register=false --inherit-env=true --volume=dir1,kind=host,source=^TMPDIR^ --mount=volume=dir1,target=dir1 ^VOL_RO_READ_FILE^"`, `<<<2>>>`, + 0, }, // Check that injecting a rw mount/volume works without any mountpoint in the image manifest { `/bin/sh -c "export FILE=/dir1/file CONTENT=1 ; ^RKT_BIN^ --debug --insecure-options=image run --mds-register=false --inherit-env=true --volume=dir1,kind=host,source=^TMPDIR^ ^VOL_ADD_MOUNT_RW^ --mount=volume=dir1,target=dir1"`, `<<<1>>>`, + 0, }, // Check that injecting a ro mount/volume works without any mountpoint in the image manifest { `/bin/sh -c "export FILE=/dir1/file CONTENT=1 ; ^RKT_BIN^ --debug --insecure-options=image run --mds-register=false --inherit-env=true --volume=dir1,kind=host,source=^TMPDIR^,readOnly=true ^VOL_ADD_MOUNT_RO^ --mount=volume=dir1,target=dir1"`, `Cannot write to file "/dir1/file": open /dir1/file: read-only file system`, + 1, }, // Check that an implicit empty volume is created if the user didn't provide it but there's a mount point in the app { `/bin/sh -c "export FILE=/dir1/file CONTENT=1 ; ^RKT_BIN^ --debug --insecure-options=image run --mds-register=false --inherit-env=true ^VOL_RW_WRITE_FILE^"`, `<<<1>>>`, + 0, }, } @@ -122,7 +133,7 @@ func TestVolumes(t *testing.T) { t.Logf("Running test #%v", i) child := spawnOrFail(t, cmd) - defer waitOrFail(t, child, 0) + defer waitOrFail(t, child, tt.expectedExit) if err := expectTimeoutWithOutput(child, tt.expect, time.Minute); err != nil { fmt.Printf("Command: %s\n", cmd) From 0e5eb8d230adb19dc55615b8519f62cb385a63f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 23 Mar 2016 18:50:32 +0100 Subject: [PATCH 0025/1304] *: make v229 the default version for flavor src --- Documentation/build-configure.md | 4 ++-- configure.ac | 6 +++--- tests/README.md | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Documentation/build-configure.md b/Documentation/build-configure.md index c96761891d..548750debe 100644 --- a/Documentation/build-configure.md +++ b/Documentation/build-configure.md @@ -103,7 +103,7 @@ You may want to change it to point the build system to use some local repository This parameter takes either a tag name or a branch name. Tag names are usually in form of `v`, where number is a systemd version. -The default is `v222`. +The default is `v229`. You can use branch name `master` to test the bleeding edge version of systemd. ### `coreos` and `kvm` flavor @@ -122,7 +122,7 @@ If this parameter is specified, then also `--with-coreos-local-pxe-image-systemd The build system has no reliable way to deduce automatically what version of systemd the CoreOS PXE image contains, so it needs some help. This parameters tells the build systemd what is the version of systemd in the local PXE image. -The value should be like tag name in systemd git repository, that is - `v`, like `v222`. +The value should be like tag name in systemd git repository, that is - `v`, like `v229`. If this parameter is specified, then also `--with-coreos-local-pxe-image-path` must be specified too. ## Testing diff --git a/configure.ac b/configure.ac index d0d0fa5d38..48320e65c5 100644 --- a/configure.ac +++ b/configure.ac @@ -98,7 +98,7 @@ AC_ARG_WITH([stage1-systemd-src], AC_ARG_WITH([stage1-systemd-version], [AS_HELP_STRING([--with-stage1-systemd-version], - [systemd version to build, used in 'src' stage1 flavor (default: 'v222', should be in format 'v', like v222)])], + [systemd version to build, used in 'src' stage1 flavor (default: 'v229', should be in format 'v', like v229)])], [RKT_STAGE1_SYSTEMD_VER="${withval}"], [RKT_STAGE1_SYSTEMD_VER='auto']) @@ -112,7 +112,7 @@ AC_ARG_WITH([coreos-local-pxe-image-path], AC_ARG_WITH([coreos-local-pxe-image-systemd-version], [AS_HELP_STRING([--with-coreos-local-pxe-image-systemd-version], - [version of systemd in local CoreOS PXE image, used in 'coreos' and 'kvm' stage1 flavors (should be in format 'v', like v222)])], + [version of systemd in local CoreOS PXE image, used in 'coreos' and 'kvm' stage1 flavors (should be in format 'v', like v229)])], [RKT_LOCAL_COREOS_PXE_IMAGE_SYSTEMD_VER="${withval}"], [RKT_LOCAL_COREOS_PXE_IMAGE_SYSTEMD_VER=]) @@ -363,7 +363,7 @@ RKT_IF_HAS_FLAVOR([${RKT_STAGE1_FLAVORS}],[src], [:]) AS_VAR_IF([RKT_STAGE1_SYSTEMD_VER], [auto], dnl systemd version not specified, use default - [RKT_STAGE1_SYSTEMD_VER='v222'], + [RKT_STAGE1_SYSTEMD_VER='v229'], dnl systemd version specified, use it [:])], dnl we are not building src flavor diff --git a/tests/README.md b/tests/README.md index 6243126b47..b9b7bb2f12 100644 --- a/tests/README.md +++ b/tests/README.md @@ -36,7 +36,7 @@ sudo gpasswd -a runner rkt ``` ./tests/run-build.sh none -./tests/run-build.sh src v222 +./tests/run-build.sh src v229 ``` #### Thread 2 From 91c19de7e41ded7465c621e30308a85c59f1491a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 23 Mar 2016 18:50:43 +0100 Subject: [PATCH 0026/1304] functional tests: fix typo --- tests/rkt_exit_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/rkt_exit_test.go b/tests/rkt_exit_test.go index 90dfc5e9a3..7733f2f9da 100644 --- a/tests/rkt_exit_test.go +++ b/tests/rkt_exit_test.go @@ -71,7 +71,7 @@ func TestExitCodeWithSeveralApps(t *testing.T) { } t.Logf("Waiting pod termination\n") - // Since systend v227, the exit status is propagated from the app to rkt + // Since systemd v227, the exit status is propagated from the app to rkt waitOrFail(t, child, 5) t.Logf("Check final status\n") From 5d64becd39e92c3590ae2a8a1ce2ab1dafe4c179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 23 Mar 2016 18:55:19 +0100 Subject: [PATCH 0027/1304] functional tests: semaphore needs libmount to build v229 --- tests/install-deps.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/install-deps.sh b/tests/install-deps.sh index 6ad3220b0e..995ec8e5a8 100755 --- a/tests/install-deps.sh +++ b/tests/install-deps.sh @@ -15,9 +15,6 @@ fi if [ "${CI-}" == true ] ; then # https://semaphoreci.com/ if [ "${SEMAPHORE-}" == true ] ; then - # A colon to guard against an empty body error. - : - # Most dependencies are already installed on Semaphore. # Here we can install any missing dependencies. Whenever # Semaphore installs more dependencies on their platform, @@ -31,8 +28,8 @@ if [ "${CI-}" == true ] ; then sudo apt-get install -y libacl1-dev # libmount: https://github.com/systemd/systemd/pull/986#issuecomment-138451264 - # sudo add-apt-repository --yes ppa:pitti/systemd-semaphore - # sudo apt-get update -qq || true - # sudo apt-get install -y libmount-dev libmount1 + sudo add-apt-repository --yes ppa:pitti/systemd-semaphore + sudo apt-get update -qq || true + sudo apt-get install -y libmount-dev libmount1 fi fi From 67f9c1d5e56f232237c35bd21b18422997052b92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 23 Mar 2016 19:21:57 +0100 Subject: [PATCH 0028/1304] functional tests: install and use gcc-5 gcc-4.8 crashes when building systemd v229. --- tests/install-deps.sh | 5 +++++ tests/run-build.sh | 3 +++ 2 files changed, 8 insertions(+) diff --git a/tests/install-deps.sh b/tests/install-deps.sh index 995ec8e5a8..101435b374 100755 --- a/tests/install-deps.sh +++ b/tests/install-deps.sh @@ -31,5 +31,10 @@ if [ "${CI-}" == true ] ; then sudo add-apt-repository --yes ppa:pitti/systemd-semaphore sudo apt-get update -qq || true sudo apt-get install -y libmount-dev libmount1 + + # building systemd v229 crashes with the gcc 4.8, update to gcc 5 + sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y + sudo apt-get update -qq + sudo apt-get install gcc-5 gcc-5-base libgcc-5-dev -y -qq fi fi diff --git a/tests/run-build.sh b/tests/run-build.sh index 6cc36c9179..db694b5353 100755 --- a/tests/run-build.sh +++ b/tests/run-build.sh @@ -36,6 +36,9 @@ if [ "${SEMAPHORE-}" == true ] ; then . /opt/change-go-version.sh change-go-version 1.5 fi + + # systemd v229 doesn't build on gcc-4.8, set the compiler to gcc-5 + export CC=gcc-5 fi HEAD=`git rev-parse HEAD` From dead82ad5a03d12014b4f61f218aede3fab752b5 Mon Sep 17 00:00:00 2001 From: mstachowski Date: Thu, 18 Feb 2016 17:22:18 +0000 Subject: [PATCH 0029/1304] kvm: Improving lkvm performance When lkvm is using more vcpus than platform has got, then VMs spinning up is very slow. This patch blocks this behavior and when user choose more vcpus then platform has cores, then number of cpus is set to number of cores --- stage1/init/kvm/resources.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/stage1/init/kvm/resources.go b/stage1/init/kvm/resources.go index 29e223c4e5..eabbcfe664 100644 --- a/stage1/init/kvm/resources.go +++ b/stage1/init/kvm/resources.go @@ -55,10 +55,12 @@ func GetAppsResources(apps schema.AppList) (totalCpus, totalMem int64) { totalCpus += cpus totalMem += mem } - // If user doesn't specify cpus for at least one app, we set no limit for - // whole pod. - if !cpusSpecified { - totalCpus = int64(runtime.NumCPU()) + // In case when number of specified cpus is greater than + // number or when cpus aren't specified, we set number + // of logical cpus as a limit. + availableCpus := int64(runtime.NumCPU()) + if !cpusSpecified || totalCpus > availableCpus { + totalCpus = availableCpus } // Add an overhead for the VM system From fb5df19be7425cf3539dbc24e2902ad7668adb69 Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Fri, 25 Mar 2016 16:27:05 +0100 Subject: [PATCH 0030/1304] stage1/fly: fix path stat error messages --- stage1_fly/run/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stage1_fly/run/main.go b/stage1_fly/run/main.go index 4c0515fb2b..53e09b58cd 100644 --- a/stage1_fly/run/main.go +++ b/stage1_fly/run/main.go @@ -281,7 +281,7 @@ func stage1() int { if strings.HasPrefix(mount.HostPath, "/") { if hostPathInfo, err = os.Stat(mount.HostPath); err != nil { - log.PrintE(fmt.Sprintf("stat of host directory %s", mount.HostPath), err) + log.PrintE(fmt.Sprintf("stat of host path %s", mount.HostPath), err) return 1 } } else { @@ -290,7 +290,7 @@ func stage1() int { absTargetPath := filepath.Join(mount.TargetPrefixPath, mount.RelTargetPath) if targetPathInfo, err = os.Stat(absTargetPath); err != nil && !os.IsNotExist(err) { - log.PrintE(fmt.Sprintf("stat of target directory %s", absTargetPath), err) + log.PrintE(fmt.Sprintf("stat of target path %s", absTargetPath), err) return 1 } From 3e05c9d10ebe1579c7a0eed0944ce46aa04b890d Mon Sep 17 00:00:00 2001 From: Yifan Gu Date: Fri, 25 Mar 2016 18:04:27 -0700 Subject: [PATCH 0031/1304] api_service: Add logs when inner function fails in ListPods(). --- rkt/api_service.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rkt/api_service.go b/rkt/api_service.go index 87b38c3931..31ee70103a 100644 --- a/rkt/api_service.go +++ b/rkt/api_service.go @@ -303,6 +303,13 @@ func getBasicPod(p *pod) (*v1alpha.Pod, *schema.PodManifest, error) { case Running: pod.State = v1alpha.PodState_POD_STATE_RUNNING pod.Networks = getNetworks(p) + + // Get cgroup. + cgroup, err := p.getCgroup() + if err != nil { + return nil, nil, err + } + pod.Cgroup = cgroup case Deleting: pod.State = v1alpha.PodState_POD_STATE_DELETING case Exited: @@ -346,6 +353,7 @@ func (s *v1AlphaAPIServer) ListPods(ctx context.Context, request *v1alpha.ListPo if err := walkPods(includeMostDirs, func(p *pod) { pod, manifest, err := getBasicPod(p) if err != nil { // Do not return partial pods. + stderr.PrintE(fmt.Sprintf("failed to get basic pod information for pod with uuid: %v", p.uuid), err) return } @@ -356,6 +364,7 @@ func (s *v1AlphaAPIServer) ListPods(ctx context.Context, request *v1alpha.ListPo if request.Detail { if err := fillAppInfo(s.store, p, pod); err != nil { // Do not return partial pods. + stderr.PrintE(fmt.Sprintf("failed to fill app information for pod with uuid: %v", p.uuid), err) return } } else { From 5ca5b6f4f3d9e645c4382e04fb0a43a5f9cdaf1f Mon Sep 17 00:00:00 2001 From: mstachowski Date: Tue, 29 Mar 2016 12:56:08 +0200 Subject: [PATCH 0032/1304] kvm: Add missing libraries to stage1 image Due to last pxe.img upgrade, few libraries are missing inside stage1-kvm.aci image. This patch is resolving this issue. Note: this issue impacts on entering feature for kvm flavor --- stage1/usr_from_kvm/manifest.d/sshd.manifest | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/stage1/usr_from_kvm/manifest.d/sshd.manifest b/stage1/usr_from_kvm/manifest.d/sshd.manifest index b994e64552..3116bd7011 100644 --- a/stage1/usr_from_kvm/manifest.d/sshd.manifest +++ b/stage1/usr_from_kvm/manifest.d/sshd.manifest @@ -2,18 +2,18 @@ bin/chown bin/chmod bin/ssh-keygen sbin/sshd -lib64/libcrypt-2.20.so +lib64/libcrypt-2.21.so lib64/libcrypt.so.1 lib64/libcrypto.so.1.0.0 -lib64/libnsl-2.20.so +lib64/libnsl-2.21.so lib64/libnsl.so.1 -lib64/libnss_compat-2.20.so +lib64/libnss_compat-2.21.so lib64/libnss_compat.so.2 -lib64/libnss_files-2.20.so +lib64/libnss_files-2.21.so lib64/libnss_files.so.2 -lib64/libresolv-2.20.so +lib64/libresolv-2.21.so lib64/libresolv.so.2 -lib64/libutil-2.20.so +lib64/libutil-2.21.so lib64/libutil.so.1 lib64/libz.so.1 lib64/libz.so.1.2.8 From 9f98dc1ef390710aa06c1b8d83eff472ea1ca3cd Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Tue, 29 Mar 2016 18:12:46 +0200 Subject: [PATCH 0033/1304] doc: distributions: update caveats rkt on Fedora is still limited because of SELinux and FirewallD but the situation improved recently. Update the caveats. --- Documentation/distributions.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Documentation/distributions.md b/Documentation/distributions.md index ff06203025..6b86e3fa00 100644 --- a/Documentation/distributions.md +++ b/Documentation/distributions.md @@ -18,8 +18,13 @@ rkt's entry in the [Fedora package database](https://admin.fedoraproject.org/pkg #### Caveat: SELinux -rkt currently does not integrate with SELinux on Fedora. -See [#1727](https://github.com/coreos/rkt/issues/1727). +rkt can integrate with SELinux on Fedora but in a limited way. +This has the following caveats: +- running as systemd service restricted (see [#2322](https://github.com/coreos/rkt/issues/2322)) +- access to host volumes restricted (see [#2325](https://github.com/coreos/rkt/issues/2325)) +- socket activation restricted (see [#2326](https://github.com/coreos/rkt/issues/2326)) +- metadata service restricted (see [#1978](https://github.com/coreos/rkt/issues/1978)) + As a workaround, SELinux can be temporarily disabled: ``` sudo setenforce Permissive @@ -32,6 +37,7 @@ SELINUX=permissive #### Caveat: firewall The default firewall rules can block the traffic from rkt pods. +See [#2206](https://github.com/coreos/rkt/issues/2206). As a workaround, they can be removed: ``` sudo iptables -F From 2879b2515f5295a95a9a0e65c7f9f6c9b4a8cfb5 Mon Sep 17 00:00:00 2001 From: Yifan Gu Date: Fri, 25 Mar 2016 23:37:01 -0700 Subject: [PATCH 0034/1304] rkt/pods.go: Fix a bug in getContainerPID1(). If 'getChildPID()' returns an 'ErrChildNotReady' error, then the variable 'err' will be set to nil, which causes the last If statement's condition to be true, and returns '-1, nil'. --- rkt/pods.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/rkt/pods.go b/rkt/pods.go index 0750c46b92..761c518996 100644 --- a/rkt/pods.go +++ b/rkt/pods.go @@ -893,14 +893,15 @@ func (p *pod) getContainerPID1() (pid int, err error) { } ppid, err = p.readIntFromFile("ppid") + if err != nil && !os.IsNotExist(err) { + return -1, err + } if err == nil { pid, err = getChildPID(ppid) if err == nil { return pid, nil } - if _, ok := err.(ErrChildNotReady); ok { - err = nil - } else { + if _, ok := err.(ErrChildNotReady); !ok { return -1, err } } @@ -914,8 +915,8 @@ func (p *pod) getContainerPID1() (pid int, err error) { return -1, err } - if !os.IsNotExist(err) || !p.isRunning() { - return -1, err + if !p.isRunning() { + return -1, fmt.Errorf("pod %v is not running anymore", p.uuid) } } } From f1d5bc9a1582ec443ad9536be60e7672e6bf89f4 Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Wed, 30 Mar 2016 11:20:59 +0200 Subject: [PATCH 0035/1304] build: Make sure we really got all the files from the squashfs file Since unsquashfs does not have a flag for ensuring that all the files from manifest were extracted, we have to do it on our own. We do this by making sure that the complete manifest is a subset of a list of the files in the squashfs file (acquired by the "unsquashfs -ls " command). This requires doing some set operations, so we got a dependency on comm from coreutils. --- Documentation/dependencies.md | 1 + configure.ac | 1 + stage1/usr_from_coreos/build-usr.mk | 19 ++++++++++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Documentation/dependencies.md b/Documentation/dependencies.md index 1aef0544d9..645c79866f 100644 --- a/Documentation/dependencies.md +++ b/Documentation/dependencies.md @@ -37,6 +37,7 @@ For the most part the codebase is self-contained (e.g. all dependencies are vend ### Specific dependencies for the coreos/kvm flavor * cat +* comm * cpio * gzip * md5sum diff --git a/configure.ac b/configure.ac index 48320e65c5..bc8bf8cdf0 100644 --- a/configure.ac +++ b/configure.ac @@ -260,6 +260,7 @@ dnl gpg - it will be checked when we will actually download the image dnl from the network AC_DEFUN([RKT_COMMON_COREOS_PROGS], [RKT_REQ_PROG([CAT],[cat],[cat]) + RKT_REQ_PROG([COMM],[comm],[comm]) RKT_REQ_PROG([CPIO],[cpio],[cpio]) RKT_REQ_PROG([GZIP],[gzip],[gzip]) RKT_REQ_PROG([MD5SUM],[md5sum],[md5sum]) diff --git a/stage1/usr_from_coreos/build-usr.mk b/stage1/usr_from_coreos/build-usr.mk index 73d408e802..a32a7447f3 100644 --- a/stage1/usr_from_coreos/build-usr.mk +++ b/stage1/usr_from_coreos/build-usr.mk @@ -34,6 +34,13 @@ CBU_ROOTFS := $(CBU_TMPDIR)/rootfs CBU_COMPLETE_MANIFEST := $(CBU_TMPDIR)/manifest.txt # All manifest in the CBU_MANIFESTS_DIR CBU_MANIFESTS := $(wildcard $(CBU_MANIFESTS_DIR)/*) +# A list of all files in the squashfs file without the likely +# "squashfs-root" prefix +CBU_SQUASHFS_FILES := $(CBU_TMPDIR)/squashfsfiles +# A list of files that appear in both CBU_COMPLETE_MANIFEST and +# CBU_SQUASHFS_FILES, should be the same as the list in +# CBU_COMPLETE_MANIFEST, otherwise we get an error. +CBU_COMMON_FILES := $(CBU_TMPDIR)/commonfiles # Stamp telling when ACI rootfs was prepared. $(call setup-stamp-file,CBU_ACI_ROOTFS_STAMP,$(CBU_DIFF)-acirootfs) @@ -94,7 +101,9 @@ CBU_SYSTEMD_VERSION_FILE := $(CBU_ACIROOTFSDIR)/systemd-version CLEAN_FILES += \ $(CBU_COMPLETE_MANIFEST) \ - $(CBU_SYSTEMD_VERSION_FILE) + $(CBU_SYSTEMD_VERSION_FILE) \ + $(CBU_SQUASHFS_FILES) \ + $(CBU_COMMON_FILES) INSTALL_DIRS += \ $(CBU_ROOTFS):0755 INSTALL_SYMLINKS += \ @@ -154,6 +163,14 @@ $(call generate-clean-mk,$(CBU_ROOTFS_CLEAN_STAMP),$(CBU_ROOTFSDIR_CLEANMK),$(CB # This unpacks squashfs image to a temporary rootfs. $(call generate-stamp-rule,$(CBU_MKBASE_STAMP),$(CCN_SQUASHFS) $(CBU_COMPLETE_MANIFEST),$(CBU_ROOTFS), \ $(call vb,vt,UNSQUASHFS,$(call vsp,$(CCN_SQUASHFS)) => $(call vsp,$(CBU_ROOTFS)/usr)) \ + CBU_SQROOT=$$$$(unsquashfs -ls "$(CCN_SQUASHFS)" --no-progress | tail --lines=1); \ + unsquashfs -ls "$(CCN_SQUASHFS)" | grep "^$$$${CBU_SQROOT}" | sed -e "s/$$$${CBU_SQROOT}\///g" | sort >"$(CBU_SQUASHFS_FILES)"; \ + comm -1 -2 "$(CBU_SQUASHFS_FILES)" "$(CBU_COMPLETE_MANIFEST)" >"$(CBU_COMMON_FILES)"; \ + if ! cmp --silent "$(CBU_COMMON_FILES)" "$(CBU_COMPLETE_MANIFEST)"; \ + then \ + echo -e "Files listed in $(CBU_COMPLETE_MANIFEST) are missing from $(CCN_SQUASHFS):\n$$$$(comm -1 -3 "$(CBU_SQUASHFS_FILES)" "$(CBU_COMPLETE_MANIFEST)")"; \ + exit 1; \ + fi; \ unsquashfs -dest "$(CBU_ROOTFS)/usr" -ef "$(CBU_COMPLETE_MANIFEST)" "$(CCN_SQUASHFS)"$(call vl3, >/dev/null)) # If either squashfs file or the concatenated manifest file changes we From 12aa095a9dfca030bd3be6f043f3f878fc77f46f Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Wed, 30 Mar 2016 12:10:10 +0200 Subject: [PATCH 0036/1304] build: Make ip.manifest consistent with other files All other manifest files do not add the root slash to the path. Also fixes the missing files detection for kvm flavor. --- stage1/usr_from_kvm/manifest.d/ip.manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stage1/usr_from_kvm/manifest.d/ip.manifest b/stage1/usr_from_kvm/manifest.d/ip.manifest index f722531477..4fdedb4b70 100644 --- a/stage1/usr_from_kvm/manifest.d/ip.manifest +++ b/stage1/usr_from_kvm/manifest.d/ip.manifest @@ -1 +1 @@ -/bin/ip +bin/ip From 9b3137bca71e9b35198c6adcfa35cedb2ff32726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 30 Mar 2016 15:49:28 +0200 Subject: [PATCH 0037/1304] rkt: check signatures on --stage1-* options We were not checking signatures when the uses passes `--stage1-*` options. --- rkt/stage1hash.go | 51 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/rkt/stage1hash.go b/rkt/stage1hash.go index 332370b99b..1d37938e95 100644 --- a/rkt/stage1hash.go +++ b/rkt/stage1hash.go @@ -219,23 +219,41 @@ func getStage1ImagesDirectory(c *config.Config) string { } func getStage1HashFromFlag(s *store.Store, loc stage1ImageLocation, dir string) (*types.Hash, error) { + withKeystore := true + location := loc.location + if loc.kind == stage1ImageLocationFromDir { + location = filepath.Join(dir, loc.location) + } + trustedLocation, err := isTrustedLocation(location) + if err != nil { + return nil, err + } + imgType := apps.AppImageGuess switch loc.kind { case stage1ImageLocationURL: imgType = apps.AppImageURL + if trustedLocation { + withKeystore = false + } case stage1ImageLocationPath: imgType = apps.AppImagePath + if trustedLocation { + withKeystore = false + } case stage1ImageLocationName: imgType = apps.AppImageName case stage1ImageLocationHash: imgType = apps.AppImageHash case stage1ImageLocationFromDir: - loc.location = filepath.Join(dir, loc.location) + if trustedLocation { + withKeystore = false + } imgType = apps.AppImagePath } - fn := getStage1Finder(s) - return fn.FindImage(loc.location, "", imgType) + fn := getStage1Finder(s, withKeystore) + return fn.FindImage(location, "", imgType) } func getStage1DataFromConfig(c *config.Config) (string, string, string) { @@ -267,8 +285,24 @@ func getFileNameFromLocation(imgLoc string) string { return filepath.Base(imgLoc) } +func isTrustedLocation(location string) (bool, error) { + absLocation, err := filepath.Abs(location) + if err != nil { + return false, err + } + if absLocation == buildDefaultStage1ImageLoc || + strings.HasPrefix(absLocation, fmt.Sprintf("%s%c", filepath.Clean(buildDefaultStage1ImagesDir), filepath.Separator)) { + return true, nil + } + return false, nil +} + func getConfiguredStage1Hash(s *store.Store, imgRef, imgLoc, imgFileName string) (*types.Hash, error) { - fn := getStage1Finder(s) + trusted, err := isTrustedLocation(imgLoc) + if err != nil { + return nil, err + } + fn := getStage1Finder(s, !trusted) if !strings.HasSuffix(imgRef, "-dirty") { fn.StoreOnly = true if hash, err := fn.FindImage(imgRef, "", apps.AppImageName); err == nil { @@ -287,8 +321,8 @@ func getConfiguredStage1Hash(s *store.Store, imgRef, imgLoc, imgFileName string) return getStage1HashFromPath(fn, imgLoc, imgFileName) } -func getStage1Finder(s *store.Store) *image.Finder { - return &image.Finder{ +func getStage1Finder(s *store.Store, withKeystore bool) *image.Finder { + fn := &image.Finder{ S: s, InsecureFlags: globalFlags.InsecureFlags, TrustKeysFromHTTPS: globalFlags.TrustKeysFromHTTPS, @@ -297,6 +331,11 @@ func getStage1Finder(s *store.Store) *image.Finder { NoStore: false, WithDeps: false, } + + if withKeystore { + fn.Ks = getKeystore() + } + return fn } func getStage1HashFromPath(fn *image.Finder, imgLoc, imgFileName string) (*types.Hash, error) { From d7297ab9c88ae3bfa10ddf6899bd08014888ba6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 30 Mar 2016 15:49:24 +0200 Subject: [PATCH 0038/1304] rkt: don't check stage1 signature if it's in the rkt binary dir --- rkt/stage1hash.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rkt/stage1hash.go b/rkt/stage1hash.go index 1d37938e95..4ad6374d26 100644 --- a/rkt/stage1hash.go +++ b/rkt/stage1hash.go @@ -353,6 +353,8 @@ func getStage1HashFromPath(fn *image.Finder, imgLoc, imgFileName string) (*types if err != nil { fallbackErr = err } else { + // using stage1 image in rkt's path, don't check the signature + fn.Ks = nil rktDir := filepath.Dir(exePath) imgPath := filepath.Join(rktDir, imgFileName) hash, err := fn.FindImage(imgPath, "", apps.AppImagePath) From bbd2b67c1ed6fb34538760b45a1b070b013b8947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 30 Mar 2016 17:46:14 +0200 Subject: [PATCH 0039/1304] Documentation: update `--stage1-*` documentation Simply use `--stage1-name` in most of the examples now that we have the stage1 images in coreos.com. --- Documentation/hacking.md | 6 ++++++ Documentation/running-fly-stage1.md | 11 +++-------- Documentation/running-lkvm-stage1.md | 25 ++++--------------------- Documentation/subcommands/enter.md | 14 +------------- Documentation/subcommands/run.md | 18 ++++++++++++++++++ 5 files changed, 32 insertions(+), 42 deletions(-) diff --git a/Documentation/hacking.md b/Documentation/hacking.md index cb00f46970..5f4b9d3c38 100644 --- a/Documentation/hacking.md +++ b/Documentation/hacking.md @@ -85,6 +85,12 @@ However, a default value can be set for this parameter at build time by setting It can be set with the `paths` kind of configuration. For more details, see [configure script parameters documentation](build-configure.md) and [configuration documentation](configuration.md). +rkt expects stage1 images to be signed except in the following cases: + +* it is the default stage1 image and it's in the same directory as the rkt binary +* `--stage1-{name,hash}` is used and the image is already in the store +* `--stage1-{url,path,from-dir}` is used and the image is in the default directory configured at build time + ## Managing Dependencies rkt uses [`godep`](https://github.com/tools/godep) to manage third-party dependencies. diff --git a/Documentation/running-fly-stage1.md b/Documentation/running-fly-stage1.md index 97f792e037..04d33fc3d1 100644 --- a/Documentation/running-fly-stage1.md +++ b/Documentation/running-fly-stage1.md @@ -64,18 +64,13 @@ This will build the rkt binary and the stage1-fly.aci in `build-rkt-1.2.1+git/bi ### Selecting stage1 at runtime -Here is a quick example of how to use a container stage1 named `stage1-fly.aci` in `/usr/share/rkt/`: +Here is a quick example of how to use a container with the official fly stage1: ``` -# rkt run --stage1-path=/usr/share/rkt/stage1-fly.aci coreos.com/etcd:v2.2.5 +# rkt run --stage1-name=coreos.com/rkt/stage1-fly:1.2.1 coreos.com/etcd:v2.2.5 ``` -When the image is already in the store, the `--stage1-name` or `--stage1-hash` flags can be used instead for a faster startup: - -``` -# rkt run --stage1-name=coreos.com/rkt/stage1-fly coreos.com/etcd:v2.2.5 -# rkt run --stage1-hash= coreos.com/etcd:v2.2.5 -``` +If the image is not in the store, `--stage1-name` will perform discovery and fetch the image. ## Notes on isolation and security diff --git a/Documentation/running-lkvm-stage1.md b/Documentation/running-lkvm-stage1.md index e7e554d3b0..dd77c1b595 100644 --- a/Documentation/running-lkvm-stage1.md +++ b/Documentation/running-lkvm-stage1.md @@ -79,33 +79,16 @@ Currently, the memory allocated to the virtual machine is a sum of memory requir ### Selecting stage1 at runtime -If you want to run software that requires hypervisor isolation along with trusted software that only needs container isolation, you can [choose which stage1.aci to use at runtime](https://github.com/coreos/rkt/blob/master/Documentation/commands.md#use-a-custom-stage-1). +If you want to run software that requires hypervisor isolation along with trusted software that only needs container isolation, you can [choose which stage1 to use at runtime](https://github.com/coreos/rkt/blob/master/Documentation/subcommands/run.md#use-a-custom-stage-1). -For example, if you have a container stage1 named `stage1-coreos.aci` and a lkvm stage1 named `stage1-kvm.aci` in `/usr/local/rkt/`: +For example, to use the official lkvm stage1: ``` -# rkt run --stage1-path=/usr/local/rkt/stage1-coreos.aci coreos.com/etcd:v2.0.9 -... -# rkt run --stage1-path=/usr/local/rkt/stage1-kvm.aci coreos.com/etcd:v2.0.9 -... -``` - -These images can be installed in the default stage1 images directory. -In this case, the stage1 image can be selected with a different flag: - -``` -# rkt run --stage1-from-dir=stage1-coreos.aci coreos.com/etcd:v2.0.9 -... -# rkt run --stage1-from-dir=stage1-kvm.aci coreos.com/etcd:v2.0.9 +# rkt run --stage1-name=coreos.com/rkt/stage1-kvm:1.2.1 coreos.com/etcd:v2.0.9 ... ``` -When the image is already in the store, the `--stage1-name` or `--stage1-hash` flags can be used instead for a faster startup: - -``` -# rkt run --stage1-name=coreos.com/rkt/stage1-kvm coreos.com/etcd:v2.0.9 -# rkt run --stage1-hash= coreos.com/etcd:v2.0.9 -``` +If the image is not in the store, `--stage1-name` will perform discovery and fetch the image. ## How does it work? diff --git a/Documentation/subcommands/enter.md b/Documentation/subcommands/enter.md index 33b9d6b4cd..4ca3214e8d 100644 --- a/Documentation/subcommands/enter.md +++ b/Documentation/subcommands/enter.md @@ -16,18 +16,6 @@ bin data entrypoint.sh home lib64 mnt proc run selinux sys usr boot dev etc lib media opt root sbin srv tmp var ``` -## Use a Custom Stage 1 - -rkt is designed and intended to be modular, using a [staged architecture](../devel/architecture.md). - -You can use a custom stage1 by using the `--stage1-{url,path,name,hash,from-dir}` flags. - -``` -# rkt --stage1-path=/tmp/stage1.aci run coreos.com/etcd:v2.0.0 -``` - -For more details see the [hacking documentation](../hacking.md). - ## Run a Pod in the Background Work in progress. Please contribute! @@ -48,4 +36,4 @@ Work in progress. Please contribute! | `--local-config` | `/etc/rkt` | A directory path | Path to the local configuration directory | | `--system-config` | `/usr/lib/rkt` | A directory path | Path to the system configuration directory | | `--trust-keys-from-https` | `false` | `true` or `false` | Automatically trust gpg keys fetched from https | -| `--user-config` | `` | A directory path | Path to the user configuration directory | \ No newline at end of file +| `--user-config` | `` | A directory path | Path to the user configuration directory | diff --git a/Documentation/subcommands/run.md b/Documentation/subcommands/run.md index aa7ce0b976..7caafb715c 100644 --- a/Documentation/subcommands/run.md +++ b/Documentation/subcommands/run.md @@ -305,6 +305,24 @@ For example, if you use systemd, you can [run rkt using `systemd-run`](https://g If you don't use systemd, you can use [daemon](http://www.libslack.org/daemon/) as an alternative. +## Use a Custom Stage 1 + +rkt is designed and intended to be modular, using a [staged architecture](../devel/architecture.md). + +You can use a custom stage1 by using the `--stage1-{url,path,name,hash,from-dir}` flags. + +``` +# rkt --stage1-path=/tmp/stage1.aci run coreos.com/etcd:v2.0.0 +``` + +rkt expects stage1 images to be signed except in the following cases: + +* it is the default stage1 image and it's in the same directory as the rkt binary +* `--stage1-{name,hash}` is used and the image is already in the store +* `--stage1-{url,path,from-dir}` is used and the image is in the default directory configured at build time + +For more details see the [hacking documentation](../hacking.md). + ## Options | Flag | Default | Options | Description | From 1b3c4d24ae8ca6b51850970a450e5ccd4b47ee80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Thu, 31 Mar 2016 09:46:34 +0200 Subject: [PATCH 0040/1304] Godeps: bump peterbourgon/diskv to v1.0.0 Use tagged releases for dependencies. --- Godeps/Godeps.json | 3 +- .../github.com/peterbourgon/diskv/diskv.go | 42 +++++++------ .../examples/content-addressable-store/cas.go | 63 ------------------- .../super-simple-store/super-simple-store.go | 30 --------- 4 files changed, 24 insertions(+), 114 deletions(-) delete mode 100644 Godeps/_workspace/src/github.com/peterbourgon/diskv/examples/content-addressable-store/cas.go delete mode 100644 Godeps/_workspace/src/github.com/peterbourgon/diskv/examples/super-simple-store/super-simple-store.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index c34c51d13a..90834e6389 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -380,7 +380,8 @@ }, { "ImportPath": "github.com/peterbourgon/diskv", - "Rev": "508f5671a72eeaef05cf8c24abe7fbc1c07faf69" + "Comment": "v1.0.0", + "Rev": "f2c8925fb5e0e9614e23499efa68df1924ba6add" }, { "ImportPath": "github.com/russross/blackfriday", diff --git a/Godeps/_workspace/src/github.com/peterbourgon/diskv/diskv.go b/Godeps/_workspace/src/github.com/peterbourgon/diskv/diskv.go index 512b5353fd..ea05842cbd 100644 --- a/Godeps/_workspace/src/github.com/peterbourgon/diskv/diskv.go +++ b/Godeps/_workspace/src/github.com/peterbourgon/diskv/diskv.go @@ -56,8 +56,8 @@ type Options struct { // Diskv implements the Diskv interface. You shouldn't construct Diskv // structures directly; instead, use the New constructor. type Diskv struct { - sync.RWMutex Options + mu sync.RWMutex cache map[string][]byte cacheSize uint64 } @@ -109,8 +109,8 @@ func (d *Diskv) WriteStream(key string, r io.Reader, sync bool) error { return errEmptyKey } - d.Lock() - defer d.Unlock() + d.mu.Lock() + defer d.mu.Unlock() return d.writeStreamWithLock(key, r, sync) } @@ -143,6 +143,7 @@ func (d *Diskv) writeStreamWithLock(key string, r io.Reader, sync bool) error { } if err := wc.Close(); err != nil { + f.Close() // error deliberately ignored return fmt.Errorf("compression close: %s", err) } @@ -180,8 +181,8 @@ func (d *Diskv) Import(srcFilename, dstKey string, move bool) (err error) { return errImportDirectory } - d.Lock() - defer d.Unlock() + d.mu.Lock() + defer d.mu.Unlock() if err := d.ensurePathWithLock(dstKey); err != nil { return fmt.Errorf("ensure path: %s", err) @@ -233,8 +234,8 @@ func (d *Diskv) Read(key string) ([]byte, error) { // If compression is enabled, ReadStream taps into the io.Reader stream prior // to decompression, and caches the compressed data. func (d *Diskv) ReadStream(key string, direct bool) (io.ReadCloser, error) { - d.RLock() - defer d.RUnlock() + d.mu.RLock() + defer d.mu.RUnlock() if val, ok := d.cache[key]; ok { if !direct { @@ -246,8 +247,8 @@ func (d *Diskv) ReadStream(key string, direct bool) (io.ReadCloser, error) { } go func() { - d.Lock() - defer d.Unlock() + d.mu.Lock() + defer d.mu.Unlock() d.uncacheWithLock(key, uint64(len(val))) }() } @@ -351,8 +352,8 @@ func (s *siphon) Read(p []byte) (int, error) { // Erase synchronously erases the given key from the disk and the cache. func (d *Diskv) Erase(key string) error { - d.Lock() - defer d.Unlock() + d.mu.Lock() + defer d.mu.Unlock() d.bustCacheWithLock(key) @@ -364,14 +365,15 @@ func (d *Diskv) Erase(key string) error { // erase from disk filename := d.completeFilename(key) if s, err := os.Stat(filename); err == nil { - if !!s.IsDir() { + if s.IsDir() { return errBadKey } if err = os.Remove(filename); err != nil { - return fmt.Errorf("remove: %s", err) + return err } } else { - return fmt.Errorf("stat: %s", err) + // Return err as-is so caller can do os.IsNotExist(err). + return err } // clean up and return @@ -384,8 +386,8 @@ func (d *Diskv) Erase(key string) error { // diskv-related data. Care should be taken to always specify a diskv base // directory that is exclusively for diskv data. func (d *Diskv) EraseAll() error { - d.Lock() - defer d.Unlock() + d.mu.Lock() + defer d.mu.Unlock() d.cache = make(map[string][]byte) d.cacheSize = 0 return os.RemoveAll(d.BasePath) @@ -393,8 +395,8 @@ func (d *Diskv) EraseAll() error { // Has returns true if the given key exists. func (d *Diskv) Has(key string) bool { - d.Lock() - defer d.Unlock() + d.mu.Lock() + defer d.mu.Unlock() if _, ok := d.cache[key]; ok { return true @@ -497,8 +499,8 @@ func (d *Diskv) cacheWithLock(key string, val []byte) error { // cacheWithoutLock acquires the store's (write) mutex and calls cacheWithLock. func (d *Diskv) cacheWithoutLock(key string, val []byte) error { - d.Lock() - defer d.Unlock() + d.mu.Lock() + defer d.mu.Unlock() return d.cacheWithLock(key, val) } diff --git a/Godeps/_workspace/src/github.com/peterbourgon/diskv/examples/content-addressable-store/cas.go b/Godeps/_workspace/src/github.com/peterbourgon/diskv/examples/content-addressable-store/cas.go deleted file mode 100644 index a3abaaf775..0000000000 --- a/Godeps/_workspace/src/github.com/peterbourgon/diskv/examples/content-addressable-store/cas.go +++ /dev/null @@ -1,63 +0,0 @@ -package main - -import ( - "crypto/md5" - "fmt" - "io" - - "github.com/peterbourgon/diskv" -) - -const transformBlockSize = 2 // grouping of chars per directory depth - -func blockTransform(s string) []string { - var ( - sliceSize = len(s) / transformBlockSize - pathSlice = make([]string, sliceSize) - ) - for i := 0; i < sliceSize; i++ { - from, to := i*transformBlockSize, (i*transformBlockSize)+transformBlockSize - pathSlice[i] = s[from:to] - } - return pathSlice -} - -func main() { - d := diskv.New(diskv.Options{ - BasePath: "data", - Transform: blockTransform, - CacheSizeMax: 1024 * 1024, // 1MB - }) - - for _, valueStr := range []string{ - "I am the very model of a modern Major-General", - "I've information vegetable, animal, and mineral", - "I know the kings of England, and I quote the fights historical", - "From Marathon to Waterloo, in order categorical", - "I'm very well acquainted, too, with matters mathematical", - "I understand equations, both the simple and quadratical", - "About binomial theorem I'm teeming with a lot o' news", - "With many cheerful facts about the square of the hypotenuse", - } { - d.Write(md5sum(valueStr), []byte(valueStr)) - } - - var keyCount int - for key := range d.Keys(nil) { - val, err := d.Read(key) - if err != nil { - panic(fmt.Sprintf("key %s had no value", key)) - } - fmt.Printf("%s: %s\n", key, val) - keyCount++ - } - fmt.Printf("%d total keys\n", keyCount) - - // d.EraseAll() // leave it commented out to see how data is kept on disk -} - -func md5sum(s string) string { - h := md5.New() - io.WriteString(h, s) - return fmt.Sprintf("%x", h.Sum(nil)) -} diff --git a/Godeps/_workspace/src/github.com/peterbourgon/diskv/examples/super-simple-store/super-simple-store.go b/Godeps/_workspace/src/github.com/peterbourgon/diskv/examples/super-simple-store/super-simple-store.go deleted file mode 100644 index b5da11d646..0000000000 --- a/Godeps/_workspace/src/github.com/peterbourgon/diskv/examples/super-simple-store/super-simple-store.go +++ /dev/null @@ -1,30 +0,0 @@ -package main - -import ( - "fmt" - - "github.com/peterbourgon/diskv" -) - -func main() { - d := diskv.New(diskv.Options{ - BasePath: "my-diskv-data-directory", - Transform: func(s string) []string { return []string{} }, - CacheSizeMax: 1024 * 1024, // 1MB - }) - - key := "alpha" - if err := d.Write(key, []byte{'1', '2', '3'}); err != nil { - panic(err) - } - - value, err := d.Read(key) - if err != nil { - panic(err) - } - fmt.Printf("%v\n", value) - - if err := d.Erase(key); err != nil { - panic(err) - } -} From fae673fc7d9171876d8b082a8e14bd47db871959 Mon Sep 17 00:00:00 2001 From: Yifan Gu Date: Thu, 24 Mar 2016 15:49:23 -0700 Subject: [PATCH 0041/1304] api_service: Return cgroup in ListPods()/InspectPod(). Add Pod.Cgroup to indicate the cgroup of the pod. --- api/v1alpha/api.pb.go | 153 ++++++++++++++++++++-------------------- api/v1alpha/api.proto | 3 + common/cgroup/cgroup.go | 15 +++- rkt/api_service.go | 27 +++++-- 4 files changed, 113 insertions(+), 85 deletions(-) diff --git a/api/v1alpha/api.pb.go b/api/v1alpha/api.pb.go index 06e8d7bfaa..80151f7489 100644 --- a/api/v1alpha/api.pb.go +++ b/api/v1alpha/api.pb.go @@ -338,6 +338,8 @@ type Pod struct { Manifest []byte `protobuf:"bytes,6,opt,name=manifest,proto3" json:"manifest,omitempty"` // Annotations on this pod. Annotations []*KeyValue `protobuf:"bytes,7,rep,name=annotations" json:"annotations,omitempty"` + // Cgroup of the pod, empty if the pod is not running. + Cgroup string `protobuf:"bytes,8,opt,name=cgroup" json:"cgroup,omitempty"` } func (m *Pod) Reset() { *m = Pod{} } @@ -1124,17 +1126,17 @@ var _PublicAPI_serviceDesc = grpc.ServiceDesc{ } var fileDescriptor0 = []byte{ - // 1430 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x57, 0xdb, 0x6e, 0xdb, 0x46, - 0x13, 0x8e, 0x0e, 0xd4, 0x61, 0xa4, 0xc8, 0xd2, 0xda, 0x89, 0x65, 0xe5, 0xe4, 0xf0, 0xff, 0x1b, - 0xa4, 0xbe, 0x70, 0x5b, 0x27, 0xcd, 0x4d, 0x81, 0x22, 0x8a, 0x4d, 0x1b, 0x6a, 0x6c, 0x49, 0x50, - 0x94, 0xa0, 0xb9, 0x22, 0x68, 0x69, 0xe5, 0x10, 0xa1, 0x48, 0x96, 0xa4, 0x9c, 0xb8, 0x97, 0x7d, - 0x81, 0x3e, 0x42, 0xfb, 0x16, 0x05, 0x7a, 0xd3, 0x77, 0x29, 0xd0, 0xf7, 0xe8, 0xec, 0x72, 0x49, - 0x2e, 0x29, 0xea, 0xa2, 0x77, 0xe6, 0xcc, 0xec, 0x37, 0xdf, 0xcc, 0xce, 0x7c, 0x2b, 0x43, 0xdd, + // 1442 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x57, 0x4b, 0x72, 0xdb, 0x46, + 0x13, 0x36, 0x1f, 0xe0, 0xa3, 0x49, 0x53, 0xe4, 0x48, 0xb6, 0x28, 0xfa, 0x25, 0xe3, 0xff, 0xe3, + 0x72, 0xb4, 0x50, 0x12, 0xd9, 0xf1, 0x26, 0x55, 0x29, 0xd3, 0x12, 0xa4, 0x62, 0x2c, 0x91, 0x2c, + 0x9a, 0x76, 0xc5, 0x2b, 0x14, 0x44, 0x0e, 0x65, 0x94, 0x41, 0x00, 0x01, 0x40, 0xd9, 0xca, 0x32, + 0x17, 0xc8, 0x11, 0x92, 0x5b, 0x64, 0x99, 0x7d, 0x8e, 0x91, 0xaa, 0xdc, 0x23, 0x3d, 0x83, 0x01, + 0x30, 0x00, 0xc1, 0x45, 0x76, 0x42, 0x77, 0xcf, 0xd7, 0x5f, 0xf7, 0x74, 0x7f, 0x43, 0x41, 0xdd, 0x70, 0xcd, 0x43, 0xd7, 0x73, 0x02, 0x87, 0x54, 0xaf, 0xbf, 0x31, 0x2c, 0xf7, 0x83, 0xa1, 0xbe, 0x84, 0xc6, 0x60, 0x69, 0x5c, 0xd1, 0x53, 0xc7, 0x5b, 0x1a, 0x01, 0xd9, 0x87, 0x72, 0x70, 0xe3, 0xd2, 0x6e, 0x61, 0xbf, 0xf0, 0xb4, 0x75, 0x44, 0x0e, 0x45, 0xd8, 0x21, 0x8f, 0x99, 0xa2, 0x87, - 0x6c, 0x41, 0xf5, 0x9a, 0x7a, 0xbe, 0xe9, 0xd8, 0xdd, 0x22, 0x06, 0xd5, 0xd5, 0xbf, 0x0a, 0xa0, + 0x6c, 0x41, 0xf5, 0x9a, 0x7a, 0xbe, 0xe9, 0xd8, 0xdd, 0x22, 0x06, 0xd5, 0xd5, 0x3f, 0x0b, 0xa0, 0x70, 0x37, 0xf9, 0x12, 0x1a, 0x97, 0x86, 0x4f, 0xf5, 0x05, 0xc7, 0xe2, 0x18, 0x8d, 0xa3, 0x9d, 0x34, 0x86, 0xc8, 0x03, 0x50, 0x34, 0xe7, 0x21, 0x00, 0x69, 0x42, 0xd9, 0x36, 0x96, 0xb4, 0x5b, 0xe2, 0x5f, 0x12, 0x7e, 0x99, 0x1b, 0xba, 0xd0, 0x36, 0x97, 0xae, 0xe3, 0x05, 0x7a, 0x60, 0x2e, @@ -1146,73 +1148,74 @@ var fileDescriptor0 = []byte{ 0x01, 0x4a, 0x7d, 0xd7, 0xcd, 0x9c, 0x78, 0x00, 0x8a, 0xc9, 0xca, 0xe4, 0x47, 0x1a, 0x47, 0xad, 0x74, 0xf1, 0xd8, 0x5e, 0x05, 0x0b, 0x08, 0xc2, 0x5a, 0x5b, 0x12, 0x17, 0x44, 0x7a, 0xc3, 0x1c, 0xa4, 0x03, 0x75, 0xfa, 0xd9, 0x0c, 0xf4, 0x99, 0x33, 0xa7, 0xbc, 0x01, 0x9d, 0x6c, 0x19, 0xca, - 0xa6, 0x32, 0xfe, 0x44, 0x46, 0x63, 0x67, 0x2e, 0x7a, 0x1b, 0xf2, 0x69, 0x40, 0xc9, 0x15, 0x8d, + 0xa6, 0x32, 0xfe, 0x42, 0x46, 0x63, 0x67, 0x2e, 0x7a, 0x1b, 0xf2, 0x69, 0x40, 0xc9, 0x15, 0x8d, 0xee, 0x6c, 0xce, 0x8e, 0xa7, 0xc2, 0xec, 0x3d, 0x28, 0x1b, 0xae, 0xeb, 0x63, 0x62, 0x96, 0xa3, 0x29, 0xd3, 0x23, 0x2a, 0xd4, 0xec, 0xb0, 0x4b, 0x11, 0x87, 0x76, 0xec, 0x8f, 0xda, 0xb7, 0x7e, - 0x23, 0x19, 0xf2, 0xd5, 0x4d, 0xe4, 0x9f, 0x40, 0x2d, 0xfa, 0x9b, 0x91, 0xc6, 0xbf, 0x45, 0x05, - 0xb7, 0x41, 0xb9, 0x66, 0x56, 0x31, 0x6d, 0xbf, 0x17, 0xa0, 0x8e, 0x74, 0x4f, 0x4d, 0x2b, 0xa0, - 0x1e, 0x8b, 0x34, 0xe7, 0x3e, 0x46, 0x96, 0x30, 0xf2, 0x31, 0x54, 0x78, 0x79, 0x3e, 0x86, 0x96, - 0xf2, 0xeb, 0xeb, 0xb0, 0x1d, 0x70, 0x75, 0x76, 0x61, 0x3e, 0x76, 0x81, 0x9d, 0x42, 0x13, 0xbf, - 0x31, 0x9d, 0x01, 0x95, 0xb9, 0xe9, 0x0e, 0xdc, 0x16, 0x95, 0x8a, 0x48, 0x85, 0x9b, 0x33, 0xa5, - 0x54, 0x36, 0x95, 0xf2, 0x77, 0x21, 0xda, 0xa9, 0x1c, 0x92, 0xd8, 0x21, 0xd7, 0xa3, 0x0b, 0xf3, - 0xb3, 0xa0, 0x59, 0x27, 0x78, 0x5f, 0x7c, 0x6b, 0x64, 0x52, 0x18, 0xf5, 0x91, 0xde, 0x20, 0x83, - 0x98, 0x13, 0x16, 0x67, 0x19, 0x97, 0xd4, 0xda, 0x7c, 0xff, 0xe4, 0x2e, 0xb4, 0xc2, 0x45, 0xa1, - 0x73, 0xdd, 0x58, 0x60, 0x66, 0x7e, 0x05, 0x25, 0xb2, 0x0b, 0x5b, 0xb1, 0xfd, 0x92, 0xe2, 0x72, - 0xfe, 0xc7, 0xfd, 0x60, 0x0c, 0x17, 0x2b, 0xcb, 0x12, 0x0c, 0xeb, 0x8c, 0x8f, 0xfa, 0x1b, 0x16, - 0x79, 0x66, 0x39, 0x97, 0x86, 0x75, 0x6a, 0x19, 0x57, 0x3e, 0x2b, 0x72, 0x6e, 0x7a, 0xe2, 0xce, - 0xf6, 0xa0, 0xe3, 0xdf, 0xf8, 0x01, 0x5d, 0xe2, 0x18, 0xdb, 0x0b, 0xf3, 0x4a, 0x67, 0xae, 0x62, - 0xb4, 0xcd, 0x96, 0x33, 0x33, 0x2c, 0xd9, 0x13, 0x2e, 0x3e, 0xd2, 0x5c, 0xf9, 0xd4, 0x93, 0x1d, - 0xa1, 0x00, 0xb0, 0xba, 0x6c, 0x9f, 0xce, 0x56, 0x1e, 0x4a, 0x0b, 0x4b, 0xc6, 0xd7, 0x9f, 0xed, - 0xda, 0x9d, 0xc0, 0x5b, 0xf9, 0x81, 0x8e, 0xad, 0xf2, 0xf5, 0x85, 0xe7, 0x2c, 0xf5, 0x0f, 0x41, - 0xe0, 0xfa, 0xbc, 0xec, 0x9a, 0xea, 0x41, 0x79, 0x60, 0x2f, 0x1c, 0xb2, 0x0d, 0x0d, 0xef, 0x63, - 0xa0, 0x47, 0xa2, 0x12, 0x32, 0xdc, 0x81, 0x26, 0x0e, 0xc2, 0x4c, 0x4f, 0x49, 0x19, 0x0b, 0x45, - 0x89, 0x8c, 0x8d, 0x21, 0xaf, 0x03, 0x68, 0x5e, 0xf1, 0x42, 0x45, 0xf2, 0x72, 0x46, 0xd6, 0xa4, - 0x2e, 0x60, 0x4e, 0x45, 0xbb, 0xa6, 0xf6, 0x66, 0x1d, 0xe5, 0x5e, 0xae, 0xa3, 0x19, 0x05, 0x64, - 0xf4, 0x45, 0x42, 0xfc, 0x62, 0x4a, 0xc7, 0x13, 0x95, 0xc8, 0x23, 0x28, 0xcf, 0x8d, 0xc0, 0xd8, - 0xbc, 0xf6, 0x01, 0x34, 0x38, 0xaa, 0x98, 0xb6, 0xc7, 0xa0, 0xb0, 0xcc, 0xe1, 0xbc, 0xe5, 0xa7, - 0x16, 0x03, 0x19, 0x8e, 0x1f, 0xee, 0x97, 0x3c, 0x79, 0xc8, 0xcb, 0x37, 0xed, 0x19, 0xd5, 0x25, - 0x0a, 0x68, 0x5b, 0xd9, 0x81, 0x69, 0x85, 0x36, 0xae, 0xbd, 0x6a, 0x1b, 0x5a, 0x67, 0x34, 0x60, - 0x0d, 0x9e, 0xd0, 0x9f, 0x56, 0xb8, 0xef, 0xea, 0x21, 0x6c, 0xc5, 0x16, 0xdf, 0xc5, 0x81, 0xa2, - 0xe4, 0x1e, 0x2a, 0x26, 0x7e, 0x8b, 0x97, 0xe0, 0x76, 0x22, 0x86, 0x68, 0x54, 0x4f, 0x61, 0xeb, - 0xdc, 0xf4, 0x03, 0xdc, 0x4d, 0x5f, 0x40, 0x90, 0xff, 0x41, 0x75, 0xc1, 0xab, 0x08, 0xd9, 0x37, - 0x24, 0xf6, 0xc9, 0xce, 0xb7, 0xa0, 0x32, 0xa7, 0x81, 0x61, 0x5a, 0xbc, 0x79, 0x35, 0xcc, 0xdb, - 0x4e, 0x70, 0x44, 0x62, 0xd4, 0x31, 0xd7, 0x99, 0x47, 0x28, 0x4d, 0x19, 0x45, 0x7d, 0x04, 0x9d, - 0x81, 0xed, 0xbb, 0x74, 0xc6, 0x8e, 0x44, 0x99, 0x25, 0xcd, 0x54, 0xbf, 0x02, 0x22, 0x07, 0x08, - 0xc8, 0x3d, 0x54, 0x52, 0x67, 0x2e, 0x4a, 0x49, 0x23, 0xfe, 0x00, 0x1d, 0xc6, 0x80, 0xef, 0x7c, - 0x5c, 0xcb, 0x17, 0xd9, 0x5a, 0xb2, 0x0f, 0x61, 0x7e, 0x35, 0xcf, 0x81, 0xc8, 0x58, 0x22, 0xf9, - 0x43, 0xa8, 0x70, 0x91, 0x8a, 0xb0, 0x32, 0xef, 0x8a, 0xfa, 0x18, 0xb6, 0x05, 0x65, 0xfe, 0x9d, - 0x57, 0xd5, 0xb7, 0xb0, 0x93, 0x0e, 0x11, 0xd0, 0xf1, 0x8b, 0x55, 0xc8, 0x7b, 0xb1, 0xd4, 0xef, - 0x60, 0x9b, 0xf1, 0xa1, 0x36, 0x1f, 0x9f, 0xb8, 0xba, 0xff, 0x43, 0x25, 0xac, 0x6e, 0xed, 0x95, - 0x97, 0x66, 0x51, 0x7d, 0x01, 0x3b, 0xe9, 0xc3, 0x49, 0x39, 0x94, 0x5b, 0xd6, 0xca, 0xe1, 0x81, - 0xea, 0x0d, 0x1f, 0xae, 0x73, 0xe7, 0x2a, 0xce, 0x87, 0x6d, 0xc2, 0xee, 0xeb, 0xf1, 0xbb, 0x86, - 0x02, 0x19, 0x09, 0xb9, 0xd8, 0x21, 0x9c, 0x63, 0xcb, 0xb4, 0xf9, 0x1c, 0x17, 0x9e, 0x2a, 0xec, - 0xc0, 0xc2, 0xb1, 0x2c, 0xe7, 0x13, 0x9f, 0xe1, 0x5a, 0x66, 0xae, 0x95, 0x9c, 0xb9, 0xe6, 0x62, - 0xa9, 0xee, 0xf3, 0x29, 0x0e, 0x53, 0x0b, 0xb6, 0x31, 0x32, 0x57, 0xf0, 0x03, 0x0a, 0xf5, 0xe4, - 0xd7, 0x50, 0x17, 0xbb, 0x7a, 0xd1, 0x3f, 0xd3, 0xf4, 0xe9, 0xfb, 0xb1, 0xa6, 0xbf, 0x1d, 0x9e, - 0x68, 0xa7, 0x83, 0xa1, 0x76, 0xd2, 0xbe, 0x85, 0x5a, 0xb2, 0x25, 0x79, 0xfa, 0xe3, 0xf1, 0x71, - 0xbb, 0x80, 0x2f, 0x4b, 0x47, 0x32, 0x9e, 0x8c, 0x8e, 0x5f, 0x6b, 0x93, 0x76, 0x11, 0x89, 0xb4, - 0x24, 0xf3, 0xe8, 0x78, 0xd0, 0x2e, 0x1d, 0x8c, 0xa1, 0x16, 0xff, 0x28, 0xd8, 0x85, 0x6d, 0x04, - 0xd0, 0xdf, 0x4c, 0xfb, 0xd3, 0x74, 0x12, 0xc4, 0x4b, 0x1c, 0x93, 0xb7, 0xc3, 0xe1, 0x60, 0x78, - 0x86, 0x69, 0x76, 0xa0, 0x9d, 0x98, 0xb5, 0x1f, 0x07, 0x53, 0x0c, 0x2e, 0x1e, 0xfc, 0x53, 0x80, - 0x5a, 0xfc, 0x12, 0x22, 0xe4, 0x78, 0x74, 0x92, 0x03, 0x89, 0x67, 0x13, 0x87, 0x76, 0xf1, 0x6a, - 0xf2, 0x7e, 0x84, 0x88, 0xa9, 0xf0, 0xf1, 0x44, 0x1b, 0xf7, 0x27, 0x2c, 0x55, 0x11, 0xc5, 0x99, - 0x64, 0x1d, 0x08, 0x53, 0x62, 0xcc, 0x12, 0x7b, 0xc4, 0xac, 0x8c, 0xd3, 0xb6, 0x97, 0x98, 0xfb, - 0xaf, 0x46, 0x13, 0xa4, 0x16, 0x1d, 0x6b, 0x2b, 0x99, 0xe4, 0x21, 0xf1, 0x4a, 0x3a, 0xc7, 0x89, - 0x76, 0xae, 0x4d, 0x19, 0x58, 0x35, 0x9d, 0xe3, 0xac, 0x3f, 0x79, 0x85, 0x2d, 0x6c, 0xd7, 0x0e, - 0xfe, 0x28, 0x42, 0x3d, 0x11, 0x3b, 0xbc, 0x21, 0xed, 0x9d, 0x36, 0x9c, 0xae, 0xdf, 0xd0, 0x3d, - 0xd8, 0x95, 0x3c, 0x0c, 0x29, 0xe6, 0x5f, 0xc0, 0x5f, 0x3b, 0x0f, 0xf3, 0x9d, 0x11, 0x6b, 0xac, - 0xbd, 0x07, 0x77, 0x33, 0x31, 0x48, 0x85, 0xfb, 0x4a, 0x28, 0x17, 0x77, 0x32, 0x3e, 0x51, 0x4e, - 0x19, 0x77, 0x67, 0x3f, 0xe3, 0x12, 0xdc, 0xf5, 0xe3, 0xd1, 0xf9, 0xb9, 0x76, 0xcc, 0xa2, 0x94, - 0x0c, 0xb8, 0xb8, 0xce, 0x49, 0xd8, 0x90, 0x34, 0x38, 0xf3, 0x09, 0xf0, 0x2a, 0x6b, 0xb0, 0xe4, - 0x0a, 0xa7, 0x6a, 0x70, 0x31, 0x0e, 0x29, 0xd7, 0xc8, 0x7d, 0xe8, 0xae, 0xb9, 0x27, 0xda, 0xc5, - 0xe8, 0x1d, 0x7a, 0xeb, 0x47, 0xbf, 0x94, 0xf1, 0xc7, 0xd5, 0xea, 0xd2, 0x32, 0x67, 0xfd, 0xf1, - 0x80, 0x7c, 0x0f, 0x55, 0x21, 0xe8, 0x64, 0x37, 0x79, 0xed, 0x52, 0xa2, 0xdf, 0xeb, 0xae, 0x3b, - 0xc2, 0xad, 0x51, 0x6f, 0x91, 0x3e, 0xd4, 0x22, 0x61, 0x26, 0x49, 0x5c, 0x46, 0xf3, 0x7b, 0x7b, - 0x39, 0x9e, 0x18, 0xe2, 0x0c, 0x20, 0x91, 0x62, 0xd2, 0x93, 0x1e, 0x90, 0x8c, 0x80, 0xf7, 0xee, - 0xe5, 0xfa, 0x64, 0xa0, 0x44, 0x56, 0x25, 0xa0, 0x35, 0xdd, 0x96, 0x80, 0xd6, 0x75, 0x18, 0x81, - 0x2e, 0xa0, 0x29, 0xcb, 0x28, 0xb9, 0x9f, 0xcd, 0x2b, 0x0b, 0x70, 0xef, 0xc1, 0x06, 0x6f, 0x0c, - 0x37, 0x82, 0xa6, 0xac, 0x90, 0x12, 0x5c, 0x8e, 0xea, 0x4a, 0x70, 0x79, 0xb2, 0xaa, 0xde, 0xfa, - 0xba, 0x40, 0x5e, 0xf2, 0x4b, 0x63, 0xfa, 0x95, 0xbe, 0x34, 0x49, 0x4c, 0xd3, 0x97, 0x26, 0x4b, - 0x1d, 0x43, 0xb8, 0xac, 0xf0, 0xff, 0x10, 0x9f, 0xfd, 0x1b, 0x00, 0x00, 0xff, 0xff, 0xca, 0x1c, - 0xe0, 0x93, 0x2e, 0x0e, 0x00, 0x00, + 0x23, 0x19, 0xf2, 0xd5, 0x0d, 0xe4, 0x49, 0x0b, 0x2a, 0xb3, 0x2b, 0xcf, 0x59, 0xb9, 0x78, 0x4d, + 0xac, 0xbd, 0x4f, 0xa0, 0x16, 0xfb, 0xb0, 0x08, 0xfc, 0x5b, 0x54, 0x74, 0x1b, 0x94, 0x6b, 0x66, + 0x15, 0xd3, 0xf7, 0x7b, 0x01, 0xea, 0x48, 0xff, 0xd4, 0xb4, 0x02, 0xea, 0xb1, 0x48, 0x73, 0xee, + 0x63, 0x64, 0x09, 0x23, 0x1f, 0x43, 0x85, 0x97, 0xeb, 0x63, 0x68, 0x29, 0xbf, 0xde, 0x0e, 0xdb, + 0x09, 0x57, 0x67, 0x17, 0xe8, 0x63, 0x57, 0xd8, 0x29, 0x34, 0xf1, 0x1b, 0xd4, 0x19, 0x50, 0x99, + 0x9b, 0xee, 0xc0, 0x6d, 0x51, 0xb9, 0x88, 0x54, 0xb8, 0x39, 0x53, 0x5a, 0x65, 0xd3, 0xbd, 0xfc, + 0x5d, 0x88, 0x76, 0x2c, 0x87, 0x24, 0x76, 0xcc, 0xf5, 0xe8, 0xc2, 0xfc, 0x2c, 0x68, 0xd6, 0x09, + 0xde, 0x1f, 0xdf, 0x22, 0x99, 0x14, 0x46, 0x7d, 0xa4, 0x37, 0xc8, 0x20, 0xe6, 0x84, 0xc5, 0x59, + 0xc6, 0x25, 0xb5, 0x36, 0xcf, 0x03, 0xb9, 0x0b, 0xad, 0x70, 0x71, 0xe8, 0x5c, 0x37, 0x16, 0x98, + 0x99, 0x5f, 0x49, 0x89, 0xec, 0xc2, 0x56, 0x6c, 0xbf, 0xa4, 0xb8, 0xac, 0xff, 0x71, 0x5f, 0x18, + 0xc3, 0xc5, 0xca, 0xb2, 0x04, 0xc3, 0x3a, 0xe3, 0xa3, 0xfe, 0x86, 0x45, 0x9e, 0x59, 0xce, 0xa5, + 0x61, 0x9d, 0x5a, 0xc6, 0x95, 0xcf, 0x8a, 0x9c, 0x9b, 0x9e, 0xb8, 0xb3, 0x3d, 0xe8, 0xf8, 0x37, + 0x7e, 0x40, 0x97, 0x38, 0xd6, 0xf6, 0xc2, 0xbc, 0xd2, 0x99, 0xab, 0x18, 0x6d, 0xb7, 0xe5, 0xcc, + 0x0c, 0x4b, 0xf6, 0x84, 0x42, 0x80, 0x34, 0x57, 0x3e, 0xf5, 0x64, 0x47, 0x28, 0x08, 0xac, 0x2e, + 0xdb, 0xa7, 0xb3, 0x95, 0x87, 0x52, 0xc3, 0x92, 0x71, 0x39, 0x60, 0xbb, 0x77, 0x27, 0xf0, 0x56, + 0x7e, 0xa0, 0x63, 0xab, 0x7c, 0x7d, 0xe1, 0x39, 0x4b, 0xfd, 0x43, 0x10, 0xb8, 0x3e, 0x2f, 0xbb, + 0xa6, 0x7a, 0x50, 0x1e, 0xd8, 0x0b, 0x87, 0x6c, 0x43, 0xc3, 0xfb, 0x18, 0xe8, 0x91, 0xc8, 0x84, + 0x0c, 0x77, 0xa0, 0x89, 0x83, 0x30, 0xd3, 0x53, 0xd2, 0xc6, 0x42, 0x51, 0x32, 0x63, 0x63, 0xc8, + 0xeb, 0x00, 0x9a, 0x57, 0xbc, 0x50, 0x91, 0xbc, 0x9c, 0x91, 0x39, 0xa9, 0x0b, 0x98, 0x53, 0xd1, + 0xae, 0xa9, 0xbd, 0x59, 0x57, 0xb9, 0x97, 0xeb, 0x6a, 0x46, 0x11, 0x19, 0x7d, 0x91, 0x10, 0xbf, + 0x98, 0xf2, 0xf1, 0x44, 0x25, 0xf2, 0x08, 0xca, 0x73, 0x23, 0x30, 0x36, 0xcb, 0x40, 0x00, 0x0d, + 0x8e, 0x2a, 0xa6, 0xed, 0x31, 0x28, 0x2c, 0x73, 0x38, 0x6f, 0xf9, 0xa9, 0xc5, 0x40, 0x86, 0xe3, + 0x87, 0xfb, 0x25, 0x4f, 0x1e, 0xf2, 0xf2, 0x4d, 0x7b, 0x46, 0x75, 0x89, 0x02, 0xda, 0x56, 0x76, + 0x60, 0x5a, 0xa1, 0x8d, 0x6b, 0xb1, 0xda, 0x86, 0xd6, 0x19, 0x0d, 0x58, 0x83, 0x27, 0xf4, 0xa7, + 0x15, 0xee, 0xbf, 0x7a, 0x08, 0x5b, 0xb1, 0xc5, 0x77, 0x71, 0xa0, 0x28, 0xb9, 0x87, 0x0a, 0x8a, + 0xdf, 0xe2, 0x65, 0xb8, 0x9d, 0x88, 0x23, 0x1a, 0xd5, 0x53, 0xd8, 0x3a, 0x37, 0xfd, 0x00, 0x77, + 0xd3, 0x17, 0x10, 0xe4, 0x7f, 0x50, 0x5d, 0xf0, 0x2a, 0x42, 0xf6, 0x0d, 0x89, 0x7d, 0xb2, 0xf3, + 0xa8, 0x1c, 0x73, 0x1a, 0x18, 0xa6, 0xc5, 0x9b, 0x57, 0xc3, 0xbc, 0xed, 0x04, 0x47, 0x24, 0x46, + 0x5d, 0x73, 0x9d, 0x79, 0x84, 0xd2, 0x94, 0x51, 0xd4, 0x47, 0xd0, 0x19, 0xd8, 0xbe, 0x4b, 0x67, + 0xec, 0x48, 0x94, 0x59, 0xd2, 0x50, 0xf5, 0x2b, 0x20, 0x72, 0x80, 0x80, 0xdc, 0x43, 0x65, 0x75, + 0xe6, 0xa2, 0x94, 0x34, 0xe2, 0x0f, 0xd0, 0x61, 0x0c, 0xf8, 0xce, 0xc7, 0xb5, 0x7c, 0x91, 0xad, + 0x25, 0xfb, 0x30, 0xe6, 0x57, 0xf3, 0x1c, 0x88, 0x8c, 0x25, 0x92, 0x3f, 0x84, 0x0a, 0x17, 0xa9, + 0x08, 0x2b, 0xf3, 0xce, 0xa8, 0x8f, 0x61, 0x5b, 0x50, 0xe6, 0xdf, 0x79, 0x55, 0x7d, 0x0b, 0x3b, + 0xe9, 0x10, 0x01, 0x1d, 0xbf, 0x60, 0x85, 0xbc, 0x17, 0x4c, 0xfd, 0x0e, 0xb6, 0x19, 0x1f, 0x6a, + 0xf3, 0xf1, 0x89, 0xab, 0xfb, 0x3f, 0x54, 0xc2, 0xea, 0xd6, 0x5e, 0x7d, 0x69, 0x16, 0xd5, 0x17, + 0xb0, 0x93, 0x3e, 0x9c, 0x94, 0x43, 0xb9, 0x65, 0xad, 0x1c, 0x1e, 0xa8, 0xde, 0xf0, 0xe1, 0x3a, + 0x77, 0xae, 0xe2, 0x7c, 0xd8, 0x26, 0xec, 0xbe, 0x1e, 0xbf, 0x73, 0x28, 0x90, 0x91, 0x90, 0x8b, + 0x1d, 0xc2, 0x39, 0xb6, 0x4c, 0x9b, 0xcf, 0x71, 0xe1, 0xa9, 0xc2, 0x0e, 0x2c, 0x1c, 0xcb, 0x72, + 0x3e, 0xf1, 0x19, 0xae, 0x65, 0xe6, 0x5a, 0xc9, 0x99, 0x6b, 0x2e, 0x96, 0xea, 0x3e, 0x9f, 0xe2, + 0x30, 0xb5, 0x60, 0x1b, 0x23, 0x73, 0x05, 0x3f, 0xa0, 0x50, 0x4f, 0x7e, 0x1d, 0x75, 0xb1, 0xab, + 0x17, 0xfd, 0x33, 0x4d, 0x9f, 0xbe, 0x1f, 0x6b, 0xfa, 0xdb, 0xe1, 0x89, 0x76, 0x3a, 0x18, 0x6a, + 0x27, 0xed, 0x5b, 0xa8, 0x25, 0x5b, 0x92, 0xa7, 0x3f, 0x1e, 0x1f, 0xb7, 0x0b, 0xf8, 0xb2, 0x74, + 0x24, 0xe3, 0xc9, 0xe8, 0xf8, 0xb5, 0x36, 0x69, 0x17, 0x91, 0x48, 0x4b, 0x32, 0x8f, 0x8e, 0x07, + 0xed, 0xd2, 0xc1, 0x18, 0x6a, 0xf1, 0x8f, 0x84, 0x5d, 0xd8, 0x46, 0x00, 0xfd, 0xcd, 0xb4, 0x3f, + 0x4d, 0x27, 0x41, 0xbc, 0xc4, 0x31, 0x79, 0x3b, 0x1c, 0x0e, 0x86, 0x67, 0x98, 0x66, 0x07, 0xda, + 0x89, 0x59, 0xfb, 0x71, 0x30, 0xc5, 0xe0, 0xe2, 0xc1, 0x3f, 0x05, 0xa8, 0xc5, 0x2f, 0x21, 0x42, + 0x8e, 0x47, 0x27, 0x39, 0x90, 0x78, 0x36, 0x71, 0x68, 0x17, 0xaf, 0x26, 0xef, 0x47, 0x88, 0x98, + 0x0a, 0x1f, 0x4f, 0xb4, 0x71, 0x7f, 0xc2, 0x52, 0x15, 0x51, 0x9c, 0x49, 0xd6, 0x81, 0x30, 0x25, + 0xc6, 0x2c, 0xb1, 0x47, 0xcc, 0xca, 0x38, 0x6d, 0x7b, 0x89, 0xb9, 0xff, 0x6a, 0x34, 0x41, 0x6a, + 0xd1, 0xb1, 0xb6, 0x92, 0x49, 0x1e, 0x12, 0xaf, 0xa4, 0x73, 0x9c, 0x68, 0xe7, 0xda, 0x94, 0x81, + 0x55, 0xd3, 0x39, 0xce, 0xfa, 0x93, 0x57, 0xd8, 0xc2, 0x76, 0xed, 0xe0, 0x8f, 0x22, 0xd4, 0x13, + 0xb1, 0xc3, 0x1b, 0xd2, 0xde, 0x69, 0xc3, 0xe9, 0xfa, 0x0d, 0xdd, 0x83, 0x5d, 0xc9, 0xc3, 0x90, + 0x62, 0xfe, 0x05, 0xfc, 0xf5, 0xf3, 0x30, 0xdf, 0x19, 0xb1, 0xc6, 0xda, 0x7b, 0x70, 0x37, 0x13, + 0x83, 0x54, 0xb8, 0xaf, 0x84, 0x72, 0x71, 0x27, 0xe3, 0x13, 0xe5, 0x94, 0x71, 0x77, 0xf6, 0x33, + 0x2e, 0xc1, 0x5d, 0x3f, 0x1e, 0x9d, 0x9f, 0x6b, 0xc7, 0x2c, 0x4a, 0xc9, 0x80, 0x8b, 0xeb, 0x9c, + 0x84, 0x0d, 0x49, 0x83, 0x33, 0x9f, 0x00, 0xaf, 0xb2, 0x06, 0x4b, 0xae, 0x70, 0xaa, 0x06, 0x17, + 0xe3, 0x90, 0x72, 0x8d, 0xdc, 0x87, 0xee, 0x9a, 0x7b, 0xa2, 0x5d, 0x8c, 0xde, 0xa1, 0xb7, 0x7e, + 0xf4, 0x4b, 0x19, 0x7f, 0x5c, 0xad, 0x2e, 0x2d, 0x73, 0xd6, 0x1f, 0x0f, 0xc8, 0xf7, 0x50, 0x15, + 0x82, 0x4e, 0x76, 0x93, 0xd7, 0x2e, 0x25, 0xfa, 0xbd, 0xee, 0xba, 0x23, 0xdc, 0x1a, 0xf5, 0x16, + 0xe9, 0x43, 0x2d, 0x12, 0x66, 0x92, 0xc4, 0x65, 0x34, 0xbf, 0xb7, 0x97, 0xe3, 0x89, 0x21, 0xce, + 0x00, 0x12, 0x29, 0x26, 0x3d, 0xe9, 0x01, 0xc9, 0x08, 0x78, 0xef, 0x5e, 0xae, 0x4f, 0x06, 0x4a, + 0x64, 0x55, 0x02, 0x5a, 0xd3, 0x6d, 0x09, 0x68, 0x5d, 0x87, 0x11, 0xe8, 0x02, 0x9a, 0xb2, 0x8c, + 0x92, 0xfb, 0xd9, 0xbc, 0xb2, 0x00, 0xf7, 0x1e, 0x6c, 0xf0, 0xc6, 0x70, 0x23, 0x68, 0xca, 0x0a, + 0x29, 0xc1, 0xe5, 0xa8, 0xae, 0x04, 0x97, 0x27, 0xab, 0xea, 0xad, 0xaf, 0x0b, 0xe4, 0x25, 0xbf, + 0x34, 0xa6, 0x5f, 0xe9, 0x4b, 0x93, 0xc4, 0x34, 0x7d, 0x69, 0xb2, 0xd4, 0x31, 0x84, 0xcb, 0x0a, + 0xff, 0x8f, 0xf1, 0xd9, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xee, 0xd0, 0xb0, 0x32, 0x3e, 0x0e, + 0x00, 0x00, } diff --git a/api/v1alpha/api.proto b/api/v1alpha/api.proto index efa97c47b2..fca5c92bdb 100644 --- a/api/v1alpha/api.proto +++ b/api/v1alpha/api.proto @@ -172,6 +172,9 @@ message Pod { // Annotations on this pod. repeated KeyValue annotations = 7; + + // Cgroup of the pod, empty if the pod is not running. + string cgroup = 8; } message KeyValue { diff --git a/common/cgroup/cgroup.go b/common/cgroup/cgroup.go index 17e58d88be..967485aedb 100644 --- a/common/cgroup/cgroup.go +++ b/common/cgroup/cgroup.go @@ -182,8 +182,7 @@ func getControllerRWFiles(controller string) []string { return nil } -func parseOwnCgroupController(controller string) ([]string, error) { - cgroupPath := "/proc/self/cgroup" +func parseCgroupController(cgroupPath, controller string) ([]string, error) { cg, err := os.Open(cgroupPath) if err != nil { return nil, errwrap.Wrap(errors.New("error opening /proc/self/cgroup"), err) @@ -210,7 +209,17 @@ func parseOwnCgroupController(controller string) ([]string, error) { // GetOwnCgroupPath returns the cgroup path of this process in controller // hierarchy func GetOwnCgroupPath(controller string) (string, error) { - parts, err := parseOwnCgroupController(controller) + parts, err := parseCgroupController("/proc/self/cgroup", controller) + if err != nil { + return "", err + } + return parts[2], nil +} + +// GetCgroupPathByPid returns the cgroup path of the process with the given pid +// and given controller. +func GetCgroupPathByPid(pid int, controller string) (string, error) { + parts, err := parseCgroupController(fmt.Sprintf("/proc/%d/cgroup", pid), controller) if err != nil { return "", err } diff --git a/rkt/api_service.go b/rkt/api_service.go index 31ee70103a..63ed9b4b1c 100644 --- a/rkt/api_service.go +++ b/rkt/api_service.go @@ -29,6 +29,7 @@ import ( "github.com/appc/spec/schema/types" "github.com/coreos/rkt/api/v1alpha" "github.com/coreos/rkt/common" + "github.com/coreos/rkt/common/cgroup" "github.com/coreos/rkt/pkg/set" "github.com/coreos/rkt/store" "github.com/coreos/rkt/version" @@ -303,13 +304,6 @@ func getBasicPod(p *pod) (*v1alpha.Pod, *schema.PodManifest, error) { case Running: pod.State = v1alpha.PodState_POD_STATE_RUNNING pod.Networks = getNetworks(p) - - // Get cgroup. - cgroup, err := p.getCgroup() - if err != nil { - return nil, nil, err - } - pod.Cgroup = cgroup case Deleting: pod.State = v1alpha.PodState_POD_STATE_DELETING case Exited: @@ -341,6 +335,25 @@ func getBasicPod(p *pod) (*v1alpha.Pod, *schema.PodManifest, error) { pod.Pid = int32(pid) } + if pod.State == v1alpha.PodState_POD_STATE_RUNNING { + // Get cgroup for the "name=systemd" controller. + pid, err := p.getContainerPID1() + if err != nil { + return nil, nil, err + } + cgroup, err := cgroup.GetCgroupPathByPid(pid, "name=systemd") + if err != nil { + return nil, nil, err + } + + // If the stage1 systemd > v226, it will put the PID1 into "init.scope" + // implicit scope unit in the root slice. + // See https://github.com/coreos/rkt/pull/2331#issuecomment-203540543 + // + // TODO(yifan): Revisit this when using unified cgroup hierarchy. + pod.Cgroup = strings.TrimSuffix(cgroup, "/init.scope") + } + pod.Manifest = data pod.Apps = apps pod.Annotations = convertAnnotationsToKeyValue(manifest.Annotations) From b3a0850032556374329e4f083b33d74ca8452e9c Mon Sep 17 00:00:00 2001 From: Yifan Gu Date: Fri, 25 Mar 2016 11:58:16 -0700 Subject: [PATCH 0042/1304] api_service: Add cgroups in the pod filter. If PodFilter.Cgroups is not empty, then only the pods whose cgroups are listed will be returned. --- api/v1alpha/api.pb.go | 186 +++++++++++++++++++++--------------------- api/v1alpha/api.proto | 3 + rkt/api_service.go | 8 ++ 3 files changed, 105 insertions(+), 92 deletions(-) diff --git a/api/v1alpha/api.pb.go b/api/v1alpha/api.pb.go index 80151f7489..99783930f9 100644 --- a/api/v1alpha/api.pb.go +++ b/api/v1alpha/api.pb.go @@ -395,6 +395,8 @@ type PodFilter struct { NetworkNames []string `protobuf:"bytes,5,rep,name=network_names" json:"network_names,omitempty"` // If not empty, the pods that have all of the annotations will be returned. Annotations []*KeyValue `protobuf:"bytes,6,rep,name=annotations" json:"annotations,omitempty"` + // If not empty, the pods whose cgroup are listed will be returned. + Cgroups []string `protobuf:"bytes,7,rep,name=cgroups" json:"cgroups,omitempty"` } func (m *PodFilter) Reset() { *m = PodFilter{} } @@ -1126,96 +1128,96 @@ var _PublicAPI_serviceDesc = grpc.ServiceDesc{ } var fileDescriptor0 = []byte{ - // 1442 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x57, 0x4b, 0x72, 0xdb, 0x46, - 0x13, 0x36, 0x1f, 0xe0, 0xa3, 0x49, 0x53, 0xe4, 0x48, 0xb6, 0x28, 0xfa, 0x25, 0xe3, 0xff, 0xe3, - 0x72, 0xb4, 0x50, 0x12, 0xd9, 0xf1, 0x26, 0x55, 0x29, 0xd3, 0x12, 0xa4, 0x62, 0x2c, 0x91, 0x2c, - 0x9a, 0x76, 0xc5, 0x2b, 0x14, 0x44, 0x0e, 0x65, 0x94, 0x41, 0x00, 0x01, 0x40, 0xd9, 0xca, 0x32, - 0x17, 0xc8, 0x11, 0x92, 0x5b, 0x64, 0x99, 0x7d, 0x8e, 0x91, 0xaa, 0xdc, 0x23, 0x3d, 0x83, 0x01, - 0x30, 0x00, 0xc1, 0x45, 0x76, 0x42, 0x77, 0xcf, 0xd7, 0x5f, 0xf7, 0x74, 0x7f, 0x43, 0x41, 0xdd, - 0x70, 0xcd, 0x43, 0xd7, 0x73, 0x02, 0x87, 0x54, 0xaf, 0xbf, 0x31, 0x2c, 0xf7, 0x83, 0xa1, 0xbe, - 0x84, 0xc6, 0x60, 0x69, 0x5c, 0xd1, 0x53, 0xc7, 0x5b, 0x1a, 0x01, 0xd9, 0x87, 0x72, 0x70, 0xe3, - 0xd2, 0x6e, 0x61, 0xbf, 0xf0, 0xb4, 0x75, 0x44, 0x0e, 0x45, 0xd8, 0x21, 0x8f, 0x99, 0xa2, 0x87, - 0x6c, 0x41, 0xf5, 0x9a, 0x7a, 0xbe, 0xe9, 0xd8, 0xdd, 0x22, 0x06, 0xd5, 0xd5, 0x3f, 0x0b, 0xa0, - 0x70, 0x37, 0xf9, 0x12, 0x1a, 0x97, 0x86, 0x4f, 0xf5, 0x05, 0xc7, 0xe2, 0x18, 0x8d, 0xa3, 0x9d, - 0x34, 0x86, 0xc8, 0x03, 0x50, 0x34, 0xe7, 0x21, 0x00, 0x69, 0x42, 0xd9, 0x36, 0x96, 0xb4, 0x5b, - 0xe2, 0x5f, 0x12, 0x7e, 0x99, 0x1b, 0xba, 0xd0, 0x36, 0x97, 0xae, 0xe3, 0x05, 0x7a, 0x60, 0x2e, - 0xa9, 0x1f, 0x18, 0x4b, 0xb7, 0xab, 0xa0, 0xa7, 0x44, 0xda, 0x50, 0x5b, 0x1a, 0xb6, 0xb9, 0x40, - 0x63, 0xb7, 0x82, 0x96, 0x26, 0x83, 0xf2, 0xcd, 0x9f, 0x69, 0xb7, 0xca, 0xfd, 0x4f, 0xa0, 0x61, - 0xd8, 0xb6, 0x13, 0x18, 0x01, 0xa2, 0xf9, 0xdd, 0xda, 0x7e, 0x09, 0xf9, 0x74, 0x62, 0x3e, 0xaf, - 0xe9, 0xcd, 0x3b, 0xc3, 0x5a, 0x51, 0xf5, 0x19, 0x54, 0x87, 0x34, 0xf8, 0xe4, 0x78, 0x1f, 0x63, - 0x2e, 0x85, 0x88, 0x99, 0xe9, 0x5e, 0x3f, 0x4f, 0x78, 0xe2, 0xd7, 0x8b, 0x90, 0xa7, 0xfa, 0x6b, - 0x01, 0x4a, 0x7d, 0xd7, 0xcd, 0x9c, 0x78, 0x00, 0x8a, 0xc9, 0xca, 0xe4, 0x47, 0x1a, 0x47, 0xad, - 0x74, 0xf1, 0xd8, 0x5e, 0x05, 0x0b, 0x08, 0xc2, 0x5a, 0x5b, 0x12, 0x17, 0x44, 0x7a, 0xc3, 0x1c, - 0xa4, 0x03, 0x75, 0xfa, 0xd9, 0x0c, 0xf4, 0x99, 0x33, 0xa7, 0xbc, 0x01, 0x9d, 0x6c, 0x19, 0xca, - 0xa6, 0x32, 0xfe, 0x42, 0x46, 0x63, 0x67, 0x2e, 0x7a, 0x1b, 0xf2, 0x69, 0x40, 0xc9, 0x15, 0x8d, - 0xee, 0x6c, 0xce, 0x8e, 0xa7, 0xc2, 0xec, 0x3d, 0x28, 0x1b, 0xae, 0xeb, 0x63, 0x62, 0x96, 0xa3, - 0x29, 0xd3, 0x23, 0x2a, 0xd4, 0xec, 0xb0, 0x4b, 0x11, 0x87, 0x76, 0xec, 0x8f, 0xda, 0xb7, 0x7e, - 0x23, 0x19, 0xf2, 0xd5, 0x0d, 0xe4, 0x49, 0x0b, 0x2a, 0xb3, 0x2b, 0xcf, 0x59, 0xb9, 0x78, 0x4d, - 0xac, 0xbd, 0x4f, 0xa0, 0x16, 0xfb, 0xb0, 0x08, 0xfc, 0x5b, 0x54, 0x74, 0x1b, 0x94, 0x6b, 0x66, - 0x15, 0xd3, 0xf7, 0x7b, 0x01, 0xea, 0x48, 0xff, 0xd4, 0xb4, 0x02, 0xea, 0xb1, 0x48, 0x73, 0xee, - 0x63, 0x64, 0x09, 0x23, 0x1f, 0x43, 0x85, 0x97, 0xeb, 0x63, 0x68, 0x29, 0xbf, 0xde, 0x0e, 0xdb, - 0x09, 0x57, 0x67, 0x17, 0xe8, 0x63, 0x57, 0xd8, 0x29, 0x34, 0xf1, 0x1b, 0xd4, 0x19, 0x50, 0x99, - 0x9b, 0xee, 0xc0, 0x6d, 0x51, 0xb9, 0x88, 0x54, 0xb8, 0x39, 0x53, 0x5a, 0x65, 0xd3, 0xbd, 0xfc, - 0x5d, 0x88, 0x76, 0x2c, 0x87, 0x24, 0x76, 0xcc, 0xf5, 0xe8, 0xc2, 0xfc, 0x2c, 0x68, 0xd6, 0x09, - 0xde, 0x1f, 0xdf, 0x22, 0x99, 0x14, 0x46, 0x7d, 0xa4, 0x37, 0xc8, 0x20, 0xe6, 0x84, 0xc5, 0x59, - 0xc6, 0x25, 0xb5, 0x36, 0xcf, 0x03, 0xb9, 0x0b, 0xad, 0x70, 0x71, 0xe8, 0x5c, 0x37, 0x16, 0x98, - 0x99, 0x5f, 0x49, 0x89, 0xec, 0xc2, 0x56, 0x6c, 0xbf, 0xa4, 0xb8, 0xac, 0xff, 0x71, 0x5f, 0x18, - 0xc3, 0xc5, 0xca, 0xb2, 0x04, 0xc3, 0x3a, 0xe3, 0xa3, 0xfe, 0x86, 0x45, 0x9e, 0x59, 0xce, 0xa5, - 0x61, 0x9d, 0x5a, 0xc6, 0x95, 0xcf, 0x8a, 0x9c, 0x9b, 0x9e, 0xb8, 0xb3, 0x3d, 0xe8, 0xf8, 0x37, - 0x7e, 0x40, 0x97, 0x38, 0xd6, 0xf6, 0xc2, 0xbc, 0xd2, 0x99, 0xab, 0x18, 0x6d, 0xb7, 0xe5, 0xcc, - 0x0c, 0x4b, 0xf6, 0x84, 0x42, 0x80, 0x34, 0x57, 0x3e, 0xf5, 0x64, 0x47, 0x28, 0x08, 0xac, 0x2e, - 0xdb, 0xa7, 0xb3, 0x95, 0x87, 0x52, 0xc3, 0x92, 0x71, 0x39, 0x60, 0xbb, 0x77, 0x27, 0xf0, 0x56, - 0x7e, 0xa0, 0x63, 0xab, 0x7c, 0x7d, 0xe1, 0x39, 0x4b, 0xfd, 0x43, 0x10, 0xb8, 0x3e, 0x2f, 0xbb, - 0xa6, 0x7a, 0x50, 0x1e, 0xd8, 0x0b, 0x87, 0x6c, 0x43, 0xc3, 0xfb, 0x18, 0xe8, 0x91, 0xc8, 0x84, - 0x0c, 0x77, 0xa0, 0x89, 0x83, 0x30, 0xd3, 0x53, 0xd2, 0xc6, 0x42, 0x51, 0x32, 0x63, 0x63, 0xc8, - 0xeb, 0x00, 0x9a, 0x57, 0xbc, 0x50, 0x91, 0xbc, 0x9c, 0x91, 0x39, 0xa9, 0x0b, 0x98, 0x53, 0xd1, - 0xae, 0xa9, 0xbd, 0x59, 0x57, 0xb9, 0x97, 0xeb, 0x6a, 0x46, 0x11, 0x19, 0x7d, 0x91, 0x10, 0xbf, - 0x98, 0xf2, 0xf1, 0x44, 0x25, 0xf2, 0x08, 0xca, 0x73, 0x23, 0x30, 0x36, 0xcb, 0x40, 0x00, 0x0d, - 0x8e, 0x2a, 0xa6, 0xed, 0x31, 0x28, 0x2c, 0x73, 0x38, 0x6f, 0xf9, 0xa9, 0xc5, 0x40, 0x86, 0xe3, - 0x87, 0xfb, 0x25, 0x4f, 0x1e, 0xf2, 0xf2, 0x4d, 0x7b, 0x46, 0x75, 0x89, 0x02, 0xda, 0x56, 0x76, - 0x60, 0x5a, 0xa1, 0x8d, 0x6b, 0xb1, 0xda, 0x86, 0xd6, 0x19, 0x0d, 0x58, 0x83, 0x27, 0xf4, 0xa7, - 0x15, 0xee, 0xbf, 0x7a, 0x08, 0x5b, 0xb1, 0xc5, 0x77, 0x71, 0xa0, 0x28, 0xb9, 0x87, 0x0a, 0x8a, - 0xdf, 0xe2, 0x65, 0xb8, 0x9d, 0x88, 0x23, 0x1a, 0xd5, 0x53, 0xd8, 0x3a, 0x37, 0xfd, 0x00, 0x77, - 0xd3, 0x17, 0x10, 0xe4, 0x7f, 0x50, 0x5d, 0xf0, 0x2a, 0x42, 0xf6, 0x0d, 0x89, 0x7d, 0xb2, 0xf3, - 0xa8, 0x1c, 0x73, 0x1a, 0x18, 0xa6, 0xc5, 0x9b, 0x57, 0xc3, 0xbc, 0xed, 0x04, 0x47, 0x24, 0x46, - 0x5d, 0x73, 0x9d, 0x79, 0x84, 0xd2, 0x94, 0x51, 0xd4, 0x47, 0xd0, 0x19, 0xd8, 0xbe, 0x4b, 0x67, - 0xec, 0x48, 0x94, 0x59, 0xd2, 0x50, 0xf5, 0x2b, 0x20, 0x72, 0x80, 0x80, 0xdc, 0x43, 0x65, 0x75, - 0xe6, 0xa2, 0x94, 0x34, 0xe2, 0x0f, 0xd0, 0x61, 0x0c, 0xf8, 0xce, 0xc7, 0xb5, 0x7c, 0x91, 0xad, - 0x25, 0xfb, 0x30, 0xe6, 0x57, 0xf3, 0x1c, 0x88, 0x8c, 0x25, 0x92, 0x3f, 0x84, 0x0a, 0x17, 0xa9, - 0x08, 0x2b, 0xf3, 0xce, 0xa8, 0x8f, 0x61, 0x5b, 0x50, 0xe6, 0xdf, 0x79, 0x55, 0x7d, 0x0b, 0x3b, - 0xe9, 0x10, 0x01, 0x1d, 0xbf, 0x60, 0x85, 0xbc, 0x17, 0x4c, 0xfd, 0x0e, 0xb6, 0x19, 0x1f, 0x6a, - 0xf3, 0xf1, 0x89, 0xab, 0xfb, 0x3f, 0x54, 0xc2, 0xea, 0xd6, 0x5e, 0x7d, 0x69, 0x16, 0xd5, 0x17, - 0xb0, 0x93, 0x3e, 0x9c, 0x94, 0x43, 0xb9, 0x65, 0xad, 0x1c, 0x1e, 0xa8, 0xde, 0xf0, 0xe1, 0x3a, - 0x77, 0xae, 0xe2, 0x7c, 0xd8, 0x26, 0xec, 0xbe, 0x1e, 0xbf, 0x73, 0x28, 0x90, 0x91, 0x90, 0x8b, - 0x1d, 0xc2, 0x39, 0xb6, 0x4c, 0x9b, 0xcf, 0x71, 0xe1, 0xa9, 0xc2, 0x0e, 0x2c, 0x1c, 0xcb, 0x72, - 0x3e, 0xf1, 0x19, 0xae, 0x65, 0xe6, 0x5a, 0xc9, 0x99, 0x6b, 0x2e, 0x96, 0xea, 0x3e, 0x9f, 0xe2, - 0x30, 0xb5, 0x60, 0x1b, 0x23, 0x73, 0x05, 0x3f, 0xa0, 0x50, 0x4f, 0x7e, 0x1d, 0x75, 0xb1, 0xab, - 0x17, 0xfd, 0x33, 0x4d, 0x9f, 0xbe, 0x1f, 0x6b, 0xfa, 0xdb, 0xe1, 0x89, 0x76, 0x3a, 0x18, 0x6a, - 0x27, 0xed, 0x5b, 0xa8, 0x25, 0x5b, 0x92, 0xa7, 0x3f, 0x1e, 0x1f, 0xb7, 0x0b, 0xf8, 0xb2, 0x74, - 0x24, 0xe3, 0xc9, 0xe8, 0xf8, 0xb5, 0x36, 0x69, 0x17, 0x91, 0x48, 0x4b, 0x32, 0x8f, 0x8e, 0x07, - 0xed, 0xd2, 0xc1, 0x18, 0x6a, 0xf1, 0x8f, 0x84, 0x5d, 0xd8, 0x46, 0x00, 0xfd, 0xcd, 0xb4, 0x3f, - 0x4d, 0x27, 0x41, 0xbc, 0xc4, 0x31, 0x79, 0x3b, 0x1c, 0x0e, 0x86, 0x67, 0x98, 0x66, 0x07, 0xda, - 0x89, 0x59, 0xfb, 0x71, 0x30, 0xc5, 0xe0, 0xe2, 0xc1, 0x3f, 0x05, 0xa8, 0xc5, 0x2f, 0x21, 0x42, - 0x8e, 0x47, 0x27, 0x39, 0x90, 0x78, 0x36, 0x71, 0x68, 0x17, 0xaf, 0x26, 0xef, 0x47, 0x88, 0x98, - 0x0a, 0x1f, 0x4f, 0xb4, 0x71, 0x7f, 0xc2, 0x52, 0x15, 0x51, 0x9c, 0x49, 0xd6, 0x81, 0x30, 0x25, - 0xc6, 0x2c, 0xb1, 0x47, 0xcc, 0xca, 0x38, 0x6d, 0x7b, 0x89, 0xb9, 0xff, 0x6a, 0x34, 0x41, 0x6a, - 0xd1, 0xb1, 0xb6, 0x92, 0x49, 0x1e, 0x12, 0xaf, 0xa4, 0x73, 0x9c, 0x68, 0xe7, 0xda, 0x94, 0x81, - 0x55, 0xd3, 0x39, 0xce, 0xfa, 0x93, 0x57, 0xd8, 0xc2, 0x76, 0xed, 0xe0, 0x8f, 0x22, 0xd4, 0x13, - 0xb1, 0xc3, 0x1b, 0xd2, 0xde, 0x69, 0xc3, 0xe9, 0xfa, 0x0d, 0xdd, 0x83, 0x5d, 0xc9, 0xc3, 0x90, - 0x62, 0xfe, 0x05, 0xfc, 0xf5, 0xf3, 0x30, 0xdf, 0x19, 0xb1, 0xc6, 0xda, 0x7b, 0x70, 0x37, 0x13, - 0x83, 0x54, 0xb8, 0xaf, 0x84, 0x72, 0x71, 0x27, 0xe3, 0x13, 0xe5, 0x94, 0x71, 0x77, 0xf6, 0x33, - 0x2e, 0xc1, 0x5d, 0x3f, 0x1e, 0x9d, 0x9f, 0x6b, 0xc7, 0x2c, 0x4a, 0xc9, 0x80, 0x8b, 0xeb, 0x9c, - 0x84, 0x0d, 0x49, 0x83, 0x33, 0x9f, 0x00, 0xaf, 0xb2, 0x06, 0x4b, 0xae, 0x70, 0xaa, 0x06, 0x17, - 0xe3, 0x90, 0x72, 0x8d, 0xdc, 0x87, 0xee, 0x9a, 0x7b, 0xa2, 0x5d, 0x8c, 0xde, 0xa1, 0xb7, 0x7e, - 0xf4, 0x4b, 0x19, 0x7f, 0x5c, 0xad, 0x2e, 0x2d, 0x73, 0xd6, 0x1f, 0x0f, 0xc8, 0xf7, 0x50, 0x15, - 0x82, 0x4e, 0x76, 0x93, 0xd7, 0x2e, 0x25, 0xfa, 0xbd, 0xee, 0xba, 0x23, 0xdc, 0x1a, 0xf5, 0x16, - 0xe9, 0x43, 0x2d, 0x12, 0x66, 0x92, 0xc4, 0x65, 0x34, 0xbf, 0xb7, 0x97, 0xe3, 0x89, 0x21, 0xce, - 0x00, 0x12, 0x29, 0x26, 0x3d, 0xe9, 0x01, 0xc9, 0x08, 0x78, 0xef, 0x5e, 0xae, 0x4f, 0x06, 0x4a, - 0x64, 0x55, 0x02, 0x5a, 0xd3, 0x6d, 0x09, 0x68, 0x5d, 0x87, 0x11, 0xe8, 0x02, 0x9a, 0xb2, 0x8c, - 0x92, 0xfb, 0xd9, 0xbc, 0xb2, 0x00, 0xf7, 0x1e, 0x6c, 0xf0, 0xc6, 0x70, 0x23, 0x68, 0xca, 0x0a, - 0x29, 0xc1, 0xe5, 0xa8, 0xae, 0x04, 0x97, 0x27, 0xab, 0xea, 0xad, 0xaf, 0x0b, 0xe4, 0x25, 0xbf, - 0x34, 0xa6, 0x5f, 0xe9, 0x4b, 0x93, 0xc4, 0x34, 0x7d, 0x69, 0xb2, 0xd4, 0x31, 0x84, 0xcb, 0x0a, - 0xff, 0x8f, 0xf1, 0xd9, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xee, 0xd0, 0xb0, 0x32, 0x3e, 0x0e, - 0x00, 0x00, + // 1450 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x57, 0x4d, 0x72, 0xdb, 0x46, + 0x13, 0x35, 0x7f, 0xc0, 0x9f, 0x26, 0x4d, 0x91, 0x23, 0xd9, 0xa2, 0xe8, 0x3f, 0x19, 0xdf, 0x17, + 0x97, 0xa3, 0x85, 0x92, 0xc8, 0x8e, 0x37, 0xa9, 0x4a, 0x99, 0x96, 0x20, 0x15, 0x63, 0x89, 0x64, + 0xd1, 0xb4, 0x2b, 0x5e, 0xa1, 0x20, 0x72, 0x28, 0xa3, 0x0c, 0x02, 0x08, 0x00, 0xca, 0x56, 0x96, + 0xb9, 0x40, 0x8e, 0x90, 0x33, 0x64, 0x95, 0x65, 0xf6, 0x39, 0x46, 0xaa, 0x72, 0x8f, 0xf4, 0x0c, + 0x06, 0xc0, 0x00, 0x04, 0x17, 0xd9, 0x89, 0xdd, 0x33, 0xaf, 0xdf, 0xeb, 0xe9, 0x79, 0x03, 0x41, + 0xdd, 0x70, 0xcd, 0x43, 0xd7, 0x73, 0x02, 0x87, 0x54, 0xaf, 0xbf, 0x31, 0x2c, 0xf7, 0x83, 0xa1, + 0xbe, 0x84, 0xc6, 0x60, 0x69, 0x5c, 0xd1, 0x53, 0xc7, 0x5b, 0x1a, 0x01, 0xd9, 0x87, 0x72, 0x70, + 0xe3, 0xd2, 0x6e, 0x61, 0xbf, 0xf0, 0xb4, 0x75, 0x44, 0x0e, 0xc5, 0xb2, 0x43, 0xbe, 0x66, 0x8a, + 0x19, 0xb2, 0x05, 0xd5, 0x6b, 0xea, 0xf9, 0xa6, 0x63, 0x77, 0x8b, 0xb8, 0xa8, 0xae, 0xfe, 0x59, + 0x00, 0x85, 0xa7, 0xc9, 0x97, 0xd0, 0xb8, 0x34, 0x7c, 0xaa, 0x2f, 0x38, 0x16, 0xc7, 0x68, 0x1c, + 0xed, 0xa4, 0x31, 0x44, 0x1d, 0x80, 0xa2, 0x39, 0x0f, 0x01, 0x48, 0x13, 0xca, 0xb6, 0xb1, 0xa4, + 0xdd, 0x12, 0xff, 0x25, 0xe1, 0x97, 0x79, 0xa0, 0x0b, 0x6d, 0x73, 0xe9, 0x3a, 0x5e, 0xa0, 0x07, + 0xe6, 0x92, 0xfa, 0x81, 0xb1, 0x74, 0xbb, 0x0a, 0x66, 0x4a, 0xa4, 0x0d, 0xb5, 0xa5, 0x61, 0x9b, + 0x0b, 0x0c, 0x76, 0x2b, 0x18, 0x69, 0x32, 0x28, 0xdf, 0xfc, 0x99, 0x76, 0xab, 0x3c, 0xff, 0x04, + 0x1a, 0x86, 0x6d, 0x3b, 0x81, 0x11, 0x20, 0x9a, 0xdf, 0xad, 0xed, 0x97, 0x90, 0x4f, 0x27, 0xe6, + 0xf3, 0x9a, 0xde, 0xbc, 0x33, 0xac, 0x15, 0x55, 0x9f, 0x41, 0x75, 0x48, 0x83, 0x4f, 0x8e, 0xf7, + 0x31, 0xe6, 0x52, 0x88, 0x98, 0x99, 0xee, 0xf5, 0xf3, 0x84, 0x27, 0xfe, 0x7a, 0x11, 0xf2, 0x54, + 0x7f, 0x2d, 0x40, 0xa9, 0xef, 0xba, 0x99, 0x1d, 0x0f, 0x40, 0x31, 0x99, 0x4c, 0xbe, 0xa5, 0x71, + 0xd4, 0x4a, 0x8b, 0xc7, 0xf6, 0x2a, 0x28, 0x20, 0x08, 0xb5, 0xb6, 0x24, 0x2e, 0x88, 0xf4, 0x86, + 0x25, 0x48, 0x07, 0xea, 0xf4, 0xb3, 0x19, 0xe8, 0x33, 0x67, 0x4e, 0x79, 0x03, 0x3a, 0x59, 0x19, + 0xca, 0x26, 0x19, 0x7f, 0x21, 0xa3, 0xb1, 0x33, 0x17, 0xbd, 0x0d, 0xf9, 0x34, 0xa0, 0xe4, 0x8a, + 0x46, 0x77, 0x36, 0x57, 0xc7, 0x5d, 0x61, 0xf5, 0x1e, 0x94, 0x0d, 0xd7, 0xf5, 0xb1, 0x30, 0xab, + 0xd1, 0x94, 0xe9, 0x11, 0x15, 0x6a, 0x76, 0xd8, 0xa5, 0x88, 0x43, 0x3b, 0xce, 0x47, 0xed, 0x5b, + 0x3f, 0x91, 0x0c, 0xf9, 0xea, 0x06, 0xf2, 0xa4, 0x05, 0x95, 0xd9, 0x95, 0xe7, 0xac, 0x5c, 0x3c, + 0x26, 0xd6, 0xde, 0x27, 0x50, 0x8b, 0x73, 0x28, 0x02, 0xff, 0x16, 0x8a, 0x6e, 0x83, 0x72, 0xcd, + 0xa2, 0x62, 0xfa, 0x7e, 0x2f, 0x40, 0x1d, 0xe9, 0x9f, 0x9a, 0x56, 0x40, 0x3d, 0xb6, 0xd2, 0x9c, + 0xfb, 0xb8, 0xb2, 0x84, 0x2b, 0x1f, 0x43, 0x85, 0xcb, 0xf5, 0x71, 0x69, 0x29, 0x5f, 0x6f, 0x87, + 0xdd, 0x09, 0x57, 0x67, 0x07, 0xe8, 0x63, 0x57, 0xd8, 0x2e, 0x0c, 0xf1, 0x13, 0xd4, 0x19, 0x50, + 0x99, 0x87, 0xee, 0xc0, 0x6d, 0xa1, 0x5c, 0xac, 0x54, 0x78, 0x38, 0x23, 0xad, 0xb2, 0x49, 0x1a, + 0x4e, 0x74, 0x28, 0x2d, 0x94, 0x5f, 0x57, 0xff, 0x2e, 0x44, 0x97, 0x2e, 0x87, 0x35, 0xb6, 0xd0, + 0xf5, 0xe8, 0xc2, 0xfc, 0x2c, 0x78, 0xd7, 0x09, 0x1e, 0x28, 0xbf, 0x56, 0x32, 0x4b, 0x5c, 0xf5, + 0x91, 0xde, 0x20, 0xa5, 0x98, 0x24, 0xaa, 0xb5, 0x8c, 0x4b, 0x6a, 0x6d, 0x1e, 0x10, 0x72, 0x17, + 0x5a, 0xe1, 0x4d, 0xa2, 0x73, 0xdd, 0x58, 0x60, 0x65, 0x7e, 0x46, 0x25, 0xb2, 0x0b, 0x5b, 0x71, + 0xfc, 0x92, 0xe2, 0xed, 0xfd, 0x8f, 0x17, 0x88, 0x31, 0x5c, 0xac, 0x2c, 0x4b, 0x30, 0xac, 0x73, + 0x91, 0xbf, 0xa1, 0xc8, 0x33, 0xcb, 0xb9, 0x34, 0xac, 0x53, 0xcb, 0xb8, 0xf2, 0x99, 0xc8, 0xb9, + 0xe9, 0x89, 0x43, 0xdc, 0x83, 0x8e, 0x7f, 0xe3, 0x07, 0x74, 0x89, 0x73, 0x6e, 0x2f, 0xcc, 0x2b, + 0x9d, 0xa5, 0x8a, 0xd1, 0x75, 0xb7, 0x9c, 0x99, 0x61, 0xc9, 0x99, 0xd0, 0x19, 0x90, 0xe6, 0xca, + 0xa7, 0x9e, 0x9c, 0x08, 0x1d, 0x82, 0xe9, 0xb2, 0x7d, 0x3a, 0x5b, 0x79, 0xe8, 0x3d, 0xac, 0x18, + 0xf7, 0x07, 0x76, 0x19, 0xef, 0x04, 0xde, 0xca, 0x0f, 0x74, 0x6c, 0x95, 0xaf, 0x2f, 0x3c, 0x67, + 0xa9, 0x7f, 0x08, 0x02, 0xd7, 0xe7, 0xb2, 0x6b, 0xaa, 0x07, 0xe5, 0x81, 0xbd, 0x70, 0xc8, 0x36, + 0x34, 0xbc, 0x8f, 0x81, 0x1e, 0xb9, 0x4e, 0xc8, 0x70, 0x07, 0x9a, 0x38, 0x19, 0x33, 0x3d, 0xe5, + 0x75, 0x6c, 0x29, 0x7a, 0x68, 0x1c, 0x0c, 0x79, 0x1d, 0x40, 0xf3, 0x8a, 0x0b, 0x15, 0xc5, 0xcb, + 0x19, 0xdf, 0x93, 0xba, 0x80, 0x35, 0x15, 0xed, 0x9a, 0xda, 0x9b, 0x8d, 0x96, 0x67, 0xb9, 0xd1, + 0x66, 0x2c, 0x92, 0xd1, 0x17, 0x05, 0xf1, 0x17, 0xb3, 0x42, 0x5e, 0xa8, 0x44, 0x1e, 0x41, 0x79, + 0x6e, 0x04, 0xc6, 0x66, 0x5f, 0x08, 0xa0, 0xc1, 0x51, 0xc5, 0xb4, 0x3d, 0x06, 0x85, 0x55, 0x0e, + 0xe7, 0x2d, 0xbf, 0xb4, 0x18, 0xc8, 0x70, 0xfc, 0xf0, 0xc2, 0xc9, 0x93, 0x87, 0xbc, 0x7c, 0xd3, + 0x9e, 0x51, 0x5d, 0xa2, 0x80, 0xb1, 0x95, 0x1d, 0x98, 0x56, 0x18, 0xe3, 0xe6, 0xac, 0xb6, 0xa1, + 0x75, 0x46, 0x03, 0xd6, 0xe0, 0x09, 0xfd, 0x69, 0x85, 0x86, 0xa0, 0x1e, 0xc2, 0x56, 0x1c, 0xf1, + 0x5d, 0x1c, 0x28, 0x4a, 0xee, 0xa1, 0xa5, 0xe2, 0x6f, 0xf1, 0x54, 0xdc, 0x4e, 0xdc, 0x12, 0x83, + 0xea, 0x29, 0x6c, 0x9d, 0x9b, 0x7e, 0x80, 0x97, 0xd5, 0x17, 0x10, 0xe4, 0x7f, 0x50, 0x5d, 0x70, + 0x15, 0x21, 0xfb, 0x86, 0xc4, 0x3e, 0x31, 0x01, 0xb4, 0x92, 0x39, 0x0d, 0x0c, 0xd3, 0xe2, 0xcd, + 0xab, 0x61, 0xdd, 0x76, 0x82, 0x23, 0x0a, 0xa3, 0xd1, 0xb9, 0xce, 0x3c, 0x42, 0x69, 0xca, 0x28, + 0xea, 0x23, 0xe8, 0x0c, 0x6c, 0xdf, 0xa5, 0x33, 0xb6, 0x25, 0xaa, 0x2c, 0x99, 0xaa, 0xfa, 0x15, + 0x10, 0x79, 0x81, 0x80, 0xdc, 0x43, 0xab, 0x75, 0xe6, 0x42, 0x4a, 0x1a, 0xf1, 0x07, 0xe8, 0x30, + 0x06, 0xfc, 0xce, 0xc7, 0x5a, 0xbe, 0xc8, 0x6a, 0xc9, 0xbe, 0x94, 0xf9, 0x6a, 0x9e, 0x03, 0x91, + 0xb1, 0x44, 0xf1, 0x87, 0x50, 0xe1, 0xae, 0x15, 0x61, 0x65, 0x1e, 0x1e, 0xf5, 0x31, 0x6c, 0x0b, + 0xca, 0xfc, 0x77, 0x9e, 0xaa, 0x6f, 0x61, 0x27, 0xbd, 0x44, 0x40, 0xc7, 0x4f, 0x5a, 0x21, 0xef, + 0x49, 0x53, 0xbf, 0x83, 0x6d, 0xc6, 0x87, 0xda, 0x7c, 0x7c, 0x62, 0x75, 0xff, 0x87, 0x4a, 0xa8, + 0x6e, 0xed, 0x33, 0x40, 0x9a, 0x45, 0xf5, 0x05, 0xec, 0xa4, 0x37, 0x27, 0x72, 0x28, 0x8f, 0xac, + 0xc9, 0xe1, 0x0b, 0xd5, 0x1b, 0x3e, 0x5c, 0xe7, 0xce, 0x55, 0x5c, 0x0f, 0xdb, 0x84, 0xdd, 0xd7, + 0xe3, 0x87, 0x0f, 0x0d, 0x32, 0x72, 0x76, 0x71, 0x87, 0x70, 0x8e, 0x2d, 0xd3, 0xe6, 0x73, 0x5c, + 0x78, 0xaa, 0xb0, 0x0d, 0x0b, 0xc7, 0xb2, 0x9c, 0x4f, 0x7c, 0x86, 0x6b, 0x99, 0xb9, 0x56, 0x72, + 0xe6, 0x9a, 0x9b, 0xa5, 0xba, 0xcf, 0xa7, 0x38, 0x2c, 0x2d, 0xd8, 0xc6, 0xc8, 0xdc, 0xc1, 0x0f, + 0x28, 0xd4, 0x93, 0xcf, 0xa5, 0x2e, 0x76, 0xf5, 0xa2, 0x7f, 0xa6, 0xe9, 0xd3, 0xf7, 0x63, 0x4d, + 0x7f, 0x3b, 0x3c, 0xd1, 0x4e, 0x07, 0x43, 0xed, 0xa4, 0x7d, 0x0b, 0xbd, 0x64, 0x4b, 0xca, 0xf4, + 0xc7, 0xe3, 0xe3, 0x76, 0x01, 0x9f, 0x9a, 0x8e, 0x14, 0x3c, 0x19, 0x1d, 0xbf, 0xd6, 0x26, 0xed, + 0x22, 0x12, 0x69, 0x49, 0xe1, 0xd1, 0xf1, 0xa0, 0x5d, 0x3a, 0x18, 0x43, 0x2d, 0xfe, 0x6a, 0xd8, + 0x85, 0x6d, 0x04, 0xd0, 0xdf, 0x4c, 0xfb, 0xd3, 0x74, 0x11, 0xc4, 0x4b, 0x12, 0x93, 0xb7, 0xc3, + 0xe1, 0x60, 0x78, 0x86, 0x65, 0x76, 0xa0, 0x9d, 0x84, 0xb5, 0x1f, 0x07, 0x53, 0x5c, 0x5c, 0x3c, + 0xf8, 0xa7, 0x00, 0xb5, 0xf8, 0x69, 0x44, 0xc8, 0xf1, 0xe8, 0x24, 0x07, 0x12, 0xf7, 0x26, 0x09, + 0xed, 0xe2, 0xd5, 0xe4, 0xfd, 0x08, 0x11, 0x53, 0xcb, 0xc7, 0x13, 0x6d, 0xdc, 0x9f, 0xb0, 0x52, + 0x45, 0x34, 0x67, 0x92, 0x4d, 0x20, 0x4c, 0x89, 0x31, 0x4b, 0xe2, 0x11, 0xb3, 0x32, 0x4e, 0xdb, + 0x5e, 0x12, 0xee, 0xbf, 0x1a, 0x4d, 0x90, 0x5a, 0xb4, 0xad, 0xad, 0x64, 0x8a, 0x87, 0xc4, 0x2b, + 0xe9, 0x1a, 0x27, 0xda, 0xb9, 0x36, 0x65, 0x60, 0xd5, 0x74, 0x8d, 0xb3, 0xfe, 0xe4, 0x15, 0xb6, + 0xb0, 0x5d, 0x3b, 0xf8, 0xa3, 0x08, 0xf5, 0xc4, 0xec, 0xf0, 0x84, 0xb4, 0x77, 0xda, 0x70, 0xba, + 0x7e, 0x42, 0xf7, 0x60, 0x57, 0xca, 0x30, 0xa4, 0x98, 0x7f, 0x01, 0x3f, 0x87, 0x1e, 0xe6, 0x27, + 0x23, 0xd6, 0xa8, 0xbd, 0x07, 0x77, 0x33, 0x6b, 0x90, 0x0a, 0xcf, 0x95, 0xd0, 0x2e, 0xee, 0x64, + 0x72, 0x42, 0x4e, 0x19, 0xef, 0xce, 0x7e, 0x26, 0x25, 0xb8, 0xeb, 0xc7, 0xa3, 0xf3, 0x73, 0xed, + 0x98, 0xad, 0x52, 0x32, 0xe0, 0xe2, 0x38, 0x27, 0x61, 0x43, 0xd2, 0xe0, 0x2c, 0x27, 0xc0, 0xab, + 0xac, 0xc1, 0x52, 0x2a, 0x9c, 0xaa, 0xc1, 0xc5, 0x38, 0xa4, 0x5c, 0x23, 0xf7, 0xa1, 0xbb, 0x96, + 0x9e, 0x68, 0x17, 0xa3, 0x77, 0x98, 0xad, 0x1f, 0xfd, 0x52, 0xc6, 0xaf, 0xad, 0xd5, 0xa5, 0x65, + 0xce, 0xfa, 0xe3, 0x01, 0xf9, 0x1e, 0xaa, 0xc2, 0xd0, 0xc9, 0x6e, 0xf2, 0xda, 0xa5, 0x4c, 0xbf, + 0xd7, 0x5d, 0x4f, 0x84, 0xb7, 0x46, 0xbd, 0x45, 0xfa, 0x50, 0x8b, 0x8c, 0x99, 0x24, 0xeb, 0x32, + 0x9e, 0xdf, 0xdb, 0xcb, 0xc9, 0xc4, 0x10, 0x67, 0x00, 0x89, 0x15, 0x93, 0x9e, 0xf4, 0x80, 0x64, + 0x0c, 0xbc, 0x77, 0x2f, 0x37, 0x27, 0x03, 0x25, 0xb6, 0x2a, 0x01, 0xad, 0xf9, 0xb6, 0x04, 0xb4, + 0xee, 0xc3, 0x08, 0x74, 0x01, 0x4d, 0xd9, 0x46, 0xc9, 0xfd, 0x6c, 0x5d, 0xd9, 0x80, 0x7b, 0x0f, + 0x36, 0x64, 0x63, 0xb8, 0x11, 0x34, 0x65, 0x87, 0x94, 0xe0, 0x72, 0x5c, 0x57, 0x82, 0xcb, 0xb3, + 0x55, 0xf5, 0xd6, 0xd7, 0x05, 0xf2, 0x92, 0x1f, 0x1a, 0xf3, 0xaf, 0xf4, 0xa1, 0x49, 0x66, 0x9a, + 0x3e, 0x34, 0xd9, 0xea, 0x18, 0xc2, 0x65, 0x85, 0xff, 0x0b, 0xf9, 0xec, 0xdf, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x8d, 0x30, 0x01, 0x4e, 0x4f, 0x0e, 0x00, 0x00, } diff --git a/api/v1alpha/api.proto b/api/v1alpha/api.proto index fca5c92bdb..0f1944f37f 100644 --- a/api/v1alpha/api.proto +++ b/api/v1alpha/api.proto @@ -204,6 +204,9 @@ message PodFilter { // If not empty, the pods that have all of the annotations will be returned. repeated KeyValue annotations = 6; + + // If not empty, the pods whose cgroup are listed will be returned. + repeated string cgroups = 7; } // ImageFilter defines the condition that the returned images need to satisfy in ListImages(). diff --git a/rkt/api_service.go b/rkt/api_service.go index 63ed9b4b1c..fbbe5db7ee 100644 --- a/rkt/api_service.go +++ b/rkt/api_service.go @@ -191,6 +191,14 @@ func satisfiesPodFilter(pod v1alpha.Pod, manifest schema.PodManifest, filter v1a } } + // Filter according to the cgroup. + if len(filter.Cgroups) > 0 { + s := set.NewString(filter.Cgroups...) + if !s.Has(pod.Cgroup) { + return false + } + } + return true } From fa65282d14152056bbe3d12e616476b9e261cfce Mon Sep 17 00:00:00 2001 From: Yifan Gu Date: Thu, 24 Mar 2016 18:40:06 -0700 Subject: [PATCH 0043/1304] tests: Add tests for api service to test the cgroup. Test the cgroup should be returned for running pods. Test the cgroup filter should work for running pods. --- tests/rkt_api_service_test.go | 115 ++++++++++++++++++++++++++++++++++ tests/rkt_tests.go | 3 + tests/testutils/utils.go | 10 +++ 3 files changed, 128 insertions(+) diff --git a/tests/rkt_api_service_test.go b/tests/rkt_api_service_test.go index 9bb3c0d729..80a10709c7 100644 --- a/tests/rkt_api_service_test.go +++ b/tests/rkt_api_service_test.go @@ -23,6 +23,7 @@ import ( "strings" "syscall" "testing" + "time" "github.com/appc/spec/schema" "github.com/appc/spec/schema/types" @@ -148,6 +149,17 @@ func checkPod(t *testing.T, ctx *testutils.RktRunCtx, p *v1alpha.Pod, hasAppStat checkPodApps(t, podInfo.apps, p.Apps, hasAppState) checkPodNetworks(t, podInfo.networks, p.Networks) + expectedCgroupSuffix := "" + if podInfo.state == "running" { + machineID := fmt.Sprintf("rkt-%s", p.Id) + escapedmID := strings.Replace(machineID, "-", "\\x2d", -1) + expectedCgroupSuffix = fmt.Sprintf("/machine-%s.scope", escapedmID) + } + + if !strings.HasSuffix(p.Cgroup, expectedCgroupSuffix) { + t.Errorf("Expected the cgroup suffix to have %q, but saw %q", expectedCgroupSuffix, p.Cgroup) + } + if hasManifest { var mfst schema.PodManifest err := json.Unmarshal(podInfo.manifest, &mfst) @@ -406,3 +418,106 @@ func TestAPIServiceListInspectImages(t *testing.T) { checkImageDetails(t, ctx, m) } } + +func TestAPIServiceCroup(t *testing.T) { + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + svc := startAPIService(t, ctx) + defer stopAPIService(t, svc) + + c, conn := newAPIClientOrFail(t, "localhost:15441") + defer conn.Close() + + aciFileName := patchTestACI("rkt-inspect-interactive.aci", "--exec=/inspect --read-stdin") + defer os.Remove(aciFileName) + + runCmd := fmt.Sprintf("%s --insecure-options=image run --interactive %s", ctx.Cmd(), aciFileName) + child := spawnOrFail(t, runCmd) + + var resp *v1alpha.ListPodsResponse + var err error + done := make(chan struct{}) + + // Wait the pods to be running. + go func() { + for { + // ListPods(detail=false). + resp, err = c.ListPods(context.Background(), &v1alpha.ListPodsRequest{}) + if err != nil { + t.Fatalf("Unexpected error: %v", err) + } + + if len(resp.Pods) != 0 { + allRunning := true + for _, p := range resp.Pods { + if p.State != v1alpha.PodState_POD_STATE_RUNNING { + allRunning = false + break + } + } + if allRunning { + t.Logf("Pods are running") + close(done) + return + } + } + t.Logf("Pods are not in RUNNING state") + time.Sleep(time.Second) + } + }() + + testutils.WaitOrTimeout(t, time.Second*10, done) + + var cgroups []string + + for _, p := range resp.Pods { + checkPodBasics(t, ctx, p) + + // Test InspectPod(). + inspectResp, err := c.InspectPod(context.Background(), &v1alpha.InspectPodRequest{Id: p.Id}) + if err != nil { + t.Fatalf("Unexpected error: %v", err) + } + checkPodDetails(t, ctx, inspectResp.Pod) + if p.Cgroup != "" { + cgroups = append(cgroups, p.Cgroup) + } + } + + // ListPods(detail=true). Filter according to the cgroup. + resp, err = c.ListPods(context.Background(), &v1alpha.ListPodsRequest{ + Detail: true, + Filters: []*v1alpha.PodFilter{{Cgroups: cgroups}}, + }) + if err != nil { + t.Fatalf("Unexpected error: %v", err) + } + + if len(resp.Pods) == 0 { + t.Errorf("Unexpected result: %v, should see non-zero pods", resp.Pods) + } + + for _, p := range resp.Pods { + checkPodDetails(t, ctx, p) + } + + // Terminate the pods. + if err := child.SendLine("Good bye"); err != nil { + t.Fatalf("Failed to send message to the pod: %v", err) + } + waitOrFail(t, child, 0) + + // Check that there's no cgroups returned for non-running pods. + cgroups = []string{} + resp, err = c.ListPods(context.Background(), &v1alpha.ListPodsRequest{}) + for _, p := range resp.Pods { + checkPodBasics(t, ctx, p) + if p.Cgroup != "" { + cgroups = append(cgroups, p.Cgroup) + } + } + if len(cgroups) != 0 { + t.Errorf("Unexpected cgroup returned by pods: %v", cgroups) + } +} diff --git a/tests/rkt_tests.go b/tests/rkt_tests.go index ebe37264dc..4709950969 100644 --- a/tests/rkt_tests.go +++ b/tests/rkt_tests.go @@ -428,6 +428,9 @@ func parsePodInfoOutput(t *testing.T, result string, p *podInfo) { case "state": p.state = tuples[1] case "networks": + if tuples[1] == "" { + break + } networks := strings.Split(tuples[1], ",") for _, n := range networks { fields := strings.Split(n, ":") diff --git a/tests/testutils/utils.go b/tests/testutils/utils.go index 1f25c9a6b6..e653c81f45 100644 --- a/tests/testutils/utils.go +++ b/tests/testutils/utils.go @@ -17,6 +17,8 @@ package testutils import ( "fmt" "os" + "testing" + "time" ) func GetValueFromEnvOrPanic(envVar string) string { @@ -26,3 +28,11 @@ func GetValueFromEnvOrPanic(envVar string) string { } return path } + +func WaitOrTimeout(t *testing.T, timeout time.Duration, notify chan struct{}) { + select { + case <-time.After(timeout): + t.Fatalf("Timeout after %v", timeout) + case <-notify: + } +} From 0976e9e31001f1d3c3d13d24cd0ebecb81ae7630 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Thu, 31 Mar 2016 12:26:40 +0200 Subject: [PATCH 0044/1304] api_service: fix typos Follow up to https://github.com/coreos/rkt/pull/2331 --- tests/rkt_api_service_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/rkt_api_service_test.go b/tests/rkt_api_service_test.go index 80a10709c7..d3dd9244bd 100644 --- a/tests/rkt_api_service_test.go +++ b/tests/rkt_api_service_test.go @@ -419,7 +419,7 @@ func TestAPIServiceListInspectImages(t *testing.T) { } } -func TestAPIServiceCroup(t *testing.T) { +func TestAPIServiceCgroup(t *testing.T) { ctx := testutils.NewRktRunCtx() defer ctx.Cleanup() @@ -502,7 +502,7 @@ func TestAPIServiceCroup(t *testing.T) { checkPodDetails(t, ctx, p) } - // Terminate the pods. + // Terminate the pod. if err := child.SendLine("Good bye"); err != nil { t.Fatalf("Failed to send message to the pod: %v", err) } From 64f7216c8b35da8fd46eda0c9723a0c532cc0ddc Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Fri, 11 Mar 2016 14:26:51 +0100 Subject: [PATCH 0045/1304] docs: Deduplicate the global options table The redundancy was mind-boggling. This just replaces all the tables in subcommands with a link to a global options section in general commands documentation. This also saves us the requirement to remember to update all the tables, when new global option is added. --- Documentation/subcommands/api-service.md | 10 +--------- Documentation/subcommands/cat-manifest.md | 10 +--------- Documentation/subcommands/enter.md | 10 +--------- Documentation/subcommands/fetch.md | 10 +--------- Documentation/subcommands/gc.md | 10 +--------- Documentation/subcommands/image.md | 10 +--------- Documentation/subcommands/list.md | 10 +--------- Documentation/subcommands/metadata-service.md | 10 +--------- Documentation/subcommands/prepare.md | 10 +--------- Documentation/subcommands/rm.md | 10 +--------- Documentation/subcommands/run-prepared.md | 10 +--------- Documentation/subcommands/run.md | 10 +--------- Documentation/subcommands/status.md | 10 +--------- Documentation/subcommands/trust.md | 10 +--------- 14 files changed, 14 insertions(+), 126 deletions(-) diff --git a/Documentation/subcommands/api-service.md b/Documentation/subcommands/api-service.md index 2e203b69dd..e2795e4d51 100644 --- a/Documentation/subcommands/api-service.md +++ b/Documentation/subcommands/api-service.md @@ -26,12 +26,4 @@ Here is a small [Go program](../../api/v1alpha/client_example.go) that illustrat ## Global options -| Flag | Default | Options | Description | -| --- | --- | --- | --- | -| `--debug` | `false` | `true` or `false` | Prints out more debug information to `stderr` | -| `--dir` | `/var/lib/rkt` | A directory path | Path to the `rkt` data directory | -| `--insecure-options` | none | **none**: All security features are enabled
**http**: Allow HTTP connections. Be warned that this will send any credentials as clear text.
**image**: Disables verifying image signatures
**tls**: Accept any certificate from the server and any host name in that certificate
**ondisk**: Disables verifying the integrity of the on-disk, rendered image before running. This significantly speeds up start time.
**all**: Disables all security checks | Comma-separated list of security features to disable | -| `--local-config` | `/etc/rkt` | A directory path | Path to the local configuration directory | -| `--system-config` | `/usr/lib/rkt` | A directory path | Path to the system configuration directory | -| `--trust-keys-from-https` | `false` | `true` or `false` | Automatically trust gpg keys fetched from https | -| `--user-config` | `` | A directory path | Path to the user configuration directory | \ No newline at end of file +See the table with [global options in general commands documentation](../commands.md#global-options). diff --git a/Documentation/subcommands/cat-manifest.md b/Documentation/subcommands/cat-manifest.md index 928a40610f..d350b26add 100644 --- a/Documentation/subcommands/cat-manifest.md +++ b/Documentation/subcommands/cat-manifest.md @@ -18,12 +18,4 @@ For debugging or inspection you may want to extract the PodManifest to stdout. ## Global options -| Flag | Default | Options | Description | -| --- | --- | --- | --- | -| `--debug` | `false` | `true` or `false` | Prints out more debug information to `stderr` | -| `--dir` | `/var/lib/rkt` | A directory path | Path to the `rkt` data directory | -| `--insecure-options` | none | **none**: All security features are enabled
**http**: Allow HTTP connections. Be warned that this will send any credentials as clear text.
**image**: Disables verifying image signatures
**tls**: Accept any certificate from the server and any host name in that certificate
**ondisk**: Disables verifying the integrity of the on-disk, rendered image before running. This significantly speeds up start time.
**all**: Disables all security checks | Comma-separated list of security features to disable | -| `--local-config` | `/etc/rkt` | A directory path | Path to the local configuration directory | -| `--system-config` | `/usr/lib/rkt` | A directory path | Path to the system configuration directory | -| `--trust-keys-from-https` | `false` | `true` or `false` | Automatically trust gpg keys fetched from https | -| `--user-config` | `` | A directory path | Path to the user configuration directory | \ No newline at end of file +See the table with [global options in general commands documentation](../commands.md#global-options). diff --git a/Documentation/subcommands/enter.md b/Documentation/subcommands/enter.md index 4ca3214e8d..1bedb20512 100644 --- a/Documentation/subcommands/enter.md +++ b/Documentation/subcommands/enter.md @@ -28,12 +28,4 @@ Work in progress. Please contribute! ## Global options -| Flag | Default | Options | Description | -| --- | --- | --- | --- | -| `--debug` | `false` | `true` or `false` | Prints out more debug information to `stderr` | -| `--dir` | `/var/lib/rkt` | A directory path | Path to the `rkt` data directory | -| `--insecure-options` | none | **none**: All security features are enabled
**http**: Allow HTTP connections. Be warned that this will send any credentials as clear text.
**image**: Disables verifying image signatures
**tls**: Accept any certificate from the server and any host name in that certificate
**ondisk**: Disables verifying the integrity of the on-disk, rendered image before running. This significantly speeds up start time.
**all**: Disables all security checks | Comma-separated list of security features to disable | -| `--local-config` | `/etc/rkt` | A directory path | Path to the local configuration directory | -| `--system-config` | `/usr/lib/rkt` | A directory path | Path to the system configuration directory | -| `--trust-keys-from-https` | `false` | `true` or `false` | Automatically trust gpg keys fetched from https | -| `--user-config` | `` | A directory path | Path to the user configuration directory | +See the table with [global options in general commands documentation](../commands.md#global-options). diff --git a/Documentation/subcommands/fetch.md b/Documentation/subcommands/fetch.md index 7bac28ee6d..460410b263 100644 --- a/Documentation/subcommands/fetch.md +++ b/Documentation/subcommands/fetch.md @@ -92,14 +92,6 @@ Note that the configuration kind for images downloaded via https:// and images d ## Global options -| Flag | Default | Options | Description | -| --- | --- | --- | --- | -| `--debug` | `false` | `true` or `false` | Prints out more debug information to `stderr` | -| `--dir` | `/var/lib/rkt` | A directory path | Path to the `rkt` data directory | -| `--insecure-options` | none | **none**: All security features are enabled
**http**: Allow HTTP connections. Be warned that this will send any credentials as clear text.
**image**: Disables verifying image signatures
**tls**: Accept any certificate from the server and any host name in that certificate
**ondisk**: Disables verifying the integrity of the on-disk, rendered image before running. This significantly speeds up start time.
**all**: Disables all security checks | Comma-separated list of security features to disable | -| `--local-config` | `/etc/rkt` | A directory path | Path to the local configuration directory | -| `--system-config` | `/usr/lib/rkt` | A directory path | Path to the system configuration directory | -| `--trust-keys-from-https` | `false` | `true` or `false` | Automatically trust gpg keys fetched from https | -| `--user-config` | `` | A directory path | Path to the user configuration directory | +See the table with [global options in general commands documentation](../commands.md#global-options). [appc-discovery]: https://github.com/appc/spec/blob/master/spec/discovery.md diff --git a/Documentation/subcommands/gc.md b/Documentation/subcommands/gc.md index 336f78057e..326732f22d 100644 --- a/Documentation/subcommands/gc.md +++ b/Documentation/subcommands/gc.md @@ -32,12 +32,4 @@ Garbage collecting pod "f07a4070-79a9-4db0-ae65-a090c9c393a3" ## Global options -| Flag | Default | Options | Description | -| --- | --- | --- | --- | -| `--debug` | `false` | `true` or `false` | Prints out more debug information to `stderr` | -| `--dir` | `/var/lib/rkt` | A directory path | Path to the `rkt` data directory | -| `--insecure-options` | none | **none**: All security features are enabled
**http**: Allow HTTP connections. Be warned that this will send any credentials as clear text.
**image**: Disables verifying image signatures
**tls**: Accept any certificate from the server and any host name in that certificate
**ondisk**: Disables verifying the integrity of the on-disk, rendered image before running. This significantly speeds up start time.
**all**: Disables all security checks | Comma-separated list of security features to disable | -| `--local-config` | `/etc/rkt` | A directory path | Path to the local configuration directory | -| `--system-config` | `/usr/lib/rkt` | A directory path | Path to the system configuration directory | -| `--trust-keys-from-https` | `false` | `true` or `false` | Automatically trust gpg keys fetched from https | -| `--user-config` | `` | A directory path | Path to the user configuration directory | \ No newline at end of file +See the table with [global options in general commands documentation](../commands.md#global-options). diff --git a/Documentation/subcommands/image.md b/Documentation/subcommands/image.md index 3eda8093cd..150f7ed364 100644 --- a/Documentation/subcommands/image.md +++ b/Documentation/subcommands/image.md @@ -143,12 +143,4 @@ rkt: 2 image(s) successfully removed ## Global options -| Flag | Default | Options | Description | -| --- | --- | --- | --- | -| `--debug` | `false` | `true` or `false` | Prints out more debug information to `stderr` | -| `--dir` | `/var/lib/rkt` | A directory path | Path to the `rkt` data directory | -| `--insecure-options` | none | **none**: All security features are enabled
**http**: Allow HTTP connections. Be warned that this will send any credentials as clear text.
**image**: Disables verifying image signatures
**tls**: Accept any certificate from the server and any host name in that certificate
**ondisk**: Disables verifying the integrity of the on-disk, rendered image before running. This significantly speeds up start time.
**all**: Disables all security checks | Comma-separated list of security features to disable | -| `--local-config` | `/etc/rkt` | A directory path | Path to the local configuration directory | -| `--system-config` | `/usr/lib/rkt` | A directory path | Path to the system configuration directory | -| `--trust-keys-from-https` | `false` | `true` or `false` | Automatically trust gpg keys fetched from https | -| `--user-config` | `` | A directory path | Path to the user configuration directory | +See the table with [global options in general commands documentation](../commands.md#global-options). diff --git a/Documentation/subcommands/list.md b/Documentation/subcommands/list.md index 0fea9b367e..fca4fccfd5 100644 --- a/Documentation/subcommands/list.md +++ b/Documentation/subcommands/list.md @@ -29,12 +29,4 @@ UUID APP IMAGE NAME IMAGE ID ## Global options -| Flag | Default | Options | Description | -| --- | --- | --- | --- | -| `--debug` | `false` | `true` or `false` | Prints out more debug information to `stderr` | -| `--dir` | `/var/lib/rkt` | A directory path | Path to the `rkt` data directory | -| `--insecure-options` | none | **none**: All security features are enabled
**http**: Allow HTTP connections. Be warned that this will send any credentials as clear text.
**image**: Disables verifying image signatures
**tls**: Accept any certificate from the server and any host name in that certificate
**ondisk**: Disables verifying the integrity of the on-disk, rendered image before running. This significantly speeds up start time.
**all**: Disables all security checks | Comma-separated list of security features to disable | -| `--local-config` | `/etc/rkt` | A directory path | Path to the local configuration directory | -| `--system-config` | `/usr/lib/rkt` | A directory path | Path to the system configuration directory | -| `--trust-keys-from-https` | `false` | `true` or `false` | Automatically trust gpg keys fetched from https | -| `--user-config` | `` | A directory path | Path to the user configuration directory | +See the table with [global options in general commands documentation](../commands.md#global-options). diff --git a/Documentation/subcommands/metadata-service.md b/Documentation/subcommands/metadata-service.md index 3af2a77859..41839da1dc 100644 --- a/Documentation/subcommands/metadata-service.md +++ b/Documentation/subcommands/metadata-service.md @@ -34,12 +34,4 @@ See [App Container specification](https://github.com/appc/spec/blob/master/spec/ ## Global options -| Flag | Default | Options | Description | -| --- | --- | --- | --- | -| `--debug` | `false` | `true` or `false` | Prints out more debug information to `stderr` | -| `--dir` | `/var/lib/rkt` | A directory path | Path to the `rkt` data directory | -| `--insecure-options` | none | **none**: All security features are enabled
**http**: Allow HTTP connections. Be warned that this will send any credentials as clear text.
**image**: Disables verifying image signatures
**tls**: Accept any certificate from the server and any host name in that certificate
**ondisk**: Disables verifying the integrity of the on-disk, rendered image before running. This significantly speeds up start time.
**all**: Disables all security checks | Comma-separated list of security features to disable | -| `--local-config` | `/etc/rkt` | A directory path | Path to the local configuration directory | -| `--system-config` | `/usr/lib/rkt` | A directory path | Path to the system configuration directory | -| `--trust-keys-from-https` | `false` | `true` or `false` | Automatically trust gpg keys fetched from https | -| `--user-config` | `` | A directory path | Path to the user configuration directory | \ No newline at end of file +See the table with [global options in general commands documentation](../commands.md#global-options). diff --git a/Documentation/subcommands/prepare.md b/Documentation/subcommands/prepare.md index 2cc71d0e02..9b1793dd91 100644 --- a/Documentation/subcommands/prepare.md +++ b/Documentation/subcommands/prepare.md @@ -55,12 +55,4 @@ c9fad0e6-8236-4fc2-ad17-55d0a4c7d742 ## Global options -| Flag | Default | Options | Description | -| --- | --- | --- | --- | -| `--debug` | `false` | `true` or `false` | Prints out more debug information to `stderr` | -| `--dir` | `/var/lib/rkt` | A directory path | Path to the `rkt` data directory | -| `--insecure-options` | none | **none**: All security features are enabled
**http**: Allow HTTP connections. Be warned that this will send any credentials as clear text.
**image**: Disables verifying image signatures
**tls**: Accept any certificate from the server and any host name in that certificate
**ondisk**: Disables verifying the integrity of the on-disk, rendered image before running. This significantly speeds up start time.
**all**: Disables all security checks | Comma-separated list of security features to disable | -| `--local-config` | `/etc/rkt` | A directory path | Path to the local configuration directory | -| `--system-config` | `/usr/lib/rkt` | A directory path | Path to the system configuration directory | -| `--trust-keys-from-https` | `false` | `true` or `false` | Automatically trust gpg keys fetched from https | -| `--user-config` | `` | A directory path | Path to the user configuration directory | +See the table with [global options in general commands documentation](../commands.md#global-options). diff --git a/Documentation/subcommands/rm.md b/Documentation/subcommands/rm.md index a4990c66bb..30b888201f 100644 --- a/Documentation/subcommands/rm.md +++ b/Documentation/subcommands/rm.md @@ -17,12 +17,4 @@ rkt rm --uuid-file=/run/rkt-uuids/mypod ### Global options -| Flag | Default | Options | Description | -| --- | --- | --- | --- | -| `--debug` | `false` | `true` or `false` | Prints out more debug information to `stderr` | -| `--dir` | `/var/lib/rkt` | A directory path | Path to the `rkt` data directory | -| `--insecure-options` | none | **none**: All security features are enabled
**http**: Allow HTTP connections. Be warned that this will send any credentials as clear text.
**image**: Disables verifying image signatures
**tls**: Accept any certificate from the server and any host name in that certificate
**ondisk**: Disables verifying the integrity of the on-disk, rendered image before running. This significantly speeds up start time.
**all**: Disables all security checks | Comma-separated list of security features to disable | -| `--local-config` | `/etc/rkt` | A directory path | Path to the local configuration directory | -| `--system-config` | `/usr/lib/rkt` | A directory path | Path to the system configuration directory | -| `--trust-keys-from-https` | `false` | `true` or `false` | Automatically trust gpg keys fetched from https | -| `--user-config` | `` | A directory path | Path to the user configuration directory | \ No newline at end of file +See the table with [global options in general commands documentation](../commands.md#global-options). diff --git a/Documentation/subcommands/run-prepared.md b/Documentation/subcommands/run-prepared.md index 7b7e7fb2e6..dcf7b75ad3 100644 --- a/Documentation/subcommands/run-prepared.md +++ b/Documentation/subcommands/run-prepared.md @@ -55,12 +55,4 @@ c9fad0e6 etcd coreos.com/etcd prepared ## Global options -| Flag | Default | Options | Description | -| --- | --- | --- | --- | -| `--debug` | `false` | `true` or `false` | Prints out more debug information to `stderr` | -| `--dir` | `/var/lib/rkt` | A directory path | Path to the `rkt` data directory | -| `--insecure-options` | none | **none**: All security features are enabled
**http**: Allow HTTP connections. Be warned that this will send any credentials as clear text.
**image**: Disables verifying image signatures
**tls**: Accept any certificate from the server and any host name in that certificate
**ondisk**: Disables verifying the integrity of the on-disk, rendered image before running. This significantly speeds up start time.
**all**: Disables all security checks | Comma-separated list of security features to disable | -| `--local-config` | `/etc/rkt` | A directory path | Path to the local configuration directory | -| `--system-config` | `/usr/lib/rkt` | A directory path | Path to the system configuration directory | -| `--trust-keys-from-https` | `false` | `true` or `false` | Automatically trust gpg keys fetched from https | -| `--user-config` | `` | A directory path | Path to the user configuration directory | +See the table with [global options in general commands documentation](../commands.md#global-options). diff --git a/Documentation/subcommands/run.md b/Documentation/subcommands/run.md index 7caafb715c..0040dab16a 100644 --- a/Documentation/subcommands/run.md +++ b/Documentation/subcommands/run.md @@ -357,12 +357,4 @@ For more details see the [hacking documentation](../hacking.md). ## Global options -| Flag | Default | Options | Description | -| --- | --- | --- | --- | -| `--debug` | `false` | `true` or `false` | Prints out more debug information to `stderr` | -| `--dir` | `/var/lib/rkt` | A directory path | Path to the `rkt` data directory | -| `--insecure-options` | none | **none**: All security features are enabled
**http**: Allow HTTP connections. Be warned that this will send any credentials as clear text.
**image**: Disables verifying image signatures
**tls**: Accept any certificate from the server and any host name in that certificate
**ondisk**: Disables verifying the integrity of the on-disk, rendered image before running. This significantly speeds up start time.
**all**: Disables all security checks | Comma-separated list of security features to disable | -| `--local-config` | `/etc/rkt` | A directory path | Path to the local configuration directory | -| `--system-config` | `/usr/lib/rkt` | A directory path | Path to the system configuration directory | -| `--trust-keys-from-https` | `false` | `true` or `false` | Automatically trust gpg keys fetched from https | -| `--user-config` | `` | A directory path | Path to the user configuration directory | +See the table with [global options in general commands documentation](../commands.md#global-options). diff --git a/Documentation/subcommands/status.md b/Documentation/subcommands/status.md index 0f7a8aedc7..0db25fb261 100644 --- a/Documentation/subcommands/status.md +++ b/Documentation/subcommands/status.md @@ -24,12 +24,4 @@ If the pod is still running, you can wait for it to finish and then get the stat ## Global options -| Flag | Default | Options | Description | -| --- | --- | --- | --- | -| `--debug` | `false` | `true` or `false` | Prints out more debug information to `stderr` | -| `--dir` | `/var/lib/rkt` | A directory path | Path to the `rkt` data directory | -| `--insecure-options` | none | **none**: All security features are enabled
**http**: Allow HTTP connections. Be warned that this will send any credentials as clear text.
**image**: Disables verifying image signatures
**tls**: Accept any certificate from the server and any host name in that certificate
**ondisk**: Disables verifying the integrity of the on-disk, rendered image before running. This significantly speeds up start time.
**all**: Disables all security checks | Comma-separated list of security features to disable | -| `--local-config` | `/etc/rkt` | A directory path | Path to the local configuration directory | -| `--system-config` | `/usr/lib/rkt` | A directory path | Path to the system configuration directory | -| `--trust-keys-from-https` | `false` | `true` or `false` | Automatically trust gpg keys fetched from https | -| `--user-config` | `` | A directory path | Path to the user configuration directory | \ No newline at end of file +See the table with [global options in general commands documentation](../commands.md#global-options). diff --git a/Documentation/subcommands/trust.md b/Documentation/subcommands/trust.md index 64e57bd360..68611f0095 100644 --- a/Documentation/subcommands/trust.md +++ b/Documentation/subcommands/trust.md @@ -94,14 +94,6 @@ $ find /etc/rkt/trustedkeys/ ## Global options -| Flag | Default | Options | Description | -| --- | --- | --- | --- | -| `--debug` | `false` | `true` or `false` | Prints out more debug information to `stderr` | -| `--dir` | `/var/lib/rkt` | A directory path | Path to the `rkt` data directory | -| `--insecure-options` | none | **none**: All security features are enabled
**http**: Allow HTTP connections. Be warned that this will send any credentials as clear text.
**image**: Disables verifying image signatures
**tls**: Accept any certificate from the server and any host name in that certificate
**ondisk**: Disables verifying the integrity of the on-disk, rendered image before running. This significantly speeds up start time.
**all**: Disables all security checks | Comma-separated list of security features to disable | -| `--local-config` | `/etc/rkt` | A directory path | Path to the local configuration directory | -| `--system-config` | `/usr/lib/rkt` | A directory path | Path to the system configuration directory | -| `--trust-keys-from-https` | `false` | `true` or `false` | Automatically trust gpg keys fetched from https | -| `--user-config` | `` | A directory path | Path to the user configuration directory | +See the table with [global options in general commands documentation](../commands.md#global-options). [appc-discovery]: https://github.com/appc/spec/blob/master/spec/discovery.md From e525b6c4ed3aa369b5f220e2808a78d5063bf7f7 Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Mon, 7 Mar 2016 15:34:31 +0100 Subject: [PATCH 0046/1304] docs, flag, image, pubkey: Allow downloading insecure GPG keys When fetching images via a discovery mechanism, it is also possible to fetch the keys via the discovery and then trust them to verify the image signature. For the key to be fetched, HTTPS connection is required and the server's certificate must be successfully verified. Trusting the key puts it into a persistent keystore. This makes it hard to test it with a local server, which usually doesn't have a valid certificate. The "pubkey" option of the --insecure-options flag makes fetching keys from insecure places possible, that is - from HTTP connections or from servers with an invalid certificate. --- Documentation/commands.md | 4 +-- rkt/flag/secflags.go | 12 ++++++--- rkt/image/namefetcher.go | 20 ++++++++++----- rkt/pubkey/pubkey.go | 54 +++++++++++++++++++++++++++++++++------ 4 files changed, 70 insertions(+), 20 deletions(-) diff --git a/Documentation/commands.md b/Documentation/commands.md index f983518224..d40876c2f8 100644 --- a/Documentation/commands.md +++ b/Documentation/commands.md @@ -72,10 +72,10 @@ In addition to the flags used by individual `rkt` commands, `rkt` has a set of g | --- | --- | --- | --- | | `--debug` | `false` | `true` or `false` | Prints out more debug information to `stderr` | | `--dir` | `/var/lib/rkt` | A directory path | Path to the `rkt` data directory | -| `--insecure-options` | none | **none**: All security features are enabled
**http**: Allow HTTP connections. Be warned that this will send any credentials as clear text.
**image**: Disables verifying image signatures
**tls**: Accept any certificate from the server and any host name in that certificate
**ondisk**: Disables verifying the integrity of the on-disk, rendered image before running. This significantly speeds up start time.
**all**: Disables all security checks | Comma-separated list of security features to disable | +| `--insecure-options` | none | **none**: All security features are enabled
**http**: Allow HTTP connections. Be warned that this will send any credentials as clear text.
**image**: Disables verifying image signatures
**tls**: Accept any certificate from the server and any host name in that certificate
**ondisk**: Disables verifying the integrity of the on-disk, rendered image before running. This significantly speeds up start time.
**pubkey**: Allow fetching pubkeys via insecure connections (via HTTP connections or from servers with unverified certificates). This slightly extends the meaning of the `--trust-keys-from-https` flag.
**all**: Disables all security checks | Comma-separated list of security features to disable | | `--local-config` | `/etc/rkt` | A directory path | Path to the local configuration directory | | `--system-config` | `/usr/lib/rkt` | A directory path | Path to the system configuration directory | -| `--trust-keys-from-https` | `false` | `true` or `false` | Automatically trust gpg keys fetched from https | +| `--trust-keys-from-https` | `false` | `true` or `false` | Automatically trust gpg keys fetched from HTTPS (or HTTP if the insecure `pubkey` option is also specified) | | `--user-config` | `` | A directory path | Path to the user configuration directory | ## Logging diff --git a/rkt/flag/secflags.go b/rkt/flag/secflags.go index e1badf0528..817c3ef485 100644 --- a/rkt/flag/secflags.go +++ b/rkt/flag/secflags.go @@ -20,12 +20,13 @@ const ( insecureTLS insecureOnDisk insecureHTTP + insecurePubKey - insecureAll = (insecureImage | insecureTLS | insecureOnDisk | insecureHTTP) + insecureAll = (insecureImage | insecureTLS | insecureOnDisk | insecureHTTP | insecurePubKey) ) var ( - insecureOptions = []string{"none", "image", "tls", "ondisk", "http", "all"} + insecureOptions = []string{"none", "image", "tls", "ondisk", "http", "pubkey", "all"} insecureOptionsMap = map[string]int{ insecureOptions[0]: insecureNone, @@ -33,7 +34,8 @@ var ( insecureOptions[2]: insecureTLS, insecureOptions[3]: insecureOnDisk, insecureOptions[4]: insecureHTTP, - insecureOptions[5]: insecureAll, + insecureOptions[5]: insecurePubKey, + insecureOptions[6]: insecureAll, } ) @@ -69,6 +71,10 @@ func (sf *SecFlags) AllowHTTP() bool { return sf.hasFlag(insecureHTTP) } +func (sf *SecFlags) ConsiderInsecurePubKeys() bool { + return sf.hasFlag(insecurePubKey) +} + func (sf *SecFlags) SkipAllSecurityChecks() bool { return sf.hasFlag(insecureAll) } diff --git a/rkt/image/namefetcher.go b/rkt/image/namefetcher.go index fe71fe0e82..9fded8f7f7 100644 --- a/rkt/image/namefetcher.go +++ b/rkt/image/namefetcher.go @@ -199,13 +199,19 @@ func (f *nameFetcher) maybeFetchPubKeys(appName string) { log.Printf("keys already exist for prefix %q, not fetching again", appName) return } - if !f.InsecureFlags.SkipTLSCheck() { + allowHTTP := false + if f.InsecureFlags.ConsiderInsecurePubKeys() { + log.Printf("signing keys may be downloaded from an insecure connection") + allowHTTP = f.InsecureFlags.AllowHTTP() + } + if !f.InsecureFlags.SkipTLSCheck() || f.InsecureFlags.ConsiderInsecurePubKeys() { m := &pubkey.Manager{ - AuthPerHost: f.Headers, - InsecureAllowHTTP: false, - TrustKeysFromHTTPS: f.TrustKeysFromHTTPS, - Ks: f.Ks, - Debug: f.Debug, + AuthPerHost: f.Headers, + InsecureAllowHTTP: allowHTTP, + InsecureSkipTLSCheck: f.InsecureFlags.SkipTLSCheck(), + TrustKeysFromHTTPS: f.TrustKeysFromHTTPS, + Ks: f.Ks, + Debug: f.Debug, } pkls, err := m.GetPubKeyLocations(appName) // We do not bail out here, because if fetching the @@ -233,7 +239,7 @@ func (f *nameFetcher) checkIdentity(appName string, ascFile io.ReadSeeker) error empty := bytes.NewReader([]byte{}) if _, err := f.Ks.CheckSignature(appName, empty, ascFile); err != nil { if err == pgperrors.ErrUnknownIssuer { - log.Printf("If you expected the signing key to change, try running:") + log.Printf("if you expected the signing key to change, try running:") log.Printf(" rkt trust --prefix %q", appName) } if _, ok := err.(pgperrors.SignatureError); !ok { diff --git a/rkt/pubkey/pubkey.go b/rkt/pubkey/pubkey.go index 933151ad67..000dec8c53 100644 --- a/rkt/pubkey/pubkey.go +++ b/rkt/pubkey/pubkey.go @@ -16,14 +16,17 @@ package pubkey import ( "bufio" + "crypto/tls" "errors" "fmt" "io" "io/ioutil" + "net" "net/http" "net/url" "os" "strings" + "time" "github.com/coreos/rkt/pkg/keystore" rktlog "github.com/coreos/rkt/pkg/log" @@ -36,11 +39,12 @@ import ( ) type Manager struct { - AuthPerHost map[string]config.Headerer - InsecureAllowHTTP bool - TrustKeysFromHTTPS bool - Ks *keystore.Keystore - Debug bool + AuthPerHost map[string]config.Headerer + InsecureAllowHTTP bool + InsecureSkipTLSCheck bool + TrustKeysFromHTTPS bool + Ks *keystore.Keystore + Debug bool } type AcceptOption int @@ -157,6 +161,9 @@ func (m *Manager) metaDiscoverPubKeyLocations(prefix string) ([]string, error) { if m.InsecureAllowHTTP { insecure = insecure | discovery.InsecureHttp } + if m.InsecureSkipTLSCheck { + insecure = insecure | discovery.InsecureTls + } ep, attempts, err := discovery.DiscoverPublicKeys(*app, hostHeaders, insecure) if err != nil { return nil, err @@ -182,14 +189,14 @@ func (m *Manager) getPubKey(u *url.URL) (*os.File, error) { } fallthrough case "https": - return downloadKey(u) + return downloadKey(u, m.InsecureSkipTLSCheck) } return nil, fmt.Errorf("only local files and http or https URLs supported") } // downloadKey retrieves the file, storing it in a deleted tempfile -func downloadKey(u *url.URL) (*os.File, error) { +func downloadKey(u *url.URL, skipTLSCheck bool) (*os.File, error) { tf, err := ioutil.TempFile("", "") if err != nil { return nil, errwrap.Wrap(errors.New("error creating tempfile"), err) @@ -204,7 +211,8 @@ func downloadKey(u *url.URL) (*os.File, error) { // TODO(krnowak): we should probably apply credential headers // from config here - res, err := http.Get(u.String()) + client := getClient(skipTLSCheck) + res, err := client.Get(u.String()) if err != nil { return nil, errwrap.Wrap(errors.New("error getting key"), err) } @@ -227,6 +235,36 @@ func downloadKey(u *url.URL) (*os.File, error) { return retTf, nil } +func getClient(skipTLSCheck bool) *http.Client { + if !skipTLSCheck { + return http.DefaultClient + } + client := *http.DefaultClient + var tr *http.Transport + // default transport is hidden behind the RoundTripper + // interface, so we can't easily make a copy of it + if transport, ok := http.DefaultTransport.(*http.Transport); ok { + trCopy := *transport + tr = &trCopy + } else { + // meh, an already outdated copy from golang's + // net/http DefaultTransport defintion, without the + // ExpectContinueTimeout field set, because it exists + // only in go1.6 + tr = &http.Transport{ + Proxy: http.ProxyFromEnvironment, + Dial: (&net.Dialer{ + Timeout: 30 * time.Second, + KeepAlive: 30 * time.Second, + }).Dial, + TLSHandshakeTimeout: 10 * time.Second, + } + } + tr.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} + client.Transport = tr + return &client +} + // displayKey shows the key summary func displayKey(prefix, location string, key *os.File) error { defer key.Seek(0, os.SEEK_SET) From c0d0ef704d00c1ce62c200371b909442dc134d64 Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Thu, 31 Mar 2016 12:09:15 +0200 Subject: [PATCH 0047/1304] godeps: Update gexpect This gets some fixes in gexpect, so the tests will be less likely to fail. --- Godeps/Godeps.json | 4 +- .../github.com/coreos/gexpect/examples/ftp.go | 27 ---------- .../coreos/gexpect/examples/ping.go | 15 ------ .../coreos/gexpect/examples/python.go | 22 -------- .../coreos/gexpect/examples/screen.go | 53 ------------------- .../src/github.com/coreos/gexpect/gexpect.go | 24 ++++----- 6 files changed, 13 insertions(+), 132 deletions(-) delete mode 100644 Godeps/_workspace/src/github.com/coreos/gexpect/examples/ftp.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/gexpect/examples/ping.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/gexpect/examples/python.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/gexpect/examples/screen.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 90834e6389..9bc7b578e9 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,6 +1,7 @@ { "ImportPath": "github.com/coreos/rkt", "GoVersion": "go1.5", + "GodepVersion": "v60", "Packages": [ "./...", "github.com/appc/spec/actool", @@ -214,7 +215,8 @@ }, { "ImportPath": "github.com/coreos/gexpect", - "Rev": "0b5620b695de57d5fcea082b9a062157ac60ed73" + "Comment": "v0.1.0", + "Rev": "ca42424d18c76d0d51a4cccd830d11878e9e5c17" }, { "ImportPath": "github.com/coreos/go-iptables/iptables", diff --git a/Godeps/_workspace/src/github.com/coreos/gexpect/examples/ftp.go b/Godeps/_workspace/src/github.com/coreos/gexpect/examples/ftp.go deleted file mode 100644 index 28fbbae4f4..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/gexpect/examples/ftp.go +++ /dev/null @@ -1,27 +0,0 @@ -package main - -import gexpect "github.com/coreos/gexpect" -import "log" - -func main() { - log.Printf("Testing Ftp... ") - - child, err := gexpect.Spawn("ftp ftp.openbsd.org") - if err != nil { - panic(err) - } - child.Expect("Name") - child.SendLine("anonymous") - child.Expect("Password") - child.SendLine("pexpect@sourceforge.net") - child.Expect("ftp> ") - child.SendLine("cd /pub/OpenBSD/3.7/packages/i386") - child.Expect("ftp> ") - child.SendLine("bin") - child.Expect("ftp> ") - child.SendLine("prompt") - child.Expect("ftp> ") - child.SendLine("pwd") - child.Expect("ftp> ") - log.Printf("Success\n") -} diff --git a/Godeps/_workspace/src/github.com/coreos/gexpect/examples/ping.go b/Godeps/_workspace/src/github.com/coreos/gexpect/examples/ping.go deleted file mode 100644 index a39dd68f2b..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/gexpect/examples/ping.go +++ /dev/null @@ -1,15 +0,0 @@ -package main - -import gexpect "github.com/coreos/gexpect" -import "log" - -func main() { - log.Printf("Testing Ping interact... \n") - - child, err := gexpect.Spawn("ping -c8 127.0.0.1") - if err != nil { - panic(err) - } - child.Interact() - log.Printf("Success\n") -} diff --git a/Godeps/_workspace/src/github.com/coreos/gexpect/examples/python.go b/Godeps/_workspace/src/github.com/coreos/gexpect/examples/python.go deleted file mode 100644 index ef8be7cb6b..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/gexpect/examples/python.go +++ /dev/null @@ -1,22 +0,0 @@ -package main - -import "github.com/coreos/gexpect" -import "fmt" - -func main() { - fmt.Printf("Starting python.. \n") - child, err := gexpect.Spawn("python") - if err != nil { - panic(err) - } - fmt.Printf("Expecting >>>.. \n") - child.Expect(">>>") - fmt.Printf("print 'Hello World'..\n") - child.SendLine("print 'Hello World'") - child.Expect(">>>") - - fmt.Printf("Interacting.. \n") - child.Interact() - fmt.Printf("Done \n") - child.Close() -} diff --git a/Godeps/_workspace/src/github.com/coreos/gexpect/examples/screen.go b/Godeps/_workspace/src/github.com/coreos/gexpect/examples/screen.go deleted file mode 100644 index dfdd74747f..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/gexpect/examples/screen.go +++ /dev/null @@ -1,53 +0,0 @@ -package main - -import "github.com/coreos/gexpect" -import "fmt" -import "strings" - -func main() { - waitChan := make(chan string) - - fmt.Printf("Starting screen.. \n") - - child, err := gexpect.Spawn("screen") - if err != nil { - panic(err) - } - - sender, reciever := child.AsyncInteractChannels() - go func() { - waitString := "" - count := 0 - for { - select { - case waitString = <-waitChan: - count++ - case msg, open := <-reciever: - if !open { - return - } - fmt.Printf("Recieved: %s\n", msg) - - if strings.Contains(msg, waitString) { - if count >= 1 { - waitChan <- msg - count -= 1 - } - } - } - } - }() - wait := func(str string) { - waitChan <- str - <-waitChan - } - fmt.Printf("Waiting until started.. \n") - wait(" ") - fmt.Printf("Sending Enter.. \n") - sender <- "\n" - wait("$") - fmt.Printf("Sending echo.. \n") - sender <- "echo Hello World\n" - wait("Hello World") - fmt.Printf("Received echo. \n") -} diff --git a/Godeps/_workspace/src/github.com/coreos/gexpect/gexpect.go b/Godeps/_workspace/src/github.com/coreos/gexpect/gexpect.go index 63bbf00270..4ea620ef6e 100644 --- a/Godeps/_workspace/src/github.com/coreos/gexpect/gexpect.go +++ b/Godeps/_workspace/src/github.com/coreos/gexpect/gexpect.go @@ -71,7 +71,7 @@ func (buf *buffer) ReadRune() (r rune, size int, err error) { if err != nil { return 0, 0, err } - if utf8.FullRune(chunk) { + if utf8.FullRune(chunk[:n]) { r, rL := utf8.DecodeRune(chunk) if n > rL { buf.PutBack(chunk[rL:n]) @@ -90,7 +90,7 @@ func (buf *buffer) ReadRune() (r rune, size int, err error) { } l = l + fn - if utf8.FullRune(chunk) { + if utf8.FullRune(chunk[:l]) { r, rL := utf8.DecodeRune(chunk) if buf.collect { buf.collection.WriteRune(r) @@ -331,7 +331,7 @@ func (expect *ExpectSubprocess) Expect(searchString string) (e error) { if i == target { unreadIndex := m + i - offset if len(chunk) > unreadIndex { - expect.buf.PutBack(chunk[unreadIndex:]) + expect.buf.PutBack(chunk[unreadIndex:n]) } return nil } @@ -378,27 +378,26 @@ func (expect *ExpectSubprocess) Interact() { } func (expect *ExpectSubprocess) ReadUntil(delim byte) ([]byte, error) { - join := make([]byte, 1, 512) + join := make([]byte, 0, 512) chunk := make([]byte, 255) for { - n, err := expect.buf.Read(chunk) - if err != nil { - return join, err - } - for i := 0; i < n; i++ { if chunk[i] == delim { if len(chunk) > i+1 { - expect.buf.PutBack(chunk[i+1:]) + expect.buf.PutBack(chunk[i+1:n]) } return join, nil } else { join = append(join, chunk[i]) } } + + if err != nil { + return join, err + } } } @@ -408,10 +407,7 @@ func (expect *ExpectSubprocess) Wait() error { func (expect *ExpectSubprocess) ReadLine() (string, error) { str, err := expect.ReadUntil('\n') - if err != nil { - return "", err - } - return string(str), nil + return string(str), err } func _start(expect *ExpectSubprocess) (*ExpectSubprocess, error) { From 02939a31dda76543928a7ac4078fc3fbba9ec96b Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Tue, 29 Mar 2016 17:18:05 +0200 Subject: [PATCH 0048/1304] tests/aws.sh: add test for Fedora 24 --- tests/aws.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/aws.sh b/tests/aws.sh index 5e1953cf79..a3163d6dc7 100755 --- a/tests/aws.sh +++ b/tests/aws.sh @@ -29,6 +29,7 @@ if [ "$DISTRO" = "all" ] ; then gnome-terminal \ --tab --command="$SCRIPTPATH/aws.sh fedora-22 $GIT_URL $GIT_BRANCH $FLAVOR" \ --tab --command="$SCRIPTPATH/aws.sh fedora-23 $GIT_URL $GIT_BRANCH $FLAVOR" \ + --tab --command="$SCRIPTPATH/aws.sh fedora-24 $GIT_URL $GIT_BRANCH $FLAVOR" \ --tab --command="$SCRIPTPATH/aws.sh fedora-rawhide $GIT_URL $GIT_BRANCH $FLAVOR" \ --tab --command="$SCRIPTPATH/aws.sh ubuntu-1604 $GIT_URL $GIT_BRANCH $FLAVOR" \ --tab --command="$SCRIPTPATH/aws.sh ubuntu-1510 $GIT_URL $GIT_BRANCH $FLAVOR" \ @@ -60,6 +61,13 @@ elif [ "$DISTRO" = "fedora-23" ] ; then # Workarounds DISABLE_SELINUX=true +elif [ "$DISTRO" = "fedora-24" ] ; then + # Fedora-Cloud-Base-24_Alpha-7.x86_64-eu-central-1-HVM-standard-0 + AMI=ami-748b6d1b + AWS_USER=fedora + + # Workarounds + DISABLE_OVERLAY=true elif [ "$DISTRO" = "fedora-rawhide" ] ; then # Fedora-Cloud-Base-Rawhide-20160321.0.x86_64-eu-central-1-HVM-standard-0 AMI=ami-69967006 From c02ccb91b4cd066529e9484169c26375d2dc659f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Thu, 17 Mar 2016 15:10:48 +0100 Subject: [PATCH 0049/1304] stage1: implement docker volume semantics Docker volumes are initialized with the files in the image if they exist, unless a host directory is mounted there (see https://docs.docker.com/engine/userguide/containers/dockervolumes/#data-volumes). However, when we convert docker images with docker2aci, we convert docker volumes to mount points, and if the user doesn't specify a host path for mounting, we mount an empty volume, effectively masking the files in the image. To fix this, we create a special case for the case when application uses an image converted from docker and we mount an implicit empty volume. In that case, we copy the files from the image to the volume, so docker images work correctly. Note that we won't do this if the user explicitly specifies an empty volume or if they mount a host directory. --- stage1/init/common/kvm_mount.go | 23 +++++-- stage1/init/common/mount.go | 111 ++++++++++++++++++++++++++------ stage1/init/common/pod.go | 46 +++++-------- 3 files changed, 123 insertions(+), 57 deletions(-) diff --git a/stage1/init/common/kvm_mount.go b/stage1/init/common/kvm_mount.go index b3e6cc68c7..08b37f007b 100644 --- a/stage1/init/common/kvm_mount.go +++ b/stage1/init/common/kvm_mount.go @@ -38,6 +38,7 @@ package common import ( "crypto/md5" "encoding/hex" + "errors" "fmt" "io" "io/ioutil" @@ -172,7 +173,7 @@ func AppToSystemdMountUnits(root string, appName types.ACName, volumes []types.V vols[v.Name] = v } - mounts := GenerateMounts(ra, vols) + mounts := generateMounts(ra, vols) for _, m := range mounts { vol := vols[m.Volume] @@ -180,18 +181,26 @@ func AppToSystemdMountUnits(root string, appName types.ACName, volumes []types.V hashedVolName := makeHashFromVolumeName(vol.Name.String()) whatPath := filepath.Join(stage1MntDir, hashedVolName) - whatFullPath := filepath.Join(root, whatPath) - // set volume permissions - if err := PrepareMountpoints(whatFullPath, &vol); err != nil { - return err - } - // destination relative to stage1 rootfs and relative to pod root wherePath := filepath.Join(common.RelAppRootfsPath(appName), m.Path) whereFullPath := filepath.Join(root, wherePath) + // create shared volumes directory + stage1MntPath := filepath.Join(root, stage1MntDir) + if err := os.MkdirAll(stage1MntPath, sharedVolPerm); err != nil { + return errwrap.Wrap(errors.New("could not create shared volumes directory"), err) + } + if err := os.Chmod(stage1MntPath, sharedVolPerm); err != nil { + return errwrap.Wrap(fmt.Errorf("could not change permissions of %q", stage1MntPath), err) + } + + // prepare empty volumes + if err := PrepareMountpoints(whatFullPath, whereFullPath, &vol, m.dockerImplicit); err != nil { + return errwrap.Wrap(errors.New("error preparing empty mount points"), err) + } + // assertion to make sure that "what" exists (created earlier by PodToSystemdHostMountUnits) diag.Printf("checking required source path: %q", whatFullPath) if _, err := os.Stat(whatFullPath); os.IsNotExist(err) { diff --git a/stage1/init/common/mount.go b/stage1/init/common/mount.go index 4ed5150917..9045268552 100644 --- a/stage1/init/common/mount.go +++ b/stage1/init/common/mount.go @@ -18,12 +18,23 @@ import ( "fmt" "os" "strconv" + "syscall" + + "github.com/coreos/rkt/pkg/fileutil" + "github.com/coreos/rkt/pkg/uid" "github.com/appc/spec/schema" "github.com/appc/spec/schema/types" "github.com/hashicorp/errwrap" ) +// mountWrapper is a wrapper around a schema.Mount with an additional field indicating +// whether it is an implicit empty volume converted from a Docker image. +type mountWrapper struct { + schema.Mount + dockerImplicit bool +} + func isMPReadOnly(mountPoints []types.MountPoint, name types.ACName) bool { for _, mp := range mountPoints { if mp.Name == name { @@ -45,13 +56,28 @@ func IsMountReadOnly(vol types.Volume, mountPoints []types.MountPoint) bool { return isMPReadOnly(mountPoints, vol.Name) } -// GenerateMounts maps MountPoint paths to volumes, returning a list of Mounts. -func GenerateMounts(ra *schema.RuntimeApp, volumes map[types.ACName]types.Volume) []schema.Mount { +func convertedFromDocker(ra *schema.RuntimeApp) bool { + ann := ra.Annotations + _, ok := ann.Get("appc.io/docker/repository") + return ok +} + +// generateMounts maps MountPoint paths to volumes, returning a list of mounts, +// each with a parameter indicating if it's an implicit empty volume from a +// Docker image. +func generateMounts(ra *schema.RuntimeApp, volumes map[types.ACName]types.Volume) []mountWrapper { app := ra.App + var genMnts []mountWrapper + mnts := make(map[string]schema.Mount) for _, m := range ra.Mounts { mnts[m.Path] = m + genMnts = append(genMnts, + mountWrapper{ + Mount: m, + dockerImplicit: false, + }) } for _, mp := range app.MountPoints { @@ -74,36 +100,79 @@ func GenerateMounts(ra *schema.RuntimeApp, volumes map[types.ACName]types.Volume GID: &defaultGID, } + dockerImplicit := convertedFromDocker(ra) log.Printf("warning: no volume specified for mount point %q, implicitly creating an \"empty\" volume. This volume will be removed when the pod is garbage-collected.", mp.Name) + if dockerImplicit { + log.Printf("Docker converted image, initializing implicit volume with data contained at the mount point %q.", mp.Name) + } volumes[mp.Name] = emptyVol - ra.Mounts = append(ra.Mounts, schema.Mount{Volume: mp.Name, Path: mp.Path}) + genMnts = append(genMnts, + mountWrapper{ + Mount: schema.Mount{ + Volume: mp.Name, + Path: mp.Path, + }, + dockerImplicit: dockerImplicit, + }) } else { - ra.Mounts = append(ra.Mounts, schema.Mount{Volume: vol.Name, Path: mp.Path}) + genMnts = append(genMnts, + mountWrapper{ + Mount: schema.Mount{ + Volume: vol.Name, + Path: mp.Path, + }, + dockerImplicit: false, + }) } } - return ra.Mounts + return genMnts } -// PrepareMountpoints creates and sets permissions for volumes. -func PrepareMountpoints(path string, vol *types.Volume) error { - if vol.Kind == "empty" { - diag.Printf("creating an empty volume folder for sharing: %q", path) - err := os.MkdirAll(path, sharedVolPerm) - if err != nil { - return errwrap.Wrap(fmt.Errorf("could not create mount point for volume %q", vol.Name), err) - } - if err := os.Chown(path, *vol.UID, *vol.GID); err != nil { - return errwrap.Wrap(fmt.Errorf("could not change owner of %q", path), err) - } - mod, err := strconv.ParseUint(*vol.Mode, 8, 32) - if err != nil { - return errwrap.Wrap(fmt.Errorf("invalid mode %q for volume %q", *vol.Mode, vol.Name), err) +// PrepareMountpoints creates and sets permissions for empty volumes. +// If the mountpoint comes from a Docker image and it is an implicit empty +// volume, we copy files from the image to the volume, see +// https://docs.docker.com/engine/userguide/containers/dockervolumes/#data-volumes +func PrepareMountpoints(volPath string, targetPath string, vol *types.Volume, dockerImplicit bool) error { + if vol.Kind != "empty" { + return nil + } + + diag.Printf("creating an empty volume folder for sharing: %q", volPath) + m, err := strconv.ParseUint(*vol.Mode, 8, 32) + if err != nil { + return errwrap.Wrap(fmt.Errorf("invalid mode %q for volume %q", *vol.Mode, vol.Name), err) + } + mode := os.FileMode(m) + Uid := *vol.UID + Gid := *vol.GID + + if dockerImplicit { + fi, err := os.Stat(targetPath) + if err == nil { + // the directory exists in the image, let's set the same + // permissions and copy files from there to the empty volume + mode = fi.Mode() + Uid = int(fi.Sys().(*syscall.Stat_t).Uid) + Gid = int(fi.Sys().(*syscall.Stat_t).Gid) + + if err := fileutil.CopyTree(targetPath, volPath, uid.NewBlankUidRange()); err != nil { + return errwrap.Wrap(fmt.Errorf("error copying image files to empty volume %q", volPath), err) + } } - if err := os.Chmod(path, os.FileMode(mod)); err != nil { - return errwrap.Wrap(fmt.Errorf("could not change permissions of %q", path), err) + } else { + if err := os.MkdirAll(volPath, 0770); err != nil { + return errwrap.Wrap(fmt.Errorf("error creating %q", volPath), err) } + + } + if err := os.Chown(volPath, Uid, Gid); err != nil { + return errwrap.Wrap(fmt.Errorf("could not change owner of %q", volPath), err) } + if err := os.Chmod(volPath, mode); err != nil { + return errwrap.Wrap(fmt.Errorf("could not change permissions of %q", volPath), err) + } + return nil } diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index d108023eb6..ab6f265ad6 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -638,25 +638,26 @@ func appToNspawnArgs(p *stage1commontypes.Pod, ra *schema.RuntimeApp) ([]string, vols[v.Name] = v } - mounts := GenerateMounts(ra, vols) + mounts := generateMounts(ra, vols) for _, m := range mounts { vol := vols[m.Volume] - if vol.Kind == "empty" { - p := filepath.Join(sharedVolPath, vol.Name.String()) - if err := os.MkdirAll(p, sharedVolPerm); err != nil { - return nil, errwrap.Wrap(fmt.Errorf("could not create shared volume %q", vol.Name), err) - } - if err := os.Chown(p, *vol.UID, *vol.GID); err != nil { - return nil, errwrap.Wrap(fmt.Errorf("could not change owner of %q", p), err) - } - mod, err := strconv.ParseUint(*vol.Mode, 8, 32) - if err != nil { - return nil, errwrap.Wrap(fmt.Errorf("invalid mode %q for volume %q", *vol.Mode, vol.Name), err) - } - if err := os.Chmod(p, os.FileMode(mod)); err != nil { - return nil, errwrap.Wrap(fmt.Errorf("could not change permissions of %q", p), err) - } + shPath := filepath.Join(sharedVolPath, vol.Name.String()) + + absRoot, err := filepath.Abs(p.Root) // Absolute path to the pod's rootfs. + if err != nil { + return nil, errwrap.Wrap(errors.New("could not get pod's root absolute path"), err) + } + + appRootfs := common.AppRootfsPath(absRoot, appName) + mntPath, err := evaluateAppMountPath(appRootfs, m.Path) + if err != nil { + return nil, errwrap.Wrap(fmt.Errorf("could not evaluate path %v", m.Path), err) + } + mntAbsPath := filepath.Join(appRootfs, mntPath) + + if err := PrepareMountpoints(shPath, mntAbsPath, &vol, m.dockerImplicit); err != nil { + return nil, err } opt := make([]string, 4) @@ -667,11 +668,6 @@ func appToNspawnArgs(p *stage1commontypes.Pod, ra *schema.RuntimeApp) ([]string, opt[0] = "--bind=" } - absRoot, err := filepath.Abs(p.Root) // Absolute path to the pod's rootfs. - if err != nil { - return nil, errwrap.Wrap(errors.New("could not get pod's root absolute path"), err) - } - switch vol.Kind { case "host": opt[1] = vol.Source @@ -681,15 +677,7 @@ func appToNspawnArgs(p *stage1commontypes.Pod, ra *schema.RuntimeApp) ([]string, return nil, fmt.Errorf(`invalid volume kind %q. Must be one of "host" or "empty"`, vol.Kind) } opt[2] = ":" - - appRootfs := common.AppRootfsPath(absRoot, appName) - mntPath, err := evaluateAppMountPath(appRootfs, m.Path) - if err != nil { - return nil, errwrap.Wrap(fmt.Errorf("could not evaluate path %v", m.Path), err) - } - opt[3] = filepath.Join(common.RelAppRootfsPath(appName), mntPath) - args = append(args, strings.Join(opt, "")) } From 5d3928de4fd0010a7e4e87db1cd437e21fb3036c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 23 Mar 2016 16:47:04 +0100 Subject: [PATCH 0050/1304] stage1/init: generate unique names for implicit empty vols --- stage1/init/common/mount.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/stage1/init/common/mount.go b/stage1/init/common/mount.go index 9045268552..86978d31bf 100644 --- a/stage1/init/common/mount.go +++ b/stage1/init/common/mount.go @@ -92,8 +92,9 @@ func generateMounts(ra *schema.RuntimeApp, volumes map[types.ACName]types.Volume defaultMode := "0755" defaultUID := 0 defaultGID := 0 + uniqName := ra.Name + "-" + mp.Name emptyVol := types.Volume{ - Name: mp.Name, + Name: uniqName, Kind: "empty", Mode: &defaultMode, UID: &defaultUID, @@ -106,11 +107,11 @@ func generateMounts(ra *schema.RuntimeApp, volumes map[types.ACName]types.Volume log.Printf("Docker converted image, initializing implicit volume with data contained at the mount point %q.", mp.Name) } - volumes[mp.Name] = emptyVol + volumes[uniqName] = emptyVol genMnts = append(genMnts, mountWrapper{ Mount: schema.Mount{ - Volume: mp.Name, + Volume: uniqName, Path: mp.Path, }, dockerImplicit: dockerImplicit, From 8de36ca9edd65a62471e7a81da524462bc8e960a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 30 Mar 2016 15:40:28 +0200 Subject: [PATCH 0051/1304] functional tests: simulate a docker-converted image To test Docker volume semantics, we simulate the inspect aci is a Docker-converted image. The other tests don't care about this. --- tests/image/manifest | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/image/manifest b/tests/image/manifest index 73913d743b..81978de79d 100644 --- a/tests/image/manifest +++ b/tests/image/manifest @@ -55,6 +55,10 @@ ] }, "annotations": [ + { + "name": "appc.io/docker/repository", + "value": "whatever" + }, { "name": "coreos.com/rkt/stage1/run", "value": "/ex/run" From 4ebff8a0369b87753ba40e05c7fb5a3ef426b0ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 30 Mar 2016 15:41:14 +0200 Subject: [PATCH 0052/1304] functional tests: test Docker volume semantics --- tests/rkt_volume_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/rkt_volume_test.go b/tests/rkt_volume_test.go index 4077bd45b8..6f9a7abae2 100644 --- a/tests/rkt_volume_test.go +++ b/tests/rkt_volume_test.go @@ -141,3 +141,16 @@ func TestVolumes(t *testing.T) { } } } + +func TestDockerVolumeSemantics(t *testing.T) { + dockerVolImage := patchTestACI("rkt-volume-image.aci", fmt.Sprintf("--mounts=dir1,path=/dir1,readOnly=false")) + defer os.Remove(dockerVolImage) + + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + cmd := fmt.Sprintf(`/bin/sh -c "export FILE=/dir1/file ; %s --debug --insecure-options=image run --inherit-env %s --exec /inspect -- --read-file"`, ctx.Cmd(), dockerVolImage) + + expected := "<<>>" + runRktAndCheckOutput(t, cmd, expected, false) +} From f8db946bf6cb0a036db72c134f8956403d70780a Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Thu, 31 Mar 2016 13:38:47 +0200 Subject: [PATCH 0053/1304] godeps: update goaci to v0.1.0 No code changes here. --- Godeps/Godeps.json | 1 + 1 file changed, 1 insertion(+) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 9bc7b578e9..1c15d7093d 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -148,6 +148,7 @@ }, { "ImportPath": "github.com/appc/goaci/proj2aci", + "Comment": "v0.1.0", "Rev": "ba7b591f930783c0ab75f5bbfd6ff65c7bd011bf" }, { From 2c2bb2ef6ca60ed34df1ff2e739a8d57e80950fa Mon Sep 17 00:00:00 2001 From: 0xbzho <0xbzho@gmail.com> Date: Thu, 31 Mar 2016 13:49:01 +0100 Subject: [PATCH 0054/1304] Use lowercase for UID & GID options in run example The syntax description for the --volume option uses lowercase for the uid and gid parameters; whereas the example uses uppercase. Change the example to conform to the implemented behaviour. --- Documentation/subcommands/run.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/subcommands/run.md b/Documentation/subcommands/run.md index 0040dab16a..411863880d 100644 --- a/Documentation/subcommands/run.md +++ b/Documentation/subcommands/run.md @@ -170,7 +170,7 @@ Syntax: In the following example, we create an empty volume for app1's `/var/data`: ``` - # rkt run --volume data,kind=empty,mode=0700,UID=0,GID=0 + # rkt run --volume data,kind=empty,mode=0700,uid=0,gid=0 ``` ### Mounting Volumes without Mount Points From bce65e08dfd95f6cdb4c9fbff3551cf0c6ca4293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Thu, 31 Mar 2016 15:28:16 +0200 Subject: [PATCH 0055/1304] Godeps: bump diskv to v2.0.0 Yes. Another bump. On the same day. --- Godeps/Godeps.json | 12 +- .../src/github.com/google/btree/.travis.yml | 1 + .../src/github.com/google/btree/LICENSE | 202 +++++++ .../src/github.com/google/btree/README.md | 12 + .../src/github.com/google/btree/btree.go | 571 ++++++++++++++++++ .../src/github.com/google/btree/btree_mem.go | 76 +++ .../github.com/petar/GoLLRB/llrb/avgvar.go | 39 -- .../github.com/petar/GoLLRB/llrb/iterator.go | 93 --- .../petar/GoLLRB/llrb/llrb-stats.go | 46 -- .../src/github.com/petar/GoLLRB/llrb/llrb.go | 456 -------------- .../src/github.com/petar/GoLLRB/llrb/util.go | 17 - .../github.com/peterbourgon/diskv/index.go | 71 ++- 12 files changed, 903 insertions(+), 693 deletions(-) create mode 100644 Godeps/_workspace/src/github.com/google/btree/.travis.yml create mode 100644 Godeps/_workspace/src/github.com/google/btree/LICENSE create mode 100644 Godeps/_workspace/src/github.com/google/btree/README.md create mode 100644 Godeps/_workspace/src/github.com/google/btree/btree.go create mode 100644 Godeps/_workspace/src/github.com/google/btree/btree_mem.go delete mode 100644 Godeps/_workspace/src/github.com/petar/GoLLRB/llrb/avgvar.go delete mode 100644 Godeps/_workspace/src/github.com/petar/GoLLRB/llrb/iterator.go delete mode 100644 Godeps/_workspace/src/github.com/petar/GoLLRB/llrb/llrb-stats.go delete mode 100644 Godeps/_workspace/src/github.com/petar/GoLLRB/llrb/llrb.go delete mode 100644 Godeps/_workspace/src/github.com/petar/GoLLRB/llrb/util.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 1c15d7093d..8e30ea4b2e 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -344,6 +344,10 @@ "ImportPath": "github.com/golang/protobuf/proto", "Rev": "2402d76f3d41f928c7902a765dfc872356dd3aad" }, + { + "ImportPath": "github.com/google/btree", + "Rev": "f06e229e679911bb31a04e07ac891115822e37c3" + }, { "ImportPath": "github.com/gorilla/context", "Rev": "50c25fb3b2b3b3cc724e9b6ac75fb44b3bccd0da" @@ -377,14 +381,10 @@ "ImportPath": "github.com/pborman/uuid", "Rev": "cccd189d45f7ac3368a0d127efb7f4d08ae0b655" }, - { - "ImportPath": "github.com/petar/GoLLRB/llrb", - "Rev": "53be0d36a84c2a886ca057d34b6aa4468df9ccb4" - }, { "ImportPath": "github.com/peterbourgon/diskv", - "Comment": "v1.0.0", - "Rev": "f2c8925fb5e0e9614e23499efa68df1924ba6add" + "Comment": "v2.0.0", + "Rev": "937c5a91d7fb1477fa6d2bb71410b2ae7a0f2143" }, { "ImportPath": "github.com/russross/blackfriday", diff --git a/Godeps/_workspace/src/github.com/google/btree/.travis.yml b/Godeps/_workspace/src/github.com/google/btree/.travis.yml new file mode 100644 index 0000000000..4f2ee4d973 --- /dev/null +++ b/Godeps/_workspace/src/github.com/google/btree/.travis.yml @@ -0,0 +1 @@ +language: go diff --git a/Godeps/_workspace/src/github.com/google/btree/LICENSE b/Godeps/_workspace/src/github.com/google/btree/LICENSE new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/Godeps/_workspace/src/github.com/google/btree/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor 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, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/Godeps/_workspace/src/github.com/google/btree/README.md b/Godeps/_workspace/src/github.com/google/btree/README.md new file mode 100644 index 0000000000..6062a4dacd --- /dev/null +++ b/Godeps/_workspace/src/github.com/google/btree/README.md @@ -0,0 +1,12 @@ +# BTree implementation for Go + +![Travis CI Build Status](https://api.travis-ci.org/google/btree.svg?branch=master) + +This package provides an in-memory B-Tree implementation for Go, useful as +an ordered, mutable data structure. + +The API is based off of the wonderful +http://godoc.org/github.com/petar/GoLLRB/llrb, and is meant to allow btree to +act as a drop-in replacement for gollrb trees. + +See http://godoc.org/github.com/google/btree for documentation. diff --git a/Godeps/_workspace/src/github.com/google/btree/btree.go b/Godeps/_workspace/src/github.com/google/btree/btree.go new file mode 100644 index 0000000000..eb1f75cda6 --- /dev/null +++ b/Godeps/_workspace/src/github.com/google/btree/btree.go @@ -0,0 +1,571 @@ +// Copyright 2014 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package btree implements in-memory B-Trees of arbitrary degree. +// +// btree implements an in-memory B-Tree for use as an ordered data structure. +// It is not meant for persistent storage solutions. +// +// It has a flatter structure than an equivalent red-black or other binary tree, +// which in some cases yields better memory usage and/or performance. +// See some discussion on the matter here: +// http://google-opensource.blogspot.com/2013/01/c-containers-that-save-memory-and-time.html +// Note, though, that this project is in no way related to the C++ B-Tree +// implmentation written about there. +// +// Within this tree, each node contains a slice of items and a (possibly nil) +// slice of children. For basic numeric values or raw structs, this can cause +// efficiency differences when compared to equivalent C++ template code that +// stores values in arrays within the node: +// * Due to the overhead of storing values as interfaces (each +// value needs to be stored as the value itself, then 2 words for the +// interface pointing to that value and its type), resulting in higher +// memory use. +// * Since interfaces can point to values anywhere in memory, values are +// most likely not stored in contiguous blocks, resulting in a higher +// number of cache misses. +// These issues don't tend to matter, though, when working with strings or other +// heap-allocated structures, since C++-equivalent structures also must store +// pointers and also distribute their values across the heap. +// +// This implementation is designed to be a drop-in replacement to gollrb.LLRB +// trees, (http://github.com/petar/gollrb), an excellent and probably the most +// widely used ordered tree implementation in the Go ecosystem currently. +// Its functions, therefore, exactly mirror those of +// llrb.LLRB where possible. Unlike gollrb, though, we currently don't +// support storing multiple equivalent values or backwards iteration. +package btree + +import ( + "fmt" + "io" + "sort" + "strings" +) + +// Item represents a single object in the tree. +type Item interface { + // Less tests whether the current item is less than the given argument. + // + // This must provide a strict weak ordering. + // If !a.Less(b) && !b.Less(a), we treat this to mean a == b (i.e. we can only + // hold one of either a or b in the tree). + Less(than Item) bool +} + +// ItemIterator allows callers of Ascend* to iterate in-order over portions of +// the tree. When this function returns false, iteration will stop and the +// associated Ascend* function will immediately return. +type ItemIterator func(i Item) bool + +// New creates a new B-Tree with the given degree. +// +// New(2), for example, will create a 2-3-4 tree (each node contains 1-3 items +// and 2-4 children). +func New(degree int) *BTree { + if degree <= 1 { + panic("bad degree") + } + return &BTree{ + degree: degree, + freelist: make([]*node, 0, 32), + } +} + +// items stores items in a node. +type items []Item + +// insertAt inserts a value into the given index, pushing all subsequent values +// forward. +func (s *items) insertAt(index int, item Item) { + *s = append(*s, nil) + if index < len(*s) { + copy((*s)[index+1:], (*s)[index:]) + } + (*s)[index] = item +} + +// removeAt removes a value at a given index, pulling all subsequent values +// back. +func (s *items) removeAt(index int) Item { + item := (*s)[index] + copy((*s)[index:], (*s)[index+1:]) + *s = (*s)[:len(*s)-1] + return item +} + +// pop removes and returns the last element in the list. +func (s *items) pop() (out Item) { + index := len(*s) - 1 + out, *s = (*s)[index], (*s)[:index] + return +} + +// find returns the index where the given item should be inserted into this +// list. 'found' is true if the item already exists in the list at the given +// index. +func (s items) find(item Item) (index int, found bool) { + i := sort.Search(len(s), func(i int) bool { + return item.Less(s[i]) + }) + if i > 0 && !s[i-1].Less(item) { + return i - 1, true + } + return i, false +} + +// children stores child nodes in a node. +type children []*node + +// insertAt inserts a value into the given index, pushing all subsequent values +// forward. +func (s *children) insertAt(index int, n *node) { + *s = append(*s, nil) + if index < len(*s) { + copy((*s)[index+1:], (*s)[index:]) + } + (*s)[index] = n +} + +// removeAt removes a value at a given index, pulling all subsequent values +// back. +func (s *children) removeAt(index int) *node { + n := (*s)[index] + copy((*s)[index:], (*s)[index+1:]) + *s = (*s)[:len(*s)-1] + return n +} + +// pop removes and returns the last element in the list. +func (s *children) pop() (out *node) { + index := len(*s) - 1 + out, *s = (*s)[index], (*s)[:index] + return +} + +// node is an internal node in a tree. +// +// It must at all times maintain the invariant that either +// * len(children) == 0, len(items) unconstrained +// * len(children) == len(items) + 1 +type node struct { + items items + children children + t *BTree +} + +// split splits the given node at the given index. The current node shrinks, +// and this function returns the item that existed at that index and a new node +// containing all items/children after it. +func (n *node) split(i int) (Item, *node) { + item := n.items[i] + next := n.t.newNode() + next.items = append(next.items, n.items[i+1:]...) + n.items = n.items[:i] + if len(n.children) > 0 { + next.children = append(next.children, n.children[i+1:]...) + n.children = n.children[:i+1] + } + return item, next +} + +// maybeSplitChild checks if a child should be split, and if so splits it. +// Returns whether or not a split occurred. +func (n *node) maybeSplitChild(i, maxItems int) bool { + if len(n.children[i].items) < maxItems { + return false + } + first := n.children[i] + item, second := first.split(maxItems / 2) + n.items.insertAt(i, item) + n.children.insertAt(i+1, second) + return true +} + +// insert inserts an item into the subtree rooted at this node, making sure +// no nodes in the subtree exceed maxItems items. Should an equivalent item be +// be found/replaced by insert, it will be returned. +func (n *node) insert(item Item, maxItems int) Item { + i, found := n.items.find(item) + if found { + out := n.items[i] + n.items[i] = item + return out + } + if len(n.children) == 0 { + n.items.insertAt(i, item) + return nil + } + if n.maybeSplitChild(i, maxItems) { + inTree := n.items[i] + switch { + case item.Less(inTree): + // no change, we want first split node + case inTree.Less(item): + i++ // we want second split node + default: + out := n.items[i] + n.items[i] = item + return out + } + } + return n.children[i].insert(item, maxItems) +} + +// get finds the given key in the subtree and returns it. +func (n *node) get(key Item) Item { + i, found := n.items.find(key) + if found { + return n.items[i] + } else if len(n.children) > 0 { + return n.children[i].get(key) + } + return nil +} + +// toRemove details what item to remove in a node.remove call. +type toRemove int + +const ( + removeItem toRemove = iota // removes the given item + removeMin // removes smallest item in the subtree + removeMax // removes largest item in the subtree +) + +// remove removes an item from the subtree rooted at this node. +func (n *node) remove(item Item, minItems int, typ toRemove) Item { + var i int + var found bool + switch typ { + case removeMax: + if len(n.children) == 0 { + return n.items.pop() + } + i = len(n.items) + case removeMin: + if len(n.children) == 0 { + return n.items.removeAt(0) + } + i = 0 + case removeItem: + i, found = n.items.find(item) + if len(n.children) == 0 { + if found { + return n.items.removeAt(i) + } + return nil + } + default: + panic("invalid type") + } + // If we get to here, we have children. + child := n.children[i] + if len(child.items) <= minItems { + return n.growChildAndRemove(i, item, minItems, typ) + } + // Either we had enough items to begin with, or we've done some + // merging/stealing, because we've got enough now and we're ready to return + // stuff. + if found { + // The item exists at index 'i', and the child we've selected can give us a + // predecessor, since if we've gotten here it's got > minItems items in it. + out := n.items[i] + // We use our special-case 'remove' call with typ=maxItem to pull the + // predecessor of item i (the rightmost leaf of our immediate left child) + // and set it into where we pulled the item from. + n.items[i] = child.remove(nil, minItems, removeMax) + return out + } + // Final recursive call. Once we're here, we know that the item isn't in this + // node and that the child is big enough to remove from. + return child.remove(item, minItems, typ) +} + +// growChildAndRemove grows child 'i' to make sure it's possible to remove an +// item from it while keeping it at minItems, then calls remove to actually +// remove it. +// +// Most documentation says we have to do two sets of special casing: +// 1) item is in this node +// 2) item is in child +// In both cases, we need to handle the two subcases: +// A) node has enough values that it can spare one +// B) node doesn't have enough values +// For the latter, we have to check: +// a) left sibling has node to spare +// b) right sibling has node to spare +// c) we must merge +// To simplify our code here, we handle cases #1 and #2 the same: +// If a node doesn't have enough items, we make sure it does (using a,b,c). +// We then simply redo our remove call, and the second time (regardless of +// whether we're in case 1 or 2), we'll have enough items and can guarantee +// that we hit case A. +func (n *node) growChildAndRemove(i int, item Item, minItems int, typ toRemove) Item { + child := n.children[i] + if i > 0 && len(n.children[i-1].items) > minItems { + // Steal from left child + stealFrom := n.children[i-1] + stolenItem := stealFrom.items.pop() + child.items.insertAt(0, n.items[i-1]) + n.items[i-1] = stolenItem + if len(stealFrom.children) > 0 { + child.children.insertAt(0, stealFrom.children.pop()) + } + } else if i < len(n.items) && len(n.children[i+1].items) > minItems { + // steal from right child + stealFrom := n.children[i+1] + stolenItem := stealFrom.items.removeAt(0) + child.items = append(child.items, n.items[i]) + n.items[i] = stolenItem + if len(stealFrom.children) > 0 { + child.children = append(child.children, stealFrom.children.removeAt(0)) + } + } else { + if i >= len(n.items) { + i-- + child = n.children[i] + } + // merge with right child + mergeItem := n.items.removeAt(i) + mergeChild := n.children.removeAt(i + 1) + child.items = append(child.items, mergeItem) + child.items = append(child.items, mergeChild.items...) + child.children = append(child.children, mergeChild.children...) + n.t.freeNode(mergeChild) + } + return n.remove(item, minItems, typ) +} + +// iterate provides a simple method for iterating over elements in the tree. +// It could probably use some work to be extra-efficient (it calls from() a +// little more than it should), but it works pretty well for now. +// +// It requires that 'from' and 'to' both return true for values we should hit +// with the iterator. It should also be the case that 'from' returns true for +// values less than or equal to values 'to' returns true for, and 'to' +// returns true for values greater than or equal to those that 'from' +// does. +func (n *node) iterate(from, to func(Item) bool, iter ItemIterator) bool { + for i, item := range n.items { + if !from(item) { + continue + } + if len(n.children) > 0 && !n.children[i].iterate(from, to, iter) { + return false + } + if !to(item) { + return false + } + if !iter(item) { + return false + } + } + if len(n.children) > 0 { + return n.children[len(n.children)-1].iterate(from, to, iter) + } + return true +} + +// Used for testing/debugging purposes. +func (n *node) print(w io.Writer, level int) { + fmt.Fprintf(w, "%sNODE:%v\n", strings.Repeat(" ", level), n.items) + for _, c := range n.children { + c.print(w, level+1) + } +} + +// BTree is an implementation of a B-Tree. +// +// BTree stores Item instances in an ordered structure, allowing easy insertion, +// removal, and iteration. +// +// Write operations are not safe for concurrent mutation by multiple +// goroutines, but Read operations are. +type BTree struct { + degree int + length int + root *node + freelist []*node +} + +// maxItems returns the max number of items to allow per node. +func (t *BTree) maxItems() int { + return t.degree*2 - 1 +} + +// minItems returns the min number of items to allow per node (ignored for the +// root node). +func (t *BTree) minItems() int { + return t.degree - 1 +} + +func (t *BTree) newNode() (n *node) { + index := len(t.freelist) - 1 + if index < 0 { + return &node{t: t} + } + t.freelist, n = t.freelist[:index], t.freelist[index] + return +} + +func (t *BTree) freeNode(n *node) { + if len(t.freelist) < cap(t.freelist) { + for i := range n.items { + n.items[i] = nil // clear to allow GC + } + n.items = n.items[:0] + for i := range n.children { + n.children[i] = nil // clear to allow GC + } + n.children = n.children[:0] + t.freelist = append(t.freelist, n) + } +} + +// ReplaceOrInsert adds the given item to the tree. If an item in the tree +// already equals the given one, it is removed from the tree and returned. +// Otherwise, nil is returned. +// +// nil cannot be added to the tree (will panic). +func (t *BTree) ReplaceOrInsert(item Item) Item { + if item == nil { + panic("nil item being added to BTree") + } + if t.root == nil { + t.root = t.newNode() + t.root.items = append(t.root.items, item) + t.length++ + return nil + } else if len(t.root.items) >= t.maxItems() { + item2, second := t.root.split(t.maxItems() / 2) + oldroot := t.root + t.root = t.newNode() + t.root.items = append(t.root.items, item2) + t.root.children = append(t.root.children, oldroot, second) + } + out := t.root.insert(item, t.maxItems()) + if out == nil { + t.length++ + } + return out +} + +// Delete removes an item equal to the passed in item from the tree, returning +// it. If no such item exists, returns nil. +func (t *BTree) Delete(item Item) Item { + return t.deleteItem(item, removeItem) +} + +// DeleteMin removes the smallest item in the tree and returns it. +// If no such item exists, returns nil. +func (t *BTree) DeleteMin() Item { + return t.deleteItem(nil, removeMin) +} + +// DeleteMax removes the largest item in the tree and returns it. +// If no such item exists, returns nil. +func (t *BTree) DeleteMax() Item { + return t.deleteItem(nil, removeMax) +} + +func (t *BTree) deleteItem(item Item, typ toRemove) Item { + if t.root == nil || len(t.root.items) == 0 { + return nil + } + out := t.root.remove(item, t.minItems(), typ) + if len(t.root.items) == 0 && len(t.root.children) > 0 { + oldroot := t.root + t.root = t.root.children[0] + t.freeNode(oldroot) + } + if out != nil { + t.length-- + } + return out +} + +// AscendRange calls the iterator for every value in the tree within the range +// [greaterOrEqual, lessThan), until iterator returns false. +func (t *BTree) AscendRange(greaterOrEqual, lessThan Item, iterator ItemIterator) { + if t.root == nil { + return + } + t.root.iterate( + func(a Item) bool { return !a.Less(greaterOrEqual) }, + func(a Item) bool { return a.Less(lessThan) }, + iterator) +} + +// AscendLessThan calls the iterator for every value in the tree within the range +// [first, pivot), until iterator returns false. +func (t *BTree) AscendLessThan(pivot Item, iterator ItemIterator) { + if t.root == nil { + return + } + t.root.iterate( + func(a Item) bool { return true }, + func(a Item) bool { return a.Less(pivot) }, + iterator) +} + +// AscendGreaterOrEqual calls the iterator for every value in the tree within +// the range [pivot, last], until iterator returns false. +func (t *BTree) AscendGreaterOrEqual(pivot Item, iterator ItemIterator) { + if t.root == nil { + return + } + t.root.iterate( + func(a Item) bool { return !a.Less(pivot) }, + func(a Item) bool { return true }, + iterator) +} + +// Ascend calls the iterator for every value in the tree within the range +// [first, last], until iterator returns false. +func (t *BTree) Ascend(iterator ItemIterator) { + if t.root == nil { + return + } + t.root.iterate( + func(a Item) bool { return true }, + func(a Item) bool { return true }, + iterator) +} + +// Get looks for the key item in the tree, returning it. It returns nil if +// unable to find that item. +func (t *BTree) Get(key Item) Item { + if t.root == nil { + return nil + } + return t.root.get(key) +} + +// Has returns true if the given key is in the tree. +func (t *BTree) Has(key Item) bool { + return t.Get(key) != nil +} + +// Len returns the number of items currently in the tree. +func (t *BTree) Len() int { + return t.length +} + +// Int implements the Item interface for integers. +type Int int + +// Less returns true if int(a) < int(b). +func (a Int) Less(b Item) bool { + return a < b.(Int) +} diff --git a/Godeps/_workspace/src/github.com/google/btree/btree_mem.go b/Godeps/_workspace/src/github.com/google/btree/btree_mem.go new file mode 100644 index 0000000000..cb95b7fa1b --- /dev/null +++ b/Godeps/_workspace/src/github.com/google/btree/btree_mem.go @@ -0,0 +1,76 @@ +// Copyright 2014 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build ignore + +// This binary compares memory usage between btree and gollrb. +package main + +import ( + "flag" + "fmt" + "math/rand" + "runtime" + "time" + + "github.com/google/btree" + "github.com/petar/GoLLRB/llrb" +) + +var ( + size = flag.Int("size", 1000000, "size of the tree to build") + degree = flag.Int("degree", 8, "degree of btree") + gollrb = flag.Bool("llrb", false, "use llrb instead of btree") +) + +func main() { + flag.Parse() + vals := rand.Perm(*size) + var t, v interface{} + v = vals + var stats runtime.MemStats + for i := 0; i < 10; i++ { + runtime.GC() + } + fmt.Println("-------- BEFORE ----------") + runtime.ReadMemStats(&stats) + fmt.Printf("%+v\n", stats) + start := time.Now() + if *gollrb { + tr := llrb.New() + for _, v := range vals { + tr.ReplaceOrInsert(llrb.Int(v)) + } + t = tr // keep it around + } else { + tr := btree.New(*degree) + for _, v := range vals { + tr.ReplaceOrInsert(btree.Int(v)) + } + t = tr // keep it around + } + fmt.Printf("%v inserts in %v\n", *size, time.Since(start)) + fmt.Println("-------- AFTER ----------") + runtime.ReadMemStats(&stats) + fmt.Printf("%+v\n", stats) + for i := 0; i < 10; i++ { + runtime.GC() + } + fmt.Println("-------- AFTER GC ----------") + runtime.ReadMemStats(&stats) + fmt.Printf("%+v\n", stats) + if t == v { + fmt.Println("to make sure vals and tree aren't GC'd") + } +} diff --git a/Godeps/_workspace/src/github.com/petar/GoLLRB/llrb/avgvar.go b/Godeps/_workspace/src/github.com/petar/GoLLRB/llrb/avgvar.go deleted file mode 100644 index 2d7e2a3262..0000000000 --- a/Godeps/_workspace/src/github.com/petar/GoLLRB/llrb/avgvar.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2010 Petar Maymounkov. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package llrb - -import "math" - -// avgVar maintains the average and variance of a stream of numbers -// in a space-efficient manner. -type avgVar struct { - count int64 - sum, sumsq float64 -} - -func (av *avgVar) Init() { - av.count = 0 - av.sum = 0.0 - av.sumsq = 0.0 -} - -func (av *avgVar) Add(sample float64) { - av.count++ - av.sum += sample - av.sumsq += sample * sample -} - -func (av *avgVar) GetCount() int64 { return av.count } - -func (av *avgVar) GetAvg() float64 { return av.sum / float64(av.count) } - -func (av *avgVar) GetTotal() float64 { return av.sum } - -func (av *avgVar) GetVar() float64 { - a := av.GetAvg() - return av.sumsq/float64(av.count) - a*a -} - -func (av *avgVar) GetStdDev() float64 { return math.Sqrt(av.GetVar()) } diff --git a/Godeps/_workspace/src/github.com/petar/GoLLRB/llrb/iterator.go b/Godeps/_workspace/src/github.com/petar/GoLLRB/llrb/iterator.go deleted file mode 100644 index ee7b27f442..0000000000 --- a/Godeps/_workspace/src/github.com/petar/GoLLRB/llrb/iterator.go +++ /dev/null @@ -1,93 +0,0 @@ -package llrb - -type ItemIterator func(i Item) bool - -//func (t *Tree) Ascend(iterator ItemIterator) { -// t.AscendGreaterOrEqual(Inf(-1), iterator) -//} - -func (t *LLRB) AscendRange(greaterOrEqual, lessThan Item, iterator ItemIterator) { - t.ascendRange(t.root, greaterOrEqual, lessThan, iterator) -} - -func (t *LLRB) ascendRange(h *Node, inf, sup Item, iterator ItemIterator) bool { - if h == nil { - return true - } - if !less(h.Item, sup) { - return t.ascendRange(h.Left, inf, sup, iterator) - } - if less(h.Item, inf) { - return t.ascendRange(h.Right, inf, sup, iterator) - } - - if !t.ascendRange(h.Left, inf, sup, iterator) { - return false - } - if !iterator(h.Item) { - return false - } - return t.ascendRange(h.Right, inf, sup, iterator) -} - -// AscendGreaterOrEqual will call iterator once for each element greater or equal to -// pivot in ascending order. It will stop whenever the iterator returns false. -func (t *LLRB) AscendGreaterOrEqual(pivot Item, iterator ItemIterator) { - t.ascendGreaterOrEqual(t.root, pivot, iterator) -} - -func (t *LLRB) ascendGreaterOrEqual(h *Node, pivot Item, iterator ItemIterator) bool { - if h == nil { - return true - } - if !less(h.Item, pivot) { - if !t.ascendGreaterOrEqual(h.Left, pivot, iterator) { - return false - } - if !iterator(h.Item) { - return false - } - } - return t.ascendGreaterOrEqual(h.Right, pivot, iterator) -} - -func (t *LLRB) AscendLessThan(pivot Item, iterator ItemIterator) { - t.ascendLessThan(t.root, pivot, iterator) -} - -func (t *LLRB) ascendLessThan(h *Node, pivot Item, iterator ItemIterator) bool { - if h == nil { - return true - } - if !t.ascendLessThan(h.Left, pivot, iterator) { - return false - } - if !iterator(h.Item) { - return false - } - if less(h.Item, pivot) { - return t.ascendLessThan(h.Left, pivot, iterator) - } - return true -} - -// DescendLessOrEqual will call iterator once for each element less than the -// pivot in descending order. It will stop whenever the iterator returns false. -func (t *LLRB) DescendLessOrEqual(pivot Item, iterator ItemIterator) { - t.descendLessOrEqual(t.root, pivot, iterator) -} - -func (t *LLRB) descendLessOrEqual(h *Node, pivot Item, iterator ItemIterator) bool { - if h == nil { - return true - } - if less(h.Item, pivot) || !less(pivot, h.Item) { - if !t.descendLessOrEqual(h.Right, pivot, iterator) { - return false - } - if !iterator(h.Item) { - return false - } - } - return t.descendLessOrEqual(h.Left, pivot, iterator) -} diff --git a/Godeps/_workspace/src/github.com/petar/GoLLRB/llrb/llrb-stats.go b/Godeps/_workspace/src/github.com/petar/GoLLRB/llrb/llrb-stats.go deleted file mode 100644 index 47126a3be9..0000000000 --- a/Godeps/_workspace/src/github.com/petar/GoLLRB/llrb/llrb-stats.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2010 Petar Maymounkov. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package llrb - -// GetHeight() returns an item in the tree with key @key, and it's height in the tree -func (t *LLRB) GetHeight(key Item) (result Item, depth int) { - return t.getHeight(t.root, key) -} - -func (t *LLRB) getHeight(h *Node, item Item) (Item, int) { - if h == nil { - return nil, 0 - } - if less(item, h.Item) { - result, depth := t.getHeight(h.Left, item) - return result, depth + 1 - } - if less(h.Item, item) { - result, depth := t.getHeight(h.Right, item) - return result, depth + 1 - } - return h.Item, 0 -} - -// HeightStats() returns the average and standard deviation of the height -// of elements in the tree -func (t *LLRB) HeightStats() (avg, stddev float64) { - av := &avgVar{} - heightStats(t.root, 0, av) - return av.GetAvg(), av.GetStdDev() -} - -func heightStats(h *Node, d int, av *avgVar) { - if h == nil { - return - } - av.Add(float64(d)) - if h.Left != nil { - heightStats(h.Left, d+1, av) - } - if h.Right != nil { - heightStats(h.Right, d+1, av) - } -} diff --git a/Godeps/_workspace/src/github.com/petar/GoLLRB/llrb/llrb.go b/Godeps/_workspace/src/github.com/petar/GoLLRB/llrb/llrb.go deleted file mode 100644 index 81373fbfdf..0000000000 --- a/Godeps/_workspace/src/github.com/petar/GoLLRB/llrb/llrb.go +++ /dev/null @@ -1,456 +0,0 @@ -// Copyright 2010 Petar Maymounkov. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// A Left-Leaning Red-Black (LLRB) implementation of 2-3 balanced binary search trees, -// based on the following work: -// -// http://www.cs.princeton.edu/~rs/talks/LLRB/08Penn.pdf -// http://www.cs.princeton.edu/~rs/talks/LLRB/LLRB.pdf -// http://www.cs.princeton.edu/~rs/talks/LLRB/Java/RedBlackBST.java -// -// 2-3 trees (and the run-time equivalent 2-3-4 trees) are the de facto standard BST -// algoritms found in implementations of Python, Java, and other libraries. The LLRB -// implementation of 2-3 trees is a recent improvement on the traditional implementation, -// observed and documented by Robert Sedgewick. -// -package llrb - -// Tree is a Left-Leaning Red-Black (LLRB) implementation of 2-3 trees -type LLRB struct { - count int - root *Node -} - -type Node struct { - Item - Left, Right *Node // Pointers to left and right child nodes - Black bool // If set, the color of the link (incoming from the parent) is black - // In the LLRB, new nodes are always red, hence the zero-value for node -} - -type Item interface { - Less(than Item) bool -} - -// -func less(x, y Item) bool { - if x == pinf { - return false - } - if x == ninf { - return true - } - return x.Less(y) -} - -// Inf returns an Item that is "bigger than" any other item, if sign is positive. -// Otherwise it returns an Item that is "smaller than" any other item. -func Inf(sign int) Item { - if sign == 0 { - panic("sign") - } - if sign > 0 { - return pinf - } - return ninf -} - -var ( - ninf = nInf{} - pinf = pInf{} -) - -type nInf struct{} - -func (nInf) Less(Item) bool { - return true -} - -type pInf struct{} - -func (pInf) Less(Item) bool { - return false -} - -// New() allocates a new tree -func New() *LLRB { - return &LLRB{} -} - -// SetRoot sets the root node of the tree. -// It is intended to be used by functions that deserialize the tree. -func (t *LLRB) SetRoot(r *Node) { - t.root = r -} - -// Root returns the root node of the tree. -// It is intended to be used by functions that serialize the tree. -func (t *LLRB) Root() *Node { - return t.root -} - -// Len returns the number of nodes in the tree. -func (t *LLRB) Len() int { return t.count } - -// Has returns true if the tree contains an element whose order is the same as that of key. -func (t *LLRB) Has(key Item) bool { - return t.Get(key) != nil -} - -// Get retrieves an element from the tree whose order is the same as that of key. -func (t *LLRB) Get(key Item) Item { - h := t.root - for h != nil { - switch { - case less(key, h.Item): - h = h.Left - case less(h.Item, key): - h = h.Right - default: - return h.Item - } - } - return nil -} - -// Min returns the minimum element in the tree. -func (t *LLRB) Min() Item { - h := t.root - if h == nil { - return nil - } - for h.Left != nil { - h = h.Left - } - return h.Item -} - -// Max returns the maximum element in the tree. -func (t *LLRB) Max() Item { - h := t.root - if h == nil { - return nil - } - for h.Right != nil { - h = h.Right - } - return h.Item -} - -func (t *LLRB) ReplaceOrInsertBulk(items ...Item) { - for _, i := range items { - t.ReplaceOrInsert(i) - } -} - -func (t *LLRB) InsertNoReplaceBulk(items ...Item) { - for _, i := range items { - t.InsertNoReplace(i) - } -} - -// ReplaceOrInsert inserts item into the tree. If an existing -// element has the same order, it is removed from the tree and returned. -func (t *LLRB) ReplaceOrInsert(item Item) Item { - if item == nil { - panic("inserting nil item") - } - var replaced Item - t.root, replaced = t.replaceOrInsert(t.root, item) - t.root.Black = true - if replaced == nil { - t.count++ - } - return replaced -} - -func (t *LLRB) replaceOrInsert(h *Node, item Item) (*Node, Item) { - if h == nil { - return newNode(item), nil - } - - h = walkDownRot23(h) - - var replaced Item - if less(item, h.Item) { // BUG - h.Left, replaced = t.replaceOrInsert(h.Left, item) - } else if less(h.Item, item) { - h.Right, replaced = t.replaceOrInsert(h.Right, item) - } else { - replaced, h.Item = h.Item, item - } - - h = walkUpRot23(h) - - return h, replaced -} - -// InsertNoReplace inserts item into the tree. If an existing -// element has the same order, both elements remain in the tree. -func (t *LLRB) InsertNoReplace(item Item) { - if item == nil { - panic("inserting nil item") - } - t.root = t.insertNoReplace(t.root, item) - t.root.Black = true - t.count++ -} - -func (t *LLRB) insertNoReplace(h *Node, item Item) *Node { - if h == nil { - return newNode(item) - } - - h = walkDownRot23(h) - - if less(item, h.Item) { - h.Left = t.insertNoReplace(h.Left, item) - } else { - h.Right = t.insertNoReplace(h.Right, item) - } - - return walkUpRot23(h) -} - -// Rotation driver routines for 2-3 algorithm - -func walkDownRot23(h *Node) *Node { return h } - -func walkUpRot23(h *Node) *Node { - if isRed(h.Right) && !isRed(h.Left) { - h = rotateLeft(h) - } - - if isRed(h.Left) && isRed(h.Left.Left) { - h = rotateRight(h) - } - - if isRed(h.Left) && isRed(h.Right) { - flip(h) - } - - return h -} - -// Rotation driver routines for 2-3-4 algorithm - -func walkDownRot234(h *Node) *Node { - if isRed(h.Left) && isRed(h.Right) { - flip(h) - } - - return h -} - -func walkUpRot234(h *Node) *Node { - if isRed(h.Right) && !isRed(h.Left) { - h = rotateLeft(h) - } - - if isRed(h.Left) && isRed(h.Left.Left) { - h = rotateRight(h) - } - - return h -} - -// DeleteMin deletes the minimum element in the tree and returns the -// deleted item or nil otherwise. -func (t *LLRB) DeleteMin() Item { - var deleted Item - t.root, deleted = deleteMin(t.root) - if t.root != nil { - t.root.Black = true - } - if deleted != nil { - t.count-- - } - return deleted -} - -// deleteMin code for LLRB 2-3 trees -func deleteMin(h *Node) (*Node, Item) { - if h == nil { - return nil, nil - } - if h.Left == nil { - return nil, h.Item - } - - if !isRed(h.Left) && !isRed(h.Left.Left) { - h = moveRedLeft(h) - } - - var deleted Item - h.Left, deleted = deleteMin(h.Left) - - return fixUp(h), deleted -} - -// DeleteMax deletes the maximum element in the tree and returns -// the deleted item or nil otherwise -func (t *LLRB) DeleteMax() Item { - var deleted Item - t.root, deleted = deleteMax(t.root) - if t.root != nil { - t.root.Black = true - } - if deleted != nil { - t.count-- - } - return deleted -} - -func deleteMax(h *Node) (*Node, Item) { - if h == nil { - return nil, nil - } - if isRed(h.Left) { - h = rotateRight(h) - } - if h.Right == nil { - return nil, h.Item - } - if !isRed(h.Right) && !isRed(h.Right.Left) { - h = moveRedRight(h) - } - var deleted Item - h.Right, deleted = deleteMax(h.Right) - - return fixUp(h), deleted -} - -// Delete deletes an item from the tree whose key equals key. -// The deleted item is return, otherwise nil is returned. -func (t *LLRB) Delete(key Item) Item { - var deleted Item - t.root, deleted = t.delete(t.root, key) - if t.root != nil { - t.root.Black = true - } - if deleted != nil { - t.count-- - } - return deleted -} - -func (t *LLRB) delete(h *Node, item Item) (*Node, Item) { - var deleted Item - if h == nil { - return nil, nil - } - if less(item, h.Item) { - if h.Left == nil { // item not present. Nothing to delete - return h, nil - } - if !isRed(h.Left) && !isRed(h.Left.Left) { - h = moveRedLeft(h) - } - h.Left, deleted = t.delete(h.Left, item) - } else { - if isRed(h.Left) { - h = rotateRight(h) - } - // If @item equals @h.Item and no right children at @h - if !less(h.Item, item) && h.Right == nil { - return nil, h.Item - } - // PETAR: Added 'h.Right != nil' below - if h.Right != nil && !isRed(h.Right) && !isRed(h.Right.Left) { - h = moveRedRight(h) - } - // If @item equals @h.Item, and (from above) 'h.Right != nil' - if !less(h.Item, item) { - var subDeleted Item - h.Right, subDeleted = deleteMin(h.Right) - if subDeleted == nil { - panic("logic") - } - deleted, h.Item = h.Item, subDeleted - } else { // Else, @item is bigger than @h.Item - h.Right, deleted = t.delete(h.Right, item) - } - } - - return fixUp(h), deleted -} - -// Internal node manipulation routines - -func newNode(item Item) *Node { return &Node{Item: item} } - -func isRed(h *Node) bool { - if h == nil { - return false - } - return !h.Black -} - -func rotateLeft(h *Node) *Node { - x := h.Right - if x.Black { - panic("rotating a black link") - } - h.Right = x.Left - x.Left = h - x.Black = h.Black - h.Black = false - return x -} - -func rotateRight(h *Node) *Node { - x := h.Left - if x.Black { - panic("rotating a black link") - } - h.Left = x.Right - x.Right = h - x.Black = h.Black - h.Black = false - return x -} - -// REQUIRE: Left and Right children must be present -func flip(h *Node) { - h.Black = !h.Black - h.Left.Black = !h.Left.Black - h.Right.Black = !h.Right.Black -} - -// REQUIRE: Left and Right children must be present -func moveRedLeft(h *Node) *Node { - flip(h) - if isRed(h.Right.Left) { - h.Right = rotateRight(h.Right) - h = rotateLeft(h) - flip(h) - } - return h -} - -// REQUIRE: Left and Right children must be present -func moveRedRight(h *Node) *Node { - flip(h) - if isRed(h.Left.Left) { - h = rotateRight(h) - flip(h) - } - return h -} - -func fixUp(h *Node) *Node { - if isRed(h.Right) { - h = rotateLeft(h) - } - - if isRed(h.Left) && isRed(h.Left.Left) { - h = rotateRight(h) - } - - if isRed(h.Left) && isRed(h.Right) { - flip(h) - } - - return h -} diff --git a/Godeps/_workspace/src/github.com/petar/GoLLRB/llrb/util.go b/Godeps/_workspace/src/github.com/petar/GoLLRB/llrb/util.go deleted file mode 100644 index 63dbdb2df0..0000000000 --- a/Godeps/_workspace/src/github.com/petar/GoLLRB/llrb/util.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2010 Petar Maymounkov. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package llrb - -type Int int - -func (x Int) Less(than Item) bool { - return x < than.(Int) -} - -type String string - -func (x String) Less(than Item) bool { - return x < than.(String) -} diff --git a/Godeps/_workspace/src/github.com/peterbourgon/diskv/index.go b/Godeps/_workspace/src/github.com/peterbourgon/diskv/index.go index 1481b2c763..96fee5152b 100644 --- a/Godeps/_workspace/src/github.com/peterbourgon/diskv/index.go +++ b/Godeps/_workspace/src/github.com/peterbourgon/diskv/index.go @@ -3,7 +3,7 @@ package diskv import ( "sync" - "github.com/petar/GoLLRB/llrb" + "github.com/google/btree" ) // Index is a generic interface for things that can @@ -18,85 +18,84 @@ type Index interface { // LessFunction is used to initialize an Index of keys in a specific order. type LessFunction func(string, string) bool -// llrbString is a custom data type that satisfies the LLRB Less interface, -// making the strings it wraps sortable by the LLRB package. -type llrbString struct { +// btreeString is a custom data type that satisfies the BTree Less interface, +// making the strings it wraps sortable by the BTree package. +type btreeString struct { s string l LessFunction } -// Less satisfies the llrb.Less interface using the llrbString's LessFunction. -func (s llrbString) Less(i llrb.Item) bool { - return s.l(s.s, i.(llrbString).s) +// Less satisfies the BTree.Less interface using the btreeString's LessFunction. +func (s btreeString) Less(i btree.Item) bool { + return s.l(s.s, i.(btreeString).s) } -// LLRBIndex is an implementation of the Index interface -// using Petar Maymounkov's LLRB tree. -type LLRBIndex struct { +// BTreeIndex is an implementation of the Index interface using google/btree. +type BTreeIndex struct { sync.RWMutex LessFunction - *llrb.LLRB + *btree.BTree } -// Initialize populates the LLRB tree with data from the keys channel, -// according to the passed less function. It's destructive to the LLRBIndex. -func (i *LLRBIndex) Initialize(less LessFunction, keys <-chan string) { +// Initialize populates the BTree tree with data from the keys channel, +// according to the passed less function. It's destructive to the BTreeIndex. +func (i *BTreeIndex) Initialize(less LessFunction, keys <-chan string) { i.Lock() defer i.Unlock() i.LessFunction = less - i.LLRB = rebuild(less, keys) + i.BTree = rebuild(less, keys) } -// Insert inserts the given key (only) into the LLRB tree. -func (i *LLRBIndex) Insert(key string) { +// Insert inserts the given key (only) into the BTree tree. +func (i *BTreeIndex) Insert(key string) { i.Lock() defer i.Unlock() - if i.LLRB == nil || i.LessFunction == nil { + if i.BTree == nil || i.LessFunction == nil { panic("uninitialized index") } - i.LLRB.ReplaceOrInsert(llrbString{s: key, l: i.LessFunction}) + i.BTree.ReplaceOrInsert(btreeString{s: key, l: i.LessFunction}) } -// Delete removes the given key (only) from the LLRB tree. -func (i *LLRBIndex) Delete(key string) { +// Delete removes the given key (only) from the BTree tree. +func (i *BTreeIndex) Delete(key string) { i.Lock() defer i.Unlock() - if i.LLRB == nil || i.LessFunction == nil { + if i.BTree == nil || i.LessFunction == nil { panic("uninitialized index") } - i.LLRB.Delete(llrbString{s: key, l: i.LessFunction}) + i.BTree.Delete(btreeString{s: key, l: i.LessFunction}) } // Keys yields a maximum of n keys in order. If the passed 'from' key is empty, // Keys will return the first n keys. If the passed 'from' key is non-empty, the // first key in the returned slice will be the key that immediately follows the // passed key, in key order. -func (i *LLRBIndex) Keys(from string, n int) []string { +func (i *BTreeIndex) Keys(from string, n int) []string { i.RLock() defer i.RUnlock() - if i.LLRB == nil || i.LessFunction == nil { + if i.BTree == nil || i.LessFunction == nil { panic("uninitialized index") } - if i.LLRB.Len() <= 0 { + if i.BTree.Len() <= 0 { return []string{} } - llrbFrom := llrbString{s: from, l: i.LessFunction} + btreeFrom := btreeString{s: from, l: i.LessFunction} skipFirst := true - if len(from) <= 0 || !i.LLRB.Has(llrbFrom) { - // no such key, so start at the top - llrbFrom = i.LLRB.Min().(llrbString) + if len(from) <= 0 || !i.BTree.Has(btreeFrom) { + // no such key, so fabricate an always-smallest item + btreeFrom = btreeString{s: "", l: func(string, string) bool { return true }} skipFirst = false } keys := []string{} - iterator := func(i llrb.Item) bool { - keys = append(keys, i.(llrbString).s) + iterator := func(i btree.Item) bool { + keys = append(keys, i.(btreeString).s) return len(keys) < n } - i.LLRB.AscendGreaterOrEqual(llrbFrom, iterator) + i.BTree.AscendGreaterOrEqual(btreeFrom, iterator) if skipFirst && len(keys) > 0 { keys = keys[1:] @@ -107,10 +106,10 @@ func (i *LLRBIndex) Keys(from string, n int) []string { // rebuildIndex does the work of regenerating the index // with the given keys. -func rebuild(less LessFunction, keys <-chan string) *llrb.LLRB { - tree := llrb.New() +func rebuild(less LessFunction, keys <-chan string) *btree.BTree { + tree := btree.New(2) for key := range keys { - tree.ReplaceOrInsert(llrbString{s: key, l: less}) + tree.ReplaceOrInsert(btreeString{s: key, l: less}) } return tree } From 7bd0dfca044d62d39998f92c3aa7641d3a77fc2e Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Thu, 31 Mar 2016 15:55:08 +0200 Subject: [PATCH 0056/1304] pubkey: simplify the code Just assume that DefaultTransport _is_ an *http.Transport behind the RoundTripper interface. If this is not true in future, we can adapt. --- rkt/pubkey/pubkey.go | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/rkt/pubkey/pubkey.go b/rkt/pubkey/pubkey.go index 000dec8c53..006954b44c 100644 --- a/rkt/pubkey/pubkey.go +++ b/rkt/pubkey/pubkey.go @@ -21,12 +21,10 @@ import ( "fmt" "io" "io/ioutil" - "net" "net/http" "net/url" "os" "strings" - "time" "github.com/coreos/rkt/pkg/keystore" rktlog "github.com/coreos/rkt/pkg/log" @@ -240,28 +238,16 @@ func getClient(skipTLSCheck bool) *http.Client { return http.DefaultClient } client := *http.DefaultClient - var tr *http.Transport - // default transport is hidden behind the RoundTripper - // interface, so we can't easily make a copy of it - if transport, ok := http.DefaultTransport.(*http.Transport); ok { - trCopy := *transport - tr = &trCopy - } else { - // meh, an already outdated copy from golang's - // net/http DefaultTransport defintion, without the - // ExpectContinueTimeout field set, because it exists - // only in go1.6 - tr = &http.Transport{ - Proxy: http.ProxyFromEnvironment, - Dial: (&net.Dialer{ - Timeout: 30 * time.Second, - KeepAlive: 30 * time.Second, - }).Dial, - TLSHandshakeTimeout: 10 * time.Second, - } + // Default transport is hidden behind the RoundTripper + // interface, so we can't easily make a copy of it. If this + // ever panics, we will have to adapt. + realTransport := http.DefaultTransport.(*http.Transport) + tr := *realTransport + if tr.TLSClientConfig == nil { + tr.TLSClientConfig = &tls.Config{} } - tr.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} - client.Transport = tr + tr.TLSClientConfig.InsecureSkipVerify = true + client.Transport = &tr return &client } From d16d80123e4435c9542ff1207137ee360ab44541 Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Thu, 31 Mar 2016 18:53:46 +0200 Subject: [PATCH 0057/1304] README: add known issue about overlayfs+selinux --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b38c809df0..a4fbf4049a 100644 --- a/README.md +++ b/README.md @@ -82,4 +82,6 @@ Due to a bug in the Linux kernel, using rkt's overlay support on top of an overl Due to a bug in the Linux kernel, rkt will not work when /var/lib/rkt is on btrfs ([#2175](https://github.com/coreos/rkt/issues/2175)). +Due to a bug in the Linux kernel, using rkt's overlay support in conjunction with SELinux requires a set of patches that are only currently available on some Linux distributions (for example, [CoreOS Linux](https://github.com/coreos/coreos-overlay/tree/master/sys-kernel/coreos-sources/files/4.4)). Work is ongoing to merge this work into the mainline Linux kernel ([#1727](https://github.com/coreos/rkt/issues/1727#issuecomment-173203129)). + Linux 3.18+ is required to successfully garbage collect rkt pods when system services such as udevd are in a slave mount namespace (see [lazy umounts on unlinked files and directories](https://github.com/torvalds/linux/commit/8ed936b) and [#1922](https://github.com/coreos/rkt/issues/1922)). From cabcf866da75b37242d6a55eba65973e2ad11396 Mon Sep 17 00:00:00 2001 From: 0xbzho <0xbzho@gmail.com> Date: Fri, 1 Apr 2016 09:14:10 +0100 Subject: [PATCH 0058/1304] Fix broken links in networking docs --- Documentation/networking/overview.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/networking/overview.md b/Documentation/networking/overview.md index 384ce333c5..964aff3941 100644 --- a/Documentation/networking/overview.md +++ b/Documentation/networking/overview.md @@ -1,10 +1,10 @@ # Networking -On some of rkt's subcommands *([run](subcommands/run.md), [run-prepared](subcommands/run-prepared.md))*, the `--net` flag allows you to configure the pod's network. +On some of rkt's subcommands *([run](../subcommands/run.md), [run-prepared](../subcommands/run-prepared.md))*, the `--net` flag allows you to configure the pod's network. The various options can be grouped by two categories: -* [host mode](#host mode) -* [contained mode (default)](#contained mode) +* [host mode](#host-mode) +* [contained mode (default)](#contained-mode) This document gives a brief overview of the supported plugins. More examples and advanced topics are linked in the [more docs](#more-docs) section. @@ -333,7 +333,7 @@ The pod's TCP port 80 can be mapped to an arbitrary port on the host during rkt Now, any traffic arriving on host's TCP port 8888 will be forwarded to the pod on port 80. rkt also supports socket activation. -This is documented in [Socket-activated service](using-rkt-with-systemd.md#socket-activated-service). +This is documented in [Socket-activated service](../using-rkt-with-systemd.md#socket-activated-service). ## More Docs From e1523587fd3e9ebedee16b9d3bf7fcb0adce2148 Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Fri, 1 Apr 2016 10:28:13 +0200 Subject: [PATCH 0059/1304] deps: bump go-iptables to v0.1.0 --- Godeps/Godeps.json | 3 +- .../coreos/go-iptables/iptables/iptables.go | 141 +++++++++++------- .../coreos/go-iptables/iptables/lock.go | 84 +++++++++++ 3 files changed, 176 insertions(+), 52 deletions(-) create mode 100644 Godeps/_workspace/src/github.com/coreos/go-iptables/iptables/lock.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 8e30ea4b2e..a5629f8561 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -221,7 +221,8 @@ }, { "ImportPath": "github.com/coreos/go-iptables/iptables", - "Rev": "74b0926558061d3a23824e9c18c9cf9c1b9c11f4" + "Comment": "v0.1.0", + "Rev": "fbb73372b87f6e89951c2b6b31470c2c9d5cfae3" }, { "ImportPath": "github.com/coreos/go-semver/semver", diff --git a/Godeps/_workspace/src/github.com/coreos/go-iptables/iptables/iptables.go b/Godeps/_workspace/src/github.com/coreos/go-iptables/iptables/iptables.go index 4d8db73ab4..4b2f2f2f4b 100644 --- a/Godeps/_workspace/src/github.com/coreos/go-iptables/iptables/iptables.go +++ b/Godeps/_workspace/src/github.com/coreos/go-iptables/iptables/iptables.go @@ -17,7 +17,7 @@ package iptables import ( "bytes" "fmt" - "log" + "io" "os/exec" "regexp" "strconv" @@ -40,7 +40,9 @@ func (e *Error) Error() string { } type IPTables struct { - path string + path string + hasCheck bool + hasWait bool } func New() (*IPTables, error) { @@ -48,33 +50,34 @@ func New() (*IPTables, error) { if err != nil { return nil, err } - - return &IPTables{path}, nil + checkPresent, waitPresent, err := getIptablesCommandSupport() + if err != nil { + return nil, fmt.Errorf("error checking iptables version: %v", err) + } + ipt := IPTables{ + path: path, + hasCheck: checkPresent, + hasWait: waitPresent, + } + return &ipt, nil } // Exists checks if given rulespec in specified table/chain exists func (ipt *IPTables) Exists(table, chain string, rulespec ...string) (bool, error) { - checkPresent, err := getIptablesHasCheckCommand() - if err != nil { - log.Printf("Error checking iptables version, assuming version at least 1.4.11: %v", err) - checkPresent = true - } + if !ipt.hasCheck { + return ipt.existsForOldIptables(table, chain, rulespec) - if !checkPresent { - cmd := append([]string{"-A", chain}, rulespec...) - return existsForOldIpTables(table, strings.Join(cmd, " ")) - } else { - cmd := append([]string{"-t", table, "-C", chain}, rulespec...) - err := ipt.run(cmd...) - - switch { - case err == nil: - return true, nil - case err.(*Error).ExitStatus() == 1: - return false, nil - default: - return false, err - } + } + cmd := append([]string{"-t", table, "-C", chain}, rulespec...) + err := ipt.run(cmd...) + eerr, eok := err.(*Error) + switch { + case err == nil: + return true, nil + case eok && eerr.ExitStatus() == 1: + return false, nil + default: + return false, err } } @@ -112,16 +115,10 @@ func (ipt *IPTables) Delete(table, chain string, rulespec ...string) error { // List rules in specified table/chain func (ipt *IPTables) List(table, chain string) ([]string, error) { - var stdout, stderr bytes.Buffer - cmd := exec.Cmd{ - Path: ipt.path, - Args: []string{ipt.path, "--wait", "-t", table, "-S", chain}, - Stdout: &stdout, - Stderr: &stderr, - } - - if err := cmd.Run(); err != nil { - return nil, &Error{*(err.(*exec.ExitError)), stderr.String()} + args := []string{"-t", table, "-S", chain} + var stdout bytes.Buffer + if err := ipt.runWithOutput(args, &stdout); err != nil { + return nil, err } rules := strings.Split(stdout.String(), "\n") @@ -136,15 +133,16 @@ func (ipt *IPTables) NewChain(table, chain string) error { return ipt.run("-t", table, "-N", chain) } -// ClearChain flushed (deletes all rules) in the specifed table/chain. -// If the chain does not exist, new one will be created +// ClearChain flushed (deletes all rules) in the specified table/chain. +// If the chain does not exist, a new one will be created func (ipt *IPTables) ClearChain(table, chain string) error { err := ipt.NewChain(table, chain) + eerr, eok := err.(*Error) switch { case err == nil: return nil - case err.(*Error).ExitStatus() == 1: + case eok && eerr.ExitStatus() == 1: // chain already exists. Flush (clear) it. return ipt.run("-t", table, "-F", chain) default: @@ -152,18 +150,46 @@ func (ipt *IPTables) ClearChain(table, chain string) error { } } +// RenameChain renames the old chain to the new one. +func (ipt *IPTables) RenameChain(table, oldChain, newChain string) error { + return ipt.run("-t", table, "-E", oldChain, newChain) +} + // DeleteChain deletes the chain in the specified table. // The chain must be empty func (ipt *IPTables) DeleteChain(table, chain string) error { return ipt.run("-t", table, "-X", chain) } +// run runs an iptables command with the given arguments, ignoring +// any stdout output func (ipt *IPTables) run(args ...string) error { + return ipt.runWithOutput(args, nil) +} + +// runWithOutput runs an iptables command with the given arguments, +// writing any stdout output to the given writer +func (ipt *IPTables) runWithOutput(args []string, stdout io.Writer) error { + args = append([]string{ipt.path}, args...) + if ipt.hasWait { + args = append(args, "--wait") + } else { + fmu, err := newXtablesFileLock() + if err != nil { + return err + } + ul, err := fmu.tryLock() + if err != nil { + return err + } + defer ul.Unlock() + } + var stderr bytes.Buffer - args = append([]string{"--wait"}, args...) cmd := exec.Cmd{ Path: ipt.path, - Args: append([]string{ipt.path}, args...), + Args: args, + Stdout: stdout, Stderr: &stderr, } @@ -174,19 +200,19 @@ func (ipt *IPTables) run(args ...string) error { return nil } -// Checks if iptables has the "-C" flag -func getIptablesHasCheckCommand() (bool, error) { +// Checks if iptables has the "-C" and "--wait" flag +func getIptablesCommandSupport() (bool, bool, error) { vstring, err := getIptablesVersionString() if err != nil { - return false, err + return false, false, err } v1, v2, v3, err := extractIptablesVersion(vstring) if err != nil { - return false, err + return false, false, err } - return iptablesHasCheckCommand(v1, v2, v3), nil + return iptablesHasCheckCommand(v1, v2, v3), iptablesHasWaitCommand(v1, v2, v3), nil } // getIptablesVersion returns the first three components of the iptables version. @@ -242,15 +268,28 @@ func iptablesHasCheckCommand(v1 int, v2 int, v3 int) bool { return false } +// Checks if an iptables version is after 1.4.20, when --wait was added +func iptablesHasWaitCommand(v1 int, v2 int, v3 int) bool { + if v1 > 1 { + return true + } + if v1 == 1 && v2 > 4 { + return true + } + if v1 == 1 && v2 == 4 && v3 >= 20 { + return true + } + return false +} + // Checks if a rule specification exists for a table -func existsForOldIpTables(table string, ruleSpec string) (bool, error) { - cmd := exec.Command("iptables", "-t", table, "-S") - var out bytes.Buffer - cmd.Stdout = &out - err := cmd.Run() +func (ipt *IPTables) existsForOldIptables(table, chain string, rulespec []string) (bool, error) { + rs := strings.Join(append([]string{"-A", chain}, rulespec...), " ") + args := []string{"-t", table, "-S"} + var stdout bytes.Buffer + err := ipt.runWithOutput(args, &stdout) if err != nil { return false, err } - rules := out.String() - return strings.Contains(rules, ruleSpec), nil + return strings.Contains(stdout.String(), rs), nil } diff --git a/Godeps/_workspace/src/github.com/coreos/go-iptables/iptables/lock.go b/Godeps/_workspace/src/github.com/coreos/go-iptables/iptables/lock.go new file mode 100644 index 0000000000..a88e92b4e4 --- /dev/null +++ b/Godeps/_workspace/src/github.com/coreos/go-iptables/iptables/lock.go @@ -0,0 +1,84 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package iptables + +import ( + "os" + "sync" + "syscall" +) + +const ( + // In earlier versions of iptables, the xtables lock was implemented + // via a Unix socket, but now flock is used via this lockfile: + // http://git.netfilter.org/iptables/commit/?id=aa562a660d1555b13cffbac1e744033e91f82707 + // Note the LSB-conforming "/run" directory does not exist on old + // distributions, so assume "/var" is symlinked + xtablesLockFilePath = "/var/run/xtables.lock" + + defaultFilePerm = 0600 +) + +type Unlocker interface { + Unlock() error +} + +type nopUnlocker struct{} + +func (_ nopUnlocker) Unlock() error { return nil } + +type fileLock struct { + // mu is used to protect against concurrent invocations from within this process + mu sync.Mutex + fd int +} + +// tryLock takes an exclusive lock on the xtables lock file without blocking. +// This is best-effort only: if the exclusive lock would block (i.e. because +// another process already holds it), no error is returned. Otherwise, any +// error encountered during the locking operation is returned. +// The returned Unlocker should be used to release the lock when the caller is +// done invoking iptables commands. +func (l *fileLock) tryLock() (Unlocker, error) { + l.mu.Lock() + err := syscall.Flock(l.fd, syscall.LOCK_EX|syscall.LOCK_NB) + switch err { + case syscall.EWOULDBLOCK: + l.mu.Unlock() + return nopUnlocker{}, nil + case nil: + return l, nil + default: + l.mu.Unlock() + return nil, err + } +} + +// Unlock closes the underlying file, which implicitly unlocks it as well. It +// also unlocks the associated mutex. +func (l *fileLock) Unlock() error { + defer l.mu.Unlock() + return syscall.Close(l.fd) +} + +// newXtablesFileLock opens a new lock on the xtables lockfile without +// acquiring the lock +func newXtablesFileLock() (*fileLock, error) { + fd, err := syscall.Open(xtablesLockFilePath, os.O_CREATE, defaultFilePerm) + if err != nil { + return nil, err + } + return &fileLock{fd: fd}, nil +} From fd4d49b6e59b8ca08e001ec7a5c3f774e01ea31d Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Fri, 1 Apr 2016 11:09:42 +0200 Subject: [PATCH 0060/1304] test: TestAPIServiceCgroup: increase timeout A timeout of 10 seconds is not enough for slow machines. https://github.com/coreos/rkt/issues/2357 --- tests/rkt_api_service_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/rkt_api_service_test.go b/tests/rkt_api_service_test.go index d3dd9244bd..40606513eb 100644 --- a/tests/rkt_api_service_test.go +++ b/tests/rkt_api_service_test.go @@ -467,7 +467,7 @@ func TestAPIServiceCgroup(t *testing.T) { } }() - testutils.WaitOrTimeout(t, time.Second*10, done) + testutils.WaitOrTimeout(t, time.Second*30, done) var cgroups []string From 443073354c7d2bb40a3f69d520f4f45f69f2f31d Mon Sep 17 00:00:00 2001 From: Josh Wood Date: Fri, 1 Apr 2016 01:27:38 -0700 Subject: [PATCH 0061/1304] Doc/subcmd/run: Add docker port name convention Update link to contained network doc#heading. Ref #2113. --- Documentation/subcommands/run.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/subcommands/run.md b/Documentation/subcommands/run.md index 411863880d..613ea9f28c 100644 --- a/Documentation/subcommands/run.md +++ b/Documentation/subcommands/run.md @@ -342,7 +342,7 @@ For more details see the [hacking documentation](../hacking.md). | `--no-overlay` | `false` | `true` or `false` | Disable overlay filesystem | | `--no-store` | `false` | `true` or `false` | Fetch images, ignoring the local store. See [image fetching behavior](../image-fetching-behavior.md) | | `--pod-manifest` | `` | A path | The path to the pod manifest. If it's non-empty, then only `--net`, `--no-overlay` and `--interactive` will have effect | -| `--port` | `` | A port number | Ports to expose on the host (requires [contained network](https://github.com/coreos/rkt/blob/master/Documentation/networking.md#contained-mode)). Syntax: --port=NAME:HOSTPORT | +| `--port` | `` | A port number | Ports to expose on the host (requires [contained network](https://github.com/coreos/rkt/blob/master/Documentation/networking/overview.md#contained-mode)). Syntax: `--port=NAME:HOSTPORT` The NAME is that given in the ACI. By convention, Docker containers' EXPOSEd ports are given a name formed from the port number, a hyphen, and the protocol, e.g., `80-tcp`, giving something like `--port=80-tcp:8080` | | `--private-users` | `false` | `true` or `false` | Run within user namespaces (experimental) | | `--set-env` | `` | An environment variable. Syntax `NAME=VALUE` | An environment variable to set for apps | | `--signature` | `` | A file path | Local signature file to use in validating the preceding image | From 37df88e7b13ec8e8779d66d9ee932378812c4d94 Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Fri, 1 Apr 2016 12:27:08 +0200 Subject: [PATCH 0062/1304] Godeps: bump coreos/go-tspi to v0.1.1 --- Godeps/Godeps.json | 21 +- .../coreos/go-tspi/tpmclient/tpmclient.go | 104 +++- .../github.com/coreos/go-tspi/tspi/context.go | 107 ---- .../github.com/coreos/go-tspi/tspi/hash.go | 38 -- .../src/github.com/coreos/go-tspi/tspi/key.go | 75 --- .../src/github.com/coreos/go-tspi/tspi/nv.go | 44 -- .../github.com/coreos/go-tspi/tspi/pcrs.go | 61 --- .../github.com/coreos/go-tspi/tspi/policy.go | 31 -- .../src/github.com/coreos/go-tspi/tspi/tpm.go | 189 ------- .../{tspi/tspi.go => tspiconst/tspiconst.go} | 461 +----------------- .../verification.go} | 234 ++------- 11 files changed, 151 insertions(+), 1214 deletions(-) delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/context.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/hash.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/key.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/nv.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/pcrs.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/policy.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/tpm.go rename Godeps/_workspace/src/github.com/coreos/go-tspi/{tspi/tspi.go => tspiconst/tspiconst.go} (68%) rename Godeps/_workspace/src/github.com/coreos/go-tspi/{attestation/attestation.go => verification/verification.go} (84%) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 8e30ea4b2e..4b3a8dc506 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -58,12 +58,12 @@ }, { "ImportPath": "github.com/appc/cni/plugins/ipam/host-local/backend", - "Comment": "v0.1.0-84-gb7ff8ab", + "Comment": "v0.1.0-84-gb7ff8ab158bd", "Rev": "b7ff8ab158bd2fbc700d0fe6e0a58712970fabc0" }, { "ImportPath": "github.com/appc/cni/plugins/ipam/host-local/backend/disk", - "Comment": "v0.1.0-84-gb7ff8ab", + "Comment": "v0.1.0-84-gb7ff8ab158bd", "Rev": "b7ff8ab158bd2fbc700d0fe6e0a58712970fabc0" }, { @@ -248,16 +248,19 @@ "Rev": "7b2428fec40033549c68f54e26e89e7ca9a9ce31" }, { - "ImportPath": "github.com/coreos/go-tspi/attestation", - "Rev": "8d98d77f9fc5e3a93227cbcde7abb8bdf1a29869" + "ImportPath": "github.com/coreos/go-tspi/tpmclient", + "Comment": "v0.1.1", + "Rev": "03955c59fff97f9e38e7e32c68ac4db21a2aea2b" }, { - "ImportPath": "github.com/coreos/go-tspi/tpmclient", - "Rev": "8d98d77f9fc5e3a93227cbcde7abb8bdf1a29869" + "ImportPath": "github.com/coreos/go-tspi/tspiconst", + "Comment": "v0.1.1", + "Rev": "03955c59fff97f9e38e7e32c68ac4db21a2aea2b" }, { - "ImportPath": "github.com/coreos/go-tspi/tspi", - "Rev": "8d98d77f9fc5e3a93227cbcde7abb8bdf1a29869" + "ImportPath": "github.com/coreos/go-tspi/verification", + "Comment": "v0.1.1", + "Rev": "03955c59fff97f9e38e7e32c68ac4db21a2aea2b" }, { "ImportPath": "github.com/coreos/ioprogress", @@ -337,7 +340,7 @@ }, { "ImportPath": "github.com/godbus/dbus/introspect", - "Comment": "v3-6-ga1b8ba5", + "Comment": "v3-6-ga1b8ba5163b7", "Rev": "a1b8ba5163b7f041b22761461eabd02b70d1f824" }, { diff --git a/Godeps/_workspace/src/github.com/coreos/go-tspi/tpmclient/tpmclient.go b/Godeps/_workspace/src/github.com/coreos/go-tspi/tpmclient/tpmclient.go index e71aa1464f..fb5279b2a1 100644 --- a/Godeps/_workspace/src/github.com/coreos/go-tspi/tpmclient/tpmclient.go +++ b/Godeps/_workspace/src/github.com/coreos/go-tspi/tpmclient/tpmclient.go @@ -24,8 +24,8 @@ import ( "net/http" "time" - "github.com/coreos/go-tspi/attestation" - "github.com/coreos/go-tspi/tspi" + "github.com/coreos/go-tspi/tspiconst" + "github.com/coreos/go-tspi/verification" ) // TPMClient represents a connection to a system running a daemon providing @@ -35,8 +35,17 @@ type TPMClient struct { timeout time.Duration } +const ( + GetEKCertURL = "/v1/getEkcert" + ExtendURL = "/v1/extend" + QuoteURL = "/v1/quote" + GenerateAikURL = "/v1/generateAik" + GenerateKeyURL = "/v1/generateKey" + AikChallengeURL = "/v1/aikChallenge" +) + func (client *TPMClient) get(endpoint string) (*http.Response, error) { - url := fmt.Sprintf("http://%s/%s", client.host, endpoint) + url := fmt.Sprintf("http://%s%s", client.host, endpoint) httpClient := &http.Client{ Timeout: client.timeout, } @@ -45,7 +54,7 @@ func (client *TPMClient) get(endpoint string) (*http.Response, error) { } func (client *TPMClient) post(endpoint string, data io.Reader) (*http.Response, error) { - url := fmt.Sprintf("http://%s/%s", client.host, endpoint) + url := fmt.Sprintf("http://%s%s", client.host, endpoint) httpClient := &http.Client{ Timeout: client.timeout, } @@ -53,7 +62,7 @@ func (client *TPMClient) post(endpoint string, data io.Reader) (*http.Response, return resp, err } -type ekcertResponse struct { +type EkcertResponse struct { EKCert []byte } @@ -61,9 +70,9 @@ type ekcertResponse struct { // is an X509 certificate containing the public half of the Endorsement Key // and a signature chain chaining back to a vendor-issued signing certificate. func (client *TPMClient) GetEKCert() (ekcert []byte, err error) { - var ekcertData ekcertResponse + var ekcertData EkcertResponse - ekresp, err := client.get("v1/getEkcert") + ekresp, err := client.get(GetEKCertURL) if err != nil { return nil, fmt.Errorf("Can't obtain ekcert: %s", err) } @@ -81,7 +90,7 @@ func (client *TPMClient) GetEKCert() (ekcert []byte, err error) { return ekcertData.EKCert, nil } -type aikResponse struct { +type AikResponse struct { AIKBlob []byte AIKPub []byte } @@ -90,9 +99,9 @@ type aikResponse struct { // It returns an unencrypted copy of the public half of the AIK, along with // a TSPI key blob encrypted by the TPM. func (client *TPMClient) GenerateAIK() (aikpub []byte, aikblob []byte, err error) { - var aikData aikResponse + var aikData AikResponse - aikresp, err := client.post("v1/generateAik", nil) + aikresp, err := client.post(GenerateAikURL, nil) if err != nil { return nil, nil, fmt.Errorf("Can't generate AIK: %s", err) } @@ -113,13 +122,54 @@ func (client *TPMClient) GenerateAIK() (aikpub []byte, aikblob []byte, err error return aikpub, aikblob, nil } -type challengeData struct { +type KeyData struct { + KeyFlags int +} + +type KeyResponse struct { + KeyBlob []byte + KeyPub []byte +} + +// GenerateKey requests that the TPM generate a new keypair +func (client *TPMClient) GenerateKey(flags int) (keypub []byte, keyblob []byte, err error) { + var keyData KeyData + var keyResponse KeyResponse + + keyData.KeyFlags = flags + request, err := json.Marshal(keyData) + if err != nil { + return nil, nil, fmt.Errorf("Can't construct request JSON: %s", err) + } + + keyresp, err := client.post(GenerateKeyURL, bytes.NewBuffer(request)) + if err != nil { + return nil, nil, fmt.Errorf("Can't generate key: %s", err) + } + defer keyresp.Body.Close() + body, err := ioutil.ReadAll(keyresp.Body) + if err != nil { + return nil, nil, fmt.Errorf("Can't read key response: %s", err) + } + + err = json.Unmarshal(body, &keyResponse) + if err != nil { + return nil, nil, fmt.Errorf("Can't parse key response: %s (%s)", err, body) + } + + keypub = keyResponse.KeyPub + keyblob = keyResponse.KeyBlob + + return keypub, keyblob, nil +} + +type ChallengeData struct { AIK []byte Asymenc []byte Symenc []byte } -type challengeResponse struct { +type ChallengeResponse struct { Response []byte } @@ -130,8 +180,8 @@ type challengeResponse struct { // provides the AES key used to encrypt symenc. Decrypting symenc provides // the original secret, which is then returned. func (client *TPMClient) ValidateAIK(aikblob []byte, asymenc []byte, symenc []byte) (secret []byte, err error) { - var challenge challengeData - var response challengeResponse + var challenge ChallengeData + var response ChallengeResponse challenge.AIK = aikblob challenge.Asymenc = asymenc @@ -141,7 +191,7 @@ func (client *TPMClient) ValidateAIK(aikblob []byte, asymenc []byte, symenc []by if err != nil { return nil, fmt.Errorf("Can't construct challenge JSON: %s", err) } - chalresp, err := client.post("v1/aikChallenge", bytes.NewBuffer(request)) + chalresp, err := client.post(AikChallengeURL, bytes.NewBuffer(request)) if err != nil { return nil, fmt.Errorf("Can't perform AIK challenge: %s", err) } @@ -158,7 +208,7 @@ func (client *TPMClient) ValidateAIK(aikblob []byte, asymenc []byte, symenc []by return response.Response, nil } -type extendInput struct { +type ExtendInput struct { Pcr int Eventtype int Data []byte @@ -170,7 +220,7 @@ type extendInput struct { // event is not nil, data and event will be hashed to generate the extension // value. Event will then be stored in the TPM event log. func (client *TPMClient) Extend(pcr int, eventtype int, data []byte, event string) error { - var extendData extendInput + var extendData ExtendInput extendData.Pcr = pcr extendData.Eventtype = eventtype @@ -181,7 +231,7 @@ func (client *TPMClient) Extend(pcr int, eventtype int, data []byte, event strin if err != nil { return fmt.Errorf("Can't construct extension JSON: %s", err) } - chalresp, err := client.post("v1/extend", bytes.NewBuffer(request)) + chalresp, err := client.post(ExtendURL, bytes.NewBuffer(request)) if err != nil { return fmt.Errorf("Can't perform PCR extension: %s", err) } @@ -190,25 +240,25 @@ func (client *TPMClient) Extend(pcr int, eventtype int, data []byte, event strin return nil } -type quoteData struct { +type QuoteData struct { AIK []byte PCRs []int Nonce []byte } -type quoteResponse struct { +type QuoteResponse struct { Data []byte Validation []byte PCRValues [][]byte - Events []tspi.Log + Events []tspiconst.Log } // GetQuote obtains a PCR quote from the TPM. It takes the aikpub Tspi Key, the // encrypted AIK blob and a list of PCRs as arguments. The response will // contain an array of PCR values, an array of log entries and any error. -func (client *TPMClient) GetQuote(aikpub []byte, aikblob []byte, pcrs []int) (pcrvals [][]byte, log []tspi.Log, err error) { - var quoteRequest quoteData - var response quoteResponse +func (client *TPMClient) GetQuote(aikpub []byte, aikblob []byte, pcrs []int) (pcrvals [][]byte, log []tspiconst.Log, err error) { + var quoteRequest QuoteData + var response QuoteResponse nonce := make([]byte, 20) _, err = rand.Read(nonce) @@ -224,7 +274,7 @@ func (client *TPMClient) GetQuote(aikpub []byte, aikblob []byte, pcrs []int) (pc if err != nil { return nil, nil, fmt.Errorf("Can't construct quote request JSON: %s", err) } - chalresp, err := client.post("v1/quote", bytes.NewBuffer(request)) + chalresp, err := client.post(QuoteURL, bytes.NewBuffer(request)) if err != nil { return nil, nil, fmt.Errorf("Can't perform obtain quote: %s", err) } @@ -239,9 +289,9 @@ func (client *TPMClient) GetQuote(aikpub []byte, aikblob []byte, pcrs []int) (pc return nil, nil, fmt.Errorf("Can't parse quote response: %s", err) } - aikmod := tspi.ModulusFromBlob(aikpub) + aikmod := aikpub[28:] - err = attestation.QuoteVerify(response.Data, response.Validation, aikmod, response.PCRValues, nonce) + err = verification.QuoteVerify(response.Data, response.Validation, aikmod, response.PCRValues, nonce) if err != nil { return nil, nil, fmt.Errorf("Can't verify quote: %s", err) diff --git a/Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/context.go b/Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/context.go deleted file mode 100644 index 306506a86e..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/context.go +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package tspi - -// #include -import "C" -import "unsafe" - -// Context is a TSS context -type Context struct { - context C.TSS_HCONTEXT - tpm TPM -} - -// NewContext returns a TSS daemon context -func NewContext() (*Context, error) { - context := new(Context) - err := tspiError(C.Tspi_Context_Create(&context.context)) - return context, err -} - -// Connect opens a connection between the context and the TSS daemon. It -// returns an error on failure. -func (context *Context) Connect() error { - var tpmhandle C.TSS_HTPM - err := tspiError(C.Tspi_Context_Connect(context.context, nil)) - if err != nil { - return err - } - C.Tspi_Context_GetTpmObject(context.context, &tpmhandle) - context.tpm = TPM{handle: tpmhandle, context: context.context} - return nil -} - -// Close closes the connection between the context and the TSS daemon. It -// returns an error on failure. -func (context *Context) Close() error { - err := tspiError(C.Tspi_Context_Close(context.context)) - return err -} - -// CreateNV creates a TSS object referring to a TPM NVRAM area. It returns a -// reference to the object and any error. -func (context *Context) CreateNV() (*NV, error) { - var handle C.TSS_HNVSTORE - err := tspiError(C.Tspi_Context_CreateObject(context.context, C.TSS_OBJECT_TYPE_NV, 0, (*C.TSS_HOBJECT)(&handle))) - return &NV{handle: handle, context: context.context}, err -} - -// CreateKey creates a TSS object referring to a TPM key. It returns a -// reference to the object and any error. -func (context *Context) CreateKey(flags int) (*Key, error) { - var handle C.TSS_HKEY - err := tspiError(C.Tspi_Context_CreateObject(context.context, C.TSS_OBJECT_TYPE_RSAKEY, (C.TSS_FLAG)(flags), (*C.TSS_HOBJECT)(&handle))) - return &Key{handle: handle, context: context.context}, err -} - -// LoadKeyByUUID loads the key referenced by UUID. The storetype argument -// indicates whether the key should be obtained from the system or user -// stores. It returns a reference to the key and any error. -func (context *Context) LoadKeyByUUID(storetype int, uuid C.TSS_UUID) (*Key, error) { - var handle C.TSS_HKEY - err := tspiError(C.Tspi_Context_LoadKeyByUUID(context.context, (C.TSS_FLAG)(storetype), uuid, &handle)) - return &Key{handle: handle, context: context.context}, err -} - -// LoadKeyByBlob takes an encrypted key blob and reads it into the TPM. It -// takes a reference to the parent key and the key blob, and returns a -// reference to the key and any error. -func (context *Context) LoadKeyByBlob(parent *Key, blob []byte) (*Key, error) { - var handle C.TSS_HKEY - err := tspiError(C.Tspi_Context_LoadKeyByBlob(context.context, parent.handle, (C.UINT32)(len(blob)), (*C.BYTE)(unsafe.Pointer(&blob[0])), &handle)) - return &Key{handle: handle, context: context.context}, err -} - -// GetTPM returns a reference to the TPM associated with this context -func (context *Context) GetTPM() *TPM { - return &context.tpm -} - -// CreatePolicy creates an object referring to a TSS policy. It returns a -// reference to the object plus any error. -func (context *Context) CreatePolicy(flags int) (*Policy, error) { - var handle C.TSS_HPOLICY - err := tspiError(C.Tspi_Context_CreateObject(context.context, C.TSS_OBJECT_TYPE_POLICY, (C.TSS_FLAG)(flags), (*C.TSS_HOBJECT)(&handle))) - return &Policy{handle: handle, context: context.context}, err -} - -// CreatePCRs creates an object referring to a TSS PCR composite. It returns -// a reference to the object plus any error. -func (context *Context) CreatePCRs(flags int) (*PCRs, error) { - var handle C.TSS_HPCRS - err := tspiError(C.Tspi_Context_CreateObject(context.context, C.TSS_OBJECT_TYPE_PCRS, (C.TSS_FLAG)(flags), (*C.TSS_HOBJECT)(&handle))) - return &PCRs{handle: handle, context: context.context}, err -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/hash.go b/Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/hash.go deleted file mode 100644 index 72cb161921..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/hash.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package tspi - -// #include -import "C" - -// Hash is a TSS hash -type Hash struct { - handle C.TSS_HHASH - context C.TSS_HCONTEXT -} - -// Update updates a TSS hash with the data provided. It returns an error on -// failure. -func (hash *Hash) Update(data []byte) error { - err := tspiError(C.Tspi_Hash_UpdateHashValue(hash.handle, (C.UINT32)(len(data)), (*C.BYTE)(&data[0]))) - return err -} - -// Verify checks whether a hash matches the signature signed with the -// provided key. It returns an error on failure. -func (hash *Hash) Verify(key *Key, signature []byte) error { - err := tspiError(C.Tspi_Hash_VerifySignature(hash.handle, key.handle, (C.UINT32)(len(signature)), (*C.BYTE)(&signature[0]))) - return err -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/key.go b/Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/key.go deleted file mode 100644 index 14e4ed4e7d..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/key.go +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package tspi - -// #include -import "C" -import "unsafe" - -// ModulusFromBlob provides the modulus of a provided TSS key blob -func ModulusFromBlob(blob []byte) []byte { - return blob[28:] -} - -// Key is a TSS key -type Key struct { - handle C.TSS_HKEY - context C.TSS_HCONTEXT -} - -// GetPolicy returns the policy associated with the key -func (key *Key) GetPolicy(poltype int) (*Policy, error) { - var policyHandle C.TSS_HPOLICY - err := tspiError(C.Tspi_GetPolicyObject((C.TSS_HOBJECT)(key.handle), (C.TSS_FLAG)(poltype), &policyHandle)) - return &Policy{handle: policyHandle, context: key.context}, err -} - -// SetModulus sets the modulus of a public key to the provided value -func (key *Key) SetModulus(n []byte) error { - err := tspiError(C.Tspi_SetAttribData((C.TSS_HOBJECT)(key.handle), C.TSS_TSPATTRIB_RSAKEY_INFO, C.TSS_TSPATTRIB_KEYINFO_RSA_MODULUS, (C.UINT32)(len(n)), (*C.BYTE)(unsafe.Pointer(&n[0])))) - return err -} - -// GetModulus returns the modulus of the public key -func (key *Key) GetModulus() (modulus []byte, err error) { - var dataLen C.UINT32 - var cData *C.BYTE - err = tspiError(C.Tspi_GetAttribData((C.TSS_HOBJECT)(key.handle), C.TSS_TSPATTRIB_RSAKEY_INFO, C.TSS_TSPATTRIB_KEYINFO_RSA_MODULUS, &dataLen, &cData)) - data := C.GoBytes(unsafe.Pointer(cData), (C.int)(dataLen)) - C.Tspi_Context_FreeMemory(key.context, cData) - return data, err -} - -// GetPubKeyBlob returns the public half of the key in TPM blob format -func (key *Key) GetPubKeyBlob() (pubkey []byte, err error) { - var dataLen C.UINT32 - var cData *C.BYTE - err = tspiError(C.Tspi_GetAttribData((C.TSS_HOBJECT)(key.handle), C.TSS_TSPATTRIB_KEY_BLOB, C.TSS_TSPATTRIB_KEYBLOB_PUBLIC_KEY, &dataLen, &cData)) - data := C.GoBytes(unsafe.Pointer(cData), (C.int)(dataLen)) - C.Tspi_Context_FreeMemory(key.context, cData) - return data, err -} - -// GetKeyBlob returns an encrypted blob containing the public and private -// halves of the key -func (key *Key) GetKeyBlob() ([]byte, error) { - var dataLen C.UINT32 - var cData *C.BYTE - err := tspiError(C.Tspi_GetAttribData((C.TSS_HOBJECT)(key.handle), C.TSS_TSPATTRIB_KEY_BLOB, C.TSS_TSPATTRIB_KEYBLOB_BLOB, &dataLen, &cData)) - data := C.GoBytes(unsafe.Pointer(cData), (C.int)(dataLen)) - C.Tspi_Context_FreeMemory(key.context, cData) - return data, err -} - diff --git a/Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/nv.go b/Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/nv.go deleted file mode 100644 index 844741f085..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/nv.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package tspi - -// #include -import "C" -import "unsafe" - -// NV is a TSS NV object -type NV struct { - handle C.TSS_HNVSTORE - context C.TSS_HCONTEXT -} - -// ReadValue reads length bytes from offset in the TPM NVRAM space -func (nv *NV) ReadValue(offset uint, length uint) ([]byte, error) { - data := make([]byte, length) - err := tspiError(C.Tspi_NV_ReadValue(nv.handle, (C.UINT32)(offset), (*C.UINT32)(unsafe.Pointer(&length)), (**C.BYTE)(unsafe.Pointer(&data)))) - return data, err -} - -// SetIndex sets the TPM NVRAM index that will be referenced by ReadValue() -func (nv *NV) SetIndex(index uint) error { - err := tspiError(C.Tspi_SetAttribUint32((C.TSS_HOBJECT)(nv.handle), C.TSS_TSPATTRIB_NV_INDEX, 0, (C.UINT32)(index))) - return err -} - -// AssignPolicy assigns a policy to the TPM NVRAM region -func (nv *NV) AssignPolicy(policy *Policy) error { - err := tspiError(C.Tspi_Policy_AssignToObject(policy.handle, (C.TSS_HOBJECT)(nv.handle))) - return err -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/pcrs.go b/Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/pcrs.go deleted file mode 100644 index 98eb412e7d..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/pcrs.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package tspi - -// #include -import "C" -import "unsafe" - -// PCRs is a structure representing a PCR object and the PCR values -type PCRs struct { - handle C.TSS_HPCRS - context C.TSS_HCONTEXT - pcrs [24][]byte - pcrset [24]bool -} - -// SetPCRs takes an array of integers referring to PCRs. Any queries performed -// with this PCR object will then query these PCRs. -func (pcrs *PCRs) SetPCRs(pcrset []int) error { - for pcr := range pcrs.pcrset { - pcrs.pcrset[pcr] = false - } - for _, pcr := range pcrset { - err := tspiError(C.Tspi_PcrComposite_SelectPcrIndex(pcrs.handle, (C.UINT32)(pcr))) - if err != nil { - return err - } - pcrs.pcrset[pcr] = true - } - return nil -} - -// GetPCRValues obtains the PCR values for any PCRs that have been set. -func (pcrs *PCRs) GetPCRValues() ([][]byte, error) { - var buflen C.UINT32 - var buf *C.BYTE - for pcr := range pcrs.pcrs { - if pcrs.pcrset[pcr] == false { - continue - } - err := tspiError(C.Tspi_PcrComposite_GetPcrValue(pcrs.handle, (C.UINT32)(pcr), &buflen, &buf)) - if err != nil { - return nil, err - } - pcrs.pcrs[pcr] = C.GoBytes(unsafe.Pointer(buf), (C.int)(buflen)) - C.Tspi_Context_FreeMemory(pcrs.context, buf) - } - return pcrs.pcrs[:], nil -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/policy.go b/Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/policy.go deleted file mode 100644 index acc67ad035..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/policy.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package tspi - -// #include -import "C" - -// Policy is a TSS policy object -type Policy struct { - handle C.TSS_HPOLICY - context C.TSS_HCONTEXT -} - -// SetSecret sets the secret for a policy. This policy may then be applied to -// another object. -func (policy *Policy) SetSecret(sectype int, secret []byte) error { - err := tspiError(C.Tspi_Policy_SetSecret(policy.handle, (C.TSS_FLAG)(sectype), (C.UINT32)(len(secret)), (*C.BYTE)(&secret[0]))) - return err -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/tpm.go b/Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/tpm.go deleted file mode 100644 index c15f92dd21..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/tpm.go +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package tspi - -// #include -import "C" -import ( - "crypto/sha1" - "unsafe" -) - -// TPM is a TSS TPM object -type TPM struct { - handle C.TSS_HTPM - context C.TSS_HCONTEXT -} - -// Log represents an entry from the TSS event log. Pcr is the register that -// was extended by the event. Eventtype is the type of the event. PcrValue -// is the value that was hashed into the TPM. Event is the raw event data. -type Log struct { - Pcr int - Eventtype int - PcrValue []byte - Event []byte -} - -// GetEventLog returns an array of structures representing the contents of the -// TSS event log -func (tpm *TPM) GetEventLog() ([]Log, error) { - var count C.UINT32 - var events *C.TSS_PCR_EVENT - var event C.TSS_PCR_EVENT - - err := tspiError(C.Tspi_TPM_GetEventLog(tpm.handle, &count, &events)) - if err != nil { - return nil, err - } - - if count == 0 { - return nil, nil - } - - log := make([]Log, count) - length := count * C.UINT32(unsafe.Sizeof(event)) - slice := (*[1 << 30]C.TSS_PCR_EVENT)(unsafe.Pointer(events))[:length:length] - - for i := 0; i < int(count); i++ { - log[i].Pcr = int(slice[i].ulPcrIndex) - log[i].Eventtype = int(slice[i].eventType) - log[i].PcrValue = C.GoBytes(unsafe.Pointer(slice[i].rgbPcrValue), C.int(slice[i].ulPcrValueLength)) - log[i].Event = C.GoBytes(unsafe.Pointer(slice[i].rgbEvent), C.int(slice[i].ulEventLength)) - } - C.Tspi_Context_FreeMemory(tpm.context, (*C.BYTE)(unsafe.Pointer(events))) - return log, nil -} - -// ExtendPCR extends a pcr. If event is nil, data must be pre-hashed with -// SHA1. If event is not nil, event is used to populate the TSS event -// log. If both data and event are provided, both will be used to create the -// extend hash. -func (tpm *TPM) ExtendPCR(pcr int, data []byte, eventtype int, event []byte) error { - var outlen C.UINT32 - var pcrval *C.BYTE - var eventstruct C.TSS_PCR_EVENT - var err error - - shasum := sha1.Sum(data) - - if event != nil { - var pcrdata *C.BYTE - var pcrdatalen C.UINT32 - - eventstruct.versionInfo.bMajor = 1 - eventstruct.versionInfo.bMinor = 2 - eventstruct.versionInfo.bRevMajor = 1 - eventstruct.versionInfo.bRevMinor = 0 - eventstruct.ulPcrIndex = C.UINT32(pcr) - eventstruct.rgbPcrValue = (*C.BYTE)(&shasum[0]) - eventstruct.eventType = C.TSS_EVENTTYPE(eventtype) - eventstruct.ulEventLength = C.UINT32(len(event)) - eventstruct.rgbEvent = (*C.BYTE)(&event[0]) - - if data == nil || len(data) == 0 { - pcrdata = nil - pcrdatalen = C.UINT32(0) - } else { - pcrdata = (*C.BYTE)(&data[0]) - pcrdatalen = C.UINT32(len(data)) - } - - err = tspiError(C.Tspi_TPM_PcrExtend(tpm.handle, C.UINT32(pcr), pcrdatalen, pcrdata, &eventstruct, &outlen, &pcrval)) - } else { - err = tspiError(C.Tspi_TPM_PcrExtend(tpm.handle, C.UINT32(pcr), C.UINT32(len(shasum)), (*C.BYTE)(&shasum[0]), nil, &outlen, &pcrval)) - } - - C.Tspi_Context_FreeMemory(tpm.context, pcrval) - - return err -} - -//GetQuote takes an encrypted key blob representing the AIK, a set of PCRs -//and a challenge and returns a blob containing a hash of the PCR hashes and -//the challenge, and a validation blob signed by the AIK. -func (tpm *TPM) GetQuote(aik *Key, pcrs *PCRs, challenge []byte) ([]byte, []byte, error) { - var validation C.TSS_VALIDATION - challangeHash := sha1.Sum(challenge[:]) - - validation.ulExternalDataLength = sha1.Size - validation.rgbExternalData = (*C.BYTE)(&challangeHash[0]) - err := tspiError(C.Tspi_TPM_Quote(tpm.handle, aik.handle, pcrs.handle, &validation)) - - if err != nil { - return nil, nil, err - } - - data := C.GoBytes(unsafe.Pointer(validation.rgbData), (C.int)(validation.ulDataLength)) - validationOutput := C.GoBytes(unsafe.Pointer(validation.rgbValidationData), (C.int)(validation.ulValidationDataLength)) - - C.Tspi_Context_FreeMemory(tpm.context, validation.rgbData) - C.Tspi_Context_FreeMemory(tpm.context, validation.rgbValidationData) - - return data, validationOutput, nil -} - -// ActivateIdentity accepts an encrypted key blob representing the AIK and -// two blobs representing the asymmetric and symmetric challenges associated -// with the AIK. If the TPM is able to decrypt the challenges and the -// challenges correspond to the AIK, the TPM will return the original -// challenge secret. -func (tpm *TPM) ActivateIdentity(aik *Key, asymblob []byte, symblob []byte) (secret []byte, err error) { - var creds *C.BYTE - var credlen C.UINT32 - - err = tspiError(C.Tspi_TPM_ActivateIdentity(tpm.handle, aik.handle, (C.UINT32)(len(asymblob)), (*C.BYTE)(&asymblob[0]), (C.UINT32)(len(symblob)), (*C.BYTE)(&symblob[0]), &credlen, &creds)) - - if err != nil { - return nil, err - } - - plaintext := C.GoBytes(unsafe.Pointer(creds), (C.int)(credlen)) - - C.Tspi_Context_FreeMemory(tpm.context, creds) - - return plaintext, nil -} - -// GetPolicy returns the TSS policy associated with the TPM. -func (tpm *TPM) GetPolicy(poltype int) (*Policy, error) { - var policyHandle C.TSS_HPOLICY - err := tspiError(C.Tspi_GetPolicyObject((C.TSS_HOBJECT)(tpm.handle), (C.TSS_FLAG)(poltype), &policyHandle)) - return &Policy{handle: policyHandle, context: tpm.context}, err -} - -// TakeOwnership transitions a TPM from unowned state to owned, installing the -// encrypted key blob as the SRK. -func (tpm *TPM) TakeOwnership(srk *Key) error { - err := tspiError(C.Tspi_TPM_TakeOwnership(tpm.handle, srk.handle, 0)) - return err -} - - -// AssignPolicy assigns a TSS policy to the TPM. -func (tpm *TPM) AssignPolicy(policy *Policy) error { - err := tspiError(C.Tspi_Policy_AssignToObject(policy.handle, (C.TSS_HOBJECT)(tpm.handle))) - return err -} - -// CollateIdentityRequest creates a signing request for the provided AIKq -func (tpm *TPM) CollateIdentityRequest(srk *Key, pubkey *Key, aik *Key) ([]byte, error) { - var certLen C.UINT32 - var cCertReq *C.BYTE - err := tspiError(C.Tspi_TPM_CollateIdentityRequest(tpm.handle, srk.handle, pubkey.handle, 0, nil, aik.handle, C.TSS_ALG_AES, &certLen, &cCertReq)) - certReq := C.GoBytes(unsafe.Pointer(cCertReq), (C.int)(certLen)) - C.Tspi_Context_FreeMemory(tpm.context, cCertReq) - return certReq, err -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/tspi.go b/Godeps/_workspace/src/github.com/coreos/go-tspi/tspiconst/tspiconst.go similarity index 68% rename from Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/tspi.go rename to Godeps/_workspace/src/github.com/coreos/go-tspi/tspiconst/tspiconst.go index 3a39bb7cc5..f2446db76b 100644 --- a/Godeps/_workspace/src/github.com/coreos/go-tspi/tspi/tspi.go +++ b/Godeps/_workspace/src/github.com/coreos/go-tspi/tspiconst/tspiconst.go @@ -12,370 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package tspi - -// #include -// #cgo LDFLAGS: -ltspi -import "C" -import "errors" -import "fmt" - -func tspiError(tssRet C.TSS_RESULT) error { - ret := (int)(tssRet) - if ret == 0 { - return nil - } - if (ret & 0xf000) != 0 { - ret &= ^(0xf000) - switch { - case ret == C.TSS_E_FAIL: - return errors.New("TSS_E_FAIL") - case ret == C.TSS_E_BAD_PARAMETER: - return errors.New("TSS_E_BAD_PARAMETER") - case ret == C.TSS_E_INTERNAL_ERROR: - return errors.New("TSS_E_INTERNAL_ERROR") - case ret == C.TSS_E_OUTOFMEMORY: - return errors.New("TSS_E_OUTOFMEMORY") - case ret == C.TSS_E_NOTIMPL: - return errors.New("TSS_E_NOTIMPL") - case ret == C.TSS_E_KEY_ALREADY_REGISTERED: - return errors.New("TSS_E_KEY_ALREADY_REGISTERED") - case ret == C.TSS_E_TPM_UNEXPECTED: - return errors.New("TSS_E_TPM_UNEXPECTED") - case ret == C.TSS_E_COMM_FAILURE: - return errors.New("TSS_E_COMM_FAILURE") - case ret == C.TSS_E_TIMEOUT: - return errors.New("TSS_E_TIMEOUT") - case ret == C.TSS_E_TPM_UNSUPPORTED_FEATURE: - return errors.New("TSS_E_TPM_UNSUPPORTED_FEATURE") - case ret == C.TSS_E_CANCELED: - return errors.New("TSS_E_CANCELED") - case ret == C.TSS_E_PS_KEY_NOTFOUND: - return errors.New("TSS_E_PS_KEY_NOTFOUND") - case ret == C.TSS_E_PS_KEY_EXISTS: - return errors.New("TSS_E_PS_KEY_EXISTS") - case ret == C.TSS_E_PS_BAD_KEY_STATE: - return errors.New("TSS_E_PS_BAD_KEY_STATE") - case ret == C.TSS_E_INVALID_OBJECT_TYPE: - return errors.New("TSS_E_INVALID_OBJECT_TYPE") - case ret == C.TSS_E_NO_CONNECTION: - return errors.New("TSS_E_NO_CONNECTION") - case ret == C.TSS_E_CONNECTION_FAILED: - return errors.New("TSS_E_CONNECTION_FAILED") - case ret == C.TSS_E_CONNECTION_BROKEN: - return errors.New("TSS_E_CONNECTION_BROKEN") - case ret == C.TSS_E_HASH_INVALID_ALG: - return errors.New("TSS_E_HASH_INVALID_ALG") - case ret == C.TSS_E_HASH_INVALID_LENGTH: - return errors.New("TSS_E_HASH_INVALID_LENGTH") - case ret == C.TSS_E_HASH_NO_DATA: - return errors.New("TSS_E_HASH_NO_DATA") - case ret == C.TSS_E_INVALID_ATTRIB_FLAG: - return errors.New("TSS_E_INVALID_ATTRIB_FLAG") - case ret == C.TSS_E_INVALID_ATTRIB_SUBFLAG: - return errors.New("TSS_E_INVALID_ATTRIB_SUBFLAG") - case ret == C.TSS_E_INVALID_ATTRIB_DATA: - return errors.New("TSS_E_INVALID_ATTRIB_DATA") - case ret == C.TSS_E_INVALID_OBJECT_INITFLAG: - return errors.New("TSS_E_INVALID_OBJECT_INITFLAG") - case ret == C.TSS_E_NO_PCRS_SET: - return errors.New("TSS_E_NO_PCRS_SET") - case ret == C.TSS_E_KEY_NOT_LOADED: - return errors.New("TSS_E_KEY_NOT_LOADED") - case ret == C.TSS_E_KEY_NOT_SET: - return errors.New("TSS_E_KEY_NOT_SET") - case ret == C.TSS_E_VALIDATION_FAILED: - return errors.New("TSS_E_VALIDATION_FAILED") - case ret == C.TSS_E_TSP_AUTHREQUIRED: - return errors.New("TSS_E_TSP_AUTHREQUIRED") - case ret == C.TSS_E_TSP_AUTH2REQUIRED: - return errors.New("TSS_E_TSP_AUTH2REQUIRED") - case ret == C.TSS_E_TSP_AUTHFAIL: - return errors.New("TSS_E_TSP_AUTHFAIL") - case ret == C.TSS_E_TSP_AUTH2FAIL: - return errors.New("TSS_E_TSP_AUTH2FAIL") - case ret == C.TSS_E_KEY_NO_MIGRATION_POLICY: - return errors.New("TSS_E_KEY_NO_MIGRATION_POLICY") - case ret == C.TSS_E_POLICY_NO_SECRET: - return errors.New("TSS_E_POLICY_NO_SECRET") - case ret == C.TSS_E_INVALID_OBJ_ACCESS: - return errors.New("TSS_E_INVALID_OBJ_ACCESS") - case ret == C.TSS_E_INVALID_ENCSCHEME: - return errors.New("TSS_E_INVALID_ENCSCHEME") - case ret == C.TSS_E_INVALID_SIGSCHEME: - return errors.New("TSS_E_INVALID_SIGSCHEME") - case ret == C.TSS_E_ENC_INVALID_LENGTH: - return errors.New("TSS_E_ENC_INVALID_LENGTH") - case ret == C.TSS_E_ENC_NO_DATA: - return errors.New("TSS_E_ENC_NO_DATA") - case ret == C.TSS_E_ENC_INVALID_TYPE: - return errors.New("TSS_E_ENC_INVALID_TYPE") - case ret == C.TSS_E_INVALID_KEYUSAGE: - return errors.New("TSS_E_INVALID_KEYUSAGE") - case ret == C.TSS_E_VERIFICATION_FAILED: - return errors.New("TSS_E_VERIFICATION_FAILED") - case ret == C.TSS_E_HASH_NO_IDENTIFIER: - return errors.New("TSS_E_HASH_NO_IDENTIFIER") - case ret == C.TSS_E_INVALID_HANDLE: - return errors.New("TSS_E_INVALID_HANDLE") - case ret == C.TSS_E_SILENT_CONTEXT: - return errors.New("TSS_E_SILENT_CONTEXT") - case ret == C.TSS_E_EK_CHECKSUM: - return errors.New("TSS_E_EK_CHECKSUM") - case ret == C.TSS_E_DELEGATION_NOTSET: - return errors.New("TSS_E_DELEGATION_NOTSET") - case ret == C.TSS_E_DELFAMILY_NOTFOUND: - return errors.New("TSS_E_DELFAMILY_NOTFOUND") - case ret == C.TSS_E_DELFAMILY_ROWEXISTS: - return errors.New("TSS_E_DELFAMILY_ROWEXISTS") - case ret == C.TSS_E_VERSION_MISMATCH: - return errors.New("TSS_E_VERSION_MISMATCH") - case ret == C.TSS_E_DAA_AR_DECRYPTION_ERROR: - return errors.New("TSS_E_DAA_AR_DECRYPTION_ERROR") - case ret == C.TSS_E_DAA_AUTHENTICATION_ERROR: - return errors.New("TSS_E_DAA_AUTHENTICATION_ERROR") - case ret == C.TSS_E_DAA_CHALLENGE_RESPONSE_ERROR: - return errors.New("TSS_E_DAA_CHALLENGE_RESPONSE_ERROR") - case ret == C.TSS_E_DAA_CREDENTIAL_PROOF_ERROR: - return errors.New("TSS_E_DAA_CREDENTIAL_PROOF_ERROR") - case ret == C.TSS_E_DAA_CREDENTIAL_REQUEST_PROOF_ERROR: - return errors.New("TSS_E_DAA_CREDENTIAL_REQUEST_PROOF_ERROR") - case ret == C.TSS_E_DAA_ISSUER_KEY_ERROR: - return errors.New("TSS_E_DAA_ISSUER_KEY_ERROR") - case ret == C.TSS_E_DAA_PSEUDONYM_ERROR: - return errors.New("TSS_E_DAA_PSEUDONYM_ERROR") - case ret == C.TSS_E_INVALID_RESOURCE: - return errors.New("TSS_E_INVALID_RESOURCE") - case ret == C.TSS_E_NV_AREA_EXIST: - return errors.New("TSS_E_NV_AREA_EXIST") - case ret == C.TSS_E_NV_AREA_NOT_EXIST: - return errors.New("TSS_E_NV_AREA_NOT_EXIST") - case ret == C.TSS_E_TSP_TRANS_AUTHFAIL: - return errors.New("TSS_E_TSP_TRANS_AUTHFAIL") - case ret == C.TSS_E_TSP_TRANS_AUTHREQUIRED: - return errors.New("TSS_E_TSP_TRANS_AUTHREQUIRED") - case ret == C.TSS_E_TSP_TRANS_NOTEXCLUSIVE: - return errors.New("TSS_E_TSP_TRANS_NOTEXCLUSIVE") - case ret == C.TSS_E_TSP_TRANS_FAIL: - return errors.New("TSS_E_TSP_TRANS_FAIL") - case ret == C.TSS_E_TSP_TRANS_NO_PUBKEY: - return errors.New("TSS_E_TSP_TRANS_NO_PUBKEY") - case ret == C.TSS_E_NO_ACTIVE_COUNTER: - return errors.New("TSS_E_NO_ACTIVE_COUNTER") - } - return fmt.Errorf("Unknown TSS error: %x", ret) - } - - switch { - case ret == C.TPM_E_NON_FATAL: - return errors.New("TPM_E_NON_FATAL") - case ret == C.TPM_E_AUTHFAIL: - return errors.New("TPM_E_AUTHFAIL") - case ret == C.TPM_E_BADINDEX: - return errors.New("TPM_E_BADINDEX") - case ret == C.TPM_E_BAD_PARAMETER: - return errors.New("TPM_E_BAD_PARAMETER") - case ret == C.TPM_E_AUDITFAILURE: - return errors.New("TPM_E_AUDITFAILURE") - case ret == C.TPM_E_CLEAR_DISABLED: - return errors.New("TPM_E_CLEAR_DISABLED") - case ret == C.TPM_E_DEACTIVATED: - return errors.New("TPM_E_DEACTIVATED") - case ret == C.TPM_E_DISABLED: - return errors.New("TPM_E_DISABLED") - case ret == C.TPM_E_DISABLED_CMD: - return errors.New("TPM_E_DISABLED_CMD") - case ret == C.TPM_E_FAIL: - return errors.New("TPM_E_FAIL") - case ret == C.TPM_E_BAD_ORDINAL: - return errors.New("TPM_E_BAD_ORDINAL") - case ret == C.TPM_E_INSTALL_DISABLED: - return errors.New("TPM_E_INSTALL_DISABLED") - case ret == C.TPM_E_INVALID_KEYHANDLE: - return errors.New("TPM_E_INVALID_KEYHANDLE") - case ret == C.TPM_E_KEYNOTFOUND: - return errors.New("TPM_E_KEYNOTFOUND") - case ret == C.TPM_E_INAPPROPRIATE_ENC: - return errors.New("TPM_E_INAPPROPRIATE_ENC") - case ret == C.TPM_E_MIGRATEFAIL: - return errors.New("TPM_E_MIGRATEFAIL") - case ret == C.TPM_E_INVALID_PCR_INFO: - return errors.New("TPM_E_INVALID_PCR_INFO") - case ret == C.TPM_E_NOSPACE: - return errors.New("TPM_E_NOSPACE") - case ret == C.TPM_E_NOSRK: - return errors.New("TPM_E_NOSRK") - case ret == C.TPM_E_NOTSEALED_BLOB: - return errors.New("TPM_E_NOTSEALED_BLOB") - case ret == C.TPM_E_OWNER_SET: - return errors.New("TPM_E_OWNER_SET") - case ret == C.TPM_E_RESOURCES: - return errors.New("TPM_E_RESOURCES") - case ret == C.TPM_E_SHORTRANDOM: - return errors.New("TPM_E_SHORTRANDOM") - case ret == C.TPM_E_SIZE: - return errors.New("TPM_E_SIZE") - case ret == C.TPM_E_WRONGPCRVAL: - return errors.New("TPM_E_WRONGPCRVAL") - case ret == C.TPM_E_BAD_PARAM_SIZE: - return errors.New("TPM_E_BAD_PARAM_SIZE") - case ret == C.TPM_E_SHA_THREAD: - return errors.New("TPM_E_SHA_THREAD") - case ret == C.TPM_E_SHA_ERROR: - return errors.New("TPM_E_SHA_ERROR") - case ret == C.TPM_E_FAILEDSELFTEST: - return errors.New("TPM_E_FAILEDSELFTEST") - case ret == C.TPM_E_AUTH2FAIL: - return errors.New("TPM_E_AUTH2FAIL") - case ret == C.TPM_E_BADTAG: - return errors.New("TPM_E_BADTAG") - case ret == C.TPM_E_IOERROR: - return errors.New("TPM_E_IOERROR") - case ret == C.TPM_E_ENCRYPT_ERROR: - return errors.New("TPM_E_ENCRYPT_ERROR") - case ret == C.TPM_E_DECRYPT_ERROR: - return errors.New("TPM_E_DECRYPT_ERROR") - case ret == C.TPM_E_INVALID_AUTHHANDLE: - return errors.New("TPM_E_INVALID_AUTHHANDLE") - case ret == C.TPM_E_NO_ENDORSEMENT: - return errors.New("TPM_E_NO_ENDORSEMENT") - case ret == C.TPM_E_INVALID_KEYUSAGE: - return errors.New("TPM_E_INVALID_KEYUSAGE") - case ret == C.TPM_E_WRONG_ENTITYTYPE: - return errors.New("TPM_E_WRONG_ENTITYTYPE") - case ret == C.TPM_E_INVALID_POSTINIT: - return errors.New("TPM_E_INVALID_POSTINIT") - case ret == C.TPM_E_INAPPROPRIATE_SIG: - return errors.New("TPM_E_INAPPROPRIATE_SIG") - case ret == C.TPM_E_BAD_KEY_PROPERTY: - return errors.New("TPM_E_BAD_KEY_PROPERTY") - case ret == C.TPM_E_BAD_MIGRATION: - return errors.New("TPM_E_BAD_MIGRATION") - case ret == C.TPM_E_BAD_SCHEME: - return errors.New("TPM_E_BAD_SCHEME") - case ret == C.TPM_E_BAD_DATASIZE: - return errors.New("TPM_E_BAD_DATASIZE") - case ret == C.TPM_E_BAD_MODE: - return errors.New("TPM_E_BAD_MODE") - case ret == C.TPM_E_BAD_PRESENCE: - return errors.New("TPM_E_BAD_PRESENCE") - case ret == C.TPM_E_BAD_VERSION: - return errors.New("TPM_E_BAD_VERSION") - case ret == C.TPM_E_NO_WRAP_TRANSPORT: - return errors.New("TPM_E_NO_WRAP_TRANSPORT") - case ret == C.TPM_E_AUDITFAIL_UNSUCCESSFUL: - return errors.New("TPM_E_AUDITFAIL_UNSUCCESSFUL") - case ret == C.TPM_E_AUDITFAIL_SUCCESSFUL: - return errors.New("TPM_E_AUDITFAIL_SUCCESSFUL") - case ret == C.TPM_E_NOTRESETABLE: - return errors.New("TPM_E_NOTRESETABLE") - case ret == C.TPM_E_NOTLOCAL: - return errors.New("TPM_E_NOTLOCAL") - case ret == C.TPM_E_BAD_TYPE: - return errors.New("TPM_E_BAD_TYPE") - case ret == C.TPM_E_INVALID_RESOURCE: - return errors.New("TPM_E_INVALID_RESOURCE") - case ret == C.TPM_E_NOTFIPS: - return errors.New("TPM_E_NOTFIPS") - case ret == C.TPM_E_INVALID_FAMILY: - return errors.New("TPM_E_INVALID_FAMILY") - case ret == C.TPM_E_NO_NV_PERMISSION: - return errors.New("TPM_E_NO_NV_PERMISSION") - case ret == C.TPM_E_REQUIRES_SIGN: - return errors.New("TPM_E_REQUIRES_SIGN") - case ret == C.TPM_E_KEY_NOTSUPPORTED: - return errors.New("TPM_E_KEY_NOTSUPPORTED") - case ret == C.TPM_E_AUTH_CONFLICT: - return errors.New("TPM_E_AUTH_CONFLICT") - case ret == C.TPM_E_AREA_LOCKED: - return errors.New("TPM_E_AREA_LOCKED") - case ret == C.TPM_E_BAD_LOCALITY: - return errors.New("TPM_E_BAD_LOCALITY") - case ret == C.TPM_E_READ_ONLY: - return errors.New("TPM_E_READ_ONLY") - case ret == C.TPM_E_PER_NOWRITE: - return errors.New("TPM_E_PER_NOWRITE") - case ret == C.TPM_E_FAMILYCOUNT: - return errors.New("TPM_E_FAMILYCOUNT") - case ret == C.TPM_E_WRITE_LOCKED: - return errors.New("TPM_E_WRITE_LOCKED") - case ret == C.TPM_E_BAD_ATTRIBUTES: - return errors.New("TPM_E_BAD_ATTRIBUTES") - case ret == C.TPM_E_INVALID_STRUCTURE: - return errors.New("TPM_E_INVALID_STRUCTURE") - case ret == C.TPM_E_KEY_OWNER_CONTROL: - return errors.New("TPM_E_KEY_OWNER_CONTROL") - case ret == C.TPM_E_BAD_COUNTER: - return errors.New("TPM_E_BAD_COUNTER") - case ret == C.TPM_E_NOT_FULLWRITE: - return errors.New("TPM_E_NOT_FULLWRITE") - case ret == C.TPM_E_CONTEXT_GAP: - return errors.New("TPM_E_CONTEXT_GAP") - case ret == C.TPM_E_MAXNVWRITES: - return errors.New("TPM_E_MAXNVWRITES") - case ret == C.TPM_E_NOOPERATOR: - return errors.New("TPM_E_NOOPERATOR") - case ret == C.TPM_E_RESOURCEMISSING: - return errors.New("TPM_E_RESOURCEMISSING") - case ret == C.TPM_E_DELEGATE_LOCK: - return errors.New("TPM_E_DELEGATE_LOCK") - case ret == C.TPM_E_DELEGATE_FAMILY: - return errors.New("TPM_E_DELEGATE_FAMILY") - case ret == C.TPM_E_DELEGATE_ADMIN: - return errors.New("TPM_E_DELEGATE_ADMIN") - case ret == C.TPM_E_TRANSPORT_NOTEXCLUSIVE: - return errors.New("TPM_E_TRANSPORT_NOTEXCLUSIVE") - case ret == C.TPM_E_OWNER_CONTROL: - return errors.New("TPM_E_OWNER_CONTROL") - case ret == C.TPM_E_DAA_RESOURCES: - return errors.New("TPM_E_DAA_RESOURCES") - case ret == C.TPM_E_DAA_INPUT_DATA0: - return errors.New("TPM_E_DAA_INPUT_DATA0") - case ret == C.TPM_E_DAA_INPUT_DATA1: - return errors.New("TPM_E_DAA_INPUT_DATA1") - case ret == C.TPM_E_DAA_ISSUER_SETTINGS: - return errors.New("TPM_E_DAA_ISSUER_SETTINGS") - case ret == C.TPM_E_DAA_TPM_SETTINGS: - return errors.New("TPM_E_DAA_TPM_SETTINGS") - case ret == C.TPM_E_DAA_STAGE: - return errors.New("TPM_E_DAA_STAGE") - case ret == C.TPM_E_DAA_ISSUER_VALIDITY: - return errors.New("TPM_E_DAA_ISSUER_VALIDITY") - case ret == C.TPM_E_DAA_WRONG_W: - return errors.New("TPM_E_DAA_WRONG_W") - case ret == C.TPM_E_BAD_HANDLE: - return errors.New("TPM_E_BAD_HANDLE") - case ret == C.TPM_E_BAD_DELEGATE: - return errors.New("TPM_E_BAD_DELEGATE") - case ret == C.TPM_E_BADCONTEXT: - return errors.New("TPM_E_BADCONTEXT") - case ret == C.TPM_E_TOOMANYCONTEXTS: - return errors.New("TPM_E_TOOMANYCONTEXTS") - case ret == C.TPM_E_MA_TICKET_SIGNATURE: - return errors.New("TPM_E_MA_TICKET_SIGNATURE") - case ret == C.TPM_E_MA_DESTINATION: - return errors.New("TPM_E_MA_DESTINATION") - case ret == C.TPM_E_MA_SOURCE: - return errors.New("TPM_E_MA_SOURCE") - case ret == C.TPM_E_MA_AUTHORITY: - return errors.New("TPM_E_MA_AUTHORITY") - case ret == C.TPM_E_PERMANENTEK: - return errors.New("TPM_E_PERMANENTEK") - case ret == C.TPM_E_BAD_SIGNATURE: - return errors.New("TPM_E_BAD_SIGNATURE") - case ret == C.TPM_E_NOCONTEXTSPACE: - return errors.New("TPM_E_NOCONTEXTSPACE") - case ret == C.TPM_E_RETRY: - return errors.New("TPM_E_RETRY") - case ret == C.TPM_E_NEEDS_SELFTEST: - return errors.New("TPM_E_NEEDS_SELFTEST") - case ret == C.TPM_E_DOING_SELFTEST: - return errors.New("TPM_E_DOING_SELFTEST") - case ret == C.TPM_E_DEFEND_LOCK_RUNNING: - return errors.New("TPM_E_DEFEND_LOCK_RUNNING") - } - return fmt.Errorf("Unknown error: %x", ret) -} +package tspiconst const ( TSS_OBJECT_TYPE_POLICY = 0x01 @@ -890,92 +527,12 @@ const ( TPM_ES_SYM_CBC_PKCS5PAD = 0x00FF ) -var TSS_UUID_SRK = C.TSS_UUID{ - ulTimeLow: 0, - usTimeMid: 0, - usTimeHigh: 0, - bClockSeqHigh: 0, - bClockSeqLow: 0, - rgbNode: [6]C.BYTE{0, 0, 0, 0, 0, 1}, -} - -var TSS_UUID_SK = C.TSS_UUID{ - ulTimeLow: 0, - usTimeMid: 0, - usTimeHigh: 0, - bClockSeqHigh: 0, - bClockSeqLow: 0, - rgbNode: [6]C.BYTE{0, 0, 0, 0, 0, 2}, -} - -var TSS_UUID_RK = C.TSS_UUID{ - ulTimeLow: 0, - usTimeMid: 0, - usTimeHigh: 0, - bClockSeqHigh: 0, - bClockSeqLow: 0, - rgbNode: [6]C.BYTE{0, 0, 0, 0, 0, 3}, -} - -var TSS_UUID_CRK = C.TSS_UUID{ - ulTimeLow: 0, - usTimeMid: 0, - usTimeHigh: 0, - bClockSeqHigh: 0, - bClockSeqLow: 0, - rgbNode: [6]C.BYTE{0, 0, 0, 0, 0, 8}, -} - -var TSS_UUID_USK1 = C.TSS_UUID{ - ulTimeLow: 0, - usTimeMid: 0, - usTimeHigh: 0, - bClockSeqHigh: 0, - bClockSeqLow: 0, - rgbNode: [6]C.BYTE{0, 0, 0, 0, 0, 4}, -} - -var TSS_UUID_USK2 = C.TSS_UUID{ - ulTimeLow: 0, - usTimeMid: 0, - usTimeHigh: 0, - bClockSeqHigh: 0, - bClockSeqLow: 0, - rgbNode: [6]C.BYTE{0, 0, 0, 0, 0, 5}, -} - -var TSS_UUID_USK3 = C.TSS_UUID{ - ulTimeLow: 0, - usTimeMid: 0, - usTimeHigh: 0, - bClockSeqHigh: 0, - bClockSeqLow: 0, - rgbNode: [6]C.BYTE{0, 0, 0, 0, 0, 6}, -} - -var TSS_UUID_USK4 = C.TSS_UUID{ - ulTimeLow: 0, - usTimeMid: 0, - usTimeHigh: 0, - bClockSeqHigh: 0, - bClockSeqLow: 0, - rgbNode: [6]C.BYTE{0, 0, 0, 0, 0, 7}, -} - -var TSS_UUID_USK5 = C.TSS_UUID{ - ulTimeLow: 0, - usTimeMid: 0, - usTimeHigh: 0, - bClockSeqHigh: 0, - bClockSeqLow: 0, - rgbNode: [6]C.BYTE{0, 0, 0, 0, 0, 9}, -} - -var TSS_UUID_USK6 = C.TSS_UUID{ - ulTimeLow: 0, - usTimeMid: 0, - usTimeHigh: 0, - bClockSeqHigh: 0, - bClockSeqLow: 0, - rgbNode: [6]C.BYTE{0, 0, 0, 0, 0, 10}, +// Log represents an entry from the TSS event log. Pcr is the register that +// was extended by the event. Eventtype is the type of the event. PcrValue +// is the value that was hashed into the TPM. Event is the raw event data. +type Log struct { + Pcr int32 + Eventtype int32 + PcrValue [20]byte + Event []byte } diff --git a/Godeps/_workspace/src/github.com/coreos/go-tspi/attestation/attestation.go b/Godeps/_workspace/src/github.com/coreos/go-tspi/verification/verification.go similarity index 84% rename from Godeps/_workspace/src/github.com/coreos/go-tspi/attestation/attestation.go rename to Godeps/_workspace/src/github.com/coreos/go-tspi/verification/verification.go index 925380b371..15e06e2103 100644 --- a/Godeps/_workspace/src/github.com/coreos/go-tspi/attestation/attestation.go +++ b/Godeps/_workspace/src/github.com/coreos/go-tspi/verification/verification.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package attestation +package verification import ( "bytes" @@ -29,7 +29,7 @@ import ( "fmt" "math/big" - "github.com/coreos/go-tspi/tspi" + "github.com/coreos/go-tspi/tspiconst" ) func pad(plaintext []byte, bsize int) ([]byte, error) { @@ -46,14 +46,14 @@ func pad(plaintext []byte, bsize int) ([]byte, error) { return plaintext, nil } -// GenerateChallenge takes a TSPI context, a copy of the EK certificate, the -// public half of the AIK to be challenged and a secret. It then -// symmetrically encrypts the secret with a randomly generated AES key and -// Asymmetrically encrypts the AES key with the public half of the EK. These -// can then be provided to the TPM in order to ensure that the AIK is under -// the control of the TPM. It returns the asymmetrically and symmetrically -// encrypted data, along with any error. -func GenerateChallenge(context *tspi.Context, ekcert []byte, aikpub []byte, secret []byte) (asymenc []byte, symenc []byte, err error) { +// GenerateChallenge takes a copy of the EK certificate, the public half of +// the AIK to be challenged and a secret. It then symmetrically encrypts the +// secret with a randomly generated AES key and Asymmetrically encrypts the +// AES key with the public half of the EK. These can then be provided to the +// TPM in order to ensure that the AIK is under the control of the TPM. It +// returns the asymmetrically and symmetrically encrypted data, along with +// any error. +func GenerateChallenge(ekcert []byte, aikpub []byte, secret []byte) (asymenc []byte, symenc []byte, err error) { aeskey := make([]byte, 16) iv := make([]byte, 16) @@ -99,15 +99,15 @@ func GenerateChallenge(context *tspi.Context, ekcert []byte, aikpub []byte, secr if err != nil { return nil, nil, err } - err = binary.Write(symheader, binary.BigEndian, (uint32)(tspi.TPM_ALG_AES)) + err = binary.Write(symheader, binary.BigEndian, (uint32)(tspiconst.TPM_ALG_AES)) if err != nil { return nil, nil, err } - err = binary.Write(symheader, binary.BigEndian, (uint16)(tspi.TPM_ES_SYM_CBC_PKCS5PAD)) + err = binary.Write(symheader, binary.BigEndian, (uint16)(tspiconst.TPM_ES_SYM_CBC_PKCS5PAD)) if err != nil { return nil, nil, err } - err = binary.Write(symheader, binary.BigEndian, (uint16)(tspi.TPM_SS_NONE)) + err = binary.Write(symheader, binary.BigEndian, (uint16)(tspiconst.TPM_SS_NONE)) if err != nil { return nil, nil, err } @@ -136,111 +136,6 @@ func GenerateChallenge(context *tspi.Context, ekcert []byte, aikpub []byte, secr return asymenc, symenc, nil } -// AIKChallengeResponse takes the output from GenerateChallenge along with the -// encrypted AIK key blob. The TPM then decrypts the asymmetric challenge with -// its EK in order to obtain the AES key, and uses the AES key to decrypt the -// symmetrically encrypted data. It verifies that this data blob corresponds -// to the AIK it was given, and if so hands back the secret contained within -// the symmetrically encrypted data. -func AIKChallengeResponse(context *tspi.Context, aikblob []byte, asymchallenge []byte, symchallenge []byte) (secret []byte, err error) { - var wellKnown [20]byte - - srk, err := context.LoadKeyByUUID(tspi.TSS_PS_TYPE_SYSTEM, tspi.TSS_UUID_SRK) - if err != nil { - return nil, err - } - srkpolicy, err := srk.GetPolicy(tspi.TSS_POLICY_USAGE) - if err != nil { - return nil, err - } - srkpolicy.SetSecret(tspi.TSS_SECRET_MODE_SHA1, wellKnown[:]) - - tpm := context.GetTPM() - tpmpolicy, err := context.CreatePolicy(tspi.TSS_POLICY_USAGE) - if err != nil { - return nil, err - } - tpm.AssignPolicy(tpmpolicy) - tpmpolicy.SetSecret(tspi.TSS_SECRET_MODE_SHA1, wellKnown[:]) - - aik, err := context.LoadKeyByBlob(srk, aikblob) - if err != nil { - return nil, err - } - secret, err = tpm.ActivateIdentity(aik, asymchallenge, symchallenge) - - return secret, err -} - -// CreateAIK asks the TPM to generate an Attestation Identity Key. It returns -// the unencrypted public half of the AIK along with an encrypted blob -// containing both halves of the key, and any error. -func CreateAIK(context *tspi.Context) ([]byte, []byte, error) { - var wellKnown [20]byte - n := make([]byte, 2048/8) - for i := 0; i < 2048/8; i++ { - n[i] = 0xff - } - - srk, err := context.LoadKeyByUUID(tspi.TSS_PS_TYPE_SYSTEM, tspi.TSS_UUID_SRK) - if err != nil { - return nil, nil, err - } - keypolicy, err := srk.GetPolicy(tspi.TSS_POLICY_USAGE) - if err != nil { - return nil, nil, err - } - err = keypolicy.SetSecret(tspi.TSS_SECRET_MODE_SHA1, wellKnown[:]) - if err != nil { - return nil, nil, err - } - - tpm := context.GetTPM() - tpmpolicy, err := tpm.GetPolicy(tspi.TSS_POLICY_USAGE) - if err != nil { - return nil, nil, err - } - err = tpm.AssignPolicy(tpmpolicy) - if err != nil { - return nil, nil, err - } - err = tpmpolicy.SetSecret(tspi.TSS_SECRET_MODE_SHA1, wellKnown[:]) - if err != nil { - return nil, nil, err - } - - pcakey, err := context.CreateKey(tspi.TSS_KEY_TYPE_LEGACY | tspi.TSS_KEY_SIZE_2048) - if err != nil { - return nil, nil, err - } - - err = pcakey.SetModulus(n) - if err != nil { - return nil, nil, err - } - - aik, err := context.CreateKey(tspi.TSS_KEY_TYPE_IDENTITY | tspi.TSS_KEY_SIZE_2048) - if err != nil { - return nil, nil, err - } - _, err = tpm.CollateIdentityRequest(srk, pcakey, aik) - if err != nil { - return nil, nil, err - } - - pubkey, err := aik.GetPubKeyBlob() - if err != nil { - return nil, nil, err - } - blob, err := aik.GetKeyBlob() - if err != nil { - return nil, nil, err - } - - _, err = aik.GetModulus() - return pubkey, blob, nil -} - // VerifyEKCert verifies that the provided EK certificate is signed by a // trusted manufacturer. func VerifyEKCert(ekcert []byte) error { @@ -675,69 +570,6 @@ BwIDAQAB return fmt.Errorf("No matching certificate found") } -// GetEKCert reads the Endorsement Key certificate from the TPM's NVRAM and -// returns it, along with any error generated. -func GetEKCert(context *tspi.Context) (ekcert []byte, err error) { - var wellKnown [20]byte - tpm := context.GetTPM() - nv, err := context.CreateNV() - if err != nil { - return nil, err - } - policy, err := tpm.GetPolicy(tspi.TSS_POLICY_USAGE) - if err != nil { - return nil, err - } - policy.SetSecret(tspi.TSS_SECRET_MODE_SHA1, wellKnown[:]) - nv.SetIndex(0x1000f000) - nv.AssignPolicy(policy) - data, err := nv.ReadValue(0, 5) - if err != nil { - return nil, err - } - - tag := (uint)((uint)(data[0])<<8 | (uint)(data[1])) - if tag != 0x1001 { - return nil, fmt.Errorf("Invalid tag: %x", tag) - } - - if data[2] != 0 { - return nil, fmt.Errorf("Invalid certificate") - } - - ekbuflen := (uint)(uint(data[3])<<8 | (uint)(data[4])) - offset := (uint)(5) - - data, err = nv.ReadValue(offset, 2) - - tag = (uint)((uint)(data[0])<<8 | (uint)(data[1])) - if tag == 0x1002 { - offset += 2 - ekbuflen -= 2 - } else if data[0] != 0x30 { - return nil, fmt.Errorf("Invalid header: %x\n", tag) - } - - ekoffset := (uint)(0) - var ekbuf []byte - for ekoffset < ekbuflen { - length := (uint)(ekbuflen - ekoffset) - if length > 128 { - length = 128 - } - data, err = nv.ReadValue(offset, length) - if err != nil { - return nil, err - } - - ekbuf = append(ekbuf, data...) - offset += length - ekoffset += length - } - - return ekbuf, nil -} - // QuoteVerify verifies that a quote was genuinely provided by the TPM. It // takes the quote data, quote validation blob, public half of the AIK, // current PCR values and the nonce used in the original quote request. It @@ -780,3 +612,43 @@ func QuoteVerify(data []byte, validation []byte, aikpub []byte, pcrvalues [][]by return nil } + +// KeyVerify verifies that a key certification request was genuinely +// provided by the TPM. It takes the certification data, certification +// validation blob, the public half of the AIK, the public half of the key +// to be certified and the nonce used in the original quote request. It then +// verifies that the validation block is a valid signature for the +// certification data, that the certification data matches the certified key +// and that the secrets are the same (in order to avoid replay attacks). It +// returns an error if any stage of the validation fails. +func KeyVerify(data []byte, validation []byte, aikpub []byte, keypub []byte, secret []byte) error { + n := big.NewInt(0) + n.SetBytes(aikpub) + e := 65537 + + pKey := rsa.PublicKey{N: n, E: int(e)} + + dataHash := sha1.Sum(data[:]) + + err := rsa.VerifyPKCS1v15(&pKey, crypto.SHA1, dataHash[:], validation) + if err != nil { + return err + } + + keyHash := data[43:63] + nonceHash := data[63:83] + + secretHash := sha1.Sum(secret[:]) + + if bytes.Equal(secretHash[:], nonceHash) == false { + return fmt.Errorf("Secret doesn't match") + } + + certHash := sha1.Sum(keypub[:]) + + if bytes.Equal(certHash[:], keyHash) == false { + return fmt.Errorf("Key doesn't match") + } + + return nil +} From 4510ce391fc93318dc18bc678f71e51ce6bc0669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Fri, 1 Apr 2016 15:23:07 +0200 Subject: [PATCH 0063/1304] Godeps: bump CNI to v0.2.0-rc0 --- Godeps/Godeps.json | 69 ++++++++++--------- .../appc/cni/pkg/invoke/delegate.go | 39 +++++++++++ .../github.com/appc/cni/pkg/invoke/exec.go | 5 -- .../github.com/appc/cni/pkg/invoke/find.go | 34 +++++---- .../src/github.com/appc/cni/pkg/ip/ipmasq.go | 12 ++-- .../src/github.com/appc/cni/pkg/ipam/ipam.go | 10 +-- .../src/github.com/appc/cni/pkg/ns/ns.go | 7 +- .../src/github.com/appc/cni/pkg/types/args.go | 45 +++++++++++- .../github.com/appc/cni/pkg/utils/utils.go | 27 ++++++++ .../cni/plugins/ipam/host-local/allocator.go | 4 +- .../cni/plugins/ipam/host-local/config.go | 5 +- .../appc/cni/plugins/ipam/host-local/main.go | 7 -- .../appc/cni/plugins/main/bridge/bridge.go | 6 +- .../appc/cni/plugins/main/ptp/ptp.go | 14 ++-- .../appc/cni/plugins/meta/flannel/flannel.go | 6 +- 15 files changed, 199 insertions(+), 91 deletions(-) create mode 100644 Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/delegate.go create mode 100644 Godeps/_workspace/src/github.com/appc/cni/pkg/utils/utils.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 6552414950..5b590a543f 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -18,83 +18,88 @@ "Deps": [ { "ImportPath": "github.com/appc/cni/pkg/invoke", - "Comment": "v0.1.0-84-gb7ff8ab", - "Rev": "b7ff8ab158bd2fbc700d0fe6e0a58712970fabc0" + "Comment": "v0.2.0-rc0", + "Rev": "0046767be795f629180e0713b71822b731531997" }, { "ImportPath": "github.com/appc/cni/pkg/ip", - "Comment": "v0.1.0-84-gb7ff8ab", - "Rev": "b7ff8ab158bd2fbc700d0fe6e0a58712970fabc0" + "Comment": "v0.2.0-rc0", + "Rev": "0046767be795f629180e0713b71822b731531997" }, { "ImportPath": "github.com/appc/cni/pkg/ipam", - "Comment": "v0.1.0-84-gb7ff8ab", - "Rev": "b7ff8ab158bd2fbc700d0fe6e0a58712970fabc0" + "Comment": "v0.2.0-rc0", + "Rev": "0046767be795f629180e0713b71822b731531997" }, { "ImportPath": "github.com/appc/cni/pkg/ns", - "Comment": "v0.1.0-84-gb7ff8ab", - "Rev": "b7ff8ab158bd2fbc700d0fe6e0a58712970fabc0" + "Comment": "v0.2.0-rc0", + "Rev": "0046767be795f629180e0713b71822b731531997" }, { "ImportPath": "github.com/appc/cni/pkg/skel", - "Comment": "v0.1.0-84-gb7ff8ab", - "Rev": "b7ff8ab158bd2fbc700d0fe6e0a58712970fabc0" + "Comment": "v0.2.0-rc0", + "Rev": "0046767be795f629180e0713b71822b731531997" }, { "ImportPath": "github.com/appc/cni/pkg/types", - "Comment": "v0.1.0-84-gb7ff8ab", - "Rev": "b7ff8ab158bd2fbc700d0fe6e0a58712970fabc0" + "Comment": "v0.2.0-rc0", + "Rev": "0046767be795f629180e0713b71822b731531997" + }, + { + "ImportPath": "github.com/appc/cni/pkg/utils", + "Comment": "v0.2.0-rc0", + "Rev": "0046767be795f629180e0713b71822b731531997" }, { "ImportPath": "github.com/appc/cni/plugins/ipam/dhcp", - "Comment": "v0.1.0-84-gb7ff8ab", - "Rev": "b7ff8ab158bd2fbc700d0fe6e0a58712970fabc0" + "Comment": "v0.2.0-rc0", + "Rev": "0046767be795f629180e0713b71822b731531997" }, { "ImportPath": "github.com/appc/cni/plugins/ipam/host-local", - "Comment": "v0.1.0-84-gb7ff8ab", - "Rev": "b7ff8ab158bd2fbc700d0fe6e0a58712970fabc0" + "Comment": "v0.2.0-rc0", + "Rev": "0046767be795f629180e0713b71822b731531997" }, { "ImportPath": "github.com/appc/cni/plugins/ipam/host-local/backend", - "Comment": "v0.1.0-84-gb7ff8ab158bd", - "Rev": "b7ff8ab158bd2fbc700d0fe6e0a58712970fabc0" + "Comment": "v0.2.0-rc0", + "Rev": "0046767be795f629180e0713b71822b731531997" }, { "ImportPath": "github.com/appc/cni/plugins/ipam/host-local/backend/disk", - "Comment": "v0.1.0-84-gb7ff8ab158bd", - "Rev": "b7ff8ab158bd2fbc700d0fe6e0a58712970fabc0" + "Comment": "v0.2.0-rc0", + "Rev": "0046767be795f629180e0713b71822b731531997" }, { "ImportPath": "github.com/appc/cni/plugins/main/bridge", - "Comment": "v0.1.0-84-gb7ff8ab", - "Rev": "b7ff8ab158bd2fbc700d0fe6e0a58712970fabc0" + "Comment": "v0.2.0-rc0", + "Rev": "0046767be795f629180e0713b71822b731531997" }, { "ImportPath": "github.com/appc/cni/plugins/main/ipvlan", - "Comment": "v0.1.0-84-gb7ff8ab", - "Rev": "b7ff8ab158bd2fbc700d0fe6e0a58712970fabc0" + "Comment": "v0.2.0-rc0", + "Rev": "0046767be795f629180e0713b71822b731531997" }, { "ImportPath": "github.com/appc/cni/plugins/main/macvlan", - "Comment": "v0.1.0-84-gb7ff8ab", - "Rev": "b7ff8ab158bd2fbc700d0fe6e0a58712970fabc0" + "Comment": "v0.2.0-rc0", + "Rev": "0046767be795f629180e0713b71822b731531997" }, { "ImportPath": "github.com/appc/cni/plugins/main/ptp", - "Comment": "v0.1.0-84-gb7ff8ab", - "Rev": "b7ff8ab158bd2fbc700d0fe6e0a58712970fabc0" + "Comment": "v0.2.0-rc0", + "Rev": "0046767be795f629180e0713b71822b731531997" }, { "ImportPath": "github.com/appc/cni/plugins/meta/flannel", - "Comment": "v0.1.0-84-gb7ff8ab", - "Rev": "b7ff8ab158bd2fbc700d0fe6e0a58712970fabc0" + "Comment": "v0.2.0-rc0", + "Rev": "0046767be795f629180e0713b71822b731531997" }, { "ImportPath": "github.com/appc/cni/plugins/meta/tuning", - "Comment": "v0.1.0-84-gb7ff8ab", - "Rev": "b7ff8ab158bd2fbc700d0fe6e0a58712970fabc0" + "Comment": "v0.2.0-rc0", + "Rev": "0046767be795f629180e0713b71822b731531997" }, { "ImportPath": "github.com/appc/docker2aci/lib", diff --git a/Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/delegate.go b/Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/delegate.go new file mode 100644 index 0000000000..9864e6f53e --- /dev/null +++ b/Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/delegate.go @@ -0,0 +1,39 @@ +package invoke + +import ( + "fmt" + "os" + "strings" + + "github.com/appc/cni/pkg/types" +) + +func DelegateAdd(delegatePlugin string, netconf []byte) (*types.Result, error) { + if os.Getenv("CNI_COMMAND") != "ADD" { + return nil, fmt.Errorf("CNI_COMMAND is not ADD") + } + + paths := strings.Split(os.Getenv("CNI_PATH"), ":") + + pluginPath, err := FindInPath(delegatePlugin, paths) + if err != nil { + return nil, err + } + + return ExecPluginWithResult(pluginPath, netconf, ArgsFromEnv()) +} + +func DelegateDel(delegatePlugin string, netconf []byte) error { + if os.Getenv("CNI_COMMAND") != "DEL" { + return fmt.Errorf("CNI_COMMAND is not DEL") + } + + paths := strings.Split(os.Getenv("CNI_PATH"), ":") + + pluginPath, err := FindInPath(delegatePlugin, paths) + if err != nil { + return err + } + + return ExecPluginWithoutResult(pluginPath, netconf, ArgsFromEnv()) +} diff --git a/Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/exec.go b/Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/exec.go index 905649707b..337bfcb870 100644 --- a/Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/exec.go +++ b/Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/exec.go @@ -20,7 +20,6 @@ import ( "fmt" "os" "os/exec" - "path/filepath" "github.com/appc/cni/pkg/types" ) @@ -58,10 +57,6 @@ func ExecPluginWithoutResult(pluginPath string, netconf []byte, args CNIArgs) er } func execPlugin(pluginPath string, netconf []byte, args CNIArgs) ([]byte, error) { - if pluginPath == "" { - return nil, fmt.Errorf("could not find %q plugin", filepath.Base(pluginPath)) - } - stdout := &bytes.Buffer{} c := exec.Cmd{ diff --git a/Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/find.go b/Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/find.go index 82f9a9b766..3b03790711 100644 --- a/Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/find.go +++ b/Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/find.go @@ -15,23 +15,33 @@ package invoke import ( + "fmt" "os" "path/filepath" - "strings" ) -func FindInPath(plugin string, path []string) string { - for _, p := range path { - fullname := filepath.Join(p, plugin) - if fi, err := os.Stat(fullname); err == nil && fi.Mode().IsRegular() { - return fullname +// FindInPath returns the full path of the plugin by searching in the provided path +func FindInPath(plugin string, paths []string) (string, error) { + if plugin == "" { + return "", fmt.Errorf("no plugin name provided") + } + + if len(paths) == 0 { + return "", fmt.Errorf("no paths provided") + } + + var fullpath string + for _, path := range paths { + full := filepath.Join(path, plugin) + if fi, err := os.Stat(full); err == nil && fi.Mode().IsRegular() { + fullpath = full + break } } - return "" -} -// Find returns the full path of the plugin by searching in CNI_PATH -func Find(plugin string) string { - paths := strings.Split(os.Getenv("CNI_PATH"), ":") - return FindInPath(plugin, paths) + if fullpath == "" { + return "", fmt.Errorf("failed to find plugin %q in path %s", plugin, paths) + } + + return fullpath, nil } diff --git a/Godeps/_workspace/src/github.com/appc/cni/pkg/ip/ipmasq.go b/Godeps/_workspace/src/github.com/appc/cni/pkg/ip/ipmasq.go index 6901f69e96..8ee279717a 100644 --- a/Godeps/_workspace/src/github.com/appc/cni/pkg/ip/ipmasq.go +++ b/Godeps/_workspace/src/github.com/appc/cni/pkg/ip/ipmasq.go @@ -23,7 +23,7 @@ import ( // SetupIPMasq installs iptables rules to masquerade traffic // coming from ipn and going outside of it -func SetupIPMasq(ipn *net.IPNet, chain string) error { +func SetupIPMasq(ipn *net.IPNet, chain string, comment string) error { ipt, err := iptables.New() if err != nil { return fmt.Errorf("failed to locate iptables: %v", err) @@ -36,25 +36,25 @@ func SetupIPMasq(ipn *net.IPNet, chain string) error { } } - if err = ipt.AppendUnique("nat", chain, "-d", ipn.String(), "-j", "ACCEPT"); err != nil { + if err = ipt.AppendUnique("nat", chain, "-d", ipn.String(), "-j", "ACCEPT", "-m", "comment", "--comment", comment); err != nil { return err } - if err = ipt.AppendUnique("nat", chain, "!", "-d", "224.0.0.0/4", "-j", "MASQUERADE"); err != nil { + if err = ipt.AppendUnique("nat", chain, "!", "-d", "224.0.0.0/4", "-j", "MASQUERADE", "-m", "comment", "--comment", comment); err != nil { return err } - return ipt.AppendUnique("nat", "POSTROUTING", "-s", ipn.String(), "-j", chain) + return ipt.AppendUnique("nat", "POSTROUTING", "-s", ipn.String(), "-j", chain, "-m", "comment", "--comment", comment) } // TeardownIPMasq undoes the effects of SetupIPMasq -func TeardownIPMasq(ipn *net.IPNet, chain string) error { +func TeardownIPMasq(ipn *net.IPNet, chain string, comment string) error { ipt, err := iptables.New() if err != nil { return fmt.Errorf("failed to locate iptables: %v", err) } - if err = ipt.Delete("nat", "POSTROUTING", "-s", ipn.String(), "-j", chain); err != nil { + if err = ipt.Delete("nat", "POSTROUTING", "-s", ipn.String(), "-j", chain, "-m", "comment", "--comment", comment); err != nil { return err } diff --git a/Godeps/_workspace/src/github.com/appc/cni/pkg/ipam/ipam.go b/Godeps/_workspace/src/github.com/appc/cni/pkg/ipam/ipam.go index 4920838a8b..f0adfb7f60 100644 --- a/Godeps/_workspace/src/github.com/appc/cni/pkg/ipam/ipam.go +++ b/Godeps/_workspace/src/github.com/appc/cni/pkg/ipam/ipam.go @@ -26,17 +26,11 @@ import ( ) func ExecAdd(plugin string, netconf []byte) (*types.Result, error) { - if os.Getenv("CNI_COMMAND") != "ADD" { - return nil, fmt.Errorf("CNI_COMMAND is not ADD") - } - return invoke.ExecPluginWithResult(invoke.Find(plugin), netconf, invoke.ArgsFromEnv()) + return invoke.DelegateAdd(plugin, netconf) } func ExecDel(plugin string, netconf []byte) error { - if os.Getenv("CNI_COMMAND") != "DEL" { - return fmt.Errorf("CNI_COMMAND is not DEL") - } - return invoke.ExecPluginWithoutResult(invoke.Find(plugin), netconf, invoke.ArgsFromEnv()) + return invoke.DelegateDel(plugin, netconf) } // ConfigureIface takes the result of IPAM plugin and diff --git a/Godeps/_workspace/src/github.com/appc/cni/pkg/ns/ns.go b/Godeps/_workspace/src/github.com/appc/cni/pkg/ns/ns.go index 9996aac728..4f0814f1d6 100644 --- a/Godeps/_workspace/src/github.com/appc/cni/pkg/ns/ns.go +++ b/Godeps/_workspace/src/github.com/appc/cni/pkg/ns/ns.go @@ -66,7 +66,8 @@ func WithNetNSPath(nspath string, lockThread bool, f func(*os.File) error) error // Changing namespaces must be done on a goroutine that has been // locked to an OS thread. If lockThread arg is true, this function // locks the goroutine prior to change namespace and unlocks before -// returning +// returning. If the closure returns an error, WithNetNS attempts to +// restore the original namespace before returning. func WithNetNS(ns *os.File, lockThread bool, f func(*os.File) error) error { if lockThread { runtime.LockOSThread() @@ -82,11 +83,11 @@ func WithNetNS(ns *os.File, lockThread bool, f func(*os.File) error) error { if err = SetNS(ns, syscall.CLONE_NEWNET); err != nil { return fmt.Errorf("Error switching to ns %v: %v", ns.Name(), err) } + defer SetNS(thisNS, syscall.CLONE_NEWNET) // switch back if err = f(thisNS); err != nil { return err } - // switch back - return SetNS(thisNS, syscall.CLONE_NEWNET) + return nil } diff --git a/Godeps/_workspace/src/github.com/appc/cni/pkg/types/args.go b/Godeps/_workspace/src/github.com/appc/cni/pkg/types/args.go index 3c0fd88e9c..3b667b0f20 100644 --- a/Godeps/_workspace/src/github.com/appc/cni/pkg/types/args.go +++ b/Godeps/_workspace/src/github.com/appc/cni/pkg/types/args.go @@ -21,6 +21,39 @@ import ( "strings" ) +// UnmarshallableBool typedef for builtin bool +// because builtin type's methods can't be declared +type UnmarshallableBool bool + +// UnmarshalText implements the encoding.TextUnmarshaler interface. +// Returns boolean true if the string is "1" or "[Tt]rue" +// Returns boolean false if the string is "0" or "[Ff]alse" +func (b *UnmarshallableBool) UnmarshalText(data []byte) error { + s := strings.ToLower(string(data)) + switch s { + case "1", "true": + *b = true + case "0", "false": + *b = false + default: + return fmt.Errorf("Boolean unmarshal error: invalid input %s", s) + } + return nil +} + +// CommonArgs contains the IgnoreUnknown argument +// and must be embedded by all Arg structs +type CommonArgs struct { + IgnoreUnknown UnmarshallableBool `json:"ignoreunknown,omitempty"` +} + +// GetKeyField is a helper function to receive Values +// Values that represent a pointer to a struct +func GetKeyField(keyString string, v reflect.Value) reflect.Value { + return v.Elem().FieldByName(keyString) +} + +// LoadArgs parses args from a string in the form "K=V;K2=V2;..." func LoadArgs(args string, container interface{}) error { if args == "" { return nil @@ -29,6 +62,7 @@ func LoadArgs(args string, container interface{}) error { containerValue := reflect.ValueOf(container) pairs := strings.Split(args, ";") + unknownArgs := []string{} for _, pair := range pairs { kv := strings.Split(pair, "=") if len(kv) != 2 { @@ -36,15 +70,22 @@ func LoadArgs(args string, container interface{}) error { } keyString := kv[0] valueString := kv[1] - keyField := containerValue.Elem().FieldByName(keyString) + keyField := GetKeyField(keyString, containerValue) if !keyField.IsValid() { - return fmt.Errorf("ARGS: invalid key %q", keyString) + unknownArgs = append(unknownArgs, pair) + continue } + u := keyField.Addr().Interface().(encoding.TextUnmarshaler) err := u.UnmarshalText([]byte(valueString)) if err != nil { return fmt.Errorf("ARGS: error parsing value of pair %q: %v)", pair, err) } } + + isIgnoreUnknown := GetKeyField("IgnoreUnknown", containerValue).Bool() + if len(unknownArgs) > 0 && !isIgnoreUnknown { + return fmt.Errorf("ARGS: unknown args %q", unknownArgs) + } return nil } diff --git a/Godeps/_workspace/src/github.com/appc/cni/pkg/utils/utils.go b/Godeps/_workspace/src/github.com/appc/cni/pkg/utils/utils.go new file mode 100644 index 0000000000..7ec139fd8f --- /dev/null +++ b/Godeps/_workspace/src/github.com/appc/cni/pkg/utils/utils.go @@ -0,0 +1,27 @@ +package utils + +import ( + "crypto/sha512" + "fmt" +) + +const ( + maxChainLength = 28 + chainPrefix = "CNI-" + prefixLength = len(chainPrefix) +) + +// Generates a chain name to be used with iptables. +// Ensures that the generated chain name is exactly +// maxChainLength chars in length +func FormatChainName(name string, id string) string { + chainBytes := sha512.Sum512([]byte(name + id)) + chain := fmt.Sprintf("%s%x", chainPrefix, chainBytes) + return chain[:maxChainLength] +} + +// FormatComment returns a comment used for easier +// rule identification within iptables. +func FormatComment(name string, id string) string { + return fmt.Sprintf("name: %q id: %q", name, id) +} diff --git a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/allocator.go b/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/allocator.go index 159e2cb726..2b867ce525 100644 --- a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/allocator.go +++ b/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/allocator.go @@ -104,7 +104,7 @@ func (a *IPAllocator) Get(id string) (*types.IPConfig, error) { if reserved { return &types.IPConfig{ - IP: net.IPNet{requestedIP, a.conf.Subnet.Mask}, + IP: net.IPNet{IP: requestedIP, Mask: a.conf.Subnet.Mask}, Gateway: gw, Routes: a.conf.Routes, }, nil @@ -124,7 +124,7 @@ func (a *IPAllocator) Get(id string) (*types.IPConfig, error) { } if reserved { return &types.IPConfig{ - IP: net.IPNet{cur, a.conf.Subnet.Mask}, + IP: net.IPNet{IP: cur, Mask: a.conf.Subnet.Mask}, Gateway: gw, Routes: a.conf.Routes, }, nil diff --git a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/config.go b/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/config.go index 53ab396b3b..08ca07e384 100644 --- a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/config.go +++ b/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/config.go @@ -35,6 +35,7 @@ type IPAMConfig struct { } type IPAMArgs struct { + types.CommonArgs IP net.IP `json:"ip,omitempty"` } @@ -51,8 +52,8 @@ func LoadIPAMConfig(bytes []byte, args string) (*IPAMConfig, error) { } if args != "" { - ipamArgs := IPAMArgs{} - err := types.LoadArgs(args, &ipamArgs) + n.IPAM.Args = &IPAMArgs{} + err := types.LoadArgs(args, n.IPAM.Args) if err != nil { return nil, err } diff --git a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/main.go b/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/main.go index f1d7d6ae44..9f67e8a507 100644 --- a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/main.go +++ b/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/main.go @@ -37,13 +37,6 @@ func cmdAdd(args *skel.CmdArgs) error { } defer store.Close() - ipamArgs := IPAMArgs{} - err = types.LoadArgs(args.Args, &ipamArgs) - if err != nil { - return err - } - ipamConf.Args = &ipamArgs - allocator, err := NewIPAllocator(ipamConf, store) if err != nil { return err diff --git a/Godeps/_workspace/src/github.com/appc/cni/plugins/main/bridge/bridge.go b/Godeps/_workspace/src/github.com/appc/cni/plugins/main/bridge/bridge.go index 49c0aa5d23..e4bc106c00 100644 --- a/Godeps/_workspace/src/github.com/appc/cni/plugins/main/bridge/bridge.go +++ b/Godeps/_workspace/src/github.com/appc/cni/plugins/main/bridge/bridge.go @@ -28,6 +28,7 @@ import ( "github.com/appc/cni/pkg/ns" "github.com/appc/cni/pkg/skel" "github.com/appc/cni/pkg/types" + "github.com/appc/cni/pkg/utils" "github.com/vishvananda/netlink" ) @@ -220,8 +221,9 @@ func cmdAdd(args *skel.CmdArgs) error { } if n.IPMasq { - chain := "CNI-" + n.Name - if err = ip.SetupIPMasq(ip.Network(&result.IP4.IP), chain); err != nil { + chain := utils.FormatChainName(n.Name, args.ContainerID) + comment := utils.FormatComment(n.Name, args.ContainerID) + if err = ip.SetupIPMasq(ip.Network(&result.IP4.IP), chain, comment); err != nil { return err } } diff --git a/Godeps/_workspace/src/github.com/appc/cni/plugins/main/ptp/ptp.go b/Godeps/_workspace/src/github.com/appc/cni/plugins/main/ptp/ptp.go index 3cb8f64388..3035c643f7 100644 --- a/Godeps/_workspace/src/github.com/appc/cni/plugins/main/ptp/ptp.go +++ b/Godeps/_workspace/src/github.com/appc/cni/plugins/main/ptp/ptp.go @@ -15,7 +15,6 @@ package main import ( - "crypto/sha512" "encoding/json" "errors" "fmt" @@ -30,6 +29,7 @@ import ( "github.com/appc/cni/pkg/ns" "github.com/appc/cni/pkg/skel" "github.com/appc/cni/pkg/types" + "github.com/appc/cni/pkg/utils" ) func init() { @@ -178,9 +178,9 @@ func cmdAdd(args *skel.CmdArgs) error { } if conf.IPMasq { - h := sha512.Sum512([]byte(args.ContainerID)) - chain := fmt.Sprintf("CNI-%s-%x", conf.Name, h[:8]) - if err = ip.SetupIPMasq(&result.IP4.IP, chain); err != nil { + chain := utils.FormatChainName(conf.Name, args.ContainerID) + comment := utils.FormatComment(conf.Name, args.ContainerID) + if err = ip.SetupIPMasq(&result.IP4.IP, chain, comment); err != nil { return err } } @@ -206,9 +206,9 @@ func cmdDel(args *skel.CmdArgs) error { } if conf.IPMasq { - h := sha512.Sum512([]byte(args.ContainerID)) - chain := fmt.Sprintf("CNI-%s-%x", conf.Name, h[:8]) - if err = ip.TeardownIPMasq(ipn, chain); err != nil { + chain := utils.FormatChainName(conf.Name, args.ContainerID) + comment := utils.FormatComment(conf.Name, args.ContainerID) + if err = ip.TeardownIPMasq(ipn, chain, comment); err != nil { return err } } diff --git a/Godeps/_workspace/src/github.com/appc/cni/plugins/meta/flannel/flannel.go b/Godeps/_workspace/src/github.com/appc/cni/plugins/meta/flannel/flannel.go index af629738d6..6653baca2a 100644 --- a/Godeps/_workspace/src/github.com/appc/cni/plugins/meta/flannel/flannel.go +++ b/Godeps/_workspace/src/github.com/appc/cni/plugins/meta/flannel/flannel.go @@ -29,7 +29,7 @@ import ( "strconv" "strings" - "github.com/appc/cni/pkg/ipam" + "github.com/appc/cni/pkg/invoke" "github.com/appc/cni/pkg/skel" "github.com/appc/cni/pkg/types" ) @@ -155,7 +155,7 @@ func delegateAdd(cid string, netconf map[string]interface{}) error { return err } - result, err := ipam.ExecAdd(netconf["type"].(string), netconfBytes) + result, err := invoke.DelegateAdd(netconf["type"].(string), netconfBytes) if err != nil { return err } @@ -245,7 +245,7 @@ func cmdDel(args *skel.CmdArgs) error { return fmt.Errorf("failed to parse netconf: %v", err) } - return ipam.ExecDel(n.Type, netconfBytes) + return invoke.DelegateDel(n.Type, netconfBytes) } func main() { From eabbfa02c5d7db1c652ac8a3eeb0692240a1cd8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Fri, 1 Apr 2016 15:26:39 +0200 Subject: [PATCH 0064/1304] Godeps: bump docker2aci to v0.9.3 --- Godeps/Godeps.json | 40 +++++++++---------- .../internal/backend/repository/repository.go | 5 +-- .../backend/repository/repository2.go | 5 +-- .../appc/docker2aci/lib/internal/util/util.go | 22 ++++++++++ .../github.com/appc/docker2aci/lib/version.go | 2 +- 5 files changed, 47 insertions(+), 27 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 5b590a543f..4128e8078c 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -103,53 +103,53 @@ }, { "ImportPath": "github.com/appc/docker2aci/lib", - "Comment": "v0.9.2", - "Rev": "549d085bf2a55d8e8079f1186c425cee7fdcc4d5" + "Comment": "v0.9.3", + "Rev": "3b996e400e8937a7433b1759f846215e1d3b2fbd" }, { "ImportPath": "github.com/appc/docker2aci/lib/common", - "Comment": "v0.9.2", - "Rev": "549d085bf2a55d8e8079f1186c425cee7fdcc4d5" + "Comment": "v0.9.3", + "Rev": "3b996e400e8937a7433b1759f846215e1d3b2fbd" }, { "ImportPath": "github.com/appc/docker2aci/lib/internal", - "Comment": "v0.9.2", - "Rev": "549d085bf2a55d8e8079f1186c425cee7fdcc4d5" + "Comment": "v0.9.3", + "Rev": "3b996e400e8937a7433b1759f846215e1d3b2fbd" }, { "ImportPath": "github.com/appc/docker2aci/lib/internal/backend/file", - "Comment": "v0.9.2", - "Rev": "549d085bf2a55d8e8079f1186c425cee7fdcc4d5" + "Comment": "v0.9.3", + "Rev": "3b996e400e8937a7433b1759f846215e1d3b2fbd" }, { "ImportPath": "github.com/appc/docker2aci/lib/internal/backend/repository", - "Comment": "v0.9.2", - "Rev": "549d085bf2a55d8e8079f1186c425cee7fdcc4d5" + "Comment": "v0.9.3", + "Rev": "3b996e400e8937a7433b1759f846215e1d3b2fbd" }, { "ImportPath": "github.com/appc/docker2aci/lib/internal/docker", - "Comment": "v0.9.2", - "Rev": "549d085bf2a55d8e8079f1186c425cee7fdcc4d5" + "Comment": "v0.9.3", + "Rev": "3b996e400e8937a7433b1759f846215e1d3b2fbd" }, { "ImportPath": "github.com/appc/docker2aci/lib/internal/tarball", - "Comment": "v0.9.2", - "Rev": "549d085bf2a55d8e8079f1186c425cee7fdcc4d5" + "Comment": "v0.9.3", + "Rev": "3b996e400e8937a7433b1759f846215e1d3b2fbd" }, { "ImportPath": "github.com/appc/docker2aci/lib/internal/types", - "Comment": "v0.9.2", - "Rev": "549d085bf2a55d8e8079f1186c425cee7fdcc4d5" + "Comment": "v0.9.3", + "Rev": "3b996e400e8937a7433b1759f846215e1d3b2fbd" }, { "ImportPath": "github.com/appc/docker2aci/lib/internal/util", - "Comment": "v0.9.2", - "Rev": "549d085bf2a55d8e8079f1186c425cee7fdcc4d5" + "Comment": "v0.9.3", + "Rev": "3b996e400e8937a7433b1759f846215e1d3b2fbd" }, { "ImportPath": "github.com/appc/docker2aci/pkg/log", - "Comment": "v0.9.2", - "Rev": "549d085bf2a55d8e8079f1186c425cee7fdcc4d5" + "Comment": "v0.9.3", + "Rev": "3b996e400e8937a7433b1759f846215e1d3b2fbd" }, { "ImportPath": "github.com/appc/goaci/proj2aci", diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository.go index 0f791ee5ba..3c6715e8b3 100644 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository.go +++ b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository.go @@ -20,7 +20,6 @@ package repository import ( - "crypto/tls" "fmt" "net/http" "path" @@ -28,6 +27,7 @@ import ( "github.com/appc/docker2aci/lib/common" "github.com/appc/docker2aci/lib/internal/docker" "github.com/appc/docker2aci/lib/internal/types" + "github.com/appc/docker2aci/lib/internal/util" "github.com/appc/spec/schema" ) @@ -137,8 +137,7 @@ func (rb *RepositoryBackend) supportsRegistry(indexURL string, version registryV rb.setBasicAuth(req) - tr := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: rb.insecure}} - client := &http.Client{Transport: tr} + client := util.GetTLSClient(rb.insecure) res, err = client.Do(req) return } diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository2.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository2.go index 974a690985..b685cf8eaa 100644 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository2.go +++ b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository2.go @@ -15,7 +15,6 @@ package repository import ( - "crypto/tls" "encoding/json" "errors" "fmt" @@ -32,6 +31,7 @@ import ( "github.com/appc/docker2aci/lib/common" "github.com/appc/docker2aci/lib/internal" "github.com/appc/docker2aci/lib/internal/types" + "github.com/appc/docker2aci/lib/internal/util" "github.com/appc/docker2aci/pkg/log" "github.com/appc/spec/schema" "github.com/coreos/ioprogress" @@ -315,8 +315,7 @@ func (rb *RepositoryBackend) makeRequest(req *http.Request, repo string) (*http. } } - tr := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: rb.insecure}} - client := &http.Client{Transport: tr} + client := util.GetTLSClient(rb.insecure) res, err := client.Do(req) if err != nil { return nil, err diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/util/util.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/util/util.go index 07cde45611..ebaafca62c 100644 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/util/util.go +++ b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/util/util.go @@ -19,7 +19,9 @@ package util import ( + "crypto/tls" "fmt" + "net/http" "github.com/appc/spec/pkg/acirenderer" ) @@ -59,3 +61,23 @@ func IndexOf(list []string, el string) int { } return -1 } + +// GetTLSClient gets an HTTP client that behaves like the default HTTP +// client, but optionally skips the TLS certificate verification. +func GetTLSClient(skipTLSCheck bool) *http.Client { + if !skipTLSCheck { + return http.DefaultClient + } + client := *http.DefaultClient + // Default transport is hidden behind the RoundTripper + // interface, so we can't easily make a copy of it. If this + // ever panics, we will have to adapt. + realTransport := http.DefaultTransport.(*http.Transport) + tr := *realTransport + if tr.TLSClientConfig == nil { + tr.TLSClientConfig = &tls.Config{} + } + tr.TLSClientConfig.InsecureSkipVerify = true + client.Transport = &tr + return &client +} diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/version.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/version.go index 3bf7c4e45e..6120c38b82 100644 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/version.go +++ b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/version.go @@ -16,5 +16,5 @@ package docker2aci import "github.com/appc/spec/schema" -var Version = "0.9.2" +var Version = "0.9.3" var AppcVersion = schema.AppContainerVersion From 206a8ce1c1c55dfc71f2ad5a656822628399962f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Fri, 1 Apr 2016 15:13:18 +0200 Subject: [PATCH 0065/1304] networking/kvm: add comment to IP masquerading The function signature for SetupIPMasq() and TeardownIPMasq() changed. --- networking/kvm.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/networking/kvm.go b/networking/kvm.go index b702554469..e353d896c4 100644 --- a/networking/kvm.go +++ b/networking/kvm.go @@ -42,6 +42,7 @@ const ( defaultBrName = "kvm-cni0" defaultSubnetFile = "/run/flannel/subnet.env" defaultMTU = 1500 + masqComment = "rkt-lkvm masquerading" ) type BridgeNetConf struct { @@ -534,7 +535,7 @@ func kvmSetup(podRoot string, podID types.UUID, fps []ForwardedPort, netList com if err := ip.SetupIPMasq(&net.IPNet{ IP: n.runtime.IP, Mask: net.IPMask(n.runtime.Mask), - }, chain); err != nil { + }, chain, masqComment); err != nil { return nil, err } } @@ -591,7 +592,7 @@ func (n *Networking) teardownKvmNets() { err := ip.TeardownIPMasq(&net.IPNet{ IP: an.runtime.IP, Mask: net.IPMask(an.runtime.Mask), - }, chain) + }, chain, masqComment) if err != nil { stderr.PrintE("error on removing masquerading", err) } From 66ca7ac0fd48ffd8f3fbf2d2fe999b261132da65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Thu, 31 Mar 2016 16:22:01 +0200 Subject: [PATCH 0066/1304] ROADMAP: update --- ROADMAP.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index e5daecc49b..e25a5f0e53 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -9,23 +9,21 @@ The version of the spec that rkt implements can be seen in the output of `rkt ve rkt's version 1.0 release marks the command line user interface and on-disk data structures as stable and reliable for external development. The (optional) API for pod inspection is not yet completely stabilized, but is quite usable. -### rkt 1.3 (March) +### rkt 1.4 (April) - enhanced DNS configuration [#2044](https://github.com/coreos/rkt/issues/2044) -- app exit status propagation [#1460](https://github.com/coreos/rkt/issues/1460) -- different shared namespace execution modes [#1433](https://github.com/coreos/rkt/issues/1433) -- stage1 benchmarking [#1788](https://github.com/coreos/rkt/issues/1788) - user configuration for stage1 [#2013](https://github.com/coreos/rkt/issues/2013) +- `rkt fly` as top-level command [#1889](https://github.com/coreos/rkt/issues/1889) +- IPv6 support [appc/cni#31](https://github.com/appc/cni/issues/31) +- stage1 benchmarking [#1788](https://github.com/coreos/rkt/issues/1788) - rkt runs on Fedora with SELinux in enforcing mode -### rkt 1.4 (April) +### rkt 1.5 (April) - stable API - full integration with Kubernetes (aka "rktnetes") - full integration with `machinectl login` and `systemd-run` [#1463](https://github.com/coreos/rkt/issues/1463) -- `rkt fly` as top-level command [#1889](https://github.com/coreos/rkt/issues/1889) - attach to the app's stdin/stdout [#1799](https://github.com/coreos/rkt/issues/1799) -- IPv6 support [appc/cni#31](https://github.com/appc/cni/issues/31) - packaged for more distributions - Debian [#1307](https://github.com/coreos/rkt/issues/1307) - CentOS [#1305](https://github.com/coreos/rkt/issues/1305) From 03b7de4bf9d62ca250bcc20aa67b65e7ad422bd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Thu, 31 Mar 2016 17:54:00 +0200 Subject: [PATCH 0067/1304] CHANGELOG: add v1.3.0 --- CHANGELOG.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89fbe458f5..ab0a4d4792 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,31 @@ +## v1.3.0 + +This release includes a number of new features and bugfixes like the long-awaited propagation of apps' exit status. + +#### New features and UX changes + +- Propagate exit status from apps inside the pod to rkt ([#2308](https://github.com/coreos/rkt/pull/2308)). Previously, if an app exited with a non-zero exit status, rkt's exit status would still be 0. Now, if an app fails, its exit status will be propagated to the outside. While this was partially implemented in some stage1 flavors since rkt v1.1.0, it now works in the default coreos flavor. +- Check signatures for stage1 images by default, especially useful when stage1 images are downloaded from the Internet ([#2336](https://github.com/coreos/rkt/pull/2336)). + This doesn't affect the following cases: + - The stage1 image is already in the store + - The stage1 image is in the default directory configured at build time + - The stage1 image is the default one and it is in the same directory as the rkt binary +- Allow downloading of insecure public keys with the `pubkey` insecure option ([#2278](https://github.com/coreos/rkt/pull/2278)). +- Implement Docker volume semantics ([#2315](https://github.com/coreos/rkt/pull/2315)). Docker volumes are initialized with the files in the image if they exist, unless a host directory is mounted there. Implement that behavior in rkt when it runs a Docker converted image. + +#### API service + +- Return the cgroup when getting information about running pods and add a new cgroup filter ([#2331](https://github.com/coreos/rkt/pull/2331)). + +#### Bug fixes + +- Avoid configuring more CPUs than the host has in the kvm flavor ([#2321](https://github.com/coreos/rkt/pull/2321)). +- Fix a bug where the proxy configuration wasn't forwarded to docker2aci ([docker2aci#147](https://github.com/appc/docker2aci/pull/147)). + +#### Notes + +- This release drops support for go1.4. + ## v1.2.1 This release fixes a couple of bugs we missed in 1.2.0. From 97b92aac8e4ea6b39b8d2e0a42b3d3a1b91c9092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Thu, 31 Mar 2016 17:58:38 +0200 Subject: [PATCH 0068/1304] version: bump to v1.3.0 --- Documentation/getting-started-ubuntu.md | 6 +++--- Documentation/running-fly-stage1.md | 4 ++-- Documentation/running-lkvm-stage1.md | 4 ++-- Documentation/subcommands/prepare.md | 2 +- Documentation/subcommands/version.md | 2 +- Documentation/trying-out-rkt.md | 6 +++--- configure.ac | 2 +- scripts/acbuild-rkt-builder.sh | 2 +- scripts/build-rir.sh | 2 +- tests/empty-image/manifest | 2 +- tests/image/manifest | 2 +- tests/rkt_exec_test.go | 2 +- tests/rkt_image_cat_manifest_test.go | 2 +- tests/rkt_image_export_test.go | 2 +- tests/rkt_image_render_test.go | 2 +- tests/rkt_os_arch_test.go | 2 +- 16 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Documentation/getting-started-ubuntu.md b/Documentation/getting-started-ubuntu.md index 86672711a7..591bc19fe9 100644 --- a/Documentation/getting-started-ubuntu.md +++ b/Documentation/getting-started-ubuntu.md @@ -15,9 +15,9 @@ vagrant up --provider virtualbox vagrant ssh sudo -s -wget https://github.com/coreos/rkt/releases/download/v1.2.1/rkt-v1.2.1.tar.gz -tar xzvf rkt-v1.2.1.tar.gz -cd rkt-v1.2.1 +wget https://github.com/coreos/rkt/releases/download/v1.3.0/rkt-v1.3.0.tar.gz +tar xzvf rkt-v1.3.0.tar.gz +cd rkt-v1.3.0 ./rkt help ``` diff --git a/Documentation/running-fly-stage1.md b/Documentation/running-fly-stage1.md index 04d33fc3d1..b1a370a42f 100644 --- a/Documentation/running-fly-stage1.md +++ b/Documentation/running-fly-stage1.md @@ -60,14 +60,14 @@ $ ./autogen.sh && ./configure --with-stage1-flavors=fly && make ``` For more details about configure parameters, see the [configure script parameters documentation](build-configure.md). -This will build the rkt binary and the stage1-fly.aci in `build-rkt-1.2.1+git/bin/`. +This will build the rkt binary and the stage1-fly.aci in `build-rkt-1.3.0+git/bin/`. ### Selecting stage1 at runtime Here is a quick example of how to use a container with the official fly stage1: ``` -# rkt run --stage1-name=coreos.com/rkt/stage1-fly:1.2.1 coreos.com/etcd:v2.2.5 +# rkt run --stage1-name=coreos.com/rkt/stage1-fly:1.3.0 coreos.com/etcd:v2.2.5 ``` If the image is not in the store, `--stage1-name` will perform discovery and fetch the image. diff --git a/Documentation/running-lkvm-stage1.md b/Documentation/running-lkvm-stage1.md index dd77c1b595..b66dbef611 100644 --- a/Documentation/running-lkvm-stage1.md +++ b/Documentation/running-lkvm-stage1.md @@ -13,7 +13,7 @@ $ ./autogen.sh && ./configure --with-stage1-flavors=kvm && make ``` For more details about configure parameters, see [configure script parameters documentation](build-configure.md). -This will build the rkt binary and the LKVM stage1-kvm.aci in `build-rkt-1.2.1+git/bin/`. +This will build the rkt binary and the LKVM stage1-kvm.aci in `build-rkt-1.3.0+git/bin/`. Provided you have hardware virtualization support and the [kernel KVM module](http://www.linux-kvm.org/page/Getting_the_kvm_kernel_modules) loaded (refer to your distribution for instructions), you can then run an image like you would normally do with rkt: @@ -84,7 +84,7 @@ If you want to run software that requires hypervisor isolation along with truste For example, to use the official lkvm stage1: ``` -# rkt run --stage1-name=coreos.com/rkt/stage1-kvm:1.2.1 coreos.com/etcd:v2.0.9 +# rkt run --stage1-name=coreos.com/rkt/stage1-kvm:1.3.0 coreos.com/etcd:v2.0.9 ... ``` diff --git a/Documentation/subcommands/prepare.md b/Documentation/subcommands/prepare.md index 9b1793dd91..0c9df9ca45 100644 --- a/Documentation/subcommands/prepare.md +++ b/Documentation/subcommands/prepare.md @@ -14,7 +14,7 @@ Therefore, the supported arguments are mostly the same as in `run` except runtim ``` # rkt prepare coreos.com/etcd:v2.0.10 rkt prepare coreos.com/etcd:v2.0.10 -rkt: using image from local store for image name coreos.com/rkt/stage1-coreos:1.2.1 +rkt: using image from local store for image name coreos.com/rkt/stage1-coreos:1.3.0 rkt: searching for app image coreos.com/etcd:v2.0.10 rkt: remote fetching from url https://github.com/coreos/etcd/releases/download/v2.0.10/etcd-v2.0.10-linux-amd64.aci prefix: "coreos.com/etcd" diff --git a/Documentation/subcommands/version.md b/Documentation/subcommands/version.md index 905dba5666..69cfbfbafb 100644 --- a/Documentation/subcommands/version.md +++ b/Documentation/subcommands/version.md @@ -6,7 +6,7 @@ This command prints the rkt version, the appc version rkt is built against, and ``` $ rkt version -rkt Version: 1.2.1 +rkt Version: 1.3.0 appc Version: 0.7.4 Go Version: go1.5.3 Go OS/Arch: linux/amd64 diff --git a/Documentation/trying-out-rkt.md b/Documentation/trying-out-rkt.md index 909c515bbb..e966deb92b 100644 --- a/Documentation/trying-out-rkt.md +++ b/Documentation/trying-out-rkt.md @@ -10,9 +10,9 @@ rkt consists of a single CLI tool, and is currently supported on amd64 Linux. A To download the rkt binary, simply grab the latest release directly from GitHub: ``` -wget https://github.com/coreos/rkt/releases/download/v1.2.1/rkt-v1.2.1.tar.gz -tar xzvf rkt-v1.2.1.tar.gz -cd rkt-v1.2.1 +wget https://github.com/coreos/rkt/releases/download/v1.3.0/rkt-v1.3.0.tar.gz +tar xzvf rkt-v1.3.0.tar.gz +cd rkt-v1.3.0 ./rkt help ``` diff --git a/configure.ac b/configure.ac index 19f06c020a..4df5fbe3d3 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.63]) -AC_INIT([rkt], [1.2.1+git], [https://github.com/coreos/rkt/issues]) +AC_INIT([rkt], [1.3.0], [https://github.com/coreos/rkt/issues]) AC_DEFUN([RKT_CHECK_PROG], [AS_VAR_IF([$1], [], diff --git a/scripts/acbuild-rkt-builder.sh b/scripts/acbuild-rkt-builder.sh index 1e5ef7a12a..76a49dd403 100755 --- a/scripts/acbuild-rkt-builder.sh +++ b/scripts/acbuild-rkt-builder.sh @@ -25,7 +25,7 @@ ACI_NAME=${ACI_NAME:-"coreos.com/rkt/builder"} BUILDDIR=/opt/build-rkt SRC_DIR=/opt/rkt ACI_GOPATH=/go -VERSION=${VERSION:-"v1.2.1+git"} +VERSION=${VERSION:-"v1.3.0"} echo "Version: $VERSION" echo "Building $ACI_FILE" diff --git a/scripts/build-rir.sh b/scripts/build-rir.sh index 8db2ec9076..67c16e2d9f 100755 --- a/scripts/build-rir.sh +++ b/scripts/build-rir.sh @@ -4,7 +4,7 @@ set -xe SRC_DIR=${SRC_DIR:-$PWD} BUILDDIR=${BUILDDIR:-$PWD/build-rir} -RKT_BUILDER_ACI=${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.2.1+git} +RKT_BUILDER_ACI=${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.3.0} mkdir -p $BUILDDIR diff --git a/tests/empty-image/manifest b/tests/empty-image/manifest index 09c7e908ef..2a57160f49 100644 --- a/tests/empty-image/manifest +++ b/tests/empty-image/manifest @@ -5,7 +5,7 @@ "labels": [ { "name": "version", - "value": "1.2.1" + "value": "1.3.0" }, { "name": "arch", diff --git a/tests/image/manifest b/tests/image/manifest index 81978de79d..a48b7362ea 100644 --- a/tests/image/manifest +++ b/tests/image/manifest @@ -5,7 +5,7 @@ "labels": [ { "name": "version", - "value": "1.2.1" + "value": "1.3.0" }, { "name": "arch", diff --git a/tests/rkt_exec_test.go b/tests/rkt_exec_test.go index 9696bacd81..3268656bfe 100644 --- a/tests/rkt_exec_test.go +++ b/tests/rkt_exec_test.go @@ -24,7 +24,7 @@ import ( ) const ( - noappManifestStr = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"coreos.com/rkt-inspect","labels":[{"name":"version","value":"1.2.1"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}]}` + noappManifestStr = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"coreos.com/rkt-inspect","labels":[{"name":"version","value":"1.3.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}]}` ) func TestRunOverrideExec(t *testing.T) { diff --git a/tests/rkt_image_cat_manifest_test.go b/tests/rkt_image_cat_manifest_test.go index 72dd1e5948..765e584db9 100644 --- a/tests/rkt_image_cat_manifest_test.go +++ b/tests/rkt_image_cat_manifest_test.go @@ -27,7 +27,7 @@ import ( const ( // The expected image manifest of the 'rkt-inspect-image-cat-manifest.aci'. - manifestTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.2.1"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.3.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageCatManifest tests 'rkt image cat-manifest', it will: diff --git a/tests/rkt_image_export_test.go b/tests/rkt_image_export_test.go index fd48d7a8f2..35401d5927 100644 --- a/tests/rkt_image_export_test.go +++ b/tests/rkt_image_export_test.go @@ -26,7 +26,7 @@ import ( ) const ( - manifestExportTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.2.1"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestExportTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.3.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageExport tests 'rkt image export', it will import some existing diff --git a/tests/rkt_image_render_test.go b/tests/rkt_image_render_test.go index 8abba1a4e2..8b5f91420f 100644 --- a/tests/rkt_image_render_test.go +++ b/tests/rkt_image_render_test.go @@ -26,7 +26,7 @@ import ( ) const ( - manifestRenderTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.2.1"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"dependencies":[{"imageName":"coreos.com/rkt-inspect"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestRenderTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.3.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"dependencies":[{"imageName":"coreos.com/rkt-inspect"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageRender tests 'rkt image render', it will import some existing empty diff --git a/tests/rkt_os_arch_test.go b/tests/rkt_os_arch_test.go index ef5165ffad..a82e36b684 100644 --- a/tests/rkt_os_arch_test.go +++ b/tests/rkt_os_arch_test.go @@ -25,7 +25,7 @@ import ( ) const ( - manifestOSArchTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.2.1"}ARCH_OS],"app":{"exec":["/inspect", "--print-msg=HelloWorld"],"user":"0","group":"0","workingDirectory":"/"}}` + manifestOSArchTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.3.0"}ARCH_OS],"app":{"exec":["/inspect", "--print-msg=HelloWorld"],"user":"0","group":"0","workingDirectory":"/"}}` ) type osArchTest struct { From 00e233f24bd6639413fd95995cd1fd949fac68ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Thu, 31 Mar 2016 17:58:38 +0200 Subject: [PATCH 0069/1304] version: bump to v1.3.0+git --- configure.ac | 2 +- scripts/acbuild-rkt-builder.sh | 2 +- scripts/build-rir.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 4df5fbe3d3..096c1dc974 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.63]) -AC_INIT([rkt], [1.3.0], [https://github.com/coreos/rkt/issues]) +AC_INIT([rkt], [1.3.0+git], [https://github.com/coreos/rkt/issues]) AC_DEFUN([RKT_CHECK_PROG], [AS_VAR_IF([$1], [], diff --git a/scripts/acbuild-rkt-builder.sh b/scripts/acbuild-rkt-builder.sh index 76a49dd403..27cff65468 100755 --- a/scripts/acbuild-rkt-builder.sh +++ b/scripts/acbuild-rkt-builder.sh @@ -25,7 +25,7 @@ ACI_NAME=${ACI_NAME:-"coreos.com/rkt/builder"} BUILDDIR=/opt/build-rkt SRC_DIR=/opt/rkt ACI_GOPATH=/go -VERSION=${VERSION:-"v1.3.0"} +VERSION=${VERSION:-"v1.3.0+git"} echo "Version: $VERSION" echo "Building $ACI_FILE" diff --git a/scripts/build-rir.sh b/scripts/build-rir.sh index 67c16e2d9f..2bcb4ae23e 100755 --- a/scripts/build-rir.sh +++ b/scripts/build-rir.sh @@ -4,7 +4,7 @@ set -xe SRC_DIR=${SRC_DIR:-$PWD} BUILDDIR=${BUILDDIR:-$PWD/build-rir} -RKT_BUILDER_ACI=${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.3.0} +RKT_BUILDER_ACI=${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.3.0+git} mkdir -p $BUILDDIR From f65389b19e7830ce986ee37844600ff2290ccd05 Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Mon, 4 Apr 2016 12:56:31 +0200 Subject: [PATCH 0070/1304] Update CONTRIBUTING.md --- CONTRIBUTING.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bd31523d82..72d14470d6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,9 +14,10 @@ contribution. See the [DCO](DCO) file for details. # Email and Chat -The project has a mailing list and currently uses the general CoreOS IRC channel: +The project has a mailing list and two discussion channels in IRC: - Email: [rkt-dev](https://groups.google.com/forum/#!forum/rkt-dev) -- IRC: #[coreos](irc://irc.freenode.org:6667/#coreos) IRC channel on freenode.org +- IRC: #[rkt](irc://irc.freenode.org:6667/#rkt) on freenode.org, for general discussion +- IRC: #[rkt-dev](irc://irc.freenode.org:6667/#rkt-dev) on freenode.org, for development discussion Please avoid emailing maintainers found in the MAINTAINERS file directly. They are very busy and read the mailing lists. From 608803b082ed50fce17eb74157b1356eb8a7d48f Mon Sep 17 00:00:00 2001 From: Angus Lees Date: Mon, 4 Apr 2016 21:09:52 +1000 Subject: [PATCH 0071/1304] Build actool for the *build* architecture actool is used during the build to generate stage1 images, etc. Without this patch, actool is mistakenly compiled for the *target* architecture. --- tools/actool.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/actool.mk b/tools/actool.mk index 839a3dcc81..1e07c95f14 100644 --- a/tools/actool.mk +++ b/tools/actool.mk @@ -4,6 +4,7 @@ $(call setup-stamp-file,ACTOOL_STAMP) BGB_STAMP := $(ACTOOL_STAMP) BGB_PKG_IN_REPO := Godeps/_workspace/src/github.com/appc/spec/actool BGB_BINARY := $(ACTOOL) +BGB_ADDITIONAL_GO_ENV := GOARCH=$(GOARCH_FOR_BUILD) CC=$(CC_FOR_BUILD) CLEAN_FILES += $(ACTOOL) From d4cc75bbd6dca1c65f8bfdf134adce91c0758ee9 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Mon, 4 Apr 2016 14:34:32 +0200 Subject: [PATCH 0072/1304] Godeps: add cobra/doc --- Godeps/Godeps.json | 6 +- .../github.com/spf13/cobra/doc/man_docs.go | 218 ++++++++++++++++++ .../github.com/spf13/cobra/doc/man_docs.md | 26 +++ .../src/github.com/spf13/cobra/doc/md_docs.go | 175 ++++++++++++++ .../src/github.com/spf13/cobra/doc/md_docs.md | 104 +++++++++ .../src/github.com/spf13/cobra/doc/util.go | 38 +++ rkt/rkt.go | 1 + 7 files changed, 567 insertions(+), 1 deletion(-) create mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/doc/man_docs.go create mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/doc/man_docs.md create mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/doc/md_docs.go create mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/doc/md_docs.md create mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/doc/util.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 4128e8078c..edbe03bfa0 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -406,7 +406,11 @@ }, { "ImportPath": "github.com/spf13/cobra", - "Rev": "1c44ec8d3f1552cac48999f9306da23c4d8a288b" + "Rev": "4c05eb1145f16d0e6bb4a3e1b6d769f4713cb41f" + }, + { + "ImportPath": "github.com/spf13/cobra/doc", + "Rev": "4c05eb1145f16d0e6bb4a3e1b6d769f4713cb41f" }, { "ImportPath": "github.com/spf13/pflag", diff --git a/Godeps/_workspace/src/github.com/spf13/cobra/doc/man_docs.go b/Godeps/_workspace/src/github.com/spf13/cobra/doc/man_docs.go new file mode 100644 index 0000000000..a98674bf3a --- /dev/null +++ b/Godeps/_workspace/src/github.com/spf13/cobra/doc/man_docs.go @@ -0,0 +1,218 @@ +// Copyright 2015 Red Hat Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package doc + +import ( + "bytes" + "fmt" + "io" + "os" + "path/filepath" + "sort" + "strings" + "time" + + mangen "github.com/cpuguy83/go-md2man/md2man" + "github.com/spf13/cobra" + "github.com/spf13/pflag" +) + +// GenManTree will generate a man page for this command and all decendants +// in the directory given. The header may be nil. This function may not work +// correctly if your command names have - in them. If you have `cmd` with two +// subcmds, `sub` and `sub-third`. And `sub` has a subcommand called `third` +// it is undefined which help output will be in the file `cmd-sub-third.1`. +func GenManTree(cmd *cobra.Command, header *GenManHeader, dir string) error { + if header == nil { + header = &GenManHeader{} + } + for _, c := range cmd.Commands() { + if !c.IsAvailableCommand() || c.IsHelpCommand() { + continue + } + if err := GenManTree(c, header, dir); err != nil { + return err + } + } + needToResetTitle := header.Title == "" + + basename := strings.Replace(cmd.CommandPath(), " ", "_", -1) + ".1" + filename := filepath.Join(dir, basename) + f, err := os.Create(filename) + if err != nil { + return err + } + defer f.Close() + + if err := GenMan(cmd, header, f); err != nil { + return err + } + + if needToResetTitle { + header.Title = "" + } + return nil +} + +// GenManHeader is a lot like the .TH header at the start of man pages. These +// include the title, section, date, source, and manual. We will use the +// current time if Date if unset and will use "Auto generated by spf13/cobra" +// if the Source is unset. +type GenManHeader struct { + Title string + Section string + Date *time.Time + date string + Source string + Manual string +} + +// GenMan will generate a man page for the given command and write it to +// w. The header argument may be nil, however obviously w may not. +func GenMan(cmd *cobra.Command, header *GenManHeader, w io.Writer) error { + if header == nil { + header = &GenManHeader{} + } + b := genMan(cmd, header) + final := mangen.Render(b) + _, err := w.Write(final) + return err +} + +func fillHeader(header *GenManHeader, name string) { + if header.Title == "" { + header.Title = strings.ToUpper(strings.Replace(name, " ", "\\-", -1)) + } + if header.Section == "" { + header.Section = "1" + } + if header.Date == nil { + now := time.Now() + header.Date = &now + } + header.date = (*header.Date).Format("Jan 2006") + if header.Source == "" { + header.Source = "Auto generated by spf13/cobra" + } +} + +func manPreamble(out io.Writer, header *GenManHeader, name, short, long string) { + dashName := strings.Replace(name, " ", "-", -1) + fmt.Fprintf(out, `%% %s(%s)%s +%% %s +%% %s +# NAME +`, header.Title, header.Section, header.date, header.Source, header.Manual) + fmt.Fprintf(out, "%s \\- %s\n\n", dashName, short) + fmt.Fprintf(out, "# SYNOPSIS\n") + fmt.Fprintf(out, "**%s** [OPTIONS]\n\n", name) + fmt.Fprintf(out, "# DESCRIPTION\n") + fmt.Fprintf(out, "%s\n\n", long) +} + +func manPrintFlags(out io.Writer, flags *pflag.FlagSet) { + flags.VisitAll(func(flag *pflag.Flag) { + if len(flag.Deprecated) > 0 || flag.Hidden { + return + } + format := "" + if len(flag.Shorthand) > 0 { + format = "**-%s**, **--%s**" + } else { + format = "%s**--%s**" + } + if len(flag.NoOptDefVal) > 0 { + format = format + "[" + } + if flag.Value.Type() == "string" { + // put quotes on the value + format = format + "=%q" + } else { + format = format + "=%s" + } + if len(flag.NoOptDefVal) > 0 { + format = format + "]" + } + format = format + "\n\t%s\n\n" + fmt.Fprintf(out, format, flag.Shorthand, flag.Name, flag.DefValue, flag.Usage) + }) +} + +func manPrintOptions(out io.Writer, command *cobra.Command) { + flags := command.NonInheritedFlags() + if flags.HasFlags() { + fmt.Fprintf(out, "# OPTIONS\n") + manPrintFlags(out, flags) + fmt.Fprintf(out, "\n") + } + flags = command.InheritedFlags() + if flags.HasFlags() { + fmt.Fprintf(out, "# OPTIONS INHERITED FROM PARENT COMMANDS\n") + manPrintFlags(out, flags) + fmt.Fprintf(out, "\n") + } +} + +func genMan(cmd *cobra.Command, header *GenManHeader) []byte { + // something like `rootcmd subcmd1 subcmd2` + commandName := cmd.CommandPath() + // something like `rootcmd-subcmd1-subcmd2` + dashCommandName := strings.Replace(commandName, " ", "-", -1) + + fillHeader(header, commandName) + + buf := new(bytes.Buffer) + + short := cmd.Short + long := cmd.Long + if len(long) == 0 { + long = short + } + + manPreamble(buf, header, commandName, short, long) + manPrintOptions(buf, cmd) + if len(cmd.Example) > 0 { + fmt.Fprintf(buf, "# EXAMPLE\n") + fmt.Fprintf(buf, "```\n%s\n```\n", cmd.Example) + } + if hasSeeAlso(cmd) { + fmt.Fprintf(buf, "# SEE ALSO\n") + seealsos := make([]string, 0) + if cmd.HasParent() { + parentPath := cmd.Parent().CommandPath() + dashParentPath := strings.Replace(parentPath, " ", "-", -1) + seealso := fmt.Sprintf("**%s(%s)**", dashParentPath, header.Section) + seealsos = append(seealsos, seealso) + cmd.VisitParents(func(c *cobra.Command) { + if c.DisableAutoGenTag { + cmd.DisableAutoGenTag = c.DisableAutoGenTag + } + }) + } + children := cmd.Commands() + sort.Sort(byName(children)) + for _, c := range children { + if !c.IsAvailableCommand() || c.IsHelpCommand() { + continue + } + seealso := fmt.Sprintf("**%s-%s(%s)**", dashCommandName, c.Name(), header.Section) + seealsos = append(seealsos, seealso) + } + fmt.Fprintf(buf, "%s\n", strings.Join(seealsos, ", ")) + } + if !cmd.DisableAutoGenTag { + fmt.Fprintf(buf, "# HISTORY\n%s Auto generated by spf13/cobra\n", header.Date.Format("2-Jan-2006")) + } + return buf.Bytes() +} diff --git a/Godeps/_workspace/src/github.com/spf13/cobra/doc/man_docs.md b/Godeps/_workspace/src/github.com/spf13/cobra/doc/man_docs.md new file mode 100644 index 0000000000..5fe957a355 --- /dev/null +++ b/Godeps/_workspace/src/github.com/spf13/cobra/doc/man_docs.md @@ -0,0 +1,26 @@ +# Generating Man Pages For Your Own cobra.Command + +Generating man pages from a cobra command is incredibly easy. An example is as follows: + +```go +package main + +import ( + "github.com/spf13/cobra" + "github.com/spf13/cobra/doc" +) + +func main() { + cmd := &cobra.Command{ + Use: "test", + Short: "my test program", + } + header := &cobra.GenManHeader{ + Title: "MINE", + Section: "3", + } + doc.GenManTree(cmd, header, "/tmp") +} +``` + +That will get you a man page `/tmp/test.1` diff --git a/Godeps/_workspace/src/github.com/spf13/cobra/doc/md_docs.go b/Godeps/_workspace/src/github.com/spf13/cobra/doc/md_docs.go new file mode 100644 index 0000000000..fa13631804 --- /dev/null +++ b/Godeps/_workspace/src/github.com/spf13/cobra/doc/md_docs.go @@ -0,0 +1,175 @@ +//Copyright 2015 Red Hat Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package doc + +import ( + "fmt" + "io" + "os" + "path/filepath" + "sort" + "strings" + "time" + + "github.com/spf13/cobra" +) + +func printOptions(w io.Writer, cmd *cobra.Command, name string) error { + flags := cmd.NonInheritedFlags() + flags.SetOutput(w) + if flags.HasFlags() { + if _, err := fmt.Fprintf(w, "### Options\n\n```\n"); err != nil { + return err + } + flags.PrintDefaults() + if _, err := fmt.Fprintf(w, "```\n\n"); err != nil { + return err + } + } + + parentFlags := cmd.InheritedFlags() + parentFlags.SetOutput(w) + if parentFlags.HasFlags() { + if _, err := fmt.Fprintf(w, "### Options inherited from parent commands\n\n```\n"); err != nil { + return err + } + parentFlags.PrintDefaults() + if _, err := fmt.Fprintf(w, "```\n\n"); err != nil { + return err + } + } + return nil +} + +func GenMarkdown(cmd *cobra.Command, w io.Writer) error { + return GenMarkdownCustom(cmd, w, func(s string) string { return s }) +} + +func GenMarkdownCustom(cmd *cobra.Command, w io.Writer, linkHandler func(string) string) error { + name := cmd.CommandPath() + + short := cmd.Short + long := cmd.Long + if len(long) == 0 { + long = short + } + + if _, err := fmt.Fprintf(w, "## %s\n\n", name); err != nil { + return err + } + if _, err := fmt.Fprintf(w, "%s\n\n", short); err != nil { + return err + } + if _, err := fmt.Fprintf(w, "### Synopsis\n\n"); err != nil { + return err + } + if _, err := fmt.Fprintf(w, "\n%s\n\n", long); err != nil { + return err + } + + if cmd.Runnable() { + if _, err := fmt.Fprintf(w, "```\n%s\n```\n\n", cmd.UseLine()); err != nil { + return err + } + } + + if len(cmd.Example) > 0 { + if _, err := fmt.Fprintf(w, "### Examples\n\n"); err != nil { + return err + } + if _, err := fmt.Fprintf(w, "```\n%s\n```\n\n", cmd.Example); err != nil { + return err + } + } + + if err := printOptions(w, cmd, name); err != nil { + return err + } + if hasSeeAlso(cmd) { + if _, err := fmt.Fprintf(w, "### SEE ALSO\n"); err != nil { + return err + } + if cmd.HasParent() { + parent := cmd.Parent() + pname := parent.CommandPath() + link := pname + ".md" + link = strings.Replace(link, " ", "_", -1) + if _, err := fmt.Fprintf(w, "* [%s](%s)\t - %s\n", pname, linkHandler(link), parent.Short); err != nil { + return err + } + cmd.VisitParents(func(c *cobra.Command) { + if c.DisableAutoGenTag { + cmd.DisableAutoGenTag = c.DisableAutoGenTag + } + }) + } + + children := cmd.Commands() + sort.Sort(byName(children)) + + for _, child := range children { + if !child.IsAvailableCommand() || child.IsHelpCommand() { + continue + } + cname := name + " " + child.Name() + link := cname + ".md" + link = strings.Replace(link, " ", "_", -1) + if _, err := fmt.Fprintf(w, "* [%s](%s)\t - %s\n", cname, linkHandler(link), child.Short); err != nil { + return err + } + } + if _, err := fmt.Fprintf(w, "\n"); err != nil { + return err + } + } + if !cmd.DisableAutoGenTag { + if _, err := fmt.Fprintf(w, "###### Auto generated by spf13/cobra on %s\n", time.Now().Format("2-Jan-2006")); err != nil { + return err + } + } + return nil +} + +func GenMarkdownTree(cmd *cobra.Command, dir string) error { + identity := func(s string) string { return s } + emptyStr := func(s string) string { return "" } + return GenMarkdownTreeCustom(cmd, dir, emptyStr, identity) +} + +func GenMarkdownTreeCustom(cmd *cobra.Command, dir string, filePrepender, linkHandler func(string) string) error { + for _, c := range cmd.Commands() { + if !c.IsAvailableCommand() || c.IsHelpCommand() { + continue + } + if err := GenMarkdownTreeCustom(c, dir, filePrepender, linkHandler); err != nil { + return err + } + } + + basename := strings.Replace(cmd.CommandPath(), " ", "_", -1) + ".md" + filename := filepath.Join(dir, basename) + f, err := os.Create(filename) + if err != nil { + return err + } + defer f.Close() + + if _, err := io.WriteString(f, filePrepender(filename)); err != nil { + return err + } + if err := GenMarkdownCustom(cmd, f, linkHandler); err != nil { + return err + } + return nil +} diff --git a/Godeps/_workspace/src/github.com/spf13/cobra/doc/md_docs.md b/Godeps/_workspace/src/github.com/spf13/cobra/doc/md_docs.md new file mode 100644 index 0000000000..0c3b96e271 --- /dev/null +++ b/Godeps/_workspace/src/github.com/spf13/cobra/doc/md_docs.md @@ -0,0 +1,104 @@ +# Generating Markdown Docs For Your Own cobra.Command + +Generating man pages from a cobra command is incredibly easy. An example is as follows: + +```go +package main + +import ( + "github.com/spf13/cobra" + "github.com/spf13/cobra/doc" +) + +func main() { + cmd := &cobra.Command{ + Use: "test", + Short: "my test program", + } + doc.GenMarkdownTree(cmd, "/tmp") +} +``` + +That will get you a Markdown document `/tmp/test.md` + +## Generate markdown docs for the entire command tree + +This program can actually generate docs for the kubectl command in the kubernetes project + +```go +package main + +import ( + "io/ioutil" + "os" + + kubectlcmd "k8s.io/kubernetes/pkg/kubectl/cmd" + cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" + + "github.com/spf13/cobra/doc" +) + +func main() { + cmd := kubectlcmd.NewKubectlCommand(cmdutil.NewFactory(nil), os.Stdin, ioutil.Discard, ioutil.Discard) + doc.GenMarkdownTree(cmd, "./") +} +``` + +This will generate a whole series of files, one for each command in the tree, in the directory specified (in this case "./") + +## Generate markdown docs for a single command + +You may wish to have more control over the output, or only generate for a single command, instead of the entire command tree. If this is the case you may prefer to `GenMarkdown` instead of `GenMarkdownTree` + +```go + out := new(bytes.Buffer) + doc.GenMarkdown(cmd, out) +``` + +This will write the markdown doc for ONLY "cmd" into the out, buffer. + +## Customize the output + +Both `GenMarkdown` and `GenMarkdownTree` have alternate versions with callbacks to get some control of the output: + +```go +func GenMarkdownTreeCustom(cmd *Command, dir string, filePrepender, linkHandler func(string) string) error { + //... +} +``` + +```go +func GenMarkdownCustom(cmd *Command, out *bytes.Buffer, linkHandler func(string) string) error { + //... +} +``` + +The `filePrepender` will prepend the return value given the full filepath to the rendered Markdown file. A common use case is to add front matter to use the generated documentation with [Hugo](http://gohugo.io/): + +```go +const fmTemplate = `--- +date: %s +title: "%s" +slug: %s +url: %s +--- +` + +filePrepender := func(filename string) string { + now := time.Now().Format(time.RFC3339) + name := filepath.Base(filename) + base := strings.TrimSuffix(name, path.Ext(name)) + url := "/commands/" + strings.ToLower(base) + "/" + return fmt.Sprintf(fmTemplate, now, strings.Replace(base, "_", " ", -1), base, url) +} +``` + +The `linkHandler` can be used to customize the rendered internal links to the commands, given a filename: + +```go +linkHandler := func(name string) string { + base := strings.TrimSuffix(name, path.Ext(name)) + return "/commands/" + strings.ToLower(base) + "/" +} +``` + diff --git a/Godeps/_workspace/src/github.com/spf13/cobra/doc/util.go b/Godeps/_workspace/src/github.com/spf13/cobra/doc/util.go new file mode 100644 index 0000000000..a1c6b89ba6 --- /dev/null +++ b/Godeps/_workspace/src/github.com/spf13/cobra/doc/util.go @@ -0,0 +1,38 @@ +// Copyright 2015 Red Hat Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package doc + +import "github.com/spf13/cobra" + +// Test to see if we have a reason to print See Also information in docs +// Basically this is a test for a parent commend or a subcommand which is +// both not deprecated and not the autogenerated help command. +func hasSeeAlso(cmd *cobra.Command) bool { + if cmd.HasParent() { + return true + } + for _, c := range cmd.Commands() { + if !c.IsAvailableCommand() || c.IsHelpCommand() { + continue + } + return true + } + return false +} + +type byName []*cobra.Command + +func (s byName) Len() int { return len(s) } +func (s byName) Swap(i, j int) { s[i], s[j] = s[j], s[i] } +func (s byName) Less(i, j int) bool { return s[i].Name() < s[j].Name() } diff --git a/rkt/rkt.go b/rkt/rkt.go index dd94488a5a..367c5f5022 100644 --- a/rkt/rkt.go +++ b/rkt/rkt.go @@ -28,6 +28,7 @@ import ( "github.com/coreos/rkt/rkt/config" rktflag "github.com/coreos/rkt/rkt/flag" "github.com/spf13/cobra" + _ "github.com/spf13/cobra/doc" ) const ( From 608b1d43e50950f0cf7f188584cd98b227d004c1 Mon Sep 17 00:00:00 2001 From: Euan Kemp Date: Mon, 4 Apr 2016 17:10:17 -0700 Subject: [PATCH 0073/1304] prepare: Support 'ondisk' verification skip Prior to this commit, `rkt prepare` would check the ondisk image even if the `--insecure-options=ondisk` flag was provided. This commit corrects that. --- rkt/prepare.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rkt/prepare.go b/rkt/prepare.go index f9b6823e8d..3e882c66e0 100644 --- a/rkt/prepare.go +++ b/rkt/prepare.go @@ -165,9 +165,10 @@ func runPrepare(cmd *cobra.Command, args []string) (exit int) { } pcfg := stage0.PrepareConfig{ - CommonConfig: &cfg, - UseOverlay: !flagNoOverlay && common.SupportsOverlay(), - PrivateUsers: privateUsers, + CommonConfig: &cfg, + UseOverlay: !flagNoOverlay && common.SupportsOverlay(), + PrivateUsers: privateUsers, + SkipTreeStoreCheck: globalFlags.InsecureFlags.SkipOnDiskCheck(), } if len(flagPodManifest) > 0 { From 7e96245048a19eae7b2b0bf1396d42c050bef5c7 Mon Sep 17 00:00:00 2001 From: Yifan Gu Date: Mon, 4 Apr 2016 19:26:15 -0700 Subject: [PATCH 0074/1304] api: Add 'CreatedAt', 'StartedAt' in pod's info. --- api/v1alpha/api.pb.go | 183 ++++++++++++++++++++++-------------------- api/v1alpha/api.proto | 6 ++ rkt/api_service.go | 12 +++ 3 files changed, 112 insertions(+), 89 deletions(-) diff --git a/api/v1alpha/api.pb.go b/api/v1alpha/api.pb.go index 99783930f9..5ae9fe8ace 100644 --- a/api/v1alpha/api.pb.go +++ b/api/v1alpha/api.pb.go @@ -340,6 +340,10 @@ type Pod struct { Annotations []*KeyValue `protobuf:"bytes,7,rep,name=annotations" json:"annotations,omitempty"` // Cgroup of the pod, empty if the pod is not running. Cgroup string `protobuf:"bytes,8,opt,name=cgroup" json:"cgroup,omitempty"` + // Timestamp when the pod is created, nanoseconds since epoch. + CreatedAt int64 `protobuf:"varint,9,opt,name=created_at" json:"created_at,omitempty"` + // Timestamp when the pod is started, nanoseconds since epoch. + StartedAt int64 `protobuf:"varint,10,opt,name=started_at" json:"started_at,omitempty"` } func (m *Pod) Reset() { *m = Pod{} } @@ -1128,96 +1132,97 @@ var _PublicAPI_serviceDesc = grpc.ServiceDesc{ } var fileDescriptor0 = []byte{ - // 1450 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x57, 0x4d, 0x72, 0xdb, 0x46, - 0x13, 0x35, 0x7f, 0xc0, 0x9f, 0x26, 0x4d, 0x91, 0x23, 0xd9, 0xa2, 0xe8, 0x3f, 0x19, 0xdf, 0x17, - 0x97, 0xa3, 0x85, 0x92, 0xc8, 0x8e, 0x37, 0xa9, 0x4a, 0x99, 0x96, 0x20, 0x15, 0x63, 0x89, 0x64, - 0xd1, 0xb4, 0x2b, 0x5e, 0xa1, 0x20, 0x72, 0x28, 0xa3, 0x0c, 0x02, 0x08, 0x00, 0xca, 0x56, 0x96, - 0xb9, 0x40, 0x8e, 0x90, 0x33, 0x64, 0x95, 0x65, 0xf6, 0x39, 0x46, 0xaa, 0x72, 0x8f, 0xf4, 0x0c, - 0x06, 0xc0, 0x00, 0x04, 0x17, 0xd9, 0x89, 0xdd, 0x33, 0xaf, 0xdf, 0xeb, 0xe9, 0x79, 0x03, 0x41, - 0xdd, 0x70, 0xcd, 0x43, 0xd7, 0x73, 0x02, 0x87, 0x54, 0xaf, 0xbf, 0x31, 0x2c, 0xf7, 0x83, 0xa1, - 0xbe, 0x84, 0xc6, 0x60, 0x69, 0x5c, 0xd1, 0x53, 0xc7, 0x5b, 0x1a, 0x01, 0xd9, 0x87, 0x72, 0x70, - 0xe3, 0xd2, 0x6e, 0x61, 0xbf, 0xf0, 0xb4, 0x75, 0x44, 0x0e, 0xc5, 0xb2, 0x43, 0xbe, 0x66, 0x8a, - 0x19, 0xb2, 0x05, 0xd5, 0x6b, 0xea, 0xf9, 0xa6, 0x63, 0x77, 0x8b, 0xb8, 0xa8, 0xae, 0xfe, 0x59, - 0x00, 0x85, 0xa7, 0xc9, 0x97, 0xd0, 0xb8, 0x34, 0x7c, 0xaa, 0x2f, 0x38, 0x16, 0xc7, 0x68, 0x1c, - 0xed, 0xa4, 0x31, 0x44, 0x1d, 0x80, 0xa2, 0x39, 0x0f, 0x01, 0x48, 0x13, 0xca, 0xb6, 0xb1, 0xa4, - 0xdd, 0x12, 0xff, 0x25, 0xe1, 0x97, 0x79, 0xa0, 0x0b, 0x6d, 0x73, 0xe9, 0x3a, 0x5e, 0xa0, 0x07, - 0xe6, 0x92, 0xfa, 0x81, 0xb1, 0x74, 0xbb, 0x0a, 0x66, 0x4a, 0xa4, 0x0d, 0xb5, 0xa5, 0x61, 0x9b, - 0x0b, 0x0c, 0x76, 0x2b, 0x18, 0x69, 0x32, 0x28, 0xdf, 0xfc, 0x99, 0x76, 0xab, 0x3c, 0xff, 0x04, + // 1469 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x57, 0x4b, 0x72, 0xdb, 0x46, + 0x13, 0x36, 0x1f, 0xe0, 0xa3, 0x49, 0x53, 0xe4, 0x48, 0xb6, 0x28, 0xfa, 0x25, 0xe3, 0xff, 0xe3, + 0x72, 0xb4, 0x50, 0x12, 0xd9, 0xf1, 0x26, 0x55, 0x29, 0xd3, 0x12, 0xa4, 0x62, 0x2c, 0x91, 0x2c, + 0x9a, 0x76, 0xc5, 0x2b, 0x14, 0x44, 0x0e, 0x65, 0x94, 0x41, 0x00, 0x01, 0x40, 0xd9, 0xca, 0x32, + 0x17, 0xc8, 0x11, 0x72, 0x86, 0xac, 0xb2, 0xcc, 0x5d, 0x52, 0x95, 0x0b, 0xe4, 0x04, 0xe9, 0x19, + 0x0c, 0x80, 0x01, 0x08, 0x2e, 0xb2, 0x13, 0xbb, 0x7b, 0xbe, 0xfe, 0xba, 0xa7, 0xfb, 0x1b, 0x08, + 0xea, 0x86, 0x6b, 0x1e, 0xba, 0x9e, 0x13, 0x38, 0xa4, 0x7a, 0xfd, 0x8d, 0x61, 0xb9, 0x1f, 0x0c, + 0xf5, 0x25, 0x34, 0x06, 0x4b, 0xe3, 0x8a, 0x9e, 0x3a, 0xde, 0xd2, 0x08, 0xc8, 0x3e, 0x94, 0x83, + 0x1b, 0x97, 0x76, 0x0b, 0xfb, 0x85, 0xa7, 0xad, 0x23, 0x72, 0x28, 0xc2, 0x0e, 0x79, 0xcc, 0x14, + 0x3d, 0x64, 0x0b, 0xaa, 0xd7, 0xd4, 0xf3, 0x4d, 0xc7, 0xee, 0x16, 0x31, 0xa8, 0xae, 0xfe, 0x59, + 0x00, 0x85, 0xbb, 0xc9, 0x97, 0xd0, 0xb8, 0x34, 0x7c, 0xaa, 0x2f, 0x38, 0x16, 0xc7, 0x68, 0x1c, + 0xed, 0xa4, 0x31, 0x44, 0x1e, 0x80, 0xa2, 0x39, 0x0f, 0x01, 0x48, 0x13, 0xca, 0xb6, 0xb1, 0xa4, + 0xdd, 0x12, 0xff, 0x25, 0xe1, 0x97, 0xb9, 0xa1, 0x0b, 0x6d, 0x73, 0xe9, 0x3a, 0x5e, 0xa0, 0x07, + 0xe6, 0x92, 0xfa, 0x81, 0xb1, 0x74, 0xbb, 0x0a, 0x7a, 0x4a, 0xa4, 0x0d, 0xb5, 0xa5, 0x61, 0x9b, + 0x0b, 0x34, 0x76, 0x2b, 0x68, 0x69, 0x32, 0x28, 0xdf, 0xfc, 0x99, 0x76, 0xab, 0xdc, 0xff, 0x04, 0x1a, 0x86, 0x6d, 0x3b, 0x81, 0x11, 0x20, 0x9a, 0xdf, 0xad, 0xed, 0x97, 0x90, 0x4f, 0x27, 0xe6, 0xf3, 0x9a, 0xde, 0xbc, 0x33, 0xac, 0x15, 0x55, 0x9f, 0x41, 0x75, 0x48, 0x83, 0x4f, 0x8e, 0xf7, 0x31, 0xe6, 0x52, 0x88, 0x98, 0x99, 0xee, 0xf5, 0xf3, 0x84, 0x27, 0xfe, 0x7a, 0x11, 0xf2, 0x54, - 0x7f, 0x2d, 0x40, 0xa9, 0xef, 0xba, 0x99, 0x1d, 0x0f, 0x40, 0x31, 0x99, 0x4c, 0xbe, 0xa5, 0x71, - 0xd4, 0x4a, 0x8b, 0xc7, 0xf6, 0x2a, 0x28, 0x20, 0x08, 0xb5, 0xb6, 0x24, 0x2e, 0x88, 0xf4, 0x86, - 0x25, 0x48, 0x07, 0xea, 0xf4, 0xb3, 0x19, 0xe8, 0x33, 0x67, 0x4e, 0x79, 0x03, 0x3a, 0x59, 0x19, - 0xca, 0x26, 0x19, 0x7f, 0x21, 0xa3, 0xb1, 0x33, 0x17, 0xbd, 0x0d, 0xf9, 0x34, 0xa0, 0xe4, 0x8a, - 0x46, 0x77, 0x36, 0x57, 0xc7, 0x5d, 0x61, 0xf5, 0x1e, 0x94, 0x0d, 0xd7, 0xf5, 0xb1, 0x30, 0xab, - 0xd1, 0x94, 0xe9, 0x11, 0x15, 0x6a, 0x76, 0xd8, 0xa5, 0x88, 0x43, 0x3b, 0xce, 0x47, 0xed, 0x5b, - 0x3f, 0x91, 0x0c, 0xf9, 0xea, 0x06, 0xf2, 0xa4, 0x05, 0x95, 0xd9, 0x95, 0xe7, 0xac, 0x5c, 0x3c, - 0x26, 0xd6, 0xde, 0x27, 0x50, 0x8b, 0x73, 0x28, 0x02, 0xff, 0x16, 0x8a, 0x6e, 0x83, 0x72, 0xcd, - 0xa2, 0x62, 0xfa, 0x7e, 0x2f, 0x40, 0x1d, 0xe9, 0x9f, 0x9a, 0x56, 0x40, 0x3d, 0xb6, 0xd2, 0x9c, - 0xfb, 0xb8, 0xb2, 0x84, 0x2b, 0x1f, 0x43, 0x85, 0xcb, 0xf5, 0x71, 0x69, 0x29, 0x5f, 0x6f, 0x87, - 0xdd, 0x09, 0x57, 0x67, 0x07, 0xe8, 0x63, 0x57, 0xd8, 0x2e, 0x0c, 0xf1, 0x13, 0xd4, 0x19, 0x50, - 0x99, 0x87, 0xee, 0xc0, 0x6d, 0xa1, 0x5c, 0xac, 0x54, 0x78, 0x38, 0x23, 0xad, 0xb2, 0x49, 0x1a, - 0x4e, 0x74, 0x28, 0x2d, 0x94, 0x5f, 0x57, 0xff, 0x2e, 0x44, 0x97, 0x2e, 0x87, 0x35, 0xb6, 0xd0, - 0xf5, 0xe8, 0xc2, 0xfc, 0x2c, 0x78, 0xd7, 0x09, 0x1e, 0x28, 0xbf, 0x56, 0x32, 0x4b, 0x5c, 0xf5, - 0x91, 0xde, 0x20, 0xa5, 0x98, 0x24, 0xaa, 0xb5, 0x8c, 0x4b, 0x6a, 0x6d, 0x1e, 0x10, 0x72, 0x17, - 0x5a, 0xe1, 0x4d, 0xa2, 0x73, 0xdd, 0x58, 0x60, 0x65, 0x7e, 0x46, 0x25, 0xb2, 0x0b, 0x5b, 0x71, - 0xfc, 0x92, 0xe2, 0xed, 0xfd, 0x8f, 0x17, 0x88, 0x31, 0x5c, 0xac, 0x2c, 0x4b, 0x30, 0xac, 0x73, - 0x91, 0xbf, 0xa1, 0xc8, 0x33, 0xcb, 0xb9, 0x34, 0xac, 0x53, 0xcb, 0xb8, 0xf2, 0x99, 0xc8, 0xb9, - 0xe9, 0x89, 0x43, 0xdc, 0x83, 0x8e, 0x7f, 0xe3, 0x07, 0x74, 0x89, 0x73, 0x6e, 0x2f, 0xcc, 0x2b, - 0x9d, 0xa5, 0x8a, 0xd1, 0x75, 0xb7, 0x9c, 0x99, 0x61, 0xc9, 0x99, 0xd0, 0x19, 0x90, 0xe6, 0xca, - 0xa7, 0x9e, 0x9c, 0x08, 0x1d, 0x82, 0xe9, 0xb2, 0x7d, 0x3a, 0x5b, 0x79, 0xe8, 0x3d, 0xac, 0x18, - 0xf7, 0x07, 0x76, 0x19, 0xef, 0x04, 0xde, 0xca, 0x0f, 0x74, 0x6c, 0x95, 0xaf, 0x2f, 0x3c, 0x67, - 0xa9, 0x7f, 0x08, 0x02, 0xd7, 0xe7, 0xb2, 0x6b, 0xaa, 0x07, 0xe5, 0x81, 0xbd, 0x70, 0xc8, 0x36, - 0x34, 0xbc, 0x8f, 0x81, 0x1e, 0xb9, 0x4e, 0xc8, 0x70, 0x07, 0x9a, 0x38, 0x19, 0x33, 0x3d, 0xe5, - 0x75, 0x6c, 0x29, 0x7a, 0x68, 0x1c, 0x0c, 0x79, 0x1d, 0x40, 0xf3, 0x8a, 0x0b, 0x15, 0xc5, 0xcb, - 0x19, 0xdf, 0x93, 0xba, 0x80, 0x35, 0x15, 0xed, 0x9a, 0xda, 0x9b, 0x8d, 0x96, 0x67, 0xb9, 0xd1, - 0x66, 0x2c, 0x92, 0xd1, 0x17, 0x05, 0xf1, 0x17, 0xb3, 0x42, 0x5e, 0xa8, 0x44, 0x1e, 0x41, 0x79, - 0x6e, 0x04, 0xc6, 0x66, 0x5f, 0x08, 0xa0, 0xc1, 0x51, 0xc5, 0xb4, 0x3d, 0x06, 0x85, 0x55, 0x0e, - 0xe7, 0x2d, 0xbf, 0xb4, 0x18, 0xc8, 0x70, 0xfc, 0xf0, 0xc2, 0xc9, 0x93, 0x87, 0xbc, 0x7c, 0xd3, - 0x9e, 0x51, 0x5d, 0xa2, 0x80, 0xb1, 0x95, 0x1d, 0x98, 0x56, 0x18, 0xe3, 0xe6, 0xac, 0xb6, 0xa1, - 0x75, 0x46, 0x03, 0xd6, 0xe0, 0x09, 0xfd, 0x69, 0x85, 0x86, 0xa0, 0x1e, 0xc2, 0x56, 0x1c, 0xf1, - 0x5d, 0x1c, 0x28, 0x4a, 0xee, 0xa1, 0xa5, 0xe2, 0x6f, 0xf1, 0x54, 0xdc, 0x4e, 0xdc, 0x12, 0x83, - 0xea, 0x29, 0x6c, 0x9d, 0x9b, 0x7e, 0x80, 0x97, 0xd5, 0x17, 0x10, 0xe4, 0x7f, 0x50, 0x5d, 0x70, - 0x15, 0x21, 0xfb, 0x86, 0xc4, 0x3e, 0x31, 0x01, 0xb4, 0x92, 0x39, 0x0d, 0x0c, 0xd3, 0xe2, 0xcd, - 0xab, 0x61, 0xdd, 0x76, 0x82, 0x23, 0x0a, 0xa3, 0xd1, 0xb9, 0xce, 0x3c, 0x42, 0x69, 0xca, 0x28, - 0xea, 0x23, 0xe8, 0x0c, 0x6c, 0xdf, 0xa5, 0x33, 0xb6, 0x25, 0xaa, 0x2c, 0x99, 0xaa, 0xfa, 0x15, - 0x10, 0x79, 0x81, 0x80, 0xdc, 0x43, 0xab, 0x75, 0xe6, 0x42, 0x4a, 0x1a, 0xf1, 0x07, 0xe8, 0x30, - 0x06, 0xfc, 0xce, 0xc7, 0x5a, 0xbe, 0xc8, 0x6a, 0xc9, 0xbe, 0x94, 0xf9, 0x6a, 0x9e, 0x03, 0x91, - 0xb1, 0x44, 0xf1, 0x87, 0x50, 0xe1, 0xae, 0x15, 0x61, 0x65, 0x1e, 0x1e, 0xf5, 0x31, 0x6c, 0x0b, - 0xca, 0xfc, 0x77, 0x9e, 0xaa, 0x6f, 0x61, 0x27, 0xbd, 0x44, 0x40, 0xc7, 0x4f, 0x5a, 0x21, 0xef, - 0x49, 0x53, 0xbf, 0x83, 0x6d, 0xc6, 0x87, 0xda, 0x7c, 0x7c, 0x62, 0x75, 0xff, 0x87, 0x4a, 0xa8, - 0x6e, 0xed, 0x33, 0x40, 0x9a, 0x45, 0xf5, 0x05, 0xec, 0xa4, 0x37, 0x27, 0x72, 0x28, 0x8f, 0xac, - 0xc9, 0xe1, 0x0b, 0xd5, 0x1b, 0x3e, 0x5c, 0xe7, 0xce, 0x55, 0x5c, 0x0f, 0xdb, 0x84, 0xdd, 0xd7, - 0xe3, 0x87, 0x0f, 0x0d, 0x32, 0x72, 0x76, 0x71, 0x87, 0x70, 0x8e, 0x2d, 0xd3, 0xe6, 0x73, 0x5c, - 0x78, 0xaa, 0xb0, 0x0d, 0x0b, 0xc7, 0xb2, 0x9c, 0x4f, 0x7c, 0x86, 0x6b, 0x99, 0xb9, 0x56, 0x72, - 0xe6, 0x9a, 0x9b, 0xa5, 0xba, 0xcf, 0xa7, 0x38, 0x2c, 0x2d, 0xd8, 0xc6, 0xc8, 0xdc, 0xc1, 0x0f, - 0x28, 0xd4, 0x93, 0xcf, 0xa5, 0x2e, 0x76, 0xf5, 0xa2, 0x7f, 0xa6, 0xe9, 0xd3, 0xf7, 0x63, 0x4d, - 0x7f, 0x3b, 0x3c, 0xd1, 0x4e, 0x07, 0x43, 0xed, 0xa4, 0x7d, 0x0b, 0xbd, 0x64, 0x4b, 0xca, 0xf4, - 0xc7, 0xe3, 0xe3, 0x76, 0x01, 0x9f, 0x9a, 0x8e, 0x14, 0x3c, 0x19, 0x1d, 0xbf, 0xd6, 0x26, 0xed, - 0x22, 0x12, 0x69, 0x49, 0xe1, 0xd1, 0xf1, 0xa0, 0x5d, 0x3a, 0x18, 0x43, 0x2d, 0xfe, 0x6a, 0xd8, - 0x85, 0x6d, 0x04, 0xd0, 0xdf, 0x4c, 0xfb, 0xd3, 0x74, 0x11, 0xc4, 0x4b, 0x12, 0x93, 0xb7, 0xc3, - 0xe1, 0x60, 0x78, 0x86, 0x65, 0x76, 0xa0, 0x9d, 0x84, 0xb5, 0x1f, 0x07, 0x53, 0x5c, 0x5c, 0x3c, - 0xf8, 0xa7, 0x00, 0xb5, 0xf8, 0x69, 0x44, 0xc8, 0xf1, 0xe8, 0x24, 0x07, 0x12, 0xf7, 0x26, 0x09, - 0xed, 0xe2, 0xd5, 0xe4, 0xfd, 0x08, 0x11, 0x53, 0xcb, 0xc7, 0x13, 0x6d, 0xdc, 0x9f, 0xb0, 0x52, - 0x45, 0x34, 0x67, 0x92, 0x4d, 0x20, 0x4c, 0x89, 0x31, 0x4b, 0xe2, 0x11, 0xb3, 0x32, 0x4e, 0xdb, - 0x5e, 0x12, 0xee, 0xbf, 0x1a, 0x4d, 0x90, 0x5a, 0xb4, 0xad, 0xad, 0x64, 0x8a, 0x87, 0xc4, 0x2b, - 0xe9, 0x1a, 0x27, 0xda, 0xb9, 0x36, 0x65, 0x60, 0xd5, 0x74, 0x8d, 0xb3, 0xfe, 0xe4, 0x15, 0xb6, - 0xb0, 0x5d, 0x3b, 0xf8, 0xa3, 0x08, 0xf5, 0xc4, 0xec, 0xf0, 0x84, 0xb4, 0x77, 0xda, 0x70, 0xba, - 0x7e, 0x42, 0xf7, 0x60, 0x57, 0xca, 0x30, 0xa4, 0x98, 0x7f, 0x01, 0x3f, 0x87, 0x1e, 0xe6, 0x27, - 0x23, 0xd6, 0xa8, 0xbd, 0x07, 0x77, 0x33, 0x6b, 0x90, 0x0a, 0xcf, 0x95, 0xd0, 0x2e, 0xee, 0x64, - 0x72, 0x42, 0x4e, 0x19, 0xef, 0xce, 0x7e, 0x26, 0x25, 0xb8, 0xeb, 0xc7, 0xa3, 0xf3, 0x73, 0xed, - 0x98, 0xad, 0x52, 0x32, 0xe0, 0xe2, 0x38, 0x27, 0x61, 0x43, 0xd2, 0xe0, 0x2c, 0x27, 0xc0, 0xab, - 0xac, 0xc1, 0x52, 0x2a, 0x9c, 0xaa, 0xc1, 0xc5, 0x38, 0xa4, 0x5c, 0x23, 0xf7, 0xa1, 0xbb, 0x96, - 0x9e, 0x68, 0x17, 0xa3, 0x77, 0x98, 0xad, 0x1f, 0xfd, 0x52, 0xc6, 0xaf, 0xad, 0xd5, 0xa5, 0x65, - 0xce, 0xfa, 0xe3, 0x01, 0xf9, 0x1e, 0xaa, 0xc2, 0xd0, 0xc9, 0x6e, 0xf2, 0xda, 0xa5, 0x4c, 0xbf, - 0xd7, 0x5d, 0x4f, 0x84, 0xb7, 0x46, 0xbd, 0x45, 0xfa, 0x50, 0x8b, 0x8c, 0x99, 0x24, 0xeb, 0x32, - 0x9e, 0xdf, 0xdb, 0xcb, 0xc9, 0xc4, 0x10, 0x67, 0x00, 0x89, 0x15, 0x93, 0x9e, 0xf4, 0x80, 0x64, - 0x0c, 0xbc, 0x77, 0x2f, 0x37, 0x27, 0x03, 0x25, 0xb6, 0x2a, 0x01, 0xad, 0xf9, 0xb6, 0x04, 0xb4, - 0xee, 0xc3, 0x08, 0x74, 0x01, 0x4d, 0xd9, 0x46, 0xc9, 0xfd, 0x6c, 0x5d, 0xd9, 0x80, 0x7b, 0x0f, - 0x36, 0x64, 0x63, 0xb8, 0x11, 0x34, 0x65, 0x87, 0x94, 0xe0, 0x72, 0x5c, 0x57, 0x82, 0xcb, 0xb3, - 0x55, 0xf5, 0xd6, 0xd7, 0x05, 0xf2, 0x92, 0x1f, 0x1a, 0xf3, 0xaf, 0xf4, 0xa1, 0x49, 0x66, 0x9a, - 0x3e, 0x34, 0xd9, 0xea, 0x18, 0xc2, 0x65, 0x85, 0xff, 0x0b, 0xf9, 0xec, 0xdf, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x8d, 0x30, 0x01, 0x4e, 0x4f, 0x0e, 0x00, 0x00, + 0x7f, 0x2d, 0x40, 0xa9, 0xef, 0xba, 0x99, 0x13, 0x0f, 0x40, 0x31, 0x59, 0x99, 0xfc, 0x48, 0xe3, + 0xa8, 0x95, 0x2e, 0x1e, 0xdb, 0xab, 0x60, 0x01, 0x41, 0x58, 0x6b, 0x4b, 0xe2, 0x82, 0x48, 0x6f, + 0x98, 0x83, 0x74, 0xa0, 0x4e, 0x3f, 0x9b, 0x81, 0x3e, 0x73, 0xe6, 0x94, 0x37, 0xa0, 0x93, 0x2d, + 0x43, 0xd9, 0x54, 0xc6, 0x3f, 0xc8, 0x68, 0xec, 0xcc, 0x45, 0x6f, 0x43, 0x3e, 0x0d, 0x28, 0xb9, + 0xa2, 0xd1, 0x9d, 0xcd, 0xd9, 0xf1, 0x54, 0x98, 0xbd, 0x07, 0x65, 0xc3, 0x75, 0x7d, 0x4c, 0xcc, + 0x72, 0x34, 0x65, 0x7a, 0x44, 0x85, 0x9a, 0x1d, 0x76, 0x29, 0xe2, 0xd0, 0x8e, 0xfd, 0x51, 0xfb, + 0xd6, 0x6f, 0x24, 0x43, 0xbe, 0xba, 0x81, 0x3c, 0x69, 0x41, 0x65, 0x76, 0xe5, 0x39, 0x2b, 0x17, + 0xaf, 0x89, 0x11, 0xc7, 0x2a, 0x66, 0x1e, 0x45, 0x4e, 0x73, 0x1d, 0x47, 0xa9, 0xce, 0xef, 0x13, + 0x6d, 0xc8, 0xdf, 0x13, 0x36, 0x60, 0x36, 0xf5, 0x09, 0xd4, 0x62, 0x0c, 0x2c, 0x16, 0xff, 0x16, + 0x95, 0xdf, 0x06, 0xe5, 0x9a, 0x59, 0xc5, 0x94, 0xfe, 0x5e, 0x80, 0x3a, 0x96, 0x79, 0x6a, 0x5a, + 0x01, 0xf5, 0x58, 0xa4, 0x39, 0xf7, 0x31, 0xb2, 0x84, 0x91, 0x8f, 0xa1, 0xc2, 0xdb, 0xe2, 0x63, + 0x68, 0x29, 0xbf, 0x2f, 0x1d, 0xb6, 0x3b, 0xae, 0xce, 0x2e, 0xda, 0xc7, 0xee, 0xb1, 0x53, 0x68, + 0xe2, 0x37, 0xad, 0x33, 0xa0, 0x32, 0x37, 0xdd, 0x81, 0xdb, 0xa2, 0x43, 0x22, 0x52, 0xe1, 0xe6, + 0x4c, 0x0b, 0x2a, 0x9b, 0x5a, 0x80, 0x93, 0x1f, 0xb6, 0x20, 0x6c, 0x53, 0x5d, 0xfd, 0xab, 0x10, + 0x2d, 0x67, 0x0e, 0x6b, 0x6c, 0xb5, 0xeb, 0xd1, 0x85, 0xf9, 0x59, 0xf0, 0xe6, 0x2d, 0xe3, 0xeb, + 0x27, 0xb3, 0xc4, 0xa8, 0x8f, 0xf4, 0x06, 0x29, 0xc5, 0x24, 0xb1, 0x5a, 0xcb, 0xb8, 0xa4, 0xd6, + 0xe6, 0x41, 0x22, 0x77, 0xa1, 0x15, 0x6e, 0x1c, 0x6b, 0xf4, 0x02, 0x33, 0xf3, 0xbb, 0x2c, 0x91, + 0x5d, 0xd8, 0x8a, 0xed, 0x97, 0x14, 0xb7, 0xfc, 0x3f, 0x2e, 0x1a, 0x63, 0xb8, 0x58, 0x59, 0x96, + 0x60, 0x58, 0xe7, 0x45, 0xfe, 0x86, 0x45, 0x9e, 0x59, 0xce, 0xa5, 0x61, 0x9d, 0x5a, 0xc6, 0x95, + 0xcf, 0x8a, 0x9c, 0x9b, 0x9e, 0xb8, 0xc4, 0x3d, 0xe8, 0xf8, 0x37, 0x7e, 0x40, 0x97, 0xb8, 0x0f, + 0xf6, 0xc2, 0xbc, 0xd2, 0x99, 0xab, 0x18, 0xc9, 0x82, 0xe5, 0xcc, 0x0c, 0x4b, 0xf6, 0x84, 0x0a, + 0x82, 0x34, 0x57, 0x3e, 0xf5, 0x64, 0x47, 0xa8, 0x24, 0xac, 0x2e, 0xdb, 0xa7, 0xb3, 0x95, 0x87, + 0x1a, 0xc5, 0x92, 0x71, 0x1d, 0x61, 0x4b, 0x7b, 0x27, 0xf0, 0x56, 0x7e, 0xa0, 0x63, 0xab, 0x7c, + 0x7d, 0xe1, 0x39, 0x4b, 0xfd, 0x43, 0x10, 0xb8, 0x3e, 0x2f, 0xbb, 0xa6, 0x7a, 0x50, 0x1e, 0xd8, + 0x0b, 0x87, 0x6c, 0x43, 0xc3, 0xfb, 0x18, 0xe8, 0x91, 0x3a, 0x85, 0x0c, 0x77, 0xa0, 0x89, 0x93, + 0x31, 0xd3, 0x53, 0x9a, 0xc8, 0x42, 0x51, 0x6b, 0x63, 0x63, 0xc8, 0xeb, 0x00, 0x9a, 0x57, 0xbc, + 0x50, 0x91, 0xbc, 0x9c, 0xd1, 0x47, 0xa9, 0x0b, 0x98, 0x53, 0xd1, 0xae, 0xa9, 0xbd, 0x59, 0x90, + 0xb9, 0x97, 0x0b, 0x72, 0x46, 0x4a, 0x19, 0x7d, 0x91, 0x10, 0x7f, 0x31, 0xc9, 0xe4, 0x89, 0x4a, + 0xe4, 0x11, 0x94, 0xe7, 0x46, 0x60, 0x6c, 0xd6, 0x8f, 0x00, 0x1a, 0x1c, 0x55, 0x4c, 0xdb, 0x63, + 0x50, 0x58, 0xe6, 0x70, 0xde, 0xf2, 0x53, 0x8b, 0x81, 0x0c, 0xc7, 0x0f, 0x17, 0x4e, 0x9e, 0x3c, + 0xb6, 0xac, 0xa6, 0x3d, 0xa3, 0xba, 0x44, 0x01, 0x6d, 0x2b, 0x3b, 0x30, 0xad, 0xd0, 0xc6, 0x45, + 0x5c, 0x6d, 0x43, 0xeb, 0x8c, 0x06, 0xac, 0xc1, 0x13, 0xfa, 0xd3, 0x0a, 0x85, 0x43, 0x3d, 0x84, + 0xad, 0xd8, 0xe2, 0xbb, 0x38, 0x50, 0x94, 0xdc, 0x43, 0xe9, 0xc5, 0xdf, 0xe2, 0x49, 0xb9, 0x9d, + 0xa8, 0x2a, 0x1a, 0xd5, 0x53, 0xd8, 0x3a, 0x37, 0xfd, 0x00, 0x97, 0xd5, 0x17, 0x10, 0xe4, 0x7f, + 0x50, 0x5d, 0xf0, 0x2a, 0x42, 0xf6, 0x0d, 0x89, 0x7d, 0x22, 0x02, 0x28, 0x39, 0x73, 0x1a, 0x18, + 0xa6, 0xc5, 0x9b, 0x57, 0xc3, 0xbc, 0xed, 0x04, 0x47, 0x24, 0x46, 0x41, 0x74, 0x9d, 0x79, 0x84, + 0xd2, 0x94, 0x51, 0xd4, 0x47, 0xd0, 0x19, 0xd8, 0xbe, 0x4b, 0x67, 0xec, 0x48, 0x94, 0x59, 0x12, + 0x5f, 0xf5, 0x2b, 0x20, 0x72, 0x80, 0x80, 0xdc, 0x43, 0x49, 0x76, 0xe6, 0xa2, 0x94, 0x34, 0xe2, + 0x0f, 0xd0, 0x61, 0x0c, 0xf8, 0xce, 0xc7, 0xb5, 0x7c, 0x91, 0xad, 0x25, 0xfb, 0xa2, 0xe6, 0x57, + 0xf3, 0x1c, 0x88, 0x8c, 0x25, 0x92, 0x3f, 0x84, 0x0a, 0x57, 0xad, 0x08, 0x2b, 0xf3, 0x40, 0xa9, + 0x8f, 0x61, 0x5b, 0x50, 0xe6, 0xbf, 0xf3, 0xaa, 0xfa, 0x16, 0x76, 0xd2, 0x21, 0x02, 0x3a, 0x7e, + 0xfa, 0x0a, 0x79, 0x4f, 0x9f, 0xfa, 0x1d, 0x6c, 0x33, 0x3e, 0xd4, 0xe6, 0xe3, 0x13, 0x57, 0xf7, + 0x7f, 0xa8, 0x84, 0xd5, 0xad, 0x7d, 0x2e, 0x48, 0xb3, 0xa8, 0xbe, 0x80, 0x9d, 0xf4, 0xe1, 0xa4, + 0x1c, 0xca, 0x2d, 0x6b, 0xe5, 0xf0, 0x40, 0xf5, 0x86, 0x0f, 0xd7, 0xb9, 0x73, 0x15, 0xe7, 0xc3, + 0x36, 0x61, 0xf7, 0xf5, 0xf8, 0x81, 0x44, 0x81, 0x8c, 0x94, 0x5d, 0xec, 0x10, 0xce, 0xb1, 0x65, + 0xda, 0x7c, 0x8e, 0x0b, 0x4f, 0x15, 0x76, 0x60, 0xe1, 0x58, 0x96, 0xf3, 0x89, 0xcf, 0x70, 0x2d, + 0x33, 0xd7, 0x4a, 0xce, 0x5c, 0x73, 0xb1, 0x54, 0xf7, 0xf9, 0x14, 0x87, 0xa9, 0x05, 0xdb, 0x18, + 0x99, 0x2b, 0xf8, 0x01, 0x85, 0x7a, 0xf2, 0x59, 0xd5, 0xc5, 0xae, 0x5e, 0xf4, 0xcf, 0x34, 0x7d, + 0xfa, 0x7e, 0xac, 0xe9, 0x6f, 0x87, 0x27, 0xda, 0xe9, 0x60, 0xa8, 0x9d, 0xb4, 0x6f, 0xa1, 0x96, + 0x6c, 0x49, 0x9e, 0xfe, 0x78, 0x7c, 0xdc, 0x2e, 0xe0, 0x53, 0xd3, 0x91, 0x8c, 0x27, 0xa3, 0xe3, + 0xd7, 0xda, 0xa4, 0x5d, 0x44, 0x22, 0x2d, 0xc9, 0x3c, 0x3a, 0x1e, 0xb4, 0x4b, 0x07, 0x63, 0xa8, + 0xc5, 0x5f, 0x17, 0xbb, 0xb0, 0x8d, 0x00, 0xfa, 0x9b, 0x69, 0x7f, 0x9a, 0x4e, 0x82, 0x78, 0x89, + 0x63, 0xf2, 0x76, 0x38, 0x1c, 0x0c, 0xcf, 0x30, 0xcd, 0x0e, 0xb4, 0x13, 0xb3, 0xf6, 0xe3, 0x60, + 0x8a, 0xc1, 0xc5, 0x83, 0xbf, 0x0b, 0x50, 0x8b, 0x9f, 0x46, 0x84, 0x1c, 0x8f, 0x4e, 0x72, 0x20, + 0xf1, 0x6c, 0xe2, 0xd0, 0x2e, 0x5e, 0x4d, 0xde, 0x8f, 0x10, 0x31, 0x15, 0x3e, 0x9e, 0x68, 0xe3, + 0xfe, 0x84, 0xa5, 0x2a, 0xa2, 0x38, 0x93, 0xac, 0x03, 0x61, 0x4a, 0x8c, 0x59, 0x62, 0x8f, 0x98, + 0x95, 0x71, 0xda, 0xf6, 0x12, 0x73, 0xff, 0xd5, 0x68, 0x82, 0xd4, 0xa2, 0x63, 0x6d, 0x25, 0x93, + 0x3c, 0x24, 0x5e, 0x49, 0xe7, 0x38, 0xd1, 0xce, 0xb5, 0x29, 0x03, 0xab, 0xa6, 0x73, 0x9c, 0xf5, + 0x27, 0xaf, 0xb0, 0x85, 0xed, 0xda, 0xc1, 0x1f, 0x45, 0xa8, 0x27, 0x62, 0x87, 0x37, 0xa4, 0xbd, + 0xd3, 0x86, 0xd3, 0xf5, 0x1b, 0xba, 0x07, 0xbb, 0x92, 0x87, 0x21, 0xc5, 0xfc, 0x0b, 0xf8, 0xd9, + 0xf4, 0x30, 0xdf, 0x19, 0xb1, 0xc6, 0xda, 0x7b, 0x70, 0x37, 0x13, 0x83, 0x54, 0xb8, 0xaf, 0x84, + 0x72, 0x71, 0x27, 0xe3, 0x13, 0xe5, 0x94, 0x71, 0x77, 0xf6, 0x33, 0x2e, 0xc1, 0x5d, 0x3f, 0x1e, + 0x9d, 0x9f, 0x6b, 0xc7, 0x2c, 0x4a, 0xc9, 0x80, 0x8b, 0xeb, 0x9c, 0x84, 0x0d, 0x49, 0x83, 0x33, + 0x9f, 0x00, 0xaf, 0xb2, 0x06, 0x4b, 0xae, 0x70, 0xaa, 0x06, 0x17, 0xe3, 0x90, 0x72, 0x8d, 0xdc, + 0x87, 0xee, 0x9a, 0x7b, 0xa2, 0x5d, 0x8c, 0xde, 0xa1, 0xb7, 0x7e, 0xf4, 0x4b, 0x19, 0xbf, 0xb6, + 0x56, 0x97, 0x96, 0x39, 0xeb, 0x8f, 0x07, 0xe4, 0x7b, 0xa8, 0x0a, 0x41, 0x27, 0xbb, 0xc9, 0x6b, + 0x97, 0x12, 0xfd, 0x5e, 0x77, 0xdd, 0x11, 0x6e, 0x8d, 0x7a, 0x8b, 0xf4, 0xa1, 0x16, 0x09, 0x33, + 0x49, 0xe2, 0x32, 0x9a, 0xdf, 0xdb, 0xcb, 0xf1, 0xc4, 0x10, 0x67, 0x00, 0x89, 0x14, 0x93, 0x9e, + 0xf4, 0x80, 0x64, 0x04, 0xbc, 0x77, 0x2f, 0xd7, 0x27, 0x03, 0x25, 0xb2, 0x2a, 0x01, 0xad, 0xe9, + 0xb6, 0x04, 0xb4, 0xae, 0xc3, 0x08, 0x74, 0x01, 0x4d, 0x59, 0x46, 0xc9, 0xfd, 0x6c, 0x5e, 0x59, + 0x80, 0x7b, 0x0f, 0x36, 0x78, 0x63, 0xb8, 0x11, 0x34, 0x65, 0x85, 0x94, 0xe0, 0x72, 0x54, 0x57, + 0x82, 0xcb, 0x93, 0x55, 0xf5, 0xd6, 0xd7, 0x05, 0xf2, 0x92, 0x5f, 0x1a, 0xd3, 0xaf, 0xf4, 0xa5, + 0x49, 0x62, 0x9a, 0xbe, 0x34, 0x59, 0xea, 0x18, 0xc2, 0x65, 0x85, 0xff, 0xab, 0xf9, 0xec, 0xdf, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xba, 0xf4, 0x5c, 0xf5, 0x77, 0x0e, 0x00, 0x00, } diff --git a/api/v1alpha/api.proto b/api/v1alpha/api.proto index 0f1944f37f..d28dda35e3 100644 --- a/api/v1alpha/api.proto +++ b/api/v1alpha/api.proto @@ -175,6 +175,12 @@ message Pod { // Cgroup of the pod, empty if the pod is not running. string cgroup = 8; + + // Timestamp when the pod is created, nanoseconds since epoch. + int64 created_at = 9; + + // Timestamp when the pod is started, nanoseconds since epoch. + int64 started_at = 10; } message KeyValue { diff --git a/rkt/api_service.go b/rkt/api_service.go index fbbe5db7ee..72b66285bd 100644 --- a/rkt/api_service.go +++ b/rkt/api_service.go @@ -323,6 +323,18 @@ func getBasicPod(p *pod) (*v1alpha.Pod, *schema.PodManifest, error) { return pod, nil, nil } + createdAt, err := p.getCreationTime() + if err != nil { + return nil, nil, err + } + + startedAt, err := p.getStartTime() + if err != nil { + return nil, nil, err + } + + pod.CreatedAt, pod.StartedAt = createdAt.UnixNano(), startedAt.UnixNano() + manifest, data, err := getPodManifest(p) if err != nil { return nil, nil, err From d6f61cac084621aaf7c124a08e70ce76cefbe6b7 Mon Sep 17 00:00:00 2001 From: Yifan Gu Date: Mon, 4 Apr 2016 19:52:31 -0700 Subject: [PATCH 0075/1304] tests: Add tests for testing CreatedAt and StartedAt for api service. --- tests/rkt_api_service_test.go | 8 ++++++++ tests/rkt_tests.go | 28 ++++++++++++++++++++++------ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/tests/rkt_api_service_test.go b/tests/rkt_api_service_test.go index 40606513eb..d7ce1ef837 100644 --- a/tests/rkt_api_service_test.go +++ b/tests/rkt_api_service_test.go @@ -145,6 +145,14 @@ func checkPod(t *testing.T, ctx *testutils.RktRunCtx, p *v1alpha.Pod, hasAppStat if podInfo.pid != int(p.Pid) { t.Errorf("Expected %d, saw %d", podInfo.pid, p.Pid) } + // The time accuracy returned by 'rkt status' stops at milliseconds. + accuracy := time.Millisecond.Nanoseconds() + if podInfo.createdAt/accuracy != p.CreatedAt/accuracy { + t.Errorf("Expected %d, saw %d", podInfo.createdAt, p.CreatedAt) + } + if podInfo.startedAt/accuracy != p.StartedAt/accuracy { + t.Errorf("Expected %d, saw %d", podInfo.startedAt, p.StartedAt) + } checkPodState(t, podInfo.state, p.State) checkPodApps(t, podInfo.apps, p.Apps, hasAppState) checkPodNetworks(t, podInfo.networks, p.Networks) diff --git a/tests/rkt_tests.go b/tests/rkt_tests.go index 4709950969..34c9a91107 100644 --- a/tests/rkt_tests.go +++ b/tests/rkt_tests.go @@ -402,12 +402,14 @@ type networkInfo struct { } type podInfo struct { - id string - pid int - state string - apps map[string]*appInfo - networks map[string]*networkInfo - manifest []byte + id string + pid int + state string + apps map[string]*appInfo + networks map[string]*networkInfo + manifest []byte + createdAt int64 + startedAt int64 } // parsePodInfo parses the 'rkt status $UUID' result into podInfo struct. @@ -416,6 +418,8 @@ type podInfo struct { // networks=default:ip4=172.16.28.103 // pid=14352 // exited=false +// created=2016-04-01 19:12:03.447 -0700 PDT +// started=2016-04-01 19:12:04.279 -0700 PDT func parsePodInfoOutput(t *testing.T, result string, p *podInfo) { lines := strings.Split(strings.TrimSuffix(result, "\n"), "\n") for _, line := range lines { @@ -455,6 +459,18 @@ func parsePodInfoOutput(t *testing.T, result string, p *podInfo) { t.Fatalf("Cannot parse the pod's pid %q: %v", tuples[1], err) } p.pid = pid + case "created": + createdAt, err := time.Parse(defaultTimeLayout, tuples[1]) + if err != nil { + t.Fatalf("Cannot parse the pod's creation time %q: %v", tuples[1], err) + } + p.createdAt = createdAt.UnixNano() + case "started": + startedAt, err := time.Parse(defaultTimeLayout, tuples[1]) + if err != nil { + t.Fatalf("Cannot parse the pod's start time %q: %v", tuples[1], err) + } + p.startedAt = startedAt.UnixNano() } if strings.HasPrefix(tuples[0], "app-") { exitCode, err := strconv.Atoi(tuples[1]) From cb0d5e2177ab91ffe75674bb466774d65ad5b2d5 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Mon, 4 Apr 2016 14:35:20 +0200 Subject: [PATCH 0076/1304] manpages: generate manpages with cobra To update the manpages, use: $ make manpages It will generate the manpages in dist/manpages/. Also the bash completion file is no longer built manually, but you can use: $ make bash-completion It will generate dist/bash_completion/rkt.bash. The release scripts are updated to make sure that each release contains an up-to-date version of the manpages and the bash completion file. --- CHANGELOG.md | 9 + dist/bash_completion/rkt.bash | 860 ---------------------------------- rkt/bash_completion_gen.go | 32 ++ rkt/main.go | 37 ++ rkt/manpages_gen.go | 39 ++ rkt/rkt.go | 22 - rkt/rkt.mk | 8 + scripts/build-rkt.sh | 9 +- 8 files changed, 133 insertions(+), 883 deletions(-) delete mode 100644 dist/bash_completion/rkt.bash create mode 100644 rkt/bash_completion_gen.go create mode 100644 rkt/main.go create mode 100644 rkt/manpages_gen.go diff --git a/CHANGELOG.md b/CHANGELOG.md index ab0a4d4792..2b09ab1b5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## vUNRELEASED + +#### Note for packagers + +Files generated from sources are no longer checked-in the git repository. Instead, packagers should build them: + +- Bash completion file, generated by `make bash-completion` +- Man pages, generated by `make manpages` + ## v1.3.0 This release includes a number of new features and bugfixes like the long-awaited propagation of apps' exit status. diff --git a/dist/bash_completion/rkt.bash b/dist/bash_completion/rkt.bash deleted file mode 100644 index cc114764f6..0000000000 --- a/dist/bash_completion/rkt.bash +++ /dev/null @@ -1,860 +0,0 @@ -#!/bin/bash - -__debug() -{ - if [[ -n ${BASH_COMP_DEBUG_FILE} ]]; then - echo "$*" >> "${BASH_COMP_DEBUG_FILE}" - fi -} - -# Homebrew on Macs have version 1.3 of bash-completion which doesn't include -# _init_completion. This is a very minimal version of that function. -__my_init_completion() -{ - COMPREPLY=() - _get_comp_words_by_ref cur prev words cword -} - -__index_of_word() -{ - local w word=$1 - shift - index=0 - for w in "$@"; do - [[ $w = "$word" ]] && return - index=$((index+1)) - done - index=-1 -} - -__contains_word() -{ - local w word=$1; shift - for w in "$@"; do - [[ $w = "$word" ]] && return - done - return 1 -} - -__handle_reply() -{ - __debug "${FUNCNAME}" - case $cur in - -*) - if [[ $(type -t compopt) = "builtin" ]]; then - compopt -o nospace - fi - local allflags - if [ ${#must_have_one_flag[@]} -ne 0 ]; then - allflags=("${must_have_one_flag[@]}") - else - allflags=("${flags[*]} ${two_word_flags[*]}") - fi - COMPREPLY=( $(compgen -W "${allflags[*]}" -- "$cur") ) - if [[ $(type -t compopt) = "builtin" ]]; then - [[ $COMPREPLY == *= ]] || compopt +o nospace - fi - return 0; - ;; - esac - - # check if we are handling a flag with special work handling - local index - __index_of_word "${prev}" "${flags_with_completion[@]}" - if [[ ${index} -ge 0 ]]; then - ${flags_completion[${index}]} - return - fi - - # we are parsing a flag and don't have a special handler, no completion - if [[ ${cur} != "${words[cword]}" ]]; then - return - fi - - local completions - if [[ ${#must_have_one_flag[@]} -ne 0 ]]; then - completions=("${must_have_one_flag[@]}") - elif [[ ${#must_have_one_noun[@]} -ne 0 ]]; then - completions=("${must_have_one_noun[@]}") - else - completions=("${commands[@]}") - fi - COMPREPLY=( $(compgen -W "${completions[*]}" -- "$cur") ) - - if [[ ${#COMPREPLY[@]} -eq 0 ]]; then - declare -F __custom_func >/dev/null && __custom_func - fi -} - -# The arguments should be in the form "ext1|ext2|extn" -__handle_filename_extension_flag() -{ - local ext="$1" - _filedir "@(${ext})" -} - -__handle_subdirs_in_dir_flag() -{ - local dir="$1" - pushd "${dir}" >/dev/null 2>&1 && _filedir -d && popd >/dev/null 2>&1 -} - -__handle_flag() -{ - __debug "${FUNCNAME}: c is $c words[c] is ${words[c]}" - - # if a command required a flag, and we found it, unset must_have_one_flag() - local flagname=${words[c]} - # if the word contained an = - if [[ ${words[c]} == *"="* ]]; then - flagname=${flagname%=*} # strip everything after the = - flagname="${flagname}=" # but put the = back - fi - __debug "${FUNCNAME}: looking for ${flagname}" - if __contains_word "${flagname}" "${must_have_one_flag[@]}"; then - must_have_one_flag=() - fi - - # skip the argument to a two word flag - if __contains_word "${words[c]}" "${two_word_flags[@]}"; then - c=$((c+1)) - # if we are looking for a flags value, don't show commands - if [[ $c -eq $cword ]]; then - commands=() - fi - fi - - # skip the flag itself - c=$((c+1)) - -} - -__handle_noun() -{ - __debug "${FUNCNAME}: c is $c words[c] is ${words[c]}" - - if __contains_word "${words[c]}" "${must_have_one_noun[@]}"; then - must_have_one_noun=() - fi - - nouns+=("${words[c]}") - c=$((c+1)) -} - -__handle_command() -{ - __debug "${FUNCNAME}: c is $c words[c] is ${words[c]}" - - local next_command - if [[ -n ${last_command} ]]; then - next_command="_${last_command}_${words[c]}" - else - next_command="_${words[c]}" - fi - c=$((c+1)) - __debug "${FUNCNAME}: looking for ${next_command}" - declare -F $next_command >/dev/null && $next_command -} - -__handle_word() -{ - if [[ $c -ge $cword ]]; then - __handle_reply - return - fi - __debug "${FUNCNAME}: c is $c words[c] is ${words[c]}" - if [[ "${words[c]}" == -* ]]; then - __handle_flag - elif __contains_word "${words[c]}" "${commands[@]}"; then - __handle_command - else - __handle_noun - fi - __handle_word -} - -__rkt_parse_image() -{ - local rkt_output - if rkt_output=$(rkt image list --no-legend 2>/dev/null); then - out=($(echo "${rkt_output}" | awk '{print $1}')) - COMPREPLY=( $( compgen -W "${out[*]}" -- "$cur" ) ) - fi -} - -__rkt_parse_list() -{ - local rkt_output - if rkt_output=$(rkt list --no-legend 2>/dev/null); then - if [[ -n "$1" ]]; then - out=($(echo "${rkt_output}" | grep ${1} | awk '{print $1}')) - else - out=($(echo "${rkt_output}" | awk '{print $1}')) - fi - COMPREPLY=( $( compgen -W "${out[*]}" -- "$cur" ) ) - fi -} - -__custom_func() { - case ${last_command} in - rkt_image_export | \ - rkt_image_extract | \ - rkt_image_cat-manifest | \ - rkt_image_render | \ - rkt_image_rm | \ - rkt_run | \ - rkt_prepare) - __rkt_parse_image - return - ;; - rkt_run-prepared) - __rkt_parse_list prepared - return - ;; - rkt_enter) - __rkt_parse_list running - return - ;; - rkt_rm) - __rkt_parse_list "prepare\|exited" - return - ;; - rkt_status) - __rkt_parse_list - return - ;; - *) - ;; - esac -} - -_rkt_api-service() -{ - last_command="rkt_api-service" - commands=() - - flags=() - two_word_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--listen=") - flags+=("--debug") - flags+=("--dir=") - flags+=("--insecure-options=") - flags+=("--user-config=") - flags+=("--local-config=") - flags+=("--system-config=") - flags+=("--trust-keys-from-https") - - must_have_one_flag=() - must_have_one_noun=() -} - -_rkt_cat-manifest() -{ - last_command="rkt_cat-manifest" - commands=() - - flags=() - two_word_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--pretty-print") - flags+=("--debug") - flags+=("--dir=") - flags+=("--insecure-options=") - flags+=("--user-config=") - flags+=("--local-config=") - flags+=("--system-config=") - flags+=("--trust-keys-from-https") - - must_have_one_flag=() - must_have_one_noun=() -} - -_rkt_enter() -{ - last_command="rkt_enter" - commands=() - - flags=() - two_word_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--app=") - flags+=("--debug") - flags+=("--dir=") - flags+=("--insecure-options=") - flags+=("--user-config=") - flags+=("--local-config=") - flags+=("--system-config=") - flags+=("--trust-keys-from-https") - - must_have_one_flag=() - must_have_one_noun=() -} - -_rkt_fetch() -{ - last_command="rkt_fetch" - commands=() - - flags=() - two_word_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--no-store") - flags+=("--signature=") - flags+=("--store-only") - flags+=("--debug") - flags+=("--dir=") - flags+=("--insecure-options=") - flags+=("--user-config=") - flags+=("--local-config=") - flags+=("--system-config=") - flags+=("--trust-keys-from-https") - - must_have_one_flag=() - must_have_one_noun=() -} - -_rkt_gc() -{ - last_command="rkt_gc" - commands=() - - flags=() - two_word_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--expire-prepared=") - flags+=("--grace-period=") - flags+=("--debug") - flags+=("--dir=") - flags+=("--insecure-options=") - flags+=("--user-config=") - flags+=("--local-config=") - flags+=("--system-config=") - flags+=("--trust-keys-from-https") - - must_have_one_flag=() - must_have_one_noun=() -} - -_rkt_image_cat-manifest() -{ - last_command="rkt_image_cat-manifest" - commands=() - - flags=() - two_word_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--pretty-print") - flags+=("--debug") - flags+=("--dir=") - flags+=("--insecure-options=") - flags+=("--user-config=") - flags+=("--local-config=") - flags+=("--system-config=") - flags+=("--trust-keys-from-https") - - must_have_one_flag=() - must_have_one_noun=() -} - -_rkt_image_export() -{ - last_command="rkt_image_export" - commands=() - - flags=() - two_word_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--overwrite") - flags+=("--debug") - flags+=("--dir=") - flags+=("--insecure-options=") - flags+=("--user-config=") - flags+=("--local-config=") - flags+=("--system-config=") - flags+=("--trust-keys-from-https") - - must_have_one_flag=() - must_have_one_noun=() -} - -_rkt_image_extract() -{ - last_command="rkt_image_extract" - commands=() - - flags=() - two_word_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--overwrite") - flags+=("--rootfs-only") - flags+=("--debug") - flags+=("--dir=") - flags+=("--insecure-options=") - flags+=("--user-config=") - flags+=("--local-config=") - flags+=("--system-config=") - flags+=("--trust-keys-from-https") - - must_have_one_flag=() - must_have_one_noun=() -} - -_rkt_image_gc() -{ - last_command="rkt_image_gc" - commands=() - - flags=() - two_word_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--grace-period=") - flags+=("--debug") - flags+=("--dir=") - flags+=("--insecure-options=") - flags+=("--user-config=") - flags+=("--local-config=") - flags+=("--system-config=") - flags+=("--trust-keys-from-https") - - must_have_one_flag=() - must_have_one_noun=() -} - -_rkt_image_list() -{ - last_command="rkt_image_list" - commands=() - - flags=() - two_word_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--fields=") - flags+=("--full") - flags+=("--no-legend") - flags+=("--order=") - flags+=("--sort=") - flags+=("--debug") - flags+=("--dir=") - flags+=("--insecure-options=") - flags+=("--user-config=") - flags+=("--local-config=") - flags+=("--system-config=") - flags+=("--trust-keys-from-https") - - must_have_one_flag=() - must_have_one_noun=() -} - -_rkt_image_render() -{ - last_command="rkt_image_render" - commands=() - - flags=() - two_word_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--overwrite") - flags+=("--rootfs-only") - flags+=("--debug") - flags+=("--dir=") - flags+=("--insecure-options=") - flags+=("--user-config=") - flags+=("--local-config=") - flags+=("--system-config=") - flags+=("--trust-keys-from-https") - - must_have_one_flag=() - must_have_one_noun=() -} - -_rkt_image_rm() -{ - last_command="rkt_image_rm" - commands=() - - flags=() - two_word_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--debug") - flags+=("--dir=") - flags+=("--insecure-options=") - flags+=("--user-config=") - flags+=("--local-config=") - flags+=("--system-config=") - flags+=("--trust-keys-from-https") - - must_have_one_flag=() - must_have_one_noun=() -} - -_rkt_image() -{ - last_command="rkt_image" - commands=() - commands+=("cat-manifest") - commands+=("export") - commands+=("extract") - commands+=("gc") - commands+=("list") - commands+=("render") - commands+=("rm") - - flags=() - two_word_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--debug") - flags+=("--dir=") - flags+=("--insecure-options=") - flags+=("--user-config=") - flags+=("--local-config=") - flags+=("--system-config=") - flags+=("--trust-keys-from-https") - - must_have_one_flag=() - must_have_one_noun=() -} - -_rkt_list() -{ - last_command="rkt_list" - commands=() - - flags=() - two_word_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--full") - flags+=("--no-legend") - flags+=("--debug") - flags+=("--dir=") - flags+=("--insecure-options=") - flags+=("--user-config=") - flags+=("--local-config=") - flags+=("--system-config=") - flags+=("--trust-keys-from-https") - - must_have_one_flag=() - must_have_one_noun=() -} - -_rkt_metadata-service() -{ - last_command="rkt_metadata-service" - commands=() - - flags=() - two_word_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--listen-port=") - flags+=("--debug") - flags+=("--dir=") - flags+=("--insecure-options=") - flags+=("--user-config=") - flags+=("--local-config=") - flags+=("--system-config=") - flags+=("--trust-keys-from-https") - - must_have_one_flag=() - must_have_one_noun=() -} - -_rkt_prepare() -{ - last_command="rkt_prepare" - commands=() - - flags=() - two_word_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--exec=") - flags+=("--inherit-env") - flags+=("--mount=") - flags+=("--no-overlay") - flags+=("--no-store") - flags+=("--pod-manifest=") - flags+=("--port=") - flags+=("--private-users") - flags+=("--quiet") - flags+=("--set-env=") - flags+=("--stage1-path=") - flags+=("--stage1-url=") - flags+=("--stage1-name=") - flags+=("--stage1-hash=") - flags+=("--stage1-from-dir=") - flags+=("--store-only") - flags+=("--volume=") - flags+=("--debug") - flags+=("--dir=") - flags+=("--insecure-options=") - flags+=("--user-config=") - flags+=("--local-config=") - flags+=("--system-config=") - flags+=("--trust-keys-from-https") - - must_have_one_flag=() - must_have_one_noun=() -} - -_rkt_rm() -{ - last_command="rkt_rm" - commands=() - - flags=() - two_word_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--uuid-file=") - flags+=("--debug") - flags+=("--dir=") - flags+=("--insecure-options=") - flags+=("--user-config=") - flags+=("--local-config=") - flags+=("--system-config=") - flags+=("--trust-keys-from-https") - - must_have_one_flag=() - must_have_one_noun=() -} - -_rkt_run() -{ - last_command="rkt_run" - commands=() - - flags=() - two_word_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--cpu=") - flags+=("--exec=") - flags+=("--inherit-env") - flags+=("--interactive") - flags+=("--mds-register") - flags+=("--memory=") - flags+=("--mount=") - flags+=("--net=") - flags+=("--no-overlay") - flags+=("--no-store") - flags+=("--pod-manifest=") - flags+=("--port=") - flags+=("--private-users") - flags+=("--set-env=") - flags+=("--signature=") - flags+=("--stage1-path=") - flags+=("--stage1-url=") - flags+=("--stage1-name=") - flags+=("--stage1-hash=") - flags+=("--stage1-from-dir=") - flags+=("--store-only") - flags+=("--uuid-file-save=") - flags+=("--volume=") - flags+=("--debug") - flags+=("--dir=") - flags+=("--insecure-options=") - flags+=("--user-config=") - flags+=("--local-config=") - flags+=("--system-config=") - flags+=("--trust-keys-from-https") - - must_have_one_flag=() - must_have_one_noun=() -} - -_rkt_run-prepared() -{ - last_command="rkt_run-prepared" - commands=() - - flags=() - two_word_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--interactive") - flags+=("--mds-register") - flags+=("--net=") - flags+=("--debug") - flags+=("--dir=") - flags+=("--insecure-options=") - flags+=("--user-config=") - flags+=("--local-config=") - flags+=("--system-config=") - flags+=("--trust-keys-from-https") - - must_have_one_flag=() - must_have_one_noun=() -} - -_rkt_status() -{ - last_command="rkt_status" - commands=() - - flags=() - two_word_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--wait") - flags+=("--debug") - flags+=("--dir=") - flags+=("--insecure-options=") - flags+=("--user-config=") - flags+=("--local-config=") - flags+=("--system-config=") - flags+=("--trust-keys-from-https") - - must_have_one_flag=() - must_have_one_noun=() -} - -_rkt_trust() -{ - last_command="rkt_trust" - commands=() - - flags=() - two_word_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--insecure-allow-http") - flags+=("--prefix=") - flags+=("--root") - flags+=("--skip-fingerprint-review") - flags+=("--debug") - flags+=("--dir=") - flags+=("--insecure-options=") - flags+=("--user-config=") - flags+=("--local-config=") - flags+=("--system-config=") - flags+=("--trust-keys-from-https") - - must_have_one_flag=() - must_have_one_noun=() -} - -_rkt_version() -{ - last_command="rkt_version" - commands=() - - flags=() - two_word_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--debug") - flags+=("--dir=") - flags+=("--insecure-options=") - flags+=("--user-config=") - flags+=("--local-config=") - flags+=("--system-config=") - flags+=("--trust-keys-from-https") - - must_have_one_flag=() - must_have_one_noun=() -} - -_rkt() -{ - last_command="rkt" - commands=() - commands+=("api-service") - commands+=("cat-manifest") - commands+=("enter") - commands+=("fetch") - commands+=("gc") - commands+=("image") - commands+=("list") - commands+=("metadata-service") - commands+=("prepare") - commands+=("rm") - commands+=("run") - commands+=("run-prepared") - commands+=("status") - commands+=("trust") - commands+=("version") - - flags=() - two_word_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--debug") - flags+=("--dir=") - flags+=("--insecure-options=") - flags+=("--user-config=") - flags+=("--local-config=") - flags+=("--system-config=") - flags+=("--trust-keys-from-https") - - must_have_one_flag=() - must_have_one_noun=() -} - -__start_rkt() -{ - local cur prev words cword - if declare -F _init_completion >/dev/null 2>&1; then - _init_completion -s || return - else - __my_init_completion || return - fi - - local c=0 - local flags=() - local two_word_flags=() - local flags_with_completion=() - local flags_completion=() - local commands=("rkt") - local must_have_one_flag=() - local must_have_one_noun=() - local last_command - local nouns=() - - __handle_word -} - -if [[ $(type -t compopt) = "builtin" ]]; then - complete -F __start_rkt rkt -else - complete -o nospace -F __start_rkt rkt -fi - -# ex: ts=4 sw=4 et filetype=sh diff --git a/rkt/bash_completion_gen.go b/rkt/bash_completion_gen.go new file mode 100644 index 0000000000..cb6a95a6f6 --- /dev/null +++ b/rkt/bash_completion_gen.go @@ -0,0 +1,32 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This file is not part of the rkt binary. It is only executed manually via +// the makefile. +//+build ignore + +package main + +import ( + "fmt" + "os" +) + +func main() { + err := cmdRkt.GenBashCompletionFile("dist/bash_completion/rkt.bash") + if err != nil { + fmt.Fprintf(os.Stderr, "Failed to generate the bash completion file: %v\n", err) + os.Exit(1) + } +} diff --git a/rkt/main.go b/rkt/main.go new file mode 100644 index 0000000000..9067e734ab --- /dev/null +++ b/rkt/main.go @@ -0,0 +1,37 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "os" + + "github.com/coreos/rkt/pkg/multicall" +) + +func main() { + // check if rkt is executed with a multicall command + multicall.MaybeExec() + + cmdRkt.SetUsageFunc(usageFunc) + + // Make help just show the usage + cmdRkt.SetHelpTemplate(`{{.UsageString}}`) + + if err := cmdRkt.Execute(); err != nil && cmdExitCode == 0 { + // err already printed by cobra on stderr + cmdExitCode = 2 // invalid argument + } + os.Exit(cmdExitCode) +} diff --git a/rkt/manpages_gen.go b/rkt/manpages_gen.go new file mode 100644 index 0000000000..1c79adc876 --- /dev/null +++ b/rkt/manpages_gen.go @@ -0,0 +1,39 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This file is not part of the rkt binary. It is only executed manually via +// the makefile. +//+build ignore + +package main + +import ( + "fmt" + "os" + + "github.com/spf13/cobra/doc" +) + +func main() { + header := &doc.GenManHeader{ + Title: "rkt - App Container runtime", + Section: "1", + } + + err := doc.GenManTree(cmdRkt, header, "dist/manpages") + if err != nil { + fmt.Fprintf(os.Stderr, "Failed to generate the man pages: %v\n", err) + os.Exit(1) + } +} diff --git a/rkt/rkt.go b/rkt/rkt.go index 367c5f5022..cf87815ca3 100644 --- a/rkt/rkt.go +++ b/rkt/rkt.go @@ -24,11 +24,9 @@ import ( "github.com/coreos/rkt/common" "github.com/coreos/rkt/pkg/keystore" "github.com/coreos/rkt/pkg/log" - "github.com/coreos/rkt/pkg/multicall" "github.com/coreos/rkt/rkt/config" rktflag "github.com/coreos/rkt/rkt/flag" "github.com/spf13/cobra" - _ "github.com/spf13/cobra/doc" ) const ( @@ -215,26 +213,6 @@ func runMissingCommand(cmd *cobra.Command, args []string) { cmdExitCode = 2 // invalid argument } -func main() { - // check if rkt is executed with a multicall command - multicall.MaybeExec() - - cmdRkt.SetUsageFunc(usageFunc) - - // Make help just show the usage - cmdRkt.SetHelpTemplate(`{{.UsageString}}`) - - // // Uncomment to update rkt.bash - // stdout.Print("Generating rkt.bash") - // cmdRkt.GenBashCompletionFile("dist/bash_completion/rkt.bash") - // os.Exit(0) - - if err := cmdRkt.Execute(); err != nil && cmdExitCode == 0 { - cmdExitCode = 2 // invalid argument - } - os.Exit(cmdExitCode) -} - // where pod directories are created and locked before moving to prepared func embryoDir() string { return filepath.Join(getDataDir(), "pods", "embryo") diff --git a/rkt/rkt.mk b/rkt/rkt.mk index cde6985c31..be99d972f7 100644 --- a/rkt/rkt.mk +++ b/rkt/rkt.mk @@ -29,6 +29,14 @@ $(BGB_BINARY): $(MK_PATH) | $(BINDIR) include makelib/build_go_bin.mk +manpages: | $(GOPATH_TO_CREATE)/src/$(REPO_PATH) + mkdir -p dist/manpages/ + ls rkt/*.go | grep -vE '_test.go|main.go|_gen.go' | xargs go run rkt/manpages_gen.go + +bash-completion: | $(GOPATH_TO_CREATE)/src/$(REPO_PATH) + mkdir -p dist/bash_completion/ + ls rkt/*.go | grep -vE '_test.go|main.go|_gen.go' | xargs go run rkt/bash_completion_gen.go + $(call undefine-namespaces,LOCAL) # RKT_STAMP deliberately not cleared # RKT_BINARY deliberately not cleared diff --git a/scripts/build-rkt.sh b/scripts/build-rkt.sh index 53ee7b5806..65db041679 100755 --- a/scripts/build-rkt.sh +++ b/scripts/build-rkt.sh @@ -2,4 +2,11 @@ set -e -./autogen.sh && ./configure --enable-tpm=no --with-stage1-default-images-directory=/usr/lib/rkt/stage1-images --with-stage1-default-location=/usr/lib/rkt/stage1-images/stage1-coreos.aci && make -j4 +./autogen.sh +./configure \ + --enable-tpm=no \ + --with-stage1-default-images-directory=/usr/lib/rkt/stage1-images \ + --with-stage1-default-location=/usr/lib/rkt/stage1-images/stage1-coreos.aci +make manpages +make bash-completion +make -j4 From 3b797b5206b601696b5f5ce1d11df1d3cf74baec Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Tue, 5 Apr 2016 15:09:06 +0200 Subject: [PATCH 0077/1304] rkt/image: remove redundant quotes --- rkt/image/fetcher.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rkt/image/fetcher.go b/rkt/image/fetcher.go index 28054d6e78..5a9026a1c6 100644 --- a/rkt/image/fetcher.go +++ b/rkt/image/fetcher.go @@ -118,7 +118,7 @@ func (f *Fetcher) fetchSingleImage(img string, a *asc, imgType apps.AppImageType imgType = guessImageType(img) } if imgType == apps.AppImageHash { - return "", fmt.Errorf("cannot fetch a hash '%q', expected either a URL, a path or an image name", img) + return "", fmt.Errorf("cannot fetch a hash %q, expected either a URL, a path or an image name", img) } switch imgType { From f0e8170c994aefa7e2707f5c27b0fedf0e3734f3 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Tue, 5 Apr 2016 13:40:53 +0200 Subject: [PATCH 0078/1304] protobuf: generate code using a script Currently protobuf bindings have to be generated manually, the process is being documented as a code comment in api/v1alpha/api.proto. This automates protobuf generation by introducing a script and also a make target "protobuf". Fixes #2004 --- api/v1alpha/README.md | 10 ++ api/v1alpha/api.pb.go | 260 ++++++++++++++++++++++-------------------- api/v1alpha/api.proto | 3 - rkt/rkt.mk | 3 + scripts/genproto.sh | 36 ++++++ 5 files changed, 186 insertions(+), 126 deletions(-) create mode 100755 scripts/genproto.sh diff --git a/api/v1alpha/README.md b/api/v1alpha/README.md index 738ae2e761..f8c292c1f3 100644 --- a/api/v1alpha/README.md +++ b/api/v1alpha/README.md @@ -9,3 +9,13 @@ For more information, see: - #1359 - #1468 - [API Service Subcommand](../../Documentation/subcommands/api-service.md) + +## Protobuf + +The rkt gRPC API uses Protocol Buffers for its services. +In order to rebuild the generated code make sure you have protobuf 3.0.0 installed (https://github.com/google/protobuf) +and execute from the top-level directory: + +``` +$ make protobuf +``` diff --git a/api/v1alpha/api.pb.go b/api/v1alpha/api.pb.go index 5ae9fe8ace..b4057e7e4a 100644 --- a/api/v1alpha/api.pb.go +++ b/api/v1alpha/api.pb.go @@ -224,7 +224,7 @@ type Image struct { // Base format of the image, required. This indicates the original format // for the image as nowadays all the image formats will be transformed to // ACI. - BaseFormat *ImageFormat `protobuf:"bytes,1,opt,name=base_format" json:"base_format,omitempty"` + BaseFormat *ImageFormat `protobuf:"bytes,1,opt,name=base_format,json=baseFormat" json:"base_format,omitempty"` // ID of the image, a string that can be used to uniquely identify the image, // e.g. sha512 hash of the ACIs, required. Id string `protobuf:"bytes,2,opt,name=id" json:"id,omitempty"` @@ -233,7 +233,7 @@ type Image struct { // Version of the image, e.g. 'latest', '2.0.10', optional. Version string `protobuf:"bytes,4,opt,name=version" json:"version,omitempty"` // Timestamp of when the image is imported, it is the seconds since epoch, optional. - ImportTimestamp int64 `protobuf:"varint,5,opt,name=import_timestamp" json:"import_timestamp,omitempty"` + ImportTimestamp int64 `protobuf:"varint,5,opt,name=import_timestamp,json=importTimestamp" json:"import_timestamp,omitempty"` // JSON-encoded byte array that represents the image manifest, optional. Manifest []byte `protobuf:"bytes,6,opt,name=manifest,proto3" json:"manifest,omitempty"` // Size is the size in bytes of this image in the store. @@ -287,7 +287,7 @@ type App struct { State AppState `protobuf:"varint,3,opt,name=state,enum=v1alpha.AppState" json:"state,omitempty"` // Exit code of the app. optional, only valid if it's returned by InspectPod() and // the app has already exited. - ExitCode int32 `protobuf:"zigzag32,4,opt,name=exit_code" json:"exit_code,omitempty"` + ExitCode int32 `protobuf:"zigzag32,4,opt,name=exit_code,json=exitCode" json:"exit_code,omitempty"` // Annotations for this app. Annotations []*KeyValue `protobuf:"bytes,5,rep,name=annotations" json:"annotations,omitempty"` } @@ -340,10 +340,6 @@ type Pod struct { Annotations []*KeyValue `protobuf:"bytes,7,rep,name=annotations" json:"annotations,omitempty"` // Cgroup of the pod, empty if the pod is not running. Cgroup string `protobuf:"bytes,8,opt,name=cgroup" json:"cgroup,omitempty"` - // Timestamp when the pod is created, nanoseconds since epoch. - CreatedAt int64 `protobuf:"varint,9,opt,name=created_at" json:"created_at,omitempty"` - // Timestamp when the pod is started, nanoseconds since epoch. - StartedAt int64 `protobuf:"varint,10,opt,name=started_at" json:"started_at,omitempty"` } func (m *Pod) Reset() { *m = Pod{} } @@ -374,7 +370,7 @@ func (m *Pod) GetAnnotations() []*KeyValue { type KeyValue struct { // Key part of the key-value pair. - Key string `protobuf:"bytes,1,opt,name=Key" json:"Key,omitempty"` + Key string `protobuf:"bytes,1,opt,name=Key,json=key" json:"Key,omitempty"` // Value part of the key-value pair. Value string `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"` } @@ -392,11 +388,11 @@ type PodFilter struct { // If not empty, the pods that have any of the states will be returned. States []PodState `protobuf:"varint,2,rep,name=states,enum=v1alpha.PodState" json:"states,omitempty"` // If not empty, the pods that all of the apps will be returned. - AppNames []string `protobuf:"bytes,3,rep,name=app_names" json:"app_names,omitempty"` + AppNames []string `protobuf:"bytes,3,rep,name=app_names,json=appNames" json:"app_names,omitempty"` // If not empty, the pods that have all of the images(in the apps) will be returned - ImageIds []string `protobuf:"bytes,4,rep,name=image_ids" json:"image_ids,omitempty"` + ImageIds []string `protobuf:"bytes,4,rep,name=image_ids,json=imageIds" json:"image_ids,omitempty"` // If not empty, the pods that are in all of the networks will be returned. - NetworkNames []string `protobuf:"bytes,5,rep,name=network_names" json:"network_names,omitempty"` + NetworkNames []string `protobuf:"bytes,5,rep,name=network_names,json=networkNames" json:"network_names,omitempty"` // If not empty, the pods that have all of the annotations will be returned. Annotations []*KeyValue `protobuf:"bytes,6,rep,name=annotations" json:"annotations,omitempty"` // If not empty, the pods whose cgroup are listed will be returned. @@ -425,20 +421,20 @@ type ImageFilter struct { // If not empty, the images that have any of the base names will be returned. // For example, both 'coreos.com/etcd' and 'k8s.io/etcd' will be returned if 'etcd' is included, // however 'k8s.io/etcd-backup' will not be returned. - BaseNames []string `protobuf:"bytes,3,rep,name=base_names" json:"base_names,omitempty"` + BaseNames []string `protobuf:"bytes,3,rep,name=base_names,json=baseNames" json:"base_names,omitempty"` // If not empty, the images that have any of the keywords in the name will be returned. // For example, both 'kubernetes-etcd', 'etcd:latest' will be returned if 'etcd' is included, Keywords []string `protobuf:"bytes,4,rep,name=keywords" json:"keywords,omitempty"` // If not empty, the images that have all of the labels will be returned. Labels []*KeyValue `protobuf:"bytes,5,rep,name=labels" json:"labels,omitempty"` // If set, the images that are imported after this timestamp will be returned. - ImportedAfter int64 `protobuf:"varint,6,opt,name=imported_after" json:"imported_after,omitempty"` + ImportedAfter int64 `protobuf:"varint,6,opt,name=imported_after,json=importedAfter" json:"imported_after,omitempty"` // If set, the images that are imported before this timestamp will be returned. - ImportedBefore int64 `protobuf:"varint,7,opt,name=imported_before" json:"imported_before,omitempty"` + ImportedBefore int64 `protobuf:"varint,7,opt,name=imported_before,json=importedBefore" json:"imported_before,omitempty"` // If not empty, the images that have all of the annotations will be returned. Annotations []*KeyValue `protobuf:"bytes,8,rep,name=annotations" json:"annotations,omitempty"` // If not empty, the images that have any of the exact full names will be returned. - FullNames []string `protobuf:"bytes,9,rep,name=full_names" json:"full_names,omitempty"` + FullNames []string `protobuf:"bytes,9,rep,name=full_names,json=fullNames" json:"full_names,omitempty"` } func (m *ImageFilter) Reset() { *m = ImageFilter{} } @@ -465,15 +461,15 @@ type GlobalFlags struct { // Data directory. Dir string `protobuf:"bytes,1,opt,name=dir" json:"dir,omitempty"` // System configuration directory. - SystemConfigDir string `protobuf:"bytes,2,opt,name=system_config_dir" json:"system_config_dir,omitempty"` + SystemConfigDir string `protobuf:"bytes,2,opt,name=system_config_dir,json=systemConfigDir" json:"system_config_dir,omitempty"` // Local configuration directory. - LocalConfigDir string `protobuf:"bytes,3,opt,name=local_config_dir" json:"local_config_dir,omitempty"` + LocalConfigDir string `protobuf:"bytes,3,opt,name=local_config_dir,json=localConfigDir" json:"local_config_dir,omitempty"` // User configuration directory. - UserConfigDir string `protobuf:"bytes,4,opt,name=user_config_dir" json:"user_config_dir,omitempty"` + UserConfigDir string `protobuf:"bytes,4,opt,name=user_config_dir,json=userConfigDir" json:"user_config_dir,omitempty"` // Insecure flags configurates what security features to disable. - InsecureFlags string `protobuf:"bytes,5,opt,name=insecure_flags" json:"insecure_flags,omitempty"` + InsecureFlags string `protobuf:"bytes,5,opt,name=insecure_flags,json=insecureFlags" json:"insecure_flags,omitempty"` // Whether to automatically trust gpg keys fetched from https - TrustKeysFromHttps bool `protobuf:"varint,6,opt,name=trust_keys_from_https" json:"trust_keys_from_https,omitempty"` + TrustKeysFromHttps bool `protobuf:"varint,6,opt,name=trust_keys_from_https,json=trustKeysFromHttps" json:"trust_keys_from_https,omitempty"` } func (m *GlobalFlags) Reset() { *m = GlobalFlags{} } @@ -484,13 +480,13 @@ func (*GlobalFlags) Descriptor() ([]byte, []int) { return fileDescriptor0, []int // Info describes the information of rkt on the machine. type Info struct { // Version of rkt, required, in the form of Semantic Versioning 2.0.0 (http://semver.org/). - RktVersion string `protobuf:"bytes,1,opt,name=rkt_version" json:"rkt_version,omitempty"` + RktVersion string `protobuf:"bytes,1,opt,name=rkt_version,json=rktVersion" json:"rkt_version,omitempty"` // Version of appc, required, in the form of Semantic Versioning 2.0.0 (http://semver.org/). - AppcVersion string `protobuf:"bytes,2,opt,name=appc_version" json:"appc_version,omitempty"` + AppcVersion string `protobuf:"bytes,2,opt,name=appc_version,json=appcVersion" json:"appc_version,omitempty"` // Latest version of the api that's supported by the service, required, in the form of Semantic Versioning 2.0.0 (http://semver.org/). - ApiVersion string `protobuf:"bytes,3,opt,name=api_version" json:"api_version,omitempty"` + ApiVersion string `protobuf:"bytes,3,opt,name=api_version,json=apiVersion" json:"api_version,omitempty"` // The global flags that passed to the rkt api service when it's launched. - GlobalFlags *GlobalFlags `protobuf:"bytes,4,opt,name=global_flags" json:"global_flags,omitempty"` + GlobalFlags *GlobalFlags `protobuf:"bytes,4,opt,name=global_flags,json=globalFlags" json:"global_flags,omitempty"` } func (m *Info) Reset() { *m = Info{} } @@ -548,10 +544,10 @@ type EventFilter struct { // If set, then only returns the events after this timestamp. // If the server starts after since_time, then only the events happened after the start of the server will be returned. // If since_time is a future timestamp, then no events will be returned until that time. - SinceTime int64 `protobuf:"varint,4,opt,name=since_time" json:"since_time,omitempty"` + SinceTime int64 `protobuf:"varint,4,opt,name=since_time,json=sinceTime" json:"since_time,omitempty"` // If set, then only returns the events before this timestamp. // If it is a future timestamp, then the event stream will be closed at that moment. - UntilTime int64 `protobuf:"varint,5,opt,name=until_time" json:"until_time,omitempty"` + UntilTime int64 `protobuf:"varint,5,opt,name=until_time,json=untilTime" json:"until_time,omitempty"` } func (m *EventFilter) Reset() { *m = EventFilter{} } @@ -748,11 +744,11 @@ func (m *ListenEventsResponse) GetEvents() []*Event { // Request for GetLogs(). type GetLogsRequest struct { // ID of the pod which we will get logs from, required. - PodId string `protobuf:"bytes,1,opt,name=pod_id" json:"pod_id,omitempty"` + PodId string `protobuf:"bytes,1,opt,name=pod_id,json=podId" json:"pod_id,omitempty"` // Name of the app within the pod which we will get logs // from, optional. If not set, then the logs of all the // apps within the pod will be returned. - AppName string `protobuf:"bytes,2,opt,name=app_name" json:"app_name,omitempty"` + AppName string `protobuf:"bytes,2,opt,name=app_name,json=appName" json:"app_name,omitempty"` // Number of most recent lines to return, optional. Lines int32 `protobuf:"varint,3,opt,name=lines" json:"lines,omitempty"` // If true, then a response stream will not be closed, @@ -760,10 +756,10 @@ type GetLogsRequest struct { Follow bool `protobuf:"varint,4,opt,name=follow" json:"follow,omitempty"` // If set, then only the logs after the timestamp will // be returned, optional. - SinceTime int64 `protobuf:"varint,5,opt,name=since_time" json:"since_time,omitempty"` + SinceTime int64 `protobuf:"varint,5,opt,name=since_time,json=sinceTime" json:"since_time,omitempty"` // If set, then only the logs before the timestamp will // be returned, optional. - UntilTime int64 `protobuf:"varint,6,opt,name=until_time" json:"until_time,omitempty"` + UntilTime int64 `protobuf:"varint,6,opt,name=until_time,json=untilTime" json:"until_time,omitempty"` } func (m *GetLogsRequest) Reset() { *m = GetLogsRequest{} } @@ -819,6 +815,10 @@ func init() { var _ context.Context var _ grpc.ClientConn +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion1 + // Client API for PublicAPI service type PublicAPIClient interface { @@ -1132,97 +1132,111 @@ var _PublicAPI_serviceDesc = grpc.ServiceDesc{ } var fileDescriptor0 = []byte{ - // 1469 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x57, 0x4b, 0x72, 0xdb, 0x46, - 0x13, 0x36, 0x1f, 0xe0, 0xa3, 0x49, 0x53, 0xe4, 0x48, 0xb6, 0x28, 0xfa, 0x25, 0xe3, 0xff, 0xe3, - 0x72, 0xb4, 0x50, 0x12, 0xd9, 0xf1, 0x26, 0x55, 0x29, 0xd3, 0x12, 0xa4, 0x62, 0x2c, 0x91, 0x2c, - 0x9a, 0x76, 0xc5, 0x2b, 0x14, 0x44, 0x0e, 0x65, 0x94, 0x41, 0x00, 0x01, 0x40, 0xd9, 0xca, 0x32, - 0x17, 0xc8, 0x11, 0x72, 0x86, 0xac, 0xb2, 0xcc, 0x5d, 0x52, 0x95, 0x0b, 0xe4, 0x04, 0xe9, 0x19, - 0x0c, 0x80, 0x01, 0x08, 0x2e, 0xb2, 0x13, 0xbb, 0x7b, 0xbe, 0xfe, 0xba, 0xa7, 0xfb, 0x1b, 0x08, - 0xea, 0x86, 0x6b, 0x1e, 0xba, 0x9e, 0x13, 0x38, 0xa4, 0x7a, 0xfd, 0x8d, 0x61, 0xb9, 0x1f, 0x0c, - 0xf5, 0x25, 0x34, 0x06, 0x4b, 0xe3, 0x8a, 0x9e, 0x3a, 0xde, 0xd2, 0x08, 0xc8, 0x3e, 0x94, 0x83, - 0x1b, 0x97, 0x76, 0x0b, 0xfb, 0x85, 0xa7, 0xad, 0x23, 0x72, 0x28, 0xc2, 0x0e, 0x79, 0xcc, 0x14, - 0x3d, 0x64, 0x0b, 0xaa, 0xd7, 0xd4, 0xf3, 0x4d, 0xc7, 0xee, 0x16, 0x31, 0xa8, 0xae, 0xfe, 0x59, - 0x00, 0x85, 0xbb, 0xc9, 0x97, 0xd0, 0xb8, 0x34, 0x7c, 0xaa, 0x2f, 0x38, 0x16, 0xc7, 0x68, 0x1c, - 0xed, 0xa4, 0x31, 0x44, 0x1e, 0x80, 0xa2, 0x39, 0x0f, 0x01, 0x48, 0x13, 0xca, 0xb6, 0xb1, 0xa4, - 0xdd, 0x12, 0xff, 0x25, 0xe1, 0x97, 0xb9, 0xa1, 0x0b, 0x6d, 0x73, 0xe9, 0x3a, 0x5e, 0xa0, 0x07, - 0xe6, 0x92, 0xfa, 0x81, 0xb1, 0x74, 0xbb, 0x0a, 0x7a, 0x4a, 0xa4, 0x0d, 0xb5, 0xa5, 0x61, 0x9b, - 0x0b, 0x34, 0x76, 0x2b, 0x68, 0x69, 0x32, 0x28, 0xdf, 0xfc, 0x99, 0x76, 0xab, 0xdc, 0xff, 0x04, - 0x1a, 0x86, 0x6d, 0x3b, 0x81, 0x11, 0x20, 0x9a, 0xdf, 0xad, 0xed, 0x97, 0x90, 0x4f, 0x27, 0xe6, - 0xf3, 0x9a, 0xde, 0xbc, 0x33, 0xac, 0x15, 0x55, 0x9f, 0x41, 0x75, 0x48, 0x83, 0x4f, 0x8e, 0xf7, - 0x31, 0xe6, 0x52, 0x88, 0x98, 0x99, 0xee, 0xf5, 0xf3, 0x84, 0x27, 0xfe, 0x7a, 0x11, 0xf2, 0x54, - 0x7f, 0x2d, 0x40, 0xa9, 0xef, 0xba, 0x99, 0x13, 0x0f, 0x40, 0x31, 0x59, 0x99, 0xfc, 0x48, 0xe3, - 0xa8, 0x95, 0x2e, 0x1e, 0xdb, 0xab, 0x60, 0x01, 0x41, 0x58, 0x6b, 0x4b, 0xe2, 0x82, 0x48, 0x6f, - 0x98, 0x83, 0x74, 0xa0, 0x4e, 0x3f, 0x9b, 0x81, 0x3e, 0x73, 0xe6, 0x94, 0x37, 0xa0, 0x93, 0x2d, - 0x43, 0xd9, 0x54, 0xc6, 0x3f, 0xc8, 0x68, 0xec, 0xcc, 0x45, 0x6f, 0x43, 0x3e, 0x0d, 0x28, 0xb9, - 0xa2, 0xd1, 0x9d, 0xcd, 0xd9, 0xf1, 0x54, 0x98, 0xbd, 0x07, 0x65, 0xc3, 0x75, 0x7d, 0x4c, 0xcc, - 0x72, 0x34, 0x65, 0x7a, 0x44, 0x85, 0x9a, 0x1d, 0x76, 0x29, 0xe2, 0xd0, 0x8e, 0xfd, 0x51, 0xfb, - 0xd6, 0x6f, 0x24, 0x43, 0xbe, 0xba, 0x81, 0x3c, 0x69, 0x41, 0x65, 0x76, 0xe5, 0x39, 0x2b, 0x17, - 0xaf, 0x89, 0x11, 0xc7, 0x2a, 0x66, 0x1e, 0x45, 0x4e, 0x73, 0x1d, 0x47, 0xa9, 0xce, 0xef, 0x13, - 0x6d, 0xc8, 0xdf, 0x13, 0x36, 0x60, 0x36, 0xf5, 0x09, 0xd4, 0x62, 0x0c, 0x2c, 0x16, 0xff, 0x16, - 0x95, 0xdf, 0x06, 0xe5, 0x9a, 0x59, 0xc5, 0x94, 0xfe, 0x5e, 0x80, 0x3a, 0x96, 0x79, 0x6a, 0x5a, - 0x01, 0xf5, 0x58, 0xa4, 0x39, 0xf7, 0x31, 0xb2, 0x84, 0x91, 0x8f, 0xa1, 0xc2, 0xdb, 0xe2, 0x63, - 0x68, 0x29, 0xbf, 0x2f, 0x1d, 0xb6, 0x3b, 0xae, 0xce, 0x2e, 0xda, 0xc7, 0xee, 0xb1, 0x53, 0x68, - 0xe2, 0x37, 0xad, 0x33, 0xa0, 0x32, 0x37, 0xdd, 0x81, 0xdb, 0xa2, 0x43, 0x22, 0x52, 0xe1, 0xe6, - 0x4c, 0x0b, 0x2a, 0x9b, 0x5a, 0x80, 0x93, 0x1f, 0xb6, 0x20, 0x6c, 0x53, 0x5d, 0xfd, 0xab, 0x10, - 0x2d, 0x67, 0x0e, 0x6b, 0x6c, 0xb5, 0xeb, 0xd1, 0x85, 0xf9, 0x59, 0xf0, 0xe6, 0x2d, 0xe3, 0xeb, - 0x27, 0xb3, 0xc4, 0xa8, 0x8f, 0xf4, 0x06, 0x29, 0xc5, 0x24, 0xb1, 0x5a, 0xcb, 0xb8, 0xa4, 0xd6, - 0xe6, 0x41, 0x22, 0x77, 0xa1, 0x15, 0x6e, 0x1c, 0x6b, 0xf4, 0x02, 0x33, 0xf3, 0xbb, 0x2c, 0x91, - 0x5d, 0xd8, 0x8a, 0xed, 0x97, 0x14, 0xb7, 0xfc, 0x3f, 0x2e, 0x1a, 0x63, 0xb8, 0x58, 0x59, 0x96, - 0x60, 0x58, 0xe7, 0x45, 0xfe, 0x86, 0x45, 0x9e, 0x59, 0xce, 0xa5, 0x61, 0x9d, 0x5a, 0xc6, 0x95, - 0xcf, 0x8a, 0x9c, 0x9b, 0x9e, 0xb8, 0xc4, 0x3d, 0xe8, 0xf8, 0x37, 0x7e, 0x40, 0x97, 0xb8, 0x0f, - 0xf6, 0xc2, 0xbc, 0xd2, 0x99, 0xab, 0x18, 0xc9, 0x82, 0xe5, 0xcc, 0x0c, 0x4b, 0xf6, 0x84, 0x0a, - 0x82, 0x34, 0x57, 0x3e, 0xf5, 0x64, 0x47, 0xa8, 0x24, 0xac, 0x2e, 0xdb, 0xa7, 0xb3, 0x95, 0x87, - 0x1a, 0xc5, 0x92, 0x71, 0x1d, 0x61, 0x4b, 0x7b, 0x27, 0xf0, 0x56, 0x7e, 0xa0, 0x63, 0xab, 0x7c, - 0x7d, 0xe1, 0x39, 0x4b, 0xfd, 0x43, 0x10, 0xb8, 0x3e, 0x2f, 0xbb, 0xa6, 0x7a, 0x50, 0x1e, 0xd8, - 0x0b, 0x87, 0x6c, 0x43, 0xc3, 0xfb, 0x18, 0xe8, 0x91, 0x3a, 0x85, 0x0c, 0x77, 0xa0, 0x89, 0x93, - 0x31, 0xd3, 0x53, 0x9a, 0xc8, 0x42, 0x51, 0x6b, 0x63, 0x63, 0xc8, 0xeb, 0x00, 0x9a, 0x57, 0xbc, - 0x50, 0x91, 0xbc, 0x9c, 0xd1, 0x47, 0xa9, 0x0b, 0x98, 0x53, 0xd1, 0xae, 0xa9, 0xbd, 0x59, 0x90, - 0xb9, 0x97, 0x0b, 0x72, 0x46, 0x4a, 0x19, 0x7d, 0x91, 0x10, 0x7f, 0x31, 0xc9, 0xe4, 0x89, 0x4a, - 0xe4, 0x11, 0x94, 0xe7, 0x46, 0x60, 0x6c, 0xd6, 0x8f, 0x00, 0x1a, 0x1c, 0x55, 0x4c, 0xdb, 0x63, - 0x50, 0x58, 0xe6, 0x70, 0xde, 0xf2, 0x53, 0x8b, 0x81, 0x0c, 0xc7, 0x0f, 0x17, 0x4e, 0x9e, 0x3c, - 0xb6, 0xac, 0xa6, 0x3d, 0xa3, 0xba, 0x44, 0x01, 0x6d, 0x2b, 0x3b, 0x30, 0xad, 0xd0, 0xc6, 0x45, - 0x5c, 0x6d, 0x43, 0xeb, 0x8c, 0x06, 0xac, 0xc1, 0x13, 0xfa, 0xd3, 0x0a, 0x85, 0x43, 0x3d, 0x84, - 0xad, 0xd8, 0xe2, 0xbb, 0x38, 0x50, 0x94, 0xdc, 0x43, 0xe9, 0xc5, 0xdf, 0xe2, 0x49, 0xb9, 0x9d, - 0xa8, 0x2a, 0x1a, 0xd5, 0x53, 0xd8, 0x3a, 0x37, 0xfd, 0x00, 0x97, 0xd5, 0x17, 0x10, 0xe4, 0x7f, - 0x50, 0x5d, 0xf0, 0x2a, 0x42, 0xf6, 0x0d, 0x89, 0x7d, 0x22, 0x02, 0x28, 0x39, 0x73, 0x1a, 0x18, - 0xa6, 0xc5, 0x9b, 0x57, 0xc3, 0xbc, 0xed, 0x04, 0x47, 0x24, 0x46, 0x41, 0x74, 0x9d, 0x79, 0x84, - 0xd2, 0x94, 0x51, 0xd4, 0x47, 0xd0, 0x19, 0xd8, 0xbe, 0x4b, 0x67, 0xec, 0x48, 0x94, 0x59, 0x12, - 0x5f, 0xf5, 0x2b, 0x20, 0x72, 0x80, 0x80, 0xdc, 0x43, 0x49, 0x76, 0xe6, 0xa2, 0x94, 0x34, 0xe2, - 0x0f, 0xd0, 0x61, 0x0c, 0xf8, 0xce, 0xc7, 0xb5, 0x7c, 0x91, 0xad, 0x25, 0xfb, 0xa2, 0xe6, 0x57, - 0xf3, 0x1c, 0x88, 0x8c, 0x25, 0x92, 0x3f, 0x84, 0x0a, 0x57, 0xad, 0x08, 0x2b, 0xf3, 0x40, 0xa9, - 0x8f, 0x61, 0x5b, 0x50, 0xe6, 0xbf, 0xf3, 0xaa, 0xfa, 0x16, 0x76, 0xd2, 0x21, 0x02, 0x3a, 0x7e, - 0xfa, 0x0a, 0x79, 0x4f, 0x9f, 0xfa, 0x1d, 0x6c, 0x33, 0x3e, 0xd4, 0xe6, 0xe3, 0x13, 0x57, 0xf7, - 0x7f, 0xa8, 0x84, 0xd5, 0xad, 0x7d, 0x2e, 0x48, 0xb3, 0xa8, 0xbe, 0x80, 0x9d, 0xf4, 0xe1, 0xa4, - 0x1c, 0xca, 0x2d, 0x6b, 0xe5, 0xf0, 0x40, 0xf5, 0x86, 0x0f, 0xd7, 0xb9, 0x73, 0x15, 0xe7, 0xc3, - 0x36, 0x61, 0xf7, 0xf5, 0xf8, 0x81, 0x44, 0x81, 0x8c, 0x94, 0x5d, 0xec, 0x10, 0xce, 0xb1, 0x65, - 0xda, 0x7c, 0x8e, 0x0b, 0x4f, 0x15, 0x76, 0x60, 0xe1, 0x58, 0x96, 0xf3, 0x89, 0xcf, 0x70, 0x2d, - 0x33, 0xd7, 0x4a, 0xce, 0x5c, 0x73, 0xb1, 0x54, 0xf7, 0xf9, 0x14, 0x87, 0xa9, 0x05, 0xdb, 0x18, - 0x99, 0x2b, 0xf8, 0x01, 0x85, 0x7a, 0xf2, 0x59, 0xd5, 0xc5, 0xae, 0x5e, 0xf4, 0xcf, 0x34, 0x7d, - 0xfa, 0x7e, 0xac, 0xe9, 0x6f, 0x87, 0x27, 0xda, 0xe9, 0x60, 0xa8, 0x9d, 0xb4, 0x6f, 0xa1, 0x96, - 0x6c, 0x49, 0x9e, 0xfe, 0x78, 0x7c, 0xdc, 0x2e, 0xe0, 0x53, 0xd3, 0x91, 0x8c, 0x27, 0xa3, 0xe3, - 0xd7, 0xda, 0xa4, 0x5d, 0x44, 0x22, 0x2d, 0xc9, 0x3c, 0x3a, 0x1e, 0xb4, 0x4b, 0x07, 0x63, 0xa8, - 0xc5, 0x5f, 0x17, 0xbb, 0xb0, 0x8d, 0x00, 0xfa, 0x9b, 0x69, 0x7f, 0x9a, 0x4e, 0x82, 0x78, 0x89, - 0x63, 0xf2, 0x76, 0x38, 0x1c, 0x0c, 0xcf, 0x30, 0xcd, 0x0e, 0xb4, 0x13, 0xb3, 0xf6, 0xe3, 0x60, - 0x8a, 0xc1, 0xc5, 0x83, 0xbf, 0x0b, 0x50, 0x8b, 0x9f, 0x46, 0x84, 0x1c, 0x8f, 0x4e, 0x72, 0x20, - 0xf1, 0x6c, 0xe2, 0xd0, 0x2e, 0x5e, 0x4d, 0xde, 0x8f, 0x10, 0x31, 0x15, 0x3e, 0x9e, 0x68, 0xe3, - 0xfe, 0x84, 0xa5, 0x2a, 0xa2, 0x38, 0x93, 0xac, 0x03, 0x61, 0x4a, 0x8c, 0x59, 0x62, 0x8f, 0x98, - 0x95, 0x71, 0xda, 0xf6, 0x12, 0x73, 0xff, 0xd5, 0x68, 0x82, 0xd4, 0xa2, 0x63, 0x6d, 0x25, 0x93, - 0x3c, 0x24, 0x5e, 0x49, 0xe7, 0x38, 0xd1, 0xce, 0xb5, 0x29, 0x03, 0xab, 0xa6, 0x73, 0x9c, 0xf5, - 0x27, 0xaf, 0xb0, 0x85, 0xed, 0xda, 0xc1, 0x1f, 0x45, 0xa8, 0x27, 0x62, 0x87, 0x37, 0xa4, 0xbd, - 0xd3, 0x86, 0xd3, 0xf5, 0x1b, 0xba, 0x07, 0xbb, 0x92, 0x87, 0x21, 0xc5, 0xfc, 0x0b, 0xf8, 0xd9, - 0xf4, 0x30, 0xdf, 0x19, 0xb1, 0xc6, 0xda, 0x7b, 0x70, 0x37, 0x13, 0x83, 0x54, 0xb8, 0xaf, 0x84, - 0x72, 0x71, 0x27, 0xe3, 0x13, 0xe5, 0x94, 0x71, 0x77, 0xf6, 0x33, 0x2e, 0xc1, 0x5d, 0x3f, 0x1e, - 0x9d, 0x9f, 0x6b, 0xc7, 0x2c, 0x4a, 0xc9, 0x80, 0x8b, 0xeb, 0x9c, 0x84, 0x0d, 0x49, 0x83, 0x33, - 0x9f, 0x00, 0xaf, 0xb2, 0x06, 0x4b, 0xae, 0x70, 0xaa, 0x06, 0x17, 0xe3, 0x90, 0x72, 0x8d, 0xdc, - 0x87, 0xee, 0x9a, 0x7b, 0xa2, 0x5d, 0x8c, 0xde, 0xa1, 0xb7, 0x7e, 0xf4, 0x4b, 0x19, 0xbf, 0xb6, - 0x56, 0x97, 0x96, 0x39, 0xeb, 0x8f, 0x07, 0xe4, 0x7b, 0xa8, 0x0a, 0x41, 0x27, 0xbb, 0xc9, 0x6b, - 0x97, 0x12, 0xfd, 0x5e, 0x77, 0xdd, 0x11, 0x6e, 0x8d, 0x7a, 0x8b, 0xf4, 0xa1, 0x16, 0x09, 0x33, - 0x49, 0xe2, 0x32, 0x9a, 0xdf, 0xdb, 0xcb, 0xf1, 0xc4, 0x10, 0x67, 0x00, 0x89, 0x14, 0x93, 0x9e, - 0xf4, 0x80, 0x64, 0x04, 0xbc, 0x77, 0x2f, 0xd7, 0x27, 0x03, 0x25, 0xb2, 0x2a, 0x01, 0xad, 0xe9, - 0xb6, 0x04, 0xb4, 0xae, 0xc3, 0x08, 0x74, 0x01, 0x4d, 0x59, 0x46, 0xc9, 0xfd, 0x6c, 0x5e, 0x59, - 0x80, 0x7b, 0x0f, 0x36, 0x78, 0x63, 0xb8, 0x11, 0x34, 0x65, 0x85, 0x94, 0xe0, 0x72, 0x54, 0x57, - 0x82, 0xcb, 0x93, 0x55, 0xf5, 0xd6, 0xd7, 0x05, 0xf2, 0x92, 0x5f, 0x1a, 0xd3, 0xaf, 0xf4, 0xa5, - 0x49, 0x62, 0x9a, 0xbe, 0x34, 0x59, 0xea, 0x18, 0xc2, 0x65, 0x85, 0xff, 0xab, 0xf9, 0xec, 0xdf, - 0x00, 0x00, 0x00, 0xff, 0xff, 0xba, 0xf4, 0x5c, 0xf5, 0x77, 0x0e, 0x00, 0x00, + // 1692 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x9c, 0x58, 0xcd, 0x6f, 0xdb, 0xc8, + 0x15, 0x0f, 0xf5, 0xad, 0x27, 0x59, 0x96, 0xc7, 0x4e, 0xa2, 0x38, 0x1f, 0x75, 0x99, 0x26, 0x71, + 0x8d, 0xc2, 0x68, 0x9c, 0xb4, 0xbd, 0x04, 0x41, 0x65, 0x99, 0x76, 0x85, 0xd8, 0x92, 0xc0, 0x28, + 0x6e, 0x83, 0x1e, 0x08, 0x5a, 0x1a, 0x39, 0x44, 0x28, 0x91, 0x15, 0x29, 0x27, 0xee, 0xb1, 0xb7, + 0x02, 0x45, 0xff, 0x83, 0xde, 0x7a, 0xde, 0xeb, 0x02, 0x7b, 0xdf, 0x3f, 0x65, 0xff, 0x85, 0xdd, + 0xeb, 0xbe, 0xf9, 0x20, 0x39, 0xa4, 0x65, 0xc3, 0xd8, 0xdb, 0xcc, 0xfb, 0xbd, 0xf9, 0xcd, 0xfb, + 0x98, 0xf7, 0x1e, 0x25, 0xa8, 0xda, 0xbe, 0xb3, 0xeb, 0xcf, 0xbd, 0xd0, 0x23, 0xe5, 0x8b, 0x97, + 0xb6, 0xeb, 0x7f, 0xb2, 0xf5, 0x3e, 0xd4, 0xba, 0x53, 0xfb, 0x9c, 0x1e, 0x7a, 0xf3, 0xa9, 0x1d, + 0x92, 0xe7, 0x50, 0x08, 0x2f, 0x7d, 0xda, 0xd2, 0xb6, 0xb4, 0xed, 0xc6, 0x1e, 0xd9, 0x95, 0x6a, + 0xbb, 0x5c, 0x67, 0x88, 0x88, 0xc9, 0x71, 0xd2, 0x82, 0xf2, 0x05, 0x9d, 0x07, 0x8e, 0x37, 0x6b, + 0xe5, 0x50, 0xb5, 0x6a, 0x46, 0x5b, 0xfd, 0x3f, 0x39, 0x28, 0x72, 0x6d, 0xf2, 0x07, 0xa8, 0x9d, + 0xd9, 0x01, 0xb5, 0x26, 0x9c, 0x9a, 0x53, 0xd6, 0xf6, 0x36, 0xd2, 0x94, 0xe2, 0x5a, 0x13, 0x98, + 0xa2, 0x34, 0xa1, 0x01, 0x39, 0x67, 0x2c, 0x59, 0x71, 0x45, 0x08, 0x14, 0x66, 0xf6, 0x94, 0xb6, + 0xf2, 0x5c, 0xc2, 0xd7, 0xea, 0xf5, 0x85, 0xd4, 0xf5, 0xe4, 0xb7, 0xd0, 0x74, 0xa6, 0xbe, 0x37, + 0x0f, 0xad, 0xd0, 0x99, 0xd2, 0x20, 0xb4, 0xa7, 0x7e, 0xab, 0x88, 0x2a, 0x79, 0x73, 0x55, 0xc8, + 0x87, 0x91, 0x98, 0x6c, 0x42, 0x65, 0x6a, 0xcf, 0x9c, 0x09, 0x6e, 0x5b, 0x25, 0x54, 0xa9, 0x9b, + 0xf1, 0x9e, 0x5d, 0x1a, 0x38, 0xff, 0xa4, 0xad, 0x32, 0x3f, 0xca, 0xd7, 0xe4, 0x15, 0xd4, 0xec, + 0xd9, 0xcc, 0x0b, 0xed, 0x10, 0x2f, 0x0a, 0x5a, 0x95, 0xad, 0x3c, 0xfa, 0xb3, 0x16, 0xfb, 0xf3, + 0x8e, 0x5e, 0x9e, 0xda, 0xee, 0x82, 0x9a, 0xaa, 0x96, 0x6e, 0x40, 0xb9, 0x47, 0xc3, 0x2f, 0xde, + 0xfc, 0x73, 0xec, 0x88, 0xa6, 0x38, 0x82, 0x32, 0xc7, 0xbf, 0x78, 0x2d, 0xdd, 0xe5, 0x6b, 0x29, + 0xfb, 0x63, 0xe4, 0x30, 0x5b, 0xeb, 0xdf, 0x69, 0x90, 0x6f, 0xfb, 0xfe, 0x52, 0x8e, 0xdf, 0x40, + 0xd1, 0x61, 0xb1, 0xe4, 0x24, 0xb5, 0xbd, 0x46, 0x3a, 0xc2, 0xa6, 0x00, 0xc9, 0x0b, 0x28, 0xa2, + 0xdb, 0xa1, 0x88, 0x63, 0x43, 0xb1, 0x1b, 0x69, 0xdf, 0x33, 0xc0, 0x14, 0x38, 0x79, 0x08, 0x55, + 0xfa, 0xd5, 0x09, 0xad, 0x91, 0x37, 0xa6, 0x3c, 0xba, 0x6b, 0x66, 0x85, 0x09, 0x3a, 0xb8, 0xcf, + 0xc6, 0xa0, 0x78, 0xab, 0x18, 0xfc, 0x3b, 0x07, 0xf9, 0x81, 0x37, 0x96, 0x99, 0xd5, 0xe2, 0xcc, + 0x36, 0x21, 0xef, 0xcb, 0x54, 0xaf, 0x99, 0x6c, 0x79, 0xbd, 0x91, 0x78, 0x3c, 0x65, 0xe4, 0x16, + 0x14, 0x6c, 0xdf, 0x0f, 0xd0, 0x3e, 0x66, 0x40, 0x5d, 0x75, 0xc6, 0xe4, 0x08, 0xf9, 0x1d, 0x54, + 0x66, 0x22, 0xf0, 0x91, 0x99, 0xcd, 0x58, 0x4b, 0x66, 0xc4, 0x8c, 0x35, 0x6e, 0x7c, 0x0b, 0x19, + 0x9f, 0xcb, 0xb7, 0xf1, 0x99, 0xdc, 0x83, 0xd2, 0xe8, 0x7c, 0xee, 0x2d, 0x7c, 0x7c, 0x27, 0xcc, + 0x5f, 0xb9, 0xd3, 0xf7, 0xa0, 0x12, 0x1d, 0x60, 0xfe, 0xe3, 0x5a, 0x06, 0x24, 0xff, 0x99, 0x5e, + 0x92, 0x0d, 0x28, 0x5e, 0x30, 0x48, 0xbe, 0x07, 0xb1, 0xd1, 0x7f, 0xd4, 0xa0, 0x8a, 0x01, 0x38, + 0x74, 0xdc, 0x90, 0xce, 0xd9, 0x29, 0x67, 0x1c, 0xe0, 0xa9, 0x3c, 0x3b, 0x85, 0x4b, 0x7c, 0xf3, + 0x25, 0x1e, 0x95, 0x00, 0x8f, 0xe5, 0x97, 0x87, 0x4d, 0x2a, 0xb0, 0xe4, 0x62, 0x74, 0x2c, 0xf6, + 0x6e, 0x02, 0x0c, 0x32, 0xa3, 0xa8, 0xa0, 0xa0, 0xc7, 0xf6, 0x0c, 0xe4, 0x6f, 0xc5, 0x62, 0xfc, + 0x05, 0x01, 0x72, 0x41, 0x17, 0x2f, 0x79, 0x0a, 0x2b, 0x32, 0x5a, 0xf2, 0x74, 0x91, 0x2b, 0xd4, + 0xa5, 0x50, 0x30, 0x64, 0x42, 0x55, 0xba, 0x55, 0xa8, 0xb0, 0x98, 0x45, 0x70, 0x44, 0x6c, 0xb1, + 0x98, 0xe5, 0x56, 0xff, 0x3e, 0x17, 0x75, 0xa7, 0xeb, 0x5c, 0xc7, 0xbc, 0xf9, 0x73, 0x3a, 0x71, + 0xbe, 0x4a, 0xe7, 0xd1, 0xe2, 0x68, 0x4f, 0x1e, 0x03, 0x6f, 0x2b, 0x29, 0x67, 0xab, 0x4c, 0x22, + 0x6c, 0xc5, 0xa3, 0x18, 0x72, 0xb4, 0x3d, 0x71, 0x36, 0xda, 0xb3, 0x88, 0xba, 0xf6, 0x19, 0x75, + 0x6f, 0x78, 0xe1, 0x52, 0x81, 0x3c, 0x83, 0x86, 0x68, 0x2c, 0x74, 0x6c, 0xd9, 0x13, 0xb4, 0x92, + 0xbf, 0x9f, 0xbc, 0xb9, 0x12, 0x49, 0xdb, 0x4c, 0x88, 0x2f, 0x7b, 0x35, 0x56, 0x3b, 0xa3, 0xd8, + 0x12, 0xa3, 0xde, 0x12, 0x9f, 0xde, 0xe7, 0xd2, 0x5f, 0xd4, 0x65, 0x98, 0xab, 0x93, 0x85, 0xeb, + 0x4a, 0x57, 0xab, 0xc2, 0x55, 0x26, 0xe1, 0xae, 0xea, 0x3f, 0x69, 0x50, 0x3b, 0x72, 0xbd, 0x33, + 0xdb, 0x3d, 0x74, 0xed, 0xf3, 0x80, 0xc5, 0x71, 0xec, 0xcc, 0xa3, 0x87, 0x87, 0x4b, 0xb2, 0x03, + 0x6b, 0xc1, 0x65, 0x10, 0xd2, 0x29, 0x96, 0xfd, 0x6c, 0xe2, 0x9c, 0x5b, 0x0c, 0x17, 0x8f, 0x70, + 0x55, 0x00, 0x1d, 0x2e, 0x3f, 0x40, 0xdd, 0x6d, 0x68, 0xba, 0xde, 0xc8, 0x76, 0x55, 0x55, 0xd1, + 0xab, 0x1a, 0x5c, 0x9e, 0x68, 0x3e, 0x87, 0xd5, 0x45, 0x40, 0xe7, 0xaa, 0xa2, 0x68, 0xd7, 0x2b, + 0x4c, 0x9c, 0xe8, 0xb1, 0x18, 0xce, 0x02, 0x3a, 0x5a, 0xcc, 0x71, 0x5a, 0x30, 0x0b, 0x79, 0xcb, + 0x46, 0xb5, 0x48, 0x2a, 0xcc, 0x7e, 0x09, 0x77, 0xc3, 0xf9, 0x22, 0x08, 0x2d, 0xcc, 0x53, 0x60, + 0x4d, 0xe6, 0xde, 0xd4, 0xfa, 0x14, 0x86, 0x7e, 0xc0, 0x23, 0x5e, 0x31, 0x09, 0x07, 0x31, 0x40, + 0xc1, 0x21, 0x42, 0x7f, 0x61, 0x88, 0xfe, 0x7f, 0x0d, 0x0a, 0xdd, 0xd9, 0xc4, 0x23, 0xbf, 0x82, + 0xda, 0xfc, 0x73, 0x68, 0x45, 0x53, 0x43, 0xb8, 0x0e, 0x28, 0x3a, 0x95, 0x83, 0xe3, 0xd7, 0x50, + 0xc7, 0x42, 0x18, 0x59, 0xe9, 0xb1, 0x56, 0x63, 0xb2, 0x48, 0x05, 0x39, 0x70, 0x82, 0xc6, 0x1a, + 0xc2, 0x67, 0x40, 0x51, 0xa4, 0xf0, 0x27, 0xa8, 0x9f, 0xf3, 0x30, 0x4b, 0x2f, 0x0a, 0x99, 0x91, + 0xa7, 0xe4, 0xc0, 0xac, 0x9d, 0x27, 0x1b, 0xfd, 0xbf, 0x1a, 0x14, 0x8d, 0x0b, 0x3a, 0xbb, 0x7e, + 0x00, 0x73, 0x54, 0x19, 0xc0, 0x4b, 0xa6, 0x24, 0x0b, 0x48, 0x34, 0x34, 0xd8, 0x9a, 0xc9, 0xd8, + 0x10, 0xe4, 0x66, 0xe0, 0x10, 0x63, 0x6b, 0x0c, 0x75, 0x61, 0x6c, 0x87, 0xf6, 0xf5, 0xef, 0x9a, + 0xc3, 0xfa, 0xff, 0xf0, 0xc5, 0xf0, 0x2b, 0x65, 0xe5, 0x6d, 0x43, 0x91, 0x5d, 0x2b, 0x6a, 0x6f, + 0xb9, 0x5d, 0x42, 0x21, 0xaa, 0xd1, 0x5c, 0x52, 0xa3, 0xd8, 0xd4, 0xd4, 0x12, 0x14, 0x1b, 0xf6, + 0x64, 0x03, 0x67, 0x36, 0xa2, 0x96, 0x62, 0x62, 0x95, 0x4b, 0xd8, 0x84, 0x66, 0xf0, 0x62, 0x16, + 0x3a, 0xae, 0x80, 0xc5, 0x04, 0xaf, 0x72, 0x09, 0x83, 0xf5, 0x26, 0x34, 0x8e, 0x68, 0xc8, 0x32, + 0x6b, 0xd2, 0x7f, 0x2c, 0xb0, 0x4b, 0xeb, 0xaf, 0x61, 0x35, 0x96, 0x04, 0x3e, 0x16, 0x05, 0xc5, + 0x94, 0x16, 0x1c, 0xdc, 0xcb, 0x2f, 0x8f, 0x95, 0x64, 0x2e, 0x32, 0x25, 0x0e, 0xe9, 0x7f, 0x85, + 0xd5, 0x63, 0x27, 0x08, 0xb1, 0x4f, 0x06, 0x92, 0x08, 0x07, 0x47, 0x79, 0xc2, 0x9d, 0x16, 0xce, + 0xd6, 0x14, 0x67, 0xe3, 0x26, 0x6c, 0x46, 0x2a, 0xac, 0xcf, 0x8f, 0x69, 0x68, 0x3b, 0x2e, 0xcf, + 0x45, 0xc5, 0x94, 0x3b, 0x34, 0xa7, 0x99, 0x10, 0x4b, 0x7b, 0x70, 0x68, 0xf9, 0xde, 0x38, 0xa2, + 0xad, 0xab, 0xb4, 0x26, 0x47, 0xf4, 0xa7, 0xb0, 0xd6, 0x9d, 0x05, 0x3e, 0x1d, 0xb1, 0x83, 0x91, + 0x41, 0x99, 0xb1, 0x89, 0xd4, 0x44, 0x55, 0x92, 0xe4, 0x4f, 0x70, 0x98, 0x7a, 0x63, 0xe9, 0x6b, + 0x9a, 0x9b, 0x01, 0xfa, 0xdf, 0x61, 0x8d, 0x19, 0xc4, 0xdb, 0x69, 0xec, 0xeb, 0x6e, 0xd6, 0xd7, + 0xec, 0xe7, 0xd9, 0x2d, 0xbd, 0x7d, 0x03, 0x44, 0x25, 0x97, 0x26, 0x3d, 0x87, 0x12, 0x1f, 0x1f, + 0x11, 0x79, 0xf6, 0xcb, 0x44, 0xa2, 0xfa, 0x33, 0x58, 0x97, 0x0e, 0x09, 0xf9, 0x35, 0x7e, 0xbf, + 0x81, 0x8d, 0xb4, 0x9a, 0xbc, 0x26, 0xfe, 0xfe, 0xd1, 0x6e, 0xf8, 0xfe, 0xd1, 0x3b, 0xb0, 0xce, + 0x4c, 0xa4, 0x33, 0xfe, 0x62, 0x95, 0x6c, 0x97, 0x84, 0x73, 0x57, 0xbe, 0x4f, 0x95, 0xe7, 0x6f, + 0x4a, 0x1d, 0xfd, 0x2d, 0x6c, 0xa4, 0x49, 0x12, 0x4f, 0x29, 0x97, 0x5c, 0xf1, 0x94, 0x2b, 0x9a, + 0x12, 0xd5, 0xbf, 0xd1, 0xf8, 0xbb, 0x3d, 0xf6, 0xce, 0x63, 0x03, 0xee, 0x42, 0x09, 0xd3, 0x63, + 0xc5, 0x9e, 0x16, 0x71, 0xd7, 0x1d, 0x93, 0x07, 0x50, 0x89, 0x06, 0x75, 0xf4, 0x85, 0x2d, 0xe7, + 0x34, 0xab, 0x27, 0xd7, 0x99, 0xf1, 0x7a, 0xd2, 0xb6, 0x8b, 0xa6, 0xd8, 0xb0, 0xd4, 0x4c, 0x3c, + 0xd7, 0xf5, 0xbe, 0xf0, 0x5a, 0xc2, 0xd4, 0x88, 0x5d, 0xa6, 0xce, 0x8a, 0x37, 0xd7, 0x59, 0x29, + 0x5b, 0x67, 0x2f, 0x78, 0x55, 0x09, 0x7b, 0xa5, 0xaf, 0xf1, 0xf5, 0x62, 0x0c, 0x8b, 0xcd, 0x0e, + 0x85, 0x6a, 0xfc, 0x1b, 0x01, 0x27, 0xfa, 0x46, 0xf7, 0xa4, 0x7d, 0x64, 0x58, 0xc3, 0x8f, 0x03, + 0xc3, 0xfa, 0xd0, 0x3b, 0x30, 0x0e, 0xbb, 0x3d, 0xe3, 0xa0, 0x79, 0x87, 0xac, 0xc3, 0xaa, 0x82, + 0xb4, 0x07, 0x83, 0x4e, 0x53, 0xc3, 0x10, 0xac, 0x29, 0xc2, 0x83, 0x7e, 0xe7, 0x9d, 0x61, 0x36, + 0x73, 0xd8, 0xbe, 0x1a, 0x8a, 0xb8, 0xdf, 0xe9, 0x36, 0xf3, 0x3b, 0x03, 0xa8, 0x44, 0xdf, 0xab, + 0xe4, 0x3e, 0xac, 0x23, 0x81, 0xf5, 0x7e, 0xd8, 0x1e, 0xa6, 0x2f, 0x41, 0xbe, 0x04, 0x30, 0x3f, + 0xf4, 0x7a, 0xdd, 0xde, 0x11, 0x5e, 0xb3, 0x01, 0xcd, 0x44, 0x6c, 0xfc, 0xad, 0x3b, 0x44, 0xe5, + 0xdc, 0xce, 0x0f, 0x1a, 0x54, 0xa2, 0xcf, 0x24, 0x46, 0x39, 0xe8, 0x1f, 0x2c, 0xa1, 0xc4, 0xb3, + 0x09, 0x60, 0x9c, 0xec, 0x9b, 0x1f, 0xfb, 0xc8, 0x98, 0x52, 0x1f, 0x98, 0xc6, 0xa0, 0x6d, 0xb2, + 0xab, 0x72, 0x98, 0x0c, 0x92, 0x05, 0x90, 0x26, 0xcf, 0x2c, 0x4b, 0xe4, 0x91, 0x65, 0x05, 0x4c, + 0xc2, 0x83, 0x44, 0xdc, 0xde, 0xef, 0x9b, 0x68, 0x5a, 0x74, 0xac, 0x59, 0xcc, 0x5c, 0x2e, 0x0c, + 0x2f, 0xa5, 0xef, 0x38, 0x30, 0x8e, 0x8d, 0x21, 0x23, 0x2b, 0xa7, 0xef, 0x38, 0x6a, 0x9b, 0xfb, + 0x18, 0xc2, 0x66, 0x65, 0xe7, 0xdb, 0x1c, 0x54, 0xe3, 0x66, 0xcd, 0x32, 0x64, 0x9c, 0x1a, 0xbd, + 0xe1, 0xd5, 0x0c, 0x3d, 0x84, 0xfb, 0x0a, 0xc2, 0x98, 0x62, 0xfb, 0x35, 0xa2, 0xc3, 0x93, 0xe5, + 0x60, 0x64, 0x35, 0xfa, 0xbe, 0x09, 0xf7, 0x32, 0x3a, 0x68, 0x0a, 0xc7, 0xf2, 0xf8, 0xaa, 0xef, + 0x66, 0x30, 0xe9, 0x4e, 0x01, 0xab, 0x78, 0x2b, 0x03, 0x49, 0xdb, 0xad, 0x4e, 0xff, 0xf8, 0xd8, + 0xe8, 0x30, 0xad, 0x62, 0x86, 0x5c, 0xa6, 0xd3, 0x14, 0x01, 0x49, 0x93, 0x33, 0x4c, 0x92, 0x97, + 0x59, 0x80, 0x15, 0x48, 0xbc, 0xaa, 0xee, 0xc9, 0x40, 0x98, 0x5c, 0x21, 0x8f, 0xa0, 0x75, 0x05, + 0x36, 0x8d, 0x93, 0xfe, 0x29, 0xa2, 0xd5, 0xbd, 0x7f, 0x15, 0xf0, 0xf3, 0x7b, 0x71, 0xe6, 0x3a, + 0xa3, 0xf6, 0xa0, 0x4b, 0xde, 0x42, 0x59, 0xce, 0x19, 0x72, 0x3f, 0x19, 0xec, 0xa9, 0x59, 0xb4, + 0xd9, 0xba, 0x0a, 0x88, 0xe2, 0xd1, 0xef, 0x90, 0x36, 0x54, 0xa2, 0xc1, 0x40, 0x12, 0xbd, 0xcc, + 0x10, 0xda, 0x7c, 0xb0, 0x04, 0x89, 0x29, 0x8e, 0x00, 0x92, 0x01, 0x40, 0x36, 0x95, 0xb9, 0x96, + 0x19, 0x1d, 0x9b, 0x0f, 0x97, 0x62, 0x2a, 0x51, 0xd2, 0xb6, 0x15, 0xa2, 0x2b, 0x83, 0x42, 0x21, + 0xba, 0xda, 0xe7, 0x91, 0xe8, 0x04, 0xea, 0x6a, 0x6b, 0x26, 0x8f, 0xb2, 0xf7, 0xaa, 0x8d, 0x7d, + 0xf3, 0xf1, 0x35, 0x68, 0x4c, 0xd7, 0x87, 0xba, 0xda, 0x66, 0x15, 0xba, 0x25, 0x2d, 0x5c, 0xa1, + 0x5b, 0xd6, 0x9b, 0xf5, 0x3b, 0xbf, 0xd7, 0xc8, 0x9f, 0x79, 0xd2, 0x58, 0x1b, 0x4b, 0x27, 0x4d, + 0x69, 0xc4, 0xe9, 0xa4, 0xa9, 0x1d, 0x8f, 0x31, 0x9c, 0x95, 0xf8, 0xff, 0x26, 0xaf, 0x7e, 0x0e, + 0x00, 0x00, 0xff, 0xff, 0xef, 0x2c, 0x8a, 0x46, 0x44, 0x11, 0x00, 0x00, } diff --git a/api/v1alpha/api.proto b/api/v1alpha/api.proto index d28dda35e3..fc7174bf6c 100644 --- a/api/v1alpha/api.proto +++ b/api/v1alpha/api.proto @@ -12,9 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// To compile, run 'protoc -I api/v1alpha api/v1alpha/api.proto --go_out=plugins=grpc:api/v1alpha' in rkt root directory. -// The protoc version must be 3.0.0. - // *************************************************** // // ************ WARNING - HERE BE DRAGONS ************ // // // diff --git a/rkt/rkt.mk b/rkt/rkt.mk index be99d972f7..bbcb67b839 100644 --- a/rkt/rkt.mk +++ b/rkt/rkt.mk @@ -37,6 +37,9 @@ bash-completion: | $(GOPATH_TO_CREATE)/src/$(REPO_PATH) mkdir -p dist/bash_completion/ ls rkt/*.go | grep -vE '_test.go|main.go|_gen.go' | xargs go run rkt/bash_completion_gen.go +protobuf: + scripts/genproto.sh + $(call undefine-namespaces,LOCAL) # RKT_STAMP deliberately not cleared # RKT_BINARY deliberately not cleared diff --git a/scripts/genproto.sh b/scripts/genproto.sh new file mode 100755 index 0000000000..4d351350b5 --- /dev/null +++ b/scripts/genproto.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# Generate rkt protobuf bindings. +# Run from repository root. +# +set -e + +if ! [[ "$0" =~ "scripts/genproto.sh" ]]; then + echo "must be run from repository root" + exit 255 +fi + +if ! [[ $(protoc --version) =~ "3.0.0" ]]; then + echo "could not find protoc 3.0.0, is it installed + in PATH?" + exit 255 +fi + +export GOPATH=$(mktemp -d) +export PATH=${GOPATH}/bin:${PATH} + +trap 'rm -rf "${GOPATH}"' EXIT + +# git (sha) version of golang/protobuf +GO_PROTOBUF_SHA="dda510ac0fd43b39770f22ac6260eb91d377bce3" + +echo "installing golang/protobuf using GOPATH=${GOPATH}" +go get -u github.com/golang/protobuf/{proto,protoc-gen-go} + +echo "resetting golang/protobuf to version ${GO_PROTOBUF_SHA}" +pushd ${GOPATH}/src/github.com/golang/protobuf + git reset --hard "${GO_PROTOBUF_SHA}" + make install +popd + +API_DIR="api/v1alpha" +protoc -I "${API_DIR}" "${API_DIR}"/*.proto --go_out=plugins=grpc:"${API_DIR}" From 05f7817ffdf396b311dbbec84ea77dbd2351ee0c Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Tue, 5 Apr 2016 17:25:41 +0200 Subject: [PATCH 0079/1304] downgrade protobuf to the same version as in godeps --- api/v1alpha/api.pb.go | 56 ++++++++++++++++++++----------------------- scripts/genproto.sh | 2 +- 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/api/v1alpha/api.pb.go b/api/v1alpha/api.pb.go index b4057e7e4a..fed327f715 100644 --- a/api/v1alpha/api.pb.go +++ b/api/v1alpha/api.pb.go @@ -224,7 +224,7 @@ type Image struct { // Base format of the image, required. This indicates the original format // for the image as nowadays all the image formats will be transformed to // ACI. - BaseFormat *ImageFormat `protobuf:"bytes,1,opt,name=base_format,json=baseFormat" json:"base_format,omitempty"` + BaseFormat *ImageFormat `protobuf:"bytes,1,opt,name=base_format" json:"base_format,omitempty"` // ID of the image, a string that can be used to uniquely identify the image, // e.g. sha512 hash of the ACIs, required. Id string `protobuf:"bytes,2,opt,name=id" json:"id,omitempty"` @@ -233,7 +233,7 @@ type Image struct { // Version of the image, e.g. 'latest', '2.0.10', optional. Version string `protobuf:"bytes,4,opt,name=version" json:"version,omitempty"` // Timestamp of when the image is imported, it is the seconds since epoch, optional. - ImportTimestamp int64 `protobuf:"varint,5,opt,name=import_timestamp,json=importTimestamp" json:"import_timestamp,omitempty"` + ImportTimestamp int64 `protobuf:"varint,5,opt,name=import_timestamp" json:"import_timestamp,omitempty"` // JSON-encoded byte array that represents the image manifest, optional. Manifest []byte `protobuf:"bytes,6,opt,name=manifest,proto3" json:"manifest,omitempty"` // Size is the size in bytes of this image in the store. @@ -287,7 +287,7 @@ type App struct { State AppState `protobuf:"varint,3,opt,name=state,enum=v1alpha.AppState" json:"state,omitempty"` // Exit code of the app. optional, only valid if it's returned by InspectPod() and // the app has already exited. - ExitCode int32 `protobuf:"zigzag32,4,opt,name=exit_code,json=exitCode" json:"exit_code,omitempty"` + ExitCode int32 `protobuf:"zigzag32,4,opt,name=exit_code" json:"exit_code,omitempty"` // Annotations for this app. Annotations []*KeyValue `protobuf:"bytes,5,rep,name=annotations" json:"annotations,omitempty"` } @@ -370,7 +370,7 @@ func (m *Pod) GetAnnotations() []*KeyValue { type KeyValue struct { // Key part of the key-value pair. - Key string `protobuf:"bytes,1,opt,name=Key,json=key" json:"Key,omitempty"` + Key string `protobuf:"bytes,1,opt,name=Key" json:"Key,omitempty"` // Value part of the key-value pair. Value string `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"` } @@ -388,11 +388,11 @@ type PodFilter struct { // If not empty, the pods that have any of the states will be returned. States []PodState `protobuf:"varint,2,rep,name=states,enum=v1alpha.PodState" json:"states,omitempty"` // If not empty, the pods that all of the apps will be returned. - AppNames []string `protobuf:"bytes,3,rep,name=app_names,json=appNames" json:"app_names,omitempty"` + AppNames []string `protobuf:"bytes,3,rep,name=app_names" json:"app_names,omitempty"` // If not empty, the pods that have all of the images(in the apps) will be returned - ImageIds []string `protobuf:"bytes,4,rep,name=image_ids,json=imageIds" json:"image_ids,omitempty"` + ImageIds []string `protobuf:"bytes,4,rep,name=image_ids" json:"image_ids,omitempty"` // If not empty, the pods that are in all of the networks will be returned. - NetworkNames []string `protobuf:"bytes,5,rep,name=network_names,json=networkNames" json:"network_names,omitempty"` + NetworkNames []string `protobuf:"bytes,5,rep,name=network_names" json:"network_names,omitempty"` // If not empty, the pods that have all of the annotations will be returned. Annotations []*KeyValue `protobuf:"bytes,6,rep,name=annotations" json:"annotations,omitempty"` // If not empty, the pods whose cgroup are listed will be returned. @@ -421,20 +421,20 @@ type ImageFilter struct { // If not empty, the images that have any of the base names will be returned. // For example, both 'coreos.com/etcd' and 'k8s.io/etcd' will be returned if 'etcd' is included, // however 'k8s.io/etcd-backup' will not be returned. - BaseNames []string `protobuf:"bytes,3,rep,name=base_names,json=baseNames" json:"base_names,omitempty"` + BaseNames []string `protobuf:"bytes,3,rep,name=base_names" json:"base_names,omitempty"` // If not empty, the images that have any of the keywords in the name will be returned. // For example, both 'kubernetes-etcd', 'etcd:latest' will be returned if 'etcd' is included, Keywords []string `protobuf:"bytes,4,rep,name=keywords" json:"keywords,omitempty"` // If not empty, the images that have all of the labels will be returned. Labels []*KeyValue `protobuf:"bytes,5,rep,name=labels" json:"labels,omitempty"` // If set, the images that are imported after this timestamp will be returned. - ImportedAfter int64 `protobuf:"varint,6,opt,name=imported_after,json=importedAfter" json:"imported_after,omitempty"` + ImportedAfter int64 `protobuf:"varint,6,opt,name=imported_after" json:"imported_after,omitempty"` // If set, the images that are imported before this timestamp will be returned. - ImportedBefore int64 `protobuf:"varint,7,opt,name=imported_before,json=importedBefore" json:"imported_before,omitempty"` + ImportedBefore int64 `protobuf:"varint,7,opt,name=imported_before" json:"imported_before,omitempty"` // If not empty, the images that have all of the annotations will be returned. Annotations []*KeyValue `protobuf:"bytes,8,rep,name=annotations" json:"annotations,omitempty"` // If not empty, the images that have any of the exact full names will be returned. - FullNames []string `protobuf:"bytes,9,rep,name=full_names,json=fullNames" json:"full_names,omitempty"` + FullNames []string `protobuf:"bytes,9,rep,name=full_names" json:"full_names,omitempty"` } func (m *ImageFilter) Reset() { *m = ImageFilter{} } @@ -461,15 +461,15 @@ type GlobalFlags struct { // Data directory. Dir string `protobuf:"bytes,1,opt,name=dir" json:"dir,omitempty"` // System configuration directory. - SystemConfigDir string `protobuf:"bytes,2,opt,name=system_config_dir,json=systemConfigDir" json:"system_config_dir,omitempty"` + SystemConfigDir string `protobuf:"bytes,2,opt,name=system_config_dir" json:"system_config_dir,omitempty"` // Local configuration directory. - LocalConfigDir string `protobuf:"bytes,3,opt,name=local_config_dir,json=localConfigDir" json:"local_config_dir,omitempty"` + LocalConfigDir string `protobuf:"bytes,3,opt,name=local_config_dir" json:"local_config_dir,omitempty"` // User configuration directory. - UserConfigDir string `protobuf:"bytes,4,opt,name=user_config_dir,json=userConfigDir" json:"user_config_dir,omitempty"` + UserConfigDir string `protobuf:"bytes,4,opt,name=user_config_dir" json:"user_config_dir,omitempty"` // Insecure flags configurates what security features to disable. - InsecureFlags string `protobuf:"bytes,5,opt,name=insecure_flags,json=insecureFlags" json:"insecure_flags,omitempty"` + InsecureFlags string `protobuf:"bytes,5,opt,name=insecure_flags" json:"insecure_flags,omitempty"` // Whether to automatically trust gpg keys fetched from https - TrustKeysFromHttps bool `protobuf:"varint,6,opt,name=trust_keys_from_https,json=trustKeysFromHttps" json:"trust_keys_from_https,omitempty"` + TrustKeysFromHttps bool `protobuf:"varint,6,opt,name=trust_keys_from_https" json:"trust_keys_from_https,omitempty"` } func (m *GlobalFlags) Reset() { *m = GlobalFlags{} } @@ -480,13 +480,13 @@ func (*GlobalFlags) Descriptor() ([]byte, []int) { return fileDescriptor0, []int // Info describes the information of rkt on the machine. type Info struct { // Version of rkt, required, in the form of Semantic Versioning 2.0.0 (http://semver.org/). - RktVersion string `protobuf:"bytes,1,opt,name=rkt_version,json=rktVersion" json:"rkt_version,omitempty"` + RktVersion string `protobuf:"bytes,1,opt,name=rkt_version" json:"rkt_version,omitempty"` // Version of appc, required, in the form of Semantic Versioning 2.0.0 (http://semver.org/). - AppcVersion string `protobuf:"bytes,2,opt,name=appc_version,json=appcVersion" json:"appc_version,omitempty"` + AppcVersion string `protobuf:"bytes,2,opt,name=appc_version" json:"appc_version,omitempty"` // Latest version of the api that's supported by the service, required, in the form of Semantic Versioning 2.0.0 (http://semver.org/). - ApiVersion string `protobuf:"bytes,3,opt,name=api_version,json=apiVersion" json:"api_version,omitempty"` + ApiVersion string `protobuf:"bytes,3,opt,name=api_version" json:"api_version,omitempty"` // The global flags that passed to the rkt api service when it's launched. - GlobalFlags *GlobalFlags `protobuf:"bytes,4,opt,name=global_flags,json=globalFlags" json:"global_flags,omitempty"` + GlobalFlags *GlobalFlags `protobuf:"bytes,4,opt,name=global_flags" json:"global_flags,omitempty"` } func (m *Info) Reset() { *m = Info{} } @@ -544,10 +544,10 @@ type EventFilter struct { // If set, then only returns the events after this timestamp. // If the server starts after since_time, then only the events happened after the start of the server will be returned. // If since_time is a future timestamp, then no events will be returned until that time. - SinceTime int64 `protobuf:"varint,4,opt,name=since_time,json=sinceTime" json:"since_time,omitempty"` + SinceTime int64 `protobuf:"varint,4,opt,name=since_time" json:"since_time,omitempty"` // If set, then only returns the events before this timestamp. // If it is a future timestamp, then the event stream will be closed at that moment. - UntilTime int64 `protobuf:"varint,5,opt,name=until_time,json=untilTime" json:"until_time,omitempty"` + UntilTime int64 `protobuf:"varint,5,opt,name=until_time" json:"until_time,omitempty"` } func (m *EventFilter) Reset() { *m = EventFilter{} } @@ -744,11 +744,11 @@ func (m *ListenEventsResponse) GetEvents() []*Event { // Request for GetLogs(). type GetLogsRequest struct { // ID of the pod which we will get logs from, required. - PodId string `protobuf:"bytes,1,opt,name=pod_id,json=podId" json:"pod_id,omitempty"` + PodId string `protobuf:"bytes,1,opt,name=pod_id" json:"pod_id,omitempty"` // Name of the app within the pod which we will get logs // from, optional. If not set, then the logs of all the // apps within the pod will be returned. - AppName string `protobuf:"bytes,2,opt,name=app_name,json=appName" json:"app_name,omitempty"` + AppName string `protobuf:"bytes,2,opt,name=app_name" json:"app_name,omitempty"` // Number of most recent lines to return, optional. Lines int32 `protobuf:"varint,3,opt,name=lines" json:"lines,omitempty"` // If true, then a response stream will not be closed, @@ -756,10 +756,10 @@ type GetLogsRequest struct { Follow bool `protobuf:"varint,4,opt,name=follow" json:"follow,omitempty"` // If set, then only the logs after the timestamp will // be returned, optional. - SinceTime int64 `protobuf:"varint,5,opt,name=since_time,json=sinceTime" json:"since_time,omitempty"` + SinceTime int64 `protobuf:"varint,5,opt,name=since_time" json:"since_time,omitempty"` // If set, then only the logs before the timestamp will // be returned, optional. - UntilTime int64 `protobuf:"varint,6,opt,name=until_time,json=untilTime" json:"until_time,omitempty"` + UntilTime int64 `protobuf:"varint,6,opt,name=until_time" json:"until_time,omitempty"` } func (m *GetLogsRequest) Reset() { *m = GetLogsRequest{} } @@ -815,10 +815,6 @@ func init() { var _ context.Context var _ grpc.ClientConn -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion1 - // Client API for PublicAPI service type PublicAPIClient interface { diff --git a/scripts/genproto.sh b/scripts/genproto.sh index 4d351350b5..851de56b33 100755 --- a/scripts/genproto.sh +++ b/scripts/genproto.sh @@ -21,7 +21,7 @@ export PATH=${GOPATH}/bin:${PATH} trap 'rm -rf "${GOPATH}"' EXIT # git (sha) version of golang/protobuf -GO_PROTOBUF_SHA="dda510ac0fd43b39770f22ac6260eb91d377bce3" +GO_PROTOBUF_SHA="2402d76f3d41f928c7902a765dfc872356dd3aad" echo "installing golang/protobuf using GOPATH=${GOPATH}" go get -u github.com/golang/protobuf/{proto,protoc-gen-go} From 040d4972d6824d3596b05f673ffc6a885cadc221 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Tue, 5 Apr 2016 17:33:51 +0200 Subject: [PATCH 0080/1304] protobuf: catchup with PR #2377 --- api/v1alpha/api.pb.go | 220 ++++++++++++++++++++++-------------------- 1 file changed, 113 insertions(+), 107 deletions(-) diff --git a/api/v1alpha/api.pb.go b/api/v1alpha/api.pb.go index fed327f715..048e000483 100644 --- a/api/v1alpha/api.pb.go +++ b/api/v1alpha/api.pb.go @@ -340,6 +340,10 @@ type Pod struct { Annotations []*KeyValue `protobuf:"bytes,7,rep,name=annotations" json:"annotations,omitempty"` // Cgroup of the pod, empty if the pod is not running. Cgroup string `protobuf:"bytes,8,opt,name=cgroup" json:"cgroup,omitempty"` + // Timestamp when the pod is created, nanoseconds since epoch. + CreatedAt int64 `protobuf:"varint,9,opt,name=created_at" json:"created_at,omitempty"` + // Timestamp when the pod is started, nanoseconds since epoch. + StartedAt int64 `protobuf:"varint,10,opt,name=started_at" json:"started_at,omitempty"` } func (m *Pod) Reset() { *m = Pod{} } @@ -1128,111 +1132,113 @@ var _PublicAPI_serviceDesc = grpc.ServiceDesc{ } var fileDescriptor0 = []byte{ - // 1692 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x9c, 0x58, 0xcd, 0x6f, 0xdb, 0xc8, - 0x15, 0x0f, 0xf5, 0xad, 0x27, 0x59, 0x96, 0xc7, 0x4e, 0xa2, 0x38, 0x1f, 0x75, 0x99, 0x26, 0x71, - 0x8d, 0xc2, 0x68, 0x9c, 0xb4, 0xbd, 0x04, 0x41, 0x65, 0x99, 0x76, 0x85, 0xd8, 0x92, 0xc0, 0x28, - 0x6e, 0x83, 0x1e, 0x08, 0x5a, 0x1a, 0x39, 0x44, 0x28, 0x91, 0x15, 0x29, 0x27, 0xee, 0xb1, 0xb7, - 0x02, 0x45, 0xff, 0x83, 0xde, 0x7a, 0xde, 0xeb, 0x02, 0x7b, 0xdf, 0x3f, 0x65, 0xff, 0x85, 0xdd, - 0xeb, 0xbe, 0xf9, 0x20, 0x39, 0xa4, 0x65, 0xc3, 0xd8, 0xdb, 0xcc, 0xfb, 0xbd, 0xf9, 0xcd, 0xfb, - 0x98, 0xf7, 0x1e, 0x25, 0xa8, 0xda, 0xbe, 0xb3, 0xeb, 0xcf, 0xbd, 0xd0, 0x23, 0xe5, 0x8b, 0x97, - 0xb6, 0xeb, 0x7f, 0xb2, 0xf5, 0x3e, 0xd4, 0xba, 0x53, 0xfb, 0x9c, 0x1e, 0x7a, 0xf3, 0xa9, 0x1d, - 0x92, 0xe7, 0x50, 0x08, 0x2f, 0x7d, 0xda, 0xd2, 0xb6, 0xb4, 0xed, 0xc6, 0x1e, 0xd9, 0x95, 0x6a, - 0xbb, 0x5c, 0x67, 0x88, 0x88, 0xc9, 0x71, 0xd2, 0x82, 0xf2, 0x05, 0x9d, 0x07, 0x8e, 0x37, 0x6b, - 0xe5, 0x50, 0xb5, 0x6a, 0x46, 0x5b, 0xfd, 0x3f, 0x39, 0x28, 0x72, 0x6d, 0xf2, 0x07, 0xa8, 0x9d, - 0xd9, 0x01, 0xb5, 0x26, 0x9c, 0x9a, 0x53, 0xd6, 0xf6, 0x36, 0xd2, 0x94, 0xe2, 0x5a, 0x13, 0x98, - 0xa2, 0x34, 0xa1, 0x01, 0x39, 0x67, 0x2c, 0x59, 0x71, 0x45, 0x08, 0x14, 0x66, 0xf6, 0x94, 0xb6, - 0xf2, 0x5c, 0xc2, 0xd7, 0xea, 0xf5, 0x85, 0xd4, 0xf5, 0xe4, 0xb7, 0xd0, 0x74, 0xa6, 0xbe, 0x37, - 0x0f, 0xad, 0xd0, 0x99, 0xd2, 0x20, 0xb4, 0xa7, 0x7e, 0xab, 0x88, 0x2a, 0x79, 0x73, 0x55, 0xc8, - 0x87, 0x91, 0x98, 0x6c, 0x42, 0x65, 0x6a, 0xcf, 0x9c, 0x09, 0x6e, 0x5b, 0x25, 0x54, 0xa9, 0x9b, - 0xf1, 0x9e, 0x5d, 0x1a, 0x38, 0xff, 0xa4, 0xad, 0x32, 0x3f, 0xca, 0xd7, 0xe4, 0x15, 0xd4, 0xec, - 0xd9, 0xcc, 0x0b, 0xed, 0x10, 0x2f, 0x0a, 0x5a, 0x95, 0xad, 0x3c, 0xfa, 0xb3, 0x16, 0xfb, 0xf3, - 0x8e, 0x5e, 0x9e, 0xda, 0xee, 0x82, 0x9a, 0xaa, 0x96, 0x6e, 0x40, 0xb9, 0x47, 0xc3, 0x2f, 0xde, - 0xfc, 0x73, 0xec, 0x88, 0xa6, 0x38, 0x82, 0x32, 0xc7, 0xbf, 0x78, 0x2d, 0xdd, 0xe5, 0x6b, 0x29, - 0xfb, 0x63, 0xe4, 0x30, 0x5b, 0xeb, 0xdf, 0x69, 0x90, 0x6f, 0xfb, 0xfe, 0x52, 0x8e, 0xdf, 0x40, - 0xd1, 0x61, 0xb1, 0xe4, 0x24, 0xb5, 0xbd, 0x46, 0x3a, 0xc2, 0xa6, 0x00, 0xc9, 0x0b, 0x28, 0xa2, - 0xdb, 0xa1, 0x88, 0x63, 0x43, 0xb1, 0x1b, 0x69, 0xdf, 0x33, 0xc0, 0x14, 0x38, 0x79, 0x08, 0x55, - 0xfa, 0xd5, 0x09, 0xad, 0x91, 0x37, 0xa6, 0x3c, 0xba, 0x6b, 0x66, 0x85, 0x09, 0x3a, 0xb8, 0xcf, - 0xc6, 0xa0, 0x78, 0xab, 0x18, 0xfc, 0x3b, 0x07, 0xf9, 0x81, 0x37, 0x96, 0x99, 0xd5, 0xe2, 0xcc, - 0x36, 0x21, 0xef, 0xcb, 0x54, 0xaf, 0x99, 0x6c, 0x79, 0xbd, 0x91, 0x78, 0x3c, 0x65, 0xe4, 0x16, - 0x14, 0x6c, 0xdf, 0x0f, 0xd0, 0x3e, 0x66, 0x40, 0x5d, 0x75, 0xc6, 0xe4, 0x08, 0xf9, 0x1d, 0x54, - 0x66, 0x22, 0xf0, 0x91, 0x99, 0xcd, 0x58, 0x4b, 0x66, 0xc4, 0x8c, 0x35, 0x6e, 0x7c, 0x0b, 0x19, - 0x9f, 0xcb, 0xb7, 0xf1, 0x99, 0xdc, 0x83, 0xd2, 0xe8, 0x7c, 0xee, 0x2d, 0x7c, 0x7c, 0x27, 0xcc, - 0x5f, 0xb9, 0xd3, 0xf7, 0xa0, 0x12, 0x1d, 0x60, 0xfe, 0xe3, 0x5a, 0x06, 0x24, 0xff, 0x99, 0x5e, - 0x92, 0x0d, 0x28, 0x5e, 0x30, 0x48, 0xbe, 0x07, 0xb1, 0xd1, 0x7f, 0xd4, 0xa0, 0x8a, 0x01, 0x38, - 0x74, 0xdc, 0x90, 0xce, 0xd9, 0x29, 0x67, 0x1c, 0xe0, 0xa9, 0x3c, 0x3b, 0x85, 0x4b, 0x7c, 0xf3, - 0x25, 0x1e, 0x95, 0x00, 0x8f, 0xe5, 0x97, 0x87, 0x4d, 0x2a, 0xb0, 0xe4, 0x62, 0x74, 0x2c, 0xf6, - 0x6e, 0x02, 0x0c, 0x32, 0xa3, 0xa8, 0xa0, 0xa0, 0xc7, 0xf6, 0x0c, 0xe4, 0x6f, 0xc5, 0x62, 0xfc, - 0x05, 0x01, 0x72, 0x41, 0x17, 0x2f, 0x79, 0x0a, 0x2b, 0x32, 0x5a, 0xf2, 0x74, 0x91, 0x2b, 0xd4, - 0xa5, 0x50, 0x30, 0x64, 0x42, 0x55, 0xba, 0x55, 0xa8, 0xb0, 0x98, 0x45, 0x70, 0x44, 0x6c, 0xb1, - 0x98, 0xe5, 0x56, 0xff, 0x3e, 0x17, 0x75, 0xa7, 0xeb, 0x5c, 0xc7, 0xbc, 0xf9, 0x73, 0x3a, 0x71, - 0xbe, 0x4a, 0xe7, 0xd1, 0xe2, 0x68, 0x4f, 0x1e, 0x03, 0x6f, 0x2b, 0x29, 0x67, 0xab, 0x4c, 0x22, - 0x6c, 0xc5, 0xa3, 0x18, 0x72, 0xb4, 0x3d, 0x71, 0x36, 0xda, 0xb3, 0x88, 0xba, 0xf6, 0x19, 0x75, - 0x6f, 0x78, 0xe1, 0x52, 0x81, 0x3c, 0x83, 0x86, 0x68, 0x2c, 0x74, 0x6c, 0xd9, 0x13, 0xb4, 0x92, - 0xbf, 0x9f, 0xbc, 0xb9, 0x12, 0x49, 0xdb, 0x4c, 0x88, 0x2f, 0x7b, 0x35, 0x56, 0x3b, 0xa3, 0xd8, - 0x12, 0xa3, 0xde, 0x12, 0x9f, 0xde, 0xe7, 0xd2, 0x5f, 0xd4, 0x65, 0x98, 0xab, 0x93, 0x85, 0xeb, - 0x4a, 0x57, 0xab, 0xc2, 0x55, 0x26, 0xe1, 0xae, 0xea, 0x3f, 0x69, 0x50, 0x3b, 0x72, 0xbd, 0x33, - 0xdb, 0x3d, 0x74, 0xed, 0xf3, 0x80, 0xc5, 0x71, 0xec, 0xcc, 0xa3, 0x87, 0x87, 0x4b, 0xb2, 0x03, - 0x6b, 0xc1, 0x65, 0x10, 0xd2, 0x29, 0x96, 0xfd, 0x6c, 0xe2, 0x9c, 0x5b, 0x0c, 0x17, 0x8f, 0x70, - 0x55, 0x00, 0x1d, 0x2e, 0x3f, 0x40, 0xdd, 0x6d, 0x68, 0xba, 0xde, 0xc8, 0x76, 0x55, 0x55, 0xd1, - 0xab, 0x1a, 0x5c, 0x9e, 0x68, 0x3e, 0x87, 0xd5, 0x45, 0x40, 0xe7, 0xaa, 0xa2, 0x68, 0xd7, 0x2b, - 0x4c, 0x9c, 0xe8, 0xb1, 0x18, 0xce, 0x02, 0x3a, 0x5a, 0xcc, 0x71, 0x5a, 0x30, 0x0b, 0x79, 0xcb, - 0x46, 0xb5, 0x48, 0x2a, 0xcc, 0x7e, 0x09, 0x77, 0xc3, 0xf9, 0x22, 0x08, 0x2d, 0xcc, 0x53, 0x60, - 0x4d, 0xe6, 0xde, 0xd4, 0xfa, 0x14, 0x86, 0x7e, 0xc0, 0x23, 0x5e, 0x31, 0x09, 0x07, 0x31, 0x40, - 0xc1, 0x21, 0x42, 0x7f, 0x61, 0x88, 0xfe, 0x7f, 0x0d, 0x0a, 0xdd, 0xd9, 0xc4, 0x23, 0xbf, 0x82, - 0xda, 0xfc, 0x73, 0x68, 0x45, 0x53, 0x43, 0xb8, 0x0e, 0x28, 0x3a, 0x95, 0x83, 0xe3, 0xd7, 0x50, - 0xc7, 0x42, 0x18, 0x59, 0xe9, 0xb1, 0x56, 0x63, 0xb2, 0x48, 0x05, 0x39, 0x70, 0x82, 0xc6, 0x1a, - 0xc2, 0x67, 0x40, 0x51, 0xa4, 0xf0, 0x27, 0xa8, 0x9f, 0xf3, 0x30, 0x4b, 0x2f, 0x0a, 0x99, 0x91, - 0xa7, 0xe4, 0xc0, 0xac, 0x9d, 0x27, 0x1b, 0xfd, 0xbf, 0x1a, 0x14, 0x8d, 0x0b, 0x3a, 0xbb, 0x7e, - 0x00, 0x73, 0x54, 0x19, 0xc0, 0x4b, 0xa6, 0x24, 0x0b, 0x48, 0x34, 0x34, 0xd8, 0x9a, 0xc9, 0xd8, - 0x10, 0xe4, 0x66, 0xe0, 0x10, 0x63, 0x6b, 0x0c, 0x75, 0x61, 0x6c, 0x87, 0xf6, 0xf5, 0xef, 0x9a, - 0xc3, 0xfa, 0xff, 0xf0, 0xc5, 0xf0, 0x2b, 0x65, 0xe5, 0x6d, 0x43, 0x91, 0x5d, 0x2b, 0x6a, 0x6f, - 0xb9, 0x5d, 0x42, 0x21, 0xaa, 0xd1, 0x5c, 0x52, 0xa3, 0xd8, 0xd4, 0xd4, 0x12, 0x14, 0x1b, 0xf6, - 0x64, 0x03, 0x67, 0x36, 0xa2, 0x96, 0x62, 0x62, 0x95, 0x4b, 0xd8, 0x84, 0x66, 0xf0, 0x62, 0x16, - 0x3a, 0xae, 0x80, 0xc5, 0x04, 0xaf, 0x72, 0x09, 0x83, 0xf5, 0x26, 0x34, 0x8e, 0x68, 0xc8, 0x32, - 0x6b, 0xd2, 0x7f, 0x2c, 0xb0, 0x4b, 0xeb, 0xaf, 0x61, 0x35, 0x96, 0x04, 0x3e, 0x16, 0x05, 0xc5, - 0x94, 0x16, 0x1c, 0xdc, 0xcb, 0x2f, 0x8f, 0x95, 0x64, 0x2e, 0x32, 0x25, 0x0e, 0xe9, 0x7f, 0x85, - 0xd5, 0x63, 0x27, 0x08, 0xb1, 0x4f, 0x06, 0x92, 0x08, 0x07, 0x47, 0x79, 0xc2, 0x9d, 0x16, 0xce, - 0xd6, 0x14, 0x67, 0xe3, 0x26, 0x6c, 0x46, 0x2a, 0xac, 0xcf, 0x8f, 0x69, 0x68, 0x3b, 0x2e, 0xcf, - 0x45, 0xc5, 0x94, 0x3b, 0x34, 0xa7, 0x99, 0x10, 0x4b, 0x7b, 0x70, 0x68, 0xf9, 0xde, 0x38, 0xa2, - 0xad, 0xab, 0xb4, 0x26, 0x47, 0xf4, 0xa7, 0xb0, 0xd6, 0x9d, 0x05, 0x3e, 0x1d, 0xb1, 0x83, 0x91, - 0x41, 0x99, 0xb1, 0x89, 0xd4, 0x44, 0x55, 0x92, 0xe4, 0x4f, 0x70, 0x98, 0x7a, 0x63, 0xe9, 0x6b, - 0x9a, 0x9b, 0x01, 0xfa, 0xdf, 0x61, 0x8d, 0x19, 0xc4, 0xdb, 0x69, 0xec, 0xeb, 0x6e, 0xd6, 0xd7, - 0xec, 0xe7, 0xd9, 0x2d, 0xbd, 0x7d, 0x03, 0x44, 0x25, 0x97, 0x26, 0x3d, 0x87, 0x12, 0x1f, 0x1f, - 0x11, 0x79, 0xf6, 0xcb, 0x44, 0xa2, 0xfa, 0x33, 0x58, 0x97, 0x0e, 0x09, 0xf9, 0x35, 0x7e, 0xbf, - 0x81, 0x8d, 0xb4, 0x9a, 0xbc, 0x26, 0xfe, 0xfe, 0xd1, 0x6e, 0xf8, 0xfe, 0xd1, 0x3b, 0xb0, 0xce, - 0x4c, 0xa4, 0x33, 0xfe, 0x62, 0x95, 0x6c, 0x97, 0x84, 0x73, 0x57, 0xbe, 0x4f, 0x95, 0xe7, 0x6f, - 0x4a, 0x1d, 0xfd, 0x2d, 0x6c, 0xa4, 0x49, 0x12, 0x4f, 0x29, 0x97, 0x5c, 0xf1, 0x94, 0x2b, 0x9a, - 0x12, 0xd5, 0xbf, 0xd1, 0xf8, 0xbb, 0x3d, 0xf6, 0xce, 0x63, 0x03, 0xee, 0x42, 0x09, 0xd3, 0x63, - 0xc5, 0x9e, 0x16, 0x71, 0xd7, 0x1d, 0x93, 0x07, 0x50, 0x89, 0x06, 0x75, 0xf4, 0x85, 0x2d, 0xe7, - 0x34, 0xab, 0x27, 0xd7, 0x99, 0xf1, 0x7a, 0xd2, 0xb6, 0x8b, 0xa6, 0xd8, 0xb0, 0xd4, 0x4c, 0x3c, - 0xd7, 0xf5, 0xbe, 0xf0, 0x5a, 0xc2, 0xd4, 0x88, 0x5d, 0xa6, 0xce, 0x8a, 0x37, 0xd7, 0x59, 0x29, - 0x5b, 0x67, 0x2f, 0x78, 0x55, 0x09, 0x7b, 0xa5, 0xaf, 0xf1, 0xf5, 0x62, 0x0c, 0x8b, 0xcd, 0x0e, - 0x85, 0x6a, 0xfc, 0x1b, 0x01, 0x27, 0xfa, 0x46, 0xf7, 0xa4, 0x7d, 0x64, 0x58, 0xc3, 0x8f, 0x03, - 0xc3, 0xfa, 0xd0, 0x3b, 0x30, 0x0e, 0xbb, 0x3d, 0xe3, 0xa0, 0x79, 0x87, 0xac, 0xc3, 0xaa, 0x82, - 0xb4, 0x07, 0x83, 0x4e, 0x53, 0xc3, 0x10, 0xac, 0x29, 0xc2, 0x83, 0x7e, 0xe7, 0x9d, 0x61, 0x36, - 0x73, 0xd8, 0xbe, 0x1a, 0x8a, 0xb8, 0xdf, 0xe9, 0x36, 0xf3, 0x3b, 0x03, 0xa8, 0x44, 0xdf, 0xab, - 0xe4, 0x3e, 0xac, 0x23, 0x81, 0xf5, 0x7e, 0xd8, 0x1e, 0xa6, 0x2f, 0x41, 0xbe, 0x04, 0x30, 0x3f, - 0xf4, 0x7a, 0xdd, 0xde, 0x11, 0x5e, 0xb3, 0x01, 0xcd, 0x44, 0x6c, 0xfc, 0xad, 0x3b, 0x44, 0xe5, - 0xdc, 0xce, 0x0f, 0x1a, 0x54, 0xa2, 0xcf, 0x24, 0x46, 0x39, 0xe8, 0x1f, 0x2c, 0xa1, 0xc4, 0xb3, - 0x09, 0x60, 0x9c, 0xec, 0x9b, 0x1f, 0xfb, 0xc8, 0x98, 0x52, 0x1f, 0x98, 0xc6, 0xa0, 0x6d, 0xb2, - 0xab, 0x72, 0x98, 0x0c, 0x92, 0x05, 0x90, 0x26, 0xcf, 0x2c, 0x4b, 0xe4, 0x91, 0x65, 0x05, 0x4c, - 0xc2, 0x83, 0x44, 0xdc, 0xde, 0xef, 0x9b, 0x68, 0x5a, 0x74, 0xac, 0x59, 0xcc, 0x5c, 0x2e, 0x0c, - 0x2f, 0xa5, 0xef, 0x38, 0x30, 0x8e, 0x8d, 0x21, 0x23, 0x2b, 0xa7, 0xef, 0x38, 0x6a, 0x9b, 0xfb, - 0x18, 0xc2, 0x66, 0x65, 0xe7, 0xdb, 0x1c, 0x54, 0xe3, 0x66, 0xcd, 0x32, 0x64, 0x9c, 0x1a, 0xbd, - 0xe1, 0xd5, 0x0c, 0x3d, 0x84, 0xfb, 0x0a, 0xc2, 0x98, 0x62, 0xfb, 0x35, 0xa2, 0xc3, 0x93, 0xe5, - 0x60, 0x64, 0x35, 0xfa, 0xbe, 0x09, 0xf7, 0x32, 0x3a, 0x68, 0x0a, 0xc7, 0xf2, 0xf8, 0xaa, 0xef, - 0x66, 0x30, 0xe9, 0x4e, 0x01, 0xab, 0x78, 0x2b, 0x03, 0x49, 0xdb, 0xad, 0x4e, 0xff, 0xf8, 0xd8, - 0xe8, 0x30, 0xad, 0x62, 0x86, 0x5c, 0xa6, 0xd3, 0x14, 0x01, 0x49, 0x93, 0x33, 0x4c, 0x92, 0x97, - 0x59, 0x80, 0x15, 0x48, 0xbc, 0xaa, 0xee, 0xc9, 0x40, 0x98, 0x5c, 0x21, 0x8f, 0xa0, 0x75, 0x05, - 0x36, 0x8d, 0x93, 0xfe, 0x29, 0xa2, 0xd5, 0xbd, 0x7f, 0x15, 0xf0, 0xf3, 0x7b, 0x71, 0xe6, 0x3a, - 0xa3, 0xf6, 0xa0, 0x4b, 0xde, 0x42, 0x59, 0xce, 0x19, 0x72, 0x3f, 0x19, 0xec, 0xa9, 0x59, 0xb4, - 0xd9, 0xba, 0x0a, 0x88, 0xe2, 0xd1, 0xef, 0x90, 0x36, 0x54, 0xa2, 0xc1, 0x40, 0x12, 0xbd, 0xcc, - 0x10, 0xda, 0x7c, 0xb0, 0x04, 0x89, 0x29, 0x8e, 0x00, 0x92, 0x01, 0x40, 0x36, 0x95, 0xb9, 0x96, - 0x19, 0x1d, 0x9b, 0x0f, 0x97, 0x62, 0x2a, 0x51, 0xd2, 0xb6, 0x15, 0xa2, 0x2b, 0x83, 0x42, 0x21, - 0xba, 0xda, 0xe7, 0x91, 0xe8, 0x04, 0xea, 0x6a, 0x6b, 0x26, 0x8f, 0xb2, 0xf7, 0xaa, 0x8d, 0x7d, - 0xf3, 0xf1, 0x35, 0x68, 0x4c, 0xd7, 0x87, 0xba, 0xda, 0x66, 0x15, 0xba, 0x25, 0x2d, 0x5c, 0xa1, - 0x5b, 0xd6, 0x9b, 0xf5, 0x3b, 0xbf, 0xd7, 0xc8, 0x9f, 0x79, 0xd2, 0x58, 0x1b, 0x4b, 0x27, 0x4d, - 0x69, 0xc4, 0xe9, 0xa4, 0xa9, 0x1d, 0x8f, 0x31, 0x9c, 0x95, 0xf8, 0xff, 0x26, 0xaf, 0x7e, 0x0e, - 0x00, 0x00, 0xff, 0xff, 0xef, 0x2c, 0x8a, 0x46, 0x44, 0x11, 0x00, 0x00, + // 1717 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x9c, 0x58, 0x4b, 0x6f, 0xdb, 0xc6, + 0x16, 0x0e, 0xf5, 0xd6, 0x91, 0x2c, 0xcb, 0x63, 0x27, 0x51, 0x9c, 0xc7, 0xf5, 0x65, 0x6e, 0x12, + 0x5f, 0xe3, 0xc2, 0xb8, 0x71, 0xd2, 0x76, 0x13, 0x04, 0x95, 0x65, 0xda, 0x15, 0x62, 0x4b, 0x02, + 0xa3, 0xb8, 0x0d, 0xba, 0x20, 0x68, 0x89, 0x72, 0x88, 0x50, 0x22, 0x4b, 0x52, 0x4e, 0xdc, 0x65, + 0xd7, 0x45, 0xff, 0x41, 0x77, 0x5d, 0x77, 0x5b, 0xa0, 0xfb, 0xa2, 0xbf, 0xa4, 0x7f, 0xa1, 0xdd, + 0xf6, 0xcc, 0x83, 0xe4, 0x90, 0x96, 0x0d, 0xa3, 0xbb, 0x99, 0xf3, 0x9d, 0xf9, 0xe6, 0x3c, 0xe6, + 0x9c, 0x43, 0x09, 0xaa, 0xa6, 0x67, 0x6f, 0x7b, 0xbe, 0x1b, 0xba, 0xa4, 0x7c, 0xf6, 0xd4, 0x74, + 0xbc, 0x77, 0xa6, 0xda, 0x87, 0x5a, 0x77, 0x6a, 0x9e, 0x5a, 0xfb, 0xae, 0x3f, 0x35, 0x43, 0xf2, + 0x18, 0x0a, 0xe1, 0xb9, 0x67, 0xb5, 0x94, 0x0d, 0x65, 0xb3, 0xb1, 0x43, 0xb6, 0x85, 0xda, 0x36, + 0xd3, 0x19, 0x22, 0xa2, 0x33, 0x9c, 0xb4, 0xa0, 0x7c, 0x66, 0xf9, 0x81, 0xed, 0xce, 0x5a, 0x39, + 0x54, 0xad, 0xea, 0xd1, 0x56, 0xfd, 0x3e, 0x07, 0x45, 0xa6, 0x4d, 0x3e, 0x81, 0xda, 0x89, 0x19, + 0x58, 0xc6, 0x84, 0x51, 0x33, 0xca, 0xda, 0xce, 0x5a, 0x9a, 0x92, 0x5f, 0xab, 0x03, 0x55, 0x14, + 0x26, 0x34, 0x20, 0x67, 0x8f, 0x05, 0x2b, 0xae, 0x08, 0x81, 0xc2, 0xcc, 0x9c, 0x5a, 0xad, 0x3c, + 0x93, 0xb0, 0xb5, 0x7c, 0x7d, 0x21, 0x75, 0x3d, 0xf9, 0x2f, 0x34, 0xed, 0xa9, 0xe7, 0xfa, 0xa1, + 0x11, 0xda, 0x53, 0x2b, 0x08, 0xcd, 0xa9, 0xd7, 0x2a, 0xa2, 0x4a, 0x5e, 0x5f, 0xe6, 0xf2, 0x61, + 0x24, 0x26, 0xeb, 0x50, 0x99, 0x9a, 0x33, 0x7b, 0x82, 0xdb, 0x56, 0x09, 0x55, 0xea, 0x7a, 0xbc, + 0xa7, 0x97, 0x06, 0xf6, 0xb7, 0x56, 0xab, 0xcc, 0x8e, 0xb2, 0x35, 0x79, 0x06, 0x35, 0x73, 0x36, + 0x73, 0x43, 0x33, 0xc4, 0x8b, 0x82, 0x56, 0x65, 0x23, 0x8f, 0xfe, 0xac, 0xc4, 0xfe, 0xbc, 0xb2, + 0xce, 0x8f, 0x4d, 0x67, 0x6e, 0xe9, 0xb2, 0x96, 0xaa, 0x41, 0xb9, 0x67, 0x85, 0x1f, 0x5c, 0xff, + 0x7d, 0xec, 0x88, 0x22, 0x39, 0x82, 0x32, 0xdb, 0x3b, 0x7b, 0x2e, 0xdc, 0x65, 0x6b, 0x21, 0xfb, + 0x34, 0x72, 0x98, 0xae, 0xd5, 0x5f, 0x15, 0xc8, 0xb7, 0x3d, 0x6f, 0x21, 0xc7, 0x7f, 0xa0, 0x68, + 0xd3, 0x58, 0x32, 0x92, 0xda, 0x4e, 0x23, 0x1d, 0x61, 0x9d, 0x83, 0xe4, 0x09, 0x14, 0xd1, 0xed, + 0x90, 0xc7, 0xb1, 0x21, 0xd9, 0x8d, 0xb4, 0xaf, 0x29, 0xa0, 0x73, 0x9c, 0xdc, 0x85, 0xaa, 0xf5, + 0xd1, 0x0e, 0x8d, 0x91, 0x3b, 0xb6, 0x58, 0x74, 0x57, 0xf4, 0x0a, 0x15, 0x74, 0x70, 0x9f, 0x8d, + 0x41, 0xf1, 0x5a, 0x31, 0xf8, 0x3d, 0x07, 0xf9, 0x81, 0x3b, 0x16, 0x99, 0x55, 0xe2, 0xcc, 0x36, + 0x21, 0xef, 0x89, 0x54, 0xaf, 0xe8, 0x74, 0x79, 0xb9, 0x91, 0x78, 0x3c, 0x65, 0xe4, 0x06, 0x14, + 0x4c, 0xcf, 0x0b, 0xd0, 0x3e, 0x6a, 0x40, 0x5d, 0x76, 0x46, 0x67, 0x08, 0xf9, 0x1f, 0x54, 0x66, + 0x3c, 0xf0, 0x91, 0x99, 0xcd, 0x58, 0x4b, 0x64, 0x44, 0x8f, 0x35, 0xae, 0x7c, 0x0b, 0x19, 0x9f, + 0xcb, 0xd7, 0xf1, 0x99, 0xdc, 0x82, 0xd2, 0xe8, 0xd4, 0x77, 0xe7, 0x1e, 0xbe, 0x13, 0xea, 0xaf, + 0xd8, 0x91, 0xfb, 0x00, 0x23, 0xdf, 0x42, 0x17, 0xc6, 0x06, 0xd6, 0x44, 0x95, 0x3d, 0xaf, 0xaa, + 0x90, 0xb4, 0x43, 0x0a, 0xa3, 0x83, 0xbe, 0x80, 0x81, 0xc3, 0x42, 0xd2, 0x0e, 0xd5, 0x1d, 0xa8, + 0x44, 0xd7, 0xd1, 0xe8, 0xe1, 0x5a, 0x84, 0x33, 0xff, 0xde, 0x3a, 0x27, 0x6b, 0x50, 0x3c, 0xa3, + 0x90, 0x78, 0x4d, 0x7c, 0xa3, 0xfe, 0xa9, 0x40, 0x15, 0xc3, 0xb7, 0x6f, 0x3b, 0xa1, 0xe5, 0xd3, + 0x53, 0xf6, 0x38, 0xc0, 0x53, 0x79, 0x7a, 0x0a, 0x97, 0x58, 0x31, 0x25, 0x16, 0xd3, 0x00, 0x8f, + 0xe5, 0x17, 0x07, 0x5d, 0x28, 0xd0, 0xa7, 0x81, 0xb1, 0x35, 0xe8, 0xab, 0x0b, 0x30, 0x45, 0x94, + 0xa2, 0x82, 0x82, 0x1e, 0xdd, 0x53, 0x90, 0xbd, 0x34, 0x83, 0xf2, 0x17, 0x38, 0xc8, 0x04, 0x5d, + 0xbc, 0xe4, 0x21, 0x2c, 0x89, 0x58, 0x8b, 0xd3, 0x45, 0xa6, 0x50, 0x17, 0x42, 0xce, 0x90, 0x09, + 0x74, 0xe9, 0x5a, 0x81, 0xc6, 0x56, 0xc0, 0x43, 0xcb, 0x33, 0x83, 0xad, 0x40, 0x6c, 0xd5, 0xdf, + 0x72, 0x51, 0x6f, 0xbb, 0xcc, 0x75, 0xcc, 0xba, 0xe7, 0x5b, 0x13, 0xfb, 0xa3, 0x70, 0x1e, 0x2d, + 0x8e, 0xf6, 0x34, 0x13, 0xac, 0x7b, 0xc9, 0xce, 0x56, 0xa9, 0x84, 0xdb, 0x8a, 0x47, 0x31, 0xe4, + 0x68, 0x7b, 0xe2, 0x6c, 0xb4, 0xa7, 0x11, 0x75, 0xcc, 0x13, 0xcb, 0xb9, 0xa2, 0x3e, 0x84, 0x02, + 0x79, 0x04, 0x0d, 0xde, 0x96, 0x68, 0xc2, 0x27, 0x68, 0x25, 0x7b, 0x7d, 0x79, 0x7d, 0x29, 0x92, + 0xb6, 0xa9, 0x10, 0xeb, 0x62, 0x39, 0x56, 0x3b, 0xb1, 0xb0, 0xa1, 0x46, 0x9d, 0x29, 0x3e, 0xbd, + 0xcb, 0xa4, 0xff, 0xa8, 0x47, 0x51, 0x57, 0x27, 0x73, 0xc7, 0x11, 0xae, 0x56, 0xb9, 0xab, 0x54, + 0xc2, 0x5c, 0x55, 0xff, 0x52, 0xa0, 0x76, 0xe0, 0xb8, 0x27, 0xa6, 0xb3, 0xef, 0x98, 0xa7, 0x01, + 0x8d, 0xe3, 0xd8, 0xf6, 0xa3, 0x87, 0x87, 0x4b, 0xb2, 0x05, 0x2b, 0xc1, 0x79, 0x10, 0x5a, 0x53, + 0x6c, 0x1a, 0xb3, 0x89, 0x7d, 0x6a, 0x50, 0x9c, 0x3f, 0xc2, 0x65, 0x0e, 0x74, 0x98, 0x7c, 0x0f, + 0x75, 0x37, 0xa1, 0xe9, 0xb8, 0x23, 0xd3, 0x91, 0x55, 0x79, 0xa7, 0x6b, 0x30, 0x79, 0xa2, 0xf9, + 0x18, 0x96, 0xe7, 0x81, 0xe5, 0xcb, 0x8a, 0xbc, 0xd9, 0x2f, 0x51, 0x71, 0xa2, 0x47, 0x63, 0x38, + 0x0b, 0xac, 0xd1, 0xdc, 0xc7, 0x59, 0x43, 0x2d, 0x64, 0x0d, 0x1f, 0xd5, 0x22, 0x29, 0x37, 0xfb, + 0x29, 0xdc, 0x0c, 0xfd, 0x79, 0x10, 0x1a, 0x98, 0xa7, 0xc0, 0x98, 0xf8, 0xee, 0xd4, 0x78, 0x17, + 0x86, 0x5e, 0xc0, 0x22, 0x5e, 0xd1, 0x09, 0x03, 0x31, 0x40, 0xc1, 0x3e, 0x42, 0x5f, 0x50, 0x44, + 0xfd, 0x49, 0x81, 0x42, 0x77, 0x36, 0x71, 0xc9, 0xbf, 0xa0, 0xe6, 0xbf, 0x0f, 0x8d, 0x68, 0xe6, + 0x70, 0xd7, 0x01, 0x45, 0xc7, 0x62, 0xec, 0xfc, 0x1b, 0xea, 0x58, 0x08, 0x23, 0x23, 0x3d, 0x14, + 0x6b, 0x54, 0x16, 0xa9, 0x20, 0x07, 0xce, 0xdf, 0x58, 0x83, 0xfb, 0x0c, 0x28, 0x8a, 0x14, 0x3e, + 0x83, 0xfa, 0x29, 0x0b, 0xb3, 0xf0, 0xa2, 0x90, 0x19, 0x98, 0x52, 0x0e, 0xf4, 0xda, 0x69, 0xb2, + 0x51, 0x7f, 0x50, 0xa0, 0xa8, 0x9d, 0x59, 0xb3, 0xcb, 0xc7, 0x37, 0x43, 0xa5, 0xf1, 0xbd, 0x60, + 0xc6, 0xd2, 0x80, 0x44, 0x23, 0x87, 0xae, 0xa9, 0x8c, 0x8e, 0x50, 0x66, 0x06, 0x8e, 0x40, 0xba, + 0xc6, 0x50, 0x17, 0xc6, 0x66, 0x68, 0x5e, 0xfe, 0xae, 0x19, 0xac, 0xfe, 0x88, 0x2f, 0x86, 0x5d, + 0x29, 0x2a, 0x6f, 0x13, 0x8a, 0xf4, 0x5a, 0x5e, 0x7b, 0x8b, 0xed, 0xe2, 0x0a, 0x51, 0x8d, 0xe6, + 0x92, 0x1a, 0xc5, 0xa6, 0x26, 0x97, 0x20, 0xdf, 0xb0, 0x3e, 0x69, 0xcf, 0x46, 0x96, 0x21, 0x99, + 0x58, 0x65, 0x12, 0x3a, 0xdf, 0x29, 0x3c, 0x9f, 0x85, 0xb6, 0xc3, 0x61, 0x3e, 0xff, 0xab, 0x4c, + 0x42, 0x61, 0xb5, 0x09, 0x8d, 0x03, 0x2b, 0xa4, 0x99, 0xd5, 0xad, 0x6f, 0xe6, 0xd8, 0xe3, 0xd5, + 0xe7, 0xb0, 0x1c, 0x4b, 0x02, 0x0f, 0x8b, 0xc2, 0xc2, 0x94, 0x16, 0x6c, 0xdc, 0x8b, 0xef, 0x96, + 0xa5, 0x64, 0xaa, 0x52, 0x25, 0x06, 0xa9, 0x5f, 0xc2, 0xf2, 0xa1, 0x1d, 0x84, 0xd8, 0x27, 0x03, + 0x41, 0x84, 0x63, 0xa7, 0x3c, 0x61, 0x4e, 0x73, 0x67, 0x6b, 0x92, 0xb3, 0x71, 0x13, 0xd6, 0x23, + 0x15, 0x3a, 0x25, 0xc6, 0x56, 0x68, 0xda, 0x0e, 0xcb, 0x45, 0x45, 0x17, 0x3b, 0x34, 0xa7, 0x99, + 0x10, 0x0b, 0x7b, 0x70, 0xe4, 0x79, 0xee, 0x38, 0xa2, 0xad, 0xcb, 0xb4, 0x3a, 0x43, 0xd4, 0x87, + 0xb0, 0xd2, 0x9d, 0x05, 0x9e, 0x35, 0xa2, 0x07, 0x23, 0x83, 0x32, 0x43, 0x17, 0xa9, 0x89, 0xac, + 0x24, 0xc8, 0x1f, 0xe0, 0x28, 0x76, 0xc7, 0xc2, 0xd7, 0x34, 0x37, 0x05, 0xd4, 0xaf, 0x61, 0x85, + 0x1a, 0xc4, 0xda, 0x69, 0xec, 0xeb, 0x76, 0xd6, 0xd7, 0xec, 0xc7, 0xdd, 0x35, 0xbd, 0x7d, 0x01, + 0x44, 0x26, 0x17, 0x26, 0x3d, 0x86, 0x12, 0x1b, 0x1f, 0x11, 0x79, 0xf6, 0xbb, 0x46, 0xa0, 0xea, + 0x23, 0x58, 0x15, 0x0e, 0x71, 0xf9, 0x25, 0x7e, 0xbf, 0x80, 0xb5, 0xb4, 0x9a, 0xb8, 0x26, 0xfe, + 0x7a, 0x52, 0xae, 0xf8, 0x7a, 0x52, 0x3b, 0xb0, 0x4a, 0x4d, 0xb4, 0x66, 0xec, 0xc5, 0x4a, 0xd9, + 0x2e, 0x71, 0xe7, 0x2e, 0x7c, 0xdd, 0x4a, 0xcf, 0x5f, 0x17, 0x3a, 0xea, 0x4b, 0x58, 0x4b, 0x93, + 0x24, 0x9e, 0x5a, 0x4c, 0x72, 0xc1, 0x53, 0xa6, 0xa8, 0x0b, 0x54, 0xfd, 0x59, 0x61, 0xef, 0xf6, + 0xd0, 0x3d, 0x8d, 0x0d, 0xb8, 0x09, 0x25, 0x4c, 0x8f, 0x11, 0x7b, 0x5a, 0xc4, 0x5d, 0x77, 0x4c, + 0xee, 0x40, 0x25, 0x1a, 0xd4, 0xd1, 0xf7, 0xb9, 0x98, 0xd3, 0xb4, 0x9e, 0x1c, 0x7b, 0xc6, 0xea, + 0x49, 0xd9, 0x2c, 0xea, 0x7c, 0x43, 0x53, 0x33, 0x71, 0x1d, 0xc7, 0xfd, 0xc0, 0x6a, 0x09, 0x53, + 0xc3, 0x77, 0x99, 0x3a, 0x2b, 0x5e, 0x5d, 0x67, 0xa5, 0x6c, 0x9d, 0x3d, 0x61, 0x55, 0xc5, 0xed, + 0x15, 0xbe, 0xc6, 0xd7, 0xf3, 0x31, 0xcc, 0x37, 0x5b, 0x16, 0x54, 0xe3, 0x5f, 0x18, 0x38, 0xd1, + 0xd7, 0xba, 0x47, 0xed, 0x03, 0xcd, 0x18, 0xbe, 0x1d, 0x68, 0xc6, 0x9b, 0xde, 0x9e, 0xb6, 0xdf, + 0xed, 0x69, 0x7b, 0xcd, 0x1b, 0x64, 0x15, 0x96, 0x25, 0xa4, 0x3d, 0x18, 0x74, 0x9a, 0x0a, 0x86, + 0x60, 0x45, 0x12, 0xee, 0xf5, 0x3b, 0xaf, 0x34, 0xbd, 0x99, 0xc3, 0xf6, 0xd5, 0x90, 0xc4, 0xfd, + 0x4e, 0xb7, 0x99, 0xdf, 0x1a, 0x40, 0x25, 0xfa, 0xda, 0x25, 0xb7, 0x61, 0x15, 0x09, 0x8c, 0xd7, + 0xc3, 0xf6, 0x30, 0x7d, 0x09, 0xf2, 0x25, 0x80, 0xfe, 0xa6, 0xd7, 0xeb, 0xf6, 0x0e, 0xf0, 0x9a, + 0x35, 0x68, 0x26, 0x62, 0xed, 0xab, 0xee, 0x10, 0x95, 0x73, 0x5b, 0x7f, 0x28, 0x50, 0x89, 0x3e, + 0x93, 0x28, 0xe5, 0xa0, 0xbf, 0xb7, 0x80, 0x12, 0xcf, 0x26, 0x80, 0x76, 0xb4, 0xab, 0xbf, 0xed, + 0x23, 0x63, 0x4a, 0x7d, 0xa0, 0x6b, 0x83, 0xb6, 0x4e, 0xaf, 0xca, 0x61, 0x32, 0x48, 0x16, 0x40, + 0x9a, 0x3c, 0xb5, 0x2c, 0x91, 0x47, 0x96, 0x15, 0x30, 0x09, 0x77, 0x12, 0x71, 0x7b, 0xb7, 0xaf, + 0xa3, 0x69, 0xd1, 0xb1, 0x66, 0x31, 0x73, 0x39, 0x37, 0xbc, 0x94, 0xbe, 0x63, 0x4f, 0x3b, 0xd4, + 0x86, 0x94, 0xac, 0x9c, 0xbe, 0xe3, 0xa0, 0xad, 0xef, 0x62, 0x08, 0x9b, 0x95, 0xad, 0x5f, 0x72, + 0x50, 0x8d, 0x9b, 0x35, 0xcd, 0x90, 0x76, 0xac, 0xf5, 0x86, 0x17, 0x33, 0x74, 0x17, 0x6e, 0x4b, + 0x08, 0x65, 0x8a, 0xed, 0x57, 0x88, 0x0a, 0x0f, 0x16, 0x83, 0x91, 0xd5, 0xe8, 0xfb, 0x3a, 0xdc, + 0xca, 0xe8, 0xa0, 0x29, 0x0c, 0xcb, 0xe3, 0xab, 0xbe, 0x99, 0xc1, 0x84, 0x3b, 0x05, 0xac, 0xe2, + 0x8d, 0x0c, 0x24, 0x6c, 0x37, 0x3a, 0xfd, 0xc3, 0x43, 0xad, 0x43, 0xb5, 0x8a, 0x19, 0x72, 0x91, + 0x4e, 0x9d, 0x07, 0x24, 0x4d, 0x4e, 0x31, 0x41, 0x5e, 0xa6, 0x01, 0x96, 0x20, 0xfe, 0xaa, 0xba, + 0x47, 0x03, 0x6e, 0x72, 0x85, 0xdc, 0x83, 0xd6, 0x05, 0x58, 0xd7, 0x8e, 0xfa, 0xc7, 0x88, 0x56, + 0x77, 0xbe, 0x2b, 0xe0, 0xe7, 0xf7, 0xfc, 0xc4, 0xb1, 0x47, 0xed, 0x41, 0x97, 0xbc, 0x84, 0xb2, + 0x98, 0x33, 0xe4, 0x76, 0x32, 0xd8, 0x53, 0xb3, 0x68, 0xbd, 0x75, 0x11, 0xe0, 0xc5, 0xa3, 0xde, + 0x20, 0x6d, 0xa8, 0x44, 0x83, 0x81, 0x24, 0x7a, 0x99, 0x21, 0xb4, 0x7e, 0x67, 0x01, 0x12, 0x53, + 0x1c, 0x00, 0x24, 0x03, 0x80, 0xac, 0x4b, 0x73, 0x2d, 0x33, 0x3a, 0xd6, 0xef, 0x2e, 0xc4, 0x64, + 0xa2, 0xa4, 0x6d, 0x4b, 0x44, 0x17, 0x06, 0x85, 0x44, 0x74, 0xb1, 0xcf, 0x23, 0xd1, 0x11, 0xd4, + 0xe5, 0xd6, 0x4c, 0xee, 0x65, 0xef, 0x95, 0x1b, 0xfb, 0xfa, 0xfd, 0x4b, 0xd0, 0x98, 0xae, 0x0f, + 0x75, 0xb9, 0xcd, 0x4a, 0x74, 0x0b, 0x5a, 0xb8, 0x44, 0xb7, 0xa8, 0x37, 0xab, 0x37, 0xfe, 0xaf, + 0x90, 0xcf, 0x59, 0xd2, 0x68, 0x1b, 0x4b, 0x27, 0x4d, 0x6a, 0xc4, 0xe9, 0xa4, 0xc9, 0x1d, 0x8f, + 0x32, 0x9c, 0x94, 0xd8, 0xbf, 0x2e, 0xcf, 0xfe, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xb2, 0xc6, 0x99, + 0x3e, 0x82, 0x11, 0x00, 0x00, } From 8e1a3b7c32e1cced2516079011d8c4962219fd0b Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Tue, 5 Apr 2016 18:20:36 +0200 Subject: [PATCH 0081/1304] stage1/init: return exit code 1 on error On error, stage1/init was returning a non-zero value between 1 and 7. It was useful for debugging to return a different value when stage1 was not able to print any error messages. But it is not the case anymore: stage1 can write on stdout/stderr nowadays. --- stage1/init/init.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/stage1/init/init.go b/stage1/init/init.go index 6d09258f29..2a3d07c88d 100644 --- a/stage1/init/init.go +++ b/stage1/init/init.go @@ -507,7 +507,7 @@ func stage1() int { flavor, _, err := stage1initcommon.GetFlavor(p) if err != nil { log.PrintE("failed to get stage1 flavor", err) - return 3 + return 1 } var n *networking.Networking @@ -515,26 +515,26 @@ func stage1() int { fps, err := forwardedPorts(p) if err != nil { log.Error(err) - return 6 + return 1 } n, err = networking.Setup(root, p.UUID, fps, netList, localConfig, flavor, debug) if err != nil { log.PrintE("failed to setup network", err) - return 6 + return 1 } if err = n.Save(); err != nil { log.PrintE("failed to save networking state", err) n.Teardown(flavor, debug) - return 6 + return 1 } if len(mdsToken) > 0 { hostIP, err := n.GetDefaultHostIP() if err != nil { log.PrintE("failed to get default Host IP", err) - return 6 + return 1 } p.MetadataServiceURL = common.MetadataServicePublicURL(hostIP, mdsToken) @@ -542,7 +542,7 @@ func stage1() int { } else { if flavor == "kvm" { log.Print("flavor kvm requires private network configuration (try --net)") - return 6 + return 1 } if len(mdsToken) > 0 { p.MetadataServiceURL = common.MetadataServicePublicURL(localhostIP, mdsToken) @@ -551,12 +551,12 @@ func stage1() int { if err = stage1initcommon.WriteDefaultTarget(p); err != nil { log.PrintE("failed to write default.target", err) - return 2 + return 1 } if err = stage1initcommon.WritePrepareAppTemplate(p); err != nil { log.PrintE("failed to write prepare-app service template", err) - return 2 + return 1 } if err := stage1initcommon.SetJournalPermissions(p); err != nil { @@ -566,19 +566,19 @@ func stage1() int { if flavor == "kvm" { if err := KvmPodToSystemd(p, n); err != nil { log.PrintE("failed to configure systemd for kvm", err) - return 2 + return 1 } } if err = stage1initcommon.PodToSystemd(p, interactive, flavor, privateUsers); err != nil { log.PrintE("failed to configure systemd", err) - return 2 + return 1 } args, env, err := getArgsEnv(p, flavor, debug, n) if err != nil { log.Error(err) - return 3 + return 1 } // create a separate mount namespace so the cgroup filesystems @@ -602,13 +602,13 @@ func stage1() int { enabledCgroups, err := cgroup.GetEnabledCgroups() if err != nil { log.FatalE("error getting cgroups", err) - return 5 + return 1 } // mount host cgroups in the rkt mount namespace if err := mountHostCgroups(enabledCgroups); err != nil { log.FatalE("couldn't mount the host cgroups", err) - return 5 + return 1 } var serviceNames []string @@ -621,7 +621,7 @@ func stage1() int { if err == nil { if err := mountContainerCgroups(s1Root, enabledCgroups, subcgroup, serviceNames); err != nil { log.PrintE("couldn't mount the container cgroups", err) - return 5 + return 1 } } else { log.PrintE("continuing with per-app isolators disabled", err) @@ -629,7 +629,7 @@ func stage1() int { if err = stage1common.WritePpid(os.Getpid()); err != nil { log.Error(err) - return 4 + return 1 } err = stage1common.WithClearedCloExec(lfd, func() error { @@ -637,7 +637,7 @@ func stage1() int { }) if err != nil { log.PrintE(fmt.Sprintf("failed to execute %q", args[0]), err) - return 7 + return 1 } return 0 From 4a0174828dc6359a26f24a4feca81583d4a0f131 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Tue, 5 Apr 2016 18:27:14 +0200 Subject: [PATCH 0082/1304] fly/init: return exit code 1 on error --- stage1_fly/run/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stage1_fly/run/main.go b/stage1_fly/run/main.go index 53e09b58cd..049f49bb3a 100644 --- a/stage1_fly/run/main.go +++ b/stage1_fly/run/main.go @@ -334,7 +334,7 @@ func stage1() int { if err = stage1common.WritePpid(os.Getpid()); err != nil { log.Error(err) - return 4 + return 1 } diag.Printf("chroot to %q", rfs) @@ -354,7 +354,7 @@ func stage1() int { }) if err != nil { log.PrintE(fmt.Sprintf("can't execute %q", args[0]), err) - return 7 + return 1 } return 0 From 9e7d5c7a5de5939e215c6042ccc62ba1d53e7d59 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Tue, 5 Apr 2016 18:57:02 +0200 Subject: [PATCH 0083/1304] tests: expect return status 0 or 1 from stage1 --- tests/rkt_mount_test.go | 4 ++-- tests/rkt_run_pod_manifest_test.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/rkt_mount_test.go b/tests/rkt_mount_test.go index 531efa3fc3..a2b39569c0 100644 --- a/tests/rkt_mount_test.go +++ b/tests/rkt_mount_test.go @@ -70,14 +70,14 @@ func TestMountSymlink(t *testing.T) { "/dir1/../../../foo", "/dir2/foo", "path escapes app's root", - 3, + 1, }, // '/dir1/link_invalid' is an invalid link because it tries to escape rootfs. { "/dir1/link_invalid/foo", "/dir2/foo", "escapes app's root with value", - 3, + 1, }, } diff --git a/tests/rkt_run_pod_manifest_test.go b/tests/rkt_run_pod_manifest_test.go index f9aeca0686..87fe3dd746 100644 --- a/tests/rkt_run_pod_manifest_test.go +++ b/tests/rkt_run_pod_manifest_test.go @@ -645,7 +645,7 @@ func TestPodManifest(t *testing.T) { }, }, }, - 2, + 1, `"user2" user not found`, "", }, @@ -666,7 +666,7 @@ func TestPodManifest(t *testing.T) { }, }, }, - 2, + 1, `"group2" group not found`, "", }, @@ -708,7 +708,7 @@ func TestPodManifest(t *testing.T) { }, }, }, - 2, + 1, `no such file or directory`, "", }, @@ -729,7 +729,7 @@ func TestPodManifest(t *testing.T) { }, }, }, - 2, + 1, `no such file or directory`, "", }, From 6bd9f7c718e705a301bc2984c826546824b63417 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Fri, 1 Apr 2016 13:46:07 +0200 Subject: [PATCH 0084/1304] tests: TestRktListCreatedStarted: fix timing issue Also fix the error messages Fix https://github.com/coreos/rkt/issues/2220 --- tests/rkt_list_test.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/rkt_list_test.go b/tests/rkt_list_test.go index 3727440825..80c49c807a 100644 --- a/tests/rkt_list_test.go +++ b/tests/rkt_list_test.go @@ -24,15 +24,16 @@ import ( "github.com/coreos/rkt/tests/testutils" ) -const delta = 3 * time.Second +const delta = 4 * time.Second +const precision = 2 * time.Second -// compareTime checks if a and b are roughly equal (1s precision) +// compareTime checks if a and b are roughly equal func compareTime(a time.Time, b time.Time) bool { diff := a.Sub(b) if diff < 0 { diff = -diff } - return diff < time.Second + return diff < precision } func TestRktList(t *testing.T) { @@ -174,9 +175,9 @@ func TestRktListCreatedStarted(t *testing.T) { creation, start := getCreationStartTime(t, ctx, imageID) if !compareTime(expectPrepare, creation) { - t.Fatalf("incorrect creation time returned. Got: %q Expect: %q (1s precision)", creation, expectPrepare) + t.Fatalf("rkt list returned an incorrect creation time. Got: %q Expect: %q", creation, expectPrepare) } if !compareTime(expectRun, start) { - t.Fatalf("incorrect creation time returned. Got: %q Expect: %q (1s precision)", start, expectRun) + t.Fatalf("rkt list returned an incorrect start time. Got: %q Expect: %q", start, expectRun) } } From 25f9cd2d2ca12f99738919fe4740e1c9823bba92 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Wed, 6 Apr 2016 14:05:30 +0200 Subject: [PATCH 0085/1304] Godeps: add golang/protobuf/protoc-gen-go --- Godeps/Godeps.json | 23 +- .../golang/protobuf/protoc-gen-go/Makefile | 33 + .../protoc-gen-go/descriptor/Makefile | 39 + .../protoc-gen-go/descriptor/descriptor.pb.go | 1812 +++++++++++ .../golang/protobuf/protoc-gen-go/doc.go | 51 + .../protobuf/protoc-gen-go/generator/Makefile | 40 + .../protoc-gen-go/generator/generator.go | 2715 +++++++++++++++++ .../protoc-gen-go/internal/grpc/grpc.go | 442 +++ .../protobuf/protoc-gen-go/link_grpc.go | 34 + .../golang/protobuf/protoc-gen-go/main.go | 98 + .../protobuf/protoc-gen-go/plugin/Makefile | 45 + .../protoc-gen-go/plugin/plugin.pb.go | 222 ++ .../protoc-gen-go/plugin/plugin.pb.golden | 83 + 13 files changed, 5636 insertions(+), 1 deletion(-) create mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/Makefile create mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/descriptor/Makefile create mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.pb.go create mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/doc.go create mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/generator/Makefile create mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/generator/generator.go create mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/internal/grpc/grpc.go create mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/link_grpc.go create mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/main.go create mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/plugin/Makefile create mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/plugin/plugin.pb.go create mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/plugin/plugin.pb.golden diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index edbe03bfa0..403994f9ec 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -13,7 +13,8 @@ "github.com/appc/cni/plugins/main/ptp", "github.com/appc/cni/plugins/meta/flannel", "github.com/appc/cni/plugins/meta/tuning", - "github.com/appc/spec/ace" + "github.com/appc/spec/ace", + "github.com/golang/protobuf/protoc-gen-go" ], "Deps": [ { @@ -353,6 +354,26 @@ "ImportPath": "github.com/golang/protobuf/proto", "Rev": "2402d76f3d41f928c7902a765dfc872356dd3aad" }, + { + "ImportPath": "github.com/golang/protobuf/protoc-gen-go", + "Rev": "2402d76f3d41f928c7902a765dfc872356dd3aad" + }, + { + "ImportPath": "github.com/golang/protobuf/protoc-gen-go/descriptor", + "Rev": "2402d76f3d41f928c7902a765dfc872356dd3aad" + }, + { + "ImportPath": "github.com/golang/protobuf/protoc-gen-go/generator", + "Rev": "2402d76f3d41f928c7902a765dfc872356dd3aad" + }, + { + "ImportPath": "github.com/golang/protobuf/protoc-gen-go/internal/grpc", + "Rev": "2402d76f3d41f928c7902a765dfc872356dd3aad" + }, + { + "ImportPath": "github.com/golang/protobuf/protoc-gen-go/plugin", + "Rev": "2402d76f3d41f928c7902a765dfc872356dd3aad" + }, { "ImportPath": "github.com/google/btree", "Rev": "f06e229e679911bb31a04e07ac891115822e37c3" diff --git a/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/Makefile b/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/Makefile new file mode 100644 index 0000000000..a42cc3717f --- /dev/null +++ b/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/Makefile @@ -0,0 +1,33 @@ +# Go support for Protocol Buffers - Google's data interchange format +# +# Copyright 2010 The Go Authors. All rights reserved. +# https://github.com/golang/protobuf +# +# 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. + +test: + cd testdata && make test diff --git a/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/descriptor/Makefile b/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/descriptor/Makefile new file mode 100644 index 0000000000..4942418e32 --- /dev/null +++ b/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/descriptor/Makefile @@ -0,0 +1,39 @@ +# Go support for Protocol Buffers - Google's data interchange format +# +# Copyright 2010 The Go Authors. All rights reserved. +# https://github.com/golang/protobuf +# +# 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. + +# Not stored here, but descriptor.proto is in https://github.com/google/protobuf/ +# at src/google/protobuf/descriptor.proto +regenerate: + echo WARNING! THIS RULE IS PROBABLY NOT RIGHT FOR YOUR INSTALLATION + protoc --go_out=. -I$(HOME)/src/protobuf/src $(HOME)/src/protobuf/src/google/protobuf/descriptor.proto && \ + sed 's,^package google_protobuf,package descriptor,' google/protobuf/descriptor.pb.go > \ + $(GOPATH)/src/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.pb.go && \ + rm -f google/protobuf/descriptor.pb.go diff --git a/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.pb.go b/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.pb.go new file mode 100644 index 0000000000..6a3be28eb6 --- /dev/null +++ b/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.pb.go @@ -0,0 +1,1812 @@ +// Code generated by protoc-gen-go. +// source: google/protobuf/descriptor.proto +// DO NOT EDIT! + +/* +Package google_protobuf is a generated protocol buffer package. + +It is generated from these files: + google/protobuf/descriptor.proto + +It has these top-level messages: + FileDescriptorSet + FileDescriptorProto + DescriptorProto + FieldDescriptorProto + OneofDescriptorProto + EnumDescriptorProto + EnumValueDescriptorProto + ServiceDescriptorProto + MethodDescriptorProto + FileOptions + MessageOptions + FieldOptions + EnumOptions + EnumValueOptions + ServiceOptions + MethodOptions + UninterpretedOption + SourceCodeInfo +*/ +package descriptor + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +const _ = proto.ProtoPackageIsVersion1 + +type FieldDescriptorProto_Type int32 + +const ( + // 0 is reserved for errors. + // Order is weird for historical reasons. + FieldDescriptorProto_TYPE_DOUBLE FieldDescriptorProto_Type = 1 + FieldDescriptorProto_TYPE_FLOAT FieldDescriptorProto_Type = 2 + // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + // negative values are likely. + FieldDescriptorProto_TYPE_INT64 FieldDescriptorProto_Type = 3 + FieldDescriptorProto_TYPE_UINT64 FieldDescriptorProto_Type = 4 + // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + // negative values are likely. + FieldDescriptorProto_TYPE_INT32 FieldDescriptorProto_Type = 5 + FieldDescriptorProto_TYPE_FIXED64 FieldDescriptorProto_Type = 6 + FieldDescriptorProto_TYPE_FIXED32 FieldDescriptorProto_Type = 7 + FieldDescriptorProto_TYPE_BOOL FieldDescriptorProto_Type = 8 + FieldDescriptorProto_TYPE_STRING FieldDescriptorProto_Type = 9 + FieldDescriptorProto_TYPE_GROUP FieldDescriptorProto_Type = 10 + FieldDescriptorProto_TYPE_MESSAGE FieldDescriptorProto_Type = 11 + // New in version 2. + FieldDescriptorProto_TYPE_BYTES FieldDescriptorProto_Type = 12 + FieldDescriptorProto_TYPE_UINT32 FieldDescriptorProto_Type = 13 + FieldDescriptorProto_TYPE_ENUM FieldDescriptorProto_Type = 14 + FieldDescriptorProto_TYPE_SFIXED32 FieldDescriptorProto_Type = 15 + FieldDescriptorProto_TYPE_SFIXED64 FieldDescriptorProto_Type = 16 + FieldDescriptorProto_TYPE_SINT32 FieldDescriptorProto_Type = 17 + FieldDescriptorProto_TYPE_SINT64 FieldDescriptorProto_Type = 18 +) + +var FieldDescriptorProto_Type_name = map[int32]string{ + 1: "TYPE_DOUBLE", + 2: "TYPE_FLOAT", + 3: "TYPE_INT64", + 4: "TYPE_UINT64", + 5: "TYPE_INT32", + 6: "TYPE_FIXED64", + 7: "TYPE_FIXED32", + 8: "TYPE_BOOL", + 9: "TYPE_STRING", + 10: "TYPE_GROUP", + 11: "TYPE_MESSAGE", + 12: "TYPE_BYTES", + 13: "TYPE_UINT32", + 14: "TYPE_ENUM", + 15: "TYPE_SFIXED32", + 16: "TYPE_SFIXED64", + 17: "TYPE_SINT32", + 18: "TYPE_SINT64", +} +var FieldDescriptorProto_Type_value = map[string]int32{ + "TYPE_DOUBLE": 1, + "TYPE_FLOAT": 2, + "TYPE_INT64": 3, + "TYPE_UINT64": 4, + "TYPE_INT32": 5, + "TYPE_FIXED64": 6, + "TYPE_FIXED32": 7, + "TYPE_BOOL": 8, + "TYPE_STRING": 9, + "TYPE_GROUP": 10, + "TYPE_MESSAGE": 11, + "TYPE_BYTES": 12, + "TYPE_UINT32": 13, + "TYPE_ENUM": 14, + "TYPE_SFIXED32": 15, + "TYPE_SFIXED64": 16, + "TYPE_SINT32": 17, + "TYPE_SINT64": 18, +} + +func (x FieldDescriptorProto_Type) Enum() *FieldDescriptorProto_Type { + p := new(FieldDescriptorProto_Type) + *p = x + return p +} +func (x FieldDescriptorProto_Type) String() string { + return proto.EnumName(FieldDescriptorProto_Type_name, int32(x)) +} +func (x *FieldDescriptorProto_Type) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(FieldDescriptorProto_Type_value, data, "FieldDescriptorProto_Type") + if err != nil { + return err + } + *x = FieldDescriptorProto_Type(value) + return nil +} +func (FieldDescriptorProto_Type) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{3, 0} } + +type FieldDescriptorProto_Label int32 + +const ( + // 0 is reserved for errors + FieldDescriptorProto_LABEL_OPTIONAL FieldDescriptorProto_Label = 1 + FieldDescriptorProto_LABEL_REQUIRED FieldDescriptorProto_Label = 2 + FieldDescriptorProto_LABEL_REPEATED FieldDescriptorProto_Label = 3 +) + +var FieldDescriptorProto_Label_name = map[int32]string{ + 1: "LABEL_OPTIONAL", + 2: "LABEL_REQUIRED", + 3: "LABEL_REPEATED", +} +var FieldDescriptorProto_Label_value = map[string]int32{ + "LABEL_OPTIONAL": 1, + "LABEL_REQUIRED": 2, + "LABEL_REPEATED": 3, +} + +func (x FieldDescriptorProto_Label) Enum() *FieldDescriptorProto_Label { + p := new(FieldDescriptorProto_Label) + *p = x + return p +} +func (x FieldDescriptorProto_Label) String() string { + return proto.EnumName(FieldDescriptorProto_Label_name, int32(x)) +} +func (x *FieldDescriptorProto_Label) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(FieldDescriptorProto_Label_value, data, "FieldDescriptorProto_Label") + if err != nil { + return err + } + *x = FieldDescriptorProto_Label(value) + return nil +} +func (FieldDescriptorProto_Label) EnumDescriptor() ([]byte, []int) { + return fileDescriptor0, []int{3, 1} +} + +// Generated classes can be optimized for speed or code size. +type FileOptions_OptimizeMode int32 + +const ( + FileOptions_SPEED FileOptions_OptimizeMode = 1 + // etc. + FileOptions_CODE_SIZE FileOptions_OptimizeMode = 2 + FileOptions_LITE_RUNTIME FileOptions_OptimizeMode = 3 +) + +var FileOptions_OptimizeMode_name = map[int32]string{ + 1: "SPEED", + 2: "CODE_SIZE", + 3: "LITE_RUNTIME", +} +var FileOptions_OptimizeMode_value = map[string]int32{ + "SPEED": 1, + "CODE_SIZE": 2, + "LITE_RUNTIME": 3, +} + +func (x FileOptions_OptimizeMode) Enum() *FileOptions_OptimizeMode { + p := new(FileOptions_OptimizeMode) + *p = x + return p +} +func (x FileOptions_OptimizeMode) String() string { + return proto.EnumName(FileOptions_OptimizeMode_name, int32(x)) +} +func (x *FileOptions_OptimizeMode) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(FileOptions_OptimizeMode_value, data, "FileOptions_OptimizeMode") + if err != nil { + return err + } + *x = FileOptions_OptimizeMode(value) + return nil +} +func (FileOptions_OptimizeMode) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{9, 0} } + +type FieldOptions_CType int32 + +const ( + // Default mode. + FieldOptions_STRING FieldOptions_CType = 0 + FieldOptions_CORD FieldOptions_CType = 1 + FieldOptions_STRING_PIECE FieldOptions_CType = 2 +) + +var FieldOptions_CType_name = map[int32]string{ + 0: "STRING", + 1: "CORD", + 2: "STRING_PIECE", +} +var FieldOptions_CType_value = map[string]int32{ + "STRING": 0, + "CORD": 1, + "STRING_PIECE": 2, +} + +func (x FieldOptions_CType) Enum() *FieldOptions_CType { + p := new(FieldOptions_CType) + *p = x + return p +} +func (x FieldOptions_CType) String() string { + return proto.EnumName(FieldOptions_CType_name, int32(x)) +} +func (x *FieldOptions_CType) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(FieldOptions_CType_value, data, "FieldOptions_CType") + if err != nil { + return err + } + *x = FieldOptions_CType(value) + return nil +} +func (FieldOptions_CType) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{11, 0} } + +// The protocol compiler can output a FileDescriptorSet containing the .proto +// files it parses. +type FileDescriptorSet struct { + File []*FileDescriptorProto `protobuf:"bytes,1,rep,name=file" json:"file,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *FileDescriptorSet) Reset() { *m = FileDescriptorSet{} } +func (m *FileDescriptorSet) String() string { return proto.CompactTextString(m) } +func (*FileDescriptorSet) ProtoMessage() {} +func (*FileDescriptorSet) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } + +func (m *FileDescriptorSet) GetFile() []*FileDescriptorProto { + if m != nil { + return m.File + } + return nil +} + +// Describes a complete .proto file. +type FileDescriptorProto struct { + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Package *string `protobuf:"bytes,2,opt,name=package" json:"package,omitempty"` + // Names of files imported by this file. + Dependency []string `protobuf:"bytes,3,rep,name=dependency" json:"dependency,omitempty"` + // Indexes of the public imported files in the dependency list above. + PublicDependency []int32 `protobuf:"varint,10,rep,name=public_dependency" json:"public_dependency,omitempty"` + // Indexes of the weak imported files in the dependency list. + // For Google-internal migration only. Do not use. + WeakDependency []int32 `protobuf:"varint,11,rep,name=weak_dependency" json:"weak_dependency,omitempty"` + // All top-level definitions in this file. + MessageType []*DescriptorProto `protobuf:"bytes,4,rep,name=message_type" json:"message_type,omitempty"` + EnumType []*EnumDescriptorProto `protobuf:"bytes,5,rep,name=enum_type" json:"enum_type,omitempty"` + Service []*ServiceDescriptorProto `protobuf:"bytes,6,rep,name=service" json:"service,omitempty"` + Extension []*FieldDescriptorProto `protobuf:"bytes,7,rep,name=extension" json:"extension,omitempty"` + Options *FileOptions `protobuf:"bytes,8,opt,name=options" json:"options,omitempty"` + // This field contains optional information about the original source code. + // You may safely remove this entire field without harming runtime + // functionality of the descriptors -- the information is needed only by + // development tools. + SourceCodeInfo *SourceCodeInfo `protobuf:"bytes,9,opt,name=source_code_info" json:"source_code_info,omitempty"` + // The syntax of the proto file. + // The supported values are "proto2" and "proto3". + Syntax *string `protobuf:"bytes,12,opt,name=syntax" json:"syntax,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *FileDescriptorProto) Reset() { *m = FileDescriptorProto{} } +func (m *FileDescriptorProto) String() string { return proto.CompactTextString(m) } +func (*FileDescriptorProto) ProtoMessage() {} +func (*FileDescriptorProto) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } + +func (m *FileDescriptorProto) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *FileDescriptorProto) GetPackage() string { + if m != nil && m.Package != nil { + return *m.Package + } + return "" +} + +func (m *FileDescriptorProto) GetDependency() []string { + if m != nil { + return m.Dependency + } + return nil +} + +func (m *FileDescriptorProto) GetPublicDependency() []int32 { + if m != nil { + return m.PublicDependency + } + return nil +} + +func (m *FileDescriptorProto) GetWeakDependency() []int32 { + if m != nil { + return m.WeakDependency + } + return nil +} + +func (m *FileDescriptorProto) GetMessageType() []*DescriptorProto { + if m != nil { + return m.MessageType + } + return nil +} + +func (m *FileDescriptorProto) GetEnumType() []*EnumDescriptorProto { + if m != nil { + return m.EnumType + } + return nil +} + +func (m *FileDescriptorProto) GetService() []*ServiceDescriptorProto { + if m != nil { + return m.Service + } + return nil +} + +func (m *FileDescriptorProto) GetExtension() []*FieldDescriptorProto { + if m != nil { + return m.Extension + } + return nil +} + +func (m *FileDescriptorProto) GetOptions() *FileOptions { + if m != nil { + return m.Options + } + return nil +} + +func (m *FileDescriptorProto) GetSourceCodeInfo() *SourceCodeInfo { + if m != nil { + return m.SourceCodeInfo + } + return nil +} + +func (m *FileDescriptorProto) GetSyntax() string { + if m != nil && m.Syntax != nil { + return *m.Syntax + } + return "" +} + +// Describes a message type. +type DescriptorProto struct { + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Field []*FieldDescriptorProto `protobuf:"bytes,2,rep,name=field" json:"field,omitempty"` + Extension []*FieldDescriptorProto `protobuf:"bytes,6,rep,name=extension" json:"extension,omitempty"` + NestedType []*DescriptorProto `protobuf:"bytes,3,rep,name=nested_type" json:"nested_type,omitempty"` + EnumType []*EnumDescriptorProto `protobuf:"bytes,4,rep,name=enum_type" json:"enum_type,omitempty"` + ExtensionRange []*DescriptorProto_ExtensionRange `protobuf:"bytes,5,rep,name=extension_range" json:"extension_range,omitempty"` + OneofDecl []*OneofDescriptorProto `protobuf:"bytes,8,rep,name=oneof_decl" json:"oneof_decl,omitempty"` + Options *MessageOptions `protobuf:"bytes,7,opt,name=options" json:"options,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *DescriptorProto) Reset() { *m = DescriptorProto{} } +func (m *DescriptorProto) String() string { return proto.CompactTextString(m) } +func (*DescriptorProto) ProtoMessage() {} +func (*DescriptorProto) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } + +func (m *DescriptorProto) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *DescriptorProto) GetField() []*FieldDescriptorProto { + if m != nil { + return m.Field + } + return nil +} + +func (m *DescriptorProto) GetExtension() []*FieldDescriptorProto { + if m != nil { + return m.Extension + } + return nil +} + +func (m *DescriptorProto) GetNestedType() []*DescriptorProto { + if m != nil { + return m.NestedType + } + return nil +} + +func (m *DescriptorProto) GetEnumType() []*EnumDescriptorProto { + if m != nil { + return m.EnumType + } + return nil +} + +func (m *DescriptorProto) GetExtensionRange() []*DescriptorProto_ExtensionRange { + if m != nil { + return m.ExtensionRange + } + return nil +} + +func (m *DescriptorProto) GetOneofDecl() []*OneofDescriptorProto { + if m != nil { + return m.OneofDecl + } + return nil +} + +func (m *DescriptorProto) GetOptions() *MessageOptions { + if m != nil { + return m.Options + } + return nil +} + +type DescriptorProto_ExtensionRange struct { + Start *int32 `protobuf:"varint,1,opt,name=start" json:"start,omitempty"` + End *int32 `protobuf:"varint,2,opt,name=end" json:"end,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *DescriptorProto_ExtensionRange) Reset() { *m = DescriptorProto_ExtensionRange{} } +func (m *DescriptorProto_ExtensionRange) String() string { return proto.CompactTextString(m) } +func (*DescriptorProto_ExtensionRange) ProtoMessage() {} +func (*DescriptorProto_ExtensionRange) Descriptor() ([]byte, []int) { + return fileDescriptor0, []int{2, 0} +} + +func (m *DescriptorProto_ExtensionRange) GetStart() int32 { + if m != nil && m.Start != nil { + return *m.Start + } + return 0 +} + +func (m *DescriptorProto_ExtensionRange) GetEnd() int32 { + if m != nil && m.End != nil { + return *m.End + } + return 0 +} + +// Describes a field within a message. +type FieldDescriptorProto struct { + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Number *int32 `protobuf:"varint,3,opt,name=number" json:"number,omitempty"` + Label *FieldDescriptorProto_Label `protobuf:"varint,4,opt,name=label,enum=google.protobuf.FieldDescriptorProto_Label" json:"label,omitempty"` + // If type_name is set, this need not be set. If both this and type_name + // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + Type *FieldDescriptorProto_Type `protobuf:"varint,5,opt,name=type,enum=google.protobuf.FieldDescriptorProto_Type" json:"type,omitempty"` + // For message and enum types, this is the name of the type. If the name + // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + // rules are used to find the type (i.e. first the nested types within this + // message are searched, then within the parent, on up to the root + // namespace). + TypeName *string `protobuf:"bytes,6,opt,name=type_name" json:"type_name,omitempty"` + // For extensions, this is the name of the type being extended. It is + // resolved in the same manner as type_name. + Extendee *string `protobuf:"bytes,2,opt,name=extendee" json:"extendee,omitempty"` + // For numeric types, contains the original text representation of the value. + // For booleans, "true" or "false". + // For strings, contains the default text contents (not escaped in any way). + // For bytes, contains the C escaped value. All bytes >= 128 are escaped. + // TODO(kenton): Base-64 encode? + DefaultValue *string `protobuf:"bytes,7,opt,name=default_value" json:"default_value,omitempty"` + // If set, gives the index of a oneof in the containing type's oneof_decl + // list. This field is a member of that oneof. Extensions of a oneof should + // not set this since the oneof to which they belong will be inferred based + // on the extension range containing the extension's field number. + OneofIndex *int32 `protobuf:"varint,9,opt,name=oneof_index" json:"oneof_index,omitempty"` + // JSON name of this field. The value is set by protocol compiler. If the + // user has set a "json_name" option on this field, that option's value + // will be used. Otherwise, it's deduced from the field's name by converting + // it to camelCase. + JsonName *string `protobuf:"bytes,10,opt,name=json_name" json:"json_name,omitempty"` + Options *FieldOptions `protobuf:"bytes,8,opt,name=options" json:"options,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *FieldDescriptorProto) Reset() { *m = FieldDescriptorProto{} } +func (m *FieldDescriptorProto) String() string { return proto.CompactTextString(m) } +func (*FieldDescriptorProto) ProtoMessage() {} +func (*FieldDescriptorProto) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } + +func (m *FieldDescriptorProto) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *FieldDescriptorProto) GetNumber() int32 { + if m != nil && m.Number != nil { + return *m.Number + } + return 0 +} + +func (m *FieldDescriptorProto) GetLabel() FieldDescriptorProto_Label { + if m != nil && m.Label != nil { + return *m.Label + } + return FieldDescriptorProto_LABEL_OPTIONAL +} + +func (m *FieldDescriptorProto) GetType() FieldDescriptorProto_Type { + if m != nil && m.Type != nil { + return *m.Type + } + return FieldDescriptorProto_TYPE_DOUBLE +} + +func (m *FieldDescriptorProto) GetTypeName() string { + if m != nil && m.TypeName != nil { + return *m.TypeName + } + return "" +} + +func (m *FieldDescriptorProto) GetExtendee() string { + if m != nil && m.Extendee != nil { + return *m.Extendee + } + return "" +} + +func (m *FieldDescriptorProto) GetDefaultValue() string { + if m != nil && m.DefaultValue != nil { + return *m.DefaultValue + } + return "" +} + +func (m *FieldDescriptorProto) GetOneofIndex() int32 { + if m != nil && m.OneofIndex != nil { + return *m.OneofIndex + } + return 0 +} + +func (m *FieldDescriptorProto) GetJsonName() string { + if m != nil && m.JsonName != nil { + return *m.JsonName + } + return "" +} + +func (m *FieldDescriptorProto) GetOptions() *FieldOptions { + if m != nil { + return m.Options + } + return nil +} + +// Describes a oneof. +type OneofDescriptorProto struct { + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *OneofDescriptorProto) Reset() { *m = OneofDescriptorProto{} } +func (m *OneofDescriptorProto) String() string { return proto.CompactTextString(m) } +func (*OneofDescriptorProto) ProtoMessage() {} +func (*OneofDescriptorProto) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } + +func (m *OneofDescriptorProto) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +// Describes an enum type. +type EnumDescriptorProto struct { + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Value []*EnumValueDescriptorProto `protobuf:"bytes,2,rep,name=value" json:"value,omitempty"` + Options *EnumOptions `protobuf:"bytes,3,opt,name=options" json:"options,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *EnumDescriptorProto) Reset() { *m = EnumDescriptorProto{} } +func (m *EnumDescriptorProto) String() string { return proto.CompactTextString(m) } +func (*EnumDescriptorProto) ProtoMessage() {} +func (*EnumDescriptorProto) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} } + +func (m *EnumDescriptorProto) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *EnumDescriptorProto) GetValue() []*EnumValueDescriptorProto { + if m != nil { + return m.Value + } + return nil +} + +func (m *EnumDescriptorProto) GetOptions() *EnumOptions { + if m != nil { + return m.Options + } + return nil +} + +// Describes a value within an enum. +type EnumValueDescriptorProto struct { + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Number *int32 `protobuf:"varint,2,opt,name=number" json:"number,omitempty"` + Options *EnumValueOptions `protobuf:"bytes,3,opt,name=options" json:"options,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *EnumValueDescriptorProto) Reset() { *m = EnumValueDescriptorProto{} } +func (m *EnumValueDescriptorProto) String() string { return proto.CompactTextString(m) } +func (*EnumValueDescriptorProto) ProtoMessage() {} +func (*EnumValueDescriptorProto) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} } + +func (m *EnumValueDescriptorProto) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *EnumValueDescriptorProto) GetNumber() int32 { + if m != nil && m.Number != nil { + return *m.Number + } + return 0 +} + +func (m *EnumValueDescriptorProto) GetOptions() *EnumValueOptions { + if m != nil { + return m.Options + } + return nil +} + +// Describes a service. +type ServiceDescriptorProto struct { + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Method []*MethodDescriptorProto `protobuf:"bytes,2,rep,name=method" json:"method,omitempty"` + Options *ServiceOptions `protobuf:"bytes,3,opt,name=options" json:"options,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *ServiceDescriptorProto) Reset() { *m = ServiceDescriptorProto{} } +func (m *ServiceDescriptorProto) String() string { return proto.CompactTextString(m) } +func (*ServiceDescriptorProto) ProtoMessage() {} +func (*ServiceDescriptorProto) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} } + +func (m *ServiceDescriptorProto) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *ServiceDescriptorProto) GetMethod() []*MethodDescriptorProto { + if m != nil { + return m.Method + } + return nil +} + +func (m *ServiceDescriptorProto) GetOptions() *ServiceOptions { + if m != nil { + return m.Options + } + return nil +} + +// Describes a method of a service. +type MethodDescriptorProto struct { + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + // Input and output type names. These are resolved in the same way as + // FieldDescriptorProto.type_name, but must refer to a message type. + InputType *string `protobuf:"bytes,2,opt,name=input_type" json:"input_type,omitempty"` + OutputType *string `protobuf:"bytes,3,opt,name=output_type" json:"output_type,omitempty"` + Options *MethodOptions `protobuf:"bytes,4,opt,name=options" json:"options,omitempty"` + // Identifies if client streams multiple client messages + ClientStreaming *bool `protobuf:"varint,5,opt,name=client_streaming,def=0" json:"client_streaming,omitempty"` + // Identifies if server streams multiple server messages + ServerStreaming *bool `protobuf:"varint,6,opt,name=server_streaming,def=0" json:"server_streaming,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *MethodDescriptorProto) Reset() { *m = MethodDescriptorProto{} } +func (m *MethodDescriptorProto) String() string { return proto.CompactTextString(m) } +func (*MethodDescriptorProto) ProtoMessage() {} +func (*MethodDescriptorProto) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} } + +const Default_MethodDescriptorProto_ClientStreaming bool = false +const Default_MethodDescriptorProto_ServerStreaming bool = false + +func (m *MethodDescriptorProto) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *MethodDescriptorProto) GetInputType() string { + if m != nil && m.InputType != nil { + return *m.InputType + } + return "" +} + +func (m *MethodDescriptorProto) GetOutputType() string { + if m != nil && m.OutputType != nil { + return *m.OutputType + } + return "" +} + +func (m *MethodDescriptorProto) GetOptions() *MethodOptions { + if m != nil { + return m.Options + } + return nil +} + +func (m *MethodDescriptorProto) GetClientStreaming() bool { + if m != nil && m.ClientStreaming != nil { + return *m.ClientStreaming + } + return Default_MethodDescriptorProto_ClientStreaming +} + +func (m *MethodDescriptorProto) GetServerStreaming() bool { + if m != nil && m.ServerStreaming != nil { + return *m.ServerStreaming + } + return Default_MethodDescriptorProto_ServerStreaming +} + +type FileOptions struct { + // Sets the Java package where classes generated from this .proto will be + // placed. By default, the proto package is used, but this is often + // inappropriate because proto packages do not normally start with backwards + // domain names. + JavaPackage *string `protobuf:"bytes,1,opt,name=java_package" json:"java_package,omitempty"` + // If set, all the classes from the .proto file are wrapped in a single + // outer class with the given name. This applies to both Proto1 + // (equivalent to the old "--one_java_file" option) and Proto2 (where + // a .proto always translates to a single class, but you may want to + // explicitly choose the class name). + JavaOuterClassname *string `protobuf:"bytes,8,opt,name=java_outer_classname" json:"java_outer_classname,omitempty"` + // If set true, then the Java code generator will generate a separate .java + // file for each top-level message, enum, and service defined in the .proto + // file. Thus, these types will *not* be nested inside the outer class + // named by java_outer_classname. However, the outer class will still be + // generated to contain the file's getDescriptor() method as well as any + // top-level extensions defined in the file. + JavaMultipleFiles *bool `protobuf:"varint,10,opt,name=java_multiple_files,def=0" json:"java_multiple_files,omitempty"` + // If set true, then the Java code generator will generate equals() and + // hashCode() methods for all messages defined in the .proto file. + // - In the full runtime, this is purely a speed optimization, as the + // AbstractMessage base class includes reflection-based implementations of + // these methods. + // - In the lite runtime, setting this option changes the semantics of + // equals() and hashCode() to more closely match those of the full runtime; + // the generated methods compute their results based on field values rather + // than object identity. (Implementations should not assume that hashcodes + // will be consistent across runtimes or versions of the protocol compiler.) + JavaGenerateEqualsAndHash *bool `protobuf:"varint,20,opt,name=java_generate_equals_and_hash,def=0" json:"java_generate_equals_and_hash,omitempty"` + // If set true, then the Java2 code generator will generate code that + // throws an exception whenever an attempt is made to assign a non-UTF-8 + // byte sequence to a string field. + // Message reflection will do the same. + // However, an extension field still accepts non-UTF-8 byte sequences. + // This option has no effect on when used with the lite runtime. + JavaStringCheckUtf8 *bool `protobuf:"varint,27,opt,name=java_string_check_utf8,def=0" json:"java_string_check_utf8,omitempty"` + OptimizeFor *FileOptions_OptimizeMode `protobuf:"varint,9,opt,name=optimize_for,enum=google.protobuf.FileOptions_OptimizeMode,def=1" json:"optimize_for,omitempty"` + // Sets the Go package where structs generated from this .proto will be + // placed. If omitted, the Go package will be derived from the following: + // - The basename of the package import path, if provided. + // - Otherwise, the package statement in the .proto file, if present. + // - Otherwise, the basename of the .proto file, without extension. + GoPackage *string `protobuf:"bytes,11,opt,name=go_package" json:"go_package,omitempty"` + // Should generic services be generated in each language? "Generic" services + // are not specific to any particular RPC system. They are generated by the + // main code generators in each language (without additional plugins). + // Generic services were the only kind of service generation supported by + // early versions of google.protobuf. + // + // Generic services are now considered deprecated in favor of using plugins + // that generate code specific to your particular RPC system. Therefore, + // these default to false. Old code which depends on generic services should + // explicitly set them to true. + CcGenericServices *bool `protobuf:"varint,16,opt,name=cc_generic_services,def=0" json:"cc_generic_services,omitempty"` + JavaGenericServices *bool `protobuf:"varint,17,opt,name=java_generic_services,def=0" json:"java_generic_services,omitempty"` + PyGenericServices *bool `protobuf:"varint,18,opt,name=py_generic_services,def=0" json:"py_generic_services,omitempty"` + // Is this file deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for everything in the file, or it will be completely ignored; in the very + // least, this is a formalization for deprecating files. + Deprecated *bool `protobuf:"varint,23,opt,name=deprecated,def=0" json:"deprecated,omitempty"` + // Enables the use of arenas for the proto messages in this file. This applies + // only to generated classes for C++. + CcEnableArenas *bool `protobuf:"varint,31,opt,name=cc_enable_arenas,def=0" json:"cc_enable_arenas,omitempty"` + // The parser stores options it doesn't recognize here. See above. + UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option" json:"uninterpreted_option,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *FileOptions) Reset() { *m = FileOptions{} } +func (m *FileOptions) String() string { return proto.CompactTextString(m) } +func (*FileOptions) ProtoMessage() {} +func (*FileOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} } + +var extRange_FileOptions = []proto.ExtensionRange{ + {1000, 536870911}, +} + +func (*FileOptions) ExtensionRangeArray() []proto.ExtensionRange { + return extRange_FileOptions +} +func (m *FileOptions) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} + +const Default_FileOptions_JavaMultipleFiles bool = false +const Default_FileOptions_JavaGenerateEqualsAndHash bool = false +const Default_FileOptions_JavaStringCheckUtf8 bool = false +const Default_FileOptions_OptimizeFor FileOptions_OptimizeMode = FileOptions_SPEED +const Default_FileOptions_CcGenericServices bool = false +const Default_FileOptions_JavaGenericServices bool = false +const Default_FileOptions_PyGenericServices bool = false +const Default_FileOptions_Deprecated bool = false +const Default_FileOptions_CcEnableArenas bool = false + +func (m *FileOptions) GetJavaPackage() string { + if m != nil && m.JavaPackage != nil { + return *m.JavaPackage + } + return "" +} + +func (m *FileOptions) GetJavaOuterClassname() string { + if m != nil && m.JavaOuterClassname != nil { + return *m.JavaOuterClassname + } + return "" +} + +func (m *FileOptions) GetJavaMultipleFiles() bool { + if m != nil && m.JavaMultipleFiles != nil { + return *m.JavaMultipleFiles + } + return Default_FileOptions_JavaMultipleFiles +} + +func (m *FileOptions) GetJavaGenerateEqualsAndHash() bool { + if m != nil && m.JavaGenerateEqualsAndHash != nil { + return *m.JavaGenerateEqualsAndHash + } + return Default_FileOptions_JavaGenerateEqualsAndHash +} + +func (m *FileOptions) GetJavaStringCheckUtf8() bool { + if m != nil && m.JavaStringCheckUtf8 != nil { + return *m.JavaStringCheckUtf8 + } + return Default_FileOptions_JavaStringCheckUtf8 +} + +func (m *FileOptions) GetOptimizeFor() FileOptions_OptimizeMode { + if m != nil && m.OptimizeFor != nil { + return *m.OptimizeFor + } + return Default_FileOptions_OptimizeFor +} + +func (m *FileOptions) GetGoPackage() string { + if m != nil && m.GoPackage != nil { + return *m.GoPackage + } + return "" +} + +func (m *FileOptions) GetCcGenericServices() bool { + if m != nil && m.CcGenericServices != nil { + return *m.CcGenericServices + } + return Default_FileOptions_CcGenericServices +} + +func (m *FileOptions) GetJavaGenericServices() bool { + if m != nil && m.JavaGenericServices != nil { + return *m.JavaGenericServices + } + return Default_FileOptions_JavaGenericServices +} + +func (m *FileOptions) GetPyGenericServices() bool { + if m != nil && m.PyGenericServices != nil { + return *m.PyGenericServices + } + return Default_FileOptions_PyGenericServices +} + +func (m *FileOptions) GetDeprecated() bool { + if m != nil && m.Deprecated != nil { + return *m.Deprecated + } + return Default_FileOptions_Deprecated +} + +func (m *FileOptions) GetCcEnableArenas() bool { + if m != nil && m.CcEnableArenas != nil { + return *m.CcEnableArenas + } + return Default_FileOptions_CcEnableArenas +} + +func (m *FileOptions) GetUninterpretedOption() []*UninterpretedOption { + if m != nil { + return m.UninterpretedOption + } + return nil +} + +type MessageOptions struct { + // Set true to use the old proto1 MessageSet wire format for extensions. + // This is provided for backwards-compatibility with the MessageSet wire + // format. You should not use this for any other reason: It's less + // efficient, has fewer features, and is more complicated. + // + // The message must be defined exactly as follows: + // message Foo { + // option message_set_wire_format = true; + // extensions 4 to max; + // } + // Note that the message cannot have any defined fields; MessageSets only + // have extensions. + // + // All extensions of your type must be singular messages; e.g. they cannot + // be int32s, enums, or repeated messages. + // + // Because this is an option, the above two restrictions are not enforced by + // the protocol compiler. + MessageSetWireFormat *bool `protobuf:"varint,1,opt,name=message_set_wire_format,def=0" json:"message_set_wire_format,omitempty"` + // Disables the generation of the standard "descriptor()" accessor, which can + // conflict with a field of the same name. This is meant to make migration + // from proto1 easier; new code should avoid fields named "descriptor". + NoStandardDescriptorAccessor *bool `protobuf:"varint,2,opt,name=no_standard_descriptor_accessor,def=0" json:"no_standard_descriptor_accessor,omitempty"` + // Is this message deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for the message, or it will be completely ignored; in the very least, + // this is a formalization for deprecating messages. + Deprecated *bool `protobuf:"varint,3,opt,name=deprecated,def=0" json:"deprecated,omitempty"` + // Whether the message is an automatically generated map entry type for the + // maps field. + // + // For maps fields: + // map map_field = 1; + // The parsed descriptor looks like: + // message MapFieldEntry { + // option map_entry = true; + // optional KeyType key = 1; + // optional ValueType value = 2; + // } + // repeated MapFieldEntry map_field = 1; + // + // Implementations may choose not to generate the map_entry=true message, but + // use a native map in the target language to hold the keys and values. + // The reflection APIs in such implementions still need to work as + // if the field is a repeated message field. + // + // NOTE: Do not set the option in .proto files. Always use the maps syntax + // instead. The option should only be implicitly set by the proto compiler + // parser. + MapEntry *bool `protobuf:"varint,7,opt,name=map_entry" json:"map_entry,omitempty"` + // The parser stores options it doesn't recognize here. See above. + UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option" json:"uninterpreted_option,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *MessageOptions) Reset() { *m = MessageOptions{} } +func (m *MessageOptions) String() string { return proto.CompactTextString(m) } +func (*MessageOptions) ProtoMessage() {} +func (*MessageOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} } + +var extRange_MessageOptions = []proto.ExtensionRange{ + {1000, 536870911}, +} + +func (*MessageOptions) ExtensionRangeArray() []proto.ExtensionRange { + return extRange_MessageOptions +} +func (m *MessageOptions) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} + +const Default_MessageOptions_MessageSetWireFormat bool = false +const Default_MessageOptions_NoStandardDescriptorAccessor bool = false +const Default_MessageOptions_Deprecated bool = false + +func (m *MessageOptions) GetMessageSetWireFormat() bool { + if m != nil && m.MessageSetWireFormat != nil { + return *m.MessageSetWireFormat + } + return Default_MessageOptions_MessageSetWireFormat +} + +func (m *MessageOptions) GetNoStandardDescriptorAccessor() bool { + if m != nil && m.NoStandardDescriptorAccessor != nil { + return *m.NoStandardDescriptorAccessor + } + return Default_MessageOptions_NoStandardDescriptorAccessor +} + +func (m *MessageOptions) GetDeprecated() bool { + if m != nil && m.Deprecated != nil { + return *m.Deprecated + } + return Default_MessageOptions_Deprecated +} + +func (m *MessageOptions) GetMapEntry() bool { + if m != nil && m.MapEntry != nil { + return *m.MapEntry + } + return false +} + +func (m *MessageOptions) GetUninterpretedOption() []*UninterpretedOption { + if m != nil { + return m.UninterpretedOption + } + return nil +} + +type FieldOptions struct { + // The ctype option instructs the C++ code generator to use a different + // representation of the field than it normally would. See the specific + // options below. This option is not yet implemented in the open source + // release -- sorry, we'll try to include it in a future version! + Ctype *FieldOptions_CType `protobuf:"varint,1,opt,name=ctype,enum=google.protobuf.FieldOptions_CType,def=0" json:"ctype,omitempty"` + // The packed option can be enabled for repeated primitive fields to enable + // a more efficient representation on the wire. Rather than repeatedly + // writing the tag and type for each element, the entire array is encoded as + // a single length-delimited blob. + Packed *bool `protobuf:"varint,2,opt,name=packed" json:"packed,omitempty"` + // Should this field be parsed lazily? Lazy applies only to message-type + // fields. It means that when the outer message is initially parsed, the + // inner message's contents will not be parsed but instead stored in encoded + // form. The inner message will actually be parsed when it is first accessed. + // + // This is only a hint. Implementations are free to choose whether to use + // eager or lazy parsing regardless of the value of this option. However, + // setting this option true suggests that the protocol author believes that + // using lazy parsing on this field is worth the additional bookkeeping + // overhead typically needed to implement it. + // + // This option does not affect the public interface of any generated code; + // all method signatures remain the same. Furthermore, thread-safety of the + // interface is not affected by this option; const methods remain safe to + // call from multiple threads concurrently, while non-const methods continue + // to require exclusive access. + // + // + // Note that implementations may choose not to check required fields within + // a lazy sub-message. That is, calling IsInitialized() on the outher message + // may return true even if the inner message has missing required fields. + // This is necessary because otherwise the inner message would have to be + // parsed in order to perform the check, defeating the purpose of lazy + // parsing. An implementation which chooses not to check required fields + // must be consistent about it. That is, for any particular sub-message, the + // implementation must either *always* check its required fields, or *never* + // check its required fields, regardless of whether or not the message has + // been parsed. + Lazy *bool `protobuf:"varint,5,opt,name=lazy,def=0" json:"lazy,omitempty"` + // Is this field deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for accessors, or it will be completely ignored; in the very least, this + // is a formalization for deprecating fields. + Deprecated *bool `protobuf:"varint,3,opt,name=deprecated,def=0" json:"deprecated,omitempty"` + // For Google-internal migration only. Do not use. + Weak *bool `protobuf:"varint,10,opt,name=weak,def=0" json:"weak,omitempty"` + // The parser stores options it doesn't recognize here. See above. + UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option" json:"uninterpreted_option,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *FieldOptions) Reset() { *m = FieldOptions{} } +func (m *FieldOptions) String() string { return proto.CompactTextString(m) } +func (*FieldOptions) ProtoMessage() {} +func (*FieldOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} } + +var extRange_FieldOptions = []proto.ExtensionRange{ + {1000, 536870911}, +} + +func (*FieldOptions) ExtensionRangeArray() []proto.ExtensionRange { + return extRange_FieldOptions +} +func (m *FieldOptions) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} + +const Default_FieldOptions_Ctype FieldOptions_CType = FieldOptions_STRING +const Default_FieldOptions_Lazy bool = false +const Default_FieldOptions_Deprecated bool = false +const Default_FieldOptions_Weak bool = false + +func (m *FieldOptions) GetCtype() FieldOptions_CType { + if m != nil && m.Ctype != nil { + return *m.Ctype + } + return Default_FieldOptions_Ctype +} + +func (m *FieldOptions) GetPacked() bool { + if m != nil && m.Packed != nil { + return *m.Packed + } + return false +} + +func (m *FieldOptions) GetLazy() bool { + if m != nil && m.Lazy != nil { + return *m.Lazy + } + return Default_FieldOptions_Lazy +} + +func (m *FieldOptions) GetDeprecated() bool { + if m != nil && m.Deprecated != nil { + return *m.Deprecated + } + return Default_FieldOptions_Deprecated +} + +func (m *FieldOptions) GetWeak() bool { + if m != nil && m.Weak != nil { + return *m.Weak + } + return Default_FieldOptions_Weak +} + +func (m *FieldOptions) GetUninterpretedOption() []*UninterpretedOption { + if m != nil { + return m.UninterpretedOption + } + return nil +} + +type EnumOptions struct { + // Set this option to true to allow mapping different tag names to the same + // value. + AllowAlias *bool `protobuf:"varint,2,opt,name=allow_alias" json:"allow_alias,omitempty"` + // Is this enum deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for the enum, or it will be completely ignored; in the very least, this + // is a formalization for deprecating enums. + Deprecated *bool `protobuf:"varint,3,opt,name=deprecated,def=0" json:"deprecated,omitempty"` + // The parser stores options it doesn't recognize here. See above. + UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option" json:"uninterpreted_option,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *EnumOptions) Reset() { *m = EnumOptions{} } +func (m *EnumOptions) String() string { return proto.CompactTextString(m) } +func (*EnumOptions) ProtoMessage() {} +func (*EnumOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{12} } + +var extRange_EnumOptions = []proto.ExtensionRange{ + {1000, 536870911}, +} + +func (*EnumOptions) ExtensionRangeArray() []proto.ExtensionRange { + return extRange_EnumOptions +} +func (m *EnumOptions) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} + +const Default_EnumOptions_Deprecated bool = false + +func (m *EnumOptions) GetAllowAlias() bool { + if m != nil && m.AllowAlias != nil { + return *m.AllowAlias + } + return false +} + +func (m *EnumOptions) GetDeprecated() bool { + if m != nil && m.Deprecated != nil { + return *m.Deprecated + } + return Default_EnumOptions_Deprecated +} + +func (m *EnumOptions) GetUninterpretedOption() []*UninterpretedOption { + if m != nil { + return m.UninterpretedOption + } + return nil +} + +type EnumValueOptions struct { + // Is this enum value deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for the enum value, or it will be completely ignored; in the very least, + // this is a formalization for deprecating enum values. + Deprecated *bool `protobuf:"varint,1,opt,name=deprecated,def=0" json:"deprecated,omitempty"` + // The parser stores options it doesn't recognize here. See above. + UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option" json:"uninterpreted_option,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *EnumValueOptions) Reset() { *m = EnumValueOptions{} } +func (m *EnumValueOptions) String() string { return proto.CompactTextString(m) } +func (*EnumValueOptions) ProtoMessage() {} +func (*EnumValueOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{13} } + +var extRange_EnumValueOptions = []proto.ExtensionRange{ + {1000, 536870911}, +} + +func (*EnumValueOptions) ExtensionRangeArray() []proto.ExtensionRange { + return extRange_EnumValueOptions +} +func (m *EnumValueOptions) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} + +const Default_EnumValueOptions_Deprecated bool = false + +func (m *EnumValueOptions) GetDeprecated() bool { + if m != nil && m.Deprecated != nil { + return *m.Deprecated + } + return Default_EnumValueOptions_Deprecated +} + +func (m *EnumValueOptions) GetUninterpretedOption() []*UninterpretedOption { + if m != nil { + return m.UninterpretedOption + } + return nil +} + +type ServiceOptions struct { + // Is this service deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for the service, or it will be completely ignored; in the very least, + // this is a formalization for deprecating services. + Deprecated *bool `protobuf:"varint,33,opt,name=deprecated,def=0" json:"deprecated,omitempty"` + // The parser stores options it doesn't recognize here. See above. + UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option" json:"uninterpreted_option,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *ServiceOptions) Reset() { *m = ServiceOptions{} } +func (m *ServiceOptions) String() string { return proto.CompactTextString(m) } +func (*ServiceOptions) ProtoMessage() {} +func (*ServiceOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{14} } + +var extRange_ServiceOptions = []proto.ExtensionRange{ + {1000, 536870911}, +} + +func (*ServiceOptions) ExtensionRangeArray() []proto.ExtensionRange { + return extRange_ServiceOptions +} +func (m *ServiceOptions) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} + +const Default_ServiceOptions_Deprecated bool = false + +func (m *ServiceOptions) GetDeprecated() bool { + if m != nil && m.Deprecated != nil { + return *m.Deprecated + } + return Default_ServiceOptions_Deprecated +} + +func (m *ServiceOptions) GetUninterpretedOption() []*UninterpretedOption { + if m != nil { + return m.UninterpretedOption + } + return nil +} + +type MethodOptions struct { + // Is this method deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for the method, or it will be completely ignored; in the very least, + // this is a formalization for deprecating methods. + Deprecated *bool `protobuf:"varint,33,opt,name=deprecated,def=0" json:"deprecated,omitempty"` + // The parser stores options it doesn't recognize here. See above. + UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option" json:"uninterpreted_option,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *MethodOptions) Reset() { *m = MethodOptions{} } +func (m *MethodOptions) String() string { return proto.CompactTextString(m) } +func (*MethodOptions) ProtoMessage() {} +func (*MethodOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{15} } + +var extRange_MethodOptions = []proto.ExtensionRange{ + {1000, 536870911}, +} + +func (*MethodOptions) ExtensionRangeArray() []proto.ExtensionRange { + return extRange_MethodOptions +} +func (m *MethodOptions) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} + +const Default_MethodOptions_Deprecated bool = false + +func (m *MethodOptions) GetDeprecated() bool { + if m != nil && m.Deprecated != nil { + return *m.Deprecated + } + return Default_MethodOptions_Deprecated +} + +func (m *MethodOptions) GetUninterpretedOption() []*UninterpretedOption { + if m != nil { + return m.UninterpretedOption + } + return nil +} + +// A message representing a option the parser does not recognize. This only +// appears in options protos created by the compiler::Parser class. +// DescriptorPool resolves these when building Descriptor objects. Therefore, +// options protos in descriptor objects (e.g. returned by Descriptor::options(), +// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions +// in them. +type UninterpretedOption struct { + Name []*UninterpretedOption_NamePart `protobuf:"bytes,2,rep,name=name" json:"name,omitempty"` + // The value of the uninterpreted option, in whatever type the tokenizer + // identified it as during parsing. Exactly one of these should be set. + IdentifierValue *string `protobuf:"bytes,3,opt,name=identifier_value" json:"identifier_value,omitempty"` + PositiveIntValue *uint64 `protobuf:"varint,4,opt,name=positive_int_value" json:"positive_int_value,omitempty"` + NegativeIntValue *int64 `protobuf:"varint,5,opt,name=negative_int_value" json:"negative_int_value,omitempty"` + DoubleValue *float64 `protobuf:"fixed64,6,opt,name=double_value" json:"double_value,omitempty"` + StringValue []byte `protobuf:"bytes,7,opt,name=string_value" json:"string_value,omitempty"` + AggregateValue *string `protobuf:"bytes,8,opt,name=aggregate_value" json:"aggregate_value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *UninterpretedOption) Reset() { *m = UninterpretedOption{} } +func (m *UninterpretedOption) String() string { return proto.CompactTextString(m) } +func (*UninterpretedOption) ProtoMessage() {} +func (*UninterpretedOption) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{16} } + +func (m *UninterpretedOption) GetName() []*UninterpretedOption_NamePart { + if m != nil { + return m.Name + } + return nil +} + +func (m *UninterpretedOption) GetIdentifierValue() string { + if m != nil && m.IdentifierValue != nil { + return *m.IdentifierValue + } + return "" +} + +func (m *UninterpretedOption) GetPositiveIntValue() uint64 { + if m != nil && m.PositiveIntValue != nil { + return *m.PositiveIntValue + } + return 0 +} + +func (m *UninterpretedOption) GetNegativeIntValue() int64 { + if m != nil && m.NegativeIntValue != nil { + return *m.NegativeIntValue + } + return 0 +} + +func (m *UninterpretedOption) GetDoubleValue() float64 { + if m != nil && m.DoubleValue != nil { + return *m.DoubleValue + } + return 0 +} + +func (m *UninterpretedOption) GetStringValue() []byte { + if m != nil { + return m.StringValue + } + return nil +} + +func (m *UninterpretedOption) GetAggregateValue() string { + if m != nil && m.AggregateValue != nil { + return *m.AggregateValue + } + return "" +} + +// The name of the uninterpreted option. Each string represents a segment in +// a dot-separated name. is_extension is true iff a segment represents an +// extension (denoted with parentheses in options specs in .proto files). +// E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents +// "foo.(bar.baz).qux". +type UninterpretedOption_NamePart struct { + NamePart *string `protobuf:"bytes,1,req,name=name_part" json:"name_part,omitempty"` + IsExtension *bool `protobuf:"varint,2,req,name=is_extension" json:"is_extension,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *UninterpretedOption_NamePart) Reset() { *m = UninterpretedOption_NamePart{} } +func (m *UninterpretedOption_NamePart) String() string { return proto.CompactTextString(m) } +func (*UninterpretedOption_NamePart) ProtoMessage() {} +func (*UninterpretedOption_NamePart) Descriptor() ([]byte, []int) { + return fileDescriptor0, []int{16, 0} +} + +func (m *UninterpretedOption_NamePart) GetNamePart() string { + if m != nil && m.NamePart != nil { + return *m.NamePart + } + return "" +} + +func (m *UninterpretedOption_NamePart) GetIsExtension() bool { + if m != nil && m.IsExtension != nil { + return *m.IsExtension + } + return false +} + +// Encapsulates information about the original source file from which a +// FileDescriptorProto was generated. +type SourceCodeInfo struct { + // A Location identifies a piece of source code in a .proto file which + // corresponds to a particular definition. This information is intended + // to be useful to IDEs, code indexers, documentation generators, and similar + // tools. + // + // For example, say we have a file like: + // message Foo { + // optional string foo = 1; + // } + // Let's look at just the field definition: + // optional string foo = 1; + // ^ ^^ ^^ ^ ^^^ + // a bc de f ghi + // We have the following locations: + // span path represents + // [a,i) [ 4, 0, 2, 0 ] The whole field definition. + // [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + // [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + // [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + // [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + // + // Notes: + // - A location may refer to a repeated field itself (i.e. not to any + // particular index within it). This is used whenever a set of elements are + // logically enclosed in a single code segment. For example, an entire + // extend block (possibly containing multiple extension definitions) will + // have an outer location whose path refers to the "extensions" repeated + // field without an index. + // - Multiple locations may have the same path. This happens when a single + // logical declaration is spread out across multiple places. The most + // obvious example is the "extend" block again -- there may be multiple + // extend blocks in the same scope, each of which will have the same path. + // - A location's span is not always a subset of its parent's span. For + // example, the "extendee" of an extension declaration appears at the + // beginning of the "extend" block and is shared by all extensions within + // the block. + // - Just because a location's span is a subset of some other location's span + // does not mean that it is a descendent. For example, a "group" defines + // both a type and a field in a single declaration. Thus, the locations + // corresponding to the type and field and their components will overlap. + // - Code which tries to interpret locations should probably be designed to + // ignore those that it doesn't understand, as more types of locations could + // be recorded in the future. + Location []*SourceCodeInfo_Location `protobuf:"bytes,1,rep,name=location" json:"location,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *SourceCodeInfo) Reset() { *m = SourceCodeInfo{} } +func (m *SourceCodeInfo) String() string { return proto.CompactTextString(m) } +func (*SourceCodeInfo) ProtoMessage() {} +func (*SourceCodeInfo) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{17} } + +func (m *SourceCodeInfo) GetLocation() []*SourceCodeInfo_Location { + if m != nil { + return m.Location + } + return nil +} + +type SourceCodeInfo_Location struct { + // Identifies which part of the FileDescriptorProto was defined at this + // location. + // + // Each element is a field number or an index. They form a path from + // the root FileDescriptorProto to the place where the definition. For + // example, this path: + // [ 4, 3, 2, 7, 1 ] + // refers to: + // file.message_type(3) // 4, 3 + // .field(7) // 2, 7 + // .name() // 1 + // This is because FileDescriptorProto.message_type has field number 4: + // repeated DescriptorProto message_type = 4; + // and DescriptorProto.field has field number 2: + // repeated FieldDescriptorProto field = 2; + // and FieldDescriptorProto.name has field number 1: + // optional string name = 1; + // + // Thus, the above path gives the location of a field name. If we removed + // the last element: + // [ 4, 3, 2, 7 ] + // this path refers to the whole field declaration (from the beginning + // of the label to the terminating semicolon). + Path []int32 `protobuf:"varint,1,rep,packed,name=path" json:"path,omitempty"` + // Always has exactly three or four elements: start line, start column, + // end line (optional, otherwise assumed same as start line), end column. + // These are packed into a single field for efficiency. Note that line + // and column numbers are zero-based -- typically you will want to add + // 1 to each before displaying to a user. + Span []int32 `protobuf:"varint,2,rep,packed,name=span" json:"span,omitempty"` + // If this SourceCodeInfo represents a complete declaration, these are any + // comments appearing before and after the declaration which appear to be + // attached to the declaration. + // + // A series of line comments appearing on consecutive lines, with no other + // tokens appearing on those lines, will be treated as a single comment. + // + // Only the comment content is provided; comment markers (e.g. //) are + // stripped out. For block comments, leading whitespace and an asterisk + // will be stripped from the beginning of each line other than the first. + // Newlines are included in the output. + // + // Examples: + // + // optional int32 foo = 1; // Comment attached to foo. + // // Comment attached to bar. + // optional int32 bar = 2; + // + // optional string baz = 3; + // // Comment attached to baz. + // // Another line attached to baz. + // + // // Comment attached to qux. + // // + // // Another line attached to qux. + // optional double qux = 4; + // + // optional string corge = 5; + // /* Block comment attached + // * to corge. Leading asterisks + // * will be removed. */ + // /* Block comment attached to + // * grault. */ + // optional int32 grault = 6; + LeadingComments *string `protobuf:"bytes,3,opt,name=leading_comments" json:"leading_comments,omitempty"` + TrailingComments *string `protobuf:"bytes,4,opt,name=trailing_comments" json:"trailing_comments,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *SourceCodeInfo_Location) Reset() { *m = SourceCodeInfo_Location{} } +func (m *SourceCodeInfo_Location) String() string { return proto.CompactTextString(m) } +func (*SourceCodeInfo_Location) ProtoMessage() {} +func (*SourceCodeInfo_Location) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{17, 0} } + +func (m *SourceCodeInfo_Location) GetPath() []int32 { + if m != nil { + return m.Path + } + return nil +} + +func (m *SourceCodeInfo_Location) GetSpan() []int32 { + if m != nil { + return m.Span + } + return nil +} + +func (m *SourceCodeInfo_Location) GetLeadingComments() string { + if m != nil && m.LeadingComments != nil { + return *m.LeadingComments + } + return "" +} + +func (m *SourceCodeInfo_Location) GetTrailingComments() string { + if m != nil && m.TrailingComments != nil { + return *m.TrailingComments + } + return "" +} + +func init() { + proto.RegisterType((*FileDescriptorSet)(nil), "google.protobuf.FileDescriptorSet") + proto.RegisterType((*FileDescriptorProto)(nil), "google.protobuf.FileDescriptorProto") + proto.RegisterType((*DescriptorProto)(nil), "google.protobuf.DescriptorProto") + proto.RegisterType((*DescriptorProto_ExtensionRange)(nil), "google.protobuf.DescriptorProto.ExtensionRange") + proto.RegisterType((*FieldDescriptorProto)(nil), "google.protobuf.FieldDescriptorProto") + proto.RegisterType((*OneofDescriptorProto)(nil), "google.protobuf.OneofDescriptorProto") + proto.RegisterType((*EnumDescriptorProto)(nil), "google.protobuf.EnumDescriptorProto") + proto.RegisterType((*EnumValueDescriptorProto)(nil), "google.protobuf.EnumValueDescriptorProto") + proto.RegisterType((*ServiceDescriptorProto)(nil), "google.protobuf.ServiceDescriptorProto") + proto.RegisterType((*MethodDescriptorProto)(nil), "google.protobuf.MethodDescriptorProto") + proto.RegisterType((*FileOptions)(nil), "google.protobuf.FileOptions") + proto.RegisterType((*MessageOptions)(nil), "google.protobuf.MessageOptions") + proto.RegisterType((*FieldOptions)(nil), "google.protobuf.FieldOptions") + proto.RegisterType((*EnumOptions)(nil), "google.protobuf.EnumOptions") + proto.RegisterType((*EnumValueOptions)(nil), "google.protobuf.EnumValueOptions") + proto.RegisterType((*ServiceOptions)(nil), "google.protobuf.ServiceOptions") + proto.RegisterType((*MethodOptions)(nil), "google.protobuf.MethodOptions") + proto.RegisterType((*UninterpretedOption)(nil), "google.protobuf.UninterpretedOption") + proto.RegisterType((*UninterpretedOption_NamePart)(nil), "google.protobuf.UninterpretedOption.NamePart") + proto.RegisterType((*SourceCodeInfo)(nil), "google.protobuf.SourceCodeInfo") + proto.RegisterType((*SourceCodeInfo_Location)(nil), "google.protobuf.SourceCodeInfo.Location") + proto.RegisterEnum("google.protobuf.FieldDescriptorProto_Type", FieldDescriptorProto_Type_name, FieldDescriptorProto_Type_value) + proto.RegisterEnum("google.protobuf.FieldDescriptorProto_Label", FieldDescriptorProto_Label_name, FieldDescriptorProto_Label_value) + proto.RegisterEnum("google.protobuf.FileOptions_OptimizeMode", FileOptions_OptimizeMode_name, FileOptions_OptimizeMode_value) + proto.RegisterEnum("google.protobuf.FieldOptions_CType", FieldOptions_CType_name, FieldOptions_CType_value) +} + +var fileDescriptor0 = []byte{ + // 1635 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xbc, 0x58, 0xcd, 0x72, 0xdb, 0xd4, + 0x17, 0xff, 0xfb, 0x43, 0xfe, 0x38, 0x76, 0x1c, 0x45, 0x49, 0x5b, 0x35, 0xff, 0x96, 0xb4, 0xa6, + 0x2d, 0x69, 0x69, 0x1d, 0x26, 0x2d, 0xa5, 0x84, 0x55, 0x3e, 0xd4, 0xd4, 0x33, 0x4e, 0x6c, 0x12, + 0x87, 0xa1, 0x6c, 0x34, 0x37, 0xf2, 0xb5, 0xa3, 0x56, 0x96, 0x8c, 0x24, 0xa7, 0x4d, 0x19, 0x66, + 0x78, 0x00, 0x98, 0xe1, 0x09, 0x18, 0x5e, 0x81, 0x0d, 0x2b, 0x36, 0xec, 0x79, 0x03, 0xb6, 0x0c, + 0xf0, 0x18, 0x9c, 0x7b, 0xaf, 0x25, 0x4b, 0x8a, 0x9d, 0xb6, 0x4c, 0x4b, 0x57, 0xee, 0xb9, 0xbf, + 0x73, 0xce, 0xef, 0x9e, 0xcf, 0xab, 0xc0, 0x95, 0x9e, 0xe3, 0xf4, 0x2c, 0xba, 0x32, 0x70, 0x1d, + 0xdf, 0x39, 0x1c, 0x76, 0x57, 0x3a, 0xd4, 0x33, 0x5c, 0x73, 0xe0, 0x3b, 0x6e, 0x8d, 0xcb, 0x94, + 0x59, 0x81, 0xa8, 0x05, 0x88, 0xea, 0x36, 0xcc, 0x3d, 0x34, 0x2d, 0xba, 0x15, 0x02, 0xf7, 0xa9, + 0xaf, 0xac, 0x42, 0xb6, 0x8b, 0x42, 0x35, 0x75, 0x25, 0xb3, 0x5c, 0x5a, 0xbd, 0x56, 0x4b, 0x28, + 0xd5, 0xe2, 0x1a, 0x2d, 0x26, 0xae, 0xfe, 0x9e, 0x81, 0xf9, 0x09, 0x72, 0xa5, 0x0c, 0x59, 0x9b, + 0xf4, 0x99, 0xad, 0xd4, 0x72, 0x51, 0x99, 0x85, 0xfc, 0x80, 0x18, 0x4f, 0x49, 0x8f, 0xaa, 0x69, + 0x2e, 0x50, 0x00, 0x3a, 0x74, 0x40, 0xed, 0x0e, 0xb5, 0x8d, 0x13, 0x35, 0x83, 0x0e, 0x8b, 0xca, + 0x45, 0x98, 0x1b, 0x0c, 0x0f, 0x2d, 0xd3, 0xd0, 0x23, 0x47, 0x80, 0x47, 0x92, 0x72, 0x01, 0x66, + 0x9f, 0x51, 0xf2, 0x34, 0x7a, 0x50, 0xe2, 0x07, 0xf7, 0xa1, 0xdc, 0xa7, 0x9e, 0x87, 0x86, 0x75, + 0xff, 0x64, 0x40, 0xd5, 0x2c, 0xa7, 0x7e, 0xe5, 0x14, 0xf5, 0x24, 0xbd, 0x8f, 0xa0, 0x48, 0xed, + 0x61, 0x5f, 0x28, 0x49, 0x53, 0xee, 0xab, 0x21, 0x22, 0xa9, 0xf8, 0x00, 0xf2, 0x1e, 0x75, 0x8f, + 0x4d, 0x83, 0xaa, 0x39, 0xae, 0xf6, 0xde, 0x29, 0xb5, 0x7d, 0x71, 0x7e, 0x5a, 0xb3, 0x48, 0x9f, + 0xfb, 0xd4, 0xf6, 0x4c, 0xc7, 0x56, 0xf3, 0x5c, 0xf7, 0xfa, 0x84, 0x10, 0x53, 0xab, 0x93, 0xd4, + 0xbc, 0x03, 0x79, 0x67, 0xe0, 0xa3, 0x9a, 0xa7, 0x16, 0x30, 0x7a, 0xa5, 0xd5, 0x4b, 0x13, 0x53, + 0xd3, 0x14, 0x18, 0xe5, 0x63, 0x90, 0x3d, 0x67, 0xe8, 0x1a, 0x54, 0x37, 0x9c, 0x0e, 0xd5, 0x4d, + 0xbb, 0xeb, 0xa8, 0x45, 0xae, 0xb7, 0x74, 0x9a, 0x2b, 0x07, 0x6e, 0x22, 0xae, 0x8e, 0x30, 0xa5, + 0x02, 0x39, 0xef, 0xc4, 0xf6, 0xc9, 0x73, 0xb5, 0xcc, 0xd2, 0x54, 0xfd, 0x23, 0x03, 0xb3, 0x67, + 0x67, 0xf6, 0x1e, 0x48, 0x5d, 0xc6, 0x19, 0xf3, 0xfa, 0x1a, 0x37, 0x8a, 0xc5, 0x22, 0xf7, 0x3a, + 0x9a, 0x1f, 0x42, 0xc9, 0xa6, 0x9e, 0x4f, 0x3b, 0x22, 0x75, 0x99, 0x7f, 0x93, 0xef, 0xec, 0x6b, + 0xe4, 0xfb, 0x11, 0xcc, 0x86, 0x4c, 0x75, 0x97, 0xd8, 0xbd, 0xa0, 0x5c, 0x56, 0x5e, 0xe6, 0xb3, + 0xa6, 0x05, 0x7a, 0x7b, 0x4c, 0x0d, 0xd3, 0x02, 0x8e, 0x4d, 0x9d, 0x2e, 0x16, 0xb1, 0x61, 0x61, + 0x22, 0x27, 0x5f, 0xba, 0xc9, 0x20, 0x49, 0x12, 0x1f, 0x8c, 0x0b, 0x20, 0x3f, 0x25, 0x91, 0x3b, + 0xa2, 0x0b, 0x46, 0x35, 0xb0, 0x78, 0x1b, 0x2a, 0x09, 0xf7, 0x33, 0x20, 0x79, 0x3e, 0x71, 0x7d, + 0x9e, 0x37, 0x49, 0x29, 0x41, 0x06, 0x3b, 0x89, 0x77, 0xa3, 0x54, 0xfd, 0x45, 0x82, 0x85, 0x89, + 0xd1, 0x8e, 0xe7, 0x1a, 0xab, 0x03, 0x23, 0x74, 0x48, 0x5d, 0x0c, 0x3b, 0xb3, 0xb1, 0x06, 0x92, + 0x45, 0x0e, 0xa9, 0x85, 0x01, 0x4d, 0x2d, 0x57, 0x56, 0xdf, 0x7f, 0xa5, 0x0c, 0xd6, 0x1a, 0x4c, + 0x05, 0x2b, 0x20, 0x3b, 0xea, 0x3d, 0xa6, 0x7a, 0xeb, 0xd5, 0x54, 0xdb, 0xa8, 0xa1, 0xcc, 0x41, + 0x91, 0x69, 0xea, 0x9c, 0x58, 0x8e, 0x13, 0x93, 0xa1, 0xc0, 0x93, 0xd4, 0xa1, 0xc1, 0x7c, 0x39, + 0x07, 0x33, 0x1d, 0xda, 0x25, 0x43, 0xcb, 0xd7, 0x8f, 0x89, 0x35, 0xa4, 0x3c, 0x6e, 0x45, 0x65, + 0x1e, 0x4a, 0x22, 0x07, 0x26, 0x62, 0x9f, 0xf3, 0xae, 0x90, 0x98, 0xc1, 0x27, 0x1e, 0x66, 0x97, + 0x1b, 0x04, 0x8e, 0xab, 0x25, 0x3b, 0xee, 0xf2, 0x64, 0x82, 0xa3, 0x70, 0x57, 0x7f, 0x4e, 0x43, + 0x96, 0x93, 0x9b, 0x85, 0x52, 0xfb, 0x71, 0x4b, 0xd3, 0xb7, 0x9a, 0x07, 0x1b, 0x0d, 0x4d, 0x4e, + 0x61, 0xcc, 0x80, 0x0b, 0x1e, 0x36, 0x9a, 0xeb, 0x6d, 0x39, 0x1d, 0xfe, 0xbf, 0xbe, 0xdb, 0xbe, + 0x7f, 0x4f, 0xce, 0x84, 0x0a, 0x07, 0x42, 0x90, 0x8d, 0x02, 0xee, 0xae, 0xca, 0x12, 0xde, 0xad, + 0x2c, 0x0c, 0xd4, 0x3f, 0xd7, 0xb6, 0x10, 0x91, 0x8b, 0x4b, 0x10, 0x93, 0xc7, 0xdc, 0x16, 0xb9, + 0x64, 0xa3, 0xd9, 0x6c, 0xc8, 0x85, 0xd0, 0xe6, 0x7e, 0x7b, 0xaf, 0xbe, 0xbb, 0x2d, 0x17, 0x43, + 0x9b, 0xdb, 0x7b, 0xcd, 0x83, 0x96, 0x0c, 0xa1, 0x85, 0x1d, 0x6d, 0x7f, 0x7f, 0x7d, 0x5b, 0x93, + 0x4b, 0x21, 0x62, 0xe3, 0x71, 0x5b, 0xdb, 0x97, 0xcb, 0x31, 0x5a, 0xe8, 0x62, 0x26, 0x74, 0xa1, + 0xed, 0x1e, 0xec, 0xc8, 0x15, 0x8c, 0xd9, 0x8c, 0x70, 0x11, 0x90, 0x98, 0x4d, 0x88, 0x90, 0xa9, + 0x3c, 0x26, 0x22, 0xac, 0xcc, 0xc5, 0x04, 0x88, 0x50, 0xaa, 0x9b, 0x20, 0x89, 0x7a, 0x50, 0xa0, + 0xd2, 0x58, 0xdf, 0xd0, 0x1a, 0x7a, 0xb3, 0xd5, 0xae, 0x37, 0x77, 0xd7, 0x1b, 0x18, 0xbb, 0x50, + 0xb6, 0xa7, 0x7d, 0x7a, 0x50, 0xdf, 0xd3, 0xb6, 0x30, 0x7e, 0x11, 0x59, 0x4b, 0x5b, 0x6f, 0xa3, + 0x2c, 0x53, 0xbd, 0x06, 0x0b, 0x13, 0xdb, 0x26, 0x56, 0xbd, 0xd5, 0x6f, 0x53, 0x30, 0x3f, 0xa9, + 0xc3, 0xe3, 0x35, 0xfe, 0x00, 0x24, 0x51, 0x30, 0x62, 0x9e, 0xdd, 0x9c, 0x38, 0x24, 0x3e, 0x63, + 0x88, 0x33, 0xa6, 0x74, 0x66, 0xca, 0x94, 0x66, 0xba, 0x41, 0xc9, 0x58, 0xa0, 0x4e, 0x35, 0x35, + 0xad, 0xed, 0x78, 0xb7, 0xe2, 0x9a, 0x4e, 0x38, 0xba, 0x3a, 0x9d, 0x64, 0xe0, 0xed, 0xfb, 0x14, + 0x9c, 0x9f, 0xb2, 0x97, 0xe2, 0xce, 0xee, 0x43, 0xae, 0x4f, 0xfd, 0x23, 0x27, 0x18, 0xe8, 0x37, + 0x26, 0x4c, 0x1a, 0x76, 0x7c, 0xc6, 0x88, 0xca, 0x4c, 0xdb, 0x35, 0xc2, 0x7f, 0x40, 0xe9, 0xd7, + 0x14, 0x9c, 0x9b, 0x6c, 0x2b, 0xce, 0x08, 0x9f, 0x0a, 0xa6, 0x3d, 0x18, 0xfa, 0x62, 0x76, 0xa7, + 0xc3, 0x3e, 0x1e, 0xfa, 0xa1, 0x30, 0xc3, 0x85, 0x2b, 0x63, 0x0a, 0x59, 0x4e, 0xe1, 0x9d, 0x29, + 0xdc, 0x83, 0x45, 0xb9, 0x04, 0xb2, 0x61, 0x99, 0xd4, 0xf6, 0x75, 0xcf, 0x77, 0x29, 0xe9, 0x9b, + 0x76, 0x8f, 0xcf, 0xa3, 0xc2, 0x9a, 0xd4, 0x25, 0x96, 0x47, 0x19, 0x80, 0x2d, 0x7b, 0xea, 0x46, + 0x00, 0xb9, 0x08, 0xa0, 0xfa, 0x5b, 0x16, 0x4a, 0xd1, 0xd5, 0xbb, 0x00, 0xe5, 0x27, 0xe4, 0x98, + 0xe8, 0xc1, 0x63, 0x47, 0xdc, 0xe0, 0x12, 0x2c, 0x70, 0x29, 0x52, 0x46, 0x53, 0x86, 0x45, 0x3c, + 0x8f, 0xdf, 0xaf, 0xc0, 0x4f, 0xab, 0x30, 0xcf, 0x4f, 0xfb, 0x38, 0xac, 0xcc, 0x81, 0x45, 0x75, + 0xf6, 0x06, 0xf3, 0xf8, 0x20, 0x0a, 0x89, 0xdc, 0x86, 0xcb, 0x1c, 0xd3, 0xa3, 0x36, 0x75, 0x89, + 0x4f, 0x75, 0xfa, 0xe5, 0x10, 0x0f, 0x74, 0x62, 0x77, 0xf4, 0x23, 0xe2, 0x1d, 0xa9, 0x0b, 0x51, + 0xf4, 0x75, 0x38, 0xcf, 0xd1, 0x48, 0x1a, 0x19, 0xeb, 0xc6, 0x11, 0x35, 0x9e, 0xea, 0x43, 0xbf, + 0xfb, 0x40, 0xfd, 0x7f, 0x14, 0xf6, 0x10, 0xca, 0x2c, 0x5e, 0x7d, 0xf3, 0x05, 0xfa, 0x74, 0x5c, + 0x3e, 0x0d, 0x2b, 0x13, 0x2a, 0x3e, 0x72, 0xc1, 0x5a, 0x73, 0xa4, 0xb0, 0x83, 0x2f, 0x86, 0x35, + 0x69, 0xbf, 0xa5, 0x69, 0x5b, 0x2c, 0x41, 0x3d, 0x27, 0xbc, 0x72, 0x29, 0xb8, 0x94, 0x61, 0x08, + 0xba, 0xf8, 0x9e, 0x1b, 0xbd, 0x98, 0x3c, 0x55, 0x8e, 0xfa, 0xbf, 0x06, 0xe7, 0xc6, 0x97, 0x8a, + 0xa2, 0xe6, 0xa2, 0x28, 0xb4, 0x34, 0x38, 0x39, 0x8d, 0x51, 0xa2, 0x98, 0x8b, 0xfc, 0x35, 0xe9, + 0x52, 0x03, 0x43, 0xd3, 0x51, 0x2f, 0x24, 0x52, 0x88, 0x44, 0xa8, 0x4d, 0x0e, 0x31, 0xb2, 0xc4, + 0xc5, 0x1f, 0x9e, 0xba, 0x14, 0x05, 0x6c, 0xc2, 0xc2, 0xd0, 0x36, 0x6d, 0xcc, 0x0c, 0x1a, 0x60, + 0xef, 0x0a, 0x51, 0x43, 0xea, 0x5f, 0xf9, 0x29, 0xaf, 0x84, 0x83, 0x28, 0x5a, 0xc4, 0xa5, 0xba, + 0x06, 0xe5, 0x68, 0x64, 0x94, 0x22, 0x88, 0xd8, 0xe0, 0x10, 0xc3, 0xc1, 0xb9, 0xd9, 0xdc, 0x62, + 0x23, 0xef, 0x0b, 0x0d, 0xe7, 0x17, 0x8e, 0xde, 0x46, 0xbd, 0xad, 0xe9, 0x7b, 0x07, 0xbb, 0xed, + 0xfa, 0x8e, 0x26, 0x67, 0x6e, 0x15, 0x0b, 0x7f, 0xe7, 0xe5, 0x6f, 0xf0, 0x5f, 0xba, 0xfa, 0x67, + 0x0a, 0x2a, 0xf1, 0x45, 0xae, 0xdc, 0x80, 0x0b, 0xc1, 0x03, 0xd7, 0xa3, 0xbe, 0xfe, 0xcc, 0x74, + 0x79, 0xb2, 0xfa, 0x44, 0x2c, 0xf2, 0xf0, 0x1a, 0x35, 0x58, 0xb2, 0x1d, 0xcc, 0x38, 0x56, 0x04, + 0x71, 0x3b, 0xfa, 0xf8, 0x0b, 0x40, 0x27, 0x06, 0xc6, 0xcb, 0x73, 0xc4, 0xf4, 0x98, 0x12, 0xb2, + 0x4c, 0xf4, 0x08, 0xf7, 0x61, 0x9f, 0x0c, 0x30, 0x66, 0xbe, 0x7b, 0xc2, 0xf7, 0x66, 0xe1, 0x8d, + 0x04, 0x29, 0x7a, 0xd1, 0x1f, 0xd3, 0x50, 0x8e, 0x2e, 0x50, 0xf6, 0x94, 0x30, 0x78, 0x2b, 0xa7, + 0x78, 0x11, 0xbe, 0x7b, 0xe6, 0xba, 0xad, 0x6d, 0xb2, 0x5d, 0xbb, 0x96, 0x13, 0xfb, 0x8d, 0xcd, + 0x47, 0x56, 0x7c, 0x54, 0xbc, 0x66, 0x0a, 0x38, 0x1c, 0xb2, 0x16, 0x79, 0x71, 0x12, 0x6f, 0xe5, + 0x33, 0xee, 0x8b, 0x78, 0xf6, 0x71, 0x11, 0xef, 0xb8, 0x37, 0x52, 0x16, 0x2b, 0x20, 0x71, 0xaa, + 0xd8, 0x21, 0x23, 0xb2, 0xf2, 0xff, 0x94, 0x02, 0x64, 0x37, 0x9b, 0x7b, 0xac, 0x34, 0xb0, 0x16, + 0x84, 0x54, 0x6f, 0xd5, 0xb5, 0x4d, 0xac, 0x8e, 0x68, 0x88, 0xbe, 0x4b, 0x41, 0x29, 0xb2, 0x2f, + 0xd8, 0xc8, 0x23, 0x96, 0xe5, 0x3c, 0xd3, 0x89, 0x65, 0x62, 0x0d, 0x8b, 0xab, 0x9e, 0x71, 0xab, + 0x37, 0x9d, 0xb2, 0xaf, 0x41, 0x4e, 0x6e, 0x95, 0x84, 0xfb, 0xd4, 0xdb, 0x74, 0xff, 0x15, 0x54, + 0xe2, 0xfb, 0x23, 0xe1, 0xfc, 0xea, 0xdb, 0x74, 0xfe, 0x02, 0x66, 0xe2, 0x9b, 0xe3, 0x3f, 0xf4, + 0xfd, 0x43, 0x1a, 0xe6, 0x27, 0x40, 0x94, 0x4f, 0x46, 0x4b, 0x52, 0xac, 0xe9, 0x3b, 0xaf, 0x62, + 0xb6, 0xb6, 0x8b, 0x0a, 0x2d, 0xfc, 0x06, 0x50, 0x54, 0x90, 0x4d, 0xfc, 0x8c, 0xf6, 0x4d, 0xfc, + 0x76, 0x73, 0x47, 0x2f, 0x64, 0xb1, 0x44, 0x17, 0x41, 0x19, 0x38, 0x9e, 0xe9, 0x9b, 0xc7, 0xec, + 0xcb, 0x31, 0x78, 0x3d, 0xb3, 0x7d, 0x9a, 0x65, 0x67, 0x36, 0xed, 0x91, 0xc4, 0x19, 0x6b, 0xb3, + 0x0c, 0xdb, 0x7c, 0x1d, 0x67, 0xc8, 0x86, 0xac, 0x90, 0xb2, 0x35, 0x99, 0x62, 0xd2, 0xd1, 0x12, + 0x1a, 0xbf, 0xc2, 0xcb, 0xec, 0x6b, 0x9e, 0xf4, 0x7a, 0x2e, 0x33, 0x15, 0xc0, 0xf9, 0x2a, 0x5c, + 0xbc, 0x0b, 0x85, 0x90, 0x22, 0x4e, 0x21, 0x76, 0x3f, 0xdc, 0x2b, 0xfc, 0x9b, 0x25, 0x8d, 0xdc, + 0xd0, 0x9a, 0xe9, 0xe9, 0xe3, 0x0f, 0xc7, 0x34, 0x4a, 0x0b, 0xd5, 0x9f, 0x70, 0x68, 0x26, 0x3e, + 0x63, 0xd7, 0xa0, 0x60, 0x39, 0x98, 0x1b, 0x06, 0x12, 0x7f, 0xcc, 0x58, 0x7e, 0xc9, 0x97, 0x6f, + 0xad, 0x31, 0xc2, 0x2f, 0x1a, 0x50, 0x08, 0x7e, 0x63, 0x83, 0x66, 0x07, 0xc4, 0x3f, 0xe2, 0x36, + 0xa4, 0x8d, 0x34, 0x6f, 0xd9, 0xac, 0x37, 0x20, 0x36, 0x8f, 0xba, 0x90, 0x60, 0x28, 0x2d, 0x4a, + 0x3a, 0x7c, 0xd1, 0x3a, 0xfd, 0x3e, 0x06, 0xd5, 0x1b, 0x85, 0xf2, 0x22, 0xcc, 0xf9, 0x2e, 0x31, + 0xad, 0xd8, 0x11, 0x8b, 0x64, 0x71, 0xe3, 0x26, 0xae, 0x47, 0xa7, 0x9f, 0xe4, 0xb4, 0x21, 0x27, + 0x5e, 0x42, 0xde, 0xa3, 0xd4, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x3d, 0xe5, 0x5c, 0x96, 0xdd, + 0x11, 0x00, 0x00, +} diff --git a/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/doc.go b/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/doc.go new file mode 100644 index 0000000000..0d6055d610 --- /dev/null +++ b/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/doc.go @@ -0,0 +1,51 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +/* + A plugin for the Google protocol buffer compiler to generate Go code. + Run it by building this program and putting it in your path with the name + protoc-gen-go + That word 'go' at the end becomes part of the option string set for the + protocol compiler, so once the protocol compiler (protoc) is installed + you can run + protoc --go_out=output_directory input_directory/file.proto + to generate Go bindings for the protocol defined by file.proto. + With that input, the output will be written to + output_directory/file.pb.go + + The generated code is documented in the package comment for + the library. + + See the README and documentation for protocol buffers to learn more: + https://developers.google.com/protocol-buffers/ + +*/ +package documentation diff --git a/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/generator/Makefile b/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/generator/Makefile new file mode 100644 index 0000000000..b5715c3577 --- /dev/null +++ b/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/generator/Makefile @@ -0,0 +1,40 @@ +# Go support for Protocol Buffers - Google's data interchange format +# +# Copyright 2010 The Go Authors. All rights reserved. +# https://github.com/golang/protobuf +# +# 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. + +include $(GOROOT)/src/Make.inc + +TARG=github.com/golang/protobuf/compiler/generator +GOFILES=\ + generator.go\ + +DEPS=../descriptor ../plugin ../../proto + +include $(GOROOT)/src/Make.pkg diff --git a/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/generator/generator.go b/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/generator/generator.go new file mode 100644 index 0000000000..c2c96bf720 --- /dev/null +++ b/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/generator/generator.go @@ -0,0 +1,2715 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +/* + The code generator for the plugin for the Google protocol buffer compiler. + It generates Go code from the protocol buffer description files read by the + main routine. +*/ +package generator + +import ( + "bufio" + "bytes" + "compress/gzip" + "fmt" + "go/parser" + "go/printer" + "go/token" + "log" + "os" + "path" + "strconv" + "strings" + "unicode" + "unicode/utf8" + + "github.com/golang/protobuf/proto" + + "github.com/golang/protobuf/protoc-gen-go/descriptor" + plugin "github.com/golang/protobuf/protoc-gen-go/plugin" +) + +// generatedCodeVersion indicates a version of the generated code. +// It is incremented whenever an incompatibility between the generated code and +// proto package is introduced; the generated code references +// a constant, proto.ProtoPackageIsVersionN (where N is generatedCodeVersion). +const generatedCodeVersion = 1 + +// A Plugin provides functionality to add to the output during Go code generation, +// such as to produce RPC stubs. +type Plugin interface { + // Name identifies the plugin. + Name() string + // Init is called once after data structures are built but before + // code generation begins. + Init(g *Generator) + // Generate produces the code generated by the plugin for this file, + // except for the imports, by calling the generator's methods P, In, and Out. + Generate(file *FileDescriptor) + // GenerateImports produces the import declarations for this file. + // It is called after Generate. + GenerateImports(file *FileDescriptor) +} + +var plugins []Plugin + +// RegisterPlugin installs a (second-order) plugin to be run when the Go output is generated. +// It is typically called during initialization. +func RegisterPlugin(p Plugin) { + plugins = append(plugins, p) +} + +// Each type we import as a protocol buffer (other than FileDescriptorProto) needs +// a pointer to the FileDescriptorProto that represents it. These types achieve that +// wrapping by placing each Proto inside a struct with the pointer to its File. The +// structs have the same names as their contents, with "Proto" removed. +// FileDescriptor is used to store the things that it points to. + +// The file and package name method are common to messages and enums. +type common struct { + file *descriptor.FileDescriptorProto // File this object comes from. +} + +// PackageName is name in the package clause in the generated file. +func (c *common) PackageName() string { return uniquePackageOf(c.file) } + +func (c *common) File() *descriptor.FileDescriptorProto { return c.file } + +func fileIsProto3(file *descriptor.FileDescriptorProto) bool { + return file.GetSyntax() == "proto3" +} + +func (c *common) proto3() bool { return fileIsProto3(c.file) } + +// Descriptor represents a protocol buffer message. +type Descriptor struct { + common + *descriptor.DescriptorProto + parent *Descriptor // The containing message, if any. + nested []*Descriptor // Inner messages, if any. + enums []*EnumDescriptor // Inner enums, if any. + ext []*ExtensionDescriptor // Extensions, if any. + typename []string // Cached typename vector. + index int // The index into the container, whether the file or another message. + path string // The SourceCodeInfo path as comma-separated integers. + group bool +} + +// TypeName returns the elements of the dotted type name. +// The package name is not part of this name. +func (d *Descriptor) TypeName() []string { + if d.typename != nil { + return d.typename + } + n := 0 + for parent := d; parent != nil; parent = parent.parent { + n++ + } + s := make([]string, n, n) + for parent := d; parent != nil; parent = parent.parent { + n-- + s[n] = parent.GetName() + } + d.typename = s + return s +} + +// EnumDescriptor describes an enum. If it's at top level, its parent will be nil. +// Otherwise it will be the descriptor of the message in which it is defined. +type EnumDescriptor struct { + common + *descriptor.EnumDescriptorProto + parent *Descriptor // The containing message, if any. + typename []string // Cached typename vector. + index int // The index into the container, whether the file or a message. + path string // The SourceCodeInfo path as comma-separated integers. +} + +// TypeName returns the elements of the dotted type name. +// The package name is not part of this name. +func (e *EnumDescriptor) TypeName() (s []string) { + if e.typename != nil { + return e.typename + } + name := e.GetName() + if e.parent == nil { + s = make([]string, 1) + } else { + pname := e.parent.TypeName() + s = make([]string, len(pname)+1) + copy(s, pname) + } + s[len(s)-1] = name + e.typename = s + return s +} + +// Everything but the last element of the full type name, CamelCased. +// The values of type Foo.Bar are call Foo_value1... not Foo_Bar_value1... . +func (e *EnumDescriptor) prefix() string { + if e.parent == nil { + // If the enum is not part of a message, the prefix is just the type name. + return CamelCase(*e.Name) + "_" + } + typeName := e.TypeName() + return CamelCaseSlice(typeName[0:len(typeName)-1]) + "_" +} + +// The integer value of the named constant in this enumerated type. +func (e *EnumDescriptor) integerValueAsString(name string) string { + for _, c := range e.Value { + if c.GetName() == name { + return fmt.Sprint(c.GetNumber()) + } + } + log.Fatal("cannot find value for enum constant") + return "" +} + +// ExtensionDescriptor describes an extension. If it's at top level, its parent will be nil. +// Otherwise it will be the descriptor of the message in which it is defined. +type ExtensionDescriptor struct { + common + *descriptor.FieldDescriptorProto + parent *Descriptor // The containing message, if any. +} + +// TypeName returns the elements of the dotted type name. +// The package name is not part of this name. +func (e *ExtensionDescriptor) TypeName() (s []string) { + name := e.GetName() + if e.parent == nil { + // top-level extension + s = make([]string, 1) + } else { + pname := e.parent.TypeName() + s = make([]string, len(pname)+1) + copy(s, pname) + } + s[len(s)-1] = name + return s +} + +// DescName returns the variable name used for the generated descriptor. +func (e *ExtensionDescriptor) DescName() string { + // The full type name. + typeName := e.TypeName() + // Each scope of the extension is individually CamelCased, and all are joined with "_" with an "E_" prefix. + for i, s := range typeName { + typeName[i] = CamelCase(s) + } + return "E_" + strings.Join(typeName, "_") +} + +// ImportedDescriptor describes a type that has been publicly imported from another file. +type ImportedDescriptor struct { + common + o Object +} + +func (id *ImportedDescriptor) TypeName() []string { return id.o.TypeName() } + +// FileDescriptor describes an protocol buffer descriptor file (.proto). +// It includes slices of all the messages and enums defined within it. +// Those slices are constructed by WrapTypes. +type FileDescriptor struct { + *descriptor.FileDescriptorProto + desc []*Descriptor // All the messages defined in this file. + enum []*EnumDescriptor // All the enums defined in this file. + ext []*ExtensionDescriptor // All the top-level extensions defined in this file. + imp []*ImportedDescriptor // All types defined in files publicly imported by this file. + + // Comments, stored as a map of path (comma-separated integers) to the comment. + comments map[string]*descriptor.SourceCodeInfo_Location + + // The full list of symbols that are exported, + // as a map from the exported object to its symbols. + // This is used for supporting public imports. + exported map[Object][]symbol + + index int // The index of this file in the list of files to generate code for + + proto3 bool // whether to generate proto3 code for this file +} + +// PackageName is the package name we'll use in the generated code to refer to this file. +func (d *FileDescriptor) PackageName() string { return uniquePackageOf(d.FileDescriptorProto) } + +// goPackageName returns the Go package name to use in the +// generated Go file. The result explicit reports whether the name +// came from an option go_package statement. If explicit is false, +// the name was derived from the protocol buffer's package statement +// or the input file name. +func (d *FileDescriptor) goPackageName() (name string, explicit bool) { + // Does the file have a "go_package" option? + if opts := d.Options; opts != nil { + if pkg := opts.GetGoPackage(); pkg != "" { + return pkg, true + } + } + + // Does the file have a package clause? + if pkg := d.GetPackage(); pkg != "" { + return pkg, false + } + // Use the file base name. + return baseName(d.GetName()), false +} + +func (d *FileDescriptor) addExport(obj Object, sym symbol) { + d.exported[obj] = append(d.exported[obj], sym) +} + +// symbol is an interface representing an exported Go symbol. +type symbol interface { + // GenerateAlias should generate an appropriate alias + // for the symbol from the named package. + GenerateAlias(g *Generator, pkg string) +} + +type messageSymbol struct { + sym string + hasExtensions, isMessageSet bool + hasOneof bool + getters []getterSymbol +} + +type getterSymbol struct { + name string + typ string + typeName string // canonical name in proto world; empty for proto.Message and similar + genType bool // whether typ contains a generated type (message/group/enum) +} + +func (ms *messageSymbol) GenerateAlias(g *Generator, pkg string) { + remoteSym := pkg + "." + ms.sym + + g.P("type ", ms.sym, " ", remoteSym) + g.P("func (m *", ms.sym, ") Reset() { (*", remoteSym, ")(m).Reset() }") + g.P("func (m *", ms.sym, ") String() string { return (*", remoteSym, ")(m).String() }") + g.P("func (*", ms.sym, ") ProtoMessage() {}") + if ms.hasExtensions { + g.P("func (*", ms.sym, ") ExtensionRangeArray() []", g.Pkg["proto"], ".ExtensionRange ", + "{ return (*", remoteSym, ")(nil).ExtensionRangeArray() }") + g.P("func (m *", ms.sym, ") ExtensionMap() map[int32]", g.Pkg["proto"], ".Extension ", + "{ return (*", remoteSym, ")(m).ExtensionMap() }") + if ms.isMessageSet { + g.P("func (m *", ms.sym, ") Marshal() ([]byte, error) ", + "{ return (*", remoteSym, ")(m).Marshal() }") + g.P("func (m *", ms.sym, ") Unmarshal(buf []byte) error ", + "{ return (*", remoteSym, ")(m).Unmarshal(buf) }") + } + } + if ms.hasOneof { + // Oneofs and public imports do not mix well. + // We can make them work okay for the binary format, + // but they're going to break weirdly for text/JSON. + enc := "_" + ms.sym + "_OneofMarshaler" + dec := "_" + ms.sym + "_OneofUnmarshaler" + size := "_" + ms.sym + "_OneofSizer" + encSig := "(msg " + g.Pkg["proto"] + ".Message, b *" + g.Pkg["proto"] + ".Buffer) error" + decSig := "(msg " + g.Pkg["proto"] + ".Message, tag, wire int, b *" + g.Pkg["proto"] + ".Buffer) (bool, error)" + sizeSig := "(msg " + g.Pkg["proto"] + ".Message) int" + g.P("func (m *", ms.sym, ") XXX_OneofFuncs() (func", encSig, ", func", decSig, ", func", sizeSig, ", []interface{}) {") + g.P("return ", enc, ", ", dec, ", ", size, ", nil") + g.P("}") + + g.P("func ", enc, encSig, " {") + g.P("m := msg.(*", ms.sym, ")") + g.P("m0 := (*", remoteSym, ")(m)") + g.P("enc, _, _, _ := m0.XXX_OneofFuncs()") + g.P("return enc(m0, b)") + g.P("}") + + g.P("func ", dec, decSig, " {") + g.P("m := msg.(*", ms.sym, ")") + g.P("m0 := (*", remoteSym, ")(m)") + g.P("_, dec, _, _ := m0.XXX_OneofFuncs()") + g.P("return dec(m0, tag, wire, b)") + g.P("}") + + g.P("func ", size, sizeSig, " {") + g.P("m := msg.(*", ms.sym, ")") + g.P("m0 := (*", remoteSym, ")(m)") + g.P("_, _, size, _ := m0.XXX_OneofFuncs()") + g.P("return size(m0)") + g.P("}") + } + for _, get := range ms.getters { + + if get.typeName != "" { + g.RecordTypeUse(get.typeName) + } + typ := get.typ + val := "(*" + remoteSym + ")(m)." + get.name + "()" + if get.genType { + // typ will be "*pkg.T" (message/group) or "pkg.T" (enum) + // or "map[t]*pkg.T" (map to message/enum). + // The first two of those might have a "[]" prefix if it is repeated. + // Drop any package qualifier since we have hoisted the type into this package. + rep := strings.HasPrefix(typ, "[]") + if rep { + typ = typ[2:] + } + isMap := strings.HasPrefix(typ, "map[") + star := typ[0] == '*' + if !isMap { // map types handled lower down + typ = typ[strings.Index(typ, ".")+1:] + } + if star { + typ = "*" + typ + } + if rep { + // Go does not permit conversion between slice types where both + // element types are named. That means we need to generate a bit + // of code in this situation. + // typ is the element type. + // val is the expression to get the slice from the imported type. + + ctyp := typ // conversion type expression; "Foo" or "(*Foo)" + if star { + ctyp = "(" + typ + ")" + } + + g.P("func (m *", ms.sym, ") ", get.name, "() []", typ, " {") + g.In() + g.P("o := ", val) + g.P("if o == nil {") + g.In() + g.P("return nil") + g.Out() + g.P("}") + g.P("s := make([]", typ, ", len(o))") + g.P("for i, x := range o {") + g.In() + g.P("s[i] = ", ctyp, "(x)") + g.Out() + g.P("}") + g.P("return s") + g.Out() + g.P("}") + continue + } + if isMap { + // Split map[keyTyp]valTyp. + bra, ket := strings.Index(typ, "["), strings.Index(typ, "]") + keyTyp, valTyp := typ[bra+1:ket], typ[ket+1:] + // Drop any package qualifier. + // Only the value type may be foreign. + star := valTyp[0] == '*' + valTyp = valTyp[strings.Index(valTyp, ".")+1:] + if star { + valTyp = "*" + valTyp + } + + typ := "map[" + keyTyp + "]" + valTyp + g.P("func (m *", ms.sym, ") ", get.name, "() ", typ, " {") + g.P("o := ", val) + g.P("if o == nil { return nil }") + g.P("s := make(", typ, ", len(o))") + g.P("for k, v := range o {") + g.P("s[k] = (", valTyp, ")(v)") + g.P("}") + g.P("return s") + g.P("}") + continue + } + // Convert imported type into the forwarding type. + val = "(" + typ + ")(" + val + ")" + } + + g.P("func (m *", ms.sym, ") ", get.name, "() ", typ, " { return ", val, " }") + } + +} + +type enumSymbol struct { + name string + proto3 bool // Whether this came from a proto3 file. +} + +func (es enumSymbol) GenerateAlias(g *Generator, pkg string) { + s := es.name + g.P("type ", s, " ", pkg, ".", s) + g.P("var ", s, "_name = ", pkg, ".", s, "_name") + g.P("var ", s, "_value = ", pkg, ".", s, "_value") + g.P("func (x ", s, ") String() string { return (", pkg, ".", s, ")(x).String() }") + if !es.proto3 { + g.P("func (x ", s, ") Enum() *", s, "{ return (*", s, ")((", pkg, ".", s, ")(x).Enum()) }") + g.P("func (x *", s, ") UnmarshalJSON(data []byte) error { return (*", pkg, ".", s, ")(x).UnmarshalJSON(data) }") + } +} + +type constOrVarSymbol struct { + sym string + typ string // either "const" or "var" + cast string // if non-empty, a type cast is required (used for enums) +} + +func (cs constOrVarSymbol) GenerateAlias(g *Generator, pkg string) { + v := pkg + "." + cs.sym + if cs.cast != "" { + v = cs.cast + "(" + v + ")" + } + g.P(cs.typ, " ", cs.sym, " = ", v) +} + +// Object is an interface abstracting the abilities shared by enums, messages, extensions and imported objects. +type Object interface { + PackageName() string // The name we use in our output (a_b_c), possibly renamed for uniqueness. + TypeName() []string + File() *descriptor.FileDescriptorProto +} + +// Each package name we generate must be unique. The package we're generating +// gets its own name but every other package must have a unique name that does +// not conflict in the code we generate. These names are chosen globally (although +// they don't have to be, it simplifies things to do them globally). +func uniquePackageOf(fd *descriptor.FileDescriptorProto) string { + s, ok := uniquePackageName[fd] + if !ok { + log.Fatal("internal error: no package name defined for " + fd.GetName()) + } + return s +} + +// Generator is the type whose methods generate the output, stored in the associated response structure. +type Generator struct { + *bytes.Buffer + + Request *plugin.CodeGeneratorRequest // The input. + Response *plugin.CodeGeneratorResponse // The output. + + Param map[string]string // Command-line parameters. + PackageImportPath string // Go import path of the package we're generating code for + ImportPrefix string // String to prefix to imported package file names. + ImportMap map[string]string // Mapping from import name to generated name + + Pkg map[string]string // The names under which we import support packages + + packageName string // What we're calling ourselves. + allFiles []*FileDescriptor // All files in the tree + allFilesByName map[string]*FileDescriptor // All files by filename. + genFiles []*FileDescriptor // Those files we will generate output for. + file *FileDescriptor // The file we are compiling now. + usedPackages map[string]bool // Names of packages used in current file. + typeNameToObject map[string]Object // Key is a fully-qualified name in input syntax. + init []string // Lines to emit in the init function. + indent string + writeOutput bool +} + +// New creates a new generator and allocates the request and response protobufs. +func New() *Generator { + g := new(Generator) + g.Buffer = new(bytes.Buffer) + g.Request = new(plugin.CodeGeneratorRequest) + g.Response = new(plugin.CodeGeneratorResponse) + return g +} + +// Error reports a problem, including an error, and exits the program. +func (g *Generator) Error(err error, msgs ...string) { + s := strings.Join(msgs, " ") + ":" + err.Error() + log.Print("protoc-gen-go: error:", s) + os.Exit(1) +} + +// Fail reports a problem and exits the program. +func (g *Generator) Fail(msgs ...string) { + s := strings.Join(msgs, " ") + log.Print("protoc-gen-go: error:", s) + os.Exit(1) +} + +// CommandLineParameters breaks the comma-separated list of key=value pairs +// in the parameter (a member of the request protobuf) into a key/value map. +// It then sets file name mappings defined by those entries. +func (g *Generator) CommandLineParameters(parameter string) { + g.Param = make(map[string]string) + for _, p := range strings.Split(parameter, ",") { + if i := strings.Index(p, "="); i < 0 { + g.Param[p] = "" + } else { + g.Param[p[0:i]] = p[i+1:] + } + } + + g.ImportMap = make(map[string]string) + pluginList := "none" // Default list of plugin names to enable (empty means all). + for k, v := range g.Param { + switch k { + case "import_prefix": + g.ImportPrefix = v + case "import_path": + g.PackageImportPath = v + case "plugins": + pluginList = v + default: + if len(k) > 0 && k[0] == 'M' { + g.ImportMap[k[1:]] = v + } + } + } + + if pluginList != "" { + // Amend the set of plugins. + enabled := make(map[string]bool) + for _, name := range strings.Split(pluginList, "+") { + enabled[name] = true + } + var nplugins []Plugin + for _, p := range plugins { + if enabled[p.Name()] { + nplugins = append(nplugins, p) + } + } + plugins = nplugins + } +} + +// DefaultPackageName returns the package name printed for the object. +// If its file is in a different package, it returns the package name we're using for this file, plus ".". +// Otherwise it returns the empty string. +func (g *Generator) DefaultPackageName(obj Object) string { + pkg := obj.PackageName() + if pkg == g.packageName { + return "" + } + return pkg + "." +} + +// For each input file, the unique package name to use, underscored. +var uniquePackageName = make(map[*descriptor.FileDescriptorProto]string) + +// Package names already registered. Key is the name from the .proto file; +// value is the name that appears in the generated code. +var pkgNamesInUse = make(map[string]bool) + +// Create and remember a guaranteed unique package name for this file descriptor. +// Pkg is the candidate name. If f is nil, it's a builtin package like "proto" and +// has no file descriptor. +func RegisterUniquePackageName(pkg string, f *FileDescriptor) string { + // Convert dots to underscores before finding a unique alias. + pkg = strings.Map(badToUnderscore, pkg) + + for i, orig := 1, pkg; pkgNamesInUse[pkg]; i++ { + // It's a duplicate; must rename. + pkg = orig + strconv.Itoa(i) + } + // Install it. + pkgNamesInUse[pkg] = true + if f != nil { + uniquePackageName[f.FileDescriptorProto] = pkg + } + return pkg +} + +var isGoKeyword = map[string]bool{ + "break": true, + "case": true, + "chan": true, + "const": true, + "continue": true, + "default": true, + "else": true, + "defer": true, + "fallthrough": true, + "for": true, + "func": true, + "go": true, + "goto": true, + "if": true, + "import": true, + "interface": true, + "map": true, + "package": true, + "range": true, + "return": true, + "select": true, + "struct": true, + "switch": true, + "type": true, + "var": true, +} + +// defaultGoPackage returns the package name to use, +// derived from the import path of the package we're building code for. +func (g *Generator) defaultGoPackage() string { + p := g.PackageImportPath + if i := strings.LastIndex(p, "/"); i >= 0 { + p = p[i+1:] + } + if p == "" { + return "" + } + + p = strings.Map(badToUnderscore, p) + // Identifier must not be keyword: insert _. + if isGoKeyword[p] { + p = "_" + p + } + // Identifier must not begin with digit: insert _. + if r, _ := utf8.DecodeRuneInString(p); unicode.IsDigit(r) { + p = "_" + p + } + return p +} + +// SetPackageNames sets the package name for this run. +// The package name must agree across all files being generated. +// It also defines unique package names for all imported files. +func (g *Generator) SetPackageNames() { + // Register the name for this package. It will be the first name + // registered so is guaranteed to be unmodified. + pkg, explicit := g.genFiles[0].goPackageName() + + // Check all files for an explicit go_package option. + for _, f := range g.genFiles { + thisPkg, thisExplicit := f.goPackageName() + if thisExplicit { + if !explicit { + // Let this file's go_package option serve for all input files. + pkg, explicit = thisPkg, true + } else if thisPkg != pkg { + g.Fail("inconsistent package names:", thisPkg, pkg) + } + } + } + + // If we don't have an explicit go_package option but we have an + // import path, use that. + if !explicit { + p := g.defaultGoPackage() + if p != "" { + pkg, explicit = p, true + } + } + + // If there was no go_package and no import path to use, + // double-check that all the inputs have the same implicit + // Go package name. + if !explicit { + for _, f := range g.genFiles { + thisPkg, _ := f.goPackageName() + if thisPkg != pkg { + g.Fail("inconsistent package names:", thisPkg, pkg) + } + } + } + + g.packageName = RegisterUniquePackageName(pkg, g.genFiles[0]) + + // Register the support package names. They might collide with the + // name of a package we import. + g.Pkg = map[string]string{ + "fmt": RegisterUniquePackageName("fmt", nil), + "math": RegisterUniquePackageName("math", nil), + "proto": RegisterUniquePackageName("proto", nil), + } + +AllFiles: + for _, f := range g.allFiles { + for _, genf := range g.genFiles { + if f == genf { + // In this package already. + uniquePackageName[f.FileDescriptorProto] = g.packageName + continue AllFiles + } + } + // The file is a dependency, so we want to ignore its go_package option + // because that is only relevant for its specific generated output. + pkg := f.GetPackage() + if pkg == "" { + pkg = baseName(*f.Name) + } + RegisterUniquePackageName(pkg, f) + } +} + +// WrapTypes walks the incoming data, wrapping DescriptorProtos, EnumDescriptorProtos +// and FileDescriptorProtos into file-referenced objects within the Generator. +// It also creates the list of files to generate and so should be called before GenerateAllFiles. +func (g *Generator) WrapTypes() { + g.allFiles = make([]*FileDescriptor, len(g.Request.ProtoFile)) + g.allFilesByName = make(map[string]*FileDescriptor, len(g.allFiles)) + for i, f := range g.Request.ProtoFile { + // We must wrap the descriptors before we wrap the enums + descs := wrapDescriptors(f) + g.buildNestedDescriptors(descs) + enums := wrapEnumDescriptors(f, descs) + g.buildNestedEnums(descs, enums) + exts := wrapExtensions(f) + fd := &FileDescriptor{ + FileDescriptorProto: f, + desc: descs, + enum: enums, + ext: exts, + exported: make(map[Object][]symbol), + proto3: fileIsProto3(f), + } + extractComments(fd) + g.allFiles[i] = fd + g.allFilesByName[f.GetName()] = fd + } + for _, fd := range g.allFiles { + fd.imp = wrapImported(fd.FileDescriptorProto, g) + } + + g.genFiles = make([]*FileDescriptor, len(g.Request.FileToGenerate)) + for i, fileName := range g.Request.FileToGenerate { + g.genFiles[i] = g.allFilesByName[fileName] + if g.genFiles[i] == nil { + g.Fail("could not find file named", fileName) + } + g.genFiles[i].index = i + } + g.Response.File = make([]*plugin.CodeGeneratorResponse_File, len(g.genFiles)) +} + +// Scan the descriptors in this file. For each one, build the slice of nested descriptors +func (g *Generator) buildNestedDescriptors(descs []*Descriptor) { + for _, desc := range descs { + if len(desc.NestedType) != 0 { + for _, nest := range descs { + if nest.parent == desc { + desc.nested = append(desc.nested, nest) + } + } + if len(desc.nested) != len(desc.NestedType) { + g.Fail("internal error: nesting failure for", desc.GetName()) + } + } + } +} + +func (g *Generator) buildNestedEnums(descs []*Descriptor, enums []*EnumDescriptor) { + for _, desc := range descs { + if len(desc.EnumType) != 0 { + for _, enum := range enums { + if enum.parent == desc { + desc.enums = append(desc.enums, enum) + } + } + if len(desc.enums) != len(desc.EnumType) { + g.Fail("internal error: enum nesting failure for", desc.GetName()) + } + } + } +} + +// Construct the Descriptor +func newDescriptor(desc *descriptor.DescriptorProto, parent *Descriptor, file *descriptor.FileDescriptorProto, index int) *Descriptor { + d := &Descriptor{ + common: common{file}, + DescriptorProto: desc, + parent: parent, + index: index, + } + if parent == nil { + d.path = fmt.Sprintf("%d,%d", messagePath, index) + } else { + d.path = fmt.Sprintf("%s,%d,%d", parent.path, messageMessagePath, index) + } + + // The only way to distinguish a group from a message is whether + // the containing message has a TYPE_GROUP field that matches. + if parent != nil { + parts := d.TypeName() + if file.Package != nil { + parts = append([]string{*file.Package}, parts...) + } + exp := "." + strings.Join(parts, ".") + for _, field := range parent.Field { + if field.GetType() == descriptor.FieldDescriptorProto_TYPE_GROUP && field.GetTypeName() == exp { + d.group = true + break + } + } + } + + d.ext = make([]*ExtensionDescriptor, len(desc.Extension)) + for i, field := range desc.Extension { + d.ext[i] = &ExtensionDescriptor{common{file}, field, d} + } + + return d +} + +// Return a slice of all the Descriptors defined within this file +func wrapDescriptors(file *descriptor.FileDescriptorProto) []*Descriptor { + sl := make([]*Descriptor, 0, len(file.MessageType)+10) + for i, desc := range file.MessageType { + sl = wrapThisDescriptor(sl, desc, nil, file, i) + } + return sl +} + +// Wrap this Descriptor, recursively +func wrapThisDescriptor(sl []*Descriptor, desc *descriptor.DescriptorProto, parent *Descriptor, file *descriptor.FileDescriptorProto, index int) []*Descriptor { + sl = append(sl, newDescriptor(desc, parent, file, index)) + me := sl[len(sl)-1] + for i, nested := range desc.NestedType { + sl = wrapThisDescriptor(sl, nested, me, file, i) + } + return sl +} + +// Construct the EnumDescriptor +func newEnumDescriptor(desc *descriptor.EnumDescriptorProto, parent *Descriptor, file *descriptor.FileDescriptorProto, index int) *EnumDescriptor { + ed := &EnumDescriptor{ + common: common{file}, + EnumDescriptorProto: desc, + parent: parent, + index: index, + } + if parent == nil { + ed.path = fmt.Sprintf("%d,%d", enumPath, index) + } else { + ed.path = fmt.Sprintf("%s,%d,%d", parent.path, messageEnumPath, index) + } + return ed +} + +// Return a slice of all the EnumDescriptors defined within this file +func wrapEnumDescriptors(file *descriptor.FileDescriptorProto, descs []*Descriptor) []*EnumDescriptor { + sl := make([]*EnumDescriptor, 0, len(file.EnumType)+10) + // Top-level enums. + for i, enum := range file.EnumType { + sl = append(sl, newEnumDescriptor(enum, nil, file, i)) + } + // Enums within messages. Enums within embedded messages appear in the outer-most message. + for _, nested := range descs { + for i, enum := range nested.EnumType { + sl = append(sl, newEnumDescriptor(enum, nested, file, i)) + } + } + return sl +} + +// Return a slice of all the top-level ExtensionDescriptors defined within this file. +func wrapExtensions(file *descriptor.FileDescriptorProto) []*ExtensionDescriptor { + sl := make([]*ExtensionDescriptor, len(file.Extension)) + for i, field := range file.Extension { + sl[i] = &ExtensionDescriptor{common{file}, field, nil} + } + return sl +} + +// Return a slice of all the types that are publicly imported into this file. +func wrapImported(file *descriptor.FileDescriptorProto, g *Generator) (sl []*ImportedDescriptor) { + for _, index := range file.PublicDependency { + df := g.fileByName(file.Dependency[index]) + for _, d := range df.desc { + if d.GetOptions().GetMapEntry() { + continue + } + sl = append(sl, &ImportedDescriptor{common{file}, d}) + } + for _, e := range df.enum { + sl = append(sl, &ImportedDescriptor{common{file}, e}) + } + for _, ext := range df.ext { + sl = append(sl, &ImportedDescriptor{common{file}, ext}) + } + } + return +} + +func extractComments(file *FileDescriptor) { + file.comments = make(map[string]*descriptor.SourceCodeInfo_Location) + for _, loc := range file.GetSourceCodeInfo().GetLocation() { + if loc.LeadingComments == nil { + continue + } + var p []string + for _, n := range loc.Path { + p = append(p, strconv.Itoa(int(n))) + } + file.comments[strings.Join(p, ",")] = loc + } +} + +// BuildTypeNameMap builds the map from fully qualified type names to objects. +// The key names for the map come from the input data, which puts a period at the beginning. +// It should be called after SetPackageNames and before GenerateAllFiles. +func (g *Generator) BuildTypeNameMap() { + g.typeNameToObject = make(map[string]Object) + for _, f := range g.allFiles { + // The names in this loop are defined by the proto world, not us, so the + // package name may be empty. If so, the dotted package name of X will + // be ".X"; otherwise it will be ".pkg.X". + dottedPkg := "." + f.GetPackage() + if dottedPkg != "." { + dottedPkg += "." + } + for _, enum := range f.enum { + name := dottedPkg + dottedSlice(enum.TypeName()) + g.typeNameToObject[name] = enum + } + for _, desc := range f.desc { + name := dottedPkg + dottedSlice(desc.TypeName()) + g.typeNameToObject[name] = desc + } + } +} + +// ObjectNamed, given a fully-qualified input type name as it appears in the input data, +// returns the descriptor for the message or enum with that name. +func (g *Generator) ObjectNamed(typeName string) Object { + o, ok := g.typeNameToObject[typeName] + if !ok { + g.Fail("can't find object with type", typeName) + } + + // If the file of this object isn't a direct dependency of the current file, + // or in the current file, then this object has been publicly imported into + // a dependency of the current file. + // We should return the ImportedDescriptor object for it instead. + direct := *o.File().Name == *g.file.Name + if !direct { + for _, dep := range g.file.Dependency { + if *g.fileByName(dep).Name == *o.File().Name { + direct = true + break + } + } + } + if !direct { + found := false + Loop: + for _, dep := range g.file.Dependency { + df := g.fileByName(*g.fileByName(dep).Name) + for _, td := range df.imp { + if td.o == o { + // Found it! + o = td + found = true + break Loop + } + } + } + if !found { + log.Printf("protoc-gen-go: WARNING: failed finding publicly imported dependency for %v, used in %v", typeName, *g.file.Name) + } + } + + return o +} + +// P prints the arguments to the generated output. It handles strings and int32s, plus +// handling indirections because they may be *string, etc. +func (g *Generator) P(str ...interface{}) { + if !g.writeOutput { + return + } + g.WriteString(g.indent) + for _, v := range str { + switch s := v.(type) { + case string: + g.WriteString(s) + case *string: + g.WriteString(*s) + case bool: + fmt.Fprintf(g, "%t", s) + case *bool: + fmt.Fprintf(g, "%t", *s) + case int: + fmt.Fprintf(g, "%d", s) + case *int32: + fmt.Fprintf(g, "%d", *s) + case *int64: + fmt.Fprintf(g, "%d", *s) + case float64: + fmt.Fprintf(g, "%g", s) + case *float64: + fmt.Fprintf(g, "%g", *s) + default: + g.Fail(fmt.Sprintf("unknown type in printer: %T", v)) + } + } + g.WriteByte('\n') +} + +// addInitf stores the given statement to be printed inside the file's init function. +// The statement is given as a format specifier and arguments. +func (g *Generator) addInitf(stmt string, a ...interface{}) { + g.init = append(g.init, fmt.Sprintf(stmt, a...)) +} + +// In Indents the output one tab stop. +func (g *Generator) In() { g.indent += "\t" } + +// Out unindents the output one tab stop. +func (g *Generator) Out() { + if len(g.indent) > 0 { + g.indent = g.indent[1:] + } +} + +// GenerateAllFiles generates the output for all the files we're outputting. +func (g *Generator) GenerateAllFiles() { + // Initialize the plugins + for _, p := range plugins { + p.Init(g) + } + // Generate the output. The generator runs for every file, even the files + // that we don't generate output for, so that we can collate the full list + // of exported symbols to support public imports. + genFileMap := make(map[*FileDescriptor]bool, len(g.genFiles)) + for _, file := range g.genFiles { + genFileMap[file] = true + } + i := 0 + for _, file := range g.allFiles { + g.Reset() + g.writeOutput = genFileMap[file] + g.generate(file) + if !g.writeOutput { + continue + } + g.Response.File[i] = new(plugin.CodeGeneratorResponse_File) + g.Response.File[i].Name = proto.String(goFileName(*file.Name)) + g.Response.File[i].Content = proto.String(g.String()) + i++ + } +} + +// Run all the plugins associated with the file. +func (g *Generator) runPlugins(file *FileDescriptor) { + for _, p := range plugins { + p.Generate(file) + } +} + +// FileOf return the FileDescriptor for this FileDescriptorProto. +func (g *Generator) FileOf(fd *descriptor.FileDescriptorProto) *FileDescriptor { + for _, file := range g.allFiles { + if file.FileDescriptorProto == fd { + return file + } + } + g.Fail("could not find file in table:", fd.GetName()) + return nil +} + +// Fill the response protocol buffer with the generated output for all the files we're +// supposed to generate. +func (g *Generator) generate(file *FileDescriptor) { + g.file = g.FileOf(file.FileDescriptorProto) + g.usedPackages = make(map[string]bool) + + if g.file.index == 0 { + // For one file in the package, assert version compatibility. + g.P("// This is a compile-time assertion to ensure that this generated file") + g.P("// is compatible with the proto package it is being compiled against.") + g.P("const _ = ", g.Pkg["proto"], ".ProtoPackageIsVersion", generatedCodeVersion) + g.P() + } + + for _, td := range g.file.imp { + g.generateImported(td) + } + for _, enum := range g.file.enum { + g.generateEnum(enum) + } + for _, desc := range g.file.desc { + // Don't generate virtual messages for maps. + if desc.GetOptions().GetMapEntry() { + continue + } + g.generateMessage(desc) + } + for _, ext := range g.file.ext { + g.generateExtension(ext) + } + g.generateInitFunction() + + // Run the plugins before the imports so we know which imports are necessary. + g.runPlugins(file) + + g.generateFileDescriptor(file) + + // Generate header and imports last, though they appear first in the output. + rem := g.Buffer + g.Buffer = new(bytes.Buffer) + g.generateHeader() + g.generateImports() + if !g.writeOutput { + return + } + g.Write(rem.Bytes()) + + // Reformat generated code. + fset := token.NewFileSet() + raw := g.Bytes() + ast, err := parser.ParseFile(fset, "", g, parser.ParseComments) + if err != nil { + // Print out the bad code with line numbers. + // This should never happen in practice, but it can while changing generated code, + // so consider this a debugging aid. + var src bytes.Buffer + s := bufio.NewScanner(bytes.NewReader(raw)) + for line := 1; s.Scan(); line++ { + fmt.Fprintf(&src, "%5d\t%s\n", line, s.Bytes()) + } + g.Fail("bad Go source code was generated:", err.Error(), "\n"+src.String()) + } + g.Reset() + err = (&printer.Config{Mode: printer.TabIndent | printer.UseSpaces, Tabwidth: 8}).Fprint(g, fset, ast) + if err != nil { + g.Fail("generated Go source code could not be reformatted:", err.Error()) + } +} + +// Generate the header, including package definition +func (g *Generator) generateHeader() { + g.P("// Code generated by protoc-gen-go.") + g.P("// source: ", g.file.Name) + g.P("// DO NOT EDIT!") + g.P() + + name := g.file.PackageName() + + if g.file.index == 0 { + // Generate package docs for the first file in the package. + g.P("/*") + g.P("Package ", name, " is a generated protocol buffer package.") + g.P() + if loc, ok := g.file.comments[strconv.Itoa(packagePath)]; ok { + // not using g.PrintComments because this is a /* */ comment block. + text := strings.TrimSuffix(loc.GetLeadingComments(), "\n") + for _, line := range strings.Split(text, "\n") { + line = strings.TrimPrefix(line, " ") + // ensure we don't escape from the block comment + line = strings.Replace(line, "*/", "* /", -1) + g.P(line) + } + g.P() + } + var topMsgs []string + g.P("It is generated from these files:") + for _, f := range g.genFiles { + g.P("\t", f.Name) + for _, msg := range f.desc { + if msg.parent != nil { + continue + } + topMsgs = append(topMsgs, CamelCaseSlice(msg.TypeName())) + } + } + g.P() + g.P("It has these top-level messages:") + for _, msg := range topMsgs { + g.P("\t", msg) + } + g.P("*/") + } + + g.P("package ", name) + g.P() +} + +// PrintComments prints any comments from the source .proto file. +// The path is a comma-separated list of integers. +// It returns an indication of whether any comments were printed. +// See descriptor.proto for its format. +func (g *Generator) PrintComments(path string) bool { + if !g.writeOutput { + return false + } + if loc, ok := g.file.comments[path]; ok { + text := strings.TrimSuffix(loc.GetLeadingComments(), "\n") + for _, line := range strings.Split(text, "\n") { + g.P("// ", strings.TrimPrefix(line, " ")) + } + return true + } + return false +} + +func (g *Generator) fileByName(filename string) *FileDescriptor { + return g.allFilesByName[filename] +} + +// weak returns whether the ith import of the current file is a weak import. +func (g *Generator) weak(i int32) bool { + for _, j := range g.file.WeakDependency { + if j == i { + return true + } + } + return false +} + +// Generate the imports +func (g *Generator) generateImports() { + // We almost always need a proto import. Rather than computing when we + // do, which is tricky when there's a plugin, just import it and + // reference it later. The same argument applies to the fmt and math packages. + g.P("import " + g.Pkg["proto"] + " " + strconv.Quote(g.ImportPrefix+"github.com/golang/protobuf/proto")) + g.P("import " + g.Pkg["fmt"] + ` "fmt"`) + g.P("import " + g.Pkg["math"] + ` "math"`) + for i, s := range g.file.Dependency { + fd := g.fileByName(s) + // Do not import our own package. + if fd.PackageName() == g.packageName { + continue + } + filename := goFileName(s) + // By default, import path is the dirname of the Go filename. + importPath := path.Dir(filename) + if substitution, ok := g.ImportMap[s]; ok { + importPath = substitution + } + importPath = g.ImportPrefix + importPath + // Skip weak imports. + if g.weak(int32(i)) { + g.P("// skipping weak import ", fd.PackageName(), " ", strconv.Quote(importPath)) + continue + } + // We need to import all the dependencies, even if we don't reference them, + // because other code and tools depend on having the full transitive closure + // of protocol buffer types in the binary. + pname := fd.PackageName() + if _, ok := g.usedPackages[pname]; !ok { + pname = "_" + } + g.P("import ", pname, " ", strconv.Quote(importPath)) + } + g.P() + // TODO: may need to worry about uniqueness across plugins + for _, p := range plugins { + p.GenerateImports(g.file) + g.P() + } + g.P("// Reference imports to suppress errors if they are not otherwise used.") + g.P("var _ = ", g.Pkg["proto"], ".Marshal") + g.P("var _ = ", g.Pkg["fmt"], ".Errorf") + g.P("var _ = ", g.Pkg["math"], ".Inf") + g.P() +} + +func (g *Generator) generateImported(id *ImportedDescriptor) { + // Don't generate public import symbols for files that we are generating + // code for, since those symbols will already be in this package. + // We can't simply avoid creating the ImportedDescriptor objects, + // because g.genFiles isn't populated at that stage. + tn := id.TypeName() + sn := tn[len(tn)-1] + df := g.FileOf(id.o.File()) + filename := *df.Name + for _, fd := range g.genFiles { + if *fd.Name == filename { + g.P("// Ignoring public import of ", sn, " from ", filename) + g.P() + return + } + } + g.P("// ", sn, " from public import ", filename) + g.usedPackages[df.PackageName()] = true + + for _, sym := range df.exported[id.o] { + sym.GenerateAlias(g, df.PackageName()) + } + + g.P() +} + +// Generate the enum definitions for this EnumDescriptor. +func (g *Generator) generateEnum(enum *EnumDescriptor) { + // The full type name + typeName := enum.TypeName() + // The full type name, CamelCased. + ccTypeName := CamelCaseSlice(typeName) + ccPrefix := enum.prefix() + + g.PrintComments(enum.path) + g.P("type ", ccTypeName, " int32") + g.file.addExport(enum, enumSymbol{ccTypeName, enum.proto3()}) + g.P("const (") + g.In() + for i, e := range enum.Value { + g.PrintComments(fmt.Sprintf("%s,%d,%d", enum.path, enumValuePath, i)) + + name := ccPrefix + *e.Name + g.P(name, " ", ccTypeName, " = ", e.Number) + g.file.addExport(enum, constOrVarSymbol{name, "const", ccTypeName}) + } + g.Out() + g.P(")") + g.P("var ", ccTypeName, "_name = map[int32]string{") + g.In() + generated := make(map[int32]bool) // avoid duplicate values + for _, e := range enum.Value { + duplicate := "" + if _, present := generated[*e.Number]; present { + duplicate = "// Duplicate value: " + } + g.P(duplicate, e.Number, ": ", strconv.Quote(*e.Name), ",") + generated[*e.Number] = true + } + g.Out() + g.P("}") + g.P("var ", ccTypeName, "_value = map[string]int32{") + g.In() + for _, e := range enum.Value { + g.P(strconv.Quote(*e.Name), ": ", e.Number, ",") + } + g.Out() + g.P("}") + + if !enum.proto3() { + g.P("func (x ", ccTypeName, ") Enum() *", ccTypeName, " {") + g.In() + g.P("p := new(", ccTypeName, ")") + g.P("*p = x") + g.P("return p") + g.Out() + g.P("}") + } + + g.P("func (x ", ccTypeName, ") String() string {") + g.In() + g.P("return ", g.Pkg["proto"], ".EnumName(", ccTypeName, "_name, int32(x))") + g.Out() + g.P("}") + + if !enum.proto3() { + g.P("func (x *", ccTypeName, ") UnmarshalJSON(data []byte) error {") + g.In() + g.P("value, err := ", g.Pkg["proto"], ".UnmarshalJSONEnum(", ccTypeName, `_value, data, "`, ccTypeName, `")`) + g.P("if err != nil {") + g.In() + g.P("return err") + g.Out() + g.P("}") + g.P("*x = ", ccTypeName, "(value)") + g.P("return nil") + g.Out() + g.P("}") + } + + var indexes []string + for m := enum.parent; m != nil; m = m.parent { + // XXX: skip groups? + indexes = append([]string{strconv.Itoa(m.index)}, indexes...) + } + indexes = append(indexes, strconv.Itoa(enum.index)) + g.P("func (", ccTypeName, ") EnumDescriptor() ([]byte, []int) { return fileDescriptor", g.file.index, ", []int{", strings.Join(indexes, ", "), "} }") + + g.P() +} + +// The tag is a string like "varint,2,opt,name=fieldname,def=7" that +// identifies details of the field for the protocol buffer marshaling and unmarshaling +// code. The fields are: +// wire encoding +// protocol tag number +// opt,req,rep for optional, required, or repeated +// packed whether the encoding is "packed" (optional; repeated primitives only) +// name= the original declared name +// enum= the name of the enum type if it is an enum-typed field. +// proto3 if this field is in a proto3 message +// def= string representation of the default value, if any. +// The default value must be in a representation that can be used at run-time +// to generate the default value. Thus bools become 0 and 1, for instance. +func (g *Generator) goTag(message *Descriptor, field *descriptor.FieldDescriptorProto, wiretype string) string { + optrepreq := "" + switch { + case isOptional(field): + optrepreq = "opt" + case isRequired(field): + optrepreq = "req" + case isRepeated(field): + optrepreq = "rep" + } + var defaultValue string + if dv := field.DefaultValue; dv != nil { // set means an explicit default + defaultValue = *dv + // Some types need tweaking. + switch *field.Type { + case descriptor.FieldDescriptorProto_TYPE_BOOL: + if defaultValue == "true" { + defaultValue = "1" + } else { + defaultValue = "0" + } + case descriptor.FieldDescriptorProto_TYPE_STRING, + descriptor.FieldDescriptorProto_TYPE_BYTES: + // Nothing to do. Quoting is done for the whole tag. + case descriptor.FieldDescriptorProto_TYPE_ENUM: + // For enums we need to provide the integer constant. + obj := g.ObjectNamed(field.GetTypeName()) + if id, ok := obj.(*ImportedDescriptor); ok { + // It is an enum that was publicly imported. + // We need the underlying type. + obj = id.o + } + enum, ok := obj.(*EnumDescriptor) + if !ok { + log.Printf("obj is a %T", obj) + if id, ok := obj.(*ImportedDescriptor); ok { + log.Printf("id.o is a %T", id.o) + } + g.Fail("unknown enum type", CamelCaseSlice(obj.TypeName())) + } + defaultValue = enum.integerValueAsString(defaultValue) + } + defaultValue = ",def=" + defaultValue + } + enum := "" + if *field.Type == descriptor.FieldDescriptorProto_TYPE_ENUM { + // We avoid using obj.PackageName(), because we want to use the + // original (proto-world) package name. + obj := g.ObjectNamed(field.GetTypeName()) + if id, ok := obj.(*ImportedDescriptor); ok { + obj = id.o + } + enum = ",enum=" + if pkg := obj.File().GetPackage(); pkg != "" { + enum += pkg + "." + } + enum += CamelCaseSlice(obj.TypeName()) + } + packed := "" + if field.Options != nil && field.Options.GetPacked() { + packed = ",packed" + } + fieldName := field.GetName() + name := fieldName + if *field.Type == descriptor.FieldDescriptorProto_TYPE_GROUP { + // We must use the type name for groups instead of + // the field name to preserve capitalization. + // type_name in FieldDescriptorProto is fully-qualified, + // but we only want the local part. + name = *field.TypeName + if i := strings.LastIndex(name, "."); i >= 0 { + name = name[i+1:] + } + } + name = ",name=" + name + if message.proto3() { + // We only need the extra tag for []byte fields; + // no need to add noise for the others. + if *field.Type == descriptor.FieldDescriptorProto_TYPE_BYTES { + name += ",proto3" + } + + } + oneof := "" + if field.OneofIndex != nil { + oneof = ",oneof" + } + return strconv.Quote(fmt.Sprintf("%s,%d,%s%s%s%s%s%s", + wiretype, + field.GetNumber(), + optrepreq, + packed, + name, + enum, + oneof, + defaultValue)) +} + +func needsStar(typ descriptor.FieldDescriptorProto_Type) bool { + switch typ { + case descriptor.FieldDescriptorProto_TYPE_GROUP: + return false + case descriptor.FieldDescriptorProto_TYPE_MESSAGE: + return false + case descriptor.FieldDescriptorProto_TYPE_BYTES: + return false + } + return true +} + +// TypeName is the printed name appropriate for an item. If the object is in the current file, +// TypeName drops the package name and underscores the rest. +// Otherwise the object is from another package; and the result is the underscored +// package name followed by the item name. +// The result always has an initial capital. +func (g *Generator) TypeName(obj Object) string { + return g.DefaultPackageName(obj) + CamelCaseSlice(obj.TypeName()) +} + +// TypeNameWithPackage is like TypeName, but always includes the package +// name even if the object is in our own package. +func (g *Generator) TypeNameWithPackage(obj Object) string { + return obj.PackageName() + CamelCaseSlice(obj.TypeName()) +} + +// GoType returns a string representing the type name, and the wire type +func (g *Generator) GoType(message *Descriptor, field *descriptor.FieldDescriptorProto) (typ string, wire string) { + // TODO: Options. + switch *field.Type { + case descriptor.FieldDescriptorProto_TYPE_DOUBLE: + typ, wire = "float64", "fixed64" + case descriptor.FieldDescriptorProto_TYPE_FLOAT: + typ, wire = "float32", "fixed32" + case descriptor.FieldDescriptorProto_TYPE_INT64: + typ, wire = "int64", "varint" + case descriptor.FieldDescriptorProto_TYPE_UINT64: + typ, wire = "uint64", "varint" + case descriptor.FieldDescriptorProto_TYPE_INT32: + typ, wire = "int32", "varint" + case descriptor.FieldDescriptorProto_TYPE_UINT32: + typ, wire = "uint32", "varint" + case descriptor.FieldDescriptorProto_TYPE_FIXED64: + typ, wire = "uint64", "fixed64" + case descriptor.FieldDescriptorProto_TYPE_FIXED32: + typ, wire = "uint32", "fixed32" + case descriptor.FieldDescriptorProto_TYPE_BOOL: + typ, wire = "bool", "varint" + case descriptor.FieldDescriptorProto_TYPE_STRING: + typ, wire = "string", "bytes" + case descriptor.FieldDescriptorProto_TYPE_GROUP: + desc := g.ObjectNamed(field.GetTypeName()) + typ, wire = "*"+g.TypeName(desc), "group" + case descriptor.FieldDescriptorProto_TYPE_MESSAGE: + desc := g.ObjectNamed(field.GetTypeName()) + typ, wire = "*"+g.TypeName(desc), "bytes" + case descriptor.FieldDescriptorProto_TYPE_BYTES: + typ, wire = "[]byte", "bytes" + case descriptor.FieldDescriptorProto_TYPE_ENUM: + desc := g.ObjectNamed(field.GetTypeName()) + typ, wire = g.TypeName(desc), "varint" + case descriptor.FieldDescriptorProto_TYPE_SFIXED32: + typ, wire = "int32", "fixed32" + case descriptor.FieldDescriptorProto_TYPE_SFIXED64: + typ, wire = "int64", "fixed64" + case descriptor.FieldDescriptorProto_TYPE_SINT32: + typ, wire = "int32", "zigzag32" + case descriptor.FieldDescriptorProto_TYPE_SINT64: + typ, wire = "int64", "zigzag64" + default: + g.Fail("unknown type for", field.GetName()) + } + if isRepeated(field) { + typ = "[]" + typ + } else if message != nil && message.proto3() { + return + } else if field.OneofIndex != nil && message != nil { + return + } else if needsStar(*field.Type) { + typ = "*" + typ + } + return +} + +func (g *Generator) RecordTypeUse(t string) { + if obj, ok := g.typeNameToObject[t]; ok { + // Call ObjectNamed to get the true object to record the use. + obj = g.ObjectNamed(t) + g.usedPackages[obj.PackageName()] = true + } +} + +// Method names that may be generated. Fields with these names get an +// underscore appended. +var methodNames = [...]string{ + "Reset", + "String", + "ProtoMessage", + "Marshal", + "Unmarshal", + "ExtensionRangeArray", + "ExtensionMap", + "Descriptor", +} + +// Generate the type and default constant definitions for this Descriptor. +func (g *Generator) generateMessage(message *Descriptor) { + // The full type name + typeName := message.TypeName() + // The full type name, CamelCased. + ccTypeName := CamelCaseSlice(typeName) + + usedNames := make(map[string]bool) + for _, n := range methodNames { + usedNames[n] = true + } + fieldNames := make(map[*descriptor.FieldDescriptorProto]string) + fieldGetterNames := make(map[*descriptor.FieldDescriptorProto]string) + fieldTypes := make(map[*descriptor.FieldDescriptorProto]string) + mapFieldTypes := make(map[*descriptor.FieldDescriptorProto]string) + + oneofFieldName := make(map[int32]string) // indexed by oneof_index field of FieldDescriptorProto + oneofDisc := make(map[int32]string) // name of discriminator method + oneofTypeName := make(map[*descriptor.FieldDescriptorProto]string) // without star + oneofInsertPoints := make(map[int32]int) // oneof_index => offset of g.Buffer + + g.PrintComments(message.path) + g.P("type ", ccTypeName, " struct {") + g.In() + + // allocNames finds a conflict-free variation of the given strings, + // consistently mutating their suffixes. + // It returns the same number of strings. + allocNames := func(ns ...string) []string { + Loop: + for { + for _, n := range ns { + if usedNames[n] { + for i := range ns { + ns[i] += "_" + } + continue Loop + } + } + for _, n := range ns { + usedNames[n] = true + } + return ns + } + } + + for i, field := range message.Field { + // Allocate the getter and the field at the same time so name + // collisions create field/method consistent names. + // TODO: This allocation occurs based on the order of the fields + // in the proto file, meaning that a change in the field + // ordering can change generated Method/Field names. + base := CamelCase(*field.Name) + ns := allocNames(base, "Get"+base) + fieldName, fieldGetterName := ns[0], ns[1] + typename, wiretype := g.GoType(message, field) + jsonName := *field.Name + tag := fmt.Sprintf("protobuf:%s json:%q", g.goTag(message, field, wiretype), jsonName+",omitempty") + + fieldNames[field] = fieldName + fieldGetterNames[field] = fieldGetterName + + oneof := field.OneofIndex != nil + if oneof && oneofFieldName[*field.OneofIndex] == "" { + odp := message.OneofDecl[int(*field.OneofIndex)] + fname := allocNames(CamelCase(odp.GetName()))[0] + + // This is the first field of a oneof we haven't seen before. + // Generate the union field. + com := g.PrintComments(fmt.Sprintf("%s,%d,%d", message.path, messageOneofPath, *field.OneofIndex)) + if com { + g.P("//") + } + g.P("// Types that are valid to be assigned to ", fname, ":") + // Generate the rest of this comment later, + // when we've computed any disambiguation. + oneofInsertPoints[*field.OneofIndex] = g.Buffer.Len() + + dname := "is" + ccTypeName + "_" + fname + oneofFieldName[*field.OneofIndex] = fname + oneofDisc[*field.OneofIndex] = dname + tag := `protobuf_oneof:"` + odp.GetName() + `"` + g.P(fname, " ", dname, " `", tag, "`") + } + + if *field.Type == descriptor.FieldDescriptorProto_TYPE_MESSAGE { + desc := g.ObjectNamed(field.GetTypeName()) + if d, ok := desc.(*Descriptor); ok && d.GetOptions().GetMapEntry() { + // Figure out the Go types and tags for the key and value types. + keyField, valField := d.Field[0], d.Field[1] + keyType, keyWire := g.GoType(d, keyField) + valType, valWire := g.GoType(d, valField) + keyTag, valTag := g.goTag(d, keyField, keyWire), g.goTag(d, valField, valWire) + + // We don't use stars, except for message-typed values. + // Message and enum types are the only two possibly foreign types used in maps, + // so record their use. They are not permitted as map keys. + keyType = strings.TrimPrefix(keyType, "*") + switch *valField.Type { + case descriptor.FieldDescriptorProto_TYPE_ENUM: + valType = strings.TrimPrefix(valType, "*") + g.RecordTypeUse(valField.GetTypeName()) + case descriptor.FieldDescriptorProto_TYPE_MESSAGE: + g.RecordTypeUse(valField.GetTypeName()) + default: + valType = strings.TrimPrefix(valType, "*") + } + + typename = fmt.Sprintf("map[%s]%s", keyType, valType) + mapFieldTypes[field] = typename // record for the getter generation + + tag += fmt.Sprintf(" protobuf_key:%s protobuf_val:%s", keyTag, valTag) + } + } + + fieldTypes[field] = typename + + if oneof { + tname := ccTypeName + "_" + fieldName + // It is possible for this to collide with a message or enum + // nested in this message. Check for collisions. + for { + ok := true + for _, desc := range message.nested { + if CamelCaseSlice(desc.TypeName()) == tname { + ok = false + break + } + } + for _, enum := range message.enums { + if CamelCaseSlice(enum.TypeName()) == tname { + ok = false + break + } + } + if !ok { + tname += "_" + continue + } + break + } + + oneofTypeName[field] = tname + continue + } + + g.PrintComments(fmt.Sprintf("%s,%d,%d", message.path, messageFieldPath, i)) + g.P(fieldName, "\t", typename, "\t`", tag, "`") + g.RecordTypeUse(field.GetTypeName()) + } + if len(message.ExtensionRange) > 0 { + g.P("XXX_extensions\t\tmap[int32]", g.Pkg["proto"], ".Extension `json:\"-\"`") + } + if !message.proto3() { + g.P("XXX_unrecognized\t[]byte `json:\"-\"`") + } + g.Out() + g.P("}") + + // Update g.Buffer to list valid oneof types. + // We do this down here, after we've disambiguated the oneof type names. + // We go in reverse order of insertion point to avoid invalidating offsets. + for oi := int32(len(message.OneofDecl)); oi >= 0; oi-- { + ip := oneofInsertPoints[oi] + all := g.Buffer.Bytes() + rem := all[ip:] + g.Buffer = bytes.NewBuffer(all[:ip:ip]) // set cap so we don't scribble on rem + for _, field := range message.Field { + if field.OneofIndex == nil || *field.OneofIndex != oi { + continue + } + g.P("//\t*", oneofTypeName[field]) + } + g.Buffer.Write(rem) + } + + // Reset, String and ProtoMessage methods. + g.P("func (m *", ccTypeName, ") Reset() { *m = ", ccTypeName, "{} }") + g.P("func (m *", ccTypeName, ") String() string { return ", g.Pkg["proto"], ".CompactTextString(m) }") + g.P("func (*", ccTypeName, ") ProtoMessage() {}") + if !message.group { + var indexes []string + for m := message; m != nil; m = m.parent { + // XXX: skip groups? + indexes = append([]string{strconv.Itoa(m.index)}, indexes...) + } + g.P("func (*", ccTypeName, ") Descriptor() ([]byte, []int) { return fileDescriptor", g.file.index, ", []int{", strings.Join(indexes, ", "), "} }") + } + + // Extension support methods + var hasExtensions, isMessageSet bool + if len(message.ExtensionRange) > 0 { + hasExtensions = true + // message_set_wire_format only makes sense when extensions are defined. + if opts := message.Options; opts != nil && opts.GetMessageSetWireFormat() { + isMessageSet = true + g.P() + g.P("func (m *", ccTypeName, ") Marshal() ([]byte, error) {") + g.In() + g.P("return ", g.Pkg["proto"], ".MarshalMessageSet(m.ExtensionMap())") + g.Out() + g.P("}") + g.P("func (m *", ccTypeName, ") Unmarshal(buf []byte) error {") + g.In() + g.P("return ", g.Pkg["proto"], ".UnmarshalMessageSet(buf, m.ExtensionMap())") + g.Out() + g.P("}") + g.P("func (m *", ccTypeName, ") MarshalJSON() ([]byte, error) {") + g.In() + g.P("return ", g.Pkg["proto"], ".MarshalMessageSetJSON(m.XXX_extensions)") + g.Out() + g.P("}") + g.P("func (m *", ccTypeName, ") UnmarshalJSON(buf []byte) error {") + g.In() + g.P("return ", g.Pkg["proto"], ".UnmarshalMessageSetJSON(buf, m.XXX_extensions)") + g.Out() + g.P("}") + g.P("// ensure ", ccTypeName, " satisfies proto.Marshaler and proto.Unmarshaler") + g.P("var _ ", g.Pkg["proto"], ".Marshaler = (*", ccTypeName, ")(nil)") + g.P("var _ ", g.Pkg["proto"], ".Unmarshaler = (*", ccTypeName, ")(nil)") + } + + g.P() + g.P("var extRange_", ccTypeName, " = []", g.Pkg["proto"], ".ExtensionRange{") + g.In() + for _, r := range message.ExtensionRange { + end := fmt.Sprint(*r.End - 1) // make range inclusive on both ends + g.P("{", r.Start, ", ", end, "},") + } + g.Out() + g.P("}") + g.P("func (*", ccTypeName, ") ExtensionRangeArray() []", g.Pkg["proto"], ".ExtensionRange {") + g.In() + g.P("return extRange_", ccTypeName) + g.Out() + g.P("}") + g.P("func (m *", ccTypeName, ") ExtensionMap() map[int32]", g.Pkg["proto"], ".Extension {") + g.In() + g.P("if m.XXX_extensions == nil {") + g.In() + g.P("m.XXX_extensions = make(map[int32]", g.Pkg["proto"], ".Extension)") + g.Out() + g.P("}") + g.P("return m.XXX_extensions") + g.Out() + g.P("}") + } + + // Default constants + defNames := make(map[*descriptor.FieldDescriptorProto]string) + for _, field := range message.Field { + def := field.GetDefaultValue() + if def == "" { + continue + } + fieldname := "Default_" + ccTypeName + "_" + CamelCase(*field.Name) + defNames[field] = fieldname + typename, _ := g.GoType(message, field) + if typename[0] == '*' { + typename = typename[1:] + } + kind := "const " + switch { + case typename == "bool": + case typename == "string": + def = strconv.Quote(def) + case typename == "[]byte": + def = "[]byte(" + strconv.Quote(def) + ")" + kind = "var " + case def == "inf", def == "-inf", def == "nan": + // These names are known to, and defined by, the protocol language. + switch def { + case "inf": + def = "math.Inf(1)" + case "-inf": + def = "math.Inf(-1)" + case "nan": + def = "math.NaN()" + } + if *field.Type == descriptor.FieldDescriptorProto_TYPE_FLOAT { + def = "float32(" + def + ")" + } + kind = "var " + case *field.Type == descriptor.FieldDescriptorProto_TYPE_ENUM: + // Must be an enum. Need to construct the prefixed name. + obj := g.ObjectNamed(field.GetTypeName()) + var enum *EnumDescriptor + if id, ok := obj.(*ImportedDescriptor); ok { + // The enum type has been publicly imported. + enum, _ = id.o.(*EnumDescriptor) + } else { + enum, _ = obj.(*EnumDescriptor) + } + if enum == nil { + log.Printf("don't know how to generate constant for %s", fieldname) + continue + } + def = g.DefaultPackageName(obj) + enum.prefix() + def + } + g.P(kind, fieldname, " ", typename, " = ", def) + g.file.addExport(message, constOrVarSymbol{fieldname, kind, ""}) + } + g.P() + + // Oneof per-field types, discriminants and getters. + // + // Generate unexported named types for the discriminant interfaces. + // We shouldn't have to do this, but there was (~19 Aug 2015) a compiler/linker bug + // that was triggered by using anonymous interfaces here. + // TODO: Revisit this and consider reverting back to anonymous interfaces. + for oi := range message.OneofDecl { + dname := oneofDisc[int32(oi)] + g.P("type ", dname, " interface { ", dname, "() }") + } + g.P() + for _, field := range message.Field { + if field.OneofIndex == nil { + continue + } + _, wiretype := g.GoType(message, field) + tag := "protobuf:" + g.goTag(message, field, wiretype) + g.P("type ", oneofTypeName[field], " struct{ ", fieldNames[field], " ", fieldTypes[field], " `", tag, "` }") + g.RecordTypeUse(field.GetTypeName()) + } + g.P() + for _, field := range message.Field { + if field.OneofIndex == nil { + continue + } + g.P("func (*", oneofTypeName[field], ") ", oneofDisc[*field.OneofIndex], "() {}") + } + g.P() + for oi := range message.OneofDecl { + fname := oneofFieldName[int32(oi)] + g.P("func (m *", ccTypeName, ") Get", fname, "() ", oneofDisc[int32(oi)], " {") + g.P("if m != nil { return m.", fname, " }") + g.P("return nil") + g.P("}") + } + g.P() + + // Field getters + var getters []getterSymbol + for _, field := range message.Field { + oneof := field.OneofIndex != nil + + fname := fieldNames[field] + typename, _ := g.GoType(message, field) + if t, ok := mapFieldTypes[field]; ok { + typename = t + } + mname := fieldGetterNames[field] + star := "" + if needsStar(*field.Type) && typename[0] == '*' { + typename = typename[1:] + star = "*" + } + + // In proto3, only generate getters for message fields and oneof fields. + if message.proto3() && *field.Type != descriptor.FieldDescriptorProto_TYPE_MESSAGE && !oneof { + continue + } + + // Only export getter symbols for basic types, + // and for messages and enums in the same package. + // Groups are not exported. + // Foreign types can't be hoisted through a public import because + // the importer may not already be importing the defining .proto. + // As an example, imagine we have an import tree like this: + // A.proto -> B.proto -> C.proto + // If A publicly imports B, we need to generate the getters from B in A's output, + // but if one such getter returns something from C then we cannot do that + // because A is not importing C already. + var getter, genType bool + switch *field.Type { + case descriptor.FieldDescriptorProto_TYPE_GROUP: + getter = false + case descriptor.FieldDescriptorProto_TYPE_MESSAGE, descriptor.FieldDescriptorProto_TYPE_ENUM: + // Only export getter if its return type is in this package. + getter = g.ObjectNamed(field.GetTypeName()).PackageName() == message.PackageName() + genType = true + default: + getter = true + } + if getter { + getters = append(getters, getterSymbol{ + name: mname, + typ: typename, + typeName: field.GetTypeName(), + genType: genType, + }) + } + + g.P("func (m *", ccTypeName, ") "+mname+"() "+typename+" {") + g.In() + def, hasDef := defNames[field] + typeDefaultIsNil := false // whether this field type's default value is a literal nil unless specified + switch *field.Type { + case descriptor.FieldDescriptorProto_TYPE_BYTES: + typeDefaultIsNil = !hasDef + case descriptor.FieldDescriptorProto_TYPE_GROUP, descriptor.FieldDescriptorProto_TYPE_MESSAGE: + typeDefaultIsNil = true + } + if isRepeated(field) { + typeDefaultIsNil = true + } + if typeDefaultIsNil && !oneof { + // A bytes field with no explicit default needs less generated code, + // as does a message or group field, or a repeated field. + g.P("if m != nil {") + g.In() + g.P("return m." + fname) + g.Out() + g.P("}") + g.P("return nil") + g.Out() + g.P("}") + g.P() + continue + } + if !oneof { + g.P("if m != nil && m." + fname + " != nil {") + g.In() + g.P("return " + star + "m." + fname) + g.Out() + g.P("}") + } else { + uname := oneofFieldName[*field.OneofIndex] + tname := oneofTypeName[field] + g.P("if x, ok := m.Get", uname, "().(*", tname, "); ok {") + g.P("return x.", fname) + g.P("}") + } + if hasDef { + if *field.Type != descriptor.FieldDescriptorProto_TYPE_BYTES { + g.P("return " + def) + } else { + // The default is a []byte var. + // Make a copy when returning it to be safe. + g.P("return append([]byte(nil), ", def, "...)") + } + } else { + switch *field.Type { + case descriptor.FieldDescriptorProto_TYPE_BOOL: + g.P("return false") + case descriptor.FieldDescriptorProto_TYPE_STRING: + g.P(`return ""`) + case descriptor.FieldDescriptorProto_TYPE_GROUP, + descriptor.FieldDescriptorProto_TYPE_MESSAGE, + descriptor.FieldDescriptorProto_TYPE_BYTES: + // This is only possible for oneof fields. + g.P("return nil") + case descriptor.FieldDescriptorProto_TYPE_ENUM: + // The default default for an enum is the first value in the enum, + // not zero. + obj := g.ObjectNamed(field.GetTypeName()) + var enum *EnumDescriptor + if id, ok := obj.(*ImportedDescriptor); ok { + // The enum type has been publicly imported. + enum, _ = id.o.(*EnumDescriptor) + } else { + enum, _ = obj.(*EnumDescriptor) + } + if enum == nil { + log.Printf("don't know how to generate getter for %s", field.GetName()) + continue + } + if len(enum.Value) == 0 { + g.P("return 0 // empty enum") + } else { + first := enum.Value[0].GetName() + g.P("return ", g.DefaultPackageName(obj)+enum.prefix()+first) + } + default: + g.P("return 0") + } + } + g.Out() + g.P("}") + g.P() + } + + if !message.group { + ms := &messageSymbol{ + sym: ccTypeName, + hasExtensions: hasExtensions, + isMessageSet: isMessageSet, + hasOneof: len(message.OneofDecl) > 0, + getters: getters, + } + g.file.addExport(message, ms) + } + + // Oneof functions + if len(message.OneofDecl) > 0 { + fieldWire := make(map[*descriptor.FieldDescriptorProto]string) + + // method + enc := "_" + ccTypeName + "_OneofMarshaler" + dec := "_" + ccTypeName + "_OneofUnmarshaler" + size := "_" + ccTypeName + "_OneofSizer" + encSig := "(msg " + g.Pkg["proto"] + ".Message, b *" + g.Pkg["proto"] + ".Buffer) error" + decSig := "(msg " + g.Pkg["proto"] + ".Message, tag, wire int, b *" + g.Pkg["proto"] + ".Buffer) (bool, error)" + sizeSig := "(msg " + g.Pkg["proto"] + ".Message) (n int)" + + g.P("// XXX_OneofFuncs is for the internal use of the proto package.") + g.P("func (*", ccTypeName, ") XXX_OneofFuncs() (func", encSig, ", func", decSig, ", func", sizeSig, ", []interface{}) {") + g.P("return ", enc, ", ", dec, ", ", size, ", []interface{}{") + for _, field := range message.Field { + if field.OneofIndex == nil { + continue + } + g.P("(*", oneofTypeName[field], ")(nil),") + } + g.P("}") + g.P("}") + g.P() + + // marshaler + g.P("func ", enc, encSig, " {") + g.P("m := msg.(*", ccTypeName, ")") + for oi, odp := range message.OneofDecl { + g.P("// ", odp.GetName()) + fname := oneofFieldName[int32(oi)] + g.P("switch x := m.", fname, ".(type) {") + for _, field := range message.Field { + if field.OneofIndex == nil || int(*field.OneofIndex) != oi { + continue + } + g.P("case *", oneofTypeName[field], ":") + var wire, pre, post string + val := "x." + fieldNames[field] // overridden for TYPE_BOOL + canFail := false // only TYPE_MESSAGE and TYPE_GROUP can fail + switch *field.Type { + case descriptor.FieldDescriptorProto_TYPE_DOUBLE: + wire = "WireFixed64" + pre = "b.EncodeFixed64(" + g.Pkg["math"] + ".Float64bits(" + post = "))" + case descriptor.FieldDescriptorProto_TYPE_FLOAT: + wire = "WireFixed32" + pre = "b.EncodeFixed32(uint64(" + g.Pkg["math"] + ".Float32bits(" + post = ")))" + case descriptor.FieldDescriptorProto_TYPE_INT64, + descriptor.FieldDescriptorProto_TYPE_UINT64: + wire = "WireVarint" + pre, post = "b.EncodeVarint(uint64(", "))" + case descriptor.FieldDescriptorProto_TYPE_INT32, + descriptor.FieldDescriptorProto_TYPE_UINT32, + descriptor.FieldDescriptorProto_TYPE_ENUM: + wire = "WireVarint" + pre, post = "b.EncodeVarint(uint64(", "))" + case descriptor.FieldDescriptorProto_TYPE_FIXED64, + descriptor.FieldDescriptorProto_TYPE_SFIXED64: + wire = "WireFixed64" + pre, post = "b.EncodeFixed64(uint64(", "))" + case descriptor.FieldDescriptorProto_TYPE_FIXED32, + descriptor.FieldDescriptorProto_TYPE_SFIXED32: + wire = "WireFixed32" + pre, post = "b.EncodeFixed32(uint64(", "))" + case descriptor.FieldDescriptorProto_TYPE_BOOL: + // bool needs special handling. + g.P("t := uint64(0)") + g.P("if ", val, " { t = 1 }") + val = "t" + wire = "WireVarint" + pre, post = "b.EncodeVarint(", ")" + case descriptor.FieldDescriptorProto_TYPE_STRING: + wire = "WireBytes" + pre, post = "b.EncodeStringBytes(", ")" + case descriptor.FieldDescriptorProto_TYPE_GROUP: + wire = "WireStartGroup" + pre, post = "b.Marshal(", ")" + canFail = true + case descriptor.FieldDescriptorProto_TYPE_MESSAGE: + wire = "WireBytes" + pre, post = "b.EncodeMessage(", ")" + canFail = true + case descriptor.FieldDescriptorProto_TYPE_BYTES: + wire = "WireBytes" + pre, post = "b.EncodeRawBytes(", ")" + case descriptor.FieldDescriptorProto_TYPE_SINT32: + wire = "WireVarint" + pre, post = "b.EncodeZigzag32(uint64(", "))" + case descriptor.FieldDescriptorProto_TYPE_SINT64: + wire = "WireVarint" + pre, post = "b.EncodeZigzag64(uint64(", "))" + default: + g.Fail("unhandled oneof field type ", field.Type.String()) + } + fieldWire[field] = wire + g.P("b.EncodeVarint(", field.Number, "<<3|", g.Pkg["proto"], ".", wire, ")") + if !canFail { + g.P(pre, val, post) + } else { + g.P("if err := ", pre, val, post, "; err != nil {") + g.P("return err") + g.P("}") + } + if *field.Type == descriptor.FieldDescriptorProto_TYPE_GROUP { + g.P("b.EncodeVarint(", field.Number, "<<3|", g.Pkg["proto"], ".WireEndGroup)") + } + } + g.P("case nil:") + g.P("default: return ", g.Pkg["fmt"], `.Errorf("`, ccTypeName, ".", fname, ` has unexpected type %T", x)`) + g.P("}") + } + g.P("return nil") + g.P("}") + g.P() + + // unmarshaler + g.P("func ", dec, decSig, " {") + g.P("m := msg.(*", ccTypeName, ")") + g.P("switch tag {") + for _, field := range message.Field { + if field.OneofIndex == nil { + continue + } + odp := message.OneofDecl[int(*field.OneofIndex)] + g.P("case ", field.Number, ": // ", odp.GetName(), ".", *field.Name) + g.P("if wire != ", g.Pkg["proto"], ".", fieldWire[field], " {") + g.P("return true, ", g.Pkg["proto"], ".ErrInternalBadWireType") + g.P("}") + lhs := "x, err" // overridden for TYPE_MESSAGE and TYPE_GROUP + var dec, cast, cast2 string + switch *field.Type { + case descriptor.FieldDescriptorProto_TYPE_DOUBLE: + dec, cast = "b.DecodeFixed64()", g.Pkg["math"]+".Float64frombits" + case descriptor.FieldDescriptorProto_TYPE_FLOAT: + dec, cast, cast2 = "b.DecodeFixed32()", "uint32", g.Pkg["math"]+".Float32frombits" + case descriptor.FieldDescriptorProto_TYPE_INT64: + dec, cast = "b.DecodeVarint()", "int64" + case descriptor.FieldDescriptorProto_TYPE_UINT64: + dec = "b.DecodeVarint()" + case descriptor.FieldDescriptorProto_TYPE_INT32: + dec, cast = "b.DecodeVarint()", "int32" + case descriptor.FieldDescriptorProto_TYPE_FIXED64: + dec = "b.DecodeFixed64()" + case descriptor.FieldDescriptorProto_TYPE_FIXED32: + dec, cast = "b.DecodeFixed32()", "uint32" + case descriptor.FieldDescriptorProto_TYPE_BOOL: + dec = "b.DecodeVarint()" + // handled specially below + case descriptor.FieldDescriptorProto_TYPE_STRING: + dec = "b.DecodeStringBytes()" + case descriptor.FieldDescriptorProto_TYPE_GROUP: + g.P("msg := new(", fieldTypes[field][1:], ")") // drop star + lhs = "err" + dec = "b.DecodeGroup(msg)" + // handled specially below + case descriptor.FieldDescriptorProto_TYPE_MESSAGE: + g.P("msg := new(", fieldTypes[field][1:], ")") // drop star + lhs = "err" + dec = "b.DecodeMessage(msg)" + // handled specially below + case descriptor.FieldDescriptorProto_TYPE_BYTES: + dec = "b.DecodeRawBytes(true)" + case descriptor.FieldDescriptorProto_TYPE_UINT32: + dec, cast = "b.DecodeVarint()", "uint32" + case descriptor.FieldDescriptorProto_TYPE_ENUM: + dec, cast = "b.DecodeVarint()", fieldTypes[field] + case descriptor.FieldDescriptorProto_TYPE_SFIXED32: + dec, cast = "b.DecodeFixed32()", "int32" + case descriptor.FieldDescriptorProto_TYPE_SFIXED64: + dec, cast = "b.DecodeFixed64()", "int64" + case descriptor.FieldDescriptorProto_TYPE_SINT32: + dec, cast = "b.DecodeZigzag32()", "int32" + case descriptor.FieldDescriptorProto_TYPE_SINT64: + dec, cast = "b.DecodeZigzag64()", "int64" + default: + g.Fail("unhandled oneof field type ", field.Type.String()) + } + g.P(lhs, " := ", dec) + val := "x" + if cast != "" { + val = cast + "(" + val + ")" + } + if cast2 != "" { + val = cast2 + "(" + val + ")" + } + switch *field.Type { + case descriptor.FieldDescriptorProto_TYPE_BOOL: + val += " != 0" + case descriptor.FieldDescriptorProto_TYPE_GROUP, + descriptor.FieldDescriptorProto_TYPE_MESSAGE: + val = "msg" + } + g.P("m.", oneofFieldName[*field.OneofIndex], " = &", oneofTypeName[field], "{", val, "}") + g.P("return true, err") + } + g.P("default: return false, nil") + g.P("}") + g.P("}") + g.P() + + // sizer + g.P("func ", size, sizeSig, " {") + g.P("m := msg.(*", ccTypeName, ")") + for oi, odp := range message.OneofDecl { + g.P("// ", odp.GetName()) + fname := oneofFieldName[int32(oi)] + g.P("switch x := m.", fname, ".(type) {") + for _, field := range message.Field { + if field.OneofIndex == nil || int(*field.OneofIndex) != oi { + continue + } + g.P("case *", oneofTypeName[field], ":") + val := "x." + fieldNames[field] + var wire, varint, fixed string + switch *field.Type { + case descriptor.FieldDescriptorProto_TYPE_DOUBLE: + wire = "WireFixed64" + fixed = "8" + case descriptor.FieldDescriptorProto_TYPE_FLOAT: + wire = "WireFixed32" + fixed = "4" + case descriptor.FieldDescriptorProto_TYPE_INT64, + descriptor.FieldDescriptorProto_TYPE_UINT64, + descriptor.FieldDescriptorProto_TYPE_INT32, + descriptor.FieldDescriptorProto_TYPE_UINT32, + descriptor.FieldDescriptorProto_TYPE_ENUM: + wire = "WireVarint" + varint = val + case descriptor.FieldDescriptorProto_TYPE_FIXED64, + descriptor.FieldDescriptorProto_TYPE_SFIXED64: + wire = "WireFixed64" + fixed = "8" + case descriptor.FieldDescriptorProto_TYPE_FIXED32, + descriptor.FieldDescriptorProto_TYPE_SFIXED32: + wire = "WireFixed32" + fixed = "4" + case descriptor.FieldDescriptorProto_TYPE_BOOL: + wire = "WireVarint" + fixed = "1" + case descriptor.FieldDescriptorProto_TYPE_STRING: + wire = "WireBytes" + fixed = "len(" + val + ")" + varint = fixed + case descriptor.FieldDescriptorProto_TYPE_GROUP: + wire = "WireStartGroup" + fixed = g.Pkg["proto"] + ".Size(" + val + ")" + case descriptor.FieldDescriptorProto_TYPE_MESSAGE: + wire = "WireBytes" + g.P("s := ", g.Pkg["proto"], ".Size(", val, ")") + fixed = "s" + varint = fixed + case descriptor.FieldDescriptorProto_TYPE_BYTES: + wire = "WireBytes" + fixed = "len(" + val + ")" + varint = fixed + case descriptor.FieldDescriptorProto_TYPE_SINT32: + wire = "WireVarint" + varint = "(uint32(" + val + ") << 1) ^ uint32((int32(" + val + ") >> 31))" + case descriptor.FieldDescriptorProto_TYPE_SINT64: + wire = "WireVarint" + varint = "uint64(" + val + " << 1) ^ uint64((int64(" + val + ") >> 63))" + default: + g.Fail("unhandled oneof field type ", field.Type.String()) + } + g.P("n += ", g.Pkg["proto"], ".SizeVarint(", field.Number, "<<3|", g.Pkg["proto"], ".", wire, ")") + if varint != "" { + g.P("n += ", g.Pkg["proto"], ".SizeVarint(uint64(", varint, "))") + } + if fixed != "" { + g.P("n += ", fixed) + } + if *field.Type == descriptor.FieldDescriptorProto_TYPE_GROUP { + g.P("n += ", g.Pkg["proto"], ".SizeVarint(", field.Number, "<<3|", g.Pkg["proto"], ".WireEndGroup)") + } + } + g.P("case nil:") + g.P("default:") + g.P("panic(", g.Pkg["fmt"], ".Sprintf(\"proto: unexpected type %T in oneof\", x))") + g.P("}") + } + g.P("return n") + g.P("}") + g.P() + } + + for _, ext := range message.ext { + g.generateExtension(ext) + } + + fullName := strings.Join(message.TypeName(), ".") + if g.file.Package != nil { + fullName = *g.file.Package + "." + fullName + } + + g.addInitf("%s.RegisterType((*%s)(nil), %q)", g.Pkg["proto"], ccTypeName, fullName) +} + +func (g *Generator) generateExtension(ext *ExtensionDescriptor) { + ccTypeName := ext.DescName() + + extObj := g.ObjectNamed(*ext.Extendee) + var extDesc *Descriptor + if id, ok := extObj.(*ImportedDescriptor); ok { + // This is extending a publicly imported message. + // We need the underlying type for goTag. + extDesc = id.o.(*Descriptor) + } else { + extDesc = extObj.(*Descriptor) + } + extendedType := "*" + g.TypeName(extObj) // always use the original + field := ext.FieldDescriptorProto + fieldType, wireType := g.GoType(ext.parent, field) + tag := g.goTag(extDesc, field, wireType) + g.RecordTypeUse(*ext.Extendee) + if n := ext.FieldDescriptorProto.TypeName; n != nil { + // foreign extension type + g.RecordTypeUse(*n) + } + + typeName := ext.TypeName() + + // Special case for proto2 message sets: If this extension is extending + // proto2_bridge.MessageSet, and its final name component is "message_set_extension", + // then drop that last component. + mset := false + if extendedType == "*proto2_bridge.MessageSet" && typeName[len(typeName)-1] == "message_set_extension" { + typeName = typeName[:len(typeName)-1] + mset = true + } + + // For text formatting, the package must be exactly what the .proto file declares, + // ignoring overrides such as the go_package option, and with no dot/underscore mapping. + extName := strings.Join(typeName, ".") + if g.file.Package != nil { + extName = *g.file.Package + "." + extName + } + + g.P("var ", ccTypeName, " = &", g.Pkg["proto"], ".ExtensionDesc{") + g.In() + g.P("ExtendedType: (", extendedType, ")(nil),") + g.P("ExtensionType: (", fieldType, ")(nil),") + g.P("Field: ", field.Number, ",") + g.P(`Name: "`, extName, `",`) + g.P("Tag: ", tag, ",") + + g.Out() + g.P("}") + g.P() + + if mset { + // Generate a bit more code to register with message_set.go. + g.addInitf("%s.RegisterMessageSetType((%s)(nil), %d, %q)", g.Pkg["proto"], fieldType, *field.Number, extName) + } + + g.file.addExport(ext, constOrVarSymbol{ccTypeName, "var", ""}) +} + +func (g *Generator) generateInitFunction() { + for _, enum := range g.file.enum { + g.generateEnumRegistration(enum) + } + for _, d := range g.file.desc { + for _, ext := range d.ext { + g.generateExtensionRegistration(ext) + } + } + for _, ext := range g.file.ext { + g.generateExtensionRegistration(ext) + } + if len(g.init) == 0 { + return + } + g.P("func init() {") + g.In() + for _, l := range g.init { + g.P(l) + } + g.Out() + g.P("}") + g.init = nil +} + +func (g *Generator) generateFileDescriptor(file *FileDescriptor) { + // Make a copy and trim source_code_info data. + // TODO: Trim this more when we know exactly what we need. + pb := proto.Clone(file.FileDescriptorProto).(*descriptor.FileDescriptorProto) + pb.SourceCodeInfo = nil + + b, err := proto.Marshal(pb) + if err != nil { + g.Fail(err.Error()) + } + + var buf bytes.Buffer + w, _ := gzip.NewWriterLevel(&buf, gzip.BestCompression) + w.Write(b) + w.Close() + b = buf.Bytes() + + g.P("var fileDescriptor", file.index, " = []byte{") + g.In() + g.P("// ", len(b), " bytes of a gzipped FileDescriptorProto") + for len(b) > 0 { + n := 16 + if n > len(b) { + n = len(b) + } + + s := "" + for _, c := range b[:n] { + s += fmt.Sprintf("0x%02x,", c) + } + g.P(s) + + b = b[n:] + } + g.Out() + g.P("}") +} + +func (g *Generator) generateEnumRegistration(enum *EnumDescriptor) { + // // We always print the full (proto-world) package name here. + pkg := enum.File().GetPackage() + if pkg != "" { + pkg += "." + } + // The full type name + typeName := enum.TypeName() + // The full type name, CamelCased. + ccTypeName := CamelCaseSlice(typeName) + g.addInitf("%s.RegisterEnum(%q, %[3]s_name, %[3]s_value)", g.Pkg["proto"], pkg+ccTypeName, ccTypeName) +} + +func (g *Generator) generateExtensionRegistration(ext *ExtensionDescriptor) { + g.addInitf("%s.RegisterExtension(%s)", g.Pkg["proto"], ext.DescName()) +} + +// And now lots of helper functions. + +// Is c an ASCII lower-case letter? +func isASCIILower(c byte) bool { + return 'a' <= c && c <= 'z' +} + +// Is c an ASCII digit? +func isASCIIDigit(c byte) bool { + return '0' <= c && c <= '9' +} + +// CamelCase returns the CamelCased name. +// If there is an interior underscore followed by a lower case letter, +// drop the underscore and convert the letter to upper case. +// There is a remote possibility of this rewrite causing a name collision, +// but it's so remote we're prepared to pretend it's nonexistent - since the +// C++ generator lowercases names, it's extremely unlikely to have two fields +// with different capitalizations. +// In short, _my_field_name_2 becomes XMyFieldName_2. +func CamelCase(s string) string { + if s == "" { + return "" + } + t := make([]byte, 0, 32) + i := 0 + if s[0] == '_' { + // Need a capital letter; drop the '_'. + t = append(t, 'X') + i++ + } + // Invariant: if the next letter is lower case, it must be converted + // to upper case. + // That is, we process a word at a time, where words are marked by _ or + // upper case letter. Digits are treated as words. + for ; i < len(s); i++ { + c := s[i] + if c == '_' && i+1 < len(s) && isASCIILower(s[i+1]) { + continue // Skip the underscore in s. + } + if isASCIIDigit(c) { + t = append(t, c) + continue + } + // Assume we have a letter now - if not, it's a bogus identifier. + // The next word is a sequence of characters that must start upper case. + if isASCIILower(c) { + c ^= ' ' // Make it a capital letter. + } + t = append(t, c) // Guaranteed not lower case. + // Accept lower case sequence that follows. + for i+1 < len(s) && isASCIILower(s[i+1]) { + i++ + t = append(t, s[i]) + } + } + return string(t) +} + +// CamelCaseSlice is like CamelCase, but the argument is a slice of strings to +// be joined with "_". +func CamelCaseSlice(elem []string) string { return CamelCase(strings.Join(elem, "_")) } + +// dottedSlice turns a sliced name into a dotted name. +func dottedSlice(elem []string) string { return strings.Join(elem, ".") } + +// Given a .proto file name, return the output name for the generated Go program. +func goFileName(name string) string { + ext := path.Ext(name) + if ext == ".proto" || ext == ".protodevel" { + name = name[0 : len(name)-len(ext)] + } + return name + ".pb.go" +} + +// Is this field optional? +func isOptional(field *descriptor.FieldDescriptorProto) bool { + return field.Label != nil && *field.Label == descriptor.FieldDescriptorProto_LABEL_OPTIONAL +} + +// Is this field required? +func isRequired(field *descriptor.FieldDescriptorProto) bool { + return field.Label != nil && *field.Label == descriptor.FieldDescriptorProto_LABEL_REQUIRED +} + +// Is this field repeated? +func isRepeated(field *descriptor.FieldDescriptorProto) bool { + return field.Label != nil && *field.Label == descriptor.FieldDescriptorProto_LABEL_REPEATED +} + +// badToUnderscore is the mapping function used to generate Go names from package names, +// which can be dotted in the input .proto file. It replaces non-identifier characters such as +// dot or dash with underscore. +func badToUnderscore(r rune) rune { + if unicode.IsLetter(r) || unicode.IsDigit(r) || r == '_' { + return r + } + return '_' +} + +// baseName returns the last path element of the name, with the last dotted suffix removed. +func baseName(name string) string { + // First, find the last element + if i := strings.LastIndex(name, "/"); i >= 0 { + name = name[i+1:] + } + // Now drop the suffix + if i := strings.LastIndex(name, "."); i >= 0 { + name = name[0:i] + } + return name +} + +// The SourceCodeInfo message describes the location of elements of a parsed +// .proto file by way of a "path", which is a sequence of integers that +// describe the route from a FileDescriptorProto to the relevant submessage. +// The path alternates between a field number of a repeated field, and an index +// into that repeated field. The constants below define the field numbers that +// are used. +// +// See descriptor.proto for more information about this. +const ( + // tag numbers in FileDescriptorProto + packagePath = 2 // package + messagePath = 4 // message_type + enumPath = 5 // enum_type + // tag numbers in DescriptorProto + messageFieldPath = 2 // field + messageMessagePath = 3 // nested_type + messageEnumPath = 4 // enum_type + messageOneofPath = 8 // oneof_decl + // tag numbers in EnumDescriptorProto + enumValuePath = 2 // value +) diff --git a/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/internal/grpc/grpc.go b/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/internal/grpc/grpc.go new file mode 100644 index 0000000000..f33f7011bf --- /dev/null +++ b/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/internal/grpc/grpc.go @@ -0,0 +1,442 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2015 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +// Package grpc outputs gRPC service descriptions in Go code. +// It runs as a plugin for the Go protocol buffer compiler plugin. +// It is linked in to protoc-gen-go. +package grpc + +import ( + "fmt" + "path" + "strconv" + "strings" + + pb "github.com/golang/protobuf/protoc-gen-go/descriptor" + "github.com/golang/protobuf/protoc-gen-go/generator" +) + +// Paths for packages used by code generated in this file, +// relative to the import_prefix of the generator.Generator. +const ( + contextPkgPath = "golang.org/x/net/context" + grpcPkgPath = "google.golang.org/grpc" +) + +func init() { + generator.RegisterPlugin(new(grpc)) +} + +// grpc is an implementation of the Go protocol buffer compiler's +// plugin architecture. It generates bindings for gRPC support. +type grpc struct { + gen *generator.Generator +} + +// Name returns the name of this plugin, "grpc". +func (g *grpc) Name() string { + return "grpc" +} + +// The names for packages imported in the generated code. +// They may vary from the final path component of the import path +// if the name is used by other packages. +var ( + contextPkg string + grpcPkg string +) + +// Init initializes the plugin. +func (g *grpc) Init(gen *generator.Generator) { + g.gen = gen + contextPkg = generator.RegisterUniquePackageName("context", nil) + grpcPkg = generator.RegisterUniquePackageName("grpc", nil) +} + +// Given a type name defined in a .proto, return its object. +// Also record that we're using it, to guarantee the associated import. +func (g *grpc) objectNamed(name string) generator.Object { + g.gen.RecordTypeUse(name) + return g.gen.ObjectNamed(name) +} + +// Given a type name defined in a .proto, return its name as we will print it. +func (g *grpc) typeName(str string) string { + return g.gen.TypeName(g.objectNamed(str)) +} + +// P forwards to g.gen.P. +func (g *grpc) P(args ...interface{}) { g.gen.P(args...) } + +// Generate generates code for the services in the given file. +func (g *grpc) Generate(file *generator.FileDescriptor) { + if len(file.FileDescriptorProto.Service) == 0 { + return + } + g.P("// Reference imports to suppress errors if they are not otherwise used.") + g.P("var _ ", contextPkg, ".Context") + g.P("var _ ", grpcPkg, ".ClientConn") + g.P() + for i, service := range file.FileDescriptorProto.Service { + g.generateService(file, service, i) + } +} + +// GenerateImports generates the import declaration for this file. +func (g *grpc) GenerateImports(file *generator.FileDescriptor) { + if len(file.FileDescriptorProto.Service) == 0 { + return + } + g.P("import (") + g.P(contextPkg, " ", strconv.Quote(path.Join(g.gen.ImportPrefix, contextPkgPath))) + g.P(grpcPkg, " ", strconv.Quote(path.Join(g.gen.ImportPrefix, grpcPkgPath))) + g.P(")") + g.P() +} + +// reservedClientName records whether a client name is reserved on the client side. +var reservedClientName = map[string]bool{ +// TODO: do we need any in gRPC? +} + +func unexport(s string) string { return strings.ToLower(s[:1]) + s[1:] } + +// generateService generates all the code for the named service. +func (g *grpc) generateService(file *generator.FileDescriptor, service *pb.ServiceDescriptorProto, index int) { + path := fmt.Sprintf("6,%d", index) // 6 means service. + + origServName := service.GetName() + fullServName := origServName + if pkg := file.GetPackage(); pkg != "" { + fullServName = pkg + "." + fullServName + } + servName := generator.CamelCase(origServName) + + g.P() + g.P("// Client API for ", servName, " service") + g.P() + + // Client interface. + g.P("type ", servName, "Client interface {") + for i, method := range service.Method { + g.gen.PrintComments(fmt.Sprintf("%s,2,%d", path, i)) // 2 means method in a service. + g.P(g.generateClientSignature(servName, method)) + } + g.P("}") + g.P() + + // Client structure. + g.P("type ", unexport(servName), "Client struct {") + g.P("cc *", grpcPkg, ".ClientConn") + g.P("}") + g.P() + + // NewClient factory. + g.P("func New", servName, "Client (cc *", grpcPkg, ".ClientConn) ", servName, "Client {") + g.P("return &", unexport(servName), "Client{cc}") + g.P("}") + g.P() + + var methodIndex, streamIndex int + serviceDescVar := "_" + servName + "_serviceDesc" + // Client method implementations. + for _, method := range service.Method { + var descExpr string + if !method.GetServerStreaming() && !method.GetClientStreaming() { + // Unary RPC method + descExpr = fmt.Sprintf("&%s.Methods[%d]", serviceDescVar, methodIndex) + methodIndex++ + } else { + // Streaming RPC method + descExpr = fmt.Sprintf("&%s.Streams[%d]", serviceDescVar, streamIndex) + streamIndex++ + } + g.generateClientMethod(servName, fullServName, serviceDescVar, method, descExpr) + } + + g.P("// Server API for ", servName, " service") + g.P() + + // Server interface. + serverType := servName + "Server" + g.P("type ", serverType, " interface {") + for i, method := range service.Method { + g.gen.PrintComments(fmt.Sprintf("%s,2,%d", path, i)) // 2 means method in a service. + g.P(g.generateServerSignature(servName, method)) + } + g.P("}") + g.P() + + // Server registration. + g.P("func Register", servName, "Server(s *", grpcPkg, ".Server, srv ", serverType, ") {") + g.P("s.RegisterService(&", serviceDescVar, `, srv)`) + g.P("}") + g.P() + + // Server handler implementations. + var handlerNames []string + for _, method := range service.Method { + hname := g.generateServerMethod(servName, method) + handlerNames = append(handlerNames, hname) + } + + // Service descriptor. + g.P("var ", serviceDescVar, " = ", grpcPkg, ".ServiceDesc {") + g.P("ServiceName: ", strconv.Quote(fullServName), ",") + g.P("HandlerType: (*", serverType, ")(nil),") + g.P("Methods: []", grpcPkg, ".MethodDesc{") + for i, method := range service.Method { + if method.GetServerStreaming() || method.GetClientStreaming() { + continue + } + g.P("{") + g.P("MethodName: ", strconv.Quote(method.GetName()), ",") + g.P("Handler: ", handlerNames[i], ",") + g.P("},") + } + g.P("},") + g.P("Streams: []", grpcPkg, ".StreamDesc{") + for i, method := range service.Method { + if !method.GetServerStreaming() && !method.GetClientStreaming() { + continue + } + g.P("{") + g.P("StreamName: ", strconv.Quote(method.GetName()), ",") + g.P("Handler: ", handlerNames[i], ",") + if method.GetServerStreaming() { + g.P("ServerStreams: true,") + } + if method.GetClientStreaming() { + g.P("ClientStreams: true,") + } + g.P("},") + } + g.P("},") + g.P("}") + g.P() +} + +// generateClientSignature returns the client-side signature for a method. +func (g *grpc) generateClientSignature(servName string, method *pb.MethodDescriptorProto) string { + origMethName := method.GetName() + methName := generator.CamelCase(origMethName) + if reservedClientName[methName] { + methName += "_" + } + reqArg := ", in *" + g.typeName(method.GetInputType()) + if method.GetClientStreaming() { + reqArg = "" + } + respName := "*" + g.typeName(method.GetOutputType()) + if method.GetServerStreaming() || method.GetClientStreaming() { + respName = servName + "_" + generator.CamelCase(origMethName) + "Client" + } + return fmt.Sprintf("%s(ctx %s.Context%s, opts ...%s.CallOption) (%s, error)", methName, contextPkg, reqArg, grpcPkg, respName) +} + +func (g *grpc) generateClientMethod(servName, fullServName, serviceDescVar string, method *pb.MethodDescriptorProto, descExpr string) { + sname := fmt.Sprintf("/%s/%s", fullServName, method.GetName()) + methName := generator.CamelCase(method.GetName()) + inType := g.typeName(method.GetInputType()) + outType := g.typeName(method.GetOutputType()) + + g.P("func (c *", unexport(servName), "Client) ", g.generateClientSignature(servName, method), "{") + if !method.GetServerStreaming() && !method.GetClientStreaming() { + g.P("out := new(", outType, ")") + // TODO: Pass descExpr to Invoke. + g.P("err := ", grpcPkg, `.Invoke(ctx, "`, sname, `", in, out, c.cc, opts...)`) + g.P("if err != nil { return nil, err }") + g.P("return out, nil") + g.P("}") + g.P() + return + } + streamType := unexport(servName) + methName + "Client" + g.P("stream, err := ", grpcPkg, ".NewClientStream(ctx, ", descExpr, `, c.cc, "`, sname, `", opts...)`) + g.P("if err != nil { return nil, err }") + g.P("x := &", streamType, "{stream}") + if !method.GetClientStreaming() { + g.P("if err := x.ClientStream.SendMsg(in); err != nil { return nil, err }") + g.P("if err := x.ClientStream.CloseSend(); err != nil { return nil, err }") + } + g.P("return x, nil") + g.P("}") + g.P() + + genSend := method.GetClientStreaming() + genRecv := method.GetServerStreaming() + genCloseAndRecv := !method.GetServerStreaming() + + // Stream auxiliary types and methods. + g.P("type ", servName, "_", methName, "Client interface {") + if genSend { + g.P("Send(*", inType, ") error") + } + if genRecv { + g.P("Recv() (*", outType, ", error)") + } + if genCloseAndRecv { + g.P("CloseAndRecv() (*", outType, ", error)") + } + g.P(grpcPkg, ".ClientStream") + g.P("}") + g.P() + + g.P("type ", streamType, " struct {") + g.P(grpcPkg, ".ClientStream") + g.P("}") + g.P() + + if genSend { + g.P("func (x *", streamType, ") Send(m *", inType, ") error {") + g.P("return x.ClientStream.SendMsg(m)") + g.P("}") + g.P() + } + if genRecv { + g.P("func (x *", streamType, ") Recv() (*", outType, ", error) {") + g.P("m := new(", outType, ")") + g.P("if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err }") + g.P("return m, nil") + g.P("}") + g.P() + } + if genCloseAndRecv { + g.P("func (x *", streamType, ") CloseAndRecv() (*", outType, ", error) {") + g.P("if err := x.ClientStream.CloseSend(); err != nil { return nil, err }") + g.P("m := new(", outType, ")") + g.P("if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err }") + g.P("return m, nil") + g.P("}") + g.P() + } +} + +// generateServerSignature returns the server-side signature for a method. +func (g *grpc) generateServerSignature(servName string, method *pb.MethodDescriptorProto) string { + origMethName := method.GetName() + methName := generator.CamelCase(origMethName) + if reservedClientName[methName] { + methName += "_" + } + + var reqArgs []string + ret := "error" + if !method.GetServerStreaming() && !method.GetClientStreaming() { + reqArgs = append(reqArgs, contextPkg+".Context") + ret = "(*" + g.typeName(method.GetOutputType()) + ", error)" + } + if !method.GetClientStreaming() { + reqArgs = append(reqArgs, "*"+g.typeName(method.GetInputType())) + } + if method.GetServerStreaming() || method.GetClientStreaming() { + reqArgs = append(reqArgs, servName+"_"+generator.CamelCase(origMethName)+"Server") + } + + return methName + "(" + strings.Join(reqArgs, ", ") + ") " + ret +} + +func (g *grpc) generateServerMethod(servName string, method *pb.MethodDescriptorProto) string { + methName := generator.CamelCase(method.GetName()) + hname := fmt.Sprintf("_%s_%s_Handler", servName, methName) + inType := g.typeName(method.GetInputType()) + outType := g.typeName(method.GetOutputType()) + + if !method.GetServerStreaming() && !method.GetClientStreaming() { + g.P("func ", hname, "(srv interface{}, ctx ", contextPkg, ".Context, dec func(interface{}) error) (interface{}, error) {") + g.P("in := new(", inType, ")") + g.P("if err := dec(in); err != nil { return nil, err }") + g.P("out, err := srv.(", servName, "Server).", methName, "(ctx, in)") + g.P("if err != nil { return nil, err }") + g.P("return out, nil") + g.P("}") + g.P() + return hname + } + streamType := unexport(servName) + methName + "Server" + g.P("func ", hname, "(srv interface{}, stream ", grpcPkg, ".ServerStream) error {") + if !method.GetClientStreaming() { + g.P("m := new(", inType, ")") + g.P("if err := stream.RecvMsg(m); err != nil { return err }") + g.P("return srv.(", servName, "Server).", methName, "(m, &", streamType, "{stream})") + } else { + g.P("return srv.(", servName, "Server).", methName, "(&", streamType, "{stream})") + } + g.P("}") + g.P() + + genSend := method.GetServerStreaming() + genSendAndClose := !method.GetServerStreaming() + genRecv := method.GetClientStreaming() + + // Stream auxiliary types and methods. + g.P("type ", servName, "_", methName, "Server interface {") + if genSend { + g.P("Send(*", outType, ") error") + } + if genSendAndClose { + g.P("SendAndClose(*", outType, ") error") + } + if genRecv { + g.P("Recv() (*", inType, ", error)") + } + g.P(grpcPkg, ".ServerStream") + g.P("}") + g.P() + + g.P("type ", streamType, " struct {") + g.P(grpcPkg, ".ServerStream") + g.P("}") + g.P() + + if genSend { + g.P("func (x *", streamType, ") Send(m *", outType, ") error {") + g.P("return x.ServerStream.SendMsg(m)") + g.P("}") + g.P() + } + if genSendAndClose { + g.P("func (x *", streamType, ") SendAndClose(m *", outType, ") error {") + g.P("return x.ServerStream.SendMsg(m)") + g.P("}") + g.P() + } + if genRecv { + g.P("func (x *", streamType, ") Recv() (*", inType, ", error) {") + g.P("m := new(", inType, ")") + g.P("if err := x.ServerStream.RecvMsg(m); err != nil { return nil, err }") + g.P("return m, nil") + g.P("}") + g.P() + } + + return hname +} diff --git a/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/link_grpc.go b/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/link_grpc.go new file mode 100644 index 0000000000..24e490ec4b --- /dev/null +++ b/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/link_grpc.go @@ -0,0 +1,34 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2015 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +package main + +import _ "github.com/golang/protobuf/protoc-gen-go/internal/grpc" diff --git a/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/main.go b/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/main.go new file mode 100644 index 0000000000..8e2486de0b --- /dev/null +++ b/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/main.go @@ -0,0 +1,98 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +// protoc-gen-go is a plugin for the Google protocol buffer compiler to generate +// Go code. Run it by building this program and putting it in your path with +// the name +// protoc-gen-go +// That word 'go' at the end becomes part of the option string set for the +// protocol compiler, so once the protocol compiler (protoc) is installed +// you can run +// protoc --go_out=output_directory input_directory/file.proto +// to generate Go bindings for the protocol defined by file.proto. +// With that input, the output will be written to +// output_directory/file.pb.go +// +// The generated code is documented in the package comment for +// the library. +// +// See the README and documentation for protocol buffers to learn more: +// https://developers.google.com/protocol-buffers/ +package main + +import ( + "io/ioutil" + "os" + + "github.com/golang/protobuf/proto" + "github.com/golang/protobuf/protoc-gen-go/generator" +) + +func main() { + // Begin by allocating a generator. The request and response structures are stored there + // so we can do error handling easily - the response structure contains the field to + // report failure. + g := generator.New() + + data, err := ioutil.ReadAll(os.Stdin) + if err != nil { + g.Error(err, "reading input") + } + + if err := proto.Unmarshal(data, g.Request); err != nil { + g.Error(err, "parsing input proto") + } + + if len(g.Request.FileToGenerate) == 0 { + g.Fail("no files to generate") + } + + g.CommandLineParameters(g.Request.GetParameter()) + + // Create a wrapped version of the Descriptors and EnumDescriptors that + // point to the file that defines them. + g.WrapTypes() + + g.SetPackageNames() + g.BuildTypeNameMap() + + g.GenerateAllFiles() + + // Send back the results. + data, err = proto.Marshal(g.Response) + if err != nil { + g.Error(err, "failed to marshal output proto") + } + _, err = os.Stdout.Write(data) + if err != nil { + g.Error(err, "failed to write output proto") + } +} diff --git a/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/plugin/Makefile b/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/plugin/Makefile new file mode 100644 index 0000000000..eb41f20daa --- /dev/null +++ b/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/plugin/Makefile @@ -0,0 +1,45 @@ +# Go support for Protocol Buffers - Google's data interchange format +# +# Copyright 2010 The Go Authors. All rights reserved. +# https://github.com/golang/protobuf +# +# 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. + +# Not stored here, but plugin.proto is in https://github.com/google/protobuf/ +# at src/google/protobuf/compiler/plugin.proto +# Also we need to fix an import. +regenerate: + echo WARNING! THIS RULE IS PROBABLY NOT RIGHT FOR YOUR INSTALLATION + protoc --go_out=Mgoogle/protobuf/descriptor.proto=github.com/golang/protobuf/protoc-gen-go/descriptor:. \ + -I$(HOME)/src/protobuf/src $(HOME)/src/protobuf/src/google/protobuf/compiler/plugin.proto && \ + mv google/protobuf/compiler/plugin.pb.go $(GOPATH)/src/github.com/golang/protobuf/protoc-gen-go/plugin + +restore: + cp plugin.pb.golden plugin.pb.go + +preserve: + cp plugin.pb.go plugin.pb.golden diff --git a/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/plugin/plugin.pb.go b/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/plugin/plugin.pb.go new file mode 100644 index 0000000000..af31f733e9 --- /dev/null +++ b/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/plugin/plugin.pb.go @@ -0,0 +1,222 @@ +// Code generated by protoc-gen-go. +// source: google/protobuf/compiler/plugin.proto +// DO NOT EDIT! + +/* +Package google_protobuf_compiler is a generated protocol buffer package. + +It is generated from these files: + google/protobuf/compiler/plugin.proto + +It has these top-level messages: + CodeGeneratorRequest + CodeGeneratorResponse +*/ +package google_protobuf_compiler + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" +import google_protobuf "github.com/golang/protobuf/protoc-gen-go/descriptor" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +const _ = proto.ProtoPackageIsVersion1 + +// An encoded CodeGeneratorRequest is written to the plugin's stdin. +type CodeGeneratorRequest struct { + // The .proto files that were explicitly listed on the command-line. The + // code generator should generate code only for these files. Each file's + // descriptor will be included in proto_file, below. + FileToGenerate []string `protobuf:"bytes,1,rep,name=file_to_generate" json:"file_to_generate,omitempty"` + // The generator parameter passed on the command-line. + Parameter *string `protobuf:"bytes,2,opt,name=parameter" json:"parameter,omitempty"` + // FileDescriptorProtos for all files in files_to_generate and everything + // they import. The files will appear in topological order, so each file + // appears before any file that imports it. + // + // protoc guarantees that all proto_files will be written after + // the fields above, even though this is not technically guaranteed by the + // protobuf wire format. This theoretically could allow a plugin to stream + // in the FileDescriptorProtos and handle them one by one rather than read + // the entire set into memory at once. However, as of this writing, this + // is not similarly optimized on protoc's end -- it will store all fields in + // memory at once before sending them to the plugin. + ProtoFile []*google_protobuf.FileDescriptorProto `protobuf:"bytes,15,rep,name=proto_file" json:"proto_file,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CodeGeneratorRequest) Reset() { *m = CodeGeneratorRequest{} } +func (m *CodeGeneratorRequest) String() string { return proto.CompactTextString(m) } +func (*CodeGeneratorRequest) ProtoMessage() {} +func (*CodeGeneratorRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } + +func (m *CodeGeneratorRequest) GetFileToGenerate() []string { + if m != nil { + return m.FileToGenerate + } + return nil +} + +func (m *CodeGeneratorRequest) GetParameter() string { + if m != nil && m.Parameter != nil { + return *m.Parameter + } + return "" +} + +func (m *CodeGeneratorRequest) GetProtoFile() []*google_protobuf.FileDescriptorProto { + if m != nil { + return m.ProtoFile + } + return nil +} + +// The plugin writes an encoded CodeGeneratorResponse to stdout. +type CodeGeneratorResponse struct { + // Error message. If non-empty, code generation failed. The plugin process + // should exit with status code zero even if it reports an error in this way. + // + // This should be used to indicate errors in .proto files which prevent the + // code generator from generating correct code. Errors which indicate a + // problem in protoc itself -- such as the input CodeGeneratorRequest being + // unparseable -- should be reported by writing a message to stderr and + // exiting with a non-zero status code. + Error *string `protobuf:"bytes,1,opt,name=error" json:"error,omitempty"` + File []*CodeGeneratorResponse_File `protobuf:"bytes,15,rep,name=file" json:"file,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CodeGeneratorResponse) Reset() { *m = CodeGeneratorResponse{} } +func (m *CodeGeneratorResponse) String() string { return proto.CompactTextString(m) } +func (*CodeGeneratorResponse) ProtoMessage() {} +func (*CodeGeneratorResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } + +func (m *CodeGeneratorResponse) GetError() string { + if m != nil && m.Error != nil { + return *m.Error + } + return "" +} + +func (m *CodeGeneratorResponse) GetFile() []*CodeGeneratorResponse_File { + if m != nil { + return m.File + } + return nil +} + +// Represents a single generated file. +type CodeGeneratorResponse_File struct { + // The file name, relative to the output directory. The name must not + // contain "." or ".." components and must be relative, not be absolute (so, + // the file cannot lie outside the output directory). "/" must be used as + // the path separator, not "\". + // + // If the name is omitted, the content will be appended to the previous + // file. This allows the generator to break large files into small chunks, + // and allows the generated text to be streamed back to protoc so that large + // files need not reside completely in memory at one time. Note that as of + // this writing protoc does not optimize for this -- it will read the entire + // CodeGeneratorResponse before writing files to disk. + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + // If non-empty, indicates that the named file should already exist, and the + // content here is to be inserted into that file at a defined insertion + // point. This feature allows a code generator to extend the output + // produced by another code generator. The original generator may provide + // insertion points by placing special annotations in the file that look + // like: + // @@protoc_insertion_point(NAME) + // The annotation can have arbitrary text before and after it on the line, + // which allows it to be placed in a comment. NAME should be replaced with + // an identifier naming the point -- this is what other generators will use + // as the insertion_point. Code inserted at this point will be placed + // immediately above the line containing the insertion point (thus multiple + // insertions to the same point will come out in the order they were added). + // The double-@ is intended to make it unlikely that the generated code + // could contain things that look like insertion points by accident. + // + // For example, the C++ code generator places the following line in the + // .pb.h files that it generates: + // // @@protoc_insertion_point(namespace_scope) + // This line appears within the scope of the file's package namespace, but + // outside of any particular class. Another plugin can then specify the + // insertion_point "namespace_scope" to generate additional classes or + // other declarations that should be placed in this scope. + // + // Note that if the line containing the insertion point begins with + // whitespace, the same whitespace will be added to every line of the + // inserted text. This is useful for languages like Python, where + // indentation matters. In these languages, the insertion point comment + // should be indented the same amount as any inserted code will need to be + // in order to work correctly in that context. + // + // The code generator that generates the initial file and the one which + // inserts into it must both run as part of a single invocation of protoc. + // Code generators are executed in the order in which they appear on the + // command line. + // + // If |insertion_point| is present, |name| must also be present. + InsertionPoint *string `protobuf:"bytes,2,opt,name=insertion_point" json:"insertion_point,omitempty"` + // The file contents. + Content *string `protobuf:"bytes,15,opt,name=content" json:"content,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CodeGeneratorResponse_File) Reset() { *m = CodeGeneratorResponse_File{} } +func (m *CodeGeneratorResponse_File) String() string { return proto.CompactTextString(m) } +func (*CodeGeneratorResponse_File) ProtoMessage() {} +func (*CodeGeneratorResponse_File) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1, 0} } + +func (m *CodeGeneratorResponse_File) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *CodeGeneratorResponse_File) GetInsertionPoint() string { + if m != nil && m.InsertionPoint != nil { + return *m.InsertionPoint + } + return "" +} + +func (m *CodeGeneratorResponse_File) GetContent() string { + if m != nil && m.Content != nil { + return *m.Content + } + return "" +} + +func init() { + proto.RegisterType((*CodeGeneratorRequest)(nil), "google.protobuf.compiler.CodeGeneratorRequest") + proto.RegisterType((*CodeGeneratorResponse)(nil), "google.protobuf.compiler.CodeGeneratorResponse") + proto.RegisterType((*CodeGeneratorResponse_File)(nil), "google.protobuf.compiler.CodeGeneratorResponse.File") +} + +var fileDescriptor0 = []byte{ + // 269 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x74, 0x91, 0xc1, 0x4a, 0xc3, 0x40, + 0x10, 0x86, 0xa9, 0x46, 0xa4, 0x63, 0x25, 0x1a, 0x14, 0x43, 0xf1, 0x10, 0x44, 0xc1, 0x83, 0x6c, + 0x40, 0x3c, 0x78, 0xf2, 0x10, 0x45, 0xaf, 0xc5, 0x17, 0x08, 0x31, 0x9d, 0x86, 0x85, 0x74, 0x67, + 0x9d, 0xdd, 0x1c, 0x7d, 0x21, 0x9f, 0xd2, 0xc9, 0xa6, 0x15, 0x09, 0xf6, 0x14, 0xf8, 0xe7, 0xcf, + 0xf7, 0xcd, 0xb0, 0x70, 0xd3, 0x10, 0x35, 0x2d, 0xe6, 0x96, 0xc9, 0xd3, 0x47, 0xb7, 0xca, 0x6b, + 0x5a, 0x5b, 0xdd, 0x22, 0xe7, 0xb6, 0xed, 0x1a, 0x6d, 0x54, 0x18, 0x24, 0xe9, 0x50, 0x53, 0xdb, + 0x9a, 0xda, 0xd6, 0xe6, 0xd9, 0x18, 0xb0, 0x44, 0x57, 0xb3, 0xb6, 0x9e, 0x78, 0x68, 0x5f, 0x7d, + 0xc1, 0xd9, 0x33, 0x2d, 0xf1, 0x0d, 0x0d, 0x72, 0x25, 0xf1, 0x3b, 0x7e, 0x76, 0xe8, 0x7c, 0x92, + 0xc2, 0xc9, 0x4a, 0x10, 0xa5, 0xa7, 0xb2, 0x19, 0x66, 0x98, 0x4e, 0xb2, 0xfd, 0xdb, 0x69, 0x72, + 0x0a, 0x53, 0x5b, 0x71, 0xb5, 0x46, 0x8f, 0x9c, 0xee, 0x65, 0x13, 0x89, 0x1e, 0x01, 0x02, 0xad, + 0xec, 0x7f, 0x49, 0x63, 0xa9, 0x1d, 0xdd, 0x5f, 0xab, 0xf1, 0x56, 0xaf, 0x32, 0x7c, 0xf9, 0xf5, + 0x2f, 0x82, 0xfe, 0x7b, 0x02, 0xe7, 0x23, 0xbf, 0xb3, 0x64, 0x1c, 0x26, 0xc7, 0x70, 0x80, 0xcc, + 0xc4, 0x62, 0xed, 0x15, 0x05, 0x44, 0x7f, 0xe0, 0x0f, 0x6a, 0xd7, 0xc9, 0xea, 0x5f, 0x5a, 0x70, + 0xcf, 0x9f, 0x20, 0xea, 0xbf, 0xc9, 0x0c, 0x22, 0x23, 0xfb, 0x6f, 0xc8, 0x17, 0x10, 0x6b, 0xa9, + 0xb0, 0xd7, 0x64, 0x4a, 0x4b, 0xda, 0xf8, 0xcd, 0x55, 0x31, 0x1c, 0xd6, 0x64, 0x3c, 0x4a, 0x10, + 0xf7, 0x41, 0x71, 0x07, 0x97, 0xa2, 0xd9, 0xa9, 0x2e, 0x66, 0x8b, 0xf0, 0x2a, 0xe1, 0x32, 0xf7, + 0x13, 0x00, 0x00, 0xff, 0xff, 0xdb, 0x18, 0x2a, 0x2a, 0xbd, 0x01, 0x00, 0x00, +} diff --git a/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/plugin/plugin.pb.golden b/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/plugin/plugin.pb.golden new file mode 100644 index 0000000000..8953d0ff82 --- /dev/null +++ b/Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/plugin/plugin.pb.golden @@ -0,0 +1,83 @@ +// Code generated by protoc-gen-go. +// source: google/protobuf/compiler/plugin.proto +// DO NOT EDIT! + +package google_protobuf_compiler + +import proto "github.com/golang/protobuf/proto" +import "math" +import google_protobuf "github.com/golang/protobuf/protoc-gen-go/descriptor" + +// Reference proto and math imports to suppress error if they are not otherwise used. +var _ = proto.GetString +var _ = math.Inf + +type CodeGeneratorRequest struct { + FileToGenerate []string `protobuf:"bytes,1,rep,name=file_to_generate" json:"file_to_generate,omitempty"` + Parameter *string `protobuf:"bytes,2,opt,name=parameter" json:"parameter,omitempty"` + ProtoFile []*google_protobuf.FileDescriptorProto `protobuf:"bytes,15,rep,name=proto_file" json:"proto_file,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (this *CodeGeneratorRequest) Reset() { *this = CodeGeneratorRequest{} } +func (this *CodeGeneratorRequest) String() string { return proto.CompactTextString(this) } +func (*CodeGeneratorRequest) ProtoMessage() {} + +func (this *CodeGeneratorRequest) GetParameter() string { + if this != nil && this.Parameter != nil { + return *this.Parameter + } + return "" +} + +type CodeGeneratorResponse struct { + Error *string `protobuf:"bytes,1,opt,name=error" json:"error,omitempty"` + File []*CodeGeneratorResponse_File `protobuf:"bytes,15,rep,name=file" json:"file,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (this *CodeGeneratorResponse) Reset() { *this = CodeGeneratorResponse{} } +func (this *CodeGeneratorResponse) String() string { return proto.CompactTextString(this) } +func (*CodeGeneratorResponse) ProtoMessage() {} + +func (this *CodeGeneratorResponse) GetError() string { + if this != nil && this.Error != nil { + return *this.Error + } + return "" +} + +type CodeGeneratorResponse_File struct { + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + InsertionPoint *string `protobuf:"bytes,2,opt,name=insertion_point" json:"insertion_point,omitempty"` + Content *string `protobuf:"bytes,15,opt,name=content" json:"content,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (this *CodeGeneratorResponse_File) Reset() { *this = CodeGeneratorResponse_File{} } +func (this *CodeGeneratorResponse_File) String() string { return proto.CompactTextString(this) } +func (*CodeGeneratorResponse_File) ProtoMessage() {} + +func (this *CodeGeneratorResponse_File) GetName() string { + if this != nil && this.Name != nil { + return *this.Name + } + return "" +} + +func (this *CodeGeneratorResponse_File) GetInsertionPoint() string { + if this != nil && this.InsertionPoint != nil { + return *this.InsertionPoint + } + return "" +} + +func (this *CodeGeneratorResponse_File) GetContent() string { + if this != nil && this.Content != nil { + return *this.Content + } + return "" +} + +func init() { +} From c62a59a4661fa1059bd696a17d4afbf84bdf0730 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Wed, 6 Apr 2016 14:15:55 +0200 Subject: [PATCH 0086/1304] protobuf: use vendored protoc-gen-go --- rkt/rkt.go | 1 + scripts/genproto.sh | 21 ++++++--------------- vendoredApps | 3 +++ 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/rkt/rkt.go b/rkt/rkt.go index cf87815ca3..407088c928 100644 --- a/rkt/rkt.go +++ b/rkt/rkt.go @@ -27,6 +27,7 @@ import ( "github.com/coreos/rkt/rkt/config" rktflag "github.com/coreos/rkt/rkt/flag" "github.com/spf13/cobra" + _ "github.com/spf13/cobra/doc" // transitive dependency for man page generation ) const ( diff --git a/scripts/genproto.sh b/scripts/genproto.sh index 851de56b33..e536b81851 100755 --- a/scripts/genproto.sh +++ b/scripts/genproto.sh @@ -15,22 +15,13 @@ if ! [[ $(protoc --version) =~ "3.0.0" ]]; then exit 255 fi -export GOPATH=$(mktemp -d) -export PATH=${GOPATH}/bin:${PATH} +export GOPATH=$(godep path) +export PATH=.:${PATH} -trap 'rm -rf "${GOPATH}"' EXIT - -# git (sha) version of golang/protobuf -GO_PROTOBUF_SHA="2402d76f3d41f928c7902a765dfc872356dd3aad" - -echo "installing golang/protobuf using GOPATH=${GOPATH}" -go get -u github.com/golang/protobuf/{proto,protoc-gen-go} - -echo "resetting golang/protobuf to version ${GO_PROTOBUF_SHA}" -pushd ${GOPATH}/src/github.com/golang/protobuf - git reset --hard "${GO_PROTOBUF_SHA}" - make install -popd +echo "building protoc-gen-go" +go build github.com/golang/protobuf/protoc-gen-go +trap 'rm -f "protoc-gen-go"' EXIT +echo "generating code" API_DIR="api/v1alpha" protoc -I "${API_DIR}" "${API_DIR}"/*.proto --go_out=plugins=grpc:"${API_DIR}" diff --git a/vendoredApps b/vendoredApps index a82349b119..e8b00a1c35 100644 --- a/vendoredApps +++ b/vendoredApps @@ -13,3 +13,6 @@ github.com/appc/cni/plugins/meta/tuning # Vendor in ACE, which is used in functional tests github.com/appc/spec/ace + +# Vendor protobuf go generator +github.com/golang/protobuf/protoc-gen-go From 9f297e75960e0f68527f57daf676e72bf001fb01 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Wed, 6 Apr 2016 14:43:29 +0200 Subject: [PATCH 0087/1304] godep: use +doc in favor of +ignore in *_gen.go --- rkt/bash_completion_gen.go | 2 +- rkt/manpages_gen.go | 2 +- rkt/rkt.go | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/rkt/bash_completion_gen.go b/rkt/bash_completion_gen.go index cb6a95a6f6..67fe4bf5be 100644 --- a/rkt/bash_completion_gen.go +++ b/rkt/bash_completion_gen.go @@ -14,7 +14,7 @@ // This file is not part of the rkt binary. It is only executed manually via // the makefile. -//+build ignore +//+build doc package main diff --git a/rkt/manpages_gen.go b/rkt/manpages_gen.go index 1c79adc876..0f07936816 100644 --- a/rkt/manpages_gen.go +++ b/rkt/manpages_gen.go @@ -14,7 +14,7 @@ // This file is not part of the rkt binary. It is only executed manually via // the makefile. -//+build ignore +//+build doc package main diff --git a/rkt/rkt.go b/rkt/rkt.go index 407088c928..cf87815ca3 100644 --- a/rkt/rkt.go +++ b/rkt/rkt.go @@ -27,7 +27,6 @@ import ( "github.com/coreos/rkt/rkt/config" rktflag "github.com/coreos/rkt/rkt/flag" "github.com/spf13/cobra" - _ "github.com/spf13/cobra/doc" // transitive dependency for man page generation ) const ( From 96f65b362258cef064ab3a660faa891bc7366cba Mon Sep 17 00:00:00 2001 From: Rob Szumski Date: Thu, 25 Feb 2016 16:16:58 -0800 Subject: [PATCH 0088/1304] docs: make options table more consistent --- Documentation/subcommands/prepare.md | 14 +++---- Documentation/subcommands/run.md | 55 ++++++++++++++-------------- 2 files changed, 34 insertions(+), 35 deletions(-) diff --git a/Documentation/subcommands/prepare.md b/Documentation/subcommands/prepare.md index 0c9df9ca45..9d968c973b 100644 --- a/Documentation/subcommands/prepare.md +++ b/Documentation/subcommands/prepare.md @@ -34,13 +34,13 @@ c9fad0e6-8236-4fc2-ad17-55d0a4c7d742 | Flag | Default | Options | Description | | --- | --- | --- | --- | -| `--exec` | `` | A path | Override the exec command for the preceding image | -| `--inherit-env` | `false` | `true` or `false` | Inherit all environment variables not set by apps | -| `--mount` | `` | Mount syntax (`volume=NAME,target=PATH`). See [Mounting Volumes without Mount Points](run.md#mounting-volumes-without-mount-points) | Mount point binding a volume to a path within an app | -| `--no-overlay` | `false` | `true` or `false` | Disable overlay filesystem | -| `--no-store` | `false` | `true` or `false` | Fetch images, ignoring the local store. See [image fetching behavior](../image-fetching-behavior.md) | -| `--pod-manifest` | `` | A path | The path to the pod manifest. If it's non-empty, then only `--net`, `--no-overlay` and `--interactive` will have effect | -| `--port` | `` | A port number | Ports to expose on the host (requires [contained network](https://github.com/coreos/rkt/blob/master/Documentation/networking.md#contained-mode)). Syntax: --port=NAME:HOSTPORT | +| `--exec` | none | Path to executable | Override the exec command for the preceding image. | +| `--inherit-env` | `false` | `true` or `false` | Inherit all environment variables not set by apps. | +| `--mount` | none | Mount syntax (ex. `--mount volume=NAME,target=PATH`) | Mount point binding a volume to a path within an app. See [Mounting Volumes without Mount Points](#mounting-volumes-without-mount-points). | +| `--no-overlay` | `false` | `true` or `false` | Disable the overlay filesystem. | +| `--no-store` | `false` | `true` or `false` | Fetch images, ignoring the local store. See [image fetching behavior](../image-fetching-behavior.md) | +| `--pod-manifest` | none | A path | The path to the pod manifest. If it's non-empty, then only `--net`, `--no-overlay` and `--interactive` will have effect. | +| `--port` | none | A port number (ex. `--port=NAME:HOSTPORT`) | Ports to expose on the host (requires [contained network](../networking.md#contained-mode)). | | `--private-users` | `false` | `true` or `false` | Run within user namespaces (experimental) | | `--quiet` | `false` | `true` or `false` | Suppress superfluous output on stdout, print only the UUID on success | | `--set-env` | `` | An environment variable. Syntax `NAME=VALUE` | An environment variable to set for apps | diff --git a/Documentation/subcommands/run.md b/Documentation/subcommands/run.md index 613ea9f28c..d2971c6662 100644 --- a/Documentation/subcommands/run.md +++ b/Documentation/subcommands/run.md @@ -327,34 +327,33 @@ For more details see the [hacking documentation](../hacking.md). | Flag | Default | Options | Description | | --- | --- | --- | --- | -| `--cpu` | `` | CPU units (example `--cpu=500m`, see the [Kubernetes resource model](http://kubernetes.io/v1.1/docs/design/resources.html)) | CPU limit for the preceding image | -| `--dns` | `` | IP Address | Name server to write in `/etc/resolv.conf`. It can be specified several times | -| `--dns-opt` | `` | Option as described in the options section in resolv.conf(5) | DNS option to write in `/etc/resolv.conf`. It can be specified several times | -| `--dns-search` | `` | Domain name | DNS search domain to write in `/etc/resolv.conf`. It can be specified several times | -| `--exec` | `` | A path | Override the exec command for the preceding image | -| `--hostname` | `` | A host name | Pod's hostname. If empty, it will be "rkt-$PODUUID" | -| `--inherit-env` | `false` | `true` or `false` | Inherit all environment variables not set by apps | -| `--interactive` | `false` | `true` or `false` | Run pod interactively. If true, only one image may be supplied | -| `--mds-register` | `false` | `true` or `false` | Register pod with metadata service. It needs network connectivity to the host (`--net=(default|default-restricted|host)` | -| `--memory` | `` | Memory units (example '--memory=50M', see the [Kubernetes resource model](http://kubernetes.io/v1.1/docs/design/resources.html)) | Memory limit for the preceding image | -| `--mount` | `` | Mount syntax (`volume=NAME,target=PATH`). See [Mounting Volumes without Mount Points](#mounting-volumes-without-mount-points) | Mount point binding a volume to a path within an app | -| `--net` | `default` | A comma-separated list of networks. Syntax: `--net[=n[:args], ...]` | Configure the pod's networking. Optionally, pass a list of user-configured networks to load and set arguments to pass to each network, respectively | -| `--no-overlay` | `false` | `true` or `false` | Disable overlay filesystem | -| `--no-store` | `false` | `true` or `false` | Fetch images, ignoring the local store. See [image fetching behavior](../image-fetching-behavior.md) | -| `--pod-manifest` | `` | A path | The path to the pod manifest. If it's non-empty, then only `--net`, `--no-overlay` and `--interactive` will have effect | -| `--port` | `` | A port number | Ports to expose on the host (requires [contained network](https://github.com/coreos/rkt/blob/master/Documentation/networking/overview.md#contained-mode)). Syntax: `--port=NAME:HOSTPORT` The NAME is that given in the ACI. By convention, Docker containers' EXPOSEd ports are given a name formed from the port number, a hyphen, and the protocol, e.g., `80-tcp`, giving something like `--port=80-tcp:8080` | -| `--private-users` | `false` | `true` or `false` | Run within user namespaces (experimental) | -| `--set-env` | `` | An environment variable. Syntax `NAME=VALUE` | An environment variable to set for apps | -| `--signature` | `` | A file path | Local signature file to use in validating the preceding image | -| `--stage1-url` | `` | A URL to a stage1 image. HTTP/HTTPS/File/Docker URLs are supported | Image to use as stage1 | -| `--stage1-path` | `` | A path to a stage1 image. Absolute and relative paths are supported | Image to use as stage1 | -| `--stage1-name` | `` | A name of a stage1 image. Will perform a discovery if the image is not in the store | Image to use as stage1 | -| `--stage1-hash` | `` | A hash of a stage1 image. The image must exist in the store | Image to use as stage1 | -| `--stage1-from-dir` | `` | A stage1 image file inside the default stage1 images directory | Image to use as stage1 | -| `--store-only` | `false` | `true` or `false` | Use only available images in the store (do not discover or download from remote URLs). See [image fetching behavior](../image-fetching-behavior.md) | -| `--uuid-file-save` | `` | A file path | Write out the pod UUID to a file | -| `--volume` | `` | Volume syntax (`NAME,kind=KIND,source=PATH,readOnly=BOOL`). See [Mount Volumes into a Pod](#mount-volumes-into-a-pod) | Volumes to make available in the pod | +| `--cpu` | none | CPU units (ex. `--cpu=500m`) | CPU limit for the preceding image in [Kubernetes resource model](http://kubernetes.io/v1.1/docs/design/resources.html) format. | +| `--dns` | none | IP Address | Name server to write in `/etc/resolv.conf`. It can be specified several times | +| `--dns-opt` | none | DNS option | DNS option from resolv.conf(5) to write in `/etc/resolv.conf`. It can be specified several times. | +| `--dns-search` | none | Domain name | DNS search domain to write in `/etc/resolv.conf`. It can be specified several times. | +| `--exec` | none | Path to executable | Override the exec command for the preceding image. | +| `--inherit-env` | `false` | `true` or `false` | Inherit all environment variables not set by apps. | +| `--interactive` | `false` | `true` or `false` | Run pod interactively. If true, only one image may be supplied. | +| `--mds-register` | `false` | `true` or `false` | Register pod with metadata service. It needs network connectivity to the host (`--net` as `default`, `default-restricted`, or `host`). | +| `--memory` | none | Memory units (ex. `--memory=50M`) | Memory limit for the preceding image in [Kubernetes resource model](http://kubernetes.io/v1.1/docs/design/resources.html) format. | +| `--mount` | none | Mount syntax (ex. `--mount volume=NAME,target=PATH`) | Mount point binding a volume to a path within an app. See [Mounting Volumes without Mount Points](#mounting-volumes-without-mount-points). | +| `--net` | `default` | A comma-separated list of networks. (ex. `--net[=n[:args], ...]`) | Configure the pod's networking. Optionally, pass a list of user-configured networks to load and set arguments to pass to each network, respectively. | +| `--no-overlay` | `false` | `true` or `false` | Disable the overlay filesystem. | +| `--no-store` | `false` | `true` or `false` | Fetch images, ignoring the local store. See [image fetching behavior](../image-fetching-behavior.md) | +| `--pod-manifest` | none | A path | The path to the pod manifest. If it's non-empty, then only `--net`, `--no-overlay` and `--interactive` will have effect. | +| `--port` | none | A port number (ex. `--port=NAME:HOSTPORT`) | Ports to expose on the host (requires [contained network](../networking.md#contained-mode)). | +| `--private-users` | `false` | `true` or `false` | Run within user namespaces (experimental). | +| `--set-env` | none | An environment variable (ex. `--set-env=NAME=VALUE`) | An environment variable to set for apps. | +| `--signature` | none | A file path | Local signature file to use in validating the preceding image | +| `--stage1-url` | none | URL with protocol | A URL to a stage1 image. HTTP/HTTPS/File/Docker URLs are supported. | +| `--stage1-path` | none | Absolute or relative path | A path to a stage1 image. | +| `--stage1-name` | none | Image name (ex. `--stage1-name=coreos.com/rkt/stage1-coreos`) | A name of a stage1 image. Will perform a discovery if the image is not in the store. | +| `--stage1-hash` | none | Image hash (ex. `--stage1-hash=sha512-dedce9f5ea50`) | A hash of a stage1 image. The image must exist in the store. | +| `--stage1-from-dir` | none | Image name (ex. `--stage1-name=coreos.com/rkt/stage1-coreos`) | A stage1 image file name to search for inside the default stage1 images directory. | +| `--store-only` | `false` | `true` or `false` | Use only available images in the store (do not discover or download from remote URLs). See [image fetching behavior](../image-fetching-behavior.md). | +| `--uuid-file-save` | none | A file path | Write out the pod UUID to a file. | +| `--volume` | none | Volume syntax (ex. `--volume NAME,kind=KIND,source=PATH,readOnly=BOOL`) | Volumes to make available in the pod. See [Mount Volumes into a Pod](#mount-volumes-into-a-pod). | ## Global options -See the table with [global options in general commands documentation](../commands.md#global-options). +See the table with [global options in general commands documentation](../commands.md#global-options). \ No newline at end of file From 28add4d037a4fa49b21019a4fc1610eeecbe1455 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Thu, 7 Apr 2016 18:51:14 +0200 Subject: [PATCH 0089/1304] tests: TestDockerVolumeSemantics: more tests with symlinks I tried to reproduce the issue mentioned in: https://github.com/coreos/rkt/pull/2290#issuecomment-206003364 However, the tests pass fine for me. Nevertheless, this test is worth adding. --- tests/rkt_volume_test.go | 42 ++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/tests/rkt_volume_test.go b/tests/rkt_volume_test.go index 6f9a7abae2..2a25650b16 100644 --- a/tests/rkt_volume_test.go +++ b/tests/rkt_volume_test.go @@ -142,15 +142,45 @@ func TestVolumes(t *testing.T) { } } -func TestDockerVolumeSemantics(t *testing.T) { - dockerVolImage := patchTestACI("rkt-volume-image.aci", fmt.Sprintf("--mounts=dir1,path=/dir1,readOnly=false")) - defer os.Remove(dockerVolImage) +var volDockerTests = []struct { + dir string + expectedContent string +}{ + { + "/dir1", + "dir1", + }, + { + "/dir2", + "dir2", + }, + { + "/dir1/link_rel_dir2", + "dir2", + }, + { + "/dir1/link_abs_dir2", + "dir2", + }, +} +func TestDockerVolumeSemantics(t *testing.T) { ctx := testutils.NewRktRunCtx() defer ctx.Cleanup() - cmd := fmt.Sprintf(`/bin/sh -c "export FILE=/dir1/file ; %s --debug --insecure-options=image run --inherit-env %s --exec /inspect -- --read-file"`, ctx.Cmd(), dockerVolImage) + var dockerVolImage []string + for _, tt := range volDockerTests { + img := patchTestACI("rkt-volume-image.aci", fmt.Sprintf("--mounts=mydir,path=%s,readOnly=false", tt.dir)) + defer os.Remove(img) + dockerVolImage = append(dockerVolImage, img) + } + + for i, tt := range volDockerTests { + t.Logf("Running test #%v on directory %s", i, tt.dir) - expected := "<<>>" - runRktAndCheckOutput(t, cmd, expected, false) + cmd := fmt.Sprintf(`/bin/sh -c "export FILE=%s/file ; %s --debug --insecure-options=image run --inherit-env %s --exec /inspect -- --read-file"`, tt.dir, ctx.Cmd(), dockerVolImage[i]) + + expected := fmt.Sprintf("<<<%s>>>", tt.expectedContent) + runRktAndCheckOutput(t, cmd, expected, false) + } } From e9a00d7324936ec00525265ec8ceae3ea584cf8d Mon Sep 17 00:00:00 2001 From: mstachowski Date: Fri, 18 Mar 2016 11:44:51 +0100 Subject: [PATCH 0090/1304] rkt: Improve build shell script Rework of run-build shell script. New run-build script will have got following features: - Add temporary build files cleanup (during Semaphore build, it improve test stability) - DONE - Split script body into functions - DONE - Add better argument parsing - DONE - Fix build directory name - DONE --- tests/README.md | 23 ++- tests/build-and-run-tests.sh | 251 +++++++++++++++++++++++++++++++ tests/cloudinit/centos.cloudinit | 2 +- tests/cloudinit/debian.cloudinit | 2 +- tests/cloudinit/fedora.cloudinit | 2 +- tests/cloudinit/ubuntu.cloudinit | 2 +- tests/run-build.sh | 119 --------------- 7 files changed, 271 insertions(+), 130 deletions(-) create mode 100755 tests/build-and-run-tests.sh delete mode 100755 tests/run-build.sh diff --git a/tests/README.md b/tests/README.md index b9b7bb2f12..f2e062422a 100644 --- a/tests/README.md +++ b/tests/README.md @@ -35,15 +35,15 @@ sudo gpasswd -a runner rkt #### Thread 1 ``` -./tests/run-build.sh none -./tests/run-build.sh src v229 +./tests/build-and-run-tests.sh -f none -c +./tests/build-and-run-tests.sh -f src -s v229 -c ``` #### Thread 2 ``` -./tests/run-build.sh coreos -./tests/run-build.sh host +./tests/build-and-run-tests.sh -f coreos -c +./tests/build-and-run-tests.sh -f host -c ``` #### Post thread @@ -58,11 +58,20 @@ The LKVM stage1 or other versions of systemd are not currently tested. It would be possible to add more tests with the following commands: ``` -./tests/run-build.sh src v227 -./tests/run-build.sh src master -./tests/run-build.sh kvm +./tests/build-and-run-tests.sh -f src -s v227 -c +./tests/build-and-run-tests.sh -f src -s master -c +./tests/build-and-run-tests.sh -f kvm -c ``` +#### build-and-run-tests.sh parameters description + +The build script has the following parameters: +- `-f` - Select flavor for rkt. You can choose only one from the following list: "`coreos`, `host`, `kvm`, `none`, `src`". +- `-s` - Systemd version. You can choose `master` or a tag from the [systemd GitHub repository](https://github.com/systemd/systemd). +- `-c` - Run cleanup. Cleanup has two phases: *after build* and *after tests*. In the *after build* phase, this script removes artifacts from external dependencies (like kernel sources in the `kvm` flavor). In the *after tests* phase, it removes `rkt` build artifacts and (if the build is running on CI or if the `-x` flag is used) it unmounts the remaining `rkt` mountpoints, removes unused `rkt` NICs and flushes the current state of IPAM IP reservation. +- `-x` - Force after-test cleanup on a non-CI system. **WARNING: This flag can affect your system. Use with caution.** +- `-u` - Show usage message and exit. + ### Platform Select `Ubuntu 14.04 LTS v1503 (beta with Docker support)`. diff --git a/tests/build-and-run-tests.sh b/tests/build-and-run-tests.sh new file mode 100755 index 0000000000..5a2363da9e --- /dev/null +++ b/tests/build-and-run-tests.sh @@ -0,0 +1,251 @@ +#!/usr/bin/env bash + +set -ex + +# Clean up environment after build. It is flushing every assigned IP address via IPAM, umounting every +# mountpoint and removing unused links +function cleanup { + if [[ "${POSTCLEANUP}" == true ]]; then + if [[ "${CI}" == true || "${FORCE}" == true ]]; then + for mp in $(mount | grep rkt | awk '{print $3}' | tac); do + sudo umount "${mp}" + done + + for link in $(ip link | grep rkt | cut -d':' -f2); do + sudo ip link del "${link}" + done + sudo rm -rf /var/lib/cni/networks/* + fi + sudo rm -rf "${BUILD_DIR}" + fi +} + +# Skip build on demand. It requires the `last-commit` file inside the last commit. +function ciSkip { + cat last-commit + echo + echo "Build skipped as requested in the last commit." + exit 0 +} + +# Configure SemaphoreCI environment. +function semaphoreConfiguration { + # We might not need to run functional tests or process docs. + # This is best-effort; || true ensures this does not affect test outcome + # First, ensure origin is updated - semaphore can do some weird caching + git fetch || true + SRC_CHANGES=$(git diff-tree --no-commit-id --name-only -r HEAD..origin/master | grep -cEv ${DOC_CHANGE_PATTERN}) || true + DOC_CHANGES=$(git diff-tree --no-commit-id --name-only -r HEAD..origin/master | grep -cE ${DOC_CHANGE_PATTERN}) || true + + # Set up go environment on semaphore + if [ -f /opt/change-go-version.sh ]; then + . /opt/change-go-version.sh + change-go-version 1.5 + + # systemd v229 doesn't build on gcc-4.8, set the compiler to gcc-5 + export CC=gcc-5 + fi +} + +function checkFlavorValue { + FLAVORS="coreos host kvm none src" + if [ -z "${RKT_STAGE1_USR_FROM}" ]; then + set - + echo "Flavor is not set" + exit 1 + fi + if ! [[ "${FLAVORS}" =~ "${RKT_STAGE1_USR_FROM}" ]]; then + set - + echo "Unknown flavor: ${RKT_STAGE1_USR_FROM}" + echo "Available flavors: ${FLAVORS}" + exit 1 + fi +} + +# Parse user provided parameters +function parseParameters { + while getopts "f:s:cxu" option; do + case ${option} in + f) + RKT_STAGE1_USR_FROM="${OPTARG}" + ;; + s) + if [[ $RKT_STAGE1_USR_FROM == "src" ]]; then + RKT_STAGE1_SYSTEMD_VER="${OPTARG}" + else + echo "Only \`src\` flavor requires systemd version" + fi + ;; + x) + FORCE=true + ;; + u) + set - + usage + exit 0 + ;; + c) + PRECLEANUP=true + POSTCLEANUP=true + ;; + \?) + set - + echo "Invalid parameter -${OPTARG}" + usage + exit 1 + ;; + esac + done + checkFlavorValue +} + +# Configure build +function configure { + case "${RKT_STAGE1_USR_FROM}" in + coreos|kvm) + ./configure --with-stage1-flavors="${RKT_STAGE1_USR_FROM}" \ + --with-stage1-default-flavor="${RKT_STAGE1_USR_FROM}" \ + --enable-functional-tests --enable-tpm=auto \ + --enable-insecure-go + ;; + host) + ./configure --with-stage1-flavors=host \ + --with-default-stage1-flavor=host \ + --enable-functional-tests=auto --enable-tpm=auto \ + --enable-insecure-go + ;; + src) + ./configure --with-stage1-flavors="${RKT_STAGE1_USR_FROM}" \ + --with-stage1-default-flavor="${RKT_STAGE1_USR_FROM}" \ + --with-stage1-systemd-version="${RKT_STAGE1_SYSTEMD_VER}" \ + --enable-functional-tests --enable-tpm=auto \ + --enable-insecure-go + ;; + none) + # Not a flavor per se, so perform a detailed setup for some + # hypothetical 3rd party stage1 image + ./configure --with-stage1-default-name="example.com/some-stage1-for-rkt" \ + --with-stage1-default-version="0.0.1" --enable-tpm=auto \ + --enable-insecure-go + ;; + *) + echo "Unknown flavor: ${RKT_STAGE1_USR_FROM}" + exit 1 + ;; + esac +} + +# Build rkt and run unit & functional tests +function build { + ./autogen.sh + + configure + + CORES=$(grep -c ^processor /proc/cpuinfo) + echo "Running make with ${CORES} threads" + make "-j${CORES}" + + if [[ ${PRECLEANUP} == true ]]; then + rm -rf "${BUILD_DIR}/tmp/usr_from_${RKT_STAGE1_USR_FROM}" + fi + + make check + make "-j${CORES}" clean +} + +# Prepare build directory name +function buildFolder { + if [[ "${RKT_STAGE1_USR_FROM}" == "src" ]]; then + POSTFIX="-${RKT_STAGE1_SYSTEMD_VER}" + fi + BUILD_DIR="build-rkt-${RKT_STAGE1_USR_FROM}${POSTFIX}" +} + +# Detect changes from last commit. If there is no changes, there is no +# need to run build +function detectChanges { + HEAD=`git rev-parse HEAD` + MASTER=`git rev-parse origin/master` + if [[ ${HEAD} != ${MASTER} ]]; then + SRC_CHANGES=1 + DOC_CHANGES=1 + elif [[ ${SRC_CHANGES} -eq 0 && ${DOC_CHANGES} -eq 0 ]]; then + echo "No changes detected and HEAD is not origin/master" + exit 0 + fi +} + +# Clone source code into build directory +function cloneCode { + detectChanges + git clone ../ "${BUILD_DIR}" + pushd "${BUILD_DIR}" +} + +# Show usage +function usage { + echo "build-and-run-tests.sh usage:" + echo -e "-f\tSelect flavor" + echo -e "-s\tSystemd version" + echo -e "-c\tCleanup" + echo -e "-x\tUse with '-c' to force cleanup on non-CI systems" + echo -e "-u\tShow this message" +} + +# Prepare build environment +function prepareBuildEnv { + # In case it wasn't cleaned up + if [ -e "builds/${BUILD_DIR}" ]; then + sudo rm -rf "builds/${BUILD_DIR}" + fi + mkdir -p builds +} + +# Run docs scan +function docsScan { + : + # echo Changes in docs detected, checking docs. + # TODO check for broken links + # TODO check for obvious spelling mistakes: + # coreos -> CoreOS + # More?! +} + +function main { + # Skip build if requested + if test -e ci-skip ; then + ciSkip + fi + + SRC_CHANGES=1 # run functional tests by default + DOC_CHANGES=1 # process docs by default + + parseParameters "${@}" + + DOC_CHANGE_PATTERN="\ + -e ^Documentation/ \ + -e ^(README|ROADMAP|CONTRIBUTING|CHANGELOG)$ \ + -e \.md$\ + " + + buildFolder + + # https://semaphoreci.com/docs/available-environment-variables.html + if [ "${SEMAPHORE-}" == true ] ; then + semaphoreConfiguration + fi + + prepareBuildEnv + cd builds + cloneCode + + if [ ${SRC_CHANGES} -gt 0 ]; then + build + fi + if [ ${DOC_CHANGES} -gt 0 ]; then + docsScan + fi + cleanup +} + +main "${@}" diff --git a/tests/cloudinit/centos.cloudinit b/tests/cloudinit/centos.cloudinit index 3f4a7e5142..5e65d4abe1 100644 --- a/tests/cloudinit/centos.cloudinit +++ b/tests/cloudinit/centos.cloudinit @@ -35,7 +35,7 @@ export PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/centos/.loca sed -i 's/ requiretty$/ !requiretty/g' /etc/sudoers su - centos --command="cd /var/tmp ; git clone --branch @GIT_BRANCH@ @GIT_URL@ rkt" -su - centos --command="PATH=\$PATH ; cd /var/tmp/rkt ; ./tests/run-build.sh @FLAVOR@" +su - centos --command="PATH=\$PATH ; cd /var/tmp/rkt ; ./tests/build-and-run-tests.sh -f @FLAVOR@" TESTEOF chmod +x /var/tmp/rkt-test.sh diff --git a/tests/cloudinit/debian.cloudinit b/tests/cloudinit/debian.cloudinit index da347913b2..7c8858639a 100644 --- a/tests/cloudinit/debian.cloudinit +++ b/tests/cloudinit/debian.cloudinit @@ -20,7 +20,7 @@ apt-get install -y --force-yes build-essential autoconf apt-get install -y --force-yes wget squashfs-tools patch gnupg golang git dbus libacl1-dev systemd-container su - admin --command="cd /var/tmp ; git clone --branch @GIT_BRANCH@ @GIT_URL@ rkt" -su - admin --command="PATH=\$PATH ; cd /var/tmp/rkt ; ./tests/run-build.sh @FLAVOR@" +su - admin --command="PATH=\$PATH ; cd /var/tmp/rkt ; ./tests/build-and-run-tests.sh -f @FLAVOR@" TESTEOF chmod +x /var/tmp/rkt-test.sh diff --git a/tests/cloudinit/fedora.cloudinit b/tests/cloudinit/fedora.cloudinit index eabe16a70c..aa900ef3d9 100644 --- a/tests/cloudinit/fedora.cloudinit +++ b/tests/cloudinit/fedora.cloudinit @@ -33,7 +33,7 @@ dnf -y -v install systemd-container || true export PATH=/usr/lib64/ccache:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/fedora/.local/bin:/home/fedora/bin su - fedora --command="cd /var/tmp ; git clone --branch @GIT_BRANCH@ @GIT_URL@ rkt" -su - fedora --command="PATH=\$PATH ; cd /var/tmp/rkt ; ./tests/run-build.sh @FLAVOR@" +su - fedora --command="PATH=\$PATH ; cd /var/tmp/rkt ; ./tests/build-and-run-tests.sh -f @FLAVOR@" TESTEOF chmod +x /var/tmp/rkt-test.sh diff --git a/tests/cloudinit/ubuntu.cloudinit b/tests/cloudinit/ubuntu.cloudinit index 65521e6d8c..22f848ec36 100644 --- a/tests/cloudinit/ubuntu.cloudinit +++ b/tests/cloudinit/ubuntu.cloudinit @@ -19,7 +19,7 @@ apt-get install -y build-essential autoconf apt-get install -y wget squashfs-tools patch gnupg golang libacl1-dev systemd-container su - ubuntu --command="cd /var/tmp ; git clone --branch @GIT_BRANCH@ @GIT_URL@ rkt" -su - ubuntu --command="PATH=\$PATH ; cd /var/tmp/rkt ; ./tests/run-build.sh @FLAVOR@" +su - ubuntu --command="PATH=\$PATH ; cd /var/tmp/rkt ; ./tests/build-and-run-tests.sh -f @FLAVOR@" TESTEOF chmod +x /var/tmp/rkt-test.sh diff --git a/tests/run-build.sh b/tests/run-build.sh deleted file mode 100755 index db694b5353..0000000000 --- a/tests/run-build.sh +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/env bash - -set -ex - -# Skip build if requested -if test -e ci-skip ; then - cat last-commit - echo - echo "Build skipped as requested in the last commit." - exit 0 -fi - -SRC_CHANGES=1 # run functional tests by default -DOC_CHANGES=1 # process docs by default -DOC_CHANGE_PATTERN="\ - -e ^Documentation/ \ - -e ^(README|ROADMAP|CONTRIBUTING|CHANGELOG)$ \ - -e \.md$\ -" - -RKT_STAGE1_USR_FROM="${1}" -RKT_STAGE1_SYSTEMD_VER="${2}" -BUILD_DIR="build-rkt-${RKT_STAGE1_USR_FROM}-${RKT_STAGE1_SYSTEMD_VER}" - -# https://semaphoreci.com/docs/available-environment-variables.html -if [ "${SEMAPHORE-}" == true ] ; then - # We might not need to run functional tests or process docs. - # This is best-effort; || true ensures this does not affect test outcome - # First, ensure origin is updated - semaphore can do some weird caching - git fetch || true - SRC_CHANGES=$(git diff-tree --no-commit-id --name-only -r HEAD..origin/master | grep -cEv ${DOC_CHANGE_PATTERN}) || true - DOC_CHANGES=$(git diff-tree --no-commit-id --name-only -r HEAD..origin/master | grep -cE ${DOC_CHANGE_PATTERN}) || true - - # Set up go environment on semaphore - if [ -f /opt/change-go-version.sh ]; then - . /opt/change-go-version.sh - change-go-version 1.5 - fi - - # systemd v229 doesn't build on gcc-4.8, set the compiler to gcc-5 - export CC=gcc-5 -fi - -HEAD=`git rev-parse HEAD` -MASTER=`git rev-parse origin/master` -if [[ ${HEAD} == ${MASTER} ]]; then - SRC_CHANGES=1 - DOC_CHANGES=1 -elif [[ ${SRC_CHANGES} -eq 0 && ${DOC_CHANGES} -eq 0 ]]; then - echo "No changes detected and HEAD is not origin/master" - exit 0 -fi - -# In case it wasn't cleaned up -if [ -e "${BUILD_DIR}" ]; then - sudo rm -rf "${BUILD_DIR}" -fi - -mkdir -p builds -cd builds - -git clone ../ "${BUILD_DIR}" -pushd "${BUILD_DIR}" - -if [ ${SRC_CHANGES} -gt 0 ]; then - echo "Changes in sources detected. Running functional tests." - ./autogen.sh - case "${RKT_STAGE1_USR_FROM}" in - coreos|kvm) - ./configure --with-stage1-flavors="${RKT_STAGE1_USR_FROM}" \ - --with-stage1-default-flavor="${RKT_STAGE1_USR_FROM}" \ - --enable-functional-tests --enable-tpm=auto \ - --enable-insecure-go - ;; - host) - ./configure --with-stage1-flavors=host \ - --with-default-stage1-flavor=host \ - --enable-functional-tests=auto --enable-tpm=auto \ - --enable-insecure-go - ;; - src) - ./configure --with-stage1-flavors="${RKT_STAGE1_USR_FROM}" \ - --with-stage1-default-flavor="${RKT_STAGE1_USR_FROM}" \ - --with-stage1-systemd-version="${RKT_STAGE1_SYSTEMD_VER}" \ - --enable-functional-tests --enable-tpm=auto \ - --enable-insecure-go - ;; - none) - # Not a flavor per se, so perform a detailed setup for some - # hypothetical 3rd party stage1 image - ./configure --with-stage1-default-name="example.com/some-stage1-for-rkt" \ - --with-stage1-default-version="0.0.1" --enable-tpm=auto \ - --enable-insecure-go - ;; - *) - echo "Unknown flavor: ${RKT_STAGE1_USR_FROM}" - exit 1 - ;; - esac - - CORES=$(grep -c ^processor /proc/cpuinfo) - echo "Running make with ${CORES} threads" - make "-j${CORES}" - make check - make "-j${CORES}" clean -fi -if [ ${DOC_CHANGES} -gt 0 ]; then - : - # echo Changes in docs detected, checking docs. - # TODO check for broken links - # TODO check for obvious spelling mistakes: - # coreos -> CoreOS - # More?! -fi - -popd - -# Make sure there is enough disk space for the next build -sudo rm -rf "${BUILD_DIR}" From 53104d09eb789ffd1ddd62883d9cf38854dfcef9 Mon Sep 17 00:00:00 2001 From: Simone Gotti Date: Fri, 8 Apr 2016 13:02:01 +0200 Subject: [PATCH 0091/1304] store: fix multi process and multi goroutines race on db. When there are multiple OS processes concurrently accessing the ql db and at least one of them has multiple goroutines using a shared store instance the internal ql (camlistore based) locking error: `cannot acquire lock: resource temporarily unavailable` can be triggered. For example: Process A, goroutine 1: takes the the flock, then takes the lock on the mutex, and do db.Open Process A, goroutine 2: takes the flock, blocks on the lock on the mutex Process A, goroutine 1: does something on db, calls db.Close, unlocks the flock, release the lock on the mutex Process A, goroutine 2: takes the lock on the mutex, but now it has the flock UNLOCKED Process B, goroutine 1: take the lock on the flock and then takes lock on the mutex (since it's another process): the ql internal camlistore lock will fail. In the code there's already a locking made by a mutex, but looks like it was put just there to make the go race detector happy and the lock/unlock order is wrong. Instead this is really needed. This patch fixes the lock/unlock order. A future test to really test this problem will need to spawn two processes with one at least using multiple goroutines using the same store instance. Here an example repro: ``` package main import ( "fmt" "os" "github.com/coreos/rkt/store" ) func main() { s, err := store.NewStore("/tmp/test/rkt") if err != nil { fmt.Printf("cannot open store: %v", err) os.Exit(1) } runs := 10000 for i := 0; i < runs; i++ { go func() { _, err = s.GetAllACIInfos(nil, false) if err != nil { fmt.Printf("cannot query db: %v", err) os.Exit(1) } }() } s.Close() } ``` compile and execute the above command with something like: ``` #!/bin/bash while true; do for i in $(seq 0 2); do ./test01 & done wait done ``` --- store/db.go | 41 ++++++++++++++++++++++++++++++----------- store/db_test.go | 3 +++ 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/store/db.go b/store/db.go index 26edcc1bfb..d326760a93 100644 --- a/store/db.go +++ b/store/db.go @@ -17,6 +17,7 @@ package store import ( "database/sql" "errors" + "fmt" "os" "path/filepath" "sync" @@ -34,9 +35,11 @@ const ( // dbLock is used to guarantee both thread-safety and process-safety // for db access. type dbLock struct { + // This lock is to make that access to the ql db file being blocking + // since ql use an internal locking that will not block and return an + // error when a lock is already held. fl *lock.FileLock - // Although the FileLock already ensures thread safety, the Go runtime is unaware - // of this, and so Mutex is necessary to satisfy the Go race detector. + // This lock is to avoid concurrent access from multiple goroutines. sync.Mutex } @@ -49,19 +52,37 @@ func newDBLock(dirPath string) (*dbLock, error) { } func (dl *dbLock) lock() error { + dl.Lock() if err := dl.fl.ExclusiveLock(); err != nil { + dl.Unlock() return err } - dl.Lock() return nil } -func (dl *dbLock) unlock() error { +func (dl *dbLock) unlock() { if err := dl.fl.Unlock(); err != nil { - return err + // TODO(sgotti) what'll happen when df.fl.Unlock fails? From + // man 2 flock looks like it'll happen only when the underlying + // fd has been closed (in this case the lock has been released + // when the fd has been closed, assuming no dup fd due to + // forking etc...). + + // If there're other cases where it fails without unlocking, + // there's no simple way to handle them. + // Possible solutions: + // * panic (done here) + // * try to close the lock (and related fd), panic if close + // fails and create a new lock. + // + // Passing a specific error to the caller and let it recover + // creating a new store instance is tricky because we + // don't know the lock state and cannot be sure on how to clean + // this store instance + + panic(fmt.Errorf("failed to unlock the db flock: %v", err)) } dl.Unlock() - return nil } type DB struct { @@ -90,10 +111,7 @@ func (db *DB) Open() error { sqldb, err := sql.Open("ql", filepath.Join(db.dbdir, DbFilename)) if err != nil { - unlockErr := db.dl.unlock() - if unlockErr != nil { - err = errwrap.Wrap(unlockErr, err) - } + db.dl.unlock() return err } db.sqldb = sqldb @@ -112,7 +130,8 @@ func (db *DB) Close() error { db.sqldb = nil // Don't close the flock as it will be reused. - return db.dl.unlock() + db.dl.unlock() + return nil } func (db *DB) Begin() (*sql.Tx, error) { diff --git a/store/db_test.go b/store/db_test.go index 895d6ec019..a639c4f48c 100644 --- a/store/db_test.go +++ b/store/db_test.go @@ -78,6 +78,9 @@ func createTable(db *DB, t *testing.T) { } func TestDBRace(t *testing.T) { + // TODO(sgotti) this will not find concurrenct accesses to ql db from + // multiple processes using multiple goroutines. A test that spawns at + // least two processes using multiple goroutines is needed. oldGoMaxProcs := runtime.GOMAXPROCS(runtime.NumCPU()) defer runtime.GOMAXPROCS(oldGoMaxProcs) From c5cb65a85d231a230a18c2f35f0492a19c4e3106 Mon Sep 17 00:00:00 2001 From: Piotr Skamruk Date: Wed, 23 Mar 2016 16:34:03 +0100 Subject: [PATCH 0092/1304] kvm: new volumes support --- stage1/init/common/kvm_mount.go | 267 +++++---------------------- stage1/init/common/kvm_mount_test.go | 68 ------- stage1/init/common/pod.go | 5 +- stage1/init/init.go | 6 +- stage1/init/kvm.go | 19 +- 5 files changed, 53 insertions(+), 312 deletions(-) delete mode 100644 stage1/init/common/kvm_mount_test.go diff --git a/stage1/init/common/kvm_mount.go b/stage1/init/common/kvm_mount.go index 08b37f007b..b7efc44a7b 100644 --- a/stage1/init/common/kvm_mount.go +++ b/stage1/init/common/kvm_mount.go @@ -12,260 +12,89 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Package common and the file kvm_mount.go provide functions for creating mount units for managing -// inner(kind=empty) and external(kind=host) volumes. -// note: used only for kvm flavor (lkvm based) -// -// Idea. -// For example when we have two volumes: -// 1) --volume=hostdata,kind=host,source=/host/some_data_to_share -// 2) --volume=temporary,kind=empty -// then in stage1/rootfs rkt creates two folders (in rootfs of guest) -// 1) /mnt/hostdata - which is mounted through 9p host thanks to -// lkvm --9p=/host/some_data_to_share,hostdata flag shared to quest -// 2) /mnt/temporary - is created as empty directory in guest -// -// both of them are then bind mounted to /opt/stage2/ -// for every application, that has mountPoints specified in ACI json -// - host mounting is realized by podToSystemdHostMountUnits (for whole pod), -// which creates mount.units (9p) required and ordered before all applications -// service units -// - bind mounting is realized by appToSystemdMountUnits (for each app), -// which creates mount.units (bind) required and ordered before particular application -// note: systemd mount units require /usr/bin/mount package common import ( - "crypto/md5" - "encoding/hex" "errors" "fmt" - "io" - "io/ioutil" "os" "path/filepath" - "strings" + "strconv" + "syscall" "github.com/appc/spec/schema" "github.com/appc/spec/schema/types" - "github.com/coreos/go-systemd/unit" "github.com/coreos/rkt/common" "github.com/hashicorp/errwrap" ) -const ( - // location within stage1 rootfs where shared volumes will be put - // (or empty directories for kind=empty) - stage1MntDir = "/mnt/" -) - -// makeHashFromVolumeName returns string of 16 bytes length from the volume name, -// P9 file system needs that the tag be less than 31 bytes. -func makeHashFromVolumeName(v string) (ret string) { - h := md5.New() - io.WriteString(h, v) - ret = hex.EncodeToString(h.Sum(nil)) - return -} - -// serviceUnitName returns a systemd service unit name for the given app name. -// note: it was shamefully copy-pasted from stage1/init/path.go -// TODO: extract common functions from path.go -func serviceUnitName(appName types.ACName) string { - return appName.String() + ".service" -} - -// installNewMountUnit creates and installs a new mount unit in the default -// systemd location (/usr/lib/systemd/system) inside the pod stage1 filesystem. -// root is pod's absolute stage1 path (from Pod.Root). -// beforeAndrequiredBy creates a systemd unit dependency (can be space separated -// for multi). -// It returns the name of the generated unit. -func installNewMountUnit(root, what, where, fsType, options, beforeAndrequiredBy, unitsDir string) (string, error) { - opts := []*unit.UnitOption{ - unit.NewUnitOption("Unit", "Description", fmt.Sprintf("Mount unit for %s", where)), - unit.NewUnitOption("Unit", "DefaultDependencies", "false"), - unit.NewUnitOption("Unit", "Before", beforeAndrequiredBy), - unit.NewUnitOption("Mount", "What", what), - unit.NewUnitOption("Mount", "Where", where), - unit.NewUnitOption("Mount", "Type", fsType), - unit.NewUnitOption("Mount", "Options", options), - unit.NewUnitOption("Install", "RequiredBy", beforeAndrequiredBy), - } - - unitsPath := filepath.Join(root, unitsDir) - unitName := unit.UnitNamePathEscape(where + ".mount") - - if err := writeUnit(opts, filepath.Join(unitsPath, unitName)); err != nil { - return "", err - } - diag.Printf("mount unit created: %q in %q (what=%q, where=%q)", unitName, unitsPath, what, where) - - return unitName, nil -} - -func writeUnit(opts []*unit.UnitOption, unitPath string) error { - unitBytes, err := ioutil.ReadAll(unit.Serialize(opts)) - if err != nil { - return errwrap.Wrap(fmt.Errorf("failed to serialize mount unit file to bytes %q", unitPath), err) - } - - err = ioutil.WriteFile(unitPath, unitBytes, 0644) - if err != nil { - return errwrap.Wrap(fmt.Errorf("failed to create mount unit file %q", unitPath), err) - } - - return nil -} - -// PodToSystemdHostMountUnits create host shared remote file system -// mounts (using e.g. 9p) according to https://www.kernel.org/doc/Documentation/filesystems/9p.txt. -// Additionally it creates required directories in stage1MntDir and then prepares -// bind mount unit for each app. -// "root" parameter is stage1 root filesystem path. -// appNames are used to create before/required dependency between mount unit and -// app service units. -func PodToSystemdHostMountUnits(root string, volumes []types.Volume, appNames []types.ACName, unitsDir string) error { - // pod volumes need to mount p9 qemu mount_tags - for _, vol := range volumes { // only host shared volumes - name := vol.Name.String() - mountTag := makeHashFromVolumeName(name) - - // serviceNames for ordering and requirements dependency for apps - var serviceNames []string - for _, appName := range appNames { - serviceNames = append(serviceNames, serviceUnitName(appName)) - } - - // for host kind we create a mount unit to mount host shared folder - if vol.Kind == "host" { - // /var/lib/.../pod/run/rootfs/mnt/{mountTag} - mountPoint := filepath.Join(root, stage1MntDir, mountTag) - err := os.MkdirAll(mountPoint, 0700) - if err != nil { - return err - } - - _, err = installNewMountUnit(root, - mountTag, // what (source) in 9p it is a channel tag which equals to volume mountTag - filepath.Join(stage1MntDir, name), // where - destination - "9p", // fsType - "trans=virtio", // 9p specific options - strings.Join(serviceNames, " "), // space separated list of services for unit dependency - unitsDir, - ) - if err != nil { - return err - } - } - } - - return nil -} - -// AppToSystemdMountUnits prepare bind mount unit for empty or host kind mounting -// between stage1 rootfs and chrooted filesystem for application -func AppToSystemdMountUnits(root string, appName types.ACName, volumes []types.Volume, ra *schema.RuntimeApp, unitsDir string) error { +func MountSharedVolumes(root string, appName types.ACName, volumes []types.Volume, ra *schema.RuntimeApp) error { app := ra.App - vols := make(map[types.ACName]types.Volume) for _, v := range volumes { vols[v.Name] = v } + sharedVolPath := common.SharedVolumesPath(root) + if err := os.MkdirAll(sharedVolPath, sharedVolPerm); err != nil { + return errwrap.Wrap(errors.New("could not create shared volumes directory"), err) + } + if err := os.Chmod(sharedVolPath, sharedVolPerm); err != nil { + return errwrap.Wrap(fmt.Errorf("could not change permissions of %q", sharedVolPath), err) + } + mounts := generateMounts(ra, vols) for _, m := range mounts { vol := vols[m.Volume] - // source relative to stage1 rootfs to relative pod root - hashedVolName := makeHashFromVolumeName(vol.Name.String()) - - whatPath := filepath.Join(stage1MntDir, hashedVolName) - whatFullPath := filepath.Join(root, whatPath) - - // destination relative to stage1 rootfs and relative to pod root - wherePath := filepath.Join(common.RelAppRootfsPath(appName), m.Path) - whereFullPath := filepath.Join(root, wherePath) - - // create shared volumes directory - stage1MntPath := filepath.Join(root, stage1MntDir) - if err := os.MkdirAll(stage1MntPath, sharedVolPerm); err != nil { - return errwrap.Wrap(errors.New("could not create shared volumes directory"), err) - } - if err := os.Chmod(stage1MntPath, sharedVolPerm); err != nil { - return errwrap.Wrap(fmt.Errorf("could not change permissions of %q", stage1MntPath), err) - } - - // prepare empty volumes - if err := PrepareMountpoints(whatFullPath, whereFullPath, &vol, m.dockerImplicit); err != nil { - return errwrap.Wrap(errors.New("error preparing empty mount points"), err) - } - - // assertion to make sure that "what" exists (created earlier by PodToSystemdHostMountUnits) - diag.Printf("checking required source path: %q", whatFullPath) - if _, err := os.Stat(whatFullPath); os.IsNotExist(err) { - return fmt.Errorf("bug: missing source for volume %v", vol.Name) + if vol.Kind == "empty" { + p := filepath.Join(sharedVolPath, vol.Name.String()) + if err := os.MkdirAll(p, sharedVolPerm); err != nil { + return errwrap.Wrap(fmt.Errorf("could not create shared volume %q", vol.Name), err) + } + if err := os.Chown(p, *vol.UID, *vol.GID); err != nil { + return errwrap.Wrap(fmt.Errorf("could not change owner of %q", p), err) + } + mod, err := strconv.ParseUint(*vol.Mode, 8, 32) + if err != nil { + return errwrap.Wrap(fmt.Errorf("invalid mode %q for volume %q", *vol.Mode, vol.Name), err) + } + if err := os.Chmod(p, os.FileMode(mod)); err != nil { + return errwrap.Wrap(fmt.Errorf("could not change permissions of %q", p), err) + } } - // optionally prepare app directory - diag.Printf("optionally preparing destination path: %q", whereFullPath) - err := os.MkdirAll(whereFullPath, 0700) - if err != nil { - return errwrap.Wrap(fmt.Errorf("failed to prepare dir for mount %v", m.Volume), err) + readOnly := IsMountReadOnly(vol, app.MountPoints) + var source string + switch vol.Kind { + case "host": + source = vol.Source + case "empty": + source = filepath.Join(common.SharedVolumesPath(root), vol.Name.String()) + default: + return fmt.Errorf(`invalid volume kind %q. Must be one of "host" or "empty"`, vol.Kind) } - - // install new mount unit for bind mount /mnt/volumeName -> /opt/stage2/{app-id}/rootfs/{{mountPoint.Path}} - mu, err := installNewMountUnit( - root, // where put a mount unit - whatPath, // what - stage1 rootfs /mnt/VolumeName - wherePath, // where - inside chroot app filesystem - "bind", // fstype - "bind", // options - serviceUnitName(appName), - unitsDir, - ) + appRootfs := common.AppRootfsPath(".", appName) + mntPath, err := evaluateAppMountPath(appRootfs, m.Path) if err != nil { - return errwrap.Wrap(fmt.Errorf("cannot install new mount unit for app %q", appName.String()), err) + return errwrap.Wrap(fmt.Errorf("could not evaluate path %v", m.Path), err) } - // TODO(iaguis) when we update util-linux to 2.27, this code can go - // away and we can bind-mount RO with one unit file. - // http://ftp.kernel.org/pub/linux/utils/util-linux/v2.27/v2.27-ReleaseNotes - if IsMountReadOnly(vol, app.MountPoints) { - opts := []*unit.UnitOption{ - unit.NewUnitOption("Unit", "Description", fmt.Sprintf("Remount read-only unit for %s", wherePath)), - unit.NewUnitOption("Unit", "DefaultDependencies", "false"), - unit.NewUnitOption("Unit", "After", mu), - unit.NewUnitOption("Unit", "Wants", mu), - unit.NewUnitOption("Service", "ExecStart", fmt.Sprintf("/usr/bin/mount -o remount,ro %s", wherePath)), - unit.NewUnitOption("Install", "RequiredBy", mu), - } + destination := filepath.Join(appRootfs, mntPath) - remountUnitPath := filepath.Join(root, unitsDir, unit.UnitNamePathEscape(wherePath+"-remount.service")) - if err := writeUnit(opts, remountUnitPath); err != nil { - return err - } + if err := doBindMount(source, destination, readOnly); err != nil { + return errwrap.Wrap(fmt.Errorf("could not bind mount path %v (s: %v, d: %v)", m.Path, source, destination), err) } } return nil } -// VolumesToKvmDiskArgs prepares argument list to be passed to lkvm to configure -// shared volumes (only for "host" kind). -// Example return is ["--9p,src/folder,9ptag"]. -func VolumesToKvmDiskArgs(volumes []types.Volume) []string { - var args []string - - for _, vol := range volumes { - // tag/channel name for virtio - mountTag := makeHashFromVolumeName(vol.Name.String()) - if vol.Kind == "host" { - // eg. --9p=/home/jon/srcdir,tag - arg := "--9p=" + vol.Source + "," + mountTag - diag.Printf("--disk argument: %#v", arg) - args = append(args, arg) - } +func doBindMount(source, destination string, readOnly bool) error { + if err := syscall.Mount(source, destination, "bind", syscall.MS_BIND, ""); err != nil { + return err } - - return args + if readOnly { + return syscall.Mount(source, destination, "bind", syscall.MS_REMOUNT|syscall.MS_RDONLY|syscall.MS_BIND, "") + } + return nil } diff --git a/stage1/init/common/kvm_mount_test.go b/stage1/init/common/kvm_mount_test.go deleted file mode 100644 index ee2d687d62..0000000000 --- a/stage1/init/common/kvm_mount_test.go +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2015 The rkt Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package common - -import ( - "fmt" - "testing" - - "github.com/appc/spec/schema/types" -) - -func TestVolumesToKvmDiskArgs(t *testing.T) { - tests := []struct { - volumes []types.Volume - expected []string - }{ - { // one host volume - one argument - volumes: []types.Volume{{Name: types.ACName("foo"), Kind: "host", Source: "src1"}}, - expected: []string{fmt.Sprintf("--9p=src1,%s", makeHashFromVolumeName("foo"))}, - }, - { // on empty volume - no arguments - volumes: []types.Volume{{Name: types.ACName("foo"), Kind: "empty", Source: "src1"}}, - expected: []string{}, - }, - { // two host volumes - volumes: []types.Volume{ - {Name: types.ACName("foo"), Kind: "host", Source: "src1"}, - {Name: types.ACName("bar"), Kind: "host", Source: "src2"}, - }, - expected: []string{fmt.Sprintf("--9p=src1,%s", makeHashFromVolumeName("foo")), - fmt.Sprintf("--9p=src2,%s", makeHashFromVolumeName("bar"))}, - }, - { // mix host and empty - volumes: []types.Volume{ - {Name: types.ACName("foo"), Kind: "host", Source: "src1"}, - {Name: types.ACName("baz"), Kind: "empty", Source: "src1"}, - {Name: types.ACName("bar"), Kind: "host", Source: "src2"}, - }, - expected: []string{fmt.Sprintf("--9p=src1,%s", makeHashFromVolumeName("foo")), - fmt.Sprintf("--9p=src2,%s", makeHashFromVolumeName("bar"))}, - }, - } - - for i, tt := range tests { - got := VolumesToKvmDiskArgs(tt.volumes) - if len(got) != len(tt.expected) { - t.Errorf("#%d: expected %v elements got %v", i, len(tt.expected), len(got)) - } else { - for iarg, argExpected := range tt.expected { - if got[iarg] != argExpected { - t.Errorf("#%d: arg %d expected `%v` got `%v`", i, iarg, argExpected, got[iarg]) - } - } - } - } -} diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index ab6f265ad6..75170536e2 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -456,9 +456,8 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b } if flavor == "kvm" { - // bind mount all shared volumes from /mnt/volumeName (we don't use mechanism for bind-mounting given by nspawn) - err := AppToSystemdMountUnits(common.Stage1RootfsPath(p.Root), appName, p.Manifest.Volumes, ra, UnitsDir) - if err != nil { + // bind mount all shared volumes (we don't use mechanism for bind-mounting given by nspawn) + if err := MountSharedVolumes(common.Stage1RootfsPath(p.Root), appName, p.Manifest.Volumes, ra); err != nil { return errwrap.Wrap(errors.New("failed to prepare mount units"), err) } diff --git a/stage1/init/init.go b/stage1/init/init.go index 2a3d07c88d..73bb098890 100644 --- a/stage1/init/init.go +++ b/stage1/init/init.go @@ -286,10 +286,6 @@ func getArgsEnv(p *stage1commontypes.Pod, flavor string, debug bool, n *networki args = append(args, "--debug") } - // host volume sharing with 9p - nsargs := stage1initcommon.VolumesToKvmDiskArgs(p.Manifest.Volumes) - args = append(args, nsargs...) - // lkvm requires $HOME to be defined, // see https://github.com/coreos/rkt/issues/1393 if os.Getenv("HOME") == "" { @@ -564,7 +560,7 @@ func stage1() int { } if flavor == "kvm" { - if err := KvmPodToSystemd(p, n); err != nil { + if err := KvmNetworkingToSystemd(p, n); err != nil { log.PrintE("failed to configure systemd for kvm", err) return 1 } diff --git a/stage1/init/kvm.go b/stage1/init/kvm.go index cc7241a7bd..a240e8b10e 100644 --- a/stage1/init/kvm.go +++ b/stage1/init/kvm.go @@ -20,8 +20,6 @@ import ( "errors" "path/filepath" - "github.com/appc/spec/schema/types" - "github.com/coreos/rkt/common" "github.com/coreos/rkt/networking" stage1commontypes "github.com/coreos/rkt/stage1/common/types" @@ -30,8 +28,8 @@ import ( "github.com/hashicorp/errwrap" ) -// KvmPodToSystemd generates systemd unit files for a pod according to the manifest and network configuration -func KvmPodToSystemd(p *stage1commontypes.Pod, n *networking.Networking) error { +// KvmNetworkingToSystemd generates systemd unit files for a pod according to network configuration +func KvmNetworkingToSystemd(p *stage1commontypes.Pod, n *networking.Networking) error { podRoot := common.Stage1RootfsPath(p.Root) // networking @@ -40,18 +38,5 @@ func KvmPodToSystemd(p *stage1commontypes.Pod, n *networking.Networking) error { return errwrap.Wrap(errors.New("failed to transform networking to units"), err) } - // volumes - // prepare all applications names to become dependency for mount units - // all host-shared folder has to become available before applications starts - appNames := []types.ACName{} - for _, runtimeApp := range p.Manifest.Apps { - appNames = append(appNames, runtimeApp.Name) - } - // mount host volumes through some remote file system e.g. 9p to /mnt/volumeName location - // order is important here: PodToSystemHostMountUnits prepares folders that are checked by each appToSystemdMountUnits later - if err := stage1initcommon.PodToSystemdHostMountUnits(podRoot, p.Manifest.Volumes, appNames, stage1initcommon.UnitsDir); err != nil { - return errwrap.Wrap(errors.New("failed to transform pod volumes into mount units"), err) - } - return nil } From e9196cd12da93b18da905c591d4c9a83e8b55447 Mon Sep 17 00:00:00 2001 From: Piotr Skamruk Date: Wed, 30 Mar 2016 13:15:04 +0200 Subject: [PATCH 0093/1304] kvm: fix data loss on 9p caches Without this change some data could be lost if they are saved by application just before pod stopping. For example if I started docker://busybox in interactive mode, added some volume, echoed some value into new file in this volume and then quickly closed pod - file was created, but without expected content inside. Changing this option helped. Change was done basing on information from https://www.kernel.org/doc/Documentation/filesystems/9p.txt --- .../lkvm/patches/do_synchronous_writes.patch | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 stage1/usr_from_kvm/lkvm/patches/do_synchronous_writes.patch diff --git a/stage1/usr_from_kvm/lkvm/patches/do_synchronous_writes.patch b/stage1/usr_from_kvm/lkvm/patches/do_synchronous_writes.patch new file mode 100644 index 0000000000..700caf7b6a --- /dev/null +++ b/stage1/usr_from_kvm/lkvm/patches/do_synchronous_writes.patch @@ -0,0 +1,13 @@ +diff --git a/builtin-run.c b/builtin-run.c +index edcaf3e..f2f2d73 100644 +--- a/builtin-run.c ++++ b/builtin-run.c +@@ -590,7 +591,7 @@ static struct kvm *kvm_cmd_run_init(int argc, const char **argv) + } + + if (kvm->cfg.using_rootfs) { +- strcat(real_cmdline, " rw rootflags=trans=virtio,version=9p2000.L,cache=loose rootfstype=9p"); ++ strcat(real_cmdline, " rw rootflags=trans=virtio,version=9p2000.L,cache=none rootfstype=9p"); + if (kvm->cfg.custom_rootfs) { + kvm_run_set_sandbox(kvm); + From 67f1be7eb5f83b5bc9ff5c93be40fa00b0f3f7e4 Mon Sep 17 00:00:00 2001 From: Piotr Skamruk Date: Fri, 25 Mar 2016 12:51:44 +0100 Subject: [PATCH 0094/1304] kvm: fix for missing destination --- stage1/init/common/kvm_mount.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/stage1/init/common/kvm_mount.go b/stage1/init/common/kvm_mount.go index b7efc44a7b..13cd78dc81 100644 --- a/stage1/init/common/kvm_mount.go +++ b/stage1/init/common/kvm_mount.go @@ -81,6 +81,11 @@ func MountSharedVolumes(root string, appName types.ACName, volumes []types.Volum } destination := filepath.Join(appRootfs, mntPath) + // TODO: verify if rkt should do this, or it should be some outer responsibility + // to ensure if such patch exists + if err := ensureDestinationExists(source, destination); err != nil { + return errwrap.Wrap(fmt.Errorf("could not create destination mount point: %v", destination), err) + } if err := doBindMount(source, destination, readOnly); err != nil { return errwrap.Wrap(fmt.Errorf("could not bind mount path %v (s: %v, d: %v)", m.Path, source, destination), err) @@ -98,3 +103,28 @@ func doBindMount(source, destination string, readOnly bool) error { } return nil } + +func ensureDestinationExists(source, destination string) error { + fileInfo, err := os.Stat(source) + if err != nil { + return errwrap.Wrap(fmt.Errorf("could not stat source location: %v", source), err) + } + + targetPathParent, _ := filepath.Split(destination) + if err := os.MkdirAll(targetPathParent, sharedVolPerm); err != nil { + return errwrap.Wrap(fmt.Errorf("could not create parent directory: %v", targetPathParent), err) + } + + if fileInfo.IsDir() { + if err := os.Mkdir(destination, sharedVolPerm); !os.IsExist(err) { + return err + } + } else { + if file, err := os.OpenFile(destination, os.O_CREATE, sharedVolPerm); err != nil { + return err + } else { + file.Close() + } + } + return nil +} From 0ed812208407e4dadf2a34e6892b5493a9a430ae Mon Sep 17 00:00:00 2001 From: Piotr Skamruk Date: Tue, 29 Mar 2016 14:13:56 +0200 Subject: [PATCH 0095/1304] kvm: fix for mounting symlinks Co-authored-by: Michal Stachowski --- stage1/init/common/kvm_mount.go | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/stage1/init/common/kvm_mount.go b/stage1/init/common/kvm_mount.go index 13cd78dc81..238b39d987 100644 --- a/stage1/init/common/kvm_mount.go +++ b/stage1/init/common/kvm_mount.go @@ -20,6 +20,7 @@ import ( "os" "path/filepath" "strconv" + "strings" "syscall" "github.com/appc/spec/schema" @@ -74,21 +75,26 @@ func MountSharedVolumes(root string, appName types.ACName, volumes []types.Volum default: return fmt.Errorf(`invalid volume kind %q. Must be one of "host" or "empty"`, vol.Kind) } - appRootfs := common.AppRootfsPath(".", appName) - mntPath, err := evaluateAppMountPath(appRootfs, m.Path) + absAppRootfs, err := filepath.Abs(common.AppRootfsPath(".", appName)) if err != nil { - return errwrap.Wrap(fmt.Errorf("could not evaluate path %v", m.Path), err) + return fmt.Errorf(`could not evaluate absolute path for application rootfs in app: %v`, appName) } - destination := filepath.Join(appRootfs, mntPath) - // TODO: verify if rkt should do this, or it should be some outer responsibility - // to ensure if such patch exists - if err := ensureDestinationExists(source, destination); err != nil { - return errwrap.Wrap(fmt.Errorf("could not create destination mount point: %v", destination), err) + absDestination, err := filepath.Abs(filepath.Join(absAppRootfs, m.Path)) + if err != nil { + return fmt.Errorf(`could not evaluate absolute path for application volume path %q in: %v`, m.Path, appName) } - - if err := doBindMount(source, destination, readOnly); err != nil { - return errwrap.Wrap(fmt.Errorf("could not bind mount path %v (s: %v, d: %v)", m.Path, source, destination), err) + if !strings.HasPrefix(absDestination, absAppRootfs) { + return fmt.Errorf("path escapes app's root: %v", absDestination) + } + // TODO: verify if rkt should ensure existance of destination there, or it should be some + // outer responsibility to ensure if such path exists + if cleanedSource, err := filepath.EvalSymlinks(source); err != nil { + return errwrap.Wrap(fmt.Errorf("could not resolve symlink for source: %v", source), err) + } else if err := ensureDestinationExists(cleanedSource, absDestination); err != nil { + return errwrap.Wrap(fmt.Errorf("could not create destination mount point: %v", absDestination), err) + } else if err := doBindMount(cleanedSource, absDestination, readOnly); err != nil { + return errwrap.Wrap(fmt.Errorf("could not bind mount path %v (s: %v, d: %v)", m.Path, source, absDestination), err) } } return nil From df5330807227bf99ba04fa241eccc6e79d7ca36e Mon Sep 17 00:00:00 2001 From: Piotr Skamruk Date: Thu, 7 Apr 2016 17:28:18 +0200 Subject: [PATCH 0096/1304] kvm: refactor volume mounting --- stage1/init/common/kvm_mount.go | 136 -------------------------------- stage1/init/common/mount.go | 4 +- stage1/init/common/pod.go | 16 +--- stage1/init/init.go | 8 ++ stage1/init/kvm.go | 132 +++++++++++++++++++++++++++++++ 5 files changed, 146 insertions(+), 150 deletions(-) delete mode 100644 stage1/init/common/kvm_mount.go diff --git a/stage1/init/common/kvm_mount.go b/stage1/init/common/kvm_mount.go deleted file mode 100644 index 238b39d987..0000000000 --- a/stage1/init/common/kvm_mount.go +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright 2015 The rkt Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package common - -import ( - "errors" - "fmt" - "os" - "path/filepath" - "strconv" - "strings" - "syscall" - - "github.com/appc/spec/schema" - "github.com/appc/spec/schema/types" - "github.com/coreos/rkt/common" - "github.com/hashicorp/errwrap" -) - -func MountSharedVolumes(root string, appName types.ACName, volumes []types.Volume, ra *schema.RuntimeApp) error { - app := ra.App - vols := make(map[types.ACName]types.Volume) - for _, v := range volumes { - vols[v.Name] = v - } - - sharedVolPath := common.SharedVolumesPath(root) - if err := os.MkdirAll(sharedVolPath, sharedVolPerm); err != nil { - return errwrap.Wrap(errors.New("could not create shared volumes directory"), err) - } - if err := os.Chmod(sharedVolPath, sharedVolPerm); err != nil { - return errwrap.Wrap(fmt.Errorf("could not change permissions of %q", sharedVolPath), err) - } - - mounts := generateMounts(ra, vols) - for _, m := range mounts { - vol := vols[m.Volume] - - if vol.Kind == "empty" { - p := filepath.Join(sharedVolPath, vol.Name.String()) - if err := os.MkdirAll(p, sharedVolPerm); err != nil { - return errwrap.Wrap(fmt.Errorf("could not create shared volume %q", vol.Name), err) - } - if err := os.Chown(p, *vol.UID, *vol.GID); err != nil { - return errwrap.Wrap(fmt.Errorf("could not change owner of %q", p), err) - } - mod, err := strconv.ParseUint(*vol.Mode, 8, 32) - if err != nil { - return errwrap.Wrap(fmt.Errorf("invalid mode %q for volume %q", *vol.Mode, vol.Name), err) - } - if err := os.Chmod(p, os.FileMode(mod)); err != nil { - return errwrap.Wrap(fmt.Errorf("could not change permissions of %q", p), err) - } - } - - readOnly := IsMountReadOnly(vol, app.MountPoints) - var source string - switch vol.Kind { - case "host": - source = vol.Source - case "empty": - source = filepath.Join(common.SharedVolumesPath(root), vol.Name.String()) - default: - return fmt.Errorf(`invalid volume kind %q. Must be one of "host" or "empty"`, vol.Kind) - } - absAppRootfs, err := filepath.Abs(common.AppRootfsPath(".", appName)) - if err != nil { - return fmt.Errorf(`could not evaluate absolute path for application rootfs in app: %v`, appName) - } - - absDestination, err := filepath.Abs(filepath.Join(absAppRootfs, m.Path)) - if err != nil { - return fmt.Errorf(`could not evaluate absolute path for application volume path %q in: %v`, m.Path, appName) - } - if !strings.HasPrefix(absDestination, absAppRootfs) { - return fmt.Errorf("path escapes app's root: %v", absDestination) - } - // TODO: verify if rkt should ensure existance of destination there, or it should be some - // outer responsibility to ensure if such path exists - if cleanedSource, err := filepath.EvalSymlinks(source); err != nil { - return errwrap.Wrap(fmt.Errorf("could not resolve symlink for source: %v", source), err) - } else if err := ensureDestinationExists(cleanedSource, absDestination); err != nil { - return errwrap.Wrap(fmt.Errorf("could not create destination mount point: %v", absDestination), err) - } else if err := doBindMount(cleanedSource, absDestination, readOnly); err != nil { - return errwrap.Wrap(fmt.Errorf("could not bind mount path %v (s: %v, d: %v)", m.Path, source, absDestination), err) - } - } - return nil -} - -func doBindMount(source, destination string, readOnly bool) error { - if err := syscall.Mount(source, destination, "bind", syscall.MS_BIND, ""); err != nil { - return err - } - if readOnly { - return syscall.Mount(source, destination, "bind", syscall.MS_REMOUNT|syscall.MS_RDONLY|syscall.MS_BIND, "") - } - return nil -} - -func ensureDestinationExists(source, destination string) error { - fileInfo, err := os.Stat(source) - if err != nil { - return errwrap.Wrap(fmt.Errorf("could not stat source location: %v", source), err) - } - - targetPathParent, _ := filepath.Split(destination) - if err := os.MkdirAll(targetPathParent, sharedVolPerm); err != nil { - return errwrap.Wrap(fmt.Errorf("could not create parent directory: %v", targetPathParent), err) - } - - if fileInfo.IsDir() { - if err := os.Mkdir(destination, sharedVolPerm); !os.IsExist(err) { - return err - } - } else { - if file, err := os.OpenFile(destination, os.O_CREATE, sharedVolPerm); err != nil { - return err - } else { - file.Close() - } - } - return nil -} diff --git a/stage1/init/common/mount.go b/stage1/init/common/mount.go index 86978d31bf..cbfd8c9a7a 100644 --- a/stage1/init/common/mount.go +++ b/stage1/init/common/mount.go @@ -62,10 +62,10 @@ func convertedFromDocker(ra *schema.RuntimeApp) bool { return ok } -// generateMounts maps MountPoint paths to volumes, returning a list of mounts, +// GenerateMounts maps MountPoint paths to volumes, returning a list of mounts, // each with a parameter indicating if it's an implicit empty volume from a // Docker image. -func generateMounts(ra *schema.RuntimeApp, volumes map[types.ACName]types.Volume) []mountWrapper { +func GenerateMounts(ra *schema.RuntimeApp, volumes map[types.ACName]types.Volume) []mountWrapper { app := ra.App var genMnts []mountWrapper diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index 75170536e2..ce213b2f6c 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -48,7 +48,7 @@ import ( const ( // FlavorFile names the file storing the pod's flavor FlavorFile = "flavor" - sharedVolPerm = os.FileMode(0755) + SharedVolPerm = os.FileMode(0755) ) var ( @@ -455,14 +455,6 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b return errwrap.Wrap(errors.New("failed to link service want"), err) } - if flavor == "kvm" { - // bind mount all shared volumes (we don't use mechanism for bind-mounting given by nspawn) - if err := MountSharedVolumes(common.Stage1RootfsPath(p.Root), appName, p.Manifest.Volumes, ra); err != nil { - return errwrap.Wrap(errors.New("failed to prepare mount units"), err) - } - - } - if err = writeAppReaper(p, appName.String()); err != nil { return errwrap.Wrap(fmt.Errorf("failed to write app %q reaper service", appName), err) } @@ -625,10 +617,10 @@ func appToNspawnArgs(p *stage1commontypes.Pod, ra *schema.RuntimeApp) ([]string, app := ra.App sharedVolPath := common.SharedVolumesPath(p.Root) - if err := os.MkdirAll(sharedVolPath, sharedVolPerm); err != nil { + if err := os.MkdirAll(sharedVolPath, SharedVolPerm); err != nil { return nil, errwrap.Wrap(errors.New("could not create shared volumes directory"), err) } - if err := os.Chmod(sharedVolPath, sharedVolPerm); err != nil { + if err := os.Chmod(sharedVolPath, SharedVolPerm); err != nil { return nil, errwrap.Wrap(fmt.Errorf("could not change permissions of %q", sharedVolPath), err) } @@ -637,7 +629,7 @@ func appToNspawnArgs(p *stage1commontypes.Pod, ra *schema.RuntimeApp) ([]string, vols[v.Name] = v } - mounts := generateMounts(ra, vols) + mounts := GenerateMounts(ra, vols) for _, m := range mounts { vol := vols[m.Volume] diff --git a/stage1/init/init.go b/stage1/init/init.go index 73bb098890..fecb7c111c 100644 --- a/stage1/init/init.go +++ b/stage1/init/init.go @@ -628,6 +628,14 @@ func stage1() int { return 1 } + // prepare mounts for kvm flavor + if flavor == "kvm" { + if err := KvmPrepareMounts(s1Root, p); err != nil { + log.PrintE("could not prepare mounts", err) + return 1 + } + } + err = stage1common.WithClearedCloExec(lfd, func() error { return syscall.Exec(args[0], args, env) }) diff --git a/stage1/init/kvm.go b/stage1/init/kvm.go index a240e8b10e..40c423cc3f 100644 --- a/stage1/init/kvm.go +++ b/stage1/init/kvm.go @@ -18,8 +18,15 @@ package main import ( "errors" + "fmt" + "os" "path/filepath" + "strconv" + "strings" + "syscall" + "github.com/appc/spec/schema" + "github.com/appc/spec/schema/types" "github.com/coreos/rkt/common" "github.com/coreos/rkt/networking" stage1commontypes "github.com/coreos/rkt/stage1/common/types" @@ -40,3 +47,128 @@ func KvmNetworkingToSystemd(p *stage1commontypes.Pod, n *networking.Networking) return nil } + +func mountSharedVolumes(root string, volumes []types.Volume, ra *schema.RuntimeApp) error { + app := ra.App + appName := ra.Name + vols := make(map[types.ACName]types.Volume) + for _, v := range volumes { + vols[v.Name] = v + } + + sharedVolPath := common.SharedVolumesPath(root) + if err := os.MkdirAll(sharedVolPath, stage1initcommon.SharedVolPerm); err != nil { + return errwrap.Wrap(errors.New("could not create shared volumes directory"), err) + } + if err := os.Chmod(sharedVolPath, stage1initcommon.SharedVolPerm); err != nil { + return errwrap.Wrap(fmt.Errorf("could not change permissions of %q", sharedVolPath), err) + } + + mounts := stage1initcommon.GenerateMounts(ra, vols) + for _, m := range mounts { + vol := vols[m.Volume] + + if vol.Kind == "empty" { + p := filepath.Join(sharedVolPath, vol.Name.String()) + if err := os.MkdirAll(p, stage1initcommon.SharedVolPerm); err != nil { + return errwrap.Wrap(fmt.Errorf("could not create shared volume %q", vol.Name), err) + } + if err := os.Chown(p, *vol.UID, *vol.GID); err != nil { + return errwrap.Wrap(fmt.Errorf("could not change owner of %q", p), err) + } + mod, err := strconv.ParseUint(*vol.Mode, 8, 32) + if err != nil { + return errwrap.Wrap(fmt.Errorf("invalid mode %q for volume %q", *vol.Mode, vol.Name), err) + } + if err := os.Chmod(p, os.FileMode(mod)); err != nil { + return errwrap.Wrap(fmt.Errorf("could not change permissions of %q", p), err) + } + } + + readOnly := stage1initcommon.IsMountReadOnly(vol, app.MountPoints) + var source string + switch vol.Kind { + case "host": + source = vol.Source + case "empty": + source = filepath.Join(common.SharedVolumesPath(root), vol.Name.String()) + default: + return fmt.Errorf(`invalid volume kind %q. Must be one of "host" or "empty"`, vol.Kind) + } + absAppRootfs, err := filepath.Abs(common.AppRootfsPath(root, appName)) + if err != nil { + return fmt.Errorf(`could not evaluate absolute path for application rootfs in app: %v`, appName) + } + + absDestination, err := filepath.Abs(filepath.Join(absAppRootfs, m.Path)) + if err != nil { + return fmt.Errorf(`could not evaluate absolute path for application volume path %q in: %v`, m.Path, appName) + } + if !strings.HasPrefix(absDestination, absAppRootfs) { + return fmt.Errorf("path escapes app's root: %v", absDestination) + } + if cleanedSource, err := filepath.EvalSymlinks(source); err != nil { + return errwrap.Wrap(fmt.Errorf("could not resolve symlink for source: %v", source), err) + } else if err := ensureDestinationExists(cleanedSource, absDestination); err != nil { + return errwrap.Wrap(fmt.Errorf("could not create destination mount point: %v", absDestination), err) + } else if err := doBindMount(cleanedSource, absDestination, readOnly); err != nil { + return errwrap.Wrap(fmt.Errorf("could not bind mount path %v (s: %v, d: %v)", m.Path, source, absDestination), err) + } + } + return nil +} + +func doBindMount(source, destination string, readOnly bool) error { + if err := syscall.Mount(source, destination, "bind", syscall.MS_BIND, ""); err != nil { + return err + } + if readOnly { + return syscall.Mount(source, destination, "bind", syscall.MS_REMOUNT|syscall.MS_RDONLY|syscall.MS_BIND, "") + } + return nil +} + +func ensureDestinationExists(source, destination string) error { + fileInfo, err := os.Stat(source) + if err != nil { + return errwrap.Wrap(fmt.Errorf("could not stat source location: %v", source), err) + } + + targetPathParent, _ := filepath.Split(destination) + if err := os.MkdirAll(targetPathParent, stage1initcommon.SharedVolPerm); err != nil { + return errwrap.Wrap(fmt.Errorf("could not create parent directory: %v", targetPathParent), err) + } + + if fileInfo.IsDir() { + if err := os.Mkdir(destination, stage1initcommon.SharedVolPerm); !os.IsExist(err) { + return err + } + } else { + if file, err := os.OpenFile(destination, os.O_CREATE, stage1initcommon.SharedVolPerm); err != nil { + return err + } else { + file.Close() + } + } + return nil +} + +func prepareMountsForApp(s1Root string, p *stage1commontypes.Pod, ra *schema.RuntimeApp) error { + // bind mount all shared volumes (we don't use mechanism for bind-mounting given by nspawn) + if err := mountSharedVolumes(s1Root, p.Manifest.Volumes, ra); err != nil { + return errwrap.Wrap(errors.New("failed to prepare mount point"), err) + } + + return nil +} + +func KvmPrepareMounts(s1Root string, p *stage1commontypes.Pod) error { + for i := range p.Manifest.Apps { + ra := &p.Manifest.Apps[i] + if err := prepareMountsForApp(s1Root, p, ra); err != nil { + return errwrap.Wrap(fmt.Errorf("failed prepare mounts for app %q", ra.Name), err) + } + } + + return nil +} From 13690ed22e6b584c8eec3e2c3b7da934a770e9e5 Mon Sep 17 00:00:00 2001 From: Piotr Skamruk Date: Fri, 8 Apr 2016 12:38:03 +0200 Subject: [PATCH 0097/1304] kvm: fix pid vs ppid usage Fixes #2389 --- stage1/common/run.go | 11 +++++------ stage1/init/init.go | 10 +++++++++- stage1_fly/run/main.go | 2 +- tests/stub-stage1/run/main.go | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/stage1/common/run.go b/stage1/common/run.go index 37327bb84c..4b71bd58ef 100644 --- a/stage1/common/run.go +++ b/stage1/common/run.go @@ -37,19 +37,18 @@ func WithClearedCloExec(lfd int, f func() error) error { return f() } -// WritePpid writes the pid's parent pid to $PWD/ppid -func WritePpid(pid int) error { - // write ppid file as specified in +// WritePid writes the given pid to $PWD/{filename} +func WritePid(pid int, filename string) error { + // write pid file as specified in // Documentation/devel/stage1-implementors-guide.md out, err := os.Getwd() if err != nil { return errwrap.Wrap(errors.New("cannot get current working directory"), err) } - // we are the parent of the process that is PID 1 in the container so we write our PID to "ppid" - err = ioutil.WriteFile(filepath.Join(out, "ppid"), + err = ioutil.WriteFile(filepath.Join(out, filename), []byte(fmt.Sprintf("%d\n", pid)), 0644) if err != nil { - return errwrap.Wrap(errors.New("cannot write ppid file"), err) + return errwrap.Wrap(errors.New("cannot write pid file"), err) } return nil } diff --git a/stage1/init/init.go b/stage1/init/init.go index 2a3d07c88d..33452a53c5 100644 --- a/stage1/init/init.go +++ b/stage1/init/init.go @@ -627,7 +627,15 @@ func stage1() int { log.PrintE("continuing with per-app isolators disabled", err) } - if err = stage1common.WritePpid(os.Getpid()); err != nil { + // kvm flavor has a bit different logic in handling pid vs ppid, for details look into #2389 + // it does not require existance of "ppid", but instead registers current pid (which + // will be reused by lkvm binary) as an pod process pid used in entering + pid_filename := "ppid" + if flavor == "kvm" { + pid_filename = "pid" + } + + if err = stage1common.WritePid(os.Getpid(), pid_filename); err != nil { log.Error(err) return 1 } diff --git a/stage1_fly/run/main.go b/stage1_fly/run/main.go index 049f49bb3a..dd7e8dbd3f 100644 --- a/stage1_fly/run/main.go +++ b/stage1_fly/run/main.go @@ -332,7 +332,7 @@ func stage1() int { } } - if err = stage1common.WritePpid(os.Getpid()); err != nil { + if err = stage1common.WritePid(os.Getpid(), "ppid"); err != nil { log.Error(err) return 1 } diff --git a/tests/stub-stage1/run/main.go b/tests/stub-stage1/run/main.go index 679f749009..67227fdd70 100644 --- a/tests/stub-stage1/run/main.go +++ b/tests/stub-stage1/run/main.go @@ -39,7 +39,7 @@ func run() int { return 1 } - if err := stage1common.WritePpid(os.Getpid()); err != nil { + if err := stage1common.WritePid(os.Getpid(), "ppid"); err != nil { fmt.Fprintf(os.Stderr, "write ppid: %v", err) return 1 } From 0a70c841f16f2915144185b198b5ee85e35265f1 Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Fri, 8 Apr 2016 12:33:22 +0200 Subject: [PATCH 0098/1304] docs: clean up English in hacking guide --- Documentation/hacking.md | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/Documentation/hacking.md b/Documentation/hacking.md index 5f4b9d3c38..3cd36ce0e2 100644 --- a/Documentation/hacking.md +++ b/Documentation/hacking.md @@ -7,10 +7,10 @@ For more information on the rkt internals, see the [`devel`](devel/) documentati ## Building rkt -You should be able build rkt on any modern Linux system. +You should be able build rkt on any modern Linux system with [Go](https://golang.org/) (1.5+) installed. For the most part the codebase is self-contained (e.g. all dependencies are vendored), but assembly of the stage1 requires some other tools to be installed on the system. Please see [the list of the build-time dependencies](dependencies.md#build-time-dependencies). -Once the dependencies have been satisfied you can build rkt by running the following commands: +Once the dependencies have been satisfied you can build rkt with a default configuration by running the following commands: ``` git clone https://github.com/coreos/rkt.git @@ -22,27 +22,25 @@ Build verbosity can be controlled with the V variable. Set V to 0 to have a silent build. Set V to either 1 or 2 to get short messages about what is being done (level 2 prints more of them). Set V to 3 to get raw output. -Instead of a number, english words can be used. -`quiet` or `silent` for level 0, `info` for level 1, `all` for level 2 and `raw` for level 3. Example: - -`make V=raw` +Instead of a number, English words can be used: `quiet` or `silent` for level 0, `info` for level 1, `all` for level 2 and `raw` for level 3. +For example, `make V=raw` is equivalent to `make V=3`. To be able to run rkt, please see [the list of the run-time dependencies](dependencies.md#run-time-dependencies). -### With Docker +### Building rkt with Docker Alternatively, you can build rkt in a Docker container with the following command. -Replace $SRC with the absolute path to your rkt source code: +Replace `$SRC` with the absolute path to your rkt source code: ``` # docker run -v $SRC:/opt/rkt -i -t golang:1.5 /bin/bash -c "apt-get update && apt-get install -y coreutils cpio squashfs-tools realpath autoconf file xz-utils patch bc && cd /opt/rkt && go get github.com/appc/spec/... && ./autogen.sh && ./configure && make" ``` -### Building systemd in stage1 from the sources +### Building systemd in stage1 from source By default, rkt gets systemd from a CoreOS image to generate stage1. -But it's also possible to build systemd from the sources. -To do this, use the following configure parameters after running `./autogen.sh`: +It's also possible to build systemd from source. +To do this, use the following `configure` parameters after running `./autogen.sh`: - `--with-stage1-flavors` - `--with-stage1-default-flavor` (optional) @@ -60,9 +58,9 @@ Example: The stage1 kvm image is based on CoreOS, but with additional components for running containers on top of a hypervisor. -To build, pass `kvm` to `--with-stage1-flavors` parameter in `./configure` +To build this stage1 image, pass `kvm` to `--with-stage1-flavors` parameter in `./configure` -This will generate stage1 with embedded kernel and kvmtool to start pod in virtual machine. +This will generate a stage1 with an embedded kernel and kvmtool, which launches each pod in a separate virtual machine. Additional build dependencies for the stage1 kvm follow. If building with docker, these must be added to the `apt-get install` command. @@ -91,7 +89,7 @@ rkt expects stage1 images to be signed except in the following cases: * `--stage1-{name,hash}` is used and the image is already in the store * `--stage1-{url,path,from-dir}` is used and the image is in the default directory configured at build time -## Managing Dependencies +## Managing dependencies rkt uses [`godep`](https://github.com/tools/godep) to manage third-party dependencies. The build process is crafted to make this transparent to most users (i.e. if you're just building rkt from source, or modifying any of the codebase without changing dependencies, you should have no need to interact with godep). From b02fd2fee8ca2bd858701ff128248a1918df9697 Mon Sep 17 00:00:00 2001 From: Simone Gotti Date: Fri, 8 Apr 2016 15:42:25 +0200 Subject: [PATCH 0099/1304] rkt: calculate real dataDir path If dataDir or some of its parents are symlinks all seems to work correctly except the gc. That's because stage0.MountGC determines which mountpoints should be unmounted filtering the mountpoints returned from /proc/self/mountinfo with the dataDir value. These mountpoints are the real path so, if the dataDir or its parents are symlinks, no mountpoint will match. This patch evaluates the dataDir real path. --- rkt/rkt.go | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/rkt/rkt.go b/rkt/rkt.go index cf87815ca3..1577f3c343 100644 --- a/rkt/rkt.go +++ b/rkt/rkt.go @@ -259,10 +259,12 @@ func getDataDir() string { } func calculateDataDir() string { + var dataDir string + // If --dir parameter is passed, then use this value. if dirFlag := cmdRkt.PersistentFlags().Lookup("dir"); dirFlag != nil { if dirFlag.Changed { - return globalFlags.Dir + dataDir = globalFlags.Dir } } else { // should not happen @@ -270,17 +272,29 @@ func calculateDataDir() string { } // If above fails, then try to get the value from configuration. - if config, err := getConfig(); err != nil { - stderr.PrintE("cannot get configuration", err) - os.Exit(1) - } else { - if config.Paths.DataDir != "" { - return config.Paths.DataDir + if dataDir == "" { + if config, err := getConfig(); err != nil { + stderr.PrintE("cannot get configuration", err) + os.Exit(1) + } else { + if config.Paths.DataDir != "" { + dataDir = config.Paths.DataDir + } } } + if dataDir == "" { + dataDir = defaultDataDir + } + + // Resolve symlinks + realDataDir, err := filepath.EvalSymlinks(dataDir) + if err != nil { + stderr.PrintE(fmt.Sprintf("cannot evaluate dataDir %q real path", dataDir), err) + os.Exit(1) + } // If above fails, then use the default. - return defaultDataDir + return realDataDir } func getConfig() (*config.Config, error) { From ce059a7c7e4130b36c4d53a99dba0f96c249379b Mon Sep 17 00:00:00 2001 From: Piotr Skamruk Date: Mon, 15 Feb 2016 11:54:13 +0100 Subject: [PATCH 0100/1304] kvm: Fix macvtap naming issue. Closes #2023 --- networking/kvm.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/networking/kvm.go b/networking/kvm.go index e353d896c4..f4a1117b74 100644 --- a/networking/kvm.go +++ b/networking/kvm.go @@ -81,7 +81,8 @@ type MacVTapNetConf struct { // setupTapDevice creates persistent macvtap device // and returns a newly created netlink.Link structure -func setupMacVTapDevice(podID types.UUID, config MacVTapNetConf) (netlink.Link, error) { +// using part of pod hash and interface number in interface name +func setupMacVTapDevice(podID types.UUID, config MacVTapNetConf, interfaceNumber int) (netlink.Link, error) { master, err := netlink.LinkByName(config.Master) if err != nil { return nil, errwrap.Wrap(fmt.Errorf("cannot find master device '%v'", config.Master), err) @@ -105,11 +106,11 @@ func setupMacVTapDevice(podID types.UUID, config MacVTapNetConf) (netlink.Link, if config.MTU != 0 { mtu = config.MTU } - nameTemplate := fmt.Sprintf("rkt-%s-vtap%%d", podID.String()[0:4]) + interfaceName := fmt.Sprintf("rkt-%s-vtap%d", podID.String()[0:4], interfaceNumber) link := &netlink.Macvtap{ Macvlan: netlink.Macvlan{ LinkAttrs: netlink.LinkAttrs{ - Name: nameTemplate, + Name: interfaceName, MTU: mtu, ParentIndex: master.Attrs().Index, }, @@ -120,6 +121,11 @@ func setupMacVTapDevice(podID types.UUID, config MacVTapNetConf) (netlink.Link, if err := netlink.LinkAdd(link); err != nil { return nil, errwrap.Wrap(errors.New("cannot create macvtap interface"), err) } + if err := netlink.LinkSetUp(link); err != nil { + // remove the newly added link and ignore errors, because we already are in a failed state + _ = netlink.LinkDel(link) + return nil, errwrap.Wrap(errors.New("cannot set up macvtap interface"), err) + } return link, nil } @@ -131,8 +137,12 @@ func kvmSetupNetAddressing(network *Networking, n activeNet, ifName string) erro if err := ip.EnableIP4Forward(); err != nil { return errwrap.Wrap(errors.New("failed to enable forwarding"), err) } + + // patch plugin type only for single IPAM run time, then revert this change + original_type := n.conf.Type n.conf.Type = n.conf.IPAM.Type output, err := network.execNetPlugin("ADD", &n, ifName) + n.conf.Type = original_type if err != nil { return errwrap.Wrap(fmt.Errorf("problem executing network plugin %q (%q)", n.conf.Type, ifName), err) } @@ -514,7 +524,7 @@ func kvmSetup(podRoot string, podID types.UUID, fps []ForwardedPort, netList com if err := json.Unmarshal(n.confBytes, &config); err != nil { return nil, errwrap.Wrap(fmt.Errorf("error parsing %q result", n.conf.Name), err) } - link, err := setupMacVTapDevice(podID, config) + link, err := setupMacVTapDevice(podID, config, i) if err != nil { return nil, err } From 6305635e9fd16c60ce146c84a99387b4d429f97e Mon Sep 17 00:00:00 2001 From: Yifan Gu Date: Fri, 8 Apr 2016 13:12:51 -0700 Subject: [PATCH 0101/1304] gc: Add flag 'mark-only' to mark garbage pods without deleting them. If this flag is set to true, then we move the exited/aborted pods to exited-garbage/garbage directory, but do not deleting them. For prepared pods, if the flag is true, we don't move them to garbage even the pods are expired. A third party application can use 'rkt gc --mark-only=true' to marks the time when the pods is not running. --- Documentation/subcommands/gc.md | 1 + rkt/gc.go | 6 +++ tests/rkt_gc_test.go | 74 +++++++++++++++++++++++++++++++++ tests/rkt_tests.go | 8 ++++ 4 files changed, 89 insertions(+) create mode 100644 tests/rkt_gc_test.go diff --git a/Documentation/subcommands/gc.md b/Documentation/subcommands/gc.md index 326732f22d..0befbe6b53 100644 --- a/Documentation/subcommands/gc.md +++ b/Documentation/subcommands/gc.md @@ -29,6 +29,7 @@ Garbage collecting pod "f07a4070-79a9-4db0-ae65-a090c9c393a3" | --- | --- | --- | --- | | `--expire-prepared` | `24h0m0s` | A time | Duration to wait before expiring prepared pods | | `--grace-period` | `30m0s` | A time | Duration to wait before discarding inactive pods from garbage | +| `--mark-only` | `false` | If set to true, then the exited/aborted pods will be moved to the garbage directories without actually deleting them, this is useful for marking the exit time of a pod | ## Global options diff --git a/rkt/gc.go b/rkt/gc.go index b15b6c7ae6..b671a9db12 100644 --- a/rkt/gc.go +++ b/rkt/gc.go @@ -48,12 +48,14 @@ Use --grace-period=0s to effectively disable the grace-period.`, } flagGracePeriod time.Duration flagPreparedExpiration time.Duration + flagMarkOnly bool ) func init() { cmdRkt.AddCommand(cmdGC) cmdGC.Flags().DurationVar(&flagGracePeriod, "grace-period", defaultGracePeriod, "duration to wait before discarding inactive pods from garbage") cmdGC.Flags().DurationVar(&flagPreparedExpiration, "expire-prepared", defaultPreparedExpiration, "duration to wait before expiring prepared pods") + cmdGC.Flags().BoolVar(&flagMarkOnly, "mark-only", false, "if set to true, then the exited/aborted pods will be moved to the garbage directories without actually deleting them, this is useful for marking the exit time of a pod") } func runGC(cmd *cobra.Command, args []string) (exit int) { @@ -67,6 +69,10 @@ func runGC(cmd *cobra.Command, args []string) (exit int) { return 1 } + if flagMarkOnly { + return + } + if err := renameExpired(flagPreparedExpiration); err != nil { stderr.PrintE("failed to rename expired prepared pods", err) return 1 diff --git a/tests/rkt_gc_test.go b/tests/rkt_gc_test.go new file mode 100644 index 0000000000..6e1009a8ad --- /dev/null +++ b/tests/rkt_gc_test.go @@ -0,0 +1,74 @@ +// Copyright 2015 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "fmt" + "io/ioutil" + "os" + "path/filepath" + "testing" + + "github.com/coreos/rkt/tests/testutils" +) + +func TestGC(t *testing.T) { + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + // Finished pods. + patchImportAndRun("inspect-gc-test-run.aci", []string{"--exec=/inspect --print-msg=HELLO_API --exit-code=0"}, t, ctx) + + // Prepared pods. + patchImportAndPrepare("inspect-gc-test-prepare.aci", []string{"--exec=/inspect --print-msg=HELLO_API --exit-code=0"}, t, ctx) + + // Abort prepare. + imagePath := patchTestACI("inspect-gc-test-abort.aci", []string{"--exec=/inspect --print-msg=HELLO_API --exit-code=0"}...) + defer os.Remove(imagePath) + cmd := fmt.Sprintf("%s --insecure-options=image prepare %s %s", ctx.Cmd(), imagePath, imagePath) + spawnAndWaitOrFail(t, cmd, 1) + + gcCmd := fmt.Sprintf("%s gc --mark-only=true --expire-prepared=0 --grace-period=0", ctx.Cmd()) + spawnAndWaitOrFail(t, gcCmd, 0) + + gcDirs := []string{ + filepath.Join(ctx.DataDir(), "pods", "exited-garbage"), + filepath.Join(ctx.DataDir(), "pods", "prepared"), + filepath.Join(ctx.DataDir(), "pods", "garbage"), + } + + for _, dir := range gcDirs { + pods, err := ioutil.ReadDir(dir) + if err != nil { + t.Fatalf("cannot read gc directory %q: %v", dir, err) + } + if len(pods) == 0 { + t.Fatalf("pods should still exist in directory %q", dir) + } + } + + gcCmd = fmt.Sprintf("%s gc --mark-only=false --expire-prepared=0 --grace-period=0", ctx.Cmd()) + spawnAndWaitOrFail(t, gcCmd, 0) + + for _, dir := range gcDirs { + pods, err := ioutil.ReadDir(dir) + if err != nil { + t.Fatalf("cannot read gc directory %q: %v", dir, err) + } + if len(pods) != 0 { + t.Fatalf("no pods should exist in directory %q, but found: %v", dir, pods) + } + } +} diff --git a/tests/rkt_tests.go b/tests/rkt_tests.go index 34c9a91107..a7c5fbd8fe 100644 --- a/tests/rkt_tests.go +++ b/tests/rkt_tests.go @@ -238,6 +238,14 @@ func patchImportAndRun(image string, patches []string, t *testing.T, ctx *testut spawnAndWaitOrFail(t, cmd, 0) } +func patchImportAndPrepare(image string, patches []string, t *testing.T, ctx *testutils.RktRunCtx) { + imagePath := patchTestACI(image, patches...) + defer os.Remove(imagePath) + + cmd := fmt.Sprintf("%s --insecure-options=image prepare %s", ctx.Cmd(), imagePath) + spawnAndWaitOrFail(t, cmd, 0) +} + func runGC(t *testing.T, ctx *testutils.RktRunCtx) { cmd := fmt.Sprintf("%s gc --grace-period=0s", ctx.Cmd()) spawnAndWaitOrFail(t, cmd, 0) From ccb9254742a9f207d8d11d2b577869b82c1f7a04 Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Mon, 11 Apr 2016 15:02:52 +0200 Subject: [PATCH 0102/1304] store: fix comment + add link in db test --- store/db_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/store/db_test.go b/store/db_test.go index a639c4f48c..b8bdd2a74d 100644 --- a/store/db_test.go +++ b/store/db_test.go @@ -78,9 +78,10 @@ func createTable(db *DB, t *testing.T) { } func TestDBRace(t *testing.T) { - // TODO(sgotti) this will not find concurrenct accesses to ql db from + // TODO(sgotti) this will not find concurrent accesses to ql db from // multiple processes using multiple goroutines. A test that spawns at // least two processes using multiple goroutines is needed. + // See https://github.com/coreos/rkt/pull/2391 oldGoMaxProcs := runtime.GOMAXPROCS(runtime.NumCPU()) defer runtime.GOMAXPROCS(oldGoMaxProcs) From 15b33b18f4693e30943b5539f0091b5a8755c939 Mon Sep 17 00:00:00 2001 From: Simone Gotti Date: Fri, 8 Apr 2016 14:55:05 +0200 Subject: [PATCH 0103/1304] rkt/image: check that discovery labels match manifest labels The spec in the discovery part says: "Implementations MUST ensure that the initial name and labels used for discovery matches the name and labels in the Image Manifest." Actually rkt just checks that the names matches but ignore the labels. This patch also check the labels. Like the other validation parts the check is executed only if the user doesn't pass `--insecure-options=image` A functional test is added. With this patch users calling `rkt fetch example.com/aci:latest` but receiving an aci with a different version (like v2.0) will receive a validation error. --- CHANGELOG.md | 4 +++ rkt/image/namefetcher.go | 10 ++++-- rkt/image/validator.go | 16 ++++++++++ tests/rkt_fetch_test.go | 69 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b09ab1b5a..b187c87f14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## vUNRELEASED +#### New features and UX changes + +- Ensure that the initial name and labels used for discovery match the name and labels in the Image Manifest as specified in the appc spec ([#2311](https://github.com/coreos/rkt/pull/2311)). Users wanting the latest image should use `rkt prepare/run/fetch example.com/aci` without any labels. If the discovery server supports the "latest" pattern, the user can bypass a locally cached image in the store and fetch an updated image using `rkt prepare/run/fetch --no-store example.com/aci` option. + #### Note for packagers Files generated from sources are no longer checked-in the git repository. Instead, packagers should build them: diff --git a/rkt/image/namefetcher.go b/rkt/image/namefetcher.go index 9fded8f7f7..da128379e3 100644 --- a/rkt/image/namefetcher.go +++ b/rkt/image/namefetcher.go @@ -181,7 +181,7 @@ func (f *nameFetcher) fetchVerifiedURL(app *discovery.App, u *url.URL, a *asc) ( } } - if err := f.validate(appName, aciFile, ascFile); err != nil { + if err := f.validate(app, aciFile, ascFile); err != nil { return nil, nil, err } retAciFile := aciFile @@ -249,13 +249,17 @@ func (f *nameFetcher) checkIdentity(appName string, ascFile io.ReadSeeker) error return nil } -func (f *nameFetcher) validate(appName string, aciFile, ascFile io.ReadSeeker) error { +func (f *nameFetcher) validate(app *discovery.App, aciFile, ascFile io.ReadSeeker) error { v, err := newValidator(aciFile) if err != nil { return err } - if err := v.ValidateName(appName); err != nil { + if err := v.ValidateName(app.Name.String()); err != nil { + return err + } + + if err := v.ValidateLabels(app.Labels); err != nil { return err } diff --git a/rkt/image/validator.go b/rkt/image/validator.go index bace2715fc..a9c0751632 100644 --- a/rkt/image/validator.go +++ b/rkt/image/validator.go @@ -24,6 +24,7 @@ import ( "github.com/appc/spec/aci" "github.com/appc/spec/schema" + "github.com/appc/spec/schema/types" "golang.org/x/crypto/openpgp" pgperrors "golang.org/x/crypto/openpgp/errors" ) @@ -64,6 +65,21 @@ func (v *validator) ValidateName(imageName string) error { return nil } +// ValidateLabels checks if desired image labels are actually the same as +// the ones in the image manifest. +func (v *validator) ValidateLabels(labels map[types.ACIdentifier]string) error { + for n, rv := range labels { + if av, ok := v.manifest.GetLabel(n.String()); ok { + if rv != av { + return fmt.Errorf("requested value for label %q: %q differs from fetched aci label value: %q", n, rv, av) + } + } else { + return fmt.Errorf("requested label %q not provided by the image manifest", n) + } + } + return nil +} + // ValidateWithSignature verifies the image against a given signature // file. func (v *validator) ValidateWithSignature(ks *keystore.Keystore, sig io.ReadSeeker) (*openpgp.Entity, error) { diff --git a/tests/rkt_fetch_test.go b/tests/rkt_fetch_test.go index a13867bc9d..69634e4d2e 100644 --- a/tests/rkt_fetch_test.go +++ b/tests/rkt_fetch_test.go @@ -17,6 +17,7 @@ package main import ( "fmt" "io" + "io/ioutil" "net/http" "net/http/httptest" "os" @@ -458,3 +459,71 @@ func TestDeferredSignatureDownload(t *testing.T) { } } } + +func TestDifferentDiscoveryLabels(t *testing.T) { + manifestTemplate := `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.2.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}]}` + emptyImage := getEmptyImagePath() + imageName := "localhost/rkt-test-different-discovery-labels-image" + manifest := strings.Replace(manifestTemplate, "IMG_NAME", imageName, -1) + tmpDir := createTempDirOrPanic("rkt-TestDifferentDiscoveryLabels-") + defer os.RemoveAll(tmpDir) + + tmpManifest, err := ioutil.TempFile(tmpDir, "manifest") + if err != nil { + panic(fmt.Sprintf("Cannot create temp manifest: %v", err)) + } + if err := ioutil.WriteFile(tmpManifest.Name(), []byte(manifest), 0600); err != nil { + panic(fmt.Sprintf("Cannot write to temp manifest: %v", err)) + } + defer os.Remove(tmpManifest.Name()) + + image := patchACI(emptyImage, "rkt-test-different-discovery-labels-image.aci", "--manifest", tmpManifest.Name()) + imageFileName := fmt.Sprintf("%s.aci", filepath.Base(imageName)) + defer os.Remove(image) + + asc := runSignImage(t, image, 1) + defer os.Remove(asc) + ascBase := filepath.Base(asc) + + setup := taas.GetDefaultServerSetup() + server := runServer(t, setup) + defer server.Close() + fileSet := make(map[string]string, 2) + fileSet[imageFileName] = image + fileSet[ascBase] = asc + if err := server.UpdateFileSet(fileSet); err != nil { + t.Fatalf("Failed to populate a file list in test aci server: %v", err) + } + + tests := []struct { + imageName string + expectedMessage string + }{ + {imageName + ":2.0", fmt.Sprintf("requested value for label %q: %q differs from fetched aci label value: %q", "version", "2.0", "1.2.0")}, + {imageName + ":latest", fmt.Sprintf("requested value for label %q: %q differs from fetched aci label value: %q", "version", "latest", "1.2.0")}, + {imageName + ",arch=armv7b", fmt.Sprintf("requested value for label %q: %q differs from fetched aci label value: %q", "arch", "armv7b", "amd64")}, + {imageName + ",unexistinglabel=bla", fmt.Sprintf("requested label %q not provided by the image manifest", "unexistinglabel")}, + } + + for _, tt := range tests { + testDifferentDiscoveryNameLabels(t, tt.imageName, tt.expectedMessage) + } +} + +func testDifferentDiscoveryNameLabels(t *testing.T, imageName string, expectedMessage string) { + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + runRktTrust(t, ctx, "", 1) + + // Since aci-server provided meta tag template doesn't contains + // {version} {os} or {arch}, we can just ask for any version/os/arch + // and always get the same ACI + runCmd := fmt.Sprintf("%s --debug --insecure-options=tls fetch %s", ctx.Cmd(), imageName) + child := spawnOrFail(t, runCmd) + defer waitOrFail(t, child, 1) + + if err := expectWithOutput(child, expectedMessage); err != nil { + t.Fatalf("Could not find expected msg %q, output follows:\n%v", expectedMessage, err) + } +} From 3d610d8ada044be14f5f6665005ef6fe1f9c8bfb Mon Sep 17 00:00:00 2001 From: Wlodzimierz Borkowski Date: Tue, 8 Mar 2016 08:36:12 +0100 Subject: [PATCH 0104/1304] functional tests: Add new test with systemd-proxyd Setting ptp template network and IP address in systemd unit during test. Updated also docs with example. --- Documentation/using-rkt-with-systemd.md | 79 ++++++++++ tests/rkt_socket_proxyd_test.go | 200 ++++++++++++++++++++++++ 2 files changed, 279 insertions(+) create mode 100644 tests/rkt_socket_proxyd_test.go diff --git a/Documentation/using-rkt-with-systemd.md b/Documentation/using-rkt-with-systemd.md index 6db494365d..47dad93524 100644 --- a/Documentation/using-rkt-with-systemd.md +++ b/Documentation/using-rkt-with-systemd.md @@ -202,6 +202,84 @@ Jul 30 12:24:50 locke-work systemd[1]: Listening on My socket-activated app's so Now, a new connection to port 8080 will start your container to handle the request. +### Bidirectionally proxy local sockets to another (possibly remote) socket. + +`rkt` also supports the [socket-proxyd service][systemd-socket-proxyd]. Much like socket activation, with socket-proxyd systemd provides a listener on a given port on behalf of a container, and starts the container when a connection is received. Socket-proxy listening can be useful in environments that lack native support for socket activation. The LKVM stage1 flavor is an example of such an environment. + +To set up socket proxyd, create a network template consisting of three units, like the example below. This example uses the redis app and the PTP network template in `/etc/rkt/net.d/ptp0.conf`: + +```json +{ + "name": "ptp0", + "type": "ptp", + "ipMasq": true, + "ipam": { + "type": "host-local", + "subnet": "172.16.28.0/24", + "routes": [ + { "dst": "0.0.0.0/0" } + ] + } +} +``` + +``` +# rkt-redis.service +[Unit] +Description=Socket-proxyd redis server + +[Service] +ExecStart=/usr/bin/rkt --insecure-options=image run --net="ptp:IP=172.16.28.101" docker://redis +KillMode=process +``` +Note that you have to specify IP manually in systemd unit. + +Then you will need a pair of `.service` and `.socket` unit files. + +We want to use the port 6379 on the localhost instead of the remote container IP, +so we use next systemd unit to override it. + +``` +# proxy-to-rkt-redis.service +[Unit] +Requires=rkt-redis.service +After=rkt-redis.service + +[Service] +ExecStart=/usr/lib/systemd/systemd-socket-proxyd 172.16.28.101:6379 +``` +Lastly the related socket unit, +``` +# proxy-to-rkt-redis.socket +[Socket] +ListenStream=6371 + +[Install] +WantedBy=sockets.target +``` + +Finally, start the socket unit: + +``` +# systemctl enable proxy-to-redis.socket +$ sudo systemctl start proxy-to-redis.socket +● proxy-to-rkt-redis.socket + Loaded: loaded (/etc/systemd/system/proxy-to-rkt-redis.socket; enabled; vendor preset: disabled) + Active: active (listening) since Mon 2016-03-07 11:53:32 CET; 8s ago + Listen: [::]:6371 (Stream) + +Mar 07 11:53:32 user-host systemd[1]: Listening on proxy-to-rkt-redis.socket. +Mar 07 11:53:32 user-host systemd[1]: Starting proxy-to-rkt-redis.socket. + +``` + +Now, a new connection to localhost port 6371 will start your container with redis, to handle the request. + +``` +$ curl http://localhost:6371/ +``` + + ## Other tools for managing pods Let us assume the service from the simple example unit file, above, is started on the host. @@ -309,3 +387,4 @@ $ systemd-cgls --all [systemd-machined]: http://www.freedesktop.org/software/systemd/man/systemd-machined.service.html [systemd-run]: http://www.freedesktop.org/software/systemd/man/systemd-run.html [systemd-socket-activated]: http://www.freedesktop.org/software/systemd/man/sd_listen_fds.html +[systemd-socket-proxyd]: https://www.freedesktop.org/software/systemd/man/systemd-socket-proxyd.html diff --git a/tests/rkt_socket_proxyd_test.go b/tests/rkt_socket_proxyd_test.go new file mode 100644 index 0000000000..8c07df2c1e --- /dev/null +++ b/tests/rkt_socket_proxyd_test.go @@ -0,0 +1,200 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "bufio" + "fmt" + "io/ioutil" + "math/rand" + "net" + "os" + "path/filepath" + "testing" + "time" + + sd_dbus "github.com/coreos/go-systemd/dbus" + sd_util "github.com/coreos/go-systemd/util" + "github.com/coreos/rkt/tests/testutils" + "github.com/vishvananda/netlink" +) + +func TestSocketProxyd(t *testing.T) { + if !sd_util.IsRunningSystemd() { + t.Skip("Systemd is not running on the host.") + } + + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + iface, _, err := testutils.GetNonLoIfaceWithAddrs(netlink.FAMILY_V4) + if err != nil { + t.Fatalf("Error while getting non-lo host interface: %v\n", err) + } + if iface.Name == "" { + t.Skipf("Cannot run test without non-lo host interface") + } + + nt := networkTemplateT{ + Name: "ptp0", + Type: "ptp", + IpMasq: true, + Master: iface.Name, + Ipam: ipamTemplateT{ + Type: "host-local", + Subnet: "192.168.0.0/24", + Routes: []map[string]string{ + {"dst": "0.0.0.0/0"}, + }, + }, + } + + netDir := prepareTestNet(t, ctx, nt) + defer os.RemoveAll(netDir) + + port, err := randomFreePort(t) + if err != nil { + t.Fatal(err) + } + + echoImage := patchTestACI("rkt-inspect-echo.aci", + "--exec=/echo-socket-activated", + "--ports=test-port,protocol=tcp,port=80,socketActivated=true") + defer os.Remove(echoImage) + + conn, err := sd_dbus.New() + if err != nil { + t.Fatal(err) + } + + rktTestingEchoService := ` + [Unit] + Description=Socket-activated echo server + + [Service] + ExecStart=%s + KillMode=process + ` + + r := rand.New(rand.NewSource(time.Now().UnixNano())) + rnd := r.Int() + + // Write unit files directly to runtime system units directory + // (/run/systemd/system) to avoid calling LinkUnitFiles - it is buggy in + // systemd v219 as it does not work with absolute paths. + unitsDir := "/run/systemd/system" + containerIP := "192.168.0.101" + + cmd := fmt.Sprintf("%s --insecure-options=image --debug run --net=\"%s:IP=%s\" --port=test-port:%d --mds-register=false %s", + ctx.Cmd(), nt.Name, containerIP, port, echoImage) + + serviceContent := fmt.Sprintf(rktTestingEchoService, cmd) + serviceTargetBase := fmt.Sprintf("rkt-testing-socket-activation-%d.service", rnd) + serviceTarget := filepath.Join(unitsDir, serviceTargetBase) + + if err := ioutil.WriteFile(serviceTarget, []byte(serviceContent), 0666); err != nil { + t.Fatal(err) + } + defer os.Remove(serviceTarget) + + rktTestingEchoSocket := ` + [Unit] + Description=Socket-activated netcat server socket + + [Socket] + ListenStream=%d + + [Install] + WantedBy=sockets.target + ` + + socketContent := fmt.Sprintf(rktTestingEchoSocket, port) + socketTargetBase := fmt.Sprintf("proxy-to-rkt-testing-socket-activation-%d.socket", rnd) + socketTarget := filepath.Join(unitsDir, socketTargetBase) + + if err := ioutil.WriteFile(socketTarget, []byte(socketContent), 0666); err != nil { + t.Fatal(err) + } + defer os.Remove(socketTarget) + + proxyToRktTestingEchoService := ` + [Unit] + Requires=%s + After=%s + + [Service] + ExecStart=/lib/systemd/systemd-socket-proxyd %s:%d + ` + + proxyContent := fmt.Sprintf(proxyToRktTestingEchoService, serviceTargetBase, serviceTargetBase, containerIP, port) + proxyContentBase := fmt.Sprintf("proxy-to-rkt-testing-socket-activation-%d.service", rnd) + proxyTarget := filepath.Join(unitsDir, proxyContentBase) + + if err := ioutil.WriteFile(proxyTarget, []byte(proxyContent), 0666); err != nil { + t.Fatal(err) + } + defer os.Remove(proxyTarget) + + reschan := make(chan string) + doJob := func() { + job := <-reschan + if job != "done" { + t.Fatal("Job is not done:", job) + } + } + + if _, err := conn.StartUnit(socketTargetBase, "replace", reschan); err != nil { + t.Fatal(err) + } + doJob() + + defer func() { + if _, err := conn.StopUnit(socketTargetBase, "replace", reschan); err != nil { + t.Fatal(err) + } + doJob() + + if _, err := conn.StopUnit(serviceTargetBase, "replace", reschan); err != nil { + t.Fatal(err) + } + doJob() + + if _, err := conn.StopUnit(proxyContentBase, "replace", reschan); err != nil { + t.Fatal(err) + } + doJob() + }() + + expected := "HELO\n" + sockConn, err := net.Dial("tcp", fmt.Sprintf("localhost:%d", port)) + if err != nil { + t.Fatal(err) + } + + if _, err := fmt.Fprintf(sockConn, expected); err != nil { + t.Fatal(err) + } + + answer, err := bufio.NewReader(sockConn).ReadString('\n') + if err != nil { + t.Fatal(err) + } + + if answer != expected { + t.Fatalf("Expected %q, Got %q", expected, answer) + } + + return +} From 6d8c7ae4d695a8fbb4919ceaf26bf4410999f73f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Tue, 12 Apr 2016 12:06:40 +0200 Subject: [PATCH 0105/1304] stage1/init: create empty volume directory always If there was an implicit empty volume and the image was converted from docker, we copy the files from the image to the volume. However, if the image defines the mountpoint but the directory is not actually present in the image, CopyTree will do nothing and the volume directory won't be created, making the following Chown call fail. We now create the directory always. If CopyTree already created it, it doesn't hurt. --- stage1/init/common/mount.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/stage1/init/common/mount.go b/stage1/init/common/mount.go index cbfd8c9a7a..2b9a3936d5 100644 --- a/stage1/init/common/mount.go +++ b/stage1/init/common/mount.go @@ -162,11 +162,10 @@ func PrepareMountpoints(volPath string, targetPath string, vol *types.Volume, do return errwrap.Wrap(fmt.Errorf("error copying image files to empty volume %q", volPath), err) } } - } else { - if err := os.MkdirAll(volPath, 0770); err != nil { - return errwrap.Wrap(fmt.Errorf("error creating %q", volPath), err) - } + } + if err := os.MkdirAll(volPath, 0770); err != nil { + return errwrap.Wrap(fmt.Errorf("error creating %q", volPath), err) } if err := os.Chown(volPath, Uid, Gid); err != nil { return errwrap.Wrap(fmt.Errorf("could not change owner of %q", volPath), err) From 9939be1749014da029a4e1447a26e81be9dcf3b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Tue, 12 Apr 2016 11:42:37 +0200 Subject: [PATCH 0106/1304] functional tests: use different image names for docker vol semantics test We were only testing the last generated image, and the other cases worked because there was no volume being mounted there and hence the files were visible. Name each test image differently so we actually do the tests. --- tests/rkt_volume_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/rkt_volume_test.go b/tests/rkt_volume_test.go index 2a25650b16..2d468d8a72 100644 --- a/tests/rkt_volume_test.go +++ b/tests/rkt_volume_test.go @@ -169,8 +169,8 @@ func TestDockerVolumeSemantics(t *testing.T) { defer ctx.Cleanup() var dockerVolImage []string - for _, tt := range volDockerTests { - img := patchTestACI("rkt-volume-image.aci", fmt.Sprintf("--mounts=mydir,path=%s,readOnly=false", tt.dir)) + for i, tt := range volDockerTests { + img := patchTestACI(fmt.Sprintf("rkt-volume-image-%d.aci", i), fmt.Sprintf("--mounts=mydir,path=%s,readOnly=false", tt.dir)) defer os.Remove(img) dockerVolImage = append(dockerVolImage, img) } From 4112d50b1e724637ecef9a65606e1f77a78b9da5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Tue, 12 Apr 2016 10:58:38 +0200 Subject: [PATCH 0107/1304] stage1/init: get annotations from the ImageManifest To detect if we're running an image that was converted from docker, we were getting annotations from the RuntimeApp. This doesn't work for the case where the user runs rkt directly with a pod manifest, since they can omit the annotations there. Instead, use the ImageManifest, which is the right place to look for annotations. --- stage1/init/common/mount.go | 8 ++++---- stage1/init/common/pod.go | 3 ++- stage1/init/kvm.go | 8 +++++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/stage1/init/common/mount.go b/stage1/init/common/mount.go index 2b9a3936d5..2f264b422a 100644 --- a/stage1/init/common/mount.go +++ b/stage1/init/common/mount.go @@ -56,8 +56,8 @@ func IsMountReadOnly(vol types.Volume, mountPoints []types.MountPoint) bool { return isMPReadOnly(mountPoints, vol.Name) } -func convertedFromDocker(ra *schema.RuntimeApp) bool { - ann := ra.Annotations +func convertedFromDocker(im *schema.ImageManifest) bool { + ann := im.Annotations _, ok := ann.Get("appc.io/docker/repository") return ok } @@ -65,7 +65,7 @@ func convertedFromDocker(ra *schema.RuntimeApp) bool { // GenerateMounts maps MountPoint paths to volumes, returning a list of mounts, // each with a parameter indicating if it's an implicit empty volume from a // Docker image. -func GenerateMounts(ra *schema.RuntimeApp, volumes map[types.ACName]types.Volume) []mountWrapper { +func GenerateMounts(ra *schema.RuntimeApp, volumes map[types.ACName]types.Volume, imageManifest *schema.ImageManifest) []mountWrapper { app := ra.App var genMnts []mountWrapper @@ -101,7 +101,7 @@ func GenerateMounts(ra *schema.RuntimeApp, volumes map[types.ACName]types.Volume GID: &defaultGID, } - dockerImplicit := convertedFromDocker(ra) + dockerImplicit := convertedFromDocker(imageManifest) log.Printf("warning: no volume specified for mount point %q, implicitly creating an \"empty\" volume. This volume will be removed when the pod is garbage-collected.", mp.Name) if dockerImplicit { log.Printf("Docker converted image, initializing implicit volume with data contained at the mount point %q.", mp.Name) diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index ce213b2f6c..0737c9db1a 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -629,7 +629,8 @@ func appToNspawnArgs(p *stage1commontypes.Pod, ra *schema.RuntimeApp) ([]string, vols[v.Name] = v } - mounts := GenerateMounts(ra, vols) + imageManifest := p.Images[appName.String()] + mounts := GenerateMounts(ra, vols, imageManifest) for _, m := range mounts { vol := vols[m.Volume] diff --git a/stage1/init/kvm.go b/stage1/init/kvm.go index 40c423cc3f..cb16b7f26d 100644 --- a/stage1/init/kvm.go +++ b/stage1/init/kvm.go @@ -48,9 +48,10 @@ func KvmNetworkingToSystemd(p *stage1commontypes.Pod, n *networking.Networking) return nil } -func mountSharedVolumes(root string, volumes []types.Volume, ra *schema.RuntimeApp) error { +func mountSharedVolumes(root string, p *stage1commontypes.Pod, ra *schema.RuntimeApp) error { app := ra.App appName := ra.Name + volumes := p.Manifest.Volumes vols := make(map[types.ACName]types.Volume) for _, v := range volumes { vols[v.Name] = v @@ -64,7 +65,8 @@ func mountSharedVolumes(root string, volumes []types.Volume, ra *schema.RuntimeA return errwrap.Wrap(fmt.Errorf("could not change permissions of %q", sharedVolPath), err) } - mounts := stage1initcommon.GenerateMounts(ra, vols) + imageManifest := p.Images[appName.String()] + mounts := stage1initcommon.GenerateMounts(ra, vols, imageManifest) for _, m := range mounts { vol := vols[m.Volume] @@ -155,7 +157,7 @@ func ensureDestinationExists(source, destination string) error { func prepareMountsForApp(s1Root string, p *stage1commontypes.Pod, ra *schema.RuntimeApp) error { // bind mount all shared volumes (we don't use mechanism for bind-mounting given by nspawn) - if err := mountSharedVolumes(s1Root, p.Manifest.Volumes, ra); err != nil { + if err := mountSharedVolumes(s1Root, p, ra); err != nil { return errwrap.Wrap(errors.New("failed to prepare mount point"), err) } From e38cf060b20f30333af1a2f4d5c4e436c5c03466 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Tue, 12 Apr 2016 11:40:25 +0200 Subject: [PATCH 0108/1304] functional tests: add docker vol semantics + pod manifest test --- tests/rkt_run_pod_manifest_test.go | 17 ---------- tests/rkt_tests.go | 17 ++++++++++ tests/rkt_volume_test.go | 52 ++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 17 deletions(-) diff --git a/tests/rkt_run_pod_manifest_test.go b/tests/rkt_run_pod_manifest_test.go index 87fe3dd746..322156b206 100644 --- a/tests/rkt_run_pod_manifest_test.go +++ b/tests/rkt_run_pod_manifest_test.go @@ -41,23 +41,6 @@ func stringP(s string) *string { return &s } -func generatePodManifestFile(t *testing.T, manifest *schema.PodManifest) string { - tmpDir := testutils.GetValueFromEnvOrPanic("FUNCTIONAL_TMP") - f, err := ioutil.TempFile(tmpDir, "rkt-test-manifest-") - if err != nil { - t.Fatalf("Cannot create tmp pod manifest: %v", err) - } - - data, err := json.Marshal(manifest) - if err != nil { - t.Fatalf("Cannot marshal pod manifest: %v", err) - } - if err := ioutil.WriteFile(f.Name(), data, 0600); err != nil { - t.Fatalf("Cannot write pod manifest file: %v", err) - } - return f.Name() -} - func verifyHostFile(t *testing.T, tmpdir, filename string, i int, expectedResult string) { filePath := path.Join(tmpdir, filename) defer os.Remove(filePath) diff --git a/tests/rkt_tests.go b/tests/rkt_tests.go index a7c5fbd8fe..a85740f28a 100644 --- a/tests/rkt_tests.go +++ b/tests/rkt_tests.go @@ -679,6 +679,23 @@ func runRktTrust(t *testing.T, ctx *testutils.RktRunCtx, prefix string, keyIndex } } +func generatePodManifestFile(t *testing.T, manifest *schema.PodManifest) string { + tmpDir := testutils.GetValueFromEnvOrPanic("FUNCTIONAL_TMP") + f, err := ioutil.TempFile(tmpDir, "rkt-test-manifest-") + if err != nil { + t.Fatalf("Cannot create tmp pod manifest: %v", err) + } + + data, err := json.Marshal(manifest) + if err != nil { + t.Fatalf("Cannot marshal pod manifest: %v", err) + } + if err := ioutil.WriteFile(f.Name(), data, 0600); err != nil { + t.Fatalf("Cannot write pod manifest file: %v", err) + } + return f.Name() +} + func checkUserNS() error { // CentOS 7 pretends to support user namespaces, but does not. // See https://bugzilla.redhat.com/show_bug.cgi?id=1168776#c5 diff --git a/tests/rkt_volume_test.go b/tests/rkt_volume_test.go index 2d468d8a72..2d9d24bde1 100644 --- a/tests/rkt_volume_test.go +++ b/tests/rkt_volume_test.go @@ -24,6 +24,9 @@ import ( "time" "github.com/coreos/rkt/tests/testutils" + + "github.com/appc/spec/schema" + "github.com/appc/spec/schema/types" ) var volTests = []struct { @@ -184,3 +187,52 @@ func TestDockerVolumeSemantics(t *testing.T) { runRktAndCheckOutput(t, cmd, expected, false) } } + +func TestDockerVolumeSemanticsPodManifest(t *testing.T) { + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + for i, tt := range volDockerTests { + t.Logf("Running test #%v on directory %s", i, tt.dir) + + hash := patchImportAndFetchHash(fmt.Sprintf("rkt-volume-image-pm-%d.aci", i), []string{fmt.Sprintf("--mounts=mydir,path=%s,readOnly=false", tt.dir)}, t, ctx) + + imgID, err := types.NewHash(hash) + if err != nil { + t.Fatalf("Cannot generate types.Hash from %v: %v", hash, err) + } + + pm := &schema.PodManifest{ + ACKind: schema.PodManifestKind, + ACVersion: schema.AppContainerVersion, + Apps: []schema.RuntimeApp{ + { + Name: "rkt-volume-image", + App: &types.App{ + Exec: []string{"/inspect", "--read-file"}, + User: "0", + Group: "0", + Environment: []types.EnvironmentVariable{ + {"FILE", fmt.Sprintf("%s/file", tt.dir)}, + }, + MountPoints: []types.MountPoint{ + {"mydir", tt.dir, false}, + }, + }, + Image: schema.RuntimeImage{ + ID: *imgID, + }, + }, + }, + } + + manifestFile := generatePodManifestFile(t, pm) + defer os.Remove(manifestFile) + + cmd := fmt.Sprintf("%s --debug --insecure-options=image run --pod-manifest=%s", ctx.Cmd(), manifestFile) + + expected := fmt.Sprintf("<<<%s>>>", tt.expectedContent) + + runRktAndCheckOutput(t, cmd, expected, false) + } +} From ef52083eb2f3e13d2f4b7a900aa1f406cef8052a Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Tue, 12 Apr 2016 16:30:40 +0200 Subject: [PATCH 0109/1304] documentation: remove superfluous dash --- Documentation/subcommands/run.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/subcommands/run.md b/Documentation/subcommands/run.md index d2971c6662..e8dd61349e 100644 --- a/Documentation/subcommands/run.md +++ b/Documentation/subcommands/run.md @@ -142,7 +142,7 @@ The read-only parameter is false by default. Syntax: ``` ----volume NAME,kind=host,source=SOURCE_PATH,readOnly=BOOL +--volume NAME,kind=host,source=SOURCE_PATH,readOnly=BOOL ``` In the following example, we make the host's `/srv/data` accessible to app1 on `/var/data`: From e846f29bc6eea2cbfa3e4b1d7579878715caad1f Mon Sep 17 00:00:00 2001 From: Yifan Gu Date: Fri, 8 Apr 2016 17:28:21 -0700 Subject: [PATCH 0110/1304] pods.go: Add pod.getGCMarkedTime(). This returns the timestamp when the pod is moved to garbage/exited-garbage. --- rkt/pods.go | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/rkt/pods.go b/rkt/pods.go index 761c518996..1ae0113648 100644 --- a/rkt/pods.go +++ b/rkt/pods.go @@ -478,7 +478,7 @@ func (p *pod) xToExitedGarbage() error { return nil } -// xToGarbage transitions a pod from prepared -> garbage or prepared -> garbage +// xToGarbage transitions a pod from abortedPrepared -> garbage or prepared -> garbage func (p *pod) xToGarbage() error { if !p.isAbortedPrepare && !p.isPrepared { return fmt.Errorf("bug: only failed prepare or prepared pods may transition to garbage") @@ -676,6 +676,7 @@ func (p *pod) refreshState() error { // waitExited waits for a pod to (run and) exit. func (p *pod) waitExited() error { + // isExited implies isExitedGarbage. for !p.isExited && !p.isAbortedPrepare && !p.isGarbage && !p.isGone { if err := p.SharedLock(); err != nil { return err @@ -764,6 +765,7 @@ func (p *pod) getModTime(path string) (time.Time, error) { if err != nil { return time.Time{}, err } + defer f.Close() fi, err := f.Stat() if err != nil { @@ -805,6 +807,29 @@ func (p *pod) getStartTime() (time.Time, error) { return t, err } +func (p *pod) getGCMarkedTime() (time.Time, error) { + if !p.isGarbage && !p.isExitedGarbage { + return time.Time{}, nil + } + + // At this point, the pod is in either exited-garbage dir, garbage dir or gone already. + podPath := p.path() + if podPath == "" { + // Pod is gone. + return time.Time{}, nil + } + + st := &syscall.Stat_t{} + if err := syscall.Lstat(podPath, st); err != nil { + if err == syscall.ENOENT { + // Pod is gone. + err = nil + } + return time.Time{}, err + } + return time.Unix(st.Ctim.Unix()), nil +} + type ErrChildNotReady struct { } From 490042fc2691733ba772280643be583f4ada5d5a Mon Sep 17 00:00:00 2001 From: Yifan Gu Date: Fri, 8 Apr 2016 18:21:47 -0700 Subject: [PATCH 0111/1304] api: Add 'gc_marked_at' field in the pod. --- api/v1alpha/api.pb.go | 213 ++++++++++++++++++++---------------------- api/v1alpha/api.proto | 11 ++- 2 files changed, 111 insertions(+), 113 deletions(-) diff --git a/api/v1alpha/api.pb.go b/api/v1alpha/api.pb.go index 048e000483..d801049bec 100644 --- a/api/v1alpha/api.pb.go +++ b/api/v1alpha/api.pb.go @@ -340,10 +340,16 @@ type Pod struct { Annotations []*KeyValue `protobuf:"bytes,7,rep,name=annotations" json:"annotations,omitempty"` // Cgroup of the pod, empty if the pod is not running. Cgroup string `protobuf:"bytes,8,opt,name=cgroup" json:"cgroup,omitempty"` - // Timestamp when the pod is created, nanoseconds since epoch. + // Timestamp of when the pod is created, nanoseconds since epoch. + // Zero if the pod is not created. CreatedAt int64 `protobuf:"varint,9,opt,name=created_at" json:"created_at,omitempty"` - // Timestamp when the pod is started, nanoseconds since epoch. + // Timestamp of when the pod is started, nanoseconds since epoch. + // Zero if the pod is not started. StartedAt int64 `protobuf:"varint,10,opt,name=started_at" json:"started_at,omitempty"` + // Timestamp of when the pod is moved to exited-garbage/garbage, + // in nanoseconds since epoch. + // Zero if the pod is not moved to exited-garbage/garbage yet. + GcMarkedAt int64 `protobuf:"varint,11,opt,name=gc_marked_at" json:"gc_marked_at,omitempty"` } func (m *Pod) Reset() { *m = Pod{} } @@ -1132,113 +1138,98 @@ var _PublicAPI_serviceDesc = grpc.ServiceDesc{ } var fileDescriptor0 = []byte{ - // 1717 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x9c, 0x58, 0x4b, 0x6f, 0xdb, 0xc6, - 0x16, 0x0e, 0xf5, 0xd6, 0x91, 0x2c, 0xcb, 0x63, 0x27, 0x51, 0x9c, 0xc7, 0xf5, 0x65, 0x6e, 0x12, - 0x5f, 0xe3, 0xc2, 0xb8, 0x71, 0xd2, 0x76, 0x13, 0x04, 0x95, 0x65, 0xda, 0x15, 0x62, 0x4b, 0x02, - 0xa3, 0xb8, 0x0d, 0xba, 0x20, 0x68, 0x89, 0x72, 0x88, 0x50, 0x22, 0x4b, 0x52, 0x4e, 0xdc, 0x65, - 0xd7, 0x45, 0xff, 0x41, 0x77, 0x5d, 0x77, 0x5b, 0xa0, 0xfb, 0xa2, 0xbf, 0xa4, 0x7f, 0xa1, 0xdd, - 0xf6, 0xcc, 0x83, 0xe4, 0x90, 0x96, 0x0d, 0xa3, 0xbb, 0x99, 0xf3, 0x9d, 0xf9, 0xe6, 0x3c, 0xe6, - 0x9c, 0x43, 0x09, 0xaa, 0xa6, 0x67, 0x6f, 0x7b, 0xbe, 0x1b, 0xba, 0xa4, 0x7c, 0xf6, 0xd4, 0x74, - 0xbc, 0x77, 0xa6, 0xda, 0x87, 0x5a, 0x77, 0x6a, 0x9e, 0x5a, 0xfb, 0xae, 0x3f, 0x35, 0x43, 0xf2, - 0x18, 0x0a, 0xe1, 0xb9, 0x67, 0xb5, 0x94, 0x0d, 0x65, 0xb3, 0xb1, 0x43, 0xb6, 0x85, 0xda, 0x36, - 0xd3, 0x19, 0x22, 0xa2, 0x33, 0x9c, 0xb4, 0xa0, 0x7c, 0x66, 0xf9, 0x81, 0xed, 0xce, 0x5a, 0x39, - 0x54, 0xad, 0xea, 0xd1, 0x56, 0xfd, 0x3e, 0x07, 0x45, 0xa6, 0x4d, 0x3e, 0x81, 0xda, 0x89, 0x19, - 0x58, 0xc6, 0x84, 0x51, 0x33, 0xca, 0xda, 0xce, 0x5a, 0x9a, 0x92, 0x5f, 0xab, 0x03, 0x55, 0x14, - 0x26, 0x34, 0x20, 0x67, 0x8f, 0x05, 0x2b, 0xae, 0x08, 0x81, 0xc2, 0xcc, 0x9c, 0x5a, 0xad, 0x3c, - 0x93, 0xb0, 0xb5, 0x7c, 0x7d, 0x21, 0x75, 0x3d, 0xf9, 0x2f, 0x34, 0xed, 0xa9, 0xe7, 0xfa, 0xa1, - 0x11, 0xda, 0x53, 0x2b, 0x08, 0xcd, 0xa9, 0xd7, 0x2a, 0xa2, 0x4a, 0x5e, 0x5f, 0xe6, 0xf2, 0x61, - 0x24, 0x26, 0xeb, 0x50, 0x99, 0x9a, 0x33, 0x7b, 0x82, 0xdb, 0x56, 0x09, 0x55, 0xea, 0x7a, 0xbc, - 0xa7, 0x97, 0x06, 0xf6, 0xb7, 0x56, 0xab, 0xcc, 0x8e, 0xb2, 0x35, 0x79, 0x06, 0x35, 0x73, 0x36, - 0x73, 0x43, 0x33, 0xc4, 0x8b, 0x82, 0x56, 0x65, 0x23, 0x8f, 0xfe, 0xac, 0xc4, 0xfe, 0xbc, 0xb2, - 0xce, 0x8f, 0x4d, 0x67, 0x6e, 0xe9, 0xb2, 0x96, 0xaa, 0x41, 0xb9, 0x67, 0x85, 0x1f, 0x5c, 0xff, - 0x7d, 0xec, 0x88, 0x22, 0x39, 0x82, 0x32, 0xdb, 0x3b, 0x7b, 0x2e, 0xdc, 0x65, 0x6b, 0x21, 0xfb, - 0x34, 0x72, 0x98, 0xae, 0xd5, 0x5f, 0x15, 0xc8, 0xb7, 0x3d, 0x6f, 0x21, 0xc7, 0x7f, 0xa0, 0x68, - 0xd3, 0x58, 0x32, 0x92, 0xda, 0x4e, 0x23, 0x1d, 0x61, 0x9d, 0x83, 0xe4, 0x09, 0x14, 0xd1, 0xed, - 0x90, 0xc7, 0xb1, 0x21, 0xd9, 0x8d, 0xb4, 0xaf, 0x29, 0xa0, 0x73, 0x9c, 0xdc, 0x85, 0xaa, 0xf5, - 0xd1, 0x0e, 0x8d, 0x91, 0x3b, 0xb6, 0x58, 0x74, 0x57, 0xf4, 0x0a, 0x15, 0x74, 0x70, 0x9f, 0x8d, - 0x41, 0xf1, 0x5a, 0x31, 0xf8, 0x3d, 0x07, 0xf9, 0x81, 0x3b, 0x16, 0x99, 0x55, 0xe2, 0xcc, 0x36, - 0x21, 0xef, 0x89, 0x54, 0xaf, 0xe8, 0x74, 0x79, 0xb9, 0x91, 0x78, 0x3c, 0x65, 0xe4, 0x06, 0x14, - 0x4c, 0xcf, 0x0b, 0xd0, 0x3e, 0x6a, 0x40, 0x5d, 0x76, 0x46, 0x67, 0x08, 0xf9, 0x1f, 0x54, 0x66, - 0x3c, 0xf0, 0x91, 0x99, 0xcd, 0x58, 0x4b, 0x64, 0x44, 0x8f, 0x35, 0xae, 0x7c, 0x0b, 0x19, 0x9f, - 0xcb, 0xd7, 0xf1, 0x99, 0xdc, 0x82, 0xd2, 0xe8, 0xd4, 0x77, 0xe7, 0x1e, 0xbe, 0x13, 0xea, 0xaf, - 0xd8, 0x91, 0xfb, 0x00, 0x23, 0xdf, 0x42, 0x17, 0xc6, 0x06, 0xd6, 0x44, 0x95, 0x3d, 0xaf, 0xaa, - 0x90, 0xb4, 0x43, 0x0a, 0xa3, 0x83, 0xbe, 0x80, 0x81, 0xc3, 0x42, 0xd2, 0x0e, 0xd5, 0x1d, 0xa8, - 0x44, 0xd7, 0xd1, 0xe8, 0xe1, 0x5a, 0x84, 0x33, 0xff, 0xde, 0x3a, 0x27, 0x6b, 0x50, 0x3c, 0xa3, - 0x90, 0x78, 0x4d, 0x7c, 0xa3, 0xfe, 0xa9, 0x40, 0x15, 0xc3, 0xb7, 0x6f, 0x3b, 0xa1, 0xe5, 0xd3, - 0x53, 0xf6, 0x38, 0xc0, 0x53, 0x79, 0x7a, 0x0a, 0x97, 0x58, 0x31, 0x25, 0x16, 0xd3, 0x00, 0x8f, - 0xe5, 0x17, 0x07, 0x5d, 0x28, 0xd0, 0xa7, 0x81, 0xb1, 0x35, 0xe8, 0xab, 0x0b, 0x30, 0x45, 0x94, - 0xa2, 0x82, 0x82, 0x1e, 0xdd, 0x53, 0x90, 0xbd, 0x34, 0x83, 0xf2, 0x17, 0x38, 0xc8, 0x04, 0x5d, - 0xbc, 0xe4, 0x21, 0x2c, 0x89, 0x58, 0x8b, 0xd3, 0x45, 0xa6, 0x50, 0x17, 0x42, 0xce, 0x90, 0x09, - 0x74, 0xe9, 0x5a, 0x81, 0xc6, 0x56, 0xc0, 0x43, 0xcb, 0x33, 0x83, 0xad, 0x40, 0x6c, 0xd5, 0xdf, - 0x72, 0x51, 0x6f, 0xbb, 0xcc, 0x75, 0xcc, 0xba, 0xe7, 0x5b, 0x13, 0xfb, 0xa3, 0x70, 0x1e, 0x2d, - 0x8e, 0xf6, 0x34, 0x13, 0xac, 0x7b, 0xc9, 0xce, 0x56, 0xa9, 0x84, 0xdb, 0x8a, 0x47, 0x31, 0xe4, - 0x68, 0x7b, 0xe2, 0x6c, 0xb4, 0xa7, 0x11, 0x75, 0xcc, 0x13, 0xcb, 0xb9, 0xa2, 0x3e, 0x84, 0x02, - 0x79, 0x04, 0x0d, 0xde, 0x96, 0x68, 0xc2, 0x27, 0x68, 0x25, 0x7b, 0x7d, 0x79, 0x7d, 0x29, 0x92, - 0xb6, 0xa9, 0x10, 0xeb, 0x62, 0x39, 0x56, 0x3b, 0xb1, 0xb0, 0xa1, 0x46, 0x9d, 0x29, 0x3e, 0xbd, - 0xcb, 0xa4, 0xff, 0xa8, 0x47, 0x51, 0x57, 0x27, 0x73, 0xc7, 0x11, 0xae, 0x56, 0xb9, 0xab, 0x54, - 0xc2, 0x5c, 0x55, 0xff, 0x52, 0xa0, 0x76, 0xe0, 0xb8, 0x27, 0xa6, 0xb3, 0xef, 0x98, 0xa7, 0x01, - 0x8d, 0xe3, 0xd8, 0xf6, 0xa3, 0x87, 0x87, 0x4b, 0xb2, 0x05, 0x2b, 0xc1, 0x79, 0x10, 0x5a, 0x53, - 0x6c, 0x1a, 0xb3, 0x89, 0x7d, 0x6a, 0x50, 0x9c, 0x3f, 0xc2, 0x65, 0x0e, 0x74, 0x98, 0x7c, 0x0f, - 0x75, 0x37, 0xa1, 0xe9, 0xb8, 0x23, 0xd3, 0x91, 0x55, 0x79, 0xa7, 0x6b, 0x30, 0x79, 0xa2, 0xf9, - 0x18, 0x96, 0xe7, 0x81, 0xe5, 0xcb, 0x8a, 0xbc, 0xd9, 0x2f, 0x51, 0x71, 0xa2, 0x47, 0x63, 0x38, - 0x0b, 0xac, 0xd1, 0xdc, 0xc7, 0x59, 0x43, 0x2d, 0x64, 0x0d, 0x1f, 0xd5, 0x22, 0x29, 0x37, 0xfb, - 0x29, 0xdc, 0x0c, 0xfd, 0x79, 0x10, 0x1a, 0x98, 0xa7, 0xc0, 0x98, 0xf8, 0xee, 0xd4, 0x78, 0x17, - 0x86, 0x5e, 0xc0, 0x22, 0x5e, 0xd1, 0x09, 0x03, 0x31, 0x40, 0xc1, 0x3e, 0x42, 0x5f, 0x50, 0x44, - 0xfd, 0x49, 0x81, 0x42, 0x77, 0x36, 0x71, 0xc9, 0xbf, 0xa0, 0xe6, 0xbf, 0x0f, 0x8d, 0x68, 0xe6, - 0x70, 0xd7, 0x01, 0x45, 0xc7, 0x62, 0xec, 0xfc, 0x1b, 0xea, 0x58, 0x08, 0x23, 0x23, 0x3d, 0x14, - 0x6b, 0x54, 0x16, 0xa9, 0x20, 0x07, 0xce, 0xdf, 0x58, 0x83, 0xfb, 0x0c, 0x28, 0x8a, 0x14, 0x3e, - 0x83, 0xfa, 0x29, 0x0b, 0xb3, 0xf0, 0xa2, 0x90, 0x19, 0x98, 0x52, 0x0e, 0xf4, 0xda, 0x69, 0xb2, - 0x51, 0x7f, 0x50, 0xa0, 0xa8, 0x9d, 0x59, 0xb3, 0xcb, 0xc7, 0x37, 0x43, 0xa5, 0xf1, 0xbd, 0x60, - 0xc6, 0xd2, 0x80, 0x44, 0x23, 0x87, 0xae, 0xa9, 0x8c, 0x8e, 0x50, 0x66, 0x06, 0x8e, 0x40, 0xba, - 0xc6, 0x50, 0x17, 0xc6, 0x66, 0x68, 0x5e, 0xfe, 0xae, 0x19, 0xac, 0xfe, 0x88, 0x2f, 0x86, 0x5d, - 0x29, 0x2a, 0x6f, 0x13, 0x8a, 0xf4, 0x5a, 0x5e, 0x7b, 0x8b, 0xed, 0xe2, 0x0a, 0x51, 0x8d, 0xe6, - 0x92, 0x1a, 0xc5, 0xa6, 0x26, 0x97, 0x20, 0xdf, 0xb0, 0x3e, 0x69, 0xcf, 0x46, 0x96, 0x21, 0x99, - 0x58, 0x65, 0x12, 0x3a, 0xdf, 0x29, 0x3c, 0x9f, 0x85, 0xb6, 0xc3, 0x61, 0x3e, 0xff, 0xab, 0x4c, - 0x42, 0x61, 0xb5, 0x09, 0x8d, 0x03, 0x2b, 0xa4, 0x99, 0xd5, 0xad, 0x6f, 0xe6, 0xd8, 0xe3, 0xd5, - 0xe7, 0xb0, 0x1c, 0x4b, 0x02, 0x0f, 0x8b, 0xc2, 0xc2, 0x94, 0x16, 0x6c, 0xdc, 0x8b, 0xef, 0x96, - 0xa5, 0x64, 0xaa, 0x52, 0x25, 0x06, 0xa9, 0x5f, 0xc2, 0xf2, 0xa1, 0x1d, 0x84, 0xd8, 0x27, 0x03, - 0x41, 0x84, 0x63, 0xa7, 0x3c, 0x61, 0x4e, 0x73, 0x67, 0x6b, 0x92, 0xb3, 0x71, 0x13, 0xd6, 0x23, - 0x15, 0x3a, 0x25, 0xc6, 0x56, 0x68, 0xda, 0x0e, 0xcb, 0x45, 0x45, 0x17, 0x3b, 0x34, 0xa7, 0x99, - 0x10, 0x0b, 0x7b, 0x70, 0xe4, 0x79, 0xee, 0x38, 0xa2, 0xad, 0xcb, 0xb4, 0x3a, 0x43, 0xd4, 0x87, - 0xb0, 0xd2, 0x9d, 0x05, 0x9e, 0x35, 0xa2, 0x07, 0x23, 0x83, 0x32, 0x43, 0x17, 0xa9, 0x89, 0xac, - 0x24, 0xc8, 0x1f, 0xe0, 0x28, 0x76, 0xc7, 0xc2, 0xd7, 0x34, 0x37, 0x05, 0xd4, 0xaf, 0x61, 0x85, - 0x1a, 0xc4, 0xda, 0x69, 0xec, 0xeb, 0x76, 0xd6, 0xd7, 0xec, 0xc7, 0xdd, 0x35, 0xbd, 0x7d, 0x01, - 0x44, 0x26, 0x17, 0x26, 0x3d, 0x86, 0x12, 0x1b, 0x1f, 0x11, 0x79, 0xf6, 0xbb, 0x46, 0xa0, 0xea, - 0x23, 0x58, 0x15, 0x0e, 0x71, 0xf9, 0x25, 0x7e, 0xbf, 0x80, 0xb5, 0xb4, 0x9a, 0xb8, 0x26, 0xfe, - 0x7a, 0x52, 0xae, 0xf8, 0x7a, 0x52, 0x3b, 0xb0, 0x4a, 0x4d, 0xb4, 0x66, 0xec, 0xc5, 0x4a, 0xd9, - 0x2e, 0x71, 0xe7, 0x2e, 0x7c, 0xdd, 0x4a, 0xcf, 0x5f, 0x17, 0x3a, 0xea, 0x4b, 0x58, 0x4b, 0x93, - 0x24, 0x9e, 0x5a, 0x4c, 0x72, 0xc1, 0x53, 0xa6, 0xa8, 0x0b, 0x54, 0xfd, 0x59, 0x61, 0xef, 0xf6, - 0xd0, 0x3d, 0x8d, 0x0d, 0xb8, 0x09, 0x25, 0x4c, 0x8f, 0x11, 0x7b, 0x5a, 0xc4, 0x5d, 0x77, 0x4c, - 0xee, 0x40, 0x25, 0x1a, 0xd4, 0xd1, 0xf7, 0xb9, 0x98, 0xd3, 0xb4, 0x9e, 0x1c, 0x7b, 0xc6, 0xea, - 0x49, 0xd9, 0x2c, 0xea, 0x7c, 0x43, 0x53, 0x33, 0x71, 0x1d, 0xc7, 0xfd, 0xc0, 0x6a, 0x09, 0x53, - 0xc3, 0x77, 0x99, 0x3a, 0x2b, 0x5e, 0x5d, 0x67, 0xa5, 0x6c, 0x9d, 0x3d, 0x61, 0x55, 0xc5, 0xed, - 0x15, 0xbe, 0xc6, 0xd7, 0xf3, 0x31, 0xcc, 0x37, 0x5b, 0x16, 0x54, 0xe3, 0x5f, 0x18, 0x38, 0xd1, - 0xd7, 0xba, 0x47, 0xed, 0x03, 0xcd, 0x18, 0xbe, 0x1d, 0x68, 0xc6, 0x9b, 0xde, 0x9e, 0xb6, 0xdf, - 0xed, 0x69, 0x7b, 0xcd, 0x1b, 0x64, 0x15, 0x96, 0x25, 0xa4, 0x3d, 0x18, 0x74, 0x9a, 0x0a, 0x86, - 0x60, 0x45, 0x12, 0xee, 0xf5, 0x3b, 0xaf, 0x34, 0xbd, 0x99, 0xc3, 0xf6, 0xd5, 0x90, 0xc4, 0xfd, - 0x4e, 0xb7, 0x99, 0xdf, 0x1a, 0x40, 0x25, 0xfa, 0xda, 0x25, 0xb7, 0x61, 0x15, 0x09, 0x8c, 0xd7, - 0xc3, 0xf6, 0x30, 0x7d, 0x09, 0xf2, 0x25, 0x80, 0xfe, 0xa6, 0xd7, 0xeb, 0xf6, 0x0e, 0xf0, 0x9a, - 0x35, 0x68, 0x26, 0x62, 0xed, 0xab, 0xee, 0x10, 0x95, 0x73, 0x5b, 0x7f, 0x28, 0x50, 0x89, 0x3e, - 0x93, 0x28, 0xe5, 0xa0, 0xbf, 0xb7, 0x80, 0x12, 0xcf, 0x26, 0x80, 0x76, 0xb4, 0xab, 0xbf, 0xed, - 0x23, 0x63, 0x4a, 0x7d, 0xa0, 0x6b, 0x83, 0xb6, 0x4e, 0xaf, 0xca, 0x61, 0x32, 0x48, 0x16, 0x40, - 0x9a, 0x3c, 0xb5, 0x2c, 0x91, 0x47, 0x96, 0x15, 0x30, 0x09, 0x77, 0x12, 0x71, 0x7b, 0xb7, 0xaf, - 0xa3, 0x69, 0xd1, 0xb1, 0x66, 0x31, 0x73, 0x39, 0x37, 0xbc, 0x94, 0xbe, 0x63, 0x4f, 0x3b, 0xd4, - 0x86, 0x94, 0xac, 0x9c, 0xbe, 0xe3, 0xa0, 0xad, 0xef, 0x62, 0x08, 0x9b, 0x95, 0xad, 0x5f, 0x72, - 0x50, 0x8d, 0x9b, 0x35, 0xcd, 0x90, 0x76, 0xac, 0xf5, 0x86, 0x17, 0x33, 0x74, 0x17, 0x6e, 0x4b, - 0x08, 0x65, 0x8a, 0xed, 0x57, 0x88, 0x0a, 0x0f, 0x16, 0x83, 0x91, 0xd5, 0xe8, 0xfb, 0x3a, 0xdc, - 0xca, 0xe8, 0xa0, 0x29, 0x0c, 0xcb, 0xe3, 0xab, 0xbe, 0x99, 0xc1, 0x84, 0x3b, 0x05, 0xac, 0xe2, - 0x8d, 0x0c, 0x24, 0x6c, 0x37, 0x3a, 0xfd, 0xc3, 0x43, 0xad, 0x43, 0xb5, 0x8a, 0x19, 0x72, 0x91, - 0x4e, 0x9d, 0x07, 0x24, 0x4d, 0x4e, 0x31, 0x41, 0x5e, 0xa6, 0x01, 0x96, 0x20, 0xfe, 0xaa, 0xba, - 0x47, 0x03, 0x6e, 0x72, 0x85, 0xdc, 0x83, 0xd6, 0x05, 0x58, 0xd7, 0x8e, 0xfa, 0xc7, 0x88, 0x56, - 0x77, 0xbe, 0x2b, 0xe0, 0xe7, 0xf7, 0xfc, 0xc4, 0xb1, 0x47, 0xed, 0x41, 0x97, 0xbc, 0x84, 0xb2, - 0x98, 0x33, 0xe4, 0x76, 0x32, 0xd8, 0x53, 0xb3, 0x68, 0xbd, 0x75, 0x11, 0xe0, 0xc5, 0xa3, 0xde, - 0x20, 0x6d, 0xa8, 0x44, 0x83, 0x81, 0x24, 0x7a, 0x99, 0x21, 0xb4, 0x7e, 0x67, 0x01, 0x12, 0x53, - 0x1c, 0x00, 0x24, 0x03, 0x80, 0xac, 0x4b, 0x73, 0x2d, 0x33, 0x3a, 0xd6, 0xef, 0x2e, 0xc4, 0x64, - 0xa2, 0xa4, 0x6d, 0x4b, 0x44, 0x17, 0x06, 0x85, 0x44, 0x74, 0xb1, 0xcf, 0x23, 0xd1, 0x11, 0xd4, - 0xe5, 0xd6, 0x4c, 0xee, 0x65, 0xef, 0x95, 0x1b, 0xfb, 0xfa, 0xfd, 0x4b, 0xd0, 0x98, 0xae, 0x0f, - 0x75, 0xb9, 0xcd, 0x4a, 0x74, 0x0b, 0x5a, 0xb8, 0x44, 0xb7, 0xa8, 0x37, 0xab, 0x37, 0xfe, 0xaf, - 0x90, 0xcf, 0x59, 0xd2, 0x68, 0x1b, 0x4b, 0x27, 0x4d, 0x6a, 0xc4, 0xe9, 0xa4, 0xc9, 0x1d, 0x8f, - 0x32, 0x9c, 0x94, 0xd8, 0xbf, 0x2e, 0xcf, 0xfe, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xb2, 0xc6, 0x99, - 0x3e, 0x82, 0x11, 0x00, 0x00, + // 1481 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x57, 0xcd, 0x72, 0xdb, 0x46, + 0x12, 0x36, 0x7f, 0xc0, 0x9f, 0x26, 0x4d, 0x91, 0x23, 0xd9, 0xa2, 0xe8, 0x3f, 0x19, 0xbb, 0xeb, + 0xf2, 0xea, 0xa0, 0xdd, 0xc8, 0x8e, 0x2f, 0xa9, 0x4a, 0x99, 0x96, 0x20, 0x15, 0x63, 0x89, 0x64, + 0xd1, 0xb4, 0x2b, 0x3e, 0xa1, 0x20, 0x72, 0x28, 0xa3, 0x04, 0x02, 0x08, 0x00, 0xca, 0x56, 0x8e, + 0x39, 0xe5, 0x96, 0x47, 0xc8, 0x33, 0xe4, 0x94, 0x63, 0xde, 0x25, 0x55, 0x79, 0x8f, 0xf4, 0x0c, + 0x06, 0xc0, 0x00, 0x04, 0x0f, 0xb9, 0x89, 0xdd, 0x3d, 0x5f, 0x7f, 0xdd, 0xd3, 0xfd, 0x0d, 0x04, + 0x75, 0xc3, 0x35, 0x0f, 0x5d, 0xcf, 0x09, 0x1c, 0x52, 0xbd, 0xf9, 0xca, 0xb0, 0xdc, 0x4f, 0x86, + 0xfa, 0x1a, 0x1a, 0x83, 0xa5, 0x71, 0x45, 0x4f, 0x1d, 0x6f, 0x69, 0x04, 0x64, 0x1f, 0xca, 0xc1, + 0xad, 0x4b, 0xbb, 0x85, 0xfd, 0xc2, 0xf3, 0xd6, 0x11, 0x39, 0x14, 0x61, 0x87, 0x3c, 0x66, 0x8a, + 0x1e, 0xb2, 0x05, 0xd5, 0x1b, 0xea, 0xf9, 0xa6, 0x63, 0x77, 0x8b, 0x18, 0x54, 0x57, 0xff, 0x28, + 0x80, 0xc2, 0xdd, 0xe4, 0xbf, 0xd0, 0xb8, 0x34, 0x7c, 0xaa, 0x2f, 0x38, 0x16, 0xc7, 0x68, 0x1c, + 0xed, 0xa4, 0x31, 0x44, 0x1e, 0x80, 0xa2, 0x39, 0x0f, 0x01, 0x48, 0x13, 0xca, 0xb6, 0xb1, 0xa4, + 0xdd, 0x12, 0xff, 0x25, 0xe1, 0x97, 0xb9, 0xa1, 0x0b, 0x6d, 0x73, 0xe9, 0x3a, 0x5e, 0xa0, 0x07, + 0xe6, 0x92, 0xfa, 0x81, 0xb1, 0x74, 0xbb, 0x0a, 0x7a, 0x4a, 0xa4, 0x0d, 0xb5, 0xa5, 0x61, 0x9b, + 0x0b, 0x34, 0x76, 0x2b, 0x68, 0x69, 0x32, 0x28, 0xdf, 0xfc, 0x91, 0x76, 0xab, 0xdc, 0xff, 0x0c, + 0x1a, 0x86, 0x6d, 0x3b, 0x81, 0x11, 0x20, 0x9a, 0xdf, 0xad, 0xed, 0x97, 0x90, 0x4f, 0x27, 0xe6, + 0xf3, 0x96, 0xde, 0x7e, 0x30, 0xac, 0x15, 0x55, 0x5f, 0x40, 0x75, 0x48, 0x83, 0xcf, 0x8e, 0x77, + 0x1d, 0x73, 0x29, 0x44, 0xcc, 0x4c, 0xf7, 0xe6, 0x65, 0xc2, 0x13, 0x7f, 0xbd, 0x0a, 0x79, 0xaa, + 0xbf, 0x14, 0xa0, 0xd4, 0x77, 0xdd, 0xcc, 0x89, 0x47, 0xa0, 0x98, 0xac, 0x4c, 0x7e, 0xa4, 0x71, + 0xd4, 0x4a, 0x17, 0x8f, 0xed, 0x55, 0xb0, 0x80, 0x20, 0xac, 0xb5, 0x25, 0x71, 0x41, 0xa4, 0x77, + 0xcc, 0x41, 0x3a, 0x50, 0xa7, 0x5f, 0xcc, 0x40, 0x9f, 0x39, 0x73, 0xca, 0x1b, 0xd0, 0xc9, 0x96, + 0xa1, 0x6c, 0x2a, 0xe3, 0xe7, 0x22, 0x94, 0xc6, 0xce, 0x5c, 0xf4, 0x36, 0xe4, 0xd3, 0x80, 0x92, + 0x2b, 0x1a, 0xdd, 0xd9, 0x9c, 0x1d, 0x4f, 0x85, 0xd9, 0x7b, 0x50, 0x36, 0x5c, 0xd7, 0xc7, 0xc4, + 0x2c, 0x47, 0x53, 0xa6, 0x47, 0x54, 0xa8, 0xd9, 0x61, 0x97, 0x22, 0x0e, 0xed, 0xd8, 0x1f, 0xb5, + 0x6f, 0xfd, 0x46, 0x32, 0xe4, 0xab, 0x1b, 0xc8, 0x93, 0x16, 0x54, 0x66, 0x57, 0x9e, 0xb3, 0x72, + 0xf1, 0x9a, 0x18, 0x71, 0xac, 0x62, 0xe6, 0x51, 0xe4, 0x34, 0xd7, 0x71, 0x94, 0xea, 0xfc, 0x3e, + 0xd1, 0x86, 0xfc, 0x3d, 0x61, 0x03, 0x6e, 0xdb, 0x81, 0xe6, 0xd5, 0x4c, 0x5f, 0x1a, 0xde, 0x75, + 0x68, 0x6d, 0x30, 0xab, 0xfa, 0x0c, 0x6a, 0x31, 0x32, 0xb6, 0x00, 0xff, 0x16, 0xfd, 0xb8, 0x0b, + 0xca, 0x0d, 0xb3, 0x8a, 0xd9, 0xfd, 0xad, 0x00, 0x75, 0x2c, 0xfe, 0xd4, 0xb4, 0x02, 0xea, 0xb1, + 0x48, 0x73, 0xee, 0x63, 0x64, 0x09, 0x23, 0x9f, 0x42, 0x85, 0x37, 0xcb, 0xc7, 0xd0, 0x52, 0x7e, + 0xb7, 0x3a, 0x6c, 0xa3, 0x5c, 0x9d, 0x5d, 0xbf, 0x8f, 0x3d, 0x65, 0xa7, 0xd0, 0xc4, 0xef, 0x5f, + 0x67, 0x40, 0x65, 0x6e, 0xba, 0x07, 0x77, 0x45, 0xdf, 0x44, 0xa4, 0xc2, 0xcd, 0x99, 0xc6, 0x54, + 0x36, 0x35, 0x06, 0xf7, 0x21, 0x6c, 0x4c, 0xd8, 0xbc, 0xba, 0xfa, 0x67, 0x21, 0x5a, 0xd9, 0x1c, + 0xd6, 0x78, 0x01, 0xae, 0x47, 0x17, 0xe6, 0x17, 0xc1, 0x9b, 0x37, 0x92, 0x2f, 0xa5, 0xcc, 0x12, + 0xa3, 0xae, 0xe9, 0x2d, 0x52, 0x8a, 0x49, 0x62, 0xb5, 0x96, 0x71, 0x49, 0xad, 0xcd, 0xe3, 0x45, + 0xee, 0x43, 0x2b, 0xdc, 0x43, 0xd6, 0xe8, 0x05, 0x66, 0xe6, 0x37, 0x5c, 0x22, 0xbb, 0xb0, 0x15, + 0xdb, 0x2f, 0x29, 0xee, 0xfe, 0x3f, 0x5c, 0x3f, 0xc6, 0x70, 0xb1, 0xb2, 0x2c, 0xc1, 0xb0, 0xce, + 0x8b, 0xfc, 0x15, 0x8b, 0x3c, 0xb3, 0x9c, 0x4b, 0xc3, 0x3a, 0xb5, 0x8c, 0x2b, 0x9f, 0x15, 0x39, + 0x37, 0x3d, 0x71, 0x89, 0x7b, 0xd0, 0xf1, 0x6f, 0xfd, 0x80, 0x2e, 0x71, 0x4b, 0xec, 0x85, 0x79, + 0xa5, 0x33, 0x57, 0x31, 0x12, 0x0b, 0xcb, 0x99, 0x19, 0x96, 0xec, 0x09, 0x75, 0x05, 0x69, 0xae, + 0x7c, 0xea, 0xc9, 0x8e, 0x50, 0x5f, 0x58, 0x5d, 0xb6, 0x4f, 0x67, 0x2b, 0x0f, 0x95, 0x8b, 0x25, + 0xe3, 0xea, 0xc2, 0x56, 0xf9, 0x5e, 0xe0, 0xad, 0xfc, 0x40, 0xc7, 0x56, 0xf9, 0xfa, 0xc2, 0x73, + 0x96, 0xfa, 0xa7, 0x20, 0x70, 0x7d, 0x5e, 0x76, 0x4d, 0xf5, 0xa0, 0x3c, 0xb0, 0x17, 0x0e, 0xd9, + 0x86, 0x86, 0x77, 0x1d, 0xe8, 0x91, 0x66, 0x85, 0x0c, 0x71, 0x2a, 0x71, 0x32, 0x66, 0x7a, 0x4a, + 0x29, 0x59, 0x28, 0x2a, 0x70, 0x6c, 0x0c, 0x79, 0x1d, 0xe0, 0x00, 0xf3, 0x42, 0x45, 0xf2, 0x72, + 0x46, 0x35, 0xa5, 0x2e, 0x60, 0x4e, 0x45, 0xbb, 0xa1, 0xf6, 0x66, 0x99, 0xe6, 0x5e, 0x2e, 0xd3, + 0x19, 0x81, 0x65, 0xf4, 0x45, 0x42, 0xfc, 0xc5, 0x84, 0x94, 0x27, 0x2a, 0x91, 0x27, 0x50, 0x9e, + 0x1b, 0x81, 0xb1, 0x59, 0x55, 0x02, 0x68, 0x70, 0x54, 0x31, 0x6d, 0x4f, 0x41, 0x61, 0x99, 0xc3, + 0x79, 0xcb, 0x4f, 0x2d, 0x06, 0x32, 0x1c, 0x3f, 0x5c, 0x38, 0x79, 0xf2, 0xd8, 0x0a, 0x9b, 0xf6, + 0x8c, 0xea, 0x12, 0x05, 0xb4, 0xad, 0xec, 0xc0, 0xb4, 0x42, 0x1b, 0x97, 0x76, 0xb5, 0x0d, 0xad, + 0x33, 0x1a, 0xb0, 0x06, 0x4f, 0xe8, 0x0f, 0x2b, 0x94, 0x13, 0xf5, 0x10, 0xb6, 0x62, 0x8b, 0xef, + 0xe2, 0x40, 0x51, 0xf2, 0x00, 0x05, 0x19, 0x7f, 0x8b, 0x87, 0xe6, 0x6e, 0xa2, 0xb5, 0x68, 0x54, + 0x4f, 0x61, 0xeb, 0xdc, 0xf4, 0x03, 0x5c, 0x56, 0x5f, 0x40, 0x90, 0x7f, 0x41, 0x75, 0xc1, 0xab, + 0x08, 0xd9, 0x37, 0x24, 0xf6, 0x89, 0x08, 0xa0, 0x10, 0xcd, 0x69, 0x60, 0x98, 0x16, 0x6f, 0x5e, + 0x0d, 0xf3, 0xb6, 0x13, 0x1c, 0x91, 0x18, 0x65, 0xd2, 0x75, 0xe6, 0x11, 0x4a, 0x53, 0x46, 0x51, + 0x9f, 0x40, 0x67, 0x60, 0xfb, 0x2e, 0x9d, 0xb1, 0x23, 0x51, 0x66, 0x49, 0x92, 0xd5, 0xff, 0x01, + 0x91, 0x03, 0x04, 0xe4, 0x1e, 0x0a, 0xb5, 0x33, 0x17, 0xa5, 0xa4, 0x11, 0xbf, 0x83, 0x0e, 0x63, + 0xc0, 0x77, 0x3e, 0xae, 0xe5, 0x3f, 0xd9, 0x5a, 0xb2, 0xef, 0x6c, 0x7e, 0x35, 0x2f, 0x81, 0xc8, + 0x58, 0x22, 0xf9, 0x63, 0xa8, 0x70, 0xd5, 0x8a, 0xb0, 0x32, 0xcf, 0x96, 0xfa, 0x14, 0xb6, 0x05, + 0x65, 0xfe, 0x3b, 0xaf, 0xaa, 0xaf, 0x61, 0x27, 0x1d, 0x22, 0xa0, 0xe3, 0x07, 0xb1, 0x90, 0xf7, + 0x20, 0xaa, 0xdf, 0xc0, 0x36, 0xe3, 0x43, 0x6d, 0x3e, 0x3e, 0x71, 0x75, 0xff, 0x86, 0x4a, 0x58, + 0xdd, 0xda, 0x47, 0x84, 0x34, 0x8b, 0xea, 0x2b, 0xd8, 0x49, 0x1f, 0x4e, 0xca, 0xa1, 0xdc, 0xb2, + 0x56, 0x0e, 0x0f, 0x54, 0x6f, 0xf9, 0x70, 0x9d, 0x3b, 0x57, 0x71, 0x3e, 0x6c, 0x13, 0x76, 0x5f, + 0x8f, 0x9f, 0x4d, 0x14, 0xc8, 0x48, 0xd9, 0xc5, 0x0e, 0xe1, 0x1c, 0x5b, 0xa6, 0xcd, 0xe7, 0xb8, + 0xf0, 0x5c, 0x61, 0x07, 0x16, 0x8e, 0x65, 0x39, 0x9f, 0xf9, 0x0c, 0xd7, 0x32, 0x73, 0xad, 0xe4, + 0xcc, 0x35, 0x17, 0x4b, 0x75, 0x9f, 0x4f, 0x71, 0x98, 0x5a, 0xb0, 0x8d, 0x91, 0xb9, 0x82, 0x1f, + 0x50, 0xa8, 0x27, 0x1f, 0x5b, 0x5d, 0xec, 0xea, 0x45, 0xff, 0x4c, 0xd3, 0xa7, 0x1f, 0xc7, 0x9a, + 0xfe, 0x7e, 0x78, 0xa2, 0x9d, 0x0e, 0x86, 0xda, 0x49, 0xfb, 0x0e, 0x6a, 0xc9, 0x96, 0xe4, 0xe9, + 0x8f, 0xc7, 0xc7, 0xed, 0x02, 0x3e, 0x35, 0x1d, 0xc9, 0x78, 0x32, 0x3a, 0x7e, 0xab, 0x4d, 0xda, + 0x45, 0x24, 0xd2, 0x92, 0xcc, 0xa3, 0xe3, 0x41, 0xbb, 0x74, 0x30, 0x86, 0x5a, 0xfc, 0xcd, 0xb1, + 0x0b, 0xdb, 0x08, 0xa0, 0xbf, 0x9b, 0xf6, 0xa7, 0xe9, 0x24, 0x88, 0x97, 0x38, 0x26, 0xef, 0x87, + 0xc3, 0xc1, 0xf0, 0x0c, 0xd3, 0xec, 0x40, 0x3b, 0x31, 0x6b, 0xdf, 0x0f, 0xa6, 0x18, 0x5c, 0x3c, + 0xf8, 0xab, 0x00, 0xb5, 0xf8, 0x69, 0x44, 0xc8, 0xf1, 0xe8, 0x24, 0x07, 0x12, 0xcf, 0x26, 0x0e, + 0xed, 0xe2, 0xcd, 0xe4, 0xe3, 0x08, 0x11, 0x53, 0xe1, 0xe3, 0x89, 0x36, 0xee, 0x4f, 0x58, 0xaa, + 0x22, 0x8a, 0x33, 0xc9, 0x3a, 0x10, 0xa6, 0xc4, 0x98, 0x25, 0xf6, 0x88, 0x59, 0x19, 0xa7, 0x6d, + 0x2f, 0x31, 0xf7, 0xdf, 0x8c, 0x26, 0x48, 0x2d, 0x3a, 0xd6, 0x56, 0x32, 0xc9, 0x43, 0xe2, 0x95, + 0x74, 0x8e, 0x13, 0xed, 0x5c, 0x9b, 0x32, 0xb0, 0x6a, 0x3a, 0xc7, 0x59, 0x7f, 0xf2, 0x06, 0x5b, + 0xd8, 0xae, 0x1d, 0xfc, 0x5e, 0x84, 0x7a, 0x22, 0x76, 0x78, 0x43, 0xda, 0x07, 0x6d, 0x38, 0x5d, + 0xbf, 0xa1, 0x07, 0xb0, 0x2b, 0x79, 0x18, 0x52, 0xcc, 0xbf, 0x80, 0x1f, 0x53, 0x8f, 0xf3, 0x9d, + 0x11, 0x6b, 0xac, 0xbd, 0x07, 0xf7, 0x33, 0x31, 0x48, 0x85, 0xfb, 0x4a, 0x28, 0x17, 0xf7, 0x32, + 0x3e, 0x51, 0x4e, 0x19, 0x77, 0x67, 0x3f, 0xe3, 0x12, 0xdc, 0xf5, 0xe3, 0xd1, 0xf9, 0xb9, 0x76, + 0xcc, 0xa2, 0x94, 0x0c, 0xb8, 0xb8, 0xce, 0x49, 0xd8, 0x90, 0x34, 0x38, 0xf3, 0x09, 0xf0, 0x2a, + 0x6b, 0xb0, 0xe4, 0x0a, 0xa7, 0x6a, 0x70, 0x31, 0x0e, 0x29, 0xd7, 0xc8, 0x43, 0xe8, 0xae, 0xb9, + 0x27, 0xda, 0xc5, 0xe8, 0x03, 0x7a, 0xeb, 0x47, 0x3f, 0x95, 0xf1, 0x6b, 0x6b, 0x75, 0x69, 0x99, + 0xb3, 0xfe, 0x78, 0x40, 0xbe, 0x85, 0xaa, 0x10, 0x74, 0xb2, 0x9b, 0xbc, 0x76, 0x29, 0xd1, 0xef, + 0x75, 0xd7, 0x1d, 0xe1, 0xd6, 0xa8, 0x77, 0x48, 0x1f, 0x6a, 0x91, 0x30, 0x93, 0x24, 0x2e, 0xa3, + 0xf9, 0xbd, 0xbd, 0x1c, 0x4f, 0x0c, 0x71, 0x06, 0x90, 0x48, 0x31, 0xe9, 0x49, 0x0f, 0x48, 0x46, + 0xc0, 0x7b, 0x0f, 0x72, 0x7d, 0x32, 0x50, 0x22, 0xab, 0x12, 0xd0, 0x9a, 0x6e, 0x4b, 0x40, 0xeb, + 0x3a, 0x8c, 0x40, 0x17, 0xd0, 0x94, 0x65, 0x94, 0x3c, 0xcc, 0xe6, 0x95, 0x05, 0xb8, 0xf7, 0x68, + 0x83, 0x37, 0x86, 0x1b, 0x41, 0x53, 0x56, 0x48, 0x09, 0x2e, 0x47, 0x75, 0x25, 0xb8, 0x3c, 0x59, + 0x55, 0xef, 0xfc, 0xbf, 0x40, 0x5e, 0xf3, 0x4b, 0x63, 0xfa, 0x95, 0xbe, 0x34, 0x49, 0x4c, 0xd3, + 0x97, 0x26, 0x4b, 0x1d, 0x43, 0xb8, 0xac, 0xf0, 0x7f, 0x40, 0x5f, 0xfc, 0x1d, 0x00, 0x00, 0xff, + 0xff, 0x4d, 0xcd, 0xc6, 0xd5, 0x8d, 0x0e, 0x00, 0x00, } diff --git a/api/v1alpha/api.proto b/api/v1alpha/api.proto index fc7174bf6c..51aa8e6865 100644 --- a/api/v1alpha/api.proto +++ b/api/v1alpha/api.proto @@ -173,11 +173,18 @@ message Pod { // Cgroup of the pod, empty if the pod is not running. string cgroup = 8; - // Timestamp when the pod is created, nanoseconds since epoch. + // Timestamp of when the pod is created, nanoseconds since epoch. + // Zero if the pod is not created. int64 created_at = 9; - // Timestamp when the pod is started, nanoseconds since epoch. + // Timestamp of when the pod is started, nanoseconds since epoch. + // Zero if the pod is not started. int64 started_at = 10; + + // Timestamp of when the pod is moved to exited-garbage/garbage, + // in nanoseconds since epoch. + // Zero if the pod is not moved to exited-garbage/garbage yet. + int64 gc_marked_at = 11; } message KeyValue { From 7d322e61ef9cedab9469a16b1ba623dbc883ab81 Mon Sep 17 00:00:00 2001 From: Yifan Gu Date: Tue, 12 Apr 2016 17:12:53 -0700 Subject: [PATCH 0112/1304] api: Return GcMarkedTime in api service. --- rkt/api_service.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rkt/api_service.go b/rkt/api_service.go index 72b66285bd..532d3254f1 100644 --- a/rkt/api_service.go +++ b/rkt/api_service.go @@ -333,7 +333,14 @@ func getBasicPod(p *pod) (*v1alpha.Pod, *schema.PodManifest, error) { return nil, nil, err } - pod.CreatedAt, pod.StartedAt = createdAt.UnixNano(), startedAt.UnixNano() + gcMarkedAt, err := p.getGCMarkedTime() + if err != nil { + return nil, nil, err + } + + pod.CreatedAt = createdAt.UnixNano() + pod.StartedAt = startedAt.UnixNano() + pod.GcMarkedAt = gcMarkedAt.UnixNano() manifest, data, err := getPodManifest(p) if err != nil { From ab4a7f99edf05c1726289f7821a69b4c6fa60c4e Mon Sep 17 00:00:00 2001 From: Piotr Skamruk Date: Wed, 13 Apr 2016 13:25:29 +0200 Subject: [PATCH 0113/1304] kvm: fix rkt status --- rkt/pods.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/rkt/pods.go b/rkt/pods.go index 761c518996..c19c1ce56f 100644 --- a/rkt/pods.go +++ b/rkt/pods.go @@ -872,11 +872,14 @@ func getChildPID(ppid int) (int, error) { // getPID returns the pid of the stage1 process that started the pod. func (p *pod) getPID() (int, error) { - pid, err := p.readIntFromFile("ppid") - if err != nil { + if pid, err := p.readIntFromFile("pid"); err == nil { + return pid, nil + } + if pid, err := p.readIntFromFile("ppid"); err != nil { return -1, err + } else { + return pid, nil } - return pid, nil } // getContainerPID1 returns the pid of the process with pid 1 in the pod. From 3bfd34dfbeb4489cec75cb2e135362c751867ad1 Mon Sep 17 00:00:00 2001 From: Yifan Gu Date: Tue, 12 Apr 2016 17:59:22 -0700 Subject: [PATCH 0114/1304] tests: Add checks in api service tests to test the GCMarkedTime. --- tests/rkt_api_service_test.go | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/tests/rkt_api_service_test.go b/tests/rkt_api_service_test.go index d7ce1ef837..a527977046 100644 --- a/tests/rkt_api_service_test.go +++ b/tests/rkt_api_service_test.go @@ -137,7 +137,7 @@ func checkPodNetworks(t *testing.T, rawNets map[string]*networkInfo, apiNets []* } // Check the pod's information by 'rkt status'. -func checkPod(t *testing.T, ctx *testutils.RktRunCtx, p *v1alpha.Pod, hasAppState, hasManifest bool) { +func checkPod(t *testing.T, ctx *testutils.RktRunCtx, p *v1alpha.Pod, hasAppState, hasManifest bool, expectedGCTime time.Time) { podInfo := getPodInfo(t, ctx, p.Id) if podInfo.id != p.Id { t.Errorf("Expected %q, saw %q", podInfo.id, p.Id) @@ -153,6 +153,12 @@ func checkPod(t *testing.T, ctx *testutils.RktRunCtx, p *v1alpha.Pod, hasAppStat if podInfo.startedAt/accuracy != p.StartedAt/accuracy { t.Errorf("Expected %d, saw %d", podInfo.startedAt, p.StartedAt) } + + // If expectedGCTime.IsZero() == true, then p.GcMarkedAt should also be zero. + actualTime := time.Unix(0, p.GcMarkedAt) + if !compareTime(expectedGCTime, actualTime) { + t.Errorf("API service returned an incorrect GC marked time. Got %q, Expect: %q", actualTime, expectedGCTime) + } checkPodState(t, podInfo.state, p.State) checkPodApps(t, podInfo.apps, p.Apps, hasAppState) checkPodNetworks(t, podInfo.networks, p.Networks) @@ -186,12 +192,16 @@ func checkPod(t *testing.T, ctx *testutils.RktRunCtx, p *v1alpha.Pod, hasAppStat } } +func checkPodBasicsWithGCTime(t *testing.T, ctx *testutils.RktRunCtx, p *v1alpha.Pod, expectedGCTime time.Time) { + checkPod(t, ctx, p, false, false, expectedGCTime) +} + func checkPodBasics(t *testing.T, ctx *testutils.RktRunCtx, p *v1alpha.Pod) { - checkPod(t, ctx, p, false, false) + checkPod(t, ctx, p, false, false, time.Time{}) } func checkPodDetails(t *testing.T, ctx *testutils.RktRunCtx, p *v1alpha.Pod) { - checkPod(t, ctx, p, true, true) + checkPod(t, ctx, p, true, true, time.Time{}) } // Check the image's information by 'rkt image list'. @@ -326,8 +336,12 @@ func TestAPIServiceListInspectPods(t *testing.T) { defer os.Remove(manifestFile) runCmd := fmt.Sprintf("%s run --pod-manifest=%s", ctx.Cmd(), manifestFile) - esp := spawnOrFail(t, runCmd) - waitOrFail(t, esp, 0) + waitOrFail(t, spawnOrFail(t, runCmd), 0) + + gcCmd := fmt.Sprintf("%s gc --mark-only=true", ctx.Cmd()) + waitOrFail(t, spawnOrFail(t, gcCmd), 0) + + gcTime := time.Now() // ListPods(detail=false). resp, err = c.ListPods(context.Background(), &v1alpha.ListPodsRequest{}) @@ -340,7 +354,7 @@ func TestAPIServiceListInspectPods(t *testing.T) { } for _, p := range resp.Pods { - checkPodBasics(t, ctx, p) + checkPodBasicsWithGCTime(t, ctx, p, gcTime) // Test InspectPod(). inspectResp, err := c.InspectPod(context.Background(), &v1alpha.InspectPodRequest{Id: p.Id}) From 2588b713492625983d1bca73aea0b7cd9bd89ffe Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Wed, 13 Apr 2016 12:51:29 +0200 Subject: [PATCH 0115/1304] run: add user/group app flags This adds --user and --group app flags to override the user and/or the group for the run subcommand. Fixes #1920 --- CHANGELOG.md | 2 + Documentation/subcommands/prepare.md | 2 + Documentation/subcommands/run.md | 8 ++ common/apps/apps.go | 1 + rkt/cli_apps.go | 48 ++++++++++++ rkt/prepare.go | 2 + rkt/run.go | 2 + stage0/run.go | 8 ++ tests/rkt_run_user_group_test.go | 109 +++++++++++++++++++++++++++ 9 files changed, 182 insertions(+) create mode 100644 tests/rkt_run_user_group_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index b187c87f14..adf47cf482 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ #### New features and UX changes +- Add `--user`/`--group` option to rkt run/prepare ([#2419](https://github.com/coreos/rkt/pull/2419)). This option allows overriding the user/group specified in the image manifest. + - Ensure that the initial name and labels used for discovery match the name and labels in the Image Manifest as specified in the appc spec ([#2311](https://github.com/coreos/rkt/pull/2311)). Users wanting the latest image should use `rkt prepare/run/fetch example.com/aci` without any labels. If the discovery server supports the "latest" pattern, the user can bypass a locally cached image in the store and fetch an updated image using `rkt prepare/run/fetch --no-store example.com/aci` option. #### Note for packagers diff --git a/Documentation/subcommands/prepare.md b/Documentation/subcommands/prepare.md index 9d968c973b..2e20608a11 100644 --- a/Documentation/subcommands/prepare.md +++ b/Documentation/subcommands/prepare.md @@ -52,6 +52,8 @@ c9fad0e6-8236-4fc2-ad17-55d0a4c7d742 | `--stage1-from-dir` | `` | A stage1 image file inside the default stage1 images directory | Image to use as stage1 | | `--store-only` | `false` | `true` or `false` | Use only available images in the store (do not discover or download from remote URLs). See [image fetching behavior](../image-fetching-behavior.md) | | `--volume` | `` | Volume syntax (`NAME,kind=KIND,source=PATH,readOnly=BOOL`). See [Mount Volumes into a Pod](run.md#mount-volumes-into-a-pod) | Volumes to make available in the pod | +| `--user` | none | username or UID | user override for the preceding image (example: '--user=user') | +| `--group` | none | group or GID | group override for the preceding image (example: '--group=group') | ## Global options diff --git a/Documentation/subcommands/run.md b/Documentation/subcommands/run.md index d2971c6662..97f330da3c 100644 --- a/Documentation/subcommands/run.md +++ b/Documentation/subcommands/run.md @@ -44,6 +44,14 @@ In the following example, the CPU isolator is defined to 750 milli-cores and the # rkt run coreos.com/etcd:v2.0.0 --cpu=750m --memory=128M ``` +## Overriding User/Group + +Application images must specify the username/group or the UID/GID the app is to be run as as specified in the [Image Manifest Schema](https://github.com/appc/spec/blob/master/spec/aci.md#image-manifest-schema). The user/group can be overridden by rkt using the `--user` and `--group` flags: + +``` +# rkt --insecure-options=image run docker://busybox --user=1000 --group=100 --exec id +``` + ## Passing Arguments To pass additional arguments to images use the pattern of `image1 -- [image1 flags] --- image2 -- [image2 flags]`. diff --git a/common/apps/apps.go b/common/apps/apps.go index d3a0a3db72..5c9d687a9d 100644 --- a/common/apps/apps.go +++ b/common/apps/apps.go @@ -46,6 +46,7 @@ type App struct { Mounts []schema.Mount // mounts for this app (superseding any mounts in rktApps.mounts of same MountPoint) MemoryLimit *types.ResourceMemory // memory isolator override CPULimit *types.ResourceCPU // cpu isolator override + User, Group string // user, group overrides // TODO(jonboulle): These images are partially-populated hashes, this should be clarified. ImageID types.Hash // resolved image identifier diff --git a/rkt/cli_apps.go b/rkt/cli_apps.go index a9ceda381d..70f2132ae7 100644 --- a/rkt/cli_apps.go +++ b/rkt/cli_apps.go @@ -305,3 +305,51 @@ func (aml *appCPULimit) String() string { func (aml *appCPULimit) Type() string { return "appCPULimit" } + +// appUser is for --user flags in the form of: --user=user +type appUser apps.Apps + +func (au *appUser) Set(s string) error { + app := (*apps.Apps)(au).Last() + if app == nil { + return fmt.Errorf("--user must follow an image") + } + app.User = s + return nil +} + +func (au *appUser) String() string { + app := (*apps.Apps)(au).Last() + if app == nil { + return "" + } + return app.User +} + +func (au *appUser) Type() string { + return "appUser" +} + +// appGroup is for --group flags in the form of: --group=group +type appGroup apps.Apps + +func (ag *appGroup) Set(s string) error { + app := (*apps.Apps)(ag).Last() + if app == nil { + return fmt.Errorf("--group must follow an image") + } + app.Group = s + return nil +} + +func (ag *appGroup) String() string { + app := (*apps.Apps)(ag).Last() + if app == nil { + return "" + } + return app.Group +} + +func (ag *appGroup) Type() string { + return "appGroup" +} diff --git a/rkt/prepare.go b/rkt/prepare.go index 3e882c66e0..c62696a0bd 100644 --- a/rkt/prepare.go +++ b/rkt/prepare.go @@ -69,6 +69,8 @@ func init() { cmdPrepare.Flags().Var((*appExec)(&rktApps), "exec", "override the exec command for the preceding image") cmdPrepare.Flags().Var((*appMount)(&rktApps), "mount", "mount point binding a volume to a path within an app") cmdPrepare.Flags().Var((*appAsc)(&rktApps), "signature", "local signature file to use in validating the preceding image") + cmdPrepare.Flags().Var((*appUser)(&rktApps), "user", "user override for the preceding image (example: '--user=user')") + cmdPrepare.Flags().Var((*appGroup)(&rktApps), "group", "group override for the preceding image (example: '--group=group')") // Disable interspersed flags to stop parsing after the first non flag // argument. This is need to permit to correctly handle diff --git a/rkt/run.go b/rkt/run.go index d93816e9c0..f7537b4b33 100644 --- a/rkt/run.go +++ b/rkt/run.go @@ -99,6 +99,8 @@ func init() { cmdRun.Flags().Var((*appMount)(&rktApps), "mount", "mount point binding a volume to a path within an app") cmdRun.Flags().Var((*appMemoryLimit)(&rktApps), "memory", "memory limit for the preceding image (example: '--memory=16Mi', '--memory=50M', '--memory=1G')") cmdRun.Flags().Var((*appCPULimit)(&rktApps), "cpu", "cpu limit for the preceding image (example: '--cpu=500m')") + cmdRun.Flags().Var((*appUser)(&rktApps), "user", "user override for the preceding image (example: '--user=user')") + cmdRun.Flags().Var((*appGroup)(&rktApps), "group", "group override for the preceding image (example: '--group=group')") flagPorts = portList{} flagDNS = flagStringList{} diff --git a/stage0/run.go b/stage0/run.go index f1531014ce..cbacd50fd7 100644 --- a/stage0/run.go +++ b/stage0/run.go @@ -248,6 +248,14 @@ func generatePodManifest(cfg PrepareConfig, dir string) ([]byte, error) { ra.App.Isolators = append(ra.App.Isolators, isolator) } + if user := app.User; user != "" { + ra.App.User = user + } + + if group := app.Group; group != "" { + ra.App.Group = group + } + if cfg.InheritEnv || len(cfg.ExplicitEnv) > 0 { MergeEnvs(&ra.App.Environment, cfg.InheritEnv, cfg.ExplicitEnv) } diff --git a/tests/rkt_run_user_group_test.go b/tests/rkt_run_user_group_test.go new file mode 100644 index 0000000000..a233ff117f --- /dev/null +++ b/tests/rkt_run_user_group_test.go @@ -0,0 +1,109 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "fmt" + "os" + "testing" + + "github.com/coreos/rkt/tests/testutils" +) + +func TestAppUserGroup(t *testing.T) { + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + imageDummy := patchTestACI("rkt-inspect-dummy.aci", "--name=dummy") + defer os.Remove(imageDummy) + + for _, tt := range []struct { + imageParams []string + rktParams string + expected string + }{ + { + expected: "User: uid=0 euid=0 gid=0 egid=0", + }, + { + rktParams: "--user=200", + expected: "User: uid=200 euid=200 gid=0 egid=0", + }, + { + rktParams: "--group=300", + expected: "User: uid=0 euid=0 gid=300 egid=300", + }, + { + rktParams: "--user=200 --group=300", + expected: "User: uid=200 euid=200 gid=300 egid=300", + }, + { + rktParams: "--user=user1 --group=300", + expected: "User: uid=1000 euid=1000 gid=300 egid=300", + }, + { + rktParams: "--user=200 --group=group1", + expected: "User: uid=200 euid=200 gid=100 egid=100", + }, + { + imageParams: []string{"--user=400", "--group=500"}, + expected: "User: uid=400 euid=400 gid=500 egid=500", + }, + { + imageParams: []string{"--user=400", "--group=500"}, + rktParams: "--user=200", + expected: "User: uid=200 euid=200 gid=500 egid=500", + }, + { + imageParams: []string{"--user=400", "--group=500"}, + rktParams: "--group=300", + expected: "User: uid=400 euid=400 gid=300 egid=300", + }, + { + imageParams: []string{"--user=400", "--group=500"}, + rktParams: "--user=200 --group=300", + expected: "User: uid=200 euid=200 gid=300 egid=300", + }, + { + imageParams: []string{"--user=400", "--group=500"}, + rktParams: "--user=user1 --group=group1", + expected: "User: uid=1000 euid=1000 gid=100 egid=100", + }, + } { + func() { + tt.imageParams = append(tt.imageParams, "--exec=/inspect --print-user") + image := patchTestACI("rkt-inspect-user-group.aci", tt.imageParams...) + defer os.Remove(image) + + // run the user/group overriden app first + rktCmd := fmt.Sprintf( + "%s --insecure-options=image run %s %s %s", + ctx.Cmd(), + image, tt.rktParams, + imageDummy, + ) + runRktAndCheckOutput(t, rktCmd, tt.expected, false) + + // run the user/group overriden app last + rktCmd = fmt.Sprintf( + "%s --insecure-options=image run %s %s %s", + ctx.Cmd(), + imageDummy, + image, tt.rktParams, + ) + runRktAndCheckOutput(t, rktCmd, tt.expected, false) + }() + } +} From d66fa6141cbbe2dc036d1db1b4d8946bb07d9bf2 Mon Sep 17 00:00:00 2001 From: mstachowski Date: Wed, 16 Dec 2015 13:43:35 -0600 Subject: [PATCH 0116/1304] kvm: Add support for capabilities limitation By default kvm flavor has got enabled every capability inside pod. This is normal systemd behavior, when its running as a init process inside VM. Coreos pod is started by systemd-nspawn, which apply some initial capabilities by default. This patch add support for restricted set of capabilities inside rkt-kvm pod --- stage1/init/common/pod.go | 77 ++++++++++++++++++++++++++++++++------- 1 file changed, 63 insertions(+), 14 deletions(-) diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index 0737c9db1a..f401c1fe80 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -59,6 +59,37 @@ var ( "LOGNAME": "root", "HOME": "/root", } + + // The list of default capabilities inside systemd-nspawn pod is available + // here: https://www.freedesktop.org/software/systemd/man/systemd-nspawn.html + nspawnCapabilities, _ = types.NewLinuxCapabilitiesRetainSet([]string{ + "CAP_CHOWN", + "CAP_DAC_OVERRIDE", + "CAP_DAC_READ_SEARCH", + "CAP_FOWNER", + "CAP_FSETID", + "CAP_IPC_OWNER", + "CAP_KILL", + "CAP_LEASE", + "CAP_LINUX_IMMUTABLE", + "CAP_NET_BIND_SERVICE", + "CAP_NET_BROADCAST", + "CAP_NET_RAW", + "CAP_SETGID", + "CAP_SETFCAP", + "CAP_SETPCAP", + "CAP_SETUID", + "CAP_SYS_ADMIN", + "CAP_SYS_CHROOT", + "CAP_SYS_NICE", + "CAP_SYS_PTRACE", + "CAP_SYS_TTY_CONFIG", + "CAP_SYS_RESOURCE", + "CAP_SYS_BOOT", + "CAP_AUDIT_WRITE", + "CAP_AUDIT_CONTROL", + "CAP_MKNOD", + }...) ) // execEscape uses Golang's string quoting for ", \, \n, and regex for special cases @@ -348,6 +379,13 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b opts = append(opts, unit.NewUnitOption("Service", "SyslogIdentifier", filepath.Base(app.Exec[0]))) } + if flavor == "kvm" { + capabilities := append(app.Isolators, nspawnCapabilities.AsIsolator()) + capabilitiesStr := GetAppCapabilities(capabilities) + + opts = append(opts, unit.NewUnitOption("Service", "CapabilityBoundingSet", strings.Join(capabilitiesStr, " "))) + } + // When an app fails, we shut down the pod opts = append(opts, unit.NewUnitOption("Unit", "OnFailure", "halt.target")) @@ -673,20 +711,8 @@ func appToNspawnArgs(p *stage1commontypes.Pod, ra *schema.RuntimeApp) ([]string, args = append(args, strings.Join(opt, "")) } - for _, i := range app.Isolators { - switch v := i.Value().(type) { - case types.LinuxCapabilitiesSet: - var caps []string - // TODO: cleanup the API on LinuxCapabilitiesSet to give strings easily. - for _, c := range v.Set() { - caps = append(caps, string(c)) - } - if i.Name == types.LinuxCapabilitiesRetainSetName { - capList := strings.Join(caps, ",") - args = append(args, "--capability="+capList) - } - } - } + capList := strings.Join(GetAppCapabilities(app.Isolators), ",") + args = append(args, "--capability="+capList) return args, nil } @@ -772,3 +798,26 @@ func GetAppHashes(p *stage1commontypes.Pod) []types.Hash { func GetMachineID(p *stage1commontypes.Pod) string { return "rkt-" + p.UUID.String() } + +// GetAppCapabilities is a filter which returns a string slice of valid Linux capabilities +// It requires list of available isolators +func GetAppCapabilities(isolators types.Isolators) []string { + var caps []string + + for _, isolator := range isolators { + if capSet, ok := isolator.Value().(types.LinuxCapabilitiesSet); ok && + isolator.Name == types.LinuxCapabilitiesRetainSetName { + caps = append(caps, parseLinuxCapabilitiesSet(capSet)...) + } + } + return caps +} + +// parseLinuxCapabilitySet parses a LinuxCapabilitiesSet into string slice +func parseLinuxCapabilitiesSet(capSet types.LinuxCapabilitiesSet) []string { + var capsStr []string + for _, cap := range capSet.Set() { + capsStr = append(capsStr, string(cap)) + } + return capsStr +} From c26f621030dcc8362fd91c4a2a9eabafb3a5346f Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Sat, 9 Apr 2016 16:27:15 +0200 Subject: [PATCH 0117/1304] config: add config subcommand This adds the config subcommand. Currently only stage0 configuration is supported. Fixes #2368 --- Documentation/commands.md | 1 + Documentation/subcommands/config.md | 125 ++++++++++++++++++++++++++++ rkt/config.go | 51 ++++++++++++ rkt/config/auth.go | 14 ++-- rkt/config/config.go | 89 +++++++++++++++++++- rkt/config/config_test.go | 8 ++ 6 files changed, 278 insertions(+), 10 deletions(-) create mode 100644 Documentation/subcommands/config.md create mode 100644 rkt/config.go diff --git a/Documentation/commands.md b/Documentation/commands.md index d40876c2f8..4786242554 100644 --- a/Documentation/commands.md +++ b/Documentation/commands.md @@ -63,6 +63,7 @@ The API service allows clients to list and inspect pods and images running under ## Misc * [version](subcommands/version.md) +* [config](subcommands/config.md) ## Global Options diff --git a/Documentation/subcommands/config.md b/Documentation/subcommands/config.md new file mode 100644 index 0000000000..fbef3d1c98 --- /dev/null +++ b/Documentation/subcommands/config.md @@ -0,0 +1,125 @@ +# rkt config + +The `config` subcommand prints the configuration of each rkt stage in JSON on the standard output. + +## Structure + +The general structure is a simple hierarchy consisting of the following top-level element: + +``` +{ + "stage0": [...] +} +``` + +The entry "stage0" refers to stage-specific configuration; "stage1" is currently left out intentionally because its configuration subsystem is subject to change. The generated output are valid configuration entries as specified in the configuration documentation. + +The "stage0" entry contains subentries of rktKind "auth", "dockerAuth", "paths", and "stage1". Note that the `config` subcommand will output separate entries per "auth" domain and separate entries per "dockerAuth" registry. While it is possible to specify an array of strings in the input configuration rkt internally merges configuration state from different directories potentially creating multiple entries. + +Consider the following system configuration: +``` +$ cat /etc/rkt/auth.d/basic.json +{ + "rktKind": "auth", + "rktVersion": "v1", + "domains": [ + "foo.com", + "bar.com", + "baz.com" + ], + "type": "basic", + "credentials": { "user": "sysUser", "password": "sysPassword" } +} +``` + +And the following user configuration: +``` +$ ~/.config/rkt/auth.d/basic.json +{ + "rktKind": "auth", + "rktVersion": "v1", + "domains": [ + "foo.com" + ], + "type": "basic", + "credentials": { "user": "user", "password": "password" } +} +``` + +The `config` subcommand would generate the following separate merged entries: +``` +{ + "stage0": [ + { + "rktVersion": "v1", + "rktKind": "auth", + "domains": [ "bar.com" ], + "type": "basic", + "credentials": { "user": "sysUser", "password": "sysPassword" } + }, + { + "rktVersion": "v1", + "rktKind": "auth", + "domains": [ "baz.com" ], + "type": "basic", + "credentials": { "user": "sysUser", "password": "sysPassword" } + }, + { + "rktVersion": "v1", + "rktKind": "auth", + "domains": [ "foo.com" ], + "type": "basic", + "credentials": { "user": "user", "password": "password" } + } + ] +} +``` + +In the example given above the user configuration entry for the domain "foo.com" overrides the system configuration entry leaving the entries "bar.com" and "baz.com" unchanged. The `config` subcommand output creates three separate entries for "foo.com", "bar.com", and "baz.com". + +Note: While the "bar.com", and "baz.com" entries in the example given above could be merged into one entry they are still being printed separate. This behavior is subject to change, future implementations may provide a merged output. + +## Example + +``` +$ rkt config +{ + "stage0": [ + { + "rktVersion": "v1", + "rktKind": "auth", + "domains": [ + "bar.com" + ], + "type": "oauth", + "credentials": { + "token": "someToken" + } + }, + { + "rktVersion": "v1", + "rktKind": "auth", + "domains": [ + "foo.com" + ], + "type": "basic", + "credentials": { + "user": "user", + "password": "userPassword" + } + }, + { + "rktVersion": "v1", + "rktKind": "paths", + "data": "/var/lib/rkt", + "stage1-images": "/usr/lib/rkt" + }, + { + "rktVersion": "v1", + "rktKind": "stage1", + "name": "coreos.com/rkt/stage1-coreos", + "version": "0.15.0+git", + "location": "/usr/libexec/rkt/stage1-coreos.aci" + } + ] +} diff --git a/rkt/config.go b/rkt/config.go new file mode 100644 index 0000000000..afaf6a1c2f --- /dev/null +++ b/rkt/config.go @@ -0,0 +1,51 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "encoding/json" + + "github.com/spf13/cobra" +) + +var ( + cmdConfig = &cobra.Command{ + Use: "config", + Short: "Print configuration for each stage in JSON format", + Long: `The output will be parsable JSON with "stage0" and stage1" as keys and rkt configuration entries as values. +The generated configuration entries resemble the original rkt configuration format.`, + Run: runWrapper(runConfig), + } +) + +func init() { + cmdRkt.AddCommand(cmdConfig) +} + +func runConfig(cmd *cobra.Command, args []string) int { + config, err := getConfig() + if err != nil { + stderr.PrintE("cannot get configuration", err) + return 1 + } + + b, err := json.Marshal(config) + if err != nil { + stderr.PanicE("error marshaling configuration", err) + } + + stdout.Print(string(b)) + return 0 +} diff --git a/rkt/config/auth.go b/rkt/config/auth.go index c0cce1b035..384f82bf9e 100644 --- a/rkt/config/auth.go +++ b/rkt/config/auth.go @@ -56,13 +56,12 @@ func init() { } type basicAuthHeaderer struct { - user string - password string + auth basicV1 } func (h *basicAuthHeaderer) Header() http.Header { headers := make(http.Header) - creds := []byte(fmt.Sprintf("%s:%s", h.user, h.password)) + creds := []byte(fmt.Sprintf("%s:%s", h.auth.User, h.auth.Password)) encodedCreds := base64.StdEncoding.EncodeToString(creds) headers.Add(authHeader, "Basic "+encodedCreds) @@ -70,12 +69,12 @@ func (h *basicAuthHeaderer) Header() http.Header { } type oAuthBearerTokenHeaderer struct { - token string + auth oauthV1 } func (h *oAuthBearerTokenHeaderer) Header() http.Header { headers := make(http.Header) - headers.Add(authHeader, "Bearer "+h.token) + headers.Add(authHeader, "Bearer "+h.auth.Token) return headers } @@ -124,8 +123,7 @@ func (p *authV1JsonParser) getBasicV1Headerer(raw json.RawMessage) (Headerer, er return nil, err } return &basicAuthHeaderer{ - user: basic.User, - password: basic.Password, + auth: basic, }, nil } @@ -138,7 +136,7 @@ func (p *authV1JsonParser) getOAuthV1Headerer(raw json.RawMessage) (Headerer, er return nil, fmt.Errorf("no oauth bearer token specified") } return &oAuthBearerTokenHeaderer{ - token: oauth.Token, + auth: oauth, }, nil } diff --git a/rkt/config/config.go b/rkt/config/config.go index 9f44383f06..5349c240ea 100644 --- a/rkt/config/config.go +++ b/rkt/config/config.go @@ -16,6 +16,7 @@ package config import ( "encoding/json" + "errors" "fmt" "io/ioutil" "net/http" @@ -37,8 +38,8 @@ type Headerer interface { // BasicCredentials holds typical credentials used for authentication // (user and password). Used for fetching docker images. type BasicCredentials struct { - User string - Password string + User string `json:"user"` + Password string `json:"password"` } // ConfigurablePaths holds various paths defined in the configuration. @@ -64,6 +65,90 @@ type Config struct { Stage1 Stage1Data } +// MarshalJSON marshals the config for user output. +func (c *Config) MarshalJSON() ([]byte, error) { + stage0 := []interface{}{} + + for host, auth := range c.AuthPerHost { + var typ string + var credentials interface{} + + switch h := auth.(type) { + case *basicAuthHeaderer: + typ = "basic" + credentials = h.auth + case *oAuthBearerTokenHeaderer: + typ = "oauth" + credentials = h.auth + default: + return nil, errors.New("unknown headerer type") + } + + auth := struct { + RktVersion string `json:"rktVersion"` + RktKind string `json:"rktKind"` + Domains []string `json:"domains"` + Type string `json:"type"` + Credentials interface{} `json:"credentials"` + }{ + RktVersion: "v1", + RktKind: "auth", + Domains: []string{host}, + Type: typ, + Credentials: credentials, + } + + stage0 = append(stage0, auth) + } + + for registry, credentials := range c.DockerCredentialsPerRegistry { + dockerAuth := struct { + RktVersion string `json:"rktVersion"` + RktKind string `json:"rktKind"` + Registries []string `json:"registries"` + Credentials BasicCredentials `json:"credentials"` + }{ + RktVersion: "v1", + RktKind: "dockerAuth", + Registries: []string{registry}, + Credentials: credentials, + } + + stage0 = append(stage0, dockerAuth) + } + + paths := struct { + RktVersion string `json:"rktVersion"` + RktKind string `json:"rktKind"` + Data string `json:"data"` + Stage1Images string `json:"stage1-images"` + }{ + RktVersion: "v1", + RktKind: "paths", + Data: c.Paths.DataDir, + Stage1Images: c.Paths.Stage1ImagesDir, + } + + stage1 := struct { + RktVersion string `json:"rktVersion"` + RktKind string `json:"rktKind"` + Name string `json:"name"` + Version string `json:"version"` + Location string `json:"location"` + }{ + RktVersion: "v1", + RktKind: "stage1", + Name: c.Stage1.Name, + Version: c.Stage1.Version, + Location: c.Stage1.Location, + } + + stage0 = append(stage0, paths, stage1) + + data := map[string]interface{}{"stage0": stage0} + return json.Marshal(data) +} + type configParser interface { parse(config *Config, raw []byte) error } diff --git a/rkt/config/config_test.go b/rkt/config/config_test.go index 84c301be5f..52ce69ba83 100644 --- a/rkt/config/config_test.go +++ b/rkt/config/config_test.go @@ -85,6 +85,10 @@ func TestAuthConfigFormat(t *testing.T) { t.Error("Got unexpected results\nResult:\n", result, "\n\nExpected:\n", tt.expected) } } + + if _, err := json.Marshal(cfg); err != nil { + t.Errorf("error marshaling config %v", err) + } } } @@ -118,6 +122,10 @@ func TestDockerAuthConfigFormat(t *testing.T) { t.Error("Got unexpected results\nResult:\n", result, "\n\nExpected:\n", tt.expected) } } + + if _, err := json.Marshal(cfg); err != nil { + t.Errorf("error marshaling config %v", err) + } } } From 49aa5c5dcb4734e7e698e454e49a3d19208caa13 Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Thu, 14 Apr 2016 16:50:01 +0200 Subject: [PATCH 0118/1304] tests/net: cover too long net names --- tests/rkt_net_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/rkt_net_test.go b/tests/rkt_net_test.go index cae2c00638..b9d8b45b76 100644 --- a/tests/rkt_net_test.go +++ b/tests/rkt_net_test.go @@ -743,3 +743,19 @@ func TestNetOverride(t *testing.T) { t.Fatalf("overriding IP did not work: Got %q but expected %q", containerIP, expectedIP) } } + +func TestNetLongName(t *testing.T) { + nt := networkTemplateT{ + Name: "thisnameiswaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaytoolong", + Type: "ptp", + IpMasq: true, + Ipam: ipamTemplateT{ + Type: "host-local", + Subnet: "11.11.6.0/24", + Routes: []map[string]string{ + {"dst": "0.0.0.0/0"}, + }, + }, + } + testNetCustomNatConnectivity(t, nt) +} From 1cb22b123ff74d75841f1a178ab7d1ee3aa43975 Mon Sep 17 00:00:00 2001 From: Yifan Gu Date: Thu, 14 Apr 2016 15:37:31 -0700 Subject: [PATCH 0119/1304] doc: Update docs for 'rkt gc --mark-only'. --- Documentation/subcommands/gc.md | 2 +- Documentation/using-rkt-with-systemd.md | 5 +++++ tests/rkt_gc_test.go | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Documentation/subcommands/gc.md b/Documentation/subcommands/gc.md index 0befbe6b53..2d9de34b7a 100644 --- a/Documentation/subcommands/gc.md +++ b/Documentation/subcommands/gc.md @@ -29,7 +29,7 @@ Garbage collecting pod "f07a4070-79a9-4db0-ae65-a090c9c393a3" | --- | --- | --- | --- | | `--expire-prepared` | `24h0m0s` | A time | Duration to wait before expiring prepared pods | | `--grace-period` | `30m0s` | A time | Duration to wait before discarding inactive pods from garbage | -| `--mark-only` | `false` | If set to true, then the exited/aborted pods will be moved to the garbage directories without actually deleting them, this is useful for marking the exit time of a pod | +| `--mark-only` | `false` | `true` or `false` | If set to true, only the "mark" phase of the garbage collection process will be formed (i.e., exited/aborted pods will be moved to the garbage, but nothing will be deleted) | ## Global options diff --git a/Documentation/using-rkt-with-systemd.md b/Documentation/using-rkt-with-systemd.md index 47dad93524..e88a72642f 100644 --- a/Documentation/using-rkt-with-systemd.md +++ b/Documentation/using-rkt-with-systemd.md @@ -101,6 +101,10 @@ A more advanced unit example takes advantage of a few convenient `systemd` featu 1. Inheriting environment variables specified in the unit with `--inherit-env`. This feature helps keep units concise, instead of layering on many flags to `rkt run`. 2. Using the dependency graph to start our pod after networking has come online. This is helpful if your application requires outside connectivity to fetch remote configuration (for example, from `etcd`). 3. Set resource limits for this `rkt` pod. This can also be done in the unit file, rather than flagged to `rkt run`. +4. Set `ExecStop` to invoke `rkt gc --mark-only` to record the timestamp when the pod exits. +(Run `rkt gc --help` to see more details about this flag). +After running `rkt gc --mark-only`, the timestamp can be retrieved from rkt API service in pod's `gc_marked_at` field. +The timestamp can be treated as the finished time of the pod. Here is what it looks like all together: @@ -127,6 +131,7 @@ Environment=TMPDIR=/var/tmp ExecStartPre=/usr/bin/rkt fetch myapp.com/myapp-1.3.4 # Start the app ExecStart=/usr/bin/rkt run --inherit-env --port=http:8888 myapp.com/myapp-1.3.4 +ExecStop=/usr/bin/rkt gc --mark-only KillMode=mixed Restart=always ``` diff --git a/tests/rkt_gc_test.go b/tests/rkt_gc_test.go index 6e1009a8ad..9a116c3353 100644 --- a/tests/rkt_gc_test.go +++ b/tests/rkt_gc_test.go @@ -1,4 +1,4 @@ -// Copyright 2015 The rkt Authors +// Copyright 2016 The rkt Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. From 33517ad059ef160ec49318120f017ebc4a4a22c2 Mon Sep 17 00:00:00 2001 From: Wlodzimierz Borkowski Date: Fri, 15 Apr 2016 15:10:59 +0200 Subject: [PATCH 0120/1304] skip TestSocketProxyd when systemd-socket-proxyd is not installed --- tests/rkt_socket_proxyd_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/rkt_socket_proxyd_test.go b/tests/rkt_socket_proxyd_test.go index 8c07df2c1e..d35dc3ef9e 100644 --- a/tests/rkt_socket_proxyd_test.go +++ b/tests/rkt_socket_proxyd_test.go @@ -36,6 +36,11 @@ func TestSocketProxyd(t *testing.T) { t.Skip("Systemd is not running on the host.") } + socketProxydPath := "/lib/systemd/systemd-socket-proxyd" + if _, err := os.Stat(socketProxydPath); os.IsNotExist(err) { + t.Skip("systemd-socket-proxyd is not installed.") + } + ctx := testutils.NewRktRunCtx() defer ctx.Cleanup() @@ -135,10 +140,11 @@ func TestSocketProxyd(t *testing.T) { After=%s [Service] - ExecStart=/lib/systemd/systemd-socket-proxyd %s:%d + ExecStart=%s %s:%d ` - proxyContent := fmt.Sprintf(proxyToRktTestingEchoService, serviceTargetBase, serviceTargetBase, containerIP, port) + proxyContent := fmt.Sprintf(proxyToRktTestingEchoService, serviceTargetBase, serviceTargetBase, + socketProxydPath, containerIP, port) proxyContentBase := fmt.Sprintf("proxy-to-rkt-testing-socket-activation-%d.service", rnd) proxyTarget := filepath.Join(unitsDir, proxyContentBase) From 6aa6874515022ba3e4cac43ef1780bd1e9cff5b0 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Thu, 14 Apr 2016 16:07:33 +0200 Subject: [PATCH 0121/1304] ROADMAP: update next few milestones --- ROADMAP.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index e25a5f0e53..6a38af157a 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -9,21 +9,20 @@ The version of the spec that rkt implements can be seen in the output of `rkt ve rkt's version 1.0 release marks the command line user interface and on-disk data structures as stable and reliable for external development. The (optional) API for pod inspection is not yet completely stabilized, but is quite usable. -### rkt 1.4 (April) +### rkt 1.5 (April) - enhanced DNS configuration [#2044](https://github.com/coreos/rkt/issues/2044) - user configuration for stage1 [#2013](https://github.com/coreos/rkt/issues/2013) - `rkt fly` as top-level command [#1889](https://github.com/coreos/rkt/issues/1889) -- IPv6 support [appc/cni#31](https://github.com/appc/cni/issues/31) - stage1 benchmarking [#1788](https://github.com/coreos/rkt/issues/1788) - rkt runs on Fedora with SELinux in enforcing mode -### rkt 1.5 (April) +### rkt 1.6 (May) -- stable API +- stable gRPC [API](https://github.com/coreos/rkt/tree/master/api/v1alpha) +- IPv6 support [appc/cni#31](https://github.com/appc/cni/issues/31) - full integration with Kubernetes (aka "rktnetes") - full integration with `machinectl login` and `systemd-run` [#1463](https://github.com/coreos/rkt/issues/1463) -- attach to the app's stdin/stdout [#1799](https://github.com/coreos/rkt/issues/1799) - packaged for more distributions - Debian [#1307](https://github.com/coreos/rkt/issues/1307) - CentOS [#1305](https://github.com/coreos/rkt/issues/1305) From c10453136467027bcf6836eecd1249a9e3aff853 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Fri, 15 Apr 2016 11:24:03 +0200 Subject: [PATCH 0122/1304] CHANGELOG: document 1.4.0 release --- CHANGELOG.md | 62 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index adf47cf482..fa51b1fced 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,66 @@ -## vUNRELEASED +## v1.4.0 + +This release includes a number of new features and bugfixes like a new config subcommand, man page, and bash completion generation during build time. #### New features and UX changes -- Add `--user`/`--group` option to rkt run/prepare ([#2419](https://github.com/coreos/rkt/pull/2419)). This option allows overriding the user/group specified in the image manifest. +- config: add config subcommand ([#2405](https://github.com/coreos/rkt/pull/2405)). This new subcommand prints the current rkt configuration. It can be used to get i.e. authentication credentials. See rkt's [config subcommand](https://github.com/coreos/rkt/blob/master/Documentation/subcommands/config.md) documentation. + +- run: add `--user`/`--group` app flags to `rkt run` and `rkt prepare` allowing to override the user and group specified in the image manifest ([#2419](https://github.com/coreos/rkt/pull/2419)). + +- gc: Add flag 'mark-only' to mark garbage pods without deleting them ([#2400](https://github.com/coreos/rkt/pull/2400), [#2402](https://github.com/coreos/rkt/pull/2402)). This new flag moves exited/aborted pods to the exited-garbage/garbage directory but does not delete them. A third party application can use `rkt gc --mark-only=true` to mark exited pods as garbage without deleting them. + +- kvm: Add support for app capabilities limitation ([#2222](https://github.com/coreos/rkt/pull/2222)). By default kvm flavor has got enabled every capability inside pod. This patch adds support for a restricted set of capabilities inside a kvm flavor of rkt. + +- stage1/init: return exit code 1 on error ([#2383](https://github.com/coreos/rkt/pull/2383)). On error, stage1/init was returning a non-zero value between 1 and 7. This change makes it return status code 1 only. + +- api: Add 'CreatedAt', 'StartedAt' in pod's info returned by api service. ([#2377](https://github.com/coreos/rkt/pull/2377)). + +#### Improved documentation + +- Minor documentation fixes ([#2413](https://github.com/coreos/rkt/pull/2413), [#2395](https://github.com/coreos/rkt/pull/2395), [#2231](https://github.com/coreos/rkt/pull/2231)). + +- functional tests: Add new test with systemd-proxyd ([#2257](https://github.com/coreos/rkt/pull/2257)). Adds a new test and documentation how to use systemd-proxyd with rkt pods. + +#### Bug fixes + +- kvm: refactor volumes support ([#2328](https://github.com/coreos/rkt/pull/2328)). This allows users to share regular files as volumes in addition to directories. + +- kvm: fix rkt status ([#2415](https://github.com/coreos/rkt/pull/2415)). Fixes a regression bug were `rkt status` was no longer reporting the pid of the pod when using the kvm flavor. + +- Build actool for the *build* architecture ([#2372](https://github.com/coreos/rkt/pull/2372)). Fixes a cross compilation issue with acbuild. + +- rkt: calculate real dataDir path ([#2399](https://github.com/coreos/rkt/pull/2399)). Fixes garbage collection when the data directory specified by `--dir` contains a symlink component. + +- stage1/init: fix docker volume semantics ([#2409](https://github.com/coreos/rkt/pull/2409)). Fixes a bug in docker volume semantics when rkt runs with the option `--pod-manifest`. When a Docker image exposes a mount point that is not mounted by a host volume, Docker volume semantics expect the files in the directory to be available to the application. This was partially fixed in rkt 1.3.0 via [#2315](https://github.com/coreos/rkt/pull/2315) but the bug remained when rkt runs with the option `--pod-manifest`. This is now fully fixed. + +- rkt/image: check that discovery labels match manifest labels ([#2311](https://github.com/coreos/rkt/pull/2311)). + +- store: fix multi process with multi goroutines race on db ([#2391](https://github.com/coreos/rkt/pull/2391)). This was a bug when multiple `rkt fetch` commands were executed concurrently. + +- kvm: fix pid vs ppid usage ([#2396](https://github.com/coreos/rkt/pull/2396)). Fixes a bug in `rkt enter` in the kvm flavor causing an infinite loop. + +- kvm: Fix connectivity issue in macvtap networks caused by macvlan NICs having incorrect names ([#2181](https://github.com/coreos/rkt/pull/2181)). + +- tests: TestRktListCreatedStarted: fix timing issue causing the test to fail on slow machines ([#2366](https://github.com/coreos/rkt/pull/2366)). + +- rkt/image: remove redundant quotes in an error message ([#2379](https://github.com/coreos/rkt/pull/2379)). + +- prepare: Support 'ondisk' verification skip as documented by [the global options](https://github.com/coreos/rkt/blob/master/Documentation/commands.md#global-options) ([#2376](https://github.com/coreos/rkt/pull/2376)). Prior to this commit, rkt prepare would check the ondisk image even if the `--insecure-options=ondisk` flag was provided. This corrects that. + +#### Other changes + +- tests: skip TestSocketProxyd when systemd-socket-proxyd is not installed ([#2436](https://github.com/coreos/rkt/pull/2436)). + +- tests: TestDockerVolumeSemantics: more tests with symlinks ([#2394](https://github.com/coreos/rkt/pull/2394)). + +- rkt: Improve build shell script used in [continuous integration](https://github.com/coreos/rkt/blob/master/tests/README.md) ([#2394](https://github.com/coreos/rkt/pull/2394)). + +- protobuf: generate code using a script ([#2382](https://github.com/coreos/rkt/pull/2382)). + +- Generate manpages ([#2373](https://github.com/coreos/rkt/pull/2373)). This adds support for generating rkt man pages using `make manpages` and the bash completion file using `make bash-completion`, see the note for packagers below. -- Ensure that the initial name and labels used for discovery match the name and labels in the Image Manifest as specified in the appc spec ([#2311](https://github.com/coreos/rkt/pull/2311)). Users wanting the latest image should use `rkt prepare/run/fetch example.com/aci` without any labels. If the discovery server supports the "latest" pattern, the user can bypass a locally cached image in the store and fetch an updated image using `rkt prepare/run/fetch --no-store example.com/aci` option. +- tests/aws.sh: add test for Fedora 24 ([#2340](https://github.com/coreos/rkt/pull/2340)). #### Note for packagers From f5b69782d120a7ae5ada8f2ebad97a014a98ebd5 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Fri, 15 Apr 2016 11:43:22 +0200 Subject: [PATCH 0123/1304] version: bump to v1.4.0 --- Documentation/getting-started-ubuntu.md | 6 +++--- Documentation/running-fly-stage1.md | 4 ++-- Documentation/running-lkvm-stage1.md | 4 ++-- Documentation/subcommands/prepare.md | 2 +- Documentation/subcommands/version.md | 2 +- Documentation/trying-out-rkt.md | 6 +++--- configure.ac | 2 +- scripts/acbuild-rkt-builder.sh | 2 +- scripts/build-rir.sh | 2 +- tests/empty-image/manifest | 2 +- tests/image/manifest | 2 +- tests/rkt_exec_test.go | 2 +- tests/rkt_image_cat_manifest_test.go | 2 +- tests/rkt_image_export_test.go | 2 +- tests/rkt_image_render_test.go | 2 +- tests/rkt_os_arch_test.go | 2 +- 16 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Documentation/getting-started-ubuntu.md b/Documentation/getting-started-ubuntu.md index 591bc19fe9..99bb2deb81 100644 --- a/Documentation/getting-started-ubuntu.md +++ b/Documentation/getting-started-ubuntu.md @@ -15,9 +15,9 @@ vagrant up --provider virtualbox vagrant ssh sudo -s -wget https://github.com/coreos/rkt/releases/download/v1.3.0/rkt-v1.3.0.tar.gz -tar xzvf rkt-v1.3.0.tar.gz -cd rkt-v1.3.0 +wget https://github.com/coreos/rkt/releases/download/v1.4.0/rkt-v1.4.0.tar.gz +tar xzvf rkt-v1.4.0.tar.gz +cd rkt-v1.4.0 ./rkt help ``` diff --git a/Documentation/running-fly-stage1.md b/Documentation/running-fly-stage1.md index b1a370a42f..7eff0faff9 100644 --- a/Documentation/running-fly-stage1.md +++ b/Documentation/running-fly-stage1.md @@ -60,14 +60,14 @@ $ ./autogen.sh && ./configure --with-stage1-flavors=fly && make ``` For more details about configure parameters, see the [configure script parameters documentation](build-configure.md). -This will build the rkt binary and the stage1-fly.aci in `build-rkt-1.3.0+git/bin/`. +This will build the rkt binary and the stage1-fly.aci in `build-rkt-1.4.0+git/bin/`. ### Selecting stage1 at runtime Here is a quick example of how to use a container with the official fly stage1: ``` -# rkt run --stage1-name=coreos.com/rkt/stage1-fly:1.3.0 coreos.com/etcd:v2.2.5 +# rkt run --stage1-name=coreos.com/rkt/stage1-fly:1.4.0 coreos.com/etcd:v2.2.5 ``` If the image is not in the store, `--stage1-name` will perform discovery and fetch the image. diff --git a/Documentation/running-lkvm-stage1.md b/Documentation/running-lkvm-stage1.md index b66dbef611..9111d887ee 100644 --- a/Documentation/running-lkvm-stage1.md +++ b/Documentation/running-lkvm-stage1.md @@ -13,7 +13,7 @@ $ ./autogen.sh && ./configure --with-stage1-flavors=kvm && make ``` For more details about configure parameters, see [configure script parameters documentation](build-configure.md). -This will build the rkt binary and the LKVM stage1-kvm.aci in `build-rkt-1.3.0+git/bin/`. +This will build the rkt binary and the LKVM stage1-kvm.aci in `build-rkt-1.4.0+git/bin/`. Provided you have hardware virtualization support and the [kernel KVM module](http://www.linux-kvm.org/page/Getting_the_kvm_kernel_modules) loaded (refer to your distribution for instructions), you can then run an image like you would normally do with rkt: @@ -84,7 +84,7 @@ If you want to run software that requires hypervisor isolation along with truste For example, to use the official lkvm stage1: ``` -# rkt run --stage1-name=coreos.com/rkt/stage1-kvm:1.3.0 coreos.com/etcd:v2.0.9 +# rkt run --stage1-name=coreos.com/rkt/stage1-kvm:1.4.0 coreos.com/etcd:v2.0.9 ... ``` diff --git a/Documentation/subcommands/prepare.md b/Documentation/subcommands/prepare.md index 2e20608a11..4456a44f46 100644 --- a/Documentation/subcommands/prepare.md +++ b/Documentation/subcommands/prepare.md @@ -14,7 +14,7 @@ Therefore, the supported arguments are mostly the same as in `run` except runtim ``` # rkt prepare coreos.com/etcd:v2.0.10 rkt prepare coreos.com/etcd:v2.0.10 -rkt: using image from local store for image name coreos.com/rkt/stage1-coreos:1.3.0 +rkt: using image from local store for image name coreos.com/rkt/stage1-coreos:1.4.0 rkt: searching for app image coreos.com/etcd:v2.0.10 rkt: remote fetching from url https://github.com/coreos/etcd/releases/download/v2.0.10/etcd-v2.0.10-linux-amd64.aci prefix: "coreos.com/etcd" diff --git a/Documentation/subcommands/version.md b/Documentation/subcommands/version.md index 69cfbfbafb..2c6cb0464a 100644 --- a/Documentation/subcommands/version.md +++ b/Documentation/subcommands/version.md @@ -6,7 +6,7 @@ This command prints the rkt version, the appc version rkt is built against, and ``` $ rkt version -rkt Version: 1.3.0 +rkt Version: 1.4.0 appc Version: 0.7.4 Go Version: go1.5.3 Go OS/Arch: linux/amd64 diff --git a/Documentation/trying-out-rkt.md b/Documentation/trying-out-rkt.md index e966deb92b..bd097e4480 100644 --- a/Documentation/trying-out-rkt.md +++ b/Documentation/trying-out-rkt.md @@ -10,9 +10,9 @@ rkt consists of a single CLI tool, and is currently supported on amd64 Linux. A To download the rkt binary, simply grab the latest release directly from GitHub: ``` -wget https://github.com/coreos/rkt/releases/download/v1.3.0/rkt-v1.3.0.tar.gz -tar xzvf rkt-v1.3.0.tar.gz -cd rkt-v1.3.0 +wget https://github.com/coreos/rkt/releases/download/v1.4.0/rkt-v1.4.0.tar.gz +tar xzvf rkt-v1.4.0.tar.gz +cd rkt-v1.4.0 ./rkt help ``` diff --git a/configure.ac b/configure.ac index 096c1dc974..94da0062d4 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.63]) -AC_INIT([rkt], [1.3.0+git], [https://github.com/coreos/rkt/issues]) +AC_INIT([rkt], [1.4.0], [https://github.com/coreos/rkt/issues]) AC_DEFUN([RKT_CHECK_PROG], [AS_VAR_IF([$1], [], diff --git a/scripts/acbuild-rkt-builder.sh b/scripts/acbuild-rkt-builder.sh index 27cff65468..a3b4f15c9f 100755 --- a/scripts/acbuild-rkt-builder.sh +++ b/scripts/acbuild-rkt-builder.sh @@ -25,7 +25,7 @@ ACI_NAME=${ACI_NAME:-"coreos.com/rkt/builder"} BUILDDIR=/opt/build-rkt SRC_DIR=/opt/rkt ACI_GOPATH=/go -VERSION=${VERSION:-"v1.3.0+git"} +VERSION=${VERSION:-"v1.4.0"} echo "Version: $VERSION" echo "Building $ACI_FILE" diff --git a/scripts/build-rir.sh b/scripts/build-rir.sh index 2bcb4ae23e..4afc24a38e 100755 --- a/scripts/build-rir.sh +++ b/scripts/build-rir.sh @@ -4,7 +4,7 @@ set -xe SRC_DIR=${SRC_DIR:-$PWD} BUILDDIR=${BUILDDIR:-$PWD/build-rir} -RKT_BUILDER_ACI=${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.3.0+git} +RKT_BUILDER_ACI=${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.4.0} mkdir -p $BUILDDIR diff --git a/tests/empty-image/manifest b/tests/empty-image/manifest index 2a57160f49..c661ca5d17 100644 --- a/tests/empty-image/manifest +++ b/tests/empty-image/manifest @@ -5,7 +5,7 @@ "labels": [ { "name": "version", - "value": "1.3.0" + "value": "1.4.0" }, { "name": "arch", diff --git a/tests/image/manifest b/tests/image/manifest index a48b7362ea..7d81c25d1f 100644 --- a/tests/image/manifest +++ b/tests/image/manifest @@ -5,7 +5,7 @@ "labels": [ { "name": "version", - "value": "1.3.0" + "value": "1.4.0" }, { "name": "arch", diff --git a/tests/rkt_exec_test.go b/tests/rkt_exec_test.go index 3268656bfe..3bfde38594 100644 --- a/tests/rkt_exec_test.go +++ b/tests/rkt_exec_test.go @@ -24,7 +24,7 @@ import ( ) const ( - noappManifestStr = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"coreos.com/rkt-inspect","labels":[{"name":"version","value":"1.3.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}]}` + noappManifestStr = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"coreos.com/rkt-inspect","labels":[{"name":"version","value":"1.4.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}]}` ) func TestRunOverrideExec(t *testing.T) { diff --git a/tests/rkt_image_cat_manifest_test.go b/tests/rkt_image_cat_manifest_test.go index 765e584db9..ae210c86d7 100644 --- a/tests/rkt_image_cat_manifest_test.go +++ b/tests/rkt_image_cat_manifest_test.go @@ -27,7 +27,7 @@ import ( const ( // The expected image manifest of the 'rkt-inspect-image-cat-manifest.aci'. - manifestTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.3.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.4.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageCatManifest tests 'rkt image cat-manifest', it will: diff --git a/tests/rkt_image_export_test.go b/tests/rkt_image_export_test.go index 35401d5927..50eba09988 100644 --- a/tests/rkt_image_export_test.go +++ b/tests/rkt_image_export_test.go @@ -26,7 +26,7 @@ import ( ) const ( - manifestExportTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.3.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestExportTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.4.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageExport tests 'rkt image export', it will import some existing diff --git a/tests/rkt_image_render_test.go b/tests/rkt_image_render_test.go index 8b5f91420f..a3dbd0a8f6 100644 --- a/tests/rkt_image_render_test.go +++ b/tests/rkt_image_render_test.go @@ -26,7 +26,7 @@ import ( ) const ( - manifestRenderTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.3.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"dependencies":[{"imageName":"coreos.com/rkt-inspect"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestRenderTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.4.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"dependencies":[{"imageName":"coreos.com/rkt-inspect"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageRender tests 'rkt image render', it will import some existing empty diff --git a/tests/rkt_os_arch_test.go b/tests/rkt_os_arch_test.go index a82e36b684..9430601911 100644 --- a/tests/rkt_os_arch_test.go +++ b/tests/rkt_os_arch_test.go @@ -25,7 +25,7 @@ import ( ) const ( - manifestOSArchTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.3.0"}ARCH_OS],"app":{"exec":["/inspect", "--print-msg=HelloWorld"],"user":"0","group":"0","workingDirectory":"/"}}` + manifestOSArchTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.4.0"}ARCH_OS],"app":{"exec":["/inspect", "--print-msg=HelloWorld"],"user":"0","group":"0","workingDirectory":"/"}}` ) type osArchTest struct { From 481ab7156f802206f35b534039846041b4c70d5d Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Fri, 15 Apr 2016 11:43:22 +0200 Subject: [PATCH 0124/1304] version: bump to v1.4.0+git --- configure.ac | 2 +- scripts/acbuild-rkt-builder.sh | 2 +- scripts/build-rir.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 94da0062d4..7b8fc4ef0d 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.63]) -AC_INIT([rkt], [1.4.0], [https://github.com/coreos/rkt/issues]) +AC_INIT([rkt], [1.4.0+git], [https://github.com/coreos/rkt/issues]) AC_DEFUN([RKT_CHECK_PROG], [AS_VAR_IF([$1], [], diff --git a/scripts/acbuild-rkt-builder.sh b/scripts/acbuild-rkt-builder.sh index a3b4f15c9f..135f2bc220 100755 --- a/scripts/acbuild-rkt-builder.sh +++ b/scripts/acbuild-rkt-builder.sh @@ -25,7 +25,7 @@ ACI_NAME=${ACI_NAME:-"coreos.com/rkt/builder"} BUILDDIR=/opt/build-rkt SRC_DIR=/opt/rkt ACI_GOPATH=/go -VERSION=${VERSION:-"v1.4.0"} +VERSION=${VERSION:-"v1.4.0+git"} echo "Version: $VERSION" echo "Building $ACI_FILE" diff --git a/scripts/build-rir.sh b/scripts/build-rir.sh index 4afc24a38e..acb8f4fc4a 100755 --- a/scripts/build-rir.sh +++ b/scripts/build-rir.sh @@ -4,7 +4,7 @@ set -xe SRC_DIR=${SRC_DIR:-$PWD} BUILDDIR=${BUILDDIR:-$PWD/build-rir} -RKT_BUILDER_ACI=${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.4.0} +RKT_BUILDER_ACI=${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.4.0+git} mkdir -p $BUILDDIR From 69353251fc2312a153268974f8d660af161218a6 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Fri, 15 Apr 2016 16:14:28 +0200 Subject: [PATCH 0125/1304] release: fix build-rir.sh script Currently `build-rir.sh` inherits the environment during the build. This is unnecessary and can actually break the build on a custom host PATH environment. This fixes it. --- scripts/build-rir.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/scripts/build-rir.sh b/scripts/build-rir.sh index acb8f4fc4a..e9880faa53 100755 --- a/scripts/build-rir.sh +++ b/scripts/build-rir.sh @@ -2,15 +2,14 @@ set -xe -SRC_DIR=${SRC_DIR:-$PWD} -BUILDDIR=${BUILDDIR:-$PWD/build-rir} -RKT_BUILDER_ACI=${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.4.0+git} +SRC_DIR="${SRC_DIR:-$PWD}" +BUILDDIR="${BUILDDIR:-$PWD/build-rir}" +RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.4.0+git}" mkdir -p $BUILDDIR rkt run \ - --inherit-env \ - --volume src-dir,kind=host,source=$SRC_DIR \ - --volume build-dir,kind=host,source=$BUILDDIR \ + --volume src-dir,kind=host,source="${SRC_DIR}" \ + --volume build-dir,kind=host,source="${BUILDDIR}" \ --interactive \ $RKT_BUILDER_ACI $@ From 2f53f48c171b45de44dacca6d808d6e74345ca21 Mon Sep 17 00:00:00 2001 From: Yifan Gu Date: Thu, 14 Apr 2016 15:41:44 -0700 Subject: [PATCH 0126/1304] tests: Sleep delta time before 'rkt gc --mark-only'. --- Documentation/using-rkt-with-systemd.md | 4 ++-- tests/rkt_api_service_test.go | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Documentation/using-rkt-with-systemd.md b/Documentation/using-rkt-with-systemd.md index e88a72642f..6f7f57d348 100644 --- a/Documentation/using-rkt-with-systemd.md +++ b/Documentation/using-rkt-with-systemd.md @@ -101,7 +101,7 @@ A more advanced unit example takes advantage of a few convenient `systemd` featu 1. Inheriting environment variables specified in the unit with `--inherit-env`. This feature helps keep units concise, instead of layering on many flags to `rkt run`. 2. Using the dependency graph to start our pod after networking has come online. This is helpful if your application requires outside connectivity to fetch remote configuration (for example, from `etcd`). 3. Set resource limits for this `rkt` pod. This can also be done in the unit file, rather than flagged to `rkt run`. -4. Set `ExecStop` to invoke `rkt gc --mark-only` to record the timestamp when the pod exits. +4. Set `ExecStopPost` to invoke `rkt gc --mark-only` to record the timestamp when the pod exits. (Run `rkt gc --help` to see more details about this flag). After running `rkt gc --mark-only`, the timestamp can be retrieved from rkt API service in pod's `gc_marked_at` field. The timestamp can be treated as the finished time of the pod. @@ -131,7 +131,7 @@ Environment=TMPDIR=/var/tmp ExecStartPre=/usr/bin/rkt fetch myapp.com/myapp-1.3.4 # Start the app ExecStart=/usr/bin/rkt run --inherit-env --port=http:8888 myapp.com/myapp-1.3.4 -ExecStop=/usr/bin/rkt gc --mark-only +ExecStopPost=/usr/bin/rkt gc --mark-only KillMode=mixed Restart=always ``` diff --git a/tests/rkt_api_service_test.go b/tests/rkt_api_service_test.go index a527977046..6afcd4ce2b 100644 --- a/tests/rkt_api_service_test.go +++ b/tests/rkt_api_service_test.go @@ -338,6 +338,8 @@ func TestAPIServiceListInspectPods(t *testing.T) { runCmd := fmt.Sprintf("%s run --pod-manifest=%s", ctx.Cmd(), manifestFile) waitOrFail(t, spawnOrFail(t, runCmd), 0) + time.Sleep(delta) + gcCmd := fmt.Sprintf("%s gc --mark-only=true", ctx.Cmd()) waitOrFail(t, spawnOrFail(t, gcCmd), 0) From 1530274e0624c56cd086ae36f6bdd3a3d57a2d16 Mon Sep 17 00:00:00 2001 From: Josh Wood Date: Fri, 15 Apr 2016 15:56:33 -0700 Subject: [PATCH 0127/1304] Doc/subcmd/config: Fix formatting of code blocks - newline. --- Documentation/subcommands/config.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/subcommands/config.md b/Documentation/subcommands/config.md index fbef3d1c98..8d3f1701d2 100644 --- a/Documentation/subcommands/config.md +++ b/Documentation/subcommands/config.md @@ -17,6 +17,7 @@ The entry "stage0" refers to stage-specific configuration; "stage1" is currently The "stage0" entry contains subentries of rktKind "auth", "dockerAuth", "paths", and "stage1". Note that the `config` subcommand will output separate entries per "auth" domain and separate entries per "dockerAuth" registry. While it is possible to specify an array of strings in the input configuration rkt internally merges configuration state from different directories potentially creating multiple entries. Consider the following system configuration: + ``` $ cat /etc/rkt/auth.d/basic.json { @@ -33,6 +34,7 @@ $ cat /etc/rkt/auth.d/basic.json ``` And the following user configuration: + ``` $ ~/.config/rkt/auth.d/basic.json { @@ -47,6 +49,7 @@ $ ~/.config/rkt/auth.d/basic.json ``` The `config` subcommand would generate the following separate merged entries: + ``` { "stage0": [ @@ -123,3 +126,4 @@ $ rkt config } ] } +``` From 10d22b56f25146eddbcdfb8fd071aeac7ce62d5a Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Sun, 17 Apr 2016 09:33:06 +0200 Subject: [PATCH 0128/1304] pkg/sys: add SYS_SYNCFS definition for ppc64/ppc64le Added missing SYS_SYNCFS definition for ppc64 and ppc64le, fixing build failures on those architectures. Closes: coreos/rkt#2441 Signed-off-by: Luca Bruno --- pkg/sys/sys_linux_ppc64.go | 21 +++++++++++++++++++++ pkg/sys/sys_linux_ppc64le.go | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 pkg/sys/sys_linux_ppc64.go create mode 100644 pkg/sys/sys_linux_ppc64le.go diff --git a/pkg/sys/sys_linux_ppc64.go b/pkg/sys/sys_linux_ppc64.go new file mode 100644 index 0000000000..10a1d8f875 --- /dev/null +++ b/pkg/sys/sys_linux_ppc64.go @@ -0,0 +1,21 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build linux,ppc64 + +package sys + +const ( + SYS_SYNCFS = 348 +) diff --git a/pkg/sys/sys_linux_ppc64le.go b/pkg/sys/sys_linux_ppc64le.go new file mode 100644 index 0000000000..d88a80dab7 --- /dev/null +++ b/pkg/sys/sys_linux_ppc64le.go @@ -0,0 +1,21 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build linux,ppc64le + +package sys + +const ( + SYS_SYNCFS = 348 +) From db6c62d17e75c5c72742157e5ef9621f23835d5c Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Mon, 18 Apr 2016 09:45:24 +0200 Subject: [PATCH 0129/1304] tests/TestAppUserGroup: cleanup ctx after each test Fixes #2444 --- tests/rkt_run_user_group_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/rkt_run_user_group_test.go b/tests/rkt_run_user_group_test.go index a233ff117f..b59ecee943 100644 --- a/tests/rkt_run_user_group_test.go +++ b/tests/rkt_run_user_group_test.go @@ -23,9 +23,6 @@ import ( ) func TestAppUserGroup(t *testing.T) { - ctx := testutils.NewRktRunCtx() - defer ctx.Cleanup() - imageDummy := patchTestACI("rkt-inspect-dummy.aci", "--name=dummy") defer os.Remove(imageDummy) @@ -83,6 +80,9 @@ func TestAppUserGroup(t *testing.T) { }, } { func() { + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + tt.imageParams = append(tt.imageParams, "--exec=/inspect --print-user") image := patchTestACI("rkt-inspect-user-group.aci", tt.imageParams...) defer os.Remove(image) From daa22603c4128a6994d07a18439052360876e07b Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Mon, 18 Apr 2016 11:55:25 +0300 Subject: [PATCH 0130/1304] tests: find LCA to detect commit differences Creates a function to find the lowest common ancestor between two commits. Fixes #2423 --- tests/build-and-run-tests.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/build-and-run-tests.sh b/tests/build-and-run-tests.sh index 5a2363da9e..e5f0215779 100755 --- a/tests/build-and-run-tests.sh +++ b/tests/build-and-run-tests.sh @@ -28,14 +28,24 @@ function ciSkip { exit 0 } +# Finds the branching point of two commits. +# For example, let B and D be two commits, and their ancestry graph as A -> B, A -> C -> D. +# Given commits B and D, it returns A. +function getBranchingPoint { + diff --old-line-format='' --new-line-format='' \ + <(git rev-list --first-parent "${1:-$1}") \ + <(git rev-list --first-parent "${2:-$2}") | head -1 +} + # Configure SemaphoreCI environment. function semaphoreConfiguration { # We might not need to run functional tests or process docs. # This is best-effort; || true ensures this does not affect test outcome # First, ensure origin is updated - semaphore can do some weird caching git fetch || true - SRC_CHANGES=$(git diff-tree --no-commit-id --name-only -r HEAD..origin/master | grep -cEv ${DOC_CHANGE_PATTERN}) || true - DOC_CHANGES=$(git diff-tree --no-commit-id --name-only -r HEAD..origin/master | grep -cE ${DOC_CHANGE_PATTERN}) || true + BRANCHING_POINT=$(getBranchingPoint HEAD origin/master) + SRC_CHANGES=$(git diff-tree --no-commit-id --name-only -r HEAD..${BRANCHING_POINT} | grep -cEv ${DOC_CHANGE_PATTERN}) || true + DOC_CHANGES=$(git diff-tree --no-commit-id --name-only -r HEAD..${BRANCHING_POINT} | grep -cE ${DOC_CHANGE_PATTERN}) || true # Set up go environment on semaphore if [ -f /opt/change-go-version.sh ]; then From 8bbefc32ac76bc9be9292d26cf69529bf98b9fa4 Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Tue, 19 Apr 2016 13:51:32 +0200 Subject: [PATCH 0131/1304] MAINTAINERS: add Sergiusz Urbaniak @s-urbaniak --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index ace95542cb..935b563112 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4,6 +4,7 @@ Derek Gonyeo (@dgonyeo) Iago López Galeiras (@iaguis) Jonathan Boulle (@jonboulle) Krzesimir Nowak (@krnowak) +Sergiusz Urbaniak (@s-urbaniak) Stefan Junker (@steveeJ) Vito Caputo (@vcaputo) Yifan Gu (@yifan-gu) From 159985297a9a8235c219bd542567edfdc87077b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Mon, 18 Apr 2016 15:48:03 +0200 Subject: [PATCH 0132/1304] stage1/init: interpret "root" as UID/GID 0 This is a special case and it should work even if the image doesn't have /etc/passwd or /etc/group. --- stage1/init/common/pod.go | 132 +++++++++++++++++++++++--------------- 1 file changed, 79 insertions(+), 53 deletions(-) diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index f401c1fe80..cf04ac2832 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -302,62 +302,13 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b return errwrap.Wrap(errors.New("unable to write environment file"), err) } - var _uid, gid int - var err error - - uidRange := uid.NewBlankUidRange() - if err := uidRange.Deserialize([]byte(privateUsers)); err != nil { - return errwrap.Wrap(errors.New("unable to deserialize uid range"), err) - } - - if strings.HasPrefix(app.User, "/") { - var stat syscall.Stat_t - if err = syscall.Lstat(filepath.Join(common.AppRootfsPath(p.Root, appName), - app.User), &stat); err != nil { - return errwrap.Wrap(fmt.Errorf("unable to get uid from file %q", - app.User), err) - } - uidReal, _, err := uidRange.UnshiftRange(stat.Uid, 0) - if err != nil { - return errwrap.Wrap(errors.New("unable to determine real uid"), err) - } - _uid = int(uidReal) - } else { - _uid, err = strconv.Atoi(app.User) - if err != nil { - _uid, err = passwd.LookupUidFromFile(app.User, - filepath.Join(common.AppRootfsPath(p.Root, appName), "etc/passwd")) - if err != nil { - return errwrap.Wrap(fmt.Errorf("cannot lookup user %q", app.User), err) - } - } - } - - if strings.HasPrefix(app.Group, "/") { - var stat syscall.Stat_t - if err = syscall.Lstat(filepath.Join(common.AppRootfsPath(p.Root, appName), - app.Group), &stat); err != nil { - return errwrap.Wrap(fmt.Errorf("unable to get gid from file %q", - app.Group), err) - } - _, gidReal, err := uidRange.UnshiftRange(0, stat.Gid) - if err != nil { - return errwrap.Wrap(errors.New("unable to determine real gid"), err) - } - gid = int(gidReal) - } else { - gid, err = strconv.Atoi(app.Group) - if err != nil { - gid, err = group.LookupGidFromFile(app.Group, - filepath.Join(common.AppRootfsPath(p.Root, appName), "etc/group")) - if err != nil { - return errwrap.Wrap(fmt.Errorf("cannot lookup group %q", app.Group), err) - } - } + u, g, err := parseUserGroup(p, ra, privateUsers) + if err != nil { + return err } execWrap := []string{"/appexec", common.RelAppRootfsPath(appName), workDir, RelEnvFilePath(appName), - strconv.Itoa(_uid), generateGidArg(gid, app.SupplementaryGIDs), "--"} + strconv.Itoa(u), generateGidArg(g, app.SupplementaryGIDs), "--"} execStart := quoteExec(append(execWrap, app.Exec...)) opts := []*unit.UnitOption{ unit.NewUnitOption("Unit", "Description", fmt.Sprintf("Application=%v Image=%v", appName, imgName)), @@ -500,6 +451,81 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b return nil } +// parseUserGroup parses the User and Group fields of an App and returns its +// UID and GID. +// The User and Group fields accept several formats: +// 1. the hardcoded string "root" +// 2. a path +// 3. a number +// 4. a name in reference to /etc/{group,passwod} in the image +// See https://github.com/appc/spec/blob/master/spec/aci.md#image-manifest-schema +func parseUserGroup(p *stage1commontypes.Pod, ra *schema.RuntimeApp, privateUsers string) (int, int, error) { + app := ra.App + appName := ra.Name + + var uid_, gid_ int + var err error + + uidRange := uid.NewBlankUidRange() + if err := uidRange.Deserialize([]byte(privateUsers)); err != nil { + return -1, -1, errwrap.Wrap(errors.New("unable to deserialize uid range"), err) + } + + switch { + case app.User == "root": + uid_ = 0 + case strings.HasPrefix(app.User, "/"): + var stat syscall.Stat_t + if err = syscall.Lstat(filepath.Join(common.AppRootfsPath(p.Root, appName), + app.User), &stat); err != nil { + return -1, -1, errwrap.Wrap(fmt.Errorf("unable to get uid from file %q", + app.User), err) + } + uidReal, _, err := uidRange.UnshiftRange(stat.Uid, 0) + if err != nil { + return -1, -1, errwrap.Wrap(errors.New("unable to determine real uid"), err) + } + uid_ = int(uidReal) + default: + uid_, err = strconv.Atoi(app.User) + if err != nil { + uid_, err = passwd.LookupUidFromFile(app.User, + filepath.Join(common.AppRootfsPath(p.Root, appName), "etc/passwd")) + if err != nil { + return -1, -1, errwrap.Wrap(fmt.Errorf("cannot lookup user %q", app.User), err) + } + } + } + + switch { + case app.Group == "root": + gid_ = 0 + case strings.HasPrefix(app.Group, "/"): + var stat syscall.Stat_t + if err = syscall.Lstat(filepath.Join(common.AppRootfsPath(p.Root, appName), + app.Group), &stat); err != nil { + return -1, -1, errwrap.Wrap(fmt.Errorf("unable to get gid from file %q", + app.Group), err) + } + _, gidReal, err := uidRange.UnshiftRange(0, stat.Gid) + if err != nil { + return -1, -1, errwrap.Wrap(errors.New("unable to determine real gid"), err) + } + gid_ = int(gidReal) + default: + gid_, err = strconv.Atoi(app.Group) + if err != nil { + gid_, err = group.LookupGidFromFile(app.Group, + filepath.Join(common.AppRootfsPath(p.Root, appName), "etc/group")) + if err != nil { + return -1, -1, errwrap.Wrap(fmt.Errorf("cannot lookup group %q", app.Group), err) + } + } + } + + return uid_, gid_, nil +} + func writeShutdownService(p *stage1commontypes.Pod) error { flavor, systemdVersion, err := GetFlavor(p) if err != nil { From afe0a382f36b6e7161db4582c9b66bcd7fa362eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Tue, 19 Apr 2016 12:02:53 +0200 Subject: [PATCH 0133/1304] functional tests: test "root" in User and Group --- tests/rkt_run_pod_manifest_test.go | 22 ++++++++++++++++++++++ tests/rkt_run_user_group_test.go | 12 ++++++++++++ 2 files changed, 34 insertions(+) diff --git a/tests/rkt_run_pod_manifest_test.go b/tests/rkt_run_pod_manifest_test.go index 322156b206..90eff3d349 100644 --- a/tests/rkt_run_pod_manifest_test.go +++ b/tests/rkt_run_pod_manifest_test.go @@ -611,6 +611,28 @@ func TestPodManifest(t *testing.T) { "User: uid=1000 euid=1000 gid=100 egid=100", "", }, + { + // Set "root", it should work without it being present in + // /etc/{passwd,group} + []imagePatch{ + {"rkt-test-run-pod-manifest-root-user-group.aci", []string{}}, + }, + &schema.PodManifest{ + Apps: []schema.RuntimeApp{ + { + Name: baseAppName, + App: &types.App{ + Exec: []string{"/inspect", "--print-user"}, + User: "root", + Group: "root", + }, + }, + }, + }, + 0, + "User: uid=0 euid=0 gid=0 egid=0", + "", + }, { // Set invalid non-numerical app user. []imagePatch{ diff --git a/tests/rkt_run_user_group_test.go b/tests/rkt_run_user_group_test.go index b59ecee943..5c77158103 100644 --- a/tests/rkt_run_user_group_test.go +++ b/tests/rkt_run_user_group_test.go @@ -78,6 +78,18 @@ func TestAppUserGroup(t *testing.T) { rktParams: "--user=user1 --group=group1", expected: "User: uid=1000 euid=1000 gid=100 egid=100", }, + { + imageParams: []string{"--user=root", "--group=root"}, + expected: "User: uid=0 euid=0 gid=0 egid=0", + }, + { + rktParams: "--user=root --group=root", + expected: "User: uid=0 euid=0 gid=0 egid=0", + }, + { + rktParams: "--user=/inspect --group=/inspect", + expected: "User: uid=0 euid=0 gid=0 egid=0", + }, } { func() { ctx := testutils.NewRktRunCtx() From cd08a4b32da3d1e61176b127a9998c657d6fa4d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 20 Apr 2016 11:41:15 +0200 Subject: [PATCH 0134/1304] rkt/image: strip "Authorization" on redirects to a different host We shouldn't pass the "Authorization" header if the redirect goes to a different host, it can leak sensitive information to unexpected third parties. This fixes an issue where rkt gets redirected to Amazon S3 when downloading an ACI from quay and S3 returns a 400 (Bad Request) with this error message: "Only one auth mechanism allowed; only the X-Amz-Algorithm query parameter, Signature query string parameter or the Authorization header should be specified" The problem happens because we're sending "Authorization" and the URL on the redirect already includes a "Signature" query string parameter. --- rkt/image/resumablesession.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/rkt/image/resumablesession.go b/rkt/image/resumablesession.go index 66084d5fbe..712d29bbe9 100644 --- a/rkt/image/resumablesession.go +++ b/rkt/image/resumablesession.go @@ -285,7 +285,14 @@ func (s *resumableSession) getClient() *http.Client { if len(via) >= 10 { return fmt.Errorf("too many redirects") } - s.setHTTPHeaders(req) + stripAuth := false + // don't propagate "Authorization" if the redirect is to a + // different host + previousHost := via[len(via)-1].URL.Host + if previousHost != req.URL.Host { + stripAuth = true + } + s.setHTTPHeaders(req, stripAuth) return nil }, } @@ -302,7 +309,7 @@ func (s *resumableSession) httpRequest(method string, u *url.URL) *http.Request Host: u.Host, } - s.setHTTPHeaders(req) + s.setHTTPHeaders(req, false) return req } @@ -330,8 +337,11 @@ func (s *resumableSession) eTagOK(res *http.Response) bool { return false } -func (s *resumableSession) setHTTPHeaders(req *http.Request) { +func (s *resumableSession) setHTTPHeaders(req *http.Request, stripAuth bool) { for k, v := range s.Headers { + if stripAuth && k == "Authorization" { + continue + } for _, e := range v { req.Header.Add(k, e) } From 2438736f65b23f4feb6542be3e9ac33ee35d37dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 20 Apr 2016 14:10:30 +0200 Subject: [PATCH 0135/1304] functional tests: fix detectChanges function When we did the refactoring of the CI build script, we inverted the condition that checks if we're in origin/master to always run the tests in that case. That caused tests not running on the master branch anymore. --- tests/build-and-run-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/build-and-run-tests.sh b/tests/build-and-run-tests.sh index 5a2363da9e..536754b03e 100755 --- a/tests/build-and-run-tests.sh +++ b/tests/build-and-run-tests.sh @@ -166,7 +166,7 @@ function buildFolder { function detectChanges { HEAD=`git rev-parse HEAD` MASTER=`git rev-parse origin/master` - if [[ ${HEAD} != ${MASTER} ]]; then + if [[ ${HEAD} == ${MASTER} ]]; then SRC_CHANGES=1 DOC_CHANGES=1 elif [[ ${SRC_CHANGES} -eq 0 && ${DOC_CHANGES} -eq 0 ]]; then From 81a40aee87082c0ce4af8f594cdf2fb093b1c03b Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Mon, 18 Apr 2016 12:45:47 +0300 Subject: [PATCH 0136/1304] tests: rename "Semaphore" to "Semaphore CI system" To prevent confusion, usage of "Semaphore" is changed to "Semaphore CI system" --- tests/README.md | 8 ++++---- tests/build-and-run-tests.sh | 10 +++++----- tests/install-deps.sh | 6 +++--- tests/rkt_userns_test.go | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/README.md b/tests/README.md index f2e062422a..296803a5eb 100644 --- a/tests/README.md +++ b/tests/README.md @@ -3,14 +3,14 @@ This directory contains a set of functional tests for rkt. The tests use [gexpect](https://github.com/coreos/gexpect) to spawn various `rkt run` commands and look for expected output. -## Semaphore +## Semaphore Continuous Integration System -The tests run on the [Semaphore](https://semaphoreci.com/) CI system through the [`rktbot`](https://semaphoreci.com/rktbot) user, which is part of the [`coreos`](https://semaphoreci.com/coreos/) org on Semaphore. +The tests run on the [Semaphore CI system](https://semaphoreci.com/) through the [`rktbot`](https://semaphoreci.com/rktbot) user, which is part of the [`coreos`](https://semaphoreci.com/coreos/) org on Semaphore CI system. This user is authorized against the corresponding [`rktbot`](https://github.com/rktbot) GitHub account. The credentials for `rktbot` are currently managed by CoreOS. -The tests are executed on Semaphore at each Pull Request (PR). -Each GitHub PR page should have a link to the [test results on Semaphore](https://semaphoreci.com/coreos/rkt). +The tests are executed on Semaphore CI system at each Pull Request (PR). +Each GitHub PR page should have a link to the [test results on Semaphore CI](https://semaphoreci.com/coreos/rkt). Developers can disable the tests by adding `[skip ci]` in the last commit message of the PR. diff --git a/tests/build-and-run-tests.sh b/tests/build-and-run-tests.sh index b1b0542200..bb60c7b982 100755 --- a/tests/build-and-run-tests.sh +++ b/tests/build-and-run-tests.sh @@ -37,17 +37,17 @@ function getBranchingPoint { <(git rev-list --first-parent "${2:-$2}") | head -1 } -# Configure SemaphoreCI environment. -function semaphoreConfiguration { +# Configure Semaphore CI environment. +function semaphoreCIConfiguration { # We might not need to run functional tests or process docs. # This is best-effort; || true ensures this does not affect test outcome - # First, ensure origin is updated - semaphore can do some weird caching + # First, ensure origin is updated - Semaphore CI system can do some weird caching git fetch || true BRANCHING_POINT=$(getBranchingPoint HEAD origin/master) SRC_CHANGES=$(git diff-tree --no-commit-id --name-only -r HEAD..${BRANCHING_POINT} | grep -cEv ${DOC_CHANGE_PATTERN}) || true DOC_CHANGES=$(git diff-tree --no-commit-id --name-only -r HEAD..${BRANCHING_POINT} | grep -cE ${DOC_CHANGE_PATTERN}) || true - # Set up go environment on semaphore + # Set up go environment on Semaphore CI if [ -f /opt/change-go-version.sh ]; then . /opt/change-go-version.sh change-go-version 1.5 @@ -242,7 +242,7 @@ function main { # https://semaphoreci.com/docs/available-environment-variables.html if [ "${SEMAPHORE-}" == true ] ; then - semaphoreConfiguration + semaphoreCIConfiguration fi prepareBuildEnv diff --git a/tests/install-deps.sh b/tests/install-deps.sh index 101435b374..dab8feda62 100755 --- a/tests/install-deps.sh +++ b/tests/install-deps.sh @@ -15,10 +15,10 @@ fi if [ "${CI-}" == true ] ; then # https://semaphoreci.com/ if [ "${SEMAPHORE-}" == true ] ; then - # Most dependencies are already installed on Semaphore. + # Most dependencies are already installed on Semaphore CI system. # Here we can install any missing dependencies. Whenever - # Semaphore installs more dependencies on their platform, - # they should be removed from here to save time. + # Semaphore CI system installs more dependencies on their + # platform, they should be removed from here to save time. # If there is some dependency to install then # uncomment the following line and add "sudo apt-get diff --git a/tests/rkt_userns_test.go b/tests/rkt_userns_test.go index 10697979db..a1509c3988 100644 --- a/tests/rkt_userns_test.go +++ b/tests/rkt_userns_test.go @@ -46,7 +46,7 @@ var usernsTests = []struct { "", // no check: it could be 0 but also the gid of 'rkt', see https://github.com/coreos/rkt/pull/1452 }, // TODO test with overlay fs too. We don't test it for now because - // Semaphore doesn't support it. + // Semaphore CI system doesn't support it. } func TestUserns(t *testing.T) { From cba545f421f3229f63cad76a8afeb9fce5720acb Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Wed, 20 Apr 2016 15:07:14 +0200 Subject: [PATCH 0137/1304] tests: simplify Semaphore CI references --- tests/README.md | 6 +++--- tests/build-and-run-tests.sh | 4 ++-- tests/install-deps.sh | 4 ++-- tests/rkt_userns_test.go | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/README.md b/tests/README.md index 296803a5eb..9b4c3dd24f 100644 --- a/tests/README.md +++ b/tests/README.md @@ -5,12 +5,12 @@ The tests use [gexpect](https://github.com/coreos/gexpect) to spawn various `rkt ## Semaphore Continuous Integration System -The tests run on the [Semaphore CI system](https://semaphoreci.com/) through the [`rktbot`](https://semaphoreci.com/rktbot) user, which is part of the [`coreos`](https://semaphoreci.com/coreos/) org on Semaphore CI system. +The tests run on the [Semaphore CI system](https://semaphoreci.com/) through the [`rktbot`](https://semaphoreci.com/rktbot) user, which is part of the [`coreos`](https://semaphoreci.com/coreos/) org on Semaphore. This user is authorized against the corresponding [`rktbot`](https://github.com/rktbot) GitHub account. The credentials for `rktbot` are currently managed by CoreOS. -The tests are executed on Semaphore CI system at each Pull Request (PR). -Each GitHub PR page should have a link to the [test results on Semaphore CI](https://semaphoreci.com/coreos/rkt). +The tests are executed on Semaphore at each Pull Request (PR). +Each GitHub PR page should have a link to the [test results on Semaphore](https://semaphoreci.com/coreos/rkt). Developers can disable the tests by adding `[skip ci]` in the last commit message of the PR. diff --git a/tests/build-and-run-tests.sh b/tests/build-and-run-tests.sh index bb60c7b982..e4c13f1122 100755 --- a/tests/build-and-run-tests.sh +++ b/tests/build-and-run-tests.sh @@ -41,13 +41,13 @@ function getBranchingPoint { function semaphoreCIConfiguration { # We might not need to run functional tests or process docs. # This is best-effort; || true ensures this does not affect test outcome - # First, ensure origin is updated - Semaphore CI system can do some weird caching + # First, ensure origin is updated - Semaphore can do some weird caching git fetch || true BRANCHING_POINT=$(getBranchingPoint HEAD origin/master) SRC_CHANGES=$(git diff-tree --no-commit-id --name-only -r HEAD..${BRANCHING_POINT} | grep -cEv ${DOC_CHANGE_PATTERN}) || true DOC_CHANGES=$(git diff-tree --no-commit-id --name-only -r HEAD..${BRANCHING_POINT} | grep -cE ${DOC_CHANGE_PATTERN}) || true - # Set up go environment on Semaphore CI + # Set up go environment on Semaphore if [ -f /opt/change-go-version.sh ]; then . /opt/change-go-version.sh change-go-version 1.5 diff --git a/tests/install-deps.sh b/tests/install-deps.sh index dab8feda62..1b6bff81f1 100755 --- a/tests/install-deps.sh +++ b/tests/install-deps.sh @@ -15,9 +15,9 @@ fi if [ "${CI-}" == true ] ; then # https://semaphoreci.com/ if [ "${SEMAPHORE-}" == true ] ; then - # Most dependencies are already installed on Semaphore CI system. + # Most dependencies are already installed on Semaphore. # Here we can install any missing dependencies. Whenever - # Semaphore CI system installs more dependencies on their + # Semaphore installs more dependencies on their # platform, they should be removed from here to save time. # If there is some dependency to install then diff --git a/tests/rkt_userns_test.go b/tests/rkt_userns_test.go index a1509c3988..0067b1c009 100644 --- a/tests/rkt_userns_test.go +++ b/tests/rkt_userns_test.go @@ -46,7 +46,7 @@ var usernsTests = []struct { "", // no check: it could be 0 but also the gid of 'rkt', see https://github.com/coreos/rkt/pull/1452 }, // TODO test with overlay fs too. We don't test it for now because - // Semaphore CI system doesn't support it. + // the Semaphore CI system doesn't support it. } func TestUserns(t *testing.T) { From 41948391606e5b3b03843f5b633f28dc47066077 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Wed, 6 Apr 2016 16:06:16 +0200 Subject: [PATCH 0138/1304] stage1/prepare-app: avoid recursive bind-mounts on /sys Starting a pod with 100 apps is really slow. This patch fixes the slowness. prepare-app recursively bind-mounts /sys from stage1 to the stage2 (apps' rootfs). "Recursive" means it includes all the cgroup mounts because they are in /sys/fs/cgroup. Moreover, rkt bind mounts some cgroup knob files in the cgroup filesystem for enabling the memory and cpu isolator. The number of cgroup bind mounts in stage1 is linear with the number of apps: O(n) The number of cgroup bind mounts in stage2 is quadratic with the number of apps: O(n^2) With one app, I have 17 bind mounts related to cgroups. With 100 apps, 17 * 100 * 100 = 170.000 bind mounts. For each change in the mount table, systemd is notified via inotify on /proc/self/mountinfo and it checks the configuration of that mount in /etc/systemd/system, /run/systemd/system, /usr/local/lib/systemd/system and /usr/lib64/systemd/system. systemd does about 30 syscalls per new mount notified via /proc/self/mountinfo. That was 5.100.000 syscalls for mounting cgroups in a 100-app pod. This patch changes the logic to bind mount /sys: - in the usual non-unified cgroup hierarchy: bind mount /sys non-recursively and instead bind-mount each cgroup hierarchy individually, non-recursively. - in the unified cgroup hierarchy: keep the recursive bind mount because we will not have per-app bind mounts on knob files in this case. --- stage1/prepare-app/prepare-app.c | 71 +++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/stage1/prepare-app/prepare-app.c b/stage1/prepare-app/prepare-app.c index 30d88173f5..2731ef54df 100644 --- a/stage1/prepare-app/prepare-app.c +++ b/stage1/prepare-app/prepare-app.c @@ -21,6 +21,8 @@ #include #include #include +#include +#include #define err_out(_fmt, _args...) \ fprintf(stderr, "Error: " _fmt "\n", ##_args); @@ -50,6 +52,10 @@ static int exit_err; #define MACHINE_ID_LEN lenof("0123456789abcdef0123456789ab") #define MACHINE_NAME_LEN lenof("rkt-01234567-89ab-cdef-0123-456789ab") +#ifndef CGROUP2_SUPER_MAGIC +#define CGROUP2_SUPER_MAGIC 0x63677270 +#endif + typedef struct _dir_op_t { const char *name; mode_t mode; @@ -119,6 +125,66 @@ static int ensure_etc_hosts_exists(const char *root, int rootfd) { return 0; } +static void mount_sys(const char *root) +{ + char from[4096]; + char to[4096]; + struct statfs fs; + DIR *dir = NULL; + struct dirent *d; + + pexit_if(statfs("/sys/fs/cgroup", &fs) != 0, + "Cannot statfs /sys/fs/cgroup"); + if (fs.f_type == (typeof(fs.f_type)) CGROUP2_SUPER_MAGIC) { + /* With the unified cgroup hierarchy, recursive bind mounts + * are fine. */ + exit_if(snprintf(to, sizeof(to), "%s/%s", root, "sys") >= sizeof(to), + "Path too long: \"%s\"", to); + pexit_if(mount("/sys", to, "bind", + MS_BIND | MS_REC, "NULL") == -1, + "Mounting \"%s\" on \"%s\" failed", "/sys", to); + return; + } + + /* With cgroup-v1, rkt and systemd-nspawn add more cgroup + * bind-mounts to control which files are read-only. To avoid + * a quadratic progression, prepare-app does not bind mount + * /sys recursively. See: + * https://github.com/coreos/rkt/issues/2351 */ + exit_if(snprintf(to, sizeof(to), "%s/%s", root, "sys") >= sizeof(to), + "Path too long: \"%s\"", to); + pexit_if(mount("/sys", to, "bind", + MS_BIND, "NULL") == -1, + "Mounting \"%s\" on \"%s\" failed", "/sys", to); + + exit_if(snprintf(to, sizeof(to), "%s/%s", root, "sys/fs/cgroup") >= sizeof(to), + "Path too long: \"%s\"", to); + pexit_if(mount("/sys/fs/cgroup", to, "bind", + MS_BIND, "NULL") == -1, + "Mounting \"%s\" on \"%s\" failed", "/sys/fs/cgroup", to); + + pexit_if(!(dir = opendir(to)), "Failed to open directory \"%s\"", to) + errno = 0; + while ((d = readdir(dir))) { + if (d->d_type != DT_DIR) + continue; + if (strcmp(d->d_name, ".") == 0) + continue; + if (strcmp(d->d_name, "..") == 0) + continue; + + exit_if(snprintf(from, sizeof(from), "/sys/fs/cgroup/%s", d->d_name) >= sizeof(from), + "Path too long: \"%s\"", from); + exit_if(snprintf(to, sizeof(to), "%s/sys/fs/cgroup/%s", root, d->d_name) >= sizeof(to), + "Path too long: \"%s\"", to); + pexit_if(mount(from, to, "bind", + MS_BIND, "NULL") == -1, + "Mounting \"%s\" on \"%s\" failed", from, to); + } + pexit_if(errno != 0, "Failed to read directory \"%s\"", to); + pexit_if(closedir(dir) != 0, "Failed to close directory"); +} + int main(int argc, char *argv[]) { static const char *unlink_paths[] = { @@ -152,10 +218,10 @@ int main(int argc, char *argv[]) }; static const mount_point dirs_mount_table[] = { { "/proc", "/proc", "bind", NULL, MS_BIND|MS_REC }, - { "/sys", "/sys", "bind", NULL, MS_BIND|MS_REC }, { "/dev/shm", "/dev/shm", "bind", NULL, MS_BIND }, { "/dev/pts", "/dev/pts", "bind", NULL, MS_BIND }, { "/run/systemd/journal", "/run/systemd/journal", "bind", NULL, MS_BIND }, + /* /sys is handled separately */ }; static const mount_point files_mount_table[] = { { "/etc/rkt-resolv.conf", "/etc/resolv.conf", "bind", NULL, MS_BIND }, @@ -260,6 +326,9 @@ int main(int argc, char *argv[]) "Mounting \"%s\" on \"%s\" failed", mnt->source, to); } + /* Bind mount /sys: handled differently, depending on cgroups */ + mount_sys(root); + /* Bind mount files, if the source exists */ for (i = 0; i < nelems(files_mount_table); i++) { const mount_point *mnt = &files_mount_table[i]; From cb2047f12266ea399fe062b6fe50e2be0b0092c0 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Mon, 18 Apr 2016 16:32:31 +0200 Subject: [PATCH 0139/1304] doc/CONTRIBUTING: enhace PR and issue workflow Currently it is unspecified what a contributor is supposed to do after submitting a pull request. This explains further actions after the pull request submission. Also rkt has some critical runtime dependency, namly systemd, the kernel, and the operation system. This introduces a github issue template. Fixes #2406 --- .github/ISSUE_TEMPLATE.md | 21 +++++++++++++++++++++ CONTRIBUTING.md | 31 +++++++++++++++++++++++++++---- Documentation/devel/release.md | 27 ++++++++++++++++++++++++++- 3 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000000..44ab977c7f --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,21 @@ +**rkt** + +output of `rkt version` + +**Kernel** + +output of `uname -srm` + +**Distribution** + +content of `/etc/os-release` + +**systemd** + +output of `systemctl --version` + +**What did you do?** + +**What did you expect to see?** + +**What did you see instead?** diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 72d14470d6..868581b8bf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,14 +5,14 @@ GitHub pull requests. This document outlines some of the conventions on development workflow, commit message formatting, contact points and other resources to make it easier to get your contribution accepted. -# Certificate of Origin +### Certificate of Origin By contributing to this project you agree to the Developer Certificate of Origin (DCO). This document was created by the Linux Kernel community and is a simple statement that you, as a contributor, have the legal right to make the contribution. See the [DCO](DCO) file for details. -# Email and Chat +### Email and Chat The project has a mailing list and two discussion channels in IRC: - Email: [rkt-dev](https://groups.google.com/forum/#!forum/rkt-dev) @@ -22,13 +22,13 @@ The project has a mailing list and two discussion channels in IRC: Please avoid emailing maintainers found in the MAINTAINERS file directly. They are very busy and read the mailing lists. -## Getting Started +### Getting Started - Fork the repository on GitHub - Read the [README](README.md) for build and test instructions - Play with the project, submit bugs, submit patches! -## Contribution Flow +### Contribution Flow This is a rough outline of what a contributor's workflow looks like: @@ -38,6 +38,14 @@ This is a rough outline of what a contributor's workflow looks like: - Push your changes to a topic branch in your fork of the repository. - Make sure the tests pass, and add any new tests as appropriate. - Submit a pull request to the original repository. +- Submit a comment with the sole content "@reviewer PTAL" (please take a look) in GitHub + and replace "@reviewer" with the correct recipient. +- When addressing pull request review comments add new commits to the existing pull request or, + if the added commits are about the same size as the previous commits, + squash them into the existing commits. +- Once your PR is labelled as "reviewed/lgtm" squash the addressed commits in one commit. +- If your PR addresses multiple subsystems reorganize your PR and create multiple commits per subsystem. +- Your contribution is ready to be merged. Thanks for your contributions! @@ -76,3 +84,18 @@ The first line is the subject and should be no longer than 70 characters, the second line is always blank, and other lines should be wrapped at 80 characters. This allows the message to be easier to read on GitHub as well as in various git tools. + +### Format of the Pull Request + +The pull request title and the first paragraph of the pull request description +is being used to generate the changelog of the next release. + +The convention follows the same rules as for commit messages. The PR title reflects the +what and the first paragraph of the PR description reflects the why. +In most cases one can reuse the commit title as the PR title +and the commit messages as the PR description for the PR. + +If your PR includes more commits spanning mulitple subsystems one should change the PR title +and the first paragraph of the PR description to reflect a summary of all changes involved. + +Do not add entries in the changelog yourself. They will be overwritten when creating a new release. diff --git a/Documentation/devel/release.md b/Documentation/devel/release.md index 357c9adcef..d6950fcfd6 100644 --- a/Documentation/devel/release.md +++ b/Documentation/devel/release.md @@ -98,4 +98,29 @@ Make sure to include a list of authors that contributed since the previous relea git log v1.1.0..v1.2.0 --pretty=format:"%an" | sort | uniq | tr '\n' ',' | sed -e 's#,#, #g' -e 's#, $#\n#' ``` -- Prepare CHANGELOG.md for the next release: add a "vUNRELEASED" section. The CHANGELOG should be updated alongside the code as pull requests are merged into master, so that the releaser does not need to start from scratch. +Add `CHANGELOG.md` entries: + +- Add a new version headline and a meaningful release summary: + +``` +## v1.2.0 + +This release includes a number of new features and bugfixes like a new config subcommand, man page, and bash completion generation during build time. +``` + +- Execute `scripts/changelog.sh` +- Copy/Paste the generated entries into `CHANGELOG.md` +- Group the generated entries according to the following headlines: + +``` +#### New features and UX changes +... +#### Improved documentation +... +#### Bug fixes +... +#### Other changes +... +``` + +- Correct/fix the changelog entries if necessary. From 6db56deda9cb47943fc0892e4e2a0904304a6d58 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Mon, 18 Apr 2016 16:58:35 +0200 Subject: [PATCH 0140/1304] scripts: add changelog generator This adds a new script changelog.sh to generate changelog entries automatically. Fixes #2433 --- scripts/changelog.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 scripts/changelog.sh diff --git a/scripts/changelog.sh b/scripts/changelog.sh new file mode 100755 index 0000000000..65bab0d84d --- /dev/null +++ b/scripts/changelog.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# Create a changelog. +# +# The env variable RANGE specifies the range of commits to be searched for the changelog. +# If unset the latest tag until origin/master will be set. +# +# The env variable GITHUB_AUTH can be set in the form user:token to specify a GitHub +# personal access token. Otherwise one could run into GitHub rate limits. +# Go to https://github.com/settings/tokens to generate a token. +# +set -e + +jq --version >/dev/null 2>&1 || { + echo "could not find jq (JSON command line processor), is it installed?" + exit 255 +} + +if [ -z "${RANGE}" ]; then + LATEST_TAG=$(git describe --abbrev=0) + RANGE="${LATEST_TAG}..origin/master" +fi + +if [ ! -z "${GITHUB_AUTH}" ]; then + GITHUB_AUTH="-u ${GITHUB_AUTH}" +fi + +for pr in $(git log --pretty=%s --first-parent "${RANGE}" | egrep -o '#\w+' | tr -d '#'); do + body=$(curl -s "${GITHUB_AUTH}" https://api.github.com/repos/coreos/rkt/pulls/"${pr}" | \ + jq -r '{title: .title, body: .body}') + + echo "-" \ + "$(echo "${body}" | jq -r .title | sed 's/\.$//g')" \ + "([#${pr}](https://github.com/coreos/rkt/pull/$pr))." \ + "$(echo "${body}" | jq -r .body | awk -v RS='\r\n\r\n' NR==1 | tr -d '\r')" +done From 31f3fc1dc6e2d765bf78d3990476394745bf77aa Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Wed, 20 Apr 2016 15:13:54 +0200 Subject: [PATCH 0141/1304] docs & scripts: fix rir one liners * add resolv.conf volume/mount * use dependency scripts in one liners * remove duplicate packages * configure rkt without tpm --- Documentation/rkt-build-rkt.md | 8 ++++++-- scripts/install-deps-debian-sid.sh | 6 ++++-- scripts/install-deps-fedora-22.sh | 6 ++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Documentation/rkt-build-rkt.md b/Documentation/rkt-build-rkt.md index 71e3d405bf..133979c28e 100644 --- a/Documentation/rkt-build-rkt.md +++ b/Documentation/rkt-build-rkt.md @@ -76,23 +76,27 @@ The build output will be in `${SRC_DIR}/build-rkt-${RKT_VERSION}+git`. ## Debian Sid ``` rkt run \ + --volume rslvconf,kind=host,source=/etc/resolv.conf + --mount volume=rslvconf,target=/etc/resolv.conf --volume src-dir,kind=host,source=$SRC_DIR \ --mount volume=src-dir,target=/opt/rkt \ --interactive \ --insecure-options=image \ docker://debian:sid \ --exec /bin/bash \ - -- -c 'apt-get update && apt-get install -y --no-install-recommends ca-certificates gcc libc6-dev make automake wget git golang-go coreutils cpio squashfs-tools realpath autoconf file xz-utils patch bc locales libacl1-dev && update-ca-certificates && cd /opt/rkt && ./autogen.sh && ./configure && make' + -- -c 'cd /opt/rkt && ./scripts/install-deps-debian-sid.sh && ./autogen.sh && ./configure --disable-tpm && make' ``` ## Fedora 22 ``` rkt run \ + --volume rslvconf,kind=host,source=/etc/resolv.conf + --mount volume=rslvconf,target=/etc/resolv.conf --volume src-dir,kind=host,source=$SRC_DIR \ --mount volume=src-dir,target=/opt/rkt \ --interactive \ --insecure-options=image \ docker://fedora:22 \ --exec /bin/bash \ - -- -c 'dnf install -y make gcc glibc-devel glibc-static cpio squashfs-tools gpg autoconf make automake golang file git wget tar xz patch bc hostname findutils openssl libacl-devel && cd /opt/rkt && ./autogen.sh && ./configure && make' + -- -c 'cd /opt/rkt && ./scripts/install-deps-fedora-22.sh && ./autogen.sh && ./configure --disable-tpm && make' ``` diff --git a/scripts/install-deps-debian-sid.sh b/scripts/install-deps-debian-sid.sh index d0794b6c11..0db2db2ed5 100755 --- a/scripts/install-deps-debian-sid.sh +++ b/scripts/install-deps-debian-sid.sh @@ -1,7 +1,9 @@ #!/bin/bash set -e -export DEBIAN_FRONTEND=noninteractive +DEBIAN_SID_DEPS="ca-certificates gcc libc6-dev make automake wget git golang-go coreutils cpio squashfs-tools realpath autoconf file xz-utils patch bc locales libacl1-dev libssl-dev" + +export DEBIAN_FRONTEND=noninteractive apt-get update -apt-get install -y --no-install-recommends ca-certificates gcc libc6-dev make automake wget git golang-go coreutils cpio squashfs-tools realpath autoconf file xz-utils patch bc locales libacl1-dev libssl-dev +apt-get install -y --no-install-recommends ${DEBIAN_SID_DEPS} diff --git a/scripts/install-deps-fedora-22.sh b/scripts/install-deps-fedora-22.sh index 4fe11fb8df..d29bedfc16 100755 --- a/scripts/install-deps-fedora-22.sh +++ b/scripts/install-deps-fedora-22.sh @@ -1,5 +1,7 @@ #!/bin/bash -set -xe +set -e -dnf install -y make gcc glibc-devel glibc-static cpio squashfs-tools gpg autoconf make automake golang file git wget tar xz patch bc hostname findutils openssl libacl-devel openssl-devel +FEDORA22_DEPS="make gcc glibc-devel glibc-static cpio squashfs-tools gpg autoconf automake golang file git wget tar xz patch bc hostname findutils openssl libacl-devel openssl-devel" + +dnf install -y ${FEDORA22_DEPS} From ddd59b8935a3a9ee7c031e753642ea7863526fde Mon Sep 17 00:00:00 2001 From: Derek Gonyeo Date: Wed, 20 Apr 2016 14:28:38 -0400 Subject: [PATCH 0142/1304] benchmarks: pulled in code from github.com/dgonyeo/rkt-monitor Added the tests/benchmarks directory, which includes the code for a golang binary that can start rkt and watch its resource usage. This directory also includes bash scripts for generating a handful of test scenarios. --- tests/rkt-monitor/README.md | 43 ++++ tests/rkt-monitor/build | 9 + tests/rkt-monitor/build-cpu-stresser.sh | 26 +++ tests/rkt-monitor/build-log-stresser.sh | 26 +++ tests/rkt-monitor/build-mem-stresser.sh | 26 +++ tests/rkt-monitor/build-too-many-apps.sh | 91 ++++++++ tests/rkt-monitor/cpu-stresser/main.go | 24 ++ tests/rkt-monitor/log-stresser/main.go | 26 +++ tests/rkt-monitor/main.go | 285 +++++++++++++++++++++++ tests/rkt-monitor/mem-stresser/main.go | 29 +++ tests/rkt-monitor/sleeper/main.go | 25 ++ 11 files changed, 610 insertions(+) create mode 100644 tests/rkt-monitor/README.md create mode 100755 tests/rkt-monitor/build create mode 100755 tests/rkt-monitor/build-cpu-stresser.sh create mode 100755 tests/rkt-monitor/build-log-stresser.sh create mode 100755 tests/rkt-monitor/build-mem-stresser.sh create mode 100755 tests/rkt-monitor/build-too-many-apps.sh create mode 100644 tests/rkt-monitor/cpu-stresser/main.go create mode 100644 tests/rkt-monitor/log-stresser/main.go create mode 100644 tests/rkt-monitor/main.go create mode 100644 tests/rkt-monitor/mem-stresser/main.go create mode 100644 tests/rkt-monitor/sleeper/main.go diff --git a/tests/rkt-monitor/README.md b/tests/rkt-monitor/README.md new file mode 100644 index 0000000000..e600f5d746 --- /dev/null +++ b/tests/rkt-monitor/README.md @@ -0,0 +1,43 @@ +# rkt-monitor + +This is a small go utility intended to monitor the CPU and memory usage of rkt +and its children processes. This is accomplished by exec'ing rkt, reading proc +once a second for a specified duration, and printing the results. + +This utility has a handful of flags: + +``` +Usage: + rkt-monitor IMAGE [flags] + +Examples: +rkt-monitor mem-stresser.aci -v -d 30s + +Flags: + -d, --duration="10s": How long to run the ACI + -h, --help[=false]: help for rkt-monitor + -o, --show-output[=false]: Display rkt's stdout and stderr + -v, --verbose[=false]: Print current usage every second +``` + +Some acbuild scripts and golang source code is provided to build ACIs that +attempt to eat up resources in different ways. + +An example usage: + +``` +derek@rokot ~/go/src/github.com/coreos/rkt/tests/rkt-monitor> ./build-log-stresser.sh +Building worker... +Beginning build with an empty ACI +Setting name of ACI to appc.io/rkt-log-stresser +Copying host:worker-binary to aci:/worker +Setting exec command [/worker] +Writing ACI to log-stresser.aci +Ending the build +derek@rokot ~/go/src/github.com/coreos/rkt/tests/rkt-monitor> sudo ./rkt-monitor log-stresser.aci +[sudo] password for derek: +rkt(13261): seconds alive: 10 avg CPU: 33.113897% avg Mem: 4 kB peak Mem: 4 kB +systemd(13302): seconds alive: 9 avg CPU: 0.000000% avg Mem: 4 mB peak Mem: 4 mB +systemd-journal(13303): seconds alive: 9 avg CPU: 68.004584% avg Mem: 7 mB peak Mem: 7 mB +worker(13307): seconds alive: 9 avg CPU: 13.004088% avg Mem: 1 mB peak Mem: 1 mB +``` diff --git a/tests/rkt-monitor/build b/tests/rkt-monitor/build new file mode 100755 index 0000000000..5189fc5d44 --- /dev/null +++ b/tests/rkt-monitor/build @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +set -e + +export GOPATH=${PWD}/../../Godeps/_workspace + +eval $(go env) +export GOOS GOARCH + +go build -o rkt-monitor diff --git a/tests/rkt-monitor/build-cpu-stresser.sh b/tests/rkt-monitor/build-cpu-stresser.sh new file mode 100755 index 0000000000..a39a3d2d1d --- /dev/null +++ b/tests/rkt-monitor/build-cpu-stresser.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +set -e + +echo "Building worker..." +CGO_ENABLED=0 GOOS=linux go build -o worker-binary -a -tags netgo -ldflags '-w' ./cpu-stresser/main.go + +rmWorker() { rm worker-binary; } +acbuildEnd() { + rmWorker + export EXIT=$? + acbuild --debug end && exit $EXIT +} + +trap rmWorker EXIT + +acbuild --debug begin + +trap acbuildEnd EXIT + +acbuild --debug set-name appc.io/rkt-cpu-stresser + +acbuild --debug copy worker-binary /worker + +acbuild --debug set-exec -- /worker + +acbuild --debug write --overwrite cpu-stresser.aci diff --git a/tests/rkt-monitor/build-log-stresser.sh b/tests/rkt-monitor/build-log-stresser.sh new file mode 100755 index 0000000000..692d120052 --- /dev/null +++ b/tests/rkt-monitor/build-log-stresser.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +set -e + +echo "Building worker..." +CGO_ENABLED=0 GOOS=linux go build -o worker-binary -a -tags netgo -ldflags '-w' ./log-stresser/main.go + +rmWorker() { rm worker-binary; } +acbuildEnd() { + rmWorker + export EXIT=$? + acbuild --debug end && exit $EXIT +} + +trap rmWorker EXIT + +acbuild --debug begin + +trap acbuildEnd EXIT + +acbuild --debug set-name appc.io/rkt-log-stresser + +acbuild --debug copy worker-binary /worker + +acbuild --debug set-exec -- /worker + +acbuild --debug write --overwrite log-stresser.aci diff --git a/tests/rkt-monitor/build-mem-stresser.sh b/tests/rkt-monitor/build-mem-stresser.sh new file mode 100755 index 0000000000..fa1cfd4048 --- /dev/null +++ b/tests/rkt-monitor/build-mem-stresser.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +set -e + +echo "Building worker..." +CGO_ENABLED=0 GOOS=linux go build -o worker-binary -a -tags netgo -ldflags '-w' ./mem-stresser/main.go + +rmWorker() { rm worker-binary; } +acbuildEnd() { + rmWorker + export EXIT=$? + acbuild --debug end && exit $EXIT +} + +trap rmWorker EXIT + +acbuild --debug begin + +trap acbuildEnd EXIT + +acbuild --debug set-name appc.io/rkt-mem-stresser + +acbuild --debug copy worker-binary /worker + +acbuild --debug set-exec -- /worker + +acbuild --debug write --overwrite mem-stresser.aci diff --git a/tests/rkt-monitor/build-too-many-apps.sh b/tests/rkt-monitor/build-too-many-apps.sh new file mode 100755 index 0000000000..258d7ee51b --- /dev/null +++ b/tests/rkt-monitor/build-too-many-apps.sh @@ -0,0 +1,91 @@ +#!/usr/bin/env bash + +set -e + +NUM_APPS=100 + +# Build worker binary + +echo "Building worker binary" +CGO_ENABLED=0 GOOS=linux go build -o worker-binary -a -tags netgo -ldflags '-w' ./sleeper/main.go + +# Generate worker images + +rmWorker() { rm worker-binary; } +acbuildEnd() { + rmWorker + export EXIT=$? + acbuild --debug end && exit $EXIT +} +trap acbuildEnd EXIT + +mkdir -p ./too-many-apps-images + +for i in $(seq 1 ${NUM_APPS}); +do + NAME="worker-${i}" + + echo "Building image ${NAME}" + + acbuild begin + acbuild copy worker-binary /worker-binary + acbuild set-exec /worker-binary + acbuild set-name ${NAME} + acbuild write --overwrite too-many-apps-images/${NAME}.aci + acbuild end +done + +trap rmWorker EXIT + +# Generate pod manifest + +echo "Generating pod manifest" + +OUTPUT=${PWD}/too-many-apps.podmanifest + +cat <${OUTPUT} +{ + "acVersion": "0.7.4", + "acKind": "PodManifest", + "apps": [ +EOF + +appSection() { + SHA512=$(gunzip too-many-apps-images/${1}.aci --stdout|sha512sum) + SHA512="sha512-${SHA512:0:32}" + +cat <>$2 +{ + "name": "$1", + "image": { + "name": "$1", + "id": "$SHA512", + "labels": [ + { + "name": "arch", + "value": "amd64" + }, + { + "name": "os", + "value": "linux" + } + ] + }, + "app": { + "exec": [ "/worker-binary" ], + "group": "0", + "user": "0" + } +} +EOF +} + +appSection "worker-1" ${OUTPUT} +for i in $(seq 2 ${NUM_APPS}); +do + echo ',' >> ${OUTPUT} + appSection "worker-${i}" ${OUTPUT} +done + +echo ']}' >> ${OUTPUT} + diff --git a/tests/rkt-monitor/cpu-stresser/main.go b/tests/rkt-monitor/cpu-stresser/main.go new file mode 100644 index 0000000000..4874f5a888 --- /dev/null +++ b/tests/rkt-monitor/cpu-stresser/main.go @@ -0,0 +1,24 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +func main() { + for { + var x uint64 + for i := 0; i < 1000000000; i++ { + x += uint64(i) + } + } +} diff --git a/tests/rkt-monitor/log-stresser/main.go b/tests/rkt-monitor/log-stresser/main.go new file mode 100644 index 0000000000..af1ebc379d --- /dev/null +++ b/tests/rkt-monitor/log-stresser/main.go @@ -0,0 +1,26 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "fmt" + "time" +) + +func main() { + for { + fmt.Printf("%s\n", time.Now().Format("Mon Jan 2 15:04:05 -0700 MST 2006")) + } +} diff --git a/tests/rkt-monitor/main.go b/tests/rkt-monitor/main.go new file mode 100644 index 0000000000..300a1cbf29 --- /dev/null +++ b/tests/rkt-monitor/main.go @@ -0,0 +1,285 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "encoding/json" + "fmt" + "os" + "os/exec" + "os/signal" + "strconv" + "time" + + "github.com/appc/spec/schema" + "github.com/shirou/gopsutil/process" + "github.com/spf13/cobra" +) + +type ProcessStatus struct { + Pid int32 + Name string // Name of process + CPU float64 // Percent of CPU used since last check + VMS uint64 // Virtual memory size + RSS uint64 // Resident set size + Swap uint64 // Swap size +} + +var ( + pidMap map[int32]*process.Process + + flagVerbose bool + flagDuration string + flagShowOutput bool + + cmdRktMonitor = &cobra.Command{ + Use: "rkt-monitor IMAGE", + Short: "Runs the specified ACI or pod manifest with rkt, and monitors rkt's usage", + Example: "rkt-monitor mem-stresser.aci -v -d 30s", + Run: runRktMonitor, + } +) + +func init() { + pidMap = make(map[int32]*process.Process) + + cmdRktMonitor.Flags().BoolVarP(&flagVerbose, "verbose", "v", false, "Print current usage every second") + cmdRktMonitor.Flags().StringVarP(&flagDuration, "duration", "d", "10s", "How long to run the ACI") + cmdRktMonitor.Flags().BoolVarP(&flagShowOutput, "show-output", "o", false, "Display rkt's stdout and stderr") +} + +func main() { + cmdRktMonitor.Execute() +} + +func runRktMonitor(cmd *cobra.Command, args []string) { + if len(args) != 1 { + cmd.Usage() + os.Exit(1) + } + + d, err := time.ParseDuration(flagDuration) + if err != nil { + fmt.Printf("%v\n", err) + os.Exit(1) + } + + if os.Getuid() != 0 { + fmt.Printf("need to be root to run rkt images\n") + os.Exit(1) + } + + f, err := os.Open(args[0]) + if err != nil { + fmt.Printf("%v\n", err) + os.Exit(1) + } + decoder := json.NewDecoder(f) + + podManifest := false + man := schema.PodManifest{} + err = decoder.Decode(&man) + if err == nil { + podManifest = true + } + + var execCmd *exec.Cmd + if podManifest { + execCmd = exec.Command("rkt", "run", "--pod-manifest", args[0], "--net=host") + } else { + execCmd = exec.Command("rkt", "run", args[0], "--insecure-options=image", "--net=host") + } + if flagShowOutput { + execCmd.Stdout = os.Stdout + execCmd.Stderr = os.Stderr + } + err = execCmd.Start() + if err != nil { + fmt.Printf("%v\n", err) + os.Exit(1) + } + + c := make(chan os.Signal, 1) + signal.Notify(c, os.Interrupt) + go func() { + for _ = range c { + err := killAllChildren(int32(execCmd.Process.Pid)) + if err != nil { + fmt.Fprintf(os.Stderr, "cleanup failed: %v\n", err) + } + os.Exit(1) + } + }() + + usages := make(map[int32][]*ProcessStatus) + + timeToStop := time.Now().Add(d) + for time.Now().Before(timeToStop) { + usage, err := getUsage(int32(execCmd.Process.Pid)) + if err != nil { + panic(err) + } + if flagVerbose { + printUsage(usage) + } + + for _, ps := range usage { + usages[ps.Pid] = append(usages[ps.Pid], ps) + } + + _, err = process.NewProcess(int32(execCmd.Process.Pid)) + if err != nil { + // process.Process.IsRunning is not implemented yet + fmt.Fprintf(os.Stderr, "rkt exited prematurely\n") + break + } + + time.Sleep(time.Second) + } + + err = killAllChildren(int32(execCmd.Process.Pid)) + if err != nil { + fmt.Fprintf(os.Stderr, "cleanup failed: %v\n", err) + } + + for _, processHistory := range usages { + var avgCPU float64 + var avgMem uint64 + var peakMem uint64 + + for _, p := range processHistory { + avgCPU += p.CPU + avgMem += p.RSS + if peakMem < p.RSS { + peakMem = p.RSS + } + } + + avgCPU = avgCPU / float64(len(processHistory)) + avgMem = avgMem / uint64(len(processHistory)) + + fmt.Printf("%s(%d): seconds alive: %d avg CPU: %f%% avg Mem: %s peak Mem: %s\n", processHistory[0].Name, processHistory[0].Pid, len(processHistory), avgCPU, formatSize(avgMem), formatSize(peakMem)) + } +} + +func killAllChildren(pid int32) error { + p, err := process.NewProcess(pid) + if err != nil { + return err + } + processes := []*process.Process{p} + for i := 0; i < len(processes); i++ { + children, err := processes[i].Children() + if err != nil && err != process.ErrorNoChildren { + return err + } + processes = append(processes, children...) + } + for _, p := range processes { + osProcess, err := os.FindProcess(int(p.Pid)) + if err != nil { + if err.Error() == "os: process already finished" { + continue + } + return err + } + err = osProcess.Kill() + if err != nil { + return err + } + } + return nil +} + +func getUsage(pid int32) ([]*ProcessStatus, error) { + var statuses []*ProcessStatus + pids := []int32{pid} + for i := 0; i < len(pids); i++ { + proc, ok := pidMap[pids[i]] + if !ok { + var err error + proc, err = process.NewProcess(pids[i]) + if err != nil { + return nil, err + } + pidMap[pids[i]] = proc + } + s, err := getProcStatus(proc) + if err != nil { + return nil, err + } + statuses = append(statuses, s) + + children, err := proc.Children() + if err != nil && err != process.ErrorNoChildren { + return nil, err + } + + childloop: + for _, child := range children { + for _, p := range pids { + if p == child.Pid { + fmt.Printf("%d is in %#v\n", p, pids) + continue childloop + } + } + pids = append(pids, child.Pid) + } + } + return statuses, nil +} + +func getProcStatus(p *process.Process) (*ProcessStatus, error) { + n, err := p.Name() + if err != nil { + return nil, err + } + c, err := p.Percent(0) + if err != nil { + return nil, err + } + m, err := p.MemoryInfo() + if err != nil { + return nil, err + } + return &ProcessStatus{ + Pid: p.Pid, + Name: n, + CPU: c, + VMS: m.VMS, + RSS: m.RSS, + Swap: m.Swap, + }, nil +} + +func formatSize(size uint64) string { + if size > 1024*1024*1024 { + return strconv.FormatUint(size/(1024*1024*1024), 10) + " gB" + } + if size > 1024*1024 { + return strconv.FormatUint(size/(1024*1024), 10) + " mB" + } + if size > 1024 { + return strconv.FormatUint(size/1024, 10) + " kB" + } + return strconv.FormatUint(size, 10) + " B" +} + +func printUsage(statuses []*ProcessStatus) { + for _, s := range statuses { + fmt.Printf("%s(%d): Mem: %s CPU: %f\n", s.Name, s.Pid, formatSize(s.RSS), s.CPU) + } + fmt.Printf("\n") +} diff --git a/tests/rkt-monitor/mem-stresser/main.go b/tests/rkt-monitor/mem-stresser/main.go new file mode 100644 index 0000000000..32d3c06787 --- /dev/null +++ b/tests/rkt-monitor/mem-stresser/main.go @@ -0,0 +1,29 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "time" +) + +func main() { + var counter uint64 + var numbers []uint64 + for { + numbers = append(numbers, counter) + counter = counter + 1 + time.Sleep(time.Nanosecond) + } +} diff --git a/tests/rkt-monitor/sleeper/main.go b/tests/rkt-monitor/sleeper/main.go new file mode 100644 index 0000000000..4778638060 --- /dev/null +++ b/tests/rkt-monitor/sleeper/main.go @@ -0,0 +1,25 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "time" +) + +func main() { + for { + time.Sleep(time.Hour) + } +} From 6ecb35546616bf55be8b68cd9f10aac619341464 Mon Sep 17 00:00:00 2001 From: Derek Gonyeo Date: Wed, 20 Apr 2016 14:29:09 -0400 Subject: [PATCH 0143/1304] benchmarks: godeps for rkt-monitor Vendored the dependencies necessary for rkt-monitor. --- Godeps/Godeps.json | 48 + .../src/github.com/StackExchange/wmi/LICENSE | 20 + .../github.com/StackExchange/wmi/README.md | 4 + .../src/github.com/StackExchange/wmi/wmi.go | 416 +++ .../src/github.com/go-ole/go-ole/.travis.yml | 9 + .../src/github.com/go-ole/go-ole/ChangeLog.md | 49 + .../src/github.com/go-ole/go-ole/README.md | 46 + .../src/github.com/go-ole/go-ole/appveyor.yml | 63 + .../src/github.com/go-ole/go-ole/com.go | 329 ++ .../src/github.com/go-ole/go-ole/com_func.go | 174 ++ .../src/github.com/go-ole/go-ole/connect.go | 192 ++ .../src/github.com/go-ole/go-ole/constants.go | 153 + .../src/github.com/go-ole/go-ole/error.go | 51 + .../github.com/go-ole/go-ole/error_func.go | 8 + .../github.com/go-ole/go-ole/error_windows.go | 24 + .../src/github.com/go-ole/go-ole/guid.go | 118 + .../go-ole/go-ole/iconnectionpoint.go | 20 + .../go-ole/go-ole/iconnectionpoint_func.go | 21 + .../go-ole/go-ole/iconnectionpoint_windows.go | 43 + .../go-ole/iconnectionpointcontainer.go | 17 + .../go-ole/iconnectionpointcontainer_func.go | 11 + .../iconnectionpointcontainer_windows.go | 25 + .../src/github.com/go-ole/go-ole/idispatch.go | 94 + .../go-ole/go-ole/idispatch_func.go | 19 + .../go-ole/go-ole/idispatch_windows.go | 193 ++ .../github.com/go-ole/go-ole/ienumvariant.go | 19 + .../go-ole/go-ole/ienumvariant_func.go | 19 + .../go-ole/go-ole/ienumvariant_windows.go | 63 + .../github.com/go-ole/go-ole/iinspectable.go | 18 + .../go-ole/go-ole/iinspectable_func.go | 15 + .../go-ole/go-ole/iinspectable_windows.go | 72 + .../go-ole/go-ole/iprovideclassinfo.go | 21 + .../go-ole/go-ole/iprovideclassinfo_func.go | 7 + .../go-ole/iprovideclassinfo_windows.go | 21 + .../src/github.com/go-ole/go-ole/itypeinfo.go | 34 + .../go-ole/go-ole/itypeinfo_func.go | 7 + .../go-ole/go-ole/itypeinfo_windows.go | 21 + .../src/github.com/go-ole/go-ole/iunknown.go | 57 + .../github.com/go-ole/go-ole/iunknown_func.go | 19 + .../go-ole/go-ole/iunknown_windows.go | 58 + .../src/github.com/go-ole/go-ole/ole.go | 147 + .../go-ole/go-ole/oleutil/connection.go | 100 + .../go-ole/go-ole/oleutil/connection_func.go | 10 + .../go-ole/oleutil/connection_windows.go | 57 + .../go-ole/go-ole/oleutil/go-get.go | 6 + .../go-ole/go-ole/oleutil/oleutil.go | 89 + .../src/github.com/go-ole/go-ole/safearray.go | 27 + .../go-ole/go-ole/safearray_func.go | 211 ++ .../go-ole/go-ole/safearray_windows.go | 337 +++ .../go-ole/go-ole/safearrayconversion.go | 140 + .../go-ole/go-ole/safearrayslices.go | 33 + .../src/github.com/go-ole/go-ole/utility.go | 101 + .../src/github.com/go-ole/go-ole/variables.go | 16 + .../src/github.com/go-ole/go-ole/variant.go | 105 + .../github.com/go-ole/go-ole/variant_386.go | 11 + .../github.com/go-ole/go-ole/variant_amd64.go | 12 + .../src/github.com/go-ole/go-ole/vt_string.go | 58 + .../src/github.com/go-ole/go-ole/winrt.go | 99 + .../src/github.com/go-ole/go-ole/winrt_doc.go | 36 + .../src/github.com/shirou/gopsutil/LICENSE | 27 + .../src/github.com/shirou/gopsutil/cpu/cpu.go | 76 + .../shirou/gopsutil/cpu/cpu_darwin.go | 106 + .../shirou/gopsutil/cpu/cpu_darwin_cgo.go | 107 + .../shirou/gopsutil/cpu/cpu_darwin_nocgo.go | 14 + .../shirou/gopsutil/cpu/cpu_freebsd.go | 147 + .../shirou/gopsutil/cpu/cpu_linux.go | 244 ++ .../shirou/gopsutil/cpu/cpu_unix.go | 59 + .../shirou/gopsutil/cpu/cpu_windows.go | 105 + .../github.com/shirou/gopsutil/host/host.go | 38 + .../shirou/gopsutil/host/host_darwin.go | 152 + .../shirou/gopsutil/host/host_darwin_amd64.go | 19 + .../shirou/gopsutil/host/host_freebsd.go | 196 ++ .../gopsutil/host/host_freebsd_amd64.go | 41 + .../shirou/gopsutil/host/host_linux.go | 431 +++ .../shirou/gopsutil/host/host_linux_386.go | 44 + .../shirou/gopsutil/host/host_linux_amd64.go | 42 + .../shirou/gopsutil/host/host_linux_arm.go | 42 + .../shirou/gopsutil/host/host_windows.go | 135 + .../shirou/gopsutil/host/types_darwin.go | 17 + .../shirou/gopsutil/host/types_freebsd.go | 43 + .../shirou/gopsutil/host/types_linux.go | 45 + .../shirou/gopsutil/internal/common/binary.go | 634 ++++ .../shirou/gopsutil/internal/common/common.go | 279 ++ .../gopsutil/internal/common/common_darwin.go | 70 + .../internal/common/common_freebsd.go | 70 + .../gopsutil/internal/common/common_linux.go | 3 + .../gopsutil/internal/common/common_unix.go | 66 + .../internal/common/common_windows.go | 110 + .../src/github.com/shirou/gopsutil/mem/mem.go | 64 + .../shirou/gopsutil/mem/mem_darwin.go | 69 + .../shirou/gopsutil/mem/mem_darwin_cgo.go | 53 + .../shirou/gopsutil/mem/mem_darwin_nocgo.go | 88 + .../shirou/gopsutil/mem/mem_freebsd.go | 134 + .../shirou/gopsutil/mem/mem_linux.go | 100 + .../shirou/gopsutil/mem/mem_windows.go | 50 + .../src/github.com/shirou/gopsutil/net/net.go | 243 ++ .../shirou/gopsutil/net/net_darwin.go | 114 + .../shirou/gopsutil/net/net_freebsd.go | 108 + .../shirou/gopsutil/net/net_linux.go | 620 ++++ .../shirou/gopsutil/net/net_unix.go | 68 + .../shirou/gopsutil/net/net_windows.go | 116 + .../shirou/gopsutil/process/process.go | 167 ++ .../shirou/gopsutil/process/process_darwin.go | 451 +++ .../gopsutil/process/process_darwin_amd64.go | 234 ++ .../gopsutil/process/process_freebsd.go | 336 +++ .../gopsutil/process/process_freebsd_386.go | 141 + .../gopsutil/process/process_freebsd_amd64.go | 192 ++ .../shirou/gopsutil/process/process_linux.go | 767 +++++ .../gopsutil/process/process_linux_386.go | 9 + .../gopsutil/process/process_linux_amd64.go | 9 + .../gopsutil/process/process_linux_arm.go | 9 + .../shirou/gopsutil/process/process_posix.go | 117 + .../gopsutil/process/process_windows.go | 357 +++ .../shirou/gopsutil/process/types_darwin.go | 160 + .../shirou/gopsutil/process/types_freebsd.go | 95 + .../src/github.com/shirou/w32/AUTHORS | 16 + .../src/github.com/shirou/w32/LICENSE | 23 + .../src/github.com/shirou/w32/README.md | 33 + .../src/github.com/shirou/w32/advapi32.go | 299 ++ .../src/github.com/shirou/w32/comctl32.go | 109 + .../src/github.com/shirou/w32/comdlg32.go | 38 + .../src/github.com/shirou/w32/constants.go | 2661 +++++++++++++++++ .../src/github.com/shirou/w32/dwmapi.go | 254 ++ .../src/github.com/shirou/w32/gdi32.go | 509 ++++ .../src/github.com/shirou/w32/gdiplus.go | 175 ++ .../src/github.com/shirou/w32/idispatch.go | 43 + .../src/github.com/shirou/w32/istream.go | 31 + .../src/github.com/shirou/w32/iunknown.go | 27 + .../src/github.com/shirou/w32/kernel32.go | 314 ++ .../src/github.com/shirou/w32/ole32.go | 63 + .../src/github.com/shirou/w32/oleaut32.go | 48 + .../src/github.com/shirou/w32/opengl32.go | 72 + .../src/github.com/shirou/w32/psapi.go | 25 + .../src/github.com/shirou/w32/shell32.go | 153 + .../src/github.com/shirou/w32/typedef.go | 901 ++++++ .../src/github.com/shirou/w32/user32.go | 948 ++++++ .../src/github.com/shirou/w32/utils.go | 201 ++ .../src/github.com/shirou/w32/vars.go | 13 + 138 files changed, 19382 insertions(+) create mode 100644 Godeps/_workspace/src/github.com/StackExchange/wmi/LICENSE create mode 100644 Godeps/_workspace/src/github.com/StackExchange/wmi/README.md create mode 100644 Godeps/_workspace/src/github.com/StackExchange/wmi/wmi.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/.travis.yml create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/ChangeLog.md create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/README.md create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/appveyor.yml create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/com.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/com_func.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/connect.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/constants.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/error.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/error_func.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/error_windows.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/guid.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpoint.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpoint_func.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpoint_windows.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpointcontainer.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpointcontainer_func.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpointcontainer_windows.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/idispatch.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/idispatch_func.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/idispatch_windows.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/ienumvariant.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/ienumvariant_func.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/ienumvariant_windows.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iinspectable.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iinspectable_func.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iinspectable_windows.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iprovideclassinfo.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iprovideclassinfo_func.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iprovideclassinfo_windows.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/itypeinfo.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/itypeinfo_func.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/itypeinfo_windows.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iunknown.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iunknown_func.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iunknown_windows.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/ole.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/connection.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/connection_func.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/connection_windows.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/go-get.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/oleutil.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/safearray.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/safearray_func.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/safearray_windows.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/safearrayconversion.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/safearrayslices.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/utility.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/variables.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/variant.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/variant_386.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/variant_amd64.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/vt_string.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/winrt.go create mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/winrt_doc.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/LICENSE create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_darwin.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_darwin_cgo.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_darwin_nocgo.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_freebsd.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_linux.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_unix.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_windows.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/host/host.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_darwin.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_darwin_amd64.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_freebsd.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_freebsd_amd64.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_linux.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_linux_386.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_linux_amd64.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_linux_arm.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_windows.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/host/types_darwin.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/host/types_freebsd.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/host/types_linux.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/binary.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common_darwin.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common_freebsd.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common_linux.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common_unix.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common_windows.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_darwin.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_darwin_cgo.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_darwin_nocgo.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_freebsd.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_linux.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_windows.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/net/net.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/net/net_darwin.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/net/net_freebsd.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/net/net_linux.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/net/net_unix.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/net/net_windows.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/process.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_darwin.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_darwin_amd64.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_freebsd.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_freebsd_386.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_freebsd_amd64.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_linux.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_linux_386.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_linux_amd64.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_linux_arm.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_posix.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_windows.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/types_darwin.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/types_freebsd.go create mode 100644 Godeps/_workspace/src/github.com/shirou/w32/AUTHORS create mode 100644 Godeps/_workspace/src/github.com/shirou/w32/LICENSE create mode 100644 Godeps/_workspace/src/github.com/shirou/w32/README.md create mode 100644 Godeps/_workspace/src/github.com/shirou/w32/advapi32.go create mode 100644 Godeps/_workspace/src/github.com/shirou/w32/comctl32.go create mode 100644 Godeps/_workspace/src/github.com/shirou/w32/comdlg32.go create mode 100644 Godeps/_workspace/src/github.com/shirou/w32/constants.go create mode 100644 Godeps/_workspace/src/github.com/shirou/w32/dwmapi.go create mode 100644 Godeps/_workspace/src/github.com/shirou/w32/gdi32.go create mode 100644 Godeps/_workspace/src/github.com/shirou/w32/gdiplus.go create mode 100644 Godeps/_workspace/src/github.com/shirou/w32/idispatch.go create mode 100644 Godeps/_workspace/src/github.com/shirou/w32/istream.go create mode 100644 Godeps/_workspace/src/github.com/shirou/w32/iunknown.go create mode 100644 Godeps/_workspace/src/github.com/shirou/w32/kernel32.go create mode 100644 Godeps/_workspace/src/github.com/shirou/w32/ole32.go create mode 100644 Godeps/_workspace/src/github.com/shirou/w32/oleaut32.go create mode 100644 Godeps/_workspace/src/github.com/shirou/w32/opengl32.go create mode 100644 Godeps/_workspace/src/github.com/shirou/w32/psapi.go create mode 100644 Godeps/_workspace/src/github.com/shirou/w32/shell32.go create mode 100644 Godeps/_workspace/src/github.com/shirou/w32/typedef.go create mode 100644 Godeps/_workspace/src/github.com/shirou/w32/user32.go create mode 100644 Godeps/_workspace/src/github.com/shirou/w32/utils.go create mode 100644 Godeps/_workspace/src/github.com/shirou/w32/vars.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 403994f9ec..6bc5c2f33f 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -17,6 +17,10 @@ "github.com/golang/protobuf/protoc-gen-go" ], "Deps": [ + { + "ImportPath": "github.com/StackExchange/wmi", + "Rev": "f3e2bae1e0cb5aef83e319133eabfee30013a4a5" + }, { "ImportPath": "github.com/appc/cni/pkg/invoke", "Comment": "v0.2.0-rc0", @@ -340,6 +344,16 @@ "ImportPath": "github.com/dustin/go-humanize", "Rev": "c20a8bde38c8f5ba06f6600edf473705c96829d1" }, + { + "ImportPath": "github.com/go-ole/go-ole", + "Comment": "v1.2.0-10-g572eabb", + "Rev": "572eabb84c424e76a0d39d31510dd7dfd62f70b2" + }, + { + "ImportPath": "github.com/go-ole/go-ole/oleutil", + "Comment": "v1.2.0-10-g572eabb", + "Rev": "572eabb84c424e76a0d39d31510dd7dfd62f70b2" + }, { "ImportPath": "github.com/godbus/dbus", "Comment": "v3-6-ga1b8ba5", @@ -421,6 +435,40 @@ "Comment": "v1.4-2-g300106c", "Rev": "300106c228d52c8941d4b3de6054a6062a86dda3" }, + { + "ImportPath": "github.com/shirou/gopsutil/cpu", + "Comment": "v2.0.0-10-g9ef3410", + "Rev": "9ef341037b1bcadeeee79e77da4f6baf63de4feb" + }, + { + "ImportPath": "github.com/shirou/gopsutil/host", + "Comment": "v2.0.0-10-g9ef3410", + "Rev": "9ef341037b1bcadeeee79e77da4f6baf63de4feb" + }, + { + "ImportPath": "github.com/shirou/gopsutil/internal/common", + "Comment": "v2.0.0-10-g9ef3410", + "Rev": "9ef341037b1bcadeeee79e77da4f6baf63de4feb" + }, + { + "ImportPath": "github.com/shirou/gopsutil/mem", + "Comment": "v2.0.0-10-g9ef3410", + "Rev": "9ef341037b1bcadeeee79e77da4f6baf63de4feb" + }, + { + "ImportPath": "github.com/shirou/gopsutil/net", + "Comment": "v2.0.0-10-g9ef3410", + "Rev": "9ef341037b1bcadeeee79e77da4f6baf63de4feb" + }, + { + "ImportPath": "github.com/shirou/gopsutil/process", + "Comment": "v2.0.0-10-g9ef3410", + "Rev": "9ef341037b1bcadeeee79e77da4f6baf63de4feb" + }, + { + "ImportPath": "github.com/shirou/w32", + "Rev": "3c9377fc6748f222729a8270fe2775d149a249ad" + }, { "ImportPath": "github.com/shurcooL/sanitized_anchor_name", "Rev": "10ef21a441db47d8b13ebcc5fd2310f636973c77" diff --git a/Godeps/_workspace/src/github.com/StackExchange/wmi/LICENSE b/Godeps/_workspace/src/github.com/StackExchange/wmi/LICENSE new file mode 100644 index 0000000000..ae80b67209 --- /dev/null +++ b/Godeps/_workspace/src/github.com/StackExchange/wmi/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2013 Stack Exchange + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Godeps/_workspace/src/github.com/StackExchange/wmi/README.md b/Godeps/_workspace/src/github.com/StackExchange/wmi/README.md new file mode 100644 index 0000000000..3d5f67e149 --- /dev/null +++ b/Godeps/_workspace/src/github.com/StackExchange/wmi/README.md @@ -0,0 +1,4 @@ +wmi +=== + +Package wmi provides a WQL interface for WMI on Windows. diff --git a/Godeps/_workspace/src/github.com/StackExchange/wmi/wmi.go b/Godeps/_workspace/src/github.com/StackExchange/wmi/wmi.go new file mode 100644 index 0000000000..b931ca57af --- /dev/null +++ b/Godeps/_workspace/src/github.com/StackExchange/wmi/wmi.go @@ -0,0 +1,416 @@ +// +build windows + +/* +Package wmi provides a WQL interface for WMI on Windows. + +Example code to print names of running processes: + + type Win32_Process struct { + Name string + } + + func main() { + var dst []Win32_Process + q := wmi.CreateQuery(&dst, "") + err := wmi.Query(q, &dst) + if err != nil { + log.Fatal(err) + } + for i, v := range dst { + println(i, v.Name) + } + } + +*/ +package wmi + +import ( + "bytes" + "errors" + "fmt" + "log" + "os" + "reflect" + "runtime" + "strconv" + "strings" + "sync" + "time" + + "github.com/go-ole/go-ole" + "github.com/go-ole/go-ole/oleutil" +) + +var l = log.New(os.Stdout, "", log.LstdFlags) + +var ( + ErrInvalidEntityType = errors.New("wmi: invalid entity type") + lock sync.Mutex +) + +// QueryNamespace invokes Query with the given namespace on the local machine. +func QueryNamespace(query string, dst interface{}, namespace string) error { + return Query(query, dst, nil, namespace) +} + +// Query runs the WQL query and appends the values to dst. +// +// dst must have type *[]S or *[]*S, for some struct type S. Fields selected in +// the query must have the same name in dst. Supported types are all signed and +// unsigned integers, time.Time, string, bool, or a pointer to one of those. +// Array types are not supported. +// +// By default, the local machine and default namespace are used. These can be +// changed using connectServerArgs. See +// http://msdn.microsoft.com/en-us/library/aa393720.aspx for details. +// +// Query is a wrapper around DefaultClient.Query. +func Query(query string, dst interface{}, connectServerArgs ...interface{}) error { + return DefaultClient.Query(query, dst, connectServerArgs...) +} + +// A Client is an WMI query client. +// +// Its zero value (DefaultClient) is a usable client. +type Client struct { + // NonePtrZero specifies if nil values for fields which aren't pointers + // should be returned as the field types zero value. + // + // Setting this to true allows stucts without pointer fields to be used + // without the risk failure should a nil value returned from WMI. + NonePtrZero bool + + // PtrNil specifies if nil values for pointer fields should be returned + // as nil. + // + // Setting this to true will set pointer fields to nil where WMI + // returned nil, otherwise the types zero value will be returned. + PtrNil bool + + // AllowMissingFields specifies that struct fields not present in the + // query result should not result in an error. + // + // Setting this to true allows custom queries to be used with full + // struct definitions instead of having to define multiple structs. + AllowMissingFields bool +} + +// DefaultClient is the default Client and is used by Query, QueryNamespace +var DefaultClient = &Client{} + +// Query runs the WQL query and appends the values to dst. +// +// dst must have type *[]S or *[]*S, for some struct type S. Fields selected in +// the query must have the same name in dst. Supported types are all signed and +// unsigned integers, time.Time, string, bool, or a pointer to one of those. +// Array types are not supported. +// +// By default, the local machine and default namespace are used. These can be +// changed using connectServerArgs. See +// http://msdn.microsoft.com/en-us/library/aa393720.aspx for details. +func (c *Client) Query(query string, dst interface{}, connectServerArgs ...interface{}) error { + dv := reflect.ValueOf(dst) + if dv.Kind() != reflect.Ptr || dv.IsNil() { + return ErrInvalidEntityType + } + dv = dv.Elem() + mat, elemType := checkMultiArg(dv) + if mat == multiArgTypeInvalid { + return ErrInvalidEntityType + } + + lock.Lock() + defer lock.Unlock() + runtime.LockOSThread() + defer runtime.UnlockOSThread() + + err := ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED) + if err != nil { + oleerr := err.(*ole.OleError) + // S_FALSE = 0x00000001 // CoInitializeEx was already called on this thread + if oleerr.Code() != ole.S_OK && oleerr.Code() != 0x00000001 { + return err + } + } else { + // Only invoke CoUninitialize if the thread was not initizlied before. + // This will allow other go packages based on go-ole play along + // with this library. + defer ole.CoUninitialize() + } + + unknown, err := oleutil.CreateObject("WbemScripting.SWbemLocator") + if err != nil { + return err + } + defer unknown.Release() + + wmi, err := unknown.QueryInterface(ole.IID_IDispatch) + if err != nil { + return err + } + defer wmi.Release() + + // service is a SWbemServices + serviceRaw, err := oleutil.CallMethod(wmi, "ConnectServer", connectServerArgs...) + if err != nil { + return err + } + service := serviceRaw.ToIDispatch() + defer serviceRaw.Clear() + + // result is a SWBemObjectSet + resultRaw, err := oleutil.CallMethod(service, "ExecQuery", query) + if err != nil { + return err + } + result := resultRaw.ToIDispatch() + defer resultRaw.Clear() + + count, err := oleInt64(result, "Count") + if err != nil { + return err + } + + // Initialize a slice with Count capacity + dv.Set(reflect.MakeSlice(dv.Type(), 0, int(count))) + + var errFieldMismatch error + for i := int64(0); i < count; i++ { + err := func() error { + // item is a SWbemObject, but really a Win32_Process + itemRaw, err := oleutil.CallMethod(result, "ItemIndex", i) + if err != nil { + return err + } + item := itemRaw.ToIDispatch() + defer itemRaw.Clear() + + ev := reflect.New(elemType) + if err = c.loadEntity(ev.Interface(), item); err != nil { + if _, ok := err.(*ErrFieldMismatch); ok { + // We continue loading entities even in the face of field mismatch errors. + // If we encounter any other error, that other error is returned. Otherwise, + // an ErrFieldMismatch is returned. + errFieldMismatch = err + } else { + return err + } + } + if mat != multiArgTypeStructPtr { + ev = ev.Elem() + } + dv.Set(reflect.Append(dv, ev)) + return nil + }() + if err != nil { + return err + } + } + return errFieldMismatch +} + +// ErrFieldMismatch is returned when a field is to be loaded into a different +// type than the one it was stored from, or when a field is missing or +// unexported in the destination struct. +// StructType is the type of the struct pointed to by the destination argument. +type ErrFieldMismatch struct { + StructType reflect.Type + FieldName string + Reason string +} + +func (e *ErrFieldMismatch) Error() string { + return fmt.Sprintf("wmi: cannot load field %q into a %q: %s", + e.FieldName, e.StructType, e.Reason) +} + +var timeType = reflect.TypeOf(time.Time{}) + +// loadEntity loads a SWbemObject into a struct pointer. +func (c *Client) loadEntity(dst interface{}, src *ole.IDispatch) (errFieldMismatch error) { + v := reflect.ValueOf(dst).Elem() + for i := 0; i < v.NumField(); i++ { + f := v.Field(i) + of := f + isPtr := f.Kind() == reflect.Ptr + if isPtr { + ptr := reflect.New(f.Type().Elem()) + f.Set(ptr) + f = f.Elem() + } + n := v.Type().Field(i).Name + if !f.CanSet() { + return &ErrFieldMismatch{ + StructType: of.Type(), + FieldName: n, + Reason: "CanSet() is false", + } + } + prop, err := oleutil.GetProperty(src, n) + if err != nil { + if !c.AllowMissingFields { + errFieldMismatch = &ErrFieldMismatch{ + StructType: of.Type(), + FieldName: n, + Reason: "no such struct field", + } + } + continue + } + defer prop.Clear() + + switch val := prop.Value().(type) { + case int8, int16, int32, int64, int: + v := reflect.ValueOf(val).Int() + switch f.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + f.SetInt(v) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + f.SetUint(uint64(v)) + default: + return &ErrFieldMismatch{ + StructType: of.Type(), + FieldName: n, + Reason: "not an integer class", + } + } + case uint8, uint16, uint32, uint64: + v := reflect.ValueOf(val).Uint() + switch f.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + f.SetInt(int64(v)) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + f.SetUint(v) + default: + return &ErrFieldMismatch{ + StructType: of.Type(), + FieldName: n, + Reason: "not an integer class", + } + } + case string: + switch f.Kind() { + case reflect.String: + f.SetString(val) + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + iv, err := strconv.ParseInt(val, 10, 64) + if err != nil { + return err + } + f.SetInt(iv) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + uv, err := strconv.ParseUint(val, 10, 64) + if err != nil { + return err + } + f.SetUint(uv) + case reflect.Struct: + switch f.Type() { + case timeType: + if len(val) == 25 { + mins, err := strconv.Atoi(val[22:]) + if err != nil { + return err + } + val = val[:22] + fmt.Sprintf("%02d%02d", mins/60, mins%60) + } + t, err := time.Parse("20060102150405.000000-0700", val) + if err != nil { + return err + } + f.Set(reflect.ValueOf(t)) + } + } + case bool: + switch f.Kind() { + case reflect.Bool: + f.SetBool(val) + default: + return &ErrFieldMismatch{ + StructType: of.Type(), + FieldName: n, + Reason: "not a bool", + } + } + default: + typeof := reflect.TypeOf(val) + if typeof == nil && (isPtr || c.NonePtrZero) { + if (isPtr && c.PtrNil) || (!isPtr && c.NonePtrZero) { + of.Set(reflect.Zero(of.Type())) + } + break + } + return &ErrFieldMismatch{ + StructType: of.Type(), + FieldName: n, + Reason: fmt.Sprintf("unsupported type (%T)", val), + } + } + } + return errFieldMismatch +} + +type multiArgType int + +const ( + multiArgTypeInvalid multiArgType = iota + multiArgTypeStruct + multiArgTypeStructPtr +) + +// checkMultiArg checks that v has type []S, []*S for some struct type S. +// +// It returns what category the slice's elements are, and the reflect.Type +// that represents S. +func checkMultiArg(v reflect.Value) (m multiArgType, elemType reflect.Type) { + if v.Kind() != reflect.Slice { + return multiArgTypeInvalid, nil + } + elemType = v.Type().Elem() + switch elemType.Kind() { + case reflect.Struct: + return multiArgTypeStruct, elemType + case reflect.Ptr: + elemType = elemType.Elem() + if elemType.Kind() == reflect.Struct { + return multiArgTypeStructPtr, elemType + } + } + return multiArgTypeInvalid, nil +} + +func oleInt64(item *ole.IDispatch, prop string) (int64, error) { + v, err := oleutil.GetProperty(item, prop) + if err != nil { + return 0, err + } + defer v.Clear() + + i := int64(v.Val) + return i, nil +} + +// CreateQuery returns a WQL query string that queries all columns of src. where +// is an optional string that is appended to the query, to be used with WHERE +// clauses. In such a case, the "WHERE" string should appear at the beginning. +func CreateQuery(src interface{}, where string) string { + var b bytes.Buffer + b.WriteString("SELECT ") + s := reflect.Indirect(reflect.ValueOf(src)) + t := s.Type() + if s.Kind() == reflect.Slice { + t = t.Elem() + } + if t.Kind() != reflect.Struct { + return "" + } + var fields []string + for i := 0; i < t.NumField(); i++ { + fields = append(fields, t.Field(i).Name) + } + b.WriteString(strings.Join(fields, ", ")) + b.WriteString(" FROM ") + b.WriteString(t.Name()) + b.WriteString(" " + where) + return b.String() +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/.travis.yml b/Godeps/_workspace/src/github.com/go-ole/go-ole/.travis.yml new file mode 100644 index 0000000000..0c2c02bdf2 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/.travis.yml @@ -0,0 +1,9 @@ +language: go +sudo: false + +go: + - 1.1 + - 1.2 + - 1.3 + - 1.4 + - tip diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/ChangeLog.md b/Godeps/_workspace/src/github.com/go-ole/go-ole/ChangeLog.md new file mode 100644 index 0000000000..4ba6a8c64d --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/ChangeLog.md @@ -0,0 +1,49 @@ +# Version 1.x.x + +* **Add more test cases and reference new test COM server project.** (Placeholder for future additions) + +# Version 1.2.0-alphaX + +**Minimum supported version is now Go 1.4. Go 1.1 support is deprecated, but should still build.** + + * Added CI configuration for Travis-CI and AppVeyor. + * Added test InterfaceID and ClassID for the COM Test Server project. + * Added more inline documentation (#83). + * Added IEnumVARIANT implementation (#88). + * Added IEnumVARIANT test cases (#99, #100, #101). + * Added support for retrieving `time.Time` from VARIANT (#92). + * Added test case for IUnknown (#64). + * Added test case for IDispatch (#64). + * Added test cases for scalar variants (#64, #76). + +# Version 1.1.1 + + * Fixes for Linux build. + * Fixes for Windows build. + +# Version 1.1.0 + +The change to provide building on all platforms is a new feature. The increase in minor version reflects that and allows those who wish to stay on 1.0.x to continue to do so. Support for 1.0.x will be limited to bug fixes. + + * Move GUID out of variables.go into its own file to make new documentation available. + * Move OleError out of ole.go into its own file to make new documentation available. + * Add documentation to utility functions. + * Add documentation to variant receiver functions. + * Add documentation to ole structures. + * Make variant available to other systems outside of Windows. + * Make OLE structures available to other systems outside of Windows. + +## New Features + + * Library should now be built on all platforms supported by Go. Library will NOOP on any platform that is not Windows. + * More functions are now documented and available on godoc.org. + +# Version 1.0.1 + + 1. Fix package references from repository location change. + +# Version 1.0.0 + +This version is stable enough for use. The COM API is still incomplete, but provides enough functionality for accessing COM servers using IDispatch interface. + +There is no changelog for this version. Check commits for history. diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/README.md b/Godeps/_workspace/src/github.com/go-ole/go-ole/README.md new file mode 100644 index 0000000000..0ea9db33c7 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/README.md @@ -0,0 +1,46 @@ +#Go OLE + +[![Build status](https://ci.appveyor.com/api/projects/status/qr0u2sf7q43us9fj?svg=true)](https://ci.appveyor.com/project/jacobsantos/go-ole-jgs28) +[![Build Status](https://travis-ci.org/go-ole/go-ole.svg?branch=master)](https://travis-ci.org/go-ole/go-ole) +[![GoDoc](https://godoc.org/github.com/go-ole/go-ole?status.svg)](https://godoc.org/github.com/go-ole/go-ole) + +Go bindings for Windows COM using shared libraries instead of cgo. + +By Yasuhiro Matsumoto. + +## Install + +To experiment with go-ole, you can just compile and run the example program: + +``` +go get github.com/go-ole/go-ole +cd /path/to/go-ole/ +go test + +cd /path/to/go-ole/example/excel +go run excel.go +``` + +## Continuous Integration + +Continuous integration configuration has been added for both Travis-CI and AppVeyor. You will have to add these to your own account for your fork in order for it to run. + +**Travis-CI** + +Travis-CI was added to check builds on Linux to ensure that `go get` works when cross building. Currently, Travis-CI is not used to test cross-building, but this may be changed in the future. It is also not currently possible to test the library on Linux, since COM API is specific to Windows and it is not currently possible to run a COM server on Linux or even connect to a remote COM server. + +**AppVeyor** + +AppVeyor is used to build on Windows using the (in-development) test COM server. It is currently only used to test the build and ensure that the code works on Windows. It will be used to register a COM server and then run the test cases based on the test COM server. + +The tests currently do run and do pass and this should be maintained with commits. + +##Versioning + +Go OLE uses [semantic versioning](http://semver.org) for version numbers, which is similar to the version contract of the Go language. Which means that the major version will always maintain backwards compatibility with minor versions. Minor versions will only add new additions and changes. Fixes will always be in patch. + +This contract should allow you to upgrade to new minor and patch versions without breakage or modifications to your existing code. Leave a ticket, if there is breakage, so that it could be fixed. + +##LICENSE + +Under the MIT License: http://mattn.mit-license.org/2013 diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/appveyor.yml b/Godeps/_workspace/src/github.com/go-ole/go-ole/appveyor.yml new file mode 100644 index 0000000000..e66dd31a1d --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/appveyor.yml @@ -0,0 +1,63 @@ +# Notes: +# - Minimal appveyor.yml file is an empty file. All sections are optional. +# - Indent each level of configuration with 2 spaces. Do not use tabs! +# - All section names are case-sensitive. +# - Section names should be unique on each level. + +version: "1.3.0.{build}-alpha-{branch}" + +os: Windows Server 2012 R2 + +branches: + only: + - master + - v1.2 + - v1.1 + - v1.0 + +skip_tags: true + +clone_folder: c:\gopath\src\github.com\go-ole\go-ole + +environment: + GOPATH: c:\gopath + matrix: + - GOARCH: amd64 + GOVERSION: 1.4 + GOROOT: c:\go + DOWNLOADPLATFORM: "x64" + +install: + - choco install mingw + - SET PATH=c:\tools\mingw64\bin;%PATH% + # - Download COM Server + - ps: Start-FileDownload "https://github.com/go-ole/test-com-server/releases/download/v1.0.2/test-com-server-${env:DOWNLOADPLATFORM}.zip" + - 7z e test-com-server-%DOWNLOADPLATFORM%.zip -oc:\gopath\src\github.com\go-ole\go-ole > NUL + - c:\gopath\src\github.com\go-ole\go-ole\build\register-assembly.bat + # - set + - go version + - go env + - c:\gopath\src\github.com\go-ole\go-ole\build\compile-go.bat + - go tool dist install -v cmd/8a + - go tool dist install -v cmd/8c + - go tool dist install -v cmd/8g + - go tool dist install -v cmd/8l + - go tool dist install -v cmd/6a + - go tool dist install -v cmd/6c + - go tool dist install -v cmd/6g + - go tool dist install -v cmd/6l + - go get -u golang.org/x/tools/cmd/cover + - go get -u golang.org/x/tools/cmd/godoc + - go get -u golang.org/x/tools/cmd/stringer + +build_script: + - cd c:\gopath\src\github.com\go-ole\go-ole + - go get -v -t ./... + - go build + - go test -v -cover ./... + +# disable automatic tests +test: off + +# disable deployment +deploy: off diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/com.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/com.go new file mode 100644 index 0000000000..f224fa069a --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/com.go @@ -0,0 +1,329 @@ +// +build windows + +package ole + +import ( + "errors" + "syscall" + "time" + "unicode/utf16" + "unsafe" +) + +var ( + procCoInitialize, _ = modole32.FindProc("CoInitialize") + procCoInitializeEx, _ = modole32.FindProc("CoInitializeEx") + procCoUninitialize, _ = modole32.FindProc("CoUninitialize") + procCoCreateInstance, _ = modole32.FindProc("CoCreateInstance") + procCoTaskMemFree, _ = modole32.FindProc("CoTaskMemFree") + procCLSIDFromProgID, _ = modole32.FindProc("CLSIDFromProgID") + procCLSIDFromString, _ = modole32.FindProc("CLSIDFromString") + procStringFromCLSID, _ = modole32.FindProc("StringFromCLSID") + procStringFromIID, _ = modole32.FindProc("StringFromIID") + procIIDFromString, _ = modole32.FindProc("IIDFromString") + procGetUserDefaultLCID, _ = modkernel32.FindProc("GetUserDefaultLCID") + procCopyMemory, _ = modkernel32.FindProc("RtlMoveMemory") + procVariantInit, _ = modoleaut32.FindProc("VariantInit") + procVariantClear, _ = modoleaut32.FindProc("VariantClear") + procVariantTimeToSystemTime, _ = modoleaut32.FindProc("VariantTimeToSystemTime") + procSysAllocString, _ = modoleaut32.FindProc("SysAllocString") + procSysAllocStringLen, _ = modoleaut32.FindProc("SysAllocStringLen") + procSysFreeString, _ = modoleaut32.FindProc("SysFreeString") + procSysStringLen, _ = modoleaut32.FindProc("SysStringLen") + procCreateDispTypeInfo, _ = modoleaut32.FindProc("CreateDispTypeInfo") + procCreateStdDispatch, _ = modoleaut32.FindProc("CreateStdDispatch") + procGetActiveObject, _ = modoleaut32.FindProc("GetActiveObject") + + procGetMessageW, _ = moduser32.FindProc("GetMessageW") + procDispatchMessageW, _ = moduser32.FindProc("DispatchMessageW") +) + +// coInitialize initializes COM library on current thread. +// +// MSDN documentation suggests that this function should not be called. Call +// CoInitializeEx() instead. The reason has to do with threading and this +// function is only for single-threaded apartments. +// +// That said, most users of the library have gotten away with just this +// function. If you are experiencing threading issues, then use +// CoInitializeEx(). +func coInitialize() (err error) { + // http://msdn.microsoft.com/en-us/library/windows/desktop/ms678543(v=vs.85).aspx + // Suggests that no value should be passed to CoInitialized. + // Could just be Call() since the parameter is optional. <-- Needs testing to be sure. + hr, _, _ := procCoInitialize.Call(uintptr(0)) + if hr != 0 { + err = NewError(hr) + } + return +} + +// coInitializeEx initializes COM library with concurrency model. +func coInitializeEx(coinit uint32) (err error) { + // http://msdn.microsoft.com/en-us/library/windows/desktop/ms695279(v=vs.85).aspx + // Suggests that the first parameter is not only optional but should always be NULL. + hr, _, _ := procCoInitializeEx.Call(uintptr(0), uintptr(coinit)) + if hr != 0 { + err = NewError(hr) + } + return +} + +// CoInitialize initializes COM library on current thread. +// +// MSDN documentation suggests that this function should not be called. Call +// CoInitializeEx() instead. The reason has to do with threading and this +// function is only for single-threaded apartments. +// +// That said, most users of the library have gotten away with just this +// function. If you are experiencing threading issues, then use +// CoInitializeEx(). +func CoInitialize(p uintptr) (err error) { + // p is ignored and won't be used. + // Avoid any variable not used errors. + p = uintptr(0) + return coInitialize() +} + +// CoInitializeEx initializes COM library with concurrency model. +func CoInitializeEx(p uintptr, coinit uint32) (err error) { + // Avoid any variable not used errors. + p = uintptr(0) + return coInitializeEx(coinit) +} + +// CoUninitialize uninitializes COM Library. +func CoUninitialize() { + procCoUninitialize.Call() +} + +// CoTaskMemFree frees memory pointer. +func CoTaskMemFree(memptr uintptr) { + procCoTaskMemFree.Call(memptr) +} + +// CLSIDFromProgID retrieves Class Identifier with the given Program Identifier. +// +// The Programmatic Identifier must be registered, because it will be looked up +// in the Windows Registry. The registry entry has the following keys: CLSID, +// Insertable, Protocol and Shell +// (https://msdn.microsoft.com/en-us/library/dd542719(v=vs.85).aspx). +// +// programID identifies the class id with less precision and is not guaranteed +// to be unique. These are usually found in the registry under +// HKEY_LOCAL_MACHINE\SOFTWARE\Classes, usually with the format of +// "Program.Component.Version" with version being optional. +// +// CLSIDFromProgID in Windows API. +func CLSIDFromProgID(progId string) (clsid *GUID, err error) { + var guid GUID + lpszProgID := uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(progId))) + hr, _, _ := procCLSIDFromProgID.Call(lpszProgID, uintptr(unsafe.Pointer(&guid))) + if hr != 0 { + err = NewError(hr) + } + clsid = &guid + return +} + +// CLSIDFromString retrieves Class ID from string representation. +// +// This is technically the string version of the GUID and will convert the +// string to object. +// +// CLSIDFromString in Windows API. +func CLSIDFromString(str string) (clsid *GUID, err error) { + var guid GUID + lpsz := uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(str))) + hr, _, _ := procCLSIDFromString.Call(lpsz, uintptr(unsafe.Pointer(&guid))) + if hr != 0 { + err = NewError(hr) + } + clsid = &guid + return +} + +// StringFromCLSID returns GUID formated string from GUID object. +func StringFromCLSID(clsid *GUID) (str string, err error) { + var p *uint16 + hr, _, _ := procStringFromCLSID.Call(uintptr(unsafe.Pointer(clsid)), uintptr(unsafe.Pointer(&p))) + if hr != 0 { + err = NewError(hr) + } + str = LpOleStrToString(p) + return +} + +// IIDFromString returns GUID from program ID. +func IIDFromString(progId string) (clsid *GUID, err error) { + var guid GUID + lpsz := uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(progId))) + hr, _, _ := procIIDFromString.Call(lpsz, uintptr(unsafe.Pointer(&guid))) + if hr != 0 { + err = NewError(hr) + } + clsid = &guid + return +} + +// StringFromIID returns GUID formatted string from GUID object. +func StringFromIID(iid *GUID) (str string, err error) { + var p *uint16 + hr, _, _ := procStringFromIID.Call(uintptr(unsafe.Pointer(iid)), uintptr(unsafe.Pointer(&p))) + if hr != 0 { + err = NewError(hr) + } + str = LpOleStrToString(p) + return +} + +// CreateInstance of single uninitialized object with GUID. +func CreateInstance(clsid *GUID, iid *GUID) (unk *IUnknown, err error) { + if iid == nil { + iid = IID_IUnknown + } + hr, _, _ := procCoCreateInstance.Call( + uintptr(unsafe.Pointer(clsid)), + 0, + CLSCTX_SERVER, + uintptr(unsafe.Pointer(iid)), + uintptr(unsafe.Pointer(&unk))) + if hr != 0 { + err = NewError(hr) + } + return +} + +// GetActiveObject retrieves pointer to active object. +func GetActiveObject(clsid *GUID, iid *GUID) (unk *IUnknown, err error) { + if iid == nil { + iid = IID_IUnknown + } + hr, _, _ := procGetActiveObject.Call( + uintptr(unsafe.Pointer(clsid)), + uintptr(unsafe.Pointer(iid)), + uintptr(unsafe.Pointer(&unk))) + if hr != 0 { + err = NewError(hr) + } + return +} + +// VariantInit initializes variant. +func VariantInit(v *VARIANT) (err error) { + hr, _, _ := procVariantInit.Call(uintptr(unsafe.Pointer(v))) + if hr != 0 { + err = NewError(hr) + } + return +} + +// VariantClear clears value in Variant settings to VT_EMPTY. +func VariantClear(v *VARIANT) (err error) { + hr, _, _ := procVariantClear.Call(uintptr(unsafe.Pointer(v))) + if hr != 0 { + err = NewError(hr) + } + return +} + +// SysAllocString allocates memory for string and copies string into memory. +func SysAllocString(v string) (ss *int16) { + pss, _, _ := procSysAllocString.Call(uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(v)))) + ss = (*int16)(unsafe.Pointer(pss)) + return +} + +// SysAllocStringLen copies up to length of given string returning pointer. +func SysAllocStringLen(v string) (ss *int16) { + utf16 := utf16.Encode([]rune(v + "\x00")) + ptr := &utf16[0] + + pss, _, _ := procSysAllocStringLen.Call(uintptr(unsafe.Pointer(ptr)), uintptr(len(utf16)-1)) + ss = (*int16)(unsafe.Pointer(pss)) + return +} + +// SysFreeString frees string system memory. This must be called with SysAllocString. +func SysFreeString(v *int16) (err error) { + hr, _, _ := procSysFreeString.Call(uintptr(unsafe.Pointer(v))) + if hr != 0 { + err = NewError(hr) + } + return +} + +// SysStringLen is the length of the system allocated string. +func SysStringLen(v *int16) uint32 { + l, _, _ := procSysStringLen.Call(uintptr(unsafe.Pointer(v))) + return uint32(l) +} + +// CreateStdDispatch provides default IDispatch implementation for IUnknown. +// +// This handles default IDispatch implementation for objects. It haves a few +// limitations with only supporting one language. It will also only return +// default exception codes. +func CreateStdDispatch(unk *IUnknown, v uintptr, ptinfo *IUnknown) (disp *IDispatch, err error) { + hr, _, _ := procCreateStdDispatch.Call( + uintptr(unsafe.Pointer(unk)), + v, + uintptr(unsafe.Pointer(ptinfo)), + uintptr(unsafe.Pointer(&disp))) + if hr != 0 { + err = NewError(hr) + } + return +} + +// CreateDispTypeInfo provides default ITypeInfo implementation for IDispatch. +// +// This will not handle the full implementation of the interface. +func CreateDispTypeInfo(idata *INTERFACEDATA) (pptinfo *IUnknown, err error) { + hr, _, _ := procCreateDispTypeInfo.Call( + uintptr(unsafe.Pointer(idata)), + uintptr(GetUserDefaultLCID()), + uintptr(unsafe.Pointer(&pptinfo))) + if hr != 0 { + err = NewError(hr) + } + return +} + +// copyMemory moves location of a block of memory. +func copyMemory(dest unsafe.Pointer, src unsafe.Pointer, length uint32) { + procCopyMemory.Call(uintptr(dest), uintptr(src), uintptr(length)) +} + +// GetUserDefaultLCID retrieves current user default locale. +func GetUserDefaultLCID() (lcid uint32) { + ret, _, _ := procGetUserDefaultLCID.Call() + lcid = uint32(ret) + return +} + +// GetMessage in message queue from runtime. +// +// This function appears to block. PeekMessage does not block. +func GetMessage(msg *Msg, hwnd uint32, MsgFilterMin uint32, MsgFilterMax uint32) (ret int32, err error) { + r0, _, err := procGetMessageW.Call(uintptr(unsafe.Pointer(msg)), uintptr(hwnd), uintptr(MsgFilterMin), uintptr(MsgFilterMax)) + ret = int32(r0) + return +} + +// DispatchMessage to window procedure. +func DispatchMessage(msg *Msg) (ret int32) { + r0, _, _ := procDispatchMessageW.Call(uintptr(unsafe.Pointer(msg))) + ret = int32(r0) + return +} + +// GetVariantDate converts COM Variant Time value to Go time.Time. +func GetVariantDate(value float64) (time.Time, error) { + var st syscall.Systemtime + r, _, _ := procVariantTimeToSystemTime.Call(uintptr(unsafe.Pointer(&value)), uintptr(unsafe.Pointer(&st))) + if r != 0 { + return time.Date(int(st.Year), time.Month(st.Month), int(st.Day), int(st.Hour), int(st.Minute), int(st.Second), int(st.Milliseconds/1000), nil), nil + } + return time.Now(), errors.New("Could not convert to time, passing current time.") +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/com_func.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/com_func.go new file mode 100644 index 0000000000..425aad3233 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/com_func.go @@ -0,0 +1,174 @@ +// +build !windows + +package ole + +import ( + "time" + "unsafe" +) + +// coInitialize initializes COM library on current thread. +// +// MSDN documentation suggests that this function should not be called. Call +// CoInitializeEx() instead. The reason has to do with threading and this +// function is only for single-threaded apartments. +// +// That said, most users of the library have gotten away with just this +// function. If you are experiencing threading issues, then use +// CoInitializeEx(). +func coInitialize() error { + return NewError(E_NOTIMPL) +} + +// coInitializeEx initializes COM library with concurrency model. +func coInitializeEx(coinit uint32) error { + return NewError(E_NOTIMPL) +} + +// CoInitialize initializes COM library on current thread. +// +// MSDN documentation suggests that this function should not be called. Call +// CoInitializeEx() instead. The reason has to do with threading and this +// function is only for single-threaded apartments. +// +// That said, most users of the library have gotten away with just this +// function. If you are experiencing threading issues, then use +// CoInitializeEx(). +func CoInitialize(p uintptr) error { + return NewError(E_NOTIMPL) +} + +// CoInitializeEx initializes COM library with concurrency model. +func CoInitializeEx(p uintptr, coinit uint32) error { + return NewError(E_NOTIMPL) +} + +// CoUninitialize uninitializes COM Library. +func CoUninitialize() {} + +// CoTaskMemFree frees memory pointer. +func CoTaskMemFree(memptr uintptr) {} + +// CLSIDFromProgID retrieves Class Identifier with the given Program Identifier. +// +// The Programmatic Identifier must be registered, because it will be looked up +// in the Windows Registry. The registry entry has the following keys: CLSID, +// Insertable, Protocol and Shell +// (https://msdn.microsoft.com/en-us/library/dd542719(v=vs.85).aspx). +// +// programID identifies the class id with less precision and is not guaranteed +// to be unique. These are usually found in the registry under +// HKEY_LOCAL_MACHINE\SOFTWARE\Classes, usually with the format of +// "Program.Component.Version" with version being optional. +// +// CLSIDFromProgID in Windows API. +func CLSIDFromProgID(progId string) (*GUID, error) { + return nil, NewError(E_NOTIMPL) +} + +// CLSIDFromString retrieves Class ID from string representation. +// +// This is technically the string version of the GUID and will convert the +// string to object. +// +// CLSIDFromString in Windows API. +func CLSIDFromString(str string) (*GUID, error) { + return nil, NewError(E_NOTIMPL) +} + +// StringFromCLSID returns GUID formated string from GUID object. +func StringFromCLSID(clsid *GUID) (string, error) { + return "", NewError(E_NOTIMPL) +} + +// IIDFromString returns GUID from program ID. +func IIDFromString(progId string) (*GUID, error) { + return nil, NewError(E_NOTIMPL) +} + +// StringFromIID returns GUID formatted string from GUID object. +func StringFromIID(iid *GUID) (string, error) { + return "", NewError(E_NOTIMPL) +} + +// CreateInstance of single uninitialized object with GUID. +func CreateInstance(clsid *GUID, iid *GUID) (*IUnknown, error) { + return nil, NewError(E_NOTIMPL) +} + +// GetActiveObject retrieves pointer to active object. +func GetActiveObject(clsid *GUID, iid *GUID) (*IUnknown, error) { + return nil, NewError(E_NOTIMPL) +} + +// VariantInit initializes variant. +func VariantInit(v *VARIANT) error { + return NewError(E_NOTIMPL) +} + +// VariantClear clears value in Variant settings to VT_EMPTY. +func VariantClear(v *VARIANT) error { + return NewError(E_NOTIMPL) +} + +// SysAllocString allocates memory for string and copies string into memory. +func SysAllocString(v string) *int16 { + u := int16(0) + return &u +} + +// SysAllocStringLen copies up to length of given string returning pointer. +func SysAllocStringLen(v string) *int16 { + u := int16(0) + return &u +} + +// SysFreeString frees string system memory. This must be called with SysAllocString. +func SysFreeString(v *int16) error { + return NewError(E_NOTIMPL) +} + +// SysStringLen is the length of the system allocated string. +func SysStringLen(v *int16) uint32 { + return uint32(0) +} + +// CreateStdDispatch provides default IDispatch implementation for IUnknown. +// +// This handles default IDispatch implementation for objects. It haves a few +// limitations with only supporting one language. It will also only return +// default exception codes. +func CreateStdDispatch(unk *IUnknown, v uintptr, ptinfo *IUnknown) (*IDispatch, error) { + return nil, NewError(E_NOTIMPL) +} + +// CreateDispTypeInfo provides default ITypeInfo implementation for IDispatch. +// +// This will not handle the full implementation of the interface. +func CreateDispTypeInfo(idata *INTERFACEDATA) (*IUnknown, error) { + return nil, NewError(E_NOTIMPL) +} + +// copyMemory moves location of a block of memory. +func copyMemory(dest unsafe.Pointer, src unsafe.Pointer, length uint32) {} + +// GetUserDefaultLCID retrieves current user default locale. +func GetUserDefaultLCID() uint32 { + return uint32(0) +} + +// GetMessage in message queue from runtime. +// +// This function appears to block. PeekMessage does not block. +func GetMessage(msg *Msg, hwnd uint32, MsgFilterMin uint32, MsgFilterMax uint32) (int32, error) { + return int32(0), NewError(E_NOTIMPL) +} + +// DispatchMessage to window procedure. +func DispatchMessage(msg *Msg) int32 { + return int32(0) +} + +func GetVariantDate(value float64) (time.Time, error) { + return time.Now(), NewError(E_NOTIMPL) +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/connect.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/connect.go new file mode 100644 index 0000000000..b2ac2ec67a --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/connect.go @@ -0,0 +1,192 @@ +package ole + +// Connection contains IUnknown for fluent interface interaction. +// +// Deprecated. Use oleutil package instead. +type Connection struct { + Object *IUnknown // Access COM +} + +// Initialize COM. +func (*Connection) Initialize() (err error) { + return coInitialize() +} + +// Uninitialize COM. +func (*Connection) Uninitialize() { + CoUninitialize() +} + +// Create IUnknown object based first on ProgId and then from String. +func (c *Connection) Create(progId string) (err error) { + var clsid *GUID + clsid, err = CLSIDFromProgID(progId) + if err != nil { + clsid, err = CLSIDFromString(progId) + if err != nil { + return + } + } + + unknown, err := CreateInstance(clsid, IID_IUnknown) + if err != nil { + return + } + c.Object = unknown + + return +} + +// Release IUnknown object. +func (c *Connection) Release() { + c.Object.Release() +} + +// Load COM object from list of programIDs or strings. +func (c *Connection) Load(names ...string) (errors []error) { + var tempErrors []error = make([]error, len(names)) + var numErrors int = 0 + for _, name := range names { + err := c.Create(name) + if err != nil { + tempErrors = append(tempErrors, err) + numErrors += 1 + continue + } + break + } + + copy(errors, tempErrors[0:numErrors]) + return +} + +// Dispatch returns Dispatch object. +func (c *Connection) Dispatch() (object *Dispatch, err error) { + dispatch, err := c.Object.QueryInterface(IID_IDispatch) + if err != nil { + return + } + object = &Dispatch{dispatch} + return +} + +// Dispatch stores IDispatch object. +type Dispatch struct { + Object *IDispatch // Dispatch object. +} + +// Call method on IDispatch with parameters. +func (d *Dispatch) Call(method string, params ...interface{}) (result *VARIANT, err error) { + id, err := d.GetId(method) + if err != nil { + return + } + + result, err = d.Invoke(id, DISPATCH_METHOD, params) + return +} + +// MustCall method on IDispatch with parameters. +func (d *Dispatch) MustCall(method string, params ...interface{}) (result *VARIANT) { + id, err := d.GetId(method) + if err != nil { + panic(err) + } + + result, err = d.Invoke(id, DISPATCH_METHOD, params) + if err != nil { + panic(err) + } + + return +} + +// Get property on IDispatch with parameters. +func (d *Dispatch) Get(name string, params ...interface{}) (result *VARIANT, err error) { + id, err := d.GetId(name) + if err != nil { + return + } + result, err = d.Invoke(id, DISPATCH_PROPERTYGET, params) + return +} + +// MustGet property on IDispatch with parameters. +func (d *Dispatch) MustGet(name string, params ...interface{}) (result *VARIANT) { + id, err := d.GetId(name) + if err != nil { + panic(err) + } + + result, err = d.Invoke(id, DISPATCH_PROPERTYGET, params) + if err != nil { + panic(err) + } + return +} + +// Set property on IDispatch with parameters. +func (d *Dispatch) Set(name string, params ...interface{}) (result *VARIANT, err error) { + id, err := d.GetId(name) + if err != nil { + return + } + result, err = d.Invoke(id, DISPATCH_PROPERTYPUT, params) + return +} + +// MustSet property on IDispatch with parameters. +func (d *Dispatch) MustSet(name string, params ...interface{}) (result *VARIANT) { + id, err := d.GetId(name) + if err != nil { + panic(err) + } + + result, err = d.Invoke(id, DISPATCH_PROPERTYPUT, params) + if err != nil { + panic(err) + } + return +} + +// GetId retrieves ID of name on IDispatch. +func (d *Dispatch) GetId(name string) (id int32, err error) { + var dispid []int32 + dispid, err = d.Object.GetIDsOfName([]string{name}) + if err != nil { + return + } + id = dispid[0] + return +} + +// GetIds retrieves all IDs of names on IDispatch. +func (d *Dispatch) GetIds(names ...string) (dispid []int32, err error) { + dispid, err = d.Object.GetIDsOfName(names) + return +} + +// Invoke IDispatch on DisplayID of dispatch type with parameters. +// +// There have been problems where if send cascading params..., it would error +// out because the parameters would be empty. +func (d *Dispatch) Invoke(id int32, dispatch int16, params []interface{}) (result *VARIANT, err error) { + if len(params) < 1 { + result, err = d.Object.Invoke(id, dispatch) + } else { + result, err = d.Object.Invoke(id, dispatch, params...) + } + return +} + +// Release IDispatch object. +func (d *Dispatch) Release() { + d.Object.Release() +} + +// Connect initializes COM and attempts to load IUnknown based on given names. +func Connect(names ...string) (connection *Connection) { + connection.Initialize() + connection.Load(names...) + return +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/constants.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/constants.go new file mode 100644 index 0000000000..fd0c6d74b0 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/constants.go @@ -0,0 +1,153 @@ +package ole + +const ( + CLSCTX_INPROC_SERVER = 1 + CLSCTX_INPROC_HANDLER = 2 + CLSCTX_LOCAL_SERVER = 4 + CLSCTX_INPROC_SERVER16 = 8 + CLSCTX_REMOTE_SERVER = 16 + CLSCTX_ALL = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER + CLSCTX_INPROC = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER + CLSCTX_SERVER = CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER +) + +const ( + COINIT_APARTMENTTHREADED = 0x2 + COINIT_MULTITHREADED = 0x0 + COINIT_DISABLE_OLE1DDE = 0x4 + COINIT_SPEED_OVER_MEMORY = 0x8 +) + +const ( + DISPATCH_METHOD = 1 + DISPATCH_PROPERTYGET = 2 + DISPATCH_PROPERTYPUT = 4 + DISPATCH_PROPERTYPUTREF = 8 +) + +const ( + S_OK = 0x00000000 + E_UNEXPECTED = 0x8000FFFF + E_NOTIMPL = 0x80004001 + E_OUTOFMEMORY = 0x8007000E + E_INVALIDARG = 0x80070057 + E_NOINTERFACE = 0x80004002 + E_POINTER = 0x80004003 + E_HANDLE = 0x80070006 + E_ABORT = 0x80004004 + E_FAIL = 0x80004005 + E_ACCESSDENIED = 0x80070005 + E_PENDING = 0x8000000A + + CO_E_CLASSSTRING = 0x800401F3 +) + +const ( + CC_FASTCALL = iota + CC_CDECL + CC_MSCPASCAL + CC_PASCAL = CC_MSCPASCAL + CC_MACPASCAL + CC_STDCALL + CC_FPFASTCALL + CC_SYSCALL + CC_MPWCDECL + CC_MPWPASCAL + CC_MAX = CC_MPWPASCAL +) + +type VT uint16 + +const ( + VT_EMPTY VT = 0x0 + VT_NULL VT = 0x1 + VT_I2 VT = 0x2 + VT_I4 VT = 0x3 + VT_R4 VT = 0x4 + VT_R8 VT = 0x5 + VT_CY VT = 0x6 + VT_DATE VT = 0x7 + VT_BSTR VT = 0x8 + VT_DISPATCH VT = 0x9 + VT_ERROR VT = 0xa + VT_BOOL VT = 0xb + VT_VARIANT VT = 0xc + VT_UNKNOWN VT = 0xd + VT_DECIMAL VT = 0xe + VT_I1 VT = 0x10 + VT_UI1 VT = 0x11 + VT_UI2 VT = 0x12 + VT_UI4 VT = 0x13 + VT_I8 VT = 0x14 + VT_UI8 VT = 0x15 + VT_INT VT = 0x16 + VT_UINT VT = 0x17 + VT_VOID VT = 0x18 + VT_HRESULT VT = 0x19 + VT_PTR VT = 0x1a + VT_SAFEARRAY VT = 0x1b + VT_CARRAY VT = 0x1c + VT_USERDEFINED VT = 0x1d + VT_LPSTR VT = 0x1e + VT_LPWSTR VT = 0x1f + VT_RECORD VT = 0x24 + VT_INT_PTR VT = 0x25 + VT_UINT_PTR VT = 0x26 + VT_FILETIME VT = 0x40 + VT_BLOB VT = 0x41 + VT_STREAM VT = 0x42 + VT_STORAGE VT = 0x43 + VT_STREAMED_OBJECT VT = 0x44 + VT_STORED_OBJECT VT = 0x45 + VT_BLOB_OBJECT VT = 0x46 + VT_CF VT = 0x47 + VT_CLSID VT = 0x48 + VT_BSTR_BLOB VT = 0xfff + VT_VECTOR VT = 0x1000 + VT_ARRAY VT = 0x2000 + VT_BYREF VT = 0x4000 + VT_RESERVED VT = 0x8000 + VT_ILLEGAL VT = 0xffff + VT_ILLEGALMASKED VT = 0xfff + VT_TYPEMASK VT = 0xfff +) + +const ( + DISPID_UNKNOWN = -1 + DISPID_VALUE = 0 + DISPID_PROPERTYPUT = -3 + DISPID_NEWENUM = -4 + DISPID_EVALUATE = -5 + DISPID_CONSTRUCTOR = -6 + DISPID_DESTRUCTOR = -7 + DISPID_COLLECT = -8 +) + +const ( + TKIND_ENUM = 1 + TKIND_RECORD = 2 + TKIND_MODULE = 3 + TKIND_INTERFACE = 4 + TKIND_DISPATCH = 5 + TKIND_COCLASS = 6 + TKIND_ALIAS = 7 + TKIND_UNION = 8 + TKIND_MAX = 9 +) + +// Safe Array Feature Flags + +const ( + FADF_AUTO = 0x0001 + FADF_STATIC = 0x0002 + FADF_EMBEDDED = 0x0004 + FADF_FIXEDSIZE = 0x0010 + FADF_RECORD = 0x0020 + FADF_HAVEIID = 0x0040 + FADF_HAVEVARTYPE = 0x0080 + FADF_BSTR = 0x0100 + FADF_UNKNOWN = 0x0200 + FADF_DISPATCH = 0x0400 + FADF_VARIANT = 0x0800 + FADF_RESERVED = 0xF008 +) diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/error.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/error.go new file mode 100644 index 0000000000..096b456d3a --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/error.go @@ -0,0 +1,51 @@ +package ole + +// OleError stores COM errors. +type OleError struct { + hr uintptr + description string + subError error +} + +// NewError creates new error with HResult. +func NewError(hr uintptr) *OleError { + return &OleError{hr: hr} +} + +// NewErrorWithDescription creates new COM error with HResult and description. +func NewErrorWithDescription(hr uintptr, description string) *OleError { + return &OleError{hr: hr, description: description} +} + +// NewErrorWithSubError creates new COM error with parent error. +func NewErrorWithSubError(hr uintptr, description string, err error) *OleError { + return &OleError{hr: hr, description: description, subError: err} +} + +// Code is the HResult. +func (v *OleError) Code() uintptr { + return uintptr(v.hr) +} + +// String description, either manually set or format message with error code. +func (v *OleError) String() string { + if v.description != "" { + return errstr(int(v.hr)) + " (" + v.description + ")" + } + return errstr(int(v.hr)) +} + +// Error implements error interface. +func (v *OleError) Error() string { + return v.String() +} + +// Description retrieves error summary, if there is one. +func (v *OleError) Description() string { + return v.description +} + +// SubError returns parent error, if there is one. +func (v *OleError) SubError() error { + return v.subError +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/error_func.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/error_func.go new file mode 100644 index 0000000000..8a2ffaa272 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/error_func.go @@ -0,0 +1,8 @@ +// +build !windows + +package ole + +// errstr converts error code to string. +func errstr(errno int) string { + return "" +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/error_windows.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/error_windows.go new file mode 100644 index 0000000000..d0e8e68595 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/error_windows.go @@ -0,0 +1,24 @@ +// +build windows + +package ole + +import ( + "fmt" + "syscall" + "unicode/utf16" +) + +// errstr converts error code to string. +func errstr(errno int) string { + // ask windows for the remaining errors + var flags uint32 = syscall.FORMAT_MESSAGE_FROM_SYSTEM | syscall.FORMAT_MESSAGE_ARGUMENT_ARRAY | syscall.FORMAT_MESSAGE_IGNORE_INSERTS + b := make([]uint16, 300) + n, err := syscall.FormatMessage(flags, 0, uint32(errno), 0, b, nil) + if err != nil { + return fmt.Sprintf("error %d (FormatMessage failed with: %v)", errno, err) + } + // trim terminating \r and \n + for ; n > 0 && (b[n-1] == '\n' || b[n-1] == '\r'); n-- { + } + return string(utf16.Decode(b[:n])) +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/guid.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/guid.go new file mode 100644 index 0000000000..609ef0bfe3 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/guid.go @@ -0,0 +1,118 @@ +package ole + +var ( + // IID_NULL is null Interface ID, used when no other Interface ID is known. + IID_NULL = &GUID{0x00000000, 0x0000, 0x0000, [8]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}} + + // IID_IUnknown is for IUnknown interfaces. + IID_IUnknown = &GUID{0x00000000, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} + + // IID_IDispatch is for IDispatch interfaces. + IID_IDispatch = &GUID{0x00020400, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} + + // IID_IEnumVariant is for IEnumVariant interfaces + IID_IEnumVariant = &GUID{0x00020404, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} + + // IID_IConnectionPointContainer is for IConnectionPointContainer interfaces. + IID_IConnectionPointContainer = &GUID{0xB196B284, 0xBAB4, 0x101A, [8]byte{0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07}} + + // IID_IConnectionPoint is for IConnectionPoint interfaces. + IID_IConnectionPoint = &GUID{0xB196B286, 0xBAB4, 0x101A, [8]byte{0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07}} + + // IID_IInspectable is for IInspectable interfaces. + IID_IInspectable = &GUID{0xaf86e2e0, 0xb12d, 0x4c6a, [8]byte{0x9c, 0x5a, 0xd7, 0xaa, 0x65, 0x10, 0x1e, 0x90}} + + // IID_IProvideClassInfo is for IProvideClassInfo interfaces. + IID_IProvideClassInfo = &GUID{0xb196b283, 0xbab4, 0x101a, [8]byte{0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07}} +) + +// These are for testing and not part of any library. +var ( + // IID_ICOMTestString is for ICOMTestString interfaces. + // + // {E0133EB4-C36F-469A-9D3D-C66B84BE19ED} + IID_ICOMTestString = &GUID{0xe0133eb4, 0xc36f, 0x469a, [8]byte{0x9d, 0x3d, 0xc6, 0x6b, 0x84, 0xbe, 0x19, 0xed}} + + // IID_ICOMTestInt8 is for ICOMTestInt8 interfaces. + // + // {BEB06610-EB84-4155-AF58-E2BFF53608B4} + IID_ICOMTestInt8 = &GUID{0xbeb06610, 0xeb84, 0x4155, [8]byte{0xaf, 0x58, 0xe2, 0xbf, 0xf5, 0x36, 0x80, 0xb4}} + + // IID_ICOMTestInt16 is for ICOMTestInt16 interfaces. + // + // {DAA3F9FA-761E-4976-A860-8364CE55F6FC} + IID_ICOMTestInt16 = &GUID{0xdaa3f9fa, 0x761e, 0x4976, [8]byte{0xa8, 0x60, 0x83, 0x64, 0xce, 0x55, 0xf6, 0xfc}} + + // IID_ICOMTestInt32 is for ICOMTestInt32 interfaces. + // + // {E3DEDEE7-38A2-4540-91D1-2EEF1D8891B0} + IID_ICOMTestInt32 = &GUID{0xe3dedee7, 0x38a2, 0x4540, [8]byte{0x91, 0xd1, 0x2e, 0xef, 0x1d, 0x88, 0x91, 0xb0}} + + // IID_ICOMTestInt64 is for ICOMTestInt64 interfaces. + // + // {8D437CBC-B3ED-485C-BC32-C336432A1623} + IID_ICOMTestInt64 = &GUID{0x8d437cbc, 0xb3ed, 0x485c, [8]byte{0xbc, 0x32, 0xc3, 0x36, 0x43, 0x2a, 0x16, 0x23}} + + // IID_ICOMTestFloat is for ICOMTestFloat interfaces. + // + // {BF1ED004-EA02-456A-AA55-2AC8AC6B054C} + IID_ICOMTestFloat = &GUID{0xbf1ed004, 0xea02, 0x456a, [8]byte{0xaa, 0x55, 0x2a, 0xc8, 0xac, 0x6b, 0x5, 0x4c}} + + // IID_ICOMTestDouble is for ICOMTestDouble interfaces. + // + // {BF908A81-8687-4E93-999F-D86FAB284BA0} + IID_ICOMTestDouble = &GUID{0xbf908a81, 0x8687, 0x4e93, [8]byte{0x99, 0x9f, 0xd8, 0x6f, 0xab, 0x28, 0x4b, 0xa0}} + + // IID_ICOMTestBoolean is for ICOMTestBoolean interfaces. + // + // {D530E7A6-4EE8-40D1-8931-3D63B8605001} + IID_ICOMTestBoolean = &GUID{0xd530e7a6, 0x4ee8, 0x40d1, [8]byte{0x89, 0x31, 0x3d, 0x63, 0xb8, 0x60, 0x50, 0x10}} + + // IID_ICOMEchoTestObject is for ICOMEchoTestObject interfaces. + // + // {6485B1EF-D780-4834-A4FE-1EBB51746CA3} + IID_ICOMEchoTestObject = &GUID{0x6485b1ef, 0xd780, 0x4834, [8]byte{0xa4, 0xfe, 0x1e, 0xbb, 0x51, 0x74, 0x6c, 0xa3}} + + // IID_ICOMTestTypes is for ICOMTestTypes interfaces. + // + // {CCA8D7AE-91C0-4277-A8B3-FF4EDF28D3C0} + IID_ICOMTestTypes = &GUID{0xcca8d7ae, 0x91c0, 0x4277, [8]byte{0xa8, 0xb3, 0xff, 0x4e, 0xdf, 0x28, 0xd3, 0xc0}} + + // CLSID_COMEchoTestObject is for COMEchoTestObject class. + // + // {3C24506A-AE9E-4D50-9157-EF317281F1B0} + CLSID_COMEchoTestObject = &GUID{0x3c24506a, 0xae9e, 0x4d50, [8]byte{0x91, 0x57, 0xef, 0x31, 0x72, 0x81, 0xf1, 0xb0}} + + // CLSID_COMTestScalarClass is for COMTestScalarClass class. + // + // {865B85C5-0334-4AC6-9EF6-AACEC8FC5E86} + CLSID_COMTestScalarClass = &GUID{0x865b85c5, 0x0334, 0x4ac6, [8]byte{0x9e, 0xf6, 0xaa, 0xce, 0xc8, 0xfc, 0x5e, 0x86}} +) + +// GUID is Windows API specific GUID type. +// +// This exists to match Windows GUID type for direct passing for COM. +// Format is in xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx. +type GUID struct { + Data1 uint32 + Data2 uint16 + Data3 uint16 + Data4 [8]byte +} + +// IsEqualGUID compares two GUID. +// +// Not constant time comparison. +func IsEqualGUID(guid1 *GUID, guid2 *GUID) bool { + return guid1.Data1 == guid2.Data1 && + guid1.Data2 == guid2.Data2 && + guid1.Data3 == guid2.Data3 && + guid1.Data4[0] == guid2.Data4[0] && + guid1.Data4[1] == guid2.Data4[1] && + guid1.Data4[2] == guid2.Data4[2] && + guid1.Data4[3] == guid2.Data4[3] && + guid1.Data4[4] == guid2.Data4[4] && + guid1.Data4[5] == guid2.Data4[5] && + guid1.Data4[6] == guid2.Data4[6] && + guid1.Data4[7] == guid2.Data4[7] +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpoint.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpoint.go new file mode 100644 index 0000000000..9e6c49f41f --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpoint.go @@ -0,0 +1,20 @@ +package ole + +import "unsafe" + +type IConnectionPoint struct { + IUnknown +} + +type IConnectionPointVtbl struct { + IUnknownVtbl + GetConnectionInterface uintptr + GetConnectionPointContainer uintptr + Advise uintptr + Unadvise uintptr + EnumConnections uintptr +} + +func (v *IConnectionPoint) VTable() *IConnectionPointVtbl { + return (*IConnectionPointVtbl)(unsafe.Pointer(v.RawVTable)) +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpoint_func.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpoint_func.go new file mode 100644 index 0000000000..5414dc3cd3 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpoint_func.go @@ -0,0 +1,21 @@ +// +build !windows + +package ole + +import "unsafe" + +func (v *IConnectionPoint) GetConnectionInterface(piid **GUID) int32 { + return int32(0) +} + +func (v *IConnectionPoint) Advise(unknown *IUnknown) (uint32, error) { + return uint32(0), NewError(E_NOTIMPL) +} + +func (v *IConnectionPoint) Unadvise(cookie uint32) error { + return NewError(E_NOTIMPL) +} + +func (v *IConnectionPoint) EnumConnections(p *unsafe.Pointer) (err error) { + return NewError(E_NOTIMPL) +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpoint_windows.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpoint_windows.go new file mode 100644 index 0000000000..32bc183248 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpoint_windows.go @@ -0,0 +1,43 @@ +// +build windows + +package ole + +import ( + "syscall" + "unsafe" +) + +func (v *IConnectionPoint) GetConnectionInterface(piid **GUID) int32 { + // XXX: This doesn't look like it does what it's supposed to + return release((*IUnknown)(unsafe.Pointer(v))) +} + +func (v *IConnectionPoint) Advise(unknown *IUnknown) (cookie uint32, err error) { + hr, _, _ := syscall.Syscall( + v.VTable().Advise, + 3, + uintptr(unsafe.Pointer(v)), + uintptr(unsafe.Pointer(unknown)), + uintptr(unsafe.Pointer(&cookie))) + if hr != 0 { + err = NewError(hr) + } + return +} + +func (v *IConnectionPoint) Unadvise(cookie uint32) (err error) { + hr, _, _ := syscall.Syscall( + v.VTable().Unadvise, + 2, + uintptr(unsafe.Pointer(v)), + uintptr(cookie), + 0) + if hr != 0 { + err = NewError(hr) + } + return +} + +func (v *IConnectionPoint) EnumConnections(p *unsafe.Pointer) error { + return NewError(E_NOTIMPL) +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpointcontainer.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpointcontainer.go new file mode 100644 index 0000000000..165860d199 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpointcontainer.go @@ -0,0 +1,17 @@ +package ole + +import "unsafe" + +type IConnectionPointContainer struct { + IUnknown +} + +type IConnectionPointContainerVtbl struct { + IUnknownVtbl + EnumConnectionPoints uintptr + FindConnectionPoint uintptr +} + +func (v *IConnectionPointContainer) VTable() *IConnectionPointContainerVtbl { + return (*IConnectionPointContainerVtbl)(unsafe.Pointer(v.RawVTable)) +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpointcontainer_func.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpointcontainer_func.go new file mode 100644 index 0000000000..5dfa42aaeb --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpointcontainer_func.go @@ -0,0 +1,11 @@ +// +build !windows + +package ole + +func (v *IConnectionPointContainer) EnumConnectionPoints(points interface{}) error { + return NewError(E_NOTIMPL) +} + +func (v *IConnectionPointContainer) FindConnectionPoint(iid *GUID, point **IConnectionPoint) error { + return NewError(E_NOTIMPL) +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpointcontainer_windows.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpointcontainer_windows.go new file mode 100644 index 0000000000..ad30d79efc --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpointcontainer_windows.go @@ -0,0 +1,25 @@ +// +build windows + +package ole + +import ( + "syscall" + "unsafe" +) + +func (v *IConnectionPointContainer) EnumConnectionPoints(points interface{}) error { + return NewError(E_NOTIMPL) +} + +func (v *IConnectionPointContainer) FindConnectionPoint(iid *GUID, point **IConnectionPoint) (err error) { + hr, _, _ := syscall.Syscall( + v.VTable().FindConnectionPoint, + 3, + uintptr(unsafe.Pointer(v)), + uintptr(unsafe.Pointer(iid)), + uintptr(unsafe.Pointer(point))) + if hr != 0 { + err = NewError(hr) + } + return +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/idispatch.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/idispatch.go new file mode 100644 index 0000000000..d4af124092 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/idispatch.go @@ -0,0 +1,94 @@ +package ole + +import "unsafe" + +type IDispatch struct { + IUnknown +} + +type IDispatchVtbl struct { + IUnknownVtbl + GetTypeInfoCount uintptr + GetTypeInfo uintptr + GetIDsOfNames uintptr + Invoke uintptr +} + +func (v *IDispatch) VTable() *IDispatchVtbl { + return (*IDispatchVtbl)(unsafe.Pointer(v.RawVTable)) +} + +func (v *IDispatch) GetIDsOfName(names []string) (dispid []int32, err error) { + dispid, err = getIDsOfName(v, names) + return +} + +func (v *IDispatch) Invoke(dispid int32, dispatch int16, params ...interface{}) (result *VARIANT, err error) { + result, err = invoke(v, dispid, dispatch, params...) + return +} + +func (v *IDispatch) GetTypeInfoCount() (c uint32, err error) { + c, err = getTypeInfoCount(v) + return +} + +func (v *IDispatch) GetTypeInfo() (tinfo *ITypeInfo, err error) { + tinfo, err = getTypeInfo(v) + return +} + +// GetSingleIDOfName is a helper that returns single display ID for IDispatch name. +// +// This replaces the common pattern of attempting to get a single name from the list of available +// IDs. It gives the first ID, if it is available. +func (v *IDispatch) GetSingleIDOfName(name string) (displayID int32, err error) { + var displayIDs []int32 + displayIDs, err = v.GetIDsOfName([]string{name}) + if err != nil { + return + } + displayID = displayIDs[0] + return +} + +// InvokeWithOptionalArgs accepts arguments as an array, works like Invoke. +// +// Accepts name and will attempt to retrieve Display ID to pass to Invoke. +// +// Passing params as an array is a workaround that could be fixed in later versions of Go that +// prevent passing empty params. During testing it was discovered that this is an acceptable way of +// getting around not being able to pass params normally. +func (v *IDispatch) InvokeWithOptionalArgs(name string, dispatch int16, params []interface{}) (result *VARIANT, err error) { + displayID, err := v.GetSingleIDOfName(name) + if err != nil { + return + } + + if len(params) < 1 { + result, err = v.Invoke(displayID, dispatch) + } else { + result, err = v.Invoke(displayID, dispatch, params...) + } + + return +} + +// CallMethod invokes named function with arguments on object. +func (v *IDispatch) CallMethod(name string, params ...interface{}) (*VARIANT, error) { + return v.InvokeWithOptionalArgs(name, DISPATCH_METHOD, params) +} + +// GetProperty retrieves the property with the name with the ability to pass arguments. +// +// Most of the time you will not need to pass arguments as most objects do not allow for this +// feature. Or at least, should not allow for this feature. Some servers don't follow best practices +// and this is provided for those edge cases. +func (v *IDispatch) GetProperty(name string, params ...interface{}) (*VARIANT, error) { + return v.InvokeWithOptionalArgs(name, DISPATCH_PROPERTYGET, params) +} + +// PutProperty attempts to mutate a property in the object. +func (v *IDispatch) PutProperty(name string, params ...interface{}) (*VARIANT, error) { + return v.InvokeWithOptionalArgs(name, DISPATCH_PROPERTYPUT, params) +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/idispatch_func.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/idispatch_func.go new file mode 100644 index 0000000000..b8fbbe319f --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/idispatch_func.go @@ -0,0 +1,19 @@ +// +build !windows + +package ole + +func getIDsOfName(disp *IDispatch, names []string) ([]int32, error) { + return []int32{}, NewError(E_NOTIMPL) +} + +func getTypeInfoCount(disp *IDispatch) (uint32, error) { + return uint32(0), NewError(E_NOTIMPL) +} + +func getTypeInfo(disp *IDispatch) (*ITypeInfo, error) { + return nil, NewError(E_NOTIMPL) +} + +func invoke(disp *IDispatch, dispid int32, dispatch int16, params ...interface{}) (*VARIANT, error) { + return nil, NewError(E_NOTIMPL) +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/idispatch_windows.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/idispatch_windows.go new file mode 100644 index 0000000000..bb73690382 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/idispatch_windows.go @@ -0,0 +1,193 @@ +// +build windows + +package ole + +import ( + "syscall" + "time" + "unsafe" +) + +func getIDsOfName(disp *IDispatch, names []string) (dispid []int32, err error) { + wnames := make([]*uint16, len(names)) + for i := 0; i < len(names); i++ { + wnames[i] = syscall.StringToUTF16Ptr(names[i]) + } + dispid = make([]int32, len(names)) + namelen := uint32(len(names)) + hr, _, _ := syscall.Syscall6( + disp.VTable().GetIDsOfNames, + 6, + uintptr(unsafe.Pointer(disp)), + uintptr(unsafe.Pointer(IID_NULL)), + uintptr(unsafe.Pointer(&wnames[0])), + uintptr(namelen), + uintptr(GetUserDefaultLCID()), + uintptr(unsafe.Pointer(&dispid[0]))) + if hr != 0 { + err = NewError(hr) + } + return +} + +func getTypeInfoCount(disp *IDispatch) (c uint32, err error) { + hr, _, _ := syscall.Syscall( + disp.VTable().GetTypeInfoCount, + 2, + uintptr(unsafe.Pointer(disp)), + uintptr(unsafe.Pointer(&c)), + 0) + if hr != 0 { + err = NewError(hr) + } + return +} + +func getTypeInfo(disp *IDispatch) (tinfo *ITypeInfo, err error) { + hr, _, _ := syscall.Syscall( + disp.VTable().GetTypeInfo, + 3, + uintptr(unsafe.Pointer(disp)), + uintptr(GetUserDefaultLCID()), + uintptr(unsafe.Pointer(&tinfo))) + if hr != 0 { + err = NewError(hr) + } + return +} + +func invoke(disp *IDispatch, dispid int32, dispatch int16, params ...interface{}) (result *VARIANT, err error) { + var dispparams DISPPARAMS + + if dispatch&DISPATCH_PROPERTYPUT != 0 { + dispnames := [1]int32{DISPID_PROPERTYPUT} + dispparams.rgdispidNamedArgs = uintptr(unsafe.Pointer(&dispnames[0])) + dispparams.cNamedArgs = 1 + } + var vargs []VARIANT + if len(params) > 0 { + vargs = make([]VARIANT, len(params)) + for i, v := range params { + //n := len(params)-i-1 + n := len(params) - i - 1 + VariantInit(&vargs[n]) + switch vv := v.(type) { + case bool: + if vv { + vargs[n] = NewVariant(VT_BOOL, 0xffff) + } else { + vargs[n] = NewVariant(VT_BOOL, 0) + } + case *bool: + vargs[n] = NewVariant(VT_BOOL|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*bool))))) + case uint8: + vargs[n] = NewVariant(VT_I1, int64(v.(uint8))) + case *uint8: + vargs[n] = NewVariant(VT_I1|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*uint8))))) + case int8: + vargs[n] = NewVariant(VT_I1, int64(v.(int8))) + case *int8: + vargs[n] = NewVariant(VT_I1|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*uint8))))) + case int16: + vargs[n] = NewVariant(VT_I2, int64(v.(int16))) + case *int16: + vargs[n] = NewVariant(VT_I2|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*int16))))) + case uint16: + vargs[n] = NewVariant(VT_UI2, int64(v.(uint16))) + case *uint16: + vargs[n] = NewVariant(VT_UI2|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*uint16))))) + case int32: + vargs[n] = NewVariant(VT_I4, int64(v.(int32))) + case *int32: + vargs[n] = NewVariant(VT_I4|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*int32))))) + case uint32: + vargs[n] = NewVariant(VT_UI4, int64(v.(uint32))) + case *uint32: + vargs[n] = NewVariant(VT_UI4|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*uint32))))) + case int64: + vargs[n] = NewVariant(VT_I8, int64(v.(int64))) + case *int64: + vargs[n] = NewVariant(VT_I8|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*int64))))) + case uint64: + vargs[n] = NewVariant(VT_UI8, int64(uintptr(v.(uint64)))) + case *uint64: + vargs[n] = NewVariant(VT_UI8|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*uint64))))) + case int: + vargs[n] = NewVariant(VT_I4, int64(v.(int))) + case *int: + vargs[n] = NewVariant(VT_I4|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*int))))) + case uint: + vargs[n] = NewVariant(VT_UI4, int64(v.(uint))) + case *uint: + vargs[n] = NewVariant(VT_UI4|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*uint))))) + case float32: + vargs[n] = NewVariant(VT_R4, *(*int64)(unsafe.Pointer(&vv))) + case *float32: + vargs[n] = NewVariant(VT_R4|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*float32))))) + case float64: + vargs[n] = NewVariant(VT_R8, *(*int64)(unsafe.Pointer(&vv))) + case *float64: + vargs[n] = NewVariant(VT_R8|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*float64))))) + case string: + vargs[n] = NewVariant(VT_BSTR, int64(uintptr(unsafe.Pointer(SysAllocStringLen(v.(string)))))) + case *string: + vargs[n] = NewVariant(VT_BSTR|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*string))))) + case time.Time: + s := vv.Format("2006-01-02 15:04:05") + vargs[n] = NewVariant(VT_BSTR, int64(uintptr(unsafe.Pointer(SysAllocStringLen(s))))) + case *time.Time: + s := vv.Format("2006-01-02 15:04:05") + vargs[n] = NewVariant(VT_BSTR|VT_BYREF, int64(uintptr(unsafe.Pointer(&s)))) + case *IDispatch: + vargs[n] = NewVariant(VT_DISPATCH, int64(uintptr(unsafe.Pointer(v.(*IDispatch))))) + case **IDispatch: + vargs[n] = NewVariant(VT_DISPATCH|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(**IDispatch))))) + case nil: + vargs[n] = NewVariant(VT_NULL, 0) + case *VARIANT: + vargs[n] = NewVariant(VT_VARIANT|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*VARIANT))))) + case []byte: + safeByteArray := safeArrayFromByteSlice(v.([]byte)) + vargs[n] = NewVariant(VT_ARRAY|VT_UI1, int64(uintptr(unsafe.Pointer(safeByteArray)))) + defer VariantClear(&vargs[n]) + case []string: + safeByteArray := safeArrayFromStringSlice(v.([]string)) + vargs[n] = NewVariant(VT_ARRAY|VT_BSTR, int64(uintptr(unsafe.Pointer(safeByteArray)))) + defer VariantClear(&vargs[n]) + default: + panic("unknown type") + } + } + dispparams.rgvarg = uintptr(unsafe.Pointer(&vargs[0])) + dispparams.cArgs = uint32(len(params)) + } + + result = new(VARIANT) + var excepInfo EXCEPINFO + VariantInit(result) + hr, _, _ := syscall.Syscall9( + disp.VTable().Invoke, + 9, + uintptr(unsafe.Pointer(disp)), + uintptr(dispid), + uintptr(unsafe.Pointer(IID_NULL)), + uintptr(GetUserDefaultLCID()), + uintptr(dispatch), + uintptr(unsafe.Pointer(&dispparams)), + uintptr(unsafe.Pointer(result)), + uintptr(unsafe.Pointer(&excepInfo)), + 0) + if hr != 0 { + err = NewErrorWithSubError(hr, BstrToString(excepInfo.bstrDescription), excepInfo) + } + for i, varg := range vargs { + n := len(params) - i - 1 + if varg.VT == VT_BSTR && varg.Val != 0 { + SysFreeString(((*int16)(unsafe.Pointer(uintptr(varg.Val))))) + } + if varg.VT == (VT_BSTR|VT_BYREF) && varg.Val != 0 { + *(params[n].(*string)) = LpOleStrToString(*(**uint16)(unsafe.Pointer(uintptr(varg.Val)))) + } + } + return +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/ienumvariant.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/ienumvariant.go new file mode 100644 index 0000000000..2433897544 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/ienumvariant.go @@ -0,0 +1,19 @@ +package ole + +import "unsafe" + +type IEnumVARIANT struct { + IUnknown +} + +type IEnumVARIANTVtbl struct { + IUnknownVtbl + Next uintptr + Skip uintptr + Reset uintptr + Clone uintptr +} + +func (v *IEnumVARIANT) VTable() *IEnumVARIANTVtbl { + return (*IEnumVARIANTVtbl)(unsafe.Pointer(v.RawVTable)) +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/ienumvariant_func.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/ienumvariant_func.go new file mode 100644 index 0000000000..c14848199c --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/ienumvariant_func.go @@ -0,0 +1,19 @@ +// +build !windows + +package ole + +func (enum *IEnumVARIANT) Clone() (*IEnumVARIANT, error) { + return nil, NewError(E_NOTIMPL) +} + +func (enum *IEnumVARIANT) Reset() error { + return NewError(E_NOTIMPL) +} + +func (enum *IEnumVARIANT) Skip(celt uint) error { + return NewError(E_NOTIMPL) +} + +func (enum *IEnumVARIANT) Next(celt uint) (VARIANT, uint, error) { + return NewVariant(VT_NULL, int64(0)), 0, NewError(E_NOTIMPL) +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/ienumvariant_windows.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/ienumvariant_windows.go new file mode 100644 index 0000000000..4781f3b8b0 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/ienumvariant_windows.go @@ -0,0 +1,63 @@ +// +build windows + +package ole + +import ( + "syscall" + "unsafe" +) + +func (enum *IEnumVARIANT) Clone() (cloned *IEnumVARIANT, err error) { + hr, _, _ := syscall.Syscall( + enum.VTable().Clone, + 2, + uintptr(unsafe.Pointer(enum)), + uintptr(unsafe.Pointer(&cloned)), + 0) + if hr != 0 { + err = NewError(hr) + } + return +} + +func (enum *IEnumVARIANT) Reset() (err error) { + hr, _, _ := syscall.Syscall( + enum.VTable().Reset, + 1, + uintptr(unsafe.Pointer(enum)), + 0, + 0) + if hr != 0 { + err = NewError(hr) + } + return +} + +func (enum *IEnumVARIANT) Skip(celt uint) (err error) { + hr, _, _ := syscall.Syscall( + enum.VTable().Skip, + 2, + uintptr(unsafe.Pointer(enum)), + uintptr(celt), + 0) + if hr != 0 { + err = NewError(hr) + } + return +} + +func (enum *IEnumVARIANT) Next(celt uint) (array VARIANT, length uint, err error) { + hr, _, _ := syscall.Syscall6( + enum.VTable().Next, + 4, + uintptr(unsafe.Pointer(enum)), + uintptr(celt), + uintptr(unsafe.Pointer(&array)), + uintptr(unsafe.Pointer(&length)), + 0, + 0) + if hr != 0 { + err = NewError(hr) + } + return +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iinspectable.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iinspectable.go new file mode 100644 index 0000000000..f4a19e253a --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/iinspectable.go @@ -0,0 +1,18 @@ +package ole + +import "unsafe" + +type IInspectable struct { + IUnknown +} + +type IInspectableVtbl struct { + IUnknownVtbl + GetIIds uintptr + GetRuntimeClassName uintptr + GetTrustLevel uintptr +} + +func (v *IInspectable) VTable() *IInspectableVtbl { + return (*IInspectableVtbl)(unsafe.Pointer(v.RawVTable)) +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iinspectable_func.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iinspectable_func.go new file mode 100644 index 0000000000..348829bf06 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/iinspectable_func.go @@ -0,0 +1,15 @@ +// +build !windows + +package ole + +func (v *IInspectable) GetIids() ([]*GUID, error) { + return []*GUID{}, NewError(E_NOTIMPL) +} + +func (v *IInspectable) GetRuntimeClassName() (string, error) { + return "", NewError(E_NOTIMPL) +} + +func (v *IInspectable) GetTrustLevel() (uint32, error) { + return uint32(0), NewError(E_NOTIMPL) +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iinspectable_windows.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iinspectable_windows.go new file mode 100644 index 0000000000..4519a4aa44 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/iinspectable_windows.go @@ -0,0 +1,72 @@ +// +build windows + +package ole + +import ( + "bytes" + "encoding/binary" + "reflect" + "syscall" + "unsafe" +) + +func (v *IInspectable) GetIids() (iids []*GUID, err error) { + var count uint32 + var array uintptr + hr, _, _ := syscall.Syscall( + v.VTable().GetIIds, + 3, + uintptr(unsafe.Pointer(v)), + uintptr(unsafe.Pointer(&count)), + uintptr(unsafe.Pointer(&array))) + if hr != 0 { + err = NewError(hr) + return + } + defer CoTaskMemFree(array) + + iids = make([]*GUID, count) + byteCount := count * uint32(unsafe.Sizeof(GUID{})) + slicehdr := reflect.SliceHeader{Data: array, Len: int(byteCount), Cap: int(byteCount)} + byteSlice := *(*[]byte)(unsafe.Pointer(&slicehdr)) + reader := bytes.NewReader(byteSlice) + for i := range iids { + guid := GUID{} + err = binary.Read(reader, binary.LittleEndian, &guid) + if err != nil { + return + } + iids[i] = &guid + } + return +} + +func (v *IInspectable) GetRuntimeClassName() (s string, err error) { + var hstring HString + hr, _, _ := syscall.Syscall( + v.VTable().GetRuntimeClassName, + 2, + uintptr(unsafe.Pointer(v)), + uintptr(unsafe.Pointer(&hstring)), + 0) + if hr != 0 { + err = NewError(hr) + return + } + s = hstring.String() + DeleteHString(hstring) + return +} + +func (v *IInspectable) GetTrustLevel() (level uint32, err error) { + hr, _, _ := syscall.Syscall( + v.VTable().GetTrustLevel, + 2, + uintptr(unsafe.Pointer(v)), + uintptr(unsafe.Pointer(&level)), + 0) + if hr != 0 { + err = NewError(hr) + } + return +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iprovideclassinfo.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iprovideclassinfo.go new file mode 100644 index 0000000000..25f3a6f24a --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/iprovideclassinfo.go @@ -0,0 +1,21 @@ +package ole + +import "unsafe" + +type IProvideClassInfo struct { + IUnknown +} + +type IProvideClassInfoVtbl struct { + IUnknownVtbl + GetClassInfo uintptr +} + +func (v *IProvideClassInfo) VTable() *IProvideClassInfoVtbl { + return (*IProvideClassInfoVtbl)(unsafe.Pointer(v.RawVTable)) +} + +func (v *IProvideClassInfo) GetClassInfo() (cinfo *ITypeInfo, err error) { + cinfo, err = getClassInfo(v) + return +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iprovideclassinfo_func.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iprovideclassinfo_func.go new file mode 100644 index 0000000000..7e3cb63ea7 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/iprovideclassinfo_func.go @@ -0,0 +1,7 @@ +// +build !windows + +package ole + +func getClassInfo(disp *IProvideClassInfo) (tinfo *ITypeInfo, err error) { + return nil, NewError(E_NOTIMPL) +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iprovideclassinfo_windows.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iprovideclassinfo_windows.go new file mode 100644 index 0000000000..2ad0163949 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/iprovideclassinfo_windows.go @@ -0,0 +1,21 @@ +// +build windows + +package ole + +import ( + "syscall" + "unsafe" +) + +func getClassInfo(disp *IProvideClassInfo) (tinfo *ITypeInfo, err error) { + hr, _, _ := syscall.Syscall( + disp.VTable().GetClassInfo, + 2, + uintptr(unsafe.Pointer(disp)), + uintptr(unsafe.Pointer(&tinfo)), + 0) + if hr != 0 { + err = NewError(hr) + } + return +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/itypeinfo.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/itypeinfo.go new file mode 100644 index 0000000000..dd3c5e21bb --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/itypeinfo.go @@ -0,0 +1,34 @@ +package ole + +import "unsafe" + +type ITypeInfo struct { + IUnknown +} + +type ITypeInfoVtbl struct { + IUnknownVtbl + GetTypeAttr uintptr + GetTypeComp uintptr + GetFuncDesc uintptr + GetVarDesc uintptr + GetNames uintptr + GetRefTypeOfImplType uintptr + GetImplTypeFlags uintptr + GetIDsOfNames uintptr + Invoke uintptr + GetDocumentation uintptr + GetDllEntry uintptr + GetRefTypeInfo uintptr + AddressOfMember uintptr + CreateInstance uintptr + GetMops uintptr + GetContainingTypeLib uintptr + ReleaseTypeAttr uintptr + ReleaseFuncDesc uintptr + ReleaseVarDesc uintptr +} + +func (v *ITypeInfo) VTable() *ITypeInfoVtbl { + return (*ITypeInfoVtbl)(unsafe.Pointer(v.RawVTable)) +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/itypeinfo_func.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/itypeinfo_func.go new file mode 100644 index 0000000000..8364a659ba --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/itypeinfo_func.go @@ -0,0 +1,7 @@ +// +build !windows + +package ole + +func (v *ITypeInfo) GetTypeAttr() (*TYPEATTR, error) { + return nil, NewError(E_NOTIMPL) +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/itypeinfo_windows.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/itypeinfo_windows.go new file mode 100644 index 0000000000..54782b3da5 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/itypeinfo_windows.go @@ -0,0 +1,21 @@ +// +build windows + +package ole + +import ( + "syscall" + "unsafe" +) + +func (v *ITypeInfo) GetTypeAttr() (tattr *TYPEATTR, err error) { + hr, _, _ := syscall.Syscall( + uintptr(v.VTable().GetTypeAttr), + 2, + uintptr(unsafe.Pointer(v)), + uintptr(unsafe.Pointer(&tattr)), + 0) + if hr != 0 { + err = NewError(hr) + } + return +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iunknown.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iunknown.go new file mode 100644 index 0000000000..108f28ea61 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/iunknown.go @@ -0,0 +1,57 @@ +package ole + +import "unsafe" + +type IUnknown struct { + RawVTable *interface{} +} + +type IUnknownVtbl struct { + QueryInterface uintptr + AddRef uintptr + Release uintptr +} + +type UnknownLike interface { + QueryInterface(iid *GUID) (disp *IDispatch, err error) + AddRef() int32 + Release() int32 +} + +func (v *IUnknown) VTable() *IUnknownVtbl { + return (*IUnknownVtbl)(unsafe.Pointer(v.RawVTable)) +} + +func (v *IUnknown) PutQueryInterface(interfaceID *GUID, obj interface{}) error { + return reflectQueryInterface(v, v.VTable().QueryInterface, interfaceID, obj) +} + +func (v *IUnknown) IDispatch(interfaceID *GUID) (dispatch *IDispatch, err error) { + err = v.PutQueryInterface(interfaceID, &dispatch) + return +} + +func (v *IUnknown) IEnumVARIANT(interfaceID *GUID) (enum *IEnumVARIANT, err error) { + err = v.PutQueryInterface(interfaceID, &enum) + return +} + +func (v *IUnknown) QueryInterface(iid *GUID) (*IDispatch, error) { + return queryInterface(v, iid) +} + +func (v *IUnknown) MustQueryInterface(iid *GUID) (disp *IDispatch) { + unk, err := queryInterface(v, iid) + if err != nil { + panic(err) + } + return unk +} + +func (v *IUnknown) AddRef() int32 { + return addRef(v) +} + +func (v *IUnknown) Release() int32 { + return release(v) +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iunknown_func.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iunknown_func.go new file mode 100644 index 0000000000..d0a62cfd73 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/iunknown_func.go @@ -0,0 +1,19 @@ +// +build !windows + +package ole + +func reflectQueryInterface(self interface{}, method uintptr, interfaceID *GUID, obj interface{}) (err error) { + return NewError(E_NOTIMPL) +} + +func queryInterface(unk *IUnknown, iid *GUID) (disp *IDispatch, err error) { + return nil, NewError(E_NOTIMPL) +} + +func addRef(unk *IUnknown) int32 { + return 0 +} + +func release(unk *IUnknown) int32 { + return 0 +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iunknown_windows.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iunknown_windows.go new file mode 100644 index 0000000000..ede5bb8c17 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/iunknown_windows.go @@ -0,0 +1,58 @@ +// +build windows + +package ole + +import ( + "reflect" + "syscall" + "unsafe" +) + +func reflectQueryInterface(self interface{}, method uintptr, interfaceID *GUID, obj interface{}) (err error) { + selfValue := reflect.ValueOf(self).Elem() + objValue := reflect.ValueOf(obj).Elem() + + hr, _, _ := syscall.Syscall( + method, + 3, + selfValue.UnsafeAddr(), + uintptr(unsafe.Pointer(interfaceID)), + objValue.Addr().Pointer()) + if hr != 0 { + err = NewError(hr) + } + return +} + +func queryInterface(unk *IUnknown, iid *GUID) (disp *IDispatch, err error) { + hr, _, _ := syscall.Syscall( + unk.VTable().QueryInterface, + 3, + uintptr(unsafe.Pointer(unk)), + uintptr(unsafe.Pointer(iid)), + uintptr(unsafe.Pointer(&disp))) + if hr != 0 { + err = NewError(hr) + } + return +} + +func addRef(unk *IUnknown) int32 { + ret, _, _ := syscall.Syscall( + unk.VTable().AddRef, + 1, + uintptr(unsafe.Pointer(unk)), + 0, + 0) + return int32(ret) +} + +func release(unk *IUnknown) int32 { + ret, _, _ := syscall.Syscall( + unk.VTable().Release, + 1, + uintptr(unsafe.Pointer(unk)), + 0, + 0) + return int32(ret) +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/ole.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/ole.go new file mode 100644 index 0000000000..b92b4ea189 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/ole.go @@ -0,0 +1,147 @@ +package ole + +import ( + "fmt" + "strings" +) + +// DISPPARAMS are the arguments that passed to methods or property. +type DISPPARAMS struct { + rgvarg uintptr + rgdispidNamedArgs uintptr + cArgs uint32 + cNamedArgs uint32 +} + +// EXCEPINFO defines exception info. +type EXCEPINFO struct { + wCode uint16 + wReserved uint16 + bstrSource *uint16 + bstrDescription *uint16 + bstrHelpFile *uint16 + dwHelpContext uint32 + pvReserved uintptr + pfnDeferredFillIn uintptr + scode uint32 +} + +// String convert EXCEPINFO to string. +func (e EXCEPINFO) String() string { + var src, desc, hlp string + if e.bstrSource == nil { + src = "" + } else { + src = BstrToString(e.bstrSource) + } + + if e.bstrDescription == nil { + desc = "" + } else { + desc = BstrToString(e.bstrDescription) + } + + if e.bstrHelpFile == nil { + hlp = "" + } else { + hlp = BstrToString(e.bstrHelpFile) + } + + return fmt.Sprintf( + "wCode: %#x, bstrSource: %v, bstrDescription: %v, bstrHelpFile: %v, dwHelpContext: %#x, scode: %#x", + e.wCode, src, desc, hlp, e.dwHelpContext, e.scode, + ) +} + +// Error implements error interface and returns error string. +func (e EXCEPINFO) Error() string { + if e.bstrDescription != nil { + return strings.TrimSpace(BstrToString(e.bstrDescription)) + } + + src := "Unknown" + if e.bstrSource != nil { + src = BstrToString(e.bstrSource) + } + + code := e.scode + if e.wCode != 0 { + code = uint32(e.wCode) + } + + return fmt.Sprintf("%v: %#x", src, code) +} + +// PARAMDATA defines parameter data type. +type PARAMDATA struct { + Name *int16 + Vt uint16 +} + +// METHODDATA defines method info. +type METHODDATA struct { + Name *uint16 + Data *PARAMDATA + Dispid int32 + Meth uint32 + CC int32 + CArgs uint32 + Flags uint16 + VtReturn uint32 +} + +// INTERFACEDATA defines interface info. +type INTERFACEDATA struct { + MethodData *METHODDATA + CMembers uint32 +} + +// Point is 2D vector type. +type Point struct { + X int32 + Y int32 +} + +// Msg is message between processes. +type Msg struct { + Hwnd uint32 + Message uint32 + Wparam int32 + Lparam int32 + Time uint32 + Pt Point +} + +// TYPEDESC defines data type. +type TYPEDESC struct { + Hreftype uint32 + VT uint16 +} + +// IDLDESC defines IDL info. +type IDLDESC struct { + DwReserved uint32 + WIDLFlags uint16 +} + +// TYPEATTR defines type info. +type TYPEATTR struct { + Guid GUID + Lcid uint32 + dwReserved uint32 + MemidConstructor int32 + MemidDestructor int32 + LpstrSchema *uint16 + CbSizeInstance uint32 + Typekind int32 + CFuncs uint16 + CVars uint16 + CImplTypes uint16 + CbSizeVft uint16 + CbAlignment uint16 + WTypeFlags uint16 + WMajorVerNum uint16 + WMinorVerNum uint16 + TdescAlias TYPEDESC + IdldescType IDLDESC +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/connection.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/connection.go new file mode 100644 index 0000000000..60df73cda0 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/connection.go @@ -0,0 +1,100 @@ +// +build windows + +package oleutil + +import ( + "reflect" + "unsafe" + + ole "github.com/go-ole/go-ole" +) + +type stdDispatch struct { + lpVtbl *stdDispatchVtbl + ref int32 + iid *ole.GUID + iface interface{} + funcMap map[string]int32 +} + +type stdDispatchVtbl struct { + pQueryInterface uintptr + pAddRef uintptr + pRelease uintptr + pGetTypeInfoCount uintptr + pGetTypeInfo uintptr + pGetIDsOfNames uintptr + pInvoke uintptr +} + +func dispQueryInterface(this *ole.IUnknown, iid *ole.GUID, punk **ole.IUnknown) uint32 { + pthis := (*stdDispatch)(unsafe.Pointer(this)) + *punk = nil + if ole.IsEqualGUID(iid, ole.IID_IUnknown) || + ole.IsEqualGUID(iid, ole.IID_IDispatch) { + dispAddRef(this) + *punk = this + return ole.S_OK + } + if ole.IsEqualGUID(iid, pthis.iid) { + dispAddRef(this) + *punk = this + return ole.S_OK + } + return ole.E_NOINTERFACE +} + +func dispAddRef(this *ole.IUnknown) int32 { + pthis := (*stdDispatch)(unsafe.Pointer(this)) + pthis.ref++ + return pthis.ref +} + +func dispRelease(this *ole.IUnknown) int32 { + pthis := (*stdDispatch)(unsafe.Pointer(this)) + pthis.ref-- + return pthis.ref +} + +func dispGetIDsOfNames(this *ole.IUnknown, iid *ole.GUID, wnames []*uint16, namelen int, lcid int, pdisp []int32) uintptr { + pthis := (*stdDispatch)(unsafe.Pointer(this)) + names := make([]string, len(wnames)) + for i := 0; i < len(names); i++ { + names[i] = ole.LpOleStrToString(wnames[i]) + } + for n := 0; n < namelen; n++ { + if id, ok := pthis.funcMap[names[n]]; ok { + pdisp[n] = id + } + } + return ole.S_OK +} + +func dispGetTypeInfoCount(pcount *int) uintptr { + if pcount != nil { + *pcount = 0 + } + return ole.S_OK +} + +func dispGetTypeInfo(ptypeif *uintptr) uintptr { + return ole.E_NOTIMPL +} + +func dispInvoke(this *ole.IDispatch, dispid int32, riid *ole.GUID, lcid int, flags int16, dispparams *ole.DISPPARAMS, result *ole.VARIANT, pexcepinfo *ole.EXCEPINFO, nerr *uint) uintptr { + pthis := (*stdDispatch)(unsafe.Pointer(this)) + found := "" + for name, id := range pthis.funcMap { + if id == dispid { + found = name + } + } + if found != "" { + rv := reflect.ValueOf(pthis.iface).Elem() + rm := rv.MethodByName(found) + rr := rm.Call([]reflect.Value{}) + println(len(rr)) + return ole.S_OK + } + return ole.E_NOTIMPL +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/connection_func.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/connection_func.go new file mode 100644 index 0000000000..8818fb8275 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/connection_func.go @@ -0,0 +1,10 @@ +// +build !windows + +package oleutil + +import ole "github.com/go-ole/go-ole" + +// ConnectObject creates a connection point between two services for communication. +func ConnectObject(disp *ole.IDispatch, iid *ole.GUID, idisp interface{}) (uint32, error) { + return 0, ole.NewError(ole.E_NOTIMPL) +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/connection_windows.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/connection_windows.go new file mode 100644 index 0000000000..6b5c059993 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/connection_windows.go @@ -0,0 +1,57 @@ +// +build windows + +package oleutil + +import ( + "reflect" + "syscall" + "unsafe" + + ole "github.com/go-ole/go-ole" +) + +// ConnectObject creates a connection point between two services for communication. +func ConnectObject(disp *ole.IDispatch, iid *ole.GUID, idisp interface{}) (cookie uint32, err error) { + unknown, err := disp.QueryInterface(ole.IID_IConnectionPointContainer) + if err != nil { + return + } + + container := (*ole.IConnectionPointContainer)(unsafe.Pointer(unknown)) + var point *ole.IConnectionPoint + err = container.FindConnectionPoint(iid, &point) + if err != nil { + return + } + if edisp, ok := idisp.(*ole.IUnknown); ok { + cookie, err = point.Advise(edisp) + container.Release() + if err != nil { + return + } + } + rv := reflect.ValueOf(disp).Elem() + if rv.Type().Kind() == reflect.Struct { + dest := &stdDispatch{} + dest.lpVtbl = &stdDispatchVtbl{} + dest.lpVtbl.pQueryInterface = syscall.NewCallback(dispQueryInterface) + dest.lpVtbl.pAddRef = syscall.NewCallback(dispAddRef) + dest.lpVtbl.pRelease = syscall.NewCallback(dispRelease) + dest.lpVtbl.pGetTypeInfoCount = syscall.NewCallback(dispGetTypeInfoCount) + dest.lpVtbl.pGetTypeInfo = syscall.NewCallback(dispGetTypeInfo) + dest.lpVtbl.pGetIDsOfNames = syscall.NewCallback(dispGetIDsOfNames) + dest.lpVtbl.pInvoke = syscall.NewCallback(dispInvoke) + dest.iface = disp + dest.iid = iid + cookie, err = point.Advise((*ole.IUnknown)(unsafe.Pointer(dest))) + container.Release() + if err != nil { + point.Release() + return + } + } + + container.Release() + + return 0, ole.NewError(ole.E_INVALIDARG) +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/go-get.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/go-get.go new file mode 100644 index 0000000000..58347628f2 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/go-get.go @@ -0,0 +1,6 @@ +// This file is here so go get succeeds as without it errors with: +// no buildable Go source files in ... +// +// +build !windows + +package oleutil diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/oleutil.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/oleutil.go new file mode 100644 index 0000000000..55e072a636 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/oleutil.go @@ -0,0 +1,89 @@ +package oleutil + +import ole "github.com/go-ole/go-ole" + +// ClassIDFrom retrieves class ID whether given is program ID or application string. +func ClassIDFrom(programID string) (classID *ole.GUID, err error) { + return ole.ClassIDFrom(programID) +} + +// CreateObject creates object from programID based on interface type. +// +// Only supports IUnknown. +// +// Program ID can be either program ID or application string. +func CreateObject(programID string) (unknown *ole.IUnknown, err error) { + classID, err := ole.ClassIDFrom(programID) + if err != nil { + return + } + + unknown, err = ole.CreateInstance(classID, ole.IID_IUnknown) + if err != nil { + return + } + + return +} + +// GetActiveObject retrieves active object for program ID and interface ID based +// on interface type. +// +// Only supports IUnknown. +// +// Program ID can be either program ID or application string. +func GetActiveObject(programID string) (unknown *ole.IUnknown, err error) { + classID, err := ole.ClassIDFrom(programID) + if err != nil { + return + } + + unknown, err = ole.GetActiveObject(classID, ole.IID_IUnknown) + if err != nil { + return + } + + return +} + +// CallMethod calls method on IDispatch with parameters. +func CallMethod(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT, err error) { + return disp.InvokeWithOptionalArgs(name, ole.DISPATCH_METHOD, params) +} + +// MustCallMethod calls method on IDispatch with parameters or panics. +func MustCallMethod(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT) { + r, err := CallMethod(disp, name, params...) + if err != nil { + panic(err.Error()) + } + return r +} + +// GetProperty retrieves property from IDispatch. +func GetProperty(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT, err error) { + return disp.InvokeWithOptionalArgs(name, ole.DISPATCH_PROPERTYGET, params) +} + +// MustGetProperty retrieves property from IDispatch or panics. +func MustGetProperty(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT) { + r, err := GetProperty(disp, name, params...) + if err != nil { + panic(err.Error()) + } + return r +} + +// PutProperty mutates property. +func PutProperty(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT, err error) { + return disp.InvokeWithOptionalArgs(name, ole.DISPATCH_PROPERTYPUT, params) +} + +// MustPutProperty mutates property or panics. +func MustPutProperty(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT) { + r, err := PutProperty(disp, name, params...) + if err != nil { + panic(err.Error()) + } + return r +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/safearray.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/safearray.go new file mode 100644 index 0000000000..a5201b56c3 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/safearray.go @@ -0,0 +1,27 @@ +// Package is meant to retrieve and process safe array data returned from COM. + +package ole + +// SafeArrayBound defines the SafeArray boundaries. +type SafeArrayBound struct { + Elements uint32 + LowerBound int32 +} + +// SafeArray is how COM handles arrays. +type SafeArray struct { + Dimensions uint16 + FeaturesFlag uint16 + ElementsSize uint32 + LocksAmount uint32 + Data uint32 + Bounds [16]byte +} + +// SAFEARRAY is obsolete, exists for backwards compatibility. +// Use SafeArray +type SAFEARRAY SafeArray + +// SAFEARRAYBOUND is obsolete, exists for backwards compatibility. +// Use SafeArrayBound +type SAFEARRAYBOUND SafeArrayBound diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/safearray_func.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/safearray_func.go new file mode 100644 index 0000000000..8ff0baa41d --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/safearray_func.go @@ -0,0 +1,211 @@ +// +build !windows + +package ole + +import ( + "unsafe" +) + +// safeArrayAccessData returns raw array pointer. +// +// AKA: SafeArrayAccessData in Windows API. +func safeArrayAccessData(safearray *SafeArray) (uintptr, error) { + return uintptr(0), NewError(E_NOTIMPL) +} + +// safeArrayUnaccessData releases raw array. +// +// AKA: SafeArrayUnaccessData in Windows API. +func safeArrayUnaccessData(safearray *SafeArray) error { + return NewError(E_NOTIMPL) +} + +// safeArrayAllocData allocates SafeArray. +// +// AKA: SafeArrayAllocData in Windows API. +func safeArrayAllocData(safearray *SafeArray) error { + return NewError(E_NOTIMPL) +} + +// safeArrayAllocDescriptor allocates SafeArray. +// +// AKA: SafeArrayAllocDescriptor in Windows API. +func safeArrayAllocDescriptor(dimensions uint32) (*SafeArray, error) { + return nil, NewError(E_NOTIMPL) +} + +// safeArrayAllocDescriptorEx allocates SafeArray. +// +// AKA: SafeArrayAllocDescriptorEx in Windows API. +func safeArrayAllocDescriptorEx(variantType VT, dimensions uint32) (*SafeArray, error) { + return nil, NewError(E_NOTIMPL) +} + +// safeArrayCopy returns copy of SafeArray. +// +// AKA: SafeArrayCopy in Windows API. +func safeArrayCopy(original *SafeArray) (*SafeArray, error) { + return nil, NewError(E_NOTIMPL) +} + +// safeArrayCopyData duplicates SafeArray into another SafeArray object. +// +// AKA: SafeArrayCopyData in Windows API. +func safeArrayCopyData(original *SafeArray, duplicate *SafeArray) error { + return NewError(E_NOTIMPL) +} + +// safeArrayCreate creates SafeArray. +// +// AKA: SafeArrayCreate in Windows API. +func safeArrayCreate(variantType VT, dimensions uint32, bounds *SafeArrayBound) (*SafeArray, error) { + return nil, NewError(E_NOTIMPL) +} + +// safeArrayCreateEx creates SafeArray. +// +// AKA: SafeArrayCreateEx in Windows API. +func safeArrayCreateEx(variantType VT, dimensions uint32, bounds *SafeArrayBound, extra uintptr) (*SafeArray, error) { + return nil, NewError(E_NOTIMPL) +} + +// safeArrayCreateVector creates SafeArray. +// +// AKA: SafeArrayCreateVector in Windows API. +func safeArrayCreateVector(variantType VT, lowerBound int32, length uint32) (*SafeArray, error) { + return nil, NewError(E_NOTIMPL) +} + +// safeArrayCreateVectorEx creates SafeArray. +// +// AKA: SafeArrayCreateVectorEx in Windows API. +func safeArrayCreateVectorEx(variantType VT, lowerBound int32, length uint32, extra uintptr) (*SafeArray, error) { + return nil, NewError(E_NOTIMPL) +} + +// safeArrayDestroy destroys SafeArray object. +// +// AKA: SafeArrayDestroy in Windows API. +func safeArrayDestroy(safearray *SafeArray) error { + return NewError(E_NOTIMPL) +} + +// safeArrayDestroyData destroys SafeArray object. +// +// AKA: SafeArrayDestroyData in Windows API. +func safeArrayDestroyData(safearray *SafeArray) error { + return NewError(E_NOTIMPL) +} + +// safeArrayDestroyDescriptor destroys SafeArray object. +// +// AKA: SafeArrayDestroyDescriptor in Windows API. +func safeArrayDestroyDescriptor(safearray *SafeArray) error { + return NewError(E_NOTIMPL) +} + +// safeArrayGetDim is the amount of dimensions in the SafeArray. +// +// SafeArrays may have multiple dimensions. Meaning, it could be +// multidimensional array. +// +// AKA: SafeArrayGetDim in Windows API. +func safeArrayGetDim(safearray *SafeArray) (*uint32, error) { + u := uint32(0) + return &u, NewError(E_NOTIMPL) +} + +// safeArrayGetElementSize is the element size in bytes. +// +// AKA: SafeArrayGetElemsize in Windows API. +func safeArrayGetElementSize(safearray *SafeArray) (*uint32, error) { + u := uint32(0) + return &u, NewError(E_NOTIMPL) +} + +// safeArrayGetElement retrieves element at given index. +func safeArrayGetElement(safearray *SafeArray, index int64, pv unsafe.Pointer) error { + return NewError(E_NOTIMPL) +} + +// safeArrayGetElement retrieves element at given index and converts to string. +func safeArrayGetElementString(safearray *SafeArray, index int64) (string, error) { + return "", NewError(E_NOTIMPL) +} + +// safeArrayGetIID is the InterfaceID of the elements in the SafeArray. +// +// AKA: SafeArrayGetIID in Windows API. +func safeArrayGetIID(safearray *SafeArray) (*GUID, error) { + return nil, NewError(E_NOTIMPL) +} + +// safeArrayGetLBound returns lower bounds of SafeArray. +// +// SafeArrays may have multiple dimensions. Meaning, it could be +// multidimensional array. +// +// AKA: SafeArrayGetLBound in Windows API. +func safeArrayGetLBound(safearray *SafeArray, dimension uint32) (int64, error) { + return int64(0), NewError(E_NOTIMPL) +} + +// safeArrayGetUBound returns upper bounds of SafeArray. +// +// SafeArrays may have multiple dimensions. Meaning, it could be +// multidimensional array. +// +// AKA: SafeArrayGetUBound in Windows API. +func safeArrayGetUBound(safearray *SafeArray, dimension uint32) (int64, error) { + return int64(0), NewError(E_NOTIMPL) +} + +// safeArrayGetVartype returns data type of SafeArray. +// +// AKA: SafeArrayGetVartype in Windows API. +func safeArrayGetVartype(safearray *SafeArray) (uint16, error) { + return uint16(0), NewError(E_NOTIMPL) +} + +// safeArrayLock locks SafeArray for reading to modify SafeArray. +// +// This must be called during some calls to ensure that another process does not +// read or write to the SafeArray during editing. +// +// AKA: SafeArrayLock in Windows API. +func safeArrayLock(safearray *SafeArray) error { + return NewError(E_NOTIMPL) +} + +// safeArrayUnlock unlocks SafeArray for reading. +// +// AKA: SafeArrayUnlock in Windows API. +func safeArrayUnlock(safearray *SafeArray) error { + return NewError(E_NOTIMPL) +} + +// safeArrayPutElement stores the data element at the specified location in the +// array. +// +// AKA: SafeArrayPutElement in Windows API. +func safeArrayPutElement(safearray *SafeArray, index int64, element uintptr) error { + return NewError(E_NOTIMPL) +} + +// safeArrayGetRecordInfo accesses IRecordInfo info for custom types. +// +// AKA: SafeArrayGetRecordInfo in Windows API. +// +// XXX: Must implement IRecordInfo interface for this to return. +func safeArrayGetRecordInfo(safearray *SafeArray) (interface{}, error) { + return nil, NewError(E_NOTIMPL) +} + +// safeArraySetRecordInfo mutates IRecordInfo info for custom types. +// +// AKA: SafeArraySetRecordInfo in Windows API. +// +// XXX: Must implement IRecordInfo interface for this to return. +func safeArraySetRecordInfo(safearray *SafeArray, recordInfo interface{}) error { + return NewError(E_NOTIMPL) +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/safearray_windows.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/safearray_windows.go new file mode 100644 index 0000000000..b27936e24e --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/safearray_windows.go @@ -0,0 +1,337 @@ +// +build windows + +package ole + +import ( + "unsafe" +) + +var ( + procSafeArrayAccessData, _ = modoleaut32.FindProc("SafeArrayAccessData") + procSafeArrayAllocData, _ = modoleaut32.FindProc("SafeArrayAllocData") + procSafeArrayAllocDescriptor, _ = modoleaut32.FindProc("SafeArrayAllocDescriptor") + procSafeArrayAllocDescriptorEx, _ = modoleaut32.FindProc("SafeArrayAllocDescriptorEx") + procSafeArrayCopy, _ = modoleaut32.FindProc("SafeArrayCopy") + procSafeArrayCopyData, _ = modoleaut32.FindProc("SafeArrayCopyData") + procSafeArrayCreate, _ = modoleaut32.FindProc("SafeArrayCreate") + procSafeArrayCreateEx, _ = modoleaut32.FindProc("SafeArrayCreateEx") + procSafeArrayCreateVector, _ = modoleaut32.FindProc("SafeArrayCreateVector") + procSafeArrayCreateVectorEx, _ = modoleaut32.FindProc("SafeArrayCreateVectorEx") + procSafeArrayDestroy, _ = modoleaut32.FindProc("SafeArrayDestroy") + procSafeArrayDestroyData, _ = modoleaut32.FindProc("SafeArrayDestroyData") + procSafeArrayDestroyDescriptor, _ = modoleaut32.FindProc("SafeArrayDestroyDescriptor") + procSafeArrayGetDim, _ = modoleaut32.FindProc("SafeArrayGetDim") + procSafeArrayGetElement, _ = modoleaut32.FindProc("SafeArrayGetElement") + procSafeArrayGetElemsize, _ = modoleaut32.FindProc("SafeArrayGetElemsize") + procSafeArrayGetIID, _ = modoleaut32.FindProc("SafeArrayGetIID") + procSafeArrayGetLBound, _ = modoleaut32.FindProc("SafeArrayGetLBound") + procSafeArrayGetUBound, _ = modoleaut32.FindProc("SafeArrayGetUBound") + procSafeArrayGetVartype, _ = modoleaut32.FindProc("SafeArrayGetVartype") + procSafeArrayLock, _ = modoleaut32.FindProc("SafeArrayLock") + procSafeArrayPtrOfIndex, _ = modoleaut32.FindProc("SafeArrayPtrOfIndex") + procSafeArrayUnaccessData, _ = modoleaut32.FindProc("SafeArrayUnaccessData") + procSafeArrayUnlock, _ = modoleaut32.FindProc("SafeArrayUnlock") + procSafeArrayPutElement, _ = modoleaut32.FindProc("SafeArrayPutElement") + //procSafeArrayRedim, _ = modoleaut32.FindProc("SafeArrayRedim") // TODO + //procSafeArraySetIID, _ = modoleaut32.FindProc("SafeArraySetIID") // TODO + procSafeArrayGetRecordInfo, _ = modoleaut32.FindProc("SafeArrayGetRecordInfo") + procSafeArraySetRecordInfo, _ = modoleaut32.FindProc("SafeArraySetRecordInfo") +) + +// safeArrayAccessData returns raw array pointer. +// +// AKA: SafeArrayAccessData in Windows API. +// Todo: Test +func safeArrayAccessData(safearray *SafeArray) (element uintptr, err error) { + err = convertHresultToError( + procSafeArrayAccessData.Call( + uintptr(unsafe.Pointer(safearray)), + uintptr(unsafe.Pointer(&element)))) + return +} + +// safeArrayUnaccessData releases raw array. +// +// AKA: SafeArrayUnaccessData in Windows API. +func safeArrayUnaccessData(safearray *SafeArray) (err error) { + err = convertHresultToError(procSafeArrayUnaccessData.Call(uintptr(unsafe.Pointer(safearray)))) + return +} + +// safeArrayAllocData allocates SafeArray. +// +// AKA: SafeArrayAllocData in Windows API. +func safeArrayAllocData(safearray *SafeArray) (err error) { + err = convertHresultToError(procSafeArrayAllocData.Call(uintptr(unsafe.Pointer(safearray)))) + return +} + +// safeArrayAllocDescriptor allocates SafeArray. +// +// AKA: SafeArrayAllocDescriptor in Windows API. +func safeArrayAllocDescriptor(dimensions uint32) (safearray *SafeArray, err error) { + err = convertHresultToError( + procSafeArrayAllocDescriptor.Call(uintptr(dimensions), uintptr(unsafe.Pointer(&safearray)))) + return +} + +// safeArrayAllocDescriptorEx allocates SafeArray. +// +// AKA: SafeArrayAllocDescriptorEx in Windows API. +func safeArrayAllocDescriptorEx(variantType VT, dimensions uint32) (safearray *SafeArray, err error) { + err = convertHresultToError( + procSafeArrayAllocDescriptorEx.Call( + uintptr(variantType), + uintptr(dimensions), + uintptr(unsafe.Pointer(&safearray)))) + return +} + +// safeArrayCopy returns copy of SafeArray. +// +// AKA: SafeArrayCopy in Windows API. +func safeArrayCopy(original *SafeArray) (safearray *SafeArray, err error) { + err = convertHresultToError( + procSafeArrayCopy.Call( + uintptr(unsafe.Pointer(original)), + uintptr(unsafe.Pointer(&safearray)))) + return +} + +// safeArrayCopyData duplicates SafeArray into another SafeArray object. +// +// AKA: SafeArrayCopyData in Windows API. +func safeArrayCopyData(original *SafeArray, duplicate *SafeArray) (err error) { + err = convertHresultToError( + procSafeArrayCopyData.Call( + uintptr(unsafe.Pointer(original)), + uintptr(unsafe.Pointer(duplicate)))) + return +} + +// safeArrayCreate creates SafeArray. +// +// AKA: SafeArrayCreate in Windows API. +func safeArrayCreate(variantType VT, dimensions uint32, bounds *SafeArrayBound) (safearray *SafeArray, err error) { + sa, _, err := procSafeArrayCreate.Call( + uintptr(variantType), + uintptr(dimensions), + uintptr(unsafe.Pointer(bounds))) + safearray = (*SafeArray)(unsafe.Pointer(&sa)) + return +} + +// safeArrayCreateEx creates SafeArray. +// +// AKA: SafeArrayCreateEx in Windows API. +func safeArrayCreateEx(variantType VT, dimensions uint32, bounds *SafeArrayBound, extra uintptr) (safearray *SafeArray, err error) { + sa, _, err := procSafeArrayCreateEx.Call( + uintptr(variantType), + uintptr(dimensions), + uintptr(unsafe.Pointer(bounds)), + extra) + safearray = (*SafeArray)(unsafe.Pointer(sa)) + return +} + +// safeArrayCreateVector creates SafeArray. +// +// AKA: SafeArrayCreateVector in Windows API. +func safeArrayCreateVector(variantType VT, lowerBound int32, length uint32) (safearray *SafeArray, err error) { + sa, _, err := procSafeArrayCreateVector.Call( + uintptr(variantType), + uintptr(lowerBound), + uintptr(length)) + safearray = (*SafeArray)(unsafe.Pointer(sa)) + return +} + +// safeArrayCreateVectorEx creates SafeArray. +// +// AKA: SafeArrayCreateVectorEx in Windows API. +func safeArrayCreateVectorEx(variantType VT, lowerBound int32, length uint32, extra uintptr) (safearray *SafeArray, err error) { + sa, _, err := procSafeArrayCreateVectorEx.Call( + uintptr(variantType), + uintptr(lowerBound), + uintptr(length), + extra) + safearray = (*SafeArray)(unsafe.Pointer(sa)) + return +} + +// safeArrayDestroy destroys SafeArray object. +// +// AKA: SafeArrayDestroy in Windows API. +func safeArrayDestroy(safearray *SafeArray) (err error) { + err = convertHresultToError(procSafeArrayDestroy.Call(uintptr(unsafe.Pointer(safearray)))) + return +} + +// safeArrayDestroyData destroys SafeArray object. +// +// AKA: SafeArrayDestroyData in Windows API. +func safeArrayDestroyData(safearray *SafeArray) (err error) { + err = convertHresultToError(procSafeArrayDestroyData.Call(uintptr(unsafe.Pointer(safearray)))) + return +} + +// safeArrayDestroyDescriptor destroys SafeArray object. +// +// AKA: SafeArrayDestroyDescriptor in Windows API. +func safeArrayDestroyDescriptor(safearray *SafeArray) (err error) { + err = convertHresultToError(procSafeArrayDestroyDescriptor.Call(uintptr(unsafe.Pointer(safearray)))) + return +} + +// safeArrayGetDim is the amount of dimensions in the SafeArray. +// +// SafeArrays may have multiple dimensions. Meaning, it could be +// multidimensional array. +// +// AKA: SafeArrayGetDim in Windows API. +func safeArrayGetDim(safearray *SafeArray) (dimensions *uint32, err error) { + l, _, err := procSafeArrayGetDim.Call(uintptr(unsafe.Pointer(safearray))) + dimensions = (*uint32)(unsafe.Pointer(l)) + return +} + +// safeArrayGetElementSize is the element size in bytes. +// +// AKA: SafeArrayGetElemsize in Windows API. +func safeArrayGetElementSize(safearray *SafeArray) (length *uint32, err error) { + l, _, err := procSafeArrayGetElemsize.Call(uintptr(unsafe.Pointer(safearray))) + length = (*uint32)(unsafe.Pointer(l)) + return +} + +// safeArrayGetElement retrieves element at given index. +func safeArrayGetElement(safearray *SafeArray, index int64, pv unsafe.Pointer) error { + return convertHresultToError( + procSafeArrayGetElement.Call( + uintptr(unsafe.Pointer(safearray)), + uintptr(unsafe.Pointer(&index)), + uintptr(pv))) +} + +// safeArrayGetElementString retrieves element at given index and converts to string. +func safeArrayGetElementString(safearray *SafeArray, index int64) (str string, err error) { + var element *int16 + err = convertHresultToError( + procSafeArrayGetElement.Call( + uintptr(unsafe.Pointer(safearray)), + uintptr(unsafe.Pointer(&index)), + uintptr(unsafe.Pointer(&element)))) + str = BstrToString(*(**uint16)(unsafe.Pointer(&element))) + SysFreeString(element) + return +} + +// safeArrayGetIID is the InterfaceID of the elements in the SafeArray. +// +// AKA: SafeArrayGetIID in Windows API. +func safeArrayGetIID(safearray *SafeArray) (guid *GUID, err error) { + err = convertHresultToError( + procSafeArrayGetIID.Call( + uintptr(unsafe.Pointer(safearray)), + uintptr(unsafe.Pointer(&guid)))) + return +} + +// safeArrayGetLBound returns lower bounds of SafeArray. +// +// SafeArrays may have multiple dimensions. Meaning, it could be +// multidimensional array. +// +// AKA: SafeArrayGetLBound in Windows API. +func safeArrayGetLBound(safearray *SafeArray, dimension uint32) (lowerBound int64, err error) { + err = convertHresultToError( + procSafeArrayGetLBound.Call( + uintptr(unsafe.Pointer(safearray)), + uintptr(dimension), + uintptr(unsafe.Pointer(&lowerBound)))) + return +} + +// safeArrayGetUBound returns upper bounds of SafeArray. +// +// SafeArrays may have multiple dimensions. Meaning, it could be +// multidimensional array. +// +// AKA: SafeArrayGetUBound in Windows API. +func safeArrayGetUBound(safearray *SafeArray, dimension uint32) (upperBound int64, err error) { + err = convertHresultToError( + procSafeArrayGetUBound.Call( + uintptr(unsafe.Pointer(safearray)), + uintptr(dimension), + uintptr(unsafe.Pointer(&upperBound)))) + return +} + +// safeArrayGetVartype returns data type of SafeArray. +// +// AKA: SafeArrayGetVartype in Windows API. +func safeArrayGetVartype(safearray *SafeArray) (varType uint16, err error) { + err = convertHresultToError( + procSafeArrayGetVartype.Call( + uintptr(unsafe.Pointer(safearray)), + uintptr(unsafe.Pointer(&varType)))) + return +} + +// safeArrayLock locks SafeArray for reading to modify SafeArray. +// +// This must be called during some calls to ensure that another process does not +// read or write to the SafeArray during editing. +// +// AKA: SafeArrayLock in Windows API. +func safeArrayLock(safearray *SafeArray) (err error) { + err = convertHresultToError(procSafeArrayLock.Call(uintptr(unsafe.Pointer(safearray)))) + return +} + +// safeArrayUnlock unlocks SafeArray for reading. +// +// AKA: SafeArrayUnlock in Windows API. +func safeArrayUnlock(safearray *SafeArray) (err error) { + err = convertHresultToError(procSafeArrayUnlock.Call(uintptr(unsafe.Pointer(safearray)))) + return +} + +// safeArrayPutElement stores the data element at the specified location in the +// array. +// +// AKA: SafeArrayPutElement in Windows API. +func safeArrayPutElement(safearray *SafeArray, index int64, element uintptr) (err error) { + err = convertHresultToError( + procSafeArrayPutElement.Call( + uintptr(unsafe.Pointer(safearray)), + uintptr(unsafe.Pointer(&index)), + uintptr(unsafe.Pointer(element)))) + return +} + +// safeArrayGetRecordInfo accesses IRecordInfo info for custom types. +// +// AKA: SafeArrayGetRecordInfo in Windows API. +// +// XXX: Must implement IRecordInfo interface for this to return. +func safeArrayGetRecordInfo(safearray *SafeArray) (recordInfo interface{}, err error) { + err = convertHresultToError( + procSafeArrayGetRecordInfo.Call( + uintptr(unsafe.Pointer(safearray)), + uintptr(unsafe.Pointer(&recordInfo)))) + return +} + +// safeArraySetRecordInfo mutates IRecordInfo info for custom types. +// +// AKA: SafeArraySetRecordInfo in Windows API. +// +// XXX: Must implement IRecordInfo interface for this to return. +func safeArraySetRecordInfo(safearray *SafeArray, recordInfo interface{}) (err error) { + err = convertHresultToError( + procSafeArraySetRecordInfo.Call( + uintptr(unsafe.Pointer(safearray)), + uintptr(unsafe.Pointer(&recordInfo)))) + return +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/safearrayconversion.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/safearrayconversion.go new file mode 100644 index 0000000000..ffeb2b97b0 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/safearrayconversion.go @@ -0,0 +1,140 @@ +// Helper for converting SafeArray to array of objects. + +package ole + +import ( + "unsafe" +) + +type SafeArrayConversion struct { + Array *SafeArray +} + +func (sac *SafeArrayConversion) ToStringArray() (strings []string) { + totalElements, _ := sac.TotalElements(0) + strings = make([]string, totalElements) + + for i := int64(0); i < totalElements; i++ { + strings[int32(i)], _ = safeArrayGetElementString(sac.Array, i) + } + + return +} + +func (sac *SafeArrayConversion) ToByteArray() (bytes []byte) { + totalElements, _ := sac.TotalElements(0) + bytes = make([]byte, totalElements) + + for i := int64(0); i < totalElements; i++ { + safeArrayGetElement(sac.Array, i, unsafe.Pointer(&bytes[int32(i)])) + } + + return +} + +func (sac *SafeArrayConversion) ToValueArray() (values []interface{}) { + totalElements, _ := sac.TotalElements(0) + values = make([]interface{}, totalElements) + vt, _ := safeArrayGetVartype(sac.Array) + + for i := 0; i < int(totalElements); i++ { + switch VT(vt) { + case VT_BOOL: + var v bool + safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) + values[i] = v + case VT_I1: + var v int8 + safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) + values[i] = v + case VT_I2: + var v int16 + safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) + values[i] = v + case VT_I4: + var v int32 + safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) + values[i] = v + case VT_I8: + var v int64 + safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) + values[i] = v + case VT_UI1: + var v uint8 + safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) + values[i] = v + case VT_UI2: + var v uint16 + safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) + values[i] = v + case VT_UI4: + var v uint32 + safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) + values[i] = v + case VT_UI8: + var v uint64 + safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) + values[i] = v + case VT_R4: + var v float32 + safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) + values[i] = v + case VT_R8: + var v float64 + safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) + values[i] = v + case VT_BSTR: + var v string + safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) + values[i] = v + case VT_VARIANT: + var v VARIANT + safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) + values[i] = v.Value() + default: + // TODO + } + } + + return +} + +func (sac *SafeArrayConversion) GetType() (varType uint16, err error) { + return safeArrayGetVartype(sac.Array) +} + +func (sac *SafeArrayConversion) GetDimensions() (dimensions *uint32, err error) { + return safeArrayGetDim(sac.Array) +} + +func (sac *SafeArrayConversion) GetSize() (length *uint32, err error) { + return safeArrayGetElementSize(sac.Array) +} + +func (sac *SafeArrayConversion) TotalElements(index uint32) (totalElements int64, err error) { + if index < 1 { + index = 1 + } + + // Get array bounds + var LowerBounds int64 + var UpperBounds int64 + + LowerBounds, err = safeArrayGetLBound(sac.Array, index) + if err != nil { + return + } + + UpperBounds, err = safeArrayGetUBound(sac.Array, index) + if err != nil { + return + } + + totalElements = UpperBounds - LowerBounds + 1 + return +} + +// Release Safe Array memory +func (sac *SafeArrayConversion) Release() { + safeArrayDestroy(sac.Array) +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/safearrayslices.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/safearrayslices.go new file mode 100644 index 0000000000..a9fa885f1d --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/safearrayslices.go @@ -0,0 +1,33 @@ +// +build windows + +package ole + +import ( + "unsafe" +) + +func safeArrayFromByteSlice(slice []byte) *SafeArray { + array, _ := safeArrayCreateVector(VT_UI1, 0, uint32(len(slice))) + + if array == nil { + panic("Could not convert []byte to SAFEARRAY") + } + + for i, v := range slice { + safeArrayPutElement(array, int64(i), uintptr(unsafe.Pointer(&v))) + } + return array +} + +func safeArrayFromStringSlice(slice []string) *SafeArray { + array, _ := safeArrayCreateVector(VT_BSTR, 0, uint32(len(slice))) + + if array == nil { + panic("Could not convert []string to SAFEARRAY") + } + // SysAllocStringLen(s) + for i, v := range slice { + safeArrayPutElement(array, int64(i), uintptr(unsafe.Pointer(SysAllocStringLen(v)))) + } + return array +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/utility.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/utility.go new file mode 100644 index 0000000000..99ee82dc34 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/utility.go @@ -0,0 +1,101 @@ +package ole + +import ( + "unicode/utf16" + "unsafe" +) + +// ClassIDFrom retrieves class ID whether given is program ID or application string. +// +// Helper that provides check against both Class ID from Program ID and Class ID from string. It is +// faster, if you know which you are using, to use the individual functions, but this will check +// against available functions for you. +func ClassIDFrom(programID string) (classID *GUID, err error) { + classID, err = CLSIDFromProgID(programID) + if err != nil { + classID, err = CLSIDFromString(programID) + if err != nil { + return + } + } + return +} + +// BytePtrToString converts byte pointer to a Go string. +func BytePtrToString(p *byte) string { + a := (*[10000]uint8)(unsafe.Pointer(p)) + i := 0 + for a[i] != 0 { + i++ + } + return string(a[:i]) +} + +// UTF16PtrToString is alias for LpOleStrToString. +// +// Kept for compatibility reasons. +func UTF16PtrToString(p *uint16) string { + return LpOleStrToString(p) +} + +// LpOleStrToString converts COM Unicode to Go string. +func LpOleStrToString(p *uint16) string { + if p == nil { + return "" + } + + length := lpOleStrLen(p) + a := make([]uint16, length) + + ptr := unsafe.Pointer(p) + + for i := 0; i < int(length); i++ { + a[i] = *(*uint16)(ptr) + ptr = unsafe.Pointer(uintptr(ptr) + 2) + } + + return string(utf16.Decode(a)) +} + +// BstrToString converts COM binary string to Go string. +func BstrToString(p *uint16) string { + if p == nil { + return "" + } + length := SysStringLen((*int16)(unsafe.Pointer(p))) + a := make([]uint16, length) + + ptr := unsafe.Pointer(p) + + for i := 0; i < int(length); i++ { + a[i] = *(*uint16)(ptr) + ptr = unsafe.Pointer(uintptr(ptr) + 2) + } + return string(utf16.Decode(a)) +} + +// lpOleStrLen returns the length of Unicode string. +func lpOleStrLen(p *uint16) (length int64) { + if p == nil { + return 0 + } + + ptr := unsafe.Pointer(p) + + for i := 0; ; i++ { + if 0 == *(*uint16)(ptr) { + length = int64(i) + break + } + ptr = unsafe.Pointer(uintptr(ptr) + 2) + } + return +} + +// convertHresultToError converts syscall to error, if call is unsuccessful. +func convertHresultToError(hr uintptr, r2 uintptr, ignore error) (err error) { + if hr != 0 { + err = NewError(hr) + } + return +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/variables.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/variables.go new file mode 100644 index 0000000000..ebe00f1cfc --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/variables.go @@ -0,0 +1,16 @@ +// +build windows + +package ole + +import ( + "syscall" +) + +var ( + modcombase = syscall.NewLazyDLL("combase.dll") + modkernel32, _ = syscall.LoadDLL("kernel32.dll") + modole32, _ = syscall.LoadDLL("ole32.dll") + modoleaut32, _ = syscall.LoadDLL("oleaut32.dll") + modmsvcrt, _ = syscall.LoadDLL("msvcrt.dll") + moduser32, _ = syscall.LoadDLL("user32.dll") +) diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/variant.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/variant.go new file mode 100644 index 0000000000..36969725eb --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/variant.go @@ -0,0 +1,105 @@ +package ole + +import "unsafe" + +// NewVariant returns new variant based on type and value. +func NewVariant(vt VT, val int64) VARIANT { + return VARIANT{VT: vt, Val: val} +} + +// ToIUnknown converts Variant to Unknown object. +func (v *VARIANT) ToIUnknown() *IUnknown { + if v.VT != VT_UNKNOWN { + return nil + } + return (*IUnknown)(unsafe.Pointer(uintptr(v.Val))) +} + +// ToIDispatch converts variant to dispatch object. +func (v *VARIANT) ToIDispatch() *IDispatch { + if v.VT != VT_DISPATCH { + return nil + } + return (*IDispatch)(unsafe.Pointer(uintptr(v.Val))) +} + +// ToArray converts variant to SafeArray helper. +func (v *VARIANT) ToArray() *SafeArrayConversion { + if v.VT != VT_SAFEARRAY { + if v.VT&VT_ARRAY == 0 { + return nil + } + } + var safeArray *SafeArray = (*SafeArray)(unsafe.Pointer(uintptr(v.Val))) + return &SafeArrayConversion{safeArray} +} + +// ToString converts variant to Go string. +func (v *VARIANT) ToString() string { + if v.VT != VT_BSTR { + return "" + } + return BstrToString(*(**uint16)(unsafe.Pointer(&v.Val))) +} + +// Clear the memory of variant object. +func (v *VARIANT) Clear() error { + return VariantClear(v) +} + +// Value returns variant value based on its type. +// +// Currently supported types: 2- and 4-byte integers, strings, bools. +// Note that 64-bit integers, datetimes, and other types are stored as strings +// and will be returned as strings. +// +// Needs to be further converted, because this returns an interface{}. +func (v *VARIANT) Value() interface{} { + switch v.VT { + case VT_I1: + return int8(v.Val) + case VT_UI1: + return uint8(v.Val) + case VT_I2: + return int16(v.Val) + case VT_UI2: + return uint16(v.Val) + case VT_I4: + return int32(v.Val) + case VT_UI4: + return uint32(v.Val) + case VT_I8: + return int64(v.Val) + case VT_UI8: + return uint64(v.Val) + case VT_INT: + return int(v.Val) + case VT_UINT: + return uint(v.Val) + case VT_INT_PTR: + return uintptr(v.Val) // TODO + case VT_UINT_PTR: + return uintptr(v.Val) + case VT_R4: + return *(*float32)(unsafe.Pointer(&v.Val)) + case VT_R8: + return *(*float64)(unsafe.Pointer(&v.Val)) + case VT_BSTR: + return v.ToString() + case VT_DATE: + // VT_DATE type will either return float64 or time.Time. + d := float64(v.Val) + date, err := GetVariantDate(d) + if err != nil { + return d + } + return date + case VT_UNKNOWN: + return v.ToIUnknown() + case VT_DISPATCH: + return v.ToIDispatch() + case VT_BOOL: + return v.Val != 0 + } + return nil +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/variant_386.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/variant_386.go new file mode 100644 index 0000000000..e73736bf39 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/variant_386.go @@ -0,0 +1,11 @@ +// +build 386 + +package ole + +type VARIANT struct { + VT VT // 2 + wReserved1 uint16 // 4 + wReserved2 uint16 // 6 + wReserved3 uint16 // 8 + Val int64 // 16 +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/variant_amd64.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/variant_amd64.go new file mode 100644 index 0000000000..dccdde1323 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/variant_amd64.go @@ -0,0 +1,12 @@ +// +build amd64 + +package ole + +type VARIANT struct { + VT VT // 2 + wReserved1 uint16 // 4 + wReserved2 uint16 // 6 + wReserved3 uint16 // 8 + Val int64 // 16 + _ [8]byte // 24 +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/vt_string.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/vt_string.go new file mode 100644 index 0000000000..729b4a04dd --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/vt_string.go @@ -0,0 +1,58 @@ +// generated by stringer -output vt_string.go -type VT; DO NOT EDIT + +package ole + +import "fmt" + +const ( + _VT_name_0 = "VT_EMPTYVT_NULLVT_I2VT_I4VT_R4VT_R8VT_CYVT_DATEVT_BSTRVT_DISPATCHVT_ERRORVT_BOOLVT_VARIANTVT_UNKNOWNVT_DECIMAL" + _VT_name_1 = "VT_I1VT_UI1VT_UI2VT_UI4VT_I8VT_UI8VT_INTVT_UINTVT_VOIDVT_HRESULTVT_PTRVT_SAFEARRAYVT_CARRAYVT_USERDEFINEDVT_LPSTRVT_LPWSTR" + _VT_name_2 = "VT_RECORDVT_INT_PTRVT_UINT_PTR" + _VT_name_3 = "VT_FILETIMEVT_BLOBVT_STREAMVT_STORAGEVT_STREAMED_OBJECTVT_STORED_OBJECTVT_BLOB_OBJECTVT_CFVT_CLSID" + _VT_name_4 = "VT_BSTR_BLOBVT_VECTOR" + _VT_name_5 = "VT_ARRAY" + _VT_name_6 = "VT_BYREF" + _VT_name_7 = "VT_RESERVED" + _VT_name_8 = "VT_ILLEGAL" +) + +var ( + _VT_index_0 = [...]uint8{0, 8, 15, 20, 25, 30, 35, 40, 47, 54, 65, 73, 80, 90, 100, 110} + _VT_index_1 = [...]uint8{0, 5, 11, 17, 23, 28, 34, 40, 47, 54, 64, 70, 82, 91, 105, 113, 122} + _VT_index_2 = [...]uint8{0, 9, 19, 30} + _VT_index_3 = [...]uint8{0, 11, 18, 27, 37, 55, 71, 85, 90, 98} + _VT_index_4 = [...]uint8{0, 12, 21} + _VT_index_5 = [...]uint8{0, 8} + _VT_index_6 = [...]uint8{0, 8} + _VT_index_7 = [...]uint8{0, 11} + _VT_index_8 = [...]uint8{0, 10} +) + +func (i VT) String() string { + switch { + case 0 <= i && i <= 14: + return _VT_name_0[_VT_index_0[i]:_VT_index_0[i+1]] + case 16 <= i && i <= 31: + i -= 16 + return _VT_name_1[_VT_index_1[i]:_VT_index_1[i+1]] + case 36 <= i && i <= 38: + i -= 36 + return _VT_name_2[_VT_index_2[i]:_VT_index_2[i+1]] + case 64 <= i && i <= 72: + i -= 64 + return _VT_name_3[_VT_index_3[i]:_VT_index_3[i+1]] + case 4095 <= i && i <= 4096: + i -= 4095 + return _VT_name_4[_VT_index_4[i]:_VT_index_4[i+1]] + case i == 8192: + return _VT_name_5 + case i == 16384: + return _VT_name_6 + case i == 32768: + return _VT_name_7 + case i == 65535: + return _VT_name_8 + default: + return fmt.Sprintf("VT(%d)", i) + } +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/winrt.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/winrt.go new file mode 100644 index 0000000000..4e9eca7324 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/winrt.go @@ -0,0 +1,99 @@ +// +build windows + +package ole + +import ( + "reflect" + "syscall" + "unicode/utf8" + "unsafe" +) + +var ( + procRoInitialize = modcombase.NewProc("RoInitialize") + procRoActivateInstance = modcombase.NewProc("RoActivateInstance") + procRoGetActivationFactory = modcombase.NewProc("RoGetActivationFactory") + procWindowsCreateString = modcombase.NewProc("WindowsCreateString") + procWindowsDeleteString = modcombase.NewProc("WindowsDeleteString") + procWindowsGetStringRawBuffer = modcombase.NewProc("WindowsGetStringRawBuffer") +) + +func RoInitialize(thread_type uint32) (err error) { + hr, _, _ := procRoInitialize.Call(uintptr(thread_type)) + if hr != 0 { + err = NewError(hr) + } + return +} + +func RoActivateInstance(clsid string) (ins *IInspectable, err error) { + hClsid, err := NewHString(clsid) + if err != nil { + return nil, err + } + defer DeleteHString(hClsid) + + hr, _, _ := procRoActivateInstance.Call( + uintptr(unsafe.Pointer(hClsid)), + uintptr(unsafe.Pointer(&ins))) + if hr != 0 { + err = NewError(hr) + } + return +} + +func RoGetActivationFactory(clsid string, iid *GUID) (ins *IInspectable, err error) { + hClsid, err := NewHString(clsid) + if err != nil { + return nil, err + } + defer DeleteHString(hClsid) + + hr, _, _ := procRoGetActivationFactory.Call( + uintptr(unsafe.Pointer(hClsid)), + uintptr(unsafe.Pointer(iid)), + uintptr(unsafe.Pointer(&ins))) + if hr != 0 { + err = NewError(hr) + } + return +} + +// HString is handle string for pointers. +type HString uintptr + +// NewHString returns a new HString for Go string. +func NewHString(s string) (hstring HString, err error) { + u16 := syscall.StringToUTF16Ptr(s) + len := uint32(utf8.RuneCountInString(s)) + hr, _, _ := procWindowsCreateString.Call( + uintptr(unsafe.Pointer(u16)), + uintptr(len), + uintptr(unsafe.Pointer(&hstring))) + if hr != 0 { + err = NewError(hr) + } + return +} + +// DeleteHString deletes HString. +func DeleteHString(hstring HString) (err error) { + hr, _, _ := procWindowsDeleteString.Call(uintptr(hstring)) + if hr != 0 { + err = NewError(hr) + } + return +} + +// String returns Go string value of HString. +func (h HString) String() string { + var u16buf uintptr + var u16len uint32 + u16buf, _, _ = procWindowsGetStringRawBuffer.Call( + uintptr(h), + uintptr(unsafe.Pointer(&u16len))) + + u16hdr := reflect.SliceHeader{Data: u16buf, Len: int(u16len), Cap: int(u16len)} + u16 := *(*[]uint16)(unsafe.Pointer(&u16hdr)) + return syscall.UTF16ToString(u16) +} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/winrt_doc.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/winrt_doc.go new file mode 100644 index 0000000000..52e6d74c9a --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ole/go-ole/winrt_doc.go @@ -0,0 +1,36 @@ +// +build !windows + +package ole + +// RoInitialize +func RoInitialize(thread_type uint32) (err error) { + return NewError(E_NOTIMPL) +} + +// RoActivateInstance +func RoActivateInstance(clsid string) (ins *IInspectable, err error) { + return nil, NewError(E_NOTIMPL) +} + +// RoGetActivationFactory +func RoGetActivationFactory(clsid string, iid *GUID) (ins *IInspectable, err error) { + return nil, NewError(E_NOTIMPL) +} + +// HString is handle string for pointers. +type HString uintptr + +// NewHString returns a new HString for Go string. +func NewHString(s string) (hstring HString, err error) { + return HString(uintptr(0)), NewError(E_NOTIMPL) +} + +// DeleteHString deletes HString. +func DeleteHString(hstring HString) (err error) { + return NewError(E_NOTIMPL) +} + +// String returns Go string value of HString. +func (h HString) String() string { + return "" +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/LICENSE b/Godeps/_workspace/src/github.com/shirou/gopsutil/LICENSE new file mode 100644 index 0000000000..602b2c098e --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/LICENSE @@ -0,0 +1,27 @@ +gopsutil is distributed under BSD license reproduced below. + +Copyright (c) 2014, WAKAYAMA Shirou +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 the gopsutil authors 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. diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu.go new file mode 100644 index 0000000000..71535094d4 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu.go @@ -0,0 +1,76 @@ +package cpu + +import ( + "encoding/json" + "runtime" + "strconv" + "strings" +) + +type TimesStat struct { + CPU string `json:"cpu"` + User float64 `json:"user"` + System float64 `json:"system"` + Idle float64 `json:"idle"` + Nice float64 `json:"nice"` + Iowait float64 `json:"iowait"` + Irq float64 `json:"irq"` + Softirq float64 `json:"softirq"` + Steal float64 `json:"steal"` + Guest float64 `json:"guest"` + GuestNice float64 `json:"guestNice"` + Stolen float64 `json:"stolen"` +} + +type InfoStat struct { + CPU int32 `json:"cpu"` + VendorID string `json:"vendorId"` + Family string `json:"family"` + Model string `json:"model"` + Stepping int32 `json:"stepping"` + PhysicalID string `json:"physicalId"` + CoreID string `json:"coreId"` + Cores int32 `json:"cores"` + ModelName string `json:"modelName"` + Mhz float64 `json:"mhz"` + CacheSize int32 `json:"cacheSize"` + Flags []string `json:"flags"` +} + +var lastCPUTimes []TimesStat +var lastPerCPUTimes []TimesStat + +func Counts(logical bool) (int, error) { + return runtime.NumCPU(), nil +} + +func (c TimesStat) String() string { + v := []string{ + `"cpu":"` + c.CPU + `"`, + `"user":` + strconv.FormatFloat(c.User, 'f', 1, 64), + `"system":` + strconv.FormatFloat(c.System, 'f', 1, 64), + `"idle":` + strconv.FormatFloat(c.Idle, 'f', 1, 64), + `"nice":` + strconv.FormatFloat(c.Nice, 'f', 1, 64), + `"iowait":` + strconv.FormatFloat(c.Iowait, 'f', 1, 64), + `"irq":` + strconv.FormatFloat(c.Irq, 'f', 1, 64), + `"softirq":` + strconv.FormatFloat(c.Softirq, 'f', 1, 64), + `"steal":` + strconv.FormatFloat(c.Steal, 'f', 1, 64), + `"guest":` + strconv.FormatFloat(c.Guest, 'f', 1, 64), + `"guestNice":` + strconv.FormatFloat(c.GuestNice, 'f', 1, 64), + `"stolen":` + strconv.FormatFloat(c.Stolen, 'f', 1, 64), + } + + return `{` + strings.Join(v, ",") + `}` +} + +// Total returns the total number of seconds in a CPUTimesStat +func (c TimesStat) Total() float64 { + total := c.User + c.System + c.Nice + c.Iowait + c.Irq + c.Softirq + c.Steal + + c.Guest + c.GuestNice + c.Idle + c.Stolen + return total +} + +func (c InfoStat) String() string { + s, _ := json.Marshal(c) + return string(s) +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_darwin.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_darwin.go new file mode 100644 index 0000000000..fbb74a821f --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_darwin.go @@ -0,0 +1,106 @@ +// +build darwin + +package cpu + +import ( + "os/exec" + "strconv" + "strings" +) + +// sys/resource.h +const ( + CPUser = 0 + CPNice = 1 + CPSys = 2 + CPIntr = 3 + CPIdle = 4 + CPUStates = 5 +) + +// default value. from time.h +var ClocksPerSec = float64(128) + +func Times(percpu bool) ([]TimesStat, error) { + if percpu { + return perCPUTimes() + } + + return allCPUTimes() +} + +// Returns only one CPUInfoStat on FreeBSD +func Info() ([]InfoStat, error) { + var ret []InfoStat + sysctl, err := exec.LookPath("/usr/sbin/sysctl") + if err != nil { + return ret, err + } + out, err := exec.Command(sysctl, "machdep.cpu").Output() + if err != nil { + return ret, err + } + + c := InfoStat{} + for _, line := range strings.Split(string(out), "\n") { + values := strings.Fields(line) + if len(values) < 1 { + continue + } + + t, err := strconv.ParseInt(values[1], 10, 64) + // err is not checked here because some value is string. + if strings.HasPrefix(line, "machdep.cpu.brand_string") { + c.ModelName = strings.Join(values[1:], " ") + } else if strings.HasPrefix(line, "machdep.cpu.family") { + c.Family = values[1] + } else if strings.HasPrefix(line, "machdep.cpu.model") { + c.Model = values[1] + } else if strings.HasPrefix(line, "machdep.cpu.stepping") { + if err != nil { + return ret, err + } + c.Stepping = int32(t) + } else if strings.HasPrefix(line, "machdep.cpu.features") { + for _, v := range values[1:] { + c.Flags = append(c.Flags, strings.ToLower(v)) + } + } else if strings.HasPrefix(line, "machdep.cpu.leaf7_features") { + for _, v := range values[1:] { + c.Flags = append(c.Flags, strings.ToLower(v)) + } + } else if strings.HasPrefix(line, "machdep.cpu.extfeatures") { + for _, v := range values[1:] { + c.Flags = append(c.Flags, strings.ToLower(v)) + } + } else if strings.HasPrefix(line, "machdep.cpu.core_count") { + if err != nil { + return ret, err + } + c.Cores = int32(t) + } else if strings.HasPrefix(line, "machdep.cpu.cache.size") { + if err != nil { + return ret, err + } + c.CacheSize = int32(t) + } else if strings.HasPrefix(line, "machdep.cpu.vendor") { + c.VendorID = values[1] + } + } + + // Use the rated frequency of the CPU. This is a static value and does not + // account for low power or Turbo Boost modes. + out, err = exec.Command(sysctl, "hw.cpufrequency").Output() + if err != nil { + return ret, err + } + + values := strings.Fields(string(out)) + mhz, err := strconv.ParseFloat(values[1], 64) + if err != nil { + return ret, err + } + c.Mhz = mhz / 1000000.0 + + return append(ret, c), nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_darwin_cgo.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_darwin_cgo.go new file mode 100644 index 0000000000..ee59fefc06 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_darwin_cgo.go @@ -0,0 +1,107 @@ +// +build darwin +// +build cgo + +package cpu + +/* +#include +#include +#include +#include +#include +#include +#include +#include +#include +*/ +import "C" + +import ( + "bytes" + "encoding/binary" + "fmt" + "unsafe" +) + +// these CPU times for darwin is borrowed from influxdb/telegraf. + +func perCPUTimes() ([]TimesStat, error) { + var ( + count C.mach_msg_type_number_t + cpuload *C.processor_cpu_load_info_data_t + ncpu C.natural_t + ) + + status := C.host_processor_info(C.host_t(C.mach_host_self()), + C.PROCESSOR_CPU_LOAD_INFO, + &ncpu, + (*C.processor_info_array_t)(unsafe.Pointer(&cpuload)), + &count) + + if status != C.KERN_SUCCESS { + return nil, fmt.Errorf("host_processor_info error=%d", status) + } + + // jump through some cgo casting hoops and ensure we properly free + // the memory that cpuload points to + target := C.vm_map_t(C.mach_task_self_) + address := C.vm_address_t(uintptr(unsafe.Pointer(cpuload))) + defer C.vm_deallocate(target, address, C.vm_size_t(ncpu)) + + // the body of struct processor_cpu_load_info + // aka processor_cpu_load_info_data_t + var cpu_ticks [C.CPU_STATE_MAX]uint32 + + // copy the cpuload array to a []byte buffer + // where we can binary.Read the data + size := int(ncpu) * binary.Size(cpu_ticks) + buf := C.GoBytes(unsafe.Pointer(cpuload), C.int(size)) + + bbuf := bytes.NewBuffer(buf) + + var ret []TimesStat + + for i := 0; i < int(ncpu); i++ { + err := binary.Read(bbuf, binary.LittleEndian, &cpu_ticks) + if err != nil { + return nil, err + } + + c := TimesStat{ + CPU: fmt.Sprintf("cpu%d", i), + User: float64(cpu_ticks[C.CPU_STATE_USER]) / ClocksPerSec, + System: float64(cpu_ticks[C.CPU_STATE_SYSTEM]) / ClocksPerSec, + Nice: float64(cpu_ticks[C.CPU_STATE_NICE]) / ClocksPerSec, + Idle: float64(cpu_ticks[C.CPU_STATE_IDLE]) / ClocksPerSec, + } + + ret = append(ret, c) + } + + return ret, nil +} + +func allCPUTimes() ([]TimesStat, error) { + var count C.mach_msg_type_number_t = C.HOST_CPU_LOAD_INFO_COUNT + var cpuload C.host_cpu_load_info_data_t + + status := C.host_statistics(C.host_t(C.mach_host_self()), + C.HOST_CPU_LOAD_INFO, + C.host_info_t(unsafe.Pointer(&cpuload)), + &count) + + if status != C.KERN_SUCCESS { + return nil, fmt.Errorf("host_statistics error=%d", status) + } + + c := TimesStat{ + CPU: "cpu-total", + User: float64(cpuload.cpu_ticks[C.CPU_STATE_USER]) / ClocksPerSec, + System: float64(cpuload.cpu_ticks[C.CPU_STATE_SYSTEM]) / ClocksPerSec, + Nice: float64(cpuload.cpu_ticks[C.CPU_STATE_NICE]) / ClocksPerSec, + Idle: float64(cpuload.cpu_ticks[C.CPU_STATE_IDLE]) / ClocksPerSec, + } + + return []TimesStat{c}, nil + +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_darwin_nocgo.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_darwin_nocgo.go new file mode 100644 index 0000000000..242b4a8e79 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_darwin_nocgo.go @@ -0,0 +1,14 @@ +// +build darwin +// +build !cgo + +package cpu + +import "github.com/shirou/gopsutil/internal/common" + +func perCPUTimes() ([]TimesStat, error) { + return []TimesStat{}, common.ErrNotImplementedError +} + +func allCPUTimes() ([]TimesStat, error) { + return []TimesStat{}, common.ErrNotImplementedError +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_freebsd.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_freebsd.go new file mode 100644 index 0000000000..ce1adf3c16 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_freebsd.go @@ -0,0 +1,147 @@ +// +build freebsd + +package cpu + +import ( + "fmt" + "os/exec" + "regexp" + "strconv" + "strings" + + "github.com/shirou/gopsutil/internal/common" +) + +// sys/resource.h +const ( + CPUser = 0 + CPNice = 1 + CPSys = 2 + CPIntr = 3 + CPIdle = 4 + CPUStates = 5 +) + +var ClocksPerSec = float64(128) + +func init() { + getconf, err := exec.LookPath("/usr/bin/getconf") + if err != nil { + return + } + out, err := exec.Command(getconf, "CLK_TCK").Output() + // ignore errors + if err == nil { + i, err := strconv.ParseFloat(strings.TrimSpace(string(out)), 64) + if err == nil { + ClocksPerSec = float64(i) + } + } +} + +func Times(percpu bool) ([]TimesStat, error) { + var ret []TimesStat + + var sysctlCall string + var ncpu int + if percpu { + sysctlCall = "kern.cp_times" + ncpu, _ = Counts(true) + } else { + sysctlCall = "kern.cp_time" + ncpu = 1 + } + + cpuTimes, err := common.DoSysctrl(sysctlCall) + if err != nil { + return ret, err + } + + for i := 0; i < ncpu; i++ { + offset := CPUStates * i + user, err := strconv.ParseFloat(cpuTimes[CPUser+offset], 64) + if err != nil { + return ret, err + } + nice, err := strconv.ParseFloat(cpuTimes[CPNice+offset], 64) + if err != nil { + return ret, err + } + sys, err := strconv.ParseFloat(cpuTimes[CPSys+offset], 64) + if err != nil { + return ret, err + } + idle, err := strconv.ParseFloat(cpuTimes[CPIdle+offset], 64) + if err != nil { + return ret, err + } + intr, err := strconv.ParseFloat(cpuTimes[CPIntr+offset], 64) + if err != nil { + return ret, err + } + + c := TimesStat{ + User: float64(user / ClocksPerSec), + Nice: float64(nice / ClocksPerSec), + System: float64(sys / ClocksPerSec), + Idle: float64(idle / ClocksPerSec), + Irq: float64(intr / ClocksPerSec), + } + if !percpu { + c.CPU = "cpu-total" + } else { + c.CPU = fmt.Sprintf("cpu%d", i) + } + + ret = append(ret, c) + } + + return ret, nil +} + +// Returns only one CPUInfoStat on FreeBSD +func Info() ([]InfoStat, error) { + filename := "/var/run/dmesg.boot" + lines, _ := common.ReadLines(filename) + + var ret []InfoStat + + c := InfoStat{} + for _, line := range lines { + if matches := regexp.MustCompile(`CPU:\s+(.+) \(([\d.]+).+\)`).FindStringSubmatch(line); matches != nil { + c.ModelName = matches[1] + t, err := strconv.ParseFloat(matches[2], 64) + if err != nil { + return ret, nil + } + c.Mhz = t + } else if matches := regexp.MustCompile(`Origin = "(.+)" Id = (.+) Family = (.+) Model = (.+) Stepping = (.+)`).FindStringSubmatch(line); matches != nil { + c.VendorID = matches[1] + c.Family = matches[3] + c.Model = matches[4] + t, err := strconv.ParseInt(matches[5], 10, 32) + if err != nil { + return ret, nil + } + c.Stepping = int32(t) + } else if matches := regexp.MustCompile(`Features=.+<(.+)>`).FindStringSubmatch(line); matches != nil { + for _, v := range strings.Split(matches[1], ",") { + c.Flags = append(c.Flags, strings.ToLower(v)) + } + } else if matches := regexp.MustCompile(`Features2=[a-f\dx]+<(.+)>`).FindStringSubmatch(line); matches != nil { + for _, v := range strings.Split(matches[1], ",") { + c.Flags = append(c.Flags, strings.ToLower(v)) + } + } else if matches := regexp.MustCompile(`Logical CPUs per core: (\d+)`).FindStringSubmatch(line); matches != nil { + // FIXME: no this line? + t, err := strconv.ParseInt(matches[1], 10, 32) + if err != nil { + return ret, nil + } + c.Cores = int32(t) + } + + } + + return append(ret, c), nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_linux.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_linux.go new file mode 100644 index 0000000000..975b75c072 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_linux.go @@ -0,0 +1,244 @@ +// +build linux + +package cpu + +import ( + "errors" + "fmt" + "os/exec" + "strconv" + "strings" + + "github.com/shirou/gopsutil/internal/common" +) + +var cpu_tick = float64(100) + +func init() { + getconf, err := exec.LookPath("/usr/bin/getconf") + if err != nil { + return + } + out, err := exec.Command(getconf, "CLK_TCK").Output() + // ignore errors + if err == nil { + i, err := strconv.ParseFloat(strings.TrimSpace(string(out)), 64) + if err == nil { + cpu_tick = float64(i) + } + } +} + +func Times(percpu bool) ([]TimesStat, error) { + filename := common.HostProc("stat") + var lines = []string{} + if percpu { + var startIdx uint = 1 + for { + linen, _ := common.ReadLinesOffsetN(filename, startIdx, 1) + line := linen[0] + if !strings.HasPrefix(line, "cpu") { + break + } + lines = append(lines, line) + startIdx++ + } + } else { + lines, _ = common.ReadLinesOffsetN(filename, 0, 1) + } + + ret := make([]TimesStat, 0, len(lines)) + + for _, line := range lines { + ct, err := parseStatLine(line) + if err != nil { + continue + } + ret = append(ret, *ct) + + } + return ret, nil +} + +func sysCPUPath(cpu int32, relPath string) string { + return common.HostSys(fmt.Sprintf("devices/system/cpu/cpu%d", cpu), relPath) +} + +func finishCPUInfo(c *InfoStat) error { + if c.Mhz == 0 { + lines, err := common.ReadLines(sysCPUPath(c.CPU, "cpufreq/cpuinfo_max_freq")) + if err == nil { + value, err := strconv.ParseFloat(lines[0], 64) + if err != nil { + return err + } + c.Mhz = value + } + } + if len(c.CoreID) == 0 { + lines, err := common.ReadLines(sysCPUPath(c.CPU, "topology/coreId")) + if err == nil { + c.CoreID = lines[0] + } + } + return nil +} + +// CPUInfo on linux will return 1 item per physical thread. +// +// CPUs have three levels of counting: sockets, cores, threads. +// Cores with HyperThreading count as having 2 threads per core. +// Sockets often come with many physical CPU cores. +// For example a single socket board with two cores each with HT will +// return 4 CPUInfoStat structs on Linux and the "Cores" field set to 1. +func Info() ([]InfoStat, error) { + filename := common.HostProc("cpuinfo") + lines, _ := common.ReadLines(filename) + + var ret []InfoStat + + c := InfoStat{CPU: -1, Cores: 1} + for _, line := range lines { + fields := strings.Split(line, ":") + if len(fields) < 2 { + continue + } + key := strings.TrimSpace(fields[0]) + value := strings.TrimSpace(fields[1]) + + switch key { + case "processor": + if c.CPU >= 0 { + err := finishCPUInfo(&c) + if err != nil { + return ret, err + } + ret = append(ret, c) + } + c = InfoStat{Cores: 1} + t, err := strconv.ParseInt(value, 10, 64) + if err != nil { + return ret, err + } + c.CPU = int32(t) + case "vendorId", "vendor_id": + c.VendorID = value + case "cpu family": + c.Family = value + case "model": + c.Model = value + case "model name": + c.ModelName = value + case "stepping": + t, err := strconv.ParseInt(value, 10, 64) + if err != nil { + return ret, err + } + c.Stepping = int32(t) + case "cpu MHz": + t, err := strconv.ParseFloat(value, 64) + if err != nil { + return ret, err + } + c.Mhz = t + case "cache size": + t, err := strconv.ParseInt(strings.Replace(value, " KB", "", 1), 10, 64) + if err != nil { + return ret, err + } + c.CacheSize = int32(t) + case "physical id": + c.PhysicalID = value + case "core id": + c.CoreID = value + case "flags", "Features": + c.Flags = strings.FieldsFunc(value, func(r rune) bool { + return r == ',' || r == ' ' + }) + } + } + if c.CPU >= 0 { + err := finishCPUInfo(&c) + if err != nil { + return ret, err + } + ret = append(ret, c) + } + return ret, nil +} + +func parseStatLine(line string) (*TimesStat, error) { + fields := strings.Fields(line) + + if strings.HasPrefix(fields[0], "cpu") == false { + // return CPUTimesStat{}, e + return nil, errors.New("not contain cpu") + } + + cpu := fields[0] + if cpu == "cpu" { + cpu = "cpu-total" + } + user, err := strconv.ParseFloat(fields[1], 64) + if err != nil { + return nil, err + } + nice, err := strconv.ParseFloat(fields[2], 64) + if err != nil { + return nil, err + } + system, err := strconv.ParseFloat(fields[3], 64) + if err != nil { + return nil, err + } + idle, err := strconv.ParseFloat(fields[4], 64) + if err != nil { + return nil, err + } + iowait, err := strconv.ParseFloat(fields[5], 64) + if err != nil { + return nil, err + } + irq, err := strconv.ParseFloat(fields[6], 64) + if err != nil { + return nil, err + } + softirq, err := strconv.ParseFloat(fields[7], 64) + if err != nil { + return nil, err + } + + ct := &TimesStat{ + CPU: cpu, + User: float64(user) / cpu_tick, + Nice: float64(nice) / cpu_tick, + System: float64(system) / cpu_tick, + Idle: float64(idle) / cpu_tick, + Iowait: float64(iowait) / cpu_tick, + Irq: float64(irq) / cpu_tick, + Softirq: float64(softirq) / cpu_tick, + } + if len(fields) > 8 { // Linux >= 2.6.11 + steal, err := strconv.ParseFloat(fields[8], 64) + if err != nil { + return nil, err + } + ct.Steal = float64(steal) / cpu_tick + } + if len(fields) > 9 { // Linux >= 2.6.24 + guest, err := strconv.ParseFloat(fields[9], 64) + if err != nil { + return nil, err + } + ct.Guest = float64(guest) / cpu_tick + } + if len(fields) > 10 { // Linux >= 3.2.0 + guestNice, err := strconv.ParseFloat(fields[10], 64) + if err != nil { + return nil, err + } + ct.GuestNice = float64(guestNice) / cpu_tick + } + + return ct, nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_unix.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_unix.go new file mode 100644 index 0000000000..9f1ea4d772 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_unix.go @@ -0,0 +1,59 @@ +// +build linux freebsd darwin + +package cpu + +import ( + "fmt" + "time" +) + +func Percent(interval time.Duration, percpu bool) ([]float64, error) { + getAllBusy := func(t TimesStat) (float64, float64) { + busy := t.User + t.System + t.Nice + t.Iowait + t.Irq + + t.Softirq + t.Steal + t.Guest + t.GuestNice + t.Stolen + return busy + t.Idle, busy + } + + calculate := func(t1, t2 TimesStat) float64 { + t1All, t1Busy := getAllBusy(t1) + t2All, t2Busy := getAllBusy(t2) + + if t2Busy <= t1Busy { + return 0 + } + if t2All <= t1All { + return 1 + } + return (t2Busy - t1Busy) / (t2All - t1All) * 100 + } + + // Get CPU usage at the start of the interval. + cpuTimes1, err := Times(percpu) + if err != nil { + return nil, err + } + + if interval > 0 { + time.Sleep(interval) + } + + // And at the end of the interval. + cpuTimes2, err := Times(percpu) + if err != nil { + return nil, err + } + + // Make sure the CPU measurements have the same length. + if len(cpuTimes1) != len(cpuTimes2) { + return nil, fmt.Errorf( + "received two CPU counts: %d != %d", + len(cpuTimes1), len(cpuTimes2), + ) + } + + ret := make([]float64, len(cpuTimes1)) + for i, t := range cpuTimes2 { + ret[i] = calculate(cpuTimes1[i], t) + } + return ret, nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_windows.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_windows.go new file mode 100644 index 0000000000..fbd25e6057 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_windows.go @@ -0,0 +1,105 @@ +// +build windows + +package cpu + +import ( + "fmt" + "syscall" + "time" + "unsafe" + + "github.com/StackExchange/wmi" + + "github.com/shirou/gopsutil/internal/common" +) + +type Win32_Processor struct { + LoadPercentage *uint16 + Family uint16 + Manufacturer string + Name string + NumberOfLogicalProcessors uint32 + ProcessorID *string + Stepping *string + MaxClockSpeed uint32 +} + +// TODO: Get percpu +func Times(percpu bool) ([]TimesStat, error) { + var ret []TimesStat + + var lpIdleTime common.FILETIME + var lpKernelTime common.FILETIME + var lpUserTime common.FILETIME + r, _, _ := common.ProcGetSystemTimes.Call( + uintptr(unsafe.Pointer(&lpIdleTime)), + uintptr(unsafe.Pointer(&lpKernelTime)), + uintptr(unsafe.Pointer(&lpUserTime))) + if r == 0 { + return ret, syscall.GetLastError() + } + + LOT := float64(0.0000001) + HIT := (LOT * 4294967296.0) + idle := ((HIT * float64(lpIdleTime.DwHighDateTime)) + (LOT * float64(lpIdleTime.DwLowDateTime))) + user := ((HIT * float64(lpUserTime.DwHighDateTime)) + (LOT * float64(lpUserTime.DwLowDateTime))) + kernel := ((HIT * float64(lpKernelTime.DwHighDateTime)) + (LOT * float64(lpKernelTime.DwLowDateTime))) + system := (kernel - idle) + + ret = append(ret, TimesStat{ + Idle: float64(idle), + User: float64(user), + System: float64(system), + }) + return ret, nil +} + +func Info() ([]InfoStat, error) { + var ret []InfoStat + var dst []Win32_Processor + q := wmi.CreateQuery(&dst, "") + err := wmi.Query(q, &dst) + if err != nil { + return ret, err + } + + var procID string + for i, l := range dst { + procID = "" + if l.ProcessorID != nil { + procID = *l.ProcessorID + } + + cpu := InfoStat{ + CPU: int32(i), + Family: fmt.Sprintf("%d", l.Family), + VendorID: l.Manufacturer, + ModelName: l.Name, + Cores: int32(l.NumberOfLogicalProcessors), + PhysicalID: procID, + Mhz: float64(l.MaxClockSpeed), + Flags: []string{}, + } + ret = append(ret, cpu) + } + + return ret, nil +} + +func Percent(interval time.Duration, percpu bool) ([]float64, error) { + var ret []float64 + var dst []Win32_Processor + q := wmi.CreateQuery(&dst, "") + err := wmi.Query(q, &dst) + if err != nil { + return ret, err + } + for _, l := range dst { + // use range but windows can only get one percent. + if l.LoadPercentage == nil { + continue + } + ret = append(ret, float64(*l.LoadPercentage)) + } + return ret, nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host.go new file mode 100644 index 0000000000..150eb60a7d --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host.go @@ -0,0 +1,38 @@ +package host + +import ( + "encoding/json" +) + +// A HostInfoStat describes the host status. +// This is not in the psutil but it useful. +type InfoStat struct { + Hostname string `json:"hostname"` + Uptime uint64 `json:"uptime"` + BootTime uint64 `json:"bootTime"` + Procs uint64 `json:"procs"` // number of processes + OS string `json:"os"` // ex: freebsd, linux + Platform string `json:"platform"` // ex: ubuntu, linuxmint + PlatformFamily string `json:"platformFamily"` // ex: debian, rhel + PlatformVersion string `json:"platformVersion"` + VirtualizationSystem string `json:"virtualizationSystem"` + VirtualizationRole string `json:"virtualizationRole"` // guest or host + +} + +type UserStat struct { + User string `json:"user"` + Terminal string `json:"terminal"` + Host string `json:"host"` + Started int `json:"started"` +} + +func (h InfoStat) String() string { + s, _ := json.Marshal(h) + return string(s) +} + +func (u UserStat) String() string { + s, _ := json.Marshal(u) + return string(s) +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_darwin.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_darwin.go new file mode 100644 index 0000000000..f4a8c36a26 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_darwin.go @@ -0,0 +1,152 @@ +// +build darwin + +package host + +import ( + "bytes" + "encoding/binary" + "io/ioutil" + "os" + "os/exec" + "runtime" + "strconv" + "strings" + "time" + "unsafe" + + "github.com/shirou/gopsutil/internal/common" +) + +// from utmpx.h +const USER_PROCESS = 7 + +func Info() (*InfoStat, error) { + ret := &InfoStat{ + OS: runtime.GOOS, + PlatformFamily: "darwin", + } + + hostname, err := os.Hostname() + if err == nil { + ret.Hostname = hostname + } + + platform, family, version, err := PlatformInformation() + if err == nil { + ret.Platform = platform + ret.PlatformFamily = family + ret.PlatformVersion = version + } + system, role, err := Virtualization() + if err == nil { + ret.VirtualizationSystem = system + ret.VirtualizationRole = role + } + + boot, err := BootTime() + if err == nil { + ret.BootTime = boot + ret.Uptime = uptime(boot) + } + + return ret, nil +} + +func BootTime() (uint64, error) { + values, err := common.DoSysctrl("kern.boottime") + if err != nil { + return 0, err + } + // ex: { sec = 1392261637, usec = 627534 } Thu Feb 13 12:20:37 2014 + v := strings.Replace(values[2], ",", "", 1) + boottime, err := strconv.ParseInt(v, 10, 64) + if err != nil { + return 0, err + } + + return uint64(boottime), nil +} + +func uptime(boot uint64) uint64 { + return uint64(time.Now().Unix()) - boot +} + +func Uptime() (uint64, error) { + boot, err := BootTime() + if err != nil { + return 0, err + } + return uptime(boot), nil +} + +func Users() ([]UserStat, error) { + utmpfile := "/var/run/utmpx" + var ret []UserStat + + file, err := os.Open(utmpfile) + if err != nil { + return ret, err + } + + buf, err := ioutil.ReadAll(file) + if err != nil { + return ret, err + } + + u := Utmpx{} + entrySize := int(unsafe.Sizeof(u)) + count := len(buf) / entrySize + + for i := 0; i < count; i++ { + b := buf[i*entrySize : i*entrySize+entrySize] + + var u Utmpx + br := bytes.NewReader(b) + err := binary.Read(br, binary.LittleEndian, &u) + if err != nil { + continue + } + if u.Type != USER_PROCESS { + continue + } + user := UserStat{ + User: common.IntToString(u.User[:]), + Terminal: common.IntToString(u.Line[:]), + Host: common.IntToString(u.Host[:]), + Started: int(u.Tv.Sec), + } + ret = append(ret, user) + } + + return ret, nil + +} + +func PlatformInformation() (string, string, string, error) { + platform := "" + family := "" + version := "" + + uname, err := exec.LookPath("uname") + if err != nil { + return "", "", "", err + } + out, err := exec.Command(uname, "-s").Output() + if err == nil { + platform = strings.ToLower(strings.TrimSpace(string(out))) + } + + out, err = exec.Command(uname, "-r").Output() + if err == nil { + version = strings.ToLower(strings.TrimSpace(string(out))) + } + + return platform, family, version, nil +} + +func Virtualization() (string, string, error) { + system := "" + role := "" + + return system, role, nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_darwin_amd64.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_darwin_amd64.go new file mode 100644 index 0000000000..c3596f9f5e --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_darwin_amd64.go @@ -0,0 +1,19 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_darwin.go + +package host + +type Utmpx struct { + User [256]int8 + ID [4]int8 + Line [32]int8 + Pid int32 + Type int16 + Pad_cgo_0 [6]byte + Tv Timeval + Host [256]int8 + Pad [16]uint32 +} +type Timeval struct { + Sec int32 +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_freebsd.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_freebsd.go new file mode 100644 index 0000000000..06142e1c80 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_freebsd.go @@ -0,0 +1,196 @@ +// +build freebsd + +package host + +import ( + "bytes" + "encoding/binary" + "io/ioutil" + "os" + "os/exec" + "runtime" + "strconv" + "strings" + "time" + "unsafe" + + "github.com/shirou/gopsutil/internal/common" +) + +const ( + UTNameSize = 16 /* see MAXLOGNAME in */ + UTLineSize = 8 + UTHostSize = 16 +) + +func Info() (*InfoStat, error) { + ret := &InfoStat{ + OS: runtime.GOOS, + PlatformFamily: "freebsd", + } + + hostname, err := os.Hostname() + if err == nil { + ret.Hostname = hostname + } + + platform, family, version, err := PlatformInformation() + if err == nil { + ret.Platform = platform + ret.PlatformFamily = family + ret.PlatformVersion = version + } + system, role, err := Virtualization() + if err == nil { + ret.VirtualizationSystem = system + ret.VirtualizationRole = role + } + + boot, err := BootTime() + if err == nil { + ret.BootTime = boot + ret.Uptime = uptime(boot) + } + + return ret, nil +} + +func BootTime() (uint64, error) { + values, err := common.DoSysctrl("kern.boottime") + if err != nil { + return 0, err + } + // ex: { sec = 1392261637, usec = 627534 } Thu Feb 13 12:20:37 2014 + v := strings.Replace(values[2], ",", "", 1) + + boottime, err := strconv.ParseUint(v, 10, 64) + if err != nil { + return 0, err + } + + return boottime, nil +} + +func uptime(boot uint64) uint64 { + return uint64(time.Now().Unix()) - boot +} + +func Uptime() (uint64, error) { + boot, err := BootTime() + if err != nil { + return 0, err + } + return uptime(boot), nil +} + +func Users() ([]UserStat, error) { + utmpfile := "/var/run/utx.active" + if !common.PathExists(utmpfile) { + utmpfile = "/var/run/utmp" // before 9.0 + return getUsersFromUtmp(utmpfile) + } + + var ret []UserStat + file, err := os.Open(utmpfile) + if err != nil { + return ret, err + } + + buf, err := ioutil.ReadAll(file) + if err != nil { + return ret, err + } + + u := Utmpx{} + entrySize := int(unsafe.Sizeof(u)) - 3 + entrySize = 197 // TODO: why should 197 + count := len(buf) / entrySize + + for i := 0; i < count; i++ { + b := buf[i*entrySize : i*entrySize+entrySize] + var u Utmpx + br := bytes.NewReader(b) + err := binary.Read(br, binary.LittleEndian, &u) + if err != nil || u.Type != 4 { + continue + } + sec := (binary.LittleEndian.Uint32(u.Tv.Sec[:])) / 2 // TODO: + user := UserStat{ + User: common.IntToString(u.User[:]), + Terminal: common.IntToString(u.Line[:]), + Host: common.IntToString(u.Host[:]), + Started: int(sec), + } + + ret = append(ret, user) + } + + return ret, nil + +} + +func PlatformInformation() (string, string, string, error) { + platform := "" + family := "" + version := "" + uname, err := exec.LookPath("uname") + if err != nil { + return "", "", "", err + } + + out, err := exec.Command(uname, "-s").Output() + if err == nil { + platform = strings.ToLower(strings.TrimSpace(string(out))) + } + + out, err = exec.Command(uname, "-r").Output() + if err == nil { + version = strings.ToLower(strings.TrimSpace(string(out))) + } + + return platform, family, version, nil +} + +func Virtualization() (string, string, error) { + system := "" + role := "" + + return system, role, nil +} + +// before 9.0 +func getUsersFromUtmp(utmpfile string) ([]UserStat, error) { + var ret []UserStat + file, err := os.Open(utmpfile) + if err != nil { + return ret, err + } + buf, err := ioutil.ReadAll(file) + if err != nil { + return ret, err + } + + u := Utmp{} + entrySize := int(unsafe.Sizeof(u)) + count := len(buf) / entrySize + + for i := 0; i < count; i++ { + b := buf[i*entrySize : i*entrySize+entrySize] + var u Utmp + br := bytes.NewReader(b) + err := binary.Read(br, binary.LittleEndian, &u) + if err != nil || u.Time == 0 { + continue + } + user := UserStat{ + User: common.IntToString(u.Name[:]), + Terminal: common.IntToString(u.Line[:]), + Host: common.IntToString(u.Host[:]), + Started: int(u.Time), + } + + ret = append(ret, user) + } + + return ret, nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_freebsd_amd64.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_freebsd_amd64.go new file mode 100644 index 0000000000..9a4c0a47ac --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_freebsd_amd64.go @@ -0,0 +1,41 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_freebsd.go + +package host + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Utmp struct { + Line [8]int8 + Name [16]int8 + Host [16]int8 + Time int32 +} +type Utmpx struct { + Type int16 + Tv Timeval + ID [8]int8 + Pid int32 + User [32]int8 + Line [16]int8 + Host [125]int8 + // Host [128]int8 + // X__ut_spare [64]int8 +} +type Timeval struct { + Sec [4]byte + Usec [3]byte +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_linux.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_linux.go new file mode 100644 index 0000000000..f56906c28f --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_linux.go @@ -0,0 +1,431 @@ +// +build linux + +package host + +import ( + "bytes" + "encoding/binary" + "fmt" + "io/ioutil" + "os" + "os/exec" + "regexp" + "runtime" + "strconv" + "strings" + "time" + "unsafe" + + "github.com/shirou/gopsutil/internal/common" +) + +type LSB struct { + ID string + Release string + Codename string + Description string +} + +// from utmp.h +const USER_PROCESS = 7 + +func Info() (*InfoStat, error) { + ret := &InfoStat{ + OS: runtime.GOOS, + } + + hostname, err := os.Hostname() + if err == nil { + ret.Hostname = hostname + } + + platform, family, version, err := PlatformInformation() + if err == nil { + ret.Platform = platform + ret.PlatformFamily = family + ret.PlatformVersion = version + } + system, role, err := Virtualization() + if err == nil { + ret.VirtualizationSystem = system + ret.VirtualizationRole = role + } + boot, err := BootTime() + if err == nil { + ret.BootTime = boot + ret.Uptime = uptime(boot) + } + + return ret, nil +} + +// BootTime returns the system boot time expressed in seconds since the epoch. +func BootTime() (uint64, error) { + filename := common.HostProc("stat") + lines, err := common.ReadLines(filename) + if err != nil { + return 0, err + } + for _, line := range lines { + if strings.HasPrefix(line, "btime") { + f := strings.Fields(line) + if len(f) != 2 { + return 0, fmt.Errorf("wrong btime format") + } + b, err := strconv.ParseInt(f[1], 10, 64) + if err != nil { + return 0, err + } + return uint64(b), nil + } + } + + return 0, fmt.Errorf("could not find btime") +} + +func uptime(boot uint64) uint64 { + return uint64(time.Now().Unix()) - boot +} + +func Uptime() (uint64, error) { + boot, err := BootTime() + if err != nil { + return 0, err + } + return uptime(boot), nil +} + +func Users() ([]UserStat, error) { + utmpfile := "/var/run/utmp" + + file, err := os.Open(utmpfile) + if err != nil { + return nil, err + } + + buf, err := ioutil.ReadAll(file) + if err != nil { + return nil, err + } + + u := utmp{} + entrySize := int(unsafe.Sizeof(u)) + count := len(buf) / entrySize + + ret := make([]UserStat, 0, count) + + for i := 0; i < count; i++ { + b := buf[i*entrySize : i*entrySize+entrySize] + + var u utmp + br := bytes.NewReader(b) + err := binary.Read(br, binary.LittleEndian, &u) + if err != nil { + continue + } + if u.Type != USER_PROCESS { + continue + } + user := UserStat{ + User: common.IntToString(u.User[:]), + Terminal: common.IntToString(u.Line[:]), + Host: common.IntToString(u.Host[:]), + Started: int(u.Tv.TvSec), + } + ret = append(ret, user) + } + + return ret, nil + +} + +func getLSB() (*LSB, error) { + ret := &LSB{} + if common.PathExists(common.HostEtc("lsb-release")) { + contents, err := common.ReadLines(common.HostEtc("lsb-release")) + if err != nil { + return ret, err // return empty + } + for _, line := range contents { + field := strings.Split(line, "=") + if len(field) < 2 { + continue + } + switch field[0] { + case "DISTRIB_ID": + ret.ID = field[1] + case "DISTRIB_RELEASE": + ret.Release = field[1] + case "DISTRIB_CODENAME": + ret.Codename = field[1] + case "DISTRIB_DESCRIPTION": + ret.Description = field[1] + } + } + } else if common.PathExists("/usr/bin/lsb_release") { + lsb_release, err := exec.LookPath("/usr/bin/lsb_release") + if err != nil { + return ret, err + } + out, err := exec.Command(lsb_release).Output() + if err != nil { + return ret, err + } + for _, line := range strings.Split(string(out), "\n") { + field := strings.Split(line, ":") + if len(field) < 2 { + continue + } + switch field[0] { + case "Distributor ID": + ret.ID = field[1] + case "Release": + ret.Release = field[1] + case "Codename": + ret.Codename = field[1] + case "Description": + ret.Description = field[1] + } + } + + } + + return ret, nil +} + +func PlatformInformation() (platform string, family string, version string, err error) { + + lsb, err := getLSB() + if err != nil { + lsb = &LSB{} + } + + if common.PathExists(common.HostEtc("oracle-release")) { + platform = "oracle" + contents, err := common.ReadLines(common.HostEtc("oracle-release")) + if err == nil { + version = getRedhatishVersion(contents) + } + + } else if common.PathExists(common.HostEtc("enterprise-release")) { + platform = "oracle" + contents, err := common.ReadLines(common.HostEtc("enterprise-release")) + if err == nil { + version = getRedhatishVersion(contents) + } + } else if common.PathExists(common.HostEtc("debian_version")) { + if lsb.ID == "Ubuntu" { + platform = "ubuntu" + version = lsb.Release + } else if lsb.ID == "LinuxMint" { + platform = "linuxmint" + version = lsb.Release + } else { + if common.PathExists("/usr/bin/raspi-config") { + platform = "raspbian" + } else { + platform = "debian" + } + contents, err := common.ReadLines(common.HostEtc("debian_version")) + if err == nil { + version = contents[0] + } + } + } else if common.PathExists(common.HostEtc("redhat-release")) { + contents, err := common.ReadLines(common.HostEtc("redhat-release")) + if err == nil { + version = getRedhatishVersion(contents) + platform = getRedhatishPlatform(contents) + } + } else if common.PathExists(common.HostEtc("system-release")) { + contents, err := common.ReadLines(common.HostEtc("system-release")) + if err == nil { + version = getRedhatishVersion(contents) + platform = getRedhatishPlatform(contents) + } + } else if common.PathExists(common.HostEtc("gentoo-release")) { + platform = "gentoo" + contents, err := common.ReadLines(common.HostEtc("gentoo-release")) + if err == nil { + version = getRedhatishVersion(contents) + } + } else if common.PathExists(common.HostEtc("SuSE-release")) { + contents, err := common.ReadLines(common.HostEtc("SuSE-release")) + if err == nil { + version = getSuseVersion(contents) + platform = getSusePlatform(contents) + } + // TODO: slackware detecion + } else if common.PathExists(common.HostEtc("arch-release")) { + platform = "arch" + version = lsb.Release + } else if lsb.ID == "RedHat" { + platform = "redhat" + version = lsb.Release + } else if lsb.ID == "Amazon" { + platform = "amazon" + version = lsb.Release + } else if lsb.ID == "ScientificSL" { + platform = "scientific" + version = lsb.Release + } else if lsb.ID == "XenServer" { + platform = "xenserver" + version = lsb.Release + } else if lsb.ID != "" { + platform = strings.ToLower(lsb.ID) + version = lsb.Release + } + + switch platform { + case "debian", "ubuntu", "linuxmint", "raspbian": + family = "debian" + case "fedora": + family = "fedora" + case "oracle", "centos", "redhat", "scientific", "enterpriseenterprise", "amazon", "xenserver", "cloudlinux", "ibm_powerkvm": + family = "rhel" + case "suse", "opensuse": + family = "suse" + case "gentoo": + family = "gentoo" + case "slackware": + family = "slackware" + case "arch": + family = "arch" + case "exherbo": + family = "exherbo" + } + + return platform, family, version, nil + +} + +func getRedhatishVersion(contents []string) string { + c := strings.ToLower(strings.Join(contents, "")) + + if strings.Contains(c, "rawhide") { + return "rawhide" + } + if matches := regexp.MustCompile(`release (\d[\d.]*)`).FindStringSubmatch(c); matches != nil { + return matches[1] + } + return "" +} + +func getRedhatishPlatform(contents []string) string { + c := strings.ToLower(strings.Join(contents, "")) + + if strings.Contains(c, "red hat") { + return "redhat" + } + f := strings.Split(c, " ") + + return f[0] +} + +func getSuseVersion(contents []string) string { + version := "" + for _, line := range contents { + if matches := regexp.MustCompile(`VERSION = ([\d.]+)`).FindStringSubmatch(line); matches != nil { + version = matches[1] + } else if matches := regexp.MustCompile(`PATCHLEVEL = ([\d]+)`).FindStringSubmatch(line); matches != nil { + version = version + "." + matches[1] + } + } + return version +} + +func getSusePlatform(contents []string) string { + c := strings.ToLower(strings.Join(contents, "")) + if strings.Contains(c, "opensuse") { + return "opensuse" + } + return "suse" +} + +func Virtualization() (string, string, error) { + var system string + var role string + + filename := common.HostProc("xen") + if common.PathExists(filename) { + system = "xen" + role = "guest" // assume guest + + if common.PathExists(filename + "/capabilities") { + contents, err := common.ReadLines(filename + "/capabilities") + if err == nil { + if common.StringsHas(contents, "control_d") { + role = "host" + } + } + } + } + + filename = common.HostProc("modules") + if common.PathExists(filename) { + contents, err := common.ReadLines(filename) + if err == nil { + if common.StringsContains(contents, "kvm") { + system = "kvm" + role = "host" + } else if common.StringsContains(contents, "vboxdrv") { + system = "vbox" + role = "host" + } else if common.StringsContains(contents, "vboxguest") { + system = "vbox" + role = "guest" + } + } + } + + filename = common.HostProc("cpuinfo") + if common.PathExists(filename) { + contents, err := common.ReadLines(filename) + if err == nil { + if common.StringsHas(contents, "QEMU Virtual CPU") || + common.StringsHas(contents, "Common KVM processor") || + common.StringsHas(contents, "Common 32-bit KVM processor") { + system = "kvm" + role = "guest" + } + } + } + + filename = common.HostProc() + if common.PathExists(filename + "/bc/0") { + system = "openvz" + role = "host" + } else if common.PathExists(filename + "/vz") { + system = "openvz" + role = "guest" + } + + // not use dmidecode because it requires root + if common.PathExists(filename + "/self/status") { + contents, err := common.ReadLines(filename + "/self/status") + if err == nil { + + if common.StringsHas(contents, "s_context:") || + common.StringsHas(contents, "VxID:") { + system = "linux-vserver" + } + // TODO: guest or host + } + } + + if common.PathExists(filename + "/self/cgroup") { + contents, err := common.ReadLines(filename + "/self/cgroup") + if err == nil { + if common.StringsHas(contents, "lxc") || + common.StringsHas(contents, "docker") { + system = "lxc" + role = "guest" + } else if common.PathExists("/usr/bin/lxc-version") { // TODO: which + system = "lxc" + role = "host" + } + } + } + + return system, role, nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_linux_386.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_linux_386.go new file mode 100644 index 0000000000..cab9feed41 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_linux_386.go @@ -0,0 +1,44 @@ +// ATTENTION - FILE MANUAL FIXED AFTER CGO. +// Fixed line: Tv _Ctype_struct_timeval -> Tv UtTv +// Created by cgo -godefs, MANUAL FIXED +// cgo -godefs types_linux.go + +package host + +const ( + sizeofPtr = 0x4 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x4 + sizeofLongLong = 0x8 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int32 + _C_long_long int64 +) + +type utmp struct { + Type int16 + Pad_cgo_0 [2]byte + Pid int32 + Line [32]int8 + ID [4]int8 + User [32]int8 + Host [256]int8 + Exit exit_status + Session int32 + Tv UtTv + Addr_v6 [4]int32 + X__unused [20]int8 +} +type exit_status struct { + Termination int16 + Exit int16 +} +type UtTv struct { + TvSec int32 + TvUsec int32 +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_linux_amd64.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_linux_amd64.go new file mode 100644 index 0000000000..180394bbf4 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_linux_amd64.go @@ -0,0 +1,42 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_linux.go + +package host + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type utmp struct { + Type int16 + Pad_cgo_0 [2]byte + Pid int32 + Line [32]int8 + ID [4]int8 + User [32]int8 + Host [256]int8 + Exit exit_status + Session int32 + Tv UtTv + Addr_v6 [4]int32 + X__glibc_reserved [20]int8 +} +type exit_status struct { + Termination int16 + Exit int16 +} +type UtTv struct { + TvSec int32 + TvUsec int32 +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_linux_arm.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_linux_arm.go new file mode 100644 index 0000000000..5f7e168b61 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_linux_arm.go @@ -0,0 +1,42 @@ +// +build linux +// +build arm + +package host + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type utmp struct { + Type int16 + Pad_cgo_0 [2]byte + Pid int32 + Line [32]int8 + ID [4]int8 + User [32]int8 + Host [256]int8 + Exit exit_status + Session int32 + Tv UtTv + Addr_v6 [4]int32 + X__glibc_reserved [20]int8 +} +type exit_status struct { + Termination int16 + Exit int16 +} +type UtTv struct { + TvSec int32 + TvUsec int32 +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_windows.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_windows.go new file mode 100644 index 0000000000..29f900c6e2 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_windows.go @@ -0,0 +1,135 @@ +// +build windows + +package host + +import ( + "fmt" + "os" + "runtime" + "strings" + "time" + + "github.com/StackExchange/wmi" + + "github.com/shirou/gopsutil/internal/common" + process "github.com/shirou/gopsutil/process" +) + +var ( + procGetSystemTimeAsFileTime = common.Modkernel32.NewProc("GetSystemTimeAsFileTime") + osInfo *Win32_OperatingSystem +) + +type Win32_OperatingSystem struct { + Version string + Caption string + ProductType uint32 + BuildNumber string + LastBootUpTime time.Time +} + +func Info() (*InfoStat, error) { + ret := &InfoStat{ + OS: runtime.GOOS, + } + + hostname, err := os.Hostname() + if err == nil { + ret.Hostname = hostname + } + + platform, family, version, err := PlatformInformation() + if err == nil { + ret.Platform = platform + ret.PlatformFamily = family + ret.PlatformVersion = version + } else { + return ret, err + } + + boot, err := BootTime() + if err == nil { + ret.BootTime = boot + ret.Uptime = uptime(boot) + } + + procs, err := process.Pids() + if err != nil { + return ret, err + } + + ret.Procs = uint64(len(procs)) + + return ret, nil +} + +func GetOSInfo() (Win32_OperatingSystem, error) { + var dst []Win32_OperatingSystem + q := wmi.CreateQuery(&dst, "") + err := wmi.Query(q, &dst) + if err != nil { + return Win32_OperatingSystem{}, err + } + + osInfo = &dst[0] + + return dst[0], nil +} + +func BootTime() (uint64, error) { + if osInfo == nil { + _, err := GetOSInfo() + if err != nil { + return 0, err + } + } + now := time.Now() + t := osInfo.LastBootUpTime.Local() + return uint64(now.Sub(t).Seconds()), nil +} + +func uptime(boot uint64) uint64 { + return uint64(time.Now().Unix()) - boot +} + +func Uptime() (uint64, error) { + boot, err := BootTime() + if err != nil { + return 0, err + } + return uptime(boot), nil +} + +func PlatformInformation() (platform string, family string, version string, err error) { + if osInfo == nil { + _, err = GetOSInfo() + if err != nil { + return + } + } + + // Platform + platform = strings.Trim(osInfo.Caption, " ") + + // PlatformFamily + switch osInfo.ProductType { + case 1: + family = "Standalone Workstation" + case 2: + family = "Server (Domain Controller)" + case 3: + family = "Server" + } + + // Platform Version + version = fmt.Sprintf("%s Build %s", osInfo.Version, osInfo.BuildNumber) + + return +} + +func Users() ([]UserStat, error) { + + var ret []UserStat + + return ret, nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/host/types_darwin.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/host/types_darwin.go new file mode 100644 index 0000000000..b858227885 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/host/types_darwin.go @@ -0,0 +1,17 @@ +// +build ignore +// plus hand editing about timeval + +/* +Input to cgo -godefs. +*/ + +package host + +/* +#include +#include +*/ +import "C" + +type Utmpx C.struct_utmpx +type Timeval C.struct_timeval diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/host/types_freebsd.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/host/types_freebsd.go new file mode 100644 index 0000000000..113b22eeaf --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/host/types_freebsd.go @@ -0,0 +1,43 @@ +// +build ignore + +/* +Input to cgo -godefs. +*/ + +package host + +/* +#define KERNEL +#include +#include +#include + +enum { + sizeofPtr = sizeof(void*), +}; + +*/ +import "C" + +// Machine characteristics; for internal use. + +const ( + sizeofPtr = C.sizeofPtr + sizeofShort = C.sizeof_short + sizeofInt = C.sizeof_int + sizeofLong = C.sizeof_long + sizeofLongLong = C.sizeof_longlong +) + +// Basic types + +type ( + _C_short C.short + _C_int C.int + _C_long C.long + _C_long_long C.longlong +) + +type Utmp C.struct_utmp +type Utmpx C.struct_utmpx +type Timeval C.struct_timeval diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/host/types_linux.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/host/types_linux.go new file mode 100644 index 0000000000..928545515c --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/host/types_linux.go @@ -0,0 +1,45 @@ +// +build ignore + +/* +Input to cgo -godefs. +*/ + +package host + +/* +#define KERNEL +#include +#include + +enum { + sizeofPtr = sizeof(void*), +}; + +*/ +import "C" + +// Machine characteristics; for internal use. + +const ( + sizeofPtr = C.sizeofPtr + sizeofShort = C.sizeof_short + sizeofInt = C.sizeof_int + sizeofLong = C.sizeof_long + sizeofLongLong = C.sizeof_longlong +) + +// Basic types + +type ( + _C_short C.short + _C_int C.int + _C_long C.long + _C_long_long C.longlong +) + +type utmp C.struct_utmp +type exit_status C.struct_exit_status +type UtTv struct { + TvSec int32 + TvUsec int32 +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/binary.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/binary.go new file mode 100644 index 0000000000..9b5dc55b49 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/binary.go @@ -0,0 +1,634 @@ +package common + +// 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. + +// Package binary implements simple translation between numbers and byte +// sequences and encoding and decoding of varints. +// +// Numbers are translated by reading and writing fixed-size values. +// A fixed-size value is either a fixed-size arithmetic +// type (int8, uint8, int16, float32, complex64, ...) +// or an array or struct containing only fixed-size values. +// +// The varint functions encode and decode single integer values using +// a variable-length encoding; smaller values require fewer bytes. +// For a specification, see +// http://code.google.com/apis/protocolbuffers/docs/encoding.html. +// +// This package favors simplicity over efficiency. Clients that require +// high-performance serialization, especially for large data structures, +// should look at more advanced solutions such as the encoding/gob +// package or protocol buffers. +import ( + "errors" + "io" + "math" + "reflect" +) + +// A ByteOrder specifies how to convert byte sequences into +// 16-, 32-, or 64-bit unsigned integers. +type ByteOrder interface { + Uint16([]byte) uint16 + Uint32([]byte) uint32 + Uint64([]byte) uint64 + PutUint16([]byte, uint16) + PutUint32([]byte, uint32) + PutUint64([]byte, uint64) + String() string +} + +// LittleEndian is the little-endian implementation of ByteOrder. +var LittleEndian littleEndian + +// BigEndian is the big-endian implementation of ByteOrder. +var BigEndian bigEndian + +type littleEndian struct{} + +func (littleEndian) Uint16(b []byte) uint16 { return uint16(b[0]) | uint16(b[1])<<8 } + +func (littleEndian) PutUint16(b []byte, v uint16) { + b[0] = byte(v) + b[1] = byte(v >> 8) +} + +func (littleEndian) Uint32(b []byte) uint32 { + return uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 +} + +func (littleEndian) PutUint32(b []byte, v uint32) { + b[0] = byte(v) + b[1] = byte(v >> 8) + b[2] = byte(v >> 16) + b[3] = byte(v >> 24) +} + +func (littleEndian) Uint64(b []byte) uint64 { + 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 +} + +func (littleEndian) PutUint64(b []byte, v uint64) { + b[0] = byte(v) + b[1] = byte(v >> 8) + b[2] = byte(v >> 16) + b[3] = byte(v >> 24) + b[4] = byte(v >> 32) + b[5] = byte(v >> 40) + b[6] = byte(v >> 48) + b[7] = byte(v >> 56) +} + +func (littleEndian) String() string { return "LittleEndian" } + +func (littleEndian) GoString() string { return "binary.LittleEndian" } + +type bigEndian struct{} + +func (bigEndian) Uint16(b []byte) uint16 { return uint16(b[1]) | uint16(b[0])<<8 } + +func (bigEndian) PutUint16(b []byte, v uint16) { + b[0] = byte(v >> 8) + b[1] = byte(v) +} + +func (bigEndian) Uint32(b []byte) uint32 { + return uint32(b[3]) | uint32(b[2])<<8 | uint32(b[1])<<16 | uint32(b[0])<<24 +} + +func (bigEndian) PutUint32(b []byte, v uint32) { + b[0] = byte(v >> 24) + b[1] = byte(v >> 16) + b[2] = byte(v >> 8) + b[3] = byte(v) +} + +func (bigEndian) Uint64(b []byte) uint64 { + 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 +} + +func (bigEndian) PutUint64(b []byte, v uint64) { + b[0] = byte(v >> 56) + b[1] = byte(v >> 48) + b[2] = byte(v >> 40) + b[3] = byte(v >> 32) + b[4] = byte(v >> 24) + b[5] = byte(v >> 16) + b[6] = byte(v >> 8) + b[7] = byte(v) +} + +func (bigEndian) String() string { return "BigEndian" } + +func (bigEndian) GoString() string { return "binary.BigEndian" } + +// Read reads structured binary data from r into data. +// Data must be a pointer to a fixed-size value or a slice +// of fixed-size values. +// Bytes read from r are decoded using the specified byte order +// and written to successive fields of the data. +// When reading into structs, the field data for fields with +// blank (_) field names is skipped; i.e., blank field names +// may be used for padding. +// When reading into a struct, all non-blank fields must be exported. +func Read(r io.Reader, order ByteOrder, data interface{}) error { + // Fast path for basic types and slices. + if n := intDataSize(data); n != 0 { + var b [8]byte + var bs []byte + if n > len(b) { + bs = make([]byte, n) + } else { + bs = b[:n] + } + if _, err := io.ReadFull(r, bs); err != nil { + return err + } + switch data := data.(type) { + case *int8: + *data = int8(b[0]) + case *uint8: + *data = b[0] + case *int16: + *data = int16(order.Uint16(bs)) + case *uint16: + *data = order.Uint16(bs) + case *int32: + *data = int32(order.Uint32(bs)) + case *uint32: + *data = order.Uint32(bs) + case *int64: + *data = int64(order.Uint64(bs)) + case *uint64: + *data = order.Uint64(bs) + case []int8: + for i, x := range bs { // Easier to loop over the input for 8-bit values. + data[i] = int8(x) + } + case []uint8: + copy(data, bs) + case []int16: + for i := range data { + data[i] = int16(order.Uint16(bs[2*i:])) + } + case []uint16: + for i := range data { + data[i] = order.Uint16(bs[2*i:]) + } + case []int32: + for i := range data { + data[i] = int32(order.Uint32(bs[4*i:])) + } + case []uint32: + for i := range data { + data[i] = order.Uint32(bs[4*i:]) + } + case []int64: + for i := range data { + data[i] = int64(order.Uint64(bs[8*i:])) + } + case []uint64: + for i := range data { + data[i] = order.Uint64(bs[8*i:]) + } + } + return nil + } + + // Fallback to reflect-based decoding. + v := reflect.ValueOf(data) + size := -1 + switch v.Kind() { + case reflect.Ptr: + v = v.Elem() + size = dataSize(v) + case reflect.Slice: + size = dataSize(v) + } + if size < 0 { + return errors.New("binary.Read: invalid type " + reflect.TypeOf(data).String()) + } + d := &decoder{order: order, buf: make([]byte, size)} + if _, err := io.ReadFull(r, d.buf); err != nil { + return err + } + d.value(v) + return nil +} + +// Write writes the binary representation of data into w. +// Data must be a fixed-size value or a slice of fixed-size +// values, or a pointer to such data. +// Bytes written to w are encoded using the specified byte order +// and read from successive fields of the data. +// When writing structs, zero values are written for fields +// with blank (_) field names. +func Write(w io.Writer, order ByteOrder, data interface{}) error { + // Fast path for basic types and slices. + if n := intDataSize(data); n != 0 { + var b [8]byte + var bs []byte + if n > len(b) { + bs = make([]byte, n) + } else { + bs = b[:n] + } + switch v := data.(type) { + case *int8: + bs = b[:1] + b[0] = byte(*v) + case int8: + bs = b[:1] + b[0] = byte(v) + case []int8: + for i, x := range v { + bs[i] = byte(x) + } + case *uint8: + bs = b[:1] + b[0] = *v + case uint8: + bs = b[:1] + b[0] = byte(v) + case []uint8: + bs = v + case *int16: + bs = b[:2] + order.PutUint16(bs, uint16(*v)) + case int16: + bs = b[:2] + order.PutUint16(bs, uint16(v)) + case []int16: + for i, x := range v { + order.PutUint16(bs[2*i:], uint16(x)) + } + case *uint16: + bs = b[:2] + order.PutUint16(bs, *v) + case uint16: + bs = b[:2] + order.PutUint16(bs, v) + case []uint16: + for i, x := range v { + order.PutUint16(bs[2*i:], x) + } + case *int32: + bs = b[:4] + order.PutUint32(bs, uint32(*v)) + case int32: + bs = b[:4] + order.PutUint32(bs, uint32(v)) + case []int32: + for i, x := range v { + order.PutUint32(bs[4*i:], uint32(x)) + } + case *uint32: + bs = b[:4] + order.PutUint32(bs, *v) + case uint32: + bs = b[:4] + order.PutUint32(bs, v) + case []uint32: + for i, x := range v { + order.PutUint32(bs[4*i:], x) + } + case *int64: + bs = b[:8] + order.PutUint64(bs, uint64(*v)) + case int64: + bs = b[:8] + order.PutUint64(bs, uint64(v)) + case []int64: + for i, x := range v { + order.PutUint64(bs[8*i:], uint64(x)) + } + case *uint64: + bs = b[:8] + order.PutUint64(bs, *v) + case uint64: + bs = b[:8] + order.PutUint64(bs, v) + case []uint64: + for i, x := range v { + order.PutUint64(bs[8*i:], x) + } + } + _, err := w.Write(bs) + return err + } + + // Fallback to reflect-based encoding. + v := reflect.Indirect(reflect.ValueOf(data)) + size := dataSize(v) + if size < 0 { + return errors.New("binary.Write: invalid type " + reflect.TypeOf(data).String()) + } + buf := make([]byte, size) + e := &encoder{order: order, buf: buf} + e.value(v) + _, err := w.Write(buf) + return err +} + +// Size returns how many bytes Write would generate to encode the value v, which +// must be a fixed-size value or a slice of fixed-size values, or a pointer to such data. +// If v is neither of these, Size returns -1. +func Size(v interface{}) int { + return dataSize(reflect.Indirect(reflect.ValueOf(v))) +} + +// dataSize returns the number of bytes the actual data represented by v occupies in memory. +// For compound structures, it sums the sizes of the elements. Thus, for instance, for a slice +// it returns the length of the slice times the element size and does not count the memory +// occupied by the header. If the type of v is not acceptable, dataSize returns -1. +func dataSize(v reflect.Value) int { + if v.Kind() == reflect.Slice { + if s := sizeof(v.Type().Elem()); s >= 0 { + return s * v.Len() + } + return -1 + } + return sizeof(v.Type()) +} + +// sizeof returns the size >= 0 of variables for the given type or -1 if the type is not acceptable. +func sizeof(t reflect.Type) int { + switch t.Kind() { + case reflect.Array: + if s := sizeof(t.Elem()); s >= 0 { + return s * t.Len() + } + + case reflect.Struct: + sum := 0 + for i, n := 0, t.NumField(); i < n; i++ { + s := sizeof(t.Field(i).Type) + if s < 0 { + return -1 + } + sum += s + } + return sum + + case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, + reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, + reflect.Float32, reflect.Float64, reflect.Complex64, reflect.Complex128, reflect.Ptr: + return int(t.Size()) + } + + return -1 +} + +type coder struct { + order ByteOrder + buf []byte +} + +type decoder coder +type encoder coder + +func (d *decoder) uint8() uint8 { + x := d.buf[0] + d.buf = d.buf[1:] + return x +} + +func (e *encoder) uint8(x uint8) { + e.buf[0] = x + e.buf = e.buf[1:] +} + +func (d *decoder) uint16() uint16 { + x := d.order.Uint16(d.buf[0:2]) + d.buf = d.buf[2:] + return x +} + +func (e *encoder) uint16(x uint16) { + e.order.PutUint16(e.buf[0:2], x) + e.buf = e.buf[2:] +} + +func (d *decoder) uint32() uint32 { + x := d.order.Uint32(d.buf[0:4]) + d.buf = d.buf[4:] + return x +} + +func (e *encoder) uint32(x uint32) { + e.order.PutUint32(e.buf[0:4], x) + e.buf = e.buf[4:] +} + +func (d *decoder) uint64() uint64 { + x := d.order.Uint64(d.buf[0:8]) + d.buf = d.buf[8:] + return x +} + +func (e *encoder) uint64(x uint64) { + e.order.PutUint64(e.buf[0:8], x) + e.buf = e.buf[8:] +} + +func (d *decoder) int8() int8 { return int8(d.uint8()) } + +func (e *encoder) int8(x int8) { e.uint8(uint8(x)) } + +func (d *decoder) int16() int16 { return int16(d.uint16()) } + +func (e *encoder) int16(x int16) { e.uint16(uint16(x)) } + +func (d *decoder) int32() int32 { return int32(d.uint32()) } + +func (e *encoder) int32(x int32) { e.uint32(uint32(x)) } + +func (d *decoder) int64() int64 { return int64(d.uint64()) } + +func (e *encoder) int64(x int64) { e.uint64(uint64(x)) } + +func (d *decoder) value(v reflect.Value) { + switch v.Kind() { + case reflect.Array: + l := v.Len() + for i := 0; i < l; i++ { + d.value(v.Index(i)) + } + + case reflect.Struct: + t := v.Type() + l := v.NumField() + for i := 0; i < l; i++ { + // Note: Calling v.CanSet() below is an optimization. + // It would be sufficient to check the field name, + // but creating the StructField info for each field is + // costly (run "go test -bench=ReadStruct" and compare + // results when making changes to this code). + if v := v.Field(i); v.CanSet() || t.Field(i).Name != "_" { + d.value(v) + } else { + d.skip(v) + } + } + + case reflect.Slice: + l := v.Len() + for i := 0; i < l; i++ { + d.value(v.Index(i)) + } + + case reflect.Int8: + v.SetInt(int64(d.int8())) + case reflect.Int16: + v.SetInt(int64(d.int16())) + case reflect.Int32: + v.SetInt(int64(d.int32())) + case reflect.Int64: + v.SetInt(d.int64()) + + case reflect.Uint8: + v.SetUint(uint64(d.uint8())) + case reflect.Uint16: + v.SetUint(uint64(d.uint16())) + case reflect.Uint32: + v.SetUint(uint64(d.uint32())) + case reflect.Uint64: + v.SetUint(d.uint64()) + + case reflect.Float32: + v.SetFloat(float64(math.Float32frombits(d.uint32()))) + case reflect.Float64: + v.SetFloat(math.Float64frombits(d.uint64())) + + case reflect.Complex64: + v.SetComplex(complex( + float64(math.Float32frombits(d.uint32())), + float64(math.Float32frombits(d.uint32())), + )) + case reflect.Complex128: + v.SetComplex(complex( + math.Float64frombits(d.uint64()), + math.Float64frombits(d.uint64()), + )) + } +} + +func (e *encoder) value(v reflect.Value) { + switch v.Kind() { + case reflect.Array: + l := v.Len() + for i := 0; i < l; i++ { + e.value(v.Index(i)) + } + + case reflect.Struct: + t := v.Type() + l := v.NumField() + for i := 0; i < l; i++ { + // see comment for corresponding code in decoder.value() + if v := v.Field(i); v.CanSet() || t.Field(i).Name != "_" { + e.value(v) + } else { + e.skip(v) + } + } + + case reflect.Slice: + l := v.Len() + for i := 0; i < l; i++ { + e.value(v.Index(i)) + } + + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + switch v.Type().Kind() { + case reflect.Int8: + e.int8(int8(v.Int())) + case reflect.Int16: + e.int16(int16(v.Int())) + case reflect.Int32: + e.int32(int32(v.Int())) + case reflect.Int64: + e.int64(v.Int()) + } + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + switch v.Type().Kind() { + case reflect.Uint8: + e.uint8(uint8(v.Uint())) + case reflect.Uint16: + e.uint16(uint16(v.Uint())) + case reflect.Uint32: + e.uint32(uint32(v.Uint())) + case reflect.Uint64: + e.uint64(v.Uint()) + } + + case reflect.Float32, reflect.Float64: + switch v.Type().Kind() { + case reflect.Float32: + e.uint32(math.Float32bits(float32(v.Float()))) + case reflect.Float64: + e.uint64(math.Float64bits(v.Float())) + } + + case reflect.Complex64, reflect.Complex128: + switch v.Type().Kind() { + case reflect.Complex64: + x := v.Complex() + e.uint32(math.Float32bits(float32(real(x)))) + e.uint32(math.Float32bits(float32(imag(x)))) + case reflect.Complex128: + x := v.Complex() + e.uint64(math.Float64bits(real(x))) + e.uint64(math.Float64bits(imag(x))) + } + } +} + +func (d *decoder) skip(v reflect.Value) { + d.buf = d.buf[dataSize(v):] +} + +func (e *encoder) skip(v reflect.Value) { + n := dataSize(v) + for i := range e.buf[0:n] { + e.buf[i] = 0 + } + e.buf = e.buf[n:] +} + +// intDataSize returns the size of the data required to represent the data when encoded. +// It returns zero if the type cannot be implemented by the fast path in Read or Write. +func intDataSize(data interface{}) int { + switch data := data.(type) { + case int8, *int8, *uint8: + return 1 + case []int8: + return len(data) + case []uint8: + return len(data) + case int16, *int16, *uint16: + return 2 + case []int16: + return 2 * len(data) + case []uint16: + return 2 * len(data) + case int32, *int32, *uint32: + return 4 + case []int32: + return 4 * len(data) + case []uint32: + return 4 * len(data) + case int64, *int64, *uint64: + return 8 + case []int64: + return 8 * len(data) + case []uint64: + return 8 * len(data) + } + return 0 +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common.go new file mode 100644 index 0000000000..d9dce5cac3 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common.go @@ -0,0 +1,279 @@ +package common + +// +// gopsutil is a port of psutil(http://pythonhosted.org/psutil/). +// This covers these architectures. +// - linux (amd64, arm) +// - freebsd (amd64) +// - windows (amd64) +import ( + "bufio" + "errors" + "io/ioutil" + "net/url" + "os" + "os/exec" + "path" + "path/filepath" + "reflect" + "runtime" + "strconv" + "strings" +) + +type Invoker interface { + Command(string, ...string) ([]byte, error) +} + +type Invoke struct{} + +func (i Invoke) Command(name string, arg ...string) ([]byte, error) { + return exec.Command(name, arg...).Output() +} + +type FakeInvoke struct { + CommandExpectedDir string // CommandExpectedDir specifies dir which includes expected outputs. + Suffix string // Suffix species expected file name suffix such as "fail" + Error error // If Error specfied, return the error. +} + +// Command in FakeInvoke returns from expected file if exists. +func (i FakeInvoke) Command(name string, arg ...string) ([]byte, error) { + if i.Error != nil { + return []byte{}, i.Error + } + + arch := runtime.GOOS + + fname := strings.Join(append([]string{name}, arg...), "") + fname = url.QueryEscape(fname) + var dir string + if i.CommandExpectedDir == "" { + dir = "expected" + } else { + dir = i.CommandExpectedDir + } + fpath := path.Join(dir, arch, fname) + if i.Suffix != "" { + fpath += "_" + i.Suffix + } + if PathExists(fpath) { + return ioutil.ReadFile(fpath) + } + return exec.Command(name, arg...).Output() +} + +var ErrNotImplementedError = errors.New("not implemented yet") + +// ReadLines reads contents from a file and splits them by new lines. +// A convenience wrapper to ReadLinesOffsetN(filename, 0, -1). +func ReadLines(filename string) ([]string, error) { + return ReadLinesOffsetN(filename, 0, -1) +} + +// ReadLines reads contents from file and splits them by new line. +// The offset tells at which line number to start. +// The count determines the number of lines to read (starting from offset): +// n >= 0: at most n lines +// n < 0: whole file +func ReadLinesOffsetN(filename string, offset uint, n int) ([]string, error) { + f, err := os.Open(filename) + if err != nil { + return []string{""}, err + } + defer f.Close() + + var ret []string + + r := bufio.NewReader(f) + for i := 0; i < n+int(offset) || n < 0; i++ { + line, err := r.ReadString('\n') + if err != nil { + break + } + if i < int(offset) { + continue + } + ret = append(ret, strings.Trim(line, "\n")) + } + + return ret, nil +} + +func IntToString(orig []int8) string { + ret := make([]byte, len(orig)) + size := -1 + for i, o := range orig { + if o == 0 { + size = i + break + } + ret[i] = byte(o) + } + if size == -1 { + size = len(orig) + } + + return string(ret[0:size]) +} + +func ByteToString(orig []byte) string { + n := -1 + l := -1 + for i, b := range orig { + // skip left side null + if l == -1 && b == 0 { + continue + } + if l == -1 { + l = i + } + + if b == 0 { + break + } + n = i + 1 + } + if n == -1 { + return string(orig) + } + return string(orig[l:n]) +} + +// ReadInts reads contents from single line file and returns them as []int32. +func ReadInts(filename string) ([]int64, error) { + f, err := os.Open(filename) + if err != nil { + return []int64{}, err + } + defer f.Close() + + var ret []int64 + + r := bufio.NewReader(f) + + // The int files that this is concerned with should only be one liners. + line, err := r.ReadString('\n') + if err != nil { + return []int64{}, err + } + + i, err := strconv.ParseInt(strings.Trim(line, "\n"), 10, 32) + if err != nil { + return []int64{}, err + } + ret = append(ret, i) + + return ret, nil +} + +// Parse to int32 without error +func mustParseInt32(val string) int32 { + vv, _ := strconv.ParseInt(val, 10, 32) + return int32(vv) +} + +// Parse to uint64 without error +func mustParseUint64(val string) uint64 { + vv, _ := strconv.ParseInt(val, 10, 64) + return uint64(vv) +} + +// Parse to Float64 without error +func mustParseFloat64(val string) float64 { + vv, _ := strconv.ParseFloat(val, 64) + return vv +} + +// StringsHas checks the target string slice contains src or not +func StringsHas(target []string, src string) bool { + for _, t := range target { + if strings.TrimSpace(t) == src { + return true + } + } + return false +} + +// StringsContains checks the src in any string of the target string slice +func StringsContains(target []string, src string) bool { + for _, t := range target { + if strings.Contains(t, src) { + return true + } + } + return false +} + +// IntContains checks the src in any int of the target int slice. +func IntContains(target []int, src int) bool { + for _, t := range target { + if src == t { + return true + } + } + return false +} + +// get struct attributes. +// This method is used only for debugging platform dependent code. +func attributes(m interface{}) map[string]reflect.Type { + typ := reflect.TypeOf(m) + if typ.Kind() == reflect.Ptr { + typ = typ.Elem() + } + + attrs := make(map[string]reflect.Type) + if typ.Kind() != reflect.Struct { + return nil + } + + for i := 0; i < typ.NumField(); i++ { + p := typ.Field(i) + if !p.Anonymous { + attrs[p.Name] = p.Type + } + } + + return attrs +} + +func PathExists(filename string) bool { + if _, err := os.Stat(filename); err == nil { + return true + } + return false +} + +//GetEnv retrieves the environment variable key. If it does not exist it returns the default. +func GetEnv(key string, dfault string, combineWith ...string) string { + value := os.Getenv(key) + if value == "" { + value = dfault + } + + switch len(combineWith) { + case 0: + return value + case 1: + return filepath.Join(value, combineWith[0]) + default: + all := make([]string, len(combineWith)+1) + all[0] = value + copy(all[1:], combineWith) + return filepath.Join(all...) + } + panic("invalid switch case") +} + +func HostProc(combineWith ...string) string { + return GetEnv("HOST_PROC", "/proc", combineWith...) +} + +func HostSys(combineWith ...string) string { + return GetEnv("HOST_SYS", "/sys", combineWith...) +} + +func HostEtc(combineWith ...string) string { + return GetEnv("HOST_ETC", "/etc", combineWith...) +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common_darwin.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common_darwin.go new file mode 100644 index 0000000000..2e1552aeee --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common_darwin.go @@ -0,0 +1,70 @@ +// +build darwin + +package common + +import ( + "os" + "os/exec" + "strings" + "syscall" + "unsafe" +) + +func DoSysctrl(mib string) ([]string, error) { + err := os.Setenv("LC_ALL", "C") + if err != nil { + return []string{}, err + } + + sysctl, err := exec.LookPath("/usr/sbin/sysctl") + if err != nil { + return []string{}, err + } + out, err := exec.Command(sysctl, "-n", mib).Output() + if err != nil { + return []string{}, err + } + v := strings.Replace(string(out), "{ ", "", 1) + v = strings.Replace(string(v), " }", "", 1) + values := strings.Fields(string(v)) + + return values, nil +} + +func CallSyscall(mib []int32) ([]byte, uint64, error) { + miblen := uint64(len(mib)) + + // get required buffer size + length := uint64(0) + _, _, err := syscall.Syscall6( + syscall.SYS___SYSCTL, + uintptr(unsafe.Pointer(&mib[0])), + uintptr(miblen), + 0, + uintptr(unsafe.Pointer(&length)), + 0, + 0) + if err != 0 { + var b []byte + return b, length, err + } + if length == 0 { + var b []byte + return b, length, err + } + // get proc info itself + buf := make([]byte, length) + _, _, err = syscall.Syscall6( + syscall.SYS___SYSCTL, + uintptr(unsafe.Pointer(&mib[0])), + uintptr(miblen), + uintptr(unsafe.Pointer(&buf[0])), + uintptr(unsafe.Pointer(&length)), + 0, + 0) + if err != 0 { + return buf, length, err + } + + return buf, length, nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common_freebsd.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common_freebsd.go new file mode 100644 index 0000000000..dfdcebd8d7 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common_freebsd.go @@ -0,0 +1,70 @@ +// +build freebsd + +package common + +import ( + "os" + "os/exec" + "strings" + "syscall" + "unsafe" +) + +func DoSysctrl(mib string) ([]string, error) { + err := os.Setenv("LC_ALL", "C") + if err != nil { + return []string{}, err + } + sysctl, err := exec.LookPath("/sbin/sysctl") + if err != nil { + return []string{}, err + } + out, err := exec.Command(sysctl, "-n", mib).Output() + if err != nil { + return []string{}, err + } + v := strings.Replace(string(out), "{ ", "", 1) + v = strings.Replace(string(v), " }", "", 1) + values := strings.Fields(string(v)) + + return values, nil +} + +func CallSyscall(mib []int32) ([]byte, uint64, error) { + mibptr := unsafe.Pointer(&mib[0]) + miblen := uint64(len(mib)) + + // get required buffer size + length := uint64(0) + _, _, err := syscall.Syscall6( + syscall.SYS___SYSCTL, + uintptr(mibptr), + uintptr(miblen), + 0, + uintptr(unsafe.Pointer(&length)), + 0, + 0) + if err != 0 { + var b []byte + return b, length, err + } + if length == 0 { + var b []byte + return b, length, err + } + // get proc info itself + buf := make([]byte, length) + _, _, err = syscall.Syscall6( + syscall.SYS___SYSCTL, + uintptr(mibptr), + uintptr(miblen), + uintptr(unsafe.Pointer(&buf[0])), + uintptr(unsafe.Pointer(&length)), + 0, + 0) + if err != 0 { + return buf, length, err + } + + return buf, length, nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common_linux.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common_linux.go new file mode 100644 index 0000000000..0a122e9d6a --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common_linux.go @@ -0,0 +1,3 @@ +// +build linux + +package common diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common_unix.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common_unix.go new file mode 100644 index 0000000000..6622eecc2e --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common_unix.go @@ -0,0 +1,66 @@ +// +build linux freebsd darwin + +package common + +import ( + "os/exec" + "strconv" + "strings" +) + +func CallLsof(invoke Invoker, pid int32, args ...string) ([]string, error) { + var cmd []string + if pid == 0 { // will get from all processes. + cmd = []string{"-a", "-n", "-P"} + } else { + cmd = []string{"-a", "-n", "-P", "-p", strconv.Itoa(int(pid))} + } + cmd = append(cmd, args...) + lsof, err := exec.LookPath("lsof") + if err != nil { + return []string{}, err + } + out, err := invoke.Command(lsof, cmd...) + if err != nil { + // if no pid found, lsof returnes code 1. + if err.Error() == "exit status 1" && len(out) == 0 { + return []string{}, nil + } + } + lines := strings.Split(string(out), "\n") + + var ret []string + for _, l := range lines[1:] { + if len(l) == 0 { + continue + } + ret = append(ret, l) + } + return ret, nil +} + +func CallPgrep(invoke Invoker, pid int32) ([]int32, error) { + var cmd []string + cmd = []string{"-P", strconv.Itoa(int(pid))} + pgrep, err := exec.LookPath("pgrep") + if err != nil { + return []int32{}, err + } + out, err := invoke.Command(pgrep, cmd...) + if err != nil { + return []int32{}, err + } + lines := strings.Split(string(out), "\n") + ret := make([]int32, 0, len(lines)) + for _, l := range lines { + if len(l) == 0 { + continue + } + i, err := strconv.Atoi(l) + if err != nil { + continue + } + ret = append(ret, int32(i)) + } + return ret, nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common_windows.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common_windows.go new file mode 100644 index 0000000000..d727378cbe --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common_windows.go @@ -0,0 +1,110 @@ +// +build windows + +package common + +import ( + "syscall" + "unsafe" +) + +// for double values +type PDH_FMT_COUNTERVALUE_DOUBLE struct { + CStatus uint32 + DoubleValue float64 +} + +// for 64 bit integer values +type PDH_FMT_COUNTERVALUE_LARGE struct { + CStatus uint32 + LargeValue int64 +} + +// for long values +type PDH_FMT_COUNTERVALUE_LONG struct { + CStatus uint32 + LongValue int32 + padding [4]byte +} + +// windows system const +const ( + ERROR_SUCCESS = 0 + ERROR_FILE_NOT_FOUND = 2 + DRIVE_REMOVABLE = 2 + DRIVE_FIXED = 3 + HKEY_LOCAL_MACHINE = 0x80000002 + RRF_RT_REG_SZ = 0x00000002 + RRF_RT_REG_DWORD = 0x00000010 + PDH_FMT_LONG = 0x00000100 + PDH_FMT_DOUBLE = 0x00000200 + PDH_FMT_LARGE = 0x00000400 + PDH_INVALID_DATA = 0xc0000bc6 + PDH_INVALID_HANDLE = 0xC0000bbc + PDH_NO_DATA = 0x800007d5 +) + +var ( + Modkernel32 = syscall.NewLazyDLL("kernel32.dll") + ModNt = syscall.NewLazyDLL("ntdll.dll") + ModPdh = syscall.NewLazyDLL("pdh.dll") + + ProcGetSystemTimes = Modkernel32.NewProc("GetSystemTimes") + ProcNtQuerySystemInformation = ModNt.NewProc("NtQuerySystemInformation") + PdhOpenQuery = ModPdh.NewProc("PdhOpenQuery") + PdhAddCounter = ModPdh.NewProc("PdhAddCounterW") + PdhCollectQueryData = ModPdh.NewProc("PdhCollectQueryData") + PdhGetFormattedCounterValue = ModPdh.NewProc("PdhGetFormattedCounterValue") + PdhCloseQuery = ModPdh.NewProc("PdhCloseQuery") +) + +type FILETIME struct { + DwLowDateTime uint32 + DwHighDateTime uint32 +} + +// borrowed from net/interface_windows.go +func BytePtrToString(p *uint8) string { + a := (*[10000]uint8)(unsafe.Pointer(p)) + i := 0 + for a[i] != 0 { + i++ + } + return string(a[:i]) +} + +// CounterInfo +// copied from https://github.com/mackerelio/mackerel-agent/ +type CounterInfo struct { + PostName string + CounterName string + Counter syscall.Handle +} + +// CreateQuery XXX +// copied from https://github.com/mackerelio/mackerel-agent/ +func CreateQuery() (syscall.Handle, error) { + var query syscall.Handle + r, _, err := PdhOpenQuery.Call(0, 0, uintptr(unsafe.Pointer(&query))) + if r != 0 { + return 0, err + } + return query, nil +} + +// CreateCounter XXX +func CreateCounter(query syscall.Handle, pname, cname string) (*CounterInfo, error) { + var counter syscall.Handle + r, _, err := PdhAddCounter.Call( + uintptr(query), + uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(cname))), + 0, + uintptr(unsafe.Pointer(&counter))) + if r != 0 { + return nil, err + } + return &CounterInfo{ + PostName: pname, + CounterName: cname, + Counter: counter, + }, nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem.go new file mode 100644 index 0000000000..5f122d11b1 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem.go @@ -0,0 +1,64 @@ +package mem + +import ( + "encoding/json" +) + +// Memory usage statistics. Total, Available and Used contain numbers of bytes +// for human consumption. +// +// The other fields in this struct contain kernel specific values. +type VirtualMemoryStat struct { + // Total amount of RAM on this system + Total uint64 `json:"total"` + + // RAM available for programs to allocate + // + // This value is computed from the kernel specific values. + Available uint64 `json:"available"` + + // RAM used by programs + // + // This value is computed from the kernel specific values. + Used uint64 `json:"used"` + + // Percentage of RAM used by programs + // + // This value is computed from the kernel specific values. + UsedPercent float64 `json:"usedPercent"` + + // This is the kernel's notion of free memory; RAM chips whose bits nobody + // cares about the value of right now. For a human consumable number, + // Available is what you really want. + Free uint64 `json:"free"` + + // OS X / BSD specific numbers: + // http://www.macyourself.com/2010/02/17/what-is-free-wired-active-and-inactive-system-memory-ram/ + Active uint64 `json:"active"` + Inactive uint64 `json:"inactive"` + Wired uint64 `json:"wired"` + + // Linux specific numbers + // https://www.centos.org/docs/5/html/5.1/Deployment_Guide/s2-proc-meminfo.html + Buffers uint64 `json:"buffers"` + Cached uint64 `json:"cached"` +} + +type SwapMemoryStat struct { + Total uint64 `json:"total"` + Used uint64 `json:"used"` + Free uint64 `json:"free"` + UsedPercent float64 `json:"usedPercent"` + Sin uint64 `json:"sin"` + Sout uint64 `json:"sout"` +} + +func (m VirtualMemoryStat) String() string { + s, _ := json.Marshal(m) + return string(s) +} + +func (m SwapMemoryStat) String() string { + s, _ := json.Marshal(m) + return string(s) +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_darwin.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_darwin.go new file mode 100644 index 0000000000..922b05cb4f --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_darwin.go @@ -0,0 +1,69 @@ +// +build darwin + +package mem + +import ( + "encoding/binary" + "strconv" + "strings" + "syscall" + + "github.com/shirou/gopsutil/internal/common" +) + +func getHwMemsize() (uint64, error) { + totalString, err := syscall.Sysctl("hw.memsize") + if err != nil { + return 0, err + } + + // syscall.sysctl() helpfully assumes the result is a null-terminated string and + // removes the last byte of the result if it's 0 :/ + totalString += "\x00" + + total := uint64(binary.LittleEndian.Uint64([]byte(totalString))) + + return total, nil +} + +// SwapMemory returns swapinfo. +func SwapMemory() (*SwapMemoryStat, error) { + var ret *SwapMemoryStat + + swapUsage, err := common.DoSysctrl("vm.swapusage") + if err != nil { + return ret, err + } + + total := strings.Replace(swapUsage[2], "M", "", 1) + used := strings.Replace(swapUsage[5], "M", "", 1) + free := strings.Replace(swapUsage[8], "M", "", 1) + + total_v, err := strconv.ParseFloat(total, 64) + if err != nil { + return nil, err + } + used_v, err := strconv.ParseFloat(used, 64) + if err != nil { + return nil, err + } + free_v, err := strconv.ParseFloat(free, 64) + if err != nil { + return nil, err + } + + u := float64(0) + if total_v != 0 { + u = ((total_v - free_v) / total_v) * 100.0 + } + + // vm.swapusage shows "M", multiply 1000 + ret = &SwapMemoryStat{ + Total: uint64(total_v * 1000), + Used: uint64(used_v * 1000), + Free: uint64(free_v * 1000), + UsedPercent: u, + } + + return ret, nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_darwin_cgo.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_darwin_cgo.go new file mode 100644 index 0000000000..461631976e --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_darwin_cgo.go @@ -0,0 +1,53 @@ +// +build darwin +// +build cgo + +package mem + +/* +#include +*/ +import "C" + +import ( + "fmt" + "syscall" + "unsafe" +) + +// VirtualMemory returns VirtualmemoryStat. +func VirtualMemory() (*VirtualMemoryStat, error) { + count := C.mach_msg_type_number_t(C.HOST_VM_INFO_COUNT) + var vmstat C.vm_statistics_data_t + + status := C.host_statistics(C.host_t(C.mach_host_self()), + C.HOST_VM_INFO, + C.host_info_t(unsafe.Pointer(&vmstat)), + &count) + + if status != C.KERN_SUCCESS { + return nil, fmt.Errorf("host_statistics error=%d", status) + } + + pageSize := uint64(syscall.Getpagesize()) + total, err := getHwMemsize() + if err != nil { + return nil, err + } + totalCount := C.natural_t(total / pageSize) + + availableCount := vmstat.inactive_count + vmstat.free_count + usedPercent := 100 * float64(totalCount-availableCount) / float64(totalCount) + + usedCount := totalCount - availableCount + + return &VirtualMemoryStat{ + Total: total, + Available: pageSize * uint64(availableCount), + Used: pageSize * uint64(usedCount), + UsedPercent: usedPercent, + Free: pageSize * uint64(vmstat.free_count), + Active: pageSize * uint64(vmstat.active_count), + Inactive: pageSize * uint64(vmstat.inactive_count), + Wired: pageSize * uint64(vmstat.wire_count), + }, nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_darwin_nocgo.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_darwin_nocgo.go new file mode 100644 index 0000000000..7094802d9a --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_darwin_nocgo.go @@ -0,0 +1,88 @@ +// +build darwin +// +build !cgo + +package mem + +import ( + "os/exec" + "strconv" + "strings" + "syscall" +) + +// Runs vm_stat and returns Free and inactive pages +func getVMStat(vms *VirtualMemoryStat) error { + vm_stat, err := exec.LookPath("vm_stat") + if err != nil { + return err + } + out, err := exec.Command(vm_stat).Output() + if err != nil { + return err + } + return parseVMStat(string(out), vms) +} + +func parseVMStat(out string, vms *VirtualMemoryStat) error { + var err error + + lines := strings.Split(out, "\n") + pagesize := uint64(syscall.Getpagesize()) + for _, line := range lines { + fields := strings.Split(line, ":") + if len(fields) < 2 { + continue + } + key := strings.TrimSpace(fields[0]) + value := strings.Trim(fields[1], " .") + switch key { + case "Pages free": + free, e := strconv.ParseUint(value, 10, 64) + if e != nil { + err = e + } + vms.Free = free * pagesize + case "Pages inactive": + inactive, e := strconv.ParseUint(value, 10, 64) + if e != nil { + err = e + } + vms.Inactive = inactive * pagesize + case "Pages active": + active, e := strconv.ParseUint(value, 10, 64) + if e != nil { + err = e + } + vms.Active = active * pagesize + case "Pages wired down": + wired, e := strconv.ParseUint(value, 10, 64) + if e != nil { + err = e + } + vms.Wired = wired * pagesize + } + } + return err +} + +// VirtualMemory returns VirtualmemoryStat. +func VirtualMemory() (*VirtualMemoryStat, error) { + ret := &VirtualMemoryStat{} + + total, err := getHwMemsize() + if err != nil { + return nil, err + } + err = getVMStat(ret) + if err != nil { + return nil, err + } + + ret.Available = ret.Free + ret.Inactive + ret.Total = total + + ret.Used = ret.Total - ret.Available + ret.UsedPercent = 100 * float64(ret.Used) / float64(ret.Total) + + return ret, nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_freebsd.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_freebsd.go new file mode 100644 index 0000000000..7194057674 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_freebsd.go @@ -0,0 +1,134 @@ +// +build freebsd + +package mem + +import ( + "errors" + "os/exec" + "strconv" + "strings" + + "github.com/shirou/gopsutil/internal/common" +) + +func VirtualMemory() (*VirtualMemoryStat, error) { + pageSize, err := common.DoSysctrl("vm.stats.vm.v_page_size") + if err != nil { + return nil, err + } + p, err := strconv.ParseUint(pageSize[0], 10, 64) + if err != nil { + return nil, err + } + + pageCount, err := common.DoSysctrl("vm.stats.vm.v_page_count") + if err != nil { + return nil, err + } + free, err := common.DoSysctrl("vm.stats.vm.v_free_count") + if err != nil { + return nil, err + } + active, err := common.DoSysctrl("vm.stats.vm.v_active_count") + if err != nil { + return nil, err + } + inactive, err := common.DoSysctrl("vm.stats.vm.v_inactive_count") + if err != nil { + return nil, err + } + cache, err := common.DoSysctrl("vm.stats.vm.v_cache_count") + if err != nil { + return nil, err + } + buffer, err := common.DoSysctrl("vfs.bufspace") + if err != nil { + return nil, err + } + wired, err := common.DoSysctrl("vm.stats.vm.v_wire_count") + if err != nil { + return nil, err + } + + parsed := make([]uint64, 0, 7) + vv := []string{ + pageCount[0], + free[0], + active[0], + inactive[0], + cache[0], + buffer[0], + wired[0], + } + for _, target := range vv { + t, err := strconv.ParseUint(target, 10, 64) + if err != nil { + return nil, err + } + parsed = append(parsed, t) + } + + ret := &VirtualMemoryStat{ + Total: parsed[0] * p, + Free: parsed[1] * p, + Active: parsed[2] * p, + Inactive: parsed[3] * p, + Cached: parsed[4] * p, + Buffers: parsed[5], + Wired: parsed[6] * p, + } + + ret.Available = ret.Inactive + ret.Cached + ret.Free + ret.Used = ret.Total - ret.Available + ret.UsedPercent = float64(ret.Used) / float64(ret.Total) * 100.0 + + return ret, nil +} + +// Return swapinfo +// FreeBSD can have multiple swap devices. but use only first device +func SwapMemory() (*SwapMemoryStat, error) { + swapinfo, err := exec.LookPath("swapinfo") + if err != nil { + return nil, err + } + + out, err := exec.Command(swapinfo).Output() + if err != nil { + return nil, err + } + for _, line := range strings.Split(string(out), "\n") { + values := strings.Fields(line) + // skip title line + if len(values) == 0 || values[0] == "Device" { + continue + } + + u := strings.Replace(values[4], "%", "", 1) + total_v, err := strconv.ParseUint(values[1], 10, 64) + if err != nil { + return nil, err + } + used_v, err := strconv.ParseUint(values[2], 10, 64) + if err != nil { + return nil, err + } + free_v, err := strconv.ParseUint(values[3], 10, 64) + if err != nil { + return nil, err + } + up_v, err := strconv.ParseFloat(u, 64) + if err != nil { + return nil, err + } + + return &SwapMemoryStat{ + Total: total_v, + Used: used_v, + Free: free_v, + UsedPercent: up_v, + }, nil + } + + return nil, errors.New("no swap devices found") +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_linux.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_linux.go new file mode 100644 index 0000000000..899da83dff --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_linux.go @@ -0,0 +1,100 @@ +// +build linux + +package mem + +import ( + "strconv" + "strings" + "syscall" + + "github.com/shirou/gopsutil/internal/common" +) + +func VirtualMemory() (*VirtualMemoryStat, error) { + filename := common.HostProc("meminfo") + lines, _ := common.ReadLines(filename) + // flag if MemAvailable is in /proc/meminfo (kernel 3.14+) + memavail := false + + ret := &VirtualMemoryStat{} + for _, line := range lines { + fields := strings.Split(line, ":") + if len(fields) != 2 { + continue + } + key := strings.TrimSpace(fields[0]) + value := strings.TrimSpace(fields[1]) + value = strings.Replace(value, " kB", "", -1) + + t, err := strconv.ParseUint(value, 10, 64) + if err != nil { + return ret, err + } + switch key { + case "MemTotal": + ret.Total = t * 1024 + case "MemFree": + ret.Free = t * 1024 + case "MemAvailable": + memavail = true + ret.Available = t * 1024 + case "Buffers": + ret.Buffers = t * 1024 + case "Cached": + ret.Cached = t * 1024 + case "Active": + ret.Active = t * 1024 + case "Inactive": + ret.Inactive = t * 1024 + } + } + if !memavail { + ret.Available = ret.Free + ret.Buffers + ret.Cached + } + ret.Used = ret.Total - ret.Available + ret.UsedPercent = float64(ret.Total-ret.Available) / float64(ret.Total) * 100.0 + + return ret, nil +} + +func SwapMemory() (*SwapMemoryStat, error) { + sysinfo := &syscall.Sysinfo_t{} + + if err := syscall.Sysinfo(sysinfo); err != nil { + return nil, err + } + ret := &SwapMemoryStat{ + Total: uint64(sysinfo.Totalswap), + Free: uint64(sysinfo.Freeswap), + } + ret.Used = ret.Total - ret.Free + //check Infinity + if ret.Total != 0 { + ret.UsedPercent = float64(ret.Total-ret.Free) / float64(ret.Total) * 100.0 + } else { + ret.UsedPercent = 0 + } + filename := common.HostProc("vmstat") + lines, _ := common.ReadLines(filename) + for _, l := range lines { + fields := strings.Fields(l) + if len(fields) < 2 { + continue + } + switch fields[0] { + case "pswpin": + value, err := strconv.ParseUint(fields[1], 10, 64) + if err != nil { + continue + } + ret.Sin = value * 4 * 1024 + case "pswpout": + value, err := strconv.ParseUint(fields[1], 10, 64) + if err != nil { + continue + } + ret.Sout = value * 4 * 1024 + } + } + return ret, nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_windows.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_windows.go new file mode 100644 index 0000000000..045af49e39 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_windows.go @@ -0,0 +1,50 @@ +// +build windows + +package mem + +import ( + "syscall" + "unsafe" + + "github.com/shirou/gopsutil/internal/common" +) + +var ( + procGlobalMemoryStatusEx = common.Modkernel32.NewProc("GlobalMemoryStatusEx") +) + +type memoryStatusEx struct { + cbSize uint32 + dwMemoryLoad uint32 + ullTotalPhys uint64 // in bytes + ullAvailPhys uint64 + ullTotalPageFile uint64 + ullAvailPageFile uint64 + ullTotalVirtual uint64 + ullAvailVirtual uint64 + ullAvailExtendedVirtual uint64 +} + +func VirtualMemory() (*VirtualMemoryStat, error) { + var memInfo memoryStatusEx + memInfo.cbSize = uint32(unsafe.Sizeof(memInfo)) + mem, _, _ := procGlobalMemoryStatusEx.Call(uintptr(unsafe.Pointer(&memInfo))) + if mem == 0 { + return nil, syscall.GetLastError() + } + + ret := &VirtualMemoryStat{ + Total: memInfo.ullTotalPhys, + Available: memInfo.ullAvailPhys, + UsedPercent: float64(memInfo.dwMemoryLoad), + } + + ret.Used = ret.Total - ret.Available + return ret, nil +} + +func SwapMemory() (*SwapMemoryStat, error) { + ret := &SwapMemoryStat{} + + return ret, nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/net/net.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/net/net.go new file mode 100644 index 0000000000..60f1069c85 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/net/net.go @@ -0,0 +1,243 @@ +package net + +import ( + "encoding/json" + "fmt" + "net" + "strconv" + "strings" + "syscall" + + "github.com/shirou/gopsutil/internal/common" +) + +var invoke common.Invoker + +func init() { + invoke = common.Invoke{} +} + +type IOCountersStat struct { + Name string `json:"name"` // interface name + BytesSent uint64 `json:"bytesSent"` // number of bytes sent + BytesRecv uint64 `json:"bytesRecv"` // number of bytes received + PacketsSent uint64 `json:"packetsSent"` // number of packets sent + PacketsRecv uint64 `json:"packetsRecv"` // number of packets received + Errin uint64 `json:"errin"` // total number of errors while receiving + Errout uint64 `json:"errout"` // total number of errors while sending + Dropin uint64 `json:"dropin"` // total number of incoming packets which were dropped + Dropout uint64 `json:"dropout"` // total number of outgoing packets which were dropped (always 0 on OSX and BSD) +} + +// Addr is implemented compatibility to psutil +type Addr struct { + IP string `json:"ip"` + Port uint32 `json:"port"` +} + +type ConnectionStat struct { + Fd uint32 `json:"fd"` + Family uint32 `json:"family"` + Type uint32 `json:"type"` + Laddr Addr `json:"localaddr"` + Raddr Addr `json:"remoteaddr"` + Status string `json:"status"` + Pid int32 `json:"pid"` +} + +// System wide stats about different network protocols +type ProtoCountersStat struct { + Protocol string `json:"protocol"` + Stats map[string]int64 `json:"stats"` +} + +// NetInterfaceAddr is designed for represent interface addresses +type InterfaceAddr struct { + Addr string `json:"addr"` +} + +type InterfaceStat struct { + MTU int `json:"mtu"` // maximum transmission unit + Name string `json:"name"` // e.g., "en0", "lo0", "eth0.100" + HardwareAddr string `json:"hardwareaddr"` // IEEE MAC-48, EUI-48 and EUI-64 form + Flags []string `json:"flags"` // e.g., FlagUp, FlagLoopback, FlagMulticast + Addrs []InterfaceAddr `json:"addrs"` +} + +type FilterStat struct { + ConnTrackCount int64 `json:"conntrackCount"` + ConnTrackMax int64 `json:"conntrackMax"` +} + +var constMap = map[string]int{ + "TCP": syscall.SOCK_STREAM, + "UDP": syscall.SOCK_DGRAM, + "IPv4": syscall.AF_INET, + "IPv6": syscall.AF_INET6, +} + +func (n IOCountersStat) String() string { + s, _ := json.Marshal(n) + return string(s) +} + +func (n ConnectionStat) String() string { + s, _ := json.Marshal(n) + return string(s) +} + +func (n ProtoCountersStat) String() string { + s, _ := json.Marshal(n) + return string(s) +} + +func (a Addr) String() string { + s, _ := json.Marshal(a) + return string(s) +} + +func (n InterfaceStat) String() string { + s, _ := json.Marshal(n) + return string(s) +} + +func (n InterfaceAddr) String() string { + s, _ := json.Marshal(n) + return string(s) +} + +func Interfaces() ([]InterfaceStat, error) { + is, err := net.Interfaces() + if err != nil { + return nil, err + } + ret := make([]InterfaceStat, 0, len(is)) + for _, ifi := range is { + + var flags []string + if ifi.Flags&net.FlagUp != 0 { + flags = append(flags, "up") + } + if ifi.Flags&net.FlagBroadcast != 0 { + flags = append(flags, "broadcast") + } + if ifi.Flags&net.FlagLoopback != 0 { + flags = append(flags, "loopback") + } + if ifi.Flags&net.FlagPointToPoint != 0 { + flags = append(flags, "pointtopoint") + } + if ifi.Flags&net.FlagMulticast != 0 { + flags = append(flags, "multicast") + } + + r := InterfaceStat{ + Name: ifi.Name, + MTU: ifi.MTU, + HardwareAddr: ifi.HardwareAddr.String(), + Flags: flags, + } + addrs, err := ifi.Addrs() + if err == nil { + r.Addrs = make([]InterfaceAddr, 0, len(addrs)) + for _, addr := range addrs { + r.Addrs = append(r.Addrs, InterfaceAddr{ + Addr: addr.String(), + }) + } + + } + ret = append(ret, r) + } + + return ret, nil +} + +func getIOCountersAll(n []IOCountersStat) ([]IOCountersStat, error) { + r := IOCountersStat{ + Name: "all", + } + for _, nic := range n { + r.BytesRecv += nic.BytesRecv + r.PacketsRecv += nic.PacketsRecv + r.Errin += nic.Errin + r.Dropin += nic.Dropin + r.BytesSent += nic.BytesSent + r.PacketsSent += nic.PacketsSent + r.Errout += nic.Errout + r.Dropout += nic.Dropout + } + + return []IOCountersStat{r}, nil +} + +func parseNetLine(line string) (ConnectionStat, error) { + f := strings.Fields(line) + if len(f) < 9 { + return ConnectionStat{}, fmt.Errorf("wrong line,%s", line) + } + + pid, err := strconv.Atoi(f[1]) + if err != nil { + return ConnectionStat{}, err + } + fd, err := strconv.Atoi(strings.Trim(f[3], "u")) + if err != nil { + return ConnectionStat{}, fmt.Errorf("unknown fd, %s", f[3]) + } + netFamily, ok := constMap[f[4]] + if !ok { + return ConnectionStat{}, fmt.Errorf("unknown family, %s", f[4]) + } + netType, ok := constMap[f[7]] + if !ok { + return ConnectionStat{}, fmt.Errorf("unknown type, %s", f[7]) + } + + laddr, raddr, err := parseNetAddr(f[8]) + if err != nil { + return ConnectionStat{}, fmt.Errorf("failed to parse netaddr, %s", f[8]) + } + + n := ConnectionStat{ + Fd: uint32(fd), + Family: uint32(netFamily), + Type: uint32(netType), + Laddr: laddr, + Raddr: raddr, + Pid: int32(pid), + } + if len(f) == 10 { + n.Status = strings.Trim(f[9], "()") + } + + return n, nil +} + +func parseNetAddr(line string) (laddr Addr, raddr Addr, err error) { + parse := func(l string) (Addr, error) { + host, port, err := net.SplitHostPort(l) + if err != nil { + return Addr{}, fmt.Errorf("wrong addr, %s", l) + } + lport, err := strconv.Atoi(port) + if err != nil { + return Addr{}, err + } + return Addr{IP: host, Port: uint32(lport)}, nil + } + + addrs := strings.Split(line, "->") + if len(addrs) == 0 { + return laddr, raddr, fmt.Errorf("wrong netaddr, %s", line) + } + laddr, err = parse(addrs[0]) + if len(addrs) == 2 { // remote addr exists + raddr, err = parse(addrs[1]) + if err != nil { + return laddr, raddr, err + } + } + + return laddr, raddr, err +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/net/net_darwin.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/net/net_darwin.go new file mode 100644 index 0000000000..4fa358a38c --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/net/net_darwin.go @@ -0,0 +1,114 @@ +// +build darwin + +package net + +import ( + "errors" + "os/exec" + "strconv" + "strings" + + "github.com/shirou/gopsutil/internal/common" +) + +// example of netstat -idbn output on yosemite +// Name Mtu Network Address Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll Drop +// lo0 16384 869107 0 169411755 869107 0 169411755 0 0 +// lo0 16384 ::1/128 ::1 869107 - 169411755 869107 - 169411755 - - +// lo0 16384 127 127.0.0.1 869107 - 169411755 869107 - 169411755 - - +func IOCounters(pernic bool) ([]IOCountersStat, error) { + netstat, err := exec.LookPath("/usr/sbin/netstat") + if err != nil { + return nil, err + } + out, err := exec.Command(netstat, "-ibdnW").Output() + if err != nil { + return nil, err + } + + lines := strings.Split(string(out), "\n") + ret := make([]IOCountersStat, 0, len(lines)-1) + exists := make([]string, 0, len(ret)) + + for _, line := range lines { + values := strings.Fields(line) + if len(values) < 1 || values[0] == "Name" { + // skip first line + continue + } + if common.StringsHas(exists, values[0]) { + // skip if already get + continue + } + exists = append(exists, values[0]) + + base := 1 + // sometimes Address is ommitted + if len(values) < 11 { + base = 0 + } + + parsed := make([]uint64, 0, 7) + vv := []string{ + values[base+3], // Ipkts == PacketsRecv + values[base+4], // Ierrs == Errin + values[base+5], // Ibytes == BytesRecv + values[base+6], // Opkts == PacketsSent + values[base+7], // Oerrs == Errout + values[base+8], // Obytes == BytesSent + } + if len(values) == 12 { + vv = append(vv, values[base+10]) + } + + for _, target := range vv { + if target == "-" { + parsed = append(parsed, 0) + continue + } + + t, err := strconv.ParseUint(target, 10, 64) + if err != nil { + return nil, err + } + parsed = append(parsed, t) + } + + n := IOCountersStat{ + Name: values[0], + PacketsRecv: parsed[0], + Errin: parsed[1], + BytesRecv: parsed[2], + PacketsSent: parsed[3], + Errout: parsed[4], + BytesSent: parsed[5], + } + if len(parsed) == 7 { + n.Dropout = parsed[6] + } + ret = append(ret, n) + } + + if pernic == false { + return getIOCountersAll(ret) + } + + return ret, nil +} + +// NetIOCountersByFile is an method which is added just a compatibility for linux. +func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) { + return IOCounters(pernic) +} + +func FilterCounters() ([]FilterStat, error) { + return nil, errors.New("NetFilterCounters not implemented for darwin") +} + +// NetProtoCounters returns network statistics for the entire system +// If protocols is empty then all protocols are returned, otherwise +// just the protocols in the list are returned. +// Not Implemented for Darwin +func ProtoCounters(protocols []string) ([]ProtoCountersStat, error) { + return nil, errors.New("NetProtoCounters not implemented for darwin") +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/net/net_freebsd.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/net/net_freebsd.go new file mode 100644 index 0000000000..3a67b4af4a --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/net/net_freebsd.go @@ -0,0 +1,108 @@ +// +build freebsd + +package net + +import ( + "errors" + "os/exec" + "strconv" + "strings" + + "github.com/shirou/gopsutil/internal/common" +) + +func IOCounters(pernic bool) ([]IOCountersStat, error) { + netstat, err := exec.LookPath("/usr/bin/netstat") + if err != nil { + return nil, err + } + out, err := exec.Command(netstat, "-ibdnW").Output() + if err != nil { + return nil, err + } + + lines := strings.Split(string(out), "\n") + ret := make([]IOCountersStat, 0, len(lines)-1) + exists := make([]string, 0, len(ret)) + + for _, line := range lines { + values := strings.Fields(line) + if len(values) < 1 || values[0] == "Name" { + continue + } + if common.StringsHas(exists, values[0]) { + // skip if already get + continue + } + exists = append(exists, values[0]) + + if len(values) < 12 { + continue + } + base := 1 + // sometimes Address is ommitted + if len(values) < 13 { + base = 0 + } + + parsed := make([]uint64, 0, 8) + vv := []string{ + values[base+3], // PacketsRecv + values[base+4], // Errin + values[base+5], // Dropin + values[base+6], // BytesRecvn + values[base+7], // PacketSent + values[base+8], // Errout + values[base+9], // BytesSent + values[base+11], // Dropout + } + for _, target := range vv { + if target == "-" { + parsed = append(parsed, 0) + continue + } + + t, err := strconv.ParseUint(target, 10, 64) + if err != nil { + return nil, err + } + parsed = append(parsed, t) + } + + n := IOCountersStat{ + Name: values[0], + PacketsRecv: parsed[0], + Errin: parsed[1], + Dropin: parsed[2], + BytesRecv: parsed[3], + PacketsSent: parsed[4], + Errout: parsed[5], + BytesSent: parsed[6], + Dropout: parsed[7], + } + ret = append(ret, n) + } + + if pernic == false { + return getIOCountersAll(ret) + } + + return ret, nil +} + +// NetIOCountersByFile is an method which is added just a compatibility for linux. +func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) { + return IOCounters(pernic) +} + +func FilterCounters() ([]FilterStat, error) { + return nil, errors.New("NetFilterCounters not implemented for freebsd") +} + +// NetProtoCounters returns network statistics for the entire system +// If protocols is empty then all protocols are returned, otherwise +// just the protocols in the list are returned. +// Not Implemented for FreeBSD +func ProtoCounters(protocols []string) ([]ProtoCountersStat, error) { + return nil, errors.New("NetProtoCounters not implemented for freebsd") +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/net/net_linux.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/net/net_linux.go new file mode 100644 index 0000000000..e0247714fe --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/net/net_linux.go @@ -0,0 +1,620 @@ +// +build linux + +package net + +import ( + "encoding/hex" + "errors" + "fmt" + "io/ioutil" + "net" + "os" + "strconv" + "strings" + "syscall" + + "github.com/shirou/gopsutil/internal/common" +) + +// NetIOCounters returnes network I/O statistics for every network +// interface installed on the system. If pernic argument is false, +// return only sum of all information (which name is 'all'). If true, +// every network interface installed on the system is returned +// separately. +func IOCounters(pernic bool) ([]IOCountersStat, error) { + filename := common.HostProc("net/dev") + return IOCountersByFile(pernic, filename) +} + +func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) { + lines, err := common.ReadLines(filename) + if err != nil { + return nil, err + } + + statlen := len(lines) - 1 + + ret := make([]IOCountersStat, 0, statlen) + + for _, line := range lines[2:] { + parts := strings.SplitN(line, ":", 2) + if len(parts) != 2 { + continue + } + interfaceName := strings.TrimSpace(parts[0]) + if interfaceName == "" { + continue + } + + fields := strings.Fields(strings.TrimSpace(parts[1])) + bytesRecv, err := strconv.ParseUint(fields[0], 10, 64) + if err != nil { + return ret, err + } + packetsRecv, err := strconv.ParseUint(fields[1], 10, 64) + if err != nil { + return ret, err + } + errIn, err := strconv.ParseUint(fields[2], 10, 64) + if err != nil { + return ret, err + } + dropIn, err := strconv.ParseUint(fields[3], 10, 64) + if err != nil { + return ret, err + } + bytesSent, err := strconv.ParseUint(fields[8], 10, 64) + if err != nil { + return ret, err + } + packetsSent, err := strconv.ParseUint(fields[9], 10, 64) + if err != nil { + return ret, err + } + errOut, err := strconv.ParseUint(fields[10], 10, 64) + if err != nil { + return ret, err + } + dropOut, err := strconv.ParseUint(fields[13], 10, 64) + if err != nil { + return ret, err + } + + nic := IOCountersStat{ + Name: interfaceName, + BytesRecv: bytesRecv, + PacketsRecv: packetsRecv, + Errin: errIn, + Dropin: dropIn, + BytesSent: bytesSent, + PacketsSent: packetsSent, + Errout: errOut, + Dropout: dropOut, + } + ret = append(ret, nic) + } + + if pernic == false { + return getIOCountersAll(ret) + } + + return ret, nil +} + +var netProtocols = []string{ + "ip", + "icmp", + "icmpmsg", + "tcp", + "udp", + "udplite", +} + +// NetProtoCounters returns network statistics for the entire system +// If protocols is empty then all protocols are returned, otherwise +// just the protocols in the list are returned. +// Available protocols: +// ip,icmp,icmpmsg,tcp,udp,udplite +func ProtoCounters(protocols []string) ([]ProtoCountersStat, error) { + if len(protocols) == 0 { + protocols = netProtocols + } + + stats := make([]ProtoCountersStat, 0, len(protocols)) + protos := make(map[string]bool, len(protocols)) + for _, p := range protocols { + protos[p] = true + } + + filename := common.HostProc("net/snmp") + lines, err := common.ReadLines(filename) + if err != nil { + return nil, err + } + + linecount := len(lines) + for i := 0; i < linecount; i++ { + line := lines[i] + r := strings.IndexRune(line, ':') + if r == -1 { + return nil, errors.New(filename + " is not fomatted correctly, expected ':'.") + } + proto := strings.ToLower(line[:r]) + if !protos[proto] { + // skip protocol and data line + i++ + continue + } + + // Read header line + statNames := strings.Split(line[r+2:], " ") + + // Read data line + i++ + statValues := strings.Split(lines[i][r+2:], " ") + if len(statNames) != len(statValues) { + return nil, errors.New(filename + " is not fomatted correctly, expected same number of columns.") + } + stat := ProtoCountersStat{ + Protocol: proto, + Stats: make(map[string]int64, len(statNames)), + } + for j := range statNames { + value, err := strconv.ParseInt(statValues[j], 10, 64) + if err != nil { + return nil, err + } + stat.Stats[statNames[j]] = value + } + stats = append(stats, stat) + } + return stats, nil +} + +// NetFilterCounters returns iptables conntrack statistics +// the currently in use conntrack count and the max. +// If the file does not exist or is invalid it will return nil. +func FilterCounters() ([]FilterStat, error) { + countfile := common.HostProc("sys/net/netfilter/nf_conntrackCount") + maxfile := common.HostProc("sys/net/netfilter/nf_conntrackMax") + + count, err := common.ReadInts(countfile) + + if err != nil { + return nil, err + } + stats := make([]FilterStat, 0, 1) + + max, err := common.ReadInts(maxfile) + if err != nil { + return nil, err + } + + payload := FilterStat{ + ConnTrackCount: count[0], + ConnTrackMax: max[0], + } + + stats = append(stats, payload) + return stats, nil +} + +// http://students.mimuw.edu.pl/lxr/source/include/net/tcp_states.h +var TCPStatuses = map[string]string{ + "01": "ESTABLISHED", + "02": "SYN_SENT", + "03": "SYN_RECV", + "04": "FIN_WAIT1", + "05": "FIN_WAIT2", + "06": "TIME_WAIT", + "07": "CLOSE", + "08": "CLOSE_WAIT", + "09": "LAST_ACK", + "0A": "LISTEN", + "0B": "CLOSING", +} + +type netConnectionKindType struct { + family uint32 + sockType uint32 + filename string +} + +var kindTCP4 = netConnectionKindType{ + family: syscall.AF_INET, + sockType: syscall.SOCK_STREAM, + filename: "tcp", +} +var kindTCP6 = netConnectionKindType{ + family: syscall.AF_INET6, + sockType: syscall.SOCK_STREAM, + filename: "tcp6", +} +var kindUDP4 = netConnectionKindType{ + family: syscall.AF_INET, + sockType: syscall.SOCK_DGRAM, + filename: "udp", +} +var kindUDP6 = netConnectionKindType{ + family: syscall.AF_INET6, + sockType: syscall.SOCK_DGRAM, + filename: "udp6", +} +var kindUNIX = netConnectionKindType{ + family: syscall.AF_UNIX, + filename: "unix", +} + +var netConnectionKindMap = map[string][]netConnectionKindType{ + "all": []netConnectionKindType{kindTCP4, kindTCP6, kindUDP4, kindUDP6, kindUNIX}, + "tcp": []netConnectionKindType{kindTCP4, kindTCP6}, + "tcp4": []netConnectionKindType{kindTCP4}, + "tcp6": []netConnectionKindType{kindTCP6}, + "udp": []netConnectionKindType{kindUDP4, kindUDP6}, + "udp4": []netConnectionKindType{kindUDP4}, + "udp6": []netConnectionKindType{kindUDP6}, + "unix": []netConnectionKindType{kindUNIX}, + "inet": []netConnectionKindType{kindTCP4, kindTCP6, kindUDP4, kindUDP6}, + "inet4": []netConnectionKindType{kindTCP4, kindUDP4}, + "inet6": []netConnectionKindType{kindTCP6, kindUDP6}, +} + +type inodeMap struct { + pid int32 + fd uint32 +} + +type connTmp struct { + fd uint32 + family uint32 + sockType uint32 + laddr Addr + raddr Addr + status string + pid int32 + boundPid int32 + path string +} + +// Return a list of network connections opened. +func Connections(kind string) ([]ConnectionStat, error) { + return ConnectionsPid(kind, 0) +} + +// Return a list of network connections opened by a process. +func ConnectionsPid(kind string, pid int32) ([]ConnectionStat, error) { + tmap, ok := netConnectionKindMap[kind] + if !ok { + return nil, fmt.Errorf("invalid kind, %s", kind) + } + root := common.HostProc() + var err error + var inodes map[string][]inodeMap + if pid == 0 { + inodes, err = getProcInodesAll(root) + } else { + inodes, err = getProcInodes(root, pid) + if len(inodes) == 0 { + // no connection for the pid + return []ConnectionStat{}, nil + } + } + if err != nil { + return nil, fmt.Errorf("cound not get pid(s), %d", pid) + } + + dupCheckMap := make(map[string]bool) + var ret []ConnectionStat + + for _, t := range tmap { + var path string + var ls []connTmp + path = fmt.Sprintf("%s/net/%s", root, t.filename) + switch t.family { + case syscall.AF_INET: + fallthrough + case syscall.AF_INET6: + ls, err = processInet(path, t, inodes, pid) + case syscall.AF_UNIX: + ls, err = processUnix(path, t, inodes, pid) + } + if err != nil { + return nil, err + } + for _, c := range ls { + conn := ConnectionStat{ + Fd: c.fd, + Family: c.family, + Type: c.sockType, + Laddr: c.laddr, + Raddr: c.raddr, + Status: c.status, + Pid: c.pid, + } + if c.pid == 0 { + conn.Pid = c.boundPid + } else { + conn.Pid = c.pid + } + // check duplicate using JSON format + json := conn.String() + _, exists := dupCheckMap[json] + if !exists { + ret = append(ret, conn) + dupCheckMap[json] = true + } + } + + } + + return ret, nil +} + +// getProcInodes returnes fd of the pid. +func getProcInodes(root string, pid int32) (map[string][]inodeMap, error) { + ret := make(map[string][]inodeMap) + + dir := fmt.Sprintf("%s/%d/fd", root, pid) + files, err := ioutil.ReadDir(dir) + if err != nil { + return ret, nil + } + for _, fd := range files { + inodePath := fmt.Sprintf("%s/%d/fd/%s", root, pid, fd.Name()) + + inode, err := os.Readlink(inodePath) + if err != nil { + continue + } + if !strings.HasPrefix(inode, "socket:[") { + continue + } + // the process is using a socket + l := len(inode) + inode = inode[8 : l-1] + _, ok := ret[inode] + if !ok { + ret[inode] = make([]inodeMap, 0) + } + fd, err := strconv.Atoi(fd.Name()) + if err != nil { + continue + } + + i := inodeMap{ + pid: pid, + fd: uint32(fd), + } + ret[inode] = append(ret[inode], i) + } + return ret, nil +} + +// Pids retunres all pids. +// Note: this is a copy of process_linux.Pids() +// FIXME: Import process occures import cycle. +// move to common made other platform breaking. Need consider. +func Pids() ([]int32, error) { + var ret []int32 + + d, err := os.Open(common.HostProc()) + if err != nil { + return nil, err + } + defer d.Close() + + fnames, err := d.Readdirnames(-1) + if err != nil { + return nil, err + } + for _, fname := range fnames { + pid, err := strconv.ParseInt(fname, 10, 32) + if err != nil { + // if not numeric name, just skip + continue + } + ret = append(ret, int32(pid)) + } + + return ret, nil +} + +func getProcInodesAll(root string) (map[string][]inodeMap, error) { + pids, err := Pids() + if err != nil { + return nil, err + } + ret := make(map[string][]inodeMap) + + for _, pid := range pids { + t, err := getProcInodes(root, pid) + if err != nil { + return ret, err + } + if len(t) == 0 { + continue + } + // TODO: update ret. + ret = updateMap(ret, t) + } + return ret, nil +} + +// decodeAddress decode addresse represents addr in proc/net/* +// ex: +// "0500000A:0016" -> "10.0.0.5", 22 +// "0085002452100113070057A13F025401:0035" -> "2400:8500:1301:1052:a157:7:154:23f", 53 +func decodeAddress(family uint32, src string) (Addr, error) { + t := strings.Split(src, ":") + if len(t) != 2 { + return Addr{}, fmt.Errorf("does not contain port, %s", src) + } + addr := t[0] + port, err := strconv.ParseInt("0x"+t[1], 0, 64) + if err != nil { + return Addr{}, fmt.Errorf("invalid port, %s", src) + } + decoded, err := hex.DecodeString(addr) + if err != nil { + return Addr{}, fmt.Errorf("decode error, %s", err) + } + var ip net.IP + // Assumes this is little_endian + if family == syscall.AF_INET { + ip = net.IP(Reverse(decoded)) + } else { // IPv6 + ip, err = parseIPv6HexString(decoded) + if err != nil { + return Addr{}, err + } + } + return Addr{ + IP: ip.String(), + Port: uint32(port), + }, nil +} + +// Reverse reverses array of bytes. +func Reverse(s []byte) []byte { + for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 { + s[i], s[j] = s[j], s[i] + } + return s +} + +// parseIPv6HexString parse array of bytes to IPv6 string +func parseIPv6HexString(src []byte) (net.IP, error) { + if len(src) != 16 { + return nil, fmt.Errorf("invalid IPv6 string") + } + + buf := make([]byte, 0, 16) + for i := 0; i < len(src); i += 4 { + r := Reverse(src[i : i+4]) + buf = append(buf, r...) + } + return net.IP(buf), nil +} + +func processInet(file string, kind netConnectionKindType, inodes map[string][]inodeMap, filterPid int32) ([]connTmp, error) { + + if strings.HasSuffix(file, "6") && !common.PathExists(file) { + // IPv6 not supported, return empty. + return []connTmp{}, nil + } + lines, err := common.ReadLines(file) + if err != nil { + return nil, err + } + var ret []connTmp + // skip first line + for _, line := range lines[1:] { + l := strings.Fields(line) + if len(l) < 10 { + continue + } + laddr := l[1] + raddr := l[2] + status := l[3] + inode := l[9] + pid := int32(0) + fd := uint32(0) + i, exists := inodes[inode] + if exists { + pid = i[0].pid + fd = i[0].fd + } + if filterPid > 0 && filterPid != pid { + continue + } + if kind.sockType == syscall.SOCK_STREAM { + status = TCPStatuses[status] + } else { + status = "NONE" + } + la, err := decodeAddress(kind.family, laddr) + if err != nil { + continue + } + ra, err := decodeAddress(kind.family, raddr) + if err != nil { + continue + } + + ret = append(ret, connTmp{ + fd: fd, + family: kind.family, + sockType: kind.sockType, + laddr: la, + raddr: ra, + status: status, + pid: pid, + }) + } + + return ret, nil +} + +func processUnix(file string, kind netConnectionKindType, inodes map[string][]inodeMap, filterPid int32) ([]connTmp, error) { + lines, err := common.ReadLines(file) + if err != nil { + return nil, err + } + + var ret []connTmp + // skip first line + for _, line := range lines[1:] { + tokens := strings.Fields(line) + if len(tokens) < 6 { + continue + } + st, err := strconv.Atoi(tokens[4]) + if err != nil { + return nil, err + } + + inode := tokens[6] + + var pairs []inodeMap + pairs, exists := inodes[inode] + if !exists { + pairs = []inodeMap{ + inodeMap{}, + } + } + for _, pair := range pairs { + if filterPid > 0 && filterPid != pair.pid { + continue + } + var path string + if len(tokens) == 8 { + path = tokens[len(tokens)-1] + } + ret = append(ret, connTmp{ + fd: pair.fd, + family: kind.family, + sockType: uint32(st), + laddr: Addr{ + IP: path, + }, + pid: pair.pid, + status: "NONE", + path: path, + }) + } + } + + return ret, nil +} + +func updateMap(src map[string][]inodeMap, add map[string][]inodeMap) map[string][]inodeMap { + for key, value := range add { + a, exists := src[key] + if !exists { + src[key] = value + continue + } + src[key] = append(a, value...) + } + return src +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/net/net_unix.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/net/net_unix.go new file mode 100644 index 0000000000..45de6b17de --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/net/net_unix.go @@ -0,0 +1,68 @@ +// +build freebsd darwin + +package net + +import ( + "strings" + + "github.com/shirou/gopsutil/internal/common" +) + +// Return a list of network connections opened. +func Connections(kind string) ([]ConnectionStat, error) { + return ConnectionsPid(kind, 0) +} + +// Return a list of network connections opened by a process. +func ConnectionsPid(kind string, pid int32) ([]ConnectionStat, error) { + var ret []ConnectionStat + + args := []string{"-i"} + switch strings.ToLower(kind) { + default: + fallthrough + case "": + fallthrough + case "all": + fallthrough + case "inet": + args = append(args, "tcp", "-i", "udp") + case "inet4": + args = append(args, "4") + case "inet6": + args = append(args, "6") + case "tcp": + args = append(args, "tcp") + case "tcp4": + args = append(args, "4tcp") + case "tcp6": + args = append(args, "6tcp") + case "udp": + args = append(args, "udp") + case "udp4": + args = append(args, "6udp") + case "udp6": + args = append(args, "6udp") + case "unix": + return ret, common.ErrNotImplementedError + } + + r, err := common.CallLsof(invoke, pid, args...) + if err != nil { + return nil, err + } + for _, rr := range r { + if strings.HasPrefix(rr, "COMMAND") { + continue + } + n, err := parseNetLine(rr) + if err != nil { + + continue + } + + ret = append(ret, n) + } + + return ret, nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/net/net_windows.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/net/net_windows.go new file mode 100644 index 0000000000..f125260c4d --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/net/net_windows.go @@ -0,0 +1,116 @@ +// +build windows + +package net + +import ( + "errors" + "net" + "os" + "syscall" + "unsafe" + + "github.com/shirou/gopsutil/internal/common" +) + +var ( + modiphlpapi = syscall.NewLazyDLL("iphlpapi.dll") + procGetExtendedTCPTable = modiphlpapi.NewProc("GetExtendedTcpTable") + procGetExtendedUDPTable = modiphlpapi.NewProc("GetExtendedUdpTable") +) + +const ( + TCPTableBasicListener = iota + TCPTableBasicConnections + TCPTableBasicAll + TCPTableOwnerPIDListener + TCPTableOwnerPIDConnections + TCPTableOwnerPIDAll + TCPTableOwnerModuleListener + TCPTableOwnerModuleConnections + TCPTableOwnerModuleAll +) + +func IOCounters(pernic bool) ([]IOCountersStat, error) { + ifs, err := net.Interfaces() + if err != nil { + return nil, err + } + + ai, err := getAdapterList() + if err != nil { + return nil, err + } + var ret []IOCountersStat + + for _, ifi := range ifs { + name := ifi.Name + for ; ai != nil; ai = ai.Next { + name = common.BytePtrToString(&ai.Description[0]) + c := IOCountersStat{ + Name: name, + } + + row := syscall.MibIfRow{Index: ai.Index} + e := syscall.GetIfEntry(&row) + if e != nil { + return nil, os.NewSyscallError("GetIfEntry", e) + } + c.BytesSent = uint64(row.OutOctets) + c.BytesRecv = uint64(row.InOctets) + c.PacketsSent = uint64(row.OutUcastPkts) + c.PacketsRecv = uint64(row.InUcastPkts) + c.Errin = uint64(row.InErrors) + c.Errout = uint64(row.OutErrors) + c.Dropin = uint64(row.InDiscards) + c.Dropout = uint64(row.OutDiscards) + + ret = append(ret, c) + } + } + + if pernic == false { + return getIOCountersAll(ret) + } + return ret, nil +} + +// NetIOCountersByFile is an method which is added just a compatibility for linux. +func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) { + return IOCounters(pernic) +} + +// Return a list of network connections opened by a process +func Connections(kind string) ([]ConnectionStat, error) { + var ret []ConnectionStat + + return ret, common.ErrNotImplementedError +} + +// borrowed from src/pkg/net/interface_windows.go +func getAdapterList() (*syscall.IpAdapterInfo, error) { + b := make([]byte, 1000) + l := uint32(len(b)) + a := (*syscall.IpAdapterInfo)(unsafe.Pointer(&b[0])) + err := syscall.GetAdaptersInfo(a, &l) + if err == syscall.ERROR_BUFFER_OVERFLOW { + b = make([]byte, l) + a = (*syscall.IpAdapterInfo)(unsafe.Pointer(&b[0])) + err = syscall.GetAdaptersInfo(a, &l) + } + if err != nil { + return nil, os.NewSyscallError("GetAdaptersInfo", err) + } + return a, nil +} + +func FilterCounters() ([]FilterStat, error) { + return nil, errors.New("NetFilterCounters not implemented for windows") +} + +// NetProtoCounters returns network statistics for the entire system +// If protocols is empty then all protocols are returned, otherwise +// just the protocols in the list are returned. +// Not Implemented for Windows +func ProtoCounters(protocols []string) ([]ProtoCountersStat, error) { + return nil, errors.New("NetProtoCounters not implemented for windows") +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process.go new file mode 100644 index 0000000000..4b69224340 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process.go @@ -0,0 +1,167 @@ +package process + +import ( + "encoding/json" + "runtime" + "time" + + "github.com/shirou/gopsutil/cpu" + "github.com/shirou/gopsutil/internal/common" + "github.com/shirou/gopsutil/mem" +) + +var invoke common.Invoker + +func init() { + invoke = common.Invoke{} +} + +type Process struct { + Pid int32 `json:"pid"` + name string + status string + parent int32 + numCtxSwitches *NumCtxSwitchesStat + uids []int32 + gids []int32 + numThreads int32 + memInfo *MemoryInfoStat + + lastCPUTimes *cpu.TimesStat + lastCPUTime time.Time +} + +type OpenFilesStat struct { + Path string `json:"path"` + Fd uint64 `json:"fd"` +} + +type MemoryInfoStat struct { + RSS uint64 `json:"rss"` // bytes + VMS uint64 `json:"vms"` // bytes + Swap uint64 `json:"swap"` // bytes +} + +type RlimitStat struct { + Resource int32 `json:"resource"` + Soft int32 `json:"soft"` + Hard int32 `json:"hard"` +} + +type IOCountersStat struct { + ReadCount uint64 `json:"readCount"` + WriteCount uint64 `json:"writeCount"` + ReadBytes uint64 `json:"readBytes"` + WriteBytes uint64 `json:"writeBytes"` +} + +type NumCtxSwitchesStat struct { + Voluntary int64 `json:"voluntary"` + Involuntary int64 `json:"involuntary"` +} + +func (p Process) String() string { + s, _ := json.Marshal(p) + return string(s) +} + +func (o OpenFilesStat) String() string { + s, _ := json.Marshal(o) + return string(s) +} + +func (m MemoryInfoStat) String() string { + s, _ := json.Marshal(m) + return string(s) +} + +func (r RlimitStat) String() string { + s, _ := json.Marshal(r) + return string(s) +} + +func (i IOCountersStat) String() string { + s, _ := json.Marshal(i) + return string(s) +} + +func (p NumCtxSwitchesStat) String() string { + s, _ := json.Marshal(p) + return string(s) +} + +func PidExists(pid int32) (bool, error) { + pids, err := Pids() + if err != nil { + return false, err + } + + for _, i := range pids { + if i == pid { + return true, err + } + } + + return false, err +} + +// If interval is 0, return difference from last call(non-blocking). +// If interval > 0, wait interval sec and return diffrence between start and end. +func (p *Process) Percent(interval time.Duration) (float64, error) { + cpuTimes, err := p.Times() + if err != nil { + return 0, err + } + now := time.Now() + + if interval > 0 { + p.lastCPUTimes = cpuTimes + p.lastCPUTime = now + time.Sleep(interval) + cpuTimes, err = p.Times() + now = time.Now() + if err != nil { + return 0, err + } + } else { + if p.lastCPUTimes == nil { + // invoked first time + p.lastCPUTimes = cpuTimes + p.lastCPUTime = now + return 0, nil + } + } + + numcpu := runtime.NumCPU() + delta := (now.Sub(p.lastCPUTime).Seconds()) * float64(numcpu) + ret := calculatePercent(p.lastCPUTimes, cpuTimes, delta, numcpu) + p.lastCPUTimes = cpuTimes + p.lastCPUTime = now + return ret, nil +} + +func calculatePercent(t1, t2 *cpu.TimesStat, delta float64, numcpu int) float64 { + if delta == 0 { + return 0 + } + delta_proc := t2.Total() - t1.Total() + overall_percent := ((delta_proc / delta) * 100) * float64(numcpu) + return overall_percent +} + +// MemoryPercent returns how many percent of the total RAM this process uses +func (p *Process) MemoryPercent() (float32, error) { + machineMemory, err := mem.VirtualMemory() + if err != nil { + return 0, err + } + total := machineMemory.Total + + processMemory, err := p.MemoryInfo() + if err != nil { + return 0, err + } + used := processMemory.RSS + + return (100 * float32(used) / float32(total)), nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_darwin.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_darwin.go new file mode 100644 index 0000000000..cea0803e6d --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_darwin.go @@ -0,0 +1,451 @@ +// +build darwin + +package process + +import ( + "bytes" + "encoding/binary" + "fmt" + "os/exec" + "strconv" + "strings" + "syscall" + "unsafe" + + "github.com/shirou/gopsutil/cpu" + "github.com/shirou/gopsutil/internal/common" + "github.com/shirou/gopsutil/net" +) + +// copied from sys/sysctl.h +const ( + CTLKern = 1 // "high kernel": proc, limits + KernProc = 14 // struct: process entries + KernProcPID = 1 // by process id + KernProcProc = 8 // only return procs + KernProcAll = 0 // everything + KernProcPathname = 12 // path to executable +) + +const ( + ClockTicks = 100 // C.sysconf(C._SC_CLK_TCK) +) + +type _Ctype_struct___0 struct { + Pad uint64 +} + +// MemoryInfoExStat is different between OSes +type MemoryInfoExStat struct { +} + +type MemoryMapsStat struct { +} + +func Pids() ([]int32, error) { + var ret []int32 + + pids, err := callPs("pid", 0, false) + if err != nil { + return ret, err + } + + for _, pid := range pids { + v, err := strconv.Atoi(pid[0]) + if err != nil { + return ret, err + } + ret = append(ret, int32(v)) + } + + return ret, nil +} + +func (p *Process) Ppid() (int32, error) { + r, err := callPs("ppid", p.Pid, false) + v, err := strconv.Atoi(r[0][0]) + if err != nil { + return 0, err + } + + return int32(v), err +} +func (p *Process) Name() (string, error) { + k, err := p.getKProc() + if err != nil { + return "", err + } + + return common.IntToString(k.Proc.P_comm[:]), nil +} +func (p *Process) Exe() (string, error) { + return "", common.ErrNotImplementedError +} + +// Cmdline returns the command line arguments of the process as a string with +// each argument separated by 0x20 ascii character. +func (p *Process) Cmdline() (string, error) { + r, err := callPs("command", p.Pid, false) + if err != nil { + return "", err + } + return strings.Join(r[0], " "), err +} + +// CmdlineSlice returns the command line arguments of the process as a slice with each +// element being an argument. Because of current deficiencies in the way that the command +// line arguments are found, single arguments that have spaces in the will actually be +// reported as two separate items. In order to do something better CGO would be needed +// to use the native darwin functions. +func (p *Process) CmdlineSlice() ([]string, error) { + r, err := callPs("command", p.Pid, false) + if err != nil { + return nil, err + } + return r[0], err +} +func (p *Process) CreateTime() (int64, error) { + return 0, common.ErrNotImplementedError +} +func (p *Process) Cwd() (string, error) { + return "", common.ErrNotImplementedError +} +func (p *Process) Parent() (*Process, error) { + rr, err := common.CallLsof(invoke, p.Pid, "-FR") + if err != nil { + return nil, err + } + for _, r := range rr { + if strings.HasPrefix(r, "p") { // skip if process + continue + } + l := string(r) + v, err := strconv.Atoi(strings.Replace(l, "R", "", 1)) + if err != nil { + return nil, err + } + return NewProcess(int32(v)) + } + return nil, fmt.Errorf("could not find parent line") +} +func (p *Process) Status() (string, error) { + r, err := callPs("state", p.Pid, false) + if err != nil { + return "", err + } + + return r[0][0], err +} +func (p *Process) Uids() ([]int32, error) { + k, err := p.getKProc() + if err != nil { + return nil, err + } + + // See: http://unix.superglobalmegacorp.com/Net2/newsrc/sys/ucred.h.html + userEffectiveUID := int32(k.Eproc.Ucred.UID) + + return []int32{userEffectiveUID}, nil +} +func (p *Process) Gids() ([]int32, error) { + k, err := p.getKProc() + if err != nil { + return nil, err + } + + gids := make([]int32, 0, 3) + gids = append(gids, int32(k.Eproc.Pcred.P_rgid), int32(k.Eproc.Ucred.Ngroups), int32(k.Eproc.Pcred.P_svgid)) + + return gids, nil +} +func (p *Process) Terminal() (string, error) { + return "", common.ErrNotImplementedError + /* + k, err := p.getKProc() + if err != nil { + return "", err + } + + ttyNr := uint64(k.Eproc.Tdev) + termmap, err := getTerminalMap() + if err != nil { + return "", err + } + + return termmap[ttyNr], nil + */ +} +func (p *Process) Nice() (int32, error) { + k, err := p.getKProc() + if err != nil { + return 0, err + } + return int32(k.Proc.P_nice), nil +} +func (p *Process) IOnice() (int32, error) { + return 0, common.ErrNotImplementedError +} +func (p *Process) Rlimit() ([]RlimitStat, error) { + var rlimit []RlimitStat + return rlimit, common.ErrNotImplementedError +} +func (p *Process) IOCounters() (*IOCountersStat, error) { + return nil, common.ErrNotImplementedError +} +func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) { + return nil, common.ErrNotImplementedError +} +func (p *Process) NumFDs() (int32, error) { + return 0, common.ErrNotImplementedError +} +func (p *Process) NumThreads() (int32, error) { + r, err := callPs("utime,stime", p.Pid, true) + if err != nil { + return 0, err + } + return int32(len(r)), nil +} +func (p *Process) Threads() (map[string]string, error) { + ret := make(map[string]string, 0) + return ret, common.ErrNotImplementedError +} + +func convertCPUTimes(s string) (ret float64, err error) { + var t int + var _tmp string + if strings.Contains(s, ":") { + _t := strings.Split(s, ":") + hour, err := strconv.Atoi(_t[0]) + if err != nil { + return ret, err + } + t += hour * 60 * 100 + _tmp = _t[1] + } else { + _tmp = s + } + + _t := strings.Split(_tmp, ".") + if err != nil { + return ret, err + } + h, err := strconv.Atoi(_t[0]) + t += h * 100 + h, err = strconv.Atoi(_t[1]) + t += h + return float64(t) / ClockTicks, nil +} +func (p *Process) Times() (*cpu.TimesStat, error) { + r, err := callPs("utime,stime", p.Pid, false) + + if err != nil { + return nil, err + } + + utime, err := convertCPUTimes(r[0][0]) + if err != nil { + return nil, err + } + stime, err := convertCPUTimes(r[0][1]) + if err != nil { + return nil, err + } + + ret := &cpu.TimesStat{ + CPU: "cpu", + User: utime, + System: stime, + } + return ret, nil +} +func (p *Process) CPUAffinity() ([]int32, error) { + return nil, common.ErrNotImplementedError +} +func (p *Process) MemoryInfo() (*MemoryInfoStat, error) { + r, err := callPs("rss,vsize,pagein", p.Pid, false) + if err != nil { + return nil, err + } + rss, err := strconv.Atoi(r[0][0]) + if err != nil { + return nil, err + } + vms, err := strconv.Atoi(r[0][1]) + if err != nil { + return nil, err + } + pagein, err := strconv.Atoi(r[0][2]) + if err != nil { + return nil, err + } + + ret := &MemoryInfoStat{ + RSS: uint64(rss) * 1024, + VMS: uint64(vms) * 1024, + Swap: uint64(pagein), + } + + return ret, nil +} +func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) { + return nil, common.ErrNotImplementedError +} + +func (p *Process) Children() ([]*Process, error) { + pids, err := common.CallPgrep(invoke, p.Pid) + if err != nil { + return nil, err + } + ret := make([]*Process, 0, len(pids)) + for _, pid := range pids { + np, err := NewProcess(pid) + if err != nil { + return nil, err + } + ret = append(ret, np) + } + return ret, nil +} + +func (p *Process) OpenFiles() ([]OpenFilesStat, error) { + return nil, common.ErrNotImplementedError +} + +func (p *Process) Connections() ([]net.ConnectionStat, error) { + return net.ConnectionsPid("all", p.Pid) +} + +func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error) { + return nil, common.ErrNotImplementedError +} + +func (p *Process) IsRunning() (bool, error) { + return true, common.ErrNotImplementedError +} +func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) { + var ret []MemoryMapsStat + return &ret, common.ErrNotImplementedError +} + +func processes() ([]Process, error) { + results := make([]Process, 0, 50) + + mib := []int32{CTLKern, KernProc, KernProcAll, 0} + buf, length, err := common.CallSyscall(mib) + if err != nil { + return results, err + } + + // get kinfo_proc size + k := KinfoProc{} + procinfoLen := int(unsafe.Sizeof(k)) + count := int(length / uint64(procinfoLen)) + /* + fmt.Println(length, procinfoLen, count) + b := buf[0*procinfoLen : 0*procinfoLen+procinfoLen] + fmt.Println(b) + kk, err := parseKinfoProc(b) + fmt.Printf("%#v", kk) + */ + + // parse buf to procs + for i := 0; i < count; i++ { + b := buf[i*procinfoLen : i*procinfoLen+procinfoLen] + k, err := parseKinfoProc(b) + if err != nil { + continue + } + p, err := NewProcess(int32(k.Proc.P_pid)) + if err != nil { + continue + } + results = append(results, *p) + } + + return results, nil +} + +func parseKinfoProc(buf []byte) (KinfoProc, error) { + var k KinfoProc + br := bytes.NewReader(buf) + + err := common.Read(br, binary.LittleEndian, &k) + if err != nil { + return k, err + } + + return k, nil +} + +// Returns a proc as defined here: +// http://unix.superglobalmegacorp.com/Net2/newsrc/sys/kinfo_proc.h.html +func (p *Process) getKProc() (*KinfoProc, error) { + mib := []int32{CTLKern, KernProc, KernProcPID, p.Pid} + procK := KinfoProc{} + length := uint64(unsafe.Sizeof(procK)) + buf := make([]byte, length) + _, _, syserr := syscall.Syscall6( + syscall.SYS___SYSCTL, + uintptr(unsafe.Pointer(&mib[0])), + uintptr(len(mib)), + uintptr(unsafe.Pointer(&buf[0])), + uintptr(unsafe.Pointer(&length)), + 0, + 0) + if syserr != 0 { + return nil, syserr + } + k, err := parseKinfoProc(buf) + if err != nil { + return nil, err + } + + return &k, nil +} + +func NewProcess(pid int32) (*Process, error) { + p := &Process{Pid: pid} + + return p, nil +} + +// call ps command. +// Return value deletes Header line(you must not input wrong arg). +// And splited by Space. Caller have responsibility to manage. +// If passed arg pid is 0, get information from all process. +func callPs(arg string, pid int32, threadOption bool) ([][]string, error) { + bin, err := exec.LookPath("ps") + if err != nil { + return [][]string{}, err + } + + var cmd []string + if pid == 0 { // will get from all processes. + cmd = []string{"-ax", "-o", arg} + } else if threadOption { + cmd = []string{"-x", "-o", arg, "-M", "-p", strconv.Itoa(int(pid))} + } else { + cmd = []string{"-x", "-o", arg, "-p", strconv.Itoa(int(pid))} + } + out, err := invoke.Command(bin, cmd...) + if err != nil { + return [][]string{}, err + } + lines := strings.Split(string(out), "\n") + + var ret [][]string + for _, l := range lines[1:] { + var lr []string + for _, r := range strings.Split(l, " ") { + if r == "" { + continue + } + lr = append(lr, strings.TrimSpace(r)) + } + if len(lr) != 0 { + ret = append(ret, lr) + } + } + + return ret, nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_darwin_amd64.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_darwin_amd64.go new file mode 100644 index 0000000000..f8e922385b --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_darwin_amd64.go @@ -0,0 +1,234 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_darwin.go + +package process + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int32 + Pad_cgo_0 [4]byte +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type UGid_t uint32 + +type KinfoProc struct { + Proc ExternProc + Eproc Eproc +} + +type Eproc struct { + Paddr *uint64 + Sess *Session + Pcred Upcred + Ucred Uucred + Pad_cgo_0 [4]byte + Vm Vmspace + Ppid int32 + Pgid int32 + Jobc int16 + Pad_cgo_1 [2]byte + Tdev int32 + Tpgid int32 + Pad_cgo_2 [4]byte + Tsess *Session + Wmesg [8]int8 + Xsize int32 + Xrssize int16 + Xccount int16 + Xswrss int16 + Pad_cgo_3 [2]byte + Flag int32 + Login [12]int8 + Spare [4]int32 + Pad_cgo_4 [4]byte +} + +type Proc struct{} + +type Session struct{} + +type ucred struct { + Link _Ctype_struct___0 + Ref uint64 + Posix Posix_cred + Label *Label + Audit Au_session +} + +type Uucred struct { + Ref int32 + UID uint32 + Ngroups int16 + Pad_cgo_0 [2]byte + Groups [16]uint32 +} + +type Upcred struct { + Pc_lock [72]int8 + Pc_ucred *ucred + P_ruid uint32 + P_svuid uint32 + P_rgid uint32 + P_svgid uint32 + P_refcnt int32 + Pad_cgo_0 [4]byte +} + +type Vmspace struct { + Dummy int32 + Pad_cgo_0 [4]byte + Dummy2 *int8 + Dummy3 [5]int32 + Pad_cgo_1 [4]byte + Dummy4 [3]*int8 +} + +type Sigacts struct{} + +type ExternProc struct { + P_un [16]byte + P_vmspace uint64 + P_sigacts uint64 + Pad_cgo_0 [3]byte + P_flag int32 + P_stat int8 + P_pid int32 + P_oppid int32 + P_dupfd int32 + Pad_cgo_1 [4]byte + User_stack uint64 + Exit_thread uint64 + P_debugger int32 + Sigwait int32 + P_estcpu uint32 + P_cpticks int32 + P_pctcpu uint32 + Pad_cgo_2 [4]byte + P_wchan uint64 + P_wmesg uint64 + P_swtime uint32 + P_slptime uint32 + P_realtimer Itimerval + P_rtime Timeval + P_uticks uint64 + P_sticks uint64 + P_iticks uint64 + P_traceflag int32 + Pad_cgo_3 [4]byte + P_tracep uint64 + P_siglist int32 + Pad_cgo_4 [4]byte + P_textvp uint64 + P_holdcnt int32 + P_sigmask uint32 + P_sigignore uint32 + P_sigcatch uint32 + P_priority uint8 + P_usrpri uint8 + P_nice int8 + P_comm [17]int8 + Pad_cgo_5 [4]byte + P_pgrp uint64 + P_addr uint64 + P_xstat uint16 + P_acflag uint16 + Pad_cgo_6 [4]byte + P_ru uint64 +} + +type Itimerval struct { + Interval Timeval + Value Timeval +} + +type Vnode struct{} + +type Pgrp struct{} + +type UserStruct struct{} + +type Au_session struct { + Aia_p *AuditinfoAddr + Mask AuMask +} + +type Posix_cred struct { + UID uint32 + Ruid uint32 + Svuid uint32 + Ngroups int16 + Pad_cgo_0 [2]byte + Groups [16]uint32 + Rgid uint32 + Svgid uint32 + Gmuid uint32 + Flags int32 +} + +type Label struct{} + +type AuditinfoAddr struct { + Auid uint32 + Mask AuMask + Termid AuTidAddr + Asid int32 + Flags uint64 +} +type AuMask struct { + Success uint32 + Failure uint32 +} +type AuTidAddr struct { + Port int32 + Type uint32 + Addr [4]uint32 +} + +type UcredQueue struct { + Next *ucred + Prev **ucred +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_freebsd.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_freebsd.go new file mode 100644 index 0000000000..5362128e6e --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_freebsd.go @@ -0,0 +1,336 @@ +// +build freebsd + +package process + +import ( + "bytes" + "encoding/binary" + "strings" + "syscall" + + cpu "github.com/shirou/gopsutil/cpu" + "github.com/shirou/gopsutil/internal/common" + net "github.com/shirou/gopsutil/net" +) + +// MemoryInfoExStat is different between OSes +type MemoryInfoExStat struct { +} + +type MemoryMapsStat struct { +} + +func Pids() ([]int32, error) { + var ret []int32 + procs, err := processes() + if err != nil { + return ret, nil + } + + for _, p := range procs { + ret = append(ret, p.Pid) + } + + return ret, nil +} + +func (p *Process) Ppid() (int32, error) { + k, err := p.getKProc() + if err != nil { + return 0, err + } + + return k.Ppid, nil +} +func (p *Process) Name() (string, error) { + k, err := p.getKProc() + if err != nil { + return "", err + } + + return common.IntToString(k.Comm[:]), nil +} +func (p *Process) Exe() (string, error) { + return "", common.ErrNotImplementedError +} + +func (p *Process) Cmdline() (string, error) { + mib := []int32{CTLKern, KernProc, KernProcArgs, p.Pid} + buf, _, err := common.CallSyscall(mib) + if err != nil { + return "", err + } + ret := strings.FieldsFunc(string(buf), func(r rune) bool { + if r == '\u0000' { + return true + } + return false + }) + + return strings.Join(ret, " "), nil +} + +func (p *Process) CmdlineSlice() ([]string, error) { + mib := []int32{CTLKern, KernProc, KernProcArgs, p.Pid} + buf, _, err := common.CallSyscall(mib) + if err != nil { + return nil, err + } + if len(buf) == 0 { + return nil, nil + } + if buf[len(buf)-1] == 0 { + buf = buf[:len(buf)-1] + } + parts := bytes.Split(buf, []byte{0}) + var strParts []string + for _, p := range parts { + strParts = append(strParts, string(p)) + } + + return strParts, nil +} +func (p *Process) CreateTime() (int64, error) { + return 0, common.ErrNotImplementedError +} +func (p *Process) Cwd() (string, error) { + return "", common.ErrNotImplementedError +} +func (p *Process) Parent() (*Process, error) { + return p, common.ErrNotImplementedError +} +func (p *Process) Status() (string, error) { + k, err := p.getKProc() + if err != nil { + return "", err + } + var s string + switch k.Stat { + case SIDL: + s = "I" + case SRUN: + s = "R" + case SSLEEP: + s = "S" + case SSTOP: + s = "T" + case SZOMB: + s = "Z" + case SWAIT: + s = "W" + case SLOCK: + s = "L" + } + + return s, nil +} +func (p *Process) Uids() ([]int32, error) { + k, err := p.getKProc() + if err != nil { + return nil, err + } + + uids := make([]int32, 0, 3) + + uids = append(uids, int32(k.Ruid), int32(k.Uid), int32(k.Svuid)) + + return uids, nil +} +func (p *Process) Gids() ([]int32, error) { + k, err := p.getKProc() + if err != nil { + return nil, err + } + + gids := make([]int32, 0, 3) + gids = append(gids, int32(k.Rgid), int32(k.Ngroups), int32(k.Svgid)) + + return gids, nil +} +func (p *Process) Terminal() (string, error) { + k, err := p.getKProc() + if err != nil { + return "", err + } + + ttyNr := uint64(k.Tdev) + + termmap, err := getTerminalMap() + if err != nil { + return "", err + } + + return termmap[ttyNr], nil +} +func (p *Process) Nice() (int32, error) { + k, err := p.getKProc() + if err != nil { + return 0, err + } + return int32(k.Nice), nil +} +func (p *Process) IOnice() (int32, error) { + return 0, common.ErrNotImplementedError +} +func (p *Process) Rlimit() ([]RlimitStat, error) { + var rlimit []RlimitStat + return rlimit, common.ErrNotImplementedError +} +func (p *Process) IOCounters() (*IOCountersStat, error) { + k, err := p.getKProc() + if err != nil { + return nil, err + } + return &IOCountersStat{ + ReadCount: uint64(k.Rusage.Inblock), + WriteCount: uint64(k.Rusage.Oublock), + }, nil +} +func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) { + return nil, common.ErrNotImplementedError +} +func (p *Process) NumFDs() (int32, error) { + return 0, common.ErrNotImplementedError +} +func (p *Process) NumThreads() (int32, error) { + k, err := p.getKProc() + if err != nil { + return 0, err + } + + return k.Numthreads, nil +} +func (p *Process) Threads() (map[string]string, error) { + ret := make(map[string]string, 0) + return ret, common.ErrNotImplementedError +} +func (p *Process) Times() (*cpu.TimesStat, error) { + k, err := p.getKProc() + if err != nil { + return nil, err + } + return &cpu.TimesStat{ + CPU: "cpu", + User: float64(k.Rusage.Utime.Sec) + float64(k.Rusage.Utime.Usec)/1000000, + System: float64(k.Rusage.Stime.Sec) + float64(k.Rusage.Stime.Usec)/1000000, + }, nil +} +func (p *Process) CPUAffinity() ([]int32, error) { + return nil, common.ErrNotImplementedError +} +func (p *Process) MemoryInfo() (*MemoryInfoStat, error) { + k, err := p.getKProc() + if err != nil { + return nil, err + } + v, err := syscall.Sysctl("vm.stats.vm.v_page_size") + if err != nil { + return nil, err + } + pageSize := common.LittleEndian.Uint16([]byte(v)) + + return &MemoryInfoStat{ + RSS: uint64(k.Rssize) * uint64(pageSize), + VMS: uint64(k.Size), + }, nil +} +func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) { + return nil, common.ErrNotImplementedError +} + +func (p *Process) Children() ([]*Process, error) { + pids, err := common.CallPgrep(invoke, p.Pid) + if err != nil { + return nil, err + } + ret := make([]*Process, 0, len(pids)) + for _, pid := range pids { + np, err := NewProcess(pid) + if err != nil { + return nil, err + } + ret = append(ret, np) + } + return ret, nil +} + +func (p *Process) OpenFiles() ([]OpenFilesStat, error) { + return nil, common.ErrNotImplementedError +} + +func (p *Process) Connections() ([]net.ConnectionStat, error) { + return nil, common.ErrNotImplementedError +} + +func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error) { + return nil, common.ErrNotImplementedError +} + +func (p *Process) IsRunning() (bool, error) { + return true, common.ErrNotImplementedError +} +func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) { + var ret []MemoryMapsStat + return &ret, common.ErrNotImplementedError +} + +func processes() ([]Process, error) { + results := make([]Process, 0, 50) + + mib := []int32{CTLKern, KernProc, KernProcProc, 0} + buf, length, err := common.CallSyscall(mib) + if err != nil { + return results, err + } + + // get kinfo_proc size + count := int(length / uint64(sizeOfKinfoProc)) + + // parse buf to procs + for i := 0; i < count; i++ { + b := buf[i*sizeOfKinfoProc : (i+1)*sizeOfKinfoProc] + k, err := parseKinfoProc(b) + if err != nil { + continue + } + p, err := NewProcess(int32(k.Pid)) + if err != nil { + continue + } + + results = append(results, *p) + } + + return results, nil +} + +func parseKinfoProc(buf []byte) (KinfoProc, error) { + var k KinfoProc + br := bytes.NewReader(buf) + err := common.Read(br, binary.LittleEndian, &k) + return k, err +} + +func (p *Process) getKProc() (*KinfoProc, error) { + mib := []int32{CTLKern, KernProc, KernProcPID, p.Pid} + + buf, length, err := common.CallSyscall(mib) + if err != nil { + return nil, err + } + if length != sizeOfKinfoProc { + return nil, err + } + + k, err := parseKinfoProc(buf) + if err != nil { + return nil, err + } + return &k, nil +} + +func NewProcess(pid int32) (*Process, error) { + p := &Process{Pid: pid} + + return p, nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_freebsd_386.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_freebsd_386.go new file mode 100644 index 0000000000..201f714601 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_freebsd_386.go @@ -0,0 +1,141 @@ +// +build freebsd +// +build 386 + +package process + +// copied from sys/sysctl.h +const ( + CTLKern = 1 // "high kernel": proc, limits + KernProc = 14 // struct: process entries + KernProcPID = 1 // by process id + KernProcProc = 8 // only return procs + KernProcPathname = 12 // path to executable + KernProcArgs = 7 // get/set arguments/proctitle +) + +const ( + SIDL = 1 + SRUN = 2 + SSLEEP = 3 + SSTOP = 4 + SZOMB = 5 + SWAIT = 6 + SLOCK = 7 +) + +const ( + sizeOfKinfoVmentry = 0x244 // TODO: really? + sizeOfKinfoProc = 0x220 +) + +type Timespec struct { + Sec int32 + Nsec int32 +} + +type Timeval struct { + Sec int32 + Usec int32 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int32 + Ixrss int32 + Idrss int32 + Isrss int32 + Minflt int32 + Majflt int32 + Nswap int32 + Inblock int32 + Oublock int32 + Msgsnd int32 + Msgrcv int32 + Nsignals int32 + Nvcsw int32 + Nivcsw int32 +} + +// copied from sys/user.h +type KinfoProc struct { + Structsize int32 + Layout int32 + Args int32 + Paddr int32 + Addr int32 + Tracep int32 + Textvp int32 + Fd int32 + Vmspace int32 + Wchan int32 + Pid int32 + Ppid int32 + Pgid int32 + Tpgid int32 + Sid int32 + Tsid int32 + Jobc [2]byte + SpareShort1 [2]byte + Tdev int32 + Siglist [16]byte + Sigmask [16]byte + Sigignore [16]byte + Sigcatch [16]byte + Uid int32 + Ruid int32 + Svuid int32 + Rgid int32 + Svgid int32 + Ngroups int16 + SpareShort2 [2]byte + Groups [64]byte + Size int32 + Rssize int32 + Swrss int32 + Tsize int32 + Dsize int32 + Ssize int32 + Xstat [2]byte + Acflag [2]byte + Pctcpu int32 + Estcpu int32 + Slptime int32 + Swtime int32 + Cow int32 + Runtime int64 + Start [8]byte + Childtime [8]byte + Flag int32 + Kflag int32 + Traceflag int32 + Stat int8 + Nice [1]byte + Lock [1]byte + Rqindex [1]byte + Oncpu [1]byte + Lastcpu [1]byte + Ocomm [17]byte + Wmesg [9]byte + Login [18]byte + Lockname [9]byte + Comm [20]int8 + Emul [17]byte + Sparestrings [68]byte + Spareints [36]byte + CrFlags int32 + Jid int32 + Numthreads int32 + Tid int32 + Pri int32 + Rusage Rusage + RusageCh [72]byte + Pcb int32 + Kstack int32 + Udata int32 + Tdaddr int32 + Spareptrs [24]byte + Spareint64s [48]byte + Sflag int32 + Tdflags int32 +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_freebsd_amd64.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_freebsd_amd64.go new file mode 100644 index 0000000000..79e2ba8816 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_freebsd_amd64.go @@ -0,0 +1,192 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_freebsd.go + +package process + +const ( + CTLKern = 1 + KernProc = 14 + KernProcPID = 1 + KernProcProc = 8 + KernProcPathname = 12 + KernProcArgs = 7 +) + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 +) + +const ( + sizeOfKinfoVmentry = 0x488 + sizeOfKinfoProc = 0x440 +) + +const ( + SIDL = 1 + SRUN = 2 + SSLEEP = 3 + SSTOP = 4 + SZOMB = 5 + SWAIT = 6 + SLOCK = 7 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int64 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur int64 + Max int64 +} + +type KinfoProc struct { + Structsize int32 + Layout int32 + Args int64 /* pargs */ + Paddr int64 /* proc */ + Addr int64 /* user */ + Tracep int64 /* vnode */ + Textvp int64 /* vnode */ + Fd int64 /* filedesc */ + Vmspace int64 /* vmspace */ + Wchan int64 + Pid int32 + Ppid int32 + Pgid int32 + Tpgid int32 + Sid int32 + Tsid int32 + Jobc int16 + Spare_short1 int16 + Tdev uint32 + Siglist [16]byte /* sigset */ + Sigmask [16]byte /* sigset */ + Sigignore [16]byte /* sigset */ + Sigcatch [16]byte /* sigset */ + Uid uint32 + Ruid uint32 + Svuid uint32 + Rgid uint32 + Svgid uint32 + Ngroups int16 + Spare_short2 int16 + Groups [16]uint32 + Size uint64 + Rssize int64 + Swrss int64 + Tsize int64 + Dsize int64 + Ssize int64 + Xstat uint16 + Acflag uint16 + Pctcpu uint32 + Estcpu uint32 + Slptime uint32 + Swtime uint32 + Cow uint32 + Runtime uint64 + Start Timeval + Childtime Timeval + Flag int64 + Kiflag int64 + Traceflag int32 + Stat int8 + Nice int8 + Lock int8 + Rqindex int8 + Oncpu uint8 + Lastcpu uint8 + Tdname [17]int8 + Wmesg [9]int8 + Login [18]int8 + Lockname [9]int8 + Comm [20]int8 + Emul [17]int8 + Loginclass [18]int8 + Sparestrings [50]int8 + Spareints [7]int32 + Flag2 int32 + Fibnum int32 + Cr_flags uint32 + Jid int32 + Numthreads int32 + Tid int32 + Pri Priority + Rusage Rusage + Rusage_ch Rusage + Pcb int64 /* pcb */ + Kstack int64 + Udata int64 + Tdaddr int64 /* thread */ + Spareptrs [6]int64 + Sparelongs [12]int64 + Sflag int64 + Tdflags int64 +} + +type Priority struct { + Class uint8 + Level uint8 + Native uint8 + User uint8 +} + +type KinfoVmentry struct { + Structsize int32 + Type int32 + Start uint64 + End uint64 + Offset uint64 + Vn_fileid uint64 + Vn_fsid uint32 + Flags int32 + Resident int32 + Private_resident int32 + Protection int32 + Ref_count int32 + Shadow_count int32 + Vn_type int32 + Vn_size uint64 + Vn_rdev uint32 + Vn_mode uint16 + Status uint16 + X_kve_ispare [12]int32 + Path [1024]int8 +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_linux.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_linux.go new file mode 100644 index 0000000000..ae300412c2 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_linux.go @@ -0,0 +1,767 @@ +// +build linux + +package process + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + "io/ioutil" + "os" + "path/filepath" + "strconv" + "strings" + "syscall" + + "github.com/shirou/gopsutil/cpu" + "github.com/shirou/gopsutil/host" + "github.com/shirou/gopsutil/internal/common" + "github.com/shirou/gopsutil/net" +) + +var ErrorNoChildren = errors.New("process does not have children") + +const ( + PrioProcess = 0 // linux/resource.h +) + +// MemoryInfoExStat is different between OSes +type MemoryInfoExStat struct { + RSS uint64 `json:"rss"` // bytes + VMS uint64 `json:"vms"` // bytes + Shared uint64 `json:"shared"` // bytes + Text uint64 `json:"text"` // bytes + Lib uint64 `json:"lib"` // bytes + Data uint64 `json:"data"` // bytes + Dirty uint64 `json:"dirty"` // bytes +} + +func (m MemoryInfoExStat) String() string { + s, _ := json.Marshal(m) + return string(s) +} + +type MemoryMapsStat struct { + Path string `json:"path"` + Rss uint64 `json:"rss"` + Size uint64 `json:"size"` + Pss uint64 `json:"pss"` + SharedClean uint64 `json:"sharedClean"` + SharedDirty uint64 `json:"sharedDirty"` + PrivateClean uint64 `json:"privateClean"` + PrivateDirty uint64 `json:"privateDirty"` + Referenced uint64 `json:"referenced"` + Anonymous uint64 `json:"anonymous"` + Swap uint64 `json:"swap"` +} + +// String returns JSON value of the process. +func (m MemoryMapsStat) String() string { + s, _ := json.Marshal(m) + return string(s) +} + +// NewProcess creates a new Process instance, it only stores the pid and +// checks that the process exists. Other method on Process can be used +// to get more information about the process. An error will be returned +// if the process does not exist. +func NewProcess(pid int32) (*Process, error) { + p := &Process{ + Pid: int32(pid), + } + file, err := os.Open(common.HostProc(strconv.Itoa(int(p.Pid)))) + defer file.Close() + return p, err +} + +// Ppid returns Parent Process ID of the process. +func (p *Process) Ppid() (int32, error) { + _, ppid, _, _, _, err := p.fillFromStat() + if err != nil { + return -1, err + } + return ppid, nil +} + +// Name returns name of the process. +func (p *Process) Name() (string, error) { + if p.name == "" { + if err := p.fillFromStatus(); err != nil { + return "", err + } + } + return p.name, nil +} + +// Exe returns executable path of the process. +func (p *Process) Exe() (string, error) { + return p.fillFromExe() +} + +// Cmdline returns the command line arguments of the process as a string with +// each argument separated by 0x20 ascii character. +func (p *Process) Cmdline() (string, error) { + return p.fillFromCmdline() +} + +// CmdlineSlice returns the command line arguments of the process as a slice with each +// element being an argument. +func (p *Process) CmdlineSlice() ([]string, error) { + return p.fillSliceFromCmdline() +} + +// CreateTime returns created time of the process in seconds since the epoch, in UTC. +func (p *Process) CreateTime() (int64, error) { + _, _, _, createTime, _, err := p.fillFromStat() + if err != nil { + return 0, err + } + return createTime, nil +} + +// Cwd returns current working directory of the process. +func (p *Process) Cwd() (string, error) { + return p.fillFromCwd() +} + +// Parent returns parent Process of the process. +func (p *Process) Parent() (*Process, error) { + err := p.fillFromStatus() + if err != nil { + return nil, err + } + if p.parent == 0 { + return nil, fmt.Errorf("wrong number of parents") + } + return NewProcess(p.parent) +} + +// Status returns the process status. +// Return value could be one of these. +// R: Running S: Sleep T: Stop I: Idle +// Z: Zombie W: Wait L: Lock +// The charactor is same within all supported platforms. +func (p *Process) Status() (string, error) { + err := p.fillFromStatus() + if err != nil { + return "", err + } + return p.status, nil +} + +// Uids returns user ids of the process as a slice of the int +func (p *Process) Uids() ([]int32, error) { + err := p.fillFromStatus() + if err != nil { + return []int32{}, err + } + return p.uids, nil +} + +// Gids returns group ids of the process as a slice of the int +func (p *Process) Gids() ([]int32, error) { + err := p.fillFromStatus() + if err != nil { + return []int32{}, err + } + return p.gids, nil +} + +// Terminal returns a terminal which is associated with the process. +func (p *Process) Terminal() (string, error) { + terminal, _, _, _, _, err := p.fillFromStat() + if err != nil { + return "", err + } + return terminal, nil +} + +// Nice returns a nice value (priority). +// Notice: gopsutil can not set nice value. +func (p *Process) Nice() (int32, error) { + _, _, _, _, nice, err := p.fillFromStat() + if err != nil { + return 0, err + } + return nice, nil +} + +// IOnice returns process I/O nice value (priority). +func (p *Process) IOnice() (int32, error) { + return 0, common.ErrNotImplementedError +} + +// Rlimit returns Resource Limits. +func (p *Process) Rlimit() ([]RlimitStat, error) { + return nil, common.ErrNotImplementedError +} + +// IOCounters returns IO Counters. +func (p *Process) IOCounters() (*IOCountersStat, error) { + return p.fillFromIO() +} + +// NumCtxSwitches returns the number of the context switches of the process. +func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) { + err := p.fillFromStatus() + if err != nil { + return nil, err + } + return p.numCtxSwitches, nil +} + +// NumFDs returns the number of File Descriptors used by the process. +func (p *Process) NumFDs() (int32, error) { + numFds, _, err := p.fillFromfd() + return numFds, err +} + +// NumThreads returns the number of threads used by the process. +func (p *Process) NumThreads() (int32, error) { + err := p.fillFromStatus() + if err != nil { + return 0, err + } + return p.numThreads, nil +} + +// Threads returns a map of threads +// +// Notice: Not implemented yet. always returns empty map. +func (p *Process) Threads() (map[string]string, error) { + ret := make(map[string]string, 0) + return ret, nil +} + +// Times returns CPU times of the process. +func (p *Process) Times() (*cpu.TimesStat, error) { + _, _, cpuTimes, _, _, err := p.fillFromStat() + if err != nil { + return nil, err + } + return cpuTimes, nil +} + +// CPUAffinity returns CPU affinity of the process. +// +// Notice: Not implemented yet. +func (p *Process) CPUAffinity() ([]int32, error) { + return nil, common.ErrNotImplementedError +} + +// MemoryInfo returns platform in-dependend memory information, such as RSS, VMS and Swap +func (p *Process) MemoryInfo() (*MemoryInfoStat, error) { + meminfo, _, err := p.fillFromStatm() + if err != nil { + return nil, err + } + return meminfo, nil +} + +// MemoryInfoEx returns platform dependend memory information. +func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) { + _, memInfoEx, err := p.fillFromStatm() + if err != nil { + return nil, err + } + return memInfoEx, nil +} + +// Children returns a slice of Process of the process. +func (p *Process) Children() ([]*Process, error) { + pids, err := common.CallPgrep(invoke, p.Pid) + if err != nil { + if pids == nil || len(pids) == 0 { + return nil, ErrorNoChildren + } + return nil, err + } + ret := make([]*Process, 0, len(pids)) + for _, pid := range pids { + np, err := NewProcess(pid) + if err != nil { + return nil, err + } + ret = append(ret, np) + } + return ret, nil +} + +// OpenFiles returns a slice of OpenFilesStat opend by the process. +// OpenFilesStat includes a file path and file descriptor. +func (p *Process) OpenFiles() ([]OpenFilesStat, error) { + _, ofs, err := p.fillFromfd() + if err != nil { + return nil, err + } + ret := make([]OpenFilesStat, len(ofs)) + for i, o := range ofs { + ret[i] = *o + } + + return ret, nil +} + +// Connections returns a slice of net.ConnectionStat used by the process. +// This returns all kind of the connection. This measn TCP, UDP or UNIX. +func (p *Process) Connections() ([]net.ConnectionStat, error) { + return net.ConnectionsPid("all", p.Pid) +} + +// NetIOCounters returns NetIOCounters of the process. +func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error) { + filename := common.HostProc(strconv.Itoa(int(p.Pid)), "net/dev") + return net.IOCountersByFile(pernic, filename) +} + +// IsRunning returns whether the process is running or not. +// Not implemented yet. +func (p *Process) IsRunning() (bool, error) { + return true, common.ErrNotImplementedError +} + +// MemoryMaps get memory maps from /proc/(pid)/smaps +func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) { + pid := p.Pid + var ret []MemoryMapsStat + smapsPath := common.HostProc(strconv.Itoa(int(pid)), "smaps") + contents, err := ioutil.ReadFile(smapsPath) + if err != nil { + return nil, err + } + lines := strings.Split(string(contents), "\n") + + // function of parsing a block + getBlock := func(first_line []string, block []string) (MemoryMapsStat, error) { + m := MemoryMapsStat{} + m.Path = first_line[len(first_line)-1] + + for _, line := range block { + if strings.Contains(line, "VmFlags") { + continue + } + field := strings.Split(line, ":") + if len(field) < 2 { + continue + } + v := strings.Trim(field[1], " kB") // remove last "kB" + t, err := strconv.ParseUint(v, 10, 64) + if err != nil { + return m, err + } + + switch field[0] { + case "Size": + m.Size = t + case "Rss": + m.Rss = t + case "Pss": + m.Pss = t + case "Shared_Clean": + m.SharedClean = t + case "Shared_Dirty": + m.SharedDirty = t + case "Private_Clean": + m.PrivateClean = t + case "Private_Dirty": + m.PrivateDirty = t + case "Referenced": + m.Referenced = t + case "Anonymous": + m.Anonymous = t + case "Swap": + m.Swap = t + } + } + return m, nil + } + + blocks := make([]string, 16) + for _, line := range lines { + field := strings.Split(line, " ") + if strings.HasSuffix(field[0], ":") == false { + // new block section + if len(blocks) > 0 { + g, err := getBlock(field, blocks) + if err != nil { + return &ret, err + } + ret = append(ret, g) + } + // starts new block + blocks = make([]string, 16) + } else { + blocks = append(blocks, line) + } + } + + return &ret, nil +} + +/** +** Internal functions +**/ + +// Get num_fds from /proc/(pid)/fd +func (p *Process) fillFromfd() (int32, []*OpenFilesStat, error) { + pid := p.Pid + statPath := common.HostProc(strconv.Itoa(int(pid)), "fd") + d, err := os.Open(statPath) + if err != nil { + return 0, nil, err + } + defer d.Close() + fnames, err := d.Readdirnames(-1) + numFDs := int32(len(fnames)) + + var openfiles []*OpenFilesStat + for _, fd := range fnames { + fpath := filepath.Join(statPath, fd) + filepath, err := os.Readlink(fpath) + if err != nil { + continue + } + t, err := strconv.ParseUint(fd, 10, 64) + if err != nil { + return numFDs, openfiles, err + } + o := &OpenFilesStat{ + Path: filepath, + Fd: t, + } + openfiles = append(openfiles, o) + } + + return numFDs, openfiles, nil +} + +// Get cwd from /proc/(pid)/cwd +func (p *Process) fillFromCwd() (string, error) { + pid := p.Pid + cwdPath := common.HostProc(strconv.Itoa(int(pid)), "cwd") + cwd, err := os.Readlink(cwdPath) + if err != nil { + return "", err + } + return string(cwd), nil +} + +// Get exe from /proc/(pid)/exe +func (p *Process) fillFromExe() (string, error) { + pid := p.Pid + exePath := common.HostProc(strconv.Itoa(int(pid)), "exe") + exe, err := os.Readlink(exePath) + if err != nil { + return "", err + } + return string(exe), nil +} + +// Get cmdline from /proc/(pid)/cmdline +func (p *Process) fillFromCmdline() (string, error) { + pid := p.Pid + cmdPath := common.HostProc(strconv.Itoa(int(pid)), "cmdline") + cmdline, err := ioutil.ReadFile(cmdPath) + if err != nil { + return "", err + } + ret := strings.FieldsFunc(string(cmdline), func(r rune) bool { + if r == '\u0000' { + return true + } + return false + }) + + return strings.Join(ret, " "), nil +} + +func (p *Process) fillSliceFromCmdline() ([]string, error) { + pid := p.Pid + cmdPath := common.HostProc(strconv.Itoa(int(pid)), "cmdline") + cmdline, err := ioutil.ReadFile(cmdPath) + if err != nil { + return nil, err + } + if len(cmdline) == 0 { + return nil, nil + } + if cmdline[len(cmdline)-1] == 0 { + cmdline = cmdline[:len(cmdline)-1] + } + parts := bytes.Split(cmdline, []byte{0}) + var strParts []string + for _, p := range parts { + strParts = append(strParts, string(p)) + } + + return strParts, nil +} + +// Get IO status from /proc/(pid)/io +func (p *Process) fillFromIO() (*IOCountersStat, error) { + pid := p.Pid + ioPath := common.HostProc(strconv.Itoa(int(pid)), "io") + ioline, err := ioutil.ReadFile(ioPath) + if err != nil { + return nil, err + } + lines := strings.Split(string(ioline), "\n") + ret := &IOCountersStat{} + + for _, line := range lines { + field := strings.Fields(line) + if len(field) < 2 { + continue + } + t, err := strconv.ParseUint(field[1], 10, 64) + if err != nil { + return nil, err + } + param := field[0] + if strings.HasSuffix(param, ":") { + param = param[:len(param)-1] + } + switch param { + case "syscr": + ret.ReadCount = t + case "syscw": + ret.WriteCount = t + case "readBytes": + ret.ReadBytes = t + case "writeBytes": + ret.WriteBytes = t + } + } + + return ret, nil +} + +// Get memory info from /proc/(pid)/statm +func (p *Process) fillFromStatm() (*MemoryInfoStat, *MemoryInfoExStat, error) { + pid := p.Pid + memPath := common.HostProc(strconv.Itoa(int(pid)), "statm") + contents, err := ioutil.ReadFile(memPath) + if err != nil { + return nil, nil, err + } + fields := strings.Split(string(contents), " ") + + vms, err := strconv.ParseUint(fields[0], 10, 64) + if err != nil { + return nil, nil, err + } + rss, err := strconv.ParseUint(fields[1], 10, 64) + if err != nil { + return nil, nil, err + } + memInfo := &MemoryInfoStat{ + RSS: rss * PageSize, + VMS: vms * PageSize, + } + + shared, err := strconv.ParseUint(fields[2], 10, 64) + if err != nil { + return nil, nil, err + } + text, err := strconv.ParseUint(fields[3], 10, 64) + if err != nil { + return nil, nil, err + } + lib, err := strconv.ParseUint(fields[4], 10, 64) + if err != nil { + return nil, nil, err + } + dirty, err := strconv.ParseUint(fields[5], 10, 64) + if err != nil { + return nil, nil, err + } + + memInfoEx := &MemoryInfoExStat{ + RSS: rss * PageSize, + VMS: vms * PageSize, + Shared: shared * PageSize, + Text: text * PageSize, + Lib: lib * PageSize, + Dirty: dirty * PageSize, + } + + return memInfo, memInfoEx, nil +} + +// Get various status from /proc/(pid)/status +func (p *Process) fillFromStatus() error { + pid := p.Pid + statPath := common.HostProc(strconv.Itoa(int(pid)), "status") + contents, err := ioutil.ReadFile(statPath) + if err != nil { + return err + } + lines := strings.Split(string(contents), "\n") + p.numCtxSwitches = &NumCtxSwitchesStat{} + p.memInfo = &MemoryInfoStat{} + for _, line := range lines { + tabParts := strings.SplitN(line, "\t", 2) + if len(tabParts) < 2 { + continue + } + value := tabParts[1] + switch strings.TrimRight(tabParts[0], ":") { + case "Name": + p.name = strings.Trim(value, " \t") + case "State": + p.status = value[0:1] + case "PPid", "Ppid": + pval, err := strconv.ParseInt(value, 10, 32) + if err != nil { + return err + } + p.parent = int32(pval) + case "Uid": + p.uids = make([]int32, 0, 4) + for _, i := range strings.Split(value, "\t") { + v, err := strconv.ParseInt(i, 10, 32) + if err != nil { + return err + } + p.uids = append(p.uids, int32(v)) + } + case "Gid": + p.gids = make([]int32, 0, 4) + for _, i := range strings.Split(value, "\t") { + v, err := strconv.ParseInt(i, 10, 32) + if err != nil { + return err + } + p.gids = append(p.gids, int32(v)) + } + case "Threads": + v, err := strconv.ParseInt(value, 10, 32) + if err != nil { + return err + } + p.numThreads = int32(v) + case "voluntary_ctxt_switches": + v, err := strconv.ParseInt(value, 10, 64) + if err != nil { + return err + } + p.numCtxSwitches.Voluntary = v + case "nonvoluntary_ctxt_switches": + v, err := strconv.ParseInt(value, 10, 64) + if err != nil { + return err + } + p.numCtxSwitches.Involuntary = v + case "VmRSS": + value := strings.Trim(value, " kB") // remove last "kB" + v, err := strconv.ParseUint(value, 10, 64) + if err != nil { + return err + } + p.memInfo.RSS = v * 1024 + case "VmSize": + value := strings.Trim(value, " kB") // remove last "kB" + v, err := strconv.ParseUint(value, 10, 64) + if err != nil { + return err + } + p.memInfo.VMS = v * 1024 + case "VmSwap": + value := strings.Trim(value, " kB") // remove last "kB" + v, err := strconv.ParseUint(value, 10, 64) + if err != nil { + return err + } + p.memInfo.Swap = v * 1024 + } + + } + return nil +} + +func (p *Process) fillFromStat() (string, int32, *cpu.TimesStat, int64, int32, error) { + pid := p.Pid + statPath := common.HostProc(strconv.Itoa(int(pid)), "stat") + contents, err := ioutil.ReadFile(statPath) + if err != nil { + return "", 0, nil, 0, 0, err + } + fields := strings.Fields(string(contents)) + + i := 1 + for !strings.HasSuffix(fields[i], ")") { + i++ + } + + termmap, err := getTerminalMap() + terminal := "" + if err == nil { + t, err := strconv.ParseUint(fields[i+5], 10, 64) + if err != nil { + return "", 0, nil, 0, 0, err + } + terminal = termmap[t] + } + + ppid, err := strconv.ParseInt(fields[i+2], 10, 32) + if err != nil { + return "", 0, nil, 0, 0, err + } + utime, err := strconv.ParseFloat(fields[i+12], 64) + if err != nil { + return "", 0, nil, 0, 0, err + } + + stime, err := strconv.ParseFloat(fields[i+13], 64) + if err != nil { + return "", 0, nil, 0, 0, err + } + + cpuTimes := &cpu.TimesStat{ + CPU: "cpu", + User: float64(utime / ClockTicks), + System: float64(stime / ClockTicks), + } + + bootTime, _ := host.BootTime() + t, err := strconv.ParseUint(fields[i+20], 10, 64) + if err != nil { + return "", 0, nil, 0, 0, err + } + ctime := (t / uint64(ClockTicks)) + uint64(bootTime) + createTime := int64(ctime * 1000) + + // p.Nice = mustParseInt32(fields[18]) + // use syscall instead of parse Stat file + snice, _ := syscall.Getpriority(PrioProcess, int(pid)) + nice := int32(snice) // FIXME: is this true? + + return terminal, int32(ppid), cpuTimes, createTime, nice, nil +} + +// Pids returns a slice of process ID list which are running now. +func Pids() ([]int32, error) { + var ret []int32 + + d, err := os.Open(common.HostProc()) + if err != nil { + return nil, err + } + defer d.Close() + + fnames, err := d.Readdirnames(-1) + if err != nil { + return nil, err + } + for _, fname := range fnames { + pid, err := strconv.ParseInt(fname, 10, 32) + if err != nil { + // if not numeric name, just skip + continue + } + ret = append(ret, int32(pid)) + } + + return ret, nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_linux_386.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_linux_386.go new file mode 100644 index 0000000000..541b854c75 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_linux_386.go @@ -0,0 +1,9 @@ +// +build linux +// +build 386 + +package process + +const ( + ClockTicks = 100 // C.sysconf(C._SC_CLK_TCK) + PageSize = 4096 // C.sysconf(C._SC_PAGE_SIZE) +) diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_linux_amd64.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_linux_amd64.go new file mode 100644 index 0000000000..b4a4ce8b7c --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_linux_amd64.go @@ -0,0 +1,9 @@ +// +build linux +// +build amd64 + +package process + +const ( + ClockTicks = 100 // C.sysconf(C._SC_CLK_TCK) + PageSize = 4096 // C.sysconf(C._SC_PAGE_SIZE) +) diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_linux_arm.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_linux_arm.go new file mode 100644 index 0000000000..c6123a4891 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_linux_arm.go @@ -0,0 +1,9 @@ +// +build linux +// +build arm + +package process + +const ( + ClockTicks = 100 // C.sysconf(C._SC_CLK_TCK) + PageSize = 4096 // C.sysconf(C._SC_PAGE_SIZE) +) diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_posix.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_posix.go new file mode 100644 index 0000000000..8853118ac6 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_posix.go @@ -0,0 +1,117 @@ +// +build linux freebsd darwin + +package process + +import ( + "os" + "os/exec" + "os/user" + "strconv" + "strings" + "syscall" +) + +// POSIX +func getTerminalMap() (map[uint64]string, error) { + ret := make(map[uint64]string) + var termfiles []string + + d, err := os.Open("/dev") + if err != nil { + return nil, err + } + defer d.Close() + + devnames, err := d.Readdirnames(-1) + for _, devname := range devnames { + if strings.HasPrefix(devname, "/dev/tty") { + termfiles = append(termfiles, "/dev/tty/"+devname) + } + } + + ptsd, err := os.Open("/dev/pts") + if err != nil { + return nil, err + } + defer ptsd.Close() + + ptsnames, err := ptsd.Readdirnames(-1) + for _, ptsname := range ptsnames { + termfiles = append(termfiles, "/dev/pts/"+ptsname) + } + + for _, name := range termfiles { + stat := syscall.Stat_t{} + if err = syscall.Stat(name, &stat); err != nil { + return nil, err + } + rdev := uint64(stat.Rdev) + ret[rdev] = strings.Replace(name, "/dev", "", -1) + } + return ret, nil +} + +// SendSignal sends a syscall.Signal to the process. +// Currently, SIGSTOP, SIGCONT, SIGTERM and SIGKILL are supported. +func (p *Process) SendSignal(sig syscall.Signal) error { + sigAsStr := "INT" + switch sig { + case syscall.SIGSTOP: + sigAsStr = "STOP" + case syscall.SIGCONT: + sigAsStr = "CONT" + case syscall.SIGTERM: + sigAsStr = "TERM" + case syscall.SIGKILL: + sigAsStr = "KILL" + } + + kill, err := exec.LookPath("kill") + if err != nil { + return err + } + cmd := exec.Command(kill, "-s", sigAsStr, strconv.Itoa(int(p.Pid))) + cmd.Stderr = os.Stderr + err = cmd.Run() + if err != nil { + return err + } + + return nil +} + +// Suspend sends SIGSTOP to the process. +func (p *Process) Suspend() error { + return p.SendSignal(syscall.SIGSTOP) +} + +// Resume sends SIGCONT to the process. +func (p *Process) Resume() error { + return p.SendSignal(syscall.SIGCONT) +} + +// Terminate sends SIGTERM to the process. +func (p *Process) Terminate() error { + return p.SendSignal(syscall.SIGTERM) +} + +// Kill sends SIGKILL to the process. +func (p *Process) Kill() error { + return p.SendSignal(syscall.SIGKILL) +} + +// Username returns a username of the process. +func (p *Process) Username() (string, error) { + uids, err := p.Uids() + if err != nil { + return "", err + } + if len(uids) > 0 { + u, err := user.LookupId(strconv.Itoa(int(uids[0]))) + if err != nil { + return "", err + } + return u.Username, nil + } + return "", nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_windows.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_windows.go new file mode 100644 index 0000000000..3176cde05a --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_windows.go @@ -0,0 +1,357 @@ +// +build windows + +package process + +import ( + "errors" + "fmt" + "strings" + "syscall" + "time" + "unsafe" + + "github.com/StackExchange/wmi" + "github.com/shirou/w32" + + cpu "github.com/shirou/gopsutil/cpu" + "github.com/shirou/gopsutil/internal/common" + net "github.com/shirou/gopsutil/net" +) + +const ( + NoMoreFiles = 0x12 + MaxPathLength = 260 +) + +type SystemProcessInformation struct { + NextEntryOffset uint64 + NumberOfThreads uint64 + Reserved1 [48]byte + Reserved2 [3]byte + UniqueProcessID uintptr + Reserved3 uintptr + HandleCount uint64 + Reserved4 [4]byte + Reserved5 [11]byte + PeakPagefileUsage uint64 + PrivatePageCount uint64 + Reserved6 [6]uint64 +} + +// Memory_info_ex is different between OSes +type MemoryInfoExStat struct { +} + +type MemoryMapsStat struct { +} + +type Win32_Process struct { + Name string + ExecutablePath *string + CommandLine *string + Priority uint32 + CreationDate *time.Time + ProcessID uint32 + ThreadCount uint32 + + /* + CSCreationClassName string + CSName string + Caption *string + CreationClassName string + Description *string + ExecutionState *uint16 + HandleCount uint32 + KernelModeTime uint64 + MaximumWorkingSetSize *uint32 + MinimumWorkingSetSize *uint32 + OSCreationClassName string + OSName string + OtherOperationCount uint64 + OtherTransferCount uint64 + PageFaults uint32 + PageFileUsage uint32 + ParentProcessID uint32 + PeakPageFileUsage uint32 + PeakVirtualSize uint64 + PeakWorkingSetSize uint32 + PrivatePageCount uint64 + ReadOperationCount uint64 + ReadTransferCount uint64 + Status *string + TerminationDate *time.Time + UserModeTime uint64 + WorkingSetSize uint64 + WriteOperationCount uint64 + WriteTransferCount uint64 + */ +} + +func Pids() ([]int32, error) { + var ret []int32 + + procs, err := processes() + if err != nil { + return ret, nil + } + + for _, proc := range procs { + ret = append(ret, proc.Pid) + } + + return ret, nil +} + +func (p *Process) Ppid() (int32, error) { + ret, _, _, err := p.getFromSnapProcess(p.Pid) + if err != nil { + return 0, err + } + return ret, nil +} + +func GetWin32Proc(pid int32) ([]Win32_Process, error) { + var dst []Win32_Process + query := fmt.Sprintf("WHERE ProcessId = %d", pid) + q := wmi.CreateQuery(&dst, query) + err := wmi.Query(q, &dst) + if err != nil { + return []Win32_Process{}, fmt.Errorf("could not get win32Proc: %s", err) + } + if len(dst) != 1 { + return []Win32_Process{}, fmt.Errorf("could not get win32Proc: empty") + } + return dst, nil +} + +func (p *Process) Name() (string, error) { + dst, err := GetWin32Proc(p.Pid) + if err != nil { + return "", fmt.Errorf("could not get Name: %s", err) + } + return dst[0].Name, nil +} +func (p *Process) Exe() (string, error) { + dst, err := GetWin32Proc(p.Pid) + if err != nil { + return "", fmt.Errorf("could not get ExecutablePath: %s", err) + } + return *dst[0].ExecutablePath, nil +} +func (p *Process) Cmdline() (string, error) { + dst, err := GetWin32Proc(p.Pid) + if err != nil { + return "", fmt.Errorf("could not get CommandLine: %s", err) + } + return *dst[0].CommandLine, nil +} + +// CmdlineSlice returns the command line arguments of the process as a slice with each +// element being an argument. This merely returns the CommandLine informations passed +// to the process split on the 0x20 ASCII character. +func (p *Process) CmdlineSlice() ([]string, error) { + cmdline, err := p.Cmdline() + if err != nil { + return nil, err + } + return strings.Split(cmdline, " "), nil +} + +func (p *Process) CreateTime() (int64, error) { + dst, err := GetWin32Proc(p.Pid) + if err != nil { + return 0, fmt.Errorf("could not get CreationDate: %s", err) + } + date := *dst[0].CreationDate + return date.Unix(), nil +} + +func (p *Process) Cwd() (string, error) { + return "", common.ErrNotImplementedError +} +func (p *Process) Parent() (*Process, error) { + return p, common.ErrNotImplementedError +} +func (p *Process) Status() (string, error) { + return "", common.ErrNotImplementedError +} +func (p *Process) Username() (string, error) { + return "", common.ErrNotImplementedError +} +func (p *Process) Uids() ([]int32, error) { + var uids []int32 + + return uids, common.ErrNotImplementedError +} +func (p *Process) Gids() ([]int32, error) { + var gids []int32 + return gids, common.ErrNotImplementedError +} +func (p *Process) Terminal() (string, error) { + return "", common.ErrNotImplementedError +} + +// Nice returnes priority in Windows +func (p *Process) Nice() (int32, error) { + dst, err := GetWin32Proc(p.Pid) + if err != nil { + return 0, fmt.Errorf("could not get Priority: %s", err) + } + return int32(dst[0].Priority), nil +} +func (p *Process) IOnice() (int32, error) { + return 0, common.ErrNotImplementedError +} +func (p *Process) Rlimit() ([]RlimitStat, error) { + var rlimit []RlimitStat + + return rlimit, common.ErrNotImplementedError +} +func (p *Process) IOCounters() (*IOCountersStat, error) { + return nil, common.ErrNotImplementedError +} +func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) { + return nil, common.ErrNotImplementedError +} +func (p *Process) NumFDs() (int32, error) { + return 0, common.ErrNotImplementedError +} +func (p *Process) NumThreads() (int32, error) { + dst, err := GetWin32Proc(p.Pid) + if err != nil { + return 0, fmt.Errorf("could not get ThreadCount: %s", err) + } + return int32(dst[0].ThreadCount), nil +} +func (p *Process) Threads() (map[string]string, error) { + ret := make(map[string]string, 0) + return ret, common.ErrNotImplementedError +} +func (p *Process) Times() (*cpu.TimesStat, error) { + return nil, common.ErrNotImplementedError +} +func (p *Process) CPUAffinity() ([]int32, error) { + return nil, common.ErrNotImplementedError +} +func (p *Process) MemoryInfo() (*MemoryInfoStat, error) { + return nil, common.ErrNotImplementedError +} +func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) { + return nil, common.ErrNotImplementedError +} + +func (p *Process) Children() ([]*Process, error) { + return nil, common.ErrNotImplementedError +} + +func (p *Process) OpenFiles() ([]OpenFilesStat, error) { + return nil, common.ErrNotImplementedError +} + +func (p *Process) Connections() ([]net.ConnectionStat, error) { + return nil, common.ErrNotImplementedError +} + +func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error) { + return nil, common.ErrNotImplementedError +} + +func (p *Process) IsRunning() (bool, error) { + return true, common.ErrNotImplementedError +} + +func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) { + var ret []MemoryMapsStat + return &ret, common.ErrNotImplementedError +} + +func NewProcess(pid int32) (*Process, error) { + p := &Process{Pid: pid} + + return p, nil +} + +func (p *Process) SendSignal(sig syscall.Signal) error { + return common.ErrNotImplementedError +} + +func (p *Process) Suspend() error { + return common.ErrNotImplementedError +} +func (p *Process) Resume() error { + return common.ErrNotImplementedError +} +func (p *Process) Terminate() error { + return common.ErrNotImplementedError +} +func (p *Process) Kill() error { + return common.ErrNotImplementedError +} + +func (p *Process) getFromSnapProcess(pid int32) (int32, int32, string, error) { + snap := w32.CreateToolhelp32Snapshot(w32.TH32CS_SNAPPROCESS, uint32(pid)) + if snap == 0 { + return 0, 0, "", syscall.GetLastError() + } + defer w32.CloseHandle(snap) + var pe32 w32.PROCESSENTRY32 + pe32.DwSize = uint32(unsafe.Sizeof(pe32)) + if w32.Process32First(snap, &pe32) == false { + return 0, 0, "", syscall.GetLastError() + } + + if pe32.Th32ProcessID == uint32(pid) { + szexe := syscall.UTF16ToString(pe32.SzExeFile[:]) + return int32(pe32.Th32ParentProcessID), int32(pe32.CntThreads), szexe, nil + } + + for w32.Process32Next(snap, &pe32) { + if pe32.Th32ProcessID == uint32(pid) { + szexe := syscall.UTF16ToString(pe32.SzExeFile[:]) + return int32(pe32.Th32ParentProcessID), int32(pe32.CntThreads), szexe, nil + } + } + return 0, 0, "", errors.New("Couldn't find pid:" + string(pid)) +} + +// Get processes +func processes() ([]*Process, error) { + + var dst []Win32_Process + q := wmi.CreateQuery(&dst, "") + err := wmi.Query(q, &dst) + if err != nil { + return []*Process{}, err + } + if len(dst) == 0 { + return []*Process{}, fmt.Errorf("could not get Process") + } + results := make([]*Process, 0, len(dst)) + for _, proc := range dst { + p, err := NewProcess(int32(proc.ProcessID)) + if err != nil { + continue + } + results = append(results, p) + } + + return results, nil +} + +func getProcInfo(pid int32) (*SystemProcessInformation, error) { + initialBufferSize := uint64(0x4000) + bufferSize := initialBufferSize + buffer := make([]byte, bufferSize) + + var sysProcInfo SystemProcessInformation + ret, _, _ := common.ProcNtQuerySystemInformation.Call( + uintptr(unsafe.Pointer(&sysProcInfo)), + uintptr(unsafe.Pointer(&buffer[0])), + uintptr(unsafe.Pointer(&bufferSize)), + uintptr(unsafe.Pointer(&bufferSize))) + if ret != 0 { + return nil, syscall.GetLastError() + } + + return &sysProcInfo, nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/process/types_darwin.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/types_darwin.go new file mode 100644 index 0000000000..21216cd09a --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/types_darwin.go @@ -0,0 +1,160 @@ +// 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. + +// Hand Writing +// - all pointer in ExternProc to uint64 + +// +build ignore + +/* +Input to cgo -godefs. +*/ + +// +godefs map struct_in_addr [4]byte /* in_addr */ +// +godefs map struct_in6_addr [16]byte /* in6_addr */ +// +godefs map struct_ [16]byte /* in6_addr */ + +package process + +/* +#define __DARWIN_UNIX03 0 +#define KERNEL +#define _DARWIN_USE_64_BIT_INODE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + sizeofPtr = sizeof(void*), +}; + +union sockaddr_all { + struct sockaddr s1; // this one gets used for fields + struct sockaddr_in s2; // these pad it out + struct sockaddr_in6 s3; + struct sockaddr_un s4; + struct sockaddr_dl s5; +}; + +struct sockaddr_any { + struct sockaddr addr; + char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; +}; + +struct ucred_queue { + struct ucred *tqe_next; + struct ucred **tqe_prev; + TRACEBUF +}; + +*/ +import "C" + +// Machine characteristics; for internal use. + +const ( + sizeofPtr = C.sizeofPtr + sizeofShort = C.sizeof_short + sizeofInt = C.sizeof_int + sizeofLong = C.sizeof_long + sizeofLongLong = C.sizeof_longlong +) + +// Basic types + +type ( + _C_short C.short + _C_int C.int + _C_long C.long + _C_long_long C.longlong +) + +// Time + +type Timespec C.struct_timespec + +type Timeval C.struct_timeval + +// Processes + +type Rusage C.struct_rusage + +type Rlimit C.struct_rlimit + +type UGid_t C.gid_t + +type KinfoProc C.struct_kinfo_proc + +type Eproc C.struct_eproc + +type Proc C.struct_proc + +type Session C.struct_session + +type ucred C.struct_ucred + +type Uucred C.struct__ucred + +type Upcred C.struct__pcred + +type Vmspace C.struct_vmspace + +type Sigacts C.struct_sigacts + +type ExternProc C.struct_extern_proc + +type Itimerval C.struct_itimerval + +type Vnode C.struct_vnode + +type Pgrp C.struct_pgrp + +type UserStruct C.struct_user + +type Au_session C.struct_au_session + +type Posix_cred C.struct_posix_cred + +type Label C.struct_label + +type AuditinfoAddr C.struct_auditinfo_addr +type AuMask C.struct_au_mask +type AuTidAddr C.struct_au_tid_addr + +// TAILQ(ucred) +type UcredQueue C.struct_ucred_queue diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/process/types_freebsd.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/types_freebsd.go new file mode 100644 index 0000000000..aa7b3462de --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/types_freebsd.go @@ -0,0 +1,95 @@ +// +build ignore + +// We still need editing by hands. +// go tool cgo -godefs types_freebsd.go | sed 's/\*int64/int64/' | sed 's/\*byte/int64/' > process_freebsd_amd64.go + +/* +Input to cgo -godefs. +*/ + +// +godefs map struct_pargs int64 /* pargs */ +// +godefs map struct_proc int64 /* proc */ +// +godefs map struct_user int64 /* user */ +// +godefs map struct_vnode int64 /* vnode */ +// +godefs map struct_vnode int64 /* vnode */ +// +godefs map struct_filedesc int64 /* filedesc */ +// +godefs map struct_vmspace int64 /* vmspace */ +// +godefs map struct_pcb int64 /* pcb */ +// +godefs map struct_thread int64 /* thread */ +// +godefs map struct___sigset [16]byte /* sigset */ + +package process + +/* +#include +#include + +enum { + sizeofPtr = sizeof(void*), +}; + + +*/ +import "C" + +// Machine characteristics; for internal use. + +const ( + CTLKern = 1 // "high kernel": proc, limits + KernProc = 14 // struct: process entries + KernProcPID = 1 // by process id + KernProcProc = 8 // only return procs + KernProcPathname = 12 // path to executable + KernProcArgs = 7 // get/set arguments/proctitle +) + +const ( + sizeofPtr = C.sizeofPtr + sizeofShort = C.sizeof_short + sizeofInt = C.sizeof_int + sizeofLong = C.sizeof_long + sizeofLongLong = C.sizeof_longlong +) + +const ( + sizeOfKinfoVmentry = C.sizeof_struct_kinfo_vmentry + sizeOfKinfoProc = C.sizeof_struct_kinfo_proc +) + +// from sys/proc.h +const ( + SIDL = 1 /* Process being created by fork. */ + SRUN = 2 /* Currently runnable. */ + SSLEEP = 3 /* Sleeping on an address. */ + SSTOP = 4 /* Process debugging or suspension. */ + SZOMB = 5 /* Awaiting collection by parent. */ + SWAIT = 6 /* Waiting for interrupt. */ + SLOCK = 7 /* Blocked on a lock. */ +) + +// Basic types + +type ( + _C_short C.short + _C_int C.int + _C_long C.long + _C_long_long C.longlong +) + +// Time + +type Timespec C.struct_timespec + +type Timeval C.struct_timeval + +// Processes + +type Rusage C.struct_rusage + +type Rlimit C.struct_rlimit + +type KinfoProc C.struct_kinfo_proc + +type Priority C.struct_priority + +type KinfoVmentry C.struct_kinfo_vmentry diff --git a/Godeps/_workspace/src/github.com/shirou/w32/AUTHORS b/Godeps/_workspace/src/github.com/shirou/w32/AUTHORS new file mode 100644 index 0000000000..c0785e8203 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/w32/AUTHORS @@ -0,0 +1,16 @@ +# This is the official list of 'w32' authors for copyright purposes. + +# Names should be added to this file as +# Name or Organization +# The email address is not required for organizations. + +# Please keep the list sorted. + +# Contributors +# ============ + +Allen Dang +Benny Siegert +Bruno Bigras +Gerald Rosenberg +Michael Henke \ No newline at end of file diff --git a/Godeps/_workspace/src/github.com/shirou/w32/LICENSE b/Godeps/_workspace/src/github.com/shirou/w32/LICENSE new file mode 100644 index 0000000000..9f36608c87 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/w32/LICENSE @@ -0,0 +1,23 @@ +Copyright (c) 2010-2012 The w32 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: +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. The names of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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. diff --git a/Godeps/_workspace/src/github.com/shirou/w32/README.md b/Godeps/_workspace/src/github.com/shirou/w32/README.md new file mode 100644 index 0000000000..ed196e7661 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/w32/README.md @@ -0,0 +1,33 @@ +About w32 +========== + +w32 is a wrapper of windows apis for the Go Programming Language. + +It wraps win32 apis to "Go style" to make them easier to use. + +Setup +===== + +1. Make sure you have a working Go installation and build environment, + see this go-nuts post for details: + http://groups.google.com/group/golang-nuts/msg/5c87630a84f4fd0c + + Updated versions of the Windows Go build are available here: + http://code.google.com/p/gomingw/downloads/list + +2. Create a "gopath" directory if you do not have one yet and set the + GOPATH variable accordingly. For example: + mkdir -p go-externals/src + export GOPATH=${PWD}/go-externals + +3. go get github.com/AllenDang/w32 + +4. go install github.com/AllenDang/w32... + +Contribute +========== + +Contributions in form of design, code, documentation, bug reporting or other +ways you see fit are very welcome. + +Thank You! diff --git a/Godeps/_workspace/src/github.com/shirou/w32/advapi32.go b/Godeps/_workspace/src/github.com/shirou/w32/advapi32.go new file mode 100644 index 0000000000..2f8a4fe010 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/w32/advapi32.go @@ -0,0 +1,299 @@ +// Copyright 2010-2012 The W32 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 w32 + +import ( + "errors" + "fmt" + "syscall" + "unsafe" +) + +var ( + modadvapi32 = syscall.NewLazyDLL("advapi32.dll") + + procRegCreateKeyEx = modadvapi32.NewProc("RegCreateKeyExW") + procRegOpenKeyEx = modadvapi32.NewProc("RegOpenKeyExW") + procRegCloseKey = modadvapi32.NewProc("RegCloseKey") + procRegGetValue = modadvapi32.NewProc("RegGetValueW") + procRegEnumKeyEx = modadvapi32.NewProc("RegEnumKeyExW") + // procRegSetKeyValue = modadvapi32.NewProc("RegSetKeyValueW") + procRegSetValueEx = modadvapi32.NewProc("RegSetValueExW") + procOpenEventLog = modadvapi32.NewProc("OpenEventLogW") + procReadEventLog = modadvapi32.NewProc("ReadEventLogW") + procCloseEventLog = modadvapi32.NewProc("CloseEventLog") + procOpenSCManager = modadvapi32.NewProc("OpenSCManagerW") + procCloseServiceHandle = modadvapi32.NewProc("CloseServiceHandle") + procOpenService = modadvapi32.NewProc("OpenServiceW") + procStartService = modadvapi32.NewProc("StartServiceW") + procControlService = modadvapi32.NewProc("ControlService") +) + +func RegCreateKey(hKey HKEY, subKey string) HKEY { + var result HKEY + ret, _, _ := procRegCreateKeyEx.Call( + uintptr(hKey), + uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(subKey))), + uintptr(0), + uintptr(0), + uintptr(0), + uintptr(KEY_ALL_ACCESS), + uintptr(0), + uintptr(unsafe.Pointer(&result)), + uintptr(0)) + _ = ret + return result +} + +func RegOpenKeyEx(hKey HKEY, subKey string, samDesired uint32) HKEY { + var result HKEY + ret, _, _ := procRegOpenKeyEx.Call( + uintptr(hKey), + uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(subKey))), + uintptr(0), + uintptr(samDesired), + uintptr(unsafe.Pointer(&result))) + + if ret != ERROR_SUCCESS { + panic(fmt.Sprintf("RegOpenKeyEx(%d, %s, %d) failed", hKey, subKey, samDesired)) + } + return result +} + +func RegCloseKey(hKey HKEY) error { + var err error + ret, _, _ := procRegCloseKey.Call( + uintptr(hKey)) + + if ret != ERROR_SUCCESS { + err = errors.New("RegCloseKey failed") + } + return err +} + +func RegGetRaw(hKey HKEY, subKey string, value string) []byte { + var bufLen uint32 + var valptr unsafe.Pointer + if len(value) > 0 { + valptr = unsafe.Pointer(syscall.StringToUTF16Ptr(value)) + } + procRegGetValue.Call( + uintptr(hKey), + uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(subKey))), + uintptr(valptr), + uintptr(RRF_RT_ANY), + 0, + 0, + uintptr(unsafe.Pointer(&bufLen))) + + if bufLen == 0 { + return nil + } + + buf := make([]byte, bufLen) + ret, _, _ := procRegGetValue.Call( + uintptr(hKey), + uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(subKey))), + uintptr(valptr), + uintptr(RRF_RT_ANY), + 0, + uintptr(unsafe.Pointer(&buf[0])), + uintptr(unsafe.Pointer(&bufLen))) + + if ret != ERROR_SUCCESS { + return nil + } + + return buf +} + +func RegSetBinary(hKey HKEY, subKey string, value []byte) (errno int) { + var lptr, vptr unsafe.Pointer + if len(subKey) > 0 { + lptr = unsafe.Pointer(syscall.StringToUTF16Ptr(subKey)) + } + if len(value) > 0 { + vptr = unsafe.Pointer(&value[0]) + } + ret, _, _ := procRegSetValueEx.Call( + uintptr(hKey), + uintptr(lptr), + uintptr(0), + uintptr(REG_BINARY), + uintptr(vptr), + uintptr(len(value))) + + return int(ret) +} + +func RegGetString(hKey HKEY, subKey string, value string) string { + var bufLen uint32 + procRegGetValue.Call( + uintptr(hKey), + uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(subKey))), + uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(value))), + uintptr(RRF_RT_REG_SZ), + 0, + 0, + uintptr(unsafe.Pointer(&bufLen))) + + if bufLen == 0 { + return "" + } + + buf := make([]uint16, bufLen) + ret, _, _ := procRegGetValue.Call( + uintptr(hKey), + uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(subKey))), + uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(value))), + uintptr(RRF_RT_REG_SZ), + 0, + uintptr(unsafe.Pointer(&buf[0])), + uintptr(unsafe.Pointer(&bufLen))) + + if ret != ERROR_SUCCESS { + return "" + } + + return syscall.UTF16ToString(buf) +} + +/* +func RegSetKeyValue(hKey HKEY, subKey string, valueName string, dwType uint32, data uintptr, cbData uint16) (errno int) { + ret, _, _ := procRegSetKeyValue.Call( + uintptr(hKey), + uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(subKey))), + uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(valueName))), + uintptr(dwType), + data, + uintptr(cbData)) + + return int(ret) +} +*/ + +func RegEnumKeyEx(hKey HKEY, index uint32) string { + var bufLen uint32 = 255 + buf := make([]uint16, bufLen) + procRegEnumKeyEx.Call( + uintptr(hKey), + uintptr(index), + uintptr(unsafe.Pointer(&buf[0])), + uintptr(unsafe.Pointer(&bufLen)), + 0, + 0, + 0, + 0) + return syscall.UTF16ToString(buf) +} + +func OpenEventLog(servername string, sourcename string) HANDLE { + ret, _, _ := procOpenEventLog.Call( + uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(servername))), + uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(sourcename)))) + + return HANDLE(ret) +} + +func ReadEventLog(eventlog HANDLE, readflags, recordoffset uint32, buffer []byte, numberofbytestoread uint32, bytesread, minnumberofbytesneeded *uint32) bool { + ret, _, _ := procReadEventLog.Call( + uintptr(eventlog), + uintptr(readflags), + uintptr(recordoffset), + uintptr(unsafe.Pointer(&buffer[0])), + uintptr(numberofbytestoread), + uintptr(unsafe.Pointer(bytesread)), + uintptr(unsafe.Pointer(minnumberofbytesneeded))) + + return ret != 0 +} + +func CloseEventLog(eventlog HANDLE) bool { + ret, _, _ := procCloseEventLog.Call( + uintptr(eventlog)) + + return ret != 0 +} + +func OpenSCManager(lpMachineName, lpDatabaseName string, dwDesiredAccess uint32) (HANDLE, error) { + var p1, p2 uintptr + if len(lpMachineName) > 0 { + p1 = uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpMachineName))) + } + if len(lpDatabaseName) > 0 { + p2 = uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpDatabaseName))) + } + ret, _, _ := procOpenSCManager.Call( + p1, + p2, + uintptr(dwDesiredAccess)) + + if ret == 0 { + return 0, syscall.GetLastError() + } + + return HANDLE(ret), nil +} + +func CloseServiceHandle(hSCObject HANDLE) error { + ret, _, _ := procCloseServiceHandle.Call(uintptr(hSCObject)) + if ret == 0 { + return syscall.GetLastError() + } + return nil +} + +func OpenService(hSCManager HANDLE, lpServiceName string, dwDesiredAccess uint32) (HANDLE, error) { + ret, _, _ := procOpenService.Call( + uintptr(hSCManager), + uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpServiceName))), + uintptr(dwDesiredAccess)) + + if ret == 0 { + return 0, syscall.GetLastError() + } + + return HANDLE(ret), nil +} + +func StartService(hService HANDLE, lpServiceArgVectors []string) error { + l := len(lpServiceArgVectors) + var ret uintptr + if l == 0 { + ret, _, _ = procStartService.Call( + uintptr(hService), + 0, + 0) + } else { + lpArgs := make([]uintptr, l) + for i := 0; i < l; i++ { + lpArgs[i] = uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpServiceArgVectors[i]))) + } + + ret, _, _ = procStartService.Call( + uintptr(hService), + uintptr(l), + uintptr(unsafe.Pointer(&lpArgs[0]))) + } + + if ret == 0 { + return syscall.GetLastError() + } + + return nil +} + +func ControlService(hService HANDLE, dwControl uint32, lpServiceStatus *SERVICE_STATUS) bool { + if lpServiceStatus == nil { + panic("ControlService:lpServiceStatus cannot be nil") + } + + ret, _, _ := procControlService.Call( + uintptr(hService), + uintptr(dwControl), + uintptr(unsafe.Pointer(lpServiceStatus))) + + return ret != 0 +} diff --git a/Godeps/_workspace/src/github.com/shirou/w32/comctl32.go b/Godeps/_workspace/src/github.com/shirou/w32/comctl32.go new file mode 100644 index 0000000000..4f4e6b53a5 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/w32/comctl32.go @@ -0,0 +1,109 @@ +// Copyright 2010-2012 The W32 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 w32 + +import ( + "syscall" + "unsafe" +) + +var ( + modcomctl32 = syscall.NewLazyDLL("comctl32.dll") + + procInitCommonControlsEx = modcomctl32.NewProc("InitCommonControlsEx") + procImageList_Create = modcomctl32.NewProc("ImageList_Create") + procImageList_Destroy = modcomctl32.NewProc("ImageList_Destroy") + procImageList_GetImageCount = modcomctl32.NewProc("ImageList_GetImageCount") + procImageList_SetImageCount = modcomctl32.NewProc("ImageList_SetImageCount") + procImageList_Add = modcomctl32.NewProc("ImageList_Add") + procImageList_ReplaceIcon = modcomctl32.NewProc("ImageList_ReplaceIcon") + procImageList_Remove = modcomctl32.NewProc("ImageList_Remove") + procTrackMouseEvent = modcomctl32.NewProc("_TrackMouseEvent") +) + +func InitCommonControlsEx(lpInitCtrls *INITCOMMONCONTROLSEX) bool { + ret, _, _ := procInitCommonControlsEx.Call( + uintptr(unsafe.Pointer(lpInitCtrls))) + + return ret != 0 +} + +func ImageList_Create(cx, cy int, flags uint, cInitial, cGrow int) HIMAGELIST { + ret, _, _ := procImageList_Create.Call( + uintptr(cx), + uintptr(cy), + uintptr(flags), + uintptr(cInitial), + uintptr(cGrow)) + + if ret == 0 { + panic("Create image list failed") + } + + return HIMAGELIST(ret) +} + +func ImageList_Destroy(himl HIMAGELIST) bool { + ret, _, _ := procImageList_Destroy.Call( + uintptr(himl)) + + return ret != 0 +} + +func ImageList_GetImageCount(himl HIMAGELIST) int { + ret, _, _ := procImageList_GetImageCount.Call( + uintptr(himl)) + + return int(ret) +} + +func ImageList_SetImageCount(himl HIMAGELIST, uNewCount uint) bool { + ret, _, _ := procImageList_SetImageCount.Call( + uintptr(himl), + uintptr(uNewCount)) + + return ret != 0 +} + +func ImageList_Add(himl HIMAGELIST, hbmImage, hbmMask HBITMAP) int { + ret, _, _ := procImageList_Add.Call( + uintptr(himl), + uintptr(hbmImage), + uintptr(hbmMask)) + + return int(ret) +} + +func ImageList_ReplaceIcon(himl HIMAGELIST, i int, hicon HICON) int { + ret, _, _ := procImageList_ReplaceIcon.Call( + uintptr(himl), + uintptr(i), + uintptr(hicon)) + + return int(ret) +} + +func ImageList_AddIcon(himl HIMAGELIST, hicon HICON) int { + return ImageList_ReplaceIcon(himl, -1, hicon) +} + +func ImageList_Remove(himl HIMAGELIST, i int) bool { + ret, _, _ := procImageList_Remove.Call( + uintptr(himl), + uintptr(i)) + + return ret != 0 +} + +func ImageList_RemoveAll(himl HIMAGELIST) bool { + return ImageList_Remove(himl, -1) +} + +func TrackMouseEvent(tme *TRACKMOUSEEVENT) bool { + ret, _, _ := procTrackMouseEvent.Call( + uintptr(unsafe.Pointer(tme))) + + return ret != 0 +} diff --git a/Godeps/_workspace/src/github.com/shirou/w32/comdlg32.go b/Godeps/_workspace/src/github.com/shirou/w32/comdlg32.go new file mode 100644 index 0000000000..37bc98581d --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/w32/comdlg32.go @@ -0,0 +1,38 @@ +// Copyright 2010-2012 The W32 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 w32 + +import ( + "syscall" + "unsafe" +) + +var ( + modcomdlg32 = syscall.NewLazyDLL("comdlg32.dll") + + procGetSaveFileName = modcomdlg32.NewProc("GetSaveFileNameW") + procGetOpenFileName = modcomdlg32.NewProc("GetOpenFileNameW") + procCommDlgExtendedError = modcomdlg32.NewProc("CommDlgExtendedError") +) + +func GetOpenFileName(ofn *OPENFILENAME) bool { + ret, _, _ := procGetOpenFileName.Call( + uintptr(unsafe.Pointer(ofn))) + + return ret != 0 +} + +func GetSaveFileName(ofn *OPENFILENAME) bool { + ret, _, _ := procGetSaveFileName.Call( + uintptr(unsafe.Pointer(ofn))) + + return ret != 0 +} + +func CommDlgExtendedError() uint { + ret, _, _ := procCommDlgExtendedError.Call() + + return uint(ret) +} diff --git a/Godeps/_workspace/src/github.com/shirou/w32/constants.go b/Godeps/_workspace/src/github.com/shirou/w32/constants.go new file mode 100644 index 0000000000..62d2d4b318 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/w32/constants.go @@ -0,0 +1,2661 @@ +// Copyright 2010-2012 The W32 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 w32 + +const ( + FALSE = 0 + TRUE = 1 +) + +const ( + NO_ERROR = 0 + ERROR_SUCCESS = 0 + ERROR_FILE_NOT_FOUND = 2 + ERROR_PATH_NOT_FOUND = 3 + ERROR_ACCESS_DENIED = 5 + ERROR_INVALID_HANDLE = 6 + ERROR_BAD_FORMAT = 11 + ERROR_INVALID_NAME = 123 + ERROR_MORE_DATA = 234 + ERROR_NO_MORE_ITEMS = 259 + ERROR_INVALID_SERVICE_CONTROL = 1052 + ERROR_SERVICE_REQUEST_TIMEOUT = 1053 + ERROR_SERVICE_NO_THREAD = 1054 + ERROR_SERVICE_DATABASE_LOCKED = 1055 + ERROR_SERVICE_ALREADY_RUNNING = 1056 + ERROR_SERVICE_DISABLED = 1058 + ERROR_SERVICE_DOES_NOT_EXIST = 1060 + ERROR_SERVICE_CANNOT_ACCEPT_CTRL = 1061 + ERROR_SERVICE_NOT_ACTIVE = 1062 + ERROR_DATABASE_DOES_NOT_EXIST = 1065 + ERROR_SERVICE_DEPENDENCY_FAIL = 1068 + ERROR_SERVICE_LOGON_FAILED = 1069 + ERROR_SERVICE_MARKED_FOR_DELETE = 1072 + ERROR_SERVICE_DEPENDENCY_DELETED = 1075 +) + +const ( + SE_ERR_FNF = 2 + SE_ERR_PNF = 3 + SE_ERR_ACCESSDENIED = 5 + SE_ERR_OOM = 8 + SE_ERR_DLLNOTFOUND = 32 + SE_ERR_SHARE = 26 + SE_ERR_ASSOCINCOMPLETE = 27 + SE_ERR_DDETIMEOUT = 28 + SE_ERR_DDEFAIL = 29 + SE_ERR_DDEBUSY = 30 + SE_ERR_NOASSOC = 31 +) + +const ( + CW_USEDEFAULT = ^0x7fffffff +) + +// ShowWindow constants +const ( + SW_HIDE = 0 + SW_NORMAL = 1 + SW_SHOWNORMAL = 1 + SW_SHOWMINIMIZED = 2 + SW_MAXIMIZE = 3 + SW_SHOWMAXIMIZED = 3 + SW_SHOWNOACTIVATE = 4 + SW_SHOW = 5 + SW_MINIMIZE = 6 + SW_SHOWMINNOACTIVE = 7 + SW_SHOWNA = 8 + SW_RESTORE = 9 + SW_SHOWDEFAULT = 10 + SW_FORCEMINIMIZE = 11 +) + +// Window class styles +const ( + CS_VREDRAW = 0x00000001 + CS_HREDRAW = 0x00000002 + CS_KEYCVTWINDOW = 0x00000004 + CS_DBLCLKS = 0x00000008 + CS_OWNDC = 0x00000020 + CS_CLASSDC = 0x00000040 + CS_PARENTDC = 0x00000080 + CS_NOKEYCVT = 0x00000100 + CS_NOCLOSE = 0x00000200 + CS_SAVEBITS = 0x00000800 + CS_BYTEALIGNCLIENT = 0x00001000 + CS_BYTEALIGNWINDOW = 0x00002000 + CS_GLOBALCLASS = 0x00004000 + CS_IME = 0x00010000 + CS_DROPSHADOW = 0x00020000 +) + +// Predefined cursor constants +const ( + IDC_ARROW = 32512 + IDC_IBEAM = 32513 + IDC_WAIT = 32514 + IDC_CROSS = 32515 + IDC_UPARROW = 32516 + IDC_SIZENWSE = 32642 + IDC_SIZENESW = 32643 + IDC_SIZEWE = 32644 + IDC_SIZENS = 32645 + IDC_SIZEALL = 32646 + IDC_NO = 32648 + IDC_HAND = 32649 + IDC_APPSTARTING = 32650 + IDC_HELP = 32651 + IDC_ICON = 32641 + IDC_SIZE = 32640 +) + +// Predefined icon constants +const ( + IDI_APPLICATION = 32512 + IDI_HAND = 32513 + IDI_QUESTION = 32514 + IDI_EXCLAMATION = 32515 + IDI_ASTERISK = 32516 + IDI_WINLOGO = 32517 + IDI_WARNING = IDI_EXCLAMATION + IDI_ERROR = IDI_HAND + IDI_INFORMATION = IDI_ASTERISK +) + +// Button style constants +const ( + BS_3STATE = 5 + BS_AUTO3STATE = 6 + BS_AUTOCHECKBOX = 3 + BS_AUTORADIOBUTTON = 9 + BS_BITMAP = 128 + BS_BOTTOM = 0X800 + BS_CENTER = 0X300 + BS_CHECKBOX = 2 + BS_DEFPUSHBUTTON = 1 + BS_GROUPBOX = 7 + BS_ICON = 64 + BS_LEFT = 256 + BS_LEFTTEXT = 32 + BS_MULTILINE = 0X2000 + BS_NOTIFY = 0X4000 + BS_OWNERDRAW = 0XB + BS_PUSHBUTTON = 0 + BS_PUSHLIKE = 4096 + BS_RADIOBUTTON = 4 + BS_RIGHT = 512 + BS_RIGHTBUTTON = 32 + BS_TEXT = 0 + BS_TOP = 0X400 + BS_USERBUTTON = 8 + BS_VCENTER = 0XC00 + BS_FLAT = 0X8000 +) + +// Button state constants +const ( + BST_CHECKED = 1 + BST_INDETERMINATE = 2 + BST_UNCHECKED = 0 + BST_FOCUS = 8 + BST_PUSHED = 4 +) + +// Predefined brushes constants +const ( + COLOR_3DDKSHADOW = 21 + COLOR_3DFACE = 15 + COLOR_3DHILIGHT = 20 + COLOR_3DHIGHLIGHT = 20 + COLOR_3DLIGHT = 22 + COLOR_BTNHILIGHT = 20 + COLOR_3DSHADOW = 16 + COLOR_ACTIVEBORDER = 10 + COLOR_ACTIVECAPTION = 2 + COLOR_APPWORKSPACE = 12 + COLOR_BACKGROUND = 1 + COLOR_DESKTOP = 1 + COLOR_BTNFACE = 15 + COLOR_BTNHIGHLIGHT = 20 + COLOR_BTNSHADOW = 16 + COLOR_BTNTEXT = 18 + COLOR_CAPTIONTEXT = 9 + COLOR_GRAYTEXT = 17 + COLOR_HIGHLIGHT = 13 + COLOR_HIGHLIGHTTEXT = 14 + COLOR_INACTIVEBORDER = 11 + COLOR_INACTIVECAPTION = 3 + COLOR_INACTIVECAPTIONTEXT = 19 + COLOR_INFOBK = 24 + COLOR_INFOTEXT = 23 + COLOR_MENU = 4 + COLOR_MENUTEXT = 7 + COLOR_SCROLLBAR = 0 + COLOR_WINDOW = 5 + COLOR_WINDOWFRAME = 6 + COLOR_WINDOWTEXT = 8 + COLOR_HOTLIGHT = 26 + COLOR_GRADIENTACTIVECAPTION = 27 + COLOR_GRADIENTINACTIVECAPTION = 28 +) + +// Button message constants +const ( + BM_CLICK = 245 + BM_GETCHECK = 240 + BM_GETIMAGE = 246 + BM_GETSTATE = 242 + BM_SETCHECK = 241 + BM_SETIMAGE = 247 + BM_SETSTATE = 243 + BM_SETSTYLE = 244 +) + +// Button notifications +const ( + BN_CLICKED = 0 + BN_PAINT = 1 + BN_HILITE = 2 + BN_PUSHED = BN_HILITE + BN_UNHILITE = 3 + BN_UNPUSHED = BN_UNHILITE + BN_DISABLE = 4 + BN_DOUBLECLICKED = 5 + BN_DBLCLK = BN_DOUBLECLICKED + BN_SETFOCUS = 6 + BN_KILLFOCUS = 7 +) + +// GetWindowLong and GetWindowLongPtr constants +const ( + GWL_EXSTYLE = -20 + GWL_STYLE = -16 + GWL_WNDPROC = -4 + GWLP_WNDPROC = -4 + GWL_HINSTANCE = -6 + GWLP_HINSTANCE = -6 + GWL_HWNDPARENT = -8 + GWLP_HWNDPARENT = -8 + GWL_ID = -12 + GWLP_ID = -12 + GWL_USERDATA = -21 + GWLP_USERDATA = -21 +) + +// Window style constants +const ( + WS_OVERLAPPED = 0X00000000 + WS_POPUP = 0X80000000 + WS_CHILD = 0X40000000 + WS_MINIMIZE = 0X20000000 + WS_VISIBLE = 0X10000000 + WS_DISABLED = 0X08000000 + WS_CLIPSIBLINGS = 0X04000000 + WS_CLIPCHILDREN = 0X02000000 + WS_MAXIMIZE = 0X01000000 + WS_CAPTION = 0X00C00000 + WS_BORDER = 0X00800000 + WS_DLGFRAME = 0X00400000 + WS_VSCROLL = 0X00200000 + WS_HSCROLL = 0X00100000 + WS_SYSMENU = 0X00080000 + WS_THICKFRAME = 0X00040000 + WS_GROUP = 0X00020000 + WS_TABSTOP = 0X00010000 + WS_MINIMIZEBOX = 0X00020000 + WS_MAXIMIZEBOX = 0X00010000 + WS_TILED = 0X00000000 + WS_ICONIC = 0X20000000 + WS_SIZEBOX = 0X00040000 + WS_OVERLAPPEDWINDOW = 0X00000000 | 0X00C00000 | 0X00080000 | 0X00040000 | 0X00020000 | 0X00010000 + WS_POPUPWINDOW = 0X80000000 | 0X00800000 | 0X00080000 + WS_CHILDWINDOW = 0X40000000 +) + +// Extended window style constants +const ( + WS_EX_DLGMODALFRAME = 0X00000001 + WS_EX_NOPARENTNOTIFY = 0X00000004 + WS_EX_TOPMOST = 0X00000008 + WS_EX_ACCEPTFILES = 0X00000010 + WS_EX_TRANSPARENT = 0X00000020 + WS_EX_MDICHILD = 0X00000040 + WS_EX_TOOLWINDOW = 0X00000080 + WS_EX_WINDOWEDGE = 0X00000100 + WS_EX_CLIENTEDGE = 0X00000200 + WS_EX_CONTEXTHELP = 0X00000400 + WS_EX_RIGHT = 0X00001000 + WS_EX_LEFT = 0X00000000 + WS_EX_RTLREADING = 0X00002000 + WS_EX_LTRREADING = 0X00000000 + WS_EX_LEFTSCROLLBAR = 0X00004000 + WS_EX_RIGHTSCROLLBAR = 0X00000000 + WS_EX_CONTROLPARENT = 0X00010000 + WS_EX_STATICEDGE = 0X00020000 + WS_EX_APPWINDOW = 0X00040000 + WS_EX_OVERLAPPEDWINDOW = 0X00000100 | 0X00000200 + WS_EX_PALETTEWINDOW = 0X00000100 | 0X00000080 | 0X00000008 + WS_EX_LAYERED = 0X00080000 + WS_EX_NOINHERITLAYOUT = 0X00100000 + WS_EX_LAYOUTRTL = 0X00400000 + WS_EX_NOACTIVATE = 0X08000000 +) + +// Window message constants +const ( + WM_APP = 32768 + WM_ACTIVATE = 6 + WM_ACTIVATEAPP = 28 + WM_AFXFIRST = 864 + WM_AFXLAST = 895 + WM_ASKCBFORMATNAME = 780 + WM_CANCELJOURNAL = 75 + WM_CANCELMODE = 31 + WM_CAPTURECHANGED = 533 + WM_CHANGECBCHAIN = 781 + WM_CHAR = 258 + WM_CHARTOITEM = 47 + WM_CHILDACTIVATE = 34 + WM_CLEAR = 771 + WM_CLOSE = 16 + WM_COMMAND = 273 + WM_COMMNOTIFY = 68 /* OBSOLETE */ + WM_COMPACTING = 65 + WM_COMPAREITEM = 57 + WM_CONTEXTMENU = 123 + WM_COPY = 769 + WM_COPYDATA = 74 + WM_CREATE = 1 + WM_CTLCOLORBTN = 309 + WM_CTLCOLORDLG = 310 + WM_CTLCOLOREDIT = 307 + WM_CTLCOLORLISTBOX = 308 + WM_CTLCOLORMSGBOX = 306 + WM_CTLCOLORSCROLLBAR = 311 + WM_CTLCOLORSTATIC = 312 + WM_CUT = 768 + WM_DEADCHAR = 259 + WM_DELETEITEM = 45 + WM_DESTROY = 2 + WM_DESTROYCLIPBOARD = 775 + WM_DEVICECHANGE = 537 + WM_DEVMODECHANGE = 27 + WM_DISPLAYCHANGE = 126 + WM_DRAWCLIPBOARD = 776 + WM_DRAWITEM = 43 + WM_DROPFILES = 563 + WM_ENABLE = 10 + WM_ENDSESSION = 22 + WM_ENTERIDLE = 289 + WM_ENTERMENULOOP = 529 + WM_ENTERSIZEMOVE = 561 + WM_ERASEBKGND = 20 + WM_EXITMENULOOP = 530 + WM_EXITSIZEMOVE = 562 + WM_FONTCHANGE = 29 + WM_GETDLGCODE = 135 + WM_GETFONT = 49 + WM_GETHOTKEY = 51 + WM_GETICON = 127 + WM_GETMINMAXINFO = 36 + WM_GETTEXT = 13 + WM_GETTEXTLENGTH = 14 + WM_HANDHELDFIRST = 856 + WM_HANDHELDLAST = 863 + WM_HELP = 83 + WM_HOTKEY = 786 + WM_HSCROLL = 276 + WM_HSCROLLCLIPBOARD = 782 + WM_ICONERASEBKGND = 39 + WM_INITDIALOG = 272 + WM_INITMENU = 278 + WM_INITMENUPOPUP = 279 + WM_INPUT = 0X00FF + WM_INPUTLANGCHANGE = 81 + WM_INPUTLANGCHANGEREQUEST = 80 + WM_KEYDOWN = 256 + WM_KEYUP = 257 + WM_KILLFOCUS = 8 + WM_MDIACTIVATE = 546 + WM_MDICASCADE = 551 + WM_MDICREATE = 544 + WM_MDIDESTROY = 545 + WM_MDIGETACTIVE = 553 + WM_MDIICONARRANGE = 552 + WM_MDIMAXIMIZE = 549 + WM_MDINEXT = 548 + WM_MDIREFRESHMENU = 564 + WM_MDIRESTORE = 547 + WM_MDISETMENU = 560 + WM_MDITILE = 550 + WM_MEASUREITEM = 44 + WM_GETOBJECT = 0X003D + WM_CHANGEUISTATE = 0X0127 + WM_UPDATEUISTATE = 0X0128 + WM_QUERYUISTATE = 0X0129 + WM_UNINITMENUPOPUP = 0X0125 + WM_MENURBUTTONUP = 290 + WM_MENUCOMMAND = 0X0126 + WM_MENUGETOBJECT = 0X0124 + WM_MENUDRAG = 0X0123 + WM_APPCOMMAND = 0X0319 + WM_MENUCHAR = 288 + WM_MENUSELECT = 287 + WM_MOVE = 3 + WM_MOVING = 534 + WM_NCACTIVATE = 134 + WM_NCCALCSIZE = 131 + WM_NCCREATE = 129 + WM_NCDESTROY = 130 + WM_NCHITTEST = 132 + WM_NCLBUTTONDBLCLK = 163 + WM_NCLBUTTONDOWN = 161 + WM_NCLBUTTONUP = 162 + WM_NCMBUTTONDBLCLK = 169 + WM_NCMBUTTONDOWN = 167 + WM_NCMBUTTONUP = 168 + WM_NCXBUTTONDOWN = 171 + WM_NCXBUTTONUP = 172 + WM_NCXBUTTONDBLCLK = 173 + WM_NCMOUSEHOVER = 0X02A0 + WM_NCMOUSELEAVE = 0X02A2 + WM_NCMOUSEMOVE = 160 + WM_NCPAINT = 133 + WM_NCRBUTTONDBLCLK = 166 + WM_NCRBUTTONDOWN = 164 + WM_NCRBUTTONUP = 165 + WM_NEXTDLGCTL = 40 + WM_NEXTMENU = 531 + WM_NOTIFY = 78 + WM_NOTIFYFORMAT = 85 + WM_NULL = 0 + WM_PAINT = 15 + WM_PAINTCLIPBOARD = 777 + WM_PAINTICON = 38 + WM_PALETTECHANGED = 785 + WM_PALETTEISCHANGING = 784 + WM_PARENTNOTIFY = 528 + WM_PASTE = 770 + WM_PENWINFIRST = 896 + WM_PENWINLAST = 911 + WM_POWER = 72 + WM_POWERBROADCAST = 536 + WM_PRINT = 791 + WM_PRINTCLIENT = 792 + WM_QUERYDRAGICON = 55 + WM_QUERYENDSESSION = 17 + WM_QUERYNEWPALETTE = 783 + WM_QUERYOPEN = 19 + WM_QUEUESYNC = 35 + WM_QUIT = 18 + WM_RENDERALLFORMATS = 774 + WM_RENDERFORMAT = 773 + WM_SETCURSOR = 32 + WM_SETFOCUS = 7 + WM_SETFONT = 48 + WM_SETHOTKEY = 50 + WM_SETICON = 128 + WM_SETREDRAW = 11 + WM_SETTEXT = 12 + WM_SETTINGCHANGE = 26 + WM_SHOWWINDOW = 24 + WM_SIZE = 5 + WM_SIZECLIPBOARD = 779 + WM_SIZING = 532 + WM_SPOOLERSTATUS = 42 + WM_STYLECHANGED = 125 + WM_STYLECHANGING = 124 + WM_SYSCHAR = 262 + WM_SYSCOLORCHANGE = 21 + WM_SYSCOMMAND = 274 + WM_SYSDEADCHAR = 263 + WM_SYSKEYDOWN = 260 + WM_SYSKEYUP = 261 + WM_TCARD = 82 + WM_THEMECHANGED = 794 + WM_TIMECHANGE = 30 + WM_TIMER = 275 + WM_UNDO = 772 + WM_USER = 1024 + WM_USERCHANGED = 84 + WM_VKEYTOITEM = 46 + WM_VSCROLL = 277 + WM_VSCROLLCLIPBOARD = 778 + WM_WINDOWPOSCHANGED = 71 + WM_WINDOWPOSCHANGING = 70 + WM_WININICHANGE = 26 + WM_KEYFIRST = 256 + WM_KEYLAST = 264 + WM_SYNCPAINT = 136 + WM_MOUSEACTIVATE = 33 + WM_MOUSEMOVE = 512 + WM_LBUTTONDOWN = 513 + WM_LBUTTONUP = 514 + WM_LBUTTONDBLCLK = 515 + WM_RBUTTONDOWN = 516 + WM_RBUTTONUP = 517 + WM_RBUTTONDBLCLK = 518 + WM_MBUTTONDOWN = 519 + WM_MBUTTONUP = 520 + WM_MBUTTONDBLCLK = 521 + WM_MOUSEWHEEL = 522 + WM_MOUSEFIRST = 512 + WM_XBUTTONDOWN = 523 + WM_XBUTTONUP = 524 + WM_XBUTTONDBLCLK = 525 + WM_MOUSELAST = 525 + WM_MOUSEHOVER = 0X2A1 + WM_MOUSELEAVE = 0X2A3 + WM_CLIPBOARDUPDATE = 0x031D +) + +// WM_ACTIVATE +const ( + WA_INACTIVE = 0 + WA_ACTIVE = 1 + WA_CLICKACTIVE = 2 +) + +const LF_FACESIZE = 32 + +// Font weight constants +const ( + FW_DONTCARE = 0 + FW_THIN = 100 + FW_EXTRALIGHT = 200 + FW_ULTRALIGHT = FW_EXTRALIGHT + FW_LIGHT = 300 + FW_NORMAL = 400 + FW_REGULAR = 400 + FW_MEDIUM = 500 + FW_SEMIBOLD = 600 + FW_DEMIBOLD = FW_SEMIBOLD + FW_BOLD = 700 + FW_EXTRABOLD = 800 + FW_ULTRABOLD = FW_EXTRABOLD + FW_HEAVY = 900 + FW_BLACK = FW_HEAVY +) + +// Charset constants +const ( + ANSI_CHARSET = 0 + DEFAULT_CHARSET = 1 + SYMBOL_CHARSET = 2 + SHIFTJIS_CHARSET = 128 + HANGEUL_CHARSET = 129 + HANGUL_CHARSET = 129 + GB2312_CHARSET = 134 + CHINESEBIG5_CHARSET = 136 + GREEK_CHARSET = 161 + TURKISH_CHARSET = 162 + HEBREW_CHARSET = 177 + ARABIC_CHARSET = 178 + BALTIC_CHARSET = 186 + RUSSIAN_CHARSET = 204 + THAI_CHARSET = 222 + EASTEUROPE_CHARSET = 238 + OEM_CHARSET = 255 + JOHAB_CHARSET = 130 + VIETNAMESE_CHARSET = 163 + MAC_CHARSET = 77 +) + +// Font output precision constants +const ( + OUT_DEFAULT_PRECIS = 0 + OUT_STRING_PRECIS = 1 + OUT_CHARACTER_PRECIS = 2 + OUT_STROKE_PRECIS = 3 + OUT_TT_PRECIS = 4 + OUT_DEVICE_PRECIS = 5 + OUT_RASTER_PRECIS = 6 + OUT_TT_ONLY_PRECIS = 7 + OUT_OUTLINE_PRECIS = 8 + OUT_PS_ONLY_PRECIS = 10 +) + +// Font clipping precision constants +const ( + CLIP_DEFAULT_PRECIS = 0 + CLIP_CHARACTER_PRECIS = 1 + CLIP_STROKE_PRECIS = 2 + CLIP_MASK = 15 + CLIP_LH_ANGLES = 16 + CLIP_TT_ALWAYS = 32 + CLIP_EMBEDDED = 128 +) + +// Font output quality constants +const ( + DEFAULT_QUALITY = 0 + DRAFT_QUALITY = 1 + PROOF_QUALITY = 2 + NONANTIALIASED_QUALITY = 3 + ANTIALIASED_QUALITY = 4 + CLEARTYPE_QUALITY = 5 +) + +// Font pitch constants +const ( + DEFAULT_PITCH = 0 + FIXED_PITCH = 1 + VARIABLE_PITCH = 2 +) + +// Font family constants +const ( + FF_DECORATIVE = 80 + FF_DONTCARE = 0 + FF_MODERN = 48 + FF_ROMAN = 16 + FF_SCRIPT = 64 + FF_SWISS = 32 +) + +// DeviceCapabilities capabilities +const ( + DC_FIELDS = 1 + DC_PAPERS = 2 + DC_PAPERSIZE = 3 + DC_MINEXTENT = 4 + DC_MAXEXTENT = 5 + DC_BINS = 6 + DC_DUPLEX = 7 + DC_SIZE = 8 + DC_EXTRA = 9 + DC_VERSION = 10 + DC_DRIVER = 11 + DC_BINNAMES = 12 + DC_ENUMRESOLUTIONS = 13 + DC_FILEDEPENDENCIES = 14 + DC_TRUETYPE = 15 + DC_PAPERNAMES = 16 + DC_ORIENTATION = 17 + DC_COPIES = 18 + DC_BINADJUST = 19 + DC_EMF_COMPLIANT = 20 + DC_DATATYPE_PRODUCED = 21 + DC_COLLATE = 22 + DC_MANUFACTURER = 23 + DC_MODEL = 24 + DC_PERSONALITY = 25 + DC_PRINTRATE = 26 + DC_PRINTRATEUNIT = 27 + DC_PRINTERMEM = 28 + DC_MEDIAREADY = 29 + DC_STAPLE = 30 + DC_PRINTRATEPPM = 31 + DC_COLORDEVICE = 32 + DC_NUP = 33 + DC_MEDIATYPENAMES = 34 + DC_MEDIATYPES = 35 +) + +// GetDeviceCaps index constants +const ( + DRIVERVERSION = 0 + TECHNOLOGY = 2 + HORZSIZE = 4 + VERTSIZE = 6 + HORZRES = 8 + VERTRES = 10 + LOGPIXELSX = 88 + LOGPIXELSY = 90 + BITSPIXEL = 12 + PLANES = 14 + NUMBRUSHES = 16 + NUMPENS = 18 + NUMFONTS = 22 + NUMCOLORS = 24 + NUMMARKERS = 20 + ASPECTX = 40 + ASPECTY = 42 + ASPECTXY = 44 + PDEVICESIZE = 26 + CLIPCAPS = 36 + SIZEPALETTE = 104 + NUMRESERVED = 106 + COLORRES = 108 + PHYSICALWIDTH = 110 + PHYSICALHEIGHT = 111 + PHYSICALOFFSETX = 112 + PHYSICALOFFSETY = 113 + SCALINGFACTORX = 114 + SCALINGFACTORY = 115 + VREFRESH = 116 + DESKTOPHORZRES = 118 + DESKTOPVERTRES = 117 + BLTALIGNMENT = 119 + SHADEBLENDCAPS = 120 + COLORMGMTCAPS = 121 + RASTERCAPS = 38 + CURVECAPS = 28 + LINECAPS = 30 + POLYGONALCAPS = 32 + TEXTCAPS = 34 +) + +// GetDeviceCaps TECHNOLOGY constants +const ( + DT_PLOTTER = 0 + DT_RASDISPLAY = 1 + DT_RASPRINTER = 2 + DT_RASCAMERA = 3 + DT_CHARSTREAM = 4 + DT_METAFILE = 5 + DT_DISPFILE = 6 +) + +// GetDeviceCaps SHADEBLENDCAPS constants +const ( + SB_NONE = 0x00 + SB_CONST_ALPHA = 0x01 + SB_PIXEL_ALPHA = 0x02 + SB_PREMULT_ALPHA = 0x04 + SB_GRAD_RECT = 0x10 + SB_GRAD_TRI = 0x20 +) + +// GetDeviceCaps COLORMGMTCAPS constants +const ( + CM_NONE = 0x00 + CM_DEVICE_ICM = 0x01 + CM_GAMMA_RAMP = 0x02 + CM_CMYK_COLOR = 0x04 +) + +// GetDeviceCaps RASTERCAPS constants +const ( + RC_BANDING = 2 + RC_BITBLT = 1 + RC_BITMAP64 = 8 + RC_DI_BITMAP = 128 + RC_DIBTODEV = 512 + RC_FLOODFILL = 4096 + RC_GDI20_OUTPUT = 16 + RC_PALETTE = 256 + RC_SCALING = 4 + RC_STRETCHBLT = 2048 + RC_STRETCHDIB = 8192 + RC_DEVBITS = 0x8000 + RC_OP_DX_OUTPUT = 0x4000 +) + +// GetDeviceCaps CURVECAPS constants +const ( + CC_NONE = 0 + CC_CIRCLES = 1 + CC_PIE = 2 + CC_CHORD = 4 + CC_ELLIPSES = 8 + CC_WIDE = 16 + CC_STYLED = 32 + CC_WIDESTYLED = 64 + CC_INTERIORS = 128 + CC_ROUNDRECT = 256 +) + +// GetDeviceCaps LINECAPS constants +const ( + LC_NONE = 0 + LC_POLYLINE = 2 + LC_MARKER = 4 + LC_POLYMARKER = 8 + LC_WIDE = 16 + LC_STYLED = 32 + LC_WIDESTYLED = 64 + LC_INTERIORS = 128 +) + +// GetDeviceCaps POLYGONALCAPS constants +const ( + PC_NONE = 0 + PC_POLYGON = 1 + PC_POLYPOLYGON = 256 + PC_PATHS = 512 + PC_RECTANGLE = 2 + PC_WINDPOLYGON = 4 + PC_SCANLINE = 8 + PC_TRAPEZOID = 4 + PC_WIDE = 16 + PC_STYLED = 32 + PC_WIDESTYLED = 64 + PC_INTERIORS = 128 +) + +// GetDeviceCaps TEXTCAPS constants +const ( + TC_OP_CHARACTER = 1 + TC_OP_STROKE = 2 + TC_CP_STROKE = 4 + TC_CR_90 = 8 + TC_CR_ANY = 16 + TC_SF_X_YINDEP = 32 + TC_SA_DOUBLE = 64 + TC_SA_INTEGER = 128 + TC_SA_CONTIN = 256 + TC_EA_DOUBLE = 512 + TC_IA_ABLE = 1024 + TC_UA_ABLE = 2048 + TC_SO_ABLE = 4096 + TC_RA_ABLE = 8192 + TC_VA_ABLE = 16384 + TC_RESERVED = 32768 + TC_SCROLLBLT = 65536 +) + +// Static control styles +const ( + SS_BITMAP = 14 + SS_BLACKFRAME = 7 + SS_BLACKRECT = 4 + SS_CENTER = 1 + SS_CENTERIMAGE = 512 + SS_EDITCONTROL = 0x2000 + SS_ENHMETAFILE = 15 + SS_ETCHEDFRAME = 18 + SS_ETCHEDHORZ = 16 + SS_ETCHEDVERT = 17 + SS_GRAYFRAME = 8 + SS_GRAYRECT = 5 + SS_ICON = 3 + SS_LEFT = 0 + SS_LEFTNOWORDWRAP = 0xc + SS_NOPREFIX = 128 + SS_NOTIFY = 256 + SS_OWNERDRAW = 0xd + SS_REALSIZECONTROL = 0x040 + SS_REALSIZEIMAGE = 0x800 + SS_RIGHT = 2 + SS_RIGHTJUST = 0x400 + SS_SIMPLE = 11 + SS_SUNKEN = 4096 + SS_WHITEFRAME = 9 + SS_WHITERECT = 6 + SS_USERITEM = 10 + SS_TYPEMASK = 0x0000001F + SS_ENDELLIPSIS = 0x00004000 + SS_PATHELLIPSIS = 0x00008000 + SS_WORDELLIPSIS = 0x0000C000 + SS_ELLIPSISMASK = 0x0000C000 +) + +// Edit styles +const ( + ES_LEFT = 0x0000 + ES_CENTER = 0x0001 + ES_RIGHT = 0x0002 + ES_MULTILINE = 0x0004 + ES_UPPERCASE = 0x0008 + ES_LOWERCASE = 0x0010 + ES_PASSWORD = 0x0020 + ES_AUTOVSCROLL = 0x0040 + ES_AUTOHSCROLL = 0x0080 + ES_NOHIDESEL = 0x0100 + ES_OEMCONVERT = 0x0400 + ES_READONLY = 0x0800 + ES_WANTRETURN = 0x1000 + ES_NUMBER = 0x2000 +) + +// Edit notifications +const ( + EN_SETFOCUS = 0x0100 + EN_KILLFOCUS = 0x0200 + EN_CHANGE = 0x0300 + EN_UPDATE = 0x0400 + EN_ERRSPACE = 0x0500 + EN_MAXTEXT = 0x0501 + EN_HSCROLL = 0x0601 + EN_VSCROLL = 0x0602 + EN_ALIGN_LTR_EC = 0x0700 + EN_ALIGN_RTL_EC = 0x0701 +) + +// Edit messages +const ( + EM_GETSEL = 0x00B0 + EM_SETSEL = 0x00B1 + EM_GETRECT = 0x00B2 + EM_SETRECT = 0x00B3 + EM_SETRECTNP = 0x00B4 + EM_SCROLL = 0x00B5 + EM_LINESCROLL = 0x00B6 + EM_SCROLLCARET = 0x00B7 + EM_GETMODIFY = 0x00B8 + EM_SETMODIFY = 0x00B9 + EM_GETLINECOUNT = 0x00BA + EM_LINEINDEX = 0x00BB + EM_SETHANDLE = 0x00BC + EM_GETHANDLE = 0x00BD + EM_GETTHUMB = 0x00BE + EM_LINELENGTH = 0x00C1 + EM_REPLACESEL = 0x00C2 + EM_GETLINE = 0x00C4 + EM_LIMITTEXT = 0x00C5 + EM_CANUNDO = 0x00C6 + EM_UNDO = 0x00C7 + EM_FMTLINES = 0x00C8 + EM_LINEFROMCHAR = 0x00C9 + EM_SETTABSTOPS = 0x00CB + EM_SETPASSWORDCHAR = 0x00CC + EM_EMPTYUNDOBUFFER = 0x00CD + EM_GETFIRSTVISIBLELINE = 0x00CE + EM_SETREADONLY = 0x00CF + EM_SETWORDBREAKPROC = 0x00D0 + EM_GETWORDBREAKPROC = 0x00D1 + EM_GETPASSWORDCHAR = 0x00D2 + EM_SETMARGINS = 0x00D3 + EM_GETMARGINS = 0x00D4 + EM_SETLIMITTEXT = EM_LIMITTEXT + EM_GETLIMITTEXT = 0x00D5 + EM_POSFROMCHAR = 0x00D6 + EM_CHARFROMPOS = 0x00D7 + EM_SETIMESTATUS = 0x00D8 + EM_GETIMESTATUS = 0x00D9 + EM_SETCUEBANNER = 0x1501 + EM_GETCUEBANNER = 0x1502 +) + +const ( + CCM_FIRST = 0x2000 + CCM_LAST = CCM_FIRST + 0x200 + CCM_SETBKCOLOR = 8193 + CCM_SETCOLORSCHEME = 8194 + CCM_GETCOLORSCHEME = 8195 + CCM_GETDROPTARGET = 8196 + CCM_SETUNICODEFORMAT = 8197 + CCM_GETUNICODEFORMAT = 8198 + CCM_SETVERSION = 0x2007 + CCM_GETVERSION = 0x2008 + CCM_SETNOTIFYWINDOW = 0x2009 + CCM_SETWINDOWTHEME = 0x200b + CCM_DPISCALE = 0x200c +) + +// Common controls styles +const ( + CCS_TOP = 1 + CCS_NOMOVEY = 2 + CCS_BOTTOM = 3 + CCS_NORESIZE = 4 + CCS_NOPARENTALIGN = 8 + CCS_ADJUSTABLE = 32 + CCS_NODIVIDER = 64 + CCS_VERT = 128 + CCS_LEFT = 129 + CCS_NOMOVEX = 130 + CCS_RIGHT = 131 +) + +// ProgressBar messages +const ( + PROGRESS_CLASS = "msctls_progress32" + PBM_SETPOS = WM_USER + 2 + PBM_DELTAPOS = WM_USER + 3 + PBM_SETSTEP = WM_USER + 4 + PBM_STEPIT = WM_USER + 5 + PBM_SETRANGE32 = 1030 + PBM_GETRANGE = 1031 + PBM_GETPOS = 1032 + PBM_SETBARCOLOR = 1033 + PBM_SETBKCOLOR = CCM_SETBKCOLOR + PBS_SMOOTH = 1 + PBS_VERTICAL = 4 +) + +// GetOpenFileName and GetSaveFileName extended flags +const ( + OFN_EX_NOPLACESBAR = 0x00000001 +) + +// GetOpenFileName and GetSaveFileName flags +const ( + OFN_ALLOWMULTISELECT = 0x00000200 + OFN_CREATEPROMPT = 0x00002000 + OFN_DONTADDTORECENT = 0x02000000 + OFN_ENABLEHOOK = 0x00000020 + OFN_ENABLEINCLUDENOTIFY = 0x00400000 + OFN_ENABLESIZING = 0x00800000 + OFN_ENABLETEMPLATE = 0x00000040 + OFN_ENABLETEMPLATEHANDLE = 0x00000080 + OFN_EXPLORER = 0x00080000 + OFN_EXTENSIONDIFFERENT = 0x00000400 + OFN_FILEMUSTEXIST = 0x00001000 + OFN_FORCESHOWHIDDEN = 0x10000000 + OFN_HIDEREADONLY = 0x00000004 + OFN_LONGNAMES = 0x00200000 + OFN_NOCHANGEDIR = 0x00000008 + OFN_NODEREFERENCELINKS = 0x00100000 + OFN_NOLONGNAMES = 0x00040000 + OFN_NONETWORKBUTTON = 0x00020000 + OFN_NOREADONLYRETURN = 0x00008000 + OFN_NOTESTFILECREATE = 0x00010000 + OFN_NOVALIDATE = 0x00000100 + OFN_OVERWRITEPROMPT = 0x00000002 + OFN_PATHMUSTEXIST = 0x00000800 + OFN_READONLY = 0x00000001 + OFN_SHAREAWARE = 0x00004000 + OFN_SHOWHELP = 0x00000010 +) + +//SHBrowseForFolder flags +const ( + BIF_RETURNONLYFSDIRS = 0x00000001 + BIF_DONTGOBELOWDOMAIN = 0x00000002 + BIF_STATUSTEXT = 0x00000004 + BIF_RETURNFSANCESTORS = 0x00000008 + BIF_EDITBOX = 0x00000010 + BIF_VALIDATE = 0x00000020 + BIF_NEWDIALOGSTYLE = 0x00000040 + BIF_BROWSEINCLUDEURLS = 0x00000080 + BIF_USENEWUI = BIF_EDITBOX | BIF_NEWDIALOGSTYLE + BIF_UAHINT = 0x00000100 + BIF_NONEWFOLDERBUTTON = 0x00000200 + BIF_NOTRANSLATETARGETS = 0x00000400 + BIF_BROWSEFORCOMPUTER = 0x00001000 + BIF_BROWSEFORPRINTER = 0x00002000 + BIF_BROWSEINCLUDEFILES = 0x00004000 + BIF_SHAREABLE = 0x00008000 + BIF_BROWSEFILEJUNCTIONS = 0x00010000 +) + +//MessageBox flags +const ( + MB_OK = 0x00000000 + MB_OKCANCEL = 0x00000001 + MB_ABORTRETRYIGNORE = 0x00000002 + MB_YESNOCANCEL = 0x00000003 + MB_YESNO = 0x00000004 + MB_RETRYCANCEL = 0x00000005 + MB_CANCELTRYCONTINUE = 0x00000006 + MB_ICONHAND = 0x00000010 + MB_ICONQUESTION = 0x00000020 + MB_ICONEXCLAMATION = 0x00000030 + MB_ICONASTERISK = 0x00000040 + MB_USERICON = 0x00000080 + MB_ICONWARNING = MB_ICONEXCLAMATION + MB_ICONERROR = MB_ICONHAND + MB_ICONINFORMATION = MB_ICONASTERISK + MB_ICONSTOP = MB_ICONHAND + MB_DEFBUTTON1 = 0x00000000 + MB_DEFBUTTON2 = 0x00000100 + MB_DEFBUTTON3 = 0x00000200 + MB_DEFBUTTON4 = 0x00000300 +) + +//COM +const ( + E_INVALIDARG = 0x80070057 + E_OUTOFMEMORY = 0x8007000E + E_UNEXPECTED = 0x8000FFFF +) + +const ( + S_OK = 0 + S_FALSE = 0x0001 + RPC_E_CHANGED_MODE = 0x80010106 +) + +// GetSystemMetrics constants +const ( + SM_CXSCREEN = 0 + SM_CYSCREEN = 1 + SM_CXVSCROLL = 2 + SM_CYHSCROLL = 3 + SM_CYCAPTION = 4 + SM_CXBORDER = 5 + SM_CYBORDER = 6 + SM_CXDLGFRAME = 7 + SM_CYDLGFRAME = 8 + SM_CYVTHUMB = 9 + SM_CXHTHUMB = 10 + SM_CXICON = 11 + SM_CYICON = 12 + SM_CXCURSOR = 13 + SM_CYCURSOR = 14 + SM_CYMENU = 15 + SM_CXFULLSCREEN = 16 + SM_CYFULLSCREEN = 17 + SM_CYKANJIWINDOW = 18 + SM_MOUSEPRESENT = 19 + SM_CYVSCROLL = 20 + SM_CXHSCROLL = 21 + SM_DEBUG = 22 + SM_SWAPBUTTON = 23 + SM_RESERVED1 = 24 + SM_RESERVED2 = 25 + SM_RESERVED3 = 26 + SM_RESERVED4 = 27 + SM_CXMIN = 28 + SM_CYMIN = 29 + SM_CXSIZE = 30 + SM_CYSIZE = 31 + SM_CXFRAME = 32 + SM_CYFRAME = 33 + SM_CXMINTRACK = 34 + SM_CYMINTRACK = 35 + SM_CXDOUBLECLK = 36 + SM_CYDOUBLECLK = 37 + SM_CXICONSPACING = 38 + SM_CYICONSPACING = 39 + SM_MENUDROPALIGNMENT = 40 + SM_PENWINDOWS = 41 + SM_DBCSENABLED = 42 + SM_CMOUSEBUTTONS = 43 + SM_CXFIXEDFRAME = SM_CXDLGFRAME + SM_CYFIXEDFRAME = SM_CYDLGFRAME + SM_CXSIZEFRAME = SM_CXFRAME + SM_CYSIZEFRAME = SM_CYFRAME + SM_SECURE = 44 + SM_CXEDGE = 45 + SM_CYEDGE = 46 + SM_CXMINSPACING = 47 + SM_CYMINSPACING = 48 + SM_CXSMICON = 49 + SM_CYSMICON = 50 + SM_CYSMCAPTION = 51 + SM_CXSMSIZE = 52 + SM_CYSMSIZE = 53 + SM_CXMENUSIZE = 54 + SM_CYMENUSIZE = 55 + SM_ARRANGE = 56 + SM_CXMINIMIZED = 57 + SM_CYMINIMIZED = 58 + SM_CXMAXTRACK = 59 + SM_CYMAXTRACK = 60 + SM_CXMAXIMIZED = 61 + SM_CYMAXIMIZED = 62 + SM_NETWORK = 63 + SM_CLEANBOOT = 67 + SM_CXDRAG = 68 + SM_CYDRAG = 69 + SM_SHOWSOUNDS = 70 + SM_CXMENUCHECK = 71 + SM_CYMENUCHECK = 72 + SM_SLOWMACHINE = 73 + SM_MIDEASTENABLED = 74 + SM_MOUSEWHEELPRESENT = 75 + SM_XVIRTUALSCREEN = 76 + SM_YVIRTUALSCREEN = 77 + SM_CXVIRTUALSCREEN = 78 + SM_CYVIRTUALSCREEN = 79 + SM_CMONITORS = 80 + SM_SAMEDISPLAYFORMAT = 81 + SM_IMMENABLED = 82 + SM_CXFOCUSBORDER = 83 + SM_CYFOCUSBORDER = 84 + SM_TABLETPC = 86 + SM_MEDIACENTER = 87 + SM_STARTER = 88 + SM_SERVERR2 = 89 + SM_CMETRICS = 91 + SM_REMOTESESSION = 0x1000 + SM_SHUTTINGDOWN = 0x2000 + SM_REMOTECONTROL = 0x2001 + SM_CARETBLINKINGENABLED = 0x2002 +) + +const ( + CLSCTX_INPROC_SERVER = 1 + CLSCTX_INPROC_HANDLER = 2 + CLSCTX_LOCAL_SERVER = 4 + CLSCTX_INPROC_SERVER16 = 8 + CLSCTX_REMOTE_SERVER = 16 + CLSCTX_ALL = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER + CLSCTX_INPROC = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER + CLSCTX_SERVER = CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER +) + +const ( + COINIT_APARTMENTTHREADED = 0x2 + COINIT_MULTITHREADED = 0x0 + COINIT_DISABLE_OLE1DDE = 0x4 + COINIT_SPEED_OVER_MEMORY = 0x8 +) + +const ( + DISPATCH_METHOD = 1 + DISPATCH_PROPERTYGET = 2 + DISPATCH_PROPERTYPUT = 4 + DISPATCH_PROPERTYPUTREF = 8 +) + +const ( + CC_FASTCALL = iota + CC_CDECL + CC_MSCPASCAL + CC_PASCAL = CC_MSCPASCAL + CC_MACPASCAL + CC_STDCALL + CC_FPFASTCALL + CC_SYSCALL + CC_MPWCDECL + CC_MPWPASCAL + CC_MAX = CC_MPWPASCAL +) + +const ( + VT_EMPTY = 0x0 + VT_NULL = 0x1 + VT_I2 = 0x2 + VT_I4 = 0x3 + VT_R4 = 0x4 + VT_R8 = 0x5 + VT_CY = 0x6 + VT_DATE = 0x7 + VT_BSTR = 0x8 + VT_DISPATCH = 0x9 + VT_ERROR = 0xa + VT_BOOL = 0xb + VT_VARIANT = 0xc + VT_UNKNOWN = 0xd + VT_DECIMAL = 0xe + VT_I1 = 0x10 + VT_UI1 = 0x11 + VT_UI2 = 0x12 + VT_UI4 = 0x13 + VT_I8 = 0x14 + VT_UI8 = 0x15 + VT_INT = 0x16 + VT_UINT = 0x17 + VT_VOID = 0x18 + VT_HRESULT = 0x19 + VT_PTR = 0x1a + VT_SAFEARRAY = 0x1b + VT_CARRAY = 0x1c + VT_USERDEFINED = 0x1d + VT_LPSTR = 0x1e + VT_LPWSTR = 0x1f + VT_RECORD = 0x24 + VT_INT_PTR = 0x25 + VT_UINT_PTR = 0x26 + VT_FILETIME = 0x40 + VT_BLOB = 0x41 + VT_STREAM = 0x42 + VT_STORAGE = 0x43 + VT_STREAMED_OBJECT = 0x44 + VT_STORED_OBJECT = 0x45 + VT_BLOB_OBJECT = 0x46 + VT_CF = 0x47 + VT_CLSID = 0x48 + VT_BSTR_BLOB = 0xfff + VT_VECTOR = 0x1000 + VT_ARRAY = 0x2000 + VT_BYREF = 0x4000 + VT_RESERVED = 0x8000 + VT_ILLEGAL = 0xffff + VT_ILLEGALMASKED = 0xfff + VT_TYPEMASK = 0xfff +) + +const ( + DISPID_UNKNOWN = -1 + DISPID_VALUE = 0 + DISPID_PROPERTYPUT = -3 + DISPID_NEWENUM = -4 + DISPID_EVALUATE = -5 + DISPID_CONSTRUCTOR = -6 + DISPID_DESTRUCTOR = -7 + DISPID_COLLECT = -8 +) + +const ( + MONITOR_DEFAULTTONULL = 0x00000000 + MONITOR_DEFAULTTOPRIMARY = 0x00000001 + MONITOR_DEFAULTTONEAREST = 0x00000002 + + MONITORINFOF_PRIMARY = 0x00000001 +) + +const ( + CCHDEVICENAME = 32 + CCHFORMNAME = 32 +) + +const ( + IDOK = 1 + IDCANCEL = 2 + IDABORT = 3 + IDRETRY = 4 + IDIGNORE = 5 + IDYES = 6 + IDNO = 7 + IDCLOSE = 8 + IDHELP = 9 + IDTRYAGAIN = 10 + IDCONTINUE = 11 + IDTIMEOUT = 32000 +) + +// Generic WM_NOTIFY notification codes +const ( + NM_FIRST = 0 + NM_OUTOFMEMORY = NM_FIRST - 1 + NM_CLICK = NM_FIRST - 2 + NM_DBLCLK = NM_FIRST - 3 + NM_RETURN = NM_FIRST - 4 + NM_RCLICK = NM_FIRST - 5 + NM_RDBLCLK = NM_FIRST - 6 + NM_SETFOCUS = NM_FIRST - 7 + NM_KILLFOCUS = NM_FIRST - 8 + NM_CUSTOMDRAW = NM_FIRST - 12 + NM_HOVER = NM_FIRST - 13 + NM_NCHITTEST = NM_FIRST - 14 + NM_KEYDOWN = NM_FIRST - 15 + NM_RELEASEDCAPTURE = NM_FIRST - 16 + NM_SETCURSOR = NM_FIRST - 17 + NM_CHAR = NM_FIRST - 18 + NM_TOOLTIPSCREATED = NM_FIRST - 19 + NM_LAST = NM_FIRST - 99 +) + +// ListView messages +const ( + LVM_FIRST = 0x1000 + LVM_GETITEMCOUNT = LVM_FIRST + 4 + LVM_SETIMAGELIST = LVM_FIRST + 3 + LVM_GETIMAGELIST = LVM_FIRST + 2 + LVM_GETITEM = LVM_FIRST + 75 + LVM_SETITEM = LVM_FIRST + 76 + LVM_INSERTITEM = LVM_FIRST + 77 + LVM_DELETEITEM = LVM_FIRST + 8 + LVM_DELETEALLITEMS = LVM_FIRST + 9 + LVM_GETCALLBACKMASK = LVM_FIRST + 10 + LVM_SETCALLBACKMASK = LVM_FIRST + 11 + LVM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT + LVM_GETNEXTITEM = LVM_FIRST + 12 + LVM_FINDITEM = LVM_FIRST + 83 + LVM_GETITEMRECT = LVM_FIRST + 14 + LVM_GETSTRINGWIDTH = LVM_FIRST + 87 + LVM_HITTEST = LVM_FIRST + 18 + LVM_ENSUREVISIBLE = LVM_FIRST + 19 + LVM_SCROLL = LVM_FIRST + 20 + LVM_REDRAWITEMS = LVM_FIRST + 21 + LVM_ARRANGE = LVM_FIRST + 22 + LVM_EDITLABEL = LVM_FIRST + 118 + LVM_GETEDITCONTROL = LVM_FIRST + 24 + LVM_GETCOLUMN = LVM_FIRST + 95 + LVM_SETCOLUMN = LVM_FIRST + 96 + LVM_INSERTCOLUMN = LVM_FIRST + 97 + LVM_DELETECOLUMN = LVM_FIRST + 28 + LVM_GETCOLUMNWIDTH = LVM_FIRST + 29 + LVM_SETCOLUMNWIDTH = LVM_FIRST + 30 + LVM_GETHEADER = LVM_FIRST + 31 + LVM_CREATEDRAGIMAGE = LVM_FIRST + 33 + LVM_GETVIEWRECT = LVM_FIRST + 34 + LVM_GETTEXTCOLOR = LVM_FIRST + 35 + LVM_SETTEXTCOLOR = LVM_FIRST + 36 + LVM_GETTEXTBKCOLOR = LVM_FIRST + 37 + LVM_SETTEXTBKCOLOR = LVM_FIRST + 38 + LVM_GETTOPINDEX = LVM_FIRST + 39 + LVM_GETCOUNTPERPAGE = LVM_FIRST + 40 + LVM_GETORIGIN = LVM_FIRST + 41 + LVM_UPDATE = LVM_FIRST + 42 + LVM_SETITEMSTATE = LVM_FIRST + 43 + LVM_GETITEMSTATE = LVM_FIRST + 44 + LVM_GETITEMTEXT = LVM_FIRST + 115 + LVM_SETITEMTEXT = LVM_FIRST + 116 + LVM_SETITEMCOUNT = LVM_FIRST + 47 + LVM_SORTITEMS = LVM_FIRST + 48 + LVM_SETITEMPOSITION32 = LVM_FIRST + 49 + LVM_GETSELECTEDCOUNT = LVM_FIRST + 50 + LVM_GETITEMSPACING = LVM_FIRST + 51 + LVM_GETISEARCHSTRING = LVM_FIRST + 117 + LVM_SETICONSPACING = LVM_FIRST + 53 + LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 54 + LVM_GETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 55 + LVM_GETSUBITEMRECT = LVM_FIRST + 56 + LVM_SUBITEMHITTEST = LVM_FIRST + 57 + LVM_SETCOLUMNORDERARRAY = LVM_FIRST + 58 + LVM_GETCOLUMNORDERARRAY = LVM_FIRST + 59 + LVM_SETHOTITEM = LVM_FIRST + 60 + LVM_GETHOTITEM = LVM_FIRST + 61 + LVM_SETHOTCURSOR = LVM_FIRST + 62 + LVM_GETHOTCURSOR = LVM_FIRST + 63 + LVM_APPROXIMATEVIEWRECT = LVM_FIRST + 64 + LVM_SETWORKAREAS = LVM_FIRST + 65 + LVM_GETWORKAREAS = LVM_FIRST + 70 + LVM_GETNUMBEROFWORKAREAS = LVM_FIRST + 73 + LVM_GETSELECTIONMARK = LVM_FIRST + 66 + LVM_SETSELECTIONMARK = LVM_FIRST + 67 + LVM_SETHOVERTIME = LVM_FIRST + 71 + LVM_GETHOVERTIME = LVM_FIRST + 72 + LVM_SETTOOLTIPS = LVM_FIRST + 74 + LVM_GETTOOLTIPS = LVM_FIRST + 78 + LVM_SORTITEMSEX = LVM_FIRST + 81 + LVM_SETBKIMAGE = LVM_FIRST + 138 + LVM_GETBKIMAGE = LVM_FIRST + 139 + LVM_SETSELECTEDCOLUMN = LVM_FIRST + 140 + LVM_SETVIEW = LVM_FIRST + 142 + LVM_GETVIEW = LVM_FIRST + 143 + LVM_INSERTGROUP = LVM_FIRST + 145 + LVM_SETGROUPINFO = LVM_FIRST + 147 + LVM_GETGROUPINFO = LVM_FIRST + 149 + LVM_REMOVEGROUP = LVM_FIRST + 150 + LVM_MOVEGROUP = LVM_FIRST + 151 + LVM_GETGROUPCOUNT = LVM_FIRST + 152 + LVM_GETGROUPINFOBYINDEX = LVM_FIRST + 153 + LVM_MOVEITEMTOGROUP = LVM_FIRST + 154 + LVM_GETGROUPRECT = LVM_FIRST + 98 + LVM_SETGROUPMETRICS = LVM_FIRST + 155 + LVM_GETGROUPMETRICS = LVM_FIRST + 156 + LVM_ENABLEGROUPVIEW = LVM_FIRST + 157 + LVM_SORTGROUPS = LVM_FIRST + 158 + LVM_INSERTGROUPSORTED = LVM_FIRST + 159 + LVM_REMOVEALLGROUPS = LVM_FIRST + 160 + LVM_HASGROUP = LVM_FIRST + 161 + LVM_GETGROUPSTATE = LVM_FIRST + 92 + LVM_GETFOCUSEDGROUP = LVM_FIRST + 93 + LVM_SETTILEVIEWINFO = LVM_FIRST + 162 + LVM_GETTILEVIEWINFO = LVM_FIRST + 163 + LVM_SETTILEINFO = LVM_FIRST + 164 + LVM_GETTILEINFO = LVM_FIRST + 165 + LVM_SETINSERTMARK = LVM_FIRST + 166 + LVM_GETINSERTMARK = LVM_FIRST + 167 + LVM_INSERTMARKHITTEST = LVM_FIRST + 168 + LVM_GETINSERTMARKRECT = LVM_FIRST + 169 + LVM_SETINSERTMARKCOLOR = LVM_FIRST + 170 + LVM_GETINSERTMARKCOLOR = LVM_FIRST + 171 + LVM_SETINFOTIP = LVM_FIRST + 173 + LVM_GETSELECTEDCOLUMN = LVM_FIRST + 174 + LVM_ISGROUPVIEWENABLED = LVM_FIRST + 175 + LVM_GETOUTLINECOLOR = LVM_FIRST + 176 + LVM_SETOUTLINECOLOR = LVM_FIRST + 177 + LVM_CANCELEDITLABEL = LVM_FIRST + 179 + LVM_MAPINDEXTOID = LVM_FIRST + 180 + LVM_MAPIDTOINDEX = LVM_FIRST + 181 + LVM_ISITEMVISIBLE = LVM_FIRST + 182 + LVM_GETNEXTITEMINDEX = LVM_FIRST + 211 +) + +// ListView notifications +const ( + LVN_FIRST = -100 + + LVN_ITEMCHANGING = LVN_FIRST - 0 + LVN_ITEMCHANGED = LVN_FIRST - 1 + LVN_INSERTITEM = LVN_FIRST - 2 + LVN_DELETEITEM = LVN_FIRST - 3 + LVN_DELETEALLITEMS = LVN_FIRST - 4 + LVN_BEGINLABELEDITA = LVN_FIRST - 5 + LVN_BEGINLABELEDITW = LVN_FIRST - 75 + LVN_ENDLABELEDITA = LVN_FIRST - 6 + LVN_ENDLABELEDITW = LVN_FIRST - 76 + LVN_COLUMNCLICK = LVN_FIRST - 8 + LVN_BEGINDRAG = LVN_FIRST - 9 + LVN_BEGINRDRAG = LVN_FIRST - 11 + LVN_ODCACHEHINT = LVN_FIRST - 13 + LVN_ODFINDITEMA = LVN_FIRST - 52 + LVN_ODFINDITEMW = LVN_FIRST - 79 + LVN_ITEMACTIVATE = LVN_FIRST - 14 + LVN_ODSTATECHANGED = LVN_FIRST - 15 + LVN_HOTTRACK = LVN_FIRST - 21 + LVN_GETDISPINFO = LVN_FIRST - 77 + LVN_SETDISPINFO = LVN_FIRST - 78 + LVN_KEYDOWN = LVN_FIRST - 55 + LVN_MARQUEEBEGIN = LVN_FIRST - 56 + LVN_GETINFOTIP = LVN_FIRST - 58 + LVN_INCREMENTALSEARCH = LVN_FIRST - 63 + LVN_BEGINSCROLL = LVN_FIRST - 80 + LVN_ENDSCROLL = LVN_FIRST - 81 +) + +// ListView LVNI constants +const ( + LVNI_ALL = 0 + LVNI_FOCUSED = 1 + LVNI_SELECTED = 2 + LVNI_CUT = 4 + LVNI_DROPHILITED = 8 + LVNI_ABOVE = 256 + LVNI_BELOW = 512 + LVNI_TOLEFT = 1024 + LVNI_TORIGHT = 2048 +) + +// ListView styles +const ( + LVS_ICON = 0x0000 + LVS_REPORT = 0x0001 + LVS_SMALLICON = 0x0002 + LVS_LIST = 0x0003 + LVS_TYPEMASK = 0x0003 + LVS_SINGLESEL = 0x0004 + LVS_SHOWSELALWAYS = 0x0008 + LVS_SORTASCENDING = 0x0010 + LVS_SORTDESCENDING = 0x0020 + LVS_SHAREIMAGELISTS = 0x0040 + LVS_NOLABELWRAP = 0x0080 + LVS_AUTOARRANGE = 0x0100 + LVS_EDITLABELS = 0x0200 + LVS_OWNERDATA = 0x1000 + LVS_NOSCROLL = 0x2000 + LVS_TYPESTYLEMASK = 0xfc00 + LVS_ALIGNTOP = 0x0000 + LVS_ALIGNLEFT = 0x0800 + LVS_ALIGNMASK = 0x0c00 + LVS_OWNERDRAWFIXED = 0x0400 + LVS_NOCOLUMNHEADER = 0x4000 + LVS_NOSORTHEADER = 0x8000 +) + +// ListView extended styles +const ( + LVS_EX_GRIDLINES = 0x00000001 + LVS_EX_SUBITEMIMAGES = 0x00000002 + LVS_EX_CHECKBOXES = 0x00000004 + LVS_EX_TRACKSELECT = 0x00000008 + LVS_EX_HEADERDRAGDROP = 0x00000010 + LVS_EX_FULLROWSELECT = 0x00000020 + LVS_EX_ONECLICKACTIVATE = 0x00000040 + LVS_EX_TWOCLICKACTIVATE = 0x00000080 + LVS_EX_FLATSB = 0x00000100 + LVS_EX_REGIONAL = 0x00000200 + LVS_EX_INFOTIP = 0x00000400 + LVS_EX_UNDERLINEHOT = 0x00000800 + LVS_EX_UNDERLINECOLD = 0x00001000 + LVS_EX_MULTIWORKAREAS = 0x00002000 + LVS_EX_LABELTIP = 0x00004000 + LVS_EX_BORDERSELECT = 0x00008000 + LVS_EX_DOUBLEBUFFER = 0x00010000 + LVS_EX_HIDELABELS = 0x00020000 + LVS_EX_SINGLEROW = 0x00040000 + LVS_EX_SNAPTOGRID = 0x00080000 + LVS_EX_SIMPLESELECT = 0x00100000 +) + +// ListView column flags +const ( + LVCF_FMT = 0x0001 + LVCF_WIDTH = 0x0002 + LVCF_TEXT = 0x0004 + LVCF_SUBITEM = 0x0008 + LVCF_IMAGE = 0x0010 + LVCF_ORDER = 0x0020 +) + +// ListView column format constants +const ( + LVCFMT_LEFT = 0x0000 + LVCFMT_RIGHT = 0x0001 + LVCFMT_CENTER = 0x0002 + LVCFMT_JUSTIFYMASK = 0x0003 + LVCFMT_IMAGE = 0x0800 + LVCFMT_BITMAP_ON_RIGHT = 0x1000 + LVCFMT_COL_HAS_IMAGES = 0x8000 +) + +// ListView item flags +const ( + LVIF_TEXT = 0x00000001 + LVIF_IMAGE = 0x00000002 + LVIF_PARAM = 0x00000004 + LVIF_STATE = 0x00000008 + LVIF_INDENT = 0x00000010 + LVIF_NORECOMPUTE = 0x00000800 + LVIF_GROUPID = 0x00000100 + LVIF_COLUMNS = 0x00000200 +) + +// ListView item states +const ( + LVIS_FOCUSED = 1 + LVIS_SELECTED = 2 + LVIS_CUT = 4 + LVIS_DROPHILITED = 8 + LVIS_OVERLAYMASK = 0xF00 + LVIS_STATEIMAGEMASK = 0xF000 +) + +// ListView hit test constants +const ( + LVHT_NOWHERE = 0x00000001 + LVHT_ONITEMICON = 0x00000002 + LVHT_ONITEMLABEL = 0x00000004 + LVHT_ONITEMSTATEICON = 0x00000008 + LVHT_ONITEM = LVHT_ONITEMICON | LVHT_ONITEMLABEL | LVHT_ONITEMSTATEICON + + LVHT_ABOVE = 0x00000008 + LVHT_BELOW = 0x00000010 + LVHT_TORIGHT = 0x00000020 + LVHT_TOLEFT = 0x00000040 +) + +// ListView image list types +const ( + LVSIL_NORMAL = 0 + LVSIL_SMALL = 1 + LVSIL_STATE = 2 + LVSIL_GROUPHEADER = 3 +) + +// InitCommonControlsEx flags +const ( + ICC_LISTVIEW_CLASSES = 1 + ICC_TREEVIEW_CLASSES = 2 + ICC_BAR_CLASSES = 4 + ICC_TAB_CLASSES = 8 + ICC_UPDOWN_CLASS = 16 + ICC_PROGRESS_CLASS = 32 + ICC_HOTKEY_CLASS = 64 + ICC_ANIMATE_CLASS = 128 + ICC_WIN95_CLASSES = 255 + ICC_DATE_CLASSES = 256 + ICC_USEREX_CLASSES = 512 + ICC_COOL_CLASSES = 1024 + ICC_INTERNET_CLASSES = 2048 + ICC_PAGESCROLLER_CLASS = 4096 + ICC_NATIVEFNTCTL_CLASS = 8192 + INFOTIPSIZE = 1024 + ICC_STANDARD_CLASSES = 0x00004000 + ICC_LINK_CLASS = 0x00008000 +) + +// Dialog Codes +const ( + DLGC_WANTARROWS = 0x0001 + DLGC_WANTTAB = 0x0002 + DLGC_WANTALLKEYS = 0x0004 + DLGC_WANTMESSAGE = 0x0004 + DLGC_HASSETSEL = 0x0008 + DLGC_DEFPUSHBUTTON = 0x0010 + DLGC_UNDEFPUSHBUTTON = 0x0020 + DLGC_RADIOBUTTON = 0x0040 + DLGC_WANTCHARS = 0x0080 + DLGC_STATIC = 0x0100 + DLGC_BUTTON = 0x2000 +) + +// Get/SetWindowWord/Long offsets for use with WC_DIALOG windows +const ( + DWL_MSGRESULT = 0 + DWL_DLGPROC = 4 + DWL_USER = 8 +) + +// Registry predefined keys +const ( + HKEY_CLASSES_ROOT HKEY = 0x80000000 + HKEY_CURRENT_USER HKEY = 0x80000001 + HKEY_LOCAL_MACHINE HKEY = 0x80000002 + HKEY_USERS HKEY = 0x80000003 + HKEY_PERFORMANCE_DATA HKEY = 0x80000004 + HKEY_CURRENT_CONFIG HKEY = 0x80000005 + HKEY_DYN_DATA HKEY = 0x80000006 +) + +// Registry Key Security and Access Rights +const ( + KEY_ALL_ACCESS = 0xF003F + KEY_CREATE_SUB_KEY = 0x0004 + KEY_ENUMERATE_SUB_KEYS = 0x0008 + KEY_NOTIFY = 0x0010 + KEY_QUERY_VALUE = 0x0001 + KEY_SET_VALUE = 0x0002 + KEY_READ = 0x20019 + KEY_WRITE = 0x20006 +) + +const ( + NFR_ANSI = 1 + NFR_UNICODE = 2 + NF_QUERY = 3 + NF_REQUERY = 4 +) + +// Registry value types +const ( + RRF_RT_REG_NONE = 0x00000001 + RRF_RT_REG_SZ = 0x00000002 + RRF_RT_REG_EXPAND_SZ = 0x00000004 + RRF_RT_REG_BINARY = 0x00000008 + RRF_RT_REG_DWORD = 0x00000010 + RRF_RT_REG_MULTI_SZ = 0x00000020 + RRF_RT_REG_QWORD = 0x00000040 + RRF_RT_DWORD = (RRF_RT_REG_BINARY | RRF_RT_REG_DWORD) + RRF_RT_QWORD = (RRF_RT_REG_BINARY | RRF_RT_REG_QWORD) + RRF_RT_ANY = 0x0000ffff + RRF_NOEXPAND = 0x10000000 + RRF_ZEROONFAILURE = 0x20000000 + REG_PROCESS_APPKEY = 0x00000001 + REG_MUI_STRING_TRUNCATE = 0x00000001 +) + +// PeekMessage wRemoveMsg value +const ( + PM_NOREMOVE = 0x000 + PM_REMOVE = 0x001 + PM_NOYIELD = 0x002 +) + +// ImageList flags +const ( + ILC_MASK = 0x00000001 + ILC_COLOR = 0x00000000 + ILC_COLORDDB = 0x000000FE + ILC_COLOR4 = 0x00000004 + ILC_COLOR8 = 0x00000008 + ILC_COLOR16 = 0x00000010 + ILC_COLOR24 = 0x00000018 + ILC_COLOR32 = 0x00000020 + ILC_PALETTE = 0x00000800 + ILC_MIRROR = 0x00002000 + ILC_PERITEMMIRROR = 0x00008000 + ILC_ORIGINALSIZE = 0x00010000 + ILC_HIGHQUALITYSCALE = 0x00020000 +) + +// Keystroke Message Flags +const ( + KF_EXTENDED = 0x0100 + KF_DLGMODE = 0x0800 + KF_MENUMODE = 0x1000 + KF_ALTDOWN = 0x2000 + KF_REPEAT = 0x4000 + KF_UP = 0x8000 +) + +// Virtual-Key Codes +const ( + VK_LBUTTON = 0x01 + VK_RBUTTON = 0x02 + VK_CANCEL = 0x03 + VK_MBUTTON = 0x04 + VK_XBUTTON1 = 0x05 + VK_XBUTTON2 = 0x06 + VK_BACK = 0x08 + VK_TAB = 0x09 + VK_CLEAR = 0x0C + VK_RETURN = 0x0D + VK_SHIFT = 0x10 + VK_CONTROL = 0x11 + VK_MENU = 0x12 + VK_PAUSE = 0x13 + VK_CAPITAL = 0x14 + VK_KANA = 0x15 + VK_HANGEUL = 0x15 + VK_HANGUL = 0x15 + VK_JUNJA = 0x17 + VK_FINAL = 0x18 + VK_HANJA = 0x19 + VK_KANJI = 0x19 + VK_ESCAPE = 0x1B + VK_CONVERT = 0x1C + VK_NONCONVERT = 0x1D + VK_ACCEPT = 0x1E + VK_MODECHANGE = 0x1F + VK_SPACE = 0x20 + VK_PRIOR = 0x21 + VK_NEXT = 0x22 + VK_END = 0x23 + VK_HOME = 0x24 + VK_LEFT = 0x25 + VK_UP = 0x26 + VK_RIGHT = 0x27 + VK_DOWN = 0x28 + VK_SELECT = 0x29 + VK_PRINT = 0x2A + VK_EXECUTE = 0x2B + VK_SNAPSHOT = 0x2C + VK_INSERT = 0x2D + VK_DELETE = 0x2E + VK_HELP = 0x2F + VK_LWIN = 0x5B + VK_RWIN = 0x5C + VK_APPS = 0x5D + VK_SLEEP = 0x5F + VK_NUMPAD0 = 0x60 + VK_NUMPAD1 = 0x61 + VK_NUMPAD2 = 0x62 + VK_NUMPAD3 = 0x63 + VK_NUMPAD4 = 0x64 + VK_NUMPAD5 = 0x65 + VK_NUMPAD6 = 0x66 + VK_NUMPAD7 = 0x67 + VK_NUMPAD8 = 0x68 + VK_NUMPAD9 = 0x69 + VK_MULTIPLY = 0x6A + VK_ADD = 0x6B + VK_SEPARATOR = 0x6C + VK_SUBTRACT = 0x6D + VK_DECIMAL = 0x6E + VK_DIVIDE = 0x6F + VK_F1 = 0x70 + VK_F2 = 0x71 + VK_F3 = 0x72 + VK_F4 = 0x73 + VK_F5 = 0x74 + VK_F6 = 0x75 + VK_F7 = 0x76 + VK_F8 = 0x77 + VK_F9 = 0x78 + VK_F10 = 0x79 + VK_F11 = 0x7A + VK_F12 = 0x7B + VK_F13 = 0x7C + VK_F14 = 0x7D + VK_F15 = 0x7E + VK_F16 = 0x7F + VK_F17 = 0x80 + VK_F18 = 0x81 + VK_F19 = 0x82 + VK_F20 = 0x83 + VK_F21 = 0x84 + VK_F22 = 0x85 + VK_F23 = 0x86 + VK_F24 = 0x87 + VK_NUMLOCK = 0x90 + VK_SCROLL = 0x91 + VK_OEM_NEC_EQUAL = 0x92 + VK_OEM_FJ_JISHO = 0x92 + VK_OEM_FJ_MASSHOU = 0x93 + VK_OEM_FJ_TOUROKU = 0x94 + VK_OEM_FJ_LOYA = 0x95 + VK_OEM_FJ_ROYA = 0x96 + VK_LSHIFT = 0xA0 + VK_RSHIFT = 0xA1 + VK_LCONTROL = 0xA2 + VK_RCONTROL = 0xA3 + VK_LMENU = 0xA4 + VK_RMENU = 0xA5 + VK_BROWSER_BACK = 0xA6 + VK_BROWSER_FORWARD = 0xA7 + VK_BROWSER_REFRESH = 0xA8 + VK_BROWSER_STOP = 0xA9 + VK_BROWSER_SEARCH = 0xAA + VK_BROWSER_FAVORITES = 0xAB + VK_BROWSER_HOME = 0xAC + VK_VOLUME_MUTE = 0xAD + VK_VOLUME_DOWN = 0xAE + VK_VOLUME_UP = 0xAF + VK_MEDIA_NEXT_TRACK = 0xB0 + VK_MEDIA_PREV_TRACK = 0xB1 + VK_MEDIA_STOP = 0xB2 + VK_MEDIA_PLAY_PAUSE = 0xB3 + VK_LAUNCH_MAIL = 0xB4 + VK_LAUNCH_MEDIA_SELECT = 0xB5 + VK_LAUNCH_APP1 = 0xB6 + VK_LAUNCH_APP2 = 0xB7 + VK_OEM_1 = 0xBA + VK_OEM_PLUS = 0xBB + VK_OEM_COMMA = 0xBC + VK_OEM_MINUS = 0xBD + VK_OEM_PERIOD = 0xBE + VK_OEM_2 = 0xBF + VK_OEM_3 = 0xC0 + VK_OEM_4 = 0xDB + VK_OEM_5 = 0xDC + VK_OEM_6 = 0xDD + VK_OEM_7 = 0xDE + VK_OEM_8 = 0xDF + VK_OEM_AX = 0xE1 + VK_OEM_102 = 0xE2 + VK_ICO_HELP = 0xE3 + VK_ICO_00 = 0xE4 + VK_PROCESSKEY = 0xE5 + VK_ICO_CLEAR = 0xE6 + VK_OEM_RESET = 0xE9 + VK_OEM_JUMP = 0xEA + VK_OEM_PA1 = 0xEB + VK_OEM_PA2 = 0xEC + VK_OEM_PA3 = 0xED + VK_OEM_WSCTRL = 0xEE + VK_OEM_CUSEL = 0xEF + VK_OEM_ATTN = 0xF0 + VK_OEM_FINISH = 0xF1 + VK_OEM_COPY = 0xF2 + VK_OEM_AUTO = 0xF3 + VK_OEM_ENLW = 0xF4 + VK_OEM_BACKTAB = 0xF5 + VK_ATTN = 0xF6 + VK_CRSEL = 0xF7 + VK_EXSEL = 0xF8 + VK_EREOF = 0xF9 + VK_PLAY = 0xFA + VK_ZOOM = 0xFB + VK_NONAME = 0xFC + VK_PA1 = 0xFD + VK_OEM_CLEAR = 0xFE +) + +// Registry Value Types +const ( + REG_NONE = 0 + REG_SZ = 1 + REG_EXPAND_SZ = 2 + REG_BINARY = 3 + REG_DWORD = 4 + REG_DWORD_LITTLE_ENDIAN = 4 + REG_DWORD_BIG_ENDIAN = 5 + REG_LINK = 6 + REG_MULTI_SZ = 7 + REG_RESOURCE_LIST = 8 + REG_FULL_RESOURCE_DESCRIPTOR = 9 + REG_RESOURCE_REQUIREMENTS_LIST = 10 + REG_QWORD = 11 + REG_QWORD_LITTLE_ENDIAN = 11 +) + +// Tooltip styles +const ( + TTS_ALWAYSTIP = 0x01 + TTS_NOPREFIX = 0x02 + TTS_NOANIMATE = 0x10 + TTS_NOFADE = 0x20 + TTS_BALLOON = 0x40 + TTS_CLOSE = 0x80 + TTS_USEVISUALSTYLE = 0x100 +) + +// Tooltip messages +const ( + TTM_ACTIVATE = (WM_USER + 1) + TTM_SETDELAYTIME = (WM_USER + 3) + TTM_ADDTOOL = (WM_USER + 50) + TTM_DELTOOL = (WM_USER + 51) + TTM_NEWTOOLRECT = (WM_USER + 52) + TTM_RELAYEVENT = (WM_USER + 7) + TTM_GETTOOLINFO = (WM_USER + 53) + TTM_SETTOOLINFO = (WM_USER + 54) + TTM_HITTEST = (WM_USER + 55) + TTM_GETTEXT = (WM_USER + 56) + TTM_UPDATETIPTEXT = (WM_USER + 57) + TTM_GETTOOLCOUNT = (WM_USER + 13) + TTM_ENUMTOOLS = (WM_USER + 58) + TTM_GETCURRENTTOOL = (WM_USER + 59) + TTM_WINDOWFROMPOINT = (WM_USER + 16) + TTM_TRACKACTIVATE = (WM_USER + 17) + TTM_TRACKPOSITION = (WM_USER + 18) + TTM_SETTIPBKCOLOR = (WM_USER + 19) + TTM_SETTIPTEXTCOLOR = (WM_USER + 20) + TTM_GETDELAYTIME = (WM_USER + 21) + TTM_GETTIPBKCOLOR = (WM_USER + 22) + TTM_GETTIPTEXTCOLOR = (WM_USER + 23) + TTM_SETMAXTIPWIDTH = (WM_USER + 24) + TTM_GETMAXTIPWIDTH = (WM_USER + 25) + TTM_SETMARGIN = (WM_USER + 26) + TTM_GETMARGIN = (WM_USER + 27) + TTM_POP = (WM_USER + 28) + TTM_UPDATE = (WM_USER + 29) + TTM_GETBUBBLESIZE = (WM_USER + 30) + TTM_ADJUSTRECT = (WM_USER + 31) + TTM_SETTITLE = (WM_USER + 33) + TTM_POPUP = (WM_USER + 34) + TTM_GETTITLE = (WM_USER + 35) +) + +// Tooltip icons +const ( + TTI_NONE = 0 + TTI_INFO = 1 + TTI_WARNING = 2 + TTI_ERROR = 3 + TTI_INFO_LARGE = 4 + TTI_WARNING_LARGE = 5 + TTI_ERROR_LARGE = 6 +) + +// Tooltip notifications +const ( + TTN_FIRST = -520 + TTN_LAST = -549 + TTN_GETDISPINFO = (TTN_FIRST - 10) + TTN_SHOW = (TTN_FIRST - 1) + TTN_POP = (TTN_FIRST - 2) + TTN_LINKCLICK = (TTN_FIRST - 3) + TTN_NEEDTEXT = TTN_GETDISPINFO +) + +const ( + TTF_IDISHWND = 0x0001 + TTF_CENTERTIP = 0x0002 + TTF_RTLREADING = 0x0004 + TTF_SUBCLASS = 0x0010 + TTF_TRACK = 0x0020 + TTF_ABSOLUTE = 0x0080 + TTF_TRANSPARENT = 0x0100 + TTF_PARSELINKS = 0x1000 + TTF_DI_SETITEM = 0x8000 +) + +const ( + SWP_NOSIZE = 0x0001 + SWP_NOMOVE = 0x0002 + SWP_NOZORDER = 0x0004 + SWP_NOREDRAW = 0x0008 + SWP_NOACTIVATE = 0x0010 + SWP_FRAMECHANGED = 0x0020 + SWP_SHOWWINDOW = 0x0040 + SWP_HIDEWINDOW = 0x0080 + SWP_NOCOPYBITS = 0x0100 + SWP_NOOWNERZORDER = 0x0200 + SWP_NOSENDCHANGING = 0x0400 + SWP_DRAWFRAME = SWP_FRAMECHANGED + SWP_NOREPOSITION = SWP_NOOWNERZORDER + SWP_DEFERERASE = 0x2000 + SWP_ASYNCWINDOWPOS = 0x4000 +) + +// Predefined window handles +const ( + HWND_BROADCAST = HWND(0xFFFF) + HWND_BOTTOM = HWND(1) + HWND_NOTOPMOST = ^HWND(1) // -2 + HWND_TOP = HWND(0) + HWND_TOPMOST = ^HWND(0) // -1 + HWND_DESKTOP = HWND(0) + HWND_MESSAGE = ^HWND(2) // -3 +) + +// Pen types +const ( + PS_COSMETIC = 0x00000000 + PS_GEOMETRIC = 0x00010000 + PS_TYPE_MASK = 0x000F0000 +) + +// Pen styles +const ( + PS_SOLID = 0 + PS_DASH = 1 + PS_DOT = 2 + PS_DASHDOT = 3 + PS_DASHDOTDOT = 4 + PS_NULL = 5 + PS_INSIDEFRAME = 6 + PS_USERSTYLE = 7 + PS_ALTERNATE = 8 + PS_STYLE_MASK = 0x0000000F +) + +// Pen cap types +const ( + PS_ENDCAP_ROUND = 0x00000000 + PS_ENDCAP_SQUARE = 0x00000100 + PS_ENDCAP_FLAT = 0x00000200 + PS_ENDCAP_MASK = 0x00000F00 +) + +// Pen join types +const ( + PS_JOIN_ROUND = 0x00000000 + PS_JOIN_BEVEL = 0x00001000 + PS_JOIN_MITER = 0x00002000 + PS_JOIN_MASK = 0x0000F000 +) + +// Hatch styles +const ( + HS_HORIZONTAL = 0 + HS_VERTICAL = 1 + HS_FDIAGONAL = 2 + HS_BDIAGONAL = 3 + HS_CROSS = 4 + HS_DIAGCROSS = 5 +) + +// Stock Logical Objects +const ( + WHITE_BRUSH = 0 + LTGRAY_BRUSH = 1 + GRAY_BRUSH = 2 + DKGRAY_BRUSH = 3 + BLACK_BRUSH = 4 + NULL_BRUSH = 5 + HOLLOW_BRUSH = NULL_BRUSH + WHITE_PEN = 6 + BLACK_PEN = 7 + NULL_PEN = 8 + OEM_FIXED_FONT = 10 + ANSI_FIXED_FONT = 11 + ANSI_VAR_FONT = 12 + SYSTEM_FONT = 13 + DEVICE_DEFAULT_FONT = 14 + DEFAULT_PALETTE = 15 + SYSTEM_FIXED_FONT = 16 + DEFAULT_GUI_FONT = 17 + DC_BRUSH = 18 + DC_PEN = 19 +) + +// Brush styles +const ( + BS_SOLID = 0 + BS_NULL = 1 + BS_HOLLOW = BS_NULL + BS_HATCHED = 2 + BS_PATTERN = 3 + BS_INDEXED = 4 + BS_DIBPATTERN = 5 + BS_DIBPATTERNPT = 6 + BS_PATTERN8X8 = 7 + BS_DIBPATTERN8X8 = 8 + BS_MONOPATTERN = 9 +) + +// TRACKMOUSEEVENT flags +const ( + TME_HOVER = 0x00000001 + TME_LEAVE = 0x00000002 + TME_NONCLIENT = 0x00000010 + TME_QUERY = 0x40000000 + TME_CANCEL = 0x80000000 + + HOVER_DEFAULT = 0xFFFFFFFF +) + +// WM_NCHITTEST and MOUSEHOOKSTRUCT Mouse Position Codes +const ( + HTERROR = (-2) + HTTRANSPARENT = (-1) + HTNOWHERE = 0 + HTCLIENT = 1 + HTCAPTION = 2 + HTSYSMENU = 3 + HTGROWBOX = 4 + HTSIZE = HTGROWBOX + HTMENU = 5 + HTHSCROLL = 6 + HTVSCROLL = 7 + HTMINBUTTON = 8 + HTMAXBUTTON = 9 + HTLEFT = 10 + HTRIGHT = 11 + HTTOP = 12 + HTTOPLEFT = 13 + HTTOPRIGHT = 14 + HTBOTTOM = 15 + HTBOTTOMLEFT = 16 + HTBOTTOMRIGHT = 17 + HTBORDER = 18 + HTREDUCE = HTMINBUTTON + HTZOOM = HTMAXBUTTON + HTSIZEFIRST = HTLEFT + HTSIZELAST = HTBOTTOMRIGHT + HTOBJECT = 19 + HTCLOSE = 20 + HTHELP = 21 +) + +// DrawText[Ex] format flags +const ( + DT_TOP = 0x00000000 + DT_LEFT = 0x00000000 + DT_CENTER = 0x00000001 + DT_RIGHT = 0x00000002 + DT_VCENTER = 0x00000004 + DT_BOTTOM = 0x00000008 + DT_WORDBREAK = 0x00000010 + DT_SINGLELINE = 0x00000020 + DT_EXPANDTABS = 0x00000040 + DT_TABSTOP = 0x00000080 + DT_NOCLIP = 0x00000100 + DT_EXTERNALLEADING = 0x00000200 + DT_CALCRECT = 0x00000400 + DT_NOPREFIX = 0x00000800 + DT_INTERNAL = 0x00001000 + DT_EDITCONTROL = 0x00002000 + DT_PATH_ELLIPSIS = 0x00004000 + DT_END_ELLIPSIS = 0x00008000 + DT_MODIFYSTRING = 0x00010000 + DT_RTLREADING = 0x00020000 + DT_WORD_ELLIPSIS = 0x00040000 + DT_NOFULLWIDTHCHARBREAK = 0x00080000 + DT_HIDEPREFIX = 0x00100000 + DT_PREFIXONLY = 0x00200000 +) + +const CLR_INVALID = 0xFFFFFFFF + +// Background Modes +const ( + TRANSPARENT = 1 + OPAQUE = 2 + BKMODE_LAST = 2 +) + +// Global Memory Flags +const ( + GMEM_FIXED = 0x0000 + GMEM_MOVEABLE = 0x0002 + GMEM_NOCOMPACT = 0x0010 + GMEM_NODISCARD = 0x0020 + GMEM_ZEROINIT = 0x0040 + GMEM_MODIFY = 0x0080 + GMEM_DISCARDABLE = 0x0100 + GMEM_NOT_BANKED = 0x1000 + GMEM_SHARE = 0x2000 + GMEM_DDESHARE = 0x2000 + GMEM_NOTIFY = 0x4000 + GMEM_LOWER = GMEM_NOT_BANKED + GMEM_VALID_FLAGS = 0x7F72 + GMEM_INVALID_HANDLE = 0x8000 + GHND = (GMEM_MOVEABLE | GMEM_ZEROINIT) + GPTR = (GMEM_FIXED | GMEM_ZEROINIT) +) + +// Ternary raster operations +const ( + SRCCOPY = 0x00CC0020 + SRCPAINT = 0x00EE0086 + SRCAND = 0x008800C6 + SRCINVERT = 0x00660046 + SRCERASE = 0x00440328 + NOTSRCCOPY = 0x00330008 + NOTSRCERASE = 0x001100A6 + MERGECOPY = 0x00C000CA + MERGEPAINT = 0x00BB0226 + PATCOPY = 0x00F00021 + PATPAINT = 0x00FB0A09 + PATINVERT = 0x005A0049 + DSTINVERT = 0x00550009 + BLACKNESS = 0x00000042 + WHITENESS = 0x00FF0062 + NOMIRRORBITMAP = 0x80000000 + CAPTUREBLT = 0x40000000 +) + +// Clipboard formats +const ( + CF_TEXT = 1 + CF_BITMAP = 2 + CF_METAFILEPICT = 3 + CF_SYLK = 4 + CF_DIF = 5 + CF_TIFF = 6 + CF_OEMTEXT = 7 + CF_DIB = 8 + CF_PALETTE = 9 + CF_PENDATA = 10 + CF_RIFF = 11 + CF_WAVE = 12 + CF_UNICODETEXT = 13 + CF_ENHMETAFILE = 14 + CF_HDROP = 15 + CF_LOCALE = 16 + CF_DIBV5 = 17 + CF_MAX = 18 + CF_OWNERDISPLAY = 0x0080 + CF_DSPTEXT = 0x0081 + CF_DSPBITMAP = 0x0082 + CF_DSPMETAFILEPICT = 0x0083 + CF_DSPENHMETAFILE = 0x008E + CF_PRIVATEFIRST = 0x0200 + CF_PRIVATELAST = 0x02FF + CF_GDIOBJFIRST = 0x0300 + CF_GDIOBJLAST = 0x03FF +) + +// Bitmap compression formats +const ( + BI_RGB = 0 + BI_RLE8 = 1 + BI_RLE4 = 2 + BI_BITFIELDS = 3 + BI_JPEG = 4 + BI_PNG = 5 +) + +// SetDIBitsToDevice fuColorUse +const ( + DIB_PAL_COLORS = 1 + DIB_RGB_COLORS = 0 +) + +const ( + STANDARD_RIGHTS_REQUIRED = 0x000F +) + +// Service Control Manager object specific access types +const ( + SC_MANAGER_CONNECT = 0x0001 + SC_MANAGER_CREATE_SERVICE = 0x0002 + SC_MANAGER_ENUMERATE_SERVICE = 0x0004 + SC_MANAGER_LOCK = 0x0008 + SC_MANAGER_QUERY_LOCK_STATUS = 0x0010 + SC_MANAGER_MODIFY_BOOT_CONFIG = 0x0020 + SC_MANAGER_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SC_MANAGER_CONNECT | SC_MANAGER_CREATE_SERVICE | SC_MANAGER_ENUMERATE_SERVICE | SC_MANAGER_LOCK | SC_MANAGER_QUERY_LOCK_STATUS | SC_MANAGER_MODIFY_BOOT_CONFIG +) + +// Service Types (Bit Mask) +const ( + SERVICE_KERNEL_DRIVER = 0x00000001 + SERVICE_FILE_SYSTEM_DRIVER = 0x00000002 + SERVICE_ADAPTER = 0x00000004 + SERVICE_RECOGNIZER_DRIVER = 0x00000008 + SERVICE_DRIVER = SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | SERVICE_RECOGNIZER_DRIVER + SERVICE_WIN32_OWN_PROCESS = 0x00000010 + SERVICE_WIN32_SHARE_PROCESS = 0x00000020 + SERVICE_WIN32 = SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS + SERVICE_INTERACTIVE_PROCESS = 0x00000100 + SERVICE_TYPE_ALL = SERVICE_WIN32 | SERVICE_ADAPTER | SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS +) + +// Service State -- for CurrentState +const ( + SERVICE_STOPPED = 0x00000001 + SERVICE_START_PENDING = 0x00000002 + SERVICE_STOP_PENDING = 0x00000003 + SERVICE_RUNNING = 0x00000004 + SERVICE_CONTINUE_PENDING = 0x00000005 + SERVICE_PAUSE_PENDING = 0x00000006 + SERVICE_PAUSED = 0x00000007 +) + +// Controls Accepted (Bit Mask) +const ( + SERVICE_ACCEPT_STOP = 0x00000001 + SERVICE_ACCEPT_PAUSE_CONTINUE = 0x00000002 + SERVICE_ACCEPT_SHUTDOWN = 0x00000004 + SERVICE_ACCEPT_PARAMCHANGE = 0x00000008 + SERVICE_ACCEPT_NETBINDCHANGE = 0x00000010 + SERVICE_ACCEPT_HARDWAREPROFILECHANGE = 0x00000020 + SERVICE_ACCEPT_POWEREVENT = 0x00000040 + SERVICE_ACCEPT_SESSIONCHANGE = 0x00000080 + SERVICE_ACCEPT_PRESHUTDOWN = 0x00000100 + SERVICE_ACCEPT_TIMECHANGE = 0x00000200 + SERVICE_ACCEPT_TRIGGEREVENT = 0x00000400 +) + +// Service object specific access type +const ( + SERVICE_QUERY_CONFIG = 0x0001 + SERVICE_CHANGE_CONFIG = 0x0002 + SERVICE_QUERY_STATUS = 0x0004 + SERVICE_ENUMERATE_DEPENDENTS = 0x0008 + SERVICE_START = 0x0010 + SERVICE_STOP = 0x0020 + SERVICE_PAUSE_CONTINUE = 0x0040 + SERVICE_INTERROGATE = 0x0080 + SERVICE_USER_DEFINED_CONTROL = 0x0100 + + SERVICE_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | + SERVICE_QUERY_CONFIG | + SERVICE_CHANGE_CONFIG | + SERVICE_QUERY_STATUS | + SERVICE_ENUMERATE_DEPENDENTS | + SERVICE_START | + SERVICE_STOP | + SERVICE_PAUSE_CONTINUE | + SERVICE_INTERROGATE | + SERVICE_USER_DEFINED_CONTROL +) + +// MapVirtualKey maptypes +const ( + MAPVK_VK_TO_CHAR = 2 + MAPVK_VK_TO_VSC = 0 + MAPVK_VSC_TO_VK = 1 + MAPVK_VSC_TO_VK_EX = 3 +) + +// ReadEventLog Flags +const ( + EVENTLOG_SEEK_READ = 0x0002 + EVENTLOG_SEQUENTIAL_READ = 0x0001 + EVENTLOG_FORWARDS_READ = 0x0004 + EVENTLOG_BACKWARDS_READ = 0x0008 +) + +// CreateToolhelp32Snapshot flags +const ( + TH32CS_SNAPHEAPLIST = 0x00000001 + TH32CS_SNAPPROCESS = 0x00000002 + TH32CS_SNAPTHREAD = 0x00000004 + TH32CS_SNAPMODULE = 0x00000008 + TH32CS_SNAPMODULE32 = 0x00000010 + TH32CS_INHERIT = 0x80000000 + TH32CS_SNAPALL = TH32CS_SNAPHEAPLIST | TH32CS_SNAPMODULE | TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD +) + +const ( + MAX_MODULE_NAME32 = 255 + MAX_PATH = 260 +) + +const ( + FOREGROUND_BLUE = 0x0001 + FOREGROUND_GREEN = 0x0002 + FOREGROUND_RED = 0x0004 + FOREGROUND_INTENSITY = 0x0008 + BACKGROUND_BLUE = 0x0010 + BACKGROUND_GREEN = 0x0020 + BACKGROUND_RED = 0x0040 + BACKGROUND_INTENSITY = 0x0080 + COMMON_LVB_LEADING_BYTE = 0x0100 + COMMON_LVB_TRAILING_BYTE = 0x0200 + COMMON_LVB_GRID_HORIZONTAL = 0x0400 + COMMON_LVB_GRID_LVERTICAL = 0x0800 + COMMON_LVB_GRID_RVERTICAL = 0x1000 + COMMON_LVB_REVERSE_VIDEO = 0x4000 + COMMON_LVB_UNDERSCORE = 0x8000 +) + +// Flags used by the DWM_BLURBEHIND structure to indicate +// which of its members contain valid information. +const ( + DWM_BB_ENABLE = 0x00000001 // A value for the fEnable member has been specified. + DWM_BB_BLURREGION = 0x00000002 // A value for the hRgnBlur member has been specified. + DWM_BB_TRANSITIONONMAXIMIZED = 0x00000004 // A value for the fTransitionOnMaximized member has been specified. +) + +// Flags used by the DwmEnableComposition function +// to change the state of Desktop Window Manager (DWM) composition. +const ( + DWM_EC_DISABLECOMPOSITION = 0 // Disable composition + DWM_EC_ENABLECOMPOSITION = 1 // Enable composition +) + +// enum-lite implementation for the following constant structure +type DWM_SHOWCONTACT int32 + +const ( + DWMSC_DOWN = 0x00000001 + DWMSC_UP = 0x00000002 + DWMSC_DRAG = 0x00000004 + DWMSC_HOLD = 0x00000008 + DWMSC_PENBARREL = 0x00000010 + DWMSC_NONE = 0x00000000 + DWMSC_ALL = 0xFFFFFFFF +) + +// enum-lite implementation for the following constant structure +type DWM_SOURCE_FRAME_SAMPLING int32 + +// TODO: need to verify this construction +// Flags used by the DwmSetPresentParameters function +// to specify the frame sampling type +const ( + DWM_SOURCE_FRAME_SAMPLING_POINT = iota + 1 + DWM_SOURCE_FRAME_SAMPLING_COVERAGE + DWM_SOURCE_FRAME_SAMPLING_LAST +) + +// Flags used by the DWM_THUMBNAIL_PROPERTIES structure to +// indicate which of its members contain valid information. +const ( + DWM_TNP_RECTDESTINATION = 0x00000001 // A value for the rcDestination member has been specified + DWM_TNP_RECTSOURCE = 0x00000002 // A value for the rcSource member has been specified + DWM_TNP_OPACITY = 0x00000004 // A value for the opacity member has been specified + DWM_TNP_VISIBLE = 0x00000008 // A value for the fVisible member has been specified + DWM_TNP_SOURCECLIENTAREAONLY = 0x00000010 // A value for the fSourceClientAreaOnly member has been specified +) + +// enum-lite implementation for the following constant structure +type DWMFLIP3DWINDOWPOLICY int32 + +// TODO: need to verify this construction +// Flags used by the DwmSetWindowAttribute function +// to specify the Flip3D window policy +const ( + DWMFLIP3D_DEFAULT = iota + 1 + DWMFLIP3D_EXCLUDEBELOW + DWMFLIP3D_EXCLUDEABOVE + DWMFLIP3D_LAST +) + +// enum-lite implementation for the following constant structure +type DWMNCRENDERINGPOLICY int32 + +// TODO: need to verify this construction +// Flags used by the DwmSetWindowAttribute function +// to specify the non-client area rendering policy +const ( + DWMNCRP_USEWINDOWSTYLE = iota + 1 + DWMNCRP_DISABLED + DWMNCRP_ENABLED + DWMNCRP_LAST +) + +// enum-lite implementation for the following constant structure +type DWMTRANSITION_OWNEDWINDOW_TARGET int32 + +const ( + DWMTRANSITION_OWNEDWINDOW_NULL = -1 + DWMTRANSITION_OWNEDWINDOW_REPOSITION = 0 +) + +// enum-lite implementation for the following constant structure +type DWMWINDOWATTRIBUTE int32 + +// TODO: need to verify this construction +// Flags used by the DwmGetWindowAttribute and DwmSetWindowAttribute functions +// to specify window attributes for non-client rendering +const ( + DWMWA_NCRENDERING_ENABLED = iota + 1 + DWMWA_NCRENDERING_POLICY + DWMWA_TRANSITIONS_FORCEDISABLED + DWMWA_ALLOW_NCPAINT + DWMWA_CAPTION_BUTTON_BOUNDS + DWMWA_NONCLIENT_RTL_LAYOUT + DWMWA_FORCE_ICONIC_REPRESENTATION + DWMWA_FLIP3D_POLICY + DWMWA_EXTENDED_FRAME_BOUNDS + DWMWA_HAS_ICONIC_BITMAP + DWMWA_DISALLOW_PEEK + DWMWA_EXCLUDED_FROM_PEEK + DWMWA_CLOAK + DWMWA_CLOAKED + DWMWA_FREEZE_REPRESENTATION + DWMWA_LAST +) + +// enum-lite implementation for the following constant structure +type GESTURE_TYPE int32 + +// TODO: use iota? +// Identifies the gesture type +const ( + GT_PEN_TAP = 0 + GT_PEN_DOUBLETAP = 1 + GT_PEN_RIGHTTAP = 2 + GT_PEN_PRESSANDHOLD = 3 + GT_PEN_PRESSANDHOLDABORT = 4 + GT_TOUCH_TAP = 5 + GT_TOUCH_DOUBLETAP = 6 + GT_TOUCH_RIGHTTAP = 7 + GT_TOUCH_PRESSANDHOLD = 8 + GT_TOUCH_PRESSANDHOLDABORT = 9 + GT_TOUCH_PRESSANDTAP = 10 +) + +// Icons +const ( + ICON_SMALL = 0 + ICON_BIG = 1 + ICON_SMALL2 = 2 +) + +const ( + SIZE_RESTORED = 0 + SIZE_MINIMIZED = 1 + SIZE_MAXIMIZED = 2 + SIZE_MAXSHOW = 3 + SIZE_MAXHIDE = 4 +) + +// XButton values +const ( + XBUTTON1 = 1 + XBUTTON2 = 2 +) + +// Devmode +const ( + DM_SPECVERSION = 0x0401 + + DM_ORIENTATION = 0x00000001 + DM_PAPERSIZE = 0x00000002 + DM_PAPERLENGTH = 0x00000004 + DM_PAPERWIDTH = 0x00000008 + DM_SCALE = 0x00000010 + DM_POSITION = 0x00000020 + DM_NUP = 0x00000040 + DM_DISPLAYORIENTATION = 0x00000080 + DM_COPIES = 0x00000100 + DM_DEFAULTSOURCE = 0x00000200 + DM_PRINTQUALITY = 0x00000400 + DM_COLOR = 0x00000800 + DM_DUPLEX = 0x00001000 + DM_YRESOLUTION = 0x00002000 + DM_TTOPTION = 0x00004000 + DM_COLLATE = 0x00008000 + DM_FORMNAME = 0x00010000 + DM_LOGPIXELS = 0x00020000 + DM_BITSPERPEL = 0x00040000 + DM_PELSWIDTH = 0x00080000 + DM_PELSHEIGHT = 0x00100000 + DM_DISPLAYFLAGS = 0x00200000 + DM_DISPLAYFREQUENCY = 0x00400000 + DM_ICMMETHOD = 0x00800000 + DM_ICMINTENT = 0x01000000 + DM_MEDIATYPE = 0x02000000 + DM_DITHERTYPE = 0x04000000 + DM_PANNINGWIDTH = 0x08000000 + DM_PANNINGHEIGHT = 0x10000000 + DM_DISPLAYFIXEDOUTPUT = 0x20000000 +) + +// ChangeDisplaySettings +const ( + CDS_UPDATEREGISTRY = 0x00000001 + CDS_TEST = 0x00000002 + CDS_FULLSCREEN = 0x00000004 + CDS_GLOBAL = 0x00000008 + CDS_SET_PRIMARY = 0x00000010 + CDS_VIDEOPARAMETERS = 0x00000020 + CDS_RESET = 0x40000000 + CDS_NORESET = 0x10000000 + + DISP_CHANGE_SUCCESSFUL = 0 + DISP_CHANGE_RESTART = 1 + DISP_CHANGE_FAILED = -1 + DISP_CHANGE_BADMODE = -2 + DISP_CHANGE_NOTUPDATED = -3 + DISP_CHANGE_BADFLAGS = -4 + DISP_CHANGE_BADPARAM = -5 + DISP_CHANGE_BADDUALVIEW = -6 +) + +const ( + ENUM_CURRENT_SETTINGS = 0xFFFFFFFF + ENUM_REGISTRY_SETTINGS = 0xFFFFFFFE +) + +// PIXELFORMATDESCRIPTOR +const ( + PFD_TYPE_RGBA = 0 + PFD_TYPE_COLORINDEX = 1 + + PFD_MAIN_PLANE = 0 + PFD_OVERLAY_PLANE = 1 + PFD_UNDERLAY_PLANE = -1 + + PFD_DOUBLEBUFFER = 0x00000001 + PFD_STEREO = 0x00000002 + PFD_DRAW_TO_WINDOW = 0x00000004 + PFD_DRAW_TO_BITMAP = 0x00000008 + PFD_SUPPORT_GDI = 0x00000010 + PFD_SUPPORT_OPENGL = 0x00000020 + PFD_GENERIC_FORMAT = 0x00000040 + PFD_NEED_PALETTE = 0x00000080 + PFD_NEED_SYSTEM_PALETTE = 0x00000100 + PFD_SWAP_EXCHANGE = 0x00000200 + PFD_SWAP_COPY = 0x00000400 + PFD_SWAP_LAYER_BUFFERS = 0x00000800 + PFD_GENERIC_ACCELERATED = 0x00001000 + PFD_SUPPORT_DIRECTDRAW = 0x00002000 + PFD_DIRECT3D_ACCELERATED = 0x00004000 + PFD_SUPPORT_COMPOSITION = 0x00008000 + + PFD_DEPTH_DONTCARE = 0x20000000 + PFD_DOUBLEBUFFER_DONTCARE = 0x40000000 + PFD_STEREO_DONTCARE = 0x80000000 +) + +const ( + INPUT_MOUSE = 0 + INPUT_KEYBOARD = 1 + INPUT_HARDWARE = 2 +) + +const ( + MOUSEEVENTF_ABSOLUTE = 0x8000 + MOUSEEVENTF_HWHEEL = 0x01000 + MOUSEEVENTF_MOVE = 0x0001 + MOUSEEVENTF_MOVE_NOCOALESCE = 0x2000 + MOUSEEVENTF_LEFTDOWN = 0x0002 + MOUSEEVENTF_LEFTUP = 0x0004 + MOUSEEVENTF_RIGHTDOWN = 0x0008 + MOUSEEVENTF_RIGHTUP = 0x0010 + MOUSEEVENTF_MIDDLEDOWN = 0x0020 + MOUSEEVENTF_MIDDLEUP = 0x0040 + MOUSEEVENTF_VIRTUALDESK = 0x4000 + MOUSEEVENTF_WHEEL = 0x0800 + MOUSEEVENTF_XDOWN = 0x0080 + MOUSEEVENTF_XUP = 0x0100 +) diff --git a/Godeps/_workspace/src/github.com/shirou/w32/dwmapi.go b/Godeps/_workspace/src/github.com/shirou/w32/dwmapi.go new file mode 100644 index 0000000000..eb656d1874 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/w32/dwmapi.go @@ -0,0 +1,254 @@ +// Copyright 2010-2012 The W32 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 w32 + +import ( + "fmt" + "syscall" + "unsafe" +) + +// DEFINED IN THE DWM API BUT NOT IMPLEMENTED BY MS: +// DwmAttachMilContent +// DwmDetachMilContent +// DwmEnableComposition +// DwmGetGraphicsStreamClient +// DwmGetGraphicsStreamTransformHint + +var ( + moddwmapi = syscall.NewLazyDLL("dwmapi.dll") + + procDwmDefWindowProc = moddwmapi.NewProc("DwmDefWindowProc") + procDwmEnableBlurBehindWindow = moddwmapi.NewProc("DwmEnableBlurBehindWindow") + procDwmEnableMMCSS = moddwmapi.NewProc("DwmEnableMMCSS") + procDwmExtendFrameIntoClientArea = moddwmapi.NewProc("DwmExtendFrameIntoClientArea") + procDwmFlush = moddwmapi.NewProc("DwmFlush") + procDwmGetColorizationColor = moddwmapi.NewProc("DwmGetColorizationColor") + procDwmGetCompositionTimingInfo = moddwmapi.NewProc("DwmGetCompositionTimingInfo") + procDwmGetTransportAttributes = moddwmapi.NewProc("DwmGetTransportAttributes") + procDwmGetWindowAttribute = moddwmapi.NewProc("DwmGetWindowAttribute") + procDwmInvalidateIconicBitmaps = moddwmapi.NewProc("DwmInvalidateIconicBitmaps") + procDwmIsCompositionEnabled = moddwmapi.NewProc("DwmIsCompositionEnabled") + procDwmModifyPreviousDxFrameDuration = moddwmapi.NewProc("DwmModifyPreviousDxFrameDuration") + procDwmQueryThumbnailSourceSize = moddwmapi.NewProc("DwmQueryThumbnailSourceSize") + procDwmRegisterThumbnail = moddwmapi.NewProc("DwmRegisterThumbnail") + procDwmRenderGesture = moddwmapi.NewProc("DwmRenderGesture") + procDwmSetDxFrameDuration = moddwmapi.NewProc("DwmSetDxFrameDuration") + procDwmSetIconicLivePreviewBitmap = moddwmapi.NewProc("DwmSetIconicLivePreviewBitmap") + procDwmSetIconicThumbnail = moddwmapi.NewProc("DwmSetIconicThumbnail") + procDwmSetPresentParameters = moddwmapi.NewProc("DwmSetPresentParameters") + procDwmSetWindowAttribute = moddwmapi.NewProc("DwmSetWindowAttribute") + procDwmShowContact = moddwmapi.NewProc("DwmShowContact") + procDwmTetherContact = moddwmapi.NewProc("DwmTetherContact") + procDwmTransitionOwnedWindow = moddwmapi.NewProc("DwmTransitionOwnedWindow") + procDwmUnregisterThumbnail = moddwmapi.NewProc("DwmUnregisterThumbnail") + procDwmUpdateThumbnailProperties = moddwmapi.NewProc("DwmUpdateThumbnailProperties") +) + +func DwmDefWindowProc(hWnd HWND, msg uint, wParam, lParam uintptr) (bool, uint) { + var result uint + ret, _, _ := procDwmDefWindowProc.Call( + uintptr(hWnd), + uintptr(msg), + wParam, + lParam, + uintptr(unsafe.Pointer(&result))) + return ret != 0, result +} + +func DwmEnableBlurBehindWindow(hWnd HWND, pBlurBehind *DWM_BLURBEHIND) HRESULT { + ret, _, _ := procDwmEnableBlurBehindWindow.Call( + uintptr(hWnd), + uintptr(unsafe.Pointer(pBlurBehind))) + return HRESULT(ret) +} + +func DwmEnableMMCSS(fEnableMMCSS bool) HRESULT { + ret, _, _ := procDwmEnableMMCSS.Call( + uintptr(BoolToBOOL(fEnableMMCSS))) + return HRESULT(ret) +} + +func DwmExtendFrameIntoClientArea(hWnd HWND, pMarInset *MARGINS) HRESULT { + ret, _, _ := procDwmExtendFrameIntoClientArea.Call( + uintptr(hWnd), + uintptr(unsafe.Pointer(pMarInset))) + return HRESULT(ret) +} + +func DwmFlush() HRESULT { + ret, _, _ := procDwmFlush.Call() + return HRESULT(ret) +} + +func DwmGetColorizationColor(pcrColorization *uint32, pfOpaqueBlend *BOOL) HRESULT { + ret, _, _ := procDwmGetColorizationColor.Call( + uintptr(unsafe.Pointer(pcrColorization)), + uintptr(unsafe.Pointer(pfOpaqueBlend))) + return HRESULT(ret) +} + +func DwmGetCompositionTimingInfo(hWnd HWND, pTimingInfo *DWM_TIMING_INFO) HRESULT { + ret, _, _ := procDwmGetCompositionTimingInfo.Call( + uintptr(hWnd), + uintptr(unsafe.Pointer(pTimingInfo))) + return HRESULT(ret) +} + +func DwmGetTransportAttributes(pfIsRemoting *BOOL, pfIsConnected *BOOL, pDwGeneration *uint32) HRESULT { + ret, _, _ := procDwmGetTransportAttributes.Call( + uintptr(unsafe.Pointer(pfIsRemoting)), + uintptr(unsafe.Pointer(pfIsConnected)), + uintptr(unsafe.Pointer(pDwGeneration))) + return HRESULT(ret) +} + +// TODO: verify handling of variable arguments +func DwmGetWindowAttribute(hWnd HWND, dwAttribute uint32) (pAttribute interface{}, result HRESULT) { + var pvAttribute, pvAttrSize uintptr + switch dwAttribute { + case DWMWA_NCRENDERING_ENABLED: + v := new(BOOL) + pAttribute = v + pvAttribute = uintptr(unsafe.Pointer(v)) + pvAttrSize = unsafe.Sizeof(*v) + case DWMWA_CAPTION_BUTTON_BOUNDS, DWMWA_EXTENDED_FRAME_BOUNDS: + v := new(RECT) + pAttribute = v + pvAttribute = uintptr(unsafe.Pointer(v)) + pvAttrSize = unsafe.Sizeof(*v) + case DWMWA_CLOAKED: + panic(fmt.Sprintf("DwmGetWindowAttribute(%d) is not currently supported.", dwAttribute)) + default: + panic(fmt.Sprintf("DwmGetWindowAttribute(%d) is not valid.", dwAttribute)) + } + + ret, _, _ := procDwmGetWindowAttribute.Call( + uintptr(hWnd), + uintptr(dwAttribute), + pvAttribute, + pvAttrSize) + result = HRESULT(ret) + return +} + +func DwmInvalidateIconicBitmaps(hWnd HWND) HRESULT { + ret, _, _ := procDwmInvalidateIconicBitmaps.Call( + uintptr(hWnd)) + return HRESULT(ret) +} + +func DwmIsCompositionEnabled(pfEnabled *BOOL) HRESULT { + ret, _, _ := procDwmIsCompositionEnabled.Call( + uintptr(unsafe.Pointer(pfEnabled))) + return HRESULT(ret) +} + +func DwmModifyPreviousDxFrameDuration(hWnd HWND, cRefreshes int, fRelative bool) HRESULT { + ret, _, _ := procDwmModifyPreviousDxFrameDuration.Call( + uintptr(hWnd), + uintptr(cRefreshes), + uintptr(BoolToBOOL(fRelative))) + return HRESULT(ret) +} + +func DwmQueryThumbnailSourceSize(hThumbnail HTHUMBNAIL, pSize *SIZE) HRESULT { + ret, _, _ := procDwmQueryThumbnailSourceSize.Call( + uintptr(hThumbnail), + uintptr(unsafe.Pointer(pSize))) + return HRESULT(ret) +} + +func DwmRegisterThumbnail(hWndDestination HWND, hWndSource HWND, phThumbnailId *HTHUMBNAIL) HRESULT { + ret, _, _ := procDwmRegisterThumbnail.Call( + uintptr(hWndDestination), + uintptr(hWndSource), + uintptr(unsafe.Pointer(phThumbnailId))) + return HRESULT(ret) +} + +func DwmRenderGesture(gt GESTURE_TYPE, cContacts uint, pdwPointerID *uint32, pPoints *POINT) { + procDwmRenderGesture.Call( + uintptr(gt), + uintptr(cContacts), + uintptr(unsafe.Pointer(pdwPointerID)), + uintptr(unsafe.Pointer(pPoints))) + return +} + +func DwmSetDxFrameDuration(hWnd HWND, cRefreshes int) HRESULT { + ret, _, _ := procDwmSetDxFrameDuration.Call( + uintptr(hWnd), + uintptr(cRefreshes)) + return HRESULT(ret) +} + +func DwmSetIconicLivePreviewBitmap(hWnd HWND, hbmp HBITMAP, pptClient *POINT, dwSITFlags uint32) HRESULT { + ret, _, _ := procDwmSetIconicLivePreviewBitmap.Call( + uintptr(hWnd), + uintptr(hbmp), + uintptr(unsafe.Pointer(pptClient)), + uintptr(dwSITFlags)) + return HRESULT(ret) +} + +func DwmSetIconicThumbnail(hWnd HWND, hbmp HBITMAP, dwSITFlags uint32) HRESULT { + ret, _, _ := procDwmSetIconicThumbnail.Call( + uintptr(hWnd), + uintptr(hbmp), + uintptr(dwSITFlags)) + return HRESULT(ret) +} + +func DwmSetPresentParameters(hWnd HWND, pPresentParams *DWM_PRESENT_PARAMETERS) HRESULT { + ret, _, _ := procDwmSetPresentParameters.Call( + uintptr(hWnd), + uintptr(unsafe.Pointer(pPresentParams))) + return HRESULT(ret) +} + +func DwmSetWindowAttribute(hWnd HWND, dwAttribute uint32, pvAttribute LPCVOID, cbAttribute uint32) HRESULT { + ret, _, _ := procDwmSetWindowAttribute.Call( + uintptr(hWnd), + uintptr(dwAttribute), + uintptr(pvAttribute), + uintptr(cbAttribute)) + return HRESULT(ret) +} + +func DwmShowContact(dwPointerID uint32, eShowContact DWM_SHOWCONTACT) { + procDwmShowContact.Call( + uintptr(dwPointerID), + uintptr(eShowContact)) + return +} + +func DwmTetherContact(dwPointerID uint32, fEnable bool, ptTether POINT) { + procDwmTetherContact.Call( + uintptr(dwPointerID), + uintptr(BoolToBOOL(fEnable)), + uintptr(unsafe.Pointer(&ptTether))) + return +} + +func DwmTransitionOwnedWindow(hWnd HWND, target DWMTRANSITION_OWNEDWINDOW_TARGET) { + procDwmTransitionOwnedWindow.Call( + uintptr(hWnd), + uintptr(target)) + return +} + +func DwmUnregisterThumbnail(hThumbnailId HTHUMBNAIL) HRESULT { + ret, _, _ := procDwmUnregisterThumbnail.Call( + uintptr(hThumbnailId)) + return HRESULT(ret) +} + +func DwmUpdateThumbnailProperties(hThumbnailId HTHUMBNAIL, ptnProperties *DWM_THUMBNAIL_PROPERTIES) HRESULT { + ret, _, _ := procDwmUpdateThumbnailProperties.Call( + uintptr(hThumbnailId), + uintptr(unsafe.Pointer(ptnProperties))) + return HRESULT(ret) +} diff --git a/Godeps/_workspace/src/github.com/shirou/w32/gdi32.go b/Godeps/_workspace/src/github.com/shirou/w32/gdi32.go new file mode 100644 index 0000000000..6f377e8e4c --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/w32/gdi32.go @@ -0,0 +1,509 @@ +// Copyright 2010-2012 The W32 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 w32 + +import ( + "syscall" + "unsafe" +) + +var ( + modgdi32 = syscall.NewLazyDLL("gdi32.dll") + + procGetDeviceCaps = modgdi32.NewProc("GetDeviceCaps") + procDeleteObject = modgdi32.NewProc("DeleteObject") + procCreateFontIndirect = modgdi32.NewProc("CreateFontIndirectW") + procAbortDoc = modgdi32.NewProc("AbortDoc") + procBitBlt = modgdi32.NewProc("BitBlt") + procCloseEnhMetaFile = modgdi32.NewProc("CloseEnhMetaFile") + procCopyEnhMetaFile = modgdi32.NewProc("CopyEnhMetaFileW") + procCreateBrushIndirect = modgdi32.NewProc("CreateBrushIndirect") + procCreateCompatibleDC = modgdi32.NewProc("CreateCompatibleDC") + procCreateDC = modgdi32.NewProc("CreateDCW") + procCreateDIBSection = modgdi32.NewProc("CreateDIBSection") + procCreateEnhMetaFile = modgdi32.NewProc("CreateEnhMetaFileW") + procCreateIC = modgdi32.NewProc("CreateICW") + procDeleteDC = modgdi32.NewProc("DeleteDC") + procDeleteEnhMetaFile = modgdi32.NewProc("DeleteEnhMetaFile") + procEllipse = modgdi32.NewProc("Ellipse") + procEndDoc = modgdi32.NewProc("EndDoc") + procEndPage = modgdi32.NewProc("EndPage") + procExtCreatePen = modgdi32.NewProc("ExtCreatePen") + procGetEnhMetaFile = modgdi32.NewProc("GetEnhMetaFileW") + procGetEnhMetaFileHeader = modgdi32.NewProc("GetEnhMetaFileHeader") + procGetObject = modgdi32.NewProc("GetObjectW") + procGetStockObject = modgdi32.NewProc("GetStockObject") + procGetTextExtentExPoint = modgdi32.NewProc("GetTextExtentExPointW") + procGetTextExtentPoint32 = modgdi32.NewProc("GetTextExtentPoint32W") + procGetTextMetrics = modgdi32.NewProc("GetTextMetricsW") + procLineTo = modgdi32.NewProc("LineTo") + procMoveToEx = modgdi32.NewProc("MoveToEx") + procPlayEnhMetaFile = modgdi32.NewProc("PlayEnhMetaFile") + procRectangle = modgdi32.NewProc("Rectangle") + procResetDC = modgdi32.NewProc("ResetDCW") + procSelectObject = modgdi32.NewProc("SelectObject") + procSetBkMode = modgdi32.NewProc("SetBkMode") + procSetBrushOrgEx = modgdi32.NewProc("SetBrushOrgEx") + procSetStretchBltMode = modgdi32.NewProc("SetStretchBltMode") + procSetTextColor = modgdi32.NewProc("SetTextColor") + procSetBkColor = modgdi32.NewProc("SetBkColor") + procStartDoc = modgdi32.NewProc("StartDocW") + procStartPage = modgdi32.NewProc("StartPage") + procStretchBlt = modgdi32.NewProc("StretchBlt") + procSetDIBitsToDevice = modgdi32.NewProc("SetDIBitsToDevice") + procChoosePixelFormat = modgdi32.NewProc("ChoosePixelFormat") + procDescribePixelFormat = modgdi32.NewProc("DescribePixelFormat") + procGetEnhMetaFilePixelFormat = modgdi32.NewProc("GetEnhMetaFilePixelFormat") + procGetPixelFormat = modgdi32.NewProc("GetPixelFormat") + procSetPixelFormat = modgdi32.NewProc("SetPixelFormat") + procSwapBuffers = modgdi32.NewProc("SwapBuffers") +) + +func GetDeviceCaps(hdc HDC, index int) int { + ret, _, _ := procGetDeviceCaps.Call( + uintptr(hdc), + uintptr(index)) + + return int(ret) +} + +func DeleteObject(hObject HGDIOBJ) bool { + ret, _, _ := procDeleteObject.Call( + uintptr(hObject)) + + return ret != 0 +} + +func CreateFontIndirect(logFont *LOGFONT) HFONT { + ret, _, _ := procCreateFontIndirect.Call( + uintptr(unsafe.Pointer(logFont))) + + return HFONT(ret) +} + +func AbortDoc(hdc HDC) int { + ret, _, _ := procAbortDoc.Call( + uintptr(hdc)) + + return int(ret) +} + +func BitBlt(hdcDest HDC, nXDest, nYDest, nWidth, nHeight int, hdcSrc HDC, nXSrc, nYSrc int, dwRop uint) { + ret, _, _ := procBitBlt.Call( + uintptr(hdcDest), + uintptr(nXDest), + uintptr(nYDest), + uintptr(nWidth), + uintptr(nHeight), + uintptr(hdcSrc), + uintptr(nXSrc), + uintptr(nYSrc), + uintptr(dwRop)) + + if ret == 0 { + panic("BitBlt failed") + } +} + +func CloseEnhMetaFile(hdc HDC) HENHMETAFILE { + ret, _, _ := procCloseEnhMetaFile.Call( + uintptr(hdc)) + + return HENHMETAFILE(ret) +} + +func CopyEnhMetaFile(hemfSrc HENHMETAFILE, lpszFile *uint16) HENHMETAFILE { + ret, _, _ := procCopyEnhMetaFile.Call( + uintptr(hemfSrc), + uintptr(unsafe.Pointer(lpszFile))) + + return HENHMETAFILE(ret) +} + +func CreateBrushIndirect(lplb *LOGBRUSH) HBRUSH { + ret, _, _ := procCreateBrushIndirect.Call( + uintptr(unsafe.Pointer(lplb))) + + return HBRUSH(ret) +} + +func CreateCompatibleDC(hdc HDC) HDC { + ret, _, _ := procCreateCompatibleDC.Call( + uintptr(hdc)) + + if ret == 0 { + panic("Create compatible DC failed") + } + + return HDC(ret) +} + +func CreateDC(lpszDriver, lpszDevice, lpszOutput *uint16, lpInitData *DEVMODE) HDC { + ret, _, _ := procCreateDC.Call( + uintptr(unsafe.Pointer(lpszDriver)), + uintptr(unsafe.Pointer(lpszDevice)), + uintptr(unsafe.Pointer(lpszOutput)), + uintptr(unsafe.Pointer(lpInitData))) + + return HDC(ret) +} + +func CreateDIBSection(hdc HDC, pbmi *BITMAPINFO, iUsage uint, ppvBits *unsafe.Pointer, hSection HANDLE, dwOffset uint) HBITMAP { + ret, _, _ := procCreateDIBSection.Call( + uintptr(hdc), + uintptr(unsafe.Pointer(pbmi)), + uintptr(iUsage), + uintptr(unsafe.Pointer(ppvBits)), + uintptr(hSection), + uintptr(dwOffset)) + + return HBITMAP(ret) +} + +func CreateEnhMetaFile(hdcRef HDC, lpFilename *uint16, lpRect *RECT, lpDescription *uint16) HDC { + ret, _, _ := procCreateEnhMetaFile.Call( + uintptr(hdcRef), + uintptr(unsafe.Pointer(lpFilename)), + uintptr(unsafe.Pointer(lpRect)), + uintptr(unsafe.Pointer(lpDescription))) + + return HDC(ret) +} + +func CreateIC(lpszDriver, lpszDevice, lpszOutput *uint16, lpdvmInit *DEVMODE) HDC { + ret, _, _ := procCreateIC.Call( + uintptr(unsafe.Pointer(lpszDriver)), + uintptr(unsafe.Pointer(lpszDevice)), + uintptr(unsafe.Pointer(lpszOutput)), + uintptr(unsafe.Pointer(lpdvmInit))) + + return HDC(ret) +} + +func DeleteDC(hdc HDC) bool { + ret, _, _ := procDeleteDC.Call( + uintptr(hdc)) + + return ret != 0 +} + +func DeleteEnhMetaFile(hemf HENHMETAFILE) bool { + ret, _, _ := procDeleteEnhMetaFile.Call( + uintptr(hemf)) + + return ret != 0 +} + +func Ellipse(hdc HDC, nLeftRect, nTopRect, nRightRect, nBottomRect int) bool { + ret, _, _ := procEllipse.Call( + uintptr(hdc), + uintptr(nLeftRect), + uintptr(nTopRect), + uintptr(nRightRect), + uintptr(nBottomRect)) + + return ret != 0 +} + +func EndDoc(hdc HDC) int { + ret, _, _ := procEndDoc.Call( + uintptr(hdc)) + + return int(ret) +} + +func EndPage(hdc HDC) int { + ret, _, _ := procEndPage.Call( + uintptr(hdc)) + + return int(ret) +} + +func ExtCreatePen(dwPenStyle, dwWidth uint, lplb *LOGBRUSH, dwStyleCount uint, lpStyle *uint) HPEN { + ret, _, _ := procExtCreatePen.Call( + uintptr(dwPenStyle), + uintptr(dwWidth), + uintptr(unsafe.Pointer(lplb)), + uintptr(dwStyleCount), + uintptr(unsafe.Pointer(lpStyle))) + + return HPEN(ret) +} + +func GetEnhMetaFile(lpszMetaFile *uint16) HENHMETAFILE { + ret, _, _ := procGetEnhMetaFile.Call( + uintptr(unsafe.Pointer(lpszMetaFile))) + + return HENHMETAFILE(ret) +} + +func GetEnhMetaFileHeader(hemf HENHMETAFILE, cbBuffer uint, lpemh *ENHMETAHEADER) uint { + ret, _, _ := procGetEnhMetaFileHeader.Call( + uintptr(hemf), + uintptr(cbBuffer), + uintptr(unsafe.Pointer(lpemh))) + + return uint(ret) +} + +func GetObject(hgdiobj HGDIOBJ, cbBuffer uintptr, lpvObject unsafe.Pointer) int { + ret, _, _ := procGetObject.Call( + uintptr(hgdiobj), + uintptr(cbBuffer), + uintptr(lpvObject)) + + return int(ret) +} + +func GetStockObject(fnObject int) HGDIOBJ { + ret, _, _ := procGetDeviceCaps.Call( + uintptr(fnObject)) + + return HGDIOBJ(ret) +} + +func GetTextExtentExPoint(hdc HDC, lpszStr *uint16, cchString, nMaxExtent int, lpnFit, alpDx *int, lpSize *SIZE) bool { + ret, _, _ := procGetTextExtentExPoint.Call( + uintptr(hdc), + uintptr(unsafe.Pointer(lpszStr)), + uintptr(cchString), + uintptr(nMaxExtent), + uintptr(unsafe.Pointer(lpnFit)), + uintptr(unsafe.Pointer(alpDx)), + uintptr(unsafe.Pointer(lpSize))) + + return ret != 0 +} + +func GetTextExtentPoint32(hdc HDC, lpString *uint16, c int, lpSize *SIZE) bool { + ret, _, _ := procGetTextExtentPoint32.Call( + uintptr(hdc), + uintptr(unsafe.Pointer(lpString)), + uintptr(c), + uintptr(unsafe.Pointer(lpSize))) + + return ret != 0 +} + +func GetTextMetrics(hdc HDC, lptm *TEXTMETRIC) bool { + ret, _, _ := procGetTextMetrics.Call( + uintptr(hdc), + uintptr(unsafe.Pointer(lptm))) + + return ret != 0 +} + +func LineTo(hdc HDC, nXEnd, nYEnd int) bool { + ret, _, _ := procLineTo.Call( + uintptr(hdc), + uintptr(nXEnd), + uintptr(nYEnd)) + + return ret != 0 +} + +func MoveToEx(hdc HDC, x, y int, lpPoint *POINT) bool { + ret, _, _ := procMoveToEx.Call( + uintptr(hdc), + uintptr(x), + uintptr(y), + uintptr(unsafe.Pointer(lpPoint))) + + return ret != 0 +} + +func PlayEnhMetaFile(hdc HDC, hemf HENHMETAFILE, lpRect *RECT) bool { + ret, _, _ := procPlayEnhMetaFile.Call( + uintptr(hdc), + uintptr(hemf), + uintptr(unsafe.Pointer(lpRect))) + + return ret != 0 +} + +func Rectangle(hdc HDC, nLeftRect, nTopRect, nRightRect, nBottomRect int) bool { + ret, _, _ := procRectangle.Call( + uintptr(hdc), + uintptr(nLeftRect), + uintptr(nTopRect), + uintptr(nRightRect), + uintptr(nBottomRect)) + + return ret != 0 +} + +func ResetDC(hdc HDC, lpInitData *DEVMODE) HDC { + ret, _, _ := procResetDC.Call( + uintptr(hdc), + uintptr(unsafe.Pointer(lpInitData))) + + return HDC(ret) +} + +func SelectObject(hdc HDC, hgdiobj HGDIOBJ) HGDIOBJ { + ret, _, _ := procSelectObject.Call( + uintptr(hdc), + uintptr(hgdiobj)) + + if ret == 0 { + panic("SelectObject failed") + } + + return HGDIOBJ(ret) +} + +func SetBkMode(hdc HDC, iBkMode int) int { + ret, _, _ := procSetBkMode.Call( + uintptr(hdc), + uintptr(iBkMode)) + + if ret == 0 { + panic("SetBkMode failed") + } + + return int(ret) +} + +func SetBrushOrgEx(hdc HDC, nXOrg, nYOrg int, lppt *POINT) bool { + ret, _, _ := procSetBrushOrgEx.Call( + uintptr(hdc), + uintptr(nXOrg), + uintptr(nYOrg), + uintptr(unsafe.Pointer(lppt))) + + return ret != 0 +} + +func SetStretchBltMode(hdc HDC, iStretchMode int) int { + ret, _, _ := procSetStretchBltMode.Call( + uintptr(hdc), + uintptr(iStretchMode)) + + return int(ret) +} + +func SetTextColor(hdc HDC, crColor COLORREF) COLORREF { + ret, _, _ := procSetTextColor.Call( + uintptr(hdc), + uintptr(crColor)) + + if ret == CLR_INVALID { + panic("SetTextColor failed") + } + + return COLORREF(ret) +} + +func SetBkColor(hdc HDC, crColor COLORREF) COLORREF { + ret, _, _ := procSetBkColor.Call( + uintptr(hdc), + uintptr(crColor)) + + if ret == CLR_INVALID { + panic("SetBkColor failed") + } + + return COLORREF(ret) +} + +func StartDoc(hdc HDC, lpdi *DOCINFO) int { + ret, _, _ := procStartDoc.Call( + uintptr(hdc), + uintptr(unsafe.Pointer(lpdi))) + + return int(ret) +} + +func StartPage(hdc HDC) int { + ret, _, _ := procStartPage.Call( + uintptr(hdc)) + + return int(ret) +} + +func StretchBlt(hdcDest HDC, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest int, hdcSrc HDC, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc int, dwRop uint) { + ret, _, _ := procStretchBlt.Call( + uintptr(hdcDest), + uintptr(nXOriginDest), + uintptr(nYOriginDest), + uintptr(nWidthDest), + uintptr(nHeightDest), + uintptr(hdcSrc), + uintptr(nXOriginSrc), + uintptr(nYOriginSrc), + uintptr(nWidthSrc), + uintptr(nHeightSrc), + uintptr(dwRop)) + + if ret == 0 { + panic("StretchBlt failed") + } +} + +func SetDIBitsToDevice(hdc HDC, xDest, yDest, dwWidth, dwHeight, xSrc, ySrc int, uStartScan, cScanLines uint, lpvBits []byte, lpbmi *BITMAPINFO, fuColorUse uint) int { + ret, _, _ := procSetDIBitsToDevice.Call( + uintptr(hdc), + uintptr(xDest), + uintptr(yDest), + uintptr(dwWidth), + uintptr(dwHeight), + uintptr(xSrc), + uintptr(ySrc), + uintptr(uStartScan), + uintptr(cScanLines), + uintptr(unsafe.Pointer(&lpvBits[0])), + uintptr(unsafe.Pointer(lpbmi)), + uintptr(fuColorUse)) + + return int(ret) +} + +func ChoosePixelFormat(hdc HDC, pfd *PIXELFORMATDESCRIPTOR) int { + ret, _, _ := procChoosePixelFormat.Call( + uintptr(hdc), + uintptr(unsafe.Pointer(pfd)), + ) + return int(ret) +} + +func DescribePixelFormat(hdc HDC, iPixelFormat int, nBytes uint, pfd *PIXELFORMATDESCRIPTOR) int { + ret, _, _ := procDescribePixelFormat.Call( + uintptr(hdc), + uintptr(iPixelFormat), + uintptr(nBytes), + uintptr(unsafe.Pointer(pfd)), + ) + return int(ret) +} + +func GetEnhMetaFilePixelFormat(hemf HENHMETAFILE, cbBuffer uint32, pfd *PIXELFORMATDESCRIPTOR) uint { + ret, _, _ := procGetEnhMetaFilePixelFormat.Call( + uintptr(hemf), + uintptr(cbBuffer), + uintptr(unsafe.Pointer(pfd)), + ) + return uint(ret) +} + +func GetPixelFormat(hdc HDC) int { + ret, _, _ := procGetPixelFormat.Call( + uintptr(hdc), + ) + return int(ret) +} + +func SetPixelFormat(hdc HDC, iPixelFormat int, pfd *PIXELFORMATDESCRIPTOR) bool { + ret, _, _ := procSetPixelFormat.Call( + uintptr(hdc), + uintptr(iPixelFormat), + uintptr(unsafe.Pointer(pfd)), + ) + return ret == TRUE +} + +func SwapBuffers(hdc HDC) bool { + ret, _, _ := procSwapBuffers.Call(uintptr(hdc)) + return ret == TRUE +} diff --git a/Godeps/_workspace/src/github.com/shirou/w32/gdiplus.go b/Godeps/_workspace/src/github.com/shirou/w32/gdiplus.go new file mode 100644 index 0000000000..f3a8fca4d1 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/w32/gdiplus.go @@ -0,0 +1,175 @@ +// Copyright 2010-2012 The W32 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 w32 + +import ( + "errors" + "fmt" + "syscall" + "unsafe" +) + +const ( + Ok = 0 + GenericError = 1 + InvalidParameter = 2 + OutOfMemory = 3 + ObjectBusy = 4 + InsufficientBuffer = 5 + NotImplemented = 6 + Win32Error = 7 + WrongState = 8 + Aborted = 9 + FileNotFound = 10 + ValueOverflow = 11 + AccessDenied = 12 + UnknownImageFormat = 13 + FontFamilyNotFound = 14 + FontStyleNotFound = 15 + NotTrueTypeFont = 16 + UnsupportedGdiplusVersion = 17 + GdiplusNotInitialized = 18 + PropertyNotFound = 19 + PropertyNotSupported = 20 + ProfileNotFound = 21 +) + +func GetGpStatus(s int32) string { + switch s { + case Ok: + return "Ok" + case GenericError: + return "GenericError" + case InvalidParameter: + return "InvalidParameter" + case OutOfMemory: + return "OutOfMemory" + case ObjectBusy: + return "ObjectBusy" + case InsufficientBuffer: + return "InsufficientBuffer" + case NotImplemented: + return "NotImplemented" + case Win32Error: + return "Win32Error" + case WrongState: + return "WrongState" + case Aborted: + return "Aborted" + case FileNotFound: + return "FileNotFound" + case ValueOverflow: + return "ValueOverflow" + case AccessDenied: + return "AccessDenied" + case UnknownImageFormat: + return "UnknownImageFormat" + case FontFamilyNotFound: + return "FontFamilyNotFound" + case FontStyleNotFound: + return "FontStyleNotFound" + case NotTrueTypeFont: + return "NotTrueTypeFont" + case UnsupportedGdiplusVersion: + return "UnsupportedGdiplusVersion" + case GdiplusNotInitialized: + return "GdiplusNotInitialized" + case PropertyNotFound: + return "PropertyNotFound" + case PropertyNotSupported: + return "PropertyNotSupported" + case ProfileNotFound: + return "ProfileNotFound" + } + return "Unknown Status Value" +} + +var ( + token uintptr + + modgdiplus = syscall.NewLazyDLL("gdiplus.dll") + + procGdipCreateBitmapFromFile = modgdiplus.NewProc("GdipCreateBitmapFromFile") + procGdipCreateBitmapFromHBITMAP = modgdiplus.NewProc("GdipCreateBitmapFromHBITMAP") + procGdipCreateHBITMAPFromBitmap = modgdiplus.NewProc("GdipCreateHBITMAPFromBitmap") + procGdipCreateBitmapFromResource = modgdiplus.NewProc("GdipCreateBitmapFromResource") + procGdipCreateBitmapFromStream = modgdiplus.NewProc("GdipCreateBitmapFromStream") + procGdipDisposeImage = modgdiplus.NewProc("GdipDisposeImage") + procGdiplusShutdown = modgdiplus.NewProc("GdiplusShutdown") + procGdiplusStartup = modgdiplus.NewProc("GdiplusStartup") +) + +func GdipCreateBitmapFromFile(filename string) (*uintptr, error) { + var bitmap *uintptr + ret, _, _ := procGdipCreateBitmapFromFile.Call( + uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(filename))), + uintptr(unsafe.Pointer(&bitmap))) + + if ret != Ok { + return nil, errors.New(fmt.Sprintf("GdipCreateBitmapFromFile failed with status '%s' for file '%s'", GetGpStatus(int32(ret)), filename)) + } + + return bitmap, nil +} + +func GdipCreateBitmapFromResource(instance HINSTANCE, resId *uint16) (*uintptr, error) { + var bitmap *uintptr + ret, _, _ := procGdipCreateBitmapFromResource.Call( + uintptr(instance), + uintptr(unsafe.Pointer(resId)), + uintptr(unsafe.Pointer(&bitmap))) + + if ret != Ok { + return nil, errors.New(fmt.Sprintf("GdiCreateBitmapFromResource failed with status '%s'", GetGpStatus(int32(ret)))) + } + + return bitmap, nil +} + +func GdipCreateBitmapFromStream(stream *IStream) (*uintptr, error) { + var bitmap *uintptr + ret, _, _ := procGdipCreateBitmapFromStream.Call( + uintptr(unsafe.Pointer(stream)), + uintptr(unsafe.Pointer(&bitmap))) + + if ret != Ok { + return nil, errors.New(fmt.Sprintf("GdipCreateBitmapFromStream failed with status '%s'", GetGpStatus(int32(ret)))) + } + + return bitmap, nil +} + +func GdipCreateHBITMAPFromBitmap(bitmap *uintptr, background uint32) (HBITMAP, error) { + var hbitmap HBITMAP + ret, _, _ := procGdipCreateHBITMAPFromBitmap.Call( + uintptr(unsafe.Pointer(bitmap)), + uintptr(unsafe.Pointer(&hbitmap)), + uintptr(background)) + + if ret != Ok { + return 0, errors.New(fmt.Sprintf("GdipCreateHBITMAPFromBitmap failed with status '%s'", GetGpStatus(int32(ret)))) + } + + return hbitmap, nil +} + +func GdipDisposeImage(image *uintptr) { + procGdipDisposeImage.Call(uintptr(unsafe.Pointer(image))) +} + +func GdiplusShutdown() { + procGdiplusShutdown.Call(token) +} + +func GdiplusStartup(input *GdiplusStartupInput, output *GdiplusStartupOutput) { + ret, _, _ := procGdiplusStartup.Call( + uintptr(unsafe.Pointer(&token)), + uintptr(unsafe.Pointer(input)), + uintptr(unsafe.Pointer(output))) + + if ret != Ok { + panic("GdiplusStartup failed with status " + GetGpStatus(int32(ret))) + } +} diff --git a/Godeps/_workspace/src/github.com/shirou/w32/idispatch.go b/Godeps/_workspace/src/github.com/shirou/w32/idispatch.go new file mode 100644 index 0000000000..41634a6488 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/w32/idispatch.go @@ -0,0 +1,43 @@ +// Copyright 2010-2012 The W32 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 w32 + +import ( + "unsafe" +) + +type pIDispatchVtbl struct { + pQueryInterface uintptr + pAddRef uintptr + pRelease uintptr + pGetTypeInfoCount uintptr + pGetTypeInfo uintptr + pGetIDsOfNames uintptr + pInvoke uintptr +} + +type IDispatch struct { + lpVtbl *pIDispatchVtbl +} + +func (this *IDispatch) QueryInterface(id *GUID) *IDispatch { + return ComQueryInterface((*IUnknown)(unsafe.Pointer(this)), id) +} + +func (this *IDispatch) AddRef() int32 { + return ComAddRef((*IUnknown)(unsafe.Pointer(this))) +} + +func (this *IDispatch) Release() int32 { + return ComRelease((*IUnknown)(unsafe.Pointer(this))) +} + +func (this *IDispatch) GetIDsOfName(names []string) []int32 { + return ComGetIDsOfName(this, names) +} + +func (this *IDispatch) Invoke(dispid int32, dispatch int16, params ...interface{}) *VARIANT { + return ComInvoke(this, dispid, dispatch, params...) +} diff --git a/Godeps/_workspace/src/github.com/shirou/w32/istream.go b/Godeps/_workspace/src/github.com/shirou/w32/istream.go new file mode 100644 index 0000000000..2b840c3b09 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/w32/istream.go @@ -0,0 +1,31 @@ +// Copyright 2010-2012 The W32 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 w32 + +import ( + "unsafe" +) + +type pIStreamVtbl struct { + pQueryInterface uintptr + pAddRef uintptr + pRelease uintptr +} + +type IStream struct { + lpVtbl *pIStreamVtbl +} + +func (this *IStream) QueryInterface(id *GUID) *IDispatch { + return ComQueryInterface((*IUnknown)(unsafe.Pointer(this)), id) +} + +func (this *IStream) AddRef() int32 { + return ComAddRef((*IUnknown)(unsafe.Pointer(this))) +} + +func (this *IStream) Release() int32 { + return ComRelease((*IUnknown)(unsafe.Pointer(this))) +} diff --git a/Godeps/_workspace/src/github.com/shirou/w32/iunknown.go b/Godeps/_workspace/src/github.com/shirou/w32/iunknown.go new file mode 100644 index 0000000000..d63ff1bbca --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/w32/iunknown.go @@ -0,0 +1,27 @@ +// Copyright 2010-2012 The W32 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 w32 + +type pIUnknownVtbl struct { + pQueryInterface uintptr + pAddRef uintptr + pRelease uintptr +} + +type IUnknown struct { + lpVtbl *pIUnknownVtbl +} + +func (this *IUnknown) QueryInterface(id *GUID) *IDispatch { + return ComQueryInterface(this, id) +} + +func (this *IUnknown) AddRef() int32 { + return ComAddRef(this) +} + +func (this *IUnknown) Release() int32 { + return ComRelease(this) +} diff --git a/Godeps/_workspace/src/github.com/shirou/w32/kernel32.go b/Godeps/_workspace/src/github.com/shirou/w32/kernel32.go new file mode 100644 index 0000000000..891ec1578b --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/w32/kernel32.go @@ -0,0 +1,314 @@ +// Copyright 2010-2012 The W32 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 w32 + +import ( + "syscall" + "unsafe" +) + +var ( + modkernel32 = syscall.NewLazyDLL("kernel32.dll") + + procGetModuleHandle = modkernel32.NewProc("GetModuleHandleW") + procMulDiv = modkernel32.NewProc("MulDiv") + procGetConsoleWindow = modkernel32.NewProc("GetConsoleWindow") + procGetCurrentThread = modkernel32.NewProc("GetCurrentThread") + procGetLogicalDrives = modkernel32.NewProc("GetLogicalDrives") + procGetUserDefaultLCID = modkernel32.NewProc("GetUserDefaultLCID") + procLstrlen = modkernel32.NewProc("lstrlenW") + procLstrcpy = modkernel32.NewProc("lstrcpyW") + procGlobalAlloc = modkernel32.NewProc("GlobalAlloc") + procGlobalFree = modkernel32.NewProc("GlobalFree") + procGlobalLock = modkernel32.NewProc("GlobalLock") + procGlobalUnlock = modkernel32.NewProc("GlobalUnlock") + procMoveMemory = modkernel32.NewProc("RtlMoveMemory") + procFindResource = modkernel32.NewProc("FindResourceW") + procSizeofResource = modkernel32.NewProc("SizeofResource") + procLockResource = modkernel32.NewProc("LockResource") + procLoadResource = modkernel32.NewProc("LoadResource") + procGetLastError = modkernel32.NewProc("GetLastError") + procOpenProcess = modkernel32.NewProc("OpenProcess") + procTerminateProcess = modkernel32.NewProc("TerminateProcess") + procCloseHandle = modkernel32.NewProc("CloseHandle") + procCreateToolhelp32Snapshot = modkernel32.NewProc("CreateToolhelp32Snapshot") + procModule32First = modkernel32.NewProc("Module32FirstW") + procModule32Next = modkernel32.NewProc("Module32NextW") + procProcess32First = modkernel32.NewProc("Process32FirstW") + procProcess32Next = modkernel32.NewProc("Process32NextW") + procGetSystemTimes = modkernel32.NewProc("GetSystemTimes") + procGetConsoleScreenBufferInfo = modkernel32.NewProc("GetConsoleScreenBufferInfo") + procSetConsoleTextAttribute = modkernel32.NewProc("SetConsoleTextAttribute") + procGetDiskFreeSpaceEx = modkernel32.NewProc("GetDiskFreeSpaceExW") + procGetProcessTimes = modkernel32.NewProc("GetProcessTimes") +) + +func GetModuleHandle(modulename string) HINSTANCE { + var mn uintptr + if modulename == "" { + mn = 0 + } else { + mn = uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(modulename))) + } + ret, _, _ := procGetModuleHandle.Call(mn) + return HINSTANCE(ret) +} + +func MulDiv(number, numerator, denominator int) int { + ret, _, _ := procMulDiv.Call( + uintptr(number), + uintptr(numerator), + uintptr(denominator)) + + return int(ret) +} + +func GetConsoleWindow() HWND { + ret, _, _ := procGetConsoleWindow.Call() + + return HWND(ret) +} + +func GetCurrentThread() HANDLE { + ret, _, _ := procGetCurrentThread.Call() + + return HANDLE(ret) +} + +func GetLogicalDrives() uint32 { + ret, _, _ := procGetLogicalDrives.Call() + + return uint32(ret) +} + +func GetUserDefaultLCID() uint32 { + ret, _, _ := procGetUserDefaultLCID.Call() + + return uint32(ret) +} + +func Lstrlen(lpString *uint16) int { + ret, _, _ := procLstrlen.Call(uintptr(unsafe.Pointer(lpString))) + + return int(ret) +} + +func Lstrcpy(buf []uint16, lpString *uint16) { + procLstrcpy.Call( + uintptr(unsafe.Pointer(&buf[0])), + uintptr(unsafe.Pointer(lpString))) +} + +func GlobalAlloc(uFlags uint, dwBytes uint32) HGLOBAL { + ret, _, _ := procGlobalAlloc.Call( + uintptr(uFlags), + uintptr(dwBytes)) + + if ret == 0 { + panic("GlobalAlloc failed") + } + + return HGLOBAL(ret) +} + +func GlobalFree(hMem HGLOBAL) { + ret, _, _ := procGlobalFree.Call(uintptr(hMem)) + + if ret != 0 { + panic("GlobalFree failed") + } +} + +func GlobalLock(hMem HGLOBAL) unsafe.Pointer { + ret, _, _ := procGlobalLock.Call(uintptr(hMem)) + + if ret == 0 { + panic("GlobalLock failed") + } + + return unsafe.Pointer(ret) +} + +func GlobalUnlock(hMem HGLOBAL) bool { + ret, _, _ := procGlobalUnlock.Call(uintptr(hMem)) + + return ret != 0 +} + +func MoveMemory(destination, source unsafe.Pointer, length uint32) { + procMoveMemory.Call( + uintptr(unsafe.Pointer(destination)), + uintptr(source), + uintptr(length)) +} + +func FindResource(hModule HMODULE, lpName, lpType *uint16) (HRSRC, error) { + ret, _, _ := procFindResource.Call( + uintptr(hModule), + uintptr(unsafe.Pointer(lpName)), + uintptr(unsafe.Pointer(lpType))) + + if ret == 0 { + return 0, syscall.GetLastError() + } + + return HRSRC(ret), nil +} + +func SizeofResource(hModule HMODULE, hResInfo HRSRC) uint32 { + ret, _, _ := procSizeofResource.Call( + uintptr(hModule), + uintptr(hResInfo)) + + if ret == 0 { + panic("SizeofResource failed") + } + + return uint32(ret) +} + +func LockResource(hResData HGLOBAL) unsafe.Pointer { + ret, _, _ := procLockResource.Call(uintptr(hResData)) + + if ret == 0 { + panic("LockResource failed") + } + + return unsafe.Pointer(ret) +} + +func LoadResource(hModule HMODULE, hResInfo HRSRC) HGLOBAL { + ret, _, _ := procLoadResource.Call( + uintptr(hModule), + uintptr(hResInfo)) + + if ret == 0 { + panic("LoadResource failed") + } + + return HGLOBAL(ret) +} + +func GetLastError() uint32 { + ret, _, _ := procGetLastError.Call() + return uint32(ret) +} + +func OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) HANDLE { + inherit := 0 + if inheritHandle { + inherit = 1 + } + + ret, _, _ := procOpenProcess.Call( + uintptr(desiredAccess), + uintptr(inherit), + uintptr(processId)) + return HANDLE(ret) +} + +func TerminateProcess(hProcess HANDLE, uExitCode uint) bool { + ret, _, _ := procTerminateProcess.Call( + uintptr(hProcess), + uintptr(uExitCode)) + return ret != 0 +} + +func CloseHandle(object HANDLE) bool { + ret, _, _ := procCloseHandle.Call( + uintptr(object)) + return ret != 0 +} + +func CreateToolhelp32Snapshot(flags, processId uint32) HANDLE { + ret, _, _ := procCreateToolhelp32Snapshot.Call( + uintptr(flags), + uintptr(processId)) + + if ret <= 0 { + return HANDLE(0) + } + + return HANDLE(ret) +} + +func Module32First(snapshot HANDLE, me *MODULEENTRY32) bool { + ret, _, _ := procModule32First.Call( + uintptr(snapshot), + uintptr(unsafe.Pointer(me))) + + return ret != 0 +} + +func Module32Next(snapshot HANDLE, me *MODULEENTRY32) bool { + ret, _, _ := procModule32Next.Call( + uintptr(snapshot), + uintptr(unsafe.Pointer(me))) + + return ret != 0 +} +func Process32First(snapshot HANDLE, pe *PROCESSENTRY32) bool { + ret, _, _ := procProcess32First.Call( + uintptr(snapshot), + uintptr(unsafe.Pointer(pe))) + + return ret != 0 +} + +func Process32Next(snapshot HANDLE, pe *PROCESSENTRY32) bool { + ret, _, _ := procProcess32Next.Call( + uintptr(snapshot), + uintptr(unsafe.Pointer(pe))) + + return ret != 0 +} +func GetSystemTimes(lpIdleTime, lpKernelTime, lpUserTime *FILETIME) bool { + ret, _, _ := procGetSystemTimes.Call( + uintptr(unsafe.Pointer(lpIdleTime)), + uintptr(unsafe.Pointer(lpKernelTime)), + uintptr(unsafe.Pointer(lpUserTime))) + + return ret != 0 +} + +func GetProcessTimes(hProcess HANDLE, lpCreationTime, lpExitTime, lpKernelTime, lpUserTime *FILETIME) bool { + ret, _, _ := procGetProcessTimes.Call( + uintptr(hProcess), + uintptr(unsafe.Pointer(lpCreationTime)), + uintptr(unsafe.Pointer(lpExitTime)), + uintptr(unsafe.Pointer(lpKernelTime)), + uintptr(unsafe.Pointer(lpUserTime))) + + return ret != 0 +} + +func GetConsoleScreenBufferInfo(hConsoleOutput HANDLE) *CONSOLE_SCREEN_BUFFER_INFO { + var csbi CONSOLE_SCREEN_BUFFER_INFO + ret, _, _ := procGetConsoleScreenBufferInfo.Call( + uintptr(hConsoleOutput), + uintptr(unsafe.Pointer(&csbi))) + if ret == 0 { + return nil + } + return &csbi +} + +func SetConsoleTextAttribute(hConsoleOutput HANDLE, wAttributes uint16) bool { + ret, _, _ := procSetConsoleTextAttribute.Call( + uintptr(hConsoleOutput), + uintptr(wAttributes)) + return ret != 0 +} + +func GetDiskFreeSpaceEx(dirName string) (r bool, + freeBytesAvailable, totalNumberOfBytes, totalNumberOfFreeBytes uint64) { + ret, _, _ := procGetDiskFreeSpaceEx.Call( + uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(dirName))), + uintptr(unsafe.Pointer(&freeBytesAvailable)), + uintptr(unsafe.Pointer(&totalNumberOfBytes)), + uintptr(unsafe.Pointer(&totalNumberOfFreeBytes))) + return ret != 0, + freeBytesAvailable, totalNumberOfBytes, totalNumberOfFreeBytes +} diff --git a/Godeps/_workspace/src/github.com/shirou/w32/ole32.go b/Godeps/_workspace/src/github.com/shirou/w32/ole32.go new file mode 100644 index 0000000000..a7f79b550d --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/w32/ole32.go @@ -0,0 +1,63 @@ +// Copyright 2010-2012 The W32 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 w32 + +import ( + "syscall" + "unsafe" +) + +var ( + modole32 = syscall.NewLazyDLL("ole32.dll") + + procCoInitializeEx = modole32.NewProc("CoInitializeEx") + procCoInitialize = modole32.NewProc("CoInitialize") + procCoUninitialize = modole32.NewProc("CoUninitialize") + procCreateStreamOnHGlobal = modole32.NewProc("CreateStreamOnHGlobal") +) + +func CoInitializeEx(coInit uintptr) HRESULT { + ret, _, _ := procCoInitializeEx.Call( + 0, + coInit) + + switch uint32(ret) { + case E_INVALIDARG: + panic("CoInitializeEx failed with E_INVALIDARG") + case E_OUTOFMEMORY: + panic("CoInitializeEx failed with E_OUTOFMEMORY") + case E_UNEXPECTED: + panic("CoInitializeEx failed with E_UNEXPECTED") + } + + return HRESULT(ret) +} + +func CoInitialize() { + procCoInitialize.Call(0) +} + +func CoUninitialize() { + procCoUninitialize.Call() +} + +func CreateStreamOnHGlobal(hGlobal HGLOBAL, fDeleteOnRelease bool) *IStream { + stream := new(IStream) + ret, _, _ := procCreateStreamOnHGlobal.Call( + uintptr(hGlobal), + uintptr(BoolToBOOL(fDeleteOnRelease)), + uintptr(unsafe.Pointer(&stream))) + + switch uint32(ret) { + case E_INVALIDARG: + panic("CreateStreamOnHGlobal failed with E_INVALIDARG") + case E_OUTOFMEMORY: + panic("CreateStreamOnHGlobal failed with E_OUTOFMEMORY") + case E_UNEXPECTED: + panic("CreateStreamOnHGlobal failed with E_UNEXPECTED") + } + + return stream +} diff --git a/Godeps/_workspace/src/github.com/shirou/w32/oleaut32.go b/Godeps/_workspace/src/github.com/shirou/w32/oleaut32.go new file mode 100644 index 0000000000..0eeeab7246 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/w32/oleaut32.go @@ -0,0 +1,48 @@ +// Copyright 2010-2012 The W32 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 w32 + +import ( + "syscall" + "unsafe" +) + +var ( + modoleaut32 = syscall.NewLazyDLL("oleaut32") + + procVariantInit = modoleaut32.NewProc("VariantInit") + procSysAllocString = modoleaut32.NewProc("SysAllocString") + procSysFreeString = modoleaut32.NewProc("SysFreeString") + procSysStringLen = modoleaut32.NewProc("SysStringLen") + procCreateDispTypeInfo = modoleaut32.NewProc("CreateDispTypeInfo") + procCreateStdDispatch = modoleaut32.NewProc("CreateStdDispatch") +) + +func VariantInit(v *VARIANT) { + hr, _, _ := procVariantInit.Call(uintptr(unsafe.Pointer(v))) + if hr != 0 { + panic("Invoke VariantInit error.") + } + return +} + +func SysAllocString(v string) (ss *int16) { + pss, _, _ := procSysAllocString.Call(uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(v)))) + ss = (*int16)(unsafe.Pointer(pss)) + return +} + +func SysFreeString(v *int16) { + hr, _, _ := procSysFreeString.Call(uintptr(unsafe.Pointer(v))) + if hr != 0 { + panic("Invoke SysFreeString error.") + } + return +} + +func SysStringLen(v *int16) uint { + l, _, _ := procSysStringLen.Call(uintptr(unsafe.Pointer(v))) + return uint(l) +} diff --git a/Godeps/_workspace/src/github.com/shirou/w32/opengl32.go b/Godeps/_workspace/src/github.com/shirou/w32/opengl32.go new file mode 100644 index 0000000000..7363bb10ad --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/w32/opengl32.go @@ -0,0 +1,72 @@ +// Copyright 2010-2012 The W32 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 w32 + +import ( + "syscall" + "unsafe" +) + +var ( + modopengl32 = syscall.NewLazyDLL("opengl32.dll") + + procwglCreateContext = modopengl32.NewProc("wglCreateContext") + procwglCreateLayerContext = modopengl32.NewProc("wglCreateLayerContext") + procwglDeleteContext = modopengl32.NewProc("wglDeleteContext") + procwglGetProcAddress = modopengl32.NewProc("wglGetProcAddress") + procwglMakeCurrent = modopengl32.NewProc("wglMakeCurrent") + procwglShareLists = modopengl32.NewProc("wglShareLists") +) + +func WglCreateContext(hdc HDC) HGLRC { + ret, _, _ := procwglCreateContext.Call( + uintptr(hdc), + ) + + return HGLRC(ret) +} + +func WglCreateLayerContext(hdc HDC, iLayerPlane int) HGLRC { + ret, _, _ := procwglCreateLayerContext.Call( + uintptr(hdc), + uintptr(iLayerPlane), + ) + + return HGLRC(ret) +} + +func WglDeleteContext(hglrc HGLRC) bool { + ret, _, _ := procwglDeleteContext.Call( + uintptr(hglrc), + ) + + return ret == TRUE +} + +func WglGetProcAddress(szProc string) uintptr { + ret, _, _ := procwglGetProcAddress.Call( + uintptr(unsafe.Pointer(syscall.StringBytePtr(szProc))), + ) + + return ret +} + +func WglMakeCurrent(hdc HDC, hglrc HGLRC) bool { + ret, _, _ := procwglMakeCurrent.Call( + uintptr(hdc), + uintptr(hglrc), + ) + + return ret == TRUE +} + +func WglShareLists(hglrc1, hglrc2 HGLRC) bool { + ret, _, _ := procwglShareLists.Call( + uintptr(hglrc1), + uintptr(hglrc2), + ) + + return ret == TRUE +} diff --git a/Godeps/_workspace/src/github.com/shirou/w32/psapi.go b/Godeps/_workspace/src/github.com/shirou/w32/psapi.go new file mode 100644 index 0000000000..bd1e12627c --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/w32/psapi.go @@ -0,0 +1,25 @@ +// Copyright 2010-2012 The W32 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 w32 + +import ( + "syscall" + "unsafe" +) + +var ( + modpsapi = syscall.NewLazyDLL("psapi.dll") + + procEnumProcesses = modpsapi.NewProc("EnumProcesses") +) + +func EnumProcesses(processIds []uint32, cb uint32, bytesReturned *uint32) bool { + ret, _, _ := procEnumProcesses.Call( + uintptr(unsafe.Pointer(&processIds[0])), + uintptr(cb), + uintptr(unsafe.Pointer(bytesReturned))) + + return ret != 0 +} diff --git a/Godeps/_workspace/src/github.com/shirou/w32/shell32.go b/Godeps/_workspace/src/github.com/shirou/w32/shell32.go new file mode 100644 index 0000000000..0923b8b61d --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/w32/shell32.go @@ -0,0 +1,153 @@ +// Copyright 2010-2012 The W32 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 w32 + +import ( + "errors" + "fmt" + "syscall" + "unsafe" +) + +var ( + modshell32 = syscall.NewLazyDLL("shell32.dll") + + procSHBrowseForFolder = modshell32.NewProc("SHBrowseForFolderW") + procSHGetPathFromIDList = modshell32.NewProc("SHGetPathFromIDListW") + procDragAcceptFiles = modshell32.NewProc("DragAcceptFiles") + procDragQueryFile = modshell32.NewProc("DragQueryFileW") + procDragQueryPoint = modshell32.NewProc("DragQueryPoint") + procDragFinish = modshell32.NewProc("DragFinish") + procShellExecute = modshell32.NewProc("ShellExecuteW") + procExtractIcon = modshell32.NewProc("ExtractIconW") +) + +func SHBrowseForFolder(bi *BROWSEINFO) uintptr { + ret, _, _ := procSHBrowseForFolder.Call(uintptr(unsafe.Pointer(bi))) + + return ret +} + +func SHGetPathFromIDList(idl uintptr) string { + buf := make([]uint16, 1024) + procSHGetPathFromIDList.Call( + idl, + uintptr(unsafe.Pointer(&buf[0]))) + + return syscall.UTF16ToString(buf) +} + +func DragAcceptFiles(hwnd HWND, accept bool) { + procDragAcceptFiles.Call( + uintptr(hwnd), + uintptr(BoolToBOOL(accept))) +} + +func DragQueryFile(hDrop HDROP, iFile uint) (fileName string, fileCount uint) { + ret, _, _ := procDragQueryFile.Call( + uintptr(hDrop), + uintptr(iFile), + 0, + 0) + + fileCount = uint(ret) + + if iFile != 0xFFFFFFFF { + buf := make([]uint16, fileCount+1) + + ret, _, _ := procDragQueryFile.Call( + uintptr(hDrop), + uintptr(iFile), + uintptr(unsafe.Pointer(&buf[0])), + uintptr(fileCount+1)) + + if ret == 0 { + panic("Invoke DragQueryFile error.") + } + + fileName = syscall.UTF16ToString(buf) + } + + return +} + +func DragQueryPoint(hDrop HDROP) (x, y int, isClientArea bool) { + var pt POINT + ret, _, _ := procDragQueryPoint.Call( + uintptr(hDrop), + uintptr(unsafe.Pointer(&pt))) + + return int(pt.X), int(pt.Y), (ret == 1) +} + +func DragFinish(hDrop HDROP) { + procDragFinish.Call(uintptr(hDrop)) +} + +func ShellExecute(hwnd HWND, lpOperation, lpFile, lpParameters, lpDirectory string, nShowCmd int) error { + var op, param, directory uintptr + if len(lpOperation) != 0 { + op = uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpOperation))) + } + if len(lpParameters) != 0 { + param = uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpParameters))) + } + if len(lpDirectory) != 0 { + directory = uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpDirectory))) + } + + ret, _, _ := procShellExecute.Call( + uintptr(hwnd), + op, + uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpFile))), + param, + directory, + uintptr(nShowCmd)) + + errorMsg := "" + if ret != 0 && ret <= 32 { + switch int(ret) { + case ERROR_FILE_NOT_FOUND: + errorMsg = "The specified file was not found." + case ERROR_PATH_NOT_FOUND: + errorMsg = "The specified path was not found." + case ERROR_BAD_FORMAT: + errorMsg = "The .exe file is invalid (non-Win32 .exe or error in .exe image)." + case SE_ERR_ACCESSDENIED: + errorMsg = "The operating system denied access to the specified file." + case SE_ERR_ASSOCINCOMPLETE: + errorMsg = "The file name association is incomplete or invalid." + case SE_ERR_DDEBUSY: + errorMsg = "The DDE transaction could not be completed because other DDE transactions were being processed." + case SE_ERR_DDEFAIL: + errorMsg = "The DDE transaction failed." + case SE_ERR_DDETIMEOUT: + errorMsg = "The DDE transaction could not be completed because the request timed out." + case SE_ERR_DLLNOTFOUND: + errorMsg = "The specified DLL was not found." + case SE_ERR_NOASSOC: + errorMsg = "There is no application associated with the given file name extension. This error will also be returned if you attempt to print a file that is not printable." + case SE_ERR_OOM: + errorMsg = "There was not enough memory to complete the operation." + case SE_ERR_SHARE: + errorMsg = "A sharing violation occurred." + default: + errorMsg = fmt.Sprintf("Unknown error occurred with error code %v", ret) + } + } else { + return nil + } + + return errors.New(errorMsg) +} + +func ExtractIcon(lpszExeFileName string, nIconIndex int) HICON { + ret, _, _ := procExtractIcon.Call( + 0, + uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(lpszExeFileName))), + uintptr(nIconIndex)) + + return HICON(ret) +} diff --git a/Godeps/_workspace/src/github.com/shirou/w32/typedef.go b/Godeps/_workspace/src/github.com/shirou/w32/typedef.go new file mode 100644 index 0000000000..65f5111292 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/w32/typedef.go @@ -0,0 +1,901 @@ +// Copyright 2010-2012 The W32 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 w32 + +import ( + "unsafe" +) + +// From MSDN: Windows Data Types +// http://msdn.microsoft.com/en-us/library/s3f49ktz.aspx +// http://msdn.microsoft.com/en-us/library/windows/desktop/aa383751.aspx +// ATOM WORD +// BOOL int32 +// BOOLEAN byte +// BYTE byte +// CCHAR int8 +// CHAR int8 +// COLORREF DWORD +// DWORD uint32 +// DWORDLONG ULONGLONG +// DWORD_PTR ULONG_PTR +// DWORD32 uint32 +// DWORD64 uint64 +// FLOAT float32 +// HACCEL HANDLE +// HALF_PTR struct{} // ??? +// HANDLE PVOID +// HBITMAP HANDLE +// HBRUSH HANDLE +// HCOLORSPACE HANDLE +// HCONV HANDLE +// HCONVLIST HANDLE +// HCURSOR HANDLE +// HDC HANDLE +// HDDEDATA HANDLE +// HDESK HANDLE +// HDROP HANDLE +// HDWP HANDLE +// HENHMETAFILE HANDLE +// HFILE HANDLE +// HFONT HANDLE +// HGDIOBJ HANDLE +// HGLOBAL HANDLE +// HHOOK HANDLE +// HICON HANDLE +// HINSTANCE HANDLE +// HKEY HANDLE +// HKL HANDLE +// HLOCAL HANDLE +// HMENU HANDLE +// HMETAFILE HANDLE +// HMODULE HANDLE +// HPALETTE HANDLE +// HPEN HANDLE +// HRESULT int32 +// HRGN HANDLE +// HSZ HANDLE +// HWINSTA HANDLE +// HWND HANDLE +// INT int32 +// INT_PTR uintptr +// INT8 int8 +// INT16 int16 +// INT32 int32 +// INT64 int64 +// LANGID WORD +// LCID DWORD +// LCTYPE DWORD +// LGRPID DWORD +// LONG int32 +// LONGLONG int64 +// LONG_PTR uintptr +// LONG32 int32 +// LONG64 int64 +// LPARAM LONG_PTR +// LPBOOL *BOOL +// LPBYTE *BYTE +// LPCOLORREF *COLORREF +// LPCSTR *int8 +// LPCTSTR LPCWSTR +// LPCVOID unsafe.Pointer +// LPCWSTR *WCHAR +// LPDWORD *DWORD +// LPHANDLE *HANDLE +// LPINT *INT +// LPLONG *LONG +// LPSTR *CHAR +// LPTSTR LPWSTR +// LPVOID unsafe.Pointer +// LPWORD *WORD +// LPWSTR *WCHAR +// LRESULT LONG_PTR +// PBOOL *BOOL +// PBOOLEAN *BOOLEAN +// PBYTE *BYTE +// PCHAR *CHAR +// PCSTR *CHAR +// PCTSTR PCWSTR +// PCWSTR *WCHAR +// PDWORD *DWORD +// PDWORDLONG *DWORDLONG +// PDWORD_PTR *DWORD_PTR +// PDWORD32 *DWORD32 +// PDWORD64 *DWORD64 +// PFLOAT *FLOAT +// PHALF_PTR *HALF_PTR +// PHANDLE *HANDLE +// PHKEY *HKEY +// PINT_PTR *INT_PTR +// PINT8 *INT8 +// PINT16 *INT16 +// PINT32 *INT32 +// PINT64 *INT64 +// PLCID *LCID +// PLONG *LONG +// PLONGLONG *LONGLONG +// PLONG_PTR *LONG_PTR +// PLONG32 *LONG32 +// PLONG64 *LONG64 +// POINTER_32 struct{} // ??? +// POINTER_64 struct{} // ??? +// POINTER_SIGNED uintptr +// POINTER_UNSIGNED uintptr +// PSHORT *SHORT +// PSIZE_T *SIZE_T +// PSSIZE_T *SSIZE_T +// PSTR *CHAR +// PTBYTE *TBYTE +// PTCHAR *TCHAR +// PTSTR PWSTR +// PUCHAR *UCHAR +// PUHALF_PTR *UHALF_PTR +// PUINT *UINT +// PUINT_PTR *UINT_PTR +// PUINT8 *UINT8 +// PUINT16 *UINT16 +// PUINT32 *UINT32 +// PUINT64 *UINT64 +// PULONG *ULONG +// PULONGLONG *ULONGLONG +// PULONG_PTR *ULONG_PTR +// PULONG32 *ULONG32 +// PULONG64 *ULONG64 +// PUSHORT *USHORT +// PVOID unsafe.Pointer +// PWCHAR *WCHAR +// PWORD *WORD +// PWSTR *WCHAR +// QWORD uint64 +// SC_HANDLE HANDLE +// SC_LOCK LPVOID +// SERVICE_STATUS_HANDLE HANDLE +// SHORT int16 +// SIZE_T ULONG_PTR +// SSIZE_T LONG_PTR +// TBYTE WCHAR +// TCHAR WCHAR +// UCHAR uint8 +// UHALF_PTR struct{} // ??? +// UINT uint32 +// UINT_PTR uintptr +// UINT8 uint8 +// UINT16 uint16 +// UINT32 uint32 +// UINT64 uint64 +// ULONG uint32 +// ULONGLONG uint64 +// ULONG_PTR uintptr +// ULONG32 uint32 +// ULONG64 uint64 +// USHORT uint16 +// USN LONGLONG +// WCHAR uint16 +// WORD uint16 +// WPARAM UINT_PTR +type ( + ATOM uint16 + BOOL int32 + COLORREF uint32 + DWM_FRAME_COUNT uint64 + HACCEL HANDLE + HANDLE uintptr + HBITMAP HANDLE + HBRUSH HANDLE + HCURSOR HANDLE + HDC HANDLE + HDROP HANDLE + HDWP HANDLE + HENHMETAFILE HANDLE + HFONT HANDLE + HGDIOBJ HANDLE + HGLOBAL HANDLE + HGLRC HANDLE + HICON HANDLE + HIMAGELIST HANDLE + HINSTANCE HANDLE + HKEY HANDLE + HKL HANDLE + HMENU HANDLE + HMODULE HANDLE + HMONITOR HANDLE + HPEN HANDLE + HRESULT int32 + HRGN HANDLE + HRSRC HANDLE + HTHUMBNAIL HANDLE + HWND HANDLE + LPCVOID unsafe.Pointer + PVOID unsafe.Pointer + QPC_TIME uint64 +) + +// http://msdn.microsoft.com/en-us/library/windows/desktop/dd162805.aspx +type POINT struct { + X, Y int32 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/dd162897.aspx +type RECT struct { + Left, Top, Right, Bottom int32 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/ms633577.aspx +type WNDCLASSEX struct { + Size uint32 + Style uint32 + WndProc uintptr + ClsExtra int32 + WndExtra int32 + Instance HINSTANCE + Icon HICON + Cursor HCURSOR + Background HBRUSH + MenuName *uint16 + ClassName *uint16 + IconSm HICON +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/ms644958.aspx +type MSG struct { + Hwnd HWND + Message uint32 + WParam uintptr + LParam uintptr + Time uint32 + Pt POINT +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/dd145037.aspx +type LOGFONT struct { + Height int32 + Width int32 + Escapement int32 + Orientation int32 + Weight int32 + Italic byte + Underline byte + StrikeOut byte + CharSet byte + OutPrecision byte + ClipPrecision byte + Quality byte + PitchAndFamily byte + FaceName [LF_FACESIZE]uint16 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/ms646839.aspx +type OPENFILENAME struct { + StructSize uint32 + Owner HWND + Instance HINSTANCE + Filter *uint16 + CustomFilter *uint16 + MaxCustomFilter uint32 + FilterIndex uint32 + File *uint16 + MaxFile uint32 + FileTitle *uint16 + MaxFileTitle uint32 + InitialDir *uint16 + Title *uint16 + Flags uint32 + FileOffset uint16 + FileExtension uint16 + DefExt *uint16 + CustData uintptr + FnHook uintptr + TemplateName *uint16 + PvReserved unsafe.Pointer + DwReserved uint32 + FlagsEx uint32 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/bb773205.aspx +type BROWSEINFO struct { + Owner HWND + Root *uint16 + DisplayName *uint16 + Title *uint16 + Flags uint32 + CallbackFunc uintptr + LParam uintptr + Image int32 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/aa373931.aspx +type GUID struct { + Data1 uint32 + Data2 uint16 + Data3 uint16 + Data4 [8]byte +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/ms221627.aspx +type VARIANT struct { + VT uint16 // 2 + WReserved1 uint16 // 4 + WReserved2 uint16 // 6 + WReserved3 uint16 // 8 + Val int64 // 16 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/ms221416.aspx +type DISPPARAMS struct { + Rgvarg uintptr + RgdispidNamedArgs uintptr + CArgs uint32 + CNamedArgs uint32 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/ms221133.aspx +type EXCEPINFO struct { + WCode uint16 + WReserved uint16 + BstrSource *uint16 + BstrDescription *uint16 + BstrHelpFile *uint16 + DwHelpContext uint32 + PvReserved uintptr + PfnDeferredFillIn uintptr + Scode int32 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/dd145035.aspx +type LOGBRUSH struct { + LbStyle uint32 + LbColor COLORREF + LbHatch uintptr +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/dd183565.aspx +type DEVMODE struct { + DmDeviceName [CCHDEVICENAME]uint16 + DmSpecVersion uint16 + DmDriverVersion uint16 + DmSize uint16 + DmDriverExtra uint16 + DmFields uint32 + DmOrientation int16 + DmPaperSize int16 + DmPaperLength int16 + DmPaperWidth int16 + DmScale int16 + DmCopies int16 + DmDefaultSource int16 + DmPrintQuality int16 + DmColor int16 + DmDuplex int16 + DmYResolution int16 + DmTTOption int16 + DmCollate int16 + DmFormName [CCHFORMNAME]uint16 + DmLogPixels uint16 + DmBitsPerPel uint32 + DmPelsWidth uint32 + DmPelsHeight uint32 + DmDisplayFlags uint32 + DmDisplayFrequency uint32 + DmICMMethod uint32 + DmICMIntent uint32 + DmMediaType uint32 + DmDitherType uint32 + DmReserved1 uint32 + DmReserved2 uint32 + DmPanningWidth uint32 + DmPanningHeight uint32 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/dd183376.aspx +type BITMAPINFOHEADER struct { + BiSize uint32 + BiWidth int32 + BiHeight int32 + BiPlanes uint16 + BiBitCount uint16 + BiCompression uint32 + BiSizeImage uint32 + BiXPelsPerMeter int32 + BiYPelsPerMeter int32 + BiClrUsed uint32 + BiClrImportant uint32 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/dd162938.aspx +type RGBQUAD struct { + RgbBlue byte + RgbGreen byte + RgbRed byte + RgbReserved byte +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/dd183375.aspx +type BITMAPINFO struct { + BmiHeader BITMAPINFOHEADER + BmiColors *RGBQUAD +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/dd183371.aspx +type BITMAP struct { + BmType int32 + BmWidth int32 + BmHeight int32 + BmWidthBytes int32 + BmPlanes uint16 + BmBitsPixel uint16 + BmBits unsafe.Pointer +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/dd183567.aspx +type DIBSECTION struct { + DsBm BITMAP + DsBmih BITMAPINFOHEADER + DsBitfields [3]uint32 + DshSection HANDLE + DsOffset uint32 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/dd162607.aspx +type ENHMETAHEADER struct { + IType uint32 + NSize uint32 + RclBounds RECT + RclFrame RECT + DSignature uint32 + NVersion uint32 + NBytes uint32 + NRecords uint32 + NHandles uint16 + SReserved uint16 + NDescription uint32 + OffDescription uint32 + NPalEntries uint32 + SzlDevice SIZE + SzlMillimeters SIZE + CbPixelFormat uint32 + OffPixelFormat uint32 + BOpenGL uint32 + SzlMicrometers SIZE +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/dd145106.aspx +type SIZE struct { + CX, CY int32 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/dd145132.aspx +type TEXTMETRIC struct { + TmHeight int32 + TmAscent int32 + TmDescent int32 + TmInternalLeading int32 + TmExternalLeading int32 + TmAveCharWidth int32 + TmMaxCharWidth int32 + TmWeight int32 + TmOverhang int32 + TmDigitizedAspectX int32 + TmDigitizedAspectY int32 + TmFirstChar uint16 + TmLastChar uint16 + TmDefaultChar uint16 + TmBreakChar uint16 + TmItalic byte + TmUnderlined byte + TmStruckOut byte + TmPitchAndFamily byte + TmCharSet byte +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/dd183574.aspx +type DOCINFO struct { + CbSize int32 + LpszDocName *uint16 + LpszOutput *uint16 + LpszDatatype *uint16 + FwType uint32 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/bb775514.aspx +type NMHDR struct { + HwndFrom HWND + IdFrom uintptr + Code uint32 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/bb774743.aspx +type LVCOLUMN struct { + Mask uint32 + Fmt int32 + Cx int32 + PszText *uint16 + CchTextMax int32 + ISubItem int32 + IImage int32 + IOrder int32 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/bb774760.aspx +type LVITEM struct { + Mask uint32 + IItem int32 + ISubItem int32 + State uint32 + StateMask uint32 + PszText *uint16 + CchTextMax int32 + IImage int32 + LParam uintptr + IIndent int32 + IGroupId int32 + CColumns uint32 + PuColumns uint32 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/bb774754.aspx +type LVHITTESTINFO struct { + Pt POINT + Flags uint32 + IItem int32 + ISubItem int32 + IGroup int32 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/bb774771.aspx +type NMITEMACTIVATE struct { + Hdr NMHDR + IItem int32 + ISubItem int32 + UNewState uint32 + UOldState uint32 + UChanged uint32 + PtAction POINT + LParam uintptr + UKeyFlags uint32 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/bb774773.aspx +type NMLISTVIEW struct { + Hdr NMHDR + IItem int32 + ISubItem int32 + UNewState uint32 + UOldState uint32 + UChanged uint32 + PtAction POINT + LParam uintptr +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/bb774780.aspx +type NMLVDISPINFO struct { + Hdr NMHDR + Item LVITEM +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/bb775507.aspx +type INITCOMMONCONTROLSEX struct { + DwSize uint32 + DwICC uint32 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/bb760256.aspx +type TOOLINFO struct { + CbSize uint32 + UFlags uint32 + Hwnd HWND + UId uintptr + Rect RECT + Hinst HINSTANCE + LpszText *uint16 + LParam uintptr + LpReserved unsafe.Pointer +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/ms645604.aspx +type TRACKMOUSEEVENT struct { + CbSize uint32 + DwFlags uint32 + HwndTrack HWND + DwHoverTime uint32 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/ms534067.aspx +type GdiplusStartupInput struct { + GdiplusVersion uint32 + DebugEventCallback uintptr + SuppressBackgroundThread BOOL + SuppressExternalCodecs BOOL +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/ms534068.aspx +type GdiplusStartupOutput struct { + NotificationHook uintptr + NotificationUnhook uintptr +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/dd162768.aspx +type PAINTSTRUCT struct { + Hdc HDC + FErase BOOL + RcPaint RECT + FRestore BOOL + FIncUpdate BOOL + RgbReserved [32]byte +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/aa363646.aspx +type EVENTLOGRECORD struct { + Length uint32 + Reserved uint32 + RecordNumber uint32 + TimeGenerated uint32 + TimeWritten uint32 + EventID uint32 + EventType uint16 + NumStrings uint16 + EventCategory uint16 + ReservedFlags uint16 + ClosingRecordNumber uint32 + StringOffset uint32 + UserSidLength uint32 + UserSidOffset uint32 + DataLength uint32 + DataOffset uint32 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/ms685996.aspx +type SERVICE_STATUS struct { + DwServiceType uint32 + DwCurrentState uint32 + DwControlsAccepted uint32 + DwWin32ExitCode uint32 + DwServiceSpecificExitCode uint32 + DwCheckPoint uint32 + DwWaitHint uint32 +} +type PROCESSENTRY32 struct { + DwSize uint32 + CntUsage uint32 + Th32ProcessID uint32 + Th32DefaultHeapID uintptr + Th32ModuleID uint32 + CntThreads uint32 + Th32ParentProcessID uint32 + PcPriClassBase int32 + DwFlags uint32 + SzExeFile [MAX_PATH]uint16 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/ms684225.aspx +type MODULEENTRY32 struct { + Size uint32 + ModuleID uint32 + ProcessID uint32 + GlblcntUsage uint32 + ProccntUsage uint32 + ModBaseAddr *uint8 + ModBaseSize uint32 + HModule HMODULE + SzModule [MAX_MODULE_NAME32 + 1]uint16 + SzExePath [MAX_PATH]uint16 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/ms724284.aspx +type FILETIME struct { + DwLowDateTime uint32 + DwHighDateTime uint32 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/ms682119.aspx +type COORD struct { + X, Y int16 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/ms686311.aspx +type SMALL_RECT struct { + Left, Top, Right, Bottom int16 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/ms682093.aspx +type CONSOLE_SCREEN_BUFFER_INFO struct { + DwSize COORD + DwCursorPosition COORD + WAttributes uint16 + SrWindow SMALL_RECT + DwMaximumWindowSize COORD +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/bb773244.aspx +type MARGINS struct { + CxLeftWidth, CxRightWidth, CyTopHeight, CyBottomHeight int32 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/aa969500.aspx +type DWM_BLURBEHIND struct { + DwFlags uint32 + fEnable BOOL + hRgnBlur HRGN + fTransitionOnMaximized BOOL +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/aa969501.aspx +type DWM_PRESENT_PARAMETERS struct { + cbSize uint32 + fQueue BOOL + cRefreshStart DWM_FRAME_COUNT + cBuffer uint32 + fUseSourceRate BOOL + rateSource UNSIGNED_RATIO + cRefreshesPerFrame uint32 + eSampling DWM_SOURCE_FRAME_SAMPLING +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/aa969502.aspx +type DWM_THUMBNAIL_PROPERTIES struct { + dwFlags uint32 + rcDestination RECT + rcSource RECT + opacity byte + fVisible BOOL + fSourceClientAreaOnly BOOL +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/aa969503.aspx +type DWM_TIMING_INFO struct { + cbSize uint32 + rateRefresh UNSIGNED_RATIO + qpcRefreshPeriod QPC_TIME + rateCompose UNSIGNED_RATIO + qpcVBlank QPC_TIME + cRefresh DWM_FRAME_COUNT + cDXRefresh uint32 + qpcCompose QPC_TIME + cFrame DWM_FRAME_COUNT + cDXPresent uint32 + cRefreshFrame DWM_FRAME_COUNT + cFrameSubmitted DWM_FRAME_COUNT + cDXPresentSubmitted uint32 + cFrameConfirmed DWM_FRAME_COUNT + cDXPresentConfirmed uint32 + cRefreshConfirmed DWM_FRAME_COUNT + cDXRefreshConfirmed uint32 + cFramesLate DWM_FRAME_COUNT + cFramesOutstanding uint32 + cFrameDisplayed DWM_FRAME_COUNT + qpcFrameDisplayed QPC_TIME + cRefreshFrameDisplayed DWM_FRAME_COUNT + cFrameComplete DWM_FRAME_COUNT + qpcFrameComplete QPC_TIME + cFramePending DWM_FRAME_COUNT + qpcFramePending QPC_TIME + cFramesDisplayed DWM_FRAME_COUNT + cFramesComplete DWM_FRAME_COUNT + cFramesPending DWM_FRAME_COUNT + cFramesAvailable DWM_FRAME_COUNT + cFramesDropped DWM_FRAME_COUNT + cFramesMissed DWM_FRAME_COUNT + cRefreshNextDisplayed DWM_FRAME_COUNT + cRefreshNextPresented DWM_FRAME_COUNT + cRefreshesDisplayed DWM_FRAME_COUNT + cRefreshesPresented DWM_FRAME_COUNT + cRefreshStarted DWM_FRAME_COUNT + cPixelsReceived uint64 + cPixelsDrawn uint64 + cBuffersEmpty DWM_FRAME_COUNT +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/dd389402.aspx +type MilMatrix3x2D struct { + S_11, S_12, S_21, S_22 float64 + DX, DY float64 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/aa969505.aspx +type UNSIGNED_RATIO struct { + uiNumerator uint32 + uiDenominator uint32 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/ms632603.aspx +type CREATESTRUCT struct { + CreateParams uintptr + Instance HINSTANCE + Menu HMENU + Parent HWND + Cy, Cx int32 + Y, X int32 + Style int32 + Name *uint16 + Class *uint16 + dwExStyle uint32 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/dd145065.aspx +type MONITORINFO struct { + CbSize uint32 + RcMonitor RECT + RcWork RECT + DwFlags uint32 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/dd145066.aspx +type MONITORINFOEX struct { + MONITORINFO + SzDevice [CCHDEVICENAME]uint16 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/dd368826.aspx +type PIXELFORMATDESCRIPTOR struct { + Size uint16 + Version uint16 + DwFlags uint32 + IPixelType byte + ColorBits byte + RedBits, RedShift byte + GreenBits, GreenShift byte + BlueBits, BlueShift byte + AlphaBits, AlphaShift byte + AccumBits byte + AccumRedBits byte + AccumGreenBits byte + AccumBlueBits byte + AccumAlphaBits byte + DepthBits, StencilBits byte + AuxBuffers byte + ILayerType byte + Reserved byte + DwLayerMask uint32 + DwVisibleMask uint32 + DwDamageMask uint32 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/ms646270(v=vs.85).aspx +type INPUT struct { + Type uint32 + Mi MOUSEINPUT + Ki KEYBDINPUT + Hi HARDWAREINPUT +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/ms646273(v=vs.85).aspx +type MOUSEINPUT struct { + Dx int32 + Dy int32 + MouseData uint32 + DwFlags uint32 + Time uint32 + DwExtraInfo uintptr +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/ms646271(v=vs.85).aspx +type KEYBDINPUT struct { + WVk uint16 + WScan uint16 + DwFlags uint32 + Time uint32 + DwExtraInfo uintptr +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/ms646269(v=vs.85).aspx +type HARDWAREINPUT struct { + UMsg uint32 + WParamL uint16 + WParamH uint16 +} + +type KbdInput struct { + typ uint32 + ki KEYBDINPUT +} + +type MouseInput struct { + typ uint32 + mi MOUSEINPUT +} + +type HardwareInput struct { + typ uint32 + hi HARDWAREINPUT +} diff --git a/Godeps/_workspace/src/github.com/shirou/w32/user32.go b/Godeps/_workspace/src/github.com/shirou/w32/user32.go new file mode 100644 index 0000000000..44b87726d1 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/w32/user32.go @@ -0,0 +1,948 @@ +// Copyright 2010-2012 The W32 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 w32 + +import ( + "fmt" + "syscall" + "unsafe" +) + +var ( + moduser32 = syscall.NewLazyDLL("user32.dll") + + procRegisterClassEx = moduser32.NewProc("RegisterClassExW") + procLoadIcon = moduser32.NewProc("LoadIconW") + procLoadCursor = moduser32.NewProc("LoadCursorW") + procShowWindow = moduser32.NewProc("ShowWindow") + procUpdateWindow = moduser32.NewProc("UpdateWindow") + procCreateWindowEx = moduser32.NewProc("CreateWindowExW") + procAdjustWindowRect = moduser32.NewProc("AdjustWindowRect") + procAdjustWindowRectEx = moduser32.NewProc("AdjustWindowRectEx") + procDestroyWindow = moduser32.NewProc("DestroyWindow") + procDefWindowProc = moduser32.NewProc("DefWindowProcW") + procDefDlgProc = moduser32.NewProc("DefDlgProcW") + procPostQuitMessage = moduser32.NewProc("PostQuitMessage") + procGetMessage = moduser32.NewProc("GetMessageW") + procTranslateMessage = moduser32.NewProc("TranslateMessage") + procDispatchMessage = moduser32.NewProc("DispatchMessageW") + procSendMessage = moduser32.NewProc("SendMessageW") + procPostMessage = moduser32.NewProc("PostMessageW") + procWaitMessage = moduser32.NewProc("WaitMessage") + procSetWindowText = moduser32.NewProc("SetWindowTextW") + procGetWindowTextLength = moduser32.NewProc("GetWindowTextLengthW") + procGetWindowText = moduser32.NewProc("GetWindowTextW") + procGetWindowRect = moduser32.NewProc("GetWindowRect") + procMoveWindow = moduser32.NewProc("MoveWindow") + procScreenToClient = moduser32.NewProc("ScreenToClient") + procCallWindowProc = moduser32.NewProc("CallWindowProcW") + procSetWindowLong = moduser32.NewProc("SetWindowLongW") + procSetWindowLongPtr = moduser32.NewProc("SetWindowLongW") + procGetWindowLong = moduser32.NewProc("GetWindowLongW") + procGetWindowLongPtr = moduser32.NewProc("GetWindowLongW") + procEnableWindow = moduser32.NewProc("EnableWindow") + procIsWindowEnabled = moduser32.NewProc("IsWindowEnabled") + procIsWindowVisible = moduser32.NewProc("IsWindowVisible") + procSetFocus = moduser32.NewProc("SetFocus") + procInvalidateRect = moduser32.NewProc("InvalidateRect") + procGetClientRect = moduser32.NewProc("GetClientRect") + procGetDC = moduser32.NewProc("GetDC") + procReleaseDC = moduser32.NewProc("ReleaseDC") + procSetCapture = moduser32.NewProc("SetCapture") + procReleaseCapture = moduser32.NewProc("ReleaseCapture") + procGetWindowThreadProcessId = moduser32.NewProc("GetWindowThreadProcessId") + procMessageBox = moduser32.NewProc("MessageBoxW") + procGetSystemMetrics = moduser32.NewProc("GetSystemMetrics") + procCopyRect = moduser32.NewProc("CopyRect") + procEqualRect = moduser32.NewProc("EqualRect") + procInflateRect = moduser32.NewProc("InflateRect") + procIntersectRect = moduser32.NewProc("IntersectRect") + procIsRectEmpty = moduser32.NewProc("IsRectEmpty") + procOffsetRect = moduser32.NewProc("OffsetRect") + procPtInRect = moduser32.NewProc("PtInRect") + procSetRect = moduser32.NewProc("SetRect") + procSetRectEmpty = moduser32.NewProc("SetRectEmpty") + procSubtractRect = moduser32.NewProc("SubtractRect") + procUnionRect = moduser32.NewProc("UnionRect") + procCreateDialogParam = moduser32.NewProc("CreateDialogParamW") + procDialogBoxParam = moduser32.NewProc("DialogBoxParamW") + procGetDlgItem = moduser32.NewProc("GetDlgItem") + procDrawIcon = moduser32.NewProc("DrawIcon") + procClientToScreen = moduser32.NewProc("ClientToScreen") + procIsDialogMessage = moduser32.NewProc("IsDialogMessageW") + procIsWindow = moduser32.NewProc("IsWindow") + procEndDialog = moduser32.NewProc("EndDialog") + procPeekMessage = moduser32.NewProc("PeekMessageW") + procTranslateAccelerator = moduser32.NewProc("TranslateAcceleratorW") + procSetWindowPos = moduser32.NewProc("SetWindowPos") + procFillRect = moduser32.NewProc("FillRect") + procDrawText = moduser32.NewProc("DrawTextW") + procAddClipboardFormatListener = moduser32.NewProc("AddClipboardFormatListener") + procRemoveClipboardFormatListener = moduser32.NewProc("RemoveClipboardFormatListener") + procOpenClipboard = moduser32.NewProc("OpenClipboard") + procCloseClipboard = moduser32.NewProc("CloseClipboard") + procEnumClipboardFormats = moduser32.NewProc("EnumClipboardFormats") + procGetClipboardData = moduser32.NewProc("GetClipboardData") + procSetClipboardData = moduser32.NewProc("SetClipboardData") + procEmptyClipboard = moduser32.NewProc("EmptyClipboard") + procGetClipboardFormatName = moduser32.NewProc("GetClipboardFormatNameW") + procIsClipboardFormatAvailable = moduser32.NewProc("IsClipboardFormatAvailable") + procBeginPaint = moduser32.NewProc("BeginPaint") + procEndPaint = moduser32.NewProc("EndPaint") + procGetKeyboardState = moduser32.NewProc("GetKeyboardState") + procMapVirtualKey = moduser32.NewProc("MapVirtualKeyExW") + procGetAsyncKeyState = moduser32.NewProc("GetAsyncKeyState") + procToAscii = moduser32.NewProc("ToAscii") + procSwapMouseButton = moduser32.NewProc("SwapMouseButton") + procGetCursorPos = moduser32.NewProc("GetCursorPos") + procSetCursorPos = moduser32.NewProc("SetCursorPos") + procSetCursor = moduser32.NewProc("SetCursor") + procCreateIcon = moduser32.NewProc("CreateIcon") + procDestroyIcon = moduser32.NewProc("DestroyIcon") + procMonitorFromPoint = moduser32.NewProc("MonitorFromPoint") + procMonitorFromRect = moduser32.NewProc("MonitorFromRect") + procMonitorFromWindow = moduser32.NewProc("MonitorFromWindow") + procGetMonitorInfo = moduser32.NewProc("GetMonitorInfoW") + procEnumDisplayMonitors = moduser32.NewProc("EnumDisplayMonitors") + procEnumDisplaySettingsEx = moduser32.NewProc("EnumDisplaySettingsExW") + procChangeDisplaySettingsEx = moduser32.NewProc("ChangeDisplaySettingsExW") + procSendInput = moduser32.NewProc("SendInput") +) + +func RegisterClassEx(wndClassEx *WNDCLASSEX) ATOM { + ret, _, _ := procRegisterClassEx.Call(uintptr(unsafe.Pointer(wndClassEx))) + return ATOM(ret) +} + +func LoadIcon(instance HINSTANCE, iconName *uint16) HICON { + ret, _, _ := procLoadIcon.Call( + uintptr(instance), + uintptr(unsafe.Pointer(iconName))) + + return HICON(ret) + +} + +func LoadCursor(instance HINSTANCE, cursorName *uint16) HCURSOR { + ret, _, _ := procLoadCursor.Call( + uintptr(instance), + uintptr(unsafe.Pointer(cursorName))) + + return HCURSOR(ret) + +} + +func ShowWindow(hwnd HWND, cmdshow int) bool { + ret, _, _ := procShowWindow.Call( + uintptr(hwnd), + uintptr(cmdshow)) + + return ret != 0 + +} + +func UpdateWindow(hwnd HWND) bool { + ret, _, _ := procUpdateWindow.Call( + uintptr(hwnd)) + return ret != 0 +} + +func CreateWindowEx(exStyle uint, className, windowName *uint16, + style uint, x, y, width, height int, parent HWND, menu HMENU, + instance HINSTANCE, param unsafe.Pointer) HWND { + ret, _, _ := procCreateWindowEx.Call( + uintptr(exStyle), + uintptr(unsafe.Pointer(className)), + uintptr(unsafe.Pointer(windowName)), + uintptr(style), + uintptr(x), + uintptr(y), + uintptr(width), + uintptr(height), + uintptr(parent), + uintptr(menu), + uintptr(instance), + uintptr(param)) + + return HWND(ret) +} + +func AdjustWindowRectEx(rect *RECT, style uint, menu bool, exStyle uint) bool { + ret, _, _ := procAdjustWindowRectEx.Call( + uintptr(unsafe.Pointer(rect)), + uintptr(style), + uintptr(BoolToBOOL(menu)), + uintptr(exStyle)) + + return ret != 0 +} + +func AdjustWindowRect(rect *RECT, style uint, menu bool) bool { + ret, _, _ := procAdjustWindowRect.Call( + uintptr(unsafe.Pointer(rect)), + uintptr(style), + uintptr(BoolToBOOL(menu))) + + return ret != 0 +} + +func DestroyWindow(hwnd HWND) bool { + ret, _, _ := procDestroyWindow.Call( + uintptr(hwnd)) + + return ret != 0 +} + +func DefWindowProc(hwnd HWND, msg uint32, wParam, lParam uintptr) uintptr { + ret, _, _ := procDefWindowProc.Call( + uintptr(hwnd), + uintptr(msg), + wParam, + lParam) + + return ret +} + +func DefDlgProc(hwnd HWND, msg uint32, wParam, lParam uintptr) uintptr { + ret, _, _ := procDefDlgProc.Call( + uintptr(hwnd), + uintptr(msg), + wParam, + lParam) + + return ret +} + +func PostQuitMessage(exitCode int) { + procPostQuitMessage.Call( + uintptr(exitCode)) +} + +func GetMessage(msg *MSG, hwnd HWND, msgFilterMin, msgFilterMax uint32) int { + ret, _, _ := procGetMessage.Call( + uintptr(unsafe.Pointer(msg)), + uintptr(hwnd), + uintptr(msgFilterMin), + uintptr(msgFilterMax)) + + return int(ret) +} + +func TranslateMessage(msg *MSG) bool { + ret, _, _ := procTranslateMessage.Call( + uintptr(unsafe.Pointer(msg))) + + return ret != 0 + +} + +func DispatchMessage(msg *MSG) uintptr { + ret, _, _ := procDispatchMessage.Call( + uintptr(unsafe.Pointer(msg))) + + return ret + +} + +func SendMessage(hwnd HWND, msg uint32, wParam, lParam uintptr) uintptr { + ret, _, _ := procSendMessage.Call( + uintptr(hwnd), + uintptr(msg), + wParam, + lParam) + + return ret +} + +func PostMessage(hwnd HWND, msg uint32, wParam, lParam uintptr) bool { + ret, _, _ := procPostMessage.Call( + uintptr(hwnd), + uintptr(msg), + wParam, + lParam) + + return ret != 0 +} + +func WaitMessage() bool { + ret, _, _ := procWaitMessage.Call() + return ret != 0 +} + +func SetWindowText(hwnd HWND, text string) { + procSetWindowText.Call( + uintptr(hwnd), + uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(text)))) +} + +func GetWindowTextLength(hwnd HWND) int { + ret, _, _ := procGetWindowTextLength.Call( + uintptr(hwnd)) + + return int(ret) +} + +func GetWindowText(hwnd HWND) string { + textLen := GetWindowTextLength(hwnd) + 1 + + buf := make([]uint16, textLen) + procGetWindowText.Call( + uintptr(hwnd), + uintptr(unsafe.Pointer(&buf[0])), + uintptr(textLen)) + + return syscall.UTF16ToString(buf) +} + +func GetWindowRect(hwnd HWND) *RECT { + var rect RECT + procGetWindowRect.Call( + uintptr(hwnd), + uintptr(unsafe.Pointer(&rect))) + + return &rect +} + +func MoveWindow(hwnd HWND, x, y, width, height int, repaint bool) bool { + ret, _, _ := procMoveWindow.Call( + uintptr(hwnd), + uintptr(x), + uintptr(y), + uintptr(width), + uintptr(height), + uintptr(BoolToBOOL(repaint))) + + return ret != 0 + +} + +func ScreenToClient(hwnd HWND, x, y int) (X, Y int, ok bool) { + pt := POINT{X: int32(x), Y: int32(y)} + ret, _, _ := procScreenToClient.Call( + uintptr(hwnd), + uintptr(unsafe.Pointer(&pt))) + + return int(pt.X), int(pt.Y), ret != 0 +} + +func CallWindowProc(preWndProc uintptr, hwnd HWND, msg uint32, wParam, lParam uintptr) uintptr { + ret, _, _ := procCallWindowProc.Call( + preWndProc, + uintptr(hwnd), + uintptr(msg), + wParam, + lParam) + + return ret +} + +func SetWindowLong(hwnd HWND, index int, value uint32) uint32 { + ret, _, _ := procSetWindowLong.Call( + uintptr(hwnd), + uintptr(index), + uintptr(value)) + + return uint32(ret) +} + +func SetWindowLongPtr(hwnd HWND, index int, value uintptr) uintptr { + ret, _, _ := procSetWindowLongPtr.Call( + uintptr(hwnd), + uintptr(index), + value) + + return ret +} + +func GetWindowLong(hwnd HWND, index int) int32 { + ret, _, _ := procGetWindowLong.Call( + uintptr(hwnd), + uintptr(index)) + + return int32(ret) +} + +func GetWindowLongPtr(hwnd HWND, index int) uintptr { + ret, _, _ := procGetWindowLongPtr.Call( + uintptr(hwnd), + uintptr(index)) + + return ret +} + +func EnableWindow(hwnd HWND, b bool) bool { + ret, _, _ := procEnableWindow.Call( + uintptr(hwnd), + uintptr(BoolToBOOL(b))) + return ret != 0 +} + +func IsWindowEnabled(hwnd HWND) bool { + ret, _, _ := procIsWindowEnabled.Call( + uintptr(hwnd)) + + return ret != 0 +} + +func IsWindowVisible(hwnd HWND) bool { + ret, _, _ := procIsWindowVisible.Call( + uintptr(hwnd)) + + return ret != 0 +} + +func SetFocus(hwnd HWND) HWND { + ret, _, _ := procSetFocus.Call( + uintptr(hwnd)) + + return HWND(ret) +} + +func InvalidateRect(hwnd HWND, rect *RECT, erase bool) bool { + ret, _, _ := procInvalidateRect.Call( + uintptr(hwnd), + uintptr(unsafe.Pointer(rect)), + uintptr(BoolToBOOL(erase))) + + return ret != 0 +} + +func GetClientRect(hwnd HWND) *RECT { + var rect RECT + ret, _, _ := procGetClientRect.Call( + uintptr(hwnd), + uintptr(unsafe.Pointer(&rect))) + + if ret == 0 { + panic(fmt.Sprintf("GetClientRect(%d) failed", hwnd)) + } + + return &rect +} + +func GetDC(hwnd HWND) HDC { + ret, _, _ := procGetDC.Call( + uintptr(hwnd)) + + return HDC(ret) +} + +func ReleaseDC(hwnd HWND, hDC HDC) bool { + ret, _, _ := procReleaseDC.Call( + uintptr(hwnd), + uintptr(hDC)) + + return ret != 0 +} + +func SetCapture(hwnd HWND) HWND { + ret, _, _ := procSetCapture.Call( + uintptr(hwnd)) + + return HWND(ret) +} + +func ReleaseCapture() bool { + ret, _, _ := procReleaseCapture.Call() + + return ret != 0 +} + +func GetWindowThreadProcessId(hwnd HWND) (HANDLE, int) { + var processId int + ret, _, _ := procGetWindowThreadProcessId.Call( + uintptr(hwnd), + uintptr(unsafe.Pointer(&processId))) + + return HANDLE(ret), processId +} + +func MessageBox(hwnd HWND, title, caption string, flags uint) int { + ret, _, _ := procMessageBox.Call( + uintptr(hwnd), + uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(title))), + uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(caption))), + uintptr(flags)) + + return int(ret) +} + +func GetSystemMetrics(index int) int { + ret, _, _ := procGetSystemMetrics.Call( + uintptr(index)) + + return int(ret) +} + +func CopyRect(dst, src *RECT) bool { + ret, _, _ := procCopyRect.Call( + uintptr(unsafe.Pointer(dst)), + uintptr(unsafe.Pointer(src))) + + return ret != 0 +} + +func EqualRect(rect1, rect2 *RECT) bool { + ret, _, _ := procEqualRect.Call( + uintptr(unsafe.Pointer(rect1)), + uintptr(unsafe.Pointer(rect2))) + + return ret != 0 +} + +func InflateRect(rect *RECT, dx, dy int) bool { + ret, _, _ := procInflateRect.Call( + uintptr(unsafe.Pointer(rect)), + uintptr(dx), + uintptr(dy)) + + return ret != 0 +} + +func IntersectRect(dst, src1, src2 *RECT) bool { + ret, _, _ := procIntersectRect.Call( + uintptr(unsafe.Pointer(dst)), + uintptr(unsafe.Pointer(src1)), + uintptr(unsafe.Pointer(src2))) + + return ret != 0 +} + +func IsRectEmpty(rect *RECT) bool { + ret, _, _ := procIsRectEmpty.Call( + uintptr(unsafe.Pointer(rect))) + + return ret != 0 +} + +func OffsetRect(rect *RECT, dx, dy int) bool { + ret, _, _ := procOffsetRect.Call( + uintptr(unsafe.Pointer(rect)), + uintptr(dx), + uintptr(dy)) + + return ret != 0 +} + +func PtInRect(rect *RECT, x, y int) bool { + pt := POINT{X: int32(x), Y: int32(y)} + ret, _, _ := procPtInRect.Call( + uintptr(unsafe.Pointer(rect)), + uintptr(unsafe.Pointer(&pt))) + + return ret != 0 +} + +func SetRect(rect *RECT, left, top, right, bottom int) bool { + ret, _, _ := procSetRect.Call( + uintptr(unsafe.Pointer(rect)), + uintptr(left), + uintptr(top), + uintptr(right), + uintptr(bottom)) + + return ret != 0 +} + +func SetRectEmpty(rect *RECT) bool { + ret, _, _ := procSetRectEmpty.Call( + uintptr(unsafe.Pointer(rect))) + + return ret != 0 +} + +func SubtractRect(dst, src1, src2 *RECT) bool { + ret, _, _ := procSubtractRect.Call( + uintptr(unsafe.Pointer(dst)), + uintptr(unsafe.Pointer(src1)), + uintptr(unsafe.Pointer(src2))) + + return ret != 0 +} + +func UnionRect(dst, src1, src2 *RECT) bool { + ret, _, _ := procUnionRect.Call( + uintptr(unsafe.Pointer(dst)), + uintptr(unsafe.Pointer(src1)), + uintptr(unsafe.Pointer(src2))) + + return ret != 0 +} + +func CreateDialog(hInstance HINSTANCE, lpTemplate *uint16, hWndParent HWND, lpDialogProc uintptr) HWND { + ret, _, _ := procCreateDialogParam.Call( + uintptr(hInstance), + uintptr(unsafe.Pointer(lpTemplate)), + uintptr(hWndParent), + lpDialogProc, + 0) + + return HWND(ret) +} + +func DialogBox(hInstance HINSTANCE, lpTemplateName *uint16, hWndParent HWND, lpDialogProc uintptr) int { + ret, _, _ := procDialogBoxParam.Call( + uintptr(hInstance), + uintptr(unsafe.Pointer(lpTemplateName)), + uintptr(hWndParent), + lpDialogProc, + 0) + + return int(ret) +} + +func GetDlgItem(hDlg HWND, nIDDlgItem int) HWND { + ret, _, _ := procGetDlgItem.Call( + uintptr(unsafe.Pointer(hDlg)), + uintptr(nIDDlgItem)) + + return HWND(ret) +} + +func DrawIcon(hDC HDC, x, y int, hIcon HICON) bool { + ret, _, _ := procDrawIcon.Call( + uintptr(unsafe.Pointer(hDC)), + uintptr(x), + uintptr(y), + uintptr(unsafe.Pointer(hIcon))) + + return ret != 0 +} + +func ClientToScreen(hwnd HWND, x, y int) (int, int) { + pt := POINT{X: int32(x), Y: int32(y)} + + procClientToScreen.Call( + uintptr(hwnd), + uintptr(unsafe.Pointer(&pt))) + + return int(pt.X), int(pt.Y) +} + +func IsDialogMessage(hwnd HWND, msg *MSG) bool { + ret, _, _ := procIsDialogMessage.Call( + uintptr(hwnd), + uintptr(unsafe.Pointer(msg))) + + return ret != 0 +} + +func IsWindow(hwnd HWND) bool { + ret, _, _ := procIsWindow.Call( + uintptr(hwnd)) + + return ret != 0 +} + +func EndDialog(hwnd HWND, nResult uintptr) bool { + ret, _, _ := procEndDialog.Call( + uintptr(hwnd), + nResult) + + return ret != 0 +} + +func PeekMessage(lpMsg *MSG, hwnd HWND, wMsgFilterMin, wMsgFilterMax, wRemoveMsg uint32) bool { + ret, _, _ := procPeekMessage.Call( + uintptr(unsafe.Pointer(lpMsg)), + uintptr(hwnd), + uintptr(wMsgFilterMin), + uintptr(wMsgFilterMax), + uintptr(wRemoveMsg)) + + return ret != 0 +} + +func TranslateAccelerator(hwnd HWND, hAccTable HACCEL, lpMsg *MSG) bool { + ret, _, _ := procTranslateMessage.Call( + uintptr(hwnd), + uintptr(hAccTable), + uintptr(unsafe.Pointer(lpMsg))) + + return ret != 0 +} + +func SetWindowPos(hwnd, hWndInsertAfter HWND, x, y, cx, cy int, uFlags uint) bool { + ret, _, _ := procSetWindowPos.Call( + uintptr(hwnd), + uintptr(hWndInsertAfter), + uintptr(x), + uintptr(y), + uintptr(cx), + uintptr(cy), + uintptr(uFlags)) + + return ret != 0 +} + +func FillRect(hDC HDC, lprc *RECT, hbr HBRUSH) bool { + ret, _, _ := procFillRect.Call( + uintptr(hDC), + uintptr(unsafe.Pointer(lprc)), + uintptr(hbr)) + + return ret != 0 +} + +func DrawText(hDC HDC, text string, uCount int, lpRect *RECT, uFormat uint) int { + ret, _, _ := procDrawText.Call( + uintptr(hDC), + uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(text))), + uintptr(uCount), + uintptr(unsafe.Pointer(lpRect)), + uintptr(uFormat)) + + return int(ret) +} + +func AddClipboardFormatListener(hwnd HWND) bool { + ret, _, _ := procAddClipboardFormatListener.Call( + uintptr(hwnd)) + return ret != 0 +} + +func RemoveClipboardFormatListener(hwnd HWND) bool { + ret, _, _ := procRemoveClipboardFormatListener.Call( + uintptr(hwnd)) + return ret != 0 +} + +func OpenClipboard(hWndNewOwner HWND) bool { + ret, _, _ := procOpenClipboard.Call( + uintptr(hWndNewOwner)) + return ret != 0 +} + +func CloseClipboard() bool { + ret, _, _ := procCloseClipboard.Call() + return ret != 0 +} + +func EnumClipboardFormats(format uint) uint { + ret, _, _ := procEnumClipboardFormats.Call( + uintptr(format)) + return uint(ret) +} + +func GetClipboardData(uFormat uint) HANDLE { + ret, _, _ := procGetClipboardData.Call( + uintptr(uFormat)) + return HANDLE(ret) +} + +func SetClipboardData(uFormat uint, hMem HANDLE) HANDLE { + ret, _, _ := procSetClipboardData.Call( + uintptr(uFormat), + uintptr(hMem)) + return HANDLE(ret) +} + +func EmptyClipboard() bool { + ret, _, _ := procEmptyClipboard.Call() + return ret != 0 +} + +func GetClipboardFormatName(format uint) (string, bool) { + cchMaxCount := 255 + buf := make([]uint16, cchMaxCount) + ret, _, _ := procGetClipboardFormatName.Call( + uintptr(format), + uintptr(unsafe.Pointer(&buf[0])), + uintptr(cchMaxCount)) + + if ret > 0 { + return syscall.UTF16ToString(buf), true + } + + return "Requested format does not exist or is predefined", false +} + +func IsClipboardFormatAvailable(format uint) bool { + ret, _, _ := procIsClipboardFormatAvailable.Call(uintptr(format)) + return ret != 0 +} + +func BeginPaint(hwnd HWND, paint *PAINTSTRUCT) HDC { + ret, _, _ := procBeginPaint.Call( + uintptr(hwnd), + uintptr(unsafe.Pointer(paint))) + return HDC(ret) +} + +func EndPaint(hwnd HWND, paint *PAINTSTRUCT) { + procBeginPaint.Call( + uintptr(hwnd), + uintptr(unsafe.Pointer(paint))) +} + +func GetKeyboardState(lpKeyState *[]byte) bool { + ret, _, _ := procGetKeyboardState.Call( + uintptr(unsafe.Pointer(&(*lpKeyState)[0]))) + return ret != 0 +} + +func MapVirtualKeyEx(uCode, uMapType uint, dwhkl HKL) uint { + ret, _, _ := procMapVirtualKey.Call( + uintptr(uCode), + uintptr(uMapType), + uintptr(dwhkl)) + return uint(ret) +} + +func GetAsyncKeyState(vKey int) uint16 { + ret, _, _ := procGetAsyncKeyState.Call(uintptr(vKey)) + return uint16(ret) +} + +func ToAscii(uVirtKey, uScanCode uint, lpKeyState *byte, lpChar *uint16, uFlags uint) int { + ret, _, _ := procToAscii.Call( + uintptr(uVirtKey), + uintptr(uScanCode), + uintptr(unsafe.Pointer(lpKeyState)), + uintptr(unsafe.Pointer(lpChar)), + uintptr(uFlags)) + return int(ret) +} + +func SwapMouseButton(fSwap bool) bool { + ret, _, _ := procSwapMouseButton.Call( + uintptr(BoolToBOOL(fSwap))) + return ret != 0 +} + +func GetCursorPos() (x, y int, ok bool) { + pt := POINT{} + ret, _, _ := procGetCursorPos.Call(uintptr(unsafe.Pointer(&pt))) + return int(pt.X), int(pt.Y), ret != 0 +} + +func SetCursorPos(x, y int) bool { + ret, _, _ := procSetCursorPos.Call( + uintptr(x), + uintptr(y), + ) + return ret != 0 +} + +func SetCursor(cursor HCURSOR) HCURSOR { + ret, _, _ := procSetCursor.Call( + uintptr(cursor), + ) + return HCURSOR(ret) +} + +func CreateIcon(instance HINSTANCE, nWidth, nHeight int, cPlanes, cBitsPerPixel byte, ANDbits, XORbits *byte) HICON { + ret, _, _ := procCreateIcon.Call( + uintptr(instance), + uintptr(nWidth), + uintptr(nHeight), + uintptr(cPlanes), + uintptr(cBitsPerPixel), + uintptr(unsafe.Pointer(ANDbits)), + uintptr(unsafe.Pointer(XORbits)), + ) + return HICON(ret) +} + +func DestroyIcon(icon HICON) bool { + ret, _, _ := procDestroyIcon.Call( + uintptr(icon), + ) + return ret != 0 +} + +func MonitorFromPoint(x, y int, dwFlags uint32) HMONITOR { + ret, _, _ := procMonitorFromPoint.Call( + uintptr(x), + uintptr(y), + uintptr(dwFlags), + ) + return HMONITOR(ret) +} + +func MonitorFromRect(rc *RECT, dwFlags uint32) HMONITOR { + ret, _, _ := procMonitorFromRect.Call( + uintptr(unsafe.Pointer(rc)), + uintptr(dwFlags), + ) + return HMONITOR(ret) +} + +func MonitorFromWindow(hwnd HWND, dwFlags uint32) HMONITOR { + ret, _, _ := procMonitorFromWindow.Call( + uintptr(hwnd), + uintptr(dwFlags), + ) + return HMONITOR(ret) +} + +func GetMonitorInfo(hMonitor HMONITOR, lmpi *MONITORINFO) bool { + ret, _, _ := procGetMonitorInfo.Call( + uintptr(hMonitor), + uintptr(unsafe.Pointer(lmpi)), + ) + return ret != 0 +} + +func EnumDisplayMonitors(hdc HDC, clip *RECT, fnEnum, dwData uintptr) bool { + ret, _, _ := procEnumDisplayMonitors.Call( + uintptr(hdc), + uintptr(unsafe.Pointer(clip)), + fnEnum, + dwData, + ) + return ret != 0 +} + +func EnumDisplaySettingsEx(szDeviceName *uint16, iModeNum uint32, devMode *DEVMODE, dwFlags uint32) bool { + ret, _, _ := procEnumDisplaySettingsEx.Call( + uintptr(unsafe.Pointer(szDeviceName)), + uintptr(iModeNum), + uintptr(unsafe.Pointer(devMode)), + uintptr(dwFlags), + ) + return ret != 0 +} + +func ChangeDisplaySettingsEx(szDeviceName *uint16, devMode *DEVMODE, hwnd HWND, dwFlags uint32, lParam uintptr) int32 { + ret, _, _ := procChangeDisplaySettingsEx.Call( + uintptr(unsafe.Pointer(szDeviceName)), + uintptr(unsafe.Pointer(devMode)), + uintptr(hwnd), + uintptr(dwFlags), + lParam, + ) + return int32(ret) +} + +/* remove to build without cgo +func SendInput(inputs []INPUT) uint32 { + var validInputs []C.INPUT + + for _, oneInput := range inputs { + input := C.INPUT{_type: C.DWORD(oneInput.Type)} + + switch oneInput.Type { + case INPUT_MOUSE: + (*MouseInput)(unsafe.Pointer(&input)).mi = oneInput.Mi + case INPUT_KEYBOARD: + (*KbdInput)(unsafe.Pointer(&input)).ki = oneInput.Ki + case INPUT_HARDWARE: + (*HardwareInput)(unsafe.Pointer(&input)).hi = oneInput.Hi + default: + panic("unkown type") + } + + validInputs = append(validInputs, input) + } + + ret, _, _ := procSendInput.Call( + uintptr(len(validInputs)), + uintptr(unsafe.Pointer(&validInputs[0])), + uintptr(unsafe.Sizeof(C.INPUT{})), + ) + return uint32(ret) +} +*/ diff --git a/Godeps/_workspace/src/github.com/shirou/w32/utils.go b/Godeps/_workspace/src/github.com/shirou/w32/utils.go new file mode 100644 index 0000000000..4fb5b6c2c1 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/w32/utils.go @@ -0,0 +1,201 @@ +// Copyright 2010-2012 The W32 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 w32 + +import ( + "syscall" + "unicode/utf16" + "unsafe" +) + +func MakeIntResource(id uint16) *uint16 { + return (*uint16)(unsafe.Pointer(uintptr(id))) +} + +func LOWORD(dw uint32) uint16 { + return uint16(dw) +} + +func HIWORD(dw uint32) uint16 { + return uint16(dw >> 16 & 0xffff) +} + +func BoolToBOOL(value bool) BOOL { + if value { + return 1 + } + + return 0 +} + +func UTF16PtrToString(cstr *uint16) string { + if cstr != nil { + us := make([]uint16, 0, 256) + for p := uintptr(unsafe.Pointer(cstr)); ; p += 2 { + u := *(*uint16)(unsafe.Pointer(p)) + if u == 0 { + return string(utf16.Decode(us)) + } + us = append(us, u) + } + } + + return "" +} + +func ComAddRef(unknown *IUnknown) int32 { + ret, _, _ := syscall.Syscall(unknown.lpVtbl.pAddRef, 1, + uintptr(unsafe.Pointer(unknown)), + 0, + 0) + return int32(ret) +} + +func ComRelease(unknown *IUnknown) int32 { + ret, _, _ := syscall.Syscall(unknown.lpVtbl.pRelease, 1, + uintptr(unsafe.Pointer(unknown)), + 0, + 0) + return int32(ret) +} + +func ComQueryInterface(unknown *IUnknown, id *GUID) *IDispatch { + var disp *IDispatch + hr, _, _ := syscall.Syscall(unknown.lpVtbl.pQueryInterface, 3, + uintptr(unsafe.Pointer(unknown)), + uintptr(unsafe.Pointer(id)), + uintptr(unsafe.Pointer(&disp))) + if hr != 0 { + panic("Invoke QieryInterface error.") + } + return disp +} + +func ComGetIDsOfName(disp *IDispatch, names []string) []int32 { + wnames := make([]*uint16, len(names)) + dispid := make([]int32, len(names)) + for i := 0; i < len(names); i++ { + wnames[i] = syscall.StringToUTF16Ptr(names[i]) + } + hr, _, _ := syscall.Syscall6(disp.lpVtbl.pGetIDsOfNames, 6, + uintptr(unsafe.Pointer(disp)), + uintptr(unsafe.Pointer(IID_NULL)), + uintptr(unsafe.Pointer(&wnames[0])), + uintptr(len(names)), + uintptr(GetUserDefaultLCID()), + uintptr(unsafe.Pointer(&dispid[0]))) + if hr != 0 { + panic("Invoke GetIDsOfName error.") + } + return dispid +} + +func ComInvoke(disp *IDispatch, dispid int32, dispatch int16, params ...interface{}) (result *VARIANT) { + var dispparams DISPPARAMS + + if dispatch&DISPATCH_PROPERTYPUT != 0 { + dispnames := [1]int32{DISPID_PROPERTYPUT} + dispparams.RgdispidNamedArgs = uintptr(unsafe.Pointer(&dispnames[0])) + dispparams.CNamedArgs = 1 + } + var vargs []VARIANT + if len(params) > 0 { + vargs = make([]VARIANT, len(params)) + for i, v := range params { + //n := len(params)-i-1 + n := len(params) - i - 1 + VariantInit(&vargs[n]) + switch v.(type) { + case bool: + if v.(bool) { + vargs[n] = VARIANT{VT_BOOL, 0, 0, 0, 0xffff} + } else { + vargs[n] = VARIANT{VT_BOOL, 0, 0, 0, 0} + } + case *bool: + vargs[n] = VARIANT{VT_BOOL | VT_BYREF, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(*bool))))} + case byte: + vargs[n] = VARIANT{VT_I1, 0, 0, 0, int64(v.(byte))} + case *byte: + vargs[n] = VARIANT{VT_I1 | VT_BYREF, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(*byte))))} + case int16: + vargs[n] = VARIANT{VT_I2, 0, 0, 0, int64(v.(int16))} + case *int16: + vargs[n] = VARIANT{VT_I2 | VT_BYREF, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(*int16))))} + case uint16: + vargs[n] = VARIANT{VT_UI2, 0, 0, 0, int64(v.(int16))} + case *uint16: + vargs[n] = VARIANT{VT_UI2 | VT_BYREF, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(*uint16))))} + case int, int32: + vargs[n] = VARIANT{VT_UI4, 0, 0, 0, int64(v.(int))} + case *int, *int32: + vargs[n] = VARIANT{VT_I4 | VT_BYREF, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(*int))))} + case uint, uint32: + vargs[n] = VARIANT{VT_UI4, 0, 0, 0, int64(v.(uint))} + case *uint, *uint32: + vargs[n] = VARIANT{VT_UI4 | VT_BYREF, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(*uint))))} + case int64: + vargs[n] = VARIANT{VT_I8, 0, 0, 0, v.(int64)} + case *int64: + vargs[n] = VARIANT{VT_I8 | VT_BYREF, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(*int64))))} + case uint64: + vargs[n] = VARIANT{VT_UI8, 0, 0, 0, int64(v.(uint64))} + case *uint64: + vargs[n] = VARIANT{VT_UI8 | VT_BYREF, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(*uint64))))} + case float32: + vargs[n] = VARIANT{VT_R4, 0, 0, 0, int64(v.(float32))} + case *float32: + vargs[n] = VARIANT{VT_R4 | VT_BYREF, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(*float32))))} + case float64: + vargs[n] = VARIANT{VT_R8, 0, 0, 0, int64(v.(float64))} + case *float64: + vargs[n] = VARIANT{VT_R8 | VT_BYREF, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(*float64))))} + case string: + vargs[n] = VARIANT{VT_BSTR, 0, 0, 0, int64(uintptr(unsafe.Pointer(SysAllocString(v.(string)))))} + case *string: + vargs[n] = VARIANT{VT_BSTR | VT_BYREF, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(*string))))} + case *IDispatch: + vargs[n] = VARIANT{VT_DISPATCH, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(*IDispatch))))} + case **IDispatch: + vargs[n] = VARIANT{VT_DISPATCH | VT_BYREF, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(**IDispatch))))} + case nil: + vargs[n] = VARIANT{VT_NULL, 0, 0, 0, 0} + case *VARIANT: + vargs[n] = VARIANT{VT_VARIANT | VT_BYREF, 0, 0, 0, int64(uintptr(unsafe.Pointer(v.(*VARIANT))))} + default: + panic("unknown type") + } + } + dispparams.Rgvarg = uintptr(unsafe.Pointer(&vargs[0])) + dispparams.CArgs = uint32(len(params)) + } + + var ret VARIANT + var excepInfo EXCEPINFO + VariantInit(&ret) + hr, _, _ := syscall.Syscall9(disp.lpVtbl.pInvoke, 8, + uintptr(unsafe.Pointer(disp)), + uintptr(dispid), + uintptr(unsafe.Pointer(IID_NULL)), + uintptr(GetUserDefaultLCID()), + uintptr(dispatch), + uintptr(unsafe.Pointer(&dispparams)), + uintptr(unsafe.Pointer(&ret)), + uintptr(unsafe.Pointer(&excepInfo)), + 0) + if hr != 0 { + if excepInfo.BstrDescription != nil { + bs := UTF16PtrToString(excepInfo.BstrDescription) + panic(bs) + } + } + for _, varg := range vargs { + if varg.VT == VT_BSTR && varg.Val != 0 { + SysFreeString(((*int16)(unsafe.Pointer(uintptr(varg.Val))))) + } + } + result = &ret + return +} diff --git a/Godeps/_workspace/src/github.com/shirou/w32/vars.go b/Godeps/_workspace/src/github.com/shirou/w32/vars.go new file mode 100644 index 0000000000..2dab2e3963 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/w32/vars.go @@ -0,0 +1,13 @@ +// Copyright 2010-2012 The W32 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 w32 + +var ( + IID_NULL = &GUID{0x00000000, 0x0000, 0x0000, [8]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}} + IID_IUnknown = &GUID{0x00000000, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} + IID_IDispatch = &GUID{0x00020400, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} + IID_IConnectionPointContainer = &GUID{0xB196B284, 0xBAB4, 0x101A, [8]byte{0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07}} + IID_IConnectionPoint = &GUID{0xB196B286, 0xBAB4, 0x101A, [8]byte{0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07}} +) From 48040419bea380a47d1e01be1b6eea84777bd903 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Thu, 21 Apr 2016 09:59:44 +0200 Subject: [PATCH 0144/1304] contributing: shorten github issue template --- .github/ISSUE_TEMPLATE.md | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 44ab977c7f..36cd699078 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,18 +1,8 @@ -**rkt** +**Environment** -output of `rkt version` +Replace this with the output of: -**Kernel** - -output of `uname -srm` - -**Distribution** - -content of `/etc/os-release` - -**systemd** - -output of `systemctl --version` +`printf "$(rkt version)\n--\n$(uname -srm)\n--\n$(cat /etc/os-release)\n--\n$(systemctl --version)"` **What did you do?** From 9d62321ce365d07810de4db3037c61c9a5bff866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Fri, 8 Apr 2016 14:48:49 +0200 Subject: [PATCH 0145/1304] rkt/image: render images on fetch rkt was delaying rendering images to the tree store until they were about to run for the first time which caused that first run to be slow for big images. This commit renders the image to the tree store at fetch time. If the system doesn't support overlayfs, we don't render it because we don't use the tree store when overlayfs is not used. Startup time benchmark: rkt run a Docker nginx image, pre-fetched. Size = 188MiB when unextracted The insecure option `ondisk` was used. command | time (rkt master) | time (rkt master + https://github.com/coreos/rkt/pull/2398) --------|-------------------|--------------------------- 1st time run | real 0m4.964s, user 0m3.570s, sys 0m0.813s | real 0m0.333s, user 0m0.097s, sys 0m0.050s 2nd time run | real 0m0.350s, user 0m0.063s, sys 0m0.077s | real 0m0.343s, user 0m0.073s, sys 0m0.070s --- rkt/image/fetcher.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rkt/image/fetcher.go b/rkt/image/fetcher.go index 5a9026a1c6..7583e56863 100644 --- a/rkt/image/fetcher.go +++ b/rkt/image/fetcher.go @@ -16,10 +16,12 @@ package image import ( "container/list" + "errors" "fmt" "net/url" "runtime" + "github.com/coreos/rkt/common" "github.com/coreos/rkt/common/apps" "github.com/coreos/rkt/stage0" "github.com/coreos/rkt/store" @@ -50,6 +52,11 @@ func (f *Fetcher) FetchImage(img string, ascPath string, imgType apps.AppImageTy return "", err } } + if common.SupportsOverlay() { + if _, _, err := f.S.RenderTreeStore(hash, false); err != nil { + return "", errwrap.Wrap(errors.New("error rendering tree store"), err) + } + } return hash, nil } From 333b5ef7cc2aafa7ea6a7f7e391d42044c027374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Tue, 19 Apr 2016 14:34:25 +0200 Subject: [PATCH 0146/1304] functional tests: test render on fetch --- tests/rkt_image_dependencies_test.go | 107 +++++++++++++++++++++------ 1 file changed, 83 insertions(+), 24 deletions(-) diff --git a/tests/rkt_image_dependencies_test.go b/tests/rkt_image_dependencies_test.go index 2ac08805f7..11e1a2dcdb 100644 --- a/tests/rkt_image_dependencies_test.go +++ b/tests/rkt_image_dependencies_test.go @@ -18,9 +18,11 @@ import ( "fmt" "io/ioutil" "os" + "path/filepath" "strings" "testing" + "github.com/coreos/rkt/common" "github.com/coreos/rkt/tests/testutils" taas "github.com/coreos/rkt/tests/testutils/aci-server" ) @@ -62,20 +64,22 @@ const ( ` ) -// TestImageDependencies generates ACIs with a complex dependency tree and -// fetches them via the discovery mechanism. Some dependencies are already -// cached in the CAS, and some dependencies are fetched via the discovery -// mechanism. This is to reproduce the scenario in explained in: -// https://github.com/coreos/rkt/issues/1752#issue-117121841 -func TestImageDependencies(t *testing.T) { - tmpDir := createTempDirOrPanic("rkt-TestImageDeps-") - defer os.RemoveAll(tmpDir) +var topImage string = "localhost/image-a" - ctx := testutils.NewRktRunCtx() - defer ctx.Cleanup() +type testImage struct { + shortName string + imageName string + deps string + version string + prefetch bool - server := runServer(t, taas.GetDefaultServerSetup()) - defer server.Close() + manifest string + fileName string +} + +func generateComplexDependencyTree(t *testing.T, ctx *testutils.RktRunCtx) (map[string]string, []testImage) { + tmpDir := createTempDirOrPanic("rkt-TestImageDeps-") + defer os.RemoveAll(tmpDir) baseImage := getInspectImagePath() _ = importImageAndFetchHash(t, ctx, "", baseImage) @@ -96,17 +100,7 @@ func TestImageDependencies(t *testing.T) { // D->B // D->E - topImage := "localhost/image-a" - imageList := []struct { - shortName string - imageName string - deps string - version string - prefetch bool - - manifest string - fileName string - }{ + imageList := []testImage{ { shortName: "a", imageName: topImage, @@ -161,10 +155,29 @@ func TestImageDependencies(t *testing.T) { baseName := "image-" + img.shortName + ".aci" img.fileName = patchACI(emptyImage, baseName, "--manifest", tmpManifest.Name()) - defer os.Remove(img.fileName) fileSet[baseName] = img.fileName } + return fileSet, imageList +} + +// TestImageDependencies generates ACIs with a complex dependency tree and +// fetches them via the discovery mechanism. Some dependencies are already +// cached in the CAS, and some dependencies are fetched via the discovery +// mechanism. This is to reproduce the scenario in explained in: +// https://github.com/coreos/rkt/issues/1752#issue-117121841 +func TestImageDependencies(t *testing.T) { + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + server := runServer(t, taas.GetDefaultServerSetup()) + defer server.Close() + + fileSet, imageList := generateComplexDependencyTree(t, ctx) + for _, img := range imageList { + defer os.Remove(img.fileName) + } + if err := server.UpdateFileSet(fileSet); err != nil { t.Fatalf("Failed to populate a file list in test aci server: %v", err) } @@ -198,3 +211,49 @@ func TestImageDependencies(t *testing.T) { waitOrFail(t, child, 0) } + +func TestRenderOnFetch(t *testing.T) { + // If overlayfs is not supported, we don't render images on fetch + if !common.SupportsOverlay() { + t.Skip("Overlay fs not supported.") + } + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + server := runServer(t, taas.GetDefaultServerSetup()) + defer server.Close() + + fileSet, imageList := generateComplexDependencyTree(t, ctx) + for _, img := range imageList { + defer os.Remove(img.fileName) + } + + if err := server.UpdateFileSet(fileSet); err != nil { + t.Fatalf("Failed to populate a file list in test aci server: %v", err) + } + + for i := len(imageList) - 1; i >= 0; i-- { + img := imageList[i] + if img.prefetch { + t.Logf("Importing image %q: %q", img.imageName, img.fileName) + testImageShortHash := importImageAndFetchHash(t, ctx, "", img.fileName) + t.Logf("Imported image %q: %s", img.imageName, testImageShortHash) + } + } + + fetchCmd := fmt.Sprintf("%s --debug --insecure-options=image,tls fetch %s", ctx.Cmd(), topImage) + child := spawnOrFail(t, fetchCmd) + + treeStoreDir := filepath.Join(ctx.DataDir(), "cas", "tree") + trees, err := ioutil.ReadDir(treeStoreDir) + if err != nil { + panic(fmt.Sprintf("Cannot read tree store dir: %v", err)) + } + + // We expect 2 trees: stage1 and the image + if len(trees) != 2 { + t.Fatalf("Expected 2 trees but found %d", len(trees)) + } + + waitOrFail(t, child, 0) +} From 961568e948f705de1d6460763aeef2275b9aa9c0 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Thu, 21 Apr 2016 17:07:31 +0200 Subject: [PATCH 0147/1304] kvm: not experimental anymore --- Documentation/running-lkvm-stage1.md | 4 ++-- configure.ac | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Documentation/running-lkvm-stage1.md b/Documentation/running-lkvm-stage1.md index 9111d887ee..d527421461 100644 --- a/Documentation/running-lkvm-stage1.md +++ b/Documentation/running-lkvm-stage1.md @@ -1,8 +1,8 @@ # Running rkt with an LKVM stage1 -rkt has experimental support for executing pods with an [LKVM](https://kernel.googlesource.com/pub/scm/linux/kernel/git/will/kvmtool/+/master/README) [stage1](devel/architecture.md#stage-1). rkt employs this [alternative stage1](devel/stage1-implementors-guide.md) to run a pod within a virtual machine with its own operating system kernel and hypervisor isolation, rather than creating a container using Linux cgroups and namespaces. +rkt has support for executing pods with an [LKVM](https://kernel.googlesource.com/pub/scm/linux/kernel/git/will/kvmtool/+/master/README) [stage1](devel/architecture.md#stage-1). rkt employs this [alternative stage1](devel/stage1-implementors-guide.md) to run a pod within a virtual machine with its own operating system kernel and hypervisor isolation, rather than creating a container using Linux cgroups and namespaces. -The "experimental" label denotes that the LKVM stage1 does not yet implement all of the default stage1's features and semantics. While the same app container can be executed under isolation by either stage1, it may require different configuration, especially for networking. However, several deployments of the LKVM stage1 are operational outside of CoreOS, and we encourage testing of this feature and welcome your contributions. +The LKVM stage1 does not yet implement all of the default stage1's features and semantics. While the same app container can be executed under isolation by either stage1, it may require different configuration, especially for networking. However, several deployments of the LKVM stage1 are operational outside of CoreOS, and we encourage testing of this feature and welcome your contributions. ## Getting started diff --git a/configure.ac b/configure.ac index 7b8fc4ef0d..d0e36073c0 100644 --- a/configure.ac +++ b/configure.ac @@ -285,8 +285,7 @@ RKT_ITERATE_FLAVORS([${RKT_STAGE1_FLAVORS}],[flavor], [coreos], [RKT_COMMON_COREOS_PROGS], [kvm], - [AC_MSG_WARN([* kvm is an experimental stage1 implementation, some features are missing]) - AC_MSG_NOTICE([will build linux kernel and lkvm from source, make sure that all their build requirements are fulfilled]) + [AC_MSG_NOTICE([will build linux kernel and lkvm from source, make sure that all their build requirements are fulfilled]) RKT_COMMON_COREOS_PROGS RKT_REQ_PROG([PATCH],[patch],[patch]) RKT_REQ_PROG([TAR],[tar],[tar]) From 27fa8b7d7dc26ef4c24221ebbe812aa5c974b540 Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Tue, 19 Apr 2016 14:22:12 +0300 Subject: [PATCH 0148/1304] *: fix gofmt errors Fixes gofmt errors throught the code. Related to #2390 --- common/apps/apps.go | 2 +- common/cgroup/cgroup.go | 4 +-- common/cgroup/cgroup_test.go | 40 ++++++++++++++-------------- common/common.go | 8 +++--- networking/kvm.go | 2 +- networking/podenv.go | 2 +- pkg/keystore/keystoretest/keymap.go | 12 ++++----- pkg/tar/tar_test.go | 20 +++++++------- rkt/cli_apps_test.go | 4 +-- rkt/config/config_test.go | 8 +++--- rkt/config/stage1.go | 8 +++--- rkt/image_list.go | 8 +++--- rkt/pubkey/pubkey.go | 4 ++- rkt/stage1hash.go | 10 +++---- stage0/arch.go | 2 +- store/store.go | 2 +- tests/rkt_api_service_test.go | 6 ++--- tests/rkt_image_dependencies_test.go | 2 +- tools/quickrm/main.go | 6 ++--- 19 files changed, 76 insertions(+), 74 deletions(-) diff --git a/common/apps/apps.go b/common/apps/apps.go index 5c9d687a9d..865c3aaf52 100644 --- a/common/apps/apps.go +++ b/common/apps/apps.go @@ -112,7 +112,7 @@ func (al *Apps) Validate() error { // Walk iterates on al.apps calling f for each app // walking stops if f returns an error, the error is simply returned func (al *Apps) Walk(f func(*App) error) error { - for i, _ := range al.apps { + for i := range al.apps { // XXX(vc): note we supply f() with a pointer to the app instance in al.apps to enable modification by f() if err := f(&al.apps[i]); err != nil { return err diff --git a/common/cgroup/cgroup.go b/common/cgroup/cgroup.go index 967485aedb..6866220c7c 100644 --- a/common/cgroup/cgroup.go +++ b/common/cgroup/cgroup.go @@ -41,8 +41,8 @@ var ( "memory": addMemoryLimit, } cgroupControllerRWFiles = map[string][]string{ - "memory": []string{"memory.limit_in_bytes"}, - "cpu": []string{"cpu.cfs_quota_us"}, + "memory": {"memory.limit_in_bytes"}, + "cpu": {"cpu.cfs_quota_us"}, } ) diff --git a/common/cgroup/cgroup_test.go b/common/cgroup/cgroup_test.go index 55d8dd5908..92ec647532 100644 --- a/common/cgroup/cgroup_test.go +++ b/common/cgroup/cgroup_test.go @@ -65,36 +65,36 @@ net_prio 6 432 1` { input: strings.NewReader(cg1), output: map[int][]string{ - 2: []string{"cpuset"}, - 3: []string{"cpu", "cpuacct"}, - 4: []string{"blkio"}, - 6: []string{"memory"}, - 7: []string{"devices"}, - 8: []string{"freezer"}, - 5: []string{"net_cls"}, + 2: {"cpuset"}, + 3: {"cpu", "cpuacct"}, + 4: {"blkio"}, + 6: {"memory"}, + 7: {"devices"}, + 8: {"freezer"}, + 5: {"net_cls"}, }, }, { input: strings.NewReader(cg2), output: map[int][]string{ - 8: []string{"cpuset"}, - 4: []string{"cpu", "cpuacct"}, - 2: []string{"blkio"}, - 3: []string{"devices"}, - 7: []string{"freezer"}, - 6: []string{"net_cls", "net_prio"}, - 5: []string{"perf_event"}, + 8: {"cpuset"}, + 4: {"cpu", "cpuacct"}, + 2: {"blkio"}, + 3: {"devices"}, + 7: {"freezer"}, + 6: {"net_cls", "net_prio"}, + 5: {"perf_event"}, }, }, { input: strings.NewReader(cg3), output: map[int][]string{ - 1: []string{"cpuset"}, - 4: []string{"cpu"}, - 2: []string{"blkio"}, - 3: []string{"devices"}, - 7: []string{"freezer"}, - 6: []string{"net_cls", "net_prio"}, + 1: {"cpuset"}, + 4: {"cpu"}, + 2: {"blkio"}, + 3: {"devices"}, + 7: {"freezer"}, + 6: {"net_cls", "net_prio"}, }, }, } diff --git a/common/common.go b/common/common.go index 2f05ba61b9..c557f0da7f 100644 --- a/common/common.go +++ b/common/common.go @@ -241,12 +241,12 @@ func (l *NetList) Strings() []string { return list } -func (l *NetList) StringsOnlyNames() []string { - var list []string - for k, _ := range l.mapping { +func (l *NetList) StringsOnlyNames() (list []string) { + for k := range l.mapping { list = append(list, k) } - return list + + return } // Check if host networking has been requested diff --git a/networking/kvm.go b/networking/kvm.go index f4a1117b74..aa302bd222 100644 --- a/networking/kvm.go +++ b/networking/kvm.go @@ -386,7 +386,7 @@ func kvmTransformFlannelNetwork(net *activeNet) error { "type": "host-local", "subnet": fenv.sn.String(), "routes": []cnitypes.Route{ - cnitypes.Route{ + { Dst: *fenv.nw, }, }, diff --git a/networking/podenv.go b/networking/podenv.go index c6a31acd69..5fe95f4ed7 100644 --- a/networking/podenv.go +++ b/networking/podenv.go @@ -284,7 +284,7 @@ func missingNets(defined common.NetList, loaded []activeNet) []string { } var missing []string - for n, _ := range diff { + for n := range diff { missing = append(missing, n) } return missing diff --git a/pkg/keystore/keystoretest/keymap.go b/pkg/keystore/keystoretest/keymap.go index 1fa0d0ff3e..03d3a2dddd 100644 --- a/pkg/keystore/keystoretest/keymap.go +++ b/pkg/keystore/keystoretest/keymap.go @@ -5,7 +5,7 @@ package keystoretest var KeyMap = map[string]*KeyDetails{ - "example.com": &KeyDetails{ + "example.com": { Fingerprint: `4d5b338b00c2935b90e50c16d71af6b1683451d2`, ArmoredPublicKey: `-----BEGIN PGP PUBLIC KEY BLOCK----- @@ -93,7 +93,7 @@ VH9rpClNzRXrKWVqCk2JjaaXM0FEVJpZQeT74hfe+NVFKJQf =mdQJ -----END PGP PRIVATE KEY BLOCK-----`, }, - "coreos.com": &KeyDetails{ + "coreos.com": { Fingerprint: `78b3fd7a0089dd84abad6641cbf56f3df44ede02`, ArmoredPublicKey: `-----BEGIN PGP PUBLIC KEY BLOCK----- @@ -181,7 +181,7 @@ nzYD7TV4jzDcRB4Zvnlqto+X76++XWM+fpVVWOZsIxkOv4TPbijQA5tXwZeiWj8U =Aa3W -----END PGP PRIVATE KEY BLOCK-----`, }, - "example.com/app": &KeyDetails{ + "example.com/app": { Fingerprint: `847157ec2524660482f8940beeafad1ea7040030`, ArmoredPublicKey: `-----BEGIN PGP PUBLIC KEY BLOCK----- @@ -269,7 +269,7 @@ tvSbMuIwWPpUksGYZX38KHDEEkNuFUJ3/HLqf1n3zFQasWhxPPe4Ew== =iOdD -----END PGP PRIVATE KEY BLOCK-----`, }, - "acme.com": &KeyDetails{ + "acme.com": { Fingerprint: `0580ac91290ca2bcdebe122cfc5f8bda55abd47d`, ArmoredPublicKey: `-----BEGIN PGP PUBLIC KEY BLOCK----- @@ -357,7 +357,7 @@ e+qZ6AxHGXjGKDYhVyWMVq0jAdRwgX9sLZMX0kTN =lHJX -----END PGP PRIVATE KEY BLOCK-----`, }, - "acme.com/services": &KeyDetails{ + "acme.com/services": { Fingerprint: `418d97e1f80fcc35c996249b2f13c45b30c346ea`, ArmoredPublicKey: `-----BEGIN PGP PUBLIC KEY BLOCK----- @@ -445,7 +445,7 @@ coxZfgZRV90cDur+F6xLufAAsmabtSlHoejinL02/KF8NHU9prLv =lUpJ -----END PGP PRIVATE KEY BLOCK-----`, }, - "acme.com/services/web/nginx": &KeyDetails{ + "acme.com/services/web/nginx": { Fingerprint: `b555d08c15547bd283b9605578ca11a4fa553a28`, ArmoredPublicKey: `-----BEGIN PGP PUBLIC KEY BLOCK----- diff --git a/pkg/tar/tar_test.go b/pkg/tar/tar_test.go index 541301564a..f24ea285de 100644 --- a/pkg/tar/tar_test.go +++ b/pkg/tar/tar_test.go @@ -603,16 +603,16 @@ func testExtractTarOverwrite(t *testing.T, extractTar func(io.Reader, string) er err = extractTar(containerTar2, tmpdir) expectedFiles := []*fileInfo{ - &fileInfo{path: "hello.txt", typeflag: tar.TypeReg, size: 8, contents: "newhello"}, - &fileInfo{path: "linktofile", typeflag: tar.TypeReg, size: 20}, - &fileInfo{path: "linktodir", typeflag: tar.TypeReg, size: 20}, - &fileInfo{path: "afolder", typeflag: tar.TypeReg, size: 8}, - &fileInfo{path: "dirsymlinked", typeflag: tar.TypeDir}, - &fileInfo{path: "afile", typeflag: tar.TypeDir}, - &fileInfo{path: "filesymlinked", typeflag: tar.TypeReg, size: 5}, - &fileInfo{path: "folder01", typeflag: tar.TypeDir}, - &fileInfo{path: "folder01/file01", typeflag: tar.TypeReg, size: 5}, - &fileInfo{path: "folder01/file02", typeflag: tar.TypeReg, size: 5}, + {path: "hello.txt", typeflag: tar.TypeReg, size: 8, contents: "newhello"}, + {path: "linktofile", typeflag: tar.TypeReg, size: 20}, + {path: "linktodir", typeflag: tar.TypeReg, size: 20}, + {path: "afolder", typeflag: tar.TypeReg, size: 8}, + {path: "dirsymlinked", typeflag: tar.TypeDir}, + {path: "afile", typeflag: tar.TypeDir}, + {path: "filesymlinked", typeflag: tar.TypeReg, size: 5}, + {path: "folder01", typeflag: tar.TypeDir}, + {path: "folder01/file01", typeflag: tar.TypeReg, size: 5}, + {path: "folder01/file02", typeflag: tar.TypeReg, size: 5}, } err = checkExpectedFiles(tmpdir, fileInfoSliceToMap(expectedFiles)) diff --git a/rkt/cli_apps_test.go b/rkt/cli_apps_test.go index 6df506b6ab..b82545077e 100644 --- a/rkt/cli_apps_test.go +++ b/rkt/cli_apps_test.go @@ -37,8 +37,8 @@ func TestParseAppArgs(t *testing.T) { []string{"example.com/foo", "example.com/bar", "example.com/baz"}, [][]string{ nil, - []string{"--help"}, - []string{"--verbose"}, + {"--help"}, + {"--verbose"}, }, false, }, diff --git a/rkt/config/config_test.go b/rkt/config/config_test.go index 52ce69ba83..7476399075 100644 --- a/rkt/config/config_test.go +++ b/rkt/config/config_test.go @@ -110,7 +110,7 @@ func TestDockerAuthConfigFormat(t *testing.T) { {`{"rktKind": "dockerAuth", "rktVersion": "v1", "registries": ["coreos.com"], "credentials": {"user": ""}}`, nil, true}, {`{"rktKind": "dockerAuth", "rktVersion": "v1", "registries": ["coreos.com"], "credentials": {"user": "bar"}}`, nil, true}, {`{"rktKind": "dockerAuth", "rktVersion": "v1", "registries": ["coreos.com"], "credentials": {"user": "bar", "password": ""}}`, nil, true}, - {`{"rktKind": "dockerAuth", "rktVersion": "v1", "registries": ["coreos.com"], "credentials": {"user": "bar", "password": "baz"}}`, map[string]BasicCredentials{"coreos.com": BasicCredentials{User: "bar", Password: "baz"}}, false}, + {`{"rktKind": "dockerAuth", "rktVersion": "v1", "registries": ["coreos.com"], "credentials": {"user": "bar", "password": "baz"}}`, map[string]BasicCredentials{"coreos.com": {User: "bar", Password: "baz"}}, false}, } for _, tt := range tests { cfg, err := getConfigFromContents(tt.contents, "dockerAuth") @@ -275,15 +275,15 @@ func TestConfigLoading(t *testing.T) { result[d] = h.Header() } expected := map[string]http.Header{ - "endocode.com": http.Header{ + "endocode.com": { // local_user1:local_password1 authHeader: []string{"Basic bG9jYWxfdXNlcjE6bG9jYWxfcGFzc3dvcmQx"}, }, - "coreos.com": http.Header{ + "coreos.com": { // system_user2:system_password2 authHeader: []string{"Basic c3lzdGVtX3VzZXIyOnN5c3RlbV9wYXNzd29yZDI="}, }, - "tectonic.com": http.Header{ + "tectonic.com": { // local_user2:local_password2 authHeader: []string{"Basic bG9jYWxfdXNlcjI6bG9jYWxfcGFzc3dvcmQy"}, }, diff --git a/rkt/config/stage1.go b/rkt/config/stage1.go index 79d206d627..ee6b32f6f2 100644 --- a/rkt/config/stage1.go +++ b/rkt/config/stage1.go @@ -33,10 +33,10 @@ type stage1V1 struct { var ( allowedSchemes = map[string]struct{}{ - "file": struct{}{}, - "docker": struct{}{}, - "http": struct{}{}, - "https": struct{}{}, + "file": {}, + "docker": {}, + "http": {}, + "https": {}, } ) diff --git a/rkt/image_list.go b/rkt/image_list.go index 7d3dd89d14..4cdefd9efd 100644 --- a/rkt/image_list.go +++ b/rkt/image_list.go @@ -71,10 +71,10 @@ var ( } ImagesSortableFields = map[string]struct{}{ - l(name): struct{}{}, - l(importTime): struct{}{}, - l(lastUsed): struct{}{}, - l(size): struct{}{}, + l(name): {}, + l(importTime): {}, + l(lastUsed): {}, + l(size): {}, } ) diff --git a/rkt/pubkey/pubkey.go b/rkt/pubkey/pubkey.go index 006954b44c..5d879c86e5 100644 --- a/rkt/pubkey/pubkey.go +++ b/rkt/pubkey/pubkey.go @@ -266,10 +266,12 @@ func displayKey(prefix, location string, key *os.File) error { for _, sk := range k.Subkeys { stdout.Printf(" Subkey fingerprint: %s", fingerToString(sk.PublicKey.Fingerprint)) } - for n, _ := range k.Identities { + + for n := range k.Identities { stdout.Printf("\t%s", n) } } + return nil } diff --git a/rkt/stage1hash.go b/rkt/stage1hash.go index 4ad6374d26..56338133cd 100644 --- a/rkt/stage1hash.go +++ b/rkt/stage1hash.go @@ -110,35 +110,35 @@ var ( // this holds necessary data to generate the --stage1-* flags // for each location kind stage1FlagsData = map[stage1ImageLocationKind]*stage1FlagData{ - stage1ImageLocationURL: &stage1FlagData{ + stage1ImageLocationURL: { kind: stage1ImageLocationURL, flag: "stage1-url", name: "stage1URL", help: "a URL to an image to use as stage1", }, - stage1ImageLocationPath: &stage1FlagData{ + stage1ImageLocationPath: { kind: stage1ImageLocationPath, flag: "stage1-path", name: "stage1Path", help: "an absolute or a relative path to an image to use as stage1", }, - stage1ImageLocationName: &stage1FlagData{ + stage1ImageLocationName: { kind: stage1ImageLocationName, flag: "stage1-name", name: "stage1Name", help: "a name of an image to use as stage1", }, - stage1ImageLocationHash: &stage1FlagData{ + stage1ImageLocationHash: { kind: stage1ImageLocationHash, flag: "stage1-hash", name: "stage1Hash", help: "a hash of an image to use as stage1", }, - stage1ImageLocationFromDir: &stage1FlagData{ + stage1ImageLocationFromDir: { kind: stage1ImageLocationFromDir, flag: "stage1-from-dir", name: "stage1FromDir", diff --git a/stage0/arch.go b/stage0/arch.go index 879c322a8d..441dacb742 100644 --- a/stage0/arch.go +++ b/stage0/arch.go @@ -15,5 +15,5 @@ package stage0 var ValidOSArch = map[string][]string{ - "linux": []string{"amd64", "i386", "aarch64", "aarch64_be", "armv6l", "armv7l", "armv7b"}, + "linux": {"amd64", "i386", "aarch64", "aarch64_be", "armv6l", "armv7l", "armv7b"}, } diff --git a/store/store.go b/store/store.go index 8b7ded6450..ee226632a1 100644 --- a/store/store.go +++ b/store/store.go @@ -181,7 +181,7 @@ func (s *Store) populateSize() error { } } - for k, _ := range aciSizes { + for k := range aciSizes { s.UpdateSize(k, aciSizes[k]) s.UpdateTreeStoreSize(k, tsSizes[k]) } diff --git a/tests/rkt_api_service_test.go b/tests/rkt_api_service_test.go index a527977046..0d0b9c94df 100644 --- a/tests/rkt_api_service_test.go +++ b/tests/rkt_api_service_test.go @@ -322,16 +322,16 @@ func TestAPIServiceListInspectPods(t *testing.T) { } pm := schema.BlankPodManifest() pm.Apps = []schema.RuntimeApp{ - schema.RuntimeApp{ + { Name: types.ACName("rkt-inspect"), Image: schema.RuntimeImage{ Name: types.MustACIdentifier("coreos.com/rkt-inspect"), ID: *imgID, }, - Annotations: []types.Annotation{types.Annotation{Name: types.ACIdentifier("app-test"), Value: "app-test"}}, + Annotations: []types.Annotation{{Name: types.ACIdentifier("app-test"), Value: "app-test"}}, }, } - pm.Annotations = []types.Annotation{types.Annotation{Name: types.ACIdentifier("test"), Value: "test"}} + pm.Annotations = []types.Annotation{{Name: types.ACIdentifier("test"), Value: "test"}} manifestFile := generatePodManifestFile(t, pm) defer os.Remove(manifestFile) diff --git a/tests/rkt_image_dependencies_test.go b/tests/rkt_image_dependencies_test.go index 2ac08805f7..22a51c3416 100644 --- a/tests/rkt_image_dependencies_test.go +++ b/tests/rkt_image_dependencies_test.go @@ -140,7 +140,7 @@ func TestImageDependencies(t *testing.T) { }, } - for i, _ := range imageList { + for i := range imageList { // We need a reference rather than a new copy from "range" // because we modify the content img := &imageList[i] diff --git a/tools/quickrm/main.go b/tools/quickrm/main.go index aedcc12e21..c3dadb7586 100644 --- a/tools/quickrm/main.go +++ b/tools/quickrm/main.go @@ -100,15 +100,15 @@ func main() { func getItems() []items { kinds := []*kindData{ - &kindData{ + { option: "files", proc: &fileProcessor{}, }, - &kindData{ + { option: "symlinks", proc: &symlinkProcessor{}, }, - &kindData{ + { option: "dirs", proc: &dirProcessor{}, }, From 2a3c6dd549d0bc219bc09e7daa89a6d287acecce Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Fri, 22 Apr 2016 18:02:29 +0200 Subject: [PATCH 0149/1304] stage1: src: remove obsolete systemd configure flags Symptoms: configure: WARNING: unrecognized options: --disable-python-devel, --disable-chkconfig, --disable-bootchart, --disable-gudev, --disable-terminal --- stage1/usr_from_src/usr_from_src.mk | 5 ----- 1 file changed, 5 deletions(-) diff --git a/stage1/usr_from_src/usr_from_src.mk b/stage1/usr_from_src/usr_from_src.mk index 5dc3fdf608..748fe914a6 100644 --- a/stage1/usr_from_src/usr_from_src.mk +++ b/stage1/usr_from_src/usr_from_src.mk @@ -145,10 +145,8 @@ $(call generate-stamp-rule,$(UFS_SYSTEMD_BUILD_STAMP),$(UFS_SYSTEMD_CLONE_AND_PA "$(abspath $(UFS_SYSTEMD_SRCDIR))/configure" \ $(call vl3,--quiet) \ --disable-dbus \ - --disable-python-devel \ --disable-kmod \ --disable-blkid \ - --disable-chkconfig \ --disable-selinux \ --disable-pam \ --disable-acl \ @@ -161,7 +159,6 @@ $(call generate-stamp-rule,$(UFS_SYSTEMD_BUILD_STAMP),$(UFS_SYSTEMD_CLONE_AND_PA --disable-gnutls \ --disable-binfmt \ --disable-vconsole \ - --disable-bootchart \ --disable-quotacheck \ --disable-tmpfiles \ --disable-sysusers \ @@ -179,12 +176,10 @@ $(call generate-stamp-rule,$(UFS_SYSTEMD_BUILD_STAMP),$(UFS_SYSTEMD_CLONE_AND_PA --disable-networkd \ --disable-efi \ --disable-myhostname \ - --disable-gudev \ --disable-manpages \ --disable-tests \ --disable-blkid \ --disable-hibernate \ - --disable-terminal \ --disable-hwdb \ --disable-importd \ --disable-firstboot \ From 74f17ab91bee012e872e32a68188692fa97fb0cd Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Tue, 19 Apr 2016 11:45:49 +0300 Subject: [PATCH 0150/1304] stage1/init: improve documentation Improves documentation and fixes a typo --- stage1/init/init.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/stage1/init/init.go b/stage1/init/init.go index f2b43466ce..0488e31711 100644 --- a/stage1/init/init.go +++ b/stage1/init/init.go @@ -601,7 +601,6 @@ func stage1() int { return 1 } - // mount host cgroups in the rkt mount namespace if err := mountHostCgroups(enabledCgroups); err != nil { log.FatalE("couldn't mount the host cgroups", err) return 1 @@ -623,9 +622,9 @@ func stage1() int { log.PrintE("continuing with per-app isolators disabled", err) } - // kvm flavor has a bit different logic in handling pid vs ppid, for details look into #2389 - // it does not require existance of "ppid", but instead registers current pid (which - // will be reused by lkvm binary) as an pod process pid used in entering + // KVM flavor has a bit different logic in handling pid vs ppid, for details look into #2389 + // it doesn't require the existence of a "ppid", instead it registers the current pid (which + // will be reused by lkvm binary) as a pod process pid used during entering pid_filename := "ppid" if flavor == "kvm" { pid_filename = "pid" @@ -636,7 +635,6 @@ func stage1() int { return 1 } - // prepare mounts for kvm flavor if flavor == "kvm" { if err := KvmPrepareMounts(s1Root, p); err != nil { log.PrintE("could not prepare mounts", err) From ed3afb63826a0229b0adc5b844e2252a6ecea996 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Mon, 25 Apr 2016 10:55:25 +0200 Subject: [PATCH 0151/1304] stage1/prepare-app: check for user namespace env Currently prepare-app always bind mounts /sys non-recursively if the non-unified cgroups hierarchy is present to prevent O(n2) behavior caused by recursive mounting. This optimization fails if a container is started in a user namespace environment where the kernel prevents from mounting /sys non-recursively. This checks explicitely if we are in a user namespaced environment and falls back to a recursive bind mount in this case. Fixes #2490 --- stage1/prepare-app/prepare-app.c | 85 +++++++++++++++++++++----------- 1 file changed, 57 insertions(+), 28 deletions(-) diff --git a/stage1/prepare-app/prepare-app.c b/stage1/prepare-app/prepare-app.c index 2731ef54df..912c992394 100644 --- a/stage1/prepare-app/prepare-app.c +++ b/stage1/prepare-app/prepare-app.c @@ -23,6 +23,7 @@ #include #include #include +#include #define err_out(_fmt, _args...) \ fprintf(stderr, "Error: " _fmt "\n", ##_args); @@ -52,6 +53,8 @@ static int exit_err; #define MACHINE_ID_LEN lenof("0123456789abcdef0123456789ab") #define MACHINE_NAME_LEN lenof("rkt-01234567-89ab-cdef-0123-456789ab") +#define UNMAPPED ((uid_t) -1) + #ifndef CGROUP2_SUPER_MAGIC #define CGROUP2_SUPER_MAGIC 0x63677270 #endif @@ -125,44 +128,78 @@ static int ensure_etc_hosts_exists(const char *root, int rootfd) { return 0; } +static void mount_at(const char *root, const mount_point *mnt) +{ + char to[4096]; + exit_if(snprintf(to, sizeof(to), "%s/%s", root, mnt->target) >= sizeof(to), + "Path too long: \"%s\"", to); + pexit_if(mount(mnt->source, to, mnt->type, + mnt->flags, mnt->options) == -1, + "Mounting \"%s\" on \"%s\" failed", mnt->source, to); +} + static void mount_sys(const char *root) { - char from[4096]; + int i; char to[4096]; struct statfs fs; DIR *dir = NULL; struct dirent *d; + const mount_point mnt_rec = { "/sys", "sys", "bind", NULL, MS_BIND|MS_REC }; + const mount_point sys_bind_table[] = { + { "/sys", "sys", "bind", NULL, MS_BIND }, + { "/sys/fs/cgroup", "sys/fs/cgroup", "bind", NULL, MS_BIND }, + }; pexit_if(statfs("/sys/fs/cgroup", &fs) != 0, "Cannot statfs /sys/fs/cgroup"); if (fs.f_type == (typeof(fs.f_type)) CGROUP2_SUPER_MAGIC) { /* With the unified cgroup hierarchy, recursive bind mounts * are fine. */ - exit_if(snprintf(to, sizeof(to), "%s/%s", root, "sys") >= sizeof(to), - "Path too long: \"%s\"", to); - pexit_if(mount("/sys", to, "bind", - MS_BIND | MS_REC, "NULL") == -1, - "Mounting \"%s\" on \"%s\" failed", "/sys", to); + mount_at(root, &mnt_rec); return; } + // For security reasons recent Linux kernels do not allow to bind-mount non-recursively + // if it would give read-write access to other subdirectories mounted as read-only. + // Hence we have to check if we are in a user namespaced environment and bind mount recursively instead. + if (access("/proc/1/uid_map", F_OK) == 0) { + FILE *f; + int k; + uid_t uid_base, uid_shift, uid_range; + + pexit_if((f = fopen("/proc/1/uid_map", "re")) == NULL, + "Unable to open /proc/1/uid_map"); + + if (sizeof(uid_t) == 4) { + k = fscanf(f, "%"PRIu32" %"PRIu32" %"PRIu32, + &uid_base, &uid_shift, &uid_range); + } else { + k = fscanf(f, "%"PRIu16" %"PRIu16" %"PRIu16, + &uid_base, &uid_shift, &uid_range); + } + pexit_if(fclose(f) != 0, "Unable to close /proc/1/uid_map"); + pexit_if(k != 3, "Invalid uid_map format"); + + // do a recursive bind mount if we are in a user namespace having a parent namespace set, + // i.e. either one of uid base, shift, or the range is set, see user_namespaces(7). + if (uid_base != 0 || uid_shift != 0 || uid_range != UNMAPPED) { + mount_at(root, &mnt_rec); + return; + } + } + /* With cgroup-v1, rkt and systemd-nspawn add more cgroup * bind-mounts to control which files are read-only. To avoid * a quadratic progression, prepare-app does not bind mount * /sys recursively. See: * https://github.com/coreos/rkt/issues/2351 */ - exit_if(snprintf(to, sizeof(to), "%s/%s", root, "sys") >= sizeof(to), - "Path too long: \"%s\"", to); - pexit_if(mount("/sys", to, "bind", - MS_BIND, "NULL") == -1, - "Mounting \"%s\" on \"%s\" failed", "/sys", to); + for (i = 0; i < nelems(sys_bind_table); i++) { + mount_at(root, &sys_bind_table[i]); + } exit_if(snprintf(to, sizeof(to), "%s/%s", root, "sys/fs/cgroup") >= sizeof(to), "Path too long: \"%s\"", to); - pexit_if(mount("/sys/fs/cgroup", to, "bind", - MS_BIND, "NULL") == -1, - "Mounting \"%s\" on \"%s\" failed", "/sys/fs/cgroup", to); - pexit_if(!(dir = opendir(to)), "Failed to open directory \"%s\"", to) errno = 0; while ((d = readdir(dir))) { @@ -173,13 +210,11 @@ static void mount_sys(const char *root) if (strcmp(d->d_name, "..") == 0) continue; - exit_if(snprintf(from, sizeof(from), "/sys/fs/cgroup/%s", d->d_name) >= sizeof(from), - "Path too long: \"%s\"", from); - exit_if(snprintf(to, sizeof(to), "%s/sys/fs/cgroup/%s", root, d->d_name) >= sizeof(to), + exit_if(snprintf(to, sizeof(to), "sys/fs/cgroup/%s", d->d_name) >= sizeof(to), "Path too long: \"%s\"", to); - pexit_if(mount(from, to, "bind", - MS_BIND, "NULL") == -1, - "Mounting \"%s\" on \"%s\" failed", from, to); + + mount_point mnt = { to, to, "bind", NULL, MS_BIND }; + mount_at(root, &mnt); } pexit_if(errno != 0, "Failed to read directory \"%s\"", to); pexit_if(closedir(dir) != 0, "Failed to close directory"); @@ -317,13 +352,7 @@ int main(int argc, char *argv[]) /* Bind mount directories */ for (i = 0; i < nelems(dirs_mount_table); i++) { - const mount_point *mnt = &dirs_mount_table[i]; - - exit_if(snprintf(to, sizeof(to), "%s/%s", root, mnt->target) >= sizeof(to), - "Path too long: \"%s\"", to); - pexit_if(mount(mnt->source, to, mnt->type, - mnt->flags, mnt->options) == -1, - "Mounting \"%s\" on \"%s\" failed", mnt->source, to); + mount_at(root, &dirs_mount_table[i]); } /* Bind mount /sys: handled differently, depending on cgroups */ From f4f115151491bd916f5b38a5da1fc2d226937c0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Mon, 25 Apr 2016 19:55:23 +0200 Subject: [PATCH 0152/1304] api: fix image size reporting We need to take into account the treestore size too. --- rkt/api_service.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rkt/api_service.go b/rkt/api_service.go index 532d3254f1..3e217589cd 100644 --- a/rkt/api_service.go +++ b/rkt/api_service.go @@ -546,7 +546,7 @@ func aciInfoToV1AlphaAPIImage(store *store.Store, aciInfo *store.ACIInfo) (*v1al Version: version, ImportTimestamp: aciInfo.ImportTime.Unix(), Manifest: manifest, - Size: aciInfo.Size, + Size: aciInfo.Size + aciInfo.TreeStoreSize, Annotations: convertAnnotationsToKeyValue(im.Annotations), }, &im, nil } From 1fede92eaebf30818a92cbdde71ae315cbf539d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Mon, 25 Apr 2016 19:59:47 +0200 Subject: [PATCH 0153/1304] functional tests: update TestImageSize We're now rendering the image when we fetch it if we use overlay fs. Take that into account in the test. --- tests/rkt_image_list_test.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/rkt_image_list_test.go b/tests/rkt_image_list_test.go index 7e78c6ab9d..9cd4698a9f 100644 --- a/tests/rkt_image_list_test.go +++ b/tests/rkt_image_list_test.go @@ -22,6 +22,7 @@ import ( "strings" "testing" + "github.com/coreos/rkt/common" "github.com/coreos/rkt/pkg/fileutil" "github.com/coreos/rkt/tests/testutils" ) @@ -77,14 +78,17 @@ func TestImageSize(t *testing.T) { imageListCmd := fmt.Sprintf("%s image list --no-legend --full", ctx.Cmd()) - // check that the printed size is the same as the actual image size - expectedStr := fmt.Sprintf("(?s)%s.*%d.*", imageHash, imageSize) + // if we don't support overlay fs, we don't render the image on fetch + if !common.SupportsOverlay() { + // check that the printed size is the same as the actual image size + expectedStr := fmt.Sprintf("(?s)%s.*%d.*", imageHash, imageSize) - runRktAndCheckRegexOutput(t, imageListCmd, expectedStr) + runRktAndCheckRegexOutput(t, imageListCmd, expectedStr) - // run the image, so rkt renders it in the tree store - runCmd := fmt.Sprintf("%s --insecure-options=image run %s", ctx.Cmd(), image) - spawnAndWaitOrFail(t, runCmd, 0) + // run the image, so rkt renders it in the tree store + runCmd := fmt.Sprintf("%s --insecure-options=image run %s", ctx.Cmd(), image) + spawnAndWaitOrFail(t, runCmd, 0) + } tmpDir := createTempDirOrPanic("rkt_image_list_test") defer os.RemoveAll(tmpDir) @@ -113,7 +117,7 @@ func TestImageSize(t *testing.T) { } // check the size with the rendered image - expectedStr = fmt.Sprintf("(?s)%s.*%d.*", imageHash, imageSize+tsSize) + expectedStr := fmt.Sprintf("(?s)%s.*%d.*", imageHash, imageSize+tsSize) runRktAndCheckRegexOutput(t, imageListCmd, expectedStr) // gc the pod From ff66c0f86e6205ab5518da1cfcf5843c3d78420e Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Thu, 21 Apr 2016 17:28:58 +0200 Subject: [PATCH 0154/1304] userns: not experimental anymore --- Documentation/devel/user-namespaces.md | 17 ++++++++++------- Documentation/subcommands/prepare.md | 2 +- Documentation/subcommands/run.md | 4 ++-- rkt/prepare.go | 2 +- rkt/run.go | 2 +- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Documentation/devel/user-namespaces.md b/Documentation/devel/user-namespaces.md index 703837cc88..2281afc2e5 100644 --- a/Documentation/devel/user-namespaces.md +++ b/Documentation/devel/user-namespaces.md @@ -7,20 +7,23 @@ It can provide a better isolation and security: the privileged user `root` in th ## Implementation status -rkt has an experimental implementation based on systemd-nspawn. +rkt's implementation is based on systemd-nspawn. A pod can transparently use user IDs in the range 0-65535 and this range is mapped on the host to a high range chosen randomly. Before the pod is started, the ACIs are rendered to the filesystem and the owners of the files are set with `chown` in that high range. -## Future work +## Current limitations -### Choosing the UID range +### UID range allocation When starting several pods with user namespaces, they will each get a random UID range. -In order to avoid collisions, it is planned to implement a locking -mechanism so that two pods will always have a different UID range. -### Working with overlayfs +Although very unlikely, it is possible that two distincts containers get the same UID range. +If this happens, user namespaces will not provide any additional isolation between the two containers, exactly like when user namespaces are not used. +The two containers will however still not use the same UID range as the host, so using user namespaces is better than not using them. +In order to avoid collisions, it is planned to implement a locking mechanism so that two pods will always have a different UID range. + +### Incompatible with overlayfs The initial implementation works only with `--no-overlay`. Ideally, preparing a pod should not have to iterate over all files to call `chown`. @@ -28,7 +31,7 @@ Ideally, preparing a pod should not have to iterate over all files to call `chow It is planned to add kernel support for a mount option to shift the user IDs in the correct range (https://github.com/coreos/rkt/issues/1057). It would make it work with overlayfs. -### Volumes +### Inconvenient UID shift on volumes When mounting a volume from the host into the pod, the ownership of the files is not shifted, so it makes volumes difficult if not impossible to use with user namespaces. The same kernel support should help here too (https://github.com/coreos/rkt/issues/1057). diff --git a/Documentation/subcommands/prepare.md b/Documentation/subcommands/prepare.md index 4456a44f46..38ae3a3c96 100644 --- a/Documentation/subcommands/prepare.md +++ b/Documentation/subcommands/prepare.md @@ -41,7 +41,7 @@ c9fad0e6-8236-4fc2-ad17-55d0a4c7d742 | `--no-store` | `false` | `true` or `false` | Fetch images, ignoring the local store. See [image fetching behavior](../image-fetching-behavior.md) | | `--pod-manifest` | none | A path | The path to the pod manifest. If it's non-empty, then only `--net`, `--no-overlay` and `--interactive` will have effect. | | `--port` | none | A port number (ex. `--port=NAME:HOSTPORT`) | Ports to expose on the host (requires [contained network](../networking.md#contained-mode)). | -| `--private-users` | `false` | `true` or `false` | Run within user namespaces (experimental) | +| `--private-users` | `false` | `true` or `false` | Run within user namespaces | | `--quiet` | `false` | `true` or `false` | Suppress superfluous output on stdout, print only the UUID on success | | `--set-env` | `` | An environment variable. Syntax `NAME=VALUE` | An environment variable to set for apps | | `--signature` | `` | A file path | Local signature file to use in validating the preceding image | diff --git a/Documentation/subcommands/run.md b/Documentation/subcommands/run.md index b522ae44b3..d43046bfd8 100644 --- a/Documentation/subcommands/run.md +++ b/Documentation/subcommands/run.md @@ -350,7 +350,7 @@ For more details see the [hacking documentation](../hacking.md). | `--no-store` | `false` | `true` or `false` | Fetch images, ignoring the local store. See [image fetching behavior](../image-fetching-behavior.md) | | `--pod-manifest` | none | A path | The path to the pod manifest. If it's non-empty, then only `--net`, `--no-overlay` and `--interactive` will have effect. | | `--port` | none | A port number (ex. `--port=NAME:HOSTPORT`) | Ports to expose on the host (requires [contained network](../networking.md#contained-mode)). | -| `--private-users` | `false` | `true` or `false` | Run within user namespaces (experimental). | +| `--private-users` | `false` | `true` or `false` | Run within user namespaces. | | `--set-env` | none | An environment variable (ex. `--set-env=NAME=VALUE`) | An environment variable to set for apps. | | `--signature` | none | A file path | Local signature file to use in validating the preceding image | | `--stage1-url` | none | URL with protocol | A URL to a stage1 image. HTTP/HTTPS/File/Docker URLs are supported. | @@ -364,4 +364,4 @@ For more details see the [hacking documentation](../hacking.md). ## Global options -See the table with [global options in general commands documentation](../commands.md#global-options). \ No newline at end of file +See the table with [global options in general commands documentation](../commands.md#global-options). diff --git a/rkt/prepare.go b/rkt/prepare.go index c62696a0bd..127d176113 100644 --- a/rkt/prepare.go +++ b/rkt/prepare.go @@ -58,7 +58,7 @@ func init() { cmdPrepare.Flags().BoolVar(&flagQuiet, "quiet", false, "suppress superfluous output on stdout, print only the UUID on success") cmdPrepare.Flags().BoolVar(&flagInheritEnv, "inherit-env", false, "inherit all environment variables not set by apps") cmdPrepare.Flags().BoolVar(&flagNoOverlay, "no-overlay", false, "disable overlay filesystem") - cmdPrepare.Flags().BoolVar(&flagPrivateUsers, "private-users", false, "run within user namespaces (experimental).") + cmdPrepare.Flags().BoolVar(&flagPrivateUsers, "private-users", false, "run within user namespaces.") cmdPrepare.Flags().Var(&flagExplicitEnv, "set-env", "an environment variable to set for apps in the form name=value") cmdPrepare.Flags().BoolVar(&flagStoreOnly, "store-only", false, "use only available images in the store (do not discover or download from remote URLs)") cmdPrepare.Flags().BoolVar(&flagNoStore, "no-store", false, "fetch images ignoring the local store") diff --git a/rkt/run.go b/rkt/run.go index f7537b4b33..01ba367925 100644 --- a/rkt/run.go +++ b/rkt/run.go @@ -79,7 +79,7 @@ func init() { cmdRun.Flags().Lookup("net").NoOptDefVal = "default" cmdRun.Flags().BoolVar(&flagInheritEnv, "inherit-env", false, "inherit all environment variables not set by apps") cmdRun.Flags().BoolVar(&flagNoOverlay, "no-overlay", false, "disable overlay filesystem") - cmdRun.Flags().BoolVar(&flagPrivateUsers, "private-users", false, "run within user namespaces (experimental).") + cmdRun.Flags().BoolVar(&flagPrivateUsers, "private-users", false, "run within user namespaces.") cmdRun.Flags().Var(&flagExplicitEnv, "set-env", "an environment variable to set for apps in the form name=value") cmdRun.Flags().BoolVar(&flagInteractive, "interactive", false, "run pod interactively. If true, only one image may be supplied.") cmdRun.Flags().Var(&flagDNS, "dns", "name servers to write in /etc/resolv.conf") From 0e8debedf83af021603f2bd081932c2e26a39ef3 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Fri, 8 Apr 2016 13:44:16 +0200 Subject: [PATCH 0155/1304] doc: stage1-implementors-guide.md: clarify pid vs ppid Clarify that only one file must be written among pid / ppid. Reword the description. With the kvm flavor, the pid 1 of the container was not visible on the host. The new wording does not make that assumption. --- Documentation/devel/stage1-implementors-guide.md | 6 +++--- rkt/pods.go | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Documentation/devel/stage1-implementors-guide.md b/Documentation/devel/stage1-implementors-guide.md index 926942fab5..357e8038bf 100644 --- a/Documentation/devel/stage1-implementors-guide.md +++ b/Documentation/devel/stage1-implementors-guide.md @@ -50,10 +50,10 @@ An alternative stage 1 could forego systemd-nspawn and systemd altogether, or re All that is required is an executable at the place indicated by the `coreos.com/rkt/stage1/run` entrypoint that knows how to apply the pod manifest and prepared ACI file-systems to good effect. The resolved entrypoint must inform rkt of its PID for the benefit of `rkt enter`. -Stage 1 must write the host PIDs of the pod's process #1 and that process's parent to these two files, respectively: +Stage 1 implementors have two options for doing so; only one must be implemented: -* `/var/lib/rkt/pods/run/$uuid/pid`: the PID of the process that is PID 1 in the container. -* `/var/lib/rkt/pods/run/$uuid/ppid`: the PID of the parent of the process that is PID 1 in the container. +* `/var/lib/rkt/pods/run/$uuid/pid`: the PID of the process that will be given to the "enter" entrypoint. +* `/var/lib/rkt/pods/run/$uuid/ppid`: the PID of the parent of the process that will be given to the "enter" entrypoint. That parent process must have exactly one child process. #### Arguments diff --git a/rkt/pods.go b/rkt/pods.go index 88a488455a..ec7e6b9023 100644 --- a/rkt/pods.go +++ b/rkt/pods.go @@ -909,8 +909,9 @@ func (p *pod) getPID() (int, error) { // getContainerPID1 returns the pid of the process with pid 1 in the pod. func (p *pod) getContainerPID1() (pid int, err error) { - // rkt supports two methods to find the container's PID 1: - // the pid file and the ppid file. + // rkt supports two methods to find the container's PID 1: the pid + // file and the ppid file. + // The ordering is not important and only one of them must be supplied. // See Documentation/devel/stage1-implementors-guide.md for { var ppid int From 2711408e47d1cb1e7202aa1e7a68dc553275a46e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Thu, 21 Apr 2016 19:33:02 +0200 Subject: [PATCH 0156/1304] stage1/init/pod: fix typo --- stage1/init/common/pod.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index cf04ac2832..9ca0e35a29 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -457,7 +457,7 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b // 1. the hardcoded string "root" // 2. a path // 3. a number -// 4. a name in reference to /etc/{group,passwod} in the image +// 4. a name in reference to /etc/{group,passwd} in the image // See https://github.com/appc/spec/blob/master/spec/aci.md#image-manifest-schema func parseUserGroup(p *stage1commontypes.Pod, ra *schema.RuntimeApp, privateUsers string) (int, int, error) { app := ra.App From 9b7774fc98a40f2653ef884045843b9804193fd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Fri, 22 Apr 2016 18:06:40 +0200 Subject: [PATCH 0157/1304] stage1: use pure systemd to start apps in a pod Up to this point, we were using appexec as a wrapper to the actual binary to set up the environment for the apps in a pod. This commit replaces appexec's functionality with pure systemd options: appexec | systemd option ------------ | ------------- chroot | RootDirectory= chdir | WorkingDirectory= setenv | EnvironmentFile= setresuid | User= setresgid | Group= setgroups | SupplementaryGroups= execvp | ExecStart= $PATH lookup | implemented when writing the unit file ELF diagnostic | not yet implemented We're still using appexec (it'll be renamed in a follow-up commit) to implement the `rkt enter` functionality. Implementing this in systemd allows us to restrict the capabilities granted to apps, including `CAP_SYS_ADMIN`. --- stage1/init/common/path.go | 25 +- stage1/init/common/pod.go | 224 ++++++++++++++---- stage1/units/units/sysusers.service | 12 + .../manifest.d/systemd.manifest | 2 + stage1/usr_from_src/usr_from_src.mk | 1 - tests/rkt_exec_test.go | 22 +- 6 files changed, 220 insertions(+), 66 deletions(-) create mode 100644 stage1/units/units/sysusers.service diff --git a/stage1/init/common/path.go b/stage1/init/common/path.go index b869c22b83..140d5058cd 100644 --- a/stage1/init/common/path.go +++ b/stage1/init/common/path.go @@ -43,15 +43,28 @@ func ServiceUnitPath(root string, appName types.ACName) string { return filepath.Join(common.Stage1RootfsPath(root), UnitsDir, ServiceUnitName(appName)) } -// RelEnvFilePath returns the path to the environment file for the given app name -// relative to the pod's root. -func RelEnvFilePath(appName types.ACName) string { +// RelEnvFilePathAppexec returns the path to the environment file for the given +// app name relative to the pod's root to be parsed by appexec. +func RelEnvFilePathAppexec(appName types.ACName) string { return filepath.Join(envDir, appName.String()) } -// EnvFilePath returns the path to the environment file for the given app name. -func EnvFilePath(root string, appName types.ACName) string { - return filepath.Join(common.Stage1RootfsPath(root), RelEnvFilePath(appName)) +// EnvFilePathAppexec returns the path to the environment file for the given +// app name to be parsed by appexec. +func EnvFilePathAppexec(root string, appName types.ACName) string { + return filepath.Join(common.Stage1RootfsPath(root), RelEnvFilePathAppexec(appName)) +} + +// RelEnvFilePathSystemd returns the path to the environment file for the given +// app name relative to the pod's root to be parsed by systemd. +func RelEnvFilePathSystemd(appName types.ACName) string { + return filepath.Join(envDir, appName.String()) + "-systemd" +} + +// EnvFilePathSystemd returns the path to the environment file for the given +// app name to be parsed by systemd. +func EnvFilePathSystemd(root string, appName types.ACName) string { + return EnvFilePathAppexec(root, appName) + "-systemd" } // ServiceWantPath returns the systemd default.target want symlink path for the diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index 9ca0e35a29..11ca3ac451 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -60,35 +60,23 @@ var ( "HOME": "/root", } - // The list of default capabilities inside systemd-nspawn pod is available - // here: https://www.freedesktop.org/software/systemd/man/systemd-nspawn.html - nspawnCapabilities, _ = types.NewLinuxCapabilitiesRetainSet([]string{ + // appDefaultCapabilities defines a restricted set of capabilities given to + // apps by default. + appDefaultCapabilities, _ = types.NewLinuxCapabilitiesRetainSet([]string{ + "CAP_AUDIT_WRITE", "CAP_CHOWN", "CAP_DAC_OVERRIDE", - "CAP_DAC_READ_SEARCH", - "CAP_FOWNER", "CAP_FSETID", - "CAP_IPC_OWNER", + "CAP_FOWNER", "CAP_KILL", - "CAP_LEASE", - "CAP_LINUX_IMMUTABLE", - "CAP_NET_BIND_SERVICE", - "CAP_NET_BROADCAST", + "CAP_MKNOD", "CAP_NET_RAW", + "CAP_NET_BIND_SERVICE", + "CAP_SETUID", "CAP_SETGID", - "CAP_SETFCAP", "CAP_SETPCAP", - "CAP_SETUID", - "CAP_SYS_ADMIN", + "CAP_SETFCAP", "CAP_SYS_CHROOT", - "CAP_SYS_NICE", - "CAP_SYS_PTRACE", - "CAP_SYS_TTY_CONFIG", - "CAP_SYS_RESOURCE", - "CAP_SYS_BOOT", - "CAP_AUDIT_WRITE", - "CAP_AUDIT_CONTROL", - "CAP_MKNOD", }...) ) @@ -276,6 +264,116 @@ func findHostPort(pm schema.PodManifest, name types.ACName) uint { return port } +// generateSysusers generates systemd sysusers files for a given app so that +// corresponding entries in /etc/passwd and /etc/group are created in stage1. +// This is needed to use the "User=" and "Group=" options in the systemd +// service files of apps. +// If there're several apps defining the same UIDs/GIDs, systemd will take care +// of only generating one /etc/{passwd,group} entry +func generateSysusers(p *stage1commontypes.Pod, ra *schema.RuntimeApp, uid_ int, gid_ int) error { + app := ra.App + appName := ra.Name + + if err := os.MkdirAll(path.Join(common.Stage1RootfsPath(p.Root), "usr/lib/sysusers.d"), 0755); err != nil { + return err + } + + gids := append(app.SupplementaryGIDs, gid_) + + // Create the Unix user and group + var sysusersConf []string + + for _, g := range gids { + groupname := "gen" + strconv.Itoa(g) + sysusersConf = append(sysusersConf, fmt.Sprintf("g %s %d\n", groupname, g)) + } + + username := "gen" + strconv.Itoa(uid_) + sysusersConf = append(sysusersConf, fmt.Sprintf("u %s %d \"%s\"\n", username, uid_, username)) + + if err := ioutil.WriteFile(path.Join(common.Stage1RootfsPath(p.Root), "usr/lib/sysusers.d", ServiceUnitName(appName)+".conf"), + []byte(strings.Join(sysusersConf, "\n")), 0640); err != nil { + return err + } + + return nil +} + +// lookupPathInsideApp returns the path (relative to the app rootfs) of the +// given binary. It will look up on "paths" (also relative to the app rootfs) +// and evaluate possible symlinks to check if the resulting path is actually +// executable. +func lookupPathInsideApp(bin string, paths string, appRootfs string) (string, error) { + pathsArr := filepath.SplitList(paths) + var appPathsArr []string + for _, p := range pathsArr { + appPathsArr = append(appPathsArr, filepath.Join(appRootfs, p)) + } + for _, path := range appPathsArr { + binPath := filepath.Join(path, bin) + binAbsPath, err := filepath.Abs(binPath) + if err != nil { + return "", fmt.Errorf("unable to find absolute path for %s", binPath) + } + relPath := strings.TrimPrefix(binAbsPath, appRootfs) + d, err := os.Lstat(binAbsPath) + if err != nil { + continue + } + binRealPath, err := evaluateSymlinksInsideApp(appRootfs, relPath) + if err != nil { + return "", errwrap.Wrap(fmt.Errorf("could not evaluate path %v", binAbsPath), err) + } + binRealPath = filepath.Join(appRootfs, binRealPath) + d, err = os.Stat(binRealPath) + if err != nil { + continue + } + // Check the executable bit, inspired by os.exec.LookPath() + if m := d.Mode(); !m.IsDir() && m&0111 != 0 { + // The real path is executable, return the path relative to the app + return relPath, nil + } + } + return "", fmt.Errorf("unable to find %q in %q", bin, paths) +} + +// appSearchPaths returns a list of paths where we should search for +// non-absolute exec binaries +func appSearchPaths(p *stage1commontypes.Pod, appRootfs string, app types.App) []string { + appEnv := app.Environment + + if imgPath, ok := appEnv.Get("PATH"); ok { + return strings.Split(imgPath, ":") + } + + // emulate exec(3) behavior, first check pod's directory and then the list + // of directories returned by confstr(_CS_PATH). That's typically + // "/bin:/usr/bin" so let's use that. + return []string{appRootfs, "/bin", "/usr/bin"} +} + +// findBinPath takes a binary path and returns a the absolute path of the +// binary relative to the app rootfs. This can be passed to ExecStart on the +// app's systemd service file directly. +func findBinPath(p *stage1commontypes.Pod, appName types.ACName, app types.App, bin string) (string, error) { + absRoot, err := filepath.Abs(p.Root) + if err != nil { + return "", errwrap.Wrap(errors.New("could not get pod's root absolute path"), err) + } + + appRootfs := common.AppRootfsPath(absRoot, appName) + appPathDirs := appSearchPaths(p, appRootfs, app) + appPath := strings.Join(appPathDirs, ":") + + binPath, err := lookupPathInsideApp(bin, appPath, appRootfs) + if err != nil { + return "", errwrap.Wrap(fmt.Errorf("error looking up %q", bin), err) + } + + return strings.TrimPrefix(binPath, appRootfs), nil +} + // appToSystemd transforms the provided RuntimeApp+ImageManifest into systemd units func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive bool, flavor string, privateUsers string) error { app := ra.App @@ -298,8 +396,16 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b env.Set("AC_METADATA_URL", p.MetadataServiceURL) } - if err := writeEnvFile(p, env, appName, privateUsers); err != nil { - return errwrap.Wrap(errors.New("unable to write environment file"), err) + // TODO(iaguis): make appexec use the same format as systemd + envFilePathSystemd := EnvFilePathSystemd(p.Root, appName) + envFilePathAppexec := EnvFilePathAppexec(p.Root, appName) + + if err := writeEnvFile(p, env, appName, privateUsers, '\n', envFilePathSystemd); err != nil { + return errwrap.Wrap(errors.New("unable to write environment file for systemd"), err) + } + + if err := writeEnvFile(p, env, appName, privateUsers, '\000', envFilePathAppexec); err != nil { + return errwrap.Wrap(errors.New("unable to write environment file for appexec"), err) } u, g, err := parseUserGroup(p, ra, privateUsers) @@ -307,17 +413,43 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b return err } - execWrap := []string{"/appexec", common.RelAppRootfsPath(appName), workDir, RelEnvFilePath(appName), - strconv.Itoa(u), generateGidArg(g, app.SupplementaryGIDs), "--"} - execStart := quoteExec(append(execWrap, app.Exec...)) + if err := generateSysusers(p, ra, u, g); err != nil { + return errwrap.Wrap(errors.New("unable to generate sysusers"), err) + } + + binPath := app.Exec[0] + if !filepath.IsAbs(binPath) { + binPath, err = findBinPath(p, appName, *app, binPath) + if err != nil { + return err + } + } + + var supplementaryGroups []string + for _, g := range app.SupplementaryGIDs { + supplementaryGroups = append(supplementaryGroups, strconv.Itoa(g)) + } + + // TODO: read the RemoveSet as well. See + // https://github.com/coreos/rkt/issues/2348#issuecomment-211796840 + capabilities := append(app.Isolators, appDefaultCapabilities.AsIsolator()) + capabilitiesStr := GetAppCapabilities(capabilities) + + execStart := append([]string{binPath}, app.Exec[1:]...) + execStartString := quoteExec(execStart) opts := []*unit.UnitOption{ unit.NewUnitOption("Unit", "Description", fmt.Sprintf("Application=%v Image=%v", appName, imgName)), unit.NewUnitOption("Unit", "DefaultDependencies", "false"), unit.NewUnitOption("Unit", "Wants", fmt.Sprintf("reaper-%s.service", appName)), unit.NewUnitOption("Service", "Restart", "no"), - unit.NewUnitOption("Service", "ExecStart", execStart), - unit.NewUnitOption("Service", "User", "0"), - unit.NewUnitOption("Service", "Group", "0"), + unit.NewUnitOption("Service", "ExecStart", execStartString), + unit.NewUnitOption("Service", "RootDirectory", common.RelAppRootfsPath(appName)), + unit.NewUnitOption("Service", "WorkingDirectory", workDir), + unit.NewUnitOption("Service", "EnvironmentFile", RelEnvFilePathSystemd(appName)), + unit.NewUnitOption("Service", "User", strconv.Itoa(u)), + unit.NewUnitOption("Service", "Group", strconv.Itoa(g)), + unit.NewUnitOption("Service", "SupplementaryGroups", strings.Join(supplementaryGroups, " ")), + unit.NewUnitOption("Service", "CapabilityBoundingSet", strings.Join(capabilitiesStr, " ")), } if interactive { @@ -330,13 +462,6 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b opts = append(opts, unit.NewUnitOption("Service", "SyslogIdentifier", filepath.Base(app.Exec[0]))) } - if flavor == "kvm" { - capabilities := append(app.Isolators, nspawnCapabilities.AsIsolator()) - capabilitiesStr := GetAppCapabilities(capabilities) - - opts = append(opts, unit.NewUnitOption("Service", "CapabilityBoundingSet", strings.Join(capabilitiesStr, " "))) - } - // When an app fails, we shut down the pod opts = append(opts, unit.NewUnitOption("Unit", "OnFailure", "halt.target")) @@ -350,7 +475,7 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b default: return fmt.Errorf("unrecognized eventHandler: %v", eh.Name) } - exec := quoteExec(append(execWrap, eh.Exec...)) + exec := quoteExec(eh.Exec) opts = append(opts, unit.NewUnitOption("Service", typ, exec)) } @@ -430,6 +555,9 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b opts = append(opts, unit.NewUnitOption("Unit", "Requires", InstantiatedPrepareAppUnitName(appName))) opts = append(opts, unit.NewUnitOption("Unit", "After", InstantiatedPrepareAppUnitName(appName))) + opts = append(opts, unit.NewUnitOption("Unit", "Requires", "sysusers.service")) + opts = append(opts, unit.NewUnitOption("Unit", "After", "sysusers.service")) + file, err := os.OpenFile(ServiceUnitPath(p.Root, appName), os.O_WRONLY|os.O_CREATE, 0644) if err != nil { return errwrap.Wrap(errors.New("failed to create service unit file"), err) @@ -574,17 +702,17 @@ func writeShutdownService(p *stage1commontypes.Pod) error { // writeEnvFile creates an environment file for given app name, the minimum // required environment variables by the appc spec will be set to sensible // defaults here if they're not provided by env. -func writeEnvFile(p *stage1commontypes.Pod, env types.Environment, appName types.ACName, privateUsers string) error { +func writeEnvFile(p *stage1commontypes.Pod, env types.Environment, appName types.ACName, privateUsers string, separator byte, envFilePath string) error { ef := bytes.Buffer{} for dk, dv := range defaultEnv { if _, exists := env.Get(dk); !exists { - fmt.Fprintf(&ef, "%s=%s\000", dk, dv) + fmt.Fprintf(&ef, "%s=%s%c", dk, dv, separator) } } for _, e := range env { - fmt.Fprintf(&ef, "%s=%s\000", e.Name, e.Value) + fmt.Fprintf(&ef, "%s=%s%c", e.Name, e.Value, separator) } uidRange := uid.NewBlankUidRange() @@ -592,7 +720,6 @@ func writeEnvFile(p *stage1commontypes.Pod, env types.Environment, appName types return err } - envFilePath := EnvFilePath(p.Root, appName) if err := ioutil.WriteFile(envFilePath, ef.Bytes(), 0644); err != nil { return err } @@ -623,12 +750,9 @@ func PodToSystemd(p *stage1commontypes.Pod, interactive bool, flavor string, pri return nil } -// evaluateAppMountPath tries to resolve symlinks within the path. -// It returns the actual relative path for the given path. -// TODO(yifan): This is a temporary fix for systemd-nspawn not handling symlink mounts well. -// Could be removed when https://github.com/systemd/systemd/issues/2860 is resolved, and systemd -// version is bumped. -func evaluateAppMountPath(appRootfs, path string) (string, error) { +// evaluateSymlinksInsideApp tries to resolve symlinks within the path. +// It returns the actual path relative to the pod for the given path. +func evaluateSymlinksInsideApp(appRootfs, path string) (string, error) { link := appRootfs paths := strings.Split(path, "/") @@ -706,7 +830,11 @@ func appToNspawnArgs(p *stage1commontypes.Pod, ra *schema.RuntimeApp) ([]string, } appRootfs := common.AppRootfsPath(absRoot, appName) - mntPath, err := evaluateAppMountPath(appRootfs, m.Path) + + // TODO(yifan): This is a temporary fix for systemd-nspawn not handling symlink mounts well. + // Could be removed when https://github.com/systemd/systemd/issues/2860 is resolved, and systemd + // version is bumped. + mntPath, err := evaluateSymlinksInsideApp(appRootfs, m.Path) if err != nil { return nil, errwrap.Wrap(fmt.Errorf("could not evaluate path %v", m.Path), err) } diff --git a/stage1/units/units/sysusers.service b/stage1/units/units/sysusers.service new file mode 100644 index 0000000000..f8265def11 --- /dev/null +++ b/stage1/units/units/sysusers.service @@ -0,0 +1,12 @@ +[Unit] +Description=Create /etc/passwd and /etc/group +DefaultDependencies=false +OnFailureJobMode=fail + +[Service] +Type=oneshot +Restart=no +Environment="SYSTEMD_LOG_LEVEL=warning" +ExecStart=/usr/bin/systemd-sysusers +User=0 +Group=0 diff --git a/stage1/usr_from_coreos/manifest.d/systemd.manifest b/stage1/usr_from_coreos/manifest.d/systemd.manifest index 8ba84bfc19..6f9ba518bf 100644 --- a/stage1/usr_from_coreos/manifest.d/systemd.manifest +++ b/stage1/usr_from_coreos/manifest.d/systemd.manifest @@ -20,6 +20,8 @@ bin/systemd-sysusers bin/systemd-tmpfiles bin/systemd-tty-ask-password-agent lib +lib64/libnss_files.so.2 +lib64/libnss_files-2.21.so lib64/ld-2.21.so lib64/ld-linux-x86-64.so.2 lib64/libattr.so diff --git a/stage1/usr_from_src/usr_from_src.mk b/stage1/usr_from_src/usr_from_src.mk index 748fe914a6..c543c91223 100644 --- a/stage1/usr_from_src/usr_from_src.mk +++ b/stage1/usr_from_src/usr_from_src.mk @@ -161,7 +161,6 @@ $(call generate-stamp-rule,$(UFS_SYSTEMD_BUILD_STAMP),$(UFS_SYSTEMD_CLONE_AND_PA --disable-vconsole \ --disable-quotacheck \ --disable-tmpfiles \ - --disable-sysusers \ --disable-randomseed \ --disable-backlight \ --disable-rfkill \ diff --git a/tests/rkt_exec_test.go b/tests/rkt_exec_test.go index 3bfde38594..4891e3a5d8 100644 --- a/tests/rkt_exec_test.go +++ b/tests/rkt_exec_test.go @@ -41,32 +41,32 @@ func TestRunOverrideExec(t *testing.T) { defer ctx.Cleanup() for _, tt := range []struct { - rktCmd string - expectedLine string + rktCmd string + expectedRegex string }{ { // Sanity check - make sure no --exec override prints the expected exec invocation - rktCmd: fmt.Sprintf("%s --insecure-options=image run --mds-register=false %s -- --print-exec", ctx.Cmd(), execImage), - expectedLine: "inspect execed as: /inspect", + rktCmd: fmt.Sprintf("%s --insecure-options=image run --mds-register=false %s -- --print-exec", ctx.Cmd(), execImage), + expectedRegex: "inspect execed as: /inspect", }, { // Now test overriding the entrypoint (which is a symlink to /inspect so should behave identically) - rktCmd: fmt.Sprintf("%s --insecure-options=image run --mds-register=false %s --exec /inspect-link -- --print-exec", ctx.Cmd(), execImage), - expectedLine: "inspect execed as: /inspect-link", + rktCmd: fmt.Sprintf("%s --insecure-options=image run --mds-register=false %s --exec /inspect-link -- --print-exec", ctx.Cmd(), execImage), + expectedRegex: "inspect execed as: /inspect-link", }, { // Test overriding the entrypoint with a relative path - rktCmd: fmt.Sprintf("%s --insecure-options=image run --mds-register=false %s --exec inspect-link-bin -- --print-exec", ctx.Cmd(), execImage), - expectedLine: "inspect execed as: inspect-link-bin", + rktCmd: fmt.Sprintf("%s --insecure-options=image run --mds-register=false %s --exec inspect-link-bin -- --print-exec", ctx.Cmd(), execImage), + expectedRegex: "inspect execed as: .*inspect-link-bin", }, { // Test overriding the entrypoint with a missing app section - rktCmd: fmt.Sprintf("%s --insecure-options=image run --mds-register=false %s --exec /inspect -- --print-exec", ctx.Cmd(), noappImage), - expectedLine: "inspect execed as: /inspect", + rktCmd: fmt.Sprintf("%s --insecure-options=image run --mds-register=false %s --exec /inspect -- --print-exec", ctx.Cmd(), noappImage), + expectedRegex: "inspect execed as: /inspect", }, } { - runRktAndCheckOutput(t, tt.rktCmd, tt.expectedLine, false) + runRktAndCheckRegexOutput(t, tt.rktCmd, tt.expectedRegex) } } From c5a6bf702003011ee10305b96e4b8f5d541a794c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Fri, 22 Apr 2016 16:44:28 +0200 Subject: [PATCH 0158/1304] functional tests: add CAP_SYS_PTRACE to isolator tests It's needed to read files via /proc/self/root. --- tests/rkt_app_isolator_test.go | 7 ++++--- tests/rkt_run_pod_manifest_test.go | 8 ++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/rkt_app_isolator_test.go b/tests/rkt_app_isolator_test.go index 3c36cce8bf..a6e8baff9a 100644 --- a/tests/rkt_app_isolator_test.go +++ b/tests/rkt_app_isolator_test.go @@ -30,12 +30,13 @@ const ( CPUQuota = 800 // milli-cores ) +// We need CAP_SYS_PTRACE to escape the chroot var memoryTest = struct { testName string aciBuildArgs []string }{ `Check memory isolator`, - []string{"--exec=/inspect --print-memorylimit"}, + []string{"--exec=/inspect --print-memorylimit", "--capability=CAP_SYS_PTRACE"}, } var cpuTest = struct { @@ -43,7 +44,7 @@ var cpuTest = struct { aciBuildArgs []string }{ `Check CPU quota`, - []string{"--exec=/inspect --print-cpuquota"}, + []string{"--exec=/inspect --print-cpuquota", "--capability=CAP_SYS_PTRACE"}, } var cgroupsTest = struct { @@ -51,7 +52,7 @@ var cgroupsTest = struct { aciBuildArgs []string }{ `Check cgroup mounts`, - []string{"--exec=/inspect --check-cgroups"}, + []string{"--exec=/inspect --check-cgroups", "--capability=CAP_SYS_PTRACE"}, } func TestAppIsolatorMemory(t *testing.T) { diff --git a/tests/rkt_run_pod_manifest_test.go b/tests/rkt_run_pod_manifest_test.go index 90eff3d349..169971085e 100644 --- a/tests/rkt_run_pod_manifest_test.go +++ b/tests/rkt_run_pod_manifest_test.go @@ -431,6 +431,10 @@ func TestPodManifest(t *testing.T) { Name: "resource/cpu", ValueRaw: rawRequestLimit("100", "100"), }, + { + Name: "os/linux/capabilities-retain-set", + ValueRaw: rawValue(`{"set":["CAP_SYS_PTRACE"]}`), + }, }, }, }, @@ -459,6 +463,10 @@ func TestPodManifest(t *testing.T) { // 4MB. ValueRaw: rawRequestLimit("4194304", "4194304"), }, + { + Name: "os/linux/capabilities-retain-set", + ValueRaw: rawValue(`{"set":["CAP_SYS_PTRACE"]}`), + }, }, }, }, From 38bbafbaeb63676fedc6de6ae45f7dd89ca5459e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Fri, 22 Apr 2016 16:25:05 +0200 Subject: [PATCH 0159/1304] stage1: rename appexec -> enterexec --- Documentation/devel/stage1-implementors-guide.md | 4 ++-- stage1/enter/enter.c | 10 +++++----- stage1/enter_kvm/enter_kvm.go | 6 +++--- stage1/{appexec => enterexec}/elf.h | 0 .../{appexec/appexec.c => enterexec/enterexec.c} | 0 .../appexec.mk => enterexec/enterexec.mk} | 0 stage1/init/common/path.go | 16 ++++++++-------- stage1/init/common/pod.go | 10 +++++----- stage1/secondary-stuff.mk | 2 +- 9 files changed, 24 insertions(+), 24 deletions(-) rename stage1/{appexec => enterexec}/elf.h (100%) rename stage1/{appexec/appexec.c => enterexec/enterexec.c} (100%) rename stage1/{appexec/appexec.mk => enterexec/enterexec.mk} (100%) diff --git a/Documentation/devel/stage1-implementors-guide.md b/Documentation/devel/stage1-implementors-guide.md index 926942fab5..844905e005 100644 --- a/Documentation/devel/stage1-implementors-guide.md +++ b/Documentation/devel/stage1-implementors-guide.md @@ -77,8 +77,8 @@ Stage 1 must write the host PIDs of the pod's process #1 and that process's pare 4. executes the resolved entrypoint relative to `/var/lib/rkt/pods/run/$uuid/stage1/rootfs` In the bundled rkt stage 1, the entrypoint is a statically-linked C program found at `/enter` within the stage 1 ACI rootfs. -This program enters the namespaces of the systemd-nspawn container's PID 1 before executing the `/appexec` program. -`appexec` then `chroot`s into the ACI's rootfs, loading the application and its environment. +This program enters the namespaces of the systemd-nspawn container's PID 1 before executing the `/enterexec` program. +`enterexec` then `chroot`s into the ACI's rootfs, loading the application and its environment. An alternative stage 1 would need to do whatever is appropriate for entering the application environment created by its own `coreos.com/rkt/stage1/run` entrypoint. diff --git a/stage1/enter/enter.c b/stage1/enter/enter.c index 163f7224a9..9d130e59c5 100644 --- a/stage1/enter/enter.c +++ b/stage1/enter/enter.c @@ -131,15 +131,15 @@ int main(int argc, char *argv[]) "Unable to fork"); /* some stuff make the argv->args copy less cryptic */ -#define APPEXEC_ARGV_FWD_OFFSET 8 +#define ENTEREXEC_ARGV_FWD_OFFSET 8 if(child == 0) { char root[PATH_MAX]; char env[PATH_MAX]; - char *args[APPEXEC_ARGV_FWD_OFFSET + argc - optind + 1 /* NULL terminator */]; + char *args[ENTEREXEC_ARGV_FWD_OFFSET + argc - optind + 1 /* NULL terminator */]; int argsind; - /* Child goes on to execute /appexec */ + /* Child goes on to execute /enterexec */ exit_if(snprintf(root, sizeof(root), "/opt/stage2/%s/rootfs", appname) == sizeof(root), @@ -149,7 +149,7 @@ int main(int argc, char *argv[]) "/rkt/env/%s", appname) == sizeof(env), "Env path overflow"); - args[0] = "/appexec"; + args[0] = "/enterexec"; args[1] = root; args[2] = "/"; /* TODO(vc): plumb this into app.WorkingDirectory */ args[3] = env; @@ -157,7 +157,7 @@ int main(int argc, char *argv[]) args[5] = "0"; /* gid */ args[6] = "-e"; /* entering phase */ args[7] = "--"; - argsind = APPEXEC_ARGV_FWD_OFFSET; + argsind = ENTEREXEC_ARGV_FWD_OFFSET; while (optind < argc) args[argsind++] = argv[optind++]; diff --git a/stage1/enter_kvm/enter_kvm.go b/stage1/enter_kvm/enter_kvm.go index 5f6bdd7a76..612c1ddf89 100644 --- a/stage1/enter_kvm/enter_kvm.go +++ b/stage1/enter_kvm/enter_kvm.go @@ -181,11 +181,11 @@ func getPodDefaultIP(workDir string) (string, error) { return "", fmt.Errorf("pod has no default network!") } -func getAppexecArgs() []string { +func getEnterexecArgs() []string { // Documentation/devel/stage1-implementors-guide.md#arguments-1 // also from ../enter/enter.c args := []string{ - "/appexec", + "/enterexec", fmt.Sprintf("/opt/stage2/%s/rootfs", appName), "/", // as in ../enter/enter.c - this should be app.WorkingDirectory fmt.Sprintf("/rkt/env/%s", appName), @@ -230,7 +230,7 @@ func execSSH() error { "-o", "LogLevel=quiet", // do not log minor informations podDefaultIP, } - args = append(args, getAppexecArgs()...) + args = append(args, getEnterexecArgs()...) // this should not return in case of success err = syscall.Exec(sshPath, args, os.Environ()) diff --git a/stage1/appexec/elf.h b/stage1/enterexec/elf.h similarity index 100% rename from stage1/appexec/elf.h rename to stage1/enterexec/elf.h diff --git a/stage1/appexec/appexec.c b/stage1/enterexec/enterexec.c similarity index 100% rename from stage1/appexec/appexec.c rename to stage1/enterexec/enterexec.c diff --git a/stage1/appexec/appexec.mk b/stage1/enterexec/enterexec.mk similarity index 100% rename from stage1/appexec/appexec.mk rename to stage1/enterexec/enterexec.mk diff --git a/stage1/init/common/path.go b/stage1/init/common/path.go index 140d5058cd..51422e04c0 100644 --- a/stage1/init/common/path.go +++ b/stage1/init/common/path.go @@ -43,16 +43,16 @@ func ServiceUnitPath(root string, appName types.ACName) string { return filepath.Join(common.Stage1RootfsPath(root), UnitsDir, ServiceUnitName(appName)) } -// RelEnvFilePathAppexec returns the path to the environment file for the given -// app name relative to the pod's root to be parsed by appexec. -func RelEnvFilePathAppexec(appName types.ACName) string { +// RelEnvFilePathEnterexec returns the path to the environment file for the given +// app name relative to the pod's root to be parsed by enterexec. +func RelEnvFilePathEnterexec(appName types.ACName) string { return filepath.Join(envDir, appName.String()) } -// EnvFilePathAppexec returns the path to the environment file for the given -// app name to be parsed by appexec. -func EnvFilePathAppexec(root string, appName types.ACName) string { - return filepath.Join(common.Stage1RootfsPath(root), RelEnvFilePathAppexec(appName)) +// EnvFilePathEnterexec returns the path to the environment file for the given +// app name to be parsed by enterexec. +func EnvFilePathEnterexec(root string, appName types.ACName) string { + return filepath.Join(common.Stage1RootfsPath(root), RelEnvFilePathEnterexec(appName)) } // RelEnvFilePathSystemd returns the path to the environment file for the given @@ -64,7 +64,7 @@ func RelEnvFilePathSystemd(appName types.ACName) string { // EnvFilePathSystemd returns the path to the environment file for the given // app name to be parsed by systemd. func EnvFilePathSystemd(root string, appName types.ACName) string { - return EnvFilePathAppexec(root, appName) + "-systemd" + return EnvFilePathEnterexec(root, appName) + "-systemd" } // ServiceWantPath returns the systemd default.target want symlink path for the diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index 11ca3ac451..ca4089b761 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -105,7 +105,7 @@ func execEscape(i int, str string) string { // quoteExec returns an array of quoted strings appropriate for systemd execStart usage func quoteExec(exec []string) string { if len(exec) == 0 { - // existing callers prefix {"/appexec", "/app/root", "/work/dir", "/env/file"} so this shouldn't occur. + // existing callers always include at least the binary so this shouldn't occur. panic("empty exec") } @@ -396,16 +396,16 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b env.Set("AC_METADATA_URL", p.MetadataServiceURL) } - // TODO(iaguis): make appexec use the same format as systemd + // TODO(iaguis): make enterexec use the same format as systemd envFilePathSystemd := EnvFilePathSystemd(p.Root, appName) - envFilePathAppexec := EnvFilePathAppexec(p.Root, appName) + envFilePathEnterexec := EnvFilePathEnterexec(p.Root, appName) if err := writeEnvFile(p, env, appName, privateUsers, '\n', envFilePathSystemd); err != nil { return errwrap.Wrap(errors.New("unable to write environment file for systemd"), err) } - if err := writeEnvFile(p, env, appName, privateUsers, '\000', envFilePathAppexec); err != nil { - return errwrap.Wrap(errors.New("unable to write environment file for appexec"), err) + if err := writeEnvFile(p, env, appName, privateUsers, '\000', envFilePathEnterexec); err != nil { + return errwrap.Wrap(errors.New("unable to write environment file for enterexec"), err) } u, g, err := parseUserGroup(p, ra, privateUsers) diff --git a/stage1/secondary-stuff.mk b/stage1/secondary-stuff.mk index 1366d29628..3acf76935c 100644 --- a/stage1/secondary-stuff.mk +++ b/stage1/secondary-stuff.mk @@ -1,6 +1,6 @@ # aci directory should be the last one _S1_SS_SUBDIRS_ := \ - appexec \ + enterexec \ prepare-app \ enter \ enter_kvm \ From a2e11efa763d9979002c608fd06d0a48dd89735a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Mon, 25 Apr 2016 12:53:40 +0200 Subject: [PATCH 0160/1304] usr_from_src: copy libnss from the host Now that we use the "User" and "Group" options of systemd to start applications, we need to have libnss in the image. --- stage1/usr_from_src/libnss.mk | 19 +++++++++++++++++++ stage1/usr_from_src/usr_from_src.mk | 1 + 2 files changed, 20 insertions(+) create mode 100644 stage1/usr_from_src/libnss.mk diff --git a/stage1/usr_from_src/libnss.mk b/stage1/usr_from_src/libnss.mk new file mode 100644 index 0000000000..497a235701 --- /dev/null +++ b/stage1/usr_from_src/libnss.mk @@ -0,0 +1,19 @@ +$(call setup-stamp-file,UFSN_STAMP) +UFSN_LIBNSS_FILES_LINK := libnss_files.so.2 +# TODO: add this functionality to find-so-deps.mk +UFSN_LIBS := $(shell ld --verbose | grep SEARCH_DIR | sed -e 's/SEARCH_DIR("=*\([^"]*\)");*/\1/g') +UFSN_LIB_PATH := $(shell for l in $(UFSN_LIBS); do if [[ -e $${l}/$(UFSN_LIBNSS_FILES_LINK) ]]; then echo $${l}; break; fi; done) + +UFSN_LIBNSS_FILES_PATH := $(UFSN_LIB_PATH)/$(UFSN_LIBNSS_FILES_LINK) +UFSN_LIBNSS_FILES_REALPATH := $(shell realpath $(UFSN_LIBNSS_FILES_PATH)) +UFSN_LIBNSS_FILES := $(shell basename UFSN_LIBNSS_FILES_REALPATH) + +UFSN_LIBNSS_FILES_ON_ACI := $(S1_RF_ACIROOTFSDIR)/usr/lib/$(UFSN_LIBNSS_FILES) + +S1_RF_SECONDARY_STAMPS += $(UFSN_STAMP) +S1_RF_INSTALL_FILES += $(UFSN_LIBNSS_FILES_PATH):$(UFSN_LIBNSS_FILES_ON_ACI):- +S1_RF_INSTALL_SYMLINKS += $(UFSN_LIBNSS_FILES):$(S1_RF_ACIROOTFSDIR)/usr/lib/$(UFSN_LIBNSS_FILES_LINK) + +$(call generate-stamp-rule,$(UFSN_STAMP),$(UFSN_LIBNSS_FILES_ON_ACI), $(S1_RF_ACIROOTFSDIR)/usr/lib/$(UFSN_LIBNSS_FILES_LINK)) + +$(call undefine-namespaces,UFSN) diff --git a/stage1/usr_from_src/usr_from_src.mk b/stage1/usr_from_src/usr_from_src.mk index c543c91223..65cedd1a1f 100644 --- a/stage1/usr_from_src/usr_from_src.mk +++ b/stage1/usr_from_src/usr_from_src.mk @@ -104,6 +104,7 @@ CLEAN_DIRS += \ CLEAN_SYMLINKS += $(S1_RF_ACIROOTFSDIR)/flavor $(call inc-one,bash.mk) +$(call inc-one,libnss.mk) # this makes sure everything is done - ACI rootfs is populated, # clean/deps/filelist are generated From 53eaf22cc5e2aa04c7305804daca4754bc6b6e8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Tue, 26 Apr 2016 11:40:54 +0200 Subject: [PATCH 0161/1304] stage1/init: shift sysusers directory and file Also, refactor privateUsers logic a bit to avoid deserializing the file many times. --- stage1/init/common/pod.go | 48 +++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index ca4089b761..f25b0d98d5 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -270,11 +270,15 @@ func findHostPort(pm schema.PodManifest, name types.ACName) uint { // service files of apps. // If there're several apps defining the same UIDs/GIDs, systemd will take care // of only generating one /etc/{passwd,group} entry -func generateSysusers(p *stage1commontypes.Pod, ra *schema.RuntimeApp, uid_ int, gid_ int) error { +func generateSysusers(p *stage1commontypes.Pod, ra *schema.RuntimeApp, uid_ int, gid_ int, uidRange *uid.UidRange) error { + var toShift []string + app := ra.App appName := ra.Name - if err := os.MkdirAll(path.Join(common.Stage1RootfsPath(p.Root), "usr/lib/sysusers.d"), 0755); err != nil { + sysusersDir := path.Join(common.Stage1RootfsPath(p.Root), "usr/lib/sysusers.d") + toShift = append(toShift, sysusersDir) + if err := os.MkdirAll(sysusersDir, 0755); err != nil { return err } @@ -291,11 +295,20 @@ func generateSysusers(p *stage1commontypes.Pod, ra *schema.RuntimeApp, uid_ int, username := "gen" + strconv.Itoa(uid_) sysusersConf = append(sysusersConf, fmt.Sprintf("u %s %d \"%s\"\n", username, uid_, username)) - if err := ioutil.WriteFile(path.Join(common.Stage1RootfsPath(p.Root), "usr/lib/sysusers.d", ServiceUnitName(appName)+".conf"), - []byte(strings.Join(sysusersConf, "\n")), 0640); err != nil { + sysusersFile := path.Join(common.Stage1RootfsPath(p.Root), "usr/lib/sysusers.d", ServiceUnitName(appName)+".conf") + toShift = append(toShift, sysusersFile) + if err := ioutil.WriteFile(sysusersFile, []byte(strings.Join(sysusersConf, "\n")), 0640); err != nil { return err } + if uidRange.Shift != 0 && uidRange.Count != 0 { + for _, f := range toShift { + if err := os.Chown(f, int(uidRange.Shift), int(uidRange.Shift)); err != nil { + return err + } + } + } + return nil } @@ -400,20 +413,25 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b envFilePathSystemd := EnvFilePathSystemd(p.Root, appName) envFilePathEnterexec := EnvFilePathEnterexec(p.Root, appName) - if err := writeEnvFile(p, env, appName, privateUsers, '\n', envFilePathSystemd); err != nil { + uidRange := uid.NewBlankUidRange() + if err := uidRange.Deserialize([]byte(privateUsers)); err != nil { + return err + } + + if err := writeEnvFile(p, env, appName, uidRange, '\n', envFilePathSystemd); err != nil { return errwrap.Wrap(errors.New("unable to write environment file for systemd"), err) } - if err := writeEnvFile(p, env, appName, privateUsers, '\000', envFilePathEnterexec); err != nil { + if err := writeEnvFile(p, env, appName, uidRange, '\000', envFilePathEnterexec); err != nil { return errwrap.Wrap(errors.New("unable to write environment file for enterexec"), err) } - u, g, err := parseUserGroup(p, ra, privateUsers) + u, g, err := parseUserGroup(p, ra, uidRange) if err != nil { return err } - if err := generateSysusers(p, ra, u, g); err != nil { + if err := generateSysusers(p, ra, u, g, uidRange); err != nil { return errwrap.Wrap(errors.New("unable to generate sysusers"), err) } @@ -587,18 +605,13 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b // 3. a number // 4. a name in reference to /etc/{group,passwd} in the image // See https://github.com/appc/spec/blob/master/spec/aci.md#image-manifest-schema -func parseUserGroup(p *stage1commontypes.Pod, ra *schema.RuntimeApp, privateUsers string) (int, int, error) { +func parseUserGroup(p *stage1commontypes.Pod, ra *schema.RuntimeApp, uidRange *uid.UidRange) (int, int, error) { app := ra.App appName := ra.Name var uid_, gid_ int var err error - uidRange := uid.NewBlankUidRange() - if err := uidRange.Deserialize([]byte(privateUsers)); err != nil { - return -1, -1, errwrap.Wrap(errors.New("unable to deserialize uid range"), err) - } - switch { case app.User == "root": uid_ = 0 @@ -702,7 +715,7 @@ func writeShutdownService(p *stage1commontypes.Pod) error { // writeEnvFile creates an environment file for given app name, the minimum // required environment variables by the appc spec will be set to sensible // defaults here if they're not provided by env. -func writeEnvFile(p *stage1commontypes.Pod, env types.Environment, appName types.ACName, privateUsers string, separator byte, envFilePath string) error { +func writeEnvFile(p *stage1commontypes.Pod, env types.Environment, appName types.ACName, uidRange *uid.UidRange, separator byte, envFilePath string) error { ef := bytes.Buffer{} for dk, dv := range defaultEnv { @@ -715,11 +728,6 @@ func writeEnvFile(p *stage1commontypes.Pod, env types.Environment, appName types fmt.Fprintf(&ef, "%s=%s%c", e.Name, e.Value, separator) } - uidRange := uid.NewBlankUidRange() - if err := uidRange.Deserialize([]byte(privateUsers)); err != nil { - return err - } - if err := ioutil.WriteFile(envFilePath, ef.Bytes(), 0644); err != nil { return err } From 3504f9822aa14524308492d744e2f87ea5b8774c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Tue, 26 Apr 2016 12:30:11 +0200 Subject: [PATCH 0162/1304] stage1/init: review changes --- stage1/init/common/pod.go | 78 ++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index f25b0d98d5..4f0b88e290 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -316,36 +316,31 @@ func generateSysusers(p *stage1commontypes.Pod, ra *schema.RuntimeApp, uid_ int, // given binary. It will look up on "paths" (also relative to the app rootfs) // and evaluate possible symlinks to check if the resulting path is actually // executable. -func lookupPathInsideApp(bin string, paths string, appRootfs string) (string, error) { +func lookupPathInsideApp(bin string, paths string, appRootfs string, workDir string) (string, error) { pathsArr := filepath.SplitList(paths) var appPathsArr []string for _, p := range pathsArr { + if !filepath.IsAbs(p) { + p = filepath.Join(workDir, p) + } appPathsArr = append(appPathsArr, filepath.Join(appRootfs, p)) } for _, path := range appPathsArr { binPath := filepath.Join(path, bin) - binAbsPath, err := filepath.Abs(binPath) - if err != nil { - return "", fmt.Errorf("unable to find absolute path for %s", binPath) - } - relPath := strings.TrimPrefix(binAbsPath, appRootfs) - d, err := os.Lstat(binAbsPath) - if err != nil { - continue - } - binRealPath, err := evaluateSymlinksInsideApp(appRootfs, relPath) + stage2Path := strings.TrimPrefix(binPath, appRootfs) + binRealPath, err := evaluateSymlinksInsideApp(appRootfs, stage2Path) if err != nil { - return "", errwrap.Wrap(fmt.Errorf("could not evaluate path %v", binAbsPath), err) + return "", errwrap.Wrap(fmt.Errorf("could not evaluate path %v", stage2Path), err) } binRealPath = filepath.Join(appRootfs, binRealPath) - d, err = os.Stat(binRealPath) + d, err := os.Stat(binRealPath) if err != nil { continue } // Check the executable bit, inspired by os.exec.LookPath() if m := d.Mode(); !m.IsDir() && m&0111 != 0 { // The real path is executable, return the path relative to the app - return relPath, nil + return stage2Path, nil } } return "", fmt.Errorf("unable to find %q in %q", bin, paths) @@ -353,38 +348,48 @@ func lookupPathInsideApp(bin string, paths string, appRootfs string) (string, er // appSearchPaths returns a list of paths where we should search for // non-absolute exec binaries -func appSearchPaths(p *stage1commontypes.Pod, appRootfs string, app types.App) []string { +func appSearchPaths(p *stage1commontypes.Pod, workDir string, app types.App) []string { appEnv := app.Environment if imgPath, ok := appEnv.Get("PATH"); ok { return strings.Split(imgPath, ":") } - // emulate exec(3) behavior, first check pod's directory and then the list - // of directories returned by confstr(_CS_PATH). That's typically + // emulate exec(3) behavior, first check working directory and then the + // list of directories returned by confstr(_CS_PATH). That's typically // "/bin:/usr/bin" so let's use that. - return []string{appRootfs, "/bin", "/usr/bin"} + return []string{workDir, "/bin", "/usr/bin"} } // findBinPath takes a binary path and returns a the absolute path of the // binary relative to the app rootfs. This can be passed to ExecStart on the // app's systemd service file directly. -func findBinPath(p *stage1commontypes.Pod, appName types.ACName, app types.App, bin string) (string, error) { - absRoot, err := filepath.Abs(p.Root) - if err != nil { - return "", errwrap.Wrap(errors.New("could not get pod's root absolute path"), err) - } - - appRootfs := common.AppRootfsPath(absRoot, appName) - appPathDirs := appSearchPaths(p, appRootfs, app) - appPath := strings.Join(appPathDirs, ":") +func findBinPath(p *stage1commontypes.Pod, appName types.ACName, app types.App, workDir string, bin string) (string, error) { + var binPath string + switch { + // absolute path, just use it + case filepath.IsAbs(bin): + binPath = bin + // non-absolute path containing a slash, look in the working dir + case strings.Contains(bin, "/"): + binPath = filepath.Join(workDir, bin) + // filename, search in the app's $PATH + default: + absRoot, err := filepath.Abs(p.Root) + if err != nil { + return "", errwrap.Wrap(errors.New("could not get pod's root absolute path"), err) + } + appRootfs := common.AppRootfsPath(absRoot, appName) + appPathDirs := appSearchPaths(p, workDir, app) + appPath := strings.Join(appPathDirs, ":") - binPath, err := lookupPathInsideApp(bin, appPath, appRootfs) - if err != nil { - return "", errwrap.Wrap(fmt.Errorf("error looking up %q", bin), err) + binPath, err = lookupPathInsideApp(bin, appPath, appRootfs, workDir) + if err != nil { + return "", errwrap.Wrap(fmt.Errorf("error looking up %q", bin), err) + } } - return strings.TrimPrefix(binPath, appRootfs), nil + return binPath, nil } // appToSystemd transforms the provided RuntimeApp+ImageManifest into systemd units @@ -435,12 +440,9 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b return errwrap.Wrap(errors.New("unable to generate sysusers"), err) } - binPath := app.Exec[0] - if !filepath.IsAbs(binPath) { - binPath, err = findBinPath(p, appName, *app, binPath) - if err != nil { - return err - } + binPath, err := findBinPath(p, appName, *app, workDir, app.Exec[0]) + if err != nil { + return err } var supplementaryGroups []string @@ -759,7 +761,7 @@ func PodToSystemd(p *stage1commontypes.Pod, interactive bool, flavor string, pri } // evaluateSymlinksInsideApp tries to resolve symlinks within the path. -// It returns the actual path relative to the pod for the given path. +// It returns the actual path relative to the app rootfs for the given path. func evaluateSymlinksInsideApp(appRootfs, path string) (string, error) { link := appRootfs From ecfe030460fea3bef4a4b06766b1594ae8de046f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Tue, 26 Apr 2016 15:09:56 +0200 Subject: [PATCH 0163/1304] pkg,stage1: refactor exec bit check to fileutil.IsExecutable() --- pkg/fileutil/fileutil.go | 11 +++++++++++ stage1/init/common/pod.go | 8 ++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/pkg/fileutil/fileutil.go b/pkg/fileutil/fileutil.go index c22d8ae7a6..15c5774cd4 100644 --- a/pkg/fileutil/fileutil.go +++ b/pkg/fileutil/fileutil.go @@ -225,3 +225,14 @@ func DirSize(path string) (int64, error) { return 0, nil } + +// IsExecutable checks if the given path points to an executable file by +// checking the executable bit. Inspired by os.exec.LookPath() +func IsExecutable(path string) bool { + d, err := os.Stat(path) + if err == nil { + m := d.Mode() + return !m.IsDir() && m&0111 != 0 + } + return false +} diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index 4f0b88e290..700144da87 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -42,6 +42,7 @@ import ( "github.com/coreos/rkt/common" "github.com/coreos/rkt/common/cgroup" + "github.com/coreos/rkt/pkg/fileutil" "github.com/coreos/rkt/pkg/uid" ) @@ -333,12 +334,7 @@ func lookupPathInsideApp(bin string, paths string, appRootfs string, workDir str return "", errwrap.Wrap(fmt.Errorf("could not evaluate path %v", stage2Path), err) } binRealPath = filepath.Join(appRootfs, binRealPath) - d, err := os.Stat(binRealPath) - if err != nil { - continue - } - // Check the executable bit, inspired by os.exec.LookPath() - if m := d.Mode(); !m.IsDir() && m&0111 != 0 { + if fileutil.IsExecutable(binRealPath) { // The real path is executable, return the path relative to the app return stage2Path, nil } From 5385e8658342f0d4a83bd44cf1906da792704f66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Tue, 26 Apr 2016 17:56:47 +0200 Subject: [PATCH 0164/1304] stage1: sort things --- stage1/secondary-stuff.mk | 10 +++++----- .../usr_from_coreos/manifest.d/journald.manifest | 6 +++--- stage1/usr_from_coreos/manifest.d/systemd.manifest | 14 +++++++------- stage1/usr_from_kvm/manifest.d/sshd.manifest | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/stage1/secondary-stuff.mk b/stage1/secondary-stuff.mk index 3acf76935c..e80be4ec8b 100644 --- a/stage1/secondary-stuff.mk +++ b/stage1/secondary-stuff.mk @@ -1,13 +1,13 @@ # aci directory should be the last one _S1_SS_SUBDIRS_ := \ - enterexec \ - prepare-app \ enter \ enter_kvm \ - net-plugins \ - net \ - init \ + enterexec \ gc \ + init \ + net \ + net-plugins \ + prepare-app \ reaper \ units \ aci diff --git a/stage1/usr_from_coreos/manifest.d/journald.manifest b/stage1/usr_from_coreos/manifest.d/journald.manifest index 48541b712b..5db0061c21 100644 --- a/stage1/usr_from_coreos/manifest.d/journald.manifest +++ b/stage1/usr_from_coreos/manifest.d/journald.manifest @@ -1,5 +1,5 @@ +lib64/systemd/system/syslog.socket +lib64/systemd/system/systemd-journald-audit.socket +lib64/systemd/system/systemd-journald-dev-log.socket lib64/systemd/system/systemd-journald.service lib64/systemd/system/systemd-journald.socket -lib64/systemd/system/systemd-journald-dev-log.socket -lib64/systemd/system/systemd-journald-audit.socket -lib64/systemd/system/syslog.socket diff --git a/stage1/usr_from_coreos/manifest.d/systemd.manifest b/stage1/usr_from_coreos/manifest.d/systemd.manifest index 6f9ba518bf..fca30bbdfd 100644 --- a/stage1/usr_from_coreos/manifest.d/systemd.manifest +++ b/stage1/usr_from_coreos/manifest.d/systemd.manifest @@ -20,8 +20,6 @@ bin/systemd-sysusers bin/systemd-tmpfiles bin/systemd-tty-ask-password-agent lib -lib64/libnss_files.so.2 -lib64/libnss_files-2.21.so lib64/ld-2.21.so lib64/ld-linux-x86-64.so.2 lib64/libattr.so @@ -34,10 +32,10 @@ lib64/libblkid.so lib64/libblkid.so.1 lib64/libblkid.so.1.1.0 lib64/libc-2.21.so +lib64/libc.so.6 lib64/libcap.so lib64/libcap.so.2 lib64/libcap.so.2.24 -lib64/libc.so.6 lib64/libgcc_s.so lib64/libgcc_s.so.1 lib64/libgcrypt.so @@ -46,12 +44,12 @@ lib64/libgcrypt.so.20.0.3 lib64/libgpg-error.so lib64/libgpg-error.so.0 lib64/libgpg-error.so.0.10.0 -lib64/libitm.so -lib64/libitm.so.1 -lib64/libitm.so.1.0.0 lib64/libip4tc.so lib64/libip4tc.so.0 lib64/libip4tc.so.0.1.0 +lib64/libitm.so +lib64/libitm.so.1 +lib64/libitm.so.1.0.0 lib64/libkmod.so lib64/libkmod.so.2 lib64/libkmod.so.2.2.11 @@ -61,6 +59,8 @@ lib64/liblzma.so.5.0.8 lib64/libmount.so lib64/libmount.so.1 lib64/libmount.so.1.1.0 +lib64/libnss_files-2.21.so +lib64/libnss_files.so.2 lib64/libpcre.so lib64/libpcre.so.1 lib64/libpcre.so.1.2.4 @@ -81,6 +81,7 @@ lib64/libuuid.so.1.3.0 lib64/libz.so lib64/libz.so.1 lib64/libz.so.1.2.8 +lib64/systemd/system-sleep lib64/systemd/systemd lib64/systemd/systemd-ac-power lib64/systemd/systemd-activate @@ -112,5 +113,4 @@ lib64/systemd/systemd-udevd lib64/systemd/systemd-update-done lib64/systemd/systemd-update-utmp lib64/systemd/systemd-vconsole-setup -lib64/systemd/system-sleep lib64/systemd/user-generators diff --git a/stage1/usr_from_kvm/manifest.d/sshd.manifest b/stage1/usr_from_kvm/manifest.d/sshd.manifest index 3116bd7011..eece908803 100644 --- a/stage1/usr_from_kvm/manifest.d/sshd.manifest +++ b/stage1/usr_from_kvm/manifest.d/sshd.manifest @@ -1,7 +1,6 @@ -bin/chown bin/chmod +bin/chown bin/ssh-keygen -sbin/sshd lib64/libcrypt-2.21.so lib64/libcrypt.so.1 lib64/libcrypto.so.1.0.0 @@ -17,3 +16,4 @@ lib64/libutil-2.21.so lib64/libutil.so.1 lib64/libz.so.1 lib64/libz.so.1.2.8 +sbin/sshd From ef65bab1f1db7c6c5686acba1a1a1334cf63f271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Tue, 26 Apr 2016 18:00:58 +0200 Subject: [PATCH 0165/1304] stage1/init: mention spec issue about default capabilities --- stage1/init/common/pod.go | 1 + 1 file changed, 1 insertion(+) diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index 700144da87..52532f9b46 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -63,6 +63,7 @@ var ( // appDefaultCapabilities defines a restricted set of capabilities given to // apps by default. + // See https://github.com/appc/spec/issues/598 appDefaultCapabilities, _ = types.NewLinuxCapabilitiesRetainSet([]string{ "CAP_AUDIT_WRITE", "CAP_CHOWN", From 8286aaf08982ace0ae9a228d15377c31b1df0804 Mon Sep 17 00:00:00 2001 From: Dalton Hubble Date: Tue, 26 Apr 2016 18:46:51 -0700 Subject: [PATCH 0166/1304] Documentation: Fix setup-data-dir.sh script location --- Documentation/trying-out-rkt.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/trying-out-rkt.md b/Documentation/trying-out-rkt.md index bd097e4480..138dbe6f3c 100644 --- a/Documentation/trying-out-rkt.md +++ b/Documentation/trying-out-rkt.md @@ -27,7 +27,7 @@ rkt ships with a simple script that can help set up the appropriate permissions ``` sudo groupadd rkt export WHOAMI=$(whoami); sudo gpasswd -a $WHOAMI rkt -sudo ./scripts/setup-data-dir.sh +sudo ./dist/scripts/setup-data-dir.sh ``` Trust the signing key for etcd images. This must be run as root as access to the keystore is restricted: From 00679dd3a52cebec0ee66793ff19532eea841451 Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Wed, 27 Apr 2016 12:20:18 +0200 Subject: [PATCH 0167/1304] tests: prepare to use go build constraints for test selection --- tests/functional.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional.mk b/tests/functional.mk index 4d335c5a05..a866e2c5fc 100644 --- a/tests/functional.mk +++ b/tests/functional.mk @@ -77,11 +77,11 @@ CLEAN_SYMLINKS += \ $(call forward-vars,$(FTST_FUNCTIONAL_TESTS_STAMP), \ FTST_RKT_PATH ACTOOL FTST_IMAGE FTST_EMPTY_IMAGE FTST_TEST_TMP ABS_GO \ FTST_INSPECT_BINARY GO_ENV GO_TEST_FUNC_ARGS REPO_PATH \ - FTST_ACE_MAIN_IMAGE FTST_ACE_SIDEKICK_IMAGE FTST_SS1_IMAGE) + FTST_ACE_MAIN_IMAGE FTST_ACE_SIDEKICK_IMAGE RKT_STAGE1_DEFAULT_FLAVOR FTST_SS1_IMAGE) $(FTST_FUNCTIONAL_TESTS_STAMP): $(FTST_IMAGE) $(FTST_EMPTY_IMAGE) $(ACTOOL_STAMP) $(RKT_STAMP) $(FTST_ACE_MAIN_IMAGE) $(FTST_ACE_SIDEKICK_IMAGE) $(FTST_SS1_STAMP) | $(FTST_TEST_TMP) $(FTST_RKT_PATH) $(FTST_STAGE1_ALL_FLAVOR_SYMLINKS) $(VQ) \ $(call vb,vt,GO TEST,$(REPO_PATH)/tests) \ - sudo RKT="$(FTST_RKT_PATH)" ACTOOL="$(ACTOOL)" RKT_INSPECT_IMAGE="$(FTST_IMAGE)" RKT_EMPTY_IMAGE="$(FTST_EMPTY_IMAGE)" RKT_ACE_MAIN_IMAGE=$(FTST_ACE_MAIN_IMAGE) RKT_ACE_SIDEKICK_IMAGE=$(FTST_ACE_SIDEKICK_IMAGE) FUNCTIONAL_TMP="$(FTST_TEST_TMP)" INSPECT_BINARY="$(FTST_INSPECT_BINARY)" STUB_STAGE1="$(FTST_SS1_IMAGE)" $(GO_ENV) "$(ABS_GO)" test -timeout 30m -v $(GO_TEST_FUNC_ARGS) $(REPO_PATH)/tests + sudo RKT_STAGE1_DEFAULT_FLAVOR="$(RKT_STAGE1_DEFAULT_FLAVOR)" RKT="$(FTST_RKT_PATH)" ACTOOL="$(ACTOOL)" RKT_INSPECT_IMAGE="$(FTST_IMAGE)" RKT_EMPTY_IMAGE="$(FTST_EMPTY_IMAGE)" RKT_ACE_MAIN_IMAGE=$(FTST_ACE_MAIN_IMAGE) RKT_ACE_SIDEKICK_IMAGE=$(FTST_ACE_SIDEKICK_IMAGE) FUNCTIONAL_TMP="$(FTST_TEST_TMP)" INSPECT_BINARY="$(FTST_INSPECT_BINARY)" STUB_STAGE1="$(FTST_SS1_IMAGE)" $(GO_ENV) "$(ABS_GO)" test -tags $(RKT_STAGE1_DEFAULT_FLAVOR) -timeout 30m -v $(GO_TEST_FUNC_ARGS) $(REPO_PATH)/tests $(call forward-vars,$(FTST_IMAGE), \ FTST_IMAGE_ROOTFSDIR ACTOOL FTST_IMAGE_DIR) From ae1a61b04e5cbf4f74cb055db8d397f5329b89b9 Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Wed, 27 Apr 2016 12:20:48 +0200 Subject: [PATCH 0168/1304] tests: add interface to wrap test execution --- tests/testutils/test.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/testutils/test.go diff --git a/tests/testutils/test.go b/tests/testutils/test.go new file mode 100644 index 0000000000..fde9e7e987 --- /dev/null +++ b/tests/testutils/test.go @@ -0,0 +1,32 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package testutils + +import "testing" + +// Test is the interface that wraps a test. +// It is meant to be used for parametrized test fixtures. +// +// Execute executes the test. +type Test interface { + Execute(*testing.T) +} + +// TestFunc is a functional adapter to allow ordinary functions as test wrappers. +type TestFunc func(*testing.T) + +func (f TestFunc) Execute(t *testing.T) { + f(t) +} From 53e9ba6878806df5b77c68c1043f9b365ae93610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 20 Apr 2016 17:14:29 +0200 Subject: [PATCH 0169/1304] scripts: generate a Debian Sid ACI instead of using the Docker hub Instead of getting the Debian Sid image from the Docker hub (we don't check its signature) we generate a Debian Sid ACI using debootstrap. This is an intermediate step to having the rkt builder hosted by CoreOS with a proper official signature. --- scripts/acbuild-rkt-builder.sh | 55 +++++++++++++--------------------- 1 file changed, 20 insertions(+), 35 deletions(-) diff --git a/scripts/acbuild-rkt-builder.sh b/scripts/acbuild-rkt-builder.sh index 135f2bc220..d656b1f68b 100755 --- a/scripts/acbuild-rkt-builder.sh +++ b/scripts/acbuild-rkt-builder.sh @@ -16,51 +16,37 @@ fi MODIFY=${MODIFY:-""} FLAGS=${FLAGS:-""} -IMG=${IMG:-"debian"} -IMG_VERSION=${IMG_VERSION:-"sid"} -DOCKERIMG="$IMG:$IMG_VERSION" -ACI_FILE=${ACI_FILE:-"./library-$IMG-$IMG_VERSION.aci"} -OUT_ACI=${OUT_ACI:-"rkt-builder.aci"} -ACI_NAME=${ACI_NAME:-"coreos.com/rkt/builder"} +IMG_NAME="coreos.com/rkt/builder" +IMG_VERSION=${VERSION:-"v1.4.0+git"} +ACI_FILE=rkt-builder.aci BUILDDIR=/opt/build-rkt SRC_DIR=/opt/rkt ACI_GOPATH=/go -VERSION=${VERSION:-"v1.4.0+git"} -echo "Version: $VERSION" -echo "Building $ACI_FILE" - -check_tool acbuild -check_tool docker2aci -# check_tool actool - -if [ ! -f "$ACI_FILE" ]; then - docker2aci "docker://$DOCKERIMG" - # These base images don't always come with valid values - # actool patch-manifest -user 0 -group 0 --name $IMG-$IMG_VERSION --exec /bin/bash --replace $ACI_FILE -fi +DEBIAN_SID_DEPS="ca-certificates gcc libc6-dev make automake wget git golang-go cpio squashfs-tools realpath autoconf file xz-utils patch bc locales libacl1-dev libssl-dev" acbuildend () { export EXIT=$?; - acbuild --debug end && exit $EXIT; + acbuild --debug end && rm -rf rootfs && exit $EXIT; } -# If modify is specified, pass the modify flag to each command and don't use -# acbuild begin, write or end otherwise build with a context, and setup a trap -# to handle failures, -if [ "$MODIFY" ]; then - FLAGS="--modify $MODIFY $FLAGS" - OUT_ACI=$MODIFY -else - acbuild $FLAGS begin "$ACI_FILE" - trap acbuildend EXIT -fi +echo "Generating debian sid tree" + +mkdir rootfs +debootstrap --force-check-gpg --variant=minbase --components=main --include="${DEBIAN_SID_DEPS}" sid rootfs http://httpredir.debian.org/debian/ +rm -rf rootfs/var/cache/apt/archives/* + +echo "Version: ${IMG_VERSION}" +echo "Building ${ACI_FILE}" + +acbuild begin ./rootfs +trap acbuildend EXIT -acbuild $FLAGS set-name $ACI_NAME -acbuild $FLAGS label add version $VERSION +acbuild $FLAGS set-name $IMG_NAME +acbuild $FLAGS label add version $IMG_VERSION acbuild $FLAGS set-user 0 acbuild $FLAGS set-group 0 -acbuild $FLAGS environment add OS_VERSION $IMG_VERSION +acbuild $FLAGS environment add OS_VERSION sid acbuild $FLAGS environment add GOPATH $ACI_GOPATH acbuild $FLAGS environment add BUILDDIR $BUILDDIR acbuild $FLAGS environment add SRC_DIR $SRC_DIR @@ -68,9 +54,8 @@ acbuild $FLAGS mount add build-dir $BUILDDIR acbuild $FLAGS mount add src-dir $SRC_DIR acbuild $FLAGS set-working-dir $SRC_DIR acbuild $FLAGS copy "$(dirname $0)" /scripts -acbuild $FLAGS run /bin/bash "/scripts/install-deps-$IMG-$IMG_VERSION.sh" acbuild $FLAGS run /bin/bash /scripts/install-appc-spec.sh acbuild $FLAGS set-exec /bin/bash /scripts/build-rkt.sh if [ -z "$MODIFY" ]; then - acbuild $FLAGS write --overwrite $OUT_ACI + acbuild write --overwrite $ACI_FILE fi From feca930dd08fdab178aafad7409bf6fd477a71d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 20 Apr 2016 17:50:57 +0200 Subject: [PATCH 0170/1304] Documentation: update rkt-in-rkt docs --- Documentation/rkt-build-rkt.md | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/Documentation/rkt-build-rkt.md b/Documentation/rkt-build-rkt.md index 71e3d405bf..010c989382 100644 --- a/Documentation/rkt-build-rkt.md +++ b/Documentation/rkt-build-rkt.md @@ -1,35 +1,19 @@ # coreos.com/rkt/builder This container contains all build-time dependencies in order to build rkt. -It currently can be built in one of two flavors: _Debian Sid_ or _Fedora 22_. +It currently can be built in: _Debian Sid_. All commands assume you are running them in your local git checkout of rkt. ## Building coreos.com/rkt/builder using acbuild Requirements: -- Go or `docker2aci` - rkt -The file `scripts/acbuild-rkt-builder.sh` contains a simple bash script which will download a base docker image which is then converted into an ACI. -Once the ACI has been downloaded, the manifest is patched. -Next acbuild is run which creates an ACI that has all the required build dependencies for compiling `rkt`. - -If you want to change the base OS you can set it by using one of the following sets of variables: - -``` -export IMG=fedora -export IMGVERSION=22 -``` - -Or (default): - -``` -export IMG=debian -export IMGVERSION=sid -``` +The file `scripts/acbuild-rkt-builder.sh` contains a simple bash script which generates a Debian Sid tree and creates an ACI ready to build `rkt`. Running the build script: + ``` ./scripts/acbuild-rkt-builder.sh ``` @@ -41,6 +25,7 @@ Once that is finished there should be a `rkt-builder.aci` file in the current di Now that `rkt-builder.aci` has been built you have a container which will compile `rkt`. Put it into the rkt CAS: + ``` rkt fetch --insecure-options=image ./rkt-builder.aci ``` @@ -63,6 +48,7 @@ You should see rkt building in your rkt container, and once it's finished, the o # Building rkt in rkt one liners (sort of) If you don't want to bother with acbuild and want a simple one liner that uses rkt to build rkt, you can install all the dependencies and build rkt from source in one line using bash in a container. +Note that this fetches images from the Docker hub and doesn't check signatures. Set `SRC_DIR` to the absolute path to your git checkout of `rkt`: From 07caad3e48e4ec37a7015886111824b1324f54c3 Mon Sep 17 00:00:00 2001 From: Simone Gotti Date: Wed, 27 Apr 2016 12:35:22 +0200 Subject: [PATCH 0171/1304] functional tests: don't use gnupg for signing images Some distros only provide gnupg2 (while others provides both version) and the `gpg` command is a symlink to `gpg2`. With gnupg >= 2.1 signing test images fails due to changes in the secring handling (see https://www.gnupg.org/faq/whats-new-in-2.1.html#nosecring) To make tests work with gnupg >= 2.1 the `runSignImage` function should be changed to do these steps: * Create a temporary gnupg home (with secure permissions like 700). * Copy the secring.gpg file to that gnupg home. * Call gpg with this command line: `gpg --homedir %s --default-key %s --output %s --detach-sig %s` If the gpg command is provided by gnupg2 it'll convert the secring to the format required by the gpg-agent in the `private-keys-v1.d` directory. Additionally gpg2 will spawn a gpg-agent to handle the private keys and there'll be an additional problem when the path to the gpg-agent socket files is too long (see http://comments.gmane.org/gmane.comp.encryption.gpg.devel/21073), so it'll require a gnupg home inside a short path. To avoid all of this, since the functional tests only require gpg for signing tests images this patch uses the `golang.org/x/crypto/openpgp` package. Fixes #2424. --- tests/pubring.gpg | Bin 2479 -> 0 bytes tests/rkt_tests.go | 49 +++++++++++++++++++++++++++++++++++++-------- 2 files changed, 41 insertions(+), 8 deletions(-) delete mode 100644 tests/pubring.gpg diff --git a/tests/pubring.gpg b/tests/pubring.gpg deleted file mode 100644 index 74e068a410bc893426c0f6af3511c0e85c3f2a83..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2479 zcmajfc{~%2AII@+h9PuJ$~jU(%{6jMmKwR)R}*D3=h%$O9L*>UC9>R6XwKY)MUKc_ zj-eu&BSbnczJRh%Apdc8{2gn6N0CiAj_6r{Sfsc2{ z20#qGyCf!IYkT{Z3-5FKrzvV(v(*pzW-8F$ z0YB5x7OsA&!6x_kCAG+lE1-yA_VAN+cg=$a4+H?c&9^2Cm+FVa&%B8~$cefFuNpN< zVRrh+Hgg+}Q)R6#>NE*;@L6M>zRoo$51RS9nZmfY25}x|Y2`}_xd?Nxr!nghVyoGI z(uA&re&ibct~&u@lps{LG3%8&!5Y+vunlth6zDj#M!Jgv>;eLSRTgG=3e1g2h6UjL z13Z1*VMJd71$Ov%R|S}!H=Y9jF^2zZ4F5Skjt_M4ArbI!9MQ*s4%7ng0fGRs+@POt z28na=2=GC8xj;N35D*`~0C+Em3kZ?|f<(gr{CqnPvR`hz99=SsSmxc5N!LY2HJIld zE7v~K)AdOC98=xf;k8HpUKD}7s=q7_zb@ig;L^(=E0RAS(v;ea>28RmhB=j%s0=z{ z4aC;GdfDhv;VKMLVLp3egu`P?9`=<%7FKA_b9yG0%b9c=x9UIaG=9+!lA-Gap&FZXGN*M^iRr?>FPvN4I(YMqg;M))j<2T{Hv&@pRP?jPO^LX@Zf{As z6nm&1!B9qZxSuLy`Mzc3{;a6dw3}OPkIQl&{?NGpjIm{HIx@D<2`_m1u~=3dXNr?V zTu25mr^~}P<7nwRoP4c#t(G1+J$XVp?%hnp*MAC+Bhu>)h6`>fp zY{(quE6`3YM4A@;rL`kxn=uavJyE>pb$d=LXG>@Bt#3TEawY2*PdZQk4R~mQ39;aL6!VipkScwxzO9<-M%v2aZ9)7Fd z)*PirzXBWh<`OYWJ-|Lc1~(13(fwebSO&RUAkhcYojq4AUVsro>oP6cT?xJ=C9pB_ z2g#pmQh%x`OOg5!wVBoo%f+MDB1}rzc}3yH_<{PJHKrcz?)!uPsI#H;4NTZnOvu9S zxEV{9sJec=j0r+))@(aP1;{xOE0XWE)Sk+^A!T6Mb8Yal$;C|9qM`Hp2F!%A<4eQf0{P3ynbY$J{^L28c{$k))uwK_#l9$M1#mqo(^n$+ z1riCKwxM%n(UpYjXZ-|PYtr!x!`$i*&P^NcDHx)D_t8+fF}ute3|pfGzE~W9tsZ48 z#o6uBr{j{2EM$u7YHx|?I6#~3MJgAN`R}DgwgpvwR%3b{1~+BBlV+Cnkm%OJARdmnta+`d7PUb;|f>Mj}l3(N{lKTi*pXu z69ujmIaSqOyqTKT6sxCE8E-VsNs&q0F2Bw(cm=OFaga~IiapZvpq##}!NguyYcZ-4 z>J}_49`G3a4Am6Odgdt{pxo~l1{Hsre_J}qWZg04v-uu&fo1v0tr5V#%l4Pi*4<-I zMyv!LdkM@W)F3XNWh^lK>@T@6??)jT8sc|$2@^)s&TX6Pw-;r3WyERu@Vj2KndMB- z_HuTU6&WjadD=K1$eYN=?$8B`9Z9YaX?{em63fa!+H5#NqL`FN5bE|5R6Yu^qskmP z6l*JOk_LH}&7oqMq}8eMX%wyiyQ^IZO)=08HJC=c9KCZb#Hu0hwQy#3ZvzX83!5hu zxLF*^Dp#d-)M1018yf7SSPWz?8%WhJ+1Uw~hGSH<9QR!gzdezFwC0A)kW3cGKJcdX z3oCq~eqH*8dzf5!T3_x(Vq`Mv7WMrDjxI*NDB~+_tG?EJ=F$!Im5%=@+b>SP%J#RK z^F-b)7$UxEz+^>|gbka%TYMiDT#70Ztv(Z0Wl6lyqX&xa>5K{P{dD3gu*qoH>T03M zLdk1GQmLqQ;M3Eu%Dj1=hJ3#|Np71TLxADjUeK85r%pe9rX%Gwa29}xl9W9-2reTT zM7>kKa=+~1t7jYijFm6})+N7|4YfyWX)*%Mks7X=MTx*lMqF>K+W6>OxuH5={pOoy z$2X)(%&qKEb^W#UUFW#(&aD|h$Q{ycFN9}WjB0~fL=P?Ny<(puZ`WxcMS*4V$?7P6 zXveYWJoUj+^gZi!{5)GEf@0Bzj-epm_7qn)j(+lwhi^(}?kx8hKQOV&mRM!|fCcXK H_^IYkPBLos diff --git a/tests/rkt_tests.go b/tests/rkt_tests.go index a85740f28a..73a23077f2 100644 --- a/tests/rkt_tests.go +++ b/tests/rkt_tests.go @@ -33,6 +33,8 @@ import ( "testing" "time" + "golang.org/x/crypto/openpgp" + "github.com/appc/spec/schema" "github.com/appc/spec/schema/types" "github.com/coreos/gexpect" @@ -628,10 +630,8 @@ func serverHandler(t *testing.T, server *taas.Server) { } } -func runSignImage(t *testing.T, imageFile string, keyIndex int) string { - ascFile := fmt.Sprintf("%s.asc", imageFile) - - // keys stored in tests/secring.gpg, tests/pubring.gpg, tests/key1.gpg, tests/key2.gpg +func runSignImage(t *testing.T, imagePath string, keyIndex int) string { + // keys stored in tests/secring.gpg. keyFingerprint := "" switch keyIndex { case 1: @@ -642,10 +642,43 @@ func runSignImage(t *testing.T, imageFile string, keyIndex int) string { panic("unknown key") } - cmd := fmt.Sprintf("gpg --no-default-keyring --secret-keyring ./secring.gpg --keyring ./pubring.gpg --default-key %s --output %s --detach-sig %s", - keyFingerprint, ascFile, imageFile) - spawnAndWaitOrFail(t, cmd, 0) - return ascFile + secringFile, err := os.Open("./secring.gpg") + if err != nil { + t.Fatalf("Cannot open secring.gpg file: %v", err) + } + defer secringFile.Close() + + entityList, err := openpgp.ReadKeyRing(secringFile) + if err != nil { + t.Fatalf("Failed to read secring.gpg file: %v", err) + } + + var signingEntity *openpgp.Entity + for _, entity := range entityList { + if entity.PrivateKey.KeyIdShortString() == keyFingerprint { + signingEntity = entity + } + } + + imageFile, err := os.Open(imagePath) + if err != nil { + t.Fatalf("Cannot open image file %s: %v", imagePath, err) + } + defer imageFile.Close() + + ascPath := fmt.Sprintf("%s.asc", imagePath) + ascFile, err := os.Create(ascPath) + if err != nil { + t.Fatalf("Cannot create asc file %s: %v", ascPath, err) + } + defer ascFile.Close() + + err = openpgp.ArmoredDetachSign(ascFile, signingEntity, imageFile, nil) + if err != nil { + t.Fatalf("Cannot create armored detached signature: %v", err) + } + + return ascPath } func runRktTrust(t *testing.T, ctx *testutils.RktRunCtx, prefix string, keyIndex int) { From 87cab04886eb4de0bec3b708aa321901de7edd83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 27 Apr 2016 15:43:42 +0200 Subject: [PATCH 0172/1304] functional tests: add CAP_SYS_PTRACE to TestUserns It's needed to read /proc/1/root --- tests/rkt_userns_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/rkt_userns_test.go b/tests/rkt_userns_test.go index 0067b1c009..680ba0d53b 100644 --- a/tests/rkt_userns_test.go +++ b/tests/rkt_userns_test.go @@ -58,7 +58,8 @@ func TestUserns(t *testing.T) { t.Skip("User namespaces don't work on this host.") } - image := patchTestACI("rkt-inspect-stat.aci", "--exec=/inspect --stat-file") + // we need CAP_SYS_PTRACE to read /proc/1/root + image := patchTestACI("rkt-inspect-stat.aci", "--exec=/inspect --stat-file", "--capability=CAP_SYS_PTRACE") defer os.Remove(image) ctx := testutils.NewRktRunCtx() defer ctx.Cleanup() From 59a90f2912134739ba278bbcfacff7f098842aea Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Fri, 22 Apr 2016 14:28:02 +0300 Subject: [PATCH 0173/1304] rkt/image: remove 'get' from method names Refactors 'rkt/image' to remove 'Get' from the method names. Related to #2450 --- rkt/image/dockerfetcher.go | 4 ++-- rkt/image/downloader.go | 24 ++++++++++++------------ rkt/image/fetcher.go | 8 ++++---- rkt/image/filefetcher.go | 6 +++--- rkt/image/httpfetcher.go | 16 ++++++++-------- rkt/image/httpops.go | 4 ++-- rkt/image/namefetcher.go | 12 ++++++------ rkt/image/resumablesession.go | 6 +++--- rkt/image/validator.go | 8 ++++---- 9 files changed, 44 insertions(+), 44 deletions(-) diff --git a/rkt/image/dockerfetcher.go b/rkt/image/dockerfetcher.go index 658649a13f..c41c2e3ef6 100644 --- a/rkt/image/dockerfetcher.go +++ b/rkt/image/dockerfetcher.go @@ -46,9 +46,9 @@ type dockerFetcher struct { Debug bool } -// GetHash uses docker2aci to download the image and convert it to +// Hash uses docker2aci to download the image and convert it to // ACI, then stores it in the store and returns the hash. -func (f *dockerFetcher) GetHash(u *url.URL) (string, error) { +func (f *dockerFetcher) Hash(u *url.URL) (string, error) { ensureLogger(f.Debug) dockerURL, err := d2acommon.ParseDockerURL(path.Join(u.Host, u.Path)) if err != nil { diff --git a/rkt/image/downloader.go b/rkt/image/downloader.go index cc449745ad..06936b97f5 100644 --- a/rkt/image/downloader.go +++ b/rkt/image/downloader.go @@ -26,21 +26,21 @@ import ( // downloadSession is an interface used by downloader for controlling // the downloading process. type downloadSession interface { - // GetClient returns a client used for handling the + // Client returns a client used for handling the // requests. It is a good place for e.g. setting up a redirect // handling. - GetClient() (*http.Client, error) - // GetRequest returns an HTTP request. Is is a good place to + Client() (*http.Client, error) + // Request returns an HTTP request. It is a good place to // add some headers to a request. - GetRequest(u *url.URL) (*http.Request, error) + Request(u *url.URL) (*http.Request, error) // HandleStatus is mostly used to check if the response has // the required HTTP status. When this function returns either // an error or a false value, then the downloader will skip // getting contents of the response body. HandleStatus(res *http.Response) (bool, error) - // GetBodyReader returns a reader used to get contents of the + // BodyReader returns a reader used to get contents of the // response body. - GetBodyReader(*http.Response) (io.Reader, error) + BodyReader(*http.Response) (io.Reader, error) } // downloader has a rather obvious purpose - it downloads stuff. @@ -53,11 +53,11 @@ type downloader struct { // a given writeSyncer instance. func (d *downloader) Download(u *url.URL, out writeSyncer) error { d.ensureSession() - client, err := d.Session.GetClient() + client, err := d.Session.Client() if err != nil { return err } - req, err := d.Session.GetRequest(u) + req, err := d.Session.Request(u) if err != nil { return err } @@ -71,7 +71,7 @@ func (d *downloader) Download(u *url.URL, out writeSyncer) error { return err } - reader, err := d.Session.GetBodyReader(res) + reader, err := d.Session.BodyReader(res) if err != nil { return err } @@ -98,15 +98,15 @@ func (d *downloader) ensureSession() { // response other than 200 as an error. type defaultDownloadSession struct{} -func (s *defaultDownloadSession) GetBodyReader(res *http.Response) (io.Reader, error) { +func (s *defaultDownloadSession) BodyReader(res *http.Response) (io.Reader, error) { return res.Body, nil } -func (s *defaultDownloadSession) GetClient() (*http.Client, error) { +func (s *defaultDownloadSession) Client() (*http.Client, error) { return http.DefaultClient, nil } -func (s *defaultDownloadSession) GetRequest(u *url.URL) (*http.Request, error) { +func (s *defaultDownloadSession) Request(u *url.URL) (*http.Request, error) { req := &http.Request{ Method: "GET", URL: u, diff --git a/rkt/image/fetcher.go b/rkt/image/fetcher.go index 7583e56863..9450744024 100644 --- a/rkt/image/fetcher.go +++ b/rkt/image/fetcher.go @@ -239,7 +239,7 @@ func (f *Fetcher) maybeFetchHTTPURLFromRemote(rem *store.Remote, u *url.URL, a * Debug: f.Debug, Headers: f.Headers, } - return hf.GetHash(u, a) + return hf.Hash(u, a) } return "", nil } @@ -253,7 +253,7 @@ func (f *Fetcher) maybeFetchDockerURLFromRemote(u *url.URL) (string, error) { S: f.S, Debug: f.Debug, } - return df.GetHash(u) + return df.Hash(u) } return "", nil } @@ -266,7 +266,7 @@ func (f *Fetcher) fetchSingleImageByPath(path string, a *asc) (string, error) { Ks: f.Ks, Debug: f.Debug, } - return ff.GetHash(path, a) + return ff.Hash(path, a) } type appBundle struct { @@ -353,7 +353,7 @@ func (f *Fetcher) maybeFetchImageFromRemote(app *appBundle, a *asc) (string, err Headers: f.Headers, TrustKeysFromHTTPS: f.TrustKeysFromHTTPS, } - return nf.GetHash(app.App, a) + return nf.Hash(app.App, a) } return "", nil } diff --git a/rkt/image/filefetcher.go b/rkt/image/filefetcher.go index e41e0b094d..f88ee1c152 100644 --- a/rkt/image/filefetcher.go +++ b/rkt/image/filefetcher.go @@ -34,9 +34,9 @@ type fileFetcher struct { Debug bool } -// GetHash opens a file, optionally verifies it against passed asc, +// Hash opens a file, optionally verifies it against passed asc, // stores it in the store and returns the hash. -func (f *fileFetcher) GetHash(aciPath string, a *asc) (string, error) { +func (f *fileFetcher) Hash(aciPath string, a *asc) (string, error) { ensureLogger(f.Debug) absPath, err := filepath.Abs(aciPath) if err != nil { @@ -98,7 +98,7 @@ func (f *fileFetcher) getVerifiedFile(aciPath string, a *asc) (*os.File, error) entity, err := validator.ValidateWithSignature(f.Ks, ascFile) if err != nil { - return nil, errwrap.Wrap(fmt.Errorf("image %q verification failed", validator.GetImageName()), err) + return nil, errwrap.Wrap(fmt.Errorf("image %q verification failed", validator.ImageName()), err) } printIdentities(entity) diff --git a/rkt/image/httpfetcher.go b/rkt/image/httpfetcher.go index 2b256b5ed6..59dab6f464 100644 --- a/rkt/image/httpfetcher.go +++ b/rkt/image/httpfetcher.go @@ -37,9 +37,9 @@ type httpFetcher struct { Headers map[string]config.Headerer } -// GetHash fetches the URL, optionally verifies it against passed asc, +// Hash fetches the URL, optionally verifies it against passed asc, // stores it in the store and returns the hash. -func (f *httpFetcher) GetHash(u *url.URL, a *asc) (string, error) { +func (f *httpFetcher) Hash(u *url.URL, a *asc) (string, error) { ensureLogger(f.Debug) urlStr := u.String() @@ -47,7 +47,7 @@ func (f *httpFetcher) GetHash(u *url.URL, a *asc) (string, error) { log.Printf("fetching image from %s", urlStr) } - aciFile, cd, err := f.fetchURL(u, a, f.getETag()) + aciFile, cd, err := f.fetchURL(u, a, f.eTag()) if err != nil { return "", err } @@ -104,7 +104,7 @@ func (f *httpFetcher) fetchURL(u *url.URL, a *asc, etag string) (readSeekCloser, } if f.InsecureFlags.SkipImageCheck() || f.Ks == nil { - o := f.getHTTPOps() + o := f.httpOps() aciFile, cd, err := o.DownloadImageWithETag(u, etag) if err != nil { return nil, nil, err @@ -116,7 +116,7 @@ func (f *httpFetcher) fetchURL(u *url.URL, a *asc, etag string) (readSeekCloser, } func (f *httpFetcher) fetchVerifiedURL(u *url.URL, a *asc, etag string) (readSeekCloser, *cacheData, error) { - o := f.getHTTPOps() + o := f.httpOps() f.maybeOverrideAscFetcherWithRemote(o, u, a) ascFile, retry, err := o.DownloadSignature(a) if err != nil { @@ -148,7 +148,7 @@ func (f *httpFetcher) fetchVerifiedURL(u *url.URL, a *asc, etag string) (readSee return retAciFile, cd, nil } -func (f *httpFetcher) getHTTPOps() *httpOps { +func (f *httpFetcher) httpOps() *httpOps { return &httpOps{ InsecureSkipTLSVerify: f.InsecureFlags.SkipTLSCheck(), S: f.S, @@ -174,7 +174,7 @@ func (f *httpFetcher) validate(aciFile, ascFile io.ReadSeeker) error { return nil } -func (f *httpFetcher) getETag() string { +func (f *httpFetcher) eTag() string { if f.Rem != nil { return f.Rem.ETag } @@ -187,5 +187,5 @@ func (f *httpFetcher) maybeOverrideAscFetcherWithRemote(o *httpOps, u *url.URL, } u2 := ascURLFromImgURL(u) a.Location = u2.String() - a.Fetcher = o.GetAscRemoteFetcher() + a.Fetcher = o.AscRemoteFetcher() } diff --git a/rkt/image/httpops.go b/rkt/image/httpops.go index eb4dee6234..84137349e5 100644 --- a/rkt/image/httpops.go +++ b/rkt/image/httpops.go @@ -106,8 +106,8 @@ func (o *httpOps) DownloadImageWithETag(u *url.URL, etag string) (readSeekCloser return retAciFile, session.Cd, nil } -// GetAscRemoteFetcher provides a remoteAscFetcher for asc. -func (o *httpOps) GetAscRemoteFetcher() *remoteAscFetcher { +// AscRemoteFetcher provides a remoteAscFetcher for asc. +func (o *httpOps) AscRemoteFetcher() *remoteAscFetcher { ensureLogger(o.Debug) f := func(u *url.URL, file *os.File) error { switch u.Scheme { diff --git a/rkt/image/namefetcher.go b/rkt/image/namefetcher.go index da128379e3..1110251935 100644 --- a/rkt/image/namefetcher.go +++ b/rkt/image/namefetcher.go @@ -43,9 +43,9 @@ type nameFetcher struct { TrustKeysFromHTTPS bool } -// GetHash runs the discovery, fetches the image, optionally verifies +// Hash runs the discovery, fetches the image, optionally verifies // it against passed asc, stores it in the store and returns the hash. -func (f *nameFetcher) GetHash(app *discovery.App, a *asc) (string, error) { +func (f *nameFetcher) Hash(app *discovery.App, a *asc) (string, error) { ensureLogger(f.Debug) name := app.Name.String() log.Printf("searching for app image %s", name) @@ -140,7 +140,7 @@ func (f *nameFetcher) fetch(app *discovery.App, aciURL string, a *asc) (readSeek } if f.InsecureFlags.SkipImageCheck() || f.Ks == nil { - o := f.getHTTPOps() + o := f.httpOps() aciFile, cd, err := o.DownloadImage(u) if err != nil { return nil, nil, err @@ -155,7 +155,7 @@ func (f *nameFetcher) fetchVerifiedURL(app *discovery.App, u *url.URL, a *asc) ( appName := app.Name.String() f.maybeFetchPubKeys(appName) - o := f.getHTTPOps() + o := f.httpOps() ascFile, retry, err := o.DownloadSignature(a) if err != nil { return nil, nil, err @@ -281,10 +281,10 @@ func (f *nameFetcher) maybeOverrideAscFetcherWithRemote(ascURL string, a *asc) { return } a.Location = ascURL - a.Fetcher = f.getHTTPOps().GetAscRemoteFetcher() + a.Fetcher = f.httpOps().AscRemoteFetcher() } -func (f *nameFetcher) getHTTPOps() *httpOps { +func (f *nameFetcher) httpOps() *httpOps { return &httpOps{ InsecureSkipTLSVerify: f.InsecureFlags.SkipTLSCheck(), S: f.S, diff --git a/rkt/image/resumablesession.go b/rkt/image/resumablesession.go index 712d29bbe9..89bbef95cb 100644 --- a/rkt/image/resumablesession.go +++ b/rkt/image/resumablesession.go @@ -81,12 +81,12 @@ type resumableSession struct { byteRangeSupported bool } -func (s *resumableSession) GetClient() (*http.Client, error) { +func (s *resumableSession) Client() (*http.Client, error) { s.ensureClient() return s.client, nil } -func (s *resumableSession) GetRequest(u *url.URL) (*http.Request, error) { +func (s *resumableSession) Request(u *url.URL) (*http.Request, error) { s.u = u if err := s.maybeSetupDownloadResume(u); err != nil { return nil, err @@ -116,7 +116,7 @@ func (s *resumableSession) HandleStatus(res *http.Response) (bool, error) { } } -func (s *resumableSession) GetBodyReader(res *http.Response) (io.Reader, error) { +func (s *resumableSession) BodyReader(res *http.Response) (io.Reader, error) { reader := getIoProgressReader(s.Label, res) return reader, nil } diff --git a/rkt/image/validator.go b/rkt/image/validator.go index a9c0751632..78e1aa2d7b 100644 --- a/rkt/image/validator.go +++ b/rkt/image/validator.go @@ -49,15 +49,15 @@ func newValidator(image io.ReadSeeker) (*validator, error) { return v, nil } -// GetImageName returns image name as it is in the image manifest. -func (v *validator) GetImageName() string { +// ImageName returns image name as it is in the image manifest. +func (v *validator) ImageName() string { return v.manifest.Name.String() } // ValidateName checks if desired image name is actually the same as // the one in the image manifest. func (v *validator) ValidateName(imageName string) error { - name := v.GetImageName() + name := v.ImageName() if name != imageName { return fmt.Errorf("error when reading the app name: %q expected but %q found", imageName, name) @@ -92,7 +92,7 @@ func (v *validator) ValidateWithSignature(ks *keystore.Keystore, sig io.ReadSeek if _, err := sig.Seek(0, 0); err != nil { return nil, errwrap.Wrap(errors.New("error seeking signature file"), err) } - entity, err := ks.CheckSignature(v.GetImageName(), v.image, sig) + entity, err := ks.CheckSignature(v.ImageName(), v.image, sig) if err == pgperrors.ErrUnknownIssuer { log.Print("If you expected the signing key to change, try running:") log.Print(" rkt trust --prefix ") From 9e117622850ba93215fbfd4b8e30744d02b0addc Mon Sep 17 00:00:00 2001 From: Wlodzimierz Borkowski Date: Wed, 27 Apr 2016 09:01:08 +0200 Subject: [PATCH 0174/1304] tests/TestSocketProxyd: removing double quotes from rkt cmd The command is executed as a systemd unit and is not sent to a shell and the double quotes were not interpreted by systemd-v219 on some old distros (like Fedora 22). Fixes #2432 --- Documentation/networking/overriding-defaults.md | 2 +- tests/rkt_socket_proxyd_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/networking/overriding-defaults.md b/Documentation/networking/overriding-defaults.md index 9f54c9a0a4..4f44fbbfe8 100644 --- a/Documentation/networking/overriding-defaults.md +++ b/Documentation/networking/overriding-defaults.md @@ -17,7 +17,7 @@ rkt supports the `CNI_ARGS` variable through the command line argument `--net`. ### Syntax The syntax for passing arguments to a network looks like `--net="$networkname1:$arg1=$val1;$arg2=val2"`. -The usage of double quotes is mandatory due to the `;` being used as separator within the arguments for a single network. +When executed from a shell, you can use double quotes to avoid `;` being interpreted as a command separator by the shell. To allow the passing of arguments to different networks simply append the arguments to the network name with a colon (`:`), and separate the arguments by semicolon (`;`). All arguments can either be given in a single instance of the `--net`, or can be spread across multiple uses of `--net`. *Reminder:* the separator for the networks (and their arguments) within one `--net` instance is the comma `,`. diff --git a/tests/rkt_socket_proxyd_test.go b/tests/rkt_socket_proxyd_test.go index d35dc3ef9e..6d00e3e84f 100644 --- a/tests/rkt_socket_proxyd_test.go +++ b/tests/rkt_socket_proxyd_test.go @@ -102,7 +102,7 @@ func TestSocketProxyd(t *testing.T) { unitsDir := "/run/systemd/system" containerIP := "192.168.0.101" - cmd := fmt.Sprintf("%s --insecure-options=image --debug run --net=\"%s:IP=%s\" --port=test-port:%d --mds-register=false %s", + cmd := fmt.Sprintf("%s --insecure-options=image --debug run --net=%s:IP=%s --port=test-port:%d --mds-register=false %s", ctx.Cmd(), nt.Name, containerIP, port, echoImage) serviceContent := fmt.Sprintf(rktTestingEchoService, cmd) From 7765590baa45f47a8e1c00096d6c4d9e011748a9 Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Wed, 27 Apr 2016 16:45:12 +0200 Subject: [PATCH 0175/1304] tests: mark all existing tests for coreos flavor --- tests/rkt_ace_validator_test.go | 2 ++ tests/rkt_api_service_bench_test.go | 2 ++ tests/rkt_api_service_test.go | 2 ++ tests/rkt_app_isolator_test.go | 2 ++ tests/rkt_auth_test.go | 2 ++ tests/rkt_caps_test.go | 2 ++ tests/rkt_cat_manifest_test.go | 2 ++ tests/rkt_dns_test.go | 2 ++ tests/rkt_env_test.go | 2 ++ tests/rkt_error_output_test.go | 2 ++ tests/rkt_etc_hosts_test.go | 2 ++ tests/rkt_exec_test.go | 2 ++ tests/rkt_exit_test.go | 2 ++ tests/rkt_fetch_test.go | 2 ++ tests/rkt_gc_test.go | 2 ++ tests/rkt_hostname_test.go | 2 ++ tests/rkt_image_cat_manifest_test.go | 2 ++ tests/rkt_image_dependencies_test.go | 2 ++ tests/rkt_image_export_test.go | 2 ++ tests/rkt_image_extract_test.go | 2 ++ tests/rkt_image_gc_test.go | 2 ++ tests/rkt_image_list_test.go | 2 ++ tests/rkt_image_render_test.go | 2 ++ tests/rkt_image_rm_test.go | 2 ++ tests/rkt_interactive_test.go | 2 ++ tests/rkt_list_test.go | 2 ++ tests/rkt_metadata_service_test.go | 2 ++ tests/rkt_mount_test.go | 2 ++ tests/rkt_net_test.go | 2 ++ tests/rkt_non_root_test.go | 2 ++ tests/rkt_os_arch_test.go | 2 ++ tests/rkt_pid_file_test.go | 2 ++ tests/rkt_root_commands_test.go | 2 ++ tests/rkt_run_pod_manifest_test.go | 2 ++ tests/rkt_run_user_group_test.go | 2 ++ tests/rkt_service_file_test.go | 2 ++ tests/rkt_socket_activation_test.go | 2 ++ tests/rkt_socket_proxyd_test.go | 2 ++ tests/rkt_stage1_loading_test.go | 2 ++ tests/rkt_supplementary_gids_test.go | 2 ++ tests/rkt_trust_test.go | 2 ++ tests/rkt_userns_test.go | 2 ++ tests/rkt_volume_test.go | 2 ++ 43 files changed, 86 insertions(+) diff --git a/tests/rkt_ace_validator_test.go b/tests/rkt_ace_validator_test.go index 7701f90d02..6232a2f87e 100644 --- a/tests/rkt_ace_validator_test.go +++ b/tests/rkt_ace_validator_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_api_service_bench_test.go b/tests/rkt_api_service_bench_test.go index 1104efdbbb..20715f18f2 100644 --- a/tests/rkt_api_service_bench_test.go +++ b/tests/rkt_api_service_bench_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_api_service_test.go b/tests/rkt_api_service_test.go index cc712ab662..923dbcfd69 100644 --- a/tests/rkt_api_service_test.go +++ b/tests/rkt_api_service_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_app_isolator_test.go b/tests/rkt_app_isolator_test.go index a6e8baff9a..98b0b0e0a2 100644 --- a/tests/rkt_app_isolator_test.go +++ b/tests/rkt_app_isolator_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_auth_test.go b/tests/rkt_auth_test.go index cf0e6b6323..7fd8aad9f0 100644 --- a/tests/rkt_auth_test.go +++ b/tests/rkt_auth_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_caps_test.go b/tests/rkt_caps_test.go index 8559244ef7..c5e5a06aac 100644 --- a/tests/rkt_caps_test.go +++ b/tests/rkt_caps_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_cat_manifest_test.go b/tests/rkt_cat_manifest_test.go index 2ec4aa0d1e..2d7b3cd959 100644 --- a/tests/rkt_cat_manifest_test.go +++ b/tests/rkt_cat_manifest_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_dns_test.go b/tests/rkt_dns_test.go index 6d80ff9e1c..a927432176 100644 --- a/tests/rkt_dns_test.go +++ b/tests/rkt_dns_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_env_test.go b/tests/rkt_env_test.go index 5a03c563dc..8e8de6af75 100644 --- a/tests/rkt_env_test.go +++ b/tests/rkt_env_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_error_output_test.go b/tests/rkt_error_output_test.go index 4299444dfa..f696eb06bb 100644 --- a/tests/rkt_error_output_test.go +++ b/tests/rkt_error_output_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_etc_hosts_test.go b/tests/rkt_etc_hosts_test.go index 52f3ef8151..b3b3ec66d7 100644 --- a/tests/rkt_etc_hosts_test.go +++ b/tests/rkt_etc_hosts_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_exec_test.go b/tests/rkt_exec_test.go index 4891e3a5d8..df5efa121e 100644 --- a/tests/rkt_exec_test.go +++ b/tests/rkt_exec_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_exit_test.go b/tests/rkt_exit_test.go index 7733f2f9da..50477a3ad4 100644 --- a/tests/rkt_exit_test.go +++ b/tests/rkt_exit_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_fetch_test.go b/tests/rkt_fetch_test.go index 69634e4d2e..5b5885b43c 100644 --- a/tests/rkt_fetch_test.go +++ b/tests/rkt_fetch_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_gc_test.go b/tests/rkt_gc_test.go index 9a116c3353..d7711c1fe9 100644 --- a/tests/rkt_gc_test.go +++ b/tests/rkt_gc_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_hostname_test.go b/tests/rkt_hostname_test.go index 85d7b4c464..4042dfc986 100644 --- a/tests/rkt_hostname_test.go +++ b/tests/rkt_hostname_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_image_cat_manifest_test.go b/tests/rkt_image_cat_manifest_test.go index ae210c86d7..54c58cf423 100644 --- a/tests/rkt_image_cat_manifest_test.go +++ b/tests/rkt_image_cat_manifest_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_image_dependencies_test.go b/tests/rkt_image_dependencies_test.go index 051b7c2f2e..ad14274c9d 100644 --- a/tests/rkt_image_dependencies_test.go +++ b/tests/rkt_image_dependencies_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_image_export_test.go b/tests/rkt_image_export_test.go index 50eba09988..f5e268ea5e 100644 --- a/tests/rkt_image_export_test.go +++ b/tests/rkt_image_export_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_image_extract_test.go b/tests/rkt_image_extract_test.go index 68df373f3c..37304c8df5 100644 --- a/tests/rkt_image_extract_test.go +++ b/tests/rkt_image_extract_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_image_gc_test.go b/tests/rkt_image_gc_test.go index dd4def6490..316f402b37 100644 --- a/tests/rkt_image_gc_test.go +++ b/tests/rkt_image_gc_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_image_list_test.go b/tests/rkt_image_list_test.go index 7e78c6ab9d..3870113e6c 100644 --- a/tests/rkt_image_list_test.go +++ b/tests/rkt_image_list_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_image_render_test.go b/tests/rkt_image_render_test.go index a3dbd0a8f6..16a31c0d6f 100644 --- a/tests/rkt_image_render_test.go +++ b/tests/rkt_image_render_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_image_rm_test.go b/tests/rkt_image_rm_test.go index 1019fa85ca..46d6c21591 100644 --- a/tests/rkt_image_rm_test.go +++ b/tests/rkt_image_rm_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_interactive_test.go b/tests/rkt_interactive_test.go index 846d093c02..a20631d102 100644 --- a/tests/rkt_interactive_test.go +++ b/tests/rkt_interactive_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_list_test.go b/tests/rkt_list_test.go index 80c49c807a..1927c8fb78 100644 --- a/tests/rkt_list_test.go +++ b/tests/rkt_list_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_metadata_service_test.go b/tests/rkt_metadata_service_test.go index 178b8abea4..29dc27c20e 100644 --- a/tests/rkt_metadata_service_test.go +++ b/tests/rkt_metadata_service_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_mount_test.go b/tests/rkt_mount_test.go index a2b39569c0..2212b04cb5 100644 --- a/tests/rkt_mount_test.go +++ b/tests/rkt_mount_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_net_test.go b/tests/rkt_net_test.go index cae2c00638..e42763b0d4 100644 --- a/tests/rkt_net_test.go +++ b/tests/rkt_net_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_non_root_test.go b/tests/rkt_non_root_test.go index cc3c920ffd..4c96cab371 100644 --- a/tests/rkt_non_root_test.go +++ b/tests/rkt_non_root_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_os_arch_test.go b/tests/rkt_os_arch_test.go index 9430601911..d3d1514aaa 100644 --- a/tests/rkt_os_arch_test.go +++ b/tests/rkt_os_arch_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_pid_file_test.go b/tests/rkt_pid_file_test.go index 2aeda499b3..3f93ca1893 100644 --- a/tests/rkt_pid_file_test.go +++ b/tests/rkt_pid_file_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_root_commands_test.go b/tests/rkt_root_commands_test.go index 0efa6cdaa5..e0a80a5adc 100644 --- a/tests/rkt_root_commands_test.go +++ b/tests/rkt_root_commands_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_run_pod_manifest_test.go b/tests/rkt_run_pod_manifest_test.go index 169971085e..910e439b53 100644 --- a/tests/rkt_run_pod_manifest_test.go +++ b/tests/rkt_run_pod_manifest_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_run_user_group_test.go b/tests/rkt_run_user_group_test.go index 5c77158103..ed9a084585 100644 --- a/tests/rkt_run_user_group_test.go +++ b/tests/rkt_run_user_group_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_service_file_test.go b/tests/rkt_service_file_test.go index 608af67174..18424552e6 100644 --- a/tests/rkt_service_file_test.go +++ b/tests/rkt_service_file_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_socket_activation_test.go b/tests/rkt_socket_activation_test.go index 60d72ce261..f70622a8f2 100644 --- a/tests/rkt_socket_activation_test.go +++ b/tests/rkt_socket_activation_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_socket_proxyd_test.go b/tests/rkt_socket_proxyd_test.go index d35dc3ef9e..88a75e3d9a 100644 --- a/tests/rkt_socket_proxyd_test.go +++ b/tests/rkt_socket_proxyd_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_stage1_loading_test.go b/tests/rkt_stage1_loading_test.go index 316ba0cc79..0ff8a5e5ba 100644 --- a/tests/rkt_stage1_loading_test.go +++ b/tests/rkt_stage1_loading_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_supplementary_gids_test.go b/tests/rkt_supplementary_gids_test.go index 342c25f26b..0d9daa3b80 100644 --- a/tests/rkt_supplementary_gids_test.go +++ b/tests/rkt_supplementary_gids_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_trust_test.go b/tests/rkt_trust_test.go index f503499dd4..965ed2ea1e 100644 --- a/tests/rkt_trust_test.go +++ b/tests/rkt_trust_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_userns_test.go b/tests/rkt_userns_test.go index 0067b1c009..9233db949d 100644 --- a/tests/rkt_userns_test.go +++ b/tests/rkt_userns_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( diff --git a/tests/rkt_volume_test.go b/tests/rkt_volume_test.go index 2d9d24bde1..30b403e7b5 100644 --- a/tests/rkt_volume_test.go +++ b/tests/rkt_volume_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build coreos + package main import ( From dc071307b44b7521fa95efcdf569c1f2e3a246b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 27 Apr 2016 17:26:49 +0200 Subject: [PATCH 0176/1304] stage1/init: copy systemd-sysusers on flavor host We're using it in stage1 so we need to copy it from the host in the host flaver. --- stage1/init/init.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/stage1/init/init.go b/stage1/init/init.go index f2b43466ce..31def472e8 100644 --- a/stage1/init/init.go +++ b/stage1/init/init.go @@ -165,6 +165,10 @@ func installAssets() error { if err != nil { return err } + systemdSysusersBin, err := common.LookupPath("systemd-sysusers", os.Getenv("PATH")) + if err != nil { + return err + } bashBin, err := common.LookupPath("bash", os.Getenv("PATH")) if err != nil { return err @@ -189,6 +193,7 @@ func installAssets() error { assets := []string{ proj2aci.GetAssetString("/usr/lib/systemd/systemd", systemdBin), proj2aci.GetAssetString("/usr/bin/systemctl", systemctlBin), + proj2aci.GetAssetString("/usr/bin/systemd-sysusers", systemdSysusersBin), proj2aci.GetAssetString("/usr/lib/systemd/systemd-journald", systemdJournaldBin), proj2aci.GetAssetString("/usr/bin/bash", bashBin), proj2aci.GetAssetString(fmt.Sprintf("%s/systemd-journald.service", systemdUnitsPath), fmt.Sprintf("%s/systemd-journald.service", systemdUnitsPath)), From ce8c2de5b650609472456d2f7c820aa5d7445f28 Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Wed, 27 Apr 2016 16:47:12 +0200 Subject: [PATCH 0177/1304] tests: initially cover fly flavor --- tests/build-and-run-tests.sh | 4 +-- tests/rkt_fly_test.go | 54 ++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 tests/rkt_fly_test.go diff --git a/tests/build-and-run-tests.sh b/tests/build-and-run-tests.sh index e4c13f1122..2f0ddb397a 100755 --- a/tests/build-and-run-tests.sh +++ b/tests/build-and-run-tests.sh @@ -58,7 +58,7 @@ function semaphoreCIConfiguration { } function checkFlavorValue { - FLAVORS="coreos host kvm none src" + FLAVORS="coreos host kvm none src fly" if [ -z "${RKT_STAGE1_USR_FROM}" ]; then set - echo "Flavor is not set" @@ -112,7 +112,7 @@ function parseParameters { # Configure build function configure { case "${RKT_STAGE1_USR_FROM}" in - coreos|kvm) + coreos|kvm|fly) ./configure --with-stage1-flavors="${RKT_STAGE1_USR_FROM}" \ --with-stage1-default-flavor="${RKT_STAGE1_USR_FROM}" \ --enable-functional-tests --enable-tpm=auto \ diff --git a/tests/rkt_fly_test.go b/tests/rkt_fly_test.go new file mode 100644 index 0000000000..7001a3580b --- /dev/null +++ b/tests/rkt_fly_test.go @@ -0,0 +1,54 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build fly + +package main + +import ( + "fmt" + "os" + "testing" + + "github.com/coreos/rkt/tests/testutils" +) + +func TestFlyNetns(t *testing.T) { + testImageArgs := []string{"--exec=/inspect --print-netns"} + testImage := patchTestACI("rkt-inspect-stage1-fly.aci", testImageArgs...) + defer os.Remove(testImage) + + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + cmd := fmt.Sprintf("%s --debug --insecure-options=image run %s", ctx.Cmd(), testImage) + child := spawnOrFail(t, cmd) + ctx.RegisterChild(child) + defer waitOrFail(t, child, 0) + + expectedRegex := `NetNS: (net:\[\d+\])` + result, out, err := expectRegexWithOutput(child, expectedRegex) + if err != nil { + t.Fatalf("Error: %v\nOutput: %v", err, out) + } + + ns, err := os.Readlink("/proc/self/ns/net") + if err != nil { + t.Fatalf("Cannot evaluate NetNS symlink: %v", err) + } + + if nsChanged := ns != result[1]; nsChanged { + t.Fatalf("container left host netns") + } +} From 3092d7520fb55fe6f232ad6cd4bac3c4b69f2fcd Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Wed, 27 Apr 2016 19:51:04 +0200 Subject: [PATCH 0178/1304] tests: enable src flavor with coreos tests --- tests/rkt_ace_validator_test.go | 2 +- tests/rkt_api_service_bench_test.go | 2 +- tests/rkt_api_service_test.go | 2 +- tests/rkt_app_isolator_test.go | 2 +- tests/rkt_auth_test.go | 2 +- tests/rkt_caps_test.go | 2 +- tests/rkt_cat_manifest_test.go | 2 +- tests/rkt_dns_test.go | 2 +- tests/rkt_env_test.go | 2 +- tests/rkt_error_output_test.go | 2 +- tests/rkt_etc_hosts_test.go | 2 +- tests/rkt_exec_test.go | 2 +- tests/rkt_exit_test.go | 2 +- tests/rkt_fetch_test.go | 2 +- tests/rkt_gc_test.go | 2 +- tests/rkt_hostname_test.go | 2 +- tests/rkt_image_cat_manifest_test.go | 2 +- tests/rkt_image_dependencies_test.go | 2 +- tests/rkt_image_export_test.go | 2 +- tests/rkt_image_extract_test.go | 2 +- tests/rkt_image_gc_test.go | 2 +- tests/rkt_image_list_test.go | 2 +- tests/rkt_image_render_test.go | 2 +- tests/rkt_image_rm_test.go | 2 +- tests/rkt_interactive_test.go | 2 +- tests/rkt_list_test.go | 2 +- tests/rkt_metadata_service_test.go | 2 +- tests/rkt_mount_test.go | 2 +- tests/rkt_net_test.go | 2 +- tests/rkt_non_root_test.go | 2 +- tests/rkt_os_arch_test.go | 2 +- tests/rkt_pid_file_test.go | 2 +- tests/rkt_root_commands_test.go | 2 +- tests/rkt_run_pod_manifest_test.go | 2 +- tests/rkt_run_user_group_test.go | 2 +- tests/rkt_service_file_test.go | 2 +- tests/rkt_socket_activation_test.go | 2 +- tests/rkt_socket_proxyd_test.go | 2 +- tests/rkt_stage1_loading_test.go | 2 +- tests/rkt_supplementary_gids_test.go | 2 +- tests/rkt_trust_test.go | 2 +- tests/rkt_userns_test.go | 2 +- tests/rkt_volume_test.go | 2 +- 43 files changed, 43 insertions(+), 43 deletions(-) diff --git a/tests/rkt_ace_validator_test.go b/tests/rkt_ace_validator_test.go index 6232a2f87e..08f135e759 100644 --- a/tests/rkt_ace_validator_test.go +++ b/tests/rkt_ace_validator_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_api_service_bench_test.go b/tests/rkt_api_service_bench_test.go index 20715f18f2..e33745efbc 100644 --- a/tests/rkt_api_service_bench_test.go +++ b/tests/rkt_api_service_bench_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_api_service_test.go b/tests/rkt_api_service_test.go index 923dbcfd69..0b69ee52b1 100644 --- a/tests/rkt_api_service_test.go +++ b/tests/rkt_api_service_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_app_isolator_test.go b/tests/rkt_app_isolator_test.go index 98b0b0e0a2..c89bfdbb80 100644 --- a/tests/rkt_app_isolator_test.go +++ b/tests/rkt_app_isolator_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_auth_test.go b/tests/rkt_auth_test.go index 7fd8aad9f0..d3a7ccf88c 100644 --- a/tests/rkt_auth_test.go +++ b/tests/rkt_auth_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_caps_test.go b/tests/rkt_caps_test.go index c5e5a06aac..a0a2aec818 100644 --- a/tests/rkt_caps_test.go +++ b/tests/rkt_caps_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_cat_manifest_test.go b/tests/rkt_cat_manifest_test.go index 2d7b3cd959..6189b97113 100644 --- a/tests/rkt_cat_manifest_test.go +++ b/tests/rkt_cat_manifest_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_dns_test.go b/tests/rkt_dns_test.go index a927432176..21903d8df5 100644 --- a/tests/rkt_dns_test.go +++ b/tests/rkt_dns_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_env_test.go b/tests/rkt_env_test.go index 8e8de6af75..da6b7a3804 100644 --- a/tests/rkt_env_test.go +++ b/tests/rkt_env_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_error_output_test.go b/tests/rkt_error_output_test.go index f696eb06bb..d9bf374708 100644 --- a/tests/rkt_error_output_test.go +++ b/tests/rkt_error_output_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_etc_hosts_test.go b/tests/rkt_etc_hosts_test.go index b3b3ec66d7..8997b46990 100644 --- a/tests/rkt_etc_hosts_test.go +++ b/tests/rkt_etc_hosts_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_exec_test.go b/tests/rkt_exec_test.go index df5efa121e..11aa2a872a 100644 --- a/tests/rkt_exec_test.go +++ b/tests/rkt_exec_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_exit_test.go b/tests/rkt_exit_test.go index 50477a3ad4..b4ecc244fa 100644 --- a/tests/rkt_exit_test.go +++ b/tests/rkt_exit_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_fetch_test.go b/tests/rkt_fetch_test.go index 5b5885b43c..c4e7ca3d7c 100644 --- a/tests/rkt_fetch_test.go +++ b/tests/rkt_fetch_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_gc_test.go b/tests/rkt_gc_test.go index d7711c1fe9..bc53e7c2c0 100644 --- a/tests/rkt_gc_test.go +++ b/tests/rkt_gc_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_hostname_test.go b/tests/rkt_hostname_test.go index 4042dfc986..4c9508dd5a 100644 --- a/tests/rkt_hostname_test.go +++ b/tests/rkt_hostname_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_image_cat_manifest_test.go b/tests/rkt_image_cat_manifest_test.go index 54c58cf423..c83f1875d5 100644 --- a/tests/rkt_image_cat_manifest_test.go +++ b/tests/rkt_image_cat_manifest_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_image_dependencies_test.go b/tests/rkt_image_dependencies_test.go index ad14274c9d..7437911a25 100644 --- a/tests/rkt_image_dependencies_test.go +++ b/tests/rkt_image_dependencies_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_image_export_test.go b/tests/rkt_image_export_test.go index f5e268ea5e..19661781d2 100644 --- a/tests/rkt_image_export_test.go +++ b/tests/rkt_image_export_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_image_extract_test.go b/tests/rkt_image_extract_test.go index 37304c8df5..9ce3b36423 100644 --- a/tests/rkt_image_extract_test.go +++ b/tests/rkt_image_extract_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_image_gc_test.go b/tests/rkt_image_gc_test.go index 316f402b37..57c5adb2be 100644 --- a/tests/rkt_image_gc_test.go +++ b/tests/rkt_image_gc_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_image_list_test.go b/tests/rkt_image_list_test.go index 3870113e6c..99c894070f 100644 --- a/tests/rkt_image_list_test.go +++ b/tests/rkt_image_list_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_image_render_test.go b/tests/rkt_image_render_test.go index 16a31c0d6f..6168bbc930 100644 --- a/tests/rkt_image_render_test.go +++ b/tests/rkt_image_render_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_image_rm_test.go b/tests/rkt_image_rm_test.go index 46d6c21591..db3d593482 100644 --- a/tests/rkt_image_rm_test.go +++ b/tests/rkt_image_rm_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_interactive_test.go b/tests/rkt_interactive_test.go index a20631d102..7cb4fe4ea8 100644 --- a/tests/rkt_interactive_test.go +++ b/tests/rkt_interactive_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_list_test.go b/tests/rkt_list_test.go index 1927c8fb78..271bf15d51 100644 --- a/tests/rkt_list_test.go +++ b/tests/rkt_list_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_metadata_service_test.go b/tests/rkt_metadata_service_test.go index 29dc27c20e..830b3c8218 100644 --- a/tests/rkt_metadata_service_test.go +++ b/tests/rkt_metadata_service_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_mount_test.go b/tests/rkt_mount_test.go index 2212b04cb5..b3ea225dbf 100644 --- a/tests/rkt_mount_test.go +++ b/tests/rkt_mount_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_net_test.go b/tests/rkt_net_test.go index e42763b0d4..d882c3c93a 100644 --- a/tests/rkt_net_test.go +++ b/tests/rkt_net_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_non_root_test.go b/tests/rkt_non_root_test.go index 4c96cab371..e29ce946da 100644 --- a/tests/rkt_non_root_test.go +++ b/tests/rkt_non_root_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_os_arch_test.go b/tests/rkt_os_arch_test.go index d3d1514aaa..7afb21732d 100644 --- a/tests/rkt_os_arch_test.go +++ b/tests/rkt_os_arch_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_pid_file_test.go b/tests/rkt_pid_file_test.go index 3f93ca1893..d9b88b5636 100644 --- a/tests/rkt_pid_file_test.go +++ b/tests/rkt_pid_file_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_root_commands_test.go b/tests/rkt_root_commands_test.go index e0a80a5adc..65917acee9 100644 --- a/tests/rkt_root_commands_test.go +++ b/tests/rkt_root_commands_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_run_pod_manifest_test.go b/tests/rkt_run_pod_manifest_test.go index 910e439b53..353a2e2bab 100644 --- a/tests/rkt_run_pod_manifest_test.go +++ b/tests/rkt_run_pod_manifest_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_run_user_group_test.go b/tests/rkt_run_user_group_test.go index ed9a084585..5de9e4f028 100644 --- a/tests/rkt_run_user_group_test.go +++ b/tests/rkt_run_user_group_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_service_file_test.go b/tests/rkt_service_file_test.go index 18424552e6..22205cefe2 100644 --- a/tests/rkt_service_file_test.go +++ b/tests/rkt_service_file_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_socket_activation_test.go b/tests/rkt_socket_activation_test.go index f70622a8f2..cd37a44b0f 100644 --- a/tests/rkt_socket_activation_test.go +++ b/tests/rkt_socket_activation_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_socket_proxyd_test.go b/tests/rkt_socket_proxyd_test.go index 88a75e3d9a..705e3d39ed 100644 --- a/tests/rkt_socket_proxyd_test.go +++ b/tests/rkt_socket_proxyd_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_stage1_loading_test.go b/tests/rkt_stage1_loading_test.go index 0ff8a5e5ba..68d58d15c1 100644 --- a/tests/rkt_stage1_loading_test.go +++ b/tests/rkt_stage1_loading_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_supplementary_gids_test.go b/tests/rkt_supplementary_gids_test.go index 0d9daa3b80..fef54a7c94 100644 --- a/tests/rkt_supplementary_gids_test.go +++ b/tests/rkt_supplementary_gids_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_trust_test.go b/tests/rkt_trust_test.go index 965ed2ea1e..1a50732512 100644 --- a/tests/rkt_trust_test.go +++ b/tests/rkt_trust_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_userns_test.go b/tests/rkt_userns_test.go index 9233db949d..20838ab216 100644 --- a/tests/rkt_userns_test.go +++ b/tests/rkt_userns_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main diff --git a/tests/rkt_volume_test.go b/tests/rkt_volume_test.go index 30b403e7b5..2b8882bc27 100644 --- a/tests/rkt_volume_test.go +++ b/tests/rkt_volume_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos +// +build coreos src package main From f4e7bf0753f12fdce5485a040098127a23a05d82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Thu, 28 Apr 2016 10:34:48 +0200 Subject: [PATCH 0179/1304] rkt/image: render images only if we're root To render images, we need access to the tree store directories and capabilities to do a chroot. We could allow the rkt group to access the tree store directories and not do a chroot when rendering but since this rendering-on-fetch is just an optimization, it's simpler to just skip the rendering if we fetch as non-root. --- rkt/image/fetcher.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rkt/image/fetcher.go b/rkt/image/fetcher.go index 7583e56863..43cdbdd70e 100644 --- a/rkt/image/fetcher.go +++ b/rkt/image/fetcher.go @@ -19,6 +19,7 @@ import ( "errors" "fmt" "net/url" + "os" "runtime" "github.com/coreos/rkt/common" @@ -52,7 +53,9 @@ func (f *Fetcher) FetchImage(img string, ascPath string, imgType apps.AppImageTy return "", err } } - if common.SupportsOverlay() { + // we need to be able to do a chroot and access to the tree store + // directories, check if we're root + if common.SupportsOverlay() && os.Geteuid() == 0 { if _, _, err := f.S.RenderTreeStore(hash, false); err != nil { return "", errwrap.Wrap(errors.New("error rendering tree store"), err) } From 7c24738982814d364bf559bc616c0356a5195fbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Thu, 28 Apr 2016 10:58:49 +0200 Subject: [PATCH 0180/1304] Documentation: update references to the Docker Hub The Docker Hub index URL is not index.docker.io anymore, it is registry-1.docker.io. Also, fix the Docker Hub link so it goes to the user-facing page. --- Documentation/configuration.md | 10 +++++----- Documentation/running-docker-images.md | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Documentation/configuration.md b/Documentation/configuration.md index 4dd3be5f89..3e7a0f8247 100644 --- a/Documentation/configuration.md +++ b/Documentation/configuration.md @@ -192,7 +192,7 @@ These fields must be specified and cannot be empty. Some popular Docker registries: -* index.docker.io (Assumed as the default when no specific registry is named on the rkt command line, as in `docker:///redis`.) +* registry-1.docker.io (Assumed as the default when no specific registry is named on the rkt command line, as in `docker:///redis`.) * quay.io * gcr.io @@ -204,7 +204,7 @@ Example `dockerAuth` configuration: { "rktKind": "dockerAuth", "rktVersion": "v1", - "registries": ["index.docker.io", "quay.io"], + "registries": ["registry-1.docker.io", "quay.io"], "credentials": { "user": "foo", "password": "bar" @@ -224,7 +224,7 @@ For example, given this system configuration: { "rktKind": "dockerAuth", "rktVersion": "v1", - "registries": ["index.docker.io", "gcr.io", "quay.io"], + "registries": ["registry-1.docker.io", "gcr.io", "quay.io"], "credentials": { "user": "foo", "password": "bar" @@ -232,7 +232,7 @@ For example, given this system configuration: } ``` -If only this configuration file is provided, then when downloading images from either `index.docker.io`, `gcr.io`, or `quay.io`, `rkt` would use user `foo` and password `bar`. +If only this configuration file is provided, then when downloading images from either `registry-1.docker.io`, `gcr.io`, or `quay.io`, `rkt` would use user `foo` and password `bar`. But with additional configuration provided in the local configuration directory, this can be overridden. For example, given the above system configuration and the following local configuration: @@ -265,7 +265,7 @@ For example, given the above system configuration and the following local config } ``` -The result is that when downloading images from `index.docker.io`, `rkt` still sends user `foo` and password `bar`, but when downloading from `quay.io`, it uses user `baz` and password `quux`; and for `gcr.io` it will use user `goo` and password `gle`. +The result is that when downloading images from `registry-1.docker.io`, `rkt` still sends user `foo` and password `bar`, but when downloading from `quay.io`, it uses user `baz` and password `quux`; and for `gcr.io` it will use user `goo` and password `gle`. Note that _within_ a particular configuration directory (either system or local), it is a syntax error for the same Docker registry to be defined in multiple files. diff --git a/Documentation/running-docker-images.md b/Documentation/running-docker-images.md index e05e01ef7e..84db2570db 100644 --- a/Documentation/running-docker-images.md +++ b/Documentation/running-docker-images.md @@ -45,7 +45,7 @@ Downloading layer: f2fb89b0a711a7178528c7785d247ba3572924353b0d5e23e9b28f0518253 4:M 19 Apr 06:09:02.375 * The server is now ready to accept connections on port 6379 ``` -This behaves similarly to the Docker client: if no specific registry is named, the [Docker Hub](https://index.docker.io/v1/) is used by default. +This behaves similarly to the Docker client: if no specific registry is named, the [Docker Hub](https://hub.docker.com) is used by default. As with Docker, alternative registries can be used by specifying the registry as part of the image reference. For example, the following command will fetch an nginx Docker image hosted on quay.io: From fa3544e00a8fcad83291cee44f66b50c18164b0a Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Tue, 19 Apr 2016 13:39:21 +0300 Subject: [PATCH 0181/1304] tests: check the returned err value Checks the discarded error value. Related to #2390 --- tests/rkt_net_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/rkt_net_test.go b/tests/rkt_net_test.go index cae2c00638..895ef7cdc8 100644 --- a/tests/rkt_net_test.go +++ b/tests/rkt_net_test.go @@ -608,6 +608,10 @@ func testNetCustomNatConnectivity(t *testing.T, nt networkTemplateT) { // Child connects to host hostname, err := os.Hostname() + if err != nil { + panic(err) + } + go func() { defer ga.Done() testImageArgs := []string{fmt.Sprintf("--exec=/inspect --get-http=%v", httpGetAddr)} @@ -623,6 +627,7 @@ func testNetCustomNatConnectivity(t *testing.T, nt networkTemplateT) { if err != nil { ga.Fatalf("Error: %v\nOutput: %v", err, out) } + if result[1] != hostname { ga.Fatalf("Hostname received by client `%v` doesn't match `%v`", result[1], hostname) } From d8de2c52e4bb257f8131411f64a7aca861777c6a Mon Sep 17 00:00:00 2001 From: Ilya Dmitrichenko Date: Wed, 27 Apr 2016 14:58:05 +0100 Subject: [PATCH 0182/1304] Documentation: `--hostname` flag It was missing for `rkt run`. This change also make `rkt run-prepared` docs consistent with `rkt run` about `--hostname` flag usage. --- Documentation/subcommands/run-prepared.md | 2 +- Documentation/subcommands/run.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/subcommands/run-prepared.md b/Documentation/subcommands/run-prepared.md index dcf7b75ad3..7f8ba71eaa 100644 --- a/Documentation/subcommands/run-prepared.md +++ b/Documentation/subcommands/run-prepared.md @@ -48,7 +48,7 @@ c9fad0e6 etcd coreos.com/etcd prepared | `--dns` | `` | IP Address | Name server to write in `/etc/resolv.conf`. It can be specified several times | | `--dns-opt` | `` | Option as described in the options section in resolv.conf(5) | DNS option to write in `/etc/resolv.conf`. It can be specified several times | | `--dns-search` | `` | Domain name | DNS search domain to write in `/etc/resolv.conf`. It can be specified several times | -| `--hostname` | `` | A host name | Pod's hostname. If empty, it will be "rkt-$PODUUID" | +| `--hostname` | "rkt-$PODUUID" | A host name | Set pod's host name. | | `--interactive` | `false` | `true` or `false` | Run pod interactively. If true, only one image may be supplied | | `--mds-register` | `false` | `true` or `false` | Register pod with metadata service. It needs network connectivity to the host (`--net=(default|default-restricted|host)` | | `--net` | `default` | A comma-separated list of networks. Syntax: `--net[=n[:args], ...]` | Configure the pod's networking. Optionally, pass a list of user-configured networks to load and set arguments to pass to each network, respectively | diff --git a/Documentation/subcommands/run.md b/Documentation/subcommands/run.md index d43046bfd8..41351d3b52 100644 --- a/Documentation/subcommands/run.md +++ b/Documentation/subcommands/run.md @@ -340,6 +340,7 @@ For more details see the [hacking documentation](../hacking.md). | `--dns-opt` | none | DNS option | DNS option from resolv.conf(5) to write in `/etc/resolv.conf`. It can be specified several times. | | `--dns-search` | none | Domain name | DNS search domain to write in `/etc/resolv.conf`. It can be specified several times. | | `--exec` | none | Path to executable | Override the exec command for the preceding image. | +| `--hostname` | "rkt-$PODUUID" | A host name | Set pod's host name. | | `--inherit-env` | `false` | `true` or `false` | Inherit all environment variables not set by apps. | | `--interactive` | `false` | `true` or `false` | Run pod interactively. If true, only one image may be supplied. | | `--mds-register` | `false` | `true` or `false` | Register pod with metadata service. It needs network connectivity to the host (`--net` as `default`, `default-restricted`, or `host`). | From 2323c2b237fba49235f4816bcc0ebf66b88e8dec Mon Sep 17 00:00:00 2001 From: Michal Stachowski Date: Thu, 14 Apr 2016 11:53:51 +0000 Subject: [PATCH 0183/1304] kvm: prepare functional tests for support kvm Prepare functional tests for support kvm. Co-authored: @s-urbaniak --- tests/README.md | 4 +- tests/build-and-run-tests.sh | 2 +- tests/rkt_api_service_bench_test.go | 2 +- tests/rkt_api_service_nspawn_test.go | 27 ++ tests/rkt_api_service_test.go | 304 ++++++------ tests/rkt_app_isolator_nspawn_test.go | 39 ++ tests/rkt_app_isolator_test.go | 16 +- tests/rkt_auth_test.go | 2 +- tests/rkt_caps_kvm_test.go | 27 ++ tests/rkt_caps_nspawn_test.go | 23 + tests/rkt_caps_test.go | 82 ++-- tests/rkt_cat_manifest_test.go | 2 +- tests/rkt_env_test.go | 2 +- tests/rkt_error_output_test.go | 2 +- tests/rkt_exec_test.go | 2 +- tests/rkt_fetch_test.go | 2 +- tests/rkt_gc_test.go | 2 +- tests/rkt_hostname_test.go | 2 +- tests/rkt_image_cat_manifest_test.go | 2 +- tests/rkt_image_dependencies_test.go | 2 +- tests/rkt_image_export_test.go | 2 +- tests/rkt_image_extract_test.go | 2 +- tests/rkt_image_gc_test.go | 2 +- tests/rkt_image_list_test.go | 2 +- tests/rkt_image_render_test.go | 2 +- tests/rkt_image_rm_test.go | 2 +- tests/rkt_interactive_test.go | 2 +- tests/rkt_list_test.go | 2 +- tests/rkt_metadata_service_test.go | 2 +- tests/rkt_net_kvm_test.go | 30 ++ tests/rkt_net_nspawn_test.go | 59 +++ tests/rkt_net_test.go | 645 ++++++++++++++------------ tests/rkt_non_root_test.go | 2 +- tests/rkt_os_arch_test.go | 2 +- tests/rkt_pid_file_kvm_test.go | 30 ++ tests/rkt_pid_file_nspawn_test.go | 30 ++ tests/rkt_pid_file_test.go | 135 +++--- tests/rkt_root_commands_test.go | 2 +- tests/rkt_service_file_test.go | 2 +- tests/rkt_socket_activation_test.go | 2 +- tests/rkt_socket_proxyd_test.go | 2 +- tests/rkt_stage1_loading_test.go | 2 +- tests/rkt_supplementary_gids_test.go | 2 +- tests/rkt_trust_test.go | 2 +- tests/rkt_userns_test.go | 49 +- tests/rkt_volume_nspawn_test.go | 23 + tests/rkt_volume_test.go | 98 ++-- 47 files changed, 1006 insertions(+), 675 deletions(-) create mode 100644 tests/rkt_api_service_nspawn_test.go create mode 100644 tests/rkt_app_isolator_nspawn_test.go create mode 100644 tests/rkt_caps_kvm_test.go create mode 100644 tests/rkt_caps_nspawn_test.go create mode 100644 tests/rkt_net_kvm_test.go create mode 100644 tests/rkt_net_nspawn_test.go create mode 100644 tests/rkt_pid_file_kvm_test.go create mode 100644 tests/rkt_pid_file_nspawn_test.go create mode 100644 tests/rkt_volume_nspawn_test.go diff --git a/tests/README.md b/tests/README.md index 9b4c3dd24f..b05a09199c 100644 --- a/tests/README.md +++ b/tests/README.md @@ -36,7 +36,7 @@ sudo gpasswd -a runner rkt ``` ./tests/build-and-run-tests.sh -f none -c -./tests/build-and-run-tests.sh -f src -s v229 -c +./tests/build-and-run-tests.sh -f kvm -c ``` #### Thread 2 @@ -60,7 +60,7 @@ It would be possible to add more tests with the following commands: ``` ./tests/build-and-run-tests.sh -f src -s v227 -c ./tests/build-and-run-tests.sh -f src -s master -c -./tests/build-and-run-tests.sh -f kvm -c +./tests/build-and-run-tests.sh -f src -s v229 -c ``` #### build-and-run-tests.sh parameters description diff --git a/tests/build-and-run-tests.sh b/tests/build-and-run-tests.sh index 2f0ddb397a..643fe18739 100755 --- a/tests/build-and-run-tests.sh +++ b/tests/build-and-run-tests.sh @@ -11,7 +11,7 @@ function cleanup { sudo umount "${mp}" done - for link in $(ip link | grep rkt | cut -d':' -f2); do + for link in $(ip link | grep rkt | cut -d':' -f2 | cut -d'@' -f1); do sudo ip link del "${link}" done sudo rm -rf /var/lib/cni/networks/* diff --git a/tests/rkt_api_service_bench_test.go b/tests/rkt_api_service_bench_test.go index e33745efbc..454996c363 100644 --- a/tests/rkt_api_service_bench_test.go +++ b/tests/rkt_api_service_bench_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_api_service_nspawn_test.go b/tests/rkt_api_service_nspawn_test.go new file mode 100644 index 0000000000..ac591ff6b8 --- /dev/null +++ b/tests/rkt_api_service_nspawn_test.go @@ -0,0 +1,27 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build coreos src + +package main + +import "testing" + +func TestAPIServiceListInspectPods(t *testing.T) { + NewAPIServiceListInspectPodsTest().Execute(t) +} + +func TestAPIServiceCgroup(t *testing.T) { + NewAPIServiceCgroupTest().Execute(t) +} diff --git a/tests/rkt_api_service_test.go b/tests/rkt_api_service_test.go index 0b69ee52b1..cd6a7b8ad5 100644 --- a/tests/rkt_api_service_test.go +++ b/tests/rkt_api_service_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main @@ -297,95 +297,97 @@ func TestAPIServiceGetInfo(t *testing.T) { } } -func TestAPIServiceListInspectPods(t *testing.T) { - ctx := testutils.NewRktRunCtx() - defer ctx.Cleanup() +func NewAPIServiceListInspectPodsTest() testutils.Test { + return testutils.TestFunc(func(t *testing.T) { + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() - svc := startAPIService(t, ctx) - defer stopAPIService(t, svc) + svc := startAPIService(t, ctx) + defer stopAPIService(t, svc) - c, conn := newAPIClientOrFail(t, "localhost:15441") - defer conn.Close() + c, conn := newAPIClientOrFail(t, "localhost:15441") + defer conn.Close() - resp, err := c.ListPods(context.Background(), &v1alpha.ListPodsRequest{}) - if err != nil { - t.Fatalf("Unexpected error: %v", err) - } + resp, err := c.ListPods(context.Background(), &v1alpha.ListPodsRequest{}) + if err != nil { + t.Fatalf("Unexpected error: %v", err) + } - if len(resp.Pods) != 0 { - t.Errorf("Unexpected result: %v, should see zero pods", resp.Pods) - } + if len(resp.Pods) != 0 { + t.Errorf("Unexpected result: %v, should see zero pods", resp.Pods) + } - patches := []string{"--exec=/inspect --print-msg=HELLO_API --exit-code=0"} - imageHash := patchImportAndFetchHash("rkt-inspect-print.aci", patches, t, ctx) - imgID, err := types.NewHash(imageHash) - if err != nil { - t.Fatalf("Cannot generate types.Hash from %v: %v", imageHash, err) - } - pm := schema.BlankPodManifest() - pm.Apps = []schema.RuntimeApp{ - { - Name: types.ACName("rkt-inspect"), - Image: schema.RuntimeImage{ - Name: types.MustACIdentifier("coreos.com/rkt-inspect"), - ID: *imgID, + patches := []string{"--exec=/inspect --print-msg=HELLO_API --exit-code=0"} + imageHash := patchImportAndFetchHash("rkt-inspect-print.aci", patches, t, ctx) + imgID, err := types.NewHash(imageHash) + if err != nil { + t.Fatalf("Cannot generate types.Hash from %v: %v", imageHash, err) + } + pm := schema.BlankPodManifest() + pm.Apps = []schema.RuntimeApp{ + { + Name: types.ACName("rkt-inspect"), + Image: schema.RuntimeImage{ + Name: types.MustACIdentifier("coreos.com/rkt-inspect"), + ID: *imgID, + }, + Annotations: []types.Annotation{{Name: types.ACIdentifier("app-test"), Value: "app-test"}}, }, - Annotations: []types.Annotation{{Name: types.ACIdentifier("app-test"), Value: "app-test"}}, - }, - } - pm.Annotations = []types.Annotation{{Name: types.ACIdentifier("test"), Value: "test"}} - manifestFile := generatePodManifestFile(t, pm) - defer os.Remove(manifestFile) + } + pm.Annotations = []types.Annotation{{Name: types.ACIdentifier("test"), Value: "test"}} + manifestFile := generatePodManifestFile(t, pm) + defer os.Remove(manifestFile) - runCmd := fmt.Sprintf("%s run --pod-manifest=%s", ctx.Cmd(), manifestFile) - waitOrFail(t, spawnOrFail(t, runCmd), 0) + runCmd := fmt.Sprintf("%s run --pod-manifest=%s", ctx.Cmd(), manifestFile) + waitOrFail(t, spawnOrFail(t, runCmd), 0) - time.Sleep(delta) + time.Sleep(delta) - gcCmd := fmt.Sprintf("%s gc --mark-only=true", ctx.Cmd()) - waitOrFail(t, spawnOrFail(t, gcCmd), 0) + gcCmd := fmt.Sprintf("%s gc --mark-only=true", ctx.Cmd()) + waitOrFail(t, spawnOrFail(t, gcCmd), 0) - gcTime := time.Now() + gcTime := time.Now() - // ListPods(detail=false). - resp, err = c.ListPods(context.Background(), &v1alpha.ListPodsRequest{}) - if err != nil { - t.Fatalf("Unexpected error: %v", err) - } + // ListPods(detail=false). + resp, err = c.ListPods(context.Background(), &v1alpha.ListPodsRequest{}) + if err != nil { + t.Fatalf("Unexpected error: %v", err) + } - if len(resp.Pods) == 0 { - t.Errorf("Unexpected result: %v, should see non-zero pods", resp.Pods) - } + if len(resp.Pods) == 0 { + t.Errorf("Unexpected result: %v, should see non-zero pods", resp.Pods) + } + + for _, p := range resp.Pods { + checkPodBasicsWithGCTime(t, ctx, p, gcTime) + + // Test InspectPod(). + inspectResp, err := c.InspectPod(context.Background(), &v1alpha.InspectPodRequest{Id: p.Id}) + if err != nil { + t.Fatalf("Unexpected error: %v", err) + } + checkPodDetails(t, ctx, inspectResp.Pod) - for _, p := range resp.Pods { - checkPodBasicsWithGCTime(t, ctx, p, gcTime) + // Test Apps. + for i, app := range p.Apps { + checkAnnotations(t, pm.Apps[i].Annotations, app.Annotations) + } + } - // Test InspectPod(). - inspectResp, err := c.InspectPod(context.Background(), &v1alpha.InspectPodRequest{Id: p.Id}) + // ListPods(detail=true). + resp, err = c.ListPods(context.Background(), &v1alpha.ListPodsRequest{Detail: true}) if err != nil { t.Fatalf("Unexpected error: %v", err) } - checkPodDetails(t, ctx, inspectResp.Pod) - // Test Apps. - for i, app := range p.Apps { - checkAnnotations(t, pm.Apps[i].Annotations, app.Annotations) + if len(resp.Pods) == 0 { + t.Errorf("Unexpected result: %v, should see non-zero pods", resp.Pods) } - } - - // ListPods(detail=true). - resp, err = c.ListPods(context.Background(), &v1alpha.ListPodsRequest{Detail: true}) - if err != nil { - t.Fatalf("Unexpected error: %v", err) - } - - if len(resp.Pods) == 0 { - t.Errorf("Unexpected result: %v, should see non-zero pods", resp.Pods) - } - for _, p := range resp.Pods { - checkPodDetails(t, ctx, p) - } + for _, p := range resp.Pods { + checkPodDetails(t, ctx, p) + } + }) } func TestAPIServiceListInspectImages(t *testing.T) { @@ -445,105 +447,107 @@ func TestAPIServiceListInspectImages(t *testing.T) { } } -func TestAPIServiceCgroup(t *testing.T) { - ctx := testutils.NewRktRunCtx() - defer ctx.Cleanup() +func NewAPIServiceCgroupTest() testutils.Test { + return testutils.TestFunc(func(t *testing.T) { + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() - svc := startAPIService(t, ctx) - defer stopAPIService(t, svc) + svc := startAPIService(t, ctx) + defer stopAPIService(t, svc) - c, conn := newAPIClientOrFail(t, "localhost:15441") - defer conn.Close() + c, conn := newAPIClientOrFail(t, "localhost:15441") + defer conn.Close() - aciFileName := patchTestACI("rkt-inspect-interactive.aci", "--exec=/inspect --read-stdin") - defer os.Remove(aciFileName) + aciFileName := patchTestACI("rkt-inspect-interactive.aci", "--exec=/inspect --read-stdin") + defer os.Remove(aciFileName) - runCmd := fmt.Sprintf("%s --insecure-options=image run --interactive %s", ctx.Cmd(), aciFileName) - child := spawnOrFail(t, runCmd) + runCmd := fmt.Sprintf("%s --insecure-options=image run --interactive %s", ctx.Cmd(), aciFileName) + child := spawnOrFail(t, runCmd) - var resp *v1alpha.ListPodsResponse - var err error - done := make(chan struct{}) + var resp *v1alpha.ListPodsResponse + var err error + done := make(chan struct{}) - // Wait the pods to be running. - go func() { - for { - // ListPods(detail=false). - resp, err = c.ListPods(context.Background(), &v1alpha.ListPodsRequest{}) - if err != nil { - t.Fatalf("Unexpected error: %v", err) - } + // Wait the pods to be running. + go func() { + for { + // ListPods(detail=false). + resp, err = c.ListPods(context.Background(), &v1alpha.ListPodsRequest{}) + if err != nil { + t.Fatalf("Unexpected error: %v", err) + } - if len(resp.Pods) != 0 { - allRunning := true - for _, p := range resp.Pods { - if p.State != v1alpha.PodState_POD_STATE_RUNNING { - allRunning = false - break + if len(resp.Pods) != 0 { + allRunning := true + for _, p := range resp.Pods { + if p.State != v1alpha.PodState_POD_STATE_RUNNING { + allRunning = false + break + } + } + if allRunning { + t.Logf("Pods are running") + close(done) + return } } - if allRunning { - t.Logf("Pods are running") - close(done) - return - } + t.Logf("Pods are not in RUNNING state") + time.Sleep(time.Second) } - t.Logf("Pods are not in RUNNING state") - time.Sleep(time.Second) - } - }() + }() - testutils.WaitOrTimeout(t, time.Second*30, done) + testutils.WaitOrTimeout(t, time.Second*30, done) - var cgroups []string + var cgroups []string - for _, p := range resp.Pods { - checkPodBasics(t, ctx, p) + for _, p := range resp.Pods { + checkPodBasics(t, ctx, p) - // Test InspectPod(). - inspectResp, err := c.InspectPod(context.Background(), &v1alpha.InspectPodRequest{Id: p.Id}) + // Test InspectPod(). + inspectResp, err := c.InspectPod(context.Background(), &v1alpha.InspectPodRequest{Id: p.Id}) + if err != nil { + t.Fatalf("Unexpected error: %v", err) + } + checkPodDetails(t, ctx, inspectResp.Pod) + if p.Cgroup != "" { + cgroups = append(cgroups, p.Cgroup) + } + } + + // ListPods(detail=true). Filter according to the cgroup. + resp, err = c.ListPods(context.Background(), &v1alpha.ListPodsRequest{ + Detail: true, + Filters: []*v1alpha.PodFilter{{Cgroups: cgroups}}, + }) if err != nil { t.Fatalf("Unexpected error: %v", err) } - checkPodDetails(t, ctx, inspectResp.Pod) - if p.Cgroup != "" { - cgroups = append(cgroups, p.Cgroup) - } - } - - // ListPods(detail=true). Filter according to the cgroup. - resp, err = c.ListPods(context.Background(), &v1alpha.ListPodsRequest{ - Detail: true, - Filters: []*v1alpha.PodFilter{{Cgroups: cgroups}}, - }) - if err != nil { - t.Fatalf("Unexpected error: %v", err) - } - - if len(resp.Pods) == 0 { - t.Errorf("Unexpected result: %v, should see non-zero pods", resp.Pods) - } - for _, p := range resp.Pods { - checkPodDetails(t, ctx, p) - } + if len(resp.Pods) == 0 { + t.Errorf("Unexpected result: %v, should see non-zero pods", resp.Pods) + } - // Terminate the pod. - if err := child.SendLine("Good bye"); err != nil { - t.Fatalf("Failed to send message to the pod: %v", err) - } - waitOrFail(t, child, 0) + for _, p := range resp.Pods { + checkPodDetails(t, ctx, p) + } - // Check that there's no cgroups returned for non-running pods. - cgroups = []string{} - resp, err = c.ListPods(context.Background(), &v1alpha.ListPodsRequest{}) - for _, p := range resp.Pods { - checkPodBasics(t, ctx, p) - if p.Cgroup != "" { - cgroups = append(cgroups, p.Cgroup) + // Terminate the pod. + if err := child.SendLine("Good bye"); err != nil { + t.Fatalf("Failed to send message to the pod: %v", err) } - } - if len(cgroups) != 0 { - t.Errorf("Unexpected cgroup returned by pods: %v", cgroups) - } + waitOrFail(t, child, 0) + + // Check that there's no cgroups returned for non-running pods. + cgroups = []string{} + resp, err = c.ListPods(context.Background(), &v1alpha.ListPodsRequest{}) + for _, p := range resp.Pods { + checkPodBasics(t, ctx, p) + if p.Cgroup != "" { + cgroups = append(cgroups, p.Cgroup) + } + } + if len(cgroups) != 0 { + t.Errorf("Unexpected cgroup returned by pods: %v", cgroups) + } + }) } diff --git a/tests/rkt_app_isolator_nspawn_test.go b/tests/rkt_app_isolator_nspawn_test.go new file mode 100644 index 0000000000..c7e53ee02d --- /dev/null +++ b/tests/rkt_app_isolator_nspawn_test.go @@ -0,0 +1,39 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build coreos src + +package main + +import ( + "fmt" + "os" + "testing" + + "github.com/coreos/rkt/tests/testutils" +) + +func TestCgroups(t *testing.T) { + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + t.Logf("Running test: %v", cgroupsTest.testName) + + aciFileName := patchTestACI("rkt-inspect-isolators.aci", cgroupsTest.aciBuildArgs...) + defer os.Remove(aciFileName) + + rktCmd := fmt.Sprintf("%s --insecure-options=image run --mds-register=false %s", ctx.Cmd(), aciFileName) + expectedLine := "check-cgroups: SUCCESS" + runRktAndCheckOutput(t, rktCmd, expectedLine, false) +} diff --git a/tests/rkt_app_isolator_test.go b/tests/rkt_app_isolator_test.go index c89bfdbb80..d5c6e441d3 100644 --- a/tests/rkt_app_isolator_test.go +++ b/tests/rkt_app_isolator_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main @@ -102,17 +102,3 @@ func TestAppIsolatorCPU(t *testing.T) { expectedLine = "CPU Quota: " + strconv.Itoa(900) runRktAndCheckOutput(t, rktCmd, expectedLine, false) } - -func TestCgroups(t *testing.T) { - ctx := testutils.NewRktRunCtx() - defer ctx.Cleanup() - - t.Logf("Running test: %v", cgroupsTest.testName) - - aciFileName := patchTestACI("rkt-inspect-isolators.aci", cgroupsTest.aciBuildArgs...) - defer os.Remove(aciFileName) - - rktCmd := fmt.Sprintf("%s --insecure-options=image run --mds-register=false %s", ctx.Cmd(), aciFileName) - expectedLine := "check-cgroups: SUCCESS" - runRktAndCheckOutput(t, rktCmd, expectedLine, false) -} diff --git a/tests/rkt_auth_test.go b/tests/rkt_auth_test.go index d3a7ccf88c..33fe70831b 100644 --- a/tests/rkt_auth_test.go +++ b/tests/rkt_auth_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_caps_kvm_test.go b/tests/rkt_caps_kvm_test.go new file mode 100644 index 0000000000..b30a108319 --- /dev/null +++ b/tests/rkt_caps_kvm_test.go @@ -0,0 +1,27 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build kvm + +package main + +import "testing" + +func TestCaps(t *testing.T) { + // KVM is running VMs as stage1 pods, so root has access to all VM options. + // The case with access to PID 1 is skipped... + // KVM flavor runs systemd stage1 with full capabilities in stage1 (pid=1) + // so expect every capability enabled + NewCapsTest(true, []int{2}).Execute(t) +} diff --git a/tests/rkt_caps_nspawn_test.go b/tests/rkt_caps_nspawn_test.go new file mode 100644 index 0000000000..c85aa7216e --- /dev/null +++ b/tests/rkt_caps_nspawn_test.go @@ -0,0 +1,23 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build coreos src + +package main + +import "testing" + +func TestCaps(t *testing.T) { + NewCapsTest(false, []int{1, 2}).Execute(t) +} diff --git a/tests/rkt_caps_test.go b/tests/rkt_caps_test.go index a0a2aec818..961a50f7c8 100644 --- a/tests/rkt_caps_test.go +++ b/tests/rkt_caps_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main @@ -75,46 +75,54 @@ var capsTests = []struct { }, } -func TestCaps(t *testing.T) { - ctx := testutils.NewRktRunCtx() - defer ctx.Cleanup() - - for i, tt := range capsTests { - stage1Args := []string{"--exec=/inspect --print-caps-pid=1 --print-user"} - stage2Args := []string{"--exec=/inspect --print-caps-pid=0 --print-user"} - if tt.capIsolator != "" { - stage1Args = append(stage1Args, "--capability="+tt.capIsolator) - stage2Args = append(stage2Args, "--capability="+tt.capIsolator) - } - stage1FileName := patchTestACI("rkt-inspect-print-caps-stage1.aci", stage1Args...) - defer os.Remove(stage1FileName) - stage2FileName := patchTestACI("rkt-inspect-print-caps-stage2.aci", stage2Args...) - defer os.Remove(stage2FileName) - stageFileNames := []string{stage1FileName, stage2FileName} - - for _, stage := range []int{1, 2} { - t.Logf("Running test #%v: %v [stage %v]", i, tt.testName, stage) - - cmd := fmt.Sprintf("%s --debug --insecure-options=image run --mds-register=false --set-env=CAPABILITY=%d %s", ctx.Cmd(), int(tt.capa), stageFileNames[stage-1]) - child := spawnOrFail(t, cmd) - - expectedLine := tt.capa.String() - if (stage == 1 && tt.capInStage1Expected) || (stage == 2 && tt.capInStage2Expected) { - expectedLine += "=enabled" - } else { - expectedLine += "=disabled" - } - if err := expectWithOutput(child, expectedLine); err != nil { - t.Fatalf("Expected %q but not found: %v", expectedLine, err) +// CommonTestCaps creates a new capabilities test fixture for the given stages. +func NewCapsTest(hasStage1FullCaps bool, stages []int) testutils.Test { + return testutils.TestFunc(func(t *testing.T) { + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + for i, tt := range capsTests { + stage1Args := []string{"--exec=/inspect --print-caps-pid=1 --print-user"} + stage2Args := []string{"--exec=/inspect --print-caps-pid=0 --print-user"} + if tt.capIsolator != "" { + stage1Args = append(stage1Args, "--capability="+tt.capIsolator) + stage2Args = append(stage2Args, "--capability="+tt.capIsolator) } + stage1FileName := patchTestACI("rkt-inspect-print-caps-stage1.aci", stage1Args...) + defer os.Remove(stage1FileName) + stage2FileName := patchTestACI("rkt-inspect-print-caps-stage2.aci", stage2Args...) + defer os.Remove(stage2FileName) + stageFileNames := []string{stage1FileName, stage2FileName} + + for _, stage := range stages { + t.Logf("Running test #%v: %v [stage %v]", i, tt.testName, stage) - if err := expectWithOutput(child, "User: uid=0 euid=0 gid=0 egid=0"); err != nil { - t.Fatalf("Expected user 0 but not found: %v", err) + cmd := fmt.Sprintf("%s --debug --insecure-options=image run --mds-register=false --set-env=CAPABILITY=%d %s", ctx.Cmd(), int(tt.capa), stageFileNames[stage-1]) + child := spawnOrFail(t, cmd) + + expectedLine := tt.capa.String() + + capInStage1Expected := tt.capInStage1Expected || hasStage1FullCaps + + if (stage == 1 && capInStage1Expected) || (stage == 2 && tt.capInStage2Expected) { + expectedLine += "=enabled" + } else { + expectedLine += "=disabled" + } + + if err := expectWithOutput(child, expectedLine); err != nil { + t.Fatalf("Expected %q but not found: %v", expectedLine, err) + } + + if err := expectWithOutput(child, "User: uid=0 euid=0 gid=0 egid=0"); err != nil { + t.Fatalf("Expected user 0 but not found: %v", err) + } + + waitOrFail(t, child, 0) } - waitOrFail(t, child, 0) + ctx.Reset() } - ctx.Reset() - } + }) } func TestCapsNonRoot(t *testing.T) { diff --git a/tests/rkt_cat_manifest_test.go b/tests/rkt_cat_manifest_test.go index 6189b97113..89a4c188d9 100644 --- a/tests/rkt_cat_manifest_test.go +++ b/tests/rkt_cat_manifest_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_env_test.go b/tests/rkt_env_test.go index da6b7a3804..4d4b583f01 100644 --- a/tests/rkt_env_test.go +++ b/tests/rkt_env_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_error_output_test.go b/tests/rkt_error_output_test.go index d9bf374708..153a15ea21 100644 --- a/tests/rkt_error_output_test.go +++ b/tests/rkt_error_output_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_exec_test.go b/tests/rkt_exec_test.go index 11aa2a872a..957f2beebb 100644 --- a/tests/rkt_exec_test.go +++ b/tests/rkt_exec_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_fetch_test.go b/tests/rkt_fetch_test.go index c4e7ca3d7c..4834735668 100644 --- a/tests/rkt_fetch_test.go +++ b/tests/rkt_fetch_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_gc_test.go b/tests/rkt_gc_test.go index bc53e7c2c0..c7b1b53b39 100644 --- a/tests/rkt_gc_test.go +++ b/tests/rkt_gc_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_hostname_test.go b/tests/rkt_hostname_test.go index 4c9508dd5a..a65ad8e3c6 100644 --- a/tests/rkt_hostname_test.go +++ b/tests/rkt_hostname_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_image_cat_manifest_test.go b/tests/rkt_image_cat_manifest_test.go index c83f1875d5..7521a9377f 100644 --- a/tests/rkt_image_cat_manifest_test.go +++ b/tests/rkt_image_cat_manifest_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_image_dependencies_test.go b/tests/rkt_image_dependencies_test.go index 7437911a25..7751fb13cf 100644 --- a/tests/rkt_image_dependencies_test.go +++ b/tests/rkt_image_dependencies_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_image_export_test.go b/tests/rkt_image_export_test.go index 19661781d2..07ad79f79d 100644 --- a/tests/rkt_image_export_test.go +++ b/tests/rkt_image_export_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_image_extract_test.go b/tests/rkt_image_extract_test.go index 9ce3b36423..9c8d4fb77b 100644 --- a/tests/rkt_image_extract_test.go +++ b/tests/rkt_image_extract_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_image_gc_test.go b/tests/rkt_image_gc_test.go index 57c5adb2be..3f6e68c747 100644 --- a/tests/rkt_image_gc_test.go +++ b/tests/rkt_image_gc_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_image_list_test.go b/tests/rkt_image_list_test.go index 99c894070f..f9e2a262ed 100644 --- a/tests/rkt_image_list_test.go +++ b/tests/rkt_image_list_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_image_render_test.go b/tests/rkt_image_render_test.go index 6168bbc930..b04233e525 100644 --- a/tests/rkt_image_render_test.go +++ b/tests/rkt_image_render_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_image_rm_test.go b/tests/rkt_image_rm_test.go index db3d593482..160a01c1ee 100644 --- a/tests/rkt_image_rm_test.go +++ b/tests/rkt_image_rm_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_interactive_test.go b/tests/rkt_interactive_test.go index 7cb4fe4ea8..f9c92f9c3a 100644 --- a/tests/rkt_interactive_test.go +++ b/tests/rkt_interactive_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_list_test.go b/tests/rkt_list_test.go index 271bf15d51..863eadc473 100644 --- a/tests/rkt_list_test.go +++ b/tests/rkt_list_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_metadata_service_test.go b/tests/rkt_metadata_service_test.go index 830b3c8218..5bd24a2dc3 100644 --- a/tests/rkt_metadata_service_test.go +++ b/tests/rkt_metadata_service_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_net_kvm_test.go b/tests/rkt_net_kvm_test.go new file mode 100644 index 0000000000..59ecb3680d --- /dev/null +++ b/tests/rkt_net_kvm_test.go @@ -0,0 +1,30 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build kvm + +package main + +import "testing" + +func TestNetDefaultPortFwdConnectivity(t *testing.T) { + NewNetDefaultPortFwdConnectivityTest( + PortFwdCase{"172.16.28.1", "--net=default", true}, + ).Execute(t) +} + +func TestNetCustomPtp(t *testing.T) { + // PTP means connection Point-To-Point. That is, connections to other pods/containers should be forbidden + NewNetCustomPtpTest(false) +} diff --git a/tests/rkt_net_nspawn_test.go b/tests/rkt_net_nspawn_test.go new file mode 100644 index 0000000000..e436727351 --- /dev/null +++ b/tests/rkt_net_nspawn_test.go @@ -0,0 +1,59 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build coreos src + +package main + +import "testing" + +func TestNetHost(t *testing.T) { + NewNetHostTest().Execute(t) +} + +func TestNetHostConnectivity(t *testing.T) { + NewNetHostConnectivityTest().Execute(t) +} + +func TestNetDefaultPortFwdConnectivity(t *testing.T) { + NewNetDefaultPortFwdConnectivityTest( + PortFwdCase{"172.16.28.1", "--net=default", true}, + PortFwdCase{"127.0.0.1", "--net=default", true}, + ).Execute(t) +} + +func TestNetNone(t *testing.T) { + NewNetNoneTest().Execute(t) +} + +func TestNetCustomMacvlan(t *testing.T) { + NewNetCustomMacvlanTest().Execute(t) +} + +func TestNetCustomBridge(t *testing.T) { + NewNetCustomBridgeTest().Execute(t) +} + +func TestNetOverride(t *testing.T) { + NewNetOverrideTest().Execute(t) +} + +func TestNetCustomPtp(t *testing.T) { + // PTP means connection Point-To-Point. That is, connections to other pods/containers should be forbidden + NewNetCustomPtpTest(true).Execute(t) +} + +func TestNetDefaultConnectivity(t *testing.T) { + NewNetDefaultConnectivityTest().Execute(t) +} diff --git a/tests/rkt_net_test.go b/tests/rkt_net_test.go index d882c3c93a..3cb7c8d14f 100644 --- a/tests/rkt_net_test.go +++ b/tests/rkt_net_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main @@ -35,33 +35,35 @@ import ( * --- * Container must have the same network namespace as the host */ -func TestNetHost(t *testing.T) { - testImageArgs := []string{"--exec=/inspect --print-netns"} - testImage := patchTestACI("rkt-inspect-networking.aci", testImageArgs...) - defer os.Remove(testImage) +func NewNetHostTest() testutils.Test { + return testutils.TestFunc(func(t *testing.T) { + testImageArgs := []string{"--exec=/inspect --print-netns"} + testImage := patchTestACI("rkt-inspect-networking.aci", testImageArgs...) + defer os.Remove(testImage) - ctx := testutils.NewRktRunCtx() - defer ctx.Cleanup() + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() - cmd := fmt.Sprintf("%s --net=host --debug --insecure-options=image run --mds-register=false %s", ctx.Cmd(), testImage) - child := spawnOrFail(t, cmd) - ctx.RegisterChild(child) - defer waitOrFail(t, child, 0) + cmd := fmt.Sprintf("%s --net=host --debug --insecure-options=image run --mds-register=false %s", ctx.Cmd(), testImage) + child := spawnOrFail(t, cmd) + ctx.RegisterChild(child) + defer waitOrFail(t, child, 0) - expectedRegex := `NetNS: (net:\[\d+\])` - result, out, err := expectRegexWithOutput(child, expectedRegex) - if err != nil { - t.Fatalf("Error: %v\nOutput: %v", err, out) - } + expectedRegex := `NetNS: (net:\[\d+\])` + result, out, err := expectRegexWithOutput(child, expectedRegex) + if err != nil { + t.Fatalf("Error: %v\nOutput: %v", err, out) + } - ns, err := os.Readlink("/proc/self/ns/net") - if err != nil { - t.Fatalf("Cannot evaluate NetNS symlink: %v", err) - } + ns, err := os.Readlink("/proc/self/ns/net") + if err != nil { + t.Fatalf("Cannot evaluate NetNS symlink: %v", err) + } - if nsChanged := ns != result[1]; nsChanged { - t.Fatalf("container left host netns") - } + if nsChanged := ns != result[1]; nsChanged { + t.Fatalf("container left host netns") + } + }) } /* @@ -70,52 +72,54 @@ func TestNetHost(t *testing.T) { * Container launches http server which must be reachable by the host via the * localhost address */ -func TestNetHostConnectivity(t *testing.T) { - logger.SetLogger(t) +func NewNetHostConnectivityTest() testutils.Test { + return testutils.TestFunc(func(t *testing.T) { + logger.SetLogger(t) - httpPort, err := testutils.GetNextFreePort4() - if err != nil { - t.Fatalf("%v", err) - } - httpServeAddr := fmt.Sprintf("0.0.0.0:%v", httpPort) - httpGetAddr := fmt.Sprintf("http://127.0.0.1:%v", httpPort) + httpPort, err := testutils.GetNextFreePort4() + if err != nil { + t.Fatalf("%v", err) + } + httpServeAddr := fmt.Sprintf("0.0.0.0:%v", httpPort) + httpGetAddr := fmt.Sprintf("http://127.0.0.1:%v", httpPort) - testImageArgs := []string{"--exec=/inspect --serve-http=" + httpServeAddr} - testImage := patchTestACI("rkt-inspect-networking.aci", testImageArgs...) - defer os.Remove(testImage) + testImageArgs := []string{"--exec=/inspect --serve-http=" + httpServeAddr} + testImage := patchTestACI("rkt-inspect-networking.aci", testImageArgs...) + defer os.Remove(testImage) - ctx := testutils.NewRktRunCtx() - defer ctx.Cleanup() + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() - cmd := fmt.Sprintf("%s --net=host --debug --insecure-options=image run --mds-register=false %s", ctx.Cmd(), testImage) - child := spawnOrFail(t, cmd) - ctx.RegisterChild(child) + cmd := fmt.Sprintf("%s --net=host --debug --insecure-options=image run --mds-register=false %s", ctx.Cmd(), testImage) + child := spawnOrFail(t, cmd) + ctx.RegisterChild(child) - ga := testutils.NewGoroutineAssistant(t) - ga.Add(2) + ga := testutils.NewGoroutineAssistant(t) + ga.Add(2) - // Child opens the server - go func() { - defer ga.Done() - ga.WaitOrFail(child) - }() + // Child opens the server + go func() { + defer ga.Done() + ga.WaitOrFail(child) + }() - // Host connects to the child - go func() { - defer ga.Done() - expectedRegex := `serving on` - _, out, err := expectRegexWithOutput(child, expectedRegex) - if err != nil { - ga.Fatalf("Error: %v\nOutput: %v", err, out) - } - body, err := testutils.HTTPGet(httpGetAddr) - if err != nil { - ga.Fatalf("%v\n", err) - } - t.Logf("HTTP-Get received: %s", body) - }() + // Host connects to the child + go func() { + defer ga.Done() + expectedRegex := `serving on` + _, out, err := expectRegexWithOutput(child, expectedRegex) + if err != nil { + ga.Fatalf("Error: %v\nOutput: %v", err, out) + } + body, err := testutils.HTTPGet(httpGetAddr) + if err != nil { + ga.Fatalf("%v\n", err) + } + t.Logf("HTTP-Get received: %s", body) + }() - ga.Wait() + ga.Wait() + }) } /* @@ -123,45 +127,47 @@ func TestNetHostConnectivity(t *testing.T) { * --- * must be in an empty netns */ -func TestNetNone(t *testing.T) { - testImageArgs := []string{"--exec=/inspect --print-netns --print-iface-count"} - testImage := patchTestACI("rkt-inspect-networking.aci", testImageArgs...) - defer os.Remove(testImage) +func NewNetNoneTest() testutils.Test { + return testutils.TestFunc(func(t *testing.T) { + testImageArgs := []string{"--exec=/inspect --print-netns --print-iface-count"} + testImage := patchTestACI("rkt-inspect-networking.aci", testImageArgs...) + defer os.Remove(testImage) - ctx := testutils.NewRktRunCtx() - defer ctx.Cleanup() + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() - cmd := fmt.Sprintf("%s --debug --insecure-options=image run --net=none --mds-register=false %s", ctx.Cmd(), testImage) + cmd := fmt.Sprintf("%s --debug --insecure-options=image run --net=none --mds-register=false %s", ctx.Cmd(), testImage) - child := spawnOrFail(t, cmd) - defer waitOrFail(t, child, 0) - expectedRegex := `NetNS: (net:\[\d+\])` - result, out, err := expectRegexWithOutput(child, expectedRegex) - if err != nil { - t.Fatalf("Error: %v\nOutput: %v", err, out) - } + child := spawnOrFail(t, cmd) + defer waitOrFail(t, child, 0) + expectedRegex := `NetNS: (net:\[\d+\])` + result, out, err := expectRegexWithOutput(child, expectedRegex) + if err != nil { + t.Fatalf("Error: %v\nOutput: %v", err, out) + } - ns, err := os.Readlink("/proc/self/ns/net") - if err != nil { - t.Fatalf("Cannot evaluate NetNS symlink: %v", err) - } + ns, err := os.Readlink("/proc/self/ns/net") + if err != nil { + t.Fatalf("Cannot evaluate NetNS symlink: %v", err) + } - if nsChanged := ns != result[1]; !nsChanged { - t.Fatalf("container did not leave host netns") - } + if nsChanged := ns != result[1]; !nsChanged { + t.Fatalf("container did not leave host netns") + } - expectedRegex = `Interface count: (\d+)` - result, out, err = expectRegexWithOutput(child, expectedRegex) - if err != nil { - t.Fatalf("Error: %v\nOutput: %v", err, out) - } - ifaceCount, err := strconv.Atoi(result[1]) - if err != nil { - t.Fatalf("Error parsing interface count: %v\nOutput: %v", err, out) - } - if ifaceCount != 1 { - t.Fatalf("Interface count must be 1 not %q", ifaceCount) - } + expectedRegex = `Interface count: (\d+)` + result, out, err = expectRegexWithOutput(child, expectedRegex) + if err != nil { + t.Fatalf("Error: %v\nOutput: %v", err, out) + } + ifaceCount, err := strconv.Atoi(result[1]) + if err != nil { + t.Fatalf("Error parsing interface count: %v\nOutput: %v", err, out) + } + if ifaceCount != 1 { + t.Fatalf("Interface count must be 1 not %q", ifaceCount) + } + }) } /* @@ -210,71 +216,73 @@ func TestNetDefaultNetNS(t *testing.T) { * default network, which is NATed * TODO: test connection to host on an outside interface */ -func TestNetDefaultConnectivity(t *testing.T) { - ctx := testutils.NewRktRunCtx() - defer ctx.Cleanup() - - f := func(argument string) { - httpPort, err := testutils.GetNextFreePort4() - if err != nil { - t.Fatalf("%v", err) - } - httpServeAddr := fmt.Sprintf("0.0.0.0:%v", httpPort) - httpServeTimeout := 30 - - nonLoIPv4, err := testutils.GetNonLoIfaceIPv4() - if err != nil { - t.Fatalf("%v", err) - } - if nonLoIPv4 == "" { - t.Skipf("Can not find any NAT'able IPv4 on the host, skipping..") - } - - httpGetAddr := fmt.Sprintf("http://%v:%v", nonLoIPv4, httpPort) - t.Log("Telling the child to connect via", httpGetAddr) - - testImageArgs := []string{fmt.Sprintf("--exec=/inspect --get-http=%v", httpGetAddr)} - testImage := patchTestACI("rkt-inspect-networking.aci", testImageArgs...) - defer os.Remove(testImage) +func NewNetDefaultConnectivityTest() testutils.Test { + return testutils.TestFunc(func(t *testing.T) { + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() - hostname, err := os.Hostname() - if err != nil { - t.Fatalf("Error getting hostname: %v", err) - } - - ga := testutils.NewGoroutineAssistant(t) - ga.Add(2) + f := func(argument string) { + httpPort, err := testutils.GetNextFreePort4() + if err != nil { + t.Fatalf("%v", err) + } + httpServeAddr := fmt.Sprintf("0.0.0.0:%v", httpPort) + httpServeTimeout := 30 - // Host opens the server - go func() { - defer ga.Done() - err := testutils.HTTPServe(httpServeAddr, httpServeTimeout) + nonLoIPv4, err := testutils.GetNonLoIfaceIPv4() if err != nil { - ga.Fatalf("Error during HTTPServe: %v", err) + t.Fatalf("%v", err) + } + if nonLoIPv4 == "" { + t.Skipf("Can not find any NAT'able IPv4 on the host, skipping..") } - }() - // Child connects to host - go func() { - defer ga.Done() - cmd := fmt.Sprintf("%s --debug --insecure-options=image run %s --mds-register=false %s", ctx.Cmd(), argument, testImage) - child := ga.SpawnOrFail(cmd) - defer ga.WaitOrFail(child) + httpGetAddr := fmt.Sprintf("http://%v:%v", nonLoIPv4, httpPort) + t.Log("Telling the child to connect via", httpGetAddr) + + testImageArgs := []string{fmt.Sprintf("--exec=/inspect --get-http=%v", httpGetAddr)} + testImage := patchTestACI("rkt-inspect-networking.aci", testImageArgs...) + defer os.Remove(testImage) - expectedRegex := `HTTP-Get received: (.*)\r` - result, out, err := expectRegexWithOutput(child, expectedRegex) + hostname, err := os.Hostname() if err != nil { - ga.Fatalf("Error: %v\nOutput: %v", err, out) - } - if result[1] != hostname { - ga.Fatalf("Hostname received by client `%v` doesn't match `%v`", result[1], hostname) + t.Fatalf("Error getting hostname: %v", err) } - }() - ga.Wait() - } - f("--net=default") - f("") + ga := testutils.NewGoroutineAssistant(t) + ga.Add(2) + + // Host opens the server + go func() { + defer ga.Done() + err := testutils.HTTPServe(httpServeAddr, httpServeTimeout) + if err != nil { + ga.Fatalf("Error during HTTPServe: %v", err) + } + }() + + // Child connects to host + go func() { + defer ga.Done() + cmd := fmt.Sprintf("%s --debug --insecure-options=image run %s --mds-register=false %s", ctx.Cmd(), argument, testImage) + child := ga.SpawnOrFail(cmd) + defer ga.WaitOrFail(child) + + expectedRegex := `HTTP-Get received: (.*)\r` + result, out, err := expectRegexWithOutput(child, expectedRegex) + if err != nil { + ga.Fatalf("Error: %v\nOutput: %v", err, out) + } + if result[1] != hostname { + ga.Fatalf("Hostname received by client `%v` doesn't match `%v`", result[1], hostname) + } + }() + + ga.Wait() + } + f("--net=default") + f("") + }) } /* @@ -304,7 +312,7 @@ func TestNetDefaultRestrictedConnectivity(t *testing.T) { cmd := fmt.Sprintf("%s --debug --insecure-options=image run %s --mds-register=false %s", ctx.Cmd(), argument, testImage) child := spawnOrFail(t, cmd) - expectedRegex := `IPv4: (.*)\r` + expectedRegex := `IPv4: (\d+\.\d+\.\d+\.\d+)` result, out, err := expectRegexWithOutput(child, expectedRegex) if err != nil { t.Fatalf("Error: %v\nOutput: %v", err, out) @@ -340,80 +348,95 @@ func TestNetDefaultRestrictedConnectivity(t *testing.T) { f("--net=default-restricted") } -/* - * Default net port forwarding connectivity - * --- - * Container launches http server on all its interfaces - * Host must be able to connect to container's http server on it's own interfaces - */ -func TestNetDefaultPortFwdConnectivity(t *testing.T) { - ctx := testutils.NewRktRunCtx() - defer ctx.Cleanup() +type PortFwdCase struct { + HttpGetIP string + RktArg string + ShouldSucceed bool +} + +func (ct PortFwdCase) Execute(t *testing.T, ctx *testutils.RktRunCtx) { bannedPorts := make(map[int]struct{}, 0) - f := func(httpGetIP string, rktArg string, shouldSucceed bool) { - httpPort, err := testutils.GetNextFreePort4Banned(bannedPorts) - if err != nil { - t.Fatalf("%v", err) - } - bannedPorts[httpPort] = struct{}{} + httpPort, err := testutils.GetNextFreePort4Banned(bannedPorts) + if err != nil { + t.Fatalf("%v", err) + } + bannedPorts[httpPort] = struct{}{} - httpServeAddr := fmt.Sprintf("0.0.0.0:%d", httpPort) - testImageArgs := []string{ - fmt.Sprintf("--ports=http,protocol=tcp,port=%d", httpPort), - fmt.Sprintf("--exec=/inspect --serve-http=%v", httpServeAddr), - } - testImage := patchTestACI("rkt-inspect-networking.aci", testImageArgs...) - defer os.Remove(testImage) + httpServeAddr := fmt.Sprintf("0.0.0.0:%d", httpPort) + testImageArgs := []string{ + fmt.Sprintf("--ports=http,protocol=tcp,port=%d", httpPort), + fmt.Sprintf("--exec=/inspect --serve-http=%v", httpServeAddr), + } + testImage := patchTestACI("rkt-inspect-networking.aci", testImageArgs...) + defer os.Remove(testImage) - cmd := fmt.Sprintf( - "%s --debug --insecure-options=image run --port=http:%d %s --mds-register=false %s", - ctx.Cmd(), httpPort, rktArg, testImage) - child := spawnOrFail(t, cmd) + cmd := fmt.Sprintf( + "%s --debug --insecure-options=image run --port=http:%d %s --mds-register=false %s", + ctx.Cmd(), httpPort, ct.RktArg, testImage) + child := spawnOrFail(t, cmd) - httpGetAddr := fmt.Sprintf("http://%v:%v", httpGetIP, httpPort) + httpGetAddr := fmt.Sprintf("http://%v:%v", ct.HttpGetIP, httpPort) - ga := testutils.NewGoroutineAssistant(t) - ga.Add(2) + ga := testutils.NewGoroutineAssistant(t) + ga.Add(2) - // Child opens the server - go func() { - defer ga.Done() - ga.WaitOrFail(child) - }() + // Child opens the server + go func() { + defer ga.Done() + ga.WaitOrFail(child) + }() - // Host connects to the child via the forward port on localhost - go func() { - defer ga.Done() - expectedRegex := `serving on` - _, out, err := expectRegexWithOutput(child, expectedRegex) - if err != nil { - ga.Fatalf("Error: %v\nOutput: %v", err, out) - } - body, err := testutils.HTTPGet(httpGetAddr) - switch { - case err != nil && shouldSucceed: - ga.Fatalf("%v\n", err) - case err == nil && !shouldSucceed: - ga.Fatalf("HTTP-Get to %q should have failed! But received %q", httpGetAddr, body) - case err != nil && !shouldSucceed: - child.Close() - fallthrough - default: - t.Logf("HTTP-Get received: %s", body) - } - }() + // Host connects to the child via the forward port on localhost + go func() { + defer ga.Done() + expectedRegex := `serving on` + _, out, err := expectRegexWithOutput(child, expectedRegex) + if err != nil { + ga.Fatalf("Error: %v\nOutput: %v", err, out) + } + body, err := testutils.HTTPGet(httpGetAddr) + switch { + case err != nil && ct.ShouldSucceed: + ga.Fatalf("%v\n", err) + case err == nil && !ct.ShouldSucceed: + ga.Fatalf("HTTP-Get to %q should have failed! But received %q", httpGetAddr, body) + case err != nil && !ct.ShouldSucceed: + child.Close() + fallthrough + default: + t.Logf("HTTP-Get received: %s", body) + } + }() - ga.Wait() - } - f("172.16.28.1", "--net=default", true) - f("127.0.0.1", "--net=default", true) + ga.Wait() // TODO: ensure that default-restricted is not accessible from non-host // f("172.16.28.1", "--net=default-restricted", true) // f("127.0.0.1", "--net=default-restricted", true) } +type portFwdTest []PortFwdCase + +func (ct portFwdTest) Execute(t *testing.T) { + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + for _, testCase := range ct { + testCase.Execute(t, ctx) + } +} + +/* + * Default net port forwarding connectivity + * --- + * Container launches http server on all its interfaces + * Host must be able to connect to container's http server on it's own interfaces + */ +func NewNetDefaultPortFwdConnectivityTest(cases ...PortFwdCase) testutils.Test { + return portFwdTest(cases) +} + func writeNetwork(t *testing.T, net networkTemplateT, netd string) error { var err error path := filepath.Join(netd, net.Name+".conf") @@ -526,7 +549,7 @@ func testNetCustomDual(t *testing.T, nt networkTemplateT) { ga.Fatalf("Error: %v\nOutput: %v", err, out) } container1IPv4 <- result[1] - expectedRegex = `(rkt-.*): serving on` + expectedRegex = ` ([a-zA-Z0-9\-]*): serving on` result, out, err = expectRegexTimeoutWithOutput(child, expectedRegex, 30*time.Second) if err != nil { ga.Fatalf("Error: %v\nOutput: %v", err, out) @@ -549,7 +572,7 @@ func testNetCustomDual(t *testing.T, nt networkTemplateT) { defer ga.WaitOrFail(child) expectedHostname := <-container1Hostname - expectedRegex := `HTTP-Get received: (.*)\r` + expectedRegex := `HTTP-Get received: (.*?)\r` result, out, err := expectRegexTimeoutWithOutput(child, expectedRegex, 20*time.Second) if err != nil { ga.Fatalf("Error: %v\nOutput: %v", err, out) @@ -620,7 +643,7 @@ func testNetCustomNatConnectivity(t *testing.T, nt networkTemplateT) { child := ga.SpawnOrFail(cmd) defer ga.WaitOrFail(child) - expectedRegex := `HTTP-Get received: (.*)\r` + expectedRegex := `HTTP-Get received: (.*?)\r` result, out, err := expectRegexWithOutput(child, expectedRegex) if err != nil { ga.Fatalf("Error: %v\nOutput: %v", err, out) @@ -633,115 +656,125 @@ func testNetCustomNatConnectivity(t *testing.T, nt networkTemplateT) { ga.Wait() } -func TestNetCustomPtp(t *testing.T) { - nt := networkTemplateT{ - Name: "ptp0", - Type: "ptp", - IpMasq: true, - Ipam: ipamTemplateT{ - Type: "host-local", - Subnet: "11.11.1.0/24", - Routes: []map[string]string{ - {"dst": "0.0.0.0/0"}, +func NewNetCustomPtpTest(runCustomDual bool) testutils.Test { + return testutils.TestFunc(func(t *testing.T) { + nt := networkTemplateT{ + Name: "ptp0", + Type: "ptp", + IpMasq: true, + Ipam: ipamTemplateT{ + Type: "host-local", + Subnet: "11.11.1.0/24", + Routes: []map[string]string{ + {"dst": "0.0.0.0/0"}, + }, }, - }, - } - testNetCustomNatConnectivity(t, nt) - testNetCustomDual(t, nt) + } + testNetCustomNatConnectivity(t, nt) + if runCustomDual { + testNetCustomDual(t, nt) + } + }) } -func TestNetCustomMacvlan(t *testing.T) { - iface, _, err := testutils.GetNonLoIfaceWithAddrs(netlink.FAMILY_V4) - if err != nil { - t.Fatalf("Error while getting non-lo host interface: %v\n", err) - } - if iface.Name == "" { - t.Skipf("Cannot run test without non-lo host interface") - } +func NewNetCustomMacvlanTest() testutils.Test { + return testutils.TestFunc(func(t *testing.T) { + iface, _, err := testutils.GetNonLoIfaceWithAddrs(netlink.FAMILY_V4) + if err != nil { + t.Fatalf("Error while getting non-lo host interface: %v\n", err) + } + if iface.Name == "" { + t.Skipf("Cannot run test without non-lo host interface") + } - nt := networkTemplateT{ - Name: "macvlan0", - Type: "macvlan", - Master: iface.Name, - Ipam: ipamTemplateT{ - Type: "host-local", - Subnet: "11.11.2.0/24", - }, - } - testNetCustomDual(t, nt) + nt := networkTemplateT{ + Name: "macvlan0", + Type: "macvlan", + Master: iface.Name, + Ipam: ipamTemplateT{ + Type: "host-local", + Subnet: "11.11.2.0/24", + }, + } + testNetCustomDual(t, nt) + }) } -func TestNetCustomBridge(t *testing.T) { - iface, _, err := testutils.GetNonLoIfaceWithAddrs(netlink.FAMILY_V4) - if err != nil { - t.Fatalf("Error while getting non-lo host interface: %v\n", err) - } - if iface.Name == "" { - t.Skipf("Cannot run test without non-lo host interface") - } +func NewNetCustomBridgeTest() testutils.Test { + return testutils.TestFunc(func(t *testing.T) { + iface, _, err := testutils.GetNonLoIfaceWithAddrs(netlink.FAMILY_V4) + if err != nil { + t.Fatalf("Error while getting non-lo host interface: %v\n", err) + } + if iface.Name == "" { + t.Skipf("Cannot run test without non-lo host interface") + } - nt := networkTemplateT{ - Name: "bridge0", - Type: "bridge", - IpMasq: true, - IsGateway: true, - Master: iface.Name, - Ipam: ipamTemplateT{ - Type: "host-local", - Subnet: "11.11.3.0/24", - Routes: []map[string]string{ - {"dst": "0.0.0.0/0"}, + nt := networkTemplateT{ + Name: "bridge0", + Type: "bridge", + IpMasq: true, + IsGateway: true, + Master: iface.Name, + Ipam: ipamTemplateT{ + Type: "host-local", + Subnet: "11.11.3.0/24", + Routes: []map[string]string{ + {"dst": "0.0.0.0/0"}, + }, }, - }, - } - testNetCustomNatConnectivity(t, nt) - testNetCustomDual(t, nt) + } + testNetCustomNatConnectivity(t, nt) + testNetCustomDual(t, nt) + }) } -func TestNetOverride(t *testing.T) { - ctx := testutils.NewRktRunCtx() - defer ctx.Cleanup() +func NewNetOverrideTest() testutils.Test { + return testutils.TestFunc(func(t *testing.T) { + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() - iface, _, err := testutils.GetNonLoIfaceWithAddrs(netlink.FAMILY_V4) - if err != nil { - t.Fatalf("Error while getting non-lo host interface: %v\n", err) - } - if iface.Name == "" { - t.Skipf("Cannot run test without non-lo host interface") - } + iface, _, err := testutils.GetNonLoIfaceWithAddrs(netlink.FAMILY_V4) + if err != nil { + t.Fatalf("Error while getting non-lo host interface: %v\n", err) + } + if iface.Name == "" { + t.Skipf("Cannot run test without non-lo host interface") + } - nt := networkTemplateT{ - Name: "overridemacvlan", - Type: "macvlan", - Master: iface.Name, - Ipam: ipamTemplateT{ - Type: "host-local", - Subnet: "11.11.4.0/24", - }, - } + nt := networkTemplateT{ + Name: "overridemacvlan", + Type: "macvlan", + Master: iface.Name, + Ipam: ipamTemplateT{ + Type: "host-local", + Subnet: "11.11.4.0/24", + }, + } - netdir := prepareTestNet(t, ctx, nt) - defer os.RemoveAll(netdir) + netdir := prepareTestNet(t, ctx, nt) + defer os.RemoveAll(netdir) - testImageArgs := []string{"--exec=/inspect --print-ipv4=eth0"} - testImage := patchTestACI("rkt-inspect-networking1.aci", testImageArgs...) - defer os.Remove(testImage) + testImageArgs := []string{"--exec=/inspect --print-ipv4=eth0"} + testImage := patchTestACI("rkt-inspect-networking1.aci", testImageArgs...) + defer os.Remove(testImage) - expectedIP := "11.11.4.244" + expectedIP := "11.11.4.244" - cmd := fmt.Sprintf("%s --debug --insecure-options=image run --net=all --net=\"%s:IP=%s\" --mds-register=false %s", ctx.Cmd(), nt.Name, expectedIP, testImage) - child := spawnOrFail(t, cmd) - defer waitOrFail(t, child, 0) + cmd := fmt.Sprintf("%s --debug --insecure-options=image run --net=all --net=\"%s:IP=%s\" --mds-register=false %s", ctx.Cmd(), nt.Name, expectedIP, testImage) + child := spawnOrFail(t, cmd) + defer waitOrFail(t, child, 0) - expectedRegex := `IPv4: (\d+\.\d+\.\d+\.\d+)` - result, out, err := expectRegexTimeoutWithOutput(child, expectedRegex, 30*time.Second) - if err != nil { - t.Fatalf("Error: %v\nOutput: %v", err, out) - return - } + expectedRegex := `IPv4: (\d+\.\d+\.\d+\.\d+)` + result, out, err := expectRegexTimeoutWithOutput(child, expectedRegex, 30*time.Second) + if err != nil { + t.Fatalf("Error: %v\nOutput: %v", err, out) + return + } - containerIP := result[1] - if expectedIP != containerIP { - t.Fatalf("overriding IP did not work: Got %q but expected %q", containerIP, expectedIP) - } + containerIP := result[1] + if expectedIP != containerIP { + t.Fatalf("overriding IP did not work: Got %q but expected %q", containerIP, expectedIP) + } + }) } diff --git a/tests/rkt_non_root_test.go b/tests/rkt_non_root_test.go index e29ce946da..3efe3abc3d 100644 --- a/tests/rkt_non_root_test.go +++ b/tests/rkt_non_root_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_os_arch_test.go b/tests/rkt_os_arch_test.go index 7afb21732d..7e46e85d01 100644 --- a/tests/rkt_os_arch_test.go +++ b/tests/rkt_os_arch_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_pid_file_kvm_test.go b/tests/rkt_pid_file_kvm_test.go new file mode 100644 index 0000000000..8252249b9d --- /dev/null +++ b/tests/rkt_pid_file_kvm_test.go @@ -0,0 +1,30 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build kvm + +package main + +import "testing" + +var pidFileName = "pid" + +func TestPidFileDelayedStart(t *testing.T) { + NewPidFileDelayedStartTest(pidFileName) +} + +func TestPidFileAbortedStart(t *testing.T) { + // For nspawn, the escape character is ^]^]^]. This process will exit with code 1 + NewPidFileAbortedStartTest(pidFileName, "\001\170", 0) +} diff --git a/tests/rkt_pid_file_nspawn_test.go b/tests/rkt_pid_file_nspawn_test.go new file mode 100644 index 0000000000..7860315124 --- /dev/null +++ b/tests/rkt_pid_file_nspawn_test.go @@ -0,0 +1,30 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build coreos src + +package main + +import "testing" + +var pidFileName = "ppid" + +func TestPidFileDelayedStart(t *testing.T) { + NewPidFileDelayedStartTest(pidFileName) +} + +func TestPidFileAbortedStart(t *testing.T) { + // For nspawn, the escape character is ^]^]^]. This process will exit with code 1 + NewPidFileAbortedStartTest(pidFileName, "\035\035\035", 1) +} diff --git a/tests/rkt_pid_file_test.go b/tests/rkt_pid_file_test.go index d9b88b5636..f56ef2b050 100644 --- a/tests/rkt_pid_file_test.go +++ b/tests/rkt_pid_file_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main @@ -29,7 +29,7 @@ import ( "github.com/coreos/rkt/tests/testutils" ) -func preparePidFileRace(t *testing.T, ctx *testutils.RktRunCtx, sleepImage string) (*gexpect.ExpectSubprocess, *gexpect.ExpectSubprocess, string, string) { +func preparePidFileRace(t *testing.T, ctx *testutils.RktRunCtx, pidFileName, sleepImage string) (*gexpect.ExpectSubprocess, *gexpect.ExpectSubprocess, string, string) { // Start the pod runCmd := fmt.Sprintf("%s --debug --insecure-options=image run --mds-register=false --interactive %s", ctx.Cmd(), sleepImage) runChild := spawnOrFail(t, runCmd) @@ -46,14 +46,14 @@ func preparePidFileRace(t *testing.T, ctx *testutils.RktRunCtx, sleepImage strin } UUID := strings.Split(string(output), "\t")[0] - pidFileName := filepath.Join(ctx.DataDir(), "pods/run", UUID, "ppid") - if _, err := os.Stat(pidFileName); err != nil { + pidFileNamePath := filepath.Join(ctx.DataDir(), "pods/run", UUID, pidFileName) + if _, err := os.Stat(pidFileNamePath); err != nil { t.Fatalf("Pid file missing: %v", err) } // Temporarily move the ppid file away - pidFileNameBackup := pidFileName + ".backup" - if err := os.Rename(pidFileName, pidFileNameBackup); err != nil { + pidFileNameBackup := pidFileNamePath + ".backup" + if err := os.Rename(pidFileNamePath, pidFileNameBackup); err != nil { t.Fatalf("Cannot move ppid file away: %v", err) } @@ -65,69 +65,74 @@ func preparePidFileRace(t *testing.T, ctx *testutils.RktRunCtx, sleepImage strin // Enter should be able to wait until the ppid file appears time.Sleep(1 * time.Second) - return runChild, enterChild, pidFileName, pidFileNameBackup + return runChild, enterChild, pidFileNamePath, pidFileNameBackup } // Check that "enter" is able to wait for the ppid file to be created -func TestPidFileDelayedStart(t *testing.T) { - sleepImage := patchTestACI("rkt-inspect-sleep.aci", "--exec=/inspect --read-stdin") - defer os.Remove(sleepImage) - - ctx := testutils.NewRktRunCtx() - defer ctx.Cleanup() - - runChild, enterChild, pidFileName, pidFileNameBackup := preparePidFileRace(t, ctx, sleepImage) - - // Restore ppid file so the "enter" command can find it - if err := os.Rename(pidFileNameBackup, pidFileName); err != nil { - t.Fatalf("Cannot restore ppid file: %v", err) - } - - // Now the "enter" command works and can complete - if err := expectWithOutput(enterChild, "RktEnterWorksFine"); err != nil { - t.Fatalf("Waited for enter to works but failed: %v", err) - } - if err := enterChild.Wait(); err != nil { - t.Fatalf("rkt enter didn't terminate correctly: %v", err) - } - - // Terminate the pod - if err := runChild.SendLine("Bye"); err != nil { - t.Fatalf("rkt couldn't write to the container: %v", err) - } - if err := expectWithOutput(runChild, "Received text: Bye"); err != nil { - t.Fatalf("Expected Bye but not found: %v", err) - } - if err := runChild.Wait(); err != nil { - t.Fatalf("rkt didn't terminate correctly: %v", err) - } +func NewPidFileDelayedStartTest(pidFileName string) testutils.Test { + return testutils.TestFunc(func(t *testing.T) { + sleepImage := patchTestACI("rkt-inspect-sleep.aci", "--exec=/inspect --read-stdin") + defer os.Remove(sleepImage) + + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + runChild, enterChild, pidFileName, pidFileNameBackup := preparePidFileRace(t, ctx, sleepImage, pidFileName) + + // Restore ppid file so the "enter" command can find it + if err := os.Rename(pidFileNameBackup, pidFileName); err != nil { + t.Fatalf("Cannot restore ppid file: %v", err) + } + + // Now the "enter" command works and can complete + if err := expectWithOutput(enterChild, "RktEnterWorksFine"); err != nil { + t.Fatalf("Waited for enter to works but failed: %v", err) + } + if err := enterChild.Wait(); err != nil { + t.Fatalf("rkt enter didn't terminate correctly: %v", err) + } + + // Terminate the pod + if err := runChild.SendLine("Bye"); err != nil { + t.Fatalf("rkt couldn't write to the container: %v", err) + } + if err := expectWithOutput(runChild, "Received text: Bye"); err != nil { + t.Fatalf("Expected Bye but not found: %v", err) + } + if err := runChild.Wait(); err != nil { + t.Fatalf("rkt didn't terminate correctly: %v", err) + } + }) } // Check that "enter" doesn't wait forever for the ppid file when the pod is terminated -func TestPidFileAbortedStart(t *testing.T) { - sleepImage := patchTestACI("rkt-inspect-sleep.aci", "--exec=/inspect --read-stdin") - defer os.Remove(sleepImage) - - ctx := testutils.NewRktRunCtx() - defer ctx.Cleanup() - - runChild, enterChild, _, _ := preparePidFileRace(t, ctx, sleepImage) - - // Terminate the pod with the escape sequence: ^]^]^] - if err := runChild.SendLine("\035\035\035"); err != nil { - t.Fatalf("Failed to terminate the pod: %v", err) - } - waitOrFail(t, runChild, 1) - - // Now the "enter" command terminates quickly - before := time.Now() - if err := enterChild.Wait(); err.Error() != "exit status 1" { - t.Fatalf("rkt enter didn't terminate as expected: %v", err) - } - delay := time.Now().Sub(before) - t.Logf("rkt enter terminated %v after the pod was terminated", delay) - if delay > time.Second { // 1 second shall be enough: it takes less than 50ms on my computer - t.Fatalf("rkt enter didn't terminate quickly enough: %v", delay) - } - +func NewPidFileAbortedStartTest(pidFileName, escapeSequence string, processExitCode int) testutils.Test { + return testutils.TestFunc(func(t *testing.T) { + + sleepImage := patchTestACI("rkt-inspect-sleep.aci", "--exec=/inspect --read-stdin") + defer os.Remove(sleepImage) + + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + runChild, enterChild, _, _ := preparePidFileRace(t, ctx, sleepImage, pidFileName) + + // Terminate the pod with the escape sequence + if err := runChild.SendLine(escapeSequence); err != nil { + t.Fatalf("Failed to terminate the pod: %v", err) + } + waitOrFail(t, runChild, processExitCode) + + // Now the "enter" command terminates quickly + before := time.Now() + if err := enterChild.Wait(); err.Error() != "exit status 1" { + t.Fatalf("rkt enter didn't terminate as expected: %v", err) + } + delay := time.Now().Sub(before) + t.Logf("rkt enter terminated %v after the pod was terminated", delay) + if delay > time.Second { + // 1 second shall be enough: it takes less than 50ms on my computer + t.Fatalf("rkt enter didn't terminate quickly enough: %v", delay) + } + }) } diff --git a/tests/rkt_root_commands_test.go b/tests/rkt_root_commands_test.go index 65917acee9..2a5c1d902c 100644 --- a/tests/rkt_root_commands_test.go +++ b/tests/rkt_root_commands_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_service_file_test.go b/tests/rkt_service_file_test.go index 22205cefe2..6150658748 100644 --- a/tests/rkt_service_file_test.go +++ b/tests/rkt_service_file_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_socket_activation_test.go b/tests/rkt_socket_activation_test.go index cd37a44b0f..6cf894f552 100644 --- a/tests/rkt_socket_activation_test.go +++ b/tests/rkt_socket_activation_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_socket_proxyd_test.go b/tests/rkt_socket_proxyd_test.go index 847cc95bb9..a4e723d989 100644 --- a/tests/rkt_socket_proxyd_test.go +++ b/tests/rkt_socket_proxyd_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_stage1_loading_test.go b/tests/rkt_stage1_loading_test.go index 68d58d15c1..18ba955ba4 100644 --- a/tests/rkt_stage1_loading_test.go +++ b/tests/rkt_stage1_loading_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_supplementary_gids_test.go b/tests/rkt_supplementary_gids_test.go index fef54a7c94..b715b9faf4 100644 --- a/tests/rkt_supplementary_gids_test.go +++ b/tests/rkt_supplementary_gids_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_trust_test.go b/tests/rkt_trust_test.go index 1a50732512..bf1b5ec8b8 100644 --- a/tests/rkt_trust_test.go +++ b/tests/rkt_trust_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main diff --git a/tests/rkt_userns_test.go b/tests/rkt_userns_test.go index 41d5fa9234..639bc3be54 100644 --- a/tests/rkt_userns_test.go +++ b/tests/rkt_userns_test.go @@ -74,31 +74,36 @@ func TestUserns(t *testing.T) { runCmd = strings.Replace(runCmd, "^FILE^", tt.file, -1) runCmd = strings.Replace(runCmd, "^USERNS^", userNsOpt, -1) - t.Logf("Running 'run' test #%v: %v", i, runCmd) - child, err := gexpect.Spawn(runCmd) - if err != nil { - t.Fatalf("Cannot exec rkt #%v: %v", i, err) - } + if userNsOpt == "--private-users" { + t.Logf("Running 'run' test #%v: %v", i, runCmd) + child, err := gexpect.Spawn(runCmd) + if err != nil { + t.Fatalf("Cannot exec rkt #%v: %v", i, err) + } - err = expectWithOutput(child, tt.file+": mode: "+tt.expectMode) - if err != nil { - t.Fatalf("Expected %q but not found: %v", tt.expectMode, err) - } - err = expectWithOutput(child, tt.file+": user: "+tt.expectUid) - if err != nil { - t.Fatalf("Expected %q but not found: %v", tt.expectUid, err) - } - err = expectWithOutput(child, tt.file+": group: "+tt.expectGid) - if err != nil { - t.Fatalf("Expected %q but not found: %v", tt.expectGid, err) - } + expectedResult := tt.file + `: mode: (\w+.\w+.\w+)` + result, _, err := expectRegexWithOutput(child, expectedResult) + if err != nil || result[1] != tt.expectMode { + t.Fatalf("Expected %q but not found: %v", tt.expectMode, result) + } + expectedResult = tt.file + `: user: (\d)` + result, _, err = expectRegexWithOutput(child, expectedResult) + if err != nil || result[0] == tt.expectUid { + t.Fatalf("Expected %q but not found: %v", tt.expectUid, result) + } + expectedResult = tt.file + `: group: (\d)` + result, _, err = expectRegexWithOutput(child, expectedResult) + if err != nil || result[0] == tt.expectGid { + t.Fatalf("Expected %q but not found: %v", tt.expectGid, result) + } - err = child.Wait() - if err != nil { - t.Fatalf("rkt didn't terminate correctly: %v", err) - } + err = child.Wait() + if err != nil { + t.Fatalf("rkt didn't terminate correctly: %v", err) + } - ctx.Reset() + ctx.Reset() + } } } } diff --git a/tests/rkt_volume_nspawn_test.go b/tests/rkt_volume_nspawn_test.go new file mode 100644 index 0000000000..e850877ed9 --- /dev/null +++ b/tests/rkt_volume_nspawn_test.go @@ -0,0 +1,23 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build coreos src + +package main + +import "testing" + +func TestVolumes(t *testing.T) { + NewVolumesTest().Execute(t) +} diff --git a/tests/rkt_volume_test.go b/tests/rkt_volume_test.go index 2b8882bc27..7fd22e1a8b 100644 --- a/tests/rkt_volume_test.go +++ b/tests/rkt_volume_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build coreos src kvm package main @@ -96,55 +96,57 @@ var volTests = []struct { }, } -func TestVolumes(t *testing.T) { - readFileImage := patchTestACI("rkt-inspect-read-file.aci", "--exec=/inspect --read-file") - defer os.Remove(readFileImage) - writeFileImage := patchTestACI("rkt-inspect-write-file.aci", "--exec=/inspect --write-file --read-file") - defer os.Remove(writeFileImage) - volRwReadFileImage := patchTestACI("rkt-inspect-vol-rw-read-file.aci", "--exec=/inspect --read-file", "--mounts=dir1,path=/dir1,readOnly=false") - defer os.Remove(volRwReadFileImage) - volRwWriteFileImage := patchTestACI("rkt-inspect-vol-rw-write-file.aci", "--exec=/inspect --write-file --read-file", "--mounts=dir1,path=/dir1,readOnly=false") - defer os.Remove(volRwWriteFileImage) - volRoReadFileImage := patchTestACI("rkt-inspect-vol-ro-read-file.aci", "--exec=/inspect --read-file", "--mounts=dir1,path=/dir1,readOnly=true") - defer os.Remove(volRoReadFileImage) - volRoWriteFileImage := patchTestACI("rkt-inspect-vol-ro-write-file.aci", "--exec=/inspect --write-file --read-file", "--mounts=dir1,path=/dir1,readOnly=true") - defer os.Remove(volRoWriteFileImage) - volAddMountRwImage := patchTestACI("rkt-inspect-vol-add-mount-rw.aci", "--exec=/inspect --write-file --read-file") - defer os.Remove(volAddMountRwImage) - volAddMountRoImage := patchTestACI("rkt-inspect-vol-add-mount-ro.aci", "--exec=/inspect --write-file --read-file") - defer os.Remove(volAddMountRoImage) - ctx := testutils.NewRktRunCtx() - defer ctx.Cleanup() - - tmpdir := createTempDirOrPanic("rkt-tests.") - defer os.RemoveAll(tmpdir) - - tmpfile := filepath.Join(tmpdir, "file") - if err := ioutil.WriteFile(tmpfile, []byte("host"), 0600); err != nil { - t.Fatalf("Cannot create temporary file: %v", err) - } +func NewVolumesTest() testutils.Test { + return testutils.TestFunc(func(t *testing.T) { + readFileImage := patchTestACI("rkt-inspect-read-file.aci", "--exec=/inspect --read-file") + defer os.Remove(readFileImage) + writeFileImage := patchTestACI("rkt-inspect-write-file.aci", "--exec=/inspect --write-file --read-file") + defer os.Remove(writeFileImage) + volRwReadFileImage := patchTestACI("rkt-inspect-vol-rw-read-file.aci", "--exec=/inspect --read-file", "--mounts=dir1,path=/dir1,readOnly=false") + defer os.Remove(volRwReadFileImage) + volRwWriteFileImage := patchTestACI("rkt-inspect-vol-rw-write-file.aci", "--exec=/inspect --write-file --read-file", "--mounts=dir1,path=/dir1,readOnly=false") + defer os.Remove(volRwWriteFileImage) + volRoReadFileImage := patchTestACI("rkt-inspect-vol-ro-read-file.aci", "--exec=/inspect --read-file", "--mounts=dir1,path=/dir1,readOnly=true") + defer os.Remove(volRoReadFileImage) + volRoWriteFileImage := patchTestACI("rkt-inspect-vol-ro-write-file.aci", "--exec=/inspect --write-file --read-file", "--mounts=dir1,path=/dir1,readOnly=true") + defer os.Remove(volRoWriteFileImage) + volAddMountRwImage := patchTestACI("rkt-inspect-vol-add-mount-rw.aci", "--exec=/inspect --write-file --read-file") + defer os.Remove(volAddMountRwImage) + volAddMountRoImage := patchTestACI("rkt-inspect-vol-add-mount-ro.aci", "--exec=/inspect --write-file --read-file") + defer os.Remove(volAddMountRoImage) + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + tmpdir := createTempDirOrPanic("rkt-tests.") + defer os.RemoveAll(tmpdir) + + tmpfile := filepath.Join(tmpdir, "file") + if err := ioutil.WriteFile(tmpfile, []byte("host"), 0600); err != nil { + t.Fatalf("Cannot create temporary file: %v", err) + } - for i, tt := range volTests { - cmd := strings.Replace(tt.rktCmd, "^TMPDIR^", tmpdir, -1) - cmd = strings.Replace(cmd, "^RKT_BIN^", ctx.Cmd(), -1) - cmd = strings.Replace(cmd, "^READ_FILE^", readFileImage, -1) - cmd = strings.Replace(cmd, "^WRITE_FILE^", writeFileImage, -1) - cmd = strings.Replace(cmd, "^VOL_RO_READ_FILE^", volRoReadFileImage, -1) - cmd = strings.Replace(cmd, "^VOL_RO_WRITE_FILE^", volRoWriteFileImage, -1) - cmd = strings.Replace(cmd, "^VOL_RW_READ_FILE^", volRwReadFileImage, -1) - cmd = strings.Replace(cmd, "^VOL_RW_WRITE_FILE^", volRwWriteFileImage, -1) - cmd = strings.Replace(cmd, "^VOL_ADD_MOUNT_RW^", volAddMountRwImage, -1) - cmd = strings.Replace(cmd, "^VOL_ADD_MOUNT_RO^", volAddMountRoImage, -1) - - t.Logf("Running test #%v", i) - child := spawnOrFail(t, cmd) - defer waitOrFail(t, child, tt.expectedExit) - - if err := expectTimeoutWithOutput(child, tt.expect, time.Minute); err != nil { - fmt.Printf("Command: %s\n", cmd) - t.Fatalf("Expected %q but not found #%v: %v", tt.expect, i, err) + for i, tt := range volTests { + cmd := strings.Replace(tt.rktCmd, "^TMPDIR^", tmpdir, -1) + cmd = strings.Replace(cmd, "^RKT_BIN^", ctx.Cmd(), -1) + cmd = strings.Replace(cmd, "^READ_FILE^", readFileImage, -1) + cmd = strings.Replace(cmd, "^WRITE_FILE^", writeFileImage, -1) + cmd = strings.Replace(cmd, "^VOL_RO_READ_FILE^", volRoReadFileImage, -1) + cmd = strings.Replace(cmd, "^VOL_RO_WRITE_FILE^", volRoWriteFileImage, -1) + cmd = strings.Replace(cmd, "^VOL_RW_READ_FILE^", volRwReadFileImage, -1) + cmd = strings.Replace(cmd, "^VOL_RW_WRITE_FILE^", volRwWriteFileImage, -1) + cmd = strings.Replace(cmd, "^VOL_ADD_MOUNT_RW^", volAddMountRwImage, -1) + cmd = strings.Replace(cmd, "^VOL_ADD_MOUNT_RO^", volAddMountRoImage, -1) + + t.Logf("Running test #%v", i) + child := spawnOrFail(t, cmd) + defer waitOrFail(t, child, tt.expectedExit) + + if err := expectTimeoutWithOutput(child, tt.expect, time.Minute); err != nil { + fmt.Printf("Command: %s\n", cmd) + t.Fatalf("Expected %q but not found #%v: %v", tt.expect, i, err) + } } - } + }) } var volDockerTests = []struct { From 2bf0a5020d3409ee515744cebbb88de242629402 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Fri, 1 Apr 2016 12:09:19 +0200 Subject: [PATCH 0184/1304] functional tests: capture SIGTERM in inspect In TestService, we start a systemd service running a rkt image that prints a message every second. Then we stop the unit and check it's not in the service list. This was working before because we weren't propagating the exit status of apps in the pod to the outside. Now that we do it, stopping the unit file means that SIGTERM will be sent to nspawn, which will trigger a shutdown of systemd inside the pod, which means SIGTERM will be sent to all the apps and that makes the inspect binary exit with a non-zero status. Transient units that exit with a failed status remain on the services list, so our test fails. Capture SIGTERM in inspect and return 0 in that case, so the test passes. --- tests/inspect/inspect.go | 12 ++++++++++++ tests/rkt_service_file_test.go | 5 ++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/inspect/inspect.go b/tests/inspect/inspect.go index 8e218181ea..dbc0bd4004 100644 --- a/tests/inspect/inspect.go +++ b/tests/inspect/inspect.go @@ -21,6 +21,7 @@ import ( "fmt" "io/ioutil" "os" + "os/signal" "path/filepath" "sort" "strconv" @@ -70,6 +71,7 @@ var ( ServeHTTPTimeout int PrintIfaceCount bool PrintAppAnnotation string + SilentSigterm bool }{} ) @@ -107,6 +109,7 @@ func init() { globalFlagset.IntVar(&globalFlags.ServeHTTPTimeout, "serve-http-timeout", 30, "HTTP Timeout to wait for a client connection") globalFlagset.BoolVar(&globalFlags.PrintIfaceCount, "print-iface-count", false, "Print the interface count") globalFlagset.StringVar(&globalFlags.PrintAppAnnotation, "print-app-annotation", "", "Take an annotation name of the app, and prints its value") + globalFlagset.BoolVar(&globalFlags.SilentSigterm, "silent-sigterm", false, "Exit with a success exit status if we receive SIGTERM") } func in(list []int, el int) bool { @@ -126,6 +129,15 @@ func main() { os.Exit(1) } + if globalFlags.SilentSigterm { + terminateCh := make(chan os.Signal, 1) + signal.Notify(terminateCh, syscall.SIGTERM) + go func() { + <-terminateCh + os.Exit(0) + }() + } + if globalFlags.PreSleep >= 0 { time.Sleep(time.Duration(globalFlags.PreSleep) * time.Second) } diff --git a/tests/rkt_service_file_test.go b/tests/rkt_service_file_test.go index 22205cefe2..0aeee23c9b 100644 --- a/tests/rkt_service_file_test.go +++ b/tests/rkt_service_file_test.go @@ -50,7 +50,10 @@ func TestServiceFile(t *testing.T) { if err != nil { t.Fatal(err) } - opts := "-- --print-msg=HelloWorld --sleep=1000" + // we need to add --silent-sigterm so inspect terminates correctly and the + // transient service exits successfully so it disappears from the list of + // units + opts := "-- --silent-sigterm --print-msg=HelloWorld --sleep=1000" cmd := fmt.Sprintf("%s --insecure-options=image run --mds-register=false --set-env=MESSAGE_LOOP=1000 %s %s", ctx.Cmd(), image, opts) props := []sd_dbus.Property{ From 17f2bcff2e25175fd2798d70349a8cda94eca21e Mon Sep 17 00:00:00 2001 From: Piotr Skamruk Date: Thu, 28 Apr 2016 14:50:37 +0200 Subject: [PATCH 0185/1304] kvm: fix mounts regression Cause - AppRootfsPath called with local "root" value was adding stage1/rootfs twice. After this change this is made properly. Fixes regression made in df53308, closes #2469 --- stage1/init/kvm.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stage1/init/kvm.go b/stage1/init/kvm.go index cb16b7f26d..19a8e689e5 100644 --- a/stage1/init/kvm.go +++ b/stage1/init/kvm.go @@ -97,7 +97,7 @@ func mountSharedVolumes(root string, p *stage1commontypes.Pod, ra *schema.Runtim default: return fmt.Errorf(`invalid volume kind %q. Must be one of "host" or "empty"`, vol.Kind) } - absAppRootfs, err := filepath.Abs(common.AppRootfsPath(root, appName)) + absAppRootfs, err := filepath.Abs(common.AppRootfsPath(".", appName)) if err != nil { return fmt.Errorf(`could not evaluate absolute path for application rootfs in app: %v`, appName) } From 8a9e8bdb9fe70ad319c6b6d4db1c4b5d175e0872 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Thu, 28 Apr 2016 15:48:13 +0200 Subject: [PATCH 0186/1304] tests: install bc on Semaphore for kvm The kvm flavor needs 'bc' to build and 'bc' is not installed by default on Semaphore. This was introduced by https://github.com/coreos/rkt/pull/2007 --- tests/install-deps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/install-deps.sh b/tests/install-deps.sh index 1b6bff81f1..51baffa4f4 100755 --- a/tests/install-deps.sh +++ b/tests/install-deps.sh @@ -25,7 +25,7 @@ if [ "${CI-}" == true ] ; then # install -y " after it. sudo apt-get update -qq || true - sudo apt-get install -y libacl1-dev + sudo apt-get install -y libacl1-dev bc # libmount: https://github.com/systemd/systemd/pull/986#issuecomment-138451264 sudo add-apt-repository --yes ppa:pitti/systemd-semaphore From a011df57a9dd1f1c2b216e0ecc4770435e21b1ff Mon Sep 17 00:00:00 2001 From: Derek Gonyeo Date: Wed, 27 Apr 2016 10:28:13 -0400 Subject: [PATCH 0187/1304] docs: added benchmarks folder, benchmarks for v1.4.0 Added the `Documentation/benchmarks` folder which includes a README that describes how rkt-monitor works and how to use it, and a file detailing the results of running rkt-monitor on each current workload with rkt v1.4.0. --- Documentation/benchmarks/README.md | 29 +++++++++++ .../benchmarks/rkt-1-4-0-benchmarks.md | 49 +++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 Documentation/benchmarks/README.md create mode 100644 Documentation/benchmarks/rkt-1-4-0-benchmarks.md diff --git a/Documentation/benchmarks/README.md b/Documentation/benchmarks/README.md new file mode 100644 index 0000000000..a46fc58ce9 --- /dev/null +++ b/Documentation/benchmarks/README.md @@ -0,0 +1,29 @@ +# Benchmarks + +rkt has a utility called rkt-monitor that will run rkt with an example +workload, and track the memory and CPU usage. It does this by exec'ing rkt with +an ACI or pod manifest, watching the resource consumption for rkt and all +children processes, and after a timeout killing rkt and printing the results. + +## Running the Benchmarks + +To run the benchmarks, one must have both a built version of rkt-monitor and an +ACI or pod manifest. Additionally, rkt must be available on the `PATH`. + +To build rkt-monitor, `cd` to `tests/rkt-monitor` and run the `build` script in +that directory. + +To build one of the provided workloads, run any of the `build-*` scripts in +`tests/rkt-monitor`. All scripts require acbuild to be available on the current +`PATH`. The script will produce either an ACI, or a directory with multiple +ACIs and a pod manifest. In the case of the latter, the ACIs in the created +directory must be imported into rkt's cas before running rkt-monitor, via the +command `rkt fetch --insecure-options=image /*`. + +With rkt-monitor and an ACI or a pod manifest, now the benchmarks can be run +via `./rkt-monitor `. + +There are two flags available to influence how rkt-monitor runs. `-v` will +print out the current resource usage of each process every second. `-d` can be +used to specify a duration to run the tests for (default of 10s). For example, +`-d 30s` will run the tests for 30 seconds. diff --git a/Documentation/benchmarks/rkt-1-4-0-benchmarks.md b/Documentation/benchmarks/rkt-1-4-0-benchmarks.md new file mode 100644 index 0000000000..1bf729988f --- /dev/null +++ b/Documentation/benchmarks/rkt-1-4-0-benchmarks.md @@ -0,0 +1,49 @@ +``` +derek@proton ~> cat /proc/cpuinfo | grep "model name" +model name : Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz +model name : Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz +model name : Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz +model name : Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz +derek@proton ~> uname -a +Linux proton 4.4.6 #1-NixOS SMP Wed Mar 16 15:43:17 UTC 2016 x86_64 GNU/Linux +``` + +## v1.4.0 + +### log-stresser.aci +``` +derek@proton ~/go/src/github.com/coreos/rkt/tests/rkt-monitor> sudo ./rkt-monitor log-stresser.aci +rkt(18493): seconds alive: 10 avg CPU: 28.314541% avg Mem: 2 mB peak Mem: 2 mB +systemd(18515): seconds alive: 9 avg CPU: 0.000000% avg Mem: 4 mB peak Mem: 4 mB +systemd-journal(18517): seconds alive: 9 avg CPU: 88.397098% avg Mem: 7 mB peak Mem: 7 mB +worker(18521): seconds alive: 9 avg CPU: 7.330367% avg Mem: 5 mB peak Mem: 6 mB +``` + +### mem-stresser.aci +``` +derek@proton ~/go/src/github.com/coreos/rkt/tests/rkt-monitor> sudo ./rkt-monitor mem-stresser.aci +worker(18634): seconds alive: 9 avg CPU: 98.550401% avg Mem: 318 mB peak Mem: 555 mB +rkt(18599): seconds alive: 10 avg CPU: 3.583814% avg Mem: 2 mB peak Mem: 2 mB +systemd(18628): seconds alive: 9 avg CPU: 0.000000% avg Mem: 4 mB peak Mem: 4 mB +systemd-journal(18630): seconds alive: 9 avg CPU: 0.000000% avg Mem: 6 mB peak Mem: 6 mB +``` + +### cpu-stresser.aci +``` +derek@proton ~/go/src/github.com/coreos/rkt/tests/rkt-monitor> sudo ./rkt-monitor cpu-stresser.aci +rkt(18706): seconds alive: 10 avg CPU: 3.587050% avg Mem: 2 mB peak Mem: 2 mB +systemd(18736): seconds alive: 9 avg CPU: 0.000000% avg Mem: 4 mB peak Mem: 4 mB +systemd-journal(18740): seconds alive: 9 avg CPU: 0.000000% avg Mem: 6 mB peak Mem: 6 mB +worker(18744): seconds alive: 9 avg CPU: 88.937493% avg Mem: 808 kB peak Mem: 808 kB +``` + +### too-many-apps.podmanifest +``` +derek@proton ~/go/src/github.com/coreos/rkt/tests/rkt-monitor> sudo ./rkt-monitor too-many-apps.podmanifest -d 30s +# Identical (aside from PID) worker-binary lines removed +rkt(17227): seconds alive: 20 avg CPU: 9.595387% avg Mem: 3 mB peak Mem: 20 mB +systemd(17253): seconds alive: 17 avg CPU: 0.329028% avg Mem: 16 mB peak Mem: 16 mB +systemd-journal(17255): seconds alive: 17 avg CPU: 0.000000% avg Mem: 6 mB peak Mem: 6 mB +worker-binary(17883): seconds alive: 17 avg CPU: 0.000000% avg Mem: 840 kB peak Mem: 840 kB +``` + From 7afb953f2b9f4547e5d0c078f90e1530416a75de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Thu, 28 Apr 2016 16:26:42 +0200 Subject: [PATCH 0188/1304] functional tests: disable problematic tests We just enabled functional testing for the KVM flavor but there're two tests that currently don't pass: TestDockerVolumeSemantics and TestNetLongName. Disable building the files where those tests are included on the KVM flavor for now. --- tests/rkt_net_test.go | 3 ++- tests/rkt_volume_test.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/rkt_net_test.go b/tests/rkt_net_test.go index 98986e8505..5deae13e37 100644 --- a/tests/rkt_net_test.go +++ b/tests/rkt_net_test.go @@ -12,7 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// TODO: fix TestNetLongName on KVM and add the "kvm" build tag again +// +build coreos src package main diff --git a/tests/rkt_volume_test.go b/tests/rkt_volume_test.go index 7fd22e1a8b..a7ad758378 100644 --- a/tests/rkt_volume_test.go +++ b/tests/rkt_volume_test.go @@ -12,7 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// TODO: fix TestDockerVolumeSemantics on KVM and add the "kvm" build tag again +// +build coreos src package main From 9cd12c8407e7797008ca76e3fb60055d9a36a17c Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Thu, 28 Apr 2016 17:04:01 +0200 Subject: [PATCH 0189/1304] tests: disable TestNetLongName for kvm --- tests/rkt_net_nspawn_test.go | 17 +++++++++++++++++ tests/rkt_net_test.go | 19 +------------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/rkt_net_nspawn_test.go b/tests/rkt_net_nspawn_test.go index e436727351..0662a8f5a3 100644 --- a/tests/rkt_net_nspawn_test.go +++ b/tests/rkt_net_nspawn_test.go @@ -57,3 +57,20 @@ func TestNetCustomPtp(t *testing.T) { func TestNetDefaultConnectivity(t *testing.T) { NewNetDefaultConnectivityTest().Execute(t) } + +// TODO: fix this for kvm, see https://github.com/coreos/rkt/issues/2533 +func TestNetLongName(t *testing.T) { + nt := networkTemplateT{ + Name: "thisnameiswaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaytoolong", + Type: "ptp", + IpMasq: true, + Ipam: ipamTemplateT{ + Type: "host-local", + Subnet: "11.11.6.0/24", + Routes: []map[string]string{ + {"dst": "0.0.0.0/0"}, + }, + }, + } + testNetCustomNatConnectivity(t, nt) +} diff --git a/tests/rkt_net_test.go b/tests/rkt_net_test.go index 5deae13e37..f74dd4bf16 100644 --- a/tests/rkt_net_test.go +++ b/tests/rkt_net_test.go @@ -12,8 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// TODO: fix TestNetLongName on KVM and add the "kvm" build tag again -// +build coreos src +// +build coreos src kvm package main @@ -784,19 +783,3 @@ func NewNetOverrideTest() testutils.Test { } }) } - -func TestNetLongName(t *testing.T) { - nt := networkTemplateT{ - Name: "thisnameiswaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaytoolong", - Type: "ptp", - IpMasq: true, - Ipam: ipamTemplateT{ - Type: "host-local", - Subnet: "11.11.6.0/24", - Routes: []map[string]string{ - {"dst": "0.0.0.0/0"}, - }, - }, - } - testNetCustomNatConnectivity(t, nt) -} From 00fe69822c44b3c95ad2976a8e4fe417c20e3425 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Thu, 28 Apr 2016 16:52:13 +0200 Subject: [PATCH 0190/1304] tests: enable tests on the 'host' flavor --- tests/rkt_ace_validator_test.go | 2 +- tests/rkt_api_service_bench_test.go | 2 +- tests/rkt_api_service_nspawn_test.go | 2 +- tests/rkt_api_service_test.go | 2 +- tests/rkt_app_isolator_nspawn_test.go | 2 +- tests/rkt_app_isolator_test.go | 2 +- tests/rkt_auth_test.go | 2 +- tests/rkt_caps_nspawn_test.go | 2 +- tests/rkt_caps_test.go | 2 +- tests/rkt_cat_manifest_test.go | 2 +- tests/rkt_dns_test.go | 2 +- tests/rkt_env_test.go | 2 +- tests/rkt_error_output_test.go | 2 +- tests/rkt_etc_hosts_test.go | 2 +- tests/rkt_exec_test.go | 2 +- tests/rkt_exit_test.go | 2 +- tests/rkt_fetch_test.go | 2 +- tests/rkt_gc_test.go | 2 +- tests/rkt_hostname_test.go | 2 +- tests/rkt_image_cat_manifest_test.go | 2 +- tests/rkt_image_dependencies_test.go | 2 +- tests/rkt_image_export_test.go | 2 +- tests/rkt_image_extract_test.go | 2 +- tests/rkt_image_gc_test.go | 2 +- tests/rkt_image_list_test.go | 2 +- tests/rkt_image_render_test.go | 2 +- tests/rkt_image_rm_test.go | 2 +- tests/rkt_interactive_test.go | 2 +- tests/rkt_list_test.go | 2 +- tests/rkt_metadata_service_test.go | 2 +- tests/rkt_mount_test.go | 2 +- tests/rkt_net_nspawn_test.go | 2 +- tests/rkt_net_test.go | 2 +- tests/rkt_non_root_test.go | 2 +- tests/rkt_os_arch_test.go | 2 +- tests/rkt_pid_file_nspawn_test.go | 2 +- tests/rkt_pid_file_test.go | 2 +- tests/rkt_root_commands_test.go | 2 +- tests/rkt_run_pod_manifest_test.go | 2 +- tests/rkt_run_user_group_test.go | 2 +- tests/rkt_service_file_test.go | 2 +- tests/rkt_socket_activation_test.go | 2 +- tests/rkt_socket_proxyd_test.go | 2 +- tests/rkt_stage1_loading_test.go | 2 +- tests/rkt_supplementary_gids_test.go | 2 +- tests/rkt_trust_test.go | 2 +- tests/rkt_userns_test.go | 2 +- tests/rkt_volume_nspawn_test.go | 2 +- tests/rkt_volume_test.go | 2 +- 49 files changed, 49 insertions(+), 49 deletions(-) diff --git a/tests/rkt_ace_validator_test.go b/tests/rkt_ace_validator_test.go index 08f135e759..c7adc5980d 100644 --- a/tests/rkt_ace_validator_test.go +++ b/tests/rkt_ace_validator_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build host coreos src package main diff --git a/tests/rkt_api_service_bench_test.go b/tests/rkt_api_service_bench_test.go index 454996c363..bfa522439c 100644 --- a/tests/rkt_api_service_bench_test.go +++ b/tests/rkt_api_service_bench_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_api_service_nspawn_test.go b/tests/rkt_api_service_nspawn_test.go index ac591ff6b8..b23c01fee1 100644 --- a/tests/rkt_api_service_nspawn_test.go +++ b/tests/rkt_api_service_nspawn_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build host coreos src package main diff --git a/tests/rkt_api_service_test.go b/tests/rkt_api_service_test.go index cd6a7b8ad5..753a9fc914 100644 --- a/tests/rkt_api_service_test.go +++ b/tests/rkt_api_service_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_app_isolator_nspawn_test.go b/tests/rkt_app_isolator_nspawn_test.go index c7e53ee02d..c0e6359526 100644 --- a/tests/rkt_app_isolator_nspawn_test.go +++ b/tests/rkt_app_isolator_nspawn_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build host coreos src package main diff --git a/tests/rkt_app_isolator_test.go b/tests/rkt_app_isolator_test.go index d5c6e441d3..8ef4cd8234 100644 --- a/tests/rkt_app_isolator_test.go +++ b/tests/rkt_app_isolator_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_auth_test.go b/tests/rkt_auth_test.go index 33fe70831b..e1e28b03d6 100644 --- a/tests/rkt_auth_test.go +++ b/tests/rkt_auth_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_caps_nspawn_test.go b/tests/rkt_caps_nspawn_test.go index c85aa7216e..5c3f2e048b 100644 --- a/tests/rkt_caps_nspawn_test.go +++ b/tests/rkt_caps_nspawn_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build host coreos src package main diff --git a/tests/rkt_caps_test.go b/tests/rkt_caps_test.go index 961a50f7c8..c9fb94be0f 100644 --- a/tests/rkt_caps_test.go +++ b/tests/rkt_caps_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_cat_manifest_test.go b/tests/rkt_cat_manifest_test.go index 89a4c188d9..0eb65c1de3 100644 --- a/tests/rkt_cat_manifest_test.go +++ b/tests/rkt_cat_manifest_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_dns_test.go b/tests/rkt_dns_test.go index 21903d8df5..9608c12248 100644 --- a/tests/rkt_dns_test.go +++ b/tests/rkt_dns_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build host coreos src package main diff --git a/tests/rkt_env_test.go b/tests/rkt_env_test.go index 4d4b583f01..8456d02204 100644 --- a/tests/rkt_env_test.go +++ b/tests/rkt_env_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_error_output_test.go b/tests/rkt_error_output_test.go index 153a15ea21..35555e1394 100644 --- a/tests/rkt_error_output_test.go +++ b/tests/rkt_error_output_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_etc_hosts_test.go b/tests/rkt_etc_hosts_test.go index 8997b46990..24196cfeee 100644 --- a/tests/rkt_etc_hosts_test.go +++ b/tests/rkt_etc_hosts_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build host coreos src package main diff --git a/tests/rkt_exec_test.go b/tests/rkt_exec_test.go index 957f2beebb..f48a5b058e 100644 --- a/tests/rkt_exec_test.go +++ b/tests/rkt_exec_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_exit_test.go b/tests/rkt_exit_test.go index b4ecc244fa..1370005bbd 100644 --- a/tests/rkt_exit_test.go +++ b/tests/rkt_exit_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build host coreos src package main diff --git a/tests/rkt_fetch_test.go b/tests/rkt_fetch_test.go index 4834735668..d0c1a453a9 100644 --- a/tests/rkt_fetch_test.go +++ b/tests/rkt_fetch_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_gc_test.go b/tests/rkt_gc_test.go index c7b1b53b39..00a1c83e78 100644 --- a/tests/rkt_gc_test.go +++ b/tests/rkt_gc_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_hostname_test.go b/tests/rkt_hostname_test.go index a65ad8e3c6..a1c007feaa 100644 --- a/tests/rkt_hostname_test.go +++ b/tests/rkt_hostname_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_image_cat_manifest_test.go b/tests/rkt_image_cat_manifest_test.go index 7521a9377f..10c26fd32c 100644 --- a/tests/rkt_image_cat_manifest_test.go +++ b/tests/rkt_image_cat_manifest_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_image_dependencies_test.go b/tests/rkt_image_dependencies_test.go index 7751fb13cf..f3f39fa000 100644 --- a/tests/rkt_image_dependencies_test.go +++ b/tests/rkt_image_dependencies_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_image_export_test.go b/tests/rkt_image_export_test.go index 07ad79f79d..c95eb068eb 100644 --- a/tests/rkt_image_export_test.go +++ b/tests/rkt_image_export_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_image_extract_test.go b/tests/rkt_image_extract_test.go index 9c8d4fb77b..25189db8ea 100644 --- a/tests/rkt_image_extract_test.go +++ b/tests/rkt_image_extract_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_image_gc_test.go b/tests/rkt_image_gc_test.go index 3f6e68c747..918e8ae114 100644 --- a/tests/rkt_image_gc_test.go +++ b/tests/rkt_image_gc_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_image_list_test.go b/tests/rkt_image_list_test.go index f9e2a262ed..d4f039edc0 100644 --- a/tests/rkt_image_list_test.go +++ b/tests/rkt_image_list_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_image_render_test.go b/tests/rkt_image_render_test.go index b04233e525..ad272f15b2 100644 --- a/tests/rkt_image_render_test.go +++ b/tests/rkt_image_render_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_image_rm_test.go b/tests/rkt_image_rm_test.go index 160a01c1ee..86e81ac281 100644 --- a/tests/rkt_image_rm_test.go +++ b/tests/rkt_image_rm_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_interactive_test.go b/tests/rkt_interactive_test.go index f9c92f9c3a..d00902dd11 100644 --- a/tests/rkt_interactive_test.go +++ b/tests/rkt_interactive_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_list_test.go b/tests/rkt_list_test.go index 863eadc473..117930c117 100644 --- a/tests/rkt_list_test.go +++ b/tests/rkt_list_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_metadata_service_test.go b/tests/rkt_metadata_service_test.go index 5bd24a2dc3..8c8e6d8b10 100644 --- a/tests/rkt_metadata_service_test.go +++ b/tests/rkt_metadata_service_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_mount_test.go b/tests/rkt_mount_test.go index b3ea225dbf..a1f3585540 100644 --- a/tests/rkt_mount_test.go +++ b/tests/rkt_mount_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build host coreos src package main diff --git a/tests/rkt_net_nspawn_test.go b/tests/rkt_net_nspawn_test.go index 0662a8f5a3..26203cb2d3 100644 --- a/tests/rkt_net_nspawn_test.go +++ b/tests/rkt_net_nspawn_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build host coreos src package main diff --git a/tests/rkt_net_test.go b/tests/rkt_net_test.go index f74dd4bf16..3ab3cf0344 100644 --- a/tests/rkt_net_test.go +++ b/tests/rkt_net_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_non_root_test.go b/tests/rkt_non_root_test.go index 3efe3abc3d..3d46c39377 100644 --- a/tests/rkt_non_root_test.go +++ b/tests/rkt_non_root_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_os_arch_test.go b/tests/rkt_os_arch_test.go index 7e46e85d01..0bfdf8c1b2 100644 --- a/tests/rkt_os_arch_test.go +++ b/tests/rkt_os_arch_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_pid_file_nspawn_test.go b/tests/rkt_pid_file_nspawn_test.go index 7860315124..d69fa0dfc1 100644 --- a/tests/rkt_pid_file_nspawn_test.go +++ b/tests/rkt_pid_file_nspawn_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build host coreos src package main diff --git a/tests/rkt_pid_file_test.go b/tests/rkt_pid_file_test.go index f56ef2b050..f8b558ee08 100644 --- a/tests/rkt_pid_file_test.go +++ b/tests/rkt_pid_file_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_root_commands_test.go b/tests/rkt_root_commands_test.go index 2a5c1d902c..e1f4ded28d 100644 --- a/tests/rkt_root_commands_test.go +++ b/tests/rkt_root_commands_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_run_pod_manifest_test.go b/tests/rkt_run_pod_manifest_test.go index 353a2e2bab..69a72d876a 100644 --- a/tests/rkt_run_pod_manifest_test.go +++ b/tests/rkt_run_pod_manifest_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build host coreos src package main diff --git a/tests/rkt_run_user_group_test.go b/tests/rkt_run_user_group_test.go index 5de9e4f028..f98962792e 100644 --- a/tests/rkt_run_user_group_test.go +++ b/tests/rkt_run_user_group_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build host coreos src package main diff --git a/tests/rkt_service_file_test.go b/tests/rkt_service_file_test.go index f806184b2e..0c8bad6ef0 100644 --- a/tests/rkt_service_file_test.go +++ b/tests/rkt_service_file_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_socket_activation_test.go b/tests/rkt_socket_activation_test.go index 6cf894f552..33985b6b62 100644 --- a/tests/rkt_socket_activation_test.go +++ b/tests/rkt_socket_activation_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_socket_proxyd_test.go b/tests/rkt_socket_proxyd_test.go index a4e723d989..d7f1a084c9 100644 --- a/tests/rkt_socket_proxyd_test.go +++ b/tests/rkt_socket_proxyd_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_stage1_loading_test.go b/tests/rkt_stage1_loading_test.go index 18ba955ba4..ec80852291 100644 --- a/tests/rkt_stage1_loading_test.go +++ b/tests/rkt_stage1_loading_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_supplementary_gids_test.go b/tests/rkt_supplementary_gids_test.go index b715b9faf4..2c68edd9f7 100644 --- a/tests/rkt_supplementary_gids_test.go +++ b/tests/rkt_supplementary_gids_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_trust_test.go b/tests/rkt_trust_test.go index bf1b5ec8b8..132f93e25c 100644 --- a/tests/rkt_trust_test.go +++ b/tests/rkt_trust_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src kvm +// +build host coreos src kvm package main diff --git a/tests/rkt_userns_test.go b/tests/rkt_userns_test.go index 639bc3be54..4b0106e653 100644 --- a/tests/rkt_userns_test.go +++ b/tests/rkt_userns_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build host coreos src package main diff --git a/tests/rkt_volume_nspawn_test.go b/tests/rkt_volume_nspawn_test.go index e850877ed9..bddf30554b 100644 --- a/tests/rkt_volume_nspawn_test.go +++ b/tests/rkt_volume_nspawn_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build coreos src +// +build host coreos src package main diff --git a/tests/rkt_volume_test.go b/tests/rkt_volume_test.go index a7ad758378..a57366f368 100644 --- a/tests/rkt_volume_test.go +++ b/tests/rkt_volume_test.go @@ -13,7 +13,7 @@ // limitations under the License. // TODO: fix TestDockerVolumeSemantics on KVM and add the "kvm" build tag again -// +build coreos src +// +build host coreos src package main From b5bf7a0bb4187b83e678041cf1ec8595a3aff314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Fri, 29 Apr 2016 11:21:13 +0200 Subject: [PATCH 0191/1304] Revert "stage1/prepare-app: check for user namespace env" This reverts commit ed3afb63826a0229b0adc5b844e2252a6ecea996. --- stage1/prepare-app/prepare-app.c | 85 +++++++++++--------------------- 1 file changed, 28 insertions(+), 57 deletions(-) diff --git a/stage1/prepare-app/prepare-app.c b/stage1/prepare-app/prepare-app.c index 912c992394..2731ef54df 100644 --- a/stage1/prepare-app/prepare-app.c +++ b/stage1/prepare-app/prepare-app.c @@ -23,7 +23,6 @@ #include #include #include -#include #define err_out(_fmt, _args...) \ fprintf(stderr, "Error: " _fmt "\n", ##_args); @@ -53,8 +52,6 @@ static int exit_err; #define MACHINE_ID_LEN lenof("0123456789abcdef0123456789ab") #define MACHINE_NAME_LEN lenof("rkt-01234567-89ab-cdef-0123-456789ab") -#define UNMAPPED ((uid_t) -1) - #ifndef CGROUP2_SUPER_MAGIC #define CGROUP2_SUPER_MAGIC 0x63677270 #endif @@ -128,78 +125,44 @@ static int ensure_etc_hosts_exists(const char *root, int rootfd) { return 0; } -static void mount_at(const char *root, const mount_point *mnt) -{ - char to[4096]; - exit_if(snprintf(to, sizeof(to), "%s/%s", root, mnt->target) >= sizeof(to), - "Path too long: \"%s\"", to); - pexit_if(mount(mnt->source, to, mnt->type, - mnt->flags, mnt->options) == -1, - "Mounting \"%s\" on \"%s\" failed", mnt->source, to); -} - static void mount_sys(const char *root) { - int i; + char from[4096]; char to[4096]; struct statfs fs; DIR *dir = NULL; struct dirent *d; - const mount_point mnt_rec = { "/sys", "sys", "bind", NULL, MS_BIND|MS_REC }; - const mount_point sys_bind_table[] = { - { "/sys", "sys", "bind", NULL, MS_BIND }, - { "/sys/fs/cgroup", "sys/fs/cgroup", "bind", NULL, MS_BIND }, - }; pexit_if(statfs("/sys/fs/cgroup", &fs) != 0, "Cannot statfs /sys/fs/cgroup"); if (fs.f_type == (typeof(fs.f_type)) CGROUP2_SUPER_MAGIC) { /* With the unified cgroup hierarchy, recursive bind mounts * are fine. */ - mount_at(root, &mnt_rec); + exit_if(snprintf(to, sizeof(to), "%s/%s", root, "sys") >= sizeof(to), + "Path too long: \"%s\"", to); + pexit_if(mount("/sys", to, "bind", + MS_BIND | MS_REC, "NULL") == -1, + "Mounting \"%s\" on \"%s\" failed", "/sys", to); return; } - // For security reasons recent Linux kernels do not allow to bind-mount non-recursively - // if it would give read-write access to other subdirectories mounted as read-only. - // Hence we have to check if we are in a user namespaced environment and bind mount recursively instead. - if (access("/proc/1/uid_map", F_OK) == 0) { - FILE *f; - int k; - uid_t uid_base, uid_shift, uid_range; - - pexit_if((f = fopen("/proc/1/uid_map", "re")) == NULL, - "Unable to open /proc/1/uid_map"); - - if (sizeof(uid_t) == 4) { - k = fscanf(f, "%"PRIu32" %"PRIu32" %"PRIu32, - &uid_base, &uid_shift, &uid_range); - } else { - k = fscanf(f, "%"PRIu16" %"PRIu16" %"PRIu16, - &uid_base, &uid_shift, &uid_range); - } - pexit_if(fclose(f) != 0, "Unable to close /proc/1/uid_map"); - pexit_if(k != 3, "Invalid uid_map format"); - - // do a recursive bind mount if we are in a user namespace having a parent namespace set, - // i.e. either one of uid base, shift, or the range is set, see user_namespaces(7). - if (uid_base != 0 || uid_shift != 0 || uid_range != UNMAPPED) { - mount_at(root, &mnt_rec); - return; - } - } - /* With cgroup-v1, rkt and systemd-nspawn add more cgroup * bind-mounts to control which files are read-only. To avoid * a quadratic progression, prepare-app does not bind mount * /sys recursively. See: * https://github.com/coreos/rkt/issues/2351 */ - for (i = 0; i < nelems(sys_bind_table); i++) { - mount_at(root, &sys_bind_table[i]); - } + exit_if(snprintf(to, sizeof(to), "%s/%s", root, "sys") >= sizeof(to), + "Path too long: \"%s\"", to); + pexit_if(mount("/sys", to, "bind", + MS_BIND, "NULL") == -1, + "Mounting \"%s\" on \"%s\" failed", "/sys", to); exit_if(snprintf(to, sizeof(to), "%s/%s", root, "sys/fs/cgroup") >= sizeof(to), "Path too long: \"%s\"", to); + pexit_if(mount("/sys/fs/cgroup", to, "bind", + MS_BIND, "NULL") == -1, + "Mounting \"%s\" on \"%s\" failed", "/sys/fs/cgroup", to); + pexit_if(!(dir = opendir(to)), "Failed to open directory \"%s\"", to) errno = 0; while ((d = readdir(dir))) { @@ -210,11 +173,13 @@ static void mount_sys(const char *root) if (strcmp(d->d_name, "..") == 0) continue; - exit_if(snprintf(to, sizeof(to), "sys/fs/cgroup/%s", d->d_name) >= sizeof(to), + exit_if(snprintf(from, sizeof(from), "/sys/fs/cgroup/%s", d->d_name) >= sizeof(from), + "Path too long: \"%s\"", from); + exit_if(snprintf(to, sizeof(to), "%s/sys/fs/cgroup/%s", root, d->d_name) >= sizeof(to), "Path too long: \"%s\"", to); - - mount_point mnt = { to, to, "bind", NULL, MS_BIND }; - mount_at(root, &mnt); + pexit_if(mount(from, to, "bind", + MS_BIND, "NULL") == -1, + "Mounting \"%s\" on \"%s\" failed", from, to); } pexit_if(errno != 0, "Failed to read directory \"%s\"", to); pexit_if(closedir(dir) != 0, "Failed to close directory"); @@ -352,7 +317,13 @@ int main(int argc, char *argv[]) /* Bind mount directories */ for (i = 0; i < nelems(dirs_mount_table); i++) { - mount_at(root, &dirs_mount_table[i]); + const mount_point *mnt = &dirs_mount_table[i]; + + exit_if(snprintf(to, sizeof(to), "%s/%s", root, mnt->target) >= sizeof(to), + "Path too long: \"%s\"", to); + pexit_if(mount(mnt->source, to, mnt->type, + mnt->flags, mnt->options) == -1, + "Mounting \"%s\" on \"%s\" failed", mnt->source, to); } /* Bind mount /sys: handled differently, depending on cgroups */ From 3256dae2e25bb0227aa5151b6e3f416b6926a3cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Fri, 29 Apr 2016 11:21:18 +0200 Subject: [PATCH 0192/1304] Revert "stage1/prepare-app: avoid recursive bind-mounts on /sys" This reverts commit 41948391606e5b3b03843f5b633f28dc47066077. --- stage1/prepare-app/prepare-app.c | 71 +------------------------------- 1 file changed, 1 insertion(+), 70 deletions(-) diff --git a/stage1/prepare-app/prepare-app.c b/stage1/prepare-app/prepare-app.c index 2731ef54df..30d88173f5 100644 --- a/stage1/prepare-app/prepare-app.c +++ b/stage1/prepare-app/prepare-app.c @@ -21,8 +21,6 @@ #include #include #include -#include -#include #define err_out(_fmt, _args...) \ fprintf(stderr, "Error: " _fmt "\n", ##_args); @@ -52,10 +50,6 @@ static int exit_err; #define MACHINE_ID_LEN lenof("0123456789abcdef0123456789ab") #define MACHINE_NAME_LEN lenof("rkt-01234567-89ab-cdef-0123-456789ab") -#ifndef CGROUP2_SUPER_MAGIC -#define CGROUP2_SUPER_MAGIC 0x63677270 -#endif - typedef struct _dir_op_t { const char *name; mode_t mode; @@ -125,66 +119,6 @@ static int ensure_etc_hosts_exists(const char *root, int rootfd) { return 0; } -static void mount_sys(const char *root) -{ - char from[4096]; - char to[4096]; - struct statfs fs; - DIR *dir = NULL; - struct dirent *d; - - pexit_if(statfs("/sys/fs/cgroup", &fs) != 0, - "Cannot statfs /sys/fs/cgroup"); - if (fs.f_type == (typeof(fs.f_type)) CGROUP2_SUPER_MAGIC) { - /* With the unified cgroup hierarchy, recursive bind mounts - * are fine. */ - exit_if(snprintf(to, sizeof(to), "%s/%s", root, "sys") >= sizeof(to), - "Path too long: \"%s\"", to); - pexit_if(mount("/sys", to, "bind", - MS_BIND | MS_REC, "NULL") == -1, - "Mounting \"%s\" on \"%s\" failed", "/sys", to); - return; - } - - /* With cgroup-v1, rkt and systemd-nspawn add more cgroup - * bind-mounts to control which files are read-only. To avoid - * a quadratic progression, prepare-app does not bind mount - * /sys recursively. See: - * https://github.com/coreos/rkt/issues/2351 */ - exit_if(snprintf(to, sizeof(to), "%s/%s", root, "sys") >= sizeof(to), - "Path too long: \"%s\"", to); - pexit_if(mount("/sys", to, "bind", - MS_BIND, "NULL") == -1, - "Mounting \"%s\" on \"%s\" failed", "/sys", to); - - exit_if(snprintf(to, sizeof(to), "%s/%s", root, "sys/fs/cgroup") >= sizeof(to), - "Path too long: \"%s\"", to); - pexit_if(mount("/sys/fs/cgroup", to, "bind", - MS_BIND, "NULL") == -1, - "Mounting \"%s\" on \"%s\" failed", "/sys/fs/cgroup", to); - - pexit_if(!(dir = opendir(to)), "Failed to open directory \"%s\"", to) - errno = 0; - while ((d = readdir(dir))) { - if (d->d_type != DT_DIR) - continue; - if (strcmp(d->d_name, ".") == 0) - continue; - if (strcmp(d->d_name, "..") == 0) - continue; - - exit_if(snprintf(from, sizeof(from), "/sys/fs/cgroup/%s", d->d_name) >= sizeof(from), - "Path too long: \"%s\"", from); - exit_if(snprintf(to, sizeof(to), "%s/sys/fs/cgroup/%s", root, d->d_name) >= sizeof(to), - "Path too long: \"%s\"", to); - pexit_if(mount(from, to, "bind", - MS_BIND, "NULL") == -1, - "Mounting \"%s\" on \"%s\" failed", from, to); - } - pexit_if(errno != 0, "Failed to read directory \"%s\"", to); - pexit_if(closedir(dir) != 0, "Failed to close directory"); -} - int main(int argc, char *argv[]) { static const char *unlink_paths[] = { @@ -218,10 +152,10 @@ int main(int argc, char *argv[]) }; static const mount_point dirs_mount_table[] = { { "/proc", "/proc", "bind", NULL, MS_BIND|MS_REC }, + { "/sys", "/sys", "bind", NULL, MS_BIND|MS_REC }, { "/dev/shm", "/dev/shm", "bind", NULL, MS_BIND }, { "/dev/pts", "/dev/pts", "bind", NULL, MS_BIND }, { "/run/systemd/journal", "/run/systemd/journal", "bind", NULL, MS_BIND }, - /* /sys is handled separately */ }; static const mount_point files_mount_table[] = { { "/etc/rkt-resolv.conf", "/etc/resolv.conf", "bind", NULL, MS_BIND }, @@ -326,9 +260,6 @@ int main(int argc, char *argv[]) "Mounting \"%s\" on \"%s\" failed", mnt->source, to); } - /* Bind mount /sys: handled differently, depending on cgroups */ - mount_sys(root); - /* Bind mount files, if the source exists */ for (i = 0; i < nelems(files_mount_table); i++) { const mount_point *mnt = &files_mount_table[i]; From 7b408e8a3dafc16cf202e0bde7f449e1eaa6a6bf Mon Sep 17 00:00:00 2001 From: Piotr Skamruk Date: Fri, 29 Apr 2016 12:39:26 +0200 Subject: [PATCH 0193/1304] kvm: fix net long names Update kvm flavor networking code with bits added in CNI. Resolves #2533 Reverts #2538 --- networking/kvm.go | 12 +++++++----- tests/rkt_net_nspawn_test.go | 17 ----------------- tests/rkt_net_test.go | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/networking/kvm.go b/networking/kvm.go index aa302bd222..2b23a844e1 100644 --- a/networking/kvm.go +++ b/networking/kvm.go @@ -29,6 +29,7 @@ import ( "github.com/appc/cni/pkg/ip" cnitypes "github.com/appc/cni/pkg/types" + cniutils "github.com/appc/cni/pkg/utils" "github.com/appc/spec/schema/types" "github.com/hashicorp/errwrap" "github.com/vishvananda/netlink" @@ -42,7 +43,6 @@ const ( defaultBrName = "kvm-cni0" defaultSubnetFile = "/run/flannel/subnet.env" defaultMTU = 1500 - masqComment = "rkt-lkvm masquerading" ) type BridgeNetConf struct { @@ -541,11 +541,12 @@ func kvmSetup(podRoot string, podID types.UUID, fps []ForwardedPort, netList com } if n.conf.IPMasq { - chain := getChainName(podID.String(), n.conf.Name) + chain := cniutils.FormatChainName(n.conf.Name, podID.String()) + comment := cniutils.FormatChainName(n.conf.Name, podID.String()) if err := ip.SetupIPMasq(&net.IPNet{ IP: n.runtime.IP, Mask: net.IPMask(n.runtime.Mask), - }, chain, masqComment); err != nil { + }, chain, comment); err != nil { return nil, err } } @@ -598,11 +599,12 @@ func (n *Networking) teardownKvmNets() { } // remove masquerading if it was prepared if an.conf.IPMasq { - chain := getChainName(n.podID.String(), an.conf.Name) + chain := cniutils.FormatChainName(an.conf.Name, n.podID.String()) + comment := cniutils.FormatChainName(an.conf.Name, n.podID.String()) err := ip.TeardownIPMasq(&net.IPNet{ IP: an.runtime.IP, Mask: net.IPMask(an.runtime.Mask), - }, chain, masqComment) + }, chain, comment) if err != nil { stderr.PrintE("error on removing masquerading", err) } diff --git a/tests/rkt_net_nspawn_test.go b/tests/rkt_net_nspawn_test.go index 0662a8f5a3..e436727351 100644 --- a/tests/rkt_net_nspawn_test.go +++ b/tests/rkt_net_nspawn_test.go @@ -57,20 +57,3 @@ func TestNetCustomPtp(t *testing.T) { func TestNetDefaultConnectivity(t *testing.T) { NewNetDefaultConnectivityTest().Execute(t) } - -// TODO: fix this for kvm, see https://github.com/coreos/rkt/issues/2533 -func TestNetLongName(t *testing.T) { - nt := networkTemplateT{ - Name: "thisnameiswaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaytoolong", - Type: "ptp", - IpMasq: true, - Ipam: ipamTemplateT{ - Type: "host-local", - Subnet: "11.11.6.0/24", - Routes: []map[string]string{ - {"dst": "0.0.0.0/0"}, - }, - }, - } - testNetCustomNatConnectivity(t, nt) -} diff --git a/tests/rkt_net_test.go b/tests/rkt_net_test.go index f74dd4bf16..98986e8505 100644 --- a/tests/rkt_net_test.go +++ b/tests/rkt_net_test.go @@ -783,3 +783,19 @@ func NewNetOverrideTest() testutils.Test { } }) } + +func TestNetLongName(t *testing.T) { + nt := networkTemplateT{ + Name: "thisnameiswaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaytoolong", + Type: "ptp", + IpMasq: true, + Ipam: ipamTemplateT{ + Type: "host-local", + Subnet: "11.11.6.0/24", + Routes: []map[string]string{ + {"dst": "0.0.0.0/0"}, + }, + }, + } + testNetCustomNatConnectivity(t, nt) +} From 501f87b5cba21e9a366ade539b62f24c2c5f28ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Fri, 29 Apr 2016 13:50:53 +0200 Subject: [PATCH 0194/1304] ROADMAP: update --- ROADMAP.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index 6a38af157a..04fbd596a6 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -9,20 +9,20 @@ The version of the spec that rkt implements can be seen in the output of `rkt ve rkt's version 1.0 release marks the command line user interface and on-disk data structures as stable and reliable for external development. The (optional) API for pod inspection is not yet completely stabilized, but is quite usable. -### rkt 1.5 (April) +### rkt 1.6 (May) - enhanced DNS configuration [#2044](https://github.com/coreos/rkt/issues/2044) +- app-level seccomp support [#1614](https://github.com/coreos/rkt/issues/1614) +- more isolation between stage1 and stage2 [#2483](https://github.com/coreos/rkt/issues/2483) - user configuration for stage1 [#2013](https://github.com/coreos/rkt/issues/2013) -- `rkt fly` as top-level command [#1889](https://github.com/coreos/rkt/issues/1889) -- stage1 benchmarking [#1788](https://github.com/coreos/rkt/issues/1788) -- rkt runs on Fedora with SELinux in enforcing mode -### rkt 1.6 (May) +### rkt 1.7 (May) - stable gRPC [API](https://github.com/coreos/rkt/tree/master/api/v1alpha) - IPv6 support [appc/cni#31](https://github.com/appc/cni/issues/31) - full integration with Kubernetes (aka "rktnetes") - full integration with `machinectl login` and `systemd-run` [#1463](https://github.com/coreos/rkt/issues/1463) +- `rkt fly` as top-level command [#1889](https://github.com/coreos/rkt/issues/1889) +- rkt runs on Fedora with SELinux in enforcing mode - packaged for more distributions - - Debian [#1307](https://github.com/coreos/rkt/issues/1307) - CentOS [#1305](https://github.com/coreos/rkt/issues/1305) From f0aa9a17b61013c261b247f089dfb0f43fc74615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Fri, 29 Apr 2016 14:24:01 +0200 Subject: [PATCH 0195/1304] CHANGELOG: add v1.5.0 --- CHANGELOG.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa51b1fced..6041b43dec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,37 @@ +## v1.5.0 + +This release switches to pure systemd for running apps within a pod. This lays the foundation to implement enhanced isolation capabilities. For example, starting with v1.5.0, apps are started with more restricted capabilities. User namespace support and the KVM stage1 are not experimental anymore. Resource usage can be benchmarked using the new rkt-monitor tool. + +#### New features and UX changes + +- stage1: replace appexec with pure systemd ([#2493](https://github.com/coreos/rkt/pull/2493)). Replace functionality implemented in appexec with equivalent systemd options. This allows restricting the capabilities granted to apps in a pod and makes enabling other security features (per-app mount namespaces, seccomp filters...) easier. +- stage1: restrict capabilities granted to apps ([#2493](https://github.com/coreos/rkt/pull/2493)). Apps in a pod receive now a [smaller set of capabilities](https://github.com/coreos/rkt/blob/v1.5.0/stage1/init/common/pod.go#L67). +- rkt/image: render images on fetch ([#2398](https://github.com/coreos/rkt/pull/2398)). On systems with overlay fs support, rkt was delaying rendering images to the tree store until they were about to run for the first time which caused that first run to be slow for big images. When fetching as root, render the images right away so the first run is faster. + +#### Bug fixes + +- kvm: fix mounts regression ([#2530](https://github.com/coreos/rkt/pull/2530)). Cause - AppRootfsPath called with local "root" value was adding +stage1/rootfs twice. After this change this is made properly. +- rkt/image: strip "Authorization" on redirects to a different host ([#2465](https://github.com/coreos/rkt/pull/2465)). We now don't pass the "Authorization" header if the redirect goes to a different host, it can leak sensitive information to unexpected third parties. +- stage1/init: interpret the string "root" as UID/GID 0 ([#2458](https://github.com/coreos/rkt/pull/2458)). This is a special case and it should work even if the image doesn't have /etc/passwd or /etc/group. + +#### Improved documentation + +- added benchmarks folder, benchmarks for v1.4.0 ([#2520](https://github.com/coreos/rkt/pull/2520)). Added the `Documentation/benchmarks` folder which includes a README that describes how rkt-monitor works and how to use it, and a file detailing the results of running rkt-monitor on each current workload with rkt v1.4.0. +- minor documentation fixes ([#2455](https://github.com/coreos/rkt/pull/2455), [#2528](https://github.com/coreos/rkt/pull/2528), [#2511](https://github.com/coreos/rkt/pull/2511)). + +#### Testing + +- kvm: enable functional tests for kvm ([#2007](https://github.com/coreos/rkt/pull/2007)). This includes initial support for running functional tests on the `kvm` flavor. + +#### Other changes + +- benchmarks: added rkt-monitor benchmarks ([#2324](https://github.com/coreos/rkt/pull/2324)). This includes the code for a golang binary that can start rkt and watch its resource usage and bash scripts for generating a handful of test scenarios. +- scripts: generate a Debian Sid ACI instead of using the Docker hub image ([#2471](https://github.com/coreos/rkt/pull/2471)). This is the first step to having an official release builder. +- pkg/sys: add SYS_SYNCFS definition for ppc64/ppc64le ([#2443](https://github.com/coreos/rkt/pull/2443)). Added missing SYS_SYNCFS definition for ppc64 and ppc64le, fixing build failures on those architectures. +- userns: not experimental anymore ([#2486](https://github.com/coreos/rkt/pull/2486)). Although it requires doing a recursive chown for each app, user namespaces work fine and shouldn't be marked as experimental. +- kvm: not experimental anymore ([#2485](https://github.com/coreos/rkt/pull/2485)). The kvm flavor was initially introduced in rkt v0.8.0, no reason to mark it as experimental. + ## v1.4.0 This release includes a number of new features and bugfixes like a new config subcommand, man page, and bash completion generation during build time. From 8aecf0a559417e134803c017d6bf74826486e7f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Fri, 29 Apr 2016 14:24:18 +0200 Subject: [PATCH 0196/1304] version: bump to v1.5.0 --- Documentation/getting-started-ubuntu.md | 6 +++--- Documentation/running-fly-stage1.md | 4 ++-- Documentation/running-lkvm-stage1.md | 4 ++-- Documentation/subcommands/prepare.md | 2 +- Documentation/subcommands/version.md | 2 +- Documentation/trying-out-rkt.md | 6 +++--- configure.ac | 2 +- scripts/acbuild-rkt-builder.sh | 2 +- scripts/build-rir.sh | 2 +- tests/empty-image/manifest | 2 +- tests/image/manifest | 2 +- tests/rkt_exec_test.go | 2 +- tests/rkt_image_cat_manifest_test.go | 2 +- tests/rkt_image_export_test.go | 2 +- tests/rkt_image_render_test.go | 2 +- tests/rkt_os_arch_test.go | 2 +- 16 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Documentation/getting-started-ubuntu.md b/Documentation/getting-started-ubuntu.md index 99bb2deb81..36506da88e 100644 --- a/Documentation/getting-started-ubuntu.md +++ b/Documentation/getting-started-ubuntu.md @@ -15,9 +15,9 @@ vagrant up --provider virtualbox vagrant ssh sudo -s -wget https://github.com/coreos/rkt/releases/download/v1.4.0/rkt-v1.4.0.tar.gz -tar xzvf rkt-v1.4.0.tar.gz -cd rkt-v1.4.0 +wget https://github.com/coreos/rkt/releases/download/v1.5.0/rkt-v1.5.0.tar.gz +tar xzvf rkt-v1.5.0.tar.gz +cd rkt-v1.5.0 ./rkt help ``` diff --git a/Documentation/running-fly-stage1.md b/Documentation/running-fly-stage1.md index 7eff0faff9..978adec66e 100644 --- a/Documentation/running-fly-stage1.md +++ b/Documentation/running-fly-stage1.md @@ -60,14 +60,14 @@ $ ./autogen.sh && ./configure --with-stage1-flavors=fly && make ``` For more details about configure parameters, see the [configure script parameters documentation](build-configure.md). -This will build the rkt binary and the stage1-fly.aci in `build-rkt-1.4.0+git/bin/`. +This will build the rkt binary and the stage1-fly.aci in `build-rkt-1.5.0+git/bin/`. ### Selecting stage1 at runtime Here is a quick example of how to use a container with the official fly stage1: ``` -# rkt run --stage1-name=coreos.com/rkt/stage1-fly:1.4.0 coreos.com/etcd:v2.2.5 +# rkt run --stage1-name=coreos.com/rkt/stage1-fly:1.5.0 coreos.com/etcd:v2.2.5 ``` If the image is not in the store, `--stage1-name` will perform discovery and fetch the image. diff --git a/Documentation/running-lkvm-stage1.md b/Documentation/running-lkvm-stage1.md index d527421461..839d14af73 100644 --- a/Documentation/running-lkvm-stage1.md +++ b/Documentation/running-lkvm-stage1.md @@ -13,7 +13,7 @@ $ ./autogen.sh && ./configure --with-stage1-flavors=kvm && make ``` For more details about configure parameters, see [configure script parameters documentation](build-configure.md). -This will build the rkt binary and the LKVM stage1-kvm.aci in `build-rkt-1.4.0+git/bin/`. +This will build the rkt binary and the LKVM stage1-kvm.aci in `build-rkt-1.5.0+git/bin/`. Provided you have hardware virtualization support and the [kernel KVM module](http://www.linux-kvm.org/page/Getting_the_kvm_kernel_modules) loaded (refer to your distribution for instructions), you can then run an image like you would normally do with rkt: @@ -84,7 +84,7 @@ If you want to run software that requires hypervisor isolation along with truste For example, to use the official lkvm stage1: ``` -# rkt run --stage1-name=coreos.com/rkt/stage1-kvm:1.4.0 coreos.com/etcd:v2.0.9 +# rkt run --stage1-name=coreos.com/rkt/stage1-kvm:1.5.0 coreos.com/etcd:v2.0.9 ... ``` diff --git a/Documentation/subcommands/prepare.md b/Documentation/subcommands/prepare.md index 38ae3a3c96..8d0ea0c609 100644 --- a/Documentation/subcommands/prepare.md +++ b/Documentation/subcommands/prepare.md @@ -14,7 +14,7 @@ Therefore, the supported arguments are mostly the same as in `run` except runtim ``` # rkt prepare coreos.com/etcd:v2.0.10 rkt prepare coreos.com/etcd:v2.0.10 -rkt: using image from local store for image name coreos.com/rkt/stage1-coreos:1.4.0 +rkt: using image from local store for image name coreos.com/rkt/stage1-coreos:1.5.0 rkt: searching for app image coreos.com/etcd:v2.0.10 rkt: remote fetching from url https://github.com/coreos/etcd/releases/download/v2.0.10/etcd-v2.0.10-linux-amd64.aci prefix: "coreos.com/etcd" diff --git a/Documentation/subcommands/version.md b/Documentation/subcommands/version.md index 2c6cb0464a..97257bfdf3 100644 --- a/Documentation/subcommands/version.md +++ b/Documentation/subcommands/version.md @@ -6,7 +6,7 @@ This command prints the rkt version, the appc version rkt is built against, and ``` $ rkt version -rkt Version: 1.4.0 +rkt Version: 1.5.0 appc Version: 0.7.4 Go Version: go1.5.3 Go OS/Arch: linux/amd64 diff --git a/Documentation/trying-out-rkt.md b/Documentation/trying-out-rkt.md index 138dbe6f3c..57b3361122 100644 --- a/Documentation/trying-out-rkt.md +++ b/Documentation/trying-out-rkt.md @@ -10,9 +10,9 @@ rkt consists of a single CLI tool, and is currently supported on amd64 Linux. A To download the rkt binary, simply grab the latest release directly from GitHub: ``` -wget https://github.com/coreos/rkt/releases/download/v1.4.0/rkt-v1.4.0.tar.gz -tar xzvf rkt-v1.4.0.tar.gz -cd rkt-v1.4.0 +wget https://github.com/coreos/rkt/releases/download/v1.5.0/rkt-v1.5.0.tar.gz +tar xzvf rkt-v1.5.0.tar.gz +cd rkt-v1.5.0 ./rkt help ``` diff --git a/configure.ac b/configure.ac index d0e36073c0..c726780570 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.63]) -AC_INIT([rkt], [1.4.0+git], [https://github.com/coreos/rkt/issues]) +AC_INIT([rkt], [1.5.0], [https://github.com/coreos/rkt/issues]) AC_DEFUN([RKT_CHECK_PROG], [AS_VAR_IF([$1], [], diff --git a/scripts/acbuild-rkt-builder.sh b/scripts/acbuild-rkt-builder.sh index d656b1f68b..fd8507d68b 100755 --- a/scripts/acbuild-rkt-builder.sh +++ b/scripts/acbuild-rkt-builder.sh @@ -17,7 +17,7 @@ fi MODIFY=${MODIFY:-""} FLAGS=${FLAGS:-""} IMG_NAME="coreos.com/rkt/builder" -IMG_VERSION=${VERSION:-"v1.4.0+git"} +IMG_VERSION=${VERSION:-"v1.5.0"} ACI_FILE=rkt-builder.aci BUILDDIR=/opt/build-rkt SRC_DIR=/opt/rkt diff --git a/scripts/build-rir.sh b/scripts/build-rir.sh index e9880faa53..d48396b494 100755 --- a/scripts/build-rir.sh +++ b/scripts/build-rir.sh @@ -4,7 +4,7 @@ set -xe SRC_DIR="${SRC_DIR:-$PWD}" BUILDDIR="${BUILDDIR:-$PWD/build-rir}" -RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.4.0+git}" +RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.5.0}" mkdir -p $BUILDDIR diff --git a/tests/empty-image/manifest b/tests/empty-image/manifest index c661ca5d17..39f923d290 100644 --- a/tests/empty-image/manifest +++ b/tests/empty-image/manifest @@ -5,7 +5,7 @@ "labels": [ { "name": "version", - "value": "1.4.0" + "value": "1.5.0" }, { "name": "arch", diff --git a/tests/image/manifest b/tests/image/manifest index 7d81c25d1f..14be72f2c8 100644 --- a/tests/image/manifest +++ b/tests/image/manifest @@ -5,7 +5,7 @@ "labels": [ { "name": "version", - "value": "1.4.0" + "value": "1.5.0" }, { "name": "arch", diff --git a/tests/rkt_exec_test.go b/tests/rkt_exec_test.go index f48a5b058e..5c1a5bc11b 100644 --- a/tests/rkt_exec_test.go +++ b/tests/rkt_exec_test.go @@ -26,7 +26,7 @@ import ( ) const ( - noappManifestStr = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"coreos.com/rkt-inspect","labels":[{"name":"version","value":"1.4.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}]}` + noappManifestStr = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"coreos.com/rkt-inspect","labels":[{"name":"version","value":"1.5.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}]}` ) func TestRunOverrideExec(t *testing.T) { diff --git a/tests/rkt_image_cat_manifest_test.go b/tests/rkt_image_cat_manifest_test.go index 10c26fd32c..9908721e5c 100644 --- a/tests/rkt_image_cat_manifest_test.go +++ b/tests/rkt_image_cat_manifest_test.go @@ -29,7 +29,7 @@ import ( const ( // The expected image manifest of the 'rkt-inspect-image-cat-manifest.aci'. - manifestTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.4.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.5.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageCatManifest tests 'rkt image cat-manifest', it will: diff --git a/tests/rkt_image_export_test.go b/tests/rkt_image_export_test.go index c95eb068eb..2b36d5e04a 100644 --- a/tests/rkt_image_export_test.go +++ b/tests/rkt_image_export_test.go @@ -28,7 +28,7 @@ import ( ) const ( - manifestExportTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.4.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestExportTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.5.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageExport tests 'rkt image export', it will import some existing diff --git a/tests/rkt_image_render_test.go b/tests/rkt_image_render_test.go index ad272f15b2..0510a9bab7 100644 --- a/tests/rkt_image_render_test.go +++ b/tests/rkt_image_render_test.go @@ -28,7 +28,7 @@ import ( ) const ( - manifestRenderTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.4.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"dependencies":[{"imageName":"coreos.com/rkt-inspect"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestRenderTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.5.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"dependencies":[{"imageName":"coreos.com/rkt-inspect"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageRender tests 'rkt image render', it will import some existing empty diff --git a/tests/rkt_os_arch_test.go b/tests/rkt_os_arch_test.go index 0bfdf8c1b2..adc9b91d30 100644 --- a/tests/rkt_os_arch_test.go +++ b/tests/rkt_os_arch_test.go @@ -27,7 +27,7 @@ import ( ) const ( - manifestOSArchTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.4.0"}ARCH_OS],"app":{"exec":["/inspect", "--print-msg=HelloWorld"],"user":"0","group":"0","workingDirectory":"/"}}` + manifestOSArchTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.5.0"}ARCH_OS],"app":{"exec":["/inspect", "--print-msg=HelloWorld"],"user":"0","group":"0","workingDirectory":"/"}}` ) type osArchTest struct { From 4bcd4f2cc3e3e837c4a0bf65a9e0730dacab4fbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Fri, 29 Apr 2016 14:24:18 +0200 Subject: [PATCH 0197/1304] version: bump to v1.5.0+git --- configure.ac | 2 +- scripts/acbuild-rkt-builder.sh | 2 +- scripts/build-rir.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index c726780570..af0ff4c83e 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.63]) -AC_INIT([rkt], [1.5.0], [https://github.com/coreos/rkt/issues]) +AC_INIT([rkt], [1.5.0+git], [https://github.com/coreos/rkt/issues]) AC_DEFUN([RKT_CHECK_PROG], [AS_VAR_IF([$1], [], diff --git a/scripts/acbuild-rkt-builder.sh b/scripts/acbuild-rkt-builder.sh index fd8507d68b..1cbe97ef0d 100755 --- a/scripts/acbuild-rkt-builder.sh +++ b/scripts/acbuild-rkt-builder.sh @@ -17,7 +17,7 @@ fi MODIFY=${MODIFY:-""} FLAGS=${FLAGS:-""} IMG_NAME="coreos.com/rkt/builder" -IMG_VERSION=${VERSION:-"v1.5.0"} +IMG_VERSION=${VERSION:-"v1.5.0+git"} ACI_FILE=rkt-builder.aci BUILDDIR=/opt/build-rkt SRC_DIR=/opt/rkt diff --git a/scripts/build-rir.sh b/scripts/build-rir.sh index d48396b494..d2632ce380 100755 --- a/scripts/build-rir.sh +++ b/scripts/build-rir.sh @@ -4,7 +4,7 @@ set -xe SRC_DIR="${SRC_DIR:-$PWD}" BUILDDIR="${BUILDDIR:-$PWD/build-rir}" -RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.5.0}" +RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.5.0+git}" mkdir -p $BUILDDIR From b927a2464e332ac3f01d76c5c4eaaa822927db5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Fri, 29 Apr 2016 18:06:27 +0200 Subject: [PATCH 0198/1304] stage1/init: remove redundant slice We can just list the values. --- stage1/init/common/pod.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index 52532f9b46..1f83674670 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -64,7 +64,7 @@ var ( // appDefaultCapabilities defines a restricted set of capabilities given to // apps by default. // See https://github.com/appc/spec/issues/598 - appDefaultCapabilities, _ = types.NewLinuxCapabilitiesRetainSet([]string{ + appDefaultCapabilities, _ = types.NewLinuxCapabilitiesRetainSet( "CAP_AUDIT_WRITE", "CAP_CHOWN", "CAP_DAC_OVERRIDE", @@ -78,8 +78,7 @@ var ( "CAP_SETGID", "CAP_SETPCAP", "CAP_SETFCAP", - "CAP_SYS_CHROOT", - }...) + "CAP_SYS_CHROOT") ) // execEscape uses Golang's string quoting for ", \, \n, and regex for special cases From 056412c7075783edcce6362bd56933f7f522e7f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Fri, 29 Apr 2016 18:24:14 +0200 Subject: [PATCH 0199/1304] rkt: don't bail if dataDir doesn't exist when evaluating symlinks It will be created later. --- rkt/rkt.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rkt/rkt.go b/rkt/rkt.go index 1577f3c343..2551f0ad89 100644 --- a/rkt/rkt.go +++ b/rkt/rkt.go @@ -290,8 +290,12 @@ func calculateDataDir() string { // Resolve symlinks realDataDir, err := filepath.EvalSymlinks(dataDir) if err != nil { - stderr.PrintE(fmt.Sprintf("cannot evaluate dataDir %q real path", dataDir), err) - os.Exit(1) + if os.IsNotExist(err) { + realDataDir = dataDir + } else { + stderr.PrintE(fmt.Sprintf("cannot evaluate dataDir %q real path", dataDir), err) + os.Exit(1) + } } // If above fails, then use the default. return realDataDir From c812e245d963249a67fa5a420c1d479e5685468f Mon Sep 17 00:00:00 2001 From: Piotr Skamruk Date: Fri, 29 Apr 2016 15:03:10 +0200 Subject: [PATCH 0200/1304] kvm: fix docker volume semantics Closes #2534 Reverts #2535 --- stage1/init/common/mount.go | 8 +++---- stage1/init/common/pod.go | 10 ++++---- stage1/init/kvm.go | 47 ++++++++++++++----------------------- tests/rkt_volume_test.go | 3 +-- 4 files changed, 28 insertions(+), 40 deletions(-) diff --git a/stage1/init/common/mount.go b/stage1/init/common/mount.go index 2f264b422a..2a9f6e5bf3 100644 --- a/stage1/init/common/mount.go +++ b/stage1/init/common/mount.go @@ -32,7 +32,7 @@ import ( // whether it is an implicit empty volume converted from a Docker image. type mountWrapper struct { schema.Mount - dockerImplicit bool + DockerImplicit bool } func isMPReadOnly(mountPoints []types.MountPoint, name types.ACName) bool { @@ -76,7 +76,7 @@ func GenerateMounts(ra *schema.RuntimeApp, volumes map[types.ACName]types.Volume genMnts = append(genMnts, mountWrapper{ Mount: m, - dockerImplicit: false, + DockerImplicit: false, }) } @@ -114,7 +114,7 @@ func GenerateMounts(ra *schema.RuntimeApp, volumes map[types.ACName]types.Volume Volume: uniqName, Path: mp.Path, }, - dockerImplicit: dockerImplicit, + DockerImplicit: dockerImplicit, }) } else { genMnts = append(genMnts, @@ -123,7 +123,7 @@ func GenerateMounts(ra *schema.RuntimeApp, volumes map[types.ACName]types.Volume Volume: vol.Name, Path: mp.Path, }, - dockerImplicit: false, + DockerImplicit: false, }) } } diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index 1f83674670..e428ee286a 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -329,7 +329,7 @@ func lookupPathInsideApp(bin string, paths string, appRootfs string, workDir str for _, path := range appPathsArr { binPath := filepath.Join(path, bin) stage2Path := strings.TrimPrefix(binPath, appRootfs) - binRealPath, err := evaluateSymlinksInsideApp(appRootfs, stage2Path) + binRealPath, err := EvaluateSymlinksInsideApp(appRootfs, stage2Path) if err != nil { return "", errwrap.Wrap(fmt.Errorf("could not evaluate path %v", stage2Path), err) } @@ -756,9 +756,9 @@ func PodToSystemd(p *stage1commontypes.Pod, interactive bool, flavor string, pri return nil } -// evaluateSymlinksInsideApp tries to resolve symlinks within the path. +// EvaluateSymlinksInsideApp tries to resolve symlinks within the path. // It returns the actual path relative to the app rootfs for the given path. -func evaluateSymlinksInsideApp(appRootfs, path string) (string, error) { +func EvaluateSymlinksInsideApp(appRootfs, path string) (string, error) { link := appRootfs paths := strings.Split(path, "/") @@ -840,13 +840,13 @@ func appToNspawnArgs(p *stage1commontypes.Pod, ra *schema.RuntimeApp) ([]string, // TODO(yifan): This is a temporary fix for systemd-nspawn not handling symlink mounts well. // Could be removed when https://github.com/systemd/systemd/issues/2860 is resolved, and systemd // version is bumped. - mntPath, err := evaluateSymlinksInsideApp(appRootfs, m.Path) + mntPath, err := EvaluateSymlinksInsideApp(appRootfs, m.Path) if err != nil { return nil, errwrap.Wrap(fmt.Errorf("could not evaluate path %v", m.Path), err) } mntAbsPath := filepath.Join(appRootfs, mntPath) - if err := PrepareMountpoints(shPath, mntAbsPath, &vol, m.dockerImplicit); err != nil { + if err := PrepareMountpoints(shPath, mntAbsPath, &vol, m.DockerImplicit); err != nil { return nil, err } diff --git a/stage1/init/kvm.go b/stage1/init/kvm.go index 19a8e689e5..34ee9afb6b 100644 --- a/stage1/init/kvm.go +++ b/stage1/init/kvm.go @@ -21,8 +21,6 @@ import ( "fmt" "os" "path/filepath" - "strconv" - "strings" "syscall" "github.com/appc/spec/schema" @@ -70,21 +68,24 @@ func mountSharedVolumes(root string, p *stage1commontypes.Pod, ra *schema.Runtim for _, m := range mounts { vol := vols[m.Volume] - if vol.Kind == "empty" { - p := filepath.Join(sharedVolPath, vol.Name.String()) - if err := os.MkdirAll(p, stage1initcommon.SharedVolPerm); err != nil { - return errwrap.Wrap(fmt.Errorf("could not create shared volume %q", vol.Name), err) - } - if err := os.Chown(p, *vol.UID, *vol.GID); err != nil { - return errwrap.Wrap(fmt.Errorf("could not change owner of %q", p), err) - } - mod, err := strconv.ParseUint(*vol.Mode, 8, 32) - if err != nil { - return errwrap.Wrap(fmt.Errorf("invalid mode %q for volume %q", *vol.Mode, vol.Name), err) - } - if err := os.Chmod(p, os.FileMode(mod)); err != nil { - return errwrap.Wrap(fmt.Errorf("could not change permissions of %q", p), err) - } + absRoot, err := filepath.Abs(p.Root) // Absolute path to the pod's rootfs. + if err != nil { + return errwrap.Wrap(errors.New("could not get pod's root absolute path"), err) + } + + absAppRootfs := common.AppRootfsPath(absRoot, appName) + if err != nil { + return fmt.Errorf(`could not evaluate absolute path for application rootfs in app: %v`, appName) + } + + mntPath, err := stage1initcommon.EvaluateSymlinksInsideApp(absAppRootfs, m.Path) + if err != nil { + return errwrap.Wrap(fmt.Errorf("could not evaluate path %v", m.Path), err) + } + absDestination := filepath.Join(absAppRootfs, mntPath) + shPath := filepath.Join(sharedVolPath, vol.Name.String()) + if err := stage1initcommon.PrepareMountpoints(shPath, absDestination, &vol, m.DockerImplicit); err != nil { + return err } readOnly := stage1initcommon.IsMountReadOnly(vol, app.MountPoints) @@ -97,18 +98,6 @@ func mountSharedVolumes(root string, p *stage1commontypes.Pod, ra *schema.Runtim default: return fmt.Errorf(`invalid volume kind %q. Must be one of "host" or "empty"`, vol.Kind) } - absAppRootfs, err := filepath.Abs(common.AppRootfsPath(".", appName)) - if err != nil { - return fmt.Errorf(`could not evaluate absolute path for application rootfs in app: %v`, appName) - } - - absDestination, err := filepath.Abs(filepath.Join(absAppRootfs, m.Path)) - if err != nil { - return fmt.Errorf(`could not evaluate absolute path for application volume path %q in: %v`, m.Path, appName) - } - if !strings.HasPrefix(absDestination, absAppRootfs) { - return fmt.Errorf("path escapes app's root: %v", absDestination) - } if cleanedSource, err := filepath.EvalSymlinks(source); err != nil { return errwrap.Wrap(fmt.Errorf("could not resolve symlink for source: %v", source), err) } else if err := ensureDestinationExists(cleanedSource, absDestination); err != nil { diff --git a/tests/rkt_volume_test.go b/tests/rkt_volume_test.go index a57366f368..1577ff3fa9 100644 --- a/tests/rkt_volume_test.go +++ b/tests/rkt_volume_test.go @@ -12,8 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// TODO: fix TestDockerVolumeSemantics on KVM and add the "kvm" build tag again -// +build host coreos src +// +build host coreos src kvm package main From 8ec7ff5878ff07cb7120810ea6153e803509ea06 Mon Sep 17 00:00:00 2001 From: Shaya Potter Date: Thu, 21 Apr 2016 05:33:39 -0700 Subject: [PATCH 0201/1304] Add Cgroup filter to match all of a pod's sub cgroups --- api/v1alpha/api.pb.go | 192 +++++++++++++++++++++--------------------- api/v1alpha/api.proto | 4 + rkt/api_service.go | 17 ++++ 3 files changed, 119 insertions(+), 94 deletions(-) diff --git a/api/v1alpha/api.pb.go b/api/v1alpha/api.pb.go index d801049bec..5c4bbf0883 100644 --- a/api/v1alpha/api.pb.go +++ b/api/v1alpha/api.pb.go @@ -407,6 +407,9 @@ type PodFilter struct { Annotations []*KeyValue `protobuf:"bytes,6,rep,name=annotations" json:"annotations,omitempty"` // If not empty, the pods whose cgroup are listed will be returned. Cgroups []string `protobuf:"bytes,7,rep,name=cgroups" json:"cgroups,omitempty"` + // If not empty, the pods whose these cgroup belong to will be returned. + // i.e. the pod's cgroup is a prefix of the specified cgroup + PodSubCgroups []string `protobuf:"bytes,8,rep,name=pod_sub_cgroups" json:"pod_sub_cgroups,omitempty"` } func (m *PodFilter) Reset() { *m = PodFilter{} } @@ -1138,98 +1141,99 @@ var _PublicAPI_serviceDesc = grpc.ServiceDesc{ } var fileDescriptor0 = []byte{ - // 1481 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x57, 0xcd, 0x72, 0xdb, 0x46, - 0x12, 0x36, 0x7f, 0xc0, 0x9f, 0x26, 0x4d, 0x91, 0x23, 0xd9, 0xa2, 0xe8, 0x3f, 0x19, 0xbb, 0xeb, - 0xf2, 0xea, 0xa0, 0xdd, 0xc8, 0x8e, 0x2f, 0xa9, 0x4a, 0x99, 0x96, 0x20, 0x15, 0x63, 0x89, 0x64, - 0xd1, 0xb4, 0x2b, 0x3e, 0xa1, 0x20, 0x72, 0x28, 0xa3, 0x04, 0x02, 0x08, 0x00, 0xca, 0x56, 0x8e, - 0x39, 0xe5, 0x96, 0x47, 0xc8, 0x33, 0xe4, 0x94, 0x63, 0xde, 0x25, 0x55, 0x79, 0x8f, 0xf4, 0x0c, - 0x06, 0xc0, 0x00, 0x04, 0x0f, 0xb9, 0x89, 0xdd, 0x3d, 0x5f, 0x7f, 0xdd, 0xd3, 0xfd, 0x0d, 0x04, - 0x75, 0xc3, 0x35, 0x0f, 0x5d, 0xcf, 0x09, 0x1c, 0x52, 0xbd, 0xf9, 0xca, 0xb0, 0xdc, 0x4f, 0x86, - 0xfa, 0x1a, 0x1a, 0x83, 0xa5, 0x71, 0x45, 0x4f, 0x1d, 0x6f, 0x69, 0x04, 0x64, 0x1f, 0xca, 0xc1, - 0xad, 0x4b, 0xbb, 0x85, 0xfd, 0xc2, 0xf3, 0xd6, 0x11, 0x39, 0x14, 0x61, 0x87, 0x3c, 0x66, 0x8a, - 0x1e, 0xb2, 0x05, 0xd5, 0x1b, 0xea, 0xf9, 0xa6, 0x63, 0x77, 0x8b, 0x18, 0x54, 0x57, 0xff, 0x28, - 0x80, 0xc2, 0xdd, 0xe4, 0xbf, 0xd0, 0xb8, 0x34, 0x7c, 0xaa, 0x2f, 0x38, 0x16, 0xc7, 0x68, 0x1c, - 0xed, 0xa4, 0x31, 0x44, 0x1e, 0x80, 0xa2, 0x39, 0x0f, 0x01, 0x48, 0x13, 0xca, 0xb6, 0xb1, 0xa4, - 0xdd, 0x12, 0xff, 0x25, 0xe1, 0x97, 0xb9, 0xa1, 0x0b, 0x6d, 0x73, 0xe9, 0x3a, 0x5e, 0xa0, 0x07, - 0xe6, 0x92, 0xfa, 0x81, 0xb1, 0x74, 0xbb, 0x0a, 0x7a, 0x4a, 0xa4, 0x0d, 0xb5, 0xa5, 0x61, 0x9b, - 0x0b, 0x34, 0x76, 0x2b, 0x68, 0x69, 0x32, 0x28, 0xdf, 0xfc, 0x91, 0x76, 0xab, 0xdc, 0xff, 0x0c, - 0x1a, 0x86, 0x6d, 0x3b, 0x81, 0x11, 0x20, 0x9a, 0xdf, 0xad, 0xed, 0x97, 0x90, 0x4f, 0x27, 0xe6, - 0xf3, 0x96, 0xde, 0x7e, 0x30, 0xac, 0x15, 0x55, 0x5f, 0x40, 0x75, 0x48, 0x83, 0xcf, 0x8e, 0x77, - 0x1d, 0x73, 0x29, 0x44, 0xcc, 0x4c, 0xf7, 0xe6, 0x65, 0xc2, 0x13, 0x7f, 0xbd, 0x0a, 0x79, 0xaa, - 0xbf, 0x14, 0xa0, 0xd4, 0x77, 0xdd, 0xcc, 0x89, 0x47, 0xa0, 0x98, 0xac, 0x4c, 0x7e, 0xa4, 0x71, - 0xd4, 0x4a, 0x17, 0x8f, 0xed, 0x55, 0xb0, 0x80, 0x20, 0xac, 0xb5, 0x25, 0x71, 0x41, 0xa4, 0x77, - 0xcc, 0x41, 0x3a, 0x50, 0xa7, 0x5f, 0xcc, 0x40, 0x9f, 0x39, 0x73, 0xca, 0x1b, 0xd0, 0xc9, 0x96, - 0xa1, 0x6c, 0x2a, 0xe3, 0xe7, 0x22, 0x94, 0xc6, 0xce, 0x5c, 0xf4, 0x36, 0xe4, 0xd3, 0x80, 0x92, - 0x2b, 0x1a, 0xdd, 0xd9, 0x9c, 0x1d, 0x4f, 0x85, 0xd9, 0x7b, 0x50, 0x36, 0x5c, 0xd7, 0xc7, 0xc4, - 0x2c, 0x47, 0x53, 0xa6, 0x47, 0x54, 0xa8, 0xd9, 0x61, 0x97, 0x22, 0x0e, 0xed, 0xd8, 0x1f, 0xb5, - 0x6f, 0xfd, 0x46, 0x32, 0xe4, 0xab, 0x1b, 0xc8, 0x93, 0x16, 0x54, 0x66, 0x57, 0x9e, 0xb3, 0x72, - 0xf1, 0x9a, 0x18, 0x71, 0xac, 0x62, 0xe6, 0x51, 0xe4, 0x34, 0xd7, 0x71, 0x94, 0xea, 0xfc, 0x3e, - 0xd1, 0x86, 0xfc, 0x3d, 0x61, 0x03, 0x6e, 0xdb, 0x81, 0xe6, 0xd5, 0x4c, 0x5f, 0x1a, 0xde, 0x75, - 0x68, 0x6d, 0x30, 0xab, 0xfa, 0x0c, 0x6a, 0x31, 0x32, 0xb6, 0x00, 0xff, 0x16, 0xfd, 0xb8, 0x0b, - 0xca, 0x0d, 0xb3, 0x8a, 0xd9, 0xfd, 0xad, 0x00, 0x75, 0x2c, 0xfe, 0xd4, 0xb4, 0x02, 0xea, 0xb1, - 0x48, 0x73, 0xee, 0x63, 0x64, 0x09, 0x23, 0x9f, 0x42, 0x85, 0x37, 0xcb, 0xc7, 0xd0, 0x52, 0x7e, - 0xb7, 0x3a, 0x6c, 0xa3, 0x5c, 0x9d, 0x5d, 0xbf, 0x8f, 0x3d, 0x65, 0xa7, 0xd0, 0xc4, 0xef, 0x5f, - 0x67, 0x40, 0x65, 0x6e, 0xba, 0x07, 0x77, 0x45, 0xdf, 0x44, 0xa4, 0xc2, 0xcd, 0x99, 0xc6, 0x54, - 0x36, 0x35, 0x06, 0xf7, 0x21, 0x6c, 0x4c, 0xd8, 0xbc, 0xba, 0xfa, 0x67, 0x21, 0x5a, 0xd9, 0x1c, - 0xd6, 0x78, 0x01, 0xae, 0x47, 0x17, 0xe6, 0x17, 0xc1, 0x9b, 0x37, 0x92, 0x2f, 0xa5, 0xcc, 0x12, - 0xa3, 0xae, 0xe9, 0x2d, 0x52, 0x8a, 0x49, 0x62, 0xb5, 0x96, 0x71, 0x49, 0xad, 0xcd, 0xe3, 0x45, - 0xee, 0x43, 0x2b, 0xdc, 0x43, 0xd6, 0xe8, 0x05, 0x66, 0xe6, 0x37, 0x5c, 0x22, 0xbb, 0xb0, 0x15, - 0xdb, 0x2f, 0x29, 0xee, 0xfe, 0x3f, 0x5c, 0x3f, 0xc6, 0x70, 0xb1, 0xb2, 0x2c, 0xc1, 0xb0, 0xce, - 0x8b, 0xfc, 0x15, 0x8b, 0x3c, 0xb3, 0x9c, 0x4b, 0xc3, 0x3a, 0xb5, 0x8c, 0x2b, 0x9f, 0x15, 0x39, - 0x37, 0x3d, 0x71, 0x89, 0x7b, 0xd0, 0xf1, 0x6f, 0xfd, 0x80, 0x2e, 0x71, 0x4b, 0xec, 0x85, 0x79, - 0xa5, 0x33, 0x57, 0x31, 0x12, 0x0b, 0xcb, 0x99, 0x19, 0x96, 0xec, 0x09, 0x75, 0x05, 0x69, 0xae, - 0x7c, 0xea, 0xc9, 0x8e, 0x50, 0x5f, 0x58, 0x5d, 0xb6, 0x4f, 0x67, 0x2b, 0x0f, 0x95, 0x8b, 0x25, - 0xe3, 0xea, 0xc2, 0x56, 0xf9, 0x5e, 0xe0, 0xad, 0xfc, 0x40, 0xc7, 0x56, 0xf9, 0xfa, 0xc2, 0x73, - 0x96, 0xfa, 0xa7, 0x20, 0x70, 0x7d, 0x5e, 0x76, 0x4d, 0xf5, 0xa0, 0x3c, 0xb0, 0x17, 0x0e, 0xd9, - 0x86, 0x86, 0x77, 0x1d, 0xe8, 0x91, 0x66, 0x85, 0x0c, 0x71, 0x2a, 0x71, 0x32, 0x66, 0x7a, 0x4a, - 0x29, 0x59, 0x28, 0x2a, 0x70, 0x6c, 0x0c, 0x79, 0x1d, 0xe0, 0x00, 0xf3, 0x42, 0x45, 0xf2, 0x72, - 0x46, 0x35, 0xa5, 0x2e, 0x60, 0x4e, 0x45, 0xbb, 0xa1, 0xf6, 0x66, 0x99, 0xe6, 0x5e, 0x2e, 0xd3, - 0x19, 0x81, 0x65, 0xf4, 0x45, 0x42, 0xfc, 0xc5, 0x84, 0x94, 0x27, 0x2a, 0x91, 0x27, 0x50, 0x9e, - 0x1b, 0x81, 0xb1, 0x59, 0x55, 0x02, 0x68, 0x70, 0x54, 0x31, 0x6d, 0x4f, 0x41, 0x61, 0x99, 0xc3, - 0x79, 0xcb, 0x4f, 0x2d, 0x06, 0x32, 0x1c, 0x3f, 0x5c, 0x38, 0x79, 0xf2, 0xd8, 0x0a, 0x9b, 0xf6, - 0x8c, 0xea, 0x12, 0x05, 0xb4, 0xad, 0xec, 0xc0, 0xb4, 0x42, 0x1b, 0x97, 0x76, 0xb5, 0x0d, 0xad, - 0x33, 0x1a, 0xb0, 0x06, 0x4f, 0xe8, 0x0f, 0x2b, 0x94, 0x13, 0xf5, 0x10, 0xb6, 0x62, 0x8b, 0xef, - 0xe2, 0x40, 0x51, 0xf2, 0x00, 0x05, 0x19, 0x7f, 0x8b, 0x87, 0xe6, 0x6e, 0xa2, 0xb5, 0x68, 0x54, - 0x4f, 0x61, 0xeb, 0xdc, 0xf4, 0x03, 0x5c, 0x56, 0x5f, 0x40, 0x90, 0x7f, 0x41, 0x75, 0xc1, 0xab, - 0x08, 0xd9, 0x37, 0x24, 0xf6, 0x89, 0x08, 0xa0, 0x10, 0xcd, 0x69, 0x60, 0x98, 0x16, 0x6f, 0x5e, - 0x0d, 0xf3, 0xb6, 0x13, 0x1c, 0x91, 0x18, 0x65, 0xd2, 0x75, 0xe6, 0x11, 0x4a, 0x53, 0x46, 0x51, - 0x9f, 0x40, 0x67, 0x60, 0xfb, 0x2e, 0x9d, 0xb1, 0x23, 0x51, 0x66, 0x49, 0x92, 0xd5, 0xff, 0x01, - 0x91, 0x03, 0x04, 0xe4, 0x1e, 0x0a, 0xb5, 0x33, 0x17, 0xa5, 0xa4, 0x11, 0xbf, 0x83, 0x0e, 0x63, - 0xc0, 0x77, 0x3e, 0xae, 0xe5, 0x3f, 0xd9, 0x5a, 0xb2, 0xef, 0x6c, 0x7e, 0x35, 0x2f, 0x81, 0xc8, - 0x58, 0x22, 0xf9, 0x63, 0xa8, 0x70, 0xd5, 0x8a, 0xb0, 0x32, 0xcf, 0x96, 0xfa, 0x14, 0xb6, 0x05, - 0x65, 0xfe, 0x3b, 0xaf, 0xaa, 0xaf, 0x61, 0x27, 0x1d, 0x22, 0xa0, 0xe3, 0x07, 0xb1, 0x90, 0xf7, - 0x20, 0xaa, 0xdf, 0xc0, 0x36, 0xe3, 0x43, 0x6d, 0x3e, 0x3e, 0x71, 0x75, 0xff, 0x86, 0x4a, 0x58, - 0xdd, 0xda, 0x47, 0x84, 0x34, 0x8b, 0xea, 0x2b, 0xd8, 0x49, 0x1f, 0x4e, 0xca, 0xa1, 0xdc, 0xb2, - 0x56, 0x0e, 0x0f, 0x54, 0x6f, 0xf9, 0x70, 0x9d, 0x3b, 0x57, 0x71, 0x3e, 0x6c, 0x13, 0x76, 0x5f, - 0x8f, 0x9f, 0x4d, 0x14, 0xc8, 0x48, 0xd9, 0xc5, 0x0e, 0xe1, 0x1c, 0x5b, 0xa6, 0xcd, 0xe7, 0xb8, - 0xf0, 0x5c, 0x61, 0x07, 0x16, 0x8e, 0x65, 0x39, 0x9f, 0xf9, 0x0c, 0xd7, 0x32, 0x73, 0xad, 0xe4, - 0xcc, 0x35, 0x17, 0x4b, 0x75, 0x9f, 0x4f, 0x71, 0x98, 0x5a, 0xb0, 0x8d, 0x91, 0xb9, 0x82, 0x1f, - 0x50, 0xa8, 0x27, 0x1f, 0x5b, 0x5d, 0xec, 0xea, 0x45, 0xff, 0x4c, 0xd3, 0xa7, 0x1f, 0xc7, 0x9a, - 0xfe, 0x7e, 0x78, 0xa2, 0x9d, 0x0e, 0x86, 0xda, 0x49, 0xfb, 0x0e, 0x6a, 0xc9, 0x96, 0xe4, 0xe9, - 0x8f, 0xc7, 0xc7, 0xed, 0x02, 0x3e, 0x35, 0x1d, 0xc9, 0x78, 0x32, 0x3a, 0x7e, 0xab, 0x4d, 0xda, - 0x45, 0x24, 0xd2, 0x92, 0xcc, 0xa3, 0xe3, 0x41, 0xbb, 0x74, 0x30, 0x86, 0x5a, 0xfc, 0xcd, 0xb1, - 0x0b, 0xdb, 0x08, 0xa0, 0xbf, 0x9b, 0xf6, 0xa7, 0xe9, 0x24, 0x88, 0x97, 0x38, 0x26, 0xef, 0x87, - 0xc3, 0xc1, 0xf0, 0x0c, 0xd3, 0xec, 0x40, 0x3b, 0x31, 0x6b, 0xdf, 0x0f, 0xa6, 0x18, 0x5c, 0x3c, - 0xf8, 0xab, 0x00, 0xb5, 0xf8, 0x69, 0x44, 0xc8, 0xf1, 0xe8, 0x24, 0x07, 0x12, 0xcf, 0x26, 0x0e, - 0xed, 0xe2, 0xcd, 0xe4, 0xe3, 0x08, 0x11, 0x53, 0xe1, 0xe3, 0x89, 0x36, 0xee, 0x4f, 0x58, 0xaa, - 0x22, 0x8a, 0x33, 0xc9, 0x3a, 0x10, 0xa6, 0xc4, 0x98, 0x25, 0xf6, 0x88, 0x59, 0x19, 0xa7, 0x6d, - 0x2f, 0x31, 0xf7, 0xdf, 0x8c, 0x26, 0x48, 0x2d, 0x3a, 0xd6, 0x56, 0x32, 0xc9, 0x43, 0xe2, 0x95, - 0x74, 0x8e, 0x13, 0xed, 0x5c, 0x9b, 0x32, 0xb0, 0x6a, 0x3a, 0xc7, 0x59, 0x7f, 0xf2, 0x06, 0x5b, - 0xd8, 0xae, 0x1d, 0xfc, 0x5e, 0x84, 0x7a, 0x22, 0x76, 0x78, 0x43, 0xda, 0x07, 0x6d, 0x38, 0x5d, - 0xbf, 0xa1, 0x07, 0xb0, 0x2b, 0x79, 0x18, 0x52, 0xcc, 0xbf, 0x80, 0x1f, 0x53, 0x8f, 0xf3, 0x9d, - 0x11, 0x6b, 0xac, 0xbd, 0x07, 0xf7, 0x33, 0x31, 0x48, 0x85, 0xfb, 0x4a, 0x28, 0x17, 0xf7, 0x32, - 0x3e, 0x51, 0x4e, 0x19, 0x77, 0x67, 0x3f, 0xe3, 0x12, 0xdc, 0xf5, 0xe3, 0xd1, 0xf9, 0xb9, 0x76, - 0xcc, 0xa2, 0x94, 0x0c, 0xb8, 0xb8, 0xce, 0x49, 0xd8, 0x90, 0x34, 0x38, 0xf3, 0x09, 0xf0, 0x2a, - 0x6b, 0xb0, 0xe4, 0x0a, 0xa7, 0x6a, 0x70, 0x31, 0x0e, 0x29, 0xd7, 0xc8, 0x43, 0xe8, 0xae, 0xb9, - 0x27, 0xda, 0xc5, 0xe8, 0x03, 0x7a, 0xeb, 0x47, 0x3f, 0x95, 0xf1, 0x6b, 0x6b, 0x75, 0x69, 0x99, - 0xb3, 0xfe, 0x78, 0x40, 0xbe, 0x85, 0xaa, 0x10, 0x74, 0xb2, 0x9b, 0xbc, 0x76, 0x29, 0xd1, 0xef, - 0x75, 0xd7, 0x1d, 0xe1, 0xd6, 0xa8, 0x77, 0x48, 0x1f, 0x6a, 0x91, 0x30, 0x93, 0x24, 0x2e, 0xa3, - 0xf9, 0xbd, 0xbd, 0x1c, 0x4f, 0x0c, 0x71, 0x06, 0x90, 0x48, 0x31, 0xe9, 0x49, 0x0f, 0x48, 0x46, - 0xc0, 0x7b, 0x0f, 0x72, 0x7d, 0x32, 0x50, 0x22, 0xab, 0x12, 0xd0, 0x9a, 0x6e, 0x4b, 0x40, 0xeb, - 0x3a, 0x8c, 0x40, 0x17, 0xd0, 0x94, 0x65, 0x94, 0x3c, 0xcc, 0xe6, 0x95, 0x05, 0xb8, 0xf7, 0x68, - 0x83, 0x37, 0x86, 0x1b, 0x41, 0x53, 0x56, 0x48, 0x09, 0x2e, 0x47, 0x75, 0x25, 0xb8, 0x3c, 0x59, - 0x55, 0xef, 0xfc, 0xbf, 0x40, 0x5e, 0xf3, 0x4b, 0x63, 0xfa, 0x95, 0xbe, 0x34, 0x49, 0x4c, 0xd3, - 0x97, 0x26, 0x4b, 0x1d, 0x43, 0xb8, 0xac, 0xf0, 0x7f, 0x40, 0x5f, 0xfc, 0x1d, 0x00, 0x00, 0xff, - 0xff, 0x4d, 0xcd, 0xc6, 0xd5, 0x8d, 0x0e, 0x00, 0x00, + // 1492 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x57, 0xcf, 0x6e, 0xdb, 0xc6, + 0x13, 0x8e, 0xfe, 0x4b, 0x23, 0x45, 0x96, 0xd6, 0x4e, 0x2c, 0x2b, 0xff, 0x1c, 0xfe, 0x7e, 0x0d, + 0x52, 0x1f, 0xdc, 0xd6, 0x49, 0x73, 0x29, 0x50, 0x44, 0xb1, 0x69, 0x43, 0x8d, 0x2d, 0x09, 0x8a, + 0x62, 0x34, 0x27, 0x82, 0x92, 0x56, 0x0e, 0x61, 0x8a, 0x64, 0x49, 0xca, 0x89, 0x7b, 0xec, 0xa9, + 0xb7, 0x3e, 0x42, 0x1f, 0xa3, 0xc7, 0xde, 0xfb, 0x18, 0x05, 0xfa, 0x1e, 0x9d, 0x5d, 0x2e, 0xc9, + 0x25, 0x45, 0x1d, 0x7a, 0xb3, 0x66, 0x66, 0xbf, 0xf9, 0x66, 0x76, 0xe6, 0x5b, 0x1a, 0x6a, 0xba, + 0x63, 0x1c, 0x3a, 0xae, 0xed, 0xdb, 0xa4, 0x72, 0xf3, 0x8d, 0x6e, 0x3a, 0x1f, 0x75, 0xe5, 0x35, + 0xd4, 0xfb, 0x4b, 0xfd, 0x8a, 0x9e, 0xda, 0xee, 0x52, 0xf7, 0xc9, 0x3e, 0x14, 0xfd, 0x5b, 0x87, + 0x76, 0x72, 0xfb, 0xb9, 0xe7, 0xcd, 0x23, 0x72, 0x28, 0xc2, 0x0e, 0x79, 0xcc, 0x04, 0x3d, 0x64, + 0x0b, 0x2a, 0x37, 0xd4, 0xf5, 0x0c, 0xdb, 0xea, 0xe4, 0x31, 0xa8, 0xa6, 0xfc, 0x99, 0x83, 0x12, + 0x77, 0x93, 0x2f, 0xa1, 0x3e, 0xd5, 0x3d, 0xaa, 0x2d, 0x38, 0x16, 0xc7, 0xa8, 0x1f, 0xed, 0x24, + 0x31, 0x44, 0x1e, 0x80, 0xbc, 0x31, 0x0f, 0x00, 0x48, 0x03, 0x8a, 0x96, 0xbe, 0xa4, 0x9d, 0x02, + 0xff, 0x25, 0xe1, 0x17, 0xb9, 0xa1, 0x03, 0x2d, 0x63, 0xe9, 0xd8, 0xae, 0xaf, 0xf9, 0xc6, 0x92, + 0x7a, 0xbe, 0xbe, 0x74, 0x3a, 0x25, 0xf4, 0x14, 0x48, 0x0b, 0xaa, 0x4b, 0xdd, 0x32, 0x16, 0x68, + 0xec, 0x94, 0xd1, 0xd2, 0x60, 0x50, 0x9e, 0xf1, 0x33, 0xed, 0x54, 0xb8, 0xff, 0x19, 0xd4, 0x75, + 0xcb, 0xb2, 0x7d, 0xdd, 0x47, 0x34, 0xaf, 0x53, 0xdd, 0x2f, 0x20, 0x9f, 0x76, 0xc4, 0xe7, 0x2d, + 0xbd, 0xbd, 0xd4, 0xcd, 0x15, 0x55, 0x5e, 0x40, 0x65, 0x40, 0xfd, 0x4f, 0xb6, 0x7b, 0x1d, 0x71, + 0xc9, 0x85, 0xcc, 0x0c, 0xe7, 0xe6, 0x65, 0xcc, 0x13, 0x7f, 0xbd, 0x0a, 0x78, 0x2a, 0xbf, 0xe5, + 0xa0, 0xd0, 0x73, 0x9c, 0xd4, 0x89, 0x47, 0x50, 0x32, 0x58, 0x99, 0xfc, 0x48, 0xfd, 0xa8, 0x99, + 0x2c, 0x1e, 0xdb, 0x5b, 0xc2, 0x02, 0xfc, 0xa0, 0xd6, 0xa6, 0xc4, 0x05, 0x91, 0xde, 0x31, 0x07, + 0x69, 0x43, 0x8d, 0x7e, 0x36, 0x7c, 0x6d, 0x66, 0xcf, 0x29, 0x6f, 0x40, 0x3b, 0x5d, 0x46, 0x69, + 0x53, 0x19, 0xbf, 0xe6, 0xa1, 0x30, 0xb2, 0xe7, 0xa2, 0xb7, 0x01, 0x9f, 0x3a, 0x14, 0x1c, 0xd1, + 0xe8, 0xf6, 0xe6, 0xec, 0x78, 0x2a, 0xc8, 0xde, 0x85, 0xa2, 0xee, 0x38, 0x1e, 0x26, 0x66, 0x39, + 0x1a, 0x32, 0x3d, 0xa2, 0x40, 0xd5, 0x0a, 0xba, 0x14, 0x72, 0x68, 0x45, 0xfe, 0xb0, 0x7d, 0xeb, + 0x37, 0x92, 0x22, 0x5f, 0xd9, 0x40, 0x9e, 0x34, 0xa1, 0x3c, 0xbb, 0x72, 0xed, 0x95, 0x83, 0xd7, + 0xc4, 0x88, 0x63, 0x15, 0x33, 0x97, 0x22, 0xa7, 0xb9, 0x86, 0xa3, 0x54, 0xe3, 0xf7, 0x89, 0x36, + 0xe4, 0xef, 0x0a, 0x1b, 0x70, 0xdb, 0x0e, 0x34, 0xae, 0x66, 0xda, 0x52, 0x77, 0xaf, 0x03, 0x6b, + 0x9d, 0x59, 0x95, 0x67, 0x50, 0x8d, 0x90, 0xb1, 0x05, 0xf8, 0xb7, 0xe8, 0xc7, 0x5d, 0x28, 0xdd, + 0x30, 0xab, 0x98, 0xdd, 0xbf, 0x72, 0x50, 0xc3, 0xe2, 0x4f, 0x0d, 0xd3, 0xa7, 0x2e, 0x8b, 0x34, + 0xe6, 0x1e, 0x46, 0x16, 0x30, 0xf2, 0x29, 0x94, 0x79, 0xb3, 0x3c, 0x0c, 0x2d, 0x64, 0x77, 0xab, + 0xcd, 0x36, 0xca, 0xd1, 0xd8, 0xf5, 0x7b, 0xd8, 0x53, 0x76, 0x0a, 0x4d, 0xfc, 0xfe, 0x35, 0x06, + 0x54, 0xe4, 0xa6, 0x7b, 0x70, 0x57, 0xf4, 0x4d, 0x44, 0x96, 0xb8, 0x39, 0xd5, 0x98, 0xf2, 0xa6, + 0xc6, 0xe0, 0x3e, 0x04, 0x8d, 0x09, 0x9a, 0x57, 0x23, 0xbb, 0xb0, 0xe5, 0xd8, 0x73, 0xcd, 0x5b, + 0x4d, 0xb5, 0xd0, 0xc1, 0x26, 0xbb, 0xa6, 0xfc, 0x9d, 0x0b, 0x77, 0x39, 0xa3, 0x1c, 0xbc, 0x19, + 0xc7, 0xa5, 0x0b, 0xe3, 0xb3, 0x28, 0x88, 0x77, 0x98, 0x6f, 0xab, 0x4c, 0x1f, 0xa3, 0xae, 0xe9, + 0x2d, 0x72, 0x8d, 0xd8, 0x63, 0x1b, 0x4c, 0x7d, 0x4a, 0xcd, 0xcd, 0x73, 0x47, 0xee, 0x43, 0x33, + 0x58, 0x50, 0x76, 0x03, 0x0b, 0xcc, 0xcc, 0xaf, 0xbe, 0xc0, 0x88, 0x46, 0xf6, 0x29, 0x45, 0x51, + 0xf8, 0x8f, 0x7b, 0xc9, 0x18, 0x2e, 0x56, 0xa6, 0x29, 0x18, 0xd6, 0x78, 0x91, 0xbf, 0x63, 0x91, + 0x67, 0xa6, 0x3d, 0xd5, 0xcd, 0x53, 0x53, 0xbf, 0xf2, 0x58, 0x91, 0x73, 0xc3, 0x15, 0xb7, 0xbb, + 0x07, 0x6d, 0xef, 0xd6, 0xf3, 0xe9, 0x12, 0xd7, 0xc7, 0x5a, 0x18, 0x57, 0x1a, 0x73, 0xe5, 0x43, + 0x15, 0x31, 0xed, 0x99, 0x6e, 0xca, 0x9e, 0x40, 0x70, 0x90, 0xe6, 0xca, 0xa3, 0xae, 0xec, 0x08, + 0x84, 0x87, 0xd5, 0x65, 0x79, 0x74, 0xb6, 0x72, 0x51, 0xd2, 0x58, 0x32, 0x2e, 0x3b, 0x6c, 0xc7, + 0xef, 0xf9, 0xee, 0xca, 0xf3, 0x35, 0x6c, 0x95, 0xa7, 0x2d, 0x5c, 0x7b, 0xa9, 0x7d, 0xf4, 0x7d, + 0xc7, 0xe3, 0x65, 0x57, 0x15, 0x17, 0x8a, 0x7d, 0x6b, 0x61, 0x93, 0x6d, 0xa8, 0xbb, 0xd7, 0xbe, + 0x16, 0x8a, 0x59, 0xc0, 0x10, 0xc7, 0x15, 0x47, 0x66, 0xa6, 0x25, 0x24, 0x94, 0x85, 0xa2, 0x34, + 0x47, 0xc6, 0x80, 0xd7, 0x01, 0x4e, 0x36, 0x2f, 0x54, 0x24, 0x2f, 0xa6, 0xe4, 0x54, 0xea, 0x02, + 0xe6, 0x2c, 0xa9, 0x37, 0xd4, 0xda, 0xac, 0xdf, 0xdc, 0xcb, 0xf5, 0x3b, 0xa5, 0xbc, 0x8c, 0xbe, + 0x48, 0x88, 0xbf, 0x98, 0xc2, 0xf2, 0x44, 0x05, 0xf2, 0x04, 0x8a, 0x73, 0xdd, 0xd7, 0x37, 0xcb, + 0x8d, 0x0f, 0x75, 0x8e, 0x2a, 0xa6, 0xed, 0x29, 0x94, 0x58, 0xe6, 0x60, 0xde, 0xb2, 0x53, 0x8b, + 0x81, 0x0c, 0xc6, 0x0f, 0x37, 0x51, 0x9e, 0x3c, 0xb6, 0xdb, 0x86, 0x35, 0xa3, 0x9a, 0x44, 0x01, + 0x6d, 0x2b, 0xcb, 0x37, 0xcc, 0xc0, 0xc6, 0x35, 0x5f, 0x69, 0x41, 0xf3, 0x8c, 0xfa, 0xac, 0xc1, + 0x63, 0xfa, 0xd3, 0x0a, 0x75, 0x46, 0x39, 0x84, 0xad, 0xc8, 0xe2, 0x39, 0x38, 0x50, 0x94, 0x3c, + 0x40, 0xa5, 0xc6, 0xdf, 0xe2, 0x05, 0xba, 0x1b, 0x8b, 0x30, 0x1a, 0x95, 0x53, 0xd8, 0x3a, 0x37, + 0x3c, 0x1f, 0xb7, 0xd8, 0x13, 0x10, 0xe4, 0x7f, 0x50, 0x59, 0xf0, 0x2a, 0x02, 0xf6, 0x75, 0x89, + 0x7d, 0xac, 0x0e, 0xa8, 0x50, 0x73, 0xea, 0xeb, 0x86, 0xc9, 0x9b, 0x57, 0xc5, 0xbc, 0xad, 0x18, + 0x47, 0x24, 0x46, 0xfd, 0xc4, 0xdd, 0x0c, 0x51, 0x1a, 0x32, 0x8a, 0xf2, 0x04, 0xda, 0x7d, 0xcb, + 0x73, 0xe8, 0x8c, 0x1d, 0x09, 0x33, 0x4b, 0x5a, 0xad, 0x7c, 0x05, 0x44, 0x0e, 0x10, 0x90, 0x7b, + 0xa8, 0xe0, 0xf6, 0x5c, 0x94, 0x92, 0x44, 0xfc, 0x01, 0xda, 0x8c, 0x01, 0xdf, 0xf9, 0xa8, 0x96, + 0x2f, 0xd2, 0xb5, 0xa4, 0x1f, 0xe0, 0xec, 0x6a, 0x5e, 0x02, 0x91, 0xb1, 0x44, 0xf2, 0xc7, 0x50, + 0xe6, 0x72, 0x16, 0x62, 0xa5, 0xde, 0x33, 0xe5, 0x29, 0x6c, 0x0b, 0xca, 0xfc, 0x77, 0x56, 0x55, + 0xdf, 0xc2, 0x4e, 0x32, 0x44, 0x40, 0x47, 0x2f, 0x65, 0x2e, 0xeb, 0xa5, 0x54, 0xbe, 0x83, 0x6d, + 0xc6, 0x87, 0x5a, 0x7c, 0x7c, 0xa2, 0xea, 0xfe, 0x0f, 0xe5, 0xa0, 0xba, 0xb5, 0xaf, 0x0b, 0x69, + 0x16, 0x95, 0x57, 0xb0, 0x93, 0x3c, 0x1c, 0x97, 0x43, 0xb9, 0x65, 0xad, 0x1c, 0x1e, 0xa8, 0xdc, + 0xf2, 0xe1, 0x3a, 0xb7, 0xaf, 0xa2, 0x7c, 0xd8, 0x26, 0x26, 0xb6, 0xd1, 0x7b, 0x8a, 0x02, 0x19, + 0x4a, 0xbe, 0xd8, 0x21, 0x9c, 0x63, 0xd3, 0xb0, 0xf8, 0x1c, 0xe7, 0x9e, 0x97, 0xd8, 0x81, 0x85, + 0x6d, 0x9a, 0xf6, 0x27, 0x3e, 0xc3, 0xd5, 0xd4, 0x5c, 0x97, 0x32, 0xe6, 0x9a, 0x8b, 0xa5, 0xb2, + 0xcf, 0xa7, 0x38, 0x48, 0x2d, 0xd8, 0x46, 0xc8, 0x5c, 0xc1, 0x0f, 0x28, 0xd4, 0xe2, 0xaf, 0xb0, + 0x0e, 0x76, 0xf5, 0xa2, 0x77, 0xa6, 0x6a, 0x93, 0x0f, 0x23, 0x55, 0x7b, 0x3f, 0x38, 0x51, 0x4f, + 0xfb, 0x03, 0xf5, 0xa4, 0x75, 0x07, 0xb5, 0x64, 0x4b, 0xf2, 0xf4, 0x46, 0xa3, 0xe3, 0x56, 0x0e, + 0xdf, 0xa0, 0xb6, 0x64, 0x3c, 0x19, 0x1e, 0xbf, 0x55, 0xc7, 0xad, 0x3c, 0x12, 0x69, 0x4a, 0xe6, + 0xe1, 0x71, 0xbf, 0x55, 0x38, 0x18, 0x41, 0x35, 0xfa, 0x18, 0xd9, 0x85, 0x6d, 0x04, 0xd0, 0xde, + 0x4d, 0x7a, 0x93, 0x64, 0x12, 0xc4, 0x8b, 0x1d, 0xe3, 0xf7, 0x83, 0x41, 0x7f, 0x70, 0x86, 0x69, + 0x76, 0xa0, 0x15, 0x9b, 0xd5, 0x1f, 0xfb, 0x13, 0x0c, 0xce, 0x1f, 0xfc, 0x93, 0x83, 0x6a, 0xf4, + 0x66, 0x22, 0xe4, 0x68, 0x78, 0x92, 0x01, 0x89, 0x67, 0x63, 0x87, 0x7a, 0xf1, 0x66, 0xfc, 0x61, + 0x88, 0x88, 0x89, 0xf0, 0xd1, 0x58, 0x1d, 0xf5, 0xc6, 0x2c, 0x55, 0x1e, 0xc5, 0x99, 0xa4, 0x1d, + 0x08, 0x53, 0x60, 0xcc, 0x62, 0x7b, 0xc8, 0xac, 0x88, 0xd3, 0xb6, 0x17, 0x9b, 0x7b, 0x6f, 0x86, + 0x63, 0xa4, 0x16, 0x1e, 0x6b, 0x95, 0x52, 0xc9, 0x03, 0xe2, 0xe5, 0x64, 0x8e, 0x13, 0xf5, 0x5c, + 0x9d, 0x30, 0xb0, 0x4a, 0x32, 0xc7, 0x59, 0x6f, 0xfc, 0x06, 0x5b, 0xd8, 0xaa, 0x1e, 0xfc, 0x91, + 0x87, 0x5a, 0x2c, 0x76, 0x78, 0x43, 0xea, 0xa5, 0x3a, 0x98, 0xac, 0xdf, 0xd0, 0x03, 0xd8, 0x95, + 0x3c, 0x0c, 0x29, 0xe2, 0x9f, 0xc3, 0xaf, 0xac, 0xc7, 0xd9, 0xce, 0x90, 0x35, 0xd6, 0xde, 0x85, + 0xfb, 0xa9, 0x18, 0xa4, 0xc2, 0x7d, 0x05, 0x94, 0x8b, 0x7b, 0x29, 0x9f, 0x28, 0xa7, 0x88, 0xbb, + 0xb3, 0x9f, 0x72, 0x09, 0xee, 0xda, 0xf1, 0xf0, 0xfc, 0x5c, 0x3d, 0x66, 0x51, 0xa5, 0x14, 0xb8, + 0xb8, 0xce, 0x71, 0xd0, 0x90, 0x24, 0x38, 0xf3, 0x09, 0xf0, 0x0a, 0x6b, 0xb0, 0xe4, 0x0a, 0xa6, + 0xaa, 0x7f, 0x31, 0x0a, 0x28, 0x57, 0xc9, 0x43, 0xe8, 0xac, 0xb9, 0xc7, 0xea, 0xc5, 0xf0, 0x12, + 0xbd, 0xb5, 0xa3, 0x5f, 0x8a, 0xf8, 0x19, 0xb6, 0x9a, 0x9a, 0xc6, 0xac, 0x37, 0xea, 0x93, 0xef, + 0xa1, 0x22, 0x04, 0x9d, 0xec, 0xc6, 0xaf, 0x5d, 0x42, 0xf4, 0xbb, 0x9d, 0x75, 0x47, 0xb0, 0x35, + 0xca, 0x1d, 0xd2, 0x83, 0x6a, 0x28, 0xcc, 0x24, 0x8e, 0x4b, 0x69, 0x7e, 0x77, 0x2f, 0xc3, 0x13, + 0x41, 0x9c, 0x01, 0xc4, 0x52, 0x4c, 0xba, 0xd2, 0x03, 0x92, 0x12, 0xf0, 0xee, 0x83, 0x4c, 0x9f, + 0x0c, 0x14, 0xcb, 0xaa, 0x04, 0xb4, 0xa6, 0xdb, 0x12, 0xd0, 0xba, 0x0e, 0x23, 0xd0, 0x05, 0x34, + 0x64, 0x19, 0x25, 0x0f, 0xd3, 0x79, 0x65, 0x01, 0xee, 0x3e, 0xda, 0xe0, 0x8d, 0xe0, 0x86, 0xd0, + 0x90, 0x15, 0x52, 0x82, 0xcb, 0x50, 0x5d, 0x09, 0x2e, 0x4b, 0x56, 0x95, 0x3b, 0x5f, 0xe7, 0xc8, + 0x6b, 0x7e, 0x69, 0x4c, 0xbf, 0x92, 0x97, 0x26, 0x89, 0x69, 0xf2, 0xd2, 0x64, 0xa9, 0x63, 0x08, + 0xd3, 0x32, 0xff, 0xcf, 0xf4, 0xc5, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x4a, 0x23, 0xef, 0x15, + 0xa6, 0x0e, 0x00, 0x00, } diff --git a/api/v1alpha/api.proto b/api/v1alpha/api.proto index 51aa8e6865..80b870a3f3 100644 --- a/api/v1alpha/api.proto +++ b/api/v1alpha/api.proto @@ -217,6 +217,10 @@ message PodFilter { // If not empty, the pods whose cgroup are listed will be returned. repeated string cgroups = 7; + + // If not empty, the pods whose these cgroup belong to will be returned. + // i.e. the pod's cgroup is a prefix of the specified cgroup + repeated string pod_sub_cgroups = 8; } // ImageFilter defines the condition that the returned images need to satisfy in ListImages(). diff --git a/rkt/api_service.go b/rkt/api_service.go index 532d3254f1..aa453503ba 100644 --- a/rkt/api_service.go +++ b/rkt/api_service.go @@ -199,6 +199,23 @@ func satisfiesPodFilter(pod v1alpha.Pod, manifest schema.PodManifest, filter v1a } } + // Filter if pod's cgroup is a prefix of the passed in cgroup + if len(filter.PodSubCgroups) > 0 { + matched := false + if pod.Cgroup != "" { + for _, cgroup := range filter.PodSubCgroups { + if strings.HasPrefix(cgroup, pod.Cgroup) { + matched = true + break + } + } + } + + if !matched { + return false + } + } + return true } From 146dfc69a39a61d2f9e52761904b3d936c79363e Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Mon, 2 May 2016 13:04:36 +0300 Subject: [PATCH 0202/1304] rkt: test calculateDataDir Add tests for calculateDataDir. Fixes #2422 Fixes #2550 Fixes #2552 --- rkt/rkt_test.go | 92 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 rkt/rkt_test.go diff --git a/rkt/rkt_test.go b/rkt/rkt_test.go new file mode 100644 index 0000000000..cf3bda3f78 --- /dev/null +++ b/rkt/rkt_test.go @@ -0,0 +1,92 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "fmt" + "io/ioutil" + "os" + "testing" + + "github.com/coreos/rkt/pkg/log" +) + +func TestCalculateDataDir(t *testing.T) { + // Used in calculateDataDir. + // TODO(tmrts): Restructure this pkg, specifically by using dependency + // injection, to eliminate these work-arounds. + stderr = log.New(os.Stderr, "TestCalculateDataDir", globalFlags.Debug) + + _, err := getConfig() + if err != nil { + panic(fmt.Errorf("getConfig() got error %q", err)) + } + + if cachedConfig == nil { + panic(fmt.Errorf("getConfig() should've set `cachedConfig`")) + } + + dirFlag := cmdRkt.PersistentFlags().Lookup("dir") + dirFlag.Changed = false + defDirFlagVal := dirFlag.Value.String() + defCfgDataDir := cachedConfig.Paths.DataDir + + resetConfigState := func() { + cmdRkt.PersistentFlags().Set("dir", defDirFlagVal) + dirFlag.Changed = false + + cachedConfig.Paths.DataDir = defCfgDataDir + } + + tmpDir, err := ioutil.TempDir("", "") + if err != nil { + panic(fmt.Errorf("ioutil.TempDir(%q, %q) got error %q", "", "", err)) + } + defer os.Remove(tmpDir) + + // TODO(tmrts): Write a utility function that generates unused random paths. + // Example signature would be fileutils.GenerateUniquePath(prefix string) (string, error). + nonExistantDir, err := ioutil.TempDir("", "non-existant-") + if err != nil { + panic(fmt.Errorf("ioutil.TempDir(%q, %q) got error %q", "", "", err)) + } + if err := os.Remove(nonExistantDir); err != nil { + panic(fmt.Errorf("os.Remove(%q) got error %q", nonExistantDir, err)) + } + + testCases := []struct { + flagDataDir string + configDataDir string + out string + }{ + {"", "", defaultDataDir}, + {"", tmpDir, tmpDir}, + {tmpDir, "", tmpDir}, + {nonExistantDir, "", nonExistantDir}, + {"", nonExistantDir, nonExistantDir}, + } + + for _, tc := range testCases { + cmdRkt.PersistentFlags().Set("dir", tc.flagDataDir) + + cachedConfig.Paths.DataDir = tc.configDataDir + + if dataDir := calculateDataDir(); dataDir != tc.out { + t.Errorf("main.calculateDataDir() with setup %q, expected %q, got %q", tc, tc.out, dataDir) + } + + resetConfigState() + } +} From bc1ce35b00e2644bb4162536a43ed4e359e3aeaf Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Fri, 29 Apr 2016 15:07:50 +0300 Subject: [PATCH 0203/1304] pkg/fileutil: test IsExecutable utility function Adds tests for fileutil.IsExecutable function. Fixes #2509 --- pkg/fileutil/fileutil_test.go | 68 ++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/pkg/fileutil/fileutil_test.go b/pkg/fileutil/fileutil_test.go index c5dd60d0bf..08e386734d 100644 --- a/pkg/fileutil/fileutil_test.go +++ b/pkg/fileutil/fileutil_test.go @@ -70,7 +70,7 @@ func TestCopyTree(t *testing.T) { src := filepath.Join(td, "src") dst := filepath.Join(td, "dst") if err := os.MkdirAll(filepath.Join(td, "src"), 0755); err != nil { - t.Fatal(err) + panic(err) } tr := []tree{ @@ -117,3 +117,69 @@ func TestCopyTree(t *testing.T) { } checkTree(t, dst, tr) } + +func TestFileIsExecutable(t *testing.T) { + tempDir, err := ioutil.TempDir("", tstprefix) + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(tempDir) + + testCases := []struct { + Permission os.FileMode + IsExecutable bool + }{ + {0200, false}, + {0400, false}, + {0600, false}, + {0100, true}, + {0300, true}, + {0500, true}, + {0700, true}, + + {0002, false}, + {0004, false}, + {0006, false}, + {0001, true}, + {0003, true}, + {0005, true}, + {0007, true}, + + {0020, false}, + {0040, false}, + {0060, false}, + {0010, true}, + {0030, true}, + {0050, true}, + {0070, true}, + + {0000, false}, + {0222, false}, + {0444, false}, + {0666, false}, + + {0146, true}, + {0661, true}, + } + + for _, tc := range testCases { + f, err := ioutil.TempFile(tempDir, "") + if err != nil { + panic(err) + } + + if err := f.Chmod(tc.Permission); err != nil { + panic(err) + } + + if err := f.Close(); err != nil { + panic(err) + } + + path := f.Name() + + if tc.IsExecutable != IsExecutable(path) { + t.Errorf("fileutil.IsExecutable(%q) with permissions %q, expected %v", path, tc.Permission, tc.IsExecutable) + } + } +} From fe806b242799377916867060dabfc7fd4328aff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chris=20K=C3=BChl?= Date: Mon, 2 May 2016 16:09:00 +0200 Subject: [PATCH 0204/1304] docs: remove leftover enter subcmd section --- Documentation/subcommands/enter.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Documentation/subcommands/enter.md b/Documentation/subcommands/enter.md index 1bedb20512..758ade5782 100644 --- a/Documentation/subcommands/enter.md +++ b/Documentation/subcommands/enter.md @@ -16,10 +16,6 @@ bin data entrypoint.sh home lib64 mnt proc run selinux sys usr boot dev etc lib media opt root sbin srv tmp var ``` -## Run a Pod in the Background - -Work in progress. Please contribute! - ## Options | Flag | Default | Options | Description | From c7bfd571b72b6f758297a76b7b1e9991e5883f40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Mon, 2 May 2016 15:41:59 +0200 Subject: [PATCH 0205/1304] CHANGELOG: add v1.5.1 --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6041b43dec..e833732529 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +## v1.5.1 + +This release is a minor bug fix release. + +#### Bug fixes + +- rkt: fix bug where rkt errored out if the default data directory didn't exist [#2557](https://github.com/coreos/rkt/pull/2557). +- kvm: fix docker volume semantics ([#2558](https://github.com/coreos/rkt/pull/2558)). When a Docker image exposes a mount point that is not mounted by a host volume, Docker volume semantics expect the files in the directory to be available to the application. This was not working properly in the kvm flavor and it's fixed now. +- kvm: fix net long names ([#2543](https://github.com/coreos/rkt/pull/2543)). Handle network names that are longer than the maximum allowed by iptables in the kvm flavor. + +#### Other changes + +- minor tests and clean-ups (, [#2551](https://github.com/coreos/rkt/pull/2551)). + ## v1.5.0 This release switches to pure systemd for running apps within a pod. This lays the foundation to implement enhanced isolation capabilities. For example, starting with v1.5.0, apps are started with more restricted capabilities. User namespace support and the KVM stage1 are not experimental anymore. Resource usage can be benchmarked using the new rkt-monitor tool. From ba45abd0afc0afaae16f3fdd5e6894461a42cbeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Mon, 2 May 2016 15:43:01 +0200 Subject: [PATCH 0206/1304] version: bump to v1.5.1 --- Documentation/getting-started-ubuntu.md | 6 +++--- Documentation/running-fly-stage1.md | 4 ++-- Documentation/running-lkvm-stage1.md | 4 ++-- Documentation/subcommands/prepare.md | 2 +- Documentation/subcommands/version.md | 2 +- Documentation/trying-out-rkt.md | 6 +++--- configure.ac | 2 +- scripts/acbuild-rkt-builder.sh | 2 +- scripts/build-rir.sh | 2 +- tests/empty-image/manifest | 2 +- tests/image/manifest | 2 +- tests/rkt_exec_test.go | 2 +- tests/rkt_image_cat_manifest_test.go | 2 +- tests/rkt_image_export_test.go | 2 +- tests/rkt_image_render_test.go | 2 +- tests/rkt_os_arch_test.go | 2 +- 16 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Documentation/getting-started-ubuntu.md b/Documentation/getting-started-ubuntu.md index 36506da88e..ecf6d7090d 100644 --- a/Documentation/getting-started-ubuntu.md +++ b/Documentation/getting-started-ubuntu.md @@ -15,9 +15,9 @@ vagrant up --provider virtualbox vagrant ssh sudo -s -wget https://github.com/coreos/rkt/releases/download/v1.5.0/rkt-v1.5.0.tar.gz -tar xzvf rkt-v1.5.0.tar.gz -cd rkt-v1.5.0 +wget https://github.com/coreos/rkt/releases/download/v1.5.1/rkt-v1.5.1.tar.gz +tar xzvf rkt-v1.5.1.tar.gz +cd rkt-v1.5.1 ./rkt help ``` diff --git a/Documentation/running-fly-stage1.md b/Documentation/running-fly-stage1.md index 978adec66e..1ff6303ed2 100644 --- a/Documentation/running-fly-stage1.md +++ b/Documentation/running-fly-stage1.md @@ -60,14 +60,14 @@ $ ./autogen.sh && ./configure --with-stage1-flavors=fly && make ``` For more details about configure parameters, see the [configure script parameters documentation](build-configure.md). -This will build the rkt binary and the stage1-fly.aci in `build-rkt-1.5.0+git/bin/`. +This will build the rkt binary and the stage1-fly.aci in `build-rkt-1.5.1+git/bin/`. ### Selecting stage1 at runtime Here is a quick example of how to use a container with the official fly stage1: ``` -# rkt run --stage1-name=coreos.com/rkt/stage1-fly:1.5.0 coreos.com/etcd:v2.2.5 +# rkt run --stage1-name=coreos.com/rkt/stage1-fly:1.5.1 coreos.com/etcd:v2.2.5 ``` If the image is not in the store, `--stage1-name` will perform discovery and fetch the image. diff --git a/Documentation/running-lkvm-stage1.md b/Documentation/running-lkvm-stage1.md index 839d14af73..c80c8bf657 100644 --- a/Documentation/running-lkvm-stage1.md +++ b/Documentation/running-lkvm-stage1.md @@ -13,7 +13,7 @@ $ ./autogen.sh && ./configure --with-stage1-flavors=kvm && make ``` For more details about configure parameters, see [configure script parameters documentation](build-configure.md). -This will build the rkt binary and the LKVM stage1-kvm.aci in `build-rkt-1.5.0+git/bin/`. +This will build the rkt binary and the LKVM stage1-kvm.aci in `build-rkt-1.5.1+git/bin/`. Provided you have hardware virtualization support and the [kernel KVM module](http://www.linux-kvm.org/page/Getting_the_kvm_kernel_modules) loaded (refer to your distribution for instructions), you can then run an image like you would normally do with rkt: @@ -84,7 +84,7 @@ If you want to run software that requires hypervisor isolation along with truste For example, to use the official lkvm stage1: ``` -# rkt run --stage1-name=coreos.com/rkt/stage1-kvm:1.5.0 coreos.com/etcd:v2.0.9 +# rkt run --stage1-name=coreos.com/rkt/stage1-kvm:1.5.1 coreos.com/etcd:v2.0.9 ... ``` diff --git a/Documentation/subcommands/prepare.md b/Documentation/subcommands/prepare.md index 8d0ea0c609..9ab207a796 100644 --- a/Documentation/subcommands/prepare.md +++ b/Documentation/subcommands/prepare.md @@ -14,7 +14,7 @@ Therefore, the supported arguments are mostly the same as in `run` except runtim ``` # rkt prepare coreos.com/etcd:v2.0.10 rkt prepare coreos.com/etcd:v2.0.10 -rkt: using image from local store for image name coreos.com/rkt/stage1-coreos:1.5.0 +rkt: using image from local store for image name coreos.com/rkt/stage1-coreos:1.5.1 rkt: searching for app image coreos.com/etcd:v2.0.10 rkt: remote fetching from url https://github.com/coreos/etcd/releases/download/v2.0.10/etcd-v2.0.10-linux-amd64.aci prefix: "coreos.com/etcd" diff --git a/Documentation/subcommands/version.md b/Documentation/subcommands/version.md index 97257bfdf3..1ad445e790 100644 --- a/Documentation/subcommands/version.md +++ b/Documentation/subcommands/version.md @@ -6,7 +6,7 @@ This command prints the rkt version, the appc version rkt is built against, and ``` $ rkt version -rkt Version: 1.5.0 +rkt Version: 1.5.1 appc Version: 0.7.4 Go Version: go1.5.3 Go OS/Arch: linux/amd64 diff --git a/Documentation/trying-out-rkt.md b/Documentation/trying-out-rkt.md index 57b3361122..f9e48b0b71 100644 --- a/Documentation/trying-out-rkt.md +++ b/Documentation/trying-out-rkt.md @@ -10,9 +10,9 @@ rkt consists of a single CLI tool, and is currently supported on amd64 Linux. A To download the rkt binary, simply grab the latest release directly from GitHub: ``` -wget https://github.com/coreos/rkt/releases/download/v1.5.0/rkt-v1.5.0.tar.gz -tar xzvf rkt-v1.5.0.tar.gz -cd rkt-v1.5.0 +wget https://github.com/coreos/rkt/releases/download/v1.5.1/rkt-v1.5.1.tar.gz +tar xzvf rkt-v1.5.1.tar.gz +cd rkt-v1.5.1 ./rkt help ``` diff --git a/configure.ac b/configure.ac index af0ff4c83e..ab1b35ba5d 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.63]) -AC_INIT([rkt], [1.5.0+git], [https://github.com/coreos/rkt/issues]) +AC_INIT([rkt], [1.5.1], [https://github.com/coreos/rkt/issues]) AC_DEFUN([RKT_CHECK_PROG], [AS_VAR_IF([$1], [], diff --git a/scripts/acbuild-rkt-builder.sh b/scripts/acbuild-rkt-builder.sh index 1cbe97ef0d..889c5f83c4 100755 --- a/scripts/acbuild-rkt-builder.sh +++ b/scripts/acbuild-rkt-builder.sh @@ -17,7 +17,7 @@ fi MODIFY=${MODIFY:-""} FLAGS=${FLAGS:-""} IMG_NAME="coreos.com/rkt/builder" -IMG_VERSION=${VERSION:-"v1.5.0+git"} +IMG_VERSION=${VERSION:-"v1.5.1"} ACI_FILE=rkt-builder.aci BUILDDIR=/opt/build-rkt SRC_DIR=/opt/rkt diff --git a/scripts/build-rir.sh b/scripts/build-rir.sh index d2632ce380..95268f2b46 100755 --- a/scripts/build-rir.sh +++ b/scripts/build-rir.sh @@ -4,7 +4,7 @@ set -xe SRC_DIR="${SRC_DIR:-$PWD}" BUILDDIR="${BUILDDIR:-$PWD/build-rir}" -RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.5.0+git}" +RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.5.1}" mkdir -p $BUILDDIR diff --git a/tests/empty-image/manifest b/tests/empty-image/manifest index 39f923d290..d423df3965 100644 --- a/tests/empty-image/manifest +++ b/tests/empty-image/manifest @@ -5,7 +5,7 @@ "labels": [ { "name": "version", - "value": "1.5.0" + "value": "1.5.1" }, { "name": "arch", diff --git a/tests/image/manifest b/tests/image/manifest index 14be72f2c8..46b767e09e 100644 --- a/tests/image/manifest +++ b/tests/image/manifest @@ -5,7 +5,7 @@ "labels": [ { "name": "version", - "value": "1.5.0" + "value": "1.5.1" }, { "name": "arch", diff --git a/tests/rkt_exec_test.go b/tests/rkt_exec_test.go index 5c1a5bc11b..51c8702ce4 100644 --- a/tests/rkt_exec_test.go +++ b/tests/rkt_exec_test.go @@ -26,7 +26,7 @@ import ( ) const ( - noappManifestStr = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"coreos.com/rkt-inspect","labels":[{"name":"version","value":"1.5.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}]}` + noappManifestStr = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"coreos.com/rkt-inspect","labels":[{"name":"version","value":"1.5.1"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}]}` ) func TestRunOverrideExec(t *testing.T) { diff --git a/tests/rkt_image_cat_manifest_test.go b/tests/rkt_image_cat_manifest_test.go index 9908721e5c..f927ea4346 100644 --- a/tests/rkt_image_cat_manifest_test.go +++ b/tests/rkt_image_cat_manifest_test.go @@ -29,7 +29,7 @@ import ( const ( // The expected image manifest of the 'rkt-inspect-image-cat-manifest.aci'. - manifestTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.5.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.5.1"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageCatManifest tests 'rkt image cat-manifest', it will: diff --git a/tests/rkt_image_export_test.go b/tests/rkt_image_export_test.go index 2b36d5e04a..219029118a 100644 --- a/tests/rkt_image_export_test.go +++ b/tests/rkt_image_export_test.go @@ -28,7 +28,7 @@ import ( ) const ( - manifestExportTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.5.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestExportTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.5.1"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageExport tests 'rkt image export', it will import some existing diff --git a/tests/rkt_image_render_test.go b/tests/rkt_image_render_test.go index 0510a9bab7..ab34c6254c 100644 --- a/tests/rkt_image_render_test.go +++ b/tests/rkt_image_render_test.go @@ -28,7 +28,7 @@ import ( ) const ( - manifestRenderTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.5.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"dependencies":[{"imageName":"coreos.com/rkt-inspect"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestRenderTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.5.1"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"dependencies":[{"imageName":"coreos.com/rkt-inspect"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageRender tests 'rkt image render', it will import some existing empty diff --git a/tests/rkt_os_arch_test.go b/tests/rkt_os_arch_test.go index adc9b91d30..081196fccd 100644 --- a/tests/rkt_os_arch_test.go +++ b/tests/rkt_os_arch_test.go @@ -27,7 +27,7 @@ import ( ) const ( - manifestOSArchTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.5.0"}ARCH_OS],"app":{"exec":["/inspect", "--print-msg=HelloWorld"],"user":"0","group":"0","workingDirectory":"/"}}` + manifestOSArchTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.5.1"}ARCH_OS],"app":{"exec":["/inspect", "--print-msg=HelloWorld"],"user":"0","group":"0","workingDirectory":"/"}}` ) type osArchTest struct { From 1d48c8fe388d95f8c10aaa09c4d9cf391a1d1a08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Mon, 2 May 2016 15:43:01 +0200 Subject: [PATCH 0207/1304] version: bump to v1.5.1+git --- configure.ac | 2 +- scripts/acbuild-rkt-builder.sh | 2 +- scripts/build-rir.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index ab1b35ba5d..0f301fc0ba 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.63]) -AC_INIT([rkt], [1.5.1], [https://github.com/coreos/rkt/issues]) +AC_INIT([rkt], [1.5.1+git], [https://github.com/coreos/rkt/issues]) AC_DEFUN([RKT_CHECK_PROG], [AS_VAR_IF([$1], [], diff --git a/scripts/acbuild-rkt-builder.sh b/scripts/acbuild-rkt-builder.sh index 889c5f83c4..72e6023dbb 100755 --- a/scripts/acbuild-rkt-builder.sh +++ b/scripts/acbuild-rkt-builder.sh @@ -17,7 +17,7 @@ fi MODIFY=${MODIFY:-""} FLAGS=${FLAGS:-""} IMG_NAME="coreos.com/rkt/builder" -IMG_VERSION=${VERSION:-"v1.5.1"} +IMG_VERSION=${VERSION:-"v1.5.1+git"} ACI_FILE=rkt-builder.aci BUILDDIR=/opt/build-rkt SRC_DIR=/opt/rkt diff --git a/scripts/build-rir.sh b/scripts/build-rir.sh index 95268f2b46..d1e8dfb55f 100755 --- a/scripts/build-rir.sh +++ b/scripts/build-rir.sh @@ -4,7 +4,7 @@ set -xe SRC_DIR="${SRC_DIR:-$PWD}" BUILDDIR="${BUILDDIR:-$PWD/build-rir}" -RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.5.1}" +RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.5.1+git}" mkdir -p $BUILDDIR From 4e35a0d1981d01e27185f02b0a98f4505c7bd50f Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Mon, 2 May 2016 17:54:48 +0200 Subject: [PATCH 0208/1304] changelog: correct minor tests entry --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e833732529..ec3106b63b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ This release is a minor bug fix release. #### Other changes -- minor tests and clean-ups (, [#2551](https://github.com/coreos/rkt/pull/2551)). +- minor tests and clean-ups ([#2551](https://github.com/coreos/rkt/pull/2551)). ## v1.5.0 From 9dcc645d29c9c3c6e1532b880f0faa090f16fd38 Mon Sep 17 00:00:00 2001 From: PI-Victor Date: Sun, 1 May 2016 00:16:49 +0200 Subject: [PATCH 0209/1304] README: remove specific version from link to coreos-overlay repo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a4fbf4049a..c11bab146c 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,6 @@ Due to a bug in the Linux kernel, using rkt's overlay support on top of an overl Due to a bug in the Linux kernel, rkt will not work when /var/lib/rkt is on btrfs ([#2175](https://github.com/coreos/rkt/issues/2175)). -Due to a bug in the Linux kernel, using rkt's overlay support in conjunction with SELinux requires a set of patches that are only currently available on some Linux distributions (for example, [CoreOS Linux](https://github.com/coreos/coreos-overlay/tree/master/sys-kernel/coreos-sources/files/4.4)). Work is ongoing to merge this work into the mainline Linux kernel ([#1727](https://github.com/coreos/rkt/issues/1727#issuecomment-173203129)). +Due to a bug in the Linux kernel, using rkt's overlay support in conjunction with SELinux requires a set of patches that are only currently available on some Linux distributions (for example, [CoreOS Linux](https://github.com/coreos/coreos-overlay/tree/master/sys-kernel/coreos-sources/files)). Work is ongoing to merge this work into the mainline Linux kernel ([#1727](https://github.com/coreos/rkt/issues/1727#issuecomment-173203129)). Linux 3.18+ is required to successfully garbage collect rkt pods when system services such as udevd are in a slave mount namespace (see [lazy umounts on unlinked files and directories](https://github.com/torvalds/linux/commit/8ed936b) and [#1922](https://github.com/coreos/rkt/issues/1922)). From a29dc3fc3408ceb71ec6eece1d5a94add7c0d94e Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Mon, 2 May 2016 19:24:00 -0700 Subject: [PATCH 0210/1304] stage1: download CoreOS over HTTPS --- stage1/usr_from_coreos/coreos-common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stage1/usr_from_coreos/coreos-common.mk b/stage1/usr_from_coreos/coreos-common.mk index 72197709e7..b5bfa7798b 100644 --- a/stage1/usr_from_coreos/coreos-common.mk +++ b/stage1/usr_from_coreos/coreos-common.mk @@ -13,7 +13,7 @@ CCN_SYSTEMD_VERSION := v225 # coreos image version CCN_IMG_RELEASE := 991.0.0 # coreos image URL -CCN_IMG_URL := http://alpha.release.core-os.net/amd64-usr/$(CCN_IMG_RELEASE)/coreos_production_pxe_image.cpio.gz +CCN_IMG_URL := https://alpha.release.core-os.net/amd64-usr/$(CCN_IMG_RELEASE)/coreos_production_pxe_image.cpio.gz # path to downloaded pxe image CCN_DOWNLOADED_PXE := $(CCN_TMPDIR)/pxe.img CLEAN_FILES += \ From e983bc4a16de5efde14b785232707fd2f9d4bef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 27 Apr 2016 12:08:45 +0200 Subject: [PATCH 0211/1304] stage1/usr_from_coreos: use CoreOS 1032.0.0 with systemd v229 --- stage1/usr_from_coreos/coreos-common.mk | 4 ++-- stage1/usr_from_coreos/manifest.d/systemd.manifest | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/stage1/usr_from_coreos/coreos-common.mk b/stage1/usr_from_coreos/coreos-common.mk index b5bfa7798b..f864f56d6e 100644 --- a/stage1/usr_from_coreos/coreos-common.mk +++ b/stage1/usr_from_coreos/coreos-common.mk @@ -9,9 +9,9 @@ _CCN_INCLUDED_ := x $(call setup-tmp-dir,CCN_TMPDIR) # systemd version in coreos image -CCN_SYSTEMD_VERSION := v225 +CCN_SYSTEMD_VERSION := v229 # coreos image version -CCN_IMG_RELEASE := 991.0.0 +CCN_IMG_RELEASE := 1032.0.0 # coreos image URL CCN_IMG_URL := https://alpha.release.core-os.net/amd64-usr/$(CCN_IMG_RELEASE)/coreos_production_pxe_image.cpio.gz # path to downloaded pxe image diff --git a/stage1/usr_from_coreos/manifest.d/systemd.manifest b/stage1/usr_from_coreos/manifest.d/systemd.manifest index fca30bbdfd..51d5fbcd36 100644 --- a/stage1/usr_from_coreos/manifest.d/systemd.manifest +++ b/stage1/usr_from_coreos/manifest.d/systemd.manifest @@ -61,6 +61,9 @@ lib64/libmount.so.1 lib64/libmount.so.1.1.0 lib64/libnss_files-2.21.so lib64/libnss_files.so.2 +lib64/libpam.so +lib64/libpam.so.0 +lib64/libpam.so.0.84.1 lib64/libpcre.so lib64/libpcre.so.1 lib64/libpcre.so.1.2.4 From dd12c26ec90a9d5bc2fed3e4ef8f9c79935f56cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Tue, 3 May 2016 11:17:22 +0200 Subject: [PATCH 0212/1304] stage1/init: pass both UID and GID to UnshiftRange Even if we only keep the unshifted UID (or only the GID), we need to call UnshiftRange with both shifted parameters or we get a range error. --- stage1/init/common/pod.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index e428ee286a..b6477b1fef 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -620,7 +620,7 @@ func parseUserGroup(p *stage1commontypes.Pod, ra *schema.RuntimeApp, uidRange *u return -1, -1, errwrap.Wrap(fmt.Errorf("unable to get uid from file %q", app.User), err) } - uidReal, _, err := uidRange.UnshiftRange(stat.Uid, 0) + uidReal, _, err := uidRange.UnshiftRange(stat.Uid, stat.Gid) if err != nil { return -1, -1, errwrap.Wrap(errors.New("unable to determine real uid"), err) } @@ -646,7 +646,7 @@ func parseUserGroup(p *stage1commontypes.Pod, ra *schema.RuntimeApp, uidRange *u return -1, -1, errwrap.Wrap(fmt.Errorf("unable to get gid from file %q", app.Group), err) } - _, gidReal, err := uidRange.UnshiftRange(0, stat.Gid) + _, gidReal, err := uidRange.UnshiftRange(stat.Uid, stat.Gid) if err != nil { return -1, -1, errwrap.Wrap(errors.New("unable to determine real gid"), err) } From 84a1280b3c3f9424c3dd0bb42184450074cdb8ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Tue, 26 Apr 2016 13:00:33 +0200 Subject: [PATCH 0213/1304] functional tests: run TestAppUserGroup with --private-users To make sure sysusers entries are generated correctly. --- tests/rkt_run_user_group_test.go | 44 ++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/tests/rkt_run_user_group_test.go b/tests/rkt_run_user_group_test.go index f98962792e..8b8981a9b3 100644 --- a/tests/rkt_run_user_group_test.go +++ b/tests/rkt_run_user_group_test.go @@ -21,6 +21,7 @@ import ( "os" "testing" + "github.com/coreos/rkt/common" "github.com/coreos/rkt/tests/testutils" ) @@ -28,6 +29,8 @@ func TestAppUserGroup(t *testing.T) { imageDummy := patchTestACI("rkt-inspect-dummy.aci", "--name=dummy") defer os.Remove(imageDummy) + supportsUserNS := common.SupportsUserNS() && checkUserNS() == nil + for _, tt := range []struct { imageParams []string rktParams string @@ -101,23 +104,32 @@ func TestAppUserGroup(t *testing.T) { image := patchTestACI("rkt-inspect-user-group.aci", tt.imageParams...) defer os.Remove(image) - // run the user/group overriden app first - rktCmd := fmt.Sprintf( - "%s --insecure-options=image run %s %s %s", - ctx.Cmd(), - image, tt.rktParams, - imageDummy, - ) - runRktAndCheckOutput(t, rktCmd, tt.expected, false) + userNSOpts := []string{""} + if supportsUserNS { + userNSOpts = append(userNSOpts, "--private-users --no-overlay") + } + + for _, userNSOpt := range userNSOpts { + // run the user/group overriden app first + rktCmd := fmt.Sprintf( + "%s --debug --insecure-options=image run %s %s %s %s", + ctx.Cmd(), + userNSOpt, + image, tt.rktParams, + imageDummy, + ) + runRktAndCheckOutput(t, rktCmd, tt.expected, false) - // run the user/group overriden app last - rktCmd = fmt.Sprintf( - "%s --insecure-options=image run %s %s %s", - ctx.Cmd(), - imageDummy, - image, tt.rktParams, - ) - runRktAndCheckOutput(t, rktCmd, tt.expected, false) + // run the user/group overriden app last + rktCmd = fmt.Sprintf( + "%s --debug --insecure-options=image run %s %s %s %s", + ctx.Cmd(), + userNSOpt, + imageDummy, + image, tt.rktParams, + ) + runRktAndCheckOutput(t, rktCmd, tt.expected, false) + } }() } } From 748c62650033c0643e1bb483352c67dd0c3632e5 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Tue, 26 Apr 2016 17:40:36 +0200 Subject: [PATCH 0214/1304] user: implement resolvers for resolving user UIDs/GIDs Currently resolving UIDs/GIDs is implemented in a single private method in stage1/init/common/pod.go. For future reuse/compositionality this is not the best solution. This refactors resolving UIDs/GIDs in a new user package. It introduces uid/gid resolvers capable of resolving those values from stat()ing a file, looking up etc/passwd, or etc/group, or simply assigning static uid/gid values. Fixes #2439 Backports #2508 --- pkg/aci/render.go | 10 +- pkg/fileutil/fileutil.go | 4 +- pkg/fileutil/fileutil_test.go | 8 +- pkg/tar/chroot.go | 6 +- pkg/tar/tar.go | 4 +- pkg/tar/tar_test.go | 6 +- pkg/user/doc.go | 17 ++ pkg/user/resolver.go | 143 +++++++++++ pkg/user/resolver_test.go | 350 ++++++++++++++++++++++++++ pkg/{uid/uid.go => user/uid_range.go} | 2 +- rkt/image_extract.go | 6 +- rkt/image_render.go | 4 +- rkt/prepare.go | 6 +- rkt/run.go | 6 +- stage0/run.go | 4 +- stage1/init/common/mount.go | 4 +- stage1/init/common/pod.go | 101 +++----- stage1_fly/run/main.go | 52 ++++ store/backup.go | 4 +- store/tree.go | 4 +- 20 files changed, 641 insertions(+), 100 deletions(-) create mode 100644 pkg/user/doc.go create mode 100644 pkg/user/resolver.go create mode 100644 pkg/user/resolver_test.go rename pkg/{uid/uid.go => user/uid_range.go} (99%) diff --git a/pkg/aci/render.go b/pkg/aci/render.go index 9d8469cc6b..b7aebb9f6a 100644 --- a/pkg/aci/render.go +++ b/pkg/aci/render.go @@ -17,7 +17,7 @@ package aci import ( "errors" - "github.com/coreos/rkt/pkg/uid" + "github.com/coreos/rkt/pkg/user" "github.com/hashicorp/errwrap" ptar "github.com/coreos/rkt/pkg/tar" @@ -28,7 +28,7 @@ import ( // Given an imageID, start with the matching image available in the store, // build its dependency list and render it inside dir -func RenderACIWithImageID(imageID types.Hash, dir string, ap acirenderer.ACIRegistry, uidRange *uid.UidRange) error { +func RenderACIWithImageID(imageID types.Hash, dir string, ap acirenderer.ACIRegistry, uidRange *user.UidRange) error { renderedACI, err := acirenderer.GetRenderedACIWithImageID(imageID, ap) if err != nil { return err @@ -38,7 +38,7 @@ func RenderACIWithImageID(imageID types.Hash, dir string, ap acirenderer.ACIRegi // Given an image app name and optional labels, get the best matching image // available in the store, build its dependency list and render it inside dir -func RenderACI(name types.ACIdentifier, labels types.Labels, dir string, ap acirenderer.ACIRegistry, uidRange *uid.UidRange) error { +func RenderACI(name types.ACIdentifier, labels types.Labels, dir string, ap acirenderer.ACIRegistry, uidRange *user.UidRange) error { renderedACI, err := acirenderer.GetRenderedACI(name, labels, ap) if err != nil { return err @@ -48,7 +48,7 @@ func RenderACI(name types.ACIdentifier, labels types.Labels, dir string, ap acir // Given an already populated dependency list, it will extract, under the provided // directory, the rendered ACI -func RenderACIFromList(imgs acirenderer.Images, dir string, ap acirenderer.ACIProvider, uidRange *uid.UidRange) error { +func RenderACIFromList(imgs acirenderer.Images, dir string, ap acirenderer.ACIProvider, uidRange *user.UidRange) error { renderedACI, err := acirenderer.GetRenderedACIFromList(imgs, ap) if err != nil { return err @@ -61,7 +61,7 @@ func RenderACIFromList(imgs acirenderer.Images, dir string, ap acirenderer.ACIPr // The manifest will be extracted from the upper ACI. // No file overwriting is done as it should usually be called // providing an empty directory. -func renderImage(renderedACI acirenderer.RenderedACI, dir string, ap acirenderer.ACIProvider, uidRange *uid.UidRange) error { +func renderImage(renderedACI acirenderer.RenderedACI, dir string, ap acirenderer.ACIProvider, uidRange *user.UidRange) error { for _, ra := range renderedACI { rs, err := ap.ReadStream(ra.Key) if err != nil { diff --git a/pkg/fileutil/fileutil.go b/pkg/fileutil/fileutil.go index 15c5774cd4..9b22e5e12f 100644 --- a/pkg/fileutil/fileutil.go +++ b/pkg/fileutil/fileutil.go @@ -22,7 +22,7 @@ import ( "syscall" "time" - "github.com/coreos/rkt/pkg/uid" + "github.com/coreos/rkt/pkg/user" "github.com/appc/spec/pkg/device" ) @@ -60,7 +60,7 @@ func CopySymlink(src, dest string) error { return nil } -func CopyTree(src, dest string, uidRange *uid.UidRange) error { +func CopyTree(src, dest string, uidRange *user.UidRange) error { cleanSrc := filepath.Clean(src) dirs := make(map[string][]syscall.Timespec) diff --git a/pkg/fileutil/fileutil_test.go b/pkg/fileutil/fileutil_test.go index 08e386734d..aa68ac9b28 100644 --- a/pkg/fileutil/fileutil_test.go +++ b/pkg/fileutil/fileutil_test.go @@ -20,7 +20,7 @@ import ( "path/filepath" "testing" - "github.com/coreos/rkt/pkg/uid" + "github.com/coreos/rkt/pkg/user" ) const tstprefix = "fileutil-test" @@ -95,7 +95,7 @@ func TestCopyTree(t *testing.T) { createTree(t, src, tr) // absolute paths - if err := CopyTree(src, dst, uid.NewBlankUidRange()); err != nil { + if err := CopyTree(src, dst, user.NewBlankUidRange()); err != nil { t.Fatal(err) } checkTree(t, dst, tr) @@ -106,13 +106,13 @@ func TestCopyTree(t *testing.T) { } dst = "dst-rel1" - if err := CopyTree("././src/", dst, uid.NewBlankUidRange()); err != nil { + if err := CopyTree("././src/", dst, user.NewBlankUidRange()); err != nil { t.Fatal(err) } checkTree(t, dst, tr) dst = "./dst-rel2" - if err := CopyTree("./src", dst, uid.NewBlankUidRange()); err != nil { + if err := CopyTree("./src", dst, user.NewBlankUidRange()); err != nil { t.Fatal(err) } checkTree(t, dst, tr) diff --git a/pkg/tar/chroot.go b/pkg/tar/chroot.go index c30fad8670..d835fdd155 100644 --- a/pkg/tar/chroot.go +++ b/pkg/tar/chroot.go @@ -28,7 +28,7 @@ import ( "github.com/coreos/rkt/pkg/multicall" "github.com/coreos/rkt/pkg/sys" - "github.com/coreos/rkt/pkg/uid" + "github.com/coreos/rkt/pkg/user" "github.com/hashicorp/errwrap" ) @@ -68,7 +68,7 @@ func extractTarCommand() error { return errwrap.Wrap(errors.New("error parsing uidShift argument"), err) } - uidRange := &uid.UidRange{Shift: uint32(us), Count: uint32(uc)} + uidRange := &user.UidRange{Shift: uint32(us), Count: uint32(uc)} if err := syscall.Chroot(dir); err != nil { return errwrap.Wrap(fmt.Errorf("failed to chroot in %s", dir), err) @@ -101,7 +101,7 @@ func extractTarCommand() error { // If overwrite is true, existing files will be overwritten. // The extraction is executed by fork/exec()ing a new process. The new process // needs the CAP_SYS_CHROOT capability. -func ExtractTar(rs io.Reader, dir string, overwrite bool, uidRange *uid.UidRange, pwl PathWhitelistMap) error { +func ExtractTar(rs io.Reader, dir string, overwrite bool, uidRange *user.UidRange, pwl PathWhitelistMap) error { r, w, err := os.Pipe() if err != nil { return err diff --git a/pkg/tar/tar.go b/pkg/tar/tar.go index 1b20706d05..0d8f27ad87 100644 --- a/pkg/tar/tar.go +++ b/pkg/tar/tar.go @@ -27,7 +27,7 @@ import ( "github.com/appc/spec/pkg/device" "github.com/coreos/rkt/pkg/fileutil" - "github.com/coreos/rkt/pkg/uid" + "github.com/coreos/rkt/pkg/user" "github.com/hashicorp/errwrap" ) @@ -41,7 +41,7 @@ type PathWhitelistMap map[string]struct{} type FilePermissionsEditor func(string, int, int, byte, os.FileInfo) error -func NewUidShiftingFilePermEditor(uidRange *uid.UidRange) (FilePermissionsEditor, error) { +func NewUidShiftingFilePermEditor(uidRange *user.UidRange) (FilePermissionsEditor, error) { if os.Geteuid() != 0 { return func(_ string, _, _ int, _ byte, _ os.FileInfo) error { // The files are owned by the current user on creation. diff --git a/pkg/tar/tar_test.go b/pkg/tar/tar_test.go index f24ea285de..0363ad86c6 100644 --- a/pkg/tar/tar_test.go +++ b/pkg/tar/tar_test.go @@ -28,7 +28,7 @@ import ( "github.com/coreos/rkt/pkg/multicall" "github.com/coreos/rkt/pkg/sys" - "github.com/coreos/rkt/pkg/uid" + "github.com/coreos/rkt/pkg/user" ) func init() { @@ -792,7 +792,7 @@ func extractTarHelper(rdr io.Reader, target string) error { } func extractTarHelperPWL(rdr io.Reader, target string, pwl PathWhitelistMap) error { - return ExtractTar(rdr, target, false, uid.NewBlankUidRange(), pwl) + return ExtractTar(rdr, target, false, user.NewBlankUidRange(), pwl) } func extractTarInsecureHelper(rdr io.Reader, target string) error { @@ -800,7 +800,7 @@ func extractTarInsecureHelper(rdr io.Reader, target string) error { } func extractTarInsecureHelperPWL(rdr io.Reader, target string, pwl PathWhitelistMap) error { - editor, err := NewUidShiftingFilePermEditor(uid.NewBlankUidRange()) + editor, err := NewUidShiftingFilePermEditor(user.NewBlankUidRange()) if err != nil { return err } diff --git a/pkg/user/doc.go b/pkg/user/doc.go new file mode 100644 index 0000000000..6396db1c4e --- /dev/null +++ b/pkg/user/doc.go @@ -0,0 +1,17 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package user allows resolving user UIDs/GIDs using various methods. +// It also provides an implementation for shifting UIDs/GIDs. +package user diff --git a/pkg/user/resolver.go b/pkg/user/resolver.go new file mode 100644 index 0000000000..855c59a430 --- /dev/null +++ b/pkg/user/resolver.go @@ -0,0 +1,143 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package user + +import ( + "errors" + "fmt" + "path/filepath" + "strconv" + "strings" + "syscall" + + "github.com/coreos/rkt/pkg/group" + "github.com/coreos/rkt/pkg/passwd" + "github.com/hashicorp/errwrap" +) + +// Resolver defines the interface for resolving a UID/GID. +type Resolver interface { + IDs() (uid int, gid int, err error) +} + +type idsFromEtc struct { + rootPath string + username string + group string +} + +// IDsFromEtc returns a new UID/GID resolver by parsing etc/passwd, and etc/group +// relative from the given rootPath looking for the given username, or group. +// If username is empty string the etc/passwd lookup will be ommitted. +// If group is empty string the etc/group lookup will be ommitted. +func IDsFromEtc(rootPath, username, group string) (Resolver, error) { + return idsFromEtc{ + rootPath: rootPath, + username: username, + group: group, + }, nil +} + +func (e idsFromEtc) IDs() (uid int, gid int, err error) { + uid, gid = -1, -1 + + uid, err = passwd.LookupUidFromFile( + e.username, + filepath.Join(e.rootPath, "etc/passwd"), + ) + + if e.username != "" && err != nil { + return + } + + gid, err = group.LookupGidFromFile( + e.group, + filepath.Join(e.rootPath, "etc/group"), + ) + + if e.group != "" && err != nil { + return + } + + return uid, gid, nil +} + +type idsFromStat struct { + path string + r *UidRange +} + +// IDsFromStat returns a new UID/GID resolver deriving the UID/GID from file attributes +// and unshifts the UID/GID if the given range is not nil. +// If the given id does not start with a slash "/" an error is returned. +func IDsFromStat(rootPath, file string, r *UidRange) (Resolver, error) { + if strings.HasPrefix(file, "/") { + return idsFromStat{filepath.Join(rootPath, file), r}, nil + } + + return nil, fmt.Errorf("invalid filename %q", file) +} + +func (s idsFromStat) IDs() (int, int, error) { + var stat syscall.Stat_t + + if err := syscall.Lstat(s.path, &stat); err != nil { + return -1, -1, errwrap.Wrap( + fmt.Errorf("unable to stat file %q", s.path), + err, + ) + } + + if s.r == nil { + return int(stat.Uid), int(stat.Gid), nil + } + + uid, _, err := s.r.UnshiftRange(stat.Uid, stat.Gid) + if err != nil { + return -1, -1, errwrap.Wrap(errors.New("unable to determine real uid"), err) + } + + _, gid, err := s.r.UnshiftRange(stat.Uid, stat.Gid) + if err != nil { + return -1, -1, errwrap.Wrap(errors.New("unable to determine real gid"), err) + } + + return int(uid), int(gid), nil +} + +// numericIDs is the struct that always resolves to uid=i and gid=i. +type numericIDs struct { + i int +} + +// NumericIDs returns a resolver that will resolve constant UID/GID values. +// If the given id equals to "root" the resolver always resolves UID=0 and GID=0. +// If the given id is a numeric literal i it always resolves UID=i and GID=i. +// If the given id is neither "root" nor a numeric literal an error is returned. +func NumericIDs(id string) (Resolver, error) { + if id == "root" { + return numericIDs{0}, nil + } + + if i, err := strconv.Atoi(id); err == nil { + return numericIDs{i}, nil + } + + return nil, fmt.Errorf("invalid id %q", id) +} + +func (n numericIDs) IDs() (int, int, error) { + return n.i, n.i, nil +} diff --git a/pkg/user/resolver_test.go b/pkg/user/resolver_test.go new file mode 100644 index 0000000000..db97a475d2 --- /dev/null +++ b/pkg/user/resolver_test.go @@ -0,0 +1,350 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package user_test + +import ( + "io/ioutil" + "os" + "path/filepath" + "strconv" + "testing" + + osuser "os/user" + + "github.com/coreos/rkt/pkg/user" +) + +const ( + maxInt = int(^uint(0) >> 1) + minInt = -maxInt - 1 +) + +func TestNumeric(t *testing.T) { + for i, tt := range []struct { + id string + + // expected + err bool + uid, gid int + }{ + { + id: "foo", + err: true, + }, + { + id: "", + err: true, + }, + { + id: "root", + uid: 0, gid: 0, + }, + { + id: "0", + uid: 0, gid: 0, + }, + { + id: "1", + uid: 1, gid: 1, + }, + { + id: strconv.Itoa(minInt), + uid: minInt, gid: minInt, + }, + { + id: strconv.Itoa(maxInt), + uid: maxInt, gid: maxInt, + }, + { + id: "9223372036854775808", // overflow (64bit) int by one + err: true, + }, + { + id: "-9223372036854775809", // overflow (64bit) int by one + err: true, + }, + { + id: "-1", + uid: -1, gid: -1, + }, + } { + gen, err := user.NumericIDs(tt.id) + if err == nil && tt.err { + t.Errorf("test %d: expected err but got none", i) + } + + if err != nil { + continue + } + + uid, gid, err := gen.IDs() + if err != nil { + panic(err) // must not happen + } + + if uid != tt.uid { + t.Errorf("test %d: expected uid %d but got %d", i, tt.uid, uid) + } + + if gid != tt.gid { + t.Errorf("test %d: expected gid %d but got %d", i, tt.gid, gid) + } + } +} + +func TestFromEtc(t *testing.T) { + root, err := ioutil.TempDir("", "rkt-TestFromEtc-") + if err != nil { + panic(err) + } + + defer os.RemoveAll(root) + + if err := os.Mkdir( + filepath.Join(root, "etc"), + 0700, + ); err != nil { + panic(err) + } + + if err := ioutil.WriteFile( + filepath.Join(root, "etc/passwd"), + []byte(`u1:xxx:1000:100:::`), + 0600, + ); err != nil { + panic(err) + } + + if err := ioutil.WriteFile( + filepath.Join(root, "etc/group"), + []byte(`g1:xxx:100:u1`), + 0600, + ); err != nil { + panic(err) + } + + for i, tt := range []struct { + username, group string + + // expected + err bool + uid, gid int + }{ + { + uid: -1, + gid: -1, + err: false, + }, + { + username: "unknown", + + uid: -1, + gid: -1, + err: true, + }, + { + group: "unknown", + + uid: -1, + gid: -1, + err: true, + }, + { + username: "u1", + + uid: 1000, + gid: -1, + err: false, + }, + { + username: "u1", + group: "unknown", + + uid: 1000, + gid: -1, + err: true, + }, + { + group: "g1", + + uid: -1, + gid: 100, + err: false, + }, + { + username: "unknown", + group: "g1", + + uid: -1, + gid: -1, + err: true, + }, + { + username: "u1", + group: "g1", + + uid: 1000, + gid: 100, + err: false, + }, + } { + gen, err := user.IDsFromEtc(root, tt.username, tt.group) + if err != nil { + panic(err) + } + + uid, gid, err := gen.IDs() + if err == nil && tt.err { + t.Errorf("test %d: expected err but got none", i) + } + + if err != nil && !tt.err { + t.Errorf("test %d: expected no err but got one", i) + } + + if uid != tt.uid { + t.Errorf("test %d: expected uid %d but got %d", i, tt.uid, uid) + } + + if gid != tt.gid { + t.Errorf("test %d: expected gid %d but got %d", i, tt.gid, gid) + } + } +} + +func TestStat(t *testing.T) { + tmp, err := ioutil.TempFile("", "rkt-TestStat-") + if err != nil { + panic(err) + } + + defer os.Remove(tmp.Name()) + + rng := user.NewBlankUidRange() + rng.SetRandomUidRange(100) + + u, err := osuser.Current() + if err != nil { + panic(err) + } + + procUid, err := strconv.Atoi(u.Uid) + if err != nil { + panic(err) + } + + procGid, err := strconv.Atoi(u.Gid) + if err != nil { + panic(err) + } + + for i, tt := range []struct { + root, path string + + // expected + errIDs, err bool + uid, gid int + }{ + { + root: "", + path: "", + + err: true, + }, + { + root: "unknown", + path: "", + + err: true, + }, + { + root: "", + path: "unknown", + + err: true, + }, + { + root: "", + path: tmp.Name(), + + uid: procUid, + gid: procGid, + }, + { + root: "/", + path: tmp.Name(), + + uid: procUid, + gid: procGid, + }, + { + root: "unknown", + path: tmp.Name(), + + errIDs: true, + uid: -1, + gid: -1, + }, + { + root: filepath.Dir(tmp.Name()), + path: "", + + err: true, + }, + { + root: filepath.Dir(tmp.Name()), + path: "/" + filepath.Base(tmp.Name()), + + uid: procUid, + gid: procGid, + }, + { + root: filepath.Dir(tmp.Name()), + path: "/unknown", + + errIDs: true, + uid: -1, + gid: -1, + }, + { + root: filepath.Dir(tmp.Name()), + path: "unknown", + + err: true, + }, + } { + gen, err := user.IDsFromStat(tt.root, tt.path, nil) + if err == nil && tt.err { + t.Errorf("test %d: expected error but got one", i) + } + + if err != nil { + continue + } + + uid, gid, err := gen.IDs() + if err == nil && tt.errIDs { + t.Errorf("test %d: expected err but got none", i) + } + + if uid != tt.uid { + t.Errorf("test %d: expected uid %d but got %d", i, tt.uid, uid) + } + + if gid != tt.gid { + t.Errorf("test %d: expected gid %d but got %d", i, tt.gid, gid) + } + } +} diff --git a/pkg/uid/uid.go b/pkg/user/uid_range.go similarity index 99% rename from pkg/uid/uid.go rename to pkg/user/uid_range.go index 79843df4ef..4f99abab85 100644 --- a/pkg/uid/uid.go +++ b/pkg/user/uid_range.go @@ -15,7 +15,7 @@ // For how the uidshift and uidcount are generated please check: // http://cgit.freedesktop.org/systemd/systemd/commit/?id=03cfe0d51499e86b1573d1 -package uid +package user import ( "errors" diff --git a/rkt/image_extract.go b/rkt/image_extract.go index 6fa2b906c5..e90df89817 100644 --- a/rkt/image_extract.go +++ b/rkt/image_extract.go @@ -22,7 +22,7 @@ import ( "github.com/coreos/rkt/pkg/fileutil" "github.com/coreos/rkt/pkg/tar" - "github.com/coreos/rkt/pkg/uid" + "github.com/coreos/rkt/pkg/user" "github.com/coreos/rkt/store" "github.com/spf13/cobra" @@ -124,7 +124,7 @@ func runImageExtract(cmd *cobra.Command, args []string) (exit int) { } } - if err := tar.ExtractTar(aci, extractDir, false, uid.NewBlankUidRange(), nil); err != nil { + if err := tar.ExtractTar(aci, extractDir, false, user.NewBlankUidRange(), nil); err != nil { stderr.PrintE("error extracting ACI", err) return 1 } @@ -134,7 +134,7 @@ func runImageExtract(cmd *cobra.Command, args []string) (exit int) { if err := os.Rename(rootfsDir, absOutputDir); err != nil { if e, ok := err.(*os.LinkError); ok && e.Err == syscall.EXDEV { // it's on a different device, fall back to copying - if err := fileutil.CopyTree(rootfsDir, absOutputDir, uid.NewBlankUidRange()); err != nil { + if err := fileutil.CopyTree(rootfsDir, absOutputDir, user.NewBlankUidRange()); err != nil { stderr.PrintE("error copying ACI rootfs", err) return 1 } diff --git a/rkt/image_render.go b/rkt/image_render.go index 9d374e9f1c..43b4426251 100644 --- a/rkt/image_render.go +++ b/rkt/image_render.go @@ -21,7 +21,7 @@ import ( "path/filepath" "github.com/coreos/rkt/pkg/fileutil" - "github.com/coreos/rkt/pkg/uid" + "github.com/coreos/rkt/pkg/user" "github.com/coreos/rkt/store" "github.com/spf13/cobra" @@ -127,7 +127,7 @@ func runImageRender(cmd *cobra.Command, args []string) (exit int) { } cachedTreePath := s.GetTreeStoreRootFS(id) - if err := fileutil.CopyTree(cachedTreePath, rootfsOutDir, uid.NewBlankUidRange()); err != nil { + if err := fileutil.CopyTree(cachedTreePath, rootfsOutDir, user.NewBlankUidRange()); err != nil { stderr.PrintE("error copying ACI rootfs", err) return 1 } diff --git a/rkt/prepare.go b/rkt/prepare.go index 127d176113..061028411e 100644 --- a/rkt/prepare.go +++ b/rkt/prepare.go @@ -22,7 +22,7 @@ import ( "github.com/appc/spec/schema/types" "github.com/coreos/rkt/common" "github.com/coreos/rkt/pkg/lock" - "github.com/coreos/rkt/pkg/uid" + "github.com/coreos/rkt/pkg/user" "github.com/coreos/rkt/rkt/image" "github.com/coreos/rkt/stage0" "github.com/coreos/rkt/store" @@ -81,7 +81,7 @@ func init() { func runPrepare(cmd *cobra.Command, args []string) (exit int) { var err error origStdout := os.Stdout - privateUsers := uid.NewBlankUidRange() + privateUsers := user.NewBlankUidRange() if flagQuiet { if os.Stdout, err = os.Open("/dev/null"); err != nil { stderr.PrintE("unable to open /dev/null", err) @@ -99,7 +99,7 @@ func runPrepare(cmd *cobra.Command, args []string) (exit int) { stderr.Print("--private-users is not supported, kernel compiled without user namespace support") return 1 } - privateUsers.SetRandomUidRange(uid.DefaultRangeCount) + privateUsers.SetRandomUidRange(user.DefaultRangeCount) } if err = parseApps(&rktApps, args, cmd.Flags(), true); err != nil { diff --git a/rkt/run.go b/rkt/run.go index 01ba367925..3762d307ba 100644 --- a/rkt/run.go +++ b/rkt/run.go @@ -25,7 +25,7 @@ import ( "github.com/coreos/rkt/common" "github.com/coreos/rkt/pkg/label" "github.com/coreos/rkt/pkg/lock" - "github.com/coreos/rkt/pkg/uid" + "github.com/coreos/rkt/pkg/user" "github.com/coreos/rkt/rkt/image" "github.com/coreos/rkt/stage0" "github.com/coreos/rkt/store" @@ -114,7 +114,7 @@ func init() { } func runRun(cmd *cobra.Command, args []string) (exit int) { - privateUsers := uid.NewBlankUidRange() + privateUsers := user.NewBlankUidRange() err := parseApps(&rktApps, args, cmd.Flags(), true) if err != nil { stderr.PrintE("error parsing app image arguments", err) @@ -131,7 +131,7 @@ func runRun(cmd *cobra.Command, args []string) (exit int) { stderr.Print("--private-users is not supported, kernel compiled without user namespace support") return 1 } - privateUsers.SetRandomUidRange(uid.DefaultRangeCount) + privateUsers.SetRandomUidRange(user.DefaultRangeCount) } if len(flagPorts) > 0 && flagNet.None() { diff --git a/stage0/run.go b/stage0/run.go index cbacd50fd7..a9a1dd9647 100644 --- a/stage0/run.go +++ b/stage0/run.go @@ -47,7 +47,7 @@ import ( "github.com/coreos/rkt/pkg/label" "github.com/coreos/rkt/pkg/sys" "github.com/coreos/rkt/pkg/tpm" - "github.com/coreos/rkt/pkg/uid" + "github.com/coreos/rkt/pkg/user" "github.com/coreos/rkt/store" "github.com/coreos/rkt/version" "github.com/hashicorp/errwrap" @@ -76,7 +76,7 @@ type PrepareConfig struct { UseOverlay bool // prepare pod with overlay fs SkipTreeStoreCheck bool // skip checking the treestore before rendering PodManifest string // use the pod manifest specified by the user, this will ignore flags such as '--volume', '--port', etc. - PrivateUsers *uid.UidRange // User namespaces + PrivateUsers *user.UidRange // User namespaces } // configuration parameters needed by Run diff --git a/stage1/init/common/mount.go b/stage1/init/common/mount.go index 2a9f6e5bf3..43c8f8d011 100644 --- a/stage1/init/common/mount.go +++ b/stage1/init/common/mount.go @@ -21,7 +21,7 @@ import ( "syscall" "github.com/coreos/rkt/pkg/fileutil" - "github.com/coreos/rkt/pkg/uid" + "github.com/coreos/rkt/pkg/user" "github.com/appc/spec/schema" "github.com/appc/spec/schema/types" @@ -158,7 +158,7 @@ func PrepareMountpoints(volPath string, targetPath string, vol *types.Volume, do Uid = int(fi.Sys().(*syscall.Stat_t).Uid) Gid = int(fi.Sys().(*syscall.Stat_t).Gid) - if err := fileutil.CopyTree(targetPath, volPath, uid.NewBlankUidRange()); err != nil { + if err := fileutil.CopyTree(targetPath, volPath, user.NewBlankUidRange()); err != nil { return errwrap.Wrap(fmt.Errorf("error copying image files to empty volume %q", volPath), err) } } diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index b6477b1fef..11b077c075 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -28,11 +28,8 @@ import ( "regexp" "strconv" "strings" - "syscall" "github.com/coreos/rkt/pkg/acl" - "github.com/coreos/rkt/pkg/group" - "github.com/coreos/rkt/pkg/passwd" stage1commontypes "github.com/coreos/rkt/stage1/common/types" "github.com/appc/spec/schema" @@ -43,7 +40,7 @@ import ( "github.com/coreos/rkt/common" "github.com/coreos/rkt/common/cgroup" "github.com/coreos/rkt/pkg/fileutil" - "github.com/coreos/rkt/pkg/uid" + "github.com/coreos/rkt/pkg/user" ) const ( @@ -271,7 +268,7 @@ func findHostPort(pm schema.PodManifest, name types.ACName) uint { // service files of apps. // If there're several apps defining the same UIDs/GIDs, systemd will take care // of only generating one /etc/{passwd,group} entry -func generateSysusers(p *stage1commontypes.Pod, ra *schema.RuntimeApp, uid_ int, gid_ int, uidRange *uid.UidRange) error { +func generateSysusers(p *stage1commontypes.Pod, ra *schema.RuntimeApp, uid_ int, gid_ int, uidRange *user.UidRange) error { var toShift []string app := ra.App @@ -414,7 +411,7 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b envFilePathSystemd := EnvFilePathSystemd(p.Root, appName) envFilePathEnterexec := EnvFilePathEnterexec(p.Root, appName) - uidRange := uid.NewBlankUidRange() + uidRange := user.NewBlankUidRange() if err := uidRange.Deserialize([]byte(privateUsers)); err != nil { return err } @@ -603,66 +600,48 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b // 3. a number // 4. a name in reference to /etc/{group,passwd} in the image // See https://github.com/appc/spec/blob/master/spec/aci.md#image-manifest-schema -func parseUserGroup(p *stage1commontypes.Pod, ra *schema.RuntimeApp, uidRange *uid.UidRange) (int, int, error) { - app := ra.App - appName := ra.Name - - var uid_, gid_ int +func parseUserGroup(p *stage1commontypes.Pod, ra *schema.RuntimeApp, uidRange *user.UidRange) (int, int, error) { + var uidResolver, gidResolver user.Resolver + var uid, gid int var err error - switch { - case app.User == "root": - uid_ = 0 - case strings.HasPrefix(app.User, "/"): - var stat syscall.Stat_t - if err = syscall.Lstat(filepath.Join(common.AppRootfsPath(p.Root, appName), - app.User), &stat); err != nil { - return -1, -1, errwrap.Wrap(fmt.Errorf("unable to get uid from file %q", - app.User), err) - } - uidReal, _, err := uidRange.UnshiftRange(stat.Uid, stat.Gid) - if err != nil { - return -1, -1, errwrap.Wrap(errors.New("unable to determine real uid"), err) - } - uid_ = int(uidReal) - default: - uid_, err = strconv.Atoi(app.User) - if err != nil { - uid_, err = passwd.LookupUidFromFile(app.User, - filepath.Join(common.AppRootfsPath(p.Root, appName), "etc/passwd")) - if err != nil { - return -1, -1, errwrap.Wrap(fmt.Errorf("cannot lookup user %q", app.User), err) - } - } + root := common.AppRootfsPath(p.Root, ra.Name) + + uidResolver, err = user.NumericIDs(ra.App.User) + if err != nil { + uidResolver, err = user.IDsFromStat(root, ra.App.User, uidRange) } - switch { - case app.Group == "root": - gid_ = 0 - case strings.HasPrefix(app.Group, "/"): - var stat syscall.Stat_t - if err = syscall.Lstat(filepath.Join(common.AppRootfsPath(p.Root, appName), - app.Group), &stat); err != nil { - return -1, -1, errwrap.Wrap(fmt.Errorf("unable to get gid from file %q", - app.Group), err) - } - _, gidReal, err := uidRange.UnshiftRange(stat.Uid, stat.Gid) - if err != nil { - return -1, -1, errwrap.Wrap(errors.New("unable to determine real gid"), err) - } - gid_ = int(gidReal) - default: - gid_, err = strconv.Atoi(app.Group) - if err != nil { - gid_, err = group.LookupGidFromFile(app.Group, - filepath.Join(common.AppRootfsPath(p.Root, appName), "etc/group")) - if err != nil { - return -1, -1, errwrap.Wrap(fmt.Errorf("cannot lookup group %q", app.Group), err) - } - } + if err != nil { + uidResolver, err = user.IDsFromEtc(root, ra.App.User, "") + } + + if err != nil { // give up + return -1, -1, errwrap.Wrap(fmt.Errorf("invalid user %q", ra.App.User), err) + } + + if uid, _, err = uidResolver.IDs(); err != nil { + return -1, -1, errwrap.Wrap(fmt.Errorf("failed to configure user %q", ra.App.User), err) + } + + gidResolver, err = user.NumericIDs(ra.App.Group) + if err != nil { + gidResolver, err = user.IDsFromStat(root, ra.App.Group, uidRange) + } + + if err != nil { + gidResolver, err = user.IDsFromEtc(root, "", ra.App.Group) + } + + if err != nil { // give up + return -1, -1, errwrap.Wrap(fmt.Errorf("invalid group %q", ra.App.Group), err) + } + + if _, gid, err = gidResolver.IDs(); err != nil { + return -1, -1, errwrap.Wrap(fmt.Errorf("failed to configure group %q", ra.App.Group), err) } - return uid_, gid_, nil + return uid, gid, nil } func writeShutdownService(p *stage1commontypes.Pod) error { @@ -713,7 +692,7 @@ func writeShutdownService(p *stage1commontypes.Pod) error { // writeEnvFile creates an environment file for given app name, the minimum // required environment variables by the appc spec will be set to sensible // defaults here if they're not provided by env. -func writeEnvFile(p *stage1commontypes.Pod, env types.Environment, appName types.ACName, uidRange *uid.UidRange, separator byte, envFilePath string) error { +func writeEnvFile(p *stage1commontypes.Pod, env types.Environment, appName types.ACName, uidRange *user.UidRange, separator byte, envFilePath string) error { ef := bytes.Buffer{} for dk, dv := range defaultEnv { diff --git a/stage1_fly/run/main.go b/stage1_fly/run/main.go index dd7e8dbd3f..396ef39ebd 100644 --- a/stage1_fly/run/main.go +++ b/stage1_fly/run/main.go @@ -22,6 +22,7 @@ import ( "io/ioutil" "os" "path/filepath" + "runtime" "strings" "syscall" @@ -32,6 +33,7 @@ import ( "github.com/coreos/rkt/common" rktlog "github.com/coreos/rkt/pkg/log" "github.com/coreos/rkt/pkg/sys" + "github.com/coreos/rkt/pkg/user" stage1common "github.com/coreos/rkt/stage1/common" stage1commontypes "github.com/coreos/rkt/stage1/common/types" ) @@ -337,6 +339,39 @@ func stage1() int { return 1 } + var uidResolver, gidResolver user.Resolver + var uid, gid int + + uidResolver, err = user.NumericIDs(ra.App.User) + if err != nil { + uidResolver, err = user.IDsFromStat(rfs, ra.App.User, nil) + } + + if err != nil { // give up + log.PrintE(fmt.Sprintf("invalid user %q", ra.App.User), err) + return 1 + } + + if uid, _, err = uidResolver.IDs(); err != nil { + log.PrintE(fmt.Sprintf("failed to configure user %q", ra.App.User), err) + return 1 + } + + gidResolver, err = user.NumericIDs(ra.App.Group) + if err != nil { + gidResolver, err = user.IDsFromStat(rfs, ra.App.Group, nil) + } + + if err != nil { // give up + log.PrintE(fmt.Sprintf("invalid group %q", ra.App.Group), err) + return 1 + } + + if _, gid, err = gidResolver.IDs(); err != nil { + log.PrintE(fmt.Sprintf("failed to configure group %q", ra.App.Group), err) + return 1 + } + diag.Printf("chroot to %q", rfs) if err := syscall.Chroot(rfs); err != nil { log.PrintE("can't chroot", err) @@ -348,6 +383,23 @@ func stage1() int { return 1 } + // lock the current goroutine to its current OS thread. + // This will force the subsequent syscalls to be executed in the same OS thread as Setresuid, and Setresgid, + // see https://github.com/golang/go/issues/1435#issuecomment-66054163. + runtime.LockOSThread() + + diag.Printf("setting uid %d gid %d", uid, gid) + + if err := syscall.Setresgid(gid, gid, gid); err != nil { + log.PrintE(fmt.Sprintf("can't set gid %d", gid), err) + return 1 + } + + if err := syscall.Setresuid(uid, uid, uid); err != nil { + log.PrintE(fmt.Sprintf("can't set uid %d", uid), err) + return 1 + } + diag.Printf("execing %q in %q", args, rfs) err = stage1common.WithClearedCloExec(lfd, func() error { return syscall.Exec(args[0], args, env) diff --git a/store/backup.go b/store/backup.go index b6c02e4938..dfda1cf1ef 100644 --- a/store/backup.go +++ b/store/backup.go @@ -21,7 +21,7 @@ import ( "strconv" "github.com/coreos/rkt/pkg/fileutil" - "github.com/coreos/rkt/pkg/uid" + "github.com/coreos/rkt/pkg/user" ) // createBackup backs a database up in a given directory. It basically @@ -37,7 +37,7 @@ func createBackup(dbDir, backupsDir string, limit int) error { if err := os.MkdirAll(backupsDir, defaultPathPerm); err != nil { return err } - if err := fileutil.CopyTree(dbDir, tmpBackupDir, uid.NewBlankUidRange()); err != nil { + if err := fileutil.CopyTree(dbDir, tmpBackupDir, user.NewBlankUidRange()); err != nil { return err } defer os.RemoveAll(tmpBackupDir) diff --git a/store/tree.go b/store/tree.go index f098cf5f36..56f9a578a5 100644 --- a/store/tree.go +++ b/store/tree.go @@ -33,7 +33,7 @@ import ( "github.com/coreos/rkt/pkg/aci" "github.com/coreos/rkt/pkg/fileutil" "github.com/coreos/rkt/pkg/sys" - "github.com/coreos/rkt/pkg/uid" + "github.com/coreos/rkt/pkg/user" "github.com/hashicorp/errwrap" ) @@ -66,7 +66,7 @@ func (ts *TreeStore) Write(id string, key string, s *Store) (string, error) { if err := os.MkdirAll(treepath, 0755); err != nil { return "", errwrap.Wrap(fmt.Errorf("cannot create treestore directory %s", treepath), err) } - err = aci.RenderACIWithImageID(*imageID, treepath, s, uid.NewBlankUidRange()) + err = aci.RenderACIWithImageID(*imageID, treepath, s, user.NewBlankUidRange()) if err != nil { return "", errwrap.Wrap(errors.New("cannot render aci"), err) } From 45ca65de765e919b27575f36d43b93ac3daaa561 Mon Sep 17 00:00:00 2001 From: Shaya Potter Date: Mon, 2 May 2016 14:22:27 -0700 Subject: [PATCH 0215/1304] tests: add PodSubCgroup filter test to Cgroup filter test --- tests/rkt_api_service_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/rkt_api_service_test.go b/tests/rkt_api_service_test.go index 753a9fc914..2a5769b765 100644 --- a/tests/rkt_api_service_test.go +++ b/tests/rkt_api_service_test.go @@ -21,6 +21,7 @@ import ( "encoding/json" "fmt" "os" + "path/filepath" "reflect" "strings" "syscall" @@ -499,6 +500,7 @@ func NewAPIServiceCgroupTest() testutils.Test { testutils.WaitOrTimeout(t, time.Second*30, done) var cgroups []string + var subcgroups []string for _, p := range resp.Pods { checkPodBasics(t, ctx, p) @@ -511,6 +513,7 @@ func NewAPIServiceCgroupTest() testutils.Test { checkPodDetails(t, ctx, inspectResp.Pod) if p.Cgroup != "" { cgroups = append(cgroups, p.Cgroup) + subcgroups = append(subcgroups, filepath.Join(p.Cgroup, "system.slice")) } } @@ -531,6 +534,22 @@ func NewAPIServiceCgroupTest() testutils.Test { checkPodDetails(t, ctx, p) } + resp, err = c.ListPods(context.Background(), &v1alpha.ListPodsRequest{ + Detail: true, + Filters: []*v1alpha.PodFilter{{PodSubCgroups: subcgroups}}, + }) + if err != nil { + t.Fatalf("Unexpected error: %v", err) + } + + if len(resp.Pods) == 0 { + t.Errorf("Unexpected result: %v, should see non-zero pods", resp.Pods) + } + + for _, p := range resp.Pods { + checkPodDetails(t, ctx, p) + } + // Terminate the pod. if err := child.SendLine("Good bye"); err != nil { t.Fatalf("Failed to send message to the pod: %v", err) From 7bb2b5e85b8903242361d47ddc42403308f3200f Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Tue, 3 May 2016 14:02:53 +0200 Subject: [PATCH 0216/1304] docs: FirewallD caveat on Fedora --- Documentation/distributions.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Documentation/distributions.md b/Documentation/distributions.md index 6b86e3fa00..079eabd5ea 100644 --- a/Documentation/distributions.md +++ b/Documentation/distributions.md @@ -34,16 +34,19 @@ Or permanently disabled by editing `/etc/selinux/config`: SELINUX=permissive ``` -#### Caveat: firewall +#### Caveat: firewalld -The default firewall rules can block the traffic from rkt pods. -See [#2206](https://github.com/coreos/rkt/issues/2206). -As a workaround, they can be removed: +Fedora uses [firewalld](https://fedoraproject.org/wiki/FirewallD) to dynamically define firewall zones. +rkt is [not yet fully integrated with firewalld](https://github.com/coreos/rkt/issues/2206). +The default firewalld rules may interfere with the network connectivity of rkt pods. +To work around this, add a firewalld rule to allow pod traffic: ``` -sudo iptables -F -sudo iptables -F -t nat +sudo firewall-cmd --add-source=172.16.28.0/24 --zone=trusted ``` +172.16.28.0/24 is the subnet of the [default pod network](https://github.com/coreos/rkt/blob/master/Documentation/networking/overview.md#the-default-network). The command must be adapted when rkt is configured to use a [different network](https://github.com/coreos/rkt/blob/master/Documentation/networking/overview.md#setting-up-additional-networks) with a different subnet. + + ## Arch rkt is available in the [Arch User Repository (AUR)](https://aur.archlinux.org/packages/rkt). From 22897d1cbabf613b0a1ff2bf370f420805a0a627 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Tue, 3 May 2016 14:06:32 +0200 Subject: [PATCH 0217/1304] README.md: add a link to distributions.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c11bab146c..12611baa68 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ Check out the [roadmap](ROADMAP.md) for more details on the future of rkt. ## Trying out rkt To get started quickly using rkt for the first time, start with the ["trying out rkt" document](Documentation/trying-out-rkt.md). +Also check [rkt support on your Linux distribution](Documentation/distributions.md). For an end-to-end example of building an application from scratch and running it with rkt, check out the [getting started guide](Documentation/getting-started-guide.md). ## Getting help with rkt From d745a599ec8d5822f783ae53cbdd494062500f37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 4 May 2016 15:02:04 +0200 Subject: [PATCH 0218/1304] Documentation: how to update coreos flavor stage1 This adds instructions to update the CoreOS image use to build the coreos flavor stage1. We usually want to do this to get a newer version of systemd. --- Documentation/devel/update-coreos-stage1.md | 129 ++++++++++++++++++++ Documentation/hacking.md | 4 + 2 files changed, 133 insertions(+) create mode 100644 Documentation/devel/update-coreos-stage1.md diff --git a/Documentation/devel/update-coreos-stage1.md b/Documentation/devel/update-coreos-stage1.md new file mode 100644 index 0000000000..b51e138cb7 --- /dev/null +++ b/Documentation/devel/update-coreos-stage1.md @@ -0,0 +1,129 @@ +# Update coreos flavor stage1 + +This guide will guide you through updating the version of the coreos flavor of stage1. +We usually want to do this to update the systemd version used by the stage1. + +The process is quite manual because it's not done often, but improvements are welcomed. + +## Extract the root filesystem of the image + +Let's assume you want to update from version 991.0.0 to version 1032.0.0. + +First, you need to download and verify the image. +Make sure you trust the [CoreOS Image Signing Key](https://coreos.com/security/image-signing-key/). + +Since 1032.0.0 is currently only available in the Alpha channel, we'll use the alpha URL: + +``` +$ mkdir /tmp/coreos-image +$ curl -O https://alpha.release.core-os.net/amd64-usr/1032.0.0/coreos_production_pxe_image.cpio.gz + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed +100 222M 100 222M 0 0 7769k 0 0:00:29 0:00:29 --:--:-- 7790k +$ curl -O http://alpha.release.core-os.net/amd64-usr/1032.0.0/coreos_production_pxe_image.cpio.gz.sig + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed +100 543 100 543 0 0 495 0 0:00:01 0:00:01 --:--:-- 495 +$ gpg --verify coreos_production_pxe_image.cpio.gz.sig +gpg: assuming signed data in 'coreos_production_pxe_image.cpio.gz' +gpg: Signature made Thu 28 Apr 2016 04:54:00 AM CEST using RSA key ID 1CB5FA26 +gpg: checking the trustdb +gpg: marginals needed: 3 completes needed: 1 trust model: PGP +gpg: depth: 0 valid: 5 signed: 5 trust: 0-, 0q, 0n, 0m, 0f, 5u +gpg: depth: 1 valid: 5 signed: 0 trust: 3-, 0q, 0n, 0m, 2f, 0u +gpg: next trustdb check due at 2017-01-19 +gpg: Good signature from "CoreOS Buildbot (Offical Builds) " [ultimate] +``` + +Then you need to extract it: + +``` +$ gunzip coreos_production_pxe_image.cpio.gz +$ cpio -i < coreos_production_pxe_image.cpio +457785 blocks +$ unsquashfs usr.squashfs +Parallel unsquashfs: Using 4 processors +13445 inodes (14861 blocks) to write + + +write_xattr: could not write xattr security.capability for file squashfs-root/bin/arping because you're not superuser! + +write_xattr: to avoid this error message, either specify -user-xattrs, -no-xattrs, or run as superuser! + +Further error messages of this type are suppressed! +[======================================================================================================================================-] 14861/14861 100% + +created 12391 files +created 1989 directories +created 722 symlinks +created 0 devices +created 0 fifos +``` + +You should have now the rootfs of the image in the `squashfs-root` directory. + +## Update the manifest files + +Back to the rkt repo, in the directory `stage1/usr_from_coreos/manifest.d`, there are some manifest files that define which files are copied from the CoreOS image to the stage1 image. + +You need to go through all of them and check that the files listed correspond to files that are in the actual rootfs of the image (which we extracted in the previous step). + +Usually, there are some updated libraries which need an update on their version numbers. +In our case, there are no updates and all the files mentioned in the manifest are present in the updated CoreOS image. + +## Update the coreos flavor version used by the build system + +In the file `stage1/usr_from_coreos/coreos-common.mk`, we define which CoreOS image version we use for the coreos flavor. +Update `CCN_IMG_RELEASE` to 1032.0.0 and `CCN_SYSTEMD_VERSION` to the systemd version shipped with the image (in our case, v229). + +```diff +diff --git a/stage1/usr_from_coreos/coreos-common.mk b/stage1/usr_from_coreos/coreos-common.mk +index b5bfa77..f864f56 100644 +--- a/stage1/usr_from_coreos/coreos-common.mk ++++ b/stage1/usr_from_coreos/coreos-common.mk +@@ -9,9 +9,9 @@ _CCN_INCLUDED_ := x + $(call setup-tmp-dir,CCN_TMPDIR) + + # systemd version in coreos image +-CCN_SYSTEMD_VERSION := v225 ++CCN_SYSTEMD_VERSION := v229 + # coreos image version +-CCN_IMG_RELEASE := 991.0.0 ++CCN_IMG_RELEASE := 1032.0.0 + # coreos image URL + CCN_IMG_URL := https://alpha.release.core-os.net/amd64-usr/$(CCN_IMG_RELEASE)/coreos_production_pxe_image.cpio.gz + # path to downloaded pxe image +``` + +## Check that things work + +Once you're finished updating the manifest files and `coreos-common.mk`, do a clean build and try to run rkt. +If there are some new libraries missing from the image, you need to add them to the correspoding manifest file. + +For example, this update breaks systemd. +When you try to run rkt, you get this error: + +``` +/usr/lib/systemd/systemd: error while loading shared libraries: libpam.so.0: cannot open shared object file: No such file or directory +``` + +This means that we need to add libpam to the systemd manifest file: + +```diff +diff --git a/stage1/usr_from_coreos/manifest.d/systemd.manifest b/stage1/usr_from_coreos/manifest.d/systemd.manifest +index fca30bb..51d5fbc 100644 +--- a/stage1/usr_from_coreos/manifest.d/systemd.manifest ++++ b/stage1/usr_from_coreos/manifest.d/systemd.manifest +@@ -61,6 +61,9 @@ lib64/libmount.so.1 + lib64/libmount.so.1.1.0 + lib64/libnss_files-2.21.so + lib64/libnss_files.so.2 ++lib64/libpam.so ++lib64/libpam.so.0 ++lib64/libpam.so.0.84.1 + lib64/libpcre.so + lib64/libpcre.so.1 + lib64/libpcre.so.1.2.4 +``` + +After those two patches, the update is complete and rkt works fine with the new image. diff --git a/Documentation/hacking.md b/Documentation/hacking.md index 3cd36ce0e2..a87f958b57 100644 --- a/Documentation/hacking.md +++ b/Documentation/hacking.md @@ -89,6 +89,10 @@ rkt expects stage1 images to be signed except in the following cases: * `--stage1-{name,hash}` is used and the image is already in the store * `--stage1-{url,path,from-dir}` is used and the image is in the default directory configured at build time +### Updating the coreos flavor stage1 + +Follow the instructions on [Update coreos flavor stage1](devel/update-coreos-stage1.md). + ## Managing dependencies rkt uses [`godep`](https://github.com/tools/godep) to manage third-party dependencies. From 861593fc57c7b24f4be7828e303a87616844ec2b Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Wed, 4 May 2016 15:13:09 +0200 Subject: [PATCH 0219/1304] Documentation: update Arch Linux documentation Partially fixes #2202 --- Documentation/distributions.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Documentation/distributions.md b/Documentation/distributions.md index 6b86e3fa00..d30cb918e9 100644 --- a/Documentation/distributions.md +++ b/Documentation/distributions.md @@ -46,8 +46,10 @@ sudo iptables -F -t nat ## Arch -rkt is available in the [Arch User Repository (AUR)](https://aur.archlinux.org/packages/rkt). -Installing instructions are available in the [AUR installing packages documentation](https://wiki.archlinux.org/index.php/Arch_User_Repository#Installing_packages) or you can use an [AUR helper](https://wiki.archlinux.org/index.php/AUR_helpers). +rkt is available in the [Community Repository](https://www.archlinux.org/packages/community/x86_64/rkt/) and can be installed using pacman: +``` +sudo pacman -S rkt +``` ## Void From 4586596b40016a42e96a1d2bc746bd7e77df1e7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chris=20K=C3=BChl?= Date: Fri, 6 May 2016 14:54:07 +0200 Subject: [PATCH 0220/1304] docs: remove indef articles from start of arg doc strings --- rkt/prepare.go | 2 +- rkt/run.go | 2 +- rkt/stage1hash.go | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/rkt/prepare.go b/rkt/prepare.go index 061028411e..8b537128cb 100644 --- a/rkt/prepare.go +++ b/rkt/prepare.go @@ -59,7 +59,7 @@ func init() { cmdPrepare.Flags().BoolVar(&flagInheritEnv, "inherit-env", false, "inherit all environment variables not set by apps") cmdPrepare.Flags().BoolVar(&flagNoOverlay, "no-overlay", false, "disable overlay filesystem") cmdPrepare.Flags().BoolVar(&flagPrivateUsers, "private-users", false, "run within user namespaces.") - cmdPrepare.Flags().Var(&flagExplicitEnv, "set-env", "an environment variable to set for apps in the form name=value") + cmdPrepare.Flags().Var(&flagExplicitEnv, "set-env", "environment variable to set for apps in the form name=value") cmdPrepare.Flags().BoolVar(&flagStoreOnly, "store-only", false, "use only available images in the store (do not discover or download from remote URLs)") cmdPrepare.Flags().BoolVar(&flagNoStore, "no-store", false, "fetch images ignoring the local store") cmdPrepare.Flags().StringVar(&flagPodManifest, "pod-manifest", "", "the path to the pod manifest. If it's non-empty, then only '--quiet' and '--no-overlay' will have effect") diff --git a/rkt/run.go b/rkt/run.go index 3762d307ba..6f1198c7d1 100644 --- a/rkt/run.go +++ b/rkt/run.go @@ -80,7 +80,7 @@ func init() { cmdRun.Flags().BoolVar(&flagInheritEnv, "inherit-env", false, "inherit all environment variables not set by apps") cmdRun.Flags().BoolVar(&flagNoOverlay, "no-overlay", false, "disable overlay filesystem") cmdRun.Flags().BoolVar(&flagPrivateUsers, "private-users", false, "run within user namespaces.") - cmdRun.Flags().Var(&flagExplicitEnv, "set-env", "an environment variable to set for apps in the form name=value") + cmdRun.Flags().Var(&flagExplicitEnv, "set-env", "environment variable to set for apps in the form name=value") cmdRun.Flags().BoolVar(&flagInteractive, "interactive", false, "run pod interactively. If true, only one image may be supplied.") cmdRun.Flags().Var(&flagDNS, "dns", "name servers to write in /etc/resolv.conf") cmdRun.Flags().Var(&flagDNSSearch, "dns-search", "DNS search domains to write in /etc/resolv.conf") diff --git a/rkt/stage1hash.go b/rkt/stage1hash.go index 56338133cd..fdb6362bd0 100644 --- a/rkt/stage1hash.go +++ b/rkt/stage1hash.go @@ -114,35 +114,35 @@ var ( kind: stage1ImageLocationURL, flag: "stage1-url", name: "stage1URL", - help: "a URL to an image to use as stage1", + help: "URL to an image to use as stage1", }, stage1ImageLocationPath: { kind: stage1ImageLocationPath, flag: "stage1-path", name: "stage1Path", - help: "an absolute or a relative path to an image to use as stage1", + help: "absolute or relative path to an image to use as stage1", }, stage1ImageLocationName: { kind: stage1ImageLocationName, flag: "stage1-name", name: "stage1Name", - help: "a name of an image to use as stage1", + help: "name of an image to use as stage1", }, stage1ImageLocationHash: { kind: stage1ImageLocationHash, flag: "stage1-hash", name: "stage1Hash", - help: "a hash of an image to use as stage1", + help: "hash of an image to use as stage1", }, stage1ImageLocationFromDir: { kind: stage1ImageLocationFromDir, flag: "stage1-from-dir", name: "stage1FromDir", - help: "a filename of an image in stage1 images directory to use as stage1", + help: "filename of an image in stage1 images directory to use as stage1", }, } // location to stage1 image overridden by one of --stage1-* From e6072e481f6916a443209a54045e1bf93568afba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chris=20K=C3=BChl?= Date: Fri, 6 May 2016 14:54:56 +0200 Subject: [PATCH 0221/1304] docs: fix rkt run-prepared's --interactive doc string --- rkt/run_prepared.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rkt/run_prepared.go b/rkt/run_prepared.go index 075bf616d6..787f1f95b2 100644 --- a/rkt/run_prepared.go +++ b/rkt/run_prepared.go @@ -44,7 +44,7 @@ func init() { cmdRunPrepared.Flags().Var(&flagDNS, "dns", "name servers to write in /etc/resolv.conf") cmdRunPrepared.Flags().Var(&flagDNSSearch, "dns-search", "DNS search domains to write in /etc/resolv.conf") cmdRunPrepared.Flags().Var(&flagDNSOpt, "dns-opt", "DNS options to write in /etc/resolv.conf") - cmdRunPrepared.Flags().BoolVar(&flagInteractive, "interactive", false, "the pod is interactive") + cmdRunPrepared.Flags().BoolVar(&flagInteractive, "interactive", false, "run pod interactively") cmdRunPrepared.Flags().BoolVar(&flagMDSRegister, "mds-register", false, "register pod with metadata service") cmdRunPrepared.Flags().StringVar(&flagHostname, "hostname", "", `pod's hostname. If empty, it will be "rkt-$PODUUID"`) } From c59f791a3dcac3566538544529aa7910ac00a4c3 Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Mon, 9 May 2016 10:49:53 +0300 Subject: [PATCH 0222/1304] stage0: check and create /etc Checks '/etc' before writing to '/etc/rkt-resolv.conf' and create it with default permissions if it doesn't exist. --- stage0/run.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/stage0/run.go b/stage0/run.go index a9a1dd9647..ed1d45e6af 100644 --- a/stage0/run.go +++ b/stage0/run.go @@ -415,6 +415,12 @@ func addResolvConf(cfg RunConfig, rootfs string) { } content += "\n" + if err := os.Mkdir(filepath.Join(rootfs, "etc"), defaultRegularDirPerm); err != nil { + if !os.IsExist(err) { + log.Fatalf("error creating dir %q: %v\n", "/etc", err) + } + } + if err := ioutil.WriteFile(filepath.Join(rootfs, "etc/rkt-resolv.conf"), []byte(content), 0644); err != nil { log.Fatalf("error writing /etc/rkt-resolv.conf: %v\n", err) } From dc8b2fb9a9dca2251d62b0724dea830d1bf21da5 Mon Sep 17 00:00:00 2001 From: Michal Rostecki Date: Sat, 7 May 2016 20:18:26 +0200 Subject: [PATCH 0223/1304] lkvm: Bump the version of upstream repository glibc >= 2.23 deprecated the readdir_r usage in favor of readdir. Build of lkvm is treating warnings as errors, so it's impossible to build rkt with kvm flawor with the newest glibc. That was fixed in the upstream commit[1]. Also, the another commit[2] fixed an issue with dead lock on reboot, so dead_lock_fix patch isn't needed anymore. [1] https://kernel.googlesource.com/pub/scm/linux/kernel/git/will/kvmtool/+/d62653e177597251c24494a6dda60acd6d846671 [2] https://kernel.googlesource.com/pub/scm/linux/kernel/git/will/kvmtool/+/e8cb90fb9697da24cdf553a1b8cf120f94c20832 Fixes #2594 Signed-off-by: Michal Rostecki --- stage1/usr_from_kvm/lkvm.mk | 2 +- .../lkvm/patches/dead_lock_fix.patch | 53 ------------------- 2 files changed, 1 insertion(+), 54 deletions(-) delete mode 100644 stage1/usr_from_kvm/lkvm/patches/dead_lock_fix.patch diff --git a/stage1/usr_from_kvm/lkvm.mk b/stage1/usr_from_kvm/lkvm.mk index c7a60e4e78..81ded66447 100644 --- a/stage1/usr_from_kvm/lkvm.mk +++ b/stage1/usr_from_kvm/lkvm.mk @@ -5,7 +5,7 @@ LKVM_BINARY := $(LKVM_SRCDIR)/lkvm-static LKVM_ACI_BINARY := $(S1_RF_ACIROOTFSDIR)/lkvm LKVM_GIT := https://kernel.googlesource.com/pub/scm/linux/kernel/git/will/kvmtool # just last published version (for reproducible builds), not for any other reason -LKVM_VERSION := 3c8aec9e2b5066412390559629dabeb7816ee8f2 +LKVM_VERSION := d62653e177597251c24494a6dda60acd6d846671 LKVM_STUFFDIR := $(MK_SRCDIR)/lkvm LKVM_PATCHESDIR := $(LKVM_STUFFDIR)/patches diff --git a/stage1/usr_from_kvm/lkvm/patches/dead_lock_fix.patch b/stage1/usr_from_kvm/lkvm/patches/dead_lock_fix.patch deleted file mode 100644 index 67b56da31f..0000000000 --- a/stage1/usr_from_kvm/lkvm/patches/dead_lock_fix.patch +++ /dev/null @@ -1,53 +0,0 @@ -diff --git a/builtin-run.c b/builtin-run.c -index 54e03be..fab97e0 100644 ---- a/builtin-run.c -+++ b/builtin-run.c -@@ -633,16 +633,38 @@ static struct kvm *kvm_cmd_run_init(int argc, const char **argv) - - static int kvm_cmd_run_work(struct kvm *kvm) - { -- int i; -- void *ret = NULL; -- -- for (i = 0; i < kvm->nrcpus; i++) { -- if (pthread_create(&kvm->cpus[i]->thread, NULL, kvm_cpu_thread, kvm->cpus[i]) != 0) -- die("unable to create KVM VCPU thread"); -- } -- -- /* Only VCPU #0 is going to exit by itself when shutting down */ -- return pthread_join(kvm->cpus[0]->thread, &ret); -+ int i; -+ int exit_status = 0; -+ -+ for (i = 0; i < kvm->nrcpus; i++) { -+ if (pthread_create(&kvm->cpus[i]->thread, NULL, kvm_cpu_thread, kvm->cpus[i]) != 0) -+ die("unable to create KVM VCPU thread"); -+ } -+ -+ /* -+ * Only VCPU #0 is going to exit by itself when shutting down -+ * -+ * BUT It's not actually true for reboot sequence -+ * Reboot is sending SIGKVMEXIT signal to all cpus -+ * and that is causing race condition on removing -+ * devices (which are pausing exiting cpus). -+ * This piece of code waits for death of all -+ * cpu threads -+ */ -+ for (i = 0; i < kvm->nrcpus; i++) { -+ -+ void* thrstatus = NULL; -+ -+ int retval = pthread_join(kvm->cpus[i]->thread, &thrstatus); -+ -+ if (retval != 0) -+ die("unable to end KVM VCPU thread"); -+ -+ /* Set exit status if one of vcpus returns error code > 0 */ -+ if ((intptr_t) thrstatus != 0) -+ exit_status = (intptr_t) thrstatus; -+ } -+ return exit_status; - } - - static void kvm_cmd_run_exit(struct kvm *kvm, int guest_ret) From 023ee1fa3d88ddcc671be159e3efdb4b21ac5a61 Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Wed, 13 Apr 2016 23:13:10 +0200 Subject: [PATCH 0224/1304] net/portfwd: choose network according to ipmasq When a network has ipmasq enabled, CNI generates masquerading rules for the networks subnet. These rules are appended, so the first network is the most upper one. Hence, rkt needs to use the address of first masqueraded network as packets will always hit this subnet's CNI rule first. If no network has ipmasq enabled, we default to the previous behavior of using the last loaded network, which is either the default or default-restricted network. --- Documentation/networking/overview.md | 8 ++++++ networking/kvm.go | 6 +++- networking/networking.go | 43 ++++++++++++++++++++++------ 3 files changed, 48 insertions(+), 9 deletions(-) diff --git a/Documentation/networking/overview.md b/Documentation/networking/overview.md index 964aff3941..02a280d338 100644 --- a/Documentation/networking/overview.md +++ b/Documentation/networking/overview.md @@ -332,6 +332,14 @@ The pod's TCP port 80 can be mapped to an arbitrary port on the host during rkt Now, any traffic arriving on host's TCP port 8888 will be forwarded to the pod on port 80. +### Network used for forwarded ports + +The network that will be chosen for the port forwarding depends on the _ipMasq_ setting of the configured networks. +If at least one of them has _ipMasq_ enabled, the forwarded traffic will be passed through the first loaded network that has IP masquerading enabled. +If no network is masqueraded, the last loaded network will be used. +As a reminder, the sort order of the loaded networks is detailed in the chapter about [setting up additional networks](#setting-up-additional-networks). + +### Socket Activation rkt also supports socket activation. This is documented in [Socket-activated service](../using-rkt-with-systemd.md#socket-activated-service). diff --git a/networking/kvm.go b/networking/kvm.go index 2b23a844e1..0329cf3ee9 100644 --- a/networking/kvm.go +++ b/networking/kvm.go @@ -552,7 +552,11 @@ func kvmSetup(podRoot string, podID types.UUID, fps []ForwardedPort, netList com } network.nets[i] = n } - err := network.forwardPorts(fps, network.GetDefaultIP()) + defaultIP, err := network.GetDefaultIP() + if err != nil { + return nil, err + } + err = network.forwardPorts(fps, defaultIP) if err != nil { return nil, err } diff --git a/networking/networking.go b/networking/networking.go index a7d0ba15f7..c985bec60b 100644 --- a/networking/networking.go +++ b/networking/networking.go @@ -121,7 +121,11 @@ func Setup(podRoot string, podID types.UUID, fps []ForwardedPort, netList common if err = n.enableDefaultLocalnetRouting(); err != nil { return err } - if err := n.forwardPorts(fps, n.GetDefaultIP()); err != nil { + defaultIP, err := n.GetDefaultIP() + if err != nil { + return err + } + if err := n.forwardPorts(fps, defaultIP); err != nil { n.unforwardPorts() return err } @@ -229,18 +233,41 @@ func Load(podRoot string, podID *types.UUID) (*Networking, error) { }, nil } -func (n *Networking) GetDefaultIP() net.IP { - if len(n.nets) == 0 { - return nil +// GetDefaultNet iterates through all loaded networks and returns either +// the first network that has masquerading enabled, +// or the last network in case there is no masqueraded one, +// or an error if no network was loaded. +func (n *Networking) GetDefaultNet() (*activeNet, error) { + numberNets := len(n.nets) + if numberNets == 0 { + return nil, fmt.Errorf("no networks found") + } + for _, net := range n.nets { + if net.IPMasq() { + return &net, nil + } } - return n.nets[len(n.nets)-1].runtime.IP + return &n.nets[numberNets-1], nil } +// GetDefaultIP uses GetDefaultNet() to determine the default network and then +// returns the Pod's IP of that network. +func (n *Networking) GetDefaultIP() (net.IP, error) { + net, err := n.GetDefaultNet() + if err != nil { + return nil, err + } + return net.runtime.IP, nil +} + +// GetDefaultHostIP uses GetDefaultNet() to determine the default network and then +// returns the Host's IP of that network. func (n *Networking) GetDefaultHostIP() (net.IP, error) { - if len(n.nets) == 0 { - return nil, fmt.Errorf("no networks found") + net, err := n.GetDefaultNet() + if err != nil { + return nil, err } - return n.nets[len(n.nets)-1].runtime.HostIP, nil + return net.runtime.HostIP, nil } // GetIfacesByIP searches for and returns the interfaces with the given IP From 993b93350f9ceef70c9209ef8b6e1c909501d41f Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Thu, 14 Apr 2016 12:17:46 +0200 Subject: [PATCH 0225/1304] net/portfwd: allow host/pod port to differ --- networking/portfwd.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/networking/portfwd.go b/networking/portfwd.go index acdd9c4a4d..db43d27871 100644 --- a/networking/portfwd.go +++ b/networking/portfwd.go @@ -22,7 +22,7 @@ import ( "github.com/coreos/go-iptables/iptables" ) -func (e *podEnv) forwardPorts(fps []ForwardedPort, defIP net.IP) error { +func (e *podEnv) forwardPorts(fps []ForwardedPort, podIP net.IP) error { if len(fps) == 0 { return nil } @@ -70,9 +70,9 @@ func (e *podEnv) forwardPorts(fps []ForwardedPort, defIP net.IP) error { for _, p := range fps { - dst := fmt.Sprintf("%v:%v", defIP, p.PodPort) - dstIP := fmt.Sprintf("%v", defIP) - dport := strconv.Itoa(int(p.HostPort)) + socketPod := fmt.Sprintf("%v:%v", podIP, p.PodPort) + dstPortHost := strconv.Itoa(int(p.HostPort)) + dstPortPod := strconv.Itoa(int(p.PodPort)) for _, r := range []struct { chain string @@ -82,9 +82,9 @@ func (e *podEnv) forwardPorts(fps []ForwardedPort, defIP net.IP) error { chainDNAT, []string{ "-p", p.Protocol, - "--dport", dport, + "--dport", dstPortHost, "-j", "DNAT", - "--to-destination", dst, + "--to-destination", socketPod, }, }, { // Rewrite the source for connections to localhost on the host @@ -92,8 +92,8 @@ func (e *podEnv) forwardPorts(fps []ForwardedPort, defIP net.IP) error { []string{ "-p", p.Protocol, "-s", "127.0.0.1", - "-d", dstIP, - "--dport", dport, + "-d", podIP.String(), + "--dport", dstPortPod, "-j", "MASQUERADE", }, }, From 90f8bfd799593b62bc638f34c21d006060c2b26b Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Wed, 27 Apr 2016 10:38:15 +0200 Subject: [PATCH 0226/1304] net/portfwd: refactor related methods --- networking/kvm.go | 5 ++-- networking/networking.go | 51 +++------------------------------------- networking/portfwd.go | 45 +++++++++++++++++++++++++++++++++++ stage1/init/init.go | 2 +- 4 files changed, 51 insertions(+), 52 deletions(-) diff --git a/networking/kvm.go b/networking/kvm.go index 0329cf3ee9..7753680234 100644 --- a/networking/kvm.go +++ b/networking/kvm.go @@ -552,12 +552,11 @@ func kvmSetup(podRoot string, podID types.UUID, fps []ForwardedPort, netList com } network.nets[i] = n } - defaultIP, err := network.GetDefaultIP() + podIP, err := network.GetForwardableNetPodIP() if err != nil { return nil, err } - err = network.forwardPorts(fps, defaultIP) - if err != nil { + if err := network.forwardPorts(fps, podIP); err != nil { return nil, err } diff --git a/networking/networking.go b/networking/networking.go index c985bec60b..61ec25c0c4 100644 --- a/networking/networking.go +++ b/networking/networking.go @@ -40,14 +40,6 @@ const ( selfNetNS = "/proc/self/ns/net" ) -// ForwardedPort describes a port that will be -// forwarded (mapped) from the host to the pod -type ForwardedPort struct { - Protocol string - HostPort uint - PodPort uint -} - // Networking describes the networking details of a pod. type Networking struct { podEnv @@ -121,11 +113,11 @@ func Setup(podRoot string, podID types.UUID, fps []ForwardedPort, netList common if err = n.enableDefaultLocalnetRouting(); err != nil { return err } - defaultIP, err := n.GetDefaultIP() + podIP, err := n.GetForwardableNetPodIP() if err != nil { return err } - if err := n.forwardPorts(fps, defaultIP); err != nil { + if err := n.forwardPorts(fps, podIP); err != nil { n.unforwardPorts() return err } @@ -145,7 +137,7 @@ func Setup(podRoot string, podID types.UUID, fps []ForwardedPort, netList common func (n *Networking) enableDefaultLocalnetRouting() error { routeLocalnetFormat := "" - defaultHostIP, err := n.GetDefaultHostIP() + defaultHostIP, err := n.GetForwardableNetHostIP() if err != nil { return err } @@ -233,43 +225,6 @@ func Load(podRoot string, podID *types.UUID) (*Networking, error) { }, nil } -// GetDefaultNet iterates through all loaded networks and returns either -// the first network that has masquerading enabled, -// or the last network in case there is no masqueraded one, -// or an error if no network was loaded. -func (n *Networking) GetDefaultNet() (*activeNet, error) { - numberNets := len(n.nets) - if numberNets == 0 { - return nil, fmt.Errorf("no networks found") - } - for _, net := range n.nets { - if net.IPMasq() { - return &net, nil - } - } - return &n.nets[numberNets-1], nil -} - -// GetDefaultIP uses GetDefaultNet() to determine the default network and then -// returns the Pod's IP of that network. -func (n *Networking) GetDefaultIP() (net.IP, error) { - net, err := n.GetDefaultNet() - if err != nil { - return nil, err - } - return net.runtime.IP, nil -} - -// GetDefaultHostIP uses GetDefaultNet() to determine the default network and then -// returns the Host's IP of that network. -func (n *Networking) GetDefaultHostIP() (net.IP, error) { - net, err := n.GetDefaultNet() - if err != nil { - return nil, err - } - return net.runtime.HostIP, nil -} - // GetIfacesByIP searches for and returns the interfaces with the given IP // Disregards the subnet mask since not every net.IP object contains // On success it will return the list of found interfaces diff --git a/networking/portfwd.go b/networking/portfwd.go index db43d27871..3eb1bf4110 100644 --- a/networking/portfwd.go +++ b/networking/portfwd.go @@ -22,6 +22,51 @@ import ( "github.com/coreos/go-iptables/iptables" ) +// ForwardedPort describes a port that will be +// forwarded (mapped) from the host to the pod +type ForwardedPort struct { + Protocol string + HostPort uint + PodPort uint +} + +// GetForwardableNet iterates through all loaded networks and returns either +// the first network that has masquerading enabled, +// or the last network in case there is no masqueraded one, +// or an error if no network was loaded. +func (n *Networking) GetForwardableNet() (*activeNet, error) { + numberNets := len(n.nets) + if numberNets == 0 { + return nil, fmt.Errorf("no networks found") + } + for _, net := range n.nets { + if net.IPMasq() { + return &net, nil + } + } + return &n.nets[numberNets-1], nil +} + +// GetForwardableNetPodIP uses GetForwardableNet() to determine the default network and then +// returns the Pod's IP of that network. +func (n *Networking) GetForwardableNetPodIP() (net.IP, error) { + net, err := n.GetForwardableNet() + if err != nil { + return nil, err + } + return net.runtime.IP, nil +} + +// GetForwardableNetHostIP uses GetForwardableNet() to determine the default network and then +// returns the Host's IP of that network. +func (n *Networking) GetForwardableNetHostIP() (net.IP, error) { + net, err := n.GetForwardableNet() + if err != nil { + return nil, err + } + return net.runtime.HostIP, nil +} + func (e *podEnv) forwardPorts(fps []ForwardedPort, podIP net.IP) error { if len(fps) == 0 { return nil diff --git a/stage1/init/init.go b/stage1/init/init.go index cdcb7d5c20..94f2730218 100644 --- a/stage1/init/init.go +++ b/stage1/init/init.go @@ -532,7 +532,7 @@ func stage1() int { } if len(mdsToken) > 0 { - hostIP, err := n.GetDefaultHostIP() + hostIP, err := n.GetForwardableNetHostIP() if err != nil { log.PrintE("failed to get default Host IP", err) return 1 From 9678c97fc6c6400c6be11866eeb16f69b68cff23 Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Wed, 6 Apr 2016 19:14:07 +0200 Subject: [PATCH 0227/1304] tests/net: add more port forwarding cases * bridged network * different host port than application port --- tests/rkt_net_kvm_test.go | 6 ++--- tests/rkt_net_nspawn_test.go | 14 +++++++--- tests/rkt_net_test.go | 51 +++++++++++++++++++++++++++++------- 3 files changed, 55 insertions(+), 16 deletions(-) diff --git a/tests/rkt_net_kvm_test.go b/tests/rkt_net_kvm_test.go index 59ecb3680d..79acb909b8 100644 --- a/tests/rkt_net_kvm_test.go +++ b/tests/rkt_net_kvm_test.go @@ -18,9 +18,9 @@ package main import "testing" -func TestNetDefaultPortFwdConnectivity(t *testing.T) { - NewNetDefaultPortFwdConnectivityTest( - PortFwdCase{"172.16.28.1", "--net=default", true}, +func TestNetPortFwdConnectivity(t *testing.T) { + NewNetPortFwdConnectivityTest( + defaultSamePortFwdCase, ).Execute(t) } diff --git a/tests/rkt_net_nspawn_test.go b/tests/rkt_net_nspawn_test.go index a32a3bc93e..905c5a588d 100644 --- a/tests/rkt_net_nspawn_test.go +++ b/tests/rkt_net_nspawn_test.go @@ -26,10 +26,16 @@ func TestNetHostConnectivity(t *testing.T) { NewNetHostConnectivityTest().Execute(t) } -func TestNetDefaultPortFwdConnectivity(t *testing.T) { - NewNetDefaultPortFwdConnectivityTest( - PortFwdCase{"172.16.28.1", "--net=default", true}, - PortFwdCase{"127.0.0.1", "--net=default", true}, +func TestNetPortFwdConnectivity(t *testing.T) { + NewNetPortFwdConnectivityTest( + defaultSamePortFwdCase, + defaultDiffPortFwdCase, + defaultLoSamePortFwdCase, + defaultLoDiffPortFwdCase, + bridgeSamePortFwdCase, + bridgeDiffPortFwdCase, + bridgeLoSamePortFwdCase, + bridgeLoDiffPortFwdCase, ).Execute(t) } diff --git a/tests/rkt_net_test.go b/tests/rkt_net_test.go index 6c69fb3669..58eb30b4a7 100644 --- a/tests/rkt_net_test.go +++ b/tests/rkt_net_test.go @@ -350,24 +350,60 @@ func TestNetDefaultRestrictedConnectivity(t *testing.T) { type PortFwdCase struct { HttpGetIP string + HttpServePort int RktArg string ShouldSucceed bool } +var ( + bannedPorts = make(map[int]struct{}, 0) + + defaultSamePortFwdCase = PortFwdCase{"172.16.28.1", 0, "--net=default", true} + defaultDiffPortFwdCase = PortFwdCase{"172.16.28.1", 1024, "--net=default", true} + defaultLoSamePortFwdCase = PortFwdCase{"127.0.0.1", 0, "--net=default", true} + defaultLoDiffPortFwdCase = PortFwdCase{"127.0.0.1", 1014, "--net=default", true} + + portFwdBridge = networkTemplateT{ + Name: "bridge1", + Type: "bridge", + Bridge: "bridge1", + IpMasq: true, + IsGateway: true, + Ipam: ipamTemplateT{ + Type: "host-local", + Subnet: "11.11.5.0/24", + Routes: []map[string]string{ + {"dst": "0.0.0.0/0"}, + }, + }, + } + bridgeSamePortFwdCase = PortFwdCase{"11.11.5.1", 0, "--net=" + portFwdBridge.Name, true} + bridgeDiffPortFwdCase = PortFwdCase{"11.11.5.1", 1024, "--net=" + portFwdBridge.Name, true} + bridgeLoSamePortFwdCase = PortFwdCase{"127.0.0.1", 0, "--net=" + portFwdBridge.Name, true} + bridgeLoDiffPortFwdCase = PortFwdCase{"127.0.0.1", 1024, "--net=" + portFwdBridge.Name, true} +) + func (ct PortFwdCase) Execute(t *testing.T, ctx *testutils.RktRunCtx) { + netdir := prepareTestNet(t, ctx, portFwdBridge) + defer os.RemoveAll(netdir) - bannedPorts := make(map[int]struct{}, 0) httpPort, err := testutils.GetNextFreePort4Banned(bannedPorts) if err != nil { t.Fatalf("%v", err) } bannedPorts[httpPort] = struct{}{} - httpServeAddr := fmt.Sprintf("0.0.0.0:%d", httpPort) + httpServePort := ct.HttpServePort + if httpServePort == 0 { + httpServePort = httpPort + } + + httpServeAddr := fmt.Sprintf("0.0.0.0:%d", httpServePort) testImageArgs := []string{ - fmt.Sprintf("--ports=http,protocol=tcp,port=%d", httpPort), + fmt.Sprintf("--ports=http,protocol=tcp,port=%d", httpServePort), fmt.Sprintf("--exec=/inspect --serve-http=%v", httpServeAddr), } + t.Logf("testImageArgs: %v", testImageArgs) testImage := patchTestACI("rkt-inspect-networking.aci", testImageArgs...) defer os.Remove(testImage) @@ -410,10 +446,6 @@ func (ct PortFwdCase) Execute(t *testing.T, ctx *testutils.RktRunCtx) { }() ga.Wait() - - // TODO: ensure that default-restricted is not accessible from non-host - // f("172.16.28.1", "--net=default-restricted", true) - // f("127.0.0.1", "--net=default-restricted", true) } type portFwdTest []PortFwdCase @@ -428,12 +460,12 @@ func (ct portFwdTest) Execute(t *testing.T) { } /* - * Default net port forwarding connectivity + * Net port forwarding connectivity * --- * Container launches http server on all its interfaces * Host must be able to connect to container's http server on it's own interfaces */ -func NewNetDefaultPortFwdConnectivityTest(cases ...PortFwdCase) testutils.Test { +func NewNetPortFwdConnectivityTest(cases ...PortFwdCase) testutils.Test { return portFwdTest(cases) } @@ -465,6 +497,7 @@ type networkTemplateT struct { Master string `json:"master,omitempty"` IpMasq bool IsGateway bool + Bridge string `json:"bridge,omitempty"` Ipam ipamTemplateT } From f6fcfb66362459042a216267bbc77f28994e6729 Mon Sep 17 00:00:00 2001 From: Matthias Jahn Date: Tue, 10 May 2016 16:31:59 +0200 Subject: [PATCH 0228/1304] docs: Change getting started guide to build a static binary Current build command would not work after #2506 Fixes #2584 --- Documentation/getting-started-guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/getting-started-guide.md b/Documentation/getting-started-guide.md index 98f654447d..3c2bb4f33f 100644 --- a/Documentation/getting-started-guide.md +++ b/Documentation/getting-started-guide.md @@ -28,7 +28,7 @@ Next we need to build our application. We are going to statically link our app so we can ship an App Container Image with no external dependencies. ``` -$ CGO_ENABLED=0 GOOS=linux go build -o hello -a -tags netgo -ldflags '-w' . +$ CGO_ENABLED=0 go build -ldflags '-extldflags "-static"' ``` Before proceeding, verify that the produced binary is statically linked: From 495d5f65927273658601e71f89dc63a45b2a3dd8 Mon Sep 17 00:00:00 2001 From: Michal Rostecki Date: Tue, 10 May 2016 17:54:14 +0200 Subject: [PATCH 0229/1304] build: check for openssl headers for kvm flavor To use kernel sources during kvm flavor build, openssl headers are needed. Also update information about dependencies in documentation. --- Documentation/dependencies.md | 5 ++++- Documentation/hacking.md | 3 ++- configure.ac | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Documentation/dependencies.md b/Documentation/dependencies.md index 4efbe99463..f8339a7a79 100644 --- a/Documentation/dependencies.md +++ b/Documentation/dependencies.md @@ -52,7 +52,10 @@ For the most part the codebase is self-contained (e.g. all dependencies are vend * patch * tar * xz -* build dependencies for kernel +* [build dependencies for kernel](https://www.kernel.org/doc/Documentation/Changes) + * bc + * binutils + * openssl * build dependencies for lkvm ### Specific dependencies for the src flavor diff --git a/Documentation/hacking.md b/Documentation/hacking.md index a87f958b57..5477f4945c 100644 --- a/Documentation/hacking.md +++ b/Documentation/hacking.md @@ -33,7 +33,7 @@ Alternatively, you can build rkt in a Docker container with the following comman Replace `$SRC` with the absolute path to your rkt source code: ``` -# docker run -v $SRC:/opt/rkt -i -t golang:1.5 /bin/bash -c "apt-get update && apt-get install -y coreutils cpio squashfs-tools realpath autoconf file xz-utils patch bc && cd /opt/rkt && go get github.com/appc/spec/... && ./autogen.sh && ./configure && make" +# docker run -v $SRC:/opt/rkt -i -t golang:1.5 /bin/bash -c "apt-get update && apt-get install -y coreutils cpio squashfs-tools realpath autoconf file xz-utils patch bc libacl1-dev libtspi-dev libssl-dev && cd /opt/rkt && go get github.com/appc/spec/... && ./autogen.sh && ./configure && make" ``` ### Building systemd in stage1 from source @@ -69,6 +69,7 @@ If building with docker, these must be added to the `apt-get install` command. * xz-utils * patch * bc +* libssl-dev ### Alternative stage1 paths diff --git a/configure.ac b/configure.ac index 0f301fc0ba..bdba629c22 100644 --- a/configure.ac +++ b/configure.ac @@ -289,7 +289,11 @@ RKT_ITERATE_FLAVORS([${RKT_STAGE1_FLAVORS}],[flavor], RKT_COMMON_COREOS_PROGS RKT_REQ_PROG([PATCH],[patch],[patch]) RKT_REQ_PROG([TAR],[tar],[tar]) - RKT_REQ_PROG([XZ],[xz],[xz])], + RKT_REQ_PROG([XZ],[xz],[xz]) + AC_CHECK_HEADER([openssl/bio.h], + [], + [AC_MSG_ERROR([** No development headers for openssl found])], + [AC_INCLUDES_DEFAULT])], [host], [], [fly], From 316f400a598d6de041c887844b517fc50133035a Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Wed, 11 May 2016 11:29:32 +0300 Subject: [PATCH 0230/1304] tests: simplify for loop conditions For loop invocation is simplified to comply with `gofmt -s` --- tests/rkt-monitor/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/rkt-monitor/main.go b/tests/rkt-monitor/main.go index 300a1cbf29..8679aa3344 100644 --- a/tests/rkt-monitor/main.go +++ b/tests/rkt-monitor/main.go @@ -114,7 +114,7 @@ func runRktMonitor(cmd *cobra.Command, args []string) { c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt) go func() { - for _ = range c { + for range c { err := killAllChildren(int32(execCmd.Process.Pid)) if err != nil { fmt.Fprintf(os.Stderr, "cleanup failed: %v\n", err) From 27fea8451b427b1891fc22bee5a2971c0856f368 Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Fri, 22 Apr 2016 15:13:57 +0300 Subject: [PATCH 0231/1304] tests: invoke gofmt with simplify-code flag Enables code simplification checks of gofmt. Related to #2462 --- tests/tests.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests.mk b/tests/tests.mk index b462e3af21..4ac27d653b 100644 --- a/tests/tests.mk +++ b/tests/tests.mk @@ -16,7 +16,7 @@ $(TST_SHORT_TESTS_STAMP): $(VQ) \ set -e; \ $(call vb,vt,GOFMT,$(TST_GOFMT_DIRS)) \ - res=$$($(GOFMT) -l $(TST_GOFMT_DIRS)); \ + res=$$($(GOFMT) -s -l $(TST_GOFMT_DIRS)); \ if [ -n "$${res}" ]; then echo -e "gofmt checking failed:\n$${res}"; exit 1; fi; \ $(call vb,vt,GO VET,$(TST_GO_VET_PACKAGES)) \ res=$$($(GO_ENV) "$(GO)" vet $(TST_GO_VET_PACKAGES)); \ From b8ee0d658e12eef4bc2c4fee372091cd1e321ccc Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Tue, 19 Apr 2016 10:12:03 +0300 Subject: [PATCH 0232/1304] rkt: simplify if-else chains and spacing Refactors the if-else chains for readability Fixes #2421 --- rkt/rkt.go | 67 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 27 deletions(-) diff --git a/rkt/rkt.go b/rkt/rkt.go index 2551f0ad89..775d768243 100644 --- a/rkt/rkt.go +++ b/rkt/rkt.go @@ -107,7 +107,9 @@ func (d *absDir) Set(str string) error { if err != nil { return err } + *d = (absDir)(dir) + return nil } @@ -181,7 +183,9 @@ func init() { func getTabOutWithWriter(writer io.Writer) *tabwriter.Writer { aTabOut := new(tabwriter.Writer) + aTabOut.Init(writer, 0, 8, 1, '\t', 0) + return aTabOut } @@ -203,6 +207,7 @@ func ensureSuperuser(cf func(cmd *cobra.Command, args []string)) func(cmd *cobra cmdExitCode = 1 return } + cf(cmd, args) } } @@ -255,6 +260,7 @@ func getDataDir() string { if cachedDataDir == "" { cachedDataDir = calculateDataDir() } + return cachedDataDir } @@ -262,29 +268,29 @@ func calculateDataDir() string { var dataDir string // If --dir parameter is passed, then use this value. - if dirFlag := cmdRkt.PersistentFlags().Lookup("dir"); dirFlag != nil { - if dirFlag.Changed { - dataDir = globalFlags.Dir - } - } else { + dirFlag := cmdRkt.PersistentFlags().Lookup("dir") + if dirFlag == nil { // should not happen panic(`"--dir" flag not found`) } + if dirFlag.Changed { + dataDir = globalFlags.Dir + } + // If above fails, then try to get the value from configuration. if dataDir == "" { - if config, err := getConfig(); err != nil { + config, err := getConfig() + if err != nil { stderr.PrintE("cannot get configuration", err) os.Exit(1) - } else { - if config.Paths.DataDir != "" { - dataDir = config.Paths.DataDir - } } - } - if dataDir == "" { - dataDir = defaultDataDir + if config.Paths.DataDir != "" { + dataDir = config.Paths.DataDir + } else { + dataDir = defaultDataDir + } } // Resolve symlinks @@ -297,26 +303,33 @@ func calculateDataDir() string { os.Exit(1) } } + // If above fails, then use the default. return realDataDir } func getConfig() (*config.Config, error) { - if cachedConfig == nil { - dirs := []string{ - globalFlags.SystemConfigDir, - globalFlags.LocalConfigDir, - } - if globalFlags.UserConfigDir != "" { - dirs = append(dirs, globalFlags.UserConfigDir) - } - cfg, err := config.GetConfigFrom(dirs...) - if err != nil { - return nil, err - } - cachedConfig = cfg + if cachedConfig != nil { + return cachedConfig, nil + } + + dirs := []string{ + globalFlags.SystemConfigDir, + globalFlags.LocalConfigDir, } - return cachedConfig, nil + + if globalFlags.UserConfigDir != "" { + dirs = append(dirs, globalFlags.UserConfigDir) + } + + cfg, err := config.GetConfigFrom(dirs...) + if err != nil { + return nil, err + } + + cachedConfig = cfg + + return cfg, nil } func lockDir() string { From 5991563ec1062071ba088339c1f5311630251d54 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 11 May 2016 13:28:39 +0200 Subject: [PATCH 0233/1304] docs: Add example to run multiple apps in one pod (#2609) * docs: Add example to run multiple apps in one pod A example was missing how to run multiple apps in one pod Fixes #2583 * docs: Change level of "run multiple apps in same pod", add preamble "run multiple apps in same pod" should be higher level Fixes #2583 --- Documentation/subcommands/run.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/subcommands/run.md b/Documentation/subcommands/run.md index 41351d3b52..8ed9571535 100644 --- a/Documentation/subcommands/run.md +++ b/Documentation/subcommands/run.md @@ -25,6 +25,13 @@ rkt will automatically [fetch](fetch.md) them if they're not present in the loca # rkt --insecure-options=image run docker://quay.io/coreos/etcd:v2.0.0 ``` +## Run multiple applications in the same pod + +Multiple applications can be run in a pod by passing multiple images to the run command: +``` +# rkt run example.com/app1 example.com/app2 +``` + ## Overriding Executable to launch Application images include an `exec` field that specifies the executable to launch. From e7393a40793bf16376419fa5d7bb65bfc9cdb5f1 Mon Sep 17 00:00:00 2001 From: ian Clark Date: Tue, 3 May 2016 15:36:16 -0500 Subject: [PATCH 0234/1304] stage1/prepare-app/prepare-app.c: Parse UUIDs of 32 character length The proper format of UUIDs is the format of 8-4-4-4-12. Updating this to follow the correct format (which is generated by a third-party package). Issue #2573 --- stage1/prepare-app/prepare-app.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stage1/prepare-app/prepare-app.c b/stage1/prepare-app/prepare-app.c index 30d88173f5..beaf54792e 100644 --- a/stage1/prepare-app/prepare-app.c +++ b/stage1/prepare-app/prepare-app.c @@ -47,8 +47,8 @@ static int exit_err; #define lenof(_str) \ (sizeof(_str) - 1) -#define MACHINE_ID_LEN lenof("0123456789abcdef0123456789ab") -#define MACHINE_NAME_LEN lenof("rkt-01234567-89ab-cdef-0123-456789ab") +#define MACHINE_ID_LEN lenof("0123456789abcdef0123456789abcdef") +#define MACHINE_NAME_LEN lenof("rkt-01234567-89ab-cdef-0123-456789abcdef") typedef struct _dir_op_t { const char *name; @@ -77,7 +77,7 @@ static int get_machine_name(char *out, int out_len) { pgoto_if(close(fd) != 0, _fail, "Error closing \"/etc/machine-id\""); goto_if(snprintf(out, out_len, - "rkt-%.8s-%.4s-%.4s-%.4s-%.8s", + "rkt-%.8s-%.4s-%.4s-%.4s-%.12s", buf, buf+8, buf+12, buf+16, buf+20) >= out_len, _fail, "Error constructing machine name"); From de1e896c14c7698e06b48cafa69efe156a31713d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Mon, 9 May 2016 14:50:06 +0200 Subject: [PATCH 0235/1304] stage1/init: create a new mount ns for each app Up to this point, you could escape the app's chroot easily by using a simple program downloaded from the internet [[1]][1]. To avoid this, we now create a new mount namespace per each app. You can still escape the chroot if you have CAP_SYS_PTRACE and access `/proc/1/root` but this fixes the issue for images that don't need this capability. [1]: http://www.unixwiz.net/techtips/chroot-practices.html --- stage1/init/common/pod.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index 11b077c075..8f64b5cd3f 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -457,6 +457,9 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b unit.NewUnitOption("Service", "Restart", "no"), unit.NewUnitOption("Service", "ExecStart", execStartString), unit.NewUnitOption("Service", "RootDirectory", common.RelAppRootfsPath(appName)), + // MountFlags=shared creates a new mount namespace and (as unintuitive + // as it might seem) makes sure the mount is slave+shared. + unit.NewUnitOption("Service", "MountFlags", "shared"), unit.NewUnitOption("Service", "WorkingDirectory", workDir), unit.NewUnitOption("Service", "EnvironmentFile", RelEnvFilePathSystemd(appName)), unit.NewUnitOption("Service", "User", strconv.Itoa(u)), From 2b468df4d7801b77e032cfab95314e82c3233105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 11 May 2016 16:35:50 +0200 Subject: [PATCH 0236/1304] functional tests: test reading a file written in another app --- tests/rkt_volume_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/rkt_volume_test.go b/tests/rkt_volume_test.go index 1577ff3fa9..406afef649 100644 --- a/tests/rkt_volume_test.go +++ b/tests/rkt_volume_test.go @@ -94,6 +94,11 @@ var volTests = []struct { `<<<1>>>`, 0, }, + { + `/bin/sh -c "export FILE=/dir1/file CONTENT=1 ; ^RKT_BIN^ --debug --insecure-options=image run --mds-register=false --volume=dir1,kind=host,source=^TMPDIR^ --inherit-env=true ^VOL_RW_WRITE_FILE_ONLY^ ^VOL_RO_READ_FILE_ONLY^ --exec /inspect -- --pre-sleep=1 --read-file"`, + `<<<1>>>`, + 0, + }, } func NewVolumesTest() testutils.Test { @@ -106,6 +111,10 @@ func NewVolumesTest() testutils.Test { defer os.Remove(volRwReadFileImage) volRwWriteFileImage := patchTestACI("rkt-inspect-vol-rw-write-file.aci", "--exec=/inspect --write-file --read-file", "--mounts=dir1,path=/dir1,readOnly=false") defer os.Remove(volRwWriteFileImage) + volRwWriteFileOnlyImage := patchTestACI("rkt-inspect-vol-rw-write-file-only.aci", "--exec=/inspect --write-file", "--mounts=dir1,path=/dir1,readOnly=false") + defer os.Remove(volRwWriteFileOnlyImage) + volRoReadFileOnlyImage := patchTestACI("rkt-inspect-vol-ro-read-file-only.aci", "--name=coreos.com/rkt-inspect-2", "--exec=/inspect --read-file", "--mounts=dir1,path=/dir1,readOnly=true") + defer os.Remove(volRoReadFileOnlyImage) volRoReadFileImage := patchTestACI("rkt-inspect-vol-ro-read-file.aci", "--exec=/inspect --read-file", "--mounts=dir1,path=/dir1,readOnly=true") defer os.Remove(volRoReadFileImage) volRoWriteFileImage := patchTestACI("rkt-inspect-vol-ro-write-file.aci", "--exec=/inspect --write-file --read-file", "--mounts=dir1,path=/dir1,readOnly=true") @@ -134,6 +143,8 @@ func NewVolumesTest() testutils.Test { cmd = strings.Replace(cmd, "^VOL_RO_WRITE_FILE^", volRoWriteFileImage, -1) cmd = strings.Replace(cmd, "^VOL_RW_READ_FILE^", volRwReadFileImage, -1) cmd = strings.Replace(cmd, "^VOL_RW_WRITE_FILE^", volRwWriteFileImage, -1) + cmd = strings.Replace(cmd, "^VOL_RW_WRITE_FILE_ONLY^", volRwWriteFileOnlyImage, -1) + cmd = strings.Replace(cmd, "^VOL_RO_READ_FILE_ONLY^", volRoReadFileOnlyImage, -1) cmd = strings.Replace(cmd, "^VOL_ADD_MOUNT_RW^", volAddMountRwImage, -1) cmd = strings.Replace(cmd, "^VOL_ADD_MOUNT_RO^", volAddMountRoImage, -1) From e04ad9246f51aaf3cd93bc18551a78c7f16dad73 Mon Sep 17 00:00:00 2001 From: Euan Kemp Date: Tue, 10 May 2016 17:38:17 -0700 Subject: [PATCH 0237/1304] stage1: Fix segfault in enterexec Prior to this commit, if `rkt enter` was executed without the `TERM` environment variable set, a segfault could occur. This commit treats an empty TERM environment variable as meaning 'xterm' and avoids the segfault. --- stage1/enterexec/enterexec.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/stage1/enterexec/enterexec.c b/stage1/enterexec/enterexec.c index 72ec9d3bb1..36079235a2 100644 --- a/stage1/enterexec/enterexec.c +++ b/stage1/enterexec/enterexec.c @@ -214,7 +214,15 @@ static void load_env(const char *env_file, const char *keep_env_file, int enteri set_env(env_file); set_env(keep_env_file); - if (entering) setenv("TERM", term, 1); + if (entering) { + // enter is typically interactive; ensure we always have a sane enough term + // variable. + if (term == NULL) { + setenv("TERM", "vt100", 1); + } else { + setenv("TERM", term, 1); + } + } } /* Parse a comma-separated list of numeric gids from str, returns an malloc'd From 59150b9d1d1b61481fb6d41cdd246554a32e8bd7 Mon Sep 17 00:00:00 2001 From: Yifan Gu Date: Thu, 28 Apr 2016 18:46:47 -0700 Subject: [PATCH 0238/1304] api: Return the pods even when we failed to get every information of it. --- rkt/api_service.go | 188 +++++++++++++++++++-------------------------- 1 file changed, 79 insertions(+), 109 deletions(-) diff --git a/rkt/api_service.go b/rkt/api_service.go index 532d3254f1..786957ab9f 100644 --- a/rkt/api_service.go +++ b/rkt/api_service.go @@ -241,15 +241,9 @@ func getPodManifest(p *pod) (*schema.PodManifest, []byte, error) { } // getApplist returns a list of apps in the pod. -func getApplist(p *pod) ([]*v1alpha.App, error) { +func getApplist(manifest *schema.PodManifest) []*v1alpha.App { var apps []*v1alpha.App - applist, err := p.getApps() - if err != nil { - stderr.PrintE(fmt.Sprintf("failed to get app list for pod %q", p.uuid), err) - return nil, err - } - - for _, app := range applist { + for _, app := range manifest.Apps { img := &v1alpha.Image{ BaseFormat: &v1alpha.ImageFormat{ // Only support appc image now. If it's a docker image, then it @@ -268,7 +262,7 @@ func getApplist(p *pod) ([]*v1alpha.App, error) { // State and exit code are not returned in 'ListPods()'. }) } - return apps, nil + return apps } // getNetworks returns the list of the info of the network that the pod belongs to. @@ -286,29 +280,30 @@ func getNetworks(p *pod) []*v1alpha.Network { // getBasicPod returns *v1alpha.Pod with basic pod information, it also returns a *schema.PodManifest // object. -func getBasicPod(p *pod) (*v1alpha.Pod, *schema.PodManifest, error) { +func getBasicPod(p *pod) (*v1alpha.Pod, *schema.PodManifest) { pod := &v1alpha.Pod{Id: p.uuid.String(), Pid: -1} - // If a pod is in Embryo, Preparing, AbortedPrepare state, - // only id and state will be returned. - // - // If a pod is in other states, the pod manifest and - // apps will be returned when 'detailed' is true in the request. - // - // Valid pid and networks are only returned when a pod is in Running. + manifest, data, err := getPodManifest(p) + if err != nil { + stderr.PrintE(fmt.Sprintf("failed to get the pod manifest for pod %q", p.uuid), err) + } else { + pod.Manifest = data + pod.Annotations = convertAnnotationsToKeyValue(manifest.Annotations) + pod.Apps = getApplist(manifest) + } + switch p.getState() { case Embryo: pod.State = v1alpha.PodState_POD_STATE_EMBRYO - return pod, nil, nil + // When a pod is in embryo state, there is not much + // information to return. + return pod, manifest case Preparing: pod.State = v1alpha.PodState_POD_STATE_PREPARING - return pod, nil, nil case AbortedPrepare: pod.State = v1alpha.PodState_POD_STATE_ABORTED_PREPARE - return pod, nil, nil case Prepared: pod.State = v1alpha.PodState_POD_STATE_PREPARED - return pod, nil, nil case Running: pod.State = v1alpha.PodState_POD_STATE_RUNNING pod.Networks = getNetworks(p) @@ -320,45 +315,35 @@ func getBasicPod(p *pod) (*v1alpha.Pod, *schema.PodManifest, error) { pod.State = v1alpha.PodState_POD_STATE_GARBAGE default: pod.State = v1alpha.PodState_POD_STATE_UNDEFINED - return pod, nil, nil + return pod, manifest } createdAt, err := p.getCreationTime() if err != nil { - return nil, nil, err + stderr.PrintE(fmt.Sprintf("failed to get the creation time for pod %q", p.uuid), err) + } else if !createdAt.IsZero() { + pod.CreatedAt = createdAt.UnixNano() } startedAt, err := p.getStartTime() if err != nil { - return nil, nil, err - } + stderr.PrintE(fmt.Sprintf("failed to get the start time for pod %q", p.uuid), err) + } else if !startedAt.IsZero() { + pod.StartedAt = startedAt.UnixNano() - gcMarkedAt, err := p.getGCMarkedTime() - if err != nil { - return nil, nil, err } - pod.CreatedAt = createdAt.UnixNano() - pod.StartedAt = startedAt.UnixNano() - pod.GcMarkedAt = gcMarkedAt.UnixNano() - - manifest, data, err := getPodManifest(p) + gcMarkedAt, err := p.getGCMarkedTime() if err != nil { - return nil, nil, err + stderr.PrintE(fmt.Sprintf("failed to get the gc marked time for pod %q", p.uuid), err) + } else if !gcMarkedAt.IsZero() { + pod.GcMarkedAt = gcMarkedAt.UnixNano() } - apps, err := getApplist(p) + pid, err := p.getPID() if err != nil { - return nil, nil, err - } - - if pod.State == v1alpha.PodState_POD_STATE_RUNNING || - pod.State == v1alpha.PodState_POD_STATE_DELETING || - pod.State == v1alpha.PodState_POD_STATE_EXITED { - pid, err := p.getPID() - if err != nil { - return nil, nil, err - } + stderr.PrintE(fmt.Sprintf("failed to get the PID for pod %q", p.uuid), err) + } else { pod.Pid = int32(pid) } @@ -366,36 +351,29 @@ func getBasicPod(p *pod) (*v1alpha.Pod, *schema.PodManifest, error) { // Get cgroup for the "name=systemd" controller. pid, err := p.getContainerPID1() if err != nil { - return nil, nil, err - } - cgroup, err := cgroup.GetCgroupPathByPid(pid, "name=systemd") - if err != nil { - return nil, nil, err + stderr.PrintE(fmt.Sprintf("failed to get the container PID1 for pod %q", p.uuid), err) + } else { + cgroup, err := cgroup.GetCgroupPathByPid(pid, "name=systemd") + if err != nil { + stderr.PrintE(fmt.Sprintf("failed to get the cgroup path for pod %q", p.uuid), err) + } else { + // If the stage1 systemd > v226, it will put the PID1 into "init.scope" + // implicit scope unit in the root slice. + // See https://github.com/coreos/rkt/pull/2331#issuecomment-203540543 + // + // TODO(yifan): Revisit this when using unified cgroup hierarchy. + pod.Cgroup = strings.TrimSuffix(cgroup, "/init.scope") + } } - - // If the stage1 systemd > v226, it will put the PID1 into "init.scope" - // implicit scope unit in the root slice. - // See https://github.com/coreos/rkt/pull/2331#issuecomment-203540543 - // - // TODO(yifan): Revisit this when using unified cgroup hierarchy. - pod.Cgroup = strings.TrimSuffix(cgroup, "/init.scope") } - pod.Manifest = data - pod.Apps = apps - pod.Annotations = convertAnnotationsToKeyValue(manifest.Annotations) - - return pod, manifest, nil + return pod, manifest } func (s *v1AlphaAPIServer) ListPods(ctx context.Context, request *v1alpha.ListPodsRequest) (*v1alpha.ListPodsResponse, error) { var pods []*v1alpha.Pod if err := walkPods(includeMostDirs, func(p *pod) { - pod, manifest, err := getBasicPod(p) - if err != nil { // Do not return partial pods. - stderr.PrintE(fmt.Sprintf("failed to get basic pod information for pod with uuid: %v", p.uuid), err) - return - } + pod, manifest := getBasicPod(p) // Filters are combined with 'OR'. if !satisfiesAnyPodFilters(pod, manifest, request.Filters) { @@ -403,10 +381,7 @@ func (s *v1AlphaAPIServer) ListPods(ctx context.Context, request *v1alpha.ListPo } if request.Detail { - if err := fillAppInfo(s.store, p, pod); err != nil { // Do not return partial pods. - stderr.PrintE(fmt.Sprintf("failed to fill app information for pod with uuid: %v", p.uuid), err) - return - } + fillAppInfo(s.store, p, pod) } else { pod.Manifest = nil } @@ -419,25 +394,36 @@ func (s *v1AlphaAPIServer) ListPods(ctx context.Context, request *v1alpha.ListPo } // fillAppInfo fills the apps' state and image info of the pod. -func fillAppInfo(store *store.Store, p *pod, v1pod *v1alpha.Pod) error { - statusDir, err := p.getStatusDir() - if err != nil { - stderr.PrintE("failed to get pod exit status directory", err) - return err +func fillAppInfo(store *store.Store, p *pod, v1pod *v1alpha.Pod) { + switch v1pod.State { + case v1alpha.PodState_POD_STATE_UNDEFINED: + return + case v1alpha.PodState_POD_STATE_EMBRYO: + return } for _, app := range v1pod.Apps { + readStatus := false + + if p.isRunning() { + readStatus = true + app.State = v1alpha.AppState_APP_STATE_RUNNING + } else if p.afterRun() { + readStatus = true + app.State = v1alpha.AppState_APP_STATE_EXITED + } else { + app.State = v1alpha.AppState_APP_STATE_UNDEFINED + } + // Fill app's image info (id, name, version). fullImageID, err := store.ResolveKey(app.Image.Id) if err != nil { stderr.PrintE(fmt.Sprintf("failed to resolve the image ID %q", app.Image.Id), err) - return err } im, err := p.getAppImageManifest(*types.MustACName(app.Name)) if err != nil { stderr.PrintE(fmt.Sprintf("failed to get image manifests for app %q", app.Name), err) - return err } version, ok := im.Labels.Get("version") @@ -459,32 +445,21 @@ func fillAppInfo(store *store.Store, p *pod, v1pod *v1alpha.Pod) error { // info from store. } - // Fill app's state and exit code. - value, err := p.readIntFromFile(filepath.Join(statusDir, app.Name)) - if err == nil { - app.State = v1alpha.AppState_APP_STATE_EXITED - app.ExitCode = int32(value) - continue - } - - if !os.IsNotExist(err) { - stderr.PrintE(fmt.Sprintf("failed to read status for app %q", app.Name), err) - return err - } - // If status file does not exit, that means the - // app is either running or aborted. - // - // FIXME(yifan): This is not acttually true, the app can be aborted while - // the pod is still running if the spec changes. - switch p.getState() { - case Running: - app.State = v1alpha.AppState_APP_STATE_RUNNING - default: - app.State = v1alpha.AppState_APP_STATE_UNDEFINED + if readStatus { + // Fill app's state and exit code. + statusDir, err := p.getStatusDir() + if err != nil { + stderr.PrintE("failed to get pod exit status directory", err) + } else { + value, err := p.readIntFromFile(filepath.Join(statusDir, app.Name)) + if err != nil && !os.IsNotExist(err) { + stderr.PrintE(fmt.Sprintf("failed to read status for app %q", app.Name), err) + } else { + app.ExitCode = int32(value) + } + } } - } - return nil } func (s *v1AlphaAPIServer) InspectPod(ctx context.Context, request *v1alpha.InspectPodRequest) (*v1alpha.InspectPodResponse, error) { @@ -501,15 +476,10 @@ func (s *v1AlphaAPIServer) InspectPod(ctx context.Context, request *v1alpha.Insp } defer p.Close() - pod, _, err := getBasicPod(p) - if err != nil { - return nil, err - } + pod, _ := getBasicPod(p) // Fill the extra pod info that is not available in ListPods(detail=false). - if err := fillAppInfo(s.store, p, pod); err != nil { - return nil, err - } + fillAppInfo(s.store, p, pod) return &v1alpha.InspectPodResponse{Pod: pod}, nil } From 93615518ab773e08f588860e54d6203730084a34 Mon Sep 17 00:00:00 2001 From: Yifan Gu Date: Fri, 6 May 2016 16:12:34 -0700 Subject: [PATCH 0239/1304] test: Update rkt api service tests. --- tests/rkt_api_service_test.go | 132 ++++++++++++++++++++++------------ tests/rkt_tests.go | 18 +++-- 2 files changed, 96 insertions(+), 54 deletions(-) diff --git a/tests/rkt_api_service_test.go b/tests/rkt_api_service_test.go index cd6a7b8ad5..dd592dcd98 100644 --- a/tests/rkt_api_service_test.go +++ b/tests/rkt_api_service_test.go @@ -100,23 +100,35 @@ func checkPodState(t *testing.T, rawState string, apiState v1alpha.PodState) { t.Errorf("Pod state returned by api-service (%q) is not equivalent to the state returned by 'rkt status' (%q)", apiState, rawState) } -func checkPodApps(t *testing.T, rawApps map[string]*appInfo, apiApps []*v1alpha.App, hasAppState bool) { +func checkPodApps(t *testing.T, rawPod *podInfo, apiApps []*v1alpha.App, hasAppState bool) { + rawApps := rawPod.apps if len(rawApps) != len(apiApps) { t.Errorf("Expected %d apps, saw %d apps returned by api service %v", len(rawApps), len(apiApps), apiApps) } for _, app := range apiApps { - if appInfo, ok := rawApps[app.Name]; ok { - if hasAppState && appInfo.exitCode != int(app.ExitCode) { - t.Errorf("Expected %v, saw %v", appInfo.exitCode, app.ExitCode) - } - // Image hash in the pod manifest can be partial hash. - if !strings.HasPrefix(app.Image.Id, appInfo.image.id) { - t.Errorf("Expected partial hash of %q, saw %q", appInfo.image.id, app.Image.Id) - } - } else { - t.Errorf("Expected app (name: %q) in the app list", appInfo.name) + appInfo, ok := rawApps[app.Name] + if !ok { + t.Errorf("Expected app (name: %q) in the app list", app.Name) + continue + } + + appACName := types.MustACName(app.Name) + runtimeApp := rawPod.manifest.Apps.Get(*appACName) + if runtimeApp == nil { + t.Errorf("Expected app (name: %q) in the pod manifest", app.Name) + } + + if hasAppState && appInfo.exitCode != int(app.ExitCode) { + t.Errorf("Expected %v, saw %v", appInfo.exitCode, app.ExitCode) } + // Image hash in the pod manifest can be partial hash. + if !strings.HasPrefix(app.Image.Id, appInfo.image.id) { + t.Errorf("Expected partial hash of %q, saw %q", appInfo.image.id, app.Image.Id) + } + + // Check app annotations. + checkAnnotations(t, runtimeApp.Annotations, app.Annotations) } } @@ -162,7 +174,7 @@ func checkPod(t *testing.T, ctx *testutils.RktRunCtx, p *v1alpha.Pod, hasAppStat t.Errorf("API service returned an incorrect GC marked time. Got %q, Expect: %q", actualTime, expectedGCTime) } checkPodState(t, podInfo.state, p.State) - checkPodApps(t, podInfo.apps, p.Apps, hasAppState) + checkPodApps(t, podInfo, p.Apps, hasAppState) checkPodNetworks(t, podInfo.networks, p.Networks) expectedCgroupSuffix := "" @@ -176,19 +188,17 @@ func checkPod(t *testing.T, ctx *testutils.RktRunCtx, p *v1alpha.Pod, hasAppStat t.Errorf("Expected the cgroup suffix to have %q, but saw %q", expectedCgroupSuffix, p.Cgroup) } - if hasManifest { - var mfst schema.PodManifest - err := json.Unmarshal(podInfo.manifest, &mfst) - if err != nil { - t.Fatal(err) - } - if mfst.Annotations != nil { - checkAnnotations(t, mfst.Annotations, p.Annotations) - } + if hasManifest && podInfo.manifest.Annotations != nil { + checkAnnotations(t, podInfo.manifest.Annotations, p.Annotations) } - if hasManifest && !bytes.Equal(podInfo.manifest, p.Manifest) { - t.Errorf("Expected %q, saw %q", string(podInfo.manifest), string(p.Manifest)) + msft, err := json.Marshal(podInfo.manifest) + if err != nil { + t.Errorf("Cannot marshal manifest: %v", err) + } + + if hasManifest && !bytes.Equal(msft, p.Manifest) { + t.Errorf("Expected %q, saw %q", string(msft), string(p.Manifest)) } else if !hasManifest && p.Manifest != nil { t.Errorf("Expected nil manifest") } @@ -323,23 +333,62 @@ func NewAPIServiceListInspectPodsTest() testutils.Test { if err != nil { t.Fatalf("Cannot generate types.Hash from %v: %v", imageHash, err) } - pm := schema.BlankPodManifest() - pm.Apps = []schema.RuntimeApp{ + + podManifests := []struct { + mfst schema.PodManifest + net string + expectedExitCode int + }{ { - Name: types.ACName("rkt-inspect"), - Image: schema.RuntimeImage{ - Name: types.MustACIdentifier("coreos.com/rkt-inspect"), - ID: *imgID, + // 1, Good pod. + schema.PodManifest{ + ACKind: schema.PodManifestKind, + ACVersion: schema.AppContainerVersion, + Apps: []schema.RuntimeApp{ + { + Name: types.ACName("rkt-inspect"), + Image: schema.RuntimeImage{ + Name: types.MustACIdentifier("coreos.com/rkt-inspect"), + ID: *imgID, + }, + Annotations: []types.Annotation{{Name: types.ACIdentifier("app-test"), Value: "app-test"}}, + }, + }, + Annotations: []types.Annotation{ + {Name: types.ACIdentifier("test"), Value: "test"}, + }, }, - Annotations: []types.Annotation{{Name: types.ACIdentifier("app-test"), Value: "app-test"}}, + "default", + 0, + }, + { + // 2, Bad pod, won't be launched correctly. + schema.PodManifest{ + ACKind: schema.PodManifestKind, + ACVersion: schema.AppContainerVersion, + Apps: []schema.RuntimeApp{ + { + Name: types.ACName("rkt-inspect"), + Image: schema.RuntimeImage{ + Name: types.MustACIdentifier("coreos.com/rkt-inspect"), + ID: *imgID, + }, + }, + }, + }, + "non-existed-network", + 1, }, } - pm.Annotations = []types.Annotation{{Name: types.ACIdentifier("test"), Value: "test"}} - manifestFile := generatePodManifestFile(t, pm) - defer os.Remove(manifestFile) - runCmd := fmt.Sprintf("%s run --pod-manifest=%s", ctx.Cmd(), manifestFile) - waitOrFail(t, spawnOrFail(t, runCmd), 0) + // Launch the pods. + for _, entry := range podManifests { + manifestFile := generatePodManifestFile(t, &entry.mfst) + defer os.Remove(manifestFile) + + runCmd := fmt.Sprintf("%s run --net=%s --pod-manifest=%s", ctx.Cmd(), entry.net, manifestFile) + waitOrFail(t, spawnOrFail(t, runCmd), entry.expectedExitCode) + } time.Sleep(delta) @@ -354,8 +403,8 @@ func NewAPIServiceListInspectPodsTest() testutils.Test { t.Fatalf("Unexpected error: %v", err) } - if len(resp.Pods) == 0 { - t.Errorf("Unexpected result: %v, should see non-zero pods", resp.Pods) + if len(resp.Pods) != len(podManifests) { + t.Errorf("Unexpected result: %v, should see %v pods", len(resp.Pods), len(podManifests)) } for _, p := range resp.Pods { @@ -367,11 +416,6 @@ func NewAPIServiceListInspectPodsTest() testutils.Test { t.Fatalf("Unexpected error: %v", err) } checkPodDetails(t, ctx, inspectResp.Pod) - - // Test Apps. - for i, app := range p.Apps { - checkAnnotations(t, pm.Apps[i].Annotations, app.Annotations) - } } // ListPods(detail=true). @@ -380,8 +424,8 @@ func NewAPIServiceListInspectPodsTest() testutils.Test { t.Fatalf("Unexpected error: %v", err) } - if len(resp.Pods) == 0 { - t.Errorf("Unexpected result: %v, should see non-zero pods", resp.Pods) + if len(resp.Pods) != len(podManifests) { + t.Errorf("Unexpected result: %v, should see %v pods", len(resp.Pods), len(podManifests)) } for _, p := range resp.Pods { diff --git a/tests/rkt_tests.go b/tests/rkt_tests.go index 73a23077f2..09f3fc878d 100644 --- a/tests/rkt_tests.go +++ b/tests/rkt_tests.go @@ -417,7 +417,7 @@ type podInfo struct { state string apps map[string]*appInfo networks map[string]*networkInfo - manifest []byte + manifest *schema.PodManifest createdAt int64 startedAt int64 } @@ -435,7 +435,8 @@ func parsePodInfoOutput(t *testing.T, result string, p *podInfo) { for _, line := range lines { tuples := strings.SplitN(line, "=", 2) if len(tuples) != 2 { - t.Fatalf("Unexpected line: %v", line) + t.Logf("Unexpected line: %v", line) + continue } switch tuples[0] { @@ -521,6 +522,7 @@ func getPodDir(t *testing.T, ctx *testutils.RktRunCtx, podID string) string { func getPodInfo(t *testing.T, ctx *testutils.RktRunCtx, podID string) *podInfo { p := &podInfo{ id: podID, + pid: -1, apps: make(map[string]*appInfo), networks: make(map[string]*networkInfo), } @@ -532,14 +534,13 @@ func getPodInfo(t *testing.T, ctx *testutils.RktRunCtx, podID string) *podInfo { } // Trim the last '\n' character. - p.manifest = bytes.TrimSpace(output) + mfst := bytes.TrimSpace(output) // Fill app infos. - var manifest schema.PodManifest - if err := json.Unmarshal(p.manifest, &manifest); err != nil { + if err := json.Unmarshal(mfst, &p.manifest); err != nil { t.Fatalf("Unexpected error: %v", err) } - for _, app := range manifest.Apps { + for _, app := range p.manifest.Apps { appName := app.Name.String() p.apps[appName] = &appInfo{ name: appName, @@ -549,10 +550,7 @@ func getPodInfo(t *testing.T, ctx *testutils.RktRunCtx, podID string) *podInfo { } // Fill other infos. - output, err = exec.Command("/bin/bash", "-c", fmt.Sprintf("%s status %s", ctx.Cmd(), podID)).CombinedOutput() - if err != nil { - t.Fatalf("Unexpected error: %v", err) - } + output, _ = exec.Command("/bin/bash", "-c", fmt.Sprintf("%s status %s", ctx.Cmd(), podID)).CombinedOutput() parsePodInfoOutput(t, string(output), p) return p From e1ba9ef00f553ebc97cdecba1916b5af5d3a33b0 Mon Sep 17 00:00:00 2001 From: Chance Zibolski Date: Wed, 20 Apr 2016 14:48:16 -0700 Subject: [PATCH 0240/1304] dist: Update tmpfiles to create /etc/rkt By creating this directory, users can run `rkt trust` without being root, if the user is in the rkt group. --- dist/init/systemd/tmpfiles.d/rkt.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dist/init/systemd/tmpfiles.d/rkt.conf b/dist/init/systemd/tmpfiles.d/rkt.conf index 00f37580b7..406172741e 100644 --- a/dist/init/systemd/tmpfiles.d/rkt.conf +++ b/dist/init/systemd/tmpfiles.d/rkt.conf @@ -22,3 +22,5 @@ d /var/lib/rkt/pods/prepared 2750 root rkt d /var/lib/rkt/pods/run 2750 root rkt d /var/lib/rkt/pods/exited-garbage 2750 root rkt d /var/lib/rkt/pods/garbage 2750 root rkt + +d /etc/rkt 2770 root rkt-admin From f2c25434468838a019c0c73fce246e253fbecb37 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Thu, 12 May 2016 01:21:51 +0200 Subject: [PATCH 0241/1304] tests: print proper output for TestAceValidator This allows to debug https://github.com/coreos/rkt/issues/2171 properly. --- tests/rkt_ace_validator_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/rkt_ace_validator_test.go b/tests/rkt_ace_validator_test.go index c7adc5980d..fc8a514d10 100644 --- a/tests/rkt_ace_validator_test.go +++ b/tests/rkt_ace_validator_test.go @@ -56,16 +56,18 @@ func TestAceValidator(t *testing.T) { child := spawnOrFail(t, rktCmd) defer waitOrFail(t, child, 0) + out := "" for _, set := range expected { for len(set) > 0 { - results, _, err := expectRegexWithOutput(child, pattern) + results, o, err := expectRegexWithOutput(child, pattern) + out += o if err != nil { var keys []string for k := range set { keys = append(keys, fmt.Sprintf("%q", k)) } ex := strings.Join(keys, " or ") - t.Fatalf("Expected %s, but not found: %v", ex, err) + t.Fatalf("Expected %s, but not found: %v\nOutput: %v", ex, err, out) } if len(results) != 2 { t.Fatalf("Unexpected regex results, expected a whole match and one submatch, got %#v", results) From 2ce4abb1940d8de97f674472b7c2383f42d403ae Mon Sep 17 00:00:00 2001 From: Matthias Jahn Date: Thu, 12 May 2016 08:52:26 +0200 Subject: [PATCH 0242/1304] scripts: add libtspi-dev Now the install script can be reused e.g. for the 'build with docker' part Fixes #2215 --- scripts/install-deps-debian-sid.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install-deps-debian-sid.sh b/scripts/install-deps-debian-sid.sh index 0db2db2ed5..b4edb2c102 100755 --- a/scripts/install-deps-debian-sid.sh +++ b/scripts/install-deps-debian-sid.sh @@ -2,7 +2,7 @@ set -e -DEBIAN_SID_DEPS="ca-certificates gcc libc6-dev make automake wget git golang-go coreutils cpio squashfs-tools realpath autoconf file xz-utils patch bc locales libacl1-dev libssl-dev" +DEBIAN_SID_DEPS="ca-certificates gcc libc6-dev make automake wget git golang-go coreutils cpio squashfs-tools realpath autoconf file xz-utils patch bc locales libacl1-dev libssl-dev libtspi-dev" export DEBIAN_FRONTEND=noninteractive apt-get update From 78c9d76fe5ca19e07e9fdc9c5b5f8e64188a28ac Mon Sep 17 00:00:00 2001 From: Matthias Jahn Date: Thu, 12 May 2016 08:55:08 +0200 Subject: [PATCH 0243/1304] docs: change docker img to debian:sid, install deps via script "build with docker" and "build with rkt" should use same deps and img Fixes #2215 --- Documentation/hacking.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/hacking.md b/Documentation/hacking.md index 5477f4945c..539e812950 100644 --- a/Documentation/hacking.md +++ b/Documentation/hacking.md @@ -33,7 +33,7 @@ Alternatively, you can build rkt in a Docker container with the following comman Replace `$SRC` with the absolute path to your rkt source code: ``` -# docker run -v $SRC:/opt/rkt -i -t golang:1.5 /bin/bash -c "apt-get update && apt-get install -y coreutils cpio squashfs-tools realpath autoconf file xz-utils patch bc libacl1-dev libtspi-dev libssl-dev && cd /opt/rkt && go get github.com/appc/spec/... && ./autogen.sh && ./configure && make" +# docker run -v $SRC:/opt/rkt debian:sid /bin/bash -c "cd /opt/rkt && ./scripts/install-deps-debian-sid.sh go get github.com/appc/spec/... && ./autogen.sh && ./configure && make" ``` ### Building systemd in stage1 from source From 7e796e85668d222f0ea4895cf0b016791d68940b Mon Sep 17 00:00:00 2001 From: Matthias Jahn Date: Thu, 12 May 2016 09:08:40 +0200 Subject: [PATCH 0244/1304] docs: fixed build with docker cmd (forgot && between two cmds) Without "&&" the cmd is not correct Fixes #2215 --- Documentation/hacking.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/hacking.md b/Documentation/hacking.md index 539e812950..56180eed6a 100644 --- a/Documentation/hacking.md +++ b/Documentation/hacking.md @@ -33,7 +33,7 @@ Alternatively, you can build rkt in a Docker container with the following comman Replace `$SRC` with the absolute path to your rkt source code: ``` -# docker run -v $SRC:/opt/rkt debian:sid /bin/bash -c "cd /opt/rkt && ./scripts/install-deps-debian-sid.sh go get github.com/appc/spec/... && ./autogen.sh && ./configure && make" +# docker run -v $SRC:/opt/rkt debian:sid /bin/bash -c "cd /opt/rkt && ./scripts/install-deps-debian-sid.sh && go get github.com/appc/spec/... && ./autogen.sh && ./configure && make" ``` ### Building systemd in stage1 from source From bccd93a59d0df87ad85a1312b428c5d5af5d4bf5 Mon Sep 17 00:00:00 2001 From: Tamer TAS Date: Thu, 12 May 2016 11:30:48 +0300 Subject: [PATCH 0245/1304] docs: add instructions for nixos (#2614) Adds instructions for installing rkt on NixOS. Related to #2202 --- Documentation/distributions.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/distributions.md b/Documentation/distributions.md index f872138711..22df43dd35 100644 --- a/Documentation/distributions.md +++ b/Documentation/distributions.md @@ -54,6 +54,16 @@ rkt is available in the [Community Repository](https://www.archlinux.org/package sudo pacman -S rkt ``` +## NixOS + +rkt can be installed on NixOS using the following command: + +``` +nix-env -iA rkt +``` + +The source for the rkt.nix expression can be found on [GitHub](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/virtualization/rkt/default.nix) + ## Void rkt is available in the [official binary packages](http://www.voidlinux.eu/packages/) for the Void Linux distribution. From 01f08f1af219640f76d0eb3580ad0ae79d2e02a6 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Thu, 12 May 2016 11:36:44 +0200 Subject: [PATCH 0246/1304] godeps: update cni to v0.2.3 Fixes #2580 --- Godeps/Godeps.json | 68 +++++++++---------- .../appc/cni/plugins/main/bridge/bridge.go | 23 +++++-- .../appc/cni/plugins/main/ptp/ptp.go | 6 +- 3 files changed, 58 insertions(+), 39 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 6bc5c2f33f..b8c1333117 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -23,88 +23,88 @@ }, { "ImportPath": "github.com/appc/cni/pkg/invoke", - "Comment": "v0.2.0-rc0", - "Rev": "0046767be795f629180e0713b71822b731531997" + "Comment": "v0.2.3", + "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" }, { "ImportPath": "github.com/appc/cni/pkg/ip", - "Comment": "v0.2.0-rc0", - "Rev": "0046767be795f629180e0713b71822b731531997" + "Comment": "v0.2.3", + "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" }, { "ImportPath": "github.com/appc/cni/pkg/ipam", - "Comment": "v0.2.0-rc0", - "Rev": "0046767be795f629180e0713b71822b731531997" + "Comment": "v0.2.3", + "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" }, { "ImportPath": "github.com/appc/cni/pkg/ns", - "Comment": "v0.2.0-rc0", - "Rev": "0046767be795f629180e0713b71822b731531997" + "Comment": "v0.2.3", + "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" }, { "ImportPath": "github.com/appc/cni/pkg/skel", - "Comment": "v0.2.0-rc0", - "Rev": "0046767be795f629180e0713b71822b731531997" + "Comment": "v0.2.3", + "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" }, { "ImportPath": "github.com/appc/cni/pkg/types", - "Comment": "v0.2.0-rc0", - "Rev": "0046767be795f629180e0713b71822b731531997" + "Comment": "v0.2.3", + "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" }, { "ImportPath": "github.com/appc/cni/pkg/utils", - "Comment": "v0.2.0-rc0", - "Rev": "0046767be795f629180e0713b71822b731531997" + "Comment": "v0.2.3", + "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" }, { "ImportPath": "github.com/appc/cni/plugins/ipam/dhcp", - "Comment": "v0.2.0-rc0", - "Rev": "0046767be795f629180e0713b71822b731531997" + "Comment": "v0.2.3", + "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" }, { "ImportPath": "github.com/appc/cni/plugins/ipam/host-local", - "Comment": "v0.2.0-rc0", - "Rev": "0046767be795f629180e0713b71822b731531997" + "Comment": "v0.2.3", + "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" }, { "ImportPath": "github.com/appc/cni/plugins/ipam/host-local/backend", - "Comment": "v0.2.0-rc0", - "Rev": "0046767be795f629180e0713b71822b731531997" + "Comment": "v0.2.3", + "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" }, { "ImportPath": "github.com/appc/cni/plugins/ipam/host-local/backend/disk", - "Comment": "v0.2.0-rc0", - "Rev": "0046767be795f629180e0713b71822b731531997" + "Comment": "v0.2.3", + "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" }, { "ImportPath": "github.com/appc/cni/plugins/main/bridge", - "Comment": "v0.2.0-rc0", - "Rev": "0046767be795f629180e0713b71822b731531997" + "Comment": "v0.2.3", + "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" }, { "ImportPath": "github.com/appc/cni/plugins/main/ipvlan", - "Comment": "v0.2.0-rc0", - "Rev": "0046767be795f629180e0713b71822b731531997" + "Comment": "v0.2.3", + "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" }, { "ImportPath": "github.com/appc/cni/plugins/main/macvlan", - "Comment": "v0.2.0-rc0", - "Rev": "0046767be795f629180e0713b71822b731531997" + "Comment": "v0.2.3", + "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" }, { "ImportPath": "github.com/appc/cni/plugins/main/ptp", - "Comment": "v0.2.0-rc0", - "Rev": "0046767be795f629180e0713b71822b731531997" + "Comment": "v0.2.3", + "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" }, { "ImportPath": "github.com/appc/cni/plugins/meta/flannel", - "Comment": "v0.2.0-rc0", - "Rev": "0046767be795f629180e0713b71822b731531997" + "Comment": "v0.2.3", + "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" }, { "ImportPath": "github.com/appc/cni/plugins/meta/tuning", - "Comment": "v0.2.0-rc0", - "Rev": "0046767be795f629180e0713b71822b731531997" + "Comment": "v0.2.3", + "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" }, { "ImportPath": "github.com/appc/docker2aci/lib", diff --git a/Godeps/_workspace/src/github.com/appc/cni/plugins/main/bridge/bridge.go b/Godeps/_workspace/src/github.com/appc/cni/plugins/main/bridge/bridge.go index e4bc106c00..e87eb726fc 100644 --- a/Godeps/_workspace/src/github.com/appc/cni/plugins/main/bridge/bridge.go +++ b/Godeps/_workspace/src/github.com/appc/cni/plugins/main/bridge/bridge.go @@ -238,14 +238,29 @@ func cmdDel(args *skel.CmdArgs) error { return err } - err = ipam.ExecDel(n.IPAM.Type, args.StdinData) - if err != nil { + if err := ipam.ExecDel(n.IPAM.Type, args.StdinData); err != nil { return err } - return ns.WithNetNSPath(args.Netns, false, func(hostNS *os.File) error { - return ip.DelLinkByName(args.IfName) + var ipn *net.IPNet + err = ns.WithNetNSPath(args.Netns, false, func(hostNS *os.File) error { + var err error + ipn, err = ip.DelLinkByNameAddr(args.IfName, netlink.FAMILY_V4) + return err }) + if err != nil { + return err + } + + if n.IPMasq { + chain := utils.FormatChainName(n.Name, args.ContainerID) + comment := utils.FormatComment(n.Name, args.ContainerID) + if err = ip.TeardownIPMasq(ipn, chain, comment); err != nil { + return err + } + } + + return nil } func main() { diff --git a/Godeps/_workspace/src/github.com/appc/cni/plugins/main/ptp/ptp.go b/Godeps/_workspace/src/github.com/appc/cni/plugins/main/ptp/ptp.go index 3035c643f7..05b3b2a324 100644 --- a/Godeps/_workspace/src/github.com/appc/cni/plugins/main/ptp/ptp.go +++ b/Godeps/_workspace/src/github.com/appc/cni/plugins/main/ptp/ptp.go @@ -195,6 +195,10 @@ func cmdDel(args *skel.CmdArgs) error { return fmt.Errorf("failed to load netconf: %v", err) } + if err := ipam.ExecDel(conf.IPAM.Type, args.StdinData); err != nil { + return err + } + var ipn *net.IPNet err := ns.WithNetNSPath(args.Netns, false, func(hostNS *os.File) error { var err error @@ -213,7 +217,7 @@ func cmdDel(args *skel.CmdArgs) error { } } - return ipam.ExecDel(conf.IPAM.Type, args.StdinData) + return nil } func main() { From 44d1f4e5068901d1c026073c621490c0f9ef81ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Thu, 12 May 2016 11:40:48 +0200 Subject: [PATCH 0247/1304] fuctional tests: check that each app is in a different mount ns --- tests/inspect/inspect.go | 21 ++++++++++++++++++++ tests/rkt_mountns_test.go | 41 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 tests/rkt_mountns_test.go diff --git a/tests/inspect/inspect.go b/tests/inspect/inspect.go index dbc0bd4004..485d53e8e1 100644 --- a/tests/inspect/inspect.go +++ b/tests/inspect/inspect.go @@ -72,6 +72,7 @@ var ( PrintIfaceCount bool PrintAppAnnotation string SilentSigterm bool + CheckMountNS bool }{} ) @@ -110,6 +111,7 @@ func init() { globalFlagset.BoolVar(&globalFlags.PrintIfaceCount, "print-iface-count", false, "Print the interface count") globalFlagset.StringVar(&globalFlags.PrintAppAnnotation, "print-app-annotation", "", "Take an annotation name of the app, and prints its value") globalFlagset.BoolVar(&globalFlags.SilentSigterm, "silent-sigterm", false, "Exit with a success exit status if we receive SIGTERM") + globalFlagset.BoolVar(&globalFlags.CheckMountNS, "check-mountns", false, "Check if app's mount ns is different than stage1's. Requires CAP_SYS_PTRACE") } func in(list []int, el int) bool { @@ -474,5 +476,24 @@ func main() { fmt.Printf("Annotation %s=%s\n", globalFlags.PrintAppAnnotation, body) } + if globalFlags.CheckMountNS { + appMountNS, err := os.Readlink("/proc/self/ns/mnt") + if err != nil { + fmt.Fprintf(os.Stderr, "%v\n", err) + os.Exit(1) + } + s1MountNS, err := os.Readlink("/proc/1/ns/mnt") + if err != nil { + fmt.Fprintf(os.Stderr, "%v\n", err) + os.Exit(1) + } + if appMountNS != s1MountNS { + fmt.Println("check-mountns: DIFFERENT") + } else { + fmt.Println("check-mountns: IDENTICAL") + os.Exit(1) + } + } + os.Exit(globalFlags.ExitCode) } diff --git a/tests/rkt_mountns_test.go b/tests/rkt_mountns_test.go new file mode 100644 index 0000000000..d7bdf98a92 --- /dev/null +++ b/tests/rkt_mountns_test.go @@ -0,0 +1,41 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build host coreos src kvm + +package main + +import ( + "fmt" + "os" + "testing" + + "github.com/coreos/rkt/tests/testutils" +) + +func TestMountNSApp(t *testing.T) { + image := patchTestACI("rkt-test-mount-ns-app.aci", "--exec=/inspect --check-mountns", "--capability=CAP_SYS_PTRACE") + defer os.Remove(image) + + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + rktCmd := fmt.Sprintf("%s --insecure-options=image run %s", ctx.Cmd(), image) + + expectedLine := "check-mountns: DIFFERENT" + runRktAndCheckOutput(t, rktCmd, expectedLine, false) +} + +func TestSharedSlave(t *testing.T) { +} From affb06c6aa11bea1c06ed5545d20c4dbcd0f2690 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Wed, 11 May 2016 17:00:00 +0200 Subject: [PATCH 0248/1304] Bump Godeps to appc/spec 0.8.0 --- Godeps/Godeps.json | 52 ++--- .../src/github.com/appc/spec/ace/build_aci | 4 +- ..._main.json => image_manifest_main.json.in} | 8 +- ...k.json => image_manifest_sidekick.json.in} | 8 +- .../src/github.com/appc/spec/ace/validator.go | 80 +++---- .../github.com/appc/spec/actool/discover.go | 31 ++- .../github.com/appc/spec/actool/manifest.go | 30 ++- .../appc/spec/discovery/discovery.go | 73 +++---- .../github.com/appc/spec/discovery/http.go | 26 +-- .../github.com/appc/spec/discovery/myapp.html | 15 -- .../appc/spec/discovery/myapp2.html | 15 -- .../appc/spec/pkg/device/device_linux.go | 33 +++ .../appc/spec/pkg/device/device_posix.go | 2 +- .../src/github.com/appc/spec/schema/image.go | 2 +- .../src/github.com/appc/spec/schema/pod.go | 2 +- .../github.com/appc/spec/schema/version.go | 2 +- Godeps/_workspace/src/go4.org/LICENSE | 202 ++++++++++++++++++ .../pkg => go4.org}/errorutil/highlight.go | 0 18 files changed, 403 insertions(+), 182 deletions(-) rename Godeps/_workspace/src/github.com/appc/spec/ace/{image_manifest_main.json => image_manifest_main.json.in} (91%) rename Godeps/_workspace/src/github.com/appc/spec/ace/{image_manifest_sidekick.json => image_manifest_sidekick.json.in} (70%) delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/discovery/myapp.html delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/discovery/myapp2.html create mode 100644 Godeps/_workspace/src/github.com/appc/spec/pkg/device/device_linux.go create mode 100644 Godeps/_workspace/src/go4.org/LICENSE rename Godeps/_workspace/src/{github.com/camlistore/camlistore/pkg => go4.org}/errorutil/highlight.go (100%) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index b8c1333117..62e046a18d 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -163,62 +163,58 @@ }, { "ImportPath": "github.com/appc/spec/ace", - "Comment": "v0.7.4", - "Rev": "0875c991a496fe2b65ed296551c667b199a6bfb8" + "Comment": "v0.8.0", + "Rev": "09a93af33cd0691f49e2d18689af16a1432b13e4" }, { "ImportPath": "github.com/appc/spec/aci", - "Comment": "v0.7.4", - "Rev": "0875c991a496fe2b65ed296551c667b199a6bfb8" + "Comment": "v0.8.0", + "Rev": "09a93af33cd0691f49e2d18689af16a1432b13e4" }, { "ImportPath": "github.com/appc/spec/actool", - "Comment": "v0.7.4", - "Rev": "0875c991a496fe2b65ed296551c667b199a6bfb8" + "Comment": "v0.8.0", + "Rev": "09a93af33cd0691f49e2d18689af16a1432b13e4" }, { "ImportPath": "github.com/appc/spec/discovery", - "Comment": "v0.7.4", - "Rev": "0875c991a496fe2b65ed296551c667b199a6bfb8" + "Comment": "v0.8.0", + "Rev": "09a93af33cd0691f49e2d18689af16a1432b13e4" }, { "ImportPath": "github.com/appc/spec/pkg/acirenderer", - "Comment": "v0.7.4", - "Rev": "0875c991a496fe2b65ed296551c667b199a6bfb8" + "Comment": "v0.8.0", + "Rev": "09a93af33cd0691f49e2d18689af16a1432b13e4" }, { "ImportPath": "github.com/appc/spec/pkg/device", - "Comment": "v0.7.4", - "Rev": "0875c991a496fe2b65ed296551c667b199a6bfb8" + "Comment": "v0.8.0", + "Rev": "09a93af33cd0691f49e2d18689af16a1432b13e4" }, { "ImportPath": "github.com/appc/spec/pkg/tarheader", - "Comment": "v0.7.4", - "Rev": "0875c991a496fe2b65ed296551c667b199a6bfb8" + "Comment": "v0.8.0", + "Rev": "09a93af33cd0691f49e2d18689af16a1432b13e4" }, { "ImportPath": "github.com/appc/spec/schema", - "Comment": "v0.7.4", - "Rev": "0875c991a496fe2b65ed296551c667b199a6bfb8" + "Comment": "v0.8.0", + "Rev": "09a93af33cd0691f49e2d18689af16a1432b13e4" }, { "ImportPath": "github.com/appc/spec/schema/common", - "Comment": "v0.7.4", - "Rev": "0875c991a496fe2b65ed296551c667b199a6bfb8" + "Comment": "v0.8.0", + "Rev": "09a93af33cd0691f49e2d18689af16a1432b13e4" }, { "ImportPath": "github.com/appc/spec/schema/lastditch", - "Comment": "v0.7.4", - "Rev": "0875c991a496fe2b65ed296551c667b199a6bfb8" + "Comment": "v0.8.0", + "Rev": "09a93af33cd0691f49e2d18689af16a1432b13e4" }, { "ImportPath": "github.com/appc/spec/schema/types", - "Comment": "v0.7.4", - "Rev": "0875c991a496fe2b65ed296551c667b199a6bfb8" - }, - { - "ImportPath": "github.com/camlistore/camlistore/pkg/errorutil", - "Rev": "9868aa0f8d8a93ff0b30ff0de46cc351b6b88b30" + "Comment": "v0.8.0", + "Rev": "09a93af33cd0691f49e2d18689af16a1432b13e4" }, { "ImportPath": "github.com/camlistore/go4/lock", @@ -497,6 +493,10 @@ "ImportPath": "github.com/vishvananda/netlink/nl", "Rev": "ecf47fd5739b3d2c3daf7c89c4b9715a2605c21b" }, + { + "ImportPath": "go4.org/errorutil", + "Rev": "03efcb870d84809319ea509714dd6d19a1498483" + }, { "ImportPath": "golang.org/x/crypto/cast5", "Rev": "a7ead6ddf06233883deca151dffaef2effbf498f" diff --git a/Godeps/_workspace/src/github.com/appc/spec/ace/build_aci b/Godeps/_workspace/src/github.com/appc/spec/ace/build_aci index 5baae5b297..ebfc225661 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/ace/build_aci +++ b/Godeps/_workspace/src/github.com/appc/spec/ace/build_aci @@ -6,6 +6,8 @@ set -eu PREFIX="ace" : ${NO_SIGNATURE=} +GOOS="$(go env GOOS)" +GOARCH="$(go env GOARCH)" if ! [[ $0 =~ "${PREFIX}/build_aci" ]]; then echo "invoke from repository root" 1>&2 @@ -20,7 +22,7 @@ for typ in main sidekick; do layoutdir="bin/ace-${typ}-layout" mkdir -p ${layoutdir}/rootfs/opt/acvalidator cp bin/ace-validator ${layoutdir}/rootfs/ - cp ${PREFIX}/image_manifest_${typ}.json ${layoutdir}/manifest + sed -e "s/@GOOS@/$GOOS/" -e "s/@GOARCH@/$GOARCH/" < ${PREFIX}/image_manifest_${typ}.json.in > ${layoutdir}/manifest # now build the tarball, and sign it pushd ${layoutdir} >/dev/null # Set a consistent timestamp so we get a consistent hash diff --git a/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_main.json b/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_main.json.in similarity index 91% rename from Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_main.json rename to Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_main.json.in index f3173b7d34..3f4f11abd5 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_main.json +++ b/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_main.json.in @@ -1,11 +1,11 @@ { - "acVersion": "0.7.4", + "acVersion": "0.8.0", "acKind": "ImageManifest", "name": "coreos.com/ace-validator-main", "labels": [ - { "name": "version", "value": "0.7.4" }, - { "name": "os", "value": "linux" }, - { "name": "arch", "value": "amd64" } + { "name": "version", "value": "0.8.0" }, + { "name": "os", "value": "@GOOS@" }, + { "name": "arch", "value": "@GOARCH@" } ], "app": { "exec": [ diff --git a/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_sidekick.json b/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_sidekick.json.in similarity index 70% rename from Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_sidekick.json rename to Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_sidekick.json.in index f5d08f1173..a227de9000 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_sidekick.json +++ b/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_sidekick.json.in @@ -1,11 +1,11 @@ { - "acVersion": "0.7.4", + "acVersion": "0.8.0", "acKind": "ImageManifest", "name": "coreos.com/ace-validator-sidekick", "labels": [ - { "name": "version", "value": "0.7.4" }, - { "name": "os", "value": "linux" }, - { "name": "arch", "value": "amd64" } + { "name": "version", "value": "0.8.0" }, + { "name": "os", "value": "@GOOS@" }, + { "name": "arch", "value": "@GOARCH@" } ], "app": { "exec": [ diff --git a/Godeps/_workspace/src/github.com/appc/spec/ace/validator.go b/Godeps/_workspace/src/github.com/appc/spec/ace/validator.go index 5c53a22542..420ae78897 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/ace/validator.go +++ b/Godeps/_workspace/src/github.com/appc/spec/ace/validator.go @@ -226,7 +226,7 @@ func ValidateMountpoints(wmp map[string]types.MountPoint) results { return r } -func metadataRequest(req *http.Request) ([]byte, error) { +func metadataRequest(req *http.Request, expectedContentType string) ([]byte, error) { cli := http.Client{ Timeout: 100 * time.Millisecond, } @@ -242,6 +242,11 @@ func metadataRequest(req *http.Request) ([]byte, error) { return nil, fmt.Errorf("Get %s failed with %v", req.URL, resp.StatusCode) } + if respContentType := resp.Header.Get("Content-Type"); respContentType != expectedContentType { + return nil, fmt.Errorf("`%s` did not respond with expected Content-Type header. Expected %s, received %s", + req.RequestURI, expectedContentType, respContentType) + } + body, err := ioutil.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("Get %s failed on body read: %v", req.URL, err) @@ -250,27 +255,28 @@ func metadataRequest(req *http.Request) ([]byte, error) { return body, nil } -func metadataGet(metadataURL, path string) ([]byte, error) { +func metadataGet(metadataURL, path string, expectedContentType string) ([]byte, error) { uri := metadataURL + metadataPathBase + path req, err := http.NewRequest("GET", uri, nil) if err != nil { panic(err) } - return metadataRequest(req) + + return metadataRequest(req, expectedContentType) } -func metadataPost(metadataURL, path string, body []byte) ([]byte, error) { +func metadataPost(metadataURL, path string, body []byte, expectedContentType string) ([]byte, error) { uri := metadataURL + metadataPathBase + path req, err := http.NewRequest("POST", uri, bytes.NewBuffer(body)) if err != nil { panic(err) } - req.Header.Set("Content-Type", "text/plan") + req.Header.Set("Content-Type", "text/plain") - return metadataRequest(req) + return metadataRequest(req, expectedContentType) } -func metadataPostForm(metadataURL, path string, data url.Values) ([]byte, error) { +func metadataPostForm(metadataURL, path string, data url.Values, expectedContentType string) ([]byte, error) { uri := metadataURL + metadataPathBase + path req, err := http.NewRequest("POST", uri, strings.NewReader(data.Encode())) if err != nil { @@ -278,7 +284,7 @@ func metadataPostForm(metadataURL, path string, data url.Values) ([]byte, error) } req.Header.Set("Content-Type", "application/x-www-form-urlencoded") - return metadataRequest(req) + return metadataRequest(req, expectedContentType) } func validatePodAnnotations(metadataURL string, pm *schema.PodManifest) results { @@ -286,28 +292,14 @@ func validatePodAnnotations(metadataURL string, pm *schema.PodManifest) results var actualAnnots types.Annotations - annots, err := metadataGet(metadataURL, "/pod/annotations/") + annotJson, err := metadataGet(metadataURL, "/pod/annotations/", "application/json") if err != nil { return append(r, err) } - for _, key := range strings.Split(string(annots), "\n") { - if key == "" { - continue - } - - val, err := metadataGet(metadataURL, "/pod/annotations/"+key) - if err != nil { - r = append(r, err) - } - - name, err := types.NewACIdentifier(key) - if err != nil { - r = append(r, fmt.Errorf("invalid annotation name: %v", err)) - continue - } - - actualAnnots.Set(*name, string(val)) + err = json.Unmarshal(annotJson, actualAnnots) + if err != nil { + return append(r, err) } if !reflect.DeepEqual(actualAnnots, pm.Annotations) { @@ -320,7 +312,7 @@ func validatePodAnnotations(metadataURL string, pm *schema.PodManifest) results func validatePodMetadata(metadataURL string, pm *schema.PodManifest) results { r := results{} - uuid, err := metadataGet(metadataURL, "/pod/uuid") + uuid, err := metadataGet(metadataURL, "/pod/uuid", "text/plain; charset=us-ascii") if err != nil { return append(r, err) } @@ -349,28 +341,14 @@ func validateAppAnnotations(metadataURL string, pm *schema.PodManifest, app *sch var actualAnnots types.Annotations - annots, err := metadataGet(metadataURL, "/apps/"+string(app.Name)+"/annotations/") + annotJson, err := metadataGet(metadataURL, "/apps/"+string(app.Name)+"/annotations", "application/json") if err != nil { return append(r, err) } - for _, key := range strings.Split(string(annots), "\n") { - if key == "" { - continue - } - - val, err := metadataGet(metadataURL, "/apps/"+string(app.Name)+"/annotations/"+key) - if err != nil { - r = append(r, err) - } - - lbl, err := types.NewACIdentifier(key) - if err != nil { - r = append(r, fmt.Errorf("invalid annotation name: %v", err)) - continue - } - - actualAnnots.Set(*lbl, string(val)) + err = json.Unmarshal(annotJson, actualAnnots) + if err != nil { + return append(r, err) } if !reflect.DeepEqual(actualAnnots, expectedAnnots) { @@ -384,7 +362,7 @@ func validateAppAnnotations(metadataURL string, pm *schema.PodManifest, app *sch func validateAppMetadata(metadataURL string, pm *schema.PodManifest, app *schema.RuntimeApp) results { r := results{} - am, err := metadataGet(metadataURL, "/apps/"+app.Name.String()+"/image/manifest") + am, err := metadataGet(metadataURL, "/apps/"+app.Name.String()+"/image/manifest", "application/json") if err != nil { return append(r, err) } @@ -394,7 +372,7 @@ func validateAppMetadata(metadataURL string, pm *schema.PodManifest, app *schema return append(r, fmt.Errorf("failed to JSON-decode %q manifest: %v", app.Name.String(), err)) } - id, err := metadataGet(metadataURL, "/apps/"+app.Name.String()+"/image/id") + id, err := metadataGet(metadataURL, "/apps/"+app.Name.String()+"/image/id", "text/plain; charset=us-ascii") if err != nil { r = append(r, err) } @@ -411,7 +389,7 @@ func validateSigning(metadataURL string, pm *schema.PodManifest) results { r := results{} // Get our UUID - uuid, err := metadataGet(metadataURL, "/pod/uuid") + uuid, err := metadataGet(metadataURL, "/pod/uuid", "text/plain; charset=us-ascii") if err != nil { return append(r, err) } @@ -421,7 +399,7 @@ func validateSigning(metadataURL string, pm *schema.PodManifest) results { // Sign sig, err := metadataPostForm(metadataURL, "/pod/hmac/sign", url.Values{ "content": []string{plaintext}, - }) + }, "text/plain; charset=us-ascii") if err != nil { return append(r, err) } @@ -431,7 +409,7 @@ func validateSigning(metadataURL string, pm *schema.PodManifest) results { "content": []string{plaintext}, "uuid": []string{string(uuid)}, "signature": []string{string(sig)}, - }) + }, "text/plain; charset=us-ascii") if err != nil { return append(r, err) @@ -448,7 +426,7 @@ func ValidateMetadataSvc() results { return append(r, fmt.Errorf("AC_METADATA_URL is not set")) } - pod, err := metadataGet(metadataURL, "/pod/manifest") + pod, err := metadataGet(metadataURL, "/pod/manifest", "application/json") if err != nil { return append(r, err) } diff --git a/Godeps/_workspace/src/github.com/appc/spec/actool/discover.go b/Godeps/_workspace/src/github.com/appc/spec/actool/discover.go index cfccb76b29..f91f526d7b 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/actool/discover.go +++ b/Godeps/_workspace/src/github.com/appc/spec/actool/discover.go @@ -60,29 +60,44 @@ func runDiscover(args []string) (exit int) { } insecure := discovery.InsecureNone if transportFlags.Insecure { - insecure = discovery.InsecureTls | discovery.InsecureHttp + insecure = discovery.InsecureTLS | discovery.InsecureHTTP } - eps, attempts, err := discovery.DiscoverEndpoints(*app, nil, insecure) + eps, attempts, err := discovery.DiscoverACIEndpoints(*app, nil, insecure) if err != nil { - stderr("error fetching %s: %s", name, err) + stderr("error fetching endpoints for %s: %s", name, err) return 1 } for _, a := range attempts { - fmt.Printf("discover walk: prefix: %s error: %v\n", a.Prefix, a.Error) + fmt.Printf("discover endpoints walk: prefix: %s error: %v\n", a.Prefix, a.Error) } + publicKeys, attempts, err := discovery.DiscoverPublicKeys(*app, nil, insecure) + if err != nil { + stderr("error fetching public keys for %s: %s", name, err) + return 1 + } + for _, a := range attempts { + fmt.Printf("discover public keys walk: prefix: %s error: %v\n", a.Prefix, a.Error) + } + + type discoveryData struct { + ACIEndpoints []discovery.ACIEndpoint + PublicKeys []string + } + if outputJson { - jsonBytes, err := json.MarshalIndent(&eps, "", " ") + dd := discoveryData{ACIEndpoints: eps, PublicKeys: publicKeys} + jsonBytes, err := json.MarshalIndent(dd, "", " ") if err != nil { stderr("error generating JSON: %s", err) return 1 } fmt.Println(string(jsonBytes)) } else { - for _, aciEndpoint := range eps.ACIEndpoints { + for _, aciEndpoint := range eps { fmt.Printf("ACI: %s, ASC: %s\n", aciEndpoint.ACI, aciEndpoint.ASC) } - if len(eps.Keys) > 0 { - fmt.Println("Keys: " + strings.Join(eps.Keys, ",")) + if len(publicKeys) > 0 { + fmt.Println("PublicKeys: " + strings.Join(publicKeys, ",")) } } } diff --git a/Godeps/_workspace/src/github.com/appc/spec/actool/manifest.go b/Godeps/_workspace/src/github.com/appc/spec/actool/manifest.go index d09f11f60c..94eff16a4c 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/actool/manifest.go +++ b/Godeps/_workspace/src/github.com/appc/spec/actool/manifest.go @@ -47,6 +47,7 @@ var ( patchGroup string patchSupplementaryGIDs string patchCaps string + patchRevokeCaps string patchMounts string patchPorts string patchIsolators string @@ -63,6 +64,7 @@ var ( [--exec="/app --debug"] [--user=uid] [--group=gid] [--capability=CAP_SYS_ADMIN,CAP_NET_ADMIN] + [--revoke-capability=CAP_SYS_CHROOT,CAP_MKNOD] [--mounts=work,path=/opt,readOnly=true[:work2,...]] [--ports=query,protocol=tcp,port=8080[:query2,...]] [--supplementary-groups=gid1,gid2,...] @@ -92,7 +94,8 @@ func init() { cmdPatchManifest.Flags.StringVar(&patchUser, "user", "", "Replace user") cmdPatchManifest.Flags.StringVar(&patchGroup, "group", "", "Replace group") cmdPatchManifest.Flags.StringVar(&patchSupplementaryGIDs, "supplementary-groups", "", "Replace supplementary groups, expects a comma-separated list.") - cmdPatchManifest.Flags.StringVar(&patchCaps, "capability", "", "Replace capability") + cmdPatchManifest.Flags.StringVar(&patchCaps, "capability", "", "Set the capability remain set") + cmdPatchManifest.Flags.StringVar(&patchRevokeCaps, "revoke-capability", "", "Set the capability remove set") cmdPatchManifest.Flags.StringVar(&patchMounts, "mounts", "", "Replace mount points") cmdPatchManifest.Flags.StringVar(&patchPorts, "ports", "", "Replace ports") cmdPatchManifest.Flags.StringVar(&patchIsolators, "isolators", "", "Replace isolators") @@ -161,7 +164,14 @@ func patchManifest(im *schema.ImageManifest) error { app.Exec = strings.Split(patchExec, " ") } - if patchUser != "" || patchGroup != "" || patchSupplementaryGIDs != "" || patchCaps != "" || patchMounts != "" || patchPorts != "" || patchIsolators != "" { + if patchUser != "" || + patchGroup != "" || + patchSupplementaryGIDs != "" || + patchCaps != "" || + patchRevokeCaps != "" || + patchMounts != "" || + patchPorts != "" || + patchIsolators != "" { // ...but if we still don't have an app and the user is trying // to patch one of its other parameters, it's an error if app == nil { @@ -192,7 +202,7 @@ func patchManifest(im *schema.ImageManifest) error { if patchCaps != "" { isolator := app.Isolators.GetByName(types.LinuxCapabilitiesRetainSetName) if isolator != nil { - return fmt.Errorf("isolator already exists") + return fmt.Errorf("isolator already exists (os/linux/capabilities-retain-set)") } // Instantiate a Isolator with the content specified by the --capability @@ -203,6 +213,20 @@ func patchManifest(im *schema.ImageManifest) error { } app.Isolators = append(app.Isolators, caps.AsIsolator()) } + if patchRevokeCaps != "" { + isolator := app.Isolators.GetByName(types.LinuxCapabilitiesRevokeSetName) + if isolator != nil { + return fmt.Errorf("isolator already exists (os/linux/capabilities-remove-set)") + } + + // Instantiate a Isolator with the content specified by the --revoke-capability + // parameter. + caps, err := types.NewLinuxCapabilitiesRevokeSet(strings.Split(patchRevokeCaps, ",")...) + if err != nil { + return fmt.Errorf("cannot parse capability %q: %v", patchRevokeCaps, err) + } + app.Isolators = append(app.Isolators, caps.AsIsolator()) + } if patchMounts != "" { mounts := strings.Split(patchMounts, ":") diff --git a/Godeps/_workspace/src/github.com/appc/spec/discovery/discovery.go b/Godeps/_workspace/src/github.com/appc/spec/discovery/discovery.go index 39931d215c..b2dc659541 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/discovery/discovery.go +++ b/Godeps/_workspace/src/github.com/appc/spec/discovery/discovery.go @@ -37,15 +37,17 @@ type ACIEndpoint struct { ASC string } -type Endpoints struct { +// A struct containing both discovered endpoints and keys. Used to avoid +// function duplication (one for endpoints and one for keys, so to avoid two +// doDiscover, two DiscoverWalkFunc) +type discoveryData struct { ACIEndpoints []ACIEndpoint - Keys []string + PublicKeys []string } -func (e *Endpoints) Append(ep Endpoints) { - e.ACIEndpoints = append(e.ACIEndpoints, ep.ACIEndpoints...) - e.Keys = append(e.Keys, ep.Keys...) -} +type ACIEndpoints []ACIEndpoint + +type PublicKeys []string const ( defaultVersion = "latest" @@ -124,7 +126,7 @@ func createTemplateVars(app App) []string { return tplVars } -func doDiscover(pre string, hostHeaders map[string]http.Header, app App, insecure InsecureOption) (*Endpoints, error) { +func doDiscover(pre string, hostHeaders map[string]http.Header, app App, insecure InsecureOption) (*discoveryData, error) { app = *app.Copy() if app.Labels["version"] == "" { app.Labels["version"] = defaultVersion @@ -140,7 +142,7 @@ func doDiscover(pre string, hostHeaders map[string]http.Header, app App, insecur tplVars := createTemplateVars(app) - de := &Endpoints{} + dd := &discoveryData{} for _, m := range meta { if !strings.HasPrefix(app.Name.String(), m.prefix) { @@ -159,41 +161,37 @@ func doDiscover(pre string, hostHeaders map[string]http.Header, app App, insecur if !ok { continue } - de.ACIEndpoints = append(de.ACIEndpoints, ACIEndpoint{ACI: aci, ASC: asc}) + dd.ACIEndpoints = append(dd.ACIEndpoints, ACIEndpoint{ACI: aci, ASC: asc}) case "ac-discovery-pubkeys": - de.Keys = append(de.Keys, m.uri) + dd.PublicKeys = append(dd.PublicKeys, m.uri) } } - return de, nil + return dd, nil } // DiscoverWalk will make HTTPS requests to find discovery meta tags and // optionally will use HTTP if insecure is set. hostHeaders specifies the // header to apply depending on the host (e.g. authentication). Based on the // response of the discoverFn it will continue to recurse up the tree. -func DiscoverWalk(app App, hostHeaders map[string]http.Header, insecure InsecureOption, discoverFn DiscoverWalkFunc) (err error) { - var ( - eps *Endpoints - ) - +func DiscoverWalk(app App, hostHeaders map[string]http.Header, insecure InsecureOption, discoverFn DiscoverWalkFunc) (dd *discoveryData, err error) { parts := strings.Split(string(app.Name), "/") for i := range parts { end := len(parts) - i pre := strings.Join(parts[:end], "/") - eps, err = doDiscover(pre, hostHeaders, app, insecure) - if derr := discoverFn(pre, eps, err); derr != nil { - return derr + dd, err = doDiscover(pre, hostHeaders, app, insecure) + if derr := discoverFn(pre, dd, err); derr != nil { + return dd, derr } } - return + return nil, fmt.Errorf("discovery failed") } // DiscoverWalkFunc can stop a DiscoverWalk by returning non-nil error. -type DiscoverWalkFunc func(prefix string, eps *Endpoints, err error) error +type DiscoverWalkFunc func(prefix string, dd *discoveryData, err error) error // FailedAttempt represents a failed discovery attempt. This is for debugging // and user feedback. @@ -202,59 +200,58 @@ type FailedAttempt struct { Error error } -func walker(out *Endpoints, attempts *[]FailedAttempt, testFn DiscoverWalkFunc) DiscoverWalkFunc { - return func(pre string, eps *Endpoints, err error) error { +func walker(attempts *[]FailedAttempt, testFn DiscoverWalkFunc) DiscoverWalkFunc { + return func(pre string, dd *discoveryData, err error) error { if err != nil { *attempts = append(*attempts, FailedAttempt{pre, err}) return nil } - out.Append(*eps) - if err := testFn(pre, eps, err); err != nil { + if err := testFn(pre, dd, err); err != nil { return err } return nil } } -// DiscoverEndpoints will make HTTPS requests to find the ac-discovery meta +// DiscoverACIEndpoints will make HTTPS requests to find the ac-discovery meta // tags and optionally will use HTTP if insecure is set. hostHeaders // specifies the header to apply depending on the host (e.g. authentication). // It will not give up until it has exhausted the path or found an image // discovery. -func DiscoverEndpoints(app App, hostHeaders map[string]http.Header, insecure InsecureOption) (out *Endpoints, attempts []FailedAttempt, err error) { - out = &Endpoints{} - testFn := func(pre string, eps *Endpoints, err error) error { - if len(out.ACIEndpoints) != 0 { +func DiscoverACIEndpoints(app App, hostHeaders map[string]http.Header, insecure InsecureOption) (ACIEndpoints, []FailedAttempt, error) { + testFn := func(pre string, dd *discoveryData, err error) error { + if len(dd.ACIEndpoints) != 0 { return errEnough } return nil } - err = DiscoverWalk(app, hostHeaders, insecure, walker(out, &attempts, testFn)) + attempts := []FailedAttempt{} + dd, err := DiscoverWalk(app, hostHeaders, insecure, walker(&attempts, testFn)) if err != nil && err != errEnough { return nil, attempts, err } - return out, attempts, nil + return dd.ACIEndpoints, attempts, nil } // DiscoverPublicKey will make HTTPS requests to find the ac-public-keys meta // tags and optionally will use HTTP if insecure is set. hostHeaders // specifies the header to apply depending on the host (e.g. authentication). // It will not give up until it has exhausted the path or found an public key. -func DiscoverPublicKeys(app App, hostHeaders map[string]http.Header, insecure InsecureOption) (out *Endpoints, attempts []FailedAttempt, err error) { - out = &Endpoints{} - testFn := func(pre string, eps *Endpoints, err error) error { - if len(out.Keys) != 0 { +func DiscoverPublicKeys(app App, hostHeaders map[string]http.Header, insecure InsecureOption) (PublicKeys, []FailedAttempt, error) { + testFn := func(pre string, dd *discoveryData, err error) error { + if len(dd.PublicKeys) != 0 { return errEnough } return nil } - err = DiscoverWalk(app, hostHeaders, insecure, walker(out, &attempts, testFn)) + attempts := []FailedAttempt{} + dd, err := DiscoverWalk(app, hostHeaders, insecure, walker(&attempts, testFn)) if err != nil && err != errEnough { return nil, attempts, err } - return out, attempts, nil + return dd.PublicKeys, attempts, nil } diff --git a/Godeps/_workspace/src/github.com/appc/spec/discovery/http.go b/Godeps/_workspace/src/github.com/appc/spec/discovery/http.go index a00d535c15..430bcc61cf 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/discovery/http.go +++ b/Godeps/_workspace/src/github.com/appc/spec/discovery/http.go @@ -33,19 +33,19 @@ const ( const ( InsecureNone InsecureOption = 0 - InsecureTls InsecureOption = 1 << iota - InsecureHttp + InsecureTLS InsecureOption = 1 << iota + InsecureHTTP ) var ( // Client is the default http.Client used for discovery requests. Client *http.Client - ClientInsecureTls *http.Client + ClientInsecureTLS *http.Client // httpDo is the internal object used by discovery to retrieve URLs; it is // defined here so it can be overridden for testing httpDo httpDoer - httpDoInsecureTls httpDoer + httpDoInsecureTLS httpDoer ) // httpDoer is an interface used to wrap http.Client for real requests and @@ -66,13 +66,13 @@ func init() { } httpDo = Client - // copy for InsecureTls - tInsecureTls := *t - tInsecureTls.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} - ClientInsecureTls = &http.Client{ - Transport: &tInsecureTls, + // copy for InsecureTLS + tInsecureTLS := *t + tInsecureTLS.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} + ClientInsecureTLS = &http.Client{ + Transport: &tInsecureTLS, } - httpDoInsecureTls = ClientInsecureTls + httpDoInsecureTLS = ClientInsecureTLS } func httpsOrHTTP(name string, hostHeaders map[string]http.Header, insecure InsecureOption) (urlStr string, body io.ReadCloser, err error) { @@ -90,8 +90,8 @@ func httpsOrHTTP(name string, hostHeaders map[string]http.Header, insecure Insec if hostHeader, ok := hostHeaders[u.Host]; ok { req.Header = hostHeader } - if insecure&InsecureTls != 0 { - res, err = httpDoInsecureTls.Do(req) + if insecure&InsecureTLS != 0 { + res, err = httpDoInsecureTLS.Do(req) return } res, err = httpDo.Do(req) @@ -104,7 +104,7 @@ func httpsOrHTTP(name string, hostHeaders map[string]http.Header, insecure Insec } urlStr, res, err := fetch("https") if err != nil || res.StatusCode != http.StatusOK { - if insecure&InsecureHttp != 0 { + if insecure&InsecureHTTP != 0 { closeBody(res) urlStr, res, err = fetch("http") } diff --git a/Godeps/_workspace/src/github.com/appc/spec/discovery/myapp.html b/Godeps/_workspace/src/github.com/appc/spec/discovery/myapp.html deleted file mode 100644 index 10c80eb64b..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/discovery/myapp.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - My app - - - - - - - -

My App

- - diff --git a/Godeps/_workspace/src/github.com/appc/spec/discovery/myapp2.html b/Godeps/_workspace/src/github.com/appc/spec/discovery/myapp2.html deleted file mode 100644 index 270b4c670e..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/discovery/myapp2.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - My app - - - - - - - -

My App

- - diff --git a/Godeps/_workspace/src/github.com/appc/spec/pkg/device/device_linux.go b/Godeps/_workspace/src/github.com/appc/spec/pkg/device/device_linux.go new file mode 100644 index 0000000000..4f895cd76e --- /dev/null +++ b/Godeps/_workspace/src/github.com/appc/spec/pkg/device/device_linux.go @@ -0,0 +1,33 @@ +// Copyright 2016 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build linux + +package device + +// with glibc/sysdeps/unix/sysv/linux/sys/sysmacros.h as reference + +func Major(rdev uint64) uint { + return uint((rdev>>8)&0xfff) | (uint(rdev>>32) & ^uint(0xfff)) +} + +func Minor(rdev uint64) uint { + return uint(rdev&0xff) | uint(uint32(rdev>>12) & ^uint32(0xff)) +} + +func Makedev(maj uint, min uint) uint64 { + return uint64(min&0xff) | (uint64(maj&0xfff) << 8) | + ((uint64(min) & ^uint64(0xff)) << 12) | + ((uint64(maj) & ^uint64(0xfff)) << 32) +} diff --git a/Godeps/_workspace/src/github.com/appc/spec/pkg/device/device_posix.go b/Godeps/_workspace/src/github.com/appc/spec/pkg/device/device_posix.go index a0bdd774f8..c2e1b31697 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/pkg/device/device_posix.go +++ b/Godeps/_workspace/src/github.com/appc/spec/pkg/device/device_posix.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build linux freebsd netbsd openbsd darwin +// +build freebsd netbsd openbsd darwin package device diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/image.go b/Godeps/_workspace/src/github.com/appc/spec/schema/image.go index 5aa536fd84..fac4c794c3 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/image.go +++ b/Godeps/_workspace/src/github.com/appc/spec/schema/image.go @@ -22,7 +22,7 @@ import ( "github.com/appc/spec/schema/types" - "github.com/camlistore/camlistore/pkg/errorutil" + "go4.org/errorutil" ) const ( diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/pod.go b/Godeps/_workspace/src/github.com/appc/spec/schema/pod.go index 4046816efa..b8699315f0 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/pod.go +++ b/Godeps/_workspace/src/github.com/appc/spec/schema/pod.go @@ -22,7 +22,7 @@ import ( "github.com/appc/spec/schema/types" - "github.com/camlistore/camlistore/pkg/errorutil" + "go4.org/errorutil" ) const PodManifestKind = types.ACKind("PodManifest") diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/version.go b/Godeps/_workspace/src/github.com/appc/spec/schema/version.go index 01c13bc09b..04b92edb02 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/version.go +++ b/Godeps/_workspace/src/github.com/appc/spec/schema/version.go @@ -22,7 +22,7 @@ const ( // version represents the canonical version of the appc spec and tooling. // For now, the schema and tooling is coupled with the spec itself, so // this must be kept in sync with the VERSION file in the root of the repo. - version string = "0.7.4" + version string = "0.8.0" ) var ( diff --git a/Godeps/_workspace/src/go4.org/LICENSE b/Godeps/_workspace/src/go4.org/LICENSE new file mode 100644 index 0000000000..8f71f43fee --- /dev/null +++ b/Godeps/_workspace/src/go4.org/LICENSE @@ -0,0 +1,202 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor 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, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/pkg/errorutil/highlight.go b/Godeps/_workspace/src/go4.org/errorutil/highlight.go similarity index 100% rename from Godeps/_workspace/src/github.com/camlistore/camlistore/pkg/errorutil/highlight.go rename to Godeps/_workspace/src/go4.org/errorutil/highlight.go From f899dd7b79d3b75444f04a51ba2e81b9f3f38558 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Wed, 11 May 2016 17:04:36 +0200 Subject: [PATCH 0249/1304] rkt: fix compilation with appc/spec 0.8.0 The fixes are necessary since the introduction of the following changes: - https://github.com/appc/spec/pull/561 - https://github.com/appc/spec/pull/576 --- rkt/image/namefetcher.go | 16 ++++++++-------- rkt/pubkey/pubkey.go | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/rkt/image/namefetcher.go b/rkt/image/namefetcher.go index 1110251935..9bdc75d757 100644 --- a/rkt/image/namefetcher.go +++ b/rkt/image/namefetcher.go @@ -61,16 +61,16 @@ func (f *nameFetcher) Hash(app *discovery.App, a *asc) (string, error) { return f.fetchImageFromEndpoints(app, ep, a, latest) } -func (f *nameFetcher) discoverApp(app *discovery.App) (*discovery.Endpoints, error) { +func (f *nameFetcher) discoverApp(app *discovery.App) (discovery.ACIEndpoints, error) { insecure := discovery.InsecureNone if f.InsecureFlags.SkipTLSCheck() { - insecure = insecure | discovery.InsecureTls + insecure = insecure | discovery.InsecureTLS } if f.InsecureFlags.AllowHTTP() { - insecure = insecure | discovery.InsecureHttp + insecure = insecure | discovery.InsecureHTTP } hostHeaders := config.ResolveAuthPerHost(f.Headers) - ep, attempts, err := discovery.DiscoverEndpoints(*app, hostHeaders, insecure) + ep, attempts, err := discovery.DiscoverACIEndpoints(*app, hostHeaders, insecure) if f.Debug { for _, a := range attempts { log.PrintE(fmt.Sprintf("meta tag 'ac-discovery' not found on %s", a.Prefix), a.Error) @@ -79,19 +79,19 @@ func (f *nameFetcher) discoverApp(app *discovery.App) (*discovery.Endpoints, err if err != nil { return nil, err } - if len(ep.ACIEndpoints) == 0 { + if len(ep) == 0 { return nil, fmt.Errorf("no endpoints discovered") } return ep, nil } -func (f *nameFetcher) fetchImageFromEndpoints(app *discovery.App, ep *discovery.Endpoints, a *asc, latest bool) (string, error) { +func (f *nameFetcher) fetchImageFromEndpoints(app *discovery.App, ep discovery.ACIEndpoints, a *asc, latest bool) (string, error) { ensureLogger(f.Debug) // TODO(krnowak): we should probably try all the endpoints, // for this we need to clone "a" and call // maybeOverrideAscFetcherWithRemote on the clone - aciURL := ep.ACIEndpoints[0].ACI - ascURL := ep.ACIEndpoints[0].ASC + aciURL := ep[0].ACI + ascURL := ep[0].ASC log.Printf("remote fetching from URL %q", aciURL) f.maybeOverrideAscFetcherWithRemote(ascURL, a) return f.fetchImageFromSingleEndpoint(app, aciURL, a, latest) diff --git a/rkt/pubkey/pubkey.go b/rkt/pubkey/pubkey.go index 5d879c86e5..41d604fc72 100644 --- a/rkt/pubkey/pubkey.go +++ b/rkt/pubkey/pubkey.go @@ -157,12 +157,12 @@ func (m *Manager) metaDiscoverPubKeyLocations(prefix string) ([]string, error) { hostHeaders := config.ResolveAuthPerHost(m.AuthPerHost) insecure := discovery.InsecureNone if m.InsecureAllowHTTP { - insecure = insecure | discovery.InsecureHttp + insecure = insecure | discovery.InsecureHTTP } if m.InsecureSkipTLSCheck { - insecure = insecure | discovery.InsecureTls + insecure = insecure | discovery.InsecureTLS } - ep, attempts, err := discovery.DiscoverPublicKeys(*app, hostHeaders, insecure) + keys, attempts, err := discovery.DiscoverPublicKeys(*app, hostHeaders, insecure) if err != nil { return nil, err } @@ -173,7 +173,7 @@ func (m *Manager) metaDiscoverPubKeyLocations(prefix string) ([]string, error) { } } - return ep.Keys, nil + return keys, nil } // getPubKey retrieves a public key (if remote), and verifies it's a gpg key From f804c9be6451b4e8a7cffa5d287725dff6823b3b Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Thu, 12 May 2016 00:06:56 +0200 Subject: [PATCH 0250/1304] tests: ACE: fix compilation with appc/spec 0.8.0 The fixes are necessary since the introduction of the following changes: - https://github.com/appc/spec/pull/569 --- tests/functional.mk | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/functional.mk b/tests/functional.mk index a866e2c5fc..73cb535c0e 100644 --- a/tests/functional.mk +++ b/tests/functional.mk @@ -10,11 +10,11 @@ FTST_IMAGE_MANIFEST := $(FTST_IMAGE_DIR)/manifest FTST_IMAGE_TEST_DIRS := $(FTST_IMAGE_ROOTFSDIR)/dir1 $(FTST_IMAGE_ROOTFSDIR)/dir2 $(FTST_IMAGE_ROOTFSDIR)/bin $(FTST_IMAGE_ROOTFSDIR)/etc FTST_ACE_MAIN_IMAGE_DIR := $(FTST_TMPDIR)/ace-main FTST_ACE_MAIN_IMAGE := $(FTST_TMPDIR)/rkt-ace-validator-main.aci -FTST_ACE_MAIN_IMAGE_MANIFEST_SRC := Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_main.json +FTST_ACE_MAIN_IMAGE_MANIFEST_SRC := Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_main.json.in FTST_ACE_MAIN_IMAGE_MANIFEST := $(FTST_ACE_MAIN_IMAGE_DIR)/manifest FTST_ACE_SIDEKICK_IMAGE_DIR := $(FTST_TMPDIR)/ace-sidekick FTST_ACE_SIDEKICK_IMAGE := $(FTST_TMPDIR)/rkt-ace-validator-sidekick.aci -FTST_ACE_SIDEKICK_IMAGE_MANIFEST_SRC := Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_sidekick.json +FTST_ACE_SIDEKICK_IMAGE_MANIFEST_SRC := Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_sidekick.json.in FTST_ACE_SIDEKICK_IMAGE_MANIFEST := $(FTST_ACE_SIDEKICK_IMAGE_DIR)/manifest FTST_INSPECT_BINARY := $(FTST_TMPDIR)/inspect FTST_ACI_INSPECT := $(FTST_IMAGE_ROOTFSDIR)/inspect @@ -39,8 +39,6 @@ INSTALL_FILES += \ $(FTST_IMAGE_MANIFEST_SRC):$(FTST_IMAGE_MANIFEST):- \ $(FTST_INSPECT_BINARY):$(FTST_ACI_INSPECT):- \ $(FTST_EMPTY_IMAGE_MANIFEST_SRC):$(FTST_EMPTY_IMAGE_MANIFEST):- \ - $(FTST_ACE_MAIN_IMAGE_MANIFEST_SRC):$(FTST_ACE_MAIN_IMAGE_MANIFEST):- \ - $(FTST_ACE_SIDEKICK_IMAGE_MANIFEST_SRC):$(FTST_ACE_SIDEKICK_IMAGE_MANIFEST):- \ $(FTST_ECHO_SERVER_BINARY):$(FTST_ACI_ECHO_SERVER):- CREATE_DIRS += \ $(FTST_IMAGE_DIR) \ @@ -145,8 +143,16 @@ include makelib/build_go_bin.mk # 1 - image # 2 - aci directory # 3 - ace validator +# 4 - manifest.json.in define FTST_GENERATE_ACE_IMAGE +$$(call forward-vars,$2/manifest,ABS_GO) +$2/manifest: $4 | $2 + $$(VQ) \ + $$(call vb,v2,GEN,$$(call vsp,$$@)) \ + GOARCH="$$$$($$(ABS_GO) env GOARCH)"; \ + sed -e "s/@GOOS@/linux/" -e "s/@GOARCH@/$$$$GOARCH/" <$$< >$$@ + $$(call forward-vars,$1,ACTOOL) $1: $2/manifest $2/rootfs/ace-validator | $2/rootfs/opt/acvalidator $$(VQ) \ @@ -155,10 +161,10 @@ $1: $2/manifest $2/rootfs/ace-validator | $2/rootfs/opt/acvalidator CREATE_DIRS += $2 $$(call dir-chain,$2,rootfs/opt/acvalidator) INSTALL_FILES += $3:$2/rootfs/ace-validator:- -CLEAN_FILES += $1 +CLEAN_FILES += $1 $2/manifest endef -$(eval $(call FTST_GENERATE_ACE_IMAGE,$(FTST_ACE_MAIN_IMAGE),$(FTST_ACE_MAIN_IMAGE_DIR),$(FTST_ACE_BINARY))) -$(eval $(call FTST_GENERATE_ACE_IMAGE,$(FTST_ACE_SIDEKICK_IMAGE),$(FTST_ACE_SIDEKICK_IMAGE_DIR),$(FTST_ACE_BINARY))) +$(eval $(call FTST_GENERATE_ACE_IMAGE,$(FTST_ACE_MAIN_IMAGE),$(FTST_ACE_MAIN_IMAGE_DIR),$(FTST_ACE_BINARY),$(FTST_ACE_MAIN_IMAGE_MANIFEST_SRC))) +$(eval $(call FTST_GENERATE_ACE_IMAGE,$(FTST_ACE_SIDEKICK_IMAGE),$(FTST_ACE_SIDEKICK_IMAGE_DIR),$(FTST_ACE_BINARY),$(FTST_ACE_SIDEKICK_IMAGE_MANIFEST_SRC))) $(call undefine-namespaces,FTST) From 92f06816551068bcfb755d7b18aa8381611f73e5 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Thu, 12 May 2016 12:04:48 +0200 Subject: [PATCH 0251/1304] metadata-service: ACE: fix compilation with appc/spec 0.8.0 The fixes are necessary since the introduction of the following changes: - https://github.com/appc/spec/pull/451 --- rkt/metadata_service.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/rkt/metadata_service.go b/rkt/metadata_service.go index f0fc05e9a6..4855c42906 100644 --- a/rkt/metadata_service.go +++ b/rkt/metadata_service.go @@ -309,7 +309,7 @@ func appGet(h func(http.ResponseWriter, *http.Request, *schema.PodManifest, *sch func handlePodAnnotations(w http.ResponseWriter, r *http.Request, pm *schema.PodManifest) { defer r.Body.Close() - w.Header().Add("Content-Type", "text/plain") + w.Header().Add("Content-Type", "application/json") w.WriteHeader(http.StatusOK) for k := range pm.Annotations { @@ -335,7 +335,7 @@ func handlePodAnnotation(w http.ResponseWriter, r *http.Request, pm *schema.PodM return } - w.Header().Add("Content-Type", "text/plain") + w.Header().Add("Content-Type", "application/json") w.WriteHeader(http.StatusOK) w.Write([]byte(v)) } @@ -363,7 +363,7 @@ func handlePodUUID(w http.ResponseWriter, r *http.Request) { return } - w.Header().Add("Content-Type", "text/plain") + w.Header().Add("Content-Type", "text/plain; charset=us-ascii") w.WriteHeader(http.StatusOK) w.Write([]byte(uuid.String())) } @@ -395,7 +395,7 @@ func handleAppAnnotations(w http.ResponseWriter, r *http.Request, pm *schema.Pod return } - w.Header().Add("Content-Type", "text/plain") + w.Header().Add("Content-Type", "text/plain; charset=us-ascii") w.WriteHeader(http.StatusOK) for _, annot := range mergeAppAnnotations(im, pm, an) { @@ -431,7 +431,7 @@ func handleAppAnnotation(w http.ResponseWriter, r *http.Request, pm *schema.PodM return } - w.Header().Add("Content-Type", "text/plain") + w.Header().Add("Content-Type", "application/json") w.WriteHeader(http.StatusOK) w.Write([]byte(v)) } @@ -458,7 +458,7 @@ func handleAppID(w http.ResponseWriter, r *http.Request, pm *schema.PodManifest, return } - w.Header().Add("Content-Type", "text/plain") + w.Header().Add("Content-Type", "text/plain; charset=us-ascii") w.WriteHeader(http.StatusOK) app := pm.Apps.Get(*an) if app == nil { @@ -501,7 +501,7 @@ func handlePodSign(w http.ResponseWriter, r *http.Request) { h.Write([]byte(content)) // Send back HMAC as the signature - w.Header().Add("Content-Type", "text/plain") + w.Header().Add("Content-Type", "text/plain; charset=us-ascii") w.WriteHeader(http.StatusOK) enc := base64.NewEncoder(base64.StdEncoding, w) enc.Write(h.Sum(nil)) From dcbdfbf7f609f967915f14358284bbd3660c09f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Thu, 12 May 2016 14:35:27 +0200 Subject: [PATCH 0252/1304] functional tests: ignore ACE validator test After https://github.com/appc/spec/pull/451, the spec changed regarding the metadata service. Since its use is not widespread, let's disable the test for now and fix it later. --- tests/rkt_ace_validator_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/rkt_ace_validator_test.go b/tests/rkt_ace_validator_test.go index fc8a514d10..820b396679 100644 --- a/tests/rkt_ace_validator_test.go +++ b/tests/rkt_ace_validator_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build host coreos src +// +build ignore package main From 2f6911d8220508a33ed258d2563216c9267cd6ca Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Fri, 6 May 2016 14:53:45 +0200 Subject: [PATCH 0253/1304] stage1: capabilities: implement both remain set and remove set --- stage1/init/common/pod.go | 112 +++++++++++++++++++++++++++----------- 1 file changed, 80 insertions(+), 32 deletions(-) diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index 8f64b5cd3f..a525009a16 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -57,25 +57,6 @@ var ( "LOGNAME": "root", "HOME": "/root", } - - // appDefaultCapabilities defines a restricted set of capabilities given to - // apps by default. - // See https://github.com/appc/spec/issues/598 - appDefaultCapabilities, _ = types.NewLinuxCapabilitiesRetainSet( - "CAP_AUDIT_WRITE", - "CAP_CHOWN", - "CAP_DAC_OVERRIDE", - "CAP_FSETID", - "CAP_FOWNER", - "CAP_KILL", - "CAP_MKNOD", - "CAP_NET_RAW", - "CAP_NET_BIND_SERVICE", - "CAP_SETUID", - "CAP_SETGID", - "CAP_SETPCAP", - "CAP_SETFCAP", - "CAP_SYS_CHROOT") ) // execEscape uses Golang's string quoting for ", \, \n, and regex for special cases @@ -443,10 +424,10 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b supplementaryGroups = append(supplementaryGroups, strconv.Itoa(g)) } - // TODO: read the RemoveSet as well. See - // https://github.com/coreos/rkt/issues/2348#issuecomment-211796840 - capabilities := append(app.Isolators, appDefaultCapabilities.AsIsolator()) - capabilitiesStr := GetAppCapabilities(capabilities) + capabilitiesStr, err := getAppCapabilities(app.Isolators) + if err != nil { + return err + } execStart := append([]string{binPath}, app.Exec[1:]...) execStartString := quoteExec(execStart) @@ -853,7 +834,11 @@ func appToNspawnArgs(p *stage1commontypes.Pod, ra *schema.RuntimeApp) ([]string, args = append(args, strings.Join(opt, "")) } - capList := strings.Join(GetAppCapabilities(app.Isolators), ",") + capabilitiesStr, err := getAppCapabilities(app.Isolators) + if err != nil { + return nil, err + } + capList := strings.Join(capabilitiesStr, ",") args = append(args, "--capability="+capList) return args, nil @@ -941,18 +926,81 @@ func GetMachineID(p *stage1commontypes.Pod) string { return "rkt-" + p.UUID.String() } -// GetAppCapabilities is a filter which returns a string slice of valid Linux capabilities -// It requires list of available isolators -func GetAppCapabilities(isolators types.Isolators) []string { - var caps []string +// getAppCapabilities computes the set of Linux capabilities that an app +// should have based on its isolators. Only the following capabalities matter: +// - os/linux/capabilities-retain-set +// - os/linux/capabilities-remove-set +// +// The resulting capabilities are generated following the rules from the spec: +// See: https://github.com/appc/spec/blob/master/spec/ace.md#linux-isolators +func getAppCapabilities(isolators types.Isolators) ([]string, error) { + var capsToRetain []string + var capsToRemove []string + + // Default caps defined in + // https://github.com/appc/spec/blob/master/spec/ace.md#linux-isolators + appDefaultCapabilities := []string{ + "CAP_AUDIT_WRITE", + "CAP_CHOWN", + "CAP_DAC_OVERRIDE", + "CAP_FSETID", + "CAP_FOWNER", + "CAP_KILL", + "CAP_MKNOD", + "CAP_NET_RAW", + "CAP_NET_BIND_SERVICE", + "CAP_SETUID", + "CAP_SETGID", + "CAP_SETPCAP", + "CAP_SETFCAP", + "CAP_SYS_CHROOT", + } + // Iterate over the isolators defined in + // https://github.com/appc/spec/blob/master/spec/ace.md#linux-isolators + // Only read the capababilities isolators: + // - os/linux/capabilities-retain-set + // - os/linux/capabilities-remove-set for _, isolator := range isolators { - if capSet, ok := isolator.Value().(types.LinuxCapabilitiesSet); ok && - isolator.Name == types.LinuxCapabilitiesRetainSetName { - caps = append(caps, parseLinuxCapabilitiesSet(capSet)...) + if capSet, ok := isolator.Value().(types.LinuxCapabilitiesSet); ok { + switch isolator.Name { + case types.LinuxCapabilitiesRetainSetName: + capsToRetain = append(capsToRetain, parseLinuxCapabilitiesSet(capSet)...) + case types.LinuxCapabilitiesRevokeSetName: + capsToRemove = append(capsToRemove, parseLinuxCapabilitiesSet(capSet)...) + } + } + } + + // appc/spec does not allow to have both the retain set and the remove + // set defined. + if len(capsToRetain) > 0 && len(capsToRemove) > 0 { + return nil, errors.New("cannot have both os/linux/capabilities-retain-set and os/linux/capabilities-remove-set") + } + + // Neither the retain set or the remove set are defined + if len(capsToRetain) == 0 && len(capsToRemove) == 0 { + return appDefaultCapabilities, nil + } + + if len(capsToRetain) > 0 { + return capsToRetain, nil + } + + if len(capsToRemove) == 0 { + panic("len(capsToRetain) is negative. This cannot happen.") + } + + caps := appDefaultCapabilities + for _, rc := range capsToRemove { + // backward loop to be safe against deletion + for i := len(caps) - 1; i >= 0; i-- { + if caps[i] == rc { + caps = append(caps[:i], caps[i+1:]...) + } } } - return caps + return caps, nil } // parseLinuxCapabilitySet parses a LinuxCapabilitiesSet into string slice From ad2fb5d702c0f24c6f5d1a46fedc76ee555fd80d Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Sat, 7 May 2016 02:09:44 +0200 Subject: [PATCH 0254/1304] tests: TestCapsSeveralApp: new test TestCapsSeveralApp run a pod with 12 apps with various capability definitions and test that each app is executed with the correct caps. --- tests/inspect/inspect.go | 14 +- tests/rkt_caps_test.go | 298 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 306 insertions(+), 6 deletions(-) diff --git a/tests/inspect/inspect.go b/tests/inspect/inspect.go index 485d53e8e1..ad76b27845 100644 --- a/tests/inspect/inspect.go +++ b/tests/inspect/inspect.go @@ -42,6 +42,7 @@ var ( CheckTty bool PrintExec bool PrintMsg string + SuffixMsg string PrintEnv string PrintCapsPid int PrintUser bool @@ -81,6 +82,7 @@ func init() { globalFlagset.BoolVar(&globalFlags.CheckTty, "check-tty", false, "Check if stdin is a terminal") globalFlagset.BoolVar(&globalFlags.PrintExec, "print-exec", false, "Print the command we were execed as (i.e. argv[0])") globalFlagset.StringVar(&globalFlags.PrintMsg, "print-msg", "", "Print the message given as parameter") + globalFlagset.StringVar(&globalFlags.SuffixMsg, "suffix-msg", "", "Print this suffix after some commands") globalFlagset.StringVar(&globalFlags.CheckCwd, "check-cwd", "", "Check if the current working directory is the one specified") globalFlagset.StringVar(&globalFlags.PrintEnv, "print-env", "", "Print the specified environment variable") globalFlagset.IntVar(&globalFlags.PrintCapsPid, "print-caps-pid", -1, "Print capabilities of the specified pid (or current process if pid=0)") @@ -188,10 +190,10 @@ func main() { fmt.Fprintf(os.Stderr, "Cannot get caps: %v\n", err) os.Exit(1) } - fmt.Printf("Capability set: effective: %s\n", caps.StringCap(capability.EFFECTIVE)) - fmt.Printf("Capability set: permitted: %s\n", caps.StringCap(capability.PERMITTED)) - fmt.Printf("Capability set: inheritable: %s\n", caps.StringCap(capability.INHERITABLE)) - fmt.Printf("Capability set: bounding: %s\n", caps.StringCap(capability.BOUNDING)) + fmt.Printf("Capability set: effective: %s (%s)\n", caps.StringCap(capability.EFFECTIVE), globalFlags.SuffixMsg) + fmt.Printf("Capability set: permitted: %s (%s)\n", caps.StringCap(capability.PERMITTED), globalFlags.SuffixMsg) + fmt.Printf("Capability set: inheritable: %s (%s)\n", caps.StringCap(capability.INHERITABLE), globalFlags.SuffixMsg) + fmt.Printf("Capability set: bounding: %s (%s)\n", caps.StringCap(capability.BOUNDING), globalFlags.SuffixMsg) if capStr := os.Getenv("CAPABILITY"); capStr != "" { capInt, err := strconv.Atoi(capStr) @@ -201,9 +203,9 @@ func main() { } c := capability.Cap(capInt) if caps.Get(capability.BOUNDING, c) { - fmt.Printf("%v=enabled\n", c.String()) + fmt.Printf("%v=enabled (%s)\n", c.String(), globalFlags.SuffixMsg) } else { - fmt.Printf("%v=disabled\n", c.String()) + fmt.Printf("%v=disabled (%s)\n", c.String(), globalFlags.SuffixMsg) } } } diff --git a/tests/rkt_caps_test.go b/tests/rkt_caps_test.go index c9fb94be0f..d8fce6b1e0 100644 --- a/tests/rkt_caps_test.go +++ b/tests/rkt_caps_test.go @@ -19,12 +19,310 @@ package main import ( "fmt" "os" + "strings" "testing" "github.com/coreos/rkt/tests/testutils" "github.com/syndtr/gocapability/capability" ) +func TestCapsSeveralApp(t *testing.T) { + // All the following images are launched together in the same pod + var appCapsTests = []struct { + // constants + testName string // name of the image + capRemainSet string // if != "x", value passed to actool patch-manifest --capability= + capRemoveSet string // if != "x", value passed to actool patch-manifest --revoke-capability= + expected string // caps bounding set as printed by gocapability + + // set during the test + imageFile string + }{ + // Testing without isolators + { + testName: "image-none", + capRemainSet: "x", + capRemoveSet: "x", + expected: strings.Join([]string{ + "chown", + "dac_override", + "fowner", + "fsetid", + "kill", + "setgid", + "setuid", + "setpcap", + "net_bind_service", + "net_raw", + "sys_chroot", + "mknod", + "audit_write", + "setfcap", + }, ", "), + }, + // Testing remain set + { + testName: "image-only-one-cap", + capRemainSet: "CAP_NET_ADMIN", + capRemoveSet: "x", + expected: "net_admin", + }, + { + testName: "image-only-one-cap-from-default", + capRemainSet: "CAP_CHOWN", + capRemoveSet: "x", + expected: "chown", + }, + { + testName: "image-some-caps", + capRemainSet: strings.Join([]string{ + "CAP_CHOWN", + "CAP_FOWNER", + "CAP_SYS_ADMIN", + "CAP_NET_ADMIN", + }, ","), + capRemoveSet: "x", + expected: strings.Join([]string{ + "chown", + "fowner", + "net_admin", + "sys_admin", + }, ", "), + }, + { + testName: "image-caps-from-nspawn-default", + capRemainSet: strings.Join([]string{ + "CAP_CHOWN", + "CAP_DAC_OVERRIDE", + "CAP_DAC_READ_SEARCH", + "CAP_FOWNER", + "CAP_FSETID", + "CAP_IPC_OWNER", + "CAP_KILL", + "CAP_LEASE", + "CAP_LINUX_IMMUTABLE", + "CAP_NET_BIND_SERVICE", + "CAP_NET_BROADCAST", + "CAP_NET_RAW", + "CAP_SETGID", + "CAP_SETFCAP", + "CAP_SETPCAP", + "CAP_SETUID", + "CAP_SYS_ADMIN", + "CAP_SYS_CHROOT", + "CAP_SYS_NICE", + "CAP_SYS_PTRACE", + "CAP_SYS_TTY_CONFIG", + "CAP_SYS_RESOURCE", + "CAP_SYS_BOOT", + "CAP_AUDIT_WRITE", + "CAP_AUDIT_CONTROL", + }, ","), + capRemoveSet: "x", + expected: strings.Join([]string{ + "chown", + "dac_override", + "dac_read_search", + "fowner", + "fsetid", + "kill", + "setgid", + "setuid", + "setpcap", + "linux_immutable", + "net_bind_service", + "net_broadcast", + "net_raw", + "ipc_owner", + "sys_chroot", + "sys_ptrace", + "sys_admin", + "sys_boot", + "sys_nice", + "sys_resource", + "sys_tty_config", + "lease", + "audit_write", + "audit_control", + "setfcap", + }, ", "), + }, + // Testing revoke set + { + testName: "image-revoke-one-from-default", + capRemainSet: "x", + capRemoveSet: "CAP_CHOWN", + expected: strings.Join([]string{ + "dac_override, fowner, fsetid, kill, setgid, setuid, setpcap, net_bind_service, net_raw, sys_chroot, mknod, audit_write, setfcap", + }, ", "), + }, + { + testName: "image-revoke-one-already-revoked", + capRemainSet: "x", + capRemoveSet: "CAP_SYS_ADMIN", + expected: strings.Join([]string{ + "chown", + "dac_override", + "fowner", + "fsetid", + "kill", + "setgid", + "setuid", + "setpcap", + "net_bind_service", + "net_raw", + "sys_chroot", + "mknod", + "audit_write", + "setfcap", + }, ", "), + }, + { + testName: "image-revoke-two", + capRemainSet: "x", + capRemoveSet: "CAP_CHOWN,CAP_SYS_ADMIN", + expected: strings.Join([]string{ + "dac_override", + "fowner", + "fsetid", + "kill", + "setgid", + "setuid", + "setpcap", + "net_bind_service", + "net_raw", + "sys_chroot", + "mknod", + "audit_write", + "setfcap", + }, ", "), + }, + { + testName: "image-revoke-all", + capRemainSet: "x", + capRemoveSet: strings.Join([]string{ + "CAP_AUDIT_WRITE", + "CAP_CHOWN", + "CAP_DAC_OVERRIDE", + "CAP_FSETID", + "CAP_FOWNER", + "CAP_KILL", + "CAP_MKNOD", + "CAP_NET_RAW", + "CAP_NET_BIND_SERVICE", + "CAP_SETUID", + "CAP_SETGID", + "CAP_SETPCAP", + "CAP_SETFCAP", + "CAP_SYS_CHROOT", + }, ","), + expected: "", + }, + { + testName: "image-revoke-all-but-one", + capRemainSet: "x", + capRemoveSet: strings.Join([]string{ + "CAP_AUDIT_WRITE", + "CAP_CHOWN", + "CAP_DAC_OVERRIDE", + "CAP_FSETID", + "CAP_FOWNER", + "CAP_KILL", + "CAP_MKNOD", + "CAP_NET_RAW", + "CAP_NET_BIND_SERVICE", + "CAP_SETUID", + "CAP_SETGID", + "CAP_SETPCAP", + "CAP_SETFCAP", + }, ","), + expected: "sys_chroot", + }, + { + testName: "image-revoke-all-plus-one", + capRemainSet: "x", + capRemoveSet: strings.Join([]string{ + "CAP_AUDIT_WRITE", + "CAP_CHOWN", + "CAP_DAC_OVERRIDE", + "CAP_FSETID", + "CAP_FOWNER", + "CAP_KILL", + "CAP_MKNOD", + "CAP_NET_RAW", + "CAP_NET_BIND_SERVICE", + "CAP_SETUID", + "CAP_SETGID", + "CAP_SETPCAP", + "CAP_SETFCAP", + "CAP_SYS_CHROOT", + "CAP_SYS_ADMIN", + }, ","), + expected: "", + }, + // Testing with an empty remain set or an empty remove set + // TODO(alban): "actool patch-manifest" cannot generate those images for now + //{ + // testName: "image-remain-set-empty", + // capRemainSet: "", + // capRemoveSet: "x", + // expected: "", + //}, + //{ + // testName: "image-revoke-none", + // capRemainSet: "x", + // capRemoveSet: "", + // expected: "TODO(alban)", + //}, + } + + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + for i, tt := range appCapsTests { + patches := []string{ + fmt.Sprintf("--name=%s", tt.testName), + fmt.Sprintf("--exec=/inspect --print-caps-pid=0 --suffix-msg=%s", tt.testName), + } + if tt.capRemainSet != "x" { + patches = append(patches, "--capability="+tt.capRemainSet) + } + if tt.capRemoveSet != "x" { + patches = append(patches, "--revoke-capability="+tt.capRemoveSet) + } + imageFile := patchTestACI(tt.testName+".aci", patches...) + defer os.Remove(imageFile) + appCapsTests[i].imageFile = imageFile + t.Logf("Built image %q", imageFile) + } + + // Generate the rkt arguments to launch all the apps in the same pod + rktArgs := "" + for _, tt := range appCapsTests { + rktArgs += " " + tt.imageFile + } + cmd := fmt.Sprintf("%s --insecure-options=image run %s", ctx.Cmd(), rktArgs) + + // Ideally, the test would run the pod only one time, but all + // apps' output is mixed together without ordering guarantees, so + // it makes it impossible to call all the expectWithOutput() in + // the correct order. + for _, tt := range appCapsTests { + t.Logf("Checking caps for %q", tt.testName) + child := spawnOrFail(t, cmd) + + expected := fmt.Sprintf("Capability set: bounding: %s (%s)", + tt.expected, tt.testName) + if err := expectWithOutput(child, expected); err != nil { + t.Fatalf("Expected %q but not found: %v", expected, err) + } + + waitOrFail(t, child, 0) + + ctx.RunGC() + } +} + var capsTests = []struct { testName string capIsolator string From 4a30cee695ba9f4cf5742a5ebedd5ad613d2ecad Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Fri, 13 May 2016 10:46:04 +0300 Subject: [PATCH 0255/1304] godep: update appc/spec to v0.8.1 --- Godeps/Godeps.json | 46 +++++++++---------- .../appc/spec/ace/image_manifest_main.json.in | 4 +- .../spec/ace/image_manifest_sidekick.json.in | 4 +- .../src/github.com/appc/spec/schema/pod.go | 11 +++-- .../github.com/appc/spec/schema/version.go | 2 +- 5 files changed, 34 insertions(+), 33 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 62e046a18d..ea6ae03d68 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,7 +1,7 @@ { "ImportPath": "github.com/coreos/rkt", "GoVersion": "go1.5", - "GodepVersion": "v60", + "GodepVersion": "v62", "Packages": [ "./...", "github.com/appc/spec/actool", @@ -163,58 +163,58 @@ }, { "ImportPath": "github.com/appc/spec/ace", - "Comment": "v0.8.0", - "Rev": "09a93af33cd0691f49e2d18689af16a1432b13e4" + "Comment": "v0.8.1", + "Rev": "b889d03467ae08bb6c13241762a64305b69bcf82" }, { "ImportPath": "github.com/appc/spec/aci", - "Comment": "v0.8.0", - "Rev": "09a93af33cd0691f49e2d18689af16a1432b13e4" + "Comment": "v0.8.1", + "Rev": "b889d03467ae08bb6c13241762a64305b69bcf82" }, { "ImportPath": "github.com/appc/spec/actool", - "Comment": "v0.8.0", - "Rev": "09a93af33cd0691f49e2d18689af16a1432b13e4" + "Comment": "v0.8.1", + "Rev": "b889d03467ae08bb6c13241762a64305b69bcf82" }, { "ImportPath": "github.com/appc/spec/discovery", - "Comment": "v0.8.0", - "Rev": "09a93af33cd0691f49e2d18689af16a1432b13e4" + "Comment": "v0.8.1", + "Rev": "b889d03467ae08bb6c13241762a64305b69bcf82" }, { "ImportPath": "github.com/appc/spec/pkg/acirenderer", - "Comment": "v0.8.0", - "Rev": "09a93af33cd0691f49e2d18689af16a1432b13e4" + "Comment": "v0.8.1", + "Rev": "b889d03467ae08bb6c13241762a64305b69bcf82" }, { "ImportPath": "github.com/appc/spec/pkg/device", - "Comment": "v0.8.0", - "Rev": "09a93af33cd0691f49e2d18689af16a1432b13e4" + "Comment": "v0.8.1", + "Rev": "b889d03467ae08bb6c13241762a64305b69bcf82" }, { "ImportPath": "github.com/appc/spec/pkg/tarheader", - "Comment": "v0.8.0", - "Rev": "09a93af33cd0691f49e2d18689af16a1432b13e4" + "Comment": "v0.8.1", + "Rev": "b889d03467ae08bb6c13241762a64305b69bcf82" }, { "ImportPath": "github.com/appc/spec/schema", - "Comment": "v0.8.0", - "Rev": "09a93af33cd0691f49e2d18689af16a1432b13e4" + "Comment": "v0.8.1", + "Rev": "b889d03467ae08bb6c13241762a64305b69bcf82" }, { "ImportPath": "github.com/appc/spec/schema/common", - "Comment": "v0.8.0", - "Rev": "09a93af33cd0691f49e2d18689af16a1432b13e4" + "Comment": "v0.8.1", + "Rev": "b889d03467ae08bb6c13241762a64305b69bcf82" }, { "ImportPath": "github.com/appc/spec/schema/lastditch", - "Comment": "v0.8.0", - "Rev": "09a93af33cd0691f49e2d18689af16a1432b13e4" + "Comment": "v0.8.1", + "Rev": "b889d03467ae08bb6c13241762a64305b69bcf82" }, { "ImportPath": "github.com/appc/spec/schema/types", - "Comment": "v0.8.0", - "Rev": "09a93af33cd0691f49e2d18689af16a1432b13e4" + "Comment": "v0.8.1", + "Rev": "b889d03467ae08bb6c13241762a64305b69bcf82" }, { "ImportPath": "github.com/camlistore/go4/lock", diff --git a/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_main.json.in b/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_main.json.in index 3f4f11abd5..511e2a5359 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_main.json.in +++ b/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_main.json.in @@ -1,9 +1,9 @@ { - "acVersion": "0.8.0", + "acVersion": "0.8.1", "acKind": "ImageManifest", "name": "coreos.com/ace-validator-main", "labels": [ - { "name": "version", "value": "0.8.0" }, + { "name": "version", "value": "0.8.1" }, { "name": "os", "value": "@GOOS@" }, { "name": "arch", "value": "@GOARCH@" } ], diff --git a/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_sidekick.json.in b/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_sidekick.json.in index a227de9000..9020e4f10d 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_sidekick.json.in +++ b/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_sidekick.json.in @@ -1,9 +1,9 @@ { - "acVersion": "0.8.0", + "acVersion": "0.8.1", "acKind": "ImageManifest", "name": "coreos.com/ace-validator-sidekick", "labels": [ - { "name": "version", "value": "0.8.0" }, + { "name": "version", "value": "0.8.1" }, { "name": "os", "value": "@GOOS@" }, { "name": "arch", "value": "@GOARCH@" } ], diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/pod.go b/Godeps/_workspace/src/github.com/appc/spec/schema/pod.go index b8699315f0..d4792ff3b4 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/pod.go +++ b/Godeps/_workspace/src/github.com/appc/spec/schema/pod.go @@ -152,11 +152,12 @@ func (r Mount) assertValid() error { // RuntimeApp describes an application referenced in a PodManifest type RuntimeApp struct { - Name types.ACName `json:"name"` - Image RuntimeImage `json:"image"` - App *types.App `json:"app,omitempty"` - Mounts []Mount `json:"mounts,omitempty"` - Annotations types.Annotations `json:"annotations,omitempty"` + Name types.ACName `json:"name"` + Image RuntimeImage `json:"image"` + App *types.App `json:"app,omitempty"` + ReadOnlyRootFS bool `json:"readOnlyRootFS,omitempty"` + Mounts []Mount `json:"mounts,omitempty"` + Annotations types.Annotations `json:"annotations,omitempty"` } // RuntimeImage describes an image referenced in a RuntimeApp diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/version.go b/Godeps/_workspace/src/github.com/appc/spec/schema/version.go index 04b92edb02..eaa5f8bfdc 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/version.go +++ b/Godeps/_workspace/src/github.com/appc/spec/schema/version.go @@ -22,7 +22,7 @@ const ( // version represents the canonical version of the appc spec and tooling. // For now, the schema and tooling is coupled with the spec itself, so // this must be kept in sync with the VERSION file in the root of the repo. - version string = "0.8.0" + version string = "0.8.1" ) var ( From b55c7d74b842248dff103fca77c861253ef5122d Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Wed, 11 May 2016 13:49:47 +0300 Subject: [PATCH 0256/1304] docs: sort subcommand descriptions --- Documentation/subcommands/run.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/subcommands/run.md b/Documentation/subcommands/run.md index 8ed9571535..36a43a3d69 100644 --- a/Documentation/subcommands/run.md +++ b/Documentation/subcommands/run.md @@ -361,11 +361,11 @@ For more details see the [hacking documentation](../hacking.md). | `--private-users` | `false` | `true` or `false` | Run within user namespaces. | | `--set-env` | none | An environment variable (ex. `--set-env=NAME=VALUE`) | An environment variable to set for apps. | | `--signature` | none | A file path | Local signature file to use in validating the preceding image | -| `--stage1-url` | none | URL with protocol | A URL to a stage1 image. HTTP/HTTPS/File/Docker URLs are supported. | -| `--stage1-path` | none | Absolute or relative path | A path to a stage1 image. | -| `--stage1-name` | none | Image name (ex. `--stage1-name=coreos.com/rkt/stage1-coreos`) | A name of a stage1 image. Will perform a discovery if the image is not in the store. | -| `--stage1-hash` | none | Image hash (ex. `--stage1-hash=sha512-dedce9f5ea50`) | A hash of a stage1 image. The image must exist in the store. | | `--stage1-from-dir` | none | Image name (ex. `--stage1-name=coreos.com/rkt/stage1-coreos`) | A stage1 image file name to search for inside the default stage1 images directory. | +| `--stage1-hash` | none | Image hash (ex. `--stage1-hash=sha512-dedce9f5ea50`) | A hash of a stage1 image. The image must exist in the store. | +| `--stage1-name` | none | Image name (ex. `--stage1-name=coreos.com/rkt/stage1-coreos`) | A name of a stage1 image. Will perform a discovery if the image is not in the store. | +| `--stage1-path` | none | Absolute or relative path | A path to a stage1 image. | +| `--stage1-url` | none | URL with protocol | A URL to a stage1 image. HTTP/HTTPS/File/Docker URLs are supported. | | `--store-only` | `false` | `true` or `false` | Use only available images in the store (do not discover or download from remote URLs). See [image fetching behavior](../image-fetching-behavior.md). | | `--uuid-file-save` | none | A file path | Write out the pod UUID to a file. | | `--volume` | none | Volume syntax (ex. `--volume NAME,kind=KIND,source=PATH,readOnly=BOOL`) | Volumes to make available in the pod. See [Mount Volumes into a Pod](#mount-volumes-into-a-pod). | From a644d42ef19e4f0b266cc7cbd6174762d4c1ec31 Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Wed, 11 May 2016 14:13:19 +0300 Subject: [PATCH 0257/1304] stage1: implement read-only rootfs Using the Pod manifest `readOnlyRootFS` option mounts the rootfs of the app as read-only using systemd-exec unit option `ReadOnlyDirectories`. Uses `ReadWriteDirectories` systemd-exec unit option for mounting read-write volumes. Fixes #2487 --- stage1/init/common/pod.go | 31 ++++ tests/rkt_run_pod_manifest_test.go | 284 +++++++++++++++++++++++++++++ 2 files changed, 315 insertions(+) diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index a525009a16..ee9b756129 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -449,6 +449,37 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b unit.NewUnitOption("Service", "CapabilityBoundingSet", strings.Join(capabilitiesStr, " ")), } + if ra.ReadOnlyRootFS { + opts = append(opts, unit.NewUnitOption("Service", "ReadOnlyDirectories", "/")) + } + + // TODO(tmrts): Extract this logic into a utility function. + vols := make(map[types.ACName]types.Volume) + for _, v := range p.Manifest.Volumes { + vols[v.Name] = v + } + + absRoot, err := filepath.Abs(p.Root) // Absolute path to the pod's rootfs. + if err != nil { + return err + } + appRootfs := common.AppRootfsPath(absRoot, appName) + + rwDirs := []string{} + imageManifest := p.Images[appName.String()] + for _, m := range GenerateMounts(ra, vols, imageManifest) { + mntPath, err := EvaluateSymlinksInsideApp(appRootfs, m.Path) + if err != nil { + return err + } + + if !IsMountReadOnly(vols[m.Volume], app.MountPoints) { + rwDirs = append(rwDirs, mntPath) + } + } + + opts = append(opts, unit.NewUnitOption("Service", "ReadWriteDirectories", strings.Join(rwDirs, " "))) + if interactive { opts = append(opts, unit.NewUnitOption("Service", "StandardInput", "tty")) opts = append(opts, unit.NewUnitOption("Service", "StandardOutput", "tty")) diff --git a/tests/rkt_run_pod_manifest_test.go b/tests/rkt_run_pod_manifest_test.go index 69a72d876a..15f105c136 100644 --- a/tests/rkt_run_pod_manifest_test.go +++ b/tests/rkt_run_pod_manifest_test.go @@ -143,6 +143,31 @@ func TestPodManifest(t *testing.T) { "dir1", "", }, + { + // Simple read from read-only rootfs. + []imagePatch{ + {"rkt-test-run-read-only-rootfs-pod-manifest-read.aci", []string{}}, + }, + &schema.PodManifest{ + Apps: []schema.RuntimeApp{ + { + Name: baseAppName, + App: &types.App{ + Exec: []string{"/inspect", "--read-file"}, + User: "0", + Group: "0", + Environment: []types.EnvironmentVariable{ + {"FILE", "/dir1/file"}, + }, + }, + ReadOnlyRootFS: true, + }, + }, + }, + 0, + "dir1", + "", + }, { // Simple read after write with *empty* volume mounted. []imagePatch{ @@ -180,6 +205,44 @@ func TestPodManifest(t *testing.T) { "empty:foo", "", }, + { + // Simple read from read-only rootfs after write with *empty* volume mounted. + []imagePatch{ + {"rkt-test-run-pod-manifest-read-only-rootfs-empty-vol-rw.aci", []string{}}, + }, + &schema.PodManifest{ + Apps: []schema.RuntimeApp{ + { + Name: baseAppName, + App: &types.App{ + Exec: []string{"/inspect", "--write-file", "--read-file"}, + User: "0", + Group: "0", + Environment: []types.EnvironmentVariable{ + {"FILE", "/dir1/file"}, + {"CONTENT", "empty:foo"}, + }, + MountPoints: []types.MountPoint{ + {"dir1", "/dir1", false}, + }, + }, + ReadOnlyRootFS: true, + }, + }, + Volumes: []types.Volume{ + { + Name: "dir1", + Kind: "empty", + Mode: stringP("0755"), + UID: intP(0), + GID: intP(0), + }, + }, + }, + 0, + "empty:foo", + "", + }, { // Stat directory in a *empty* volume mounted. []imagePatch{ @@ -216,6 +279,43 @@ func TestPodManifest(t *testing.T) { "(?s)/dir1: mode: d--x-w--wx.*" + "/dir1: user: 9991.*" + "/dir1: group: 9992", "", }, + { + // Stat directory in a *empty* volume mounted using a read-only rootfs. + []imagePatch{ + {"rkt-test-run-pod-manifest-read-only-rootfs-empty-vol-stat.aci", []string{}}, + }, + &schema.PodManifest{ + Apps: []schema.RuntimeApp{ + { + Name: baseAppName, + App: &types.App{ + Exec: []string{"/inspect", "--stat-file"}, + User: "0", + Group: "0", + Environment: []types.EnvironmentVariable{ + {"FILE", "/dir1"}, + }, + MountPoints: []types.MountPoint{ + {"dir1", "/dir1", false}, + }, + }, + ReadOnlyRootFS: true, + }, + }, + Volumes: []types.Volume{ + { + Name: "dir1", + Kind: "empty", + Mode: stringP("0123"), + UID: intP(9991), + GID: intP(9992), + }, + }, + }, + 0, + "(?s)/dir1: mode: d--x-w--wx.*" + "/dir1: user: 9991.*" + "/dir1: group: 9992", + "", + }, { // Simple read after write with volume mounted. []imagePatch{ @@ -247,6 +347,38 @@ func TestPodManifest(t *testing.T) { "host:foo", "", }, + { + // Simple read after write with volume mounted in a read-only rootfs. + []imagePatch{ + {"rkt-test-run-pod-manifest-read-only-rootfs-vol-rw.aci", []string{}}, + }, + &schema.PodManifest{ + Apps: []schema.RuntimeApp{ + { + Name: baseAppName, + App: &types.App{ + Exec: []string{"/inspect", "--write-file", "--read-file"}, + User: "0", + Group: "0", + Environment: []types.EnvironmentVariable{ + {"FILE", "/dir1/file"}, + {"CONTENT", "host:foo"}, + }, + MountPoints: []types.MountPoint{ + {"dir1", "/dir1", false}, + }, + }, + ReadOnlyRootFS: true, + }, + }, + Volumes: []types.Volume{ + {"dir1", "host", tmpdir, nil, nil, nil, nil}, + }, + }, + 0, + "host:foo", + "", + }, { // Simple read after write with read-only mount point, should fail. []imagePatch{ @@ -278,6 +410,38 @@ func TestPodManifest(t *testing.T) { `Cannot write to file "/dir1/file": open /dir1/file: read-only file system`, "", }, + { + // Simple read after write with read-only mount point in a read-only rootfs, should fail. + []imagePatch{ + {"rkt-test-run-pod-manifest-read-only-rootfs-vol-ro.aci", []string{}}, + }, + &schema.PodManifest{ + Apps: []schema.RuntimeApp{ + { + Name: baseAppName, + App: &types.App{ + Exec: []string{"/inspect", "--write-file", "--read-file"}, + User: "0", + Group: "0", + Environment: []types.EnvironmentVariable{ + {"FILE", "/dir1/file"}, + {"CONTENT", "bar"}, + }, + MountPoints: []types.MountPoint{ + {"dir1", "/dir1", true}, + }, + }, + ReadOnlyRootFS: true, + }, + }, + Volumes: []types.Volume{ + {"dir1", "host", tmpdir, nil, nil, nil, nil}, + }, + }, + 1, + `Cannot write to file "/dir1/file": open /dir1/file: read-only file system`, + "", + }, { // Simple read after write with volume mounted. // Override the image's mount point spec. This should fail as the volume is @@ -311,6 +475,40 @@ func TestPodManifest(t *testing.T) { `Cannot write to file "/dir1/file": open /dir1/file: read-only file system`, "", }, + { + // Simple read after write with volume mounted in a read-only rootfs. + // Override the image's mount point spec. This should fail as the volume is + // read-only in pod manifest, (which will override the mount point in both image/pod manifest). + []imagePatch{ + {"rkt-test-run-pod-manifest-vol-rw-override.aci", []string{"--mounts=dir1,path=/dir1,readOnly=false"}}, + }, + &schema.PodManifest{ + Apps: []schema.RuntimeApp{ + { + Name: baseAppName, + App: &types.App{ + Exec: []string{"/inspect", "--write-file", "--read-file"}, + User: "0", + Group: "0", + Environment: []types.EnvironmentVariable{ + {"FILE", "/dir1/file"}, + {"CONTENT", "bar"}, + }, + MountPoints: []types.MountPoint{ + {"dir1", "/dir1", false}, + }, + }, + ReadOnlyRootFS: true, + }, + }, + Volumes: []types.Volume{ + {"dir1", "host", tmpdir, &boolTrue, nil, nil, nil}, + }, + }, + 1, + `Cannot write to file "/dir1/file": open /dir1/file: read-only file system`, + "", + }, { // Simple read after write with volume mounted. // Override the image's mount point spec. @@ -343,6 +541,39 @@ func TestPodManifest(t *testing.T) { "host:bar", "", }, + { + // Simple read after write with volume mounted in a read-only rootfs. + // Override the image's mount point spec. + []imagePatch{ + {"rkt-test-run-pod-manifest-read-only-rootfs-vol-rw-override.aci", []string{"--mounts=dir1,path=/dir1,readOnly=true"}}, + }, + &schema.PodManifest{ + Apps: []schema.RuntimeApp{ + { + Name: baseAppName, + App: &types.App{ + Exec: []string{"/inspect", "--write-file", "--read-file"}, + User: "0", + Group: "0", + Environment: []types.EnvironmentVariable{ + {"FILE", "/dir2/file"}, + {"CONTENT", "host:bar"}, + }, + MountPoints: []types.MountPoint{ + {"dir1", "/dir2", false}, + }, + }, + ReadOnlyRootFS: true, + }, + }, + Volumes: []types.Volume{ + {"dir1", "host", tmpdir, nil, nil, nil, nil}, + }, + }, + 0, + "host:bar", + "", + }, { // Simple read after write with volume mounted, no apps in pod manifest. []imagePatch{ @@ -366,6 +597,32 @@ func TestPodManifest(t *testing.T) { "host:baz", "", }, + { + // Simple read after write with volume mounted in a read-only rootfs, no apps in pod manifest. + []imagePatch{ + { + "rkt-test-run-pod-manifest-read-only-rootfs-vol-rw-no-app.aci", + []string{ + "--exec=/inspect --write-file --read-file --file-name=/dir1/file --content=host:baz", + "--mounts=dir1,path=/dir1,readOnly=false", + }, + }, + }, + &schema.PodManifest{ + Apps: []schema.RuntimeApp{ + { + Name: baseAppName, + ReadOnlyRootFS: true, + }, + }, + Volumes: []types.Volume{ + {"dir1", "host", tmpdir, nil, nil, nil, nil}, + }, + }, + 1, + `Cannot write to file "/dir1/host": open /dir1/host: read-only file system`, + "", + }, { // Simple read after write with volume mounted, no apps in pod manifest. // This should succeed even the mount point in image manifest is readOnly, @@ -415,6 +672,33 @@ func TestPodManifest(t *testing.T) { `Cannot write to file "/dir1/file": open /dir1/file: read-only file system`, "", }, + { + // Simple read after write in read-only rootfs with read-only volume mounted, no apps in pod manifest. + // This should fail as the volume is read-only. + []imagePatch{ + { + "rkt-test-run-pod-manifest-read-only-rootfs-vol-ro-no-app.aci", + []string{ + "--exec=/inspect --write-file --read-file --file-name=/dir1/file --content=baz", + "--mounts=dir1,path=/dir1,readOnly=false", + }, + }, + }, + &schema.PodManifest{ + Apps: []schema.RuntimeApp{ + { + Name: baseAppName, + ReadOnlyRootFS: true, + }, + }, + Volumes: []types.Volume{ + {"dir1", "host", tmpdir, &boolTrue, nil, nil, nil}, + }, + }, + 1, + `Cannot write to file "/dir1/file": open /dir1/file: read-only file system`, + "", + }, { // Print CPU quota, which should be overwritten by the pod manifest. []imagePatch{ From 25266779c2f9d02561ffc8dfd0520cd1e699977e Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Fri, 13 May 2016 12:15:55 +0300 Subject: [PATCH 0258/1304] tests/rkt-run-pod-manifest: contain test failures Tests shouldn't fail completely when a case fails --- tests/rkt_run_pod_manifest_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/rkt_run_pod_manifest_test.go b/tests/rkt_run_pod_manifest_test.go index 15f105c136..c494b250e7 100644 --- a/tests/rkt_run_pod_manifest_test.go +++ b/tests/rkt_run_pod_manifest_test.go @@ -1068,7 +1068,8 @@ func TestPodManifest(t *testing.T) { if tt.expectedResult != "" { if _, out, err := expectRegexWithOutput(child, tt.expectedResult); err != nil { - t.Fatalf("Expected %q but not found: %v\n%s", tt.expectedResult, err, out) + t.Errorf("Expected %q but not found: %v\n%s", tt.expectedResult, err, out) + continue } } waitOrFail(t, child, tt.expectedExit) @@ -1085,7 +1086,8 @@ func TestPodManifest(t *testing.T) { if tt.expectedResult != "" { if _, out, err := expectRegexWithOutput(child, tt.expectedResult); err != nil { - t.Fatalf("Expected %q but not found: %v\n%s", tt.expectedResult, err, out) + t.Errorf("Expected %q but not found: %v\n%s", tt.expectedResult, err, out) + continue } } From e46dcddf7252151dac5bcf798ca30aa1fd2c86d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Fri, 13 May 2016 13:18:38 +0200 Subject: [PATCH 0259/1304] stage1/init: use path relative to stage1 in Read.*Directories Systemd doesn't take paths relative to RootDirectory when specifying ReadWriteDirectories and ReadOnlyDirectories. --- stage1/init/common/pod.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index ee9b756129..0f5db3808e 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -450,7 +450,7 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b } if ra.ReadOnlyRootFS { - opts = append(opts, unit.NewUnitOption("Service", "ReadOnlyDirectories", "/")) + opts = append(opts, unit.NewUnitOption("Service", "ReadOnlyDirectories", common.RelAppRootfsPath(appName))) } // TODO(tmrts): Extract this logic into a utility function. @@ -474,7 +474,7 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b } if !IsMountReadOnly(vols[m.Volume], app.MountPoints) { - rwDirs = append(rwDirs, mntPath) + rwDirs = append(rwDirs, filepath.Join(common.RelAppRootfsPath(appName), mntPath)) } } From 93293d996742ccf104aa04d1ea8345ddedd8d3cd Mon Sep 17 00:00:00 2001 From: Piotr Skamruk Date: Fri, 13 May 2016 14:15:35 +0200 Subject: [PATCH 0260/1304] kvm: fix flannel network info Closes #2604 --- networking/kvm.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/networking/kvm.go b/networking/kvm.go index 7753680234..cf2a5ef4e5 100644 --- a/networking/kvm.go +++ b/networking/kvm.go @@ -35,7 +35,6 @@ import ( "github.com/vishvananda/netlink" "github.com/coreos/rkt/common" - "github.com/coreos/rkt/networking/netinfo" "github.com/coreos/rkt/networking/tuntap" ) @@ -397,12 +396,11 @@ func kvmTransformFlannelNetwork(net *activeNet) error { return errwrap.Wrap(errors.New("error in marshaling generated network settings"), err) } + net.runtime.IP4 = &cnitypes.IPConfig{} *net = activeNet{ confBytes: bytes, conf: &NetConf{}, - runtime: &netinfo.NetInfo{ - IP4: &cnitypes.IPConfig{}, - }, + runtime: net.runtime, } net.conf.Name = n.Name net.conf.Type = n.Delegate["type"].(string) From ec22d5b50e3295980fb2df02e39c6abdc4fe58a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Fri, 13 May 2016 14:37:02 +0200 Subject: [PATCH 0261/1304] functional tests: fix pod manifest tests for RO rootfs --- tests/rkt_run_pod_manifest_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/rkt_run_pod_manifest_test.go b/tests/rkt_run_pod_manifest_test.go index c494b250e7..2b46ee6cb7 100644 --- a/tests/rkt_run_pod_manifest_test.go +++ b/tests/rkt_run_pod_manifest_test.go @@ -580,7 +580,7 @@ func TestPodManifest(t *testing.T) { { "rkt-test-run-pod-manifest-vol-rw-no-app.aci", []string{ - "--exec=/inspect --write-file --read-file --file-name=/dir1/file --content=host:baz", + "--exec=/inspect --write-file --read-file --file-name=/dir1/file --content=host:baw", "--mounts=dir1,path=/dir1,readOnly=false", }, }, @@ -594,7 +594,7 @@ func TestPodManifest(t *testing.T) { }, }, 0, - "host:baz", + "host:baw", "", }, { @@ -619,14 +619,14 @@ func TestPodManifest(t *testing.T) { {"dir1", "host", tmpdir, nil, nil, nil, nil}, }, }, - 1, - `Cannot write to file "/dir1/host": open /dir1/host: read-only file system`, + 0, + "host:baz", "", }, { // Simple read after write with volume mounted, no apps in pod manifest. // This should succeed even the mount point in image manifest is readOnly, - // because it is overrided by the volume's readOnly. + // because it is overriden by the volume's readOnly. []imagePatch{ { "rkt-test-run-pod-manifest-vol-ro-no-app.aci", From 5c0c31d6a4e5af25e3cc77473c15b641d3f3fe9e Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Fri, 13 May 2016 16:20:39 +0200 Subject: [PATCH 0262/1304] ROADMAP: update --- ROADMAP.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index 04fbd596a6..d04c5ab900 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -9,14 +9,12 @@ The version of the spec that rkt implements can be seen in the output of `rkt ve rkt's version 1.0 release marks the command line user interface and on-disk data structures as stable and reliable for external development. The (optional) API for pod inspection is not yet completely stabilized, but is quite usable. -### rkt 1.6 (May) +### rkt 1.7 (May) - enhanced DNS configuration [#2044](https://github.com/coreos/rkt/issues/2044) - app-level seccomp support [#1614](https://github.com/coreos/rkt/issues/1614) -- more isolation between stage1 and stage2 [#2483](https://github.com/coreos/rkt/issues/2483) -- user configuration for stage1 [#2013](https://github.com/coreos/rkt/issues/2013) -### rkt 1.7 (May) +### rkt 1.8 (June) - stable gRPC [API](https://github.com/coreos/rkt/tree/master/api/v1alpha) - IPv6 support [appc/cni#31](https://github.com/appc/cni/issues/31) @@ -26,3 +24,4 @@ rkt's version 1.0 release marks the command line user interface and on-disk data - rkt runs on Fedora with SELinux in enforcing mode - packaged for more distributions - CentOS [#1305](https://github.com/coreos/rkt/issues/1305) +- user configuration for stage1 [#2013](https://github.com/coreos/rkt/issues/2013) From c2fc06a98644d378fac2b261f860bb48a7ddb300 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Fri, 13 May 2016 17:35:52 +0200 Subject: [PATCH 0263/1304] CHANGELOG: add v1.6.0 --- CHANGELOG.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec3106b63b..b6a3f2e88d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,35 @@ +## v1.6.0 + +This release focuses on security enhancements. It provides additional isolators, creating a new mount namespace per app. Also a new version of CoreOS 1032.0.0 with systemd v229 is being used in stage1. + +#### New features and UX changes + +- stage1: implement read-only rootfs ([#2624](https://github.com/coreos/rkt/pull/2624)). Using the Pod manifest readOnlyRootFS option mounts the rootfs of the app as read-only using systemd-exec unit option ReadOnlyDirectories, see [appc/spec](https://github.com/appc/spec/blob/master/spec/pods.md#pod-manifest-schema). +- stage1: capabilities: implement both remain set and remove set ([#2589](https://github.com/coreos/rkt/pull/2589)). It follows the [Linux Isolators semantics from the App Container Executor spec](https://github.com/appc/spec/blob/master/spec/ace.md#linux-isolators), as modified by [appc/spec#600](https://github.com/appc/spec/pull/600). +- stage1/init: create a new mount ns for each app ([#2603](https://github.com/coreos/rkt/pull/2603)). Up to this point, you could escape the app's chroot easily by using a simple program downloaded from the internet [1](http://www.unixwiz.net/techtips/chroot-practices.html). To avoid this, we now create a new mount namespace per each app. +- api: Return the pods even when we failed getting information about them ([#2593](https://github.com/coreos/rkt/pull/2593)). +- stage1/usr_from_coreos: use CoreOS 1032.0.0 with systemd v229 ([#2514](https://github.com/coreos/rkt/pull/2514)). + +#### Bug fixes + +- kvm: fix flannel network info ([#2625](https://github.com/coreos/rkt/pull/2625)). It wasn't saving the network information on disk. +- stage1: Machine name wasn't being populated with the full UUID ([#2575](https://github.com/coreos/rkt/pull/2575)). +- rkt: Some simple arg doc string fixes ([#2588](https://github.com/coreos/rkt/pull/2588)). Remove some unnecessary indefinite articles from the start of argument doc strings and fixes the arg doc string for run-prepared's --interactive flag. +- stage1: Fix segfault in enterexec ([#2608](https://github.com/coreos/rkt/pull/2608)). This happened if rkt enter was executed without the TERM environment variable set. +- net: fix port forwarding behavior with custom CNI ipMasq'ed networks and allow different hostPort:podPort combinations ([#2387](https://github.com/coreos/rkt/pull/2387)). +- stage0: check and create /etc ([#2599](https://github.com/coreos/rkt/pull/2599)). Checks '/etc' before writing to '/etc/rkt-resolv.conf' and creates it with default permissions if it doesn't exist. + +#### Other changes + +- godep: update cni to v0.2.3 ([#2618](https://github.com/coreos/rkt/pull/2618)). +- godep: update appc/spec to v0.8.1 ([#2623](https://github.com/coreos/rkt/pull/2623), [#2611](https://github.com/coreos/rkt/pull/2611)). +- dist: Update tmpfiles to create /etc/rkt ([#2472](https://github.com/coreos/rkt/pull/2472)). By creating this directory, users can run `rkt trust` without being root, if the user is in the rkt group. +- Invoke gofmt with simplify-code flag ([#2489](https://github.com/coreos/rkt/pull/2489)). Enables code simplification checks of gofmt. +- Implement composable uid/gid generators ([#2510](https://github.com/coreos/rkt/pull/2510)). This cleans up the code a bit and implements uid/gid functionality for rkt fly. +- stage1: download CoreOS over HTTPS ([#2568](https://github.com/coreos/rkt/pull/2568)). +- Documentation updates ([#2555](https://github.com/coreos/rkt/pull/2555), [#2609](https://github.com/coreos/rkt/pull/2609), [#2605](https://github.com/coreos/rkt/pull/2605), [#2578](https://github.com/coreos/rkt/pull/2578), [#2614](https://github.com/coreos/rkt/pull/2614), [#2579](https://github.com/coreos/rkt/pull/2579), [#2570](https://github.com/coreos/rkt/pull/2570)). +- Test improvements ([#2613](https://github.com/coreos/rkt/pull/2613), [#2566](https://github.com/coreos/rkt/pull/2566), [#2508](https://github.com/coreos/rkt/pull/2508)). + ## v1.5.1 This release is a minor bug fix release. From 14437382a98e5ebeb6cafb57cff445370e3f7d56 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Fri, 13 May 2016 17:36:43 +0200 Subject: [PATCH 0264/1304] version: bump to v1.6.0 --- Documentation/getting-started-ubuntu.md | 6 +++--- Documentation/running-fly-stage1.md | 4 ++-- Documentation/running-lkvm-stage1.md | 4 ++-- Documentation/subcommands/prepare.md | 2 +- Documentation/subcommands/version.md | 2 +- Documentation/trying-out-rkt.md | 6 +++--- configure.ac | 2 +- scripts/acbuild-rkt-builder.sh | 2 +- scripts/build-rir.sh | 2 +- tests/empty-image/manifest | 2 +- tests/image/manifest | 2 +- tests/rkt_exec_test.go | 2 +- tests/rkt_image_cat_manifest_test.go | 2 +- tests/rkt_image_export_test.go | 2 +- tests/rkt_image_render_test.go | 2 +- tests/rkt_os_arch_test.go | 2 +- 16 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Documentation/getting-started-ubuntu.md b/Documentation/getting-started-ubuntu.md index ecf6d7090d..2b53e27848 100644 --- a/Documentation/getting-started-ubuntu.md +++ b/Documentation/getting-started-ubuntu.md @@ -15,9 +15,9 @@ vagrant up --provider virtualbox vagrant ssh sudo -s -wget https://github.com/coreos/rkt/releases/download/v1.5.1/rkt-v1.5.1.tar.gz -tar xzvf rkt-v1.5.1.tar.gz -cd rkt-v1.5.1 +wget https://github.com/coreos/rkt/releases/download/v1.6.0/rkt-v1.6.0.tar.gz +tar xzvf rkt-v1.6.0.tar.gz +cd rkt-v1.6.0 ./rkt help ``` diff --git a/Documentation/running-fly-stage1.md b/Documentation/running-fly-stage1.md index 1ff6303ed2..1d145e8031 100644 --- a/Documentation/running-fly-stage1.md +++ b/Documentation/running-fly-stage1.md @@ -60,14 +60,14 @@ $ ./autogen.sh && ./configure --with-stage1-flavors=fly && make ``` For more details about configure parameters, see the [configure script parameters documentation](build-configure.md). -This will build the rkt binary and the stage1-fly.aci in `build-rkt-1.5.1+git/bin/`. +This will build the rkt binary and the stage1-fly.aci in `build-rkt-1.6.0+git/bin/`. ### Selecting stage1 at runtime Here is a quick example of how to use a container with the official fly stage1: ``` -# rkt run --stage1-name=coreos.com/rkt/stage1-fly:1.5.1 coreos.com/etcd:v2.2.5 +# rkt run --stage1-name=coreos.com/rkt/stage1-fly:1.6.0 coreos.com/etcd:v2.2.5 ``` If the image is not in the store, `--stage1-name` will perform discovery and fetch the image. diff --git a/Documentation/running-lkvm-stage1.md b/Documentation/running-lkvm-stage1.md index c80c8bf657..d75391b533 100644 --- a/Documentation/running-lkvm-stage1.md +++ b/Documentation/running-lkvm-stage1.md @@ -13,7 +13,7 @@ $ ./autogen.sh && ./configure --with-stage1-flavors=kvm && make ``` For more details about configure parameters, see [configure script parameters documentation](build-configure.md). -This will build the rkt binary and the LKVM stage1-kvm.aci in `build-rkt-1.5.1+git/bin/`. +This will build the rkt binary and the LKVM stage1-kvm.aci in `build-rkt-1.6.0+git/bin/`. Provided you have hardware virtualization support and the [kernel KVM module](http://www.linux-kvm.org/page/Getting_the_kvm_kernel_modules) loaded (refer to your distribution for instructions), you can then run an image like you would normally do with rkt: @@ -84,7 +84,7 @@ If you want to run software that requires hypervisor isolation along with truste For example, to use the official lkvm stage1: ``` -# rkt run --stage1-name=coreos.com/rkt/stage1-kvm:1.5.1 coreos.com/etcd:v2.0.9 +# rkt run --stage1-name=coreos.com/rkt/stage1-kvm:1.6.0 coreos.com/etcd:v2.0.9 ... ``` diff --git a/Documentation/subcommands/prepare.md b/Documentation/subcommands/prepare.md index 9ab207a796..5e55a81f8c 100644 --- a/Documentation/subcommands/prepare.md +++ b/Documentation/subcommands/prepare.md @@ -14,7 +14,7 @@ Therefore, the supported arguments are mostly the same as in `run` except runtim ``` # rkt prepare coreos.com/etcd:v2.0.10 rkt prepare coreos.com/etcd:v2.0.10 -rkt: using image from local store for image name coreos.com/rkt/stage1-coreos:1.5.1 +rkt: using image from local store for image name coreos.com/rkt/stage1-coreos:1.6.0 rkt: searching for app image coreos.com/etcd:v2.0.10 rkt: remote fetching from url https://github.com/coreos/etcd/releases/download/v2.0.10/etcd-v2.0.10-linux-amd64.aci prefix: "coreos.com/etcd" diff --git a/Documentation/subcommands/version.md b/Documentation/subcommands/version.md index 1ad445e790..56b5c9c937 100644 --- a/Documentation/subcommands/version.md +++ b/Documentation/subcommands/version.md @@ -6,7 +6,7 @@ This command prints the rkt version, the appc version rkt is built against, and ``` $ rkt version -rkt Version: 1.5.1 +rkt Version: 1.6.0 appc Version: 0.7.4 Go Version: go1.5.3 Go OS/Arch: linux/amd64 diff --git a/Documentation/trying-out-rkt.md b/Documentation/trying-out-rkt.md index f9e48b0b71..96736c4aa1 100644 --- a/Documentation/trying-out-rkt.md +++ b/Documentation/trying-out-rkt.md @@ -10,9 +10,9 @@ rkt consists of a single CLI tool, and is currently supported on amd64 Linux. A To download the rkt binary, simply grab the latest release directly from GitHub: ``` -wget https://github.com/coreos/rkt/releases/download/v1.5.1/rkt-v1.5.1.tar.gz -tar xzvf rkt-v1.5.1.tar.gz -cd rkt-v1.5.1 +wget https://github.com/coreos/rkt/releases/download/v1.6.0/rkt-v1.6.0.tar.gz +tar xzvf rkt-v1.6.0.tar.gz +cd rkt-v1.6.0 ./rkt help ``` diff --git a/configure.ac b/configure.ac index bdba629c22..dba4a9bcce 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.63]) -AC_INIT([rkt], [1.5.1+git], [https://github.com/coreos/rkt/issues]) +AC_INIT([rkt], [1.6.0], [https://github.com/coreos/rkt/issues]) AC_DEFUN([RKT_CHECK_PROG], [AS_VAR_IF([$1], [], diff --git a/scripts/acbuild-rkt-builder.sh b/scripts/acbuild-rkt-builder.sh index 72e6023dbb..94f40d38b0 100755 --- a/scripts/acbuild-rkt-builder.sh +++ b/scripts/acbuild-rkt-builder.sh @@ -17,7 +17,7 @@ fi MODIFY=${MODIFY:-""} FLAGS=${FLAGS:-""} IMG_NAME="coreos.com/rkt/builder" -IMG_VERSION=${VERSION:-"v1.5.1+git"} +IMG_VERSION=${VERSION:-"v1.6.0"} ACI_FILE=rkt-builder.aci BUILDDIR=/opt/build-rkt SRC_DIR=/opt/rkt diff --git a/scripts/build-rir.sh b/scripts/build-rir.sh index d1e8dfb55f..9f225e8471 100755 --- a/scripts/build-rir.sh +++ b/scripts/build-rir.sh @@ -4,7 +4,7 @@ set -xe SRC_DIR="${SRC_DIR:-$PWD}" BUILDDIR="${BUILDDIR:-$PWD/build-rir}" -RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.5.1+git}" +RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.6.0}" mkdir -p $BUILDDIR diff --git a/tests/empty-image/manifest b/tests/empty-image/manifest index d423df3965..7ef4622e87 100644 --- a/tests/empty-image/manifest +++ b/tests/empty-image/manifest @@ -5,7 +5,7 @@ "labels": [ { "name": "version", - "value": "1.5.1" + "value": "1.6.0" }, { "name": "arch", diff --git a/tests/image/manifest b/tests/image/manifest index 46b767e09e..d4abdfe4dc 100644 --- a/tests/image/manifest +++ b/tests/image/manifest @@ -5,7 +5,7 @@ "labels": [ { "name": "version", - "value": "1.5.1" + "value": "1.6.0" }, { "name": "arch", diff --git a/tests/rkt_exec_test.go b/tests/rkt_exec_test.go index 51c8702ce4..b9e3be307d 100644 --- a/tests/rkt_exec_test.go +++ b/tests/rkt_exec_test.go @@ -26,7 +26,7 @@ import ( ) const ( - noappManifestStr = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"coreos.com/rkt-inspect","labels":[{"name":"version","value":"1.5.1"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}]}` + noappManifestStr = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"coreos.com/rkt-inspect","labels":[{"name":"version","value":"1.6.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}]}` ) func TestRunOverrideExec(t *testing.T) { diff --git a/tests/rkt_image_cat_manifest_test.go b/tests/rkt_image_cat_manifest_test.go index f927ea4346..9831833c66 100644 --- a/tests/rkt_image_cat_manifest_test.go +++ b/tests/rkt_image_cat_manifest_test.go @@ -29,7 +29,7 @@ import ( const ( // The expected image manifest of the 'rkt-inspect-image-cat-manifest.aci'. - manifestTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.5.1"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.6.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageCatManifest tests 'rkt image cat-manifest', it will: diff --git a/tests/rkt_image_export_test.go b/tests/rkt_image_export_test.go index 219029118a..80a203961b 100644 --- a/tests/rkt_image_export_test.go +++ b/tests/rkt_image_export_test.go @@ -28,7 +28,7 @@ import ( ) const ( - manifestExportTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.5.1"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestExportTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.6.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageExport tests 'rkt image export', it will import some existing diff --git a/tests/rkt_image_render_test.go b/tests/rkt_image_render_test.go index ab34c6254c..191b7d6388 100644 --- a/tests/rkt_image_render_test.go +++ b/tests/rkt_image_render_test.go @@ -28,7 +28,7 @@ import ( ) const ( - manifestRenderTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.5.1"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"dependencies":[{"imageName":"coreos.com/rkt-inspect"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestRenderTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.6.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"dependencies":[{"imageName":"coreos.com/rkt-inspect"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageRender tests 'rkt image render', it will import some existing empty diff --git a/tests/rkt_os_arch_test.go b/tests/rkt_os_arch_test.go index 081196fccd..172a80d74e 100644 --- a/tests/rkt_os_arch_test.go +++ b/tests/rkt_os_arch_test.go @@ -27,7 +27,7 @@ import ( ) const ( - manifestOSArchTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.5.1"}ARCH_OS],"app":{"exec":["/inspect", "--print-msg=HelloWorld"],"user":"0","group":"0","workingDirectory":"/"}}` + manifestOSArchTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.6.0"}ARCH_OS],"app":{"exec":["/inspect", "--print-msg=HelloWorld"],"user":"0","group":"0","workingDirectory":"/"}}` ) type osArchTest struct { From 0faae55f62f7874f022a9b89843ff8703f91295a Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Fri, 13 May 2016 17:20:29 +0200 Subject: [PATCH 0265/1304] version: bump to v1.6.0+git --- configure.ac | 2 +- scripts/acbuild-rkt-builder.sh | 2 +- scripts/build-rir.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index dba4a9bcce..dce34b5c9c 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.63]) -AC_INIT([rkt], [1.6.0], [https://github.com/coreos/rkt/issues]) +AC_INIT([rkt], [1.6.0+git], [https://github.com/coreos/rkt/issues]) AC_DEFUN([RKT_CHECK_PROG], [AS_VAR_IF([$1], [], diff --git a/scripts/acbuild-rkt-builder.sh b/scripts/acbuild-rkt-builder.sh index 94f40d38b0..d3bb62a776 100755 --- a/scripts/acbuild-rkt-builder.sh +++ b/scripts/acbuild-rkt-builder.sh @@ -17,7 +17,7 @@ fi MODIFY=${MODIFY:-""} FLAGS=${FLAGS:-""} IMG_NAME="coreos.com/rkt/builder" -IMG_VERSION=${VERSION:-"v1.6.0"} +IMG_VERSION=${VERSION:-"v1.6.0+git"} ACI_FILE=rkt-builder.aci BUILDDIR=/opt/build-rkt SRC_DIR=/opt/rkt diff --git a/scripts/build-rir.sh b/scripts/build-rir.sh index 9f225e8471..6f771b6bda 100755 --- a/scripts/build-rir.sh +++ b/scripts/build-rir.sh @@ -4,7 +4,7 @@ set -xe SRC_DIR="${SRC_DIR:-$PWD}" BUILDDIR="${BUILDDIR:-$PWD/build-rir}" -RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.6.0}" +RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.6.0+git}" mkdir -p $BUILDDIR From 4e0cfd012d4073d817b8469b56d79241b74f00e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chris=20K=C3=BChl?= Date: Fri, 6 May 2016 16:14:08 +0200 Subject: [PATCH 0266/1304] docs: add containerd to comparison doc --- Documentation/rkt-vs-docker-process-model.png | Bin 105884 -> 37744 bytes Documentation/rkt-vs-other-projects.md | 28 +++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Documentation/rkt-vs-docker-process-model.png b/Documentation/rkt-vs-docker-process-model.png index b40ad1915a7c40eb6565dfd0e5826200c6455693..4348157c002e1f14f2416a1f2a2820a3162479f2 100644 GIT binary patch literal 37744 zcmeF3Wl&tt7T^;?2pZgi1`jSlf)ijM5ZoOC4DK?x6WoHkyGwBQ;7)LN7+eS0;k|uZ ze_qvo-Q5pcbql5%ZujZar_Vj-*XK@hP;NhSx z@>`tf&|k1dLQ+DnUR6dQ-Rr%5^-A#7HxVI4r`Lz6Z{5s$ZriBS4#154Jxjj@LuP1X zX>0tsbHPuI<8gQ8H8F@W@-?!?pTJ=21}>F)u;uCfiqWq*SKF#&b4SiUz-x#H{~vH# zY9iZtiXCtTwC!#rktCHO0xKf;;$o$cP155x#C(m8_TrKe1o&IRzHIa^f$uNqM@(l8 z@q!Qh$JJjj#zzW6_RlL4`!znc+L{9JWe?EC#&`cEK@}NkHW{7U0R77zNVC6Q|6`2j z@dTA&4HOOhWfDbS&cQ%&m-wah=>5T7p}{35pQ>L78t4^@xb)_QprkNr=#g?!*!+e# zFXj(z%yfM@j0hWqe!Lm!D}v+J?z%0W_c@_C`@`z^X@9S|KvN=gbG$~JOh z4zAw_C*HxZ0)gu4`Un!%5b7+K_K$;xlR5M0Kc;^E#0EO+;aRzr2JIK-H}(;`mPE%K zwLKnLc^;fU-t-ArKIMi(XMx4%eU?Q{`ie}p8+N8dZNuX%I=x2203j-BjS5}wa>zukB+=I8!7Nks58JeNxgYeY zV~3L12Ol;_p2RO5X8P(Z7PjMw|Yo7HUD_&Z^6BmiwVh= zv+nQ0RJO~`JGYIaDPP#Ekb|9g0HJtmw6wJIgxjj1fp+gVODm68oB`tw7vo}}okDJU z*ZrwN%drfh@Hyr(PPQK_Pmk9RkOX z(pRWkSvffrb1L5=*f}`3fr9H*rqe|?nK9`Ku^qeDLDXpptU4DViiRSS?QrCDTHmN2 zMm?_B>PGn?IT|@K@zM^bC+XH?UVBE7sxaF2imrjGD3SI4Emsl<~Zqv}}90 zGK;=AtR8iwx%0do)My-CnHR&D1T1FtzTklxsFjM4^6p zx<6k+7b9G&wORp}HG#Q7PY>5kx92;Mc6p$J_29hc(}TPEBg?$&oMC)J6uDUA6Qu3w zyzk4(Z0i+!-5_HVSIqqLqJq}~NUq4+U5{JpNIvDK%4KS0y35q&DD~rZyvChN54#e~6_^AQ9 zp@~%J^LbLqGvNDCfv4uC&0ms)*Yp6~ z>(|%&uip`_PG)`9@wna6F4Spusw5EbXy)0=iC*mEzpCVb+hV9&Tt8-*U|y(#fSVxP zHddq+TWQ&k$s87E*8@RQhHsv_ucPKjtT@rY=ygaWllNi6w=tbecJ z{p@}xa3gdL^;?7QGO|ep&WG3-iH#*71xzcMpCjX=Sbw#odc+p*-N}+kermH&Z*}iF3K7DJ9dVk#nawb>V?*026FT%^Nep%L!8_{3 zxnz-~UR6QNALbG>tRF7&1uhXgq0Ymy+&t4Q#TDG3-EenV?s*hD=k$ff91lB`Ihv&7 zHzN7#4!qk#BY}ez%*bGjeiHIt_+Sk3T$+36R&Q(h5!UIGx&M=lJXh% zmBbzRI6&Z|hc+Kj{-mU$wYAiSXR^fusM+YOyly#m=O4qtjT`aPy@_z!Bo7jZ`EB4c zZoi#qU1eDzF=+%y35^QYb|Tfb!`6xe7^!&+*aX^z6zHEjg@`o%>)O* z))RlG8+=T_xeV7Dtbn8+fsQIM_ErLRFpY0)`PT);)|(%F^!Q(S>K_*+7gdImbn$dQ zx5u4-92z3Uv%q7=18IW5*qVXNr1f>^`+bKPw{m%ZCKGj=S-Y^hz=3B9#C6x(f4(Y*!ktSUM1Fmr$dBr zjnr%-wCT~o{1f|f?Smxrp%)wg4bavbW=sp=Dc~~}$@fAlvb|V>hXZ-Zn>(nJ$8FCx zJbWiG;>+E(=$55|E=pjrU}9|?B*gHD0F|ix*Y!VPDY3RH$q^hVP=c}O-hUkb8-g~9 zJ|8gH`zb$Veex9b4Wb@^im@9$V->@En8w=32fZ&;@CNCpQa|p#BoY79?Wk)H#`4E@ zZcV0%jXS?~YH_EC%*e8Kvic$$qON}Di#y#6()7Ej{AQb8*9l_h%_!|mR5nCH8A?3# zmHTZ@J|<=C4Ytk}ETcYpyn(}32>1Y79*iI33aqk5(g(r_sr6uosQ{aNiqRy#z`=pP z>)cJmV@Mozydz1mMukA1mj{FG#wb6r02tRa5*LSa)eqMl?m<;u^mwz>^}}*?72F@# z;PLQ>nhEWOSol4So|sJ=RuaB+q9DHE!ju04xFK=b{n!`!9>Ch`h__p_F%?tjx6`W6rkO$jpU z;f?V!>&xoY>0r`c1*3z-_d-99CUcJN2o)kB^1tg8XET&l)?6Pza+XVBem{Y&$)g&C zSVwmTr#Ho+71T>6vhn^a-`6FZ!XF$T#jVGM_Ck;(OjR~rIik^kME$s>3N5Fd3VixmP!{QP{sn6)o>c-&2 zjJ0<6S;K1W%IJ~`I{5 zAC=I>4kZN#?DCPEiRcIu@B5$PVIz|OKNiRoaj+Gvm6P<^`ihE((!`pm}%=I!XNy7!)VE)ie z3@oD9j2zJjhb?zwk^wchZQ#Z3_|X;muEg9&2C&v%eUkqLQA;NbE(Kr=-$HDzD}aRD zd$a)qkS}M84(NnjAE(oBTT9?jq>4}7{nQ1mY+(rn>Bq7!u7{l z*2E0b08&H1-!5}l6BEpzlBx_yvlNTl%y`V}36<*+b2vEog4T9qs9-r%-V-lS>5p1i z+!93_bbkE<0iS#|`&Y9RX`*2C&|U+8sIk7W9dr@x`b!Wn!o?NOgeX% z3DCpEbXdUF{#{!LL!4(T@ zm>_4i$eJY~g~x|tA|D&I?}W#IS`G7&h<^mf1FfObS_;s?*rnK8{KapGZp>%)*)J}?>V;u>x07Ng-PsZl$-Pdy!Ck@kXa%sJJTl0!<)I(41zQ zmbc>9MZR?SlNXho6YD_G{DRB*s^8w&v612XWhf$}ET*Ue*f0_JkLt%omXdvb`K|kT z^7>$W`~J1eA0KVL@5{#PRV|z90f!d(*nl=(8`5q!P0QE6>BR;Etr<~*tu5oOM436Z1ghgHLD^3wHs8=rpC@;d{tnnRPrLE|*nTxrF8p zL%b$z+DgZSA6MxjUSj~nC(8uQzQza*eErrzl8le#c7#6%@D?^PNQcq^ZPzo;!^cb{J=CE7WXj=VJfdY6=ozwm+p z4Zs{?O2Ry?Sc4rhc)U7dEZb1LfjlBj*B|EA=X;iGX}X`&Uzz!Y+u(kkL+JqH^>l;< z-4W@(?p@3-F%}`N&$#%JvOdsVWT>e>?+2NX6C>L4jj^#HdweB~BK*3J0m~`Ix&Dmr zn%stv9?xqK!;&Abm*yNVujH@4EU@t_f7-|S&*p!b(;4P|3!YMIzo`=h!ocfN6J372 z2{-dO(PY7EXX`rq1G}gnqfgOe#J~*ux7rUM9~ljZ+aEC=csg*7>)5oTCZx(5hffen zdgYsmy5@HAMicjJBF@0o=mzFO2C8;a1p9~hd{UMIIWk!{SiE6_7=pL{s{X4IK6Gy+ zr2pC@v(~$2@aieTQo_BZFS0iHiYAIG8fD1E0#p@!S4Rv;k+YXYR{Ih(ou-NqBsYe{ zSf4Se(1V>H`ElB2zR%f&BpA<=X7q5wdm_HnzQ*OfVSbTH)y6Y);B1sd+hC)M@fYf) z@xW8sQRV)1sHv%sWwYqY%-CrvdowS_N%}qiK74|L2lSZ_j@jnZ5Tlio231CT!Fz|I8)xZM;wy;9J$Kn~O;qD?16zTV@w#&7ihS zDPA)?)l>J+^>HNwJrjLHyncz2;9O%bj={+Z?NEllYdG(y_k}aKdf|L*I?h9csQ(?B zQgTd0r3%}gR>(_=X6Pb}p;Wja4KR^s5q-)DU1d`buZohm-J_*}F~|P`oJu`^r+0}D z5c-1KD=h7tqxpHfqBBk%XLG&NVZ9@ zwP+;r&)ObUqrABAJBQ*0xR?61l=VywF~pplX*L7?lA2D+4RCmza>PS^)`Y%nuugsF z`%so9sD}xC;QgIdDTM+<8fKV!7?xt;AxS*v{2-eC`p1lmN>e#_L8glB;%65Jy__Wk z!7|P+dWsCsU`8C^C8rCsVAJ(+juVjjEhC(aeD@#N_=N&W4+EH$VxDimzYWzs{gZQ|2I@Uwi6oMtFmm362ZHb#A)@Zj4t=t4h_C%I4{AiSbZMWinPHW zfZ8B*4X3RBwT9Ky&o|vIfNj`4@0!fCTUjA9#n7_>??nt_Q`<6@v-pJxHpWtu$FD0^ zQ!Cfvy@oW|P+!4`F55OPrK?l|e?jkkmd2+wnqKO>LDgq0yw`m?qJ-sU=So~LLIZ;i zv(S2rIa^~cx-S0Bq>v7ut36gab#vf)VKA1&A<%BiMkriWJ6QC}Y)g z>AD>5bdFMLG{c=}E3*g)M3c72{4t9P{6#2F&f^b^O zQFyGAQMqpYg#oC^Xs8aQ}XVUwS`$rLlc?Kn(cv zu#)FJp$e<12pN%8ty-H>?ZQaez#Y!nXWpCoIn3eK@=pR6UK}QunXd4k%he7(0NXZI zZj0{5)XMA!y2E7*W&_L?ZVm}&Yiz2EABP%_CKqUZq2{vwf!KW_mc%)bPQc*l%H)UG z2V##-cHYO(;clgQ6wURbQND$S*AM!I7c3Sq`!57S0nFG(EO4yiv@hEHn5kt8&@F=0-Bkp|tWCqXY1l z0%Y8{fp_i`wo@R9J26>F`;n9Nfb;N^bW_1qgRqc7{~*MfH~r(I|`c6 zdyBeh;}7xXpx9#`E${h1tCt=6Lk1r&QTdjgk8HA8$l39*3<`KRKG!|O$5XJ=?w2(} zg+B5b8B_`mMTiMy?Ru5{V{6|}ZoEb}s<>^7QH9$+@ZkE1KRrROfa|EV4E$3=b7{D4 zL9olgV~jKfFP@^+Zd$1<{gXv5TfTp}In_Rw%78O>WUrBq^(E)h_5i)kwAjiDmEn=$ z>|b4xu;RzNw;n(`H?`VXOG}7<+vR0uTad(La)^8Ko%@s7zFC&8?L}I~6P)Wdo%ENF zCP7dK<~Z{B!Nyxs%pAMwtd4LkUJ&T`F)>CuN!J${QynNgX>C;0w(~JL%vJ0wK20ji zbm*v%hy6skV8S5b09dkJ#{rhs`!w378HN4w#egsNWP!g!4RpcvZ4e&8#yln~- zL9v@oe{xDTv`qYHQA2{csAU}+g2?jGkfUkBxSGJ`^dT;c+a$JuEAfz@v-P5=m|f-X zJYAVpL)jd5ydL;-o=EBDc5LxHy=?m*>y<7ogPfcCO_=maMmH84iD98ps<2-KxdUC0(U{`vIM&Z?lzp74lm`wCIus?wL5j>INog zB9d!x!@Q$Ku&%RfSBKfI)Gyh++P8zP_wA44k4oe%NL_sy`@FeeWF9B(ZQWMAxTEM$ zSnf8bCu?0Cx5`69#6pR&21pzz6?x|Vqu2Q0%Z-h3m7Lufb&kU!S)!yCS=e%pl$TnN z3(|J^?G_2qH5}V;H*d^Qwb;DjCWqb!Uj;{VoxA@oBY=$L&l%44ci_G&^ z13HE2-_G_)N=YKW@m|zwg(0!=G>J zG{~t(s_`I&6hZ%p$)yF_VDPAIT%W1~%E>cU|3pe@{C51{K^O=59hH^XQd0EFNm0}$j0s?+?IfdyJ>rTz(%MkT$xHbZmJd(pZQ(J z{#31w)LQyDiMIL<7Ke#)=!=)0s$-srmUsbl{kpTCNx~Dsg@*#?eq%68WA75{T zAE3)~Ti8l=;HYZ&urB}IpDOQV-*`by6=vKW_iu&=en zBW;g@s+y7V*139;lg@@B=aTRS9Pd!!Bl~BJ!WS>->jjkpOnpKuiF*QS4U_Aw!|~4< z$}W~kOrzvcaPl^mdzfR?C`Q>`82xKnS1XKFP;pmlheunM3w#Iilyea)kG8^u;mhMA`gU&_o^_!g>U6y}VRzojGkzba!GPF}F`>dy;YKJtfj z!MOWYm>XZ%ah1(3q7}3~p$iCiBgzI*3Rvt(t>>!(;tVyTKSjbikmtsYBC%nSGmM%J z>fdG&9Q~#cecmn8X3!LGuMeujv=5`uivK-o%JK9>I$5D61mCa+5lz{^xhMbf zYG|vfVe;%An_4ocWUKvvL}wa%Y-L$lQaiEH`4;R{o0VHWH&F%*YRy~X3GFm!e3d6LY*&IM%DSMX<>*l=7@KR zM9kTky0*lu3v={tE_5Q1VNYCvL%&Ey-SgV_kv-LOQ|}4U4_jyew9v!;_bY0cj6iyS zT0scI?T(QQ#)|z(p1ymvZ|GeSISlNoO6s-80>P&5GM*vlRWr7SS*=>Lthr;#W4?j? zg1gjNEsC=$%O!!clbm8MBl?Lia4>rJ@{#LU_3) zTw6DBsV-{O{A48`d_T`~U;kPsZ^!5|x5kd${(Ycve;XYNQ(=-s5db@s`-kpr-O@&_ z=k<=qu$52c;8n`>HbrcHI*tpJk$>`i<*P99z0^1S>-Z_>?H zWa-9`cx33iTj$&d3Tw86+0JOWRx>OarnZEUWlkB#YeeK9KXe(*#i3vN2(-LCbn!Ig zXzpa_bUQYaLMY`uCt{GqNbU?A<%QrYwnDJlKHyzkmJQQ87lY<|El!mfn)L+#JT<< z5cjDzHsb@>a|$RDK&d0ry))KE1Kn40A6(KgVYH_4xjv;a%uwEV_^Gyyar)s68hdsf z6Re!$9$A&$$FGpkIZY|1xiuHx9w?RFMU$Mp(fEDkE^5|>Ze`@3dsO@j8YOE*+5(uP zLrLGY=PFP)*joO2{m_*er{YsPTa=m;aGD!S7S07MU->l|8I5gXMzxvSJBoWOp4lruB66l08y#y`pn0j0rNveWr zmmN#O05Vp$@=taWueQ=DKV$y*30uq?t0wC>=iyq55-3e!>g<~-!+lj^oYGcd*k_^9 zP`n6}M<>ne7?6egM@*23QSOp+Wn0y<_S8TA9%!fp6l8V9M@CF@y^Av-h*WCbps+8K64FnFiiF=~K$1w(SAUn4LE(maouWb9^m% zI@SuR&Kx>d;dX9Dq7%Q(CFrv4jjMVLhqOeAQ?11RMdg>b*+=j&as*(TF}2N*AU&Dx zFxZ!QI&}KKPdCP$s}EK?FS`rZsb4lfb@e)dYyQ{{)h`nTM+;xjL52m#zs@(LjcYD`5(`;Pm)n4hbu0 z*t8W$kZV0A4o5jbl#($2rd-`e@q!aQGd_H8egcIkHM>~J7raS?boLn*B^3<3s7>@H zBZqRie#ZJFx)+$NfeOmyW<`|JUeGBld?Fg=e8I>{L5Vj4AtpAq;qd{oV}nv%oOBm3#F>0E0+-%t~bfi zN}7EyrUWg1Ati$8S?h{=kB|$c(*IC`bxbWaL=!f3*UhOE3MT z6921v7^ot>{j^_DK0#R4=aNox^8tz%8Y4r4>KC5kg7#%=Bs#PYd_4uK7t*153qtiv znyK<%t)b99`r(sVgZ_z5z2IS?fD;Cx<;B85p_T}=55Qk&;m!-ONuj5<=;FK3Bd32B zc#@Js`(W+N`~F`R>J3$s;Mem1YQ=x98b#+Y#CWMxc&M6SFfZuzDSc@RSNdP6M*;WH zv%eBa>Md&Rt0Hc211EwL$%_^fUEhyV6rXLPdmrqS3}(+4(E3Y5qkcV2y-Nar8zR>% zY`!0g1^RnIl5-C`vV9W|q34&#!?)@z)5Vgo_C!s7l0nrJ84w0ZFXvxcvn(=({>^;=i_=AUeh_dUh6kL(!iX<|g|YYF1doxyr&XHd=-& zbTjM{m(jko8c>!HiLw7hZ0V}Ib! zQC(rL-?A{sk6L2R1LuP@IT>fw87aYOXq;PqdNzCsE~M00>`el2j)x!fSb7o6mk)Vf zpA{W}Zw(jJSFG$74wCO7U3thC!Viz=}grk%79OgVbU+Ki3JQS6pSb~#2 zfciJR`G?<}b2cbx92~hRfp<-OHJwd@%#2MPQCk}37?x#sdQr=)#bihhX%C$=Yt@L- z)EcK5G<6PoQOfM!$$Uuoti_wo4=umv%J&d{_?hN=Pd2s_hUh@MuXuJ4C2!IAwcXz8 zy2~}b9yiX)ZZbdxq8eakRPN9eTI49erT0stt!4b-EYlF|3kkD5UbIk6&Pr$XU01nU z;tWq+4GR{-v9xJ(HE1AERN4lhlvsnBTRYe_Zr$4Y5tP)|W z8)634pM#^o?P*)=%Dm`2ZGwVf-%g%$V9-P5wh<{lcSKgi)LP=4-yz<{}= zlcsLyU|!KYT(%sV!a4NUX@#GBQ3kBBjZ;!=W2kIhicbw1UD{;iwUH;-FnDZK2aWp< zF4Bga;%RCD_mY+b(ls{Vlz+3QVPH=aKy6b-@Zskj3LoO_w~Wyb*#0wx%xBKEpU4GT ztqNTyV^BVk-`=(tC^t}^bgwfkX9Rvgk>r?Zz~ zhwuRBb+1!5sOpQ(4*$uY!gc61lhb#2HLE>m=OUfjJKDfo9 zClx>M!lpn0t$R{1?lT26HPTzs3V<|IB|xj|qR1!mmRrT$MLvM8Z`c_*bm1vSf)+45 z;qBh^jS{Yxxmo^BHtM|!ow29c8cq7;k@M+zn`P@TTV>2frSk!P?b3p$4)2{?S&d)E z+rp}nDW#}NC2QfvNB`fg&APHD(~RWBOLCL%8k$!A{v9dcGHQzgZ)*MgNw%l~`mnFf zf?M20g=$N}tWVzmspf!9epvOX&1X@k{F^&1~H4jRMh1J`uy!Nyz$;a#i{d=yV*7sa} zZ@$O@$`V_8Ged{)_y^M2V_AJ%-wyOI7@<_J4iRPNr7E$Pg^Enp(U23g6u*HJiOewQ z7RcvjG^B`}Fv~>8W6xN8xUq;{G?Xc?ZBybPuk6*MSw-Y(){(sa+`W$SzBXewV0m$q zzvhXCjXA~Dd>n@}%hP{h_y?tr+kPaAWlfL#{b*=(0K?Igo)WmEMXb?R{oRMJjRxhC zoYS{m-4Zz%aA>rH>OQT}xd@hur^f^8@ph(E?b%9kbGLVMs~x00GO!db*xoe=1uMJN z8yzM(`jm&suy-YLnbM-E5-V<-iU(ZY-#8@2?_bk#E&*9k>tROJDu*A|V?G6W!vN2T zE2m@9s_}y#=pVgqV1ZjYLi70d)xTZE;hUit%^-4S|lOXS<|NqucA~(SGM|K zC0WL*(E%?|%tbW5e}~1CswM zx*fK&@ZUte8X=W4^dlXxkBJJAPWxfD5btV85fdHG+9?jKYLf*pKAU`?EP#S+Y!(6S zxLX@b4u7JtT*PU+6I4>w-HL^WgNHZ13XY47=72;!MYayC#}*B%6n&PLO^8ac8f*a= zhBinM88gO0UF`1PQ8HRs@7cc4$ldG2W`U|{)y7_*u53{|uybXjp?vFEpx{SL*|toN z?8xKe*2P+W9tEL%A1n6kBq45jKw0Gt5`ZiE6S=v(KMBZMc=tO#LdR+fXHh7#ZR5f& z5&tp`d5I2*atgxb&^ET==Ho2^(Ln#K`O&?s(I@gbS*7J=GV9B8vqhxs{q8&~o;e9g zhgy{`i|yWayPiBdxi5})XrSqHvj>Uq-4Y`Hs-MIcn5;fREVOa%`+fLmN6 zBq^4lv`IHnB`!`hky?5k+GI^1elqS0XgZ!ht6XVv4MM$3Gj|{4)=1s|rg3$}W%oOn z=~FUIO*E&)j)*$OvHt5dJQnk*>*)oYIc>a$X2@(vuTOm>gS+m|v2;>txoE}${DnxH z&5ZUwXX6n}(W(!n>=j=$*m6mdt}Yq!^(iH78#SWzLMS!FylGuRl#`| z2evvoLMX97{XjX}s5Tn)G563BF#@<-EZJdGEh{e779pc~2J5P!wu#AX=Uuj8!mwt> zVTGPj*e8DT#=5}*k4N67q>rbY>!sRqYPE&Sbnhb6N%wMP%4~lF)%?yYgE0{Y)_`t) zlx*Hr^CPb5Z=;Vbnx4R>hH!JHh@(&D~a$)X)ReTL|L){_s za;w^<#&O?%9&4_3ll^q0XK6QZ5{^*Wlp24#DE!)~S5D%6YA)^@96 zkWfCcdc9IG=D4Z$h3+7nVw-2*=YS?f#eUD?QarX5tRShp7?}zZP@G*@M9hQ`tFRZD zz=U#I!)irkTx~9W=sU+f!@4CUjStOdqteYK`T`kMJ%h+yJ2SI05W$JmVOe+|AG_GF zzg2(-A&wse2GL>4kEf@x%Nbl9014l*t7LN#92K;4`*MKjj6y_9I`=1+`uP9 zmI&^-;G%qJV15k6MB_Y*4m0Z%P{$fvrpf3)tCg8sLl&t6t2$><+Q5$ft};19ULALS9ZebfZa$B(ZV~(ERca777{N*I5gHy%qoW z|GjmpEBf}&Ov?FN1}R6|pk!6izv{*QSLTI<0L_g=Z8N98zesm>pUbHlLrMl-=0;@C zxsfbGJYK%50*f1TgaiWCSj^(JHeno@JseQzF+I zdYXn>eVz5;eB;5yYVyjQ1~QrhV1a-#{cE<7S+9r40@hTRe1kR?2z1c@eB50VoiwS!{cpWsDBM~g9{hV~E#0$rwdxs*> zUprmz2vI8s=hSVs6^1s#sODwZXJ>bPpuQlrKh;-G$A$bX-HU znycz5RsT(UM2L-zZ8?$i%_Lvt>kDyrLtr-_W44uwOG_P!Rm!DvfXY7jK}AJH-6gPW zIC6#MIm&)ZgiM7c_`T1$-Op8@x4;u~a ziORoe&a}=u)vqfFcBtnYt%XY=2MWax>=J}i1n9el(Bo{ETbOR?au0GiiU3PJn1dZAbs-~@!^S(6 zMtvh>N9rTisoz8};uMp~#1tp<`yW8Fi(y~}M=7}X<@+6M2a05oNl-5_Wq!6s0DUr8 zWB-~J0*Kl&T7;KrHO=VJlXeB5%9zNW@G;8x!l9T#Uv+5a$*rxN(=s8?IbJgJgXT*& z(K17-%@seA>F5}uuIk{hx;TR83TWucuE44+n&E}o3kJ10#IIA)EgHdNPNu?vv=JBu?`B9jg zA?nr9Dx#<$2sHTf2nFm}UItnq2<{Rs>I@B%T>dibzMe6@6sEj|`^sBlQWc^S(^%M5 zv}jWOv(YM<<+St60=(?ZFzR4Tw(NjM1kJL?TWV~ZB)81#blppv`p)=U42l=D)9(_= zp9YI-n__`OB8DAMwon%~B2Z_ZY!+C5ae5`n!_>zy^SKeSZDl*iSvM^CB}JhA4Zn#) zdpn?i@U&n^OJj2TK7@0oVOoR0ZDCn;l2wv4Zv-{QHl5%7^UW>*0af_8!J~`=d~uzZHlmBw)9L2Sq!v z2;r@!0wcmjgG-y4u~+IdR3wI_%j(C#@B&99&Z&l3Wh;=F`W(UG4G^NY;=K7D#2DjC zna6ebr8b=@J1=u?m~G48n&rXG1&h^9?0pi~m{PKaGOLiy91w99t9bB0c~*3r=OGSX z*bPzveanfwkH)1*WQ1ry-N3!HvthwdQIf9{)I9N+IRj9AD^#f7Tsaf=K~~S< z__*lvJ^t85;;bfL7ZG~`#3KFlP4h(f0!o#mhA-sy&0urqFy9wXt*~USoQY@3WLd$d z507|uOro`yrrO*iz(mvi+mY?*s;2P$TMA1*X7aOkpJA{Owe;1kT*{NNrK`+5{U5OY zU6Wz*zGeg8$qJ807J)HaXw2nO6HXHoAuy*#D~Rh|Eaii7kOQW@3WfJ?B!jg3D_Y}xHF1d|vIU;HFt!C7gv3nH)>J;5`(UP;$F8d-MD z;j!5vvIyRubw&637kz-n2H8wBG}-Hv3W_@Fd-tf0dA&U|r5f&n9D_Xo!*;LN7C*@G zhVRd#9a*FMa4oJ7dkTT7u%8$#ZcjtwF?$T9eZqa!F0y;IdhkC(ctl8_@1ReJw z4_;5t+`-q%(w4Jr3Zw1x+GsXGGSZHO&${Ll#+&&RpYfq$sZ1`58RqM2BV`E5VKxKt z+RQ9R{oG((<4WQWtj#$?jisK5Qfp2(U87@A>r_m-RUIuoY*zSh5=c+p#R{)M3#8{y zbo55FVjFU)419dohuHt7fUP`8V0UHF>-CK1aG9 zzjh7x$skYNG=&t5kzvrx3YLyLPtIWQF`YeLQ@DdZVDGaj-+oBXd&_-GqV+AP(xlV|b*L3>*1khe ze<}0op6r6s)8$93QNJ_O@5jpJjK`IQ{5zrdKpv0FFtnMkJ{@d=qj=pHG#I_#YV% zG0D3G*n}x!OIU=rgzN@yW;CekAIxDtbXZW(xE7x6IX$BH_pqf%7sDyXId{d?g#Hz1 zvM+`N4@<04`CCV{+Fh@4uvKOTEu!#FG{~*ED3}4p3BXbQk%!{l9Hepp=Fz^KmSjZhe-+3PRBGkloUpOIlXs1KNq z#wQGdw}%#x{XBp3bDwj{%Koav{`$I*eGJTR_v?%W&h}%;Nhj)pmX-Mlxy|HHrKaqB zY7n`EBfqla2R@e?PWl^udIAEe5QxY{fK&SEL$(eiHVf*7H((5R-ax{?o64@n`Pn|C z@%^NZ@!_C8+7!-42}?7o#!G!`M@_Jlvx|DnNgIU=LNbW`^s1?86Y$m!Ii1V+duN7j z+`37!)J@MHh2{yN$F*(g%JRzYT*U14_X^FxzlQ*38u6|}VKJXh6+J|xYL+P^e=0ER zgq(+aJP(XjQrnZ8LQ!?B!RSf<>xP4}gyGH>cmxlKf;o_$c8#sftA2yI=_f>2%*VU) zJ7Jmp8;zwr@zD}kurwYT>fGTEG~m>S1?gZH-0TzgB9+BRTgrL_*6gvU(7@D)!~twz zz2~VX(t;s*FH-zB3e&(E$%M^zo}ow$E5<}*Rc7)5S}p3o$kcENIo41f`7dyr^pul^}a;n{%F)0GkOI=((hbtxDc#*5NOM4t&iT0adaus>*8HZ{n)zc~uCw$zXMcO| zcjx;&?|ybZ8 zuN64@^x(#mLx1E6l${U>BC9dgq9x2qgqN#j?#(7m44A*;ZX~+4TN_gYCvK+-gEy`J zCS2N2NOxqjYCg682M>#e-`dF(Zsrm9k+(db^~Q=Daf>88XfGeFf4JsI zLMyg*8`y;WWwGtFxojM)aJq1wQ@XCyR<0kyo zQ#%5ax}Liqw|pknem0yJd50Lrp!cri2*(Ita$-x$`DHbopO267S_Yc7CXS zVgfqFFh+?C_bgv5hUE*nAYa8&dW%fgg^Mj0TGJ>X~ zMUxzK5GctgFVslRrot#$-dKZ_$tAquC03J&)TGAHOL!M*-x#$8f{i#66c^Go5Q=Bo zsE)cW3)I+9@Q1M__%`Q7A=0%_4fKospIheuAZgx~A;_|sdj0jKG8dj`eQ$h`krN$9 zX!F&kQz_4UwaJ%uC9p8PT1tc^**n{dh+*m7XBPOS63A+MGoi_KYL<&+Dg9)q$MSxb zd4cbdG)WP)NljN_gVJvTRi4A`3ZA2|B1`DZD&rT))oO=?0M1KzSsn0kwX?W{0qkRZ zag!n~Lxa3=4KlnQ?!yU@;{&uB>~o2^oxgD62qo{(Rbdm59$5M4dWRAjy+**hOhxWU z;HI~_l2_Efe9dpZKvov|(MTCF$FuH=vT6jJh`V#JM14(cPV@|Fy*ua!#r(55 zXG^n`;Io!{a5HMri3&|bgD!b3=XYR2R|KAo_iC9@p)$Bq8Q`8cTrB^H^6KAS~)wLq}S2jP96i-P&OA`MW8RJE0ZE=^#o3@L0!d@0+ltMzShoqe@(nE zTNM!3d7MOmF>+hDlREm+xTOa^#6ADj+c$I+xFo|;83iZVapAgBU(~94L^;b0&h>{9 zUt6s+L_^F3bvfZgjf`&M^tiY#NUhWcIcI0*8_#1FC~uCzgY;V&-Qb34Ek7nEciRRH z41xd#1wOk*hV);ydh#35dE*;d{`nz;Irh9DR-$>9!vs%;xdJ5E)~dM738spTSOQkMVFF!aD6jK+ zUAb}?#wzB};5>>i^<4q(6qW&5bjPobD~*)8gK{3;YHVgyu{v!M9)6(*GeKVok&(vv zr5R>>W>cB%Yx)EKy$SQR_Zrv?W3m7KE>I71wHeJoAF@y*F8fsqWJ8FfRA3ZSLQ;w* zPM5S!_L`WNW~kJWt+-oXPD=|9kMs<2tM-x0{x=A1M-3Vh_{rn^*3E-MGvQMv0v*2| zGYTOKC8nYvhO;9&(#pmOCs=6k@p^O3D9}%%XJmFx)08pWo@^*$`0qb=J zgte_WZ_Cz%KTs}#3QXWkF_r3P@T)m3ZUU4K&rMVIUi%3OoY&iJ+}?Ef!Mi9#xBemj z=hI1j0f;xtLMu(m!-L6s{J zB?D#TheLK`0VeyoJvD#ofF1@OcDobIITkfx^3X z)i?`iCY`eDtHAL7*&={8{p)1+9VktkK)HAg0VhsA%DT5wuM5sAGZ2kL-4yaiqG)F+{V70U8sJ3Y5+ZX8G1u$MFmrOB4}2>xprn1_24dJ>#LoZvp6}&mSbx zMcb#@IjHU%iF+@O)Yd&Oc7hN2!YnGSl(Hegt)plCHf~OS9=aXj^Zl9$=|#;A78Xmp zs;!4Wz>{>GNbe)R?6}Q}TULD?_68GtI0!RvW5208Xcspe>~#K&up zZhyJJ2lp}9Y#~(^UL->faE|&82Z~nv!gX{;7_ze>GQ9m?|7eR69e|AGAb8{nKH|II=1$C+K!RXS0&$ zLDyviG0ja-PvNR1Wxxfjy9J6Yo9Su@6P5siY1UMrn3%Z+{*;<=_fGe54N+B4n8-t` zsi|r8jFl#N%MS^WFnt<&8GbHjGZ#+q`h{6j*3}u`17fpHdemWoncwmN!g>gphs7ED8;+M@j<+@Nz z+TpzC?{zo?7wA+=9ebZSgfdZmXtSJWA>D^U4~1O_IsVu*wKJYA%%a1z&~6usKaj;o zKn#bm~5Nfxs;M+FYRFVbMT}pVPvT|3cV7+1>D)vCCy_EyWLl=Rjmn z0}$~7DSKgNP&dWiaJ6r~ey>Es&6dbbk7YYZ`j)WVg;qL(mAeyE#18LhhYqa9p| z)l+6Hsw!JC_j?kLm;J3~n*APJ=^k5;#p!8#a&4C-T@$8a9Yp+IZI5GSuEo+?1Upd4 z9WE%ix>c>RVuWE;^QdiKb$lI@du)%R{lvP^!g0tOg(KiywdTsGhQ|K>>mFm)^~#dg z{%<`ZYSpZ^!THGPvo>}9q`*00vE>*LzHP zVvn#4m+D2rI^RQ7j#9&0H7m)KL>)ZJZ4^%(oUCbhaq%Q?c_DfFZu zOcL7X1Y$>%4!?cyirohu@RRKGLhnHugLqkCL&HtzsJ~Nxg@5jvK?=!l1^}}91a0^J zvgT?)47B-vcdhvBr*i1O@BxwNzIa1!LrL3vkmN3HvrxeaqgBW{3y zjtK(&qS9(+<>wIf1J=^EMX;2YOG*PKY<3oa*xx+{9*ha7eHXiH7k|2Jf=04&T}Qj{ z`6e%6wg~{ND-4WESA2SqnO|x>fy4L_1lwpy&3@9&TGyX>eO3-Q z8Qt`AJuZibSNeu>RzIPGa`rgy&F?_#t>I_HtL2^>U8lrbrS*ow7Z=1l$V~LBTMB2y zZRMU%RVT-6G>yPp;hqM)RZ&)LQFp1?SoYGuT2&fU8y~1YNE&R#(F1G!4v?mGNl_0c z;hv#e=~v;=k0tSYQ4f9WR=4czP|x++1Cx{Xl~m%IGoWuQaz*e0MkhO#bzziVL>0#9 zv%B4MV?p0;v74lzPjw-LFtK;0P0W0zPdn+-xnlrL&#wHh2#6re?Tw#+5agC>NH8%{ zJ=ZZ9W2xA7S05xg;Q*tp-Y|^AxgB>O4qC4&8JAKdB7I*@BaebazI{JjsCfH{kK*Dn zB&+E*Y5H(7u$p>m$Wqg6_cD{m`C6Bh`R;o(gE%S@sM^bfznPTV)=_BJXzDracZ)6O znum{2dEOjN$VWO`xM#A@n+?tnY-G!vO%loNd}&IkA^kc1Y*D@VbuFA1M2l@ZE z^lYyPS(|-tQk&xIiM2ITm}w7F>&AyUzOL2fOP>w!Io%JGge>_}$($ewR{pd<5M(8g zS#~OjtUVeVt;Nf;$2&ag3~o>hwpY)ULLA(KR`LBM)JRJ z*so=8lw4sSM&-<2M{SDdZ#F6PdPw^;-phM-uEw3{fWG`=or@4RP5cbZaN#%sYR#O zq>#$w`HYbOy5Crhd2G#lP+8NrN%{0msZqU^IB@tin5_zd8Zq>o1$v&O6X6;lc~_Wq z<9+2_K-+ehLbh+Y97ZwGzJA8Ef!V~!#rA_1T;=cP>-CR1Oi!+`{S50z%31Z2!OYs- ztVNaaH8qCkd)Z~DL=P7IXSzZM#uVF+WVqK6_N%MF^{`{iI}L+UMfrI%!Riq3B$2_ph~dhN z&@QA72%_i>4QqRJzn7Jx(<;D13U*xBzGV^Dy`(Yj)0HEOb?f^sxZ>YWTJFW!HenA2 z$bqE(;!@0#EPwWQko=zRcPKoD6c-ju%$u6QO!O%-HQx!m2QJWJ|HOR{E6b{GmSeK4bDpp>r{5 zi9xRA_B=WS%cCNhXaVoIs#v=>%Api8UIcVRht(KsvZauMC7;O_9FJrd z-JSIYdZ{{8sF@$WqjIb?$KklKd9JPJROXP*S(i{iUu_SU2z`@J<@{x-dVU=XVBB3* zi;%wH#1x)yEG8+%$2Ce?O*K;p9)}}YOV{JUCKg)^e)k<<4Hatw6%;Xw!O4Yb)4^`xr99$43@g zfZe_nhY3c3L5UhcL0TXR4H}6(G}QDJ> zLz@7ZT&t3eE1m=j#YeN>m6%tjwPED$duy(h=KD&9bb(#noF9JS-6ognN^;wAMxkhv zqzg1*3~ya-y_RBE#TuuodDmXYb{^;&U^pCrxPWM=R=c*K5E`OyfClcXu;bE+h zh}t=A!k?nn-V!n&c4s+5Mx2>S0k2eTK_ykBKR%k#`<^;NL!bgl7w2|oC3l7Ttpk&T zGMg%sG5RM&ME!IBV=J!}ii2i?w@DI`r*Is?i!7aYoh{#T&tAHxMRK}J9W7$FW2D+J z8Z|^8?r|a<9(`FwfTJB1KW5gDqFAx{zQ-s3w&78Y z4R%tK2#>m7Z;Rq^Fn#?rsB1`$c~MYPBo9l|cOr>*?O6ve^*l>O>NNTH4pbyR^0+ZZ z6hxIA3Dt=t_6(_YMj_%XqnLC7M`OC^2C(Sl9@rQrORy>_uABn@kOx`nN=%NDaD33e z*}Rw*)6lg;4;aodmc~zDqY?uNqvE_TL)Yy6CPvX$ii_)->L8!pBalJg+RS`9nzetV zbAp-QSabJL(gj9c8!{^L38Ft}*i^AopNge$<7Y#TD(9g!<14?SFsZnT=cj%Sd5;)7 z5dJaOTSvQQS?fHFP+axH3#RR5<6@y)hn4UV+=uYEG>k)d&1_!`Re3AW#118$jz62b zbi@-zC+gV-*Pf=T)x?$$7WsEQ#1@S+He<$T#0;Z0jdvh-mpFwpH~?^3e#dJrWk^&$ z{6%mnE-=w&%^0VQPqN@dOYZP0Z5|V}vmv!X2CBqQ?gdS59= z#8a|aDW-@ysXjV?H9;{{9mB;uh#dxLpAMc+HPv-DG1|Q;#qOIa zCkuZucEQc+(24fq`!4V zg+kv8Io?%NhGS!mCB)#(6lla(maq6(<|jqC$_ScNJvZfbq~b@Ue(Rwty)Wx8yCbM>q#`+XBWgJU#-|N;8{H4sEVen1 z-XEaSuA^bZdw;#7DG!Qwi`5Dw4!hHEDY9!y4#5n-rxO%~#eV?@J7ZbQnVmIIaZ6uC zFaNE1wN}?Lyov=|hzG^(>FRlR)=NsSh?F@#4iAS-hvMZ>Ol+_&Un$Y!p{QOHLyM0u z`7Mq~zLxjp9qoj9K6U8>CieG+nPb3A(QD(Fxk}wim19%=9wf@Cm5(7DRrngS=xdQk zJyOLKZ50*ua`*cTQ>sO?WYQI?^bZrGSj?;)D2T;0QJh7(fhSjKxKWA9y4CSuqEAqI zg$o%&F&xb%ur#g6pm)?%%`A%TX}AFL&&$jLFnMU*AD?+%eru&)@Shlcj>+7av9{E& zS$diFvm>@L(G5thL?}=r<=JK0}+_hhd zV692ZR6N0EghiOf$f67J;fjIaygYe*{9M53!T~fZ7CmQh$go?jyJBQrl8@i|iGxNz z!b{vud>s>C2YH?iUwx0!r7+K`mh#hGDzxVtj8(X~aw2dGE9ip^=j)cNeD9?T>4fM7 z9cNb~FD{M}T-lh*kt(4V8mSV;CdLV z`M^#vw4ab;vD;k9PB6)J+1R_)2o4_v&q|%s)k4#Ej}3QCc5SoNI=717ou!Kaw-Mt= zFMNZjA-ZqRddsW;y;}8!;WGvC+tr1ibPhGwmtn}aH9C41@Ng!MoB5Ulsw)Qwrz&m7 zf`I>MI1dD*V8Y5ll^D^1Ya<;)s7&g;+A%A7{rlI70z|QnpbNEE9G6dG;xEG= zZ(Cuy8IVFi;_F4AG$B-ry)V#h=K*fCSSir!SI2P*jljU~FjtlDxC@&1W&YV-BsrCG zf{F4p-cxkESGRrVn};z4^Ye2+bl=pj_3l7fki-mouuTE}jsBalt%A%ht6>*g3iMg% zE}F(61}fbx-xj*}BOH7&tS*O|HV9w$u}a=I&c03-J5t0JFgxl?te=U0&N~=8>1b2| zs|ru3R|PxHOVxS2L$|922^>DkOXQYj(ZlmIQcUV-*9u+}`nUl@5rFIarsv&T33xg> z|M@2%$ac~`ieTELrPrtOYph+f2Z6;g21}0Kiuy>>uiQy;Hl27gZnLjujW^g&Ff*R3 z)Hkl4o7eZM)Nw7wS}z3W*4+^sMiU!El)u_LZ;ZPFfc}9CeMVtU6#s`QpPIy z;fRO)S)!*?NHbx#%49Mw896irZ|3t2LJ3{TS3ZITx0svsQM+yR@@+!nF5Q|25;pzj zcbEov=AAOaZPZCrt*qv68Cz-eSU8y1)VucyOl(t!hYTx8#hX93UK7r8uwkB~^osxj ziNIO7{uYIIZU6)eAfS>i?_H>~32>>8frfL;FF^vqW}n-`@8PHpz%1L5D5gp2)Rz+B z3dJY4UvakWCWwdG44wOH;9Y~Cuh_6sN2ifTMhpm!RyS|b&lBOMPAlJmOg>ILXy1XZ zzcg|i@tqS_h_*Ho`wRdVSpd*;A3Suu?ecLCoQ78M%8^V1%mm0meufE9m+FHJ%+)?`cvDy~4Pd4uj|z{NBw(uSEbl{~ zyNgwR$PC73@RD6`ZmKroAGk3YE>MD;7ug&CLal%Q!|d@KJ>ILAf6xWMdB?|CdRi8) zKY5fFk$AuY1}KNU_yc9e@KFNr62$t8b5Z_Z!|ELX&{v!=@?|nuVD)9WyMa{3$UsHT2axGM$?+tQ)(->oNyEES1zpDkI}5G;lA} zk5x1hu4+G}YYE^*9aFL4@gqQ(a;;0R1Uy>{`nu)Wh^_tg;J=YPuwR`0J~`Kd9xQe1oxCj@gL+NdY|esfR(JU5}nD^QEN3s(h=ZrN#MMCv20$_Q;xvzo*^JxmAPfKB76O@f`%`)Wx#K6RJVoJ8pb@$mm`z5WX;kR@muRW~TIl zw*&}vS1HvrV`u+>Y~P4_gh_x7?b383#ZL*N0EHz%R~aElll(MBsz z0azu24W>F?kUtrY&1e8;lG=ystgtXQ_p3{3adB};c6OI6Vx!kX>u}=hF5}_kIQOD- z3CH~z1}{qhFZRR{u%LJ(6whTNe_Ng@_Gv49p|;7#0EU zQmmHl%w3y84#6j{iT8YY(&gZ3S=n%5Ju4?S@#Y%Nmr1RhnNdl3W0&=?dw6(G@&n+7)I>$Uu8FFzX2{fW^(8RroRb*9 z;;P3m+pO>`mg{xt_G*wEZuCYhM!%H&K&8G}Kv5zO6<1}w%;hz#yM@Vwvql|}E19rR zq+AR)DtA{s^KEN5g|AP(^;#u!lJU8nwfcmCmji|`xN|3_vNv% z3>`kmd{ysuiRc1wp5%NdJL397=P^JOw#^7XN5Y%ZhLufbWOq4SvP~{aSjZT~ZKh_L z7V8MW%LmSrygZ_K?HBhA7P_@Eeg&633DnxfLS8u}Lpj za`Hm00gsz=NUIi?7;@YG{yz9eMh0j%O6>VDR5Uce19G5-JBP9@iyP4ujPDHfgb}ys zAb2ZrE++ufp?}fks=8(Acz7VG=N!Bxr}fegs2Jxu1zkZQT}q#-IxffuhlJr|1?!Y8 zRW+ll;%sQng`>s({fpbp{q08io`#1v&`c8BFESFwG`=m)^crq?&*2A`_^= zT4Ax<-bPcBKDP62_KwdZwTjxrczx||?Q1c#@B?o1_1m()=AH?dsfy_cu37^`MmAKl zpIgJi_UZh8?nvaGMOd$Idw zZ6I=c@x9PuZCbHxGV>k3W<1Qk;qc_^jJCSn=G3L>K^#^x3boTeM#2f7d)&(0UO&vmLOR2RTvTB*)X zXZ#nJ3bRR!RY$1}1`l?Z0SupCGeZt_mal!$t#Lym1<7~ zJ7dJI4{TN{yYZw*O*dR*>*i#M7a{4-b+*cG=BJ%K_AVI~Te23?c&GJ$F1w*J5-ij> zHr{=s_zA!7I9DSEQDQYxiYP} z7gO^CWKQ~`x~+@vX69w>lv8^gn|X$}P}?-2D#q~)`_mM{54|NJV{ZWRYCigvJjBTu+wi?x;ICWmjs;p0${fF1_wGuFn8byhNh*w2&+* zz7Y6Pb);E*ca!K(S z>b;*p(Gx+@BDgY40kUyuB)Ii=?h7R{KjY|BKR6R1j=d9R6rc2ElNMJ@Ii=L$M}os4 zGfbK4n7LACjcR@WmN#OIaF*+nrXqq!C1L7#GIB|f9F1TTEq(7<-pfBwCH@qI?xdfn9yM=)b+08u=vEi7@DSB(Ri|LgHE@?0+}-by5HV% zO1z$xMn{734=;?l|FVB-0Yl-`;&*}|7@o&F-4K3tcK*$US5aG{DM6Oh_1k@MhJFPx zX2Vo8&_@DSnMb7)i0YLlYffD}H%b?$I$&`Dt6$N`lV^;nc`Wty;Cn6^CZFRhlr7Ui#9 zk28v>-=;{)WzxJ$4zAYifNtX>Aqt(-3BkDx4(Q#Dc~Od-Ksu zQhwV^>(h+;N7(O~TI!>(&QrR%M7>@Kalr_k2xA_O`}aSK8`S z#%#~qLS4aq!i0-Mp~z7f9SMsicaSmNWVyPqD`Byuvt(n8eNsy|Qc^)pg16=A>Px%A z+(B3<@Oj}8I*FbfN)~1~h7$FqxK>~$huOzhMZ>L6fCdi+8XO6Z325+nXgfGOJ)+p| ziR}{;g((Do5O+1Bel?90;(+m~fYHZYLHWgQ<09dD&}0SCUtXD$8?;HlC18u*HcXV0;Pd$ zkTXWhRzZWk-;+uoDGsC^Ac@2rkV$Ze#mA%vHFK2kV>o{ofh@Ag+ZR#V0|~jdX5__U zIG9>G8*Ue{qcNEjE7G?A>VgpaT_Q;A^dlcQs~q|1eWrzKC!Y+uD`$bnFPyhfrC zbf%o7*KM%&303X%*)-!cx4E7pftI{Lq_hHeTmr~VAtq1V%#mt<{ESCCLI($d^zU2FotSjbV+EZp!!Q*=P55{AqARy$!L6& zK|>B=sl9qtD6>mc}Ql(%3)~*lO^nUd!}OG z$?AJ}&z&)Heu<1HAgC~B#fcjEkbEai?iXfCf|I_dyr}9=vr5c`O|+kVt8tE;sQ8w4 zYLO$bs+P&1t{j13Sb(OEU1>4Pn4YkZE7R6WAp}B#R&t(-r6W;wV^MC;io&;2=3bJK zyNi)Tylx(*suunBs9un zsqu);qav{v9FwWLEA~aMqlrQPRN6$6SnaI$;LmYGif=lU&R4F>Lp!?jIxf@1+@!#! z{_EnykFMhL8=K^#y69;}S^TBWpCn}m_iU%ZJ}w$~QfEe9{WZrCUV1+0j;%*{4i;2} zs6Tt0N3#Yts^B%eGuAs=y{4W+!5~pH&*;8TQYLYAIRUGix9QAgUxKMb5deA1lD+KkRuCD^sVSXi3mTLfwa%<*lPXx%e<7E{ zY)~~Wb62HE*nAPko0=)CzE7GTsre2RUjlkZhhfy zmxS@n*iKghy3Pf1QrtzCwZ-)FizE>G{RCv^bQHdH-i9A66KEObaZ)zQh7>8eP-~l9 z;u12zzh7&Sy0b-ix0|y6K{u-ghxCf+!ltt%WbTmb_DEC5fZx*%2({l&spD^Oi2~oR zvETG@65VE5z`nMz3mFnaqGh|=9R>P_*M(3vct|VXo%V@)N=lm3c*!Igc_gjeR@#ms z_V+yPE{jKB&j$g@$@NTxcf|2~A0~fv1rQ+-I#28U#&*pc9Ydil|HX#?XJ+7*>kGSg zP|ZQgWRn+4AC|#^T^`Fy1)4Ej%j)%78+jt4B?)6QMG{2v1d%Xv_e zgp>cB^6%szz{w32`TX0XC%_MxEa z`T_w93k$))Y-S)MGDN_Y5w8!ah5~Q{|Mo_w{T@-?0vKq7W?H%PJxOiyNCKbZOBZRm zs6>7yBHzEP^8|YLFaJRCY2VcP)v(12?vYmN|fDi2Z0xezJ;Js~p*y!RSf=aaORg_e}l~_UnKyN5* zxWj%&Z}@4czhE|DLYKkNS)aU&&^9Xa=h7<{8p7hasd&NOz`rUC-FEuAmO&p<$ZSE zcI139KO4SWU00TBb_8CwB$eA~A4o>J0e1B%ThJ(2(DJ}`K&0>o;p2q$IIuAMyt%HO zrepN`%*a9>JPYUHagxJN^%VoHKC2qpXmc#{d6oCijHayTQ~7tMxmC>Lyt|z?2)Pxz z(Rxz(pr2Awn5xg;JZ4^_NTnw1kWU(Rxpw~c{`2DwXSr1Srsj;DoY<2hG7jkQDpH?6 z{xg;lzBAf(I^D{$C0W^~KGge$JUDc8lzmAu)44y3i{C#9sInF@n7pO+0Gt>rUk#$; zxb&536R#D0QrEj@bS{1v2^vjS#zqap$tr(YPKR)B zXZ*f`aX3lEI*<_^hCqJ%Cn0nf&?iu+y0-r@wzoI792tgcQE}P$e&h5H{;wx#}j`lI80t+YPQU__9_dLUFSSPWId>p*Tu&%o= znq_fyb6zO>&HgHrK(aTm@1le}!3A*xMsw(^&Ude4uzY5=`vr-6&DpteY64Q{1Ktv; zN^PAt8(i9M$U)*HkqD{fuX{*N(N{LManKkvA3qO~zBuUb;yiF!PFRJgb1@{)zpWDi zhM>fE(4^EqW~6Rzcd)jrRruV*FIuy%wQn*%-s608S;zR^f3ZhgNBzS3V$&&*3H|PQ zaDl}n|0G^b)e@SV&aHUNU4I??9)DL0aKSYklxQQ~k)MECo8&jtw*MxOb?m-VUR)i1 z&q1$#&1Wz7kdKoO&*wfDZd!ZHxo)XA)gN_@;ja%nxxISLtGs&9_Le8eiq0`5`U+pc zRP=8I_;Cq%0fW>qr)JmfyL${CPfJ$ZoH5@C{3!4W>Ry5c(eBxQ6ATm#=+WJa3iSJB z%E#UvDGtnHF&Mr7l?y{aR|J@zFx}pK`qlj($6gX(oB!{=@VjgVy_Z^y10M9HiBIe% z&8Avfui1a~e2uJW(`EzMnr=(8pHaidVOVQEZNQBXX5d^q`wD^c zxI!G4P8$CjsX!Cz18F~D#(epGg%Aa@P-xz-Cj2cA0wAq^HznO~NhN?Rvi>*4^En~- z`QpEy`M@AP<8~ebKq2g@tO-jA6O()Z8fGjDqblg5V@mpGus(rCFZG5F-W*KeuSd<; z($2`tBtOEE@*3cN4g1fQ@vjbJ36#umRYyJWzuqCR0+j4TMhfabiz8419>$CLi-eiq zHjR-kK-y+(#s5-1f$qm6D|mN)m+SOf+V5IG+M{lqUuz8Tl|UtsMKsvUjO5o+0DS3& zPgc)K(9^snu$B9lyT5M$&TZ z7@#PiCSZsCuh2N^Yu9J{&WB5Hxxv?t+98KWM|C43BYo}Pauc*Gt4v1K9UL6A_vMC$ z5NU%8W#|8^h8u1ot4Vmt`-)DLGVRn^`@@wM3*hQ$&M=9b{2Ghdg@HJ_lDxcEcXIkG z2~>G6*~igWE#>aT{cJmykmd7F!&Rddk)}SkHzZ{=cqbk2$6ecV|j8 z7E7Zjl?}5um7f(Mp@v> zrcmrV!v9PYge8}MHC3oMv#?+eME#%gFE1~*K5eyH#jzvWd(q9qowJD;=|y6mCOINfC%V5Lom$|knQbFo+4MxckK-)xi@P&X>x`n zr@pc4JZe526Glg+5$Xu^MM&ib`q%1PKDU#cBl=>8X4CO3@@<_)$9_B}?E~)7Jx99w zH_iu%=twv)J5`!7dwFP$GwRefVPreIZN8C_Q;eG};2Y;v#?);8Re&bsbCr|JKJBB3 zxO^fGH3^U(aAMqSFIY7d=8??VxT@?nKu7q{WYf|YMhn$u!i=-}4q?tbw?Df0berrp z0?-qyo8q8D^z*)Hs1K>jbNoB#fT2EB(PFpIp1eLmso?2EUgoo^>k5vsPtmVpF2V<} zxWkqf^k>6Q{+oMGUS-JCfaq{Ecf@3ed%5g0^C3jya$>5fp3+tlvU?eUGVX8kM(StS zOsfS__og=FWpBF{0?*ISBSmN0lmisBw6tbsb8026CX{l=Up4fJWuxt8(<2dl&!AD= zrID(WxYJY|bVLtHMW77^!&8&~8oC6z-q1d8qSKs^~z?5W~OVoI5Kk=)FJ) zdNvWU?+};Y{?dt8;@Zuf_oqkw1qGBo1_n&`>DWHJ&x#zm(lFYIiDGx@~&s-`cJ zwBW?GH!L#V{2JEhNfn3gudw6#1u{h3xp5sD*C(?$V@_ zrlM2TWm68llNNa95&2DmTEFHsA82Ii#Ifpp0AAatuY}A67MV|x-37JHpnNm~eQW-q zp;3@WI=S;HZ7l!jHpfD#_s252d)co1LZdRtPfd`LV@Y(WJXqP7;F#czzAzrISdHXa zxH<50qQHEvuPhy6P=LcX&Tj5ZkNN;)bD_nU%(`s zmqm$p-g~ng0maZMah+Prq}5j{S2)@2|IBBjPXZ(z--j8mLc>zPU(4%rDFQ!9*f#hC|TdE!CO&?okQN3K;S}X)n zNU7c|9vE|^n~+hlFNN>$zw!QRt;cP`cS-=az{aQgcQf<2XJ`c6 zxJHDd|E2{1%%Ot9GvDt1+W+5TWPmwWYo#%hVDT?d6++eiPW1SI=J(B)2m%0jtaD5t z{IWT)aSNsb01qAyiQo5zm;j~{R3F9${cB19ps;noufiEki~g-3?>+)$dtprx_U{M= zq90s=v|p?8|MlX4EU?JiFaFH;e*jdi00&fEXpVB_{x#&INhnpkcV&ZGYS?}Sy#RyD zrxU0KPEV4;uYm@X^4%ApDEc-GsK3EV8O%UY{O$5^eyc4OK>kF{X-IbcmXk{PlrE0a%K_MB+E}iLBz$QvZMP{$H`)13HQfzo~)Z&)g@# OA8}C`ky0UD-~R>B2!!$g literal 105884 zcmeEuWmuHm+O}eVg&-xZpme8ngLHRygXGYN0n*aV&@nI|-3%(-H8hOUH4F_yej`3U zy7&9;WB>U6e8=%Ue_-Ig=U(eRuR5=5U26p^DM&rIOLX_zwQCQgUy7?-yM|74?b;15 zjN7RHKyAq)QNOOcs7Q%kE9oa$yLL_ZnzXoxn#c9c**iXX(9Gio`hpUI#wG z!o|h9bseuYw^-y>C|VhmX{x)zSEI7}kalcbhu{KkTLg9=(xjNzF(1mWX8K_A`Ib_# zo&*{OhSkg0AK_GcLNSX}E|ztGEw-4H#e@NLL~l}s-^#N&o|WD(tg|Ptuc2Z5-~LFG z7j`NVaWT{+uq5SC8y!>=uJ7!cs$R*wr=Yv2;kg)!8ly6y<@qjRmX-G8C<4+3htks! zT)&AWeC@{%VVrNLH0M7)zHGj>fYrtQTZ5!=%GsNT~H{QTA6Or2kV2oqp`JGCO<8R9@agCF0B z&mPxkGK^beJ~_plfyw!g(YTm7Y|^m+ftkAteNBSU?Z0 zfiSfugk%-a4nG48y}wm_;-WvBa7$4?-Kjk5exdxkWjl5F(8|sLm!*X(jIcXDb4O{5 z(Io<6RXMyMOcSQ~3nbLAD$*_MeC7J*xDc-bT?Ygpl71gds{e$mPaU^;Wy%BOTDAHREh1e zP9}A{SEfhR>~&Dx;gIMz`~^G2nI*pQL#Qy@t>V)P!!xt5C5}DLWG{1y$u?S##C<<~ zs&39w0uI2&8Y`5xn8$+3!hdU$FbG4-U#hxPU*3F44z9!eB)iw3UVVQx?tCI_je71G zH9cTDe;xy^|CR|nMyEea?8VXZyc)EzAMRHjp%r8D`lSZc%xKU- zh=gO4dyM6KY9%Fe&sTHv!@@|n%NZ|2w8@XS*EMeno|N0??lFDOaC}%wb(M={pa{b%!A*l zY2YbitPwtCQZu#R3dgzJ!=_YvN+<>=JbdO1+~g4+(|oGxr|ge#O3Bv#(qbkW* z(k;f$&(og;jAl?r5KzbiRr)WuHXl*!#mKN)T{g^zWP77=)16>2PD7!-Qgh`O@C`ps zcRkU_(aO%`CpYKuYrW;YW+F}04Y9df^;zy<|Fp0l8t{@e;PcyvIiJI0W&bmo55-E* z!#h!`hlMY|Y)V3<)jp^EMYaNrTSfE_9km+GdzM0j9{N+n#w*@@gl9xTp)4|-pM|ob zLJy4soS#Ovb;tGWPWRV1%esyQhLzHA-re1s5t-uv#ZVzDNR(AWvpTr zeCo|1})OS`_K@l4H=m1Zs-J%K=uHyicJ4pNt;gd}>t?AGccb?_~) zCrUHEMU)R5owH<{NADKx7JHT}#&-%%T4B$UJe#eMxxp@mUS6@m1wFp44pMKR3jFfu zWWN@8p`p%RGaj6^uGmJaLk_)|JBVKK6e&42`jAz-`@*8;)Is#(ndIMyzk0U4xz2eOK>dxeVVuJs2SMhm0jG?*NR!R@|kN`|>U>4Fb)E)UNhh6t@?!whpap zPLp*PZaFM%RMN9!Vl%b95U)k|zKSqux=$*#3ajGS;}LV|vq~}fAsm@pTYcX3W{u1o z#_n+-d@{Z2g>#NsQjN@a`S)j=wh2rJ{4=Z#4PM|S+$K7RaU@*h>y9_vsS3zEt_C`b z3g>~l_L20W6=^o6EROrNyV^p;{0`96l_K&!JB&k&F;ZSuEnPn0PSf^A+@!I`c}qL9 z(E>N}X=8fAI!q>k^#)BP(_<~?CmiDmX7^Kz?}zcgXcg7%dJE_BQ;fim6cfS}D(bc5 zyFG_A>&;Isc%*CL$P;wvE_{yxv*xzBMNtYB?!%^CFP^d~qQ@P9XJ58p^$IhuTy?*Z z**_Y+$d^gwbyzJ1KI|HrTbVyz!RK*0p4^+iF!Fq2;*A1RYd2``bnekeYtiO-LMcw@ zy4kEe=~)akB6MJZ=Oy&$`kN`C9XxfDdotGTAk7Yc$+Tlug! z#KV)_wO#7ib!ImR@H;0wex!DJSyr*x>|LrH_XQK*g?E0>a9ndrC(J~Dc0&A@R@6to z-r*}BJFG21F3vY;=LXzf0DV)=re}uOA5T!HCVQRhzbG8H3-%!o=ip*7^BLU`*K9WI ziCG@2^31vTSSd(*kJX?7w==&s8H<8Nb1q@<48sOW;jd=7$JmTxIGL6l35ISouV=xiZ8M>tg;F4h^% zTZxx7^p+BtaMfo`0H~ zfs-s|;0aF;x4P+jU8&;S%-LXI0^z`D(_BV_ER)Gv{aYw>Rz8*l_pBY$YA{~aN__>cMU-&R~PF_X_-3bni7sr zLWkPgkcm$gu%4P?|0UiYP;FePxpDsue-I5i2xTBedsR{oE!W=^bDMkDuWey$rB_&n zH;Pq_9rM|zP4JFx`0<(|38qJ~XMAmo*O=_TG&PqGuJmxs*4c;IRv~O)RdgT!pj!hs zF%@xT!`?%oEBM`r@pfA$Q;zQk0OOj{Nx27MSl^87TDYouV5KpB_72ln379OH*rf4J z81&gR3&a}ICK#q96uYV|VX$tH#q0yYx&&a5`GYjCyusOaoLD5@KS;;Dva;=m!wb(U~l4 zQ<;$4?g>cU?}B@+nSG#>2)KT->V?5&G<3nrd&yG3)m?gMFzLAj@^>UNOu{c;`ru|_3VX@9bJFl>dfYB*%7%aWm0e3>u{GpJU~{&2n8Zl9K^Qdn znlOmPy+XW$I}F)YKJen^0#?~R!92wet8!%uDBynYOMyromFn)Z*E(33S6v1&FjsQi zMf%-^$tlMk^v3Oc)zd3Vk3SSY_9m^G*-!R73|L zv*XCnU3aSB0J95j{bms#Nb{0F?(^qJF}$UBI{J-y@-@4h@i-fP$wJvGvMwHt$EG#* z^XW<_eZ&uiXlj5Ma9v+6pHGOb>Z5**kWx#%{mgwOH8G(Y8Qc4N^}y;_O{?OdL&5k^ zSq1VFd5NLR^0}h628}uGW=*EK!3#l~$XKrYaFTgj;|4zgTHSgNdE^ z=1)fqgn~|d$#0W!EvF=$LP1i@e7>>9&gDGGSp|ynD)`)C^vULOnwmlx+m3kTsn+)$ zXA@#nLr`MwX&ZS?SX7*Ud_v zt?%QIS%ZW8#HuaZ7;r0JRJ!=kCx{>#)&S^U>Ddi3gCg@O#Pi#1Tat-@lb22qexbE~clc|LS4Xwtmh`{8jW+bt&zgJz(^`sO?gYqE|#}BipR{ z;}Glbcp{iU_2XK^}{%#=ePRFu8Vo_IXrT||)J z2-k;uV$*#<^?9Lt?T|-g7IUX>vq;Vm*FCEt%qS*NB5n8d!GyD=gMyzS!+xinwTdsWg*!*)gu8((NrKWXUk!{auQD$L8BI^FE{pqHE z%G7s9<^`<7{I`@>BGZ4_GITSSE7)yd!s+3&X$fzkcRNiVI}Uk|6N$~AH*B4pv9$$y zoi{@d9o0Eq0(=IRb8`bE4eO9m`L}MJB0e>#4$_Gc;*WR^kyX_(4xV)OE5+}vSf=4k zMI6@IWYvD1P=fc@YeM1gHLOQ;$Xq}|TsE$KOJ&unKm*9ERkwd+?cRP_d%X8)3P5jIR6hSems6{8Fhllity)L*(prFItmg2; zo$i8JFe-7d3i4ZLKcIXn8IIZQN96lRV3Y$2gzj6-4Ej|nGM_k9^1dSZp;lMGwGan5 zD1=%EU3nEAd#^0h8}RdU-aK2Ed>Z9>R!kHfj%708?S1hsIEN>L^x_cZRa}@bu5z(e zXS4_^8s@sk3Z8#5YyUo3i&;Y2=GjH9^A~amav<J*WT^sot@WWz+4xYl}zY7n--FH3C^(WT73#Vc4 z!P_{b#Gh<}=*I&!;vDaUE=}=^a4{{gjmrJp0@nb9NPQUTd-;9xYWe*+u_u% z{+>@>M_o1a1?Bn6$(TLrwwW!hfzWbgy-^LDy|IF!x&-2{S#a`nn)rgimxh~oFpitS z84{kiZavs#QZ|-zkXyHcrTT+w-L{VtNS-?cKSN*^k90WNZ6;AulYRB0zEJ!?x~v}9 z)S5cX$XVm7f_E@fdvbO#?XXnDOi4IRsM@M{faE`ozN9|!wdXsIt_3s7d8_R-=h~l^ z*?Z0^qDmTF?L>zNO~^Ct^U=hbYJ@t9jHdi1qXDCM+bBAN^e)8eYP4{nNDC{w?!q@y z$5m;oSUkS$j%+3BzalV)gzZm@+Zr#XdtSUd@O*-MVo zCLa*d$ zHp2F2%|o1bz7P5p0}YNwPMF(ROi3+)FvL;&C$lZ@F+hyA_3l+#d1aBW^jlCNei@M~ z`fM+mkw~k&{dO<>)!Nixo=BNN%Cy;nHp>Fmj;iSo(5j z>O?=jLW%zFaW-eYh~Oft4heO~$k_vVgjEmYgV>-xhstLL^=x|pXZ9_=;ndNmc=Ki} zW?({R$d&i%ejYIt_b_x{{%Xh!_K~cz2@=t={%PX!gc6@g+kX)eUlv%gESQ zfRqTE`=hPNipg(p76sDKTQ-%PTEVDGt5I~%=*NNv3_Bpu!lnRm!SJZ@N^$rW$9$JPYc4n8r-er!714UR4hpKJ} z!I4==**I@C?lM>XIKZ@su*)qt|YZWpD#ciGRp?OJ9q9U+Dt zUiRrMMkIu&bOt?H;t}&-)gRl>aY|SVSf~owBkxIo{Ck|A>n_4K0}60rv4`7T3!Z9y zJUy_CXr5E5>S5EDSSn+`RN48Q1ncJmThD)GQwh0EHodWJdLtiLR$JeH()8|}O&t07 zDQ0>hjg*+Y7Rl81s_KE8ZSoTb`VtuuW-lLTHNvOpGfb-Jb?IpMLxU_0Go$GeYoHg9>MTE!K=^`cR zx#Jg__u6K&)GFna?(Uq>yUCiJNb8V27zk~fvfNXQJ05tmQ#yk+6}~XyV=xQPr^p^x zm`u2Lpe~?j7qM|93Y5yRcOj;1TmHkHNf9U=hVHa;EgtlrO+2=^NMGFo7#HnEd-hq_ z8CnTVn%-D;e2HZ#MvEjEr9zBmj#8R=Pu8kI8sFZz`l2;z~JHhy2qYNbpMPbbzxSU(>Sfp8p-c!?}sPb zOA&SL*)TGn^=TpYo5>LB`cu*YJp<>`$@_h_v+{=%uj@#`63;(UrLu#8FWAS$I`^0mWeS9&=3{3eAzj&sx#zSC8z z+@k`^$Up%uc1<5dF82jZYu$Lgmg{iEg;r`JCA<9Eo$mJfZk(^g=~Q%W7RZTlZ1k^R zvk|nPiAEMo!V7zsmO_|Yzc0L7jl!jNxe%SvSBbq0@hLSEGBqdJ;_mhwD8RAX#jc6O zC{wYR+@l6fosJ~5`g5<&eSU19R#IE-I{uU=DS>IvzMk!_P|36ly`esKupQ{@?U^Tn z_xWd1r6N35Tc(^;y+a2^+>-if1((|)>xT=I96(LLX`#(YQzvd|Fr2zG$U3e~)t}nB z*M7eM!COe;^m}3BSE@#u1|8G(ugWwFAQh)oXL)fxo+I(?I~I@ljzqaUsq?!7r#*B^=PGOst{!ogLNUpt@oEi+893bTKsqK@Y| zu9r#6C-%CI|7mroy@ElLNoSYWc&dNgV}{t$z)nH)Gzw%UfD^{)4Q?#jJ>4zoCPar} z7PCM`*ra^+5T$3TANHtuzyZ2QUPc(*+-3NqNd1#cj~DwM)7;}^d!eavWesrtO#=2< zmuUk@>$u>zpQ_J9qx84(@gsSM?Z!s(l` zI0V_mwUIM%VsR%15|M;^FI1pXf{zaB$lA9HP92trtBgW1LR559*k8%7c1D4EgKa#g z7xeGlJp;Upc)q*lDJ1ap+{x4zCiKzaB*iQ&rqfU6U{;(+ROc5S*8)1xb`P+UywSi2 z=Z6x4E^_@@gVh%!dx$SgKeA+trnJnJ!j@Z339S-w<=Zn6m0l$Y(iYpfX!KR5mUavHz3NTtQ@CZL8EF4_2B{1CQ7u)SSZuR+heN5N~Ex}HC#X`5S=psi% z$}wIM$SP#7h`;c&ph?m7+~o%VQ908`S}36x&ioX*VZK0&6GpyD)IzQ^s@UQZ@v}PS zetm$7hJ6?iJIi5|xK>g_Wh8NjD}t$h=EHeY2gGaOaULw8Mt_S{A#oF_m$*BWzg9lI zyR_nV9uog}`f|D>vY0b)5>8O6S=z%vIztH)@OXoqeY=}_n~@Aq@3j>507Mt27|gju z#3?N3p7VK>3_|01(y6OF(*F26zIwQI*38=dLS1D01pmsAIXP&6nN402$kq#ZyC;{` zidr0NE~E)6@=e0~UbP#F5cJ<4_-=gYT|qa>?gBaruZ%Q)F>egxjO}ImJ2QEWj#dHF zEZuD)U}=&O{vhLoINp;RHv_Bh9yfe?b(##WGX731O-}sn)a}J9I=EZ4Al%r{#kR2p z?4!To9ww$W{DV-6UinaAblh#bH*9@CWx_7YrB_RL7Q{vLeIZ|fj@m-pqP%s-9A_&p z)d9$6$TPXu?=7ck4-NPYXKeI9x|*- zoH0TJ5JCBq6<$NrSIuCssX%Bz$q0m0kLr(EjF2{=gl&_iiwPC&F9|(SX&~H|tEgJ? zRFG(3;&l+L6r3!sbu*xUEWc^h)*+mrHqP-HYPb_ubHYJw>MIUdZN5Zo(fE4U9r2Rd!`!1wtGiUfdmu2GnrlUrXi6Be zogLA{ME#8+jX43JK*xN0jwNq|4DR{$_0AZet-I3}Z^U{21ii1HmW))|GH>+3T=Iw=k=tCn8n+;MTrZA|IskJ5eKk8=Z1J%(~c2>Q`-a1%W&7`V#V6HzB;HJQtO3PEQ`f$>eHfxxsE8|4~im0riM!d)+(<7^l}nZn&#K%&elNUlzV)BdM0L zenLhk^NY2Jt@qltkQwR_kf4x{=UWMKXujJCfL(R61b1C96*JDc!jt>v zy;{})OIjVbv+ABNow}jHrE>_h52V|lQhcbN%-0PG-{(ty`In!hOuaQNwtRsqixGx8 zVN~3CdR0SAQ-0#JMXPOCjngGn@-hxk#rfFLG6hvoZ+C7hbf;Fe&Y)_1I+jnz=RKY$ z#oX{J_CVP(bD3F1)V1>74RCH$vz$}{Mo5F~-Q6G>0Zj2odecrmiltkQO|#E(WB6}B z1Z#T?Ohi@3^sp~Jlgl%H)Gpm@?^Jnb{JSxZ%M_&r{gQsFwSAPy+%B@Yz{BQqPWs8a zA4Qw5Yt?l^QV^C`$pBUUP{=I>RM~0Y;BZ8{v?%nP??z3>Xmeg?6-C2%SETv|RZ|*f zy;axjYQqVaTpWNB5OeRrzH#5Qysx0Xf|AaxuuTN2v*oWU_n^ehURczEZS4RcXTBPl ztw{6~$bh4WY2ZiT{u9xiD@1iZ>Yw|iz4V@6yUA!>e1f80%EDK**l~%+L4(Gf@|u?l z-DiYB7)KUYoV3ND<@kdpk49Q7@OUpO@|hipCP$A}D3rd4yHkphXk&VRLWMPVRnOF? z=zM+MfRb_VQ%I_g@s9UYb!%P77%#$X)JkAkD(<9W0m5riQBzI@KQvPUA0c0ru#cppPiG>GIvCpD zC!gvF@o5cjE@B=!YmOLHhIq&~dWl*^{_Y|SSi~^1IOR%H)#F$$yk)r`25?p>3QmB% z*Kf24z4UrARu&LHva)-$aXcN9y0v7^B<*NRy*2_~X$fy$9`iuu7u6;?W0Io2<2`;T za%ba4Vsq8j^sPzw_#LqE8q1ta%q-)=*Tf?8D8*zUF+t;z$pO&Q?(V5g!IUqiD=jUX%dUVM;4oYExQ7ho zqg0wu%Y2$~GEJ4(7-c2bpcqTz6CX~zWN3CmIO%f;o-VZ$ymIbgXVj zP@-3A^tRX|h)_{C7OoQtn3GrpziQRS^j_sT!5FP!&0XsIzY?(3ZnSnpXB2~vpudEq`*NPa z`3VD$gu#s;dG*1BxtQcRjbiXcbJt748j`);hEMMBn0;HWP}@nZX8I0ZE-VT+_-U1d zceIl|8K`D9zfKXwv@G%Pw^ewrzJU`P}qeu4R6Tlw^LZJiv{^E)&tl+&Ieh^c5 zV;@Hye!e7S;w+Z?IHRxG!YuR#@ZPJ(b+t7Ut`S+{el@voyJtY4^M`QU z{L#*%+aQss?B{D#FhU-q#EE0dr-G`BX=#|{tP*v)>fW0?Pb9~-@ZY|LX4T+79UZWs zGFsAT&b#gU?HcoG;USure;N&{bofHdo@YSklE*yJWAD^?ctBo~`(&$62cl2iJT9-H zmlDvw!6?`a_~apdLADJT>Wh({`^&k!7LLBzc*az$J{f9T{cK3QuRRmhU&LxO1{Of!F{wxxv?@&c7IYP~|8HBUf6V~3c>d3${=wi^9`KJc{9_RRt3UWC zeqEwxBSuk>Rs(k_U%EG;_;+~|OSmQA^%>bkg~;36=OZF&Sx;WS4n+g{ovcx^on|uO zi;Vr7T8YjGcx->OJZF4_bT%?0q5JdlH?Xj&=|b6D{7Y+$Cq|Skq6P#&2bVCTUo`jU zVtBwai~`VG0}0S_q8!cFsWo;WmW)vfSr%uE8T!UK4>` z`Lj=1_18~ z9#?$)&*=_U-SQE=KYDX9Yt|oNe@7?s=eKHKPdz@XdD-*vYkS{i>3yN@E4f@l3%+x# z4naVcF3lDf%@#^8F2Ys)=qglkdZI`FlB!RD?ByXs+PPqtd{<^O-WuY2I!EBgvZd7F zh{yPA3n<@pBn@B5d-yAipW7*-(X1bYgI*${<@1NGow|2@RN331?NV#a=0@|*v3{nza%Y)}5fIKRR1plZ39YdMPh?!VoMQakkj zHsb#aYWE*x`j4vpmig7E|6f#XTkLP^`Zok}KrN#O>u$5vx3_9QhLR@{hQTK9hQ18Ch_B8papET%y_mG88 zT5g)trQTZqSdN;O{G_T_+rMGUkM*($r-`2?kmC1+`a~4o`kU`Y^!_K_Err7H1{2Uo zZR;Ou*HVc3fRh+5WWB3-{DFca2nLzeDkWV=vYR%R_HIJ)v*87m$ooohpikWG{kWue^YcXoMb_ zbSBugo`IUYn+wOtX;W2+SgQOEhZ!lTk0#VR9;{cm_OtAK;R$h`!0n|yFq}M#s0ley@S4w?5&20wg(1(X;vm?v&a`&av@jr>Y zd(i7^3vzs@v6XCHyazP*)MS8ZxZ8;gpgWMl_AdNFoH<1C7#=ceKplW~Seoko)hkp< z{+ak|fcnHKgmR=ohalJDrr;%FOm9hF0$ZAgyqVNR(iy?TXnhy1{BE0KO9Azy-P zjG2$y68h2U##VDv&2HZKL8z7|=3i*Nrbp}E%+*b4{>bmLG?-H|=A2ud#;=NeuBpqK zXUG{}$-JEw+%KE|*ZBzC!<(A4s8#qBDhNx5yRmgYO(qsI<0DYPQ>TJCW{jvj(qt-e z{c0ZcV20f0;{`jVuhisK#}9eCyYo#Z z{gWM+5G9M?+XwTOCA^*z&d$$&Ij5J;112vU4tPEB-2Jna$UP3bV+it8W_j)P7mp5l z#)BmerqPaCN7}>ojV23M9yaV+BD<$vt_`62%6w&R1Z~da;%?S0aK}(FSM!kpYEx4i zD>;-L1v*veOP@>S^w@T-#$=Q6Si@7FQlFQn&z*xXZo5c`iKS0Hwo4WcnQn>wv_>?Q z(3vyBc?xwoY-%($*DHZk%6w&KKRG> znzR1zzQ7M;>;aFRQ*GyXolL{e^doc6b%M{)NnQ3FJC2%|M=fiq6u$94`{;TIshPo4y!LFCny{ zVW@2tfrATSA{^UbA8MwT=sOr@3VUZuFHyC-xR|_jcTr0tR7XG2Eax<)T1TxjZrmcp zsJj>+FP>mj1lzibhQM^0eO&?rC)R*Q_4ZFs38zQ##+r+Ji~4F(Kn%O;da4giR6jaD zMx^vo3Vn8Mv|WaRyGu!^+27BGC-{=*CC05ug6@U-qPj$lO4P8|1j#5K7{Zo9$o>8N)jj@_d?ztCo zM^%9zpnSnDFIXqdasMe${~E80xr*ix-IG$^rEc z4m|3%@dmtJ-7Rbl3p?)={qwdCia~H3@Gz#3+W-`h zE{Mb~GR^#S_^Ld`;~tcDXW*EM#cp;X zxUfok%kFsel!0gWhqvt~_@x>Nxg8$kIjj%uA>RGhd89oRRH$iV)N7P{y$^WLv?A{f z)Y=B=&0yUf@n;h$9DljRg_{1sGwvS&Dd5%h^9Av*k)IM=uiM|s@#&Q{ZHz1%qEkcd zLh(VMjv=W?XwDa;*{dkZ@zJ{c4nj4e-9z>^yP{3|>B?UFsU<$ArRk;B5! z@C~85{^}<|=w`C(;B1SeH&xIqcC*>Y_G21i#_YS=D?GX3oDavh%Haz-{Pq$S?x^Ol zF{w!_>zYQu>W(A-UgU;9{Q7i*K z)($c4{*n4WAqy};CdzW7j`*l20e2_8$anR93$jT7d>0y6p+$&$NiLVK0M6O?CEj@N z2D7hm#l(mTLJwB5y~KTTEWCN1PuOTi4|pm2vP`0SrX=X;TrB+-lB!Dd@AZ4>>!%iX zNrRhV+U`n%jnYSy1kH-xm77LvsKNApY_O?a1=lzX$9)`J-d{4bQ`DFh#iM0Lunssl zv*8B)3hk>NKN4Nn{z|-$P-*Y5aE&#Rovhx{#iS#H1Onsu6;}9{8N>uPvtc91fw@wM z42FF$dvaMW>)Fi$d*I$7`W^lqmyQoASQVEg6}|tM7;HaX!!>sa#@o=WAL?&!C-Xe< zD*)rqCVb1btMn@InO|ML>*g|H>MVLNu3<*Ci^3mBsqTq0TgxIZIh#DaM&Q^~dlZgp zG`5_i{o2})S-tm1%}rS9(O~*^3=;tpZ=s6?s^y0adF!G1A@4<5Z|a<_8g;N)>K2ci zttbM-PNjSsZ`SVqJ-EO6oNxMt4izpLVrBG(iC(h&{Lfv0dGIe^4_%{~Tjknu)a-T0 zytnUrHm$(OYul~6Igs60{_g!$-+PK*MN6i{p7yVE_N2DD;ZsW$*Ck8Arud>P%WEiryud+ho1b7B7i+TOQ9jC-HPGK9G z67+y?gN^Tx!n^!C*JlqQ>d;<*&?5r!*qGF@w~v?R{h0+;8X=Ro&aY6%FaYhpEGP3z z@xL_0$uQ)Z|>xWE){XnZM1Hu6&3lHYQW10v$3*%G>Jphe6}x}(*RR^*b1Qw zVn-6%MyXLH@uYxZ>7!-bJjZ?n#m-pAa2%@B+I)xFYsBmIZU(}R$_^%n7wJ!=LX0=L|PK0ZMmjgWY)ru?s2 zi3K7q82=o6rvG7oKfge`LWhG6 z8~e}P;kCPbs%gVVbqru>Icle~K%{1@V3n+$onHpc)R8NEs6f%GRHZ-%6>R+z=Ch(V zaW=QoN6SYI0@#)cL*#j&rwr5rb2=4AM{H9xj1Hng&L(n9Q&mZJAUq*5{)=2)ySr8Z zYHJ4a8dIV-i6tNj)L~HIF{pzV!lb@3Aptt%A4{LzQK!}1O$86`9FMK5gBD%r@b9YF zvz=ZKWgwuJ$-aLfe36pVB)V+%E?*mLfXqGgQ&DYTEDz@^&{bGSPGJ^6Mq>vCt0fr= zUz~Puf~M>d3#ZjNQnhmBPZHx_HnaKxuTsaX|Gkp#|$NY3vRYc&i_ zfGdRO5Dvmq>?fZVihuv6=QhpM7YW#N=3t?dMM~iyppNIkP4i-|GVGoFH9Q*nBkLID zJmC6zGo|`LnnM&B#74#po25x5teV(tE#2j%_f0VTO{ba@8<%XeVqW)SiwSOp4}_Q< z)x@ze!6#jort1M>w)jkheCq*0;pldU@efWb`2>GGm#g`ro7nien^ zs7XmfML-ZyC&;{#HoSeq*n79y*q-%B7~T|JCRoo&d2TdmngDbwPfaX7*Viif&Nqb! zPdy`jO6|`bL_UN#!10EDZ91hBz+4r}cIbgg8Cri^vf8|gw1OAjjHXgvrczml5Z6=gkx|z4 z|E$G0)!t(>#C5Ow4@C}qT@T(Bg6ntjPVAxKc5+ zQHBBY1VVGKR_V0Up$|N(p)6z=CD_%a^)EJ3(`%*#-e~kttEYz9?>hUhdmYsGf~Ow% zj|pW?IttA<@s^qp$ef9p2F`g+XqELPI)slE*PVs< z*A;jl#Yp_Mp&E?>nktL7z06)Oi(K|(hLllf;7oC_RjQ0Ge_Aj)(hR9bnAzER7vpk{ zi9kxhxV|1^1tvv+^3{d+)u;f@i8^V?hNfkIvQcFeH?{Jbebwq6QyEJjoAl)|zUkqV z%}|^siO{F11Z`t}e0xJ(#uHa*)#G|)8l?0zf;YS#`qSr~xkfd)597gS^BPOKCx~ic zB`pR`hXU@?+uvCg6#{p?4V2NOoI@F4?{zd`rJqD+XV`JMhX$56MqPYE=6y)A3*|iR z^-NWzOw(@n>;#-Lzp#&D<)69$1<#Y6vZ6gb^#7iM&lve>Val_@6RbpIfH*sU*v8I7 zC{yZNlA76D>OgpJB&g!o5wE1Ws8Tt>0MM5H3945bGY&@)MZpiTsiEU2Sq!|XF2Qw+ zjAq1ok6RewKyIr;OO%O)a_P}!l%@vu1z=n-BQ23lf*VTT8@}FoXImt} zUS26R`Jzu;myu{qv@0>PTE`WMw{Y7gvYeHyVrpC?bPNx7*4T{!cML@VDmPX~)@+6h z6<_cy13ayYBs3XlHnm|ztE^ISPapkJo+5quZKV6HFX|LaHiH>QKwoClf}(e$dE-Id zCxuiS0D-o_R;K!{!cZ;w`}Hc-#@qjgy|<2vs_p)V1wlkg5kWve=>}<#QUs)P=#-8D z=`K-Fy1S$si6I7t5T(02q`PaV-?8y|?t6Xzec!d7e_Vqz=bU}*YsY8rYwvyDr^iF( zTpKU$Xh(jP>8FY!537sfC{S^2XAIT`bMbU58E%lvaXD-DM zCDqn@J=c^R9d1-LVEn*P8F(i-O>|8fak|Jv1jRkQ=9PSy8>XIA)>7Hl|CES zaxIJqXB90y9g(&^+l@RB2&y19xx6h+u#q5JsJ9LUddLE627p`=sEk9%~WFLEX}cWl}{6RI)6;c7k+Y|pNwg3mP* z-NX#8gF?q!D!X8erR(dtQerVLK!mnV1f0QZL>gx3{&sa%HI9sc58KJgG2MEQcfCOO z$(M>f$|vr*@@6a?zt++VL%NLR7Eq8Z@o0<+@(b0Kkp&TpzA zZ-A~{-h)LECMnW7#EfXi5(^v2;L3qj_xG*~u9;F~K^vfxn1nJvcxAVuO^HbmT|I*ASL*lqK&!~lmV?|=+yQ|3>awGAmuy9p`Y zujd7IBE5~}(y|G^1iT0p3G9OL_F4UzYY2GiQ51P|WO6#;N#4<&g-KN4^aRpI{#3j{`KmMoC~AJ> zx)5W(gqyj4s$N5O5xZsZ&=NWn6_x48E{oVc+5s8X)dNeSsuexZ#;nL3AR`nC6Xz>X z6Y2KAeZ_=}bAo8DPEr48Q|aOXzNtzhwBAW~j!Jp{oq=kxLQV&zWNgbPPz@gNOYUcB zrw_I+CEhgtm=F3bp&f^`UWbAh@zJv!(Hd@gP@E5R37&SSDf?N(u^BB-nBjcsT@^n) zBPB6Wqk&3Iq^UedE5M1wyJnAeODc!72#07Zn;~ae-!z*LVGIx6=b1$(>~HX-k74YS zxExvp_0xRZK*Z0we;J@%nDf0{XGwRHnUFzTe z(f!PgDx3)YVG1cQ&7LDtcmV2Utf}&v9#?p7%;k%?rFxOs28?}V%Gv*5wJxgM{!S#d zKce_&DDD^JwOgd)*RXGg2tT^>>;+})o`>|qu!RIx8^bR0@Oe&>=2)kSz1nHkyNexr zNk<);nyzhcuNR&R0n;^d^A;_}Gz!9MMk31O3TV-;bK4hei~_ylw_uyS zO=@U#!!!S2xv|%t&+(3w7nTe~tSJpNgWFOBmco@0EoEpmNT3G=eTYR}xwcRwaf6TQ zLAo^$i%YjF(uusr3nVsVmzEpG3-;C(?sm4;W=+kv&05##Cc}i&bi|TU!C7y*0wZzZ z0dWO*fI-^^HA2b@->%;@dAh2moniN^0dU;GY3OMZY99_hJsll2g@O`a^kH|>gz;DS zu<(0i=d%Zp-D#5jaHz^K6>(ED4eJ*`7DP;VI*Rm!tk+PGMWGDU-We%gC({_|1*+Pc z(Nt8Z-tzaktKSn1g8sK1E#5FLCnmcDbn%>gG3L>bOJZ3L{ZzlHKCNlv9Ny zzTtl(Slc}JBf7>AgCV^_|7vaFsq5HwdaRwc=pL_JLh6c3x?OH$Za|rNO?x1(P#w+| zxGd`Mi0&Y8mN}+AX?_!PRR6bCVn;-xj$aPc>GIUD25WD$cLkc_F3iTJdRZD|F8dj< zNU#oB39iwq1WEEPX_^K93oD(uIk}x+?*r}Sr zKiw6^@9ZdPqswBi>=lj@tk$W1~6)m z6!2z*A4mz6u^zifs>ZtmKg0pQNhsbgH|eo>-TgKDJv&1`{{3cu_|$BbBU?cR&(lv8lRQD57k+<#H_v3~`J?5cpXPqNt%i zZhUvuZ_WW*>jZ3U5LVD>H+hfV>}LU}of|lMM``(58MyOUT#F=9wowbz8Fv@W zyQmxD^3^KueTd5^GyhdDqgHkeq0Ml_Z4v#&sQHw9Ygq za-KwUkFiuIu@`PSWpC>Y^vF44J@?!dR{i-jJ1MmM}BDLY#usQYwaLQ*d#Q8w15t4 z-wOK63ou`o`(#c6NUM`VmIIj{H?mc}TglztPd=-_RB_8+(}6=g94XmS{rymMe0bQL zyP0X0Bl-)<&8V@8_ze5p^TbHgtyXg5(~Xchr5S^a@}O{WdjVRDsmdkuR`+Ibb;QrH zM_%O=I!BtRU>fpz<9NLrBaiW>CtE9E%bg}jLsRx7EX$y|7LYqf(6H!FATbB0E=k?ek z)@F|5sQW#yPe3@C7v%HUfw&!@o>aLBwW@xZT^;Pg!BFm^tuxHb2KnSB(wK(EJ_J_L z*ZSnHZgs`i5#<$RrNZF7*1u{I91v~b%c*T=6PsO-643h{RnaAu zK$}j96h-|*jUg`4RHKaMfJg(awR3yxQDQqEJDf7{Nr6h3)1p!7}}v$nP<@!>3Re zZC02t>j>z?Kyd)buv1bl4_yrStIWNSTVcS^Byll;hQKllesijZ#mMglQ5+BO%MVDZ z?`dD@mm8hJ<}=>ArEi{%WA4Hz)0p*ZbESzPa0K?}@qIR@c0h=YAZ#X;9$5@w(A)E>A!v{)=kFV^)_bPvU%i zUFy^Ep#qbm(It`4@cg**^?7P%se3=U@apzM!4=PNV^ytAPjfCtfL%D;XMlwtVoWE- z)hVamLb}2(wdneGqr6z3g%J5cGWBR}9m5QIWo7kyCebGwECm$eqi_ps!m>Id`7ejD zjMmTGY>2wb*V5h3x;cq$dmjkL3(k(Yefxf(dk=}j1l-I;xh8 zsEc${ma?Pp-A6Lw4$rbNY*t~yJZ6QmVpJMYh-0lW9<*@RNsWO39Quw)qNCq2#-pU#&&?z z!HP95>-jl%6Qa9iJ)*=ul~)wm+t$H8er;C(qlNVHA_jRGWGK1zIVI`3M%+dX~gG2&S4R#imBNyaxWECyztyz+G_r_$M9{BI{cZ+>2?r$adv;A|f{K>%P`RTOv6#kMeygE`+F!$wx|u zh=59eIk|$ao*_S&{^{JHm$BC+T(_*7j0?XZDdp!l1qKB`E)$N_Uw3($^O^#?&mrd* zo2o>cPIT|4&9zSR-ZVwtKNU5`-iX+ek{%S>_8Tn~-~y=S*LAD_(yAamaNKxvJ8nd6 zw7$AY5sx~?lx{rHQ=fAR*^&VPwCigH<&%%r#_<+r9>d$UDJvE1;8t`SDlnyCGi+Ve1*l3>_b-%HRPqSug{KTsp69rZ>*r*=m zQK!qTRehJ5s36lP@6Ii|P3D|ecH7G8uXSOT;i%|y$#kl65c+MkO8eGdo-&F-(33^$ zl&Qf;Pz@tKHZ>3wLo+t=CV~eLzyj|Eg)15ybSuEA@mLeOV4dyT9uY;LN5Y7{4l~_c z?R2nY-kl1~cwo@lDYDZsEe?-33V0$AZa{o)pgqR8k*gRBKYxoiX;X&MD^Oa8gmSOskJac9ia@@Rj|-0*yCuC|GM}f7MOkJY{!?%0PY5zVj%=Nt+g7 z1BLwBg@Wo!$K9|tBg!`Xa2G#B5;$QE)wGt9@NN1B_AzG;kSP-MQfSXC<=JY#fp!gt z)uHKJrt%@LeQ?5~laDpp7cz&FU~Jx6Y5t`-3eOs0O6KDSl%#J~Fh_q{lb+W|8Vp4} zubT$fH8EJP?|zBjg=;v}4xN&&WOFO*hYK%Qwlt{pci>FoygMeqUX<)@Cc}Rt75m&F zHlGMmc7 ztQEPE)1FS@w_fr7rdC0`LqR)5W_=>!eP=gD1GQ=$gWO+DxRekZBh^X0d3J%RT{z9V z*M4BSh!zNBLq6oew`2q=XO)GzTuHUns>l z-PPULNeiYij#*r^lduv`3gMmVtjuq-(D2ZS13^J!FHz-vd=|A#BA4vO#@J7Z522mq zBU2J{wpzl5-3B}NU6hno{LzYtvfIB7xbwm#t~6G=$)$cwgvTP=Qqt#tmmxGQ~3q+F$KCHT#sH%CGJ9s(~N zz4Sg%vjBiEAPJ_G!96sY*R)(pn1r;b(nwoM!Nm}IFQv)+F{5lUsHQhrD?Y)Mx3Mx%4F=`>ODFlyMg;zf(vI+?H!dp8sGe2x%%t= zFk<*YI(3&HpXq=YEI;ay3(j*^N>#?_{zzbWsk@%~4LY-9s#ns!jaZwtUI5>O@{C+f#iF;^VY24my(Y)7B zy2_?Tk=e+HMp6R;I_B1NlX}V%hKI#mP9ZE5}&>&MP)X{5;CEl{RXSA zC+$zlSJVjiM3)iwD!lciTVapqB^Zhs)_Kq{E6slVxB1C@GUE;f0 z5zsG-{w(rn zJng9D@uL+wX`%^Xhf(b!$&!)@BUPe)?E>W>ykAC?6iMYPdr)<20s>9v()k246bUy{ zz$n6vdm_FwmQ@&KKX9o*1&AYj(fVBYesWh}1e~CKEPjAR3~6L zNn&l!PVBH+Obz`Dm5I-Z-e))r2>&UFe#qlh4dJ+si4}J=O(1ewFJkv}6mL*3@5sYO zDf_D+mQdl-(JJ*VU;E7wM;E_t?XNOYV_{?bd)id{YiH~CMpt3F#3+#oB9BFK&`;;W ziB=!*SywBZtL$Qrnl#P2aUDNyY&jk#U_YG6JRertoVG~{bBj(I)gARJ37d6KrWKQt zIn7r%T6enMEz2~SI)KZq&>KT|y)ATFB`Jh5$@pxFCi+NP*mrCZc(>n^4IX<(n9Wvx zvxiVUimDL`*`6(46+qzubRWOS!C`ZFaKqjPktU|ZQi}E+J7St`F#GI{fKsr zzlQg@z$5O(#Ghl7Z5rtOt9_rU5)ZyyUx17FRD}ns2y6-1KX8OHI#Xs!i&Js)B`@pKXuzZsmMV{vwr%w z7h$s-K|ZLL$%ZGd0yOjFpYEHJ|WE8VFrbjb2@(#zTwmIGhp|61H@6IZ>k@K8VPdf11URM^SBsSJ4)}8e+3ZmaB*K1zo zq~BtSL)(~9_YNGs5^d~nj-+$H!Q?}{LAf#7q?PTT0fi}@w*npq1m(Q-dO&wA+0sai zgzu9E&HG=w_}xc7rvC?=izIVRQDIn}Y! zpG^uJcW@6mrTJdr{ncN* zlLfrM8(DD1eOBS|wj{%ZD@*;xtOFz`=?K6XTG|&RW;1Aiw@NAQ`E%fC;H)kgc5iPBM|CB>rDrR zV`;{69hkiT1X|yuYOKstcNs8s#W~a@} zmmVU`-E^2y$-Bn752<+DEZFx_{WouF2Vr03&g~pQSgd!bQmO{pT|my!#&vCf#a%xc zP%q)t!(wL#b^$fyCJ1G?G!Zmh=Z2UZ27^qWy4UHg@3sDUe+nQj#@`Mi2q3shz*aJt z`}S&H-6((&mdLeZcCgbMc>`r{jB1tVw1fN!Uz)=p$LFs)=nvH)|#}`NXfpfu4fo-(*tGbj9Fh9L?BUfE2gOeviLM z0TiSq_Zd~SDu1rRaBdxai$H%CdvhcB7~I(N2h)9}pILn3oKXF2&*~1dkst02>j?-6a%X86*YZRP7`A#%6?t#?P{Fc#J)D>7EfCI5X$AEN|fYP0^WfD zq0N7dswDvAXFOo@9qMIDi#vqhi;sV6F(5cyW4dR3RiiPr> zPwl$owUdhmHg&Nh*t9Q4&q)5d_FXj~(3N*Nw{8GxS#x22#Tb3N{lmvdB4(P8_-Ld9 zrh3q>5H?m0T&Glf2}p6919RiwQv4rEp%w%D7PlOjV9m%XoEDk(v%UGMfPLGtpF8Lo zjmXbLnD(pw?5|C~LI5!BNX+wEMmVO^uM7X&;_pv0IoA-xWw=d#&({05TP6Ui$+Hr2 zCCd8yM!$$mx^+8cKO(&8KbHAlfBuia|4_=`fBuhy|C7OAj^qDhTC5i4`Qe#*=Y?s8 zb49v)zw!^0^OfQDZq|c~ie6^Zi-LfoL*pM~B*3W0<3q3T8GakDp9Vt|IT!O}N~Vh$ z(>Q}Ec6$KsLQ4xwCeK7_500AoiD|$x4;44I^3H2x*~vHqhR2ewk%?TRv&P-IG7I2c zg{L;Yh^$GXD_oC+!h_dNg?WlF-R%cWY5|@fX7vt6s=hria6c&^)^zy#xLTyjiB^W%X$NSxgb~4RymZ?$H z!7w|e%{bwD8Cu2{jJ?-?JT6ZA;a2fMVkAcwiwib7k=o!HUnXdAdA&k({u*wUMVq|UE&oxYE7O%UJ%FhZMEafG*Sv=4XB27=cTcB5C7%RkPVT*G zO*K0W0(Z_CnE#|CWCZc9VNpEQown8wrgLpemdl(1#V!(Ce;H@5ZN!VW!$%&HnD%hG z43AXEMd(&bS;sbr=0_QipcyW+i~{piL3Zv%#SpJ})1O27Uq0Z+qJqQd%mmb=qIz&sd(AM zG}fPs|C_kq*7oMZ8S(n1T(-A=0Lx$O_=6+7?gK8c$x{^cZ}j~7=_@KAG)TnD_`mM> z@CFb{KAw^LRqOaK&qY9*K)sz}yCiJ#e?9o!QveU4J1YK1^zh&2)B%8YlTLC3zbO9i zU;KE~OCW~BzfKJLzgAM82%rcDt%yIR?*Dwp|FQ6j`2NlO|FQ62#s7a&_^*opKSlmG zg?jh2oV=-cYs?m2&(B zcFMkd^p$>-pJJKlq77QZDx*`ak5T!4b5aj`R?+fZ)t>G;PA zj0+HVw`#fNl<^-O+;3lGef*AJ|n943>l8MKc%NR5rxWDOle%*?AU+Ht&IKw)Hz z<5|}UxAzSEab-vfVsy9G>C>>jEjaod?FuPE8`7kVE!yAq`@0-Ie2nb+ew4vE@+P8~ z&!*9#P#5+|#Ed@a`W^Up_z^;l$YdUORQu@idE4$%RUg%mpiBgjkib8gKD9UB5(CBY zaarN~z&yEAAzb@~Urmvn=x^Bc<{khDqTc=9yMN9B0GKKg00c$kCMf^Fq`x%w6Ob-Imw5hv z{p|L(IFQd!4lDcqUWLDD`kPo?+{@=rVKu|tD z$GNhf|4eKVfM1;{#Gd>&O@DLiwh{m%RY-6B8)3h$_f!U00}D$h`d9b#^Nat9;lHx- ze`5HrdhkCn{8x?s|ARH$b{V|=FUC;N7SSm$ur-GcF?c0?AZ!db_q74H!y-y`avF+d zk<{F`kx|C9UcLU_!W)&%5j%rktkDT1bFfrx>Z68yJP zy{C{p>S#4~IrRQk#YTtTk*)3#R^zDC9_Q~drB}aZ*Y5-zhk+#k(?32o9f0d)csE3F zmdRkQf6cz0Hd}>rI&CR2JyE)(paHT$K|w*Y$LK~ITEAf0s{RO}{a)DRPC0m7DewVz z7`_HXg_xi6L_wU-Jm^Yu4{%@-;Q3(dLE<2Ora8F$0g2O&i!IoO_xlNAnXcE4PpHD= zLoU_!o!OG~Ve~mNRX%V`6%PS$BmWP{W<1rmDDkLTkhn6L7Wm=}3J za80IjT55|;WEa-28WrlB4qo`;V$FP6p3by3n1|=ZPAJIPItYqXwP;iL)4~Jz$d|X7 z(We*QdYM)ToJl6Yv^dl<IQr5<_#==gd+H_BK8V#} z#xXkSUiI=)zt!avW3nwk;3T3&T~@gTh6r##l7wbH^6`=OYtOo)n%QIa7$w58h~_5- ztb@RwZcNsBTz)+Uhech%_JE#uBL^(Yyxq@h+bwyz=ytgYw2w-&ODcoT`(}C}&h3P4g-ja(fI;+>7_0hwp)n)&su3 z==~u9!kps)R+h6HoXQ46oa*83ZQ})CGt^Ho4IOW?MSCXL#n3gha$8&O7@4-;7h#Jg z8~;1~ge{fA5|hL#ff!j)TfFM}L|PUl%{SWi{I?^kyQX5>i$ zwVNe5Uq*=$!Gb!IP`i!r@bKj559Lv2m`TGo>LxU#hkh8tUNM!OUWzlxv-Krrs~Q=9e{2iIOIA z&5H-%{F=@-urn|5Mn38`@?rPH-*%CBKlqFqheyGA|K-aAzp2mUI``r6pXzIz6^=~_ z@?}}BpK+g9QQ#Am3nZ+O1kf!KM-rl*#HyZZ#`EPXT#X<9`VrbE7lnAJv*=O%IAB}tIB4R*w z(3r}JM`!m`EB?*PoM`@N$0Van8AHSaD9UwqsltLhFZy$f_m zXj>)oyLC{Iyo54nLfJMx-<4UX+(?Rvh!{{HSaX|a%oANk*qvC0 zXu;*t2NdC@D{AyEygs1Ot1T!EPpLLisobe@&`=!cd93a^R^EK>rc_Uxe6=LR6qyv0 zd_ZaDo16QHy*yGp=N&dROxsN>h4@ZeNl|eg;{n&JERcJd37KdRFS*@92@U&E#ag+7 ztn5sCcej9QpLFEuiZu!4Q7CpLTX&OfjhF|jEYGdbKUoaG{)3;+WW1*#6Jg@;>l44O zSJ3ptW2!-!d@_N)4dai@BB%qqSI(yYy#~d4vQ;8uy&yCy+S&kUeNIB5Y6NQ|Mm(x& zhg3#7Y3oN#S6a@v5xZrX-FG(3_KI4^4qc_c)jUDA_7>V!%cqKKco;Ca`+-uCKw zaxjt>LDrrKP}j{g`Lb%bO{XFuqiHcA6lzo~8m}OM(O9RHbC}`FwDW<7`rbNa^mTly z<|ym@A@kuN4?qv}@l%4VSKjH{@+SNt@U-_$2@p&7!8UJKsrcK?*x`xpsZ5^#^N zH*Q0{1tsn>N83j($Xu?cPM4&bEw9$Pofg{4QCSEtw0HRKBGa3D_N@z^9&VttHC9`# zp<{672!3f^Ey*4_1@~!{JpL`!2uRop4_8)+v$8+cbL35Rs+FCHiIM0=;+c%``SeDI^-~H`EbDOAiygj+CfrM(KUYXG=(|ju2@~}YaXMu zB`?)*e&y0a^_s;mRC{4XJ<#ARFL74ps#OsCUg@X$&d~i<`ce(zWf4_!L}V$zOQly_6E~ZSS~cI(umm;=}f{jG^cuc%-uUHv0v*O^a zdcK?n6;^;vL$utYxkVCQNImS$A6jzP$m3!1IP1Jk-t~puaj}s#(oyi)3uq)P_TXYB zf^*@6%I2NPLij-ChZ1IHGmqyP3yN)he#KiISOJM#E|67Dw$rw0baRry&jB|%MFBm1 z_pBaIm?-xfre;ShDO(dn<(k@jttYlM1tYPQ0LWrQ&+h56%Ak__k6ZK-qP)qs1=Y^c&|gG9V#`)y|f;Tnlj`kT>{ z*5&55rxXe>*-C@+4U+tt!CZlI6WqJvZmsZYvCKJT!f>n?ujHeK?P`b|YT(s+2%NDy z8{v0K)+HhhOrO8UJ!fA#3Gc77K_3qiCZt(esWw}i)Va?cjdvqA?Znl!a=ph4=*G}c zatEize^L2*kYpOw9e}Jig*_L03zf^~G=Z%!jv{%y9-drtVDPlrdJtk&+m3_gQuFPtGM^1e*`+}a(o8BVlEzHRDC8m_atv~vp>)$pzH%4W3`jHLFlzAr=K ze6g>v1V^aT`C!(E)T_f1lZa>Ea<+}#?!pt{dijfK0vY+T%@-tV`ts_jo|fv{ZBZkZ z@L%m`016OHy;;N9zBqbb|3F23mNq52VuZR6qbtVWK4A-Hy}U6#b-LeWyf!>UcoZck z%OJ2hTpP6Tc-!e9-$T1(JyvDxUHT@MYSZH{O*?Nav<3Fty^Nqd-o|C3rv`iQvRH?j zBQ43(bXsHmxEqW2-I9?Og}*+Y85me1qrn5m0uHB4?|s=+5E#WQD5JT3)O;HE21hlP zJJDnx)s};r#!J_s9b@r+e*fkRiHPowWuOs=Y70a1y|C^0koVDBV4App1_slrR(Z;P zKaPLt!DK~ZhC4&J&J?Rs!g4JmI}l6}17L9OgLwSSGHWlXc#cHpJ~66u2_O8Od_`2m zDVA3=^@*tBdroi8SBZ41loTWn<7GB4$c~f_EJf^=b)pV}{B(VC?YyrRqV|{~=T$6u{9<99##%rd}ccrUhV;;&)gqmFFdsvwoMjNz6n?kHjCR0t@GXwA)KHpA%aNxHS zBalk6n5QW2yeM9(%_CXIGEU*EtyernJptpADIAYg#9?M?7+Q`>x)^MW#Y=P%O+)uZ zV(kgTHLOcFDpwz(sXp2-%$lEyVcdEP9hNa4*~g0yO5B-=T9~$sAzoSIbIEP4)4!iH zW*87So+Dpje`07bXS*ejT`V&d*agjKYs+6>o6lF%9xy5$v^=8nuMIN0U3D?ETDR+b zNzrE1gf5*aY)k1JDK0L}U=MSD<p~h>8jOL(fd{)kn65`h1AlEu*D8Srot^ks*1Zjk*;3w8P*#;O<(U z-)+6u5NDAnd8;-vX*JKCd+n}Q_|QqX_oJmJW+f@^fzl*A-aOlQa^GjS{ov9(n6G0> z3+}U1JwSxezVM>+EMh+Q>!WCl;|5LD)j8<&L3CSjS2*Edwj0nVKAzZc@D_>2Xj2R3 zsy6Jk6$2J_ZVzW|3=?qB>Vw!+9Aas@%%Wb}xO@A&8DOI@NT5a*~F@F-|goxo>+^}vrKq=Jd&lK%%%~$9~7^z zI^kx$m;=&|Vv=x{n!*#?tuyx8nv-(XtO4m+>U5#P8FWVAir z5wX)c8G~?|xjCgr=b=@*yGh&oW5uBXqwVL>)XDfZ*1}^JS!TydImB+IS?AOE8yAep z(_0;#bvgcYpvwY@wo9D|HQ&89~yOntbnRr^GUCtJdXIe7s9^-1t ziU*a9=c!%O#k2?OgW5(ecA8^1#uq4nQtd}NCyjPE8?wN8m0DFj{9vtn`}Eu+R2MUf ziTO^jQf+|6G>|0-CM)bgN6rW)B*hPpFsX1pSe3S>T%Iyq&Rmnyq8xr5a&2zW=bl^b zOPg}5GzvwLR>=Vz?h$ou$Kz&%JlKOE6E)?p0CwEn6G1hB1VC-2S@%btT_eaif5^%&Y^9RLN zuZUo#3JguhUlY%6I+BF|tQR;bJQ&tbRAiscu?zOieO>1?o2gK@pJ}JI^K2#_2hs^g zG>Bc50zj85A5-~wmr5ho;|%5=>Pl7h+G!dw&I`jA(^QM%pC%#iMTtd;lWbMVnIKMy z?A00Q(~cQm!JG)iHW+Dc)*sG+YTYm_obD>?>>4J!w@#iD+Z+e4bTVfQ8)J&yrV0mh z*o_`X0wVaq0`U#TIL6VK2IAwv64|$EA<0QAi!s7M7}YKAvATl^-O6ga>w`qW!%&+q z-b%>i8#_RGFt@BYq2_(Ah@ouBDENu*)^zH?(ZvWgo#ZnEW-;2K|8l!JeOa3NTO zHLBFt!^NtGih*q%rRa`ey=n@GVR(sG(fW?yLjo^$v!R5KR&z~MBw!5WLcyYYL9hjjT(sp%ABj)fZ` z95z!qjlOdJ#?In=AoVePRcBZu&+!9JhoZpAQgu{AIlSP3dnAPVI28nqHB3V0KFaNP zX>;j46x|tvdV~rtgyjWo;kR`q@-tk{ZyE}waCEPU+K^^VV!yjgn%06p=|CS5c4Y-R zwhcieOXI4$6YNIz15lZf9lFQPGyE`!T+kJHy zBPH8V_hCikKm_X>U95&F^0fgM?*t7HH|V&9a%s8qMxde`t@4g#y7PuANm3aDsFSts z%XRRCudC}7sS*bRe*1IuMVyu2Mq6}JkQbafvJLW{QWuz)F7){rzS>-&V|;Z!-myn! z+aL_xJ4{pGIUJ2)Xgb=Uw2pf^B{z0~u9TM)L${-X@}yngOeTlums?d)WUzbDE>f%R2;vk)*E@QLX{B*o-%R=2odrF&vRg&JKV!x{_ zapI+14W)?)%6X_J@d|(#ToI?w1t(oKb=olz$FlZi=4Z@m4o?Lh$*w#Ujxs_daod;k zL87!2*sPr6kkHv3?)$h9?RAsGxC`^#1Zg1-_Ci?rZM^rFxj0xOvHi^Mt+@g6@q@Dh z&H+Z&$_^eX=^UTgJ)jfj3Be|fE6Dwu zo`~R$YG)XBMNTIu8F5xRn~t2hISjstc$;S*p`{0cXha?t^oa=p{Z&*w0UpQd#7eCD zD$;^^Tr&8pkGQYVQOS;?yQE-%`)bO+W=h3xuJn8mDn_F8pb`pZzs;EkBz8%f#T~yD z4{Kk{$880BSWn7Ob!c4*07WhiOP{HRCGQ^{*=^{7tIIFWPWBvHeHr?$7ZgGc)Q;00 zc__;dp4A&!H20<%RjXR8eU`sq+2gr~iIFg|7GIrdM`X-7tg&? z2~P|2FcjO~b}qgWF(BQ{NOQ~0<Om$H5f8We^xCR^f?d}= zyM=illh9gX-hEGe`oQt9s?ftUiz*;AnY?g1cO4sy6iNjKS<9}PRU2r*Hq+t{Q>Q%M z@5Vkx_Yeo#(FbEX>$Ig{x1vA-sp9QjB^uDvSu6$j+aMRkXV<*m0B2gUud37CeQ`B8 zjgLO9!P`0-{E~cbooi1DW+0j2mh79kF=}@npii@Yxni_m5YI^e9G)A^!>k3 zQj9nVZXT)W3n$n%bPR4#@>i8Vd;&Y)B-idU<4<;fJ`@8}KHW!OkWgEek<)Hh{o)aS zJRCVmW-*Yd^Yp2glTK+rWwlmG0G(m7GX_Vyza&HsKaojO7G6Z|yOEWCszf{t3{ucr z&|yh4E2?|rn!`Sf4SV%!G#+!1x0B#o#4=eTv*^R4?{@HYtBZT-X?0+2{($m($8Eh~ z?H}3r?+ISgyUf=kfg)xXh?9sxqu|2v=$fIkRl;pm8R~n1^)Usj54dYfD?!<(D8ck) zE$_Hmld~);7$-oH_ml0)x)j9WwzYQ25l|1?uLYR;0--h)w7`OIS6lI9jN_y8Qn0V4 z6j#AYSO?HBDhO}ct;-(ukzwp@Xva77p@F+2QADo|wHKAD#y(*kUNYwyF(iHlg2$8Xa``(PMWzs{- zlRu}vgvKJYy?C8C#OkRxX4|iP@uh}=ME?ezb$+?4e39O!^ZfeULfkTR@#Y8V*qq>2 z$)!-}Rs)ZTl?#tjVPNd8`;1{VM$E9Mlj{U>m-Y)tVF=nVn=@hTaJ3j6dVYmPwPa!1 zV>a%-1^<1>P(g^_?;4id9tfTS!iHOYmk3olZdk+h`31reFPBLYpQ@_riEJ73oKZoin6!L* zx@A>p*&`IK#ivH0Rp{pA3q)-ZJoAH{CH&>N>Z!=QMJ3=g*nimI?j-5z` z%>QHWE#soxx;J1!QY8cd2?3>BTBJsi?v_TnQM$vHt^sM3Zs{CAMQT8rp?g4bB!-^h zz0q?N&vTyt`}zI7&$r=b=H7d+z4o=%-g~WUtr%F|Uy%8l=g?Fm8##@J>lna}J&er2 z0r!PZ3w2hU2JheS=}?FXcc#Ahku6*^GHY}<-`8{Iw4!+M3gyxR72u#uW$|SH#M#GA zob$+BNb#A5`%@=6&7cM8;u-_Mr%+CfTZ#XEd{JZC-GF5pPFkkAMe8ayeyUZ~8zS2< zHy&ntW{Ip+SG)?J(0cj}&lC?BC?#RhLMvQzCy+H3rAd7Gw;z9NV@gg-j{PNOPShg<2lnZN3Bp%fln$uE=wE9Ztt!L+TTC$%T@fm z195D0uhQ|Afj`gHK`BtOHOJvYV&PsNuV|swFu{S#VO@9Doj>=XKLx=pR$?2lr~^wS z{We-@3e&=H0*gpWLGp59?|C-k4IB{Zt`5m zEZkj^qqbLB4PlS0-thO;-glNHdSC!ChFk)J4S8;2 z7&DrslLTddal5&SN&ux(nhf8B&Ta;2Mg}&0S;tF`XcD_mVJPIej8sWDWt%b(v~+r8 z+SNLio}Z$r0@-@^QK6)vQx7bZ#mEq)1{{%*+IiL@lpr9>f>Wnr{~9@tR~Nym#U_ln zW&0Jog}$(nhnXhL0isL2>495-gMdf~%nIZ-k2807c3v8b{b+josDec`%_ZEe>!kk+ zQaQlw+uPON6X*N`QW%&>_w~0c3Y6v?SJXDuRF!E&ZYc=&7KZy+L1}XXQ`#1_)B0r_ z3~)MjR0in(j+yLxj=7C83WyS3yxbW5Sh8FA=CeX&uKLZPDvd`WSnLSr>v<{PhsK*% zLb^^ZS9Eo=R9?icm-xr$xD>5+X5$t+tK(jx5}@GJH7b(i{D{NU>}xxbOR71JI4#lQ z7hlPfxWbPA@_BNHh~+eTc;HK#y2s#%Y4O6Ukh)X29bTnhaO**L#|%y)V~qJ1ku1f> z71}JJSB{Q9)>D&7+VZ zt6Z3bEmvf7kLqd?t2rg4)vIk)pSKFNHsv`}N#}6~nK=&o89?$g$*N+!NNK;p1DU3nfejX`Etk3L%4>lrgZrN<;OvaZM z!@lz(-HQvv?yBm$g-iy>?-0a3RZ z1bCx33j6t&U{F?;0$2>k-77l4Ip%fSQ^Gi%F#o#S9|GprRl`oF9N)s|mVf|Wd{!WW z3Byx?)2RHi7W3imB}{NxM|DZP|Ix0uj*P(luQ*`=hY2{01M%KHpJb^SWl#7JWs!V~ zoEvY_4;P_M3;&H6j3`_oYlTp>eeKwRi z`lsfi8_E0&-3V0Ko?ztfyK%e+?4}fXN+T=Dcv>dX4earvC?`U{G-9o<8A z&`U1pth+t26=WQmLn=_^QKs>|PO)z7k*O+s4#JfkxU5GmoM6pqJ9b}_Lb39eA!mgX z_;ar#0Tl(39iB0sIE6hil8>U^FZ>6K0x9cVwf`NaA&zv@G%P>hMfk8$k>Z2ts?Q_Vm;IT$?R>0H$nw0IIjYLZ??wd3#D5 zShp$aiCIW2d@b$*p|F+EQpCRAi4O?+hP$s&w=`17Y0|3%i`*nSW1^FG*YjOU>Y-)j z#=#(8gQ8IbIQW*c4z+mJchP9wJBAuG_veY_t8}hqaB2qDet+L!CBwIRCxO!OdR^y> zU_FoIt;1^YiF>!S?gTvc7hganHpXFf5=*=5(!P-s@1+i+Wao~8I+VrKxcB~$PaBdi1by?SN@%#T~^_xYJWae37>bV8VSB6cie|_^DbK#(2+yxMMpn8f#C6rq&b~1dl9rM`P|tRJC5O zK1M488>>q3zoG0_IM`V&*){#u5zH}zqUvJ@V>K>Sf> zP65S@!qPIHd%q&l`XS%0guep3TWvDg}Gy;)1Pb-)!{MLgFXdX z0mK1?hYW8vsh*tDu4VKnULfGU9TtX!4p&MgWAam>#fxSh<|Jv=W-1M&gbtUsasc;- znL!j=L3cb#RR&+q(Mhfi61r=6ttw<}M{z3fO?}Ts$z!TZ#vT(WtjWuh6s6quHBy(O zY#!ErH8SKl@O?!Ktq&u!P3^U;gE^99HG-x|p%%}@Gil(s17EjU*G9B1>(HHaAwvCa zPwb2!3`qeGd~mYwB$`<0e=NQ)F6Os*kyjclu2EZb`*8<)Xp9}{6`-H{952g9z&Pnw z@VnvV>%$n?{$n>8cB5!AAL-Sxp37%ml87{6!0m~}Z&TSK$vPUvus?vj3W z_`YHi-<3MX%hohwdC`;c*d+7(neMCyZcpAwYW08f+~L`C6V&D4aN0P|1KIC{b>Q|i zcHl_afdUK<_i7Of<1~pDvE-vMi7VF>2>-A20)razR;eb0f#h}RU z$Y;$3gFfE*r1q|>Knmc`hrhyaSXlKDkLr~Me6*Zggb~{a84?F}h397&PI1C5-Ue5B z<8NVvM*`?Q;m=KvV*dhVARO-Hh%dZFIX?<*+E0KYXIAOe*HP`3@4d^mA(XCqs^ybr zNlT!3VYw=bkgV~sQ6RLXROuV4CSI^BXTuQ*LMWhbpWQNIxhfjtixyQk&3psH#GG+4`a#-z@LCg!nl4M(mlYURH=x#E!e5 zaMKucPhB0vtp~!Ciwcb*z8|CPv3z>v!-ui%b*_fwsdZ;b&W7W!q6oNXMe>w4K+V+9 z^r=$N1yY#8&TJs3 z*r2&iaYXM?y)iYTu~)yaszm=z(%=T$jUveRR6TgFu;hDl0Zv)*?LAzV7W8=gMY|lh zhrFhucIwr|59m2^HEfIf8L9ZKeZDfP(CO^ey&62V&B=i8cItu6sh!8`U-Q+$nSXvsis1% zjhr{!sE!X(PW2Uu+%U;dO_zYH^e=IUjg&~R7EYS(ylF$)X zzwM?E3dn+B@zMLz4R3R&#}+&Iv|pQ<&FQ0V;;TedmJE~xMENK38sVM~0J%?o8#C72 zcw7T0sHJO@v;osli$6gd&1sd`Q>bv)!o%g4K6XZNC`FN77G7BpeYlJK6q=%{&v`dG zWt?G6x&lrnS{2BzNW`veHOqH7fXZ_6v3sO&QJ2DInk7}Em>0cw2n~zKlZc?<`hEpT z(dCYH>ykQ|rx88Q)$dQ9F0rwgY!t6=kJ_PjcDmyevu(+7oFV=WA$kD=#By%I550T8 zrBJQOB<=wH|4vZj8lUK}zL|X3ZuJ=I7u%bLo8gHy1#^ z6QT$Mn-wlj8sFrjn`Tpru<7GbOoF*kyQW6w z%_P+v-&<4gyTTKAc}AH8qig2w>7kc|3wePccB-L`f?35vaBPX1bN-Dki%R7PpSjs% z7`wYsa>RWF<@}<9wb$?V-&O_Y=ZrZUWbvp7i(u?F8yBPRkKli+P1>+SzD)c$-Bl7P zAGNm(6j#e5P3jp}(EotR(ot+hzi0F?#EydH;qj)$1a~-iUrB)onO2|`>1{tW?7mXE z=Ij>pxup#Re%=7y8(f-ddeB_)`O)zM#MfpB#3?H4#Ys(DgBZa03bMiEm3+!q=~Nb9 z6Lj@0&Cd473w@XEyV#e3^Ke?a1Q?uvr*6$KFqj#GhwJYL0rl#IxN;_Iz)~y?A;-;j%of<^!BF*!|r>a z?dbFQU^PL@ujTPos91Q@uJev94wc5vG=DbOY4~U)dtb5(@5@!DJ^jL)FP7a)y+>x? zjMD>^Avl*?PdSS1hM68v!4h#*1_z0*C)9no@&OWEAf(6TXYDPOFYTHc=LhOZyS;ng z1Psy3YommH-f5z|HpJ4-{&4{P z4ai~(EAbq%=f{lAvDB5g`0_OP4CpHWm4h0FM{~~#h=TGvCJ05cbal; zCCn8OcBM1jAu-xQ$gC^V{_PDY3J4wT&g|?l`1t=@WwE@WIT&tC=n?WEq?E6QL zL!3zSxvpX0E9`mVGBXk19v3$oxbfC-7X?+4Op(eDbstY?87VgKm5(gB^g-7ZvztPz z8UUS>ez?mNGlh&`;_kANdihCInBU3VCwc6B4*a4tJ(3fC{4S5n7F_v}Y{nOZ`8pRI zR^tVoqK(HtS|pZcDVtb)?L(>-MerZ!gDrnc9-sd4&aP_tW{S4NaBW+bZ)?_x4y$>q zg_kfoiyftqI8r6_MYil&vyo^Qj8(csu=hLeP5q4iDLUfI_ zgHdamki2!+Q6?28kW*1<;^=Er_~7J`;r*gzYQP*^CdOh`#*L1>kFcK^F2BZq>)#$!hvvf{sBxq;r^XFRD(N)%&-Srh?t^~ zB|3u*Njj0=QQ0K&EjQk-$4%$oCv>`|I8zbUl6B%#8!(q8ADh_a&g(~MSCL(6^r9*b z2;KGdAr#<%_K))OWT=J~1sti)t zOhVQlzTaH!1m&y<=9mOz&&%njM0)WHzn&Yq?%f+lsK%tj;!jh!ad+{frF|}L!JVz3 zfK<(=u}u;?7r6=r4;PQ3OR2025##Ta8+^a!iV}4(J$uU5TidGE<#aq0zb24JJ>2Kd zH7I`%AfCGnz*x1{^HqKVrPY$l5Y8cgOv|D;*{5RxzU|Y!1}wCV9@!>;fuVA7*hHiEPTlt1DgK`J z9dU{HGS&yd0SP*iePyi8Eq2KIdM8x+MAed2Aw26h0UcvRkf*7J%(|s74l~^I^YNR^ ztNN;*9OAzDCAr=+r_8vnfu(ESGYR<`2z|Fkx3Dn7{J6FDi4!cb`X!y_gFuFtlcWyz z)AcgG_0uj)4A-mQZArpGb(Z9HU#Fi}9Z9tV@el6w5c8#JaBx_f8?0>CLvU=BzB$_3 zxU*!NE>2sFq4`bh)LNxioX6BoV!$a*BBAhMTq>`!Lk8@rgSs&>ej8G}_-WCagp$EE zxjxUb-i?_20EXbu^rGqg=W&)_0_wj6M)}*V^Z6g$r1VeLG7wyhej&^C^l`4P{3wgI z)KGfS-DXJR&W>aml{EA51ZraUQ-9koRB6pl`g;HFTd!WZjLIfobcN0haW8uNE=Z~W z-XV@rjhK9kSMzk)?13)y6IQYonu{8-x=q^=qyI9^Jlb+?2bS`+FUAbP^JQ zs>R=>R;(kwFul~!Y$}OD5E5*bdjoOH)ubQLe8V1&@0aMYfTdyhVir~&!mB@UVD^xO z;VT+8*0+oMH0B;C2KhV)YcH=RpRuu3;0JdWp{y2zSf-(KY_zqZ7Y zQ{KlNN|`)0Jdcak)fxtO*O#<82IHYbvy6u%D|SSvoWDyL0Z||y@vjGWMo^{(6s)Y~ zZZ8N=9AG^f54

_!^|HM!ew41k^J59P4qH4;@{|PW9nOies#$&VJ+uv>(7>F8 zZM;EZ5wm9B^dwx!6tVK@*7sJt@(6ZyQUlsusMZXJzvnv*Ve+Fw9geQv=nb>F^!2eP zZsVgj;Db4Fa500&nh6xnYO95+*=qQkIh}3m`del7hu;#8(+~1m)0XuTcw^RXB(i(v zjTC<3PhD1^gk5b!fXGo_B=*@gXX=8NX~Z~W`@gxNjm(%I9SHCea{9{Tmy_@d{QO6*Wo3X}=v zd{#Jp0r^@r#frm&$8gtCJB95n(sHL%*BZSa*0>T|KS1}5$K^a8#$a_GM~Gp>0JYSR zEcBz#f+${aXB4AerzSlUljZZqJ+#VNB7D~sf5_kENIFF_x@i|2or!_GUlQJl*AWO?;(lIJtwyiv?d}G)TW)$EbZxSy|L8w`9K@JnE^x&#Zi76ou4Ua7u0W zm9I)N8OoMoWx2!MH6l@Go**G+n|+Ak;;HOjg_QCru7FOZ&YwQ{V)cqfQFrHL*+H5R zzr4PBC3EQ2p7eCKmbNFg-oS@BzQ9a{1i24NC2QVIyzV83h>BPyx&pD2(RVSQBmHNM zq9b9w%|~$S@==#-36a_ps9TO+z4zhPyZSwIt8dz-C}ccFn!W_msXy+0oM=|7X%@ym&@@^!DQg_Ab&$iQK7hv&#k)CDk&4|p%%5MdMu(03G3qGxlW*x^dWv93stC!XKC-w{dn9n%KYCLk&Fyl01b} zj<%OUX7;iRI%H~`)qaAP|xj}RApr;#@ix*y_s-&w&bDe>j6|-&KkjC znG*Lh%3%_hm01_8Bh^2Ao8*#Z7SL}hQrb|%+rgPNK`mZICcm)5Lu6|?2o4L{^iDXf zpPB8zVNo51)Yj+#IC0RERBmcq+`awnbaC-ZQgux}t0ce0gNiPuV$IwN$}NXSJ31wM z0ghIsVDiw53Y#NSTkA8jsWeQ~mow)u?c78=uU$q^GN>hSG7N^#JuikB3AT!yfO$oP z1*)qvOkoMJobi*%Fuj^al_wvt)4H8g7*AouISfR_LL)$^1PI7O!+C%0qIWlDEVt2V zrs(au-QWO|b`Zbq{glgcK?8Q=cok{kakJCIR+r})l_$!~+qHmwkt88Mrb7j)i=#B` zXutfz1iAH?9o%7QS4pH}XkOHH#dHI^VkK(w#)-ijh9K9I$vObl|4!_BZ5^Ch^%coy zpFGHa`>^dIYW!sU;g;E|J(ltZe>oM~g4)M@(xgii@Z1x`hsJhzgWp3Q$ae~nyrw+X znWe7I^cxNnVml^}qtS~g4b4*=G#kgVN!4W~tj$uIM`skgdQSGRSaUe9jnV>YR!6T^Ik5l$S@LxN!zADP#PF@~o z{~p)YEYaJCM~f1XByX=I#gX~pbwr}c2b&K%N*FT^1Cxau6_8*S@&y0wP8Ld%6amcG zFD^t&!p9V4qv>7_gA3BtJAxZs3-OLTT|6HQb6kd1XACqQASq0LYxM=p4e8mbSI0L7 zR}B*=8JO{vaGJFZQV6cAT~%fmVJf~Q&SC!~A(Y$Cb@@FXs5=#iOZmRF*hgYE7$|eetlK}y_yLFDy#!1GGH7DzbQvK-3>G7y% zn=a41Pa;Z|Ee~qjdLl#FeF=tN>R@Rydy}e~c0=JRB40jMo3^hrY8%pwT*Z2mDK;dTH{0y3PpmNxz+QSqU}E@&4^`EzcJ3 zs*1g2iLvD+ZV9(MD>)wxb7h_Vlt5!X5ajq`_6A=vFSGten45Sr4EdF8V%WXivyeKa zO7_xjPFqFT-Ec>9MOPgUiDtzy&-aavx2Be>*-iH98hK!O4Jop#IPA-FD*EGf;IHE- z|A7iV$xRQvk+tTP0v+g^izl?Ug#_13A&#iD!)GO)<<7docNfJc)cj`)D#`~WBu3(f z*{W6^vn;sUpIkt;A^Bp&TQ)0gg)(`_8is3D*@xVb!?GoEF|MKxiOXPNZCzt<(wMEi zl~b4omp^8BVQ*O;&Ye8wOs*1ds7>cxaNRkiimHriRrdU zytf9n#gAurIbh|Fa*xcy$g631Po8o%mck2w+AyFn{M%pb!yJhbON~!VJ_1OF)R}W< z#Ad|X4-32IhNb>W`Dt9~_{QGlXAfBl^nmESamA;x2!-r6XPDa4SZ!rxG0jI+w62AS>kc$JzMuRd>4<7?>P42n}qd)vy$w8bFTVAePl z##!46rrR&&W10Qgg9n$h9dAe#wR4lh4Bh&rsih3lhsCf`lp{DJ6M`kVy7r$GcUx!+ zG~2n)zDVt28{`u_e7FL=5kBb0X?69NJM=4X?PqvAhy(B!sxc$AuiBJi0!$yG%>Kv5 zA5gKN+2I?a9)`8HgE>Q{Faq5G^8&p(<|RLTr6vwbLL2Ei#RyvQqhcTpS*P;-6&-?S zEe0--@S~KIF&*jQVWYm&6(f76YJDg0rjn#JWSB48C$CxCv2nmhMDdTgI4_?2XLMf$ zG;25ezG8DX9n9Bcg$A4Od=G2?4rJqTK7{zVv%-ADG!>$HEm|#f@s%XFf;)RiSZ|On zuBMF{ZJQN@C2<0|?55yl%(R-+mVt?3i`>XnSdo$eHwF00sCE?VdRYwyrE2?JUXYlkm%UqUWIksrUnO?TV0=J8Wymh?LwWd9C_~t=F9{x zr<8hfbCkh02X&9Gm{k`gUi&ZVO<#r`L)vh>3()v>V|78Hy^0D7KGIM9h2L@!-QMu& z+%Jg}EYHX=bq-p?O4-n&PLC2&i3We-)pvb?#nQ~dAiIw>iN`0Sol%)Cgs9eK&&h3| zD(_)OFMSswP54Gf7TMQiDQqx(OL>sWj^d7vN70l>))&6W=LHv$nhJ{R01wMRSnejj zAG*HovzoU^uRSl%-(hy=C;NvMaAHli>vECD0+tq^Iipi6|1>5grSTp3qrC9M1-3O( z$~mua(RWpm15M6~-lYl`hOhG;lCqUnee7Hyd3#b8melxS*22C^Hs=$*TDc!fXZ6}gc*Cv5ZPpX z>{i-po_vXOq!Qv@cgUkJd`lO#3laP>0!`-8dv7aC^>UHOIgM(v(7b9zYVjyR|FM1a z?)g);B4-E$MZ9U)SP{X@#b)%nqlXztr}(Kxh2`be8!S>yIQl)-b(4v5OXyfI zIoC%0{gFdD+X;!f-WX)bB{w6-of@+x6ghOcF5x z84?+DtkF>*X~*7DVDTBmci(uZoJm3c0zVJ11#hfeG1d#H(@WFIqReEp77!FfDV2nJ z=aIo%Q3djy`NRF24`gK8c|K|6=G0Xh9X+lZXqqf&oJj~c@YK_>shSi;(bbI~tF9jD z?H#_-9a|+t?i+8ex!cv7qdbSgasA+r{wPXvo`YS7@Mx9hmX}>mwA=8 zRE%Q*I~U~h%ak48?hQ|{{?Wy3kIsO?UJ?%KUKHm(GjcL6CFLYqX-@y<;SQ!=F4#LwE^F3;qnN}8i7U8Kd!bv@ecyIVDqT_U zT#1`Mq283aMUb^eOHPU&1KXl&xQ9f*ubQAfjpD`K1So5N^MiM^1^={B=M_@&talg6 zt_MFL83pE9lP|`_NOaA$YIntVqe#{5{8ihZBMh!RgY}x^h?fk+0m1L2UX2I~2}OWo zh+Z}CRRv2;VUaE>p^Y!1PJ+$AD#bm z_KXAa^790s>ZJ@wM&oO|?h6tJF%Rb9eg4j4$@1w)##-;hMZ-B!&(`=61<`=3Wdm&2 z{}95T^K%~%2_@eRj$1&TIKG%|u9cN=lJ661rR_1xgD+pcY!CAz$(rQapW{v_WQ}r% zba{9~2>0NDiVZ|q4J7{!56{}8-v)-t;H*S|*9r;3I+g&hi4aDC7BmXKcJRGgWLt%m zrhn#F1qcaD@{5bPqAK%UB-iV@cj}6q4G}JNVgSw9Qk}-g9dC5Fbs8uQdRLI})j}d@ zJLbRZ2nN=B9w1KfXldv*$na7Jl7>h=!zD`qohw7!mqj|r*sBxkHVh=G>QgEoB9KU= zxaDDHIoeuAg5d(2r#aP_ubrJ;y+WEnRz$Oc+Ky>J0NM{RQ)70P^s|^^pGMjw?JWUe!fVe~qyXk1_KTf? zc3q>LfL~fzIp!d_Qx#DO*QWIEtYY!MS$3WT=g*ZCECi^^SQ~ZF>ebiQ7?g*#%HyXC zHoNyQBP9XR_-0~B1=?z-8#ZjK>OkfGs%rXgiWfXeY#IU^9VGZ|*GsfvqI~Vd?0UP$eKA zPOO)NH^$vg4z`|pkfGsI&bhiQOc|E*j7;p%e zwV1mOPz#~lp<$eVF3LZg+u*kVODm;j^0PKzCv+RrMZAm0;u`!jA7riEbcBKD|LAmO zD#&F*Te%023TO?RQSMM0(J#5;YlI?Z04VX4Z6T|{BJM#TBuKlGJ|C8FE zs}S^Gbj|cu#!A85gL38UL{4V>^Xl}J_?vDc8`8pK>Ru2Z-ktKc>XsNLMW2#~W%Fn8 zF?(yH(^{2;=YK)``Z9*m3U$~^g$x%rLxHz4=j+XV#)Ry|Y>M@Z89B;D%y|q5U_B*~ zQ&c=w()s2G2kS0%EJSDMF!TR&RU2a}D*#2IcLRq79Jk*l)ELuaKqKRV9yw&kcpy=~5HjlfAo)uXco?xcG%zS<=ge^?h1$2jT8t^}w8iKdr!x;&L47O9C@P zLPg|O2wLrbLhbk)(8{8OC~zd{SCeLu%yzHqUDCkI>e!Ngf^%5>o+HCn#$QDwZEpg` zvY#p+#8-dvMB4zo*7B0ZpvHXr;(9?pk0WaH)A3Pv6ydig!}wI8Kh`toE%v3{z?kTi zl2dhNUw*Vd@zOlo-|{n4GX023;H2F8^zx*#dy(3mD<3pyWT?Z~R(-YSSL848Yk!Oc zfIlQ@4J93W>?o}7d&`jWxF_d@Bh&38c(G(u#e-9q@&MG^lFIRFyU=DIeut7063MFJ zx)?&aYhX};}e2YrnO@#2TMeR zrw9_ibY{ldIH)lCPvi7j4?{++Z9V5r_)D&o$>l(VSN_TCo*YT0t#!XQHlAVO@l_7e zQ;D$;UEeg;?B4uA_f9W{=~Axp42x~1AG{VVJ=5@f*23!{+mHYKLtW{E0SsmCYa^^G zbe`0`tvizHyRegdHx0bnb)_mru5=$li(8{$%IDh?-ThQqka9S>By#(Qe?p>ZT3R^w zJ(tLM?Co1fF6^9={8pDrV*pgw2uO3Dd(v%sD&4i8G~eFq2q9z1afehde0iDA&?29^Ut(Ek778J!L6bq-)fZR|9E6Y2i}@xS_o&kgu-A3ZPB zpCkAGw{L<3fHOE5&E)$37Yifz7_hzgO&9zAsHCeK&ELTvzdC>Z>%_`H!~H`!+~-!#zcmg>5FqJ8TyXnY7wHc)IWO>Fo3p6B93l7L zS@QqdZqzK`?2!85W*ndI&2MMu*QW<(3|0bF`M>X||Dk|C{|v^W01h~2MK4VKACBEw zuj!M3hBNb(js9QSWvm4>0c!^1o5Xqa`j@fvUjv*UWyjV3Qvrc?KLVP-{67`^Pig*7 z1^*2>fM@?7P{F8_SyV2tgo$qk*G&5qCihrT=dJn3JTJ(2_!Cg(?}O0fo6|MUGcR#z zy)q=YsgxN06N7{C&VuA_-~Pf7WrOM5xFwUjySsZDKfCDvX2kR8r&$gHw_sBkKDIgB zh7%FeN%#e8)1G4#_#3l=A6x}+fYl%=;1)4ca9CJavrUpmsg|dbOjuFea(kwh;PB5i zOdN~3z5o5zq3<0vDq-iba!c5>&ss6v7Yixd|12j%Ps{|sr25kwDlC$Fre8wHC=?_S z;EQF$;o;%BlL5yYq9pHTcF(A10W1u}gEMVP#{J z@5C5|W3en)RrIT!{Vtdluj7sAX>wB1(dnY|Vg{?0EZGlSdvpyrjV}e~gfQJUIK4wEPBwM*MiCwvH4py<)==q~} z``jjY;ENmYR>mmMF&8YOf-L?6p@B)e!&_Wvg~dXlvMDO4?xQSuPDfrpZ+T0ZES$HP zC8)7?rzDve|54ZPpp3taPw)XnpTnUHi$Fq?5L#4<=VN<_BWljtE-STqXE@QSzEPcz&LArVw7RNd*+H9kUbo!QuU{ zR_KR(fvx}+;dCO3_Sf6b3FX`~Vqw4(Em&#(oXg*H^B-_hdUk3u}ywyywg7KeleC~Z0FrSy1_mv;ErlGC z%#+B zX}9~(;$aNyM2xsHOgpJmj5E~vY(&!ml|L)s{(_$$ZPUA)jmTQD^T&wr+0~5lUmhWR z3M};c1_LErS_>~6-)nRd8UICBdCn3M+X7Z4nmotvhilSGDyLHw>|S5N@WF2}L=kAS zcG5xMU!}N>*%@8>lqw%AQs zP9)!U-Fp_b^6)R0>kll=@CRhzFf)-b{X+XK|fto_&_DTumAER+g2<$ zqX{h?Ay0$QOEd~41V>3ZY`US+_n1G>Vd2Yo{QW{;*LDd=4;_@KQH8|}6ii-I4zKc7 zy(X9z7%mhv1Ej$Gs9d9oS;J$;x#8u9$gY2dm!3>}T}+z3?aU$`;JgQ_hyd`l#d6zt zkg&=7K_ESRu$)q-m`5(Mf)rjH0*LpA(nN5+l zk%l3=K^;~36jqXg4govE7gUlg7BQY-#zPqYo}=#Pm>cZkkj%R$ZbZnE99!k!1kl%q z6puyhcx>z(I(8gb(v#Du#ANBK&w8}C_s;!CkDjnUHn4VFk}wMNTv&B4omh?7_4Lft zg)NRz7zdnSC{y>%sx0sxVY+x&$_Ut5O1^%{=YDRofid-9Z|WCImc478cCgAUi-GSq z2oar1_bTcL^!5~bk$tBTp)B>!n8IT$2W>7$=Vd-U%yrv!@cvtKvWdJm0z@3PQP z5gctQy!Q-iV%Ck~hc*UZC%N793}=F-sRD;X2K|5p4=zp?LWKCNHuSZ~HMeA01oAX? zGn=kdNxx(*-NJ4h+&*RdSIL_*|DyWI&r8-|EYewAD+kBN$r>V#{kQg>RjcKy{G3`6 zEfCDnGj25XBkchtf1zPZl9rv%$Wf(=EuA~$19YC6M+Xr(RLOwPE?;x?4jb{jFS}P0 zj>t!CCfg(z>}GEJ>zGLUA)}_8?nC6V-~!Wx62njac_0M@Z_n3mqAD)wZznAHHolf_ z0b=oGK4-|UBSJGRkQvRp=@@WkNptBUVDQA@mkFnpJ%mf~2IO6Q zw+~)x8Hi(A^W$!kA|pI`IOj2ef(htH zq|p1bx=;#zTK`fXuo4$T*4$_M3ci+vR`pimULW0AF~$u=dN{k_pbysJBcvK^O~S@R zJVzMNHjv-hsZj5ROyOTL0d67X8`eqn%kCEbK6`%M0t4qqPKhsnPUS-|wI_@+5aT6Z z&|S3Svdqu9p~~IW>sX$x?HvzJ3-Cjoyyw2Lc$7A>rPxb$M%oGNLDezP^U`q%pMd+b zX>2zm;Q$+7^r(kz5;+A$K|;0tz#e0y<7`}Y`f5B4Xz!Y6aiE)Xme?8#lk&80x1RAnBK{RX_D^ zd(S_wjTU7G@N1X6bU^r}mEH(X-D!(2da`;n%;wUU-V9Bs1&z?XU|@bDB|vR53J_SjrN_ct}cByXJBVqpjq#TY6>F32+hz5{B+V!WYXv^9ov+^lnBlE1%k13H9lRAIerGQE$TeYZG%`x82o zC2eBUgAiseM?RNlxQG4b!Tw3(d<#ktOy+ra)$Yh(gJ??BQ-9J^4V@l$_t+@?SeIjh z%pAevxK~g`j?r~xB|nWR^MW1bHy6;o)9O*8D+q;Ls%m@GOEv=8!qV7{nfaFa5Hjdu z1*at{ds{F5>bqV()z4}-EFfP^v~*6P=o`s&8qDd?HftA|f`Zz`_pZhrs{t#godJHW z6~;jIuOEJ5P)*PiHmBlgGpy*VrUFg4j$-aSXdwJmA1FC7{?Im1X@Jv7MB!;%I7wEe zUYvayZ6{tOQE;$=sK9G=Z{9jyy14#0qBI9e7PZzz^7ra^^idsv?IZPG8}!5?R&$x1 z&@s+!+c>frcB{B}pz}b`y#&o6yy<70pW0jMXRSAk6!xGiu}$zd153W$9jkZ3lJWE@ zjZNAG^9ssaBit4;PP;a6(G_Jy>t*0vav#EEhcrp~4UvcZPgKXo-^d(AAfeVKUf#`t z{gs>T$;+2Fw8d(~D`^c%EiE4vZ5`rPj1bj&3|v^Nk}@#Ea+#hv84eVR11sB7>I-x5 z%WKn$NR*ea??kr&nE*3j)J;i;V=05?X7W(kw$)*Tjf!==%iW4p7vUpYEPK~*mYfc&*MfmS+N&S@PUMXO?RE+qJaY9T^19W}6278=gs+zxL~HcK z%b0CfWS;PvtEY$#{&XZf7-vNsABnD#8=Zlt-(|U3M)TnuaT&FN!{OEPI(Ze@(0=JA z#XA*4b4p#@922Ko)5uU`@mQ*(iUD0Px*-F5MIynb;oWm zZTBl_F)Bj_*1+v!4Ua}zTGFvVS)~vjSbKN1!T$BmGJ0ct2_>ZsA|Ko_p_Utc?<_I+ zFb|Z+(uF(UP*vAU1w4zL#vZyeum}LyD|i1+@HF%nU--MrO0gjLyzkCknDw4ZI>p%g z4+X1E3>4q!;583Hn17=`uw;w@?S_E7fZ(4E15+U3vv^#~7K_>5fV6{GbKK>&x!K`( z9U_tIvZ{WPdiNXC4q78g=eZEFqyBJ9zK{xJP5E%RE0MGQ9SD+14@}(aShK3>kX1T@ zgvQHf7>U|Q^0Euj6thpvzpdU*#g=u04827N%o_MLH)C#Ebz2&8vatJU>3Gm*lCkIu zAmVsKcE4|LSM4wyczcw~yy73cvo*iF-`@+baJ1D+JygfI7 z=<3y-YRHz79YU0rC{S=kBP(DpS$634c6m8v>LHks*K6zR)<7g^g_85+zWJ8Ta_63P|D_> z*%1*M1v({?8<%v&KgRPLSuKgMCd@@47TDVAWg1E}Ry)8hJq@PNkoJ={{E!Lo-9nvw zrA(BIzTHBU(0cO|h}Ib8SC1O$B`S#_gTY&Xt4b@Jyglt4zCq5#k?1I!oTDY1D74DC zf1LA5V|c#XL6n^g{|@E zf_In@Bu}eefZ6plzgN^;&}8FM#%NSU>--*9d?IAA=47l~T;)VOin3VaRR`FhL{voC zug{;%bpj#Y6}q$>*HDIN{pLyJc^uaM@St(aL6x-^U+v}lw!46-_rxsS98Q1iz!r=6 z7~Nbv2|j#V!sDer*f#pvC^_sz?D71BUhQQG?df`dqnvNDOQrpHBU33i+2`vv=Bn{z zy-!D1I8_cS9qjIOm2-c_^QYaW<_Q_zhw&crnm=!wSaY1qZBP)sG0DeQjuJJH(d2d* zLiXQal%ouOCd#5}{IJnvYWTa8m&|kFeK~Deq28G2rC3^rw66d&)sKCqO)+RdT%1Rn zX|J@qE3xeHvSLiYv$1l}U;sCa^wciaWe@RQyPRTi&vRV3F83$Z|OQm9^t-Z|A^UHs)528baaY?rS+rKl*%F3qZ zu1w9HJ0~{Wd*Rm1mEy>q14$cJ&fHteEpAlYWaZuiaUqtXA}TIKLFD27-oNKx{_A(@g?$HN1j1{$LsO~|NMnG{F8yt z0KpQV3MFRXBSi$>PJri_6Q&~`-~-aa%zV&FrQ+L4>*Ug+3BMLpKYHDdjS|_Tw8?3q z%BxjdvN>7F-m2>Jxg^f#^q1kKFDqhs^E}#Yu=+K+@7Id+EVDt0fC99d_w{(8Fy%YH z$@KLWC2V!S3P>}x_1CHU>}BYMm0FPs-m!+d2$qMxHz=U*?a^#Hn!i-$EWdc}&*$hz zmj=(l#osO!ncDdpZ=24BoIMqeTa+M8&O?H8IXa1j=95&1ckpCJp|xod*{&I%pApgq z_K#X_U~!?b;G?}0d&JV6PfmZ=K1Je#WV!fzRX-1qw@=u0paSOdC>($6t{ zng52AV<>X!^|RnfIw)(`PT2!K&nDMtW8UVkm8u=*)Z=FBowO;9W4e*CARkPlv>AA@ zK^!haSu700p+%v8Gpz7a-0JDK7D@wmC~ZGsXXdBNDAEts*E0{v<2uW5?>Z%~`sy`{ z^qIjp-mU4aatq)Y(O`vL@|{m#la`idAQcEtKqJ9giT#rM#*giaawpx2lG6xO^&iCg ztiL+QOTc@gS3YHCjVCoK995Mvn3~f8=}jMQY9WxZUaD#xq9L(Pa$?@Dsv0FMOhug{ zEVungA<{OOFkVlPL*d!+2p{ruX2(Cj&yoXs(`PNXMTxZQ<3^=K2f>iuA#0I*5sUt{ zFRnGZz(!!N%+pu#!J2Sqsf zm8AKurj4IpX8yq(jSc<4o0jUeL&ADdJ=XmC0czXV5#9dteDO{uU7mKMgTniO2~kQAiTm1uq(4wZvAbOdq?{wa`?jA%RSK^pZ;f@E(4=v) zV2zl!#^_?ZM)`c~P4Slh(^aV5IhXUnDtW4%%4yA-S$SI9;hRy!6qp!v;6eS|!5@SW zeBV?_a2}}JDEjK8YfBvEnhB&Xx2XKugVV$nEa{dab6_A@H<(Vg5D~BAJw0}t=RF#Y zWE(w52XGB)esS7}Pb*A}t!KJik!O?wtd-0NjotFQyF$ltEIynyKb@H)`n_mH;3C~8 zo3zHdl+bD4a}C-|860{a>|l>Mdz28nR zysgKYz*|%4aGLD}T3MnYpL9eUvI$0xU-u^wURk=0D&?{s3Pzl-$UM5EpC~PHwk@-g zSGuz_bWDIS{NsROz`Xf6q|q@G{2f8^9sF6p;@@q5+7}jtzw z>xCIEyf=NZ*dBrt0ahM$|NOuV`(@=FCW6n~ZzzSfD+X%Iuf@=b;JPgZ7=0G<1p_$; z-N}P-3tO`{MgD~DVKx~^ptJv0O?K&fntAEe$4l-sD_lplnA}B!rZS_|#@RP*2c&FP z-7G<_3jCadhH;Qr9>=1^?!w`Y4x>dDw9>N_AxjR1LVWwijB~}JlEr|dsD|6{tDI>o zkMU8df@~3mq4vJ%wjUqt*eG`(R&)utvz)9dmwO4EG2d-6MNKV>Q&Nu=)K(Mkf()wF zU)QUj6;B-f@YC^^C$c&${BeVJeB?Tl|Jti(bJy;Ff)9 z>S^JPoXc`=mvFWJf}hOEAD7%d{>xzsaFb9@Rle zcsQBwP9E!gICI*(4-t}^KS(W2kdIHg`NDcXI0(;XB^`^mZyRJelw?JOHB*-4d?rWz zgPralX}y(-YQ7bx*1)J3ynS-E93MVQH}wT>uGU8UmbybGIwgkb3P zj069<+>nr9yK&fD*PSKQO>s5`Ze znFsUU@L4G&ln zw=MEzbwB-xar`AEjvC?QnVKzes^MK2&1jq6Xj*%vNlz5>%kKpelm2Vr)b3w+-1e`t zezZ__F3=U{>dwddcu}{!$!5f8*l@Sq&%1UIJ<5ga7_ow&D?yO+X*#rUlP}64` zuIGagx~d6G==b}95t!tOE=*4lRlXJQmZY=~MHL^H{f{2-fesVc78wBGd%mA6Y(6=@ z`Bd>CpXr1Kg_XHeBj0JOgMBmTQB*QF!=)GU7$+@qTUWpnEZ!b{W2}_RaV*Wv_UWF?If;2Yfm0k^2&KO+vaTj=ABOC=pkiK zZ0mf0WT9>{?KFbqnkuD#+`4GOGfA|^scI}&&8M?|#W&G!+Otz}dUEUvZnhW3EdGGo zfWrnGveh#dJdnX^fS~k_dwTmNkOV=Z#=Cn&x8=}S!zvRuyR)rvm2>(*x;zK_9x-ma zbC+DrJUGBn6;&WuT4V2*SrT`Fy5EbQVNK{cXw71@@VVMar5l5GO50e2RqBWT{wNtQ zG|9v_?!1Zd(Ei^k^oi-rauGs{CqI_yU51xaG=56gBhSP4#{_ocL3)Q#zaJHlUl(m- z$g{)s64^DCQt~Ad)3Q=62%9S1Q`$a=*ohC94|Q*A-TD-}Qp-WyD`phR2h_R`|7xKw z!i6!S9Yz}Y#o>P_p~>`4Av9=09~}|afokM09lUkmB7#iTx9_4CJ4d~o-lB3)2~qdG zuzR{CNwR=vhi`@1!i$<(o8s#03lCt$o8a!Z@(F4=EJRri{GufX}F_NFSu zKtKU@rmf_sEvn71a^30J4}mn9`9+N}JlQ7n$FU@6T;-i#She7-|Bj|F-NVh8q$kX?)7N9BSF`y|SBphJ zlXf<;c{#1HMH+b%v+Pc| zXj?5U!wTD)f{H@BLTg$NS_cWO@MvqS9K=$5()6Aw**Z6A>D6YQTkODQ)fI)A?`kpc zEl;-ppr`)r<-AQF*h@!A-Ka?Utd?@lyMs8L@R5Z#0>&teeXotaVCLH2aWwU5p!`PV z!Rb{tENc%i@a5#5#EVb*?S|!WaQyR1P^;YU?_xmdt4sNiwCSv+mGUIPfyRq0Pny%DUf7`8!i(|3ucP@5 z=kh$-U|Hkn5X+)m*|9n<^G2Wh>RL-RX`fE6gd%0?>)~NqQ9Y1k z@G{ak{nmLq?R62xP0rBU->PPzKMr@IwBI#gzI;}C?4IJ>UTUA>Mbt2kFj>Zdk!|rZ zMBZ%F;-6d(qIJ5v)Nq=M8yNOx1dZ8tVH6xr<8)^}50a3%z3Sl76y81WL+hKVCWWGh z_cWBmvO4R?il6Q?h~GF7Ta-#QG0{pNnSFRC-QCX6c`1|^0A`Farx zUsv`SoksU!*LEAh*;BIcpti*$&MmJ4&0|sf03Z7`a%FgadXL88M68Qq?*tpOlfR$IR*0fsg8=fQv+8Nf2Z3t?- z_OsO~aC5OSmw#G53eJ0Ef^8l5u=`IW`qJXXL7A@4M2ei2z{cqZ*Gb_EW<85dN#8!3 zt43>)U->2LRk=038H00bQoWbDrK{4yO48%Uw%vz@A>-0pL;HHfzIk58@WjU;$3pBG zbEjK$hEvTtKcX(1`!T>2mFecUIq8@*TW5oa<*ht3$UIyZovsixCuw@tTjtH;$wRUrG2J>~Dh(L*betb$8hi}=aWr~9y<|&n@i~5cW#-Z+D3I#qy0j8$5a)E(6%hk z9LE}sg}a1*W$ARQxJKb^Fqc7_nC(^q{h%GZJLRW??X4jEVMyJhKz`Gcl6VL4 z>ig8&gI8hL7txaL4alwfY9!2tb7^1HrY&OU!6-^B&%!gLS>5{6MY{?7%5P?jDdL=E z!{p{aGq}J6kR!cQ7EcxYpSI#UtL0-{5?0(|5*|>D5LyN+azyGJ|AqM+s89wM)6=Z0J?je&fLmQ35B&A$sg3aZWJdWD zhuV=l=HuUjN^w(>8n3rgedVt{DxY(kz)NNMWlX!&jOtZczS1kt+>p(!Y7w=p?Y9MQpI*CY zzH(pq_N{hCAFbaam;QRebx9U&L`18= zF5Qq|yp_nP_4LBMWW5nW7(-Y8kb;|d=6rwnDlyB#HE%v7kCd4?ltT!~s&uuho@z}PyJGlMPUhLj& zL|8^bFFrEj%o}C zwQxGYQjZ!ZJYhpnRJxn3ynqYM;&BV%>!z_!RlS`_si)3q+}DP+qIv@eq`Q{`O? z0*y7_r1gsfCfa9pIzaN~Vfy;Lc3+#^%~f3mCHlI?({dt9nE0!j^cDZz|GkxFv~Tem zA{WEMK^hhXCI;<8>7aS4sYStFJqEmhVdukjbR4)GN>b4FwO6)%686IHwvdv{b7=WqLNaWW@V^v zK+vRf%ZS?@X*;T1g}!Ntv`vDYq1=k^83*uk0Ae*>#nS?io#?o0&mxY_yx(;nmVBji zA;h^;J?_1L;2?^fppUovW?n|CAFvBpKJ^8Le47Z2p#i>aoLi+y4Y4Oj5?k}|%gm>Z z_&OSEQ?{-UYAmflvgYzO@J5IDQF}9|Twe8fMoRpxeAf^$!J3+}$07HmzoeDZ zUFQEPY^E51kps4HXitW*c7c?~T(h~S4v7K-v}Cwm z2{2u0Jy0y0U$H31oYUgGa!(1LNTr}TZNx7rr2SxE738|p{oS*su{&VeGmi|LbB3Hq z(O*Eu&~wU$18e$fynm@F|G2b&aOaJ@bz}XKSrZ&?nCyMM?6N;bEAe@9m~nP>KCQdD zgH%nct@yrI1>X=65eZD_T^6aPO&#b0Glm5_EYnPSB+h5sWFJ2{m(B5cz|Rl!OD+lJ zfJp-{R}HMS;XS@9B+piKJTE03k}UL;v9e>mtFn(O%6{!BYOBn4hAkulEKvmIkUxz0 zaKHZ+gP-!%ED9z{;rSvMeqg|G*#jeXz`i9s9BUxktvoO$4672io=M(vNfU{=`G~3f zJlOxM`TRs_`6}3C!%ce1jy@|%jW}iw1Egb~3BauzcUqZ8W%@5tv0dQ8#f*WXNzOl z(F$>$;lytFxL}n5IUdUn{kBW|OFr7M@auE`zFMF(_BfBI!TS_9=@Gq_QHz-BIRQ?= zzKr2p2aR}vNXoXpf*UO@fbb?EUmcZ)tegd!zc}^TwFGo4U^~O!3&f7}wW7!J<);Ie zlb^knQmt|ZM3S)j)Qz!o_o0&2J>d7TC1Fv$Qx`^`#v$HDm8T&vxwXvDW20!S&vreP*TJ4GQJ%U_h41&GVl93bJgnZYSKw{~n*n z+!A&%Oo?|@&J7G*!oMe#MH0Z}bFY!)t&5%qAoc zURCg5syI2P6EbXjGPyEir?X(P+orkjB6KI@CS27@h70X3${P2T4yPKq@rWUHV!8gd z2vBc$XeeBb$H7^YDhz=jMmWp^I%GSIJVC~&2x3=0gukmVY2Dh_ zRqQxzrq-<0o9!QMLViumH;}WaTB6sc& zzc5Bj6>E&sl*-m&E$Pm`j2KaJz=SqC;)-}qdrD^h26mfNp)YY}H+cUrA+eaYWvJGO zZ!LdP$Wa-$ZTycTeSaeiam~JzGq;zjID6r#`qbgUB${wK<$YPZAC&fEC(~+g)=4f> zSV-jyQG@n?}iOZggH;vwpM}`t48?I!?ar?1Yq57RPt1R=I-A zlyHs-)ER=l%}i?#ba>D3ah=^re^8%3P%c!@famm8sUr0BCgzG)z2QOAGk%m$ot@-d#Id+@U{dw#hwA2ddZhP z@g2p){5{FS^H6UcrS{eKlZ?202a3n>Gc#M<|9+tdHgDBjk`CW;HKc;>W%0aGE^gj} z7T9xl1ijQYYJFfU`Rx^wCOi1)(Xh(%j`FKz1^-~b31FNjOJcD?Y{2vkY%X~FEx#+S zUn{#D|ExHFu(Ao!` zZAD(5#3u^}l4ou@)IrlX+t2w8|DGZckMMdNCD#k|e&voNUa!5;yjedO>%uU3-)QzhWPc-Gt~%*Q5st-O zq;M%9->=1wBV5(zhgDP;zxI>6stkfXrL#N@0~9FJn{spW<(QWqTh~JWr?0)1N52{N z<^-y55Ffe)L0GOi`3HoGXc)cP3j zotfW$?{$h#JFrb>;tRuMRUU6PKUWHPuQpaN>c%8r*DOIl`^Q*jx7WO>FIxn{oVN}7 z_lI=0m_g@f-~8MTh*RwK-c`}ueOkj+YK_bb_Nf6ex+~)02R{ zl-lnJyZcUBQkB65(P~|Kz|4*6oS7c|8yA&a4)2#f^C^Pq% z1vM~HQx)Bg2-yl--b@#b^9ns@>_&#nIth1bZCZORIkrK=nUH#AbPR#%{^0hrCxCI%h9o z#A`29<;v8sFz##eM*=_v9UE%oUMB|%rDMLTwc|wpHGdfKIKQ$m}jaM^=umT#T&52^({FGkK> zv=x0)IMb-1d&Q3>O5Gsd_!67?jggC96hqmoj>tkNEXc|UsIW>9G@mdtraF^0mIe(oU?h~Wd7Gw zm@?{}P0c!#*go0hy;in)Y(Ldhwm)R!4m{^!^2{i&1gDyezb?%0e`l&WV+eTAibP${ zU2&T&9r4dkj*!~^`vEz>GI!vJmg`LK(EEO7Z{AKl=x7%PCDJwu%pZI;$}t9v<9Le|rxtc-_u#Q9@RdnYu;fMf6HCx0`n zxzuN;l#<2)(cr3Z$3V@;#J0du90flA!sO_4vHuN3SkWVk`)#g=nfZNNFfqoL0!#bH z)uVlVpN?p1LyBXA97!)0wAd$x{qp@hUuil6v7o&-bqj5|$krEKQAM;DO4FM20F9lZ zS{H}DrIk;Ahtx}B+m^&7%V1uKdW% zyxyV#b5jhS#p5jJv7w)~Hk7QJC_`8EDPKz(m|eQxLVQWXo%k#_)#GPjgI{T>Wd?AJ zBDdeq_!IF@?((5FPK#b%!CBO6!EUls7wmRCsx{Lo(vE#VAL!N|na9{EiQU+wmo?D% z`E5~(v)*=yx%fp@5rN3bPvl#Hf0T*v+ddNJ8$b6xW!1_URn*dcsC#9$NXqn?bWYcN z95Sk|xxc~p!PI`K@sBk&HoXH%k@3lAotX^=@>oejT!=TB#kq;U?qvlXz3F5O@9YrXy(yM|cY_MWwQ*)baw z__sEhCqtnMQz*?4e|yo(PNU=7%$z9#KlGWjUa6;}Yz&x6*ZOan=n=&{jz^V|PGEkp? z#)!8@dbH)di)heYuYXN4lDGPd=A0@F^Lt;;I9toPJRdq?iPF8M-)ZO`?1EicxP9S1 zR*tb`cfn8%1*3>oUcL1E4!;3c4p9@4K{^aQnxi~W;V?Z3MxPi{Ppqa9&=YrsBo6``uy*Ose8Z=_Hq&&m=X0n0$E}BnZJ}{Jz@nLQ!6Ar*2d1HrJZzM^evHFLzre<{E z+2ma1y~2>Uz54~+=2lku8n;UJ_xQBmlEUm-rv3qN@ai(&I=~cvWXiyfQQl|2?5C4l&gbIIFEsWlvx@Lm+H@y$Hrd3)hP<+qgM2ppfFI3yA3?pEsm z_TinFTc9&7$|IoGJb92~APl+o4qnyq+`gltqYBx|-LK$gov*vit=cltWW?dDNbV4- ziEeTOaY!jyzpEZSQb*r)GXIq2y!BHgpu^HNc+sbcnv(-IXRc8q3~8x88=ku;I6O{~ z&pA_~k(ok&Q8;A!w?530x>gQ9Rnar+o}LR0e6g3Y@^jQW!jV`!^Ux&d8=)fLiUG$m zhGsR0oVKXl*ZIsI7VB63#-H8;6LZ7_GY80eJ?_*Jcm+p(-7Wv2ccvwr(%LIjm#7=` zRjc_%A{z8!4V5Jcy0=;r8L28e9`x`7HL6<7$tF+l-;Wp$15*A?xXp#|1~D}fovo^TEjgLcuEe>PO$4o9Bf%o)H^aSc`Si&t zE)%7Os`)d)S{CwFWAs1%_<5T z(GRSFvhsa;(Wy~rWm8n#@gr5&X0cZ3>di|J`3md)l=_beVMpL+<00OhR?F>}sazv7F%Br?5}_?Gb>-D(goqK*NVVH_%2_;VCEQ=y@)xvpDr z(jl79x6lwL=28?uSm&Z+{q%oa&;tU2ouY#+-YIdmV$uRO&P{aIgX&B20gm)IL;@^nao@PYUVN}{)6iY-env8dM=m@3v*P+lO`R~J zrucPx4ts9H&G^m3GXx1}2diUi`}wQb%a!#NM0fDC9<)8L2ygB%1h1Cx4>J!L$ZLOr z_W5s!F=0-BCVL9K^~$HCloKVI6Z)vnovbtVj$Oq&ur|p7UhXL?H5(~E@L+;L(kRpvV9aX0|k1yTornx!fI!ct>DnVAB=Ez(0d zCs2dCq{pKgew3ms(Q&Z7cq>C@Jq;f^eo^k@FM&g9SoWrUK9SRo*JDk(;-OPW#r=P0 zx>>Gy%KfWkmHG>%gkq8VUec`C5J>k^$#ywg{$+iZ4DKqshrJdK;#X>lAL;g=TcMzQ z;FrT!+p;}YRzAc(vMIdtZ|U_9gZ9nloqjmkmfCB$ed)5^1~)fWN}9;UkZiooVK+Lw zU`dS%*#Z*BR+wp%^hkA&c?Bt<(Us|O-shQRvpiVRe5|=#4*DZHL~!c zjX#xZ5TTXcTOq3wyKXYBBQyWrf!sMRcmp<)B$|nCl7Q2wc>^~#P$!!yln#o z@1pyag(fO%ii%5q3>gylRO6872+cdN@jL|1hR?pe33E<&HMO;8ScF?Lz#7N@PB3lp z@yWsjRKpIaNGu5{eiz&BR>K|Gl~CWfV)yfbtW_$#bhG+3rR3TmCUzG49&b^_8Y>08 z0c(g!~f!D z>2r&(93i?>H`)|I(+$dA>AW?{rJabYLN13&D|eC^!;#+|cco&Q&?omc6xv#qszOmCn(ElC<=T(|{-rwXKK?uW? z`Rz@yt<8vs&Y!V+`Yh4bA6!0^AT7lv_u9UEq~Sh4$yQ&I5iD)eAtSw!hfr@~o%yN_ z)H=C+!=TDKU|GG?l8DxV6x!PP*!GIUGuLxa8blO%3 zM3H>I{Lo|#6UwVbUqKSuLr)GD{E%pI@x1k7duP{&*3&u5K?dJ}*K}=qyonMP4DyF{ z3Pbgan_W{ubJbKio1=zKnx0+Fh0cRSeeSl(COE47ReH_G14^!!>c6xa`h@&}_T5L1 zgir}wo}ySfjZRLf$kx>$O`_6!u*tL9oVwP%M*S@{FY!yh{y-H`+RG~^b2X2BOH{{c z)(R@|+#-dg6?>#H#H024w^G^E0poCdeDWp8DK39-xPt$_*P=3MJrQ9iTh&O6H95vz z3x_VI(Oy}?QdTAyTDv1=Tl~l9wgM;huBzmyAI6dU0V;r_2fgo-6m&IEsxo@43gj4fae2u8-N_yA*CA13Xo2xV^#yxP26C%z7I-w8S6ImG4tq zi=P0LOkEA;MAg3u`xU9^`aOe!SZ39HN`cRqnLdwlbAs2Nn{gDFqK1QBrx5I z_q)Eo2L@)hopJ6%VWad0+UPq^gW_BN2K3FT>I(Iy!M7jVsHi{{8&&zIc_(X2q;yxM zW^`-LNk%9|37CkT2y$JUaXihNbm+4(BVJP$(tcSltO!QH3H(0XZY zV{OzBs#ZB93%z`9FPAJ_w-2_bF401~_YKjoy*t^y`2#eC*>l4@Ne2O{dS9KV}E zW+gc1<#b;B@Z=0~-*-9Os!S(!P8Rrx*Ndzzwbx=yuktwEvg0j^!0e3A8k-gA6ukX~ z$-aGa>M7KTBRVUl6da5t_nwXRB!(MQMMM~$jS@+jb2==MbsYj&w;hHgNY>|G3;wnLW>N@!I+&Jy#bOuRRvMrlzL6 zr1;4Goj(5d@AgU}?e$&7X%R;u>iG%E3Fp^-OY=K~C~v#kVU*?Os@jY3{8W`Z*&t%V zNMe?qn}xuhvfE(?vNSu-obC81%<|dfRTN9!tJW1Wi$NRwm$joN3(@sZo?%SY9{F{M zvgUM62zm0=2EcM zL%fo!h@k1VJo8aI@N3;4OmG8n{rSMuBJDFiw-A$kg>I30-E$OH~Kud8#;vEo>Qt)T9s6`eJjDq+k%7 z$&jl96832OxrIKxmia8FRlGH8a9681eu9nhS}ki?W#x%xKlQ^x9L8B}PyG;6|5-MV~(zs^%05gD{H%)6(KJp-`Gw$LS zO{TpUt%yC}lY8wVpj?S{4pkF1nxH`HCLhn}dBlUs=;hMbmftdky`M+$Vaf7{l^IY` zVec=3<5~G!`-69>VN>C4|4i8AuPq>;9#*)qT?_T_x37re)I~d<(RUgY{l#zm5W8dZmYGk@W1n_9o(0*g#W<#%iS!H;@TYWa=ylJo2 z&Y+5tT*P#VCA`vbC3+Ef(O@-L_ezA6yT?e;l9|bWyHl+kdZfCj-<3QGM0mtR2v~cz zLDH%I8H)GrL-y^6K2w0LCHU^b#J7Pfydg)Onk9On56u*y;b42*UH&r?`zM}__E(=f zP=;J(U(M_=8E|2ILV_aa;57!h4S0zSR>IGXW3ScQ3B^1{koMKTF?mg5Hxq>rH3#RZ zT>R1+XZ_*vQ{W`F;VxXFu?W>vvOuEw4JJ-Z87I?7=y*H434s>zCo|e z^W+e4w4L=BCRN`^69@1^eVy0xHbJhw!{=qGOKf2TFvKzNGc7GP)5NFWq=n6$&*Nk= zm-^VIsxhSFxpWhRt7T2KoQ+5k&hk2Jh?hKjT<_LY-d^xg3i%P~P?>a-$ISl8;$BYV zGYd{YwbGp47anN#*WxT`e>1x-Bchdd-P|e3&r>rV{D3MSGB%b(=LnLT`0ii-|15yj zff!_mg}7O;ja_eZF@Nw0!|_53?%2@de4Z5fTlhyA9R>EBPzHYu*T$UV}G8tozloL8A7Iix5J}s<@GWB z?+TT3@q%fg*#MZNbtSFn;QmpYj!A2m#&xvAibSnG z6jRf`E0=myOjZ#!11&~aRTugWKa!M*FtuL%Ef4qGPe)K@mNT7h?=)0$MaOQmRw^JT z(o42DdDd~tLl9x z$Hrmyg4v3oHM)zIv;#+$r44b;Xc}n5Jua)OG@`tizDm7;+VGe!CfH;p=*`#FS#SR# zRrtk_l!ZDTpKutbq}&DdmXggkIyMRjZCB#nxruwCmF1=?Cr~m~_H+koQe8kba?`BP zjS|G$9ESOMHWswqIYtK?*ADnqh2b1jAa|6z@7354YILtnZ2Nc5m!xhk0;y&7 zRAg8HVRhwpjkkMsHtTR_8veR!IC5>{3G^Rr-59wDSbN@Cl#guw;zFg_bRq|G+VY0J zL+i%lP+HKHpJyPZyKT{DXZ}v8?~_bz<t!aRzHaye46o>QxSj%kJ&3X^Q3T0 zUFDdfH(=@|6)FGq{fglH8IBoh{C z?Yj|$K7^X;g~eK^b=vIsXd1<+C4F0=ax`Ke%_9E+L+YrYWn_0|XXJ^b3WI%&2S6&W z>5O$TL0{bJ7F^`8c%UG~O8)w<9Q>Dt(nFF`NZ`7F|AUW>V0{;?4mBnL6J|^HZWoW0 zT;ZjJ9ft8jc8>-Ibigrm!ScIp@x};!%n!m}wA|Jd2}KkqmY^r>bl72FObvB!S@vV@ zCTRrk$AMbqB3pqeTOvRN0{zATNB;Y%1~GZ%(HB9KhjrjDcb6V^WD|Tt(JOwumjwg% zPhN~DSXggch@(0@U<**Bp)0&b%|n&BiT4;5do=dY6p)|ha9eNCJLmtF``4Jx@I4CI z;)S2Svvu0@SHSgH4g`L>o?)g6PNRPy8kOv;#!}e-BE<|Q+(Z!DA7#${$lq+>$axrIE+O!D7AXFc=>*no897t^{d>ZNy+5DoH@$Vk=Vk9 zFLaH}dDv-td$SeLc+)nrUzGA@&QE_Hsahi=;qiM}ED(~I54gLcoq`7K3<)uaoOcJ! zN2jV@OE_)Psa*$WmWOUhu zElLj2@QH^5<~OK2`nfD#`%h=cFf@HAJHt3^`QlCedOiccz0He9W9q>IW7UaSsf633C7)W+)3DPd>r=dyQy8^KYHLtj5V`+cS_91bn%!i#*y zO5MEI>XC(BG3V#?L?0K-wZd#7j@-V>l-Jj1Qv#ql1%mzC6i`ealc@$-!?K*MvWMShwJ$ z%;Le2e$OctJiJO3x0K%GX6-#csR+sbjNX+n60>6a?DF)gRN$8MGJ*K4G1{JbuyZj) zX&Swi?|souRqr-6T4g!z^Maha?d zFHH8!nbH+5YUQuxyTBq85Ui6|B#098?$zu zcDALqhRQ9g9SDBRQ#L^m;HD$s_2cZPo{wTT*5jtR$CPZiqH=v97UG|GB#WEW`X zk7lzhfNdRcp=H86+E+^B*4CYQdXIs5 zFc=zEXkF4`ZfB-?m;*_a%S&r=-4K?asIyEB-aBpNFr_Ef{S8hq3;5!e{}bTNJ!(HD zN3YVaxkYxmxJWAR6SGGQII4M04;x}MHaV>hf5?~bhO7j&=#NIk4Nu1|IhTaDSk$R1 zG{M4zFu_)?MUs_PpLMnt)5Banhr*@@h->;8V`efhLq@GH+O<_~zW1+;O15jvC7*J< zF~A}1oIV};5FJ=B>|W@+>1~}S%81+i;ul(-1U_8NR#Jk+Z?`hC*ce7$Bs`qtUb?R?BYDnluaowXcV@J~ z_u|-9@?i(brtsG?MM3MEd zc0oczYZJ_=?q34LR6eKxhz=cCz^=tUG9gn?P!R3DlpZr_XTa!@Z9f1jH-A+a^~7Do zCfs*2JC$d(#47c`*=rkqb-!iP!f4_-5)x;xRBijvsA^*Kvi56^=GncrypGnx9SEz4 z`C5AWP~H(uH=-)ej3>W;9J2p9n`ly*SuECTCtrqlX0EP217=(-lJtSC)X!;eO=l$2 z`N5i+P@shYk>BB>Cz{@4)g`uOrwWmJ7!S9DfVsC5IO2G}%~8oXpj-p7U`G%y@}=~ zW*bI<;6~HT!O6_4iKP7(-d`igns1LG+6FRLd1EYh$Gr%tJTRcbo2{^- zyp@~e<#-%$h36TK8K<0lSCzI50SEC zPqxW9RJ?;1T+#Zhq{^FM!J~CW7r%l^pOVSRq3+?NLVM04?`j}xVX;#9Gm0*0Hhpy+ z)9m)=R$uG&`8jS)k!JwvVUj9iL5j*%drS3Kwr|uy#e>f|$8*xZ<~rf|AIl1!OY3lP9GnAK`&t9 zL9|!)bV7d6 zGBrj`WGAv8avagUyO) zre~Dte0eXT7Bn|1-82tugk0h@8P3;b6He=1Z*{L{u+Eb#wy02bwyKknTS?vI5inMR z7Hit&87$`9a@ejv#>+7%_cML>T}Ub<6aTtR}W@;#U);CeL2P;?&psFHp$37%X3&MdMQWl zpgAUd!{uu+)R28M#Ka`Z6-%zt6^0=LQ?d~dw&HNL>eBQ zKm#4(ZbCfqud*%ZzzwEZ++PjH!rx*MKuv{W2~m$Z;L2uNO)bb1gMLKt!0PXPy1F(0 zR=m+Dy`!M@Hl9*hJNY1?f~IY|4|msHvO9ilDKK6wu>n=2={Klqr%O3hK1p!x7MO!r z#i*}dNzof51W z>$!!!ct68jCnp9=RO}C+awulp8dsZQPscSZdMiFDHY$3|+Y+6XG4%ruo_6h%AEvBW zSack>^3|@ND2oxG#ad+TrD1>tXbi-=UJ58N2wYP-0zbrOn=EzQ)X%>}+Kt?+X=dwK zb*&`X|6yt`YP#4kkM%&Zb-TKhq&fsG-5&&&3^3%?ZE_kaEDkUgrj56)(Zdqr*cQ?GiXT4(!xpi~)gNrqsS#w*o5p^2NJMQ2G$j*f$y0)1Nj>f5ITT(Z>pQkuK`_G0^ z`GwF1Hw87@m8(fn)F^3EaBBK4Z?II?Oy4SXx4*9mS#~tH{MpXf253qAL`{X@Jf>&7 zFIf=Z`ybiDu5JhGCc-?NZ?T%!5X}PR>M$>maYp{NMdxLO7iNSk1>tL?a@Rws3J0s! z=Mzk*h7^E5$*X1;k9Ug4r(*y60{ndCfXTY;;JZ8`e>G|)aG`ub%bEoXZr)PYs7k73 zaU4d!$4Re-X)<6ST_ajsXMrI|lb=_BS+uv$5QM#SC-93vr+nF zDj9Ff7Yl}t^Ls>S3tFBGr3=9BSW57Ir1VFZ*pnsv<;5?Gut$j!{h%0++=?~H_1G0l zhAuC}&&Q{;gf+~ufO_rgU7wV)RqwT1nwct+>w^}ISdw8%aWi4Z)Z>??>X-0N&;4!M zf0BZM=F@li)oiAud=Hvt69&!n%L7f(gVqplvv?rtU2L&VOn>y`JG+LsY`jKZ2OKz3pML& zaHq|Ua71z$)~aQ9b1T5yN2@RdPJR&&0M=MqCzn18#mi6q`tC+Atu~QdeUR6J0(3iw zFRE?X)900{sK-jAQQBm**}-Am(RGRwr({bOVBuP)a?X3l2}#Ei_&+aHrI^J<8f8I`|0JPf9SPC&8#-^H<_p^zq?gfizwY7S?

-~ z{?B9n{HUq|bfjloySWd5yIHb0w7_+6{Rl4A=6}7=uewwjiAs_U**Xn@?fCx1PN0K) z5g%N?31IY)8?mXDJWjptF)j=C9YC5{ zNx845k>l6z2<`#2R(`qg>vyM-l7J5&jbm#1le5_1&mm$T!=T;!;{0#dy^RM*Q_F(SL0CzbgGNrSmr%S~56%yIq=L>D}kF zh5H9Q#T7pwfvoE&xC-KiE-1Mt$@x38hTQ@rt^X+>moz3JHBbtW6Jopc9cl=w<>$~f zW%?;rX?4Es^Hoca*{ac689tdycTP;M&ShqUn&DEb!JI-w{MuFtrcuw|QiyY{MZQII z7#jmS?Nx(mjQ);{sp&i^r$6FdUS1xf$AONNRP#*9ZDIeP7N`M$S7S@Mi)0G60ZZ(? zeZ&#*Q$tAO_$4GH+}*1$9a(jSN8&ktx0GGEDfshj2w;^h(PP_ZpUim|GlH>aeEhkT zo!#2~JqaOwK}2E@E}a#<%bQP*$Fl6Fe$660WZW4D4Ap@d$v;w_j5P&|TYoH9 zsCWh?sQir^Kt-VI*Y1OK1Wl~&AI%?#RW4bFpo3R=E&d6FdNM+Xx`wNP`q1~Gy7}C; zZH1ppT0AGnyC`F~u}yf$=KBN@&(fFb@EU1_^0He_O#aDTZ^gx-C3?n=gp~&hYSpT< zILeZ~QYybr`s6ZcHa|qOSW9O|C#qhyyF%ir8+|5pk(lKd?%}v@5fyo;>GrJTa6Njg z*+6VCNl5w6uXLf8+@&*68pFLoN&R4A?bZoDEEn)?!uq8Q=&l*ShtUHC^U zNZ>Xa#pzDnX3|{emU;TnNo-|Tnf0GY8h>i%pTl$Zd-v|0pMZdX%a>2~K>Bc_W!LBR zzfH<_nx5S5{lG}#&R=MIno;l-j{=xK^=0aD^ybtH{+!CgW1LhcF023hDqtV_-w&Qi zqW@_4CpY~@qW{?DZ29|-ZT>&WHetjbH_uRq;x$;em>-8ZPI@c^hpz?=x=fJ6S9|{m zCucK$u+(`oE^2LKbI`srQmm_5n!LsI95CZEx+;YK(DNtC9x$FSv1>M(NNK@faCgi3 zkAqvF`7TF5{P$h6i_(^|SODZg^IZ%pY>la7Fk;98|!~DEFGCuG9EjHCp zxz8Bnf#E*6uY!B(a35l~6hUHIUFq6B4=XLhVBO*AD|oa|t8FfvT<&*+sK;byE|Qp- zxV-hK1uka@iu!(-?!}8C`3+2Zx*LwPdG^OET8=kRS48> z0jSbZ@xg!Z1%6YK$6^pRdAwWoI^y#Dmj@Fv0tP!}+~(9J`g_^@wr&A1yOXHo-hXk0 z!<2y~$C)=XK9!yR9&1`TK$xw`qoA__n}0Di;1Z@Uz#!4)TmSN4 z8g+ou_bW&KsH{2j>LnI{Fttdr)PD&QP#wouueWtJox1*iud=i~K$xZ4BVv)$S@$o} z;M@c#t!&5pll9KlX`TS;-G3~23Vr@#!N2A9AMgHS!N0}vpYQ(PYrz(I_{`Z#)$cL3 z`r>{MS?B^&ahc@JK^97%p#-O5;l2~)(5D2bp8Zv4$+H5UH0skZGdQux$Oj0lscq=inm=6F5f>~g^1`@VbO=Wj;0IS zQ|e{FJ=Z3qC^5-b3eOezQ(W&mhrvJ(Xv%q49P*!NrhkQ8{wA@z0<@cA&X%z-a@~gI zxiVCvOrIE$z|sI~7(sYX#TWi6xz0P+yX(>25?Bi`1nlVVZY~AEL0+NH!Day=h#dQiae-4 z!wmRw-)bTIn53#Z=)Z%Biq4p*Xs^SqbiCH%vT7W<@Jh*_1j$&*x+oWyA^4)`qx7^3 z0Tzh{frIZkxf($u`rb!p(1vOP)67~&e@xrdZ8*3(&t^-;b#Jaw$*5BGRntvzfBU-W zG>Wu!!Nv0w8rP(s02YX$#(D89FFvdbL+gg6QZNG(X>Yii`aGQdBfqnXHn==AL&0b# zO-vqx5+*xOXXRXjM@ZZ0N+6v8jE=4=j^)hF$isW=kNd6C+Ave&Sli#VDLgeE?^E!F zN>r^nHjRy8#Y&8fA=zioGVPuL=RUU%jD!>FEhgtpt_w=P7an^=0bkxp?T{Mo9p;V0yEwc`Qx^HJP(clAh9hfK_p*d;t|be3M~G z&S51A>6D)08S!nmrxsnRUPB7gQVNz%F$63@v(=xo(B~>mmc7RiBdLG0>J#b(eGrL^ zHWqC^K)wu0)wPip?e~N$Zc_4xs>yyB3uI6Clr%q`F&i8)oTi1eSmpWVi&@6(v!;%= z(?#JkgrUvXxkG^T;ppT@6_+2`Uz1x%p0x!!`PQ&zDdS(q!2jaLWA4RnfDvJk-nHNU zW0{g?z+0fX2F^6t+W0C^wmESpR&@`SRvUX!H*plsI`#M{xQ+T&Vi@$r!;f$5bFyn| zE!{c?C*NmmXcoM=^JuSKDgN=kZu-RXWgV;9;h^$mICs~2}ZHawecI9l$u0*#c-rdD6r zye~qjlE)@!IvxwR7!CWH()PN|&8j}wQR7d;!ttZpZSc9*s4aB|Vx=!nI7sk<^NzX# zKm0w8>vn1@*9!sb^5@&_Ln328q|`tU9W!buWQ`G?>}AOvNT^d`i+=eUOXmWUvZ!H- z(pqoqW2mL7sVUUNBCaSgI$;qikqAjXoQV^wk7f8Q46DV(1PhS8-S%cv&2V_GOA^sXpfSY-#J=7u zitfp))j97)hyu^=XykO}krx!$r*y0=^Ew(I8XS6YzAm$P5!u9B2DRkucakgi*-acV z8w;Z8%svb;2?~!YMX--rY`Z+}m<}|#;$uqNQ83T^FqQyshd!z$y}80MR4*>0N`XI}KAXYL(DFWGsQH6upJh^! zcJq4<-H{aCZFu@q{1Z09y=mH{TR3)#W)*dJ3g$!SX@aHwBPER$CT+lb=%w@epw*S> zCZIzY@3A(UmHy)Z;V&oPr*caRZh%!K)&7{BkTfc)r1vA^`gB}%QkD;zAup~OPBSI# ze0K3+T@*1$j)`g8pVEUO_|aIBi!B@3uKUt#p#@XL)yy3scbe?jB1LF3BuczmQ%i(i z^KjE7Ri{KPceMGq~S?h!1)ehknLtM16 zwi%BUJ8Ed|ZoVVEG~hGll>RVdLx+E5!^X8Sh0nlH3{1RYH?*BkJHrh>Kx*-)%GYwT zX{>rel!6r1vB@T4E?vpc(5$1n{xnpP=xRsk{3g$;=bq@Eo^$gjmC#H}-Mjk~Us?O3 z9so8%&_t?N;Z&ZCU|An$Jv4w1mEzNVq|9}jo5+W;HJknj={U&i-0#^msc9;7>~7fe zJd7AKo~Tnpkz2ocT!#GaI`zW6?pDaoAh!3~6=E*gMkMr3dePIR#CNtVhYnJYo=gnI zb|&yp&YlA+RF)`Ucqgi*bhbZ?_uQJpGQMa58%r|nEqkipoxfZzd_7Y8$IuuRJvo*j zk-K8EAD7vwLnU}CPX&7GIZ&=4a@#6HyH0m7LBR9d18sjr5B;)FQfp1yRP#=*iE_Dk zyRfyPF*msnTxfHATNC3HAX|gG)VAgUn9nYYBE~5dMatWu>@HtgD09Aq7s%{+ zR-)$Ym~ZN>d-%s`u$;Hg#Woqy4tBE`bs1D0+IjyD&K5Abs?As%vMq0{`xeto^k~Dc zc@t@qKN3UODjFRz(aV8$9T`=XCPL0ktYRS48v0FO6x$JGVk`WvaU*dnvx9Tntc!?Bwqbp{5 z`KXtB@QKPx6X3K8ILqcBzWFDs{zElMEBQGo2r(DetdW)s8Vd$GZA}N!D+(Td^x{^q zE+XK35hdBMb|)QHZ&0-nXu7vO#^Qg$V9KbnOs7#yv-GmG%V56Ff-Y?+{WFnJs39P;1{5x+Ltw%#9Xp*n&(6i$zd*$8|ar?3>;H)qj=+V~;h0obr>o^+uj_;B|!o3>p^t&fM znH@HJOlA;z*g0}ZZa3XXhdj1c@ja%hQ2_L9Yu0H8Mm?lhnh-sKk3~fYN+LFc@p8Tp zHcjI=A$6~;J0A-BFQJm|F)_6ZdUP~SmEtJ67NlG5^Oy%S7qF3()_6%G&9`;qK%*kG zJKczhe4f4|9|7tvT_XVMY19a$fUM@&L6~6?F1` zWiL|o%1DG*Yg2TSpg7!VdqzQFj~qC&mRk{($_AS6dx0)HIBi>UyIBzT5JPoIpd?p>Hl17|4BdUA}JT>F2J>`x{8HFWA9Wf7A zNKzaLj>h^SWOokBGNxZ~zsXdk9ooJ!rqQTdD6;;-R?eRx%rGTATi6dxZX_ z#rnr^7W^Bb;Jpcg#uvpr`NmCYy+kIVi2(Aow!zUfMv9teKZa(#5#)`hB_bm$$_jnA*uRuh!0`NXOOMEvIob zRh4R%v*GU~-s=@JcaHth(`4^1!TR3wE9tu=0BliMeWG6*&}Q=RC2{oU zx5YfR`5pXZhpU#wckx%S_%cJHqV=CfJZH{UMr-00c7=-4$NBG0l+j7FJuo$;u1d!e z9;u)o!~WE?#h(W#XmOzafzw$rf3wD@e53yz>8(mhpq`ZJI-~tEjz_5FsJ!tW^sRmE z{Nc@whU*#})uqk-V$sI(=F&~4t@X5xUprgV#RiljTpZyDJn=-+z)Zo-vSYV}7@+B$>!e?a3`Jyzj{aY&rhB=XGPL zp>%myJd{Db-+Zl9L|v@vQ_1Yea#(Ct_=dX^#tL4C)ce?x@sg`VcKLuFaSyyCGEmL^ zF{Ur(`h8kN$zn7*{L=1$)LnYEiuSgqJ$furgZd0dZ6lrTB)*mf9gpNBOih#m*^aLZ zWl(M|1&K+bQrD3++{ZVyV(mgm{h$mzO<0&XhCc>2w(`mgGMm{#+;4LP19;y8jtH(p zgGFo;6(^c(pH}y~>dYzjH@QZlOU=Iz1#ET?D3bBLrn$I8NJLC#6DYx7W`!$#OZt1L z_xLr zwDQ`nvp8Fi2kfwsZ{K$`Q@V%|36YZ`vlNkvgBO(S*xsP;pTZNh^m#0O)6kwc0_Nhd@InS$D3fRwvOrxH_XHzN5_)oZ(|gL^wv?1JYB zqf(t`Pt8OOy%Lrs4?p*2ftlNTHBONI#bJ`Q3 zE@wkcj_)>@q9hAbX$q9kOZS7V$fvXVU$Jl{)W#{`3}zJYIM2Gr z+}hT*FBs5Ph+pn*_6o0j+-^t}#BTx%k}BQ|G6j7u8ZqP%6IFUw*2T_7Sx;ErBtlX+ z>3X>il{)a4$xWC6mUcswZ$z#x8!l^UQi& zMz?L7kKuM6yAY%SR5X$yWfGToHyu^$0~&cj4{g8jrxZ|d&Jv^b6ItjHA=WQ1nb_AHfcHqAatb|CT9omCv#AWo;7 z*Ci`?uDRpJ@{U|9$`Tnvet~MF`6JG)tDSZCrz};3mp|f1S?O81Jk!dOeV1ICbDtQ) z;0Bch(9S+x>9mEmy#AJkvD|*jfR>AaPs&VP_8fjIb36T)ne|98XKJ5xTn#kSPH2A! z7V05#huGUMUn>VjJEBdXKfP{S-jv9kOGBTzpNGfDCfm9qkgG$46rVfTK8b5t3kmO3kSB1=C#&k!YasV_LCnYSOHz zxA{gkmBDTHE*O5!!PWe-gCW1O-rLLn*b1LGcDI%MKE}nxL7TYF6(s1Ii7xfUOtpBG z3GWZO2PJc)BH*+tBaDw$i$rMbX-!un25S0u*WN>SGU}E^K2QHhpt;b6M8%nR$L>5G zXQWVd{u2A#EOc!bn&iXxI=cj(zgcNo!1A$3ASr*>UL^O+d>rcZJ ze|KtPeQ#DDwX=t}nj=l4S|)hjeC*&umdMseTP zhBaNm5tRO#56u(yQM;rnNrM3QeP)JM$va;!Kp9oJt-L)Y-T9Nohq}7D+@d0_=E)AxLVW6J|)q6 zIIWR(OQeowMdI(wx@l$F4x?#eg>s57rVBL%-0No+f5F)~oq+fIB01!UySQwB_*T}Q zy-~>k0U$-6OGZS-)BZ4(9FOp|i3}~k$Hf))Zf7aqB1MhwdO|cn6V4yKmjy-G5hbKxCGT z>XSEW=W1zb={Bb|0FBvIG(#MTFZ zK=*8yPw?U<^A#;=*8;mxecn2+2@1FY^_PR5Mle+-BN{qWmR2i)cBxRO zXdWWU$ZvD~2GX)21O1}IhlAl`)b(ulL@O2ACre!B>f}*&^Qr2YecbacQm87PwX^~@ zh5l-{HA`0P?WktKvebgC`@k7YP~=7ytfW4#$q&_@F%xDzy#n#RibZF=ST_YOp3LCV z?+coA*hR~^>J{B__8Pn>h2H!^`=rQE{4!>&1QmGP!`R| zbNl(iFabfdYr#IPKEbF4^CMv-v?Wz97|cdQF~8jS&E%UlMX-PX;tuDtWh%x`PX?Z|fw9b!_47?cQ>K_GB1&G~Fb=h;IS&1^DfeB;JOmg3I# z=7Kb%49~9R6&5d4{S%EO8?c^3a*+AdXX(qDN}$ASl2e`KKxUd&o2t6Wj_Ko zPY&krxWgg9&AnxgxCiwxP?VPxr)S_H*rPaHLTdYi>z;6`G!#_!t>pf@%j51KTh*LLYubU(o3~77 zwMr!Vb(FLd(1%?NFc)v@x<}Dz?=BkTqr&IUb6q)VFG{$NDGVr5B9}0L|xo~bbtMWl(T+Eo8Lxp$hr&gc$i8)CP zAZgRh%Z5uKDY~;EcZus2wEZ0%e5O@$&%O8zIRwai&w1%EU6*ahgZZX_FcbVC_9ExtFe-l3d}-f+6{| zC?n&Cf+ch6^~h`T9uHF<;X#y#Y}Itq)+|KJ$)QITMs7Xt)5PyCz!&4ypENUP6Fu{O z6fnOclb*q{EfOm&A28r(JuW%rE3PS_ODVm z(0Wkkd5)eDYS+et-nVf8%zN$1 zNmRtVyg>P+VM?pz zi+AIjfW=;0&Aelda**!=7TLy?&zo(}PCMOb*uaPg*2rb1Z##c&Lb*(vbY*;?x#1Z%naBII z_#HhVYR{<0{h(mpdL$?$lgAbuTujdB(4F{ECiu);Oq^kT0NI`Ys5H62VkEFDI>c{ffy4*t+_KMJI`$WWSd z9iCJy=$dCL;Mefc-L{2hxa$3DlG)_j%pl$teBS&zwR&V$M*=tHB7V1~z``&ecV`!P zaKlqV0Hf=8@802fhw-%a=Dt#c-iNW>4rtBE$pMX2IHnH1{LC%&BdC9mDF!sc7@=J8 zNt)1m;th!_F{s1v9^A&m8qpQuCh-PRus2T%KPVUw$V?Re)S8pOac|6dvBQkIOhm{! zzDfsQn3;n#beAO(`DMqzdp1OW8$}p;SP|zmsBb7MC6;ibe4P8vrYMRgK!5yhQaXYa zx}Cfb2UYNHU2PmK&b(~C8U)G^2FpOzwREfX#SXd(>S+r}p|5)1yqM{>1|4?I*xSZ@ zo2y2&ObyGpC3~jY_4(vFS8kxIzGk{U?taK)hFTMFoJ$n^s?c=sB`%?izCYuX>oRtCL3-X?NjkcIa2Qcx zWm7rF9nihCsN&Z!ah+9w|0=2CTiqn%(T#|$L7R&s4uq(epRYY0x1)KT#9kK)g>AMI zc_W&ucUGB}VOeh}{gue=#JrAXcBT&tmz%2XyzZ;fN|cw%_w$xC2~I{MV>%w%f@W(I zDPf{TjGD=JQIpp2`lH(0c9gXA`%ap26GV5n`}aJgz&qcRrr?R98~zi9!ETdXb$Rcm zbG-~hw7T=g;jl%WIt0YSY<@+Gsvnc^s5Z`$bL*5Mh-06H^;+x=Z01^%HwvWf3t9Gh z^;X;CA$xvOwpM*5#P!`%raJsTFsKEb*?Qh*LQr7m-zyE%cg zMIOz;T80y9!fv`bN)*`g^xRJ=$^F< zRXRu1oC{B$j<;6fflbfqTQD!d`ipZovTQ+jy-z(Qqq>TbJXBJCiSThX+lKN!O^Q}o zmc!?`E1|*zh{0DQE&-Iu&pVa*)wy%mce})?*k=;vtKwQqSCKBRSQyFe;WX;@PEvH5 zV=Rs_2IcEYgiF1>T>Do82IQm?yY;z14{`|AvCz()ehtwPB?bu1n!1V&v`&F#qB(|N zj=Og;qgY>JwJbE+OoM*VG&v3;!gGh9g7xM?rK8VoZ?1jK?6P`^LOgbbHsEu`ON9=f z%6Zbo4V^`{Gju6%fD~p9-TOS^^c}6M zr7u>#p3z{Q2ki|6l{Gv)qR!Qvvg`;U2{QEB;u$9>4>u74YxNNn#E7I|c+6!xbxdUj zV@A{DXKszXFTs;Rc(1j=v?c_#`pxJPN?d{cS#`#stdqTI4F?|^Tf|2e=Z^M%wW9m| zlRDS2=UxVyk8q|A!C}!LoyS{+HI=ZO{{9PIU5MUPw^hp!O#=3t(>h$~DQ9GhJjGF$ zC6rzA9D@8Pjz{6Gj*#Ulu6REwed_p`x{}L&*Ib6c;C+X+dJe-7mq{R#o zrj#eRZon;@jiLbGr#bmyB(yvEU@;A0ebg)MO6M5MqLE03%xHV3RPz|wG}D@r>3N3I z&>G6^3`=|SO&Ugwdnt@xHXNxfXU#0&^5YSqt_9k0ZC<2FIc!zwPAc0L3`>@S&3%lj zy8)#X-hk>;){wi|wgrmpt?ODo8R|-hYM@gx6m}Pr**?OCYi%?AG}X(b!1?WQfXBBs zY{}*fc)n(9!~Lh%fJ(Aa!LCkbsh1wyIfB!8?Pd?vq9|A3qQ!TaLzRQMmyvr_bP634 zVg-37V{_muJ~TKVen@NQbr)FZ-!M3*#yI|Z`%_^M$-vj={@ZQT(+h=7rGNstIApB!czrtUK)O?DGK2W@LdI;>N&(%?z3$bgE9Hw#Rvab$5uH=ld0bIkTJ5Eg zq~xNIv^Z67p*XU+*Z<>CZy7|@+^8SJF#+}aWxan(DRn3T;i;N<@B-1d}xX%!eF>bB>`47AUQQBxnT?g z(Y$+S>B;K)*mhzxnp=)O=gkyiCM4$iY|_(?5*|WtJ8zlq@$N;~P~VBe6cNmXyVJ4e&xNpF^8dCG{U6Doasf82YUXn7r$y<0 z{f>YZh*w;GdHNyyFHez9JcrXZFw%EQ73M$B5+5GN;4q$?^kVs+LH*;SDn0OEm$H(x z@-F{MyHEjUk}5uYnq&K`y7n6Y9xR{8!g6-{;Lm}IM*%arN5Ffkp8Vw(|9?+Hyc;ds zd)@r(c@=jmdDbe(Q%@>A#hU;+byVERJiR>K-EcZjRluxv1#i2XgNYP=Xcz2NGr=!* z?8Et1V-`)^WbHkxGI0Zo*HWh#0u$YgL&gyW8wcplQb=(s1|P>or|$!&E39PP_fI<& z0_tRTG2$|=HWtj+kO09fkBEmS)tJ-j=P5Rp2g2{Lp0Z*6)f*GO2RO(6{<1N@aO^Kj z`4{6kcB)4$%((8nFsunObz~kl!@?X zJ;V8ziDUv3dA8g_00hDRlF-xMQ5?G(pC!`&kCf1p`+=-s%yc!W*A=G_?N?f@e*jhv zACFQ0-zJg`Oe9f|^V_T6iT3M&eJ=qk=joulMEEZgQ3TZc(tj-YJ2n4f!C(3F7j4t< zf3aX#I7Sr&NkR_gW)Y)4zxc;VE*%C!2=N6jxkv6X8DUoW6|6J)7D>MGMVDs^RY8Bnr;oBf9{s- z`=c%_;IxqLx%2i{28M>ZBE=fe;^^C6{^ee>@Sl<`ttaloS9bO4)ro4miK@77p&v7@ zA1hBs^|z<#9I9C?z*jB?+G56B{zkaxpC>jeaqfi3EsxK8d~8tWClkHLMGxb%8E)8* dq^KZ7Q^taN#K)OojOTzqnMaBbA@_}5{6DJv0VMzc diff --git a/Documentation/rkt-vs-other-projects.md b/Documentation/rkt-vs-other-projects.md index 5a237560c7..233ee9122b 100644 --- a/Documentation/rkt-vs-other-projects.md +++ b/Documentation/rkt-vs-other-projects.md @@ -6,6 +6,7 @@ This document describes how rkt compares to various other projects in the contai * [Process Model](#process-model) * [Privilege Separation](#privilege-separation) * [rkt vs runC](#rkt-vs-runc) +* [rkt vs containerd](#rkt-vs-containerd) * [rkt vs LXC/LXD](#rkt-vs-lxclxd) * [rkt vs OpenVZ](#rkt-vs-openvz) * [rkt vs systemd-nspawn](#rkt-vs-systemd-nspawn) @@ -14,7 +15,7 @@ This document describes how rkt compares to various other projects in the contai ## rkt vs Docker -The Docker Engine is an application container runtime implemented as a central monolithic API daemon. +The Docker Engine is an application container runtime implemented as a central API daemon. Docker can resolve a ["Docker Image"](https://github.com/docker/docker/blob/master/image/spec/v1.md) name, such as `quay.io/coreos/etcd`, and download, execute, and monitor the application container. Functionally, this is all similar to rkt; however, along with "Docker Images", rkt can also download and run "App Container Images" (ACIs) specified by the [App Container Specification](https://github.com/appc/spec) (appc). @@ -22,14 +23,21 @@ Besides also supporting ACIs, rkt has a substantially different architecture tha #### Process Model -At the time of writing, the Docker Engine daemon downloads container images, launches container processes, exposes a remote API, and acts as a log collection daemon, all in a centralized process running as root. +Prior to Docker version 1.11, the Docker Engine daemon downloaded container images, launched container processes, exposed a remote API, and acted as a log collection daemon, all in a centralized process running as root. + While such a centralized architecture is convenient for deployment, it does not follow best practices for Unix process and privilege separation; further, it makes Docker difficult to properly integrate with Linux init systems such as upstart and systemd. -Since running a Docker container from the command line (i.e. using `docker run`) just talks to the Docker daemon API, which is in turn responsible for creating the container, init systems are unable to directly track the life of the actual container process. -rkt has no centralized "init" daemon, instead launching containers directly from client commands, making it compatible with init systems such as systemd, upstart, and others. +Since version 1.11, the Docker daemon no longer handles the execution of containers itself. +Instead, this is now handled by [containerd][containerd-github]. +More precisely, the Docker daemon prepares the image as an [Open Container Image](https://www.opencontainers.org/) (OCI) bundle and makes an API call to containerd to start the OCI bundle. +containerd then starts the container using [runC][runc-github]. ![rkt-vs-docker-process-model](rkt-vs-docker-process-model.png) +Since running a Docker container from the command line (i.e. using `docker run`) just talks to the Docker daemon API, which is in turn directly or indirectly — via containerd — responsible for creating the container, init systems are unable to directly track the life of the actual container process. + +rkt has no centralized "init" daemon, instead launching containers directly from client commands, making it compatible with init systems such as systemd, upstart, and others. + #### Privilege Separation rkt uses standard Unix group permissions to allow privilege separation between different operations. @@ -51,6 +59,18 @@ As rkt does not have a centralized daemon it can also be easily integrated with [runc-github]: https://github.com/opencontainers/runc [oci-spec-github]: https://github.com/opencontainers/specs +## rkt vs containerd + +[containerd][containerd-github] is a daemon to control runC. +It has a command-line tool called `ctr` which is used to interact with the containerd daemon. +This makes the containerd process model similar to that of the Docker process model, illustrated above. + +Unlike the Docker daemon it has a reduced feature set; not supporting image download, for example. + +rkt has no centralized daemon to manage containers, instead launching containers directly from client commands, making it compatible with init systems such as systemd, upstart, and others. + +[containerd-github]: https://github.com/docker/containerd + ## rkt vs LXC/LXD LXC is a system container runtime designed to execute "full system containers", which generally consist of a full operating system image. From 051d4887fac9ee607c7a43e86039bd915e098873 Mon Sep 17 00:00:00 2001 From: Michal Stachowski Date: Sat, 30 Apr 2016 12:13:49 +0200 Subject: [PATCH 0267/1304] Add additional options for developers in build-and-run-tests.sh script This patch enables running builds w/o testing and using not commited changes for builds --- tests/README.md | 6 +++-- tests/build-and-run-tests.sh | 43 +++++++++++++++++++++++++++--------- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/tests/README.md b/tests/README.md index b05a09199c..62a1c53c5f 100644 --- a/tests/README.md +++ b/tests/README.md @@ -66,11 +66,13 @@ It would be possible to add more tests with the following commands: #### build-and-run-tests.sh parameters description The build script has the following parameters: +- `-c` - Run cleanup. Cleanup has two phases: *after build* and *after tests*. In the *after build* phase, this script removes artifacts from external dependencies (like kernel sources in the `kvm` flavor). In the *after tests* phase, it removes `rkt` build artifacts and (if the build is running on CI or if the `-x` flag is used) it unmounts the remaining `rkt` mountpoints, removes unused `rkt` NICs and flushes the current state of IPAM IP reservation. +- `-d` - Run build based on current state of local rkt repository instead of commited changes. - `-f` - Select flavor for rkt. You can choose only one from the following list: "`coreos`, `host`, `kvm`, `none`, `src`". +- `-j` - Build without running unit and functional tests. Artifacts are available after build. - `-s` - Systemd version. You can choose `master` or a tag from the [systemd GitHub repository](https://github.com/systemd/systemd). -- `-c` - Run cleanup. Cleanup has two phases: *after build* and *after tests*. In the *after build* phase, this script removes artifacts from external dependencies (like kernel sources in the `kvm` flavor). In the *after tests* phase, it removes `rkt` build artifacts and (if the build is running on CI or if the `-x` flag is used) it unmounts the remaining `rkt` mountpoints, removes unused `rkt` NICs and flushes the current state of IPAM IP reservation. -- `-x` - Force after-test cleanup on a non-CI system. **WARNING: This flag can affect your system. Use with caution.** - `-u` - Show usage message and exit. +- `-x` - Force after-test cleanup on a non-CI system. **WARNING: This flag can affect your system. Use with caution.** ### Platform diff --git a/tests/build-and-run-tests.sh b/tests/build-and-run-tests.sh index 643fe18739..109257ebf8 100755 --- a/tests/build-and-run-tests.sh +++ b/tests/build-and-run-tests.sh @@ -74,7 +74,7 @@ function checkFlavorValue { # Parse user provided parameters function parseParameters { - while getopts "f:s:cxu" option; do + while getopts "f:s:cxujd" option; do case ${option} in f) RKT_STAGE1_USR_FROM="${OPTARG}" @@ -98,6 +98,12 @@ function parseParameters { PRECLEANUP=true POSTCLEANUP=true ;; + j) + JUSTBUILD=true + ;; + d) + DIRTYBUILD=true + ;; \?) set - echo "Invalid parameter -${OPTARG}" @@ -158,9 +164,10 @@ function build { if [[ ${PRECLEANUP} == true ]]; then rm -rf "${BUILD_DIR}/tmp/usr_from_${RKT_STAGE1_USR_FROM}" fi - - make check - make "-j${CORES}" clean + if [[ ${JUSTBUILD} != true ]]; then + make check + make "-j${CORES}" clean + fi } # Prepare build directory name @@ -185,21 +192,35 @@ function detectChanges { fi } -# Clone source code into build directory -function cloneCode { - detectChanges - git clone ../ "${BUILD_DIR}" +# Copy source code into build directory +function copyCode { + if [[ $(whereis -b rsync | awk '{print $2}') != "" ]]; then + rsync -aq ../ ${BUILD_DIR} --exclude=".git*" --exclude=builds --exclude-from=../.gitignore + else + echo "Cannot find `rsync`, which is required by this shell script" + exit 1 + fi +} + +# Set source code into build directory and enter into it +function setCodeInBuildEnv { + if [[ ${DIRTYBUILD} == '' ]]; then + detectChanges + fi + copyCode pushd "${BUILD_DIR}" } # Show usage function usage { echo "build-and-run-tests.sh usage:" + echo -e "-c\tCleanup" + echo -e "-d\tUse unsaved changes for build" echo -e "-f\tSelect flavor" + echo -e "-j\tDon't run tests after build" echo -e "-s\tSystemd version" - echo -e "-c\tCleanup" - echo -e "-x\tUse with '-c' to force cleanup on non-CI systems" echo -e "-u\tShow this message" + echo -e "-x\tUse with '-c' to force cleanup on non-CI systems" } # Prepare build environment @@ -247,7 +268,7 @@ function main { prepareBuildEnv cd builds - cloneCode + setCodeInBuildEnv if [ ${SRC_CHANGES} -gt 0 ]; then build From 49101417abd7c4aa910b3d7e89bcf96f5e7532fd Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 15 May 2016 18:50:22 -0700 Subject: [PATCH 0268/1304] rkt: handle symlink in calculateDataDir test Fixes TestCalculateDataDir failure triggered when /var/lib/rkt is a symlink. --- rkt/rkt_test.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/rkt/rkt_test.go b/rkt/rkt_test.go index cf3bda3f78..098b3f1d49 100644 --- a/rkt/rkt_test.go +++ b/rkt/rkt_test.go @@ -18,6 +18,7 @@ import ( "fmt" "io/ioutil" "os" + "path/filepath" "testing" "github.com/coreos/rkt/pkg/log" @@ -83,8 +84,17 @@ func TestCalculateDataDir(t *testing.T) { cachedConfig.Paths.DataDir = tc.configDataDir - if dataDir := calculateDataDir(); dataDir != tc.out { - t.Errorf("main.calculateDataDir() with setup %q, expected %q, got %q", tc, tc.out, dataDir) + realDataDir, err := filepath.EvalSymlinks(tc.out) + if err != nil { + if os.IsNotExist(err) { + realDataDir = tc.out + } else { + panic(fmt.Errorf("filepath.EvalSymlinks(%q) got error %q", tc.out, err)) + } + } + + if dataDir := calculateDataDir(); dataDir != realDataDir { + t.Errorf("main.calculateDataDir() with setup %q, expected %q, got %q", tc, realDataDir, dataDir) } resetConfigState() From f23b69d8bc7c122484c68ca9ca9ce5ee6c1b56cd Mon Sep 17 00:00:00 2001 From: Faraz Fazli Date: Mon, 16 May 2016 02:16:41 -0400 Subject: [PATCH 0269/1304] docs: fix duplicate word Fixes the word "network" appearing twice instead of once when explaining the default contained network argument. --- Documentation/subcommands/run.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/subcommands/run.md b/Documentation/subcommands/run.md index 36a43a3d69..77defacc1d 100644 --- a/Documentation/subcommands/run.md +++ b/Documentation/subcommands/run.md @@ -295,7 +295,7 @@ The `run` subcommand features the `--net` argument which takes options to config ### Default contained networking -When the argument is not given, `--net=default` is automatically assumed and the default contained network network will be loaded. +When the argument is not given, `--net=default` is automatically assumed and the default contained network will be loaded. ### Host networking From 5b6a3c4ad3770e57d909fd51a60ed1845df04829 Mon Sep 17 00:00:00 2001 From: Faraz Fazli Date: Mon, 16 May 2016 07:05:39 -0400 Subject: [PATCH 0270/1304] docs: updated Ubuntu link * Update Ubuntu link in docs * Update getting-started-ubuntu.md --- Documentation/getting-started-ubuntu.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/getting-started-ubuntu.md b/Documentation/getting-started-ubuntu.md index 2b53e27848..73bbaec11b 100644 --- a/Documentation/getting-started-ubuntu.md +++ b/Documentation/getting-started-ubuntu.md @@ -1,11 +1,11 @@ -# Getting Started with rkt on Ubuntu Vivid +# Getting Started with rkt on Ubuntu Wily -The following guide will show you how to build and run the sample [etcd ACI](https://github.com/coreos/etcd/releases/download/v2.0.9/etcd-v2.0.9-linux-amd64.aci) on the standard vagrantcloud.com [box for Ubuntu Vivid](https://vagrantcloud.com/ubuntu/boxes/vivid64). +The following guide will show you how to build and run the sample [etcd ACI](https://github.com/coreos/etcd/releases/download/v2.0.9/etcd-v2.0.9-linux-amd64.aci) on the standard vagrantcloud.com [box for Ubuntu Wily](https://vagrantcloud.com/ubuntu/boxes/wily64). -## Download and start an Ubuntu Vivid box +## Download and start an Ubuntu Wily box ``` -vagrant init ubuntu/vivid64 +vagrant init ubuntu/wily64 vagrant up --provider virtualbox ``` From 85236f894e681013c284e21c0457b2dcd0ed8fd1 Mon Sep 17 00:00:00 2001 From: Piotr Skamruk Date: Mon, 16 May 2016 13:48:58 +0200 Subject: [PATCH 0271/1304] kvm: fix logging network plugin type --- networking/kvm.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/networking/kvm.go b/networking/kvm.go index cf2a5ef4e5..55a8f611b9 100644 --- a/networking/kvm.go +++ b/networking/kvm.go @@ -143,7 +143,7 @@ func kvmSetupNetAddressing(network *Networking, n activeNet, ifName string) erro output, err := network.execNetPlugin("ADD", &n, ifName) n.conf.Type = original_type if err != nil { - return errwrap.Wrap(fmt.Errorf("problem executing network plugin %q (%q)", n.conf.Type, ifName), err) + return errwrap.Wrap(fmt.Errorf("problem executing network plugin %q (%q)", n.conf.IPAM.Type, ifName), err) } result := cnitypes.Result{} From f41e37d028eaf53f2d349a6a0850c6bdf0232006 Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Tue, 17 May 2016 11:56:01 +0200 Subject: [PATCH 0272/1304] MAINTAINERS: add Tamer Tas @tmrts --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 935b563112..b8303539e0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6,5 +6,6 @@ Jonathan Boulle (@jonboulle) Krzesimir Nowak (@krnowak) Sergiusz Urbaniak (@s-urbaniak) Stefan Junker (@steveeJ) +Tamer Tas (@tmrts) Vito Caputo (@vcaputo) Yifan Gu (@yifan-gu) From 129d3ade49f612d35d54c951ce6fef5d29ed5831 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 17 May 2016 13:01:45 +0200 Subject: [PATCH 0273/1304] docs: improve CONTRIBUTING and test docs (#2637) * docs: improve CONTRIBUTING and test docs Some links were outdated and ./configure is not available w/o ./autogen.sh * docs: split "manually running the tests" to a section each type --- CONTRIBUTING.md | 4 ++-- tests/README.md | 26 +++++++++++++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 868581b8bf..f60d2daf39 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,7 +25,7 @@ are very busy and read the mailing lists. ### Getting Started - Fork the repository on GitHub -- Read the [README](README.md) for build and test instructions +- Read [`building rkt`](Documentation/hacking.md#building-rkt) for build and [`manually-running-the-tests`](tests/README.md#manually-running-the-tests) for test instructions - Play with the project, submit bugs, submit patches! ### Contribution Flow @@ -36,7 +36,7 @@ This is a rough outline of what a contributor's workflow looks like: - Make commits of logical units. - Make sure your commit messages are in the proper format (see below). - Push your changes to a topic branch in your fork of the repository. -- Make sure the tests pass, and add any new tests as appropriate. +- Make sure the [tests](tests/README.md#manually-running-the-tests) pass, and add any new tests as appropriate. - Submit a pull request to the original repository. - Submit a comment with the sole content "@reviewer PTAL" (please take a look) in GitHub and replace "@reviewer" with the correct recipient. diff --git a/tests/README.md b/tests/README.md index b05a09199c..b449e3b227 100644 --- a/tests/README.md +++ b/tests/README.md @@ -77,20 +77,32 @@ The build script has the following parameters: Select `Ubuntu 14.04 LTS v1503 (beta with Docker support)`. The platform with *Docker support* means the tests will run in a VM. -## Manually running the functional tests +## Manually running the tests -Make sure to pass `--enable-functional-tests` to the configure script, then, after building the project, you can run the tests. +The tests can be run manually. There is a rule to run unit, functional and all tests. + +### Unit tests + +The unit tests can be run with `make unit-check` after you [built](../Documentation/hacking.md#building-rkt) the project. + +### Functional tests + +The functional tests require to pass `--enable-functional-tests` to the configure script, then, after building the project, you can run the tests. ``` +./autogen.sh ./configure --enable-functional-tests make -j4 -make check +make functional-check ``` -For more details about the `--enable-functional-tests` parameter, see [configure script parameters documentation](build-configure.md). -The snippet above will run both unit and functional tests. -If you want to run only functional tests, use `make functional-check`. -There is also a counterpart target for running unit tests only - it is named `unit-check`. +For more details about the `--enable-functional-tests` parameter, see [configure script parameters documentation](../Documentation/build-configure.md#--enable-functional-tests). + +### All tests + +To run all tests, see [functional tests](./README.md#functional-tests) to configure and build it with functional tests enabled. Instead of `make functional-check` you have to call `make check` to run all tests. + +### Passing additional parameters You can use a `GO_TEST_FUNC_ARGS` variable to pass additional parameters to `go test`. This is mostly useful for running only the selected functional tests. From 9048b3d2a98a6f87406b8437d50f69c6a0ce09fe Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Tue, 17 May 2016 12:57:09 +0200 Subject: [PATCH 0274/1304] tests: update pattern to skip more doc/img files This commit adds more patterns to DOC_CHANGE_PATTERN, skipping testing on image changes and more top-level files. Closes #2642 Signed-off-by: Luca Bruno --- tests/build-and-run-tests.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/build-and-run-tests.sh b/tests/build-and-run-tests.sh index 643fe18739..e9d429851c 100755 --- a/tests/build-and-run-tests.sh +++ b/tests/build-and-run-tests.sh @@ -234,8 +234,10 @@ function main { DOC_CHANGE_PATTERN="\ -e ^Documentation/ \ - -e ^(README|ROADMAP|CONTRIBUTING|CHANGELOG)$ \ + -e ^logos/ \ + -e ^(MAINTAINERS|LICENSE|DCO)$ \ -e \.md$\ + -e \.(jpeg|jpg|png|svg)$\ " buildFolder From e4b5ae6b8ffc03108596011bb731eab7117a2b81 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Tue, 17 May 2016 15:47:50 +0200 Subject: [PATCH 0275/1304] build: fix `manpages` and `bash-completion` targets This commit fixes `manpages` and `bash-completion` targets, passing go-related variables to build commands. Closes #2494 --- rkt/rkt.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rkt/rkt.mk b/rkt/rkt.mk index bbcb67b839..e04e893dbd 100644 --- a/rkt/rkt.mk +++ b/rkt/rkt.mk @@ -31,11 +31,11 @@ include makelib/build_go_bin.mk manpages: | $(GOPATH_TO_CREATE)/src/$(REPO_PATH) mkdir -p dist/manpages/ - ls rkt/*.go | grep -vE '_test.go|main.go|_gen.go' | xargs go run rkt/manpages_gen.go + ls rkt/*.go | grep -vE '_test.go|main.go|_gen.go' | $(GO_ENV) xargs "$(GO)" run rkt/manpages_gen.go bash-completion: | $(GOPATH_TO_CREATE)/src/$(REPO_PATH) mkdir -p dist/bash_completion/ - ls rkt/*.go | grep -vE '_test.go|main.go|_gen.go' | xargs go run rkt/bash_completion_gen.go + ls rkt/*.go | grep -vE '_test.go|main.go|_gen.go' | $(GO_ENV) xargs "$(GO)" run rkt/bash_completion_gen.go protobuf: scripts/genproto.sh From e9fb3a6ae6a98adcb8e97d9f90d665414bc9487c Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Tue, 17 May 2016 15:55:34 +0200 Subject: [PATCH 0276/1304] build: git ignore `dist` directory `dist` directory contains build artifacts generated by `manpages`, `bash-completion` and other build targets. Not relevant for source versioning, ignoring. --- .gitignore | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 7c94a463e9..c432aeeeb2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,14 @@ *~ +.vagrant +/.config.args /Makefile +/acbuild /autom4te.cache +/build-rir* +/build-rkt* /config.log /config.status -/.config.args /configure -/build-rkt* -/build-rir* -.vagrant +/dist /tags -/acbuild From 4def159eb9fabc47e397da349e27a0328e1dfa27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Tue, 17 May 2016 13:02:01 +0200 Subject: [PATCH 0277/1304] stage1/init: work around cgroup/SCM_CREDENTIALS race There's a race[1][1] on systemd that causes the systemd unit name not getting written to the journal for short-lived non-root services. To provide a way to identify an app within a pod in the logs, we set `SyslogIdentifierp` to the app name as a workaround. This causes processes forked by the app and pre/post start hooks to be identified as the app, but it was already happening before we removed appexec[2][2] with the binary exec'd by the app instead of the app name. In theory we could remove that and we'll get the binary name of each process executed in the pod as the syslog identifier, but then this workaround would not *work*. Setting the app name as the identifier is already an improvement over the previous situation. [1]: https://github.com/systemd/systemd/issues/2913 [2]: https://github.com/coreos/rkt/pull/2493 --- stage1/init/common/pod.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index 0f5db3808e..3dad4c9bc9 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -447,6 +447,11 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b unit.NewUnitOption("Service", "Group", strconv.Itoa(g)), unit.NewUnitOption("Service", "SupplementaryGroups", strings.Join(supplementaryGroups, " ")), unit.NewUnitOption("Service", "CapabilityBoundingSet", strings.Join(capabilitiesStr, " ")), + // This helps working around a race + // (https://github.com/systemd/systemd/issues/2913) that causes the + // systemd unit name not getting written to the journal if the unit is + // short-lived and runs as non-root. + unit.NewUnitOption("Service", "SyslogIdentifier", appName.String()), } if ra.ReadOnlyRootFS { @@ -487,7 +492,6 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b } else { opts = append(opts, unit.NewUnitOption("Service", "StandardOutput", "journal+console")) opts = append(opts, unit.NewUnitOption("Service", "StandardError", "journal+console")) - opts = append(opts, unit.NewUnitOption("Service", "SyslogIdentifier", filepath.Base(app.Exec[0]))) } // When an app fails, we shut down the pod From 828db6e8ee985e44d6f535dbf2bbf147c81b01d2 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Tue, 17 May 2016 17:23:39 +0200 Subject: [PATCH 0278/1304] tests: increase timeout from 30min to 45min We added more tests recently, such as TestCapsSeveralApp. --- tests/functional.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional.mk b/tests/functional.mk index 73cb535c0e..e90d8d6c42 100644 --- a/tests/functional.mk +++ b/tests/functional.mk @@ -79,7 +79,7 @@ $(call forward-vars,$(FTST_FUNCTIONAL_TESTS_STAMP), \ $(FTST_FUNCTIONAL_TESTS_STAMP): $(FTST_IMAGE) $(FTST_EMPTY_IMAGE) $(ACTOOL_STAMP) $(RKT_STAMP) $(FTST_ACE_MAIN_IMAGE) $(FTST_ACE_SIDEKICK_IMAGE) $(FTST_SS1_STAMP) | $(FTST_TEST_TMP) $(FTST_RKT_PATH) $(FTST_STAGE1_ALL_FLAVOR_SYMLINKS) $(VQ) \ $(call vb,vt,GO TEST,$(REPO_PATH)/tests) \ - sudo RKT_STAGE1_DEFAULT_FLAVOR="$(RKT_STAGE1_DEFAULT_FLAVOR)" RKT="$(FTST_RKT_PATH)" ACTOOL="$(ACTOOL)" RKT_INSPECT_IMAGE="$(FTST_IMAGE)" RKT_EMPTY_IMAGE="$(FTST_EMPTY_IMAGE)" RKT_ACE_MAIN_IMAGE=$(FTST_ACE_MAIN_IMAGE) RKT_ACE_SIDEKICK_IMAGE=$(FTST_ACE_SIDEKICK_IMAGE) FUNCTIONAL_TMP="$(FTST_TEST_TMP)" INSPECT_BINARY="$(FTST_INSPECT_BINARY)" STUB_STAGE1="$(FTST_SS1_IMAGE)" $(GO_ENV) "$(ABS_GO)" test -tags $(RKT_STAGE1_DEFAULT_FLAVOR) -timeout 30m -v $(GO_TEST_FUNC_ARGS) $(REPO_PATH)/tests + sudo RKT_STAGE1_DEFAULT_FLAVOR="$(RKT_STAGE1_DEFAULT_FLAVOR)" RKT="$(FTST_RKT_PATH)" ACTOOL="$(ACTOOL)" RKT_INSPECT_IMAGE="$(FTST_IMAGE)" RKT_EMPTY_IMAGE="$(FTST_EMPTY_IMAGE)" RKT_ACE_MAIN_IMAGE=$(FTST_ACE_MAIN_IMAGE) RKT_ACE_SIDEKICK_IMAGE=$(FTST_ACE_SIDEKICK_IMAGE) FUNCTIONAL_TMP="$(FTST_TEST_TMP)" INSPECT_BINARY="$(FTST_INSPECT_BINARY)" STUB_STAGE1="$(FTST_SS1_IMAGE)" $(GO_ENV) "$(ABS_GO)" test -tags $(RKT_STAGE1_DEFAULT_FLAVOR) -timeout 45m -v $(GO_TEST_FUNC_ARGS) $(REPO_PATH)/tests $(call forward-vars,$(FTST_IMAGE), \ FTST_IMAGE_ROOTFSDIR ACTOOL FTST_IMAGE_DIR) From 78091ebc0f2452bb03485c680bae15ee824752bb Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Wed, 18 May 2016 10:07:22 +0200 Subject: [PATCH 0279/1304] build: only ignore specific sub-directories in `dist` Refine `.gitignore` to only ignore bash_completion and manpages artifacts. Reinstate the toplevel `dist` directory, as it contains some other tracked data. --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c432aeeeb2..bda6043d3a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,5 +10,6 @@ /config.log /config.status /configure -/dist +/dist/bash_completion +/dist/manpages /tags From a9550dd44c474898aa1ee34e5b035d61de58ce13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20J=2E=20=C5=81akis?= Date: Tue, 17 May 2016 16:11:38 +0200 Subject: [PATCH 0280/1304] Transforming flannel network in kvmTeardown --- networking/kvm.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/networking/kvm.go b/networking/kvm.go index cf2a5ef4e5..f8af5b5bc8 100644 --- a/networking/kvm.go +++ b/networking/kvm.go @@ -569,6 +569,13 @@ extend Networking struct with methods to clean up kvm specific network configura // removing tuntap interface and releasing its ip from IPAM plugin func (n *Networking) teardownKvmNets() { for _, an := range n.nets { + if an.conf.Type == "flannel" { + if err := kvmTransformFlannelNetwork(&an); err != nil { + stderr.PrintE("error transforming flannel network", err) + continue + } + } + switch an.conf.Type { case "ptp", "bridge": // remove tuntap interface From 6d57e40ec909824cc1be5207e1b816c580f7fc70 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Wed, 18 May 2016 11:06:40 +0200 Subject: [PATCH 0281/1304] build: fix building on non-English locales `depsgen` works on file lists and globs, consuming `stat` output to calculate dependencies. This commit adds an explicit C locale setting to avoid build failures on non-English locales. --- tools/depsgen/globcmd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/depsgen/globcmd.go b/tools/depsgen/globcmd.go index 7a66751249..a54bd22b72 100644 --- a/tools/depsgen/globcmd.go +++ b/tools/depsgen/globcmd.go @@ -31,7 +31,7 @@ const ( // given set of wildcards. See globMakeWildcard. globMakeFunction = `$(strip \ $(eval _DEPS_GEN_FG_ := $(strip !!!WILDCARDS!!!)) \ - $(if $(_DEPS_GEN_FG_),$(shell stat --format "%n: %F" $(_DEPS_GEN_FG_) | grep -e 'regular file$$' | cut -f1 -d:))) + $(if $(_DEPS_GEN_FG_),$(shell LC_ALL=C stat --format "%n: %F" $(_DEPS_GEN_FG_) | grep -e 'regular file$$' | cut -f1 -d:))) ` // globMakeWildcard is a template for call wildcard function // for in a given directory with a given suffix. This wildcard From a78ad02dc663ed3c9b591577d926544c15c64876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 18 May 2016 10:12:26 +0200 Subject: [PATCH 0282/1304] Documentation: document per-app logs Also, update logs examples. --- Documentation/commands.md | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Documentation/commands.md b/Documentation/commands.md index 4786242554..3c6258b5a0 100644 --- a/Documentation/commands.md +++ b/Documentation/commands.md @@ -92,7 +92,7 @@ To read the logs of a running pod, get the pod's machine name from `machinectl`: ``` $ machinectl MACHINE CLASS SERVICE -rkt-132f9d56-0e3f-4d1e-ba86-68efd488bb62 container nspawn +rkt-bc3c1451-2e81-45c6-aeb0-807db44e31b4 container rkt 1 machines listed. ``` @@ -100,16 +100,27 @@ rkt-132f9d56-0e3f-4d1e-ba86-68efd488bb62 container nspawn or `rkt list --full` ``` -# rkt list --full -UUID APP IMAGE NAME IMAGE ID STATE NETWORKS -132f9d56-0e3f-4d1e-ba86-68efd488bb62 etcd coreos.com/etcd:v2.0.10 sha512-c03b055d02e5 running +$ rkt list --full +UUID APP IMAGE NAME IMAGE ID STATE CREATED STARTED NETWORKS +bc3c1451-2e81-45c6-aeb0-807db44e31b4 etcd coreos.com/etcd:v2.3.4 sha512-7f05a10f6d2c running 2016-05-18 10:07:35.312 +0200 CEST 2016-05-18 10:07:35.405 +0200 CEST default:ip4=172.16.28.83 + redis registry-1.docker.io/library/redis:3.2 sha512-6eaaf936bc76 ``` The pod's machine name will be the pod's UUID prefixed with `rkt-`. Given this machine name, logs can be retrieved by `journalctl`: ``` -# journalctl -M rkt-132f9d56-0e3f-4d1e-ba86-68efd488bb62 +$ journalctl -M rkt-bc3c1451-2e81-45c6-aeb0-807db44e31b4 +[...] +``` + +To get logs from one app in the pod: +``` +$ journalctl -M rkt-bc3c1451-2e81-45c6-aeb0-807db44e31b4 -t etcd +[...] +$ journalctl -M rkt-bc3c1451-2e81-45c6-aeb0-807db44e31b4 -t redis [...] ``` + +Additionaly, logs can be programmatically accessed via the [sd-journal API](https://www.freedesktop.org/software/systemd/man/sd-journal.html). From 9732ab555cacc014821839f0938cfcf6988da3e5 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Wed, 18 May 2016 14:22:57 +0200 Subject: [PATCH 0283/1304] tests/config: implement functional tests This commit introduces functional tests for the config subcommand. Fixes partially #2410 --- tests/rkt_api_service_test.go | 1 + tests/rkt_auth_test.go | 37 +-- tests/rkt_config_test.go | 483 ++++++++++++++++++++++++++++++++++ tests/rkt_tests.go | 48 ++++ tests/testutils/ctx.go | 5 + 5 files changed, 547 insertions(+), 27 deletions(-) create mode 100644 tests/rkt_config_test.go diff --git a/tests/rkt_api_service_test.go b/tests/rkt_api_service_test.go index fe41f42aec..201de5017d 100644 --- a/tests/rkt_api_service_test.go +++ b/tests/rkt_api_service_test.go @@ -301,6 +301,7 @@ func TestAPIServiceGetInfo(t *testing.T) { Dir: ctx.DataDir(), SystemConfigDir: ctx.SystemDir(), LocalConfigDir: ctx.LocalDir(), + UserConfigDir: ctx.UserDir(), InsecureFlags: "none", } if !reflect.DeepEqual(resp.Info.GlobalFlags, expectedGlobalFlags) { diff --git a/tests/rkt_auth_test.go b/tests/rkt_auth_test.go index e1e28b03d6..f4c1c49e24 100644 --- a/tests/rkt_auth_test.go +++ b/tests/rkt_auth_test.go @@ -18,7 +18,6 @@ package main import ( "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -91,9 +90,9 @@ func testAuthGeneric(t *testing.T, auth taas.AuthType, tests []genericAuthTest) case authConfDirNone: // no config to write case authConfDirLocal: - writeConfig(t, ctx.LocalDir(), "test.json", server.Conf) + writeConfig(t, authDir(ctx.LocalDir()), "test.json", server.Conf) case authConfDirSystem: - writeConfig(t, ctx.SystemDir(), "test.json", server.Conf) + writeConfig(t, authDir(ctx.SystemDir()), "test.json", server.Conf) default: panic("Wrong config directory") } @@ -118,9 +117,9 @@ func TestAuthOverride(t *testing.T) { {getInvalidOAuthConfig(server.Conf), server.Conf, "invalid-system-valid-local", authFailedDownload, authSuccessfulDownload}, } for _, tt := range tests { - writeConfig(t, ctx.SystemDir(), "test.json", tt.systemConfig) + writeConfig(t, authDir(ctx.SystemDir()), "test.json", tt.systemConfig) expectedRunRkt(ctx, t, server.URL, tt.name+"-1", tt.resultBeforeOverride) - writeConfig(t, ctx.LocalDir(), "test.json", tt.localConfig) + writeConfig(t, authDir(ctx.LocalDir()), "test.json", tt.localConfig) expectedRunRkt(ctx, t, server.URL, tt.name+"-2", tt.resultAfterOverride) ctx.Reset() } @@ -136,10 +135,10 @@ func TestAuthIgnore(t *testing.T) { func testAuthIgnoreBogusFiles(t *testing.T, server *taas.Server) { ctx := testutils.NewRktRunCtx() defer ctx.Cleanup() - writeConfig(t, ctx.SystemDir(), "README", "This is system config") - writeConfig(t, ctx.LocalDir(), "README", "This is local config") - writeConfig(t, ctx.SystemDir(), "test.notjson", server.Conf) - writeConfig(t, ctx.LocalDir(), "test.notjson", server.Conf) + writeConfig(t, authDir(ctx.SystemDir()), "README", "This is system config") + writeConfig(t, authDir(ctx.LocalDir()), "README", "This is local config") + writeConfig(t, authDir(ctx.SystemDir()), "test.notjson", server.Conf) + writeConfig(t, authDir(ctx.LocalDir()), "test.notjson", server.Conf) expectedRunRkt(ctx, t, server.URL, "oauth-bogus-files", authFailedDownload) } @@ -148,8 +147,8 @@ func testAuthIgnoreSubdirectories(t *testing.T, server *taas.Server) { defer ctx.Cleanup() localSubdir := filepath.Join(ctx.LocalDir(), "subdir") systemSubdir := filepath.Join(ctx.SystemDir(), "subdir") - writeConfig(t, localSubdir, "test.json", server.Conf) - writeConfig(t, systemSubdir, "test.json", server.Conf) + writeConfig(t, authDir(localSubdir), "test.json", server.Conf) + writeConfig(t, authDir(systemSubdir), "test.json", server.Conf) expectedRunRkt(ctx, t, server.URL, "oauth-subdirectories", authFailedDownload) } @@ -194,22 +193,6 @@ func expectedRunRkt(ctx *testutils.RktRunCtx, t *testing.T, host, testName, line } } -func writeConfig(t *testing.T, baseDir, filename, contents string) { - dir := authDir(baseDir) - if err := os.MkdirAll(dir, 0755); err != nil { - t.Fatalf("Failed to create config directory %q: %v", dir, err) - } - path := filepath.Join(dir, filename) - os.Remove(path) - if err := ioutil.WriteFile(path, []byte(contents), 0644); err != nil { - t.Fatalf("Failed to write file %q: %v", path, err) - } -} - -func authDir(confDir string) string { - return filepath.Join(confDir, "auth.d") -} - func getInvalidOAuthConfig(conf string) string { return strings.Replace(conf, "sometoken", "someobviouslywrongtoken", 1) } diff --git a/tests/rkt_config_test.go b/tests/rkt_config_test.go new file mode 100644 index 0000000000..00a85e91fa --- /dev/null +++ b/tests/rkt_config_test.go @@ -0,0 +1,483 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build host coreos src kvm + +package main + +import ( + "encoding/json" + "fmt" + "reflect" + "testing" + + "github.com/coreos/rkt/tests/testutils" +) + +type basic struct { + User string `json:"user"` + Password string `json:"password"` +} + +type oauth struct { + Token string `json:"token"` +} + +type credentials struct { + *basic + *oauth +} + +type auth struct { + Type string `json:"type,omitempty"` + Registries []string `json:"registries,omitempty"` + Domains []string `json:"domains,omitempty"` + Credentials credentials `json:"credentials"` +} + +type paths struct { + Data string `json:"data,omitempty"` + Stage1Images string `json:"stage1-images,omitempty"` +} + +type stage1 struct { + Name string `json:"name,omitempty"` + Version string `json:"version,omitempty"` + Location string `json:"location,omitempty"` +} + +type cfg struct { + *auth + *paths + *stage1 + + RktVersion string `json:"rktVersion"` + RktKind string `json:"rktKind"` +} + +type stageCfg struct { + Stage0 []cfg `json:"stage0"` +} + +func (s stageCfg) search(x cfg) int { + var c cfg + var i int + + for i, c = range s.Stage0 { + if reflect.DeepEqual(c, x) { + return i + } + } + + return -1 +} + +func TestConfig(t *testing.T) { + for i, tt := range []struct { + configFunc func(*testutils.RktRunCtx) + expected []cfg + }{ + { // one auth domain + configFunc: func(ctx *testutils.RktRunCtx) { + writeConfig(t, authDir(ctx.LocalDir()), "basic.json", mustMarshalJSON( + cfg{ + RktVersion: "v1", + RktKind: "auth", + auth: &auth{ + Type: "basic", + Domains: []string{"coreos.com"}, + Credentials: credentials{ + basic: &basic{"user", "userPassword"}, + }, + }, + }, + )) + }, + expected: []cfg{ + { + RktVersion: "v1", + RktKind: "auth", + auth: &auth{ + Type: "basic", + Domains: []string{"coreos.com"}, + Credentials: credentials{ + basic: &basic{"user", "userPassword"}, + }, + }, + }, + }, + }, + + { // one docker auth registry + configFunc: func(ctx *testutils.RktRunCtx) { + writeConfig(t, authDir(ctx.LocalDir()), "docker.json", mustMarshalJSON( + cfg{ + RktVersion: "v1", + RktKind: "dockerAuth", + auth: &auth{ + Registries: []string{"quay.io"}, + Credentials: credentials{ + basic: &basic{"docker", "dockerPassword"}, + }, + }, + }, + )) + }, + expected: []cfg{ + { + RktVersion: "v1", + RktKind: "dockerAuth", + auth: &auth{ + Registries: []string{"quay.io"}, + Credentials: credentials{ + basic: &basic{"docker", "dockerPassword"}, + }, + }, + }, + }, + }, + + { // one paths entry + configFunc: func(ctx *testutils.RktRunCtx) { + writeConfig(t, pathsDir(ctx.LocalDir()), "paths.json", mustMarshalJSON( + cfg{ + RktVersion: "v1", + RktKind: "paths", + paths: &paths{ + Data: "/home/me/rkt/data", + Stage1Images: "/home/me/rkt/stage1-images", + }, + }, + )) + }, + expected: []cfg{ + { + RktVersion: "v1", + RktKind: "paths", + paths: &paths{ + Data: "/home/me/rkt/data", + Stage1Images: "/home/me/rkt/stage1-images", + }, + }, + }, + }, + + { // overwrite paths entry in user dir + configFunc: func(ctx *testutils.RktRunCtx) { + writeConfig(t, pathsDir(ctx.SystemDir()), "paths.json", mustMarshalJSON( + cfg{ + RktVersion: "v1", + RktKind: "paths", + paths: &paths{ + Data: "/usr/lib/rkt/data", + Stage1Images: "/usr/lib/rkt/stage1-images", + }, + }, + )) + writeConfig(t, pathsDir(ctx.UserDir()), "paths.json", mustMarshalJSON( + cfg{ + RktVersion: "v1", + RktKind: "paths", + paths: &paths{ + Data: "/home/me/rkt/data", + }, + }, + )) + }, + expected: []cfg{ + { + RktVersion: "v1", + RktKind: "paths", + paths: &paths{ + Data: "/home/me/rkt/data", + Stage1Images: "/usr/lib/rkt/stage1-images", + }, + }, + }, + }, + + { // one stage1 entry + configFunc: func(ctx *testutils.RktRunCtx) { + writeConfig(t, stage1Dir(ctx.LocalDir()), "stage1.json", mustMarshalJSON( + cfg{ + RktVersion: "v1", + RktKind: "stage1", + stage1: &stage1{ + Name: "example.com/rkt/stage1", + Version: "1.2.3", + Location: "http://example.com/download/stage1.aci", + }, + }, + )) + }, + expected: []cfg{ + { + RktVersion: "v1", + RktKind: "stage1", + stage1: &stage1{ + Name: "example.com/rkt/stage1", + Version: "1.2.3", + Location: "http://example.com/download/stage1.aci", + }, + }, + }, + }, + + { // overwrite stage1 entry + configFunc: func(ctx *testutils.RktRunCtx) { + writeConfig(t, stage1Dir(ctx.LocalDir()), "stage1.json", mustMarshalJSON( + cfg{ + RktVersion: "v1", + RktKind: "stage1", + stage1: &stage1{ + Name: "example.com/rkt/stage1", + Version: "1.2.3", + Location: "http://example.com/download/stage1.aci", + }, + }, + )) + writeConfig(t, stage1Dir(ctx.UserDir()), "stage1.json", mustMarshalJSON( + cfg{ + RktVersion: "v1", + RktKind: "stage1", + stage1: &stage1{ + Location: "http://localhost:8080/stage1.aci", + }, + }, + )) + }, + expected: []cfg{ + { + RktVersion: "v1", + RktKind: "stage1", + stage1: &stage1{ + Name: "example.com/rkt/stage1", + Version: "1.2.3", + Location: "http://localhost:8080/stage1.aci", + }, + }, + }, + }, + + { // two auth domains, two docker registries + configFunc: func(ctx *testutils.RktRunCtx) { + writeConfig(t, authDir(ctx.UserDir()), "basic.json", mustMarshalJSON( + cfg{ + RktVersion: "v1", + RktKind: "auth", + auth: &auth{ + Type: "basic", + Domains: []string{"tectonic.com", "coreos.com"}, + Credentials: credentials{ + basic: &basic{"user", "userPassword"}, + }, + }, + }, + )) + writeConfig(t, authDir(ctx.UserDir()), "docker.json", mustMarshalJSON( + cfg{ + RktVersion: "v1", + RktKind: "dockerAuth", + auth: &auth{ + Registries: []string{"quay.io", "gcr.io"}, + Credentials: credentials{ + basic: &basic{"docker", "dockerPassword"}, + }, + }, + }, + )) + }, + expected: []cfg{ + { + RktVersion: "v1", + RktKind: "auth", + auth: &auth{ + Type: "basic", + Domains: []string{"tectonic.com"}, + Credentials: credentials{ + basic: &basic{"user", "userPassword"}, + }, + }, + }, + { + RktVersion: "v1", + RktKind: "auth", + auth: &auth{ + Type: "basic", + Domains: []string{"coreos.com"}, + Credentials: credentials{ + basic: &basic{"user", "userPassword"}, + }, + }, + }, + { + RktVersion: "v1", + RktKind: "dockerAuth", + auth: &auth{ + Registries: []string{"quay.io"}, + Credentials: credentials{ + basic: &basic{"docker", "dockerPassword"}, + }, + }, + }, + { + RktVersion: "v1", + RktKind: "dockerAuth", + auth: &auth{ + Registries: []string{"gcr.io"}, + Credentials: credentials{ + basic: &basic{"docker", "dockerPassword"}, + }, + }, + }, + }, + }, + + { // overwrite one auth domain, one dockerAuth registry in user dir + configFunc: func(ctx *testutils.RktRunCtx) { + writeConfig(t, authDir(ctx.SystemDir()), "basic.json", mustMarshalJSON( + cfg{ + RktVersion: "v1", + RktKind: "auth", + auth: &auth{ + Type: "basic", + Domains: []string{"tectonic.com", "coreos.com"}, + Credentials: credentials{ + basic: &basic{"user", "userPassword"}, + }, + }, + }, + )) + + writeConfig(t, authDir(ctx.UserDir()), "basic.json", mustMarshalJSON( + cfg{ + RktVersion: "v1", + RktKind: "auth", + auth: &auth{ + Type: "oauth", + Domains: []string{"tectonic.com"}, + Credentials: credentials{ + oauth: &oauth{"someToken"}, + }, + }, + }, + )) + + writeConfig(t, authDir(ctx.SystemDir()), "docker.json", mustMarshalJSON( + cfg{ + RktVersion: "v1", + RktKind: "dockerAuth", + auth: &auth{ + Registries: []string{"quay.io", "gcr.io"}, + Credentials: credentials{ + basic: &basic{"docker", "dockerPassword"}, + }, + }, + }, + )) + + writeConfig(t, authDir(ctx.UserDir()), "docker.json", mustMarshalJSON( + cfg{ + RktVersion: "v1", + RktKind: "dockerAuth", + auth: &auth{ + Registries: []string{"gcr.io"}, + Credentials: credentials{ + basic: &basic{"over", "written"}, + }, + }, + }, + )) + }, + expected: []cfg{ + { + RktVersion: "v1", + RktKind: "auth", + auth: &auth{ + Type: "oauth", + Domains: []string{"tectonic.com"}, + Credentials: credentials{ + oauth: &oauth{"someToken"}, + }, + }, + }, + { + RktVersion: "v1", + RktKind: "auth", + auth: &auth{ + Type: "basic", + Domains: []string{"coreos.com"}, + Credentials: credentials{ + basic: &basic{"user", "userPassword"}, + }, + }, + }, + { + RktVersion: "v1", + RktKind: "dockerAuth", + auth: &auth{ + Registries: []string{"quay.io"}, + Credentials: credentials{ + basic: &basic{"docker", "dockerPassword"}, + }, + }, + }, + { + RktVersion: "v1", + RktKind: "dockerAuth", + auth: &auth{ + Registries: []string{"gcr.io"}, + Credentials: credentials{ + basic: &basic{"over", "written"}, + }, + }, + }, + }, + }, + } { + func() { + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + tt.configFunc(ctx) + + rktCmd := ctx.Cmd() + " --debug --insecure-options=image config" + out, status := runRkt(t, rktCmd, nobodyUid, 0) + + if status != 0 { + panic(fmt.Errorf("test %d: expected exit status code 0, got %d", i, status)) + } + + var got stageCfg + if err := json.Unmarshal([]byte(out), &got); err != nil { + panic(err) + } + + for ii, e := range tt.expected { + if got.search(e) < 0 { + t.Errorf("test %d, expected to find config %d but didn't", i, ii) + } + } + }() + } +} + +func mustMarshalJSON(data interface{}) string { + buf, err := json.Marshal(data) + if err != nil { + panic(err) + } + + return string(buf) +} diff --git a/tests/rkt_tests.go b/tests/rkt_tests.go index 09f3fc878d..93d1670594 100644 --- a/tests/rkt_tests.go +++ b/tests/rkt_tests.go @@ -312,6 +312,31 @@ func runRktAsUidGidAndCheckOutput(t *testing.T, rktCmd, expectedLine string, exp } } +func runRkt(t *testing.T, rktCmd string, uid, gid int) (string, int) { + child, err := gexpect.Command(rktCmd) + if err != nil { + t.Fatalf("cannot exec rkt: %v", err) + } + if gid != 0 { + child.Cmd.SysProcAttr = &syscall.SysProcAttr{} + child.Cmd.SysProcAttr.Credential = &syscall.Credential{Uid: uint32(uid), Gid: uint32(gid)} + } + + err = child.Start() + if err != nil { + t.Fatalf("cannot start rkt: %v", err) + } + + _, linesChan := child.AsyncInteractChannels() + + var buf bytes.Buffer + for line := range linesChan { + buf.WriteString(line + "\n") // reappend newline + } + + return buf.String(), getExitStatus(child.Wait()) +} + func startRktAsGidAndCheckOutput(t *testing.T, rktCmd, expectedLine string, gid int) *gexpect.ExpectSubprocess { child, err := gexpect.Command(rktCmd) if err != nil { @@ -733,3 +758,26 @@ func checkUserNS() error { // Check if it really works return exec.Command("/bin/bash", "-c", "unshare -U true").Run() } + +func authDir(confDir string) string { + return filepath.Join(confDir, "auth.d") +} + +func pathsDir(confDir string) string { + return filepath.Join(confDir, "paths.d") +} + +func stage1Dir(confDir string) string { + return filepath.Join(confDir, "stage1.d") +} + +func writeConfig(t *testing.T, dir, filename, contents string) { + if err := os.MkdirAll(dir, 0755); err != nil { + t.Fatalf("Failed to create config directory %q: %v", dir, err) + } + path := filepath.Join(dir, filename) + os.Remove(path) + if err := ioutil.WriteFile(path, []byte(contents), 0644); err != nil { + t.Fatalf("Failed to write file %q: %v", path, err) + } +} diff --git a/tests/testutils/ctx.go b/tests/testutils/ctx.go index 5174cf76e0..65c969acc2 100644 --- a/tests/testutils/ctx.go +++ b/tests/testutils/ctx.go @@ -96,6 +96,7 @@ func NewRktRunCtx() *RktRunCtx { newDirDesc("datadir-", "data", "dir"), newDirDesc("localdir-", "local configuration", "local-config"), newDirDesc("systemdir-", "system configuration", "system-config"), + newDirDesc("userdir-", "user configuration", "user-config"), }, } } @@ -121,6 +122,10 @@ func (ctx *RktRunCtx) SystemDir() string { return ctx.dir(2) } +func (ctx *RktRunCtx) UserDir() string { + return ctx.dir(3) +} + func (ctx *RktRunCtx) dir(idx int) string { ctx.ensureValid() if idx < len(ctx.directories) { From f6372a067cb0a301a66e1a2a5c63c271b2fc90e6 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Wed, 18 May 2016 14:36:14 -0700 Subject: [PATCH 0284/1304] stage1: update CoreOS image signing key --- stage1/usr_from_coreos/cache.sh | 102 ++++++++++++++++++++++++-------- 1 file changed, 77 insertions(+), 25 deletions(-) diff --git a/stage1/usr_from_coreos/cache.sh b/stage1/usr_from_coreos/cache.sh index f0b0552f1d..15fbfd5fcd 100755 --- a/stage1/usr_from_coreos/cache.sh +++ b/stage1/usr_from_coreos/cache.sh @@ -11,6 +11,13 @@ if [ ${V} -eq 3 ]; then fi # coreos gpg signing key +# pub 4096R/93D2DCB4 2013-09-06 +# uid [ unknown] CoreOS Buildbot (Offical Builds) +# sub 4096R/74E7E361 2013-09-06 [expired: 2014-09-06] +# sub 4096R/E5676EFC 2014-09-08 [expired: 2015-09-08] +# sub 4096R/1CB5FA26 2015-08-31 [expires: 2017-08-30] +# sub 4096R/B58844F1 2015-11-20 [revoked: 2016-05-16] +# sub 4096R/2E16137F 2016-05-16 [expires: 2017-05-16] GPG_LONG_ID="50E0885593D2DCB4" GPG_KEY="-----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v2 @@ -162,31 +169,76 @@ VGQ9BcAh8oxz1QcPQXr7TCk8+cikSemQrVmqJPq2rvdVpZIzF91ZCpAfT28e0y/a DxbrfS83Ytk+90dQOR8rStGNVnrwT/LeMn1ytV7oK8e2sIj1HFUYENQxy5jVjR3Q tcTbVoOYLvZ83/wanc4GaZnxZ7cJguuKFdqCR5kq4b7acjeQ8a76hrYI57Z+5JDs L+aOgGfCqCDx2IL/bRiwY1pNDfTCPhSSC054yydG3g6pUGk9Kpfj+oA8XrasvR+d -D4d7a2cUZRKXU29817isfLNjqZMiJ/7LA11I6DeQgPaRK+kAEQEAAYkERAQYAQgA -DwUCVk9/CAIbAgUJAeEzgAIpCRBQ4IhVk9LctMFdIAQZAQgABgUCVk9/CAAKCRCG -M/sTtYhE8RLLD/0bK5unOEb1RsuzCqL7IWPr+Z6i7smZ0tmrTF58a3St64DjR3WY -uv/RnhYyh8xCtBod7ZoIl2S+Azavevx22KWXPQgRtwhlCJFsnDoG9C5Kj0BqUrty -k+9nlGeIMOUPjMJJocEaB9yHZs7J9KFNyqpEY7x2XW6HTDihsBdaOUu814g6C4gL -iXydwbQMzU2Crefc1w/fWhSxjqiyUlKp571jeauWuUdtbQmwk/Kvq9yreHkEWN4M -Hs2HuBwwBmbj0KDFFDA2u6oUvGlRTfwomTiryXDr1tOgiySucdFVrx+6zPBMcqlX -qsVDsx8sr+u7PzIsHO9NT+P3wYQpmWhwKCjLX5KN6Xv3d0aAr7OYEacrED1sqndI -fXjM5EcouLFtw/YESA7Px8iRggFVFDN0GY3hfoPJgHpiJj2KYyuVvNe8dXpsjOdP -pFbhTPI1CoA12woT4vGtfxcI9u/uc7m5rQDJI+FCR9OtUYvtDUqtE/XYjqPXzkbg -tRy+zwjpTTdxn48OaizVU3JOW+OQwW4q/4Wk6T6nzNTpQDHUmIdxsAAbZjBJwkE4 -Qkgtl8iUjS0hUX05ixLUwn0ZuGjeLcK9O/rqynPDqd9gdeKo5fTJ91RhJxoBSFcr -j21tPOa0PhE/2Zza24AVZIX5+AweD9pie8QIkZLMk6yrvRFqs2YrHUrc5emkD/4l -GsZpfSAKWCdc+iE5pL434yMlp73rhi+40mbCiXMOgavdWPZSDcVe+7fYENx0tqUy -GZj2qKluOBtxTeovrsFVllF9fxzixBthKddA6IcDQdTb076t/Ez51jX1z/GRPzn8 -yWkDEvi3L9mfKtfuD4BRzjaVw8TtNzuFuwz2PQDDBtFXqYMklA67cdjvYdffO7Me -yKlNjKAutXOr/Or70rKkk2wZLYtSeJIDRwUSsPdKncbGLEKvfoBKOcOmjfZKjnYp -IDDNqAsMrJLIwyo+6NSUtq84Gba6QjPYLvJ9g4P299dIYzFxu/0Zy4q9QgfjJOav -3GUQT1fRhqqRS11ffXFqClJKqsKSChcPhNhK5wt6Ab6PVbd9RQhI8ImLQ81PWn70 -8rOr1dQTQfPvJrHBBrEolUw/0y7SxPmQZUkYlXiT6bvsUa2n2f4ZzIgtYtZ5JSuo -qcut/jmeUQE1TUUyG+9HVMfmhlhjNO0pDiFdSAgjk+DyTd5lUVz3tPGFliIDq7O/ -sgDq6xtSlGKvQt/gRoYstrillyxfIVqR10C2t2kCBXKSX3uQmbx3OaX8JtZ2uMjm -KZb2iovfSf8qLSu49qrsNS9Etqvda0EXqaHeX+K8NjENoQEdXZUnBRJg9VVa0HkP -iFSFIwF8IPWewm0DocZil66bp/wrHVsJkw7AwE/zJg== -=0DIT +D4d7a2cUZRKXU29817isfLNjqZMiJ/7LA11I6DeQgPaRK+kAEQEAAYkCHwQoAQgA +CQUCVzocNwIdAgAKCRBQ4IhVk9LctGVfEADBBSjZq858OE932M9FUyt5fsYQ1p/O +6zoHlCyGyyDdXNu2aDGvhjUVBd3RbjHW87FiiwggubZ/GidCSUmv/et26MAzqthl +5CJgi0yvb5p2KeiJvbTPZEN+WVitAlEsmN5FuUzD2Q7BlBhFunwaN39A27f1r3av +qfy6AoFsTIiYHVP85HscCaDYc2SpZNAJYV4ZcascuLye2UkUm3fSSaYLCjtlVg0m +Wkcjp7rZFQxqlQqSjVGarozxOYgI+HgKaqYF9+zJsh+26kmyHRdQY+Pznpt+PXjt +EQVsdzh5pqr4w4J8CnYTJKQQO4T08cfo13pfFzgqBGo4ftXOkLLDS3ZgFHgx00fg +70MGYYAgNME7BJog+pO5vthwfhQO6pMT08axC8sAWD0wia362VDNG5Kg4TQHFARu +Ao51e+NvxF8cGi0g1zBEfGMCFwlAlQOYcI9bpk1xx+Z8P3Y8dnpRdg8VK2ZRNsf/ +CggNXrgjQ2cEOrEsda5lG/NXbNqdDiygBHc1wgnoidABOHMT483WKMw3GBao3JLF +L0njULRguJgTuyI9ie8HLH/vfYWXq7t5o5sYM+bxAiJDDX+F/dp+gbomXjDE/wJ/ +jFOz/7Cp9WoLYttpWFpWPl4UTDvfyPzn9kKT/57OC7OMFZH2a3LxwEfaGTgDOvA5 +QbxS5txqnkpPcokERAQYAQgADwUCVk9/CAIbAgUJAeEzgAIpCRBQ4IhVk9LctMFd +IAQZAQgABgUCVk9/CAAKCRCGM/sTtYhE8RLLD/0bK5unOEb1RsuzCqL7IWPr+Z6i +7smZ0tmrTF58a3St64DjR3WYuv/RnhYyh8xCtBod7ZoIl2S+Azavevx22KWXPQgR +twhlCJFsnDoG9C5Kj0BqUrtyk+9nlGeIMOUPjMJJocEaB9yHZs7J9KFNyqpEY7x2 +XW6HTDihsBdaOUu814g6C4gLiXydwbQMzU2Crefc1w/fWhSxjqiyUlKp571jeauW +uUdtbQmwk/Kvq9yreHkEWN4MHs2HuBwwBmbj0KDFFDA2u6oUvGlRTfwomTiryXDr +1tOgiySucdFVrx+6zPBMcqlXqsVDsx8sr+u7PzIsHO9NT+P3wYQpmWhwKCjLX5KN +6Xv3d0aAr7OYEacrED1sqndIfXjM5EcouLFtw/YESA7Px8iRggFVFDN0GY3hfoPJ +gHpiJj2KYyuVvNe8dXpsjOdPpFbhTPI1CoA12woT4vGtfxcI9u/uc7m5rQDJI+FC +R9OtUYvtDUqtE/XYjqPXzkbgtRy+zwjpTTdxn48OaizVU3JOW+OQwW4q/4Wk6T6n +zNTpQDHUmIdxsAAbZjBJwkE4Qkgtl8iUjS0hUX05ixLUwn0ZuGjeLcK9O/rqynPD +qd9gdeKo5fTJ91RhJxoBSFcrj21tPOa0PhE/2Zza24AVZIX5+AweD9pie8QIkZLM +k6yrvRFqs2YrHUrc5emkD/4lGsZpfSAKWCdc+iE5pL434yMlp73rhi+40mbCiXMO +gavdWPZSDcVe+7fYENx0tqUyGZj2qKluOBtxTeovrsFVllF9fxzixBthKddA6IcD +QdTb076t/Ez51jX1z/GRPzn8yWkDEvi3L9mfKtfuD4BRzjaVw8TtNzuFuwz2PQDD +BtFXqYMklA67cdjvYdffO7MeyKlNjKAutXOr/Or70rKkk2wZLYtSeJIDRwUSsPdK +ncbGLEKvfoBKOcOmjfZKjnYpIDDNqAsMrJLIwyo+6NSUtq84Gba6QjPYLvJ9g4P2 +99dIYzFxu/0Zy4q9QgfjJOav3GUQT1fRhqqRS11ffXFqClJKqsKSChcPhNhK5wt6 +Ab6PVbd9RQhI8ImLQ81PWn708rOr1dQTQfPvJrHBBrEolUw/0y7SxPmQZUkYlXiT +6bvsUa2n2f4ZzIgtYtZ5JSuoqcut/jmeUQE1TUUyG+9HVMfmhlhjNO0pDiFdSAgj +k+DyTd5lUVz3tPGFliIDq7O/sgDq6xtSlGKvQt/gRoYstrillyxfIVqR10C2t2kC +BXKSX3uQmbx3OaX8JtZ2uMjmKZb2iovfSf8qLSu49qrsNS9Etqvda0EXqaHeX+K8 +NjENoQEdXZUnBRJg9VVa0HkPiFSFIwF8IPWewm0DocZil66bp/wrHVsJkw7AwE/z +JrkCDQRXOi4eARAA+cAKfT0IoViuCxqa6uPteVC8/qp8ZiEPri0neCt+khngPpCX +9JseOyRJEzwt9+31XgzsCWlfW5BWrLBd3F4caRqucu3ZnE68Qtrw6kcOsJ8LSiok +/uu1XnXW1mgpRxlu0i83YVM6+BrIXroP22SWVxkDkAXDlgvFmIvrh9TG43uSRjmg +riSnJ7EOgDXDrZ5mTlnlGHb6EGpHJHoJsfp3JdBAh4oNGBBHf5fZZhBiUIJSGwbL +g8oEzOuycNor9mEiJPaAyPm22braWRgvX7beOca60eNGIuQSZ8ML3G6rog/pNdbN +gLf1hvrfl7NJCJJ0iB7BPYw8e5+xPEHNLrJI6NjFCbD0dlHnuq79ePc9bPQALa/6 +lIICOCAZJYDCf7S2dHqkHCOnr8F2A2qwAqP5IlVqdS7sSy7D9wDDYis7jlMw8vVW +jqcL6MNxJDk3h/0ns7Ad5TNfJnLUnUbYWeH5QYbPsGgqQomhSWBvhCZkILnE7Rpb +tjl55/CvTXN1L6jyi9qJeSoWORjwhTlACKDzlsLRTO24sM/KjKDajYrqU3CRVDQG +gQL0yU3qDz/mql+awQAMUS9ckaf/ohBM8SrCandNvE/+as426Mf6/FH6R7kntJpp +YQZJMwq0XlyueadWs8xrCjrXnXFijvrVkaZhlCfJRZPEdI76hGscRp8Sr6kAEQEA +AYkERAQYAQgADwUCVzouHgIbAgUJAeEzgAIpCRBQ4IhVk9LctMFdIAQZAQgABgUC +VzouHgAKCRBI+blqLhYTf6o8D/0WqjCOqB4rAv29MGpz5SZbk57TbQrKfjneSDVe +CsvgofUBL6z9yA2jEanIh76Lo6r5ZnvF8I4pDImiRCjhZ+4vDOKaO5yvrNKruusr ++ZA6DDPwjlhnRPqW8Sm1YGl1VqAqQEjib4I7dbGb5qpR/PkAj64UDtLtbMfx6Zb9 +B9ZJvYEiWUbAEQWUohRhw6vT/qS07GrKgG35JFiJKrNPSFEh/YOLKq+vLVZwDKX9 +1Tvabs3MuNFIavuMiGaoqv4/JVRA1Iw3E9zCsXgFhIfQll4XvrrPXiGAllFzaqX2 +9PnvqMngjPRDTh+jHNUjFv8MNvhs1o3jc1pQAJT5JIpPQJJpbnNnrYoCJoBO0kfJ +04zEDznHkuVbLRn2pxWsCrF2Agwm4GB3YSenEW8AKcmtS4ov0Yaw5csY3fXUDXjB +aPR9dweNWT/kaY5V4NUwOutecnZ0o0yDc57GGIjFhTcULMdOCE6DbSTfljqcoAoP +IydzQ4rlMdmTkiM5k2F/jDHCURersqF8Naro7Nx2fKokPrLKUst+pFBBwbeTO9tW +EbOnl/ypHeRW9XA31sZ0yvvSwUrWnHC+UDpHPzvaAGleAOK7gGyJehVIw9BhgZB1 +LplkbkGgpS8L/3CAcaQ488MP5NK0peO+ED/ocNhi1tC/cHbLXtDiz/eG/1rIdxkO +h3D61WiyD/42Oj2h4BHt5qTS12By95po4avzgqaV3PFYi9Rx6tBvzwnD7x2UeGk4 +wzFdb2V4LWoe6bqMokxbUMWJgP5faWDT6/urhBt4GYcBxX0b3l9qBs20hP5JVHGX +208gOW5cjfHrTNiHiY4/CbQrbAdO24CUYZtYEmDNdHN+KHrlLLjkf0v5yGjVK2XB +qs8l6upA7xBGHAF7U/XkLYrvyusqqWdvdGHGHthbLBzjceO+4N+lb6RyHRuF6kgb +LdCcaKfCMUs/v1ZXgYGhdk7NWFHFDoF8DByHwluoihd10OudGPFg7ydTc6+V3kt9 +SN1/iQbk2/rHffI1tm28MfBvN+K/Da+Y+EAqTbUDHl6O30mSGZjLl1xJxvWoezU9 +8TdPCxy7L9XRFfqZlBJAo8cxRIPHpqKIaRy0wn616xCDfUSQ9NBLlDITL4d7tNvD +C9hLpehFKMKIEct5WDfaQIWQe2o1fjVsU2Is2wXVmdi9A7X3q7yWVA766zQTxQO6 +1TcgyoJM9k2DxncsmwXIa8oD6KP4VYtrtsx8r4VXPEjHucCjPe+qgyY65wBPXSl5 +U21AiUuGGegFQwRD6L7ZqT3K5JLDlK/kkaV3l8i0onfJ+5CytOB2T6QPQnJ4Ynch +K9w3EiyDrgzl0IpotQXxOBGHoCtcxUZvkNeOIxAb8QwkWnhgkljMyQ== +=nV4h -----END PGP PUBLIC KEY BLOCK----- " From 431af6cde3f3448d9321ae654eb1dcab97e433e5 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Thu, 19 May 2016 16:49:18 +0200 Subject: [PATCH 0285/1304] tests: TestServiceFile: increase timeout to 15s TestServiceFile was previously waiting 10 seconds. In our test on Fedora 23, it was taking 11 seconds. This made the test fail. This patch increases the delay to 15 seconds. It should be enough. --- tests/rkt_service_file_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/rkt_service_file_test.go b/tests/rkt_service_file_test.go index 0c8bad6ef0..3f7cc98a17 100644 --- a/tests/rkt_service_file_test.go +++ b/tests/rkt_service_file_test.go @@ -88,8 +88,8 @@ func TestServiceFile(t *testing.T) { t.Fatalf("Test unit not found in list") } - // Run the unit for 10 seconds. You can check the logs manually in journalctl - time.Sleep(10 * time.Second) + // Run the unit for 15 seconds. You can check the logs manually in journalctl + time.Sleep(15 * time.Second) // Stop the unit _, err = conn.StopUnit(target, "replace", reschan) From 6a355ebefec9feca918673f64f447991ec19d17f Mon Sep 17 00:00:00 2001 From: Alex Hornung Date: Thu, 14 Apr 2016 22:13:56 +0100 Subject: [PATCH 0286/1304] config: add AWS authentication mechanism This adds support for AWS authentication as a config auth mechanism to be able to, for example, access private Amazon S3 buckets. Fixes: #2161 --- Documentation/configuration.md | 22 +- Godeps/Godeps.json | 90 ++ .../src/github.com/aws/aws-sdk-go/LICENSE.txt | 202 +++++ .../src/github.com/aws/aws-sdk-go/NOTICE.txt | 3 + .../aws/aws-sdk-go/aws/awserr/error.go | 124 +++ .../aws/aws-sdk-go/aws/awserr/types.go | 197 ++++ .../aws/aws-sdk-go/aws/awsutil/copy.go | 100 +++ .../aws/aws-sdk-go/aws/awsutil/equal.go | 27 + .../aws/aws-sdk-go/aws/awsutil/path_value.go | 222 +++++ .../aws/aws-sdk-go/aws/awsutil/prettify.go | 103 +++ .../aws-sdk-go/aws/awsutil/string_value.go | 89 ++ .../aws/client/metadata/client_info.go | 12 + .../github.com/aws/aws-sdk-go/aws/config.go | 311 +++++++ .../aws/aws-sdk-go/aws/convert_types.go | 357 ++++++++ .../aws/credentials/chain_provider.go | 100 +++ .../aws-sdk-go/aws/credentials/credentials.go | 223 +++++ .../aws/credentials/env_provider.go | 77 ++ .../aws-sdk-go/aws/credentials/example.ini | 12 + .../shared_credentials_provider.go | 151 ++++ .../aws/credentials/static_provider.go | 48 + .../github.com/aws/aws-sdk-go/aws/errors.go | 17 + .../github.com/aws/aws-sdk-go/aws/logger.go | 112 +++ .../aws/aws-sdk-go/aws/request/handlers.go | 187 ++++ .../aws/aws-sdk-go/aws/request/request.go | 302 +++++++ .../aws/request/request_pagination.go | 104 +++ .../aws/aws-sdk-go/aws/request/retryer.go | 82 ++ .../github.com/aws/aws-sdk-go/aws/types.go | 88 ++ .../github.com/aws/aws-sdk-go/aws/version.go | 8 + .../aws-sdk-go/private/protocol/rest/build.go | 257 ++++++ .../private/protocol/rest/payload.go | 45 + .../private/protocol/rest/unmarshal.go | 193 ++++ .../private/signer/v4/header_rules.go | 82 ++ .../aws/aws-sdk-go/private/signer/v4/v4.go | 438 +++++++++ .../src/github.com/go-ini/ini/.gitignore | 4 + .../src/github.com/go-ini/ini/LICENSE | 191 ++++ .../src/github.com/go-ini/ini/Makefile | 12 + .../src/github.com/go-ini/ini/README.md | 632 +++++++++++++ .../src/github.com/go-ini/ini/README_ZH.md | 619 +++++++++++++ .../src/github.com/go-ini/ini/ini.go | 465 ++++++++++ .../src/github.com/go-ini/ini/key.go | 616 +++++++++++++ .../src/github.com/go-ini/ini/parser.go | 312 +++++++ .../src/github.com/go-ini/ini/section.go | 177 ++++ .../src/github.com/go-ini/ini/struct.go | 351 ++++++++ .../src/github.com/gopherjs/gopherjs/LICENSE | 24 + .../src/github.com/gopherjs/gopherjs/js/js.go | 168 ++++ .../jmespath/go-jmespath/.gitignore | 4 + .../jmespath/go-jmespath/.travis.yml | 9 + .../github.com/jmespath/go-jmespath/LICENSE | 13 + .../github.com/jmespath/go-jmespath/Makefile | 44 + .../github.com/jmespath/go-jmespath/README.md | 7 + .../github.com/jmespath/go-jmespath/api.go | 49 + .../go-jmespath/astnodetype_string.go | 16 + .../jmespath/go-jmespath/functions.go | 842 ++++++++++++++++++ .../jmespath/go-jmespath/interpreter.go | 418 +++++++++ .../github.com/jmespath/go-jmespath/lexer.go | 420 +++++++++ .../github.com/jmespath/go-jmespath/parser.go | 603 +++++++++++++ .../jmespath/go-jmespath/toktype_string.go | 16 + .../github.com/jmespath/go-jmespath/util.go | 185 ++++ .../src/github.com/jtolds/gls/LICENSE | 18 + .../src/github.com/jtolds/gls/README.md | 89 ++ .../src/github.com/jtolds/gls/context.go | 144 +++ .../src/github.com/jtolds/gls/gen_sym.go | 13 + .../src/github.com/jtolds/gls/id_pool.go | 34 + .../src/github.com/jtolds/gls/stack_tags.go | 43 + .../github.com/jtolds/gls/stack_tags_js.go | 101 +++ .../github.com/jtolds/gls/stack_tags_main.go | 61 ++ .../smartystreets/assertions/.gitignore | 3 + .../smartystreets/assertions/.travis.yml | 14 + .../smartystreets/assertions/CONTRIBUTING.md | 12 + .../smartystreets/assertions/LICENSE.md | 23 + .../smartystreets/assertions/README.md | 575 ++++++++++++ .../assertions/assertions.goconvey | 3 + .../smartystreets/assertions/collections.go | 244 +++++ .../smartystreets/assertions/doc.go | 105 +++ .../smartystreets/assertions/equality.go | 280 ++++++ .../smartystreets/assertions/filter.go | 23 + .../internal/go-render/render/render.go | 477 ++++++++++ .../internal/oglematchers/.gitignore | 5 + .../internal/oglematchers/.travis.yml | 4 + .../assertions/internal/oglematchers/LICENSE | 202 +++++ .../internal/oglematchers/README.md | 58 ++ .../internal/oglematchers/all_of.go | 70 ++ .../assertions/internal/oglematchers/any.go | 32 + .../internal/oglematchers/any_of.go | 94 ++ .../internal/oglematchers/contains.go | 61 ++ .../internal/oglematchers/deep_equals.go | 88 ++ .../internal/oglematchers/elements_are.go | 91 ++ .../internal/oglematchers/equals.go | 541 +++++++++++ .../assertions/internal/oglematchers/error.go | 51 ++ .../internal/oglematchers/greater_or_equal.go | 39 + .../internal/oglematchers/greater_than.go | 39 + .../internal/oglematchers/has_same_type_as.go | 37 + .../internal/oglematchers/has_substr.go | 46 + .../internal/oglematchers/identical_to.go | 134 +++ .../internal/oglematchers/less_or_equal.go | 41 + .../internal/oglematchers/less_than.go | 152 ++++ .../internal/oglematchers/matcher.go | 86 ++ .../internal/oglematchers/matches_regexp.go | 69 ++ .../internal/oglematchers/new_matcher.go | 43 + .../assertions/internal/oglematchers/not.go | 53 ++ .../internal/oglematchers/panics.go | 74 ++ .../internal/oglematchers/pointee.go | 65 ++ .../oglematchers/transform_description.go | 36 + .../smartystreets/assertions/messages.go | 93 ++ .../smartystreets/assertions/panic.go | 115 +++ .../smartystreets/assertions/quantity.go | 141 +++ .../smartystreets/assertions/serializer.go | 69 ++ .../smartystreets/assertions/strings.go | 227 +++++ .../smartystreets/assertions/time.go | 202 +++++ .../smartystreets/assertions/type.go | 112 +++ .../smartystreets/goconvey/LICENSE.md | 23 + .../goconvey/convey/assertions.go | 68 ++ .../smartystreets/goconvey/convey/context.go | 272 ++++++ .../goconvey/convey/convey.goconvey | 4 + .../goconvey/convey/discovery.go | 103 +++ .../smartystreets/goconvey/convey/doc.go | 218 +++++ .../goconvey/convey/gotest/utils.go | 28 + .../smartystreets/goconvey/convey/init.go | 81 ++ .../goconvey/convey/nilReporter.go | 15 + .../goconvey/convey/reporting/console.go | 16 + .../goconvey/convey/reporting/doc.go | 5 + .../goconvey/convey/reporting/dot.go | 40 + .../goconvey/convey/reporting/gotest.go | 33 + .../goconvey/convey/reporting/init.go | 94 ++ .../goconvey/convey/reporting/json.go | 88 ++ .../goconvey/convey/reporting/printer.go | 57 ++ .../goconvey/convey/reporting/problems.go | 80 ++ .../goconvey/convey/reporting/reporter.go | 39 + .../convey/reporting/reporting.goconvey | 2 + .../goconvey/convey/reporting/reports.go | 179 ++++ .../goconvey/convey/reporting/statistics.go | 108 +++ .../goconvey/convey/reporting/story.go | 73 ++ rkt/config/auth.go | 115 ++- rkt/config/auth_test.go | 54 ++ rkt/config/config.go | 5 +- rkt/config/config_test.go | 4 +- rkt/fetch_test.go | 7 +- rkt/image/httpops.go | 14 +- rkt/image/resumablesession.go | 19 +- 139 files changed, 17837 insertions(+), 21 deletions(-) create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/LICENSE.txt create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/NOTICE.txt create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awserr/error.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awserr/types.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/copy.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/equal.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/path_value.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/prettify.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/string_value.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/client/metadata/client_info.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/config.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/convert_types.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/chain_provider.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/credentials.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/env_provider.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/example.ini create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/shared_credentials_provider.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/static_provider.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/errors.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/logger.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/handlers.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/request.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/request_pagination.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/retryer.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/types.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/version.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/build.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/payload.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/signer/v4/header_rules.go create mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/signer/v4/v4.go create mode 100644 Godeps/_workspace/src/github.com/go-ini/ini/.gitignore create mode 100644 Godeps/_workspace/src/github.com/go-ini/ini/LICENSE create mode 100644 Godeps/_workspace/src/github.com/go-ini/ini/Makefile create mode 100644 Godeps/_workspace/src/github.com/go-ini/ini/README.md create mode 100644 Godeps/_workspace/src/github.com/go-ini/ini/README_ZH.md create mode 100644 Godeps/_workspace/src/github.com/go-ini/ini/ini.go create mode 100644 Godeps/_workspace/src/github.com/go-ini/ini/key.go create mode 100644 Godeps/_workspace/src/github.com/go-ini/ini/parser.go create mode 100644 Godeps/_workspace/src/github.com/go-ini/ini/section.go create mode 100644 Godeps/_workspace/src/github.com/go-ini/ini/struct.go create mode 100644 Godeps/_workspace/src/github.com/gopherjs/gopherjs/LICENSE create mode 100644 Godeps/_workspace/src/github.com/gopherjs/gopherjs/js/js.go create mode 100644 Godeps/_workspace/src/github.com/jmespath/go-jmespath/.gitignore create mode 100644 Godeps/_workspace/src/github.com/jmespath/go-jmespath/.travis.yml create mode 100644 Godeps/_workspace/src/github.com/jmespath/go-jmespath/LICENSE create mode 100644 Godeps/_workspace/src/github.com/jmespath/go-jmespath/Makefile create mode 100644 Godeps/_workspace/src/github.com/jmespath/go-jmespath/README.md create mode 100644 Godeps/_workspace/src/github.com/jmespath/go-jmespath/api.go create mode 100644 Godeps/_workspace/src/github.com/jmespath/go-jmespath/astnodetype_string.go create mode 100644 Godeps/_workspace/src/github.com/jmespath/go-jmespath/functions.go create mode 100644 Godeps/_workspace/src/github.com/jmespath/go-jmespath/interpreter.go create mode 100644 Godeps/_workspace/src/github.com/jmespath/go-jmespath/lexer.go create mode 100644 Godeps/_workspace/src/github.com/jmespath/go-jmespath/parser.go create mode 100644 Godeps/_workspace/src/github.com/jmespath/go-jmespath/toktype_string.go create mode 100644 Godeps/_workspace/src/github.com/jmespath/go-jmespath/util.go create mode 100644 Godeps/_workspace/src/github.com/jtolds/gls/LICENSE create mode 100644 Godeps/_workspace/src/github.com/jtolds/gls/README.md create mode 100644 Godeps/_workspace/src/github.com/jtolds/gls/context.go create mode 100644 Godeps/_workspace/src/github.com/jtolds/gls/gen_sym.go create mode 100644 Godeps/_workspace/src/github.com/jtolds/gls/id_pool.go create mode 100644 Godeps/_workspace/src/github.com/jtolds/gls/stack_tags.go create mode 100644 Godeps/_workspace/src/github.com/jtolds/gls/stack_tags_js.go create mode 100644 Godeps/_workspace/src/github.com/jtolds/gls/stack_tags_main.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/.gitignore create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/.travis.yml create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/CONTRIBUTING.md create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/LICENSE.md create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/README.md create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/assertions.goconvey create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/collections.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/doc.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/equality.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/filter.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/go-render/render/render.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/.gitignore create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/.travis.yml create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/LICENSE create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/README.md create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/all_of.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/any.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/any_of.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/contains.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/deep_equals.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/elements_are.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/equals.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/error.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/greater_than.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/has_substr.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/identical_to.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/less_than.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/matcher.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/new_matcher.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/not.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/panics.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/pointee.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/transform_description.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/messages.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/panic.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/quantity.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/serializer.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/strings.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/time.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/type.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/LICENSE.md create mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/assertions.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/context.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/convey.goconvey create mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/discovery.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/doc.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/gotest/utils.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/init.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/nilReporter.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/console.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/doc.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/dot.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/gotest.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/init.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/json.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/printer.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/problems.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reporter.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reporting.goconvey create mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reports.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/statistics.go create mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/story.go create mode 100644 rkt/config/auth_test.go diff --git a/Documentation/configuration.md b/Documentation/configuration.md index 3e7a0f8247..04249af6ae 100644 --- a/Documentation/configuration.md +++ b/Documentation/configuration.md @@ -65,7 +65,7 @@ This field must be specified and cannot be empty. The `credentials` field is defined by the `type` field. It should hold all the data that are needed for successful authentication with the given hosts. -This version of auth configuration supports two methods - basic HTTP authentication and OAuth Bearer Token. +This version of auth configuration supports three methods - basic HTTP authentication, OAuth Bearer Token, and AWS v4 authentication. Basic HTTP authentication requires two things - a user and a password. To use this type, define `type` as `basic` and the `credentials` field as a map with two keys - `user` and `password`. @@ -106,6 +106,26 @@ For example: } ``` +AWS v4 authentication requires three things - an access key ID, a secret access key and an AWS region. If the region is left empty, it will be determined automatically from the URL/domain. +To use this type, define `type` as `aws` and the `credentials` field as a map with two or three keys - `accessKeyID` and `secretAccessKey` are mandatory, whilst `awsRegion` is optional and can be left empty. +For example: + +`/etc/rkt/auth.d/coreos-aws.json`: + +```json +{ + "rktKind": "auth", + "rktVersion": "v1", + "domains": ["my-s3-bucket.s3.amazonaws.com"], + "type": "aws", + "credentials": { + "accessKeyID": "foo", + "secretAccessKey": "bar", + "awsRegion": "us-east-1" + } +} +``` + ##### Override semantics Overriding is done for each domain. diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index ea6ae03d68..e58a951fae 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -216,6 +216,46 @@ "Comment": "v0.8.1", "Rev": "b889d03467ae08bb6c13241762a64305b69bcf82" }, + { + "ImportPath": "github.com/aws/aws-sdk-go/aws", + "Comment": "v1.1.7", + "Rev": "13a12060f716145019378a10e2806c174356b857" + }, + { + "ImportPath": "github.com/aws/aws-sdk-go/aws/awserr", + "Comment": "v1.1.7", + "Rev": "13a12060f716145019378a10e2806c174356b857" + }, + { + "ImportPath": "github.com/aws/aws-sdk-go/aws/awsutil", + "Comment": "v1.1.7", + "Rev": "13a12060f716145019378a10e2806c174356b857" + }, + { + "ImportPath": "github.com/aws/aws-sdk-go/aws/client/metadata", + "Comment": "v1.1.7", + "Rev": "13a12060f716145019378a10e2806c174356b857" + }, + { + "ImportPath": "github.com/aws/aws-sdk-go/aws/credentials", + "Comment": "v1.1.7", + "Rev": "13a12060f716145019378a10e2806c174356b857" + }, + { + "ImportPath": "github.com/aws/aws-sdk-go/aws/request", + "Comment": "v1.1.7", + "Rev": "13a12060f716145019378a10e2806c174356b857" + }, + { + "ImportPath": "github.com/aws/aws-sdk-go/private/protocol/rest", + "Comment": "v1.1.7", + "Rev": "13a12060f716145019378a10e2806c174356b857" + }, + { + "ImportPath": "github.com/aws/aws-sdk-go/private/signer/v4", + "Comment": "v1.1.7", + "Rev": "13a12060f716145019378a10e2806c174356b857" + }, { "ImportPath": "github.com/camlistore/go4/lock", "Rev": "9ba773eba85ab9e258ff516630f7f6474bc4535b" @@ -340,6 +380,11 @@ "ImportPath": "github.com/dustin/go-humanize", "Rev": "c20a8bde38c8f5ba06f6600edf473705c96829d1" }, + { + "ImportPath": "github.com/go-ini/ini", + "Comment": "v1.11.0", + "Rev": "12f418cc7edc5a618a51407b7ac1f1f512139df3" + }, { "ImportPath": "github.com/go-ole/go-ole", "Comment": "v1.2.0-10-g572eabb", @@ -388,6 +433,11 @@ "ImportPath": "github.com/google/btree", "Rev": "f06e229e679911bb31a04e07ac891115822e37c3" }, + { + "ImportPath": "github.com/gopherjs/gopherjs/js", + "Comment": "go1.5-45-g19e100e", + "Rev": "19e100e9652485a76176bc5fd2669f57d3a2743c" + }, { "ImportPath": "github.com/gorilla/context", "Rev": "50c25fb3b2b3b3cc724e9b6ac75fb44b3bccd0da" @@ -408,6 +458,16 @@ "ImportPath": "github.com/inconshreveable/mousetrap", "Rev": "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" }, + { + "ImportPath": "github.com/jmespath/go-jmespath", + "Comment": "0.2.2-12-g0b12d6b", + "Rev": "0b12d6b521d83fc7f755e7cfc1b1fbdd35a01a74" + }, + { + "ImportPath": "github.com/jtolds/gls", + "Comment": "v4.2.0", + "Rev": "8ddce2a84170772b95dd5d576c48d517b22cac63" + }, { "ImportPath": "github.com/kballard/go-shellquote", "Rev": "e5c918b80c17694cbc49aab32a759f9a40067f5d" @@ -469,6 +529,36 @@ "ImportPath": "github.com/shurcooL/sanitized_anchor_name", "Rev": "10ef21a441db47d8b13ebcc5fd2310f636973c77" }, + { + "ImportPath": "github.com/smartystreets/assertions", + "Comment": "1.6.0-6-g40711f7", + "Rev": "40711f7748186bbf9c99977cd89f21ce1a229447" + }, + { + "ImportPath": "github.com/smartystreets/assertions/internal/go-render/render", + "Comment": "1.6.0-6-g40711f7", + "Rev": "40711f7748186bbf9c99977cd89f21ce1a229447" + }, + { + "ImportPath": "github.com/smartystreets/assertions/internal/oglematchers", + "Comment": "1.6.0-6-g40711f7", + "Rev": "40711f7748186bbf9c99977cd89f21ce1a229447" + }, + { + "ImportPath": "github.com/smartystreets/goconvey/convey", + "Comment": "1.6.1-20-gcc5d85f", + "Rev": "cc5d85f4f15bd2163abf0fe6e6753356dde72aa2" + }, + { + "ImportPath": "github.com/smartystreets/goconvey/convey/gotest", + "Comment": "1.6.1-20-gcc5d85f", + "Rev": "cc5d85f4f15bd2163abf0fe6e6753356dde72aa2" + }, + { + "ImportPath": "github.com/smartystreets/goconvey/convey/reporting", + "Comment": "1.6.1-20-gcc5d85f", + "Rev": "cc5d85f4f15bd2163abf0fe6e6753356dde72aa2" + }, { "ImportPath": "github.com/spf13/cobra", "Rev": "4c05eb1145f16d0e6bb4a3e1b6d769f4713cb41f" diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/LICENSE.txt b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/LICENSE.txt new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor 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, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/NOTICE.txt b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/NOTICE.txt new file mode 100644 index 0000000000..5f14d1162e --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/NOTICE.txt @@ -0,0 +1,3 @@ +AWS SDK for Go +Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. +Copyright 2014-2015 Stripe, Inc. diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awserr/error.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awserr/error.go new file mode 100644 index 0000000000..cbc6bb1c0b --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awserr/error.go @@ -0,0 +1,124 @@ +// Package awserr represents API error interface accessors for the SDK. +package awserr + +// An Error wraps lower level errors with code, message and an original error. +// The underlying concrete error type may also satisfy other interfaces which +// can be to used to obtain more specific information about the error. +// +// Calling Error() or String() will always include the full information about +// an error based on its underlying type. +// +// Example: +// +// output, err := s3manage.Upload(svc, input, opts) +// if err != nil { +// if awsErr, ok := err.(awserr.Error); ok { +// // Get error details +// log.Println("Error:", awsErr.Code(), awsErr.Message()) +// +// // Prints out full error message, including original error if there was one. +// log.Println("Error:", awsErr.Error()) +// +// // Get original error +// if origErr := awsErr.OrigErr(); origErr != nil { +// // operate on original error. +// } +// } else { +// fmt.Println(err.Error()) +// } +// } +// +type Error interface { + // Satisfy the generic error interface. + error + + // Returns the short phrase depicting the classification of the error. + Code() string + + // Returns the error details message. + Message() string + + // Returns the original error if one was set. Nil is returned if not set. + OrigErr() error +} + +// BatchError is a batch of errors which also wraps lower level errors with code, message, +// and original errors. Calling Error() will only return the error that is at the end +// of the list. +type BatchError interface { + // Satisfy the generic error interface. + error + + // Returns the short phrase depicting the classification of the error. + Code() string + + // Returns the error details message. + Message() string + + // Returns the original error if one was set. Nil is returned if not set. + OrigErrs() []error +} + +// New returns an Error object described by the code, message, and origErr. +// +// If origErr satisfies the Error interface it will not be wrapped within a new +// Error object and will instead be returned. +func New(code, message string, origErr error) Error { + return newBaseError(code, message, origErr) +} + +// NewBatchError returns an baseError with an expectation of an array of errors +func NewBatchError(code, message string, errs []error) BatchError { + return newBaseErrors(code, message, errs) +} + +// A RequestFailure is an interface to extract request failure information from +// an Error such as the request ID of the failed request returned by a service. +// RequestFailures may not always have a requestID value if the request failed +// prior to reaching the service such as a connection error. +// +// Example: +// +// output, err := s3manage.Upload(svc, input, opts) +// if err != nil { +// if reqerr, ok := err.(RequestFailure); ok { +// log.Println("Request failed", reqerr.Code(), reqerr.Message(), reqerr.RequestID()) +// } else { +// log.Println("Error:", err.Error()) +// } +// } +// +// Combined with awserr.Error: +// +// output, err := s3manage.Upload(svc, input, opts) +// if err != nil { +// if awsErr, ok := err.(awserr.Error); ok { +// // Generic AWS Error with Code, Message, and original error (if any) +// fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr()) +// +// if reqErr, ok := err.(awserr.RequestFailure); ok { +// // A service error occurred +// fmt.Println(reqErr.StatusCode(), reqErr.RequestID()) +// } +// } else { +// fmt.Println(err.Error()) +// } +// } +// +type RequestFailure interface { + Error + + // The status code of the HTTP response. + StatusCode() int + + // The request ID returned by the service for a request failure. This will + // be empty if no request ID is available such as the request failed due + // to a connection error. + RequestID() string +} + +// NewRequestFailure returns a new request error wrapper for the given Error +// provided. +func NewRequestFailure(err Error, statusCode int, reqID string) RequestFailure { + return newRequestError(err, statusCode, reqID) +} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awserr/types.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awserr/types.go new file mode 100644 index 0000000000..605f73c5d6 --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awserr/types.go @@ -0,0 +1,197 @@ +package awserr + +import "fmt" + +// SprintError returns a string of the formatted error code. +// +// Both extra and origErr are optional. If they are included their lines +// will be added, but if they are not included their lines will be ignored. +func SprintError(code, message, extra string, origErr error) string { + msg := fmt.Sprintf("%s: %s", code, message) + if extra != "" { + msg = fmt.Sprintf("%s\n\t%s", msg, extra) + } + if origErr != nil { + msg = fmt.Sprintf("%s\ncaused by: %s", msg, origErr.Error()) + } + return msg +} + +// A baseError wraps the code and message which defines an error. It also +// can be used to wrap an original error object. +// +// Should be used as the root for errors satisfying the awserr.Error. Also +// for any error which does not fit into a specific error wrapper type. +type baseError struct { + // Classification of error + code string + + // Detailed information about error + message string + + // Optional original error this error is based off of. Allows building + // chained errors. + errs []error +} + +// newBaseError returns an error object for the code, message, and err. +// +// code is a short no whitespace phrase depicting the classification of +// the error that is being created. +// +// message is the free flow string containing detailed information about the error. +// +// origErr is the error object which will be nested under the new error to be returned. +func newBaseError(code, message string, origErr error) *baseError { + b := &baseError{ + code: code, + message: message, + } + + if origErr != nil { + b.errs = append(b.errs, origErr) + } + + return b +} + +// newBaseErrors returns an error object for the code, message, and errors. +// +// code is a short no whitespace phrase depicting the classification of +// the error that is being created. +// +// message is the free flow string containing detailed information about the error. +// +// origErrs is the error objects which will be nested under the new errors to be returned. +func newBaseErrors(code, message string, origErrs []error) *baseError { + b := &baseError{ + code: code, + message: message, + errs: origErrs, + } + + return b +} + +// Error returns the string representation of the error. +// +// See ErrorWithExtra for formatting. +// +// Satisfies the error interface. +func (b baseError) Error() string { + size := len(b.errs) + if size > 0 { + return SprintError(b.code, b.message, "", errorList(b.errs)) + } + + return SprintError(b.code, b.message, "", nil) +} + +// String returns the string representation of the error. +// Alias for Error to satisfy the stringer interface. +func (b baseError) String() string { + return b.Error() +} + +// Code returns the short phrase depicting the classification of the error. +func (b baseError) Code() string { + return b.code +} + +// Message returns the error details message. +func (b baseError) Message() string { + return b.message +} + +// OrigErr returns the original error if one was set. Nil is returned if no error +// was set. This only returns the first element in the list. If the full list is +// needed, use BatchError +func (b baseError) OrigErr() error { + if size := len(b.errs); size > 0 { + return b.errs[0] + } + + return nil +} + +// OrigErrs returns the original errors if one was set. An empty slice is returned if +// no error was set:w +func (b baseError) OrigErrs() []error { + return b.errs +} + +// So that the Error interface type can be included as an anonymous field +// in the requestError struct and not conflict with the error.Error() method. +type awsError Error + +// A requestError wraps a request or service error. +// +// Composed of baseError for code, message, and original error. +type requestError struct { + awsError + statusCode int + requestID string +} + +// newRequestError returns a wrapped error with additional information for request +// status code, and service requestID. +// +// Should be used to wrap all request which involve service requests. Even if +// the request failed without a service response, but had an HTTP status code +// that may be meaningful. +// +// Also wraps original errors via the baseError. +func newRequestError(err Error, statusCode int, requestID string) *requestError { + return &requestError{ + awsError: err, + statusCode: statusCode, + requestID: requestID, + } +} + +// Error returns the string representation of the error. +// Satisfies the error interface. +func (r requestError) Error() string { + extra := fmt.Sprintf("status code: %d, request id: %s", + r.statusCode, r.requestID) + return SprintError(r.Code(), r.Message(), extra, r.OrigErr()) +} + +// String returns the string representation of the error. +// Alias for Error to satisfy the stringer interface. +func (r requestError) String() string { + return r.Error() +} + +// StatusCode returns the wrapped status code for the error +func (r requestError) StatusCode() int { + return r.statusCode +} + +// RequestID returns the wrapped requestID +func (r requestError) RequestID() string { + return r.requestID +} + +// An error list that satisfies the golang interface +type errorList []error + +// Error returns the string representation of the error. +// +// Satisfies the error interface. +func (e errorList) Error() string { + msg := "" + // How do we want to handle the array size being zero + if size := len(e); size > 0 { + for i := 0; i < size; i++ { + msg += fmt.Sprintf("%s", e[i].Error()) + // We check the next index to see if it is within the slice. + // If it is, then we append a newline. We do this, because unit tests + // could be broken with the additional '\n' + if i+1 < size { + msg += "\n" + } + } + } + return msg +} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/copy.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/copy.go new file mode 100644 index 0000000000..8429470b9d --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/copy.go @@ -0,0 +1,100 @@ +package awsutil + +import ( + "io" + "reflect" +) + +// Copy deeply copies a src structure to dst. Useful for copying request and +// response structures. +// +// Can copy between structs of different type, but will only copy fields which +// are assignable, and exist in both structs. Fields which are not assignable, +// or do not exist in both structs are ignored. +func Copy(dst, src interface{}) { + dstval := reflect.ValueOf(dst) + if !dstval.IsValid() { + panic("Copy dst cannot be nil") + } + + rcopy(dstval, reflect.ValueOf(src), true) +} + +// CopyOf returns a copy of src while also allocating the memory for dst. +// src must be a pointer type or this operation will fail. +func CopyOf(src interface{}) (dst interface{}) { + dsti := reflect.New(reflect.TypeOf(src).Elem()) + dst = dsti.Interface() + rcopy(dsti, reflect.ValueOf(src), true) + return +} + +// rcopy performs a recursive copy of values from the source to destination. +// +// root is used to skip certain aspects of the copy which are not valid +// for the root node of a object. +func rcopy(dst, src reflect.Value, root bool) { + if !src.IsValid() { + return + } + + switch src.Kind() { + case reflect.Ptr: + if _, ok := src.Interface().(io.Reader); ok { + if dst.Kind() == reflect.Ptr && dst.Elem().CanSet() { + dst.Elem().Set(src) + } else if dst.CanSet() { + dst.Set(src) + } + } else { + e := src.Type().Elem() + if dst.CanSet() && !src.IsNil() { + dst.Set(reflect.New(e)) + } + if src.Elem().IsValid() { + // Keep the current root state since the depth hasn't changed + rcopy(dst.Elem(), src.Elem(), root) + } + } + case reflect.Struct: + t := dst.Type() + for i := 0; i < t.NumField(); i++ { + name := t.Field(i).Name + srcVal := src.FieldByName(name) + dstVal := dst.FieldByName(name) + if srcVal.IsValid() && dstVal.CanSet() { + rcopy(dstVal, srcVal, false) + } + } + case reflect.Slice: + if src.IsNil() { + break + } + + s := reflect.MakeSlice(src.Type(), src.Len(), src.Cap()) + dst.Set(s) + for i := 0; i < src.Len(); i++ { + rcopy(dst.Index(i), src.Index(i), false) + } + case reflect.Map: + if src.IsNil() { + break + } + + s := reflect.MakeMap(src.Type()) + dst.Set(s) + for _, k := range src.MapKeys() { + v := src.MapIndex(k) + v2 := reflect.New(v.Type()).Elem() + rcopy(v2, v, false) + dst.SetMapIndex(k, v2) + } + default: + // Assign the value if possible. If its not assignable, the value would + // need to be converted and the impact of that may be unexpected, or is + // not compatible with the dst type. + if src.Type().AssignableTo(dst.Type()) { + dst.Set(src) + } + } +} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/equal.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/equal.go new file mode 100644 index 0000000000..59fa4a558a --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/equal.go @@ -0,0 +1,27 @@ +package awsutil + +import ( + "reflect" +) + +// DeepEqual returns if the two values are deeply equal like reflect.DeepEqual. +// In addition to this, this method will also dereference the input values if +// possible so the DeepEqual performed will not fail if one parameter is a +// pointer and the other is not. +// +// DeepEqual will not perform indirection of nested values of the input parameters. +func DeepEqual(a, b interface{}) bool { + ra := reflect.Indirect(reflect.ValueOf(a)) + rb := reflect.Indirect(reflect.ValueOf(b)) + + if raValid, rbValid := ra.IsValid(), rb.IsValid(); !raValid && !rbValid { + // If the elements are both nil, and of the same type the are equal + // If they are of different types they are not equal + return reflect.TypeOf(a) == reflect.TypeOf(b) + } else if raValid != rbValid { + // Both values must be valid to be equal + return false + } + + return reflect.DeepEqual(ra.Interface(), rb.Interface()) +} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/path_value.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/path_value.go new file mode 100644 index 0000000000..4d2a01e8c4 --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/path_value.go @@ -0,0 +1,222 @@ +package awsutil + +import ( + "reflect" + "regexp" + "strconv" + "strings" + + "github.com/jmespath/go-jmespath" +) + +var indexRe = regexp.MustCompile(`(.+)\[(-?\d+)?\]$`) + +// rValuesAtPath returns a slice of values found in value v. The values +// in v are explored recursively so all nested values are collected. +func rValuesAtPath(v interface{}, path string, createPath, caseSensitive, nilTerm bool) []reflect.Value { + pathparts := strings.Split(path, "||") + if len(pathparts) > 1 { + for _, pathpart := range pathparts { + vals := rValuesAtPath(v, pathpart, createPath, caseSensitive, nilTerm) + if len(vals) > 0 { + return vals + } + } + return nil + } + + values := []reflect.Value{reflect.Indirect(reflect.ValueOf(v))} + components := strings.Split(path, ".") + for len(values) > 0 && len(components) > 0 { + var index *int64 + var indexStar bool + c := strings.TrimSpace(components[0]) + if c == "" { // no actual component, illegal syntax + return nil + } else if caseSensitive && c != "*" && strings.ToLower(c[0:1]) == c[0:1] { + // TODO normalize case for user + return nil // don't support unexported fields + } + + // parse this component + if m := indexRe.FindStringSubmatch(c); m != nil { + c = m[1] + if m[2] == "" { + index = nil + indexStar = true + } else { + i, _ := strconv.ParseInt(m[2], 10, 32) + index = &i + indexStar = false + } + } + + nextvals := []reflect.Value{} + for _, value := range values { + // pull component name out of struct member + if value.Kind() != reflect.Struct { + continue + } + + if c == "*" { // pull all members + for i := 0; i < value.NumField(); i++ { + if f := reflect.Indirect(value.Field(i)); f.IsValid() { + nextvals = append(nextvals, f) + } + } + continue + } + + value = value.FieldByNameFunc(func(name string) bool { + if c == name { + return true + } else if !caseSensitive && strings.ToLower(name) == strings.ToLower(c) { + return true + } + return false + }) + + if nilTerm && value.Kind() == reflect.Ptr && len(components[1:]) == 0 { + if !value.IsNil() { + value.Set(reflect.Zero(value.Type())) + } + return []reflect.Value{value} + } + + if createPath && value.Kind() == reflect.Ptr && value.IsNil() { + // TODO if the value is the terminus it should not be created + // if the value to be set to its position is nil. + value.Set(reflect.New(value.Type().Elem())) + value = value.Elem() + } else { + value = reflect.Indirect(value) + } + + if value.Kind() == reflect.Slice || value.Kind() == reflect.Map { + if !createPath && value.IsNil() { + value = reflect.ValueOf(nil) + } + } + + if value.IsValid() { + nextvals = append(nextvals, value) + } + } + values = nextvals + + if indexStar || index != nil { + nextvals = []reflect.Value{} + for _, value := range values { + value := reflect.Indirect(value) + if value.Kind() != reflect.Slice { + continue + } + + if indexStar { // grab all indices + for i := 0; i < value.Len(); i++ { + idx := reflect.Indirect(value.Index(i)) + if idx.IsValid() { + nextvals = append(nextvals, idx) + } + } + continue + } + + // pull out index + i := int(*index) + if i >= value.Len() { // check out of bounds + if createPath { + // TODO resize slice + } else { + continue + } + } else if i < 0 { // support negative indexing + i = value.Len() + i + } + value = reflect.Indirect(value.Index(i)) + + if value.Kind() == reflect.Slice || value.Kind() == reflect.Map { + if !createPath && value.IsNil() { + value = reflect.ValueOf(nil) + } + } + + if value.IsValid() { + nextvals = append(nextvals, value) + } + } + values = nextvals + } + + components = components[1:] + } + return values +} + +// ValuesAtPath returns a list of values at the case insensitive lexical +// path inside of a structure. +func ValuesAtPath(i interface{}, path string) ([]interface{}, error) { + result, err := jmespath.Search(path, i) + if err != nil { + return nil, err + } + + v := reflect.ValueOf(result) + if !v.IsValid() || (v.Kind() == reflect.Ptr && v.IsNil()) { + return nil, nil + } + if s, ok := result.([]interface{}); ok { + return s, err + } + if v.Kind() == reflect.Map && v.Len() == 0 { + return nil, nil + } + if v.Kind() == reflect.Slice { + out := make([]interface{}, v.Len()) + for i := 0; i < v.Len(); i++ { + out[i] = v.Index(i).Interface() + } + return out, nil + } + + return []interface{}{result}, nil +} + +// SetValueAtPath sets a value at the case insensitive lexical path inside +// of a structure. +func SetValueAtPath(i interface{}, path string, v interface{}) { + if rvals := rValuesAtPath(i, path, true, false, v == nil); rvals != nil { + for _, rval := range rvals { + if rval.Kind() == reflect.Ptr && rval.IsNil() { + continue + } + setValue(rval, v) + } + } +} + +func setValue(dstVal reflect.Value, src interface{}) { + if dstVal.Kind() == reflect.Ptr { + dstVal = reflect.Indirect(dstVal) + } + srcVal := reflect.ValueOf(src) + + if !srcVal.IsValid() { // src is literal nil + if dstVal.CanAddr() { + // Convert to pointer so that pointer's value can be nil'ed + // dstVal = dstVal.Addr() + } + dstVal.Set(reflect.Zero(dstVal.Type())) + + } else if srcVal.Kind() == reflect.Ptr { + if srcVal.IsNil() { + srcVal = reflect.Zero(dstVal.Type()) + } else { + srcVal = reflect.ValueOf(src).Elem() + } + dstVal.Set(srcVal) + } else { + dstVal.Set(srcVal) + } + +} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/prettify.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/prettify.go new file mode 100644 index 0000000000..0de3eaa0f6 --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/prettify.go @@ -0,0 +1,103 @@ +package awsutil + +import ( + "bytes" + "fmt" + "io" + "reflect" + "strings" +) + +// Prettify returns the string representation of a value. +func Prettify(i interface{}) string { + var buf bytes.Buffer + prettify(reflect.ValueOf(i), 0, &buf) + return buf.String() +} + +// prettify will recursively walk value v to build a textual +// representation of the value. +func prettify(v reflect.Value, indent int, buf *bytes.Buffer) { + for v.Kind() == reflect.Ptr { + v = v.Elem() + } + + switch v.Kind() { + case reflect.Struct: + strtype := v.Type().String() + if strtype == "time.Time" { + fmt.Fprintf(buf, "%s", v.Interface()) + break + } else if strings.HasPrefix(strtype, "io.") { + buf.WriteString("") + break + } + + buf.WriteString("{\n") + + names := []string{} + for i := 0; i < v.Type().NumField(); i++ { + name := v.Type().Field(i).Name + f := v.Field(i) + if name[0:1] == strings.ToLower(name[0:1]) { + continue // ignore unexported fields + } + if (f.Kind() == reflect.Ptr || f.Kind() == reflect.Slice || f.Kind() == reflect.Map) && f.IsNil() { + continue // ignore unset fields + } + names = append(names, name) + } + + for i, n := range names { + val := v.FieldByName(n) + buf.WriteString(strings.Repeat(" ", indent+2)) + buf.WriteString(n + ": ") + prettify(val, indent+2, buf) + + if i < len(names)-1 { + buf.WriteString(",\n") + } + } + + buf.WriteString("\n" + strings.Repeat(" ", indent) + "}") + case reflect.Slice: + nl, id, id2 := "", "", "" + if v.Len() > 3 { + nl, id, id2 = "\n", strings.Repeat(" ", indent), strings.Repeat(" ", indent+2) + } + buf.WriteString("[" + nl) + for i := 0; i < v.Len(); i++ { + buf.WriteString(id2) + prettify(v.Index(i), indent+2, buf) + + if i < v.Len()-1 { + buf.WriteString("," + nl) + } + } + + buf.WriteString(nl + id + "]") + case reflect.Map: + buf.WriteString("{\n") + + for i, k := range v.MapKeys() { + buf.WriteString(strings.Repeat(" ", indent+2)) + buf.WriteString(k.String() + ": ") + prettify(v.MapIndex(k), indent+2, buf) + + if i < v.Len()-1 { + buf.WriteString(",\n") + } + } + + buf.WriteString("\n" + strings.Repeat(" ", indent) + "}") + default: + format := "%v" + switch v.Interface().(type) { + case string: + format = "%q" + case io.ReadSeeker, io.Reader: + format = "buffer(%p)" + } + fmt.Fprintf(buf, format, v.Interface()) + } +} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/string_value.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/string_value.go new file mode 100644 index 0000000000..b6432f1a11 --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/string_value.go @@ -0,0 +1,89 @@ +package awsutil + +import ( + "bytes" + "fmt" + "reflect" + "strings" +) + +// StringValue returns the string representation of a value. +func StringValue(i interface{}) string { + var buf bytes.Buffer + stringValue(reflect.ValueOf(i), 0, &buf) + return buf.String() +} + +func stringValue(v reflect.Value, indent int, buf *bytes.Buffer) { + for v.Kind() == reflect.Ptr { + v = v.Elem() + } + + switch v.Kind() { + case reflect.Struct: + buf.WriteString("{\n") + + names := []string{} + for i := 0; i < v.Type().NumField(); i++ { + name := v.Type().Field(i).Name + f := v.Field(i) + if name[0:1] == strings.ToLower(name[0:1]) { + continue // ignore unexported fields + } + if (f.Kind() == reflect.Ptr || f.Kind() == reflect.Slice) && f.IsNil() { + continue // ignore unset fields + } + names = append(names, name) + } + + for i, n := range names { + val := v.FieldByName(n) + buf.WriteString(strings.Repeat(" ", indent+2)) + buf.WriteString(n + ": ") + stringValue(val, indent+2, buf) + + if i < len(names)-1 { + buf.WriteString(",\n") + } + } + + buf.WriteString("\n" + strings.Repeat(" ", indent) + "}") + case reflect.Slice: + nl, id, id2 := "", "", "" + if v.Len() > 3 { + nl, id, id2 = "\n", strings.Repeat(" ", indent), strings.Repeat(" ", indent+2) + } + buf.WriteString("[" + nl) + for i := 0; i < v.Len(); i++ { + buf.WriteString(id2) + stringValue(v.Index(i), indent+2, buf) + + if i < v.Len()-1 { + buf.WriteString("," + nl) + } + } + + buf.WriteString(nl + id + "]") + case reflect.Map: + buf.WriteString("{\n") + + for i, k := range v.MapKeys() { + buf.WriteString(strings.Repeat(" ", indent+2)) + buf.WriteString(k.String() + ": ") + stringValue(v.MapIndex(k), indent+2, buf) + + if i < v.Len()-1 { + buf.WriteString(",\n") + } + } + + buf.WriteString("\n" + strings.Repeat(" ", indent) + "}") + default: + format := "%v" + switch v.Interface().(type) { + case string: + format = "%q" + } + fmt.Fprintf(buf, format, v.Interface()) + } +} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/client/metadata/client_info.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/client/metadata/client_info.go new file mode 100644 index 0000000000..4778056ddf --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/client/metadata/client_info.go @@ -0,0 +1,12 @@ +package metadata + +// ClientInfo wraps immutable data from the client.Client structure. +type ClientInfo struct { + ServiceName string + APIVersion string + Endpoint string + SigningName string + SigningRegion string + JSONVersion string + TargetPrefix string +} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/config.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/config.go new file mode 100644 index 0000000000..9e83e9260a --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/config.go @@ -0,0 +1,311 @@ +package aws + +import ( + "net/http" + "time" + + "github.com/aws/aws-sdk-go/aws/credentials" +) + +// UseServiceDefaultRetries instructs the config to use the service's own default +// number of retries. This will be the default action if Config.MaxRetries +// is nil also. +const UseServiceDefaultRetries = -1 + +// RequestRetryer is an alias for a type that implements the request.Retryer interface. +type RequestRetryer interface{} + +// A Config provides service configuration for service clients. By default, +// all clients will use the {defaults.DefaultConfig} structure. +type Config struct { + // Enables verbose error printing of all credential chain errors. + // Should be used when wanting to see all errors while attempting to retreive + // credentials. + CredentialsChainVerboseErrors *bool + + // The credentials object to use when signing requests. Defaults to + // a chain of credential providers to search for credentials in environment + // variables, shared credential file, and EC2 Instance Roles. + Credentials *credentials.Credentials + + // An optional endpoint URL (hostname only or fully qualified URI) + // that overrides the default generated endpoint for a client. Set this + // to `""` to use the default generated endpoint. + // + // @note You must still provide a `Region` value when specifying an + // endpoint for a client. + Endpoint *string + + // The region to send requests to. This parameter is required and must + // be configured globally or on a per-client basis unless otherwise + // noted. A full list of regions is found in the "Regions and Endpoints" + // document. + // + // @see http://docs.aws.amazon.com/general/latest/gr/rande.html + // AWS Regions and Endpoints + Region *string + + // Set this to `true` to disable SSL when sending requests. Defaults + // to `false`. + DisableSSL *bool + + // The HTTP client to use when sending requests. Defaults to + // `http.DefaultClient`. + HTTPClient *http.Client + + // An integer value representing the logging level. The default log level + // is zero (LogOff), which represents no logging. To enable logging set + // to a LogLevel Value. + LogLevel *LogLevelType + + // The logger writer interface to write logging messages to. Defaults to + // standard out. + Logger Logger + + // The maximum number of times that a request will be retried for failures. + // Defaults to -1, which defers the max retry setting to the service specific + // configuration. + MaxRetries *int + + // Retryer guides how HTTP requests should be retried in case of recoverable failures. + // + // When nil or the value does not implement the request.Retryer interface, + // the request.DefaultRetryer will be used. + // + // When both Retryer and MaxRetries are non-nil, the former is used and + // the latter ignored. + // + // To set the Retryer field in a type-safe manner and with chaining, use + // the request.WithRetryer helper function: + // + // cfg := request.WithRetryer(aws.NewConfig(), myRetryer) + // + Retryer RequestRetryer + + // Disables semantic parameter validation, which validates input for missing + // required fields and/or other semantic request input errors. + DisableParamValidation *bool + + // Disables the computation of request and response checksums, e.g., + // CRC32 checksums in Amazon DynamoDB. + DisableComputeChecksums *bool + + // Set this to `true` to force the request to use path-style addressing, + // i.e., `http://s3.amazonaws.com/BUCKET/KEY`. By default, the S3 client will + // use virtual hosted bucket addressing when possible + // (`http://BUCKET.s3.amazonaws.com/KEY`). + // + // @note This configuration option is specific to the Amazon S3 service. + // @see http://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html + // Amazon S3: Virtual Hosting of Buckets + S3ForcePathStyle *bool + + // Set this to `true` to disable the EC2Metadata client from overriding the + // default http.Client's Timeout. This is helpful if you do not want the EC2Metadata + // client to create a new http.Client. This options is only meaningful if you're not + // already using a custom HTTP client with the SDK. Enabled by default. + // + // Must be set and provided to the session.New() in order to disable the EC2Metadata + // overriding the timeout for default credentials chain. + // + // Example: + // sess := session.New(aws.NewConfig().WithEC2MetadataDiableTimeoutOverride(true)) + // svc := s3.New(sess) + // + EC2MetadataDisableTimeoutOverride *bool + + SleepDelay func(time.Duration) +} + +// NewConfig returns a new Config pointer that can be chained with builder methods to +// set multiple configuration values inline without using pointers. +// +// svc := s3.New(aws.NewConfig().WithRegion("us-west-2").WithMaxRetries(10)) +// +func NewConfig() *Config { + return &Config{} +} + +// WithCredentialsChainVerboseErrors sets a config verbose errors boolean and returning +// a Config pointer. +func (c *Config) WithCredentialsChainVerboseErrors(verboseErrs bool) *Config { + c.CredentialsChainVerboseErrors = &verboseErrs + return c +} + +// WithCredentials sets a config Credentials value returning a Config pointer +// for chaining. +func (c *Config) WithCredentials(creds *credentials.Credentials) *Config { + c.Credentials = creds + return c +} + +// WithEndpoint sets a config Endpoint value returning a Config pointer for +// chaining. +func (c *Config) WithEndpoint(endpoint string) *Config { + c.Endpoint = &endpoint + return c +} + +// WithRegion sets a config Region value returning a Config pointer for +// chaining. +func (c *Config) WithRegion(region string) *Config { + c.Region = ®ion + return c +} + +// WithDisableSSL sets a config DisableSSL value returning a Config pointer +// for chaining. +func (c *Config) WithDisableSSL(disable bool) *Config { + c.DisableSSL = &disable + return c +} + +// WithHTTPClient sets a config HTTPClient value returning a Config pointer +// for chaining. +func (c *Config) WithHTTPClient(client *http.Client) *Config { + c.HTTPClient = client + return c +} + +// WithMaxRetries sets a config MaxRetries value returning a Config pointer +// for chaining. +func (c *Config) WithMaxRetries(max int) *Config { + c.MaxRetries = &max + return c +} + +// WithDisableParamValidation sets a config DisableParamValidation value +// returning a Config pointer for chaining. +func (c *Config) WithDisableParamValidation(disable bool) *Config { + c.DisableParamValidation = &disable + return c +} + +// WithDisableComputeChecksums sets a config DisableComputeChecksums value +// returning a Config pointer for chaining. +func (c *Config) WithDisableComputeChecksums(disable bool) *Config { + c.DisableComputeChecksums = &disable + return c +} + +// WithLogLevel sets a config LogLevel value returning a Config pointer for +// chaining. +func (c *Config) WithLogLevel(level LogLevelType) *Config { + c.LogLevel = &level + return c +} + +// WithLogger sets a config Logger value returning a Config pointer for +// chaining. +func (c *Config) WithLogger(logger Logger) *Config { + c.Logger = logger + return c +} + +// WithS3ForcePathStyle sets a config S3ForcePathStyle value returning a Config +// pointer for chaining. +func (c *Config) WithS3ForcePathStyle(force bool) *Config { + c.S3ForcePathStyle = &force + return c +} + +// WithEC2MetadataDisableTimeoutOverride sets a config EC2MetadataDisableTimeoutOverride value +// returning a Config pointer for chaining. +func (c *Config) WithEC2MetadataDisableTimeoutOverride(enable bool) *Config { + c.EC2MetadataDisableTimeoutOverride = &enable + return c +} + +// WithSleepDelay overrides the function used to sleep while waiting for the +// next retry. Defaults to time.Sleep. +func (c *Config) WithSleepDelay(fn func(time.Duration)) *Config { + c.SleepDelay = fn + return c +} + +// MergeIn merges the passed in configs into the existing config object. +func (c *Config) MergeIn(cfgs ...*Config) { + for _, other := range cfgs { + mergeInConfig(c, other) + } +} + +func mergeInConfig(dst *Config, other *Config) { + if other == nil { + return + } + + if other.CredentialsChainVerboseErrors != nil { + dst.CredentialsChainVerboseErrors = other.CredentialsChainVerboseErrors + } + + if other.Credentials != nil { + dst.Credentials = other.Credentials + } + + if other.Endpoint != nil { + dst.Endpoint = other.Endpoint + } + + if other.Region != nil { + dst.Region = other.Region + } + + if other.DisableSSL != nil { + dst.DisableSSL = other.DisableSSL + } + + if other.HTTPClient != nil { + dst.HTTPClient = other.HTTPClient + } + + if other.LogLevel != nil { + dst.LogLevel = other.LogLevel + } + + if other.Logger != nil { + dst.Logger = other.Logger + } + + if other.MaxRetries != nil { + dst.MaxRetries = other.MaxRetries + } + + if other.Retryer != nil { + dst.Retryer = other.Retryer + } + + if other.DisableParamValidation != nil { + dst.DisableParamValidation = other.DisableParamValidation + } + + if other.DisableComputeChecksums != nil { + dst.DisableComputeChecksums = other.DisableComputeChecksums + } + + if other.S3ForcePathStyle != nil { + dst.S3ForcePathStyle = other.S3ForcePathStyle + } + + if other.EC2MetadataDisableTimeoutOverride != nil { + dst.EC2MetadataDisableTimeoutOverride = other.EC2MetadataDisableTimeoutOverride + } + + if other.SleepDelay != nil { + dst.SleepDelay = other.SleepDelay + } +} + +// Copy will return a shallow copy of the Config object. If any additional +// configurations are provided they will be merged into the new config returned. +func (c *Config) Copy(cfgs ...*Config) *Config { + dst := &Config{} + dst.MergeIn(c) + + for _, cfg := range cfgs { + dst.MergeIn(cfg) + } + + return dst +} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/convert_types.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/convert_types.go new file mode 100644 index 0000000000..d6a7b08dff --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/convert_types.go @@ -0,0 +1,357 @@ +package aws + +import "time" + +// String returns a pointer to of the string value passed in. +func String(v string) *string { + return &v +} + +// StringValue returns the value of the string pointer passed in or +// "" if the pointer is nil. +func StringValue(v *string) string { + if v != nil { + return *v + } + return "" +} + +// StringSlice converts a slice of string values into a slice of +// string pointers +func StringSlice(src []string) []*string { + dst := make([]*string, len(src)) + for i := 0; i < len(src); i++ { + dst[i] = &(src[i]) + } + return dst +} + +// StringValueSlice converts a slice of string pointers into a slice of +// string values +func StringValueSlice(src []*string) []string { + dst := make([]string, len(src)) + for i := 0; i < len(src); i++ { + if src[i] != nil { + dst[i] = *(src[i]) + } + } + return dst +} + +// StringMap converts a string map of string values into a string +// map of string pointers +func StringMap(src map[string]string) map[string]*string { + dst := make(map[string]*string) + for k, val := range src { + v := val + dst[k] = &v + } + return dst +} + +// StringValueMap converts a string map of string pointers into a string +// map of string values +func StringValueMap(src map[string]*string) map[string]string { + dst := make(map[string]string) + for k, val := range src { + if val != nil { + dst[k] = *val + } + } + return dst +} + +// Bool returns a pointer to of the bool value passed in. +func Bool(v bool) *bool { + return &v +} + +// BoolValue returns the value of the bool pointer passed in or +// false if the pointer is nil. +func BoolValue(v *bool) bool { + if v != nil { + return *v + } + return false +} + +// BoolSlice converts a slice of bool values into a slice of +// bool pointers +func BoolSlice(src []bool) []*bool { + dst := make([]*bool, len(src)) + for i := 0; i < len(src); i++ { + dst[i] = &(src[i]) + } + return dst +} + +// BoolValueSlice converts a slice of bool pointers into a slice of +// bool values +func BoolValueSlice(src []*bool) []bool { + dst := make([]bool, len(src)) + for i := 0; i < len(src); i++ { + if src[i] != nil { + dst[i] = *(src[i]) + } + } + return dst +} + +// BoolMap converts a string map of bool values into a string +// map of bool pointers +func BoolMap(src map[string]bool) map[string]*bool { + dst := make(map[string]*bool) + for k, val := range src { + v := val + dst[k] = &v + } + return dst +} + +// BoolValueMap converts a string map of bool pointers into a string +// map of bool values +func BoolValueMap(src map[string]*bool) map[string]bool { + dst := make(map[string]bool) + for k, val := range src { + if val != nil { + dst[k] = *val + } + } + return dst +} + +// Int returns a pointer to of the int value passed in. +func Int(v int) *int { + return &v +} + +// IntValue returns the value of the int pointer passed in or +// 0 if the pointer is nil. +func IntValue(v *int) int { + if v != nil { + return *v + } + return 0 +} + +// IntSlice converts a slice of int values into a slice of +// int pointers +func IntSlice(src []int) []*int { + dst := make([]*int, len(src)) + for i := 0; i < len(src); i++ { + dst[i] = &(src[i]) + } + return dst +} + +// IntValueSlice converts a slice of int pointers into a slice of +// int values +func IntValueSlice(src []*int) []int { + dst := make([]int, len(src)) + for i := 0; i < len(src); i++ { + if src[i] != nil { + dst[i] = *(src[i]) + } + } + return dst +} + +// IntMap converts a string map of int values into a string +// map of int pointers +func IntMap(src map[string]int) map[string]*int { + dst := make(map[string]*int) + for k, val := range src { + v := val + dst[k] = &v + } + return dst +} + +// IntValueMap converts a string map of int pointers into a string +// map of int values +func IntValueMap(src map[string]*int) map[string]int { + dst := make(map[string]int) + for k, val := range src { + if val != nil { + dst[k] = *val + } + } + return dst +} + +// Int64 returns a pointer to of the int64 value passed in. +func Int64(v int64) *int64 { + return &v +} + +// Int64Value returns the value of the int64 pointer passed in or +// 0 if the pointer is nil. +func Int64Value(v *int64) int64 { + if v != nil { + return *v + } + return 0 +} + +// Int64Slice converts a slice of int64 values into a slice of +// int64 pointers +func Int64Slice(src []int64) []*int64 { + dst := make([]*int64, len(src)) + for i := 0; i < len(src); i++ { + dst[i] = &(src[i]) + } + return dst +} + +// Int64ValueSlice converts a slice of int64 pointers into a slice of +// int64 values +func Int64ValueSlice(src []*int64) []int64 { + dst := make([]int64, len(src)) + for i := 0; i < len(src); i++ { + if src[i] != nil { + dst[i] = *(src[i]) + } + } + return dst +} + +// Int64Map converts a string map of int64 values into a string +// map of int64 pointers +func Int64Map(src map[string]int64) map[string]*int64 { + dst := make(map[string]*int64) + for k, val := range src { + v := val + dst[k] = &v + } + return dst +} + +// Int64ValueMap converts a string map of int64 pointers into a string +// map of int64 values +func Int64ValueMap(src map[string]*int64) map[string]int64 { + dst := make(map[string]int64) + for k, val := range src { + if val != nil { + dst[k] = *val + } + } + return dst +} + +// Float64 returns a pointer to of the float64 value passed in. +func Float64(v float64) *float64 { + return &v +} + +// Float64Value returns the value of the float64 pointer passed in or +// 0 if the pointer is nil. +func Float64Value(v *float64) float64 { + if v != nil { + return *v + } + return 0 +} + +// Float64Slice converts a slice of float64 values into a slice of +// float64 pointers +func Float64Slice(src []float64) []*float64 { + dst := make([]*float64, len(src)) + for i := 0; i < len(src); i++ { + dst[i] = &(src[i]) + } + return dst +} + +// Float64ValueSlice converts a slice of float64 pointers into a slice of +// float64 values +func Float64ValueSlice(src []*float64) []float64 { + dst := make([]float64, len(src)) + for i := 0; i < len(src); i++ { + if src[i] != nil { + dst[i] = *(src[i]) + } + } + return dst +} + +// Float64Map converts a string map of float64 values into a string +// map of float64 pointers +func Float64Map(src map[string]float64) map[string]*float64 { + dst := make(map[string]*float64) + for k, val := range src { + v := val + dst[k] = &v + } + return dst +} + +// Float64ValueMap converts a string map of float64 pointers into a string +// map of float64 values +func Float64ValueMap(src map[string]*float64) map[string]float64 { + dst := make(map[string]float64) + for k, val := range src { + if val != nil { + dst[k] = *val + } + } + return dst +} + +// Time returns a pointer to of the time.Time value passed in. +func Time(v time.Time) *time.Time { + return &v +} + +// TimeValue returns the value of the time.Time pointer passed in or +// time.Time{} if the pointer is nil. +func TimeValue(v *time.Time) time.Time { + if v != nil { + return *v + } + return time.Time{} +} + +// TimeSlice converts a slice of time.Time values into a slice of +// time.Time pointers +func TimeSlice(src []time.Time) []*time.Time { + dst := make([]*time.Time, len(src)) + for i := 0; i < len(src); i++ { + dst[i] = &(src[i]) + } + return dst +} + +// TimeValueSlice converts a slice of time.Time pointers into a slice of +// time.Time values +func TimeValueSlice(src []*time.Time) []time.Time { + dst := make([]time.Time, len(src)) + for i := 0; i < len(src); i++ { + if src[i] != nil { + dst[i] = *(src[i]) + } + } + return dst +} + +// TimeMap converts a string map of time.Time values into a string +// map of time.Time pointers +func TimeMap(src map[string]time.Time) map[string]*time.Time { + dst := make(map[string]*time.Time) + for k, val := range src { + v := val + dst[k] = &v + } + return dst +} + +// TimeValueMap converts a string map of time.Time pointers into a string +// map of time.Time values +func TimeValueMap(src map[string]*time.Time) map[string]time.Time { + dst := make(map[string]time.Time) + for k, val := range src { + if val != nil { + dst[k] = *val + } + } + return dst +} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/chain_provider.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/chain_provider.go new file mode 100644 index 0000000000..857311f64c --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/chain_provider.go @@ -0,0 +1,100 @@ +package credentials + +import ( + "github.com/aws/aws-sdk-go/aws/awserr" +) + +var ( + // ErrNoValidProvidersFoundInChain Is returned when there are no valid + // providers in the ChainProvider. + // + // This has been deprecated. For verbose error messaging set + // aws.Config.CredentialsChainVerboseErrors to true + // + // @readonly + ErrNoValidProvidersFoundInChain = awserr.New("NoCredentialProviders", + `no valid providers in chain. Deprecated. + For verbose messaging see aws.Config.CredentialsChainVerboseErrors`, + nil) +) + +// A ChainProvider will search for a provider which returns credentials +// and cache that provider until Retrieve is called again. +// +// The ChainProvider provides a way of chaining multiple providers together +// which will pick the first available using priority order of the Providers +// in the list. +// +// If none of the Providers retrieve valid credentials Value, ChainProvider's +// Retrieve() will return the error ErrNoValidProvidersFoundInChain. +// +// If a Provider is found which returns valid credentials Value ChainProvider +// will cache that Provider for all calls to IsExpired(), until Retrieve is +// called again. +// +// Example of ChainProvider to be used with an EnvProvider and EC2RoleProvider. +// In this example EnvProvider will first check if any credentials are available +// vai the environment variables. If there are none ChainProvider will check +// the next Provider in the list, EC2RoleProvider in this case. If EC2RoleProvider +// does not return any credentials ChainProvider will return the error +// ErrNoValidProvidersFoundInChain +// +// creds := NewChainCredentials( +// []Provider{ +// &EnvProvider{}, +// &EC2RoleProvider{ +// Client: ec2metadata.New(sess), +// }, +// }) +// +// // Usage of ChainCredentials with aws.Config +// svc := ec2.New(&aws.Config{Credentials: creds}) +// +type ChainProvider struct { + Providers []Provider + curr Provider + VerboseErrors bool +} + +// NewChainCredentials returns a pointer to a new Credentials object +// wrapping a chain of providers. +func NewChainCredentials(providers []Provider) *Credentials { + return NewCredentials(&ChainProvider{ + Providers: append([]Provider{}, providers...), + }) +} + +// Retrieve returns the credentials value or error if no provider returned +// without error. +// +// If a provider is found it will be cached and any calls to IsExpired() +// will return the expired state of the cached provider. +func (c *ChainProvider) Retrieve() (Value, error) { + var errs []error + for _, p := range c.Providers { + creds, err := p.Retrieve() + if err == nil { + c.curr = p + return creds, nil + } + errs = append(errs, err) + } + c.curr = nil + + var err error + err = ErrNoValidProvidersFoundInChain + if c.VerboseErrors { + err = awserr.NewBatchError("NoCredentialProviders", "no valid providers in chain", errs) + } + return Value{}, err +} + +// IsExpired will returned the expired state of the currently cached provider +// if there is one. If there is no current provider, true will be returned. +func (c *ChainProvider) IsExpired() bool { + if c.curr != nil { + return c.curr.IsExpired() + } + + return true +} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/credentials.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/credentials.go new file mode 100644 index 0000000000..7b8ebf5f9d --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/credentials.go @@ -0,0 +1,223 @@ +// Package credentials provides credential retrieval and management +// +// The Credentials is the primary method of getting access to and managing +// credentials Values. Using dependency injection retrieval of the credential +// values is handled by a object which satisfies the Provider interface. +// +// By default the Credentials.Get() will cache the successful result of a +// Provider's Retrieve() until Provider.IsExpired() returns true. At which +// point Credentials will call Provider's Retrieve() to get new credential Value. +// +// The Provider is responsible for determining when credentials Value have expired. +// It is also important to note that Credentials will always call Retrieve the +// first time Credentials.Get() is called. +// +// Example of using the environment variable credentials. +// +// creds := NewEnvCredentials() +// +// // Retrieve the credentials value +// credValue, err := creds.Get() +// if err != nil { +// // handle error +// } +// +// Example of forcing credentials to expire and be refreshed on the next Get(). +// This may be helpful to proactively expire credentials and refresh them sooner +// than they would naturally expire on their own. +// +// creds := NewCredentials(&EC2RoleProvider{}) +// creds.Expire() +// credsValue, err := creds.Get() +// // New credentials will be retrieved instead of from cache. +// +// +// Custom Provider +// +// Each Provider built into this package also provides a helper method to generate +// a Credentials pointer setup with the provider. To use a custom Provider just +// create a type which satisfies the Provider interface and pass it to the +// NewCredentials method. +// +// type MyProvider struct{} +// func (m *MyProvider) Retrieve() (Value, error) {...} +// func (m *MyProvider) IsExpired() bool {...} +// +// creds := NewCredentials(&MyProvider{}) +// credValue, err := creds.Get() +// +package credentials + +import ( + "sync" + "time" +) + +// AnonymousCredentials is an empty Credential object that can be used as +// dummy placeholder credentials for requests that do not need signed. +// +// This Credentials can be used to configure a service to not sign requests +// when making service API calls. For example, when accessing public +// s3 buckets. +// +// svc := s3.New(&aws.Config{Credentials: AnonymousCredentials}) +// // Access public S3 buckets. +// +// @readonly +var AnonymousCredentials = NewStaticCredentials("", "", "") + +// A Value is the AWS credentials value for individual credential fields. +type Value struct { + // AWS Access key ID + AccessKeyID string + + // AWS Secret Access Key + SecretAccessKey string + + // AWS Session Token + SessionToken string + + // Provider used to get credentials + ProviderName string +} + +// A Provider is the interface for any component which will provide credentials +// Value. A provider is required to manage its own Expired state, and what to +// be expired means. +// +// The Provider should not need to implement its own mutexes, because +// that will be managed by Credentials. +type Provider interface { + // Refresh returns nil if it successfully retrieved the value. + // Error is returned if the value were not obtainable, or empty. + Retrieve() (Value, error) + + // IsExpired returns if the credentials are no longer valid, and need + // to be retrieved. + IsExpired() bool +} + +// A Expiry provides shared expiration logic to be used by credentials +// providers to implement expiry functionality. +// +// The best method to use this struct is as an anonymous field within the +// provider's struct. +// +// Example: +// type EC2RoleProvider struct { +// Expiry +// ... +// } +type Expiry struct { + // The date/time when to expire on + expiration time.Time + + // If set will be used by IsExpired to determine the current time. + // Defaults to time.Now if CurrentTime is not set. Available for testing + // to be able to mock out the current time. + CurrentTime func() time.Time +} + +// SetExpiration sets the expiration IsExpired will check when called. +// +// If window is greater than 0 the expiration time will be reduced by the +// window value. +// +// Using a window is helpful to trigger credentials to expire sooner than +// the expiration time given to ensure no requests are made with expired +// tokens. +func (e *Expiry) SetExpiration(expiration time.Time, window time.Duration) { + e.expiration = expiration + if window > 0 { + e.expiration = e.expiration.Add(-window) + } +} + +// IsExpired returns if the credentials are expired. +func (e *Expiry) IsExpired() bool { + if e.CurrentTime == nil { + e.CurrentTime = time.Now + } + return e.expiration.Before(e.CurrentTime()) +} + +// A Credentials provides synchronous safe retrieval of AWS credentials Value. +// Credentials will cache the credentials value until they expire. Once the value +// expires the next Get will attempt to retrieve valid credentials. +// +// Credentials is safe to use across multiple goroutines and will manage the +// synchronous state so the Providers do not need to implement their own +// synchronization. +// +// The first Credentials.Get() will always call Provider.Retrieve() to get the +// first instance of the credentials Value. All calls to Get() after that +// will return the cached credentials Value until IsExpired() returns true. +type Credentials struct { + creds Value + forceRefresh bool + m sync.Mutex + + provider Provider +} + +// NewCredentials returns a pointer to a new Credentials with the provider set. +func NewCredentials(provider Provider) *Credentials { + return &Credentials{ + provider: provider, + forceRefresh: true, + } +} + +// Get returns the credentials value, or error if the credentials Value failed +// to be retrieved. +// +// Will return the cached credentials Value if it has not expired. If the +// credentials Value has expired the Provider's Retrieve() will be called +// to refresh the credentials. +// +// If Credentials.Expire() was called the credentials Value will be force +// expired, and the next call to Get() will cause them to be refreshed. +func (c *Credentials) Get() (Value, error) { + c.m.Lock() + defer c.m.Unlock() + + if c.isExpired() { + creds, err := c.provider.Retrieve() + if err != nil { + return Value{}, err + } + c.creds = creds + c.forceRefresh = false + } + + return c.creds, nil +} + +// Expire expires the credentials and forces them to be retrieved on the +// next call to Get(). +// +// This will override the Provider's expired state, and force Credentials +// to call the Provider's Retrieve(). +func (c *Credentials) Expire() { + c.m.Lock() + defer c.m.Unlock() + + c.forceRefresh = true +} + +// IsExpired returns if the credentials are no longer valid, and need +// to be retrieved. +// +// If the Credentials were forced to be expired with Expire() this will +// reflect that override. +func (c *Credentials) IsExpired() bool { + c.m.Lock() + defer c.m.Unlock() + + return c.isExpired() +} + +// isExpired helper method wrapping the definition of expired credentials. +func (c *Credentials) isExpired() bool { + return c.forceRefresh || c.provider.IsExpired() +} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/env_provider.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/env_provider.go new file mode 100644 index 0000000000..96655bc46a --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/env_provider.go @@ -0,0 +1,77 @@ +package credentials + +import ( + "os" + + "github.com/aws/aws-sdk-go/aws/awserr" +) + +// EnvProviderName provides a name of Env provider +const EnvProviderName = "EnvProvider" + +var ( + // ErrAccessKeyIDNotFound is returned when the AWS Access Key ID can't be + // found in the process's environment. + // + // @readonly + ErrAccessKeyIDNotFound = awserr.New("EnvAccessKeyNotFound", "AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY not found in environment", nil) + + // ErrSecretAccessKeyNotFound is returned when the AWS Secret Access Key + // can't be found in the process's environment. + // + // @readonly + ErrSecretAccessKeyNotFound = awserr.New("EnvSecretNotFound", "AWS_SECRET_ACCESS_KEY or AWS_SECRET_KEY not found in environment", nil) +) + +// A EnvProvider retrieves credentials from the environment variables of the +// running process. Environment credentials never expire. +// +// Environment variables used: +// +// * Access Key ID: AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY +// * Secret Access Key: AWS_SECRET_ACCESS_KEY or AWS_SECRET_KEY +type EnvProvider struct { + retrieved bool +} + +// NewEnvCredentials returns a pointer to a new Credentials object +// wrapping the environment variable provider. +func NewEnvCredentials() *Credentials { + return NewCredentials(&EnvProvider{}) +} + +// Retrieve retrieves the keys from the environment. +func (e *EnvProvider) Retrieve() (Value, error) { + e.retrieved = false + + id := os.Getenv("AWS_ACCESS_KEY_ID") + if id == "" { + id = os.Getenv("AWS_ACCESS_KEY") + } + + secret := os.Getenv("AWS_SECRET_ACCESS_KEY") + if secret == "" { + secret = os.Getenv("AWS_SECRET_KEY") + } + + if id == "" { + return Value{ProviderName: EnvProviderName}, ErrAccessKeyIDNotFound + } + + if secret == "" { + return Value{ProviderName: EnvProviderName}, ErrSecretAccessKeyNotFound + } + + e.retrieved = true + return Value{ + AccessKeyID: id, + SecretAccessKey: secret, + SessionToken: os.Getenv("AWS_SESSION_TOKEN"), + ProviderName: EnvProviderName, + }, nil +} + +// IsExpired returns if the credentials have been retrieved. +func (e *EnvProvider) IsExpired() bool { + return !e.retrieved +} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/example.ini b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/example.ini new file mode 100644 index 0000000000..7fc91d9d20 --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/example.ini @@ -0,0 +1,12 @@ +[default] +aws_access_key_id = accessKey +aws_secret_access_key = secret +aws_session_token = token + +[no_token] +aws_access_key_id = accessKey +aws_secret_access_key = secret + +[with_colon] +aws_access_key_id: accessKey +aws_secret_access_key: secret diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/shared_credentials_provider.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/shared_credentials_provider.go new file mode 100644 index 0000000000..7fb7cbf0db --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/shared_credentials_provider.go @@ -0,0 +1,151 @@ +package credentials + +import ( + "fmt" + "os" + "path/filepath" + + "github.com/go-ini/ini" + + "github.com/aws/aws-sdk-go/aws/awserr" +) + +// SharedCredsProviderName provides a name of SharedCreds provider +const SharedCredsProviderName = "SharedCredentialsProvider" + +var ( + // ErrSharedCredentialsHomeNotFound is emitted when the user directory cannot be found. + // + // @readonly + ErrSharedCredentialsHomeNotFound = awserr.New("UserHomeNotFound", "user home directory not found.", nil) +) + +// A SharedCredentialsProvider retrieves credentials from the current user's home +// directory, and keeps track if those credentials are expired. +// +// Profile ini file example: $HOME/.aws/credentials +type SharedCredentialsProvider struct { + // Path to the shared credentials file. + // + // If empty will look for "AWS_SHARED_CREDENTIALS_FILE" env variable. If the + // env value is empty will default to current user's home directory. + // Linux/OSX: "$HOME/.aws/credentials" + // Windows: "%USERPROFILE%\.aws\credentials" + Filename string + + // AWS Profile to extract credentials from the shared credentials file. If empty + // will default to environment variable "AWS_PROFILE" or "default" if + // environment variable is also not set. + Profile string + + // retrieved states if the credentials have been successfully retrieved. + retrieved bool +} + +// NewSharedCredentials returns a pointer to a new Credentials object +// wrapping the Profile file provider. +func NewSharedCredentials(filename, profile string) *Credentials { + return NewCredentials(&SharedCredentialsProvider{ + Filename: filename, + Profile: profile, + }) +} + +// Retrieve reads and extracts the shared credentials from the current +// users home directory. +func (p *SharedCredentialsProvider) Retrieve() (Value, error) { + p.retrieved = false + + filename, err := p.filename() + if err != nil { + return Value{ProviderName: SharedCredsProviderName}, err + } + + creds, err := loadProfile(filename, p.profile()) + if err != nil { + return Value{ProviderName: SharedCredsProviderName}, err + } + + p.retrieved = true + return creds, nil +} + +// IsExpired returns if the shared credentials have expired. +func (p *SharedCredentialsProvider) IsExpired() bool { + return !p.retrieved +} + +// loadProfiles loads from the file pointed to by shared credentials filename for profile. +// The credentials retrieved from the profile will be returned or error. Error will be +// returned if it fails to read from the file, or the data is invalid. +func loadProfile(filename, profile string) (Value, error) { + config, err := ini.Load(filename) + if err != nil { + return Value{ProviderName: SharedCredsProviderName}, awserr.New("SharedCredsLoad", "failed to load shared credentials file", err) + } + iniProfile, err := config.GetSection(profile) + if err != nil { + return Value{ProviderName: SharedCredsProviderName}, awserr.New("SharedCredsLoad", "failed to get profile", err) + } + + id, err := iniProfile.GetKey("aws_access_key_id") + if err != nil { + return Value{ProviderName: SharedCredsProviderName}, awserr.New("SharedCredsAccessKey", + fmt.Sprintf("shared credentials %s in %s did not contain aws_access_key_id", profile, filename), + err) + } + + secret, err := iniProfile.GetKey("aws_secret_access_key") + if err != nil { + return Value{ProviderName: SharedCredsProviderName}, awserr.New("SharedCredsSecret", + fmt.Sprintf("shared credentials %s in %s did not contain aws_secret_access_key", profile, filename), + nil) + } + + // Default to empty string if not found + token := iniProfile.Key("aws_session_token") + + return Value{ + AccessKeyID: id.String(), + SecretAccessKey: secret.String(), + SessionToken: token.String(), + ProviderName: SharedCredsProviderName, + }, nil +} + +// filename returns the filename to use to read AWS shared credentials. +// +// Will return an error if the user's home directory path cannot be found. +func (p *SharedCredentialsProvider) filename() (string, error) { + if p.Filename == "" { + if p.Filename = os.Getenv("AWS_SHARED_CREDENTIALS_FILE"); p.Filename != "" { + return p.Filename, nil + } + + homeDir := os.Getenv("HOME") // *nix + if homeDir == "" { // Windows + homeDir = os.Getenv("USERPROFILE") + } + if homeDir == "" { + return "", ErrSharedCredentialsHomeNotFound + } + + p.Filename = filepath.Join(homeDir, ".aws", "credentials") + } + + return p.Filename, nil +} + +// profile returns the AWS shared credentials profile. If empty will read +// environment variable "AWS_PROFILE". If that is not set profile will +// return "default". +func (p *SharedCredentialsProvider) profile() string { + if p.Profile == "" { + p.Profile = os.Getenv("AWS_PROFILE") + } + if p.Profile == "" { + p.Profile = "default" + } + + return p.Profile +} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/static_provider.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/static_provider.go new file mode 100644 index 0000000000..71189e733d --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/static_provider.go @@ -0,0 +1,48 @@ +package credentials + +import ( + "github.com/aws/aws-sdk-go/aws/awserr" +) + +// StaticProviderName provides a name of Static provider +const StaticProviderName = "StaticProvider" + +var ( + // ErrStaticCredentialsEmpty is emitted when static credentials are empty. + // + // @readonly + ErrStaticCredentialsEmpty = awserr.New("EmptyStaticCreds", "static credentials are empty", nil) +) + +// A StaticProvider is a set of credentials which are set pragmatically, +// and will never expire. +type StaticProvider struct { + Value +} + +// NewStaticCredentials returns a pointer to a new Credentials object +// wrapping a static credentials value provider. +func NewStaticCredentials(id, secret, token string) *Credentials { + return NewCredentials(&StaticProvider{Value: Value{ + AccessKeyID: id, + SecretAccessKey: secret, + SessionToken: token, + }}) +} + +// Retrieve returns the credentials or error if the credentials are invalid. +func (s *StaticProvider) Retrieve() (Value, error) { + if s.AccessKeyID == "" || s.SecretAccessKey == "" { + return Value{ProviderName: StaticProviderName}, ErrStaticCredentialsEmpty + } + + s.Value.ProviderName = StaticProviderName + return s.Value, nil +} + +// IsExpired returns if the credentials are expired. +// +// For StaticProvider, the credentials never expired. +func (s *StaticProvider) IsExpired() bool { + return false +} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/errors.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/errors.go new file mode 100644 index 0000000000..5766361686 --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/errors.go @@ -0,0 +1,17 @@ +package aws + +import "github.com/aws/aws-sdk-go/aws/awserr" + +var ( + // ErrMissingRegion is an error that is returned if region configuration is + // not found. + // + // @readonly + ErrMissingRegion = awserr.New("MissingRegion", "could not find region configuration", nil) + + // ErrMissingEndpoint is an error that is returned if an endpoint cannot be + // resolved for a service. + // + // @readonly + ErrMissingEndpoint = awserr.New("MissingEndpoint", "'Endpoint' configuration is required for this service", nil) +) diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/logger.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/logger.go new file mode 100644 index 0000000000..db87188e20 --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/logger.go @@ -0,0 +1,112 @@ +package aws + +import ( + "log" + "os" +) + +// A LogLevelType defines the level logging should be performed at. Used to instruct +// the SDK which statements should be logged. +type LogLevelType uint + +// LogLevel returns the pointer to a LogLevel. Should be used to workaround +// not being able to take the address of a non-composite literal. +func LogLevel(l LogLevelType) *LogLevelType { + return &l +} + +// Value returns the LogLevel value or the default value LogOff if the LogLevel +// is nil. Safe to use on nil value LogLevelTypes. +func (l *LogLevelType) Value() LogLevelType { + if l != nil { + return *l + } + return LogOff +} + +// Matches returns true if the v LogLevel is enabled by this LogLevel. Should be +// used with logging sub levels. Is safe to use on nil value LogLevelTypes. If +// LogLevel is nill, will default to LogOff comparison. +func (l *LogLevelType) Matches(v LogLevelType) bool { + c := l.Value() + return c&v == v +} + +// AtLeast returns true if this LogLevel is at least high enough to satisfies v. +// Is safe to use on nil value LogLevelTypes. If LogLevel is nill, will default +// to LogOff comparison. +func (l *LogLevelType) AtLeast(v LogLevelType) bool { + c := l.Value() + return c >= v +} + +const ( + // LogOff states that no logging should be performed by the SDK. This is the + // default state of the SDK, and should be use to disable all logging. + LogOff LogLevelType = iota * 0x1000 + + // LogDebug state that debug output should be logged by the SDK. This should + // be used to inspect request made and responses received. + LogDebug +) + +// Debug Logging Sub Levels +const ( + // LogDebugWithSigning states that the SDK should log request signing and + // presigning events. This should be used to log the signing details of + // requests for debugging. Will also enable LogDebug. + LogDebugWithSigning LogLevelType = LogDebug | (1 << iota) + + // LogDebugWithHTTPBody states the SDK should log HTTP request and response + // HTTP bodys in addition to the headers and path. This should be used to + // see the body content of requests and responses made while using the SDK + // Will also enable LogDebug. + LogDebugWithHTTPBody + + // LogDebugWithRequestRetries states the SDK should log when service requests will + // be retried. This should be used to log when you want to log when service + // requests are being retried. Will also enable LogDebug. + LogDebugWithRequestRetries + + // LogDebugWithRequestErrors states the SDK should log when service requests fail + // to build, send, validate, or unmarshal. + LogDebugWithRequestErrors +) + +// A Logger is a minimalistic interface for the SDK to log messages to. Should +// be used to provide custom logging writers for the SDK to use. +type Logger interface { + Log(...interface{}) +} + +// A LoggerFunc is a convenience type to convert a function taking a variadic +// list of arguments and wrap it so the Logger interface can be used. +// +// Example: +// s3.New(sess, &aws.Config{Logger: aws.LoggerFunc(func(args ...interface{}) { +// fmt.Fprintln(os.Stdout, args...) +// })}) +type LoggerFunc func(...interface{}) + +// Log calls the wrapped function with the arguments provided +func (f LoggerFunc) Log(args ...interface{}) { + f(args...) +} + +// NewDefaultLogger returns a Logger which will write log messages to stdout, and +// use same formatting runes as the stdlib log.Logger +func NewDefaultLogger() Logger { + return &defaultLogger{ + logger: log.New(os.Stdout, "", log.LstdFlags), + } +} + +// A defaultLogger provides a minimalistic logger satisfying the Logger interface. +type defaultLogger struct { + logger *log.Logger +} + +// Log logs the parameters to the stdlib logger. See log.Println. +func (l defaultLogger) Log(args ...interface{}) { + l.logger.Println(args...) +} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/handlers.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/handlers.go new file mode 100644 index 0000000000..5279c19c09 --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/handlers.go @@ -0,0 +1,187 @@ +package request + +import ( + "fmt" + "strings" +) + +// A Handlers provides a collection of request handlers for various +// stages of handling requests. +type Handlers struct { + Validate HandlerList + Build HandlerList + Sign HandlerList + Send HandlerList + ValidateResponse HandlerList + Unmarshal HandlerList + UnmarshalMeta HandlerList + UnmarshalError HandlerList + Retry HandlerList + AfterRetry HandlerList +} + +// Copy returns of this handler's lists. +func (h *Handlers) Copy() Handlers { + return Handlers{ + Validate: h.Validate.copy(), + Build: h.Build.copy(), + Sign: h.Sign.copy(), + Send: h.Send.copy(), + ValidateResponse: h.ValidateResponse.copy(), + Unmarshal: h.Unmarshal.copy(), + UnmarshalError: h.UnmarshalError.copy(), + UnmarshalMeta: h.UnmarshalMeta.copy(), + Retry: h.Retry.copy(), + AfterRetry: h.AfterRetry.copy(), + } +} + +// Clear removes callback functions for all handlers +func (h *Handlers) Clear() { + h.Validate.Clear() + h.Build.Clear() + h.Send.Clear() + h.Sign.Clear() + h.Unmarshal.Clear() + h.UnmarshalMeta.Clear() + h.UnmarshalError.Clear() + h.ValidateResponse.Clear() + h.Retry.Clear() + h.AfterRetry.Clear() +} + +// A HandlerListRunItem represents an entry in the HandlerList which +// is being run. +type HandlerListRunItem struct { + Index int + Handler NamedHandler + Request *Request +} + +// A HandlerList manages zero or more handlers in a list. +type HandlerList struct { + list []NamedHandler + + // Called after each request handler in the list is called. If set + // and the func returns true the HandlerList will continue to iterate + // over the request handlers. If false is returned the HandlerList + // will stop iterating. + // + // Should be used if extra logic to be performed between each handler + // in the list. This can be used to terminate a list's iteration + // based on a condition such as error like, HandlerListStopOnError. + // Or for logging like HandlerListLogItem. + AfterEachFn func(item HandlerListRunItem) bool +} + +// A NamedHandler is a struct that contains a name and function callback. +type NamedHandler struct { + Name string + Fn func(*Request) +} + +// copy creates a copy of the handler list. +func (l *HandlerList) copy() HandlerList { + n := HandlerList{ + AfterEachFn: l.AfterEachFn, + } + n.list = append([]NamedHandler{}, l.list...) + return n +} + +// Clear clears the handler list. +func (l *HandlerList) Clear() { + l.list = []NamedHandler{} +} + +// Len returns the number of handlers in the list. +func (l *HandlerList) Len() int { + return len(l.list) +} + +// PushBack pushes handler f to the back of the handler list. +func (l *HandlerList) PushBack(f func(*Request)) { + l.list = append(l.list, NamedHandler{"__anonymous", f}) +} + +// PushFront pushes handler f to the front of the handler list. +func (l *HandlerList) PushFront(f func(*Request)) { + l.list = append([]NamedHandler{{"__anonymous", f}}, l.list...) +} + +// PushBackNamed pushes named handler f to the back of the handler list. +func (l *HandlerList) PushBackNamed(n NamedHandler) { + l.list = append(l.list, n) +} + +// PushFrontNamed pushes named handler f to the front of the handler list. +func (l *HandlerList) PushFrontNamed(n NamedHandler) { + l.list = append([]NamedHandler{n}, l.list...) +} + +// Remove removes a NamedHandler n +func (l *HandlerList) Remove(n NamedHandler) { + newlist := []NamedHandler{} + for _, m := range l.list { + if m.Name != n.Name { + newlist = append(newlist, m) + } + } + l.list = newlist +} + +// Run executes all handlers in the list with a given request object. +func (l *HandlerList) Run(r *Request) { + for i, h := range l.list { + h.Fn(r) + item := HandlerListRunItem{ + Index: i, Handler: h, Request: r, + } + if l.AfterEachFn != nil && !l.AfterEachFn(item) { + return + } + } +} + +// HandlerListLogItem logs the request handler and the state of the +// request's Error value. Always returns true to continue iterating +// request handlers in a HandlerList. +func HandlerListLogItem(item HandlerListRunItem) bool { + if item.Request.Config.Logger == nil { + return true + } + item.Request.Config.Logger.Log("DEBUG: RequestHandler", + item.Index, item.Handler.Name, item.Request.Error) + + return true +} + +// HandlerListStopOnError returns false to stop the HandlerList iterating +// over request handlers if Request.Error is not nil. True otherwise +// to continue iterating. +func HandlerListStopOnError(item HandlerListRunItem) bool { + return item.Request.Error == nil +} + +// MakeAddToUserAgentHandler will add the name/version pair to the User-Agent request +// header. If the extra parameters are provided they will be added as metadata to the +// name/version pair resulting in the following format. +// "name/version (extra0; extra1; ...)" +// The user agent part will be concatenated with this current request's user agent string. +func MakeAddToUserAgentHandler(name, version string, extra ...string) func(*Request) { + ua := fmt.Sprintf("%s/%s", name, version) + if len(extra) > 0 { + ua += fmt.Sprintf(" (%s)", strings.Join(extra, "; ")) + } + return func(r *Request) { + AddToUserAgent(r, ua) + } +} + +// MakeAddToUserAgentFreeFormHandler adds the input to the User-Agent request header. +// The input string will be concatenated with the current request's user agent string. +func MakeAddToUserAgentFreeFormHandler(s string) func(*Request) { + return func(r *Request) { + AddToUserAgent(r, s) + } +} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/request.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/request.go new file mode 100644 index 0000000000..85eead3d51 --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/request.go @@ -0,0 +1,302 @@ +package request + +import ( + "bytes" + "fmt" + "io" + "io/ioutil" + "net/http" + "net/url" + "reflect" + "strings" + "time" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/client/metadata" +) + +// A Request is the service request to be made. +type Request struct { + Config aws.Config + ClientInfo metadata.ClientInfo + Handlers Handlers + + Retryer + Time time.Time + ExpireTime time.Duration + Operation *Operation + HTTPRequest *http.Request + HTTPResponse *http.Response + Body io.ReadSeeker + BodyStart int64 // offset from beginning of Body that the request body starts + Params interface{} + Error error + Data interface{} + RequestID string + RetryCount int + Retryable *bool + RetryDelay time.Duration + NotHoist bool + SignedHeaderVals http.Header + + built bool +} + +// An Operation is the service API operation to be made. +type Operation struct { + Name string + HTTPMethod string + HTTPPath string + *Paginator +} + +// Paginator keeps track of pagination configuration for an API operation. +type Paginator struct { + InputTokens []string + OutputTokens []string + LimitToken string + TruncationToken string +} + +// New returns a new Request pointer for the service API +// operation and parameters. +// +// Params is any value of input parameters to be the request payload. +// Data is pointer value to an object which the request's response +// payload will be deserialized to. +func New(cfg aws.Config, clientInfo metadata.ClientInfo, handlers Handlers, + retryer Retryer, operation *Operation, params interface{}, data interface{}) *Request { + + method := operation.HTTPMethod + if method == "" { + method = "POST" + } + p := operation.HTTPPath + if p == "" { + p = "/" + } + + httpReq, _ := http.NewRequest(method, "", nil) + httpReq.URL, _ = url.Parse(clientInfo.Endpoint + p) + + r := &Request{ + Config: cfg, + ClientInfo: clientInfo, + Handlers: handlers.Copy(), + + Retryer: retryer, + Time: time.Now(), + ExpireTime: 0, + Operation: operation, + HTTPRequest: httpReq, + Body: nil, + Params: params, + Error: nil, + Data: data, + } + r.SetBufferBody([]byte{}) + + return r +} + +// WillRetry returns if the request's can be retried. +func (r *Request) WillRetry() bool { + return r.Error != nil && aws.BoolValue(r.Retryable) && r.RetryCount < r.MaxRetries() +} + +// ParamsFilled returns if the request's parameters have been populated +// and the parameters are valid. False is returned if no parameters are +// provided or invalid. +func (r *Request) ParamsFilled() bool { + return r.Params != nil && reflect.ValueOf(r.Params).Elem().IsValid() +} + +// DataFilled returns true if the request's data for response deserialization +// target has been set and is a valid. False is returned if data is not +// set, or is invalid. +func (r *Request) DataFilled() bool { + return r.Data != nil && reflect.ValueOf(r.Data).Elem().IsValid() +} + +// SetBufferBody will set the request's body bytes that will be sent to +// the service API. +func (r *Request) SetBufferBody(buf []byte) { + r.SetReaderBody(bytes.NewReader(buf)) +} + +// SetStringBody sets the body of the request to be backed by a string. +func (r *Request) SetStringBody(s string) { + r.SetReaderBody(strings.NewReader(s)) +} + +// SetReaderBody will set the request's body reader. +func (r *Request) SetReaderBody(reader io.ReadSeeker) { + r.HTTPRequest.Body = ioutil.NopCloser(reader) + r.Body = reader +} + +// Presign returns the request's signed URL. Error will be returned +// if the signing fails. +func (r *Request) Presign(expireTime time.Duration) (string, error) { + r.ExpireTime = expireTime + r.NotHoist = false + r.Sign() + if r.Error != nil { + return "", r.Error + } + return r.HTTPRequest.URL.String(), nil +} + +// PresignRequest behaves just like presign, but hoists all headers and signs them. +// Also returns the signed hash back to the user +func (r *Request) PresignRequest(expireTime time.Duration) (string, http.Header, error) { + r.ExpireTime = expireTime + r.NotHoist = true + r.Sign() + if r.Error != nil { + return "", nil, r.Error + } + return r.HTTPRequest.URL.String(), r.SignedHeaderVals, nil +} + +func debugLogReqError(r *Request, stage string, retrying bool, err error) { + if !r.Config.LogLevel.Matches(aws.LogDebugWithRequestErrors) { + return + } + + retryStr := "not retrying" + if retrying { + retryStr = "will retry" + } + + r.Config.Logger.Log(fmt.Sprintf("DEBUG: %s %s/%s failed, %s, error %v", + stage, r.ClientInfo.ServiceName, r.Operation.Name, retryStr, err)) +} + +// Build will build the request's object so it can be signed and sent +// to the service. Build will also validate all the request's parameters. +// Anny additional build Handlers set on this request will be run +// in the order they were set. +// +// The request will only be built once. Multiple calls to build will have +// no effect. +// +// If any Validate or Build errors occur the build will stop and the error +// which occurred will be returned. +func (r *Request) Build() error { + if !r.built { + r.Error = nil + r.Handlers.Validate.Run(r) + if r.Error != nil { + debugLogReqError(r, "Validate Request", false, r.Error) + return r.Error + } + r.Handlers.Build.Run(r) + if r.Error != nil { + debugLogReqError(r, "Build Request", false, r.Error) + return r.Error + } + r.built = true + } + + return r.Error +} + +// Sign will sign the request retuning error if errors are encountered. +// +// Send will build the request prior to signing. All Sign Handlers will +// be executed in the order they were set. +func (r *Request) Sign() error { + r.Build() + if r.Error != nil { + debugLogReqError(r, "Build Request", false, r.Error) + return r.Error + } + + r.Handlers.Sign.Run(r) + return r.Error +} + +// Send will send the request returning error if errors are encountered. +// +// Send will sign the request prior to sending. All Send Handlers will +// be executed in the order they were set. +func (r *Request) Send() error { + for { + r.Sign() + if r.Error != nil { + return r.Error + } + + if aws.BoolValue(r.Retryable) { + if r.Config.LogLevel.Matches(aws.LogDebugWithRequestRetries) { + r.Config.Logger.Log(fmt.Sprintf("DEBUG: Retrying Request %s/%s, attempt %d", + r.ClientInfo.ServiceName, r.Operation.Name, r.RetryCount)) + } + + // Closing response body. Since we are setting a new request to send off, this + // response will get squashed and leaked. + r.HTTPResponse.Body.Close() + + // Re-seek the body back to the original point in for a retry so that + // send will send the body's contents again in the upcoming request. + r.Body.Seek(r.BodyStart, 0) + r.HTTPRequest.Body = ioutil.NopCloser(r.Body) + } + r.Retryable = nil + + r.Handlers.Send.Run(r) + if r.Error != nil { + err := r.Error + r.Handlers.Retry.Run(r) + r.Handlers.AfterRetry.Run(r) + if r.Error != nil { + debugLogReqError(r, "Send Request", false, r.Error) + return r.Error + } + debugLogReqError(r, "Send Request", true, err) + continue + } + + r.Handlers.UnmarshalMeta.Run(r) + r.Handlers.ValidateResponse.Run(r) + if r.Error != nil { + err := r.Error + r.Handlers.UnmarshalError.Run(r) + r.Handlers.Retry.Run(r) + r.Handlers.AfterRetry.Run(r) + if r.Error != nil { + debugLogReqError(r, "Validate Response", false, r.Error) + return r.Error + } + debugLogReqError(r, "Validate Response", true, err) + continue + } + + r.Handlers.Unmarshal.Run(r) + if r.Error != nil { + err := r.Error + r.Handlers.Retry.Run(r) + r.Handlers.AfterRetry.Run(r) + if r.Error != nil { + debugLogReqError(r, "Unmarshal Response", false, r.Error) + return r.Error + } + debugLogReqError(r, "Unmarshal Response", true, err) + continue + } + + break + } + + return nil +} + +// AddToUserAgent adds the string to the end of the request's current user agent. +func AddToUserAgent(r *Request, s string) { + curUA := r.HTTPRequest.Header.Get("User-Agent") + if len(curUA) > 0 { + s = curUA + " " + s + } + r.HTTPRequest.Header.Set("User-Agent", s) +} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/request_pagination.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/request_pagination.go new file mode 100644 index 0000000000..2939ec473f --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/request_pagination.go @@ -0,0 +1,104 @@ +package request + +import ( + "reflect" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awsutil" +) + +//type Paginater interface { +// HasNextPage() bool +// NextPage() *Request +// EachPage(fn func(data interface{}, isLastPage bool) (shouldContinue bool)) error +//} + +// HasNextPage returns true if this request has more pages of data available. +func (r *Request) HasNextPage() bool { + return len(r.nextPageTokens()) > 0 +} + +// nextPageTokens returns the tokens to use when asking for the next page of +// data. +func (r *Request) nextPageTokens() []interface{} { + if r.Operation.Paginator == nil { + return nil + } + + if r.Operation.TruncationToken != "" { + tr, _ := awsutil.ValuesAtPath(r.Data, r.Operation.TruncationToken) + if len(tr) == 0 { + return nil + } + + switch v := tr[0].(type) { + case *bool: + if !aws.BoolValue(v) { + return nil + } + case bool: + if v == false { + return nil + } + } + } + + tokens := []interface{}{} + tokenAdded := false + for _, outToken := range r.Operation.OutputTokens { + v, _ := awsutil.ValuesAtPath(r.Data, outToken) + if len(v) > 0 { + tokens = append(tokens, v[0]) + tokenAdded = true + } else { + tokens = append(tokens, nil) + } + } + if !tokenAdded { + return nil + } + + return tokens +} + +// NextPage returns a new Request that can be executed to return the next +// page of result data. Call .Send() on this request to execute it. +func (r *Request) NextPage() *Request { + tokens := r.nextPageTokens() + if len(tokens) == 0 { + return nil + } + + data := reflect.New(reflect.TypeOf(r.Data).Elem()).Interface() + nr := New(r.Config, r.ClientInfo, r.Handlers, r.Retryer, r.Operation, awsutil.CopyOf(r.Params), data) + for i, intok := range nr.Operation.InputTokens { + awsutil.SetValueAtPath(nr.Params, intok, tokens[i]) + } + return nr +} + +// EachPage iterates over each page of a paginated request object. The fn +// parameter should be a function with the following sample signature: +// +// func(page *T, lastPage bool) bool { +// return true // return false to stop iterating +// } +// +// Where "T" is the structure type matching the output structure of the given +// operation. For example, a request object generated by +// DynamoDB.ListTablesRequest() would expect to see dynamodb.ListTablesOutput +// as the structure "T". The lastPage value represents whether the page is +// the last page of data or not. The return value of this function should +// return true to keep iterating or false to stop. +func (r *Request) EachPage(fn func(data interface{}, isLastPage bool) (shouldContinue bool)) error { + for page := r; page != nil; page = page.NextPage() { + if err := page.Send(); err != nil { + return err + } + if getNextPage := fn(page.Data, !page.HasNextPage()); !getNextPage { + return page.Error + } + } + + return nil +} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/retryer.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/retryer.go new file mode 100644 index 0000000000..ab6fff5ac8 --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/retryer.go @@ -0,0 +1,82 @@ +package request + +import ( + "time" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awserr" +) + +// Retryer is an interface to control retry logic for a given service. +// The default implementation used by most services is the service.DefaultRetryer +// structure, which contains basic retry logic using exponential backoff. +type Retryer interface { + RetryRules(*Request) time.Duration + ShouldRetry(*Request) bool + MaxRetries() int +} + +// WithRetryer sets a config Retryer value to the given Config returning it +// for chaining. +func WithRetryer(cfg *aws.Config, retryer Retryer) *aws.Config { + cfg.Retryer = retryer + return cfg +} + +// retryableCodes is a collection of service response codes which are retry-able +// without any further action. +var retryableCodes = map[string]struct{}{ + "RequestError": {}, + "RequestTimeout": {}, + "ProvisionedThroughputExceededException": {}, + "Throttling": {}, + "ThrottlingException": {}, + "RequestLimitExceeded": {}, + "RequestThrottled": {}, + "LimitExceededException": {}, // Deleting 10+ DynamoDb tables at once + "TooManyRequestsException": {}, // Lambda functions +} + +// credsExpiredCodes is a collection of error codes which signify the credentials +// need to be refreshed. Expired tokens require refreshing of credentials, and +// resigning before the request can be retried. +var credsExpiredCodes = map[string]struct{}{ + "ExpiredToken": {}, + "ExpiredTokenException": {}, + "RequestExpired": {}, // EC2 Only +} + +func isCodeRetryable(code string) bool { + if _, ok := retryableCodes[code]; ok { + return true + } + + return isCodeExpiredCreds(code) +} + +func isCodeExpiredCreds(code string) bool { + _, ok := credsExpiredCodes[code] + return ok +} + +// IsErrorRetryable returns whether the error is retryable, based on its Code. +// Returns false if the request has no Error set. +func (r *Request) IsErrorRetryable() bool { + if r.Error != nil { + if err, ok := r.Error.(awserr.Error); ok { + return isCodeRetryable(err.Code()) + } + } + return false +} + +// IsErrorExpired returns whether the error code is a credential expiry error. +// Returns false if the request has no Error set. +func (r *Request) IsErrorExpired() bool { + if r.Error != nil { + if err, ok := r.Error.(awserr.Error); ok { + return isCodeExpiredCreds(err.Code()) + } + } + return false +} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/types.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/types.go new file mode 100644 index 0000000000..0f067c57f4 --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/types.go @@ -0,0 +1,88 @@ +package aws + +import ( + "io" + "sync" +) + +// ReadSeekCloser wraps a io.Reader returning a ReaderSeekerCloser +func ReadSeekCloser(r io.Reader) ReaderSeekerCloser { + return ReaderSeekerCloser{r} +} + +// ReaderSeekerCloser represents a reader that can also delegate io.Seeker and +// io.Closer interfaces to the underlying object if they are available. +type ReaderSeekerCloser struct { + r io.Reader +} + +// Read reads from the reader up to size of p. The number of bytes read, and +// error if it occurred will be returned. +// +// If the reader is not an io.Reader zero bytes read, and nil error will be returned. +// +// Performs the same functionality as io.Reader Read +func (r ReaderSeekerCloser) Read(p []byte) (int, error) { + switch t := r.r.(type) { + case io.Reader: + return t.Read(p) + } + return 0, nil +} + +// Seek sets the offset for the next Read to offset, interpreted according to +// whence: 0 means relative to the origin of the file, 1 means relative to the +// current offset, and 2 means relative to the end. Seek returns the new offset +// and an error, if any. +// +// If the ReaderSeekerCloser is not an io.Seeker nothing will be done. +func (r ReaderSeekerCloser) Seek(offset int64, whence int) (int64, error) { + switch t := r.r.(type) { + case io.Seeker: + return t.Seek(offset, whence) + } + return int64(0), nil +} + +// Close closes the ReaderSeekerCloser. +// +// If the ReaderSeekerCloser is not an io.Closer nothing will be done. +func (r ReaderSeekerCloser) Close() error { + switch t := r.r.(type) { + case io.Closer: + return t.Close() + } + return nil +} + +// A WriteAtBuffer provides a in memory buffer supporting the io.WriterAt interface +// Can be used with the s3manager.Downloader to download content to a buffer +// in memory. Safe to use concurrently. +type WriteAtBuffer struct { + buf []byte + m sync.Mutex +} + +// WriteAt writes a slice of bytes to a buffer starting at the position provided +// The number of bytes written will be returned, or error. Can overwrite previous +// written slices if the write ats overlap. +func (b *WriteAtBuffer) WriteAt(p []byte, pos int64) (n int, err error) { + b.m.Lock() + defer b.m.Unlock() + + expLen := pos + int64(len(p)) + if int64(len(b.buf)) < expLen { + newBuf := make([]byte, expLen) + copy(newBuf, b.buf) + b.buf = newBuf + } + copy(b.buf[pos:], p) + return len(p), nil +} + +// Bytes returns a slice of bytes written to the buffer. +func (b *WriteAtBuffer) Bytes() []byte { + b.m.Lock() + defer b.m.Unlock() + return b.buf[:len(b.buf):len(b.buf)] +} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/version.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/version.go new file mode 100644 index 0000000000..669da2d695 --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/version.go @@ -0,0 +1,8 @@ +// Package aws provides core functionality for making requests to AWS services. +package aws + +// SDKName is the name of this AWS SDK +const SDKName = "aws-sdk-go" + +// SDKVersion is the version of this SDK +const SDKVersion = "1.1.7" diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/build.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/build.go new file mode 100644 index 0000000000..5469edb60b --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/build.go @@ -0,0 +1,257 @@ +// Package rest provides RESTful serialization of AWS requests and responses. +package rest + +import ( + "bytes" + "encoding/base64" + "fmt" + "io" + "net/http" + "net/url" + "path" + "reflect" + "strconv" + "strings" + "time" + + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/request" +) + +// RFC822 returns an RFC822 formatted timestamp for AWS protocols +const RFC822 = "Mon, 2 Jan 2006 15:04:05 GMT" + +// Whether the byte value can be sent without escaping in AWS URLs +var noEscape [256]bool + +var errValueNotSet = fmt.Errorf("value not set") + +func init() { + for i := 0; i < len(noEscape); i++ { + // AWS expects every character except these to be escaped + noEscape[i] = (i >= 'A' && i <= 'Z') || + (i >= 'a' && i <= 'z') || + (i >= '0' && i <= '9') || + i == '-' || + i == '.' || + i == '_' || + i == '~' + } +} + +// BuildHandler is a named request handler for building rest protocol requests +var BuildHandler = request.NamedHandler{Name: "awssdk.rest.Build", Fn: Build} + +// Build builds the REST component of a service request. +func Build(r *request.Request) { + if r.ParamsFilled() { + v := reflect.ValueOf(r.Params).Elem() + buildLocationElements(r, v) + buildBody(r, v) + } +} + +func buildLocationElements(r *request.Request, v reflect.Value) { + query := r.HTTPRequest.URL.Query() + + for i := 0; i < v.NumField(); i++ { + m := v.Field(i) + if n := v.Type().Field(i).Name; n[0:1] == strings.ToLower(n[0:1]) { + continue + } + + if m.IsValid() { + field := v.Type().Field(i) + name := field.Tag.Get("locationName") + if name == "" { + name = field.Name + } + if m.Kind() == reflect.Ptr { + m = m.Elem() + } + if !m.IsValid() { + continue + } + + var err error + switch field.Tag.Get("location") { + case "headers": // header maps + err = buildHeaderMap(&r.HTTPRequest.Header, m, field.Tag.Get("locationName")) + case "header": + err = buildHeader(&r.HTTPRequest.Header, m, name) + case "uri": + err = buildURI(r.HTTPRequest.URL, m, name) + case "querystring": + err = buildQueryString(query, m, name) + } + r.Error = err + } + if r.Error != nil { + return + } + } + + r.HTTPRequest.URL.RawQuery = query.Encode() + updatePath(r.HTTPRequest.URL, r.HTTPRequest.URL.Path) +} + +func buildBody(r *request.Request, v reflect.Value) { + if field, ok := v.Type().FieldByName("_"); ok { + if payloadName := field.Tag.Get("payload"); payloadName != "" { + pfield, _ := v.Type().FieldByName(payloadName) + if ptag := pfield.Tag.Get("type"); ptag != "" && ptag != "structure" { + payload := reflect.Indirect(v.FieldByName(payloadName)) + if payload.IsValid() && payload.Interface() != nil { + switch reader := payload.Interface().(type) { + case io.ReadSeeker: + r.SetReaderBody(reader) + case []byte: + r.SetBufferBody(reader) + case string: + r.SetStringBody(reader) + default: + r.Error = awserr.New("SerializationError", + "failed to encode REST request", + fmt.Errorf("unknown payload type %s", payload.Type())) + } + } + } + } + } +} + +func buildHeader(header *http.Header, v reflect.Value, name string) error { + str, err := convertType(v) + if err == errValueNotSet { + return nil + } else if err != nil { + return awserr.New("SerializationError", "failed to encode REST request", err) + } + + header.Add(name, str) + + return nil +} + +func buildHeaderMap(header *http.Header, v reflect.Value, prefix string) error { + for _, key := range v.MapKeys() { + str, err := convertType(v.MapIndex(key)) + if err == errValueNotSet { + continue + } else if err != nil { + return awserr.New("SerializationError", "failed to encode REST request", err) + + } + + header.Add(prefix+key.String(), str) + } + return nil +} + +func buildURI(u *url.URL, v reflect.Value, name string) error { + value, err := convertType(v) + if err == errValueNotSet { + return nil + } else if err != nil { + return awserr.New("SerializationError", "failed to encode REST request", err) + } + + uri := u.Path + uri = strings.Replace(uri, "{"+name+"}", EscapePath(value, true), -1) + uri = strings.Replace(uri, "{"+name+"+}", EscapePath(value, false), -1) + u.Path = uri + + return nil +} + +func buildQueryString(query url.Values, v reflect.Value, name string) error { + switch value := v.Interface().(type) { + case []*string: + for _, item := range value { + query.Add(name, *item) + } + case map[string]*string: + for key, item := range value { + query.Add(key, *item) + } + case map[string][]*string: + for key, items := range value { + for _, item := range items { + query.Add(key, *item) + } + } + default: + str, err := convertType(v) + if err == errValueNotSet { + return nil + } else if err != nil { + return awserr.New("SerializationError", "failed to encode REST request", err) + } + query.Set(name, str) + } + + return nil +} + +func updatePath(url *url.URL, urlPath string) { + scheme, query := url.Scheme, url.RawQuery + + hasSlash := strings.HasSuffix(urlPath, "/") + + // clean up path + urlPath = path.Clean(urlPath) + if hasSlash && !strings.HasSuffix(urlPath, "/") { + urlPath += "/" + } + + // get formatted URL minus scheme so we can build this into Opaque + url.Scheme, url.Path, url.RawQuery = "", "", "" + s := url.String() + url.Scheme = scheme + url.RawQuery = query + + // build opaque URI + url.Opaque = s + urlPath +} + +// EscapePath escapes part of a URL path in Amazon style +func EscapePath(path string, encodeSep bool) string { + var buf bytes.Buffer + for i := 0; i < len(path); i++ { + c := path[i] + if noEscape[c] || (c == '/' && !encodeSep) { + buf.WriteByte(c) + } else { + buf.WriteByte('%') + buf.WriteString(strings.ToUpper(strconv.FormatUint(uint64(c), 16))) + } + } + return buf.String() +} + +func convertType(v reflect.Value) (string, error) { + v = reflect.Indirect(v) + if !v.IsValid() { + return "", errValueNotSet + } + + var str string + switch value := v.Interface().(type) { + case string: + str = value + case []byte: + str = base64.StdEncoding.EncodeToString(value) + case bool: + str = strconv.FormatBool(value) + case int64: + str = strconv.FormatInt(value, 10) + case float64: + str = strconv.FormatFloat(value, 'f', -1, 64) + case time.Time: + str = value.UTC().Format(RFC822) + default: + err := fmt.Errorf("Unsupported value for param %v (%s)", v.Interface(), v.Type()) + return "", err + } + return str, nil +} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/payload.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/payload.go new file mode 100644 index 0000000000..4366de2e1e --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/payload.go @@ -0,0 +1,45 @@ +package rest + +import "reflect" + +// PayloadMember returns the payload field member of i if there is one, or nil. +func PayloadMember(i interface{}) interface{} { + if i == nil { + return nil + } + + v := reflect.ValueOf(i).Elem() + if !v.IsValid() { + return nil + } + if field, ok := v.Type().FieldByName("_"); ok { + if payloadName := field.Tag.Get("payload"); payloadName != "" { + field, _ := v.Type().FieldByName(payloadName) + if field.Tag.Get("type") != "structure" { + return nil + } + + payload := v.FieldByName(payloadName) + if payload.IsValid() || (payload.Kind() == reflect.Ptr && !payload.IsNil()) { + return payload.Interface() + } + } + } + return nil +} + +// PayloadType returns the type of a payload field member of i if there is one, or "". +func PayloadType(i interface{}) string { + v := reflect.Indirect(reflect.ValueOf(i)) + if !v.IsValid() { + return "" + } + if field, ok := v.Type().FieldByName("_"); ok { + if payloadName := field.Tag.Get("payload"); payloadName != "" { + if member, ok := v.Type().FieldByName(payloadName); ok { + return member.Tag.Get("type") + } + } + } + return "" +} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go new file mode 100644 index 0000000000..ba46f5bc9f --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go @@ -0,0 +1,193 @@ +package rest + +import ( + "encoding/base64" + "fmt" + "io/ioutil" + "net/http" + "reflect" + "strconv" + "strings" + "time" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/request" +) + +// UnmarshalHandler is a named request handler for unmarshaling rest protocol requests +var UnmarshalHandler = request.NamedHandler{Name: "awssdk.rest.Unmarshal", Fn: Unmarshal} + +// UnmarshalMetaHandler is a named request handler for unmarshaling rest protocol request metadata +var UnmarshalMetaHandler = request.NamedHandler{Name: "awssdk.rest.UnmarshalMeta", Fn: UnmarshalMeta} + +// Unmarshal unmarshals the REST component of a response in a REST service. +func Unmarshal(r *request.Request) { + if r.DataFilled() { + v := reflect.Indirect(reflect.ValueOf(r.Data)) + unmarshalBody(r, v) + } +} + +// UnmarshalMeta unmarshals the REST metadata of a response in a REST service +func UnmarshalMeta(r *request.Request) { + r.RequestID = r.HTTPResponse.Header.Get("X-Amzn-Requestid") + if r.RequestID == "" { + // Alternative version of request id in the header + r.RequestID = r.HTTPResponse.Header.Get("X-Amz-Request-Id") + } + if r.DataFilled() { + v := reflect.Indirect(reflect.ValueOf(r.Data)) + unmarshalLocationElements(r, v) + } +} + +func unmarshalBody(r *request.Request, v reflect.Value) { + if field, ok := v.Type().FieldByName("_"); ok { + if payloadName := field.Tag.Get("payload"); payloadName != "" { + pfield, _ := v.Type().FieldByName(payloadName) + if ptag := pfield.Tag.Get("type"); ptag != "" && ptag != "structure" { + payload := v.FieldByName(payloadName) + if payload.IsValid() { + switch payload.Interface().(type) { + case []byte: + b, err := ioutil.ReadAll(r.HTTPResponse.Body) + if err != nil { + r.Error = awserr.New("SerializationError", "failed to decode REST response", err) + } else { + payload.Set(reflect.ValueOf(b)) + } + case *string: + b, err := ioutil.ReadAll(r.HTTPResponse.Body) + if err != nil { + r.Error = awserr.New("SerializationError", "failed to decode REST response", err) + } else { + str := string(b) + payload.Set(reflect.ValueOf(&str)) + } + default: + switch payload.Type().String() { + case "io.ReadSeeker": + payload.Set(reflect.ValueOf(aws.ReadSeekCloser(r.HTTPResponse.Body))) + case "aws.ReadSeekCloser", "io.ReadCloser": + payload.Set(reflect.ValueOf(r.HTTPResponse.Body)) + default: + r.Error = awserr.New("SerializationError", + "failed to decode REST response", + fmt.Errorf("unknown payload type %s", payload.Type())) + } + } + } + } + } + } +} + +func unmarshalLocationElements(r *request.Request, v reflect.Value) { + for i := 0; i < v.NumField(); i++ { + m, field := v.Field(i), v.Type().Field(i) + if n := field.Name; n[0:1] == strings.ToLower(n[0:1]) { + continue + } + + if m.IsValid() { + name := field.Tag.Get("locationName") + if name == "" { + name = field.Name + } + + switch field.Tag.Get("location") { + case "statusCode": + unmarshalStatusCode(m, r.HTTPResponse.StatusCode) + case "header": + err := unmarshalHeader(m, r.HTTPResponse.Header.Get(name)) + if err != nil { + r.Error = awserr.New("SerializationError", "failed to decode REST response", err) + break + } + case "headers": + prefix := field.Tag.Get("locationName") + err := unmarshalHeaderMap(m, r.HTTPResponse.Header, prefix) + if err != nil { + r.Error = awserr.New("SerializationError", "failed to decode REST response", err) + break + } + } + } + if r.Error != nil { + return + } + } +} + +func unmarshalStatusCode(v reflect.Value, statusCode int) { + if !v.IsValid() { + return + } + + switch v.Interface().(type) { + case *int64: + s := int64(statusCode) + v.Set(reflect.ValueOf(&s)) + } +} + +func unmarshalHeaderMap(r reflect.Value, headers http.Header, prefix string) error { + switch r.Interface().(type) { + case map[string]*string: // we only support string map value types + out := map[string]*string{} + for k, v := range headers { + k = http.CanonicalHeaderKey(k) + if strings.HasPrefix(strings.ToLower(k), strings.ToLower(prefix)) { + out[k[len(prefix):]] = &v[0] + } + } + r.Set(reflect.ValueOf(out)) + } + return nil +} + +func unmarshalHeader(v reflect.Value, header string) error { + if !v.IsValid() || (header == "" && v.Elem().Kind() != reflect.String) { + return nil + } + + switch v.Interface().(type) { + case *string: + v.Set(reflect.ValueOf(&header)) + case []byte: + b, err := base64.StdEncoding.DecodeString(header) + if err != nil { + return err + } + v.Set(reflect.ValueOf(&b)) + case *bool: + b, err := strconv.ParseBool(header) + if err != nil { + return err + } + v.Set(reflect.ValueOf(&b)) + case *int64: + i, err := strconv.ParseInt(header, 10, 64) + if err != nil { + return err + } + v.Set(reflect.ValueOf(&i)) + case *float64: + f, err := strconv.ParseFloat(header, 64) + if err != nil { + return err + } + v.Set(reflect.ValueOf(&f)) + case *time.Time: + t, err := time.Parse(RFC822, header) + if err != nil { + return err + } + v.Set(reflect.ValueOf(&t)) + default: + err := fmt.Errorf("Unsupported value for param %v (%s)", v.Interface(), v.Type()) + return err + } + return nil +} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/signer/v4/header_rules.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/signer/v4/header_rules.go new file mode 100644 index 0000000000..244c86da05 --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/signer/v4/header_rules.go @@ -0,0 +1,82 @@ +package v4 + +import ( + "net/http" + "strings" +) + +// validator houses a set of rule needed for validation of a +// string value +type rules []rule + +// rule interface allows for more flexible rules and just simply +// checks whether or not a value adheres to that rule +type rule interface { + IsValid(value string) bool +} + +// IsValid will iterate through all rules and see if any rules +// apply to the value and supports nested rules +func (r rules) IsValid(value string) bool { + for _, rule := range r { + if rule.IsValid(value) { + return true + } + } + return false +} + +// mapRule generic rule for maps +type mapRule map[string]struct{} + +// IsValid for the map rule satisfies whether it exists in the map +func (m mapRule) IsValid(value string) bool { + _, ok := m[value] + return ok +} + +// whitelist is a generic rule for whitelisting +type whitelist struct { + rule +} + +// IsValid for whitelist checks if the value is within the whitelist +func (w whitelist) IsValid(value string) bool { + return w.rule.IsValid(value) +} + +// blacklist is a generic rule for blacklisting +type blacklist struct { + rule +} + +// IsValid for whitelist checks if the value is within the whitelist +func (b blacklist) IsValid(value string) bool { + return !b.rule.IsValid(value) +} + +type patterns []string + +// IsValid for patterns checks each pattern and returns if a match has +// been found +func (p patterns) IsValid(value string) bool { + for _, pattern := range p { + if strings.HasPrefix(http.CanonicalHeaderKey(value), pattern) { + return true + } + } + return false +} + +// inclusiveRules rules allow for rules to depend on one another +type inclusiveRules []rule + +// IsValid will return true if all rules are true +func (r inclusiveRules) IsValid(value string) bool { + for _, rule := range r { + if !rule.IsValid(value) { + return false + } + } + return true +} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/signer/v4/v4.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/signer/v4/v4.go new file mode 100644 index 0000000000..14b0c66161 --- /dev/null +++ b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/signer/v4/v4.go @@ -0,0 +1,438 @@ +// Package v4 implements signing for AWS V4 signer +package v4 + +import ( + "crypto/hmac" + "crypto/sha256" + "encoding/hex" + "fmt" + "io" + "net/http" + "net/url" + "sort" + "strconv" + "strings" + "time" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/credentials" + "github.com/aws/aws-sdk-go/aws/request" + "github.com/aws/aws-sdk-go/private/protocol/rest" +) + +const ( + authHeaderPrefix = "AWS4-HMAC-SHA256" + timeFormat = "20060102T150405Z" + shortTimeFormat = "20060102" +) + +var ignoredHeaders = rules{ + blacklist{ + mapRule{ + "Content-Length": struct{}{}, + "User-Agent": struct{}{}, + }, + }, +} + +// requiredSignedHeaders is a whitelist for build canonical headers. +var requiredSignedHeaders = rules{ + whitelist{ + mapRule{ + "Cache-Control": struct{}{}, + "Content-Disposition": struct{}{}, + "Content-Encoding": struct{}{}, + "Content-Language": struct{}{}, + "Content-Md5": struct{}{}, + "Content-Type": struct{}{}, + "Expires": struct{}{}, + "If-Match": struct{}{}, + "If-Modified-Since": struct{}{}, + "If-None-Match": struct{}{}, + "If-Unmodified-Since": struct{}{}, + "Range": struct{}{}, + "X-Amz-Acl": struct{}{}, + "X-Amz-Copy-Source": struct{}{}, + "X-Amz-Copy-Source-If-Match": struct{}{}, + "X-Amz-Copy-Source-If-Modified-Since": struct{}{}, + "X-Amz-Copy-Source-If-None-Match": struct{}{}, + "X-Amz-Copy-Source-If-Unmodified-Since": struct{}{}, + "X-Amz-Copy-Source-Range": struct{}{}, + "X-Amz-Copy-Source-Server-Side-Encryption-Customer-Algorithm": struct{}{}, + "X-Amz-Copy-Source-Server-Side-Encryption-Customer-Key": struct{}{}, + "X-Amz-Copy-Source-Server-Side-Encryption-Customer-Key-Md5": struct{}{}, + "X-Amz-Grant-Full-control": struct{}{}, + "X-Amz-Grant-Read": struct{}{}, + "X-Amz-Grant-Read-Acp": struct{}{}, + "X-Amz-Grant-Write": struct{}{}, + "X-Amz-Grant-Write-Acp": struct{}{}, + "X-Amz-Metadata-Directive": struct{}{}, + "X-Amz-Mfa": struct{}{}, + "X-Amz-Request-Payer": struct{}{}, + "X-Amz-Server-Side-Encryption": struct{}{}, + "X-Amz-Server-Side-Encryption-Aws-Kms-Key-Id": struct{}{}, + "X-Amz-Server-Side-Encryption-Customer-Algorithm": struct{}{}, + "X-Amz-Server-Side-Encryption-Customer-Key": struct{}{}, + "X-Amz-Server-Side-Encryption-Customer-Key-Md5": struct{}{}, + "X-Amz-Storage-Class": struct{}{}, + "X-Amz-Website-Redirect-Location": struct{}{}, + }, + }, + patterns{"X-Amz-Meta-"}, +} + +// allowedHoisting is a whitelist for build query headers. The boolean value +// represents whether or not it is a pattern. +var allowedQueryHoisting = inclusiveRules{ + blacklist{requiredSignedHeaders}, + patterns{"X-Amz-"}, +} + +type signer struct { + Request *http.Request + Time time.Time + ExpireTime time.Duration + ServiceName string + Region string + CredValues credentials.Value + Credentials *credentials.Credentials + Query url.Values + Body io.ReadSeeker + Debug aws.LogLevelType + Logger aws.Logger + + isPresign bool + formattedTime string + formattedShortTime string + + signedHeaders string + canonicalHeaders string + canonicalString string + credentialString string + stringToSign string + signature string + authorization string + notHoist bool + signedHeaderVals http.Header +} + +// Sign requests with signature version 4. +// +// Will sign the requests with the service config's Credentials object +// Signing is skipped if the credentials is the credentials.AnonymousCredentials +// object. +func Sign(req *request.Request) { + // If the request does not need to be signed ignore the signing of the + // request if the AnonymousCredentials object is used. + if req.Config.Credentials == credentials.AnonymousCredentials { + return + } + + region := req.ClientInfo.SigningRegion + if region == "" { + region = aws.StringValue(req.Config.Region) + } + + name := req.ClientInfo.SigningName + if name == "" { + name = req.ClientInfo.ServiceName + } + + s := signer{ + Request: req.HTTPRequest, + Time: req.Time, + ExpireTime: req.ExpireTime, + Query: req.HTTPRequest.URL.Query(), + Body: req.Body, + ServiceName: name, + Region: region, + Credentials: req.Config.Credentials, + Debug: req.Config.LogLevel.Value(), + Logger: req.Config.Logger, + notHoist: req.NotHoist, + } + + req.Error = s.sign() + req.SignedHeaderVals = s.signedHeaderVals +} + +func (v4 *signer) sign() error { + if v4.ExpireTime != 0 { + v4.isPresign = true + } + + if v4.isRequestSigned() { + if !v4.Credentials.IsExpired() { + // If the request is already signed, and the credentials have not + // expired yet ignore the signing request. + return nil + } + + // The credentials have expired for this request. The current signing + // is invalid, and needs to be request because the request will fail. + if v4.isPresign { + v4.removePresign() + // Update the request's query string to ensure the values stays in + // sync in the case retrieving the new credentials fails. + v4.Request.URL.RawQuery = v4.Query.Encode() + } + } + + var err error + v4.CredValues, err = v4.Credentials.Get() + if err != nil { + return err + } + + if v4.isPresign { + v4.Query.Set("X-Amz-Algorithm", authHeaderPrefix) + if v4.CredValues.SessionToken != "" { + v4.Query.Set("X-Amz-Security-Token", v4.CredValues.SessionToken) + } else { + v4.Query.Del("X-Amz-Security-Token") + } + } else if v4.CredValues.SessionToken != "" { + v4.Request.Header.Set("X-Amz-Security-Token", v4.CredValues.SessionToken) + } + + v4.build() + + if v4.Debug.Matches(aws.LogDebugWithSigning) { + v4.logSigningInfo() + } + + return nil +} + +const logSignInfoMsg = `DEBUG: Request Signiture: +---[ CANONICAL STRING ]----------------------------- +%s +---[ STRING TO SIGN ]-------------------------------- +%s%s +-----------------------------------------------------` +const logSignedURLMsg = ` +---[ SIGNED URL ]------------------------------------ +%s` + +func (v4 *signer) logSigningInfo() { + signedURLMsg := "" + if v4.isPresign { + signedURLMsg = fmt.Sprintf(logSignedURLMsg, v4.Request.URL.String()) + } + msg := fmt.Sprintf(logSignInfoMsg, v4.canonicalString, v4.stringToSign, signedURLMsg) + v4.Logger.Log(msg) +} + +func (v4 *signer) build() { + + v4.buildTime() // no depends + v4.buildCredentialString() // no depends + + unsignedHeaders := v4.Request.Header + if v4.isPresign { + if !v4.notHoist { + urlValues := url.Values{} + urlValues, unsignedHeaders = buildQuery(allowedQueryHoisting, unsignedHeaders) // no depends + for k := range urlValues { + v4.Query[k] = urlValues[k] + } + } + } + + v4.buildCanonicalHeaders(ignoredHeaders, unsignedHeaders) + v4.buildCanonicalString() // depends on canon headers / signed headers + v4.buildStringToSign() // depends on canon string + v4.buildSignature() // depends on string to sign + + if v4.isPresign { + v4.Request.URL.RawQuery += "&X-Amz-Signature=" + v4.signature + } else { + parts := []string{ + authHeaderPrefix + " Credential=" + v4.CredValues.AccessKeyID + "/" + v4.credentialString, + "SignedHeaders=" + v4.signedHeaders, + "Signature=" + v4.signature, + } + v4.Request.Header.Set("Authorization", strings.Join(parts, ", ")) + } +} + +func (v4 *signer) buildTime() { + v4.formattedTime = v4.Time.UTC().Format(timeFormat) + v4.formattedShortTime = v4.Time.UTC().Format(shortTimeFormat) + + if v4.isPresign { + duration := int64(v4.ExpireTime / time.Second) + v4.Query.Set("X-Amz-Date", v4.formattedTime) + v4.Query.Set("X-Amz-Expires", strconv.FormatInt(duration, 10)) + } else { + v4.Request.Header.Set("X-Amz-Date", v4.formattedTime) + } +} + +func (v4 *signer) buildCredentialString() { + v4.credentialString = strings.Join([]string{ + v4.formattedShortTime, + v4.Region, + v4.ServiceName, + "aws4_request", + }, "/") + + if v4.isPresign { + v4.Query.Set("X-Amz-Credential", v4.CredValues.AccessKeyID+"/"+v4.credentialString) + } +} + +func buildQuery(r rule, header http.Header) (url.Values, http.Header) { + query := url.Values{} + unsignedHeaders := http.Header{} + for k, h := range header { + if r.IsValid(k) { + query[k] = h + } else { + unsignedHeaders[k] = h + } + } + + return query, unsignedHeaders +} +func (v4 *signer) buildCanonicalHeaders(r rule, header http.Header) { + var headers []string + headers = append(headers, "host") + for k, v := range header { + canonicalKey := http.CanonicalHeaderKey(k) + if !r.IsValid(canonicalKey) { + continue // ignored header + } + + lowerCaseKey := strings.ToLower(k) + headers = append(headers, lowerCaseKey) + + if v4.signedHeaderVals == nil { + v4.signedHeaderVals = make(http.Header) + } + v4.signedHeaderVals[lowerCaseKey] = v + } + sort.Strings(headers) + + v4.signedHeaders = strings.Join(headers, ";") + + if v4.isPresign { + v4.Query.Set("X-Amz-SignedHeaders", v4.signedHeaders) + } + + headerValues := make([]string, len(headers)) + for i, k := range headers { + if k == "host" { + headerValues[i] = "host:" + v4.Request.URL.Host + } else { + headerValues[i] = k + ":" + + strings.Join(v4.Request.Header[http.CanonicalHeaderKey(k)], ",") + } + } + + v4.canonicalHeaders = strings.Join(headerValues, "\n") +} + +func (v4 *signer) buildCanonicalString() { + v4.Request.URL.RawQuery = strings.Replace(v4.Query.Encode(), "+", "%20", -1) + uri := v4.Request.URL.Opaque + if uri != "" { + uri = "/" + strings.Join(strings.Split(uri, "/")[3:], "/") + } else { + uri = v4.Request.URL.Path + } + if uri == "" { + uri = "/" + } + + if v4.ServiceName != "s3" { + uri = rest.EscapePath(uri, false) + } + + v4.canonicalString = strings.Join([]string{ + v4.Request.Method, + uri, + v4.Request.URL.RawQuery, + v4.canonicalHeaders + "\n", + v4.signedHeaders, + v4.bodyDigest(), + }, "\n") +} + +func (v4 *signer) buildStringToSign() { + v4.stringToSign = strings.Join([]string{ + authHeaderPrefix, + v4.formattedTime, + v4.credentialString, + hex.EncodeToString(makeSha256([]byte(v4.canonicalString))), + }, "\n") +} + +func (v4 *signer) buildSignature() { + secret := v4.CredValues.SecretAccessKey + date := makeHmac([]byte("AWS4"+secret), []byte(v4.formattedShortTime)) + region := makeHmac(date, []byte(v4.Region)) + service := makeHmac(region, []byte(v4.ServiceName)) + credentials := makeHmac(service, []byte("aws4_request")) + signature := makeHmac(credentials, []byte(v4.stringToSign)) + v4.signature = hex.EncodeToString(signature) +} + +func (v4 *signer) bodyDigest() string { + hash := v4.Request.Header.Get("X-Amz-Content-Sha256") + if hash == "" { + if v4.isPresign && v4.ServiceName == "s3" { + hash = "UNSIGNED-PAYLOAD" + } else if v4.Body == nil { + hash = hex.EncodeToString(makeSha256([]byte{})) + } else { + hash = hex.EncodeToString(makeSha256Reader(v4.Body)) + } + v4.Request.Header.Add("X-Amz-Content-Sha256", hash) + } + return hash +} + +// isRequestSigned returns if the request is currently signed or presigned +func (v4 *signer) isRequestSigned() bool { + if v4.isPresign && v4.Query.Get("X-Amz-Signature") != "" { + return true + } + if v4.Request.Header.Get("Authorization") != "" { + return true + } + + return false +} + +// unsign removes signing flags for both signed and presigned requests. +func (v4 *signer) removePresign() { + v4.Query.Del("X-Amz-Algorithm") + v4.Query.Del("X-Amz-Signature") + v4.Query.Del("X-Amz-Security-Token") + v4.Query.Del("X-Amz-Date") + v4.Query.Del("X-Amz-Expires") + v4.Query.Del("X-Amz-Credential") + v4.Query.Del("X-Amz-SignedHeaders") +} + +func makeHmac(key []byte, data []byte) []byte { + hash := hmac.New(sha256.New, key) + hash.Write(data) + return hash.Sum(nil) +} + +func makeSha256(data []byte) []byte { + hash := sha256.New() + hash.Write(data) + return hash.Sum(nil) +} + +func makeSha256Reader(reader io.ReadSeeker) []byte { + hash := sha256.New() + start, _ := reader.Seek(0, 1) + defer reader.Seek(start, 0) + + io.Copy(hash, reader) + return hash.Sum(nil) +} diff --git a/Godeps/_workspace/src/github.com/go-ini/ini/.gitignore b/Godeps/_workspace/src/github.com/go-ini/ini/.gitignore new file mode 100644 index 0000000000..7adca9439c --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ini/ini/.gitignore @@ -0,0 +1,4 @@ +testdata/conf_out.ini +ini.sublime-project +ini.sublime-workspace +testdata/conf_reflect.ini diff --git a/Godeps/_workspace/src/github.com/go-ini/ini/LICENSE b/Godeps/_workspace/src/github.com/go-ini/ini/LICENSE new file mode 100644 index 0000000000..37ec93a14f --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ini/ini/LICENSE @@ -0,0 +1,191 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, "control" means (i) the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising +permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +"Object" form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +"submitted" means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor 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, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of +this License; and +You must cause any modified files to carry prominent notices stating that You +changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets "[]" replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same "printed page" as the copyright notice for easier identification within +third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/Godeps/_workspace/src/github.com/go-ini/ini/Makefile b/Godeps/_workspace/src/github.com/go-ini/ini/Makefile new file mode 100644 index 0000000000..ac034e5258 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ini/ini/Makefile @@ -0,0 +1,12 @@ +.PHONY: build test bench vet + +build: vet bench + +test: + go test -v -cover -race + +bench: + go test -v -cover -race -test.bench=. -test.benchmem + +vet: + go vet diff --git a/Godeps/_workspace/src/github.com/go-ini/ini/README.md b/Godeps/_workspace/src/github.com/go-ini/ini/README.md new file mode 100644 index 0000000000..a87cca2328 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ini/ini/README.md @@ -0,0 +1,632 @@ +ini [![Build Status](https://drone.io/github.com/go-ini/ini/status.png)](https://drone.io/github.com/go-ini/ini/latest) [![](http://gocover.io/_badge/github.com/go-ini/ini)](http://gocover.io/github.com/go-ini/ini) +=== + +![](https://avatars0.githubusercontent.com/u/10216035?v=3&s=200) + +Package ini provides INI file read and write functionality in Go. + +[简体中文](README_ZH.md) + +## Feature + +- Load multiple data sources(`[]byte` or file) with overwrites. +- Read with recursion values. +- Read with parent-child sections. +- Read with auto-increment key names. +- Read with multiple-line values. +- Read with tons of helper methods. +- Read and convert values to Go types. +- Read and **WRITE** comments of sections and keys. +- Manipulate sections, keys and comments with ease. +- Keep sections and keys in order as you parse and save. + +## Installation + +To use a tagged revision: + + go get gopkg.in/ini.v1 + +To use with latest changes: + + go get github.com/go-ini/ini + +Please add `-u` flag to update in the future. + +### Testing + +If you want to test on your machine, please apply `-t` flag: + + go get -t gopkg.in/ini.v1 + +Please add `-u` flag to update in the future. + +## Getting Started + +### Loading from data sources + +A **Data Source** is either raw data in type `[]byte` or a file name with type `string` and you can load **as many as** data sources you want. Passing other types will simply return an error. + +```go +cfg, err := ini.Load([]byte("raw data"), "filename") +``` + +Or start with an empty object: + +```go +cfg := ini.Empty() +``` + +When you cannot decide how many data sources to load at the beginning, you still able to **Append()** them later. + +```go +err := cfg.Append("other file", []byte("other raw data")) +``` + +If you have a list of files with possibilities that some of them may not available at the time, and you don't know exactly which ones, you can use `LooseLoad` to ignore nonexistent files without returning error. + +```go +cfg, err := ini.LooseLoad("filename", "filename_404") +``` + +The cool thing is, whenever the file is available to load while you're calling `Reload` method, it will be counted as usual. + +### Working with sections + +To get a section, you would need to: + +```go +section, err := cfg.GetSection("section name") +``` + +For a shortcut for default section, just give an empty string as name: + +```go +section, err := cfg.GetSection("") +``` + +When you're pretty sure the section exists, following code could make your life easier: + +```go +section := cfg.Section("") +``` + +What happens when the section somehow does not exist? Don't panic, it automatically creates and returns a new section to you. + +To create a new section: + +```go +err := cfg.NewSection("new section") +``` + +To get a list of sections or section names: + +```go +sections := cfg.Sections() +names := cfg.SectionStrings() +``` + +### Working with keys + +To get a key under a section: + +```go +key, err := cfg.Section("").GetKey("key name") +``` + +Same rule applies to key operations: + +```go +key := cfg.Section("").Key("key name") +``` + +To check if a key exists: + +```go +yes := cfg.Section("").HasKey("key name") +``` + +To create a new key: + +```go +err := cfg.Section("").NewKey("name", "value") +``` + +To get a list of keys or key names: + +```go +keys := cfg.Section("").Keys() +names := cfg.Section("").KeyStrings() +``` + +To get a clone hash of keys and corresponding values: + +```go +hash := cfg.GetSection("").KeysHash() +``` + +### Working with values + +To get a string value: + +```go +val := cfg.Section("").Key("key name").String() +``` + +To validate key value on the fly: + +```go +val := cfg.Section("").Key("key name").Validate(func(in string) string { + if len(in) == 0 { + return "default" + } + return in +}) +``` + +If you do not want any auto-transformation (such as recursive read) for the values, you can get raw value directly (this way you get much better performance): + +```go +val := cfg.Section("").Key("key name").Value() +``` + +To check if raw value exists: + +```go +yes := cfg.Section("").HasValue("test value") +``` + +To get value with types: + +```go +// For boolean values: +// true when value is: 1, t, T, TRUE, true, True, YES, yes, Yes, y, ON, on, On +// false when value is: 0, f, F, FALSE, false, False, NO, no, No, n, OFF, off, Off +v, err = cfg.Section("").Key("BOOL").Bool() +v, err = cfg.Section("").Key("FLOAT64").Float64() +v, err = cfg.Section("").Key("INT").Int() +v, err = cfg.Section("").Key("INT64").Int64() +v, err = cfg.Section("").Key("UINT").Uint() +v, err = cfg.Section("").Key("UINT64").Uint64() +v, err = cfg.Section("").Key("TIME").TimeFormat(time.RFC3339) +v, err = cfg.Section("").Key("TIME").Time() // RFC3339 + +v = cfg.Section("").Key("BOOL").MustBool() +v = cfg.Section("").Key("FLOAT64").MustFloat64() +v = cfg.Section("").Key("INT").MustInt() +v = cfg.Section("").Key("INT64").MustInt64() +v = cfg.Section("").Key("UINT").MustUint() +v = cfg.Section("").Key("UINT64").MustUint64() +v = cfg.Section("").Key("TIME").MustTimeFormat(time.RFC3339) +v = cfg.Section("").Key("TIME").MustTime() // RFC3339 + +// Methods start with Must also accept one argument for default value +// when key not found or fail to parse value to given type. +// Except method MustString, which you have to pass a default value. + +v = cfg.Section("").Key("String").MustString("default") +v = cfg.Section("").Key("BOOL").MustBool(true) +v = cfg.Section("").Key("FLOAT64").MustFloat64(1.25) +v = cfg.Section("").Key("INT").MustInt(10) +v = cfg.Section("").Key("INT64").MustInt64(99) +v = cfg.Section("").Key("UINT").MustUint(3) +v = cfg.Section("").Key("UINT64").MustUint64(6) +v = cfg.Section("").Key("TIME").MustTimeFormat(time.RFC3339, time.Now()) +v = cfg.Section("").Key("TIME").MustTime(time.Now()) // RFC3339 +``` + +What if my value is three-line long? + +```ini +[advance] +ADDRESS = """404 road, +NotFound, State, 5000 +Earth""" +``` + +Not a problem! + +```go +cfg.Section("advance").Key("ADDRESS").String() + +/* --- start --- +404 road, +NotFound, State, 5000 +Earth +------ end --- */ +``` + +That's cool, how about continuation lines? + +```ini +[advance] +two_lines = how about \ + continuation lines? +lots_of_lines = 1 \ + 2 \ + 3 \ + 4 +``` + +Piece of cake! + +```go +cfg.Section("advance").Key("two_lines").String() // how about continuation lines? +cfg.Section("advance").Key("lots_of_lines").String() // 1 2 3 4 +``` + +Note that single quotes around values will be stripped: + +```ini +foo = "some value" // foo: some value +bar = 'some value' // bar: some value +``` + +That's all? Hmm, no. + +#### Helper methods of working with values + +To get value with given candidates: + +```go +v = cfg.Section("").Key("STRING").In("default", []string{"str", "arr", "types"}) +v = cfg.Section("").Key("FLOAT64").InFloat64(1.1, []float64{1.25, 2.5, 3.75}) +v = cfg.Section("").Key("INT").InInt(5, []int{10, 20, 30}) +v = cfg.Section("").Key("INT64").InInt64(10, []int64{10, 20, 30}) +v = cfg.Section("").Key("UINT").InUint(4, []int{3, 6, 9}) +v = cfg.Section("").Key("UINT64").InUint64(8, []int64{3, 6, 9}) +v = cfg.Section("").Key("TIME").InTimeFormat(time.RFC3339, time.Now(), []time.Time{time1, time2, time3}) +v = cfg.Section("").Key("TIME").InTime(time.Now(), []time.Time{time1, time2, time3}) // RFC3339 +``` + +Default value will be presented if value of key is not in candidates you given, and default value does not need be one of candidates. + +To validate value in a given range: + +```go +vals = cfg.Section("").Key("FLOAT64").RangeFloat64(0.0, 1.1, 2.2) +vals = cfg.Section("").Key("INT").RangeInt(0, 10, 20) +vals = cfg.Section("").Key("INT64").RangeInt64(0, 10, 20) +vals = cfg.Section("").Key("UINT").RangeUint(0, 3, 9) +vals = cfg.Section("").Key("UINT64").RangeUint64(0, 3, 9) +vals = cfg.Section("").Key("TIME").RangeTimeFormat(time.RFC3339, time.Now(), minTime, maxTime) +vals = cfg.Section("").Key("TIME").RangeTime(time.Now(), minTime, maxTime) // RFC3339 +``` + +##### Auto-split values into a slice + +To use zero value of type for invalid inputs: + +```go +// Input: 1.1, 2.2, 3.3, 4.4 -> [1.1 2.2 3.3 4.4] +// Input: how, 2.2, are, you -> [0.0 2.2 0.0 0.0] +vals = cfg.Section("").Key("STRINGS").Strings(",") +vals = cfg.Section("").Key("FLOAT64S").Float64s(",") +vals = cfg.Section("").Key("INTS").Ints(",") +vals = cfg.Section("").Key("INT64S").Int64s(",") +vals = cfg.Section("").Key("UINTS").Uints(",") +vals = cfg.Section("").Key("UINT64S").Uint64s(",") +vals = cfg.Section("").Key("TIMES").Times(",") +``` + +To exclude invalid values out of result slice: + +```go +// Input: 1.1, 2.2, 3.3, 4.4 -> [1.1 2.2 3.3 4.4] +// Input: how, 2.2, are, you -> [2.2] +vals = cfg.Section("").Key("FLOAT64S").ValidFloat64s(",") +vals = cfg.Section("").Key("INTS").ValidInts(",") +vals = cfg.Section("").Key("INT64S").ValidInt64s(",") +vals = cfg.Section("").Key("UINTS").ValidUints(",") +vals = cfg.Section("").Key("UINT64S").ValidUint64s(",") +vals = cfg.Section("").Key("TIMES").ValidTimes(",") +``` + +Or to return nothing but error when have invalid inputs: + +```go +// Input: 1.1, 2.2, 3.3, 4.4 -> [1.1 2.2 3.3 4.4] +// Input: how, 2.2, are, you -> error +vals = cfg.Section("").Key("FLOAT64S").StrictFloat64s(",") +vals = cfg.Section("").Key("INTS").StrictInts(",") +vals = cfg.Section("").Key("INT64S").StrictInt64s(",") +vals = cfg.Section("").Key("UINTS").StrictUints(",") +vals = cfg.Section("").Key("UINT64S").StrictUint64s(",") +vals = cfg.Section("").Key("TIMES").StrictTimes(",") +``` + +### Save your configuration + +Finally, it's time to save your configuration to somewhere. + +A typical way to save configuration is writing it to a file: + +```go +// ... +err = cfg.SaveTo("my.ini") +err = cfg.SaveToIndent("my.ini", "\t") +``` + +Another way to save is writing to a `io.Writer` interface: + +```go +// ... +cfg.WriteTo(writer) +cfg.WriteToIndent(writer, "\t") +``` + +## Advanced Usage + +### Recursive Values + +For all value of keys, there is a special syntax `%()s`, where `` is the key name in same section or default section, and `%()s` will be replaced by corresponding value(empty string if key not found). You can use this syntax at most 99 level of recursions. + +```ini +NAME = ini + +[author] +NAME = Unknwon +GITHUB = https://github.com/%(NAME)s + +[package] +FULL_NAME = github.com/go-ini/%(NAME)s +``` + +```go +cfg.Section("author").Key("GITHUB").String() // https://github.com/Unknwon +cfg.Section("package").Key("FULL_NAME").String() // github.com/go-ini/ini +``` + +### Parent-child Sections + +You can use `.` in section name to indicate parent-child relationship between two or more sections. If the key not found in the child section, library will try again on its parent section until there is no parent section. + +```ini +NAME = ini +VERSION = v1 +IMPORT_PATH = gopkg.in/%(NAME)s.%(VERSION)s + +[package] +CLONE_URL = https://%(IMPORT_PATH)s + +[package.sub] +``` + +```go +cfg.Section("package.sub").Key("CLONE_URL").String() // https://gopkg.in/ini.v1 +``` + +### Auto-increment Key Names + +If key name is `-` in data source, then it would be seen as special syntax for auto-increment key name start from 1, and every section is independent on counter. + +```ini +[features] +-: Support read/write comments of keys and sections +-: Support auto-increment of key names +-: Support load multiple files to overwrite key values +``` + +```go +cfg.Section("features").KeyStrings() // []{"#1", "#2", "#3"} +``` + +### Map To Struct + +Want more objective way to play with INI? Cool. + +```ini +Name = Unknwon +age = 21 +Male = true +Born = 1993-01-01T20:17:05Z + +[Note] +Content = Hi is a good man! +Cities = HangZhou, Boston +``` + +```go +type Note struct { + Content string + Cities []string +} + +type Person struct { + Name string + Age int `ini:"age"` + Male bool + Born time.Time + Note + Created time.Time `ini:"-"` +} + +func main() { + cfg, err := ini.Load("path/to/ini") + // ... + p := new(Person) + err = cfg.MapTo(p) + // ... + + // Things can be simpler. + err = ini.MapTo(p, "path/to/ini") + // ... + + // Just map a section? Fine. + n := new(Note) + err = cfg.Section("Note").MapTo(n) + // ... +} +``` + +Can I have default value for field? Absolutely. + +Assign it before you map to struct. It will keep the value as it is if the key is not presented or got wrong type. + +```go +// ... +p := &Person{ + Name: "Joe", +} +// ... +``` + +It's really cool, but what's the point if you can't give me my file back from struct? + +### Reflect From Struct + +Why not? + +```go +type Embeded struct { + Dates []time.Time `delim:"|"` + Places []string + None []int +} + +type Author struct { + Name string `ini:"NAME"` + Male bool + Age int + GPA float64 + NeverMind string `ini:"-"` + *Embeded +} + +func main() { + a := &Author{"Unknwon", true, 21, 2.8, "", + &Embeded{ + []time.Time{time.Now(), time.Now()}, + []string{"HangZhou", "Boston"}, + []int{}, + }} + cfg := ini.Empty() + err = ini.ReflectFrom(cfg, a) + // ... +} +``` + +So, what do I get? + +```ini +NAME = Unknwon +Male = true +Age = 21 +GPA = 2.8 + +[Embeded] +Dates = 2015-08-07T22:14:22+08:00|2015-08-07T22:14:22+08:00 +Places = HangZhou,Boston +None = +``` + +#### Name Mapper + +To save your time and make your code cleaner, this library supports [`NameMapper`](https://gowalker.org/gopkg.in/ini.v1#NameMapper) between struct field and actual section and key name. + +There are 2 built-in name mappers: + +- `AllCapsUnderscore`: it converts to format `ALL_CAPS_UNDERSCORE` then match section or key. +- `TitleUnderscore`: it converts to format `title_underscore` then match section or key. + +To use them: + +```go +type Info struct { + PackageName string +} + +func main() { + err = ini.MapToWithMapper(&Info{}, ini.TitleUnderscore, []byte("package_name=ini")) + // ... + + cfg, err := ini.Load([]byte("PACKAGE_NAME=ini")) + // ... + info := new(Info) + cfg.NameMapper = ini.AllCapsUnderscore + err = cfg.MapTo(info) + // ... +} +``` + +Same rules of name mapper apply to `ini.ReflectFromWithMapper` function. + +#### Other Notes On Map/Reflect + +Any embedded struct is treated as a section by default, and there is no automatic parent-child relations in map/reflect feature: + +```go +type Child struct { + Age string +} + +type Parent struct { + Name string + Child +} + +type Config struct { + City string + Parent +} +``` + +Example configuration: + +```ini +City = Boston + +[Parent] +Name = Unknwon + +[Child] +Age = 21 +``` + +What if, yes, I'm paranoid, I want embedded struct to be in the same section. Well, all roads lead to Rome. + +```go +type Child struct { + Age string +} + +type Parent struct { + Name string + Child `ini:"Parent"` +} + +type Config struct { + City string + Parent +} +``` + +Example configuration: + +```ini +City = Boston + +[Parent] +Name = Unknwon +Age = 21 +``` + +## Getting Help + +- [API Documentation](https://gowalker.org/gopkg.in/ini.v1) +- [File An Issue](https://github.com/go-ini/ini/issues/new) + +## FAQs + +### What does `BlockMode` field do? + +By default, library lets you read and write values so we need a locker to make sure your data is safe. But in cases that you are very sure about only reading data through the library, you can set `cfg.BlockMode = false` to speed up read operations about **50-70%** faster. + +### Why another INI library? + +Many people are using my another INI library [goconfig](https://github.com/Unknwon/goconfig), so the reason for this one is I would like to make more Go style code. Also when you set `cfg.BlockMode = false`, this one is about **10-30%** faster. + +To make those changes I have to confirm API broken, so it's safer to keep it in another place and start using `gopkg.in` to version my package at this time.(PS: shorter import path) + +## License + +This project is under Apache v2 License. See the [LICENSE](LICENSE) file for the full license text. diff --git a/Godeps/_workspace/src/github.com/go-ini/ini/README_ZH.md b/Godeps/_workspace/src/github.com/go-ini/ini/README_ZH.md new file mode 100644 index 0000000000..75c10051a1 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ini/ini/README_ZH.md @@ -0,0 +1,619 @@ +本包提供了 Go 语言中读写 INI 文件的功能。 + +## 功能特性 + +- 支持覆盖加载多个数据源(`[]byte` 或文件) +- 支持递归读取键值 +- 支持读取父子分区 +- 支持读取自增键名 +- 支持读取多行的键值 +- 支持大量辅助方法 +- 支持在读取时直接转换为 Go 语言类型 +- 支持读取和 **写入** 分区和键的注释 +- 轻松操作分区、键值和注释 +- 在保存文件时分区和键值会保持原有的顺序 + +## 下载安装 + +使用一个特定版本: + + go get gopkg.in/ini.v1 + +使用最新版: + + go get github.com/go-ini/ini + +如需更新请添加 `-u` 选项。 + +### 测试安装 + +如果您想要在自己的机器上运行测试,请使用 `-t` 标记: + + go get -t gopkg.in/ini.v1 + +如需更新请添加 `-u` 选项。 + +## 开始使用 + +### 从数据源加载 + +一个 **数据源** 可以是 `[]byte` 类型的原始数据,或 `string` 类型的文件路径。您可以加载 **任意多个** 数据源。如果您传递其它类型的数据源,则会直接返回错误。 + +```go +cfg, err := ini.Load([]byte("raw data"), "filename") +``` + +或者从一个空白的文件开始: + +```go +cfg := ini.Empty() +``` + +当您在一开始无法决定需要加载哪些数据源时,仍可以使用 **Append()** 在需要的时候加载它们。 + +```go +err := cfg.Append("other file", []byte("other raw data")) +``` + +当您想要加载一系列文件,但是不能够确定其中哪些文件是不存在的,可以通过调用函数 `LooseLoad` 来忽略它们(`Load` 会因为文件不存在而返回错误): + +```go +cfg, err := ini.LooseLoad("filename", "filename_404") +``` + +更牛逼的是,当那些之前不存在的文件在重新调用 `Reload` 方法的时候突然出现了,那么它们会被正常加载。 + +### 操作分区(Section) + +获取指定分区: + +```go +section, err := cfg.GetSection("section name") +``` + +如果您想要获取默认分区,则可以用空字符串代替分区名: + +```go +section, err := cfg.GetSection("") +``` + +当您非常确定某个分区是存在的,可以使用以下简便方法: + +```go +section := cfg.Section("") +``` + +如果不小心判断错了,要获取的分区其实是不存在的,那会发生什么呢?没事的,它会自动创建并返回一个对应的分区对象给您。 + +创建一个分区: + +```go +err := cfg.NewSection("new section") +``` + +获取所有分区对象或名称: + +```go +sections := cfg.Sections() +names := cfg.SectionStrings() +``` + +### 操作键(Key) + +获取某个分区下的键: + +```go +key, err := cfg.Section("").GetKey("key name") +``` + +和分区一样,您也可以直接获取键而忽略错误处理: + +```go +key := cfg.Section("").Key("key name") +``` + +判断某个键是否存在: + +```go +yes := cfg.Section("").HasKey("key name") +``` + +创建一个新的键: + +```go +err := cfg.Section("").NewKey("name", "value") +``` + +获取分区下的所有键或键名: + +```go +keys := cfg.Section("").Keys() +names := cfg.Section("").KeyStrings() +``` + +获取分区下的所有键值对的克隆: + +```go +hash := cfg.GetSection("").KeysHash() +``` + +### 操作键值(Value) + +获取一个类型为字符串(string)的值: + +```go +val := cfg.Section("").Key("key name").String() +``` + +获取值的同时通过自定义函数进行处理验证: + +```go +val := cfg.Section("").Key("key name").Validate(func(in string) string { + if len(in) == 0 { + return "default" + } + return in +}) +``` + +如果您不需要任何对值的自动转变功能(例如递归读取),可以直接获取原值(这种方式性能最佳): + +```go +val := cfg.Section("").Key("key name").Value() +``` + +判断某个原值是否存在: + +```go +yes := cfg.Section("").HasValue("test value") +``` + +获取其它类型的值: + +```go +// 布尔值的规则: +// true 当值为:1, t, T, TRUE, true, True, YES, yes, Yes, y, ON, on, On +// false 当值为:0, f, F, FALSE, false, False, NO, no, No, n, OFF, off, Off +v, err = cfg.Section("").Key("BOOL").Bool() +v, err = cfg.Section("").Key("FLOAT64").Float64() +v, err = cfg.Section("").Key("INT").Int() +v, err = cfg.Section("").Key("INT64").Int64() +v, err = cfg.Section("").Key("UINT").Uint() +v, err = cfg.Section("").Key("UINT64").Uint64() +v, err = cfg.Section("").Key("TIME").TimeFormat(time.RFC3339) +v, err = cfg.Section("").Key("TIME").Time() // RFC3339 + +v = cfg.Section("").Key("BOOL").MustBool() +v = cfg.Section("").Key("FLOAT64").MustFloat64() +v = cfg.Section("").Key("INT").MustInt() +v = cfg.Section("").Key("INT64").MustInt64() +v = cfg.Section("").Key("UINT").MustUint() +v = cfg.Section("").Key("UINT64").MustUint64() +v = cfg.Section("").Key("TIME").MustTimeFormat(time.RFC3339) +v = cfg.Section("").Key("TIME").MustTime() // RFC3339 + +// 由 Must 开头的方法名允许接收一个相同类型的参数来作为默认值, +// 当键不存在或者转换失败时,则会直接返回该默认值。 +// 但是,MustString 方法必须传递一个默认值。 + +v = cfg.Seciont("").Key("String").MustString("default") +v = cfg.Section("").Key("BOOL").MustBool(true) +v = cfg.Section("").Key("FLOAT64").MustFloat64(1.25) +v = cfg.Section("").Key("INT").MustInt(10) +v = cfg.Section("").Key("INT64").MustInt64(99) +v = cfg.Section("").Key("UINT").MustUint(3) +v = cfg.Section("").Key("UINT64").MustUint64(6) +v = cfg.Section("").Key("TIME").MustTimeFormat(time.RFC3339, time.Now()) +v = cfg.Section("").Key("TIME").MustTime(time.Now()) // RFC3339 +``` + +如果我的值有好多行怎么办? + +```ini +[advance] +ADDRESS = """404 road, +NotFound, State, 5000 +Earth""" +``` + +嗯哼?小 case! + +```go +cfg.Section("advance").Key("ADDRESS").String() + +/* --- start --- +404 road, +NotFound, State, 5000 +Earth +------ end --- */ +``` + +赞爆了!那要是我属于一行的内容写不下想要写到第二行怎么办? + +```ini +[advance] +two_lines = how about \ + continuation lines? +lots_of_lines = 1 \ + 2 \ + 3 \ + 4 +``` + +简直是小菜一碟! + +```go +cfg.Section("advance").Key("two_lines").String() // how about continuation lines? +cfg.Section("advance").Key("lots_of_lines").String() // 1 2 3 4 +``` + +需要注意的是,值两侧的单引号会被自动剔除: + +```ini +foo = "some value" // foo: some value +bar = 'some value' // bar: some value +``` + +这就是全部了?哈哈,当然不是。 + +#### 操作键值的辅助方法 + +获取键值时设定候选值: + +```go +v = cfg.Section("").Key("STRING").In("default", []string{"str", "arr", "types"}) +v = cfg.Section("").Key("FLOAT64").InFloat64(1.1, []float64{1.25, 2.5, 3.75}) +v = cfg.Section("").Key("INT").InInt(5, []int{10, 20, 30}) +v = cfg.Section("").Key("INT64").InInt64(10, []int64{10, 20, 30}) +v = cfg.Section("").Key("UINT").InUint(4, []int{3, 6, 9}) +v = cfg.Section("").Key("UINT64").InUint64(8, []int64{3, 6, 9}) +v = cfg.Section("").Key("TIME").InTimeFormat(time.RFC3339, time.Now(), []time.Time{time1, time2, time3}) +v = cfg.Section("").Key("TIME").InTime(time.Now(), []time.Time{time1, time2, time3}) // RFC3339 +``` + +如果获取到的值不是候选值的任意一个,则会返回默认值,而默认值不需要是候选值中的一员。 + +验证获取的值是否在指定范围内: + +```go +vals = cfg.Section("").Key("FLOAT64").RangeFloat64(0.0, 1.1, 2.2) +vals = cfg.Section("").Key("INT").RangeInt(0, 10, 20) +vals = cfg.Section("").Key("INT64").RangeInt64(0, 10, 20) +vals = cfg.Section("").Key("UINT").RangeUint(0, 3, 9) +vals = cfg.Section("").Key("UINT64").RangeUint64(0, 3, 9) +vals = cfg.Section("").Key("TIME").RangeTimeFormat(time.RFC3339, time.Now(), minTime, maxTime) +vals = cfg.Section("").Key("TIME").RangeTime(time.Now(), minTime, maxTime) // RFC3339 +``` + +##### 自动分割键值到切片(slice) + +当存在无效输入时,使用零值代替: + +```go +// Input: 1.1, 2.2, 3.3, 4.4 -> [1.1 2.2 3.3 4.4] +// Input: how, 2.2, are, you -> [0.0 2.2 0.0 0.0] +vals = cfg.Section("").Key("STRINGS").Strings(",") +vals = cfg.Section("").Key("FLOAT64S").Float64s(",") +vals = cfg.Section("").Key("INTS").Ints(",") +vals = cfg.Section("").Key("INT64S").Int64s(",") +vals = cfg.Section("").Key("UINTS").Uints(",") +vals = cfg.Section("").Key("UINT64S").Uint64s(",") +vals = cfg.Section("").Key("TIMES").Times(",") +``` + +从结果切片中剔除无效输入: + +```go +// Input: 1.1, 2.2, 3.3, 4.4 -> [1.1 2.2 3.3 4.4] +// Input: how, 2.2, are, you -> [2.2] +vals = cfg.Section("").Key("FLOAT64S").ValidFloat64s(",") +vals = cfg.Section("").Key("INTS").ValidInts(",") +vals = cfg.Section("").Key("INT64S").ValidInt64s(",") +vals = cfg.Section("").Key("UINTS").ValidUints(",") +vals = cfg.Section("").Key("UINT64S").ValidUint64s(",") +vals = cfg.Section("").Key("TIMES").ValidTimes(",") +``` + +当存在无效输入时,直接返回错误: + +```go +// Input: 1.1, 2.2, 3.3, 4.4 -> [1.1 2.2 3.3 4.4] +// Input: how, 2.2, are, you -> error +vals = cfg.Section("").Key("FLOAT64S").StrictFloat64s(",") +vals = cfg.Section("").Key("INTS").StrictInts(",") +vals = cfg.Section("").Key("INT64S").StrictInt64s(",") +vals = cfg.Section("").Key("UINTS").StrictUints(",") +vals = cfg.Section("").Key("UINT64S").StrictUint64s(",") +vals = cfg.Section("").Key("TIMES").StrictTimes(",") +``` + +### 保存配置 + +终于到了这个时刻,是时候保存一下配置了。 + +比较原始的做法是输出配置到某个文件: + +```go +// ... +err = cfg.SaveTo("my.ini") +err = cfg.SaveToIndent("my.ini", "\t") +``` + +另一个比较高级的做法是写入到任何实现 `io.Writer` 接口的对象中: + +```go +// ... +cfg.WriteTo(writer) +cfg.WriteToIndent(writer, "\t") +``` + +### 高级用法 + +#### 递归读取键值 + +在获取所有键值的过程中,特殊语法 `%()s` 会被应用,其中 `` 可以是相同分区或者默认分区下的键名。字符串 `%()s` 会被相应的键值所替代,如果指定的键不存在,则会用空字符串替代。您可以最多使用 99 层的递归嵌套。 + +```ini +NAME = ini + +[author] +NAME = Unknwon +GITHUB = https://github.com/%(NAME)s + +[package] +FULL_NAME = github.com/go-ini/%(NAME)s +``` + +```go +cfg.Section("author").Key("GITHUB").String() // https://github.com/Unknwon +cfg.Section("package").Key("FULL_NAME").String() // github.com/go-ini/ini +``` + +#### 读取父子分区 + +您可以在分区名称中使用 `.` 来表示两个或多个分区之间的父子关系。如果某个键在子分区中不存在,则会去它的父分区中再次寻找,直到没有父分区为止。 + +```ini +NAME = ini +VERSION = v1 +IMPORT_PATH = gopkg.in/%(NAME)s.%(VERSION)s + +[package] +CLONE_URL = https://%(IMPORT_PATH)s + +[package.sub] +``` + +```go +cfg.Section("package.sub").Key("CLONE_URL").String() // https://gopkg.in/ini.v1 +``` + +#### 读取自增键名 + +如果数据源中的键名为 `-`,则认为该键使用了自增键名的特殊语法。计数器从 1 开始,并且分区之间是相互独立的。 + +```ini +[features] +-: Support read/write comments of keys and sections +-: Support auto-increment of key names +-: Support load multiple files to overwrite key values +``` + +```go +cfg.Section("features").KeyStrings() // []{"#1", "#2", "#3"} +``` + +### 映射到结构 + +想要使用更加面向对象的方式玩转 INI 吗?好主意。 + +```ini +Name = Unknwon +age = 21 +Male = true +Born = 1993-01-01T20:17:05Z + +[Note] +Content = Hi is a good man! +Cities = HangZhou, Boston +``` + +```go +type Note struct { + Content string + Cities []string +} + +type Person struct { + Name string + Age int `ini:"age"` + Male bool + Born time.Time + Note + Created time.Time `ini:"-"` +} + +func main() { + cfg, err := ini.Load("path/to/ini") + // ... + p := new(Person) + err = cfg.MapTo(p) + // ... + + // 一切竟可以如此的简单。 + err = ini.MapTo(p, "path/to/ini") + // ... + + // 嗯哼?只需要映射一个分区吗? + n := new(Note) + err = cfg.Section("Note").MapTo(n) + // ... +} +``` + +结构的字段怎么设置默认值呢?很简单,只要在映射之前对指定字段进行赋值就可以了。如果键未找到或者类型错误,该值不会发生改变。 + +```go +// ... +p := &Person{ + Name: "Joe", +} +// ... +``` + +这样玩 INI 真的好酷啊!然而,如果不能还给我原来的配置文件,有什么卵用? + +### 从结构反射 + +可是,我有说不能吗? + +```go +type Embeded struct { + Dates []time.Time `delim:"|"` + Places []string + None []int +} + +type Author struct { + Name string `ini:"NAME"` + Male bool + Age int + GPA float64 + NeverMind string `ini:"-"` + *Embeded +} + +func main() { + a := &Author{"Unknwon", true, 21, 2.8, "", + &Embeded{ + []time.Time{time.Now(), time.Now()}, + []string{"HangZhou", "Boston"}, + []int{}, + }} + cfg := ini.Empty() + err = ini.ReflectFrom(cfg, a) + // ... +} +``` + +瞧瞧,奇迹发生了。 + +```ini +NAME = Unknwon +Male = true +Age = 21 +GPA = 2.8 + +[Embeded] +Dates = 2015-08-07T22:14:22+08:00|2015-08-07T22:14:22+08:00 +Places = HangZhou,Boston +None = +``` + +#### 名称映射器(Name Mapper) + +为了节省您的时间并简化代码,本库支持类型为 [`NameMapper`](https://gowalker.org/gopkg.in/ini.v1#NameMapper) 的名称映射器,该映射器负责结构字段名与分区名和键名之间的映射。 + +目前有 2 款内置的映射器: + +- `AllCapsUnderscore`:该映射器将字段名转换至格式 `ALL_CAPS_UNDERSCORE` 后再去匹配分区名和键名。 +- `TitleUnderscore`:该映射器将字段名转换至格式 `title_underscore` 后再去匹配分区名和键名。 + +使用方法: + +```go +type Info struct{ + PackageName string +} + +func main() { + err = ini.MapToWithMapper(&Info{}, ini.TitleUnderscore, []byte("package_name=ini")) + // ... + + cfg, err := ini.Load([]byte("PACKAGE_NAME=ini")) + // ... + info := new(Info) + cfg.NameMapper = ini.AllCapsUnderscore + err = cfg.MapTo(info) + // ... +} +``` + +使用函数 `ini.ReflectFromWithMapper` 时也可应用相同的规则。 + +#### 映射/反射的其它说明 + +任何嵌入的结构都会被默认认作一个不同的分区,并且不会自动产生所谓的父子分区关联: + +```go +type Child struct { + Age string +} + +type Parent struct { + Name string + Child +} + +type Config struct { + City string + Parent +} +``` + +示例配置文件: + +```ini +City = Boston + +[Parent] +Name = Unknwon + +[Child] +Age = 21 +``` + +很好,但是,我就是要嵌入结构也在同一个分区。好吧,你爹是李刚! + +```go +type Child struct { + Age string +} + +type Parent struct { + Name string + Child `ini:"Parent"` +} + +type Config struct { + City string + Parent +} +``` + +示例配置文件: + +```ini +City = Boston + +[Parent] +Name = Unknwon +Age = 21 +``` + +## 获取帮助 + +- [API 文档](https://gowalker.org/gopkg.in/ini.v1) +- [创建工单](https://github.com/go-ini/ini/issues/new) + +## 常见问题 + +### 字段 `BlockMode` 是什么? + +默认情况下,本库会在您进行读写操作时采用锁机制来确保数据时间。但在某些情况下,您非常确定只进行读操作。此时,您可以通过设置 `cfg.BlockMode = false` 来将读操作提升大约 **50-70%** 的性能。 + +### 为什么要写另一个 INI 解析库? + +许多人都在使用我的 [goconfig](https://github.com/Unknwon/goconfig) 来完成对 INI 文件的操作,但我希望使用更加 Go 风格的代码。并且当您设置 `cfg.BlockMode = false` 时,会有大约 **10-30%** 的性能提升。 + +为了做出这些改变,我必须对 API 进行破坏,所以新开一个仓库是最安全的做法。除此之外,本库直接使用 `gopkg.in` 来进行版本化发布。(其实真相是导入路径更短了) diff --git a/Godeps/_workspace/src/github.com/go-ini/ini/ini.go b/Godeps/_workspace/src/github.com/go-ini/ini/ini.go new file mode 100644 index 0000000000..f186148aad --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ini/ini/ini.go @@ -0,0 +1,465 @@ +// Copyright 2014 Unknwon +// +// Licensed under the Apache License, Version 2.0 (the "License"): you may +// not use this file except in compliance with the License. You may obtain +// a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations +// under the License. + +// Package ini provides INI file read and write functionality in Go. +package ini + +import ( + "bytes" + "errors" + "fmt" + "io" + "os" + "regexp" + "runtime" + "strconv" + "strings" + "sync" + "time" +) + +const ( + // Name for default section. You can use this constant or the string literal. + // In most of cases, an empty string is all you need to access the section. + DEFAULT_SECTION = "DEFAULT" + + // Maximum allowed depth when recursively substituing variable names. + _DEPTH_VALUES = 99 + _VERSION = "1.11.0" +) + +// Version returns current package version literal. +func Version() string { + return _VERSION +} + +var ( + // Delimiter to determine or compose a new line. + // This variable will be changed to "\r\n" automatically on Windows + // at package init time. + LineBreak = "\n" + + // Variable regexp pattern: %(variable)s + varPattern = regexp.MustCompile(`%\(([^\)]+)\)s`) + + // Indicate whether to align "=" sign with spaces to produce pretty output + // or reduce all possible spaces for compact format. + PrettyFormat = true + + // Explicitly write DEFAULT section header + DefaultHeader = false +) + +func init() { + if runtime.GOOS == "windows" { + LineBreak = "\r\n" + } +} + +func inSlice(str string, s []string) bool { + for _, v := range s { + if str == v { + return true + } + } + return false +} + +// dataSource is an interface that returns object which can be read and closed. +type dataSource interface { + ReadCloser() (io.ReadCloser, error) +} + +// sourceFile represents an object that contains content on the local file system. +type sourceFile struct { + name string +} + +func (s sourceFile) ReadCloser() (_ io.ReadCloser, err error) { + return os.Open(s.name) +} + +type bytesReadCloser struct { + reader io.Reader +} + +func (rc *bytesReadCloser) Read(p []byte) (n int, err error) { + return rc.reader.Read(p) +} + +func (rc *bytesReadCloser) Close() error { + return nil +} + +// sourceData represents an object that contains content in memory. +type sourceData struct { + data []byte +} + +func (s *sourceData) ReadCloser() (io.ReadCloser, error) { + return &bytesReadCloser{bytes.NewReader(s.data)}, nil +} + +// File represents a combination of a or more INI file(s) in memory. +type File struct { + // Should make things safe, but sometimes doesn't matter. + BlockMode bool + // Make sure data is safe in multiple goroutines. + lock sync.RWMutex + + // Allow combination of multiple data sources. + dataSources []dataSource + // Actual data is stored here. + sections map[string]*Section + + // To keep data in order. + sectionList []string + + // Whether the parser should ignore nonexistent files or return error. + looseMode bool + + NameMapper +} + +// newFile initializes File object with given data sources. +func newFile(dataSources []dataSource, looseMode bool) *File { + return &File{ + BlockMode: true, + dataSources: dataSources, + sections: make(map[string]*Section), + sectionList: make([]string, 0, 10), + looseMode: looseMode, + } +} + +func parseDataSource(source interface{}) (dataSource, error) { + switch s := source.(type) { + case string: + return sourceFile{s}, nil + case []byte: + return &sourceData{s}, nil + default: + return nil, fmt.Errorf("error parsing data source: unknown type '%s'", s) + } +} + +func loadSources(looseMode bool, source interface{}, others ...interface{}) (_ *File, err error) { + sources := make([]dataSource, len(others)+1) + sources[0], err = parseDataSource(source) + if err != nil { + return nil, err + } + for i := range others { + sources[i+1], err = parseDataSource(others[i]) + if err != nil { + return nil, err + } + } + f := newFile(sources, looseMode) + if err = f.Reload(); err != nil { + return nil, err + } + return f, nil +} + +// Load loads and parses from INI data sources. +// Arguments can be mixed of file name with string type, or raw data in []byte. +// It will return error if list contains nonexistent files. +func Load(source interface{}, others ...interface{}) (*File, error) { + return loadSources(false, source, others...) +} + +// LooseLoad has exactly same functionality as Load function +// except it ignores nonexistent files instead of returning error. +func LooseLoad(source interface{}, others ...interface{}) (*File, error) { + return loadSources(true, source, others...) +} + +// Empty returns an empty file object. +func Empty() *File { + // Ignore error here, we sure our data is good. + f, _ := Load([]byte("")) + return f +} + +// NewSection creates a new section. +func (f *File) NewSection(name string) (*Section, error) { + if len(name) == 0 { + return nil, errors.New("error creating new section: empty section name") + } + + if f.BlockMode { + f.lock.Lock() + defer f.lock.Unlock() + } + + if inSlice(name, f.sectionList) { + return f.sections[name], nil + } + + f.sectionList = append(f.sectionList, name) + f.sections[name] = newSection(f, name) + return f.sections[name], nil +} + +// NewSections creates a list of sections. +func (f *File) NewSections(names ...string) (err error) { + for _, name := range names { + if _, err = f.NewSection(name); err != nil { + return err + } + } + return nil +} + +// GetSection returns section by given name. +func (f *File) GetSection(name string) (*Section, error) { + if len(name) == 0 { + name = DEFAULT_SECTION + } + + if f.BlockMode { + f.lock.RLock() + defer f.lock.RUnlock() + } + + sec := f.sections[name] + if sec == nil { + return nil, fmt.Errorf("section '%s' does not exist", name) + } + return sec, nil +} + +// Section assumes named section exists and returns a zero-value when not. +func (f *File) Section(name string) *Section { + sec, err := f.GetSection(name) + if err != nil { + // Note: It's OK here because the only possible error is empty section name, + // but if it's empty, this piece of code won't be executed. + sec, _ = f.NewSection(name) + return sec + } + return sec +} + +// Section returns list of Section. +func (f *File) Sections() []*Section { + sections := make([]*Section, len(f.sectionList)) + for i := range f.sectionList { + sections[i] = f.Section(f.sectionList[i]) + } + return sections +} + +// SectionStrings returns list of section names. +func (f *File) SectionStrings() []string { + list := make([]string, len(f.sectionList)) + copy(list, f.sectionList) + return list +} + +// DeleteSection deletes a section. +func (f *File) DeleteSection(name string) { + if f.BlockMode { + f.lock.Lock() + defer f.lock.Unlock() + } + + if len(name) == 0 { + name = DEFAULT_SECTION + } + + for i, s := range f.sectionList { + if s == name { + f.sectionList = append(f.sectionList[:i], f.sectionList[i+1:]...) + delete(f.sections, name) + return + } + } +} + +func (f *File) reload(s dataSource) error { + r, err := s.ReadCloser() + if err != nil { + return err + } + defer r.Close() + + return f.parse(r) +} + +// Reload reloads and parses all data sources. +func (f *File) Reload() (err error) { + for _, s := range f.dataSources { + if err = f.reload(s); err != nil { + // In loose mode, we create an empty default section for nonexistent files. + if os.IsNotExist(err) && f.looseMode { + f.parse(bytes.NewBuffer(nil)) + continue + } + return err + } + } + return nil +} + +// Append appends one or more data sources and reloads automatically. +func (f *File) Append(source interface{}, others ...interface{}) error { + ds, err := parseDataSource(source) + if err != nil { + return err + } + f.dataSources = append(f.dataSources, ds) + for _, s := range others { + ds, err = parseDataSource(s) + if err != nil { + return err + } + f.dataSources = append(f.dataSources, ds) + } + return f.Reload() +} + +// WriteToIndent writes content into io.Writer with given indention. +// If PrettyFormat has been set to be true, +// it will align "=" sign with spaces under each section. +func (f *File) WriteToIndent(w io.Writer, indent string) (n int64, err error) { + equalSign := "=" + if PrettyFormat { + equalSign = " = " + } + + // Use buffer to make sure target is safe until finish encoding. + buf := bytes.NewBuffer(nil) + for i, sname := range f.sectionList { + sec := f.Section(sname) + if len(sec.Comment) > 0 { + if sec.Comment[0] != '#' && sec.Comment[0] != ';' { + sec.Comment = "; " + sec.Comment + } + if _, err = buf.WriteString(sec.Comment + LineBreak); err != nil { + return 0, err + } + } + + if i > 0 || DefaultHeader { + if _, err = buf.WriteString("[" + sname + "]" + LineBreak); err != nil { + return 0, err + } + } else { + // Write nothing if default section is empty + if len(sec.keyList) == 0 { + continue + } + } + + // Count and generate alignment length and buffer spaces + alignLength := 0 + if PrettyFormat { + for i := 0; i < len(sec.keyList); i++ { + if len(sec.keyList[i]) > alignLength { + alignLength = len(sec.keyList[i]) + } + } + } + alignSpaces := bytes.Repeat([]byte(" "), alignLength) + + for _, kname := range sec.keyList { + key := sec.Key(kname) + if len(key.Comment) > 0 { + if len(indent) > 0 && sname != DEFAULT_SECTION { + buf.WriteString(indent) + } + if key.Comment[0] != '#' && key.Comment[0] != ';' { + key.Comment = "; " + key.Comment + } + if _, err = buf.WriteString(key.Comment + LineBreak); err != nil { + return 0, err + } + } + + if len(indent) > 0 && sname != DEFAULT_SECTION { + buf.WriteString(indent) + } + + switch { + case key.isAutoIncr: + kname = "-" + case strings.ContainsAny(kname, "\"=:"): + kname = "`" + kname + "`" + case strings.Contains(kname, "`"): + kname = `"""` + kname + `"""` + } + if _, err = buf.WriteString(kname); err != nil { + return 0, err + } + + // Write out alignment spaces before "=" sign + if PrettyFormat { + buf.Write(alignSpaces[:alignLength-len(kname)]) + } + + val := key.value + // In case key value contains "\n", "`", "\"", "#" or ";" + if strings.ContainsAny(val, "\n`") { + val = `"""` + val + `"""` + } else if strings.ContainsAny(val, "#;") { + val = "`" + val + "`" + } + if _, err = buf.WriteString(equalSign + val + LineBreak); err != nil { + return 0, err + } + } + + // Put a line between sections + if _, err = buf.WriteString(LineBreak); err != nil { + return 0, err + } + } + + return buf.WriteTo(w) +} + +// WriteTo writes file content into io.Writer. +func (f *File) WriteTo(w io.Writer) (int64, error) { + return f.WriteToIndent(w, "") +} + +// SaveToIndent writes content to file system with given value indention. +func (f *File) SaveToIndent(filename, indent string) error { + // Note: Because we are truncating with os.Create, + // so it's safer to save to a temporary file location and rename afte done. + tmpPath := filename + "." + strconv.Itoa(time.Now().Nanosecond()) + ".tmp" + defer os.Remove(tmpPath) + + fw, err := os.Create(tmpPath) + if err != nil { + return err + } + + if _, err = f.WriteToIndent(fw, indent); err != nil { + fw.Close() + return err + } + fw.Close() + + // Remove old file and rename the new one. + os.Remove(filename) + return os.Rename(tmpPath, filename) +} + +// SaveTo writes content to file system. +func (f *File) SaveTo(filename string) error { + return f.SaveToIndent(filename, "") +} diff --git a/Godeps/_workspace/src/github.com/go-ini/ini/key.go b/Godeps/_workspace/src/github.com/go-ini/ini/key.go new file mode 100644 index 0000000000..7cbccd38e6 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ini/ini/key.go @@ -0,0 +1,616 @@ +// Copyright 2014 Unknwon +// +// Licensed under the Apache License, Version 2.0 (the "License"): you may +// not use this file except in compliance with the License. You may obtain +// a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations +// under the License. + +package ini + +import ( + "fmt" + "strconv" + "strings" + "time" +) + +// Key represents a key under a section. +type Key struct { + s *Section + Comment string + name string + value string + isAutoIncr bool +} + +// Name returns name of key. +func (k *Key) Name() string { + return k.name +} + +// Value returns raw value of key for performance purpose. +func (k *Key) Value() string { + return k.value +} + +// String returns string representation of value. +func (k *Key) String() string { + val := k.value + if strings.Index(val, "%") == -1 { + return val + } + + for i := 0; i < _DEPTH_VALUES; i++ { + vr := varPattern.FindString(val) + if len(vr) == 0 { + break + } + + // Take off leading '%(' and trailing ')s'. + noption := strings.TrimLeft(vr, "%(") + noption = strings.TrimRight(noption, ")s") + + // Search in the same section. + nk, err := k.s.GetKey(noption) + if err != nil { + // Search again in default section. + nk, _ = k.s.f.Section("").GetKey(noption) + } + + // Substitute by new value and take off leading '%(' and trailing ')s'. + val = strings.Replace(val, vr, nk.value, -1) + } + return val +} + +// Validate accepts a validate function which can +// return modifed result as key value. +func (k *Key) Validate(fn func(string) string) string { + return fn(k.String()) +} + +// parseBool returns the boolean value represented by the string. +// +// It accepts 1, t, T, TRUE, true, True, YES, yes, Yes, y, ON, on, On, +// 0, f, F, FALSE, false, False, NO, no, No, n, OFF, off, Off. +// Any other value returns an error. +func parseBool(str string) (value bool, err error) { + switch str { + case "1", "t", "T", "true", "TRUE", "True", "YES", "yes", "Yes", "y", "ON", "on", "On": + return true, nil + case "0", "f", "F", "false", "FALSE", "False", "NO", "no", "No", "n", "OFF", "off", "Off": + return false, nil + } + return false, fmt.Errorf("parsing \"%s\": invalid syntax", str) +} + +// Bool returns bool type value. +func (k *Key) Bool() (bool, error) { + return parseBool(k.String()) +} + +// Float64 returns float64 type value. +func (k *Key) Float64() (float64, error) { + return strconv.ParseFloat(k.String(), 64) +} + +// Int returns int type value. +func (k *Key) Int() (int, error) { + return strconv.Atoi(k.String()) +} + +// Int64 returns int64 type value. +func (k *Key) Int64() (int64, error) { + return strconv.ParseInt(k.String(), 10, 64) +} + +// Uint returns uint type valued. +func (k *Key) Uint() (uint, error) { + u, e := strconv.ParseUint(k.String(), 10, 64) + return uint(u), e +} + +// Uint64 returns uint64 type value. +func (k *Key) Uint64() (uint64, error) { + return strconv.ParseUint(k.String(), 10, 64) +} + +// Duration returns time.Duration type value. +func (k *Key) Duration() (time.Duration, error) { + return time.ParseDuration(k.String()) +} + +// TimeFormat parses with given format and returns time.Time type value. +func (k *Key) TimeFormat(format string) (time.Time, error) { + return time.Parse(format, k.String()) +} + +// Time parses with RFC3339 format and returns time.Time type value. +func (k *Key) Time() (time.Time, error) { + return k.TimeFormat(time.RFC3339) +} + +// MustString returns default value if key value is empty. +func (k *Key) MustString(defaultVal string) string { + val := k.String() + if len(val) == 0 { + return defaultVal + } + return val +} + +// MustBool always returns value without error, +// it returns false if error occurs. +func (k *Key) MustBool(defaultVal ...bool) bool { + val, err := k.Bool() + if len(defaultVal) > 0 && err != nil { + return defaultVal[0] + } + return val +} + +// MustFloat64 always returns value without error, +// it returns 0.0 if error occurs. +func (k *Key) MustFloat64(defaultVal ...float64) float64 { + val, err := k.Float64() + if len(defaultVal) > 0 && err != nil { + return defaultVal[0] + } + return val +} + +// MustInt always returns value without error, +// it returns 0 if error occurs. +func (k *Key) MustInt(defaultVal ...int) int { + val, err := k.Int() + if len(defaultVal) > 0 && err != nil { + return defaultVal[0] + } + return val +} + +// MustInt64 always returns value without error, +// it returns 0 if error occurs. +func (k *Key) MustInt64(defaultVal ...int64) int64 { + val, err := k.Int64() + if len(defaultVal) > 0 && err != nil { + return defaultVal[0] + } + return val +} + +// MustUint always returns value without error, +// it returns 0 if error occurs. +func (k *Key) MustUint(defaultVal ...uint) uint { + val, err := k.Uint() + if len(defaultVal) > 0 && err != nil { + return defaultVal[0] + } + return val +} + +// MustUint64 always returns value without error, +// it returns 0 if error occurs. +func (k *Key) MustUint64(defaultVal ...uint64) uint64 { + val, err := k.Uint64() + if len(defaultVal) > 0 && err != nil { + return defaultVal[0] + } + return val +} + +// MustDuration always returns value without error, +// it returns zero value if error occurs. +func (k *Key) MustDuration(defaultVal ...time.Duration) time.Duration { + val, err := k.Duration() + if len(defaultVal) > 0 && err != nil { + return defaultVal[0] + } + return val +} + +// MustTimeFormat always parses with given format and returns value without error, +// it returns zero value if error occurs. +func (k *Key) MustTimeFormat(format string, defaultVal ...time.Time) time.Time { + val, err := k.TimeFormat(format) + if len(defaultVal) > 0 && err != nil { + return defaultVal[0] + } + return val +} + +// MustTime always parses with RFC3339 format and returns value without error, +// it returns zero value if error occurs. +func (k *Key) MustTime(defaultVal ...time.Time) time.Time { + return k.MustTimeFormat(time.RFC3339, defaultVal...) +} + +// In always returns value without error, +// it returns default value if error occurs or doesn't fit into candidates. +func (k *Key) In(defaultVal string, candidates []string) string { + val := k.String() + for _, cand := range candidates { + if val == cand { + return val + } + } + return defaultVal +} + +// InFloat64 always returns value without error, +// it returns default value if error occurs or doesn't fit into candidates. +func (k *Key) InFloat64(defaultVal float64, candidates []float64) float64 { + val := k.MustFloat64() + for _, cand := range candidates { + if val == cand { + return val + } + } + return defaultVal +} + +// InInt always returns value without error, +// it returns default value if error occurs or doesn't fit into candidates. +func (k *Key) InInt(defaultVal int, candidates []int) int { + val := k.MustInt() + for _, cand := range candidates { + if val == cand { + return val + } + } + return defaultVal +} + +// InInt64 always returns value without error, +// it returns default value if error occurs or doesn't fit into candidates. +func (k *Key) InInt64(defaultVal int64, candidates []int64) int64 { + val := k.MustInt64() + for _, cand := range candidates { + if val == cand { + return val + } + } + return defaultVal +} + +// InUint always returns value without error, +// it returns default value if error occurs or doesn't fit into candidates. +func (k *Key) InUint(defaultVal uint, candidates []uint) uint { + val := k.MustUint() + for _, cand := range candidates { + if val == cand { + return val + } + } + return defaultVal +} + +// InUint64 always returns value without error, +// it returns default value if error occurs or doesn't fit into candidates. +func (k *Key) InUint64(defaultVal uint64, candidates []uint64) uint64 { + val := k.MustUint64() + for _, cand := range candidates { + if val == cand { + return val + } + } + return defaultVal +} + +// InTimeFormat always parses with given format and returns value without error, +// it returns default value if error occurs or doesn't fit into candidates. +func (k *Key) InTimeFormat(format string, defaultVal time.Time, candidates []time.Time) time.Time { + val := k.MustTimeFormat(format) + for _, cand := range candidates { + if val == cand { + return val + } + } + return defaultVal +} + +// InTime always parses with RFC3339 format and returns value without error, +// it returns default value if error occurs or doesn't fit into candidates. +func (k *Key) InTime(defaultVal time.Time, candidates []time.Time) time.Time { + return k.InTimeFormat(time.RFC3339, defaultVal, candidates) +} + +// RangeFloat64 checks if value is in given range inclusively, +// and returns default value if it's not. +func (k *Key) RangeFloat64(defaultVal, min, max float64) float64 { + val := k.MustFloat64() + if val < min || val > max { + return defaultVal + } + return val +} + +// RangeInt checks if value is in given range inclusively, +// and returns default value if it's not. +func (k *Key) RangeInt(defaultVal, min, max int) int { + val := k.MustInt() + if val < min || val > max { + return defaultVal + } + return val +} + +// RangeInt64 checks if value is in given range inclusively, +// and returns default value if it's not. +func (k *Key) RangeInt64(defaultVal, min, max int64) int64 { + val := k.MustInt64() + if val < min || val > max { + return defaultVal + } + return val +} + +// RangeTimeFormat checks if value with given format is in given range inclusively, +// and returns default value if it's not. +func (k *Key) RangeTimeFormat(format string, defaultVal, min, max time.Time) time.Time { + val := k.MustTimeFormat(format) + if val.Unix() < min.Unix() || val.Unix() > max.Unix() { + return defaultVal + } + return val +} + +// RangeTime checks if value with RFC3339 format is in given range inclusively, +// and returns default value if it's not. +func (k *Key) RangeTime(defaultVal, min, max time.Time) time.Time { + return k.RangeTimeFormat(time.RFC3339, defaultVal, min, max) +} + +// Strings returns list of string divided by given delimiter. +func (k *Key) Strings(delim string) []string { + str := k.String() + if len(str) == 0 { + return []string{} + } + + vals := strings.Split(str, delim) + for i := range vals { + vals[i] = strings.TrimSpace(vals[i]) + } + return vals +} + +// Float64s returns list of float64 divided by given delimiter. Any invalid input will be treated as zero value. +func (k *Key) Float64s(delim string) []float64 { + vals, _ := k.getFloat64s(delim, true, false) + return vals +} + +// Ints returns list of int divided by given delimiter. Any invalid input will be treated as zero value. +func (k *Key) Ints(delim string) []int { + vals, _ := k.getInts(delim, true, false) + return vals +} + +// Int64s returns list of int64 divided by given delimiter. Any invalid input will be treated as zero value. +func (k *Key) Int64s(delim string) []int64 { + vals, _ := k.getInt64s(delim, true, false) + return vals +} + +// Uints returns list of uint divided by given delimiter. Any invalid input will be treated as zero value. +func (k *Key) Uints(delim string) []uint { + vals, _ := k.getUints(delim, true, false) + return vals +} + +// Uint64s returns list of uint64 divided by given delimiter. Any invalid input will be treated as zero value. +func (k *Key) Uint64s(delim string) []uint64 { + vals, _ := k.getUint64s(delim, true, false) + return vals +} + +// TimesFormat parses with given format and returns list of time.Time divided by given delimiter. +// Any invalid input will be treated as zero value (0001-01-01 00:00:00 +0000 UTC). +func (k *Key) TimesFormat(format, delim string) []time.Time { + vals, _ := k.getTimesFormat(format, delim, true, false) + return vals +} + +// Times parses with RFC3339 format and returns list of time.Time divided by given delimiter. +// Any invalid input will be treated as zero value (0001-01-01 00:00:00 +0000 UTC). +func (k *Key) Times(delim string) []time.Time { + return k.TimesFormat(time.RFC3339, delim) +} + +// ValidFloat64s returns list of float64 divided by given delimiter. If some value is not float, then +// it will not be included to result list. +func (k *Key) ValidFloat64s(delim string) []float64 { + vals, _ := k.getFloat64s(delim, false, false) + return vals +} + +// ValidInts returns list of int divided by given delimiter. If some value is not integer, then it will +// not be included to result list. +func (k *Key) ValidInts(delim string) []int { + vals, _ := k.getInts(delim, false, false) + return vals +} + +// ValidInt64s returns list of int64 divided by given delimiter. If some value is not 64-bit integer, +// then it will not be included to result list. +func (k *Key) ValidInt64s(delim string) []int64 { + vals, _ := k.getInt64s(delim, false, false) + return vals +} + +// ValidUints returns list of uint divided by given delimiter. If some value is not unsigned integer, +// then it will not be included to result list. +func (k *Key) ValidUints(delim string) []uint { + vals, _ := k.getUints(delim, false, false) + return vals +} + +// ValidUint64s returns list of uint64 divided by given delimiter. If some value is not 64-bit unsigned +// integer, then it will not be included to result list. +func (k *Key) ValidUint64s(delim string) []uint64 { + vals, _ := k.getUint64s(delim, false, false) + return vals +} + +// ValidTimesFormat parses with given format and returns list of time.Time divided by given delimiter. +func (k *Key) ValidTimesFormat(format, delim string) []time.Time { + vals, _ := k.getTimesFormat(format, delim, false, false) + return vals +} + +// ValidTimes parses with RFC3339 format and returns list of time.Time divided by given delimiter. +func (k *Key) ValidTimes(delim string) []time.Time { + return k.ValidTimesFormat(time.RFC3339, delim) +} + +// StrictFloat64s returns list of float64 divided by given delimiter or error on first invalid input. +func (k *Key) StrictFloat64s(delim string) ([]float64, error) { + return k.getFloat64s(delim, false, true) +} + +// StrictInts returns list of int divided by given delimiter or error on first invalid input. +func (k *Key) StrictInts(delim string) ([]int, error) { + return k.getInts(delim, false, true) +} + +// StrictInt64s returns list of int64 divided by given delimiter or error on first invalid input. +func (k *Key) StrictInt64s(delim string) ([]int64, error) { + return k.getInt64s(delim, false, true) +} + +// StrictUints returns list of uint divided by given delimiter or error on first invalid input. +func (k *Key) StrictUints(delim string) ([]uint, error) { + return k.getUints(delim, false, true) +} + +// StrictUint64s returns list of uint64 divided by given delimiter or error on first invalid input. +func (k *Key) StrictUint64s(delim string) ([]uint64, error) { + return k.getUint64s(delim, false, true) +} + +// StrictTimesFormat parses with given format and returns list of time.Time divided by given delimiter +// or error on first invalid input. +func (k *Key) StrictTimesFormat(format, delim string) ([]time.Time, error) { + return k.getTimesFormat(format, delim, false, true) +} + +// StrictTimes parses with RFC3339 format and returns list of time.Time divided by given delimiter +// or error on first invalid input. +func (k *Key) StrictTimes(delim string) ([]time.Time, error) { + return k.StrictTimesFormat(time.RFC3339, delim) +} + +// getFloat64s returns list of float64 divided by given delimiter. +func (k *Key) getFloat64s(delim string, addInvalid, returnOnInvalid bool) ([]float64, error) { + strs := k.Strings(delim) + vals := make([]float64, 0, len(strs)) + for _, str := range strs { + val, err := strconv.ParseFloat(str, 64) + if err != nil && returnOnInvalid { + return nil, err + } + if err == nil || addInvalid { + vals = append(vals, val) + } + } + return vals, nil +} + +// getInts returns list of int divided by given delimiter. +func (k *Key) getInts(delim string, addInvalid, returnOnInvalid bool) ([]int, error) { + strs := k.Strings(delim) + vals := make([]int, 0, len(strs)) + for _, str := range strs { + val, err := strconv.Atoi(str) + if err != nil && returnOnInvalid { + return nil, err + } + if err == nil || addInvalid { + vals = append(vals, val) + } + } + return vals, nil +} + +// getInt64s returns list of int64 divided by given delimiter. +func (k *Key) getInt64s(delim string, addInvalid, returnOnInvalid bool) ([]int64, error) { + strs := k.Strings(delim) + vals := make([]int64, 0, len(strs)) + for _, str := range strs { + val, err := strconv.ParseInt(str, 10, 64) + if err != nil && returnOnInvalid { + return nil, err + } + if err == nil || addInvalid { + vals = append(vals, val) + } + } + return vals, nil +} + +// getUints returns list of uint divided by given delimiter. +func (k *Key) getUints(delim string, addInvalid, returnOnInvalid bool) ([]uint, error) { + strs := k.Strings(delim) + vals := make([]uint, 0, len(strs)) + for _, str := range strs { + val, err := strconv.ParseUint(str, 10, 0) + if err != nil && returnOnInvalid { + return nil, err + } + if err == nil || addInvalid { + vals = append(vals, uint(val)) + } + } + return vals, nil +} + +// getUint64s returns list of uint64 divided by given delimiter. +func (k *Key) getUint64s(delim string, addInvalid, returnOnInvalid bool) ([]uint64, error) { + strs := k.Strings(delim) + vals := make([]uint64, 0, len(strs)) + for _, str := range strs { + val, err := strconv.ParseUint(str, 10, 64) + if err != nil && returnOnInvalid { + return nil, err + } + if err == nil || addInvalid { + vals = append(vals, val) + } + } + return vals, nil +} + +// getTimesFormat parses with given format and returns list of time.Time divided by given delimiter. +func (k *Key) getTimesFormat(format, delim string, addInvalid, returnOnInvalid bool) ([]time.Time, error) { + strs := k.Strings(delim) + vals := make([]time.Time, 0, len(strs)) + for _, str := range strs { + val, err := time.Parse(format, str) + if err != nil && returnOnInvalid { + return nil, err + } + if err == nil || addInvalid { + vals = append(vals, val) + } + } + return vals, nil +} + +// SetValue changes key value. +func (k *Key) SetValue(v string) { + if k.s.f.BlockMode { + k.s.f.lock.Lock() + defer k.s.f.lock.Unlock() + } + + k.value = v + k.s.keysHash[k.name] = v +} diff --git a/Godeps/_workspace/src/github.com/go-ini/ini/parser.go b/Godeps/_workspace/src/github.com/go-ini/ini/parser.go new file mode 100644 index 0000000000..1c1bf91f0e --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ini/ini/parser.go @@ -0,0 +1,312 @@ +// Copyright 2015 Unknwon +// +// Licensed under the Apache License, Version 2.0 (the "License"): you may +// not use this file except in compliance with the License. You may obtain +// a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations +// under the License. + +package ini + +import ( + "bufio" + "bytes" + "fmt" + "io" + "strconv" + "strings" + "unicode" +) + +type tokenType int + +const ( + _TOKEN_INVALID tokenType = iota + _TOKEN_COMMENT + _TOKEN_SECTION + _TOKEN_KEY +) + +type parser struct { + buf *bufio.Reader + isEOF bool + count int + comment *bytes.Buffer +} + +func newParser(r io.Reader) *parser { + return &parser{ + buf: bufio.NewReader(r), + count: 1, + comment: &bytes.Buffer{}, + } +} + +// BOM handles header of BOM-UTF8 format. +// http://en.wikipedia.org/wiki/Byte_order_mark#Representations_of_byte_order_marks_by_encoding +func (p *parser) BOM() error { + mask, err := p.buf.Peek(3) + if err != nil && err != io.EOF { + return err + } else if len(mask) < 3 { + return nil + } else if mask[0] == 239 && mask[1] == 187 && mask[2] == 191 { + p.buf.Read(mask) + } + return nil +} + +func (p *parser) readUntil(delim byte) ([]byte, error) { + data, err := p.buf.ReadBytes(delim) + if err != nil { + if err == io.EOF { + p.isEOF = true + } else { + return nil, err + } + } + return data, nil +} + +func cleanComment(in []byte) ([]byte, bool) { + i := bytes.IndexAny(in, "#;") + if i == -1 { + return nil, false + } + return in[i:], true +} + +func readKeyName(in []byte) (string, int, error) { + line := string(in) + + // Check if key name surrounded by quotes. + var keyQuote string + if line[0] == '"' { + if len(line) > 6 && string(line[0:3]) == `"""` { + keyQuote = `"""` + } else { + keyQuote = `"` + } + } else if line[0] == '`' { + keyQuote = "`" + } + + // Get out key name + endIdx := -1 + if len(keyQuote) > 0 { + startIdx := len(keyQuote) + // FIXME: fail case -> """"""name"""=value + pos := strings.Index(line[startIdx:], keyQuote) + if pos == -1 { + return "", -1, fmt.Errorf("missing closing key quote: %s", line) + } + pos += startIdx + + // Find key-value delimiter + i := strings.IndexAny(line[pos+startIdx:], "=:") + if i < 0 { + return "", -1, fmt.Errorf("key-value delimiter not found: %s", line) + } + endIdx = pos + i + return strings.TrimSpace(line[startIdx:pos]), endIdx + startIdx + 1, nil + } + + endIdx = strings.IndexAny(line, "=:") + if endIdx < 0 { + return "", -1, fmt.Errorf("key-value delimiter not found: %s", line) + } + return strings.TrimSpace(line[0:endIdx]), endIdx + 1, nil +} + +func (p *parser) readMultilines(line, val, valQuote string) (string, error) { + for { + data, err := p.readUntil('\n') + if err != nil { + return "", err + } + next := string(data) + + pos := strings.LastIndex(next, valQuote) + if pos > -1 { + val += next[:pos] + + comment, has := cleanComment([]byte(next[pos:])) + if has { + p.comment.Write(bytes.TrimSpace(comment)) + } + break + } + val += next + if p.isEOF { + return "", fmt.Errorf("missing closing key quote from '%s' to '%s'", line, next) + } + } + return val, nil +} + +func (p *parser) readContinuationLines(val string) (string, error) { + for { + data, err := p.readUntil('\n') + if err != nil { + return "", err + } + next := strings.TrimSpace(string(data)) + + if len(next) == 0 { + break + } + val += next + if val[len(val)-1] != '\\' { + break + } + val = val[:len(val)-1] + } + return val, nil +} + +// hasSurroundedQuote check if and only if the first and last characters +// are quotes \" or \'. +// It returns false if any other parts also contain same kind of quotes. +func hasSurroundedQuote(in string, quote byte) bool { + return len(in) > 2 && in[0] == quote && in[len(in)-1] == quote && + strings.IndexByte(in[1:], quote) == len(in)-2 +} + +func (p *parser) readValue(in []byte) (string, error) { + line := strings.TrimLeftFunc(string(in), unicode.IsSpace) + if len(line) == 0 { + return "", nil + } + + var valQuote string + if len(line) > 3 && string(line[0:3]) == `"""` { + valQuote = `"""` + } else if line[0] == '`' { + valQuote = "`" + } + + if len(valQuote) > 0 { + startIdx := len(valQuote) + pos := strings.LastIndex(line[startIdx:], valQuote) + // Check for multi-line value + if pos == -1 { + return p.readMultilines(line, line[startIdx:], valQuote) + } + + return line[startIdx : pos+startIdx], nil + } + + // Won't be able to reach here if value only contains whitespace. + line = strings.TrimSpace(line) + + // Check continuation lines + if line[len(line)-1] == '\\' { + return p.readContinuationLines(line[:len(line)-1]) + } + + i := strings.IndexAny(line, "#;") + if i > -1 { + p.comment.WriteString(line[i:]) + line = strings.TrimSpace(line[:i]) + } + + // Trim single quotes + if hasSurroundedQuote(line, '\'') || + hasSurroundedQuote(line, '"') { + line = line[1 : len(line)-1] + } + return line, nil +} + +// parse parses data through an io.Reader. +func (f *File) parse(reader io.Reader) (err error) { + p := newParser(reader) + if err = p.BOM(); err != nil { + return fmt.Errorf("BOM: %v", err) + } + + // Ignore error because default section name is never empty string. + section, _ := f.NewSection(DEFAULT_SECTION) + + var line []byte + for !p.isEOF { + line, err = p.readUntil('\n') + if err != nil { + return err + } + + line = bytes.TrimLeftFunc(line, unicode.IsSpace) + if len(line) == 0 { + continue + } + + // Comments + if line[0] == '#' || line[0] == ';' { + // Note: we do not care ending line break, + // it is needed for adding second line, + // so just clean it once at the end when set to value. + p.comment.Write(line) + continue + } + + // Section + if line[0] == '[' { + // Read to the next ']' (TODO: support quoted strings) + closeIdx := bytes.IndexByte(line, ']') + if closeIdx == -1 { + return fmt.Errorf("unclosed section: %s", line) + } + + section, err = f.NewSection(string(line[1:closeIdx])) + if err != nil { + return err + } + + comment, has := cleanComment(line[closeIdx+1:]) + if has { + p.comment.Write(comment) + } + + section.Comment = strings.TrimSpace(p.comment.String()) + + // Reset aotu-counter and comments + p.comment.Reset() + p.count = 1 + continue + } + + kname, offset, err := readKeyName(line) + if err != nil { + return err + } + + // Auto increment. + isAutoIncr := false + if kname == "-" { + isAutoIncr = true + kname = "#" + strconv.Itoa(p.count) + p.count++ + } + + key, err := section.NewKey(kname, "") + if err != nil { + return err + } + key.isAutoIncr = isAutoIncr + + value, err := p.readValue(line[offset:]) + if err != nil { + return err + } + key.SetValue(value) + key.Comment = strings.TrimSpace(p.comment.String()) + p.comment.Reset() + } + return nil +} diff --git a/Godeps/_workspace/src/github.com/go-ini/ini/section.go b/Godeps/_workspace/src/github.com/go-ini/ini/section.go new file mode 100644 index 0000000000..ed8cbdb54a --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ini/ini/section.go @@ -0,0 +1,177 @@ +// Copyright 2014 Unknwon +// +// Licensed under the Apache License, Version 2.0 (the "License"): you may +// not use this file except in compliance with the License. You may obtain +// a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations +// under the License. + +package ini + +import ( + "errors" + "fmt" + "strings" +) + +// Section represents a config section. +type Section struct { + f *File + Comment string + name string + keys map[string]*Key + keyList []string + keysHash map[string]string +} + +func newSection(f *File, name string) *Section { + return &Section{f, "", name, make(map[string]*Key), make([]string, 0, 10), make(map[string]string)} +} + +// Name returns name of Section. +func (s *Section) Name() string { + return s.name +} + +// NewKey creates a new key to given section. +func (s *Section) NewKey(name, val string) (*Key, error) { + if len(name) == 0 { + return nil, errors.New("error creating new key: empty key name") + } + + if s.f.BlockMode { + s.f.lock.Lock() + defer s.f.lock.Unlock() + } + + if inSlice(name, s.keyList) { + s.keys[name].value = val + return s.keys[name], nil + } + + s.keyList = append(s.keyList, name) + s.keys[name] = &Key{s, "", name, val, false} + s.keysHash[name] = val + return s.keys[name], nil +} + +// GetKey returns key in section by given name. +func (s *Section) GetKey(name string) (*Key, error) { + // FIXME: change to section level lock? + if s.f.BlockMode { + s.f.lock.RLock() + } + key := s.keys[name] + if s.f.BlockMode { + s.f.lock.RUnlock() + } + + if key == nil { + // Check if it is a child-section. + sname := s.name + for { + if i := strings.LastIndex(sname, "."); i > -1 { + sname = sname[:i] + sec, err := s.f.GetSection(sname) + if err != nil { + continue + } + return sec.GetKey(name) + } else { + break + } + } + return nil, fmt.Errorf("error when getting key of section '%s': key '%s' not exists", s.name, name) + } + return key, nil +} + +// HasKey returns true if section contains a key with given name. +func (s *Section) HasKey(name string) bool { + key, _ := s.GetKey(name) + return key != nil +} + +// Haskey is a backwards-compatible name for HasKey. +func (s *Section) Haskey(name string) bool { + return s.HasKey(name) +} + +// HasValue returns true if section contains given raw value. +func (s *Section) HasValue(value string) bool { + if s.f.BlockMode { + s.f.lock.RLock() + defer s.f.lock.RUnlock() + } + + for _, k := range s.keys { + if value == k.value { + return true + } + } + return false +} + +// Key assumes named Key exists in section and returns a zero-value when not. +func (s *Section) Key(name string) *Key { + key, err := s.GetKey(name) + if err != nil { + // It's OK here because the only possible error is empty key name, + // but if it's empty, this piece of code won't be executed. + key, _ = s.NewKey(name, "") + return key + } + return key +} + +// Keys returns list of keys of section. +func (s *Section) Keys() []*Key { + keys := make([]*Key, len(s.keyList)) + for i := range s.keyList { + keys[i] = s.Key(s.keyList[i]) + } + return keys +} + +// KeyStrings returns list of key names of section. +func (s *Section) KeyStrings() []string { + list := make([]string, len(s.keyList)) + copy(list, s.keyList) + return list +} + +// KeysHash returns keys hash consisting of names and values. +func (s *Section) KeysHash() map[string]string { + if s.f.BlockMode { + s.f.lock.RLock() + defer s.f.lock.RUnlock() + } + + hash := map[string]string{} + for key, value := range s.keysHash { + hash[key] = value + } + return hash +} + +// DeleteKey deletes a key from section. +func (s *Section) DeleteKey(name string) { + if s.f.BlockMode { + s.f.lock.Lock() + defer s.f.lock.Unlock() + } + + for i, k := range s.keyList { + if k == name { + s.keyList = append(s.keyList[:i], s.keyList[i+1:]...) + delete(s.keys, name) + return + } + } +} diff --git a/Godeps/_workspace/src/github.com/go-ini/ini/struct.go b/Godeps/_workspace/src/github.com/go-ini/ini/struct.go new file mode 100644 index 0000000000..3fb92c3962 --- /dev/null +++ b/Godeps/_workspace/src/github.com/go-ini/ini/struct.go @@ -0,0 +1,351 @@ +// Copyright 2014 Unknwon +// +// Licensed under the Apache License, Version 2.0 (the "License"): you may +// not use this file except in compliance with the License. You may obtain +// a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations +// under the License. + +package ini + +import ( + "bytes" + "errors" + "fmt" + "reflect" + "time" + "unicode" +) + +// NameMapper represents a ini tag name mapper. +type NameMapper func(string) string + +// Built-in name getters. +var ( + // AllCapsUnderscore converts to format ALL_CAPS_UNDERSCORE. + AllCapsUnderscore NameMapper = func(raw string) string { + newstr := make([]rune, 0, len(raw)) + for i, chr := range raw { + if isUpper := 'A' <= chr && chr <= 'Z'; isUpper { + if i > 0 { + newstr = append(newstr, '_') + } + } + newstr = append(newstr, unicode.ToUpper(chr)) + } + return string(newstr) + } + // TitleUnderscore converts to format title_underscore. + TitleUnderscore NameMapper = func(raw string) string { + newstr := make([]rune, 0, len(raw)) + for i, chr := range raw { + if isUpper := 'A' <= chr && chr <= 'Z'; isUpper { + if i > 0 { + newstr = append(newstr, '_') + } + chr -= ('A' - 'a') + } + newstr = append(newstr, chr) + } + return string(newstr) + } +) + +func (s *Section) parseFieldName(raw, actual string) string { + if len(actual) > 0 { + return actual + } + if s.f.NameMapper != nil { + return s.f.NameMapper(raw) + } + return raw +} + +func parseDelim(actual string) string { + if len(actual) > 0 { + return actual + } + return "," +} + +var reflectTime = reflect.TypeOf(time.Now()).Kind() + +// setWithProperType sets proper value to field based on its type, +// but it does not return error for failing parsing, +// because we want to use default value that is already assigned to strcut. +func setWithProperType(t reflect.Type, key *Key, field reflect.Value, delim string) error { + switch t.Kind() { + case reflect.String: + if len(key.String()) == 0 { + return nil + } + field.SetString(key.String()) + case reflect.Bool: + boolVal, err := key.Bool() + if err != nil { + return nil + } + field.SetBool(boolVal) + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + durationVal, err := key.Duration() + // Skip zero value + if err == nil && int(durationVal) > 0 { + field.Set(reflect.ValueOf(durationVal)) + return nil + } + + intVal, err := key.Int64() + if err != nil || intVal == 0 { + return nil + } + field.SetInt(intVal) + // byte is an alias for uint8, so supporting uint8 breaks support for byte + case reflect.Uint, reflect.Uint16, reflect.Uint32, reflect.Uint64: + durationVal, err := key.Duration() + if err == nil { + field.Set(reflect.ValueOf(durationVal)) + return nil + } + + uintVal, err := key.Uint64() + if err != nil { + return nil + } + field.SetUint(uintVal) + + case reflect.Float64: + floatVal, err := key.Float64() + if err != nil { + return nil + } + field.SetFloat(floatVal) + case reflectTime: + timeVal, err := key.Time() + if err != nil { + return nil + } + field.Set(reflect.ValueOf(timeVal)) + case reflect.Slice: + vals := key.Strings(delim) + numVals := len(vals) + if numVals == 0 { + return nil + } + + sliceOf := field.Type().Elem().Kind() + + var times []time.Time + if sliceOf == reflectTime { + times = key.Times(delim) + } + + slice := reflect.MakeSlice(field.Type(), numVals, numVals) + for i := 0; i < numVals; i++ { + switch sliceOf { + case reflectTime: + slice.Index(i).Set(reflect.ValueOf(times[i])) + default: + slice.Index(i).Set(reflect.ValueOf(vals[i])) + } + } + field.Set(slice) + default: + return fmt.Errorf("unsupported type '%s'", t) + } + return nil +} + +func (s *Section) mapTo(val reflect.Value) error { + if val.Kind() == reflect.Ptr { + val = val.Elem() + } + typ := val.Type() + + for i := 0; i < typ.NumField(); i++ { + field := val.Field(i) + tpField := typ.Field(i) + + tag := tpField.Tag.Get("ini") + if tag == "-" { + continue + } + + fieldName := s.parseFieldName(tpField.Name, tag) + if len(fieldName) == 0 || !field.CanSet() { + continue + } + + isAnonymous := tpField.Type.Kind() == reflect.Ptr && tpField.Anonymous + isStruct := tpField.Type.Kind() == reflect.Struct + if isAnonymous { + field.Set(reflect.New(tpField.Type.Elem())) + } + + if isAnonymous || isStruct { + if sec, err := s.f.GetSection(fieldName); err == nil { + if err = sec.mapTo(field); err != nil { + return fmt.Errorf("error mapping field(%s): %v", fieldName, err) + } + continue + } + } + + if key, err := s.GetKey(fieldName); err == nil { + if err = setWithProperType(tpField.Type, key, field, parseDelim(tpField.Tag.Get("delim"))); err != nil { + return fmt.Errorf("error mapping field(%s): %v", fieldName, err) + } + } + } + return nil +} + +// MapTo maps section to given struct. +func (s *Section) MapTo(v interface{}) error { + typ := reflect.TypeOf(v) + val := reflect.ValueOf(v) + if typ.Kind() == reflect.Ptr { + typ = typ.Elem() + val = val.Elem() + } else { + return errors.New("cannot map to non-pointer struct") + } + + return s.mapTo(val) +} + +// MapTo maps file to given struct. +func (f *File) MapTo(v interface{}) error { + return f.Section("").MapTo(v) +} + +// MapTo maps data sources to given struct with name mapper. +func MapToWithMapper(v interface{}, mapper NameMapper, source interface{}, others ...interface{}) error { + cfg, err := Load(source, others...) + if err != nil { + return err + } + cfg.NameMapper = mapper + return cfg.MapTo(v) +} + +// MapTo maps data sources to given struct. +func MapTo(v, source interface{}, others ...interface{}) error { + return MapToWithMapper(v, nil, source, others...) +} + +// reflectWithProperType does the opposite thing with setWithProperType. +func reflectWithProperType(t reflect.Type, key *Key, field reflect.Value, delim string) error { + switch t.Kind() { + case reflect.String: + key.SetValue(field.String()) + case reflect.Bool, + reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, + reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, + reflect.Float64, + reflectTime: + key.SetValue(fmt.Sprint(field)) + case reflect.Slice: + vals := field.Slice(0, field.Len()) + if field.Len() == 0 { + return nil + } + + var buf bytes.Buffer + isTime := fmt.Sprint(field.Type()) == "[]time.Time" + for i := 0; i < field.Len(); i++ { + if isTime { + buf.WriteString(vals.Index(i).Interface().(time.Time).Format(time.RFC3339)) + } else { + buf.WriteString(fmt.Sprint(vals.Index(i))) + } + buf.WriteString(delim) + } + key.SetValue(buf.String()[:buf.Len()-1]) + default: + return fmt.Errorf("unsupported type '%s'", t) + } + return nil +} + +func (s *Section) reflectFrom(val reflect.Value) error { + if val.Kind() == reflect.Ptr { + val = val.Elem() + } + typ := val.Type() + + for i := 0; i < typ.NumField(); i++ { + field := val.Field(i) + tpField := typ.Field(i) + + tag := tpField.Tag.Get("ini") + if tag == "-" { + continue + } + + fieldName := s.parseFieldName(tpField.Name, tag) + if len(fieldName) == 0 || !field.CanSet() { + continue + } + + if (tpField.Type.Kind() == reflect.Ptr && tpField.Anonymous) || + (tpField.Type.Kind() == reflect.Struct) { + // Note: The only error here is section doesn't exist. + sec, err := s.f.GetSection(fieldName) + if err != nil { + // Note: fieldName can never be empty here, ignore error. + sec, _ = s.f.NewSection(fieldName) + } + if err = sec.reflectFrom(field); err != nil { + return fmt.Errorf("error reflecting field(%s): %v", fieldName, err) + } + continue + } + + // Note: Same reason as secion. + key, err := s.GetKey(fieldName) + if err != nil { + key, _ = s.NewKey(fieldName, "") + } + if err = reflectWithProperType(tpField.Type, key, field, parseDelim(tpField.Tag.Get("delim"))); err != nil { + return fmt.Errorf("error reflecting field(%s): %v", fieldName, err) + } + + } + return nil +} + +// ReflectFrom reflects secion from given struct. +func (s *Section) ReflectFrom(v interface{}) error { + typ := reflect.TypeOf(v) + val := reflect.ValueOf(v) + if typ.Kind() == reflect.Ptr { + typ = typ.Elem() + val = val.Elem() + } else { + return errors.New("cannot reflect from non-pointer struct") + } + + return s.reflectFrom(val) +} + +// ReflectFrom reflects file from given struct. +func (f *File) ReflectFrom(v interface{}) error { + return f.Section("").ReflectFrom(v) +} + +// ReflectFrom reflects data sources from given struct with name mapper. +func ReflectFromWithMapper(cfg *File, v interface{}, mapper NameMapper) error { + cfg.NameMapper = mapper + return cfg.ReflectFrom(v) +} + +// ReflectFrom reflects data sources from given struct. +func ReflectFrom(cfg *File, v interface{}) error { + return ReflectFromWithMapper(cfg, v, nil) +} diff --git a/Godeps/_workspace/src/github.com/gopherjs/gopherjs/LICENSE b/Godeps/_workspace/src/github.com/gopherjs/gopherjs/LICENSE new file mode 100644 index 0000000000..d496fef109 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gopherjs/gopherjs/LICENSE @@ -0,0 +1,24 @@ +Copyright (c) 2013 Richard Musiol. 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. + +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. diff --git a/Godeps/_workspace/src/github.com/gopherjs/gopherjs/js/js.go b/Godeps/_workspace/src/github.com/gopherjs/gopherjs/js/js.go new file mode 100644 index 0000000000..5367d3d0fa --- /dev/null +++ b/Godeps/_workspace/src/github.com/gopherjs/gopherjs/js/js.go @@ -0,0 +1,168 @@ +// Package js provides functions for interacting with native JavaScript APIs. Calls to these functions are treated specially by GopherJS and translated directly to their corresponding JavaScript syntax. +// +// Use MakeWrapper to expose methods to JavaScript. When passing values directly, the following type conversions are performed: +// +// | Go type | JavaScript type | Conversions back to interface{} | +// | --------------------- | --------------------- | ------------------------------- | +// | bool | Boolean | bool | +// | integers and floats | Number | float64 | +// | string | String | string | +// | []int8 | Int8Array | []int8 | +// | []int16 | Int16Array | []int16 | +// | []int32, []int | Int32Array | []int | +// | []uint8 | Uint8Array | []uint8 | +// | []uint16 | Uint16Array | []uint16 | +// | []uint32, []uint | Uint32Array | []uint | +// | []float32 | Float32Array | []float32 | +// | []float64 | Float64Array | []float64 | +// | all other slices | Array | []interface{} | +// | arrays | see slice type | see slice type | +// | functions | Function | func(...interface{}) *js.Object | +// | time.Time | Date | time.Time | +// | - | instanceof Node | *js.Object | +// | maps, structs | instanceof Object | map[string]interface{} | +// +// Additionally, for a struct containing a *js.Object field, only the content of the field will be passed to JavaScript and vice versa. +package js + +// Object is a container for a native JavaScript object. Calls to its methods are treated specially by GopherJS and translated directly to their JavaScript syntax. A nil pointer to Object is equal to JavaScript's "null". Object can not be used as a map key. +type Object struct{ object *Object } + +// Get returns the object's property with the given key. +func (o *Object) Get(key string) *Object { return o.object.Get(key) } + +// Set assigns the value to the object's property with the given key. +func (o *Object) Set(key string, value interface{}) { o.object.Set(key, value) } + +// Delete removes the object's property with the given key. +func (o *Object) Delete(key string) { o.object.Delete(key) } + +// Length returns the object's "length" property, converted to int. +func (o *Object) Length() int { return o.object.Length() } + +// Index returns the i'th element of an array. +func (o *Object) Index(i int) *Object { return o.object.Index(i) } + +// SetIndex sets the i'th element of an array. +func (o *Object) SetIndex(i int, value interface{}) { o.object.SetIndex(i, value) } + +// Call calls the object's method with the given name. +func (o *Object) Call(name string, args ...interface{}) *Object { return o.object.Call(name, args...) } + +// Invoke calls the object itself. This will fail if it is not a function. +func (o *Object) Invoke(args ...interface{}) *Object { return o.object.Invoke(args...) } + +// New creates a new instance of this type object. This will fail if it not a function (constructor). +func (o *Object) New(args ...interface{}) *Object { return o.object.New(args...) } + +// Bool returns the object converted to bool according to JavaScript type conversions. +func (o *Object) Bool() bool { return o.object.Bool() } + +// String returns the object converted to string according to JavaScript type conversions. +func (o *Object) String() string { return o.object.String() } + +// Int returns the object converted to int according to JavaScript type conversions (parseInt). +func (o *Object) Int() int { return o.object.Int() } + +// Int64 returns the object converted to int64 according to JavaScript type conversions (parseInt). +func (o *Object) Int64() int64 { return o.object.Int64() } + +// Uint64 returns the object converted to uint64 according to JavaScript type conversions (parseInt). +func (o *Object) Uint64() uint64 { return o.object.Uint64() } + +// Float returns the object converted to float64 according to JavaScript type conversions (parseFloat). +func (o *Object) Float() float64 { return o.object.Float() } + +// Interface returns the object converted to interface{}. See GopherJS' README for details. +func (o *Object) Interface() interface{} { return o.object.Interface() } + +// Unsafe returns the object as an uintptr, which can be converted via unsafe.Pointer. Not intended for public use. +func (o *Object) Unsafe() uintptr { return o.object.Unsafe() } + +// Error encapsulates JavaScript errors. Those are turned into a Go panic and may be recovered, giving an *Error that holds the JavaScript error object. +type Error struct { + *Object +} + +// Error returns the message of the encapsulated JavaScript error object. +func (err *Error) Error() string { + return "JavaScript error: " + err.Get("message").String() +} + +// Stack returns the stack property of the encapsulated JavaScript error object. +func (err *Error) Stack() string { + return err.Get("stack").String() +} + +// Global gives JavaScript's global object ("window" for browsers and "GLOBAL" for Node.js). +var Global *Object + +// Module gives the value of the "module" variable set by Node.js. Hint: Set a module export with 'js.Module.Get("exports").Set("exportName", ...)'. +var Module *Object + +// Undefined gives the JavaScript value "undefined". +var Undefined *Object + +// Debugger gets compiled to JavaScript's "debugger;" statement. +func Debugger() {} + +// InternalObject returns the internal JavaScript object that represents i. Not intended for public use. +func InternalObject(i interface{}) *Object { + return nil +} + +// MakeFunc wraps a function and gives access to the values of JavaScript's "this" and "arguments" keywords. +func MakeFunc(func(this *Object, arguments []*Object) interface{}) *Object { + return nil +} + +// Keys returns the keys of the given JavaScript object. +func Keys(o *Object) []string { + if o == nil || o == Undefined { + return nil + } + a := Global.Get("Object").Call("keys", o) + s := make([]string, a.Length()) + for i := 0; i < a.Length(); i++ { + s[i] = a.Index(i).String() + } + return s +} + +// MakeWrapper creates a JavaScript object which has wrappers for the exported methods of i. Use explicit getter and setter methods to expose struct fields to JavaScript. +func MakeWrapper(i interface{}) *Object { + v := InternalObject(i) + o := Global.Get("Object").New() + o.Set("__internal_object__", v) + methods := v.Get("constructor").Get("methods") + for i := 0; i < methods.Length(); i++ { + m := methods.Index(i) + if m.Get("pkg").String() != "" { // not exported + continue + } + o.Set(m.Get("name").String(), func(args ...*Object) *Object { + return Global.Call("$externalizeFunction", v.Get(m.Get("prop").String()), m.Get("typ"), true).Call("apply", v, args) + }) + } + return o +} + +// NewArrayBuffer creates a JavaScript ArrayBuffer from a byte slice. +func NewArrayBuffer(b []byte) *Object { + slice := InternalObject(b) + offset := slice.Get("$offset").Int() + length := slice.Get("$length").Int() + return slice.Get("$array").Get("buffer").Call("slice", offset, offset+length) +} + +// M is a simple map type. It is intended as a shorthand for JavaScript objects (before conversion). +type M map[string]interface{} + +// S is a simple slice type. It is intended as a shorthand for JavaScript arrays (before conversion). +type S []interface{} + +func init() { + // avoid dead code elimination + e := Error{} + _ = e +} diff --git a/Godeps/_workspace/src/github.com/jmespath/go-jmespath/.gitignore b/Godeps/_workspace/src/github.com/jmespath/go-jmespath/.gitignore new file mode 100644 index 0000000000..531fcc11c7 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jmespath/go-jmespath/.gitignore @@ -0,0 +1,4 @@ +jpgo +jmespath-fuzz.zip +cpu.out +go-jmespath.test diff --git a/Godeps/_workspace/src/github.com/jmespath/go-jmespath/.travis.yml b/Godeps/_workspace/src/github.com/jmespath/go-jmespath/.travis.yml new file mode 100644 index 0000000000..1f98077570 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jmespath/go-jmespath/.travis.yml @@ -0,0 +1,9 @@ +language: go + +sudo: false + +go: + - 1.4 + +install: go get -v -t ./... +script: make test diff --git a/Godeps/_workspace/src/github.com/jmespath/go-jmespath/LICENSE b/Godeps/_workspace/src/github.com/jmespath/go-jmespath/LICENSE new file mode 100644 index 0000000000..b03310a91f --- /dev/null +++ b/Godeps/_workspace/src/github.com/jmespath/go-jmespath/LICENSE @@ -0,0 +1,13 @@ +Copyright 2015 James Saryerwinnie + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/Godeps/_workspace/src/github.com/jmespath/go-jmespath/Makefile b/Godeps/_workspace/src/github.com/jmespath/go-jmespath/Makefile new file mode 100644 index 0000000000..a828d2848f --- /dev/null +++ b/Godeps/_workspace/src/github.com/jmespath/go-jmespath/Makefile @@ -0,0 +1,44 @@ + +CMD = jpgo + +help: + @echo "Please use \`make ' where is one of" + @echo " test to run all the tests" + @echo " build to build the library and jp executable" + @echo " generate to run codegen" + + +generate: + go generate ./... + +build: + rm -f $(CMD) + go build ./... + rm -f cmd/$(CMD)/$(CMD) && cd cmd/$(CMD)/ && go build ./... + mv cmd/$(CMD)/$(CMD) . + +test: + go test -v ./... + +check: + go vet ./... + @echo "golint ./..." + @lint=`golint ./...`; \ + lint=`echo "$$lint" | grep -v "astnodetype_string.go" | grep -v "toktype_string.go"`; \ + echo "$$lint"; \ + if [ "$$lint" != "" ]; then exit 1; fi + +htmlc: + go test -coverprofile="/tmp/jpcov" && go tool cover -html="/tmp/jpcov" && unlink /tmp/jpcov + +buildfuzz: + go-fuzz-build github.com/jmespath/go-jmespath/fuzz + +fuzz: buildfuzz + go-fuzz -bin=./jmespath-fuzz.zip -workdir=fuzz/testdata + +bench: + go test -bench . -cpuprofile cpu.out + +pprof-cpu: + go tool pprof ./go-jmespath.test ./cpu.out diff --git a/Godeps/_workspace/src/github.com/jmespath/go-jmespath/README.md b/Godeps/_workspace/src/github.com/jmespath/go-jmespath/README.md new file mode 100644 index 0000000000..187ef676dc --- /dev/null +++ b/Godeps/_workspace/src/github.com/jmespath/go-jmespath/README.md @@ -0,0 +1,7 @@ +# go-jmespath - A JMESPath implementation in Go + +[![Build Status](https://img.shields.io/travis/jmespath/go-jmespath.svg)](https://travis-ci.org/jmespath/go-jmespath) + + + +See http://jmespath.org for more info. diff --git a/Godeps/_workspace/src/github.com/jmespath/go-jmespath/api.go b/Godeps/_workspace/src/github.com/jmespath/go-jmespath/api.go new file mode 100644 index 0000000000..9cfa988bc5 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jmespath/go-jmespath/api.go @@ -0,0 +1,49 @@ +package jmespath + +import "strconv" + +// JmesPath is the epresentation of a compiled JMES path query. A JmesPath is +// safe for concurrent use by multiple goroutines. +type JMESPath struct { + ast ASTNode + intr *treeInterpreter +} + +// Compile parses a JMESPath expression and returns, if successful, a JMESPath +// object that can be used to match against data. +func Compile(expression string) (*JMESPath, error) { + parser := NewParser() + ast, err := parser.Parse(expression) + if err != nil { + return nil, err + } + jmespath := &JMESPath{ast: ast, intr: newInterpreter()} + return jmespath, nil +} + +// MustCompile is like Compile but panics if the expression cannot be parsed. +// It simplifies safe initialization of global variables holding compiled +// JMESPaths. +func MustCompile(expression string) *JMESPath { + jmespath, err := Compile(expression) + if err != nil { + panic(`jmespath: Compile(` + strconv.Quote(expression) + `): ` + err.Error()) + } + return jmespath +} + +// Search evaluates a JMESPath expression against input data and returns the result. +func (jp *JMESPath) Search(data interface{}) (interface{}, error) { + return jp.intr.Execute(jp.ast, data) +} + +// Search evaluates a JMESPath expression against input data and returns the result. +func Search(expression string, data interface{}) (interface{}, error) { + intr := newInterpreter() + parser := NewParser() + ast, err := parser.Parse(expression) + if err != nil { + return nil, err + } + return intr.Execute(ast, data) +} diff --git a/Godeps/_workspace/src/github.com/jmespath/go-jmespath/astnodetype_string.go b/Godeps/_workspace/src/github.com/jmespath/go-jmespath/astnodetype_string.go new file mode 100644 index 0000000000..1cd2d239c9 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jmespath/go-jmespath/astnodetype_string.go @@ -0,0 +1,16 @@ +// generated by stringer -type astNodeType; DO NOT EDIT + +package jmespath + +import "fmt" + +const _astNodeType_name = "ASTEmptyASTComparatorASTCurrentNodeASTExpRefASTFunctionExpressionASTFieldASTFilterProjectionASTFlattenASTIdentityASTIndexASTIndexExpressionASTKeyValPairASTLiteralASTMultiSelectHashASTMultiSelectListASTOrExpressionASTAndExpressionASTNotExpressionASTPipeASTProjectionASTSubexpressionASTSliceASTValueProjection" + +var _astNodeType_index = [...]uint16{0, 8, 21, 35, 44, 65, 73, 92, 102, 113, 121, 139, 152, 162, 180, 198, 213, 229, 245, 252, 265, 281, 289, 307} + +func (i astNodeType) String() string { + if i < 0 || i >= astNodeType(len(_astNodeType_index)-1) { + return fmt.Sprintf("astNodeType(%d)", i) + } + return _astNodeType_name[_astNodeType_index[i]:_astNodeType_index[i+1]] +} diff --git a/Godeps/_workspace/src/github.com/jmespath/go-jmespath/functions.go b/Godeps/_workspace/src/github.com/jmespath/go-jmespath/functions.go new file mode 100644 index 0000000000..9b7cd89b4b --- /dev/null +++ b/Godeps/_workspace/src/github.com/jmespath/go-jmespath/functions.go @@ -0,0 +1,842 @@ +package jmespath + +import ( + "encoding/json" + "errors" + "fmt" + "math" + "reflect" + "sort" + "strconv" + "strings" + "unicode/utf8" +) + +type jpFunction func(arguments []interface{}) (interface{}, error) + +type jpType string + +const ( + jpUnknown jpType = "unknown" + jpNumber jpType = "number" + jpString jpType = "string" + jpArray jpType = "array" + jpObject jpType = "object" + jpArrayNumber jpType = "array[number]" + jpArrayString jpType = "array[string]" + jpExpref jpType = "expref" + jpAny jpType = "any" +) + +type functionEntry struct { + name string + arguments []argSpec + handler jpFunction + hasExpRef bool +} + +type argSpec struct { + types []jpType + variadic bool +} + +type byExprString struct { + intr *treeInterpreter + node ASTNode + items []interface{} + hasError bool +} + +func (a *byExprString) Len() int { + return len(a.items) +} +func (a *byExprString) Swap(i, j int) { + a.items[i], a.items[j] = a.items[j], a.items[i] +} +func (a *byExprString) Less(i, j int) bool { + first, err := a.intr.Execute(a.node, a.items[i]) + if err != nil { + a.hasError = true + // Return a dummy value. + return true + } + ith, ok := first.(string) + if !ok { + a.hasError = true + return true + } + second, err := a.intr.Execute(a.node, a.items[j]) + if err != nil { + a.hasError = true + // Return a dummy value. + return true + } + jth, ok := second.(string) + if !ok { + a.hasError = true + return true + } + return ith < jth +} + +type byExprFloat struct { + intr *treeInterpreter + node ASTNode + items []interface{} + hasError bool +} + +func (a *byExprFloat) Len() int { + return len(a.items) +} +func (a *byExprFloat) Swap(i, j int) { + a.items[i], a.items[j] = a.items[j], a.items[i] +} +func (a *byExprFloat) Less(i, j int) bool { + first, err := a.intr.Execute(a.node, a.items[i]) + if err != nil { + a.hasError = true + // Return a dummy value. + return true + } + ith, ok := first.(float64) + if !ok { + a.hasError = true + return true + } + second, err := a.intr.Execute(a.node, a.items[j]) + if err != nil { + a.hasError = true + // Return a dummy value. + return true + } + jth, ok := second.(float64) + if !ok { + a.hasError = true + return true + } + return ith < jth +} + +type functionCaller struct { + functionTable map[string]functionEntry +} + +func newFunctionCaller() *functionCaller { + caller := &functionCaller{} + caller.functionTable = map[string]functionEntry{ + "length": { + name: "length", + arguments: []argSpec{ + {types: []jpType{jpString, jpArray, jpObject}}, + }, + handler: jpfLength, + }, + "starts_with": { + name: "starts_with", + arguments: []argSpec{ + {types: []jpType{jpString}}, + {types: []jpType{jpString}}, + }, + handler: jpfStartsWith, + }, + "abs": { + name: "abs", + arguments: []argSpec{ + {types: []jpType{jpNumber}}, + }, + handler: jpfAbs, + }, + "avg": { + name: "avg", + arguments: []argSpec{ + {types: []jpType{jpArrayNumber}}, + }, + handler: jpfAvg, + }, + "ceil": { + name: "ceil", + arguments: []argSpec{ + {types: []jpType{jpNumber}}, + }, + handler: jpfCeil, + }, + "contains": { + name: "contains", + arguments: []argSpec{ + {types: []jpType{jpArray, jpString}}, + {types: []jpType{jpAny}}, + }, + handler: jpfContains, + }, + "ends_with": { + name: "ends_with", + arguments: []argSpec{ + {types: []jpType{jpString}}, + {types: []jpType{jpString}}, + }, + handler: jpfEndsWith, + }, + "floor": { + name: "floor", + arguments: []argSpec{ + {types: []jpType{jpNumber}}, + }, + handler: jpfFloor, + }, + "map": { + name: "amp", + arguments: []argSpec{ + {types: []jpType{jpExpref}}, + {types: []jpType{jpArray}}, + }, + handler: jpfMap, + hasExpRef: true, + }, + "max": { + name: "max", + arguments: []argSpec{ + {types: []jpType{jpArrayNumber, jpArrayString}}, + }, + handler: jpfMax, + }, + "merge": { + name: "merge", + arguments: []argSpec{ + {types: []jpType{jpObject}, variadic: true}, + }, + handler: jpfMerge, + }, + "max_by": { + name: "max_by", + arguments: []argSpec{ + {types: []jpType{jpArray}}, + {types: []jpType{jpExpref}}, + }, + handler: jpfMaxBy, + hasExpRef: true, + }, + "sum": { + name: "sum", + arguments: []argSpec{ + {types: []jpType{jpArrayNumber}}, + }, + handler: jpfSum, + }, + "min": { + name: "min", + arguments: []argSpec{ + {types: []jpType{jpArrayNumber, jpArrayString}}, + }, + handler: jpfMin, + }, + "min_by": { + name: "min_by", + arguments: []argSpec{ + {types: []jpType{jpArray}}, + {types: []jpType{jpExpref}}, + }, + handler: jpfMinBy, + hasExpRef: true, + }, + "type": { + name: "type", + arguments: []argSpec{ + {types: []jpType{jpAny}}, + }, + handler: jpfType, + }, + "keys": { + name: "keys", + arguments: []argSpec{ + {types: []jpType{jpObject}}, + }, + handler: jpfKeys, + }, + "values": { + name: "values", + arguments: []argSpec{ + {types: []jpType{jpObject}}, + }, + handler: jpfValues, + }, + "sort": { + name: "sort", + arguments: []argSpec{ + {types: []jpType{jpArrayString, jpArrayNumber}}, + }, + handler: jpfSort, + }, + "sort_by": { + name: "sort_by", + arguments: []argSpec{ + {types: []jpType{jpArray}}, + {types: []jpType{jpExpref}}, + }, + handler: jpfSortBy, + hasExpRef: true, + }, + "join": { + name: "join", + arguments: []argSpec{ + {types: []jpType{jpString}}, + {types: []jpType{jpArrayString}}, + }, + handler: jpfJoin, + }, + "reverse": { + name: "reverse", + arguments: []argSpec{ + {types: []jpType{jpArray, jpString}}, + }, + handler: jpfReverse, + }, + "to_array": { + name: "to_array", + arguments: []argSpec{ + {types: []jpType{jpAny}}, + }, + handler: jpfToArray, + }, + "to_string": { + name: "to_string", + arguments: []argSpec{ + {types: []jpType{jpAny}}, + }, + handler: jpfToString, + }, + "to_number": { + name: "to_number", + arguments: []argSpec{ + {types: []jpType{jpAny}}, + }, + handler: jpfToNumber, + }, + "not_null": { + name: "not_null", + arguments: []argSpec{ + {types: []jpType{jpAny}, variadic: true}, + }, + handler: jpfNotNull, + }, + } + return caller +} + +func (e *functionEntry) resolveArgs(arguments []interface{}) ([]interface{}, error) { + if len(e.arguments) == 0 { + return arguments, nil + } + if !e.arguments[len(e.arguments)-1].variadic { + if len(e.arguments) != len(arguments) { + return nil, errors.New("incorrect number of args") + } + for i, spec := range e.arguments { + userArg := arguments[i] + err := spec.typeCheck(userArg) + if err != nil { + return nil, err + } + } + return arguments, nil + } + if len(arguments) < len(e.arguments) { + return nil, errors.New("Invalid arity.") + } + return arguments, nil +} + +func (a *argSpec) typeCheck(arg interface{}) error { + for _, t := range a.types { + switch t { + case jpNumber: + if _, ok := arg.(float64); ok { + return nil + } + case jpString: + if _, ok := arg.(string); ok { + return nil + } + case jpArray: + if isSliceType(arg) { + return nil + } + case jpObject: + if _, ok := arg.(map[string]interface{}); ok { + return nil + } + case jpArrayNumber: + if _, ok := toArrayNum(arg); ok { + return nil + } + case jpArrayString: + if _, ok := toArrayStr(arg); ok { + return nil + } + case jpAny: + return nil + case jpExpref: + if _, ok := arg.(expRef); ok { + return nil + } + } + } + return fmt.Errorf("Invalid type for: %v, expected: %#v", arg, a.types) +} + +func (f *functionCaller) CallFunction(name string, arguments []interface{}, intr *treeInterpreter) (interface{}, error) { + entry, ok := f.functionTable[name] + if !ok { + return nil, errors.New("unknown function: " + name) + } + resolvedArgs, err := entry.resolveArgs(arguments) + if err != nil { + return nil, err + } + if entry.hasExpRef { + var extra []interface{} + extra = append(extra, intr) + resolvedArgs = append(extra, resolvedArgs...) + } + return entry.handler(resolvedArgs) +} + +func jpfAbs(arguments []interface{}) (interface{}, error) { + num := arguments[0].(float64) + return math.Abs(num), nil +} + +func jpfLength(arguments []interface{}) (interface{}, error) { + arg := arguments[0] + if c, ok := arg.(string); ok { + return float64(utf8.RuneCountInString(c)), nil + } else if isSliceType(arg) { + v := reflect.ValueOf(arg) + return float64(v.Len()), nil + } else if c, ok := arg.(map[string]interface{}); ok { + return float64(len(c)), nil + } + return nil, errors.New("could not compute length()") +} + +func jpfStartsWith(arguments []interface{}) (interface{}, error) { + search := arguments[0].(string) + prefix := arguments[1].(string) + return strings.HasPrefix(search, prefix), nil +} + +func jpfAvg(arguments []interface{}) (interface{}, error) { + // We've already type checked the value so we can safely use + // type assertions. + args := arguments[0].([]interface{}) + length := float64(len(args)) + numerator := 0.0 + for _, n := range args { + numerator += n.(float64) + } + return numerator / length, nil +} +func jpfCeil(arguments []interface{}) (interface{}, error) { + val := arguments[0].(float64) + return math.Ceil(val), nil +} +func jpfContains(arguments []interface{}) (interface{}, error) { + search := arguments[0] + el := arguments[1] + if searchStr, ok := search.(string); ok { + if elStr, ok := el.(string); ok { + return strings.Index(searchStr, elStr) != -1, nil + } + return false, nil + } + // Otherwise this is a generic contains for []interface{} + general := search.([]interface{}) + for _, item := range general { + if item == el { + return true, nil + } + } + return false, nil +} +func jpfEndsWith(arguments []interface{}) (interface{}, error) { + search := arguments[0].(string) + suffix := arguments[1].(string) + return strings.HasSuffix(search, suffix), nil +} +func jpfFloor(arguments []interface{}) (interface{}, error) { + val := arguments[0].(float64) + return math.Floor(val), nil +} +func jpfMap(arguments []interface{}) (interface{}, error) { + intr := arguments[0].(*treeInterpreter) + exp := arguments[1].(expRef) + node := exp.ref + arr := arguments[2].([]interface{}) + mapped := make([]interface{}, 0, len(arr)) + for _, value := range arr { + current, err := intr.Execute(node, value) + if err != nil { + return nil, err + } + mapped = append(mapped, current) + } + return mapped, nil +} +func jpfMax(arguments []interface{}) (interface{}, error) { + if items, ok := toArrayNum(arguments[0]); ok { + if len(items) == 0 { + return nil, nil + } + if len(items) == 1 { + return items[0], nil + } + best := items[0] + for _, item := range items[1:] { + if item > best { + best = item + } + } + return best, nil + } + // Otherwise we're dealing with a max() of strings. + items, _ := toArrayStr(arguments[0]) + if len(items) == 0 { + return nil, nil + } + if len(items) == 1 { + return items[0], nil + } + best := items[0] + for _, item := range items[1:] { + if item > best { + best = item + } + } + return best, nil +} +func jpfMerge(arguments []interface{}) (interface{}, error) { + final := make(map[string]interface{}) + for _, m := range arguments { + mapped := m.(map[string]interface{}) + for key, value := range mapped { + final[key] = value + } + } + return final, nil +} +func jpfMaxBy(arguments []interface{}) (interface{}, error) { + intr := arguments[0].(*treeInterpreter) + arr := arguments[1].([]interface{}) + exp := arguments[2].(expRef) + node := exp.ref + if len(arr) == 0 { + return nil, nil + } else if len(arr) == 1 { + return arr[0], nil + } + start, err := intr.Execute(node, arr[0]) + if err != nil { + return nil, err + } + switch t := start.(type) { + case float64: + bestVal := t + bestItem := arr[0] + for _, item := range arr[1:] { + result, err := intr.Execute(node, item) + if err != nil { + return nil, err + } + current, ok := result.(float64) + if !ok { + return nil, errors.New("invalid type, must be number") + } + if current > bestVal { + bestVal = current + bestItem = item + } + } + return bestItem, nil + case string: + bestVal := t + bestItem := arr[0] + for _, item := range arr[1:] { + result, err := intr.Execute(node, item) + if err != nil { + return nil, err + } + current, ok := result.(string) + if !ok { + return nil, errors.New("invalid type, must be string") + } + if current > bestVal { + bestVal = current + bestItem = item + } + } + return bestItem, nil + default: + return nil, errors.New("invalid type, must be number of string") + } +} +func jpfSum(arguments []interface{}) (interface{}, error) { + items, _ := toArrayNum(arguments[0]) + sum := 0.0 + for _, item := range items { + sum += item + } + return sum, nil +} + +func jpfMin(arguments []interface{}) (interface{}, error) { + if items, ok := toArrayNum(arguments[0]); ok { + if len(items) == 0 { + return nil, nil + } + if len(items) == 1 { + return items[0], nil + } + best := items[0] + for _, item := range items[1:] { + if item < best { + best = item + } + } + return best, nil + } + items, _ := toArrayStr(arguments[0]) + if len(items) == 0 { + return nil, nil + } + if len(items) == 1 { + return items[0], nil + } + best := items[0] + for _, item := range items[1:] { + if item < best { + best = item + } + } + return best, nil +} + +func jpfMinBy(arguments []interface{}) (interface{}, error) { + intr := arguments[0].(*treeInterpreter) + arr := arguments[1].([]interface{}) + exp := arguments[2].(expRef) + node := exp.ref + if len(arr) == 0 { + return nil, nil + } else if len(arr) == 1 { + return arr[0], nil + } + start, err := intr.Execute(node, arr[0]) + if err != nil { + return nil, err + } + if t, ok := start.(float64); ok { + bestVal := t + bestItem := arr[0] + for _, item := range arr[1:] { + result, err := intr.Execute(node, item) + if err != nil { + return nil, err + } + current, ok := result.(float64) + if !ok { + return nil, errors.New("invalid type, must be number") + } + if current < bestVal { + bestVal = current + bestItem = item + } + } + return bestItem, nil + } else if t, ok := start.(string); ok { + bestVal := t + bestItem := arr[0] + for _, item := range arr[1:] { + result, err := intr.Execute(node, item) + if err != nil { + return nil, err + } + current, ok := result.(string) + if !ok { + return nil, errors.New("invalid type, must be string") + } + if current < bestVal { + bestVal = current + bestItem = item + } + } + return bestItem, nil + } else { + return nil, errors.New("invalid type, must be number of string") + } +} +func jpfType(arguments []interface{}) (interface{}, error) { + arg := arguments[0] + if _, ok := arg.(float64); ok { + return "number", nil + } + if _, ok := arg.(string); ok { + return "string", nil + } + if _, ok := arg.([]interface{}); ok { + return "array", nil + } + if _, ok := arg.(map[string]interface{}); ok { + return "object", nil + } + if arg == nil { + return "null", nil + } + if arg == true || arg == false { + return "boolean", nil + } + return nil, errors.New("unknown type") +} +func jpfKeys(arguments []interface{}) (interface{}, error) { + arg := arguments[0].(map[string]interface{}) + collected := make([]interface{}, 0, len(arg)) + for key := range arg { + collected = append(collected, key) + } + return collected, nil +} +func jpfValues(arguments []interface{}) (interface{}, error) { + arg := arguments[0].(map[string]interface{}) + collected := make([]interface{}, 0, len(arg)) + for _, value := range arg { + collected = append(collected, value) + } + return collected, nil +} +func jpfSort(arguments []interface{}) (interface{}, error) { + if items, ok := toArrayNum(arguments[0]); ok { + d := sort.Float64Slice(items) + sort.Stable(d) + final := make([]interface{}, len(d)) + for i, val := range d { + final[i] = val + } + return final, nil + } + // Otherwise we're dealing with sort()'ing strings. + items, _ := toArrayStr(arguments[0]) + d := sort.StringSlice(items) + sort.Stable(d) + final := make([]interface{}, len(d)) + for i, val := range d { + final[i] = val + } + return final, nil +} +func jpfSortBy(arguments []interface{}) (interface{}, error) { + intr := arguments[0].(*treeInterpreter) + arr := arguments[1].([]interface{}) + exp := arguments[2].(expRef) + node := exp.ref + if len(arr) == 0 { + return arr, nil + } else if len(arr) == 1 { + return arr, nil + } + start, err := intr.Execute(node, arr[0]) + if err != nil { + return nil, err + } + if _, ok := start.(float64); ok { + sortable := &byExprFloat{intr, node, arr, false} + sort.Stable(sortable) + if sortable.hasError { + return nil, errors.New("error in sort_by comparison") + } + return arr, nil + } else if _, ok := start.(string); ok { + sortable := &byExprString{intr, node, arr, false} + sort.Stable(sortable) + if sortable.hasError { + return nil, errors.New("error in sort_by comparison") + } + return arr, nil + } else { + return nil, errors.New("invalid type, must be number of string") + } +} +func jpfJoin(arguments []interface{}) (interface{}, error) { + sep := arguments[0].(string) + // We can't just do arguments[1].([]string), we have to + // manually convert each item to a string. + arrayStr := []string{} + for _, item := range arguments[1].([]interface{}) { + arrayStr = append(arrayStr, item.(string)) + } + return strings.Join(arrayStr, sep), nil +} +func jpfReverse(arguments []interface{}) (interface{}, error) { + if s, ok := arguments[0].(string); ok { + r := []rune(s) + for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 { + r[i], r[j] = r[j], r[i] + } + return string(r), nil + } + items := arguments[0].([]interface{}) + length := len(items) + reversed := make([]interface{}, length) + for i, item := range items { + reversed[length-(i+1)] = item + } + return reversed, nil +} +func jpfToArray(arguments []interface{}) (interface{}, error) { + if _, ok := arguments[0].([]interface{}); ok { + return arguments[0], nil + } + return arguments[:1:1], nil +} +func jpfToString(arguments []interface{}) (interface{}, error) { + if v, ok := arguments[0].(string); ok { + return v, nil + } + result, err := json.Marshal(arguments[0]) + if err != nil { + return nil, err + } + return string(result), nil +} +func jpfToNumber(arguments []interface{}) (interface{}, error) { + arg := arguments[0] + if v, ok := arg.(float64); ok { + return v, nil + } + if v, ok := arg.(string); ok { + conv, err := strconv.ParseFloat(v, 64) + if err != nil { + return nil, nil + } + return conv, nil + } + if _, ok := arg.([]interface{}); ok { + return nil, nil + } + if _, ok := arg.(map[string]interface{}); ok { + return nil, nil + } + if arg == nil { + return nil, nil + } + if arg == true || arg == false { + return nil, nil + } + return nil, errors.New("unknown type") +} +func jpfNotNull(arguments []interface{}) (interface{}, error) { + for _, arg := range arguments { + if arg != nil { + return arg, nil + } + } + return nil, nil +} diff --git a/Godeps/_workspace/src/github.com/jmespath/go-jmespath/interpreter.go b/Godeps/_workspace/src/github.com/jmespath/go-jmespath/interpreter.go new file mode 100644 index 0000000000..13c74604c2 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jmespath/go-jmespath/interpreter.go @@ -0,0 +1,418 @@ +package jmespath + +import ( + "errors" + "reflect" + "unicode" + "unicode/utf8" +) + +/* This is a tree based interpreter. It walks the AST and directly + interprets the AST to search through a JSON document. +*/ + +type treeInterpreter struct { + fCall *functionCaller +} + +func newInterpreter() *treeInterpreter { + interpreter := treeInterpreter{} + interpreter.fCall = newFunctionCaller() + return &interpreter +} + +type expRef struct { + ref ASTNode +} + +// Execute takes an ASTNode and input data and interprets the AST directly. +// It will produce the result of applying the JMESPath expression associated +// with the ASTNode to the input data "value". +func (intr *treeInterpreter) Execute(node ASTNode, value interface{}) (interface{}, error) { + switch node.nodeType { + case ASTComparator: + left, err := intr.Execute(node.children[0], value) + if err != nil { + return nil, err + } + right, err := intr.Execute(node.children[1], value) + if err != nil { + return nil, err + } + switch node.value { + case tEQ: + return objsEqual(left, right), nil + case tNE: + return !objsEqual(left, right), nil + } + leftNum, ok := left.(float64) + if !ok { + return nil, nil + } + rightNum, ok := right.(float64) + if !ok { + return nil, nil + } + switch node.value { + case tGT: + return leftNum > rightNum, nil + case tGTE: + return leftNum >= rightNum, nil + case tLT: + return leftNum < rightNum, nil + case tLTE: + return leftNum <= rightNum, nil + } + case ASTExpRef: + return expRef{ref: node.children[0]}, nil + case ASTFunctionExpression: + resolvedArgs := []interface{}{} + for _, arg := range node.children { + current, err := intr.Execute(arg, value) + if err != nil { + return nil, err + } + resolvedArgs = append(resolvedArgs, current) + } + return intr.fCall.CallFunction(node.value.(string), resolvedArgs, intr) + case ASTField: + if m, ok := value.(map[string]interface{}); ok { + key := node.value.(string) + return m[key], nil + } + return intr.fieldFromStruct(node.value.(string), value) + case ASTFilterProjection: + left, err := intr.Execute(node.children[0], value) + if err != nil { + return nil, nil + } + sliceType, ok := left.([]interface{}) + if !ok { + if isSliceType(left) { + return intr.filterProjectionWithReflection(node, left) + } + return nil, nil + } + compareNode := node.children[2] + collected := []interface{}{} + for _, element := range sliceType { + result, err := intr.Execute(compareNode, element) + if err != nil { + return nil, err + } + if !isFalse(result) { + current, err := intr.Execute(node.children[1], element) + if err != nil { + return nil, err + } + if current != nil { + collected = append(collected, current) + } + } + } + return collected, nil + case ASTFlatten: + left, err := intr.Execute(node.children[0], value) + if err != nil { + return nil, nil + } + sliceType, ok := left.([]interface{}) + if !ok { + // If we can't type convert to []interface{}, there's + // a chance this could still work via reflection if we're + // dealing with user provided types. + if isSliceType(left) { + return intr.flattenWithReflection(left) + } + return nil, nil + } + flattened := []interface{}{} + for _, element := range sliceType { + if elementSlice, ok := element.([]interface{}); ok { + flattened = append(flattened, elementSlice...) + } else if isSliceType(element) { + reflectFlat := []interface{}{} + v := reflect.ValueOf(element) + for i := 0; i < v.Len(); i++ { + reflectFlat = append(reflectFlat, v.Index(i).Interface()) + } + flattened = append(flattened, reflectFlat...) + } else { + flattened = append(flattened, element) + } + } + return flattened, nil + case ASTIdentity, ASTCurrentNode: + return value, nil + case ASTIndex: + if sliceType, ok := value.([]interface{}); ok { + index := node.value.(int) + if index < 0 { + index += len(sliceType) + } + if index < len(sliceType) && index >= 0 { + return sliceType[index], nil + } + return nil, nil + } + // Otherwise try via reflection. + rv := reflect.ValueOf(value) + if rv.Kind() == reflect.Slice { + index := node.value.(int) + if index < 0 { + index += rv.Len() + } + if index < rv.Len() && index >= 0 { + v := rv.Index(index) + return v.Interface(), nil + } + } + return nil, nil + case ASTKeyValPair: + return intr.Execute(node.children[0], value) + case ASTLiteral: + return node.value, nil + case ASTMultiSelectHash: + if value == nil { + return nil, nil + } + collected := make(map[string]interface{}) + for _, child := range node.children { + current, err := intr.Execute(child, value) + if err != nil { + return nil, err + } + key := child.value.(string) + collected[key] = current + } + return collected, nil + case ASTMultiSelectList: + if value == nil { + return nil, nil + } + collected := []interface{}{} + for _, child := range node.children { + current, err := intr.Execute(child, value) + if err != nil { + return nil, err + } + collected = append(collected, current) + } + return collected, nil + case ASTOrExpression: + matched, err := intr.Execute(node.children[0], value) + if err != nil { + return nil, err + } + if isFalse(matched) { + matched, err = intr.Execute(node.children[1], value) + if err != nil { + return nil, err + } + } + return matched, nil + case ASTAndExpression: + matched, err := intr.Execute(node.children[0], value) + if err != nil { + return nil, err + } + if isFalse(matched) { + return matched, nil + } + return intr.Execute(node.children[1], value) + case ASTNotExpression: + matched, err := intr.Execute(node.children[0], value) + if err != nil { + return nil, err + } + if isFalse(matched) { + return true, nil + } + return false, nil + case ASTPipe: + result := value + var err error + for _, child := range node.children { + result, err = intr.Execute(child, result) + if err != nil { + return nil, err + } + } + return result, nil + case ASTProjection: + left, err := intr.Execute(node.children[0], value) + if err != nil { + return nil, err + } + sliceType, ok := left.([]interface{}) + if !ok { + if isSliceType(left) { + return intr.projectWithReflection(node, left) + } + return nil, nil + } + collected := []interface{}{} + var current interface{} + for _, element := range sliceType { + current, err = intr.Execute(node.children[1], element) + if err != nil { + return nil, err + } + if current != nil { + collected = append(collected, current) + } + } + return collected, nil + case ASTSubexpression, ASTIndexExpression: + left, err := intr.Execute(node.children[0], value) + if err != nil { + return nil, err + } + return intr.Execute(node.children[1], left) + case ASTSlice: + sliceType, ok := value.([]interface{}) + if !ok { + if isSliceType(value) { + return intr.sliceWithReflection(node, value) + } + return nil, nil + } + parts := node.value.([]*int) + sliceParams := make([]sliceParam, 3) + for i, part := range parts { + if part != nil { + sliceParams[i].Specified = true + sliceParams[i].N = *part + } + } + return slice(sliceType, sliceParams) + case ASTValueProjection: + left, err := intr.Execute(node.children[0], value) + if err != nil { + return nil, nil + } + mapType, ok := left.(map[string]interface{}) + if !ok { + return nil, nil + } + values := make([]interface{}, len(mapType)) + for _, value := range mapType { + values = append(values, value) + } + collected := []interface{}{} + for _, element := range values { + current, err := intr.Execute(node.children[1], element) + if err != nil { + return nil, err + } + if current != nil { + collected = append(collected, current) + } + } + return collected, nil + } + return nil, errors.New("Unknown AST node: " + node.nodeType.String()) +} + +func (intr *treeInterpreter) fieldFromStruct(key string, value interface{}) (interface{}, error) { + rv := reflect.ValueOf(value) + first, n := utf8.DecodeRuneInString(key) + fieldName := string(unicode.ToUpper(first)) + key[n:] + if rv.Kind() == reflect.Struct { + v := rv.FieldByName(fieldName) + if !v.IsValid() { + return nil, nil + } + return v.Interface(), nil + } else if rv.Kind() == reflect.Ptr { + // Handle multiple levels of indirection? + if rv.IsNil() { + return nil, nil + } + rv = rv.Elem() + v := rv.FieldByName(fieldName) + if !v.IsValid() { + return nil, nil + } + return v.Interface(), nil + } + return nil, nil +} + +func (intr *treeInterpreter) flattenWithReflection(value interface{}) (interface{}, error) { + v := reflect.ValueOf(value) + flattened := []interface{}{} + for i := 0; i < v.Len(); i++ { + element := v.Index(i).Interface() + if reflect.TypeOf(element).Kind() == reflect.Slice { + // Then insert the contents of the element + // slice into the flattened slice, + // i.e flattened = append(flattened, mySlice...) + elementV := reflect.ValueOf(element) + for j := 0; j < elementV.Len(); j++ { + flattened = append( + flattened, elementV.Index(j).Interface()) + } + } else { + flattened = append(flattened, element) + } + } + return flattened, nil +} + +func (intr *treeInterpreter) sliceWithReflection(node ASTNode, value interface{}) (interface{}, error) { + v := reflect.ValueOf(value) + parts := node.value.([]*int) + sliceParams := make([]sliceParam, 3) + for i, part := range parts { + if part != nil { + sliceParams[i].Specified = true + sliceParams[i].N = *part + } + } + final := []interface{}{} + for i := 0; i < v.Len(); i++ { + element := v.Index(i).Interface() + final = append(final, element) + } + return slice(final, sliceParams) +} + +func (intr *treeInterpreter) filterProjectionWithReflection(node ASTNode, value interface{}) (interface{}, error) { + compareNode := node.children[2] + collected := []interface{}{} + v := reflect.ValueOf(value) + for i := 0; i < v.Len(); i++ { + element := v.Index(i).Interface() + result, err := intr.Execute(compareNode, element) + if err != nil { + return nil, err + } + if !isFalse(result) { + current, err := intr.Execute(node.children[1], element) + if err != nil { + return nil, err + } + if current != nil { + collected = append(collected, current) + } + } + } + return collected, nil +} + +func (intr *treeInterpreter) projectWithReflection(node ASTNode, value interface{}) (interface{}, error) { + collected := []interface{}{} + v := reflect.ValueOf(value) + for i := 0; i < v.Len(); i++ { + element := v.Index(i).Interface() + result, err := intr.Execute(node.children[1], element) + if err != nil { + return nil, err + } + if result != nil { + collected = append(collected, result) + } + } + return collected, nil +} diff --git a/Godeps/_workspace/src/github.com/jmespath/go-jmespath/lexer.go b/Godeps/_workspace/src/github.com/jmespath/go-jmespath/lexer.go new file mode 100644 index 0000000000..817900c8f5 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jmespath/go-jmespath/lexer.go @@ -0,0 +1,420 @@ +package jmespath + +import ( + "bytes" + "encoding/json" + "fmt" + "strconv" + "strings" + "unicode/utf8" +) + +type token struct { + tokenType tokType + value string + position int + length int +} + +type tokType int + +const eof = -1 + +// Lexer contains information about the expression being tokenized. +type Lexer struct { + expression string // The expression provided by the user. + currentPos int // The current position in the string. + lastWidth int // The width of the current rune. This + buf bytes.Buffer // Internal buffer used for building up values. +} + +// SyntaxError is the main error used whenever a lexing or parsing error occurs. +type SyntaxError struct { + msg string // Error message displayed to user + Expression string // Expression that generated a SyntaxError + Offset int // The location in the string where the error occurred +} + +func (e SyntaxError) Error() string { + // In the future, it would be good to underline the specific + // location where the error occurred. + return "SyntaxError: " + e.msg +} + +// HighlightLocation will show where the syntax error occurred. +// It will place a "^" character on a line below the expression +// at the point where the syntax error occurred. +func (e SyntaxError) HighlightLocation() string { + return e.Expression + "\n" + strings.Repeat(" ", e.Offset) + "^" +} + +//go:generate stringer -type=tokType +const ( + tUnknown tokType = iota + tStar + tDot + tFilter + tFlatten + tLparen + tRparen + tLbracket + tRbracket + tLbrace + tRbrace + tOr + tPipe + tNumber + tUnquotedIdentifier + tQuotedIdentifier + tComma + tColon + tLT + tLTE + tGT + tGTE + tEQ + tNE + tJSONLiteral + tStringLiteral + tCurrent + tExpref + tAnd + tNot + tEOF +) + +var basicTokens = map[rune]tokType{ + '.': tDot, + '*': tStar, + ',': tComma, + ':': tColon, + '{': tLbrace, + '}': tRbrace, + ']': tRbracket, // tLbracket not included because it could be "[]" + '(': tLparen, + ')': tRparen, + '@': tCurrent, +} + +// Bit mask for [a-zA-Z_] shifted down 64 bits to fit in a single uint64. +// When using this bitmask just be sure to shift the rune down 64 bits +// before checking against identifierStartBits. +const identifierStartBits uint64 = 576460745995190270 + +// Bit mask for [a-zA-Z0-9], 128 bits -> 2 uint64s. +var identifierTrailingBits = [2]uint64{287948901175001088, 576460745995190270} + +var whiteSpace = map[rune]bool{ + ' ': true, '\t': true, '\n': true, '\r': true, +} + +func (t token) String() string { + return fmt.Sprintf("Token{%+v, %s, %d, %d}", + t.tokenType, t.value, t.position, t.length) +} + +// NewLexer creates a new JMESPath lexer. +func NewLexer() *Lexer { + lexer := Lexer{} + return &lexer +} + +func (lexer *Lexer) next() rune { + if lexer.currentPos >= len(lexer.expression) { + lexer.lastWidth = 0 + return eof + } + r, w := utf8.DecodeRuneInString(lexer.expression[lexer.currentPos:]) + lexer.lastWidth = w + lexer.currentPos += w + return r +} + +func (lexer *Lexer) back() { + lexer.currentPos -= lexer.lastWidth +} + +func (lexer *Lexer) peek() rune { + t := lexer.next() + lexer.back() + return t +} + +// tokenize takes an expression and returns corresponding tokens. +func (lexer *Lexer) tokenize(expression string) ([]token, error) { + var tokens []token + lexer.expression = expression + lexer.currentPos = 0 + lexer.lastWidth = 0 +loop: + for { + r := lexer.next() + if identifierStartBits&(1<<(uint64(r)-64)) > 0 { + t := lexer.consumeUnquotedIdentifier() + tokens = append(tokens, t) + } else if val, ok := basicTokens[r]; ok { + // Basic single char token. + t := token{ + tokenType: val, + value: string(r), + position: lexer.currentPos - lexer.lastWidth, + length: 1, + } + tokens = append(tokens, t) + } else if r == '-' || (r >= '0' && r <= '9') { + t := lexer.consumeNumber() + tokens = append(tokens, t) + } else if r == '[' { + t := lexer.consumeLBracket() + tokens = append(tokens, t) + } else if r == '"' { + t, err := lexer.consumeQuotedIdentifier() + if err != nil { + return tokens, err + } + tokens = append(tokens, t) + } else if r == '\'' { + t, err := lexer.consumeRawStringLiteral() + if err != nil { + return tokens, err + } + tokens = append(tokens, t) + } else if r == '`' { + t, err := lexer.consumeLiteral() + if err != nil { + return tokens, err + } + tokens = append(tokens, t) + } else if r == '|' { + t := lexer.matchOrElse(r, '|', tOr, tPipe) + tokens = append(tokens, t) + } else if r == '<' { + t := lexer.matchOrElse(r, '=', tLTE, tLT) + tokens = append(tokens, t) + } else if r == '>' { + t := lexer.matchOrElse(r, '=', tGTE, tGT) + tokens = append(tokens, t) + } else if r == '!' { + t := lexer.matchOrElse(r, '=', tNE, tNot) + tokens = append(tokens, t) + } else if r == '=' { + t := lexer.matchOrElse(r, '=', tEQ, tUnknown) + tokens = append(tokens, t) + } else if r == '&' { + t := lexer.matchOrElse(r, '&', tAnd, tExpref) + tokens = append(tokens, t) + } else if r == eof { + break loop + } else if _, ok := whiteSpace[r]; ok { + // Ignore whitespace + } else { + return tokens, lexer.syntaxError(fmt.Sprintf("Unknown char: %s", strconv.QuoteRuneToASCII(r))) + } + } + tokens = append(tokens, token{tEOF, "", len(lexer.expression), 0}) + return tokens, nil +} + +// Consume characters until the ending rune "r" is reached. +// If the end of the expression is reached before seeing the +// terminating rune "r", then an error is returned. +// If no error occurs then the matching substring is returned. +// The returned string will not include the ending rune. +func (lexer *Lexer) consumeUntil(end rune) (string, error) { + start := lexer.currentPos + current := lexer.next() + for current != end && current != eof { + if current == '\\' && lexer.peek() != eof { + lexer.next() + } + current = lexer.next() + } + if lexer.lastWidth == 0 { + // Then we hit an EOF so we never reached the closing + // delimiter. + return "", SyntaxError{ + msg: "Unclosed delimiter: " + string(end), + Expression: lexer.expression, + Offset: len(lexer.expression), + } + } + return lexer.expression[start : lexer.currentPos-lexer.lastWidth], nil +} + +func (lexer *Lexer) consumeLiteral() (token, error) { + start := lexer.currentPos + value, err := lexer.consumeUntil('`') + if err != nil { + return token{}, err + } + value = strings.Replace(value, "\\`", "`", -1) + return token{ + tokenType: tJSONLiteral, + value: value, + position: start, + length: len(value), + }, nil +} + +func (lexer *Lexer) consumeRawStringLiteral() (token, error) { + start := lexer.currentPos + currentIndex := start + current := lexer.next() + for current != '\'' && lexer.peek() != eof { + if current == '\\' && lexer.peek() == '\'' { + chunk := lexer.expression[currentIndex : lexer.currentPos-1] + lexer.buf.WriteString(chunk) + lexer.buf.WriteString("'") + lexer.next() + currentIndex = lexer.currentPos + } + current = lexer.next() + } + if lexer.lastWidth == 0 { + // Then we hit an EOF so we never reached the closing + // delimiter. + return token{}, SyntaxError{ + msg: "Unclosed delimiter: '", + Expression: lexer.expression, + Offset: len(lexer.expression), + } + } + if currentIndex < lexer.currentPos { + lexer.buf.WriteString(lexer.expression[currentIndex : lexer.currentPos-1]) + } + value := lexer.buf.String() + // Reset the buffer so it can reused again. + lexer.buf.Reset() + return token{ + tokenType: tStringLiteral, + value: value, + position: start, + length: len(value), + }, nil +} + +func (lexer *Lexer) syntaxError(msg string) SyntaxError { + return SyntaxError{ + msg: msg, + Expression: lexer.expression, + Offset: lexer.currentPos - 1, + } +} + +// Checks for a two char token, otherwise matches a single character +// token. This is used whenever a two char token overlaps a single +// char token, e.g. "||" -> tPipe, "|" -> tOr. +func (lexer *Lexer) matchOrElse(first rune, second rune, matchedType tokType, singleCharType tokType) token { + start := lexer.currentPos - lexer.lastWidth + nextRune := lexer.next() + var t token + if nextRune == second { + t = token{ + tokenType: matchedType, + value: string(first) + string(second), + position: start, + length: 2, + } + } else { + lexer.back() + t = token{ + tokenType: singleCharType, + value: string(first), + position: start, + length: 1, + } + } + return t +} + +func (lexer *Lexer) consumeLBracket() token { + // There's three options here: + // 1. A filter expression "[?" + // 2. A flatten operator "[]" + // 3. A bare rbracket "[" + start := lexer.currentPos - lexer.lastWidth + nextRune := lexer.next() + var t token + if nextRune == '?' { + t = token{ + tokenType: tFilter, + value: "[?", + position: start, + length: 2, + } + } else if nextRune == ']' { + t = token{ + tokenType: tFlatten, + value: "[]", + position: start, + length: 2, + } + } else { + t = token{ + tokenType: tLbracket, + value: "[", + position: start, + length: 1, + } + lexer.back() + } + return t +} + +func (lexer *Lexer) consumeQuotedIdentifier() (token, error) { + start := lexer.currentPos + value, err := lexer.consumeUntil('"') + if err != nil { + return token{}, err + } + var decoded string + asJSON := []byte("\"" + value + "\"") + if err := json.Unmarshal([]byte(asJSON), &decoded); err != nil { + return token{}, err + } + return token{ + tokenType: tQuotedIdentifier, + value: decoded, + position: start - 1, + length: len(decoded), + }, nil +} + +func (lexer *Lexer) consumeUnquotedIdentifier() token { + // Consume runes until we reach the end of an unquoted + // identifier. + start := lexer.currentPos - lexer.lastWidth + for { + r := lexer.next() + if r < 0 || r > 128 || identifierTrailingBits[uint64(r)/64]&(1<<(uint64(r)%64)) == 0 { + lexer.back() + break + } + } + value := lexer.expression[start:lexer.currentPos] + return token{ + tokenType: tUnquotedIdentifier, + value: value, + position: start, + length: lexer.currentPos - start, + } +} + +func (lexer *Lexer) consumeNumber() token { + // Consume runes until we reach something that's not a number. + start := lexer.currentPos - lexer.lastWidth + for { + r := lexer.next() + if r < '0' || r > '9' { + lexer.back() + break + } + } + value := lexer.expression[start:lexer.currentPos] + return token{ + tokenType: tNumber, + value: value, + position: start, + length: lexer.currentPos - start, + } +} diff --git a/Godeps/_workspace/src/github.com/jmespath/go-jmespath/parser.go b/Godeps/_workspace/src/github.com/jmespath/go-jmespath/parser.go new file mode 100644 index 0000000000..1240a17552 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jmespath/go-jmespath/parser.go @@ -0,0 +1,603 @@ +package jmespath + +import ( + "encoding/json" + "fmt" + "strconv" + "strings" +) + +type astNodeType int + +//go:generate stringer -type astNodeType +const ( + ASTEmpty astNodeType = iota + ASTComparator + ASTCurrentNode + ASTExpRef + ASTFunctionExpression + ASTField + ASTFilterProjection + ASTFlatten + ASTIdentity + ASTIndex + ASTIndexExpression + ASTKeyValPair + ASTLiteral + ASTMultiSelectHash + ASTMultiSelectList + ASTOrExpression + ASTAndExpression + ASTNotExpression + ASTPipe + ASTProjection + ASTSubexpression + ASTSlice + ASTValueProjection +) + +// ASTNode represents the abstract syntax tree of a JMESPath expression. +type ASTNode struct { + nodeType astNodeType + value interface{} + children []ASTNode +} + +func (node ASTNode) String() string { + return node.PrettyPrint(0) +} + +// PrettyPrint will pretty print the parsed AST. +// The AST is an implementation detail and this pretty print +// function is provided as a convenience method to help with +// debugging. You should not rely on its output as the internal +// structure of the AST may change at any time. +func (node ASTNode) PrettyPrint(indent int) string { + spaces := strings.Repeat(" ", indent) + output := fmt.Sprintf("%s%s {\n", spaces, node.nodeType) + nextIndent := indent + 2 + if node.value != nil { + if converted, ok := node.value.(fmt.Stringer); ok { + // Account for things like comparator nodes + // that are enums with a String() method. + output += fmt.Sprintf("%svalue: %s\n", strings.Repeat(" ", nextIndent), converted.String()) + } else { + output += fmt.Sprintf("%svalue: %#v\n", strings.Repeat(" ", nextIndent), node.value) + } + } + lastIndex := len(node.children) + if lastIndex > 0 { + output += fmt.Sprintf("%schildren: {\n", strings.Repeat(" ", nextIndent)) + childIndent := nextIndent + 2 + for _, elem := range node.children { + output += elem.PrettyPrint(childIndent) + } + } + output += fmt.Sprintf("%s}\n", spaces) + return output +} + +var bindingPowers = map[tokType]int{ + tEOF: 0, + tUnquotedIdentifier: 0, + tQuotedIdentifier: 0, + tRbracket: 0, + tRparen: 0, + tComma: 0, + tRbrace: 0, + tNumber: 0, + tCurrent: 0, + tExpref: 0, + tColon: 0, + tPipe: 1, + tOr: 2, + tAnd: 3, + tEQ: 5, + tLT: 5, + tLTE: 5, + tGT: 5, + tGTE: 5, + tNE: 5, + tFlatten: 9, + tStar: 20, + tFilter: 21, + tDot: 40, + tNot: 45, + tLbrace: 50, + tLbracket: 55, + tLparen: 60, +} + +// Parser holds state about the current expression being parsed. +type Parser struct { + expression string + tokens []token + index int +} + +// NewParser creates a new JMESPath parser. +func NewParser() *Parser { + p := Parser{} + return &p +} + +// Parse will compile a JMESPath expression. +func (p *Parser) Parse(expression string) (ASTNode, error) { + lexer := NewLexer() + p.expression = expression + p.index = 0 + tokens, err := lexer.tokenize(expression) + if err != nil { + return ASTNode{}, err + } + p.tokens = tokens + parsed, err := p.parseExpression(0) + if err != nil { + return ASTNode{}, err + } + if p.current() != tEOF { + return ASTNode{}, p.syntaxError(fmt.Sprintf( + "Unexpected token at the end of the expresssion: %s", p.current())) + } + return parsed, nil +} + +func (p *Parser) parseExpression(bindingPower int) (ASTNode, error) { + var err error + leftToken := p.lookaheadToken(0) + p.advance() + leftNode, err := p.nud(leftToken) + if err != nil { + return ASTNode{}, err + } + currentToken := p.current() + for bindingPower < bindingPowers[currentToken] { + p.advance() + leftNode, err = p.led(currentToken, leftNode) + if err != nil { + return ASTNode{}, err + } + currentToken = p.current() + } + return leftNode, nil +} + +func (p *Parser) parseIndexExpression() (ASTNode, error) { + if p.lookahead(0) == tColon || p.lookahead(1) == tColon { + return p.parseSliceExpression() + } + indexStr := p.lookaheadToken(0).value + parsedInt, err := strconv.Atoi(indexStr) + if err != nil { + return ASTNode{}, err + } + indexNode := ASTNode{nodeType: ASTIndex, value: parsedInt} + p.advance() + if err := p.match(tRbracket); err != nil { + return ASTNode{}, err + } + return indexNode, nil +} + +func (p *Parser) parseSliceExpression() (ASTNode, error) { + parts := []*int{nil, nil, nil} + index := 0 + current := p.current() + for current != tRbracket && index < 3 { + if current == tColon { + index++ + p.advance() + } else if current == tNumber { + parsedInt, err := strconv.Atoi(p.lookaheadToken(0).value) + if err != nil { + return ASTNode{}, err + } + parts[index] = &parsedInt + p.advance() + } else { + return ASTNode{}, p.syntaxError( + "Expected tColon or tNumber" + ", received: " + p.current().String()) + } + current = p.current() + } + if err := p.match(tRbracket); err != nil { + return ASTNode{}, err + } + return ASTNode{ + nodeType: ASTSlice, + value: parts, + }, nil +} + +func (p *Parser) match(tokenType tokType) error { + if p.current() == tokenType { + p.advance() + return nil + } + return p.syntaxError("Expected " + tokenType.String() + ", received: " + p.current().String()) +} + +func (p *Parser) led(tokenType tokType, node ASTNode) (ASTNode, error) { + switch tokenType { + case tDot: + if p.current() != tStar { + right, err := p.parseDotRHS(bindingPowers[tDot]) + return ASTNode{ + nodeType: ASTSubexpression, + children: []ASTNode{node, right}, + }, err + } + p.advance() + right, err := p.parseProjectionRHS(bindingPowers[tDot]) + return ASTNode{ + nodeType: ASTValueProjection, + children: []ASTNode{node, right}, + }, err + case tPipe: + right, err := p.parseExpression(bindingPowers[tPipe]) + return ASTNode{nodeType: ASTPipe, children: []ASTNode{node, right}}, err + case tOr: + right, err := p.parseExpression(bindingPowers[tOr]) + return ASTNode{nodeType: ASTOrExpression, children: []ASTNode{node, right}}, err + case tAnd: + right, err := p.parseExpression(bindingPowers[tAnd]) + return ASTNode{nodeType: ASTAndExpression, children: []ASTNode{node, right}}, err + case tLparen: + name := node.value + var args []ASTNode + for p.current() != tRparen { + expression, err := p.parseExpression(0) + if err != nil { + return ASTNode{}, err + } + if p.current() == tComma { + if err := p.match(tComma); err != nil { + return ASTNode{}, err + } + } + args = append(args, expression) + } + if err := p.match(tRparen); err != nil { + return ASTNode{}, err + } + return ASTNode{ + nodeType: ASTFunctionExpression, + value: name, + children: args, + }, nil + case tFilter: + return p.parseFilter(node) + case tFlatten: + left := ASTNode{nodeType: ASTFlatten, children: []ASTNode{node}} + right, err := p.parseProjectionRHS(bindingPowers[tFlatten]) + return ASTNode{ + nodeType: ASTProjection, + children: []ASTNode{left, right}, + }, err + case tEQ, tNE, tGT, tGTE, tLT, tLTE: + right, err := p.parseExpression(bindingPowers[tokenType]) + if err != nil { + return ASTNode{}, err + } + return ASTNode{ + nodeType: ASTComparator, + value: tokenType, + children: []ASTNode{node, right}, + }, nil + case tLbracket: + tokenType := p.current() + var right ASTNode + var err error + if tokenType == tNumber || tokenType == tColon { + right, err = p.parseIndexExpression() + if err != nil { + return ASTNode{}, err + } + return p.projectIfSlice(node, right) + } + // Otherwise this is a projection. + if err := p.match(tStar); err != nil { + return ASTNode{}, err + } + if err := p.match(tRbracket); err != nil { + return ASTNode{}, err + } + right, err = p.parseProjectionRHS(bindingPowers[tStar]) + if err != nil { + return ASTNode{}, err + } + return ASTNode{ + nodeType: ASTProjection, + children: []ASTNode{node, right}, + }, nil + } + return ASTNode{}, p.syntaxError("Unexpected token: " + tokenType.String()) +} + +func (p *Parser) nud(token token) (ASTNode, error) { + switch token.tokenType { + case tJSONLiteral: + var parsed interface{} + err := json.Unmarshal([]byte(token.value), &parsed) + if err != nil { + return ASTNode{}, err + } + return ASTNode{nodeType: ASTLiteral, value: parsed}, nil + case tStringLiteral: + return ASTNode{nodeType: ASTLiteral, value: token.value}, nil + case tUnquotedIdentifier: + return ASTNode{ + nodeType: ASTField, + value: token.value, + }, nil + case tQuotedIdentifier: + node := ASTNode{nodeType: ASTField, value: token.value} + if p.current() == tLparen { + return ASTNode{}, p.syntaxErrorToken("Can't have quoted identifier as function name.", token) + } + return node, nil + case tStar: + left := ASTNode{nodeType: ASTIdentity} + var right ASTNode + var err error + if p.current() == tRbracket { + right = ASTNode{nodeType: ASTIdentity} + } else { + right, err = p.parseProjectionRHS(bindingPowers[tStar]) + } + return ASTNode{nodeType: ASTValueProjection, children: []ASTNode{left, right}}, err + case tFilter: + return p.parseFilter(ASTNode{nodeType: ASTIdentity}) + case tLbrace: + return p.parseMultiSelectHash() + case tFlatten: + left := ASTNode{ + nodeType: ASTFlatten, + children: []ASTNode{{nodeType: ASTIdentity}}, + } + right, err := p.parseProjectionRHS(bindingPowers[tFlatten]) + if err != nil { + return ASTNode{}, err + } + return ASTNode{nodeType: ASTProjection, children: []ASTNode{left, right}}, nil + case tLbracket: + tokenType := p.current() + //var right ASTNode + if tokenType == tNumber || tokenType == tColon { + right, err := p.parseIndexExpression() + if err != nil { + return ASTNode{}, nil + } + return p.projectIfSlice(ASTNode{nodeType: ASTIdentity}, right) + } else if tokenType == tStar && p.lookahead(1) == tRbracket { + p.advance() + p.advance() + right, err := p.parseProjectionRHS(bindingPowers[tStar]) + if err != nil { + return ASTNode{}, err + } + return ASTNode{ + nodeType: ASTProjection, + children: []ASTNode{{nodeType: ASTIdentity}, right}, + }, nil + } else { + return p.parseMultiSelectList() + } + case tCurrent: + return ASTNode{nodeType: ASTCurrentNode}, nil + case tExpref: + expression, err := p.parseExpression(bindingPowers[tExpref]) + if err != nil { + return ASTNode{}, err + } + return ASTNode{nodeType: ASTExpRef, children: []ASTNode{expression}}, nil + case tNot: + expression, err := p.parseExpression(bindingPowers[tNot]) + if err != nil { + return ASTNode{}, err + } + return ASTNode{nodeType: ASTNotExpression, children: []ASTNode{expression}}, nil + case tLparen: + expression, err := p.parseExpression(0) + if err != nil { + return ASTNode{}, err + } + if err := p.match(tRparen); err != nil { + return ASTNode{}, err + } + return expression, nil + case tEOF: + return ASTNode{}, p.syntaxErrorToken("Incomplete expression", token) + } + + return ASTNode{}, p.syntaxErrorToken("Invalid token: "+token.tokenType.String(), token) +} + +func (p *Parser) parseMultiSelectList() (ASTNode, error) { + var expressions []ASTNode + for { + expression, err := p.parseExpression(0) + if err != nil { + return ASTNode{}, err + } + expressions = append(expressions, expression) + if p.current() == tRbracket { + break + } + err = p.match(tComma) + if err != nil { + return ASTNode{}, err + } + } + err := p.match(tRbracket) + if err != nil { + return ASTNode{}, err + } + return ASTNode{ + nodeType: ASTMultiSelectList, + children: expressions, + }, nil +} + +func (p *Parser) parseMultiSelectHash() (ASTNode, error) { + var children []ASTNode + for { + keyToken := p.lookaheadToken(0) + if err := p.match(tUnquotedIdentifier); err != nil { + if err := p.match(tQuotedIdentifier); err != nil { + return ASTNode{}, p.syntaxError("Expected tQuotedIdentifier or tUnquotedIdentifier") + } + } + keyName := keyToken.value + err := p.match(tColon) + if err != nil { + return ASTNode{}, err + } + value, err := p.parseExpression(0) + if err != nil { + return ASTNode{}, err + } + node := ASTNode{ + nodeType: ASTKeyValPair, + value: keyName, + children: []ASTNode{value}, + } + children = append(children, node) + if p.current() == tComma { + err := p.match(tComma) + if err != nil { + return ASTNode{}, nil + } + } else if p.current() == tRbrace { + err := p.match(tRbrace) + if err != nil { + return ASTNode{}, nil + } + break + } + } + return ASTNode{ + nodeType: ASTMultiSelectHash, + children: children, + }, nil +} + +func (p *Parser) projectIfSlice(left ASTNode, right ASTNode) (ASTNode, error) { + indexExpr := ASTNode{ + nodeType: ASTIndexExpression, + children: []ASTNode{left, right}, + } + if right.nodeType == ASTSlice { + right, err := p.parseProjectionRHS(bindingPowers[tStar]) + return ASTNode{ + nodeType: ASTProjection, + children: []ASTNode{indexExpr, right}, + }, err + } + return indexExpr, nil +} +func (p *Parser) parseFilter(node ASTNode) (ASTNode, error) { + var right, condition ASTNode + var err error + condition, err = p.parseExpression(0) + if err != nil { + return ASTNode{}, err + } + if err := p.match(tRbracket); err != nil { + return ASTNode{}, err + } + if p.current() == tFlatten { + right = ASTNode{nodeType: ASTIdentity} + } else { + right, err = p.parseProjectionRHS(bindingPowers[tFilter]) + if err != nil { + return ASTNode{}, err + } + } + + return ASTNode{ + nodeType: ASTFilterProjection, + children: []ASTNode{node, right, condition}, + }, nil +} + +func (p *Parser) parseDotRHS(bindingPower int) (ASTNode, error) { + lookahead := p.current() + if tokensOneOf([]tokType{tQuotedIdentifier, tUnquotedIdentifier, tStar}, lookahead) { + return p.parseExpression(bindingPower) + } else if lookahead == tLbracket { + if err := p.match(tLbracket); err != nil { + return ASTNode{}, err + } + return p.parseMultiSelectList() + } else if lookahead == tLbrace { + if err := p.match(tLbrace); err != nil { + return ASTNode{}, err + } + return p.parseMultiSelectHash() + } + return ASTNode{}, p.syntaxError("Expected identifier, lbracket, or lbrace") +} + +func (p *Parser) parseProjectionRHS(bindingPower int) (ASTNode, error) { + current := p.current() + if bindingPowers[current] < 10 { + return ASTNode{nodeType: ASTIdentity}, nil + } else if current == tLbracket { + return p.parseExpression(bindingPower) + } else if current == tFilter { + return p.parseExpression(bindingPower) + } else if current == tDot { + err := p.match(tDot) + if err != nil { + return ASTNode{}, err + } + return p.parseDotRHS(bindingPower) + } else { + return ASTNode{}, p.syntaxError("Error") + } +} + +func (p *Parser) lookahead(number int) tokType { + return p.lookaheadToken(number).tokenType +} + +func (p *Parser) current() tokType { + return p.lookahead(0) +} + +func (p *Parser) lookaheadToken(number int) token { + return p.tokens[p.index+number] +} + +func (p *Parser) advance() { + p.index++ +} + +func tokensOneOf(elements []tokType, token tokType) bool { + for _, elem := range elements { + if elem == token { + return true + } + } + return false +} + +func (p *Parser) syntaxError(msg string) SyntaxError { + return SyntaxError{ + msg: msg, + Expression: p.expression, + Offset: p.lookaheadToken(0).position, + } +} + +// Create a SyntaxError based on the provided token. +// This differs from syntaxError() which creates a SyntaxError +// based on the current lookahead token. +func (p *Parser) syntaxErrorToken(msg string, t token) SyntaxError { + return SyntaxError{ + msg: msg, + Expression: p.expression, + Offset: t.position, + } +} diff --git a/Godeps/_workspace/src/github.com/jmespath/go-jmespath/toktype_string.go b/Godeps/_workspace/src/github.com/jmespath/go-jmespath/toktype_string.go new file mode 100644 index 0000000000..dae79cbdf3 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jmespath/go-jmespath/toktype_string.go @@ -0,0 +1,16 @@ +// generated by stringer -type=tokType; DO NOT EDIT + +package jmespath + +import "fmt" + +const _tokType_name = "tUnknowntStartDottFiltertFlattentLparentRparentLbrackettRbrackettLbracetRbracetOrtPipetNumbertUnquotedIdentifiertQuotedIdentifiertCommatColontLTtLTEtGTtGTEtEQtNEtJSONLiteraltStringLiteraltCurrenttExpreftAndtNottEOF" + +var _tokType_index = [...]uint8{0, 8, 13, 17, 24, 32, 39, 46, 55, 64, 71, 78, 81, 86, 93, 112, 129, 135, 141, 144, 148, 151, 155, 158, 161, 173, 187, 195, 202, 206, 210, 214} + +func (i tokType) String() string { + if i < 0 || i >= tokType(len(_tokType_index)-1) { + return fmt.Sprintf("tokType(%d)", i) + } + return _tokType_name[_tokType_index[i]:_tokType_index[i+1]] +} diff --git a/Godeps/_workspace/src/github.com/jmespath/go-jmespath/util.go b/Godeps/_workspace/src/github.com/jmespath/go-jmespath/util.go new file mode 100644 index 0000000000..ddc1b7d7d4 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jmespath/go-jmespath/util.go @@ -0,0 +1,185 @@ +package jmespath + +import ( + "errors" + "reflect" +) + +// IsFalse determines if an object is false based on the JMESPath spec. +// JMESPath defines false values to be any of: +// - An empty string array, or hash. +// - The boolean value false. +// - nil +func isFalse(value interface{}) bool { + switch v := value.(type) { + case bool: + return !v + case []interface{}: + return len(v) == 0 + case map[string]interface{}: + return len(v) == 0 + case string: + return len(v) == 0 + case nil: + return true + } + // Try the reflection cases before returning false. + rv := reflect.ValueOf(value) + switch rv.Kind() { + case reflect.Struct: + // A struct type will never be false, even if + // all of its values are the zero type. + return false + case reflect.Slice, reflect.Map: + return rv.Len() == 0 + case reflect.Ptr: + if rv.IsNil() { + return true + } + // If it's a pointer type, we'll try to deref the pointer + // and evaluate the pointer value for isFalse. + element := rv.Elem() + return isFalse(element.Interface()) + } + return false +} + +// ObjsEqual is a generic object equality check. +// It will take two arbitrary objects and recursively determine +// if they are equal. +func objsEqual(left interface{}, right interface{}) bool { + return reflect.DeepEqual(left, right) +} + +// SliceParam refers to a single part of a slice. +// A slice consists of a start, a stop, and a step, similar to +// python slices. +type sliceParam struct { + N int + Specified bool +} + +// Slice supports [start:stop:step] style slicing that's supported in JMESPath. +func slice(slice []interface{}, parts []sliceParam) ([]interface{}, error) { + computed, err := computeSliceParams(len(slice), parts) + if err != nil { + return nil, err + } + start, stop, step := computed[0], computed[1], computed[2] + result := []interface{}{} + if step > 0 { + for i := start; i < stop; i += step { + result = append(result, slice[i]) + } + } else { + for i := start; i > stop; i += step { + result = append(result, slice[i]) + } + } + return result, nil +} + +func computeSliceParams(length int, parts []sliceParam) ([]int, error) { + var start, stop, step int + if !parts[2].Specified { + step = 1 + } else if parts[2].N == 0 { + return nil, errors.New("Invalid slice, step cannot be 0") + } else { + step = parts[2].N + } + var stepValueNegative bool + if step < 0 { + stepValueNegative = true + } else { + stepValueNegative = false + } + + if !parts[0].Specified { + if stepValueNegative { + start = length - 1 + } else { + start = 0 + } + } else { + start = capSlice(length, parts[0].N, step) + } + + if !parts[1].Specified { + if stepValueNegative { + stop = -1 + } else { + stop = length + } + } else { + stop = capSlice(length, parts[1].N, step) + } + return []int{start, stop, step}, nil +} + +func capSlice(length int, actual int, step int) int { + if actual < 0 { + actual += length + if actual < 0 { + if step < 0 { + actual = -1 + } else { + actual = 0 + } + } + } else if actual >= length { + if step < 0 { + actual = length - 1 + } else { + actual = length + } + } + return actual +} + +// ToArrayNum converts an empty interface type to a slice of float64. +// If any element in the array cannot be converted, then nil is returned +// along with a second value of false. +func toArrayNum(data interface{}) ([]float64, bool) { + // Is there a better way to do this with reflect? + if d, ok := data.([]interface{}); ok { + result := make([]float64, len(d)) + for i, el := range d { + item, ok := el.(float64) + if !ok { + return nil, false + } + result[i] = item + } + return result, true + } + return nil, false +} + +// ToArrayStr converts an empty interface type to a slice of strings. +// If any element in the array cannot be converted, then nil is returned +// along with a second value of false. If the input data could be entirely +// converted, then the converted data, along with a second value of true, +// will be returned. +func toArrayStr(data interface{}) ([]string, bool) { + // Is there a better way to do this with reflect? + if d, ok := data.([]interface{}); ok { + result := make([]string, len(d)) + for i, el := range d { + item, ok := el.(string) + if !ok { + return nil, false + } + result[i] = item + } + return result, true + } + return nil, false +} + +func isSliceType(v interface{}) bool { + if v == nil { + return false + } + return reflect.TypeOf(v).Kind() == reflect.Slice +} diff --git a/Godeps/_workspace/src/github.com/jtolds/gls/LICENSE b/Godeps/_workspace/src/github.com/jtolds/gls/LICENSE new file mode 100644 index 0000000000..9b4a822d92 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jtolds/gls/LICENSE @@ -0,0 +1,18 @@ +Copyright (c) 2013, Space Monkey, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Godeps/_workspace/src/github.com/jtolds/gls/README.md b/Godeps/_workspace/src/github.com/jtolds/gls/README.md new file mode 100644 index 0000000000..4ebb692fb1 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jtolds/gls/README.md @@ -0,0 +1,89 @@ +gls +=== + +Goroutine local storage + +### IMPORTANT NOTE ### + +It is my duty to point you to https://blog.golang.org/context, which is how +Google solves all of the problems you'd perhaps consider using this package +for at scale. + +One downside to Google's approach is that *all* of your functions must have +a new first argument, but after clearing that hurdle everything else is much +better. + +If you aren't interested in this warning, read on. + +### Huhwaht? Why? ### + +Every so often, a thread shows up on the +[golang-nuts](https://groups.google.com/d/forum/golang-nuts) asking for some +form of goroutine-local-storage, or some kind of goroutine id, or some kind of +context. There are a few valid use cases for goroutine-local-storage, one of +the most prominent being log line context. One poster was interested in being +able to log an HTTP request context id in every log line in the same goroutine +as the incoming HTTP request, without having to change every library and +function call he was interested in logging. + +This would be pretty useful. Provided that you could get some kind of +goroutine-local-storage, you could call +[log.SetOutput](http://golang.org/pkg/log/#SetOutput) with your own logging +writer that checks goroutine-local-storage for some context information and +adds that context to your log lines. + +But alas, Andrew Gerrand's typically diplomatic answer to the question of +goroutine-local variables was: + +> We wouldn't even be having this discussion if thread local storage wasn't +> useful. But every feature comes at a cost, and in my opinion the cost of +> threadlocals far outweighs their benefits. They're just not a good fit for +> Go. + +So, yeah, that makes sense. That's a pretty good reason for why the language +won't support a specific and (relatively) unuseful feature that requires some +runtime changes, just for the sake of a little bit of log improvement. + +But does Go require runtime changes? + +### How it works ### + +Go has pretty fantastic introspective and reflective features, but one thing Go +doesn't give you is any kind of access to the stack pointer, or frame pointer, +or goroutine id, or anything contextual about your current stack. It gives you +access to your list of callers, but only along with program counters, which are +fixed at compile time. + +But it does give you the stack. + +So, we define 16 special functions and embed base-16 tags into the stack using +the call order of those 16 functions. Then, we can read our tags back out of +the stack looking at the callers list. + +We then use these tags as an index into a traditional map for implementing +this library. + +### What are people saying? ### + +"Wow, that's horrifying." + +"This is the most terrible thing I have seen in a very long time." + +"Where is it getting a context from? Is this serializing all the requests? +What the heck is the client being bound to? What are these tags? Why does he +need callers? Oh god no. No no no." + +### Docs ### + +Please see the docs at http://godoc.org/github.com/jtolds/gls + +### Related ### + +If you're okay relying on the string format of the current runtime stacktrace +including a unique goroutine id (not guaranteed by the spec or anything, but +very unlikely to change within a Go release), you might be able to squeeze +out a bit more performance by using this similar library, inspired by some +code Brad Fitzpatrick wrote for debugging his HTTP/2 library: +https://github.com/tylerb/gls (in contrast, jtolds/gls doesn't require +any knowledge of the string format of the runtime stacktrace, which +probably adds unnecessary overhead). diff --git a/Godeps/_workspace/src/github.com/jtolds/gls/context.go b/Godeps/_workspace/src/github.com/jtolds/gls/context.go new file mode 100644 index 0000000000..90cfcf7db1 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jtolds/gls/context.go @@ -0,0 +1,144 @@ +// Package gls implements goroutine-local storage. +package gls + +import ( + "sync" +) + +const ( + maxCallers = 64 +) + +var ( + stackTagPool = &idPool{} + mgrRegistry = make(map[*ContextManager]bool) + mgrRegistryMtx sync.RWMutex +) + +// Values is simply a map of key types to value types. Used by SetValues to +// set multiple values at once. +type Values map[interface{}]interface{} + +// ContextManager is the main entrypoint for interacting with +// Goroutine-local-storage. You can have multiple independent ContextManagers +// at any given time. ContextManagers are usually declared globally for a given +// class of context variables. You should use NewContextManager for +// construction. +type ContextManager struct { + mtx sync.RWMutex + values map[uint]Values +} + +// NewContextManager returns a brand new ContextManager. It also registers the +// new ContextManager in the ContextManager registry which is used by the Go +// method. ContextManagers are typically defined globally at package scope. +func NewContextManager() *ContextManager { + mgr := &ContextManager{values: make(map[uint]Values)} + mgrRegistryMtx.Lock() + defer mgrRegistryMtx.Unlock() + mgrRegistry[mgr] = true + return mgr +} + +// Unregister removes a ContextManager from the global registry, used by the +// Go method. Only intended for use when you're completely done with a +// ContextManager. Use of Unregister at all is rare. +func (m *ContextManager) Unregister() { + mgrRegistryMtx.Lock() + defer mgrRegistryMtx.Unlock() + delete(mgrRegistry, m) +} + +// SetValues takes a collection of values and a function to call for those +// values to be set in. Anything further down the stack will have the set +// values available through GetValue. SetValues will add new values or replace +// existing values of the same key and will not mutate or change values for +// previous stack frames. +// SetValues is slow (makes a copy of all current and new values for the new +// gls-context) in order to reduce the amount of lookups GetValue requires. +func (m *ContextManager) SetValues(new_values Values, context_call func()) { + if len(new_values) == 0 { + context_call() + return + } + + tags := readStackTags(1) + + m.mtx.Lock() + values := new_values + for _, tag := range tags { + if existing_values, ok := m.values[tag]; ok { + // oh, we found existing values, let's make a copy + values = make(Values, len(existing_values)+len(new_values)) + for key, val := range existing_values { + values[key] = val + } + for key, val := range new_values { + values[key] = val + } + break + } + } + new_tag := stackTagPool.Acquire() + m.values[new_tag] = values + m.mtx.Unlock() + defer func() { + m.mtx.Lock() + delete(m.values, new_tag) + m.mtx.Unlock() + stackTagPool.Release(new_tag) + }() + + addStackTag(new_tag, context_call) +} + +// GetValue will return a previously set value, provided that the value was set +// by SetValues somewhere higher up the stack. If the value is not found, ok +// will be false. +func (m *ContextManager) GetValue(key interface{}) (value interface{}, ok bool) { + + tags := readStackTags(1) + m.mtx.RLock() + defer m.mtx.RUnlock() + for _, tag := range tags { + if values, ok := m.values[tag]; ok { + value, ok := values[key] + return value, ok + } + } + return "", false +} + +func (m *ContextManager) getValues() Values { + tags := readStackTags(2) + m.mtx.RLock() + defer m.mtx.RUnlock() + for _, tag := range tags { + if values, ok := m.values[tag]; ok { + return values + } + } + return nil +} + +// Go preserves ContextManager values and Goroutine-local-storage across new +// goroutine invocations. The Go method makes a copy of all existing values on +// all registered context managers and makes sure they are still set after +// kicking off the provided function in a new goroutine. If you don't use this +// Go method instead of the standard 'go' keyword, you will lose values in +// ContextManagers, as goroutines have brand new stacks. +func Go(cb func()) { + mgrRegistryMtx.RLock() + defer mgrRegistryMtx.RUnlock() + + for mgr, _ := range mgrRegistry { + values := mgr.getValues() + if len(values) > 0 { + mgr_copy := mgr + cb_copy := cb + cb = func() { mgr_copy.SetValues(values, cb_copy) } + } + } + + go cb() +} diff --git a/Godeps/_workspace/src/github.com/jtolds/gls/gen_sym.go b/Godeps/_workspace/src/github.com/jtolds/gls/gen_sym.go new file mode 100644 index 0000000000..8d5fc24d4a --- /dev/null +++ b/Godeps/_workspace/src/github.com/jtolds/gls/gen_sym.go @@ -0,0 +1,13 @@ +package gls + +var ( + symPool = &idPool{} +) + +// ContextKey is a throwaway value you can use as a key to a ContextManager +type ContextKey struct{ id uint } + +// GenSym will return a brand new, never-before-used ContextKey +func GenSym() ContextKey { + return ContextKey{id: symPool.Acquire()} +} diff --git a/Godeps/_workspace/src/github.com/jtolds/gls/id_pool.go b/Godeps/_workspace/src/github.com/jtolds/gls/id_pool.go new file mode 100644 index 0000000000..b7974ae002 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jtolds/gls/id_pool.go @@ -0,0 +1,34 @@ +package gls + +// though this could probably be better at keeping ids smaller, the goal of +// this class is to keep a registry of the smallest unique integer ids +// per-process possible + +import ( + "sync" +) + +type idPool struct { + mtx sync.Mutex + released []uint + max_id uint +} + +func (p *idPool) Acquire() (id uint) { + p.mtx.Lock() + defer p.mtx.Unlock() + if len(p.released) > 0 { + id = p.released[len(p.released)-1] + p.released = p.released[:len(p.released)-1] + return id + } + id = p.max_id + p.max_id++ + return id +} + +func (p *idPool) Release(id uint) { + p.mtx.Lock() + defer p.mtx.Unlock() + p.released = append(p.released, id) +} diff --git a/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags.go b/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags.go new file mode 100644 index 0000000000..9b8e39ba7c --- /dev/null +++ b/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags.go @@ -0,0 +1,43 @@ +package gls + +// so, basically, we're going to encode integer tags in base-16 on the stack + +const ( + bitWidth = 4 +) + +func addStackTag(tag uint, context_call func()) { + if context_call == nil { + return + } + markS(tag, context_call) +} + +func markS(tag uint, cb func()) { _m(tag, cb) } +func mark0(tag uint, cb func()) { _m(tag, cb) } +func mark1(tag uint, cb func()) { _m(tag, cb) } +func mark2(tag uint, cb func()) { _m(tag, cb) } +func mark3(tag uint, cb func()) { _m(tag, cb) } +func mark4(tag uint, cb func()) { _m(tag, cb) } +func mark5(tag uint, cb func()) { _m(tag, cb) } +func mark6(tag uint, cb func()) { _m(tag, cb) } +func mark7(tag uint, cb func()) { _m(tag, cb) } +func mark8(tag uint, cb func()) { _m(tag, cb) } +func mark9(tag uint, cb func()) { _m(tag, cb) } +func markA(tag uint, cb func()) { _m(tag, cb) } +func markB(tag uint, cb func()) { _m(tag, cb) } +func markC(tag uint, cb func()) { _m(tag, cb) } +func markD(tag uint, cb func()) { _m(tag, cb) } +func markE(tag uint, cb func()) { _m(tag, cb) } +func markF(tag uint, cb func()) { _m(tag, cb) } + +var pc_lookup = make(map[uintptr]int8, 17) +var mark_lookup [16]func(uint, func()) + +func _m(tag_remainder uint, cb func()) { + if tag_remainder == 0 { + cb() + } else { + mark_lookup[tag_remainder&0xf](tag_remainder>>bitWidth, cb) + } +} diff --git a/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags_js.go b/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags_js.go new file mode 100644 index 0000000000..21d5595926 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags_js.go @@ -0,0 +1,101 @@ +// +build js + +package gls + +// This file is used for GopherJS builds, which don't have normal runtime support + +import ( + "regexp" + "strconv" + "strings" + + "github.com/gopherjs/gopherjs/js" +) + +var stackRE = regexp.MustCompile("\\s+at (\\S*) \\([^:]+:(\\d+):(\\d+)") + +func findPtr() uintptr { + jsStack := js.Global.Get("Error").New().Get("stack").Call("split", "\n") + for i := 1; i < jsStack.Get("length").Int(); i++ { + item := jsStack.Index(i).String() + matches := stackRE.FindAllStringSubmatch(item, -1) + if matches == nil { + return 0 + } + pkgPath := matches[0][1] + if strings.HasPrefix(pkgPath, "$packages.github.com/jtolds/gls.mark") { + line, _ := strconv.Atoi(matches[0][2]) + char, _ := strconv.Atoi(matches[0][3]) + x := (uintptr(line) << 16) | uintptr(char) + return x + } + } + + return 0 +} + +func init() { + setEntries := func(f func(uint, func()), v int8) { + var ptr uintptr + f(0, func() { + ptr = findPtr() + }) + pc_lookup[ptr] = v + if v >= 0 { + mark_lookup[v] = f + } + } + setEntries(markS, -0x1) + setEntries(mark0, 0x0) + setEntries(mark1, 0x1) + setEntries(mark2, 0x2) + setEntries(mark3, 0x3) + setEntries(mark4, 0x4) + setEntries(mark5, 0x5) + setEntries(mark6, 0x6) + setEntries(mark7, 0x7) + setEntries(mark8, 0x8) + setEntries(mark9, 0x9) + setEntries(markA, 0xa) + setEntries(markB, 0xb) + setEntries(markC, 0xc) + setEntries(markD, 0xd) + setEntries(markE, 0xe) + setEntries(markF, 0xf) +} + +func currentStack(skip int) (stack []uintptr) { + jsStack := js.Global.Get("Error").New().Get("stack").Call("split", "\n") + for i := skip + 2; i < jsStack.Get("length").Int(); i++ { + item := jsStack.Index(i).String() + matches := stackRE.FindAllStringSubmatch(item, -1) + if matches == nil { + return stack + } + line, _ := strconv.Atoi(matches[0][2]) + char, _ := strconv.Atoi(matches[0][3]) + x := (uintptr(line) << 16) | uintptr(char)&0xffff + stack = append(stack, x) + } + + return stack +} + +func readStackTags(skip int) (tags []uint) { + stack := currentStack(skip) + var current_tag uint + for _, pc := range stack { + val, ok := pc_lookup[pc] + if !ok { + continue + } + if val < 0 { + tags = append(tags, current_tag) + current_tag = 0 + continue + } + current_tag <<= bitWidth + current_tag += uint(val) + } + return +} diff --git a/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags_main.go b/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags_main.go new file mode 100644 index 0000000000..cb302b9ef6 --- /dev/null +++ b/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags_main.go @@ -0,0 +1,61 @@ +// +build !js + +package gls + +// This file is used for standard Go builds, which have the expected runtime support + +import ( + "reflect" + "runtime" +) + +func init() { + setEntries := func(f func(uint, func()), v int8) { + pc_lookup[reflect.ValueOf(f).Pointer()] = v + if v >= 0 { + mark_lookup[v] = f + } + } + setEntries(markS, -0x1) + setEntries(mark0, 0x0) + setEntries(mark1, 0x1) + setEntries(mark2, 0x2) + setEntries(mark3, 0x3) + setEntries(mark4, 0x4) + setEntries(mark5, 0x5) + setEntries(mark6, 0x6) + setEntries(mark7, 0x7) + setEntries(mark8, 0x8) + setEntries(mark9, 0x9) + setEntries(markA, 0xa) + setEntries(markB, 0xb) + setEntries(markC, 0xc) + setEntries(markD, 0xd) + setEntries(markE, 0xe) + setEntries(markF, 0xf) +} + +func currentStack(skip int) []uintptr { + stack := make([]uintptr, maxCallers) + return stack[:runtime.Callers(3+skip, stack)] +} + +func readStackTags(skip int) (tags []uint) { + stack := currentStack(skip) + var current_tag uint + for _, pc := range stack { + pc = runtime.FuncForPC(pc).Entry() + val, ok := pc_lookup[pc] + if !ok { + continue + } + if val < 0 { + tags = append(tags, current_tag) + current_tag = 0 + continue + } + current_tag <<= bitWidth + current_tag += uint(val) + } + return +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/.gitignore b/Godeps/_workspace/src/github.com/smartystreets/assertions/.gitignore new file mode 100644 index 0000000000..6ad551742d --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/.gitignore @@ -0,0 +1,3 @@ +.DS_Store +Thumbs.db +/.idea diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/.travis.yml b/Godeps/_workspace/src/github.com/smartystreets/assertions/.travis.yml new file mode 100644 index 0000000000..44217c9733 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/.travis.yml @@ -0,0 +1,14 @@ +language: go + +go: + - 1.2 + - 1.3 + - 1.4 + - 1.5 + +install: + - go get -t ./... + +script: go test -v + +sudo: false diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/CONTRIBUTING.md b/Godeps/_workspace/src/github.com/smartystreets/assertions/CONTRIBUTING.md new file mode 100644 index 0000000000..1820ecb331 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/CONTRIBUTING.md @@ -0,0 +1,12 @@ +# Contributing + +In general, the code posted to the [SmartyStreets github organization](https://github.com/smartystreets) is created to solve specific problems at SmartyStreets that are ancillary to our core products in the address verification industry and may or may not be useful to other organizations or developers. Our reason for posting said code isn't necessarily to solicit feedback or contributions from the community but more as a showcase of some of the approaches to solving problems we have adopted. + +Having stated that, we do consider issues raised by other githubbers as well as contributions submitted via pull requests. When submitting such a pull request, please follow these guidelines: + +- _Look before you leap:_ If the changes you plan to make are significant, it's in everyone's best interest for you to discuss them with a SmartyStreets team member prior to opening a pull request. +- _License and ownership:_ If modifying the `LICENSE.md` file, limit your changes to fixing typographical mistakes. Do NOT modify the actual terms in the license or the copyright by **SmartyStreets, LLC**. Code submitted to SmartyStreets projects becomes property of SmartyStreets and must be compatible with the associated license. +- _Testing:_ If the code you are submitting resides in packages/modules covered by automated tests, be sure to add passing tests that cover your changes and assert expected behavior and state. Submit the additional test cases as part of your change set. +- _Style:_ Match your approach to **naming** and **formatting** with the surrounding code. Basically, the code you submit shouldn't stand out. + - "Naming" refers to such constructs as variables, methods, functions, classes, structs, interfaces, packages, modules, directories, files, etc... + - "Formatting" refers to such constructs as whitespace, horizontal line length, vertical function length, vertical file length, indentation, curly braces, etc... diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/LICENSE.md b/Godeps/_workspace/src/github.com/smartystreets/assertions/LICENSE.md new file mode 100644 index 0000000000..8ea6f94552 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/LICENSE.md @@ -0,0 +1,23 @@ +Copyright (c) 2016 SmartyStreets, LLC + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +NOTE: Various optional and subordinate components carry their own licensing +requirements and restrictions. Use of those components is subject to the terms +and conditions outlined the respective license of each component. diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/README.md b/Godeps/_workspace/src/github.com/smartystreets/assertions/README.md new file mode 100644 index 0000000000..58383bb00a --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/README.md @@ -0,0 +1,575 @@ +# assertions +-- + import "github.com/smartystreets/assertions" + +Package assertions contains the implementations for all assertions which are +referenced in goconvey's `convey` package +(github.com/smartystreets/goconvey/convey) and gunit +(github.com/smartystreets/gunit) for use with the So(...) method. They can also +be used in traditional Go test functions and even in applications. + +Many of the assertions lean heavily on work done by Aaron Jacobs in his +excellent oglematchers library. (https://github.com/jacobsa/oglematchers) The +ShouldResemble assertion leans heavily on work done by Daniel Jacques in his +very helpful go-render library. (https://github.com/luci/go-render) + +## Usage + +#### func GoConveyMode + +```go +func GoConveyMode(yes bool) +``` +GoConveyMode provides control over JSON serialization of failures. When using +the assertions in this package from the convey package JSON results are very +helpful and can be rendered in a DIFF view. In that case, this function will be +called with a true value to enable the JSON serialization. By default, the +assertions in this package will not serializer a JSON result, making standalone +ussage more convenient. + +#### func ShouldAlmostEqual + +```go +func ShouldAlmostEqual(actual interface{}, expected ...interface{}) string +``` +ShouldAlmostEqual makes sure that two parameters are close enough to being +equal. The acceptable delta may be specified with a third argument, or a very +small default delta will be used. + +#### func ShouldBeBetween + +```go +func ShouldBeBetween(actual interface{}, expected ...interface{}) string +``` +ShouldBeBetween receives exactly three parameters: an actual value, a lower +bound, and an upper bound. It ensures that the actual value is between both +bounds (but not equal to either of them). + +#### func ShouldBeBetweenOrEqual + +```go +func ShouldBeBetweenOrEqual(actual interface{}, expected ...interface{}) string +``` +ShouldBeBetweenOrEqual receives exactly three parameters: an actual value, a +lower bound, and an upper bound. It ensures that the actual value is between +both bounds or equal to one of them. + +#### func ShouldBeBlank + +```go +func ShouldBeBlank(actual interface{}, expected ...interface{}) string +``` +ShouldBeBlank receives exactly 1 string parameter and ensures that it is equal +to "". + +#### func ShouldBeChronological + +```go +func ShouldBeChronological(actual interface{}, expected ...interface{}) string +``` +ShouldBeChronological receives a []time.Time slice and asserts that the are in +chronological order starting with the first time.Time as the earliest. + +#### func ShouldBeEmpty + +```go +func ShouldBeEmpty(actual interface{}, expected ...interface{}) string +``` +ShouldBeEmpty receives a single parameter (actual) and determines whether or not +calling len(actual) would return `0`. It obeys the rules specified by the len +function for determining length: http://golang.org/pkg/builtin/#len + +#### func ShouldBeFalse + +```go +func ShouldBeFalse(actual interface{}, expected ...interface{}) string +``` +ShouldBeFalse receives a single parameter and ensures that it is false. + +#### func ShouldBeGreaterThan + +```go +func ShouldBeGreaterThan(actual interface{}, expected ...interface{}) string +``` +ShouldBeGreaterThan receives exactly two parameters and ensures that the first +is greater than the second. + +#### func ShouldBeGreaterThanOrEqualTo + +```go +func ShouldBeGreaterThanOrEqualTo(actual interface{}, expected ...interface{}) string +``` +ShouldBeGreaterThanOrEqualTo receives exactly two parameters and ensures that +the first is greater than or equal to the second. + +#### func ShouldBeIn + +```go +func ShouldBeIn(actual interface{}, expected ...interface{}) string +``` +ShouldBeIn receives at least 2 parameters. The first is a proposed member of the +collection that is passed in either as the second parameter, or of the +collection that is comprised of all the remaining parameters. This assertion +ensures that the proposed member is in the collection (using ShouldEqual). + +#### func ShouldBeLessThan + +```go +func ShouldBeLessThan(actual interface{}, expected ...interface{}) string +``` +ShouldBeLessThan receives exactly two parameters and ensures that the first is +less than the second. + +#### func ShouldBeLessThanOrEqualTo + +```go +func ShouldBeLessThanOrEqualTo(actual interface{}, expected ...interface{}) string +``` +ShouldBeLessThan receives exactly two parameters and ensures that the first is +less than or equal to the second. + +#### func ShouldBeNil + +```go +func ShouldBeNil(actual interface{}, expected ...interface{}) string +``` +ShouldBeNil receives a single parameter and ensures that it is nil. + +#### func ShouldBeTrue + +```go +func ShouldBeTrue(actual interface{}, expected ...interface{}) string +``` +ShouldBeTrue receives a single parameter and ensures that it is true. + +#### func ShouldBeZeroValue + +```go +func ShouldBeZeroValue(actual interface{}, expected ...interface{}) string +``` +ShouldBeZeroValue receives a single parameter and ensures that it is the Go +equivalent of the default value, or "zero" value. + +#### func ShouldContain + +```go +func ShouldContain(actual interface{}, expected ...interface{}) string +``` +ShouldContain receives exactly two parameters. The first is a slice and the +second is a proposed member. Membership is determined using ShouldEqual. + +#### func ShouldContainKey + +```go +func ShouldContainKey(actual interface{}, expected ...interface{}) string +``` +ShouldContainKey receives exactly two parameters. The first is a map and the +second is a proposed key. Keys are compared with a simple '=='. + +#### func ShouldContainSubstring + +```go +func ShouldContainSubstring(actual interface{}, expected ...interface{}) string +``` +ShouldContainSubstring receives exactly 2 string parameters and ensures that the +first contains the second as a substring. + +#### func ShouldEndWith + +```go +func ShouldEndWith(actual interface{}, expected ...interface{}) string +``` +ShouldEndWith receives exactly 2 string parameters and ensures that the first +ends with the second. + +#### func ShouldEqual + +```go +func ShouldEqual(actual interface{}, expected ...interface{}) string +``` +ShouldEqual receives exactly two parameters and does an equality check. + +#### func ShouldEqualTrimSpace + +```go +func ShouldEqualTrimSpace(actual interface{}, expected ...interface{}) string +``` +ShouldEqualTrimSpace receives exactly 2 string parameters and ensures that the +first is equal to the second after removing all leading and trailing whitespace +using strings.TrimSpace(first). + +#### func ShouldEqualWithout + +```go +func ShouldEqualWithout(actual interface{}, expected ...interface{}) string +``` +ShouldEqualWithout receives exactly 3 string parameters and ensures that the +first is equal to the second after removing all instances of the third from the +first using strings.Replace(first, third, "", -1). + +#### func ShouldHappenAfter + +```go +func ShouldHappenAfter(actual interface{}, expected ...interface{}) string +``` +ShouldHappenAfter receives exactly 2 time.Time arguments and asserts that the +first happens after the second. + +#### func ShouldHappenBefore + +```go +func ShouldHappenBefore(actual interface{}, expected ...interface{}) string +``` +ShouldHappenBefore receives exactly 2 time.Time arguments and asserts that the +first happens before the second. + +#### func ShouldHappenBetween + +```go +func ShouldHappenBetween(actual interface{}, expected ...interface{}) string +``` +ShouldHappenBetween receives exactly 3 time.Time arguments and asserts that the +first happens between (not on) the second and third. + +#### func ShouldHappenOnOrAfter + +```go +func ShouldHappenOnOrAfter(actual interface{}, expected ...interface{}) string +``` +ShouldHappenOnOrAfter receives exactly 2 time.Time arguments and asserts that +the first happens on or after the second. + +#### func ShouldHappenOnOrBefore + +```go +func ShouldHappenOnOrBefore(actual interface{}, expected ...interface{}) string +``` +ShouldHappenOnOrBefore receives exactly 2 time.Time arguments and asserts that +the first happens on or before the second. + +#### func ShouldHappenOnOrBetween + +```go +func ShouldHappenOnOrBetween(actual interface{}, expected ...interface{}) string +``` +ShouldHappenOnOrBetween receives exactly 3 time.Time arguments and asserts that +the first happens between or on the second and third. + +#### func ShouldHappenWithin + +```go +func ShouldHappenWithin(actual interface{}, expected ...interface{}) string +``` +ShouldHappenWithin receives a time.Time, a time.Duration, and a time.Time (3 +arguments) and asserts that the first time.Time happens within or on the +duration specified relative to the other time.Time. + +#### func ShouldHaveLength + +```go +func ShouldHaveLength(actual interface{}, expected ...interface{}) string +``` +ShouldHaveLength receives 2 parameters. The first is a collection to check the +length of, the second being the expected length. It obeys the rules specified by +the len function for determining length: http://golang.org/pkg/builtin/#len + +#### func ShouldHaveSameTypeAs + +```go +func ShouldHaveSameTypeAs(actual interface{}, expected ...interface{}) string +``` +ShouldHaveSameTypeAs receives exactly two parameters and compares their +underlying types for equality. + +#### func ShouldImplement + +```go +func ShouldImplement(actual interface{}, expectedList ...interface{}) string +``` +ShouldImplement receives exactly two parameters and ensures that the first +implements the interface type of the second. + +#### func ShouldNotAlmostEqual + +```go +func ShouldNotAlmostEqual(actual interface{}, expected ...interface{}) string +``` +ShouldNotAlmostEqual is the inverse of ShouldAlmostEqual + +#### func ShouldNotBeBetween + +```go +func ShouldNotBeBetween(actual interface{}, expected ...interface{}) string +``` +ShouldNotBeBetween receives exactly three parameters: an actual value, a lower +bound, and an upper bound. It ensures that the actual value is NOT between both +bounds. + +#### func ShouldNotBeBetweenOrEqual + +```go +func ShouldNotBeBetweenOrEqual(actual interface{}, expected ...interface{}) string +``` +ShouldNotBeBetweenOrEqual receives exactly three parameters: an actual value, a +lower bound, and an upper bound. It ensures that the actual value is nopt +between the bounds nor equal to either of them. + +#### func ShouldNotBeBlank + +```go +func ShouldNotBeBlank(actual interface{}, expected ...interface{}) string +``` +ShouldNotBeBlank receives exactly 1 string parameter and ensures that it is +equal to "". + +#### func ShouldNotBeEmpty + +```go +func ShouldNotBeEmpty(actual interface{}, expected ...interface{}) string +``` +ShouldNotBeEmpty receives a single parameter (actual) and determines whether or +not calling len(actual) would return a value greater than zero. It obeys the +rules specified by the `len` function for determining length: +http://golang.org/pkg/builtin/#len + +#### func ShouldNotBeIn + +```go +func ShouldNotBeIn(actual interface{}, expected ...interface{}) string +``` +ShouldNotBeIn receives at least 2 parameters. The first is a proposed member of +the collection that is passed in either as the second parameter, or of the +collection that is comprised of all the remaining parameters. This assertion +ensures that the proposed member is NOT in the collection (using ShouldEqual). + +#### func ShouldNotBeNil + +```go +func ShouldNotBeNil(actual interface{}, expected ...interface{}) string +``` +ShouldNotBeNil receives a single parameter and ensures that it is not nil. + +#### func ShouldNotContain + +```go +func ShouldNotContain(actual interface{}, expected ...interface{}) string +``` +ShouldNotContain receives exactly two parameters. The first is a slice and the +second is a proposed member. Membership is determinied using ShouldEqual. + +#### func ShouldNotContainKey + +```go +func ShouldNotContainKey(actual interface{}, expected ...interface{}) string +``` +ShouldNotContainKey receives exactly two parameters. The first is a map and the +second is a proposed absent key. Keys are compared with a simple '=='. + +#### func ShouldNotContainSubstring + +```go +func ShouldNotContainSubstring(actual interface{}, expected ...interface{}) string +``` +ShouldNotContainSubstring receives exactly 2 string parameters and ensures that +the first does NOT contain the second as a substring. + +#### func ShouldNotEndWith + +```go +func ShouldNotEndWith(actual interface{}, expected ...interface{}) string +``` +ShouldEndWith receives exactly 2 string parameters and ensures that the first +does not end with the second. + +#### func ShouldNotEqual + +```go +func ShouldNotEqual(actual interface{}, expected ...interface{}) string +``` +ShouldNotEqual receives exactly two parameters and does an inequality check. + +#### func ShouldNotHappenOnOrBetween + +```go +func ShouldNotHappenOnOrBetween(actual interface{}, expected ...interface{}) string +``` +ShouldNotHappenOnOrBetween receives exactly 3 time.Time arguments and asserts +that the first does NOT happen between or on the second or third. + +#### func ShouldNotHappenWithin + +```go +func ShouldNotHappenWithin(actual interface{}, expected ...interface{}) string +``` +ShouldNotHappenWithin receives a time.Time, a time.Duration, and a time.Time (3 +arguments) and asserts that the first time.Time does NOT happen within or on the +duration specified relative to the other time.Time. + +#### func ShouldNotHaveSameTypeAs + +```go +func ShouldNotHaveSameTypeAs(actual interface{}, expected ...interface{}) string +``` +ShouldNotHaveSameTypeAs receives exactly two parameters and compares their +underlying types for inequality. + +#### func ShouldNotImplement + +```go +func ShouldNotImplement(actual interface{}, expectedList ...interface{}) string +``` +ShouldNotImplement receives exactly two parameters and ensures that the first +does NOT implement the interface type of the second. + +#### func ShouldNotPanic + +```go +func ShouldNotPanic(actual interface{}, expected ...interface{}) (message string) +``` +ShouldNotPanic receives a void, niladic function and expects to execute the +function without any panic. + +#### func ShouldNotPanicWith + +```go +func ShouldNotPanicWith(actual interface{}, expected ...interface{}) (message string) +``` +ShouldNotPanicWith receives a void, niladic function and expects to recover a +panic whose content differs from the second argument. + +#### func ShouldNotPointTo + +```go +func ShouldNotPointTo(actual interface{}, expected ...interface{}) string +``` +ShouldNotPointTo receives exactly two parameters and checks to see that they +point to different addresess. + +#### func ShouldNotResemble + +```go +func ShouldNotResemble(actual interface{}, expected ...interface{}) string +``` +ShouldNotResemble receives exactly two parameters and does an inverse deep equal +check (see reflect.DeepEqual) + +#### func ShouldNotStartWith + +```go +func ShouldNotStartWith(actual interface{}, expected ...interface{}) string +``` +ShouldNotStartWith receives exactly 2 string parameters and ensures that the +first does not start with the second. + +#### func ShouldPanic + +```go +func ShouldPanic(actual interface{}, expected ...interface{}) (message string) +``` +ShouldPanic receives a void, niladic function and expects to recover a panic. + +#### func ShouldPanicWith + +```go +func ShouldPanicWith(actual interface{}, expected ...interface{}) (message string) +``` +ShouldPanicWith receives a void, niladic function and expects to recover a panic +with the second argument as the content. + +#### func ShouldPointTo + +```go +func ShouldPointTo(actual interface{}, expected ...interface{}) string +``` +ShouldPointTo receives exactly two parameters and checks to see that they point +to the same address. + +#### func ShouldResemble + +```go +func ShouldResemble(actual interface{}, expected ...interface{}) string +``` +ShouldResemble receives exactly two parameters and does a deep equal check (see +reflect.DeepEqual) + +#### func ShouldStartWith + +```go +func ShouldStartWith(actual interface{}, expected ...interface{}) string +``` +ShouldStartWith receives exactly 2 string parameters and ensures that the first +starts with the second. + +#### func So + +```go +func So(actual interface{}, assert assertion, expected ...interface{}) (bool, string) +``` +So is a convenience function (as opposed to an inconvenience function?) for +running assertions on arbitrary arguments in any context, be it for testing or +even application logging. It allows you to perform assertion-like behavior (and +get nicely formatted messages detailing discrepancies) but without the program +blowing up or panicking. All that is required is to import this package and call +`So` with one of the assertions exported by this package as the second +parameter. The first return parameter is a boolean indicating if the assertion +was true. The second return parameter is the well-formatted message showing why +an assertion was incorrect, or blank if the assertion was correct. + +Example: + + if ok, message := So(x, ShouldBeGreaterThan, y); !ok { + log.Println(message) + } + +#### type Assertion + +```go +type Assertion struct { +} +``` + + +#### func New + +```go +func New(t testingT) *Assertion +``` +New swallows the *testing.T struct and prints failed assertions using t.Error. +Example: assertions.New(t).So(1, should.Equal, 1) + +#### func (*Assertion) Failed + +```go +func (this *Assertion) Failed() bool +``` +Failed reports whether any calls to So (on this Assertion instance) have failed. + +#### func (*Assertion) So + +```go +func (this *Assertion) So(actual interface{}, assert assertion, expected ...interface{}) bool +``` +So calls the standalone So function and additionally, calls t.Error in failure +scenarios. + +#### type FailureView + +```go +type FailureView struct { + Message string `json:"Message"` + Expected string `json:"Expected"` + Actual string `json:"Actual"` +} +``` + +This struct is also declared in +github.com/smartystreets/goconvey/convey/reporting. The json struct tags should +be equal in both declarations. + +#### type Serializer + +```go +type Serializer interface { + // contains filtered or unexported methods +} +``` diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/assertions.goconvey b/Godeps/_workspace/src/github.com/smartystreets/assertions/assertions.goconvey new file mode 100644 index 0000000000..e76cf275d4 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/assertions.goconvey @@ -0,0 +1,3 @@ +#ignore +-timeout=1s +-coverpkg=github.com/smartystreets/assertions,github.com/smartystreets/assertions/internal/oglematchers \ No newline at end of file diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/collections.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/collections.go new file mode 100644 index 0000000000..d7f407e913 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/collections.go @@ -0,0 +1,244 @@ +package assertions + +import ( + "fmt" + "reflect" + + "github.com/smartystreets/assertions/internal/oglematchers" +) + +// ShouldContain receives exactly two parameters. The first is a slice and the +// second is a proposed member. Membership is determined using ShouldEqual. +func ShouldContain(actual interface{}, expected ...interface{}) string { + if fail := need(1, expected); fail != success { + return fail + } + + if matchError := oglematchers.Contains(expected[0]).Matches(actual); matchError != nil { + typeName := reflect.TypeOf(actual) + + if fmt.Sprintf("%v", matchError) == "which is not a slice or array" { + return fmt.Sprintf(shouldHaveBeenAValidCollection, typeName) + } + return fmt.Sprintf(shouldHaveContained, typeName, expected[0]) + } + return success +} + +// ShouldNotContain receives exactly two parameters. The first is a slice and the +// second is a proposed member. Membership is determinied using ShouldEqual. +func ShouldNotContain(actual interface{}, expected ...interface{}) string { + if fail := need(1, expected); fail != success { + return fail + } + typeName := reflect.TypeOf(actual) + + if matchError := oglematchers.Contains(expected[0]).Matches(actual); matchError != nil { + if fmt.Sprintf("%v", matchError) == "which is not a slice or array" { + return fmt.Sprintf(shouldHaveBeenAValidCollection, typeName) + } + return success + } + return fmt.Sprintf(shouldNotHaveContained, typeName, expected[0]) +} + +// ShouldContainKey receives exactly two parameters. The first is a map and the +// second is a proposed key. Keys are compared with a simple '=='. +func ShouldContainKey(actual interface{}, expected ...interface{}) string { + if fail := need(1, expected); fail != success { + return fail + } + + keys, isMap := mapKeys(actual) + if !isMap { + return fmt.Sprintf(shouldHaveBeenAValidMap, reflect.TypeOf(actual)) + } + + if !keyFound(keys, expected[0]) { + return fmt.Sprintf(shouldHaveContainedKey, reflect.TypeOf(actual), expected) + } + + return "" +} + +// ShouldNotContainKey receives exactly two parameters. The first is a map and the +// second is a proposed absent key. Keys are compared with a simple '=='. +func ShouldNotContainKey(actual interface{}, expected ...interface{}) string { + if fail := need(1, expected); fail != success { + return fail + } + + keys, isMap := mapKeys(actual) + if !isMap { + return fmt.Sprintf(shouldHaveBeenAValidMap, reflect.TypeOf(actual)) + } + + if keyFound(keys, expected[0]) { + return fmt.Sprintf(shouldNotHaveContainedKey, reflect.TypeOf(actual), expected) + } + + return "" +} + +func mapKeys(m interface{}) ([]reflect.Value, bool) { + value := reflect.ValueOf(m) + if value.Kind() != reflect.Map { + return nil, false + } + return value.MapKeys(), true +} +func keyFound(keys []reflect.Value, expectedKey interface{}) bool { + found := false + for _, key := range keys { + if key.Interface() == expectedKey { + found = true + } + } + return found +} + +// ShouldBeIn receives at least 2 parameters. The first is a proposed member of the collection +// that is passed in either as the second parameter, or of the collection that is comprised +// of all the remaining parameters. This assertion ensures that the proposed member is in +// the collection (using ShouldEqual). +func ShouldBeIn(actual interface{}, expected ...interface{}) string { + if fail := atLeast(1, expected); fail != success { + return fail + } + + if len(expected) == 1 { + return shouldBeIn(actual, expected[0]) + } + return shouldBeIn(actual, expected) +} +func shouldBeIn(actual interface{}, expected interface{}) string { + if matchError := oglematchers.Contains(actual).Matches(expected); matchError != nil { + return fmt.Sprintf(shouldHaveBeenIn, actual, reflect.TypeOf(expected)) + } + return success +} + +// ShouldNotBeIn receives at least 2 parameters. The first is a proposed member of the collection +// that is passed in either as the second parameter, or of the collection that is comprised +// of all the remaining parameters. This assertion ensures that the proposed member is NOT in +// the collection (using ShouldEqual). +func ShouldNotBeIn(actual interface{}, expected ...interface{}) string { + if fail := atLeast(1, expected); fail != success { + return fail + } + + if len(expected) == 1 { + return shouldNotBeIn(actual, expected[0]) + } + return shouldNotBeIn(actual, expected) +} +func shouldNotBeIn(actual interface{}, expected interface{}) string { + if matchError := oglematchers.Contains(actual).Matches(expected); matchError == nil { + return fmt.Sprintf(shouldNotHaveBeenIn, actual, reflect.TypeOf(expected)) + } + return success +} + +// ShouldBeEmpty receives a single parameter (actual) and determines whether or not +// calling len(actual) would return `0`. It obeys the rules specified by the len +// function for determining length: http://golang.org/pkg/builtin/#len +func ShouldBeEmpty(actual interface{}, expected ...interface{}) string { + if fail := need(0, expected); fail != success { + return fail + } + + if actual == nil { + return success + } + + value := reflect.ValueOf(actual) + switch value.Kind() { + case reflect.Slice: + if value.Len() == 0 { + return success + } + case reflect.Chan: + if value.Len() == 0 { + return success + } + case reflect.Map: + if value.Len() == 0 { + return success + } + case reflect.String: + if value.Len() == 0 { + return success + } + case reflect.Ptr: + elem := value.Elem() + kind := elem.Kind() + if (kind == reflect.Slice || kind == reflect.Array) && elem.Len() == 0 { + return success + } + } + + return fmt.Sprintf(shouldHaveBeenEmpty, actual) +} + +// ShouldNotBeEmpty receives a single parameter (actual) and determines whether or not +// calling len(actual) would return a value greater than zero. It obeys the rules +// specified by the `len` function for determining length: http://golang.org/pkg/builtin/#len +func ShouldNotBeEmpty(actual interface{}, expected ...interface{}) string { + if fail := need(0, expected); fail != success { + return fail + } + + if empty := ShouldBeEmpty(actual, expected...); empty != success { + return success + } + return fmt.Sprintf(shouldNotHaveBeenEmpty, actual) +} + +// ShouldHaveLength receives 2 parameters. The first is a collection to check +// the length of, the second being the expected length. It obeys the rules +// specified by the len function for determining length: +// http://golang.org/pkg/builtin/#len +func ShouldHaveLength(actual interface{}, expected ...interface{}) string { + if fail := need(1, expected); fail != success { + return fail + } + + var expectedLen int64 + lenValue := reflect.ValueOf(expected[0]) + switch lenValue.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + expectedLen = lenValue.Int() + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + expectedLen = int64(lenValue.Uint()) + default: + return fmt.Sprintf(shouldHaveBeenAValidInteger, reflect.TypeOf(expected[0])) + } + + if expectedLen < 0 { + return fmt.Sprintf(shouldHaveBeenAValidLength, expected[0]) + } + + value := reflect.ValueOf(actual) + switch value.Kind() { + case reflect.Slice, + reflect.Chan, + reflect.Map, + reflect.String: + if int64(value.Len()) == expectedLen { + return success + } else { + return fmt.Sprintf(shouldHaveHadLength, actual, value.Len(), expectedLen) + } + case reflect.Ptr: + elem := value.Elem() + kind := elem.Kind() + if kind == reflect.Slice || kind == reflect.Array { + if int64(elem.Len()) == expectedLen { + return success + } else { + return fmt.Sprintf(shouldHaveHadLength, actual, elem.Len(), expectedLen) + } + } + } + return fmt.Sprintf(shouldHaveBeenAValidCollection, reflect.TypeOf(actual)) +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/doc.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/doc.go new file mode 100644 index 0000000000..5720fc298c --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/doc.go @@ -0,0 +1,105 @@ +// Package assertions contains the implementations for all assertions which +// are referenced in goconvey's `convey` package +// (github.com/smartystreets/goconvey/convey) and gunit (github.com/smartystreets/gunit) +// for use with the So(...) method. +// They can also be used in traditional Go test functions and even in +// applications. +// +// Many of the assertions lean heavily on work done by Aaron Jacobs in his excellent oglematchers library. +// (https://github.com/jacobsa/oglematchers) +// The ShouldResemble assertion leans heavily on work done by Daniel Jacques in his very helpful go-render library. +// (https://github.com/luci/go-render) +package assertions + +import ( + "fmt" + "runtime" +) + +// By default we use a no-op serializer. The actual Serializer provides a JSON +// representation of failure results on selected assertions so the goconvey +// web UI can display a convenient diff. +var serializer Serializer = new(noopSerializer) + +// GoConveyMode provides control over JSON serialization of failures. When +// using the assertions in this package from the convey package JSON results +// are very helpful and can be rendered in a DIFF view. In that case, this function +// will be called with a true value to enable the JSON serialization. By default, +// the assertions in this package will not serializer a JSON result, making +// standalone ussage more convenient. +func GoConveyMode(yes bool) { + if yes { + serializer = newSerializer() + } else { + serializer = new(noopSerializer) + } +} + +type testingT interface { + Error(args ...interface{}) +} + +type Assertion struct { + t testingT + failed bool +} + +// New swallows the *testing.T struct and prints failed assertions using t.Error. +// Example: assertions.New(t).So(1, should.Equal, 1) +func New(t testingT) *Assertion { + return &Assertion{t: t} +} + +// Failed reports whether any calls to So (on this Assertion instance) have failed. +func (this *Assertion) Failed() bool { + return this.failed +} + +// So calls the standalone So function and additionally, calls t.Error in failure scenarios. +func (this *Assertion) So(actual interface{}, assert assertion, expected ...interface{}) bool { + ok, result := So(actual, assert, expected...) + if !ok { + this.failed = true + _, file, line, _ := runtime.Caller(1) + this.t.Error(fmt.Sprintf("\n%s:%d\n%s", file, line, result)) + } + return ok +} + +// So is a convenience function (as opposed to an inconvenience function?) +// for running assertions on arbitrary arguments in any context, be it for testing or even +// application logging. It allows you to perform assertion-like behavior (and get nicely +// formatted messages detailing discrepancies) but without the program blowing up or panicking. +// All that is required is to import this package and call `So` with one of the assertions +// exported by this package as the second parameter. +// The first return parameter is a boolean indicating if the assertion was true. The second +// return parameter is the well-formatted message showing why an assertion was incorrect, or +// blank if the assertion was correct. +// +// Example: +// +// if ok, message := So(x, ShouldBeGreaterThan, y); !ok { +// log.Println(message) +// } +// +func So(actual interface{}, assert assertion, expected ...interface{}) (bool, string) { + if result := so(actual, assert, expected...); len(result) == 0 { + return true, result + } else { + return false, result + } +} + +// so is like So, except that it only returns the string message, which is blank if the +// assertion passed. Used to facilitate testing. +func so(actual interface{}, assert func(interface{}, ...interface{}) string, expected ...interface{}) string { + return assert(actual, expected...) +} + +// assertion is an alias for a function with a signature that the So() +// function can handle. Any future or custom assertions should conform to this +// method signature. The return value should be an empty string if the assertion +// passes and a well-formed failure message if not. +type assertion func(actual interface{}, expected ...interface{}) string + +//////////////////////////////////////////////////////////////////////////// diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/equality.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/equality.go new file mode 100644 index 0000000000..2b6049c37d --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/equality.go @@ -0,0 +1,280 @@ +package assertions + +import ( + "errors" + "fmt" + "math" + "reflect" + "strings" + + "github.com/smartystreets/assertions/internal/oglematchers" + "github.com/smartystreets/assertions/internal/go-render/render" +) + +// default acceptable delta for ShouldAlmostEqual +const defaultDelta = 0.0000000001 + +// ShouldEqual receives exactly two parameters and does an equality check. +func ShouldEqual(actual interface{}, expected ...interface{}) string { + if message := need(1, expected); message != success { + return message + } + return shouldEqual(actual, expected[0]) +} +func shouldEqual(actual, expected interface{}) (message string) { + defer func() { + if r := recover(); r != nil { + message = serializer.serialize(expected, actual, fmt.Sprintf(shouldHaveBeenEqual, expected, actual)) + return + } + }() + + if matchError := oglematchers.Equals(expected).Matches(actual); matchError != nil { + expectedSyntax := fmt.Sprintf("%v", expected) + actualSyntax := fmt.Sprintf("%v", actual) + if expectedSyntax == actualSyntax && reflect.TypeOf(expected) != reflect.TypeOf(actual) { + message = fmt.Sprintf(shouldHaveBeenEqualTypeMismatch, expected, expected, actual, actual) + } else { + message = fmt.Sprintf(shouldHaveBeenEqual, expected, actual) + } + message = serializer.serialize(expected, actual, message) + return + } + + return success +} + +// ShouldNotEqual receives exactly two parameters and does an inequality check. +func ShouldNotEqual(actual interface{}, expected ...interface{}) string { + if fail := need(1, expected); fail != success { + return fail + } else if ShouldEqual(actual, expected[0]) == success { + return fmt.Sprintf(shouldNotHaveBeenEqual, actual, expected[0]) + } + return success +} + +// ShouldAlmostEqual makes sure that two parameters are close enough to being equal. +// The acceptable delta may be specified with a third argument, +// or a very small default delta will be used. +func ShouldAlmostEqual(actual interface{}, expected ...interface{}) string { + actualFloat, expectedFloat, deltaFloat, err := cleanAlmostEqualInput(actual, expected...) + + if err != "" { + return err + } + + if math.Abs(actualFloat-expectedFloat) <= deltaFloat { + return success + } else { + return fmt.Sprintf(shouldHaveBeenAlmostEqual, actualFloat, expectedFloat) + } +} + +// ShouldNotAlmostEqual is the inverse of ShouldAlmostEqual +func ShouldNotAlmostEqual(actual interface{}, expected ...interface{}) string { + actualFloat, expectedFloat, deltaFloat, err := cleanAlmostEqualInput(actual, expected...) + + if err != "" { + return err + } + + if math.Abs(actualFloat-expectedFloat) > deltaFloat { + return success + } else { + return fmt.Sprintf(shouldHaveNotBeenAlmostEqual, actualFloat, expectedFloat) + } +} + +func cleanAlmostEqualInput(actual interface{}, expected ...interface{}) (float64, float64, float64, string) { + deltaFloat := 0.0000000001 + + if len(expected) == 0 { + return 0.0, 0.0, 0.0, "This assertion requires exactly one comparison value and an optional delta (you provided neither)" + } else if len(expected) == 2 { + delta, err := getFloat(expected[1]) + + if err != nil { + return 0.0, 0.0, 0.0, "delta must be a numerical type" + } + + deltaFloat = delta + } else if len(expected) > 2 { + return 0.0, 0.0, 0.0, "This assertion requires exactly one comparison value and an optional delta (you provided more values)" + } + + actualFloat, err := getFloat(actual) + + if err != nil { + return 0.0, 0.0, 0.0, err.Error() + } + + expectedFloat, err := getFloat(expected[0]) + + if err != nil { + return 0.0, 0.0, 0.0, err.Error() + } + + return actualFloat, expectedFloat, deltaFloat, "" +} + +// returns the float value of any real number, or error if it is not a numerical type +func getFloat(num interface{}) (float64, error) { + numValue := reflect.ValueOf(num) + numKind := numValue.Kind() + + if numKind == reflect.Int || + numKind == reflect.Int8 || + numKind == reflect.Int16 || + numKind == reflect.Int32 || + numKind == reflect.Int64 { + return float64(numValue.Int()), nil + } else if numKind == reflect.Uint || + numKind == reflect.Uint8 || + numKind == reflect.Uint16 || + numKind == reflect.Uint32 || + numKind == reflect.Uint64 { + return float64(numValue.Uint()), nil + } else if numKind == reflect.Float32 || + numKind == reflect.Float64 { + return numValue.Float(), nil + } else { + return 0.0, errors.New("must be a numerical type, but was " + numKind.String()) + } +} + +// ShouldResemble receives exactly two parameters and does a deep equal check (see reflect.DeepEqual) +func ShouldResemble(actual interface{}, expected ...interface{}) string { + if message := need(1, expected); message != success { + return message + } + + if matchError := oglematchers.DeepEquals(expected[0]).Matches(actual); matchError != nil { + return serializer.serializeDetailed(expected[0], actual, + fmt.Sprintf(shouldHaveResembled, render.Render(expected[0]), render.Render(actual))) + } + + return success +} + +// ShouldNotResemble receives exactly two parameters and does an inverse deep equal check (see reflect.DeepEqual) +func ShouldNotResemble(actual interface{}, expected ...interface{}) string { + if message := need(1, expected); message != success { + return message + } else if ShouldResemble(actual, expected[0]) == success { + return fmt.Sprintf(shouldNotHaveResembled, render.Render(actual), render.Render(expected[0])) + } + return success +} + +// ShouldPointTo receives exactly two parameters and checks to see that they point to the same address. +func ShouldPointTo(actual interface{}, expected ...interface{}) string { + if message := need(1, expected); message != success { + return message + } + return shouldPointTo(actual, expected[0]) + +} +func shouldPointTo(actual, expected interface{}) string { + actualValue := reflect.ValueOf(actual) + expectedValue := reflect.ValueOf(expected) + + if ShouldNotBeNil(actual) != success { + return fmt.Sprintf(shouldHaveBeenNonNilPointer, "first", "nil") + } else if ShouldNotBeNil(expected) != success { + return fmt.Sprintf(shouldHaveBeenNonNilPointer, "second", "nil") + } else if actualValue.Kind() != reflect.Ptr { + return fmt.Sprintf(shouldHaveBeenNonNilPointer, "first", "not") + } else if expectedValue.Kind() != reflect.Ptr { + return fmt.Sprintf(shouldHaveBeenNonNilPointer, "second", "not") + } else if ShouldEqual(actualValue.Pointer(), expectedValue.Pointer()) != success { + actualAddress := reflect.ValueOf(actual).Pointer() + expectedAddress := reflect.ValueOf(expected).Pointer() + return serializer.serialize(expectedAddress, actualAddress, fmt.Sprintf(shouldHavePointedTo, + actual, actualAddress, + expected, expectedAddress)) + } + return success +} + +// ShouldNotPointTo receives exactly two parameters and checks to see that they point to different addresess. +func ShouldNotPointTo(actual interface{}, expected ...interface{}) string { + if message := need(1, expected); message != success { + return message + } + compare := ShouldPointTo(actual, expected[0]) + if strings.HasPrefix(compare, shouldBePointers) { + return compare + } else if compare == success { + return fmt.Sprintf(shouldNotHavePointedTo, actual, expected[0], reflect.ValueOf(actual).Pointer()) + } + return success +} + +// ShouldBeNil receives a single parameter and ensures that it is nil. +func ShouldBeNil(actual interface{}, expected ...interface{}) string { + if fail := need(0, expected); fail != success { + return fail + } else if actual == nil { + return success + } else if interfaceHasNilValue(actual) { + return success + } + return fmt.Sprintf(shouldHaveBeenNil, actual) +} +func interfaceHasNilValue(actual interface{}) bool { + value := reflect.ValueOf(actual) + kind := value.Kind() + nilable := kind == reflect.Slice || + kind == reflect.Chan || + kind == reflect.Func || + kind == reflect.Ptr || + kind == reflect.Map + + // Careful: reflect.Value.IsNil() will panic unless it's an interface, chan, map, func, slice, or ptr + // Reference: http://golang.org/pkg/reflect/#Value.IsNil + return nilable && value.IsNil() +} + +// ShouldNotBeNil receives a single parameter and ensures that it is not nil. +func ShouldNotBeNil(actual interface{}, expected ...interface{}) string { + if fail := need(0, expected); fail != success { + return fail + } else if ShouldBeNil(actual) == success { + return fmt.Sprintf(shouldNotHaveBeenNil, actual) + } + return success +} + +// ShouldBeTrue receives a single parameter and ensures that it is true. +func ShouldBeTrue(actual interface{}, expected ...interface{}) string { + if fail := need(0, expected); fail != success { + return fail + } else if actual != true { + return fmt.Sprintf(shouldHaveBeenTrue, actual) + } + return success +} + +// ShouldBeFalse receives a single parameter and ensures that it is false. +func ShouldBeFalse(actual interface{}, expected ...interface{}) string { + if fail := need(0, expected); fail != success { + return fail + } else if actual != false { + return fmt.Sprintf(shouldHaveBeenFalse, actual) + } + return success +} + +// ShouldBeZeroValue receives a single parameter and ensures that it is +// the Go equivalent of the default value, or "zero" value. +func ShouldBeZeroValue(actual interface{}, expected ...interface{}) string { + if fail := need(0, expected); fail != success { + return fail + } + zeroVal := reflect.Zero(reflect.TypeOf(actual)).Interface() + if !reflect.DeepEqual(zeroVal, actual) { + return serializer.serialize(zeroVal, actual, fmt.Sprintf(shouldHaveBeenZeroValue, actual)) + } + return success +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/filter.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/filter.go new file mode 100644 index 0000000000..ee368a97ed --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/filter.go @@ -0,0 +1,23 @@ +package assertions + +import "fmt" + +const ( + success = "" + needExactValues = "This assertion requires exactly %d comparison values (you provided %d)." + needNonEmptyCollection = "This assertion requires at least 1 comparison value (you provided 0)." +) + +func need(needed int, expected []interface{}) string { + if len(expected) != needed { + return fmt.Sprintf(needExactValues, needed, len(expected)) + } + return success +} + +func atLeast(minimum int, expected []interface{}) string { + if len(expected) < 1 { + return needNonEmptyCollection + } + return success +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/go-render/render/render.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/go-render/render/render.go new file mode 100644 index 0000000000..23b7a58676 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/go-render/render/render.go @@ -0,0 +1,477 @@ +// Copyright 2015 The Chromium 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 render + +import ( + "bytes" + "fmt" + "reflect" + "sort" + "strconv" +) + +var builtinTypeMap = map[reflect.Kind]string{ + reflect.Bool: "bool", + reflect.Complex128: "complex128", + reflect.Complex64: "complex64", + reflect.Float32: "float32", + reflect.Float64: "float64", + reflect.Int16: "int16", + reflect.Int32: "int32", + reflect.Int64: "int64", + reflect.Int8: "int8", + reflect.Int: "int", + reflect.String: "string", + reflect.Uint16: "uint16", + reflect.Uint32: "uint32", + reflect.Uint64: "uint64", + reflect.Uint8: "uint8", + reflect.Uint: "uint", + reflect.Uintptr: "uintptr", +} + +var builtinTypeSet = map[string]struct{}{} + +func init() { + for _, v := range builtinTypeMap { + builtinTypeSet[v] = struct{}{} + } +} + +var typeOfString = reflect.TypeOf("") +var typeOfInt = reflect.TypeOf(int(1)) +var typeOfUint = reflect.TypeOf(uint(1)) +var typeOfFloat = reflect.TypeOf(10.1) + +// Render converts a structure to a string representation. Unline the "%#v" +// format string, this resolves pointer types' contents in structs, maps, and +// slices/arrays and prints their field values. +func Render(v interface{}) string { + buf := bytes.Buffer{} + s := (*traverseState)(nil) + s.render(&buf, 0, reflect.ValueOf(v), false) + return buf.String() +} + +// renderPointer is called to render a pointer value. +// +// This is overridable so that the test suite can have deterministic pointer +// values in its expectations. +var renderPointer = func(buf *bytes.Buffer, p uintptr) { + fmt.Fprintf(buf, "0x%016x", p) +} + +// traverseState is used to note and avoid recursion as struct members are being +// traversed. +// +// traverseState is allowed to be nil. Specifically, the root state is nil. +type traverseState struct { + parent *traverseState + ptr uintptr +} + +func (s *traverseState) forkFor(ptr uintptr) *traverseState { + for cur := s; cur != nil; cur = cur.parent { + if ptr == cur.ptr { + return nil + } + } + + fs := &traverseState{ + parent: s, + ptr: ptr, + } + return fs +} + +func (s *traverseState) render(buf *bytes.Buffer, ptrs int, v reflect.Value, implicit bool) { + if v.Kind() == reflect.Invalid { + buf.WriteString("nil") + return + } + vt := v.Type() + + // If the type being rendered is a potentially recursive type (a type that + // can contain itself as a member), we need to avoid recursion. + // + // If we've already seen this type before, mark that this is the case and + // write a recursion placeholder instead of actually rendering it. + // + // If we haven't seen it before, fork our `seen` tracking so any higher-up + // renderers will also render it at least once, then mark that we've seen it + // to avoid recursing on lower layers. + pe := uintptr(0) + vk := vt.Kind() + switch vk { + case reflect.Ptr: + // Since structs and arrays aren't pointers, they can't directly be + // recursed, but they can contain pointers to themselves. Record their + // pointer to avoid this. + switch v.Elem().Kind() { + case reflect.Struct, reflect.Array: + pe = v.Pointer() + } + + case reflect.Slice, reflect.Map: + pe = v.Pointer() + } + if pe != 0 { + s = s.forkFor(pe) + if s == nil { + buf.WriteString("") + return + } + } + + isAnon := func(t reflect.Type) bool { + if t.Name() != "" { + if _, ok := builtinTypeSet[t.Name()]; !ok { + return false + } + } + return t.Kind() != reflect.Interface + } + + switch vk { + case reflect.Struct: + if !implicit { + writeType(buf, ptrs, vt) + } + structAnon := vt.Name() == "" + buf.WriteRune('{') + for i := 0; i < vt.NumField(); i++ { + if i > 0 { + buf.WriteString(", ") + } + anon := structAnon && isAnon(vt.Field(i).Type) + + if !anon { + buf.WriteString(vt.Field(i).Name) + buf.WriteRune(':') + } + + s.render(buf, 0, v.Field(i), anon) + } + buf.WriteRune('}') + + case reflect.Slice: + if v.IsNil() { + if !implicit { + writeType(buf, ptrs, vt) + buf.WriteString("(nil)") + } else { + buf.WriteString("nil") + } + return + } + fallthrough + + case reflect.Array: + if !implicit { + writeType(buf, ptrs, vt) + } + anon := vt.Name() == "" && isAnon(vt.Elem()) + buf.WriteString("{") + for i := 0; i < v.Len(); i++ { + if i > 0 { + buf.WriteString(", ") + } + + s.render(buf, 0, v.Index(i), anon) + } + buf.WriteRune('}') + + case reflect.Map: + if !implicit { + writeType(buf, ptrs, vt) + } + if v.IsNil() { + buf.WriteString("(nil)") + } else { + buf.WriteString("{") + + mkeys := v.MapKeys() + tryAndSortMapKeys(vt, mkeys) + + kt := vt.Key() + keyAnon := typeOfString.ConvertibleTo(kt) || typeOfInt.ConvertibleTo(kt) || typeOfUint.ConvertibleTo(kt) || typeOfFloat.ConvertibleTo(kt) + valAnon := vt.Name() == "" && isAnon(vt.Elem()) + for i, mk := range mkeys { + if i > 0 { + buf.WriteString(", ") + } + + s.render(buf, 0, mk, keyAnon) + buf.WriteString(":") + s.render(buf, 0, v.MapIndex(mk), valAnon) + } + buf.WriteRune('}') + } + + case reflect.Ptr: + ptrs++ + fallthrough + case reflect.Interface: + if v.IsNil() { + writeType(buf, ptrs, v.Type()) + buf.WriteString("(nil)") + } else { + s.render(buf, ptrs, v.Elem(), false) + } + + case reflect.Chan, reflect.Func, reflect.UnsafePointer: + writeType(buf, ptrs, vt) + buf.WriteRune('(') + renderPointer(buf, v.Pointer()) + buf.WriteRune(')') + + default: + tstr := vt.String() + implicit = implicit || (ptrs == 0 && builtinTypeMap[vk] == tstr) + if !implicit { + writeType(buf, ptrs, vt) + buf.WriteRune('(') + } + + switch vk { + case reflect.String: + fmt.Fprintf(buf, "%q", v.String()) + case reflect.Bool: + fmt.Fprintf(buf, "%v", v.Bool()) + + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + fmt.Fprintf(buf, "%d", v.Int()) + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + fmt.Fprintf(buf, "%d", v.Uint()) + + case reflect.Float32, reflect.Float64: + fmt.Fprintf(buf, "%g", v.Float()) + + case reflect.Complex64, reflect.Complex128: + fmt.Fprintf(buf, "%g", v.Complex()) + } + + if !implicit { + buf.WriteRune(')') + } + } +} + +func writeType(buf *bytes.Buffer, ptrs int, t reflect.Type) { + parens := ptrs > 0 + switch t.Kind() { + case reflect.Chan, reflect.Func, reflect.UnsafePointer: + parens = true + } + + if parens { + buf.WriteRune('(') + for i := 0; i < ptrs; i++ { + buf.WriteRune('*') + } + } + + switch t.Kind() { + case reflect.Ptr: + if ptrs == 0 { + // This pointer was referenced from within writeType (e.g., as part of + // rendering a list), and so hasn't had its pointer asterisk accounted + // for. + buf.WriteRune('*') + } + writeType(buf, 0, t.Elem()) + + case reflect.Interface: + if n := t.Name(); n != "" { + buf.WriteString(t.String()) + } else { + buf.WriteString("interface{}") + } + + case reflect.Array: + buf.WriteRune('[') + buf.WriteString(strconv.FormatInt(int64(t.Len()), 10)) + buf.WriteRune(']') + writeType(buf, 0, t.Elem()) + + case reflect.Slice: + if t == reflect.SliceOf(t.Elem()) { + buf.WriteString("[]") + writeType(buf, 0, t.Elem()) + } else { + // Custom slice type, use type name. + buf.WriteString(t.String()) + } + + case reflect.Map: + if t == reflect.MapOf(t.Key(), t.Elem()) { + buf.WriteString("map[") + writeType(buf, 0, t.Key()) + buf.WriteRune(']') + writeType(buf, 0, t.Elem()) + } else { + // Custom map type, use type name. + buf.WriteString(t.String()) + } + + default: + buf.WriteString(t.String()) + } + + if parens { + buf.WriteRune(')') + } +} + +type cmpFn func(a, b reflect.Value) int + +type sortableValueSlice struct { + cmp cmpFn + elements []reflect.Value +} + +func (s sortableValueSlice) Len() int { + return len(s.elements) +} + +func (s sortableValueSlice) Less(i, j int) bool { + return s.cmp(s.elements[i], s.elements[j]) < 0 +} + +func (s sortableValueSlice) Swap(i, j int) { + s.elements[i], s.elements[j] = s.elements[j], s.elements[i] +} + +// cmpForType returns a cmpFn which sorts the data for some type t in the same +// order that a go-native map key is compared for equality. +func cmpForType(t reflect.Type) cmpFn { + switch t.Kind() { + case reflect.String: + return func(av, bv reflect.Value) int { + a, b := av.String(), bv.String() + if a < b { + return -1 + } else if a > b { + return 1 + } + return 0 + } + + case reflect.Bool: + return func(av, bv reflect.Value) int { + a, b := av.Bool(), bv.Bool() + if !a && b { + return -1 + } else if a && !b { + return 1 + } + return 0 + } + + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return func(av, bv reflect.Value) int { + a, b := av.Int(), bv.Int() + if a < b { + return -1 + } else if a > b { + return 1 + } + return 0 + } + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, + reflect.Uint64, reflect.Uintptr, reflect.UnsafePointer: + return func(av, bv reflect.Value) int { + a, b := av.Uint(), bv.Uint() + if a < b { + return -1 + } else if a > b { + return 1 + } + return 0 + } + + case reflect.Float32, reflect.Float64: + return func(av, bv reflect.Value) int { + a, b := av.Float(), bv.Float() + if a < b { + return -1 + } else if a > b { + return 1 + } + return 0 + } + + case reflect.Interface: + return func(av, bv reflect.Value) int { + a, b := av.InterfaceData(), bv.InterfaceData() + if a[0] < b[0] { + return -1 + } else if a[0] > b[0] { + return 1 + } + if a[1] < b[1] { + return -1 + } else if a[1] > b[1] { + return 1 + } + return 0 + } + + case reflect.Complex64, reflect.Complex128: + return func(av, bv reflect.Value) int { + a, b := av.Complex(), bv.Complex() + if real(a) < real(b) { + return -1 + } else if real(a) > real(b) { + return 1 + } + if imag(a) < imag(b) { + return -1 + } else if imag(a) > imag(b) { + return 1 + } + return 0 + } + + case reflect.Ptr, reflect.Chan: + return func(av, bv reflect.Value) int { + a, b := av.Pointer(), bv.Pointer() + if a < b { + return -1 + } else if a > b { + return 1 + } + return 0 + } + + case reflect.Struct: + cmpLst := make([]cmpFn, t.NumField()) + for i := range cmpLst { + cmpLst[i] = cmpForType(t.Field(i).Type) + } + return func(a, b reflect.Value) int { + for i, cmp := range cmpLst { + if rslt := cmp(a.Field(i), b.Field(i)); rslt != 0 { + return rslt + } + } + return 0 + } + } + + return nil +} + +func tryAndSortMapKeys(mt reflect.Type, k []reflect.Value) { + if cmp := cmpForType(mt.Key()); cmp != nil { + sort.Sort(sortableValueSlice{cmp, k}) + } +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/.gitignore b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/.gitignore new file mode 100644 index 0000000000..dd8fc7468f --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/.gitignore @@ -0,0 +1,5 @@ +*.6 +6.out +_obj/ +_test/ +_testmain.go diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/.travis.yml b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/.travis.yml new file mode 100644 index 0000000000..b97211926e --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/.travis.yml @@ -0,0 +1,4 @@ +# Cf. http://docs.travis-ci.com/user/getting-started/ +# Cf. http://docs.travis-ci.com/user/languages/go/ + +language: go diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/LICENSE b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/LICENSE new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor 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, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/README.md b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/README.md new file mode 100644 index 0000000000..215a2bb7a8 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/README.md @@ -0,0 +1,58 @@ +[![GoDoc](https://godoc.org/github.com/smartystreets/assertions/internal/oglematchers?status.svg)](https://godoc.org/github.com/smartystreets/assertions/internal/oglematchers) + +`oglematchers` is a package for the Go programming language containing a set of +matchers, useful in a testing or mocking framework, inspired by and mostly +compatible with [Google Test][googletest] for C++ and +[Google JS Test][google-js-test]. The package is used by the +[ogletest][ogletest] testing framework and [oglemock][oglemock] mocking +framework, which may be more directly useful to you, but can be generically used +elsewhere as well. + +A "matcher" is simply an object with a `Matches` method defining a set of golang +values matched by the matcher, and a `Description` method describing that set. +For example, here are some matchers: + +```go +// Numbers +Equals(17.13) +LessThan(19) + +// Strings +Equals("taco") +HasSubstr("burrito") +MatchesRegex("t.*o") + +// Combining matchers +AnyOf(LessThan(17), GreaterThan(19)) +``` + +There are lots more; see [here][reference] for a reference. You can also add +your own simply by implementing the `oglematchers.Matcher` interface. + + +Installation +------------ + +First, make sure you have installed Go 1.0.2 or newer. See +[here][golang-install] for instructions. + +Use the following command to install `oglematchers` and keep it up to date: + + go get -u github.com/smartystreets/assertions/internal/oglematchers + + +Documentation +------------- + +See [here][reference] for documentation. Alternatively, you can install the +package and then use `godoc`: + + godoc github.com/smartystreets/assertions/internal/oglematchers + + +[reference]: http://godoc.org/github.com/smartystreets/assertions/internal/oglematchers +[golang-install]: http://golang.org/doc/install.html +[googletest]: http://code.google.com/p/googletest/ +[google-js-test]: http://code.google.com/p/google-js-test/ +[ogletest]: http://github.com/smartystreets/assertions/internal/ogletest +[oglemock]: http://github.com/smartystreets/assertions/internal/oglemock diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/all_of.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/all_of.go new file mode 100644 index 0000000000..d93a974044 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/all_of.go @@ -0,0 +1,70 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package oglematchers + +import ( + "strings" +) + +// AllOf accepts a set of matchers S and returns a matcher that follows the +// algorithm below when considering a candidate c: +// +// 1. Return true if for every Matcher m in S, m matches c. +// +// 2. Otherwise, if there is a matcher m in S such that m returns a fatal +// error for c, return that matcher's error message. +// +// 3. Otherwise, return false with the error from some wrapped matcher. +// +// This is akin to a logical AND operation for matchers. +func AllOf(matchers ...Matcher) Matcher { + return &allOfMatcher{matchers} +} + +type allOfMatcher struct { + wrappedMatchers []Matcher +} + +func (m *allOfMatcher) Description() string { + // Special case: the empty set. + if len(m.wrappedMatchers) == 0 { + return "is anything" + } + + // Join the descriptions for the wrapped matchers. + wrappedDescs := make([]string, len(m.wrappedMatchers)) + for i, wrappedMatcher := range m.wrappedMatchers { + wrappedDescs[i] = wrappedMatcher.Description() + } + + return strings.Join(wrappedDescs, ", and ") +} + +func (m *allOfMatcher) Matches(c interface{}) (err error) { + for _, wrappedMatcher := range m.wrappedMatchers { + if wrappedErr := wrappedMatcher.Matches(c); wrappedErr != nil { + err = wrappedErr + + // If the error is fatal, return immediately with this error. + _, ok := wrappedErr.(*FatalError) + if ok { + return + } + } + } + + return +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/any.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/any.go new file mode 100644 index 0000000000..f6991ec102 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/any.go @@ -0,0 +1,32 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package oglematchers + +// Any returns a matcher that matches any value. +func Any() Matcher { + return &anyMatcher{} +} + +type anyMatcher struct { +} + +func (m *anyMatcher) Description() string { + return "is anything" +} + +func (m *anyMatcher) Matches(c interface{}) error { + return nil +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/any_of.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/any_of.go new file mode 100644 index 0000000000..2918b51f21 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/any_of.go @@ -0,0 +1,94 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package oglematchers + +import ( + "errors" + "fmt" + "reflect" + "strings" +) + +// AnyOf accepts a set of values S and returns a matcher that follows the +// algorithm below when considering a candidate c: +// +// 1. If there exists a value m in S such that m implements the Matcher +// interface and m matches c, return true. +// +// 2. Otherwise, if there exists a value v in S such that v does not implement +// the Matcher interface and the matcher Equals(v) matches c, return true. +// +// 3. Otherwise, if there is a value m in S such that m implements the Matcher +// interface and m returns a fatal error for c, return that fatal error. +// +// 4. Otherwise, return false. +// +// This is akin to a logical OR operation for matchers, with non-matchers x +// being treated as Equals(x). +func AnyOf(vals ...interface{}) Matcher { + // Get ahold of a type variable for the Matcher interface. + var dummy *Matcher + matcherType := reflect.TypeOf(dummy).Elem() + + // Create a matcher for each value, or use the value itself if it's already a + // matcher. + wrapped := make([]Matcher, len(vals)) + for i, v := range vals { + t := reflect.TypeOf(v) + if t != nil && t.Implements(matcherType) { + wrapped[i] = v.(Matcher) + } else { + wrapped[i] = Equals(v) + } + } + + return &anyOfMatcher{wrapped} +} + +type anyOfMatcher struct { + wrapped []Matcher +} + +func (m *anyOfMatcher) Description() string { + wrappedDescs := make([]string, len(m.wrapped)) + for i, matcher := range m.wrapped { + wrappedDescs[i] = matcher.Description() + } + + return fmt.Sprintf("or(%s)", strings.Join(wrappedDescs, ", ")) +} + +func (m *anyOfMatcher) Matches(c interface{}) (err error) { + err = errors.New("") + + // Try each matcher in turn. + for _, matcher := range m.wrapped { + wrappedErr := matcher.Matches(c) + + // Return immediately if there's a match. + if wrappedErr == nil { + err = nil + return + } + + // Note the fatal error, if any. + if _, isFatal := wrappedErr.(*FatalError); isFatal { + err = wrappedErr + } + } + + return +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/contains.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/contains.go new file mode 100644 index 0000000000..87f107d392 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/contains.go @@ -0,0 +1,61 @@ +// Copyright 2012 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package oglematchers + +import ( + "fmt" + "reflect" +) + +// Return a matcher that matches arrays slices with at least one element that +// matches the supplied argument. If the argument x is not itself a Matcher, +// this is equivalent to Contains(Equals(x)). +func Contains(x interface{}) Matcher { + var result containsMatcher + var ok bool + + if result.elementMatcher, ok = x.(Matcher); !ok { + result.elementMatcher = DeepEquals(x) + } + + return &result +} + +type containsMatcher struct { + elementMatcher Matcher +} + +func (m *containsMatcher) Description() string { + return fmt.Sprintf("contains: %s", m.elementMatcher.Description()) +} + +func (m *containsMatcher) Matches(candidate interface{}) error { + // The candidate must be a slice or an array. + v := reflect.ValueOf(candidate) + if v.Kind() != reflect.Slice && v.Kind() != reflect.Array { + return NewFatalError("which is not a slice or array") + } + + // Check each element. + for i := 0; i < v.Len(); i++ { + elem := v.Index(i) + if matchErr := m.elementMatcher.Matches(elem.Interface()); matchErr == nil { + return nil + } + } + + return fmt.Errorf("") +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/deep_equals.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/deep_equals.go new file mode 100644 index 0000000000..1d91baef32 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/deep_equals.go @@ -0,0 +1,88 @@ +// Copyright 2012 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package oglematchers + +import ( + "bytes" + "errors" + "fmt" + "reflect" +) + +var byteSliceType reflect.Type = reflect.TypeOf([]byte{}) + +// DeepEquals returns a matcher that matches based on 'deep equality', as +// defined by the reflect package. This matcher requires that values have +// identical types to x. +func DeepEquals(x interface{}) Matcher { + return &deepEqualsMatcher{x} +} + +type deepEqualsMatcher struct { + x interface{} +} + +func (m *deepEqualsMatcher) Description() string { + xDesc := fmt.Sprintf("%v", m.x) + xValue := reflect.ValueOf(m.x) + + // Special case: fmt.Sprintf presents nil slices as "[]", but + // reflect.DeepEqual makes a distinction between nil and empty slices. Make + // this less confusing. + if xValue.Kind() == reflect.Slice && xValue.IsNil() { + xDesc = "" + } + + return fmt.Sprintf("deep equals: %s", xDesc) +} + +func (m *deepEqualsMatcher) Matches(c interface{}) error { + // Make sure the types match. + ct := reflect.TypeOf(c) + xt := reflect.TypeOf(m.x) + + if ct != xt { + return NewFatalError(fmt.Sprintf("which is of type %v", ct)) + } + + // Special case: handle byte slices more efficiently. + cValue := reflect.ValueOf(c) + xValue := reflect.ValueOf(m.x) + + if ct == byteSliceType && !cValue.IsNil() && !xValue.IsNil() { + xBytes := m.x.([]byte) + cBytes := c.([]byte) + + if bytes.Equal(cBytes, xBytes) { + return nil + } + + return errors.New("") + } + + // Defer to the reflect package. + if reflect.DeepEqual(m.x, c) { + return nil + } + + // Special case: if the comparison failed because c is the nil slice, given + // an indication of this (since its value is printed as "[]"). + if cValue.Kind() == reflect.Slice && cValue.IsNil() { + return errors.New("which is nil") + } + + return errors.New("") +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/elements_are.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/elements_are.go new file mode 100644 index 0000000000..2941847c70 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/elements_are.go @@ -0,0 +1,91 @@ +// Copyright 2012 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package oglematchers + +import ( + "errors" + "fmt" + "reflect" + "strings" +) + +// Given a list of arguments M, ElementsAre returns a matcher that matches +// arrays and slices A where all of the following hold: +// +// * A is the same length as M. +// +// * For each i < len(A) where M[i] is a matcher, A[i] matches M[i]. +// +// * For each i < len(A) where M[i] is not a matcher, A[i] matches +// Equals(M[i]). +// +func ElementsAre(M ...interface{}) Matcher { + // Copy over matchers, or convert to Equals(x) for non-matcher x. + subMatchers := make([]Matcher, len(M)) + for i, x := range M { + if matcher, ok := x.(Matcher); ok { + subMatchers[i] = matcher + continue + } + + subMatchers[i] = Equals(x) + } + + return &elementsAreMatcher{subMatchers} +} + +type elementsAreMatcher struct { + subMatchers []Matcher +} + +func (m *elementsAreMatcher) Description() string { + subDescs := make([]string, len(m.subMatchers)) + for i, sm := range m.subMatchers { + subDescs[i] = sm.Description() + } + + return fmt.Sprintf("elements are: [%s]", strings.Join(subDescs, ", ")) +} + +func (m *elementsAreMatcher) Matches(candidates interface{}) error { + // The candidate must be a slice or an array. + v := reflect.ValueOf(candidates) + if v.Kind() != reflect.Slice && v.Kind() != reflect.Array { + return NewFatalError("which is not a slice or array") + } + + // The length must be correct. + if v.Len() != len(m.subMatchers) { + return errors.New(fmt.Sprintf("which is of length %d", v.Len())) + } + + // Check each element. + for i, subMatcher := range m.subMatchers { + c := v.Index(i) + if matchErr := subMatcher.Matches(c.Interface()); matchErr != nil { + // Return an errors indicating which element doesn't match. If the + // matcher error was fatal, make this one fatal too. + err := errors.New(fmt.Sprintf("whose element %d doesn't match", i)) + if _, isFatal := matchErr.(*FatalError); isFatal { + err = NewFatalError(err.Error()) + } + + return err + } + } + + return nil +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/equals.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/equals.go new file mode 100644 index 0000000000..a510707b3c --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/equals.go @@ -0,0 +1,541 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package oglematchers + +import ( + "errors" + "fmt" + "math" + "reflect" +) + +// Equals(x) returns a matcher that matches values v such that v and x are +// equivalent. This includes the case when the comparison v == x using Go's +// built-in comparison operator is legal (except for structs, which this +// matcher does not support), but for convenience the following rules also +// apply: +// +// * Type checking is done based on underlying types rather than actual +// types, so that e.g. two aliases for string can be compared: +// +// type stringAlias1 string +// type stringAlias2 string +// +// a := "taco" +// b := stringAlias1("taco") +// c := stringAlias2("taco") +// +// ExpectTrue(a == b) // Legal, passes +// ExpectTrue(b == c) // Illegal, doesn't compile +// +// ExpectThat(a, Equals(b)) // Passes +// ExpectThat(b, Equals(c)) // Passes +// +// * Values of numeric type are treated as if they were abstract numbers, and +// compared accordingly. Therefore Equals(17) will match int(17), +// int16(17), uint(17), float32(17), complex64(17), and so on. +// +// If you want a stricter matcher that contains no such cleverness, see +// IdenticalTo instead. +// +// Arrays are supported by this matcher, but do not participate in the +// exceptions above. Two arrays compared with this matcher must have identical +// types, and their element type must itself be comparable according to Go's == +// operator. +func Equals(x interface{}) Matcher { + v := reflect.ValueOf(x) + + // This matcher doesn't support structs. + if v.Kind() == reflect.Struct { + panic(fmt.Sprintf("oglematchers.Equals: unsupported kind %v", v.Kind())) + } + + // The == operator is not defined for non-nil slices. + if v.Kind() == reflect.Slice && v.Pointer() != uintptr(0) { + panic(fmt.Sprintf("oglematchers.Equals: non-nil slice")) + } + + return &equalsMatcher{v} +} + +type equalsMatcher struct { + expectedValue reflect.Value +} + +//////////////////////////////////////////////////////////////////////// +// Numeric types +//////////////////////////////////////////////////////////////////////// + +func isSignedInteger(v reflect.Value) bool { + k := v.Kind() + return k >= reflect.Int && k <= reflect.Int64 +} + +func isUnsignedInteger(v reflect.Value) bool { + k := v.Kind() + return k >= reflect.Uint && k <= reflect.Uintptr +} + +func isInteger(v reflect.Value) bool { + return isSignedInteger(v) || isUnsignedInteger(v) +} + +func isFloat(v reflect.Value) bool { + k := v.Kind() + return k == reflect.Float32 || k == reflect.Float64 +} + +func isComplex(v reflect.Value) bool { + k := v.Kind() + return k == reflect.Complex64 || k == reflect.Complex128 +} + +func checkAgainstInt64(e int64, c reflect.Value) (err error) { + err = errors.New("") + + switch { + case isSignedInteger(c): + if c.Int() == e { + err = nil + } + + case isUnsignedInteger(c): + u := c.Uint() + if u <= math.MaxInt64 && int64(u) == e { + err = nil + } + + // Turn around the various floating point types so that the checkAgainst* + // functions for them can deal with precision issues. + case isFloat(c), isComplex(c): + return Equals(c.Interface()).Matches(e) + + default: + err = NewFatalError("which is not numeric") + } + + return +} + +func checkAgainstUint64(e uint64, c reflect.Value) (err error) { + err = errors.New("") + + switch { + case isSignedInteger(c): + i := c.Int() + if i >= 0 && uint64(i) == e { + err = nil + } + + case isUnsignedInteger(c): + if c.Uint() == e { + err = nil + } + + // Turn around the various floating point types so that the checkAgainst* + // functions for them can deal with precision issues. + case isFloat(c), isComplex(c): + return Equals(c.Interface()).Matches(e) + + default: + err = NewFatalError("which is not numeric") + } + + return +} + +func checkAgainstFloat32(e float32, c reflect.Value) (err error) { + err = errors.New("") + + switch { + case isSignedInteger(c): + if float32(c.Int()) == e { + err = nil + } + + case isUnsignedInteger(c): + if float32(c.Uint()) == e { + err = nil + } + + case isFloat(c): + // Compare using float32 to avoid a false sense of precision; otherwise + // e.g. Equals(float32(0.1)) won't match float32(0.1). + if float32(c.Float()) == e { + err = nil + } + + case isComplex(c): + comp := c.Complex() + rl := real(comp) + im := imag(comp) + + // Compare using float32 to avoid a false sense of precision; otherwise + // e.g. Equals(float32(0.1)) won't match (0.1 + 0i). + if im == 0 && float32(rl) == e { + err = nil + } + + default: + err = NewFatalError("which is not numeric") + } + + return +} + +func checkAgainstFloat64(e float64, c reflect.Value) (err error) { + err = errors.New("") + + ck := c.Kind() + + switch { + case isSignedInteger(c): + if float64(c.Int()) == e { + err = nil + } + + case isUnsignedInteger(c): + if float64(c.Uint()) == e { + err = nil + } + + // If the actual value is lower precision, turn the comparison around so we + // apply the low-precision rules. Otherwise, e.g. Equals(0.1) may not match + // float32(0.1). + case ck == reflect.Float32 || ck == reflect.Complex64: + return Equals(c.Interface()).Matches(e) + + // Otherwise, compare with double precision. + case isFloat(c): + if c.Float() == e { + err = nil + } + + case isComplex(c): + comp := c.Complex() + rl := real(comp) + im := imag(comp) + + if im == 0 && rl == e { + err = nil + } + + default: + err = NewFatalError("which is not numeric") + } + + return +} + +func checkAgainstComplex64(e complex64, c reflect.Value) (err error) { + err = errors.New("") + realPart := real(e) + imaginaryPart := imag(e) + + switch { + case isInteger(c) || isFloat(c): + // If we have no imaginary part, then we should just compare against the + // real part. Otherwise, we can't be equal. + if imaginaryPart != 0 { + return + } + + return checkAgainstFloat32(realPart, c) + + case isComplex(c): + // Compare using complex64 to avoid a false sense of precision; otherwise + // e.g. Equals(0.1 + 0i) won't match float32(0.1). + if complex64(c.Complex()) == e { + err = nil + } + + default: + err = NewFatalError("which is not numeric") + } + + return +} + +func checkAgainstComplex128(e complex128, c reflect.Value) (err error) { + err = errors.New("") + realPart := real(e) + imaginaryPart := imag(e) + + switch { + case isInteger(c) || isFloat(c): + // If we have no imaginary part, then we should just compare against the + // real part. Otherwise, we can't be equal. + if imaginaryPart != 0 { + return + } + + return checkAgainstFloat64(realPart, c) + + case isComplex(c): + if c.Complex() == e { + err = nil + } + + default: + err = NewFatalError("which is not numeric") + } + + return +} + +//////////////////////////////////////////////////////////////////////// +// Other types +//////////////////////////////////////////////////////////////////////// + +func checkAgainstBool(e bool, c reflect.Value) (err error) { + if c.Kind() != reflect.Bool { + err = NewFatalError("which is not a bool") + return + } + + err = errors.New("") + if c.Bool() == e { + err = nil + } + return +} + +func checkAgainstChan(e reflect.Value, c reflect.Value) (err error) { + // Create a description of e's type, e.g. "chan int". + typeStr := fmt.Sprintf("%s %s", e.Type().ChanDir(), e.Type().Elem()) + + // Make sure c is a chan of the correct type. + if c.Kind() != reflect.Chan || + c.Type().ChanDir() != e.Type().ChanDir() || + c.Type().Elem() != e.Type().Elem() { + err = NewFatalError(fmt.Sprintf("which is not a %s", typeStr)) + return + } + + err = errors.New("") + if c.Pointer() == e.Pointer() { + err = nil + } + return +} + +func checkAgainstFunc(e reflect.Value, c reflect.Value) (err error) { + // Make sure c is a function. + if c.Kind() != reflect.Func { + err = NewFatalError("which is not a function") + return + } + + err = errors.New("") + if c.Pointer() == e.Pointer() { + err = nil + } + return +} + +func checkAgainstMap(e reflect.Value, c reflect.Value) (err error) { + // Make sure c is a map. + if c.Kind() != reflect.Map { + err = NewFatalError("which is not a map") + return + } + + err = errors.New("") + if c.Pointer() == e.Pointer() { + err = nil + } + return +} + +func checkAgainstPtr(e reflect.Value, c reflect.Value) (err error) { + // Create a description of e's type, e.g. "*int". + typeStr := fmt.Sprintf("*%v", e.Type().Elem()) + + // Make sure c is a pointer of the correct type. + if c.Kind() != reflect.Ptr || + c.Type().Elem() != e.Type().Elem() { + err = NewFatalError(fmt.Sprintf("which is not a %s", typeStr)) + return + } + + err = errors.New("") + if c.Pointer() == e.Pointer() { + err = nil + } + return +} + +func checkAgainstSlice(e reflect.Value, c reflect.Value) (err error) { + // Create a description of e's type, e.g. "[]int". + typeStr := fmt.Sprintf("[]%v", e.Type().Elem()) + + // Make sure c is a slice of the correct type. + if c.Kind() != reflect.Slice || + c.Type().Elem() != e.Type().Elem() { + err = NewFatalError(fmt.Sprintf("which is not a %s", typeStr)) + return + } + + err = errors.New("") + if c.Pointer() == e.Pointer() { + err = nil + } + return +} + +func checkAgainstString(e reflect.Value, c reflect.Value) (err error) { + // Make sure c is a string. + if c.Kind() != reflect.String { + err = NewFatalError("which is not a string") + return + } + + err = errors.New("") + if c.String() == e.String() { + err = nil + } + return +} + +func checkAgainstArray(e reflect.Value, c reflect.Value) (err error) { + // Create a description of e's type, e.g. "[2]int". + typeStr := fmt.Sprintf("%v", e.Type()) + + // Make sure c is the correct type. + if c.Type() != e.Type() { + err = NewFatalError(fmt.Sprintf("which is not %s", typeStr)) + return + } + + // Check for equality. + if e.Interface() != c.Interface() { + err = errors.New("") + return + } + + return +} + +func checkAgainstUnsafePointer(e reflect.Value, c reflect.Value) (err error) { + // Make sure c is a pointer. + if c.Kind() != reflect.UnsafePointer { + err = NewFatalError("which is not a unsafe.Pointer") + return + } + + err = errors.New("") + if c.Pointer() == e.Pointer() { + err = nil + } + return +} + +func checkForNil(c reflect.Value) (err error) { + err = errors.New("") + + // Make sure it is legal to call IsNil. + switch c.Kind() { + case reflect.Invalid: + case reflect.Chan: + case reflect.Func: + case reflect.Interface: + case reflect.Map: + case reflect.Ptr: + case reflect.Slice: + + default: + err = NewFatalError("which cannot be compared to nil") + return + } + + // Ask whether the value is nil. Handle a nil literal (kind Invalid) + // specially, since it's not legal to call IsNil there. + if c.Kind() == reflect.Invalid || c.IsNil() { + err = nil + } + return +} + +//////////////////////////////////////////////////////////////////////// +// Public implementation +//////////////////////////////////////////////////////////////////////// + +func (m *equalsMatcher) Matches(candidate interface{}) error { + e := m.expectedValue + c := reflect.ValueOf(candidate) + ek := e.Kind() + + switch { + case ek == reflect.Bool: + return checkAgainstBool(e.Bool(), c) + + case isSignedInteger(e): + return checkAgainstInt64(e.Int(), c) + + case isUnsignedInteger(e): + return checkAgainstUint64(e.Uint(), c) + + case ek == reflect.Float32: + return checkAgainstFloat32(float32(e.Float()), c) + + case ek == reflect.Float64: + return checkAgainstFloat64(e.Float(), c) + + case ek == reflect.Complex64: + return checkAgainstComplex64(complex64(e.Complex()), c) + + case ek == reflect.Complex128: + return checkAgainstComplex128(complex128(e.Complex()), c) + + case ek == reflect.Chan: + return checkAgainstChan(e, c) + + case ek == reflect.Func: + return checkAgainstFunc(e, c) + + case ek == reflect.Map: + return checkAgainstMap(e, c) + + case ek == reflect.Ptr: + return checkAgainstPtr(e, c) + + case ek == reflect.Slice: + return checkAgainstSlice(e, c) + + case ek == reflect.String: + return checkAgainstString(e, c) + + case ek == reflect.Array: + return checkAgainstArray(e, c) + + case ek == reflect.UnsafePointer: + return checkAgainstUnsafePointer(e, c) + + case ek == reflect.Invalid: + return checkForNil(c) + } + + panic(fmt.Sprintf("equalsMatcher.Matches: unexpected kind: %v", ek)) +} + +func (m *equalsMatcher) Description() string { + // Special case: handle nil. + if !m.expectedValue.IsValid() { + return "is nil" + } + + return fmt.Sprintf("%v", m.expectedValue.Interface()) +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/error.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/error.go new file mode 100644 index 0000000000..8a078e36d8 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/error.go @@ -0,0 +1,51 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package oglematchers + +// Error returns a matcher that matches non-nil values implementing the +// built-in error interface for whom the return value of Error() matches the +// supplied matcher. +// +// For example: +// +// err := errors.New("taco burrito") +// +// Error(Equals("taco burrito")) // matches err +// Error(HasSubstr("taco")) // matches err +// Error(HasSubstr("enchilada")) // doesn't match err +// +func Error(m Matcher) Matcher { + return &errorMatcher{m} +} + +type errorMatcher struct { + wrappedMatcher Matcher +} + +func (m *errorMatcher) Description() string { + return "error " + m.wrappedMatcher.Description() +} + +func (m *errorMatcher) Matches(c interface{}) error { + // Make sure that c is an error. + e, ok := c.(error) + if !ok { + return NewFatalError("which is not an error") + } + + // Pass on the error text to the wrapped matcher. + return m.wrappedMatcher.Matches(e.Error()) +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal.go new file mode 100644 index 0000000000..4b9d103a38 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal.go @@ -0,0 +1,39 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package oglematchers + +import ( + "fmt" + "reflect" +) + +// GreaterOrEqual returns a matcher that matches integer, floating point, or +// strings values v such that v >= x. Comparison is not defined between numeric +// and string types, but is defined between all integer and floating point +// types. +// +// x must itself be an integer, floating point, or string type; otherwise, +// GreaterOrEqual will panic. +func GreaterOrEqual(x interface{}) Matcher { + desc := fmt.Sprintf("greater than or equal to %v", x) + + // Special case: make it clear that strings are strings. + if reflect.TypeOf(x).Kind() == reflect.String { + desc = fmt.Sprintf("greater than or equal to \"%s\"", x) + } + + return transformDescription(Not(LessThan(x)), desc) +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/greater_than.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/greater_than.go new file mode 100644 index 0000000000..3eef32178f --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/greater_than.go @@ -0,0 +1,39 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package oglematchers + +import ( + "fmt" + "reflect" +) + +// GreaterThan returns a matcher that matches integer, floating point, or +// strings values v such that v > x. Comparison is not defined between numeric +// and string types, but is defined between all integer and floating point +// types. +// +// x must itself be an integer, floating point, or string type; otherwise, +// GreaterThan will panic. +func GreaterThan(x interface{}) Matcher { + desc := fmt.Sprintf("greater than %v", x) + + // Special case: make it clear that strings are strings. + if reflect.TypeOf(x).Kind() == reflect.String { + desc = fmt.Sprintf("greater than \"%s\"", x) + } + + return transformDescription(Not(LessOrEqual(x)), desc) +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as.go new file mode 100644 index 0000000000..3b286f7321 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as.go @@ -0,0 +1,37 @@ +// Copyright 2015 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package oglematchers + +import ( + "fmt" + "reflect" +) + +// HasSameTypeAs returns a matcher that matches values with exactly the same +// type as the supplied prototype. +func HasSameTypeAs(p interface{}) Matcher { + expected := reflect.TypeOf(p) + pred := func(c interface{}) error { + actual := reflect.TypeOf(c) + if actual != expected { + return fmt.Errorf("which has type %v", actual) + } + + return nil + } + + return NewMatcher(pred, fmt.Sprintf("has type %v", expected)) +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/has_substr.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/has_substr.go new file mode 100644 index 0000000000..bf5bd6ae6d --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/has_substr.go @@ -0,0 +1,46 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package oglematchers + +import ( + "errors" + "fmt" + "reflect" + "strings" +) + +// HasSubstr returns a matcher that matches strings containing s as a +// substring. +func HasSubstr(s string) Matcher { + return NewMatcher( + func(c interface{}) error { return hasSubstr(s, c) }, + fmt.Sprintf("has substring \"%s\"", s)) +} + +func hasSubstr(needle string, c interface{}) error { + v := reflect.ValueOf(c) + if v.Kind() != reflect.String { + return NewFatalError("which is not a string") + } + + // Perform the substring search. + haystack := v.String() + if strings.Contains(haystack, needle) { + return nil + } + + return errors.New("") +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/identical_to.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/identical_to.go new file mode 100644 index 0000000000..ae6460ed96 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/identical_to.go @@ -0,0 +1,134 @@ +// Copyright 2012 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package oglematchers + +import ( + "errors" + "fmt" + "reflect" +) + +// Is the type comparable according to the definition here? +// +// http://weekly.golang.org/doc/go_spec.html#Comparison_operators +// +func isComparable(t reflect.Type) bool { + switch t.Kind() { + case reflect.Array: + return isComparable(t.Elem()) + + case reflect.Struct: + for i := 0; i < t.NumField(); i++ { + if !isComparable(t.Field(i).Type) { + return false + } + } + + return true + + case reflect.Slice, reflect.Map, reflect.Func: + return false + } + + return true +} + +// Should the supplied type be allowed as an argument to IdenticalTo? +func isLegalForIdenticalTo(t reflect.Type) (bool, error) { + // Allow the zero type. + if t == nil { + return true, nil + } + + // Reference types are always okay; we compare pointers. + switch t.Kind() { + case reflect.Slice, reflect.Map, reflect.Func, reflect.Chan: + return true, nil + } + + // Reject other non-comparable types. + if !isComparable(t) { + return false, errors.New(fmt.Sprintf("%v is not comparable", t)) + } + + return true, nil +} + +// IdenticalTo(x) returns a matcher that matches values v with type identical +// to x such that: +// +// 1. If v and x are of a reference type (slice, map, function, channel), then +// they are either both nil or are references to the same object. +// +// 2. Otherwise, if v and x are not of a reference type but have a valid type, +// then v == x. +// +// If v and x are both the invalid type (which results from the predeclared nil +// value, or from nil interface variables), then the matcher is satisfied. +// +// This function will panic if x is of a value type that is not comparable. For +// example, x cannot be an array of functions. +func IdenticalTo(x interface{}) Matcher { + t := reflect.TypeOf(x) + + // Reject illegal arguments. + if ok, err := isLegalForIdenticalTo(t); !ok { + panic("IdenticalTo: " + err.Error()) + } + + return &identicalToMatcher{x} +} + +type identicalToMatcher struct { + x interface{} +} + +func (m *identicalToMatcher) Description() string { + t := reflect.TypeOf(m.x) + return fmt.Sprintf("identical to <%v> %v", t, m.x) +} + +func (m *identicalToMatcher) Matches(c interface{}) error { + // Make sure the candidate's type is correct. + t := reflect.TypeOf(m.x) + if ct := reflect.TypeOf(c); t != ct { + return NewFatalError(fmt.Sprintf("which is of type %v", ct)) + } + + // Special case: two values of the invalid type are always identical. + if t == nil { + return nil + } + + // Handle reference types. + switch t.Kind() { + case reflect.Slice, reflect.Map, reflect.Func, reflect.Chan: + xv := reflect.ValueOf(m.x) + cv := reflect.ValueOf(c) + if xv.Pointer() == cv.Pointer() { + return nil + } + + return errors.New("which is not an identical reference") + } + + // Are the values equal? + if m.x == c { + return nil + } + + return errors.New("") +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal.go new file mode 100644 index 0000000000..8402cdeaf0 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal.go @@ -0,0 +1,41 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package oglematchers + +import ( + "fmt" + "reflect" +) + +// LessOrEqual returns a matcher that matches integer, floating point, or +// strings values v such that v <= x. Comparison is not defined between numeric +// and string types, but is defined between all integer and floating point +// types. +// +// x must itself be an integer, floating point, or string type; otherwise, +// LessOrEqual will panic. +func LessOrEqual(x interface{}) Matcher { + desc := fmt.Sprintf("less than or equal to %v", x) + + // Special case: make it clear that strings are strings. + if reflect.TypeOf(x).Kind() == reflect.String { + desc = fmt.Sprintf("less than or equal to \"%s\"", x) + } + + // Put LessThan last so that its error messages will be used in the event of + // failure. + return transformDescription(AnyOf(Equals(x), LessThan(x)), desc) +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/less_than.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/less_than.go new file mode 100644 index 0000000000..8258e45d99 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/less_than.go @@ -0,0 +1,152 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package oglematchers + +import ( + "errors" + "fmt" + "math" + "reflect" +) + +// LessThan returns a matcher that matches integer, floating point, or strings +// values v such that v < x. Comparison is not defined between numeric and +// string types, but is defined between all integer and floating point types. +// +// x must itself be an integer, floating point, or string type; otherwise, +// LessThan will panic. +func LessThan(x interface{}) Matcher { + v := reflect.ValueOf(x) + kind := v.Kind() + + switch { + case isInteger(v): + case isFloat(v): + case kind == reflect.String: + + default: + panic(fmt.Sprintf("LessThan: unexpected kind %v", kind)) + } + + return &lessThanMatcher{v} +} + +type lessThanMatcher struct { + limit reflect.Value +} + +func (m *lessThanMatcher) Description() string { + // Special case: make it clear that strings are strings. + if m.limit.Kind() == reflect.String { + return fmt.Sprintf("less than \"%s\"", m.limit.String()) + } + + return fmt.Sprintf("less than %v", m.limit.Interface()) +} + +func compareIntegers(v1, v2 reflect.Value) (err error) { + err = errors.New("") + + switch { + case isSignedInteger(v1) && isSignedInteger(v2): + if v1.Int() < v2.Int() { + err = nil + } + return + + case isSignedInteger(v1) && isUnsignedInteger(v2): + if v1.Int() < 0 || uint64(v1.Int()) < v2.Uint() { + err = nil + } + return + + case isUnsignedInteger(v1) && isSignedInteger(v2): + if v1.Uint() <= math.MaxInt64 && int64(v1.Uint()) < v2.Int() { + err = nil + } + return + + case isUnsignedInteger(v1) && isUnsignedInteger(v2): + if v1.Uint() < v2.Uint() { + err = nil + } + return + } + + panic(fmt.Sprintf("compareIntegers: %v %v", v1, v2)) +} + +func getFloat(v reflect.Value) float64 { + switch { + case isSignedInteger(v): + return float64(v.Int()) + + case isUnsignedInteger(v): + return float64(v.Uint()) + + case isFloat(v): + return v.Float() + } + + panic(fmt.Sprintf("getFloat: %v", v)) +} + +func (m *lessThanMatcher) Matches(c interface{}) (err error) { + v1 := reflect.ValueOf(c) + v2 := m.limit + + err = errors.New("") + + // Handle strings as a special case. + if v1.Kind() == reflect.String && v2.Kind() == reflect.String { + if v1.String() < v2.String() { + err = nil + } + return + } + + // If we get here, we require that we are dealing with integers or floats. + v1Legal := isInteger(v1) || isFloat(v1) + v2Legal := isInteger(v2) || isFloat(v2) + if !v1Legal || !v2Legal { + err = NewFatalError("which is not comparable") + return + } + + // Handle the various comparison cases. + switch { + // Both integers + case isInteger(v1) && isInteger(v2): + return compareIntegers(v1, v2) + + // At least one float32 + case v1.Kind() == reflect.Float32 || v2.Kind() == reflect.Float32: + if float32(getFloat(v1)) < float32(getFloat(v2)) { + err = nil + } + return + + // At least one float64 + case v1.Kind() == reflect.Float64 || v2.Kind() == reflect.Float64: + if getFloat(v1) < getFloat(v2) { + err = nil + } + return + } + + // We shouldn't get here. + panic(fmt.Sprintf("lessThanMatcher.Matches: Shouldn't get here: %v %v", v1, v2)) +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/matcher.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/matcher.go new file mode 100644 index 0000000000..78159a0727 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/matcher.go @@ -0,0 +1,86 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package oglematchers provides a set of matchers useful in a testing or +// mocking framework. These matchers are inspired by and mostly compatible with +// Google Test for C++ and Google JS Test. +// +// This package is used by github.com/smartystreets/assertions/internal/ogletest and +// github.com/smartystreets/assertions/internal/oglemock, which may be more directly useful if you're not +// writing your own testing package or defining your own matchers. +package oglematchers + +// A Matcher is some predicate implicitly defining a set of values that it +// matches. For example, GreaterThan(17) matches all numeric values greater +// than 17, and HasSubstr("taco") matches all strings with the substring +// "taco". +// +// Matchers are typically exposed to tests via constructor functions like +// HasSubstr. In order to implement such a function you can either define your +// own matcher type or use NewMatcher. +type Matcher interface { + // Check whether the supplied value belongs to the the set defined by the + // matcher. Return a non-nil error if and only if it does not. + // + // The error describes why the value doesn't match. The error text is a + // relative clause that is suitable for being placed after the value. For + // example, a predicate that matches strings with a particular substring may, + // when presented with a numerical value, return the following error text: + // + // "which is not a string" + // + // Then the failure message may look like: + // + // Expected: has substring "taco" + // Actual: 17, which is not a string + // + // If the error is self-apparent based on the description of the matcher, the + // error text may be empty (but the error still non-nil). For example: + // + // Expected: 17 + // Actual: 19 + // + // If you are implementing a new matcher, see also the documentation on + // FatalError. + Matches(candidate interface{}) error + + // Description returns a string describing the property that values matching + // this matcher have, as a verb phrase where the subject is the value. For + // example, "is greather than 17" or "has substring "taco"". + Description() string +} + +// FatalError is an implementation of the error interface that may be returned +// from matchers, indicating the error should be propagated. Returning a +// *FatalError indicates that the matcher doesn't process values of the +// supplied type, or otherwise doesn't know how to handle the value. +// +// For example, if GreaterThan(17) returned false for the value "taco" without +// a fatal error, then Not(GreaterThan(17)) would return true. This is +// technically correct, but is surprising and may mask failures where the wrong +// sort of matcher is accidentally used. Instead, GreaterThan(17) can return a +// fatal error, which will be propagated by Not(). +type FatalError struct { + errorText string +} + +// NewFatalError creates a FatalError struct with the supplied error text. +func NewFatalError(s string) *FatalError { + return &FatalError{s} +} + +func (e *FatalError) Error() string { + return e.errorText +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp.go new file mode 100644 index 0000000000..1ed63f30c4 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp.go @@ -0,0 +1,69 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package oglematchers + +import ( + "errors" + "fmt" + "reflect" + "regexp" +) + +// MatchesRegexp returns a matcher that matches strings and byte slices whose +// contents match the supplied regular expression. The semantics are those of +// regexp.Match. In particular, that means the match is not implicitly anchored +// to the ends of the string: MatchesRegexp("bar") will match "foo bar baz". +func MatchesRegexp(pattern string) Matcher { + re, err := regexp.Compile(pattern) + if err != nil { + panic("MatchesRegexp: " + err.Error()) + } + + return &matchesRegexpMatcher{re} +} + +type matchesRegexpMatcher struct { + re *regexp.Regexp +} + +func (m *matchesRegexpMatcher) Description() string { + return fmt.Sprintf("matches regexp \"%s\"", m.re.String()) +} + +func (m *matchesRegexpMatcher) Matches(c interface{}) (err error) { + v := reflect.ValueOf(c) + isString := v.Kind() == reflect.String + isByteSlice := v.Kind() == reflect.Slice && v.Elem().Kind() == reflect.Uint8 + + err = errors.New("") + + switch { + case isString: + if m.re.MatchString(v.String()) { + err = nil + } + + case isByteSlice: + if m.re.Match(v.Bytes()) { + err = nil + } + + default: + err = NewFatalError("which is not a string or []byte") + } + + return +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/new_matcher.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/new_matcher.go new file mode 100644 index 0000000000..c9d8398ee6 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/new_matcher.go @@ -0,0 +1,43 @@ +// Copyright 2015 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package oglematchers + +// Create a matcher with the given description and predicate function, which +// will be invoked to handle calls to Matchers. +// +// Using this constructor may be a convenience over defining your own type that +// implements Matcher if you do not need any logic in your Description method. +func NewMatcher( + predicate func(interface{}) error, + description string) Matcher { + return &predicateMatcher{ + predicate: predicate, + description: description, + } +} + +type predicateMatcher struct { + predicate func(interface{}) error + description string +} + +func (pm *predicateMatcher) Matches(c interface{}) error { + return pm.predicate(c) +} + +func (pm *predicateMatcher) Description() string { + return pm.description +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/not.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/not.go new file mode 100644 index 0000000000..623789fe28 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/not.go @@ -0,0 +1,53 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package oglematchers + +import ( + "errors" + "fmt" +) + +// Not returns a matcher that inverts the set of values matched by the wrapped +// matcher. It does not transform the result for values for which the wrapped +// matcher returns a fatal error. +func Not(m Matcher) Matcher { + return ¬Matcher{m} +} + +type notMatcher struct { + wrapped Matcher +} + +func (m *notMatcher) Matches(c interface{}) (err error) { + err = m.wrapped.Matches(c) + + // Did the wrapped matcher say yes? + if err == nil { + return errors.New("") + } + + // Did the wrapped matcher return a fatal error? + if _, isFatal := err.(*FatalError); isFatal { + return err + } + + // The wrapped matcher returned a non-fatal error. + return nil +} + +func (m *notMatcher) Description() string { + return fmt.Sprintf("not(%s)", m.wrapped.Description()) +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/panics.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/panics.go new file mode 100644 index 0000000000..d2cfc97869 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/panics.go @@ -0,0 +1,74 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package oglematchers + +import ( + "errors" + "fmt" + "reflect" +) + +// Panics matches zero-arg functions which, when invoked, panic with an error +// that matches the supplied matcher. +// +// NOTE(jacobsa): This matcher cannot detect the case where the function panics +// using panic(nil), by design of the language. See here for more info: +// +// http://goo.gl/9aIQL +// +func Panics(m Matcher) Matcher { + return &panicsMatcher{m} +} + +type panicsMatcher struct { + wrappedMatcher Matcher +} + +func (m *panicsMatcher) Description() string { + return "panics with: " + m.wrappedMatcher.Description() +} + +func (m *panicsMatcher) Matches(c interface{}) (err error) { + // Make sure c is a zero-arg function. + v := reflect.ValueOf(c) + if v.Kind() != reflect.Func || v.Type().NumIn() != 0 { + err = NewFatalError("which is not a zero-arg function") + return + } + + // Call the function and check its panic error. + defer func() { + if e := recover(); e != nil { + err = m.wrappedMatcher.Matches(e) + + // Set a clearer error message if the matcher said no. + if err != nil { + wrappedClause := "" + if err.Error() != "" { + wrappedClause = ", " + err.Error() + } + + err = errors.New(fmt.Sprintf("which panicked with: %v%s", e, wrappedClause)) + } + } + }() + + v.Call([]reflect.Value{}) + + // If we get here, the function didn't panic. + err = errors.New("which didn't panic") + return +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/pointee.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/pointee.go new file mode 100644 index 0000000000..c5383f2402 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/pointee.go @@ -0,0 +1,65 @@ +// Copyright 2012 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package oglematchers + +import ( + "errors" + "fmt" + "reflect" +) + +// Return a matcher that matches non-nil pointers whose pointee matches the +// wrapped matcher. +func Pointee(m Matcher) Matcher { + return &pointeeMatcher{m} +} + +type pointeeMatcher struct { + wrapped Matcher +} + +func (m *pointeeMatcher) Matches(c interface{}) (err error) { + // Make sure the candidate is of the appropriate type. + cv := reflect.ValueOf(c) + if !cv.IsValid() || cv.Kind() != reflect.Ptr { + return NewFatalError("which is not a pointer") + } + + // Make sure the candidate is non-nil. + if cv.IsNil() { + return NewFatalError("") + } + + // Defer to the wrapped matcher. Fix up empty errors so that failure messages + // are more helpful than just printing a pointer for "Actual". + pointee := cv.Elem().Interface() + err = m.wrapped.Matches(pointee) + if err != nil && err.Error() == "" { + s := fmt.Sprintf("whose pointee is %v", pointee) + + if _, ok := err.(*FatalError); ok { + err = NewFatalError(s) + } else { + err = errors.New(s) + } + } + + return err +} + +func (m *pointeeMatcher) Description() string { + return fmt.Sprintf("pointee(%s)", m.wrapped.Description()) +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/transform_description.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/transform_description.go new file mode 100644 index 0000000000..f79d0c03db --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/transform_description.go @@ -0,0 +1,36 @@ +// Copyright 2011 Aaron Jacobs. All Rights Reserved. +// Author: aaronjjacobs@gmail.com (Aaron Jacobs) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package oglematchers + +// transformDescription returns a matcher that is equivalent to the supplied +// one, except that it has the supplied description instead of the one attached +// to the existing matcher. +func transformDescription(m Matcher, newDesc string) Matcher { + return &transformDescriptionMatcher{newDesc, m} +} + +type transformDescriptionMatcher struct { + desc string + wrappedMatcher Matcher +} + +func (m *transformDescriptionMatcher) Description() string { + return m.desc +} + +func (m *transformDescriptionMatcher) Matches(c interface{}) error { + return m.wrappedMatcher.Matches(c) +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/messages.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/messages.go new file mode 100644 index 0000000000..9c57ab2b8b --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/messages.go @@ -0,0 +1,93 @@ +package assertions + +const ( // equality + shouldHaveBeenEqual = "Expected: '%v'\nActual: '%v'\n(Should be equal)" + shouldNotHaveBeenEqual = "Expected '%v'\nto NOT equal '%v'\n(but it did)!" + shouldHaveBeenEqualTypeMismatch = "Expected: '%v' (%T)\nActual: '%v' (%T)\n(Should be equal, type mismatch)" + shouldHaveBeenAlmostEqual = "Expected '%v' to almost equal '%v' (but it didn't)!" + shouldHaveNotBeenAlmostEqual = "Expected '%v' to NOT almost equal '%v' (but it did)!" + shouldHaveResembled = "Expected: '%s'\nActual: '%s'\n(Should resemble)!" + shouldNotHaveResembled = "Expected '%#v'\nto NOT resemble '%#v'\n(but it did)!" + shouldBePointers = "Both arguments should be pointers " + shouldHaveBeenNonNilPointer = shouldBePointers + "(the %s was %s)!" + shouldHavePointedTo = "Expected '%+v' (address: '%v') and '%+v' (address: '%v') to be the same address (but their weren't)!" + shouldNotHavePointedTo = "Expected '%+v' and '%+v' to be different references (but they matched: '%v')!" + shouldHaveBeenNil = "Expected: nil\nActual: '%v'" + shouldNotHaveBeenNil = "Expected '%+v' to NOT be nil (but it was)!" + shouldHaveBeenTrue = "Expected: true\nActual: %v" + shouldHaveBeenFalse = "Expected: false\nActual: %v" + shouldHaveBeenZeroValue = "'%+v' should have been the zero value" //"Expected: (zero value)\nActual: %v" +) + +const ( // quantity comparisons + shouldHaveBeenGreater = "Expected '%v' to be greater than '%v' (but it wasn't)!" + shouldHaveBeenGreaterOrEqual = "Expected '%v' to be greater than or equal to '%v' (but it wasn't)!" + shouldHaveBeenLess = "Expected '%v' to be less than '%v' (but it wasn't)!" + shouldHaveBeenLessOrEqual = "Expected '%v' to be less than or equal to '%v' (but it wasn't)!" + shouldHaveBeenBetween = "Expected '%v' to be between '%v' and '%v' (but it wasn't)!" + shouldNotHaveBeenBetween = "Expected '%v' NOT to be between '%v' and '%v' (but it was)!" + shouldHaveDifferentUpperAndLower = "The lower and upper bounds must be different values (they were both '%v')." + shouldHaveBeenBetweenOrEqual = "Expected '%v' to be between '%v' and '%v' or equal to one of them (but it wasn't)!" + shouldNotHaveBeenBetweenOrEqual = "Expected '%v' NOT to be between '%v' and '%v' or equal to one of them (but it was)!" +) + +const ( // collections + shouldHaveContained = "Expected the container (%v) to contain: '%v' (but it didn't)!" + shouldNotHaveContained = "Expected the container (%v) NOT to contain: '%v' (but it did)!" + shouldHaveContainedKey = "Expected the %v to contain the key: %v (but it didn't)!" + shouldNotHaveContainedKey = "Expected the %v NOT to contain the key: %v (but it did)!" + shouldHaveBeenIn = "Expected '%v' to be in the container (%v), but it wasn't!" + shouldNotHaveBeenIn = "Expected '%v' NOT to be in the container (%v), but it was!" + shouldHaveBeenAValidCollection = "You must provide a valid container (was %v)!" + shouldHaveBeenAValidMap = "You must provide a valid map type (was %v)!" + shouldHaveBeenEmpty = "Expected %+v to be empty (but it wasn't)!" + shouldNotHaveBeenEmpty = "Expected %+v to NOT be empty (but it was)!" + shouldHaveBeenAValidInteger = "You must provide a valid integer (was %v)!" + shouldHaveBeenAValidLength = "You must provide a valid positive integer (was %v)!" + shouldHaveHadLength = "Expected %+v (length: %v) to have length equal to '%v', but it wasn't!" +) + +const ( // strings + shouldHaveStartedWith = "Expected '%v'\nto start with '%v'\n(but it didn't)!" + shouldNotHaveStartedWith = "Expected '%v'\nNOT to start with '%v'\n(but it did)!" + shouldHaveEndedWith = "Expected '%v'\nto end with '%v'\n(but it didn't)!" + shouldNotHaveEndedWith = "Expected '%v'\nNOT to end with '%v'\n(but it did)!" + shouldAllBeStrings = "All arguments to this assertion must be strings (you provided: %v)." + shouldBothBeStrings = "Both arguments to this assertion must be strings (you provided %v and %v)." + shouldBeString = "The argument to this assertion must be a string (you provided %v)." + shouldHaveContainedSubstring = "Expected '%s' to contain substring '%s' (but it didn't)!" + shouldNotHaveContainedSubstring = "Expected '%s' NOT to contain substring '%s' (but it did)!" + shouldHaveBeenBlank = "Expected '%s' to be blank (but it wasn't)!" + shouldNotHaveBeenBlank = "Expected value to NOT be blank (but it was)!" +) + +const ( // panics + shouldUseVoidNiladicFunction = "You must provide a void, niladic function as the first argument!" + shouldHavePanickedWith = "Expected func() to panic with '%v' (but it panicked with '%v')!" + shouldHavePanicked = "Expected func() to panic (but it didn't)!" + shouldNotHavePanicked = "Expected func() NOT to panic (error: '%+v')!" + shouldNotHavePanickedWith = "Expected func() NOT to panic with '%v' (but it did)!" +) + +const ( // type checking + shouldHaveBeenA = "Expected '%v' to be: '%v' (but was: '%v')!" + shouldNotHaveBeenA = "Expected '%v' to NOT be: '%v' (but it was)!" + + shouldHaveImplemented = "Expected: '%v interface support'\nActual: '%v' does not implement the interface!" + shouldNotHaveImplemented = "Expected '%v'\nto NOT implement '%v'\n(but it did)!" + shouldCompareWithInterfacePointer = "The expected value must be a pointer to an interface type (eg. *fmt.Stringer)" + shouldNotBeNilActual = "The actual value was 'nil' and should be a value or a pointer to a value!" +) + +const ( // time comparisons + shouldUseTimes = "You must provide time instances as arguments to this assertion." + shouldUseTimeSlice = "You must provide a slice of time instances as the first argument to this assertion." + shouldUseDurationAndTime = "You must provide a duration and a time as arguments to this assertion." + shouldHaveHappenedBefore = "Expected '%v' to happen before '%v' (it happened '%v' after)!" + shouldHaveHappenedAfter = "Expected '%v' to happen after '%v' (it happened '%v' before)!" + shouldHaveHappenedBetween = "Expected '%v' to happen between '%v' and '%v' (it happened '%v' outside threshold)!" + shouldNotHaveHappenedOnOrBetween = "Expected '%v' to NOT happen on or between '%v' and '%v' (but it did)!" + + // format params: incorrect-index, previous-index, previous-time, incorrect-index, incorrect-time + shouldHaveBeenChronological = "The 'Time' at index [%d] should have happened after the previous one (but it didn't!):\n [%d]: %s\n [%d]: %s (see, it happened before!)" +) diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/panic.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/panic.go new file mode 100644 index 0000000000..7e75db1784 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/panic.go @@ -0,0 +1,115 @@ +package assertions + +import "fmt" + +// ShouldPanic receives a void, niladic function and expects to recover a panic. +func ShouldPanic(actual interface{}, expected ...interface{}) (message string) { + if fail := need(0, expected); fail != success { + return fail + } + + action, _ := actual.(func()) + + if action == nil { + message = shouldUseVoidNiladicFunction + return + } + + defer func() { + recovered := recover() + if recovered == nil { + message = shouldHavePanicked + } else { + message = success + } + }() + action() + + return +} + +// ShouldNotPanic receives a void, niladic function and expects to execute the function without any panic. +func ShouldNotPanic(actual interface{}, expected ...interface{}) (message string) { + if fail := need(0, expected); fail != success { + return fail + } + + action, _ := actual.(func()) + + if action == nil { + message = shouldUseVoidNiladicFunction + return + } + + defer func() { + recovered := recover() + if recovered != nil { + message = fmt.Sprintf(shouldNotHavePanicked, recovered) + } else { + message = success + } + }() + action() + + return +} + +// ShouldPanicWith receives a void, niladic function and expects to recover a panic with the second argument as the content. +func ShouldPanicWith(actual interface{}, expected ...interface{}) (message string) { + if fail := need(1, expected); fail != success { + return fail + } + + action, _ := actual.(func()) + + if action == nil { + message = shouldUseVoidNiladicFunction + return + } + + defer func() { + recovered := recover() + if recovered == nil { + message = shouldHavePanicked + } else { + if equal := ShouldEqual(recovered, expected[0]); equal != success { + message = serializer.serialize(expected[0], recovered, fmt.Sprintf(shouldHavePanickedWith, expected[0], recovered)) + } else { + message = success + } + } + }() + action() + + return +} + +// ShouldNotPanicWith receives a void, niladic function and expects to recover a panic whose content differs from the second argument. +func ShouldNotPanicWith(actual interface{}, expected ...interface{}) (message string) { + if fail := need(1, expected); fail != success { + return fail + } + + action, _ := actual.(func()) + + if action == nil { + message = shouldUseVoidNiladicFunction + return + } + + defer func() { + recovered := recover() + if recovered == nil { + message = success + } else { + if equal := ShouldEqual(recovered, expected[0]); equal == success { + message = fmt.Sprintf(shouldNotHavePanickedWith, expected[0]) + } else { + message = success + } + } + }() + action() + + return +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/quantity.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/quantity.go new file mode 100644 index 0000000000..f28b0a062b --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/quantity.go @@ -0,0 +1,141 @@ +package assertions + +import ( + "fmt" + + "github.com/smartystreets/assertions/internal/oglematchers" +) + +// ShouldBeGreaterThan receives exactly two parameters and ensures that the first is greater than the second. +func ShouldBeGreaterThan(actual interface{}, expected ...interface{}) string { + if fail := need(1, expected); fail != success { + return fail + } + + if matchError := oglematchers.GreaterThan(expected[0]).Matches(actual); matchError != nil { + return fmt.Sprintf(shouldHaveBeenGreater, actual, expected[0]) + } + return success +} + +// ShouldBeGreaterThanOrEqualTo receives exactly two parameters and ensures that the first is greater than or equal to the second. +func ShouldBeGreaterThanOrEqualTo(actual interface{}, expected ...interface{}) string { + if fail := need(1, expected); fail != success { + return fail + } else if matchError := oglematchers.GreaterOrEqual(expected[0]).Matches(actual); matchError != nil { + return fmt.Sprintf(shouldHaveBeenGreaterOrEqual, actual, expected[0]) + } + return success +} + +// ShouldBeLessThan receives exactly two parameters and ensures that the first is less than the second. +func ShouldBeLessThan(actual interface{}, expected ...interface{}) string { + if fail := need(1, expected); fail != success { + return fail + } else if matchError := oglematchers.LessThan(expected[0]).Matches(actual); matchError != nil { + return fmt.Sprintf(shouldHaveBeenLess, actual, expected[0]) + } + return success +} + +// ShouldBeLessThan receives exactly two parameters and ensures that the first is less than or equal to the second. +func ShouldBeLessThanOrEqualTo(actual interface{}, expected ...interface{}) string { + if fail := need(1, expected); fail != success { + return fail + } else if matchError := oglematchers.LessOrEqual(expected[0]).Matches(actual); matchError != nil { + return fmt.Sprintf(shouldHaveBeenLessOrEqual, actual, expected[0]) + } + return success +} + +// ShouldBeBetween receives exactly three parameters: an actual value, a lower bound, and an upper bound. +// It ensures that the actual value is between both bounds (but not equal to either of them). +func ShouldBeBetween(actual interface{}, expected ...interface{}) string { + if fail := need(2, expected); fail != success { + return fail + } + lower, upper, fail := deriveBounds(expected) + + if fail != success { + return fail + } else if !isBetween(actual, lower, upper) { + return fmt.Sprintf(shouldHaveBeenBetween, actual, lower, upper) + } + return success +} + +// ShouldNotBeBetween receives exactly three parameters: an actual value, a lower bound, and an upper bound. +// It ensures that the actual value is NOT between both bounds. +func ShouldNotBeBetween(actual interface{}, expected ...interface{}) string { + if fail := need(2, expected); fail != success { + return fail + } + lower, upper, fail := deriveBounds(expected) + + if fail != success { + return fail + } else if isBetween(actual, lower, upper) { + return fmt.Sprintf(shouldNotHaveBeenBetween, actual, lower, upper) + } + return success +} +func deriveBounds(values []interface{}) (lower interface{}, upper interface{}, fail string) { + lower = values[0] + upper = values[1] + + if ShouldNotEqual(lower, upper) != success { + return nil, nil, fmt.Sprintf(shouldHaveDifferentUpperAndLower, lower) + } else if ShouldBeLessThan(lower, upper) != success { + lower, upper = upper, lower + } + return lower, upper, success +} +func isBetween(value, lower, upper interface{}) bool { + if ShouldBeGreaterThan(value, lower) != success { + return false + } else if ShouldBeLessThan(value, upper) != success { + return false + } + return true +} + +// ShouldBeBetweenOrEqual receives exactly three parameters: an actual value, a lower bound, and an upper bound. +// It ensures that the actual value is between both bounds or equal to one of them. +func ShouldBeBetweenOrEqual(actual interface{}, expected ...interface{}) string { + if fail := need(2, expected); fail != success { + return fail + } + lower, upper, fail := deriveBounds(expected) + + if fail != success { + return fail + } else if !isBetweenOrEqual(actual, lower, upper) { + return fmt.Sprintf(shouldHaveBeenBetweenOrEqual, actual, lower, upper) + } + return success +} + +// ShouldNotBeBetweenOrEqual receives exactly three parameters: an actual value, a lower bound, and an upper bound. +// It ensures that the actual value is nopt between the bounds nor equal to either of them. +func ShouldNotBeBetweenOrEqual(actual interface{}, expected ...interface{}) string { + if fail := need(2, expected); fail != success { + return fail + } + lower, upper, fail := deriveBounds(expected) + + if fail != success { + return fail + } else if isBetweenOrEqual(actual, lower, upper) { + return fmt.Sprintf(shouldNotHaveBeenBetweenOrEqual, actual, lower, upper) + } + return success +} + +func isBetweenOrEqual(value, lower, upper interface{}) bool { + if ShouldBeGreaterThanOrEqualTo(value, lower) != success { + return false + } else if ShouldBeLessThanOrEqualTo(value, upper) != success { + return false + } + return true +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/serializer.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/serializer.go new file mode 100644 index 0000000000..90ae3e3b69 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/serializer.go @@ -0,0 +1,69 @@ +package assertions + +import ( + "encoding/json" + "fmt" + + "github.com/smartystreets/assertions/internal/go-render/render" +) + +type Serializer interface { + serialize(expected, actual interface{}, message string) string + serializeDetailed(expected, actual interface{}, message string) string +} + +type failureSerializer struct{} + +func (self *failureSerializer) serializeDetailed(expected, actual interface{}, message string) string { + view := FailureView{ + Message: message, + Expected: render.Render(expected), + Actual: render.Render(actual), + } + serialized, err := json.Marshal(view) + if err != nil { + return message + } + return string(serialized) +} + +func (self *failureSerializer) serialize(expected, actual interface{}, message string) string { + view := FailureView{ + Message: message, + Expected: fmt.Sprintf("%+v", expected), + Actual: fmt.Sprintf("%+v", actual), + } + serialized, err := json.Marshal(view) + if err != nil { + return message + } + return string(serialized) +} + +func newSerializer() *failureSerializer { + return &failureSerializer{} +} + +/////////////////////////////////////////////////////////////////////////////// + +// This struct is also declared in github.com/smartystreets/goconvey/convey/reporting. +// The json struct tags should be equal in both declarations. +type FailureView struct { + Message string `json:"Message"` + Expected string `json:"Expected"` + Actual string `json:"Actual"` +} + +/////////////////////////////////////////////////////// + +// noopSerializer just gives back the original message. This is useful when we are using +// the assertions from a context other than the web UI, that requires the JSON structure +// provided by the failureSerializer. +type noopSerializer struct{} + +func (self *noopSerializer) serialize(expected, actual interface{}, message string) string { + return message +} +func (self *noopSerializer) serializeDetailed(expected, actual interface{}, message string) string { + return message +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/strings.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/strings.go new file mode 100644 index 0000000000..dbc3f04790 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/strings.go @@ -0,0 +1,227 @@ +package assertions + +import ( + "fmt" + "reflect" + "strings" +) + +// ShouldStartWith receives exactly 2 string parameters and ensures that the first starts with the second. +func ShouldStartWith(actual interface{}, expected ...interface{}) string { + if fail := need(1, expected); fail != success { + return fail + } + + value, valueIsString := actual.(string) + prefix, prefixIsString := expected[0].(string) + + if !valueIsString || !prefixIsString { + return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) + } + + return shouldStartWith(value, prefix) +} +func shouldStartWith(value, prefix string) string { + if !strings.HasPrefix(value, prefix) { + shortval := value + if len(shortval) > len(prefix) { + shortval = shortval[:len(prefix)] + "..." + } + return serializer.serialize(prefix, shortval, fmt.Sprintf(shouldHaveStartedWith, value, prefix)) + } + return success +} + +// ShouldNotStartWith receives exactly 2 string parameters and ensures that the first does not start with the second. +func ShouldNotStartWith(actual interface{}, expected ...interface{}) string { + if fail := need(1, expected); fail != success { + return fail + } + + value, valueIsString := actual.(string) + prefix, prefixIsString := expected[0].(string) + + if !valueIsString || !prefixIsString { + return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) + } + + return shouldNotStartWith(value, prefix) +} +func shouldNotStartWith(value, prefix string) string { + if strings.HasPrefix(value, prefix) { + if value == "" { + value = "" + } + if prefix == "" { + prefix = "" + } + return fmt.Sprintf(shouldNotHaveStartedWith, value, prefix) + } + return success +} + +// ShouldEndWith receives exactly 2 string parameters and ensures that the first ends with the second. +func ShouldEndWith(actual interface{}, expected ...interface{}) string { + if fail := need(1, expected); fail != success { + return fail + } + + value, valueIsString := actual.(string) + suffix, suffixIsString := expected[0].(string) + + if !valueIsString || !suffixIsString { + return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) + } + + return shouldEndWith(value, suffix) +} +func shouldEndWith(value, suffix string) string { + if !strings.HasSuffix(value, suffix) { + shortval := value + if len(shortval) > len(suffix) { + shortval = "..." + shortval[len(shortval)-len(suffix):] + } + return serializer.serialize(suffix, shortval, fmt.Sprintf(shouldHaveEndedWith, value, suffix)) + } + return success +} + +// ShouldEndWith receives exactly 2 string parameters and ensures that the first does not end with the second. +func ShouldNotEndWith(actual interface{}, expected ...interface{}) string { + if fail := need(1, expected); fail != success { + return fail + } + + value, valueIsString := actual.(string) + suffix, suffixIsString := expected[0].(string) + + if !valueIsString || !suffixIsString { + return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) + } + + return shouldNotEndWith(value, suffix) +} +func shouldNotEndWith(value, suffix string) string { + if strings.HasSuffix(value, suffix) { + if value == "" { + value = "" + } + if suffix == "" { + suffix = "" + } + return fmt.Sprintf(shouldNotHaveEndedWith, value, suffix) + } + return success +} + +// ShouldContainSubstring receives exactly 2 string parameters and ensures that the first contains the second as a substring. +func ShouldContainSubstring(actual interface{}, expected ...interface{}) string { + if fail := need(1, expected); fail != success { + return fail + } + + long, longOk := actual.(string) + short, shortOk := expected[0].(string) + + if !longOk || !shortOk { + return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) + } + + if !strings.Contains(long, short) { + return serializer.serialize(expected[0], actual, fmt.Sprintf(shouldHaveContainedSubstring, long, short)) + } + return success +} + +// ShouldNotContainSubstring receives exactly 2 string parameters and ensures that the first does NOT contain the second as a substring. +func ShouldNotContainSubstring(actual interface{}, expected ...interface{}) string { + if fail := need(1, expected); fail != success { + return fail + } + + long, longOk := actual.(string) + short, shortOk := expected[0].(string) + + if !longOk || !shortOk { + return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) + } + + if strings.Contains(long, short) { + return fmt.Sprintf(shouldNotHaveContainedSubstring, long, short) + } + return success +} + +// ShouldBeBlank receives exactly 1 string parameter and ensures that it is equal to "". +func ShouldBeBlank(actual interface{}, expected ...interface{}) string { + if fail := need(0, expected); fail != success { + return fail + } + value, ok := actual.(string) + if !ok { + return fmt.Sprintf(shouldBeString, reflect.TypeOf(actual)) + } + if value != "" { + return serializer.serialize("", value, fmt.Sprintf(shouldHaveBeenBlank, value)) + } + return success +} + +// ShouldNotBeBlank receives exactly 1 string parameter and ensures that it is equal to "". +func ShouldNotBeBlank(actual interface{}, expected ...interface{}) string { + if fail := need(0, expected); fail != success { + return fail + } + value, ok := actual.(string) + if !ok { + return fmt.Sprintf(shouldBeString, reflect.TypeOf(actual)) + } + if value == "" { + return shouldNotHaveBeenBlank + } + return success +} + +// ShouldEqualWithout receives exactly 3 string parameters and ensures that the first is equal to the second +// after removing all instances of the third from the first using strings.Replace(first, third, "", -1). +func ShouldEqualWithout(actual interface{}, expected ...interface{}) string { + if fail := need(2, expected); fail != success { + return fail + } + actualString, ok1 := actual.(string) + expectedString, ok2 := expected[0].(string) + replace, ok3 := expected[1].(string) + + if !ok1 || !ok2 || !ok3 { + return fmt.Sprintf(shouldAllBeStrings, []reflect.Type{ + reflect.TypeOf(actual), + reflect.TypeOf(expected[0]), + reflect.TypeOf(expected[1]), + }) + } + + replaced := strings.Replace(actualString, replace, "", -1) + if replaced == expectedString { + return "" + } + + return fmt.Sprintf("Expected '%s' to equal '%s' but without any '%s' (but it didn't).", actualString, expectedString, replace) +} + +// ShouldEqualTrimSpace receives exactly 2 string parameters and ensures that the first is equal to the second +// after removing all leading and trailing whitespace using strings.TrimSpace(first). +func ShouldEqualTrimSpace(actual interface{}, expected ...interface{}) string { + if fail := need(1, expected); fail != success { + return fail + } + + actualString, valueIsString := actual.(string) + _, value2IsString := expected[0].(string) + + if !valueIsString || !value2IsString { + return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) + } + + actualString = strings.TrimSpace(actualString) + return ShouldEqual(actualString, expected[0]) +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/time.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/time.go new file mode 100644 index 0000000000..7e05026143 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/time.go @@ -0,0 +1,202 @@ +package assertions + +import ( + "fmt" + "time" +) + +// ShouldHappenBefore receives exactly 2 time.Time arguments and asserts that the first happens before the second. +func ShouldHappenBefore(actual interface{}, expected ...interface{}) string { + if fail := need(1, expected); fail != success { + return fail + } + actualTime, firstOk := actual.(time.Time) + expectedTime, secondOk := expected[0].(time.Time) + + if !firstOk || !secondOk { + return shouldUseTimes + } + + if !actualTime.Before(expectedTime) { + return fmt.Sprintf(shouldHaveHappenedBefore, actualTime, expectedTime, actualTime.Sub(expectedTime)) + } + + return success +} + +// ShouldHappenOnOrBefore receives exactly 2 time.Time arguments and asserts that the first happens on or before the second. +func ShouldHappenOnOrBefore(actual interface{}, expected ...interface{}) string { + if fail := need(1, expected); fail != success { + return fail + } + actualTime, firstOk := actual.(time.Time) + expectedTime, secondOk := expected[0].(time.Time) + + if !firstOk || !secondOk { + return shouldUseTimes + } + + if actualTime.Equal(expectedTime) { + return success + } + return ShouldHappenBefore(actualTime, expectedTime) +} + +// ShouldHappenAfter receives exactly 2 time.Time arguments and asserts that the first happens after the second. +func ShouldHappenAfter(actual interface{}, expected ...interface{}) string { + if fail := need(1, expected); fail != success { + return fail + } + actualTime, firstOk := actual.(time.Time) + expectedTime, secondOk := expected[0].(time.Time) + + if !firstOk || !secondOk { + return shouldUseTimes + } + if !actualTime.After(expectedTime) { + return fmt.Sprintf(shouldHaveHappenedAfter, actualTime, expectedTime, expectedTime.Sub(actualTime)) + } + return success +} + +// ShouldHappenOnOrAfter receives exactly 2 time.Time arguments and asserts that the first happens on or after the second. +func ShouldHappenOnOrAfter(actual interface{}, expected ...interface{}) string { + if fail := need(1, expected); fail != success { + return fail + } + actualTime, firstOk := actual.(time.Time) + expectedTime, secondOk := expected[0].(time.Time) + + if !firstOk || !secondOk { + return shouldUseTimes + } + if actualTime.Equal(expectedTime) { + return success + } + return ShouldHappenAfter(actualTime, expectedTime) +} + +// ShouldHappenBetween receives exactly 3 time.Time arguments and asserts that the first happens between (not on) the second and third. +func ShouldHappenBetween(actual interface{}, expected ...interface{}) string { + if fail := need(2, expected); fail != success { + return fail + } + actualTime, firstOk := actual.(time.Time) + min, secondOk := expected[0].(time.Time) + max, thirdOk := expected[1].(time.Time) + + if !firstOk || !secondOk || !thirdOk { + return shouldUseTimes + } + + if !actualTime.After(min) { + return fmt.Sprintf(shouldHaveHappenedBetween, actualTime, min, max, min.Sub(actualTime)) + } + if !actualTime.Before(max) { + return fmt.Sprintf(shouldHaveHappenedBetween, actualTime, min, max, actualTime.Sub(max)) + } + return success +} + +// ShouldHappenOnOrBetween receives exactly 3 time.Time arguments and asserts that the first happens between or on the second and third. +func ShouldHappenOnOrBetween(actual interface{}, expected ...interface{}) string { + if fail := need(2, expected); fail != success { + return fail + } + actualTime, firstOk := actual.(time.Time) + min, secondOk := expected[0].(time.Time) + max, thirdOk := expected[1].(time.Time) + + if !firstOk || !secondOk || !thirdOk { + return shouldUseTimes + } + if actualTime.Equal(min) || actualTime.Equal(max) { + return success + } + return ShouldHappenBetween(actualTime, min, max) +} + +// ShouldNotHappenOnOrBetween receives exactly 3 time.Time arguments and asserts that the first +// does NOT happen between or on the second or third. +func ShouldNotHappenOnOrBetween(actual interface{}, expected ...interface{}) string { + if fail := need(2, expected); fail != success { + return fail + } + actualTime, firstOk := actual.(time.Time) + min, secondOk := expected[0].(time.Time) + max, thirdOk := expected[1].(time.Time) + + if !firstOk || !secondOk || !thirdOk { + return shouldUseTimes + } + if actualTime.Equal(min) || actualTime.Equal(max) { + return fmt.Sprintf(shouldNotHaveHappenedOnOrBetween, actualTime, min, max) + } + if actualTime.After(min) && actualTime.Before(max) { + return fmt.Sprintf(shouldNotHaveHappenedOnOrBetween, actualTime, min, max) + } + return success +} + +// ShouldHappenWithin receives a time.Time, a time.Duration, and a time.Time (3 arguments) +// and asserts that the first time.Time happens within or on the duration specified relative to +// the other time.Time. +func ShouldHappenWithin(actual interface{}, expected ...interface{}) string { + if fail := need(2, expected); fail != success { + return fail + } + actualTime, firstOk := actual.(time.Time) + tolerance, secondOk := expected[0].(time.Duration) + threshold, thirdOk := expected[1].(time.Time) + + if !firstOk || !secondOk || !thirdOk { + return shouldUseDurationAndTime + } + + min := threshold.Add(-tolerance) + max := threshold.Add(tolerance) + return ShouldHappenOnOrBetween(actualTime, min, max) +} + +// ShouldNotHappenWithin receives a time.Time, a time.Duration, and a time.Time (3 arguments) +// and asserts that the first time.Time does NOT happen within or on the duration specified relative to +// the other time.Time. +func ShouldNotHappenWithin(actual interface{}, expected ...interface{}) string { + if fail := need(2, expected); fail != success { + return fail + } + actualTime, firstOk := actual.(time.Time) + tolerance, secondOk := expected[0].(time.Duration) + threshold, thirdOk := expected[1].(time.Time) + + if !firstOk || !secondOk || !thirdOk { + return shouldUseDurationAndTime + } + + min := threshold.Add(-tolerance) + max := threshold.Add(tolerance) + return ShouldNotHappenOnOrBetween(actualTime, min, max) +} + +// ShouldBeChronological receives a []time.Time slice and asserts that the are +// in chronological order starting with the first time.Time as the earliest. +func ShouldBeChronological(actual interface{}, expected ...interface{}) string { + if fail := need(0, expected); fail != success { + return fail + } + + times, ok := actual.([]time.Time) + if !ok { + return shouldUseTimeSlice + } + + var previous time.Time + for i, current := range times { + if i > 0 && current.Before(previous) { + return fmt.Sprintf(shouldHaveBeenChronological, + i, i-1, previous.String(), i, current.String()) + } + previous = current + } + return "" +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/type.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/type.go new file mode 100644 index 0000000000..3fc00f68cd --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/assertions/type.go @@ -0,0 +1,112 @@ +package assertions + +import ( + "fmt" + "reflect" +) + +// ShouldHaveSameTypeAs receives exactly two parameters and compares their underlying types for equality. +func ShouldHaveSameTypeAs(actual interface{}, expected ...interface{}) string { + if fail := need(1, expected); fail != success { + return fail + } + + first := reflect.TypeOf(actual) + second := reflect.TypeOf(expected[0]) + + if equal := ShouldEqual(first, second); equal != success { + return serializer.serialize(second, first, fmt.Sprintf(shouldHaveBeenA, actual, second, first)) + } + return success +} + +// ShouldNotHaveSameTypeAs receives exactly two parameters and compares their underlying types for inequality. +func ShouldNotHaveSameTypeAs(actual interface{}, expected ...interface{}) string { + if fail := need(1, expected); fail != success { + return fail + } + + first := reflect.TypeOf(actual) + second := reflect.TypeOf(expected[0]) + + if equal := ShouldEqual(first, second); equal == success { + return fmt.Sprintf(shouldNotHaveBeenA, actual, second) + } + return success +} + +// ShouldImplement receives exactly two parameters and ensures +// that the first implements the interface type of the second. +func ShouldImplement(actual interface{}, expectedList ...interface{}) string { + if fail := need(1, expectedList); fail != success { + return fail + } + + expected := expectedList[0] + if fail := ShouldBeNil(expected); fail != success { + return shouldCompareWithInterfacePointer + } + + if fail := ShouldNotBeNil(actual); fail != success { + return shouldNotBeNilActual + } + + var actualType reflect.Type + if reflect.TypeOf(actual).Kind() != reflect.Ptr { + actualType = reflect.PtrTo(reflect.TypeOf(actual)) + } else { + actualType = reflect.TypeOf(actual) + } + + expectedType := reflect.TypeOf(expected) + if fail := ShouldNotBeNil(expectedType); fail != success { + return shouldCompareWithInterfacePointer + } + + expectedInterface := expectedType.Elem() + + if actualType == nil { + return fmt.Sprintf(shouldHaveImplemented, expectedInterface, actual) + } + + if !actualType.Implements(expectedInterface) { + return fmt.Sprintf(shouldHaveImplemented, expectedInterface, actualType) + } + return success +} + +// ShouldNotImplement receives exactly two parameters and ensures +// that the first does NOT implement the interface type of the second. +func ShouldNotImplement(actual interface{}, expectedList ...interface{}) string { + if fail := need(1, expectedList); fail != success { + return fail + } + + expected := expectedList[0] + if fail := ShouldBeNil(expected); fail != success { + return shouldCompareWithInterfacePointer + } + + if fail := ShouldNotBeNil(actual); fail != success { + return shouldNotBeNilActual + } + + var actualType reflect.Type + if reflect.TypeOf(actual).Kind() != reflect.Ptr { + actualType = reflect.PtrTo(reflect.TypeOf(actual)) + } else { + actualType = reflect.TypeOf(actual) + } + + expectedType := reflect.TypeOf(expected) + if fail := ShouldNotBeNil(expectedType); fail != success { + return shouldCompareWithInterfacePointer + } + + expectedInterface := expectedType.Elem() + + if actualType.Implements(expectedInterface) { + return fmt.Sprintf(shouldNotHaveImplemented, actualType, expectedInterface) + } + return success +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/LICENSE.md b/Godeps/_workspace/src/github.com/smartystreets/goconvey/LICENSE.md new file mode 100644 index 0000000000..3f87a40e77 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/goconvey/LICENSE.md @@ -0,0 +1,23 @@ +Copyright (c) 2016 SmartyStreets, LLC + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +NOTE: Various optional and subordinate components carry their own licensing +requirements and restrictions. Use of those components is subject to the terms +and conditions outlined the respective license of each component. diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/assertions.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/assertions.go new file mode 100644 index 0000000000..1e87b826df --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/assertions.go @@ -0,0 +1,68 @@ +package convey + +import "github.com/smartystreets/assertions" + +var ( + ShouldEqual = assertions.ShouldEqual + ShouldNotEqual = assertions.ShouldNotEqual + ShouldAlmostEqual = assertions.ShouldAlmostEqual + ShouldNotAlmostEqual = assertions.ShouldNotAlmostEqual + ShouldResemble = assertions.ShouldResemble + ShouldNotResemble = assertions.ShouldNotResemble + ShouldPointTo = assertions.ShouldPointTo + ShouldNotPointTo = assertions.ShouldNotPointTo + ShouldBeNil = assertions.ShouldBeNil + ShouldNotBeNil = assertions.ShouldNotBeNil + ShouldBeTrue = assertions.ShouldBeTrue + ShouldBeFalse = assertions.ShouldBeFalse + ShouldBeZeroValue = assertions.ShouldBeZeroValue + + ShouldBeGreaterThan = assertions.ShouldBeGreaterThan + ShouldBeGreaterThanOrEqualTo = assertions.ShouldBeGreaterThanOrEqualTo + ShouldBeLessThan = assertions.ShouldBeLessThan + ShouldBeLessThanOrEqualTo = assertions.ShouldBeLessThanOrEqualTo + ShouldBeBetween = assertions.ShouldBeBetween + ShouldNotBeBetween = assertions.ShouldNotBeBetween + ShouldBeBetweenOrEqual = assertions.ShouldBeBetweenOrEqual + ShouldNotBeBetweenOrEqual = assertions.ShouldNotBeBetweenOrEqual + + ShouldContain = assertions.ShouldContain + ShouldNotContain = assertions.ShouldNotContain + ShouldContainKey = assertions.ShouldContainKey + ShouldNotContainKey = assertions.ShouldNotContainKey + ShouldBeIn = assertions.ShouldBeIn + ShouldNotBeIn = assertions.ShouldNotBeIn + ShouldBeEmpty = assertions.ShouldBeEmpty + ShouldNotBeEmpty = assertions.ShouldNotBeEmpty + ShouldHaveLength = assertions.ShouldHaveLength + + ShouldStartWith = assertions.ShouldStartWith + ShouldNotStartWith = assertions.ShouldNotStartWith + ShouldEndWith = assertions.ShouldEndWith + ShouldNotEndWith = assertions.ShouldNotEndWith + ShouldBeBlank = assertions.ShouldBeBlank + ShouldNotBeBlank = assertions.ShouldNotBeBlank + ShouldContainSubstring = assertions.ShouldContainSubstring + ShouldNotContainSubstring = assertions.ShouldNotContainSubstring + + ShouldPanic = assertions.ShouldPanic + ShouldNotPanic = assertions.ShouldNotPanic + ShouldPanicWith = assertions.ShouldPanicWith + ShouldNotPanicWith = assertions.ShouldNotPanicWith + + ShouldHaveSameTypeAs = assertions.ShouldHaveSameTypeAs + ShouldNotHaveSameTypeAs = assertions.ShouldNotHaveSameTypeAs + ShouldImplement = assertions.ShouldImplement + ShouldNotImplement = assertions.ShouldNotImplement + + ShouldHappenBefore = assertions.ShouldHappenBefore + ShouldHappenOnOrBefore = assertions.ShouldHappenOnOrBefore + ShouldHappenAfter = assertions.ShouldHappenAfter + ShouldHappenOnOrAfter = assertions.ShouldHappenOnOrAfter + ShouldHappenBetween = assertions.ShouldHappenBetween + ShouldHappenOnOrBetween = assertions.ShouldHappenOnOrBetween + ShouldNotHappenOnOrBetween = assertions.ShouldNotHappenOnOrBetween + ShouldHappenWithin = assertions.ShouldHappenWithin + ShouldNotHappenWithin = assertions.ShouldNotHappenWithin + ShouldBeChronological = assertions.ShouldBeChronological +) diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/context.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/context.go new file mode 100644 index 0000000000..2c75c2d7b1 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/context.go @@ -0,0 +1,272 @@ +package convey + +import ( + "fmt" + + "github.com/jtolds/gls" + "github.com/smartystreets/goconvey/convey/reporting" +) + +type conveyErr struct { + fmt string + params []interface{} +} + +func (e *conveyErr) Error() string { + return fmt.Sprintf(e.fmt, e.params...) +} + +func conveyPanic(fmt string, params ...interface{}) { + panic(&conveyErr{fmt, params}) +} + +const ( + missingGoTest = `Top-level calls to Convey(...) need a reference to the *testing.T. + Hint: Convey("description here", t, func() { /* notice that the second argument was the *testing.T (t)! */ }) ` + extraGoTest = `Only the top-level call to Convey(...) needs a reference to the *testing.T.` + noStackContext = "Convey operation made without context on goroutine stack.\n" + + "Hint: Perhaps you meant to use `Convey(..., func(c C){...})` ?" + differentConveySituations = "Different set of Convey statements on subsequent pass!\nDid not expect %#v." + multipleIdenticalConvey = "Multiple convey suites with identical names: %#v" +) + +const ( + failureHalt = "___FAILURE_HALT___" + + nodeKey = "node" +) + +///////////////////////////////// Stack Context ///////////////////////////////// + +func getCurrentContext() *context { + ctx, ok := ctxMgr.GetValue(nodeKey) + if ok { + return ctx.(*context) + } + return nil +} + +func mustGetCurrentContext() *context { + ctx := getCurrentContext() + if ctx == nil { + conveyPanic(noStackContext) + } + return ctx +} + +//////////////////////////////////// Context //////////////////////////////////// + +// context magically handles all coordination of Convey's and So assertions. +// +// It is tracked on the stack as goroutine-local-storage with the gls package, +// or explicitly if the user decides to call convey like: +// +// Convey(..., func(c C) { +// c.So(...) +// }) +// +// This implements the `C` interface. +type context struct { + reporter reporting.Reporter + + children map[string]*context + + resets []func() + + executedOnce bool + expectChildRun *bool + complete bool + + focus bool + failureMode FailureMode +} + +// rootConvey is the main entry point to a test suite. This is called when +// there's no context in the stack already, and items must contain a `t` object, +// or this panics. +func rootConvey(items ...interface{}) { + entry := discover(items) + + if entry.Test == nil { + conveyPanic(missingGoTest) + } + + expectChildRun := true + ctx := &context{ + reporter: buildReporter(), + + children: make(map[string]*context), + + expectChildRun: &expectChildRun, + + focus: entry.Focus, + failureMode: defaultFailureMode.combine(entry.FailMode), + } + ctxMgr.SetValues(gls.Values{nodeKey: ctx}, func() { + ctx.reporter.BeginStory(reporting.NewStoryReport(entry.Test)) + defer ctx.reporter.EndStory() + + for ctx.shouldVisit() { + ctx.conveyInner(entry.Situation, entry.Func) + expectChildRun = true + } + }) +} + +//////////////////////////////////// Methods //////////////////////////////////// + +func (ctx *context) SkipConvey(items ...interface{}) { + ctx.Convey(items, skipConvey) +} + +func (ctx *context) FocusConvey(items ...interface{}) { + ctx.Convey(items, focusConvey) +} + +func (ctx *context) Convey(items ...interface{}) { + entry := discover(items) + + // we're a branch, or leaf (on the wind) + if entry.Test != nil { + conveyPanic(extraGoTest) + } + if ctx.focus && !entry.Focus { + return + } + + var inner_ctx *context + if ctx.executedOnce { + var ok bool + inner_ctx, ok = ctx.children[entry.Situation] + if !ok { + conveyPanic(differentConveySituations, entry.Situation) + } + } else { + if _, ok := ctx.children[entry.Situation]; ok { + conveyPanic(multipleIdenticalConvey, entry.Situation) + } + inner_ctx = &context{ + reporter: ctx.reporter, + + children: make(map[string]*context), + + expectChildRun: ctx.expectChildRun, + + focus: entry.Focus, + failureMode: ctx.failureMode.combine(entry.FailMode), + } + ctx.children[entry.Situation] = inner_ctx + } + + if inner_ctx.shouldVisit() { + ctxMgr.SetValues(gls.Values{nodeKey: inner_ctx}, func() { + inner_ctx.conveyInner(entry.Situation, entry.Func) + }) + } +} + +func (ctx *context) SkipSo(stuff ...interface{}) { + ctx.assertionReport(reporting.NewSkipReport()) +} + +func (ctx *context) So(actual interface{}, assert assertion, expected ...interface{}) { + if result := assert(actual, expected...); result == assertionSuccess { + ctx.assertionReport(reporting.NewSuccessReport()) + } else { + ctx.assertionReport(reporting.NewFailureReport(result)) + } +} + +func (ctx *context) Reset(action func()) { + /* TODO: Failure mode configuration */ + ctx.resets = append(ctx.resets, action) +} + +func (ctx *context) Print(items ...interface{}) (int, error) { + fmt.Fprint(ctx.reporter, items...) + return fmt.Print(items...) +} + +func (ctx *context) Println(items ...interface{}) (int, error) { + fmt.Fprintln(ctx.reporter, items...) + return fmt.Println(items...) +} + +func (ctx *context) Printf(format string, items ...interface{}) (int, error) { + fmt.Fprintf(ctx.reporter, format, items...) + return fmt.Printf(format, items...) +} + +//////////////////////////////////// Private //////////////////////////////////// + +// shouldVisit returns true iff we should traverse down into a Convey. Note +// that just because we don't traverse a Convey this time, doesn't mean that +// we may not traverse it on a subsequent pass. +func (c *context) shouldVisit() bool { + return !c.complete && *c.expectChildRun +} + +// conveyInner is the function which actually executes the user's anonymous test +// function body. At this point, Convey or RootConvey has decided that this +// function should actually run. +func (ctx *context) conveyInner(situation string, f func(C)) { + // Record/Reset state for next time. + defer func() { + ctx.executedOnce = true + + // This is only needed at the leaves, but there's no harm in also setting it + // when returning from branch Convey's + *ctx.expectChildRun = false + }() + + // Set up+tear down our scope for the reporter + ctx.reporter.Enter(reporting.NewScopeReport(situation)) + defer ctx.reporter.Exit() + + // Recover from any panics in f, and assign the `complete` status for this + // node of the tree. + defer func() { + ctx.complete = true + if problem := recover(); problem != nil { + if problem, ok := problem.(*conveyErr); ok { + panic(problem) + } + if problem != failureHalt { + ctx.reporter.Report(reporting.NewErrorReport(problem)) + } + } else { + for _, child := range ctx.children { + if !child.complete { + ctx.complete = false + return + } + } + } + }() + + // Resets are registered as the `f` function executes, so nil them here. + // All resets are run in registration order (FIFO). + ctx.resets = []func(){} + defer func() { + for _, r := range ctx.resets { + // panics handled by the previous defer + r() + } + }() + + if f == nil { + // if f is nil, this was either a Convey(..., nil), or a SkipConvey + ctx.reporter.Report(reporting.NewSkipReport()) + } else { + f(ctx) + } +} + +// assertionReport is a helper for So and SkipSo which makes the report and +// then possibly panics, depending on the current context's failureMode. +func (ctx *context) assertionReport(r *reporting.AssertionResult) { + ctx.reporter.Report(r) + if r.Failure != "" && ctx.failureMode == FailureHalts { + panic(failureHalt) + } +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/convey.goconvey b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/convey.goconvey new file mode 100644 index 0000000000..a2d9327dc9 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/convey.goconvey @@ -0,0 +1,4 @@ +#ignore +-timeout=1s +#-covermode=count +#-coverpkg=github.com/smartystreets/goconvey/convey,github.com/smartystreets/goconvey/convey/gotest,github.com/smartystreets/goconvey/convey/reporting \ No newline at end of file diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/discovery.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/discovery.go new file mode 100644 index 0000000000..eb8d4cb2ce --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/discovery.go @@ -0,0 +1,103 @@ +package convey + +type actionSpecifier uint8 + +const ( + noSpecifier actionSpecifier = iota + skipConvey + focusConvey +) + +type suite struct { + Situation string + Test t + Focus bool + Func func(C) // nil means skipped + FailMode FailureMode +} + +func newSuite(situation string, failureMode FailureMode, f func(C), test t, specifier actionSpecifier) *suite { + ret := &suite{ + Situation: situation, + Test: test, + Func: f, + FailMode: failureMode, + } + switch specifier { + case skipConvey: + ret.Func = nil + case focusConvey: + ret.Focus = true + } + return ret +} + +func discover(items []interface{}) *suite { + name, items := parseName(items) + test, items := parseGoTest(items) + failure, items := parseFailureMode(items) + action, items := parseAction(items) + specifier, items := parseSpecifier(items) + + if len(items) != 0 { + conveyPanic(parseError) + } + + return newSuite(name, failure, action, test, specifier) +} +func item(items []interface{}) interface{} { + if len(items) == 0 { + conveyPanic(parseError) + } + return items[0] +} +func parseName(items []interface{}) (string, []interface{}) { + if name, parsed := item(items).(string); parsed { + return name, items[1:] + } + conveyPanic(parseError) + panic("never get here") +} +func parseGoTest(items []interface{}) (t, []interface{}) { + if test, parsed := item(items).(t); parsed { + return test, items[1:] + } + return nil, items +} +func parseFailureMode(items []interface{}) (FailureMode, []interface{}) { + if mode, parsed := item(items).(FailureMode); parsed { + return mode, items[1:] + } + return FailureInherits, items +} +func parseAction(items []interface{}) (func(C), []interface{}) { + switch x := item(items).(type) { + case nil: + return nil, items[1:] + case func(C): + return x, items[1:] + case func(): + return func(C) { x() }, items[1:] + } + conveyPanic(parseError) + panic("never get here") +} +func parseSpecifier(items []interface{}) (actionSpecifier, []interface{}) { + if len(items) == 0 { + return noSpecifier, items + } + if spec, ok := items[0].(actionSpecifier); ok { + return spec, items[1:] + } + conveyPanic(parseError) + panic("never get here") +} + +// This interface allows us to pass the *testing.T struct +// throughout the internals of this package without ever +// having to import the "testing" package. +type t interface { + Fail() +} + +const parseError = "You must provide a name (string), then a *testing.T (if in outermost scope), an optional FailureMode, and then an action (func())." diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/doc.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/doc.go new file mode 100644 index 0000000000..2562ce4c28 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/doc.go @@ -0,0 +1,218 @@ +// Package convey contains all of the public-facing entry points to this project. +// This means that it should never be required of the user to import any other +// packages from this project as they serve internal purposes. +package convey + +import "github.com/smartystreets/goconvey/convey/reporting" + +////////////////////////////////// suite ////////////////////////////////// + +// C is the Convey context which you can optionally obtain in your action +// by calling Convey like: +// +// Convey(..., func(c C) { +// ... +// }) +// +// See the documentation on Convey for more details. +// +// All methods in this context behave identically to the global functions of the +// same name in this package. +type C interface { + Convey(items ...interface{}) + SkipConvey(items ...interface{}) + FocusConvey(items ...interface{}) + + So(actual interface{}, assert assertion, expected ...interface{}) + SkipSo(stuff ...interface{}) + + Reset(action func()) + + Println(items ...interface{}) (int, error) + Print(items ...interface{}) (int, error) + Printf(format string, items ...interface{}) (int, error) +} + +// Convey is the method intended for use when declaring the scopes of +// a specification. Each scope has a description and a func() which may contain +// other calls to Convey(), Reset() or Should-style assertions. Convey calls can +// be nested as far as you see fit. +// +// IMPORTANT NOTE: The top-level Convey() within a Test method +// must conform to the following signature: +// +// Convey(description string, t *testing.T, action func()) +// +// All other calls should look like this (no need to pass in *testing.T): +// +// Convey(description string, action func()) +// +// Don't worry, goconvey will panic if you get it wrong so you can fix it. +// +// Additionally, you may explicitly obtain access to the Convey context by doing: +// +// Convey(description string, action func(c C)) +// +// You may need to do this if you want to pass the context through to a +// goroutine, or to close over the context in a handler to a library which +// calls your handler in a goroutine (httptest comes to mind). +// +// All Convey()-blocks also accept an optional parameter of FailureMode which sets +// how goconvey should treat failures for So()-assertions in the block and +// nested blocks. See the constants in this file for the available options. +// +// By default it will inherit from its parent block and the top-level blocks +// default to the FailureHalts setting. +// +// This parameter is inserted before the block itself: +// +// Convey(description string, t *testing.T, mode FailureMode, action func()) +// Convey(description string, mode FailureMode, action func()) +// +// See the examples package for, well, examples. +func Convey(items ...interface{}) { + if ctx := getCurrentContext(); ctx == nil { + rootConvey(items...) + } else { + ctx.Convey(items...) + } +} + +// SkipConvey is analagous to Convey except that the scope is not executed +// (which means that child scopes defined within this scope are not run either). +// The reporter will be notified that this step was skipped. +func SkipConvey(items ...interface{}) { + Convey(append(items, skipConvey)...) +} + +// FocusConvey is has the inverse effect of SkipConvey. If the top-level +// Convey is changed to `FocusConvey`, only nested scopes that are defined +// with FocusConvey will be run. The rest will be ignored completely. This +// is handy when debugging a large suite that runs a misbehaving function +// repeatedly as you can disable all but one of that function +// without swaths of `SkipConvey` calls, just a targeted chain of calls +// to FocusConvey. +func FocusConvey(items ...interface{}) { + Convey(append(items, focusConvey)...) +} + +// Reset registers a cleanup function to be run after each Convey() +// in the same scope. See the examples package for a simple use case. +func Reset(action func()) { + mustGetCurrentContext().Reset(action) +} + +/////////////////////////////////// Assertions /////////////////////////////////// + +// assertion is an alias for a function with a signature that the convey.So() +// method can handle. Any future or custom assertions should conform to this +// method signature. The return value should be an empty string if the assertion +// passes and a well-formed failure message if not. +type assertion func(actual interface{}, expected ...interface{}) string + +const assertionSuccess = "" + +// So is the means by which assertions are made against the system under test. +// The majority of exported names in the assertions package begin with the word +// 'Should' and describe how the first argument (actual) should compare with any +// of the final (expected) arguments. How many final arguments are accepted +// depends on the particular assertion that is passed in as the assert argument. +// See the examples package for use cases and the assertions package for +// documentation on specific assertion methods. A failing assertion will +// cause t.Fail() to be invoked--you should never call this method (or other +// failure-inducing methods) in your test code. Leave that to GoConvey. +func So(actual interface{}, assert assertion, expected ...interface{}) { + mustGetCurrentContext().So(actual, assert, expected...) +} + +// SkipSo is analagous to So except that the assertion that would have been passed +// to So is not executed and the reporter is notified that the assertion was skipped. +func SkipSo(stuff ...interface{}) { + mustGetCurrentContext().SkipSo() +} + +// FailureMode is a type which determines how the So() blocks should fail +// if their assertion fails. See constants further down for acceptable values +type FailureMode string + +const ( + + // FailureContinues is a failure mode which prevents failing + // So()-assertions from halting Convey-block execution, instead + // allowing the test to continue past failing So()-assertions. + FailureContinues FailureMode = "continue" + + // FailureHalts is the default setting for a top-level Convey()-block + // and will cause all failing So()-assertions to halt further execution + // in that test-arm and continue on to the next arm. + FailureHalts FailureMode = "halt" + + // FailureInherits is the default setting for failure-mode, it will + // default to the failure-mode of the parent block. You should never + // need to specify this mode in your tests.. + FailureInherits FailureMode = "inherits" +) + +func (f FailureMode) combine(other FailureMode) FailureMode { + if other == FailureInherits { + return f + } + return other +} + +var defaultFailureMode FailureMode = FailureHalts + +// SetDefaultFailureMode allows you to specify the default failure mode +// for all Convey blocks. It is meant to be used in an init function to +// allow the default mode to be changdd across all tests for an entire packgae +// but it can be used anywhere. +func SetDefaultFailureMode(mode FailureMode) { + if mode == FailureContinues || mode == FailureHalts { + defaultFailureMode = mode + } else { + panic("You may only use the constants named 'FailureContinues' and 'FailureHalts' as default failure modes.") + } +} + +//////////////////////////////////// Print functions //////////////////////////////////// + +// Print is analogous to fmt.Print (and it even calls fmt.Print). It ensures that +// output is aligned with the corresponding scopes in the web UI. +func Print(items ...interface{}) (written int, err error) { + return mustGetCurrentContext().Print(items...) +} + +// Print is analogous to fmt.Println (and it even calls fmt.Println). It ensures that +// output is aligned with the corresponding scopes in the web UI. +func Println(items ...interface{}) (written int, err error) { + return mustGetCurrentContext().Println(items...) +} + +// Print is analogous to fmt.Printf (and it even calls fmt.Printf). It ensures that +// output is aligned with the corresponding scopes in the web UI. +func Printf(format string, items ...interface{}) (written int, err error) { + return mustGetCurrentContext().Printf(format, items...) +} + +/////////////////////////////////////////////////////////////////////////////// + +// SuppressConsoleStatistics prevents automatic printing of console statistics. +// Calling PrintConsoleStatistics explicitly will force printing of statistics. +func SuppressConsoleStatistics() { + reporting.SuppressConsoleStatistics() +} + +// ConsoleStatistics may be called at any time to print assertion statistics. +// Generally, the best place to do this would be in a TestMain function, +// after all tests have been run. Something like this: +// +// func TestMain(m *testing.M) { +// convey.SuppressConsoleStatistics() +// result := m.Run() +// convey.PrintConsoleStatistics() +// os.Exit(result) +// } +// +func PrintConsoleStatistics() { + reporting.PrintConsoleStatistics() +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/gotest/utils.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/gotest/utils.go new file mode 100644 index 0000000000..3a5c848a44 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/gotest/utils.go @@ -0,0 +1,28 @@ +// Package gotest contains internal functionality. Although this package +// contains one or more exported names it is not intended for public +// consumption. See the examples package for how to use this project. +package gotest + +import ( + "runtime" + "strings" +) + +func ResolveExternalCaller() (file string, line int, name string) { + var caller_id uintptr + callers := runtime.Callers(0, callStack) + + for x := 0; x < callers; x++ { + caller_id, file, line, _ = runtime.Caller(x) + if strings.HasSuffix(file, "_test.go") || strings.HasSuffix(file, "_tests.go") { + name = runtime.FuncForPC(caller_id).Name() + return + } + } + file, line, name = "", -1, "" + return // panic? +} + +const maxStackDepth = 100 // This had better be enough... + +var callStack []uintptr = make([]uintptr, maxStackDepth, maxStackDepth) diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/init.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/init.go new file mode 100644 index 0000000000..1d77ff3dcd --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/init.go @@ -0,0 +1,81 @@ +package convey + +import ( + "flag" + "os" + + "github.com/jtolds/gls" + "github.com/smartystreets/assertions" + "github.com/smartystreets/goconvey/convey/reporting" +) + +func init() { + assertions.GoConveyMode(true) + + declareFlags() + + ctxMgr = gls.NewContextManager() +} + +func declareFlags() { + flag.BoolVar(&json, "convey-json", false, "When true, emits results in JSON blocks. Default: 'false'") + flag.BoolVar(&silent, "convey-silent", false, "When true, all output from GoConvey is suppressed.") + flag.BoolVar(&story, "convey-story", false, "When true, emits story output, otherwise emits dot output. When not provided, this flag mirros the value of the '-test.v' flag") + + if noStoryFlagProvided() { + story = verboseEnabled + } + + // FYI: flag.Parse() is called from the testing package. +} + +func noStoryFlagProvided() bool { + return !story && !storyDisabled +} + +func buildReporter() reporting.Reporter { + selectReporter := os.Getenv("GOCONVEY_REPORTER") + + switch { + case testReporter != nil: + return testReporter + case json || selectReporter == "json": + return reporting.BuildJsonReporter() + case silent || selectReporter == "silent": + return reporting.BuildSilentReporter() + case selectReporter == "dot": + // Story is turned on when verbose is set, so we need to check for dot reporter first. + return reporting.BuildDotReporter() + case story || selectReporter == "story": + return reporting.BuildStoryReporter() + default: + return reporting.BuildDotReporter() + } +} + +var ( + ctxMgr *gls.ContextManager + + // only set by internal tests + testReporter reporting.Reporter +) + +var ( + json bool + silent bool + story bool + + verboseEnabled = flagFound("-test.v=true") + storyDisabled = flagFound("-story=false") +) + +// flagFound parses the command line args manually for flags defined in other +// packages. Like the '-v' flag from the "testing" package, for instance. +func flagFound(flagValue string) bool { + for _, arg := range os.Args { + if arg == flagValue { + return true + } + } + return false +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/nilReporter.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/nilReporter.go new file mode 100644 index 0000000000..777b2a5122 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/nilReporter.go @@ -0,0 +1,15 @@ +package convey + +import ( + "github.com/smartystreets/goconvey/convey/reporting" +) + +type nilReporter struct{} + +func (self *nilReporter) BeginStory(story *reporting.StoryReport) {} +func (self *nilReporter) Enter(scope *reporting.ScopeReport) {} +func (self *nilReporter) Report(report *reporting.AssertionResult) {} +func (self *nilReporter) Exit() {} +func (self *nilReporter) EndStory() {} +func (self *nilReporter) Write(p []byte) (int, error) { return len(p), nil } +func newNilReporter() *nilReporter { return &nilReporter{} } diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/console.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/console.go new file mode 100644 index 0000000000..7bf67dbb2b --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/console.go @@ -0,0 +1,16 @@ +package reporting + +import ( + "fmt" + "io" +) + +type console struct{} + +func (self *console) Write(p []byte) (n int, err error) { + return fmt.Print(string(p)) +} + +func NewConsole() io.Writer { + return new(console) +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/doc.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/doc.go new file mode 100644 index 0000000000..a37d001946 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/doc.go @@ -0,0 +1,5 @@ +// Package reporting contains internal functionality related +// to console reporting and output. Although this package has +// exported names is not intended for public consumption. See the +// examples package for how to use this project. +package reporting diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/dot.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/dot.go new file mode 100644 index 0000000000..47d57c6b0d --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/dot.go @@ -0,0 +1,40 @@ +package reporting + +import "fmt" + +type dot struct{ out *Printer } + +func (self *dot) BeginStory(story *StoryReport) {} + +func (self *dot) Enter(scope *ScopeReport) {} + +func (self *dot) Report(report *AssertionResult) { + if report.Error != nil { + fmt.Print(redColor) + self.out.Insert(dotError) + } else if report.Failure != "" { + fmt.Print(yellowColor) + self.out.Insert(dotFailure) + } else if report.Skipped { + fmt.Print(yellowColor) + self.out.Insert(dotSkip) + } else { + fmt.Print(greenColor) + self.out.Insert(dotSuccess) + } + fmt.Print(resetColor) +} + +func (self *dot) Exit() {} + +func (self *dot) EndStory() {} + +func (self *dot) Write(content []byte) (written int, err error) { + return len(content), nil // no-op +} + +func NewDotReporter(out *Printer) *dot { + self := new(dot) + self.out = out + return self +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/gotest.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/gotest.go new file mode 100644 index 0000000000..c396e16b17 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/gotest.go @@ -0,0 +1,33 @@ +package reporting + +type gotestReporter struct{ test T } + +func (self *gotestReporter) BeginStory(story *StoryReport) { + self.test = story.Test +} + +func (self *gotestReporter) Enter(scope *ScopeReport) {} + +func (self *gotestReporter) Report(r *AssertionResult) { + if !passed(r) { + self.test.Fail() + } +} + +func (self *gotestReporter) Exit() {} + +func (self *gotestReporter) EndStory() { + self.test = nil +} + +func (self *gotestReporter) Write(content []byte) (written int, err error) { + return len(content), nil // no-op +} + +func NewGoTestReporter() *gotestReporter { + return new(gotestReporter) +} + +func passed(r *AssertionResult) bool { + return r.Error == nil && r.Failure == "" +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/init.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/init.go new file mode 100644 index 0000000000..44d080e90e --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/init.go @@ -0,0 +1,94 @@ +package reporting + +import ( + "os" + "runtime" + "strings" +) + +func init() { + if !isColorableTerminal() { + monochrome() + } + + if runtime.GOOS == "windows" { + success, failure, error_ = dotSuccess, dotFailure, dotError + } +} + +func BuildJsonReporter() Reporter { + out := NewPrinter(NewConsole()) + return NewReporters( + NewGoTestReporter(), + NewJsonReporter(out)) +} +func BuildDotReporter() Reporter { + out := NewPrinter(NewConsole()) + return NewReporters( + NewGoTestReporter(), + NewDotReporter(out), + NewProblemReporter(out), + consoleStatistics) +} +func BuildStoryReporter() Reporter { + out := NewPrinter(NewConsole()) + return NewReporters( + NewGoTestReporter(), + NewStoryReporter(out), + NewProblemReporter(out), + consoleStatistics) +} +func BuildSilentReporter() Reporter { + out := NewPrinter(NewConsole()) + return NewReporters( + NewGoTestReporter(), + NewSilentProblemReporter(out)) +} + +var ( + newline = "\n" + success = "✔" + failure = "✘" + error_ = "🔥" + skip = "⚠" + dotSuccess = "." + dotFailure = "x" + dotError = "E" + dotSkip = "S" + errorTemplate = "* %s \nLine %d: - %v \n%s\n" + failureTemplate = "* %s \nLine %d:\n%s\n" +) + +var ( + greenColor = "\033[32m" + yellowColor = "\033[33m" + redColor = "\033[31m" + resetColor = "\033[0m" +) + +var consoleStatistics = NewStatisticsReporter(NewPrinter(NewConsole())) + +func SuppressConsoleStatistics() { consoleStatistics.Suppress() } +func PrintConsoleStatistics() { consoleStatistics.PrintSummary() } + +// QuiteMode disables all console output symbols. This is only meant to be used +// for tests that are internal to goconvey where the output is distracting or +// otherwise not needed in the test output. +func QuietMode() { + success, failure, error_, skip, dotSuccess, dotFailure, dotError, dotSkip = "", "", "", "", "", "", "", "" +} + +func monochrome() { + greenColor, yellowColor, redColor, resetColor = "", "", "", "" +} + +func isColorableTerminal() bool { + return strings.Contains(os.Getenv("TERM"), "color") +} + +// This interface allows us to pass the *testing.T struct +// throughout the internals of this tool without ever +// having to import the "testing" package. +type T interface { + Fail() +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/json.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/json.go new file mode 100644 index 0000000000..f8526979f8 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/json.go @@ -0,0 +1,88 @@ +// TODO: under unit test + +package reporting + +import ( + "bytes" + "encoding/json" + "fmt" + "strings" +) + +type JsonReporter struct { + out *Printer + currentKey []string + current *ScopeResult + index map[string]*ScopeResult + scopes []*ScopeResult +} + +func (self *JsonReporter) depth() int { return len(self.currentKey) } + +func (self *JsonReporter) BeginStory(story *StoryReport) {} + +func (self *JsonReporter) Enter(scope *ScopeReport) { + self.currentKey = append(self.currentKey, scope.Title) + ID := strings.Join(self.currentKey, "|") + if _, found := self.index[ID]; !found { + next := newScopeResult(scope.Title, self.depth(), scope.File, scope.Line) + self.scopes = append(self.scopes, next) + self.index[ID] = next + } + self.current = self.index[ID] +} + +func (self *JsonReporter) Report(report *AssertionResult) { + self.current.Assertions = append(self.current.Assertions, report) +} + +func (self *JsonReporter) Exit() { + self.currentKey = self.currentKey[:len(self.currentKey)-1] +} + +func (self *JsonReporter) EndStory() { + self.report() + self.reset() +} +func (self *JsonReporter) report() { + scopes := []string{} + for _, scope := range self.scopes { + serialized, err := json.Marshal(scope) + if err != nil { + self.out.Println(jsonMarshalFailure) + panic(err) + } + var buffer bytes.Buffer + json.Indent(&buffer, serialized, "", " ") + scopes = append(scopes, buffer.String()) + } + self.out.Print(fmt.Sprintf("%s\n%s,\n%s\n", OpenJson, strings.Join(scopes, ","), CloseJson)) +} +func (self *JsonReporter) reset() { + self.scopes = []*ScopeResult{} + self.index = map[string]*ScopeResult{} + self.currentKey = nil +} + +func (self *JsonReporter) Write(content []byte) (written int, err error) { + self.current.Output += string(content) + return len(content), nil +} + +func NewJsonReporter(out *Printer) *JsonReporter { + self := new(JsonReporter) + self.out = out + self.reset() + return self +} + +const OpenJson = ">->->OPEN-JSON->->->" // "⌦" +const CloseJson = "<-<-<-CLOSE-JSON<-<-<" // "⌫" +const jsonMarshalFailure = ` + +GOCONVEY_JSON_MARSHALL_FAILURE: There was an error when attempting to convert test results to JSON. +Please file a bug report and reference the code that caused this failure if possible. + +Here's the panic: + +` diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/printer.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/printer.go new file mode 100644 index 0000000000..6d4a879c40 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/printer.go @@ -0,0 +1,57 @@ +package reporting + +import ( + "fmt" + "io" + "strings" +) + +type Printer struct { + out io.Writer + prefix string +} + +func (self *Printer) Println(message string, values ...interface{}) { + formatted := self.format(message, values...) + newline + self.out.Write([]byte(formatted)) +} + +func (self *Printer) Print(message string, values ...interface{}) { + formatted := self.format(message, values...) + self.out.Write([]byte(formatted)) +} + +func (self *Printer) Insert(text string) { + self.out.Write([]byte(text)) +} + +func (self *Printer) format(message string, values ...interface{}) string { + var formatted string + if len(values) == 0 { + formatted = self.prefix + message + } else { + formatted = self.prefix + fmt.Sprintf(message, values...) + } + indented := strings.Replace(formatted, newline, newline+self.prefix, -1) + return strings.TrimRight(indented, space) +} + +func (self *Printer) Indent() { + self.prefix += pad +} + +func (self *Printer) Dedent() { + if len(self.prefix) >= padLength { + self.prefix = self.prefix[:len(self.prefix)-padLength] + } +} + +func NewPrinter(out io.Writer) *Printer { + self := new(Printer) + self.out = out + return self +} + +const space = " " +const pad = space + space +const padLength = len(pad) diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/problems.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/problems.go new file mode 100644 index 0000000000..9ae493ac3b --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/problems.go @@ -0,0 +1,80 @@ +package reporting + +import "fmt" + +type problem struct { + silent bool + out *Printer + errors []*AssertionResult + failures []*AssertionResult +} + +func (self *problem) BeginStory(story *StoryReport) {} + +func (self *problem) Enter(scope *ScopeReport) {} + +func (self *problem) Report(report *AssertionResult) { + if report.Error != nil { + self.errors = append(self.errors, report) + } else if report.Failure != "" { + self.failures = append(self.failures, report) + } +} + +func (self *problem) Exit() {} + +func (self *problem) EndStory() { + self.show(self.showErrors, redColor) + self.show(self.showFailures, yellowColor) + self.prepareForNextStory() +} +func (self *problem) show(display func(), color string) { + if !self.silent { + fmt.Print(color) + } + display() + if !self.silent { + fmt.Print(resetColor) + } + self.out.Dedent() +} +func (self *problem) showErrors() { + for i, e := range self.errors { + if i == 0 { + self.out.Println("\nErrors:\n") + self.out.Indent() + } + self.out.Println(errorTemplate, e.File, e.Line, e.Error, e.StackTrace) + } +} +func (self *problem) showFailures() { + for i, f := range self.failures { + if i == 0 { + self.out.Println("\nFailures:\n") + self.out.Indent() + } + self.out.Println(failureTemplate, f.File, f.Line, f.Failure) + } +} + +func (self *problem) Write(content []byte) (written int, err error) { + return len(content), nil // no-op +} + +func NewProblemReporter(out *Printer) *problem { + self := new(problem) + self.out = out + self.prepareForNextStory() + return self +} + +func NewSilentProblemReporter(out *Printer) *problem { + self := NewProblemReporter(out) + self.silent = true + return self +} + +func (self *problem) prepareForNextStory() { + self.errors = []*AssertionResult{} + self.failures = []*AssertionResult{} +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reporter.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reporter.go new file mode 100644 index 0000000000..cce6c5e438 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reporter.go @@ -0,0 +1,39 @@ +package reporting + +import "io" + +type Reporter interface { + BeginStory(story *StoryReport) + Enter(scope *ScopeReport) + Report(r *AssertionResult) + Exit() + EndStory() + io.Writer +} + +type reporters struct{ collection []Reporter } + +func (self *reporters) BeginStory(s *StoryReport) { self.foreach(func(r Reporter) { r.BeginStory(s) }) } +func (self *reporters) Enter(s *ScopeReport) { self.foreach(func(r Reporter) { r.Enter(s) }) } +func (self *reporters) Report(a *AssertionResult) { self.foreach(func(r Reporter) { r.Report(a) }) } +func (self *reporters) Exit() { self.foreach(func(r Reporter) { r.Exit() }) } +func (self *reporters) EndStory() { self.foreach(func(r Reporter) { r.EndStory() }) } + +func (self *reporters) Write(contents []byte) (written int, err error) { + self.foreach(func(r Reporter) { + written, err = r.Write(contents) + }) + return written, err +} + +func (self *reporters) foreach(action func(Reporter)) { + for _, r := range self.collection { + action(r) + } +} + +func NewReporters(collection ...Reporter) *reporters { + self := new(reporters) + self.collection = collection + return self +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reporting.goconvey b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reporting.goconvey new file mode 100644 index 0000000000..79982854b5 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reporting.goconvey @@ -0,0 +1,2 @@ +#ignore +-timeout=1s diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reports.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reports.go new file mode 100644 index 0000000000..712e6ade62 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reports.go @@ -0,0 +1,179 @@ +package reporting + +import ( + "encoding/json" + "fmt" + "runtime" + "strings" + + "github.com/smartystreets/goconvey/convey/gotest" +) + +////////////////// ScopeReport //////////////////// + +type ScopeReport struct { + Title string + File string + Line int +} + +func NewScopeReport(title string) *ScopeReport { + file, line, _ := gotest.ResolveExternalCaller() + self := new(ScopeReport) + self.Title = title + self.File = file + self.Line = line + return self +} + +////////////////// ScopeResult //////////////////// + +type ScopeResult struct { + Title string + File string + Line int + Depth int + Assertions []*AssertionResult + Output string +} + +func newScopeResult(title string, depth int, file string, line int) *ScopeResult { + self := new(ScopeResult) + self.Title = title + self.Depth = depth + self.File = file + self.Line = line + self.Assertions = []*AssertionResult{} + return self +} + +/////////////////// StoryReport ///////////////////// + +type StoryReport struct { + Test T + Name string + File string + Line int +} + +func NewStoryReport(test T) *StoryReport { + file, line, name := gotest.ResolveExternalCaller() + name = removePackagePath(name) + self := new(StoryReport) + self.Test = test + self.Name = name + self.File = file + self.Line = line + return self +} + +// name comes in looking like "github.com/smartystreets/goconvey/examples.TestName". +// We only want the stuff after the last '.', which is the name of the test function. +func removePackagePath(name string) string { + parts := strings.Split(name, ".") + return parts[len(parts)-1] +} + +/////////////////// FailureView //////////////////////// + +// This struct is also declared in github.com/smartystreets/assertions. +// The json struct tags should be equal in both declarations. +type FailureView struct { + Message string `json:"Message"` + Expected string `json:"Expected"` + Actual string `json:"Actual"` +} + +////////////////////AssertionResult ////////////////////// + +type AssertionResult struct { + File string + Line int + Expected string + Actual string + Failure string + Error interface{} + StackTrace string + Skipped bool +} + +func NewFailureReport(failure string) *AssertionResult { + report := new(AssertionResult) + report.File, report.Line = caller() + report.StackTrace = stackTrace() + parseFailure(failure, report) + return report +} +func parseFailure(failure string, report *AssertionResult) { + view := new(FailureView) + err := json.Unmarshal([]byte(failure), view) + if err == nil { + report.Failure = view.Message + report.Expected = view.Expected + report.Actual = view.Actual + } else { + report.Failure = failure + } +} +func NewErrorReport(err interface{}) *AssertionResult { + report := new(AssertionResult) + report.File, report.Line = caller() + report.StackTrace = fullStackTrace() + report.Error = fmt.Sprintf("%v", err) + return report +} +func NewSuccessReport() *AssertionResult { + return new(AssertionResult) +} +func NewSkipReport() *AssertionResult { + report := new(AssertionResult) + report.File, report.Line = caller() + report.StackTrace = fullStackTrace() + report.Skipped = true + return report +} + +func caller() (file string, line int) { + file, line, _ = gotest.ResolveExternalCaller() + return +} + +func stackTrace() string { + buffer := make([]byte, 1024*64) + n := runtime.Stack(buffer, false) + return removeInternalEntries(string(buffer[:n])) +} +func fullStackTrace() string { + buffer := make([]byte, 1024*64) + n := runtime.Stack(buffer, true) + return removeInternalEntries(string(buffer[:n])) +} +func removeInternalEntries(stack string) string { + lines := strings.Split(stack, newline) + filtered := []string{} + for _, line := range lines { + if !isExternal(line) { + filtered = append(filtered, line) + } + } + return strings.Join(filtered, newline) +} +func isExternal(line string) bool { + for _, p := range internalPackages { + if strings.Contains(line, p) { + return true + } + } + return false +} + +// NOTE: any new packages that host goconvey packages will need to be added here! +// An alternative is to scan the goconvey directory and then exclude stuff like +// the examples package but that's nasty too. +var internalPackages = []string{ + "goconvey/assertions", + "goconvey/convey", + "goconvey/execution", + "goconvey/gotest", + "goconvey/reporting", +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/statistics.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/statistics.go new file mode 100644 index 0000000000..c3ccd056a0 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/statistics.go @@ -0,0 +1,108 @@ +package reporting + +import ( + "fmt" + "sync" +) + +func (self *statistics) BeginStory(story *StoryReport) {} + +func (self *statistics) Enter(scope *ScopeReport) {} + +func (self *statistics) Report(report *AssertionResult) { + self.Lock() + defer self.Unlock() + + if !self.failing && report.Failure != "" { + self.failing = true + } + if !self.erroring && report.Error != nil { + self.erroring = true + } + if report.Skipped { + self.skipped += 1 + } else { + self.total++ + } +} + +func (self *statistics) Exit() {} + +func (self *statistics) EndStory() { + self.Lock() + defer self.Unlock() + + if !self.suppressed { + self.printSummaryLocked() + } +} + +func (self *statistics) Suppress() { + self.Lock() + defer self.Unlock() + self.suppressed = true +} + +func (self *statistics) PrintSummary() { + self.Lock() + defer self.Unlock() + self.printSummaryLocked() +} + +func (self *statistics) printSummaryLocked() { + self.reportAssertionsLocked() + self.reportSkippedSectionsLocked() + self.completeReportLocked() +} +func (self *statistics) reportAssertionsLocked() { + self.decideColorLocked() + self.out.Print("\n%d total %s", self.total, plural("assertion", self.total)) +} +func (self *statistics) decideColorLocked() { + if self.failing && !self.erroring { + fmt.Print(yellowColor) + } else if self.erroring { + fmt.Print(redColor) + } else { + fmt.Print(greenColor) + } +} +func (self *statistics) reportSkippedSectionsLocked() { + if self.skipped > 0 { + fmt.Print(yellowColor) + self.out.Print(" (one or more sections skipped)") + } +} +func (self *statistics) completeReportLocked() { + fmt.Print(resetColor) + self.out.Print("\n") + self.out.Print("\n") +} + +func (self *statistics) Write(content []byte) (written int, err error) { + return len(content), nil // no-op +} + +func NewStatisticsReporter(out *Printer) *statistics { + self := statistics{} + self.out = out + return &self +} + +type statistics struct { + sync.Mutex + + out *Printer + total int + failing bool + erroring bool + skipped int + suppressed bool +} + +func plural(word string, count int) string { + if count == 1 { + return word + } + return word + "s" +} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/story.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/story.go new file mode 100644 index 0000000000..9e73c971f8 --- /dev/null +++ b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/story.go @@ -0,0 +1,73 @@ +// TODO: in order for this reporter to be completely honest +// we need to retrofit to be more like the json reporter such that: +// 1. it maintains ScopeResult collections, which count assertions +// 2. it reports only after EndStory(), so that all tick marks +// are placed near the appropriate title. +// 3. Under unit test + +package reporting + +import ( + "fmt" + "strings" +) + +type story struct { + out *Printer + titlesById map[string]string + currentKey []string +} + +func (self *story) BeginStory(story *StoryReport) {} + +func (self *story) Enter(scope *ScopeReport) { + self.out.Indent() + + self.currentKey = append(self.currentKey, scope.Title) + ID := strings.Join(self.currentKey, "|") + + if _, found := self.titlesById[ID]; !found { + self.out.Println("") + self.out.Print(scope.Title) + self.out.Insert(" ") + self.titlesById[ID] = scope.Title + } +} + +func (self *story) Report(report *AssertionResult) { + if report.Error != nil { + fmt.Print(redColor) + self.out.Insert(error_) + } else if report.Failure != "" { + fmt.Print(yellowColor) + self.out.Insert(failure) + } else if report.Skipped { + fmt.Print(yellowColor) + self.out.Insert(skip) + } else { + fmt.Print(greenColor) + self.out.Insert(success) + } + fmt.Print(resetColor) +} + +func (self *story) Exit() { + self.out.Dedent() + self.currentKey = self.currentKey[:len(self.currentKey)-1] +} + +func (self *story) EndStory() { + self.titlesById = make(map[string]string) + self.out.Println("\n") +} + +func (self *story) Write(content []byte) (written int, err error) { + return len(content), nil // no-op +} + +func NewStoryReporter(out *Printer) *story { + self := new(story) + self.out = out + self.titlesById = make(map[string]string) + return self +} diff --git a/rkt/config/auth.go b/rkt/config/auth.go index 384f82bf9e..6f2f70c79e 100644 --- a/rkt/config/auth.go +++ b/rkt/config/auth.go @@ -18,11 +18,21 @@ import ( "encoding/base64" "encoding/json" "fmt" + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/client/metadata" + "github.com/aws/aws-sdk-go/aws/credentials" + "github.com/aws/aws-sdk-go/aws/request" + "github.com/aws/aws-sdk-go/private/signer/v4" + "io" "net/http" + "strings" + "time" ) const ( - authHeader string = "Authorization" + authHeader string = "Authorization" + defaultAWSRegion string = "us-east-1" + awsS3Service string = "s3" ) type authV1JsonParser struct{} @@ -42,6 +52,12 @@ type oauthV1 struct { Token string `json:"token"` } +type awsV1 struct { + AccessKeyID string `json:"accessKeyID"` + SecretAccessKey string `json:"secretAccessKey"` + Region string `json:"awsRegion"` +} + type dockerAuthV1JsonParser struct{} type dockerAuthV1 struct { @@ -59,7 +75,7 @@ type basicAuthHeaderer struct { auth basicV1 } -func (h *basicAuthHeaderer) Header() http.Header { +func (h *basicAuthHeaderer) GetHeader() http.Header { headers := make(http.Header) creds := []byte(fmt.Sprintf("%s:%s", h.auth.User, h.auth.Password)) encodedCreds := base64.StdEncoding.EncodeToString(creds) @@ -68,17 +84,90 @@ func (h *basicAuthHeaderer) Header() http.Header { return headers } +func (h *basicAuthHeaderer) SignRequest(r *http.Request) *http.Request { + r.Header.Set(authHeader, h.GetHeader().Get(authHeader)) + + return r +} + type oAuthBearerTokenHeaderer struct { auth oauthV1 } -func (h *oAuthBearerTokenHeaderer) Header() http.Header { +func (h *oAuthBearerTokenHeaderer) GetHeader() http.Header { headers := make(http.Header) headers.Add(authHeader, "Bearer "+h.auth.Token) return headers } +func (h *oAuthBearerTokenHeaderer) SignRequest(r *http.Request) *http.Request { + r.Header.Set(authHeader, h.GetHeader().Get(authHeader)) + + return r +} + +type awsAuthHeaderer struct { + accessKeyID string + secretAccessKey string + region string +} + +func (h *awsAuthHeaderer) GetHeader() http.Header { + return make(http.Header) +} + +func (h *awsAuthHeaderer) SignRequest(r *http.Request) *http.Request { + region := h.region + + var body io.ReadSeeker + if r.Body != nil { + body = r.Body.(io.ReadSeeker) + } + + if len(region) == 0 { + region = guessAWSRegion(r.URL.Host) + } + v4.Sign(&request.Request{ + ClientInfo: metadata.ClientInfo{ + SigningRegion: region, + SigningName: awsS3Service, + }, + Config: aws.Config{ + Credentials: credentials.NewStaticCredentials(h.accessKeyID, h.secretAccessKey, ""), + }, + HTTPRequest: r, + Body: body, + Time: time.Now(), + }) + + return r +} + +func guessAWSRegion(host string) string { + // Separate out potential : + hostParts := strings.Split(host, ":") + host = strings.ToLower(hostParts[0]) + + parts := strings.Split(host, ".") + + if len(parts) < 3 || parts[len(parts)-2] != "amazonaws" { + return defaultAWSRegion + } + + // Try to guess region based on url, but if nothing + // matches, just fall back to defaultAWSRegion. + if strings.HasSuffix(host, "s3.amazonaws.com") || strings.HasSuffix(host, "s3-external-1.amazonaws.com") { + return "us-east-1" + } else if len(parts) > 3 && strings.HasPrefix(parts[len(parts)-3], "s3-") { + return parts[len(parts)-3][3:] + } else if len(parts) > 4 && parts[len(parts)-4] == "s3" { + return parts[len(parts)-3] + } else { + return defaultAWSRegion + } +} + func (p *authV1JsonParser) parse(config *Config, raw []byte) error { var auth authV1 if err := json.Unmarshal(raw, &auth); err != nil { @@ -99,6 +188,8 @@ func (p *authV1JsonParser) parse(config *Config, raw []byte) error { headerer, err = p.getBasicV1Headerer(auth.Credentials) case "oauth": headerer, err = p.getOAuthV1Headerer(auth.Credentials) + case "aws": + headerer, err = p.getAWSV1Headerer(auth.Credentials) default: err = fmt.Errorf("unknown auth type: %q", auth.Type) } @@ -140,6 +231,24 @@ func (p *authV1JsonParser) getOAuthV1Headerer(raw json.RawMessage) (Headerer, er }, nil } +func (p *authV1JsonParser) getAWSV1Headerer(raw json.RawMessage) (Headerer, error) { + var aws awsV1 + if err := json.Unmarshal(raw, &aws); err != nil { + return nil, err + } + if len(aws.AccessKeyID) == 0 { + return nil, fmt.Errorf("no AWS Access Key ID specified") + } + if len(aws.SecretAccessKey) == 0 { + return nil, fmt.Errorf("no AWS Secret Access Key specified") + } + return &awsAuthHeaderer{ + accessKeyID: aws.AccessKeyID, + secretAccessKey: aws.SecretAccessKey, + region: aws.Region, + }, nil +} + func (p *dockerAuthV1JsonParser) parse(config *Config, raw []byte) error { var auth dockerAuthV1 if err := json.Unmarshal(raw, &auth); err != nil { diff --git a/rkt/config/auth_test.go b/rkt/config/auth_test.go new file mode 100644 index 0000000000..d4ff638262 --- /dev/null +++ b/rkt/config/auth_test.go @@ -0,0 +1,54 @@ +// Copyright 2015 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package config + +import ( + "testing" +) + +func TestGuessAWSRegion(t *testing.T) { + tests := []struct { + host string + region string + }{ + {"foo.s3.amazonaws.com", "us-east-1"}, + {"foo.s3-external-1.amazonaws.com", "us-east-1"}, + {"foo.bar.s3.amazonaws.com", "us-east-1"}, + {"foo.s3-us-west-1.amazonaws.com", "us-west-1"}, + {"foo.bar.baz.s3-us-west-2.amazonaws.com", "us-west-2"}, + {"foo.s3-eu-west-1.amazonaws.com", "eu-west-1"}, + {"foo.s3.eu-central-1.amazonaws.com", "eu-central-1"}, + {"foo.bar.s3.eu-central-1.amazonaws.com", "eu-central-1"}, + {"foo.s3-eu-central-1.amazonaws.com", "eu-central-1"}, + {"foo.s3-ap-northeast-1.amazonaws.com", "ap-northeast-1"}, + {"foo.s3.ap-northeast-2.amazonaws.com", "ap-northeast-2"}, + {"foo.s3-ap-northeast-2.amazonaws.com", "ap-northeast-2"}, + {"foo.bar.s3-ap-northeast-2.amazonaws.com", "ap-northeast-2"}, + {"foo.s3-ap-southeast-1.amazonaws.com", "ap-southeast-1"}, + {"foo.bar.baz.s3-ap-southeast-2.amazonaws.com", "ap-southeast-2"}, + {"foo.s3-sa-east-1.amazonaws.com", "sa-east-1"}, + {"foo.s3-ap-southeast-1.amazonaws.com:443", "ap-southeast-1"}, + {"foo.bar.baz.s3-us-west-2.amazonaws.com:80", "us-west-2"}, + {"foo.s3.eu-central-1.amazonaws.com:443", "eu-central-1"}, + {"entirely.unrecognized.url", defaultAWSRegion}, + } + + for _, tt := range tests { + region := guessAWSRegion(tt.host) + if region != tt.region { + t.Errorf("Got unexpected result for %s: %s (expected: %s)", tt.host, region, tt.region) + } + } +} diff --git a/rkt/config/config.go b/rkt/config/config.go index 5349c240ea..2603adeecc 100644 --- a/rkt/config/config.go +++ b/rkt/config/config.go @@ -32,7 +32,8 @@ import ( // Headerer is an interface for getting additional HTTP headers to use // when downloading data (images, signatures). type Headerer interface { - Header() http.Header + GetHeader() http.Header + SignRequest(r *http.Request) *http.Request } // BasicCredentials holds typical credentials used for authentication @@ -165,7 +166,7 @@ var ( func ResolveAuthPerHost(authPerHost map[string]Headerer) map[string]http.Header { hostHeaders := make(map[string]http.Header, len(authPerHost)) for k, v := range authPerHost { - hostHeaders[k] = v.Header() + hostHeaders[k] = v.GetHeader() } return hostHeaders } diff --git a/rkt/config/config_test.go b/rkt/config/config_test.go index 7476399075..845fe2ce59 100644 --- a/rkt/config/config_test.go +++ b/rkt/config/config_test.go @@ -79,7 +79,7 @@ func TestAuthConfigFormat(t *testing.T) { } else if !tt.fail { result := make(map[string]http.Header) for k, v := range cfg.AuthPerHost { - result[k] = v.Header() + result[k] = v.GetHeader() } if !reflect.DeepEqual(result, tt.expected) { t.Error("Got unexpected results\nResult:\n", result, "\n\nExpected:\n", tt.expected) @@ -272,7 +272,7 @@ func TestConfigLoading(t *testing.T) { } result := make(map[string]http.Header) for d, h := range cfg.AuthPerHost { - result[d] = h.Header() + result[d] = h.GetHeader() } expected := map[string]http.Header{ "endocode.com": { diff --git a/rkt/fetch_test.go b/rkt/fetch_test.go index a594cfc23d..1c7600a52a 100644 --- a/rkt/fetch_test.go +++ b/rkt/fetch_test.go @@ -146,10 +146,15 @@ type testHeaderer struct { h http.Header } -func (h *testHeaderer) Header() http.Header { +func (h *testHeaderer) GetHeader() http.Header { return h.h } +func (h *testHeaderer) SignRequest(r *http.Request) *http.Request { + r.Header.Set("Authorization", h.GetHeader().Get("Authorization")) + return r +} + func TestDownloading(t *testing.T) { dir, err := ioutil.TempDir("", "download-image") if err != nil { diff --git a/rkt/image/httpops.go b/rkt/image/httpops.go index 84137349e5..87553aafe9 100644 --- a/rkt/image/httpops.go +++ b/rkt/image/httpops.go @@ -137,6 +137,7 @@ func (o *httpOps) getSession(u *url.URL, file *os.File, label, etag string) *res return &resumableSession{ InsecureSkipTLSVerify: o.InsecureSkipTLSVerify, Headers: o.getHeaders(u, etag), + Headerers: o.Headers, File: file, ETagFilePath: eTagFilePath, Label: label, @@ -150,22 +151,13 @@ func (o *httpOps) getDownloader(session downloadSession) *downloader { } func (o *httpOps) getHeaders(u *url.URL, etag string) http.Header { - options := o.getHeadersForURL(u) + options := o.getHeadersForURL(u, etag) if etag != "" { options.Add("If-None-Match", etag) } return options } -func (o *httpOps) getHeadersForURL(u *url.URL) http.Header { - // Send credentials only over secure channel - // TODO(krnowak): This could be controlled with another - // insecure flag. - if u.Scheme == "https" { - if hostOpts, ok := o.Headers[u.Host]; ok { - return hostOpts.Header() - } - } - +func (o *httpOps) getHeadersForURL(u *url.URL, etag string) http.Header { return make(http.Header) } diff --git a/rkt/image/resumablesession.go b/rkt/image/resumablesession.go index 89bbef95cb..eabb5025c2 100644 --- a/rkt/image/resumablesession.go +++ b/rkt/image/resumablesession.go @@ -26,6 +26,7 @@ import ( "strings" "time" + "github.com/coreos/rkt/rkt/config" "github.com/coreos/rkt/version" ) @@ -58,8 +59,10 @@ type resumableSession struct { // validation should be skipped. InsecureSkipTLSVerify bool // Headers are HTTP headers to be added to the HTTP - // request. Used for authentication. + // request. Used for ETAG. Headers http.Header + // Headerers used for authentication. + Headerers map[string]config.Headerer // File possibly holds the downloaded data - it is used for // resuming interrupted downloads. File *os.File @@ -311,6 +314,20 @@ func (s *resumableSession) httpRequest(method string, u *url.URL) *http.Request s.setHTTPHeaders(req, false) + // Send credentials only over secure channel + // TODO(krnowak): This could be controlled with another + // insecure flag. + if req.URL.Scheme != "https" { + return req + } + + if hostOpts, ok := s.Headerers[req.URL.Host]; ok { + req = hostOpts.SignRequest(req) + if req == nil { + panic("Req is nil!") + } + } + return req } From cdf24a2311e0fb6bbe832c9612be0597d2a66191 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Thu, 19 May 2016 10:25:16 -0700 Subject: [PATCH 0287/1304] store/tree.go: fix multiple things 1. fix slice make, capacity instead of length 2. preallocate slice with capacity to avoid slice growth with append 3. simplify return type --- store/tree.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/store/tree.go b/store/tree.go index 56f9a578a5..5eb8ebcd9a 100644 --- a/store/tree.go +++ b/store/tree.go @@ -293,13 +293,13 @@ func FileInfoFromHeader(hdr *tar.Header) *fileInfo { Devmajor: hdr.Devmajor, Devminor: hdr.Devminor, } - keys := make([]string, len(hdr.Xattrs)) + keys := make([]string, 0, len(hdr.Xattrs)) for k := range hdr.Xattrs { keys = append(keys, k) } sort.Strings(keys) - xattrs := make([]xattr, 0) + xattrs := make([]xattr, 0, len(keys)) for _, k := range keys { xattrs = append(xattrs, xattr{Name: k, Value: hdr.Xattrs[k]}) } @@ -373,10 +373,7 @@ func buildWalker(root string, aw specaci.ArchiveWriter) filepath.WalkFunc { r = nil } - if err := aw.AddFile(hdr, r); err != nil { - return err - } - return nil + return aw.AddFile(hdr, r) } } From c4abdbba6e1f804f657205c1baf1ec69230ac95c Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Thu, 19 May 2016 15:23:04 +0300 Subject: [PATCH 0288/1304] *: validate git commit messages --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4ca1563148..27d821075a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,13 +7,15 @@ go: - 1.6 before_install: + - go get -u github.com/coreos/git-validation + - git-validation -run subsystem-in-subject,short-subject,dangling-whitespace + +install: - sudo apt-get update -qq - sudo apt-get install -y cpio realpath squashfs-tools - sudo apt-get install -y build-essential - sudo apt-get install -y libacl1-dev -install: true - script: - ./autogen.sh # Build host and fly to ensure we build stage1 init. We don't build everything From e3e9721a7d151bf19f066b48490720df7af5f379 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Mon, 23 May 2016 13:46:28 +0200 Subject: [PATCH 0289/1304] stage0: complain and abort on conflicting CLI flags (#2666) When a pod manifest is passed to rkt other conflicting CLI flags are discarded, so far in a silent way. This commit makes the issue explicit and aborts when conflicting flags are specified together with `--pod-manifest`. Fixes #2418 --- rkt/prepare.go | 4 ++- rkt/run.go | 4 ++- tests/rkt_prepare_test.go | 63 +++++++++++++++++++++++++++++++++++++++ tests/rkt_run_test.go | 63 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 132 insertions(+), 2 deletions(-) create mode 100644 tests/rkt_prepare_test.go create mode 100644 tests/rkt_run_test.go diff --git a/rkt/prepare.go b/rkt/prepare.go index 8b537128cb..46ee3ecf9b 100644 --- a/rkt/prepare.go +++ b/rkt/prepare.go @@ -107,7 +107,9 @@ func runPrepare(cmd *cobra.Command, args []string) (exit int) { return 1 } - if len(flagPodManifest) > 0 && (len(flagPorts) > 0 || flagInheritEnv || !flagExplicitEnv.IsEmpty() || flagStoreOnly || flagNoStore) { + if len(flagPodManifest) > 0 && (len(flagPorts) > 0 || flagInheritEnv || !flagExplicitEnv.IsEmpty() || flagStoreOnly || flagNoStore || + (*appsVolume)(&rktApps).String() != "" || (*appMount)(&rktApps).String() != "" || (*appExec)(&rktApps).String() != "" || + (*appUser)(&rktApps).String() != "" || (*appGroup)(&rktApps).String() != "") { stderr.Print("conflicting flags set with --pod-manifest (see --help)") return 1 } diff --git a/rkt/run.go b/rkt/run.go index 6f1198c7d1..c82029adb4 100644 --- a/rkt/run.go +++ b/rkt/run.go @@ -148,7 +148,9 @@ func runRun(cmd *cobra.Command, args []string) (exit int) { return 1 } - if len(flagPodManifest) > 0 && (len(flagPorts) > 0 || flagInheritEnv || !flagExplicitEnv.IsEmpty() || rktApps.Count() > 0 || flagStoreOnly || flagNoStore) { + if len(flagPodManifest) > 0 && (len(flagPorts) > 0 || flagInheritEnv || !flagExplicitEnv.IsEmpty() || rktApps.Count() > 0 || flagStoreOnly || flagNoStore || + (*appsVolume)(&rktApps).String() != "" || (*appMount)(&rktApps).String() != "" || (*appExec)(&rktApps).String() != "" || + (*appUser)(&rktApps).String() != "" || (*appGroup)(&rktApps).String() != "") { stderr.Print("conflicting flags set with --pod-manifest (see --help)") return 1 } diff --git a/tests/rkt_prepare_test.go b/tests/rkt_prepare_test.go new file mode 100644 index 0000000000..538f5e9c0a --- /dev/null +++ b/tests/rkt_prepare_test.go @@ -0,0 +1,63 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build host coreos src kvm + +package main + +import ( + "fmt" + "testing" + + "github.com/coreos/rkt/tests/testutils" +) + +// TestPrepareConflictingFlags tests that 'rkt prepare' will complain and abort +// if conflicting flags are specified together with a pod manifest. +func TestPrepareConflictingFlags(t *testing.T) { + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + prepareConflictingFlagsMsg := "conflicting flags set with --pod-manifest (see --help)" + podManifestFlag := "--pod-manifest=/dev/null" + conflictingFlags := []struct { + flag string + args string + }{ + {"--inherit-env", ""}, + {"--no-store", ""}, + {"--store-only", ""}, + {"--port=", "foo:80"}, + {"--set-env=", "foo=bar"}, + {"--volume=", "foo,kind=host,source=/tmp"}, + {"--mount=", "volume=foo,target=/tmp --volume=foo,kind=host,source=/tmp"}, + } + imageConflictingFlags := []struct { + flag string + args string + }{ + {"--exec=", "/bin/sh"}, + {"--user=", "user_foo"}, + {"--group=", "group_foo"}, + } + + for _, cf := range conflictingFlags { + cmd := fmt.Sprintf("%s prepare %s %s%s", ctx.Cmd(), podManifestFlag, cf.flag, cf.args) + runRktAndCheckOutput(t, cmd, prepareConflictingFlagsMsg, true) + } + for _, icf := range imageConflictingFlags { + cmd := fmt.Sprintf("%s prepare dummy-image.aci %s %s%s", ctx.Cmd(), podManifestFlag, icf.flag, icf.args) + runRktAndCheckOutput(t, cmd, prepareConflictingFlagsMsg, true) + } +} diff --git a/tests/rkt_run_test.go b/tests/rkt_run_test.go new file mode 100644 index 0000000000..6d321bb20e --- /dev/null +++ b/tests/rkt_run_test.go @@ -0,0 +1,63 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build host coreos src kvm + +package main + +import ( + "fmt" + "testing" + + "github.com/coreos/rkt/tests/testutils" +) + +// TestRunConflictingFlags tests that 'rkt run' will complain and abort +// if conflicting flags are specified together with a pod manifest. +func TestRunConflictingFlags(t *testing.T) { + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + runConflictingFlagsMsg := "conflicting flags set with --pod-manifest (see --help)" + podManifestFlag := "--pod-manifest=/dev/null" + conflictingFlags := []struct { + flag string + args string + }{ + {"--inherit-env", ""}, + {"--no-store", ""}, + {"--store-only", ""}, + {"--port=", "foo:80"}, + {"--set-env=", "foo=bar"}, + {"--volume=", "foo,kind=host,source=/tmp"}, + {"--mount=", "volume=foo,target=/tmp --volume=foo,kind=host,source=/tmp"}, + } + imageConflictingFlags := []struct { + flag string + args string + }{ + {"--exec=", "/bin/sh"}, + {"--user=", "user_foo"}, + {"--group=", "group_foo"}, + } + + for _, cf := range conflictingFlags { + cmd := fmt.Sprintf("%s run %s %s%s", ctx.Cmd(), podManifestFlag, cf.flag, cf.args) + runRktAndCheckOutput(t, cmd, runConflictingFlagsMsg, true) + } + for _, icf := range imageConflictingFlags { + cmd := fmt.Sprintf("%s run dummy-image.aci %s %s%s", ctx.Cmd(), podManifestFlag, icf.flag, icf.args) + runRktAndCheckOutput(t, cmd, runConflictingFlagsMsg, true) + } +} From 300a43ac38cbf85f44bfe9c558539c9dd0bd1e3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 18 May 2016 11:11:48 +0200 Subject: [PATCH 0290/1304] stage1: clean up pod cgroups on GC After a pod exits, there'll be some leftover directories in /sys/fs/cgroup. This commit cleans them up on GC. --- common/cgroup/cgroup.go | 2 +- stage1/gc/gc.go | 70 +++++++++++++++++++++++++++++++++++++++-- stage1/init/init.go | 16 ++++++---- 3 files changed, 79 insertions(+), 9 deletions(-) diff --git a/common/cgroup/cgroup.go b/common/cgroup/cgroup.go index 6866220c7c..d30fc03c30 100644 --- a/common/cgroup/cgroup.go +++ b/common/cgroup/cgroup.go @@ -375,7 +375,7 @@ func RemountCgroupsRO(root string, enabledCgroups map[int][]string, subcgroup st // Mount RW knobs we need to make the enabled isolators work for _, c := range controllers { cPath := filepath.Join(cgroupTmpfs, c) - subcgroupPath := filepath.Join(cPath, subcgroup) + subcgroupPath := filepath.Join(cPath, subcgroup, "system.slice") // Workaround for https://github.com/coreos/rkt/issues/1210 if c == "cpuset" { diff --git a/stage1/gc/gc.go b/stage1/gc/gc.go index 991d0082c9..25672a669d 100644 --- a/stage1/gc/gc.go +++ b/stage1/gc/gc.go @@ -19,9 +19,12 @@ package main import ( "errors" "flag" + "fmt" + "io/ioutil" "os" "path/filepath" "runtime" + "sort" "strings" "syscall" @@ -33,8 +36,13 @@ import ( rktlog "github.com/coreos/rkt/pkg/log" ) +const ( + cgroupFsPath = "/sys/fs/cgroup" +) + var ( debug bool + log *rktlog.Logger = rktlog.New(os.Stderr, "stage1 gc", debug) ) func init() { @@ -49,8 +57,6 @@ func init() { func main() { flag.Parse() - log := rktlog.New(os.Stderr, "stage1 gc", debug) - podID, err := types.NewUUID(flag.Arg(0)) if err != nil { log.Fatal("UUID is missing or malformed") @@ -60,6 +66,10 @@ func main() { log.PrintE("error removing journal link", err) } + if err := cleanupCgroups(); err != nil { + log.PrintE("error cleaning up cgroups", err) + } + if err := gcNetworking(podID); err != nil { log.FatalE("", err) } @@ -104,3 +114,59 @@ func removeJournalLink(uuid *types.UUID) error { } return err } + +type dirsByLength []string + +func (c dirsByLength) Len() int { return len(c) } +func (c dirsByLength) Less(i, j int) bool { return len(c[i]) < len(c[j]) } +func (c dirsByLength) Swap(i, j int) { c[i], c[j] = c[j], c[i] } + +func cleanupCgroups() error { + b, err := ioutil.ReadFile("subcgroup") + if err != nil { + return errwrap.Wrap(errors.New("error reading subcgroup file"), err) + } + subcgroup := string(b) + + f, err := os.Open(cgroupFsPath) + if err != nil { + return err + } + defer f.Close() + ns, err := f.Readdirnames(0) + if err != nil { + return err + } + var cgroupDirs []string + for _, c := range ns { + scPath := filepath.Join(cgroupFsPath, c, subcgroup) + walkCgroupDirs := func(path string, info os.FileInfo, err error) error { + // if the subcgroup is already removed, we're fine + if os.IsNotExist(err) { + return nil + } + if err != nil { + return err + } + mode := info.Mode() + if mode.IsDir() { + cgroupDirs = append(cgroupDirs, path) + } + return nil + } + if err := filepath.Walk(scPath, walkCgroupDirs); err != nil { + log.PrintE(fmt.Sprintf("error walking subcgroup %q", scPath), err) + continue + } + } + + // remove descendants before ancestors + sort.Sort(sort.Reverse(dirsByLength(cgroupDirs))) + for _, d := range cgroupDirs { + if err := os.RemoveAll(d); err != nil { + log.PrintE(fmt.Sprintf("error removing subcgroup %q", d), err) + } + } + + return nil +} diff --git a/stage1/init/init.go b/stage1/init/init.go index 94f2730218..b98f84bcd7 100644 --- a/stage1/init/init.go +++ b/stage1/init/init.go @@ -619,6 +619,11 @@ func stage1() int { machineID := stage1initcommon.GetMachineID(p) subcgroup, err := getContainerSubCgroup(machineID) if err == nil { + if err := ioutil.WriteFile(filepath.Join(p.Root, "subcgroup"), + []byte(fmt.Sprintf("%s", subcgroup)), 0644); err != nil { + log.FatalE("cannot write subcgroup file", err) + return 1 + } if err := mountContainerCgroups(s1Root, enabledCgroups, subcgroup, serviceNames); err != nil { log.PrintE("couldn't mount the container cgroups", err) return 1 @@ -729,7 +734,7 @@ func getContainerSubCgroup(machineID string) (string, error) { if err != nil { return "", errwrap.Wrap(errors.New("could not get unit name"), err) } - subcgroup = filepath.Join(slicePath, unit, "system.slice") + subcgroup = filepath.Join(slicePath, unit) } else { escapedmID := strings.Replace(machineID, "-", "\\x2d", -1) machineDir := "machine-" + escapedmID + ".scope" @@ -737,7 +742,7 @@ func getContainerSubCgroup(machineID string) (string, error) { // we are not in the final cgroup yet: systemd-nspawn will move us // to the correct cgroup later during registration so we can't // look it up in /proc/self/cgroup - subcgroup = filepath.Join("machine.slice", machineDir, "system.slice") + subcgroup = filepath.Join("machine.slice", machineDir) } else { // when registration is disabled the container will be directly // under the current cgroup so we can look it up in /proc/self/cgroup @@ -748,11 +753,10 @@ func getContainerSubCgroup(machineID string) (string, error) { // systemd-nspawn won't work if we are in the root cgroup. In addition, // we want all rkt instances to be in distinct cgroups. Create a // subcgroup and add ourselves to it. - ownCgroupPath = filepath.Join(ownCgroupPath, machineDir) - if err := cgroup.JoinSubcgroup("systemd", ownCgroupPath); err != nil { - return "", errwrap.Wrap(fmt.Errorf("error joining %s subcgroup", ownCgroupPath), err) + subcgroup = filepath.Join(ownCgroupPath, machineDir) + if err := cgroup.JoinSubcgroup("systemd", subcgroup); err != nil { + return "", errwrap.Wrap(fmt.Errorf("error joining %s subcgroup", subcgroup), err) } - subcgroup = filepath.Join(ownCgroupPath, "system.slice") } } From 3a779ef0aa9f34efebf7ad0540e49993f37dbdc0 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Fri, 13 May 2016 15:02:42 +0200 Subject: [PATCH 0291/1304] tests: check current working directory Add a new test to check that the WorkingDirectory specified in the ACI manifest is used. --- tests/inspect/inspect.go | 11 ++++------- tests/rkt_run_pod_manifest_test.go | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/tests/inspect/inspect.go b/tests/inspect/inspect.go index ad76b27845..6d05ba5891 100644 --- a/tests/inspect/inspect.go +++ b/tests/inspect/inspect.go @@ -47,7 +47,7 @@ var ( PrintCapsPid int PrintUser bool PrintGroups bool - CheckCwd string + PrintCwd bool ExitCode int ReadFile bool WriteFile bool @@ -83,7 +83,7 @@ func init() { globalFlagset.BoolVar(&globalFlags.PrintExec, "print-exec", false, "Print the command we were execed as (i.e. argv[0])") globalFlagset.StringVar(&globalFlags.PrintMsg, "print-msg", "", "Print the message given as parameter") globalFlagset.StringVar(&globalFlags.SuffixMsg, "suffix-msg", "", "Print this suffix after some commands") - globalFlagset.StringVar(&globalFlags.CheckCwd, "check-cwd", "", "Check if the current working directory is the one specified") + globalFlagset.BoolVar(&globalFlags.PrintCwd, "print-cwd", false, "Print the current working directory") globalFlagset.StringVar(&globalFlags.PrintEnv, "print-env", "", "Print the specified environment variable") globalFlagset.IntVar(&globalFlags.PrintCapsPid, "print-caps-pid", -1, "Print capabilities of the specified pid (or current process if pid=0)") globalFlagset.BoolVar(&globalFlags.PrintUser, "print-user", false, "Print uid and gid") @@ -285,16 +285,13 @@ func main() { fmt.Printf("%s: group: %v\n", fileName, fi.Sys().(*syscall.Stat_t).Gid) } - if globalFlags.CheckCwd != "" { + if globalFlags.PrintCwd { wd, err := os.Getwd() if err != nil { fmt.Fprintf(os.Stderr, "Cannot get working directory: %v\n", err) os.Exit(1) } - if wd != globalFlags.CheckCwd { - fmt.Fprintf(os.Stderr, "Working directory: %q. Expected: %q.\n", wd, globalFlags.CheckCwd) - os.Exit(1) - } + fmt.Printf("cwd: %s\n", wd) } if globalFlags.Sleep >= 0 { diff --git a/tests/rkt_run_pod_manifest_test.go b/tests/rkt_run_pod_manifest_test.go index 2b46ee6cb7..7ff003ca63 100644 --- a/tests/rkt_run_pod_manifest_test.go +++ b/tests/rkt_run_pod_manifest_test.go @@ -119,6 +119,28 @@ func TestPodManifest(t *testing.T) { `'"[$]`, "", }, + { + // Working directory. + []imagePatch{ + {"rkt-test-run-pod-manifest-working-directory.aci", []string{}}, + }, + &schema.PodManifest{ + Apps: []schema.RuntimeApp{ + { + Name: baseAppName, + App: &types.App{ + Exec: []string{"/inspect", "--print-cwd"}, + User: "0", + Group: "0", + WorkingDirectory: "/dir1", + }, + }, + }, + }, + 0, + "cwd: /dir1", + "", + }, { // Simple read. []imagePatch{ From a97a0d327a9f6455cd245414e6b0ba3a98659d3b Mon Sep 17 00:00:00 2001 From: Yifan Gu Date: Mon, 23 May 2016 13:35:18 -0700 Subject: [PATCH 0292/1304] tests/rkt_api_service_test.go: Also check PID when polling the pod. This fixes the flaky test where pod is RUNNING but pid file and network info files are not ready. --- tests/rkt_api_service_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/rkt_api_service_test.go b/tests/rkt_api_service_test.go index fe41f42aec..f4885600de 100644 --- a/tests/rkt_api_service_test.go +++ b/tests/rkt_api_service_test.go @@ -153,7 +153,11 @@ func checkPodNetworks(t *testing.T, rawNets map[string]*networkInfo, apiNets []* // Check the pod's information by 'rkt status'. func checkPod(t *testing.T, ctx *testutils.RktRunCtx, p *v1alpha.Pod, hasAppState, hasManifest bool, expectedGCTime time.Time) { + t.Logf("API Pod info: %v", p) + podInfo := getPodInfo(t, ctx, p.Id) + t.Logf("Pod info: %+v", podInfo) + if podInfo.id != p.Id { t.Errorf("Expected %q, saw %q", podInfo.id, p.Id) } @@ -525,7 +529,7 @@ func NewAPIServiceCgroupTest() testutils.Test { if len(resp.Pods) != 0 { allRunning := true for _, p := range resp.Pods { - if p.State != v1alpha.PodState_POD_STATE_RUNNING { + if p.State != v1alpha.PodState_POD_STATE_RUNNING || p.Pid == -1 { allRunning = false break } From 7825ddb98015bfa678f83a6f5310e8337325c8d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Tue, 24 May 2016 13:07:35 +0200 Subject: [PATCH 0293/1304] Revert "Revert "stage1/prepare-app: avoid recursive bind-mounts on /sys"" This reverts commit 3256dae2e25bb0227aa5151b6e3f416b6926a3cc. --- stage1/prepare-app/prepare-app.c | 71 +++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/stage1/prepare-app/prepare-app.c b/stage1/prepare-app/prepare-app.c index beaf54792e..7f14874704 100644 --- a/stage1/prepare-app/prepare-app.c +++ b/stage1/prepare-app/prepare-app.c @@ -21,6 +21,8 @@ #include #include #include +#include +#include #define err_out(_fmt, _args...) \ fprintf(stderr, "Error: " _fmt "\n", ##_args); @@ -50,6 +52,10 @@ static int exit_err; #define MACHINE_ID_LEN lenof("0123456789abcdef0123456789abcdef") #define MACHINE_NAME_LEN lenof("rkt-01234567-89ab-cdef-0123-456789abcdef") +#ifndef CGROUP2_SUPER_MAGIC +#define CGROUP2_SUPER_MAGIC 0x63677270 +#endif + typedef struct _dir_op_t { const char *name; mode_t mode; @@ -119,6 +125,66 @@ static int ensure_etc_hosts_exists(const char *root, int rootfd) { return 0; } +static void mount_sys(const char *root) +{ + char from[4096]; + char to[4096]; + struct statfs fs; + DIR *dir = NULL; + struct dirent *d; + + pexit_if(statfs("/sys/fs/cgroup", &fs) != 0, + "Cannot statfs /sys/fs/cgroup"); + if (fs.f_type == (typeof(fs.f_type)) CGROUP2_SUPER_MAGIC) { + /* With the unified cgroup hierarchy, recursive bind mounts + * are fine. */ + exit_if(snprintf(to, sizeof(to), "%s/%s", root, "sys") >= sizeof(to), + "Path too long: \"%s\"", to); + pexit_if(mount("/sys", to, "bind", + MS_BIND | MS_REC, "NULL") == -1, + "Mounting \"%s\" on \"%s\" failed", "/sys", to); + return; + } + + /* With cgroup-v1, rkt and systemd-nspawn add more cgroup + * bind-mounts to control which files are read-only. To avoid + * a quadratic progression, prepare-app does not bind mount + * /sys recursively. See: + * https://github.com/coreos/rkt/issues/2351 */ + exit_if(snprintf(to, sizeof(to), "%s/%s", root, "sys") >= sizeof(to), + "Path too long: \"%s\"", to); + pexit_if(mount("/sys", to, "bind", + MS_BIND, "NULL") == -1, + "Mounting \"%s\" on \"%s\" failed", "/sys", to); + + exit_if(snprintf(to, sizeof(to), "%s/%s", root, "sys/fs/cgroup") >= sizeof(to), + "Path too long: \"%s\"", to); + pexit_if(mount("/sys/fs/cgroup", to, "bind", + MS_BIND, "NULL") == -1, + "Mounting \"%s\" on \"%s\" failed", "/sys/fs/cgroup", to); + + pexit_if(!(dir = opendir(to)), "Failed to open directory \"%s\"", to) + errno = 0; + while ((d = readdir(dir))) { + if (d->d_type != DT_DIR) + continue; + if (strcmp(d->d_name, ".") == 0) + continue; + if (strcmp(d->d_name, "..") == 0) + continue; + + exit_if(snprintf(from, sizeof(from), "/sys/fs/cgroup/%s", d->d_name) >= sizeof(from), + "Path too long: \"%s\"", from); + exit_if(snprintf(to, sizeof(to), "%s/sys/fs/cgroup/%s", root, d->d_name) >= sizeof(to), + "Path too long: \"%s\"", to); + pexit_if(mount(from, to, "bind", + MS_BIND, "NULL") == -1, + "Mounting \"%s\" on \"%s\" failed", from, to); + } + pexit_if(errno != 0, "Failed to read directory \"%s\"", to); + pexit_if(closedir(dir) != 0, "Failed to close directory"); +} + int main(int argc, char *argv[]) { static const char *unlink_paths[] = { @@ -152,10 +218,10 @@ int main(int argc, char *argv[]) }; static const mount_point dirs_mount_table[] = { { "/proc", "/proc", "bind", NULL, MS_BIND|MS_REC }, - { "/sys", "/sys", "bind", NULL, MS_BIND|MS_REC }, { "/dev/shm", "/dev/shm", "bind", NULL, MS_BIND }, { "/dev/pts", "/dev/pts", "bind", NULL, MS_BIND }, { "/run/systemd/journal", "/run/systemd/journal", "bind", NULL, MS_BIND }, + /* /sys is handled separately */ }; static const mount_point files_mount_table[] = { { "/etc/rkt-resolv.conf", "/etc/resolv.conf", "bind", NULL, MS_BIND }, @@ -260,6 +326,9 @@ int main(int argc, char *argv[]) "Mounting \"%s\" on \"%s\" failed", mnt->source, to); } + /* Bind mount /sys: handled differently, depending on cgroups */ + mount_sys(root); + /* Bind mount files, if the source exists */ for (i = 0; i < nelems(files_mount_table); i++) { const mount_point *mnt = &files_mount_table[i]; From d18fe507ae3d77109bec3f33260c130b79c6faa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Tue, 24 May 2016 13:07:39 +0200 Subject: [PATCH 0294/1304] Revert "Revert "stage1/prepare-app: check for user namespace env"" This reverts commit b5bf7a0bb4187b83e678041cf1ec8595a3aff314. --- stage1/prepare-app/prepare-app.c | 85 +++++++++++++++++++++----------- 1 file changed, 57 insertions(+), 28 deletions(-) diff --git a/stage1/prepare-app/prepare-app.c b/stage1/prepare-app/prepare-app.c index 7f14874704..0c722f07bf 100644 --- a/stage1/prepare-app/prepare-app.c +++ b/stage1/prepare-app/prepare-app.c @@ -23,6 +23,7 @@ #include #include #include +#include #define err_out(_fmt, _args...) \ fprintf(stderr, "Error: " _fmt "\n", ##_args); @@ -52,6 +53,8 @@ static int exit_err; #define MACHINE_ID_LEN lenof("0123456789abcdef0123456789abcdef") #define MACHINE_NAME_LEN lenof("rkt-01234567-89ab-cdef-0123-456789abcdef") +#define UNMAPPED ((uid_t) -1) + #ifndef CGROUP2_SUPER_MAGIC #define CGROUP2_SUPER_MAGIC 0x63677270 #endif @@ -125,44 +128,78 @@ static int ensure_etc_hosts_exists(const char *root, int rootfd) { return 0; } +static void mount_at(const char *root, const mount_point *mnt) +{ + char to[4096]; + exit_if(snprintf(to, sizeof(to), "%s/%s", root, mnt->target) >= sizeof(to), + "Path too long: \"%s\"", to); + pexit_if(mount(mnt->source, to, mnt->type, + mnt->flags, mnt->options) == -1, + "Mounting \"%s\" on \"%s\" failed", mnt->source, to); +} + static void mount_sys(const char *root) { - char from[4096]; + int i; char to[4096]; struct statfs fs; DIR *dir = NULL; struct dirent *d; + const mount_point mnt_rec = { "/sys", "sys", "bind", NULL, MS_BIND|MS_REC }; + const mount_point sys_bind_table[] = { + { "/sys", "sys", "bind", NULL, MS_BIND }, + { "/sys/fs/cgroup", "sys/fs/cgroup", "bind", NULL, MS_BIND }, + }; pexit_if(statfs("/sys/fs/cgroup", &fs) != 0, "Cannot statfs /sys/fs/cgroup"); if (fs.f_type == (typeof(fs.f_type)) CGROUP2_SUPER_MAGIC) { /* With the unified cgroup hierarchy, recursive bind mounts * are fine. */ - exit_if(snprintf(to, sizeof(to), "%s/%s", root, "sys") >= sizeof(to), - "Path too long: \"%s\"", to); - pexit_if(mount("/sys", to, "bind", - MS_BIND | MS_REC, "NULL") == -1, - "Mounting \"%s\" on \"%s\" failed", "/sys", to); + mount_at(root, &mnt_rec); return; } + // For security reasons recent Linux kernels do not allow to bind-mount non-recursively + // if it would give read-write access to other subdirectories mounted as read-only. + // Hence we have to check if we are in a user namespaced environment and bind mount recursively instead. + if (access("/proc/1/uid_map", F_OK) == 0) { + FILE *f; + int k; + uid_t uid_base, uid_shift, uid_range; + + pexit_if((f = fopen("/proc/1/uid_map", "re")) == NULL, + "Unable to open /proc/1/uid_map"); + + if (sizeof(uid_t) == 4) { + k = fscanf(f, "%"PRIu32" %"PRIu32" %"PRIu32, + &uid_base, &uid_shift, &uid_range); + } else { + k = fscanf(f, "%"PRIu16" %"PRIu16" %"PRIu16, + &uid_base, &uid_shift, &uid_range); + } + pexit_if(fclose(f) != 0, "Unable to close /proc/1/uid_map"); + pexit_if(k != 3, "Invalid uid_map format"); + + // do a recursive bind mount if we are in a user namespace having a parent namespace set, + // i.e. either one of uid base, shift, or the range is set, see user_namespaces(7). + if (uid_base != 0 || uid_shift != 0 || uid_range != UNMAPPED) { + mount_at(root, &mnt_rec); + return; + } + } + /* With cgroup-v1, rkt and systemd-nspawn add more cgroup * bind-mounts to control which files are read-only. To avoid * a quadratic progression, prepare-app does not bind mount * /sys recursively. See: * https://github.com/coreos/rkt/issues/2351 */ - exit_if(snprintf(to, sizeof(to), "%s/%s", root, "sys") >= sizeof(to), - "Path too long: \"%s\"", to); - pexit_if(mount("/sys", to, "bind", - MS_BIND, "NULL") == -1, - "Mounting \"%s\" on \"%s\" failed", "/sys", to); + for (i = 0; i < nelems(sys_bind_table); i++) { + mount_at(root, &sys_bind_table[i]); + } exit_if(snprintf(to, sizeof(to), "%s/%s", root, "sys/fs/cgroup") >= sizeof(to), "Path too long: \"%s\"", to); - pexit_if(mount("/sys/fs/cgroup", to, "bind", - MS_BIND, "NULL") == -1, - "Mounting \"%s\" on \"%s\" failed", "/sys/fs/cgroup", to); - pexit_if(!(dir = opendir(to)), "Failed to open directory \"%s\"", to) errno = 0; while ((d = readdir(dir))) { @@ -173,13 +210,11 @@ static void mount_sys(const char *root) if (strcmp(d->d_name, "..") == 0) continue; - exit_if(snprintf(from, sizeof(from), "/sys/fs/cgroup/%s", d->d_name) >= sizeof(from), - "Path too long: \"%s\"", from); - exit_if(snprintf(to, sizeof(to), "%s/sys/fs/cgroup/%s", root, d->d_name) >= sizeof(to), + exit_if(snprintf(to, sizeof(to), "sys/fs/cgroup/%s", d->d_name) >= sizeof(to), "Path too long: \"%s\"", to); - pexit_if(mount(from, to, "bind", - MS_BIND, "NULL") == -1, - "Mounting \"%s\" on \"%s\" failed", from, to); + + mount_point mnt = { to, to, "bind", NULL, MS_BIND }; + mount_at(root, &mnt); } pexit_if(errno != 0, "Failed to read directory \"%s\"", to); pexit_if(closedir(dir) != 0, "Failed to close directory"); @@ -317,13 +352,7 @@ int main(int argc, char *argv[]) /* Bind mount directories */ for (i = 0; i < nelems(dirs_mount_table); i++) { - const mount_point *mnt = &dirs_mount_table[i]; - - exit_if(snprintf(to, sizeof(to), "%s/%s", root, mnt->target) >= sizeof(to), - "Path too long: \"%s\"", to); - pexit_if(mount(mnt->source, to, mnt->type, - mnt->flags, mnt->options) == -1, - "Mounting \"%s\" on \"%s\" failed", mnt->source, to); + mount_at(root, &dirs_mount_table[i]); } /* Bind mount /sys: handled differently, depending on cgroups */ From 2954a5814635027887bf6c77b2708a5502d89d38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Tue, 24 May 2016 13:11:42 +0200 Subject: [PATCH 0295/1304] stage1/prepare-app: don't mount /sys/fs/cgroup in stage2 The previous two patches make rkt not do a recursive bind-mount on /sys unless we use user namespaces (the kernel doesn't allow that). However, SELinux doesn't allow mounting `/sys/fs/cgroup` manually in that case. Since the spec doesn't say apps should have a view of /sys/fs/cgroup, let's not mount it in stage2. --- stage1/prepare-app/prepare-app.c | 40 ++++---------------------------- 1 file changed, 5 insertions(+), 35 deletions(-) diff --git a/stage1/prepare-app/prepare-app.c b/stage1/prepare-app/prepare-app.c index 0c722f07bf..db42773a4b 100644 --- a/stage1/prepare-app/prepare-app.c +++ b/stage1/prepare-app/prepare-app.c @@ -140,23 +140,16 @@ static void mount_at(const char *root, const mount_point *mnt) static void mount_sys(const char *root) { - int i; - char to[4096]; struct statfs fs; - DIR *dir = NULL; - struct dirent *d; - const mount_point mnt_rec = { "/sys", "sys", "bind", NULL, MS_BIND|MS_REC }; - const mount_point sys_bind_table[] = { - { "/sys", "sys", "bind", NULL, MS_BIND }, - { "/sys/fs/cgroup", "sys/fs/cgroup", "bind", NULL, MS_BIND }, - }; + const mount_point sys_bind_rec = { "/sys", "sys", "bind", NULL, MS_BIND|MS_REC }; + const mount_point sys_bind = { "/sys", "sys", "bind", NULL, MS_BIND }; pexit_if(statfs("/sys/fs/cgroup", &fs) != 0, "Cannot statfs /sys/fs/cgroup"); if (fs.f_type == (typeof(fs.f_type)) CGROUP2_SUPER_MAGIC) { /* With the unified cgroup hierarchy, recursive bind mounts * are fine. */ - mount_at(root, &mnt_rec); + mount_at(root, &sys_bind_rec); return; } @@ -184,7 +177,7 @@ static void mount_sys(const char *root) // do a recursive bind mount if we are in a user namespace having a parent namespace set, // i.e. either one of uid base, shift, or the range is set, see user_namespaces(7). if (uid_base != 0 || uid_shift != 0 || uid_range != UNMAPPED) { - mount_at(root, &mnt_rec); + mount_at(root, &sys_bind_rec); return; } } @@ -194,30 +187,7 @@ static void mount_sys(const char *root) * a quadratic progression, prepare-app does not bind mount * /sys recursively. See: * https://github.com/coreos/rkt/issues/2351 */ - for (i = 0; i < nelems(sys_bind_table); i++) { - mount_at(root, &sys_bind_table[i]); - } - - exit_if(snprintf(to, sizeof(to), "%s/%s", root, "sys/fs/cgroup") >= sizeof(to), - "Path too long: \"%s\"", to); - pexit_if(!(dir = opendir(to)), "Failed to open directory \"%s\"", to) - errno = 0; - while ((d = readdir(dir))) { - if (d->d_type != DT_DIR) - continue; - if (strcmp(d->d_name, ".") == 0) - continue; - if (strcmp(d->d_name, "..") == 0) - continue; - - exit_if(snprintf(to, sizeof(to), "sys/fs/cgroup/%s", d->d_name) >= sizeof(to), - "Path too long: \"%s\"", to); - - mount_point mnt = { to, to, "bind", NULL, MS_BIND }; - mount_at(root, &mnt); - } - pexit_if(errno != 0, "Failed to read directory \"%s\"", to); - pexit_if(closedir(dir) != 0, "Failed to close directory"); + mount_at(root, &sys_bind); } int main(int argc, char *argv[]) From 376ce85b46683288b7a262197497d2993fca9cb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 18 May 2016 12:36:45 +0200 Subject: [PATCH 0296/1304] functional tests: add a test for cleaning cgroups --- tests/rkt_gc_nspawn_test.go | 76 +++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 tests/rkt_gc_nspawn_test.go diff --git a/tests/rkt_gc_nspawn_test.go b/tests/rkt_gc_nspawn_test.go new file mode 100644 index 0000000000..5324ba0b4c --- /dev/null +++ b/tests/rkt_gc_nspawn_test.go @@ -0,0 +1,76 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build host coreos src + +package main + +import ( + "fmt" + "os" + "path/filepath" + "strings" + "testing" + + "github.com/coreos/rkt/tests/testutils" +) + +func getPodCgroups(shortUUID string) ([]string, error) { + var podCgroups []string + walkCgroups := func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + if info.Mode().IsDir() && strings.Contains(path, shortUUID) { + podCgroups = append(podCgroups, path) + } + return nil + } + if err := filepath.Walk("/sys/fs/cgroup", walkCgroups); err != nil { + return nil, err + } + return podCgroups, nil +} + +func TestGCCgroup(t *testing.T) { + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + imagePath := patchImportAndFetchHash("inspect-gc-test-run.aci", []string{"--exec=/inspect --print-msg=HELLO_API --exit-code=0"}, t, ctx) + defer os.Remove(imagePath) + cmd := fmt.Sprintf("%s --insecure-options=image prepare %s", ctx.Cmd(), imagePath) + uuid := runRktAndGetUUID(t, cmd) + shortUUID := strings.Split(uuid, "-")[0] + + cmd = fmt.Sprintf("%s run-prepared %s", ctx.Cmd(), shortUUID) + runRktAndCheckOutput(t, cmd, "", false) + + cgs, err := getPodCgroups(shortUUID) + if err != nil { + t.Fatalf("error getting pod cgroups: %v", err) + } + if len(cgs) == 0 { + t.Fatalf("expected pod cgroup directories after run, but found none") + } + + runGC(t, ctx) + + cgs, err = getPodCgroups(shortUUID) + if err != nil { + t.Fatalf("error getting pod cgroups: %v", err) + } + if len(cgs) > 0 { + t.Fatalf(fmt.Sprintf("expected no pod cgroup directories after GC, but found %d: %v", len(cgs), cgs)) + } +} From 91c39caf793d1060b6bda1a99e145f87de9b69ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Mon, 23 May 2016 11:23:13 +0200 Subject: [PATCH 0297/1304] functional tests: add tests for rkt rm --- tests/rkt_rm_nspawn_test.go | 59 +++++++++++++++++++++++++++ tests/rkt_rm_test.go | 81 +++++++++++++++++++++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 tests/rkt_rm_nspawn_test.go create mode 100644 tests/rkt_rm_test.go diff --git a/tests/rkt_rm_nspawn_test.go b/tests/rkt_rm_nspawn_test.go new file mode 100644 index 0000000000..eb7e3205c1 --- /dev/null +++ b/tests/rkt_rm_nspawn_test.go @@ -0,0 +1,59 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build host coreos src + +package main + +import ( + "fmt" + "os" + "strings" + "testing" + + "github.com/coreos/rkt/tests/testutils" +) + +func TestRmCgroup(t *testing.T) { + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + imagePath := patchImportAndFetchHash("inspect-rm-test-run.aci", []string{"--exec=/inspect --print-msg=HELLO_API --exit-code=0"}, t, ctx) + defer os.Remove(imagePath) + cmd := fmt.Sprintf("%s --insecure-options=image prepare %s", ctx.Cmd(), imagePath) + uuid := runRktAndGetUUID(t, cmd) + shortUUID := strings.Split(uuid, "-")[0] + + cmd = fmt.Sprintf("%s run-prepared %s", ctx.Cmd(), shortUUID) + runRktAndCheckOutput(t, cmd, "", false) + + cgs, err := getPodCgroups(shortUUID) + if err != nil { + t.Fatalf("error getting pod cgroups: %v", err) + } + if len(cgs) == 0 { + t.Fatalf("expected pod cgroup directories after run, but found none") + } + + rmCmd := fmt.Sprintf("%s rm %s", ctx.Cmd(), shortUUID) + spawnAndWaitOrFail(t, rmCmd, 0) + + cgs, err = getPodCgroups(shortUUID) + if err != nil { + t.Fatalf("error getting pod cgroups: %v", err) + } + if len(cgs) > 0 { + t.Fatalf(fmt.Sprintf("expected no pod cgroup directories after GC, but found %d: %v", len(cgs), cgs)) + } +} diff --git a/tests/rkt_rm_test.go b/tests/rkt_rm_test.go new file mode 100644 index 0000000000..f677aa86d7 --- /dev/null +++ b/tests/rkt_rm_test.go @@ -0,0 +1,81 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build host coreos src kvm + +package main + +import ( + "fmt" + "io/ioutil" + "os" + "path/filepath" + "testing" + + "github.com/coreos/rkt/tests/testutils" +) + +func TestRm(t *testing.T) { + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + var uuids []string + + img := patchTestACI("inspect-rm-test-run.aci", []string{"--exec=/inspect --print-msg=HELLO_API --exit-code=0"}...) + defer os.Remove(img) + prepareCmd := fmt.Sprintf("%s --insecure-options=image prepare %s", ctx.Cmd(), img) + + // Finished pod. + uuid := runRktAndGetUUID(t, prepareCmd) + runPreparedCmd := fmt.Sprintf("%s --insecure-options=image run-prepared %s", ctx.Cmd(), uuid) + runRktAndCheckOutput(t, runPreparedCmd, "", false) + + uuids = append(uuids, uuid) + + // Prepared pod. + uuid = runRktAndGetUUID(t, prepareCmd) + uuids = append(uuids, uuid) + + podDirs := []string{ + filepath.Join(ctx.DataDir(), "pods", "run"), + filepath.Join(ctx.DataDir(), "pods", "prepared"), + } + + for _, dir := range podDirs { + pods, err := ioutil.ReadDir(dir) + if err != nil { + t.Fatalf("cannot read pods directory %q: %v", dir, err) + } + if len(pods) == 0 { + t.Fatalf("pods should still exist in directory %q: %v", dir, pods) + } + } + + for _, u := range uuids { + cmd := fmt.Sprintf("%s rm %s", ctx.Cmd(), u) + spawnAndWaitOrFail(t, cmd, 0) + } + + podDirs = append(podDirs, filepath.Join(ctx.DataDir(), "pods", "exited-garbage")) + + for _, dir := range podDirs { + pods, err := ioutil.ReadDir(dir) + if err != nil { + t.Fatalf("cannot read pods directory %q: %v", dir, err) + } + if len(pods) != 0 { + t.Errorf("no pods should exist in directory %q, but found: %v", dir, pods) + } + } +} From 24f133405aa990bef9b03245d2c3f5b86282832b Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Mon, 23 May 2016 16:35:26 +0200 Subject: [PATCH 0298/1304] MAINTAINERS: add Luca Bruno (@lucab) --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index b8303539e0..1df9151f47 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4,6 +4,7 @@ Derek Gonyeo (@dgonyeo) Iago López Galeiras (@iaguis) Jonathan Boulle (@jonboulle) Krzesimir Nowak (@krnowak) +Luca Bruno (@lucab) Sergiusz Urbaniak (@s-urbaniak) Stefan Junker (@steveeJ) Tamer Tas (@tmrts) From 99ae3bec39a1e3e923ffb64a4779f326c82e165d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Tue, 24 May 2016 11:03:43 +0200 Subject: [PATCH 0299/1304] rkt: fix panic on rm a non-existing pod with uuid-file We were trusting that the value in the uuid file referred to an existing pod, which caused a panic if that wasn't the case. In this commit we resolve the UUID to check if the pod actually exists. Also, make rm's behavior consistent between caling it with a pod UUID and with `--uuid-file`: * Print a similar error message * Set the exit status to 1 if we fail to remove any pod --- rkt/rm.go | 10 ++++++---- rkt/uuid.go | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/rkt/rm.go b/rkt/rm.go index 7d29188eb0..8c9816b32f 100644 --- a/rkt/rm.go +++ b/rkt/rm.go @@ -43,20 +43,23 @@ func runRm(cmd *cobra.Command, args []string) (exit int) { var podUUIDs []*types.UUID var err error + ret := 0 switch { case len(args) == 0 && flagUUIDFile != "": podUUID, err = readUUIDFromFile(flagUUIDFile) if err != nil { - stderr.PrintE("unable to read UUID from file", err) - return 1 + stderr.PrintE("unable to resolve UUID from file", err) + ret = 1 + } else { + podUUIDs = append(podUUIDs, podUUID) } - podUUIDs = append(podUUIDs, podUUID) case len(args) > 0 && flagUUIDFile == "": for _, uuid := range args { podUUID, err := resolveUUID(uuid) if err != nil { stderr.PrintE("unable to resolve UUID", err) + ret = 1 } else { podUUIDs = append(podUUIDs, podUUID) } @@ -67,7 +70,6 @@ func runRm(cmd *cobra.Command, args []string) (exit int) { return 1 } - ret := 0 for _, podUUID = range podUUIDs { p, err := getPod(podUUID) if err != nil { diff --git a/rkt/uuid.go b/rkt/uuid.go index 5d86f3d115..3969beeb60 100644 --- a/rkt/uuid.go +++ b/rkt/uuid.go @@ -77,7 +77,7 @@ func readUUIDFromFile(path string) (*types.UUID, error) { } uuid = bytes.TrimSpace(uuid) - return types.NewUUID(string(uuid)) + return resolveUUID(string(uuid)) } func writeUUIDToFile(uuid *types.UUID, path string) error { From 4c9e24ea62d1685a2e1124cef9e4cac84cec23fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Tue, 24 May 2016 11:34:03 +0200 Subject: [PATCH 0300/1304] functional tests: add tests for rkt rm --- tests/rkt_rm_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/rkt_rm_test.go b/tests/rkt_rm_test.go index f677aa86d7..38ef516001 100644 --- a/tests/rkt_rm_test.go +++ b/tests/rkt_rm_test.go @@ -79,3 +79,24 @@ func TestRm(t *testing.T) { } } } + +func TestRmInvalid(t *testing.T) { + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + nonexistentUUID := "0f746094-3438-42bc-ab37-3cf85f132e60" + tmpDir := createTempDirOrPanic("rkt_rm_test") + defer os.RemoveAll(tmpDir) + uuidFile := filepath.Join(tmpDir, "uuid-file") + if err := ioutil.WriteFile(uuidFile, []byte(nonexistentUUID), 0600); err != nil { + t.Fatalf("cannot write uuid-file: %v", err) + } + + expected := fmt.Sprintf("no matches found for %q", nonexistentUUID) + + cmd := fmt.Sprintf("%s rm %s", ctx.Cmd(), nonexistentUUID) + runRktAndCheckOutput(t, cmd, expected, true) + + cmd = fmt.Sprintf("%s rm --uuid-file=%s", ctx.Cmd(), uuidFile) + runRktAndCheckOutput(t, cmd, expected, true) +} From 47c897b5a7fa920a986c74572c1bf65bf08deac7 Mon Sep 17 00:00:00 2001 From: Matthias Jahn Date: Thu, 12 May 2016 14:37:12 +0200 Subject: [PATCH 0301/1304] docs: add 'journalctl -m _MACHINE_ID' to docs Docs only showed a way to access logs from running container Fixes #1528 --- Documentation/commands.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Documentation/commands.md b/Documentation/commands.md index 3c6258b5a0..19e9ce852c 100644 --- a/Documentation/commands.md +++ b/Documentation/commands.md @@ -124,3 +124,15 @@ $ journalctl -M rkt-bc3c1451-2e81-45c6-aeb0-807db44e31b4 -t redis ``` Additionaly, logs can be programmatically accessed via the [sd-journal API](https://www.freedesktop.org/software/systemd/man/sd-journal.html). + +##### Stopped pod + +To read the logs of a stopped pod, use: + +``` +journalctl -m _MACHINE_ID=132f9d560e3f4d1eba8668efd488bb62 + +[...] +``` + +On some distributions such as Ubuntu, persistent journal storage is not enabled by default. In this case, it is not possible to get the logs of a stopped pod. Persistent journal storage can be enabled with `sudo mkdir /var/log/journal` before starting the pods. From 93c53711b903e8cf29bc7d77ea86a79eb9612d34 Mon Sep 17 00:00:00 2001 From: Tamer TAS Date: Tue, 24 May 2016 19:43:23 +0300 Subject: [PATCH 0302/1304] git-validation: disable short-subject validation Complains when the commit is a merge commit, it shouldn't! Discovered in #2684 cc @lucab --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 27d821075a..fc02f1fd7c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ go: before_install: - go get -u github.com/coreos/git-validation - - git-validation -run subsystem-in-subject,short-subject,dangling-whitespace + - git-validation -run subsystem-in-subject,dangling-whitespace install: - sudo apt-get update -qq From 18b43b3cf96900ff1cd346f1abd3914d684ea3e4 Mon Sep 17 00:00:00 2001 From: Wlodzimierz Borkowski Date: Fri, 6 May 2016 08:55:52 +0200 Subject: [PATCH 0303/1304] tests: rkt-monitor add new statistics New statistics for load average and boot/stop time measure of container. Diferences are measured in a nanoseconds. Godeps updated as well. Change network from 'host' to 'default-restricted' since kvm flavor can't create this type. --- .../benchmarks/rkt-1-4-0-benchmarks.md | 13 ++++ Godeps/Godeps.json | 5 ++ .../github.com/shirou/gopsutil/load/load.go | 35 +++++++++ .../shirou/gopsutil/load/load_darwin.go | 67 ++++++++++++++++ .../shirou/gopsutil/load/load_freebsd.go | 65 ++++++++++++++++ .../shirou/gopsutil/load/load_linux.go | 78 +++++++++++++++++++ .../shirou/gopsutil/load/load_windows.go | 19 +++++ tests/rkt-monitor/README.md | 3 + tests/rkt-monitor/main.go | 19 ++++- 9 files changed, 301 insertions(+), 3 deletions(-) create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/load/load.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/load/load_darwin.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/load/load_freebsd.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/load/load_linux.go create mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/load/load_windows.go diff --git a/Documentation/benchmarks/rkt-1-4-0-benchmarks.md b/Documentation/benchmarks/rkt-1-4-0-benchmarks.md index 1bf729988f..ffed74e972 100644 --- a/Documentation/benchmarks/rkt-1-4-0-benchmarks.md +++ b/Documentation/benchmarks/rkt-1-4-0-benchmarks.md @@ -17,6 +17,10 @@ rkt(18493): seconds alive: 10 avg CPU: 28.314541% avg Mem: 2 mB peak Mem: 2 m systemd(18515): seconds alive: 9 avg CPU: 0.000000% avg Mem: 4 mB peak Mem: 4 mB systemd-journal(18517): seconds alive: 9 avg CPU: 88.397098% avg Mem: 7 mB peak Mem: 7 mB worker(18521): seconds alive: 9 avg CPU: 7.330367% avg Mem: 5 mB peak Mem: 6 mB +load average in a container: Load1: 0.390000 Load5: 0.120000 Load15: 0.080000 +container start time: 250721ns +container stop time: 17332926ns + ``` ### mem-stresser.aci @@ -26,6 +30,9 @@ worker(18634): seconds alive: 9 avg CPU: 98.550401% avg Mem: 318 mB peak Mem: rkt(18599): seconds alive: 10 avg CPU: 3.583814% avg Mem: 2 mB peak Mem: 2 mB systemd(18628): seconds alive: 9 avg CPU: 0.000000% avg Mem: 4 mB peak Mem: 4 mB systemd-journal(18630): seconds alive: 9 avg CPU: 0.000000% avg Mem: 6 mB peak Mem: 6 mB +load average in a container: Load1: 0.310000 Load5: 0.150000 Load15: 0.090000 +container start time: 259746ns +container stop time: 17593446ns ``` ### cpu-stresser.aci @@ -35,6 +42,9 @@ rkt(18706): seconds alive: 10 avg CPU: 3.587050% avg Mem: 2 mB peak Mem: 2 mB systemd(18736): seconds alive: 9 avg CPU: 0.000000% avg Mem: 4 mB peak Mem: 4 mB systemd-journal(18740): seconds alive: 9 avg CPU: 0.000000% avg Mem: 6 mB peak Mem: 6 mB worker(18744): seconds alive: 9 avg CPU: 88.937493% avg Mem: 808 kB peak Mem: 808 kB +load average in a container: Load1: 0.310000 Load5: 0.130000 Load15: 0.080000 +container start time: 296570ns +container stop time: 16124700ns ``` ### too-many-apps.podmanifest @@ -45,5 +55,8 @@ rkt(17227): seconds alive: 20 avg CPU: 9.595387% avg Mem: 3 mB peak Mem: 20 m systemd(17253): seconds alive: 17 avg CPU: 0.329028% avg Mem: 16 mB peak Mem: 16 mB systemd-journal(17255): seconds alive: 17 avg CPU: 0.000000% avg Mem: 6 mB peak Mem: 6 mB worker-binary(17883): seconds alive: 17 avg CPU: 0.000000% avg Mem: 840 kB peak Mem: 840 kB +load average: Load1: 0.480000 Load5: 0.350000 Load15: 0.300000 +container start time: 528476ns +container stop time: 4522346ns ``` diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index e58a951fae..89f430688c 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -506,6 +506,11 @@ "Comment": "v2.0.0-10-g9ef3410", "Rev": "9ef341037b1bcadeeee79e77da4f6baf63de4feb" }, + { + "ImportPath": "github.com/shirou/gopsutil/load", + "Comment": "v2.0.0-10-g9ef3410", + "Rev": "9ef341037b1bcadeeee79e77da4f6baf63de4feb" + }, { "ImportPath": "github.com/shirou/gopsutil/mem", "Comment": "v2.0.0-10-g9ef3410", diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/load/load.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/load/load.go new file mode 100644 index 0000000000..dfe32a1e81 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/load/load.go @@ -0,0 +1,35 @@ +package load + +import ( + "encoding/json" + + "github.com/shirou/gopsutil/internal/common" +) + +var invoke common.Invoker + +func init() { + invoke = common.Invoke{} +} + +type AvgStat struct { + Load1 float64 `json:"load1"` + Load5 float64 `json:"load5"` + Load15 float64 `json:"load15"` +} + +func (l AvgStat) String() string { + s, _ := json.Marshal(l) + return string(s) +} + +type MiscStat struct { + ProcsRunning int `json:"procsRunning"` + ProcsBlocked int `json:"procsBlocked"` + Ctxt int `json:"ctxt"` +} + +func (m MiscStat) String() string { + s, _ := json.Marshal(m) + return string(s) +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/load/load_darwin.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/load/load_darwin.go new file mode 100644 index 0000000000..34e0653aed --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/load/load_darwin.go @@ -0,0 +1,67 @@ +// +build darwin + +package load + +import ( + "os/exec" + "strconv" + "strings" + + "github.com/shirou/gopsutil/internal/common" +) + +func Avg() (*AvgStat, error) { + values, err := common.DoSysctrl("vm.loadavg") + if err != nil { + return nil, err + } + + load1, err := strconv.ParseFloat(values[0], 64) + if err != nil { + return nil, err + } + load5, err := strconv.ParseFloat(values[1], 64) + if err != nil { + return nil, err + } + load15, err := strconv.ParseFloat(values[2], 64) + if err != nil { + return nil, err + } + + ret := &AvgStat{ + Load1: float64(load1), + Load5: float64(load5), + Load15: float64(load15), + } + + return ret, nil +} + +// Misc returnes miscellaneous host-wide statistics. +// darwin use ps command to get process running/blocked count. +// Almost same as FreeBSD implementation, but state is different. +// U means 'Uninterruptible Sleep'. +func Misc() (*MiscStat, error) { + bin, err := exec.LookPath("ps") + if err != nil { + return nil, err + } + out, err := invoke.Command(bin, "axo", "state") + if err != nil { + return nil, err + } + lines := strings.Split(string(out), "\n") + + ret := MiscStat{} + for _, l := range lines { + if strings.Contains(l, "R") { + ret.ProcsRunning++ + } else if strings.Contains(l, "U") { + // uninterruptible sleep == blocked + ret.ProcsBlocked++ + } + } + + return &ret, nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/load/load_freebsd.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/load/load_freebsd.go new file mode 100644 index 0000000000..6d3a0bafab --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/load/load_freebsd.go @@ -0,0 +1,65 @@ +// +build freebsd + +package load + +import ( + "os/exec" + "strconv" + "strings" + + "github.com/shirou/gopsutil/internal/common" +) + +func Avg() (*AvgStat, error) { + values, err := common.DoSysctrl("vm.loadavg") + if err != nil { + return nil, err + } + + load1, err := strconv.ParseFloat(values[0], 64) + if err != nil { + return nil, err + } + load5, err := strconv.ParseFloat(values[1], 64) + if err != nil { + return nil, err + } + load15, err := strconv.ParseFloat(values[2], 64) + if err != nil { + return nil, err + } + + ret := &AvgStat{ + Load1: float64(load1), + Load5: float64(load5), + Load15: float64(load15), + } + + return ret, nil +} + +// Misc returnes miscellaneous host-wide statistics. +// darwin use ps command to get process running/blocked count. +// Almost same as Darwin implementation, but state is different. +func Misc() (*MiscStat, error) { + bin, err := exec.LookPath("ps") + if err != nil { + return nil, err + } + out, err := invoke.Command(bin, "axo", "state") + if err != nil { + return nil, err + } + lines := strings.Split(string(out), "\n") + + ret := MiscStat{} + for _, l := range lines { + if strings.Contains(l, "R") { + ret.ProcsRunning++ + } else if strings.Contains(l, "D") { + ret.ProcsBlocked++ + } + } + + return &ret, nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/load/load_linux.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/load/load_linux.go new file mode 100644 index 0000000000..c455397bf8 --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/load/load_linux.go @@ -0,0 +1,78 @@ +// +build linux + +package load + +import ( + "io/ioutil" + "strconv" + "strings" + + "github.com/shirou/gopsutil/internal/common" +) + +func Avg() (*AvgStat, error) { + filename := common.HostProc("loadavg") + line, err := ioutil.ReadFile(filename) + if err != nil { + return nil, err + } + + values := strings.Fields(string(line)) + + load1, err := strconv.ParseFloat(values[0], 64) + if err != nil { + return nil, err + } + load5, err := strconv.ParseFloat(values[1], 64) + if err != nil { + return nil, err + } + load15, err := strconv.ParseFloat(values[2], 64) + if err != nil { + return nil, err + } + + ret := &AvgStat{ + Load1: load1, + Load5: load5, + Load15: load15, + } + + return ret, nil +} + +// Misc returnes miscellaneous host-wide statistics. +// Note: the name should be changed near future. +func Misc() (*MiscStat, error) { + filename := common.HostProc("stat") + out, err := ioutil.ReadFile(filename) + if err != nil { + return nil, err + } + + ret := &MiscStat{} + lines := strings.Split(string(out), "\n") + for _, line := range lines { + fields := strings.Fields(line) + if len(fields) != 2 { + continue + } + v, err := strconv.ParseInt(fields[1], 10, 64) + if err != nil { + continue + } + switch fields[0] { + case "procs_running": + ret.ProcsRunning = int(v) + case "procs_blocked": + ret.ProcsBlocked = int(v) + case "ctxt": + ret.Ctxt = int(v) + default: + continue + } + + } + + return ret, nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/load/load_windows.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/load/load_windows.go new file mode 100644 index 0000000000..c45c15442c --- /dev/null +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/load/load_windows.go @@ -0,0 +1,19 @@ +// +build windows + +package load + +import ( + "github.com/shirou/gopsutil/internal/common" +) + +func Avg() (*AvgStat, error) { + ret := AvgStat{} + + return &ret, common.ErrNotImplementedError +} + +func Misc() (*MiscStat, error) { + ret := MiscStat{} + + return &ret, common.ErrNotImplementedError +} diff --git a/tests/rkt-monitor/README.md b/tests/rkt-monitor/README.md index e600f5d746..09214b2411 100644 --- a/tests/rkt-monitor/README.md +++ b/tests/rkt-monitor/README.md @@ -40,4 +40,7 @@ rkt(13261): seconds alive: 10 avg CPU: 33.113897% avg Mem: 4 kB peak Mem: 4 k systemd(13302): seconds alive: 9 avg CPU: 0.000000% avg Mem: 4 mB peak Mem: 4 mB systemd-journal(13303): seconds alive: 9 avg CPU: 68.004584% avg Mem: 7 mB peak Mem: 7 mB worker(13307): seconds alive: 9 avg CPU: 13.004088% avg Mem: 1 mB peak Mem: 1 mB +load average in a container: Load1: 0.280000 Load5: 0.250000 Load15: 0.200000 +container start time: 315621ns +container stop time: 17280555ns ``` diff --git a/tests/rkt-monitor/main.go b/tests/rkt-monitor/main.go index 8679aa3344..c3191e21e4 100644 --- a/tests/rkt-monitor/main.go +++ b/tests/rkt-monitor/main.go @@ -24,6 +24,7 @@ import ( "time" "github.com/appc/spec/schema" + "github.com/shirou/gopsutil/load" "github.com/shirou/gopsutil/process" "github.com/spf13/cobra" ) @@ -97,24 +98,28 @@ func runRktMonitor(cmd *cobra.Command, args []string) { var execCmd *exec.Cmd if podManifest { - execCmd = exec.Command("rkt", "run", "--pod-manifest", args[0], "--net=host") + execCmd = exec.Command("rkt", "run", "--pod-manifest", args[0], "--net=default-restricted") } else { - execCmd = exec.Command("rkt", "run", args[0], "--insecure-options=image", "--net=host") + execCmd = exec.Command("rkt", "run", args[0], "--insecure-options=image", "--net=default-restricted") } if flagShowOutput { execCmd.Stdout = os.Stdout execCmd.Stderr = os.Stderr } + + containerStarting := time.Now() + err = execCmd.Start() if err != nil { fmt.Printf("%v\n", err) os.Exit(1) } + containerStarted := time.Now() c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt) go func() { - for range c { + for _ = range c { err := killAllChildren(int32(execCmd.Process.Pid)) if err != nil { fmt.Fprintf(os.Stderr, "cleanup failed: %v\n", err) @@ -149,10 +154,14 @@ func runRktMonitor(cmd *cobra.Command, args []string) { time.Sleep(time.Second) } + loadAvg, err := load.Avg() + + containerStopping := time.Now() err = killAllChildren(int32(execCmd.Process.Pid)) if err != nil { fmt.Fprintf(os.Stderr, "cleanup failed: %v\n", err) } + containerStoped := time.Now() for _, processHistory := range usages { var avgCPU float64 @@ -172,6 +181,10 @@ func runRktMonitor(cmd *cobra.Command, args []string) { fmt.Printf("%s(%d): seconds alive: %d avg CPU: %f%% avg Mem: %s peak Mem: %s\n", processHistory[0].Name, processHistory[0].Pid, len(processHistory), avgCPU, formatSize(avgMem), formatSize(peakMem)) } + fmt.Printf("load average: Load1: %f Load5: %f Load15: %f\n", loadAvg.Load1, loadAvg.Load5, loadAvg.Load15) + + fmt.Printf("container start time: %dns\n", containerStarted.Sub(containerStarting).Nanoseconds()) + fmt.Printf("container stop time: %dns\n", containerStoped.Sub(containerStopping).Nanoseconds()) } func killAllChildren(pid int32) error { From febc6c6e186e8ea0ec2f396e31d25e01215ba686 Mon Sep 17 00:00:00 2001 From: Wlodzimierz Borkowski Date: Thu, 12 May 2016 15:53:43 +0200 Subject: [PATCH 0304/1304] tests: save interval data measures to csv file Save data to csv - useful for plot a graph of usage. Add a flag command for additional validation. Fix some docs regarding to rkt-monitor. --- .../benchmarks/rkt-1-4-0-benchmarks.md | 6 +-- tests/rkt-monitor/main.go | 46 ++++++++++++++++++- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/Documentation/benchmarks/rkt-1-4-0-benchmarks.md b/Documentation/benchmarks/rkt-1-4-0-benchmarks.md index ffed74e972..1bbffa3488 100644 --- a/Documentation/benchmarks/rkt-1-4-0-benchmarks.md +++ b/Documentation/benchmarks/rkt-1-4-0-benchmarks.md @@ -17,7 +17,7 @@ rkt(18493): seconds alive: 10 avg CPU: 28.314541% avg Mem: 2 mB peak Mem: 2 m systemd(18515): seconds alive: 9 avg CPU: 0.000000% avg Mem: 4 mB peak Mem: 4 mB systemd-journal(18517): seconds alive: 9 avg CPU: 88.397098% avg Mem: 7 mB peak Mem: 7 mB worker(18521): seconds alive: 9 avg CPU: 7.330367% avg Mem: 5 mB peak Mem: 6 mB -load average in a container: Load1: 0.390000 Load5: 0.120000 Load15: 0.080000 +load average: Load1: 0.390000 Load5: 0.120000 Load15: 0.080000 container start time: 250721ns container stop time: 17332926ns @@ -30,7 +30,7 @@ worker(18634): seconds alive: 9 avg CPU: 98.550401% avg Mem: 318 mB peak Mem: rkt(18599): seconds alive: 10 avg CPU: 3.583814% avg Mem: 2 mB peak Mem: 2 mB systemd(18628): seconds alive: 9 avg CPU: 0.000000% avg Mem: 4 mB peak Mem: 4 mB systemd-journal(18630): seconds alive: 9 avg CPU: 0.000000% avg Mem: 6 mB peak Mem: 6 mB -load average in a container: Load1: 0.310000 Load5: 0.150000 Load15: 0.090000 +load average: Load1: 0.310000 Load5: 0.150000 Load15: 0.090000 container start time: 259746ns container stop time: 17593446ns ``` @@ -42,7 +42,7 @@ rkt(18706): seconds alive: 10 avg CPU: 3.587050% avg Mem: 2 mB peak Mem: 2 mB systemd(18736): seconds alive: 9 avg CPU: 0.000000% avg Mem: 4 mB peak Mem: 4 mB systemd-journal(18740): seconds alive: 9 avg CPU: 0.000000% avg Mem: 6 mB peak Mem: 6 mB worker(18744): seconds alive: 9 avg CPU: 88.937493% avg Mem: 808 kB peak Mem: 808 kB -load average in a container: Load1: 0.310000 Load5: 0.130000 Load15: 0.080000 +load average: Load1: 0.310000 Load5: 0.130000 Load15: 0.080000 container start time: 296570ns container stop time: 16124700ns ``` diff --git a/tests/rkt-monitor/main.go b/tests/rkt-monitor/main.go index c3191e21e4..0eb0bde78a 100644 --- a/tests/rkt-monitor/main.go +++ b/tests/rkt-monitor/main.go @@ -15,7 +15,9 @@ package main import ( + "encoding/csv" "encoding/json" + "flag" "fmt" "os" "os/exec" @@ -44,6 +46,7 @@ var ( flagVerbose bool flagDuration string flagShowOutput bool + saveToCsv bool cmdRktMonitor = &cobra.Command{ Use: "rkt-monitor IMAGE", @@ -59,6 +62,9 @@ func init() { cmdRktMonitor.Flags().BoolVarP(&flagVerbose, "verbose", "v", false, "Print current usage every second") cmdRktMonitor.Flags().StringVarP(&flagDuration, "duration", "d", "10s", "How long to run the ACI") cmdRktMonitor.Flags().BoolVarP(&flagShowOutput, "show-output", "o", false, "Display rkt's stdout and stderr") + cmdRktMonitor.Flags().BoolVarP(&saveToCsv, "to-file", "f", false, "Save benchmark results to benchmark.csv file") + + flag.Parse() } func main() { @@ -119,7 +125,7 @@ func runRktMonitor(cmd *cobra.Command, args []string) { c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt) go func() { - for _ = range c { + for range c { err := killAllChildren(int32(execCmd.Process.Pid)) if err != nil { fmt.Fprintf(os.Stderr, "cleanup failed: %v\n", err) @@ -131,6 +137,9 @@ func runRktMonitor(cmd *cobra.Command, args []string) { usages := make(map[int32][]*ProcessStatus) timeToStop := time.Now().Add(d) + + records := [][]string{{"Time", "PID name", "PID number", "RSS", "CPU"}} // csv headers + for time.Now().Before(timeToStop) { usage, err := getUsage(int32(execCmd.Process.Pid)) if err != nil { @@ -140,6 +149,10 @@ func runRktMonitor(cmd *cobra.Command, args []string) { printUsage(usage) } + if saveToCsv { + records = addRecords(usage, records) + } + for _, ps := range usage { usages[ps.Pid] = append(usages[ps.Pid], ps) } @@ -181,6 +194,14 @@ func runRktMonitor(cmd *cobra.Command, args []string) { fmt.Printf("%s(%d): seconds alive: %d avg CPU: %f%% avg Mem: %s peak Mem: %s\n", processHistory[0].Name, processHistory[0].Pid, len(processHistory), avgCPU, formatSize(avgMem), formatSize(peakMem)) } + + if saveToCsv { + saveRecords(records) + if err != nil { + fmt.Fprintf(os.Stderr, "Can't write to a file: %v\n", err) + } + } + fmt.Printf("load average: Load1: %f Load5: %f Load15: %f\n", loadAvg.Load1, loadAvg.Load5, loadAvg.Load15) fmt.Printf("container start time: %dns\n", containerStarted.Sub(containerStarting).Nanoseconds()) @@ -296,3 +317,26 @@ func printUsage(statuses []*ProcessStatus) { } fmt.Printf("\n") } + +func addRecords(statuses []*ProcessStatus, records [][]string) [][]string { + for _, s := range statuses { + records = append(records, []string{time.Now().String(), s.Name, strconv.Itoa(int(s.Pid)), formatSize(s.RSS), strconv.FormatFloat(s.CPU, 'g', 1, 64)}) + } + return records +} + +func saveRecords(records [][]string) error { + csvFile, err := os.Create("benchmark.csv") + defer csvFile.Close() + if err != nil { + return err + } + + w := csv.NewWriter(csvFile) + w.WriteAll(records) + if err := w.Error(); err != nil { + return err + } + + return nil +} From e828bb5de7c2d031acf8ebca958fc45880be8d65 Mon Sep 17 00:00:00 2001 From: Wlodzimierz Borkowski Date: Wed, 18 May 2016 16:08:48 +0200 Subject: [PATCH 0305/1304] tests: add new flag for repetitions number, docs update --- Documentation/benchmarks/README.md | 10 +- tests/rkt-monitor/README.md | 2 + tests/rkt-monitor/main.go | 191 ++++++++++++++++------------- 3 files changed, 117 insertions(+), 86 deletions(-) diff --git a/Documentation/benchmarks/README.md b/Documentation/benchmarks/README.md index a46fc58ce9..f626b571a2 100644 --- a/Documentation/benchmarks/README.md +++ b/Documentation/benchmarks/README.md @@ -23,7 +23,9 @@ command `rkt fetch --insecure-options=image /*`. With rkt-monitor and an ACI or a pod manifest, now the benchmarks can be run via `./rkt-monitor `. -There are two flags available to influence how rkt-monitor runs. `-v` will -print out the current resource usage of each process every second. `-d` can be -used to specify a duration to run the tests for (default of 10s). For example, -`-d 30s` will run the tests for 30 seconds. +There are four flags available to influence how rkt-monitor runs. `-r ` set the +number of benchmark experiment repetitions, `-f` save output to files in a +temporary directory with `rkt_benchmark` prefix, `-v` will print out the current +resource usage of each process every second. `-d` can be used to specify a +duration to run the tests for (default of 10s). For example, `-d 30s` will run +the tests for 30 seconds. diff --git a/tests/rkt-monitor/README.md b/tests/rkt-monitor/README.md index 09214b2411..1beda661fb 100644 --- a/tests/rkt-monitor/README.md +++ b/tests/rkt-monitor/README.md @@ -14,8 +14,10 @@ Examples: rkt-monitor mem-stresser.aci -v -d 30s Flags: + -f, --to-file[=false]: Save benchmark results to files in a temp dir -d, --duration="10s": How long to run the ACI -h, --help[=false]: help for rkt-monitor + -r, --repetitions=1: Numbers of benchmark repetitions -o, --show-output[=false]: Display rkt's stdout and stderr -v, --verbose[=false]: Print current usage every second ``` diff --git a/tests/rkt-monitor/main.go b/tests/rkt-monitor/main.go index 0eb0bde78a..0803ece332 100644 --- a/tests/rkt-monitor/main.go +++ b/tests/rkt-monitor/main.go @@ -19,6 +19,7 @@ import ( "encoding/json" "flag" "fmt" + "io/ioutil" "os" "os/exec" "os/signal" @@ -43,10 +44,11 @@ type ProcessStatus struct { var ( pidMap map[int32]*process.Process - flagVerbose bool - flagDuration string - flagShowOutput bool - saveToCsv bool + flagVerbose bool + flagDuration string + flagShowOutput bool + flagSaveToCsv bool + flagRepetitionNumber int cmdRktMonitor = &cobra.Command{ Use: "rkt-monitor IMAGE", @@ -60,9 +62,10 @@ func init() { pidMap = make(map[int32]*process.Process) cmdRktMonitor.Flags().BoolVarP(&flagVerbose, "verbose", "v", false, "Print current usage every second") + cmdRktMonitor.Flags().IntVarP(&flagRepetitionNumber, "repetitions", "r", 1, "Numbers of benchmark repetitions") cmdRktMonitor.Flags().StringVarP(&flagDuration, "duration", "d", "10s", "How long to run the ACI") cmdRktMonitor.Flags().BoolVarP(&flagShowOutput, "show-output", "o", false, "Display rkt's stdout and stderr") - cmdRktMonitor.Flags().BoolVarP(&saveToCsv, "to-file", "f", false, "Save benchmark results to benchmark.csv file") + cmdRktMonitor.Flags().BoolVarP(&flagSaveToCsv, "to-file", "f", false, "Save benchmark results to files in a temp dir") flag.Parse() } @@ -103,109 +106,133 @@ func runRktMonitor(cmd *cobra.Command, args []string) { } var execCmd *exec.Cmd - if podManifest { - execCmd = exec.Command("rkt", "run", "--pod-manifest", args[0], "--net=default-restricted") - } else { - execCmd = exec.Command("rkt", "run", args[0], "--insecure-options=image", "--net=default-restricted") - } - if flagShowOutput { - execCmd.Stdout = os.Stdout - execCmd.Stderr = os.Stderr - } + var loadAvg *load.AvgStat + var containerStarting, containerStarted, containerStopping, containerStopped time.Time - containerStarting := time.Now() + records := [][]string{{"Time", "PID name", "PID number", "RSS", "CPU"}} // csv headers + summaryRecords := [][]string{{"Load1", "Load5", "Load15", "StartTime", "StopTime"}} // csv summary headers - err = execCmd.Start() - if err != nil { - fmt.Printf("%v\n", err) - os.Exit(1) - } - containerStarted := time.Now() + for i := 0; i < flagRepetitionNumber; i++ { + containerStarting = time.Now() - c := make(chan os.Signal, 1) - signal.Notify(c, os.Interrupt) - go func() { - for range c { - err := killAllChildren(int32(execCmd.Process.Pid)) - if err != nil { - fmt.Fprintf(os.Stderr, "cleanup failed: %v\n", err) - } + if podManifest { + execCmd = exec.Command("rkt", "run", "--pod-manifest", args[0], "--net=default-restricted") + } else { + execCmd = exec.Command("rkt", "run", args[0], "--insecure-options=image", "--net=default-restricted") + } + + if flagShowOutput { + execCmd.Stdout = os.Stdout + execCmd.Stderr = os.Stderr + } + + err = execCmd.Start() + containerStarted = time.Now() + if err != nil { + fmt.Printf("%v\n", err) os.Exit(1) } - }() - usages := make(map[int32][]*ProcessStatus) + c := make(chan os.Signal, 1) + signal.Notify(c, os.Interrupt) + go func() { + for range c { + err := killAllChildren(int32(execCmd.Process.Pid)) + if err != nil { + fmt.Fprintf(os.Stderr, "cleanup failed: %v\n", err) + } + os.Exit(1) + } + }() - timeToStop := time.Now().Add(d) + usages := make(map[int32][]*ProcessStatus) - records := [][]string{{"Time", "PID name", "PID number", "RSS", "CPU"}} // csv headers + timeToStop := time.Now().Add(d) - for time.Now().Before(timeToStop) { - usage, err := getUsage(int32(execCmd.Process.Pid)) - if err != nil { - panic(err) - } - if flagVerbose { - printUsage(usage) - } + for time.Now().Before(timeToStop) { + usage, err := getUsage(int32(execCmd.Process.Pid)) + if err != nil { + panic(err) + } + if flagVerbose { + printUsage(usage) + } - if saveToCsv { - records = addRecords(usage, records) + if flagSaveToCsv { + records = addRecords(usage, records) + } + + for _, ps := range usage { + usages[ps.Pid] = append(usages[ps.Pid], ps) + } + + _, err = process.NewProcess(int32(execCmd.Process.Pid)) + if err != nil { + // process.Process.IsRunning is not implemented yet + fmt.Fprintf(os.Stderr, "rkt exited prematurely\n") + break + } + + time.Sleep(time.Second) } - for _, ps := range usage { - usages[ps.Pid] = append(usages[ps.Pid], ps) + loadAvg, err = load.Avg() + if err != nil { + fmt.Fprintf(os.Stderr, "measure load avg failed: %v\n", err) } - _, err = process.NewProcess(int32(execCmd.Process.Pid)) + containerStopping = time.Now() + err = killAllChildren(int32(execCmd.Process.Pid)) + containerStopped = time.Now() if err != nil { - // process.Process.IsRunning is not implemented yet - fmt.Fprintf(os.Stderr, "rkt exited prematurely\n") - break + fmt.Fprintf(os.Stderr, "cleanup failed: %v\n", err) } - time.Sleep(time.Second) - } + for _, processHistory := range usages { + var avgCPU float64 + var avgMem uint64 + var peakMem uint64 + + for _, p := range processHistory { + avgCPU += p.CPU + avgMem += p.RSS + if peakMem < p.RSS { + peakMem = p.RSS + } + } - loadAvg, err := load.Avg() + avgCPU = avgCPU / float64(len(processHistory)) + avgMem = avgMem / uint64(len(processHistory)) - containerStopping := time.Now() - err = killAllChildren(int32(execCmd.Process.Pid)) - if err != nil { - fmt.Fprintf(os.Stderr, "cleanup failed: %v\n", err) - } - containerStoped := time.Now() - - for _, processHistory := range usages { - var avgCPU float64 - var avgMem uint64 - var peakMem uint64 - - for _, p := range processHistory { - avgCPU += p.CPU - avgMem += p.RSS - if peakMem < p.RSS { - peakMem = p.RSS + if !flagSaveToCsv { + fmt.Printf("%s(%d): seconds alive: %d avg CPU: %f%% avg Mem: %s peak Mem: %s\n", processHistory[0].Name, processHistory[0].Pid, len(processHistory), avgCPU, formatSize(avgMem), formatSize(peakMem)) } } - avgCPU = avgCPU / float64(len(processHistory)) - avgMem = avgMem / uint64(len(processHistory)) - - fmt.Printf("%s(%d): seconds alive: %d avg CPU: %f%% avg Mem: %s peak Mem: %s\n", processHistory[0].Name, processHistory[0].Pid, len(processHistory), avgCPU, formatSize(avgMem), formatSize(peakMem)) + if flagSaveToCsv { + summaryRecords = append(summaryRecords, []string{ + strconv.FormatFloat(loadAvg.Load1, 'g', 3, 64), + strconv.FormatFloat(loadAvg.Load5, 'g', 3, 64), + strconv.FormatFloat(loadAvg.Load15, 'g', 3, 64), + strconv.FormatInt(containerStarted.Sub(containerStarting).Nanoseconds(), 10), + strconv.FormatInt(containerStopped.Sub(containerStopping).Nanoseconds(), 10)}) + } else { + fmt.Printf("load average: Load1: %f Load5: %f Load15: %f\n", loadAvg.Load1, loadAvg.Load5, loadAvg.Load15) + fmt.Printf("container start time: %dns\n", containerStarted.Sub(containerStarting).Nanoseconds()) + fmt.Printf("container stop time: %dns\n", containerStopped.Sub(containerStopping).Nanoseconds()) + } } - if saveToCsv { - saveRecords(records) + if flagSaveToCsv { + err = saveRecords(records, "rkt_benchmark_interval_") if err != nil { fmt.Fprintf(os.Stderr, "Can't write to a file: %v\n", err) } + err = saveRecords(summaryRecords, "rkt_benchmark_summary_") + if err != nil { + fmt.Fprintf(os.Stderr, "Can't write to a summary file: %v\n", err) + } } - - fmt.Printf("load average: Load1: %f Load5: %f Load15: %f\n", loadAvg.Load1, loadAvg.Load5, loadAvg.Load15) - - fmt.Printf("container start time: %dns\n", containerStarted.Sub(containerStarting).Nanoseconds()) - fmt.Printf("container stop time: %dns\n", containerStoped.Sub(containerStopping).Nanoseconds()) } func killAllChildren(pid int32) error { @@ -325,8 +352,8 @@ func addRecords(statuses []*ProcessStatus, records [][]string) [][]string { return records } -func saveRecords(records [][]string) error { - csvFile, err := os.Create("benchmark.csv") +func saveRecords(records [][]string, prefix string) error { + csvFile, err := ioutil.TempFile("", prefix) defer csvFile.Close() if err != nil { return err From 66bb5c5392d8a7f765658e547ba8b51369dcf59b Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Fri, 20 May 2016 21:54:19 +0200 Subject: [PATCH 0306/1304] stage1: restrict access to procfs and sysfs paths Many procfs and sysfs endpoints are currently not namespace-aware and can be used by malicious pods to manipulate host state and escape the sandboxing. This commit introduces an initial mitigation, by marking those paths as read-only or inaccessible to containers. --- stage1/init/common/pod.go | 37 +++++++++++++++++++++++++++++++++++++ tests/rkt_mount_test.go | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index 3dad4c9bc9..dbf63b4c9d 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -454,6 +454,43 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b unit.NewUnitOption("Service", "SyslogIdentifier", appName.String()), } + // Restrict access to some security-sensitive paths under /proc and /sys. + // Those entries can be hidden or just made read-only to app. + roPaths := []string{ + "/proc/sys/kernel/core_pattern", + "/proc/sys/kernel/modprobe", + "/proc/sys/vm/panic_on_oom", + "/proc/sysrq-trigger", + "/sys/block/", + "/sys/bus/", + "/sys/class/", + "/sys/dev/", + "/sys/devices/", + "/sys/kernel/", + } + hiddenPaths := []string{ + // TODO(lucab): file-paths restrictions need support in systemd first + //"/proc/config.gz", + //"/proc/kallsyms", + //"/proc/sched_debug", + //"/proc/kcore", + //"/proc/kmem", + //"/proc/mem", + "/sys/firmware/", + "/sys/fs/", + "/sys/hypervisor/", + "/sys/module/", + "/sys/power/", + } + // Paths prefixed with "-" are ignored if they do not exist: + // [https://www.freedesktop.org/software/systemd/man/systemd.exec.html#ReadWriteDirectories=] + for _, p := range hiddenPaths { + opts = append(opts, unit.NewUnitOption("Service", "InaccessibleDirectories", fmt.Sprintf("-%s", filepath.Join(common.RelAppRootfsPath(appName), p)))) + } + for _, p := range roPaths { + opts = append(opts, unit.NewUnitOption("Service", "ReadOnlyDirectories", fmt.Sprintf("-%s", filepath.Join(common.RelAppRootfsPath(appName), p)))) + } + if ra.ReadOnlyRootFS { opts = append(opts, unit.NewUnitOption("Service", "ReadOnlyDirectories", common.RelAppRootfsPath(appName))) } diff --git a/tests/rkt_mount_test.go b/tests/rkt_mount_test.go index a1f3585540..d93c72ed9a 100644 --- a/tests/rkt_mount_test.go +++ b/tests/rkt_mount_test.go @@ -102,3 +102,35 @@ func TestMountSymlink(t *testing.T) { } } } + +// TestProcFSRestrictions checks that access to sensitive paths under +// /proc and /sys is correctly restricted: +// https://github.com/coreos/rkt/issues/2484 +func TestProcFSRestrictions(t *testing.T) { + // check access to read-only paths + roEntry := "/proc/sysrq-trigger" + testContent := "h" + roImage := patchTestACI("rkt-inspect-write-procfs.aci", fmt.Sprintf("--exec=/inspect --write-file --file-name %s --content %s", roEntry, testContent)) + defer os.Remove(roImage) + + roCtx := testutils.NewRktRunCtx() + defer roCtx.Cleanup() + + roCmd := fmt.Sprintf("%s --insecure-options=image run %s", roCtx.Cmd(), roImage) + + roExpectedLine := fmt.Sprintf("Cannot write to file \"%s\"", roEntry) + runRktAndCheckOutput(t, roCmd, roExpectedLine, true) + + // check access to inaccessible paths + hiddenEntry := "/sys/firmware/" + hiddenImage := patchTestACI("rkt-inspect-stat-procfs.aci", fmt.Sprintf("--exec=/inspect --stat-file --file-name %s", hiddenEntry)) + defer os.Remove(hiddenImage) + + hiddenCtx := testutils.NewRktRunCtx() + defer hiddenCtx.Cleanup() + + hiddenCmd := fmt.Sprintf("%s --insecure-options=image run %s", hiddenCtx.Cmd(), hiddenImage) + + hiddenExpectedLine := fmt.Sprintf("%s: mode: d---------", hiddenEntry) + runRktAndCheckOutput(t, hiddenCmd, hiddenExpectedLine, false) +} From 8f14d4df13fcbe4a237178e946ac6e5b7c5c5954 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 25 May 2016 12:09:16 +0200 Subject: [PATCH 0307/1304] git-validation: check only the HEAD commit Travis fails because git-validation also checks Godeps changes. Let's check only HEAD until https://github.com/coreos/git-validation/issues/4 is solved. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fc02f1fd7c..e8ea25c50d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ go: before_install: - go get -u github.com/coreos/git-validation - - git-validation -run subsystem-in-subject,dangling-whitespace + - git-validation -run subsystem-in-subject,dangling-whitespace -range HEAD^.. install: - sudo apt-get update -qq From dd2b775844932d21ad307c3b96ee10f09f12dfdd Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Wed, 25 May 2016 13:42:36 +0200 Subject: [PATCH 0308/1304] build: Find also blackbox tests for unit-check We were only checking the packages that had non-empty TestGoFiles field returned by "go list". But the TestGoFiles contains only files that have the same package as the non-test files in the same directory. The test files with the different package name are in the XTestGoFiles field, which we did not handle before. This makes go test to run the test for pkg/selinux and pkg/user packages too. --- makelib/misc.mk | 11 ++++++----- tests/tests.mk | 15 ++++++--------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/makelib/misc.mk b/makelib/misc.mk index ba6b6b4720..fcd0dfc15f 100644 --- a/makelib/misc.mk +++ b/makelib/misc.mk @@ -165,11 +165,11 @@ $(eval $(call setup-custom-dep-file,$1,$(MK_PATH)$2)) endef # Returns all not-excluded directories inside $REPO_PATH that have -# nonzero files matching given "go list -f {{.ITEM}}". +# nonzero files matching given "go list -f {{.ITEM1}} {{.ITEM2}}...". # 1 - where to look for files (./... to look for all files inside the project) -# 2 - a "go list -f {{.ITEM}}" item (GoFiles, TestGoFiles, etc) +# 2 - a list of "go list -f {{.ITEM}}" items (GoFiles, TestGoFiles, etc) # 3 - space-separated list of excluded directories -# Example: $(call go-find-directories,./...,TestGoFiles,tests) +# Example: $(call go-find-directories,./...,TestGoFiles XTestGoFiles,tests) define go-find-directories $(strip \ $(eval _MISC_GFD_ESCAPED_SRCDIR := $(MK_TOPLEVEL_ABS_SRCDIR)) \ @@ -177,8 +177,9 @@ $(strip \ $(eval _MISC_GFD_ESCAPED_SRCDIR := $(subst /,\/,$(_MISC_GFD_ESCAPED_SRCDIR))) \ $(eval _MISC_GFD_SPACE_ :=) \ $(eval _MISC_GFD_SPACE_ +=) \ - $(eval _MISC_GFD_FILES_ := $(shell $(GO_ENV) "$(GO)" list -f '{{.ImportPath}} {{.$2}}' $1 | \ - grep --invert-match '\[\]' | \ + $(eval _MISC_GFD_GO_LIST_ITEMS_ := $(foreach i,$2,{{.$i}})) \ + $(eval _MISC_GFD_FILES_ := $(shell $(GO_ENV) "$(GO)" list -f '{{.ImportPath}} $(_MISC_GFD_GO_LIST_ITEMS_)' $1 | \ + grep '\[[^]]' | \ sed -e 's/.*$(_MISC_GFD_ESCAPED_SRCDIR)\///' -e 's/[[:space:]]*\[.*\]$$//' \ $(if $3,| grep --invert-match '^\($(subst $(_MISC_GFD_SPACE_),\|,$3)\)'))) \ $(_MISC_GFD_FILES_) \ diff --git a/tests/tests.mk b/tests/tests.mk index 4ac27d653b..2eaef12f4d 100644 --- a/tests/tests.mk +++ b/tests/tests.mk @@ -1,18 +1,15 @@ $(call setup-stamp-file,TST_SHORT_TESTS_STAMP,/short-tests) -TST_DIRS_WITH_GOFILES := $(call go-find-directories,$(GO_TEST_PACKAGES),GoFiles) -TST_DIRS_WITH_TESTGOFILES := $(call go-find-directories,$(GO_TEST_PACKAGES),TestGoFiles,tests) - # gofmt takes list of directories -TST_GOFMT_DIRS := $(foreach d,$(TST_DIRS_WITH_GOFILES),./$d) # go vet and go test take a list of packages -TST_GO_VET_PACKAGES := $(foreach d,$(TST_DIRS_WITH_GOFILES),$(REPO_PATH)/$d) -TST_GO_TEST_PACKAGES := $(foreach d,$(TST_DIRS_WITH_TESTGOFILES),$(REPO_PATH)/$d) - $(call forward-vars,$(TST_SHORT_TESTS_STAMP), \ - GOFMT TST_GOFMT_DIRS GO_ENV GO TST_GO_VET_PACKAGES RKT_TAGS \ - TST_GO_TEST_PACKAGES) + GOFMT GO_ENV GO RKT_TAGS) $(TST_SHORT_TESTS_STAMP): + $(eval TST_DIRS_WITH_GOFILES := $(call go-find-directories,$(GO_TEST_PACKAGES),GoFiles)) + $(eval TST_DIRS_WITH_TESTGOFILES := $(call go-find-directories,$(GO_TEST_PACKAGES),TestGoFiles XTestGoFiles,tests)) + $(eval TST_GOFMT_DIRS := $(foreach d,$(TST_DIRS_WITH_GOFILES),./$d)) + $(eval TST_GO_VET_PACKAGES := $(foreach d,$(TST_DIRS_WITH_GOFILES),$(REPO_PATH)/$d)) + $(eval TST_GO_TEST_PACKAGES := $(foreach d,$(TST_DIRS_WITH_TESTGOFILES),$(REPO_PATH)/$d)) $(VQ) \ set -e; \ $(call vb,vt,GOFMT,$(TST_GOFMT_DIRS)) \ From 9b651d6202947578039dbe9e2206745163b086bd Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Wed, 25 May 2016 18:27:18 +0200 Subject: [PATCH 0309/1304] travis: really remove git validation --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index e8ea25c50d..a61b4039b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,10 +6,6 @@ go: - 1.5.3 - 1.6 -before_install: - - go get -u github.com/coreos/git-validation - - git-validation -run subsystem-in-subject,dangling-whitespace -range HEAD^.. - install: - sudo apt-get update -qq - sudo apt-get install -y cpio realpath squashfs-tools From 752236fde53a1ae0b66dd3023155a81fae4adc9a Mon Sep 17 00:00:00 2001 From: Derek Gonyeo Date: Sun, 15 May 2016 20:52:02 -0400 Subject: [PATCH 0310/1304] docs: added instructions for installing a newer rkt in coreos Added Documentation/install-rkt-in-coreos.md, which details a systemd oneshot unit file that downloads and extracts rkt to /opt. Added a reference to this file in Documentation/distributions.md. --- Documentation/distributions.md | 2 ++ Documentation/install-rkt-in-coreos.md | 38 ++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 Documentation/install-rkt-in-coreos.md diff --git a/Documentation/distributions.md b/Documentation/distributions.md index 22df43dd35..9b4ecd788e 100644 --- a/Documentation/distributions.md +++ b/Documentation/distributions.md @@ -5,6 +5,8 @@ rkt is an integral part of CoreOS, installed with the operating system. The [CoreOS releases page](https://coreos.com/releases/) lists the version of rkt available in each CoreOS release channel. +If the version of rkt included in CoreOS is too old, it's fairly trivial to fetch the desired version [via a systemd unit](Documentation/install-rkt-in-coreos.md) + ## Fedora rkt is packaged in the development version of Fedora, [Rawhide](https://fedoraproject.org/wiki/Releases/Rawhide): diff --git a/Documentation/install-rkt-in-coreos.md b/Documentation/install-rkt-in-coreos.md new file mode 100644 index 0000000000..484f09c3cc --- /dev/null +++ b/Documentation/install-rkt-in-coreos.md @@ -0,0 +1,38 @@ +# Installing a different version of rkt in CoreOS + +If a different version of rkt is required than what ships with CoreOS, a +oneshot systemd unit can be used to download and install an alternate version +on boot. + +The following unit will use curl to download rkt, its signature, and the CoreOS +app signing key. The downloaded rkt is then verified with its signature, and +extracted to /opt/rkt. + +``` +[Unit] +Description=rkt installer +Requires=network.target + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/bin/mkdir -p /opt/rkt +ExecStart=/usr/bin/curl --silent -L -o /opt/rkt.tar.gz +ExecStart=/usr/bin/curl --silent -L -o /opt/rkt.tar.gz.sig +ExecStart=/usr/bin/curl --silent -L -o /opt/coreos-app-signing-key.gpg https://coreos.com/dist/pubkeys/app-signing-pubkey.gpg +ExecStart=/usr/bin/gpg --keyring /tmp/gpg-keyring --no-default-keyring --import /opt/coreos-app-signing-key.gpg +ExecStart=/usr/bin/gpg --keyring /tmp/gpg-keyring --no-default-keyring --verify /opt/rkt.tar.gz.sig /opt/rkt.tar.gz +ExecStart=/usr/bin/tar --strip-components=1 -xf /opt/rkt.tar.gz -C /opt/rkt +``` + +The URLs in this unit must be filled in before the unit is installed. Valid +URLs can be found on [rkt's releases page][1]. + +This unit should be installed with either [ignition][2] or a [cloud config][3]. +Other units being added can then contain a `After=rkt-install.service` (or +whatever the service was named) to delay their running until rkt has been +installed. + +[1]: https://github.com/coreos/rkt/releases +[2]: https://coreos.com/ignition/docs/latest/ +[3]: https://coreos.com/os/docs/latest/cloud-config.html From 29c8b8603b28a807dc94dadef9ec42f95f9c9430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Doma=C5=84ski?= Date: Sun, 8 May 2016 22:43:13 +0200 Subject: [PATCH 0311/1304] disable OverlayFS by default when working on certain filesystems --- common/common.go | 23 +++++++++++++++++++++++ rkt/prepare.go | 2 +- rkt/run.go | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/common/common.go b/common/common.go index c557f0da7f..4320edfd0a 100644 --- a/common/common.go +++ b/common/common.go @@ -25,6 +25,7 @@ import ( "path/filepath" "strconv" "strings" + "syscall" "github.com/appc/spec/aci" "github.com/appc/spec/schema/types" @@ -56,6 +57,11 @@ const ( DefaultSystemConfigDir = "/usr/lib/rkt" ) +const ( + FsMagicAUFS = int64(0x61756673) // https://goo.gl/CBwx43 + FsMagicZFS = int64(0x2FC12FC1) // https://goo.gl/xTvzO5 +) + // Stage1ImagePath returns the path where the stage1 app image (unpacked ACI) is rooted, // (i.e. where its contents are extracted during stage0). func Stage1ImagePath(root string) string { @@ -314,3 +320,20 @@ func SystemdVersion(systemdBinaryPath string) (int, error) { return version, nil } + +// FSSupportsOverlay checks whether the filesystem under which +// a specified path resides is compatible with OverlayFS +func FSSupportsOverlay(path string) bool { + var data syscall.Statfs_t + err := syscall.Statfs(path, &data) + if err != nil { + return false + } + + if data.Type == FsMagicAUFS || + data.Type == FsMagicZFS { + return false + } + + return true +} diff --git a/rkt/prepare.go b/rkt/prepare.go index 46ee3ecf9b..8bcb22f809 100644 --- a/rkt/prepare.go +++ b/rkt/prepare.go @@ -170,7 +170,7 @@ func runPrepare(cmd *cobra.Command, args []string) (exit int) { pcfg := stage0.PrepareConfig{ CommonConfig: &cfg, - UseOverlay: !flagNoOverlay && common.SupportsOverlay(), + UseOverlay: !flagNoOverlay && common.SupportsOverlay() && common.FSSupportsOverlay(getDataDir()), PrivateUsers: privateUsers, SkipTreeStoreCheck: globalFlags.InsecureFlags.SkipOnDiskCheck(), } diff --git a/rkt/run.go b/rkt/run.go index c82029adb4..f0756d8bf4 100644 --- a/rkt/run.go +++ b/rkt/run.go @@ -235,7 +235,7 @@ func runRun(cmd *cobra.Command, args []string) (exit int) { pcfg := stage0.PrepareConfig{ CommonConfig: &cfg, - UseOverlay: !flagNoOverlay && common.SupportsOverlay(), + UseOverlay: !flagNoOverlay && common.SupportsOverlay() && common.FSSupportsOverlay(getDataDir()), PrivateUsers: privateUsers, SkipTreeStoreCheck: globalFlags.InsecureFlags.SkipOnDiskCheck(), } From ea619cab0fb916d7b2e6590b3109e28672e18537 Mon Sep 17 00:00:00 2001 From: Nick Owens Date: Wed, 25 May 2016 15:27:34 -0700 Subject: [PATCH 0312/1304] dist: fix "other" permissions so rkt list can work without root/rkt-admin without this, a user in the rkt group can't do an operation like 'rkt list' due to the permissions on /etc/rkt. core@core2 ~ $ id uid=500(core) gid=500(core) groups=500(core),10(wheel),233(docker),248(systemd-journal),250(portage),251(rkt),253(fleet) context=system_u:system_r:kernel_t:s0 core@core2 ~ $ rkt list list: cannot get configuration: stat /etc/rkt/paths.d: permission denied core@core2 ~ $ ls -ld /etc/rkt drwxrws---. 3 root rkt-admin 4096 Jan 21 10:34 /etc/rkt --- dist/init/systemd/tmpfiles.d/rkt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/init/systemd/tmpfiles.d/rkt.conf b/dist/init/systemd/tmpfiles.d/rkt.conf index 406172741e..e24c8ad097 100644 --- a/dist/init/systemd/tmpfiles.d/rkt.conf +++ b/dist/init/systemd/tmpfiles.d/rkt.conf @@ -23,4 +23,4 @@ d /var/lib/rkt/pods/run 2750 root rkt d /var/lib/rkt/pods/exited-garbage 2750 root rkt d /var/lib/rkt/pods/garbage 2750 root rkt -d /etc/rkt 2770 root rkt-admin +d /etc/rkt 2775 root rkt-admin From f9c3f392f8b2e66fec3ec860b5b8a4604285e6c1 Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Thu, 26 May 2016 12:53:16 +0200 Subject: [PATCH 0313/1304] Godeps: remove unused dependencies Seems these were inadvertently added in #2428 --- Godeps/Godeps.json | 42 +- .../src/github.com/gopherjs/gopherjs/js/js.go | 168 ----- .../src/github.com/jtolds/gls/LICENSE | 18 - .../src/github.com/jtolds/gls/README.md | 89 --- .../src/github.com/jtolds/gls/context.go | 144 ----- .../src/github.com/jtolds/gls/gen_sym.go | 13 - .../src/github.com/jtolds/gls/id_pool.go | 34 -- .../src/github.com/jtolds/gls/stack_tags.go | 43 -- .../github.com/jtolds/gls/stack_tags_js.go | 101 --- .../github.com/jtolds/gls/stack_tags_main.go | 61 -- .../smartystreets/assertions/.gitignore | 3 - .../smartystreets/assertions/.travis.yml | 14 - .../smartystreets/assertions/CONTRIBUTING.md | 12 - .../smartystreets/assertions/LICENSE.md | 23 - .../smartystreets/assertions/README.md | 575 ------------------ .../assertions/assertions.goconvey | 3 - .../smartystreets/assertions/collections.go | 244 -------- .../smartystreets/assertions/doc.go | 105 ---- .../smartystreets/assertions/equality.go | 280 --------- .../smartystreets/assertions/filter.go | 23 - .../internal/go-render/render/render.go | 477 --------------- .../internal/oglematchers/.gitignore | 5 - .../internal/oglematchers/.travis.yml | 4 - .../assertions/internal/oglematchers/LICENSE | 202 ------ .../internal/oglematchers/README.md | 58 -- .../internal/oglematchers/all_of.go | 70 --- .../assertions/internal/oglematchers/any.go | 32 - .../internal/oglematchers/any_of.go | 94 --- .../internal/oglematchers/contains.go | 61 -- .../internal/oglematchers/deep_equals.go | 88 --- .../internal/oglematchers/elements_are.go | 91 --- .../internal/oglematchers/equals.go | 541 ---------------- .../assertions/internal/oglematchers/error.go | 51 -- .../internal/oglematchers/greater_or_equal.go | 39 -- .../internal/oglematchers/greater_than.go | 39 -- .../internal/oglematchers/has_same_type_as.go | 37 -- .../internal/oglematchers/has_substr.go | 46 -- .../internal/oglematchers/identical_to.go | 134 ---- .../internal/oglematchers/less_or_equal.go | 41 -- .../internal/oglematchers/less_than.go | 152 ----- .../internal/oglematchers/matcher.go | 86 --- .../internal/oglematchers/matches_regexp.go | 69 --- .../internal/oglematchers/new_matcher.go | 43 -- .../assertions/internal/oglematchers/not.go | 53 -- .../internal/oglematchers/panics.go | 74 --- .../internal/oglematchers/pointee.go | 65 -- .../oglematchers/transform_description.go | 36 -- .../smartystreets/assertions/messages.go | 93 --- .../smartystreets/assertions/panic.go | 115 ---- .../smartystreets/assertions/quantity.go | 141 ----- .../smartystreets/assertions/serializer.go | 69 --- .../smartystreets/assertions/strings.go | 227 ------- .../smartystreets/assertions/time.go | 202 ------ .../smartystreets/assertions/type.go | 112 ---- .../smartystreets/goconvey/LICENSE.md | 23 - .../goconvey/convey/assertions.go | 68 --- .../smartystreets/goconvey/convey/context.go | 272 --------- .../goconvey/convey/convey.goconvey | 4 - .../goconvey/convey/discovery.go | 103 ---- .../smartystreets/goconvey/convey/doc.go | 218 ------- .../goconvey/convey/gotest/utils.go | 28 - .../smartystreets/goconvey/convey/init.go | 81 --- .../goconvey/convey/nilReporter.go | 15 - .../goconvey/convey/reporting/console.go | 16 - .../goconvey/convey/reporting/doc.go | 5 - .../goconvey/convey/reporting/dot.go | 40 -- .../goconvey/convey/reporting/gotest.go | 33 - .../goconvey/convey/reporting/init.go | 94 --- .../goconvey/convey/reporting/json.go | 88 --- .../goconvey/convey/reporting/printer.go | 57 -- .../goconvey/convey/reporting/problems.go | 80 --- .../goconvey/convey/reporting/reporter.go | 39 -- .../convey/reporting/reporting.goconvey | 2 - .../goconvey/convey/reporting/reports.go | 179 ------ .../goconvey/convey/reporting/statistics.go | 108 ---- .../goconvey/convey/reporting/story.go | 73 --- 76 files changed, 1 insertion(+), 7267 deletions(-) delete mode 100644 Godeps/_workspace/src/github.com/gopherjs/gopherjs/js/js.go delete mode 100644 Godeps/_workspace/src/github.com/jtolds/gls/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/jtolds/gls/README.md delete mode 100644 Godeps/_workspace/src/github.com/jtolds/gls/context.go delete mode 100644 Godeps/_workspace/src/github.com/jtolds/gls/gen_sym.go delete mode 100644 Godeps/_workspace/src/github.com/jtolds/gls/id_pool.go delete mode 100644 Godeps/_workspace/src/github.com/jtolds/gls/stack_tags.go delete mode 100644 Godeps/_workspace/src/github.com/jtolds/gls/stack_tags_js.go delete mode 100644 Godeps/_workspace/src/github.com/jtolds/gls/stack_tags_main.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/.gitignore delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/.travis.yml delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/CONTRIBUTING.md delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/LICENSE.md delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/README.md delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/assertions.goconvey delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/collections.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/doc.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/equality.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/filter.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/go-render/render/render.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/.gitignore delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/.travis.yml delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/README.md delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/all_of.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/any.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/any_of.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/contains.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/deep_equals.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/elements_are.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/equals.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/error.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/greater_than.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/has_substr.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/identical_to.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/less_than.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/matcher.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/new_matcher.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/not.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/panics.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/pointee.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/transform_description.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/messages.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/panic.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/quantity.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/serializer.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/strings.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/time.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/type.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/LICENSE.md delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/assertions.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/context.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/convey.goconvey delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/discovery.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/doc.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/gotest/utils.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/init.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/nilReporter.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/console.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/doc.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/dot.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/gotest.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/init.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/json.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/printer.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/problems.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reporter.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reporting.goconvey delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reports.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/statistics.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/story.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index e58a951fae..1e59f33be5 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,7 +1,7 @@ { "ImportPath": "github.com/coreos/rkt", "GoVersion": "go1.5", - "GodepVersion": "v62", + "GodepVersion": "v71", "Packages": [ "./...", "github.com/appc/spec/actool", @@ -433,11 +433,6 @@ "ImportPath": "github.com/google/btree", "Rev": "f06e229e679911bb31a04e07ac891115822e37c3" }, - { - "ImportPath": "github.com/gopherjs/gopherjs/js", - "Comment": "go1.5-45-g19e100e", - "Rev": "19e100e9652485a76176bc5fd2669f57d3a2743c" - }, { "ImportPath": "github.com/gorilla/context", "Rev": "50c25fb3b2b3b3cc724e9b6ac75fb44b3bccd0da" @@ -463,11 +458,6 @@ "Comment": "0.2.2-12-g0b12d6b", "Rev": "0b12d6b521d83fc7f755e7cfc1b1fbdd35a01a74" }, - { - "ImportPath": "github.com/jtolds/gls", - "Comment": "v4.2.0", - "Rev": "8ddce2a84170772b95dd5d576c48d517b22cac63" - }, { "ImportPath": "github.com/kballard/go-shellquote", "Rev": "e5c918b80c17694cbc49aab32a759f9a40067f5d" @@ -529,36 +519,6 @@ "ImportPath": "github.com/shurcooL/sanitized_anchor_name", "Rev": "10ef21a441db47d8b13ebcc5fd2310f636973c77" }, - { - "ImportPath": "github.com/smartystreets/assertions", - "Comment": "1.6.0-6-g40711f7", - "Rev": "40711f7748186bbf9c99977cd89f21ce1a229447" - }, - { - "ImportPath": "github.com/smartystreets/assertions/internal/go-render/render", - "Comment": "1.6.0-6-g40711f7", - "Rev": "40711f7748186bbf9c99977cd89f21ce1a229447" - }, - { - "ImportPath": "github.com/smartystreets/assertions/internal/oglematchers", - "Comment": "1.6.0-6-g40711f7", - "Rev": "40711f7748186bbf9c99977cd89f21ce1a229447" - }, - { - "ImportPath": "github.com/smartystreets/goconvey/convey", - "Comment": "1.6.1-20-gcc5d85f", - "Rev": "cc5d85f4f15bd2163abf0fe6e6753356dde72aa2" - }, - { - "ImportPath": "github.com/smartystreets/goconvey/convey/gotest", - "Comment": "1.6.1-20-gcc5d85f", - "Rev": "cc5d85f4f15bd2163abf0fe6e6753356dde72aa2" - }, - { - "ImportPath": "github.com/smartystreets/goconvey/convey/reporting", - "Comment": "1.6.1-20-gcc5d85f", - "Rev": "cc5d85f4f15bd2163abf0fe6e6753356dde72aa2" - }, { "ImportPath": "github.com/spf13/cobra", "Rev": "4c05eb1145f16d0e6bb4a3e1b6d769f4713cb41f" diff --git a/Godeps/_workspace/src/github.com/gopherjs/gopherjs/js/js.go b/Godeps/_workspace/src/github.com/gopherjs/gopherjs/js/js.go deleted file mode 100644 index 5367d3d0fa..0000000000 --- a/Godeps/_workspace/src/github.com/gopherjs/gopherjs/js/js.go +++ /dev/null @@ -1,168 +0,0 @@ -// Package js provides functions for interacting with native JavaScript APIs. Calls to these functions are treated specially by GopherJS and translated directly to their corresponding JavaScript syntax. -// -// Use MakeWrapper to expose methods to JavaScript. When passing values directly, the following type conversions are performed: -// -// | Go type | JavaScript type | Conversions back to interface{} | -// | --------------------- | --------------------- | ------------------------------- | -// | bool | Boolean | bool | -// | integers and floats | Number | float64 | -// | string | String | string | -// | []int8 | Int8Array | []int8 | -// | []int16 | Int16Array | []int16 | -// | []int32, []int | Int32Array | []int | -// | []uint8 | Uint8Array | []uint8 | -// | []uint16 | Uint16Array | []uint16 | -// | []uint32, []uint | Uint32Array | []uint | -// | []float32 | Float32Array | []float32 | -// | []float64 | Float64Array | []float64 | -// | all other slices | Array | []interface{} | -// | arrays | see slice type | see slice type | -// | functions | Function | func(...interface{}) *js.Object | -// | time.Time | Date | time.Time | -// | - | instanceof Node | *js.Object | -// | maps, structs | instanceof Object | map[string]interface{} | -// -// Additionally, for a struct containing a *js.Object field, only the content of the field will be passed to JavaScript and vice versa. -package js - -// Object is a container for a native JavaScript object. Calls to its methods are treated specially by GopherJS and translated directly to their JavaScript syntax. A nil pointer to Object is equal to JavaScript's "null". Object can not be used as a map key. -type Object struct{ object *Object } - -// Get returns the object's property with the given key. -func (o *Object) Get(key string) *Object { return o.object.Get(key) } - -// Set assigns the value to the object's property with the given key. -func (o *Object) Set(key string, value interface{}) { o.object.Set(key, value) } - -// Delete removes the object's property with the given key. -func (o *Object) Delete(key string) { o.object.Delete(key) } - -// Length returns the object's "length" property, converted to int. -func (o *Object) Length() int { return o.object.Length() } - -// Index returns the i'th element of an array. -func (o *Object) Index(i int) *Object { return o.object.Index(i) } - -// SetIndex sets the i'th element of an array. -func (o *Object) SetIndex(i int, value interface{}) { o.object.SetIndex(i, value) } - -// Call calls the object's method with the given name. -func (o *Object) Call(name string, args ...interface{}) *Object { return o.object.Call(name, args...) } - -// Invoke calls the object itself. This will fail if it is not a function. -func (o *Object) Invoke(args ...interface{}) *Object { return o.object.Invoke(args...) } - -// New creates a new instance of this type object. This will fail if it not a function (constructor). -func (o *Object) New(args ...interface{}) *Object { return o.object.New(args...) } - -// Bool returns the object converted to bool according to JavaScript type conversions. -func (o *Object) Bool() bool { return o.object.Bool() } - -// String returns the object converted to string according to JavaScript type conversions. -func (o *Object) String() string { return o.object.String() } - -// Int returns the object converted to int according to JavaScript type conversions (parseInt). -func (o *Object) Int() int { return o.object.Int() } - -// Int64 returns the object converted to int64 according to JavaScript type conversions (parseInt). -func (o *Object) Int64() int64 { return o.object.Int64() } - -// Uint64 returns the object converted to uint64 according to JavaScript type conversions (parseInt). -func (o *Object) Uint64() uint64 { return o.object.Uint64() } - -// Float returns the object converted to float64 according to JavaScript type conversions (parseFloat). -func (o *Object) Float() float64 { return o.object.Float() } - -// Interface returns the object converted to interface{}. See GopherJS' README for details. -func (o *Object) Interface() interface{} { return o.object.Interface() } - -// Unsafe returns the object as an uintptr, which can be converted via unsafe.Pointer. Not intended for public use. -func (o *Object) Unsafe() uintptr { return o.object.Unsafe() } - -// Error encapsulates JavaScript errors. Those are turned into a Go panic and may be recovered, giving an *Error that holds the JavaScript error object. -type Error struct { - *Object -} - -// Error returns the message of the encapsulated JavaScript error object. -func (err *Error) Error() string { - return "JavaScript error: " + err.Get("message").String() -} - -// Stack returns the stack property of the encapsulated JavaScript error object. -func (err *Error) Stack() string { - return err.Get("stack").String() -} - -// Global gives JavaScript's global object ("window" for browsers and "GLOBAL" for Node.js). -var Global *Object - -// Module gives the value of the "module" variable set by Node.js. Hint: Set a module export with 'js.Module.Get("exports").Set("exportName", ...)'. -var Module *Object - -// Undefined gives the JavaScript value "undefined". -var Undefined *Object - -// Debugger gets compiled to JavaScript's "debugger;" statement. -func Debugger() {} - -// InternalObject returns the internal JavaScript object that represents i. Not intended for public use. -func InternalObject(i interface{}) *Object { - return nil -} - -// MakeFunc wraps a function and gives access to the values of JavaScript's "this" and "arguments" keywords. -func MakeFunc(func(this *Object, arguments []*Object) interface{}) *Object { - return nil -} - -// Keys returns the keys of the given JavaScript object. -func Keys(o *Object) []string { - if o == nil || o == Undefined { - return nil - } - a := Global.Get("Object").Call("keys", o) - s := make([]string, a.Length()) - for i := 0; i < a.Length(); i++ { - s[i] = a.Index(i).String() - } - return s -} - -// MakeWrapper creates a JavaScript object which has wrappers for the exported methods of i. Use explicit getter and setter methods to expose struct fields to JavaScript. -func MakeWrapper(i interface{}) *Object { - v := InternalObject(i) - o := Global.Get("Object").New() - o.Set("__internal_object__", v) - methods := v.Get("constructor").Get("methods") - for i := 0; i < methods.Length(); i++ { - m := methods.Index(i) - if m.Get("pkg").String() != "" { // not exported - continue - } - o.Set(m.Get("name").String(), func(args ...*Object) *Object { - return Global.Call("$externalizeFunction", v.Get(m.Get("prop").String()), m.Get("typ"), true).Call("apply", v, args) - }) - } - return o -} - -// NewArrayBuffer creates a JavaScript ArrayBuffer from a byte slice. -func NewArrayBuffer(b []byte) *Object { - slice := InternalObject(b) - offset := slice.Get("$offset").Int() - length := slice.Get("$length").Int() - return slice.Get("$array").Get("buffer").Call("slice", offset, offset+length) -} - -// M is a simple map type. It is intended as a shorthand for JavaScript objects (before conversion). -type M map[string]interface{} - -// S is a simple slice type. It is intended as a shorthand for JavaScript arrays (before conversion). -type S []interface{} - -func init() { - // avoid dead code elimination - e := Error{} - _ = e -} diff --git a/Godeps/_workspace/src/github.com/jtolds/gls/LICENSE b/Godeps/_workspace/src/github.com/jtolds/gls/LICENSE deleted file mode 100644 index 9b4a822d92..0000000000 --- a/Godeps/_workspace/src/github.com/jtolds/gls/LICENSE +++ /dev/null @@ -1,18 +0,0 @@ -Copyright (c) 2013, Space Monkey, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Godeps/_workspace/src/github.com/jtolds/gls/README.md b/Godeps/_workspace/src/github.com/jtolds/gls/README.md deleted file mode 100644 index 4ebb692fb1..0000000000 --- a/Godeps/_workspace/src/github.com/jtolds/gls/README.md +++ /dev/null @@ -1,89 +0,0 @@ -gls -=== - -Goroutine local storage - -### IMPORTANT NOTE ### - -It is my duty to point you to https://blog.golang.org/context, which is how -Google solves all of the problems you'd perhaps consider using this package -for at scale. - -One downside to Google's approach is that *all* of your functions must have -a new first argument, but after clearing that hurdle everything else is much -better. - -If you aren't interested in this warning, read on. - -### Huhwaht? Why? ### - -Every so often, a thread shows up on the -[golang-nuts](https://groups.google.com/d/forum/golang-nuts) asking for some -form of goroutine-local-storage, or some kind of goroutine id, or some kind of -context. There are a few valid use cases for goroutine-local-storage, one of -the most prominent being log line context. One poster was interested in being -able to log an HTTP request context id in every log line in the same goroutine -as the incoming HTTP request, without having to change every library and -function call he was interested in logging. - -This would be pretty useful. Provided that you could get some kind of -goroutine-local-storage, you could call -[log.SetOutput](http://golang.org/pkg/log/#SetOutput) with your own logging -writer that checks goroutine-local-storage for some context information and -adds that context to your log lines. - -But alas, Andrew Gerrand's typically diplomatic answer to the question of -goroutine-local variables was: - -> We wouldn't even be having this discussion if thread local storage wasn't -> useful. But every feature comes at a cost, and in my opinion the cost of -> threadlocals far outweighs their benefits. They're just not a good fit for -> Go. - -So, yeah, that makes sense. That's a pretty good reason for why the language -won't support a specific and (relatively) unuseful feature that requires some -runtime changes, just for the sake of a little bit of log improvement. - -But does Go require runtime changes? - -### How it works ### - -Go has pretty fantastic introspective and reflective features, but one thing Go -doesn't give you is any kind of access to the stack pointer, or frame pointer, -or goroutine id, or anything contextual about your current stack. It gives you -access to your list of callers, but only along with program counters, which are -fixed at compile time. - -But it does give you the stack. - -So, we define 16 special functions and embed base-16 tags into the stack using -the call order of those 16 functions. Then, we can read our tags back out of -the stack looking at the callers list. - -We then use these tags as an index into a traditional map for implementing -this library. - -### What are people saying? ### - -"Wow, that's horrifying." - -"This is the most terrible thing I have seen in a very long time." - -"Where is it getting a context from? Is this serializing all the requests? -What the heck is the client being bound to? What are these tags? Why does he -need callers? Oh god no. No no no." - -### Docs ### - -Please see the docs at http://godoc.org/github.com/jtolds/gls - -### Related ### - -If you're okay relying on the string format of the current runtime stacktrace -including a unique goroutine id (not guaranteed by the spec or anything, but -very unlikely to change within a Go release), you might be able to squeeze -out a bit more performance by using this similar library, inspired by some -code Brad Fitzpatrick wrote for debugging his HTTP/2 library: -https://github.com/tylerb/gls (in contrast, jtolds/gls doesn't require -any knowledge of the string format of the runtime stacktrace, which -probably adds unnecessary overhead). diff --git a/Godeps/_workspace/src/github.com/jtolds/gls/context.go b/Godeps/_workspace/src/github.com/jtolds/gls/context.go deleted file mode 100644 index 90cfcf7db1..0000000000 --- a/Godeps/_workspace/src/github.com/jtolds/gls/context.go +++ /dev/null @@ -1,144 +0,0 @@ -// Package gls implements goroutine-local storage. -package gls - -import ( - "sync" -) - -const ( - maxCallers = 64 -) - -var ( - stackTagPool = &idPool{} - mgrRegistry = make(map[*ContextManager]bool) - mgrRegistryMtx sync.RWMutex -) - -// Values is simply a map of key types to value types. Used by SetValues to -// set multiple values at once. -type Values map[interface{}]interface{} - -// ContextManager is the main entrypoint for interacting with -// Goroutine-local-storage. You can have multiple independent ContextManagers -// at any given time. ContextManagers are usually declared globally for a given -// class of context variables. You should use NewContextManager for -// construction. -type ContextManager struct { - mtx sync.RWMutex - values map[uint]Values -} - -// NewContextManager returns a brand new ContextManager. It also registers the -// new ContextManager in the ContextManager registry which is used by the Go -// method. ContextManagers are typically defined globally at package scope. -func NewContextManager() *ContextManager { - mgr := &ContextManager{values: make(map[uint]Values)} - mgrRegistryMtx.Lock() - defer mgrRegistryMtx.Unlock() - mgrRegistry[mgr] = true - return mgr -} - -// Unregister removes a ContextManager from the global registry, used by the -// Go method. Only intended for use when you're completely done with a -// ContextManager. Use of Unregister at all is rare. -func (m *ContextManager) Unregister() { - mgrRegistryMtx.Lock() - defer mgrRegistryMtx.Unlock() - delete(mgrRegistry, m) -} - -// SetValues takes a collection of values and a function to call for those -// values to be set in. Anything further down the stack will have the set -// values available through GetValue. SetValues will add new values or replace -// existing values of the same key and will not mutate or change values for -// previous stack frames. -// SetValues is slow (makes a copy of all current and new values for the new -// gls-context) in order to reduce the amount of lookups GetValue requires. -func (m *ContextManager) SetValues(new_values Values, context_call func()) { - if len(new_values) == 0 { - context_call() - return - } - - tags := readStackTags(1) - - m.mtx.Lock() - values := new_values - for _, tag := range tags { - if existing_values, ok := m.values[tag]; ok { - // oh, we found existing values, let's make a copy - values = make(Values, len(existing_values)+len(new_values)) - for key, val := range existing_values { - values[key] = val - } - for key, val := range new_values { - values[key] = val - } - break - } - } - new_tag := stackTagPool.Acquire() - m.values[new_tag] = values - m.mtx.Unlock() - defer func() { - m.mtx.Lock() - delete(m.values, new_tag) - m.mtx.Unlock() - stackTagPool.Release(new_tag) - }() - - addStackTag(new_tag, context_call) -} - -// GetValue will return a previously set value, provided that the value was set -// by SetValues somewhere higher up the stack. If the value is not found, ok -// will be false. -func (m *ContextManager) GetValue(key interface{}) (value interface{}, ok bool) { - - tags := readStackTags(1) - m.mtx.RLock() - defer m.mtx.RUnlock() - for _, tag := range tags { - if values, ok := m.values[tag]; ok { - value, ok := values[key] - return value, ok - } - } - return "", false -} - -func (m *ContextManager) getValues() Values { - tags := readStackTags(2) - m.mtx.RLock() - defer m.mtx.RUnlock() - for _, tag := range tags { - if values, ok := m.values[tag]; ok { - return values - } - } - return nil -} - -// Go preserves ContextManager values and Goroutine-local-storage across new -// goroutine invocations. The Go method makes a copy of all existing values on -// all registered context managers and makes sure they are still set after -// kicking off the provided function in a new goroutine. If you don't use this -// Go method instead of the standard 'go' keyword, you will lose values in -// ContextManagers, as goroutines have brand new stacks. -func Go(cb func()) { - mgrRegistryMtx.RLock() - defer mgrRegistryMtx.RUnlock() - - for mgr, _ := range mgrRegistry { - values := mgr.getValues() - if len(values) > 0 { - mgr_copy := mgr - cb_copy := cb - cb = func() { mgr_copy.SetValues(values, cb_copy) } - } - } - - go cb() -} diff --git a/Godeps/_workspace/src/github.com/jtolds/gls/gen_sym.go b/Godeps/_workspace/src/github.com/jtolds/gls/gen_sym.go deleted file mode 100644 index 8d5fc24d4a..0000000000 --- a/Godeps/_workspace/src/github.com/jtolds/gls/gen_sym.go +++ /dev/null @@ -1,13 +0,0 @@ -package gls - -var ( - symPool = &idPool{} -) - -// ContextKey is a throwaway value you can use as a key to a ContextManager -type ContextKey struct{ id uint } - -// GenSym will return a brand new, never-before-used ContextKey -func GenSym() ContextKey { - return ContextKey{id: symPool.Acquire()} -} diff --git a/Godeps/_workspace/src/github.com/jtolds/gls/id_pool.go b/Godeps/_workspace/src/github.com/jtolds/gls/id_pool.go deleted file mode 100644 index b7974ae002..0000000000 --- a/Godeps/_workspace/src/github.com/jtolds/gls/id_pool.go +++ /dev/null @@ -1,34 +0,0 @@ -package gls - -// though this could probably be better at keeping ids smaller, the goal of -// this class is to keep a registry of the smallest unique integer ids -// per-process possible - -import ( - "sync" -) - -type idPool struct { - mtx sync.Mutex - released []uint - max_id uint -} - -func (p *idPool) Acquire() (id uint) { - p.mtx.Lock() - defer p.mtx.Unlock() - if len(p.released) > 0 { - id = p.released[len(p.released)-1] - p.released = p.released[:len(p.released)-1] - return id - } - id = p.max_id - p.max_id++ - return id -} - -func (p *idPool) Release(id uint) { - p.mtx.Lock() - defer p.mtx.Unlock() - p.released = append(p.released, id) -} diff --git a/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags.go b/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags.go deleted file mode 100644 index 9b8e39ba7c..0000000000 --- a/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags.go +++ /dev/null @@ -1,43 +0,0 @@ -package gls - -// so, basically, we're going to encode integer tags in base-16 on the stack - -const ( - bitWidth = 4 -) - -func addStackTag(tag uint, context_call func()) { - if context_call == nil { - return - } - markS(tag, context_call) -} - -func markS(tag uint, cb func()) { _m(tag, cb) } -func mark0(tag uint, cb func()) { _m(tag, cb) } -func mark1(tag uint, cb func()) { _m(tag, cb) } -func mark2(tag uint, cb func()) { _m(tag, cb) } -func mark3(tag uint, cb func()) { _m(tag, cb) } -func mark4(tag uint, cb func()) { _m(tag, cb) } -func mark5(tag uint, cb func()) { _m(tag, cb) } -func mark6(tag uint, cb func()) { _m(tag, cb) } -func mark7(tag uint, cb func()) { _m(tag, cb) } -func mark8(tag uint, cb func()) { _m(tag, cb) } -func mark9(tag uint, cb func()) { _m(tag, cb) } -func markA(tag uint, cb func()) { _m(tag, cb) } -func markB(tag uint, cb func()) { _m(tag, cb) } -func markC(tag uint, cb func()) { _m(tag, cb) } -func markD(tag uint, cb func()) { _m(tag, cb) } -func markE(tag uint, cb func()) { _m(tag, cb) } -func markF(tag uint, cb func()) { _m(tag, cb) } - -var pc_lookup = make(map[uintptr]int8, 17) -var mark_lookup [16]func(uint, func()) - -func _m(tag_remainder uint, cb func()) { - if tag_remainder == 0 { - cb() - } else { - mark_lookup[tag_remainder&0xf](tag_remainder>>bitWidth, cb) - } -} diff --git a/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags_js.go b/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags_js.go deleted file mode 100644 index 21d5595926..0000000000 --- a/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags_js.go +++ /dev/null @@ -1,101 +0,0 @@ -// +build js - -package gls - -// This file is used for GopherJS builds, which don't have normal runtime support - -import ( - "regexp" - "strconv" - "strings" - - "github.com/gopherjs/gopherjs/js" -) - -var stackRE = regexp.MustCompile("\\s+at (\\S*) \\([^:]+:(\\d+):(\\d+)") - -func findPtr() uintptr { - jsStack := js.Global.Get("Error").New().Get("stack").Call("split", "\n") - for i := 1; i < jsStack.Get("length").Int(); i++ { - item := jsStack.Index(i).String() - matches := stackRE.FindAllStringSubmatch(item, -1) - if matches == nil { - return 0 - } - pkgPath := matches[0][1] - if strings.HasPrefix(pkgPath, "$packages.github.com/jtolds/gls.mark") { - line, _ := strconv.Atoi(matches[0][2]) - char, _ := strconv.Atoi(matches[0][3]) - x := (uintptr(line) << 16) | uintptr(char) - return x - } - } - - return 0 -} - -func init() { - setEntries := func(f func(uint, func()), v int8) { - var ptr uintptr - f(0, func() { - ptr = findPtr() - }) - pc_lookup[ptr] = v - if v >= 0 { - mark_lookup[v] = f - } - } - setEntries(markS, -0x1) - setEntries(mark0, 0x0) - setEntries(mark1, 0x1) - setEntries(mark2, 0x2) - setEntries(mark3, 0x3) - setEntries(mark4, 0x4) - setEntries(mark5, 0x5) - setEntries(mark6, 0x6) - setEntries(mark7, 0x7) - setEntries(mark8, 0x8) - setEntries(mark9, 0x9) - setEntries(markA, 0xa) - setEntries(markB, 0xb) - setEntries(markC, 0xc) - setEntries(markD, 0xd) - setEntries(markE, 0xe) - setEntries(markF, 0xf) -} - -func currentStack(skip int) (stack []uintptr) { - jsStack := js.Global.Get("Error").New().Get("stack").Call("split", "\n") - for i := skip + 2; i < jsStack.Get("length").Int(); i++ { - item := jsStack.Index(i).String() - matches := stackRE.FindAllStringSubmatch(item, -1) - if matches == nil { - return stack - } - line, _ := strconv.Atoi(matches[0][2]) - char, _ := strconv.Atoi(matches[0][3]) - x := (uintptr(line) << 16) | uintptr(char)&0xffff - stack = append(stack, x) - } - - return stack -} - -func readStackTags(skip int) (tags []uint) { - stack := currentStack(skip) - var current_tag uint - for _, pc := range stack { - val, ok := pc_lookup[pc] - if !ok { - continue - } - if val < 0 { - tags = append(tags, current_tag) - current_tag = 0 - continue - } - current_tag <<= bitWidth - current_tag += uint(val) - } - return -} diff --git a/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags_main.go b/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags_main.go deleted file mode 100644 index cb302b9ef6..0000000000 --- a/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags_main.go +++ /dev/null @@ -1,61 +0,0 @@ -// +build !js - -package gls - -// This file is used for standard Go builds, which have the expected runtime support - -import ( - "reflect" - "runtime" -) - -func init() { - setEntries := func(f func(uint, func()), v int8) { - pc_lookup[reflect.ValueOf(f).Pointer()] = v - if v >= 0 { - mark_lookup[v] = f - } - } - setEntries(markS, -0x1) - setEntries(mark0, 0x0) - setEntries(mark1, 0x1) - setEntries(mark2, 0x2) - setEntries(mark3, 0x3) - setEntries(mark4, 0x4) - setEntries(mark5, 0x5) - setEntries(mark6, 0x6) - setEntries(mark7, 0x7) - setEntries(mark8, 0x8) - setEntries(mark9, 0x9) - setEntries(markA, 0xa) - setEntries(markB, 0xb) - setEntries(markC, 0xc) - setEntries(markD, 0xd) - setEntries(markE, 0xe) - setEntries(markF, 0xf) -} - -func currentStack(skip int) []uintptr { - stack := make([]uintptr, maxCallers) - return stack[:runtime.Callers(3+skip, stack)] -} - -func readStackTags(skip int) (tags []uint) { - stack := currentStack(skip) - var current_tag uint - for _, pc := range stack { - pc = runtime.FuncForPC(pc).Entry() - val, ok := pc_lookup[pc] - if !ok { - continue - } - if val < 0 { - tags = append(tags, current_tag) - current_tag = 0 - continue - } - current_tag <<= bitWidth - current_tag += uint(val) - } - return -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/.gitignore b/Godeps/_workspace/src/github.com/smartystreets/assertions/.gitignore deleted file mode 100644 index 6ad551742d..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.DS_Store -Thumbs.db -/.idea diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/.travis.yml b/Godeps/_workspace/src/github.com/smartystreets/assertions/.travis.yml deleted file mode 100644 index 44217c9733..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: go - -go: - - 1.2 - - 1.3 - - 1.4 - - 1.5 - -install: - - go get -t ./... - -script: go test -v - -sudo: false diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/CONTRIBUTING.md b/Godeps/_workspace/src/github.com/smartystreets/assertions/CONTRIBUTING.md deleted file mode 100644 index 1820ecb331..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/CONTRIBUTING.md +++ /dev/null @@ -1,12 +0,0 @@ -# Contributing - -In general, the code posted to the [SmartyStreets github organization](https://github.com/smartystreets) is created to solve specific problems at SmartyStreets that are ancillary to our core products in the address verification industry and may or may not be useful to other organizations or developers. Our reason for posting said code isn't necessarily to solicit feedback or contributions from the community but more as a showcase of some of the approaches to solving problems we have adopted. - -Having stated that, we do consider issues raised by other githubbers as well as contributions submitted via pull requests. When submitting such a pull request, please follow these guidelines: - -- _Look before you leap:_ If the changes you plan to make are significant, it's in everyone's best interest for you to discuss them with a SmartyStreets team member prior to opening a pull request. -- _License and ownership:_ If modifying the `LICENSE.md` file, limit your changes to fixing typographical mistakes. Do NOT modify the actual terms in the license or the copyright by **SmartyStreets, LLC**. Code submitted to SmartyStreets projects becomes property of SmartyStreets and must be compatible with the associated license. -- _Testing:_ If the code you are submitting resides in packages/modules covered by automated tests, be sure to add passing tests that cover your changes and assert expected behavior and state. Submit the additional test cases as part of your change set. -- _Style:_ Match your approach to **naming** and **formatting** with the surrounding code. Basically, the code you submit shouldn't stand out. - - "Naming" refers to such constructs as variables, methods, functions, classes, structs, interfaces, packages, modules, directories, files, etc... - - "Formatting" refers to such constructs as whitespace, horizontal line length, vertical function length, vertical file length, indentation, curly braces, etc... diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/LICENSE.md b/Godeps/_workspace/src/github.com/smartystreets/assertions/LICENSE.md deleted file mode 100644 index 8ea6f94552..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/LICENSE.md +++ /dev/null @@ -1,23 +0,0 @@ -Copyright (c) 2016 SmartyStreets, LLC - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -NOTE: Various optional and subordinate components carry their own licensing -requirements and restrictions. Use of those components is subject to the terms -and conditions outlined the respective license of each component. diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/README.md b/Godeps/_workspace/src/github.com/smartystreets/assertions/README.md deleted file mode 100644 index 58383bb00a..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/README.md +++ /dev/null @@ -1,575 +0,0 @@ -# assertions --- - import "github.com/smartystreets/assertions" - -Package assertions contains the implementations for all assertions which are -referenced in goconvey's `convey` package -(github.com/smartystreets/goconvey/convey) and gunit -(github.com/smartystreets/gunit) for use with the So(...) method. They can also -be used in traditional Go test functions and even in applications. - -Many of the assertions lean heavily on work done by Aaron Jacobs in his -excellent oglematchers library. (https://github.com/jacobsa/oglematchers) The -ShouldResemble assertion leans heavily on work done by Daniel Jacques in his -very helpful go-render library. (https://github.com/luci/go-render) - -## Usage - -#### func GoConveyMode - -```go -func GoConveyMode(yes bool) -``` -GoConveyMode provides control over JSON serialization of failures. When using -the assertions in this package from the convey package JSON results are very -helpful and can be rendered in a DIFF view. In that case, this function will be -called with a true value to enable the JSON serialization. By default, the -assertions in this package will not serializer a JSON result, making standalone -ussage more convenient. - -#### func ShouldAlmostEqual - -```go -func ShouldAlmostEqual(actual interface{}, expected ...interface{}) string -``` -ShouldAlmostEqual makes sure that two parameters are close enough to being -equal. The acceptable delta may be specified with a third argument, or a very -small default delta will be used. - -#### func ShouldBeBetween - -```go -func ShouldBeBetween(actual interface{}, expected ...interface{}) string -``` -ShouldBeBetween receives exactly three parameters: an actual value, a lower -bound, and an upper bound. It ensures that the actual value is between both -bounds (but not equal to either of them). - -#### func ShouldBeBetweenOrEqual - -```go -func ShouldBeBetweenOrEqual(actual interface{}, expected ...interface{}) string -``` -ShouldBeBetweenOrEqual receives exactly three parameters: an actual value, a -lower bound, and an upper bound. It ensures that the actual value is between -both bounds or equal to one of them. - -#### func ShouldBeBlank - -```go -func ShouldBeBlank(actual interface{}, expected ...interface{}) string -``` -ShouldBeBlank receives exactly 1 string parameter and ensures that it is equal -to "". - -#### func ShouldBeChronological - -```go -func ShouldBeChronological(actual interface{}, expected ...interface{}) string -``` -ShouldBeChronological receives a []time.Time slice and asserts that the are in -chronological order starting with the first time.Time as the earliest. - -#### func ShouldBeEmpty - -```go -func ShouldBeEmpty(actual interface{}, expected ...interface{}) string -``` -ShouldBeEmpty receives a single parameter (actual) and determines whether or not -calling len(actual) would return `0`. It obeys the rules specified by the len -function for determining length: http://golang.org/pkg/builtin/#len - -#### func ShouldBeFalse - -```go -func ShouldBeFalse(actual interface{}, expected ...interface{}) string -``` -ShouldBeFalse receives a single parameter and ensures that it is false. - -#### func ShouldBeGreaterThan - -```go -func ShouldBeGreaterThan(actual interface{}, expected ...interface{}) string -``` -ShouldBeGreaterThan receives exactly two parameters and ensures that the first -is greater than the second. - -#### func ShouldBeGreaterThanOrEqualTo - -```go -func ShouldBeGreaterThanOrEqualTo(actual interface{}, expected ...interface{}) string -``` -ShouldBeGreaterThanOrEqualTo receives exactly two parameters and ensures that -the first is greater than or equal to the second. - -#### func ShouldBeIn - -```go -func ShouldBeIn(actual interface{}, expected ...interface{}) string -``` -ShouldBeIn receives at least 2 parameters. The first is a proposed member of the -collection that is passed in either as the second parameter, or of the -collection that is comprised of all the remaining parameters. This assertion -ensures that the proposed member is in the collection (using ShouldEqual). - -#### func ShouldBeLessThan - -```go -func ShouldBeLessThan(actual interface{}, expected ...interface{}) string -``` -ShouldBeLessThan receives exactly two parameters and ensures that the first is -less than the second. - -#### func ShouldBeLessThanOrEqualTo - -```go -func ShouldBeLessThanOrEqualTo(actual interface{}, expected ...interface{}) string -``` -ShouldBeLessThan receives exactly two parameters and ensures that the first is -less than or equal to the second. - -#### func ShouldBeNil - -```go -func ShouldBeNil(actual interface{}, expected ...interface{}) string -``` -ShouldBeNil receives a single parameter and ensures that it is nil. - -#### func ShouldBeTrue - -```go -func ShouldBeTrue(actual interface{}, expected ...interface{}) string -``` -ShouldBeTrue receives a single parameter and ensures that it is true. - -#### func ShouldBeZeroValue - -```go -func ShouldBeZeroValue(actual interface{}, expected ...interface{}) string -``` -ShouldBeZeroValue receives a single parameter and ensures that it is the Go -equivalent of the default value, or "zero" value. - -#### func ShouldContain - -```go -func ShouldContain(actual interface{}, expected ...interface{}) string -``` -ShouldContain receives exactly two parameters. The first is a slice and the -second is a proposed member. Membership is determined using ShouldEqual. - -#### func ShouldContainKey - -```go -func ShouldContainKey(actual interface{}, expected ...interface{}) string -``` -ShouldContainKey receives exactly two parameters. The first is a map and the -second is a proposed key. Keys are compared with a simple '=='. - -#### func ShouldContainSubstring - -```go -func ShouldContainSubstring(actual interface{}, expected ...interface{}) string -``` -ShouldContainSubstring receives exactly 2 string parameters and ensures that the -first contains the second as a substring. - -#### func ShouldEndWith - -```go -func ShouldEndWith(actual interface{}, expected ...interface{}) string -``` -ShouldEndWith receives exactly 2 string parameters and ensures that the first -ends with the second. - -#### func ShouldEqual - -```go -func ShouldEqual(actual interface{}, expected ...interface{}) string -``` -ShouldEqual receives exactly two parameters and does an equality check. - -#### func ShouldEqualTrimSpace - -```go -func ShouldEqualTrimSpace(actual interface{}, expected ...interface{}) string -``` -ShouldEqualTrimSpace receives exactly 2 string parameters and ensures that the -first is equal to the second after removing all leading and trailing whitespace -using strings.TrimSpace(first). - -#### func ShouldEqualWithout - -```go -func ShouldEqualWithout(actual interface{}, expected ...interface{}) string -``` -ShouldEqualWithout receives exactly 3 string parameters and ensures that the -first is equal to the second after removing all instances of the third from the -first using strings.Replace(first, third, "", -1). - -#### func ShouldHappenAfter - -```go -func ShouldHappenAfter(actual interface{}, expected ...interface{}) string -``` -ShouldHappenAfter receives exactly 2 time.Time arguments and asserts that the -first happens after the second. - -#### func ShouldHappenBefore - -```go -func ShouldHappenBefore(actual interface{}, expected ...interface{}) string -``` -ShouldHappenBefore receives exactly 2 time.Time arguments and asserts that the -first happens before the second. - -#### func ShouldHappenBetween - -```go -func ShouldHappenBetween(actual interface{}, expected ...interface{}) string -``` -ShouldHappenBetween receives exactly 3 time.Time arguments and asserts that the -first happens between (not on) the second and third. - -#### func ShouldHappenOnOrAfter - -```go -func ShouldHappenOnOrAfter(actual interface{}, expected ...interface{}) string -``` -ShouldHappenOnOrAfter receives exactly 2 time.Time arguments and asserts that -the first happens on or after the second. - -#### func ShouldHappenOnOrBefore - -```go -func ShouldHappenOnOrBefore(actual interface{}, expected ...interface{}) string -``` -ShouldHappenOnOrBefore receives exactly 2 time.Time arguments and asserts that -the first happens on or before the second. - -#### func ShouldHappenOnOrBetween - -```go -func ShouldHappenOnOrBetween(actual interface{}, expected ...interface{}) string -``` -ShouldHappenOnOrBetween receives exactly 3 time.Time arguments and asserts that -the first happens between or on the second and third. - -#### func ShouldHappenWithin - -```go -func ShouldHappenWithin(actual interface{}, expected ...interface{}) string -``` -ShouldHappenWithin receives a time.Time, a time.Duration, and a time.Time (3 -arguments) and asserts that the first time.Time happens within or on the -duration specified relative to the other time.Time. - -#### func ShouldHaveLength - -```go -func ShouldHaveLength(actual interface{}, expected ...interface{}) string -``` -ShouldHaveLength receives 2 parameters. The first is a collection to check the -length of, the second being the expected length. It obeys the rules specified by -the len function for determining length: http://golang.org/pkg/builtin/#len - -#### func ShouldHaveSameTypeAs - -```go -func ShouldHaveSameTypeAs(actual interface{}, expected ...interface{}) string -``` -ShouldHaveSameTypeAs receives exactly two parameters and compares their -underlying types for equality. - -#### func ShouldImplement - -```go -func ShouldImplement(actual interface{}, expectedList ...interface{}) string -``` -ShouldImplement receives exactly two parameters and ensures that the first -implements the interface type of the second. - -#### func ShouldNotAlmostEqual - -```go -func ShouldNotAlmostEqual(actual interface{}, expected ...interface{}) string -``` -ShouldNotAlmostEqual is the inverse of ShouldAlmostEqual - -#### func ShouldNotBeBetween - -```go -func ShouldNotBeBetween(actual interface{}, expected ...interface{}) string -``` -ShouldNotBeBetween receives exactly three parameters: an actual value, a lower -bound, and an upper bound. It ensures that the actual value is NOT between both -bounds. - -#### func ShouldNotBeBetweenOrEqual - -```go -func ShouldNotBeBetweenOrEqual(actual interface{}, expected ...interface{}) string -``` -ShouldNotBeBetweenOrEqual receives exactly three parameters: an actual value, a -lower bound, and an upper bound. It ensures that the actual value is nopt -between the bounds nor equal to either of them. - -#### func ShouldNotBeBlank - -```go -func ShouldNotBeBlank(actual interface{}, expected ...interface{}) string -``` -ShouldNotBeBlank receives exactly 1 string parameter and ensures that it is -equal to "". - -#### func ShouldNotBeEmpty - -```go -func ShouldNotBeEmpty(actual interface{}, expected ...interface{}) string -``` -ShouldNotBeEmpty receives a single parameter (actual) and determines whether or -not calling len(actual) would return a value greater than zero. It obeys the -rules specified by the `len` function for determining length: -http://golang.org/pkg/builtin/#len - -#### func ShouldNotBeIn - -```go -func ShouldNotBeIn(actual interface{}, expected ...interface{}) string -``` -ShouldNotBeIn receives at least 2 parameters. The first is a proposed member of -the collection that is passed in either as the second parameter, or of the -collection that is comprised of all the remaining parameters. This assertion -ensures that the proposed member is NOT in the collection (using ShouldEqual). - -#### func ShouldNotBeNil - -```go -func ShouldNotBeNil(actual interface{}, expected ...interface{}) string -``` -ShouldNotBeNil receives a single parameter and ensures that it is not nil. - -#### func ShouldNotContain - -```go -func ShouldNotContain(actual interface{}, expected ...interface{}) string -``` -ShouldNotContain receives exactly two parameters. The first is a slice and the -second is a proposed member. Membership is determinied using ShouldEqual. - -#### func ShouldNotContainKey - -```go -func ShouldNotContainKey(actual interface{}, expected ...interface{}) string -``` -ShouldNotContainKey receives exactly two parameters. The first is a map and the -second is a proposed absent key. Keys are compared with a simple '=='. - -#### func ShouldNotContainSubstring - -```go -func ShouldNotContainSubstring(actual interface{}, expected ...interface{}) string -``` -ShouldNotContainSubstring receives exactly 2 string parameters and ensures that -the first does NOT contain the second as a substring. - -#### func ShouldNotEndWith - -```go -func ShouldNotEndWith(actual interface{}, expected ...interface{}) string -``` -ShouldEndWith receives exactly 2 string parameters and ensures that the first -does not end with the second. - -#### func ShouldNotEqual - -```go -func ShouldNotEqual(actual interface{}, expected ...interface{}) string -``` -ShouldNotEqual receives exactly two parameters and does an inequality check. - -#### func ShouldNotHappenOnOrBetween - -```go -func ShouldNotHappenOnOrBetween(actual interface{}, expected ...interface{}) string -``` -ShouldNotHappenOnOrBetween receives exactly 3 time.Time arguments and asserts -that the first does NOT happen between or on the second or third. - -#### func ShouldNotHappenWithin - -```go -func ShouldNotHappenWithin(actual interface{}, expected ...interface{}) string -``` -ShouldNotHappenWithin receives a time.Time, a time.Duration, and a time.Time (3 -arguments) and asserts that the first time.Time does NOT happen within or on the -duration specified relative to the other time.Time. - -#### func ShouldNotHaveSameTypeAs - -```go -func ShouldNotHaveSameTypeAs(actual interface{}, expected ...interface{}) string -``` -ShouldNotHaveSameTypeAs receives exactly two parameters and compares their -underlying types for inequality. - -#### func ShouldNotImplement - -```go -func ShouldNotImplement(actual interface{}, expectedList ...interface{}) string -``` -ShouldNotImplement receives exactly two parameters and ensures that the first -does NOT implement the interface type of the second. - -#### func ShouldNotPanic - -```go -func ShouldNotPanic(actual interface{}, expected ...interface{}) (message string) -``` -ShouldNotPanic receives a void, niladic function and expects to execute the -function without any panic. - -#### func ShouldNotPanicWith - -```go -func ShouldNotPanicWith(actual interface{}, expected ...interface{}) (message string) -``` -ShouldNotPanicWith receives a void, niladic function and expects to recover a -panic whose content differs from the second argument. - -#### func ShouldNotPointTo - -```go -func ShouldNotPointTo(actual interface{}, expected ...interface{}) string -``` -ShouldNotPointTo receives exactly two parameters and checks to see that they -point to different addresess. - -#### func ShouldNotResemble - -```go -func ShouldNotResemble(actual interface{}, expected ...interface{}) string -``` -ShouldNotResemble receives exactly two parameters and does an inverse deep equal -check (see reflect.DeepEqual) - -#### func ShouldNotStartWith - -```go -func ShouldNotStartWith(actual interface{}, expected ...interface{}) string -``` -ShouldNotStartWith receives exactly 2 string parameters and ensures that the -first does not start with the second. - -#### func ShouldPanic - -```go -func ShouldPanic(actual interface{}, expected ...interface{}) (message string) -``` -ShouldPanic receives a void, niladic function and expects to recover a panic. - -#### func ShouldPanicWith - -```go -func ShouldPanicWith(actual interface{}, expected ...interface{}) (message string) -``` -ShouldPanicWith receives a void, niladic function and expects to recover a panic -with the second argument as the content. - -#### func ShouldPointTo - -```go -func ShouldPointTo(actual interface{}, expected ...interface{}) string -``` -ShouldPointTo receives exactly two parameters and checks to see that they point -to the same address. - -#### func ShouldResemble - -```go -func ShouldResemble(actual interface{}, expected ...interface{}) string -``` -ShouldResemble receives exactly two parameters and does a deep equal check (see -reflect.DeepEqual) - -#### func ShouldStartWith - -```go -func ShouldStartWith(actual interface{}, expected ...interface{}) string -``` -ShouldStartWith receives exactly 2 string parameters and ensures that the first -starts with the second. - -#### func So - -```go -func So(actual interface{}, assert assertion, expected ...interface{}) (bool, string) -``` -So is a convenience function (as opposed to an inconvenience function?) for -running assertions on arbitrary arguments in any context, be it for testing or -even application logging. It allows you to perform assertion-like behavior (and -get nicely formatted messages detailing discrepancies) but without the program -blowing up or panicking. All that is required is to import this package and call -`So` with one of the assertions exported by this package as the second -parameter. The first return parameter is a boolean indicating if the assertion -was true. The second return parameter is the well-formatted message showing why -an assertion was incorrect, or blank if the assertion was correct. - -Example: - - if ok, message := So(x, ShouldBeGreaterThan, y); !ok { - log.Println(message) - } - -#### type Assertion - -```go -type Assertion struct { -} -``` - - -#### func New - -```go -func New(t testingT) *Assertion -``` -New swallows the *testing.T struct and prints failed assertions using t.Error. -Example: assertions.New(t).So(1, should.Equal, 1) - -#### func (*Assertion) Failed - -```go -func (this *Assertion) Failed() bool -``` -Failed reports whether any calls to So (on this Assertion instance) have failed. - -#### func (*Assertion) So - -```go -func (this *Assertion) So(actual interface{}, assert assertion, expected ...interface{}) bool -``` -So calls the standalone So function and additionally, calls t.Error in failure -scenarios. - -#### type FailureView - -```go -type FailureView struct { - Message string `json:"Message"` - Expected string `json:"Expected"` - Actual string `json:"Actual"` -} -``` - -This struct is also declared in -github.com/smartystreets/goconvey/convey/reporting. The json struct tags should -be equal in both declarations. - -#### type Serializer - -```go -type Serializer interface { - // contains filtered or unexported methods -} -``` diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/assertions.goconvey b/Godeps/_workspace/src/github.com/smartystreets/assertions/assertions.goconvey deleted file mode 100644 index e76cf275d4..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/assertions.goconvey +++ /dev/null @@ -1,3 +0,0 @@ -#ignore --timeout=1s --coverpkg=github.com/smartystreets/assertions,github.com/smartystreets/assertions/internal/oglematchers \ No newline at end of file diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/collections.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/collections.go deleted file mode 100644 index d7f407e913..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/collections.go +++ /dev/null @@ -1,244 +0,0 @@ -package assertions - -import ( - "fmt" - "reflect" - - "github.com/smartystreets/assertions/internal/oglematchers" -) - -// ShouldContain receives exactly two parameters. The first is a slice and the -// second is a proposed member. Membership is determined using ShouldEqual. -func ShouldContain(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - if matchError := oglematchers.Contains(expected[0]).Matches(actual); matchError != nil { - typeName := reflect.TypeOf(actual) - - if fmt.Sprintf("%v", matchError) == "which is not a slice or array" { - return fmt.Sprintf(shouldHaveBeenAValidCollection, typeName) - } - return fmt.Sprintf(shouldHaveContained, typeName, expected[0]) - } - return success -} - -// ShouldNotContain receives exactly two parameters. The first is a slice and the -// second is a proposed member. Membership is determinied using ShouldEqual. -func ShouldNotContain(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - typeName := reflect.TypeOf(actual) - - if matchError := oglematchers.Contains(expected[0]).Matches(actual); matchError != nil { - if fmt.Sprintf("%v", matchError) == "which is not a slice or array" { - return fmt.Sprintf(shouldHaveBeenAValidCollection, typeName) - } - return success - } - return fmt.Sprintf(shouldNotHaveContained, typeName, expected[0]) -} - -// ShouldContainKey receives exactly two parameters. The first is a map and the -// second is a proposed key. Keys are compared with a simple '=='. -func ShouldContainKey(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - keys, isMap := mapKeys(actual) - if !isMap { - return fmt.Sprintf(shouldHaveBeenAValidMap, reflect.TypeOf(actual)) - } - - if !keyFound(keys, expected[0]) { - return fmt.Sprintf(shouldHaveContainedKey, reflect.TypeOf(actual), expected) - } - - return "" -} - -// ShouldNotContainKey receives exactly two parameters. The first is a map and the -// second is a proposed absent key. Keys are compared with a simple '=='. -func ShouldNotContainKey(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - keys, isMap := mapKeys(actual) - if !isMap { - return fmt.Sprintf(shouldHaveBeenAValidMap, reflect.TypeOf(actual)) - } - - if keyFound(keys, expected[0]) { - return fmt.Sprintf(shouldNotHaveContainedKey, reflect.TypeOf(actual), expected) - } - - return "" -} - -func mapKeys(m interface{}) ([]reflect.Value, bool) { - value := reflect.ValueOf(m) - if value.Kind() != reflect.Map { - return nil, false - } - return value.MapKeys(), true -} -func keyFound(keys []reflect.Value, expectedKey interface{}) bool { - found := false - for _, key := range keys { - if key.Interface() == expectedKey { - found = true - } - } - return found -} - -// ShouldBeIn receives at least 2 parameters. The first is a proposed member of the collection -// that is passed in either as the second parameter, or of the collection that is comprised -// of all the remaining parameters. This assertion ensures that the proposed member is in -// the collection (using ShouldEqual). -func ShouldBeIn(actual interface{}, expected ...interface{}) string { - if fail := atLeast(1, expected); fail != success { - return fail - } - - if len(expected) == 1 { - return shouldBeIn(actual, expected[0]) - } - return shouldBeIn(actual, expected) -} -func shouldBeIn(actual interface{}, expected interface{}) string { - if matchError := oglematchers.Contains(actual).Matches(expected); matchError != nil { - return fmt.Sprintf(shouldHaveBeenIn, actual, reflect.TypeOf(expected)) - } - return success -} - -// ShouldNotBeIn receives at least 2 parameters. The first is a proposed member of the collection -// that is passed in either as the second parameter, or of the collection that is comprised -// of all the remaining parameters. This assertion ensures that the proposed member is NOT in -// the collection (using ShouldEqual). -func ShouldNotBeIn(actual interface{}, expected ...interface{}) string { - if fail := atLeast(1, expected); fail != success { - return fail - } - - if len(expected) == 1 { - return shouldNotBeIn(actual, expected[0]) - } - return shouldNotBeIn(actual, expected) -} -func shouldNotBeIn(actual interface{}, expected interface{}) string { - if matchError := oglematchers.Contains(actual).Matches(expected); matchError == nil { - return fmt.Sprintf(shouldNotHaveBeenIn, actual, reflect.TypeOf(expected)) - } - return success -} - -// ShouldBeEmpty receives a single parameter (actual) and determines whether or not -// calling len(actual) would return `0`. It obeys the rules specified by the len -// function for determining length: http://golang.org/pkg/builtin/#len -func ShouldBeEmpty(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } - - if actual == nil { - return success - } - - value := reflect.ValueOf(actual) - switch value.Kind() { - case reflect.Slice: - if value.Len() == 0 { - return success - } - case reflect.Chan: - if value.Len() == 0 { - return success - } - case reflect.Map: - if value.Len() == 0 { - return success - } - case reflect.String: - if value.Len() == 0 { - return success - } - case reflect.Ptr: - elem := value.Elem() - kind := elem.Kind() - if (kind == reflect.Slice || kind == reflect.Array) && elem.Len() == 0 { - return success - } - } - - return fmt.Sprintf(shouldHaveBeenEmpty, actual) -} - -// ShouldNotBeEmpty receives a single parameter (actual) and determines whether or not -// calling len(actual) would return a value greater than zero. It obeys the rules -// specified by the `len` function for determining length: http://golang.org/pkg/builtin/#len -func ShouldNotBeEmpty(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } - - if empty := ShouldBeEmpty(actual, expected...); empty != success { - return success - } - return fmt.Sprintf(shouldNotHaveBeenEmpty, actual) -} - -// ShouldHaveLength receives 2 parameters. The first is a collection to check -// the length of, the second being the expected length. It obeys the rules -// specified by the len function for determining length: -// http://golang.org/pkg/builtin/#len -func ShouldHaveLength(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - var expectedLen int64 - lenValue := reflect.ValueOf(expected[0]) - switch lenValue.Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - expectedLen = lenValue.Int() - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - expectedLen = int64(lenValue.Uint()) - default: - return fmt.Sprintf(shouldHaveBeenAValidInteger, reflect.TypeOf(expected[0])) - } - - if expectedLen < 0 { - return fmt.Sprintf(shouldHaveBeenAValidLength, expected[0]) - } - - value := reflect.ValueOf(actual) - switch value.Kind() { - case reflect.Slice, - reflect.Chan, - reflect.Map, - reflect.String: - if int64(value.Len()) == expectedLen { - return success - } else { - return fmt.Sprintf(shouldHaveHadLength, actual, value.Len(), expectedLen) - } - case reflect.Ptr: - elem := value.Elem() - kind := elem.Kind() - if kind == reflect.Slice || kind == reflect.Array { - if int64(elem.Len()) == expectedLen { - return success - } else { - return fmt.Sprintf(shouldHaveHadLength, actual, elem.Len(), expectedLen) - } - } - } - return fmt.Sprintf(shouldHaveBeenAValidCollection, reflect.TypeOf(actual)) -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/doc.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/doc.go deleted file mode 100644 index 5720fc298c..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/doc.go +++ /dev/null @@ -1,105 +0,0 @@ -// Package assertions contains the implementations for all assertions which -// are referenced in goconvey's `convey` package -// (github.com/smartystreets/goconvey/convey) and gunit (github.com/smartystreets/gunit) -// for use with the So(...) method. -// They can also be used in traditional Go test functions and even in -// applications. -// -// Many of the assertions lean heavily on work done by Aaron Jacobs in his excellent oglematchers library. -// (https://github.com/jacobsa/oglematchers) -// The ShouldResemble assertion leans heavily on work done by Daniel Jacques in his very helpful go-render library. -// (https://github.com/luci/go-render) -package assertions - -import ( - "fmt" - "runtime" -) - -// By default we use a no-op serializer. The actual Serializer provides a JSON -// representation of failure results on selected assertions so the goconvey -// web UI can display a convenient diff. -var serializer Serializer = new(noopSerializer) - -// GoConveyMode provides control over JSON serialization of failures. When -// using the assertions in this package from the convey package JSON results -// are very helpful and can be rendered in a DIFF view. In that case, this function -// will be called with a true value to enable the JSON serialization. By default, -// the assertions in this package will not serializer a JSON result, making -// standalone ussage more convenient. -func GoConveyMode(yes bool) { - if yes { - serializer = newSerializer() - } else { - serializer = new(noopSerializer) - } -} - -type testingT interface { - Error(args ...interface{}) -} - -type Assertion struct { - t testingT - failed bool -} - -// New swallows the *testing.T struct and prints failed assertions using t.Error. -// Example: assertions.New(t).So(1, should.Equal, 1) -func New(t testingT) *Assertion { - return &Assertion{t: t} -} - -// Failed reports whether any calls to So (on this Assertion instance) have failed. -func (this *Assertion) Failed() bool { - return this.failed -} - -// So calls the standalone So function and additionally, calls t.Error in failure scenarios. -func (this *Assertion) So(actual interface{}, assert assertion, expected ...interface{}) bool { - ok, result := So(actual, assert, expected...) - if !ok { - this.failed = true - _, file, line, _ := runtime.Caller(1) - this.t.Error(fmt.Sprintf("\n%s:%d\n%s", file, line, result)) - } - return ok -} - -// So is a convenience function (as opposed to an inconvenience function?) -// for running assertions on arbitrary arguments in any context, be it for testing or even -// application logging. It allows you to perform assertion-like behavior (and get nicely -// formatted messages detailing discrepancies) but without the program blowing up or panicking. -// All that is required is to import this package and call `So` with one of the assertions -// exported by this package as the second parameter. -// The first return parameter is a boolean indicating if the assertion was true. The second -// return parameter is the well-formatted message showing why an assertion was incorrect, or -// blank if the assertion was correct. -// -// Example: -// -// if ok, message := So(x, ShouldBeGreaterThan, y); !ok { -// log.Println(message) -// } -// -func So(actual interface{}, assert assertion, expected ...interface{}) (bool, string) { - if result := so(actual, assert, expected...); len(result) == 0 { - return true, result - } else { - return false, result - } -} - -// so is like So, except that it only returns the string message, which is blank if the -// assertion passed. Used to facilitate testing. -func so(actual interface{}, assert func(interface{}, ...interface{}) string, expected ...interface{}) string { - return assert(actual, expected...) -} - -// assertion is an alias for a function with a signature that the So() -// function can handle. Any future or custom assertions should conform to this -// method signature. The return value should be an empty string if the assertion -// passes and a well-formed failure message if not. -type assertion func(actual interface{}, expected ...interface{}) string - -//////////////////////////////////////////////////////////////////////////// diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/equality.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/equality.go deleted file mode 100644 index 2b6049c37d..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/equality.go +++ /dev/null @@ -1,280 +0,0 @@ -package assertions - -import ( - "errors" - "fmt" - "math" - "reflect" - "strings" - - "github.com/smartystreets/assertions/internal/oglematchers" - "github.com/smartystreets/assertions/internal/go-render/render" -) - -// default acceptable delta for ShouldAlmostEqual -const defaultDelta = 0.0000000001 - -// ShouldEqual receives exactly two parameters and does an equality check. -func ShouldEqual(actual interface{}, expected ...interface{}) string { - if message := need(1, expected); message != success { - return message - } - return shouldEqual(actual, expected[0]) -} -func shouldEqual(actual, expected interface{}) (message string) { - defer func() { - if r := recover(); r != nil { - message = serializer.serialize(expected, actual, fmt.Sprintf(shouldHaveBeenEqual, expected, actual)) - return - } - }() - - if matchError := oglematchers.Equals(expected).Matches(actual); matchError != nil { - expectedSyntax := fmt.Sprintf("%v", expected) - actualSyntax := fmt.Sprintf("%v", actual) - if expectedSyntax == actualSyntax && reflect.TypeOf(expected) != reflect.TypeOf(actual) { - message = fmt.Sprintf(shouldHaveBeenEqualTypeMismatch, expected, expected, actual, actual) - } else { - message = fmt.Sprintf(shouldHaveBeenEqual, expected, actual) - } - message = serializer.serialize(expected, actual, message) - return - } - - return success -} - -// ShouldNotEqual receives exactly two parameters and does an inequality check. -func ShouldNotEqual(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } else if ShouldEqual(actual, expected[0]) == success { - return fmt.Sprintf(shouldNotHaveBeenEqual, actual, expected[0]) - } - return success -} - -// ShouldAlmostEqual makes sure that two parameters are close enough to being equal. -// The acceptable delta may be specified with a third argument, -// or a very small default delta will be used. -func ShouldAlmostEqual(actual interface{}, expected ...interface{}) string { - actualFloat, expectedFloat, deltaFloat, err := cleanAlmostEqualInput(actual, expected...) - - if err != "" { - return err - } - - if math.Abs(actualFloat-expectedFloat) <= deltaFloat { - return success - } else { - return fmt.Sprintf(shouldHaveBeenAlmostEqual, actualFloat, expectedFloat) - } -} - -// ShouldNotAlmostEqual is the inverse of ShouldAlmostEqual -func ShouldNotAlmostEqual(actual interface{}, expected ...interface{}) string { - actualFloat, expectedFloat, deltaFloat, err := cleanAlmostEqualInput(actual, expected...) - - if err != "" { - return err - } - - if math.Abs(actualFloat-expectedFloat) > deltaFloat { - return success - } else { - return fmt.Sprintf(shouldHaveNotBeenAlmostEqual, actualFloat, expectedFloat) - } -} - -func cleanAlmostEqualInput(actual interface{}, expected ...interface{}) (float64, float64, float64, string) { - deltaFloat := 0.0000000001 - - if len(expected) == 0 { - return 0.0, 0.0, 0.0, "This assertion requires exactly one comparison value and an optional delta (you provided neither)" - } else if len(expected) == 2 { - delta, err := getFloat(expected[1]) - - if err != nil { - return 0.0, 0.0, 0.0, "delta must be a numerical type" - } - - deltaFloat = delta - } else if len(expected) > 2 { - return 0.0, 0.0, 0.0, "This assertion requires exactly one comparison value and an optional delta (you provided more values)" - } - - actualFloat, err := getFloat(actual) - - if err != nil { - return 0.0, 0.0, 0.0, err.Error() - } - - expectedFloat, err := getFloat(expected[0]) - - if err != nil { - return 0.0, 0.0, 0.0, err.Error() - } - - return actualFloat, expectedFloat, deltaFloat, "" -} - -// returns the float value of any real number, or error if it is not a numerical type -func getFloat(num interface{}) (float64, error) { - numValue := reflect.ValueOf(num) - numKind := numValue.Kind() - - if numKind == reflect.Int || - numKind == reflect.Int8 || - numKind == reflect.Int16 || - numKind == reflect.Int32 || - numKind == reflect.Int64 { - return float64(numValue.Int()), nil - } else if numKind == reflect.Uint || - numKind == reflect.Uint8 || - numKind == reflect.Uint16 || - numKind == reflect.Uint32 || - numKind == reflect.Uint64 { - return float64(numValue.Uint()), nil - } else if numKind == reflect.Float32 || - numKind == reflect.Float64 { - return numValue.Float(), nil - } else { - return 0.0, errors.New("must be a numerical type, but was " + numKind.String()) - } -} - -// ShouldResemble receives exactly two parameters and does a deep equal check (see reflect.DeepEqual) -func ShouldResemble(actual interface{}, expected ...interface{}) string { - if message := need(1, expected); message != success { - return message - } - - if matchError := oglematchers.DeepEquals(expected[0]).Matches(actual); matchError != nil { - return serializer.serializeDetailed(expected[0], actual, - fmt.Sprintf(shouldHaveResembled, render.Render(expected[0]), render.Render(actual))) - } - - return success -} - -// ShouldNotResemble receives exactly two parameters and does an inverse deep equal check (see reflect.DeepEqual) -func ShouldNotResemble(actual interface{}, expected ...interface{}) string { - if message := need(1, expected); message != success { - return message - } else if ShouldResemble(actual, expected[0]) == success { - return fmt.Sprintf(shouldNotHaveResembled, render.Render(actual), render.Render(expected[0])) - } - return success -} - -// ShouldPointTo receives exactly two parameters and checks to see that they point to the same address. -func ShouldPointTo(actual interface{}, expected ...interface{}) string { - if message := need(1, expected); message != success { - return message - } - return shouldPointTo(actual, expected[0]) - -} -func shouldPointTo(actual, expected interface{}) string { - actualValue := reflect.ValueOf(actual) - expectedValue := reflect.ValueOf(expected) - - if ShouldNotBeNil(actual) != success { - return fmt.Sprintf(shouldHaveBeenNonNilPointer, "first", "nil") - } else if ShouldNotBeNil(expected) != success { - return fmt.Sprintf(shouldHaveBeenNonNilPointer, "second", "nil") - } else if actualValue.Kind() != reflect.Ptr { - return fmt.Sprintf(shouldHaveBeenNonNilPointer, "first", "not") - } else if expectedValue.Kind() != reflect.Ptr { - return fmt.Sprintf(shouldHaveBeenNonNilPointer, "second", "not") - } else if ShouldEqual(actualValue.Pointer(), expectedValue.Pointer()) != success { - actualAddress := reflect.ValueOf(actual).Pointer() - expectedAddress := reflect.ValueOf(expected).Pointer() - return serializer.serialize(expectedAddress, actualAddress, fmt.Sprintf(shouldHavePointedTo, - actual, actualAddress, - expected, expectedAddress)) - } - return success -} - -// ShouldNotPointTo receives exactly two parameters and checks to see that they point to different addresess. -func ShouldNotPointTo(actual interface{}, expected ...interface{}) string { - if message := need(1, expected); message != success { - return message - } - compare := ShouldPointTo(actual, expected[0]) - if strings.HasPrefix(compare, shouldBePointers) { - return compare - } else if compare == success { - return fmt.Sprintf(shouldNotHavePointedTo, actual, expected[0], reflect.ValueOf(actual).Pointer()) - } - return success -} - -// ShouldBeNil receives a single parameter and ensures that it is nil. -func ShouldBeNil(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } else if actual == nil { - return success - } else if interfaceHasNilValue(actual) { - return success - } - return fmt.Sprintf(shouldHaveBeenNil, actual) -} -func interfaceHasNilValue(actual interface{}) bool { - value := reflect.ValueOf(actual) - kind := value.Kind() - nilable := kind == reflect.Slice || - kind == reflect.Chan || - kind == reflect.Func || - kind == reflect.Ptr || - kind == reflect.Map - - // Careful: reflect.Value.IsNil() will panic unless it's an interface, chan, map, func, slice, or ptr - // Reference: http://golang.org/pkg/reflect/#Value.IsNil - return nilable && value.IsNil() -} - -// ShouldNotBeNil receives a single parameter and ensures that it is not nil. -func ShouldNotBeNil(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } else if ShouldBeNil(actual) == success { - return fmt.Sprintf(shouldNotHaveBeenNil, actual) - } - return success -} - -// ShouldBeTrue receives a single parameter and ensures that it is true. -func ShouldBeTrue(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } else if actual != true { - return fmt.Sprintf(shouldHaveBeenTrue, actual) - } - return success -} - -// ShouldBeFalse receives a single parameter and ensures that it is false. -func ShouldBeFalse(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } else if actual != false { - return fmt.Sprintf(shouldHaveBeenFalse, actual) - } - return success -} - -// ShouldBeZeroValue receives a single parameter and ensures that it is -// the Go equivalent of the default value, or "zero" value. -func ShouldBeZeroValue(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } - zeroVal := reflect.Zero(reflect.TypeOf(actual)).Interface() - if !reflect.DeepEqual(zeroVal, actual) { - return serializer.serialize(zeroVal, actual, fmt.Sprintf(shouldHaveBeenZeroValue, actual)) - } - return success -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/filter.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/filter.go deleted file mode 100644 index ee368a97ed..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/filter.go +++ /dev/null @@ -1,23 +0,0 @@ -package assertions - -import "fmt" - -const ( - success = "" - needExactValues = "This assertion requires exactly %d comparison values (you provided %d)." - needNonEmptyCollection = "This assertion requires at least 1 comparison value (you provided 0)." -) - -func need(needed int, expected []interface{}) string { - if len(expected) != needed { - return fmt.Sprintf(needExactValues, needed, len(expected)) - } - return success -} - -func atLeast(minimum int, expected []interface{}) string { - if len(expected) < 1 { - return needNonEmptyCollection - } - return success -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/go-render/render/render.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/go-render/render/render.go deleted file mode 100644 index 23b7a58676..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/go-render/render/render.go +++ /dev/null @@ -1,477 +0,0 @@ -// Copyright 2015 The Chromium 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 render - -import ( - "bytes" - "fmt" - "reflect" - "sort" - "strconv" -) - -var builtinTypeMap = map[reflect.Kind]string{ - reflect.Bool: "bool", - reflect.Complex128: "complex128", - reflect.Complex64: "complex64", - reflect.Float32: "float32", - reflect.Float64: "float64", - reflect.Int16: "int16", - reflect.Int32: "int32", - reflect.Int64: "int64", - reflect.Int8: "int8", - reflect.Int: "int", - reflect.String: "string", - reflect.Uint16: "uint16", - reflect.Uint32: "uint32", - reflect.Uint64: "uint64", - reflect.Uint8: "uint8", - reflect.Uint: "uint", - reflect.Uintptr: "uintptr", -} - -var builtinTypeSet = map[string]struct{}{} - -func init() { - for _, v := range builtinTypeMap { - builtinTypeSet[v] = struct{}{} - } -} - -var typeOfString = reflect.TypeOf("") -var typeOfInt = reflect.TypeOf(int(1)) -var typeOfUint = reflect.TypeOf(uint(1)) -var typeOfFloat = reflect.TypeOf(10.1) - -// Render converts a structure to a string representation. Unline the "%#v" -// format string, this resolves pointer types' contents in structs, maps, and -// slices/arrays and prints their field values. -func Render(v interface{}) string { - buf := bytes.Buffer{} - s := (*traverseState)(nil) - s.render(&buf, 0, reflect.ValueOf(v), false) - return buf.String() -} - -// renderPointer is called to render a pointer value. -// -// This is overridable so that the test suite can have deterministic pointer -// values in its expectations. -var renderPointer = func(buf *bytes.Buffer, p uintptr) { - fmt.Fprintf(buf, "0x%016x", p) -} - -// traverseState is used to note and avoid recursion as struct members are being -// traversed. -// -// traverseState is allowed to be nil. Specifically, the root state is nil. -type traverseState struct { - parent *traverseState - ptr uintptr -} - -func (s *traverseState) forkFor(ptr uintptr) *traverseState { - for cur := s; cur != nil; cur = cur.parent { - if ptr == cur.ptr { - return nil - } - } - - fs := &traverseState{ - parent: s, - ptr: ptr, - } - return fs -} - -func (s *traverseState) render(buf *bytes.Buffer, ptrs int, v reflect.Value, implicit bool) { - if v.Kind() == reflect.Invalid { - buf.WriteString("nil") - return - } - vt := v.Type() - - // If the type being rendered is a potentially recursive type (a type that - // can contain itself as a member), we need to avoid recursion. - // - // If we've already seen this type before, mark that this is the case and - // write a recursion placeholder instead of actually rendering it. - // - // If we haven't seen it before, fork our `seen` tracking so any higher-up - // renderers will also render it at least once, then mark that we've seen it - // to avoid recursing on lower layers. - pe := uintptr(0) - vk := vt.Kind() - switch vk { - case reflect.Ptr: - // Since structs and arrays aren't pointers, they can't directly be - // recursed, but they can contain pointers to themselves. Record their - // pointer to avoid this. - switch v.Elem().Kind() { - case reflect.Struct, reflect.Array: - pe = v.Pointer() - } - - case reflect.Slice, reflect.Map: - pe = v.Pointer() - } - if pe != 0 { - s = s.forkFor(pe) - if s == nil { - buf.WriteString("") - return - } - } - - isAnon := func(t reflect.Type) bool { - if t.Name() != "" { - if _, ok := builtinTypeSet[t.Name()]; !ok { - return false - } - } - return t.Kind() != reflect.Interface - } - - switch vk { - case reflect.Struct: - if !implicit { - writeType(buf, ptrs, vt) - } - structAnon := vt.Name() == "" - buf.WriteRune('{') - for i := 0; i < vt.NumField(); i++ { - if i > 0 { - buf.WriteString(", ") - } - anon := structAnon && isAnon(vt.Field(i).Type) - - if !anon { - buf.WriteString(vt.Field(i).Name) - buf.WriteRune(':') - } - - s.render(buf, 0, v.Field(i), anon) - } - buf.WriteRune('}') - - case reflect.Slice: - if v.IsNil() { - if !implicit { - writeType(buf, ptrs, vt) - buf.WriteString("(nil)") - } else { - buf.WriteString("nil") - } - return - } - fallthrough - - case reflect.Array: - if !implicit { - writeType(buf, ptrs, vt) - } - anon := vt.Name() == "" && isAnon(vt.Elem()) - buf.WriteString("{") - for i := 0; i < v.Len(); i++ { - if i > 0 { - buf.WriteString(", ") - } - - s.render(buf, 0, v.Index(i), anon) - } - buf.WriteRune('}') - - case reflect.Map: - if !implicit { - writeType(buf, ptrs, vt) - } - if v.IsNil() { - buf.WriteString("(nil)") - } else { - buf.WriteString("{") - - mkeys := v.MapKeys() - tryAndSortMapKeys(vt, mkeys) - - kt := vt.Key() - keyAnon := typeOfString.ConvertibleTo(kt) || typeOfInt.ConvertibleTo(kt) || typeOfUint.ConvertibleTo(kt) || typeOfFloat.ConvertibleTo(kt) - valAnon := vt.Name() == "" && isAnon(vt.Elem()) - for i, mk := range mkeys { - if i > 0 { - buf.WriteString(", ") - } - - s.render(buf, 0, mk, keyAnon) - buf.WriteString(":") - s.render(buf, 0, v.MapIndex(mk), valAnon) - } - buf.WriteRune('}') - } - - case reflect.Ptr: - ptrs++ - fallthrough - case reflect.Interface: - if v.IsNil() { - writeType(buf, ptrs, v.Type()) - buf.WriteString("(nil)") - } else { - s.render(buf, ptrs, v.Elem(), false) - } - - case reflect.Chan, reflect.Func, reflect.UnsafePointer: - writeType(buf, ptrs, vt) - buf.WriteRune('(') - renderPointer(buf, v.Pointer()) - buf.WriteRune(')') - - default: - tstr := vt.String() - implicit = implicit || (ptrs == 0 && builtinTypeMap[vk] == tstr) - if !implicit { - writeType(buf, ptrs, vt) - buf.WriteRune('(') - } - - switch vk { - case reflect.String: - fmt.Fprintf(buf, "%q", v.String()) - case reflect.Bool: - fmt.Fprintf(buf, "%v", v.Bool()) - - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - fmt.Fprintf(buf, "%d", v.Int()) - - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - fmt.Fprintf(buf, "%d", v.Uint()) - - case reflect.Float32, reflect.Float64: - fmt.Fprintf(buf, "%g", v.Float()) - - case reflect.Complex64, reflect.Complex128: - fmt.Fprintf(buf, "%g", v.Complex()) - } - - if !implicit { - buf.WriteRune(')') - } - } -} - -func writeType(buf *bytes.Buffer, ptrs int, t reflect.Type) { - parens := ptrs > 0 - switch t.Kind() { - case reflect.Chan, reflect.Func, reflect.UnsafePointer: - parens = true - } - - if parens { - buf.WriteRune('(') - for i := 0; i < ptrs; i++ { - buf.WriteRune('*') - } - } - - switch t.Kind() { - case reflect.Ptr: - if ptrs == 0 { - // This pointer was referenced from within writeType (e.g., as part of - // rendering a list), and so hasn't had its pointer asterisk accounted - // for. - buf.WriteRune('*') - } - writeType(buf, 0, t.Elem()) - - case reflect.Interface: - if n := t.Name(); n != "" { - buf.WriteString(t.String()) - } else { - buf.WriteString("interface{}") - } - - case reflect.Array: - buf.WriteRune('[') - buf.WriteString(strconv.FormatInt(int64(t.Len()), 10)) - buf.WriteRune(']') - writeType(buf, 0, t.Elem()) - - case reflect.Slice: - if t == reflect.SliceOf(t.Elem()) { - buf.WriteString("[]") - writeType(buf, 0, t.Elem()) - } else { - // Custom slice type, use type name. - buf.WriteString(t.String()) - } - - case reflect.Map: - if t == reflect.MapOf(t.Key(), t.Elem()) { - buf.WriteString("map[") - writeType(buf, 0, t.Key()) - buf.WriteRune(']') - writeType(buf, 0, t.Elem()) - } else { - // Custom map type, use type name. - buf.WriteString(t.String()) - } - - default: - buf.WriteString(t.String()) - } - - if parens { - buf.WriteRune(')') - } -} - -type cmpFn func(a, b reflect.Value) int - -type sortableValueSlice struct { - cmp cmpFn - elements []reflect.Value -} - -func (s sortableValueSlice) Len() int { - return len(s.elements) -} - -func (s sortableValueSlice) Less(i, j int) bool { - return s.cmp(s.elements[i], s.elements[j]) < 0 -} - -func (s sortableValueSlice) Swap(i, j int) { - s.elements[i], s.elements[j] = s.elements[j], s.elements[i] -} - -// cmpForType returns a cmpFn which sorts the data for some type t in the same -// order that a go-native map key is compared for equality. -func cmpForType(t reflect.Type) cmpFn { - switch t.Kind() { - case reflect.String: - return func(av, bv reflect.Value) int { - a, b := av.String(), bv.String() - if a < b { - return -1 - } else if a > b { - return 1 - } - return 0 - } - - case reflect.Bool: - return func(av, bv reflect.Value) int { - a, b := av.Bool(), bv.Bool() - if !a && b { - return -1 - } else if a && !b { - return 1 - } - return 0 - } - - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return func(av, bv reflect.Value) int { - a, b := av.Int(), bv.Int() - if a < b { - return -1 - } else if a > b { - return 1 - } - return 0 - } - - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, - reflect.Uint64, reflect.Uintptr, reflect.UnsafePointer: - return func(av, bv reflect.Value) int { - a, b := av.Uint(), bv.Uint() - if a < b { - return -1 - } else if a > b { - return 1 - } - return 0 - } - - case reflect.Float32, reflect.Float64: - return func(av, bv reflect.Value) int { - a, b := av.Float(), bv.Float() - if a < b { - return -1 - } else if a > b { - return 1 - } - return 0 - } - - case reflect.Interface: - return func(av, bv reflect.Value) int { - a, b := av.InterfaceData(), bv.InterfaceData() - if a[0] < b[0] { - return -1 - } else if a[0] > b[0] { - return 1 - } - if a[1] < b[1] { - return -1 - } else if a[1] > b[1] { - return 1 - } - return 0 - } - - case reflect.Complex64, reflect.Complex128: - return func(av, bv reflect.Value) int { - a, b := av.Complex(), bv.Complex() - if real(a) < real(b) { - return -1 - } else if real(a) > real(b) { - return 1 - } - if imag(a) < imag(b) { - return -1 - } else if imag(a) > imag(b) { - return 1 - } - return 0 - } - - case reflect.Ptr, reflect.Chan: - return func(av, bv reflect.Value) int { - a, b := av.Pointer(), bv.Pointer() - if a < b { - return -1 - } else if a > b { - return 1 - } - return 0 - } - - case reflect.Struct: - cmpLst := make([]cmpFn, t.NumField()) - for i := range cmpLst { - cmpLst[i] = cmpForType(t.Field(i).Type) - } - return func(a, b reflect.Value) int { - for i, cmp := range cmpLst { - if rslt := cmp(a.Field(i), b.Field(i)); rslt != 0 { - return rslt - } - } - return 0 - } - } - - return nil -} - -func tryAndSortMapKeys(mt reflect.Type, k []reflect.Value) { - if cmp := cmpForType(mt.Key()); cmp != nil { - sort.Sort(sortableValueSlice{cmp, k}) - } -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/.gitignore b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/.gitignore deleted file mode 100644 index dd8fc7468f..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -*.6 -6.out -_obj/ -_test/ -_testmain.go diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/.travis.yml b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/.travis.yml deleted file mode 100644 index b97211926e..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -# Cf. http://docs.travis-ci.com/user/getting-started/ -# Cf. http://docs.travis-ci.com/user/languages/go/ - -language: go diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/LICENSE b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/LICENSE deleted file mode 100644 index d645695673..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor 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, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/README.md b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/README.md deleted file mode 100644 index 215a2bb7a8..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/README.md +++ /dev/null @@ -1,58 +0,0 @@ -[![GoDoc](https://godoc.org/github.com/smartystreets/assertions/internal/oglematchers?status.svg)](https://godoc.org/github.com/smartystreets/assertions/internal/oglematchers) - -`oglematchers` is a package for the Go programming language containing a set of -matchers, useful in a testing or mocking framework, inspired by and mostly -compatible with [Google Test][googletest] for C++ and -[Google JS Test][google-js-test]. The package is used by the -[ogletest][ogletest] testing framework and [oglemock][oglemock] mocking -framework, which may be more directly useful to you, but can be generically used -elsewhere as well. - -A "matcher" is simply an object with a `Matches` method defining a set of golang -values matched by the matcher, and a `Description` method describing that set. -For example, here are some matchers: - -```go -// Numbers -Equals(17.13) -LessThan(19) - -// Strings -Equals("taco") -HasSubstr("burrito") -MatchesRegex("t.*o") - -// Combining matchers -AnyOf(LessThan(17), GreaterThan(19)) -``` - -There are lots more; see [here][reference] for a reference. You can also add -your own simply by implementing the `oglematchers.Matcher` interface. - - -Installation ------------- - -First, make sure you have installed Go 1.0.2 or newer. See -[here][golang-install] for instructions. - -Use the following command to install `oglematchers` and keep it up to date: - - go get -u github.com/smartystreets/assertions/internal/oglematchers - - -Documentation -------------- - -See [here][reference] for documentation. Alternatively, you can install the -package and then use `godoc`: - - godoc github.com/smartystreets/assertions/internal/oglematchers - - -[reference]: http://godoc.org/github.com/smartystreets/assertions/internal/oglematchers -[golang-install]: http://golang.org/doc/install.html -[googletest]: http://code.google.com/p/googletest/ -[google-js-test]: http://code.google.com/p/google-js-test/ -[ogletest]: http://github.com/smartystreets/assertions/internal/ogletest -[oglemock]: http://github.com/smartystreets/assertions/internal/oglemock diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/all_of.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/all_of.go deleted file mode 100644 index d93a974044..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/all_of.go +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "strings" -) - -// AllOf accepts a set of matchers S and returns a matcher that follows the -// algorithm below when considering a candidate c: -// -// 1. Return true if for every Matcher m in S, m matches c. -// -// 2. Otherwise, if there is a matcher m in S such that m returns a fatal -// error for c, return that matcher's error message. -// -// 3. Otherwise, return false with the error from some wrapped matcher. -// -// This is akin to a logical AND operation for matchers. -func AllOf(matchers ...Matcher) Matcher { - return &allOfMatcher{matchers} -} - -type allOfMatcher struct { - wrappedMatchers []Matcher -} - -func (m *allOfMatcher) Description() string { - // Special case: the empty set. - if len(m.wrappedMatchers) == 0 { - return "is anything" - } - - // Join the descriptions for the wrapped matchers. - wrappedDescs := make([]string, len(m.wrappedMatchers)) - for i, wrappedMatcher := range m.wrappedMatchers { - wrappedDescs[i] = wrappedMatcher.Description() - } - - return strings.Join(wrappedDescs, ", and ") -} - -func (m *allOfMatcher) Matches(c interface{}) (err error) { - for _, wrappedMatcher := range m.wrappedMatchers { - if wrappedErr := wrappedMatcher.Matches(c); wrappedErr != nil { - err = wrappedErr - - // If the error is fatal, return immediately with this error. - _, ok := wrappedErr.(*FatalError) - if ok { - return - } - } - } - - return -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/any.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/any.go deleted file mode 100644 index f6991ec102..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/any.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -// Any returns a matcher that matches any value. -func Any() Matcher { - return &anyMatcher{} -} - -type anyMatcher struct { -} - -func (m *anyMatcher) Description() string { - return "is anything" -} - -func (m *anyMatcher) Matches(c interface{}) error { - return nil -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/any_of.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/any_of.go deleted file mode 100644 index 2918b51f21..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/any_of.go +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "reflect" - "strings" -) - -// AnyOf accepts a set of values S and returns a matcher that follows the -// algorithm below when considering a candidate c: -// -// 1. If there exists a value m in S such that m implements the Matcher -// interface and m matches c, return true. -// -// 2. Otherwise, if there exists a value v in S such that v does not implement -// the Matcher interface and the matcher Equals(v) matches c, return true. -// -// 3. Otherwise, if there is a value m in S such that m implements the Matcher -// interface and m returns a fatal error for c, return that fatal error. -// -// 4. Otherwise, return false. -// -// This is akin to a logical OR operation for matchers, with non-matchers x -// being treated as Equals(x). -func AnyOf(vals ...interface{}) Matcher { - // Get ahold of a type variable for the Matcher interface. - var dummy *Matcher - matcherType := reflect.TypeOf(dummy).Elem() - - // Create a matcher for each value, or use the value itself if it's already a - // matcher. - wrapped := make([]Matcher, len(vals)) - for i, v := range vals { - t := reflect.TypeOf(v) - if t != nil && t.Implements(matcherType) { - wrapped[i] = v.(Matcher) - } else { - wrapped[i] = Equals(v) - } - } - - return &anyOfMatcher{wrapped} -} - -type anyOfMatcher struct { - wrapped []Matcher -} - -func (m *anyOfMatcher) Description() string { - wrappedDescs := make([]string, len(m.wrapped)) - for i, matcher := range m.wrapped { - wrappedDescs[i] = matcher.Description() - } - - return fmt.Sprintf("or(%s)", strings.Join(wrappedDescs, ", ")) -} - -func (m *anyOfMatcher) Matches(c interface{}) (err error) { - err = errors.New("") - - // Try each matcher in turn. - for _, matcher := range m.wrapped { - wrappedErr := matcher.Matches(c) - - // Return immediately if there's a match. - if wrappedErr == nil { - err = nil - return - } - - // Note the fatal error, if any. - if _, isFatal := wrappedErr.(*FatalError); isFatal { - err = wrappedErr - } - } - - return -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/contains.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/contains.go deleted file mode 100644 index 87f107d392..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/contains.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "fmt" - "reflect" -) - -// Return a matcher that matches arrays slices with at least one element that -// matches the supplied argument. If the argument x is not itself a Matcher, -// this is equivalent to Contains(Equals(x)). -func Contains(x interface{}) Matcher { - var result containsMatcher - var ok bool - - if result.elementMatcher, ok = x.(Matcher); !ok { - result.elementMatcher = DeepEquals(x) - } - - return &result -} - -type containsMatcher struct { - elementMatcher Matcher -} - -func (m *containsMatcher) Description() string { - return fmt.Sprintf("contains: %s", m.elementMatcher.Description()) -} - -func (m *containsMatcher) Matches(candidate interface{}) error { - // The candidate must be a slice or an array. - v := reflect.ValueOf(candidate) - if v.Kind() != reflect.Slice && v.Kind() != reflect.Array { - return NewFatalError("which is not a slice or array") - } - - // Check each element. - for i := 0; i < v.Len(); i++ { - elem := v.Index(i) - if matchErr := m.elementMatcher.Matches(elem.Interface()); matchErr == nil { - return nil - } - } - - return fmt.Errorf("") -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/deep_equals.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/deep_equals.go deleted file mode 100644 index 1d91baef32..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/deep_equals.go +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "bytes" - "errors" - "fmt" - "reflect" -) - -var byteSliceType reflect.Type = reflect.TypeOf([]byte{}) - -// DeepEquals returns a matcher that matches based on 'deep equality', as -// defined by the reflect package. This matcher requires that values have -// identical types to x. -func DeepEquals(x interface{}) Matcher { - return &deepEqualsMatcher{x} -} - -type deepEqualsMatcher struct { - x interface{} -} - -func (m *deepEqualsMatcher) Description() string { - xDesc := fmt.Sprintf("%v", m.x) - xValue := reflect.ValueOf(m.x) - - // Special case: fmt.Sprintf presents nil slices as "[]", but - // reflect.DeepEqual makes a distinction between nil and empty slices. Make - // this less confusing. - if xValue.Kind() == reflect.Slice && xValue.IsNil() { - xDesc = "" - } - - return fmt.Sprintf("deep equals: %s", xDesc) -} - -func (m *deepEqualsMatcher) Matches(c interface{}) error { - // Make sure the types match. - ct := reflect.TypeOf(c) - xt := reflect.TypeOf(m.x) - - if ct != xt { - return NewFatalError(fmt.Sprintf("which is of type %v", ct)) - } - - // Special case: handle byte slices more efficiently. - cValue := reflect.ValueOf(c) - xValue := reflect.ValueOf(m.x) - - if ct == byteSliceType && !cValue.IsNil() && !xValue.IsNil() { - xBytes := m.x.([]byte) - cBytes := c.([]byte) - - if bytes.Equal(cBytes, xBytes) { - return nil - } - - return errors.New("") - } - - // Defer to the reflect package. - if reflect.DeepEqual(m.x, c) { - return nil - } - - // Special case: if the comparison failed because c is the nil slice, given - // an indication of this (since its value is printed as "[]"). - if cValue.Kind() == reflect.Slice && cValue.IsNil() { - return errors.New("which is nil") - } - - return errors.New("") -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/elements_are.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/elements_are.go deleted file mode 100644 index 2941847c70..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/elements_are.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "reflect" - "strings" -) - -// Given a list of arguments M, ElementsAre returns a matcher that matches -// arrays and slices A where all of the following hold: -// -// * A is the same length as M. -// -// * For each i < len(A) where M[i] is a matcher, A[i] matches M[i]. -// -// * For each i < len(A) where M[i] is not a matcher, A[i] matches -// Equals(M[i]). -// -func ElementsAre(M ...interface{}) Matcher { - // Copy over matchers, or convert to Equals(x) for non-matcher x. - subMatchers := make([]Matcher, len(M)) - for i, x := range M { - if matcher, ok := x.(Matcher); ok { - subMatchers[i] = matcher - continue - } - - subMatchers[i] = Equals(x) - } - - return &elementsAreMatcher{subMatchers} -} - -type elementsAreMatcher struct { - subMatchers []Matcher -} - -func (m *elementsAreMatcher) Description() string { - subDescs := make([]string, len(m.subMatchers)) - for i, sm := range m.subMatchers { - subDescs[i] = sm.Description() - } - - return fmt.Sprintf("elements are: [%s]", strings.Join(subDescs, ", ")) -} - -func (m *elementsAreMatcher) Matches(candidates interface{}) error { - // The candidate must be a slice or an array. - v := reflect.ValueOf(candidates) - if v.Kind() != reflect.Slice && v.Kind() != reflect.Array { - return NewFatalError("which is not a slice or array") - } - - // The length must be correct. - if v.Len() != len(m.subMatchers) { - return errors.New(fmt.Sprintf("which is of length %d", v.Len())) - } - - // Check each element. - for i, subMatcher := range m.subMatchers { - c := v.Index(i) - if matchErr := subMatcher.Matches(c.Interface()); matchErr != nil { - // Return an errors indicating which element doesn't match. If the - // matcher error was fatal, make this one fatal too. - err := errors.New(fmt.Sprintf("whose element %d doesn't match", i)) - if _, isFatal := matchErr.(*FatalError); isFatal { - err = NewFatalError(err.Error()) - } - - return err - } - } - - return nil -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/equals.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/equals.go deleted file mode 100644 index a510707b3c..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/equals.go +++ /dev/null @@ -1,541 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "math" - "reflect" -) - -// Equals(x) returns a matcher that matches values v such that v and x are -// equivalent. This includes the case when the comparison v == x using Go's -// built-in comparison operator is legal (except for structs, which this -// matcher does not support), but for convenience the following rules also -// apply: -// -// * Type checking is done based on underlying types rather than actual -// types, so that e.g. two aliases for string can be compared: -// -// type stringAlias1 string -// type stringAlias2 string -// -// a := "taco" -// b := stringAlias1("taco") -// c := stringAlias2("taco") -// -// ExpectTrue(a == b) // Legal, passes -// ExpectTrue(b == c) // Illegal, doesn't compile -// -// ExpectThat(a, Equals(b)) // Passes -// ExpectThat(b, Equals(c)) // Passes -// -// * Values of numeric type are treated as if they were abstract numbers, and -// compared accordingly. Therefore Equals(17) will match int(17), -// int16(17), uint(17), float32(17), complex64(17), and so on. -// -// If you want a stricter matcher that contains no such cleverness, see -// IdenticalTo instead. -// -// Arrays are supported by this matcher, but do not participate in the -// exceptions above. Two arrays compared with this matcher must have identical -// types, and their element type must itself be comparable according to Go's == -// operator. -func Equals(x interface{}) Matcher { - v := reflect.ValueOf(x) - - // This matcher doesn't support structs. - if v.Kind() == reflect.Struct { - panic(fmt.Sprintf("oglematchers.Equals: unsupported kind %v", v.Kind())) - } - - // The == operator is not defined for non-nil slices. - if v.Kind() == reflect.Slice && v.Pointer() != uintptr(0) { - panic(fmt.Sprintf("oglematchers.Equals: non-nil slice")) - } - - return &equalsMatcher{v} -} - -type equalsMatcher struct { - expectedValue reflect.Value -} - -//////////////////////////////////////////////////////////////////////// -// Numeric types -//////////////////////////////////////////////////////////////////////// - -func isSignedInteger(v reflect.Value) bool { - k := v.Kind() - return k >= reflect.Int && k <= reflect.Int64 -} - -func isUnsignedInteger(v reflect.Value) bool { - k := v.Kind() - return k >= reflect.Uint && k <= reflect.Uintptr -} - -func isInteger(v reflect.Value) bool { - return isSignedInteger(v) || isUnsignedInteger(v) -} - -func isFloat(v reflect.Value) bool { - k := v.Kind() - return k == reflect.Float32 || k == reflect.Float64 -} - -func isComplex(v reflect.Value) bool { - k := v.Kind() - return k == reflect.Complex64 || k == reflect.Complex128 -} - -func checkAgainstInt64(e int64, c reflect.Value) (err error) { - err = errors.New("") - - switch { - case isSignedInteger(c): - if c.Int() == e { - err = nil - } - - case isUnsignedInteger(c): - u := c.Uint() - if u <= math.MaxInt64 && int64(u) == e { - err = nil - } - - // Turn around the various floating point types so that the checkAgainst* - // functions for them can deal with precision issues. - case isFloat(c), isComplex(c): - return Equals(c.Interface()).Matches(e) - - default: - err = NewFatalError("which is not numeric") - } - - return -} - -func checkAgainstUint64(e uint64, c reflect.Value) (err error) { - err = errors.New("") - - switch { - case isSignedInteger(c): - i := c.Int() - if i >= 0 && uint64(i) == e { - err = nil - } - - case isUnsignedInteger(c): - if c.Uint() == e { - err = nil - } - - // Turn around the various floating point types so that the checkAgainst* - // functions for them can deal with precision issues. - case isFloat(c), isComplex(c): - return Equals(c.Interface()).Matches(e) - - default: - err = NewFatalError("which is not numeric") - } - - return -} - -func checkAgainstFloat32(e float32, c reflect.Value) (err error) { - err = errors.New("") - - switch { - case isSignedInteger(c): - if float32(c.Int()) == e { - err = nil - } - - case isUnsignedInteger(c): - if float32(c.Uint()) == e { - err = nil - } - - case isFloat(c): - // Compare using float32 to avoid a false sense of precision; otherwise - // e.g. Equals(float32(0.1)) won't match float32(0.1). - if float32(c.Float()) == e { - err = nil - } - - case isComplex(c): - comp := c.Complex() - rl := real(comp) - im := imag(comp) - - // Compare using float32 to avoid a false sense of precision; otherwise - // e.g. Equals(float32(0.1)) won't match (0.1 + 0i). - if im == 0 && float32(rl) == e { - err = nil - } - - default: - err = NewFatalError("which is not numeric") - } - - return -} - -func checkAgainstFloat64(e float64, c reflect.Value) (err error) { - err = errors.New("") - - ck := c.Kind() - - switch { - case isSignedInteger(c): - if float64(c.Int()) == e { - err = nil - } - - case isUnsignedInteger(c): - if float64(c.Uint()) == e { - err = nil - } - - // If the actual value is lower precision, turn the comparison around so we - // apply the low-precision rules. Otherwise, e.g. Equals(0.1) may not match - // float32(0.1). - case ck == reflect.Float32 || ck == reflect.Complex64: - return Equals(c.Interface()).Matches(e) - - // Otherwise, compare with double precision. - case isFloat(c): - if c.Float() == e { - err = nil - } - - case isComplex(c): - comp := c.Complex() - rl := real(comp) - im := imag(comp) - - if im == 0 && rl == e { - err = nil - } - - default: - err = NewFatalError("which is not numeric") - } - - return -} - -func checkAgainstComplex64(e complex64, c reflect.Value) (err error) { - err = errors.New("") - realPart := real(e) - imaginaryPart := imag(e) - - switch { - case isInteger(c) || isFloat(c): - // If we have no imaginary part, then we should just compare against the - // real part. Otherwise, we can't be equal. - if imaginaryPart != 0 { - return - } - - return checkAgainstFloat32(realPart, c) - - case isComplex(c): - // Compare using complex64 to avoid a false sense of precision; otherwise - // e.g. Equals(0.1 + 0i) won't match float32(0.1). - if complex64(c.Complex()) == e { - err = nil - } - - default: - err = NewFatalError("which is not numeric") - } - - return -} - -func checkAgainstComplex128(e complex128, c reflect.Value) (err error) { - err = errors.New("") - realPart := real(e) - imaginaryPart := imag(e) - - switch { - case isInteger(c) || isFloat(c): - // If we have no imaginary part, then we should just compare against the - // real part. Otherwise, we can't be equal. - if imaginaryPart != 0 { - return - } - - return checkAgainstFloat64(realPart, c) - - case isComplex(c): - if c.Complex() == e { - err = nil - } - - default: - err = NewFatalError("which is not numeric") - } - - return -} - -//////////////////////////////////////////////////////////////////////// -// Other types -//////////////////////////////////////////////////////////////////////// - -func checkAgainstBool(e bool, c reflect.Value) (err error) { - if c.Kind() != reflect.Bool { - err = NewFatalError("which is not a bool") - return - } - - err = errors.New("") - if c.Bool() == e { - err = nil - } - return -} - -func checkAgainstChan(e reflect.Value, c reflect.Value) (err error) { - // Create a description of e's type, e.g. "chan int". - typeStr := fmt.Sprintf("%s %s", e.Type().ChanDir(), e.Type().Elem()) - - // Make sure c is a chan of the correct type. - if c.Kind() != reflect.Chan || - c.Type().ChanDir() != e.Type().ChanDir() || - c.Type().Elem() != e.Type().Elem() { - err = NewFatalError(fmt.Sprintf("which is not a %s", typeStr)) - return - } - - err = errors.New("") - if c.Pointer() == e.Pointer() { - err = nil - } - return -} - -func checkAgainstFunc(e reflect.Value, c reflect.Value) (err error) { - // Make sure c is a function. - if c.Kind() != reflect.Func { - err = NewFatalError("which is not a function") - return - } - - err = errors.New("") - if c.Pointer() == e.Pointer() { - err = nil - } - return -} - -func checkAgainstMap(e reflect.Value, c reflect.Value) (err error) { - // Make sure c is a map. - if c.Kind() != reflect.Map { - err = NewFatalError("which is not a map") - return - } - - err = errors.New("") - if c.Pointer() == e.Pointer() { - err = nil - } - return -} - -func checkAgainstPtr(e reflect.Value, c reflect.Value) (err error) { - // Create a description of e's type, e.g. "*int". - typeStr := fmt.Sprintf("*%v", e.Type().Elem()) - - // Make sure c is a pointer of the correct type. - if c.Kind() != reflect.Ptr || - c.Type().Elem() != e.Type().Elem() { - err = NewFatalError(fmt.Sprintf("which is not a %s", typeStr)) - return - } - - err = errors.New("") - if c.Pointer() == e.Pointer() { - err = nil - } - return -} - -func checkAgainstSlice(e reflect.Value, c reflect.Value) (err error) { - // Create a description of e's type, e.g. "[]int". - typeStr := fmt.Sprintf("[]%v", e.Type().Elem()) - - // Make sure c is a slice of the correct type. - if c.Kind() != reflect.Slice || - c.Type().Elem() != e.Type().Elem() { - err = NewFatalError(fmt.Sprintf("which is not a %s", typeStr)) - return - } - - err = errors.New("") - if c.Pointer() == e.Pointer() { - err = nil - } - return -} - -func checkAgainstString(e reflect.Value, c reflect.Value) (err error) { - // Make sure c is a string. - if c.Kind() != reflect.String { - err = NewFatalError("which is not a string") - return - } - - err = errors.New("") - if c.String() == e.String() { - err = nil - } - return -} - -func checkAgainstArray(e reflect.Value, c reflect.Value) (err error) { - // Create a description of e's type, e.g. "[2]int". - typeStr := fmt.Sprintf("%v", e.Type()) - - // Make sure c is the correct type. - if c.Type() != e.Type() { - err = NewFatalError(fmt.Sprintf("which is not %s", typeStr)) - return - } - - // Check for equality. - if e.Interface() != c.Interface() { - err = errors.New("") - return - } - - return -} - -func checkAgainstUnsafePointer(e reflect.Value, c reflect.Value) (err error) { - // Make sure c is a pointer. - if c.Kind() != reflect.UnsafePointer { - err = NewFatalError("which is not a unsafe.Pointer") - return - } - - err = errors.New("") - if c.Pointer() == e.Pointer() { - err = nil - } - return -} - -func checkForNil(c reflect.Value) (err error) { - err = errors.New("") - - // Make sure it is legal to call IsNil. - switch c.Kind() { - case reflect.Invalid: - case reflect.Chan: - case reflect.Func: - case reflect.Interface: - case reflect.Map: - case reflect.Ptr: - case reflect.Slice: - - default: - err = NewFatalError("which cannot be compared to nil") - return - } - - // Ask whether the value is nil. Handle a nil literal (kind Invalid) - // specially, since it's not legal to call IsNil there. - if c.Kind() == reflect.Invalid || c.IsNil() { - err = nil - } - return -} - -//////////////////////////////////////////////////////////////////////// -// Public implementation -//////////////////////////////////////////////////////////////////////// - -func (m *equalsMatcher) Matches(candidate interface{}) error { - e := m.expectedValue - c := reflect.ValueOf(candidate) - ek := e.Kind() - - switch { - case ek == reflect.Bool: - return checkAgainstBool(e.Bool(), c) - - case isSignedInteger(e): - return checkAgainstInt64(e.Int(), c) - - case isUnsignedInteger(e): - return checkAgainstUint64(e.Uint(), c) - - case ek == reflect.Float32: - return checkAgainstFloat32(float32(e.Float()), c) - - case ek == reflect.Float64: - return checkAgainstFloat64(e.Float(), c) - - case ek == reflect.Complex64: - return checkAgainstComplex64(complex64(e.Complex()), c) - - case ek == reflect.Complex128: - return checkAgainstComplex128(complex128(e.Complex()), c) - - case ek == reflect.Chan: - return checkAgainstChan(e, c) - - case ek == reflect.Func: - return checkAgainstFunc(e, c) - - case ek == reflect.Map: - return checkAgainstMap(e, c) - - case ek == reflect.Ptr: - return checkAgainstPtr(e, c) - - case ek == reflect.Slice: - return checkAgainstSlice(e, c) - - case ek == reflect.String: - return checkAgainstString(e, c) - - case ek == reflect.Array: - return checkAgainstArray(e, c) - - case ek == reflect.UnsafePointer: - return checkAgainstUnsafePointer(e, c) - - case ek == reflect.Invalid: - return checkForNil(c) - } - - panic(fmt.Sprintf("equalsMatcher.Matches: unexpected kind: %v", ek)) -} - -func (m *equalsMatcher) Description() string { - // Special case: handle nil. - if !m.expectedValue.IsValid() { - return "is nil" - } - - return fmt.Sprintf("%v", m.expectedValue.Interface()) -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/error.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/error.go deleted file mode 100644 index 8a078e36d8..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/error.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -// Error returns a matcher that matches non-nil values implementing the -// built-in error interface for whom the return value of Error() matches the -// supplied matcher. -// -// For example: -// -// err := errors.New("taco burrito") -// -// Error(Equals("taco burrito")) // matches err -// Error(HasSubstr("taco")) // matches err -// Error(HasSubstr("enchilada")) // doesn't match err -// -func Error(m Matcher) Matcher { - return &errorMatcher{m} -} - -type errorMatcher struct { - wrappedMatcher Matcher -} - -func (m *errorMatcher) Description() string { - return "error " + m.wrappedMatcher.Description() -} - -func (m *errorMatcher) Matches(c interface{}) error { - // Make sure that c is an error. - e, ok := c.(error) - if !ok { - return NewFatalError("which is not an error") - } - - // Pass on the error text to the wrapped matcher. - return m.wrappedMatcher.Matches(e.Error()) -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal.go deleted file mode 100644 index 4b9d103a38..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "fmt" - "reflect" -) - -// GreaterOrEqual returns a matcher that matches integer, floating point, or -// strings values v such that v >= x. Comparison is not defined between numeric -// and string types, but is defined between all integer and floating point -// types. -// -// x must itself be an integer, floating point, or string type; otherwise, -// GreaterOrEqual will panic. -func GreaterOrEqual(x interface{}) Matcher { - desc := fmt.Sprintf("greater than or equal to %v", x) - - // Special case: make it clear that strings are strings. - if reflect.TypeOf(x).Kind() == reflect.String { - desc = fmt.Sprintf("greater than or equal to \"%s\"", x) - } - - return transformDescription(Not(LessThan(x)), desc) -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/greater_than.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/greater_than.go deleted file mode 100644 index 3eef32178f..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/greater_than.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "fmt" - "reflect" -) - -// GreaterThan returns a matcher that matches integer, floating point, or -// strings values v such that v > x. Comparison is not defined between numeric -// and string types, but is defined between all integer and floating point -// types. -// -// x must itself be an integer, floating point, or string type; otherwise, -// GreaterThan will panic. -func GreaterThan(x interface{}) Matcher { - desc := fmt.Sprintf("greater than %v", x) - - // Special case: make it clear that strings are strings. - if reflect.TypeOf(x).Kind() == reflect.String { - desc = fmt.Sprintf("greater than \"%s\"", x) - } - - return transformDescription(Not(LessOrEqual(x)), desc) -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as.go deleted file mode 100644 index 3b286f7321..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2015 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "fmt" - "reflect" -) - -// HasSameTypeAs returns a matcher that matches values with exactly the same -// type as the supplied prototype. -func HasSameTypeAs(p interface{}) Matcher { - expected := reflect.TypeOf(p) - pred := func(c interface{}) error { - actual := reflect.TypeOf(c) - if actual != expected { - return fmt.Errorf("which has type %v", actual) - } - - return nil - } - - return NewMatcher(pred, fmt.Sprintf("has type %v", expected)) -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/has_substr.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/has_substr.go deleted file mode 100644 index bf5bd6ae6d..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/has_substr.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "reflect" - "strings" -) - -// HasSubstr returns a matcher that matches strings containing s as a -// substring. -func HasSubstr(s string) Matcher { - return NewMatcher( - func(c interface{}) error { return hasSubstr(s, c) }, - fmt.Sprintf("has substring \"%s\"", s)) -} - -func hasSubstr(needle string, c interface{}) error { - v := reflect.ValueOf(c) - if v.Kind() != reflect.String { - return NewFatalError("which is not a string") - } - - // Perform the substring search. - haystack := v.String() - if strings.Contains(haystack, needle) { - return nil - } - - return errors.New("") -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/identical_to.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/identical_to.go deleted file mode 100644 index ae6460ed96..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/identical_to.go +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "reflect" -) - -// Is the type comparable according to the definition here? -// -// http://weekly.golang.org/doc/go_spec.html#Comparison_operators -// -func isComparable(t reflect.Type) bool { - switch t.Kind() { - case reflect.Array: - return isComparable(t.Elem()) - - case reflect.Struct: - for i := 0; i < t.NumField(); i++ { - if !isComparable(t.Field(i).Type) { - return false - } - } - - return true - - case reflect.Slice, reflect.Map, reflect.Func: - return false - } - - return true -} - -// Should the supplied type be allowed as an argument to IdenticalTo? -func isLegalForIdenticalTo(t reflect.Type) (bool, error) { - // Allow the zero type. - if t == nil { - return true, nil - } - - // Reference types are always okay; we compare pointers. - switch t.Kind() { - case reflect.Slice, reflect.Map, reflect.Func, reflect.Chan: - return true, nil - } - - // Reject other non-comparable types. - if !isComparable(t) { - return false, errors.New(fmt.Sprintf("%v is not comparable", t)) - } - - return true, nil -} - -// IdenticalTo(x) returns a matcher that matches values v with type identical -// to x such that: -// -// 1. If v and x are of a reference type (slice, map, function, channel), then -// they are either both nil or are references to the same object. -// -// 2. Otherwise, if v and x are not of a reference type but have a valid type, -// then v == x. -// -// If v and x are both the invalid type (which results from the predeclared nil -// value, or from nil interface variables), then the matcher is satisfied. -// -// This function will panic if x is of a value type that is not comparable. For -// example, x cannot be an array of functions. -func IdenticalTo(x interface{}) Matcher { - t := reflect.TypeOf(x) - - // Reject illegal arguments. - if ok, err := isLegalForIdenticalTo(t); !ok { - panic("IdenticalTo: " + err.Error()) - } - - return &identicalToMatcher{x} -} - -type identicalToMatcher struct { - x interface{} -} - -func (m *identicalToMatcher) Description() string { - t := reflect.TypeOf(m.x) - return fmt.Sprintf("identical to <%v> %v", t, m.x) -} - -func (m *identicalToMatcher) Matches(c interface{}) error { - // Make sure the candidate's type is correct. - t := reflect.TypeOf(m.x) - if ct := reflect.TypeOf(c); t != ct { - return NewFatalError(fmt.Sprintf("which is of type %v", ct)) - } - - // Special case: two values of the invalid type are always identical. - if t == nil { - return nil - } - - // Handle reference types. - switch t.Kind() { - case reflect.Slice, reflect.Map, reflect.Func, reflect.Chan: - xv := reflect.ValueOf(m.x) - cv := reflect.ValueOf(c) - if xv.Pointer() == cv.Pointer() { - return nil - } - - return errors.New("which is not an identical reference") - } - - // Are the values equal? - if m.x == c { - return nil - } - - return errors.New("") -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal.go deleted file mode 100644 index 8402cdeaf0..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "fmt" - "reflect" -) - -// LessOrEqual returns a matcher that matches integer, floating point, or -// strings values v such that v <= x. Comparison is not defined between numeric -// and string types, but is defined between all integer and floating point -// types. -// -// x must itself be an integer, floating point, or string type; otherwise, -// LessOrEqual will panic. -func LessOrEqual(x interface{}) Matcher { - desc := fmt.Sprintf("less than or equal to %v", x) - - // Special case: make it clear that strings are strings. - if reflect.TypeOf(x).Kind() == reflect.String { - desc = fmt.Sprintf("less than or equal to \"%s\"", x) - } - - // Put LessThan last so that its error messages will be used in the event of - // failure. - return transformDescription(AnyOf(Equals(x), LessThan(x)), desc) -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/less_than.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/less_than.go deleted file mode 100644 index 8258e45d99..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/less_than.go +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "math" - "reflect" -) - -// LessThan returns a matcher that matches integer, floating point, or strings -// values v such that v < x. Comparison is not defined between numeric and -// string types, but is defined between all integer and floating point types. -// -// x must itself be an integer, floating point, or string type; otherwise, -// LessThan will panic. -func LessThan(x interface{}) Matcher { - v := reflect.ValueOf(x) - kind := v.Kind() - - switch { - case isInteger(v): - case isFloat(v): - case kind == reflect.String: - - default: - panic(fmt.Sprintf("LessThan: unexpected kind %v", kind)) - } - - return &lessThanMatcher{v} -} - -type lessThanMatcher struct { - limit reflect.Value -} - -func (m *lessThanMatcher) Description() string { - // Special case: make it clear that strings are strings. - if m.limit.Kind() == reflect.String { - return fmt.Sprintf("less than \"%s\"", m.limit.String()) - } - - return fmt.Sprintf("less than %v", m.limit.Interface()) -} - -func compareIntegers(v1, v2 reflect.Value) (err error) { - err = errors.New("") - - switch { - case isSignedInteger(v1) && isSignedInteger(v2): - if v1.Int() < v2.Int() { - err = nil - } - return - - case isSignedInteger(v1) && isUnsignedInteger(v2): - if v1.Int() < 0 || uint64(v1.Int()) < v2.Uint() { - err = nil - } - return - - case isUnsignedInteger(v1) && isSignedInteger(v2): - if v1.Uint() <= math.MaxInt64 && int64(v1.Uint()) < v2.Int() { - err = nil - } - return - - case isUnsignedInteger(v1) && isUnsignedInteger(v2): - if v1.Uint() < v2.Uint() { - err = nil - } - return - } - - panic(fmt.Sprintf("compareIntegers: %v %v", v1, v2)) -} - -func getFloat(v reflect.Value) float64 { - switch { - case isSignedInteger(v): - return float64(v.Int()) - - case isUnsignedInteger(v): - return float64(v.Uint()) - - case isFloat(v): - return v.Float() - } - - panic(fmt.Sprintf("getFloat: %v", v)) -} - -func (m *lessThanMatcher) Matches(c interface{}) (err error) { - v1 := reflect.ValueOf(c) - v2 := m.limit - - err = errors.New("") - - // Handle strings as a special case. - if v1.Kind() == reflect.String && v2.Kind() == reflect.String { - if v1.String() < v2.String() { - err = nil - } - return - } - - // If we get here, we require that we are dealing with integers or floats. - v1Legal := isInteger(v1) || isFloat(v1) - v2Legal := isInteger(v2) || isFloat(v2) - if !v1Legal || !v2Legal { - err = NewFatalError("which is not comparable") - return - } - - // Handle the various comparison cases. - switch { - // Both integers - case isInteger(v1) && isInteger(v2): - return compareIntegers(v1, v2) - - // At least one float32 - case v1.Kind() == reflect.Float32 || v2.Kind() == reflect.Float32: - if float32(getFloat(v1)) < float32(getFloat(v2)) { - err = nil - } - return - - // At least one float64 - case v1.Kind() == reflect.Float64 || v2.Kind() == reflect.Float64: - if getFloat(v1) < getFloat(v2) { - err = nil - } - return - } - - // We shouldn't get here. - panic(fmt.Sprintf("lessThanMatcher.Matches: Shouldn't get here: %v %v", v1, v2)) -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/matcher.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/matcher.go deleted file mode 100644 index 78159a0727..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/matcher.go +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package oglematchers provides a set of matchers useful in a testing or -// mocking framework. These matchers are inspired by and mostly compatible with -// Google Test for C++ and Google JS Test. -// -// This package is used by github.com/smartystreets/assertions/internal/ogletest and -// github.com/smartystreets/assertions/internal/oglemock, which may be more directly useful if you're not -// writing your own testing package or defining your own matchers. -package oglematchers - -// A Matcher is some predicate implicitly defining a set of values that it -// matches. For example, GreaterThan(17) matches all numeric values greater -// than 17, and HasSubstr("taco") matches all strings with the substring -// "taco". -// -// Matchers are typically exposed to tests via constructor functions like -// HasSubstr. In order to implement such a function you can either define your -// own matcher type or use NewMatcher. -type Matcher interface { - // Check whether the supplied value belongs to the the set defined by the - // matcher. Return a non-nil error if and only if it does not. - // - // The error describes why the value doesn't match. The error text is a - // relative clause that is suitable for being placed after the value. For - // example, a predicate that matches strings with a particular substring may, - // when presented with a numerical value, return the following error text: - // - // "which is not a string" - // - // Then the failure message may look like: - // - // Expected: has substring "taco" - // Actual: 17, which is not a string - // - // If the error is self-apparent based on the description of the matcher, the - // error text may be empty (but the error still non-nil). For example: - // - // Expected: 17 - // Actual: 19 - // - // If you are implementing a new matcher, see also the documentation on - // FatalError. - Matches(candidate interface{}) error - - // Description returns a string describing the property that values matching - // this matcher have, as a verb phrase where the subject is the value. For - // example, "is greather than 17" or "has substring "taco"". - Description() string -} - -// FatalError is an implementation of the error interface that may be returned -// from matchers, indicating the error should be propagated. Returning a -// *FatalError indicates that the matcher doesn't process values of the -// supplied type, or otherwise doesn't know how to handle the value. -// -// For example, if GreaterThan(17) returned false for the value "taco" without -// a fatal error, then Not(GreaterThan(17)) would return true. This is -// technically correct, but is surprising and may mask failures where the wrong -// sort of matcher is accidentally used. Instead, GreaterThan(17) can return a -// fatal error, which will be propagated by Not(). -type FatalError struct { - errorText string -} - -// NewFatalError creates a FatalError struct with the supplied error text. -func NewFatalError(s string) *FatalError { - return &FatalError{s} -} - -func (e *FatalError) Error() string { - return e.errorText -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp.go deleted file mode 100644 index 1ed63f30c4..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp.go +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "reflect" - "regexp" -) - -// MatchesRegexp returns a matcher that matches strings and byte slices whose -// contents match the supplied regular expression. The semantics are those of -// regexp.Match. In particular, that means the match is not implicitly anchored -// to the ends of the string: MatchesRegexp("bar") will match "foo bar baz". -func MatchesRegexp(pattern string) Matcher { - re, err := regexp.Compile(pattern) - if err != nil { - panic("MatchesRegexp: " + err.Error()) - } - - return &matchesRegexpMatcher{re} -} - -type matchesRegexpMatcher struct { - re *regexp.Regexp -} - -func (m *matchesRegexpMatcher) Description() string { - return fmt.Sprintf("matches regexp \"%s\"", m.re.String()) -} - -func (m *matchesRegexpMatcher) Matches(c interface{}) (err error) { - v := reflect.ValueOf(c) - isString := v.Kind() == reflect.String - isByteSlice := v.Kind() == reflect.Slice && v.Elem().Kind() == reflect.Uint8 - - err = errors.New("") - - switch { - case isString: - if m.re.MatchString(v.String()) { - err = nil - } - - case isByteSlice: - if m.re.Match(v.Bytes()) { - err = nil - } - - default: - err = NewFatalError("which is not a string or []byte") - } - - return -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/new_matcher.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/new_matcher.go deleted file mode 100644 index c9d8398ee6..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/new_matcher.go +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2015 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -// Create a matcher with the given description and predicate function, which -// will be invoked to handle calls to Matchers. -// -// Using this constructor may be a convenience over defining your own type that -// implements Matcher if you do not need any logic in your Description method. -func NewMatcher( - predicate func(interface{}) error, - description string) Matcher { - return &predicateMatcher{ - predicate: predicate, - description: description, - } -} - -type predicateMatcher struct { - predicate func(interface{}) error - description string -} - -func (pm *predicateMatcher) Matches(c interface{}) error { - return pm.predicate(c) -} - -func (pm *predicateMatcher) Description() string { - return pm.description -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/not.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/not.go deleted file mode 100644 index 623789fe28..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/not.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" -) - -// Not returns a matcher that inverts the set of values matched by the wrapped -// matcher. It does not transform the result for values for which the wrapped -// matcher returns a fatal error. -func Not(m Matcher) Matcher { - return ¬Matcher{m} -} - -type notMatcher struct { - wrapped Matcher -} - -func (m *notMatcher) Matches(c interface{}) (err error) { - err = m.wrapped.Matches(c) - - // Did the wrapped matcher say yes? - if err == nil { - return errors.New("") - } - - // Did the wrapped matcher return a fatal error? - if _, isFatal := err.(*FatalError); isFatal { - return err - } - - // The wrapped matcher returned a non-fatal error. - return nil -} - -func (m *notMatcher) Description() string { - return fmt.Sprintf("not(%s)", m.wrapped.Description()) -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/panics.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/panics.go deleted file mode 100644 index d2cfc97869..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/panics.go +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "reflect" -) - -// Panics matches zero-arg functions which, when invoked, panic with an error -// that matches the supplied matcher. -// -// NOTE(jacobsa): This matcher cannot detect the case where the function panics -// using panic(nil), by design of the language. See here for more info: -// -// http://goo.gl/9aIQL -// -func Panics(m Matcher) Matcher { - return &panicsMatcher{m} -} - -type panicsMatcher struct { - wrappedMatcher Matcher -} - -func (m *panicsMatcher) Description() string { - return "panics with: " + m.wrappedMatcher.Description() -} - -func (m *panicsMatcher) Matches(c interface{}) (err error) { - // Make sure c is a zero-arg function. - v := reflect.ValueOf(c) - if v.Kind() != reflect.Func || v.Type().NumIn() != 0 { - err = NewFatalError("which is not a zero-arg function") - return - } - - // Call the function and check its panic error. - defer func() { - if e := recover(); e != nil { - err = m.wrappedMatcher.Matches(e) - - // Set a clearer error message if the matcher said no. - if err != nil { - wrappedClause := "" - if err.Error() != "" { - wrappedClause = ", " + err.Error() - } - - err = errors.New(fmt.Sprintf("which panicked with: %v%s", e, wrappedClause)) - } - } - }() - - v.Call([]reflect.Value{}) - - // If we get here, the function didn't panic. - err = errors.New("which didn't panic") - return -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/pointee.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/pointee.go deleted file mode 100644 index c5383f2402..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/pointee.go +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "reflect" -) - -// Return a matcher that matches non-nil pointers whose pointee matches the -// wrapped matcher. -func Pointee(m Matcher) Matcher { - return &pointeeMatcher{m} -} - -type pointeeMatcher struct { - wrapped Matcher -} - -func (m *pointeeMatcher) Matches(c interface{}) (err error) { - // Make sure the candidate is of the appropriate type. - cv := reflect.ValueOf(c) - if !cv.IsValid() || cv.Kind() != reflect.Ptr { - return NewFatalError("which is not a pointer") - } - - // Make sure the candidate is non-nil. - if cv.IsNil() { - return NewFatalError("") - } - - // Defer to the wrapped matcher. Fix up empty errors so that failure messages - // are more helpful than just printing a pointer for "Actual". - pointee := cv.Elem().Interface() - err = m.wrapped.Matches(pointee) - if err != nil && err.Error() == "" { - s := fmt.Sprintf("whose pointee is %v", pointee) - - if _, ok := err.(*FatalError); ok { - err = NewFatalError(s) - } else { - err = errors.New(s) - } - } - - return err -} - -func (m *pointeeMatcher) Description() string { - return fmt.Sprintf("pointee(%s)", m.wrapped.Description()) -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/transform_description.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/transform_description.go deleted file mode 100644 index f79d0c03db..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/transform_description.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -// transformDescription returns a matcher that is equivalent to the supplied -// one, except that it has the supplied description instead of the one attached -// to the existing matcher. -func transformDescription(m Matcher, newDesc string) Matcher { - return &transformDescriptionMatcher{newDesc, m} -} - -type transformDescriptionMatcher struct { - desc string - wrappedMatcher Matcher -} - -func (m *transformDescriptionMatcher) Description() string { - return m.desc -} - -func (m *transformDescriptionMatcher) Matches(c interface{}) error { - return m.wrappedMatcher.Matches(c) -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/messages.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/messages.go deleted file mode 100644 index 9c57ab2b8b..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/messages.go +++ /dev/null @@ -1,93 +0,0 @@ -package assertions - -const ( // equality - shouldHaveBeenEqual = "Expected: '%v'\nActual: '%v'\n(Should be equal)" - shouldNotHaveBeenEqual = "Expected '%v'\nto NOT equal '%v'\n(but it did)!" - shouldHaveBeenEqualTypeMismatch = "Expected: '%v' (%T)\nActual: '%v' (%T)\n(Should be equal, type mismatch)" - shouldHaveBeenAlmostEqual = "Expected '%v' to almost equal '%v' (but it didn't)!" - shouldHaveNotBeenAlmostEqual = "Expected '%v' to NOT almost equal '%v' (but it did)!" - shouldHaveResembled = "Expected: '%s'\nActual: '%s'\n(Should resemble)!" - shouldNotHaveResembled = "Expected '%#v'\nto NOT resemble '%#v'\n(but it did)!" - shouldBePointers = "Both arguments should be pointers " - shouldHaveBeenNonNilPointer = shouldBePointers + "(the %s was %s)!" - shouldHavePointedTo = "Expected '%+v' (address: '%v') and '%+v' (address: '%v') to be the same address (but their weren't)!" - shouldNotHavePointedTo = "Expected '%+v' and '%+v' to be different references (but they matched: '%v')!" - shouldHaveBeenNil = "Expected: nil\nActual: '%v'" - shouldNotHaveBeenNil = "Expected '%+v' to NOT be nil (but it was)!" - shouldHaveBeenTrue = "Expected: true\nActual: %v" - shouldHaveBeenFalse = "Expected: false\nActual: %v" - shouldHaveBeenZeroValue = "'%+v' should have been the zero value" //"Expected: (zero value)\nActual: %v" -) - -const ( // quantity comparisons - shouldHaveBeenGreater = "Expected '%v' to be greater than '%v' (but it wasn't)!" - shouldHaveBeenGreaterOrEqual = "Expected '%v' to be greater than or equal to '%v' (but it wasn't)!" - shouldHaveBeenLess = "Expected '%v' to be less than '%v' (but it wasn't)!" - shouldHaveBeenLessOrEqual = "Expected '%v' to be less than or equal to '%v' (but it wasn't)!" - shouldHaveBeenBetween = "Expected '%v' to be between '%v' and '%v' (but it wasn't)!" - shouldNotHaveBeenBetween = "Expected '%v' NOT to be between '%v' and '%v' (but it was)!" - shouldHaveDifferentUpperAndLower = "The lower and upper bounds must be different values (they were both '%v')." - shouldHaveBeenBetweenOrEqual = "Expected '%v' to be between '%v' and '%v' or equal to one of them (but it wasn't)!" - shouldNotHaveBeenBetweenOrEqual = "Expected '%v' NOT to be between '%v' and '%v' or equal to one of them (but it was)!" -) - -const ( // collections - shouldHaveContained = "Expected the container (%v) to contain: '%v' (but it didn't)!" - shouldNotHaveContained = "Expected the container (%v) NOT to contain: '%v' (but it did)!" - shouldHaveContainedKey = "Expected the %v to contain the key: %v (but it didn't)!" - shouldNotHaveContainedKey = "Expected the %v NOT to contain the key: %v (but it did)!" - shouldHaveBeenIn = "Expected '%v' to be in the container (%v), but it wasn't!" - shouldNotHaveBeenIn = "Expected '%v' NOT to be in the container (%v), but it was!" - shouldHaveBeenAValidCollection = "You must provide a valid container (was %v)!" - shouldHaveBeenAValidMap = "You must provide a valid map type (was %v)!" - shouldHaveBeenEmpty = "Expected %+v to be empty (but it wasn't)!" - shouldNotHaveBeenEmpty = "Expected %+v to NOT be empty (but it was)!" - shouldHaveBeenAValidInteger = "You must provide a valid integer (was %v)!" - shouldHaveBeenAValidLength = "You must provide a valid positive integer (was %v)!" - shouldHaveHadLength = "Expected %+v (length: %v) to have length equal to '%v', but it wasn't!" -) - -const ( // strings - shouldHaveStartedWith = "Expected '%v'\nto start with '%v'\n(but it didn't)!" - shouldNotHaveStartedWith = "Expected '%v'\nNOT to start with '%v'\n(but it did)!" - shouldHaveEndedWith = "Expected '%v'\nto end with '%v'\n(but it didn't)!" - shouldNotHaveEndedWith = "Expected '%v'\nNOT to end with '%v'\n(but it did)!" - shouldAllBeStrings = "All arguments to this assertion must be strings (you provided: %v)." - shouldBothBeStrings = "Both arguments to this assertion must be strings (you provided %v and %v)." - shouldBeString = "The argument to this assertion must be a string (you provided %v)." - shouldHaveContainedSubstring = "Expected '%s' to contain substring '%s' (but it didn't)!" - shouldNotHaveContainedSubstring = "Expected '%s' NOT to contain substring '%s' (but it did)!" - shouldHaveBeenBlank = "Expected '%s' to be blank (but it wasn't)!" - shouldNotHaveBeenBlank = "Expected value to NOT be blank (but it was)!" -) - -const ( // panics - shouldUseVoidNiladicFunction = "You must provide a void, niladic function as the first argument!" - shouldHavePanickedWith = "Expected func() to panic with '%v' (but it panicked with '%v')!" - shouldHavePanicked = "Expected func() to panic (but it didn't)!" - shouldNotHavePanicked = "Expected func() NOT to panic (error: '%+v')!" - shouldNotHavePanickedWith = "Expected func() NOT to panic with '%v' (but it did)!" -) - -const ( // type checking - shouldHaveBeenA = "Expected '%v' to be: '%v' (but was: '%v')!" - shouldNotHaveBeenA = "Expected '%v' to NOT be: '%v' (but it was)!" - - shouldHaveImplemented = "Expected: '%v interface support'\nActual: '%v' does not implement the interface!" - shouldNotHaveImplemented = "Expected '%v'\nto NOT implement '%v'\n(but it did)!" - shouldCompareWithInterfacePointer = "The expected value must be a pointer to an interface type (eg. *fmt.Stringer)" - shouldNotBeNilActual = "The actual value was 'nil' and should be a value or a pointer to a value!" -) - -const ( // time comparisons - shouldUseTimes = "You must provide time instances as arguments to this assertion." - shouldUseTimeSlice = "You must provide a slice of time instances as the first argument to this assertion." - shouldUseDurationAndTime = "You must provide a duration and a time as arguments to this assertion." - shouldHaveHappenedBefore = "Expected '%v' to happen before '%v' (it happened '%v' after)!" - shouldHaveHappenedAfter = "Expected '%v' to happen after '%v' (it happened '%v' before)!" - shouldHaveHappenedBetween = "Expected '%v' to happen between '%v' and '%v' (it happened '%v' outside threshold)!" - shouldNotHaveHappenedOnOrBetween = "Expected '%v' to NOT happen on or between '%v' and '%v' (but it did)!" - - // format params: incorrect-index, previous-index, previous-time, incorrect-index, incorrect-time - shouldHaveBeenChronological = "The 'Time' at index [%d] should have happened after the previous one (but it didn't!):\n [%d]: %s\n [%d]: %s (see, it happened before!)" -) diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/panic.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/panic.go deleted file mode 100644 index 7e75db1784..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/panic.go +++ /dev/null @@ -1,115 +0,0 @@ -package assertions - -import "fmt" - -// ShouldPanic receives a void, niladic function and expects to recover a panic. -func ShouldPanic(actual interface{}, expected ...interface{}) (message string) { - if fail := need(0, expected); fail != success { - return fail - } - - action, _ := actual.(func()) - - if action == nil { - message = shouldUseVoidNiladicFunction - return - } - - defer func() { - recovered := recover() - if recovered == nil { - message = shouldHavePanicked - } else { - message = success - } - }() - action() - - return -} - -// ShouldNotPanic receives a void, niladic function and expects to execute the function without any panic. -func ShouldNotPanic(actual interface{}, expected ...interface{}) (message string) { - if fail := need(0, expected); fail != success { - return fail - } - - action, _ := actual.(func()) - - if action == nil { - message = shouldUseVoidNiladicFunction - return - } - - defer func() { - recovered := recover() - if recovered != nil { - message = fmt.Sprintf(shouldNotHavePanicked, recovered) - } else { - message = success - } - }() - action() - - return -} - -// ShouldPanicWith receives a void, niladic function and expects to recover a panic with the second argument as the content. -func ShouldPanicWith(actual interface{}, expected ...interface{}) (message string) { - if fail := need(1, expected); fail != success { - return fail - } - - action, _ := actual.(func()) - - if action == nil { - message = shouldUseVoidNiladicFunction - return - } - - defer func() { - recovered := recover() - if recovered == nil { - message = shouldHavePanicked - } else { - if equal := ShouldEqual(recovered, expected[0]); equal != success { - message = serializer.serialize(expected[0], recovered, fmt.Sprintf(shouldHavePanickedWith, expected[0], recovered)) - } else { - message = success - } - } - }() - action() - - return -} - -// ShouldNotPanicWith receives a void, niladic function and expects to recover a panic whose content differs from the second argument. -func ShouldNotPanicWith(actual interface{}, expected ...interface{}) (message string) { - if fail := need(1, expected); fail != success { - return fail - } - - action, _ := actual.(func()) - - if action == nil { - message = shouldUseVoidNiladicFunction - return - } - - defer func() { - recovered := recover() - if recovered == nil { - message = success - } else { - if equal := ShouldEqual(recovered, expected[0]); equal == success { - message = fmt.Sprintf(shouldNotHavePanickedWith, expected[0]) - } else { - message = success - } - } - }() - action() - - return -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/quantity.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/quantity.go deleted file mode 100644 index f28b0a062b..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/quantity.go +++ /dev/null @@ -1,141 +0,0 @@ -package assertions - -import ( - "fmt" - - "github.com/smartystreets/assertions/internal/oglematchers" -) - -// ShouldBeGreaterThan receives exactly two parameters and ensures that the first is greater than the second. -func ShouldBeGreaterThan(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - if matchError := oglematchers.GreaterThan(expected[0]).Matches(actual); matchError != nil { - return fmt.Sprintf(shouldHaveBeenGreater, actual, expected[0]) - } - return success -} - -// ShouldBeGreaterThanOrEqualTo receives exactly two parameters and ensures that the first is greater than or equal to the second. -func ShouldBeGreaterThanOrEqualTo(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } else if matchError := oglematchers.GreaterOrEqual(expected[0]).Matches(actual); matchError != nil { - return fmt.Sprintf(shouldHaveBeenGreaterOrEqual, actual, expected[0]) - } - return success -} - -// ShouldBeLessThan receives exactly two parameters and ensures that the first is less than the second. -func ShouldBeLessThan(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } else if matchError := oglematchers.LessThan(expected[0]).Matches(actual); matchError != nil { - return fmt.Sprintf(shouldHaveBeenLess, actual, expected[0]) - } - return success -} - -// ShouldBeLessThan receives exactly two parameters and ensures that the first is less than or equal to the second. -func ShouldBeLessThanOrEqualTo(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } else if matchError := oglematchers.LessOrEqual(expected[0]).Matches(actual); matchError != nil { - return fmt.Sprintf(shouldHaveBeenLessOrEqual, actual, expected[0]) - } - return success -} - -// ShouldBeBetween receives exactly three parameters: an actual value, a lower bound, and an upper bound. -// It ensures that the actual value is between both bounds (but not equal to either of them). -func ShouldBeBetween(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - lower, upper, fail := deriveBounds(expected) - - if fail != success { - return fail - } else if !isBetween(actual, lower, upper) { - return fmt.Sprintf(shouldHaveBeenBetween, actual, lower, upper) - } - return success -} - -// ShouldNotBeBetween receives exactly three parameters: an actual value, a lower bound, and an upper bound. -// It ensures that the actual value is NOT between both bounds. -func ShouldNotBeBetween(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - lower, upper, fail := deriveBounds(expected) - - if fail != success { - return fail - } else if isBetween(actual, lower, upper) { - return fmt.Sprintf(shouldNotHaveBeenBetween, actual, lower, upper) - } - return success -} -func deriveBounds(values []interface{}) (lower interface{}, upper interface{}, fail string) { - lower = values[0] - upper = values[1] - - if ShouldNotEqual(lower, upper) != success { - return nil, nil, fmt.Sprintf(shouldHaveDifferentUpperAndLower, lower) - } else if ShouldBeLessThan(lower, upper) != success { - lower, upper = upper, lower - } - return lower, upper, success -} -func isBetween(value, lower, upper interface{}) bool { - if ShouldBeGreaterThan(value, lower) != success { - return false - } else if ShouldBeLessThan(value, upper) != success { - return false - } - return true -} - -// ShouldBeBetweenOrEqual receives exactly three parameters: an actual value, a lower bound, and an upper bound. -// It ensures that the actual value is between both bounds or equal to one of them. -func ShouldBeBetweenOrEqual(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - lower, upper, fail := deriveBounds(expected) - - if fail != success { - return fail - } else if !isBetweenOrEqual(actual, lower, upper) { - return fmt.Sprintf(shouldHaveBeenBetweenOrEqual, actual, lower, upper) - } - return success -} - -// ShouldNotBeBetweenOrEqual receives exactly three parameters: an actual value, a lower bound, and an upper bound. -// It ensures that the actual value is nopt between the bounds nor equal to either of them. -func ShouldNotBeBetweenOrEqual(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - lower, upper, fail := deriveBounds(expected) - - if fail != success { - return fail - } else if isBetweenOrEqual(actual, lower, upper) { - return fmt.Sprintf(shouldNotHaveBeenBetweenOrEqual, actual, lower, upper) - } - return success -} - -func isBetweenOrEqual(value, lower, upper interface{}) bool { - if ShouldBeGreaterThanOrEqualTo(value, lower) != success { - return false - } else if ShouldBeLessThanOrEqualTo(value, upper) != success { - return false - } - return true -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/serializer.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/serializer.go deleted file mode 100644 index 90ae3e3b69..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/serializer.go +++ /dev/null @@ -1,69 +0,0 @@ -package assertions - -import ( - "encoding/json" - "fmt" - - "github.com/smartystreets/assertions/internal/go-render/render" -) - -type Serializer interface { - serialize(expected, actual interface{}, message string) string - serializeDetailed(expected, actual interface{}, message string) string -} - -type failureSerializer struct{} - -func (self *failureSerializer) serializeDetailed(expected, actual interface{}, message string) string { - view := FailureView{ - Message: message, - Expected: render.Render(expected), - Actual: render.Render(actual), - } - serialized, err := json.Marshal(view) - if err != nil { - return message - } - return string(serialized) -} - -func (self *failureSerializer) serialize(expected, actual interface{}, message string) string { - view := FailureView{ - Message: message, - Expected: fmt.Sprintf("%+v", expected), - Actual: fmt.Sprintf("%+v", actual), - } - serialized, err := json.Marshal(view) - if err != nil { - return message - } - return string(serialized) -} - -func newSerializer() *failureSerializer { - return &failureSerializer{} -} - -/////////////////////////////////////////////////////////////////////////////// - -// This struct is also declared in github.com/smartystreets/goconvey/convey/reporting. -// The json struct tags should be equal in both declarations. -type FailureView struct { - Message string `json:"Message"` - Expected string `json:"Expected"` - Actual string `json:"Actual"` -} - -/////////////////////////////////////////////////////// - -// noopSerializer just gives back the original message. This is useful when we are using -// the assertions from a context other than the web UI, that requires the JSON structure -// provided by the failureSerializer. -type noopSerializer struct{} - -func (self *noopSerializer) serialize(expected, actual interface{}, message string) string { - return message -} -func (self *noopSerializer) serializeDetailed(expected, actual interface{}, message string) string { - return message -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/strings.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/strings.go deleted file mode 100644 index dbc3f04790..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/strings.go +++ /dev/null @@ -1,227 +0,0 @@ -package assertions - -import ( - "fmt" - "reflect" - "strings" -) - -// ShouldStartWith receives exactly 2 string parameters and ensures that the first starts with the second. -func ShouldStartWith(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - value, valueIsString := actual.(string) - prefix, prefixIsString := expected[0].(string) - - if !valueIsString || !prefixIsString { - return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) - } - - return shouldStartWith(value, prefix) -} -func shouldStartWith(value, prefix string) string { - if !strings.HasPrefix(value, prefix) { - shortval := value - if len(shortval) > len(prefix) { - shortval = shortval[:len(prefix)] + "..." - } - return serializer.serialize(prefix, shortval, fmt.Sprintf(shouldHaveStartedWith, value, prefix)) - } - return success -} - -// ShouldNotStartWith receives exactly 2 string parameters and ensures that the first does not start with the second. -func ShouldNotStartWith(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - value, valueIsString := actual.(string) - prefix, prefixIsString := expected[0].(string) - - if !valueIsString || !prefixIsString { - return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) - } - - return shouldNotStartWith(value, prefix) -} -func shouldNotStartWith(value, prefix string) string { - if strings.HasPrefix(value, prefix) { - if value == "" { - value = "" - } - if prefix == "" { - prefix = "" - } - return fmt.Sprintf(shouldNotHaveStartedWith, value, prefix) - } - return success -} - -// ShouldEndWith receives exactly 2 string parameters and ensures that the first ends with the second. -func ShouldEndWith(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - value, valueIsString := actual.(string) - suffix, suffixIsString := expected[0].(string) - - if !valueIsString || !suffixIsString { - return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) - } - - return shouldEndWith(value, suffix) -} -func shouldEndWith(value, suffix string) string { - if !strings.HasSuffix(value, suffix) { - shortval := value - if len(shortval) > len(suffix) { - shortval = "..." + shortval[len(shortval)-len(suffix):] - } - return serializer.serialize(suffix, shortval, fmt.Sprintf(shouldHaveEndedWith, value, suffix)) - } - return success -} - -// ShouldEndWith receives exactly 2 string parameters and ensures that the first does not end with the second. -func ShouldNotEndWith(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - value, valueIsString := actual.(string) - suffix, suffixIsString := expected[0].(string) - - if !valueIsString || !suffixIsString { - return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) - } - - return shouldNotEndWith(value, suffix) -} -func shouldNotEndWith(value, suffix string) string { - if strings.HasSuffix(value, suffix) { - if value == "" { - value = "" - } - if suffix == "" { - suffix = "" - } - return fmt.Sprintf(shouldNotHaveEndedWith, value, suffix) - } - return success -} - -// ShouldContainSubstring receives exactly 2 string parameters and ensures that the first contains the second as a substring. -func ShouldContainSubstring(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - long, longOk := actual.(string) - short, shortOk := expected[0].(string) - - if !longOk || !shortOk { - return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) - } - - if !strings.Contains(long, short) { - return serializer.serialize(expected[0], actual, fmt.Sprintf(shouldHaveContainedSubstring, long, short)) - } - return success -} - -// ShouldNotContainSubstring receives exactly 2 string parameters and ensures that the first does NOT contain the second as a substring. -func ShouldNotContainSubstring(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - long, longOk := actual.(string) - short, shortOk := expected[0].(string) - - if !longOk || !shortOk { - return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) - } - - if strings.Contains(long, short) { - return fmt.Sprintf(shouldNotHaveContainedSubstring, long, short) - } - return success -} - -// ShouldBeBlank receives exactly 1 string parameter and ensures that it is equal to "". -func ShouldBeBlank(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } - value, ok := actual.(string) - if !ok { - return fmt.Sprintf(shouldBeString, reflect.TypeOf(actual)) - } - if value != "" { - return serializer.serialize("", value, fmt.Sprintf(shouldHaveBeenBlank, value)) - } - return success -} - -// ShouldNotBeBlank receives exactly 1 string parameter and ensures that it is equal to "". -func ShouldNotBeBlank(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } - value, ok := actual.(string) - if !ok { - return fmt.Sprintf(shouldBeString, reflect.TypeOf(actual)) - } - if value == "" { - return shouldNotHaveBeenBlank - } - return success -} - -// ShouldEqualWithout receives exactly 3 string parameters and ensures that the first is equal to the second -// after removing all instances of the third from the first using strings.Replace(first, third, "", -1). -func ShouldEqualWithout(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - actualString, ok1 := actual.(string) - expectedString, ok2 := expected[0].(string) - replace, ok3 := expected[1].(string) - - if !ok1 || !ok2 || !ok3 { - return fmt.Sprintf(shouldAllBeStrings, []reflect.Type{ - reflect.TypeOf(actual), - reflect.TypeOf(expected[0]), - reflect.TypeOf(expected[1]), - }) - } - - replaced := strings.Replace(actualString, replace, "", -1) - if replaced == expectedString { - return "" - } - - return fmt.Sprintf("Expected '%s' to equal '%s' but without any '%s' (but it didn't).", actualString, expectedString, replace) -} - -// ShouldEqualTrimSpace receives exactly 2 string parameters and ensures that the first is equal to the second -// after removing all leading and trailing whitespace using strings.TrimSpace(first). -func ShouldEqualTrimSpace(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - actualString, valueIsString := actual.(string) - _, value2IsString := expected[0].(string) - - if !valueIsString || !value2IsString { - return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) - } - - actualString = strings.TrimSpace(actualString) - return ShouldEqual(actualString, expected[0]) -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/time.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/time.go deleted file mode 100644 index 7e05026143..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/time.go +++ /dev/null @@ -1,202 +0,0 @@ -package assertions - -import ( - "fmt" - "time" -) - -// ShouldHappenBefore receives exactly 2 time.Time arguments and asserts that the first happens before the second. -func ShouldHappenBefore(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - expectedTime, secondOk := expected[0].(time.Time) - - if !firstOk || !secondOk { - return shouldUseTimes - } - - if !actualTime.Before(expectedTime) { - return fmt.Sprintf(shouldHaveHappenedBefore, actualTime, expectedTime, actualTime.Sub(expectedTime)) - } - - return success -} - -// ShouldHappenOnOrBefore receives exactly 2 time.Time arguments and asserts that the first happens on or before the second. -func ShouldHappenOnOrBefore(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - expectedTime, secondOk := expected[0].(time.Time) - - if !firstOk || !secondOk { - return shouldUseTimes - } - - if actualTime.Equal(expectedTime) { - return success - } - return ShouldHappenBefore(actualTime, expectedTime) -} - -// ShouldHappenAfter receives exactly 2 time.Time arguments and asserts that the first happens after the second. -func ShouldHappenAfter(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - expectedTime, secondOk := expected[0].(time.Time) - - if !firstOk || !secondOk { - return shouldUseTimes - } - if !actualTime.After(expectedTime) { - return fmt.Sprintf(shouldHaveHappenedAfter, actualTime, expectedTime, expectedTime.Sub(actualTime)) - } - return success -} - -// ShouldHappenOnOrAfter receives exactly 2 time.Time arguments and asserts that the first happens on or after the second. -func ShouldHappenOnOrAfter(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - expectedTime, secondOk := expected[0].(time.Time) - - if !firstOk || !secondOk { - return shouldUseTimes - } - if actualTime.Equal(expectedTime) { - return success - } - return ShouldHappenAfter(actualTime, expectedTime) -} - -// ShouldHappenBetween receives exactly 3 time.Time arguments and asserts that the first happens between (not on) the second and third. -func ShouldHappenBetween(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - min, secondOk := expected[0].(time.Time) - max, thirdOk := expected[1].(time.Time) - - if !firstOk || !secondOk || !thirdOk { - return shouldUseTimes - } - - if !actualTime.After(min) { - return fmt.Sprintf(shouldHaveHappenedBetween, actualTime, min, max, min.Sub(actualTime)) - } - if !actualTime.Before(max) { - return fmt.Sprintf(shouldHaveHappenedBetween, actualTime, min, max, actualTime.Sub(max)) - } - return success -} - -// ShouldHappenOnOrBetween receives exactly 3 time.Time arguments and asserts that the first happens between or on the second and third. -func ShouldHappenOnOrBetween(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - min, secondOk := expected[0].(time.Time) - max, thirdOk := expected[1].(time.Time) - - if !firstOk || !secondOk || !thirdOk { - return shouldUseTimes - } - if actualTime.Equal(min) || actualTime.Equal(max) { - return success - } - return ShouldHappenBetween(actualTime, min, max) -} - -// ShouldNotHappenOnOrBetween receives exactly 3 time.Time arguments and asserts that the first -// does NOT happen between or on the second or third. -func ShouldNotHappenOnOrBetween(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - min, secondOk := expected[0].(time.Time) - max, thirdOk := expected[1].(time.Time) - - if !firstOk || !secondOk || !thirdOk { - return shouldUseTimes - } - if actualTime.Equal(min) || actualTime.Equal(max) { - return fmt.Sprintf(shouldNotHaveHappenedOnOrBetween, actualTime, min, max) - } - if actualTime.After(min) && actualTime.Before(max) { - return fmt.Sprintf(shouldNotHaveHappenedOnOrBetween, actualTime, min, max) - } - return success -} - -// ShouldHappenWithin receives a time.Time, a time.Duration, and a time.Time (3 arguments) -// and asserts that the first time.Time happens within or on the duration specified relative to -// the other time.Time. -func ShouldHappenWithin(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - tolerance, secondOk := expected[0].(time.Duration) - threshold, thirdOk := expected[1].(time.Time) - - if !firstOk || !secondOk || !thirdOk { - return shouldUseDurationAndTime - } - - min := threshold.Add(-tolerance) - max := threshold.Add(tolerance) - return ShouldHappenOnOrBetween(actualTime, min, max) -} - -// ShouldNotHappenWithin receives a time.Time, a time.Duration, and a time.Time (3 arguments) -// and asserts that the first time.Time does NOT happen within or on the duration specified relative to -// the other time.Time. -func ShouldNotHappenWithin(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - tolerance, secondOk := expected[0].(time.Duration) - threshold, thirdOk := expected[1].(time.Time) - - if !firstOk || !secondOk || !thirdOk { - return shouldUseDurationAndTime - } - - min := threshold.Add(-tolerance) - max := threshold.Add(tolerance) - return ShouldNotHappenOnOrBetween(actualTime, min, max) -} - -// ShouldBeChronological receives a []time.Time slice and asserts that the are -// in chronological order starting with the first time.Time as the earliest. -func ShouldBeChronological(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } - - times, ok := actual.([]time.Time) - if !ok { - return shouldUseTimeSlice - } - - var previous time.Time - for i, current := range times { - if i > 0 && current.Before(previous) { - return fmt.Sprintf(shouldHaveBeenChronological, - i, i-1, previous.String(), i, current.String()) - } - previous = current - } - return "" -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/type.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/type.go deleted file mode 100644 index 3fc00f68cd..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/type.go +++ /dev/null @@ -1,112 +0,0 @@ -package assertions - -import ( - "fmt" - "reflect" -) - -// ShouldHaveSameTypeAs receives exactly two parameters and compares their underlying types for equality. -func ShouldHaveSameTypeAs(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - first := reflect.TypeOf(actual) - second := reflect.TypeOf(expected[0]) - - if equal := ShouldEqual(first, second); equal != success { - return serializer.serialize(second, first, fmt.Sprintf(shouldHaveBeenA, actual, second, first)) - } - return success -} - -// ShouldNotHaveSameTypeAs receives exactly two parameters and compares their underlying types for inequality. -func ShouldNotHaveSameTypeAs(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - first := reflect.TypeOf(actual) - second := reflect.TypeOf(expected[0]) - - if equal := ShouldEqual(first, second); equal == success { - return fmt.Sprintf(shouldNotHaveBeenA, actual, second) - } - return success -} - -// ShouldImplement receives exactly two parameters and ensures -// that the first implements the interface type of the second. -func ShouldImplement(actual interface{}, expectedList ...interface{}) string { - if fail := need(1, expectedList); fail != success { - return fail - } - - expected := expectedList[0] - if fail := ShouldBeNil(expected); fail != success { - return shouldCompareWithInterfacePointer - } - - if fail := ShouldNotBeNil(actual); fail != success { - return shouldNotBeNilActual - } - - var actualType reflect.Type - if reflect.TypeOf(actual).Kind() != reflect.Ptr { - actualType = reflect.PtrTo(reflect.TypeOf(actual)) - } else { - actualType = reflect.TypeOf(actual) - } - - expectedType := reflect.TypeOf(expected) - if fail := ShouldNotBeNil(expectedType); fail != success { - return shouldCompareWithInterfacePointer - } - - expectedInterface := expectedType.Elem() - - if actualType == nil { - return fmt.Sprintf(shouldHaveImplemented, expectedInterface, actual) - } - - if !actualType.Implements(expectedInterface) { - return fmt.Sprintf(shouldHaveImplemented, expectedInterface, actualType) - } - return success -} - -// ShouldNotImplement receives exactly two parameters and ensures -// that the first does NOT implement the interface type of the second. -func ShouldNotImplement(actual interface{}, expectedList ...interface{}) string { - if fail := need(1, expectedList); fail != success { - return fail - } - - expected := expectedList[0] - if fail := ShouldBeNil(expected); fail != success { - return shouldCompareWithInterfacePointer - } - - if fail := ShouldNotBeNil(actual); fail != success { - return shouldNotBeNilActual - } - - var actualType reflect.Type - if reflect.TypeOf(actual).Kind() != reflect.Ptr { - actualType = reflect.PtrTo(reflect.TypeOf(actual)) - } else { - actualType = reflect.TypeOf(actual) - } - - expectedType := reflect.TypeOf(expected) - if fail := ShouldNotBeNil(expectedType); fail != success { - return shouldCompareWithInterfacePointer - } - - expectedInterface := expectedType.Elem() - - if actualType.Implements(expectedInterface) { - return fmt.Sprintf(shouldNotHaveImplemented, actualType, expectedInterface) - } - return success -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/LICENSE.md b/Godeps/_workspace/src/github.com/smartystreets/goconvey/LICENSE.md deleted file mode 100644 index 3f87a40e77..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/LICENSE.md +++ /dev/null @@ -1,23 +0,0 @@ -Copyright (c) 2016 SmartyStreets, LLC - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -NOTE: Various optional and subordinate components carry their own licensing -requirements and restrictions. Use of those components is subject to the terms -and conditions outlined the respective license of each component. diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/assertions.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/assertions.go deleted file mode 100644 index 1e87b826df..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/assertions.go +++ /dev/null @@ -1,68 +0,0 @@ -package convey - -import "github.com/smartystreets/assertions" - -var ( - ShouldEqual = assertions.ShouldEqual - ShouldNotEqual = assertions.ShouldNotEqual - ShouldAlmostEqual = assertions.ShouldAlmostEqual - ShouldNotAlmostEqual = assertions.ShouldNotAlmostEqual - ShouldResemble = assertions.ShouldResemble - ShouldNotResemble = assertions.ShouldNotResemble - ShouldPointTo = assertions.ShouldPointTo - ShouldNotPointTo = assertions.ShouldNotPointTo - ShouldBeNil = assertions.ShouldBeNil - ShouldNotBeNil = assertions.ShouldNotBeNil - ShouldBeTrue = assertions.ShouldBeTrue - ShouldBeFalse = assertions.ShouldBeFalse - ShouldBeZeroValue = assertions.ShouldBeZeroValue - - ShouldBeGreaterThan = assertions.ShouldBeGreaterThan - ShouldBeGreaterThanOrEqualTo = assertions.ShouldBeGreaterThanOrEqualTo - ShouldBeLessThan = assertions.ShouldBeLessThan - ShouldBeLessThanOrEqualTo = assertions.ShouldBeLessThanOrEqualTo - ShouldBeBetween = assertions.ShouldBeBetween - ShouldNotBeBetween = assertions.ShouldNotBeBetween - ShouldBeBetweenOrEqual = assertions.ShouldBeBetweenOrEqual - ShouldNotBeBetweenOrEqual = assertions.ShouldNotBeBetweenOrEqual - - ShouldContain = assertions.ShouldContain - ShouldNotContain = assertions.ShouldNotContain - ShouldContainKey = assertions.ShouldContainKey - ShouldNotContainKey = assertions.ShouldNotContainKey - ShouldBeIn = assertions.ShouldBeIn - ShouldNotBeIn = assertions.ShouldNotBeIn - ShouldBeEmpty = assertions.ShouldBeEmpty - ShouldNotBeEmpty = assertions.ShouldNotBeEmpty - ShouldHaveLength = assertions.ShouldHaveLength - - ShouldStartWith = assertions.ShouldStartWith - ShouldNotStartWith = assertions.ShouldNotStartWith - ShouldEndWith = assertions.ShouldEndWith - ShouldNotEndWith = assertions.ShouldNotEndWith - ShouldBeBlank = assertions.ShouldBeBlank - ShouldNotBeBlank = assertions.ShouldNotBeBlank - ShouldContainSubstring = assertions.ShouldContainSubstring - ShouldNotContainSubstring = assertions.ShouldNotContainSubstring - - ShouldPanic = assertions.ShouldPanic - ShouldNotPanic = assertions.ShouldNotPanic - ShouldPanicWith = assertions.ShouldPanicWith - ShouldNotPanicWith = assertions.ShouldNotPanicWith - - ShouldHaveSameTypeAs = assertions.ShouldHaveSameTypeAs - ShouldNotHaveSameTypeAs = assertions.ShouldNotHaveSameTypeAs - ShouldImplement = assertions.ShouldImplement - ShouldNotImplement = assertions.ShouldNotImplement - - ShouldHappenBefore = assertions.ShouldHappenBefore - ShouldHappenOnOrBefore = assertions.ShouldHappenOnOrBefore - ShouldHappenAfter = assertions.ShouldHappenAfter - ShouldHappenOnOrAfter = assertions.ShouldHappenOnOrAfter - ShouldHappenBetween = assertions.ShouldHappenBetween - ShouldHappenOnOrBetween = assertions.ShouldHappenOnOrBetween - ShouldNotHappenOnOrBetween = assertions.ShouldNotHappenOnOrBetween - ShouldHappenWithin = assertions.ShouldHappenWithin - ShouldNotHappenWithin = assertions.ShouldNotHappenWithin - ShouldBeChronological = assertions.ShouldBeChronological -) diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/context.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/context.go deleted file mode 100644 index 2c75c2d7b1..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/context.go +++ /dev/null @@ -1,272 +0,0 @@ -package convey - -import ( - "fmt" - - "github.com/jtolds/gls" - "github.com/smartystreets/goconvey/convey/reporting" -) - -type conveyErr struct { - fmt string - params []interface{} -} - -func (e *conveyErr) Error() string { - return fmt.Sprintf(e.fmt, e.params...) -} - -func conveyPanic(fmt string, params ...interface{}) { - panic(&conveyErr{fmt, params}) -} - -const ( - missingGoTest = `Top-level calls to Convey(...) need a reference to the *testing.T. - Hint: Convey("description here", t, func() { /* notice that the second argument was the *testing.T (t)! */ }) ` - extraGoTest = `Only the top-level call to Convey(...) needs a reference to the *testing.T.` - noStackContext = "Convey operation made without context on goroutine stack.\n" + - "Hint: Perhaps you meant to use `Convey(..., func(c C){...})` ?" - differentConveySituations = "Different set of Convey statements on subsequent pass!\nDid not expect %#v." - multipleIdenticalConvey = "Multiple convey suites with identical names: %#v" -) - -const ( - failureHalt = "___FAILURE_HALT___" - - nodeKey = "node" -) - -///////////////////////////////// Stack Context ///////////////////////////////// - -func getCurrentContext() *context { - ctx, ok := ctxMgr.GetValue(nodeKey) - if ok { - return ctx.(*context) - } - return nil -} - -func mustGetCurrentContext() *context { - ctx := getCurrentContext() - if ctx == nil { - conveyPanic(noStackContext) - } - return ctx -} - -//////////////////////////////////// Context //////////////////////////////////// - -// context magically handles all coordination of Convey's and So assertions. -// -// It is tracked on the stack as goroutine-local-storage with the gls package, -// or explicitly if the user decides to call convey like: -// -// Convey(..., func(c C) { -// c.So(...) -// }) -// -// This implements the `C` interface. -type context struct { - reporter reporting.Reporter - - children map[string]*context - - resets []func() - - executedOnce bool - expectChildRun *bool - complete bool - - focus bool - failureMode FailureMode -} - -// rootConvey is the main entry point to a test suite. This is called when -// there's no context in the stack already, and items must contain a `t` object, -// or this panics. -func rootConvey(items ...interface{}) { - entry := discover(items) - - if entry.Test == nil { - conveyPanic(missingGoTest) - } - - expectChildRun := true - ctx := &context{ - reporter: buildReporter(), - - children: make(map[string]*context), - - expectChildRun: &expectChildRun, - - focus: entry.Focus, - failureMode: defaultFailureMode.combine(entry.FailMode), - } - ctxMgr.SetValues(gls.Values{nodeKey: ctx}, func() { - ctx.reporter.BeginStory(reporting.NewStoryReport(entry.Test)) - defer ctx.reporter.EndStory() - - for ctx.shouldVisit() { - ctx.conveyInner(entry.Situation, entry.Func) - expectChildRun = true - } - }) -} - -//////////////////////////////////// Methods //////////////////////////////////// - -func (ctx *context) SkipConvey(items ...interface{}) { - ctx.Convey(items, skipConvey) -} - -func (ctx *context) FocusConvey(items ...interface{}) { - ctx.Convey(items, focusConvey) -} - -func (ctx *context) Convey(items ...interface{}) { - entry := discover(items) - - // we're a branch, or leaf (on the wind) - if entry.Test != nil { - conveyPanic(extraGoTest) - } - if ctx.focus && !entry.Focus { - return - } - - var inner_ctx *context - if ctx.executedOnce { - var ok bool - inner_ctx, ok = ctx.children[entry.Situation] - if !ok { - conveyPanic(differentConveySituations, entry.Situation) - } - } else { - if _, ok := ctx.children[entry.Situation]; ok { - conveyPanic(multipleIdenticalConvey, entry.Situation) - } - inner_ctx = &context{ - reporter: ctx.reporter, - - children: make(map[string]*context), - - expectChildRun: ctx.expectChildRun, - - focus: entry.Focus, - failureMode: ctx.failureMode.combine(entry.FailMode), - } - ctx.children[entry.Situation] = inner_ctx - } - - if inner_ctx.shouldVisit() { - ctxMgr.SetValues(gls.Values{nodeKey: inner_ctx}, func() { - inner_ctx.conveyInner(entry.Situation, entry.Func) - }) - } -} - -func (ctx *context) SkipSo(stuff ...interface{}) { - ctx.assertionReport(reporting.NewSkipReport()) -} - -func (ctx *context) So(actual interface{}, assert assertion, expected ...interface{}) { - if result := assert(actual, expected...); result == assertionSuccess { - ctx.assertionReport(reporting.NewSuccessReport()) - } else { - ctx.assertionReport(reporting.NewFailureReport(result)) - } -} - -func (ctx *context) Reset(action func()) { - /* TODO: Failure mode configuration */ - ctx.resets = append(ctx.resets, action) -} - -func (ctx *context) Print(items ...interface{}) (int, error) { - fmt.Fprint(ctx.reporter, items...) - return fmt.Print(items...) -} - -func (ctx *context) Println(items ...interface{}) (int, error) { - fmt.Fprintln(ctx.reporter, items...) - return fmt.Println(items...) -} - -func (ctx *context) Printf(format string, items ...interface{}) (int, error) { - fmt.Fprintf(ctx.reporter, format, items...) - return fmt.Printf(format, items...) -} - -//////////////////////////////////// Private //////////////////////////////////// - -// shouldVisit returns true iff we should traverse down into a Convey. Note -// that just because we don't traverse a Convey this time, doesn't mean that -// we may not traverse it on a subsequent pass. -func (c *context) shouldVisit() bool { - return !c.complete && *c.expectChildRun -} - -// conveyInner is the function which actually executes the user's anonymous test -// function body. At this point, Convey or RootConvey has decided that this -// function should actually run. -func (ctx *context) conveyInner(situation string, f func(C)) { - // Record/Reset state for next time. - defer func() { - ctx.executedOnce = true - - // This is only needed at the leaves, but there's no harm in also setting it - // when returning from branch Convey's - *ctx.expectChildRun = false - }() - - // Set up+tear down our scope for the reporter - ctx.reporter.Enter(reporting.NewScopeReport(situation)) - defer ctx.reporter.Exit() - - // Recover from any panics in f, and assign the `complete` status for this - // node of the tree. - defer func() { - ctx.complete = true - if problem := recover(); problem != nil { - if problem, ok := problem.(*conveyErr); ok { - panic(problem) - } - if problem != failureHalt { - ctx.reporter.Report(reporting.NewErrorReport(problem)) - } - } else { - for _, child := range ctx.children { - if !child.complete { - ctx.complete = false - return - } - } - } - }() - - // Resets are registered as the `f` function executes, so nil them here. - // All resets are run in registration order (FIFO). - ctx.resets = []func(){} - defer func() { - for _, r := range ctx.resets { - // panics handled by the previous defer - r() - } - }() - - if f == nil { - // if f is nil, this was either a Convey(..., nil), or a SkipConvey - ctx.reporter.Report(reporting.NewSkipReport()) - } else { - f(ctx) - } -} - -// assertionReport is a helper for So and SkipSo which makes the report and -// then possibly panics, depending on the current context's failureMode. -func (ctx *context) assertionReport(r *reporting.AssertionResult) { - ctx.reporter.Report(r) - if r.Failure != "" && ctx.failureMode == FailureHalts { - panic(failureHalt) - } -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/convey.goconvey b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/convey.goconvey deleted file mode 100644 index a2d9327dc9..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/convey.goconvey +++ /dev/null @@ -1,4 +0,0 @@ -#ignore --timeout=1s -#-covermode=count -#-coverpkg=github.com/smartystreets/goconvey/convey,github.com/smartystreets/goconvey/convey/gotest,github.com/smartystreets/goconvey/convey/reporting \ No newline at end of file diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/discovery.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/discovery.go deleted file mode 100644 index eb8d4cb2ce..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/discovery.go +++ /dev/null @@ -1,103 +0,0 @@ -package convey - -type actionSpecifier uint8 - -const ( - noSpecifier actionSpecifier = iota - skipConvey - focusConvey -) - -type suite struct { - Situation string - Test t - Focus bool - Func func(C) // nil means skipped - FailMode FailureMode -} - -func newSuite(situation string, failureMode FailureMode, f func(C), test t, specifier actionSpecifier) *suite { - ret := &suite{ - Situation: situation, - Test: test, - Func: f, - FailMode: failureMode, - } - switch specifier { - case skipConvey: - ret.Func = nil - case focusConvey: - ret.Focus = true - } - return ret -} - -func discover(items []interface{}) *suite { - name, items := parseName(items) - test, items := parseGoTest(items) - failure, items := parseFailureMode(items) - action, items := parseAction(items) - specifier, items := parseSpecifier(items) - - if len(items) != 0 { - conveyPanic(parseError) - } - - return newSuite(name, failure, action, test, specifier) -} -func item(items []interface{}) interface{} { - if len(items) == 0 { - conveyPanic(parseError) - } - return items[0] -} -func parseName(items []interface{}) (string, []interface{}) { - if name, parsed := item(items).(string); parsed { - return name, items[1:] - } - conveyPanic(parseError) - panic("never get here") -} -func parseGoTest(items []interface{}) (t, []interface{}) { - if test, parsed := item(items).(t); parsed { - return test, items[1:] - } - return nil, items -} -func parseFailureMode(items []interface{}) (FailureMode, []interface{}) { - if mode, parsed := item(items).(FailureMode); parsed { - return mode, items[1:] - } - return FailureInherits, items -} -func parseAction(items []interface{}) (func(C), []interface{}) { - switch x := item(items).(type) { - case nil: - return nil, items[1:] - case func(C): - return x, items[1:] - case func(): - return func(C) { x() }, items[1:] - } - conveyPanic(parseError) - panic("never get here") -} -func parseSpecifier(items []interface{}) (actionSpecifier, []interface{}) { - if len(items) == 0 { - return noSpecifier, items - } - if spec, ok := items[0].(actionSpecifier); ok { - return spec, items[1:] - } - conveyPanic(parseError) - panic("never get here") -} - -// This interface allows us to pass the *testing.T struct -// throughout the internals of this package without ever -// having to import the "testing" package. -type t interface { - Fail() -} - -const parseError = "You must provide a name (string), then a *testing.T (if in outermost scope), an optional FailureMode, and then an action (func())." diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/doc.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/doc.go deleted file mode 100644 index 2562ce4c28..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/doc.go +++ /dev/null @@ -1,218 +0,0 @@ -// Package convey contains all of the public-facing entry points to this project. -// This means that it should never be required of the user to import any other -// packages from this project as they serve internal purposes. -package convey - -import "github.com/smartystreets/goconvey/convey/reporting" - -////////////////////////////////// suite ////////////////////////////////// - -// C is the Convey context which you can optionally obtain in your action -// by calling Convey like: -// -// Convey(..., func(c C) { -// ... -// }) -// -// See the documentation on Convey for more details. -// -// All methods in this context behave identically to the global functions of the -// same name in this package. -type C interface { - Convey(items ...interface{}) - SkipConvey(items ...interface{}) - FocusConvey(items ...interface{}) - - So(actual interface{}, assert assertion, expected ...interface{}) - SkipSo(stuff ...interface{}) - - Reset(action func()) - - Println(items ...interface{}) (int, error) - Print(items ...interface{}) (int, error) - Printf(format string, items ...interface{}) (int, error) -} - -// Convey is the method intended for use when declaring the scopes of -// a specification. Each scope has a description and a func() which may contain -// other calls to Convey(), Reset() or Should-style assertions. Convey calls can -// be nested as far as you see fit. -// -// IMPORTANT NOTE: The top-level Convey() within a Test method -// must conform to the following signature: -// -// Convey(description string, t *testing.T, action func()) -// -// All other calls should look like this (no need to pass in *testing.T): -// -// Convey(description string, action func()) -// -// Don't worry, goconvey will panic if you get it wrong so you can fix it. -// -// Additionally, you may explicitly obtain access to the Convey context by doing: -// -// Convey(description string, action func(c C)) -// -// You may need to do this if you want to pass the context through to a -// goroutine, or to close over the context in a handler to a library which -// calls your handler in a goroutine (httptest comes to mind). -// -// All Convey()-blocks also accept an optional parameter of FailureMode which sets -// how goconvey should treat failures for So()-assertions in the block and -// nested blocks. See the constants in this file for the available options. -// -// By default it will inherit from its parent block and the top-level blocks -// default to the FailureHalts setting. -// -// This parameter is inserted before the block itself: -// -// Convey(description string, t *testing.T, mode FailureMode, action func()) -// Convey(description string, mode FailureMode, action func()) -// -// See the examples package for, well, examples. -func Convey(items ...interface{}) { - if ctx := getCurrentContext(); ctx == nil { - rootConvey(items...) - } else { - ctx.Convey(items...) - } -} - -// SkipConvey is analagous to Convey except that the scope is not executed -// (which means that child scopes defined within this scope are not run either). -// The reporter will be notified that this step was skipped. -func SkipConvey(items ...interface{}) { - Convey(append(items, skipConvey)...) -} - -// FocusConvey is has the inverse effect of SkipConvey. If the top-level -// Convey is changed to `FocusConvey`, only nested scopes that are defined -// with FocusConvey will be run. The rest will be ignored completely. This -// is handy when debugging a large suite that runs a misbehaving function -// repeatedly as you can disable all but one of that function -// without swaths of `SkipConvey` calls, just a targeted chain of calls -// to FocusConvey. -func FocusConvey(items ...interface{}) { - Convey(append(items, focusConvey)...) -} - -// Reset registers a cleanup function to be run after each Convey() -// in the same scope. See the examples package for a simple use case. -func Reset(action func()) { - mustGetCurrentContext().Reset(action) -} - -/////////////////////////////////// Assertions /////////////////////////////////// - -// assertion is an alias for a function with a signature that the convey.So() -// method can handle. Any future or custom assertions should conform to this -// method signature. The return value should be an empty string if the assertion -// passes and a well-formed failure message if not. -type assertion func(actual interface{}, expected ...interface{}) string - -const assertionSuccess = "" - -// So is the means by which assertions are made against the system under test. -// The majority of exported names in the assertions package begin with the word -// 'Should' and describe how the first argument (actual) should compare with any -// of the final (expected) arguments. How many final arguments are accepted -// depends on the particular assertion that is passed in as the assert argument. -// See the examples package for use cases and the assertions package for -// documentation on specific assertion methods. A failing assertion will -// cause t.Fail() to be invoked--you should never call this method (or other -// failure-inducing methods) in your test code. Leave that to GoConvey. -func So(actual interface{}, assert assertion, expected ...interface{}) { - mustGetCurrentContext().So(actual, assert, expected...) -} - -// SkipSo is analagous to So except that the assertion that would have been passed -// to So is not executed and the reporter is notified that the assertion was skipped. -func SkipSo(stuff ...interface{}) { - mustGetCurrentContext().SkipSo() -} - -// FailureMode is a type which determines how the So() blocks should fail -// if their assertion fails. See constants further down for acceptable values -type FailureMode string - -const ( - - // FailureContinues is a failure mode which prevents failing - // So()-assertions from halting Convey-block execution, instead - // allowing the test to continue past failing So()-assertions. - FailureContinues FailureMode = "continue" - - // FailureHalts is the default setting for a top-level Convey()-block - // and will cause all failing So()-assertions to halt further execution - // in that test-arm and continue on to the next arm. - FailureHalts FailureMode = "halt" - - // FailureInherits is the default setting for failure-mode, it will - // default to the failure-mode of the parent block. You should never - // need to specify this mode in your tests.. - FailureInherits FailureMode = "inherits" -) - -func (f FailureMode) combine(other FailureMode) FailureMode { - if other == FailureInherits { - return f - } - return other -} - -var defaultFailureMode FailureMode = FailureHalts - -// SetDefaultFailureMode allows you to specify the default failure mode -// for all Convey blocks. It is meant to be used in an init function to -// allow the default mode to be changdd across all tests for an entire packgae -// but it can be used anywhere. -func SetDefaultFailureMode(mode FailureMode) { - if mode == FailureContinues || mode == FailureHalts { - defaultFailureMode = mode - } else { - panic("You may only use the constants named 'FailureContinues' and 'FailureHalts' as default failure modes.") - } -} - -//////////////////////////////////// Print functions //////////////////////////////////// - -// Print is analogous to fmt.Print (and it even calls fmt.Print). It ensures that -// output is aligned with the corresponding scopes in the web UI. -func Print(items ...interface{}) (written int, err error) { - return mustGetCurrentContext().Print(items...) -} - -// Print is analogous to fmt.Println (and it even calls fmt.Println). It ensures that -// output is aligned with the corresponding scopes in the web UI. -func Println(items ...interface{}) (written int, err error) { - return mustGetCurrentContext().Println(items...) -} - -// Print is analogous to fmt.Printf (and it even calls fmt.Printf). It ensures that -// output is aligned with the corresponding scopes in the web UI. -func Printf(format string, items ...interface{}) (written int, err error) { - return mustGetCurrentContext().Printf(format, items...) -} - -/////////////////////////////////////////////////////////////////////////////// - -// SuppressConsoleStatistics prevents automatic printing of console statistics. -// Calling PrintConsoleStatistics explicitly will force printing of statistics. -func SuppressConsoleStatistics() { - reporting.SuppressConsoleStatistics() -} - -// ConsoleStatistics may be called at any time to print assertion statistics. -// Generally, the best place to do this would be in a TestMain function, -// after all tests have been run. Something like this: -// -// func TestMain(m *testing.M) { -// convey.SuppressConsoleStatistics() -// result := m.Run() -// convey.PrintConsoleStatistics() -// os.Exit(result) -// } -// -func PrintConsoleStatistics() { - reporting.PrintConsoleStatistics() -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/gotest/utils.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/gotest/utils.go deleted file mode 100644 index 3a5c848a44..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/gotest/utils.go +++ /dev/null @@ -1,28 +0,0 @@ -// Package gotest contains internal functionality. Although this package -// contains one or more exported names it is not intended for public -// consumption. See the examples package for how to use this project. -package gotest - -import ( - "runtime" - "strings" -) - -func ResolveExternalCaller() (file string, line int, name string) { - var caller_id uintptr - callers := runtime.Callers(0, callStack) - - for x := 0; x < callers; x++ { - caller_id, file, line, _ = runtime.Caller(x) - if strings.HasSuffix(file, "_test.go") || strings.HasSuffix(file, "_tests.go") { - name = runtime.FuncForPC(caller_id).Name() - return - } - } - file, line, name = "", -1, "" - return // panic? -} - -const maxStackDepth = 100 // This had better be enough... - -var callStack []uintptr = make([]uintptr, maxStackDepth, maxStackDepth) diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/init.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/init.go deleted file mode 100644 index 1d77ff3dcd..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/init.go +++ /dev/null @@ -1,81 +0,0 @@ -package convey - -import ( - "flag" - "os" - - "github.com/jtolds/gls" - "github.com/smartystreets/assertions" - "github.com/smartystreets/goconvey/convey/reporting" -) - -func init() { - assertions.GoConveyMode(true) - - declareFlags() - - ctxMgr = gls.NewContextManager() -} - -func declareFlags() { - flag.BoolVar(&json, "convey-json", false, "When true, emits results in JSON blocks. Default: 'false'") - flag.BoolVar(&silent, "convey-silent", false, "When true, all output from GoConvey is suppressed.") - flag.BoolVar(&story, "convey-story", false, "When true, emits story output, otherwise emits dot output. When not provided, this flag mirros the value of the '-test.v' flag") - - if noStoryFlagProvided() { - story = verboseEnabled - } - - // FYI: flag.Parse() is called from the testing package. -} - -func noStoryFlagProvided() bool { - return !story && !storyDisabled -} - -func buildReporter() reporting.Reporter { - selectReporter := os.Getenv("GOCONVEY_REPORTER") - - switch { - case testReporter != nil: - return testReporter - case json || selectReporter == "json": - return reporting.BuildJsonReporter() - case silent || selectReporter == "silent": - return reporting.BuildSilentReporter() - case selectReporter == "dot": - // Story is turned on when verbose is set, so we need to check for dot reporter first. - return reporting.BuildDotReporter() - case story || selectReporter == "story": - return reporting.BuildStoryReporter() - default: - return reporting.BuildDotReporter() - } -} - -var ( - ctxMgr *gls.ContextManager - - // only set by internal tests - testReporter reporting.Reporter -) - -var ( - json bool - silent bool - story bool - - verboseEnabled = flagFound("-test.v=true") - storyDisabled = flagFound("-story=false") -) - -// flagFound parses the command line args manually for flags defined in other -// packages. Like the '-v' flag from the "testing" package, for instance. -func flagFound(flagValue string) bool { - for _, arg := range os.Args { - if arg == flagValue { - return true - } - } - return false -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/nilReporter.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/nilReporter.go deleted file mode 100644 index 777b2a5122..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/nilReporter.go +++ /dev/null @@ -1,15 +0,0 @@ -package convey - -import ( - "github.com/smartystreets/goconvey/convey/reporting" -) - -type nilReporter struct{} - -func (self *nilReporter) BeginStory(story *reporting.StoryReport) {} -func (self *nilReporter) Enter(scope *reporting.ScopeReport) {} -func (self *nilReporter) Report(report *reporting.AssertionResult) {} -func (self *nilReporter) Exit() {} -func (self *nilReporter) EndStory() {} -func (self *nilReporter) Write(p []byte) (int, error) { return len(p), nil } -func newNilReporter() *nilReporter { return &nilReporter{} } diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/console.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/console.go deleted file mode 100644 index 7bf67dbb2b..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/console.go +++ /dev/null @@ -1,16 +0,0 @@ -package reporting - -import ( - "fmt" - "io" -) - -type console struct{} - -func (self *console) Write(p []byte) (n int, err error) { - return fmt.Print(string(p)) -} - -func NewConsole() io.Writer { - return new(console) -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/doc.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/doc.go deleted file mode 100644 index a37d001946..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/doc.go +++ /dev/null @@ -1,5 +0,0 @@ -// Package reporting contains internal functionality related -// to console reporting and output. Although this package has -// exported names is not intended for public consumption. See the -// examples package for how to use this project. -package reporting diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/dot.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/dot.go deleted file mode 100644 index 47d57c6b0d..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/dot.go +++ /dev/null @@ -1,40 +0,0 @@ -package reporting - -import "fmt" - -type dot struct{ out *Printer } - -func (self *dot) BeginStory(story *StoryReport) {} - -func (self *dot) Enter(scope *ScopeReport) {} - -func (self *dot) Report(report *AssertionResult) { - if report.Error != nil { - fmt.Print(redColor) - self.out.Insert(dotError) - } else if report.Failure != "" { - fmt.Print(yellowColor) - self.out.Insert(dotFailure) - } else if report.Skipped { - fmt.Print(yellowColor) - self.out.Insert(dotSkip) - } else { - fmt.Print(greenColor) - self.out.Insert(dotSuccess) - } - fmt.Print(resetColor) -} - -func (self *dot) Exit() {} - -func (self *dot) EndStory() {} - -func (self *dot) Write(content []byte) (written int, err error) { - return len(content), nil // no-op -} - -func NewDotReporter(out *Printer) *dot { - self := new(dot) - self.out = out - return self -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/gotest.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/gotest.go deleted file mode 100644 index c396e16b17..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/gotest.go +++ /dev/null @@ -1,33 +0,0 @@ -package reporting - -type gotestReporter struct{ test T } - -func (self *gotestReporter) BeginStory(story *StoryReport) { - self.test = story.Test -} - -func (self *gotestReporter) Enter(scope *ScopeReport) {} - -func (self *gotestReporter) Report(r *AssertionResult) { - if !passed(r) { - self.test.Fail() - } -} - -func (self *gotestReporter) Exit() {} - -func (self *gotestReporter) EndStory() { - self.test = nil -} - -func (self *gotestReporter) Write(content []byte) (written int, err error) { - return len(content), nil // no-op -} - -func NewGoTestReporter() *gotestReporter { - return new(gotestReporter) -} - -func passed(r *AssertionResult) bool { - return r.Error == nil && r.Failure == "" -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/init.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/init.go deleted file mode 100644 index 44d080e90e..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/init.go +++ /dev/null @@ -1,94 +0,0 @@ -package reporting - -import ( - "os" - "runtime" - "strings" -) - -func init() { - if !isColorableTerminal() { - monochrome() - } - - if runtime.GOOS == "windows" { - success, failure, error_ = dotSuccess, dotFailure, dotError - } -} - -func BuildJsonReporter() Reporter { - out := NewPrinter(NewConsole()) - return NewReporters( - NewGoTestReporter(), - NewJsonReporter(out)) -} -func BuildDotReporter() Reporter { - out := NewPrinter(NewConsole()) - return NewReporters( - NewGoTestReporter(), - NewDotReporter(out), - NewProblemReporter(out), - consoleStatistics) -} -func BuildStoryReporter() Reporter { - out := NewPrinter(NewConsole()) - return NewReporters( - NewGoTestReporter(), - NewStoryReporter(out), - NewProblemReporter(out), - consoleStatistics) -} -func BuildSilentReporter() Reporter { - out := NewPrinter(NewConsole()) - return NewReporters( - NewGoTestReporter(), - NewSilentProblemReporter(out)) -} - -var ( - newline = "\n" - success = "✔" - failure = "✘" - error_ = "🔥" - skip = "⚠" - dotSuccess = "." - dotFailure = "x" - dotError = "E" - dotSkip = "S" - errorTemplate = "* %s \nLine %d: - %v \n%s\n" - failureTemplate = "* %s \nLine %d:\n%s\n" -) - -var ( - greenColor = "\033[32m" - yellowColor = "\033[33m" - redColor = "\033[31m" - resetColor = "\033[0m" -) - -var consoleStatistics = NewStatisticsReporter(NewPrinter(NewConsole())) - -func SuppressConsoleStatistics() { consoleStatistics.Suppress() } -func PrintConsoleStatistics() { consoleStatistics.PrintSummary() } - -// QuiteMode disables all console output symbols. This is only meant to be used -// for tests that are internal to goconvey where the output is distracting or -// otherwise not needed in the test output. -func QuietMode() { - success, failure, error_, skip, dotSuccess, dotFailure, dotError, dotSkip = "", "", "", "", "", "", "", "" -} - -func monochrome() { - greenColor, yellowColor, redColor, resetColor = "", "", "", "" -} - -func isColorableTerminal() bool { - return strings.Contains(os.Getenv("TERM"), "color") -} - -// This interface allows us to pass the *testing.T struct -// throughout the internals of this tool without ever -// having to import the "testing" package. -type T interface { - Fail() -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/json.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/json.go deleted file mode 100644 index f8526979f8..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/json.go +++ /dev/null @@ -1,88 +0,0 @@ -// TODO: under unit test - -package reporting - -import ( - "bytes" - "encoding/json" - "fmt" - "strings" -) - -type JsonReporter struct { - out *Printer - currentKey []string - current *ScopeResult - index map[string]*ScopeResult - scopes []*ScopeResult -} - -func (self *JsonReporter) depth() int { return len(self.currentKey) } - -func (self *JsonReporter) BeginStory(story *StoryReport) {} - -func (self *JsonReporter) Enter(scope *ScopeReport) { - self.currentKey = append(self.currentKey, scope.Title) - ID := strings.Join(self.currentKey, "|") - if _, found := self.index[ID]; !found { - next := newScopeResult(scope.Title, self.depth(), scope.File, scope.Line) - self.scopes = append(self.scopes, next) - self.index[ID] = next - } - self.current = self.index[ID] -} - -func (self *JsonReporter) Report(report *AssertionResult) { - self.current.Assertions = append(self.current.Assertions, report) -} - -func (self *JsonReporter) Exit() { - self.currentKey = self.currentKey[:len(self.currentKey)-1] -} - -func (self *JsonReporter) EndStory() { - self.report() - self.reset() -} -func (self *JsonReporter) report() { - scopes := []string{} - for _, scope := range self.scopes { - serialized, err := json.Marshal(scope) - if err != nil { - self.out.Println(jsonMarshalFailure) - panic(err) - } - var buffer bytes.Buffer - json.Indent(&buffer, serialized, "", " ") - scopes = append(scopes, buffer.String()) - } - self.out.Print(fmt.Sprintf("%s\n%s,\n%s\n", OpenJson, strings.Join(scopes, ","), CloseJson)) -} -func (self *JsonReporter) reset() { - self.scopes = []*ScopeResult{} - self.index = map[string]*ScopeResult{} - self.currentKey = nil -} - -func (self *JsonReporter) Write(content []byte) (written int, err error) { - self.current.Output += string(content) - return len(content), nil -} - -func NewJsonReporter(out *Printer) *JsonReporter { - self := new(JsonReporter) - self.out = out - self.reset() - return self -} - -const OpenJson = ">->->OPEN-JSON->->->" // "⌦" -const CloseJson = "<-<-<-CLOSE-JSON<-<-<" // "⌫" -const jsonMarshalFailure = ` - -GOCONVEY_JSON_MARSHALL_FAILURE: There was an error when attempting to convert test results to JSON. -Please file a bug report and reference the code that caused this failure if possible. - -Here's the panic: - -` diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/printer.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/printer.go deleted file mode 100644 index 6d4a879c40..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/printer.go +++ /dev/null @@ -1,57 +0,0 @@ -package reporting - -import ( - "fmt" - "io" - "strings" -) - -type Printer struct { - out io.Writer - prefix string -} - -func (self *Printer) Println(message string, values ...interface{}) { - formatted := self.format(message, values...) + newline - self.out.Write([]byte(formatted)) -} - -func (self *Printer) Print(message string, values ...interface{}) { - formatted := self.format(message, values...) - self.out.Write([]byte(formatted)) -} - -func (self *Printer) Insert(text string) { - self.out.Write([]byte(text)) -} - -func (self *Printer) format(message string, values ...interface{}) string { - var formatted string - if len(values) == 0 { - formatted = self.prefix + message - } else { - formatted = self.prefix + fmt.Sprintf(message, values...) - } - indented := strings.Replace(formatted, newline, newline+self.prefix, -1) - return strings.TrimRight(indented, space) -} - -func (self *Printer) Indent() { - self.prefix += pad -} - -func (self *Printer) Dedent() { - if len(self.prefix) >= padLength { - self.prefix = self.prefix[:len(self.prefix)-padLength] - } -} - -func NewPrinter(out io.Writer) *Printer { - self := new(Printer) - self.out = out - return self -} - -const space = " " -const pad = space + space -const padLength = len(pad) diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/problems.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/problems.go deleted file mode 100644 index 9ae493ac3b..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/problems.go +++ /dev/null @@ -1,80 +0,0 @@ -package reporting - -import "fmt" - -type problem struct { - silent bool - out *Printer - errors []*AssertionResult - failures []*AssertionResult -} - -func (self *problem) BeginStory(story *StoryReport) {} - -func (self *problem) Enter(scope *ScopeReport) {} - -func (self *problem) Report(report *AssertionResult) { - if report.Error != nil { - self.errors = append(self.errors, report) - } else if report.Failure != "" { - self.failures = append(self.failures, report) - } -} - -func (self *problem) Exit() {} - -func (self *problem) EndStory() { - self.show(self.showErrors, redColor) - self.show(self.showFailures, yellowColor) - self.prepareForNextStory() -} -func (self *problem) show(display func(), color string) { - if !self.silent { - fmt.Print(color) - } - display() - if !self.silent { - fmt.Print(resetColor) - } - self.out.Dedent() -} -func (self *problem) showErrors() { - for i, e := range self.errors { - if i == 0 { - self.out.Println("\nErrors:\n") - self.out.Indent() - } - self.out.Println(errorTemplate, e.File, e.Line, e.Error, e.StackTrace) - } -} -func (self *problem) showFailures() { - for i, f := range self.failures { - if i == 0 { - self.out.Println("\nFailures:\n") - self.out.Indent() - } - self.out.Println(failureTemplate, f.File, f.Line, f.Failure) - } -} - -func (self *problem) Write(content []byte) (written int, err error) { - return len(content), nil // no-op -} - -func NewProblemReporter(out *Printer) *problem { - self := new(problem) - self.out = out - self.prepareForNextStory() - return self -} - -func NewSilentProblemReporter(out *Printer) *problem { - self := NewProblemReporter(out) - self.silent = true - return self -} - -func (self *problem) prepareForNextStory() { - self.errors = []*AssertionResult{} - self.failures = []*AssertionResult{} -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reporter.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reporter.go deleted file mode 100644 index cce6c5e438..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reporter.go +++ /dev/null @@ -1,39 +0,0 @@ -package reporting - -import "io" - -type Reporter interface { - BeginStory(story *StoryReport) - Enter(scope *ScopeReport) - Report(r *AssertionResult) - Exit() - EndStory() - io.Writer -} - -type reporters struct{ collection []Reporter } - -func (self *reporters) BeginStory(s *StoryReport) { self.foreach(func(r Reporter) { r.BeginStory(s) }) } -func (self *reporters) Enter(s *ScopeReport) { self.foreach(func(r Reporter) { r.Enter(s) }) } -func (self *reporters) Report(a *AssertionResult) { self.foreach(func(r Reporter) { r.Report(a) }) } -func (self *reporters) Exit() { self.foreach(func(r Reporter) { r.Exit() }) } -func (self *reporters) EndStory() { self.foreach(func(r Reporter) { r.EndStory() }) } - -func (self *reporters) Write(contents []byte) (written int, err error) { - self.foreach(func(r Reporter) { - written, err = r.Write(contents) - }) - return written, err -} - -func (self *reporters) foreach(action func(Reporter)) { - for _, r := range self.collection { - action(r) - } -} - -func NewReporters(collection ...Reporter) *reporters { - self := new(reporters) - self.collection = collection - return self -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reporting.goconvey b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reporting.goconvey deleted file mode 100644 index 79982854b5..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reporting.goconvey +++ /dev/null @@ -1,2 +0,0 @@ -#ignore --timeout=1s diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reports.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reports.go deleted file mode 100644 index 712e6ade62..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reports.go +++ /dev/null @@ -1,179 +0,0 @@ -package reporting - -import ( - "encoding/json" - "fmt" - "runtime" - "strings" - - "github.com/smartystreets/goconvey/convey/gotest" -) - -////////////////// ScopeReport //////////////////// - -type ScopeReport struct { - Title string - File string - Line int -} - -func NewScopeReport(title string) *ScopeReport { - file, line, _ := gotest.ResolveExternalCaller() - self := new(ScopeReport) - self.Title = title - self.File = file - self.Line = line - return self -} - -////////////////// ScopeResult //////////////////// - -type ScopeResult struct { - Title string - File string - Line int - Depth int - Assertions []*AssertionResult - Output string -} - -func newScopeResult(title string, depth int, file string, line int) *ScopeResult { - self := new(ScopeResult) - self.Title = title - self.Depth = depth - self.File = file - self.Line = line - self.Assertions = []*AssertionResult{} - return self -} - -/////////////////// StoryReport ///////////////////// - -type StoryReport struct { - Test T - Name string - File string - Line int -} - -func NewStoryReport(test T) *StoryReport { - file, line, name := gotest.ResolveExternalCaller() - name = removePackagePath(name) - self := new(StoryReport) - self.Test = test - self.Name = name - self.File = file - self.Line = line - return self -} - -// name comes in looking like "github.com/smartystreets/goconvey/examples.TestName". -// We only want the stuff after the last '.', which is the name of the test function. -func removePackagePath(name string) string { - parts := strings.Split(name, ".") - return parts[len(parts)-1] -} - -/////////////////// FailureView //////////////////////// - -// This struct is also declared in github.com/smartystreets/assertions. -// The json struct tags should be equal in both declarations. -type FailureView struct { - Message string `json:"Message"` - Expected string `json:"Expected"` - Actual string `json:"Actual"` -} - -////////////////////AssertionResult ////////////////////// - -type AssertionResult struct { - File string - Line int - Expected string - Actual string - Failure string - Error interface{} - StackTrace string - Skipped bool -} - -func NewFailureReport(failure string) *AssertionResult { - report := new(AssertionResult) - report.File, report.Line = caller() - report.StackTrace = stackTrace() - parseFailure(failure, report) - return report -} -func parseFailure(failure string, report *AssertionResult) { - view := new(FailureView) - err := json.Unmarshal([]byte(failure), view) - if err == nil { - report.Failure = view.Message - report.Expected = view.Expected - report.Actual = view.Actual - } else { - report.Failure = failure - } -} -func NewErrorReport(err interface{}) *AssertionResult { - report := new(AssertionResult) - report.File, report.Line = caller() - report.StackTrace = fullStackTrace() - report.Error = fmt.Sprintf("%v", err) - return report -} -func NewSuccessReport() *AssertionResult { - return new(AssertionResult) -} -func NewSkipReport() *AssertionResult { - report := new(AssertionResult) - report.File, report.Line = caller() - report.StackTrace = fullStackTrace() - report.Skipped = true - return report -} - -func caller() (file string, line int) { - file, line, _ = gotest.ResolveExternalCaller() - return -} - -func stackTrace() string { - buffer := make([]byte, 1024*64) - n := runtime.Stack(buffer, false) - return removeInternalEntries(string(buffer[:n])) -} -func fullStackTrace() string { - buffer := make([]byte, 1024*64) - n := runtime.Stack(buffer, true) - return removeInternalEntries(string(buffer[:n])) -} -func removeInternalEntries(stack string) string { - lines := strings.Split(stack, newline) - filtered := []string{} - for _, line := range lines { - if !isExternal(line) { - filtered = append(filtered, line) - } - } - return strings.Join(filtered, newline) -} -func isExternal(line string) bool { - for _, p := range internalPackages { - if strings.Contains(line, p) { - return true - } - } - return false -} - -// NOTE: any new packages that host goconvey packages will need to be added here! -// An alternative is to scan the goconvey directory and then exclude stuff like -// the examples package but that's nasty too. -var internalPackages = []string{ - "goconvey/assertions", - "goconvey/convey", - "goconvey/execution", - "goconvey/gotest", - "goconvey/reporting", -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/statistics.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/statistics.go deleted file mode 100644 index c3ccd056a0..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/statistics.go +++ /dev/null @@ -1,108 +0,0 @@ -package reporting - -import ( - "fmt" - "sync" -) - -func (self *statistics) BeginStory(story *StoryReport) {} - -func (self *statistics) Enter(scope *ScopeReport) {} - -func (self *statistics) Report(report *AssertionResult) { - self.Lock() - defer self.Unlock() - - if !self.failing && report.Failure != "" { - self.failing = true - } - if !self.erroring && report.Error != nil { - self.erroring = true - } - if report.Skipped { - self.skipped += 1 - } else { - self.total++ - } -} - -func (self *statistics) Exit() {} - -func (self *statistics) EndStory() { - self.Lock() - defer self.Unlock() - - if !self.suppressed { - self.printSummaryLocked() - } -} - -func (self *statistics) Suppress() { - self.Lock() - defer self.Unlock() - self.suppressed = true -} - -func (self *statistics) PrintSummary() { - self.Lock() - defer self.Unlock() - self.printSummaryLocked() -} - -func (self *statistics) printSummaryLocked() { - self.reportAssertionsLocked() - self.reportSkippedSectionsLocked() - self.completeReportLocked() -} -func (self *statistics) reportAssertionsLocked() { - self.decideColorLocked() - self.out.Print("\n%d total %s", self.total, plural("assertion", self.total)) -} -func (self *statistics) decideColorLocked() { - if self.failing && !self.erroring { - fmt.Print(yellowColor) - } else if self.erroring { - fmt.Print(redColor) - } else { - fmt.Print(greenColor) - } -} -func (self *statistics) reportSkippedSectionsLocked() { - if self.skipped > 0 { - fmt.Print(yellowColor) - self.out.Print(" (one or more sections skipped)") - } -} -func (self *statistics) completeReportLocked() { - fmt.Print(resetColor) - self.out.Print("\n") - self.out.Print("\n") -} - -func (self *statistics) Write(content []byte) (written int, err error) { - return len(content), nil // no-op -} - -func NewStatisticsReporter(out *Printer) *statistics { - self := statistics{} - self.out = out - return &self -} - -type statistics struct { - sync.Mutex - - out *Printer - total int - failing bool - erroring bool - skipped int - suppressed bool -} - -func plural(word string, count int) string { - if count == 1 { - return word - } - return word + "s" -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/story.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/story.go deleted file mode 100644 index 9e73c971f8..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/story.go +++ /dev/null @@ -1,73 +0,0 @@ -// TODO: in order for this reporter to be completely honest -// we need to retrofit to be more like the json reporter such that: -// 1. it maintains ScopeResult collections, which count assertions -// 2. it reports only after EndStory(), so that all tick marks -// are placed near the appropriate title. -// 3. Under unit test - -package reporting - -import ( - "fmt" - "strings" -) - -type story struct { - out *Printer - titlesById map[string]string - currentKey []string -} - -func (self *story) BeginStory(story *StoryReport) {} - -func (self *story) Enter(scope *ScopeReport) { - self.out.Indent() - - self.currentKey = append(self.currentKey, scope.Title) - ID := strings.Join(self.currentKey, "|") - - if _, found := self.titlesById[ID]; !found { - self.out.Println("") - self.out.Print(scope.Title) - self.out.Insert(" ") - self.titlesById[ID] = scope.Title - } -} - -func (self *story) Report(report *AssertionResult) { - if report.Error != nil { - fmt.Print(redColor) - self.out.Insert(error_) - } else if report.Failure != "" { - fmt.Print(yellowColor) - self.out.Insert(failure) - } else if report.Skipped { - fmt.Print(yellowColor) - self.out.Insert(skip) - } else { - fmt.Print(greenColor) - self.out.Insert(success) - } - fmt.Print(resetColor) -} - -func (self *story) Exit() { - self.out.Dedent() - self.currentKey = self.currentKey[:len(self.currentKey)-1] -} - -func (self *story) EndStory() { - self.titlesById = make(map[string]string) - self.out.Println("\n") -} - -func (self *story) Write(content []byte) (written int, err error) { - return len(content), nil // no-op -} - -func NewStoryReporter(out *Printer) *story { - self := new(story) - self.out = out - self.titlesById = make(map[string]string) - return self -} From 30b5fcd26cde187343de09923b10d527196f0f1c Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Wed, 25 May 2016 08:41:15 -0700 Subject: [PATCH 0314/1304] godep: update appc/spec to v0.8.3 --- Godeps/Godeps.json | 44 +++++++++---------- .../appc/spec/ace/image_manifest_main.json.in | 4 +- .../spec/ace/image_manifest_sidekick.json.in | 4 +- .../src/github.com/appc/spec/ace/validator.go | 16 ++++--- .../github.com/appc/spec/actool/manifest.go | 14 +++++- .../schema/types/isolator_linux_specific.go | 20 +++++++++ .../spec/schema/types/isolator_resources.go | 8 ++-- .../github.com/appc/spec/schema/version.go | 2 +- 8 files changed, 75 insertions(+), 37 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 1e59f33be5..7ebe374eff 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -163,58 +163,58 @@ }, { "ImportPath": "github.com/appc/spec/ace", - "Comment": "v0.8.1", - "Rev": "b889d03467ae08bb6c13241762a64305b69bcf82" + "Comment": "v0.8.3", + "Rev": "db96f94ae6b227fe4d8288527ead8927181620f6" }, { "ImportPath": "github.com/appc/spec/aci", - "Comment": "v0.8.1", - "Rev": "b889d03467ae08bb6c13241762a64305b69bcf82" + "Comment": "v0.8.3", + "Rev": "db96f94ae6b227fe4d8288527ead8927181620f6" }, { "ImportPath": "github.com/appc/spec/actool", - "Comment": "v0.8.1", - "Rev": "b889d03467ae08bb6c13241762a64305b69bcf82" + "Comment": "v0.8.3", + "Rev": "db96f94ae6b227fe4d8288527ead8927181620f6" }, { "ImportPath": "github.com/appc/spec/discovery", - "Comment": "v0.8.1", - "Rev": "b889d03467ae08bb6c13241762a64305b69bcf82" + "Comment": "v0.8.3", + "Rev": "db96f94ae6b227fe4d8288527ead8927181620f6" }, { "ImportPath": "github.com/appc/spec/pkg/acirenderer", - "Comment": "v0.8.1", - "Rev": "b889d03467ae08bb6c13241762a64305b69bcf82" + "Comment": "v0.8.3", + "Rev": "db96f94ae6b227fe4d8288527ead8927181620f6" }, { "ImportPath": "github.com/appc/spec/pkg/device", - "Comment": "v0.8.1", - "Rev": "b889d03467ae08bb6c13241762a64305b69bcf82" + "Comment": "v0.8.3", + "Rev": "db96f94ae6b227fe4d8288527ead8927181620f6" }, { "ImportPath": "github.com/appc/spec/pkg/tarheader", - "Comment": "v0.8.1", - "Rev": "b889d03467ae08bb6c13241762a64305b69bcf82" + "Comment": "v0.8.3", + "Rev": "db96f94ae6b227fe4d8288527ead8927181620f6" }, { "ImportPath": "github.com/appc/spec/schema", - "Comment": "v0.8.1", - "Rev": "b889d03467ae08bb6c13241762a64305b69bcf82" + "Comment": "v0.8.3", + "Rev": "db96f94ae6b227fe4d8288527ead8927181620f6" }, { "ImportPath": "github.com/appc/spec/schema/common", - "Comment": "v0.8.1", - "Rev": "b889d03467ae08bb6c13241762a64305b69bcf82" + "Comment": "v0.8.3", + "Rev": "db96f94ae6b227fe4d8288527ead8927181620f6" }, { "ImportPath": "github.com/appc/spec/schema/lastditch", - "Comment": "v0.8.1", - "Rev": "b889d03467ae08bb6c13241762a64305b69bcf82" + "Comment": "v0.8.3", + "Rev": "db96f94ae6b227fe4d8288527ead8927181620f6" }, { "ImportPath": "github.com/appc/spec/schema/types", - "Comment": "v0.8.1", - "Rev": "b889d03467ae08bb6c13241762a64305b69bcf82" + "Comment": "v0.8.3", + "Rev": "db96f94ae6b227fe4d8288527ead8927181620f6" }, { "ImportPath": "github.com/aws/aws-sdk-go/aws", diff --git a/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_main.json.in b/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_main.json.in index 511e2a5359..60e6417be7 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_main.json.in +++ b/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_main.json.in @@ -1,9 +1,9 @@ { - "acVersion": "0.8.1", + "acVersion": "0.8.3", "acKind": "ImageManifest", "name": "coreos.com/ace-validator-main", "labels": [ - { "name": "version", "value": "0.8.1" }, + { "name": "version", "value": "0.8.3" }, { "name": "os", "value": "@GOOS@" }, { "name": "arch", "value": "@GOARCH@" } ], diff --git a/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_sidekick.json.in b/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_sidekick.json.in index 9020e4f10d..ed09f46a6e 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_sidekick.json.in +++ b/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_sidekick.json.in @@ -1,9 +1,9 @@ { - "acVersion": "0.8.1", + "acVersion": "0.8.3", "acKind": "ImageManifest", "name": "coreos.com/ace-validator-sidekick", "labels": [ - { "name": "version", "value": "0.8.1" }, + { "name": "version", "value": "0.8.3" }, { "name": "os", "value": "@GOOS@" }, { "name": "arch", "value": "@GOARCH@" } ], diff --git a/Godeps/_workspace/src/github.com/appc/spec/ace/validator.go b/Godeps/_workspace/src/github.com/appc/spec/ace/validator.go index 420ae78897..fdd27ac222 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/ace/validator.go +++ b/Godeps/_workspace/src/github.com/appc/spec/ace/validator.go @@ -243,8 +243,8 @@ func metadataRequest(req *http.Request, expectedContentType string) ([]byte, err } if respContentType := resp.Header.Get("Content-Type"); respContentType != expectedContentType { - return nil, fmt.Errorf("`%s` did not respond with expected Content-Type header. Expected %s, received %s", - req.RequestURI, expectedContentType, respContentType) + return nil, fmt.Errorf("`%v` did not respond with expected Content-Type header. Expected %s, received %s", + req.URL, expectedContentType, respContentType) } body, err := ioutil.ReadAll(resp.Body) @@ -292,12 +292,12 @@ func validatePodAnnotations(metadataURL string, pm *schema.PodManifest) results var actualAnnots types.Annotations - annotJson, err := metadataGet(metadataURL, "/pod/annotations/", "application/json") + annotJson, err := metadataGet(metadataURL, "/pod/annotations", "application/json") if err != nil { return append(r, err) } - err = json.Unmarshal(annotJson, actualAnnots) + err = json.Unmarshal(annotJson, &actualAnnots) if err != nil { return append(r, err) } @@ -338,6 +338,9 @@ func validateAppAnnotations(metadataURL string, pm *schema.PodManifest, app *sch for _, annot := range a.Annotations { expectedAnnots.Set(annot.Name, annot.Value) } + if len(expectedAnnots) == 0 { + expectedAnnots = nil + } var actualAnnots types.Annotations @@ -346,10 +349,13 @@ func validateAppAnnotations(metadataURL string, pm *schema.PodManifest, app *sch return append(r, err) } - err = json.Unmarshal(annotJson, actualAnnots) + err = json.Unmarshal(annotJson, &actualAnnots) if err != nil { return append(r, err) } + if len(actualAnnots) == 0 { + actualAnnots = nil + } if !reflect.DeepEqual(actualAnnots, expectedAnnots) { err := fmt.Errorf("%v annotations mismatch: %v vs %v", app.Name, actualAnnots, expectedAnnots) diff --git a/Godeps/_workspace/src/github.com/appc/spec/actool/manifest.go b/Godeps/_workspace/src/github.com/appc/spec/actool/manifest.go index 94eff16a4c..46662167dc 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/actool/manifest.go +++ b/Godeps/_workspace/src/github.com/appc/spec/actool/manifest.go @@ -258,7 +258,19 @@ func patchManifest(im *schema.ImageManifest) error { return fmt.Errorf("cannot parse isolator %q: %v", is, err) } - if _, ok := types.ResourceIsolatorNames[name]; !ok { + _, ok := types.ResourceIsolatorNames[name] + + if name == types.LinuxNoNewPrivilegesName { + ok = true + kv := strings.Split(is, ",") + if len(kv) != 2 { + return fmt.Errorf("isolator %s: invalid format", name) + } + + isolatorStr = fmt.Sprintf(`{ "name": "%s", "value": %s }`, name, kv[1]) + } + + if !ok { return fmt.Errorf("isolator %s is not supported for patching", name) } diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/isolator_linux_specific.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/isolator_linux_specific.go index b390ed9187..678e0bf1f4 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/isolator_linux_specific.go +++ b/Godeps/_workspace/src/github.com/appc/spec/schema/types/isolator_linux_specific.go @@ -22,6 +22,7 @@ import ( const ( LinuxCapabilitiesRetainSetName = "os/linux/capabilities-retain-set" LinuxCapabilitiesRevokeSetName = "os/linux/capabilities-remove-set" + LinuxNoNewPrivilegesName = "os/linux/no-new-privileges" ) var LinuxIsolatorNames = make(map[ACIdentifier]struct{}) @@ -30,12 +31,31 @@ func init() { for name, con := range map[ACIdentifier]IsolatorValueConstructor{ LinuxCapabilitiesRevokeSetName: func() IsolatorValue { return &LinuxCapabilitiesRevokeSet{} }, LinuxCapabilitiesRetainSetName: func() IsolatorValue { return &LinuxCapabilitiesRetainSet{} }, + LinuxNoNewPrivilegesName: func() IsolatorValue { v := LinuxNoNewPrivileges(false); return &v }, } { AddIsolatorName(name, LinuxIsolatorNames) AddIsolatorValueConstructor(name, con) } } +type LinuxNoNewPrivileges bool + +func (l LinuxNoNewPrivileges) AssertValid() error { + return nil +} + +func (l *LinuxNoNewPrivileges) UnmarshalJSON(b []byte) error { + var v bool + err := json.Unmarshal(b, &v) + if err != nil { + return err + } + + *l = LinuxNoNewPrivileges(v) + + return nil +} + type LinuxCapabilitiesSet interface { Set() []LinuxCapability AssertValid() error diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/isolator_resources.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/isolator_resources.go index 2ac5130d1c..d97827b96f 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/isolator_resources.go +++ b/Godeps/_workspace/src/github.com/appc/spec/schema/types/isolator_resources.go @@ -155,8 +155,8 @@ func NewResourceCPUIsolator(request, limit string) (*ResourceCPU, error) { res := &ResourceCPU{ ResourceBase{ resourceValue{ - Request: req, - Limit: lim, + Request: &req, + Limit: &lim, }, }, } @@ -209,8 +209,8 @@ func NewResourceMemoryIsolator(request, limit string) (*ResourceMemory, error) { res := &ResourceMemory{ ResourceBase{ resourceValue{ - Request: req, - Limit: lim, + Request: &req, + Limit: &lim, }, }, } diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/version.go b/Godeps/_workspace/src/github.com/appc/spec/schema/version.go index eaa5f8bfdc..1cba342bb2 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/version.go +++ b/Godeps/_workspace/src/github.com/appc/spec/schema/version.go @@ -22,7 +22,7 @@ const ( // version represents the canonical version of the appc spec and tooling. // For now, the schema and tooling is coupled with the spec itself, so // this must be kept in sync with the VERSION file in the root of the repo. - version string = "0.8.1" + version string = "0.8.3" ) var ( From 1dffd7a96bea8ebe99cee468f0beddf838a0669b Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Wed, 25 May 2016 08:59:40 -0700 Subject: [PATCH 0315/1304] godep: update k8s.io/kubernetes to v1.3.0-alpha.4 --- Godeps/Godeps.json | 24 +- .../src/github.com/gogo/protobuf/LICENSE | 36 + .../github.com/gogo/protobuf/proto/Makefile | 43 + .../github.com/gogo/protobuf/proto/clone.go | 228 +++ .../github.com/gogo/protobuf/proto/decode.go | 872 +++++++++++ .../gogo/protobuf/proto/decode_gogo.go | 175 +++ .../github.com/gogo/protobuf/proto/encode.go | 1335 +++++++++++++++++ .../gogo/protobuf/proto/encode_gogo.go | 354 +++++ .../github.com/gogo/protobuf/proto/equal.go | 266 ++++ .../gogo/protobuf/proto/extensions.go | 519 +++++++ .../gogo/protobuf/proto/extensions_gogo.go | 221 +++ .../src/github.com/gogo/protobuf/proto/lib.go | 883 +++++++++++ .../gogo/protobuf/proto/lib_gogo.go | 40 + .../gogo/protobuf/proto/message_set.go | 280 ++++ .../gogo/protobuf/proto/pointer_reflect.go | 479 ++++++ .../gogo/protobuf/proto/pointer_unsafe.go | 266 ++++ .../protobuf/proto/pointer_unsafe_gogo.go | 108 ++ .../gogo/protobuf/proto/properties.go | 915 +++++++++++ .../gogo/protobuf/proto/properties_gogo.go | 64 + .../gogo/protobuf/proto/skip_gogo.go | 117 ++ .../github.com/gogo/protobuf/proto/text.go | 793 ++++++++++ .../gogo/protobuf/proto/text_gogo.go | 55 + .../gogo/protobuf/proto/text_parser.go | 841 +++++++++++ Godeps/_workspace/src/gopkg.in/inf.v0/LICENSE | 28 + .../math/dec/inf => gopkg.in/inf.v0}/dec.go | 0 .../dec/inf => gopkg.in/inf.v0}/rounder.go | 0 .../_workspace/src/k8s.io/kubernetes/LICENSE | 2 +- .../pkg/api/resource/deep_copy_generated.go | 55 + .../pkg/api/resource/generated.pb.go | 371 +++++ .../pkg/api/resource/generated.proto | 109 ++ .../kubernetes/pkg/api/resource/quantity.go | 166 +- .../pkg/api/resource/quantity_proto.go | 78 + .../kubernetes/pkg/api/resource/scale_int.go | 95 ++ .../kubernetes/pkg/api/resource/suffix.go | 4 +- .../k8s.io/kubernetes/pkg/conversion/OWNERS | 5 + .../kubernetes/pkg/conversion/cloner.go | 237 +++ .../kubernetes/pkg/conversion/converter.go | 951 ++++++++++++ .../pkg/conversion/deep_copy_generated.go | 185 +++ .../kubernetes/pkg/conversion/deep_equal.go | 36 + .../k8s.io/kubernetes/pkg/conversion/doc.go | 24 + .../kubernetes/pkg/conversion/helper.go | 39 + .../third_party/forked/reflect/LICENSE | 27 + .../third_party/forked/reflect/deep_equal.go | 388 +++++ .../speter.net/go/exp/math/dec/inf/LICENSE | 57 - 44 files changed, 11683 insertions(+), 88 deletions(-) create mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/LICENSE create mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/Makefile create mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/clone.go create mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/decode.go create mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/decode_gogo.go create mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/encode.go create mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/encode_gogo.go create mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/equal.go create mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/extensions.go create mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/extensions_gogo.go create mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/lib.go create mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/lib_gogo.go create mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/message_set.go create mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_reflect.go create mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_unsafe.go create mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_unsafe_gogo.go create mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/properties.go create mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/properties_gogo.go create mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/skip_gogo.go create mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/text.go create mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_gogo.go create mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_parser.go create mode 100644 Godeps/_workspace/src/gopkg.in/inf.v0/LICENSE rename Godeps/_workspace/src/{speter.net/go/exp/math/dec/inf => gopkg.in/inf.v0}/dec.go (100%) rename Godeps/_workspace/src/{speter.net/go/exp/math/dec/inf => gopkg.in/inf.v0}/rounder.go (100%) create mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/deep_copy_generated.go create mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/generated.pb.go create mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/generated.proto create mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/quantity_proto.go create mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/scale_int.go create mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/OWNERS create mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/cloner.go create mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/converter.go create mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/deep_copy_generated.go create mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/deep_equal.go create mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/doc.go create mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/helper.go create mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/third_party/forked/reflect/LICENSE create mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/third_party/forked/reflect/deep_equal.go delete mode 100644 Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/LICENSE diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 7ebe374eff..f671e155bd 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -405,6 +405,11 @@ "Comment": "v3-6-ga1b8ba5163b7", "Rev": "a1b8ba5163b7f041b22761461eabd02b70d1f824" }, + { + "ImportPath": "github.com/gogo/protobuf/proto", + "Comment": "v0.1-125-g82d16f7", + "Rev": "82d16f734d6d871204a3feb1a73cb220cc92574c" + }, { "ImportPath": "github.com/golang/protobuf/proto", "Rev": "2402d76f3d41f928c7902a765dfc872356dd3aad" @@ -647,14 +652,25 @@ "ImportPath": "google.golang.org/grpc/transport", "Rev": "5da22b92e9485c15a6b284d52cc54d6580864c99" }, + { + "ImportPath": "gopkg.in/inf.v0", + "Comment": "v0.9.0", + "Rev": "3887ee99ecf07df5b447e9b00d9c0b2adaa9f3e4" + }, { "ImportPath": "k8s.io/kubernetes/pkg/api/resource", - "Comment": "v0.12.0-270-g53ec66caf4e9", - "Rev": "53ec66caf4e952a1384ec93b9f0cde37616e4caf" + "Comment": "v1.3.0-alpha.4", + "Rev": "9990f843cd62caa90445cf76b07d63ba7b5c86fd" + }, + { + "ImportPath": "k8s.io/kubernetes/pkg/conversion", + "Comment": "v1.3.0-alpha.4", + "Rev": "9990f843cd62caa90445cf76b07d63ba7b5c86fd" }, { - "ImportPath": "speter.net/go/exp/math/dec/inf", - "Rev": "42ca6cd68aa922bc3f32f1e056e61b65945d9ad7" + "ImportPath": "k8s.io/kubernetes/third_party/forked/reflect", + "Comment": "v1.3.0-alpha.4", + "Rev": "9990f843cd62caa90445cf76b07d63ba7b5c86fd" } ] } diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/LICENSE b/Godeps/_workspace/src/github.com/gogo/protobuf/LICENSE new file mode 100644 index 0000000000..335e38e19b --- /dev/null +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/LICENSE @@ -0,0 +1,36 @@ +Extensions for Protocol Buffers to create more go like structures. + +Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. +http://github.com/gogo/protobuf/gogoproto + +Go support for Protocol Buffers - Google's data interchange format + +Copyright 2010 The Go Authors. All rights reserved. +https://github.com/golang/protobuf + +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. + diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/Makefile b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/Makefile new file mode 100644 index 0000000000..23a6b17344 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/Makefile @@ -0,0 +1,43 @@ +# Go support for Protocol Buffers - Google's data interchange format +# +# Copyright 2010 The Go Authors. All rights reserved. +# https://github.com/golang/protobuf +# +# 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. + +install: + go install + +test: install generate-test-pbs + go test + + +generate-test-pbs: + make install + make -C testdata + protoc-min-version --version="3.0.0" --proto_path=.:../../../../ --gogo_out=. proto3_proto/proto3.proto + make diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/clone.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/clone.go new file mode 100644 index 0000000000..79edb86119 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/clone.go @@ -0,0 +1,228 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2011 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +// Protocol buffer deep copy and merge. +// TODO: RawMessage. + +package proto + +import ( + "log" + "reflect" + "strings" +) + +// Clone returns a deep copy of a protocol buffer. +func Clone(pb Message) Message { + in := reflect.ValueOf(pb) + if in.IsNil() { + return pb + } + + out := reflect.New(in.Type().Elem()) + // out is empty so a merge is a deep copy. + mergeStruct(out.Elem(), in.Elem()) + return out.Interface().(Message) +} + +// Merge merges src into dst. +// Required and optional fields that are set in src will be set to that value in dst. +// Elements of repeated fields will be appended. +// Merge panics if src and dst are not the same type, or if dst is nil. +func Merge(dst, src Message) { + in := reflect.ValueOf(src) + out := reflect.ValueOf(dst) + if out.IsNil() { + panic("proto: nil destination") + } + if in.Type() != out.Type() { + // Explicit test prior to mergeStruct so that mistyped nils will fail + panic("proto: type mismatch") + } + if in.IsNil() { + // Merging nil into non-nil is a quiet no-op + return + } + mergeStruct(out.Elem(), in.Elem()) +} + +func mergeStruct(out, in reflect.Value) { + sprop := GetProperties(in.Type()) + for i := 0; i < in.NumField(); i++ { + f := in.Type().Field(i) + if strings.HasPrefix(f.Name, "XXX_") { + continue + } + mergeAny(out.Field(i), in.Field(i), false, sprop.Prop[i]) + } + + if emIn, ok := in.Addr().Interface().(extensionsMap); ok { + emOut := out.Addr().Interface().(extensionsMap) + mergeExtension(emOut.ExtensionMap(), emIn.ExtensionMap()) + } else if emIn, ok := in.Addr().Interface().(extensionsBytes); ok { + emOut := out.Addr().Interface().(extensionsBytes) + bIn := emIn.GetExtensions() + bOut := emOut.GetExtensions() + *bOut = append(*bOut, *bIn...) + } + + uf := in.FieldByName("XXX_unrecognized") + if !uf.IsValid() { + return + } + uin := uf.Bytes() + if len(uin) > 0 { + out.FieldByName("XXX_unrecognized").SetBytes(append([]byte(nil), uin...)) + } +} + +// mergeAny performs a merge between two values of the same type. +// viaPtr indicates whether the values were indirected through a pointer (implying proto2). +// prop is set if this is a struct field (it may be nil). +func mergeAny(out, in reflect.Value, viaPtr bool, prop *Properties) { + if in.Type() == protoMessageType { + if !in.IsNil() { + if out.IsNil() { + out.Set(reflect.ValueOf(Clone(in.Interface().(Message)))) + } else { + Merge(out.Interface().(Message), in.Interface().(Message)) + } + } + return + } + switch in.Kind() { + case reflect.Bool, reflect.Float32, reflect.Float64, reflect.Int32, reflect.Int64, + reflect.String, reflect.Uint32, reflect.Uint64: + if !viaPtr && isProto3Zero(in) { + return + } + out.Set(in) + case reflect.Interface: + // Probably a oneof field; copy non-nil values. + if in.IsNil() { + return + } + // Allocate destination if it is not set, or set to a different type. + // Otherwise we will merge as normal. + if out.IsNil() || out.Elem().Type() != in.Elem().Type() { + out.Set(reflect.New(in.Elem().Elem().Type())) // interface -> *T -> T -> new(T) + } + mergeAny(out.Elem(), in.Elem(), false, nil) + case reflect.Map: + if in.Len() == 0 { + return + } + if out.IsNil() { + out.Set(reflect.MakeMap(in.Type())) + } + // For maps with value types of *T or []byte we need to deep copy each value. + elemKind := in.Type().Elem().Kind() + for _, key := range in.MapKeys() { + var val reflect.Value + switch elemKind { + case reflect.Ptr: + val = reflect.New(in.Type().Elem().Elem()) + mergeAny(val, in.MapIndex(key), false, nil) + case reflect.Slice: + val = in.MapIndex(key) + val = reflect.ValueOf(append([]byte{}, val.Bytes()...)) + default: + val = in.MapIndex(key) + } + out.SetMapIndex(key, val) + } + case reflect.Ptr: + if in.IsNil() { + return + } + if out.IsNil() { + out.Set(reflect.New(in.Elem().Type())) + } + mergeAny(out.Elem(), in.Elem(), true, nil) + case reflect.Slice: + if in.IsNil() { + return + } + if in.Type().Elem().Kind() == reflect.Uint8 { + // []byte is a scalar bytes field, not a repeated field. + + // Edge case: if this is in a proto3 message, a zero length + // bytes field is considered the zero value, and should not + // be merged. + if prop != nil && prop.proto3 && in.Len() == 0 { + return + } + + // Make a deep copy. + // Append to []byte{} instead of []byte(nil) so that we never end up + // with a nil result. + out.SetBytes(append([]byte{}, in.Bytes()...)) + return + } + n := in.Len() + if out.IsNil() { + out.Set(reflect.MakeSlice(in.Type(), 0, n)) + } + switch in.Type().Elem().Kind() { + case reflect.Bool, reflect.Float32, reflect.Float64, reflect.Int32, reflect.Int64, + reflect.String, reflect.Uint32, reflect.Uint64: + out.Set(reflect.AppendSlice(out, in)) + default: + for i := 0; i < n; i++ { + x := reflect.Indirect(reflect.New(in.Type().Elem())) + mergeAny(x, in.Index(i), false, nil) + out.Set(reflect.Append(out, x)) + } + } + case reflect.Struct: + mergeStruct(out, in) + default: + // unknown type, so not a protocol buffer + log.Printf("proto: don't know how to copy %v", in) + } +} + +func mergeExtension(out, in map[int32]Extension) { + for extNum, eIn := range in { + eOut := Extension{desc: eIn.desc} + if eIn.value != nil { + v := reflect.New(reflect.TypeOf(eIn.value)).Elem() + mergeAny(v, reflect.ValueOf(eIn.value), false, nil) + eOut.value = v.Interface() + } + if eIn.enc != nil { + eOut.enc = make([]byte, len(eIn.enc)) + copy(eOut.enc, eIn.enc) + } + + out[extNum] = eOut + } +} diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/decode.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/decode.go new file mode 100644 index 0000000000..cb5b213f9b --- /dev/null +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/decode.go @@ -0,0 +1,872 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +package proto + +/* + * Routines for decoding protocol buffer data to construct in-memory representations. + */ + +import ( + "errors" + "fmt" + "io" + "os" + "reflect" +) + +// errOverflow is returned when an integer is too large to be represented. +var errOverflow = errors.New("proto: integer overflow") + +// ErrInternalBadWireType is returned by generated code when an incorrect +// wire type is encountered. It does not get returned to user code. +var ErrInternalBadWireType = errors.New("proto: internal error: bad wiretype for oneof") + +// The fundamental decoders that interpret bytes on the wire. +// Those that take integer types all return uint64 and are +// therefore of type valueDecoder. + +// DecodeVarint reads a varint-encoded integer from the slice. +// It returns the integer and the number of bytes consumed, or +// zero if there is not enough. +// This is the format for the +// int32, int64, uint32, uint64, bool, and enum +// protocol buffer types. +func DecodeVarint(buf []byte) (x uint64, n int) { + // x, n already 0 + for shift := uint(0); shift < 64; shift += 7 { + if n >= len(buf) { + return 0, 0 + } + b := uint64(buf[n]) + n++ + x |= (b & 0x7F) << shift + if (b & 0x80) == 0 { + return x, n + } + } + + // The number is too large to represent in a 64-bit value. + return 0, 0 +} + +// DecodeVarint reads a varint-encoded integer from the Buffer. +// This is the format for the +// int32, int64, uint32, uint64, bool, and enum +// protocol buffer types. +func (p *Buffer) DecodeVarint() (x uint64, err error) { + // x, err already 0 + + i := p.index + l := len(p.buf) + + for shift := uint(0); shift < 64; shift += 7 { + if i >= l { + err = io.ErrUnexpectedEOF + return + } + b := p.buf[i] + i++ + x |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + p.index = i + return + } + } + + // The number is too large to represent in a 64-bit value. + err = errOverflow + return +} + +// DecodeFixed64 reads a 64-bit integer from the Buffer. +// This is the format for the +// fixed64, sfixed64, and double protocol buffer types. +func (p *Buffer) DecodeFixed64() (x uint64, err error) { + // x, err already 0 + i := p.index + 8 + if i < 0 || i > len(p.buf) { + err = io.ErrUnexpectedEOF + return + } + p.index = i + + x = uint64(p.buf[i-8]) + x |= uint64(p.buf[i-7]) << 8 + x |= uint64(p.buf[i-6]) << 16 + x |= uint64(p.buf[i-5]) << 24 + x |= uint64(p.buf[i-4]) << 32 + x |= uint64(p.buf[i-3]) << 40 + x |= uint64(p.buf[i-2]) << 48 + x |= uint64(p.buf[i-1]) << 56 + return +} + +// DecodeFixed32 reads a 32-bit integer from the Buffer. +// This is the format for the +// fixed32, sfixed32, and float protocol buffer types. +func (p *Buffer) DecodeFixed32() (x uint64, err error) { + // x, err already 0 + i := p.index + 4 + if i < 0 || i > len(p.buf) { + err = io.ErrUnexpectedEOF + return + } + p.index = i + + x = uint64(p.buf[i-4]) + x |= uint64(p.buf[i-3]) << 8 + x |= uint64(p.buf[i-2]) << 16 + x |= uint64(p.buf[i-1]) << 24 + return +} + +// DecodeZigzag64 reads a zigzag-encoded 64-bit integer +// from the Buffer. +// This is the format used for the sint64 protocol buffer type. +func (p *Buffer) DecodeZigzag64() (x uint64, err error) { + x, err = p.DecodeVarint() + if err != nil { + return + } + x = (x >> 1) ^ uint64((int64(x&1)<<63)>>63) + return +} + +// DecodeZigzag32 reads a zigzag-encoded 32-bit integer +// from the Buffer. +// This is the format used for the sint32 protocol buffer type. +func (p *Buffer) DecodeZigzag32() (x uint64, err error) { + x, err = p.DecodeVarint() + if err != nil { + return + } + x = uint64((uint32(x) >> 1) ^ uint32((int32(x&1)<<31)>>31)) + return +} + +// These are not ValueDecoders: they produce an array of bytes or a string. +// bytes, embedded messages + +// DecodeRawBytes reads a count-delimited byte buffer from the Buffer. +// This is the format used for the bytes protocol buffer +// type and for embedded messages. +func (p *Buffer) DecodeRawBytes(alloc bool) (buf []byte, err error) { + n, err := p.DecodeVarint() + if err != nil { + return nil, err + } + + nb := int(n) + if nb < 0 { + return nil, fmt.Errorf("proto: bad byte length %d", nb) + } + end := p.index + nb + if end < p.index || end > len(p.buf) { + return nil, io.ErrUnexpectedEOF + } + + if !alloc { + // todo: check if can get more uses of alloc=false + buf = p.buf[p.index:end] + p.index += nb + return + } + + buf = make([]byte, nb) + copy(buf, p.buf[p.index:]) + p.index += nb + return +} + +// DecodeStringBytes reads an encoded string from the Buffer. +// This is the format used for the proto2 string type. +func (p *Buffer) DecodeStringBytes() (s string, err error) { + buf, err := p.DecodeRawBytes(false) + if err != nil { + return + } + return string(buf), nil +} + +// Skip the next item in the buffer. Its wire type is decoded and presented as an argument. +// If the protocol buffer has extensions, and the field matches, add it as an extension. +// Otherwise, if the XXX_unrecognized field exists, append the skipped data there. +func (o *Buffer) skipAndSave(t reflect.Type, tag, wire int, base structPointer, unrecField field) error { + oi := o.index + + err := o.skip(t, tag, wire) + if err != nil { + return err + } + + if !unrecField.IsValid() { + return nil + } + + ptr := structPointer_Bytes(base, unrecField) + + // Add the skipped field to struct field + obuf := o.buf + + o.buf = *ptr + o.EncodeVarint(uint64(tag<<3 | wire)) + *ptr = append(o.buf, obuf[oi:o.index]...) + + o.buf = obuf + + return nil +} + +// Skip the next item in the buffer. Its wire type is decoded and presented as an argument. +func (o *Buffer) skip(t reflect.Type, tag, wire int) error { + + var u uint64 + var err error + + switch wire { + case WireVarint: + _, err = o.DecodeVarint() + case WireFixed64: + _, err = o.DecodeFixed64() + case WireBytes: + _, err = o.DecodeRawBytes(false) + case WireFixed32: + _, err = o.DecodeFixed32() + case WireStartGroup: + for { + u, err = o.DecodeVarint() + if err != nil { + break + } + fwire := int(u & 0x7) + if fwire == WireEndGroup { + break + } + ftag := int(u >> 3) + err = o.skip(t, ftag, fwire) + if err != nil { + break + } + } + default: + err = fmt.Errorf("proto: can't skip unknown wire type %d for %s", wire, t) + } + return err +} + +// Unmarshaler is the interface representing objects that can +// unmarshal themselves. The method should reset the receiver before +// decoding starts. The argument points to data that may be +// overwritten, so implementations should not keep references to the +// buffer. +type Unmarshaler interface { + Unmarshal([]byte) error +} + +// Unmarshal parses the protocol buffer representation in buf and places the +// decoded result in pb. If the struct underlying pb does not match +// the data in buf, the results can be unpredictable. +// +// Unmarshal resets pb before starting to unmarshal, so any +// existing data in pb is always removed. Use UnmarshalMerge +// to preserve and append to existing data. +func Unmarshal(buf []byte, pb Message) error { + pb.Reset() + return UnmarshalMerge(buf, pb) +} + +// UnmarshalMerge parses the protocol buffer representation in buf and +// writes the decoded result to pb. If the struct underlying pb does not match +// the data in buf, the results can be unpredictable. +// +// UnmarshalMerge merges into existing data in pb. +// Most code should use Unmarshal instead. +func UnmarshalMerge(buf []byte, pb Message) error { + // If the object can unmarshal itself, let it. + if u, ok := pb.(Unmarshaler); ok { + return u.Unmarshal(buf) + } + return NewBuffer(buf).Unmarshal(pb) +} + +// DecodeMessage reads a count-delimited message from the Buffer. +func (p *Buffer) DecodeMessage(pb Message) error { + enc, err := p.DecodeRawBytes(false) + if err != nil { + return err + } + return NewBuffer(enc).Unmarshal(pb) +} + +// DecodeGroup reads a tag-delimited group from the Buffer. +func (p *Buffer) DecodeGroup(pb Message) error { + typ, base, err := getbase(pb) + if err != nil { + return err + } + return p.unmarshalType(typ.Elem(), GetProperties(typ.Elem()), true, base) +} + +// Unmarshal parses the protocol buffer representation in the +// Buffer and places the decoded result in pb. If the struct +// underlying pb does not match the data in the buffer, the results can be +// unpredictable. +func (p *Buffer) Unmarshal(pb Message) error { + // If the object can unmarshal itself, let it. + if u, ok := pb.(Unmarshaler); ok { + err := u.Unmarshal(p.buf[p.index:]) + p.index = len(p.buf) + return err + } + + typ, base, err := getbase(pb) + if err != nil { + return err + } + + err = p.unmarshalType(typ.Elem(), GetProperties(typ.Elem()), false, base) + + if collectStats { + stats.Decode++ + } + + return err +} + +// unmarshalType does the work of unmarshaling a structure. +func (o *Buffer) unmarshalType(st reflect.Type, prop *StructProperties, is_group bool, base structPointer) error { + var state errorState + required, reqFields := prop.reqCount, uint64(0) + + var err error + for err == nil && o.index < len(o.buf) { + oi := o.index + var u uint64 + u, err = o.DecodeVarint() + if err != nil { + break + } + wire := int(u & 0x7) + if wire == WireEndGroup { + if is_group { + return nil // input is satisfied + } + return fmt.Errorf("proto: %s: wiretype end group for non-group", st) + } + tag := int(u >> 3) + if tag <= 0 { + return fmt.Errorf("proto: %s: illegal tag %d (wire type %d)", st, tag, wire) + } + fieldnum, ok := prop.decoderTags.get(tag) + if !ok { + // Maybe it's an extension? + if prop.extendable { + if e := structPointer_Interface(base, st).(extendableProto); isExtensionField(e, int32(tag)) { + if err = o.skip(st, tag, wire); err == nil { + if ee, eok := e.(extensionsMap); eok { + ext := ee.ExtensionMap()[int32(tag)] // may be missing + ext.enc = append(ext.enc, o.buf[oi:o.index]...) + ee.ExtensionMap()[int32(tag)] = ext + } else if ee, eok := e.(extensionsBytes); eok { + ext := ee.GetExtensions() + *ext = append(*ext, o.buf[oi:o.index]...) + } + } + continue + } + } + // Maybe it's a oneof? + if prop.oneofUnmarshaler != nil { + m := structPointer_Interface(base, st).(Message) + // First return value indicates whether tag is a oneof field. + ok, err = prop.oneofUnmarshaler(m, tag, wire, o) + if err == ErrInternalBadWireType { + // Map the error to something more descriptive. + // Do the formatting here to save generated code space. + err = fmt.Errorf("bad wiretype for oneof field in %T", m) + } + if ok { + continue + } + } + err = o.skipAndSave(st, tag, wire, base, prop.unrecField) + continue + } + p := prop.Prop[fieldnum] + + if p.dec == nil { + fmt.Fprintf(os.Stderr, "proto: no protobuf decoder for %s.%s\n", st, st.Field(fieldnum).Name) + continue + } + dec := p.dec + if wire != WireStartGroup && wire != p.WireType { + if wire == WireBytes && p.packedDec != nil { + // a packable field + dec = p.packedDec + } else { + err = fmt.Errorf("proto: bad wiretype for field %s.%s: got wiretype %d, want %d", st, st.Field(fieldnum).Name, wire, p.WireType) + continue + } + } + decErr := dec(o, p, base) + if decErr != nil && !state.shouldContinue(decErr, p) { + err = decErr + } + if err == nil && p.Required { + // Successfully decoded a required field. + if tag <= 64 { + // use bitmap for fields 1-64 to catch field reuse. + var mask uint64 = 1 << uint64(tag-1) + if reqFields&mask == 0 { + // new required field + reqFields |= mask + required-- + } + } else { + // This is imprecise. It can be fooled by a required field + // with a tag > 64 that is encoded twice; that's very rare. + // A fully correct implementation would require allocating + // a data structure, which we would like to avoid. + required-- + } + } + } + if err == nil { + if is_group { + return io.ErrUnexpectedEOF + } + if state.err != nil { + return state.err + } + if required > 0 { + // Not enough information to determine the exact field. If we use extra + // CPU, we could determine the field only if the missing required field + // has a tag <= 64 and we check reqFields. + return &RequiredNotSetError{"{Unknown}"} + } + } + return err +} + +// Individual type decoders +// For each, +// u is the decoded value, +// v is a pointer to the field (pointer) in the struct + +// Sizes of the pools to allocate inside the Buffer. +// The goal is modest amortization and allocation +// on at least 16-byte boundaries. +const ( + boolPoolSize = 16 + uint32PoolSize = 8 + uint64PoolSize = 4 +) + +// Decode a bool. +func (o *Buffer) dec_bool(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + if len(o.bools) == 0 { + o.bools = make([]bool, boolPoolSize) + } + o.bools[0] = u != 0 + *structPointer_Bool(base, p.field) = &o.bools[0] + o.bools = o.bools[1:] + return nil +} + +func (o *Buffer) dec_proto3_bool(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + *structPointer_BoolVal(base, p.field) = u != 0 + return nil +} + +// Decode an int32. +func (o *Buffer) dec_int32(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + word32_Set(structPointer_Word32(base, p.field), o, uint32(u)) + return nil +} + +func (o *Buffer) dec_proto3_int32(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + word32Val_Set(structPointer_Word32Val(base, p.field), uint32(u)) + return nil +} + +// Decode an int64. +func (o *Buffer) dec_int64(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + word64_Set(structPointer_Word64(base, p.field), o, u) + return nil +} + +func (o *Buffer) dec_proto3_int64(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + word64Val_Set(structPointer_Word64Val(base, p.field), o, u) + return nil +} + +// Decode a string. +func (o *Buffer) dec_string(p *Properties, base structPointer) error { + s, err := o.DecodeStringBytes() + if err != nil { + return err + } + *structPointer_String(base, p.field) = &s + return nil +} + +func (o *Buffer) dec_proto3_string(p *Properties, base structPointer) error { + s, err := o.DecodeStringBytes() + if err != nil { + return err + } + *structPointer_StringVal(base, p.field) = s + return nil +} + +// Decode a slice of bytes ([]byte). +func (o *Buffer) dec_slice_byte(p *Properties, base structPointer) error { + b, err := o.DecodeRawBytes(true) + if err != nil { + return err + } + *structPointer_Bytes(base, p.field) = b + return nil +} + +// Decode a slice of bools ([]bool). +func (o *Buffer) dec_slice_bool(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + v := structPointer_BoolSlice(base, p.field) + *v = append(*v, u != 0) + return nil +} + +// Decode a slice of bools ([]bool) in packed format. +func (o *Buffer) dec_slice_packed_bool(p *Properties, base structPointer) error { + v := structPointer_BoolSlice(base, p.field) + + nn, err := o.DecodeVarint() + if err != nil { + return err + } + nb := int(nn) // number of bytes of encoded bools + fin := o.index + nb + if fin < o.index { + return errOverflow + } + + y := *v + for o.index < fin { + u, err := p.valDec(o) + if err != nil { + return err + } + y = append(y, u != 0) + } + + *v = y + return nil +} + +// Decode a slice of int32s ([]int32). +func (o *Buffer) dec_slice_int32(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + structPointer_Word32Slice(base, p.field).Append(uint32(u)) + return nil +} + +// Decode a slice of int32s ([]int32) in packed format. +func (o *Buffer) dec_slice_packed_int32(p *Properties, base structPointer) error { + v := structPointer_Word32Slice(base, p.field) + + nn, err := o.DecodeVarint() + if err != nil { + return err + } + nb := int(nn) // number of bytes of encoded int32s + + fin := o.index + nb + if fin < o.index { + return errOverflow + } + for o.index < fin { + u, err := p.valDec(o) + if err != nil { + return err + } + v.Append(uint32(u)) + } + return nil +} + +// Decode a slice of int64s ([]int64). +func (o *Buffer) dec_slice_int64(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + + structPointer_Word64Slice(base, p.field).Append(u) + return nil +} + +// Decode a slice of int64s ([]int64) in packed format. +func (o *Buffer) dec_slice_packed_int64(p *Properties, base structPointer) error { + v := structPointer_Word64Slice(base, p.field) + + nn, err := o.DecodeVarint() + if err != nil { + return err + } + nb := int(nn) // number of bytes of encoded int64s + + fin := o.index + nb + if fin < o.index { + return errOverflow + } + for o.index < fin { + u, err := p.valDec(o) + if err != nil { + return err + } + v.Append(u) + } + return nil +} + +// Decode a slice of strings ([]string). +func (o *Buffer) dec_slice_string(p *Properties, base structPointer) error { + s, err := o.DecodeStringBytes() + if err != nil { + return err + } + v := structPointer_StringSlice(base, p.field) + *v = append(*v, s) + return nil +} + +// Decode a slice of slice of bytes ([][]byte). +func (o *Buffer) dec_slice_slice_byte(p *Properties, base structPointer) error { + b, err := o.DecodeRawBytes(true) + if err != nil { + return err + } + v := structPointer_BytesSlice(base, p.field) + *v = append(*v, b) + return nil +} + +// Decode a map field. +func (o *Buffer) dec_new_map(p *Properties, base structPointer) error { + raw, err := o.DecodeRawBytes(false) + if err != nil { + return err + } + oi := o.index // index at the end of this map entry + o.index -= len(raw) // move buffer back to start of map entry + + mptr := structPointer_NewAt(base, p.field, p.mtype) // *map[K]V + if mptr.Elem().IsNil() { + mptr.Elem().Set(reflect.MakeMap(mptr.Type().Elem())) + } + v := mptr.Elem() // map[K]V + + // Prepare addressable doubly-indirect placeholders for the key and value types. + // See enc_new_map for why. + keyptr := reflect.New(reflect.PtrTo(p.mtype.Key())).Elem() // addressable *K + keybase := toStructPointer(keyptr.Addr()) // **K + + var valbase structPointer + var valptr reflect.Value + switch p.mtype.Elem().Kind() { + case reflect.Slice: + // []byte + var dummy []byte + valptr = reflect.ValueOf(&dummy) // *[]byte + valbase = toStructPointer(valptr) // *[]byte + case reflect.Ptr: + // message; valptr is **Msg; need to allocate the intermediate pointer + valptr = reflect.New(reflect.PtrTo(p.mtype.Elem())).Elem() // addressable *V + valptr.Set(reflect.New(valptr.Type().Elem())) + valbase = toStructPointer(valptr) + default: + // everything else + valptr = reflect.New(reflect.PtrTo(p.mtype.Elem())).Elem() // addressable *V + valbase = toStructPointer(valptr.Addr()) // **V + } + + // Decode. + // This parses a restricted wire format, namely the encoding of a message + // with two fields. See enc_new_map for the format. + for o.index < oi { + // tagcode for key and value properties are always a single byte + // because they have tags 1 and 2. + tagcode := o.buf[o.index] + o.index++ + switch tagcode { + case p.mkeyprop.tagcode[0]: + if err := p.mkeyprop.dec(o, p.mkeyprop, keybase); err != nil { + return err + } + case p.mvalprop.tagcode[0]: + if err := p.mvalprop.dec(o, p.mvalprop, valbase); err != nil { + return err + } + default: + // TODO: Should we silently skip this instead? + return fmt.Errorf("proto: bad map data tag %d", raw[0]) + } + } + keyelem, valelem := keyptr.Elem(), valptr.Elem() + if !keyelem.IsValid() || !valelem.IsValid() { + // We did not decode the key or the value in the map entry. + // Either way, it's an invalid map entry. + return fmt.Errorf("proto: bad map data: missing key/val") + } + + v.SetMapIndex(keyelem, valelem) + return nil +} + +// Decode a group. +func (o *Buffer) dec_struct_group(p *Properties, base structPointer) error { + bas := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(bas) { + // allocate new nested message + bas = toStructPointer(reflect.New(p.stype)) + structPointer_SetStructPointer(base, p.field, bas) + } + return o.unmarshalType(p.stype, p.sprop, true, bas) +} + +// Decode an embedded message. +func (o *Buffer) dec_struct_message(p *Properties, base structPointer) (err error) { + raw, e := o.DecodeRawBytes(false) + if e != nil { + return e + } + + bas := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(bas) { + // allocate new nested message + bas = toStructPointer(reflect.New(p.stype)) + structPointer_SetStructPointer(base, p.field, bas) + } + + // If the object can unmarshal itself, let it. + if p.isUnmarshaler { + iv := structPointer_Interface(bas, p.stype) + return iv.(Unmarshaler).Unmarshal(raw) + } + + obuf := o.buf + oi := o.index + o.buf = raw + o.index = 0 + + err = o.unmarshalType(p.stype, p.sprop, false, bas) + o.buf = obuf + o.index = oi + + return err +} + +// Decode a slice of embedded messages. +func (o *Buffer) dec_slice_struct_message(p *Properties, base structPointer) error { + return o.dec_slice_struct(p, false, base) +} + +// Decode a slice of embedded groups. +func (o *Buffer) dec_slice_struct_group(p *Properties, base structPointer) error { + return o.dec_slice_struct(p, true, base) +} + +// Decode a slice of structs ([]*struct). +func (o *Buffer) dec_slice_struct(p *Properties, is_group bool, base structPointer) error { + v := reflect.New(p.stype) + bas := toStructPointer(v) + structPointer_StructPointerSlice(base, p.field).Append(bas) + + if is_group { + err := o.unmarshalType(p.stype, p.sprop, is_group, bas) + return err + } + + raw, err := o.DecodeRawBytes(false) + if err != nil { + return err + } + + // If the object can unmarshal itself, let it. + if p.isUnmarshaler { + iv := v.Interface() + return iv.(Unmarshaler).Unmarshal(raw) + } + + obuf := o.buf + oi := o.index + o.buf = raw + o.index = 0 + + err = o.unmarshalType(p.stype, p.sprop, is_group, bas) + + o.buf = obuf + o.index = oi + + return err +} diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/decode_gogo.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/decode_gogo.go new file mode 100644 index 0000000000..6a77aad766 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/decode_gogo.go @@ -0,0 +1,175 @@ +// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. +// http://github.com/gogo/protobuf/gogoproto +// +// 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. +// +// 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. + +package proto + +import ( + "reflect" +) + +// Decode a reference to a struct pointer. +func (o *Buffer) dec_ref_struct_message(p *Properties, base structPointer) (err error) { + raw, e := o.DecodeRawBytes(false) + if e != nil { + return e + } + + // If the object can unmarshal itself, let it. + if p.isUnmarshaler { + panic("not supported, since this is a pointer receiver") + } + + obuf := o.buf + oi := o.index + o.buf = raw + o.index = 0 + + bas := structPointer_FieldPointer(base, p.field) + + err = o.unmarshalType(p.stype, p.sprop, false, bas) + o.buf = obuf + o.index = oi + + return err +} + +// Decode a slice of references to struct pointers ([]struct). +func (o *Buffer) dec_slice_ref_struct(p *Properties, is_group bool, base structPointer) error { + newBas := appendStructPointer(base, p.field, p.sstype) + + if is_group { + panic("not supported, maybe in future, if requested.") + } + + raw, err := o.DecodeRawBytes(false) + if err != nil { + return err + } + + // If the object can unmarshal itself, let it. + if p.isUnmarshaler { + panic("not supported, since this is not a pointer receiver.") + } + + obuf := o.buf + oi := o.index + o.buf = raw + o.index = 0 + + err = o.unmarshalType(p.stype, p.sprop, is_group, newBas) + + o.buf = obuf + o.index = oi + + return err +} + +// Decode a slice of references to struct pointers. +func (o *Buffer) dec_slice_ref_struct_message(p *Properties, base structPointer) error { + return o.dec_slice_ref_struct(p, false, base) +} + +func setPtrCustomType(base structPointer, f field, v interface{}) { + if v == nil { + return + } + structPointer_SetStructPointer(base, f, structPointer(reflect.ValueOf(v).Pointer())) +} + +func setCustomType(base structPointer, f field, value interface{}) { + if value == nil { + return + } + v := reflect.ValueOf(value).Elem() + t := reflect.TypeOf(value).Elem() + kind := t.Kind() + switch kind { + case reflect.Slice: + slice := reflect.MakeSlice(t, v.Len(), v.Cap()) + reflect.Copy(slice, v) + oldHeader := structPointer_GetSliceHeader(base, f) + oldHeader.Data = slice.Pointer() + oldHeader.Len = v.Len() + oldHeader.Cap = v.Cap() + default: + l := 1 + size := reflect.TypeOf(value).Elem().Size() + if kind == reflect.Array { + l = reflect.TypeOf(value).Elem().Len() + size = reflect.TypeOf(value).Size() + } + total := int(size) * l + structPointer_Copy(toStructPointer(reflect.ValueOf(value)), structPointer_Add(base, f), total) + } +} + +func (o *Buffer) dec_custom_bytes(p *Properties, base structPointer) error { + b, err := o.DecodeRawBytes(true) + if err != nil { + return err + } + i := reflect.New(p.ctype.Elem()).Interface() + custom := (i).(Unmarshaler) + if err := custom.Unmarshal(b); err != nil { + return err + } + setPtrCustomType(base, p.field, custom) + return nil +} + +func (o *Buffer) dec_custom_ref_bytes(p *Properties, base structPointer) error { + b, err := o.DecodeRawBytes(true) + if err != nil { + return err + } + i := reflect.New(p.ctype).Interface() + custom := (i).(Unmarshaler) + if err := custom.Unmarshal(b); err != nil { + return err + } + if custom != nil { + setCustomType(base, p.field, custom) + } + return nil +} + +// Decode a slice of bytes ([]byte) into a slice of custom types. +func (o *Buffer) dec_custom_slice_bytes(p *Properties, base structPointer) error { + b, err := o.DecodeRawBytes(true) + if err != nil { + return err + } + i := reflect.New(p.ctype.Elem()).Interface() + custom := (i).(Unmarshaler) + if err := custom.Unmarshal(b); err != nil { + return err + } + newBas := appendStructPointer(base, p.field, p.ctype) + + setCustomType(newBas, 0, custom) + + return nil +} diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/encode.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/encode.go new file mode 100644 index 0000000000..7321e1aae1 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/encode.go @@ -0,0 +1,1335 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +package proto + +/* + * Routines for encoding data into the wire format for protocol buffers. + */ + +import ( + "errors" + "fmt" + "reflect" + "sort" +) + +// RequiredNotSetError is the error returned if Marshal is called with +// a protocol buffer struct whose required fields have not +// all been initialized. It is also the error returned if Unmarshal is +// called with an encoded protocol buffer that does not include all the +// required fields. +// +// When printed, RequiredNotSetError reports the first unset required field in a +// message. If the field cannot be precisely determined, it is reported as +// "{Unknown}". +type RequiredNotSetError struct { + field string +} + +func (e *RequiredNotSetError) Error() string { + return fmt.Sprintf("proto: required field %q not set", e.field) +} + +var ( + // errRepeatedHasNil is the error returned if Marshal is called with + // a struct with a repeated field containing a nil element. + errRepeatedHasNil = errors.New("proto: repeated field has nil element") + + // ErrNil is the error returned if Marshal is called with nil. + ErrNil = errors.New("proto: Marshal called with nil") +) + +// The fundamental encoders that put bytes on the wire. +// Those that take integer types all accept uint64 and are +// therefore of type valueEncoder. + +const maxVarintBytes = 10 // maximum length of a varint + +// EncodeVarint returns the varint encoding of x. +// This is the format for the +// int32, int64, uint32, uint64, bool, and enum +// protocol buffer types. +// Not used by the package itself, but helpful to clients +// wishing to use the same encoding. +func EncodeVarint(x uint64) []byte { + var buf [maxVarintBytes]byte + var n int + for n = 0; x > 127; n++ { + buf[n] = 0x80 | uint8(x&0x7F) + x >>= 7 + } + buf[n] = uint8(x) + n++ + return buf[0:n] +} + +// EncodeVarint writes a varint-encoded integer to the Buffer. +// This is the format for the +// int32, int64, uint32, uint64, bool, and enum +// protocol buffer types. +func (p *Buffer) EncodeVarint(x uint64) error { + for x >= 1<<7 { + p.buf = append(p.buf, uint8(x&0x7f|0x80)) + x >>= 7 + } + p.buf = append(p.buf, uint8(x)) + return nil +} + +func sizeVarint(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} + +// EncodeFixed64 writes a 64-bit integer to the Buffer. +// This is the format for the +// fixed64, sfixed64, and double protocol buffer types. +func (p *Buffer) EncodeFixed64(x uint64) error { + p.buf = append(p.buf, + uint8(x), + uint8(x>>8), + uint8(x>>16), + uint8(x>>24), + uint8(x>>32), + uint8(x>>40), + uint8(x>>48), + uint8(x>>56)) + return nil +} + +func sizeFixed64(x uint64) int { + return 8 +} + +// EncodeFixed32 writes a 32-bit integer to the Buffer. +// This is the format for the +// fixed32, sfixed32, and float protocol buffer types. +func (p *Buffer) EncodeFixed32(x uint64) error { + p.buf = append(p.buf, + uint8(x), + uint8(x>>8), + uint8(x>>16), + uint8(x>>24)) + return nil +} + +func sizeFixed32(x uint64) int { + return 4 +} + +// EncodeZigzag64 writes a zigzag-encoded 64-bit integer +// to the Buffer. +// This is the format used for the sint64 protocol buffer type. +func (p *Buffer) EncodeZigzag64(x uint64) error { + // use signed number to get arithmetic right shift. + return p.EncodeVarint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} + +func sizeZigzag64(x uint64) int { + return sizeVarint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} + +// EncodeZigzag32 writes a zigzag-encoded 32-bit integer +// to the Buffer. +// This is the format used for the sint32 protocol buffer type. +func (p *Buffer) EncodeZigzag32(x uint64) error { + // use signed number to get arithmetic right shift. + return p.EncodeVarint(uint64((uint32(x) << 1) ^ uint32((int32(x) >> 31)))) +} + +func sizeZigzag32(x uint64) int { + return sizeVarint(uint64((uint32(x) << 1) ^ uint32((int32(x) >> 31)))) +} + +// EncodeRawBytes writes a count-delimited byte buffer to the Buffer. +// This is the format used for the bytes protocol buffer +// type and for embedded messages. +func (p *Buffer) EncodeRawBytes(b []byte) error { + p.EncodeVarint(uint64(len(b))) + p.buf = append(p.buf, b...) + return nil +} + +func sizeRawBytes(b []byte) int { + return sizeVarint(uint64(len(b))) + + len(b) +} + +// EncodeStringBytes writes an encoded string to the Buffer. +// This is the format used for the proto2 string type. +func (p *Buffer) EncodeStringBytes(s string) error { + p.EncodeVarint(uint64(len(s))) + p.buf = append(p.buf, s...) + return nil +} + +func sizeStringBytes(s string) int { + return sizeVarint(uint64(len(s))) + + len(s) +} + +// Marshaler is the interface representing objects that can marshal themselves. +type Marshaler interface { + Marshal() ([]byte, error) +} + +// Marshal takes the protocol buffer +// and encodes it into the wire format, returning the data. +func Marshal(pb Message) ([]byte, error) { + // Can the object marshal itself? + if m, ok := pb.(Marshaler); ok { + return m.Marshal() + } + p := NewBuffer(nil) + err := p.Marshal(pb) + var state errorState + if err != nil && !state.shouldContinue(err, nil) { + return nil, err + } + if p.buf == nil && err == nil { + // Return a non-nil slice on success. + return []byte{}, nil + } + return p.buf, err +} + +// EncodeMessage writes the protocol buffer to the Buffer, +// prefixed by a varint-encoded length. +func (p *Buffer) EncodeMessage(pb Message) error { + t, base, err := getbase(pb) + if structPointer_IsNil(base) { + return ErrNil + } + if err == nil { + var state errorState + err = p.enc_len_struct(GetProperties(t.Elem()), base, &state) + } + return err +} + +// Marshal takes the protocol buffer +// and encodes it into the wire format, writing the result to the +// Buffer. +func (p *Buffer) Marshal(pb Message) error { + // Can the object marshal itself? + if m, ok := pb.(Marshaler); ok { + data, err := m.Marshal() + if err != nil { + return err + } + p.buf = append(p.buf, data...) + return nil + } + + t, base, err := getbase(pb) + if structPointer_IsNil(base) { + return ErrNil + } + if err == nil { + err = p.enc_struct(GetProperties(t.Elem()), base) + } + + if collectStats { + stats.Encode++ + } + + return err +} + +// Size returns the encoded size of a protocol buffer. +func Size(pb Message) (n int) { + // Can the object marshal itself? If so, Size is slow. + // TODO: add Size to Marshaler, or add a Sizer interface. + if m, ok := pb.(Marshaler); ok { + b, _ := m.Marshal() + return len(b) + } + + t, base, err := getbase(pb) + if structPointer_IsNil(base) { + return 0 + } + if err == nil { + n = size_struct(GetProperties(t.Elem()), base) + } + + if collectStats { + stats.Size++ + } + + return +} + +// Individual type encoders. + +// Encode a bool. +func (o *Buffer) enc_bool(p *Properties, base structPointer) error { + v := *structPointer_Bool(base, p.field) + if v == nil { + return ErrNil + } + x := 0 + if *v { + x = 1 + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func (o *Buffer) enc_proto3_bool(p *Properties, base structPointer) error { + v := *structPointer_BoolVal(base, p.field) + if !v { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, 1) + return nil +} + +func size_bool(p *Properties, base structPointer) int { + v := *structPointer_Bool(base, p.field) + if v == nil { + return 0 + } + return len(p.tagcode) + 1 // each bool takes exactly one byte +} + +func size_proto3_bool(p *Properties, base structPointer) int { + v := *structPointer_BoolVal(base, p.field) + if !v && !p.oneof { + return 0 + } + return len(p.tagcode) + 1 // each bool takes exactly one byte +} + +// Encode an int32. +func (o *Buffer) enc_int32(p *Properties, base structPointer) error { + v := structPointer_Word32(base, p.field) + if word32_IsNil(v) { + return ErrNil + } + x := int32(word32_Get(v)) // permit sign extension to use full 64-bit range + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func (o *Buffer) enc_proto3_int32(p *Properties, base structPointer) error { + v := structPointer_Word32Val(base, p.field) + x := int32(word32Val_Get(v)) // permit sign extension to use full 64-bit range + if x == 0 { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func size_int32(p *Properties, base structPointer) (n int) { + v := structPointer_Word32(base, p.field) + if word32_IsNil(v) { + return 0 + } + x := int32(word32_Get(v)) // permit sign extension to use full 64-bit range + n += len(p.tagcode) + n += p.valSize(uint64(x)) + return +} + +func size_proto3_int32(p *Properties, base structPointer) (n int) { + v := structPointer_Word32Val(base, p.field) + x := int32(word32Val_Get(v)) // permit sign extension to use full 64-bit range + if x == 0 && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += p.valSize(uint64(x)) + return +} + +// Encode a uint32. +// Exactly the same as int32, except for no sign extension. +func (o *Buffer) enc_uint32(p *Properties, base structPointer) error { + v := structPointer_Word32(base, p.field) + if word32_IsNil(v) { + return ErrNil + } + x := word32_Get(v) + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func (o *Buffer) enc_proto3_uint32(p *Properties, base structPointer) error { + v := structPointer_Word32Val(base, p.field) + x := word32Val_Get(v) + if x == 0 { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func size_uint32(p *Properties, base structPointer) (n int) { + v := structPointer_Word32(base, p.field) + if word32_IsNil(v) { + return 0 + } + x := word32_Get(v) + n += len(p.tagcode) + n += p.valSize(uint64(x)) + return +} + +func size_proto3_uint32(p *Properties, base structPointer) (n int) { + v := structPointer_Word32Val(base, p.field) + x := word32Val_Get(v) + if x == 0 && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += p.valSize(uint64(x)) + return +} + +// Encode an int64. +func (o *Buffer) enc_int64(p *Properties, base structPointer) error { + v := structPointer_Word64(base, p.field) + if word64_IsNil(v) { + return ErrNil + } + x := word64_Get(v) + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, x) + return nil +} + +func (o *Buffer) enc_proto3_int64(p *Properties, base structPointer) error { + v := structPointer_Word64Val(base, p.field) + x := word64Val_Get(v) + if x == 0 { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, x) + return nil +} + +func size_int64(p *Properties, base structPointer) (n int) { + v := structPointer_Word64(base, p.field) + if word64_IsNil(v) { + return 0 + } + x := word64_Get(v) + n += len(p.tagcode) + n += p.valSize(x) + return +} + +func size_proto3_int64(p *Properties, base structPointer) (n int) { + v := structPointer_Word64Val(base, p.field) + x := word64Val_Get(v) + if x == 0 && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += p.valSize(x) + return +} + +// Encode a string. +func (o *Buffer) enc_string(p *Properties, base structPointer) error { + v := *structPointer_String(base, p.field) + if v == nil { + return ErrNil + } + x := *v + o.buf = append(o.buf, p.tagcode...) + o.EncodeStringBytes(x) + return nil +} + +func (o *Buffer) enc_proto3_string(p *Properties, base structPointer) error { + v := *structPointer_StringVal(base, p.field) + if v == "" { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeStringBytes(v) + return nil +} + +func size_string(p *Properties, base structPointer) (n int) { + v := *structPointer_String(base, p.field) + if v == nil { + return 0 + } + x := *v + n += len(p.tagcode) + n += sizeStringBytes(x) + return +} + +func size_proto3_string(p *Properties, base structPointer) (n int) { + v := *structPointer_StringVal(base, p.field) + if v == "" && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += sizeStringBytes(v) + return +} + +// All protocol buffer fields are nillable, but be careful. +func isNil(v reflect.Value) bool { + switch v.Kind() { + case reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice: + return v.IsNil() + } + return false +} + +// Encode a message struct. +func (o *Buffer) enc_struct_message(p *Properties, base structPointer) error { + var state errorState + structp := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(structp) { + return ErrNil + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, err := m.Marshal() + if err != nil && !state.shouldContinue(err, nil) { + return err + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(data) + return state.err + } + + o.buf = append(o.buf, p.tagcode...) + return o.enc_len_struct(p.sprop, structp, &state) +} + +func size_struct_message(p *Properties, base structPointer) int { + structp := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(structp) { + return 0 + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, _ := m.Marshal() + n0 := len(p.tagcode) + n1 := sizeRawBytes(data) + return n0 + n1 + } + + n0 := len(p.tagcode) + n1 := size_struct(p.sprop, structp) + n2 := sizeVarint(uint64(n1)) // size of encoded length + return n0 + n1 + n2 +} + +// Encode a group struct. +func (o *Buffer) enc_struct_group(p *Properties, base structPointer) error { + var state errorState + b := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(b) { + return ErrNil + } + + o.EncodeVarint(uint64((p.Tag << 3) | WireStartGroup)) + err := o.enc_struct(p.sprop, b) + if err != nil && !state.shouldContinue(err, nil) { + return err + } + o.EncodeVarint(uint64((p.Tag << 3) | WireEndGroup)) + return state.err +} + +func size_struct_group(p *Properties, base structPointer) (n int) { + b := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(b) { + return 0 + } + + n += sizeVarint(uint64((p.Tag << 3) | WireStartGroup)) + n += size_struct(p.sprop, b) + n += sizeVarint(uint64((p.Tag << 3) | WireEndGroup)) + return +} + +// Encode a slice of bools ([]bool). +func (o *Buffer) enc_slice_bool(p *Properties, base structPointer) error { + s := *structPointer_BoolSlice(base, p.field) + l := len(s) + if l == 0 { + return ErrNil + } + for _, x := range s { + o.buf = append(o.buf, p.tagcode...) + v := uint64(0) + if x { + v = 1 + } + p.valEnc(o, v) + } + return nil +} + +func size_slice_bool(p *Properties, base structPointer) int { + s := *structPointer_BoolSlice(base, p.field) + l := len(s) + if l == 0 { + return 0 + } + return l * (len(p.tagcode) + 1) // each bool takes exactly one byte +} + +// Encode a slice of bools ([]bool) in packed format. +func (o *Buffer) enc_slice_packed_bool(p *Properties, base structPointer) error { + s := *structPointer_BoolSlice(base, p.field) + l := len(s) + if l == 0 { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeVarint(uint64(l)) // each bool takes exactly one byte + for _, x := range s { + v := uint64(0) + if x { + v = 1 + } + p.valEnc(o, v) + } + return nil +} + +func size_slice_packed_bool(p *Properties, base structPointer) (n int) { + s := *structPointer_BoolSlice(base, p.field) + l := len(s) + if l == 0 { + return 0 + } + n += len(p.tagcode) + n += sizeVarint(uint64(l)) + n += l // each bool takes exactly one byte + return +} + +// Encode a slice of bytes ([]byte). +func (o *Buffer) enc_slice_byte(p *Properties, base structPointer) error { + s := *structPointer_Bytes(base, p.field) + if s == nil { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(s) + return nil +} + +func (o *Buffer) enc_proto3_slice_byte(p *Properties, base structPointer) error { + s := *structPointer_Bytes(base, p.field) + if len(s) == 0 { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(s) + return nil +} + +func size_slice_byte(p *Properties, base structPointer) (n int) { + s := *structPointer_Bytes(base, p.field) + if s == nil && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += sizeRawBytes(s) + return +} + +func size_proto3_slice_byte(p *Properties, base structPointer) (n int) { + s := *structPointer_Bytes(base, p.field) + if len(s) == 0 && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += sizeRawBytes(s) + return +} + +// Encode a slice of int32s ([]int32). +func (o *Buffer) enc_slice_int32(p *Properties, base structPointer) error { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + for i := 0; i < l; i++ { + o.buf = append(o.buf, p.tagcode...) + x := int32(s.Index(i)) // permit sign extension to use full 64-bit range + p.valEnc(o, uint64(x)) + } + return nil +} + +func size_slice_int32(p *Properties, base structPointer) (n int) { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + for i := 0; i < l; i++ { + n += len(p.tagcode) + x := int32(s.Index(i)) // permit sign extension to use full 64-bit range + n += p.valSize(uint64(x)) + } + return +} + +// Encode a slice of int32s ([]int32) in packed format. +func (o *Buffer) enc_slice_packed_int32(p *Properties, base structPointer) error { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + // TODO: Reuse a Buffer. + buf := NewBuffer(nil) + for i := 0; i < l; i++ { + x := int32(s.Index(i)) // permit sign extension to use full 64-bit range + p.valEnc(buf, uint64(x)) + } + + o.buf = append(o.buf, p.tagcode...) + o.EncodeVarint(uint64(len(buf.buf))) + o.buf = append(o.buf, buf.buf...) + return nil +} + +func size_slice_packed_int32(p *Properties, base structPointer) (n int) { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + var bufSize int + for i := 0; i < l; i++ { + x := int32(s.Index(i)) // permit sign extension to use full 64-bit range + bufSize += p.valSize(uint64(x)) + } + + n += len(p.tagcode) + n += sizeVarint(uint64(bufSize)) + n += bufSize + return +} + +// Encode a slice of uint32s ([]uint32). +// Exactly the same as int32, except for no sign extension. +func (o *Buffer) enc_slice_uint32(p *Properties, base structPointer) error { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + for i := 0; i < l; i++ { + o.buf = append(o.buf, p.tagcode...) + x := s.Index(i) + p.valEnc(o, uint64(x)) + } + return nil +} + +func size_slice_uint32(p *Properties, base structPointer) (n int) { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + for i := 0; i < l; i++ { + n += len(p.tagcode) + x := s.Index(i) + n += p.valSize(uint64(x)) + } + return +} + +// Encode a slice of uint32s ([]uint32) in packed format. +// Exactly the same as int32, except for no sign extension. +func (o *Buffer) enc_slice_packed_uint32(p *Properties, base structPointer) error { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + // TODO: Reuse a Buffer. + buf := NewBuffer(nil) + for i := 0; i < l; i++ { + p.valEnc(buf, uint64(s.Index(i))) + } + + o.buf = append(o.buf, p.tagcode...) + o.EncodeVarint(uint64(len(buf.buf))) + o.buf = append(o.buf, buf.buf...) + return nil +} + +func size_slice_packed_uint32(p *Properties, base structPointer) (n int) { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + var bufSize int + for i := 0; i < l; i++ { + bufSize += p.valSize(uint64(s.Index(i))) + } + + n += len(p.tagcode) + n += sizeVarint(uint64(bufSize)) + n += bufSize + return +} + +// Encode a slice of int64s ([]int64). +func (o *Buffer) enc_slice_int64(p *Properties, base structPointer) error { + s := structPointer_Word64Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + for i := 0; i < l; i++ { + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, s.Index(i)) + } + return nil +} + +func size_slice_int64(p *Properties, base structPointer) (n int) { + s := structPointer_Word64Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + for i := 0; i < l; i++ { + n += len(p.tagcode) + n += p.valSize(s.Index(i)) + } + return +} + +// Encode a slice of int64s ([]int64) in packed format. +func (o *Buffer) enc_slice_packed_int64(p *Properties, base structPointer) error { + s := structPointer_Word64Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + // TODO: Reuse a Buffer. + buf := NewBuffer(nil) + for i := 0; i < l; i++ { + p.valEnc(buf, s.Index(i)) + } + + o.buf = append(o.buf, p.tagcode...) + o.EncodeVarint(uint64(len(buf.buf))) + o.buf = append(o.buf, buf.buf...) + return nil +} + +func size_slice_packed_int64(p *Properties, base structPointer) (n int) { + s := structPointer_Word64Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + var bufSize int + for i := 0; i < l; i++ { + bufSize += p.valSize(s.Index(i)) + } + + n += len(p.tagcode) + n += sizeVarint(uint64(bufSize)) + n += bufSize + return +} + +// Encode a slice of slice of bytes ([][]byte). +func (o *Buffer) enc_slice_slice_byte(p *Properties, base structPointer) error { + ss := *structPointer_BytesSlice(base, p.field) + l := len(ss) + if l == 0 { + return ErrNil + } + for i := 0; i < l; i++ { + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(ss[i]) + } + return nil +} + +func size_slice_slice_byte(p *Properties, base structPointer) (n int) { + ss := *structPointer_BytesSlice(base, p.field) + l := len(ss) + if l == 0 { + return 0 + } + n += l * len(p.tagcode) + for i := 0; i < l; i++ { + n += sizeRawBytes(ss[i]) + } + return +} + +// Encode a slice of strings ([]string). +func (o *Buffer) enc_slice_string(p *Properties, base structPointer) error { + ss := *structPointer_StringSlice(base, p.field) + l := len(ss) + for i := 0; i < l; i++ { + o.buf = append(o.buf, p.tagcode...) + o.EncodeStringBytes(ss[i]) + } + return nil +} + +func size_slice_string(p *Properties, base structPointer) (n int) { + ss := *structPointer_StringSlice(base, p.field) + l := len(ss) + n += l * len(p.tagcode) + for i := 0; i < l; i++ { + n += sizeStringBytes(ss[i]) + } + return +} + +// Encode a slice of message structs ([]*struct). +func (o *Buffer) enc_slice_struct_message(p *Properties, base structPointer) error { + var state errorState + s := structPointer_StructPointerSlice(base, p.field) + l := s.Len() + + for i := 0; i < l; i++ { + structp := s.Index(i) + if structPointer_IsNil(structp) { + return errRepeatedHasNil + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, err := m.Marshal() + if err != nil && !state.shouldContinue(err, nil) { + return err + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(data) + continue + } + + o.buf = append(o.buf, p.tagcode...) + err := o.enc_len_struct(p.sprop, structp, &state) + if err != nil && !state.shouldContinue(err, nil) { + if err == ErrNil { + return errRepeatedHasNil + } + return err + } + } + return state.err +} + +func size_slice_struct_message(p *Properties, base structPointer) (n int) { + s := structPointer_StructPointerSlice(base, p.field) + l := s.Len() + n += l * len(p.tagcode) + for i := 0; i < l; i++ { + structp := s.Index(i) + if structPointer_IsNil(structp) { + return // return the size up to this point + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, _ := m.Marshal() + n += len(p.tagcode) + n += sizeRawBytes(data) + continue + } + + n0 := size_struct(p.sprop, structp) + n1 := sizeVarint(uint64(n0)) // size of encoded length + n += n0 + n1 + } + return +} + +// Encode a slice of group structs ([]*struct). +func (o *Buffer) enc_slice_struct_group(p *Properties, base structPointer) error { + var state errorState + s := structPointer_StructPointerSlice(base, p.field) + l := s.Len() + + for i := 0; i < l; i++ { + b := s.Index(i) + if structPointer_IsNil(b) { + return errRepeatedHasNil + } + + o.EncodeVarint(uint64((p.Tag << 3) | WireStartGroup)) + + err := o.enc_struct(p.sprop, b) + + if err != nil && !state.shouldContinue(err, nil) { + if err == ErrNil { + return errRepeatedHasNil + } + return err + } + + o.EncodeVarint(uint64((p.Tag << 3) | WireEndGroup)) + } + return state.err +} + +func size_slice_struct_group(p *Properties, base structPointer) (n int) { + s := structPointer_StructPointerSlice(base, p.field) + l := s.Len() + + n += l * sizeVarint(uint64((p.Tag<<3)|WireStartGroup)) + n += l * sizeVarint(uint64((p.Tag<<3)|WireEndGroup)) + for i := 0; i < l; i++ { + b := s.Index(i) + if structPointer_IsNil(b) { + return // return size up to this point + } + + n += size_struct(p.sprop, b) + } + return +} + +// Encode an extension map. +func (o *Buffer) enc_map(p *Properties, base structPointer) error { + v := *structPointer_ExtMap(base, p.field) + if err := encodeExtensionMap(v); err != nil { + return err + } + // Fast-path for common cases: zero or one extensions. + if len(v) <= 1 { + for _, e := range v { + o.buf = append(o.buf, e.enc...) + } + return nil + } + + // Sort keys to provide a deterministic encoding. + keys := make([]int, 0, len(v)) + for k := range v { + keys = append(keys, int(k)) + } + sort.Ints(keys) + + for _, k := range keys { + o.buf = append(o.buf, v[int32(k)].enc...) + } + return nil +} + +func size_map(p *Properties, base structPointer) int { + v := *structPointer_ExtMap(base, p.field) + return sizeExtensionMap(v) +} + +// Encode a map field. +func (o *Buffer) enc_new_map(p *Properties, base structPointer) error { + var state errorState // XXX: or do we need to plumb this through? + + /* + A map defined as + map map_field = N; + is encoded in the same way as + message MapFieldEntry { + key_type key = 1; + value_type value = 2; + } + repeated MapFieldEntry map_field = N; + */ + + v := structPointer_NewAt(base, p.field, p.mtype).Elem() // map[K]V + if v.Len() == 0 { + return nil + } + + keycopy, valcopy, keybase, valbase := mapEncodeScratch(p.mtype) + + enc := func() error { + if err := p.mkeyprop.enc(o, p.mkeyprop, keybase); err != nil { + return err + } + if err := p.mvalprop.enc(o, p.mvalprop, valbase); err != nil { + return err + } + return nil + } + + // Don't sort map keys. It is not required by the spec, and C++ doesn't do it. + for _, key := range v.MapKeys() { + val := v.MapIndex(key) + + // The only illegal map entry values are nil message pointers. + if val.Kind() == reflect.Ptr && val.IsNil() { + return errors.New("proto: map has nil element") + } + + keycopy.Set(key) + valcopy.Set(val) + + o.buf = append(o.buf, p.tagcode...) + if err := o.enc_len_thing(enc, &state); err != nil { + return err + } + } + return nil +} + +func size_new_map(p *Properties, base structPointer) int { + v := structPointer_NewAt(base, p.field, p.mtype).Elem() // map[K]V + + keycopy, valcopy, keybase, valbase := mapEncodeScratch(p.mtype) + + n := 0 + for _, key := range v.MapKeys() { + val := v.MapIndex(key) + keycopy.Set(key) + valcopy.Set(val) + + // Tag codes for key and val are the responsibility of the sub-sizer. + keysize := p.mkeyprop.size(p.mkeyprop, keybase) + valsize := p.mvalprop.size(p.mvalprop, valbase) + entry := keysize + valsize + // Add on tag code and length of map entry itself. + n += len(p.tagcode) + sizeVarint(uint64(entry)) + entry + } + return n +} + +// mapEncodeScratch returns a new reflect.Value matching the map's value type, +// and a structPointer suitable for passing to an encoder or sizer. +func mapEncodeScratch(mapType reflect.Type) (keycopy, valcopy reflect.Value, keybase, valbase structPointer) { + // Prepare addressable doubly-indirect placeholders for the key and value types. + // This is needed because the element-type encoders expect **T, but the map iteration produces T. + + keycopy = reflect.New(mapType.Key()).Elem() // addressable K + keyptr := reflect.New(reflect.PtrTo(keycopy.Type())).Elem() // addressable *K + keyptr.Set(keycopy.Addr()) // + keybase = toStructPointer(keyptr.Addr()) // **K + + // Value types are more varied and require special handling. + switch mapType.Elem().Kind() { + case reflect.Slice: + // []byte + var dummy []byte + valcopy = reflect.ValueOf(&dummy).Elem() // addressable []byte + valbase = toStructPointer(valcopy.Addr()) + case reflect.Ptr: + // message; the generated field type is map[K]*Msg (so V is *Msg), + // so we only need one level of indirection. + valcopy = reflect.New(mapType.Elem()).Elem() // addressable V + valbase = toStructPointer(valcopy.Addr()) + default: + // everything else + valcopy = reflect.New(mapType.Elem()).Elem() // addressable V + valptr := reflect.New(reflect.PtrTo(valcopy.Type())).Elem() // addressable *V + valptr.Set(valcopy.Addr()) // + valbase = toStructPointer(valptr.Addr()) // **V + } + return +} + +// Encode a struct. +func (o *Buffer) enc_struct(prop *StructProperties, base structPointer) error { + var state errorState + // Encode fields in tag order so that decoders may use optimizations + // that depend on the ordering. + // https://developers.google.com/protocol-buffers/docs/encoding#order + for _, i := range prop.order { + p := prop.Prop[i] + if p.enc != nil { + err := p.enc(o, p, base) + if err != nil { + if err == ErrNil { + if p.Required && state.err == nil { + state.err = &RequiredNotSetError{p.Name} + } + } else if err == errRepeatedHasNil { + // Give more context to nil values in repeated fields. + return errors.New("repeated field " + p.OrigName + " has nil element") + } else if !state.shouldContinue(err, p) { + return err + } + } + } + } + + // Do oneof fields. + if prop.oneofMarshaler != nil { + m := structPointer_Interface(base, prop.stype).(Message) + if err := prop.oneofMarshaler(m, o); err != nil { + return err + } + } + + // Add unrecognized fields at the end. + if prop.unrecField.IsValid() { + v := *structPointer_Bytes(base, prop.unrecField) + if len(v) > 0 { + o.buf = append(o.buf, v...) + } + } + + return state.err +} + +func size_struct(prop *StructProperties, base structPointer) (n int) { + for _, i := range prop.order { + p := prop.Prop[i] + if p.size != nil { + n += p.size(p, base) + } + } + + // Add unrecognized fields at the end. + if prop.unrecField.IsValid() { + v := *structPointer_Bytes(base, prop.unrecField) + n += len(v) + } + + // Factor in any oneof fields. + // TODO: This could be faster and use less reflection. + if prop.oneofMarshaler != nil { + sv := reflect.ValueOf(structPointer_Interface(base, prop.stype)).Elem() + for i := 0; i < prop.stype.NumField(); i++ { + fv := sv.Field(i) + if fv.Kind() != reflect.Interface || fv.IsNil() { + continue + } + if prop.stype.Field(i).Tag.Get("protobuf_oneof") == "" { + continue + } + spv := fv.Elem() // interface -> *T + sv := spv.Elem() // *T -> T + sf := sv.Type().Field(0) // StructField inside T + var prop Properties + prop.Init(sf.Type, "whatever", sf.Tag.Get("protobuf"), &sf) + n += prop.size(&prop, toStructPointer(spv)) + } + } + + return +} + +var zeroes [20]byte // longer than any conceivable sizeVarint + +// Encode a struct, preceded by its encoded length (as a varint). +func (o *Buffer) enc_len_struct(prop *StructProperties, base structPointer, state *errorState) error { + return o.enc_len_thing(func() error { return o.enc_struct(prop, base) }, state) +} + +// Encode something, preceded by its encoded length (as a varint). +func (o *Buffer) enc_len_thing(enc func() error, state *errorState) error { + iLen := len(o.buf) + o.buf = append(o.buf, 0, 0, 0, 0) // reserve four bytes for length + iMsg := len(o.buf) + err := enc() + if err != nil && !state.shouldContinue(err, nil) { + return err + } + lMsg := len(o.buf) - iMsg + lLen := sizeVarint(uint64(lMsg)) + switch x := lLen - (iMsg - iLen); { + case x > 0: // actual length is x bytes larger than the space we reserved + // Move msg x bytes right. + o.buf = append(o.buf, zeroes[:x]...) + copy(o.buf[iMsg+x:], o.buf[iMsg:iMsg+lMsg]) + case x < 0: // actual length is x bytes smaller than the space we reserved + // Move msg x bytes left. + copy(o.buf[iMsg+x:], o.buf[iMsg:iMsg+lMsg]) + o.buf = o.buf[:len(o.buf)+x] // x is negative + } + // Encode the length in the reserved space. + o.buf = o.buf[:iLen] + o.EncodeVarint(uint64(lMsg)) + o.buf = o.buf[:len(o.buf)+lMsg] + return state.err +} + +// errorState maintains the first error that occurs and updates that error +// with additional context. +type errorState struct { + err error +} + +// shouldContinue reports whether encoding should continue upon encountering the +// given error. If the error is RequiredNotSetError, shouldContinue returns true +// and, if this is the first appearance of that error, remembers it for future +// reporting. +// +// If prop is not nil, it may update any error with additional context about the +// field with the error. +func (s *errorState) shouldContinue(err error, prop *Properties) bool { + // Ignore unset required fields. + reqNotSet, ok := err.(*RequiredNotSetError) + if !ok { + return false + } + if s.err == nil { + if prop != nil { + err = &RequiredNotSetError{prop.Name + "." + reqNotSet.field} + } + s.err = err + } + return true +} diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/encode_gogo.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/encode_gogo.go new file mode 100644 index 0000000000..f77cfb1eea --- /dev/null +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/encode_gogo.go @@ -0,0 +1,354 @@ +// Extensions for Protocol Buffers to create more go like structures. +// +// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. +// http://github.com/gogo/protobuf/gogoproto +// +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// http://github.com/golang/protobuf/ +// +// 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. + +package proto + +import ( + "reflect" +) + +func NewRequiredNotSetError(field string) *RequiredNotSetError { + return &RequiredNotSetError{field} +} + +type Sizer interface { + Size() int +} + +func (o *Buffer) enc_ext_slice_byte(p *Properties, base structPointer) error { + s := *structPointer_Bytes(base, p.field) + if s == nil { + return ErrNil + } + o.buf = append(o.buf, s...) + return nil +} + +func size_ext_slice_byte(p *Properties, base structPointer) (n int) { + s := *structPointer_Bytes(base, p.field) + if s == nil { + return 0 + } + n += len(s) + return +} + +// Encode a reference to bool pointer. +func (o *Buffer) enc_ref_bool(p *Properties, base structPointer) error { + v := *structPointer_BoolVal(base, p.field) + x := 0 + if v { + x = 1 + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func size_ref_bool(p *Properties, base structPointer) int { + return len(p.tagcode) + 1 // each bool takes exactly one byte +} + +// Encode a reference to int32 pointer. +func (o *Buffer) enc_ref_int32(p *Properties, base structPointer) error { + v := structPointer_Word32Val(base, p.field) + x := int32(word32Val_Get(v)) + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func size_ref_int32(p *Properties, base structPointer) (n int) { + v := structPointer_Word32Val(base, p.field) + x := int32(word32Val_Get(v)) + n += len(p.tagcode) + n += p.valSize(uint64(x)) + return +} + +func (o *Buffer) enc_ref_uint32(p *Properties, base structPointer) error { + v := structPointer_Word32Val(base, p.field) + x := word32Val_Get(v) + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func size_ref_uint32(p *Properties, base structPointer) (n int) { + v := structPointer_Word32Val(base, p.field) + x := word32Val_Get(v) + n += len(p.tagcode) + n += p.valSize(uint64(x)) + return +} + +// Encode a reference to an int64 pointer. +func (o *Buffer) enc_ref_int64(p *Properties, base structPointer) error { + v := structPointer_Word64Val(base, p.field) + x := word64Val_Get(v) + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, x) + return nil +} + +func size_ref_int64(p *Properties, base structPointer) (n int) { + v := structPointer_Word64Val(base, p.field) + x := word64Val_Get(v) + n += len(p.tagcode) + n += p.valSize(x) + return +} + +// Encode a reference to a string pointer. +func (o *Buffer) enc_ref_string(p *Properties, base structPointer) error { + v := *structPointer_StringVal(base, p.field) + o.buf = append(o.buf, p.tagcode...) + o.EncodeStringBytes(v) + return nil +} + +func size_ref_string(p *Properties, base structPointer) (n int) { + v := *structPointer_StringVal(base, p.field) + n += len(p.tagcode) + n += sizeStringBytes(v) + return +} + +// Encode a reference to a message struct. +func (o *Buffer) enc_ref_struct_message(p *Properties, base structPointer) error { + var state errorState + structp := structPointer_GetRefStructPointer(base, p.field) + if structPointer_IsNil(structp) { + return ErrNil + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, err := m.Marshal() + if err != nil && !state.shouldContinue(err, nil) { + return err + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(data) + return nil + } + + o.buf = append(o.buf, p.tagcode...) + return o.enc_len_struct(p.sprop, structp, &state) +} + +//TODO this is only copied, please fix this +func size_ref_struct_message(p *Properties, base structPointer) int { + structp := structPointer_GetRefStructPointer(base, p.field) + if structPointer_IsNil(structp) { + return 0 + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, _ := m.Marshal() + n0 := len(p.tagcode) + n1 := sizeRawBytes(data) + return n0 + n1 + } + + n0 := len(p.tagcode) + n1 := size_struct(p.sprop, structp) + n2 := sizeVarint(uint64(n1)) // size of encoded length + return n0 + n1 + n2 +} + +// Encode a slice of references to message struct pointers ([]struct). +func (o *Buffer) enc_slice_ref_struct_message(p *Properties, base structPointer) error { + var state errorState + ss := structPointer_GetStructPointer(base, p.field) + ss1 := structPointer_GetRefStructPointer(ss, field(0)) + size := p.stype.Size() + l := structPointer_Len(base, p.field) + for i := 0; i < l; i++ { + structp := structPointer_Add(ss1, field(uintptr(i)*size)) + if structPointer_IsNil(structp) { + return errRepeatedHasNil + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, err := m.Marshal() + if err != nil && !state.shouldContinue(err, nil) { + return err + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(data) + continue + } + + o.buf = append(o.buf, p.tagcode...) + err := o.enc_len_struct(p.sprop, structp, &state) + if err != nil && !state.shouldContinue(err, nil) { + if err == ErrNil { + return errRepeatedHasNil + } + return err + } + + } + return state.err +} + +//TODO this is only copied, please fix this +func size_slice_ref_struct_message(p *Properties, base structPointer) (n int) { + ss := structPointer_GetStructPointer(base, p.field) + ss1 := structPointer_GetRefStructPointer(ss, field(0)) + size := p.stype.Size() + l := structPointer_Len(base, p.field) + n += l * len(p.tagcode) + for i := 0; i < l; i++ { + structp := structPointer_Add(ss1, field(uintptr(i)*size)) + if structPointer_IsNil(structp) { + return // return the size up to this point + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, _ := m.Marshal() + n += len(p.tagcode) + n += sizeRawBytes(data) + continue + } + + n0 := size_struct(p.sprop, structp) + n1 := sizeVarint(uint64(n0)) // size of encoded length + n += n0 + n1 + } + return +} + +func (o *Buffer) enc_custom_bytes(p *Properties, base structPointer) error { + i := structPointer_InterfaceRef(base, p.field, p.ctype) + if i == nil { + return ErrNil + } + custom := i.(Marshaler) + data, err := custom.Marshal() + if err != nil { + return err + } + if data == nil { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(data) + return nil +} + +func size_custom_bytes(p *Properties, base structPointer) (n int) { + n += len(p.tagcode) + i := structPointer_InterfaceRef(base, p.field, p.ctype) + if i == nil { + return 0 + } + custom := i.(Marshaler) + data, _ := custom.Marshal() + n += sizeRawBytes(data) + return +} + +func (o *Buffer) enc_custom_ref_bytes(p *Properties, base structPointer) error { + custom := structPointer_InterfaceAt(base, p.field, p.ctype).(Marshaler) + data, err := custom.Marshal() + if err != nil { + return err + } + if data == nil { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(data) + return nil +} + +func size_custom_ref_bytes(p *Properties, base structPointer) (n int) { + n += len(p.tagcode) + i := structPointer_InterfaceAt(base, p.field, p.ctype) + if i == nil { + return 0 + } + custom := i.(Marshaler) + data, _ := custom.Marshal() + n += sizeRawBytes(data) + return +} + +func (o *Buffer) enc_custom_slice_bytes(p *Properties, base structPointer) error { + inter := structPointer_InterfaceRef(base, p.field, p.ctype) + if inter == nil { + return ErrNil + } + slice := reflect.ValueOf(inter) + l := slice.Len() + for i := 0; i < l; i++ { + v := slice.Index(i) + custom := v.Interface().(Marshaler) + data, err := custom.Marshal() + if err != nil { + return err + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(data) + } + return nil +} + +func size_custom_slice_bytes(p *Properties, base structPointer) (n int) { + inter := structPointer_InterfaceRef(base, p.field, p.ctype) + if inter == nil { + return 0 + } + slice := reflect.ValueOf(inter) + l := slice.Len() + n += l * len(p.tagcode) + for i := 0; i < l; i++ { + v := slice.Index(i) + custom := v.Interface().(Marshaler) + data, _ := custom.Marshal() + n += sizeRawBytes(data) + } + return +} diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/equal.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/equal.go new file mode 100644 index 0000000000..cc3f2c95a7 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/equal.go @@ -0,0 +1,266 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2011 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +// Protocol buffer comparison. + +package proto + +import ( + "bytes" + "log" + "reflect" + "strings" +) + +/* +Equal returns true iff protocol buffers a and b are equal. +The arguments must both be pointers to protocol buffer structs. + +Equality is defined in this way: + - Two messages are equal iff they are the same type, + corresponding fields are equal, unknown field sets + are equal, and extensions sets are equal. + - Two set scalar fields are equal iff their values are equal. + If the fields are of a floating-point type, remember that + NaN != x for all x, including NaN. + - Two repeated fields are equal iff their lengths are the same, + and their corresponding elements are equal (a "bytes" field, + although represented by []byte, is not a repeated field) + - Two unset fields are equal. + - Two unknown field sets are equal if their current + encoded state is equal. + - Two extension sets are equal iff they have corresponding + elements that are pairwise equal. + - Every other combination of things are not equal. + +The return value is undefined if a and b are not protocol buffers. +*/ +func Equal(a, b Message) bool { + if a == nil || b == nil { + return a == b + } + v1, v2 := reflect.ValueOf(a), reflect.ValueOf(b) + if v1.Type() != v2.Type() { + return false + } + if v1.Kind() == reflect.Ptr { + if v1.IsNil() { + return v2.IsNil() + } + if v2.IsNil() { + return false + } + v1, v2 = v1.Elem(), v2.Elem() + } + if v1.Kind() != reflect.Struct { + return false + } + return equalStruct(v1, v2) +} + +// v1 and v2 are known to have the same type. +func equalStruct(v1, v2 reflect.Value) bool { + for i := 0; i < v1.NumField(); i++ { + f := v1.Type().Field(i) + if strings.HasPrefix(f.Name, "XXX_") { + continue + } + f1, f2 := v1.Field(i), v2.Field(i) + if f.Type.Kind() == reflect.Ptr { + if n1, n2 := f1.IsNil(), f2.IsNil(); n1 && n2 { + // both unset + continue + } else if n1 != n2 { + // set/unset mismatch + return false + } + b1, ok := f1.Interface().(raw) + if ok { + b2 := f2.Interface().(raw) + // RawMessage + if !bytes.Equal(b1.Bytes(), b2.Bytes()) { + return false + } + continue + } + f1, f2 = f1.Elem(), f2.Elem() + } + if !equalAny(f1, f2) { + return false + } + } + + if em1 := v1.FieldByName("XXX_extensions"); em1.IsValid() { + em2 := v2.FieldByName("XXX_extensions") + if !equalExtensions(v1.Type(), em1.Interface().(map[int32]Extension), em2.Interface().(map[int32]Extension)) { + return false + } + } + + uf := v1.FieldByName("XXX_unrecognized") + if !uf.IsValid() { + return true + } + + u1 := uf.Bytes() + u2 := v2.FieldByName("XXX_unrecognized").Bytes() + if !bytes.Equal(u1, u2) { + return false + } + + return true +} + +// v1 and v2 are known to have the same type. +func equalAny(v1, v2 reflect.Value) bool { + if v1.Type() == protoMessageType { + m1, _ := v1.Interface().(Message) + m2, _ := v2.Interface().(Message) + return Equal(m1, m2) + } + switch v1.Kind() { + case reflect.Bool: + return v1.Bool() == v2.Bool() + case reflect.Float32, reflect.Float64: + return v1.Float() == v2.Float() + case reflect.Int32, reflect.Int64: + return v1.Int() == v2.Int() + case reflect.Interface: + // Probably a oneof field; compare the inner values. + n1, n2 := v1.IsNil(), v2.IsNil() + if n1 || n2 { + return n1 == n2 + } + e1, e2 := v1.Elem(), v2.Elem() + if e1.Type() != e2.Type() { + return false + } + return equalAny(e1, e2) + case reflect.Map: + if v1.Len() != v2.Len() { + return false + } + for _, key := range v1.MapKeys() { + val2 := v2.MapIndex(key) + if !val2.IsValid() { + // This key was not found in the second map. + return false + } + if !equalAny(v1.MapIndex(key), val2) { + return false + } + } + return true + case reflect.Ptr: + return equalAny(v1.Elem(), v2.Elem()) + case reflect.Slice: + if v1.Type().Elem().Kind() == reflect.Uint8 { + // short circuit: []byte + if v1.IsNil() != v2.IsNil() { + return false + } + return bytes.Equal(v1.Interface().([]byte), v2.Interface().([]byte)) + } + + if v1.Len() != v2.Len() { + return false + } + for i := 0; i < v1.Len(); i++ { + if !equalAny(v1.Index(i), v2.Index(i)) { + return false + } + } + return true + case reflect.String: + return v1.Interface().(string) == v2.Interface().(string) + case reflect.Struct: + return equalStruct(v1, v2) + case reflect.Uint32, reflect.Uint64: + return v1.Uint() == v2.Uint() + } + + // unknown type, so not a protocol buffer + log.Printf("proto: don't know how to compare %v", v1) + return false +} + +// base is the struct type that the extensions are based on. +// em1 and em2 are extension maps. +func equalExtensions(base reflect.Type, em1, em2 map[int32]Extension) bool { + if len(em1) != len(em2) { + return false + } + + for extNum, e1 := range em1 { + e2, ok := em2[extNum] + if !ok { + return false + } + + m1, m2 := e1.value, e2.value + + if m1 != nil && m2 != nil { + // Both are unencoded. + if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2)) { + return false + } + continue + } + + // At least one is encoded. To do a semantically correct comparison + // we need to unmarshal them first. + var desc *ExtensionDesc + if m := extensionMaps[base]; m != nil { + desc = m[extNum] + } + if desc == nil { + log.Printf("proto: don't know how to compare extension %d of %v", extNum, base) + continue + } + var err error + if m1 == nil { + m1, err = decodeExtension(e1.enc, desc) + } + if m2 == nil && err == nil { + m2, err = decodeExtension(e2.enc, desc) + } + if err != nil { + // The encoded form is invalid. + log.Printf("proto: badly encoded extension %d of %v: %v", extNum, base, err) + return false + } + if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2)) { + return false + } + } + + return true +} diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/extensions.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/extensions.go new file mode 100644 index 0000000000..9a6374fdbd --- /dev/null +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/extensions.go @@ -0,0 +1,519 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +package proto + +/* + * Types and routines for supporting protocol buffer extensions. + */ + +import ( + "errors" + "fmt" + "reflect" + "strconv" + "sync" +) + +// ErrMissingExtension is the error returned by GetExtension if the named extension is not in the message. +var ErrMissingExtension = errors.New("proto: missing extension") + +// ExtensionRange represents a range of message extensions for a protocol buffer. +// Used in code generated by the protocol compiler. +type ExtensionRange struct { + Start, End int32 // both inclusive +} + +// extendableProto is an interface implemented by any protocol buffer that may be extended. +type extendableProto interface { + Message + ExtensionRangeArray() []ExtensionRange +} + +type extensionsMap interface { + extendableProto + ExtensionMap() map[int32]Extension +} + +type extensionsBytes interface { + extendableProto + GetExtensions() *[]byte +} + +var extendableProtoType = reflect.TypeOf((*extendableProto)(nil)).Elem() + +// ExtensionDesc represents an extension specification. +// Used in generated code from the protocol compiler. +type ExtensionDesc struct { + ExtendedType Message // nil pointer to the type that is being extended + ExtensionType interface{} // nil pointer to the extension type + Field int32 // field number + Name string // fully-qualified name of extension, for text formatting + Tag string // protobuf tag style +} + +func (ed *ExtensionDesc) repeated() bool { + t := reflect.TypeOf(ed.ExtensionType) + return t.Kind() == reflect.Slice && t.Elem().Kind() != reflect.Uint8 +} + +// Extension represents an extension in a message. +type Extension struct { + // When an extension is stored in a message using SetExtension + // only desc and value are set. When the message is marshaled + // enc will be set to the encoded form of the message. + // + // When a message is unmarshaled and contains extensions, each + // extension will have only enc set. When such an extension is + // accessed using GetExtension (or GetExtensions) desc and value + // will be set. + desc *ExtensionDesc + value interface{} + enc []byte +} + +// SetRawExtension is for testing only. +func SetRawExtension(base extendableProto, id int32, b []byte) { + if ebase, ok := base.(extensionsMap); ok { + ebase.ExtensionMap()[id] = Extension{enc: b} + } else if ebase, ok := base.(extensionsBytes); ok { + clearExtension(base, id) + ext := ebase.GetExtensions() + *ext = append(*ext, b...) + } else { + panic("unreachable") + } +} + +// isExtensionField returns true iff the given field number is in an extension range. +func isExtensionField(pb extendableProto, field int32) bool { + for _, er := range pb.ExtensionRangeArray() { + if er.Start <= field && field <= er.End { + return true + } + } + return false +} + +// checkExtensionTypes checks that the given extension is valid for pb. +func checkExtensionTypes(pb extendableProto, extension *ExtensionDesc) error { + // Check the extended type. + if a, b := reflect.TypeOf(pb), reflect.TypeOf(extension.ExtendedType); a != b { + return errors.New("proto: bad extended type; " + b.String() + " does not extend " + a.String()) + } + // Check the range. + if !isExtensionField(pb, extension.Field) { + return errors.New("proto: bad extension number; not in declared ranges") + } + return nil +} + +// extPropKey is sufficient to uniquely identify an extension. +type extPropKey struct { + base reflect.Type + field int32 +} + +var extProp = struct { + sync.RWMutex + m map[extPropKey]*Properties +}{ + m: make(map[extPropKey]*Properties), +} + +func extensionProperties(ed *ExtensionDesc) *Properties { + key := extPropKey{base: reflect.TypeOf(ed.ExtendedType), field: ed.Field} + + extProp.RLock() + if prop, ok := extProp.m[key]; ok { + extProp.RUnlock() + return prop + } + extProp.RUnlock() + + extProp.Lock() + defer extProp.Unlock() + // Check again. + if prop, ok := extProp.m[key]; ok { + return prop + } + + prop := new(Properties) + prop.Init(reflect.TypeOf(ed.ExtensionType), "unknown_name", ed.Tag, nil) + extProp.m[key] = prop + return prop +} + +// encodeExtensionMap encodes any unmarshaled (unencoded) extensions in m. +func encodeExtensionMap(m map[int32]Extension) error { + for k, e := range m { + err := encodeExtension(&e) + if err != nil { + return err + } + m[k] = e + } + return nil +} + +func encodeExtension(e *Extension) error { + if e.value == nil || e.desc == nil { + // Extension is only in its encoded form. + return nil + } + // We don't skip extensions that have an encoded form set, + // because the extension value may have been mutated after + // the last time this function was called. + + et := reflect.TypeOf(e.desc.ExtensionType) + props := extensionProperties(e.desc) + + p := NewBuffer(nil) + // If e.value has type T, the encoder expects a *struct{ X T }. + // Pass a *T with a zero field and hope it all works out. + x := reflect.New(et) + x.Elem().Set(reflect.ValueOf(e.value)) + if err := props.enc(p, props, toStructPointer(x)); err != nil { + return err + } + e.enc = p.buf + return nil +} + +func sizeExtensionMap(m map[int32]Extension) (n int) { + for _, e := range m { + if e.value == nil || e.desc == nil { + // Extension is only in its encoded form. + n += len(e.enc) + continue + } + + // We don't skip extensions that have an encoded form set, + // because the extension value may have been mutated after + // the last time this function was called. + + et := reflect.TypeOf(e.desc.ExtensionType) + props := extensionProperties(e.desc) + + // If e.value has type T, the encoder expects a *struct{ X T }. + // Pass a *T with a zero field and hope it all works out. + x := reflect.New(et) + x.Elem().Set(reflect.ValueOf(e.value)) + n += props.size(props, toStructPointer(x)) + } + return +} + +// HasExtension returns whether the given extension is present in pb. +func HasExtension(pb extendableProto, extension *ExtensionDesc) bool { + // TODO: Check types, field numbers, etc.? + if epb, doki := pb.(extensionsMap); doki { + _, ok := epb.ExtensionMap()[extension.Field] + return ok + } else if epb, doki := pb.(extensionsBytes); doki { + ext := epb.GetExtensions() + buf := *ext + o := 0 + for o < len(buf) { + tag, n := DecodeVarint(buf[o:]) + fieldNum := int32(tag >> 3) + if int32(fieldNum) == extension.Field { + return true + } + wireType := int(tag & 0x7) + o += n + l, err := size(buf[o:], wireType) + if err != nil { + return false + } + o += l + } + return false + } + panic("unreachable") +} + +func deleteExtension(pb extensionsBytes, theFieldNum int32, offset int) int { + ext := pb.GetExtensions() + for offset < len(*ext) { + tag, n1 := DecodeVarint((*ext)[offset:]) + fieldNum := int32(tag >> 3) + wireType := int(tag & 0x7) + n2, err := size((*ext)[offset+n1:], wireType) + if err != nil { + panic(err) + } + newOffset := offset + n1 + n2 + if fieldNum == theFieldNum { + *ext = append((*ext)[:offset], (*ext)[newOffset:]...) + return offset + } + offset = newOffset + } + return -1 +} + +func clearExtension(pb extendableProto, fieldNum int32) { + if epb, doki := pb.(extensionsMap); doki { + delete(epb.ExtensionMap(), fieldNum) + } else if epb, doki := pb.(extensionsBytes); doki { + offset := 0 + for offset != -1 { + offset = deleteExtension(epb, fieldNum, offset) + } + } else { + panic("unreachable") + } +} + +// ClearExtension removes the given extension from pb. +func ClearExtension(pb extendableProto, extension *ExtensionDesc) { + // TODO: Check types, field numbers, etc.? + clearExtension(pb, extension.Field) +} + +// GetExtension parses and returns the given extension of pb. +// If the extension is not present it returns ErrMissingExtension. +func GetExtension(pb extendableProto, extension *ExtensionDesc) (interface{}, error) { + if err := checkExtensionTypes(pb, extension); err != nil { + return nil, err + } + + if epb, doki := pb.(extensionsMap); doki { + emap := epb.ExtensionMap() + e, ok := emap[extension.Field] + if !ok { + // defaultExtensionValue returns the default value or + // ErrMissingExtension if there is no default. + return defaultExtensionValue(extension) + } + if e.value != nil { + // Already decoded. Check the descriptor, though. + if e.desc != extension { + // This shouldn't happen. If it does, it means that + // GetExtension was called twice with two different + // descriptors with the same field number. + return nil, errors.New("proto: descriptor conflict") + } + return e.value, nil + } + + v, err := decodeExtension(e.enc, extension) + if err != nil { + return nil, err + } + + // Remember the decoded version and drop the encoded version. + // That way it is safe to mutate what we return. + e.value = v + e.desc = extension + e.enc = nil + emap[extension.Field] = e + return e.value, nil + } else if epb, doki := pb.(extensionsBytes); doki { + ext := epb.GetExtensions() + o := 0 + for o < len(*ext) { + tag, n := DecodeVarint((*ext)[o:]) + fieldNum := int32(tag >> 3) + wireType := int(tag & 0x7) + l, err := size((*ext)[o+n:], wireType) + if err != nil { + return nil, err + } + if int32(fieldNum) == extension.Field { + v, err := decodeExtension((*ext)[o:o+n+l], extension) + if err != nil { + return nil, err + } + return v, nil + } + o += n + l + } + return defaultExtensionValue(extension) + } + panic("unreachable") +} + +// defaultExtensionValue returns the default value for extension. +// If no default for an extension is defined ErrMissingExtension is returned. +func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) { + t := reflect.TypeOf(extension.ExtensionType) + props := extensionProperties(extension) + + sf, _, err := fieldDefault(t, props) + if err != nil { + return nil, err + } + + if sf == nil || sf.value == nil { + // There is no default value. + return nil, ErrMissingExtension + } + + if t.Kind() != reflect.Ptr { + // We do not need to return a Ptr, we can directly return sf.value. + return sf.value, nil + } + + // We need to return an interface{} that is a pointer to sf.value. + value := reflect.New(t).Elem() + value.Set(reflect.New(value.Type().Elem())) + if sf.kind == reflect.Int32 { + // We may have an int32 or an enum, but the underlying data is int32. + // Since we can't set an int32 into a non int32 reflect.value directly + // set it as a int32. + value.Elem().SetInt(int64(sf.value.(int32))) + } else { + value.Elem().Set(reflect.ValueOf(sf.value)) + } + return value.Interface(), nil +} + +// decodeExtension decodes an extension encoded in b. +func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) { + o := NewBuffer(b) + + t := reflect.TypeOf(extension.ExtensionType) + rep := extension.repeated() + + props := extensionProperties(extension) + + // t is a pointer to a struct, pointer to basic type or a slice. + // Allocate a "field" to store the pointer/slice itself; the + // pointer/slice will be stored here. We pass + // the address of this field to props.dec. + // This passes a zero field and a *t and lets props.dec + // interpret it as a *struct{ x t }. + value := reflect.New(t).Elem() + + for { + // Discard wire type and field number varint. It isn't needed. + if _, err := o.DecodeVarint(); err != nil { + return nil, err + } + + if err := props.dec(o, props, toStructPointer(value.Addr())); err != nil { + return nil, err + } + + if !rep || o.index >= len(o.buf) { + break + } + } + return value.Interface(), nil +} + +// GetExtensions returns a slice of the extensions present in pb that are also listed in es. +// The returned slice has the same length as es; missing extensions will appear as nil elements. +func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, err error) { + epb, ok := pb.(extendableProto) + if !ok { + err = errors.New("proto: not an extendable proto") + return + } + extensions = make([]interface{}, len(es)) + for i, e := range es { + extensions[i], err = GetExtension(epb, e) + if err == ErrMissingExtension { + err = nil + } + if err != nil { + return + } + } + return +} + +// SetExtension sets the specified extension of pb to the specified value. +func SetExtension(pb extendableProto, extension *ExtensionDesc, value interface{}) error { + if err := checkExtensionTypes(pb, extension); err != nil { + return err + } + typ := reflect.TypeOf(extension.ExtensionType) + if typ != reflect.TypeOf(value) { + return errors.New("proto: bad extension value type") + } + // nil extension values need to be caught early, because the + // encoder can't distinguish an ErrNil due to a nil extension + // from an ErrNil due to a missing field. Extensions are + // always optional, so the encoder would just swallow the error + // and drop all the extensions from the encoded message. + if reflect.ValueOf(value).IsNil() { + return fmt.Errorf("proto: SetExtension called with nil value of type %T", value) + } + return setExtension(pb, extension, value) +} + +func setExtension(pb extendableProto, extension *ExtensionDesc, value interface{}) error { + if epb, doki := pb.(extensionsMap); doki { + epb.ExtensionMap()[extension.Field] = Extension{desc: extension, value: value} + } else if epb, doki := pb.(extensionsBytes); doki { + ClearExtension(pb, extension) + ext := epb.GetExtensions() + et := reflect.TypeOf(extension.ExtensionType) + props := extensionProperties(extension) + p := NewBuffer(nil) + x := reflect.New(et) + x.Elem().Set(reflect.ValueOf(value)) + if err := props.enc(p, props, toStructPointer(x)); err != nil { + return err + } + *ext = append(*ext, p.buf...) + } + return nil +} + +// A global registry of extensions. +// The generated code will register the generated descriptors by calling RegisterExtension. + +var extensionMaps = make(map[reflect.Type]map[int32]*ExtensionDesc) + +// RegisterExtension is called from the generated code. +func RegisterExtension(desc *ExtensionDesc) { + st := reflect.TypeOf(desc.ExtendedType).Elem() + m := extensionMaps[st] + if m == nil { + m = make(map[int32]*ExtensionDesc) + extensionMaps[st] = m + } + if _, ok := m[desc.Field]; ok { + panic("proto: duplicate extension registered: " + st.String() + " " + strconv.Itoa(int(desc.Field))) + } + m[desc.Field] = desc +} + +// RegisteredExtensions returns a map of the registered extensions of a +// protocol buffer struct, indexed by the extension number. +// The argument pb should be a nil pointer to the struct type. +func RegisteredExtensions(pb Message) map[int32]*ExtensionDesc { + return extensionMaps[reflect.TypeOf(pb).Elem()] +} diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/extensions_gogo.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/extensions_gogo.go new file mode 100644 index 0000000000..bd55fb68b6 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/extensions_gogo.go @@ -0,0 +1,221 @@ +// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. +// http://github.com/gogo/protobuf/gogoproto +// +// 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. +// +// 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. + +package proto + +import ( + "bytes" + "errors" + "fmt" + "reflect" + "sort" + "strings" +) + +func GetBoolExtension(pb extendableProto, extension *ExtensionDesc, ifnotset bool) bool { + if reflect.ValueOf(pb).IsNil() { + return ifnotset + } + value, err := GetExtension(pb, extension) + if err != nil { + return ifnotset + } + if value == nil { + return ifnotset + } + if value.(*bool) == nil { + return ifnotset + } + return *(value.(*bool)) +} + +func (this *Extension) Equal(that *Extension) bool { + return bytes.Equal(this.enc, that.enc) +} + +func SizeOfExtensionMap(m map[int32]Extension) (n int) { + return sizeExtensionMap(m) +} + +type sortableMapElem struct { + field int32 + ext Extension +} + +func newSortableExtensionsFromMap(m map[int32]Extension) sortableExtensions { + s := make(sortableExtensions, 0, len(m)) + for k, v := range m { + s = append(s, &sortableMapElem{field: k, ext: v}) + } + return s +} + +type sortableExtensions []*sortableMapElem + +func (this sortableExtensions) Len() int { return len(this) } + +func (this sortableExtensions) Swap(i, j int) { this[i], this[j] = this[j], this[i] } + +func (this sortableExtensions) Less(i, j int) bool { return this[i].field < this[j].field } + +func (this sortableExtensions) String() string { + sort.Sort(this) + ss := make([]string, len(this)) + for i := range this { + ss[i] = fmt.Sprintf("%d: %v", this[i].field, this[i].ext) + } + return "map[" + strings.Join(ss, ",") + "]" +} + +func StringFromExtensionsMap(m map[int32]Extension) string { + return newSortableExtensionsFromMap(m).String() +} + +func StringFromExtensionsBytes(ext []byte) string { + m, err := BytesToExtensionsMap(ext) + if err != nil { + panic(err) + } + return StringFromExtensionsMap(m) +} + +func EncodeExtensionMap(m map[int32]Extension, data []byte) (n int, err error) { + if err := encodeExtensionMap(m); err != nil { + return 0, err + } + keys := make([]int, 0, len(m)) + for k := range m { + keys = append(keys, int(k)) + } + sort.Ints(keys) + for _, k := range keys { + n += copy(data[n:], m[int32(k)].enc) + } + return n, nil +} + +func GetRawExtension(m map[int32]Extension, id int32) ([]byte, error) { + if m[id].value == nil || m[id].desc == nil { + return m[id].enc, nil + } + if err := encodeExtensionMap(m); err != nil { + return nil, err + } + return m[id].enc, nil +} + +func size(buf []byte, wire int) (int, error) { + switch wire { + case WireVarint: + _, n := DecodeVarint(buf) + return n, nil + case WireFixed64: + return 8, nil + case WireBytes: + v, n := DecodeVarint(buf) + return int(v) + n, nil + case WireFixed32: + return 4, nil + case WireStartGroup: + offset := 0 + for { + u, n := DecodeVarint(buf[offset:]) + fwire := int(u & 0x7) + offset += n + if fwire == WireEndGroup { + return offset, nil + } + s, err := size(buf[offset:], wire) + if err != nil { + return 0, err + } + offset += s + } + } + return 0, fmt.Errorf("proto: can't get size for unknown wire type %d", wire) +} + +func BytesToExtensionsMap(buf []byte) (map[int32]Extension, error) { + m := make(map[int32]Extension) + i := 0 + for i < len(buf) { + tag, n := DecodeVarint(buf[i:]) + if n <= 0 { + return nil, fmt.Errorf("unable to decode varint") + } + fieldNum := int32(tag >> 3) + wireType := int(tag & 0x7) + l, err := size(buf[i+n:], wireType) + if err != nil { + return nil, err + } + end := i + int(l) + n + m[int32(fieldNum)] = Extension{enc: buf[i:end]} + i = end + } + return m, nil +} + +func NewExtension(e []byte) Extension { + ee := Extension{enc: make([]byte, len(e))} + copy(ee.enc, e) + return ee +} + +func (this Extension) GoString() string { + if this.enc == nil { + if err := encodeExtension(&this); err != nil { + panic(err) + } + } + return fmt.Sprintf("proto.NewExtension(%#v)", this.enc) +} + +func SetUnsafeExtension(pb extendableProto, fieldNum int32, value interface{}) error { + typ := reflect.TypeOf(pb).Elem() + ext, ok := extensionMaps[typ] + if !ok { + return fmt.Errorf("proto: bad extended type; %s is not extendable", typ.String()) + } + desc, ok := ext[fieldNum] + if !ok { + return errors.New("proto: bad extension number; not in declared ranges") + } + return setExtension(pb, desc, value) +} + +func GetUnsafeExtension(pb extendableProto, fieldNum int32) (interface{}, error) { + typ := reflect.TypeOf(pb).Elem() + ext, ok := extensionMaps[typ] + if !ok { + return nil, fmt.Errorf("proto: bad extended type; %s is not extendable", typ.String()) + } + desc, ok := ext[fieldNum] + if !ok { + return nil, fmt.Errorf("unregistered field number %d", fieldNum) + } + return GetExtension(pb, desc) +} diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/lib.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/lib.go new file mode 100644 index 0000000000..8ffa91a3e9 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/lib.go @@ -0,0 +1,883 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +/* +Package proto converts data structures to and from the wire format of +protocol buffers. It works in concert with the Go source code generated +for .proto files by the protocol compiler. + +A summary of the properties of the protocol buffer interface +for a protocol buffer variable v: + + - Names are turned from camel_case to CamelCase for export. + - There are no methods on v to set fields; just treat + them as structure fields. + - There are getters that return a field's value if set, + and return the field's default value if unset. + The getters work even if the receiver is a nil message. + - The zero value for a struct is its correct initialization state. + All desired fields must be set before marshaling. + - A Reset() method will restore a protobuf struct to its zero state. + - Non-repeated fields are pointers to the values; nil means unset. + That is, optional or required field int32 f becomes F *int32. + - Repeated fields are slices. + - Helper functions are available to aid the setting of fields. + msg.Foo = proto.String("hello") // set field + - Constants are defined to hold the default values of all fields that + have them. They have the form Default_StructName_FieldName. + Because the getter methods handle defaulted values, + direct use of these constants should be rare. + - Enums are given type names and maps from names to values. + Enum values are prefixed by the enclosing message's name, or by the + enum's type name if it is a top-level enum. Enum types have a String + method, and a Enum method to assist in message construction. + - Nested messages, groups and enums have type names prefixed with the name of + the surrounding message type. + - Extensions are given descriptor names that start with E_, + followed by an underscore-delimited list of the nested messages + that contain it (if any) followed by the CamelCased name of the + extension field itself. HasExtension, ClearExtension, GetExtension + and SetExtension are functions for manipulating extensions. + - Oneof field sets are given a single field in their message, + with distinguished wrapper types for each possible field value. + - Marshal and Unmarshal are functions to encode and decode the wire format. + +The simplest way to describe this is to see an example. +Given file test.proto, containing + + package example; + + enum FOO { X = 17; } + + message Test { + required string label = 1; + optional int32 type = 2 [default=77]; + repeated int64 reps = 3; + optional group OptionalGroup = 4 { + required string RequiredField = 5; + } + oneof union { + int32 number = 6; + string name = 7; + } + } + +The resulting file, test.pb.go, is: + + package example + + import proto "github.com/gogo/protobuf/proto" + import math "math" + + type FOO int32 + const ( + FOO_X FOO = 17 + ) + var FOO_name = map[int32]string{ + 17: "X", + } + var FOO_value = map[string]int32{ + "X": 17, + } + + func (x FOO) Enum() *FOO { + p := new(FOO) + *p = x + return p + } + func (x FOO) String() string { + return proto.EnumName(FOO_name, int32(x)) + } + func (x *FOO) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(FOO_value, data) + if err != nil { + return err + } + *x = FOO(value) + return nil + } + + type Test struct { + Label *string `protobuf:"bytes,1,req,name=label" json:"label,omitempty"` + Type *int32 `protobuf:"varint,2,opt,name=type,def=77" json:"type,omitempty"` + Reps []int64 `protobuf:"varint,3,rep,name=reps" json:"reps,omitempty"` + Optionalgroup *Test_OptionalGroup `protobuf:"group,4,opt,name=OptionalGroup" json:"optionalgroup,omitempty"` + // Types that are valid to be assigned to Union: + // *Test_Number + // *Test_Name + Union isTest_Union `protobuf_oneof:"union"` + XXX_unrecognized []byte `json:"-"` + } + func (m *Test) Reset() { *m = Test{} } + func (m *Test) String() string { return proto.CompactTextString(m) } + func (*Test) ProtoMessage() {} + + type isTest_Union interface { + isTest_Union() + } + + type Test_Number struct { + Number int32 `protobuf:"varint,6,opt,name=number"` + } + type Test_Name struct { + Name string `protobuf:"bytes,7,opt,name=name"` + } + + func (*Test_Number) isTest_Union() {} + func (*Test_Name) isTest_Union() {} + + func (m *Test) GetUnion() isTest_Union { + if m != nil { + return m.Union + } + return nil + } + const Default_Test_Type int32 = 77 + + func (m *Test) GetLabel() string { + if m != nil && m.Label != nil { + return *m.Label + } + return "" + } + + func (m *Test) GetType() int32 { + if m != nil && m.Type != nil { + return *m.Type + } + return Default_Test_Type + } + + func (m *Test) GetOptionalgroup() *Test_OptionalGroup { + if m != nil { + return m.Optionalgroup + } + return nil + } + + type Test_OptionalGroup struct { + RequiredField *string `protobuf:"bytes,5,req" json:"RequiredField,omitempty"` + } + func (m *Test_OptionalGroup) Reset() { *m = Test_OptionalGroup{} } + func (m *Test_OptionalGroup) String() string { return proto.CompactTextString(m) } + + func (m *Test_OptionalGroup) GetRequiredField() string { + if m != nil && m.RequiredField != nil { + return *m.RequiredField + } + return "" + } + + func (m *Test) GetNumber() int32 { + if x, ok := m.GetUnion().(*Test_Number); ok { + return x.Number + } + return 0 + } + + func (m *Test) GetName() string { + if x, ok := m.GetUnion().(*Test_Name); ok { + return x.Name + } + return "" + } + + func init() { + proto.RegisterEnum("example.FOO", FOO_name, FOO_value) + } + +To create and play with a Test object: + + package main + + import ( + "log" + + "github.com/gogo/protobuf/proto" + pb "./example.pb" + ) + + func main() { + test := &pb.Test{ + Label: proto.String("hello"), + Type: proto.Int32(17), + Optionalgroup: &pb.Test_OptionalGroup{ + RequiredField: proto.String("good bye"), + }, + Union: &pb.Test_Name{"fred"}, + } + data, err := proto.Marshal(test) + if err != nil { + log.Fatal("marshaling error: ", err) + } + newTest := &pb.Test{} + err = proto.Unmarshal(data, newTest) + if err != nil { + log.Fatal("unmarshaling error: ", err) + } + // Now test and newTest contain the same data. + if test.GetLabel() != newTest.GetLabel() { + log.Fatalf("data mismatch %q != %q", test.GetLabel(), newTest.GetLabel()) + } + // Use a type switch to determine which oneof was set. + switch u := test.Union.(type) { + case *pb.Test_Number: // u.Number contains the number. + case *pb.Test_Name: // u.Name contains the string. + } + // etc. + } +*/ +package proto + +import ( + "encoding/json" + "fmt" + "log" + "reflect" + "sort" + "strconv" + "sync" +) + +// Message is implemented by generated protocol buffer messages. +type Message interface { + Reset() + String() string + ProtoMessage() +} + +// Stats records allocation details about the protocol buffer encoders +// and decoders. Useful for tuning the library itself. +type Stats struct { + Emalloc uint64 // mallocs in encode + Dmalloc uint64 // mallocs in decode + Encode uint64 // number of encodes + Decode uint64 // number of decodes + Chit uint64 // number of cache hits + Cmiss uint64 // number of cache misses + Size uint64 // number of sizes +} + +// Set to true to enable stats collection. +const collectStats = false + +var stats Stats + +// GetStats returns a copy of the global Stats structure. +func GetStats() Stats { return stats } + +// A Buffer is a buffer manager for marshaling and unmarshaling +// protocol buffers. It may be reused between invocations to +// reduce memory usage. It is not necessary to use a Buffer; +// the global functions Marshal and Unmarshal create a +// temporary Buffer and are fine for most applications. +type Buffer struct { + buf []byte // encode/decode byte stream + index int // write point + + // pools of basic types to amortize allocation. + bools []bool + uint32s []uint32 + uint64s []uint64 + + // extra pools, only used with pointer_reflect.go + int32s []int32 + int64s []int64 + float32s []float32 + float64s []float64 +} + +// NewBuffer allocates a new Buffer and initializes its internal data to +// the contents of the argument slice. +func NewBuffer(e []byte) *Buffer { + return &Buffer{buf: e} +} + +// Reset resets the Buffer, ready for marshaling a new protocol buffer. +func (p *Buffer) Reset() { + p.buf = p.buf[0:0] // for reading/writing + p.index = 0 // for reading +} + +// SetBuf replaces the internal buffer with the slice, +// ready for unmarshaling the contents of the slice. +func (p *Buffer) SetBuf(s []byte) { + p.buf = s + p.index = 0 +} + +// Bytes returns the contents of the Buffer. +func (p *Buffer) Bytes() []byte { return p.buf } + +/* + * Helper routines for simplifying the creation of optional fields of basic type. + */ + +// Bool is a helper routine that allocates a new bool value +// to store v and returns a pointer to it. +func Bool(v bool) *bool { + return &v +} + +// Int32 is a helper routine that allocates a new int32 value +// to store v and returns a pointer to it. +func Int32(v int32) *int32 { + return &v +} + +// Int is a helper routine that allocates a new int32 value +// to store v and returns a pointer to it, but unlike Int32 +// its argument value is an int. +func Int(v int) *int32 { + p := new(int32) + *p = int32(v) + return p +} + +// Int64 is a helper routine that allocates a new int64 value +// to store v and returns a pointer to it. +func Int64(v int64) *int64 { + return &v +} + +// Float32 is a helper routine that allocates a new float32 value +// to store v and returns a pointer to it. +func Float32(v float32) *float32 { + return &v +} + +// Float64 is a helper routine that allocates a new float64 value +// to store v and returns a pointer to it. +func Float64(v float64) *float64 { + return &v +} + +// Uint32 is a helper routine that allocates a new uint32 value +// to store v and returns a pointer to it. +func Uint32(v uint32) *uint32 { + return &v +} + +// Uint64 is a helper routine that allocates a new uint64 value +// to store v and returns a pointer to it. +func Uint64(v uint64) *uint64 { + return &v +} + +// String is a helper routine that allocates a new string value +// to store v and returns a pointer to it. +func String(v string) *string { + return &v +} + +// EnumName is a helper function to simplify printing protocol buffer enums +// by name. Given an enum map and a value, it returns a useful string. +func EnumName(m map[int32]string, v int32) string { + s, ok := m[v] + if ok { + return s + } + return strconv.Itoa(int(v)) +} + +// UnmarshalJSONEnum is a helper function to simplify recovering enum int values +// from their JSON-encoded representation. Given a map from the enum's symbolic +// names to its int values, and a byte buffer containing the JSON-encoded +// value, it returns an int32 that can be cast to the enum type by the caller. +// +// The function can deal with both JSON representations, numeric and symbolic. +func UnmarshalJSONEnum(m map[string]int32, data []byte, enumName string) (int32, error) { + if data[0] == '"' { + // New style: enums are strings. + var repr string + if err := json.Unmarshal(data, &repr); err != nil { + return -1, err + } + val, ok := m[repr] + if !ok { + return 0, fmt.Errorf("unrecognized enum %s value %q", enumName, repr) + } + return val, nil + } + // Old style: enums are ints. + var val int32 + if err := json.Unmarshal(data, &val); err != nil { + return 0, fmt.Errorf("cannot unmarshal %#q into enum %s", data, enumName) + } + return val, nil +} + +// DebugPrint dumps the encoded data in b in a debugging format with a header +// including the string s. Used in testing but made available for general debugging. +func (p *Buffer) DebugPrint(s string, b []byte) { + var u uint64 + + obuf := p.buf + index := p.index + p.buf = b + p.index = 0 + depth := 0 + + fmt.Printf("\n--- %s ---\n", s) + +out: + for { + for i := 0; i < depth; i++ { + fmt.Print(" ") + } + + index := p.index + if index == len(p.buf) { + break + } + + op, err := p.DecodeVarint() + if err != nil { + fmt.Printf("%3d: fetching op err %v\n", index, err) + break out + } + tag := op >> 3 + wire := op & 7 + + switch wire { + default: + fmt.Printf("%3d: t=%3d unknown wire=%d\n", + index, tag, wire) + break out + + case WireBytes: + var r []byte + + r, err = p.DecodeRawBytes(false) + if err != nil { + break out + } + fmt.Printf("%3d: t=%3d bytes [%d]", index, tag, len(r)) + if len(r) <= 6 { + for i := 0; i < len(r); i++ { + fmt.Printf(" %.2x", r[i]) + } + } else { + for i := 0; i < 3; i++ { + fmt.Printf(" %.2x", r[i]) + } + fmt.Printf(" ..") + for i := len(r) - 3; i < len(r); i++ { + fmt.Printf(" %.2x", r[i]) + } + } + fmt.Printf("\n") + + case WireFixed32: + u, err = p.DecodeFixed32() + if err != nil { + fmt.Printf("%3d: t=%3d fix32 err %v\n", index, tag, err) + break out + } + fmt.Printf("%3d: t=%3d fix32 %d\n", index, tag, u) + + case WireFixed64: + u, err = p.DecodeFixed64() + if err != nil { + fmt.Printf("%3d: t=%3d fix64 err %v\n", index, tag, err) + break out + } + fmt.Printf("%3d: t=%3d fix64 %d\n", index, tag, u) + + case WireVarint: + u, err = p.DecodeVarint() + if err != nil { + fmt.Printf("%3d: t=%3d varint err %v\n", index, tag, err) + break out + } + fmt.Printf("%3d: t=%3d varint %d\n", index, tag, u) + + case WireStartGroup: + fmt.Printf("%3d: t=%3d start\n", index, tag) + depth++ + + case WireEndGroup: + depth-- + fmt.Printf("%3d: t=%3d end\n", index, tag) + } + } + + if depth != 0 { + fmt.Printf("%3d: start-end not balanced %d\n", p.index, depth) + } + fmt.Printf("\n") + + p.buf = obuf + p.index = index +} + +// SetDefaults sets unset protocol buffer fields to their default values. +// It only modifies fields that are both unset and have defined defaults. +// It recursively sets default values in any non-nil sub-messages. +func SetDefaults(pb Message) { + setDefaults(reflect.ValueOf(pb), true, false) +} + +// v is a pointer to a struct. +func setDefaults(v reflect.Value, recur, zeros bool) { + v = v.Elem() + + defaultMu.RLock() + dm, ok := defaults[v.Type()] + defaultMu.RUnlock() + if !ok { + dm = buildDefaultMessage(v.Type()) + defaultMu.Lock() + defaults[v.Type()] = dm + defaultMu.Unlock() + } + + for _, sf := range dm.scalars { + f := v.Field(sf.index) + if !f.IsNil() { + // field already set + continue + } + dv := sf.value + if dv == nil && !zeros { + // no explicit default, and don't want to set zeros + continue + } + fptr := f.Addr().Interface() // **T + // TODO: Consider batching the allocations we do here. + switch sf.kind { + case reflect.Bool: + b := new(bool) + if dv != nil { + *b = dv.(bool) + } + *(fptr.(**bool)) = b + case reflect.Float32: + f := new(float32) + if dv != nil { + *f = dv.(float32) + } + *(fptr.(**float32)) = f + case reflect.Float64: + f := new(float64) + if dv != nil { + *f = dv.(float64) + } + *(fptr.(**float64)) = f + case reflect.Int32: + // might be an enum + if ft := f.Type(); ft != int32PtrType { + // enum + f.Set(reflect.New(ft.Elem())) + if dv != nil { + f.Elem().SetInt(int64(dv.(int32))) + } + } else { + // int32 field + i := new(int32) + if dv != nil { + *i = dv.(int32) + } + *(fptr.(**int32)) = i + } + case reflect.Int64: + i := new(int64) + if dv != nil { + *i = dv.(int64) + } + *(fptr.(**int64)) = i + case reflect.String: + s := new(string) + if dv != nil { + *s = dv.(string) + } + *(fptr.(**string)) = s + case reflect.Uint8: + // exceptional case: []byte + var b []byte + if dv != nil { + db := dv.([]byte) + b = make([]byte, len(db)) + copy(b, db) + } else { + b = []byte{} + } + *(fptr.(*[]byte)) = b + case reflect.Uint32: + u := new(uint32) + if dv != nil { + *u = dv.(uint32) + } + *(fptr.(**uint32)) = u + case reflect.Uint64: + u := new(uint64) + if dv != nil { + *u = dv.(uint64) + } + *(fptr.(**uint64)) = u + default: + log.Printf("proto: can't set default for field %v (sf.kind=%v)", f, sf.kind) + } + } + + for _, ni := range dm.nested { + f := v.Field(ni) + // f is *T or []*T or map[T]*T + switch f.Kind() { + case reflect.Ptr: + if f.IsNil() { + continue + } + setDefaults(f, recur, zeros) + + case reflect.Slice: + for i := 0; i < f.Len(); i++ { + e := f.Index(i) + if e.IsNil() { + continue + } + setDefaults(e, recur, zeros) + } + + case reflect.Map: + for _, k := range f.MapKeys() { + e := f.MapIndex(k) + if e.IsNil() { + continue + } + setDefaults(e, recur, zeros) + } + } + } +} + +var ( + // defaults maps a protocol buffer struct type to a slice of the fields, + // with its scalar fields set to their proto-declared non-zero default values. + defaultMu sync.RWMutex + defaults = make(map[reflect.Type]defaultMessage) + + int32PtrType = reflect.TypeOf((*int32)(nil)) +) + +// defaultMessage represents information about the default values of a message. +type defaultMessage struct { + scalars []scalarField + nested []int // struct field index of nested messages +} + +type scalarField struct { + index int // struct field index + kind reflect.Kind // element type (the T in *T or []T) + value interface{} // the proto-declared default value, or nil +} + +// t is a struct type. +func buildDefaultMessage(t reflect.Type) (dm defaultMessage) { + sprop := GetProperties(t) + for _, prop := range sprop.Prop { + fi, ok := sprop.decoderTags.get(prop.Tag) + if !ok { + // XXX_unrecognized + continue + } + ft := t.Field(fi).Type + + sf, nested, err := fieldDefault(ft, prop) + switch { + case err != nil: + log.Print(err) + case nested: + dm.nested = append(dm.nested, fi) + case sf != nil: + sf.index = fi + dm.scalars = append(dm.scalars, *sf) + } + } + + return dm +} + +// fieldDefault returns the scalarField for field type ft. +// sf will be nil if the field can not have a default. +// nestedMessage will be true if this is a nested message. +// Note that sf.index is not set on return. +func fieldDefault(ft reflect.Type, prop *Properties) (sf *scalarField, nestedMessage bool, err error) { + var canHaveDefault bool + switch ft.Kind() { + case reflect.Ptr: + if ft.Elem().Kind() == reflect.Struct { + nestedMessage = true + } else { + canHaveDefault = true // proto2 scalar field + } + + case reflect.Slice: + switch ft.Elem().Kind() { + case reflect.Ptr: + nestedMessage = true // repeated message + case reflect.Uint8: + canHaveDefault = true // bytes field + } + + case reflect.Map: + if ft.Elem().Kind() == reflect.Ptr { + nestedMessage = true // map with message values + } + } + + if !canHaveDefault { + if nestedMessage { + return nil, true, nil + } + return nil, false, nil + } + + // We now know that ft is a pointer or slice. + sf = &scalarField{kind: ft.Elem().Kind()} + + // scalar fields without defaults + if !prop.HasDefault { + return sf, false, nil + } + + // a scalar field: either *T or []byte + switch ft.Elem().Kind() { + case reflect.Bool: + x, err := strconv.ParseBool(prop.Default) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default bool %q: %v", prop.Default, err) + } + sf.value = x + case reflect.Float32: + x, err := strconv.ParseFloat(prop.Default, 32) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default float32 %q: %v", prop.Default, err) + } + sf.value = float32(x) + case reflect.Float64: + x, err := strconv.ParseFloat(prop.Default, 64) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default float64 %q: %v", prop.Default, err) + } + sf.value = x + case reflect.Int32: + x, err := strconv.ParseInt(prop.Default, 10, 32) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default int32 %q: %v", prop.Default, err) + } + sf.value = int32(x) + case reflect.Int64: + x, err := strconv.ParseInt(prop.Default, 10, 64) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default int64 %q: %v", prop.Default, err) + } + sf.value = x + case reflect.String: + sf.value = prop.Default + case reflect.Uint8: + // []byte (not *uint8) + sf.value = []byte(prop.Default) + case reflect.Uint32: + x, err := strconv.ParseUint(prop.Default, 10, 32) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default uint32 %q: %v", prop.Default, err) + } + sf.value = uint32(x) + case reflect.Uint64: + x, err := strconv.ParseUint(prop.Default, 10, 64) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default uint64 %q: %v", prop.Default, err) + } + sf.value = x + default: + return nil, false, fmt.Errorf("proto: unhandled def kind %v", ft.Elem().Kind()) + } + + return sf, false, nil +} + +// Map fields may have key types of non-float scalars, strings and enums. +// The easiest way to sort them in some deterministic order is to use fmt. +// If this turns out to be inefficient we can always consider other options, +// such as doing a Schwartzian transform. + +func mapKeys(vs []reflect.Value) sort.Interface { + s := mapKeySorter{ + vs: vs, + // default Less function: textual comparison + less: func(a, b reflect.Value) bool { + return fmt.Sprint(a.Interface()) < fmt.Sprint(b.Interface()) + }, + } + + // Type specialization per https://developers.google.com/protocol-buffers/docs/proto#maps; + // numeric keys are sorted numerically. + if len(vs) == 0 { + return s + } + switch vs[0].Kind() { + case reflect.Int32, reflect.Int64: + s.less = func(a, b reflect.Value) bool { return a.Int() < b.Int() } + case reflect.Uint32, reflect.Uint64: + s.less = func(a, b reflect.Value) bool { return a.Uint() < b.Uint() } + } + + return s +} + +type mapKeySorter struct { + vs []reflect.Value + less func(a, b reflect.Value) bool +} + +func (s mapKeySorter) Len() int { return len(s.vs) } +func (s mapKeySorter) Swap(i, j int) { s.vs[i], s.vs[j] = s.vs[j], s.vs[i] } +func (s mapKeySorter) Less(i, j int) bool { + return s.less(s.vs[i], s.vs[j]) +} + +// isProto3Zero reports whether v is a zero proto3 value. +func isProto3Zero(v reflect.Value) bool { + switch v.Kind() { + case reflect.Bool: + return !v.Bool() + case reflect.Int32, reflect.Int64: + return v.Int() == 0 + case reflect.Uint32, reflect.Uint64: + return v.Uint() == 0 + case reflect.Float32, reflect.Float64: + return v.Float() == 0 + case reflect.String: + return v.String() == "" + } + return false +} diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/lib_gogo.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/lib_gogo.go new file mode 100644 index 0000000000..a6c2c06b23 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/lib_gogo.go @@ -0,0 +1,40 @@ +// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. +// http://github.com/gogo/protobuf/gogoproto +// +// 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. +// +// 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. + +package proto + +import ( + "encoding/json" + "strconv" +) + +func MarshalJSONEnum(m map[int32]string, value int32) ([]byte, error) { + s, ok := m[value] + if !ok { + s = strconv.Itoa(int(value)) + } + return json.Marshal(s) +} diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/message_set.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/message_set.go new file mode 100644 index 0000000000..e25e01e637 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/message_set.go @@ -0,0 +1,280 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +package proto + +/* + * Support for message sets. + */ + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + "reflect" + "sort" +) + +// errNoMessageTypeID occurs when a protocol buffer does not have a message type ID. +// A message type ID is required for storing a protocol buffer in a message set. +var errNoMessageTypeID = errors.New("proto does not have a message type ID") + +// The first two types (_MessageSet_Item and messageSet) +// model what the protocol compiler produces for the following protocol message: +// message MessageSet { +// repeated group Item = 1 { +// required int32 type_id = 2; +// required string message = 3; +// }; +// } +// That is the MessageSet wire format. We can't use a proto to generate these +// because that would introduce a circular dependency between it and this package. + +type _MessageSet_Item struct { + TypeId *int32 `protobuf:"varint,2,req,name=type_id"` + Message []byte `protobuf:"bytes,3,req,name=message"` +} + +type messageSet struct { + Item []*_MessageSet_Item `protobuf:"group,1,rep"` + XXX_unrecognized []byte + // TODO: caching? +} + +// Make sure messageSet is a Message. +var _ Message = (*messageSet)(nil) + +// messageTypeIder is an interface satisfied by a protocol buffer type +// that may be stored in a MessageSet. +type messageTypeIder interface { + MessageTypeId() int32 +} + +func (ms *messageSet) find(pb Message) *_MessageSet_Item { + mti, ok := pb.(messageTypeIder) + if !ok { + return nil + } + id := mti.MessageTypeId() + for _, item := range ms.Item { + if *item.TypeId == id { + return item + } + } + return nil +} + +func (ms *messageSet) Has(pb Message) bool { + if ms.find(pb) != nil { + return true + } + return false +} + +func (ms *messageSet) Unmarshal(pb Message) error { + if item := ms.find(pb); item != nil { + return Unmarshal(item.Message, pb) + } + if _, ok := pb.(messageTypeIder); !ok { + return errNoMessageTypeID + } + return nil // TODO: return error instead? +} + +func (ms *messageSet) Marshal(pb Message) error { + msg, err := Marshal(pb) + if err != nil { + return err + } + if item := ms.find(pb); item != nil { + // reuse existing item + item.Message = msg + return nil + } + + mti, ok := pb.(messageTypeIder) + if !ok { + return errNoMessageTypeID + } + + mtid := mti.MessageTypeId() + ms.Item = append(ms.Item, &_MessageSet_Item{ + TypeId: &mtid, + Message: msg, + }) + return nil +} + +func (ms *messageSet) Reset() { *ms = messageSet{} } +func (ms *messageSet) String() string { return CompactTextString(ms) } +func (*messageSet) ProtoMessage() {} + +// Support for the message_set_wire_format message option. + +func skipVarint(buf []byte) []byte { + i := 0 + for ; buf[i]&0x80 != 0; i++ { + } + return buf[i+1:] +} + +// MarshalMessageSet encodes the extension map represented by m in the message set wire format. +// It is called by generated Marshal methods on protocol buffer messages with the message_set_wire_format option. +func MarshalMessageSet(m map[int32]Extension) ([]byte, error) { + if err := encodeExtensionMap(m); err != nil { + return nil, err + } + + // Sort extension IDs to provide a deterministic encoding. + // See also enc_map in encode.go. + ids := make([]int, 0, len(m)) + for id := range m { + ids = append(ids, int(id)) + } + sort.Ints(ids) + + ms := &messageSet{Item: make([]*_MessageSet_Item, 0, len(m))} + for _, id := range ids { + e := m[int32(id)] + // Remove the wire type and field number varint, as well as the length varint. + msg := skipVarint(skipVarint(e.enc)) + + ms.Item = append(ms.Item, &_MessageSet_Item{ + TypeId: Int32(int32(id)), + Message: msg, + }) + } + return Marshal(ms) +} + +// UnmarshalMessageSet decodes the extension map encoded in buf in the message set wire format. +// It is called by generated Unmarshal methods on protocol buffer messages with the message_set_wire_format option. +func UnmarshalMessageSet(buf []byte, m map[int32]Extension) error { + ms := new(messageSet) + if err := Unmarshal(buf, ms); err != nil { + return err + } + for _, item := range ms.Item { + id := *item.TypeId + msg := item.Message + + // Restore wire type and field number varint, plus length varint. + // Be careful to preserve duplicate items. + b := EncodeVarint(uint64(id)<<3 | WireBytes) + if ext, ok := m[id]; ok { + // Existing data; rip off the tag and length varint + // so we join the new data correctly. + // We can assume that ext.enc is set because we are unmarshaling. + o := ext.enc[len(b):] // skip wire type and field number + _, n := DecodeVarint(o) // calculate length of length varint + o = o[n:] // skip length varint + msg = append(o, msg...) // join old data and new data + } + b = append(b, EncodeVarint(uint64(len(msg)))...) + b = append(b, msg...) + + m[id] = Extension{enc: b} + } + return nil +} + +// MarshalMessageSetJSON encodes the extension map represented by m in JSON format. +// It is called by generated MarshalJSON methods on protocol buffer messages with the message_set_wire_format option. +func MarshalMessageSetJSON(m map[int32]Extension) ([]byte, error) { + var b bytes.Buffer + b.WriteByte('{') + + // Process the map in key order for deterministic output. + ids := make([]int32, 0, len(m)) + for id := range m { + ids = append(ids, id) + } + sort.Sort(int32Slice(ids)) // int32Slice defined in text.go + + for i, id := range ids { + ext := m[id] + if i > 0 { + b.WriteByte(',') + } + + msd, ok := messageSetMap[id] + if !ok { + // Unknown type; we can't render it, so skip it. + continue + } + fmt.Fprintf(&b, `"[%s]":`, msd.name) + + x := ext.value + if x == nil { + x = reflect.New(msd.t.Elem()).Interface() + if err := Unmarshal(ext.enc, x.(Message)); err != nil { + return nil, err + } + } + d, err := json.Marshal(x) + if err != nil { + return nil, err + } + b.Write(d) + } + b.WriteByte('}') + return b.Bytes(), nil +} + +// UnmarshalMessageSetJSON decodes the extension map encoded in buf in JSON format. +// It is called by generated UnmarshalJSON methods on protocol buffer messages with the message_set_wire_format option. +func UnmarshalMessageSetJSON(buf []byte, m map[int32]Extension) error { + // Common-case fast path. + if len(buf) == 0 || bytes.Equal(buf, []byte("{}")) { + return nil + } + + // This is fairly tricky, and it's not clear that it is needed. + return errors.New("TODO: UnmarshalMessageSetJSON not yet implemented") +} + +// A global registry of types that can be used in a MessageSet. + +var messageSetMap = make(map[int32]messageSetDesc) + +type messageSetDesc struct { + t reflect.Type // pointer to struct + name string +} + +// RegisterMessageSetType is called from the generated code. +func RegisterMessageSetType(m Message, fieldNum int32, name string) { + messageSetMap[fieldNum] = messageSetDesc{ + t: reflect.TypeOf(m), + name: name, + } +} diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_reflect.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_reflect.go new file mode 100644 index 0000000000..749919d250 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_reflect.go @@ -0,0 +1,479 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2012 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +// +build appengine + +// This file contains an implementation of proto field accesses using package reflect. +// It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can +// be used on App Engine. + +package proto + +import ( + "math" + "reflect" +) + +// A structPointer is a pointer to a struct. +type structPointer struct { + v reflect.Value +} + +// toStructPointer returns a structPointer equivalent to the given reflect value. +// The reflect value must itself be a pointer to a struct. +func toStructPointer(v reflect.Value) structPointer { + return structPointer{v} +} + +// IsNil reports whether p is nil. +func structPointer_IsNil(p structPointer) bool { + return p.v.IsNil() +} + +// Interface returns the struct pointer as an interface value. +func structPointer_Interface(p structPointer, _ reflect.Type) interface{} { + return p.v.Interface() +} + +// A field identifies a field in a struct, accessible from a structPointer. +// In this implementation, a field is identified by the sequence of field indices +// passed to reflect's FieldByIndex. +type field []int + +// toField returns a field equivalent to the given reflect field. +func toField(f *reflect.StructField) field { + return f.Index +} + +// invalidField is an invalid field identifier. +var invalidField = field(nil) + +// IsValid reports whether the field identifier is valid. +func (f field) IsValid() bool { return f != nil } + +// field returns the given field in the struct as a reflect value. +func structPointer_field(p structPointer, f field) reflect.Value { + // Special case: an extension map entry with a value of type T + // passes a *T to the struct-handling code with a zero field, + // expecting that it will be treated as equivalent to *struct{ X T }, + // which has the same memory layout. We have to handle that case + // specially, because reflect will panic if we call FieldByIndex on a + // non-struct. + if f == nil { + return p.v.Elem() + } + + return p.v.Elem().FieldByIndex(f) +} + +// ifield returns the given field in the struct as an interface value. +func structPointer_ifield(p structPointer, f field) interface{} { + return structPointer_field(p, f).Addr().Interface() +} + +// Bytes returns the address of a []byte field in the struct. +func structPointer_Bytes(p structPointer, f field) *[]byte { + return structPointer_ifield(p, f).(*[]byte) +} + +// BytesSlice returns the address of a [][]byte field in the struct. +func structPointer_BytesSlice(p structPointer, f field) *[][]byte { + return structPointer_ifield(p, f).(*[][]byte) +} + +// Bool returns the address of a *bool field in the struct. +func structPointer_Bool(p structPointer, f field) **bool { + return structPointer_ifield(p, f).(**bool) +} + +// BoolVal returns the address of a bool field in the struct. +func structPointer_BoolVal(p structPointer, f field) *bool { + return structPointer_ifield(p, f).(*bool) +} + +// BoolSlice returns the address of a []bool field in the struct. +func structPointer_BoolSlice(p structPointer, f field) *[]bool { + return structPointer_ifield(p, f).(*[]bool) +} + +// String returns the address of a *string field in the struct. +func structPointer_String(p structPointer, f field) **string { + return structPointer_ifield(p, f).(**string) +} + +// StringVal returns the address of a string field in the struct. +func structPointer_StringVal(p structPointer, f field) *string { + return structPointer_ifield(p, f).(*string) +} + +// StringSlice returns the address of a []string field in the struct. +func structPointer_StringSlice(p structPointer, f field) *[]string { + return structPointer_ifield(p, f).(*[]string) +} + +// ExtMap returns the address of an extension map field in the struct. +func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension { + return structPointer_ifield(p, f).(*map[int32]Extension) +} + +// NewAt returns the reflect.Value for a pointer to a field in the struct. +func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value { + return structPointer_field(p, f).Addr() +} + +// SetStructPointer writes a *struct field in the struct. +func structPointer_SetStructPointer(p structPointer, f field, q structPointer) { + structPointer_field(p, f).Set(q.v) +} + +// GetStructPointer reads a *struct field in the struct. +func structPointer_GetStructPointer(p structPointer, f field) structPointer { + return structPointer{structPointer_field(p, f)} +} + +// StructPointerSlice the address of a []*struct field in the struct. +func structPointer_StructPointerSlice(p structPointer, f field) structPointerSlice { + return structPointerSlice{structPointer_field(p, f)} +} + +// A structPointerSlice represents the address of a slice of pointers to structs +// (themselves messages or groups). That is, v.Type() is *[]*struct{...}. +type structPointerSlice struct { + v reflect.Value +} + +func (p structPointerSlice) Len() int { return p.v.Len() } +func (p structPointerSlice) Index(i int) structPointer { return structPointer{p.v.Index(i)} } +func (p structPointerSlice) Append(q structPointer) { + p.v.Set(reflect.Append(p.v, q.v)) +} + +var ( + int32Type = reflect.TypeOf(int32(0)) + uint32Type = reflect.TypeOf(uint32(0)) + float32Type = reflect.TypeOf(float32(0)) + int64Type = reflect.TypeOf(int64(0)) + uint64Type = reflect.TypeOf(uint64(0)) + float64Type = reflect.TypeOf(float64(0)) +) + +// A word32 represents a field of type *int32, *uint32, *float32, or *enum. +// That is, v.Type() is *int32, *uint32, *float32, or *enum and v is assignable. +type word32 struct { + v reflect.Value +} + +// IsNil reports whether p is nil. +func word32_IsNil(p word32) bool { + return p.v.IsNil() +} + +// Set sets p to point at a newly allocated word with bits set to x. +func word32_Set(p word32, o *Buffer, x uint32) { + t := p.v.Type().Elem() + switch t { + case int32Type: + if len(o.int32s) == 0 { + o.int32s = make([]int32, uint32PoolSize) + } + o.int32s[0] = int32(x) + p.v.Set(reflect.ValueOf(&o.int32s[0])) + o.int32s = o.int32s[1:] + return + case uint32Type: + if len(o.uint32s) == 0 { + o.uint32s = make([]uint32, uint32PoolSize) + } + o.uint32s[0] = x + p.v.Set(reflect.ValueOf(&o.uint32s[0])) + o.uint32s = o.uint32s[1:] + return + case float32Type: + if len(o.float32s) == 0 { + o.float32s = make([]float32, uint32PoolSize) + } + o.float32s[0] = math.Float32frombits(x) + p.v.Set(reflect.ValueOf(&o.float32s[0])) + o.float32s = o.float32s[1:] + return + } + + // must be enum + p.v.Set(reflect.New(t)) + p.v.Elem().SetInt(int64(int32(x))) +} + +// Get gets the bits pointed at by p, as a uint32. +func word32_Get(p word32) uint32 { + elem := p.v.Elem() + switch elem.Kind() { + case reflect.Int32: + return uint32(elem.Int()) + case reflect.Uint32: + return uint32(elem.Uint()) + case reflect.Float32: + return math.Float32bits(float32(elem.Float())) + } + panic("unreachable") +} + +// Word32 returns a reference to a *int32, *uint32, *float32, or *enum field in the struct. +func structPointer_Word32(p structPointer, f field) word32 { + return word32{structPointer_field(p, f)} +} + +// A word32Val represents a field of type int32, uint32, float32, or enum. +// That is, v.Type() is int32, uint32, float32, or enum and v is assignable. +type word32Val struct { + v reflect.Value +} + +// Set sets *p to x. +func word32Val_Set(p word32Val, x uint32) { + switch p.v.Type() { + case int32Type: + p.v.SetInt(int64(x)) + return + case uint32Type: + p.v.SetUint(uint64(x)) + return + case float32Type: + p.v.SetFloat(float64(math.Float32frombits(x))) + return + } + + // must be enum + p.v.SetInt(int64(int32(x))) +} + +// Get gets the bits pointed at by p, as a uint32. +func word32Val_Get(p word32Val) uint32 { + elem := p.v + switch elem.Kind() { + case reflect.Int32: + return uint32(elem.Int()) + case reflect.Uint32: + return uint32(elem.Uint()) + case reflect.Float32: + return math.Float32bits(float32(elem.Float())) + } + panic("unreachable") +} + +// Word32Val returns a reference to a int32, uint32, float32, or enum field in the struct. +func structPointer_Word32Val(p structPointer, f field) word32Val { + return word32Val{structPointer_field(p, f)} +} + +// A word32Slice is a slice of 32-bit values. +// That is, v.Type() is []int32, []uint32, []float32, or []enum. +type word32Slice struct { + v reflect.Value +} + +func (p word32Slice) Append(x uint32) { + n, m := p.v.Len(), p.v.Cap() + if n < m { + p.v.SetLen(n + 1) + } else { + t := p.v.Type().Elem() + p.v.Set(reflect.Append(p.v, reflect.Zero(t))) + } + elem := p.v.Index(n) + switch elem.Kind() { + case reflect.Int32: + elem.SetInt(int64(int32(x))) + case reflect.Uint32: + elem.SetUint(uint64(x)) + case reflect.Float32: + elem.SetFloat(float64(math.Float32frombits(x))) + } +} + +func (p word32Slice) Len() int { + return p.v.Len() +} + +func (p word32Slice) Index(i int) uint32 { + elem := p.v.Index(i) + switch elem.Kind() { + case reflect.Int32: + return uint32(elem.Int()) + case reflect.Uint32: + return uint32(elem.Uint()) + case reflect.Float32: + return math.Float32bits(float32(elem.Float())) + } + panic("unreachable") +} + +// Word32Slice returns a reference to a []int32, []uint32, []float32, or []enum field in the struct. +func structPointer_Word32Slice(p structPointer, f field) word32Slice { + return word32Slice{structPointer_field(p, f)} +} + +// word64 is like word32 but for 64-bit values. +type word64 struct { + v reflect.Value +} + +func word64_Set(p word64, o *Buffer, x uint64) { + t := p.v.Type().Elem() + switch t { + case int64Type: + if len(o.int64s) == 0 { + o.int64s = make([]int64, uint64PoolSize) + } + o.int64s[0] = int64(x) + p.v.Set(reflect.ValueOf(&o.int64s[0])) + o.int64s = o.int64s[1:] + return + case uint64Type: + if len(o.uint64s) == 0 { + o.uint64s = make([]uint64, uint64PoolSize) + } + o.uint64s[0] = x + p.v.Set(reflect.ValueOf(&o.uint64s[0])) + o.uint64s = o.uint64s[1:] + return + case float64Type: + if len(o.float64s) == 0 { + o.float64s = make([]float64, uint64PoolSize) + } + o.float64s[0] = math.Float64frombits(x) + p.v.Set(reflect.ValueOf(&o.float64s[0])) + o.float64s = o.float64s[1:] + return + } + panic("unreachable") +} + +func word64_IsNil(p word64) bool { + return p.v.IsNil() +} + +func word64_Get(p word64) uint64 { + elem := p.v.Elem() + switch elem.Kind() { + case reflect.Int64: + return uint64(elem.Int()) + case reflect.Uint64: + return elem.Uint() + case reflect.Float64: + return math.Float64bits(elem.Float()) + } + panic("unreachable") +} + +func structPointer_Word64(p structPointer, f field) word64 { + return word64{structPointer_field(p, f)} +} + +// word64Val is like word32Val but for 64-bit values. +type word64Val struct { + v reflect.Value +} + +func word64Val_Set(p word64Val, o *Buffer, x uint64) { + switch p.v.Type() { + case int64Type: + p.v.SetInt(int64(x)) + return + case uint64Type: + p.v.SetUint(x) + return + case float64Type: + p.v.SetFloat(math.Float64frombits(x)) + return + } + panic("unreachable") +} + +func word64Val_Get(p word64Val) uint64 { + elem := p.v + switch elem.Kind() { + case reflect.Int64: + return uint64(elem.Int()) + case reflect.Uint64: + return elem.Uint() + case reflect.Float64: + return math.Float64bits(elem.Float()) + } + panic("unreachable") +} + +func structPointer_Word64Val(p structPointer, f field) word64Val { + return word64Val{structPointer_field(p, f)} +} + +type word64Slice struct { + v reflect.Value +} + +func (p word64Slice) Append(x uint64) { + n, m := p.v.Len(), p.v.Cap() + if n < m { + p.v.SetLen(n + 1) + } else { + t := p.v.Type().Elem() + p.v.Set(reflect.Append(p.v, reflect.Zero(t))) + } + elem := p.v.Index(n) + switch elem.Kind() { + case reflect.Int64: + elem.SetInt(int64(int64(x))) + case reflect.Uint64: + elem.SetUint(uint64(x)) + case reflect.Float64: + elem.SetFloat(float64(math.Float64frombits(x))) + } +} + +func (p word64Slice) Len() int { + return p.v.Len() +} + +func (p word64Slice) Index(i int) uint64 { + elem := p.v.Index(i) + switch elem.Kind() { + case reflect.Int64: + return uint64(elem.Int()) + case reflect.Uint64: + return uint64(elem.Uint()) + case reflect.Float64: + return math.Float64bits(float64(elem.Float())) + } + panic("unreachable") +} + +func structPointer_Word64Slice(p structPointer, f field) word64Slice { + return word64Slice{structPointer_field(p, f)} +} diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_unsafe.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_unsafe.go new file mode 100644 index 0000000000..e9be0fe92e --- /dev/null +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_unsafe.go @@ -0,0 +1,266 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2012 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +// +build !appengine + +// This file contains the implementation of the proto field accesses using package unsafe. + +package proto + +import ( + "reflect" + "unsafe" +) + +// NOTE: These type_Foo functions would more idiomatically be methods, +// but Go does not allow methods on pointer types, and we must preserve +// some pointer type for the garbage collector. We use these +// funcs with clunky names as our poor approximation to methods. +// +// An alternative would be +// type structPointer struct { p unsafe.Pointer } +// but that does not registerize as well. + +// A structPointer is a pointer to a struct. +type structPointer unsafe.Pointer + +// toStructPointer returns a structPointer equivalent to the given reflect value. +func toStructPointer(v reflect.Value) structPointer { + return structPointer(unsafe.Pointer(v.Pointer())) +} + +// IsNil reports whether p is nil. +func structPointer_IsNil(p structPointer) bool { + return p == nil +} + +// Interface returns the struct pointer, assumed to have element type t, +// as an interface value. +func structPointer_Interface(p structPointer, t reflect.Type) interface{} { + return reflect.NewAt(t, unsafe.Pointer(p)).Interface() +} + +// A field identifies a field in a struct, accessible from a structPointer. +// In this implementation, a field is identified by its byte offset from the start of the struct. +type field uintptr + +// toField returns a field equivalent to the given reflect field. +func toField(f *reflect.StructField) field { + return field(f.Offset) +} + +// invalidField is an invalid field identifier. +const invalidField = ^field(0) + +// IsValid reports whether the field identifier is valid. +func (f field) IsValid() bool { + return f != ^field(0) +} + +// Bytes returns the address of a []byte field in the struct. +func structPointer_Bytes(p structPointer, f field) *[]byte { + return (*[]byte)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// BytesSlice returns the address of a [][]byte field in the struct. +func structPointer_BytesSlice(p structPointer, f field) *[][]byte { + return (*[][]byte)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// Bool returns the address of a *bool field in the struct. +func structPointer_Bool(p structPointer, f field) **bool { + return (**bool)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// BoolVal returns the address of a bool field in the struct. +func structPointer_BoolVal(p structPointer, f field) *bool { + return (*bool)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// BoolSlice returns the address of a []bool field in the struct. +func structPointer_BoolSlice(p structPointer, f field) *[]bool { + return (*[]bool)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// String returns the address of a *string field in the struct. +func structPointer_String(p structPointer, f field) **string { + return (**string)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// StringVal returns the address of a string field in the struct. +func structPointer_StringVal(p structPointer, f field) *string { + return (*string)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// StringSlice returns the address of a []string field in the struct. +func structPointer_StringSlice(p structPointer, f field) *[]string { + return (*[]string)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// ExtMap returns the address of an extension map field in the struct. +func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension { + return (*map[int32]Extension)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// NewAt returns the reflect.Value for a pointer to a field in the struct. +func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value { + return reflect.NewAt(typ, unsafe.Pointer(uintptr(p)+uintptr(f))) +} + +// SetStructPointer writes a *struct field in the struct. +func structPointer_SetStructPointer(p structPointer, f field, q structPointer) { + *(*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f))) = q +} + +// GetStructPointer reads a *struct field in the struct. +func structPointer_GetStructPointer(p structPointer, f field) structPointer { + return *(*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// StructPointerSlice the address of a []*struct field in the struct. +func structPointer_StructPointerSlice(p structPointer, f field) *structPointerSlice { + return (*structPointerSlice)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// A structPointerSlice represents a slice of pointers to structs (themselves submessages or groups). +type structPointerSlice []structPointer + +func (v *structPointerSlice) Len() int { return len(*v) } +func (v *structPointerSlice) Index(i int) structPointer { return (*v)[i] } +func (v *structPointerSlice) Append(p structPointer) { *v = append(*v, p) } + +// A word32 is the address of a "pointer to 32-bit value" field. +type word32 **uint32 + +// IsNil reports whether *v is nil. +func word32_IsNil(p word32) bool { + return *p == nil +} + +// Set sets *v to point at a newly allocated word set to x. +func word32_Set(p word32, o *Buffer, x uint32) { + if len(o.uint32s) == 0 { + o.uint32s = make([]uint32, uint32PoolSize) + } + o.uint32s[0] = x + *p = &o.uint32s[0] + o.uint32s = o.uint32s[1:] +} + +// Get gets the value pointed at by *v. +func word32_Get(p word32) uint32 { + return **p +} + +// Word32 returns the address of a *int32, *uint32, *float32, or *enum field in the struct. +func structPointer_Word32(p structPointer, f field) word32 { + return word32((**uint32)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +} + +// A word32Val is the address of a 32-bit value field. +type word32Val *uint32 + +// Set sets *p to x. +func word32Val_Set(p word32Val, x uint32) { + *p = x +} + +// Get gets the value pointed at by p. +func word32Val_Get(p word32Val) uint32 { + return *p +} + +// Word32Val returns the address of a *int32, *uint32, *float32, or *enum field in the struct. +func structPointer_Word32Val(p structPointer, f field) word32Val { + return word32Val((*uint32)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +} + +// A word32Slice is a slice of 32-bit values. +type word32Slice []uint32 + +func (v *word32Slice) Append(x uint32) { *v = append(*v, x) } +func (v *word32Slice) Len() int { return len(*v) } +func (v *word32Slice) Index(i int) uint32 { return (*v)[i] } + +// Word32Slice returns the address of a []int32, []uint32, []float32, or []enum field in the struct. +func structPointer_Word32Slice(p structPointer, f field) *word32Slice { + return (*word32Slice)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// word64 is like word32 but for 64-bit values. +type word64 **uint64 + +func word64_Set(p word64, o *Buffer, x uint64) { + if len(o.uint64s) == 0 { + o.uint64s = make([]uint64, uint64PoolSize) + } + o.uint64s[0] = x + *p = &o.uint64s[0] + o.uint64s = o.uint64s[1:] +} + +func word64_IsNil(p word64) bool { + return *p == nil +} + +func word64_Get(p word64) uint64 { + return **p +} + +func structPointer_Word64(p structPointer, f field) word64 { + return word64((**uint64)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +} + +// word64Val is like word32Val but for 64-bit values. +type word64Val *uint64 + +func word64Val_Set(p word64Val, o *Buffer, x uint64) { + *p = x +} + +func word64Val_Get(p word64Val) uint64 { + return *p +} + +func structPointer_Word64Val(p structPointer, f field) word64Val { + return word64Val((*uint64)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +} + +// word64Slice is like word32Slice but for 64-bit values. +type word64Slice []uint64 + +func (v *word64Slice) Append(x uint64) { *v = append(*v, x) } +func (v *word64Slice) Len() int { return len(*v) } +func (v *word64Slice) Index(i int) uint64 { return (*v)[i] } + +func structPointer_Word64Slice(p structPointer, f field) *word64Slice { + return (*word64Slice)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_unsafe_gogo.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_unsafe_gogo.go new file mode 100644 index 0000000000..6bc85fa987 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_unsafe_gogo.go @@ -0,0 +1,108 @@ +// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. +// http://github.com/gogo/protobuf/gogoproto +// +// 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. +// +// 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. + +// +build !appengine + +// This file contains the implementation of the proto field accesses using package unsafe. + +package proto + +import ( + "reflect" + "unsafe" +) + +func structPointer_InterfaceAt(p structPointer, f field, t reflect.Type) interface{} { + point := unsafe.Pointer(uintptr(p) + uintptr(f)) + r := reflect.NewAt(t, point) + return r.Interface() +} + +func structPointer_InterfaceRef(p structPointer, f field, t reflect.Type) interface{} { + point := unsafe.Pointer(uintptr(p) + uintptr(f)) + r := reflect.NewAt(t, point) + if r.Elem().IsNil() { + return nil + } + return r.Elem().Interface() +} + +func copyUintPtr(oldptr, newptr uintptr, size int) { + oldbytes := make([]byte, 0) + oldslice := (*reflect.SliceHeader)(unsafe.Pointer(&oldbytes)) + oldslice.Data = oldptr + oldslice.Len = size + oldslice.Cap = size + newbytes := make([]byte, 0) + newslice := (*reflect.SliceHeader)(unsafe.Pointer(&newbytes)) + newslice.Data = newptr + newslice.Len = size + newslice.Cap = size + copy(newbytes, oldbytes) +} + +func structPointer_Copy(oldptr structPointer, newptr structPointer, size int) { + copyUintPtr(uintptr(oldptr), uintptr(newptr), size) +} + +func appendStructPointer(base structPointer, f field, typ reflect.Type) structPointer { + size := typ.Elem().Size() + oldHeader := structPointer_GetSliceHeader(base, f) + newLen := oldHeader.Len + 1 + slice := reflect.MakeSlice(typ, newLen, newLen) + bas := toStructPointer(slice) + for i := 0; i < oldHeader.Len; i++ { + newElemptr := uintptr(bas) + uintptr(i)*size + oldElemptr := oldHeader.Data + uintptr(i)*size + copyUintPtr(oldElemptr, newElemptr, int(size)) + } + + oldHeader.Data = uintptr(bas) + oldHeader.Len = newLen + oldHeader.Cap = newLen + + return structPointer(unsafe.Pointer(uintptr(unsafe.Pointer(bas)) + uintptr(uintptr(newLen-1)*size))) +} + +func structPointer_FieldPointer(p structPointer, f field) structPointer { + return structPointer(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +func structPointer_GetRefStructPointer(p structPointer, f field) structPointer { + return structPointer((*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +} + +func structPointer_GetSliceHeader(p structPointer, f field) *reflect.SliceHeader { + return (*reflect.SliceHeader)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +func structPointer_Add(p structPointer, size field) structPointer { + return structPointer(unsafe.Pointer(uintptr(p) + uintptr(size))) +} + +func structPointer_Len(p structPointer, f field) int { + return len(*(*[]interface{})(unsafe.Pointer(structPointer_GetRefStructPointer(p, f)))) +} diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/properties.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/properties.go new file mode 100644 index 0000000000..4711057e2b --- /dev/null +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/properties.go @@ -0,0 +1,915 @@ +// Extensions for Protocol Buffers to create more go like structures. +// +// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. +// http://github.com/gogo/protobuf/gogoproto +// +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +package proto + +/* + * Routines for encoding data into the wire format for protocol buffers. + */ + +import ( + "fmt" + "log" + "os" + "reflect" + "sort" + "strconv" + "strings" + "sync" +) + +const debug bool = false + +// Constants that identify the encoding of a value on the wire. +const ( + WireVarint = 0 + WireFixed64 = 1 + WireBytes = 2 + WireStartGroup = 3 + WireEndGroup = 4 + WireFixed32 = 5 +) + +const startSize = 10 // initial slice/string sizes + +// Encoders are defined in encode.go +// An encoder outputs the full representation of a field, including its +// tag and encoder type. +type encoder func(p *Buffer, prop *Properties, base structPointer) error + +// A valueEncoder encodes a single integer in a particular encoding. +type valueEncoder func(o *Buffer, x uint64) error + +// Sizers are defined in encode.go +// A sizer returns the encoded size of a field, including its tag and encoder +// type. +type sizer func(prop *Properties, base structPointer) int + +// A valueSizer returns the encoded size of a single integer in a particular +// encoding. +type valueSizer func(x uint64) int + +// Decoders are defined in decode.go +// A decoder creates a value from its wire representation. +// Unrecognized subelements are saved in unrec. +type decoder func(p *Buffer, prop *Properties, base structPointer) error + +// A valueDecoder decodes a single integer in a particular encoding. +type valueDecoder func(o *Buffer) (x uint64, err error) + +// A oneofMarshaler does the marshaling for all oneof fields in a message. +type oneofMarshaler func(Message, *Buffer) error + +// A oneofUnmarshaler does the unmarshaling for a oneof field in a message. +type oneofUnmarshaler func(Message, int, int, *Buffer) (bool, error) + +// tagMap is an optimization over map[int]int for typical protocol buffer +// use-cases. Encoded protocol buffers are often in tag order with small tag +// numbers. +type tagMap struct { + fastTags []int + slowTags map[int]int +} + +// tagMapFastLimit is the upper bound on the tag number that will be stored in +// the tagMap slice rather than its map. +const tagMapFastLimit = 1024 + +func (p *tagMap) get(t int) (int, bool) { + if t > 0 && t < tagMapFastLimit { + if t >= len(p.fastTags) { + return 0, false + } + fi := p.fastTags[t] + return fi, fi >= 0 + } + fi, ok := p.slowTags[t] + return fi, ok +} + +func (p *tagMap) put(t int, fi int) { + if t > 0 && t < tagMapFastLimit { + for len(p.fastTags) < t+1 { + p.fastTags = append(p.fastTags, -1) + } + p.fastTags[t] = fi + return + } + if p.slowTags == nil { + p.slowTags = make(map[int]int) + } + p.slowTags[t] = fi +} + +// StructProperties represents properties for all the fields of a struct. +// decoderTags and decoderOrigNames should only be used by the decoder. +type StructProperties struct { + Prop []*Properties // properties for each field + reqCount int // required count + decoderTags tagMap // map from proto tag to struct field number + decoderOrigNames map[string]int // map from original name to struct field number + order []int // list of struct field numbers in tag order + unrecField field // field id of the XXX_unrecognized []byte field + extendable bool // is this an extendable proto + + oneofMarshaler oneofMarshaler + oneofUnmarshaler oneofUnmarshaler + stype reflect.Type + + // OneofTypes contains information about the oneof fields in this message. + // It is keyed by the original name of a field. + OneofTypes map[string]*OneofProperties +} + +// OneofProperties represents information about a specific field in a oneof. +type OneofProperties struct { + Type reflect.Type // pointer to generated struct type for this oneof field + Field int // struct field number of the containing oneof in the message + Prop *Properties +} + +// Implement the sorting interface so we can sort the fields in tag order, as recommended by the spec. +// See encode.go, (*Buffer).enc_struct. + +func (sp *StructProperties) Len() int { return len(sp.order) } +func (sp *StructProperties) Less(i, j int) bool { + return sp.Prop[sp.order[i]].Tag < sp.Prop[sp.order[j]].Tag +} +func (sp *StructProperties) Swap(i, j int) { sp.order[i], sp.order[j] = sp.order[j], sp.order[i] } + +// Properties represents the protocol-specific behavior of a single struct field. +type Properties struct { + Name string // name of the field, for error messages + OrigName string // original name before protocol compiler (always set) + Wire string + WireType int + Tag int + Required bool + Optional bool + Repeated bool + Packed bool // relevant for repeated primitives only + Enum string // set for enum types only + proto3 bool // whether this is known to be a proto3 field; set for []byte only + oneof bool // whether this is a oneof field + + Default string // default value + HasDefault bool // whether an explicit default was provided + CustomType string + def_uint64 uint64 + + enc encoder + valEnc valueEncoder // set for bool and numeric types only + field field + tagcode []byte // encoding of EncodeVarint((Tag<<3)|WireType) + tagbuf [8]byte + stype reflect.Type // set for struct types only + sstype reflect.Type // set for slices of structs types only + ctype reflect.Type // set for custom types only + sprop *StructProperties // set for struct types only + isMarshaler bool + isUnmarshaler bool + + mtype reflect.Type // set for map types only + mkeyprop *Properties // set for map types only + mvalprop *Properties // set for map types only + + size sizer + valSize valueSizer // set for bool and numeric types only + + dec decoder + valDec valueDecoder // set for bool and numeric types only + + // If this is a packable field, this will be the decoder for the packed version of the field. + packedDec decoder +} + +// String formats the properties in the protobuf struct field tag style. +func (p *Properties) String() string { + s := p.Wire + s = "," + s += strconv.Itoa(p.Tag) + if p.Required { + s += ",req" + } + if p.Optional { + s += ",opt" + } + if p.Repeated { + s += ",rep" + } + if p.Packed { + s += ",packed" + } + if p.OrigName != p.Name { + s += ",name=" + p.OrigName + } + if p.proto3 { + s += ",proto3" + } + if p.oneof { + s += ",oneof" + } + if len(p.Enum) > 0 { + s += ",enum=" + p.Enum + } + if p.HasDefault { + s += ",def=" + p.Default + } + return s +} + +// Parse populates p by parsing a string in the protobuf struct field tag style. +func (p *Properties) Parse(s string) { + // "bytes,49,opt,name=foo,def=hello!" + fields := strings.Split(s, ",") // breaks def=, but handled below. + if len(fields) < 2 { + fmt.Fprintf(os.Stderr, "proto: tag has too few fields: %q\n", s) + return + } + + p.Wire = fields[0] + switch p.Wire { + case "varint": + p.WireType = WireVarint + p.valEnc = (*Buffer).EncodeVarint + p.valDec = (*Buffer).DecodeVarint + p.valSize = sizeVarint + case "fixed32": + p.WireType = WireFixed32 + p.valEnc = (*Buffer).EncodeFixed32 + p.valDec = (*Buffer).DecodeFixed32 + p.valSize = sizeFixed32 + case "fixed64": + p.WireType = WireFixed64 + p.valEnc = (*Buffer).EncodeFixed64 + p.valDec = (*Buffer).DecodeFixed64 + p.valSize = sizeFixed64 + case "zigzag32": + p.WireType = WireVarint + p.valEnc = (*Buffer).EncodeZigzag32 + p.valDec = (*Buffer).DecodeZigzag32 + p.valSize = sizeZigzag32 + case "zigzag64": + p.WireType = WireVarint + p.valEnc = (*Buffer).EncodeZigzag64 + p.valDec = (*Buffer).DecodeZigzag64 + p.valSize = sizeZigzag64 + case "bytes", "group": + p.WireType = WireBytes + // no numeric converter for non-numeric types + default: + fmt.Fprintf(os.Stderr, "proto: tag has unknown wire type: %q\n", s) + return + } + + var err error + p.Tag, err = strconv.Atoi(fields[1]) + if err != nil { + return + } + + for i := 2; i < len(fields); i++ { + f := fields[i] + switch { + case f == "req": + p.Required = true + case f == "opt": + p.Optional = true + case f == "rep": + p.Repeated = true + case f == "packed": + p.Packed = true + case strings.HasPrefix(f, "name="): + p.OrigName = f[5:] + case strings.HasPrefix(f, "enum="): + p.Enum = f[5:] + case f == "proto3": + p.proto3 = true + case f == "oneof": + p.oneof = true + case strings.HasPrefix(f, "def="): + p.HasDefault = true + p.Default = f[4:] // rest of string + if i+1 < len(fields) { + // Commas aren't escaped, and def is always last. + p.Default += "," + strings.Join(fields[i+1:], ",") + break + } + case strings.HasPrefix(f, "embedded="): + p.OrigName = strings.Split(f, "=")[1] + case strings.HasPrefix(f, "customtype="): + p.CustomType = strings.Split(f, "=")[1] + } + } +} + +func logNoSliceEnc(t1, t2 reflect.Type) { + fmt.Fprintf(os.Stderr, "proto: no slice oenc for %T = []%T\n", t1, t2) +} + +var protoMessageType = reflect.TypeOf((*Message)(nil)).Elem() + +// Initialize the fields for encoding and decoding. +func (p *Properties) setEncAndDec(typ reflect.Type, f *reflect.StructField, lockGetProp bool) { + p.enc = nil + p.dec = nil + p.size = nil + if len(p.CustomType) > 0 { + p.setCustomEncAndDec(typ) + p.setTag(lockGetProp) + return + } + switch t1 := typ; t1.Kind() { + default: + fmt.Fprintf(os.Stderr, "proto: no coders for %v\n", t1) + + // proto3 scalar types + + case reflect.Bool: + if p.proto3 { + p.enc = (*Buffer).enc_proto3_bool + p.dec = (*Buffer).dec_proto3_bool + p.size = size_proto3_bool + } else { + p.enc = (*Buffer).enc_ref_bool + p.dec = (*Buffer).dec_proto3_bool + p.size = size_ref_bool + } + case reflect.Int32: + if p.proto3 { + p.enc = (*Buffer).enc_proto3_int32 + p.dec = (*Buffer).dec_proto3_int32 + p.size = size_proto3_int32 + } else { + p.enc = (*Buffer).enc_ref_int32 + p.dec = (*Buffer).dec_proto3_int32 + p.size = size_ref_int32 + } + case reflect.Uint32: + if p.proto3 { + p.enc = (*Buffer).enc_proto3_uint32 + p.dec = (*Buffer).dec_proto3_int32 // can reuse + p.size = size_proto3_uint32 + } else { + p.enc = (*Buffer).enc_ref_uint32 + p.dec = (*Buffer).dec_proto3_int32 // can reuse + p.size = size_ref_uint32 + } + case reflect.Int64, reflect.Uint64: + if p.proto3 { + p.enc = (*Buffer).enc_proto3_int64 + p.dec = (*Buffer).dec_proto3_int64 + p.size = size_proto3_int64 + } else { + p.enc = (*Buffer).enc_ref_int64 + p.dec = (*Buffer).dec_proto3_int64 + p.size = size_ref_int64 + } + case reflect.Float32: + if p.proto3 { + p.enc = (*Buffer).enc_proto3_uint32 // can just treat them as bits + p.dec = (*Buffer).dec_proto3_int32 + p.size = size_proto3_uint32 + } else { + p.enc = (*Buffer).enc_ref_uint32 // can just treat them as bits + p.dec = (*Buffer).dec_proto3_int32 + p.size = size_ref_uint32 + } + case reflect.Float64: + if p.proto3 { + p.enc = (*Buffer).enc_proto3_int64 // can just treat them as bits + p.dec = (*Buffer).dec_proto3_int64 + p.size = size_proto3_int64 + } else { + p.enc = (*Buffer).enc_ref_int64 // can just treat them as bits + p.dec = (*Buffer).dec_proto3_int64 + p.size = size_ref_int64 + } + case reflect.String: + if p.proto3 { + p.enc = (*Buffer).enc_proto3_string + p.dec = (*Buffer).dec_proto3_string + p.size = size_proto3_string + } else { + p.enc = (*Buffer).enc_ref_string + p.dec = (*Buffer).dec_proto3_string + p.size = size_ref_string + } + case reflect.Struct: + p.stype = typ + p.isMarshaler = isMarshaler(typ) + p.isUnmarshaler = isUnmarshaler(typ) + if p.Wire == "bytes" { + p.enc = (*Buffer).enc_ref_struct_message + p.dec = (*Buffer).dec_ref_struct_message + p.size = size_ref_struct_message + } else { + fmt.Fprintf(os.Stderr, "proto: no coders for struct %T\n", typ) + } + + case reflect.Ptr: + switch t2 := t1.Elem(); t2.Kind() { + default: + fmt.Fprintf(os.Stderr, "proto: no encoder function for %v -> %v\n", t1, t2) + break + case reflect.Bool: + p.enc = (*Buffer).enc_bool + p.dec = (*Buffer).dec_bool + p.size = size_bool + case reflect.Int32: + p.enc = (*Buffer).enc_int32 + p.dec = (*Buffer).dec_int32 + p.size = size_int32 + case reflect.Uint32: + p.enc = (*Buffer).enc_uint32 + p.dec = (*Buffer).dec_int32 // can reuse + p.size = size_uint32 + case reflect.Int64, reflect.Uint64: + p.enc = (*Buffer).enc_int64 + p.dec = (*Buffer).dec_int64 + p.size = size_int64 + case reflect.Float32: + p.enc = (*Buffer).enc_uint32 // can just treat them as bits + p.dec = (*Buffer).dec_int32 + p.size = size_uint32 + case reflect.Float64: + p.enc = (*Buffer).enc_int64 // can just treat them as bits + p.dec = (*Buffer).dec_int64 + p.size = size_int64 + case reflect.String: + p.enc = (*Buffer).enc_string + p.dec = (*Buffer).dec_string + p.size = size_string + case reflect.Struct: + p.stype = t1.Elem() + p.isMarshaler = isMarshaler(t1) + p.isUnmarshaler = isUnmarshaler(t1) + if p.Wire == "bytes" { + p.enc = (*Buffer).enc_struct_message + p.dec = (*Buffer).dec_struct_message + p.size = size_struct_message + } else { + p.enc = (*Buffer).enc_struct_group + p.dec = (*Buffer).dec_struct_group + p.size = size_struct_group + } + } + + case reflect.Slice: + switch t2 := t1.Elem(); t2.Kind() { + default: + logNoSliceEnc(t1, t2) + break + case reflect.Bool: + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_bool + p.size = size_slice_packed_bool + } else { + p.enc = (*Buffer).enc_slice_bool + p.size = size_slice_bool + } + p.dec = (*Buffer).dec_slice_bool + p.packedDec = (*Buffer).dec_slice_packed_bool + case reflect.Int32: + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_int32 + p.size = size_slice_packed_int32 + } else { + p.enc = (*Buffer).enc_slice_int32 + p.size = size_slice_int32 + } + p.dec = (*Buffer).dec_slice_int32 + p.packedDec = (*Buffer).dec_slice_packed_int32 + case reflect.Uint32: + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_uint32 + p.size = size_slice_packed_uint32 + } else { + p.enc = (*Buffer).enc_slice_uint32 + p.size = size_slice_uint32 + } + p.dec = (*Buffer).dec_slice_int32 + p.packedDec = (*Buffer).dec_slice_packed_int32 + case reflect.Int64, reflect.Uint64: + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_int64 + p.size = size_slice_packed_int64 + } else { + p.enc = (*Buffer).enc_slice_int64 + p.size = size_slice_int64 + } + p.dec = (*Buffer).dec_slice_int64 + p.packedDec = (*Buffer).dec_slice_packed_int64 + case reflect.Uint8: + p.enc = (*Buffer).enc_slice_byte + p.dec = (*Buffer).dec_slice_byte + p.size = size_slice_byte + // This is a []byte, which is either a bytes field, + // or the value of a map field. In the latter case, + // we always encode an empty []byte, so we should not + // use the proto3 enc/size funcs. + // f == nil iff this is the key/value of a map field. + if p.proto3 && f != nil { + p.enc = (*Buffer).enc_proto3_slice_byte + p.size = size_proto3_slice_byte + } + case reflect.Float32, reflect.Float64: + switch t2.Bits() { + case 32: + // can just treat them as bits + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_uint32 + p.size = size_slice_packed_uint32 + } else { + p.enc = (*Buffer).enc_slice_uint32 + p.size = size_slice_uint32 + } + p.dec = (*Buffer).dec_slice_int32 + p.packedDec = (*Buffer).dec_slice_packed_int32 + case 64: + // can just treat them as bits + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_int64 + p.size = size_slice_packed_int64 + } else { + p.enc = (*Buffer).enc_slice_int64 + p.size = size_slice_int64 + } + p.dec = (*Buffer).dec_slice_int64 + p.packedDec = (*Buffer).dec_slice_packed_int64 + default: + logNoSliceEnc(t1, t2) + break + } + case reflect.String: + p.enc = (*Buffer).enc_slice_string + p.dec = (*Buffer).dec_slice_string + p.size = size_slice_string + case reflect.Ptr: + switch t3 := t2.Elem(); t3.Kind() { + default: + fmt.Fprintf(os.Stderr, "proto: no ptr oenc for %T -> %T -> %T\n", t1, t2, t3) + break + case reflect.Struct: + p.stype = t2.Elem() + p.isMarshaler = isMarshaler(t2) + p.isUnmarshaler = isUnmarshaler(t2) + if p.Wire == "bytes" { + p.enc = (*Buffer).enc_slice_struct_message + p.dec = (*Buffer).dec_slice_struct_message + p.size = size_slice_struct_message + } else { + p.enc = (*Buffer).enc_slice_struct_group + p.dec = (*Buffer).dec_slice_struct_group + p.size = size_slice_struct_group + } + } + case reflect.Slice: + switch t2.Elem().Kind() { + default: + fmt.Fprintf(os.Stderr, "proto: no slice elem oenc for %T -> %T -> %T\n", t1, t2, t2.Elem()) + break + case reflect.Uint8: + p.enc = (*Buffer).enc_slice_slice_byte + p.dec = (*Buffer).dec_slice_slice_byte + p.size = size_slice_slice_byte + } + case reflect.Struct: + p.setSliceOfNonPointerStructs(t1) + } + + case reflect.Map: + p.enc = (*Buffer).enc_new_map + p.dec = (*Buffer).dec_new_map + p.size = size_new_map + + p.mtype = t1 + p.mkeyprop = &Properties{} + p.mkeyprop.init(reflect.PtrTo(p.mtype.Key()), "Key", f.Tag.Get("protobuf_key"), nil, lockGetProp) + p.mvalprop = &Properties{} + vtype := p.mtype.Elem() + if vtype.Kind() != reflect.Ptr && vtype.Kind() != reflect.Slice { + // The value type is not a message (*T) or bytes ([]byte), + // so we need encoders for the pointer to this type. + vtype = reflect.PtrTo(vtype) + } + p.mvalprop.init(vtype, "Value", f.Tag.Get("protobuf_val"), nil, lockGetProp) + } + p.setTag(lockGetProp) +} + +func (p *Properties) setTag(lockGetProp bool) { + // precalculate tag code + wire := p.WireType + if p.Packed { + wire = WireBytes + } + x := uint32(p.Tag)<<3 | uint32(wire) + i := 0 + for i = 0; x > 127; i++ { + p.tagbuf[i] = 0x80 | uint8(x&0x7F) + x >>= 7 + } + p.tagbuf[i] = uint8(x) + p.tagcode = p.tagbuf[0 : i+1] + + if p.stype != nil { + if lockGetProp { + p.sprop = GetProperties(p.stype) + } else { + p.sprop = getPropertiesLocked(p.stype) + } + } +} + +var ( + marshalerType = reflect.TypeOf((*Marshaler)(nil)).Elem() + unmarshalerType = reflect.TypeOf((*Unmarshaler)(nil)).Elem() +) + +// isMarshaler reports whether type t implements Marshaler. +func isMarshaler(t reflect.Type) bool { + return t.Implements(marshalerType) +} + +// isUnmarshaler reports whether type t implements Unmarshaler. +func isUnmarshaler(t reflect.Type) bool { + return t.Implements(unmarshalerType) +} + +// Init populates the properties from a protocol buffer struct tag. +func (p *Properties) Init(typ reflect.Type, name, tag string, f *reflect.StructField) { + p.init(typ, name, tag, f, true) +} + +func (p *Properties) init(typ reflect.Type, name, tag string, f *reflect.StructField, lockGetProp bool) { + // "bytes,49,opt,def=hello!" + p.Name = name + p.OrigName = name + if f != nil { + p.field = toField(f) + } + if tag == "" { + return + } + p.Parse(tag) + p.setEncAndDec(typ, f, lockGetProp) +} + +var ( + propertiesMu sync.RWMutex + propertiesMap = make(map[reflect.Type]*StructProperties) +) + +// GetProperties returns the list of properties for the type represented by t. +// t must represent a generated struct type of a protocol message. +func GetProperties(t reflect.Type) *StructProperties { + if t.Kind() != reflect.Struct { + panic("proto: type must have kind struct") + } + + // Most calls to GetProperties in a long-running program will be + // retrieving details for types we have seen before. + propertiesMu.RLock() + sprop, ok := propertiesMap[t] + propertiesMu.RUnlock() + if ok { + if collectStats { + stats.Chit++ + } + return sprop + } + + propertiesMu.Lock() + sprop = getPropertiesLocked(t) + propertiesMu.Unlock() + return sprop +} + +// getPropertiesLocked requires that propertiesMu is held. +func getPropertiesLocked(t reflect.Type) *StructProperties { + if prop, ok := propertiesMap[t]; ok { + if collectStats { + stats.Chit++ + } + return prop + } + if collectStats { + stats.Cmiss++ + } + + prop := new(StructProperties) + // in case of recursive protos, fill this in now. + propertiesMap[t] = prop + + // build properties + prop.extendable = reflect.PtrTo(t).Implements(extendableProtoType) + prop.unrecField = invalidField + prop.Prop = make([]*Properties, t.NumField()) + prop.order = make([]int, t.NumField()) + + isOneofMessage := false + for i := 0; i < t.NumField(); i++ { + f := t.Field(i) + p := new(Properties) + name := f.Name + p.init(f.Type, name, f.Tag.Get("protobuf"), &f, false) + + if f.Name == "XXX_extensions" { // special case + if len(f.Tag.Get("protobuf")) > 0 { + p.enc = (*Buffer).enc_ext_slice_byte + p.dec = nil // not needed + p.size = size_ext_slice_byte + } else { + p.enc = (*Buffer).enc_map + p.dec = nil // not needed + p.size = size_map + } + } + if f.Name == "XXX_unrecognized" { // special case + prop.unrecField = toField(&f) + } + oneof := f.Tag.Get("protobuf_oneof") != "" // special case + if oneof { + isOneofMessage = true + } + prop.Prop[i] = p + prop.order[i] = i + if debug { + print(i, " ", f.Name, " ", t.String(), " ") + if p.Tag > 0 { + print(p.String()) + } + print("\n") + } + if p.enc == nil && !strings.HasPrefix(f.Name, "XXX_") && !oneof { + fmt.Fprintln(os.Stderr, "proto: no encoder for", f.Name, f.Type.String(), "[GetProperties]") + } + } + + // Re-order prop.order. + sort.Sort(prop) + + type oneofMessage interface { + XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), []interface{}) + } + if om, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); isOneofMessage && ok { + var oots []interface{} + prop.oneofMarshaler, prop.oneofUnmarshaler, oots = om.XXX_OneofFuncs() + prop.stype = t + + // Interpret oneof metadata. + prop.OneofTypes = make(map[string]*OneofProperties) + for _, oot := range oots { + oop := &OneofProperties{ + Type: reflect.ValueOf(oot).Type(), // *T + Prop: new(Properties), + } + sft := oop.Type.Elem().Field(0) + oop.Prop.Name = sft.Name + oop.Prop.Parse(sft.Tag.Get("protobuf")) + // There will be exactly one interface field that + // this new value is assignable to. + for i := 0; i < t.NumField(); i++ { + f := t.Field(i) + if f.Type.Kind() != reflect.Interface { + continue + } + if !oop.Type.AssignableTo(f.Type) { + continue + } + oop.Field = i + break + } + prop.OneofTypes[oop.Prop.OrigName] = oop + } + } + + // build required counts + // build tags + reqCount := 0 + prop.decoderOrigNames = make(map[string]int) + for i, p := range prop.Prop { + if strings.HasPrefix(p.Name, "XXX_") { + // Internal fields should not appear in tags/origNames maps. + // They are handled specially when encoding and decoding. + continue + } + if p.Required { + reqCount++ + } + prop.decoderTags.put(p.Tag, i) + prop.decoderOrigNames[p.OrigName] = i + } + prop.reqCount = reqCount + + return prop +} + +// Return the Properties object for the x[0]'th field of the structure. +func propByIndex(t reflect.Type, x []int) *Properties { + if len(x) != 1 { + fmt.Fprintf(os.Stderr, "proto: field index dimension %d (not 1) for type %s\n", len(x), t) + return nil + } + prop := GetProperties(t) + return prop.Prop[x[0]] +} + +// Get the address and type of a pointer to a struct from an interface. +func getbase(pb Message) (t reflect.Type, b structPointer, err error) { + if pb == nil { + err = ErrNil + return + } + // get the reflect type of the pointer to the struct. + t = reflect.TypeOf(pb) + // get the address of the struct. + value := reflect.ValueOf(pb) + b = toStructPointer(value) + return +} + +// A global registry of enum types. +// The generated code will register the generated maps by calling RegisterEnum. + +var enumValueMaps = make(map[string]map[string]int32) +var enumStringMaps = make(map[string]map[int32]string) + +// RegisterEnum is called from the generated code to install the enum descriptor +// maps into the global table to aid parsing text format protocol buffers. +func RegisterEnum(typeName string, unusedNameMap map[int32]string, valueMap map[string]int32) { + if _, ok := enumValueMaps[typeName]; ok { + panic("proto: duplicate enum registered: " + typeName) + } + enumValueMaps[typeName] = valueMap + if _, ok := enumStringMaps[typeName]; ok { + panic("proto: duplicate enum registered: " + typeName) + } + enumStringMaps[typeName] = unusedNameMap +} + +// EnumValueMap returns the mapping from names to integers of the +// enum type enumType, or a nil if not found. +func EnumValueMap(enumType string) map[string]int32 { + return enumValueMaps[enumType] +} + +// A registry of all linked message types. +// The string is a fully-qualified proto name ("pkg.Message"). +var ( + protoTypes = make(map[string]reflect.Type) + revProtoTypes = make(map[reflect.Type]string) +) + +// RegisterType is called from generated code and maps from the fully qualified +// proto name to the type (pointer to struct) of the protocol buffer. +func RegisterType(x Message, name string) { + if _, ok := protoTypes[name]; ok { + // TODO: Some day, make this a panic. + log.Printf("proto: duplicate proto type registered: %s", name) + return + } + t := reflect.TypeOf(x) + protoTypes[name] = t + revProtoTypes[t] = name +} + +// MessageName returns the fully-qualified proto name for the given message type. +func MessageName(x Message) string { return revProtoTypes[reflect.TypeOf(x)] } + +// MessageType returns the message type (pointer to struct) for a named message. +func MessageType(name string) reflect.Type { return protoTypes[name] } diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/properties_gogo.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/properties_gogo.go new file mode 100644 index 0000000000..8daf9f7768 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/properties_gogo.go @@ -0,0 +1,64 @@ +// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. +// http://github.com/gogo/protobuf/gogoproto +// +// 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. +// +// 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. + +package proto + +import ( + "fmt" + "os" + "reflect" +) + +func (p *Properties) setCustomEncAndDec(typ reflect.Type) { + p.ctype = typ + if p.Repeated { + p.enc = (*Buffer).enc_custom_slice_bytes + p.dec = (*Buffer).dec_custom_slice_bytes + p.size = size_custom_slice_bytes + } else if typ.Kind() == reflect.Ptr { + p.enc = (*Buffer).enc_custom_bytes + p.dec = (*Buffer).dec_custom_bytes + p.size = size_custom_bytes + } else { + p.enc = (*Buffer).enc_custom_ref_bytes + p.dec = (*Buffer).dec_custom_ref_bytes + p.size = size_custom_ref_bytes + } +} + +func (p *Properties) setSliceOfNonPointerStructs(typ reflect.Type) { + t2 := typ.Elem() + p.sstype = typ + p.stype = t2 + p.isMarshaler = isMarshaler(t2) + p.isUnmarshaler = isUnmarshaler(t2) + p.enc = (*Buffer).enc_slice_ref_struct_message + p.dec = (*Buffer).dec_slice_ref_struct_message + p.size = size_slice_ref_struct_message + if p.Wire != "bytes" { + fmt.Fprintf(os.Stderr, "proto: no ptr oenc for %T -> %T \n", typ, t2) + } +} diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/skip_gogo.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/skip_gogo.go new file mode 100644 index 0000000000..4fe7e0815c --- /dev/null +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/skip_gogo.go @@ -0,0 +1,117 @@ +// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. +// http://github.com/gogo/protobuf/gogoproto +// +// 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. +// +// 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. + +package proto + +import ( + "fmt" + "io" +) + +func Skip(data []byte) (n int, err error) { + l := len(data) + index := 0 + for index < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if index >= l { + return 0, io.ErrUnexpectedEOF + } + b := data[index] + index++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for { + if index >= l { + return 0, io.ErrUnexpectedEOF + } + index++ + if data[index-1] < 0x80 { + break + } + } + return index, nil + case 1: + index += 8 + return index, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if index >= l { + return 0, io.ErrUnexpectedEOF + } + b := data[index] + index++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + index += length + return index, nil + case 3: + for { + var innerWire uint64 + var start int = index + for shift := uint(0); ; shift += 7 { + if index >= l { + return 0, io.ErrUnexpectedEOF + } + b := data[index] + index++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := Skip(data[start:]) + if err != nil { + return 0, err + } + index = start + next + } + return index, nil + case 4: + return index, nil + case 5: + index += 4 + return index, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/text.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/text.go new file mode 100644 index 0000000000..7c9ae90f95 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/text.go @@ -0,0 +1,793 @@ +// Extensions for Protocol Buffers to create more go like structures. +// +// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. +// http://github.com/gogo/protobuf/gogoproto +// +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +package proto + +// Functions for writing the text protocol buffer format. + +import ( + "bufio" + "bytes" + "encoding" + "errors" + "fmt" + "io" + "log" + "math" + "reflect" + "sort" + "strings" +) + +var ( + newline = []byte("\n") + spaces = []byte(" ") + gtNewline = []byte(">\n") + endBraceNewline = []byte("}\n") + backslashN = []byte{'\\', 'n'} + backslashR = []byte{'\\', 'r'} + backslashT = []byte{'\\', 't'} + backslashDQ = []byte{'\\', '"'} + backslashBS = []byte{'\\', '\\'} + posInf = []byte("inf") + negInf = []byte("-inf") + nan = []byte("nan") +) + +type writer interface { + io.Writer + WriteByte(byte) error +} + +// textWriter is an io.Writer that tracks its indentation level. +type textWriter struct { + ind int + complete bool // if the current position is a complete line + compact bool // whether to write out as a one-liner + w writer +} + +func (w *textWriter) WriteString(s string) (n int, err error) { + if !strings.Contains(s, "\n") { + if !w.compact && w.complete { + w.writeIndent() + } + w.complete = false + return io.WriteString(w.w, s) + } + // WriteString is typically called without newlines, so this + // codepath and its copy are rare. We copy to avoid + // duplicating all of Write's logic here. + return w.Write([]byte(s)) +} + +func (w *textWriter) Write(p []byte) (n int, err error) { + newlines := bytes.Count(p, newline) + if newlines == 0 { + if !w.compact && w.complete { + w.writeIndent() + } + n, err = w.w.Write(p) + w.complete = false + return n, err + } + + frags := bytes.SplitN(p, newline, newlines+1) + if w.compact { + for i, frag := range frags { + if i > 0 { + if err := w.w.WriteByte(' '); err != nil { + return n, err + } + n++ + } + nn, err := w.w.Write(frag) + n += nn + if err != nil { + return n, err + } + } + return n, nil + } + + for i, frag := range frags { + if w.complete { + w.writeIndent() + } + nn, err := w.w.Write(frag) + n += nn + if err != nil { + return n, err + } + if i+1 < len(frags) { + if err := w.w.WriteByte('\n'); err != nil { + return n, err + } + n++ + } + } + w.complete = len(frags[len(frags)-1]) == 0 + return n, nil +} + +func (w *textWriter) WriteByte(c byte) error { + if w.compact && c == '\n' { + c = ' ' + } + if !w.compact && w.complete { + w.writeIndent() + } + err := w.w.WriteByte(c) + w.complete = c == '\n' + return err +} + +func (w *textWriter) indent() { w.ind++ } + +func (w *textWriter) unindent() { + if w.ind == 0 { + log.Printf("proto: textWriter unindented too far") + return + } + w.ind-- +} + +func writeName(w *textWriter, props *Properties) error { + if _, err := w.WriteString(props.OrigName); err != nil { + return err + } + if props.Wire != "group" { + return w.WriteByte(':') + } + return nil +} + +// raw is the interface satisfied by RawMessage. +type raw interface { + Bytes() []byte +} + +func writeStruct(w *textWriter, sv reflect.Value) error { + st := sv.Type() + sprops := GetProperties(st) + for i := 0; i < sv.NumField(); i++ { + fv := sv.Field(i) + props := sprops.Prop[i] + name := st.Field(i).Name + + if strings.HasPrefix(name, "XXX_") { + // There are two XXX_ fields: + // XXX_unrecognized []byte + // XXX_extensions map[int32]proto.Extension + // The first is handled here; + // the second is handled at the bottom of this function. + if name == "XXX_unrecognized" && !fv.IsNil() { + if err := writeUnknownStruct(w, fv.Interface().([]byte)); err != nil { + return err + } + } + continue + } + if fv.Kind() == reflect.Ptr && fv.IsNil() { + // Field not filled in. This could be an optional field or + // a required field that wasn't filled in. Either way, there + // isn't anything we can show for it. + continue + } + if fv.Kind() == reflect.Slice && fv.IsNil() { + // Repeated field that is empty, or a bytes field that is unused. + continue + } + + if props.Repeated && fv.Kind() == reflect.Slice { + // Repeated field. + for j := 0; j < fv.Len(); j++ { + if err := writeName(w, props); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + v := fv.Index(j) + if v.Kind() == reflect.Ptr && v.IsNil() { + // A nil message in a repeated field is not valid, + // but we can handle that more gracefully than panicking. + if _, err := w.Write([]byte("\n")); err != nil { + return err + } + continue + } + if len(props.Enum) > 0 { + if err := writeEnum(w, v, props); err != nil { + return err + } + } else if err := writeAny(w, v, props); err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + } + continue + } + if fv.Kind() == reflect.Map { + // Map fields are rendered as a repeated struct with key/value fields. + keys := fv.MapKeys() + sort.Sort(mapKeys(keys)) + for _, key := range keys { + val := fv.MapIndex(key) + if err := writeName(w, props); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + // open struct + if err := w.WriteByte('<'); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte('\n'); err != nil { + return err + } + } + w.indent() + // key + if _, err := w.WriteString("key:"); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + if err := writeAny(w, key, props.mkeyprop); err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + // nil values aren't legal, but we can avoid panicking because of them. + if val.Kind() != reflect.Ptr || !val.IsNil() { + // value + if _, err := w.WriteString("value:"); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + if err := writeAny(w, val, props.mvalprop); err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + } + // close struct + w.unindent() + if err := w.WriteByte('>'); err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + } + continue + } + if props.proto3 && fv.Kind() == reflect.Slice && fv.Len() == 0 { + // empty bytes field + continue + } + if props.proto3 && fv.Kind() != reflect.Ptr && fv.Kind() != reflect.Slice { + // proto3 non-repeated scalar field; skip if zero value + if isProto3Zero(fv) { + continue + } + } + + if fv.Kind() == reflect.Interface { + // Check if it is a oneof. + if st.Field(i).Tag.Get("protobuf_oneof") != "" { + // fv is nil, or holds a pointer to generated struct. + // That generated struct has exactly one field, + // which has a protobuf struct tag. + if fv.IsNil() { + continue + } + inner := fv.Elem().Elem() // interface -> *T -> T + tag := inner.Type().Field(0).Tag.Get("protobuf") + props.Parse(tag) // Overwrite the outer props. + // Write the value in the oneof, not the oneof itself. + fv = inner.Field(0) + + // Special case to cope with malformed messages gracefully: + // If the value in the oneof is a nil pointer, don't panic + // in writeAny. + if fv.Kind() == reflect.Ptr && fv.IsNil() { + // Use errors.New so writeAny won't render quotes. + msg := errors.New("/* nil */") + fv = reflect.ValueOf(&msg).Elem() + } + } + } + + if err := writeName(w, props); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + if b, ok := fv.Interface().(raw); ok { + if err := writeRaw(w, b.Bytes()); err != nil { + return err + } + continue + } + + if len(props.Enum) > 0 { + if err := writeEnum(w, fv, props); err != nil { + return err + } + } else if err := writeAny(w, fv, props); err != nil { + return err + } + + if err := w.WriteByte('\n'); err != nil { + return err + } + } + + // Extensions (the XXX_extensions field). + pv := sv + if pv.CanAddr() { + pv = sv.Addr() + } else { + pv = reflect.New(sv.Type()) + pv.Elem().Set(sv) + } + if pv.Type().Implements(extendableProtoType) { + if err := writeExtensions(w, pv); err != nil { + return err + } + } + + return nil +} + +// writeRaw writes an uninterpreted raw message. +func writeRaw(w *textWriter, b []byte) error { + if err := w.WriteByte('<'); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte('\n'); err != nil { + return err + } + } + w.indent() + if err := writeUnknownStruct(w, b); err != nil { + return err + } + w.unindent() + if err := w.WriteByte('>'); err != nil { + return err + } + return nil +} + +// writeAny writes an arbitrary field. +func writeAny(w *textWriter, v reflect.Value, props *Properties) error { + v = reflect.Indirect(v) + + if props != nil && len(props.CustomType) > 0 { + custom, ok := v.Interface().(Marshaler) + if ok { + data, err := custom.Marshal() + if err != nil { + return err + } + if err := writeString(w, string(data)); err != nil { + return err + } + return nil + } + } + + // Floats have special cases. + if v.Kind() == reflect.Float32 || v.Kind() == reflect.Float64 { + x := v.Float() + var b []byte + switch { + case math.IsInf(x, 1): + b = posInf + case math.IsInf(x, -1): + b = negInf + case math.IsNaN(x): + b = nan + } + if b != nil { + _, err := w.Write(b) + return err + } + // Other values are handled below. + } + + // We don't attempt to serialise every possible value type; only those + // that can occur in protocol buffers. + switch v.Kind() { + case reflect.Slice: + // Should only be a []byte; repeated fields are handled in writeStruct. + if err := writeString(w, string(v.Bytes())); err != nil { + return err + } + case reflect.String: + if err := writeString(w, v.String()); err != nil { + return err + } + case reflect.Struct: + // Required/optional group/message. + var bra, ket byte = '<', '>' + if props != nil && props.Wire == "group" { + bra, ket = '{', '}' + } + if err := w.WriteByte(bra); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte('\n'); err != nil { + return err + } + } + w.indent() + if tm, ok := v.Interface().(encoding.TextMarshaler); ok { + text, err := tm.MarshalText() + if err != nil { + return err + } + if _, err = w.Write(text); err != nil { + return err + } + } else if err := writeStruct(w, v); err != nil { + return err + } + w.unindent() + if err := w.WriteByte(ket); err != nil { + return err + } + default: + _, err := fmt.Fprint(w, v.Interface()) + return err + } + return nil +} + +// equivalent to C's isprint. +func isprint(c byte) bool { + return c >= 0x20 && c < 0x7f +} + +// writeString writes a string in the protocol buffer text format. +// It is similar to strconv.Quote except we don't use Go escape sequences, +// we treat the string as a byte sequence, and we use octal escapes. +// These differences are to maintain interoperability with the other +// languages' implementations of the text format. +func writeString(w *textWriter, s string) error { + // use WriteByte here to get any needed indent + if err := w.WriteByte('"'); err != nil { + return err + } + // Loop over the bytes, not the runes. + for i := 0; i < len(s); i++ { + var err error + // Divergence from C++: we don't escape apostrophes. + // There's no need to escape them, and the C++ parser + // copes with a naked apostrophe. + switch c := s[i]; c { + case '\n': + _, err = w.w.Write(backslashN) + case '\r': + _, err = w.w.Write(backslashR) + case '\t': + _, err = w.w.Write(backslashT) + case '"': + _, err = w.w.Write(backslashDQ) + case '\\': + _, err = w.w.Write(backslashBS) + default: + if isprint(c) { + err = w.w.WriteByte(c) + } else { + _, err = fmt.Fprintf(w.w, "\\%03o", c) + } + } + if err != nil { + return err + } + } + return w.WriteByte('"') +} + +func writeUnknownStruct(w *textWriter, data []byte) (err error) { + if !w.compact { + if _, err := fmt.Fprintf(w, "/* %d unknown bytes */\n", len(data)); err != nil { + return err + } + } + b := NewBuffer(data) + for b.index < len(b.buf) { + x, err := b.DecodeVarint() + if err != nil { + _, ferr := fmt.Fprintf(w, "/* %v */\n", err) + return ferr + } + wire, tag := x&7, x>>3 + if wire == WireEndGroup { + w.unindent() + if _, werr := w.Write(endBraceNewline); werr != nil { + return werr + } + continue + } + if _, ferr := fmt.Fprint(w, tag); ferr != nil { + return ferr + } + if wire != WireStartGroup { + if err := w.WriteByte(':'); err != nil { + return err + } + } + if !w.compact || wire == WireStartGroup { + if err := w.WriteByte(' '); err != nil { + return err + } + } + switch wire { + case WireBytes: + buf, e := b.DecodeRawBytes(false) + if e == nil { + _, err = fmt.Fprintf(w, "%q", buf) + } else { + _, err = fmt.Fprintf(w, "/* %v */", e) + } + case WireFixed32: + x, err = b.DecodeFixed32() + err = writeUnknownInt(w, x, err) + case WireFixed64: + x, err = b.DecodeFixed64() + err = writeUnknownInt(w, x, err) + case WireStartGroup: + err = w.WriteByte('{') + w.indent() + case WireVarint: + x, err = b.DecodeVarint() + err = writeUnknownInt(w, x, err) + default: + _, err = fmt.Fprintf(w, "/* unknown wire type %d */", wire) + } + if err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + } + return nil +} + +func writeUnknownInt(w *textWriter, x uint64, err error) error { + if err == nil { + _, err = fmt.Fprint(w, x) + } else { + _, err = fmt.Fprintf(w, "/* %v */", err) + } + return err +} + +type int32Slice []int32 + +func (s int32Slice) Len() int { return len(s) } +func (s int32Slice) Less(i, j int) bool { return s[i] < s[j] } +func (s int32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } + +// writeExtensions writes all the extensions in pv. +// pv is assumed to be a pointer to a protocol message struct that is extendable. +func writeExtensions(w *textWriter, pv reflect.Value) error { + emap := extensionMaps[pv.Type().Elem()] + ep := pv.Interface().(extendableProto) + + // Order the extensions by ID. + // This isn't strictly necessary, but it will give us + // canonical output, which will also make testing easier. + var m map[int32]Extension + if em, ok := ep.(extensionsMap); ok { + m = em.ExtensionMap() + } else if em, ok := ep.(extensionsBytes); ok { + eb := em.GetExtensions() + var err error + m, err = BytesToExtensionsMap(*eb) + if err != nil { + return err + } + } + + ids := make([]int32, 0, len(m)) + for id := range m { + ids = append(ids, id) + } + sort.Sort(int32Slice(ids)) + + for _, extNum := range ids { + ext := m[extNum] + var desc *ExtensionDesc + if emap != nil { + desc = emap[extNum] + } + if desc == nil { + // Unknown extension. + if err := writeUnknownStruct(w, ext.enc); err != nil { + return err + } + continue + } + + pb, err := GetExtension(ep, desc) + if err != nil { + return fmt.Errorf("failed getting extension: %v", err) + } + + // Repeated extensions will appear as a slice. + if !desc.repeated() { + if err := writeExtension(w, desc.Name, pb); err != nil { + return err + } + } else { + v := reflect.ValueOf(pb) + for i := 0; i < v.Len(); i++ { + if err := writeExtension(w, desc.Name, v.Index(i).Interface()); err != nil { + return err + } + } + } + } + return nil +} + +func writeExtension(w *textWriter, name string, pb interface{}) error { + if _, err := fmt.Fprintf(w, "[%s]:", name); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + if err := writeAny(w, reflect.ValueOf(pb), nil); err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + return nil +} + +func (w *textWriter) writeIndent() { + if !w.complete { + return + } + remain := w.ind * 2 + for remain > 0 { + n := remain + if n > len(spaces) { + n = len(spaces) + } + w.w.Write(spaces[:n]) + remain -= n + } + w.complete = false +} + +func marshalText(w io.Writer, pb Message, compact bool) error { + val := reflect.ValueOf(pb) + if pb == nil || val.IsNil() { + w.Write([]byte("")) + return nil + } + var bw *bufio.Writer + ww, ok := w.(writer) + if !ok { + bw = bufio.NewWriter(w) + ww = bw + } + aw := &textWriter{ + w: ww, + complete: true, + compact: compact, + } + + if tm, ok := pb.(encoding.TextMarshaler); ok { + text, err := tm.MarshalText() + if err != nil { + return err + } + if _, err = aw.Write(text); err != nil { + return err + } + if bw != nil { + return bw.Flush() + } + return nil + } + // Dereference the received pointer so we don't have outer < and >. + v := reflect.Indirect(val) + if err := writeStruct(aw, v); err != nil { + return err + } + if bw != nil { + return bw.Flush() + } + return nil +} + +// MarshalText writes a given protocol buffer in text format. +// The only errors returned are from w. +func MarshalText(w io.Writer, pb Message) error { + return marshalText(w, pb, false) +} + +// MarshalTextString is the same as MarshalText, but returns the string directly. +func MarshalTextString(pb Message) string { + var buf bytes.Buffer + marshalText(&buf, pb, false) + return buf.String() +} + +// CompactText writes a given protocol buffer in compact text format (one line). +func CompactText(w io.Writer, pb Message) error { return marshalText(w, pb, true) } + +// CompactTextString is the same as CompactText, but returns the string directly. +func CompactTextString(pb Message) string { + var buf bytes.Buffer + marshalText(&buf, pb, true) + return buf.String() +} diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_gogo.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_gogo.go new file mode 100644 index 0000000000..cdb23373c3 --- /dev/null +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_gogo.go @@ -0,0 +1,55 @@ +// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. +// http://github.com/gogo/protobuf/gogoproto +// +// 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. +// +// 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. + +package proto + +import ( + "fmt" + "reflect" +) + +func writeEnum(w *textWriter, v reflect.Value, props *Properties) error { + m, ok := enumStringMaps[props.Enum] + if !ok { + if err := writeAny(w, v, props); err != nil { + return err + } + } + key := int32(0) + if v.Kind() == reflect.Ptr { + key = int32(v.Elem().Int()) + } else { + key = int32(v.Int()) + } + s, ok := m[key] + if !ok { + if err := writeAny(w, v, props); err != nil { + return err + } + } + _, err := fmt.Fprint(w, s) + return err +} diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_parser.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_parser.go new file mode 100644 index 0000000000..f3909695ed --- /dev/null +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_parser.go @@ -0,0 +1,841 @@ +// Extensions for Protocol Buffers to create more go like structures. +// +// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. +// http://github.com/gogo/protobuf/gogoproto +// +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +package proto + +// Functions for parsing the Text protocol buffer format. +// TODO: message sets. + +import ( + "encoding" + "errors" + "fmt" + "reflect" + "strconv" + "strings" + "unicode/utf8" +) + +type ParseError struct { + Message string + Line int // 1-based line number + Offset int // 0-based byte offset from start of input +} + +func (p *ParseError) Error() string { + if p.Line == 1 { + // show offset only for first line + return fmt.Sprintf("line 1.%d: %v", p.Offset, p.Message) + } + return fmt.Sprintf("line %d: %v", p.Line, p.Message) +} + +type token struct { + value string + err *ParseError + line int // line number + offset int // byte number from start of input, not start of line + unquoted string // the unquoted version of value, if it was a quoted string +} + +func (t *token) String() string { + if t.err == nil { + return fmt.Sprintf("%q (line=%d, offset=%d)", t.value, t.line, t.offset) + } + return fmt.Sprintf("parse error: %v", t.err) +} + +type textParser struct { + s string // remaining input + done bool // whether the parsing is finished (success or error) + backed bool // whether back() was called + offset, line int + cur token +} + +func newTextParser(s string) *textParser { + p := new(textParser) + p.s = s + p.line = 1 + p.cur.line = 1 + return p +} + +func (p *textParser) errorf(format string, a ...interface{}) *ParseError { + pe := &ParseError{fmt.Sprintf(format, a...), p.cur.line, p.cur.offset} + p.cur.err = pe + p.done = true + return pe +} + +// Numbers and identifiers are matched by [-+._A-Za-z0-9] +func isIdentOrNumberChar(c byte) bool { + switch { + case 'A' <= c && c <= 'Z', 'a' <= c && c <= 'z': + return true + case '0' <= c && c <= '9': + return true + } + switch c { + case '-', '+', '.', '_': + return true + } + return false +} + +func isWhitespace(c byte) bool { + switch c { + case ' ', '\t', '\n', '\r': + return true + } + return false +} + +func (p *textParser) skipWhitespace() { + i := 0 + for i < len(p.s) && (isWhitespace(p.s[i]) || p.s[i] == '#') { + if p.s[i] == '#' { + // comment; skip to end of line or input + for i < len(p.s) && p.s[i] != '\n' { + i++ + } + if i == len(p.s) { + break + } + } + if p.s[i] == '\n' { + p.line++ + } + i++ + } + p.offset += i + p.s = p.s[i:len(p.s)] + if len(p.s) == 0 { + p.done = true + } +} + +func (p *textParser) advance() { + // Skip whitespace + p.skipWhitespace() + if p.done { + return + } + + // Start of non-whitespace + p.cur.err = nil + p.cur.offset, p.cur.line = p.offset, p.line + p.cur.unquoted = "" + switch p.s[0] { + case '<', '>', '{', '}', ':', '[', ']', ';', ',': + // Single symbol + p.cur.value, p.s = p.s[0:1], p.s[1:len(p.s)] + case '"', '\'': + // Quoted string + i := 1 + for i < len(p.s) && p.s[i] != p.s[0] && p.s[i] != '\n' { + if p.s[i] == '\\' && i+1 < len(p.s) { + // skip escaped char + i++ + } + i++ + } + if i >= len(p.s) || p.s[i] != p.s[0] { + p.errorf("unmatched quote") + return + } + unq, err := unquoteC(p.s[1:i], rune(p.s[0])) + if err != nil { + p.errorf("invalid quoted string %s: %v", p.s[0:i+1], err) + return + } + p.cur.value, p.s = p.s[0:i+1], p.s[i+1:len(p.s)] + p.cur.unquoted = unq + default: + i := 0 + for i < len(p.s) && isIdentOrNumberChar(p.s[i]) { + i++ + } + if i == 0 { + p.errorf("unexpected byte %#x", p.s[0]) + return + } + p.cur.value, p.s = p.s[0:i], p.s[i:len(p.s)] + } + p.offset += len(p.cur.value) +} + +var ( + errBadUTF8 = errors.New("proto: bad UTF-8") + errBadHex = errors.New("proto: bad hexadecimal") +) + +func unquoteC(s string, quote rune) (string, error) { + // This is based on C++'s tokenizer.cc. + // Despite its name, this is *not* parsing C syntax. + // For instance, "\0" is an invalid quoted string. + + // Avoid allocation in trivial cases. + simple := true + for _, r := range s { + if r == '\\' || r == quote { + simple = false + break + } + } + if simple { + return s, nil + } + + buf := make([]byte, 0, 3*len(s)/2) + for len(s) > 0 { + r, n := utf8.DecodeRuneInString(s) + if r == utf8.RuneError && n == 1 { + return "", errBadUTF8 + } + s = s[n:] + if r != '\\' { + if r < utf8.RuneSelf { + buf = append(buf, byte(r)) + } else { + buf = append(buf, string(r)...) + } + continue + } + + ch, tail, err := unescape(s) + if err != nil { + return "", err + } + buf = append(buf, ch...) + s = tail + } + return string(buf), nil +} + +func unescape(s string) (ch string, tail string, err error) { + r, n := utf8.DecodeRuneInString(s) + if r == utf8.RuneError && n == 1 { + return "", "", errBadUTF8 + } + s = s[n:] + switch r { + case 'a': + return "\a", s, nil + case 'b': + return "\b", s, nil + case 'f': + return "\f", s, nil + case 'n': + return "\n", s, nil + case 'r': + return "\r", s, nil + case 't': + return "\t", s, nil + case 'v': + return "\v", s, nil + case '?': + return "?", s, nil // trigraph workaround + case '\'', '"', '\\': + return string(r), s, nil + case '0', '1', '2', '3', '4', '5', '6', '7', 'x', 'X': + if len(s) < 2 { + return "", "", fmt.Errorf(`\%c requires 2 following digits`, r) + } + base := 8 + ss := s[:2] + s = s[2:] + if r == 'x' || r == 'X' { + base = 16 + } else { + ss = string(r) + ss + } + i, err := strconv.ParseUint(ss, base, 8) + if err != nil { + return "", "", err + } + return string([]byte{byte(i)}), s, nil + case 'u', 'U': + n := 4 + if r == 'U' { + n = 8 + } + if len(s) < n { + return "", "", fmt.Errorf(`\%c requires %d digits`, r, n) + } + + bs := make([]byte, n/2) + for i := 0; i < n; i += 2 { + a, ok1 := unhex(s[i]) + b, ok2 := unhex(s[i+1]) + if !ok1 || !ok2 { + return "", "", errBadHex + } + bs[i/2] = a<<4 | b + } + s = s[n:] + return string(bs), s, nil + } + return "", "", fmt.Errorf(`unknown escape \%c`, r) +} + +// Adapted from src/pkg/strconv/quote.go. +func unhex(b byte) (v byte, ok bool) { + switch { + case '0' <= b && b <= '9': + return b - '0', true + case 'a' <= b && b <= 'f': + return b - 'a' + 10, true + case 'A' <= b && b <= 'F': + return b - 'A' + 10, true + } + return 0, false +} + +// Back off the parser by one token. Can only be done between calls to next(). +// It makes the next advance() a no-op. +func (p *textParser) back() { p.backed = true } + +// Advances the parser and returns the new current token. +func (p *textParser) next() *token { + if p.backed || p.done { + p.backed = false + return &p.cur + } + p.advance() + if p.done { + p.cur.value = "" + } else if len(p.cur.value) > 0 && p.cur.value[0] == '"' { + // Look for multiple quoted strings separated by whitespace, + // and concatenate them. + cat := p.cur + for { + p.skipWhitespace() + if p.done || p.s[0] != '"' { + break + } + p.advance() + if p.cur.err != nil { + return &p.cur + } + cat.value += " " + p.cur.value + cat.unquoted += p.cur.unquoted + } + p.done = false // parser may have seen EOF, but we want to return cat + p.cur = cat + } + return &p.cur +} + +func (p *textParser) consumeToken(s string) error { + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value != s { + p.back() + return p.errorf("expected %q, found %q", s, tok.value) + } + return nil +} + +// Return a RequiredNotSetError indicating which required field was not set. +func (p *textParser) missingRequiredFieldError(sv reflect.Value) *RequiredNotSetError { + st := sv.Type() + sprops := GetProperties(st) + for i := 0; i < st.NumField(); i++ { + if !isNil(sv.Field(i)) { + continue + } + + props := sprops.Prop[i] + if props.Required { + return &RequiredNotSetError{fmt.Sprintf("%v.%v", st, props.OrigName)} + } + } + return &RequiredNotSetError{fmt.Sprintf("%v.", st)} // should not happen +} + +// Returns the index in the struct for the named field, as well as the parsed tag properties. +func structFieldByName(sprops *StructProperties, name string) (int, *Properties, bool) { + i, ok := sprops.decoderOrigNames[name] + if ok { + return i, sprops.Prop[i], true + } + return -1, nil, false +} + +// Consume a ':' from the input stream (if the next token is a colon), +// returning an error if a colon is needed but not present. +func (p *textParser) checkForColon(props *Properties, typ reflect.Type) *ParseError { + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value != ":" { + // Colon is optional when the field is a group or message. + needColon := true + switch props.Wire { + case "group": + needColon = false + case "bytes": + // A "bytes" field is either a message, a string, or a repeated field; + // those three become *T, *string and []T respectively, so we can check for + // this field being a pointer to a non-string. + if typ.Kind() == reflect.Ptr { + // *T or *string + if typ.Elem().Kind() == reflect.String { + break + } + } else if typ.Kind() == reflect.Slice { + // []T or []*T + if typ.Elem().Kind() != reflect.Ptr { + break + } + } else if typ.Kind() == reflect.String { + // The proto3 exception is for a string field, + // which requires a colon. + break + } + needColon = false + } + if needColon { + return p.errorf("expected ':', found %q", tok.value) + } + p.back() + } + return nil +} + +func (p *textParser) readStruct(sv reflect.Value, terminator string) error { + st := sv.Type() + sprops := GetProperties(st) + reqCount := sprops.reqCount + var reqFieldErr error + fieldSet := make(map[string]bool) + // A struct is a sequence of "name: value", terminated by one of + // '>' or '}', or the end of the input. A name may also be + // "[extension]". + for { + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value == terminator { + break + } + if tok.value == "[" { + // Looks like an extension. + // + // TODO: Check whether we need to handle + // namespace rooted names (e.g. ".something.Foo"). + tok = p.next() + if tok.err != nil { + return tok.err + } + var desc *ExtensionDesc + // This could be faster, but it's functional. + // TODO: Do something smarter than a linear scan. + for _, d := range RegisteredExtensions(reflect.New(st).Interface().(Message)) { + if d.Name == tok.value { + desc = d + break + } + } + if desc == nil { + return p.errorf("unrecognized extension %q", tok.value) + } + // Check the extension terminator. + tok = p.next() + if tok.err != nil { + return tok.err + } + if tok.value != "]" { + return p.errorf("unrecognized extension terminator %q", tok.value) + } + + props := &Properties{} + props.Parse(desc.Tag) + + typ := reflect.TypeOf(desc.ExtensionType) + if err := p.checkForColon(props, typ); err != nil { + return err + } + + rep := desc.repeated() + + // Read the extension structure, and set it in + // the value we're constructing. + var ext reflect.Value + if !rep { + ext = reflect.New(typ).Elem() + } else { + ext = reflect.New(typ.Elem()).Elem() + } + if err := p.readAny(ext, props); err != nil { + if _, ok := err.(*RequiredNotSetError); !ok { + return err + } + reqFieldErr = err + } + ep := sv.Addr().Interface().(extendableProto) + if !rep { + SetExtension(ep, desc, ext.Interface()) + } else { + old, err := GetExtension(ep, desc) + var sl reflect.Value + if err == nil { + sl = reflect.ValueOf(old) // existing slice + } else { + sl = reflect.MakeSlice(typ, 0, 1) + } + sl = reflect.Append(sl, ext) + SetExtension(ep, desc, sl.Interface()) + } + if err := p.consumeOptionalSeparator(); err != nil { + return err + } + continue + } + + // This is a normal, non-extension field. + name := tok.value + var dst reflect.Value + fi, props, ok := structFieldByName(sprops, name) + if ok { + dst = sv.Field(fi) + } else if oop, ok := sprops.OneofTypes[name]; ok { + // It is a oneof. + props = oop.Prop + nv := reflect.New(oop.Type.Elem()) + dst = nv.Elem().Field(0) + sv.Field(oop.Field).Set(nv) + } + if !dst.IsValid() { + return p.errorf("unknown field name %q in %v", name, st) + } + + if dst.Kind() == reflect.Map { + // Consume any colon. + if err := p.checkForColon(props, dst.Type()); err != nil { + return err + } + + // Construct the map if it doesn't already exist. + if dst.IsNil() { + dst.Set(reflect.MakeMap(dst.Type())) + } + key := reflect.New(dst.Type().Key()).Elem() + val := reflect.New(dst.Type().Elem()).Elem() + + // The map entry should be this sequence of tokens: + // < key : KEY value : VALUE > + // Technically the "key" and "value" could come in any order, + // but in practice they won't. + + tok := p.next() + var terminator string + switch tok.value { + case "<": + terminator = ">" + case "{": + terminator = "}" + default: + return p.errorf("expected '{' or '<', found %q", tok.value) + } + if err := p.consumeToken("key"); err != nil { + return err + } + if err := p.consumeToken(":"); err != nil { + return err + } + if err := p.readAny(key, props.mkeyprop); err != nil { + return err + } + if err := p.consumeOptionalSeparator(); err != nil { + return err + } + if err := p.consumeToken("value"); err != nil { + return err + } + if err := p.checkForColon(props.mvalprop, dst.Type().Elem()); err != nil { + return err + } + if err := p.readAny(val, props.mvalprop); err != nil { + return err + } + if err := p.consumeOptionalSeparator(); err != nil { + return err + } + if err := p.consumeToken(terminator); err != nil { + return err + } + + dst.SetMapIndex(key, val) + continue + } + + // Check that it's not already set if it's not a repeated field. + if !props.Repeated && fieldSet[name] { + return p.errorf("non-repeated field %q was repeated", name) + } + + if err := p.checkForColon(props, dst.Type()); err != nil { + return err + } + + // Parse into the field. + fieldSet[name] = true + if err := p.readAny(dst, props); err != nil { + if _, ok := err.(*RequiredNotSetError); !ok { + return err + } + reqFieldErr = err + } else if props.Required { + reqCount-- + } + + if err := p.consumeOptionalSeparator(); err != nil { + return err + } + + } + + if reqCount > 0 { + return p.missingRequiredFieldError(sv) + } + return reqFieldErr +} + +// consumeOptionalSeparator consumes an optional semicolon or comma. +// It is used in readStruct to provide backward compatibility. +func (p *textParser) consumeOptionalSeparator() error { + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value != ";" && tok.value != "," { + p.back() + } + return nil +} + +func (p *textParser) readAny(v reflect.Value, props *Properties) error { + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value == "" { + return p.errorf("unexpected EOF") + } + if len(props.CustomType) > 0 { + if props.Repeated { + t := reflect.TypeOf(v.Interface()) + if t.Kind() == reflect.Slice { + tc := reflect.TypeOf(new(Marshaler)) + ok := t.Elem().Implements(tc.Elem()) + if ok { + fv := v + flen := fv.Len() + if flen == fv.Cap() { + nav := reflect.MakeSlice(v.Type(), flen, 2*flen+1) + reflect.Copy(nav, fv) + fv.Set(nav) + } + fv.SetLen(flen + 1) + + // Read one. + p.back() + return p.readAny(fv.Index(flen), props) + } + } + } + if reflect.TypeOf(v.Interface()).Kind() == reflect.Ptr { + custom := reflect.New(props.ctype.Elem()).Interface().(Unmarshaler) + err := custom.Unmarshal([]byte(tok.unquoted)) + if err != nil { + return p.errorf("%v %v: %v", err, v.Type(), tok.value) + } + v.Set(reflect.ValueOf(custom)) + } else { + custom := reflect.New(reflect.TypeOf(v.Interface())).Interface().(Unmarshaler) + err := custom.Unmarshal([]byte(tok.unquoted)) + if err != nil { + return p.errorf("%v %v: %v", err, v.Type(), tok.value) + } + v.Set(reflect.Indirect(reflect.ValueOf(custom))) + } + return nil + } + switch fv := v; fv.Kind() { + case reflect.Slice: + at := v.Type() + if at.Elem().Kind() == reflect.Uint8 { + // Special case for []byte + if tok.value[0] != '"' && tok.value[0] != '\'' { + // Deliberately written out here, as the error after + // this switch statement would write "invalid []byte: ...", + // which is not as user-friendly. + return p.errorf("invalid string: %v", tok.value) + } + bytes := []byte(tok.unquoted) + fv.Set(reflect.ValueOf(bytes)) + return nil + } + // Repeated field. + if tok.value == "[" { + // Repeated field with list notation, like [1,2,3]. + for { + fv.Set(reflect.Append(fv, reflect.New(at.Elem()).Elem())) + err := p.readAny(fv.Index(fv.Len()-1), props) + if err != nil { + return err + } + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value == "]" { + break + } + if tok.value != "," { + return p.errorf("Expected ']' or ',' found %q", tok.value) + } + } + return nil + } + // One value of the repeated field. + p.back() + fv.Set(reflect.Append(fv, reflect.New(at.Elem()).Elem())) + return p.readAny(fv.Index(fv.Len()-1), props) + case reflect.Bool: + // Either "true", "false", 1 or 0. + switch tok.value { + case "true", "1": + fv.SetBool(true) + return nil + case "false", "0": + fv.SetBool(false) + return nil + } + case reflect.Float32, reflect.Float64: + v := tok.value + // Ignore 'f' for compatibility with output generated by C++, but don't + // remove 'f' when the value is "-inf" or "inf". + if strings.HasSuffix(v, "f") && tok.value != "-inf" && tok.value != "inf" { + v = v[:len(v)-1] + } + if f, err := strconv.ParseFloat(v, fv.Type().Bits()); err == nil { + fv.SetFloat(f) + return nil + } + case reflect.Int32: + if x, err := strconv.ParseInt(tok.value, 0, 32); err == nil { + fv.SetInt(x) + return nil + } + + if len(props.Enum) == 0 { + break + } + m, ok := enumValueMaps[props.Enum] + if !ok { + break + } + x, ok := m[tok.value] + if !ok { + break + } + fv.SetInt(int64(x)) + return nil + case reflect.Int64: + if x, err := strconv.ParseInt(tok.value, 0, 64); err == nil { + fv.SetInt(x) + return nil + } + + case reflect.Ptr: + // A basic field (indirected through pointer), or a repeated message/group + p.back() + fv.Set(reflect.New(fv.Type().Elem())) + return p.readAny(fv.Elem(), props) + case reflect.String: + if tok.value[0] == '"' || tok.value[0] == '\'' { + fv.SetString(tok.unquoted) + return nil + } + case reflect.Struct: + var terminator string + switch tok.value { + case "{": + terminator = "}" + case "<": + terminator = ">" + default: + return p.errorf("expected '{' or '<', found %q", tok.value) + } + // TODO: Handle nested messages which implement encoding.TextUnmarshaler. + return p.readStruct(fv, terminator) + case reflect.Uint32: + if x, err := strconv.ParseUint(tok.value, 0, 32); err == nil { + fv.SetUint(uint64(x)) + return nil + } + case reflect.Uint64: + if x, err := strconv.ParseUint(tok.value, 0, 64); err == nil { + fv.SetUint(x) + return nil + } + } + return p.errorf("invalid %v: %v", v.Type(), tok.value) +} + +// UnmarshalText reads a protocol buffer in Text format. UnmarshalText resets pb +// before starting to unmarshal, so any existing data in pb is always removed. +// If a required field is not set and no other error occurs, +// UnmarshalText returns *RequiredNotSetError. +func UnmarshalText(s string, pb Message) error { + if um, ok := pb.(encoding.TextUnmarshaler); ok { + err := um.UnmarshalText([]byte(s)) + return err + } + pb.Reset() + v := reflect.ValueOf(pb) + if pe := newTextParser(s).readStruct(v.Elem(), ""); pe != nil { + return pe + } + return nil +} diff --git a/Godeps/_workspace/src/gopkg.in/inf.v0/LICENSE b/Godeps/_workspace/src/gopkg.in/inf.v0/LICENSE new file mode 100644 index 0000000000..87a5cede33 --- /dev/null +++ b/Godeps/_workspace/src/gopkg.in/inf.v0/LICENSE @@ -0,0 +1,28 @@ +Copyright (c) 2012 Péter Surányi. Portions 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. diff --git a/Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/dec.go b/Godeps/_workspace/src/gopkg.in/inf.v0/dec.go similarity index 100% rename from Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/dec.go rename to Godeps/_workspace/src/gopkg.in/inf.v0/dec.go diff --git a/Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/rounder.go b/Godeps/_workspace/src/gopkg.in/inf.v0/rounder.go similarity index 100% rename from Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/rounder.go rename to Godeps/_workspace/src/gopkg.in/inf.v0/rounder.go diff --git a/Godeps/_workspace/src/k8s.io/kubernetes/LICENSE b/Godeps/_workspace/src/k8s.io/kubernetes/LICENSE index d645695673..6b4d837a44 100644 --- a/Godeps/_workspace/src/k8s.io/kubernetes/LICENSE +++ b/Godeps/_workspace/src/k8s.io/kubernetes/LICENSE @@ -187,7 +187,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [yyyy] [name of copyright owner] + Copyright 2014 The Kubernetes Authors All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/deep_copy_generated.go b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/deep_copy_generated.go new file mode 100644 index 0000000000..6a34e2d434 --- /dev/null +++ b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/deep_copy_generated.go @@ -0,0 +1,55 @@ +// +build !ignore_autogenerated + +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// This file was autogenerated by deepcopy-gen. Do not edit it manually! + +package resource + +import ( + inf_v0 "gopkg.in/inf.v0" + conversion "k8s.io/kubernetes/pkg/conversion" +) + +func DeepCopy_resource_Quantity(in Quantity, out *Quantity, c *conversion.Cloner) error { + if in.Amount != nil { + in, out := in.Amount, &out.Amount + *out = new(inf_v0.Dec) + if newVal, err := c.DeepCopy(*in); err != nil { + return err + } else { + **out = newVal.(inf_v0.Dec) + } + } else { + out.Amount = nil + } + out.Format = in.Format + return nil +} + +func DeepCopy_resource_QuantityProto(in QuantityProto, out *QuantityProto, c *conversion.Cloner) error { + out.Format = in.Format + out.Scale = in.Scale + if in.Bigint != nil { + in, out := in.Bigint, &out.Bigint + *out = make([]byte, len(in)) + copy(*out, in) + } else { + out.Bigint = nil + } + return nil +} diff --git a/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/generated.pb.go b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/generated.pb.go new file mode 100644 index 0000000000..7484f92761 --- /dev/null +++ b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/generated.pb.go @@ -0,0 +1,371 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by protoc-gen-gogo. +// source: k8s.io/kubernetes/pkg/api/resource/generated.proto +// DO NOT EDIT! + +/* + Package resource is a generated protocol buffer package. + + It is generated from these files: + k8s.io/kubernetes/pkg/api/resource/generated.proto + + It has these top-level messages: + Quantity + QuantityProto +*/ +package resource + +import proto "github.com/gogo/protobuf/proto" +import fmt "fmt" +import math "math" + +import io "io" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +func (m *Quantity) Reset() { *m = Quantity{} } +func (*Quantity) ProtoMessage() {} + +func (m *QuantityProto) Reset() { *m = QuantityProto{} } +func (m *QuantityProto) String() string { return proto.CompactTextString(m) } +func (*QuantityProto) ProtoMessage() {} + +func init() { + proto.RegisterType((*Quantity)(nil), "k8s.io.kubernetes.pkg.api.resource.Quantity") + proto.RegisterType((*QuantityProto)(nil), "k8s.io.kubernetes.pkg.api.resource.QuantityProto") +} +func (m *QuantityProto) Marshal() (data []byte, err error) { + size := m.Size() + data = make([]byte, size) + n, err := m.MarshalTo(data) + if err != nil { + return nil, err + } + return data[:n], nil +} + +func (m *QuantityProto) MarshalTo(data []byte) (int, error) { + var i int + _ = i + var l int + _ = l + data[i] = 0xa + i++ + i = encodeVarintGenerated(data, i, uint64(len(m.Format))) + i += copy(data[i:], m.Format) + data[i] = 0x10 + i++ + i = encodeVarintGenerated(data, i, uint64(m.Scale)) + if m.Bigint != nil { + data[i] = 0x1a + i++ + i = encodeVarintGenerated(data, i, uint64(len(m.Bigint))) + i += copy(data[i:], m.Bigint) + } + return i, nil +} + +func encodeFixed64Generated(data []byte, offset int, v uint64) int { + data[offset] = uint8(v) + data[offset+1] = uint8(v >> 8) + data[offset+2] = uint8(v >> 16) + data[offset+3] = uint8(v >> 24) + data[offset+4] = uint8(v >> 32) + data[offset+5] = uint8(v >> 40) + data[offset+6] = uint8(v >> 48) + data[offset+7] = uint8(v >> 56) + return offset + 8 +} +func encodeFixed32Generated(data []byte, offset int, v uint32) int { + data[offset] = uint8(v) + data[offset+1] = uint8(v >> 8) + data[offset+2] = uint8(v >> 16) + data[offset+3] = uint8(v >> 24) + return offset + 4 +} +func encodeVarintGenerated(data []byte, offset int, v uint64) int { + for v >= 1<<7 { + data[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + data[offset] = uint8(v) + return offset + 1 +} +func (m *QuantityProto) Size() (n int) { + var l int + _ = l + l = len(m.Format) + n += 1 + l + sovGenerated(uint64(l)) + n += 1 + sovGenerated(uint64(m.Scale)) + if m.Bigint != nil { + l = len(m.Bigint) + n += 1 + l + sovGenerated(uint64(l)) + } + return n +} + +func sovGenerated(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +func sozGenerated(x uint64) (n int) { + return sovGenerated(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QuantityProto) Unmarshal(data []byte) error { + l := len(data) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QuantityProto: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuantityProto: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Format", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Format = Format(data[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Scale", wireType) + } + m.Scale = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + m.Scale |= (int32(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bigint", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + byteLen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + byteLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Bigint = append(m.Bigint[:0], data[iNdEx:postIndex]...) + if m.Bigint == nil { + m.Bigint = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(data[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenerated(data []byte) (n int, err error) { + l := len(data) + iNdEx := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenerated + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenerated + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if data[iNdEx-1] < 0x80 { + break + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenerated + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + iNdEx += length + if length < 0 { + return 0, ErrInvalidLengthGenerated + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenerated + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipGenerated(data[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthGenerated = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenerated = fmt.Errorf("proto: integer overflow") +) diff --git a/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/generated.proto b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/generated.proto new file mode 100644 index 0000000000..34ede4581b --- /dev/null +++ b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/generated.proto @@ -0,0 +1,109 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + + +// This file was autogenerated by go-to-protobuf. Do not edit it manually! + +syntax = 'proto2'; + +package k8s.io.kubernetes.pkg.api.resource; + +import "k8s.io/kubernetes/pkg/util/intstr/generated.proto"; + +// Package-wide variables from generator "generated". +option go_package = "resource"; + +// Quantity is a fixed-point representation of a number. +// It provides convenient marshaling/unmarshaling in JSON and YAML, +// in addition to String() and Int64() accessors. +// +// The serialization format is: +// +// ::= +// (Note that may be empty, from the "" case in .) +// ::= 0 | 1 | ... | 9 +// ::= | +// ::= | . | . | . +// ::= "+" | "-" +// ::= | +// ::= | | +// ::= Ki | Mi | Gi | Ti | Pi | Ei +// (International System of units; See: http://physics.nist.gov/cuu/Units/binary.html) +// ::= m | "" | k | M | G | T | P | E +// (Note that 1024 = 1Ki but 1000 = 1k; I didn't choose the capitalization.) +// ::= "e" | "E" +// +// No matter which of the three exponent forms is used, no quantity may represent +// a number greater than 2^63-1 in magnitude, nor may it have more than 3 decimal +// places. Numbers larger or more precise will be capped or rounded up. +// (E.g.: 0.1m will rounded up to 1m.) +// This may be extended in the future if we require larger or smaller quantities. +// +// When a Quantity is parsed from a string, it will remember the type of suffix +// it had, and will use the same type again when it is serialized. +// +// Before serializing, Quantity will be put in "canonical form". +// This means that Exponent/suffix will be adjusted up or down (with a +// corresponding increase or decrease in Mantissa) such that: +// a. No precision is lost +// b. No fractional digits will be emitted +// c. The exponent (or suffix) is as large as possible. +// The sign will be omitted unless the number is negative. +// +// Examples: +// 1.5 will be serialized as "1500m" +// 1.5Gi will be serialized as "1536Mi" +// +// NOTE: We reserve the right to amend this canonical format, perhaps to +// allow 1.5 to be canonical. +// TODO: Remove above disclaimer after all bikeshedding about format is over, +// or after March 2015. +// +// Note that the quantity will NEVER be internally represented by a +// floating point number. That is the whole point of this exercise. +// +// Non-canonical values will still parse as long as they are well formed, +// but will be re-emitted in their canonical form. (So always use canonical +// form, or don't diff.) +// +// This format is intended to make it difficult to use these numbers without +// writing some sort of special handling code in the hopes that that will +// cause implementors to also use a fixed point implementation. +// +// +protobuf=true +// +protobuf.embed=QuantityProto +// +protobuf.options.marshal=false +// +protobuf.options.(gogoproto.goproto_stringer)=false +message Quantity { + optional QuantityProto QuantityProto = 1; +} + +// QuantityProto is a struct that is equivalent to Quantity, but intended for +// protobuf marshalling/unmarshalling. It is generated into a serialization +// that matches Quantity. Do not use in Go structs. +// +// +protobuf=true +message QuantityProto { + // The format of the quantity + optional string format = 1; + + // The scale dimension of the value + optional int32 scale = 2; + + // Bigint is serialized as a raw bytes array + optional bytes bigint = 3; +} + diff --git a/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/quantity.go b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/quantity.go index 01a7e60a64..e61c8800ec 100644 --- a/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/quantity.go +++ b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/quantity.go @@ -1,5 +1,5 @@ /* -Copyright 2014 Google Inc. All rights reserved. +Copyright 2014 The Kubernetes Authors All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -24,7 +24,8 @@ import ( "strings" flag "github.com/spf13/pflag" - "speter.net/go/exp/math/dec/inf" + + inf "gopkg.in/inf.v0" ) // Quantity is a fixed-point representation of a number. @@ -83,6 +84,11 @@ import ( // This format is intended to make it difficult to use these numbers without // writing some sort of special handling code in the hopes that that will // cause implementors to also use a fixed point implementation. +// +// +protobuf=true +// +protobuf.embed=QuantityProto +// +protobuf.options.marshal=false +// +protobuf.options.(gogoproto.goproto_stringer)=false type Quantity struct { // Amount is public, so you can manipulate it if the accessor // functions are not sufficient. @@ -112,10 +118,27 @@ func MustParse(str string) Quantity { return *q } +// Scale is used for getting and setting the base-10 scaled value. +// Base-2 scales are omitted for mathematical simplicity. +// See Quantity.ScaledValue for more details. +type Scale int + +const ( + Nano Scale = -9 + Micro Scale = -6 + Milli Scale = -3 + Kilo Scale = 3 + Mega Scale = 6 + Giga Scale = 9 + Tera Scale = 12 + Peta Scale = 15 + Exa Scale = 18 +) + const ( // splitREString is used to separate a number from its suffix; as such, // this is overly permissive, but that's OK-- it will be checked later. - splitREString = "^([+-]?[0-9.]+)([eEimkKMGTP]*[-+]?[0-9]*)$" + splitREString = "^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$" ) var ( @@ -171,7 +194,7 @@ func ParseQuantity(str string) (*Quantity, error) { // So that no one but us has to think about suffixes, remove it. if base == 10 { - amount.SetScale(amount.Scale() + inf.Scale(-exponent)) + amount.SetScale(amount.Scale() + Scale(exponent).infScale()) } else if base == 2 { // numericSuffix = 2 ** exponent numericSuffix := big.NewInt(1).Lsh(bigOne, uint(exponent)) @@ -184,13 +207,14 @@ func ParseQuantity(str string) (*Quantity, error) { if sign == -1 { amount.Neg(amount) } - // This rounds non-zero values up to the minimum representable - // value, under the theory that if you want some resources, you - // should get some resources, even if you asked for way too small - // of an amount. - // Arguably, this should be inf.RoundHalfUp (normal rounding), but - // that would have the side effect of rounding values < .5m to zero. - amount.Round(amount, 3, inf.RoundUp) + + // This rounds non-zero values up to the minimum representable value, under the theory that + // if you want some resources, you should get some resources, even if you asked for way too small + // of an amount. Arguably, this should be inf.RoundHalfUp (normal rounding), but that would have + // the side effect of rounding values < .5n to zero. + if v, ok := amount.Unscaled(); v != int64(0) || !ok { + amount.Round(amount, Nano.infScale(), inf.RoundUp) + } // The max is just a simple cap. if amount.Cmp(maxAllowed) > 0 { @@ -237,6 +261,11 @@ func (q *Quantity) Canonicalize() (string, suffix) { return "0", "" } + // zero is zero always + if q.Amount.Cmp(&inf.Dec{}) == 0 { + return "0", "" + } + format := q.Format switch format { case DecimalExponent, DecimalSI: @@ -294,6 +323,77 @@ func (q *Quantity) String() string { return number + string(suffix) } +// Cmp compares q and y and returns: +// +// -1 if q < y +// 0 if q == y +// +1 if q > y +// +func (q *Quantity) Cmp(y Quantity) int { + if q.Amount == nil { + if y.Amount == nil { + return 0 + } + return -y.Amount.Sign() + } + if y.Amount == nil { + return q.Amount.Sign() + } + return q.Amount.Cmp(y.Amount) +} + +func (q *Quantity) Add(y Quantity) error { + switch { + case y.Amount == nil: + // Adding 0: do nothing. + case q.Amount == nil: + q.Amount = &inf.Dec{} + return q.Add(y) + default: + // we want to preserve the format of the non-zero value + zero := &inf.Dec{} + if q.Amount.Cmp(zero) == 0 && y.Amount.Cmp(zero) != 0 { + q.Format = y.Format + } + q.Amount.Add(q.Amount, y.Amount) + } + return nil +} + +func (q *Quantity) Sub(y Quantity) error { + switch { + case y.Amount == nil: + // Subtracting 0: do nothing. + case q.Amount == nil: + q.Amount = &inf.Dec{} + return q.Sub(y) + default: + // we want to preserve the format of the non-zero value + zero := &inf.Dec{} + if q.Amount.Cmp(zero) == 0 && y.Amount.Cmp(zero) != 0 { + q.Format = y.Format + } + q.Amount.Sub(q.Amount, y.Amount) + } + return nil +} + +// Neg sets q to the negative value of y. +// It updates the format of q to match y. +func (q *Quantity) Neg(y Quantity) error { + switch { + case y.Amount == nil: + *q = y + case q.Amount == nil: + q.Amount = &inf.Dec{} + fallthrough + default: + q.Amount.Neg(y.Amount) + q.Format = y.Format + } + return nil +} + // MarshalJSON implements the json.Marshaller interface. func (q Quantity) MarshalJSON() ([]byte, error) { return []byte(`"` + q.String() + `"`), nil @@ -331,41 +431,52 @@ func NewMilliQuantity(value int64, format Format) *Quantity { } } +// NewScaledQuantity returns a new Quantity representing the given +// value * 10^scale in DecimalSI format. +func NewScaledQuantity(value int64, scale Scale) *Quantity { + return &Quantity{ + Amount: inf.NewDec(value, scale.infScale()), + Format: DecimalSI, + } +} + // Value returns the value of q; any fractional part will be lost. func (q *Quantity) Value() int64 { - if q.Amount == nil { - return 0 - } - tmp := &inf.Dec{} - return tmp.Round(q.Amount, 0, inf.RoundUp).UnscaledBig().Int64() + return q.ScaledValue(0) } -// MilliValue returns the value of q * 1000; this could overflow an int64; +// MilliValue returns the value of ceil(q * 1000); this could overflow an int64; // if that's a concern, call Value() first to verify the number is small enough. func (q *Quantity) MilliValue() int64 { + return q.ScaledValue(Milli) +} + +// ScaledValue returns the value of ceil(q * 10^scale); this could overflow an int64. +// To detect overflow, call Value() first and verify the expected magnitude. +func (q *Quantity) ScaledValue(scale Scale) int64 { if q.Amount == nil { return 0 } - tmp := &inf.Dec{} - return tmp.Round(tmp.Mul(q.Amount, decThousand), 0, inf.RoundUp).UnscaledBig().Int64() + return scaledValue(q.Amount.UnscaledBig(), int(q.Amount.Scale()), int(scale.infScale())) } // Set sets q's value to be value. func (q *Quantity) Set(value int64) { - if q.Amount == nil { - q.Amount = &inf.Dec{} - } - q.Amount.SetUnscaled(value) - q.Amount.SetScale(0) + q.SetScaled(value, 0) } // SetMilli sets q's value to be value * 1/1000. func (q *Quantity) SetMilli(value int64) { + q.SetScaled(value, Milli) +} + +// SetScaled sets q's value to be value * 10^scale +func (q *Quantity) SetScaled(value int64, scale Scale) { if q.Amount == nil { q.Amount = &inf.Dec{} } q.Amount.SetUnscaled(value) - q.Amount.SetScale(3) + q.Amount.SetScale(scale.infScale()) } // Copy is a convenience function that makes a deep copy for you. Non-deep @@ -420,3 +531,8 @@ func QuantityFlag(flagName, defaultValue, description string) *Quantity { func NewQuantityFlagValue(q *Quantity) flag.Value { return qFlag{q} } + +// infScale adapts a Scale value to an inf.Scale value. +func (s Scale) infScale() inf.Scale { + return inf.Scale(-s) // inf.Scale is upside-down +} diff --git a/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/quantity_proto.go b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/quantity_proto.go new file mode 100644 index 0000000000..01d5c2997e --- /dev/null +++ b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/quantity_proto.go @@ -0,0 +1,78 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package resource + +import ( + "math/big" + + inf "gopkg.in/inf.v0" +) + +// QuantityProto is a struct that is equivalent to Quantity, but intended for +// protobuf marshalling/unmarshalling. It is generated into a serialization +// that matches Quantity. Do not use in Go structs. +// +// +protobuf=true +type QuantityProto struct { + // The format of the quantity + Format Format `protobuf:"bytes,1,opt,name=format,casttype=Format"` + // The scale dimension of the value + Scale int32 `protobuf:"varint,2,opt,name=scale"` + // Bigint is serialized as a raw bytes array + Bigint []byte `protobuf:"bytes,3,opt,name=bigint"` +} + +// ProtoTime returns the Time as a new ProtoTime value. +func (q *Quantity) QuantityProto() *QuantityProto { + if q == nil { + return &QuantityProto{} + } + p := &QuantityProto{ + Format: q.Format, + } + if q.Amount != nil { + p.Scale = int32(q.Amount.Scale()) + p.Bigint = q.Amount.UnscaledBig().Bytes() + } + return p +} + +// Size implements the protobuf marshalling interface. +func (q *Quantity) Size() (n int) { return q.QuantityProto().Size() } + +// Reset implements the protobuf marshalling interface. +func (q *Quantity) Unmarshal(data []byte) error { + p := QuantityProto{} + if err := p.Unmarshal(data); err != nil { + return err + } + q.Format = p.Format + b := big.NewInt(0) + b.SetBytes(p.Bigint) + q.Amount = inf.NewDecBig(b, inf.Scale(p.Scale)) + return nil +} + +// Marshal implements the protobuf marshalling interface. +func (q *Quantity) Marshal() (data []byte, err error) { + return q.QuantityProto().Marshal() +} + +// MarshalTo implements the protobuf marshalling interface. +func (q *Quantity) MarshalTo(data []byte) (int, error) { + return q.QuantityProto().MarshalTo(data) +} diff --git a/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/scale_int.go b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/scale_int.go new file mode 100644 index 0000000000..173de1a217 --- /dev/null +++ b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/scale_int.go @@ -0,0 +1,95 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package resource + +import ( + "math" + "math/big" + "sync" +) + +var ( + // A sync pool to reduce allocation. + intPool sync.Pool + maxInt64 = big.NewInt(math.MaxInt64) +) + +func init() { + intPool.New = func() interface{} { + return &big.Int{} + } +} + +// scaledValue scales given unscaled value from scale to new Scale and returns +// an int64. It ALWAYS rounds up the result when scale down. The final result might +// overflow. +// +// scale, newScale represents the scale of the unscaled decimal. +// The mathematical value of the decimal is unscaled * 10**(-scale). +func scaledValue(unscaled *big.Int, scale, newScale int) int64 { + dif := scale - newScale + if dif == 0 { + return unscaled.Int64() + } + + // Handle scale up + // This is an easy case, we do not need to care about rounding and overflow. + // If any intermediate operation causes overflow, the result will overflow. + if dif < 0 { + return unscaled.Int64() * int64(math.Pow10(-dif)) + } + + // Handle scale down + // We have to be careful about the intermediate operations. + + // fast path when unscaled < max.Int64 and exp(10,dif) < max.Int64 + const log10MaxInt64 = 19 + if unscaled.Cmp(maxInt64) < 0 && dif < log10MaxInt64 { + divide := int64(math.Pow10(dif)) + result := unscaled.Int64() / divide + mod := unscaled.Int64() % divide + if mod != 0 { + return result + 1 + } + return result + } + + // We should only convert back to int64 when getting the result. + divisor := intPool.Get().(*big.Int) + exp := intPool.Get().(*big.Int) + result := intPool.Get().(*big.Int) + defer func() { + intPool.Put(divisor) + intPool.Put(exp) + intPool.Put(result) + }() + + // divisor = 10^(dif) + // TODO: create loop up table if exp costs too much. + divisor.Exp(bigTen, exp.SetInt64(int64(dif)), nil) + // reuse exp + remainder := exp + + // result = unscaled / divisor + // remainder = unscaled % divisor + result.DivMod(unscaled, divisor, remainder) + if remainder.Sign() != 0 { + return result.Int64() + 1 + } + + return result.Int64() +} diff --git a/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/suffix.go b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/suffix.go index 6f0dbd5f27..529712365d 100644 --- a/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/suffix.go +++ b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/suffix.go @@ -1,5 +1,5 @@ /* -Copyright 2014 Google Inc. All rights reserved. +Copyright 2014 The Kubernetes Authors All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -83,6 +83,8 @@ func newSuffixer() suffixer { // a suffix for 2^0. sh.decSuffixes.addSuffix("", bePair{2, 0}) + sh.decSuffixes.addSuffix("n", bePair{10, -9}) + sh.decSuffixes.addSuffix("u", bePair{10, -6}) sh.decSuffixes.addSuffix("m", bePair{10, -3}) sh.decSuffixes.addSuffix("", bePair{10, 0}) sh.decSuffixes.addSuffix("k", bePair{10, 3}) diff --git a/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/OWNERS b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/OWNERS new file mode 100644 index 0000000000..a046efc0c2 --- /dev/null +++ b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/OWNERS @@ -0,0 +1,5 @@ +assignees: + - derekwaynecarr + - lavalamp + - smarterclayton + - wojtek-t diff --git a/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/cloner.go b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/cloner.go new file mode 100644 index 0000000000..a8c5747132 --- /dev/null +++ b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/cloner.go @@ -0,0 +1,237 @@ +/* +Copyright 2014 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package conversion + +import ( + "fmt" + "reflect" +) + +// Cloner knows how to copy one type to another. +type Cloner struct { + // Map from the type to a function which can do the deep copy. + deepCopyFuncs map[reflect.Type]reflect.Value + generatedDeepCopyFuncs map[reflect.Type]reflect.Value +} + +// NewCloner creates a new Cloner object. +func NewCloner() *Cloner { + c := &Cloner{ + deepCopyFuncs: map[reflect.Type]reflect.Value{}, + generatedDeepCopyFuncs: map[reflect.Type]reflect.Value{}, + } + if err := c.RegisterDeepCopyFunc(byteSliceDeepCopy); err != nil { + // If one of the deep-copy functions is malformed, detect it immediately. + panic(err) + } + return c +} + +// Prevent recursing into every byte... +func byteSliceDeepCopy(in []byte, out *[]byte, c *Cloner) error { + if in != nil { + *out = make([]byte, len(in)) + copy(*out, in) + } else { + *out = nil + } + return nil +} + +// Verifies whether a deep-copy function has a correct signature. +func verifyDeepCopyFunctionSignature(ft reflect.Type) error { + if ft.Kind() != reflect.Func { + return fmt.Errorf("expected func, got: %v", ft) + } + if ft.NumIn() != 3 { + return fmt.Errorf("expected three 'in' params, got %v", ft) + } + if ft.NumOut() != 1 { + return fmt.Errorf("expected one 'out' param, got %v", ft) + } + if ft.In(1).Kind() != reflect.Ptr { + return fmt.Errorf("expected pointer arg for 'in' param 1, got: %v", ft) + } + if ft.In(1).Elem() != ft.In(0) { + return fmt.Errorf("expected 'in' param 0 the same as param 1, got: %v", ft) + } + var forClonerType Cloner + if expected := reflect.TypeOf(&forClonerType); ft.In(2) != expected { + return fmt.Errorf("expected '%v' arg for 'in' param 2, got: '%v'", expected, ft.In(2)) + } + var forErrorType error + // This convolution is necessary, otherwise TypeOf picks up on the fact + // that forErrorType is nil + errorType := reflect.TypeOf(&forErrorType).Elem() + if ft.Out(0) != errorType { + return fmt.Errorf("expected error return, got: %v", ft) + } + return nil +} + +// RegisterGeneratedDeepCopyFunc registers a copying func with the Cloner. +// deepCopyFunc must take three parameters: a type input, a pointer to a +// type output, and a pointer to Cloner. It should return an error. +// +// Example: +// c.RegisterGeneratedDeepCopyFunc( +// func(in Pod, out *Pod, c *Cloner) error { +// // deep copy logic... +// return nil +// }) +func (c *Cloner) RegisterDeepCopyFunc(deepCopyFunc interface{}) error { + fv := reflect.ValueOf(deepCopyFunc) + ft := fv.Type() + if err := verifyDeepCopyFunctionSignature(ft); err != nil { + return err + } + c.deepCopyFuncs[ft.In(0)] = fv + return nil +} + +// Similar to RegisterDeepCopyFunc, but registers deep copy function that were +// automatically generated. +func (c *Cloner) RegisterGeneratedDeepCopyFunc(deepCopyFunc interface{}) error { + fv := reflect.ValueOf(deepCopyFunc) + ft := fv.Type() + if err := verifyDeepCopyFunctionSignature(ft); err != nil { + return err + } + c.generatedDeepCopyFuncs[ft.In(0)] = fv + return nil +} + +// DeepCopy will perform a deep copy of a given object. +func (c *Cloner) DeepCopy(in interface{}) (interface{}, error) { + // Can be invalid if we run DeepCopy(X) where X is a nil interface type. + // For example, we get an invalid value when someone tries to deep-copy + // a nil labels.Selector. + // This does not occur if X is nil and is a pointer to a concrete type. + if in == nil { + return nil, nil + } + inValue := reflect.ValueOf(in) + outValue, err := c.deepCopy(inValue) + if err != nil { + return nil, err + } + return outValue.Interface(), nil +} + +func (c *Cloner) deepCopy(src reflect.Value) (reflect.Value, error) { + inType := src.Type() + + if fv, ok := c.deepCopyFuncs[inType]; ok { + return c.customDeepCopy(src, fv) + } + if fv, ok := c.generatedDeepCopyFuncs[inType]; ok { + return c.customDeepCopy(src, fv) + } + return c.defaultDeepCopy(src) +} + +func (c *Cloner) customDeepCopy(src, fv reflect.Value) (reflect.Value, error) { + outValue := reflect.New(src.Type()) + args := []reflect.Value{src, outValue, reflect.ValueOf(c)} + result := fv.Call(args)[0].Interface() + // This convolution is necessary because nil interfaces won't convert + // to error. + if result == nil { + return outValue.Elem(), nil + } + return outValue.Elem(), result.(error) +} + +func (c *Cloner) defaultDeepCopy(src reflect.Value) (reflect.Value, error) { + switch src.Kind() { + case reflect.Chan, reflect.Func, reflect.UnsafePointer, reflect.Uintptr: + return src, fmt.Errorf("cannot deep copy kind: %s", src.Kind()) + case reflect.Array: + dst := reflect.New(src.Type()) + for i := 0; i < src.Len(); i++ { + copyVal, err := c.deepCopy(src.Index(i)) + if err != nil { + return src, err + } + dst.Elem().Index(i).Set(copyVal) + } + return dst.Elem(), nil + case reflect.Interface: + if src.IsNil() { + return src, nil + } + return c.deepCopy(src.Elem()) + case reflect.Map: + if src.IsNil() { + return src, nil + } + dst := reflect.MakeMap(src.Type()) + for _, k := range src.MapKeys() { + copyVal, err := c.deepCopy(src.MapIndex(k)) + if err != nil { + return src, err + } + dst.SetMapIndex(k, copyVal) + } + return dst, nil + case reflect.Ptr: + if src.IsNil() { + return src, nil + } + dst := reflect.New(src.Type().Elem()) + copyVal, err := c.deepCopy(src.Elem()) + if err != nil { + return src, err + } + dst.Elem().Set(copyVal) + return dst, nil + case reflect.Slice: + if src.IsNil() { + return src, nil + } + dst := reflect.MakeSlice(src.Type(), 0, src.Len()) + for i := 0; i < src.Len(); i++ { + copyVal, err := c.deepCopy(src.Index(i)) + if err != nil { + return src, err + } + dst = reflect.Append(dst, copyVal) + } + return dst, nil + case reflect.Struct: + dst := reflect.New(src.Type()) + for i := 0; i < src.NumField(); i++ { + if !dst.Elem().Field(i).CanSet() { + // Can't set private fields. At this point, the + // best we can do is a shallow copy. For + // example, time.Time is a value type with + // private members that can be shallow copied. + return src, nil + } + copyVal, err := c.deepCopy(src.Field(i)) + if err != nil { + return src, err + } + dst.Elem().Field(i).Set(copyVal) + } + return dst.Elem(), nil + + default: + // Value types like numbers, booleans, and strings. + return src, nil + } +} diff --git a/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/converter.go b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/converter.go new file mode 100644 index 0000000000..e045dcd2f7 --- /dev/null +++ b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/converter.go @@ -0,0 +1,951 @@ +/* +Copyright 2014 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package conversion + +import ( + "fmt" + "reflect" +) + +type typePair struct { + source reflect.Type + dest reflect.Type +} + +type typeNamePair struct { + fieldType reflect.Type + fieldName string +} + +// DebugLogger allows you to get debugging messages if necessary. +type DebugLogger interface { + Logf(format string, args ...interface{}) +} + +type NameFunc func(t reflect.Type) string + +var DefaultNameFunc = func(t reflect.Type) string { return t.Name() } + +type GenericConversionFunc func(a, b interface{}, scope Scope) (bool, error) + +// Converter knows how to convert one type to another. +type Converter struct { + // Map from the conversion pair to a function which can + // do the conversion. + conversionFuncs ConversionFuncs + generatedConversionFuncs ConversionFuncs + + // genericConversions are called during normal conversion to offer a "fast-path" + // that avoids all reflection. These methods are not called outside of the .Convert() + // method. + genericConversions []GenericConversionFunc + + // Set of conversions that should be treated as a no-op + ignoredConversions map[typePair]struct{} + + // This is a map from a source field type and name, to a list of destination + // field type and name. + structFieldDests map[typeNamePair][]typeNamePair + + // Allows for the opposite lookup of structFieldDests. So that SourceFromDest + // copy flag also works. So this is a map of destination field name, to potential + // source field name and type to look for. + structFieldSources map[typeNamePair][]typeNamePair + + // Map from a type to a function which applies defaults. + defaultingFuncs map[reflect.Type]reflect.Value + + // Similar to above, but function is stored as interface{}. + defaultingInterfaces map[reflect.Type]interface{} + + // Map from an input type to a function which can apply a key name mapping + inputFieldMappingFuncs map[reflect.Type]FieldMappingFunc + + // Map from an input type to a set of default conversion flags. + inputDefaultFlags map[reflect.Type]FieldMatchingFlags + + // If non-nil, will be called to print helpful debugging info. Quite verbose. + Debug DebugLogger + + // nameFunc is called to retrieve the name of a type; this name is used for the + // purpose of deciding whether two types match or not (i.e., will we attempt to + // do a conversion). The default returns the go type name. + nameFunc func(t reflect.Type) string +} + +// NewConverter creates a new Converter object. +func NewConverter(nameFn NameFunc) *Converter { + c := &Converter{ + conversionFuncs: NewConversionFuncs(), + generatedConversionFuncs: NewConversionFuncs(), + ignoredConversions: make(map[typePair]struct{}), + defaultingFuncs: make(map[reflect.Type]reflect.Value), + defaultingInterfaces: make(map[reflect.Type]interface{}), + nameFunc: nameFn, + structFieldDests: make(map[typeNamePair][]typeNamePair), + structFieldSources: make(map[typeNamePair][]typeNamePair), + + inputFieldMappingFuncs: make(map[reflect.Type]FieldMappingFunc), + inputDefaultFlags: make(map[reflect.Type]FieldMatchingFlags), + } + c.RegisterConversionFunc(Convert_Slice_byte_To_Slice_byte) + return c +} + +// AddGenericConversionFunc adds a function that accepts the ConversionFunc call pattern +// (for two conversion types) to the converter. These functions are checked first during +// a normal conversion, but are otherwise not called. Use AddConversionFuncs when registering +// typed conversions. +func (c *Converter) AddGenericConversionFunc(fn GenericConversionFunc) { + c.genericConversions = append(c.genericConversions, fn) +} + +// WithConversions returns a Converter that is a copy of c but with the additional +// fns merged on top. +func (c *Converter) WithConversions(fns ConversionFuncs) *Converter { + copied := *c + copied.conversionFuncs = c.conversionFuncs.Merge(fns) + return &copied +} + +// DefaultMeta returns the conversion FieldMappingFunc and meta for a given type. +func (c *Converter) DefaultMeta(t reflect.Type) (FieldMatchingFlags, *Meta) { + return c.inputDefaultFlags[t], &Meta{ + KeyNameMapping: c.inputFieldMappingFuncs[t], + } +} + +// Convert_Slice_byte_To_Slice_byte prevents recursing into every byte +func Convert_Slice_byte_To_Slice_byte(in *[]byte, out *[]byte, s Scope) error { + if *in == nil { + *out = nil + return nil + } + *out = make([]byte, len(*in)) + copy(*out, *in) + return nil +} + +// Scope is passed to conversion funcs to allow them to continue an ongoing conversion. +// If multiple converters exist in the system, Scope will allow you to use the correct one +// from a conversion function--that is, the one your conversion function was called by. +type Scope interface { + // Call Convert to convert sub-objects. Note that if you call it with your own exact + // parameters, you'll run out of stack space before anything useful happens. + Convert(src, dest interface{}, flags FieldMatchingFlags) error + + // DefaultConvert performs the default conversion, without calling a conversion func + // on the current stack frame. This makes it safe to call from a conversion func. + DefaultConvert(src, dest interface{}, flags FieldMatchingFlags) error + + // If registered, returns a function applying defaults for objects of a given type. + // Used for automatically generating conversion functions. + DefaultingInterface(inType reflect.Type) (interface{}, bool) + + // SrcTags and DestTags contain the struct tags that src and dest had, respectively. + // If the enclosing object was not a struct, then these will contain no tags, of course. + SrcTag() reflect.StructTag + DestTag() reflect.StructTag + + // Flags returns the flags with which the conversion was started. + Flags() FieldMatchingFlags + + // Meta returns any information originally passed to Convert. + Meta() *Meta +} + +// FieldMappingFunc can convert an input field value into different values, depending on +// the value of the source or destination struct tags. +type FieldMappingFunc func(key string, sourceTag, destTag reflect.StructTag) (source string, dest string) + +func NewConversionFuncs() ConversionFuncs { + return ConversionFuncs{fns: make(map[typePair]reflect.Value)} +} + +type ConversionFuncs struct { + fns map[typePair]reflect.Value +} + +// Add adds the provided conversion functions to the lookup table - they must have the signature +// `func(type1, type2, Scope) error`. Functions are added in the order passed and will override +// previously registered pairs. +func (c ConversionFuncs) Add(fns ...interface{}) error { + for _, fn := range fns { + fv := reflect.ValueOf(fn) + ft := fv.Type() + if err := verifyConversionFunctionSignature(ft); err != nil { + return err + } + c.fns[typePair{ft.In(0).Elem(), ft.In(1).Elem()}] = fv + } + return nil +} + +// Merge returns a new ConversionFuncs that contains all conversions from +// both other and c, with other conversions taking precedence. +func (c ConversionFuncs) Merge(other ConversionFuncs) ConversionFuncs { + merged := NewConversionFuncs() + for k, v := range c.fns { + merged.fns[k] = v + } + for k, v := range other.fns { + merged.fns[k] = v + } + return merged +} + +// Meta is supplied by Scheme, when it calls Convert. +type Meta struct { + // KeyNameMapping is an optional function which may map the listed key (field name) + // into a source and destination value. + KeyNameMapping FieldMappingFunc +} + +// scope contains information about an ongoing conversion. +type scope struct { + converter *Converter + meta *Meta + flags FieldMatchingFlags + + // srcStack & destStack are separate because they may not have a 1:1 + // relationship. + srcStack scopeStack + destStack scopeStack +} + +type scopeStackElem struct { + tag reflect.StructTag + value reflect.Value + key string +} + +type scopeStack []scopeStackElem + +func (s *scopeStack) pop() { + n := len(*s) + *s = (*s)[:n-1] +} + +func (s *scopeStack) push(e scopeStackElem) { + *s = append(*s, e) +} + +func (s *scopeStack) top() *scopeStackElem { + return &(*s)[len(*s)-1] +} + +func (s scopeStack) describe() string { + desc := "" + if len(s) > 1 { + desc = "(" + s[1].value.Type().String() + ")" + } + for i, v := range s { + if i < 2 { + // First layer on stack is not real; second is handled specially above. + continue + } + if v.key == "" { + desc += fmt.Sprintf(".%v", v.value.Type()) + } else { + desc += fmt.Sprintf(".%v", v.key) + } + } + return desc +} + +func (s *scope) DefaultingInterface(inType reflect.Type) (interface{}, bool) { + value, found := s.converter.defaultingInterfaces[inType] + return value, found +} + +// Formats src & dest as indices for printing. +func (s *scope) setIndices(src, dest int) { + s.srcStack.top().key = fmt.Sprintf("[%v]", src) + s.destStack.top().key = fmt.Sprintf("[%v]", dest) +} + +// Formats src & dest as map keys for printing. +func (s *scope) setKeys(src, dest interface{}) { + s.srcStack.top().key = fmt.Sprintf(`["%v"]`, src) + s.destStack.top().key = fmt.Sprintf(`["%v"]`, dest) +} + +// Convert continues a conversion. +func (s *scope) Convert(src, dest interface{}, flags FieldMatchingFlags) error { + return s.converter.Convert(src, dest, flags, s.meta) +} + +// DefaultConvert continues a conversion, performing a default conversion (no conversion func) +// for the current stack frame. +func (s *scope) DefaultConvert(src, dest interface{}, flags FieldMatchingFlags) error { + return s.converter.DefaultConvert(src, dest, flags, s.meta) +} + +// SrcTag returns the tag of the struct containing the current source item, if any. +func (s *scope) SrcTag() reflect.StructTag { + return s.srcStack.top().tag +} + +// DestTag returns the tag of the struct containing the current dest item, if any. +func (s *scope) DestTag() reflect.StructTag { + return s.destStack.top().tag +} + +// Flags returns the flags with which the current conversion was started. +func (s *scope) Flags() FieldMatchingFlags { + return s.flags +} + +// Meta returns the meta object that was originally passed to Convert. +func (s *scope) Meta() *Meta { + return s.meta +} + +// describe prints the path to get to the current (source, dest) values. +func (s *scope) describe() (src, dest string) { + return s.srcStack.describe(), s.destStack.describe() +} + +// error makes an error that includes information about where we were in the objects +// we were asked to convert. +func (s *scope) errorf(message string, args ...interface{}) error { + srcPath, destPath := s.describe() + where := fmt.Sprintf("converting %v to %v: ", srcPath, destPath) + return fmt.Errorf(where+message, args...) +} + +// Verifies whether a conversion function has a correct signature. +func verifyConversionFunctionSignature(ft reflect.Type) error { + if ft.Kind() != reflect.Func { + return fmt.Errorf("expected func, got: %v", ft) + } + if ft.NumIn() != 3 { + return fmt.Errorf("expected three 'in' params, got: %v", ft) + } + if ft.NumOut() != 1 { + return fmt.Errorf("expected one 'out' param, got: %v", ft) + } + if ft.In(0).Kind() != reflect.Ptr { + return fmt.Errorf("expected pointer arg for 'in' param 0, got: %v", ft) + } + if ft.In(1).Kind() != reflect.Ptr { + return fmt.Errorf("expected pointer arg for 'in' param 1, got: %v", ft) + } + scopeType := Scope(nil) + if e, a := reflect.TypeOf(&scopeType).Elem(), ft.In(2); e != a { + return fmt.Errorf("expected '%v' arg for 'in' param 2, got '%v' (%v)", e, a, ft) + } + var forErrorType error + // This convolution is necessary, otherwise TypeOf picks up on the fact + // that forErrorType is nil. + errorType := reflect.TypeOf(&forErrorType).Elem() + if ft.Out(0) != errorType { + return fmt.Errorf("expected error return, got: %v", ft) + } + return nil +} + +// RegisterConversionFunc registers a conversion func with the +// Converter. conversionFunc must take three parameters: a pointer to the input +// type, a pointer to the output type, and a conversion.Scope (which should be +// used if recursive conversion calls are desired). It must return an error. +// +// Example: +// c.RegisterConversionFunc( +// func(in *Pod, out *v1.Pod, s Scope) error { +// // conversion logic... +// return nil +// }) +func (c *Converter) RegisterConversionFunc(conversionFunc interface{}) error { + return c.conversionFuncs.Add(conversionFunc) +} + +// Similar to RegisterConversionFunc, but registers conversion function that were +// automatically generated. +func (c *Converter) RegisterGeneratedConversionFunc(conversionFunc interface{}) error { + return c.generatedConversionFuncs.Add(conversionFunc) +} + +// RegisterIgnoredConversion registers a "no-op" for conversion, where any requested +// conversion between from and to is ignored. +func (c *Converter) RegisterIgnoredConversion(from, to interface{}) error { + typeFrom := reflect.TypeOf(from) + typeTo := reflect.TypeOf(to) + if reflect.TypeOf(from).Kind() != reflect.Ptr { + return fmt.Errorf("expected pointer arg for 'from' param 0, got: %v", typeFrom) + } + if typeTo.Kind() != reflect.Ptr { + return fmt.Errorf("expected pointer arg for 'to' param 1, got: %v", typeTo) + } + c.ignoredConversions[typePair{typeFrom.Elem(), typeTo.Elem()}] = struct{}{} + return nil +} + +// IsConversionIgnored returns true if the specified objects should be dropped during +// conversion. +func (c *Converter) IsConversionIgnored(inType, outType reflect.Type) bool { + _, found := c.ignoredConversions[typePair{inType, outType}] + return found +} + +func (c *Converter) HasConversionFunc(inType, outType reflect.Type) bool { + _, found := c.conversionFuncs.fns[typePair{inType, outType}] + return found +} + +func (c *Converter) ConversionFuncValue(inType, outType reflect.Type) (reflect.Value, bool) { + value, found := c.conversionFuncs.fns[typePair{inType, outType}] + return value, found +} + +// SetStructFieldCopy registers a correspondence. Whenever a struct field is encountered +// which has a type and name matching srcFieldType and srcFieldName, it wil be copied +// into the field in the destination struct matching destFieldType & Name, if such a +// field exists. +// May be called multiple times, even for the same source field & type--all applicable +// copies will be performed. +func (c *Converter) SetStructFieldCopy(srcFieldType interface{}, srcFieldName string, destFieldType interface{}, destFieldName string) error { + st := reflect.TypeOf(srcFieldType) + dt := reflect.TypeOf(destFieldType) + srcKey := typeNamePair{st, srcFieldName} + destKey := typeNamePair{dt, destFieldName} + c.structFieldDests[srcKey] = append(c.structFieldDests[srcKey], destKey) + c.structFieldSources[destKey] = append(c.structFieldSources[destKey], srcKey) + return nil +} + +// RegisterDefaultingFunc registers a value-defaulting func with the Converter. +// defaultingFunc must take one parameters: a pointer to the input type. +// +// Example: +// c.RegisteDefaultingFunc( +// func(in *v1.Pod) { +// // defaulting logic... +// }) +func (c *Converter) RegisterDefaultingFunc(defaultingFunc interface{}) error { + fv := reflect.ValueOf(defaultingFunc) + ft := fv.Type() + if ft.Kind() != reflect.Func { + return fmt.Errorf("expected func, got: %v", ft) + } + if ft.NumIn() != 1 { + return fmt.Errorf("expected one 'in' param, got: %v", ft) + } + if ft.NumOut() != 0 { + return fmt.Errorf("expected zero 'out' params, got: %v", ft) + } + if ft.In(0).Kind() != reflect.Ptr { + return fmt.Errorf("expected pointer arg for 'in' param 0, got: %v", ft) + } + inType := ft.In(0).Elem() + c.defaultingFuncs[inType] = fv + c.defaultingInterfaces[inType] = defaultingFunc + return nil +} + +// RegisterInputDefaults registers a field name mapping function, used when converting +// from maps to structs. Inputs to the conversion methods are checked for this type and a mapping +// applied automatically if the input matches in. A set of default flags for the input conversion +// may also be provided, which will be used when no explicit flags are requested. +func (c *Converter) RegisterInputDefaults(in interface{}, fn FieldMappingFunc, defaultFlags FieldMatchingFlags) error { + fv := reflect.ValueOf(in) + ft := fv.Type() + if ft.Kind() != reflect.Ptr { + return fmt.Errorf("expected pointer 'in' argument, got: %v", ft) + } + c.inputFieldMappingFuncs[ft] = fn + c.inputDefaultFlags[ft] = defaultFlags + return nil +} + +// FieldMatchingFlags contains a list of ways in which struct fields could be +// copied. These constants may be | combined. +type FieldMatchingFlags int + +const ( + // Loop through destination fields, search for matching source + // field to copy it from. Source fields with no corresponding + // destination field will be ignored. If SourceToDest is + // specified, this flag is ignored. If neither is specified, + // or no flags are passed, this flag is the default. + DestFromSource FieldMatchingFlags = 0 + // Loop through source fields, search for matching dest field + // to copy it into. Destination fields with no corresponding + // source field will be ignored. + SourceToDest FieldMatchingFlags = 1 << iota + // Don't treat it as an error if the corresponding source or + // dest field can't be found. + IgnoreMissingFields + // Don't require type names to match. + AllowDifferentFieldTypeNames +) + +// IsSet returns true if the given flag or combination of flags is set. +func (f FieldMatchingFlags) IsSet(flag FieldMatchingFlags) bool { + if flag == DestFromSource { + // The bit logic doesn't work on the default value. + return f&SourceToDest != SourceToDest + } + return f&flag == flag +} + +// Convert will translate src to dest if it knows how. Both must be pointers. +// If no conversion func is registered and the default copying mechanism +// doesn't work on this type pair, an error will be returned. +// Read the comments on the various FieldMatchingFlags constants to understand +// what the 'flags' parameter does. +// 'meta' is given to allow you to pass information to conversion functions, +// it is not used by Convert() other than storing it in the scope. +// Not safe for objects with cyclic references! +func (c *Converter) Convert(src, dest interface{}, flags FieldMatchingFlags, meta *Meta) error { + if len(c.genericConversions) > 0 { + // TODO: avoid scope allocation + s := &scope{converter: c, flags: flags, meta: meta} + for _, fn := range c.genericConversions { + if ok, err := fn(src, dest, s); ok { + return err + } + } + } + return c.doConversion(src, dest, flags, meta, c.convert) +} + +// DefaultConvert will translate src to dest if it knows how. Both must be pointers. +// No conversion func is used. If the default copying mechanism +// doesn't work on this type pair, an error will be returned. +// Read the comments on the various FieldMatchingFlags constants to understand +// what the 'flags' parameter does. +// 'meta' is given to allow you to pass information to conversion functions, +// it is not used by DefaultConvert() other than storing it in the scope. +// Not safe for objects with cyclic references! +func (c *Converter) DefaultConvert(src, dest interface{}, flags FieldMatchingFlags, meta *Meta) error { + return c.doConversion(src, dest, flags, meta, c.defaultConvert) +} + +type conversionFunc func(sv, dv reflect.Value, scope *scope) error + +func (c *Converter) doConversion(src, dest interface{}, flags FieldMatchingFlags, meta *Meta, f conversionFunc) error { + dv, err := EnforcePtr(dest) + if err != nil { + return err + } + if !dv.CanAddr() && !dv.CanSet() { + return fmt.Errorf("can't write to dest") + } + sv, err := EnforcePtr(src) + if err != nil { + return err + } + s := &scope{ + converter: c, + flags: flags, + meta: meta, + } + // Leave something on the stack, so that calls to struct tag getters never fail. + s.srcStack.push(scopeStackElem{}) + s.destStack.push(scopeStackElem{}) + return f(sv, dv, s) +} + +// callCustom calls 'custom' with sv & dv. custom must be a conversion function. +func (c *Converter) callCustom(sv, dv, custom reflect.Value, scope *scope) error { + if !sv.CanAddr() { + sv2 := reflect.New(sv.Type()) + sv2.Elem().Set(sv) + sv = sv2 + } else { + sv = sv.Addr() + } + if !dv.CanAddr() { + if !dv.CanSet() { + return scope.errorf("can't addr or set dest.") + } + dvOrig := dv + dv := reflect.New(dvOrig.Type()) + defer func() { dvOrig.Set(dv) }() + } else { + dv = dv.Addr() + } + args := []reflect.Value{sv, dv, reflect.ValueOf(scope)} + ret := custom.Call(args)[0].Interface() + // This convolution is necessary because nil interfaces won't convert + // to errors. + if ret == nil { + return nil + } + return ret.(error) +} + +// convert recursively copies sv into dv, calling an appropriate conversion function if +// one is registered. +func (c *Converter) convert(sv, dv reflect.Value, scope *scope) error { + dt, st := dv.Type(), sv.Type() + // Apply default values. + if fv, ok := c.defaultingFuncs[st]; ok { + if c.Debug != nil { + c.Debug.Logf("Applying defaults for '%v'", st) + } + args := []reflect.Value{sv.Addr()} + fv.Call(args) + } + + pair := typePair{st, dt} + + // ignore conversions of this type + if _, ok := c.ignoredConversions[pair]; ok { + if c.Debug != nil { + c.Debug.Logf("Ignoring conversion of '%v' to '%v'", st, dt) + } + return nil + } + + // Convert sv to dv. + if fv, ok := c.conversionFuncs.fns[pair]; ok { + if c.Debug != nil { + c.Debug.Logf("Calling custom conversion of '%v' to '%v'", st, dt) + } + return c.callCustom(sv, dv, fv, scope) + } + if fv, ok := c.generatedConversionFuncs.fns[pair]; ok { + if c.Debug != nil { + c.Debug.Logf("Calling generated conversion of '%v' to '%v'", st, dt) + } + return c.callCustom(sv, dv, fv, scope) + } + + return c.defaultConvert(sv, dv, scope) +} + +// defaultConvert recursively copies sv into dv. no conversion function is called +// for the current stack frame (but conversion functions may be called for nested objects) +func (c *Converter) defaultConvert(sv, dv reflect.Value, scope *scope) error { + dt, st := dv.Type(), sv.Type() + + if !dv.CanSet() { + return scope.errorf("Cannot set dest. (Tried to deep copy something with unexported fields?)") + } + + if !scope.flags.IsSet(AllowDifferentFieldTypeNames) && c.nameFunc(dt) != c.nameFunc(st) { + return scope.errorf( + "type names don't match (%v, %v), and no conversion 'func (%v, %v) error' registered.", + c.nameFunc(st), c.nameFunc(dt), st, dt) + } + + switch st.Kind() { + case reflect.Map, reflect.Ptr, reflect.Slice, reflect.Interface, reflect.Struct: + // Don't copy these via assignment/conversion! + default: + // This should handle all simple types. + if st.AssignableTo(dt) { + dv.Set(sv) + return nil + } + if st.ConvertibleTo(dt) { + dv.Set(sv.Convert(dt)) + return nil + } + } + + if c.Debug != nil { + c.Debug.Logf("Trying to convert '%v' to '%v'", st, dt) + } + + scope.srcStack.push(scopeStackElem{value: sv}) + scope.destStack.push(scopeStackElem{value: dv}) + defer scope.srcStack.pop() + defer scope.destStack.pop() + + switch dv.Kind() { + case reflect.Struct: + return c.convertKV(toKVValue(sv), toKVValue(dv), scope) + case reflect.Slice: + if sv.IsNil() { + // Don't make a zero-length slice. + dv.Set(reflect.Zero(dt)) + return nil + } + dv.Set(reflect.MakeSlice(dt, sv.Len(), sv.Cap())) + for i := 0; i < sv.Len(); i++ { + scope.setIndices(i, i) + if err := c.convert(sv.Index(i), dv.Index(i), scope); err != nil { + return err + } + } + case reflect.Ptr: + if sv.IsNil() { + // Don't copy a nil ptr! + dv.Set(reflect.Zero(dt)) + return nil + } + dv.Set(reflect.New(dt.Elem())) + switch st.Kind() { + case reflect.Ptr, reflect.Interface: + return c.convert(sv.Elem(), dv.Elem(), scope) + default: + return c.convert(sv, dv.Elem(), scope) + } + case reflect.Map: + if sv.IsNil() { + // Don't copy a nil ptr! + dv.Set(reflect.Zero(dt)) + return nil + } + dv.Set(reflect.MakeMap(dt)) + for _, sk := range sv.MapKeys() { + dk := reflect.New(dt.Key()).Elem() + if err := c.convert(sk, dk, scope); err != nil { + return err + } + dkv := reflect.New(dt.Elem()).Elem() + scope.setKeys(sk.Interface(), dk.Interface()) + // TODO: sv.MapIndex(sk) may return a value with CanAddr() == false, + // because a map[string]struct{} does not allow a pointer reference. + // Calling a custom conversion function defined for the map value + // will panic. Example is PodInfo map[string]ContainerStatus. + if err := c.convert(sv.MapIndex(sk), dkv, scope); err != nil { + return err + } + dv.SetMapIndex(dk, dkv) + } + case reflect.Interface: + if sv.IsNil() { + // Don't copy a nil interface! + dv.Set(reflect.Zero(dt)) + return nil + } + tmpdv := reflect.New(sv.Elem().Type()).Elem() + if err := c.convert(sv.Elem(), tmpdv, scope); err != nil { + return err + } + dv.Set(reflect.ValueOf(tmpdv.Interface())) + return nil + default: + return scope.errorf("couldn't copy '%v' into '%v'; didn't understand types", st, dt) + } + return nil +} + +var stringType = reflect.TypeOf("") + +func toKVValue(v reflect.Value) kvValue { + switch v.Kind() { + case reflect.Struct: + return structAdaptor(v) + case reflect.Map: + if v.Type().Key().AssignableTo(stringType) { + return stringMapAdaptor(v) + } + } + + return nil +} + +// kvValue lets us write the same conversion logic to work with both maps +// and structs. Only maps with string keys make sense for this. +type kvValue interface { + // returns all keys, as a []string. + keys() []string + // Will just return "" for maps. + tagOf(key string) reflect.StructTag + // Will return the zero Value if the key doesn't exist. + value(key string) reflect.Value + // Maps require explicit setting-- will do nothing for structs. + // Returns false on failure. + confirmSet(key string, v reflect.Value) bool +} + +type stringMapAdaptor reflect.Value + +func (a stringMapAdaptor) len() int { + return reflect.Value(a).Len() +} + +func (a stringMapAdaptor) keys() []string { + v := reflect.Value(a) + keys := make([]string, v.Len()) + for i, v := range v.MapKeys() { + if v.IsNil() { + continue + } + switch t := v.Interface().(type) { + case string: + keys[i] = t + } + } + return keys +} + +func (a stringMapAdaptor) tagOf(key string) reflect.StructTag { + return "" +} + +func (a stringMapAdaptor) value(key string) reflect.Value { + return reflect.Value(a).MapIndex(reflect.ValueOf(key)) +} + +func (a stringMapAdaptor) confirmSet(key string, v reflect.Value) bool { + return true +} + +type structAdaptor reflect.Value + +func (a structAdaptor) len() int { + v := reflect.Value(a) + return v.Type().NumField() +} + +func (a structAdaptor) keys() []string { + v := reflect.Value(a) + t := v.Type() + keys := make([]string, t.NumField()) + for i := range keys { + keys[i] = t.Field(i).Name + } + return keys +} + +func (a structAdaptor) tagOf(key string) reflect.StructTag { + v := reflect.Value(a) + field, ok := v.Type().FieldByName(key) + if ok { + return field.Tag + } + return "" +} + +func (a structAdaptor) value(key string) reflect.Value { + v := reflect.Value(a) + return v.FieldByName(key) +} + +func (a structAdaptor) confirmSet(key string, v reflect.Value) bool { + return true +} + +// convertKV can convert things that consist of key/value pairs, like structs +// and some maps. +func (c *Converter) convertKV(skv, dkv kvValue, scope *scope) error { + if skv == nil || dkv == nil { + // TODO: add keys to stack to support really understandable error messages. + return fmt.Errorf("Unable to convert %#v to %#v", skv, dkv) + } + + lister := dkv + if scope.flags.IsSet(SourceToDest) { + lister = skv + } + + var mapping FieldMappingFunc + if scope.meta != nil && scope.meta.KeyNameMapping != nil { + mapping = scope.meta.KeyNameMapping + } + + for _, key := range lister.keys() { + if found, err := c.checkField(key, skv, dkv, scope); found { + if err != nil { + return err + } + continue + } + stag := skv.tagOf(key) + dtag := dkv.tagOf(key) + skey := key + dkey := key + if mapping != nil { + skey, dkey = scope.meta.KeyNameMapping(key, stag, dtag) + } + + df := dkv.value(dkey) + sf := skv.value(skey) + if !df.IsValid() || !sf.IsValid() { + switch { + case scope.flags.IsSet(IgnoreMissingFields): + // No error. + case scope.flags.IsSet(SourceToDest): + return scope.errorf("%v not present in dest", dkey) + default: + return scope.errorf("%v not present in src", skey) + } + continue + } + scope.srcStack.top().key = skey + scope.srcStack.top().tag = stag + scope.destStack.top().key = dkey + scope.destStack.top().tag = dtag + if err := c.convert(sf, df, scope); err != nil { + return err + } + } + return nil +} + +// checkField returns true if the field name matches any of the struct +// field copying rules. The error should be ignored if it returns false. +func (c *Converter) checkField(fieldName string, skv, dkv kvValue, scope *scope) (bool, error) { + replacementMade := false + if scope.flags.IsSet(DestFromSource) { + df := dkv.value(fieldName) + if !df.IsValid() { + return false, nil + } + destKey := typeNamePair{df.Type(), fieldName} + // Check each of the potential source (type, name) pairs to see if they're + // present in sv. + for _, potentialSourceKey := range c.structFieldSources[destKey] { + sf := skv.value(potentialSourceKey.fieldName) + if !sf.IsValid() { + continue + } + if sf.Type() == potentialSourceKey.fieldType { + // Both the source's name and type matched, so copy. + scope.srcStack.top().key = potentialSourceKey.fieldName + scope.destStack.top().key = fieldName + if err := c.convert(sf, df, scope); err != nil { + return true, err + } + dkv.confirmSet(fieldName, df) + replacementMade = true + } + } + return replacementMade, nil + } + + sf := skv.value(fieldName) + if !sf.IsValid() { + return false, nil + } + srcKey := typeNamePair{sf.Type(), fieldName} + // Check each of the potential dest (type, name) pairs to see if they're + // present in dv. + for _, potentialDestKey := range c.structFieldDests[srcKey] { + df := dkv.value(potentialDestKey.fieldName) + if !df.IsValid() { + continue + } + if df.Type() == potentialDestKey.fieldType { + // Both the dest's name and type matched, so copy. + scope.srcStack.top().key = fieldName + scope.destStack.top().key = potentialDestKey.fieldName + if err := c.convert(sf, df, scope); err != nil { + return true, err + } + dkv.confirmSet(potentialDestKey.fieldName, df) + replacementMade = true + } + } + return replacementMade, nil +} diff --git a/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/deep_copy_generated.go b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/deep_copy_generated.go new file mode 100644 index 0000000000..717feaf18f --- /dev/null +++ b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/deep_copy_generated.go @@ -0,0 +1,185 @@ +// +build !ignore_autogenerated + +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// This file was autogenerated by deepcopy-gen. Do not edit it manually! + +package conversion + +import ( + forked_reflect "k8s.io/kubernetes/third_party/forked/reflect" + reflect "reflect" +) + +func DeepCopy_conversion_Cloner(in Cloner, out *Cloner, c *Cloner) error { + if in.deepCopyFuncs != nil { + in, out := in.deepCopyFuncs, &out.deepCopyFuncs + *out = make(map[reflect.Type]reflect.Value) + for range in { + // FIXME: Copying unassignable keys unsupported reflect.Type + } + } else { + out.deepCopyFuncs = nil + } + if in.generatedDeepCopyFuncs != nil { + in, out := in.generatedDeepCopyFuncs, &out.generatedDeepCopyFuncs + *out = make(map[reflect.Type]reflect.Value) + for range in { + // FIXME: Copying unassignable keys unsupported reflect.Type + } + } else { + out.generatedDeepCopyFuncs = nil + } + return nil +} + +func DeepCopy_conversion_ConversionFuncs(in ConversionFuncs, out *ConversionFuncs, c *Cloner) error { + if in.fns != nil { + in, out := in.fns, &out.fns + *out = make(map[typePair]reflect.Value) + for range in { + // FIXME: Copying unassignable keys unsupported typePair + } + } else { + out.fns = nil + } + return nil +} + +func DeepCopy_conversion_Converter(in Converter, out *Converter, c *Cloner) error { + if err := DeepCopy_conversion_ConversionFuncs(in.conversionFuncs, &out.conversionFuncs, c); err != nil { + return err + } + if err := DeepCopy_conversion_ConversionFuncs(in.generatedConversionFuncs, &out.generatedConversionFuncs, c); err != nil { + return err + } + if in.genericConversions != nil { + in, out := in.genericConversions, &out.genericConversions + *out = make([]GenericConversionFunc, len(in)) + for i := range in { + if newVal, err := c.DeepCopy(in[i]); err != nil { + return err + } else { + (*out)[i] = newVal.(GenericConversionFunc) + } + } + } else { + out.genericConversions = nil + } + if in.ignoredConversions != nil { + in, out := in.ignoredConversions, &out.ignoredConversions + *out = make(map[typePair]struct{}) + for range in { + // FIXME: Copying unassignable keys unsupported typePair + } + } else { + out.ignoredConversions = nil + } + if in.structFieldDests != nil { + in, out := in.structFieldDests, &out.structFieldDests + *out = make(map[typeNamePair][]typeNamePair) + for range in { + // FIXME: Copying unassignable keys unsupported typeNamePair + } + } else { + out.structFieldDests = nil + } + if in.structFieldSources != nil { + in, out := in.structFieldSources, &out.structFieldSources + *out = make(map[typeNamePair][]typeNamePair) + for range in { + // FIXME: Copying unassignable keys unsupported typeNamePair + } + } else { + out.structFieldSources = nil + } + if in.defaultingFuncs != nil { + in, out := in.defaultingFuncs, &out.defaultingFuncs + *out = make(map[reflect.Type]reflect.Value) + for range in { + // FIXME: Copying unassignable keys unsupported reflect.Type + } + } else { + out.defaultingFuncs = nil + } + if in.defaultingInterfaces != nil { + in, out := in.defaultingInterfaces, &out.defaultingInterfaces + *out = make(map[reflect.Type]interface{}) + for range in { + // FIXME: Copying unassignable keys unsupported reflect.Type + } + } else { + out.defaultingInterfaces = nil + } + if in.inputFieldMappingFuncs != nil { + in, out := in.inputFieldMappingFuncs, &out.inputFieldMappingFuncs + *out = make(map[reflect.Type]FieldMappingFunc) + for range in { + // FIXME: Copying unassignable keys unsupported reflect.Type + } + } else { + out.inputFieldMappingFuncs = nil + } + if in.inputDefaultFlags != nil { + in, out := in.inputDefaultFlags, &out.inputDefaultFlags + *out = make(map[reflect.Type]FieldMatchingFlags) + for range in { + // FIXME: Copying unassignable keys unsupported reflect.Type + } + } else { + out.inputDefaultFlags = nil + } + if in.Debug == nil { + out.Debug = nil + } else if newVal, err := c.DeepCopy(in.Debug); err != nil { + return err + } else { + out.Debug = newVal.(DebugLogger) + } + if in.nameFunc == nil { + out.nameFunc = nil + } else if newVal, err := c.DeepCopy(in.nameFunc); err != nil { + return err + } else { + out.nameFunc = newVal.(func(reflect.Type) string) + } + return nil +} + +func DeepCopy_conversion_Equalities(in Equalities, out *Equalities, c *Cloner) error { + if in.Equalities != nil { + in, out := in.Equalities, &out.Equalities + *out = make(forked_reflect.Equalities) + for range in { + // FIXME: Copying unassignable keys unsupported reflect.Type + } + } else { + out.Equalities = nil + } + return nil +} + +func DeepCopy_conversion_Meta(in Meta, out *Meta, c *Cloner) error { + if in.KeyNameMapping == nil { + out.KeyNameMapping = nil + } else if newVal, err := c.DeepCopy(in.KeyNameMapping); err != nil { + return err + } else { + out.KeyNameMapping = newVal.(FieldMappingFunc) + } + return nil +} diff --git a/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/deep_equal.go b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/deep_equal.go new file mode 100644 index 0000000000..7c3ed7cda1 --- /dev/null +++ b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/deep_equal.go @@ -0,0 +1,36 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package conversion + +import ( + "k8s.io/kubernetes/third_party/forked/reflect" +) + +// The code for this type must be located in third_party, since it forks from +// go std lib. But for convenience, we expose the type here, too. +type Equalities struct { + reflect.Equalities +} + +// For convenience, panics on errrors +func EqualitiesOrDie(funcs ...interface{}) Equalities { + e := Equalities{reflect.Equalities{}} + if err := e.AddFuncs(funcs...); err != nil { + panic(err) + } + return e +} diff --git a/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/doc.go b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/doc.go new file mode 100644 index 0000000000..3ef2eaba45 --- /dev/null +++ b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/doc.go @@ -0,0 +1,24 @@ +/* +Copyright 2014 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package conversion provides go object versioning. +// +// Specifically, conversion provides a way for you to define multiple versions +// of the same object. You may write functions which implement conversion logic, +// but for the fields which did not change, copying is automated. This makes it +// easy to modify the structures you use in memory without affecting the format +// you store on disk or respond to in your external API calls. +package conversion diff --git a/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/helper.go b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/helper.go new file mode 100644 index 0000000000..39f7826595 --- /dev/null +++ b/Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/helper.go @@ -0,0 +1,39 @@ +/* +Copyright 2014 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package conversion + +import ( + "fmt" + "reflect" +) + +// EnforcePtr ensures that obj is a pointer of some sort. Returns a reflect.Value +// of the dereferenced pointer, ensuring that it is settable/addressable. +// Returns an error if this is not possible. +func EnforcePtr(obj interface{}) (reflect.Value, error) { + v := reflect.ValueOf(obj) + if v.Kind() != reflect.Ptr { + if v.Kind() == reflect.Invalid { + return reflect.Value{}, fmt.Errorf("expected pointer, but got invalid kind") + } + return reflect.Value{}, fmt.Errorf("expected pointer, but got %v type", v.Type()) + } + if v.IsNil() { + return reflect.Value{}, fmt.Errorf("expected pointer, but got nil") + } + return v.Elem(), nil +} diff --git a/Godeps/_workspace/src/k8s.io/kubernetes/third_party/forked/reflect/LICENSE b/Godeps/_workspace/src/k8s.io/kubernetes/third_party/forked/reflect/LICENSE new file mode 100644 index 0000000000..7448756763 --- /dev/null +++ b/Godeps/_workspace/src/k8s.io/kubernetes/third_party/forked/reflect/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2012 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. diff --git a/Godeps/_workspace/src/k8s.io/kubernetes/third_party/forked/reflect/deep_equal.go b/Godeps/_workspace/src/k8s.io/kubernetes/third_party/forked/reflect/deep_equal.go new file mode 100644 index 0000000000..9e45dbe1d2 --- /dev/null +++ b/Godeps/_workspace/src/k8s.io/kubernetes/third_party/forked/reflect/deep_equal.go @@ -0,0 +1,388 @@ +// 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. + +// Package reflect is a fork of go's standard library reflection package, which +// allows for deep equal with equality functions defined. +package reflect + +import ( + "fmt" + "reflect" + "strings" +) + +// Equalities is a map from type to a function comparing two values of +// that type. +type Equalities map[reflect.Type]reflect.Value + +// For convenience, panics on errrors +func EqualitiesOrDie(funcs ...interface{}) Equalities { + e := Equalities{} + if err := e.AddFuncs(funcs...); err != nil { + panic(err) + } + return e +} + +// AddFuncs is a shortcut for multiple calls to AddFunc. +func (e Equalities) AddFuncs(funcs ...interface{}) error { + for _, f := range funcs { + if err := e.AddFunc(f); err != nil { + return err + } + } + return nil +} + +// AddFunc uses func as an equality function: it must take +// two parameters of the same type, and return a boolean. +func (e Equalities) AddFunc(eqFunc interface{}) error { + fv := reflect.ValueOf(eqFunc) + ft := fv.Type() + if ft.Kind() != reflect.Func { + return fmt.Errorf("expected func, got: %v", ft) + } + if ft.NumIn() != 2 { + return fmt.Errorf("expected three 'in' params, got: %v", ft) + } + if ft.NumOut() != 1 { + return fmt.Errorf("expected one 'out' param, got: %v", ft) + } + if ft.In(0) != ft.In(1) { + return fmt.Errorf("expected arg 1 and 2 to have same type, but got %v", ft) + } + var forReturnType bool + boolType := reflect.TypeOf(forReturnType) + if ft.Out(0) != boolType { + return fmt.Errorf("expected bool return, got: %v", ft) + } + e[ft.In(0)] = fv + return nil +} + +// Below here is forked from go's reflect/deepequal.go + +// During deepValueEqual, must keep track of checks that are +// in progress. The comparison algorithm assumes that all +// checks in progress are true when it reencounters them. +// Visited comparisons are stored in a map indexed by visit. +type visit struct { + a1 uintptr + a2 uintptr + typ reflect.Type +} + +// unexportedTypePanic is thrown when you use this DeepEqual on something that has an +// unexported type. It indicates a programmer error, so should not occur at runtime, +// which is why it's not public and thus impossible to catch. +type unexportedTypePanic []reflect.Type + +func (u unexportedTypePanic) Error() string { return u.String() } +func (u unexportedTypePanic) String() string { + strs := make([]string, len(u)) + for i, t := range u { + strs[i] = fmt.Sprintf("%v", t) + } + return "an unexported field was encountered, nested like this: " + strings.Join(strs, " -> ") +} + +func makeUsefulPanic(v reflect.Value) { + if x := recover(); x != nil { + if u, ok := x.(unexportedTypePanic); ok { + u = append(unexportedTypePanic{v.Type()}, u...) + x = u + } + panic(x) + } +} + +// Tests for deep equality using reflected types. The map argument tracks +// comparisons that have already been seen, which allows short circuiting on +// recursive types. +func (e Equalities) deepValueEqual(v1, v2 reflect.Value, visited map[visit]bool, depth int) bool { + defer makeUsefulPanic(v1) + + if !v1.IsValid() || !v2.IsValid() { + return v1.IsValid() == v2.IsValid() + } + if v1.Type() != v2.Type() { + return false + } + if fv, ok := e[v1.Type()]; ok { + return fv.Call([]reflect.Value{v1, v2})[0].Bool() + } + + hard := func(k reflect.Kind) bool { + switch k { + case reflect.Array, reflect.Map, reflect.Slice, reflect.Struct: + return true + } + return false + } + + if v1.CanAddr() && v2.CanAddr() && hard(v1.Kind()) { + addr1 := v1.UnsafeAddr() + addr2 := v2.UnsafeAddr() + if addr1 > addr2 { + // Canonicalize order to reduce number of entries in visited. + addr1, addr2 = addr2, addr1 + } + + // Short circuit if references are identical ... + if addr1 == addr2 { + return true + } + + // ... or already seen + typ := v1.Type() + v := visit{addr1, addr2, typ} + if visited[v] { + return true + } + + // Remember for later. + visited[v] = true + } + + switch v1.Kind() { + case reflect.Array: + // We don't need to check length here because length is part of + // an array's type, which has already been filtered for. + for i := 0; i < v1.Len(); i++ { + if !e.deepValueEqual(v1.Index(i), v2.Index(i), visited, depth+1) { + return false + } + } + return true + case reflect.Slice: + if (v1.IsNil() || v1.Len() == 0) != (v2.IsNil() || v2.Len() == 0) { + return false + } + if v1.IsNil() || v1.Len() == 0 { + return true + } + if v1.Len() != v2.Len() { + return false + } + if v1.Pointer() == v2.Pointer() { + return true + } + for i := 0; i < v1.Len(); i++ { + if !e.deepValueEqual(v1.Index(i), v2.Index(i), visited, depth+1) { + return false + } + } + return true + case reflect.Interface: + if v1.IsNil() || v2.IsNil() { + return v1.IsNil() == v2.IsNil() + } + return e.deepValueEqual(v1.Elem(), v2.Elem(), visited, depth+1) + case reflect.Ptr: + return e.deepValueEqual(v1.Elem(), v2.Elem(), visited, depth+1) + case reflect.Struct: + for i, n := 0, v1.NumField(); i < n; i++ { + if !e.deepValueEqual(v1.Field(i), v2.Field(i), visited, depth+1) { + return false + } + } + return true + case reflect.Map: + if (v1.IsNil() || v1.Len() == 0) != (v2.IsNil() || v2.Len() == 0) { + return false + } + if v1.IsNil() || v1.Len() == 0 { + return true + } + if v1.Len() != v2.Len() { + return false + } + if v1.Pointer() == v2.Pointer() { + return true + } + for _, k := range v1.MapKeys() { + if !e.deepValueEqual(v1.MapIndex(k), v2.MapIndex(k), visited, depth+1) { + return false + } + } + return true + case reflect.Func: + if v1.IsNil() && v2.IsNil() { + return true + } + // Can't do better than this: + return false + default: + // Normal equality suffices + if !v1.CanInterface() || !v2.CanInterface() { + panic(unexportedTypePanic{}) + } + return v1.Interface() == v2.Interface() + } +} + +// DeepEqual is like reflect.DeepEqual, but focused on semantic equality +// instead of memory equality. +// +// It will use e's equality functions if it finds types that match. +// +// An empty slice *is* equal to a nil slice for our purposes; same for maps. +// +// Unexported field members cannot be compared and will cause an imformative panic; you must add an Equality +// function for these types. +func (e Equalities) DeepEqual(a1, a2 interface{}) bool { + if a1 == nil || a2 == nil { + return a1 == a2 + } + v1 := reflect.ValueOf(a1) + v2 := reflect.ValueOf(a2) + if v1.Type() != v2.Type() { + return false + } + return e.deepValueEqual(v1, v2, make(map[visit]bool), 0) +} + +func (e Equalities) deepValueDerive(v1, v2 reflect.Value, visited map[visit]bool, depth int) bool { + defer makeUsefulPanic(v1) + + if !v1.IsValid() || !v2.IsValid() { + return v1.IsValid() == v2.IsValid() + } + if v1.Type() != v2.Type() { + return false + } + if fv, ok := e[v1.Type()]; ok { + return fv.Call([]reflect.Value{v1, v2})[0].Bool() + } + + hard := func(k reflect.Kind) bool { + switch k { + case reflect.Array, reflect.Map, reflect.Slice, reflect.Struct: + return true + } + return false + } + + if v1.CanAddr() && v2.CanAddr() && hard(v1.Kind()) { + addr1 := v1.UnsafeAddr() + addr2 := v2.UnsafeAddr() + if addr1 > addr2 { + // Canonicalize order to reduce number of entries in visited. + addr1, addr2 = addr2, addr1 + } + + // Short circuit if references are identical ... + if addr1 == addr2 { + return true + } + + // ... or already seen + typ := v1.Type() + v := visit{addr1, addr2, typ} + if visited[v] { + return true + } + + // Remember for later. + visited[v] = true + } + + switch v1.Kind() { + case reflect.Array: + // We don't need to check length here because length is part of + // an array's type, which has already been filtered for. + for i := 0; i < v1.Len(); i++ { + if !e.deepValueDerive(v1.Index(i), v2.Index(i), visited, depth+1) { + return false + } + } + return true + case reflect.Slice: + if v1.IsNil() || v1.Len() == 0 { + return true + } + if v1.Len() > v2.Len() { + return false + } + if v1.Pointer() == v2.Pointer() { + return true + } + for i := 0; i < v1.Len(); i++ { + if !e.deepValueDerive(v1.Index(i), v2.Index(i), visited, depth+1) { + return false + } + } + return true + case reflect.String: + if v1.Len() == 0 { + return true + } + if v1.Len() > v2.Len() { + return false + } + return v1.String() == v2.String() + case reflect.Interface: + if v1.IsNil() { + return true + } + return e.deepValueDerive(v1.Elem(), v2.Elem(), visited, depth+1) + case reflect.Ptr: + if v1.IsNil() { + return true + } + return e.deepValueDerive(v1.Elem(), v2.Elem(), visited, depth+1) + case reflect.Struct: + for i, n := 0, v1.NumField(); i < n; i++ { + if !e.deepValueDerive(v1.Field(i), v2.Field(i), visited, depth+1) { + return false + } + } + return true + case reflect.Map: + if v1.IsNil() || v1.Len() == 0 { + return true + } + if v1.Len() > v2.Len() { + return false + } + if v1.Pointer() == v2.Pointer() { + return true + } + for _, k := range v1.MapKeys() { + if !e.deepValueDerive(v1.MapIndex(k), v2.MapIndex(k), visited, depth+1) { + return false + } + } + return true + case reflect.Func: + if v1.IsNil() && v2.IsNil() { + return true + } + // Can't do better than this: + return false + default: + // Normal equality suffices + if !v1.CanInterface() || !v2.CanInterface() { + panic(unexportedTypePanic{}) + } + return v1.Interface() == v2.Interface() + } +} + +// DeepDerivative is similar to DeepEqual except that unset fields in a1 are +// ignored (not compared). This allows us to focus on the fields that matter to +// the semantic comparison. +// +// The unset fields include a nil pointer and an empty string. +func (e Equalities) DeepDerivative(a1, a2 interface{}) bool { + if a1 == nil { + return true + } + v1 := reflect.ValueOf(a1) + v2 := reflect.ValueOf(a2) + if v1.Type() != v2.Type() { + return false + } + return e.deepValueDerive(v1, v2, make(map[visit]bool), 0) +} diff --git a/Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/LICENSE b/Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/LICENSE deleted file mode 100644 index efa1aa1896..0000000000 --- a/Godeps/_workspace/src/speter.net/go/exp/math/dec/inf/LICENSE +++ /dev/null @@ -1,57 +0,0 @@ -Copyright (c) 2012 Péter Surányi. 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. - -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. - ----------------------------------------------------------------------- -Portions of inf.Dec's source code have been derived from Go and are -covered by the following license: ----------------------------------------------------------------------- - -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. From 2d23989c9b3866265577bc817409a4636876e68c Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Thu, 26 May 2016 11:32:51 +0200 Subject: [PATCH 0316/1304] deps: gogo/protobuf: use v0.2 Motivation is to vendor only tagged dependencies. --- Godeps/Godeps.json | 4 +-- .../github.com/gogo/protobuf/proto/encode.go | 26 ++++++----------- .../github.com/gogo/protobuf/proto/equal.go | 28 +++++++++++++------ .../gogo/protobuf/proto/extensions.go | 3 +- .../src/github.com/gogo/protobuf/proto/lib.go | 15 ++++++++-- .../gogo/protobuf/proto/properties.go | 16 ++++++++--- .../github.com/gogo/protobuf/proto/text.go | 4 +-- .../gogo/protobuf/proto/text_parser.go | 24 ++++++++++------ 8 files changed, 73 insertions(+), 47 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index f671e155bd..eac3f2f9b1 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -407,8 +407,8 @@ }, { "ImportPath": "github.com/gogo/protobuf/proto", - "Comment": "v0.1-125-g82d16f7", - "Rev": "82d16f734d6d871204a3feb1a73cb220cc92574c" + "Comment": "v0.2", + "Rev": "4168943e65a2802828518e95310aeeed6d84c4e5" }, { "ImportPath": "github.com/golang/protobuf/proto", diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/encode.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/encode.go index 7321e1aae1..231b07401a 100644 --- a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/encode.go +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/encode.go @@ -105,6 +105,11 @@ func (p *Buffer) EncodeVarint(x uint64) error { return nil } +// SizeVarint returns the varint encoding size of an integer. +func SizeVarint(x uint64) int { + return sizeVarint(x) +} + func sizeVarint(x uint64) (n int) { for { n++ @@ -1248,24 +1253,9 @@ func size_struct(prop *StructProperties, base structPointer) (n int) { } // Factor in any oneof fields. - // TODO: This could be faster and use less reflection. - if prop.oneofMarshaler != nil { - sv := reflect.ValueOf(structPointer_Interface(base, prop.stype)).Elem() - for i := 0; i < prop.stype.NumField(); i++ { - fv := sv.Field(i) - if fv.Kind() != reflect.Interface || fv.IsNil() { - continue - } - if prop.stype.Field(i).Tag.Get("protobuf_oneof") == "" { - continue - } - spv := fv.Elem() // interface -> *T - sv := spv.Elem() // *T -> T - sf := sv.Type().Field(0) // StructField inside T - var prop Properties - prop.Init(sf.Type, "whatever", sf.Tag.Get("protobuf"), &sf) - n += prop.size(&prop, toStructPointer(spv)) - } + if prop.oneofSizer != nil { + m := structPointer_Interface(base, prop.stype).(Message) + n += prop.oneofSizer(m) } return diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/equal.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/equal.go index cc3f2c95a7..f5db1def3c 100644 --- a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/equal.go +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/equal.go @@ -50,7 +50,9 @@ Equality is defined in this way: are equal, and extensions sets are equal. - Two set scalar fields are equal iff their values are equal. If the fields are of a floating-point type, remember that - NaN != x for all x, including NaN. + NaN != x for all x, including NaN. If the message is defined + in a proto3 .proto file, fields are not "set"; specifically, + zero length proto3 "bytes" fields are equal (nil == {}). - Two repeated fields are equal iff their lengths are the same, and their corresponding elements are equal (a "bytes" field, although represented by []byte, is not a repeated field) @@ -88,6 +90,7 @@ func Equal(a, b Message) bool { // v1 and v2 are known to have the same type. func equalStruct(v1, v2 reflect.Value) bool { + sprop := GetProperties(v1.Type()) for i := 0; i < v1.NumField(); i++ { f := v1.Type().Field(i) if strings.HasPrefix(f.Name, "XXX_") { @@ -113,7 +116,7 @@ func equalStruct(v1, v2 reflect.Value) bool { } f1, f2 = f1.Elem(), f2.Elem() } - if !equalAny(f1, f2) { + if !equalAny(f1, f2, sprop.Prop[i]) { return false } } @@ -140,7 +143,8 @@ func equalStruct(v1, v2 reflect.Value) bool { } // v1 and v2 are known to have the same type. -func equalAny(v1, v2 reflect.Value) bool { +// prop may be nil. +func equalAny(v1, v2 reflect.Value, prop *Properties) bool { if v1.Type() == protoMessageType { m1, _ := v1.Interface().(Message) m2, _ := v2.Interface().(Message) @@ -163,7 +167,7 @@ func equalAny(v1, v2 reflect.Value) bool { if e1.Type() != e2.Type() { return false } - return equalAny(e1, e2) + return equalAny(e1, e2, nil) case reflect.Map: if v1.Len() != v2.Len() { return false @@ -174,16 +178,22 @@ func equalAny(v1, v2 reflect.Value) bool { // This key was not found in the second map. return false } - if !equalAny(v1.MapIndex(key), val2) { + if !equalAny(v1.MapIndex(key), val2, nil) { return false } } return true case reflect.Ptr: - return equalAny(v1.Elem(), v2.Elem()) + return equalAny(v1.Elem(), v2.Elem(), prop) case reflect.Slice: if v1.Type().Elem().Kind() == reflect.Uint8 { // short circuit: []byte + + // Edge case: if this is in a proto3 message, a zero length + // bytes field is considered the zero value. + if prop != nil && prop.proto3 && v1.Len() == 0 && v2.Len() == 0 { + return true + } if v1.IsNil() != v2.IsNil() { return false } @@ -194,7 +204,7 @@ func equalAny(v1, v2 reflect.Value) bool { return false } for i := 0; i < v1.Len(); i++ { - if !equalAny(v1.Index(i), v2.Index(i)) { + if !equalAny(v1.Index(i), v2.Index(i), prop) { return false } } @@ -229,7 +239,7 @@ func equalExtensions(base reflect.Type, em1, em2 map[int32]Extension) bool { if m1 != nil && m2 != nil { // Both are unencoded. - if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2)) { + if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2), nil) { return false } continue @@ -257,7 +267,7 @@ func equalExtensions(base reflect.Type, em1, em2 map[int32]Extension) bool { log.Printf("proto: badly encoded extension %d of %v: %v", extNum, base, err) return false } - if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2)) { + if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2), nil) { return false } } diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/extensions.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/extensions.go index 9a6374fdbd..6180347e39 100644 --- a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/extensions.go +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/extensions.go @@ -403,7 +403,6 @@ func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) { o := NewBuffer(b) t := reflect.TypeOf(extension.ExtensionType) - rep := extension.repeated() props := extensionProperties(extension) @@ -425,7 +424,7 @@ func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) { return nil, err } - if !rep || o.index >= len(o.buf) { + if o.index >= len(o.buf) { break } } diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/lib.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/lib.go index 8ffa91a3e9..2e35ae2d2a 100644 --- a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/lib.go +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/lib.go @@ -70,6 +70,12 @@ for a protocol buffer variable v: with distinguished wrapper types for each possible field value. - Marshal and Unmarshal are functions to encode and decode the wire format. +When the .proto file specifies `syntax="proto3"`, there are some differences: + + - Non-repeated fields of non-message type are values instead of pointers. + - Getters are only generated for message and oneof fields. + - Enum types do not get an Enum method. + The simplest way to describe this is to see an example. Given file test.proto, containing @@ -229,6 +235,7 @@ To create and play with a Test object: test := &pb.Test{ Label: proto.String("hello"), Type: proto.Int32(17), + Reps: []int64{1, 2, 3}, Optionalgroup: &pb.Test_OptionalGroup{ RequiredField: proto.String("good bye"), }, @@ -441,7 +448,7 @@ func (p *Buffer) DebugPrint(s string, b []byte) { var u uint64 obuf := p.buf - index := p.index + sindex := p.index p.buf = b p.index = 0 depth := 0 @@ -536,7 +543,7 @@ out: fmt.Printf("\n") p.buf = obuf - p.index = index + p.index = sindex } // SetDefaults sets unset protocol buffer fields to their default values. @@ -881,3 +888,7 @@ func isProto3Zero(v reflect.Value) bool { } return false } + +// ProtoPackageIsVersion1 is referenced from generated protocol buffer files +// to assert that that code is compatible with this version of the proto package. +const GoGoProtoPackageIsVersion1 = true diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/properties.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/properties.go index 4711057e2b..5e6a0b3ba7 100644 --- a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/properties.go +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/properties.go @@ -96,6 +96,9 @@ type oneofMarshaler func(Message, *Buffer) error // A oneofUnmarshaler does the unmarshaling for a oneof field in a message. type oneofUnmarshaler func(Message, int, int, *Buffer) (bool, error) +// A oneofSizer does the sizing for all oneof fields in a message. +type oneofSizer func(Message) int + // tagMap is an optimization over map[int]int for typical protocol buffer // use-cases. Encoded protocol buffers are often in tag order with small tag // numbers. @@ -147,6 +150,7 @@ type StructProperties struct { oneofMarshaler oneofMarshaler oneofUnmarshaler oneofUnmarshaler + oneofSizer oneofSizer stype reflect.Type // OneofTypes contains information about the oneof fields in this message. @@ -174,6 +178,7 @@ func (sp *StructProperties) Swap(i, j int) { sp.order[i], sp.order[j] = sp.order type Properties struct { Name string // name of the field, for error messages OrigName string // original name before protocol compiler (always set) + JSONName string // name to use for JSON; determined by protoc Wire string WireType int Tag int @@ -233,8 +238,9 @@ func (p *Properties) String() string { if p.Packed { s += ",packed" } - if p.OrigName != p.Name { - s += ",name=" + p.OrigName + s += ",name=" + p.OrigName + if p.JSONName != p.OrigName { + s += ",json=" + p.JSONName } if p.proto3 { s += ",proto3" @@ -314,6 +320,8 @@ func (p *Properties) Parse(s string) { p.Packed = true case strings.HasPrefix(f, "name="): p.OrigName = f[5:] + case strings.HasPrefix(f, "json="): + p.JSONName = f[5:] case strings.HasPrefix(f, "enum="): p.Enum = f[5:] case f == "proto3": @@ -784,11 +792,11 @@ func getPropertiesLocked(t reflect.Type) *StructProperties { sort.Sort(prop) type oneofMessage interface { - XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), []interface{}) + XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{}) } if om, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); isOneofMessage && ok { var oots []interface{} - prop.oneofMarshaler, prop.oneofUnmarshaler, oots = om.XXX_OneofFuncs() + prop.oneofMarshaler, prop.oneofUnmarshaler, prop.oneofSizer, oots = om.XXX_OneofFuncs() prop.stype = t // Interpret oneof metadata. diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/text.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/text.go index 7c9ae90f95..e2b99b122d 100644 --- a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/text.go +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/text.go @@ -573,12 +573,12 @@ func writeUnknownStruct(w *textWriter, data []byte) (err error) { return ferr } if wire != WireStartGroup { - if err := w.WriteByte(':'); err != nil { + if err = w.WriteByte(':'); err != nil { return err } } if !w.compact || wire == WireStartGroup { - if err := w.WriteByte(' '); err != nil { + if err = w.WriteByte(' '); err != nil { return err } } diff --git a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_parser.go b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_parser.go index f3909695ed..61b4bc8cc8 100644 --- a/Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_parser.go +++ b/Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_parser.go @@ -124,6 +124,14 @@ func isWhitespace(c byte) bool { return false } +func isQuote(c byte) bool { + switch c { + case '"', '\'': + return true + } + return false +} + func (p *textParser) skipWhitespace() { i := 0 for i < len(p.s) && (isWhitespace(p.s[i]) || p.s[i] == '#') { @@ -338,13 +346,13 @@ func (p *textParser) next() *token { p.advance() if p.done { p.cur.value = "" - } else if len(p.cur.value) > 0 && p.cur.value[0] == '"' { + } else if len(p.cur.value) > 0 && isQuote(p.cur.value[0]) { // Look for multiple quoted strings separated by whitespace, // and concatenate them. cat := p.cur for { p.skipWhitespace() - if p.done || p.s[0] != '"' { + if p.done || !isQuote(p.s[0]) { break } p.advance() @@ -724,15 +732,15 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) error { if err != nil { return err } - tok := p.next() - if tok.err != nil { - return tok.err + ntok := p.next() + if ntok.err != nil { + return ntok.err } - if tok.value == "]" { + if ntok.value == "]" { break } - if tok.value != "," { - return p.errorf("Expected ']' or ',' found %q", tok.value) + if ntok.value != "," { + return p.errorf("Expected ']' or ',' found %q", ntok.value) } } return nil From 130ae758570da1b5c0ae93ce15b97af7d1498c3d Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Thu, 26 May 2016 13:06:52 +0200 Subject: [PATCH 0317/1304] deps: appc/spec: 0.8.3 -> v0.8.4 --- Godeps/Godeps.json | 46 +++++++++---------- .../appc/spec/ace/image_manifest_main.json.in | 4 +- .../spec/ace/image_manifest_sidekick.json.in | 4 +- .../spec/schema/types/isolator_resources.go | 8 ++-- .../github.com/appc/spec/schema/version.go | 2 +- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index eac3f2f9b1..2effffa85b 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,7 +1,7 @@ { "ImportPath": "github.com/coreos/rkt", "GoVersion": "go1.5", - "GodepVersion": "v71", + "GodepVersion": "v70", "Packages": [ "./...", "github.com/appc/spec/actool", @@ -163,58 +163,58 @@ }, { "ImportPath": "github.com/appc/spec/ace", - "Comment": "v0.8.3", - "Rev": "db96f94ae6b227fe4d8288527ead8927181620f6" + "Comment": "v0.8.4", + "Rev": "f82c741e743001237821b5e0bb9a8ebd324d3117" }, { "ImportPath": "github.com/appc/spec/aci", - "Comment": "v0.8.3", - "Rev": "db96f94ae6b227fe4d8288527ead8927181620f6" + "Comment": "v0.8.4", + "Rev": "f82c741e743001237821b5e0bb9a8ebd324d3117" }, { "ImportPath": "github.com/appc/spec/actool", - "Comment": "v0.8.3", - "Rev": "db96f94ae6b227fe4d8288527ead8927181620f6" + "Comment": "v0.8.4", + "Rev": "f82c741e743001237821b5e0bb9a8ebd324d3117" }, { "ImportPath": "github.com/appc/spec/discovery", - "Comment": "v0.8.3", - "Rev": "db96f94ae6b227fe4d8288527ead8927181620f6" + "Comment": "v0.8.4", + "Rev": "f82c741e743001237821b5e0bb9a8ebd324d3117" }, { "ImportPath": "github.com/appc/spec/pkg/acirenderer", - "Comment": "v0.8.3", - "Rev": "db96f94ae6b227fe4d8288527ead8927181620f6" + "Comment": "v0.8.4", + "Rev": "f82c741e743001237821b5e0bb9a8ebd324d3117" }, { "ImportPath": "github.com/appc/spec/pkg/device", - "Comment": "v0.8.3", - "Rev": "db96f94ae6b227fe4d8288527ead8927181620f6" + "Comment": "v0.8.4", + "Rev": "f82c741e743001237821b5e0bb9a8ebd324d3117" }, { "ImportPath": "github.com/appc/spec/pkg/tarheader", - "Comment": "v0.8.3", - "Rev": "db96f94ae6b227fe4d8288527ead8927181620f6" + "Comment": "v0.8.4", + "Rev": "f82c741e743001237821b5e0bb9a8ebd324d3117" }, { "ImportPath": "github.com/appc/spec/schema", - "Comment": "v0.8.3", - "Rev": "db96f94ae6b227fe4d8288527ead8927181620f6" + "Comment": "v0.8.4", + "Rev": "f82c741e743001237821b5e0bb9a8ebd324d3117" }, { "ImportPath": "github.com/appc/spec/schema/common", - "Comment": "v0.8.3", - "Rev": "db96f94ae6b227fe4d8288527ead8927181620f6" + "Comment": "v0.8.4", + "Rev": "f82c741e743001237821b5e0bb9a8ebd324d3117" }, { "ImportPath": "github.com/appc/spec/schema/lastditch", - "Comment": "v0.8.3", - "Rev": "db96f94ae6b227fe4d8288527ead8927181620f6" + "Comment": "v0.8.4", + "Rev": "f82c741e743001237821b5e0bb9a8ebd324d3117" }, { "ImportPath": "github.com/appc/spec/schema/types", - "Comment": "v0.8.3", - "Rev": "db96f94ae6b227fe4d8288527ead8927181620f6" + "Comment": "v0.8.4", + "Rev": "f82c741e743001237821b5e0bb9a8ebd324d3117" }, { "ImportPath": "github.com/aws/aws-sdk-go/aws", diff --git a/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_main.json.in b/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_main.json.in index 60e6417be7..33157eeead 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_main.json.in +++ b/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_main.json.in @@ -1,9 +1,9 @@ { - "acVersion": "0.8.3", + "acVersion": "0.8.4", "acKind": "ImageManifest", "name": "coreos.com/ace-validator-main", "labels": [ - { "name": "version", "value": "0.8.3" }, + { "name": "version", "value": "0.8.4" }, { "name": "os", "value": "@GOOS@" }, { "name": "arch", "value": "@GOARCH@" } ], diff --git a/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_sidekick.json.in b/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_sidekick.json.in index ed09f46a6e..a69bbcf66b 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_sidekick.json.in +++ b/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_sidekick.json.in @@ -1,9 +1,9 @@ { - "acVersion": "0.8.3", + "acVersion": "0.8.4", "acKind": "ImageManifest", "name": "coreos.com/ace-validator-sidekick", "labels": [ - { "name": "version", "value": "0.8.3" }, + { "name": "version", "value": "0.8.4" }, { "name": "os", "value": "@GOOS@" }, { "name": "arch", "value": "@GOARCH@" } ], diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/isolator_resources.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/isolator_resources.go index d97827b96f..2ac5130d1c 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/isolator_resources.go +++ b/Godeps/_workspace/src/github.com/appc/spec/schema/types/isolator_resources.go @@ -155,8 +155,8 @@ func NewResourceCPUIsolator(request, limit string) (*ResourceCPU, error) { res := &ResourceCPU{ ResourceBase{ resourceValue{ - Request: &req, - Limit: &lim, + Request: req, + Limit: lim, }, }, } @@ -209,8 +209,8 @@ func NewResourceMemoryIsolator(request, limit string) (*ResourceMemory, error) { res := &ResourceMemory{ ResourceBase{ resourceValue{ - Request: &req, - Limit: &lim, + Request: req, + Limit: lim, }, }, } diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/version.go b/Godeps/_workspace/src/github.com/appc/spec/schema/version.go index 1cba342bb2..029ebfac35 100644 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/version.go +++ b/Godeps/_workspace/src/github.com/appc/spec/schema/version.go @@ -22,7 +22,7 @@ const ( // version represents the canonical version of the appc spec and tooling. // For now, the schema and tooling is coupled with the spec itself, so // this must be kept in sync with the VERSION file in the root of the repo. - version string = "0.8.3" + version string = "0.8.4" ) var ( From 7c9108b76c30368a4332c87654501dc8abe441bd Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Wed, 25 May 2016 17:30:43 +0200 Subject: [PATCH 0318/1304] scripts/godep-save: compat shebang --- scripts/godep-save | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/godep-save b/scripts/godep-save index 076ee2d4a4..f488d575a1 100755 --- a/scripts/godep-save +++ b/scripts/godep-save @@ -1,4 +1,5 @@ -#!/bin/bash -e +#!/usr/bin/env bash +set -e # make sure we are running in a toplevel directory if ! [[ "$0" =~ "scripts/godep-save" ]]; then From 1d40da6777d2bbcd91fd4c9b40e21069fc2336a3 Mon Sep 17 00:00:00 2001 From: Matthias Jahn Date: Thu, 26 May 2016 10:58:34 +0200 Subject: [PATCH 0319/1304] docs: use stageX consistently Fixes #2610 --- CHANGELOG.md | 2 +- Documentation/devel/architecture.md | 10 ++-- Documentation/devel/pod-lifecycle.md | 6 +-- .../devel/stage1-implementors-guide.md | 48 +++++++++---------- Documentation/subcommands/run.md | 2 +- stage0/run.go | 4 +- stage1/README.md | 4 +- tests/rkt_caps_test.go | 2 +- 8 files changed, 39 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6a3f2e88d..2abcde86f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -482,7 +482,7 @@ rkt v0.10.0 is an incremental release with numerous bug fixes and a few small ne #### Improved documentation - [compare rkt and other projects](https://github.com/coreos/rkt/blob/master/Documentation/rkt-vs-other-projects.md) ([#1588](https://github.com/coreos/rkt/pull/1588)) -- [Stage 1 systemd Architecture](https://github.com/coreos/rkt/blob/master/Documentation/devel/architecture.md) ([#1631](https://github.com/coreos/rkt/pull/1631)) +- [Stage1 systemd Architecture](https://github.com/coreos/rkt/blob/master/Documentation/devel/architecture.md) ([#1631](https://github.com/coreos/rkt/pull/1631)) - [packaging rkt in Linux distributions](https://github.com/coreos/rkt/blob/master/Documentation/packaging.md) ([#1511](https://github.com/coreos/rkt/pull/1511)) #### Improved testing diff --git a/Documentation/devel/architecture.md b/Documentation/devel/architecture.md index e3f54869b0..f6d11911d3 100644 --- a/Documentation/devel/architecture.md +++ b/Documentation/devel/architecture.md @@ -21,12 +21,12 @@ Until https://github.com/coreos/rkt/issues/572 is resolved, this should be consi The first stage is the actual `rkt` binary itself. When running a pod, this binary is responsible for performing a number of initial preparatory tasks: -- Fetching the specified ACIs, including the stage 1 ACI of --stage1-{url,path,name,hash,from-dir} if specified. +- Fetching the specified ACIs, including the stage1 ACI of --stage1-{url,path,name,hash,from-dir} if specified. - Generating a Pod UUID - Generating a Pod Manifest - Creating a filesystem for the pod -- Setting up stage 1 and stage 2 directories in the filesystem -- Unpacking the stage 1 ACI into the pod filesystem +- Setting up stage1 and stage2 directories in the filesystem +- Unpacking the stage1 ACI into the pod filesystem - Unpacking the ACIs and copying each app into the stage2 directories Given a run command such as: @@ -61,7 +61,7 @@ At this point the stage0 execs `/stage1/rootfs/init` with the current working di ### Stage 1 The next stage is a binary that the user trusts to set up cgroups, execute processes, and perform other operations as root on the host. -This stage has the responsibility of taking the pod filesystem that was created by stage 0 and creating the necessary cgroups, namespaces and mounts to launch the pod. +This stage has the responsibility of taking the pod filesystem that was created by stage0 and creating the necessary cgroups, namespaces and mounts to launch the pod. Specifically, it must: - Read the Image and Pod Manifests. The Image Manifest defines the default `exec` specifications of each application; the Pod Manifest defines the ordering of the units, as well as any overrides. @@ -76,7 +76,7 @@ This process is slightly different for the qemu-kvm stage1 but a similar workflo ### Stage 1 systemd Architecture -rkt's Stage 1 includes a very minimal systemd that takes care of launching the apps in each pod, apply per-app resource isolators and make sure the apps finish in an orderly manner. +rkt's Stage1 includes a very minimal systemd that takes care of launching the apps in each pod, apply per-app resource isolators and make sure the apps finish in an orderly manner. We will now detail how the starting, shutdown, and exist status collection of the apps in a pod are implemented internally. diff --git a/Documentation/devel/pod-lifecycle.md b/Documentation/devel/pod-lifecycle.md index 0483e33006..7d1c6003da 100644 --- a/Documentation/devel/pod-lifecycle.md +++ b/Documentation/devel/pod-lifecycle.md @@ -72,9 +72,9 @@ Any directory in `$var/prepare` in an unlocked state is considered a failed prep `rkt run` and `rkt run-prepared` both arrive here with the pod at `$var/run/$uuid` while holding the exclusive lock. The pod is then executed while holding this lock. -It is required that the stage 1 `coreos.com/rkt/stage1/run` entrypoint keep the file descriptor representing the exclusive lock open for the lifetime of the pod's process. -All this requires is that the stage 1 implementation not close the inherited file descriptor. -This is facilitated by supplying stage 1 its number in the RKT_LOCK_FD environment variable. +It is required that the stage1 `coreos.com/rkt/stage1/run` entrypoint keep the file descriptor representing the exclusive lock open for the lifetime of the pod's process. +All this requires is that the stage1 implementation not close the inherited file descriptor. +This is facilitated by supplying stage1 its number in the RKT_LOCK_FD environment variable. What follows applies equally to `rkt run` and `rkt run-prepared`. diff --git a/Documentation/devel/stage1-implementors-guide.md b/Documentation/devel/stage1-implementors-guide.md index 222c929535..eda3915d68 100644 --- a/Documentation/devel/stage1-implementors-guide.md +++ b/Documentation/devel/stage1-implementors-guide.md @@ -1,4 +1,4 @@ -Stage 1 ACI implementor's guide +Stage1 ACI implementor's guide ============================= Background @@ -6,23 +6,23 @@ Background rkt's execution of pods is divided roughly into three separate stages: -1. Stage 0: discovering, fetching, verifying, storing, and compositing of both application (stage 2) and stage 1 images for execution. -2. Stage 1: execution of the stage 1 image from within the composite image prepared by stage 0. -3. Stage 2: execution of individual application images within the containment afforded by stage 1. +1. Stage 0: discovering, fetching, verifying, storing, and compositing of both application (stage2) and stage1 images for execution. +2. Stage 1: execution of the stage1 image from within the composite image prepared by stage0. +3. Stage 2: execution of individual application images within the containment afforded by stage1. -This separation of concerns is reflected in the file-system and layout of the composite image prepared by stage 0: +This separation of concerns is reflected in the file-system and layout of the composite image prepared by stage0: 1. Stage 0: `rkt` executable, and the pod manifest created at `/var/lib/rkt/pods/prepare/$uuid/pod`. 2. Stage 1: `stage1.aci`, made available at `/var/lib/rkt/pods/run/$uuid/stage1` by `rkt run`. 3. Stage 2: `$app.aci`, made available at `/var/lib/rkt/pods/run/$uuid/stage1/rootfs/opt/stage2/$appname` by `rkt run`, where `$appname` is the name of the app in the pod manifest. -The stage 1 implementation is what creates the execution environment for the contained applications. -This occurs via entrypoints from stage 0 on behalf of `rkt run` and `rkt enter`. -These entrypoints are executable programs located via annotations from within the stage 1 ACI manifest, and executed from within the stage 1 of a given pod at `/var/lib/rkt/pods/$state/$uuid/stage1/rootfs`. +The stage1 implementation is what creates the execution environment for the contained applications. +This occurs via entrypoints from stage0 on behalf of `rkt run` and `rkt enter`. +These entrypoints are executable programs located via annotations from within the stage1 ACI manifest, and executed from within the stage1 of a given pod at `/var/lib/rkt/pods/$state/$uuid/stage1/rootfs`. -Stage 2 is the deployed application image. -Stage 1 is the vehicle for getting there from stage 0. -For any given pod instance, stage 1 may be replaced by a completely different implementation. +Stage2 is the deployed application image. +Stage1 is the vehicle for getting there from stage0. +For any given pod instance, stage1 may be replaced by a completely different implementation. This allows users to employ different containment strategies on the same host running the same interchangeable ACIs. Entrypoints @@ -30,7 +30,7 @@ Entrypoints ### `rkt run` => `coreos.com/rkt/stage1/run` -1. rkt prepares the pod's stage 1 and stage 2 images and pod manifest under `/var/lib/rkt/pods/prepare/$uuid`, acquiring an exclusive advisory lock on the directory. +1. rkt prepares the pod's stage1 and stage2 images and pod manifest under `/var/lib/rkt/pods/prepare/$uuid`, acquiring an exclusive advisory lock on the directory. Upon a successful preparation, the directory will be renamed to `/var/lib/rkt/pods/run/$uuid`. 2. chdirs to `/var/lib/rkt/pods/run/$uuid`. 3. resolves the `coreos.com/rkt/stage1/run` entrypoint via annotations found within `/var/lib/rkt/pods/run/$uuid/stage1/manifest`. @@ -39,18 +39,18 @@ Entrypoints It is the responsibility of this entrypoint to consume the pod manifest and execute the constituent apps in the appropriate environments as specified by the pod manifest. The environment variable `RKT_LOCK_FD` contains the file descriptor number of the open directory handle for `/var/lib/rkt/pods/run/$uuid`. -It is necessary that stage 1 leave this file descriptor open and in its locked state for the duration of the `rkt run`. +It is necessary that stage1 leave this file descriptor open and in its locked state for the duration of the `rkt run`. -In the bundled rkt stage 1 which includes systemd-nspawn and systemd, the entrypoint is a static Go program found at `/init` within the stage 1 ACI rootfs. +In the bundled rkt stage1 which includes systemd-nspawn and systemd, the entrypoint is a static Go program found at `/init` within the stage1 ACI rootfs. The majority of its execution entails generating a systemd-nspawn argument list and writing systemd unit files for the constituent apps before executing systemd-nspawn. -Systemd-nspawn then boots the stage 1 systemd with the just-written unit files for launching the contained apps. +Systemd-nspawn then boots the stage1 systemd with the just-written unit files for launching the contained apps. The `/init` program's primary job is translating a pod manifest to systemd-nspawn systemd.services. -An alternative stage 1 could forego systemd-nspawn and systemd altogether, or retain these and introduce something like novm or qemu-kvm for greater isolation by first starting a VM. +An alternative stage1 could forego systemd-nspawn and systemd altogether, or retain these and introduce something like novm or qemu-kvm for greater isolation by first starting a VM. All that is required is an executable at the place indicated by the `coreos.com/rkt/stage1/run` entrypoint that knows how to apply the pod manifest and prepared ACI file-systems to good effect. The resolved entrypoint must inform rkt of its PID for the benefit of `rkt enter`. -Stage 1 implementors have two options for doing so; only one must be implemented: +Stage1 implementors have two options for doing so; only one must be implemented: * `/var/lib/rkt/pods/run/$uuid/pid`: the PID of the process that will be given to the "enter" entrypoint. * `/var/lib/rkt/pods/run/$uuid/ppid`: the PID of the parent of the process that will be given to the "enter" entrypoint. That parent process must have exactly one child process. @@ -76,11 +76,11 @@ Stage 1 implementors have two options for doing so; only one must be implemented 3. resolves the `coreos.com/rkt/stage1/enter` entrypoint via annotations found within `/var/lib/rkt/pods/run/$uuid/stage1/manifest` 4. executes the resolved entrypoint relative to `/var/lib/rkt/pods/run/$uuid/stage1/rootfs` -In the bundled rkt stage 1, the entrypoint is a statically-linked C program found at `/enter` within the stage 1 ACI rootfs. +In the bundled rkt stage1, the entrypoint is a statically-linked C program found at `/enter` within the stage1 ACI rootfs. This program enters the namespaces of the systemd-nspawn container's PID 1 before executing the `/enterexec` program. `enterexec` then `chroot`s into the ACI's rootfs, loading the application and its environment. -An alternative stage 1 would need to do whatever is appropriate for entering the application environment created by its own `coreos.com/rkt/stage1/run` entrypoint. +An alternative stage1 would need to do whatever is appropriate for entering the application environment created by its own `coreos.com/rkt/stage1/run` entrypoint. #### Arguments @@ -93,7 +93,7 @@ An alternative stage 1 would need to do whatever is appropriate for entering the ### `rkt gc` => `coreos.com/rkt/stage1/gc` -The gc entrypoint deals with garbage collecting resources allocated by stage 1. +The gc entrypoint deals with garbage collecting resources allocated by stage1. For example, it removes the network namespace of a pod. #### Arguments @@ -112,7 +112,7 @@ The current version of the stage1 interface is 2. Examples -------- -### Stage 1 ACI manifest +### Stage1 ACI manifest ```json { @@ -156,8 +156,8 @@ Examples ## Filesystem Layout Assumptions -The following paths are reserved for the stage 1 image, and they will be created during stage0. -When creating a stage 1 image, developers SHOULD NOT create or use these paths in the image's filesystem. +The following paths are reserved for the stage1 image, and they will be created during stage0. +When creating a stage1 image, developers SHOULD NOT create or use these paths in the image's filesystem. ### opt/stage2 @@ -168,7 +168,7 @@ e.g. `/var/lib/rkt/pods/run/$uuid/stage1/rootfs/opt/stage2/$appname/rootfs`. ### rkt/status This directory path is used for storing the apps' exit statuses. -For example, if an app named `foo` exits with status = `42`, stage 1 should write `42` +For example, if an app named `foo` exits with status = `42`, stage1 should write `42` in `/var/lib/rkt/pods/run/$uuid/stage1/rootfs/rkt/status/foo`. Later the exit status can be retrieved and shown by `rkt status $uuid`. diff --git a/Documentation/subcommands/run.md b/Documentation/subcommands/run.md index 77defacc1d..1ffb5b0629 100644 --- a/Documentation/subcommands/run.md +++ b/Documentation/subcommands/run.md @@ -320,7 +320,7 @@ For example, if you use systemd, you can [run rkt using `systemd-run`](https://g If you don't use systemd, you can use [daemon](http://www.libslack.org/daemon/) as an alternative. -## Use a Custom Stage 1 +## Use a Custom Stage1 rkt is designed and intended to be modular, using a [staged architecture](../devel/architecture.md). diff --git a/stage0/run.go b/stage0/run.go index ed1d45e6af..8c3acf9a46 100644 --- a/stage0/run.go +++ b/stage0/run.go @@ -20,7 +20,7 @@ package stage0 // rkt is a reference implementation of the app container specification. // // Execution on rkt is divided into a number of stages, and the `rkt` -// binary implements the first stage (stage 0) +// binary implements the first stage (stage0) // import ( @@ -526,7 +526,7 @@ func Run(cfg RunConfig, dir string, dataDir string) { log.Fatalf("error clearing FD_CLOEXEC on lock fd") } - tpmEvent := fmt.Sprintf("rkt: Rootfs: %s Manifest: %s Stage 1 args: %s", cfg.CommonConfig.RootHash, cfg.CommonConfig.ManifestData, strings.Join(args, " ")) + tpmEvent := fmt.Sprintf("rkt: Rootfs: %s Manifest: %s Stage1 args: %s", cfg.CommonConfig.RootHash, cfg.CommonConfig.ManifestData, strings.Join(args, " ")) // If there's no TPM available or there's a failure for some other // reason, ignore it and continue anyway. Long term we'll want policy // that enforces TPM behaviour, but we don't have any infrastructure diff --git a/stage1/README.md b/stage1/README.md index 6afc0b8148..d0cfc70727 100644 --- a/stage1/README.md +++ b/stage1/README.md @@ -1,5 +1,5 @@ -Stage 1 build +Stage1 build ------------- -Stage 1 build is invoked by the parent makefile by calling stage1.mk +Stage1 build is invoked by the parent makefile by calling stage1.mk read the stage1.mk contents for details diff --git a/tests/rkt_caps_test.go b/tests/rkt_caps_test.go index d8fce6b1e0..b54057e0b5 100644 --- a/tests/rkt_caps_test.go +++ b/tests/rkt_caps_test.go @@ -393,7 +393,7 @@ func NewCapsTest(hasStage1FullCaps bool, stages []int) testutils.Test { stageFileNames := []string{stage1FileName, stage2FileName} for _, stage := range stages { - t.Logf("Running test #%v: %v [stage %v]", i, tt.testName, stage) + t.Logf("Running test #%v: %v [stage%v]", i, tt.testName, stage) cmd := fmt.Sprintf("%s --debug --insecure-options=image run --mds-register=false --set-env=CAPABILITY=%d %s", ctx.Cmd(), int(tt.capa), stageFileNames[stage-1]) child := spawnOrFail(t, cmd) From 78f273f1d4e7e129c84eff0040b900265222a1e4 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Thu, 26 May 2016 11:53:50 +0200 Subject: [PATCH 0320/1304] docs: document capabilities usage This commits introduces a walk-through guide for capabilities usage. It is targeted to users, introducing them to Linux capabilities in general, documenting the differences between the two available isolators, and how to use them for building images. Fixes #2648 --- Documentation/capabilities-guide.md | 236 ++++++++++++++++++++++++++++ 1 file changed, 236 insertions(+) create mode 100644 Documentation/capabilities-guide.md diff --git a/Documentation/capabilities-guide.md b/Documentation/capabilities-guide.md new file mode 100644 index 0000000000..5ca541aec0 --- /dev/null +++ b/Documentation/capabilities-guide.md @@ -0,0 +1,236 @@ +# Capabilities Isolators Guide + +This document is a walk-through guide describing how to use rkt isolators for +[Linux Capabilities](https://lwn.net/Kernel/Index/#Capabilities). + +* [About Linux Capabilities](#about-linux-capabilities) +* [Default Capabilities](#default-capabilities) +* [Capability Isolators](#capability-isolators) +* [Usage Example](#usage-example) +* [Recommendations](#recommendations) + +## About Linux Capabilities + +Linux capabilities are meant to be a modern evolution of traditional UNIX +permissions checks. +The goal is to split the permissions granted to privileged processes into a set +of capabilities (eg. `CAP_NET_RAW` to open a raw socket), which can be +separately handled and assigned to single threads. + +Processes can gain specific capabilities by either being run by superuser, or by +having the setuid/setgid bits or specific file-capabilities set on their +executable file. +Once running, each process has a bounding set of capabilities which it can +enable and use; such process cannot get further capabilities outside of this set. + +In the context of containers, capabilities are useful for: + * restricting the effective privileges of applications running as root + * allowing applications to perform specific privileged operations, without + having to run them as root + +For the complete list of existing Linux capabilities and a detailed description +of this security mechanism, see [capabilities(7)](http://man7.org/linux/man-pages/man7/capabilities.7.html). + +## Default capabilities + +By default, rkt enforces [a default set of +capabilities](https://github.com/appc/spec/blob/master/spec/ace.md#oslinuxcapabilities-remove-set) +onto applications. +This default set is tailored to stop applications from performing a large +variety of privileged actions, while not impacting their normal behavior. +Operations which are typically not needed in containers and which may +impact host state, eg. invoking `reboot(2)`, are denied in this way. + +However, this default set is mostly meant as a safety precaution against erratic +and misbehaving applications, and will not suffice against tailored attacks. +As such, it is recommended to fine-tune the capabilities bounding set using one +of the customizable isolators available in rkt. + +## Capability Isolators + +When running Linux containers, rkt provides two mutually exclusive isolators +to define the bounding set under which an application will be run: + * `os/linux/capabilities-retain-set` + * `os/linux/capabilities-remove-set` + +Those isolators cover different use-cases and employ different techniques to +achieve the same goal of limiting available capabilities. As such, they cannot +be used together at the same time, and recommended usage varies on a +case-by-case basis. + +As the granularity of capabilities varies for specific permission cases, a word +of warning is needed in order to avoid a false sense of security. +In many cases it is possible to abuse granted capabilities in order to +completely subvert the sandbox: for example, `CAP_SYS_PTRACE` allows to access +stage1 environment and `CAP_SYS_ADMIN` grants a broad range of privileges, +effectively equivalent to root. +Many other ways to maliciously transition across capabilities have already been +[reported](https://forums.grsecurity.net/viewtopic.php?f=7&t=2522) too. + +### Retain-set + +`os/linux/capabilities-retain-set` allows for an additive approach to +capabilities: applications will be stripped of all capabilities, except the ones +listed in this isolator. + +This whitelisting approach is useful for completely locking down environments +and whenever application requirements (in terms of capabilities) are +well-defined in advance. It allows one to ensure that exactly and only the +specified capabilities could ever be used. + +For example, an application that will only need to bind to port 80 as +a privileged operation, will have `CAP_NET_BIND_SERVICE` as the only entry in +its "retain-set". + +### Remove-set + +`os/linux/capabilities-remove-set` tackles capabilities in a subtractive way: +starting from the default set of capabilities, single entries can be further +forbidden in order to prevent specific actions. + +This blacklisting approach is useful to somehow limit applications which have +broad requirements in terms of privileged operations, in order to deny some +potentially malicious operations. + +For example, an application that will need to perform multiple privileged +operations but is known to never open a raw socket, will have +`CAP_NET_RAW` specified in its "remove-set". + +## Usage Example + +The goal of these examples is to show how to build ACI images with acbuild, +where some capabilities are either explicitly blocked or allowed. +For simplicity, the starting point will be the official Alpine Linux image from +CoreOS which ships with `ping` and `nc` commands (from busybox). Those +commands respectively requires `CAP_NET_RAW` and `CAP_NET_BIND_SERVICE` +capabilities in order to perform privileged operations. +To block their usage, capabilities bounding set +can be manipulated via `os/linux/capabilities-remove-set` or +`os/linux/capabilities-retain-set`; both approaches are shown here. + +### Removing specific capabilities + +This example shows how to block `ping` only, by removing `CAP_NET_RAW` from +capabilities bounding set. + +First, a local image is built with an explicit "remove-set" isolator. +This set contains the capabilities that need to be forbidden in order to block +`ping` usage (and only that): + +``` +$ acbuild begin +$ acbuild set-name localhost/caps-remove-set-example +$ acbuild dependency add quay.io/coreos/alpine-sh +$ acbuild set-exec -- /bin/sh +$ echo '{ "set": ["CAP_NET_RAW"] }' | acbuild isolator add "os/linux/capabilities-remove-set" - +$ acbuild write caps-remove-set-example.aci +$ acbuild end +``` + +Once properly built, this image can be run in order to check that `ping` usage has +been effectively disabled: +``` +$ sudo rkt run --interactive --insecure-options=image caps-remove-set-example.aci +image: using image from file stage1-coreos.aci +image: using image from file caps-remove-set-example.aci +image: using image from local store for image name quay.io/coreos/alpine-sh + +/ # whoami +root + +/ # ping -c 1 8.8.8.8 +PING 8.8.8.8 (8.8.8.8): 56 data bytes +ping: permission denied (are you root?) +``` + +This means that `CAP_NET_RAW` had been effectively disabled inside the container. +At the same time, `CAP_NET_BIND_SERVICE` is still available in the default bounding +set, so the `nc` command will be able to bind to port 80: +``` +$ sudo rkt run --interactive --insecure-options=image caps-remove-set-example.aci +image: using image from file stage1-coreos.aci +image: using image from file caps-remove-set-example.aci +image: using image from local store for image name quay.io/coreos/alpine-sh + +/ # whoami +root + +/ # nc -v -l -p 80 +listening on [::]:80 ... +``` + +### Allowing specific capabilities + +In contrast to the example above, this one shows how to allow `ping` only, by +removing all capabilities except `CAP_NET_RAW` from the bounding set. +This means that all other privileged operations, including binding to port 80 +will be blocked. + +First, a local image is built with an explicit "retain-set" isolator. +This set contains the capabilities that need to be enabled in order to allowed +`ping` usage (and only that): + +``` +$ acbuild begin +$ acbuild set-name localhost/caps-retain-set-example +$ acbuild dependency add quay.io/coreos/alpine-sh +$ acbuild set-exec -- /bin/sh +$ echo '{ "set": ["CAP_NET_RAW"] }' | acbuild isolator add "os/linux/capabilities-retain-set" - +$ acbuild write caps-retain-set-example.aci +$ acbuild end +``` + +Once run, it can be easily verified that `ping` from inside the container is now +functional: + +``` +$ sudo rkt run --interactive --insecure-options=image caps-retain-set-example.aci +image: using image from file stage1-coreos.aci +image: using image from file caps-retain-set-example.aci +image: using image from local store for image name quay.io/coreos/alpine-sh + +/ # whoami +root + +/ # ping -c 1 8.8.8.8 +PING 8.8.8.8 (8.8.8.8): 56 data bytes +64 bytes from 8.8.8.8: seq=0 ttl=41 time=24.910 ms + +--- 8.8.8.8 ping statistics --- +1 packets transmitted, 1 packets received, 0% packet loss +round-trip min/avg/max = 24.910/24.910/24.910 ms +``` + +However, all others capabilities are now not anymore available to the application. +For example, using `nc` to bind to port 80 will now result in a failure due to +the missing `CAP_NET_BIND_SERVICE` capability: + +``` +$ sudo rkt run --interactive --insecure-options=image caps-remove-set-example.aci +image: using image from file stage1-coreos.aci +image: using image from file caps-remove-set-example.aci +image: using image from local store for image name quay.io/coreos/alpine-sh + +/ # whoami +root + +/ # nc -v -l -p 80 +nc: bind: Permission denied +``` + +## Recommendations + +As with most security features, capability isolators may require some +application-specific tuning in order to be maximally effective. For this reason, +for security-sensitive environments it is recommended to have a well-specified +set of capabilities requirements and follow best practices: + + 1. Always follow the principle of least privilege and, whenever possible, + avoid running applications as root + 2. Only grant the minimum set of capabilities needed by an application, + according to its typical usage + 3. Avoid granting overly generic capabilities. For example, `CAP_SYS_ADMIN` and + `CAP_SYS_PTRACE` are typically bad choices, as they open large attack + surfaces. + 4. Prefer a blacklisting approach, trying to keep the "retain-set" as small as + possible. From cd4d086a87cd46668fe0ef9d2543286f150c579b Mon Sep 17 00:00:00 2001 From: Derek Gonyeo Date: Thu, 26 May 2016 10:43:58 -0700 Subject: [PATCH 0321/1304] godeps: use tagged release of github.com/shirou/gopsutil Godeps also deleted a few other packages, no clue why but the project seems to build fine without them. The pakcages removed: - github.com/gopherjs/gopherjs/js - github.com/jtolds/gls - github.com/smartystreets/assertions - github.com/smartystreets/goconvey/convey --- Godeps/Godeps.json | 64 +- .../src/github.com/gopherjs/gopherjs/js/js.go | 168 ----- .../src/github.com/jtolds/gls/LICENSE | 18 - .../src/github.com/jtolds/gls/README.md | 89 --- .../src/github.com/jtolds/gls/context.go | 144 ----- .../src/github.com/jtolds/gls/gen_sym.go | 13 - .../src/github.com/jtolds/gls/id_pool.go | 34 -- .../src/github.com/jtolds/gls/stack_tags.go | 43 -- .../github.com/jtolds/gls/stack_tags_js.go | 101 --- .../github.com/jtolds/gls/stack_tags_main.go | 61 -- .../shirou/gopsutil/cpu/cpu_linux.go | 2 +- .../shirou/gopsutil/process/process.go | 1 - .../shirou/gopsutil/process/process_linux.go | 104 ++-- .../shirou/gopsutil/process/process_posix.go | 11 - .../smartystreets/assertions/.gitignore | 3 - .../smartystreets/assertions/.travis.yml | 14 - .../smartystreets/assertions/CONTRIBUTING.md | 12 - .../smartystreets/assertions/LICENSE.md | 23 - .../smartystreets/assertions/README.md | 575 ------------------ .../assertions/assertions.goconvey | 3 - .../smartystreets/assertions/collections.go | 244 -------- .../smartystreets/assertions/doc.go | 105 ---- .../smartystreets/assertions/equality.go | 280 --------- .../smartystreets/assertions/filter.go | 23 - .../internal/go-render/render/render.go | 477 --------------- .../internal/oglematchers/.gitignore | 5 - .../internal/oglematchers/.travis.yml | 4 - .../assertions/internal/oglematchers/LICENSE | 202 ------ .../internal/oglematchers/README.md | 58 -- .../internal/oglematchers/all_of.go | 70 --- .../assertions/internal/oglematchers/any.go | 32 - .../internal/oglematchers/any_of.go | 94 --- .../internal/oglematchers/contains.go | 61 -- .../internal/oglematchers/deep_equals.go | 88 --- .../internal/oglematchers/elements_are.go | 91 --- .../internal/oglematchers/equals.go | 541 ---------------- .../assertions/internal/oglematchers/error.go | 51 -- .../internal/oglematchers/greater_or_equal.go | 39 -- .../internal/oglematchers/greater_than.go | 39 -- .../internal/oglematchers/has_same_type_as.go | 37 -- .../internal/oglematchers/has_substr.go | 46 -- .../internal/oglematchers/identical_to.go | 134 ---- .../internal/oglematchers/less_or_equal.go | 41 -- .../internal/oglematchers/less_than.go | 152 ----- .../internal/oglematchers/matcher.go | 86 --- .../internal/oglematchers/matches_regexp.go | 69 --- .../internal/oglematchers/new_matcher.go | 43 -- .../assertions/internal/oglematchers/not.go | 53 -- .../internal/oglematchers/panics.go | 74 --- .../internal/oglematchers/pointee.go | 65 -- .../oglematchers/transform_description.go | 36 -- .../smartystreets/assertions/messages.go | 93 --- .../smartystreets/assertions/panic.go | 115 ---- .../smartystreets/assertions/quantity.go | 141 ----- .../smartystreets/assertions/serializer.go | 69 --- .../smartystreets/assertions/strings.go | 227 ------- .../smartystreets/assertions/time.go | 202 ------ .../smartystreets/assertions/type.go | 112 ---- .../goconvey/convey/assertions.go | 68 --- .../smartystreets/goconvey/convey/context.go | 272 --------- .../goconvey/convey/convey.goconvey | 4 - .../goconvey/convey/discovery.go | 103 ---- .../smartystreets/goconvey/convey/doc.go | 218 ------- .../goconvey/convey/gotest/utils.go | 28 - .../smartystreets/goconvey/convey/init.go | 81 --- .../goconvey/convey/nilReporter.go | 15 - .../goconvey/convey/reporting/console.go | 16 - .../goconvey/convey/reporting/doc.go | 5 - .../goconvey/convey/reporting/dot.go | 40 -- .../goconvey/convey/reporting/gotest.go | 33 - .../goconvey/convey/reporting/init.go | 94 --- .../goconvey/convey/reporting/json.go | 88 --- .../goconvey/convey/reporting/printer.go | 57 -- .../goconvey/convey/reporting/problems.go | 80 --- .../goconvey/convey/reporting/reporter.go | 39 -- .../convey/reporting/reporting.goconvey | 2 - .../goconvey/convey/reporting/reports.go | 179 ------ .../goconvey/convey/reporting/statistics.go | 108 ---- .../goconvey/convey/reporting/story.go | 73 --- 79 files changed, 48 insertions(+), 7337 deletions(-) delete mode 100644 Godeps/_workspace/src/github.com/gopherjs/gopherjs/js/js.go delete mode 100644 Godeps/_workspace/src/github.com/jtolds/gls/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/jtolds/gls/README.md delete mode 100644 Godeps/_workspace/src/github.com/jtolds/gls/context.go delete mode 100644 Godeps/_workspace/src/github.com/jtolds/gls/gen_sym.go delete mode 100644 Godeps/_workspace/src/github.com/jtolds/gls/id_pool.go delete mode 100644 Godeps/_workspace/src/github.com/jtolds/gls/stack_tags.go delete mode 100644 Godeps/_workspace/src/github.com/jtolds/gls/stack_tags_js.go delete mode 100644 Godeps/_workspace/src/github.com/jtolds/gls/stack_tags_main.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/.gitignore delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/.travis.yml delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/CONTRIBUTING.md delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/LICENSE.md delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/README.md delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/assertions.goconvey delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/collections.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/doc.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/equality.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/filter.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/go-render/render/render.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/.gitignore delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/.travis.yml delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/README.md delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/all_of.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/any.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/any_of.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/contains.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/deep_equals.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/elements_are.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/equals.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/error.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/greater_than.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/has_substr.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/identical_to.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/less_than.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/matcher.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/new_matcher.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/not.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/panics.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/pointee.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/transform_description.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/messages.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/panic.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/quantity.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/serializer.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/strings.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/time.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/assertions/type.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/assertions.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/context.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/convey.goconvey delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/discovery.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/doc.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/gotest/utils.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/init.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/nilReporter.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/console.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/doc.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/dot.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/gotest.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/init.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/json.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/printer.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/problems.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reporter.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reporting.goconvey delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reports.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/statistics.go delete mode 100644 Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/story.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index e58a951fae..66c18e843f 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -433,11 +433,6 @@ "ImportPath": "github.com/google/btree", "Rev": "f06e229e679911bb31a04e07ac891115822e37c3" }, - { - "ImportPath": "github.com/gopherjs/gopherjs/js", - "Comment": "go1.5-45-g19e100e", - "Rev": "19e100e9652485a76176bc5fd2669f57d3a2743c" - }, { "ImportPath": "github.com/gorilla/context", "Rev": "50c25fb3b2b3b3cc724e9b6ac75fb44b3bccd0da" @@ -463,11 +458,6 @@ "Comment": "0.2.2-12-g0b12d6b", "Rev": "0b12d6b521d83fc7f755e7cfc1b1fbdd35a01a74" }, - { - "ImportPath": "github.com/jtolds/gls", - "Comment": "v4.2.0", - "Rev": "8ddce2a84170772b95dd5d576c48d517b22cac63" - }, { "ImportPath": "github.com/kballard/go-shellquote", "Rev": "e5c918b80c17694cbc49aab32a759f9a40067f5d" @@ -493,33 +483,33 @@ }, { "ImportPath": "github.com/shirou/gopsutil/cpu", - "Comment": "v2.0.0-10-g9ef3410", - "Rev": "9ef341037b1bcadeeee79e77da4f6baf63de4feb" + "Comment": "v2.0.0", + "Rev": "e8f7a95747d711f34ddfe9dd9b825a84bd059dec" }, { "ImportPath": "github.com/shirou/gopsutil/host", - "Comment": "v2.0.0-10-g9ef3410", - "Rev": "9ef341037b1bcadeeee79e77da4f6baf63de4feb" + "Comment": "v2.0.0", + "Rev": "e8f7a95747d711f34ddfe9dd9b825a84bd059dec" }, { "ImportPath": "github.com/shirou/gopsutil/internal/common", - "Comment": "v2.0.0-10-g9ef3410", - "Rev": "9ef341037b1bcadeeee79e77da4f6baf63de4feb" + "Comment": "v2.0.0", + "Rev": "e8f7a95747d711f34ddfe9dd9b825a84bd059dec" }, { "ImportPath": "github.com/shirou/gopsutil/mem", - "Comment": "v2.0.0-10-g9ef3410", - "Rev": "9ef341037b1bcadeeee79e77da4f6baf63de4feb" + "Comment": "v2.0.0", + "Rev": "e8f7a95747d711f34ddfe9dd9b825a84bd059dec" }, { "ImportPath": "github.com/shirou/gopsutil/net", - "Comment": "v2.0.0-10-g9ef3410", - "Rev": "9ef341037b1bcadeeee79e77da4f6baf63de4feb" + "Comment": "v2.0.0", + "Rev": "e8f7a95747d711f34ddfe9dd9b825a84bd059dec" }, { "ImportPath": "github.com/shirou/gopsutil/process", - "Comment": "v2.0.0-10-g9ef3410", - "Rev": "9ef341037b1bcadeeee79e77da4f6baf63de4feb" + "Comment": "v2.0.0", + "Rev": "e8f7a95747d711f34ddfe9dd9b825a84bd059dec" }, { "ImportPath": "github.com/shirou/w32", @@ -529,36 +519,6 @@ "ImportPath": "github.com/shurcooL/sanitized_anchor_name", "Rev": "10ef21a441db47d8b13ebcc5fd2310f636973c77" }, - { - "ImportPath": "github.com/smartystreets/assertions", - "Comment": "1.6.0-6-g40711f7", - "Rev": "40711f7748186bbf9c99977cd89f21ce1a229447" - }, - { - "ImportPath": "github.com/smartystreets/assertions/internal/go-render/render", - "Comment": "1.6.0-6-g40711f7", - "Rev": "40711f7748186bbf9c99977cd89f21ce1a229447" - }, - { - "ImportPath": "github.com/smartystreets/assertions/internal/oglematchers", - "Comment": "1.6.0-6-g40711f7", - "Rev": "40711f7748186bbf9c99977cd89f21ce1a229447" - }, - { - "ImportPath": "github.com/smartystreets/goconvey/convey", - "Comment": "1.6.1-20-gcc5d85f", - "Rev": "cc5d85f4f15bd2163abf0fe6e6753356dde72aa2" - }, - { - "ImportPath": "github.com/smartystreets/goconvey/convey/gotest", - "Comment": "1.6.1-20-gcc5d85f", - "Rev": "cc5d85f4f15bd2163abf0fe6e6753356dde72aa2" - }, - { - "ImportPath": "github.com/smartystreets/goconvey/convey/reporting", - "Comment": "1.6.1-20-gcc5d85f", - "Rev": "cc5d85f4f15bd2163abf0fe6e6753356dde72aa2" - }, { "ImportPath": "github.com/spf13/cobra", "Rev": "4c05eb1145f16d0e6bb4a3e1b6d769f4713cb41f" diff --git a/Godeps/_workspace/src/github.com/gopherjs/gopherjs/js/js.go b/Godeps/_workspace/src/github.com/gopherjs/gopherjs/js/js.go deleted file mode 100644 index 5367d3d0fa..0000000000 --- a/Godeps/_workspace/src/github.com/gopherjs/gopherjs/js/js.go +++ /dev/null @@ -1,168 +0,0 @@ -// Package js provides functions for interacting with native JavaScript APIs. Calls to these functions are treated specially by GopherJS and translated directly to their corresponding JavaScript syntax. -// -// Use MakeWrapper to expose methods to JavaScript. When passing values directly, the following type conversions are performed: -// -// | Go type | JavaScript type | Conversions back to interface{} | -// | --------------------- | --------------------- | ------------------------------- | -// | bool | Boolean | bool | -// | integers and floats | Number | float64 | -// | string | String | string | -// | []int8 | Int8Array | []int8 | -// | []int16 | Int16Array | []int16 | -// | []int32, []int | Int32Array | []int | -// | []uint8 | Uint8Array | []uint8 | -// | []uint16 | Uint16Array | []uint16 | -// | []uint32, []uint | Uint32Array | []uint | -// | []float32 | Float32Array | []float32 | -// | []float64 | Float64Array | []float64 | -// | all other slices | Array | []interface{} | -// | arrays | see slice type | see slice type | -// | functions | Function | func(...interface{}) *js.Object | -// | time.Time | Date | time.Time | -// | - | instanceof Node | *js.Object | -// | maps, structs | instanceof Object | map[string]interface{} | -// -// Additionally, for a struct containing a *js.Object field, only the content of the field will be passed to JavaScript and vice versa. -package js - -// Object is a container for a native JavaScript object. Calls to its methods are treated specially by GopherJS and translated directly to their JavaScript syntax. A nil pointer to Object is equal to JavaScript's "null". Object can not be used as a map key. -type Object struct{ object *Object } - -// Get returns the object's property with the given key. -func (o *Object) Get(key string) *Object { return o.object.Get(key) } - -// Set assigns the value to the object's property with the given key. -func (o *Object) Set(key string, value interface{}) { o.object.Set(key, value) } - -// Delete removes the object's property with the given key. -func (o *Object) Delete(key string) { o.object.Delete(key) } - -// Length returns the object's "length" property, converted to int. -func (o *Object) Length() int { return o.object.Length() } - -// Index returns the i'th element of an array. -func (o *Object) Index(i int) *Object { return o.object.Index(i) } - -// SetIndex sets the i'th element of an array. -func (o *Object) SetIndex(i int, value interface{}) { o.object.SetIndex(i, value) } - -// Call calls the object's method with the given name. -func (o *Object) Call(name string, args ...interface{}) *Object { return o.object.Call(name, args...) } - -// Invoke calls the object itself. This will fail if it is not a function. -func (o *Object) Invoke(args ...interface{}) *Object { return o.object.Invoke(args...) } - -// New creates a new instance of this type object. This will fail if it not a function (constructor). -func (o *Object) New(args ...interface{}) *Object { return o.object.New(args...) } - -// Bool returns the object converted to bool according to JavaScript type conversions. -func (o *Object) Bool() bool { return o.object.Bool() } - -// String returns the object converted to string according to JavaScript type conversions. -func (o *Object) String() string { return o.object.String() } - -// Int returns the object converted to int according to JavaScript type conversions (parseInt). -func (o *Object) Int() int { return o.object.Int() } - -// Int64 returns the object converted to int64 according to JavaScript type conversions (parseInt). -func (o *Object) Int64() int64 { return o.object.Int64() } - -// Uint64 returns the object converted to uint64 according to JavaScript type conversions (parseInt). -func (o *Object) Uint64() uint64 { return o.object.Uint64() } - -// Float returns the object converted to float64 according to JavaScript type conversions (parseFloat). -func (o *Object) Float() float64 { return o.object.Float() } - -// Interface returns the object converted to interface{}. See GopherJS' README for details. -func (o *Object) Interface() interface{} { return o.object.Interface() } - -// Unsafe returns the object as an uintptr, which can be converted via unsafe.Pointer. Not intended for public use. -func (o *Object) Unsafe() uintptr { return o.object.Unsafe() } - -// Error encapsulates JavaScript errors. Those are turned into a Go panic and may be recovered, giving an *Error that holds the JavaScript error object. -type Error struct { - *Object -} - -// Error returns the message of the encapsulated JavaScript error object. -func (err *Error) Error() string { - return "JavaScript error: " + err.Get("message").String() -} - -// Stack returns the stack property of the encapsulated JavaScript error object. -func (err *Error) Stack() string { - return err.Get("stack").String() -} - -// Global gives JavaScript's global object ("window" for browsers and "GLOBAL" for Node.js). -var Global *Object - -// Module gives the value of the "module" variable set by Node.js. Hint: Set a module export with 'js.Module.Get("exports").Set("exportName", ...)'. -var Module *Object - -// Undefined gives the JavaScript value "undefined". -var Undefined *Object - -// Debugger gets compiled to JavaScript's "debugger;" statement. -func Debugger() {} - -// InternalObject returns the internal JavaScript object that represents i. Not intended for public use. -func InternalObject(i interface{}) *Object { - return nil -} - -// MakeFunc wraps a function and gives access to the values of JavaScript's "this" and "arguments" keywords. -func MakeFunc(func(this *Object, arguments []*Object) interface{}) *Object { - return nil -} - -// Keys returns the keys of the given JavaScript object. -func Keys(o *Object) []string { - if o == nil || o == Undefined { - return nil - } - a := Global.Get("Object").Call("keys", o) - s := make([]string, a.Length()) - for i := 0; i < a.Length(); i++ { - s[i] = a.Index(i).String() - } - return s -} - -// MakeWrapper creates a JavaScript object which has wrappers for the exported methods of i. Use explicit getter and setter methods to expose struct fields to JavaScript. -func MakeWrapper(i interface{}) *Object { - v := InternalObject(i) - o := Global.Get("Object").New() - o.Set("__internal_object__", v) - methods := v.Get("constructor").Get("methods") - for i := 0; i < methods.Length(); i++ { - m := methods.Index(i) - if m.Get("pkg").String() != "" { // not exported - continue - } - o.Set(m.Get("name").String(), func(args ...*Object) *Object { - return Global.Call("$externalizeFunction", v.Get(m.Get("prop").String()), m.Get("typ"), true).Call("apply", v, args) - }) - } - return o -} - -// NewArrayBuffer creates a JavaScript ArrayBuffer from a byte slice. -func NewArrayBuffer(b []byte) *Object { - slice := InternalObject(b) - offset := slice.Get("$offset").Int() - length := slice.Get("$length").Int() - return slice.Get("$array").Get("buffer").Call("slice", offset, offset+length) -} - -// M is a simple map type. It is intended as a shorthand for JavaScript objects (before conversion). -type M map[string]interface{} - -// S is a simple slice type. It is intended as a shorthand for JavaScript arrays (before conversion). -type S []interface{} - -func init() { - // avoid dead code elimination - e := Error{} - _ = e -} diff --git a/Godeps/_workspace/src/github.com/jtolds/gls/LICENSE b/Godeps/_workspace/src/github.com/jtolds/gls/LICENSE deleted file mode 100644 index 9b4a822d92..0000000000 --- a/Godeps/_workspace/src/github.com/jtolds/gls/LICENSE +++ /dev/null @@ -1,18 +0,0 @@ -Copyright (c) 2013, Space Monkey, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Godeps/_workspace/src/github.com/jtolds/gls/README.md b/Godeps/_workspace/src/github.com/jtolds/gls/README.md deleted file mode 100644 index 4ebb692fb1..0000000000 --- a/Godeps/_workspace/src/github.com/jtolds/gls/README.md +++ /dev/null @@ -1,89 +0,0 @@ -gls -=== - -Goroutine local storage - -### IMPORTANT NOTE ### - -It is my duty to point you to https://blog.golang.org/context, which is how -Google solves all of the problems you'd perhaps consider using this package -for at scale. - -One downside to Google's approach is that *all* of your functions must have -a new first argument, but after clearing that hurdle everything else is much -better. - -If you aren't interested in this warning, read on. - -### Huhwaht? Why? ### - -Every so often, a thread shows up on the -[golang-nuts](https://groups.google.com/d/forum/golang-nuts) asking for some -form of goroutine-local-storage, or some kind of goroutine id, or some kind of -context. There are a few valid use cases for goroutine-local-storage, one of -the most prominent being log line context. One poster was interested in being -able to log an HTTP request context id in every log line in the same goroutine -as the incoming HTTP request, without having to change every library and -function call he was interested in logging. - -This would be pretty useful. Provided that you could get some kind of -goroutine-local-storage, you could call -[log.SetOutput](http://golang.org/pkg/log/#SetOutput) with your own logging -writer that checks goroutine-local-storage for some context information and -adds that context to your log lines. - -But alas, Andrew Gerrand's typically diplomatic answer to the question of -goroutine-local variables was: - -> We wouldn't even be having this discussion if thread local storage wasn't -> useful. But every feature comes at a cost, and in my opinion the cost of -> threadlocals far outweighs their benefits. They're just not a good fit for -> Go. - -So, yeah, that makes sense. That's a pretty good reason for why the language -won't support a specific and (relatively) unuseful feature that requires some -runtime changes, just for the sake of a little bit of log improvement. - -But does Go require runtime changes? - -### How it works ### - -Go has pretty fantastic introspective and reflective features, but one thing Go -doesn't give you is any kind of access to the stack pointer, or frame pointer, -or goroutine id, or anything contextual about your current stack. It gives you -access to your list of callers, but only along with program counters, which are -fixed at compile time. - -But it does give you the stack. - -So, we define 16 special functions and embed base-16 tags into the stack using -the call order of those 16 functions. Then, we can read our tags back out of -the stack looking at the callers list. - -We then use these tags as an index into a traditional map for implementing -this library. - -### What are people saying? ### - -"Wow, that's horrifying." - -"This is the most terrible thing I have seen in a very long time." - -"Where is it getting a context from? Is this serializing all the requests? -What the heck is the client being bound to? What are these tags? Why does he -need callers? Oh god no. No no no." - -### Docs ### - -Please see the docs at http://godoc.org/github.com/jtolds/gls - -### Related ### - -If you're okay relying on the string format of the current runtime stacktrace -including a unique goroutine id (not guaranteed by the spec or anything, but -very unlikely to change within a Go release), you might be able to squeeze -out a bit more performance by using this similar library, inspired by some -code Brad Fitzpatrick wrote for debugging his HTTP/2 library: -https://github.com/tylerb/gls (in contrast, jtolds/gls doesn't require -any knowledge of the string format of the runtime stacktrace, which -probably adds unnecessary overhead). diff --git a/Godeps/_workspace/src/github.com/jtolds/gls/context.go b/Godeps/_workspace/src/github.com/jtolds/gls/context.go deleted file mode 100644 index 90cfcf7db1..0000000000 --- a/Godeps/_workspace/src/github.com/jtolds/gls/context.go +++ /dev/null @@ -1,144 +0,0 @@ -// Package gls implements goroutine-local storage. -package gls - -import ( - "sync" -) - -const ( - maxCallers = 64 -) - -var ( - stackTagPool = &idPool{} - mgrRegistry = make(map[*ContextManager]bool) - mgrRegistryMtx sync.RWMutex -) - -// Values is simply a map of key types to value types. Used by SetValues to -// set multiple values at once. -type Values map[interface{}]interface{} - -// ContextManager is the main entrypoint for interacting with -// Goroutine-local-storage. You can have multiple independent ContextManagers -// at any given time. ContextManagers are usually declared globally for a given -// class of context variables. You should use NewContextManager for -// construction. -type ContextManager struct { - mtx sync.RWMutex - values map[uint]Values -} - -// NewContextManager returns a brand new ContextManager. It also registers the -// new ContextManager in the ContextManager registry which is used by the Go -// method. ContextManagers are typically defined globally at package scope. -func NewContextManager() *ContextManager { - mgr := &ContextManager{values: make(map[uint]Values)} - mgrRegistryMtx.Lock() - defer mgrRegistryMtx.Unlock() - mgrRegistry[mgr] = true - return mgr -} - -// Unregister removes a ContextManager from the global registry, used by the -// Go method. Only intended for use when you're completely done with a -// ContextManager. Use of Unregister at all is rare. -func (m *ContextManager) Unregister() { - mgrRegistryMtx.Lock() - defer mgrRegistryMtx.Unlock() - delete(mgrRegistry, m) -} - -// SetValues takes a collection of values and a function to call for those -// values to be set in. Anything further down the stack will have the set -// values available through GetValue. SetValues will add new values or replace -// existing values of the same key and will not mutate or change values for -// previous stack frames. -// SetValues is slow (makes a copy of all current and new values for the new -// gls-context) in order to reduce the amount of lookups GetValue requires. -func (m *ContextManager) SetValues(new_values Values, context_call func()) { - if len(new_values) == 0 { - context_call() - return - } - - tags := readStackTags(1) - - m.mtx.Lock() - values := new_values - for _, tag := range tags { - if existing_values, ok := m.values[tag]; ok { - // oh, we found existing values, let's make a copy - values = make(Values, len(existing_values)+len(new_values)) - for key, val := range existing_values { - values[key] = val - } - for key, val := range new_values { - values[key] = val - } - break - } - } - new_tag := stackTagPool.Acquire() - m.values[new_tag] = values - m.mtx.Unlock() - defer func() { - m.mtx.Lock() - delete(m.values, new_tag) - m.mtx.Unlock() - stackTagPool.Release(new_tag) - }() - - addStackTag(new_tag, context_call) -} - -// GetValue will return a previously set value, provided that the value was set -// by SetValues somewhere higher up the stack. If the value is not found, ok -// will be false. -func (m *ContextManager) GetValue(key interface{}) (value interface{}, ok bool) { - - tags := readStackTags(1) - m.mtx.RLock() - defer m.mtx.RUnlock() - for _, tag := range tags { - if values, ok := m.values[tag]; ok { - value, ok := values[key] - return value, ok - } - } - return "", false -} - -func (m *ContextManager) getValues() Values { - tags := readStackTags(2) - m.mtx.RLock() - defer m.mtx.RUnlock() - for _, tag := range tags { - if values, ok := m.values[tag]; ok { - return values - } - } - return nil -} - -// Go preserves ContextManager values and Goroutine-local-storage across new -// goroutine invocations. The Go method makes a copy of all existing values on -// all registered context managers and makes sure they are still set after -// kicking off the provided function in a new goroutine. If you don't use this -// Go method instead of the standard 'go' keyword, you will lose values in -// ContextManagers, as goroutines have brand new stacks. -func Go(cb func()) { - mgrRegistryMtx.RLock() - defer mgrRegistryMtx.RUnlock() - - for mgr, _ := range mgrRegistry { - values := mgr.getValues() - if len(values) > 0 { - mgr_copy := mgr - cb_copy := cb - cb = func() { mgr_copy.SetValues(values, cb_copy) } - } - } - - go cb() -} diff --git a/Godeps/_workspace/src/github.com/jtolds/gls/gen_sym.go b/Godeps/_workspace/src/github.com/jtolds/gls/gen_sym.go deleted file mode 100644 index 8d5fc24d4a..0000000000 --- a/Godeps/_workspace/src/github.com/jtolds/gls/gen_sym.go +++ /dev/null @@ -1,13 +0,0 @@ -package gls - -var ( - symPool = &idPool{} -) - -// ContextKey is a throwaway value you can use as a key to a ContextManager -type ContextKey struct{ id uint } - -// GenSym will return a brand new, never-before-used ContextKey -func GenSym() ContextKey { - return ContextKey{id: symPool.Acquire()} -} diff --git a/Godeps/_workspace/src/github.com/jtolds/gls/id_pool.go b/Godeps/_workspace/src/github.com/jtolds/gls/id_pool.go deleted file mode 100644 index b7974ae002..0000000000 --- a/Godeps/_workspace/src/github.com/jtolds/gls/id_pool.go +++ /dev/null @@ -1,34 +0,0 @@ -package gls - -// though this could probably be better at keeping ids smaller, the goal of -// this class is to keep a registry of the smallest unique integer ids -// per-process possible - -import ( - "sync" -) - -type idPool struct { - mtx sync.Mutex - released []uint - max_id uint -} - -func (p *idPool) Acquire() (id uint) { - p.mtx.Lock() - defer p.mtx.Unlock() - if len(p.released) > 0 { - id = p.released[len(p.released)-1] - p.released = p.released[:len(p.released)-1] - return id - } - id = p.max_id - p.max_id++ - return id -} - -func (p *idPool) Release(id uint) { - p.mtx.Lock() - defer p.mtx.Unlock() - p.released = append(p.released, id) -} diff --git a/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags.go b/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags.go deleted file mode 100644 index 9b8e39ba7c..0000000000 --- a/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags.go +++ /dev/null @@ -1,43 +0,0 @@ -package gls - -// so, basically, we're going to encode integer tags in base-16 on the stack - -const ( - bitWidth = 4 -) - -func addStackTag(tag uint, context_call func()) { - if context_call == nil { - return - } - markS(tag, context_call) -} - -func markS(tag uint, cb func()) { _m(tag, cb) } -func mark0(tag uint, cb func()) { _m(tag, cb) } -func mark1(tag uint, cb func()) { _m(tag, cb) } -func mark2(tag uint, cb func()) { _m(tag, cb) } -func mark3(tag uint, cb func()) { _m(tag, cb) } -func mark4(tag uint, cb func()) { _m(tag, cb) } -func mark5(tag uint, cb func()) { _m(tag, cb) } -func mark6(tag uint, cb func()) { _m(tag, cb) } -func mark7(tag uint, cb func()) { _m(tag, cb) } -func mark8(tag uint, cb func()) { _m(tag, cb) } -func mark9(tag uint, cb func()) { _m(tag, cb) } -func markA(tag uint, cb func()) { _m(tag, cb) } -func markB(tag uint, cb func()) { _m(tag, cb) } -func markC(tag uint, cb func()) { _m(tag, cb) } -func markD(tag uint, cb func()) { _m(tag, cb) } -func markE(tag uint, cb func()) { _m(tag, cb) } -func markF(tag uint, cb func()) { _m(tag, cb) } - -var pc_lookup = make(map[uintptr]int8, 17) -var mark_lookup [16]func(uint, func()) - -func _m(tag_remainder uint, cb func()) { - if tag_remainder == 0 { - cb() - } else { - mark_lookup[tag_remainder&0xf](tag_remainder>>bitWidth, cb) - } -} diff --git a/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags_js.go b/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags_js.go deleted file mode 100644 index 21d5595926..0000000000 --- a/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags_js.go +++ /dev/null @@ -1,101 +0,0 @@ -// +build js - -package gls - -// This file is used for GopherJS builds, which don't have normal runtime support - -import ( - "regexp" - "strconv" - "strings" - - "github.com/gopherjs/gopherjs/js" -) - -var stackRE = regexp.MustCompile("\\s+at (\\S*) \\([^:]+:(\\d+):(\\d+)") - -func findPtr() uintptr { - jsStack := js.Global.Get("Error").New().Get("stack").Call("split", "\n") - for i := 1; i < jsStack.Get("length").Int(); i++ { - item := jsStack.Index(i).String() - matches := stackRE.FindAllStringSubmatch(item, -1) - if matches == nil { - return 0 - } - pkgPath := matches[0][1] - if strings.HasPrefix(pkgPath, "$packages.github.com/jtolds/gls.mark") { - line, _ := strconv.Atoi(matches[0][2]) - char, _ := strconv.Atoi(matches[0][3]) - x := (uintptr(line) << 16) | uintptr(char) - return x - } - } - - return 0 -} - -func init() { - setEntries := func(f func(uint, func()), v int8) { - var ptr uintptr - f(0, func() { - ptr = findPtr() - }) - pc_lookup[ptr] = v - if v >= 0 { - mark_lookup[v] = f - } - } - setEntries(markS, -0x1) - setEntries(mark0, 0x0) - setEntries(mark1, 0x1) - setEntries(mark2, 0x2) - setEntries(mark3, 0x3) - setEntries(mark4, 0x4) - setEntries(mark5, 0x5) - setEntries(mark6, 0x6) - setEntries(mark7, 0x7) - setEntries(mark8, 0x8) - setEntries(mark9, 0x9) - setEntries(markA, 0xa) - setEntries(markB, 0xb) - setEntries(markC, 0xc) - setEntries(markD, 0xd) - setEntries(markE, 0xe) - setEntries(markF, 0xf) -} - -func currentStack(skip int) (stack []uintptr) { - jsStack := js.Global.Get("Error").New().Get("stack").Call("split", "\n") - for i := skip + 2; i < jsStack.Get("length").Int(); i++ { - item := jsStack.Index(i).String() - matches := stackRE.FindAllStringSubmatch(item, -1) - if matches == nil { - return stack - } - line, _ := strconv.Atoi(matches[0][2]) - char, _ := strconv.Atoi(matches[0][3]) - x := (uintptr(line) << 16) | uintptr(char)&0xffff - stack = append(stack, x) - } - - return stack -} - -func readStackTags(skip int) (tags []uint) { - stack := currentStack(skip) - var current_tag uint - for _, pc := range stack { - val, ok := pc_lookup[pc] - if !ok { - continue - } - if val < 0 { - tags = append(tags, current_tag) - current_tag = 0 - continue - } - current_tag <<= bitWidth - current_tag += uint(val) - } - return -} diff --git a/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags_main.go b/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags_main.go deleted file mode 100644 index cb302b9ef6..0000000000 --- a/Godeps/_workspace/src/github.com/jtolds/gls/stack_tags_main.go +++ /dev/null @@ -1,61 +0,0 @@ -// +build !js - -package gls - -// This file is used for standard Go builds, which have the expected runtime support - -import ( - "reflect" - "runtime" -) - -func init() { - setEntries := func(f func(uint, func()), v int8) { - pc_lookup[reflect.ValueOf(f).Pointer()] = v - if v >= 0 { - mark_lookup[v] = f - } - } - setEntries(markS, -0x1) - setEntries(mark0, 0x0) - setEntries(mark1, 0x1) - setEntries(mark2, 0x2) - setEntries(mark3, 0x3) - setEntries(mark4, 0x4) - setEntries(mark5, 0x5) - setEntries(mark6, 0x6) - setEntries(mark7, 0x7) - setEntries(mark8, 0x8) - setEntries(mark9, 0x9) - setEntries(markA, 0xa) - setEntries(markB, 0xb) - setEntries(markC, 0xc) - setEntries(markD, 0xd) - setEntries(markE, 0xe) - setEntries(markF, 0xf) -} - -func currentStack(skip int) []uintptr { - stack := make([]uintptr, maxCallers) - return stack[:runtime.Callers(3+skip, stack)] -} - -func readStackTags(skip int) (tags []uint) { - stack := currentStack(skip) - var current_tag uint - for _, pc := range stack { - pc = runtime.FuncForPC(pc).Entry() - val, ok := pc_lookup[pc] - if !ok { - continue - } - if val < 0 { - tags = append(tags, current_tag) - current_tag = 0 - continue - } - current_tag <<= bitWidth - current_tag += uint(val) - } - return -} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_linux.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_linux.go index 975b75c072..f7cf4c3649 100644 --- a/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_linux.go +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_linux.go @@ -121,7 +121,7 @@ func Info() ([]InfoStat, error) { return ret, err } c.CPU = int32(t) - case "vendorId", "vendor_id": + case "vendorId": c.VendorID = value case "cpu family": c.Family = value diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process.go index 4b69224340..2b9d6854ee 100644 --- a/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process.go +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process.go @@ -20,7 +20,6 @@ type Process struct { Pid int32 `json:"pid"` name string status string - parent int32 numCtxSwitches *NumCtxSwitchesStat uids []int32 gids []int32 diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_linux.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_linux.go index ae300412c2..e79ba36edd 100644 --- a/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_linux.go +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_linux.go @@ -9,6 +9,7 @@ import ( "fmt" "io/ioutil" "os" + "os/exec" "path/filepath" "strconv" "strings" @@ -56,7 +57,6 @@ type MemoryMapsStat struct { Swap uint64 `json:"swap"` } -// String returns JSON value of the process. func (m MemoryMapsStat) String() string { s, _ := json.Marshal(m) return string(s) @@ -75,7 +75,6 @@ func NewProcess(pid int32) (*Process, error) { return p, err } -// Ppid returns Parent Process ID of the process. func (p *Process) Ppid() (int32, error) { _, ppid, _, _, _, err := p.fillFromStat() if err != nil { @@ -83,8 +82,6 @@ func (p *Process) Ppid() (int32, error) { } return ppid, nil } - -// Name returns name of the process. func (p *Process) Name() (string, error) { if p.name == "" { if err := p.fillFromStatus(); err != nil { @@ -93,8 +90,6 @@ func (p *Process) Name() (string, error) { } return p.name, nil } - -// Exe returns executable path of the process. func (p *Process) Exe() (string, error) { return p.fillFromExe() } @@ -111,7 +106,6 @@ func (p *Process) CmdlineSlice() ([]string, error) { return p.fillSliceFromCmdline() } -// CreateTime returns created time of the process in seconds since the epoch, in UTC. func (p *Process) CreateTime() (int64, error) { _, _, _, createTime, _, err := p.fillFromStat() if err != nil { @@ -120,28 +114,23 @@ func (p *Process) CreateTime() (int64, error) { return createTime, nil } -// Cwd returns current working directory of the process. func (p *Process) Cwd() (string, error) { return p.fillFromCwd() } - -// Parent returns parent Process of the process. func (p *Process) Parent() (*Process, error) { - err := p.fillFromStatus() + r, err := callLsof("R", p.Pid) if err != nil { return nil, err } - if p.parent == 0 { + if len(r) != 1 { // TODO: pid 1 return nil, fmt.Errorf("wrong number of parents") } - return NewProcess(p.parent) + v, err := strconv.Atoi(r[0]) + if err != nil { + return nil, err + } + return NewProcess(int32(v)) } - -// Status returns the process status. -// Return value could be one of these. -// R: Running S: Sleep T: Stop I: Idle -// Z: Zombie W: Wait L: Lock -// The charactor is same within all supported platforms. func (p *Process) Status() (string, error) { err := p.fillFromStatus() if err != nil { @@ -149,8 +138,6 @@ func (p *Process) Status() (string, error) { } return p.status, nil } - -// Uids returns user ids of the process as a slice of the int func (p *Process) Uids() ([]int32, error) { err := p.fillFromStatus() if err != nil { @@ -158,8 +145,6 @@ func (p *Process) Uids() ([]int32, error) { } return p.uids, nil } - -// Gids returns group ids of the process as a slice of the int func (p *Process) Gids() ([]int32, error) { err := p.fillFromStatus() if err != nil { @@ -167,8 +152,6 @@ func (p *Process) Gids() ([]int32, error) { } return p.gids, nil } - -// Terminal returns a terminal which is associated with the process. func (p *Process) Terminal() (string, error) { terminal, _, _, _, _, err := p.fillFromStat() if err != nil { @@ -176,9 +159,6 @@ func (p *Process) Terminal() (string, error) { } return terminal, nil } - -// Nice returns a nice value (priority). -// Notice: gopsutil can not set nice value. func (p *Process) Nice() (int32, error) { _, _, _, _, nice, err := p.fillFromStat() if err != nil { @@ -186,23 +166,15 @@ func (p *Process) Nice() (int32, error) { } return nice, nil } - -// IOnice returns process I/O nice value (priority). func (p *Process) IOnice() (int32, error) { return 0, common.ErrNotImplementedError } - -// Rlimit returns Resource Limits. func (p *Process) Rlimit() ([]RlimitStat, error) { return nil, common.ErrNotImplementedError } - -// IOCounters returns IO Counters. func (p *Process) IOCounters() (*IOCountersStat, error) { return p.fillFromIO() } - -// NumCtxSwitches returns the number of the context switches of the process. func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) { err := p.fillFromStatus() if err != nil { @@ -210,14 +182,10 @@ func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) { } return p.numCtxSwitches, nil } - -// NumFDs returns the number of File Descriptors used by the process. func (p *Process) NumFDs() (int32, error) { numFds, _, err := p.fillFromfd() return numFds, err } - -// NumThreads returns the number of threads used by the process. func (p *Process) NumThreads() (int32, error) { err := p.fillFromStatus() if err != nil { @@ -225,16 +193,10 @@ func (p *Process) NumThreads() (int32, error) { } return p.numThreads, nil } - -// Threads returns a map of threads -// -// Notice: Not implemented yet. always returns empty map. func (p *Process) Threads() (map[string]string, error) { ret := make(map[string]string, 0) return ret, nil } - -// Times returns CPU times of the process. func (p *Process) Times() (*cpu.TimesStat, error) { _, _, cpuTimes, _, _, err := p.fillFromStat() if err != nil { @@ -242,15 +204,9 @@ func (p *Process) Times() (*cpu.TimesStat, error) { } return cpuTimes, nil } - -// CPUAffinity returns CPU affinity of the process. -// -// Notice: Not implemented yet. func (p *Process) CPUAffinity() ([]int32, error) { return nil, common.ErrNotImplementedError } - -// MemoryInfo returns platform in-dependend memory information, such as RSS, VMS and Swap func (p *Process) MemoryInfo() (*MemoryInfoStat, error) { meminfo, _, err := p.fillFromStatm() if err != nil { @@ -258,8 +214,6 @@ func (p *Process) MemoryInfo() (*MemoryInfoStat, error) { } return meminfo, nil } - -// MemoryInfoEx returns platform dependend memory information. func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) { _, memInfoEx, err := p.fillFromStatm() if err != nil { @@ -268,7 +222,6 @@ func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) { return memInfoEx, nil } -// Children returns a slice of Process of the process. func (p *Process) Children() ([]*Process, error) { pids, err := common.CallPgrep(invoke, p.Pid) if err != nil { @@ -288,8 +241,6 @@ func (p *Process) Children() ([]*Process, error) { return ret, nil } -// OpenFiles returns a slice of OpenFilesStat opend by the process. -// OpenFilesStat includes a file path and file descriptor. func (p *Process) OpenFiles() ([]OpenFilesStat, error) { _, ofs, err := p.fillFromfd() if err != nil { @@ -303,20 +254,15 @@ func (p *Process) OpenFiles() ([]OpenFilesStat, error) { return ret, nil } -// Connections returns a slice of net.ConnectionStat used by the process. -// This returns all kind of the connection. This measn TCP, UDP or UNIX. func (p *Process) Connections() ([]net.ConnectionStat, error) { return net.ConnectionsPid("all", p.Pid) } -// NetIOCounters returns NetIOCounters of the process. func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error) { filename := common.HostProc(strconv.Itoa(int(p.Pid)), "net/dev") return net.IOCountersByFile(pernic, filename) } -// IsRunning returns whether the process is running or not. -// Not implemented yet. func (p *Process) IsRunning() (bool, error) { return true, common.ErrNotImplementedError } @@ -611,12 +557,6 @@ func (p *Process) fillFromStatus() error { p.name = strings.Trim(value, " \t") case "State": p.status = value[0:1] - case "PPid", "Ppid": - pval, err := strconv.ParseInt(value, 10, 32) - if err != nil { - return err - } - p.parent = int32(pval) case "Uid": p.uids = make([]int32, 0, 4) for _, i := range strings.Split(value, "\t") { @@ -740,7 +680,6 @@ func (p *Process) fillFromStat() (string, int32, *cpu.TimesStat, int64, int32, e return terminal, int32(ppid), cpuTimes, createTime, nice, nil } -// Pids returns a slice of process ID list which are running now. func Pids() ([]int32, error) { var ret []int32 @@ -765,3 +704,30 @@ func Pids() ([]int32, error) { return ret, nil } + +func callLsof(arg string, pid int32) ([]string, error) { + var cmd []string + if pid == 0 { // will get from all processes. + cmd = []string{"-F" + arg} + } else { + cmd = []string{"-a", "-F" + arg, "-p", strconv.Itoa(int(pid))} + } + lsof, err := exec.LookPath("lsof") + if err != nil { + return []string{}, err + } + out, err := invoke.Command(lsof, cmd...) + if err != nil { + return []string{}, err + } + lines := strings.Split(string(out), "\n") + + var ret []string + for _, l := range lines[1:] { + if strings.HasPrefix(l, arg) { + ret = append(ret, l[1:]) // delete first char + } + } + + return ret, nil +} diff --git a/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_posix.go b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_posix.go index 8853118ac6..92353b8c5d 100644 --- a/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_posix.go +++ b/Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_posix.go @@ -51,8 +51,6 @@ func getTerminalMap() (map[uint64]string, error) { return ret, nil } -// SendSignal sends a syscall.Signal to the process. -// Currently, SIGSTOP, SIGCONT, SIGTERM and SIGKILL are supported. func (p *Process) SendSignal(sig syscall.Signal) error { sigAsStr := "INT" switch sig { @@ -80,27 +78,18 @@ func (p *Process) SendSignal(sig syscall.Signal) error { return nil } -// Suspend sends SIGSTOP to the process. func (p *Process) Suspend() error { return p.SendSignal(syscall.SIGSTOP) } - -// Resume sends SIGCONT to the process. func (p *Process) Resume() error { return p.SendSignal(syscall.SIGCONT) } - -// Terminate sends SIGTERM to the process. func (p *Process) Terminate() error { return p.SendSignal(syscall.SIGTERM) } - -// Kill sends SIGKILL to the process. func (p *Process) Kill() error { return p.SendSignal(syscall.SIGKILL) } - -// Username returns a username of the process. func (p *Process) Username() (string, error) { uids, err := p.Uids() if err != nil { diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/.gitignore b/Godeps/_workspace/src/github.com/smartystreets/assertions/.gitignore deleted file mode 100644 index 6ad551742d..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.DS_Store -Thumbs.db -/.idea diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/.travis.yml b/Godeps/_workspace/src/github.com/smartystreets/assertions/.travis.yml deleted file mode 100644 index 44217c9733..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: go - -go: - - 1.2 - - 1.3 - - 1.4 - - 1.5 - -install: - - go get -t ./... - -script: go test -v - -sudo: false diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/CONTRIBUTING.md b/Godeps/_workspace/src/github.com/smartystreets/assertions/CONTRIBUTING.md deleted file mode 100644 index 1820ecb331..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/CONTRIBUTING.md +++ /dev/null @@ -1,12 +0,0 @@ -# Contributing - -In general, the code posted to the [SmartyStreets github organization](https://github.com/smartystreets) is created to solve specific problems at SmartyStreets that are ancillary to our core products in the address verification industry and may or may not be useful to other organizations or developers. Our reason for posting said code isn't necessarily to solicit feedback or contributions from the community but more as a showcase of some of the approaches to solving problems we have adopted. - -Having stated that, we do consider issues raised by other githubbers as well as contributions submitted via pull requests. When submitting such a pull request, please follow these guidelines: - -- _Look before you leap:_ If the changes you plan to make are significant, it's in everyone's best interest for you to discuss them with a SmartyStreets team member prior to opening a pull request. -- _License and ownership:_ If modifying the `LICENSE.md` file, limit your changes to fixing typographical mistakes. Do NOT modify the actual terms in the license or the copyright by **SmartyStreets, LLC**. Code submitted to SmartyStreets projects becomes property of SmartyStreets and must be compatible with the associated license. -- _Testing:_ If the code you are submitting resides in packages/modules covered by automated tests, be sure to add passing tests that cover your changes and assert expected behavior and state. Submit the additional test cases as part of your change set. -- _Style:_ Match your approach to **naming** and **formatting** with the surrounding code. Basically, the code you submit shouldn't stand out. - - "Naming" refers to such constructs as variables, methods, functions, classes, structs, interfaces, packages, modules, directories, files, etc... - - "Formatting" refers to such constructs as whitespace, horizontal line length, vertical function length, vertical file length, indentation, curly braces, etc... diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/LICENSE.md b/Godeps/_workspace/src/github.com/smartystreets/assertions/LICENSE.md deleted file mode 100644 index 8ea6f94552..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/LICENSE.md +++ /dev/null @@ -1,23 +0,0 @@ -Copyright (c) 2016 SmartyStreets, LLC - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -NOTE: Various optional and subordinate components carry their own licensing -requirements and restrictions. Use of those components is subject to the terms -and conditions outlined the respective license of each component. diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/README.md b/Godeps/_workspace/src/github.com/smartystreets/assertions/README.md deleted file mode 100644 index 58383bb00a..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/README.md +++ /dev/null @@ -1,575 +0,0 @@ -# assertions --- - import "github.com/smartystreets/assertions" - -Package assertions contains the implementations for all assertions which are -referenced in goconvey's `convey` package -(github.com/smartystreets/goconvey/convey) and gunit -(github.com/smartystreets/gunit) for use with the So(...) method. They can also -be used in traditional Go test functions and even in applications. - -Many of the assertions lean heavily on work done by Aaron Jacobs in his -excellent oglematchers library. (https://github.com/jacobsa/oglematchers) The -ShouldResemble assertion leans heavily on work done by Daniel Jacques in his -very helpful go-render library. (https://github.com/luci/go-render) - -## Usage - -#### func GoConveyMode - -```go -func GoConveyMode(yes bool) -``` -GoConveyMode provides control over JSON serialization of failures. When using -the assertions in this package from the convey package JSON results are very -helpful and can be rendered in a DIFF view. In that case, this function will be -called with a true value to enable the JSON serialization. By default, the -assertions in this package will not serializer a JSON result, making standalone -ussage more convenient. - -#### func ShouldAlmostEqual - -```go -func ShouldAlmostEqual(actual interface{}, expected ...interface{}) string -``` -ShouldAlmostEqual makes sure that two parameters are close enough to being -equal. The acceptable delta may be specified with a third argument, or a very -small default delta will be used. - -#### func ShouldBeBetween - -```go -func ShouldBeBetween(actual interface{}, expected ...interface{}) string -``` -ShouldBeBetween receives exactly three parameters: an actual value, a lower -bound, and an upper bound. It ensures that the actual value is between both -bounds (but not equal to either of them). - -#### func ShouldBeBetweenOrEqual - -```go -func ShouldBeBetweenOrEqual(actual interface{}, expected ...interface{}) string -``` -ShouldBeBetweenOrEqual receives exactly three parameters: an actual value, a -lower bound, and an upper bound. It ensures that the actual value is between -both bounds or equal to one of them. - -#### func ShouldBeBlank - -```go -func ShouldBeBlank(actual interface{}, expected ...interface{}) string -``` -ShouldBeBlank receives exactly 1 string parameter and ensures that it is equal -to "". - -#### func ShouldBeChronological - -```go -func ShouldBeChronological(actual interface{}, expected ...interface{}) string -``` -ShouldBeChronological receives a []time.Time slice and asserts that the are in -chronological order starting with the first time.Time as the earliest. - -#### func ShouldBeEmpty - -```go -func ShouldBeEmpty(actual interface{}, expected ...interface{}) string -``` -ShouldBeEmpty receives a single parameter (actual) and determines whether or not -calling len(actual) would return `0`. It obeys the rules specified by the len -function for determining length: http://golang.org/pkg/builtin/#len - -#### func ShouldBeFalse - -```go -func ShouldBeFalse(actual interface{}, expected ...interface{}) string -``` -ShouldBeFalse receives a single parameter and ensures that it is false. - -#### func ShouldBeGreaterThan - -```go -func ShouldBeGreaterThan(actual interface{}, expected ...interface{}) string -``` -ShouldBeGreaterThan receives exactly two parameters and ensures that the first -is greater than the second. - -#### func ShouldBeGreaterThanOrEqualTo - -```go -func ShouldBeGreaterThanOrEqualTo(actual interface{}, expected ...interface{}) string -``` -ShouldBeGreaterThanOrEqualTo receives exactly two parameters and ensures that -the first is greater than or equal to the second. - -#### func ShouldBeIn - -```go -func ShouldBeIn(actual interface{}, expected ...interface{}) string -``` -ShouldBeIn receives at least 2 parameters. The first is a proposed member of the -collection that is passed in either as the second parameter, or of the -collection that is comprised of all the remaining parameters. This assertion -ensures that the proposed member is in the collection (using ShouldEqual). - -#### func ShouldBeLessThan - -```go -func ShouldBeLessThan(actual interface{}, expected ...interface{}) string -``` -ShouldBeLessThan receives exactly two parameters and ensures that the first is -less than the second. - -#### func ShouldBeLessThanOrEqualTo - -```go -func ShouldBeLessThanOrEqualTo(actual interface{}, expected ...interface{}) string -``` -ShouldBeLessThan receives exactly two parameters and ensures that the first is -less than or equal to the second. - -#### func ShouldBeNil - -```go -func ShouldBeNil(actual interface{}, expected ...interface{}) string -``` -ShouldBeNil receives a single parameter and ensures that it is nil. - -#### func ShouldBeTrue - -```go -func ShouldBeTrue(actual interface{}, expected ...interface{}) string -``` -ShouldBeTrue receives a single parameter and ensures that it is true. - -#### func ShouldBeZeroValue - -```go -func ShouldBeZeroValue(actual interface{}, expected ...interface{}) string -``` -ShouldBeZeroValue receives a single parameter and ensures that it is the Go -equivalent of the default value, or "zero" value. - -#### func ShouldContain - -```go -func ShouldContain(actual interface{}, expected ...interface{}) string -``` -ShouldContain receives exactly two parameters. The first is a slice and the -second is a proposed member. Membership is determined using ShouldEqual. - -#### func ShouldContainKey - -```go -func ShouldContainKey(actual interface{}, expected ...interface{}) string -``` -ShouldContainKey receives exactly two parameters. The first is a map and the -second is a proposed key. Keys are compared with a simple '=='. - -#### func ShouldContainSubstring - -```go -func ShouldContainSubstring(actual interface{}, expected ...interface{}) string -``` -ShouldContainSubstring receives exactly 2 string parameters and ensures that the -first contains the second as a substring. - -#### func ShouldEndWith - -```go -func ShouldEndWith(actual interface{}, expected ...interface{}) string -``` -ShouldEndWith receives exactly 2 string parameters and ensures that the first -ends with the second. - -#### func ShouldEqual - -```go -func ShouldEqual(actual interface{}, expected ...interface{}) string -``` -ShouldEqual receives exactly two parameters and does an equality check. - -#### func ShouldEqualTrimSpace - -```go -func ShouldEqualTrimSpace(actual interface{}, expected ...interface{}) string -``` -ShouldEqualTrimSpace receives exactly 2 string parameters and ensures that the -first is equal to the second after removing all leading and trailing whitespace -using strings.TrimSpace(first). - -#### func ShouldEqualWithout - -```go -func ShouldEqualWithout(actual interface{}, expected ...interface{}) string -``` -ShouldEqualWithout receives exactly 3 string parameters and ensures that the -first is equal to the second after removing all instances of the third from the -first using strings.Replace(first, third, "", -1). - -#### func ShouldHappenAfter - -```go -func ShouldHappenAfter(actual interface{}, expected ...interface{}) string -``` -ShouldHappenAfter receives exactly 2 time.Time arguments and asserts that the -first happens after the second. - -#### func ShouldHappenBefore - -```go -func ShouldHappenBefore(actual interface{}, expected ...interface{}) string -``` -ShouldHappenBefore receives exactly 2 time.Time arguments and asserts that the -first happens before the second. - -#### func ShouldHappenBetween - -```go -func ShouldHappenBetween(actual interface{}, expected ...interface{}) string -``` -ShouldHappenBetween receives exactly 3 time.Time arguments and asserts that the -first happens between (not on) the second and third. - -#### func ShouldHappenOnOrAfter - -```go -func ShouldHappenOnOrAfter(actual interface{}, expected ...interface{}) string -``` -ShouldHappenOnOrAfter receives exactly 2 time.Time arguments and asserts that -the first happens on or after the second. - -#### func ShouldHappenOnOrBefore - -```go -func ShouldHappenOnOrBefore(actual interface{}, expected ...interface{}) string -``` -ShouldHappenOnOrBefore receives exactly 2 time.Time arguments and asserts that -the first happens on or before the second. - -#### func ShouldHappenOnOrBetween - -```go -func ShouldHappenOnOrBetween(actual interface{}, expected ...interface{}) string -``` -ShouldHappenOnOrBetween receives exactly 3 time.Time arguments and asserts that -the first happens between or on the second and third. - -#### func ShouldHappenWithin - -```go -func ShouldHappenWithin(actual interface{}, expected ...interface{}) string -``` -ShouldHappenWithin receives a time.Time, a time.Duration, and a time.Time (3 -arguments) and asserts that the first time.Time happens within or on the -duration specified relative to the other time.Time. - -#### func ShouldHaveLength - -```go -func ShouldHaveLength(actual interface{}, expected ...interface{}) string -``` -ShouldHaveLength receives 2 parameters. The first is a collection to check the -length of, the second being the expected length. It obeys the rules specified by -the len function for determining length: http://golang.org/pkg/builtin/#len - -#### func ShouldHaveSameTypeAs - -```go -func ShouldHaveSameTypeAs(actual interface{}, expected ...interface{}) string -``` -ShouldHaveSameTypeAs receives exactly two parameters and compares their -underlying types for equality. - -#### func ShouldImplement - -```go -func ShouldImplement(actual interface{}, expectedList ...interface{}) string -``` -ShouldImplement receives exactly two parameters and ensures that the first -implements the interface type of the second. - -#### func ShouldNotAlmostEqual - -```go -func ShouldNotAlmostEqual(actual interface{}, expected ...interface{}) string -``` -ShouldNotAlmostEqual is the inverse of ShouldAlmostEqual - -#### func ShouldNotBeBetween - -```go -func ShouldNotBeBetween(actual interface{}, expected ...interface{}) string -``` -ShouldNotBeBetween receives exactly three parameters: an actual value, a lower -bound, and an upper bound. It ensures that the actual value is NOT between both -bounds. - -#### func ShouldNotBeBetweenOrEqual - -```go -func ShouldNotBeBetweenOrEqual(actual interface{}, expected ...interface{}) string -``` -ShouldNotBeBetweenOrEqual receives exactly three parameters: an actual value, a -lower bound, and an upper bound. It ensures that the actual value is nopt -between the bounds nor equal to either of them. - -#### func ShouldNotBeBlank - -```go -func ShouldNotBeBlank(actual interface{}, expected ...interface{}) string -``` -ShouldNotBeBlank receives exactly 1 string parameter and ensures that it is -equal to "". - -#### func ShouldNotBeEmpty - -```go -func ShouldNotBeEmpty(actual interface{}, expected ...interface{}) string -``` -ShouldNotBeEmpty receives a single parameter (actual) and determines whether or -not calling len(actual) would return a value greater than zero. It obeys the -rules specified by the `len` function for determining length: -http://golang.org/pkg/builtin/#len - -#### func ShouldNotBeIn - -```go -func ShouldNotBeIn(actual interface{}, expected ...interface{}) string -``` -ShouldNotBeIn receives at least 2 parameters. The first is a proposed member of -the collection that is passed in either as the second parameter, or of the -collection that is comprised of all the remaining parameters. This assertion -ensures that the proposed member is NOT in the collection (using ShouldEqual). - -#### func ShouldNotBeNil - -```go -func ShouldNotBeNil(actual interface{}, expected ...interface{}) string -``` -ShouldNotBeNil receives a single parameter and ensures that it is not nil. - -#### func ShouldNotContain - -```go -func ShouldNotContain(actual interface{}, expected ...interface{}) string -``` -ShouldNotContain receives exactly two parameters. The first is a slice and the -second is a proposed member. Membership is determinied using ShouldEqual. - -#### func ShouldNotContainKey - -```go -func ShouldNotContainKey(actual interface{}, expected ...interface{}) string -``` -ShouldNotContainKey receives exactly two parameters. The first is a map and the -second is a proposed absent key. Keys are compared with a simple '=='. - -#### func ShouldNotContainSubstring - -```go -func ShouldNotContainSubstring(actual interface{}, expected ...interface{}) string -``` -ShouldNotContainSubstring receives exactly 2 string parameters and ensures that -the first does NOT contain the second as a substring. - -#### func ShouldNotEndWith - -```go -func ShouldNotEndWith(actual interface{}, expected ...interface{}) string -``` -ShouldEndWith receives exactly 2 string parameters and ensures that the first -does not end with the second. - -#### func ShouldNotEqual - -```go -func ShouldNotEqual(actual interface{}, expected ...interface{}) string -``` -ShouldNotEqual receives exactly two parameters and does an inequality check. - -#### func ShouldNotHappenOnOrBetween - -```go -func ShouldNotHappenOnOrBetween(actual interface{}, expected ...interface{}) string -``` -ShouldNotHappenOnOrBetween receives exactly 3 time.Time arguments and asserts -that the first does NOT happen between or on the second or third. - -#### func ShouldNotHappenWithin - -```go -func ShouldNotHappenWithin(actual interface{}, expected ...interface{}) string -``` -ShouldNotHappenWithin receives a time.Time, a time.Duration, and a time.Time (3 -arguments) and asserts that the first time.Time does NOT happen within or on the -duration specified relative to the other time.Time. - -#### func ShouldNotHaveSameTypeAs - -```go -func ShouldNotHaveSameTypeAs(actual interface{}, expected ...interface{}) string -``` -ShouldNotHaveSameTypeAs receives exactly two parameters and compares their -underlying types for inequality. - -#### func ShouldNotImplement - -```go -func ShouldNotImplement(actual interface{}, expectedList ...interface{}) string -``` -ShouldNotImplement receives exactly two parameters and ensures that the first -does NOT implement the interface type of the second. - -#### func ShouldNotPanic - -```go -func ShouldNotPanic(actual interface{}, expected ...interface{}) (message string) -``` -ShouldNotPanic receives a void, niladic function and expects to execute the -function without any panic. - -#### func ShouldNotPanicWith - -```go -func ShouldNotPanicWith(actual interface{}, expected ...interface{}) (message string) -``` -ShouldNotPanicWith receives a void, niladic function and expects to recover a -panic whose content differs from the second argument. - -#### func ShouldNotPointTo - -```go -func ShouldNotPointTo(actual interface{}, expected ...interface{}) string -``` -ShouldNotPointTo receives exactly two parameters and checks to see that they -point to different addresess. - -#### func ShouldNotResemble - -```go -func ShouldNotResemble(actual interface{}, expected ...interface{}) string -``` -ShouldNotResemble receives exactly two parameters and does an inverse deep equal -check (see reflect.DeepEqual) - -#### func ShouldNotStartWith - -```go -func ShouldNotStartWith(actual interface{}, expected ...interface{}) string -``` -ShouldNotStartWith receives exactly 2 string parameters and ensures that the -first does not start with the second. - -#### func ShouldPanic - -```go -func ShouldPanic(actual interface{}, expected ...interface{}) (message string) -``` -ShouldPanic receives a void, niladic function and expects to recover a panic. - -#### func ShouldPanicWith - -```go -func ShouldPanicWith(actual interface{}, expected ...interface{}) (message string) -``` -ShouldPanicWith receives a void, niladic function and expects to recover a panic -with the second argument as the content. - -#### func ShouldPointTo - -```go -func ShouldPointTo(actual interface{}, expected ...interface{}) string -``` -ShouldPointTo receives exactly two parameters and checks to see that they point -to the same address. - -#### func ShouldResemble - -```go -func ShouldResemble(actual interface{}, expected ...interface{}) string -``` -ShouldResemble receives exactly two parameters and does a deep equal check (see -reflect.DeepEqual) - -#### func ShouldStartWith - -```go -func ShouldStartWith(actual interface{}, expected ...interface{}) string -``` -ShouldStartWith receives exactly 2 string parameters and ensures that the first -starts with the second. - -#### func So - -```go -func So(actual interface{}, assert assertion, expected ...interface{}) (bool, string) -``` -So is a convenience function (as opposed to an inconvenience function?) for -running assertions on arbitrary arguments in any context, be it for testing or -even application logging. It allows you to perform assertion-like behavior (and -get nicely formatted messages detailing discrepancies) but without the program -blowing up or panicking. All that is required is to import this package and call -`So` with one of the assertions exported by this package as the second -parameter. The first return parameter is a boolean indicating if the assertion -was true. The second return parameter is the well-formatted message showing why -an assertion was incorrect, or blank if the assertion was correct. - -Example: - - if ok, message := So(x, ShouldBeGreaterThan, y); !ok { - log.Println(message) - } - -#### type Assertion - -```go -type Assertion struct { -} -``` - - -#### func New - -```go -func New(t testingT) *Assertion -``` -New swallows the *testing.T struct and prints failed assertions using t.Error. -Example: assertions.New(t).So(1, should.Equal, 1) - -#### func (*Assertion) Failed - -```go -func (this *Assertion) Failed() bool -``` -Failed reports whether any calls to So (on this Assertion instance) have failed. - -#### func (*Assertion) So - -```go -func (this *Assertion) So(actual interface{}, assert assertion, expected ...interface{}) bool -``` -So calls the standalone So function and additionally, calls t.Error in failure -scenarios. - -#### type FailureView - -```go -type FailureView struct { - Message string `json:"Message"` - Expected string `json:"Expected"` - Actual string `json:"Actual"` -} -``` - -This struct is also declared in -github.com/smartystreets/goconvey/convey/reporting. The json struct tags should -be equal in both declarations. - -#### type Serializer - -```go -type Serializer interface { - // contains filtered or unexported methods -} -``` diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/assertions.goconvey b/Godeps/_workspace/src/github.com/smartystreets/assertions/assertions.goconvey deleted file mode 100644 index e76cf275d4..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/assertions.goconvey +++ /dev/null @@ -1,3 +0,0 @@ -#ignore --timeout=1s --coverpkg=github.com/smartystreets/assertions,github.com/smartystreets/assertions/internal/oglematchers \ No newline at end of file diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/collections.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/collections.go deleted file mode 100644 index d7f407e913..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/collections.go +++ /dev/null @@ -1,244 +0,0 @@ -package assertions - -import ( - "fmt" - "reflect" - - "github.com/smartystreets/assertions/internal/oglematchers" -) - -// ShouldContain receives exactly two parameters. The first is a slice and the -// second is a proposed member. Membership is determined using ShouldEqual. -func ShouldContain(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - if matchError := oglematchers.Contains(expected[0]).Matches(actual); matchError != nil { - typeName := reflect.TypeOf(actual) - - if fmt.Sprintf("%v", matchError) == "which is not a slice or array" { - return fmt.Sprintf(shouldHaveBeenAValidCollection, typeName) - } - return fmt.Sprintf(shouldHaveContained, typeName, expected[0]) - } - return success -} - -// ShouldNotContain receives exactly two parameters. The first is a slice and the -// second is a proposed member. Membership is determinied using ShouldEqual. -func ShouldNotContain(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - typeName := reflect.TypeOf(actual) - - if matchError := oglematchers.Contains(expected[0]).Matches(actual); matchError != nil { - if fmt.Sprintf("%v", matchError) == "which is not a slice or array" { - return fmt.Sprintf(shouldHaveBeenAValidCollection, typeName) - } - return success - } - return fmt.Sprintf(shouldNotHaveContained, typeName, expected[0]) -} - -// ShouldContainKey receives exactly two parameters. The first is a map and the -// second is a proposed key. Keys are compared with a simple '=='. -func ShouldContainKey(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - keys, isMap := mapKeys(actual) - if !isMap { - return fmt.Sprintf(shouldHaveBeenAValidMap, reflect.TypeOf(actual)) - } - - if !keyFound(keys, expected[0]) { - return fmt.Sprintf(shouldHaveContainedKey, reflect.TypeOf(actual), expected) - } - - return "" -} - -// ShouldNotContainKey receives exactly two parameters. The first is a map and the -// second is a proposed absent key. Keys are compared with a simple '=='. -func ShouldNotContainKey(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - keys, isMap := mapKeys(actual) - if !isMap { - return fmt.Sprintf(shouldHaveBeenAValidMap, reflect.TypeOf(actual)) - } - - if keyFound(keys, expected[0]) { - return fmt.Sprintf(shouldNotHaveContainedKey, reflect.TypeOf(actual), expected) - } - - return "" -} - -func mapKeys(m interface{}) ([]reflect.Value, bool) { - value := reflect.ValueOf(m) - if value.Kind() != reflect.Map { - return nil, false - } - return value.MapKeys(), true -} -func keyFound(keys []reflect.Value, expectedKey interface{}) bool { - found := false - for _, key := range keys { - if key.Interface() == expectedKey { - found = true - } - } - return found -} - -// ShouldBeIn receives at least 2 parameters. The first is a proposed member of the collection -// that is passed in either as the second parameter, or of the collection that is comprised -// of all the remaining parameters. This assertion ensures that the proposed member is in -// the collection (using ShouldEqual). -func ShouldBeIn(actual interface{}, expected ...interface{}) string { - if fail := atLeast(1, expected); fail != success { - return fail - } - - if len(expected) == 1 { - return shouldBeIn(actual, expected[0]) - } - return shouldBeIn(actual, expected) -} -func shouldBeIn(actual interface{}, expected interface{}) string { - if matchError := oglematchers.Contains(actual).Matches(expected); matchError != nil { - return fmt.Sprintf(shouldHaveBeenIn, actual, reflect.TypeOf(expected)) - } - return success -} - -// ShouldNotBeIn receives at least 2 parameters. The first is a proposed member of the collection -// that is passed in either as the second parameter, or of the collection that is comprised -// of all the remaining parameters. This assertion ensures that the proposed member is NOT in -// the collection (using ShouldEqual). -func ShouldNotBeIn(actual interface{}, expected ...interface{}) string { - if fail := atLeast(1, expected); fail != success { - return fail - } - - if len(expected) == 1 { - return shouldNotBeIn(actual, expected[0]) - } - return shouldNotBeIn(actual, expected) -} -func shouldNotBeIn(actual interface{}, expected interface{}) string { - if matchError := oglematchers.Contains(actual).Matches(expected); matchError == nil { - return fmt.Sprintf(shouldNotHaveBeenIn, actual, reflect.TypeOf(expected)) - } - return success -} - -// ShouldBeEmpty receives a single parameter (actual) and determines whether or not -// calling len(actual) would return `0`. It obeys the rules specified by the len -// function for determining length: http://golang.org/pkg/builtin/#len -func ShouldBeEmpty(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } - - if actual == nil { - return success - } - - value := reflect.ValueOf(actual) - switch value.Kind() { - case reflect.Slice: - if value.Len() == 0 { - return success - } - case reflect.Chan: - if value.Len() == 0 { - return success - } - case reflect.Map: - if value.Len() == 0 { - return success - } - case reflect.String: - if value.Len() == 0 { - return success - } - case reflect.Ptr: - elem := value.Elem() - kind := elem.Kind() - if (kind == reflect.Slice || kind == reflect.Array) && elem.Len() == 0 { - return success - } - } - - return fmt.Sprintf(shouldHaveBeenEmpty, actual) -} - -// ShouldNotBeEmpty receives a single parameter (actual) and determines whether or not -// calling len(actual) would return a value greater than zero. It obeys the rules -// specified by the `len` function for determining length: http://golang.org/pkg/builtin/#len -func ShouldNotBeEmpty(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } - - if empty := ShouldBeEmpty(actual, expected...); empty != success { - return success - } - return fmt.Sprintf(shouldNotHaveBeenEmpty, actual) -} - -// ShouldHaveLength receives 2 parameters. The first is a collection to check -// the length of, the second being the expected length. It obeys the rules -// specified by the len function for determining length: -// http://golang.org/pkg/builtin/#len -func ShouldHaveLength(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - var expectedLen int64 - lenValue := reflect.ValueOf(expected[0]) - switch lenValue.Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - expectedLen = lenValue.Int() - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - expectedLen = int64(lenValue.Uint()) - default: - return fmt.Sprintf(shouldHaveBeenAValidInteger, reflect.TypeOf(expected[0])) - } - - if expectedLen < 0 { - return fmt.Sprintf(shouldHaveBeenAValidLength, expected[0]) - } - - value := reflect.ValueOf(actual) - switch value.Kind() { - case reflect.Slice, - reflect.Chan, - reflect.Map, - reflect.String: - if int64(value.Len()) == expectedLen { - return success - } else { - return fmt.Sprintf(shouldHaveHadLength, actual, value.Len(), expectedLen) - } - case reflect.Ptr: - elem := value.Elem() - kind := elem.Kind() - if kind == reflect.Slice || kind == reflect.Array { - if int64(elem.Len()) == expectedLen { - return success - } else { - return fmt.Sprintf(shouldHaveHadLength, actual, elem.Len(), expectedLen) - } - } - } - return fmt.Sprintf(shouldHaveBeenAValidCollection, reflect.TypeOf(actual)) -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/doc.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/doc.go deleted file mode 100644 index 5720fc298c..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/doc.go +++ /dev/null @@ -1,105 +0,0 @@ -// Package assertions contains the implementations for all assertions which -// are referenced in goconvey's `convey` package -// (github.com/smartystreets/goconvey/convey) and gunit (github.com/smartystreets/gunit) -// for use with the So(...) method. -// They can also be used in traditional Go test functions and even in -// applications. -// -// Many of the assertions lean heavily on work done by Aaron Jacobs in his excellent oglematchers library. -// (https://github.com/jacobsa/oglematchers) -// The ShouldResemble assertion leans heavily on work done by Daniel Jacques in his very helpful go-render library. -// (https://github.com/luci/go-render) -package assertions - -import ( - "fmt" - "runtime" -) - -// By default we use a no-op serializer. The actual Serializer provides a JSON -// representation of failure results on selected assertions so the goconvey -// web UI can display a convenient diff. -var serializer Serializer = new(noopSerializer) - -// GoConveyMode provides control over JSON serialization of failures. When -// using the assertions in this package from the convey package JSON results -// are very helpful and can be rendered in a DIFF view. In that case, this function -// will be called with a true value to enable the JSON serialization. By default, -// the assertions in this package will not serializer a JSON result, making -// standalone ussage more convenient. -func GoConveyMode(yes bool) { - if yes { - serializer = newSerializer() - } else { - serializer = new(noopSerializer) - } -} - -type testingT interface { - Error(args ...interface{}) -} - -type Assertion struct { - t testingT - failed bool -} - -// New swallows the *testing.T struct and prints failed assertions using t.Error. -// Example: assertions.New(t).So(1, should.Equal, 1) -func New(t testingT) *Assertion { - return &Assertion{t: t} -} - -// Failed reports whether any calls to So (on this Assertion instance) have failed. -func (this *Assertion) Failed() bool { - return this.failed -} - -// So calls the standalone So function and additionally, calls t.Error in failure scenarios. -func (this *Assertion) So(actual interface{}, assert assertion, expected ...interface{}) bool { - ok, result := So(actual, assert, expected...) - if !ok { - this.failed = true - _, file, line, _ := runtime.Caller(1) - this.t.Error(fmt.Sprintf("\n%s:%d\n%s", file, line, result)) - } - return ok -} - -// So is a convenience function (as opposed to an inconvenience function?) -// for running assertions on arbitrary arguments in any context, be it for testing or even -// application logging. It allows you to perform assertion-like behavior (and get nicely -// formatted messages detailing discrepancies) but without the program blowing up or panicking. -// All that is required is to import this package and call `So` with one of the assertions -// exported by this package as the second parameter. -// The first return parameter is a boolean indicating if the assertion was true. The second -// return parameter is the well-formatted message showing why an assertion was incorrect, or -// blank if the assertion was correct. -// -// Example: -// -// if ok, message := So(x, ShouldBeGreaterThan, y); !ok { -// log.Println(message) -// } -// -func So(actual interface{}, assert assertion, expected ...interface{}) (bool, string) { - if result := so(actual, assert, expected...); len(result) == 0 { - return true, result - } else { - return false, result - } -} - -// so is like So, except that it only returns the string message, which is blank if the -// assertion passed. Used to facilitate testing. -func so(actual interface{}, assert func(interface{}, ...interface{}) string, expected ...interface{}) string { - return assert(actual, expected...) -} - -// assertion is an alias for a function with a signature that the So() -// function can handle. Any future or custom assertions should conform to this -// method signature. The return value should be an empty string if the assertion -// passes and a well-formed failure message if not. -type assertion func(actual interface{}, expected ...interface{}) string - -//////////////////////////////////////////////////////////////////////////// diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/equality.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/equality.go deleted file mode 100644 index 2b6049c37d..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/equality.go +++ /dev/null @@ -1,280 +0,0 @@ -package assertions - -import ( - "errors" - "fmt" - "math" - "reflect" - "strings" - - "github.com/smartystreets/assertions/internal/oglematchers" - "github.com/smartystreets/assertions/internal/go-render/render" -) - -// default acceptable delta for ShouldAlmostEqual -const defaultDelta = 0.0000000001 - -// ShouldEqual receives exactly two parameters and does an equality check. -func ShouldEqual(actual interface{}, expected ...interface{}) string { - if message := need(1, expected); message != success { - return message - } - return shouldEqual(actual, expected[0]) -} -func shouldEqual(actual, expected interface{}) (message string) { - defer func() { - if r := recover(); r != nil { - message = serializer.serialize(expected, actual, fmt.Sprintf(shouldHaveBeenEqual, expected, actual)) - return - } - }() - - if matchError := oglematchers.Equals(expected).Matches(actual); matchError != nil { - expectedSyntax := fmt.Sprintf("%v", expected) - actualSyntax := fmt.Sprintf("%v", actual) - if expectedSyntax == actualSyntax && reflect.TypeOf(expected) != reflect.TypeOf(actual) { - message = fmt.Sprintf(shouldHaveBeenEqualTypeMismatch, expected, expected, actual, actual) - } else { - message = fmt.Sprintf(shouldHaveBeenEqual, expected, actual) - } - message = serializer.serialize(expected, actual, message) - return - } - - return success -} - -// ShouldNotEqual receives exactly two parameters and does an inequality check. -func ShouldNotEqual(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } else if ShouldEqual(actual, expected[0]) == success { - return fmt.Sprintf(shouldNotHaveBeenEqual, actual, expected[0]) - } - return success -} - -// ShouldAlmostEqual makes sure that two parameters are close enough to being equal. -// The acceptable delta may be specified with a third argument, -// or a very small default delta will be used. -func ShouldAlmostEqual(actual interface{}, expected ...interface{}) string { - actualFloat, expectedFloat, deltaFloat, err := cleanAlmostEqualInput(actual, expected...) - - if err != "" { - return err - } - - if math.Abs(actualFloat-expectedFloat) <= deltaFloat { - return success - } else { - return fmt.Sprintf(shouldHaveBeenAlmostEqual, actualFloat, expectedFloat) - } -} - -// ShouldNotAlmostEqual is the inverse of ShouldAlmostEqual -func ShouldNotAlmostEqual(actual interface{}, expected ...interface{}) string { - actualFloat, expectedFloat, deltaFloat, err := cleanAlmostEqualInput(actual, expected...) - - if err != "" { - return err - } - - if math.Abs(actualFloat-expectedFloat) > deltaFloat { - return success - } else { - return fmt.Sprintf(shouldHaveNotBeenAlmostEqual, actualFloat, expectedFloat) - } -} - -func cleanAlmostEqualInput(actual interface{}, expected ...interface{}) (float64, float64, float64, string) { - deltaFloat := 0.0000000001 - - if len(expected) == 0 { - return 0.0, 0.0, 0.0, "This assertion requires exactly one comparison value and an optional delta (you provided neither)" - } else if len(expected) == 2 { - delta, err := getFloat(expected[1]) - - if err != nil { - return 0.0, 0.0, 0.0, "delta must be a numerical type" - } - - deltaFloat = delta - } else if len(expected) > 2 { - return 0.0, 0.0, 0.0, "This assertion requires exactly one comparison value and an optional delta (you provided more values)" - } - - actualFloat, err := getFloat(actual) - - if err != nil { - return 0.0, 0.0, 0.0, err.Error() - } - - expectedFloat, err := getFloat(expected[0]) - - if err != nil { - return 0.0, 0.0, 0.0, err.Error() - } - - return actualFloat, expectedFloat, deltaFloat, "" -} - -// returns the float value of any real number, or error if it is not a numerical type -func getFloat(num interface{}) (float64, error) { - numValue := reflect.ValueOf(num) - numKind := numValue.Kind() - - if numKind == reflect.Int || - numKind == reflect.Int8 || - numKind == reflect.Int16 || - numKind == reflect.Int32 || - numKind == reflect.Int64 { - return float64(numValue.Int()), nil - } else if numKind == reflect.Uint || - numKind == reflect.Uint8 || - numKind == reflect.Uint16 || - numKind == reflect.Uint32 || - numKind == reflect.Uint64 { - return float64(numValue.Uint()), nil - } else if numKind == reflect.Float32 || - numKind == reflect.Float64 { - return numValue.Float(), nil - } else { - return 0.0, errors.New("must be a numerical type, but was " + numKind.String()) - } -} - -// ShouldResemble receives exactly two parameters and does a deep equal check (see reflect.DeepEqual) -func ShouldResemble(actual interface{}, expected ...interface{}) string { - if message := need(1, expected); message != success { - return message - } - - if matchError := oglematchers.DeepEquals(expected[0]).Matches(actual); matchError != nil { - return serializer.serializeDetailed(expected[0], actual, - fmt.Sprintf(shouldHaveResembled, render.Render(expected[0]), render.Render(actual))) - } - - return success -} - -// ShouldNotResemble receives exactly two parameters and does an inverse deep equal check (see reflect.DeepEqual) -func ShouldNotResemble(actual interface{}, expected ...interface{}) string { - if message := need(1, expected); message != success { - return message - } else if ShouldResemble(actual, expected[0]) == success { - return fmt.Sprintf(shouldNotHaveResembled, render.Render(actual), render.Render(expected[0])) - } - return success -} - -// ShouldPointTo receives exactly two parameters and checks to see that they point to the same address. -func ShouldPointTo(actual interface{}, expected ...interface{}) string { - if message := need(1, expected); message != success { - return message - } - return shouldPointTo(actual, expected[0]) - -} -func shouldPointTo(actual, expected interface{}) string { - actualValue := reflect.ValueOf(actual) - expectedValue := reflect.ValueOf(expected) - - if ShouldNotBeNil(actual) != success { - return fmt.Sprintf(shouldHaveBeenNonNilPointer, "first", "nil") - } else if ShouldNotBeNil(expected) != success { - return fmt.Sprintf(shouldHaveBeenNonNilPointer, "second", "nil") - } else if actualValue.Kind() != reflect.Ptr { - return fmt.Sprintf(shouldHaveBeenNonNilPointer, "first", "not") - } else if expectedValue.Kind() != reflect.Ptr { - return fmt.Sprintf(shouldHaveBeenNonNilPointer, "second", "not") - } else if ShouldEqual(actualValue.Pointer(), expectedValue.Pointer()) != success { - actualAddress := reflect.ValueOf(actual).Pointer() - expectedAddress := reflect.ValueOf(expected).Pointer() - return serializer.serialize(expectedAddress, actualAddress, fmt.Sprintf(shouldHavePointedTo, - actual, actualAddress, - expected, expectedAddress)) - } - return success -} - -// ShouldNotPointTo receives exactly two parameters and checks to see that they point to different addresess. -func ShouldNotPointTo(actual interface{}, expected ...interface{}) string { - if message := need(1, expected); message != success { - return message - } - compare := ShouldPointTo(actual, expected[0]) - if strings.HasPrefix(compare, shouldBePointers) { - return compare - } else if compare == success { - return fmt.Sprintf(shouldNotHavePointedTo, actual, expected[0], reflect.ValueOf(actual).Pointer()) - } - return success -} - -// ShouldBeNil receives a single parameter and ensures that it is nil. -func ShouldBeNil(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } else if actual == nil { - return success - } else if interfaceHasNilValue(actual) { - return success - } - return fmt.Sprintf(shouldHaveBeenNil, actual) -} -func interfaceHasNilValue(actual interface{}) bool { - value := reflect.ValueOf(actual) - kind := value.Kind() - nilable := kind == reflect.Slice || - kind == reflect.Chan || - kind == reflect.Func || - kind == reflect.Ptr || - kind == reflect.Map - - // Careful: reflect.Value.IsNil() will panic unless it's an interface, chan, map, func, slice, or ptr - // Reference: http://golang.org/pkg/reflect/#Value.IsNil - return nilable && value.IsNil() -} - -// ShouldNotBeNil receives a single parameter and ensures that it is not nil. -func ShouldNotBeNil(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } else if ShouldBeNil(actual) == success { - return fmt.Sprintf(shouldNotHaveBeenNil, actual) - } - return success -} - -// ShouldBeTrue receives a single parameter and ensures that it is true. -func ShouldBeTrue(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } else if actual != true { - return fmt.Sprintf(shouldHaveBeenTrue, actual) - } - return success -} - -// ShouldBeFalse receives a single parameter and ensures that it is false. -func ShouldBeFalse(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } else if actual != false { - return fmt.Sprintf(shouldHaveBeenFalse, actual) - } - return success -} - -// ShouldBeZeroValue receives a single parameter and ensures that it is -// the Go equivalent of the default value, or "zero" value. -func ShouldBeZeroValue(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } - zeroVal := reflect.Zero(reflect.TypeOf(actual)).Interface() - if !reflect.DeepEqual(zeroVal, actual) { - return serializer.serialize(zeroVal, actual, fmt.Sprintf(shouldHaveBeenZeroValue, actual)) - } - return success -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/filter.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/filter.go deleted file mode 100644 index ee368a97ed..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/filter.go +++ /dev/null @@ -1,23 +0,0 @@ -package assertions - -import "fmt" - -const ( - success = "" - needExactValues = "This assertion requires exactly %d comparison values (you provided %d)." - needNonEmptyCollection = "This assertion requires at least 1 comparison value (you provided 0)." -) - -func need(needed int, expected []interface{}) string { - if len(expected) != needed { - return fmt.Sprintf(needExactValues, needed, len(expected)) - } - return success -} - -func atLeast(minimum int, expected []interface{}) string { - if len(expected) < 1 { - return needNonEmptyCollection - } - return success -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/go-render/render/render.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/go-render/render/render.go deleted file mode 100644 index 23b7a58676..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/go-render/render/render.go +++ /dev/null @@ -1,477 +0,0 @@ -// Copyright 2015 The Chromium 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 render - -import ( - "bytes" - "fmt" - "reflect" - "sort" - "strconv" -) - -var builtinTypeMap = map[reflect.Kind]string{ - reflect.Bool: "bool", - reflect.Complex128: "complex128", - reflect.Complex64: "complex64", - reflect.Float32: "float32", - reflect.Float64: "float64", - reflect.Int16: "int16", - reflect.Int32: "int32", - reflect.Int64: "int64", - reflect.Int8: "int8", - reflect.Int: "int", - reflect.String: "string", - reflect.Uint16: "uint16", - reflect.Uint32: "uint32", - reflect.Uint64: "uint64", - reflect.Uint8: "uint8", - reflect.Uint: "uint", - reflect.Uintptr: "uintptr", -} - -var builtinTypeSet = map[string]struct{}{} - -func init() { - for _, v := range builtinTypeMap { - builtinTypeSet[v] = struct{}{} - } -} - -var typeOfString = reflect.TypeOf("") -var typeOfInt = reflect.TypeOf(int(1)) -var typeOfUint = reflect.TypeOf(uint(1)) -var typeOfFloat = reflect.TypeOf(10.1) - -// Render converts a structure to a string representation. Unline the "%#v" -// format string, this resolves pointer types' contents in structs, maps, and -// slices/arrays and prints their field values. -func Render(v interface{}) string { - buf := bytes.Buffer{} - s := (*traverseState)(nil) - s.render(&buf, 0, reflect.ValueOf(v), false) - return buf.String() -} - -// renderPointer is called to render a pointer value. -// -// This is overridable so that the test suite can have deterministic pointer -// values in its expectations. -var renderPointer = func(buf *bytes.Buffer, p uintptr) { - fmt.Fprintf(buf, "0x%016x", p) -} - -// traverseState is used to note and avoid recursion as struct members are being -// traversed. -// -// traverseState is allowed to be nil. Specifically, the root state is nil. -type traverseState struct { - parent *traverseState - ptr uintptr -} - -func (s *traverseState) forkFor(ptr uintptr) *traverseState { - for cur := s; cur != nil; cur = cur.parent { - if ptr == cur.ptr { - return nil - } - } - - fs := &traverseState{ - parent: s, - ptr: ptr, - } - return fs -} - -func (s *traverseState) render(buf *bytes.Buffer, ptrs int, v reflect.Value, implicit bool) { - if v.Kind() == reflect.Invalid { - buf.WriteString("nil") - return - } - vt := v.Type() - - // If the type being rendered is a potentially recursive type (a type that - // can contain itself as a member), we need to avoid recursion. - // - // If we've already seen this type before, mark that this is the case and - // write a recursion placeholder instead of actually rendering it. - // - // If we haven't seen it before, fork our `seen` tracking so any higher-up - // renderers will also render it at least once, then mark that we've seen it - // to avoid recursing on lower layers. - pe := uintptr(0) - vk := vt.Kind() - switch vk { - case reflect.Ptr: - // Since structs and arrays aren't pointers, they can't directly be - // recursed, but they can contain pointers to themselves. Record their - // pointer to avoid this. - switch v.Elem().Kind() { - case reflect.Struct, reflect.Array: - pe = v.Pointer() - } - - case reflect.Slice, reflect.Map: - pe = v.Pointer() - } - if pe != 0 { - s = s.forkFor(pe) - if s == nil { - buf.WriteString("") - return - } - } - - isAnon := func(t reflect.Type) bool { - if t.Name() != "" { - if _, ok := builtinTypeSet[t.Name()]; !ok { - return false - } - } - return t.Kind() != reflect.Interface - } - - switch vk { - case reflect.Struct: - if !implicit { - writeType(buf, ptrs, vt) - } - structAnon := vt.Name() == "" - buf.WriteRune('{') - for i := 0; i < vt.NumField(); i++ { - if i > 0 { - buf.WriteString(", ") - } - anon := structAnon && isAnon(vt.Field(i).Type) - - if !anon { - buf.WriteString(vt.Field(i).Name) - buf.WriteRune(':') - } - - s.render(buf, 0, v.Field(i), anon) - } - buf.WriteRune('}') - - case reflect.Slice: - if v.IsNil() { - if !implicit { - writeType(buf, ptrs, vt) - buf.WriteString("(nil)") - } else { - buf.WriteString("nil") - } - return - } - fallthrough - - case reflect.Array: - if !implicit { - writeType(buf, ptrs, vt) - } - anon := vt.Name() == "" && isAnon(vt.Elem()) - buf.WriteString("{") - for i := 0; i < v.Len(); i++ { - if i > 0 { - buf.WriteString(", ") - } - - s.render(buf, 0, v.Index(i), anon) - } - buf.WriteRune('}') - - case reflect.Map: - if !implicit { - writeType(buf, ptrs, vt) - } - if v.IsNil() { - buf.WriteString("(nil)") - } else { - buf.WriteString("{") - - mkeys := v.MapKeys() - tryAndSortMapKeys(vt, mkeys) - - kt := vt.Key() - keyAnon := typeOfString.ConvertibleTo(kt) || typeOfInt.ConvertibleTo(kt) || typeOfUint.ConvertibleTo(kt) || typeOfFloat.ConvertibleTo(kt) - valAnon := vt.Name() == "" && isAnon(vt.Elem()) - for i, mk := range mkeys { - if i > 0 { - buf.WriteString(", ") - } - - s.render(buf, 0, mk, keyAnon) - buf.WriteString(":") - s.render(buf, 0, v.MapIndex(mk), valAnon) - } - buf.WriteRune('}') - } - - case reflect.Ptr: - ptrs++ - fallthrough - case reflect.Interface: - if v.IsNil() { - writeType(buf, ptrs, v.Type()) - buf.WriteString("(nil)") - } else { - s.render(buf, ptrs, v.Elem(), false) - } - - case reflect.Chan, reflect.Func, reflect.UnsafePointer: - writeType(buf, ptrs, vt) - buf.WriteRune('(') - renderPointer(buf, v.Pointer()) - buf.WriteRune(')') - - default: - tstr := vt.String() - implicit = implicit || (ptrs == 0 && builtinTypeMap[vk] == tstr) - if !implicit { - writeType(buf, ptrs, vt) - buf.WriteRune('(') - } - - switch vk { - case reflect.String: - fmt.Fprintf(buf, "%q", v.String()) - case reflect.Bool: - fmt.Fprintf(buf, "%v", v.Bool()) - - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - fmt.Fprintf(buf, "%d", v.Int()) - - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - fmt.Fprintf(buf, "%d", v.Uint()) - - case reflect.Float32, reflect.Float64: - fmt.Fprintf(buf, "%g", v.Float()) - - case reflect.Complex64, reflect.Complex128: - fmt.Fprintf(buf, "%g", v.Complex()) - } - - if !implicit { - buf.WriteRune(')') - } - } -} - -func writeType(buf *bytes.Buffer, ptrs int, t reflect.Type) { - parens := ptrs > 0 - switch t.Kind() { - case reflect.Chan, reflect.Func, reflect.UnsafePointer: - parens = true - } - - if parens { - buf.WriteRune('(') - for i := 0; i < ptrs; i++ { - buf.WriteRune('*') - } - } - - switch t.Kind() { - case reflect.Ptr: - if ptrs == 0 { - // This pointer was referenced from within writeType (e.g., as part of - // rendering a list), and so hasn't had its pointer asterisk accounted - // for. - buf.WriteRune('*') - } - writeType(buf, 0, t.Elem()) - - case reflect.Interface: - if n := t.Name(); n != "" { - buf.WriteString(t.String()) - } else { - buf.WriteString("interface{}") - } - - case reflect.Array: - buf.WriteRune('[') - buf.WriteString(strconv.FormatInt(int64(t.Len()), 10)) - buf.WriteRune(']') - writeType(buf, 0, t.Elem()) - - case reflect.Slice: - if t == reflect.SliceOf(t.Elem()) { - buf.WriteString("[]") - writeType(buf, 0, t.Elem()) - } else { - // Custom slice type, use type name. - buf.WriteString(t.String()) - } - - case reflect.Map: - if t == reflect.MapOf(t.Key(), t.Elem()) { - buf.WriteString("map[") - writeType(buf, 0, t.Key()) - buf.WriteRune(']') - writeType(buf, 0, t.Elem()) - } else { - // Custom map type, use type name. - buf.WriteString(t.String()) - } - - default: - buf.WriteString(t.String()) - } - - if parens { - buf.WriteRune(')') - } -} - -type cmpFn func(a, b reflect.Value) int - -type sortableValueSlice struct { - cmp cmpFn - elements []reflect.Value -} - -func (s sortableValueSlice) Len() int { - return len(s.elements) -} - -func (s sortableValueSlice) Less(i, j int) bool { - return s.cmp(s.elements[i], s.elements[j]) < 0 -} - -func (s sortableValueSlice) Swap(i, j int) { - s.elements[i], s.elements[j] = s.elements[j], s.elements[i] -} - -// cmpForType returns a cmpFn which sorts the data for some type t in the same -// order that a go-native map key is compared for equality. -func cmpForType(t reflect.Type) cmpFn { - switch t.Kind() { - case reflect.String: - return func(av, bv reflect.Value) int { - a, b := av.String(), bv.String() - if a < b { - return -1 - } else if a > b { - return 1 - } - return 0 - } - - case reflect.Bool: - return func(av, bv reflect.Value) int { - a, b := av.Bool(), bv.Bool() - if !a && b { - return -1 - } else if a && !b { - return 1 - } - return 0 - } - - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return func(av, bv reflect.Value) int { - a, b := av.Int(), bv.Int() - if a < b { - return -1 - } else if a > b { - return 1 - } - return 0 - } - - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, - reflect.Uint64, reflect.Uintptr, reflect.UnsafePointer: - return func(av, bv reflect.Value) int { - a, b := av.Uint(), bv.Uint() - if a < b { - return -1 - } else if a > b { - return 1 - } - return 0 - } - - case reflect.Float32, reflect.Float64: - return func(av, bv reflect.Value) int { - a, b := av.Float(), bv.Float() - if a < b { - return -1 - } else if a > b { - return 1 - } - return 0 - } - - case reflect.Interface: - return func(av, bv reflect.Value) int { - a, b := av.InterfaceData(), bv.InterfaceData() - if a[0] < b[0] { - return -1 - } else if a[0] > b[0] { - return 1 - } - if a[1] < b[1] { - return -1 - } else if a[1] > b[1] { - return 1 - } - return 0 - } - - case reflect.Complex64, reflect.Complex128: - return func(av, bv reflect.Value) int { - a, b := av.Complex(), bv.Complex() - if real(a) < real(b) { - return -1 - } else if real(a) > real(b) { - return 1 - } - if imag(a) < imag(b) { - return -1 - } else if imag(a) > imag(b) { - return 1 - } - return 0 - } - - case reflect.Ptr, reflect.Chan: - return func(av, bv reflect.Value) int { - a, b := av.Pointer(), bv.Pointer() - if a < b { - return -1 - } else if a > b { - return 1 - } - return 0 - } - - case reflect.Struct: - cmpLst := make([]cmpFn, t.NumField()) - for i := range cmpLst { - cmpLst[i] = cmpForType(t.Field(i).Type) - } - return func(a, b reflect.Value) int { - for i, cmp := range cmpLst { - if rslt := cmp(a.Field(i), b.Field(i)); rslt != 0 { - return rslt - } - } - return 0 - } - } - - return nil -} - -func tryAndSortMapKeys(mt reflect.Type, k []reflect.Value) { - if cmp := cmpForType(mt.Key()); cmp != nil { - sort.Sort(sortableValueSlice{cmp, k}) - } -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/.gitignore b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/.gitignore deleted file mode 100644 index dd8fc7468f..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -*.6 -6.out -_obj/ -_test/ -_testmain.go diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/.travis.yml b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/.travis.yml deleted file mode 100644 index b97211926e..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -# Cf. http://docs.travis-ci.com/user/getting-started/ -# Cf. http://docs.travis-ci.com/user/languages/go/ - -language: go diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/LICENSE b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/LICENSE deleted file mode 100644 index d645695673..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor 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, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/README.md b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/README.md deleted file mode 100644 index 215a2bb7a8..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/README.md +++ /dev/null @@ -1,58 +0,0 @@ -[![GoDoc](https://godoc.org/github.com/smartystreets/assertions/internal/oglematchers?status.svg)](https://godoc.org/github.com/smartystreets/assertions/internal/oglematchers) - -`oglematchers` is a package for the Go programming language containing a set of -matchers, useful in a testing or mocking framework, inspired by and mostly -compatible with [Google Test][googletest] for C++ and -[Google JS Test][google-js-test]. The package is used by the -[ogletest][ogletest] testing framework and [oglemock][oglemock] mocking -framework, which may be more directly useful to you, but can be generically used -elsewhere as well. - -A "matcher" is simply an object with a `Matches` method defining a set of golang -values matched by the matcher, and a `Description` method describing that set. -For example, here are some matchers: - -```go -// Numbers -Equals(17.13) -LessThan(19) - -// Strings -Equals("taco") -HasSubstr("burrito") -MatchesRegex("t.*o") - -// Combining matchers -AnyOf(LessThan(17), GreaterThan(19)) -``` - -There are lots more; see [here][reference] for a reference. You can also add -your own simply by implementing the `oglematchers.Matcher` interface. - - -Installation ------------- - -First, make sure you have installed Go 1.0.2 or newer. See -[here][golang-install] for instructions. - -Use the following command to install `oglematchers` and keep it up to date: - - go get -u github.com/smartystreets/assertions/internal/oglematchers - - -Documentation -------------- - -See [here][reference] for documentation. Alternatively, you can install the -package and then use `godoc`: - - godoc github.com/smartystreets/assertions/internal/oglematchers - - -[reference]: http://godoc.org/github.com/smartystreets/assertions/internal/oglematchers -[golang-install]: http://golang.org/doc/install.html -[googletest]: http://code.google.com/p/googletest/ -[google-js-test]: http://code.google.com/p/google-js-test/ -[ogletest]: http://github.com/smartystreets/assertions/internal/ogletest -[oglemock]: http://github.com/smartystreets/assertions/internal/oglemock diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/all_of.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/all_of.go deleted file mode 100644 index d93a974044..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/all_of.go +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "strings" -) - -// AllOf accepts a set of matchers S and returns a matcher that follows the -// algorithm below when considering a candidate c: -// -// 1. Return true if for every Matcher m in S, m matches c. -// -// 2. Otherwise, if there is a matcher m in S such that m returns a fatal -// error for c, return that matcher's error message. -// -// 3. Otherwise, return false with the error from some wrapped matcher. -// -// This is akin to a logical AND operation for matchers. -func AllOf(matchers ...Matcher) Matcher { - return &allOfMatcher{matchers} -} - -type allOfMatcher struct { - wrappedMatchers []Matcher -} - -func (m *allOfMatcher) Description() string { - // Special case: the empty set. - if len(m.wrappedMatchers) == 0 { - return "is anything" - } - - // Join the descriptions for the wrapped matchers. - wrappedDescs := make([]string, len(m.wrappedMatchers)) - for i, wrappedMatcher := range m.wrappedMatchers { - wrappedDescs[i] = wrappedMatcher.Description() - } - - return strings.Join(wrappedDescs, ", and ") -} - -func (m *allOfMatcher) Matches(c interface{}) (err error) { - for _, wrappedMatcher := range m.wrappedMatchers { - if wrappedErr := wrappedMatcher.Matches(c); wrappedErr != nil { - err = wrappedErr - - // If the error is fatal, return immediately with this error. - _, ok := wrappedErr.(*FatalError) - if ok { - return - } - } - } - - return -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/any.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/any.go deleted file mode 100644 index f6991ec102..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/any.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -// Any returns a matcher that matches any value. -func Any() Matcher { - return &anyMatcher{} -} - -type anyMatcher struct { -} - -func (m *anyMatcher) Description() string { - return "is anything" -} - -func (m *anyMatcher) Matches(c interface{}) error { - return nil -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/any_of.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/any_of.go deleted file mode 100644 index 2918b51f21..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/any_of.go +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "reflect" - "strings" -) - -// AnyOf accepts a set of values S and returns a matcher that follows the -// algorithm below when considering a candidate c: -// -// 1. If there exists a value m in S such that m implements the Matcher -// interface and m matches c, return true. -// -// 2. Otherwise, if there exists a value v in S such that v does not implement -// the Matcher interface and the matcher Equals(v) matches c, return true. -// -// 3. Otherwise, if there is a value m in S such that m implements the Matcher -// interface and m returns a fatal error for c, return that fatal error. -// -// 4. Otherwise, return false. -// -// This is akin to a logical OR operation for matchers, with non-matchers x -// being treated as Equals(x). -func AnyOf(vals ...interface{}) Matcher { - // Get ahold of a type variable for the Matcher interface. - var dummy *Matcher - matcherType := reflect.TypeOf(dummy).Elem() - - // Create a matcher for each value, or use the value itself if it's already a - // matcher. - wrapped := make([]Matcher, len(vals)) - for i, v := range vals { - t := reflect.TypeOf(v) - if t != nil && t.Implements(matcherType) { - wrapped[i] = v.(Matcher) - } else { - wrapped[i] = Equals(v) - } - } - - return &anyOfMatcher{wrapped} -} - -type anyOfMatcher struct { - wrapped []Matcher -} - -func (m *anyOfMatcher) Description() string { - wrappedDescs := make([]string, len(m.wrapped)) - for i, matcher := range m.wrapped { - wrappedDescs[i] = matcher.Description() - } - - return fmt.Sprintf("or(%s)", strings.Join(wrappedDescs, ", ")) -} - -func (m *anyOfMatcher) Matches(c interface{}) (err error) { - err = errors.New("") - - // Try each matcher in turn. - for _, matcher := range m.wrapped { - wrappedErr := matcher.Matches(c) - - // Return immediately if there's a match. - if wrappedErr == nil { - err = nil - return - } - - // Note the fatal error, if any. - if _, isFatal := wrappedErr.(*FatalError); isFatal { - err = wrappedErr - } - } - - return -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/contains.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/contains.go deleted file mode 100644 index 87f107d392..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/contains.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "fmt" - "reflect" -) - -// Return a matcher that matches arrays slices with at least one element that -// matches the supplied argument. If the argument x is not itself a Matcher, -// this is equivalent to Contains(Equals(x)). -func Contains(x interface{}) Matcher { - var result containsMatcher - var ok bool - - if result.elementMatcher, ok = x.(Matcher); !ok { - result.elementMatcher = DeepEquals(x) - } - - return &result -} - -type containsMatcher struct { - elementMatcher Matcher -} - -func (m *containsMatcher) Description() string { - return fmt.Sprintf("contains: %s", m.elementMatcher.Description()) -} - -func (m *containsMatcher) Matches(candidate interface{}) error { - // The candidate must be a slice or an array. - v := reflect.ValueOf(candidate) - if v.Kind() != reflect.Slice && v.Kind() != reflect.Array { - return NewFatalError("which is not a slice or array") - } - - // Check each element. - for i := 0; i < v.Len(); i++ { - elem := v.Index(i) - if matchErr := m.elementMatcher.Matches(elem.Interface()); matchErr == nil { - return nil - } - } - - return fmt.Errorf("") -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/deep_equals.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/deep_equals.go deleted file mode 100644 index 1d91baef32..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/deep_equals.go +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "bytes" - "errors" - "fmt" - "reflect" -) - -var byteSliceType reflect.Type = reflect.TypeOf([]byte{}) - -// DeepEquals returns a matcher that matches based on 'deep equality', as -// defined by the reflect package. This matcher requires that values have -// identical types to x. -func DeepEquals(x interface{}) Matcher { - return &deepEqualsMatcher{x} -} - -type deepEqualsMatcher struct { - x interface{} -} - -func (m *deepEqualsMatcher) Description() string { - xDesc := fmt.Sprintf("%v", m.x) - xValue := reflect.ValueOf(m.x) - - // Special case: fmt.Sprintf presents nil slices as "[]", but - // reflect.DeepEqual makes a distinction between nil and empty slices. Make - // this less confusing. - if xValue.Kind() == reflect.Slice && xValue.IsNil() { - xDesc = "" - } - - return fmt.Sprintf("deep equals: %s", xDesc) -} - -func (m *deepEqualsMatcher) Matches(c interface{}) error { - // Make sure the types match. - ct := reflect.TypeOf(c) - xt := reflect.TypeOf(m.x) - - if ct != xt { - return NewFatalError(fmt.Sprintf("which is of type %v", ct)) - } - - // Special case: handle byte slices more efficiently. - cValue := reflect.ValueOf(c) - xValue := reflect.ValueOf(m.x) - - if ct == byteSliceType && !cValue.IsNil() && !xValue.IsNil() { - xBytes := m.x.([]byte) - cBytes := c.([]byte) - - if bytes.Equal(cBytes, xBytes) { - return nil - } - - return errors.New("") - } - - // Defer to the reflect package. - if reflect.DeepEqual(m.x, c) { - return nil - } - - // Special case: if the comparison failed because c is the nil slice, given - // an indication of this (since its value is printed as "[]"). - if cValue.Kind() == reflect.Slice && cValue.IsNil() { - return errors.New("which is nil") - } - - return errors.New("") -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/elements_are.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/elements_are.go deleted file mode 100644 index 2941847c70..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/elements_are.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "reflect" - "strings" -) - -// Given a list of arguments M, ElementsAre returns a matcher that matches -// arrays and slices A where all of the following hold: -// -// * A is the same length as M. -// -// * For each i < len(A) where M[i] is a matcher, A[i] matches M[i]. -// -// * For each i < len(A) where M[i] is not a matcher, A[i] matches -// Equals(M[i]). -// -func ElementsAre(M ...interface{}) Matcher { - // Copy over matchers, or convert to Equals(x) for non-matcher x. - subMatchers := make([]Matcher, len(M)) - for i, x := range M { - if matcher, ok := x.(Matcher); ok { - subMatchers[i] = matcher - continue - } - - subMatchers[i] = Equals(x) - } - - return &elementsAreMatcher{subMatchers} -} - -type elementsAreMatcher struct { - subMatchers []Matcher -} - -func (m *elementsAreMatcher) Description() string { - subDescs := make([]string, len(m.subMatchers)) - for i, sm := range m.subMatchers { - subDescs[i] = sm.Description() - } - - return fmt.Sprintf("elements are: [%s]", strings.Join(subDescs, ", ")) -} - -func (m *elementsAreMatcher) Matches(candidates interface{}) error { - // The candidate must be a slice or an array. - v := reflect.ValueOf(candidates) - if v.Kind() != reflect.Slice && v.Kind() != reflect.Array { - return NewFatalError("which is not a slice or array") - } - - // The length must be correct. - if v.Len() != len(m.subMatchers) { - return errors.New(fmt.Sprintf("which is of length %d", v.Len())) - } - - // Check each element. - for i, subMatcher := range m.subMatchers { - c := v.Index(i) - if matchErr := subMatcher.Matches(c.Interface()); matchErr != nil { - // Return an errors indicating which element doesn't match. If the - // matcher error was fatal, make this one fatal too. - err := errors.New(fmt.Sprintf("whose element %d doesn't match", i)) - if _, isFatal := matchErr.(*FatalError); isFatal { - err = NewFatalError(err.Error()) - } - - return err - } - } - - return nil -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/equals.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/equals.go deleted file mode 100644 index a510707b3c..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/equals.go +++ /dev/null @@ -1,541 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "math" - "reflect" -) - -// Equals(x) returns a matcher that matches values v such that v and x are -// equivalent. This includes the case when the comparison v == x using Go's -// built-in comparison operator is legal (except for structs, which this -// matcher does not support), but for convenience the following rules also -// apply: -// -// * Type checking is done based on underlying types rather than actual -// types, so that e.g. two aliases for string can be compared: -// -// type stringAlias1 string -// type stringAlias2 string -// -// a := "taco" -// b := stringAlias1("taco") -// c := stringAlias2("taco") -// -// ExpectTrue(a == b) // Legal, passes -// ExpectTrue(b == c) // Illegal, doesn't compile -// -// ExpectThat(a, Equals(b)) // Passes -// ExpectThat(b, Equals(c)) // Passes -// -// * Values of numeric type are treated as if they were abstract numbers, and -// compared accordingly. Therefore Equals(17) will match int(17), -// int16(17), uint(17), float32(17), complex64(17), and so on. -// -// If you want a stricter matcher that contains no such cleverness, see -// IdenticalTo instead. -// -// Arrays are supported by this matcher, but do not participate in the -// exceptions above. Two arrays compared with this matcher must have identical -// types, and their element type must itself be comparable according to Go's == -// operator. -func Equals(x interface{}) Matcher { - v := reflect.ValueOf(x) - - // This matcher doesn't support structs. - if v.Kind() == reflect.Struct { - panic(fmt.Sprintf("oglematchers.Equals: unsupported kind %v", v.Kind())) - } - - // The == operator is not defined for non-nil slices. - if v.Kind() == reflect.Slice && v.Pointer() != uintptr(0) { - panic(fmt.Sprintf("oglematchers.Equals: non-nil slice")) - } - - return &equalsMatcher{v} -} - -type equalsMatcher struct { - expectedValue reflect.Value -} - -//////////////////////////////////////////////////////////////////////// -// Numeric types -//////////////////////////////////////////////////////////////////////// - -func isSignedInteger(v reflect.Value) bool { - k := v.Kind() - return k >= reflect.Int && k <= reflect.Int64 -} - -func isUnsignedInteger(v reflect.Value) bool { - k := v.Kind() - return k >= reflect.Uint && k <= reflect.Uintptr -} - -func isInteger(v reflect.Value) bool { - return isSignedInteger(v) || isUnsignedInteger(v) -} - -func isFloat(v reflect.Value) bool { - k := v.Kind() - return k == reflect.Float32 || k == reflect.Float64 -} - -func isComplex(v reflect.Value) bool { - k := v.Kind() - return k == reflect.Complex64 || k == reflect.Complex128 -} - -func checkAgainstInt64(e int64, c reflect.Value) (err error) { - err = errors.New("") - - switch { - case isSignedInteger(c): - if c.Int() == e { - err = nil - } - - case isUnsignedInteger(c): - u := c.Uint() - if u <= math.MaxInt64 && int64(u) == e { - err = nil - } - - // Turn around the various floating point types so that the checkAgainst* - // functions for them can deal with precision issues. - case isFloat(c), isComplex(c): - return Equals(c.Interface()).Matches(e) - - default: - err = NewFatalError("which is not numeric") - } - - return -} - -func checkAgainstUint64(e uint64, c reflect.Value) (err error) { - err = errors.New("") - - switch { - case isSignedInteger(c): - i := c.Int() - if i >= 0 && uint64(i) == e { - err = nil - } - - case isUnsignedInteger(c): - if c.Uint() == e { - err = nil - } - - // Turn around the various floating point types so that the checkAgainst* - // functions for them can deal with precision issues. - case isFloat(c), isComplex(c): - return Equals(c.Interface()).Matches(e) - - default: - err = NewFatalError("which is not numeric") - } - - return -} - -func checkAgainstFloat32(e float32, c reflect.Value) (err error) { - err = errors.New("") - - switch { - case isSignedInteger(c): - if float32(c.Int()) == e { - err = nil - } - - case isUnsignedInteger(c): - if float32(c.Uint()) == e { - err = nil - } - - case isFloat(c): - // Compare using float32 to avoid a false sense of precision; otherwise - // e.g. Equals(float32(0.1)) won't match float32(0.1). - if float32(c.Float()) == e { - err = nil - } - - case isComplex(c): - comp := c.Complex() - rl := real(comp) - im := imag(comp) - - // Compare using float32 to avoid a false sense of precision; otherwise - // e.g. Equals(float32(0.1)) won't match (0.1 + 0i). - if im == 0 && float32(rl) == e { - err = nil - } - - default: - err = NewFatalError("which is not numeric") - } - - return -} - -func checkAgainstFloat64(e float64, c reflect.Value) (err error) { - err = errors.New("") - - ck := c.Kind() - - switch { - case isSignedInteger(c): - if float64(c.Int()) == e { - err = nil - } - - case isUnsignedInteger(c): - if float64(c.Uint()) == e { - err = nil - } - - // If the actual value is lower precision, turn the comparison around so we - // apply the low-precision rules. Otherwise, e.g. Equals(0.1) may not match - // float32(0.1). - case ck == reflect.Float32 || ck == reflect.Complex64: - return Equals(c.Interface()).Matches(e) - - // Otherwise, compare with double precision. - case isFloat(c): - if c.Float() == e { - err = nil - } - - case isComplex(c): - comp := c.Complex() - rl := real(comp) - im := imag(comp) - - if im == 0 && rl == e { - err = nil - } - - default: - err = NewFatalError("which is not numeric") - } - - return -} - -func checkAgainstComplex64(e complex64, c reflect.Value) (err error) { - err = errors.New("") - realPart := real(e) - imaginaryPart := imag(e) - - switch { - case isInteger(c) || isFloat(c): - // If we have no imaginary part, then we should just compare against the - // real part. Otherwise, we can't be equal. - if imaginaryPart != 0 { - return - } - - return checkAgainstFloat32(realPart, c) - - case isComplex(c): - // Compare using complex64 to avoid a false sense of precision; otherwise - // e.g. Equals(0.1 + 0i) won't match float32(0.1). - if complex64(c.Complex()) == e { - err = nil - } - - default: - err = NewFatalError("which is not numeric") - } - - return -} - -func checkAgainstComplex128(e complex128, c reflect.Value) (err error) { - err = errors.New("") - realPart := real(e) - imaginaryPart := imag(e) - - switch { - case isInteger(c) || isFloat(c): - // If we have no imaginary part, then we should just compare against the - // real part. Otherwise, we can't be equal. - if imaginaryPart != 0 { - return - } - - return checkAgainstFloat64(realPart, c) - - case isComplex(c): - if c.Complex() == e { - err = nil - } - - default: - err = NewFatalError("which is not numeric") - } - - return -} - -//////////////////////////////////////////////////////////////////////// -// Other types -//////////////////////////////////////////////////////////////////////// - -func checkAgainstBool(e bool, c reflect.Value) (err error) { - if c.Kind() != reflect.Bool { - err = NewFatalError("which is not a bool") - return - } - - err = errors.New("") - if c.Bool() == e { - err = nil - } - return -} - -func checkAgainstChan(e reflect.Value, c reflect.Value) (err error) { - // Create a description of e's type, e.g. "chan int". - typeStr := fmt.Sprintf("%s %s", e.Type().ChanDir(), e.Type().Elem()) - - // Make sure c is a chan of the correct type. - if c.Kind() != reflect.Chan || - c.Type().ChanDir() != e.Type().ChanDir() || - c.Type().Elem() != e.Type().Elem() { - err = NewFatalError(fmt.Sprintf("which is not a %s", typeStr)) - return - } - - err = errors.New("") - if c.Pointer() == e.Pointer() { - err = nil - } - return -} - -func checkAgainstFunc(e reflect.Value, c reflect.Value) (err error) { - // Make sure c is a function. - if c.Kind() != reflect.Func { - err = NewFatalError("which is not a function") - return - } - - err = errors.New("") - if c.Pointer() == e.Pointer() { - err = nil - } - return -} - -func checkAgainstMap(e reflect.Value, c reflect.Value) (err error) { - // Make sure c is a map. - if c.Kind() != reflect.Map { - err = NewFatalError("which is not a map") - return - } - - err = errors.New("") - if c.Pointer() == e.Pointer() { - err = nil - } - return -} - -func checkAgainstPtr(e reflect.Value, c reflect.Value) (err error) { - // Create a description of e's type, e.g. "*int". - typeStr := fmt.Sprintf("*%v", e.Type().Elem()) - - // Make sure c is a pointer of the correct type. - if c.Kind() != reflect.Ptr || - c.Type().Elem() != e.Type().Elem() { - err = NewFatalError(fmt.Sprintf("which is not a %s", typeStr)) - return - } - - err = errors.New("") - if c.Pointer() == e.Pointer() { - err = nil - } - return -} - -func checkAgainstSlice(e reflect.Value, c reflect.Value) (err error) { - // Create a description of e's type, e.g. "[]int". - typeStr := fmt.Sprintf("[]%v", e.Type().Elem()) - - // Make sure c is a slice of the correct type. - if c.Kind() != reflect.Slice || - c.Type().Elem() != e.Type().Elem() { - err = NewFatalError(fmt.Sprintf("which is not a %s", typeStr)) - return - } - - err = errors.New("") - if c.Pointer() == e.Pointer() { - err = nil - } - return -} - -func checkAgainstString(e reflect.Value, c reflect.Value) (err error) { - // Make sure c is a string. - if c.Kind() != reflect.String { - err = NewFatalError("which is not a string") - return - } - - err = errors.New("") - if c.String() == e.String() { - err = nil - } - return -} - -func checkAgainstArray(e reflect.Value, c reflect.Value) (err error) { - // Create a description of e's type, e.g. "[2]int". - typeStr := fmt.Sprintf("%v", e.Type()) - - // Make sure c is the correct type. - if c.Type() != e.Type() { - err = NewFatalError(fmt.Sprintf("which is not %s", typeStr)) - return - } - - // Check for equality. - if e.Interface() != c.Interface() { - err = errors.New("") - return - } - - return -} - -func checkAgainstUnsafePointer(e reflect.Value, c reflect.Value) (err error) { - // Make sure c is a pointer. - if c.Kind() != reflect.UnsafePointer { - err = NewFatalError("which is not a unsafe.Pointer") - return - } - - err = errors.New("") - if c.Pointer() == e.Pointer() { - err = nil - } - return -} - -func checkForNil(c reflect.Value) (err error) { - err = errors.New("") - - // Make sure it is legal to call IsNil. - switch c.Kind() { - case reflect.Invalid: - case reflect.Chan: - case reflect.Func: - case reflect.Interface: - case reflect.Map: - case reflect.Ptr: - case reflect.Slice: - - default: - err = NewFatalError("which cannot be compared to nil") - return - } - - // Ask whether the value is nil. Handle a nil literal (kind Invalid) - // specially, since it's not legal to call IsNil there. - if c.Kind() == reflect.Invalid || c.IsNil() { - err = nil - } - return -} - -//////////////////////////////////////////////////////////////////////// -// Public implementation -//////////////////////////////////////////////////////////////////////// - -func (m *equalsMatcher) Matches(candidate interface{}) error { - e := m.expectedValue - c := reflect.ValueOf(candidate) - ek := e.Kind() - - switch { - case ek == reflect.Bool: - return checkAgainstBool(e.Bool(), c) - - case isSignedInteger(e): - return checkAgainstInt64(e.Int(), c) - - case isUnsignedInteger(e): - return checkAgainstUint64(e.Uint(), c) - - case ek == reflect.Float32: - return checkAgainstFloat32(float32(e.Float()), c) - - case ek == reflect.Float64: - return checkAgainstFloat64(e.Float(), c) - - case ek == reflect.Complex64: - return checkAgainstComplex64(complex64(e.Complex()), c) - - case ek == reflect.Complex128: - return checkAgainstComplex128(complex128(e.Complex()), c) - - case ek == reflect.Chan: - return checkAgainstChan(e, c) - - case ek == reflect.Func: - return checkAgainstFunc(e, c) - - case ek == reflect.Map: - return checkAgainstMap(e, c) - - case ek == reflect.Ptr: - return checkAgainstPtr(e, c) - - case ek == reflect.Slice: - return checkAgainstSlice(e, c) - - case ek == reflect.String: - return checkAgainstString(e, c) - - case ek == reflect.Array: - return checkAgainstArray(e, c) - - case ek == reflect.UnsafePointer: - return checkAgainstUnsafePointer(e, c) - - case ek == reflect.Invalid: - return checkForNil(c) - } - - panic(fmt.Sprintf("equalsMatcher.Matches: unexpected kind: %v", ek)) -} - -func (m *equalsMatcher) Description() string { - // Special case: handle nil. - if !m.expectedValue.IsValid() { - return "is nil" - } - - return fmt.Sprintf("%v", m.expectedValue.Interface()) -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/error.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/error.go deleted file mode 100644 index 8a078e36d8..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/error.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -// Error returns a matcher that matches non-nil values implementing the -// built-in error interface for whom the return value of Error() matches the -// supplied matcher. -// -// For example: -// -// err := errors.New("taco burrito") -// -// Error(Equals("taco burrito")) // matches err -// Error(HasSubstr("taco")) // matches err -// Error(HasSubstr("enchilada")) // doesn't match err -// -func Error(m Matcher) Matcher { - return &errorMatcher{m} -} - -type errorMatcher struct { - wrappedMatcher Matcher -} - -func (m *errorMatcher) Description() string { - return "error " + m.wrappedMatcher.Description() -} - -func (m *errorMatcher) Matches(c interface{}) error { - // Make sure that c is an error. - e, ok := c.(error) - if !ok { - return NewFatalError("which is not an error") - } - - // Pass on the error text to the wrapped matcher. - return m.wrappedMatcher.Matches(e.Error()) -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal.go deleted file mode 100644 index 4b9d103a38..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "fmt" - "reflect" -) - -// GreaterOrEqual returns a matcher that matches integer, floating point, or -// strings values v such that v >= x. Comparison is not defined between numeric -// and string types, but is defined between all integer and floating point -// types. -// -// x must itself be an integer, floating point, or string type; otherwise, -// GreaterOrEqual will panic. -func GreaterOrEqual(x interface{}) Matcher { - desc := fmt.Sprintf("greater than or equal to %v", x) - - // Special case: make it clear that strings are strings. - if reflect.TypeOf(x).Kind() == reflect.String { - desc = fmt.Sprintf("greater than or equal to \"%s\"", x) - } - - return transformDescription(Not(LessThan(x)), desc) -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/greater_than.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/greater_than.go deleted file mode 100644 index 3eef32178f..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/greater_than.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "fmt" - "reflect" -) - -// GreaterThan returns a matcher that matches integer, floating point, or -// strings values v such that v > x. Comparison is not defined between numeric -// and string types, but is defined between all integer and floating point -// types. -// -// x must itself be an integer, floating point, or string type; otherwise, -// GreaterThan will panic. -func GreaterThan(x interface{}) Matcher { - desc := fmt.Sprintf("greater than %v", x) - - // Special case: make it clear that strings are strings. - if reflect.TypeOf(x).Kind() == reflect.String { - desc = fmt.Sprintf("greater than \"%s\"", x) - } - - return transformDescription(Not(LessOrEqual(x)), desc) -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as.go deleted file mode 100644 index 3b286f7321..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2015 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "fmt" - "reflect" -) - -// HasSameTypeAs returns a matcher that matches values with exactly the same -// type as the supplied prototype. -func HasSameTypeAs(p interface{}) Matcher { - expected := reflect.TypeOf(p) - pred := func(c interface{}) error { - actual := reflect.TypeOf(c) - if actual != expected { - return fmt.Errorf("which has type %v", actual) - } - - return nil - } - - return NewMatcher(pred, fmt.Sprintf("has type %v", expected)) -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/has_substr.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/has_substr.go deleted file mode 100644 index bf5bd6ae6d..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/has_substr.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "reflect" - "strings" -) - -// HasSubstr returns a matcher that matches strings containing s as a -// substring. -func HasSubstr(s string) Matcher { - return NewMatcher( - func(c interface{}) error { return hasSubstr(s, c) }, - fmt.Sprintf("has substring \"%s\"", s)) -} - -func hasSubstr(needle string, c interface{}) error { - v := reflect.ValueOf(c) - if v.Kind() != reflect.String { - return NewFatalError("which is not a string") - } - - // Perform the substring search. - haystack := v.String() - if strings.Contains(haystack, needle) { - return nil - } - - return errors.New("") -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/identical_to.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/identical_to.go deleted file mode 100644 index ae6460ed96..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/identical_to.go +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "reflect" -) - -// Is the type comparable according to the definition here? -// -// http://weekly.golang.org/doc/go_spec.html#Comparison_operators -// -func isComparable(t reflect.Type) bool { - switch t.Kind() { - case reflect.Array: - return isComparable(t.Elem()) - - case reflect.Struct: - for i := 0; i < t.NumField(); i++ { - if !isComparable(t.Field(i).Type) { - return false - } - } - - return true - - case reflect.Slice, reflect.Map, reflect.Func: - return false - } - - return true -} - -// Should the supplied type be allowed as an argument to IdenticalTo? -func isLegalForIdenticalTo(t reflect.Type) (bool, error) { - // Allow the zero type. - if t == nil { - return true, nil - } - - // Reference types are always okay; we compare pointers. - switch t.Kind() { - case reflect.Slice, reflect.Map, reflect.Func, reflect.Chan: - return true, nil - } - - // Reject other non-comparable types. - if !isComparable(t) { - return false, errors.New(fmt.Sprintf("%v is not comparable", t)) - } - - return true, nil -} - -// IdenticalTo(x) returns a matcher that matches values v with type identical -// to x such that: -// -// 1. If v and x are of a reference type (slice, map, function, channel), then -// they are either both nil or are references to the same object. -// -// 2. Otherwise, if v and x are not of a reference type but have a valid type, -// then v == x. -// -// If v and x are both the invalid type (which results from the predeclared nil -// value, or from nil interface variables), then the matcher is satisfied. -// -// This function will panic if x is of a value type that is not comparable. For -// example, x cannot be an array of functions. -func IdenticalTo(x interface{}) Matcher { - t := reflect.TypeOf(x) - - // Reject illegal arguments. - if ok, err := isLegalForIdenticalTo(t); !ok { - panic("IdenticalTo: " + err.Error()) - } - - return &identicalToMatcher{x} -} - -type identicalToMatcher struct { - x interface{} -} - -func (m *identicalToMatcher) Description() string { - t := reflect.TypeOf(m.x) - return fmt.Sprintf("identical to <%v> %v", t, m.x) -} - -func (m *identicalToMatcher) Matches(c interface{}) error { - // Make sure the candidate's type is correct. - t := reflect.TypeOf(m.x) - if ct := reflect.TypeOf(c); t != ct { - return NewFatalError(fmt.Sprintf("which is of type %v", ct)) - } - - // Special case: two values of the invalid type are always identical. - if t == nil { - return nil - } - - // Handle reference types. - switch t.Kind() { - case reflect.Slice, reflect.Map, reflect.Func, reflect.Chan: - xv := reflect.ValueOf(m.x) - cv := reflect.ValueOf(c) - if xv.Pointer() == cv.Pointer() { - return nil - } - - return errors.New("which is not an identical reference") - } - - // Are the values equal? - if m.x == c { - return nil - } - - return errors.New("") -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal.go deleted file mode 100644 index 8402cdeaf0..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "fmt" - "reflect" -) - -// LessOrEqual returns a matcher that matches integer, floating point, or -// strings values v such that v <= x. Comparison is not defined between numeric -// and string types, but is defined between all integer and floating point -// types. -// -// x must itself be an integer, floating point, or string type; otherwise, -// LessOrEqual will panic. -func LessOrEqual(x interface{}) Matcher { - desc := fmt.Sprintf("less than or equal to %v", x) - - // Special case: make it clear that strings are strings. - if reflect.TypeOf(x).Kind() == reflect.String { - desc = fmt.Sprintf("less than or equal to \"%s\"", x) - } - - // Put LessThan last so that its error messages will be used in the event of - // failure. - return transformDescription(AnyOf(Equals(x), LessThan(x)), desc) -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/less_than.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/less_than.go deleted file mode 100644 index 8258e45d99..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/less_than.go +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "math" - "reflect" -) - -// LessThan returns a matcher that matches integer, floating point, or strings -// values v such that v < x. Comparison is not defined between numeric and -// string types, but is defined between all integer and floating point types. -// -// x must itself be an integer, floating point, or string type; otherwise, -// LessThan will panic. -func LessThan(x interface{}) Matcher { - v := reflect.ValueOf(x) - kind := v.Kind() - - switch { - case isInteger(v): - case isFloat(v): - case kind == reflect.String: - - default: - panic(fmt.Sprintf("LessThan: unexpected kind %v", kind)) - } - - return &lessThanMatcher{v} -} - -type lessThanMatcher struct { - limit reflect.Value -} - -func (m *lessThanMatcher) Description() string { - // Special case: make it clear that strings are strings. - if m.limit.Kind() == reflect.String { - return fmt.Sprintf("less than \"%s\"", m.limit.String()) - } - - return fmt.Sprintf("less than %v", m.limit.Interface()) -} - -func compareIntegers(v1, v2 reflect.Value) (err error) { - err = errors.New("") - - switch { - case isSignedInteger(v1) && isSignedInteger(v2): - if v1.Int() < v2.Int() { - err = nil - } - return - - case isSignedInteger(v1) && isUnsignedInteger(v2): - if v1.Int() < 0 || uint64(v1.Int()) < v2.Uint() { - err = nil - } - return - - case isUnsignedInteger(v1) && isSignedInteger(v2): - if v1.Uint() <= math.MaxInt64 && int64(v1.Uint()) < v2.Int() { - err = nil - } - return - - case isUnsignedInteger(v1) && isUnsignedInteger(v2): - if v1.Uint() < v2.Uint() { - err = nil - } - return - } - - panic(fmt.Sprintf("compareIntegers: %v %v", v1, v2)) -} - -func getFloat(v reflect.Value) float64 { - switch { - case isSignedInteger(v): - return float64(v.Int()) - - case isUnsignedInteger(v): - return float64(v.Uint()) - - case isFloat(v): - return v.Float() - } - - panic(fmt.Sprintf("getFloat: %v", v)) -} - -func (m *lessThanMatcher) Matches(c interface{}) (err error) { - v1 := reflect.ValueOf(c) - v2 := m.limit - - err = errors.New("") - - // Handle strings as a special case. - if v1.Kind() == reflect.String && v2.Kind() == reflect.String { - if v1.String() < v2.String() { - err = nil - } - return - } - - // If we get here, we require that we are dealing with integers or floats. - v1Legal := isInteger(v1) || isFloat(v1) - v2Legal := isInteger(v2) || isFloat(v2) - if !v1Legal || !v2Legal { - err = NewFatalError("which is not comparable") - return - } - - // Handle the various comparison cases. - switch { - // Both integers - case isInteger(v1) && isInteger(v2): - return compareIntegers(v1, v2) - - // At least one float32 - case v1.Kind() == reflect.Float32 || v2.Kind() == reflect.Float32: - if float32(getFloat(v1)) < float32(getFloat(v2)) { - err = nil - } - return - - // At least one float64 - case v1.Kind() == reflect.Float64 || v2.Kind() == reflect.Float64: - if getFloat(v1) < getFloat(v2) { - err = nil - } - return - } - - // We shouldn't get here. - panic(fmt.Sprintf("lessThanMatcher.Matches: Shouldn't get here: %v %v", v1, v2)) -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/matcher.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/matcher.go deleted file mode 100644 index 78159a0727..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/matcher.go +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package oglematchers provides a set of matchers useful in a testing or -// mocking framework. These matchers are inspired by and mostly compatible with -// Google Test for C++ and Google JS Test. -// -// This package is used by github.com/smartystreets/assertions/internal/ogletest and -// github.com/smartystreets/assertions/internal/oglemock, which may be more directly useful if you're not -// writing your own testing package or defining your own matchers. -package oglematchers - -// A Matcher is some predicate implicitly defining a set of values that it -// matches. For example, GreaterThan(17) matches all numeric values greater -// than 17, and HasSubstr("taco") matches all strings with the substring -// "taco". -// -// Matchers are typically exposed to tests via constructor functions like -// HasSubstr. In order to implement such a function you can either define your -// own matcher type or use NewMatcher. -type Matcher interface { - // Check whether the supplied value belongs to the the set defined by the - // matcher. Return a non-nil error if and only if it does not. - // - // The error describes why the value doesn't match. The error text is a - // relative clause that is suitable for being placed after the value. For - // example, a predicate that matches strings with a particular substring may, - // when presented with a numerical value, return the following error text: - // - // "which is not a string" - // - // Then the failure message may look like: - // - // Expected: has substring "taco" - // Actual: 17, which is not a string - // - // If the error is self-apparent based on the description of the matcher, the - // error text may be empty (but the error still non-nil). For example: - // - // Expected: 17 - // Actual: 19 - // - // If you are implementing a new matcher, see also the documentation on - // FatalError. - Matches(candidate interface{}) error - - // Description returns a string describing the property that values matching - // this matcher have, as a verb phrase where the subject is the value. For - // example, "is greather than 17" or "has substring "taco"". - Description() string -} - -// FatalError is an implementation of the error interface that may be returned -// from matchers, indicating the error should be propagated. Returning a -// *FatalError indicates that the matcher doesn't process values of the -// supplied type, or otherwise doesn't know how to handle the value. -// -// For example, if GreaterThan(17) returned false for the value "taco" without -// a fatal error, then Not(GreaterThan(17)) would return true. This is -// technically correct, but is surprising and may mask failures where the wrong -// sort of matcher is accidentally used. Instead, GreaterThan(17) can return a -// fatal error, which will be propagated by Not(). -type FatalError struct { - errorText string -} - -// NewFatalError creates a FatalError struct with the supplied error text. -func NewFatalError(s string) *FatalError { - return &FatalError{s} -} - -func (e *FatalError) Error() string { - return e.errorText -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp.go deleted file mode 100644 index 1ed63f30c4..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp.go +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "reflect" - "regexp" -) - -// MatchesRegexp returns a matcher that matches strings and byte slices whose -// contents match the supplied regular expression. The semantics are those of -// regexp.Match. In particular, that means the match is not implicitly anchored -// to the ends of the string: MatchesRegexp("bar") will match "foo bar baz". -func MatchesRegexp(pattern string) Matcher { - re, err := regexp.Compile(pattern) - if err != nil { - panic("MatchesRegexp: " + err.Error()) - } - - return &matchesRegexpMatcher{re} -} - -type matchesRegexpMatcher struct { - re *regexp.Regexp -} - -func (m *matchesRegexpMatcher) Description() string { - return fmt.Sprintf("matches regexp \"%s\"", m.re.String()) -} - -func (m *matchesRegexpMatcher) Matches(c interface{}) (err error) { - v := reflect.ValueOf(c) - isString := v.Kind() == reflect.String - isByteSlice := v.Kind() == reflect.Slice && v.Elem().Kind() == reflect.Uint8 - - err = errors.New("") - - switch { - case isString: - if m.re.MatchString(v.String()) { - err = nil - } - - case isByteSlice: - if m.re.Match(v.Bytes()) { - err = nil - } - - default: - err = NewFatalError("which is not a string or []byte") - } - - return -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/new_matcher.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/new_matcher.go deleted file mode 100644 index c9d8398ee6..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/new_matcher.go +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2015 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -// Create a matcher with the given description and predicate function, which -// will be invoked to handle calls to Matchers. -// -// Using this constructor may be a convenience over defining your own type that -// implements Matcher if you do not need any logic in your Description method. -func NewMatcher( - predicate func(interface{}) error, - description string) Matcher { - return &predicateMatcher{ - predicate: predicate, - description: description, - } -} - -type predicateMatcher struct { - predicate func(interface{}) error - description string -} - -func (pm *predicateMatcher) Matches(c interface{}) error { - return pm.predicate(c) -} - -func (pm *predicateMatcher) Description() string { - return pm.description -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/not.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/not.go deleted file mode 100644 index 623789fe28..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/not.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" -) - -// Not returns a matcher that inverts the set of values matched by the wrapped -// matcher. It does not transform the result for values for which the wrapped -// matcher returns a fatal error. -func Not(m Matcher) Matcher { - return ¬Matcher{m} -} - -type notMatcher struct { - wrapped Matcher -} - -func (m *notMatcher) Matches(c interface{}) (err error) { - err = m.wrapped.Matches(c) - - // Did the wrapped matcher say yes? - if err == nil { - return errors.New("") - } - - // Did the wrapped matcher return a fatal error? - if _, isFatal := err.(*FatalError); isFatal { - return err - } - - // The wrapped matcher returned a non-fatal error. - return nil -} - -func (m *notMatcher) Description() string { - return fmt.Sprintf("not(%s)", m.wrapped.Description()) -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/panics.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/panics.go deleted file mode 100644 index d2cfc97869..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/panics.go +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "reflect" -) - -// Panics matches zero-arg functions which, when invoked, panic with an error -// that matches the supplied matcher. -// -// NOTE(jacobsa): This matcher cannot detect the case where the function panics -// using panic(nil), by design of the language. See here for more info: -// -// http://goo.gl/9aIQL -// -func Panics(m Matcher) Matcher { - return &panicsMatcher{m} -} - -type panicsMatcher struct { - wrappedMatcher Matcher -} - -func (m *panicsMatcher) Description() string { - return "panics with: " + m.wrappedMatcher.Description() -} - -func (m *panicsMatcher) Matches(c interface{}) (err error) { - // Make sure c is a zero-arg function. - v := reflect.ValueOf(c) - if v.Kind() != reflect.Func || v.Type().NumIn() != 0 { - err = NewFatalError("which is not a zero-arg function") - return - } - - // Call the function and check its panic error. - defer func() { - if e := recover(); e != nil { - err = m.wrappedMatcher.Matches(e) - - // Set a clearer error message if the matcher said no. - if err != nil { - wrappedClause := "" - if err.Error() != "" { - wrappedClause = ", " + err.Error() - } - - err = errors.New(fmt.Sprintf("which panicked with: %v%s", e, wrappedClause)) - } - } - }() - - v.Call([]reflect.Value{}) - - // If we get here, the function didn't panic. - err = errors.New("which didn't panic") - return -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/pointee.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/pointee.go deleted file mode 100644 index c5383f2402..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/pointee.go +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2012 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -import ( - "errors" - "fmt" - "reflect" -) - -// Return a matcher that matches non-nil pointers whose pointee matches the -// wrapped matcher. -func Pointee(m Matcher) Matcher { - return &pointeeMatcher{m} -} - -type pointeeMatcher struct { - wrapped Matcher -} - -func (m *pointeeMatcher) Matches(c interface{}) (err error) { - // Make sure the candidate is of the appropriate type. - cv := reflect.ValueOf(c) - if !cv.IsValid() || cv.Kind() != reflect.Ptr { - return NewFatalError("which is not a pointer") - } - - // Make sure the candidate is non-nil. - if cv.IsNil() { - return NewFatalError("") - } - - // Defer to the wrapped matcher. Fix up empty errors so that failure messages - // are more helpful than just printing a pointer for "Actual". - pointee := cv.Elem().Interface() - err = m.wrapped.Matches(pointee) - if err != nil && err.Error() == "" { - s := fmt.Sprintf("whose pointee is %v", pointee) - - if _, ok := err.(*FatalError); ok { - err = NewFatalError(s) - } else { - err = errors.New(s) - } - } - - return err -} - -func (m *pointeeMatcher) Description() string { - return fmt.Sprintf("pointee(%s)", m.wrapped.Description()) -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/transform_description.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/transform_description.go deleted file mode 100644 index f79d0c03db..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/internal/oglematchers/transform_description.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2011 Aaron Jacobs. All Rights Reserved. -// Author: aaronjjacobs@gmail.com (Aaron Jacobs) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package oglematchers - -// transformDescription returns a matcher that is equivalent to the supplied -// one, except that it has the supplied description instead of the one attached -// to the existing matcher. -func transformDescription(m Matcher, newDesc string) Matcher { - return &transformDescriptionMatcher{newDesc, m} -} - -type transformDescriptionMatcher struct { - desc string - wrappedMatcher Matcher -} - -func (m *transformDescriptionMatcher) Description() string { - return m.desc -} - -func (m *transformDescriptionMatcher) Matches(c interface{}) error { - return m.wrappedMatcher.Matches(c) -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/messages.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/messages.go deleted file mode 100644 index 9c57ab2b8b..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/messages.go +++ /dev/null @@ -1,93 +0,0 @@ -package assertions - -const ( // equality - shouldHaveBeenEqual = "Expected: '%v'\nActual: '%v'\n(Should be equal)" - shouldNotHaveBeenEqual = "Expected '%v'\nto NOT equal '%v'\n(but it did)!" - shouldHaveBeenEqualTypeMismatch = "Expected: '%v' (%T)\nActual: '%v' (%T)\n(Should be equal, type mismatch)" - shouldHaveBeenAlmostEqual = "Expected '%v' to almost equal '%v' (but it didn't)!" - shouldHaveNotBeenAlmostEqual = "Expected '%v' to NOT almost equal '%v' (but it did)!" - shouldHaveResembled = "Expected: '%s'\nActual: '%s'\n(Should resemble)!" - shouldNotHaveResembled = "Expected '%#v'\nto NOT resemble '%#v'\n(but it did)!" - shouldBePointers = "Both arguments should be pointers " - shouldHaveBeenNonNilPointer = shouldBePointers + "(the %s was %s)!" - shouldHavePointedTo = "Expected '%+v' (address: '%v') and '%+v' (address: '%v') to be the same address (but their weren't)!" - shouldNotHavePointedTo = "Expected '%+v' and '%+v' to be different references (but they matched: '%v')!" - shouldHaveBeenNil = "Expected: nil\nActual: '%v'" - shouldNotHaveBeenNil = "Expected '%+v' to NOT be nil (but it was)!" - shouldHaveBeenTrue = "Expected: true\nActual: %v" - shouldHaveBeenFalse = "Expected: false\nActual: %v" - shouldHaveBeenZeroValue = "'%+v' should have been the zero value" //"Expected: (zero value)\nActual: %v" -) - -const ( // quantity comparisons - shouldHaveBeenGreater = "Expected '%v' to be greater than '%v' (but it wasn't)!" - shouldHaveBeenGreaterOrEqual = "Expected '%v' to be greater than or equal to '%v' (but it wasn't)!" - shouldHaveBeenLess = "Expected '%v' to be less than '%v' (but it wasn't)!" - shouldHaveBeenLessOrEqual = "Expected '%v' to be less than or equal to '%v' (but it wasn't)!" - shouldHaveBeenBetween = "Expected '%v' to be between '%v' and '%v' (but it wasn't)!" - shouldNotHaveBeenBetween = "Expected '%v' NOT to be between '%v' and '%v' (but it was)!" - shouldHaveDifferentUpperAndLower = "The lower and upper bounds must be different values (they were both '%v')." - shouldHaveBeenBetweenOrEqual = "Expected '%v' to be between '%v' and '%v' or equal to one of them (but it wasn't)!" - shouldNotHaveBeenBetweenOrEqual = "Expected '%v' NOT to be between '%v' and '%v' or equal to one of them (but it was)!" -) - -const ( // collections - shouldHaveContained = "Expected the container (%v) to contain: '%v' (but it didn't)!" - shouldNotHaveContained = "Expected the container (%v) NOT to contain: '%v' (but it did)!" - shouldHaveContainedKey = "Expected the %v to contain the key: %v (but it didn't)!" - shouldNotHaveContainedKey = "Expected the %v NOT to contain the key: %v (but it did)!" - shouldHaveBeenIn = "Expected '%v' to be in the container (%v), but it wasn't!" - shouldNotHaveBeenIn = "Expected '%v' NOT to be in the container (%v), but it was!" - shouldHaveBeenAValidCollection = "You must provide a valid container (was %v)!" - shouldHaveBeenAValidMap = "You must provide a valid map type (was %v)!" - shouldHaveBeenEmpty = "Expected %+v to be empty (but it wasn't)!" - shouldNotHaveBeenEmpty = "Expected %+v to NOT be empty (but it was)!" - shouldHaveBeenAValidInteger = "You must provide a valid integer (was %v)!" - shouldHaveBeenAValidLength = "You must provide a valid positive integer (was %v)!" - shouldHaveHadLength = "Expected %+v (length: %v) to have length equal to '%v', but it wasn't!" -) - -const ( // strings - shouldHaveStartedWith = "Expected '%v'\nto start with '%v'\n(but it didn't)!" - shouldNotHaveStartedWith = "Expected '%v'\nNOT to start with '%v'\n(but it did)!" - shouldHaveEndedWith = "Expected '%v'\nto end with '%v'\n(but it didn't)!" - shouldNotHaveEndedWith = "Expected '%v'\nNOT to end with '%v'\n(but it did)!" - shouldAllBeStrings = "All arguments to this assertion must be strings (you provided: %v)." - shouldBothBeStrings = "Both arguments to this assertion must be strings (you provided %v and %v)." - shouldBeString = "The argument to this assertion must be a string (you provided %v)." - shouldHaveContainedSubstring = "Expected '%s' to contain substring '%s' (but it didn't)!" - shouldNotHaveContainedSubstring = "Expected '%s' NOT to contain substring '%s' (but it did)!" - shouldHaveBeenBlank = "Expected '%s' to be blank (but it wasn't)!" - shouldNotHaveBeenBlank = "Expected value to NOT be blank (but it was)!" -) - -const ( // panics - shouldUseVoidNiladicFunction = "You must provide a void, niladic function as the first argument!" - shouldHavePanickedWith = "Expected func() to panic with '%v' (but it panicked with '%v')!" - shouldHavePanicked = "Expected func() to panic (but it didn't)!" - shouldNotHavePanicked = "Expected func() NOT to panic (error: '%+v')!" - shouldNotHavePanickedWith = "Expected func() NOT to panic with '%v' (but it did)!" -) - -const ( // type checking - shouldHaveBeenA = "Expected '%v' to be: '%v' (but was: '%v')!" - shouldNotHaveBeenA = "Expected '%v' to NOT be: '%v' (but it was)!" - - shouldHaveImplemented = "Expected: '%v interface support'\nActual: '%v' does not implement the interface!" - shouldNotHaveImplemented = "Expected '%v'\nto NOT implement '%v'\n(but it did)!" - shouldCompareWithInterfacePointer = "The expected value must be a pointer to an interface type (eg. *fmt.Stringer)" - shouldNotBeNilActual = "The actual value was 'nil' and should be a value or a pointer to a value!" -) - -const ( // time comparisons - shouldUseTimes = "You must provide time instances as arguments to this assertion." - shouldUseTimeSlice = "You must provide a slice of time instances as the first argument to this assertion." - shouldUseDurationAndTime = "You must provide a duration and a time as arguments to this assertion." - shouldHaveHappenedBefore = "Expected '%v' to happen before '%v' (it happened '%v' after)!" - shouldHaveHappenedAfter = "Expected '%v' to happen after '%v' (it happened '%v' before)!" - shouldHaveHappenedBetween = "Expected '%v' to happen between '%v' and '%v' (it happened '%v' outside threshold)!" - shouldNotHaveHappenedOnOrBetween = "Expected '%v' to NOT happen on or between '%v' and '%v' (but it did)!" - - // format params: incorrect-index, previous-index, previous-time, incorrect-index, incorrect-time - shouldHaveBeenChronological = "The 'Time' at index [%d] should have happened after the previous one (but it didn't!):\n [%d]: %s\n [%d]: %s (see, it happened before!)" -) diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/panic.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/panic.go deleted file mode 100644 index 7e75db1784..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/panic.go +++ /dev/null @@ -1,115 +0,0 @@ -package assertions - -import "fmt" - -// ShouldPanic receives a void, niladic function and expects to recover a panic. -func ShouldPanic(actual interface{}, expected ...interface{}) (message string) { - if fail := need(0, expected); fail != success { - return fail - } - - action, _ := actual.(func()) - - if action == nil { - message = shouldUseVoidNiladicFunction - return - } - - defer func() { - recovered := recover() - if recovered == nil { - message = shouldHavePanicked - } else { - message = success - } - }() - action() - - return -} - -// ShouldNotPanic receives a void, niladic function and expects to execute the function without any panic. -func ShouldNotPanic(actual interface{}, expected ...interface{}) (message string) { - if fail := need(0, expected); fail != success { - return fail - } - - action, _ := actual.(func()) - - if action == nil { - message = shouldUseVoidNiladicFunction - return - } - - defer func() { - recovered := recover() - if recovered != nil { - message = fmt.Sprintf(shouldNotHavePanicked, recovered) - } else { - message = success - } - }() - action() - - return -} - -// ShouldPanicWith receives a void, niladic function and expects to recover a panic with the second argument as the content. -func ShouldPanicWith(actual interface{}, expected ...interface{}) (message string) { - if fail := need(1, expected); fail != success { - return fail - } - - action, _ := actual.(func()) - - if action == nil { - message = shouldUseVoidNiladicFunction - return - } - - defer func() { - recovered := recover() - if recovered == nil { - message = shouldHavePanicked - } else { - if equal := ShouldEqual(recovered, expected[0]); equal != success { - message = serializer.serialize(expected[0], recovered, fmt.Sprintf(shouldHavePanickedWith, expected[0], recovered)) - } else { - message = success - } - } - }() - action() - - return -} - -// ShouldNotPanicWith receives a void, niladic function and expects to recover a panic whose content differs from the second argument. -func ShouldNotPanicWith(actual interface{}, expected ...interface{}) (message string) { - if fail := need(1, expected); fail != success { - return fail - } - - action, _ := actual.(func()) - - if action == nil { - message = shouldUseVoidNiladicFunction - return - } - - defer func() { - recovered := recover() - if recovered == nil { - message = success - } else { - if equal := ShouldEqual(recovered, expected[0]); equal == success { - message = fmt.Sprintf(shouldNotHavePanickedWith, expected[0]) - } else { - message = success - } - } - }() - action() - - return -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/quantity.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/quantity.go deleted file mode 100644 index f28b0a062b..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/quantity.go +++ /dev/null @@ -1,141 +0,0 @@ -package assertions - -import ( - "fmt" - - "github.com/smartystreets/assertions/internal/oglematchers" -) - -// ShouldBeGreaterThan receives exactly two parameters and ensures that the first is greater than the second. -func ShouldBeGreaterThan(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - if matchError := oglematchers.GreaterThan(expected[0]).Matches(actual); matchError != nil { - return fmt.Sprintf(shouldHaveBeenGreater, actual, expected[0]) - } - return success -} - -// ShouldBeGreaterThanOrEqualTo receives exactly two parameters and ensures that the first is greater than or equal to the second. -func ShouldBeGreaterThanOrEqualTo(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } else if matchError := oglematchers.GreaterOrEqual(expected[0]).Matches(actual); matchError != nil { - return fmt.Sprintf(shouldHaveBeenGreaterOrEqual, actual, expected[0]) - } - return success -} - -// ShouldBeLessThan receives exactly two parameters and ensures that the first is less than the second. -func ShouldBeLessThan(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } else if matchError := oglematchers.LessThan(expected[0]).Matches(actual); matchError != nil { - return fmt.Sprintf(shouldHaveBeenLess, actual, expected[0]) - } - return success -} - -// ShouldBeLessThan receives exactly two parameters and ensures that the first is less than or equal to the second. -func ShouldBeLessThanOrEqualTo(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } else if matchError := oglematchers.LessOrEqual(expected[0]).Matches(actual); matchError != nil { - return fmt.Sprintf(shouldHaveBeenLessOrEqual, actual, expected[0]) - } - return success -} - -// ShouldBeBetween receives exactly three parameters: an actual value, a lower bound, and an upper bound. -// It ensures that the actual value is between both bounds (but not equal to either of them). -func ShouldBeBetween(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - lower, upper, fail := deriveBounds(expected) - - if fail != success { - return fail - } else if !isBetween(actual, lower, upper) { - return fmt.Sprintf(shouldHaveBeenBetween, actual, lower, upper) - } - return success -} - -// ShouldNotBeBetween receives exactly three parameters: an actual value, a lower bound, and an upper bound. -// It ensures that the actual value is NOT between both bounds. -func ShouldNotBeBetween(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - lower, upper, fail := deriveBounds(expected) - - if fail != success { - return fail - } else if isBetween(actual, lower, upper) { - return fmt.Sprintf(shouldNotHaveBeenBetween, actual, lower, upper) - } - return success -} -func deriveBounds(values []interface{}) (lower interface{}, upper interface{}, fail string) { - lower = values[0] - upper = values[1] - - if ShouldNotEqual(lower, upper) != success { - return nil, nil, fmt.Sprintf(shouldHaveDifferentUpperAndLower, lower) - } else if ShouldBeLessThan(lower, upper) != success { - lower, upper = upper, lower - } - return lower, upper, success -} -func isBetween(value, lower, upper interface{}) bool { - if ShouldBeGreaterThan(value, lower) != success { - return false - } else if ShouldBeLessThan(value, upper) != success { - return false - } - return true -} - -// ShouldBeBetweenOrEqual receives exactly three parameters: an actual value, a lower bound, and an upper bound. -// It ensures that the actual value is between both bounds or equal to one of them. -func ShouldBeBetweenOrEqual(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - lower, upper, fail := deriveBounds(expected) - - if fail != success { - return fail - } else if !isBetweenOrEqual(actual, lower, upper) { - return fmt.Sprintf(shouldHaveBeenBetweenOrEqual, actual, lower, upper) - } - return success -} - -// ShouldNotBeBetweenOrEqual receives exactly three parameters: an actual value, a lower bound, and an upper bound. -// It ensures that the actual value is nopt between the bounds nor equal to either of them. -func ShouldNotBeBetweenOrEqual(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - lower, upper, fail := deriveBounds(expected) - - if fail != success { - return fail - } else if isBetweenOrEqual(actual, lower, upper) { - return fmt.Sprintf(shouldNotHaveBeenBetweenOrEqual, actual, lower, upper) - } - return success -} - -func isBetweenOrEqual(value, lower, upper interface{}) bool { - if ShouldBeGreaterThanOrEqualTo(value, lower) != success { - return false - } else if ShouldBeLessThanOrEqualTo(value, upper) != success { - return false - } - return true -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/serializer.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/serializer.go deleted file mode 100644 index 90ae3e3b69..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/serializer.go +++ /dev/null @@ -1,69 +0,0 @@ -package assertions - -import ( - "encoding/json" - "fmt" - - "github.com/smartystreets/assertions/internal/go-render/render" -) - -type Serializer interface { - serialize(expected, actual interface{}, message string) string - serializeDetailed(expected, actual interface{}, message string) string -} - -type failureSerializer struct{} - -func (self *failureSerializer) serializeDetailed(expected, actual interface{}, message string) string { - view := FailureView{ - Message: message, - Expected: render.Render(expected), - Actual: render.Render(actual), - } - serialized, err := json.Marshal(view) - if err != nil { - return message - } - return string(serialized) -} - -func (self *failureSerializer) serialize(expected, actual interface{}, message string) string { - view := FailureView{ - Message: message, - Expected: fmt.Sprintf("%+v", expected), - Actual: fmt.Sprintf("%+v", actual), - } - serialized, err := json.Marshal(view) - if err != nil { - return message - } - return string(serialized) -} - -func newSerializer() *failureSerializer { - return &failureSerializer{} -} - -/////////////////////////////////////////////////////////////////////////////// - -// This struct is also declared in github.com/smartystreets/goconvey/convey/reporting. -// The json struct tags should be equal in both declarations. -type FailureView struct { - Message string `json:"Message"` - Expected string `json:"Expected"` - Actual string `json:"Actual"` -} - -/////////////////////////////////////////////////////// - -// noopSerializer just gives back the original message. This is useful when we are using -// the assertions from a context other than the web UI, that requires the JSON structure -// provided by the failureSerializer. -type noopSerializer struct{} - -func (self *noopSerializer) serialize(expected, actual interface{}, message string) string { - return message -} -func (self *noopSerializer) serializeDetailed(expected, actual interface{}, message string) string { - return message -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/strings.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/strings.go deleted file mode 100644 index dbc3f04790..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/strings.go +++ /dev/null @@ -1,227 +0,0 @@ -package assertions - -import ( - "fmt" - "reflect" - "strings" -) - -// ShouldStartWith receives exactly 2 string parameters and ensures that the first starts with the second. -func ShouldStartWith(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - value, valueIsString := actual.(string) - prefix, prefixIsString := expected[0].(string) - - if !valueIsString || !prefixIsString { - return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) - } - - return shouldStartWith(value, prefix) -} -func shouldStartWith(value, prefix string) string { - if !strings.HasPrefix(value, prefix) { - shortval := value - if len(shortval) > len(prefix) { - shortval = shortval[:len(prefix)] + "..." - } - return serializer.serialize(prefix, shortval, fmt.Sprintf(shouldHaveStartedWith, value, prefix)) - } - return success -} - -// ShouldNotStartWith receives exactly 2 string parameters and ensures that the first does not start with the second. -func ShouldNotStartWith(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - value, valueIsString := actual.(string) - prefix, prefixIsString := expected[0].(string) - - if !valueIsString || !prefixIsString { - return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) - } - - return shouldNotStartWith(value, prefix) -} -func shouldNotStartWith(value, prefix string) string { - if strings.HasPrefix(value, prefix) { - if value == "" { - value = "" - } - if prefix == "" { - prefix = "" - } - return fmt.Sprintf(shouldNotHaveStartedWith, value, prefix) - } - return success -} - -// ShouldEndWith receives exactly 2 string parameters and ensures that the first ends with the second. -func ShouldEndWith(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - value, valueIsString := actual.(string) - suffix, suffixIsString := expected[0].(string) - - if !valueIsString || !suffixIsString { - return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) - } - - return shouldEndWith(value, suffix) -} -func shouldEndWith(value, suffix string) string { - if !strings.HasSuffix(value, suffix) { - shortval := value - if len(shortval) > len(suffix) { - shortval = "..." + shortval[len(shortval)-len(suffix):] - } - return serializer.serialize(suffix, shortval, fmt.Sprintf(shouldHaveEndedWith, value, suffix)) - } - return success -} - -// ShouldEndWith receives exactly 2 string parameters and ensures that the first does not end with the second. -func ShouldNotEndWith(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - value, valueIsString := actual.(string) - suffix, suffixIsString := expected[0].(string) - - if !valueIsString || !suffixIsString { - return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) - } - - return shouldNotEndWith(value, suffix) -} -func shouldNotEndWith(value, suffix string) string { - if strings.HasSuffix(value, suffix) { - if value == "" { - value = "" - } - if suffix == "" { - suffix = "" - } - return fmt.Sprintf(shouldNotHaveEndedWith, value, suffix) - } - return success -} - -// ShouldContainSubstring receives exactly 2 string parameters and ensures that the first contains the second as a substring. -func ShouldContainSubstring(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - long, longOk := actual.(string) - short, shortOk := expected[0].(string) - - if !longOk || !shortOk { - return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) - } - - if !strings.Contains(long, short) { - return serializer.serialize(expected[0], actual, fmt.Sprintf(shouldHaveContainedSubstring, long, short)) - } - return success -} - -// ShouldNotContainSubstring receives exactly 2 string parameters and ensures that the first does NOT contain the second as a substring. -func ShouldNotContainSubstring(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - long, longOk := actual.(string) - short, shortOk := expected[0].(string) - - if !longOk || !shortOk { - return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) - } - - if strings.Contains(long, short) { - return fmt.Sprintf(shouldNotHaveContainedSubstring, long, short) - } - return success -} - -// ShouldBeBlank receives exactly 1 string parameter and ensures that it is equal to "". -func ShouldBeBlank(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } - value, ok := actual.(string) - if !ok { - return fmt.Sprintf(shouldBeString, reflect.TypeOf(actual)) - } - if value != "" { - return serializer.serialize("", value, fmt.Sprintf(shouldHaveBeenBlank, value)) - } - return success -} - -// ShouldNotBeBlank receives exactly 1 string parameter and ensures that it is equal to "". -func ShouldNotBeBlank(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } - value, ok := actual.(string) - if !ok { - return fmt.Sprintf(shouldBeString, reflect.TypeOf(actual)) - } - if value == "" { - return shouldNotHaveBeenBlank - } - return success -} - -// ShouldEqualWithout receives exactly 3 string parameters and ensures that the first is equal to the second -// after removing all instances of the third from the first using strings.Replace(first, third, "", -1). -func ShouldEqualWithout(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - actualString, ok1 := actual.(string) - expectedString, ok2 := expected[0].(string) - replace, ok3 := expected[1].(string) - - if !ok1 || !ok2 || !ok3 { - return fmt.Sprintf(shouldAllBeStrings, []reflect.Type{ - reflect.TypeOf(actual), - reflect.TypeOf(expected[0]), - reflect.TypeOf(expected[1]), - }) - } - - replaced := strings.Replace(actualString, replace, "", -1) - if replaced == expectedString { - return "" - } - - return fmt.Sprintf("Expected '%s' to equal '%s' but without any '%s' (but it didn't).", actualString, expectedString, replace) -} - -// ShouldEqualTrimSpace receives exactly 2 string parameters and ensures that the first is equal to the second -// after removing all leading and trailing whitespace using strings.TrimSpace(first). -func ShouldEqualTrimSpace(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - actualString, valueIsString := actual.(string) - _, value2IsString := expected[0].(string) - - if !valueIsString || !value2IsString { - return fmt.Sprintf(shouldBothBeStrings, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) - } - - actualString = strings.TrimSpace(actualString) - return ShouldEqual(actualString, expected[0]) -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/time.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/time.go deleted file mode 100644 index 7e05026143..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/time.go +++ /dev/null @@ -1,202 +0,0 @@ -package assertions - -import ( - "fmt" - "time" -) - -// ShouldHappenBefore receives exactly 2 time.Time arguments and asserts that the first happens before the second. -func ShouldHappenBefore(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - expectedTime, secondOk := expected[0].(time.Time) - - if !firstOk || !secondOk { - return shouldUseTimes - } - - if !actualTime.Before(expectedTime) { - return fmt.Sprintf(shouldHaveHappenedBefore, actualTime, expectedTime, actualTime.Sub(expectedTime)) - } - - return success -} - -// ShouldHappenOnOrBefore receives exactly 2 time.Time arguments and asserts that the first happens on or before the second. -func ShouldHappenOnOrBefore(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - expectedTime, secondOk := expected[0].(time.Time) - - if !firstOk || !secondOk { - return shouldUseTimes - } - - if actualTime.Equal(expectedTime) { - return success - } - return ShouldHappenBefore(actualTime, expectedTime) -} - -// ShouldHappenAfter receives exactly 2 time.Time arguments and asserts that the first happens after the second. -func ShouldHappenAfter(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - expectedTime, secondOk := expected[0].(time.Time) - - if !firstOk || !secondOk { - return shouldUseTimes - } - if !actualTime.After(expectedTime) { - return fmt.Sprintf(shouldHaveHappenedAfter, actualTime, expectedTime, expectedTime.Sub(actualTime)) - } - return success -} - -// ShouldHappenOnOrAfter receives exactly 2 time.Time arguments and asserts that the first happens on or after the second. -func ShouldHappenOnOrAfter(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - expectedTime, secondOk := expected[0].(time.Time) - - if !firstOk || !secondOk { - return shouldUseTimes - } - if actualTime.Equal(expectedTime) { - return success - } - return ShouldHappenAfter(actualTime, expectedTime) -} - -// ShouldHappenBetween receives exactly 3 time.Time arguments and asserts that the first happens between (not on) the second and third. -func ShouldHappenBetween(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - min, secondOk := expected[0].(time.Time) - max, thirdOk := expected[1].(time.Time) - - if !firstOk || !secondOk || !thirdOk { - return shouldUseTimes - } - - if !actualTime.After(min) { - return fmt.Sprintf(shouldHaveHappenedBetween, actualTime, min, max, min.Sub(actualTime)) - } - if !actualTime.Before(max) { - return fmt.Sprintf(shouldHaveHappenedBetween, actualTime, min, max, actualTime.Sub(max)) - } - return success -} - -// ShouldHappenOnOrBetween receives exactly 3 time.Time arguments and asserts that the first happens between or on the second and third. -func ShouldHappenOnOrBetween(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - min, secondOk := expected[0].(time.Time) - max, thirdOk := expected[1].(time.Time) - - if !firstOk || !secondOk || !thirdOk { - return shouldUseTimes - } - if actualTime.Equal(min) || actualTime.Equal(max) { - return success - } - return ShouldHappenBetween(actualTime, min, max) -} - -// ShouldNotHappenOnOrBetween receives exactly 3 time.Time arguments and asserts that the first -// does NOT happen between or on the second or third. -func ShouldNotHappenOnOrBetween(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - min, secondOk := expected[0].(time.Time) - max, thirdOk := expected[1].(time.Time) - - if !firstOk || !secondOk || !thirdOk { - return shouldUseTimes - } - if actualTime.Equal(min) || actualTime.Equal(max) { - return fmt.Sprintf(shouldNotHaveHappenedOnOrBetween, actualTime, min, max) - } - if actualTime.After(min) && actualTime.Before(max) { - return fmt.Sprintf(shouldNotHaveHappenedOnOrBetween, actualTime, min, max) - } - return success -} - -// ShouldHappenWithin receives a time.Time, a time.Duration, and a time.Time (3 arguments) -// and asserts that the first time.Time happens within or on the duration specified relative to -// the other time.Time. -func ShouldHappenWithin(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - tolerance, secondOk := expected[0].(time.Duration) - threshold, thirdOk := expected[1].(time.Time) - - if !firstOk || !secondOk || !thirdOk { - return shouldUseDurationAndTime - } - - min := threshold.Add(-tolerance) - max := threshold.Add(tolerance) - return ShouldHappenOnOrBetween(actualTime, min, max) -} - -// ShouldNotHappenWithin receives a time.Time, a time.Duration, and a time.Time (3 arguments) -// and asserts that the first time.Time does NOT happen within or on the duration specified relative to -// the other time.Time. -func ShouldNotHappenWithin(actual interface{}, expected ...interface{}) string { - if fail := need(2, expected); fail != success { - return fail - } - actualTime, firstOk := actual.(time.Time) - tolerance, secondOk := expected[0].(time.Duration) - threshold, thirdOk := expected[1].(time.Time) - - if !firstOk || !secondOk || !thirdOk { - return shouldUseDurationAndTime - } - - min := threshold.Add(-tolerance) - max := threshold.Add(tolerance) - return ShouldNotHappenOnOrBetween(actualTime, min, max) -} - -// ShouldBeChronological receives a []time.Time slice and asserts that the are -// in chronological order starting with the first time.Time as the earliest. -func ShouldBeChronological(actual interface{}, expected ...interface{}) string { - if fail := need(0, expected); fail != success { - return fail - } - - times, ok := actual.([]time.Time) - if !ok { - return shouldUseTimeSlice - } - - var previous time.Time - for i, current := range times { - if i > 0 && current.Before(previous) { - return fmt.Sprintf(shouldHaveBeenChronological, - i, i-1, previous.String(), i, current.String()) - } - previous = current - } - return "" -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/assertions/type.go b/Godeps/_workspace/src/github.com/smartystreets/assertions/type.go deleted file mode 100644 index 3fc00f68cd..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/assertions/type.go +++ /dev/null @@ -1,112 +0,0 @@ -package assertions - -import ( - "fmt" - "reflect" -) - -// ShouldHaveSameTypeAs receives exactly two parameters and compares their underlying types for equality. -func ShouldHaveSameTypeAs(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - first := reflect.TypeOf(actual) - second := reflect.TypeOf(expected[0]) - - if equal := ShouldEqual(first, second); equal != success { - return serializer.serialize(second, first, fmt.Sprintf(shouldHaveBeenA, actual, second, first)) - } - return success -} - -// ShouldNotHaveSameTypeAs receives exactly two parameters and compares their underlying types for inequality. -func ShouldNotHaveSameTypeAs(actual interface{}, expected ...interface{}) string { - if fail := need(1, expected); fail != success { - return fail - } - - first := reflect.TypeOf(actual) - second := reflect.TypeOf(expected[0]) - - if equal := ShouldEqual(first, second); equal == success { - return fmt.Sprintf(shouldNotHaveBeenA, actual, second) - } - return success -} - -// ShouldImplement receives exactly two parameters and ensures -// that the first implements the interface type of the second. -func ShouldImplement(actual interface{}, expectedList ...interface{}) string { - if fail := need(1, expectedList); fail != success { - return fail - } - - expected := expectedList[0] - if fail := ShouldBeNil(expected); fail != success { - return shouldCompareWithInterfacePointer - } - - if fail := ShouldNotBeNil(actual); fail != success { - return shouldNotBeNilActual - } - - var actualType reflect.Type - if reflect.TypeOf(actual).Kind() != reflect.Ptr { - actualType = reflect.PtrTo(reflect.TypeOf(actual)) - } else { - actualType = reflect.TypeOf(actual) - } - - expectedType := reflect.TypeOf(expected) - if fail := ShouldNotBeNil(expectedType); fail != success { - return shouldCompareWithInterfacePointer - } - - expectedInterface := expectedType.Elem() - - if actualType == nil { - return fmt.Sprintf(shouldHaveImplemented, expectedInterface, actual) - } - - if !actualType.Implements(expectedInterface) { - return fmt.Sprintf(shouldHaveImplemented, expectedInterface, actualType) - } - return success -} - -// ShouldNotImplement receives exactly two parameters and ensures -// that the first does NOT implement the interface type of the second. -func ShouldNotImplement(actual interface{}, expectedList ...interface{}) string { - if fail := need(1, expectedList); fail != success { - return fail - } - - expected := expectedList[0] - if fail := ShouldBeNil(expected); fail != success { - return shouldCompareWithInterfacePointer - } - - if fail := ShouldNotBeNil(actual); fail != success { - return shouldNotBeNilActual - } - - var actualType reflect.Type - if reflect.TypeOf(actual).Kind() != reflect.Ptr { - actualType = reflect.PtrTo(reflect.TypeOf(actual)) - } else { - actualType = reflect.TypeOf(actual) - } - - expectedType := reflect.TypeOf(expected) - if fail := ShouldNotBeNil(expectedType); fail != success { - return shouldCompareWithInterfacePointer - } - - expectedInterface := expectedType.Elem() - - if actualType.Implements(expectedInterface) { - return fmt.Sprintf(shouldNotHaveImplemented, actualType, expectedInterface) - } - return success -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/assertions.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/assertions.go deleted file mode 100644 index 1e87b826df..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/assertions.go +++ /dev/null @@ -1,68 +0,0 @@ -package convey - -import "github.com/smartystreets/assertions" - -var ( - ShouldEqual = assertions.ShouldEqual - ShouldNotEqual = assertions.ShouldNotEqual - ShouldAlmostEqual = assertions.ShouldAlmostEqual - ShouldNotAlmostEqual = assertions.ShouldNotAlmostEqual - ShouldResemble = assertions.ShouldResemble - ShouldNotResemble = assertions.ShouldNotResemble - ShouldPointTo = assertions.ShouldPointTo - ShouldNotPointTo = assertions.ShouldNotPointTo - ShouldBeNil = assertions.ShouldBeNil - ShouldNotBeNil = assertions.ShouldNotBeNil - ShouldBeTrue = assertions.ShouldBeTrue - ShouldBeFalse = assertions.ShouldBeFalse - ShouldBeZeroValue = assertions.ShouldBeZeroValue - - ShouldBeGreaterThan = assertions.ShouldBeGreaterThan - ShouldBeGreaterThanOrEqualTo = assertions.ShouldBeGreaterThanOrEqualTo - ShouldBeLessThan = assertions.ShouldBeLessThan - ShouldBeLessThanOrEqualTo = assertions.ShouldBeLessThanOrEqualTo - ShouldBeBetween = assertions.ShouldBeBetween - ShouldNotBeBetween = assertions.ShouldNotBeBetween - ShouldBeBetweenOrEqual = assertions.ShouldBeBetweenOrEqual - ShouldNotBeBetweenOrEqual = assertions.ShouldNotBeBetweenOrEqual - - ShouldContain = assertions.ShouldContain - ShouldNotContain = assertions.ShouldNotContain - ShouldContainKey = assertions.ShouldContainKey - ShouldNotContainKey = assertions.ShouldNotContainKey - ShouldBeIn = assertions.ShouldBeIn - ShouldNotBeIn = assertions.ShouldNotBeIn - ShouldBeEmpty = assertions.ShouldBeEmpty - ShouldNotBeEmpty = assertions.ShouldNotBeEmpty - ShouldHaveLength = assertions.ShouldHaveLength - - ShouldStartWith = assertions.ShouldStartWith - ShouldNotStartWith = assertions.ShouldNotStartWith - ShouldEndWith = assertions.ShouldEndWith - ShouldNotEndWith = assertions.ShouldNotEndWith - ShouldBeBlank = assertions.ShouldBeBlank - ShouldNotBeBlank = assertions.ShouldNotBeBlank - ShouldContainSubstring = assertions.ShouldContainSubstring - ShouldNotContainSubstring = assertions.ShouldNotContainSubstring - - ShouldPanic = assertions.ShouldPanic - ShouldNotPanic = assertions.ShouldNotPanic - ShouldPanicWith = assertions.ShouldPanicWith - ShouldNotPanicWith = assertions.ShouldNotPanicWith - - ShouldHaveSameTypeAs = assertions.ShouldHaveSameTypeAs - ShouldNotHaveSameTypeAs = assertions.ShouldNotHaveSameTypeAs - ShouldImplement = assertions.ShouldImplement - ShouldNotImplement = assertions.ShouldNotImplement - - ShouldHappenBefore = assertions.ShouldHappenBefore - ShouldHappenOnOrBefore = assertions.ShouldHappenOnOrBefore - ShouldHappenAfter = assertions.ShouldHappenAfter - ShouldHappenOnOrAfter = assertions.ShouldHappenOnOrAfter - ShouldHappenBetween = assertions.ShouldHappenBetween - ShouldHappenOnOrBetween = assertions.ShouldHappenOnOrBetween - ShouldNotHappenOnOrBetween = assertions.ShouldNotHappenOnOrBetween - ShouldHappenWithin = assertions.ShouldHappenWithin - ShouldNotHappenWithin = assertions.ShouldNotHappenWithin - ShouldBeChronological = assertions.ShouldBeChronological -) diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/context.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/context.go deleted file mode 100644 index 2c75c2d7b1..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/context.go +++ /dev/null @@ -1,272 +0,0 @@ -package convey - -import ( - "fmt" - - "github.com/jtolds/gls" - "github.com/smartystreets/goconvey/convey/reporting" -) - -type conveyErr struct { - fmt string - params []interface{} -} - -func (e *conveyErr) Error() string { - return fmt.Sprintf(e.fmt, e.params...) -} - -func conveyPanic(fmt string, params ...interface{}) { - panic(&conveyErr{fmt, params}) -} - -const ( - missingGoTest = `Top-level calls to Convey(...) need a reference to the *testing.T. - Hint: Convey("description here", t, func() { /* notice that the second argument was the *testing.T (t)! */ }) ` - extraGoTest = `Only the top-level call to Convey(...) needs a reference to the *testing.T.` - noStackContext = "Convey operation made without context on goroutine stack.\n" + - "Hint: Perhaps you meant to use `Convey(..., func(c C){...})` ?" - differentConveySituations = "Different set of Convey statements on subsequent pass!\nDid not expect %#v." - multipleIdenticalConvey = "Multiple convey suites with identical names: %#v" -) - -const ( - failureHalt = "___FAILURE_HALT___" - - nodeKey = "node" -) - -///////////////////////////////// Stack Context ///////////////////////////////// - -func getCurrentContext() *context { - ctx, ok := ctxMgr.GetValue(nodeKey) - if ok { - return ctx.(*context) - } - return nil -} - -func mustGetCurrentContext() *context { - ctx := getCurrentContext() - if ctx == nil { - conveyPanic(noStackContext) - } - return ctx -} - -//////////////////////////////////// Context //////////////////////////////////// - -// context magically handles all coordination of Convey's and So assertions. -// -// It is tracked on the stack as goroutine-local-storage with the gls package, -// or explicitly if the user decides to call convey like: -// -// Convey(..., func(c C) { -// c.So(...) -// }) -// -// This implements the `C` interface. -type context struct { - reporter reporting.Reporter - - children map[string]*context - - resets []func() - - executedOnce bool - expectChildRun *bool - complete bool - - focus bool - failureMode FailureMode -} - -// rootConvey is the main entry point to a test suite. This is called when -// there's no context in the stack already, and items must contain a `t` object, -// or this panics. -func rootConvey(items ...interface{}) { - entry := discover(items) - - if entry.Test == nil { - conveyPanic(missingGoTest) - } - - expectChildRun := true - ctx := &context{ - reporter: buildReporter(), - - children: make(map[string]*context), - - expectChildRun: &expectChildRun, - - focus: entry.Focus, - failureMode: defaultFailureMode.combine(entry.FailMode), - } - ctxMgr.SetValues(gls.Values{nodeKey: ctx}, func() { - ctx.reporter.BeginStory(reporting.NewStoryReport(entry.Test)) - defer ctx.reporter.EndStory() - - for ctx.shouldVisit() { - ctx.conveyInner(entry.Situation, entry.Func) - expectChildRun = true - } - }) -} - -//////////////////////////////////// Methods //////////////////////////////////// - -func (ctx *context) SkipConvey(items ...interface{}) { - ctx.Convey(items, skipConvey) -} - -func (ctx *context) FocusConvey(items ...interface{}) { - ctx.Convey(items, focusConvey) -} - -func (ctx *context) Convey(items ...interface{}) { - entry := discover(items) - - // we're a branch, or leaf (on the wind) - if entry.Test != nil { - conveyPanic(extraGoTest) - } - if ctx.focus && !entry.Focus { - return - } - - var inner_ctx *context - if ctx.executedOnce { - var ok bool - inner_ctx, ok = ctx.children[entry.Situation] - if !ok { - conveyPanic(differentConveySituations, entry.Situation) - } - } else { - if _, ok := ctx.children[entry.Situation]; ok { - conveyPanic(multipleIdenticalConvey, entry.Situation) - } - inner_ctx = &context{ - reporter: ctx.reporter, - - children: make(map[string]*context), - - expectChildRun: ctx.expectChildRun, - - focus: entry.Focus, - failureMode: ctx.failureMode.combine(entry.FailMode), - } - ctx.children[entry.Situation] = inner_ctx - } - - if inner_ctx.shouldVisit() { - ctxMgr.SetValues(gls.Values{nodeKey: inner_ctx}, func() { - inner_ctx.conveyInner(entry.Situation, entry.Func) - }) - } -} - -func (ctx *context) SkipSo(stuff ...interface{}) { - ctx.assertionReport(reporting.NewSkipReport()) -} - -func (ctx *context) So(actual interface{}, assert assertion, expected ...interface{}) { - if result := assert(actual, expected...); result == assertionSuccess { - ctx.assertionReport(reporting.NewSuccessReport()) - } else { - ctx.assertionReport(reporting.NewFailureReport(result)) - } -} - -func (ctx *context) Reset(action func()) { - /* TODO: Failure mode configuration */ - ctx.resets = append(ctx.resets, action) -} - -func (ctx *context) Print(items ...interface{}) (int, error) { - fmt.Fprint(ctx.reporter, items...) - return fmt.Print(items...) -} - -func (ctx *context) Println(items ...interface{}) (int, error) { - fmt.Fprintln(ctx.reporter, items...) - return fmt.Println(items...) -} - -func (ctx *context) Printf(format string, items ...interface{}) (int, error) { - fmt.Fprintf(ctx.reporter, format, items...) - return fmt.Printf(format, items...) -} - -//////////////////////////////////// Private //////////////////////////////////// - -// shouldVisit returns true iff we should traverse down into a Convey. Note -// that just because we don't traverse a Convey this time, doesn't mean that -// we may not traverse it on a subsequent pass. -func (c *context) shouldVisit() bool { - return !c.complete && *c.expectChildRun -} - -// conveyInner is the function which actually executes the user's anonymous test -// function body. At this point, Convey or RootConvey has decided that this -// function should actually run. -func (ctx *context) conveyInner(situation string, f func(C)) { - // Record/Reset state for next time. - defer func() { - ctx.executedOnce = true - - // This is only needed at the leaves, but there's no harm in also setting it - // when returning from branch Convey's - *ctx.expectChildRun = false - }() - - // Set up+tear down our scope for the reporter - ctx.reporter.Enter(reporting.NewScopeReport(situation)) - defer ctx.reporter.Exit() - - // Recover from any panics in f, and assign the `complete` status for this - // node of the tree. - defer func() { - ctx.complete = true - if problem := recover(); problem != nil { - if problem, ok := problem.(*conveyErr); ok { - panic(problem) - } - if problem != failureHalt { - ctx.reporter.Report(reporting.NewErrorReport(problem)) - } - } else { - for _, child := range ctx.children { - if !child.complete { - ctx.complete = false - return - } - } - } - }() - - // Resets are registered as the `f` function executes, so nil them here. - // All resets are run in registration order (FIFO). - ctx.resets = []func(){} - defer func() { - for _, r := range ctx.resets { - // panics handled by the previous defer - r() - } - }() - - if f == nil { - // if f is nil, this was either a Convey(..., nil), or a SkipConvey - ctx.reporter.Report(reporting.NewSkipReport()) - } else { - f(ctx) - } -} - -// assertionReport is a helper for So and SkipSo which makes the report and -// then possibly panics, depending on the current context's failureMode. -func (ctx *context) assertionReport(r *reporting.AssertionResult) { - ctx.reporter.Report(r) - if r.Failure != "" && ctx.failureMode == FailureHalts { - panic(failureHalt) - } -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/convey.goconvey b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/convey.goconvey deleted file mode 100644 index a2d9327dc9..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/convey.goconvey +++ /dev/null @@ -1,4 +0,0 @@ -#ignore --timeout=1s -#-covermode=count -#-coverpkg=github.com/smartystreets/goconvey/convey,github.com/smartystreets/goconvey/convey/gotest,github.com/smartystreets/goconvey/convey/reporting \ No newline at end of file diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/discovery.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/discovery.go deleted file mode 100644 index eb8d4cb2ce..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/discovery.go +++ /dev/null @@ -1,103 +0,0 @@ -package convey - -type actionSpecifier uint8 - -const ( - noSpecifier actionSpecifier = iota - skipConvey - focusConvey -) - -type suite struct { - Situation string - Test t - Focus bool - Func func(C) // nil means skipped - FailMode FailureMode -} - -func newSuite(situation string, failureMode FailureMode, f func(C), test t, specifier actionSpecifier) *suite { - ret := &suite{ - Situation: situation, - Test: test, - Func: f, - FailMode: failureMode, - } - switch specifier { - case skipConvey: - ret.Func = nil - case focusConvey: - ret.Focus = true - } - return ret -} - -func discover(items []interface{}) *suite { - name, items := parseName(items) - test, items := parseGoTest(items) - failure, items := parseFailureMode(items) - action, items := parseAction(items) - specifier, items := parseSpecifier(items) - - if len(items) != 0 { - conveyPanic(parseError) - } - - return newSuite(name, failure, action, test, specifier) -} -func item(items []interface{}) interface{} { - if len(items) == 0 { - conveyPanic(parseError) - } - return items[0] -} -func parseName(items []interface{}) (string, []interface{}) { - if name, parsed := item(items).(string); parsed { - return name, items[1:] - } - conveyPanic(parseError) - panic("never get here") -} -func parseGoTest(items []interface{}) (t, []interface{}) { - if test, parsed := item(items).(t); parsed { - return test, items[1:] - } - return nil, items -} -func parseFailureMode(items []interface{}) (FailureMode, []interface{}) { - if mode, parsed := item(items).(FailureMode); parsed { - return mode, items[1:] - } - return FailureInherits, items -} -func parseAction(items []interface{}) (func(C), []interface{}) { - switch x := item(items).(type) { - case nil: - return nil, items[1:] - case func(C): - return x, items[1:] - case func(): - return func(C) { x() }, items[1:] - } - conveyPanic(parseError) - panic("never get here") -} -func parseSpecifier(items []interface{}) (actionSpecifier, []interface{}) { - if len(items) == 0 { - return noSpecifier, items - } - if spec, ok := items[0].(actionSpecifier); ok { - return spec, items[1:] - } - conveyPanic(parseError) - panic("never get here") -} - -// This interface allows us to pass the *testing.T struct -// throughout the internals of this package without ever -// having to import the "testing" package. -type t interface { - Fail() -} - -const parseError = "You must provide a name (string), then a *testing.T (if in outermost scope), an optional FailureMode, and then an action (func())." diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/doc.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/doc.go deleted file mode 100644 index 2562ce4c28..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/doc.go +++ /dev/null @@ -1,218 +0,0 @@ -// Package convey contains all of the public-facing entry points to this project. -// This means that it should never be required of the user to import any other -// packages from this project as they serve internal purposes. -package convey - -import "github.com/smartystreets/goconvey/convey/reporting" - -////////////////////////////////// suite ////////////////////////////////// - -// C is the Convey context which you can optionally obtain in your action -// by calling Convey like: -// -// Convey(..., func(c C) { -// ... -// }) -// -// See the documentation on Convey for more details. -// -// All methods in this context behave identically to the global functions of the -// same name in this package. -type C interface { - Convey(items ...interface{}) - SkipConvey(items ...interface{}) - FocusConvey(items ...interface{}) - - So(actual interface{}, assert assertion, expected ...interface{}) - SkipSo(stuff ...interface{}) - - Reset(action func()) - - Println(items ...interface{}) (int, error) - Print(items ...interface{}) (int, error) - Printf(format string, items ...interface{}) (int, error) -} - -// Convey is the method intended for use when declaring the scopes of -// a specification. Each scope has a description and a func() which may contain -// other calls to Convey(), Reset() or Should-style assertions. Convey calls can -// be nested as far as you see fit. -// -// IMPORTANT NOTE: The top-level Convey() within a Test method -// must conform to the following signature: -// -// Convey(description string, t *testing.T, action func()) -// -// All other calls should look like this (no need to pass in *testing.T): -// -// Convey(description string, action func()) -// -// Don't worry, goconvey will panic if you get it wrong so you can fix it. -// -// Additionally, you may explicitly obtain access to the Convey context by doing: -// -// Convey(description string, action func(c C)) -// -// You may need to do this if you want to pass the context through to a -// goroutine, or to close over the context in a handler to a library which -// calls your handler in a goroutine (httptest comes to mind). -// -// All Convey()-blocks also accept an optional parameter of FailureMode which sets -// how goconvey should treat failures for So()-assertions in the block and -// nested blocks. See the constants in this file for the available options. -// -// By default it will inherit from its parent block and the top-level blocks -// default to the FailureHalts setting. -// -// This parameter is inserted before the block itself: -// -// Convey(description string, t *testing.T, mode FailureMode, action func()) -// Convey(description string, mode FailureMode, action func()) -// -// See the examples package for, well, examples. -func Convey(items ...interface{}) { - if ctx := getCurrentContext(); ctx == nil { - rootConvey(items...) - } else { - ctx.Convey(items...) - } -} - -// SkipConvey is analagous to Convey except that the scope is not executed -// (which means that child scopes defined within this scope are not run either). -// The reporter will be notified that this step was skipped. -func SkipConvey(items ...interface{}) { - Convey(append(items, skipConvey)...) -} - -// FocusConvey is has the inverse effect of SkipConvey. If the top-level -// Convey is changed to `FocusConvey`, only nested scopes that are defined -// with FocusConvey will be run. The rest will be ignored completely. This -// is handy when debugging a large suite that runs a misbehaving function -// repeatedly as you can disable all but one of that function -// without swaths of `SkipConvey` calls, just a targeted chain of calls -// to FocusConvey. -func FocusConvey(items ...interface{}) { - Convey(append(items, focusConvey)...) -} - -// Reset registers a cleanup function to be run after each Convey() -// in the same scope. See the examples package for a simple use case. -func Reset(action func()) { - mustGetCurrentContext().Reset(action) -} - -/////////////////////////////////// Assertions /////////////////////////////////// - -// assertion is an alias for a function with a signature that the convey.So() -// method can handle. Any future or custom assertions should conform to this -// method signature. The return value should be an empty string if the assertion -// passes and a well-formed failure message if not. -type assertion func(actual interface{}, expected ...interface{}) string - -const assertionSuccess = "" - -// So is the means by which assertions are made against the system under test. -// The majority of exported names in the assertions package begin with the word -// 'Should' and describe how the first argument (actual) should compare with any -// of the final (expected) arguments. How many final arguments are accepted -// depends on the particular assertion that is passed in as the assert argument. -// See the examples package for use cases and the assertions package for -// documentation on specific assertion methods. A failing assertion will -// cause t.Fail() to be invoked--you should never call this method (or other -// failure-inducing methods) in your test code. Leave that to GoConvey. -func So(actual interface{}, assert assertion, expected ...interface{}) { - mustGetCurrentContext().So(actual, assert, expected...) -} - -// SkipSo is analagous to So except that the assertion that would have been passed -// to So is not executed and the reporter is notified that the assertion was skipped. -func SkipSo(stuff ...interface{}) { - mustGetCurrentContext().SkipSo() -} - -// FailureMode is a type which determines how the So() blocks should fail -// if their assertion fails. See constants further down for acceptable values -type FailureMode string - -const ( - - // FailureContinues is a failure mode which prevents failing - // So()-assertions from halting Convey-block execution, instead - // allowing the test to continue past failing So()-assertions. - FailureContinues FailureMode = "continue" - - // FailureHalts is the default setting for a top-level Convey()-block - // and will cause all failing So()-assertions to halt further execution - // in that test-arm and continue on to the next arm. - FailureHalts FailureMode = "halt" - - // FailureInherits is the default setting for failure-mode, it will - // default to the failure-mode of the parent block. You should never - // need to specify this mode in your tests.. - FailureInherits FailureMode = "inherits" -) - -func (f FailureMode) combine(other FailureMode) FailureMode { - if other == FailureInherits { - return f - } - return other -} - -var defaultFailureMode FailureMode = FailureHalts - -// SetDefaultFailureMode allows you to specify the default failure mode -// for all Convey blocks. It is meant to be used in an init function to -// allow the default mode to be changdd across all tests for an entire packgae -// but it can be used anywhere. -func SetDefaultFailureMode(mode FailureMode) { - if mode == FailureContinues || mode == FailureHalts { - defaultFailureMode = mode - } else { - panic("You may only use the constants named 'FailureContinues' and 'FailureHalts' as default failure modes.") - } -} - -//////////////////////////////////// Print functions //////////////////////////////////// - -// Print is analogous to fmt.Print (and it even calls fmt.Print). It ensures that -// output is aligned with the corresponding scopes in the web UI. -func Print(items ...interface{}) (written int, err error) { - return mustGetCurrentContext().Print(items...) -} - -// Print is analogous to fmt.Println (and it even calls fmt.Println). It ensures that -// output is aligned with the corresponding scopes in the web UI. -func Println(items ...interface{}) (written int, err error) { - return mustGetCurrentContext().Println(items...) -} - -// Print is analogous to fmt.Printf (and it even calls fmt.Printf). It ensures that -// output is aligned with the corresponding scopes in the web UI. -func Printf(format string, items ...interface{}) (written int, err error) { - return mustGetCurrentContext().Printf(format, items...) -} - -/////////////////////////////////////////////////////////////////////////////// - -// SuppressConsoleStatistics prevents automatic printing of console statistics. -// Calling PrintConsoleStatistics explicitly will force printing of statistics. -func SuppressConsoleStatistics() { - reporting.SuppressConsoleStatistics() -} - -// ConsoleStatistics may be called at any time to print assertion statistics. -// Generally, the best place to do this would be in a TestMain function, -// after all tests have been run. Something like this: -// -// func TestMain(m *testing.M) { -// convey.SuppressConsoleStatistics() -// result := m.Run() -// convey.PrintConsoleStatistics() -// os.Exit(result) -// } -// -func PrintConsoleStatistics() { - reporting.PrintConsoleStatistics() -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/gotest/utils.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/gotest/utils.go deleted file mode 100644 index 3a5c848a44..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/gotest/utils.go +++ /dev/null @@ -1,28 +0,0 @@ -// Package gotest contains internal functionality. Although this package -// contains one or more exported names it is not intended for public -// consumption. See the examples package for how to use this project. -package gotest - -import ( - "runtime" - "strings" -) - -func ResolveExternalCaller() (file string, line int, name string) { - var caller_id uintptr - callers := runtime.Callers(0, callStack) - - for x := 0; x < callers; x++ { - caller_id, file, line, _ = runtime.Caller(x) - if strings.HasSuffix(file, "_test.go") || strings.HasSuffix(file, "_tests.go") { - name = runtime.FuncForPC(caller_id).Name() - return - } - } - file, line, name = "", -1, "" - return // panic? -} - -const maxStackDepth = 100 // This had better be enough... - -var callStack []uintptr = make([]uintptr, maxStackDepth, maxStackDepth) diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/init.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/init.go deleted file mode 100644 index 1d77ff3dcd..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/init.go +++ /dev/null @@ -1,81 +0,0 @@ -package convey - -import ( - "flag" - "os" - - "github.com/jtolds/gls" - "github.com/smartystreets/assertions" - "github.com/smartystreets/goconvey/convey/reporting" -) - -func init() { - assertions.GoConveyMode(true) - - declareFlags() - - ctxMgr = gls.NewContextManager() -} - -func declareFlags() { - flag.BoolVar(&json, "convey-json", false, "When true, emits results in JSON blocks. Default: 'false'") - flag.BoolVar(&silent, "convey-silent", false, "When true, all output from GoConvey is suppressed.") - flag.BoolVar(&story, "convey-story", false, "When true, emits story output, otherwise emits dot output. When not provided, this flag mirros the value of the '-test.v' flag") - - if noStoryFlagProvided() { - story = verboseEnabled - } - - // FYI: flag.Parse() is called from the testing package. -} - -func noStoryFlagProvided() bool { - return !story && !storyDisabled -} - -func buildReporter() reporting.Reporter { - selectReporter := os.Getenv("GOCONVEY_REPORTER") - - switch { - case testReporter != nil: - return testReporter - case json || selectReporter == "json": - return reporting.BuildJsonReporter() - case silent || selectReporter == "silent": - return reporting.BuildSilentReporter() - case selectReporter == "dot": - // Story is turned on when verbose is set, so we need to check for dot reporter first. - return reporting.BuildDotReporter() - case story || selectReporter == "story": - return reporting.BuildStoryReporter() - default: - return reporting.BuildDotReporter() - } -} - -var ( - ctxMgr *gls.ContextManager - - // only set by internal tests - testReporter reporting.Reporter -) - -var ( - json bool - silent bool - story bool - - verboseEnabled = flagFound("-test.v=true") - storyDisabled = flagFound("-story=false") -) - -// flagFound parses the command line args manually for flags defined in other -// packages. Like the '-v' flag from the "testing" package, for instance. -func flagFound(flagValue string) bool { - for _, arg := range os.Args { - if arg == flagValue { - return true - } - } - return false -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/nilReporter.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/nilReporter.go deleted file mode 100644 index 777b2a5122..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/nilReporter.go +++ /dev/null @@ -1,15 +0,0 @@ -package convey - -import ( - "github.com/smartystreets/goconvey/convey/reporting" -) - -type nilReporter struct{} - -func (self *nilReporter) BeginStory(story *reporting.StoryReport) {} -func (self *nilReporter) Enter(scope *reporting.ScopeReport) {} -func (self *nilReporter) Report(report *reporting.AssertionResult) {} -func (self *nilReporter) Exit() {} -func (self *nilReporter) EndStory() {} -func (self *nilReporter) Write(p []byte) (int, error) { return len(p), nil } -func newNilReporter() *nilReporter { return &nilReporter{} } diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/console.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/console.go deleted file mode 100644 index 7bf67dbb2b..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/console.go +++ /dev/null @@ -1,16 +0,0 @@ -package reporting - -import ( - "fmt" - "io" -) - -type console struct{} - -func (self *console) Write(p []byte) (n int, err error) { - return fmt.Print(string(p)) -} - -func NewConsole() io.Writer { - return new(console) -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/doc.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/doc.go deleted file mode 100644 index a37d001946..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/doc.go +++ /dev/null @@ -1,5 +0,0 @@ -// Package reporting contains internal functionality related -// to console reporting and output. Although this package has -// exported names is not intended for public consumption. See the -// examples package for how to use this project. -package reporting diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/dot.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/dot.go deleted file mode 100644 index 47d57c6b0d..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/dot.go +++ /dev/null @@ -1,40 +0,0 @@ -package reporting - -import "fmt" - -type dot struct{ out *Printer } - -func (self *dot) BeginStory(story *StoryReport) {} - -func (self *dot) Enter(scope *ScopeReport) {} - -func (self *dot) Report(report *AssertionResult) { - if report.Error != nil { - fmt.Print(redColor) - self.out.Insert(dotError) - } else if report.Failure != "" { - fmt.Print(yellowColor) - self.out.Insert(dotFailure) - } else if report.Skipped { - fmt.Print(yellowColor) - self.out.Insert(dotSkip) - } else { - fmt.Print(greenColor) - self.out.Insert(dotSuccess) - } - fmt.Print(resetColor) -} - -func (self *dot) Exit() {} - -func (self *dot) EndStory() {} - -func (self *dot) Write(content []byte) (written int, err error) { - return len(content), nil // no-op -} - -func NewDotReporter(out *Printer) *dot { - self := new(dot) - self.out = out - return self -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/gotest.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/gotest.go deleted file mode 100644 index c396e16b17..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/gotest.go +++ /dev/null @@ -1,33 +0,0 @@ -package reporting - -type gotestReporter struct{ test T } - -func (self *gotestReporter) BeginStory(story *StoryReport) { - self.test = story.Test -} - -func (self *gotestReporter) Enter(scope *ScopeReport) {} - -func (self *gotestReporter) Report(r *AssertionResult) { - if !passed(r) { - self.test.Fail() - } -} - -func (self *gotestReporter) Exit() {} - -func (self *gotestReporter) EndStory() { - self.test = nil -} - -func (self *gotestReporter) Write(content []byte) (written int, err error) { - return len(content), nil // no-op -} - -func NewGoTestReporter() *gotestReporter { - return new(gotestReporter) -} - -func passed(r *AssertionResult) bool { - return r.Error == nil && r.Failure == "" -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/init.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/init.go deleted file mode 100644 index 44d080e90e..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/init.go +++ /dev/null @@ -1,94 +0,0 @@ -package reporting - -import ( - "os" - "runtime" - "strings" -) - -func init() { - if !isColorableTerminal() { - monochrome() - } - - if runtime.GOOS == "windows" { - success, failure, error_ = dotSuccess, dotFailure, dotError - } -} - -func BuildJsonReporter() Reporter { - out := NewPrinter(NewConsole()) - return NewReporters( - NewGoTestReporter(), - NewJsonReporter(out)) -} -func BuildDotReporter() Reporter { - out := NewPrinter(NewConsole()) - return NewReporters( - NewGoTestReporter(), - NewDotReporter(out), - NewProblemReporter(out), - consoleStatistics) -} -func BuildStoryReporter() Reporter { - out := NewPrinter(NewConsole()) - return NewReporters( - NewGoTestReporter(), - NewStoryReporter(out), - NewProblemReporter(out), - consoleStatistics) -} -func BuildSilentReporter() Reporter { - out := NewPrinter(NewConsole()) - return NewReporters( - NewGoTestReporter(), - NewSilentProblemReporter(out)) -} - -var ( - newline = "\n" - success = "✔" - failure = "✘" - error_ = "🔥" - skip = "⚠" - dotSuccess = "." - dotFailure = "x" - dotError = "E" - dotSkip = "S" - errorTemplate = "* %s \nLine %d: - %v \n%s\n" - failureTemplate = "* %s \nLine %d:\n%s\n" -) - -var ( - greenColor = "\033[32m" - yellowColor = "\033[33m" - redColor = "\033[31m" - resetColor = "\033[0m" -) - -var consoleStatistics = NewStatisticsReporter(NewPrinter(NewConsole())) - -func SuppressConsoleStatistics() { consoleStatistics.Suppress() } -func PrintConsoleStatistics() { consoleStatistics.PrintSummary() } - -// QuiteMode disables all console output symbols. This is only meant to be used -// for tests that are internal to goconvey where the output is distracting or -// otherwise not needed in the test output. -func QuietMode() { - success, failure, error_, skip, dotSuccess, dotFailure, dotError, dotSkip = "", "", "", "", "", "", "", "" -} - -func monochrome() { - greenColor, yellowColor, redColor, resetColor = "", "", "", "" -} - -func isColorableTerminal() bool { - return strings.Contains(os.Getenv("TERM"), "color") -} - -// This interface allows us to pass the *testing.T struct -// throughout the internals of this tool without ever -// having to import the "testing" package. -type T interface { - Fail() -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/json.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/json.go deleted file mode 100644 index f8526979f8..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/json.go +++ /dev/null @@ -1,88 +0,0 @@ -// TODO: under unit test - -package reporting - -import ( - "bytes" - "encoding/json" - "fmt" - "strings" -) - -type JsonReporter struct { - out *Printer - currentKey []string - current *ScopeResult - index map[string]*ScopeResult - scopes []*ScopeResult -} - -func (self *JsonReporter) depth() int { return len(self.currentKey) } - -func (self *JsonReporter) BeginStory(story *StoryReport) {} - -func (self *JsonReporter) Enter(scope *ScopeReport) { - self.currentKey = append(self.currentKey, scope.Title) - ID := strings.Join(self.currentKey, "|") - if _, found := self.index[ID]; !found { - next := newScopeResult(scope.Title, self.depth(), scope.File, scope.Line) - self.scopes = append(self.scopes, next) - self.index[ID] = next - } - self.current = self.index[ID] -} - -func (self *JsonReporter) Report(report *AssertionResult) { - self.current.Assertions = append(self.current.Assertions, report) -} - -func (self *JsonReporter) Exit() { - self.currentKey = self.currentKey[:len(self.currentKey)-1] -} - -func (self *JsonReporter) EndStory() { - self.report() - self.reset() -} -func (self *JsonReporter) report() { - scopes := []string{} - for _, scope := range self.scopes { - serialized, err := json.Marshal(scope) - if err != nil { - self.out.Println(jsonMarshalFailure) - panic(err) - } - var buffer bytes.Buffer - json.Indent(&buffer, serialized, "", " ") - scopes = append(scopes, buffer.String()) - } - self.out.Print(fmt.Sprintf("%s\n%s,\n%s\n", OpenJson, strings.Join(scopes, ","), CloseJson)) -} -func (self *JsonReporter) reset() { - self.scopes = []*ScopeResult{} - self.index = map[string]*ScopeResult{} - self.currentKey = nil -} - -func (self *JsonReporter) Write(content []byte) (written int, err error) { - self.current.Output += string(content) - return len(content), nil -} - -func NewJsonReporter(out *Printer) *JsonReporter { - self := new(JsonReporter) - self.out = out - self.reset() - return self -} - -const OpenJson = ">->->OPEN-JSON->->->" // "⌦" -const CloseJson = "<-<-<-CLOSE-JSON<-<-<" // "⌫" -const jsonMarshalFailure = ` - -GOCONVEY_JSON_MARSHALL_FAILURE: There was an error when attempting to convert test results to JSON. -Please file a bug report and reference the code that caused this failure if possible. - -Here's the panic: - -` diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/printer.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/printer.go deleted file mode 100644 index 6d4a879c40..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/printer.go +++ /dev/null @@ -1,57 +0,0 @@ -package reporting - -import ( - "fmt" - "io" - "strings" -) - -type Printer struct { - out io.Writer - prefix string -} - -func (self *Printer) Println(message string, values ...interface{}) { - formatted := self.format(message, values...) + newline - self.out.Write([]byte(formatted)) -} - -func (self *Printer) Print(message string, values ...interface{}) { - formatted := self.format(message, values...) - self.out.Write([]byte(formatted)) -} - -func (self *Printer) Insert(text string) { - self.out.Write([]byte(text)) -} - -func (self *Printer) format(message string, values ...interface{}) string { - var formatted string - if len(values) == 0 { - formatted = self.prefix + message - } else { - formatted = self.prefix + fmt.Sprintf(message, values...) - } - indented := strings.Replace(formatted, newline, newline+self.prefix, -1) - return strings.TrimRight(indented, space) -} - -func (self *Printer) Indent() { - self.prefix += pad -} - -func (self *Printer) Dedent() { - if len(self.prefix) >= padLength { - self.prefix = self.prefix[:len(self.prefix)-padLength] - } -} - -func NewPrinter(out io.Writer) *Printer { - self := new(Printer) - self.out = out - return self -} - -const space = " " -const pad = space + space -const padLength = len(pad) diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/problems.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/problems.go deleted file mode 100644 index 9ae493ac3b..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/problems.go +++ /dev/null @@ -1,80 +0,0 @@ -package reporting - -import "fmt" - -type problem struct { - silent bool - out *Printer - errors []*AssertionResult - failures []*AssertionResult -} - -func (self *problem) BeginStory(story *StoryReport) {} - -func (self *problem) Enter(scope *ScopeReport) {} - -func (self *problem) Report(report *AssertionResult) { - if report.Error != nil { - self.errors = append(self.errors, report) - } else if report.Failure != "" { - self.failures = append(self.failures, report) - } -} - -func (self *problem) Exit() {} - -func (self *problem) EndStory() { - self.show(self.showErrors, redColor) - self.show(self.showFailures, yellowColor) - self.prepareForNextStory() -} -func (self *problem) show(display func(), color string) { - if !self.silent { - fmt.Print(color) - } - display() - if !self.silent { - fmt.Print(resetColor) - } - self.out.Dedent() -} -func (self *problem) showErrors() { - for i, e := range self.errors { - if i == 0 { - self.out.Println("\nErrors:\n") - self.out.Indent() - } - self.out.Println(errorTemplate, e.File, e.Line, e.Error, e.StackTrace) - } -} -func (self *problem) showFailures() { - for i, f := range self.failures { - if i == 0 { - self.out.Println("\nFailures:\n") - self.out.Indent() - } - self.out.Println(failureTemplate, f.File, f.Line, f.Failure) - } -} - -func (self *problem) Write(content []byte) (written int, err error) { - return len(content), nil // no-op -} - -func NewProblemReporter(out *Printer) *problem { - self := new(problem) - self.out = out - self.prepareForNextStory() - return self -} - -func NewSilentProblemReporter(out *Printer) *problem { - self := NewProblemReporter(out) - self.silent = true - return self -} - -func (self *problem) prepareForNextStory() { - self.errors = []*AssertionResult{} - self.failures = []*AssertionResult{} -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reporter.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reporter.go deleted file mode 100644 index cce6c5e438..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reporter.go +++ /dev/null @@ -1,39 +0,0 @@ -package reporting - -import "io" - -type Reporter interface { - BeginStory(story *StoryReport) - Enter(scope *ScopeReport) - Report(r *AssertionResult) - Exit() - EndStory() - io.Writer -} - -type reporters struct{ collection []Reporter } - -func (self *reporters) BeginStory(s *StoryReport) { self.foreach(func(r Reporter) { r.BeginStory(s) }) } -func (self *reporters) Enter(s *ScopeReport) { self.foreach(func(r Reporter) { r.Enter(s) }) } -func (self *reporters) Report(a *AssertionResult) { self.foreach(func(r Reporter) { r.Report(a) }) } -func (self *reporters) Exit() { self.foreach(func(r Reporter) { r.Exit() }) } -func (self *reporters) EndStory() { self.foreach(func(r Reporter) { r.EndStory() }) } - -func (self *reporters) Write(contents []byte) (written int, err error) { - self.foreach(func(r Reporter) { - written, err = r.Write(contents) - }) - return written, err -} - -func (self *reporters) foreach(action func(Reporter)) { - for _, r := range self.collection { - action(r) - } -} - -func NewReporters(collection ...Reporter) *reporters { - self := new(reporters) - self.collection = collection - return self -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reporting.goconvey b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reporting.goconvey deleted file mode 100644 index 79982854b5..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reporting.goconvey +++ /dev/null @@ -1,2 +0,0 @@ -#ignore --timeout=1s diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reports.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reports.go deleted file mode 100644 index 712e6ade62..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/reports.go +++ /dev/null @@ -1,179 +0,0 @@ -package reporting - -import ( - "encoding/json" - "fmt" - "runtime" - "strings" - - "github.com/smartystreets/goconvey/convey/gotest" -) - -////////////////// ScopeReport //////////////////// - -type ScopeReport struct { - Title string - File string - Line int -} - -func NewScopeReport(title string) *ScopeReport { - file, line, _ := gotest.ResolveExternalCaller() - self := new(ScopeReport) - self.Title = title - self.File = file - self.Line = line - return self -} - -////////////////// ScopeResult //////////////////// - -type ScopeResult struct { - Title string - File string - Line int - Depth int - Assertions []*AssertionResult - Output string -} - -func newScopeResult(title string, depth int, file string, line int) *ScopeResult { - self := new(ScopeResult) - self.Title = title - self.Depth = depth - self.File = file - self.Line = line - self.Assertions = []*AssertionResult{} - return self -} - -/////////////////// StoryReport ///////////////////// - -type StoryReport struct { - Test T - Name string - File string - Line int -} - -func NewStoryReport(test T) *StoryReport { - file, line, name := gotest.ResolveExternalCaller() - name = removePackagePath(name) - self := new(StoryReport) - self.Test = test - self.Name = name - self.File = file - self.Line = line - return self -} - -// name comes in looking like "github.com/smartystreets/goconvey/examples.TestName". -// We only want the stuff after the last '.', which is the name of the test function. -func removePackagePath(name string) string { - parts := strings.Split(name, ".") - return parts[len(parts)-1] -} - -/////////////////// FailureView //////////////////////// - -// This struct is also declared in github.com/smartystreets/assertions. -// The json struct tags should be equal in both declarations. -type FailureView struct { - Message string `json:"Message"` - Expected string `json:"Expected"` - Actual string `json:"Actual"` -} - -////////////////////AssertionResult ////////////////////// - -type AssertionResult struct { - File string - Line int - Expected string - Actual string - Failure string - Error interface{} - StackTrace string - Skipped bool -} - -func NewFailureReport(failure string) *AssertionResult { - report := new(AssertionResult) - report.File, report.Line = caller() - report.StackTrace = stackTrace() - parseFailure(failure, report) - return report -} -func parseFailure(failure string, report *AssertionResult) { - view := new(FailureView) - err := json.Unmarshal([]byte(failure), view) - if err == nil { - report.Failure = view.Message - report.Expected = view.Expected - report.Actual = view.Actual - } else { - report.Failure = failure - } -} -func NewErrorReport(err interface{}) *AssertionResult { - report := new(AssertionResult) - report.File, report.Line = caller() - report.StackTrace = fullStackTrace() - report.Error = fmt.Sprintf("%v", err) - return report -} -func NewSuccessReport() *AssertionResult { - return new(AssertionResult) -} -func NewSkipReport() *AssertionResult { - report := new(AssertionResult) - report.File, report.Line = caller() - report.StackTrace = fullStackTrace() - report.Skipped = true - return report -} - -func caller() (file string, line int) { - file, line, _ = gotest.ResolveExternalCaller() - return -} - -func stackTrace() string { - buffer := make([]byte, 1024*64) - n := runtime.Stack(buffer, false) - return removeInternalEntries(string(buffer[:n])) -} -func fullStackTrace() string { - buffer := make([]byte, 1024*64) - n := runtime.Stack(buffer, true) - return removeInternalEntries(string(buffer[:n])) -} -func removeInternalEntries(stack string) string { - lines := strings.Split(stack, newline) - filtered := []string{} - for _, line := range lines { - if !isExternal(line) { - filtered = append(filtered, line) - } - } - return strings.Join(filtered, newline) -} -func isExternal(line string) bool { - for _, p := range internalPackages { - if strings.Contains(line, p) { - return true - } - } - return false -} - -// NOTE: any new packages that host goconvey packages will need to be added here! -// An alternative is to scan the goconvey directory and then exclude stuff like -// the examples package but that's nasty too. -var internalPackages = []string{ - "goconvey/assertions", - "goconvey/convey", - "goconvey/execution", - "goconvey/gotest", - "goconvey/reporting", -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/statistics.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/statistics.go deleted file mode 100644 index c3ccd056a0..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/statistics.go +++ /dev/null @@ -1,108 +0,0 @@ -package reporting - -import ( - "fmt" - "sync" -) - -func (self *statistics) BeginStory(story *StoryReport) {} - -func (self *statistics) Enter(scope *ScopeReport) {} - -func (self *statistics) Report(report *AssertionResult) { - self.Lock() - defer self.Unlock() - - if !self.failing && report.Failure != "" { - self.failing = true - } - if !self.erroring && report.Error != nil { - self.erroring = true - } - if report.Skipped { - self.skipped += 1 - } else { - self.total++ - } -} - -func (self *statistics) Exit() {} - -func (self *statistics) EndStory() { - self.Lock() - defer self.Unlock() - - if !self.suppressed { - self.printSummaryLocked() - } -} - -func (self *statistics) Suppress() { - self.Lock() - defer self.Unlock() - self.suppressed = true -} - -func (self *statistics) PrintSummary() { - self.Lock() - defer self.Unlock() - self.printSummaryLocked() -} - -func (self *statistics) printSummaryLocked() { - self.reportAssertionsLocked() - self.reportSkippedSectionsLocked() - self.completeReportLocked() -} -func (self *statistics) reportAssertionsLocked() { - self.decideColorLocked() - self.out.Print("\n%d total %s", self.total, plural("assertion", self.total)) -} -func (self *statistics) decideColorLocked() { - if self.failing && !self.erroring { - fmt.Print(yellowColor) - } else if self.erroring { - fmt.Print(redColor) - } else { - fmt.Print(greenColor) - } -} -func (self *statistics) reportSkippedSectionsLocked() { - if self.skipped > 0 { - fmt.Print(yellowColor) - self.out.Print(" (one or more sections skipped)") - } -} -func (self *statistics) completeReportLocked() { - fmt.Print(resetColor) - self.out.Print("\n") - self.out.Print("\n") -} - -func (self *statistics) Write(content []byte) (written int, err error) { - return len(content), nil // no-op -} - -func NewStatisticsReporter(out *Printer) *statistics { - self := statistics{} - self.out = out - return &self -} - -type statistics struct { - sync.Mutex - - out *Printer - total int - failing bool - erroring bool - skipped int - suppressed bool -} - -func plural(word string, count int) string { - if count == 1 { - return word - } - return word + "s" -} diff --git a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/story.go b/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/story.go deleted file mode 100644 index 9e73c971f8..0000000000 --- a/Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/reporting/story.go +++ /dev/null @@ -1,73 +0,0 @@ -// TODO: in order for this reporter to be completely honest -// we need to retrofit to be more like the json reporter such that: -// 1. it maintains ScopeResult collections, which count assertions -// 2. it reports only after EndStory(), so that all tick marks -// are placed near the appropriate title. -// 3. Under unit test - -package reporting - -import ( - "fmt" - "strings" -) - -type story struct { - out *Printer - titlesById map[string]string - currentKey []string -} - -func (self *story) BeginStory(story *StoryReport) {} - -func (self *story) Enter(scope *ScopeReport) { - self.out.Indent() - - self.currentKey = append(self.currentKey, scope.Title) - ID := strings.Join(self.currentKey, "|") - - if _, found := self.titlesById[ID]; !found { - self.out.Println("") - self.out.Print(scope.Title) - self.out.Insert(" ") - self.titlesById[ID] = scope.Title - } -} - -func (self *story) Report(report *AssertionResult) { - if report.Error != nil { - fmt.Print(redColor) - self.out.Insert(error_) - } else if report.Failure != "" { - fmt.Print(yellowColor) - self.out.Insert(failure) - } else if report.Skipped { - fmt.Print(yellowColor) - self.out.Insert(skip) - } else { - fmt.Print(greenColor) - self.out.Insert(success) - } - fmt.Print(resetColor) -} - -func (self *story) Exit() { - self.out.Dedent() - self.currentKey = self.currentKey[:len(self.currentKey)-1] -} - -func (self *story) EndStory() { - self.titlesById = make(map[string]string) - self.out.Println("\n") -} - -func (self *story) Write(content []byte) (written int, err error) { - return len(content), nil // no-op -} - -func NewStoryReporter(out *Printer) *story { - self := new(story) - self.out = out - self.titlesById = make(map[string]string) - return self -} From 077b78f8b839b45e907bb2c6cc4255a3056037b6 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Mon, 23 May 2016 21:19:11 -0700 Subject: [PATCH 0322/1304] stage1: implement no-new-privs linux isolator Fixes #1469 --- stage1/init/common/pod.go | 15 ++++++ tests/inspect/inspect.go | 14 ++++++ tests/rkt_no_new_privs_test.go | 92 ++++++++++++++++++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 tests/rkt_no_new_privs_test.go diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index dbf63b4c9d..5895e24fdf 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -429,6 +429,8 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b return err } + noNewPrivileges := getAppNoNewPrivileges(app.Isolators) + execStart := append([]string{binPath}, app.Exec[1:]...) execStartString := quoteExec(execStart) opts := []*unit.UnitOption{ @@ -447,6 +449,7 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b unit.NewUnitOption("Service", "Group", strconv.Itoa(g)), unit.NewUnitOption("Service", "SupplementaryGroups", strings.Join(supplementaryGroups, " ")), unit.NewUnitOption("Service", "CapabilityBoundingSet", strings.Join(capabilitiesStr, " ")), + unit.NewUnitOption("Service", "NoNewPrivileges", strconv.FormatBool(noNewPrivileges)), // This helps working around a race // (https://github.com/systemd/systemd/issues/2913) that causes the // systemd unit name not getting written to the journal if the unit is @@ -1083,3 +1086,15 @@ func parseLinuxCapabilitiesSet(capSet types.LinuxCapabilitiesSet) []string { } return capsStr } + +func getAppNoNewPrivileges(isolators types.Isolators) bool { + for _, isolator := range isolators { + noNewPrivileges, ok := isolator.Value().(*types.LinuxNoNewPrivileges) + + if ok && bool(*noNewPrivileges) { + return true + } + } + + return false +} diff --git a/tests/inspect/inspect.go b/tests/inspect/inspect.go index 6d05ba5891..33b276a513 100644 --- a/tests/inspect/inspect.go +++ b/tests/inspect/inspect.go @@ -30,6 +30,8 @@ import ( "time" "unsafe" + "golang.org/x/sys/unix" + "github.com/coreos/rkt/common/cgroup" "github.com/coreos/rkt/tests/testutils" "github.com/syndtr/gocapability/capability" @@ -74,6 +76,7 @@ var ( PrintAppAnnotation string SilentSigterm bool CheckMountNS bool + PrintNoNewPrivs bool }{} ) @@ -114,6 +117,7 @@ func init() { globalFlagset.StringVar(&globalFlags.PrintAppAnnotation, "print-app-annotation", "", "Take an annotation name of the app, and prints its value") globalFlagset.BoolVar(&globalFlags.SilentSigterm, "silent-sigterm", false, "Exit with a success exit status if we receive SIGTERM") globalFlagset.BoolVar(&globalFlags.CheckMountNS, "check-mountns", false, "Check if app's mount ns is different than stage1's. Requires CAP_SYS_PTRACE") + globalFlagset.BoolVar(&globalFlags.PrintNoNewPrivs, "print-no-new-privs", false, "print the prctl PR_GET_NO_NEW_PRIVS value") } func in(list []int, el int) bool { @@ -133,6 +137,16 @@ func main() { os.Exit(1) } + if globalFlags.PrintNoNewPrivs { + r1, _, err := syscall.Syscall( + syscall.SYS_PRCTL, + uintptr(unix.PR_GET_NO_NEW_PRIVS), + uintptr(0), uintptr(0), + ) + + fmt.Printf("no_new_privs: %v err: %v\n", r1, err) + } + if globalFlags.SilentSigterm { terminateCh := make(chan os.Signal, 1) signal.Notify(terminateCh, syscall.SIGTERM) diff --git a/tests/rkt_no_new_privs_test.go b/tests/rkt_no_new_privs_test.go new file mode 100644 index 0000000000..ca16a15192 --- /dev/null +++ b/tests/rkt_no_new_privs_test.go @@ -0,0 +1,92 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build host coreos src + +package main + +import ( + "fmt" + "os" + "testing" + + "github.com/coreos/rkt/tests/testutils" +) + +func TestNoNewPrivileges(t *testing.T) { + for _, tt := range []struct { + rktParams string + patch string + expected string + }{ + { + patch: "--isolators=os/linux/no-new-privileges,true", + expected: "no_new_privs: 1 err: errno 0", + }, + { + rktParams: "--user=1000 --group=100", + patch: "--isolators=os/linux/no-new-privileges,true", + expected: "no_new_privs: 1 err: errno 0", + }, + { + patch: "--isolators=os/linux/no-new-privileges,false", + expected: "no_new_privs: 0 err: errno 0", + }, + { + rktParams: "--user=1000 --group=100", + patch: "--isolators=os/linux/no-new-privileges,false", + expected: "no_new_privs: 0 err: errno 0", + }, + { + patch: `--isolators=os/linux/no-new-privileges,false:os/linux/no-new-privileges,true`, + expected: "no_new_privs: 1 err: errno 0", + }, + { + rktParams: "--user=1000 --group=100", + patch: `--isolators=os/linux/no-new-privileges,false:os/linux/no-new-privileges,true`, + expected: "no_new_privs: 1 err: errno 0", + }, + { + patch: "", + expected: "no_new_privs: 0 err: errno 0", + }, + } { + func() { + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + ps := []string{} + if tt.patch != "" { + ps = append(ps, tt.patch) + } + + image := patchTestACI("rkt-no-new-privs.aci", ps...) + defer os.Remove(image) + + rktParams := fmt.Sprintf( + "%s --exec=/inspect -- -print-no-new-privs", + tt.rktParams, + ) + + rktCmd := fmt.Sprintf( + "%s --debug --insecure-options=image run %s %s", + ctx.Cmd(), + image, + rktParams, + ) + + runRktAndCheckOutput(t, rktCmd, tt.expected, false) + }() + } +} From b37bfb3ead682889508f4bc74b50f0512a66725c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Fri, 27 May 2016 09:40:41 +0200 Subject: [PATCH 0323/1304] Godeps: bump docker2aci to v0.11.0 For parallel goodness. --- Godeps/Godeps.json | 65 +- .../appc/docker2aci/lib/common/common.go | 6 + .../appc/docker2aci/lib/docker2aci.go | 40 +- .../lib/internal/backend/file/file.go | 61 +- .../internal/backend/repository/repository.go | 14 +- .../backend/repository/repository1.go | 91 +- .../backend/repository/repository2.go | 172 ++- .../appc/docker2aci/lib/internal/internal.go | 4 +- .../github.com/appc/docker2aci/lib/version.go | 2 +- .../src/github.com/coreos/pkg/LICENSE | 202 +++ .../src/github.com/coreos/pkg/NOTICE | 5 + .../coreos/pkg/progressutil/iocopy.go | 167 ++ .../coreos/pkg/progressutil/progressbar.go | 207 +++ .../src/github.com/klauspost/compress/LICENSE | 27 + .../klauspost/compress/flate/copy.go | 32 + .../klauspost/compress/flate/crc32_amd64.go | 39 + .../klauspost/compress/flate/crc32_amd64.s | 218 +++ .../klauspost/compress/flate/crc32_noasm.go | 34 + .../klauspost/compress/flate/deflate.go | 1358 +++++++++++++++++ .../klauspost/compress/flate/fixedhuff.go | 78 + .../klauspost/compress/flate/gen.go | 265 ++++ .../compress/flate/huffman_bit_writer.go | 717 +++++++++ .../klauspost/compress/flate/huffman_code.go | 363 +++++ .../klauspost/compress/flate/inflate.go | 846 ++++++++++ .../klauspost/compress/flate/reverse_bits.go | 48 + .../klauspost/compress/flate/snappy.go | 768 ++++++++++ .../klauspost/compress/flate/token.go | 105 ++ .../src/github.com/klauspost/cpuid/.gitignore | 24 + .../github.com/klauspost/cpuid/.travis.yml | 8 + .../src/github.com/klauspost/cpuid/LICENSE | 22 + .../src/github.com/klauspost/cpuid/README.md | 145 ++ .../src/github.com/klauspost/cpuid/cpuid.go | 1022 +++++++++++++ .../github.com/klauspost/cpuid/cpuid_386.s | 42 + .../github.com/klauspost/cpuid/cpuid_amd64.s | 42 + .../klauspost/cpuid/detect_intel.go | 17 + .../github.com/klauspost/cpuid/detect_ref.go | 23 + .../github.com/klauspost/cpuid/generate.go | 3 + .../github.com/klauspost/cpuid/private-gen.go | 476 ++++++ .../src/github.com/klauspost/crc32/.gitignore | 24 + .../github.com/klauspost/crc32/.travis.yml | 12 + .../src/github.com/klauspost/crc32/LICENSE | 28 + .../src/github.com/klauspost/crc32/README.md | 84 + .../src/github.com/klauspost/crc32/crc32.go | 186 +++ .../github.com/klauspost/crc32/crc32_amd64.go | 62 + .../github.com/klauspost/crc32/crc32_amd64.s | 237 +++ .../klauspost/crc32/crc32_amd64p32.go | 40 + .../klauspost/crc32/crc32_amd64p32.s | 67 + .../klauspost/crc32/crc32_generic.go | 29 + .../src/github.com/klauspost/pgzip/.gitignore | 24 + .../github.com/klauspost/pgzip/.travis.yml | 18 + .../src/github.com/klauspost/pgzip/GO_LICENSE | 27 + .../src/github.com/klauspost/pgzip/LICENSE | 22 + .../src/github.com/klauspost/pgzip/README.md | 115 ++ .../src/github.com/klauspost/pgzip/circle.yml | 7 + .../src/github.com/klauspost/pgzip/gunzip.go | 564 +++++++ .../src/github.com/klauspost/pgzip/gzip.go | 485 ++++++ rkt/image/dockerfetcher.go | 5 +- 57 files changed, 9618 insertions(+), 176 deletions(-) create mode 100644 Godeps/_workspace/src/github.com/coreos/pkg/LICENSE create mode 100644 Godeps/_workspace/src/github.com/coreos/pkg/NOTICE create mode 100644 Godeps/_workspace/src/github.com/coreos/pkg/progressutil/iocopy.go create mode 100644 Godeps/_workspace/src/github.com/coreos/pkg/progressutil/progressbar.go create mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/LICENSE create mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/flate/copy.go create mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/flate/crc32_amd64.go create mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/flate/crc32_amd64.s create mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/flate/crc32_noasm.go create mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/flate/deflate.go create mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/flate/fixedhuff.go create mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/flate/gen.go create mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/flate/huffman_bit_writer.go create mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/flate/huffman_code.go create mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/flate/inflate.go create mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/flate/reverse_bits.go create mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/flate/snappy.go create mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/flate/token.go create mode 100644 Godeps/_workspace/src/github.com/klauspost/cpuid/.gitignore create mode 100644 Godeps/_workspace/src/github.com/klauspost/cpuid/.travis.yml create mode 100644 Godeps/_workspace/src/github.com/klauspost/cpuid/LICENSE create mode 100644 Godeps/_workspace/src/github.com/klauspost/cpuid/README.md create mode 100644 Godeps/_workspace/src/github.com/klauspost/cpuid/cpuid.go create mode 100644 Godeps/_workspace/src/github.com/klauspost/cpuid/cpuid_386.s create mode 100644 Godeps/_workspace/src/github.com/klauspost/cpuid/cpuid_amd64.s create mode 100644 Godeps/_workspace/src/github.com/klauspost/cpuid/detect_intel.go create mode 100644 Godeps/_workspace/src/github.com/klauspost/cpuid/detect_ref.go create mode 100644 Godeps/_workspace/src/github.com/klauspost/cpuid/generate.go create mode 100644 Godeps/_workspace/src/github.com/klauspost/cpuid/private-gen.go create mode 100644 Godeps/_workspace/src/github.com/klauspost/crc32/.gitignore create mode 100644 Godeps/_workspace/src/github.com/klauspost/crc32/.travis.yml create mode 100644 Godeps/_workspace/src/github.com/klauspost/crc32/LICENSE create mode 100644 Godeps/_workspace/src/github.com/klauspost/crc32/README.md create mode 100644 Godeps/_workspace/src/github.com/klauspost/crc32/crc32.go create mode 100644 Godeps/_workspace/src/github.com/klauspost/crc32/crc32_amd64.go create mode 100644 Godeps/_workspace/src/github.com/klauspost/crc32/crc32_amd64.s create mode 100644 Godeps/_workspace/src/github.com/klauspost/crc32/crc32_amd64p32.go create mode 100644 Godeps/_workspace/src/github.com/klauspost/crc32/crc32_amd64p32.s create mode 100644 Godeps/_workspace/src/github.com/klauspost/crc32/crc32_generic.go create mode 100644 Godeps/_workspace/src/github.com/klauspost/pgzip/.gitignore create mode 100644 Godeps/_workspace/src/github.com/klauspost/pgzip/.travis.yml create mode 100644 Godeps/_workspace/src/github.com/klauspost/pgzip/GO_LICENSE create mode 100644 Godeps/_workspace/src/github.com/klauspost/pgzip/LICENSE create mode 100644 Godeps/_workspace/src/github.com/klauspost/pgzip/README.md create mode 100644 Godeps/_workspace/src/github.com/klauspost/pgzip/circle.yml create mode 100644 Godeps/_workspace/src/github.com/klauspost/pgzip/gunzip.go create mode 100644 Godeps/_workspace/src/github.com/klauspost/pgzip/gzip.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 734022758a..d7ac03d327 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -108,53 +108,53 @@ }, { "ImportPath": "github.com/appc/docker2aci/lib", - "Comment": "v0.9.3", - "Rev": "3b996e400e8937a7433b1759f846215e1d3b2fbd" + "Comment": "v0.11.0", + "Rev": "abe598e6384a9978e419a3f43d3e389218407624" }, { "ImportPath": "github.com/appc/docker2aci/lib/common", - "Comment": "v0.9.3", - "Rev": "3b996e400e8937a7433b1759f846215e1d3b2fbd" + "Comment": "v0.11.0", + "Rev": "abe598e6384a9978e419a3f43d3e389218407624" }, { "ImportPath": "github.com/appc/docker2aci/lib/internal", - "Comment": "v0.9.3", - "Rev": "3b996e400e8937a7433b1759f846215e1d3b2fbd" + "Comment": "v0.11.0", + "Rev": "abe598e6384a9978e419a3f43d3e389218407624" }, { "ImportPath": "github.com/appc/docker2aci/lib/internal/backend/file", - "Comment": "v0.9.3", - "Rev": "3b996e400e8937a7433b1759f846215e1d3b2fbd" + "Comment": "v0.11.0", + "Rev": "abe598e6384a9978e419a3f43d3e389218407624" }, { "ImportPath": "github.com/appc/docker2aci/lib/internal/backend/repository", - "Comment": "v0.9.3", - "Rev": "3b996e400e8937a7433b1759f846215e1d3b2fbd" + "Comment": "v0.11.0", + "Rev": "abe598e6384a9978e419a3f43d3e389218407624" }, { "ImportPath": "github.com/appc/docker2aci/lib/internal/docker", - "Comment": "v0.9.3", - "Rev": "3b996e400e8937a7433b1759f846215e1d3b2fbd" + "Comment": "v0.11.0", + "Rev": "abe598e6384a9978e419a3f43d3e389218407624" }, { "ImportPath": "github.com/appc/docker2aci/lib/internal/tarball", - "Comment": "v0.9.3", - "Rev": "3b996e400e8937a7433b1759f846215e1d3b2fbd" + "Comment": "v0.11.0", + "Rev": "abe598e6384a9978e419a3f43d3e389218407624" }, { "ImportPath": "github.com/appc/docker2aci/lib/internal/types", - "Comment": "v0.9.3", - "Rev": "3b996e400e8937a7433b1759f846215e1d3b2fbd" + "Comment": "v0.11.0", + "Rev": "abe598e6384a9978e419a3f43d3e389218407624" }, { "ImportPath": "github.com/appc/docker2aci/lib/internal/util", - "Comment": "v0.9.3", - "Rev": "3b996e400e8937a7433b1759f846215e1d3b2fbd" + "Comment": "v0.11.0", + "Rev": "abe598e6384a9978e419a3f43d3e389218407624" }, { "ImportPath": "github.com/appc/docker2aci/pkg/log", - "Comment": "v0.9.3", - "Rev": "3b996e400e8937a7433b1759f846215e1d3b2fbd" + "Comment": "v0.11.0", + "Rev": "abe598e6384a9978e419a3f43d3e389218407624" }, { "ImportPath": "github.com/appc/goaci/proj2aci", @@ -676,6 +676,31 @@ "ImportPath": "k8s.io/kubernetes/third_party/forked/reflect", "Comment": "v1.3.0-alpha.4", "Rev": "9990f843cd62caa90445cf76b07d63ba7b5c86fd" + }, + { + "ImportPath": "github.com/klauspost/pgzip", + "Comment": "v1.0", + "Rev": "95e8170c5d4da28db9c64dfc9ec3138ea4466fd4" + }, + { + "ImportPath": "github.com/coreos/pkg/progressutil", + "Comment": "v1", + "Rev": "160ae6282d8c48a33d8c150e4e4817fdef8a5cde" + }, + { + "ImportPath": "github.com/klauspost/compress/flate", + "Comment": "v1.0", + "Rev": "006acde2c5d283d2f8b8aa03d8f0cd2891c680cf" + }, + { + "ImportPath": "github.com/klauspost/crc32", + "Comment": "v1.0", + "Rev": "19b0b332c9e4516a6370a0456e6182c3b5036720" + }, + { + "ImportPath": "github.com/klauspost/cpuid", + "Comment": "v1.0", + "Rev": "09cded8978dc9e80714c4d85b0322337b0a1e5e0" } ] } diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/common/common.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/common/common.go index d28eddeb31..5fd1d46050 100644 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/common/common.go +++ b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/common/common.go @@ -44,6 +44,12 @@ type ErrSeveralImages struct { Images []string } +// InsecureConfig represents the different insecure options available +type InsecureConfig struct { + SkipVerify bool + AllowHTTP bool +} + func (e *ErrSeveralImages) Error() string { return e.Msg } diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/docker2aci.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/docker2aci.go index 090ad3adc1..4cb0ecc9aa 100644 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/docker2aci.go +++ b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/docker2aci.go @@ -18,7 +18,6 @@ package docker2aci import ( "archive/tar" - "compress/gzip" "fmt" "io" "io/ioutil" @@ -38,6 +37,7 @@ import ( "github.com/appc/spec/pkg/acirenderer" "github.com/appc/spec/schema" appctypes "github.com/appc/spec/schema/types" + gzip "github.com/klauspost/pgzip" ) // CommonConfig represents the shared configuration options for converting @@ -53,9 +53,9 @@ type CommonConfig struct { // converting Docker images. type RemoteConfig struct { CommonConfig - Username string // username to use if the image to convert needs authentication - Password string // password to use if the image to convert needs authentication - Insecure bool // allow converting from insecure repos + Username string // username to use if the image to convert needs authentication + Password string // password to use if the image to convert needs authentication + Insecure common.InsecureConfig // Insecure options } // FileConfig represents the saved file specific configuration for converting @@ -124,31 +124,25 @@ func convertReal(backend internal.Docker2ACIBackend, dockerURL string, squash bo conversionStore := newConversionStore() - var images acirenderer.Images - var aciLayerPaths []string - var curPwl []string - for i := len(ancestry) - 1; i >= 0; i-- { - layerID := ancestry[i] - - // only compress individual layers if we're not squashing - layerCompression := compression - if squash { - layerCompression = common.NoCompression - } + // only compress individual layers if we're not squashing + layerCompression := compression + if squash { + layerCompression = common.NoCompression + } - aciPath, manifest, err := backend.BuildACI(i, layerID, parsedDockerURL, layersOutputDir, tmpDir, curPwl, layerCompression) - if err != nil { - return nil, fmt.Errorf("error building layer: %v", err) - } + aciLayerPaths, aciManifests, err := backend.BuildACI(ancestry, parsedDockerURL, layersOutputDir, tmpDir, layerCompression) + if err != nil { + return nil, err + } - key, err := conversionStore.WriteACI(aciPath) + var images acirenderer.Images + for i, aciLayerPath := range aciLayerPaths { + key, err := conversionStore.WriteACI(aciLayerPath) if err != nil { return nil, fmt.Errorf("error inserting in the conversion store: %v", err) } - images = append(images, acirenderer.Image{Im: manifest, Key: key, Level: uint16(i)}) - aciLayerPaths = append(aciLayerPaths, aciPath) - curPwl = manifest.PathWhitelist + images = append(images, acirenderer.Image{Im: aciManifests[i], Key: key, Level: uint16(len(aciLayerPaths) - 1 - i)}) } // acirenderer expects images in order from upper to base layer diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/file/file.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/file/file.go index a0ba5e452e..a83402dfcd 100644 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/file/file.go +++ b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/file/file.go @@ -68,39 +68,48 @@ func (lb *FileBackend) GetImageInfo(dockerURL string) ([]string, *types.ParsedDo return ancestry, parsedDockerURL, nil } -func (lb *FileBackend) BuildACI(layerNumber int, layerID string, dockerURL *types.ParsedDockerURL, outputDir string, tmpBaseDir string, curPwl []string, compression common.Compression) (string, *schema.ImageManifest, error) { - tmpDir, err := ioutil.TempDir(tmpBaseDir, "docker2aci-") - if err != nil { - return "", nil, fmt.Errorf("error creating dir: %v", err) - } - defer os.RemoveAll(tmpDir) +func (lb *FileBackend) BuildACI(layerIDs []string, dockerURL *types.ParsedDockerURL, outputDir string, tmpBaseDir string, compression common.Compression) ([]string, []*schema.ImageManifest, error) { + var aciLayerPaths []string + var aciManifests []*schema.ImageManifest + var curPwl []string + for i := len(layerIDs) - 1; i >= 0; i-- { + tmpDir, err := ioutil.TempDir(tmpBaseDir, "docker2aci-") + if err != nil { + return nil, nil, fmt.Errorf("error creating dir: %v", err) + } + defer os.RemoveAll(tmpDir) - j, err := getJson(lb.file, layerID) - if err != nil { - return "", nil, fmt.Errorf("error getting image json: %v", err) - } + j, err := getJson(lb.file, layerIDs[i]) + if err != nil { + return nil, nil, fmt.Errorf("error getting image json: %v", err) + } - layerData := types.DockerImageData{} - if err := json.Unmarshal(j, &layerData); err != nil { - return "", nil, fmt.Errorf("error unmarshaling layer data: %v", err) - } + layerData := types.DockerImageData{} + if err := json.Unmarshal(j, &layerData); err != nil { + return nil, nil, fmt.Errorf("error unmarshaling layer data: %v", err) + } - tmpLayerPath := path.Join(tmpDir, layerID) - tmpLayerPath += ".tar" + tmpLayerPath := path.Join(tmpDir, layerIDs[i]) + tmpLayerPath += ".tar" - layerFile, err := extractEmbeddedLayer(lb.file, layerID, tmpLayerPath) - if err != nil { - return "", nil, fmt.Errorf("error getting layer from file: %v", err) - } - defer layerFile.Close() + layerFile, err := extractEmbeddedLayer(lb.file, layerIDs[i], tmpLayerPath) + if err != nil { + return nil, nil, fmt.Errorf("error getting layer from file: %v", err) + } + defer layerFile.Close() - log.Debug("Generating layer ACI...") - aciPath, manifest, err := internal.GenerateACI(layerNumber, layerData, dockerURL, outputDir, layerFile, curPwl, compression) - if err != nil { - return "", nil, fmt.Errorf("error generating ACI: %v", err) + log.Debug("Generating layer ACI...") + aciPath, manifest, err := internal.GenerateACI(i, layerData, dockerURL, outputDir, layerFile, curPwl, compression) + if err != nil { + return nil, nil, fmt.Errorf("error generating ACI: %v", err) + } + + aciLayerPaths = append(aciLayerPaths, aciPath) + aciManifests = append(aciManifests, manifest) + curPwl = manifest.PathWhitelist } - return aciPath, manifest, nil + return aciLayerPaths, aciManifests, nil } func getImageID(file *os.File, dockerURL *types.ParsedDockerURL) (string, *types.ParsedDockerURL, error) { diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository.go index 3c6715e8b3..57533857a1 100644 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository.go +++ b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository.go @@ -42,14 +42,14 @@ type RepositoryBackend struct { repoData *RepoData username string password string - insecure bool + insecure common.InsecureConfig hostsV2Support map[string]bool hostsV2AuthTokens map[string]map[string]string schema string imageManifests map[types.ParsedDockerURL]v2Manifest } -func NewRepositoryBackend(username string, password string, insecure bool) *RepositoryBackend { +func NewRepositoryBackend(username string, password string, insecure common.InsecureConfig) *RepositoryBackend { return &RepositoryBackend{ username: username, password: password, @@ -93,11 +93,11 @@ func (rb *RepositoryBackend) GetImageInfo(url string) ([]string, *types.ParsedDo } } -func (rb *RepositoryBackend) BuildACI(layerNumber int, layerID string, dockerURL *types.ParsedDockerURL, outputDir string, tmpBaseDir string, curPwl []string, compression common.Compression) (string, *schema.ImageManifest, error) { +func (rb *RepositoryBackend) BuildACI(layerIDs []string, dockerURL *types.ParsedDockerURL, outputDir string, tmpBaseDir string, compression common.Compression) ([]string, []*schema.ImageManifest, error) { if rb.hostsV2Support[dockerURL.IndexURL] { - return rb.buildACIV2(layerNumber, layerID, dockerURL, outputDir, tmpBaseDir, curPwl, compression) + return rb.buildACIV2(layerIDs, dockerURL, outputDir, tmpBaseDir, compression) } else { - return rb.buildACIV1(layerNumber, layerID, dockerURL, outputDir, tmpBaseDir, curPwl, compression) + return rb.buildACIV1(layerIDs, dockerURL, outputDir, tmpBaseDir, compression) } } @@ -137,7 +137,7 @@ func (rb *RepositoryBackend) supportsRegistry(indexURL string, version registryV rb.setBasicAuth(req) - client := util.GetTLSClient(rb.insecure) + client := util.GetTLSClient(rb.insecure.SkipVerify) res, err = client.Do(req) return } @@ -149,7 +149,7 @@ func (rb *RepositoryBackend) supportsRegistry(indexURL string, version registryV defer res.Body.Close() } if err != nil || !ok { - if rb.insecure { + if rb.insecure.AllowHTTP { schema = "http" res, err = fetch(schema) if err == nil { diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository1.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository1.go index 5b2f7a5cfa..bc54e47c7b 100644 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository1.go +++ b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository1.go @@ -29,6 +29,7 @@ import ( "github.com/appc/docker2aci/lib/common" "github.com/appc/docker2aci/lib/internal" "github.com/appc/docker2aci/lib/internal/types" + "github.com/appc/docker2aci/lib/internal/util" "github.com/appc/docker2aci/pkg/log" "github.com/appc/spec/schema" "github.com/coreos/ioprogress" @@ -62,40 +63,78 @@ func (rb *RepositoryBackend) getImageInfoV1(dockerURL *types.ParsedDockerURL) ([ return ancestry, dockerURL, nil } -func (rb *RepositoryBackend) buildACIV1(layerNumber int, layerID string, dockerURL *types.ParsedDockerURL, outputDir string, tmpBaseDir string, curPwl []string, compression common.Compression) (string, *schema.ImageManifest, error) { - tmpDir, err := ioutil.TempDir(tmpBaseDir, "docker2aci-") - if err != nil { - return "", nil, fmt.Errorf("error creating dir: %v", err) - } - defer os.RemoveAll(tmpDir) +func (rb *RepositoryBackend) buildACIV1(layerIDs []string, dockerURL *types.ParsedDockerURL, outputDir string, tmpBaseDir string, compression common.Compression) ([]string, []*schema.ImageManifest, error) { + layerFiles := make([]*os.File, len(layerIDs)) + layerDatas := make([]types.DockerImageData, len(layerIDs)) - j, size, err := rb.getJsonV1(layerID, rb.repoData.Endpoints[0], rb.repoData) + tmpParentDir, err := ioutil.TempDir(tmpBaseDir, "docker2aci-") if err != nil { - return "", nil, fmt.Errorf("error getting image json: %v", err) + return nil, nil, err } + defer os.RemoveAll(tmpParentDir) + + var doneChannels []chan error + for i, layerID := range layerIDs { + doneChan := make(chan error) + doneChannels = append(doneChannels, doneChan) + // https://github.com/golang/go/wiki/CommonMistakes + i := i // golang-- + layerID := layerID + go func() { + tmpDir, err := ioutil.TempDir(tmpParentDir, "") + if err != nil { + doneChan <- fmt.Errorf("error creating dir: %v", err) + return + } - layerData := types.DockerImageData{} - if err := json.Unmarshal(j, &layerData); err != nil { - return "", nil, fmt.Errorf("error unmarshaling layer data: %v", err) - } + j, size, err := rb.getJsonV1(layerID, rb.repoData.Endpoints[0], rb.repoData) + if err != nil { + doneChan <- fmt.Errorf("error getting image json: %v", err) + return + } - layerFile, err := rb.getLayerV1(layerID, rb.repoData.Endpoints[0], rb.repoData, size, tmpDir) - if err != nil { - return "", nil, fmt.Errorf("error getting the remote layer: %v", err) + layerDatas[i] = types.DockerImageData{} + if err := json.Unmarshal(j, &layerDatas[i]); err != nil { + doneChan <- fmt.Errorf("error unmarshaling layer data: %v", err) + return + } + + layerFiles[i], err = rb.getLayerV1(layerID, rb.repoData.Endpoints[0], rb.repoData, size, tmpDir) + if err != nil { + doneChan <- fmt.Errorf("error getting the remote layer: %v", err) + return + } + doneChan <- nil + }() + } + for _, doneChan := range doneChannels { + err := <-doneChan + if err != nil { + return nil, nil, err + } } - defer layerFile.Close() + var aciLayerPaths []string + var aciManifests []*schema.ImageManifest + var curPwl []string - log.Debug("Generating layer ACI...") - aciPath, manifest, err := internal.GenerateACI(layerNumber, layerData, dockerURL, outputDir, layerFile, curPwl, compression) - if err != nil { - return "", nil, fmt.Errorf("error generating ACI: %v", err) + for i := len(layerIDs) - 1; i >= 0; i-- { + log.Debug("Generating layer ACI...") + aciPath, manifest, err := internal.GenerateACI(i, layerDatas[i], dockerURL, outputDir, layerFiles[i], curPwl, compression) + if err != nil { + return nil, nil, fmt.Errorf("error generating ACI: %v", err) + } + aciLayerPaths = append(aciLayerPaths, aciPath) + aciManifests = append(aciManifests, manifest) + curPwl = manifest.PathWhitelist + + layerFiles[i].Close() } - return aciPath, manifest, nil + return aciLayerPaths, aciManifests, nil } func (rb *RepositoryBackend) getRepoDataV1(indexURL string, remote string) (*RepoData, error) { - client := &http.Client{} + client := util.GetTLSClient(rb.insecure.SkipVerify) repositoryURL := rb.schema + path.Join(indexURL, "v1", "repositories", remote, "images") req, err := http.NewRequest("GET", repositoryURL, nil) @@ -145,7 +184,7 @@ func (rb *RepositoryBackend) getRepoDataV1(indexURL string, remote string) (*Rep } func (rb *RepositoryBackend) getImageIDFromTagV1(registry string, appName string, tag string, repoData *RepoData) (string, error) { - client := &http.Client{} + client := util.GetTLSClient(rb.insecure.SkipVerify) // we get all the tags instead of directly getting the imageID of the // requested one (.../tags/TAG) because even though it's specified in the // Docker API, some registries (e.g. Google Container Registry) don't @@ -188,7 +227,7 @@ func (rb *RepositoryBackend) getImageIDFromTagV1(registry string, appName string } func (rb *RepositoryBackend) getAncestryV1(imgID, registry string, repoData *RepoData) ([]string, error) { - client := &http.Client{} + client := util.GetTLSClient(rb.insecure.SkipVerify) req, err := http.NewRequest("GET", rb.schema+path.Join(registry, "images", imgID, "ancestry"), nil) if err != nil { return nil, err @@ -221,7 +260,7 @@ func (rb *RepositoryBackend) getAncestryV1(imgID, registry string, repoData *Rep } func (rb *RepositoryBackend) getJsonV1(imgID, registry string, repoData *RepoData) ([]byte, int64, error) { - client := &http.Client{} + client := util.GetTLSClient(rb.insecure.SkipVerify) req, err := http.NewRequest("GET", rb.schema+path.Join(registry, "images", imgID, "json"), nil) if err != nil { return nil, -1, err @@ -256,7 +295,7 @@ func (rb *RepositoryBackend) getJsonV1(imgID, registry string, repoData *RepoDat } func (rb *RepositoryBackend) getLayerV1(imgID, registry string, repoData *RepoData, imgSize int64, tmpDir string) (*os.File, error) { - client := &http.Client{} + client := util.GetTLSClient(rb.insecure.SkipVerify) req, err := http.NewRequest("GET", rb.schema+path.Join(registry, "images", imgID, "layer"), nil) if err != nil { return nil, err diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository2.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository2.go index b685cf8eaa..6a0c8907da 100644 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository2.go +++ b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository2.go @@ -34,7 +34,7 @@ import ( "github.com/appc/docker2aci/lib/internal/util" "github.com/appc/docker2aci/pkg/log" "github.com/appc/spec/schema" - "github.com/coreos/ioprogress" + "github.com/coreos/pkg/progressutil" ) const ( @@ -66,42 +66,98 @@ func (rb *RepositoryBackend) getImageInfoV2(dockerURL *types.ParsedDockerURL) ([ return layers, dockerURL, nil } -func (rb *RepositoryBackend) buildACIV2(layerNumber int, layerID string, dockerURL *types.ParsedDockerURL, outputDir string, tmpBaseDir string, curPwl []string, compression common.Compression) (string, *schema.ImageManifest, error) { - manifest := rb.imageManifests[*dockerURL] +func (rb *RepositoryBackend) buildACIV2(layerIDs []string, dockerURL *types.ParsedDockerURL, outputDir string, tmpBaseDir string, compression common.Compression) ([]string, []*schema.ImageManifest, error) { + layerFiles := make([]*os.File, len(layerIDs)) + layerDatas := make([]types.DockerImageData, len(layerIDs)) - layerIndex, err := getLayerIndex(layerID, manifest) + tmpParentDir, err := ioutil.TempDir(tmpBaseDir, "docker2aci-") if err != nil { - return "", nil, err + return nil, nil, err } + defer os.RemoveAll(tmpParentDir) - if len(manifest.History) <= layerIndex { - return "", nil, fmt.Errorf("history not found for layer %s", layerID) - } + copier := &progressutil.CopyProgressPrinter{} - layerData := types.DockerImageData{} - if err := json.Unmarshal([]byte(manifest.History[layerIndex].V1Compatibility), &layerData); err != nil { - return "", nil, fmt.Errorf("error unmarshaling layer data: %v", err) - } + var errChannels []chan error + closers := make([]io.ReadCloser, len(layerIDs)) + for i, layerID := range layerIDs { + errChan := make(chan error) + errChannels = append(errChannels, errChan) + // https://github.com/golang/go/wiki/CommonMistakes + i := i // golang-- + layerID := layerID + go func() { + manifest := rb.imageManifests[*dockerURL] - tmpDir, err := ioutil.TempDir(tmpBaseDir, "docker2aci-") - if err != nil { - return "", nil, fmt.Errorf("error creating dir: %v", err) - } - defer os.RemoveAll(tmpDir) + layerIndex, err := getLayerIndex(layerID, manifest) + if err != nil { + errChan <- err + return + } + + if len(manifest.History) <= layerIndex { + errChan <- fmt.Errorf("history not found for layer %s", layerID) + return + } + + layerDatas[i] = types.DockerImageData{} + if err := json.Unmarshal([]byte(manifest.History[layerIndex].V1Compatibility), &layerDatas[i]); err != nil { + errChan <- fmt.Errorf("error unmarshaling layer data: %v", err) + return + } + + tmpDir, err := ioutil.TempDir(tmpParentDir, "") + if err != nil { + errChan <- fmt.Errorf("error creating dir: %v", err) + return + } - layerFile, err := rb.getLayerV2(layerID, dockerURL, tmpDir) + layerFiles[i], closers[i], err = rb.getLayerV2(layerID, dockerURL, tmpDir, copier) + if err != nil { + errChan <- fmt.Errorf("error getting the remote layer: %v", err) + return + } + errChan <- nil + }() + } + err = copier.PrintAndWait(os.Stderr, 500*time.Millisecond, nil) if err != nil { - return "", nil, fmt.Errorf("error getting the remote layer: %v", err) + return nil, nil, err + } + for _, closer := range closers { + if closer != nil { + closer.Close() + } + } + for _, errChan := range errChannels { + err := <-errChan + if err != nil { + return nil, nil, err + } + } + for _, layerFile := range layerFiles { + err := layerFile.Sync() + if err != nil { + return nil, nil, err + } } - defer layerFile.Close() + var aciLayerPaths []string + var aciManifests []*schema.ImageManifest + var curPwl []string + for i := len(layerIDs) - 1; i >= 0; i-- { + log.Debug("Generating layer ACI...") + aciPath, aciManifest, err := internal.GenerateACI(i, layerDatas[i], dockerURL, outputDir, layerFiles[i], curPwl, compression) + if err != nil { + return nil, nil, fmt.Errorf("error generating ACI: %v", err) + } + aciLayerPaths = append(aciLayerPaths, aciPath) + aciManifests = append(aciManifests, aciManifest) + curPwl = aciManifest.PathWhitelist - log.Debug("Generating layer ACI...") - aciPath, aciManifest, err := internal.GenerateACI(layerNumber, layerData, dockerURL, outputDir, layerFile, curPwl, compression) - if err != nil { - return "", nil, fmt.Errorf("error generating ACI: %v", err) + layerFiles[i].Close() } - return aciPath, aciManifest, nil + return aciLayerPaths, aciManifests, nil } func (rb *RepositoryBackend) getManifestV2(dockerURL *types.ParsedDockerURL) (*v2Manifest, []string, error) { @@ -224,84 +280,61 @@ func getLayerIndex(layerID string, manifest v2Manifest) (int, error) { return -1, fmt.Errorf("layer not found in manifest: %s", layerID) } -func (rb *RepositoryBackend) getLayerV2(layerID string, dockerURL *types.ParsedDockerURL, tmpDir string) (*os.File, error) { +func (rb *RepositoryBackend) getLayerV2(layerID string, dockerURL *types.ParsedDockerURL, tmpDir string, copier *progressutil.CopyProgressPrinter) (*os.File, io.ReadCloser, error) { url := rb.schema + path.Join(dockerURL.IndexURL, "v2", dockerURL.ImageName, "blobs", layerID) req, err := http.NewRequest("GET", url, nil) if err != nil { - return nil, err + return nil, nil, err } rb.setBasicAuth(req) res, err := rb.makeRequest(req, dockerURL.ImageName) if err != nil { - return nil, err + return nil, nil, err } - defer res.Body.Close() if res.StatusCode == http.StatusTemporaryRedirect || res.StatusCode == http.StatusFound { location := res.Header.Get("Location") if location != "" { req, err = http.NewRequest("GET", location, nil) if err != nil { - return nil, err + return nil, nil, err } res, err = rb.makeRequest(req, dockerURL.ImageName) if err != nil { - return nil, err + return nil, nil, err } defer res.Body.Close() } } if res.StatusCode != http.StatusOK { - return nil, fmt.Errorf("HTTP code: %d. URL: %s", res.StatusCode, req.URL) + return nil, nil, fmt.Errorf("HTTP code: %d. URL: %s", res.StatusCode, req.URL) } var in io.Reader in = res.Body + var size int64 + if hdr := res.Header.Get("Content-Length"); hdr != "" { - imgSize, err := strconv.ParseInt(hdr, 10, 64) + size, err = strconv.ParseInt(hdr, 10, 64) if err != nil { - return nil, err - } - - prefix := "Downloading " + layerID[:18] - fmtBytesSize := 18 - barSize := int64(80 - len(prefix) - fmtBytesSize) - bar := ioprogress.DrawTextFormatBarForW(barSize, os.Stderr) - fmtfunc := func(progress, total int64) string { - return fmt.Sprintf( - "%s: %s %s", - prefix, - bar(progress, total), - ioprogress.DrawTextFormatBytes(progress, total), - ) - } - in = &ioprogress.Reader{ - Reader: res.Body, - Size: imgSize, - DrawFunc: ioprogress.DrawTerminalf(os.Stderr, fmtfunc), - DrawInterval: 500 * time.Millisecond, + return nil, nil, err } } - layerFile, err := ioutil.TempFile(tmpDir, "dockerlayer-") - if err != nil { - return nil, err - } + name := "Downloading " + layerID[:18] - _, err = io.Copy(layerFile, in) + layerFile, err := ioutil.TempFile(tmpDir, "dockerlayer-") if err != nil { - return nil, err + return nil, nil, err } - if err := layerFile.Sync(); err != nil { - return nil, err - } + copier.AddCopy(in, name, size, layerFile) - return layerFile, nil + return layerFile, res.Body, nil } func (rb *RepositoryBackend) makeRequest(req *http.Request, repo string) (*http.Response, error) { @@ -315,7 +348,7 @@ func (rb *RepositoryBackend) makeRequest(req *http.Request, repo string) (*http. } } - client := util.GetTLSClient(rb.insecure) + client := util.GetTLSClient(rb.insecure.SkipVerify) res, err := client.Do(req) if err != nil { return nil, err @@ -330,18 +363,17 @@ func (rb *RepositoryBackend) makeRequest(req *http.Request, repo string) (*http. return res, err } - tokens := strings.Split(hdr, " ") - if len(tokens) != 2 || strings.ToLower(tokens[0]) != "bearer" { + tokens := strings.Split(hdr, ",") + if len(tokens) != 3 || + !strings.HasPrefix(strings.ToLower(tokens[0]), "bearer realm") { return res, err } res.Body.Close() - tokens = strings.Split(tokens[1], ",") - var realm, service, scope string for _, token := range tokens { - if strings.HasPrefix(token, "realm") { - realm = strings.Trim(token[len("realm="):], "\"") + if strings.HasPrefix(strings.ToLower(token), "bearer realm") { + realm = strings.Trim(token[len("bearer realm="):], "\"") } if strings.HasPrefix(token, "service") { service = strings.Trim(token[len("service="):], "\"") diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/internal.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/internal.go index 3a30663df3..29cd8c87e4 100644 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/internal.go +++ b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/internal.go @@ -20,7 +20,6 @@ package internal import ( "archive/tar" - "compress/gzip" "encoding/json" "fmt" "io" @@ -40,6 +39,7 @@ import ( "github.com/appc/spec/aci" "github.com/appc/spec/schema" appctypes "github.com/appc/spec/schema/types" + gzip "github.com/klauspost/pgzip" ) // Docker2ACIBackend is the interface that abstracts converting Docker layers @@ -52,7 +52,7 @@ import ( // path and its converted ImageManifest. type Docker2ACIBackend interface { GetImageInfo(dockerUrl string) ([]string, *types.ParsedDockerURL, error) - BuildACI(layerNumber int, layerID string, dockerURL *types.ParsedDockerURL, outputDir string, tmpBaseDir string, curPWl []string, compression common.Compression) (string, *schema.ImageManifest, error) + BuildACI(layerIDs []string, dockerURL *types.ParsedDockerURL, outputDir string, tmpBaseDir string, compression common.Compression) ([]string, []*schema.ImageManifest, error) } // GenerateACI takes a Docker layer and generates an ACI from it. diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/version.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/version.go index 6120c38b82..f8fe2eba80 100644 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/version.go +++ b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/version.go @@ -16,5 +16,5 @@ package docker2aci import "github.com/appc/spec/schema" -var Version = "0.9.3" +var Version = "0.11.0" var AppcVersion = schema.AppContainerVersion diff --git a/Godeps/_workspace/src/github.com/coreos/pkg/LICENSE b/Godeps/_workspace/src/github.com/coreos/pkg/LICENSE new file mode 100644 index 0000000000..e06d208186 --- /dev/null +++ b/Godeps/_workspace/src/github.com/coreos/pkg/LICENSE @@ -0,0 +1,202 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor 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, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/Godeps/_workspace/src/github.com/coreos/pkg/NOTICE b/Godeps/_workspace/src/github.com/coreos/pkg/NOTICE new file mode 100644 index 0000000000..b39ddfa5cb --- /dev/null +++ b/Godeps/_workspace/src/github.com/coreos/pkg/NOTICE @@ -0,0 +1,5 @@ +CoreOS Project +Copyright 2014 CoreOS, Inc + +This product includes software developed at CoreOS, Inc. +(http://www.coreos.com/). diff --git a/Godeps/_workspace/src/github.com/coreos/pkg/progressutil/iocopy.go b/Godeps/_workspace/src/github.com/coreos/pkg/progressutil/iocopy.go new file mode 100644 index 0000000000..d897dc86b9 --- /dev/null +++ b/Godeps/_workspace/src/github.com/coreos/pkg/progressutil/iocopy.go @@ -0,0 +1,167 @@ +// Copyright 2016 CoreOS Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package progressutil + +import ( + "fmt" + "io" + "sync" + "time" +) + +type copyReader struct { + reader io.Reader + current int64 + total int64 + done bool + pb *ProgressBar +} + +func (cr *copyReader) Read(p []byte) (int, error) { + n, err := cr.reader.Read(p) + cr.current += int64(n) + err1 := cr.updateProgressBar() + if err == nil { + err = err1 + } + if err != nil { + cr.done = true + } + return n, err +} + +func (cr *copyReader) updateProgressBar() error { + cr.pb.SetPrintAfter(cr.formattedProgress()) + + progress := float64(cr.current) / float64(cr.total) + if progress > 1 { + progress = 1 + } + return cr.pb.SetCurrentProgress(progress) +} + +// CopyProgressPrinter will perform an arbitrary number of io.Copy calls, while +// continually printing the progress of each copy. +type CopyProgressPrinter struct { + readers []*copyReader + errors []error + lock sync.Mutex + pbp *ProgressBarPrinter +} + +// AddCopy adds a copy for this CopyProgressPrinter to perform. An io.Copy call +// will be made to copy bytes from reader to dest, and name and size will be +// used to label the progress bar and display how much progress has been made. +// If size is 0, the total size of the reader is assumed to be unknown. +func (cpp *CopyProgressPrinter) AddCopy(reader io.Reader, name string, size int64, dest io.Writer) { + cpp.lock.Lock() + if cpp.pbp == nil { + cpp.pbp = &ProgressBarPrinter{} + cpp.pbp.PadToBeEven = true + } + + cr := ©Reader{ + reader: reader, + current: 0, + total: size, + pb: cpp.pbp.AddProgressBar(), + } + cr.pb.SetPrintBefore(name) + cr.pb.SetPrintAfter(cr.formattedProgress()) + + cpp.readers = append(cpp.readers, cr) + cpp.lock.Unlock() + + go func() { + _, err := io.Copy(dest, cr) + if err != nil { + cpp.lock.Lock() + cpp.errors = append(cpp.errors, err) + cpp.lock.Unlock() + } + }() +} + +// PrintAndWait will print the progress for each copy operation added with +// AddCopy to printTo every printInterval. This will continue until every added +// copy is finished, or until cancel is written to. +func (cpp *CopyProgressPrinter) PrintAndWait(printTo io.Writer, printInterval time.Duration, cancel chan struct{}) error { + for { + // If cancel is not nil, see if anything has been written to it. If + // something has, return, otherwise keep drawing. + if cancel != nil { + select { + case <-cancel: + return nil + default: + } + } + + cpp.lock.Lock() + readers := cpp.readers + errors := cpp.errors + cpp.lock.Unlock() + + if len(errors) > 0 { + return errors[0] + } + + if len(readers) > 0 { + _, err := cpp.pbp.Print(printTo) + if err != nil { + return err + } + } else { + } + + allDone := true + for _, r := range readers { + allDone = allDone && r.done + } + if allDone && len(readers) > 0 { + return nil + } + + time.Sleep(printInterval) + } +} + +func (cr *copyReader) formattedProgress() string { + var totalStr string + if cr.total == 0 { + totalStr = "?" + } else { + totalStr = ByteUnitStr(cr.total) + } + return fmt.Sprintf("%s / %s", ByteUnitStr(cr.current), totalStr) +} + +var byteUnits = []string{"B", "KB", "MB", "GB", "TB", "PB"} + +// ByteUnitStr pretty prints a number of bytes. +func ByteUnitStr(n int64) string { + var unit string + size := float64(n) + for i := 1; i < len(byteUnits); i++ { + if size < 1000 { + unit = byteUnits[i-1] + break + } + + size = size / 1000 + } + + return fmt.Sprintf("%.3g %s", size, unit) +} diff --git a/Godeps/_workspace/src/github.com/coreos/pkg/progressutil/progressbar.go b/Godeps/_workspace/src/github.com/coreos/pkg/progressutil/progressbar.go new file mode 100644 index 0000000000..76d2bff1ca --- /dev/null +++ b/Godeps/_workspace/src/github.com/coreos/pkg/progressutil/progressbar.go @@ -0,0 +1,207 @@ +// Copyright 2016 CoreOS Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package progressutil + +import ( + "fmt" + "io" + "os" + "strings" + "sync" + + "golang.org/x/crypto/ssh/terminal" +) + +var ( + // ErrorProgressOutOfBounds is returned if the progress is set to a value + // not between 0 and 1. + ErrorProgressOutOfBounds = fmt.Errorf("progress is out of bounds (0 to 1)") + + // ErrorNoBarsAdded is returned when no progress bars have been added to a + // ProgressBarPrinter before PrintAndWait is called. + ErrorNoBarsAdded = fmt.Errorf("AddProgressBar hasn't been called yet") +) + +// ProgressBar represents one progress bar in a ProgressBarPrinter. Should not +// be created directly, use the AddProgressBar on a ProgressBarPrinter to +// create these. +type ProgressBar struct { + currentProgress float64 + printBefore string + printAfter string + lock sync.Mutex + done bool +} + +// SetCurrentProgress sets the progress of this ProgressBar. The progress must +// be between 0 and 1 inclusive. +func (pb *ProgressBar) SetCurrentProgress(progress float64) error { + if progress < 0 || progress > 1 { + return ErrorProgressOutOfBounds + } + pb.lock.Lock() + pb.currentProgress = progress + pb.lock.Unlock() + return nil +} + +// SetPrintBefore sets the text printed on the line before the progress bar. +func (pb *ProgressBar) SetPrintBefore(before string) { + pb.lock.Lock() + pb.printBefore = before + pb.lock.Unlock() +} + +// SetPrintAfter sets the text printed on the line after the progress bar. +func (pb *ProgressBar) SetPrintAfter(after string) { + pb.lock.Lock() + pb.printAfter = after + pb.lock.Unlock() +} + +// ProgressBarPrinter will print out the progress of some number of +// ProgressBars. +type ProgressBarPrinter struct { + // DisplayWidth can be set to influence how large the progress bars are. + // The bars will be scaled to attempt to produce lines of this number of + // characters, but lines of different lengths may still be printed. When + // this value is 0 (aka unset), 80 character columns are assumed. + DisplayWidth int + // PadToBeEven, when set to true, will make Print pad the printBefore text + // with trailing spaces and the printAfter text with leading spaces to make + // the progress bars the same length. + PadToBeEven bool + numLinesInLastPrint int + progressBars []*ProgressBar + lock sync.Mutex +} + +// AddProgressBar will create a new ProgressBar, register it with this +// ProgressBarPrinter, and return it. This must be called at least once before +// PrintAndWait is called. +func (pbp *ProgressBarPrinter) AddProgressBar() *ProgressBar { + pb := &ProgressBar{} + pbp.lock.Lock() + pbp.progressBars = append(pbp.progressBars, pb) + pbp.lock.Unlock() + return pb +} + +// Print will print out progress information for each ProgressBar that has been +// added to this ProgressBarPrinter. The progress will be written to printTo, +// and if printTo is a terminal it will draw progress bars. AddProgressBar +// must be called at least once before Print is called. If printing to a +// terminal, all draws after the first one will move the cursor up to draw over +// the previously printed bars. +func (pbp *ProgressBarPrinter) Print(printTo io.Writer) (bool, error) { + pbp.lock.Lock() + bars := pbp.progressBars + numColumns := pbp.DisplayWidth + pbp.lock.Unlock() + + if len(bars) == 0 { + return false, ErrorNoBarsAdded + } + + if numColumns == 0 { + numColumns = 80 + } + + if isTerminal(printTo) { + moveCursorUp(printTo, pbp.numLinesInLastPrint) + } + + maxBefore := 0 + maxAfter := 0 + for _, bar := range bars { + bar.lock.Lock() + beforeSize := len(bar.printBefore) + afterSize := len(bar.printAfter) + bar.lock.Unlock() + if beforeSize > maxBefore { + maxBefore = beforeSize + } + if afterSize > maxAfter { + maxAfter = afterSize + } + } + + allDone := false + for _, bar := range bars { + if isTerminal(printTo) { + bar.printToTerminal(printTo, numColumns, pbp.PadToBeEven, maxBefore, maxAfter) + } else { + bar.printToNonTerminal(printTo) + } + allDone = allDone || bar.currentProgress == 1 + } + + pbp.numLinesInLastPrint = len(bars) + + return allDone, nil +} + +// moveCursorUp moves the cursor up numLines in the terminal +func moveCursorUp(printTo io.Writer, numLines int) { + if numLines > 0 { + fmt.Fprintf(printTo, "\033[%dA", numLines) + } +} + +func (pb *ProgressBar) printToTerminal(printTo io.Writer, numColumns int, padding bool, maxBefore, maxAfter int) { + pb.lock.Lock() + before := pb.printBefore + after := pb.printAfter + + if padding { + before = before + strings.Repeat(" ", maxBefore-len(before)) + after = strings.Repeat(" ", maxAfter-len(after)) + after + } + + progressBarSize := numColumns - (len(fmt.Sprintf("%s [] %s", before, after))) + progressBar := "" + if progressBarSize > 0 { + currentProgress := int(pb.currentProgress * float64(progressBarSize)) + progressBar = fmt.Sprintf("[%s%s] ", + strings.Repeat("=", currentProgress), + strings.Repeat(" ", progressBarSize-currentProgress)) + } else { + // If we can't fit the progress bar, better to not pad the before/after. + before = pb.printBefore + after = pb.printAfter + } + + fmt.Fprintf(printTo, "%s %s%s\n", before, progressBar, after) + pb.lock.Unlock() +} + +func (pb *ProgressBar) printToNonTerminal(printTo io.Writer) { + pb.lock.Lock() + if !pb.done { + fmt.Fprintf(printTo, "%s %s\n", pb.printBefore, pb.printAfter) + if pb.currentProgress == 1 { + pb.done = true + } + } + pb.lock.Unlock() +} + +// isTerminal returns True when w is going to a tty, and false otherwise. +func isTerminal(w io.Writer) bool { + if f, ok := w.(*os.File); ok { + return terminal.IsTerminal(int(f.Fd())) + } + return false +} diff --git a/Godeps/_workspace/src/github.com/klauspost/compress/LICENSE b/Godeps/_workspace/src/github.com/klauspost/compress/LICENSE new file mode 100644 index 0000000000..7448756763 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/compress/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2012 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. diff --git a/Godeps/_workspace/src/github.com/klauspost/compress/flate/copy.go b/Godeps/_workspace/src/github.com/klauspost/compress/flate/copy.go new file mode 100644 index 0000000000..a3200a8f49 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/compress/flate/copy.go @@ -0,0 +1,32 @@ +// 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. + +package flate + +// forwardCopy is like the built-in copy function except that it always goes +// forward from the start, even if the dst and src overlap. +// It is equivalent to: +// for i := 0; i < n; i++ { +// mem[dst+i] = mem[src+i] +// } +func forwardCopy(mem []byte, dst, src, n int) { + if dst <= src { + copy(mem[dst:dst+n], mem[src:src+n]) + return + } + for { + if dst >= src+n { + copy(mem[dst:dst+n], mem[src:src+n]) + return + } + // There is some forward overlap. The destination + // will be filled with a repeated pattern of mem[src:src+k]. + // We copy one instance of the pattern here, then repeat. + // Each time around this loop k will double. + k := dst - src + copy(mem[dst:dst+k], mem[src:src+k]) + n -= k + dst += k + } +} diff --git a/Godeps/_workspace/src/github.com/klauspost/compress/flate/crc32_amd64.go b/Godeps/_workspace/src/github.com/klauspost/compress/flate/crc32_amd64.go new file mode 100644 index 0000000000..45d52f629c --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/compress/flate/crc32_amd64.go @@ -0,0 +1,39 @@ +//+build !noasm +//+build !appengine + +// Copyright 2015, Klaus Post, see LICENSE for details. + +package flate + +import ( + "github.com/klauspost/cpuid" +) + +// crc32sse returns a hash for the first 4 bytes of the slice +// len(a) must be >= 4. +//go:noescape +func crc32sse(a []byte) hash + +// crc32sseAll calculates hashes for each 4-byte set in a. +// dst must be east len(a) - 4 in size. +// The size is not checked by the assembly. +//go:noescape +func crc32sseAll(a []byte, dst []hash) + +// matchLenSSE4 returns the number of matching bytes in a and b +// up to length 'max'. Both slices must be at least 'max' +// bytes in size. +// It uses the PCMPESTRI SSE 4.2 instruction. +//go:noescape +func matchLenSSE4(a, b []byte, max int) int + +// histogram accumulates a histogram of b in h. +// h must be at least 256 entries in length, +// and must be cleared before calling this function. +//go:noescape +func histogram(b []byte, h []int32) + +// Detect SSE 4.2 feature. +func init() { + useSSE42 = cpuid.CPU.SSE42() +} diff --git a/Godeps/_workspace/src/github.com/klauspost/compress/flate/crc32_amd64.s b/Godeps/_workspace/src/github.com/klauspost/compress/flate/crc32_amd64.s new file mode 100644 index 0000000000..0212360d66 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/compress/flate/crc32_amd64.s @@ -0,0 +1,218 @@ +//+build !noasm !appengine + +// Copyright 2015, Klaus Post, see LICENSE for details. + +// func crc32sse(a []byte) hash +TEXT ·crc32sse(SB), 7, $0 + MOVQ a+0(FP), R10 + XORQ BX, BX + + // CRC32 dword (R10), EBX + BYTE $0xF2; BYTE $0x41; BYTE $0x0f + BYTE $0x38; BYTE $0xf1; BYTE $0x1a + + MOVL BX, ret+24(FP) + RET + +// func crc32sseAll(a []byte, dst []hash) +TEXT ·crc32sseAll(SB), 7, $0 + MOVQ a+0(FP), R8 // R8: src + MOVQ a_len+8(FP), R10 // input length + MOVQ dst+24(FP), R9 // R9: dst + SUBQ $4, R10 + JS end + JZ one_crc + MOVQ R10, R13 + SHRQ $2, R10 // len/4 + ANDQ $3, R13 // len&3 + XORQ BX, BX + ADDQ $1, R13 + TESTQ R10, R10 + JZ rem_loop + +crc_loop: + MOVQ (R8), R11 + XORQ BX, BX + XORQ DX, DX + XORQ DI, DI + MOVQ R11, R12 + SHRQ $8, R11 + MOVQ R12, AX + MOVQ R11, CX + SHRQ $16, R12 + SHRQ $16, R11 + MOVQ R12, SI + + // CRC32 EAX, EBX + BYTE $0xF2; BYTE $0x0f + BYTE $0x38; BYTE $0xf1; BYTE $0xd8 + + // CRC32 ECX, EDX + BYTE $0xF2; BYTE $0x0f + BYTE $0x38; BYTE $0xf1; BYTE $0xd1 + + // CRC32 ESI, EDI + BYTE $0xF2; BYTE $0x0f + BYTE $0x38; BYTE $0xf1; BYTE $0xfe + MOVL BX, (R9) + MOVL DX, 4(R9) + MOVL DI, 8(R9) + + XORQ BX, BX + MOVL R11, AX + + // CRC32 EAX, EBX + BYTE $0xF2; BYTE $0x0f + BYTE $0x38; BYTE $0xf1; BYTE $0xd8 + MOVL BX, 12(R9) + + ADDQ $16, R9 + ADDQ $4, R8 + XORQ BX, BX + SUBQ $1, R10 + JNZ crc_loop + +rem_loop: + MOVL (R8), AX + + // CRC32 EAX, EBX + BYTE $0xF2; BYTE $0x0f + BYTE $0x38; BYTE $0xf1; BYTE $0xd8 + + MOVL BX, (R9) + ADDQ $4, R9 + ADDQ $1, R8 + XORQ BX, BX + SUBQ $1, R13 + JNZ rem_loop + +end: + RET + +one_crc: + MOVQ $1, R13 + XORQ BX, BX + JMP rem_loop + +// func matchLenSSE4(a, b []byte, max int) int +TEXT ·matchLenSSE4(SB), 7, $0 + MOVQ a+0(FP), SI // RSI: &a + MOVQ b+24(FP), DI // RDI: &b + MOVQ max+48(FP), R10 // R10: max + XORQ R11, R11 // R11: match length + MOVQ R10, R12 // R12: Remainder + SHRQ $4, R10 // max / 16 + MOVQ $16, AX // Set length for PCMPESTRI + MOVQ $16, DX // Set length for PCMPESTRI + ANDQ $15, R12 // max & 15 + TESTQ R10, R10 + JZ matchlen_verysmall + +loopback_matchlen: + MOVOU (SI), X0 // a[x] + MOVOU (DI), X1 // b[x] + + // PCMPESTRI $0x18, X1, X0 + // 0x18 = _SIDD_UBYTE_OPS (0x0) | _SIDD_CMP_EQUAL_EACH (0x8) | _SIDD_NEGATIVE_POLARITY (0x10) + BYTE $0x66; BYTE $0x0f; BYTE $0x3a + BYTE $0x61; BYTE $0xc1; BYTE $0x18 + + JC match_ended + + ADDQ $16, SI + ADDQ $16, DI + ADDQ $16, R11 + + SUBQ $1, R10 + JNZ loopback_matchlen + + // Check the remainder using REP CMPSB +matchlen_verysmall: + TESTQ R12, R12 + JZ done_matchlen + MOVQ R12, CX + ADDQ R12, R11 + + // Compare CX bytes at [SI] [DI] + // Subtract one from CX for every match. + // Terminates when CX is zero (checked pre-compare) + CLD + REP; CMPSB + + // Check if last was a match. + JZ done_matchlen + + // Subtract remanding bytes. + SUBQ CX, R11 + SUBQ $1, R11 + MOVQ R11, ret+56(FP) + RET + +match_ended: + ADDQ CX, R11 + +done_matchlen: + MOVQ R11, ret+56(FP) + RET + +// func histogram(b []byte, h []int32) +TEXT ·histogram(SB), 7, $0 + MOVQ b+0(FP), SI // SI: &b + MOVQ b_len+8(FP), R9 // R9: len(b) + MOVQ h+24(FP), DI // DI: Histogram + MOVQ R9, R8 + SHRQ $3, R8 + JZ hist1 + XORQ R11, R11 + +loop_hist8: + MOVQ (SI), R10 + + MOVB R10, R11 + INCL (DI)(R11*4) + SHRQ $8, R10 + + MOVB R10, R11 + INCL (DI)(R11*4) + SHRQ $8, R10 + + MOVB R10, R11 + INCL (DI)(R11*4) + SHRQ $8, R10 + + MOVB R10, R11 + INCL (DI)(R11*4) + SHRQ $8, R10 + + MOVB R10, R11 + INCL (DI)(R11*4) + SHRQ $8, R10 + + MOVB R10, R11 + INCL (DI)(R11*4) + SHRQ $8, R10 + + MOVB R10, R11 + INCL (DI)(R11*4) + SHRQ $8, R10 + + INCL (DI)(R10*4) + + ADDQ $8, SI + DECQ R8 + JNZ loop_hist8 + +hist1: + ANDQ $7, R9 + JZ end_hist + XORQ R10, R10 + +loop_hist1: + MOVB (SI), R10 + INCL (DI)(R10*4) + INCQ SI + DECQ R9 + JNZ loop_hist1 + +end_hist: + RET diff --git a/Godeps/_workspace/src/github.com/klauspost/compress/flate/crc32_noasm.go b/Godeps/_workspace/src/github.com/klauspost/compress/flate/crc32_noasm.go new file mode 100644 index 0000000000..1c6d23eed6 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/compress/flate/crc32_noasm.go @@ -0,0 +1,34 @@ +//+build !amd64 noasm appengine + +// Copyright 2015, Klaus Post, see LICENSE for details. + +package flate + +func init() { + useSSE42 = false +} + +// crc32sse should never be called. +func crc32sse(a []byte) hash { + panic("no assembler") +} + +// crc32sseAll should never be called. +func crc32sseAll(a []byte, dst []hash) { + panic("no assembler") +} + +// matchLenSSE4 should never be called. +func matchLenSSE4(a, b []byte, max int) int { + panic("no assembler") + return 0 +} + +// histogram accumulates a histogram of b in h. +// h must be at least 256 entries in length, +// and must be cleared before calling this function. +func histogram(b []byte, h []int32) { + for _, t := range b { + h[t]++ + } +} diff --git a/Godeps/_workspace/src/github.com/klauspost/compress/flate/deflate.go b/Godeps/_workspace/src/github.com/klauspost/compress/flate/deflate.go new file mode 100644 index 0000000000..b1efa677a5 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/compress/flate/deflate.go @@ -0,0 +1,1358 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Copyright (c) 2015 Klaus Post +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package flate + +import ( + "fmt" + "io" + "math" +) + +const ( + NoCompression = 0 + BestSpeed = 1 + BestCompression = 9 + DefaultCompression = -1 + ConstantCompression = -2 // Does only Huffman encoding + logWindowSize = 15 + windowSize = 1 << logWindowSize + windowMask = windowSize - 1 + logMaxOffsetSize = 15 // Standard DEFLATE + minMatchLength = 4 // The smallest match that the compressor looks for + maxMatchLength = 258 // The longest match for the compressor + minOffsetSize = 1 // The shortest offset that makes any sense + + // The maximum number of tokens we put into a single flat block, just too + // stop things from getting too large. + maxFlateBlockTokens = 1 << 14 + maxStoreBlockSize = 65535 + hashBits = 17 // After 17 performance degrades + hashSize = 1 << hashBits + hashMask = (1 << hashBits) - 1 + hashShift = (hashBits + minMatchLength - 1) / minMatchLength + maxHashOffset = 1 << 24 + + skipNever = math.MaxInt32 +) + +var useSSE42 bool + +type compressionLevel struct { + good, lazy, nice, chain, fastSkipHashing, level int +} + +// Compression levels have been rebalanced from zlib deflate defaults +// to give a bigger spread in speed and compression. +// See https://blog.klauspost.com/rebalancing-deflate-compression-levels/ +var levels = []compressionLevel{ + {}, // 0 + // Level 1+2 uses snappy algorithm - values not used + {0, 0, 0, 0, 0, 1}, + {0, 0, 0, 0, 0, 2}, + // For levels 3-6 we don't bother trying with lazy matches. + // Lazy matching is at least 30% slower, with 1.5% increase. + {4, 0, 8, 4, 4, 3}, + {4, 0, 12, 6, 5, 4}, + {6, 0, 24, 16, 6, 5}, + {8, 0, 32, 32, 7, 6}, + // Levels 7-9 use increasingly more lazy matching + // and increasingly stringent conditions for "good enough". + {4, 8, 16, 16, skipNever, 7}, + {6, 16, 32, 64, skipNever, 8}, + {32, 258, 258, 4096, skipNever, 9}, +} + +type hashid uint32 + +type compressor struct { + compressionLevel + + w *huffmanBitWriter + bulkHasher func([]byte, []hash) + + // compression algorithm + fill func(*compressor, []byte) int // copy data to window + step func(*compressor) // process window + sync bool // requesting flush + + // Input hash chains + // hashHead[hashValue] contains the largest inputIndex with the specified hash value + // If hashHead[hashValue] is within the current window, then + // hashPrev[hashHead[hashValue] & windowMask] contains the previous index + // with the same hash value. + chainHead int + hashHead []hashid + hashPrev []hashid + hashOffset int + + // input window: unprocessed data is window[index:windowEnd] + index int + window []byte + windowEnd int + blockStart int // window index where current tokens start + byteAvailable bool // if true, still need to process window[index-1]. + + // queued output tokens + tokens tokens + + // deflate state + length int + offset int + hash hash + maxInsertIndex int + err error + ii uint16 // position of last match, intended to overflow to reset. + + snap snappyEnc + hashMatch [maxMatchLength + minMatchLength]hash +} + +type hash int32 + +func (d *compressor) fillDeflate(b []byte) int { + if d.index >= 2*windowSize-(minMatchLength+maxMatchLength) { + // shift the window by windowSize + copy(d.window, d.window[windowSize:2*windowSize]) + d.index -= windowSize + d.windowEnd -= windowSize + if d.blockStart >= windowSize { + d.blockStart -= windowSize + } else { + d.blockStart = math.MaxInt32 + } + d.hashOffset += windowSize + if d.hashOffset > maxHashOffset { + delta := d.hashOffset - 1 + d.hashOffset -= delta + d.chainHead -= delta + for i, v := range d.hashPrev { + if int(v) > delta { + d.hashPrev[i] = hashid(int(v) - delta) + } else { + d.hashPrev[i] = 0 + } + } + for i, v := range d.hashHead { + if int(v) > delta { + d.hashHead[i] = hashid(int(v) - delta) + } else { + d.hashHead[i] = 0 + } + } + } + } + n := copy(d.window[d.windowEnd:], b) + d.windowEnd += n + return n +} + +func (d *compressor) writeBlock(tok tokens, index int, eof bool) error { + if index > 0 || eof { + var window []byte + if d.blockStart <= index { + window = d.window[d.blockStart:index] + } + d.blockStart = index + d.w.writeBlock(tok, eof, window) + return d.w.err + } + return nil +} + +// writeBlockSkip writes the current block and uses the number of tokens +// to determine if the block should be stored on no matches, or +// only huffman encoded. +func (d *compressor) writeBlockSkip(tok tokens, index int, eof bool) error { + if index > 0 || eof { + if d.blockStart <= index { + window := d.window[d.blockStart:index] + if tok.n == len(window) && !eof { + d.writeStoredBlock(window) + // If we removed less than 10 literals, huffman compress the block. + } else if tok.n > len(window)-10 { + d.w.writeBlockHuff(eof, window) + } else { + // Write a dynamic huffman block. + d.w.writeBlockDynamic(tok, eof, window) + } + } else { + d.w.writeBlock(tok, eof, nil) + } + d.blockStart = index + return d.w.err + } + return nil +} + +// fillWindow will fill the current window with the supplied +// dictionary and calculate all hashes. +// This is much faster than doing a full encode. +// Should only be used after a start/reset. +func (d *compressor) fillWindow(b []byte) { + // Do not fill window if we are in store-only mode, + // use constant or Snappy compression. + switch d.compressionLevel.level { + case 0, 1, 2: + return + } + // If we are given too much, cut it. + if len(b) > windowSize { + b = b[len(b)-windowSize:] + } + // Add all to window. + n := copy(d.window[d.windowEnd:], b) + + // Calculate 256 hashes at the time (more L1 cache hits) + loops := (n + 256 - minMatchLength) / 256 + for j := 0; j < loops; j++ { + startindex := j * 256 + end := startindex + 256 + minMatchLength - 1 + if end > n { + end = n + } + tocheck := d.window[startindex:end] + dstSize := len(tocheck) - minMatchLength + 1 + + if dstSize <= 0 { + continue + } + + dst := d.hashMatch[:dstSize] + d.bulkHasher(tocheck, dst) + var newH hash + for i, val := range dst { + di := i + startindex + newH = val & hashMask + // Get previous value with the same hash. + // Our chain should point to the previous value. + d.hashPrev[di&windowMask] = d.hashHead[newH] + // Set the head of the hash chain to us. + d.hashHead[newH] = hashid(di + d.hashOffset) + } + d.hash = newH + } + // Update window information. + d.windowEnd += n + d.index = n +} + +// Try to find a match starting at index whose length is greater than prevSize. +// We only look at chainCount possibilities before giving up. +// pos = d.index, prevHead = d.chainHead-d.hashOffset, prevLength=minMatchLength-1, lookahead +func (d *compressor) findMatch(pos int, prevHead int, prevLength int, lookahead int) (length, offset int, ok bool) { + minMatchLook := maxMatchLength + if lookahead < minMatchLook { + minMatchLook = lookahead + } + + win := d.window[0 : pos+minMatchLook] + + // We quit when we get a match that's at least nice long + nice := len(win) - pos + if d.nice < nice { + nice = d.nice + } + + // If we've got a match that's good enough, only look in 1/4 the chain. + tries := d.chain + length = prevLength + if length >= d.good { + tries >>= 2 + } + + wEnd := win[pos+length] + wPos := win[pos:] + minIndex := pos - windowSize + + for i := prevHead; tries > 0; tries-- { + if wEnd == win[i+length] { + n := matchLen(win[i:], wPos, minMatchLook) + + if n > length && (n > minMatchLength || pos-i <= 4096) { + length = n + offset = pos - i + ok = true + if n >= nice { + // The match is good enough that we don't try to find a better one. + break + } + wEnd = win[pos+n] + } + } + if i == minIndex { + // hashPrev[i & windowMask] has already been overwritten, so stop now. + break + } + i = int(d.hashPrev[i&windowMask]) - d.hashOffset + if i < minIndex || i < 0 { + break + } + } + return +} + +// Try to find a match starting at index whose length is greater than prevSize. +// We only look at chainCount possibilities before giving up. +// pos = d.index, prevHead = d.chainHead-d.hashOffset, prevLength=minMatchLength-1, lookahead +func (d *compressor) findMatchSSE(pos int, prevHead int, prevLength int, lookahead int) (length, offset int, ok bool) { + minMatchLook := maxMatchLength + if lookahead < minMatchLook { + minMatchLook = lookahead + } + + win := d.window[0 : pos+minMatchLook] + + // We quit when we get a match that's at least nice long + nice := len(win) - pos + if d.nice < nice { + nice = d.nice + } + + // If we've got a match that's good enough, only look in 1/4 the chain. + tries := d.chain + length = prevLength + if length >= d.good { + tries >>= 2 + } + + wEnd := win[pos+length] + wPos := win[pos:] + minIndex := pos - windowSize + + for i := prevHead; tries > 0; tries-- { + if wEnd == win[i+length] { + n := matchLenSSE4(win[i:], wPos, minMatchLook) + + if n > length && (n > minMatchLength || pos-i <= 4096) { + length = n + offset = pos - i + ok = true + if n >= nice { + // The match is good enough that we don't try to find a better one. + break + } + wEnd = win[pos+n] + } + } + if i == minIndex { + // hashPrev[i & windowMask] has already been overwritten, so stop now. + break + } + i = int(d.hashPrev[i&windowMask]) - d.hashOffset + if i < minIndex || i < 0 { + break + } + } + return +} + +func (d *compressor) writeStoredBlock(buf []byte) error { + if d.w.writeStoredHeader(len(buf), false); d.w.err != nil { + return d.w.err + } + d.w.writeBytes(buf) + return d.w.err +} + +// oldHash is the hash function used when no native crc32 calculation +// or similar is present. +func oldHash(b []byte) hash { + return hash(b[0])<<(hashShift*3) + hash(b[1])<<(hashShift*2) + hash(b[2])< d.windowEnd { + panic("index > windowEnd") + } + lookahead := d.windowEnd - d.index + if lookahead < minMatchLength+maxMatchLength { + if !d.sync { + return + } + if sanity && d.index > d.windowEnd { + panic("index > windowEnd") + } + if lookahead == 0 { + if d.tokens.n > 0 { + if d.err = d.writeBlockSkip(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + return + } + } + if d.index < d.maxInsertIndex { + // Update the hash + d.hash = oldHash(d.window[d.index:d.index+minMatchLength]) & hashMask + ch := d.hashHead[d.hash] + d.chainHead = int(ch) + d.hashPrev[d.index&windowMask] = ch + d.hashHead[d.hash] = hashid(d.index + d.hashOffset) + } + d.length = minMatchLength - 1 + d.offset = 0 + minIndex := d.index - windowSize + if minIndex < 0 { + minIndex = 0 + } + + if d.chainHead-d.hashOffset >= minIndex && lookahead > minMatchLength-1 { + if newLength, newOffset, ok := d.findMatch(d.index, d.chainHead-d.hashOffset, minMatchLength-1, lookahead); ok { + d.length = newLength + d.offset = newOffset + } + } + if d.length >= minMatchLength { + d.ii = 0 + // There was a match at the previous step, and the current match is + // not better. Output the previous match. + // "d.length-3" should NOT be "d.length-minMatchLength", since the format always assume 3 + d.tokens.tokens[d.tokens.n] = matchToken(uint32(d.length-3), uint32(d.offset-minOffsetSize)) + d.tokens.n++ + // Insert in the hash table all strings up to the end of the match. + // index and index-1 are already inserted. If there is not enough + // lookahead, the last two strings are not inserted into the hash + // table. + if d.length <= d.fastSkipHashing { + var newIndex int + newIndex = d.index + d.length + // Calculate missing hashes + end := newIndex + if end > d.maxInsertIndex { + end = d.maxInsertIndex + } + end += minMatchLength - 1 + startindex := d.index + 1 + if startindex > d.maxInsertIndex { + startindex = d.maxInsertIndex + } + tocheck := d.window[startindex:end] + dstSize := len(tocheck) - minMatchLength + 1 + if dstSize > 0 { + dst := d.hashMatch[:dstSize] + oldBulkHash(tocheck, dst) + var newH hash + for i, val := range dst { + di := i + startindex + newH = val & hashMask + // Get previous value with the same hash. + // Our chain should point to the previous value. + d.hashPrev[di&windowMask] = d.hashHead[newH] + // Set the head of the hash chain to us. + d.hashHead[newH] = hashid(di + d.hashOffset) + } + d.hash = newH + } + d.index = newIndex + } else { + // For matches this long, we don't bother inserting each individual + // item into the table. + d.index += d.length + if d.index < d.maxInsertIndex { + d.hash = oldHash(d.window[d.index:d.index+minMatchLength]) & hashMask + } + } + if d.tokens.n == maxFlateBlockTokens { + // The block includes the current character + if d.err = d.writeBlockSkip(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + } else { + d.ii++ + end := d.index + int(d.ii>>uint(d.fastSkipHashing)) + 1 + if end > d.windowEnd { + end = d.windowEnd + } + for i := d.index; i < end; i++ { + d.tokens.tokens[d.tokens.n] = literalToken(uint32(d.window[i])) + d.tokens.n++ + if d.tokens.n == maxFlateBlockTokens { + if d.err = d.writeBlockSkip(d.tokens, i+1, false); d.err != nil { + return + } + d.tokens.n = 0 + } + } + d.index = end + } + } +} + +// deflateLazy is the same as deflate, but with d.fastSkipHashing == skipNever, +// meaning it always has lazy matching on. +func (d *compressor) deflateLazy() { + // Sanity enables additional runtime tests. + // It's intended to be used during development + // to supplement the currently ad-hoc unit tests. + const sanity = false + + if d.windowEnd-d.index < minMatchLength+maxMatchLength && !d.sync { + return + } + + d.maxInsertIndex = d.windowEnd - (minMatchLength - 1) + if d.index < d.maxInsertIndex { + d.hash = oldHash(d.window[d.index:d.index+minMatchLength]) & hashMask + } + + for { + if sanity && d.index > d.windowEnd { + panic("index > windowEnd") + } + lookahead := d.windowEnd - d.index + if lookahead < minMatchLength+maxMatchLength { + if !d.sync { + return + } + if sanity && d.index > d.windowEnd { + panic("index > windowEnd") + } + if lookahead == 0 { + // Flush current output block if any. + if d.byteAvailable { + // There is still one pending token that needs to be flushed + d.tokens.tokens[d.tokens.n] = literalToken(uint32(d.window[d.index-1])) + d.tokens.n++ + d.byteAvailable = false + } + if d.tokens.n > 0 { + if d.err = d.writeBlock(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + return + } + } + if d.index < d.maxInsertIndex { + // Update the hash + d.hash = oldHash(d.window[d.index:d.index+minMatchLength]) & hashMask + ch := d.hashHead[d.hash] + d.chainHead = int(ch) + d.hashPrev[d.index&windowMask] = ch + d.hashHead[d.hash] = hashid(d.index + d.hashOffset) + } + prevLength := d.length + prevOffset := d.offset + d.length = minMatchLength - 1 + d.offset = 0 + minIndex := d.index - windowSize + if minIndex < 0 { + minIndex = 0 + } + + if d.chainHead-d.hashOffset >= minIndex && lookahead > prevLength && prevLength < d.lazy { + if newLength, newOffset, ok := d.findMatch(d.index, d.chainHead-d.hashOffset, minMatchLength-1, lookahead); ok { + d.length = newLength + d.offset = newOffset + } + } + if prevLength >= minMatchLength && d.length <= prevLength { + // There was a match at the previous step, and the current match is + // not better. Output the previous match. + d.tokens.tokens[d.tokens.n] = matchToken(uint32(prevLength-3), uint32(prevOffset-minOffsetSize)) + d.tokens.n++ + + // Insert in the hash table all strings up to the end of the match. + // index and index-1 are already inserted. If there is not enough + // lookahead, the last two strings are not inserted into the hash + // table. + var newIndex int + newIndex = d.index + prevLength - 1 + // Calculate missing hashes + end := newIndex + if end > d.maxInsertIndex { + end = d.maxInsertIndex + } + end += minMatchLength - 1 + startindex := d.index + 1 + if startindex > d.maxInsertIndex { + startindex = d.maxInsertIndex + } + tocheck := d.window[startindex:end] + dstSize := len(tocheck) - minMatchLength + 1 + if dstSize > 0 { + dst := d.hashMatch[:dstSize] + oldBulkHash(tocheck, dst) + var newH hash + for i, val := range dst { + di := i + startindex + newH = val & hashMask + // Get previous value with the same hash. + // Our chain should point to the previous value. + d.hashPrev[di&windowMask] = d.hashHead[newH] + // Set the head of the hash chain to us. + d.hashHead[newH] = hashid(di + d.hashOffset) + } + d.hash = newH + } + + d.index = newIndex + d.byteAvailable = false + d.length = minMatchLength - 1 + if d.tokens.n == maxFlateBlockTokens { + // The block includes the current character + if d.err = d.writeBlock(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + } else { + // Reset, if we got a match this run. + if d.length >= minMatchLength { + d.ii = 0 + } + // We have a byte waiting. Emit it. + if d.byteAvailable { + d.ii++ + d.tokens.tokens[d.tokens.n] = literalToken(uint32(d.window[d.index-1])) + d.tokens.n++ + if d.tokens.n == maxFlateBlockTokens { + if d.err = d.writeBlock(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + d.index++ + + // If we have a long run of no matches, skip additional bytes + // Resets when d.ii overflows after 64KB. + if d.ii > 31 { + n := int(d.ii >> 6) + for j := 0; j < n; j++ { + if d.index >= d.windowEnd-1 { + break + } + + d.tokens.tokens[d.tokens.n] = literalToken(uint32(d.window[d.index-1])) + d.tokens.n++ + if d.tokens.n == maxFlateBlockTokens { + if d.err = d.writeBlock(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + d.index++ + } + // Flush last byte + d.tokens.tokens[d.tokens.n] = literalToken(uint32(d.window[d.index-1])) + d.tokens.n++ + d.byteAvailable = false + // d.length = minMatchLength - 1 // not needed, since d.ii is reset above, so it should never be > minMatchLength + if d.tokens.n == maxFlateBlockTokens { + if d.err = d.writeBlock(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + } + } else { + d.index++ + d.byteAvailable = true + } + } + } +} + +// Assumes that d.fastSkipHashing != skipNever, +// otherwise use deflateLazySSE +func (d *compressor) deflateSSE() { + + // Sanity enables additional runtime tests. + // It's intended to be used during development + // to supplement the currently ad-hoc unit tests. + const sanity = false + + if d.windowEnd-d.index < minMatchLength+maxMatchLength && !d.sync { + return + } + + d.maxInsertIndex = d.windowEnd - (minMatchLength - 1) + if d.index < d.maxInsertIndex { + d.hash = oldHash(d.window[d.index:d.index+minMatchLength]) & hashMask + } + + for { + if sanity && d.index > d.windowEnd { + panic("index > windowEnd") + } + lookahead := d.windowEnd - d.index + if lookahead < minMatchLength+maxMatchLength { + if !d.sync { + return + } + if sanity && d.index > d.windowEnd { + panic("index > windowEnd") + } + if lookahead == 0 { + if d.tokens.n > 0 { + if d.err = d.writeBlockSkip(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + return + } + } + if d.index < d.maxInsertIndex { + // Update the hash + d.hash = crc32sse(d.window[d.index:d.index+minMatchLength]) & hashMask + ch := d.hashHead[d.hash] + d.chainHead = int(ch) + d.hashPrev[d.index&windowMask] = ch + d.hashHead[d.hash] = hashid(d.index + d.hashOffset) + } + d.length = minMatchLength - 1 + d.offset = 0 + minIndex := d.index - windowSize + if minIndex < 0 { + minIndex = 0 + } + + if d.chainHead-d.hashOffset >= minIndex && lookahead > minMatchLength-1 { + if newLength, newOffset, ok := d.findMatchSSE(d.index, d.chainHead-d.hashOffset, minMatchLength-1, lookahead); ok { + d.length = newLength + d.offset = newOffset + } + } + if d.length >= minMatchLength { + d.ii = 0 + // There was a match at the previous step, and the current match is + // not better. Output the previous match. + // "d.length-3" should NOT be "d.length-minMatchLength", since the format always assume 3 + d.tokens.tokens[d.tokens.n] = matchToken(uint32(d.length-3), uint32(d.offset-minOffsetSize)) + d.tokens.n++ + // Insert in the hash table all strings up to the end of the match. + // index and index-1 are already inserted. If there is not enough + // lookahead, the last two strings are not inserted into the hash + // table. + if d.length <= d.fastSkipHashing { + var newIndex int + newIndex = d.index + d.length + // Calculate missing hashes + end := newIndex + if end > d.maxInsertIndex { + end = d.maxInsertIndex + } + end += minMatchLength - 1 + startindex := d.index + 1 + if startindex > d.maxInsertIndex { + startindex = d.maxInsertIndex + } + tocheck := d.window[startindex:end] + dstSize := len(tocheck) - minMatchLength + 1 + if dstSize > 0 { + dst := d.hashMatch[:dstSize] + + crc32sseAll(tocheck, dst) + var newH hash + for i, val := range dst { + di := i + startindex + newH = val & hashMask + // Get previous value with the same hash. + // Our chain should point to the previous value. + d.hashPrev[di&windowMask] = d.hashHead[newH] + // Set the head of the hash chain to us. + d.hashHead[newH] = hashid(di + d.hashOffset) + } + d.hash = newH + } + d.index = newIndex + } else { + // For matches this long, we don't bother inserting each individual + // item into the table. + d.index += d.length + if d.index < d.maxInsertIndex { + d.hash = crc32sse(d.window[d.index:d.index+minMatchLength]) & hashMask + } + } + if d.tokens.n == maxFlateBlockTokens { + // The block includes the current character + if d.err = d.writeBlockSkip(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + } else { + d.ii++ + end := d.index + int(d.ii>>uint(d.fastSkipHashing)) + 1 + if end > d.windowEnd { + end = d.windowEnd + } + for i := d.index; i < end; i++ { + d.tokens.tokens[d.tokens.n] = literalToken(uint32(d.window[i])) + d.tokens.n++ + if d.tokens.n == maxFlateBlockTokens { + if d.err = d.writeBlockSkip(d.tokens, i+1, false); d.err != nil { + return + } + d.tokens.n = 0 + } + } + d.index = end + } + } +} + +// deflateLazy is the same as deflate, but with d.fastSkipHashing == skipNever, +// meaning it always has lazy matching on. +func (d *compressor) deflateLazySSE() { + // Sanity enables additional runtime tests. + // It's intended to be used during development + // to supplement the currently ad-hoc unit tests. + const sanity = false + + if d.windowEnd-d.index < minMatchLength+maxMatchLength && !d.sync { + return + } + + d.maxInsertIndex = d.windowEnd - (minMatchLength - 1) + if d.index < d.maxInsertIndex { + d.hash = crc32sse(d.window[d.index:d.index+minMatchLength]) & hashMask + } + + for { + if sanity && d.index > d.windowEnd { + panic("index > windowEnd") + } + lookahead := d.windowEnd - d.index + if lookahead < minMatchLength+maxMatchLength { + if !d.sync { + return + } + if sanity && d.index > d.windowEnd { + panic("index > windowEnd") + } + if lookahead == 0 { + // Flush current output block if any. + if d.byteAvailable { + // There is still one pending token that needs to be flushed + d.tokens.tokens[d.tokens.n] = literalToken(uint32(d.window[d.index-1])) + d.tokens.n++ + d.byteAvailable = false + } + if d.tokens.n > 0 { + if d.err = d.writeBlock(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + return + } + } + if d.index < d.maxInsertIndex { + // Update the hash + d.hash = crc32sse(d.window[d.index:d.index+minMatchLength]) & hashMask + ch := d.hashHead[d.hash] + d.chainHead = int(ch) + d.hashPrev[d.index&windowMask] = ch + d.hashHead[d.hash] = hashid(d.index + d.hashOffset) + } + prevLength := d.length + prevOffset := d.offset + d.length = minMatchLength - 1 + d.offset = 0 + minIndex := d.index - windowSize + if minIndex < 0 { + minIndex = 0 + } + + if d.chainHead-d.hashOffset >= minIndex && lookahead > prevLength && prevLength < d.lazy { + if newLength, newOffset, ok := d.findMatchSSE(d.index, d.chainHead-d.hashOffset, minMatchLength-1, lookahead); ok { + d.length = newLength + d.offset = newOffset + } + } + if prevLength >= minMatchLength && d.length <= prevLength { + // There was a match at the previous step, and the current match is + // not better. Output the previous match. + d.tokens.tokens[d.tokens.n] = matchToken(uint32(prevLength-3), uint32(prevOffset-minOffsetSize)) + d.tokens.n++ + + // Insert in the hash table all strings up to the end of the match. + // index and index-1 are already inserted. If there is not enough + // lookahead, the last two strings are not inserted into the hash + // table. + var newIndex int + newIndex = d.index + prevLength - 1 + // Calculate missing hashes + end := newIndex + if end > d.maxInsertIndex { + end = d.maxInsertIndex + } + end += minMatchLength - 1 + startindex := d.index + 1 + if startindex > d.maxInsertIndex { + startindex = d.maxInsertIndex + } + tocheck := d.window[startindex:end] + dstSize := len(tocheck) - minMatchLength + 1 + if dstSize > 0 { + dst := d.hashMatch[:dstSize] + crc32sseAll(tocheck, dst) + var newH hash + for i, val := range dst { + di := i + startindex + newH = val & hashMask + // Get previous value with the same hash. + // Our chain should point to the previous value. + d.hashPrev[di&windowMask] = d.hashHead[newH] + // Set the head of the hash chain to us. + d.hashHead[newH] = hashid(di + d.hashOffset) + } + d.hash = newH + } + + d.index = newIndex + d.byteAvailable = false + d.length = minMatchLength - 1 + if d.tokens.n == maxFlateBlockTokens { + // The block includes the current character + if d.err = d.writeBlock(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + } else { + // Reset, if we got a match this run. + if d.length >= minMatchLength { + d.ii = 0 + } + // We have a byte waiting. Emit it. + if d.byteAvailable { + d.ii++ + d.tokens.tokens[d.tokens.n] = literalToken(uint32(d.window[d.index-1])) + d.tokens.n++ + if d.tokens.n == maxFlateBlockTokens { + if d.err = d.writeBlock(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + d.index++ + + // If we have a long run of no matches, skip additional bytes + // Resets when d.ii overflows after 64KB. + if d.ii > 31 { + n := int(d.ii >> 6) + for j := 0; j < n; j++ { + if d.index >= d.windowEnd-1 { + break + } + + d.tokens.tokens[d.tokens.n] = literalToken(uint32(d.window[d.index-1])) + d.tokens.n++ + if d.tokens.n == maxFlateBlockTokens { + if d.err = d.writeBlock(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + d.index++ + } + // Flush last byte + d.tokens.tokens[d.tokens.n] = literalToken(uint32(d.window[d.index-1])) + d.tokens.n++ + d.byteAvailable = false + // d.length = minMatchLength - 1 // not needed, since d.ii is reset above, so it should never be > minMatchLength + if d.tokens.n == maxFlateBlockTokens { + if d.err = d.writeBlock(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + } + } else { + d.index++ + d.byteAvailable = true + } + } + } +} + +func (d *compressor) fillStore(b []byte) int { + n := copy(d.window[d.windowEnd:], b) + d.windowEnd += n + return n +} + +func (d *compressor) store() { + if d.windowEnd > 0 { + d.err = d.writeStoredBlock(d.window[:d.windowEnd]) + } + d.windowEnd = 0 +} + +// fillHuff will fill the buffer with data for huffman-only compression. +// The number of bytes copied is returned. +func (d *compressor) fillHuff(b []byte) int { + n := copy(d.window[d.windowEnd:], b) + d.windowEnd += n + return n +} + +// storeHuff will compress and store the currently added data, +// if enough has been accumulated or we at the end of the stream. +// Any error that occurred will be in d.err +func (d *compressor) storeHuff() { + // We only compress if we have maxStoreBlockSize or we are at end-of-stream + if d.windowEnd < maxStoreBlockSize && !d.sync { + return + } + if d.windowEnd == 0 { + return + } + d.w.writeBlockHuff(false, d.window[:d.windowEnd]) + d.err = d.w.err + d.windowEnd = 0 +} + +// storeHuff will compress and store the currently added data, +// if enough has been accumulated or we at the end of the stream. +// Any error that occurred will be in d.err +func (d *compressor) storeSnappy() { + // We only compress if we have maxStoreBlockSize. + if d.windowEnd < maxStoreBlockSize { + if !d.sync { + return + } + // Handle extremely small sizes. + if d.windowEnd < 128 { + if d.windowEnd == 0 { + return + } + if d.windowEnd <= 32 { + d.err = d.writeStoredBlock(d.window[:d.windowEnd]) + d.tokens.n = 0 + d.windowEnd = 0 + } else { + d.w.writeBlockHuff(false, d.window[:d.windowEnd]) + d.err = d.w.err + } + d.tokens.n = 0 + d.windowEnd = 0 + return + } + } + + d.snap.Encode(&d.tokens, d.window[:d.windowEnd]) + // If we made zero matches, store the block as is. + if d.tokens.n == d.windowEnd { + d.err = d.writeStoredBlock(d.window[:d.windowEnd]) + // If we removed less than 1/16th, huffman compress the block. + } else if d.tokens.n > d.windowEnd-(d.windowEnd>>4) { + d.w.writeBlockHuff(false, d.window[:d.windowEnd]) + d.err = d.w.err + } else { + d.w.writeBlockDynamic(d.tokens, false, d.window[:d.windowEnd]) + d.err = d.w.err + } + d.tokens.n = 0 + d.windowEnd = 0 +} + +// write will add input byte to the stream. +// Unless an error occurs all bytes will be consumed. +func (d *compressor) write(b []byte) (n int, err error) { + if d.err != nil { + return 0, d.err + } + n = len(b) + for len(b) > 0 { + d.step(d) + b = b[d.fill(d, b):] + if d.err != nil { + return 0, d.err + } + } + return n, d.err +} + +func (d *compressor) syncFlush() error { + d.sync = true + if d.err != nil { + return d.err + } + d.step(d) + if d.err == nil { + d.w.writeStoredHeader(0, false) + d.w.flush() + d.err = d.w.err + } + d.sync = false + return d.err +} + +func (d *compressor) init(w io.Writer, level int) (err error) { + d.w = newHuffmanBitWriter(w) + + switch { + case level == NoCompression: + d.window = make([]byte, maxStoreBlockSize) + d.fill = (*compressor).fillStore + d.step = (*compressor).store + case level == ConstantCompression: + d.window = make([]byte, maxStoreBlockSize) + d.fill = (*compressor).fillHuff + d.step = (*compressor).storeHuff + case level >= 1 && level <= 3: + d.snap = newSnappy(level) + d.window = make([]byte, maxStoreBlockSize) + d.fill = (*compressor).fillHuff + d.step = (*compressor).storeSnappy + d.tokens.tokens = make([]token, maxStoreBlockSize+1) + case level == DefaultCompression: + level = 5 + fallthrough + case 4 <= level && level <= 9: + d.compressionLevel = levels[level] + d.initDeflate() + d.fill = (*compressor).fillDeflate + if d.fastSkipHashing == skipNever { + if useSSE42 { + d.step = (*compressor).deflateLazySSE + } else { + d.step = (*compressor).deflateLazy + } + } else { + if useSSE42 { + d.step = (*compressor).deflateSSE + } else { + d.step = (*compressor).deflate + + } + } + default: + return fmt.Errorf("flate: invalid compression level %d: want value in range [-2, 9]", level) + } + return nil +} + +// Used for zeroing the hash slice +var hzeroes [256]hashid + +// reset the state of the compressor. +func (d *compressor) reset(w io.Writer) { + d.w.reset(w) + d.sync = false + d.err = nil + // We only need to reset a few things for Snappy. + if d.snap != nil { + d.snap.Reset() + d.windowEnd = 0 + d.tokens.n = 0 + return + } + switch d.compressionLevel.chain { + case 0: + // level was NoCompression or ConstantCompresssion. + d.windowEnd = 0 + default: + d.chainHead = -1 + for s := d.hashHead; len(s) > 0; { + n := copy(s, hzeroes[:]) + s = s[n:] + } + for s := d.hashPrev; len(s) > 0; s = s[len(hzeroes):] { + copy(s, hzeroes[:]) + } + d.hashOffset = 1 + + d.index, d.windowEnd = 0, 0 + d.blockStart, d.byteAvailable = 0, false + + d.tokens.n = 0 + d.length = minMatchLength - 1 + d.offset = 0 + d.hash = 0 + d.ii = 0 + d.maxInsertIndex = 0 + } +} + +func (d *compressor) close() error { + if d.err != nil { + return d.err + } + d.sync = true + d.step(d) + if d.err != nil { + return d.err + } + if d.w.writeStoredHeader(0, true); d.w.err != nil { + return d.w.err + } + d.w.flush() + return d.w.err +} + +// NewWriter returns a new Writer compressing data at the given level. +// Following zlib, levels range from 1 (BestSpeed) to 9 (BestCompression); +// higher levels typically run slower but compress more. +// Level 0 (NoCompression) does not attempt any compression; it only adds the +// necessary DEFLATE framing. +// Level -1 (DefaultCompression) uses the default compression level. +// Level -2 (ConstantCompression) will use Huffman compression only, giving +// a very fast compression for all types of input, but sacrificing considerable +// compression efficiency. +// +// If level is in the range [-2, 9] then the error returned will be nil. +// Otherwise the error returned will be non-nil. +func NewWriter(w io.Writer, level int) (*Writer, error) { + var dw Writer + if err := dw.d.init(w, level); err != nil { + return nil, err + } + return &dw, nil +} + +// NewWriterDict is like NewWriter but initializes the new +// Writer with a preset dictionary. The returned Writer behaves +// as if the dictionary had been written to it without producing +// any compressed output. The compressed data written to w +// can only be decompressed by a Reader initialized with the +// same dictionary. +func NewWriterDict(w io.Writer, level int, dict []byte) (*Writer, error) { + dw := &dictWriter{w} + zw, err := NewWriter(dw, level) + if err != nil { + return nil, err + } + zw.d.fillWindow(dict) + zw.dict = append(zw.dict, dict...) // duplicate dictionary for Reset method. + return zw, err +} + +type dictWriter struct { + w io.Writer +} + +func (w *dictWriter) Write(b []byte) (n int, err error) { + return w.w.Write(b) +} + +// A Writer takes data written to it and writes the compressed +// form of that data to an underlying writer (see NewWriter). +type Writer struct { + d compressor + dict []byte +} + +// Write writes data to w, which will eventually write the +// compressed form of data to its underlying writer. +func (w *Writer) Write(data []byte) (n int, err error) { + return w.d.write(data) +} + +// Flush flushes any pending compressed data to the underlying writer. +// It is useful mainly in compressed network protocols, to ensure that +// a remote reader has enough data to reconstruct a packet. +// Flush does not return until the data has been written. +// If the underlying writer returns an error, Flush returns that error. +// +// In the terminology of the zlib library, Flush is equivalent to Z_SYNC_FLUSH. +func (w *Writer) Flush() error { + // For more about flushing: + // http://www.bolet.org/~pornin/deflate-flush.html + return w.d.syncFlush() +} + +// Close flushes and closes the writer. +func (w *Writer) Close() error { + return w.d.close() +} + +// Reset discards the writer's state and makes it equivalent to +// the result of NewWriter or NewWriterDict called with dst +// and w's level and dictionary. +func (w *Writer) Reset(dst io.Writer) { + if dw, ok := w.d.w.w.(*dictWriter); ok { + // w was created with NewWriterDict + dw.w = dst + w.d.reset(dw) + w.d.fillWindow(w.dict) + } else { + // w was created with NewWriter + w.d.reset(dst) + } +} + +// ResetDict discards the writer's state and makes it equivalent to +// the result of NewWriter or NewWriterDict called with dst +// and w's level, but sets a specific dictionary. +func (w *Writer) ResetDict(dst io.Writer, dict []byte) { + w.dict = dict + w.d.reset(dst) + w.d.fillWindow(w.dict) +} diff --git a/Godeps/_workspace/src/github.com/klauspost/compress/flate/fixedhuff.go b/Godeps/_workspace/src/github.com/klauspost/compress/flate/fixedhuff.go new file mode 100644 index 0000000000..7df8b9a293 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/compress/flate/fixedhuff.go @@ -0,0 +1,78 @@ +// 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. + +package flate + +// autogenerated by go run gen.go -output fixedhuff.go, DO NOT EDIT + +var fixedHuffmanDecoder = huffmanDecoder{ + 7, + [huffmanNumChunks]uint32{ + 0x1007, 0x0508, 0x0108, 0x1188, 0x1107, 0x0708, 0x0308, 0x0c09, + 0x1087, 0x0608, 0x0208, 0x0a09, 0x0008, 0x0808, 0x0408, 0x0e09, + 0x1047, 0x0588, 0x0188, 0x0909, 0x1147, 0x0788, 0x0388, 0x0d09, + 0x10c7, 0x0688, 0x0288, 0x0b09, 0x0088, 0x0888, 0x0488, 0x0f09, + 0x1027, 0x0548, 0x0148, 0x11c8, 0x1127, 0x0748, 0x0348, 0x0c89, + 0x10a7, 0x0648, 0x0248, 0x0a89, 0x0048, 0x0848, 0x0448, 0x0e89, + 0x1067, 0x05c8, 0x01c8, 0x0989, 0x1167, 0x07c8, 0x03c8, 0x0d89, + 0x10e7, 0x06c8, 0x02c8, 0x0b89, 0x00c8, 0x08c8, 0x04c8, 0x0f89, + 0x1017, 0x0528, 0x0128, 0x11a8, 0x1117, 0x0728, 0x0328, 0x0c49, + 0x1097, 0x0628, 0x0228, 0x0a49, 0x0028, 0x0828, 0x0428, 0x0e49, + 0x1057, 0x05a8, 0x01a8, 0x0949, 0x1157, 0x07a8, 0x03a8, 0x0d49, + 0x10d7, 0x06a8, 0x02a8, 0x0b49, 0x00a8, 0x08a8, 0x04a8, 0x0f49, + 0x1037, 0x0568, 0x0168, 0x11e8, 0x1137, 0x0768, 0x0368, 0x0cc9, + 0x10b7, 0x0668, 0x0268, 0x0ac9, 0x0068, 0x0868, 0x0468, 0x0ec9, + 0x1077, 0x05e8, 0x01e8, 0x09c9, 0x1177, 0x07e8, 0x03e8, 0x0dc9, + 0x10f7, 0x06e8, 0x02e8, 0x0bc9, 0x00e8, 0x08e8, 0x04e8, 0x0fc9, + 0x1007, 0x0518, 0x0118, 0x1198, 0x1107, 0x0718, 0x0318, 0x0c29, + 0x1087, 0x0618, 0x0218, 0x0a29, 0x0018, 0x0818, 0x0418, 0x0e29, + 0x1047, 0x0598, 0x0198, 0x0929, 0x1147, 0x0798, 0x0398, 0x0d29, + 0x10c7, 0x0698, 0x0298, 0x0b29, 0x0098, 0x0898, 0x0498, 0x0f29, + 0x1027, 0x0558, 0x0158, 0x11d8, 0x1127, 0x0758, 0x0358, 0x0ca9, + 0x10a7, 0x0658, 0x0258, 0x0aa9, 0x0058, 0x0858, 0x0458, 0x0ea9, + 0x1067, 0x05d8, 0x01d8, 0x09a9, 0x1167, 0x07d8, 0x03d8, 0x0da9, + 0x10e7, 0x06d8, 0x02d8, 0x0ba9, 0x00d8, 0x08d8, 0x04d8, 0x0fa9, + 0x1017, 0x0538, 0x0138, 0x11b8, 0x1117, 0x0738, 0x0338, 0x0c69, + 0x1097, 0x0638, 0x0238, 0x0a69, 0x0038, 0x0838, 0x0438, 0x0e69, + 0x1057, 0x05b8, 0x01b8, 0x0969, 0x1157, 0x07b8, 0x03b8, 0x0d69, + 0x10d7, 0x06b8, 0x02b8, 0x0b69, 0x00b8, 0x08b8, 0x04b8, 0x0f69, + 0x1037, 0x0578, 0x0178, 0x11f8, 0x1137, 0x0778, 0x0378, 0x0ce9, + 0x10b7, 0x0678, 0x0278, 0x0ae9, 0x0078, 0x0878, 0x0478, 0x0ee9, + 0x1077, 0x05f8, 0x01f8, 0x09e9, 0x1177, 0x07f8, 0x03f8, 0x0de9, + 0x10f7, 0x06f8, 0x02f8, 0x0be9, 0x00f8, 0x08f8, 0x04f8, 0x0fe9, + 0x1007, 0x0508, 0x0108, 0x1188, 0x1107, 0x0708, 0x0308, 0x0c19, + 0x1087, 0x0608, 0x0208, 0x0a19, 0x0008, 0x0808, 0x0408, 0x0e19, + 0x1047, 0x0588, 0x0188, 0x0919, 0x1147, 0x0788, 0x0388, 0x0d19, + 0x10c7, 0x0688, 0x0288, 0x0b19, 0x0088, 0x0888, 0x0488, 0x0f19, + 0x1027, 0x0548, 0x0148, 0x11c8, 0x1127, 0x0748, 0x0348, 0x0c99, + 0x10a7, 0x0648, 0x0248, 0x0a99, 0x0048, 0x0848, 0x0448, 0x0e99, + 0x1067, 0x05c8, 0x01c8, 0x0999, 0x1167, 0x07c8, 0x03c8, 0x0d99, + 0x10e7, 0x06c8, 0x02c8, 0x0b99, 0x00c8, 0x08c8, 0x04c8, 0x0f99, + 0x1017, 0x0528, 0x0128, 0x11a8, 0x1117, 0x0728, 0x0328, 0x0c59, + 0x1097, 0x0628, 0x0228, 0x0a59, 0x0028, 0x0828, 0x0428, 0x0e59, + 0x1057, 0x05a8, 0x01a8, 0x0959, 0x1157, 0x07a8, 0x03a8, 0x0d59, + 0x10d7, 0x06a8, 0x02a8, 0x0b59, 0x00a8, 0x08a8, 0x04a8, 0x0f59, + 0x1037, 0x0568, 0x0168, 0x11e8, 0x1137, 0x0768, 0x0368, 0x0cd9, + 0x10b7, 0x0668, 0x0268, 0x0ad9, 0x0068, 0x0868, 0x0468, 0x0ed9, + 0x1077, 0x05e8, 0x01e8, 0x09d9, 0x1177, 0x07e8, 0x03e8, 0x0dd9, + 0x10f7, 0x06e8, 0x02e8, 0x0bd9, 0x00e8, 0x08e8, 0x04e8, 0x0fd9, + 0x1007, 0x0518, 0x0118, 0x1198, 0x1107, 0x0718, 0x0318, 0x0c39, + 0x1087, 0x0618, 0x0218, 0x0a39, 0x0018, 0x0818, 0x0418, 0x0e39, + 0x1047, 0x0598, 0x0198, 0x0939, 0x1147, 0x0798, 0x0398, 0x0d39, + 0x10c7, 0x0698, 0x0298, 0x0b39, 0x0098, 0x0898, 0x0498, 0x0f39, + 0x1027, 0x0558, 0x0158, 0x11d8, 0x1127, 0x0758, 0x0358, 0x0cb9, + 0x10a7, 0x0658, 0x0258, 0x0ab9, 0x0058, 0x0858, 0x0458, 0x0eb9, + 0x1067, 0x05d8, 0x01d8, 0x09b9, 0x1167, 0x07d8, 0x03d8, 0x0db9, + 0x10e7, 0x06d8, 0x02d8, 0x0bb9, 0x00d8, 0x08d8, 0x04d8, 0x0fb9, + 0x1017, 0x0538, 0x0138, 0x11b8, 0x1117, 0x0738, 0x0338, 0x0c79, + 0x1097, 0x0638, 0x0238, 0x0a79, 0x0038, 0x0838, 0x0438, 0x0e79, + 0x1057, 0x05b8, 0x01b8, 0x0979, 0x1157, 0x07b8, 0x03b8, 0x0d79, + 0x10d7, 0x06b8, 0x02b8, 0x0b79, 0x00b8, 0x08b8, 0x04b8, 0x0f79, + 0x1037, 0x0578, 0x0178, 0x11f8, 0x1137, 0x0778, 0x0378, 0x0cf9, + 0x10b7, 0x0678, 0x0278, 0x0af9, 0x0078, 0x0878, 0x0478, 0x0ef9, + 0x1077, 0x05f8, 0x01f8, 0x09f9, 0x1177, 0x07f8, 0x03f8, 0x0df9, + 0x10f7, 0x06f8, 0x02f8, 0x0bf9, 0x00f8, 0x08f8, 0x04f8, 0x0ff9, + }, + nil, 0, +} diff --git a/Godeps/_workspace/src/github.com/klauspost/compress/flate/gen.go b/Godeps/_workspace/src/github.com/klauspost/compress/flate/gen.go new file mode 100644 index 0000000000..154c89a488 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/compress/flate/gen.go @@ -0,0 +1,265 @@ +// 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 ignore + +// This program generates fixedhuff.go +// Invoke as +// +// go run gen.go -output fixedhuff.go + +package main + +import ( + "bytes" + "flag" + "fmt" + "go/format" + "io/ioutil" + "log" +) + +var filename = flag.String("output", "fixedhuff.go", "output file name") + +const maxCodeLen = 16 + +// Note: the definition of the huffmanDecoder struct is copied from +// inflate.go, as it is private to the implementation. + +// chunk & 15 is number of bits +// chunk >> 4 is value, including table link + +const ( + huffmanChunkBits = 9 + huffmanNumChunks = 1 << huffmanChunkBits + huffmanCountMask = 15 + huffmanValueShift = 4 +) + +type huffmanDecoder struct { + min int // the minimum code length + chunks [huffmanNumChunks]uint32 // chunks as described above + links [][]uint32 // overflow links + linkMask uint32 // mask the width of the link table +} + +// Initialize Huffman decoding tables from array of code lengths. +// Following this function, h is guaranteed to be initialized into a complete +// tree (i.e., neither over-subscribed nor under-subscribed). The exception is a +// degenerate case where the tree has only a single symbol with length 1. Empty +// trees are permitted. +func (h *huffmanDecoder) init(bits []int) bool { + // Sanity enables additional runtime tests during Huffman + // table construction. It's intended to be used during + // development to supplement the currently ad-hoc unit tests. + const sanity = false + + if h.min != 0 { + *h = huffmanDecoder{} + } + + // Count number of codes of each length, + // compute min and max length. + var count [maxCodeLen]int + var min, max int + for _, n := range bits { + if n == 0 { + continue + } + if min == 0 || n < min { + min = n + } + if n > max { + max = n + } + count[n]++ + } + + // Empty tree. The decompressor.huffSym function will fail later if the tree + // is used. Technically, an empty tree is only valid for the HDIST tree and + // not the HCLEN and HLIT tree. However, a stream with an empty HCLEN tree + // is guaranteed to fail since it will attempt to use the tree to decode the + // codes for the HLIT and HDIST trees. Similarly, an empty HLIT tree is + // guaranteed to fail later since the compressed data section must be + // composed of at least one symbol (the end-of-block marker). + if max == 0 { + return true + } + + code := 0 + var nextcode [maxCodeLen]int + for i := min; i <= max; i++ { + code <<= 1 + nextcode[i] = code + code += count[i] + } + + // Check that the coding is complete (i.e., that we've + // assigned all 2-to-the-max possible bit sequences). + // Exception: To be compatible with zlib, we also need to + // accept degenerate single-code codings. See also + // TestDegenerateHuffmanCoding. + if code != 1< huffmanChunkBits { + numLinks := 1 << (uint(max) - huffmanChunkBits) + h.linkMask = uint32(numLinks - 1) + + // create link tables + link := nextcode[huffmanChunkBits+1] >> 1 + h.links = make([][]uint32, huffmanNumChunks-link) + for j := uint(link); j < huffmanNumChunks; j++ { + reverse := int(reverseByte[j>>8]) | int(reverseByte[j&0xff])<<8 + reverse >>= uint(16 - huffmanChunkBits) + off := j - uint(link) + if sanity && h.chunks[reverse] != 0 { + panic("impossible: overwriting existing chunk") + } + h.chunks[reverse] = uint32(off<>8]) | int(reverseByte[code&0xff])<<8 + reverse >>= uint(16 - n) + if n <= huffmanChunkBits { + for off := reverse; off < len(h.chunks); off += 1 << uint(n) { + // We should never need to overwrite + // an existing chunk. Also, 0 is + // never a valid chunk, because the + // lower 4 "count" bits should be + // between 1 and 15. + if sanity && h.chunks[off] != 0 { + panic("impossible: overwriting existing chunk") + } + h.chunks[off] = chunk + } + } else { + j := reverse & (huffmanNumChunks - 1) + if sanity && h.chunks[j]&huffmanCountMask != huffmanChunkBits+1 { + // Longer codes should have been + // associated with a link table above. + panic("impossible: not an indirect chunk") + } + value := h.chunks[j] >> huffmanValueShift + linktab := h.links[value] + reverse >>= huffmanChunkBits + for off := reverse; off < len(linktab); off += 1 << uint(n-huffmanChunkBits) { + if sanity && linktab[off] != 0 { + panic("impossible: overwriting existing chunk") + } + linktab[off] = chunk + } + } + } + + if sanity { + // Above we've sanity checked that we never overwrote + // an existing entry. Here we additionally check that + // we filled the tables completely. + for i, chunk := range h.chunks { + if chunk == 0 { + // As an exception, in the degenerate + // single-code case, we allow odd + // chunks to be missing. + if code == 1 && i%2 == 1 { + continue + } + panic("impossible: missing chunk") + } + } + for _, linktab := range h.links { + for _, chunk := range linktab { + if chunk == 0 { + panic("impossible: missing chunk") + } + } + } + } + + return true +} + +func main() { + flag.Parse() + + var h huffmanDecoder + var bits [288]int + initReverseByte() + for i := 0; i < 144; i++ { + bits[i] = 8 + } + for i := 144; i < 256; i++ { + bits[i] = 9 + } + for i := 256; i < 280; i++ { + bits[i] = 7 + } + for i := 280; i < 288; i++ { + bits[i] = 8 + } + h.init(bits[:]) + if h.links != nil { + log.Fatal("Unexpected links table in fixed Huffman decoder") + } + + var buf bytes.Buffer + + fmt.Fprintf(&buf, `// 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.`+"\n\n") + + fmt.Fprintln(&buf, "package flate") + fmt.Fprintln(&buf) + fmt.Fprintln(&buf, "// autogenerated by go run gen.go -output fixedhuff.go, DO NOT EDIT") + fmt.Fprintln(&buf) + fmt.Fprintln(&buf, "var fixedHuffmanDecoder = huffmanDecoder{") + fmt.Fprintf(&buf, "\t%d,\n", h.min) + fmt.Fprintln(&buf, "\t[huffmanNumChunks]uint32{") + for i := 0; i < huffmanNumChunks; i++ { + if i&7 == 0 { + fmt.Fprintf(&buf, "\t\t") + } else { + fmt.Fprintf(&buf, " ") + } + fmt.Fprintf(&buf, "0x%04x,", h.chunks[i]) + if i&7 == 7 { + fmt.Fprintln(&buf) + } + } + fmt.Fprintln(&buf, "\t},") + fmt.Fprintln(&buf, "\tnil, 0,") + fmt.Fprintln(&buf, "}") + + data, err := format.Source(buf.Bytes()) + if err != nil { + log.Fatal(err) + } + err = ioutil.WriteFile(*filename, data, 0644) + if err != nil { + log.Fatal(err) + } +} + +var reverseByte [256]byte + +func initReverseByte() { + for x := 0; x < 256; x++ { + var result byte + for i := uint(0); i < 8; i++ { + result |= byte(((x >> i) & 1) << (7 - i)) + } + reverseByte[x] = result + } +} diff --git a/Godeps/_workspace/src/github.com/klauspost/compress/flate/huffman_bit_writer.go b/Godeps/_workspace/src/github.com/klauspost/compress/flate/huffman_bit_writer.go new file mode 100644 index 0000000000..5f7ffdd2e6 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/compress/flate/huffman_bit_writer.go @@ -0,0 +1,717 @@ +// 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. + +package flate + +import ( + "io" + "math" +) + +const ( + // The largest offset code. + offsetCodeCount = 30 + + // The special code used to mark the end of a block. + endBlockMarker = 256 + + // The first length code. + lengthCodesStart = 257 + + // The number of codegen codes. + codegenCodeCount = 19 + badCode = 255 + + // Output byte buffer size + // Must be multiple of 6 (48 bits) + 8 + bufferSize = 240 + 8 +) + +// The number of extra bits needed by length code X - LENGTH_CODES_START. +var lengthExtraBits = []int8{ + /* 257 */ 0, 0, 0, + /* 260 */ 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, + /* 270 */ 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, + /* 280 */ 4, 5, 5, 5, 5, 0, +} + +// The length indicated by length code X - LENGTH_CODES_START. +var lengthBase = []uint32{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, + 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, + 64, 80, 96, 112, 128, 160, 192, 224, 255, +} + +// offset code word extra bits. +var offsetExtraBits = []int8{ + 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, + 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, + 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, + /* extended window */ + 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, +} + +var offsetBase = []uint32{ + /* normal deflate */ + 0x000000, 0x000001, 0x000002, 0x000003, 0x000004, + 0x000006, 0x000008, 0x00000c, 0x000010, 0x000018, + 0x000020, 0x000030, 0x000040, 0x000060, 0x000080, + 0x0000c0, 0x000100, 0x000180, 0x000200, 0x000300, + 0x000400, 0x000600, 0x000800, 0x000c00, 0x001000, + 0x001800, 0x002000, 0x003000, 0x004000, 0x006000, + + /* extended window */ + 0x008000, 0x00c000, 0x010000, 0x018000, 0x020000, + 0x030000, 0x040000, 0x060000, 0x080000, 0x0c0000, + 0x100000, 0x180000, 0x200000, 0x300000, +} + +// The odd order in which the codegen code sizes are written. +var codegenOrder = []uint32{16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15} + +type huffmanBitWriter struct { + w io.Writer + // Data waiting to be written is bytes[0:nbytes] + // and then the low nbits of bits. + bits uint64 + nbits uint + bytes [bufferSize]byte + nbytes int + literalFreq []int32 + offsetFreq []int32 + codegen []uint8 + codegenFreq []int32 + literalEncoding *huffmanEncoder + offsetEncoding *huffmanEncoder + codegenEncoding *huffmanEncoder + err error +} + +func newHuffmanBitWriter(w io.Writer) *huffmanBitWriter { + return &huffmanBitWriter{ + w: w, + literalFreq: make([]int32, maxNumLit), + offsetFreq: make([]int32, offsetCodeCount), + codegen: make([]uint8, maxNumLit+offsetCodeCount+1), + codegenFreq: make([]int32, codegenCodeCount), + literalEncoding: newHuffmanEncoder(maxNumLit), + codegenEncoding: newHuffmanEncoder(codegenCodeCount), + offsetEncoding: newHuffmanEncoder(offsetCodeCount), + } +} + +func (w *huffmanBitWriter) reset(writer io.Writer) { + w.w = writer + w.bits, w.nbits, w.nbytes, w.err = 0, 0, 0, nil + w.bytes = [bufferSize]byte{} +} + +func (w *huffmanBitWriter) flush() { + if w.err != nil { + w.nbits = 0 + return + } + n := w.nbytes + for w.nbits != 0 { + w.bytes[n] = byte(w.bits) + w.bits >>= 8 + if w.nbits > 8 { // Avoid underflow + w.nbits -= 8 + } else { + w.nbits = 0 + } + n++ + } + w.bits = 0 + _, w.err = w.w.Write(w.bytes[0:n]) + w.nbytes = 0 +} + +func (w *huffmanBitWriter) writeBits(b int32, nb uint) { + w.bits |= uint64(b) << w.nbits + w.nbits += nb + if w.nbits >= 48 { + bits := w.bits + w.bits >>= 48 + w.nbits -= 48 + n := w.nbytes + w.bytes[n] = byte(bits) + w.bytes[n+1] = byte(bits >> 8) + w.bytes[n+2] = byte(bits >> 16) + w.bytes[n+3] = byte(bits >> 24) + w.bytes[n+4] = byte(bits >> 32) + w.bytes[n+5] = byte(bits >> 40) + n += 6 + if n >= bufferSize-8 { + _, w.err = w.w.Write(w.bytes[:bufferSize-8]) + n = 0 + } + w.nbytes = n + } +} + +func (w *huffmanBitWriter) writeBytes(bytes []byte) { + if w.err != nil { + return + } + n := w.nbytes + for w.nbits != 0 { + w.bytes[n] = byte(w.bits) + w.bits >>= 8 + w.nbits -= 8 + n++ + } + if w.nbits != 0 { + w.err = InternalError("writeBytes with unfinished bits") + return + } + if n != 0 { + _, w.err = w.w.Write(w.bytes[0:n]) + if w.err != nil { + return + } + } + w.nbytes = 0 + _, w.err = w.w.Write(bytes) +} + +// RFC 1951 3.2.7 specifies a special run-length encoding for specifying +// the literal and offset lengths arrays (which are concatenated into a single +// array). This method generates that run-length encoding. +// +// The result is written into the codegen array, and the frequencies +// of each code is written into the codegenFreq array. +// Codes 0-15 are single byte codes. Codes 16-18 are followed by additional +// information. Code badCode is an end marker +// +// numLiterals The number of literals in literalEncoding +// numOffsets The number of offsets in offsetEncoding +func (w *huffmanBitWriter) generateCodegen(numLiterals int, numOffsets int, offenc *huffmanEncoder) { + for i := range w.codegenFreq { + w.codegenFreq[i] = 0 + } + // Note that we are using codegen both as a temporary variable for holding + // a copy of the frequencies, and as the place where we put the result. + // This is fine because the output is always shorter than the input used + // so far. + codegen := w.codegen // cache + // Copy the concatenated code sizes to codegen. Put a marker at the end. + cgnl := codegen[0:numLiterals] + for i := range cgnl { + cgnl[i] = uint8(w.literalEncoding.codes[i].bits()) + } + + cgnl = codegen[numLiterals : numLiterals+numOffsets] + for i := range cgnl { + cgnl[i] = uint8(offenc.codes[i].bits()) + } + codegen[numLiterals+numOffsets] = badCode + + size := codegen[0] + count := 1 + outIndex := 0 + for inIndex := 1; size != badCode; inIndex++ { + // INVARIANT: We have seen "count" copies of size that have not yet + // had output generated for them. + nextSize := codegen[inIndex] + if nextSize == size { + count++ + continue + } + // We need to generate codegen indicating "count" of size. + if size != 0 { + codegen[outIndex] = size + outIndex++ + w.codegenFreq[size]++ + count-- + for count >= 3 { + n := 6 + if n > count { + n = count + } + codegen[outIndex] = 16 + outIndex++ + codegen[outIndex] = uint8(n - 3) + outIndex++ + w.codegenFreq[16]++ + count -= n + } + } else { + for count >= 11 { + n := 138 + if n > count { + n = count + } + codegen[outIndex] = 18 + outIndex++ + codegen[outIndex] = uint8(n - 11) + outIndex++ + w.codegenFreq[18]++ + count -= n + } + if count >= 3 { + // count >= 3 && count <= 10 + codegen[outIndex] = 17 + outIndex++ + codegen[outIndex] = uint8(count - 3) + outIndex++ + w.codegenFreq[17]++ + count = 0 + } + } + count-- + for ; count >= 0; count-- { + codegen[outIndex] = size + outIndex++ + w.codegenFreq[size]++ + } + // Set up invariant for next time through the loop. + size = nextSize + count = 1 + } + // Marker indicating the end of the codegen. + codegen[outIndex] = badCode +} + +func (w *huffmanBitWriter) writeCode(c hcode) { + if w.err != nil { + return + } + w.bits |= uint64(c.code()) << w.nbits + w.nbits += c.bits() + if w.nbits >= 48 { + bits := w.bits + w.bits >>= 48 + w.nbits -= 48 + n := w.nbytes + w.bytes[n] = byte(bits) + w.bytes[n+1] = byte(bits >> 8) + w.bytes[n+2] = byte(bits >> 16) + w.bytes[n+3] = byte(bits >> 24) + w.bytes[n+4] = byte(bits >> 32) + w.bytes[n+5] = byte(bits >> 40) + n += 6 + if n >= bufferSize-8 { + _, w.err = w.w.Write(w.bytes[:bufferSize-8]) + n = 0 + } + w.nbytes = n + } + +} + +// Write the header of a dynamic Huffman block to the output stream. +// +// numLiterals The number of literals specified in codegen +// numOffsets The number of offsets specified in codegen +// numCodegens The number of codegens used in codegen +func (w *huffmanBitWriter) writeDynamicHeader(numLiterals int, numOffsets int, numCodegens int, isEof bool) { + if w.err != nil { + return + } + var firstBits int32 = 4 + if isEof { + firstBits = 5 + } + w.writeBits(firstBits, 3) + w.writeBits(int32(numLiterals-257), 5) + w.writeBits(int32(numOffsets-1), 5) + w.writeBits(int32(numCodegens-4), 4) + + for i := 0; i < numCodegens; i++ { + value := w.codegenEncoding.codes[codegenOrder[i]].bits() + w.writeBits(int32(value), 3) + } + + i := 0 + for { + var codeWord int = int(w.codegen[i]) + i++ + if codeWord == badCode { + break + } + // The low byte contains the actual code to generate. + w.writeCode(w.codegenEncoding.codes[uint32(codeWord)]) + + switch codeWord { + case 16: + w.writeBits(int32(w.codegen[i]), 2) + i++ + break + case 17: + w.writeBits(int32(w.codegen[i]), 3) + i++ + break + case 18: + w.writeBits(int32(w.codegen[i]), 7) + i++ + break + } + } +} + +func (w *huffmanBitWriter) writeStoredHeader(length int, isEof bool) { + if w.err != nil { + return + } + var flag int32 + if isEof { + flag = 1 + } + w.writeBits(flag, 3) + w.flush() + w.writeBits(int32(length), 16) + w.writeBits(int32(^uint16(length)), 16) +} + +func (w *huffmanBitWriter) writeFixedHeader(isEof bool) { + if w.err != nil { + return + } + // Indicate that we are a fixed Huffman block + var value int32 = 2 + if isEof { + value = 3 + } + w.writeBits(value, 3) +} + +func (w *huffmanBitWriter) writeBlock(tok tokens, eof bool, input []byte) { + if w.err != nil { + return + } + for i := range w.literalFreq { + w.literalFreq[i] = 0 + } + for i := range w.offsetFreq { + w.offsetFreq[i] = 0 + } + + tok.tokens[tok.n] = endBlockMarker + tokens := tok.tokens[0 : tok.n+1] + + for _, t := range tokens { + if t < matchType { + w.literalFreq[t.literal()]++ + } else { + length := t.length() + offset := t.offset() + w.literalFreq[lengthCodesStart+lengthCode(length)]++ + w.offsetFreq[offsetCode(offset)]++ + } + } + + // get the number of literals + numLiterals := len(w.literalFreq) + for w.literalFreq[numLiterals-1] == 0 { + numLiterals-- + } + // get the number of offsets + numOffsets := len(w.offsetFreq) + for numOffsets > 0 && w.offsetFreq[numOffsets-1] == 0 { + numOffsets-- + } + if numOffsets == 0 { + // We haven't found a single match. If we want to go with the dynamic encoding, + // we should count at least one offset to be sure that the offset huffman tree could be encoded. + w.offsetFreq[0] = 1 + numOffsets = 1 + } + + w.literalEncoding.generate(w.literalFreq, 15) + w.offsetEncoding.generate(w.offsetFreq, 15) + + storedBytes := 0 + if input != nil { + storedBytes = len(input) + } + var extraBits int64 + var storedSize int64 = math.MaxInt64 + if storedBytes <= maxStoreBlockSize && input != nil { + storedSize = int64((storedBytes + 5) * 8) + // We only bother calculating the costs of the extra bits required by + // the length of offset fields (which will be the same for both fixed + // and dynamic encoding), if we need to compare those two encodings + // against stored encoding. + for lengthCode := lengthCodesStart + 8; lengthCode < numLiterals; lengthCode++ { + // First eight length codes have extra size = 0. + extraBits += int64(w.literalFreq[lengthCode]) * int64(lengthExtraBits[lengthCode-lengthCodesStart]) + } + for offsetCode := 4; offsetCode < numOffsets; offsetCode++ { + // First four offset codes have extra size = 0. + extraBits += int64(w.offsetFreq[offsetCode]) * int64(offsetExtraBits[offsetCode]) + } + } + + // Figure out smallest code. + // Fixed Huffman baseline. + var size = int64(3) + + fixedLiteralEncoding.bitLength(w.literalFreq) + + fixedOffsetEncoding.bitLength(w.offsetFreq) + + extraBits + var literalEncoding = fixedLiteralEncoding + var offsetEncoding = fixedOffsetEncoding + + // Dynamic Huffman? + var numCodegens int + + // Generate codegen and codegenFrequencies, which indicates how to encode + // the literalEncoding and the offsetEncoding. + w.generateCodegen(numLiterals, numOffsets, w.offsetEncoding) + w.codegenEncoding.generate(w.codegenFreq, 7) + numCodegens = len(w.codegenFreq) + for numCodegens > 4 && w.codegenFreq[codegenOrder[numCodegens-1]] == 0 { + numCodegens-- + } + dynamicHeader := int64(3+5+5+4+(3*numCodegens)) + + w.codegenEncoding.bitLength(w.codegenFreq) + + int64(extraBits) + + int64(w.codegenFreq[16]*2) + + int64(w.codegenFreq[17]*3) + + int64(w.codegenFreq[18]*7) + dynamicSize := dynamicHeader + + w.literalEncoding.bitLength(w.literalFreq) + + w.offsetEncoding.bitLength(w.offsetFreq) + + if dynamicSize < size { + size = dynamicSize + literalEncoding = w.literalEncoding + offsetEncoding = w.offsetEncoding + } + + // Stored bytes? + if storedSize < size { + w.writeStoredHeader(storedBytes, eof) + w.writeBytes(input[0:storedBytes]) + return + } + + // Huffman. + if literalEncoding == fixedLiteralEncoding { + w.writeFixedHeader(eof) + } else { + w.writeDynamicHeader(numLiterals, numOffsets, numCodegens, eof) + } + + leCodes := literalEncoding.codes + oeCodes := offsetEncoding.codes + for _, t := range tokens { + if t < matchType { + w.writeCode(leCodes[t.literal()]) + } else { + // Write the length + length := t.length() + lengthCode := lengthCode(length) + w.writeCode(leCodes[lengthCode+lengthCodesStart]) + extraLengthBits := uint(lengthExtraBits[lengthCode]) + if extraLengthBits > 0 { + extraLength := int32(length - lengthBase[lengthCode]) + w.writeBits(extraLength, extraLengthBits) + } + // Write the offset + offset := t.offset() + offsetCode := offsetCode(offset) + w.writeCode(oeCodes[offsetCode]) + extraOffsetBits := uint(offsetExtraBits[offsetCode]) + if extraOffsetBits > 0 { + extraOffset := int32(offset - offsetBase[offsetCode]) + w.writeBits(extraOffset, extraOffsetBits) + } + } + } +} + +// writeBlockDynamic will write a block as dynamic Huffman table +// compressed. This should be used, if the caller has a reasonable expectation +// that this block contains compressible data. +func (w *huffmanBitWriter) writeBlockDynamic(tok tokens, eof bool, input []byte) { + if w.err != nil { + return + } + for i := range w.literalFreq { + w.literalFreq[i] = 0 + } + for i := range w.offsetFreq { + w.offsetFreq[i] = 0 + } + + tok.tokens[tok.n] = endBlockMarker + tokens := tok.tokens[0 : tok.n+1] + + for _, t := range tokens { + if t < matchType { + w.literalFreq[t.literal()]++ + } else { + length := t.length() + offset := t.offset() + w.literalFreq[lengthCodesStart+lengthCode(length)]++ + w.offsetFreq[offsetCode(offset)]++ + } + } + + // get the number of literals + numLiterals := len(w.literalFreq) + for w.literalFreq[numLiterals-1] == 0 { + numLiterals-- + } + // get the number of offsets + numOffsets := len(w.offsetFreq) + for numOffsets > 0 && w.offsetFreq[numOffsets-1] == 0 { + numOffsets-- + } + if numOffsets == 0 { + // We haven't found a single match. If we want to go with the dynamic encoding, + // we should count at least one offset to be sure that the offset huffman tree could be encoded. + w.offsetFreq[0] = 1 + numOffsets = 1 + } + + w.literalEncoding.generate(w.literalFreq, 15) + w.offsetEncoding.generate(w.offsetFreq, 15) + + var numCodegens int + + // Generate codegen and codegenFrequencies, which indicates how to encode + // the literalEncoding and the offsetEncoding. + w.generateCodegen(numLiterals, numOffsets, w.offsetEncoding) + w.codegenEncoding.generate(w.codegenFreq, 7) + numCodegens = len(w.codegenFreq) + for numCodegens > 4 && w.codegenFreq[codegenOrder[numCodegens-1]] == 0 { + numCodegens-- + } + var literalEncoding = w.literalEncoding + var offsetEncoding = w.offsetEncoding + + // Write Huffman table. + w.writeDynamicHeader(numLiterals, numOffsets, numCodegens, eof) + leCodes := literalEncoding.codes + oeCodes := offsetEncoding.codes + + for _, t := range tokens { + if t < matchType { + w.writeCode(leCodes[t.literal()]) + } else { + // Write the length + length := t.length() + lengthCode := lengthCode(length) + w.writeCode(leCodes[lengthCode+lengthCodesStart]) + extraLengthBits := uint(lengthExtraBits[lengthCode]) + if extraLengthBits > 0 { + extraLength := int32(length - lengthBase[lengthCode]) + w.writeBits(extraLength, extraLengthBits) + } + // Write the offset + offset := t.offset() + offsetCode := offsetCode(offset) + w.writeCode(oeCodes[offsetCode]) + extraOffsetBits := uint(offsetExtraBits[offsetCode]) + if extraOffsetBits > 0 { + extraOffset := int32(offset - offsetBase[offsetCode]) + w.writeBits(extraOffset, extraOffsetBits) + } + } + } +} + +// static offset encoder used for huffman only encoding. +var huffOffset *huffmanEncoder + +func init() { + var w = newHuffmanBitWriter(nil) + w.offsetFreq[0] = 1 + huffOffset = newHuffmanEncoder(offsetCodeCount) + huffOffset.generate(w.offsetFreq, 15) +} + +// writeBlockHuff will write a block of bytes as either +// Huffman encoded literals or uncompressed bytes if the +// results only gains very little from compression. +func (w *huffmanBitWriter) writeBlockHuff(eof bool, input []byte) { + if w.err != nil { + return + } + + // Clear histogram + for i := range w.literalFreq { + w.literalFreq[i] = 0 + } + + // Add everything as literals + histogram(input, w.literalFreq) + + w.literalFreq[endBlockMarker] = 1 + + const numLiterals = endBlockMarker + 1 + const numOffsets = 1 + + w.literalEncoding.generate(w.literalFreq, 15) + + // Figure out smallest code. + // Always use dynamic Huffman or Store + var numCodegens int + + // Generate codegen and codegenFrequencies, which indicates how to encode + // the literalEncoding and the offsetEncoding. + w.generateCodegen(numLiterals, numOffsets, huffOffset) + w.codegenEncoding.generate(w.codegenFreq, 7) + numCodegens = len(w.codegenFreq) + for numCodegens > 4 && w.codegenFreq[codegenOrder[numCodegens-1]] == 0 { + numCodegens-- + } + headerSize := int64(3+5+5+4+(3*numCodegens)) + + w.codegenEncoding.bitLength(w.codegenFreq) + + int64(w.codegenFreq[16]*2) + + int64(w.codegenFreq[17]*3) + + int64(w.codegenFreq[18]*7) + + // Includes EOB marker + size := headerSize + w.literalEncoding.bitLength(w.literalFreq) + + // Calculate stored size + var storedSize int64 = math.MaxInt64 + var storedBytes = len(input) + if storedBytes <= maxStoreBlockSize { + storedSize = int64(storedBytes+5) * 8 + } + + // Store bytes, if we don't get a reasonable improvement. + if storedSize < (size + size>>4) { + w.writeStoredHeader(storedBytes, eof) + w.writeBytes(input) + return + } + + // Huffman. + w.writeDynamicHeader(numLiterals, numOffsets, numCodegens, eof) + encoding := w.literalEncoding.codes + for _, t := range input { + // Bitwriting inlined, ~30% speedup + c := encoding[t] + w.bits |= uint64(c.code()) << w.nbits + w.nbits += c.bits() + if w.nbits >= 48 { + bits := w.bits + w.bits >>= 48 + w.nbits -= 48 + n := w.nbytes + w.bytes[n] = byte(bits) + w.bytes[n+1] = byte(bits >> 8) + w.bytes[n+2] = byte(bits >> 16) + w.bytes[n+3] = byte(bits >> 24) + w.bytes[n+4] = byte(bits >> 32) + w.bytes[n+5] = byte(bits >> 40) + n += 6 + if n >= bufferSize-8 { + _, w.err = w.w.Write(w.bytes[:bufferSize-8]) + if w.err != nil { + return + } + w.nbytes = 0 + } else { + w.nbytes = n + } + } + } + w.writeCode(encoding[endBlockMarker]) +} diff --git a/Godeps/_workspace/src/github.com/klauspost/compress/flate/huffman_code.go b/Godeps/_workspace/src/github.com/klauspost/compress/flate/huffman_code.go new file mode 100644 index 0000000000..9dba0faf33 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/compress/flate/huffman_code.go @@ -0,0 +1,363 @@ +// 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. + +package flate + +import ( + "math" + "sort" +) + +type hcode uint32 + +type huffmanEncoder struct { + codes []hcode + freqcache []literalNode + bitCount [17]int32 + lns literalNodeSorter + lfs literalFreqSorter +} + +type literalNode struct { + literal uint16 + freq int32 +} + +// A levelInfo describes the state of the constructed tree for a given depth. +type levelInfo struct { + // Our level. for better printing + level int32 + + // The frequency of the last node at this level + lastFreq int32 + + // The frequency of the next character to add to this level + nextCharFreq int32 + + // The frequency of the next pair (from level below) to add to this level. + // Only valid if the "needed" value of the next lower level is 0. + nextPairFreq int32 + + // The number of chains remaining to generate for this level before moving + // up to the next level + needed int32 +} + +func (h hcode) codeBits() (code uint16, bits uint8) { + return uint16(h), uint8(h >> 16) +} + +func (h *hcode) set(code uint16, bits uint8) { + *h = hcode(code) | hcode(uint32(bits)<<16) +} + +func (h *hcode) setBits(bits uint8) { + *h = hcode(*h&0xffff) | hcode(uint32(bits)<<16) +} + +func toCode(code uint16, bits uint8) hcode { + return hcode(code) | hcode(uint32(bits)<<16) +} + +func (h hcode) code() (code uint16) { + return uint16(h) +} + +func (h hcode) bits() (bits uint) { + return uint(h >> 16) +} + +func maxNode() literalNode { return literalNode{math.MaxUint16, math.MaxInt32} } + +func newHuffmanEncoder(size int) *huffmanEncoder { + return &huffmanEncoder{codes: make([]hcode, size), freqcache: nil} +} + +// Generates a HuffmanCode corresponding to the fixed literal table +func generateFixedLiteralEncoding() *huffmanEncoder { + h := newHuffmanEncoder(maxNumLit) + codes := h.codes + var ch uint16 + for ch = 0; ch < maxNumLit; ch++ { + var bits uint16 + var size uint8 + switch { + case ch < 144: + // size 8, 000110000 .. 10111111 + bits = ch + 48 + size = 8 + break + case ch < 256: + // size 9, 110010000 .. 111111111 + bits = ch + 400 - 144 + size = 9 + break + case ch < 280: + // size 7, 0000000 .. 0010111 + bits = ch - 256 + size = 7 + break + default: + // size 8, 11000000 .. 11000111 + bits = ch + 192 - 280 + size = 8 + } + codes[ch] = toCode(reverseBits(bits, size), size) + } + return h +} + +func generateFixedOffsetEncoding() *huffmanEncoder { + h := newHuffmanEncoder(30) + codes := h.codes + for ch := uint16(0); ch < 30; ch++ { + codes[ch] = toCode(reverseBits(ch, 5), 5) + } + return h +} + +var fixedLiteralEncoding *huffmanEncoder = generateFixedLiteralEncoding() +var fixedOffsetEncoding *huffmanEncoder = generateFixedOffsetEncoding() + +func (h *huffmanEncoder) bitLength(freq []int32) int64 { + var total int64 + for i, f := range freq { + if f != 0 { + total += int64(f) * int64(h.codes[i].bits()) + } + } + return total +} + +const maxBitsLimit = 16 + +// Return the number of literals assigned to each bit size in the Huffman encoding +// +// This method is only called when list.length >= 3 +// The cases of 0, 1, and 2 literals are handled by special case code. +// +// list An array of the literals with non-zero frequencies +// and their associated frequencies. The array is in order of increasing +// frequency, and has as its last element a special element with frequency +// MaxInt32 +// maxBits The maximum number of bits that should be used to encode any literal. +// Must be less than 16. +// return An integer array in which array[i] indicates the number of literals +// that should be encoded in i bits. +func (h *huffmanEncoder) bitCounts(list []literalNode, maxBits int32) []int32 { + if maxBits >= maxBitsLimit { + panic("flate: maxBits too large") + } + n := int32(len(list)) + list = list[0 : n+1] + list[n] = maxNode() + + // The tree can't have greater depth than n - 1, no matter what. This + // saves a little bit of work in some small cases + if maxBits > n-1 { + maxBits = n - 1 + } + + // Create information about each of the levels. + // A bogus "Level 0" whose sole purpose is so that + // level1.prev.needed==0. This makes level1.nextPairFreq + // be a legitimate value that never gets chosen. + var levels [maxBitsLimit]levelInfo + // leafCounts[i] counts the number of literals at the left + // of ancestors of the rightmost node at level i. + // leafCounts[i][j] is the number of literals at the left + // of the level j ancestor. + var leafCounts [maxBitsLimit][maxBitsLimit]int32 + + for level := int32(1); level <= maxBits; level++ { + // For every level, the first two items are the first two characters. + // We initialize the levels as if we had already figured this out. + levels[level] = levelInfo{ + level: level, + lastFreq: list[1].freq, + nextCharFreq: list[2].freq, + nextPairFreq: list[0].freq + list[1].freq, + } + leafCounts[level][level] = 2 + if level == 1 { + levels[level].nextPairFreq = math.MaxInt32 + } + } + + // We need a total of 2*n - 2 items at top level and have already generated 2. + levels[maxBits].needed = 2*n - 4 + + level := maxBits + for { + l := &levels[level] + if l.nextPairFreq == math.MaxInt32 && l.nextCharFreq == math.MaxInt32 { + // We've run out of both leafs and pairs. + // End all calculations for this level. + // To make sure we never come back to this level or any lower level, + // set nextPairFreq impossibly large. + l.needed = 0 + levels[level+1].nextPairFreq = math.MaxInt32 + level++ + continue + } + + prevFreq := l.lastFreq + if l.nextCharFreq < l.nextPairFreq { + // The next item on this row is a leaf node. + n := leafCounts[level][level] + 1 + l.lastFreq = l.nextCharFreq + // Lower leafCounts are the same of the previous node. + leafCounts[level][level] = n + l.nextCharFreq = list[n].freq + } else { + // The next item on this row is a pair from the previous row. + // nextPairFreq isn't valid until we generate two + // more values in the level below + l.lastFreq = l.nextPairFreq + // Take leaf counts from the lower level, except counts[level] remains the same. + copy(leafCounts[level][:level], leafCounts[level-1][:level]) + levels[l.level-1].needed = 2 + } + + if l.needed--; l.needed == 0 { + // We've done everything we need to do for this level. + // Continue calculating one level up. Fill in nextPairFreq + // of that level with the sum of the two nodes we've just calculated on + // this level. + if l.level == maxBits { + // All done! + break + } + levels[l.level+1].nextPairFreq = prevFreq + l.lastFreq + level++ + } else { + // If we stole from below, move down temporarily to replenish it. + for levels[level-1].needed > 0 { + level-- + } + } + } + + // Somethings is wrong if at the end, the top level is null or hasn't used + // all of the leaves. + if leafCounts[maxBits][maxBits] != n { + panic("leafCounts[maxBits][maxBits] != n") + } + + bitCount := h.bitCount[:maxBits+1] + //make([]int32, maxBits+1) + bits := 1 + counts := &leafCounts[maxBits] + for level := maxBits; level > 0; level-- { + // chain.leafCount gives the number of literals requiring at least "bits" + // bits to encode. + bitCount[bits] = counts[level] - counts[level-1] + bits++ + } + return bitCount +} + +// Look at the leaves and assign them a bit count and an encoding as specified +// in RFC 1951 3.2.2 +func (h *huffmanEncoder) assignEncodingAndSize(bitCount []int32, list []literalNode) { + code := uint16(0) + for n, bits := range bitCount { + code <<= 1 + if n == 0 || bits == 0 { + continue + } + // The literals list[len(list)-bits] .. list[len(list)-bits] + // are encoded using "bits" bits, and get the values + // code, code + 1, .... The code values are + // assigned in literal order (not frequency order). + chunk := list[len(list)-int(bits):] + + h.lns.Sort(chunk) + for _, node := range chunk { + h.codes[node.literal] = toCode(reverseBits(code, uint8(n)), uint8(n)) + code++ + } + list = list[0 : len(list)-int(bits)] + } +} + +// Update this Huffman Code object to be the minimum code for the specified frequency count. +// +// freq An array of frequencies, in which frequency[i] gives the frequency of literal i. +// maxBits The maximum number of bits to use for any literal. +func (h *huffmanEncoder) generate(freq []int32, maxBits int32) { + if h.freqcache == nil { + h.freqcache = make([]literalNode, 300) + } + list := h.freqcache[:len(freq)+1] + // Number of non-zero literals + count := 0 + // Set list to be the set of all non-zero literals and their frequencies + for i, f := range freq { + if f != 0 { + list[count] = literalNode{uint16(i), f} + count++ + } else { + list[count] = literalNode{} + //h.codeBits[i] = 0 + h.codes[i].setBits(0) + } + } + list[len(freq)] = literalNode{} + // If freq[] is shorter than codeBits[], fill rest of codeBits[] with zeros + // FIXME: Doesn't do what it says on the tin (klauspost) + //h.codeBits = h.codeBits[0:len(freq)] + + list = list[0:count] + if count <= 2 { + // Handle the small cases here, because they are awkward for the general case code. With + // two or fewer literals, everything has bit length 1. + for i, node := range list { + // "list" is in order of increasing literal value. + h.codes[node.literal].set(uint16(i), 1) + //h.codeBits[node.literal] = 1 + //h.code[node.literal] = uint16(i) + } + return + } + h.lfs.Sort(list) + + // Get the number of literals for each bit count + bitCount := h.bitCounts(list, maxBits) + // And do the assignment + h.assignEncodingAndSize(bitCount, list) +} + +type literalNodeSorter []literalNode + +func (s *literalNodeSorter) Sort(a []literalNode) { + *s = literalNodeSorter(a) + sort.Sort(s) +} + +func (s literalNodeSorter) Len() int { return len(s) } + +func (s literalNodeSorter) Less(i, j int) bool { + return s[i].literal < s[j].literal +} + +func (s literalNodeSorter) Swap(i, j int) { s[i], s[j] = s[j], s[i] } + +type literalFreqSorter []literalNode + +func (s *literalFreqSorter) Sort(a []literalNode) { + *s = literalFreqSorter(a) + sort.Sort(s) +} + +func (s literalFreqSorter) Len() int { return len(s) } + +func (s literalFreqSorter) Less(i, j int) bool { + if s[i].freq == s[j].freq { + return s[i].literal < s[j].literal + } + return s[i].freq < s[j].freq +} + +func (s literalFreqSorter) Swap(i, j int) { s[i], s[j] = s[j], s[i] } diff --git a/Godeps/_workspace/src/github.com/klauspost/compress/flate/inflate.go b/Godeps/_workspace/src/github.com/klauspost/compress/flate/inflate.go new file mode 100644 index 0000000000..91e27e7e28 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/compress/flate/inflate.go @@ -0,0 +1,846 @@ +// 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. + +//go:generate go run gen.go -output fixedhuff.go + +// Package flate implements the DEFLATE compressed data format, described in +// RFC 1951. The gzip and zlib packages implement access to DEFLATE-based file +// formats. +package flate + +import ( + "bufio" + "io" + "strconv" +) + +const ( + maxCodeLen = 16 // max length of Huffman code + maxHist = 32768 // max history required + // The next three numbers come from the RFC section 3.2.7, with the + // additional proviso in section 3.2.5 which implies that distance codes + // 30 and 31 should never occur in compressed data. + maxNumLit = 286 + maxNumDist = 30 + numCodes = 19 // number of codes in Huffman meta-code +) + +// A CorruptInputError reports the presence of corrupt input at a given offset. +type CorruptInputError int64 + +func (e CorruptInputError) Error() string { + return "flate: corrupt input before offset " + strconv.FormatInt(int64(e), 10) +} + +// An InternalError reports an error in the flate code itself. +type InternalError string + +func (e InternalError) Error() string { return "flate: internal error: " + string(e) } + +// A ReadError reports an error encountered while reading input. +type ReadError struct { + Offset int64 // byte offset where error occurred + Err error // error returned by underlying Read +} + +func (e *ReadError) Error() string { + return "flate: read error at offset " + strconv.FormatInt(e.Offset, 10) + ": " + e.Err.Error() +} + +// A WriteError reports an error encountered while writing output. +type WriteError struct { + Offset int64 // byte offset where error occurred + Err error // error returned by underlying Write +} + +func (e *WriteError) Error() string { + return "flate: write error at offset " + strconv.FormatInt(e.Offset, 10) + ": " + e.Err.Error() +} + +// Resetter resets a ReadCloser returned by NewReader or NewReaderDict to +// to switch to a new underlying Reader. This permits reusing a ReadCloser +// instead of allocating a new one. +type Resetter interface { + // Reset discards any buffered data and resets the Resetter as if it was + // newly initialized with the given reader. + Reset(r io.Reader, dict []byte) error +} + +// Note that much of the implementation of huffmanDecoder is also copied +// into gen.go (in package main) for the purpose of precomputing the +// fixed huffman tables so they can be included statically. + +// The data structure for decoding Huffman tables is based on that of +// zlib. There is a lookup table of a fixed bit width (huffmanChunkBits), +// For codes smaller than the table width, there are multiple entries +// (each combination of trailing bits has the same value). For codes +// larger than the table width, the table contains a link to an overflow +// table. The width of each entry in the link table is the maximum code +// size minus the chunk width. + +// Note that you can do a lookup in the table even without all bits +// filled. Since the extra bits are zero, and the DEFLATE Huffman codes +// have the property that shorter codes come before longer ones, the +// bit length estimate in the result is a lower bound on the actual +// number of bits. + +// chunk & 15 is number of bits +// chunk >> 4 is value, including table link + +const ( + huffmanChunkBits = 9 + huffmanNumChunks = 1 << huffmanChunkBits + huffmanCountMask = 15 + huffmanValueShift = 4 +) + +type huffmanDecoder struct { + min int // the minimum code length + chunks [huffmanNumChunks]uint32 // chunks as described above + links [][]uint32 // overflow links + linkMask uint32 // mask the width of the link table +} + +// Initialize Huffman decoding tables from array of code lengths. +// Following this function, h is guaranteed to be initialized into a complete +// tree (i.e., neither over-subscribed nor under-subscribed). The exception is a +// degenerate case where the tree has only a single symbol with length 1. Empty +// trees are permitted. +func (h *huffmanDecoder) init(bits []int) bool { + // Sanity enables additional runtime tests during Huffman + // table construction. It's intended to be used during + // development to supplement the currently ad-hoc unit tests. + const sanity = false + + if h.min != 0 { + *h = huffmanDecoder{} + } + + // Count number of codes of each length, + // compute min and max length. + var count [maxCodeLen]int + var min, max int + for _, n := range bits { + if n == 0 { + continue + } + if min == 0 || n < min { + min = n + } + if n > max { + max = n + } + count[n]++ + } + + // Empty tree. The decompressor.huffSym function will fail later if the tree + // is used. Technically, an empty tree is only valid for the HDIST tree and + // not the HCLEN and HLIT tree. However, a stream with an empty HCLEN tree + // is guaranteed to fail since it will attempt to use the tree to decode the + // codes for the HLIT and HDIST trees. Similarly, an empty HLIT tree is + // guaranteed to fail later since the compressed data section must be + // composed of at least one symbol (the end-of-block marker). + if max == 0 { + return true + } + + code := 0 + var nextcode [maxCodeLen]int + for i := min; i <= max; i++ { + code <<= 1 + nextcode[i] = code + code += count[i] + } + + // Check that the coding is complete (i.e., that we've + // assigned all 2-to-the-max possible bit sequences). + // Exception: To be compatible with zlib, we also need to + // accept degenerate single-code codings. See also + // TestDegenerateHuffmanCoding. + if code != 1< huffmanChunkBits { + numLinks := 1 << (uint(max) - huffmanChunkBits) + h.linkMask = uint32(numLinks - 1) + + // create link tables + link := nextcode[huffmanChunkBits+1] >> 1 + h.links = make([][]uint32, huffmanNumChunks-link) + for j := uint(link); j < huffmanNumChunks; j++ { + reverse := int(reverseByte[j>>8]) | int(reverseByte[j&0xff])<<8 + reverse >>= uint(16 - huffmanChunkBits) + off := j - uint(link) + if sanity && h.chunks[reverse] != 0 { + panic("impossible: overwriting existing chunk") + } + h.chunks[reverse] = uint32(off<>8]) | int(reverseByte[code&0xff])<<8 + reverse >>= uint(16 - n) + if n <= huffmanChunkBits { + for off := reverse; off < len(h.chunks); off += 1 << uint(n) { + // We should never need to overwrite + // an existing chunk. Also, 0 is + // never a valid chunk, because the + // lower 4 "count" bits should be + // between 1 and 15. + if sanity && h.chunks[off] != 0 { + panic("impossible: overwriting existing chunk") + } + h.chunks[off] = chunk + } + } else { + j := reverse & (huffmanNumChunks - 1) + if sanity && h.chunks[j]&huffmanCountMask != huffmanChunkBits+1 { + // Longer codes should have been + // associated with a link table above. + panic("impossible: not an indirect chunk") + } + value := h.chunks[j] >> huffmanValueShift + linktab := h.links[value] + reverse >>= huffmanChunkBits + for off := reverse; off < len(linktab); off += 1 << uint(n-huffmanChunkBits) { + if sanity && linktab[off] != 0 { + panic("impossible: overwriting existing chunk") + } + linktab[off] = chunk + } + } + } + + if sanity { + // Above we've sanity checked that we never overwrote + // an existing entry. Here we additionally check that + // we filled the tables completely. + for i, chunk := range h.chunks { + if chunk == 0 { + // As an exception, in the degenerate + // single-code case, we allow odd + // chunks to be missing. + if code == 1 && i%2 == 1 { + continue + } + panic("impossible: missing chunk") + } + } + for _, linktab := range h.links { + for _, chunk := range linktab { + if chunk == 0 { + panic("impossible: missing chunk") + } + } + } + } + + return true +} + +// The actual read interface needed by NewReader. +// If the passed in io.Reader does not also have ReadByte, +// the NewReader will introduce its own buffering. +type Reader interface { + io.Reader + io.ByteReader +} + +// Decompress state. +type decompressor struct { + // Input source. + r Reader + roffset int64 + woffset int64 + + // Input bits, in top of b. + b uint32 + nb uint + + // Huffman decoders for literal/length, distance. + h1, h2 huffmanDecoder + + // Length arrays used to define Huffman codes. + bits *[maxNumLit + maxNumDist]int + codebits *[numCodes]int + + // Output history, buffer. + hist *[maxHist]byte + hp int // current output position in buffer + hw int // have written hist[0:hw] already + hfull bool // buffer has filled at least once + + // Temporary buffer (avoids repeated allocation). + buf [4]byte + + // Next step in the decompression, + // and decompression state. + step func(*decompressor) + final bool + err error + toRead []byte + hl, hd *huffmanDecoder + copyLen int + copyDist int +} + +func (f *decompressor) nextBlock() { + if f.final { + if f.hw != f.hp { + f.flush((*decompressor).nextBlock) + return + } + f.err = io.EOF + return + } + for f.nb < 1+2 { + if f.err = f.moreBits(); f.err != nil { + return + } + } + f.final = f.b&1 == 1 + f.b >>= 1 + typ := f.b & 3 + f.b >>= 2 + f.nb -= 1 + 2 + switch typ { + case 0: + f.dataBlock() + case 1: + // compressed, fixed Huffman tables + f.hl = &fixedHuffmanDecoder + f.hd = nil + f.huffmanBlock() + case 2: + // compressed, dynamic Huffman tables + if f.err = f.readHuffman(); f.err != nil { + break + } + f.hl = &f.h1 + f.hd = &f.h2 + f.huffmanBlock() + default: + // 3 is reserved. + f.err = CorruptInputError(f.roffset) + } +} + +func (f *decompressor) Read(b []byte) (int, error) { + for { + if len(f.toRead) > 0 { + n := copy(b, f.toRead) + f.toRead = f.toRead[n:] + return n, nil + } + if f.err != nil { + return 0, f.err + } + f.step(f) + } +} + +// Support the io.WriteTo interface for io.Copy and friends. +func (f *decompressor) WriteTo(w io.Writer) (int64, error) { + total := int64(0) + for { + if f.err != nil { + if f.err == io.EOF { + return total, nil + } + return total, f.err + } + if len(f.toRead) > 0 { + var n int + n, f.err = w.Write(f.toRead) + if f.err != nil { + return total, f.err + } + if n != len(f.toRead) { + return total, io.ErrShortWrite + } + f.toRead = f.toRead[:0] + total += int64(n) + } + f.step(f) + } +} + +func (f *decompressor) Close() error { + if f.err == io.EOF { + return nil + } + return f.err +} + +// RFC 1951 section 3.2.7. +// Compression with dynamic Huffman codes + +var codeOrder = [...]int{16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15} + +func (f *decompressor) readHuffman() error { + // HLIT[5], HDIST[5], HCLEN[4]. + for f.nb < 5+5+4 { + if err := f.moreBits(); err != nil { + return err + } + } + nlit := int(f.b&0x1F) + 257 + if nlit > maxNumLit { + return CorruptInputError(f.roffset) + } + f.b >>= 5 + ndist := int(f.b&0x1F) + 1 + if ndist > maxNumDist { + return CorruptInputError(f.roffset) + } + f.b >>= 5 + nclen := int(f.b&0xF) + 4 + // numCodes is 19, so nclen is always valid. + f.b >>= 4 + f.nb -= 5 + 5 + 4 + + // (HCLEN+4)*3 bits: code lengths in the magic codeOrder order. + for i := 0; i < nclen; i++ { + for f.nb < 3 { + if err := f.moreBits(); err != nil { + return err + } + } + f.codebits[codeOrder[i]] = int(f.b & 0x7) + f.b >>= 3 + f.nb -= 3 + } + for i := nclen; i < len(codeOrder); i++ { + f.codebits[codeOrder[i]] = 0 + } + if !f.h1.init(f.codebits[0:]) { + return CorruptInputError(f.roffset) + } + + // HLIT + 257 code lengths, HDIST + 1 code lengths, + // using the code length Huffman code. + for i, n := 0, nlit+ndist; i < n; { + x, err := f.huffSym(&f.h1) + if err != nil { + return err + } + if x < 16 { + // Actual length. + f.bits[i] = x + i++ + continue + } + // Repeat previous length or zero. + var rep int + var nb uint + var b int + switch x { + default: + return InternalError("unexpected length code") + case 16: + rep = 3 + nb = 2 + if i == 0 { + return CorruptInputError(f.roffset) + } + b = f.bits[i-1] + case 17: + rep = 3 + nb = 3 + b = 0 + case 18: + rep = 11 + nb = 7 + b = 0 + } + for f.nb < nb { + if err := f.moreBits(); err != nil { + return err + } + } + rep += int(f.b & uint32(1<>= nb + f.nb -= nb + if i+rep > n { + return CorruptInputError(f.roffset) + } + for j := 0; j < rep; j++ { + f.bits[i] = b + i++ + } + } + + if !f.h1.init(f.bits[0:nlit]) || !f.h2.init(f.bits[nlit:nlit+ndist]) { + return CorruptInputError(f.roffset) + } + + // In order to preserve the property that we never read any extra bytes + // after the end of the DEFLATE stream, huffSym conservatively reads min + // bits at a time until it decodes the symbol. However, since every block + // must end with an EOB marker, we can use that as the minimum number of + // bits to read and guarantee we never read past the end of the stream. + if f.bits[endBlockMarker] > 0 { + f.h1.min = f.bits[endBlockMarker] // Length of EOB marker + } + + return nil +} + +// Decode a single Huffman block from f. +// hl and hd are the Huffman states for the lit/length values +// and the distance values, respectively. If hd == nil, using the +// fixed distance encoding associated with fixed Huffman blocks. +func (f *decompressor) huffmanBlock() { + for { + v, err := f.huffSym(f.hl) + if err != nil { + f.err = err + return + } + var n uint // number of bits extra + var length int + switch { + case v < 256: + f.hist[f.hp] = byte(v) + f.hp++ + if f.hp == len(f.hist) { + // After the flush, continue this loop. + f.flush((*decompressor).huffmanBlock) + return + } + continue + case v == 256: + // Done with huffman block; read next block. + f.step = (*decompressor).nextBlock + return + // otherwise, reference to older data + case v < 265: + length = v - (257 - 3) + n = 0 + case v < 269: + length = v*2 - (265*2 - 11) + n = 1 + case v < 273: + length = v*4 - (269*4 - 19) + n = 2 + case v < 277: + length = v*8 - (273*8 - 35) + n = 3 + case v < 281: + length = v*16 - (277*16 - 67) + n = 4 + case v < 285: + length = v*32 - (281*32 - 131) + n = 5 + case v < maxNumLit: + length = 258 + n = 0 + default: + f.err = CorruptInputError(f.roffset) + return + } + if n > 0 { + for f.nb < n { + if err = f.moreBits(); err != nil { + f.err = err + return + } + } + length += int(f.b & uint32(1<>= n + f.nb -= n + } + + var dist int + if f.hd == nil { + for f.nb < 5 { + if err = f.moreBits(); err != nil { + f.err = err + return + } + } + dist = int(reverseByte[(f.b&0x1F)<<3]) + f.b >>= 5 + f.nb -= 5 + } else { + if dist, err = f.huffSym(f.hd); err != nil { + f.err = err + return + } + } + + switch { + case dist < 4: + dist++ + case dist < maxNumDist: + nb := uint(dist-2) >> 1 + // have 1 bit in bottom of dist, need nb more. + extra := (dist & 1) << nb + for f.nb < nb { + if err = f.moreBits(); err != nil { + f.err = err + return + } + } + extra |= int(f.b & uint32(1<>= nb + f.nb -= nb + dist = 1<<(nb+1) + 1 + extra + default: + f.err = CorruptInputError(f.roffset) + return + } + + // Copy history[-dist:-dist+length] into output. + if dist > len(f.hist) { + f.err = InternalError("bad history distance") + return + } + + // No check on length; encoding can be prescient. + if !f.hfull && dist > f.hp { + f.err = CorruptInputError(f.roffset) + return + } + + f.copyLen, f.copyDist = length, dist + if f.copyHist() { + return + } + } +} + +// copyHist copies f.copyLen bytes from f.hist (f.copyDist bytes ago) to itself. +// It reports whether the f.hist buffer is full. +func (f *decompressor) copyHist() bool { + p := f.hp - f.copyDist + if p < 0 { + p += len(f.hist) + } + for f.copyLen > 0 { + n := f.copyLen + if x := len(f.hist) - f.hp; n > x { + n = x + } + if x := len(f.hist) - p; n > x { + n = x + } + forwardCopy(f.hist[:], f.hp, p, n) + p += n + f.hp += n + f.copyLen -= n + if f.hp == len(f.hist) { + // After flush continue copying out of history. + f.flush((*decompressor).copyHuff) + return true + } + if p == len(f.hist) { + p = 0 + } + } + return false +} + +func (f *decompressor) copyHuff() { + if f.copyHist() { + return + } + f.huffmanBlock() +} + +// Copy a single uncompressed data block from input to output. +func (f *decompressor) dataBlock() { + // Uncompressed. + // Discard current half-byte. + f.nb = 0 + f.b = 0 + + // Length then ones-complement of length. + nr, err := io.ReadFull(f.r, f.buf[0:4]) + f.roffset += int64(nr) + if err != nil { + f.err = &ReadError{f.roffset, err} + return + } + n := int(f.buf[0]) | int(f.buf[1])<<8 + nn := int(f.buf[2]) | int(f.buf[3])<<8 + if uint16(nn) != uint16(^n) { + f.err = CorruptInputError(f.roffset) + return + } + + if n == 0 { + // 0-length block means sync + f.flush((*decompressor).nextBlock) + return + } + + f.copyLen = n + f.copyData() +} + +// copyData copies f.copyLen bytes from the underlying reader into f.hist. +// It pauses for reads when f.hist is full. +func (f *decompressor) copyData() { + n := f.copyLen + for n > 0 { + m := len(f.hist) - f.hp + if m > n { + m = n + } + m, err := io.ReadFull(f.r, f.hist[f.hp:f.hp+m]) + f.roffset += int64(m) + if err != nil { + f.err = &ReadError{f.roffset, err} + return + } + n -= m + f.hp += m + if f.hp == len(f.hist) { + f.copyLen = n + f.flush((*decompressor).copyData) + return + } + } + f.step = (*decompressor).nextBlock +} + +func (f *decompressor) setDict(dict []byte) { + if len(dict) > len(f.hist) { + // Will only remember the tail. + dict = dict[len(dict)-len(f.hist):] + } + + f.hp = copy(f.hist[:], dict) + if f.hp == len(f.hist) { + f.hp = 0 + f.hfull = true + } + f.hw = f.hp +} + +func (f *decompressor) moreBits() error { + c, err := f.r.ReadByte() + if err != nil { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + return err + } + f.roffset++ + f.b |= uint32(c) << f.nb + f.nb += 8 + return nil +} + +// Read the next Huffman-encoded symbol from f according to h. +func (f *decompressor) huffSym(h *huffmanDecoder) (int, error) { + // Since a huffmanDecoder can be empty or be composed of a degenerate tree + // with single element, huffSym must error on these two edge cases. In both + // cases, the chunks slice will be 0 for the invalid sequence, leading it + // satisfy the n == 0 check below. + n := uint(h.min) + for { + for f.nb < n { + if err := f.moreBits(); err != nil { + return 0, err + } + } + chunk := h.chunks[f.b&(huffmanNumChunks-1)] + n = uint(chunk & huffmanCountMask) + if n > huffmanChunkBits { + chunk = h.links[chunk>>huffmanValueShift][(f.b>>huffmanChunkBits)&h.linkMask] + n = uint(chunk & huffmanCountMask) + } + if n <= f.nb { + if n == 0 { + f.err = CorruptInputError(f.roffset) + return 0, f.err + } + f.b >>= n + f.nb -= n + return int(chunk >> huffmanValueShift), nil + } + } +} + +// Flush any buffered output to the underlying writer. +func (f *decompressor) flush(step func(*decompressor)) { + f.toRead = f.hist[f.hw:f.hp] + f.woffset += int64(f.hp - f.hw) + f.hw = f.hp + if f.hp == len(f.hist) { + f.hp = 0 + f.hw = 0 + f.hfull = true + } + f.step = step +} + +func makeReader(r io.Reader) Reader { + if rr, ok := r.(Reader); ok { + return rr + } + return bufio.NewReader(r) +} + +func (f *decompressor) Reset(r io.Reader, dict []byte) error { + *f = decompressor{ + r: makeReader(r), + bits: f.bits, + codebits: f.codebits, + hist: f.hist, + step: (*decompressor).nextBlock, + } + if dict != nil { + f.setDict(dict) + } + return nil +} + +// NewReader returns a new ReadCloser that can be used +// to read the uncompressed version of r. +// If r does not also implement io.ByteReader, +// the decompressor may read more data than necessary from r. +// It is the caller's responsibility to call Close on the ReadCloser +// when finished reading. +// +// The ReadCloser returned by NewReader also implements Resetter. +func NewReader(r io.Reader) io.ReadCloser { + var f decompressor + f.bits = new([maxNumLit + maxNumDist]int) + f.codebits = new([numCodes]int) + f.r = makeReader(r) + f.hist = new([maxHist]byte) + f.step = (*decompressor).nextBlock + return &f +} + +// NewReaderDict is like NewReader but initializes the reader +// with a preset dictionary. The returned Reader behaves as if +// the uncompressed data stream started with the given dictionary, +// which has already been read. NewReaderDict is typically used +// to read data compressed by NewWriterDict. +// +// The ReadCloser returned by NewReader also implements Resetter. +func NewReaderDict(r io.Reader, dict []byte) io.ReadCloser { + var f decompressor + f.r = makeReader(r) + f.hist = new([maxHist]byte) + f.bits = new([maxNumLit + maxNumDist]int) + f.codebits = new([numCodes]int) + f.step = (*decompressor).nextBlock + f.setDict(dict) + return &f +} diff --git a/Godeps/_workspace/src/github.com/klauspost/compress/flate/reverse_bits.go b/Godeps/_workspace/src/github.com/klauspost/compress/flate/reverse_bits.go new file mode 100644 index 0000000000..c1a02720d1 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/compress/flate/reverse_bits.go @@ -0,0 +1,48 @@ +// 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. + +package flate + +var reverseByte = [256]byte{ + 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, + 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, + 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, + 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, + 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, + 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, + 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, + 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, + 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, + 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, + 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, + 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, + 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, + 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, + 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, + 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, + 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, + 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, + 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, + 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, + 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, + 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, + 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, + 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, + 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, + 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, + 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, + 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, + 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, + 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, + 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, + 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, +} + +func reverseUint16(v uint16) uint16 { + return uint16(reverseByte[v>>8]) | uint16(reverseByte[v&0xFF])<<8 +} + +func reverseBits(number uint16, bitLength byte) uint16 { + return reverseUint16(number << uint8(16-bitLength)) +} diff --git a/Godeps/_workspace/src/github.com/klauspost/compress/flate/snappy.go b/Godeps/_workspace/src/github.com/klauspost/compress/flate/snappy.go new file mode 100644 index 0000000000..a7cbf351d0 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/compress/flate/snappy.go @@ -0,0 +1,768 @@ +// Copyright 2011 The Snappy-Go Authors. All rights reserved. +// Modified for deflate by Klaus Post (c) 2015. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package flate + +// We limit how far copy back-references can go, the same as the C++ code. +const maxOffset = 1 << 15 + +// emitLiteral writes a literal chunk and returns the number of bytes written. +func emitLiteral(dst *tokens, lit []byte) { + ol := dst.n + for i, v := range lit { + dst.tokens[i+ol] = token(v) + } + dst.n += len(lit) +} + +// emitCopy writes a copy chunk and returns the number of bytes written. +func emitCopy(dst *tokens, offset, length int) { + dst.tokens[dst.n] = matchToken(uint32(length-3), uint32(offset-minOffsetSize)) + dst.n++ +} + +type snappyEnc interface { + Encode(dst *tokens, src []byte) + Reset() +} + +func newSnappy(level int) snappyEnc { + if useSSE42 { + e := &snappySSE4{} + switch level { + case 3: + e.enc = e.encodeL3 + return e + } + } + e := &snappyGen{} + switch level { + case 1: + e.enc = e.encodeL1 + case 2: + e.enc = e.encodeL2 + case 3: + e.enc = e.encodeL3 + default: + panic("invalid level specified") + } + return e +} + +const tableBits = 14 // Bits used in the table +const tableSize = 1 << tableBits // Size of the table + +// snappyGen maintains the table for matches, +// and the previous byte block for level 2. +// This is the generic implementation. +type snappyGen struct { + table [tableSize]int64 + block [maxStoreBlockSize]byte + prev []byte + cur int + enc func(dst *tokens, src []byte) +} + +func (e *snappyGen) Encode(dst *tokens, src []byte) { + e.enc(dst, src) +} + +// EncodeL1 uses Snappy-like compression, but stores as Huffman +// blocks. +func (e *snappyGen) encodeL1(dst *tokens, src []byte) { + // Return early if src is short. + if len(src) <= 4 { + if len(src) != 0 { + emitLiteral(dst, src) + } + e.cur += 4 + return + } + + // Ensure that e.cur doesn't wrap, mainly an issue on 32 bits. + if e.cur > 1<<30 { + e.cur = 0 + } + + // Iterate over the source bytes. + var ( + s int // The iterator position. + t int // The last position with the same hash as s. + lit int // The start position of any pending literal bytes. + ) + + for s+3 < len(src) { + // Update the hash table. + b0, b1, b2, b3 := src[s], src[s+1], src[s+2], src[s+3] + h := uint32(b0) | uint32(b1)<<8 | uint32(b2)<<16 | uint32(b3)<<24 + p := &e.table[(h*0x1e35a7bd)>>(32-tableBits)] + // We need to to store values in [-1, inf) in table. To save + // some initialization time, (re)use the table's zero value + // and shift the values against this zero: add 1 on writes, + // subtract 1 on reads. + t, *p = int(*p)-1-e.cur, int64(s+1+e.cur) + + offset := uint(s - t - 1) + + // If t is invalid or src[s:s+4] differs from src[t:t+4], accumulate a literal byte. + if t < 0 || offset >= (maxOffset-1) || b0 != src[t] || b1 != src[t+1] || b2 != src[t+2] || b3 != src[t+3] { + // Skip 1 byte for 16 consecutive missed. + s += 1 + ((s - lit) >> 4) + continue + } + // Otherwise, we have a match. First, emit any pending literal bytes. + if lit != s { + emitLiteral(dst, src[lit:s]) + } + // Extend the match to be as long as possible. + s0 := s + s1 := s + maxMatchLength + if s1 > len(src) { + s1 = len(src) + } + s, t = s+4, t+4 + for s < s1 && src[s] == src[t] { + s++ + t++ + } + // Emit the copied bytes. + // inlined: emitCopy(dst, s-t, s-s0) + + dst.tokens[dst.n] = matchToken(uint32(s-s0-3), uint32(s-t-minOffsetSize)) + dst.n++ + lit = s + } + + // Emit any final pending literal bytes and return. + if lit != len(src) { + emitLiteral(dst, src[lit:]) + } + e.cur += len(src) +} + +// EncodeL2 uses a similar algorithm to level 1, but is capable +// of matching across blocks giving better compression at a small slowdown. +func (e *snappyGen) encodeL2(dst *tokens, src []byte) { + // Return early if src is short. + if len(src) <= 4 { + if len(src) != 0 { + emitLiteral(dst, src) + } + e.prev = nil + e.cur += len(src) + return + } + + // Ensure that e.cur doesn't wrap, mainly an issue on 32 bits. + if e.cur > 1<<30 { + e.cur = 0 + } + + // Iterate over the source bytes. + var ( + s int // The iterator position. + t int // The last position with the same hash as s. + lit int // The start position of any pending literal bytes. + ) + + for s+3 < len(src) { + // Update the hash table. + b0, b1, b2, b3 := src[s], src[s+1], src[s+2], src[s+3] + h := uint32(b0) | uint32(b1)<<8 | uint32(b2)<<16 | uint32(b3)<<24 + p := &e.table[(h*0x1e35a7bd)>>(32-tableBits)] + // We need to to store values in [-1, inf) in table. To save + // some initialization time, (re)use the table's zero value + // and shift the values against this zero: add 1 on writes, + // subtract 1 on reads. + t, *p = int(*p)-1-e.cur, int64(s+1+e.cur) + + // If t is positive, the match starts in the current block + if t >= 0 { + + offset := uint(s - t - 1) + // Check that the offset is valid and that we match at least 4 bytes + if offset >= (maxOffset-1) || b0 != src[t] || b1 != src[t+1] || b2 != src[t+2] || b3 != src[t+3] { + // Skip 1 byte for 32 consecutive missed. + s += 1 + ((s - lit) >> 5) + continue + } + // Otherwise, we have a match. First, emit any pending literal bytes. + if lit != s { + emitLiteral(dst, src[lit:s]) + } + // Extend the match to be as long as possible. + s0 := s + s1 := s + maxMatchLength + if s1 > len(src) { + s1 = len(src) + } + s, t = s+4, t+4 + for s < s1 && src[s] == src[t] { + s++ + t++ + } + // Emit the copied bytes. + // inlined: emitCopy(dst, s-t, s-s0) + dst.tokens[dst.n] = matchToken(uint32(s-s0-3), uint32(s-t-minOffsetSize)) + dst.n++ + lit = s + continue + } + // We found a match in the previous block. + tp := len(e.prev) + t + if tp < 0 || t > -5 || s-t >= maxOffset || b0 != e.prev[tp] || b1 != e.prev[tp+1] || b2 != e.prev[tp+2] || b3 != e.prev[tp+3] { + // Skip 1 byte for 32 consecutive missed. + s += 1 + ((s - lit) >> 5) + continue + } + // Otherwise, we have a match. First, emit any pending literal bytes. + if lit != s { + emitLiteral(dst, src[lit:s]) + } + // Extend the match to be as long as possible. + s0 := s + s1 := s + maxMatchLength + if s1 > len(src) { + s1 = len(src) + } + s, tp = s+4, tp+4 + for s < s1 && src[s] == e.prev[tp] { + s++ + tp++ + if tp == len(e.prev) { + t = 0 + // continue in current buffer + for s < s1 && src[s] == src[t] { + s++ + t++ + } + goto l + } + } + l: + // Emit the copied bytes. + if t < 0 { + t = tp - len(e.prev) + } + dst.tokens[dst.n] = matchToken(uint32(s-s0-3), uint32(s-t-minOffsetSize)) + dst.n++ + lit = s + + } + + // Emit any final pending literal bytes and return. + if lit != len(src) { + emitLiteral(dst, src[lit:]) + } + e.cur += len(src) + // Store this block, if it was full length. + if len(src) == maxStoreBlockSize { + copy(e.block[:], src) + e.prev = e.block[:len(src)] + } else { + e.prev = nil + } +} + +// EncodeL3 uses a similar algorithm to level 2, but is capable +// will keep two matches per hash. +// Both hashes are checked if the first isn't ok, and the longest is selected. +func (e *snappyGen) encodeL3(dst *tokens, src []byte) { + // Return early if src is short. + if len(src) <= 4 { + if len(src) != 0 { + emitLiteral(dst, src) + } + e.prev = nil + e.cur += len(src) + return + } + + // Ensure that e.cur doesn't wrap, mainly an issue on 32 bits. + if e.cur > 1<<30 { + e.cur = 0 + } + + // Iterate over the source bytes. + var ( + s int // The iterator position. + lit int // The start position of any pending literal bytes. + ) + + for s+3 < len(src) { + // Update the hash table. + h := uint32(src[s]) | uint32(src[s+1])<<8 | uint32(src[s+2])<<16 | uint32(src[s+3])<<24 + p := &e.table[(h*0x1e35a7bd)>>(32-tableBits)] + tmp := *p + p1 := int(tmp & 0xffffffff) // Closest match position + p2 := int(tmp >> 32) // Furthest match position + + // We need to to store values in [-1, inf) in table. To save + // some initialization time, (re)use the table's zero value + // and shift the values against this zero: add 1 on writes, + // subtract 1 on reads. + t1 := p1 - 1 - e.cur + + var l2 int + var t2 int + l1 := e.matchlen(s, t1, src) + // If fist match was ok, don't do the second. + if l1 < 16 { + t2 = p2 - 1 - e.cur + l2 = e.matchlen(s, t2, src) + + // If both are short, continue + if l1 < 4 && l2 < 4 { + // Update hash table + *p = int64(s+1+e.cur) | (int64(p1) << 32) + // Skip 1 byte for 32 consecutive missed. + s += 1 + ((s - lit) >> 5) + continue + } + } + + // Otherwise, we have a match. First, emit any pending literal bytes. + if lit != s { + emitLiteral(dst, src[lit:s]) + } + // Update hash table + *p = int64(s+1+e.cur) | (int64(p1) << 32) + + // Store the longest match l1 will be closest, so we prefer that if equal length + if l1 >= l2 { + dst.tokens[dst.n] = matchToken(uint32(l1-3), uint32(s-t1-minOffsetSize)) + s += l1 + } else { + dst.tokens[dst.n] = matchToken(uint32(l2-3), uint32(s-t2-minOffsetSize)) + s += l2 + } + dst.n++ + lit = s + } + + // Emit any final pending literal bytes and return. + if lit != len(src) { + emitLiteral(dst, src[lit:]) + } + e.cur += len(src) + // Store this block, if it was full length. + if len(src) == maxStoreBlockSize { + copy(e.block[:], src) + e.prev = e.block[:len(src)] + } else { + e.prev = nil + } +} + +func (e *snappyGen) matchlen(s, t int, src []byte) int { + // If t is invalid or src[s:s+4] differs from src[t:t+4], accumulate a literal byte. + offset := uint(s - t - 1) + + // If we are inside the current block + if t >= 0 { + if offset >= (maxOffset-1) || + src[s] != src[t] || src[s+1] != src[t+1] || + src[s+2] != src[t+2] || src[s+3] != src[t+3] { + return 0 + } + // Extend the match to be as long as possible. + s0 := s + s1 := s + maxMatchLength + if s1 > len(src) { + s1 = len(src) + } + s, t = s+4, t+4 + for s < s1 && src[s] == src[t] { + s++ + t++ + } + return s - s0 + } + + // We found a match in the previous block. + tp := len(e.prev) + t + if tp < 0 || offset >= (maxOffset-1) || t > -5 || + src[s] != e.prev[tp] || src[s+1] != e.prev[tp+1] || + src[s+2] != e.prev[tp+2] || src[s+3] != e.prev[tp+3] { + return 0 + } + + // Extend the match to be as long as possible. + s0 := s + s1 := s + maxMatchLength + if s1 > len(src) { + s1 = len(src) + } + s, tp = s+4, tp+4 + for s < s1 && src[s] == e.prev[tp] { + s++ + tp++ + if tp == len(e.prev) { + t = 0 + // continue in current buffer + for s < s1 && src[s] == src[t] { + s++ + t++ + } + return s - s0 + } + } + return s - s0 +} + +// Reset the encoding table. +func (e *snappyGen) Reset() { + e.prev = nil +} + +// snappySSE4 extends snappyGen. +// This implementation can use SSE 4.2 for length matching. +type snappySSE4 struct { + snappyGen +} + +/* +// EncodeL1 uses Snappy-like compression, but stores as Huffman +// blocks. +func (e *snappySSE4) encodeL1(dst *tokens, src []byte) { + // Return early if src is short. + if len(src) <= 4 { + if len(src) != 0 { + emitLiteral(dst, src) + } + e.cur += 4 + return + } + + // Ensure that e.cur doesn't wrap, mainly an issue on 32 bits. + if e.cur > 1<<30 { + e.cur = 0 + } + + // Iterate over the source bytes. + var ( + s int // The iterator position. + t int // The last position with the same hash as s. + lit int // The start position of any pending literal bytes. + ) + + for s+3 < len(src) { + // Update the hash table. + h := uint32(src[s]) | uint32(src[s+1])<<8 | uint32(src[s+2])<<16 | uint32(src[s+3])<<24 + p := &e.table[(h*0x1e35a7bd)>>(32-tableBits)] + // We need to to store values in [-1, inf) in table. To save + // some initialization time, (re)use the table's zero value + // and shift the values against this zero: add 1 on writes, + // subtract 1 on reads. + t, *p = int(*p)-1-e.cur, int64(s+1+e.cur) + + offset := uint(s - t - 1) + + // If t is invalid or src[s:s+4] differs from src[t:t+4], accumulate a literal byte. + if t < 0 || offset >= (maxOffset-1) { + // Skip 1 byte for 16 consecutive missed. + s += 1 + ((s - lit) >> 4) + continue + } + + length := len(src) - s + if length > maxMatchLength { + length = maxMatchLength + } + // Extend the match to be as long as possible. + match := matchLenSSE4(src[t:], src[s:], length) + + // Return if short. + if match < 4 { + s += 1 + (s-lit)>>4 + continue + } + + // Otherwise, we have a match. First, emit any pending literal bytes. + if lit != s { + emitLiteral(dst, src[lit:s]) + } + + dst.tokens[dst.n] = matchToken(uint32(match-3), uint32(offset)) + dst.n++ + s += match + lit = s + } + + // Emit any final pending literal bytes and return. + if lit != len(src) { + emitLiteral(dst, src[lit:]) + } + e.cur += len(src) +} + +// EncodeL2 uses a similar algorithm to level 1, but is capable +// of matching across blocks giving better compression at a small slowdown. +func (e *snappySSE4) encodeL2(dst *tokens, src []byte) { + // Return early if src is short. + if len(src) <= 4 { + if len(src) != 0 { + emitLiteral(dst, src) + } + e.prev = nil + e.cur += len(src) + return + } + + // Ensure that e.cur doesn't wrap, mainly an issue on 32 bits. + if e.cur > 1<<30 { + e.cur = 0 + } + + // Iterate over the source bytes. + var ( + s int // The iterator position. + t int // The last position with the same hash as s. + lit int // The start position of any pending literal bytes. + ) + + for s+3 < len(src) { + // Update the hash table. + b0, b1, b2, b3 := src[s], src[s+1], src[s+2], src[s+3] + h := uint32(b0) | uint32(b1)<<8 | uint32(b2)<<16 | uint32(b3)<<24 + p := &e.table[(h*0x1e35a7bd)>>(32-tableBits)] + // We need to to store values in [-1, inf) in table. To save + // some initialization time, (re)use the table's zero value + // and shift the values against this zero: add 1 on writes, + // subtract 1 on reads. + t, *p = int(*p)-1-e.cur, int64(s+1+e.cur) + + // If t is positive, the match starts in the current block + if t >= 0 { + offset := uint(s - t - 1) + + // If t is invalid or src[s:s+4] differs from src[t:t+4], accumulate a literal byte. + if t < 0 || offset >= (maxOffset-1) { + // Skip 1 byte for 16 consecutive missed. + s += 1 + ((s - lit) >> 5) + continue + } + + length := maxMatchLength + if length > len(src)-s { + length = len(src) - s + } + // Extend the match to be as long as possible. + match := matchLenSSE4(src[t:], src[s:], length) + + // Return if short. + if match < 4 { + s += 1 + (s-lit)>>5 + continue + } + + // Otherwise, we have a match. First, emit any pending literal bytes. + if lit != s { + emitLiteral(dst, src[lit:s]) + } + + dst.tokens[dst.n] = matchToken(uint32(match-3), uint32(offset)) + s += match + dst.n++ + lit = s + continue + } + + // We found a match in the previous block. + tp := len(e.prev) + t + if tp < 0 || t > -5 || s-t >= maxOffset || b0 != e.prev[tp] || b1 != e.prev[tp+1] || b2 != e.prev[tp+2] || b3 != e.prev[tp+3] { + // Skip 1 byte for 32 consecutive missed. + s += 1 + ((s - lit) >> 5) + continue + } + // Otherwise, we have a match. First, emit any pending literal bytes. + if lit != s { + emitLiteral(dst, src[lit:s]) + } + // Extend the match to be as long as possible. + s0 := s + s1 := s + maxMatchLength + if s1 > len(src) { + s1 = len(src) + } + s, tp = s+4, tp+4 + for s < s1 && src[s] == e.prev[tp] { + s++ + tp++ + if tp == len(e.prev) { + t = 0 + // continue in current buffer + for s < s1 && src[s] == src[t] { + s++ + t++ + } + goto l + } + } + l: + // Emit the copied bytes. + // inlined: emitCopy(dst, s-t, s-s0) + if t < 0 { + t = tp - len(e.prev) + } + dst.tokens[dst.n] = matchToken(uint32(s-s0-3), uint32(s-t-minOffsetSize)) + dst.n++ + lit = s + continue + + } + + // Emit any final pending literal bytes and return. + if lit != len(src) { + emitLiteral(dst, src[lit:]) + } + e.cur += len(src) + // Store this block, if it was full length. + if len(src) == maxStoreBlockSize { + copy(e.block[:], src) + e.prev = e.block[:len(src)] + } else { + e.prev = nil + } +} +*/ + +// EncodeL3 uses a similar algorithm to level 2, +// but will keep two matches per hash. +// Both hashes are checked if the first isn't ok, and the longest is selected. +func (e *snappySSE4) encodeL3(dst *tokens, src []byte) { + // Return early if src is short. + if len(src) <= 4 { + if len(src) != 0 { + emitLiteral(dst, src) + } + e.prev = nil + e.cur += len(src) + return + } + + // Ensure that e.cur doesn't wrap, mainly an issue on 32 bits. + if e.cur > 1<<30 { + e.cur = 0 + } + + // Iterate over the source bytes. + var ( + s int // The iterator position. + lit int // The start position of any pending literal bytes. + ) + + for s+3 < len(src) { + // Load potential matches from hash table. + h := uint32(src[s]) | uint32(src[s+1])<<8 | uint32(src[s+2])<<16 | uint32(src[s+3])<<24 + p := &e.table[(h*0x1e35a7bd)>>(32-tableBits)] + tmp := *p + p1 := int(tmp & 0xffffffff) // Closest match position + p2 := int(tmp >> 32) // Furthest match position + + // We need to to store values in [-1, inf) in table. To save + // some initialization time, (re)use the table's zero value + // and shift the values against this zero: add 1 on writes, + // subtract 1 on reads. + t1 := int(p1) - 1 - e.cur + + var l2 int + var t2 int + l1 := e.matchlen(s, t1, src) + // If fist match was ok, don't do the second. + if l1 < 16 { + t2 = int(p2) - 1 - e.cur + l2 = e.matchlen(s, t2, src) + + // If both are short, continue + if l1 < 4 && l2 < 4 { + // Update hash table + *p = int64(s+1+e.cur) | (int64(p1) << 32) + // Skip 1 byte for 32 consecutive missed. + s += 1 + ((s - lit) >> 5) + continue + } + } + + // Otherwise, we have a match. First, emit any pending literal bytes. + if lit != s { + emitLiteral(dst, src[lit:s]) + } + // Update hash table + *p = int64(s+1+e.cur) | (int64(p1) << 32) + + // Store the longest match l1 will be closest, so we prefer that if equal length + if l1 >= l2 { + dst.tokens[dst.n] = matchToken(uint32(l1-3), uint32(s-t1-minOffsetSize)) + s += l1 + } else { + dst.tokens[dst.n] = matchToken(uint32(l2-3), uint32(s-t2-minOffsetSize)) + s += l2 + } + dst.n++ + lit = s + } + + // Emit any final pending literal bytes and return. + if lit != len(src) { + emitLiteral(dst, src[lit:]) + } + e.cur += len(src) + // Store this block, if it was full length. + if len(src) == maxStoreBlockSize { + copy(e.block[:], src) + e.prev = e.block[:len(src)] + } else { + e.prev = nil + } +} + +func (e *snappySSE4) matchlen(s, t int, src []byte) int { + // If t is invalid or src[s:s+4] differs from src[t:t+4], accumulate a literal byte. + offset := uint(s - t - 1) + + // If we are inside the current block + if t >= 0 { + if offset >= (maxOffset - 1) { + return 0 + } + length := len(src) - s + if length > maxMatchLength { + length = maxMatchLength + } + // Extend the match to be as long as possible. + return matchLenSSE4(src[t:], src[s:], length) + } + + // We found a match in the previous block. + tp := len(e.prev) + t + if tp < 0 || offset >= (maxOffset-1) || t > -5 || + src[s] != e.prev[tp] || src[s+1] != e.prev[tp+1] || + src[s+2] != e.prev[tp+2] || src[s+3] != e.prev[tp+3] { + return 0 + } + + // Extend the match to be as long as possible. + s0 := s + s1 := s + maxMatchLength + if s1 > len(src) { + s1 = len(src) + } + s, tp = s+4, tp+4 + for s < s1 && src[s] == e.prev[tp] { + s++ + tp++ + if tp == len(e.prev) { + t = 0 + // continue in current buffer + for s < s1 && src[s] == src[t] { + s++ + t++ + } + return s - s0 + } + } + return s - s0 +} diff --git a/Godeps/_workspace/src/github.com/klauspost/compress/flate/token.go b/Godeps/_workspace/src/github.com/klauspost/compress/flate/token.go new file mode 100644 index 0000000000..94fa5eb93a --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/compress/flate/token.go @@ -0,0 +1,105 @@ +// 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. + +package flate + +const ( + // 2 bits: type 0 = literal 1=EOF 2=Match 3=Unused + // 8 bits: xlength = length - MIN_MATCH_LENGTH + // 22 bits xoffset = offset - MIN_OFFSET_SIZE, or literal + lengthShift = 22 + offsetMask = 1< pair into a match token. +func matchToken(xlength uint32, xoffset uint32) token { + return token(matchType + xlength<> lengthShift) } + +func lengthCode(len uint32) uint32 { return lengthCodes[len] } + +// Returns the offset code corresponding to a specific offset +func offsetCode(off uint32) uint32 { + if off < uint32(len(offsetCodes)) { + return offsetCodes[off] + } else if off>>7 < uint32(len(offsetCodes)) { + return offsetCodes[off>>7] + 14 + } else { + return offsetCodes[off>>14] + 28 + } +} diff --git a/Godeps/_workspace/src/github.com/klauspost/cpuid/.gitignore b/Godeps/_workspace/src/github.com/klauspost/cpuid/.gitignore new file mode 100644 index 0000000000..daf913b1b3 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/cpuid/.gitignore @@ -0,0 +1,24 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test +*.prof diff --git a/Godeps/_workspace/src/github.com/klauspost/cpuid/.travis.yml b/Godeps/_workspace/src/github.com/klauspost/cpuid/.travis.yml new file mode 100644 index 0000000000..bde823d8ab --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/cpuid/.travis.yml @@ -0,0 +1,8 @@ +language: go + +go: + - 1.3 + - 1.4 + - 1.5 + - 1.6 + - tip diff --git a/Godeps/_workspace/src/github.com/klauspost/cpuid/LICENSE b/Godeps/_workspace/src/github.com/klauspost/cpuid/LICENSE new file mode 100644 index 0000000000..5cec7ee949 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/cpuid/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Klaus Post + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/Godeps/_workspace/src/github.com/klauspost/cpuid/README.md b/Godeps/_workspace/src/github.com/klauspost/cpuid/README.md new file mode 100644 index 0000000000..b2b6bee879 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/cpuid/README.md @@ -0,0 +1,145 @@ +# cpuid +Package cpuid provides information about the CPU running the current program. + +CPU features are detected on startup, and kept for fast access through the life of the application. +Currently x86 / x64 (AMD64) is supported, and no external C (cgo) code is used, which should make the library very easy to use. + +You can access the CPU information by accessing the shared CPU variable of the cpuid library. + +Package home: https://github.com/klauspost/cpuid + +[![GoDoc][1]][2] [![Build Status][3]][4] + +[1]: https://godoc.org/github.com/klauspost/cpuid?status.svg +[2]: https://godoc.org/github.com/klauspost/cpuid +[3]: https://travis-ci.org/klauspost/cpuid.svg +[4]: https://travis-ci.org/klauspost/cpuid + +# features +## CPU Instructions +* **CMOV** (i686 CMOV) +* **NX** (NX (No-Execute) bit) +* **AMD3DNOW** (AMD 3DNOW) +* **AMD3DNOWEXT** (AMD 3DNowExt) +* **MMX** (standard MMX) +* **MMXEXT** (SSE integer functions or AMD MMX ext) +* **SSE** (SSE functions) +* **SSE2** (P4 SSE functions) +* **SSE3** (Prescott SSE3 functions) +* **SSSE3** (Conroe SSSE3 functions) +* **SSE4** (Penryn SSE4.1 functions) +* **SSE4A** (AMD Barcelona microarchitecture SSE4a instructions) +* **SSE42** (Nehalem SSE4.2 functions) +* **AVX** (AVX functions) +* **AVX2** (AVX2 functions) +* **FMA3** (Intel FMA 3) +* **FMA4** (Bulldozer FMA4 functions) +* **XOP** (Bulldozer XOP functions) +* **F16C** (Half-precision floating-point conversion) +* **BMI1** (Bit Manipulation Instruction Set 1) +* **BMI2** (Bit Manipulation Instruction Set 2) +* **TBM** (AMD Trailing Bit Manipulation) +* **LZCNT** (LZCNT instruction) +* **POPCNT** (POPCNT instruction) +* **AESNI** (Advanced Encryption Standard New Instructions) +* **CLMUL** (Carry-less Multiplication) +* **HTT** (Hyperthreading (enabled)) +* **HLE** (Hardware Lock Elision) +* **RTM** (Restricted Transactional Memory) +* **RDRAND** (RDRAND instruction is available) +* **RDSEED** (RDSEED instruction is available) +* **ADX** (Intel ADX (Multi-Precision Add-Carry Instruction Extensions)) +* **SHA** (Intel SHA Extensions) +* **AVX512F** (AVX-512 Foundation) +* **AVX512DQ** (AVX-512 Doubleword and Quadword Instructions) +* **AVX512IFMA** (AVX-512 Integer Fused Multiply-Add Instructions) +* **AVX512PF** (AVX-512 Prefetch Instructions) +* **AVX512ER** (AVX-512 Exponential and Reciprocal Instructions) +* **AVX512CD** (AVX-512 Conflict Detection Instructions) +* **AVX512BW** (AVX-512 Byte and Word Instructions) +* **AVX512VL** (AVX-512 Vector Length Extensions) +* **AVX512VBMI** (AVX-512 Vector Bit Manipulation Instructions) +* **MPX** (Intel MPX (Memory Protection Extensions)) +* **ERMS** (Enhanced REP MOVSB/STOSB) +* **RDTSCP** (RDTSCP Instruction) +* **CX16** (CMPXCHG16B Instruction) +* **SGX** (Software Guard Extensions, with activation details) + +## Performance +* **RDTSCP()** Returns current cycle count. Can be used for benchmarking. +* **SSE2SLOW** (SSE2 is supported, but usually not faster) +* **SSE3SLOW** (SSE3 is supported, but usually not faster) +* **ATOM** (Atom processor, some SSSE3 instructions are slower) +* **Cache line** (Probable size of a cache line). +* **L1, L2, L3 Cache size** on newer Intel/AMD CPUs. + +## Cpu Vendor/VM +* **Intel** +* **AMD** +* **VIA** +* **Transmeta** +* **NSC** +* **KVM** (Kernel-based Virtual Machine) +* **MSVM** (Microsoft Hyper-V or Windows Virtual PC) +* **VMware** +* **XenHVM** + +# installing + +```go get github.com/klauspost/cpuid``` + +# example + +```Go +package main + +import ( + "fmt" + "github.com/klauspost/cpuid" +) + +func main() { + // Print basic CPU information: + fmt.Println("Name:", cpuid.CPU.BrandName) + fmt.Println("PhysicalCores:", cpuid.CPU.PhysicalCores) + fmt.Println("ThreadsPerCore:", cpuid.CPU.ThreadsPerCore) + fmt.Println("LogicalCores:", cpuid.CPU.LogicalCores) + fmt.Println("Family", cpuid.CPU.Family, "Model:", cpuid.CPU.Model) + fmt.Println("Features:", cpuid.CPU.Features) + fmt.Println("Cacheline bytes:", cpuid.CPU.CacheLine) + fmt.Println("L1 Data Cache:", cpuid.CPU.Cache.L1D, "bytes") + fmt.Println("L1 Instruction Cache:", cpuid.CPU.Cache.L1D, "bytes") + fmt.Println("L2 Cache:", cpuid.CPU.Cache.L2, "bytes") + fmt.Println("L3 Cache:", cpuid.CPU.Cache.L3, "bytes") + + // Test if we have a specific feature: + if cpuid.CPU.SSE() { + fmt.Println("We have Streaming SIMD Extensions") + } +} +``` + +Sample output: +``` +>go run main.go +Name: Intel(R) Core(TM) i5-2540M CPU @ 2.60GHz +PhysicalCores: 2 +ThreadsPerCore: 2 +LogicalCores: 4 +Family 6 Model: 42 +Features: CMOV,MMX,MMXEXT,SSE,SSE2,SSE3,SSSE3,SSE4.1,SSE4.2,AVX,AESNI,CLMUL +Cacheline bytes: 64 +We have Streaming SIMD Extensions +``` + +# private package + +In the "private" folder you can find an autogenerated version of the library you can include in your own packages. + +For this purpose all exports are removed, and functions and constants are lowercased. + +This is not a recommended way of using the library, but provided for convenience, if it is difficult for you to use external packages. + +# license + +This code is published under an MIT license. See LICENSE file for more information. diff --git a/Godeps/_workspace/src/github.com/klauspost/cpuid/cpuid.go b/Godeps/_workspace/src/github.com/klauspost/cpuid/cpuid.go new file mode 100644 index 0000000000..9230ca5628 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/cpuid/cpuid.go @@ -0,0 +1,1022 @@ +// Copyright (c) 2015 Klaus Post, released under MIT License. See LICENSE file. + +// Package cpuid provides information about the CPU running the current program. +// +// CPU features are detected on startup, and kept for fast access through the life of the application. +// Currently x86 / x64 (AMD64) is supported. +// +// You can access the CPU information by accessing the shared CPU variable of the cpuid library. +// +// Package home: https://github.com/klauspost/cpuid +package cpuid + +import "strings" + +// Vendor is a representation of a CPU vendor. +type Vendor int + +const ( + Other Vendor = iota + Intel + AMD + VIA + Transmeta + NSC + KVM // Kernel-based Virtual Machine + MSVM // Microsoft Hyper-V or Windows Virtual PC + VMware + XenHVM +) + +const ( + CMOV = 1 << iota // i686 CMOV + NX // NX (No-Execute) bit + AMD3DNOW // AMD 3DNOW + AMD3DNOWEXT // AMD 3DNowExt + MMX // standard MMX + MMXEXT // SSE integer functions or AMD MMX ext + SSE // SSE functions + SSE2 // P4 SSE functions + SSE3 // Prescott SSE3 functions + SSSE3 // Conroe SSSE3 functions + SSE4 // Penryn SSE4.1 functions + SSE4A // AMD Barcelona microarchitecture SSE4a instructions + SSE42 // Nehalem SSE4.2 functions + AVX // AVX functions + AVX2 // AVX2 functions + FMA3 // Intel FMA 3 + FMA4 // Bulldozer FMA4 functions + XOP // Bulldozer XOP functions + F16C // Half-precision floating-point conversion + BMI1 // Bit Manipulation Instruction Set 1 + BMI2 // Bit Manipulation Instruction Set 2 + TBM // AMD Trailing Bit Manipulation + LZCNT // LZCNT instruction + POPCNT // POPCNT instruction + AESNI // Advanced Encryption Standard New Instructions + CLMUL // Carry-less Multiplication + HTT // Hyperthreading (enabled) + HLE // Hardware Lock Elision + RTM // Restricted Transactional Memory + RDRAND // RDRAND instruction is available + RDSEED // RDSEED instruction is available + ADX // Intel ADX (Multi-Precision Add-Carry Instruction Extensions) + SHA // Intel SHA Extensions + AVX512F // AVX-512 Foundation + AVX512DQ // AVX-512 Doubleword and Quadword Instructions + AVX512IFMA // AVX-512 Integer Fused Multiply-Add Instructions + AVX512PF // AVX-512 Prefetch Instructions + AVX512ER // AVX-512 Exponential and Reciprocal Instructions + AVX512CD // AVX-512 Conflict Detection Instructions + AVX512BW // AVX-512 Byte and Word Instructions + AVX512VL // AVX-512 Vector Length Extensions + AVX512VBMI // AVX-512 Vector Bit Manipulation Instructions + MPX // Intel MPX (Memory Protection Extensions) + ERMS // Enhanced REP MOVSB/STOSB + RDTSCP // RDTSCP Instruction + CX16 // CMPXCHG16B Instruction + SGX // Software Guard Extensions + + // Performance indicators + SSE2SLOW // SSE2 is supported, but usually not faster + SSE3SLOW // SSE3 is supported, but usually not faster + ATOM // Atom processor, some SSSE3 instructions are slower +) + +var flagNames = map[Flags]string{ + CMOV: "CMOV", // i686 CMOV + NX: "NX", // NX (No-Execute) bit + AMD3DNOW: "AMD3DNOW", // AMD 3DNOW + AMD3DNOWEXT: "AMD3DNOWEXT", // AMD 3DNowExt + MMX: "MMX", // Standard MMX + MMXEXT: "MMXEXT", // SSE integer functions or AMD MMX ext + SSE: "SSE", // SSE functions + SSE2: "SSE2", // P4 SSE2 functions + SSE3: "SSE3", // Prescott SSE3 functions + SSSE3: "SSSE3", // Conroe SSSE3 functions + SSE4: "SSE4.1", // Penryn SSE4.1 functions + SSE4A: "SSE4A", // AMD Barcelona microarchitecture SSE4a instructions + SSE42: "SSE4.2", // Nehalem SSE4.2 functions + AVX: "AVX", // AVX functions + AVX2: "AVX2", // AVX functions + FMA3: "FMA3", // Intel FMA 3 + FMA4: "FMA4", // Bulldozer FMA4 functions + XOP: "XOP", // Bulldozer XOP functions + F16C: "F16C", // Half-precision floating-point conversion + BMI1: "BMI1", // Bit Manipulation Instruction Set 1 + BMI2: "BMI2", // Bit Manipulation Instruction Set 2 + TBM: "TBM", // AMD Trailing Bit Manipulation + LZCNT: "LZCNT", // LZCNT instruction + POPCNT: "POPCNT", // POPCNT instruction + AESNI: "AESNI", // Advanced Encryption Standard New Instructions + CLMUL: "CLMUL", // Carry-less Multiplication + HTT: "HTT", // Hyperthreading (enabled) + HLE: "HLE", // Hardware Lock Elision + RTM: "RTM", // Restricted Transactional Memory + RDRAND: "RDRAND", // RDRAND instruction is available + RDSEED: "RDSEED", // RDSEED instruction is available + ADX: "ADX", // Intel ADX (Multi-Precision Add-Carry Instruction Extensions) + SHA: "SHA", // Intel SHA Extensions + AVX512F: "AVX512F", // AVX-512 Foundation + AVX512DQ: "AVX512DQ", // AVX-512 Doubleword and Quadword Instructions + AVX512IFMA: "AVX512IFMA", // AVX-512 Integer Fused Multiply-Add Instructions + AVX512PF: "AVX512PF", // AVX-512 Prefetch Instructions + AVX512ER: "AVX512ER", // AVX-512 Exponential and Reciprocal Instructions + AVX512CD: "AVX512CD", // AVX-512 Conflict Detection Instructions + AVX512BW: "AVX512BW", // AVX-512 Byte and Word Instructions + AVX512VL: "AVX512VL", // AVX-512 Vector Length Extensions + AVX512VBMI: "AVX512VBMI", // AVX-512 Vector Bit Manipulation Instructions + MPX: "MPX", // Intel MPX (Memory Protection Extensions) + ERMS: "ERMS", // Enhanced REP MOVSB/STOSB + RDTSCP: "RDTSCP", // RDTSCP Instruction + CX16: "CX16", // CMPXCHG16B Instruction + SGX: "SGX", // Software Guard Extensions + + // Performance indicators + SSE2SLOW: "SSE2SLOW", // SSE2 supported, but usually not faster + SSE3SLOW: "SSE3SLOW", // SSE3 supported, but usually not faster + ATOM: "ATOM", // Atom processor, some SSSE3 instructions are slower + +} + +// CPUInfo contains information about the detected system CPU. +type CPUInfo struct { + BrandName string // Brand name reported by the CPU + VendorID Vendor // Comparable CPU vendor ID + Features Flags // Features of the CPU + PhysicalCores int // Number of physical processor cores in your CPU. Will be 0 if undetectable. + ThreadsPerCore int // Number of threads per physical core. Will be 1 if undetectable. + LogicalCores int // Number of physical cores times threads that can run on each core through the use of hyperthreading. Will be 0 if undetectable. + Family int // CPU family number + Model int // CPU model number + CacheLine int // Cache line size in bytes. Will be 0 if undetectable. + Cache struct { + L1I int // L1 Instruction Cache (per core or shared). Will be -1 if undetected + L1D int // L1 Data Cache (per core or shared). Will be -1 if undetected + L2 int // L2 Cache (per core or shared). Will be -1 if undetected + L3 int // L3 Instruction Cache (per core or shared). Will be -1 if undetected + } + SGX SGXSupport + maxFunc uint32 + maxExFunc uint32 +} + +var cpuid func(op uint32) (eax, ebx, ecx, edx uint32) +var cpuidex func(op, op2 uint32) (eax, ebx, ecx, edx uint32) +var xgetbv func(index uint32) (eax, edx uint32) +var rdtscpAsm func() (eax, ebx, ecx, edx uint32) + +// CPU contains information about the CPU as detected on startup, +// or when Detect last was called. +// +// Use this as the primary entry point to you data, +// this way queries are +var CPU CPUInfo + +func init() { + initCPU() + Detect() +} + +// Detect will re-detect current CPU info. +// This will replace the content of the exported CPU variable. +// +// Unless you expect the CPU to change while you are running your program +// you should not need to call this function. +// If you call this, you must ensure that no other goroutine is accessing the +// exported CPU variable. +func Detect() { + CPU.maxFunc = maxFunctionID() + CPU.maxExFunc = maxExtendedFunction() + CPU.BrandName = brandName() + CPU.CacheLine = cacheLine() + CPU.Family, CPU.Model = familyModel() + CPU.Features = support() + CPU.SGX = sgx(CPU.Features&SGX != 0) + CPU.ThreadsPerCore = threadsPerCore() + CPU.LogicalCores = logicalCores() + CPU.PhysicalCores = physicalCores() + CPU.VendorID = vendorID() + CPU.cacheSize() +} + +// Generated here: http://play.golang.org/p/BxFH2Gdc0G + +// Cmov indicates support of CMOV instructions +func (c CPUInfo) Cmov() bool { + return c.Features&CMOV != 0 +} + +// Amd3dnow indicates support of AMD 3DNOW! instructions +func (c CPUInfo) Amd3dnow() bool { + return c.Features&AMD3DNOW != 0 +} + +// Amd3dnowExt indicates support of AMD 3DNOW! Extended instructions +func (c CPUInfo) Amd3dnowExt() bool { + return c.Features&AMD3DNOWEXT != 0 +} + +// MMX indicates support of MMX instructions +func (c CPUInfo) MMX() bool { + return c.Features&MMX != 0 +} + +// MMXExt indicates support of MMXEXT instructions +// (SSE integer functions or AMD MMX ext) +func (c CPUInfo) MMXExt() bool { + return c.Features&MMXEXT != 0 +} + +// SSE indicates support of SSE instructions +func (c CPUInfo) SSE() bool { + return c.Features&SSE != 0 +} + +// SSE2 indicates support of SSE 2 instructions +func (c CPUInfo) SSE2() bool { + return c.Features&SSE2 != 0 +} + +// SSE3 indicates support of SSE 3 instructions +func (c CPUInfo) SSE3() bool { + return c.Features&SSE3 != 0 +} + +// SSSE3 indicates support of SSSE 3 instructions +func (c CPUInfo) SSSE3() bool { + return c.Features&SSSE3 != 0 +} + +// SSE4 indicates support of SSE 4 (also called SSE 4.1) instructions +func (c CPUInfo) SSE4() bool { + return c.Features&SSE4 != 0 +} + +// SSE42 indicates support of SSE4.2 instructions +func (c CPUInfo) SSE42() bool { + return c.Features&SSE42 != 0 +} + +// AVX indicates support of AVX instructions +// and operating system support of AVX instructions +func (c CPUInfo) AVX() bool { + return c.Features&AVX != 0 +} + +// AVX2 indicates support of AVX2 instructions +func (c CPUInfo) AVX2() bool { + return c.Features&AVX2 != 0 +} + +// FMA3 indicates support of FMA3 instructions +func (c CPUInfo) FMA3() bool { + return c.Features&FMA3 != 0 +} + +// FMA4 indicates support of FMA4 instructions +func (c CPUInfo) FMA4() bool { + return c.Features&FMA4 != 0 +} + +// XOP indicates support of XOP instructions +func (c CPUInfo) XOP() bool { + return c.Features&XOP != 0 +} + +// F16C indicates support of F16C instructions +func (c CPUInfo) F16C() bool { + return c.Features&F16C != 0 +} + +// BMI1 indicates support of BMI1 instructions +func (c CPUInfo) BMI1() bool { + return c.Features&BMI1 != 0 +} + +// BMI2 indicates support of BMI2 instructions +func (c CPUInfo) BMI2() bool { + return c.Features&BMI2 != 0 +} + +// TBM indicates support of TBM instructions +// (AMD Trailing Bit Manipulation) +func (c CPUInfo) TBM() bool { + return c.Features&TBM != 0 +} + +// Lzcnt indicates support of LZCNT instruction +func (c CPUInfo) Lzcnt() bool { + return c.Features&LZCNT != 0 +} + +// Popcnt indicates support of POPCNT instruction +func (c CPUInfo) Popcnt() bool { + return c.Features&POPCNT != 0 +} + +// HTT indicates the processor has Hyperthreading enabled +func (c CPUInfo) HTT() bool { + return c.Features&HTT != 0 +} + +// SSE2Slow indicates that SSE2 may be slow on this processor +func (c CPUInfo) SSE2Slow() bool { + return c.Features&SSE2SLOW != 0 +} + +// SSE3Slow indicates that SSE3 may be slow on this processor +func (c CPUInfo) SSE3Slow() bool { + return c.Features&SSE3SLOW != 0 +} + +// AesNi indicates support of AES-NI instructions +// (Advanced Encryption Standard New Instructions) +func (c CPUInfo) AesNi() bool { + return c.Features&AESNI != 0 +} + +// Clmul indicates support of CLMUL instructions +// (Carry-less Multiplication) +func (c CPUInfo) Clmul() bool { + return c.Features&CLMUL != 0 +} + +// NX indicates support of NX (No-Execute) bit +func (c CPUInfo) NX() bool { + return c.Features&NX != 0 +} + +// SSE4A indicates support of AMD Barcelona microarchitecture SSE4a instructions +func (c CPUInfo) SSE4A() bool { + return c.Features&SSE4A != 0 +} + +// HLE indicates support of Hardware Lock Elision +func (c CPUInfo) HLE() bool { + return c.Features&HLE != 0 +} + +// RTM indicates support of Restricted Transactional Memory +func (c CPUInfo) RTM() bool { + return c.Features&RTM != 0 +} + +// Rdrand indicates support of RDRAND instruction is available +func (c CPUInfo) Rdrand() bool { + return c.Features&RDRAND != 0 +} + +// Rdseed indicates support of RDSEED instruction is available +func (c CPUInfo) Rdseed() bool { + return c.Features&RDSEED != 0 +} + +// ADX indicates support of Intel ADX (Multi-Precision Add-Carry Instruction Extensions) +func (c CPUInfo) ADX() bool { + return c.Features&ADX != 0 +} + +// SHA indicates support of Intel SHA Extensions +func (c CPUInfo) SHA() bool { + return c.Features&SHA != 0 +} + +// AVX512F indicates support of AVX-512 Foundation +func (c CPUInfo) AVX512F() bool { + return c.Features&AVX512F != 0 +} + +// AVX512DQ indicates support of AVX-512 Doubleword and Quadword Instructions +func (c CPUInfo) AVX512DQ() bool { + return c.Features&AVX512DQ != 0 +} + +// AVX512IFMA indicates support of AVX-512 Integer Fused Multiply-Add Instructions +func (c CPUInfo) AVX512IFMA() bool { + return c.Features&AVX512IFMA != 0 +} + +// AVX512PF indicates support of AVX-512 Prefetch Instructions +func (c CPUInfo) AVX512PF() bool { + return c.Features&AVX512PF != 0 +} + +// AVX512ER indicates support of AVX-512 Exponential and Reciprocal Instructions +func (c CPUInfo) AVX512ER() bool { + return c.Features&AVX512ER != 0 +} + +// AVX512CD indicates support of AVX-512 Conflict Detection Instructions +func (c CPUInfo) AVX512CD() bool { + return c.Features&AVX512CD != 0 +} + +// AVX512BW indicates support of AVX-512 Byte and Word Instructions +func (c CPUInfo) AVX512BW() bool { + return c.Features&AVX512BW != 0 +} + +// AVX512VL indicates support of AVX-512 Vector Length Extensions +func (c CPUInfo) AVX512VL() bool { + return c.Features&AVX512VL != 0 +} + +// AVX512VBMI indicates support of AVX-512 Vector Bit Manipulation Instructions +func (c CPUInfo) AVX512VBMI() bool { + return c.Features&AVX512VBMI != 0 +} + +// MPX indicates support of Intel MPX (Memory Protection Extensions) +func (c CPUInfo) MPX() bool { + return c.Features&MPX != 0 +} + +// ERMS indicates support of Enhanced REP MOVSB/STOSB +func (c CPUInfo) ERMS() bool { + return c.Features&ERMS != 0 +} + +func (c CPUInfo) RDTSCP() bool { + return c.Features&RDTSCP != 0 +} + +func (c CPUInfo) CX16() bool { + return c.Features&CX16 != 0 +} + +// Atom indicates an Atom processor +func (c CPUInfo) Atom() bool { + return c.Features&ATOM != 0 +} + +// Intel returns true if vendor is recognized as Intel +func (c CPUInfo) Intel() bool { + return c.VendorID == Intel +} + +// AMD returns true if vendor is recognized as AMD +func (c CPUInfo) AMD() bool { + return c.VendorID == AMD +} + +// Transmeta returns true if vendor is recognized as Transmeta +func (c CPUInfo) Transmeta() bool { + return c.VendorID == Transmeta +} + +// NSC returns true if vendor is recognized as National Semiconductor +func (c CPUInfo) NSC() bool { + return c.VendorID == NSC +} + +// VIA returns true if vendor is recognized as VIA +func (c CPUInfo) VIA() bool { + return c.VendorID == VIA +} + +// RTCounter returns the 64-bit time-stamp counter +// Uses the RDTSCP instruction. The value 0 is returned +// if the CPU does not support the instruction. +func (c CPUInfo) RTCounter() uint64 { + if !c.RDTSCP() { + return 0 + } + a, _, _, d := rdtscpAsm() + return uint64(a) | (uint64(d) << 32) +} + +// Ia32TscAux returns the IA32_TSC_AUX part of the RDTSCP. +// This variable is OS dependent, but on Linux contains information +// about the current cpu/core the code is running on. +// If the RDTSCP instruction isn't supported on the CPU, the value 0 is returned. +func (c CPUInfo) Ia32TscAux() uint32 { + if !c.RDTSCP() { + return 0 + } + _, _, ecx, _ := rdtscpAsm() + return ecx +} + +// LogicalCPU will return the Logical CPU the code is currently executing on. +// This is likely to change when the OS re-schedules the running thread +// to another CPU. +// If the current core cannot be detected, -1 will be returned. +func (c CPUInfo) LogicalCPU() int { + if c.maxFunc < 1 { + return -1 + } + _, ebx, _, _ := cpuid(1) + return int(ebx >> 24) +} + +// VM Will return true if the cpu id indicates we are in +// a virtual machine. This is only a hint, and will very likely +// have many false negatives. +func (c CPUInfo) VM() bool { + switch c.VendorID { + case MSVM, KVM, VMware, XenHVM: + return true + } + return false +} + +// Flags contains detected cpu features and caracteristics +type Flags uint64 + +// String returns a string representation of the detected +// CPU features. +func (f Flags) String() string { + return strings.Join(f.Strings(), ",") +} + +// Strings returns and array of the detected features. +func (f Flags) Strings() []string { + s := support() + r := make([]string, 0, 20) + for i := uint(0); i < 64; i++ { + key := Flags(1 << i) + val := flagNames[key] + if s&key != 0 { + r = append(r, val) + } + } + return r +} + +func maxExtendedFunction() uint32 { + eax, _, _, _ := cpuid(0x80000000) + return eax +} + +func maxFunctionID() uint32 { + a, _, _, _ := cpuid(0) + return a +} + +func brandName() string { + if maxExtendedFunction() >= 0x80000004 { + v := make([]uint32, 0, 48) + for i := uint32(0); i < 3; i++ { + a, b, c, d := cpuid(0x80000002 + i) + v = append(v, a, b, c, d) + } + return strings.Trim(string(valAsString(v...)), " ") + } + return "unknown" +} + +func threadsPerCore() int { + mfi := maxFunctionID() + if mfi < 0x4 || vendorID() != Intel { + return 1 + } + + if mfi < 0xb { + _, b, _, d := cpuid(1) + if (d & (1 << 28)) != 0 { + // v will contain logical core count + v := (b >> 16) & 255 + if v > 1 { + a4, _, _, _ := cpuid(4) + // physical cores + v2 := (a4 >> 26) + 1 + if v2 > 0 { + return int(v) / int(v2) + } + } + } + return 1 + } + _, b, _, _ := cpuidex(0xb, 0) + if b&0xffff == 0 { + return 1 + } + return int(b & 0xffff) +} + +func logicalCores() int { + mfi := maxFunctionID() + switch vendorID() { + case Intel: + // Use this on old Intel processors + if mfi < 0xb { + if mfi < 1 { + return 0 + } + // CPUID.1:EBX[23:16] represents the maximum number of addressable IDs (initial APIC ID) + // that can be assigned to logical processors in a physical package. + // The value may not be the same as the number of logical processors that are present in the hardware of a physical package. + _, ebx, _, _ := cpuid(1) + logical := (ebx >> 16) & 0xff + return int(logical) + } + _, b, _, _ := cpuidex(0xb, 1) + return int(b & 0xffff) + case AMD: + _, b, _, _ := cpuid(1) + return int((b >> 16) & 0xff) + default: + return 0 + } +} + +func familyModel() (int, int) { + if maxFunctionID() < 0x1 { + return 0, 0 + } + eax, _, _, _ := cpuid(1) + family := ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff) + model := ((eax >> 4) & 0xf) + ((eax >> 12) & 0xf0) + return int(family), int(model) +} + +func physicalCores() int { + switch vendorID() { + case Intel: + return logicalCores() / threadsPerCore() + case AMD: + if maxExtendedFunction() >= 0x80000008 { + _, _, c, _ := cpuid(0x80000008) + return int(c&0xff) + 1 + } + } + return 0 +} + +// Except from http://en.wikipedia.org/wiki/CPUID#EAX.3D0:_Get_vendor_ID +var vendorMapping = map[string]Vendor{ + "AMDisbetter!": AMD, + "AuthenticAMD": AMD, + "CentaurHauls": VIA, + "GenuineIntel": Intel, + "TransmetaCPU": Transmeta, + "GenuineTMx86": Transmeta, + "Geode by NSC": NSC, + "VIA VIA VIA ": VIA, + "KVMKVMKVMKVM": KVM, + "Microsoft Hv": MSVM, + "VMwareVMware": VMware, + "XenVMMXenVMM": XenHVM, +} + +func vendorID() Vendor { + _, b, c, d := cpuid(0) + v := valAsString(b, d, c) + vend, ok := vendorMapping[string(v)] + if !ok { + return Other + } + return vend +} + +func cacheLine() int { + if maxFunctionID() < 0x1 { + return 0 + } + + _, ebx, _, _ := cpuid(1) + cache := (ebx & 0xff00) >> 5 // cflush size + if cache == 0 && maxExtendedFunction() >= 0x80000006 { + _, _, ecx, _ := cpuid(0x80000006) + cache = ecx & 0xff // cacheline size + } + // TODO: Read from Cache and TLB Information + return int(cache) +} + +func (c *CPUInfo) cacheSize() { + c.Cache.L1D = -1 + c.Cache.L1I = -1 + c.Cache.L2 = -1 + c.Cache.L3 = -1 + vendor := vendorID() + switch vendor { + case Intel: + if maxFunctionID() < 4 { + return + } + for i := uint32(0); ; i++ { + eax, ebx, ecx, _ := cpuidex(4, i) + cacheType := eax & 15 + if cacheType == 0 { + break + } + cacheLevel := (eax >> 5) & 7 + coherency := int(ebx&0xfff) + 1 + partitions := int((ebx>>12)&0x3ff) + 1 + associativity := int((ebx>>22)&0x3ff) + 1 + sets := int(ecx) + 1 + size := associativity * partitions * coherency * sets + switch cacheLevel { + case 1: + if cacheType == 1 { + // 1 = Data Cache + c.Cache.L1D = size + } else if cacheType == 2 { + // 2 = Instruction Cache + c.Cache.L1I = size + } else { + if c.Cache.L1D < 0 { + c.Cache.L1I = size + } + if c.Cache.L1I < 0 { + c.Cache.L1I = size + } + } + case 2: + c.Cache.L2 = size + case 3: + c.Cache.L3 = size + } + } + case AMD: + // Untested. + if maxExtendedFunction() < 0x80000005 { + return + } + _, _, ecx, edx := cpuid(0x80000005) + c.Cache.L1D = int(((ecx >> 24) & 0xFF) * 1024) + c.Cache.L1I = int(((edx >> 24) & 0xFF) * 1024) + + if maxExtendedFunction() < 0x80000006 { + return + } + _, _, ecx, _ = cpuid(0x80000006) + c.Cache.L2 = int(((ecx >> 16) & 0xFFFF) * 1024) + } + + return +} + +type SGXSupport struct { + Available bool + SGX1Supported bool + SGX2Supported bool + MaxEnclaveSizeNot64 int64 + MaxEnclaveSize64 int64 +} + +func sgx(available bool) (rval SGXSupport) { + rval.Available = available + + if !available { + return + } + + a, _, _, d := cpuidex(0x12, 0) + rval.SGX1Supported = a&0x01 != 0 + rval.SGX2Supported = a&0x02 != 0 + rval.MaxEnclaveSizeNot64 = 1 << (d & 0xFF) // pow 2 + rval.MaxEnclaveSize64 = 1 << ((d >> 8) & 0xFF) // pow 2 + + return +} + +func support() Flags { + mfi := maxFunctionID() + vend := vendorID() + if mfi < 0x1 { + return 0 + } + rval := uint64(0) + _, _, c, d := cpuid(1) + if (d & (1 << 15)) != 0 { + rval |= CMOV + } + if (d & (1 << 23)) != 0 { + rval |= MMX + } + if (d & (1 << 25)) != 0 { + rval |= MMXEXT + } + if (d & (1 << 25)) != 0 { + rval |= SSE + } + if (d & (1 << 26)) != 0 { + rval |= SSE2 + } + if (c & 1) != 0 { + rval |= SSE3 + } + if (c & 0x00000200) != 0 { + rval |= SSSE3 + } + if (c & 0x00080000) != 0 { + rval |= SSE4 + } + if (c & 0x00100000) != 0 { + rval |= SSE42 + } + if (c & (1 << 25)) != 0 { + rval |= AESNI + } + if (c & (1 << 1)) != 0 { + rval |= CLMUL + } + if c&(1<<23) != 0 { + rval |= POPCNT + } + if c&(1<<30) != 0 { + rval |= RDRAND + } + if c&(1<<29) != 0 { + rval |= F16C + } + if c&(1<<13) != 0 { + rval |= CX16 + } + if vend == Intel && (d&(1<<28)) != 0 && mfi >= 4 { + if threadsPerCore() > 1 { + rval |= HTT + } + } + + // Check XGETBV, OXSAVE and AVX bits + if c&(1<<26) != 0 && c&(1<<27) != 0 && c&(1<<28) != 0 { + // Check for OS support + eax, _ := xgetbv(0) + if (eax & 0x6) == 0x6 { + rval |= AVX + if (c & 0x00001000) != 0 { + rval |= FMA3 + } + } + } + + // Check AVX2, AVX2 requires OS support, but BMI1/2 don't. + if mfi >= 7 { + _, ebx, ecx, _ := cpuidex(7, 0) + if (rval&AVX) != 0 && (ebx&0x00000020) != 0 { + rval |= AVX2 + } + if (ebx & 0x00000008) != 0 { + rval |= BMI1 + if (ebx & 0x00000100) != 0 { + rval |= BMI2 + } + } + if ebx&(1<<2) != 0 { + rval |= SGX + } + if ebx&(1<<4) != 0 { + rval |= HLE + } + if ebx&(1<<9) != 0 { + rval |= ERMS + } + if ebx&(1<<11) != 0 { + rval |= RTM + } + if ebx&(1<<14) != 0 { + rval |= MPX + } + if ebx&(1<<18) != 0 { + rval |= RDSEED + } + if ebx&(1<<19) != 0 { + rval |= ADX + } + if ebx&(1<<29) != 0 { + rval |= SHA + } + + // Only detect AVX-512 features if XGETBV is supported + if c&((1<<26)|(1<<27)) == (1<<26)|(1<<27) { + // Check for OS support + eax, _ := xgetbv(0) + + // Verify that XCR0[7:5] = ‘111b’ (OPMASK state, upper 256-bit of ZMM0-ZMM15 and + // ZMM16-ZMM31 state are enabled by OS) + /// and that XCR0[2:1] = ‘11b’ (XMM state and YMM state are enabled by OS). + if (eax>>5)&7 == 7 && (eax>>1)&3 == 3 { + if ebx&(1<<16) != 0 { + rval |= AVX512F + } + if ebx&(1<<17) != 0 { + rval |= AVX512DQ + } + if ebx&(1<<21) != 0 { + rval |= AVX512IFMA + } + if ebx&(1<<26) != 0 { + rval |= AVX512PF + } + if ebx&(1<<27) != 0 { + rval |= AVX512ER + } + if ebx&(1<<28) != 0 { + rval |= AVX512CD + } + if ebx&(1<<30) != 0 { + rval |= AVX512BW + } + if ebx&(1<<31) != 0 { + rval |= AVX512VL + } + // ecx + if ecx&(1<<1) != 0 { + rval |= AVX512VBMI + } + } + } + } + + if maxExtendedFunction() >= 0x80000001 { + _, _, c, d := cpuid(0x80000001) + if (c & (1 << 5)) != 0 { + rval |= LZCNT + rval |= POPCNT + } + if (d & (1 << 31)) != 0 { + rval |= AMD3DNOW + } + if (d & (1 << 30)) != 0 { + rval |= AMD3DNOWEXT + } + if (d & (1 << 23)) != 0 { + rval |= MMX + } + if (d & (1 << 22)) != 0 { + rval |= MMXEXT + } + if (c & (1 << 6)) != 0 { + rval |= SSE4A + } + if d&(1<<20) != 0 { + rval |= NX + } + if d&(1<<27) != 0 { + rval |= RDTSCP + } + + /* Allow for selectively disabling SSE2 functions on AMD processors + with SSE2 support but not SSE4a. This includes Athlon64, some + Opteron, and some Sempron processors. MMX, SSE, or 3DNow! are faster + than SSE2 often enough to utilize this special-case flag. + AV_CPU_FLAG_SSE2 and AV_CPU_FLAG_SSE2SLOW are both set in this case + so that SSE2 is used unless explicitly disabled by checking + AV_CPU_FLAG_SSE2SLOW. */ + if vendorID() != Intel && + rval&SSE2 != 0 && (c&0x00000040) == 0 { + rval |= SSE2SLOW + } + + /* XOP and FMA4 use the AVX instruction coding scheme, so they can't be + * used unless the OS has AVX support. */ + if (rval & AVX) != 0 { + if (c & 0x00000800) != 0 { + rval |= XOP + } + if (c & 0x00010000) != 0 { + rval |= FMA4 + } + } + + if vendorID() == Intel { + family, model := familyModel() + if family == 6 && (model == 9 || model == 13 || model == 14) { + /* 6/9 (pentium-m "banias"), 6/13 (pentium-m "dothan"), and + * 6/14 (core1 "yonah") theoretically support sse2, but it's + * usually slower than mmx. */ + if (rval & SSE2) != 0 { + rval |= SSE2SLOW + } + if (rval & SSE3) != 0 { + rval |= SSE3SLOW + } + } + /* The Atom processor has SSSE3 support, which is useful in many cases, + * but sometimes the SSSE3 version is slower than the SSE2 equivalent + * on the Atom, but is generally faster on other processors supporting + * SSSE3. This flag allows for selectively disabling certain SSSE3 + * functions on the Atom. */ + if family == 6 && model == 28 { + rval |= ATOM + } + } + } + return Flags(rval) +} + +func valAsString(values ...uint32) []byte { + r := make([]byte, 4*len(values)) + for i, v := range values { + dst := r[i*4:] + dst[0] = byte(v & 0xff) + dst[1] = byte((v >> 8) & 0xff) + dst[2] = byte((v >> 16) & 0xff) + dst[3] = byte((v >> 24) & 0xff) + switch { + case dst[0] == 0: + return r[:i*4] + case dst[1] == 0: + return r[:i*4+1] + case dst[2] == 0: + return r[:i*4+2] + case dst[3] == 0: + return r[:i*4+3] + } + } + return r +} diff --git a/Godeps/_workspace/src/github.com/klauspost/cpuid/cpuid_386.s b/Godeps/_workspace/src/github.com/klauspost/cpuid/cpuid_386.s new file mode 100644 index 0000000000..4d731711e4 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/cpuid/cpuid_386.s @@ -0,0 +1,42 @@ +// Copyright (c) 2015 Klaus Post, released under MIT License. See LICENSE file. + +// +build 386,!gccgo + +// func asmCpuid(op uint32) (eax, ebx, ecx, edx uint32) +TEXT ·asmCpuid(SB), 7, $0 + XORL CX, CX + MOVL op+0(FP), AX + CPUID + MOVL AX, eax+4(FP) + MOVL BX, ebx+8(FP) + MOVL CX, ecx+12(FP) + MOVL DX, edx+16(FP) + RET + +// func asmCpuidex(op, op2 uint32) (eax, ebx, ecx, edx uint32) +TEXT ·asmCpuidex(SB), 7, $0 + MOVL op+0(FP), AX + MOVL op2+4(FP), CX + CPUID + MOVL AX, eax+8(FP) + MOVL BX, ebx+12(FP) + MOVL CX, ecx+16(FP) + MOVL DX, edx+20(FP) + RET + +// func xgetbv(index uint32) (eax, edx uint32) +TEXT ·asmXgetbv(SB), 7, $0 + MOVL index+0(FP), CX + BYTE $0x0f; BYTE $0x01; BYTE $0xd0 // XGETBV + MOVL AX, eax+4(FP) + MOVL DX, edx+8(FP) + RET + +// func asmRdtscpAsm() (eax, ebx, ecx, edx uint32) +TEXT ·asmRdtscpAsm(SB), 7, $0 + BYTE $0x0F; BYTE $0x01; BYTE $0xF9 // RDTSCP + MOVL AX, eax+0(FP) + MOVL BX, ebx+4(FP) + MOVL CX, ecx+8(FP) + MOVL DX, edx+12(FP) + RET diff --git a/Godeps/_workspace/src/github.com/klauspost/cpuid/cpuid_amd64.s b/Godeps/_workspace/src/github.com/klauspost/cpuid/cpuid_amd64.s new file mode 100644 index 0000000000..3c1d60e422 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/cpuid/cpuid_amd64.s @@ -0,0 +1,42 @@ +// Copyright (c) 2015 Klaus Post, released under MIT License. See LICENSE file. + +//+build amd64,!gccgo + +// func asmCpuid(op uint32) (eax, ebx, ecx, edx uint32) +TEXT ·asmCpuid(SB), 7, $0 + XORQ CX, CX + MOVL op+0(FP), AX + CPUID + MOVL AX, eax+8(FP) + MOVL BX, ebx+12(FP) + MOVL CX, ecx+16(FP) + MOVL DX, edx+20(FP) + RET + +// func asmCpuidex(op, op2 uint32) (eax, ebx, ecx, edx uint32) +TEXT ·asmCpuidex(SB), 7, $0 + MOVL op+0(FP), AX + MOVL op2+4(FP), CX + CPUID + MOVL AX, eax+8(FP) + MOVL BX, ebx+12(FP) + MOVL CX, ecx+16(FP) + MOVL DX, edx+20(FP) + RET + +// func asmXgetbv(index uint32) (eax, edx uint32) +TEXT ·asmXgetbv(SB), 7, $0 + MOVL index+0(FP), CX + BYTE $0x0f; BYTE $0x01; BYTE $0xd0 // XGETBV + MOVL AX, eax+8(FP) + MOVL DX, edx+12(FP) + RET + +// func asmRdtscpAsm() (eax, ebx, ecx, edx uint32) +TEXT ·asmRdtscpAsm(SB), 7, $0 + BYTE $0x0F; BYTE $0x01; BYTE $0xF9 // RDTSCP + MOVL AX, eax+0(FP) + MOVL BX, ebx+4(FP) + MOVL CX, ecx+8(FP) + MOVL DX, edx+12(FP) + RET diff --git a/Godeps/_workspace/src/github.com/klauspost/cpuid/detect_intel.go b/Godeps/_workspace/src/github.com/klauspost/cpuid/detect_intel.go new file mode 100644 index 0000000000..a5f04dd6d0 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/cpuid/detect_intel.go @@ -0,0 +1,17 @@ +// Copyright (c) 2015 Klaus Post, released under MIT License. See LICENSE file. + +// +build 386,!gccgo amd64,!gccgo + +package cpuid + +func asmCpuid(op uint32) (eax, ebx, ecx, edx uint32) +func asmCpuidex(op, op2 uint32) (eax, ebx, ecx, edx uint32) +func asmXgetbv(index uint32) (eax, edx uint32) +func asmRdtscpAsm() (eax, ebx, ecx, edx uint32) + +func initCPU() { + cpuid = asmCpuid + cpuidex = asmCpuidex + xgetbv = asmXgetbv + rdtscpAsm = asmRdtscpAsm +} diff --git a/Godeps/_workspace/src/github.com/klauspost/cpuid/detect_ref.go b/Godeps/_workspace/src/github.com/klauspost/cpuid/detect_ref.go new file mode 100644 index 0000000000..909c5d9a7a --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/cpuid/detect_ref.go @@ -0,0 +1,23 @@ +// Copyright (c) 2015 Klaus Post, released under MIT License. See LICENSE file. + +// +build !amd64,!386 gccgo + +package cpuid + +func initCPU() { + cpuid = func(op uint32) (eax, ebx, ecx, edx uint32) { + return 0, 0, 0, 0 + } + + cpuidex = func(op, op2 uint32) (eax, ebx, ecx, edx uint32) { + return 0, 0, 0, 0 + } + + xgetbv = func(index uint32) (eax, edx uint32) { + return 0, 0 + } + + rdtscpAsm = func() (eax, ebx, ecx, edx uint32) { + return 0, 0, 0, 0 + } +} diff --git a/Godeps/_workspace/src/github.com/klauspost/cpuid/generate.go b/Godeps/_workspace/src/github.com/klauspost/cpuid/generate.go new file mode 100644 index 0000000000..c060b8165e --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/cpuid/generate.go @@ -0,0 +1,3 @@ +package cpuid + +//go:generate go run private-gen.go diff --git a/Godeps/_workspace/src/github.com/klauspost/cpuid/private-gen.go b/Godeps/_workspace/src/github.com/klauspost/cpuid/private-gen.go new file mode 100644 index 0000000000..437333d292 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/cpuid/private-gen.go @@ -0,0 +1,476 @@ +// +build ignore + +package main + +import ( + "bytes" + "fmt" + "go/ast" + "go/parser" + "go/printer" + "go/token" + "io" + "io/ioutil" + "log" + "os" + "reflect" + "strings" + "unicode" + "unicode/utf8" +) + +var inFiles = []string{"cpuid.go", "cpuid_test.go"} +var copyFiles = []string{"cpuid_amd64.s", "cpuid_386.s", "detect_ref.go", "detect_intel.go"} +var fileSet = token.NewFileSet() +var reWrites = []rewrite{ + initRewrite("CPUInfo -> cpuInfo"), + initRewrite("Vendor -> vendor"), + initRewrite("Flags -> flags"), + initRewrite("Detect -> detect"), + initRewrite("CPU -> cpu"), +} +var excludeNames = map[string]bool{"string": true, "join": true, "trim": true, + // cpuid_test.go + "t": true, "println": true, "logf": true, "log": true, "fatalf": true, "fatal": true, +} + +var excludePrefixes = []string{"test", "benchmark"} + +func main() { + Package := "private" + parserMode := parser.ParseComments + exported := make(map[string]rewrite) + for _, file := range inFiles { + in, err := os.Open(file) + if err != nil { + log.Fatalf("opening input", err) + } + + src, err := ioutil.ReadAll(in) + if err != nil { + log.Fatalf("reading input", err) + } + + astfile, err := parser.ParseFile(fileSet, file, src, parserMode) + if err != nil { + log.Fatalf("parsing input", err) + } + + for _, rw := range reWrites { + astfile = rw(astfile) + } + + // Inspect the AST and print all identifiers and literals. + var startDecl token.Pos + var endDecl token.Pos + ast.Inspect(astfile, func(n ast.Node) bool { + var s string + switch x := n.(type) { + case *ast.Ident: + if x.IsExported() { + t := strings.ToLower(x.Name) + for _, pre := range excludePrefixes { + if strings.HasPrefix(t, pre) { + return true + } + } + if excludeNames[t] != true { + //if x.Pos() > startDecl && x.Pos() < endDecl { + exported[x.Name] = initRewrite(x.Name + " -> " + t) + } + } + + case *ast.GenDecl: + if x.Tok == token.CONST && x.Lparen > 0 { + startDecl = x.Lparen + endDecl = x.Rparen + // fmt.Printf("Decl:%s -> %s\n", fileSet.Position(startDecl), fileSet.Position(endDecl)) + } + } + if s != "" { + fmt.Printf("%s:\t%s\n", fileSet.Position(n.Pos()), s) + } + return true + }) + + for _, rw := range exported { + astfile = rw(astfile) + } + + var buf bytes.Buffer + + printer.Fprint(&buf, fileSet, astfile) + + // Remove package documentation and insert information + s := buf.String() + ind := strings.Index(buf.String(), "\npackage cpuid") + s = s[ind:] + s = "// Generated, DO NOT EDIT,\n" + + "// but copy it to your own project and rename the package.\n" + + "// See more at http://github.com/klauspost/cpuid\n" + + s + + outputName := Package + string(os.PathSeparator) + file + + err = ioutil.WriteFile(outputName, []byte(s), 0644) + if err != nil { + log.Fatalf("writing output: %s", err) + } + log.Println("Generated", outputName) + } + + for _, file := range copyFiles { + dst := "" + if strings.HasPrefix(file, "cpuid") { + dst = Package + string(os.PathSeparator) + file + } else { + dst = Package + string(os.PathSeparator) + "cpuid_" + file + } + err := copyFile(file, dst) + if err != nil { + log.Fatalf("copying file: %s", err) + } + log.Println("Copied", dst) + } +} + +// CopyFile copies a file from src to dst. If src and dst files exist, and are +// the same, then return success. Copy the file contents from src to dst. +func copyFile(src, dst string) (err error) { + sfi, err := os.Stat(src) + if err != nil { + return + } + if !sfi.Mode().IsRegular() { + // cannot copy non-regular files (e.g., directories, + // symlinks, devices, etc.) + return fmt.Errorf("CopyFile: non-regular source file %s (%q)", sfi.Name(), sfi.Mode().String()) + } + dfi, err := os.Stat(dst) + if err != nil { + if !os.IsNotExist(err) { + return + } + } else { + if !(dfi.Mode().IsRegular()) { + return fmt.Errorf("CopyFile: non-regular destination file %s (%q)", dfi.Name(), dfi.Mode().String()) + } + if os.SameFile(sfi, dfi) { + return + } + } + err = copyFileContents(src, dst) + return +} + +// copyFileContents copies the contents of the file named src to the file named +// by dst. The file will be created if it does not already exist. If the +// destination file exists, all it's contents will be replaced by the contents +// of the source file. +func copyFileContents(src, dst string) (err error) { + in, err := os.Open(src) + if err != nil { + return + } + defer in.Close() + out, err := os.Create(dst) + if err != nil { + return + } + defer func() { + cerr := out.Close() + if err == nil { + err = cerr + } + }() + if _, err = io.Copy(out, in); err != nil { + return + } + err = out.Sync() + return +} + +type rewrite func(*ast.File) *ast.File + +// Mostly copied from gofmt +func initRewrite(rewriteRule string) rewrite { + f := strings.Split(rewriteRule, "->") + if len(f) != 2 { + fmt.Fprintf(os.Stderr, "rewrite rule must be of the form 'pattern -> replacement'\n") + os.Exit(2) + } + pattern := parseExpr(f[0], "pattern") + replace := parseExpr(f[1], "replacement") + return func(p *ast.File) *ast.File { return rewriteFile(pattern, replace, p) } +} + +// parseExpr parses s as an expression. +// It might make sense to expand this to allow statement patterns, +// but there are problems with preserving formatting and also +// with what a wildcard for a statement looks like. +func parseExpr(s, what string) ast.Expr { + x, err := parser.ParseExpr(s) + if err != nil { + fmt.Fprintf(os.Stderr, "parsing %s %s at %s\n", what, s, err) + os.Exit(2) + } + return x +} + +// Keep this function for debugging. +/* +func dump(msg string, val reflect.Value) { + fmt.Printf("%s:\n", msg) + ast.Print(fileSet, val.Interface()) + fmt.Println() +} +*/ + +// rewriteFile applies the rewrite rule 'pattern -> replace' to an entire file. +func rewriteFile(pattern, replace ast.Expr, p *ast.File) *ast.File { + cmap := ast.NewCommentMap(fileSet, p, p.Comments) + m := make(map[string]reflect.Value) + pat := reflect.ValueOf(pattern) + repl := reflect.ValueOf(replace) + + var rewriteVal func(val reflect.Value) reflect.Value + rewriteVal = func(val reflect.Value) reflect.Value { + // don't bother if val is invalid to start with + if !val.IsValid() { + return reflect.Value{} + } + for k := range m { + delete(m, k) + } + val = apply(rewriteVal, val) + if match(m, pat, val) { + val = subst(m, repl, reflect.ValueOf(val.Interface().(ast.Node).Pos())) + } + return val + } + + r := apply(rewriteVal, reflect.ValueOf(p)).Interface().(*ast.File) + r.Comments = cmap.Filter(r).Comments() // recreate comments list + return r +} + +// set is a wrapper for x.Set(y); it protects the caller from panics if x cannot be changed to y. +func set(x, y reflect.Value) { + // don't bother if x cannot be set or y is invalid + if !x.CanSet() || !y.IsValid() { + return + } + defer func() { + if x := recover(); x != nil { + if s, ok := x.(string); ok && + (strings.Contains(s, "type mismatch") || strings.Contains(s, "not assignable")) { + // x cannot be set to y - ignore this rewrite + return + } + panic(x) + } + }() + x.Set(y) +} + +// Values/types for special cases. +var ( + objectPtrNil = reflect.ValueOf((*ast.Object)(nil)) + scopePtrNil = reflect.ValueOf((*ast.Scope)(nil)) + + identType = reflect.TypeOf((*ast.Ident)(nil)) + objectPtrType = reflect.TypeOf((*ast.Object)(nil)) + positionType = reflect.TypeOf(token.NoPos) + callExprType = reflect.TypeOf((*ast.CallExpr)(nil)) + scopePtrType = reflect.TypeOf((*ast.Scope)(nil)) +) + +// apply replaces each AST field x in val with f(x), returning val. +// To avoid extra conversions, f operates on the reflect.Value form. +func apply(f func(reflect.Value) reflect.Value, val reflect.Value) reflect.Value { + if !val.IsValid() { + return reflect.Value{} + } + + // *ast.Objects introduce cycles and are likely incorrect after + // rewrite; don't follow them but replace with nil instead + if val.Type() == objectPtrType { + return objectPtrNil + } + + // similarly for scopes: they are likely incorrect after a rewrite; + // replace them with nil + if val.Type() == scopePtrType { + return scopePtrNil + } + + switch v := reflect.Indirect(val); v.Kind() { + case reflect.Slice: + for i := 0; i < v.Len(); i++ { + e := v.Index(i) + set(e, f(e)) + } + case reflect.Struct: + for i := 0; i < v.NumField(); i++ { + e := v.Field(i) + set(e, f(e)) + } + case reflect.Interface: + e := v.Elem() + set(v, f(e)) + } + return val +} + +func isWildcard(s string) bool { + rune, size := utf8.DecodeRuneInString(s) + return size == len(s) && unicode.IsLower(rune) +} + +// match returns true if pattern matches val, +// recording wildcard submatches in m. +// If m == nil, match checks whether pattern == val. +func match(m map[string]reflect.Value, pattern, val reflect.Value) bool { + // Wildcard matches any expression. If it appears multiple + // times in the pattern, it must match the same expression + // each time. + if m != nil && pattern.IsValid() && pattern.Type() == identType { + name := pattern.Interface().(*ast.Ident).Name + if isWildcard(name) && val.IsValid() { + // wildcards only match valid (non-nil) expressions. + if _, ok := val.Interface().(ast.Expr); ok && !val.IsNil() { + if old, ok := m[name]; ok { + return match(nil, old, val) + } + m[name] = val + return true + } + } + } + + // Otherwise, pattern and val must match recursively. + if !pattern.IsValid() || !val.IsValid() { + return !pattern.IsValid() && !val.IsValid() + } + if pattern.Type() != val.Type() { + return false + } + + // Special cases. + switch pattern.Type() { + case identType: + // For identifiers, only the names need to match + // (and none of the other *ast.Object information). + // This is a common case, handle it all here instead + // of recursing down any further via reflection. + p := pattern.Interface().(*ast.Ident) + v := val.Interface().(*ast.Ident) + return p == nil && v == nil || p != nil && v != nil && p.Name == v.Name + case objectPtrType, positionType: + // object pointers and token positions always match + return true + case callExprType: + // For calls, the Ellipsis fields (token.Position) must + // match since that is how f(x) and f(x...) are different. + // Check them here but fall through for the remaining fields. + p := pattern.Interface().(*ast.CallExpr) + v := val.Interface().(*ast.CallExpr) + if p.Ellipsis.IsValid() != v.Ellipsis.IsValid() { + return false + } + } + + p := reflect.Indirect(pattern) + v := reflect.Indirect(val) + if !p.IsValid() || !v.IsValid() { + return !p.IsValid() && !v.IsValid() + } + + switch p.Kind() { + case reflect.Slice: + if p.Len() != v.Len() { + return false + } + for i := 0; i < p.Len(); i++ { + if !match(m, p.Index(i), v.Index(i)) { + return false + } + } + return true + + case reflect.Struct: + for i := 0; i < p.NumField(); i++ { + if !match(m, p.Field(i), v.Field(i)) { + return false + } + } + return true + + case reflect.Interface: + return match(m, p.Elem(), v.Elem()) + } + + // Handle token integers, etc. + return p.Interface() == v.Interface() +} + +// subst returns a copy of pattern with values from m substituted in place +// of wildcards and pos used as the position of tokens from the pattern. +// if m == nil, subst returns a copy of pattern and doesn't change the line +// number information. +func subst(m map[string]reflect.Value, pattern reflect.Value, pos reflect.Value) reflect.Value { + if !pattern.IsValid() { + return reflect.Value{} + } + + // Wildcard gets replaced with map value. + if m != nil && pattern.Type() == identType { + name := pattern.Interface().(*ast.Ident).Name + if isWildcard(name) { + if old, ok := m[name]; ok { + return subst(nil, old, reflect.Value{}) + } + } + } + + if pos.IsValid() && pattern.Type() == positionType { + // use new position only if old position was valid in the first place + if old := pattern.Interface().(token.Pos); !old.IsValid() { + return pattern + } + return pos + } + + // Otherwise copy. + switch p := pattern; p.Kind() { + case reflect.Slice: + v := reflect.MakeSlice(p.Type(), p.Len(), p.Len()) + for i := 0; i < p.Len(); i++ { + v.Index(i).Set(subst(m, p.Index(i), pos)) + } + return v + + case reflect.Struct: + v := reflect.New(p.Type()).Elem() + for i := 0; i < p.NumField(); i++ { + v.Field(i).Set(subst(m, p.Field(i), pos)) + } + return v + + case reflect.Ptr: + v := reflect.New(p.Type()).Elem() + if elem := p.Elem(); elem.IsValid() { + v.Set(subst(m, elem, pos).Addr()) + } + return v + + case reflect.Interface: + v := reflect.New(p.Type()).Elem() + if elem := p.Elem(); elem.IsValid() { + v.Set(subst(m, elem, pos)) + } + return v + } + + return pattern +} diff --git a/Godeps/_workspace/src/github.com/klauspost/crc32/.gitignore b/Godeps/_workspace/src/github.com/klauspost/crc32/.gitignore new file mode 100644 index 0000000000..daf913b1b3 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/crc32/.gitignore @@ -0,0 +1,24 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test +*.prof diff --git a/Godeps/_workspace/src/github.com/klauspost/crc32/.travis.yml b/Godeps/_workspace/src/github.com/klauspost/crc32/.travis.yml new file mode 100644 index 0000000000..977179953d --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/crc32/.travis.yml @@ -0,0 +1,12 @@ +language: go + +go: + - 1.3 + - 1.4 + - 1.5 + - 1.6 + - tip + +script: + - go test -v . + - go test -v -race . diff --git a/Godeps/_workspace/src/github.com/klauspost/crc32/LICENSE b/Godeps/_workspace/src/github.com/klauspost/crc32/LICENSE new file mode 100644 index 0000000000..4fd5963e39 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/crc32/LICENSE @@ -0,0 +1,28 @@ +Copyright (c) 2012 The Go Authors. All rights reserved. +Copyright (c) 2015 Klaus Post + +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. diff --git a/Godeps/_workspace/src/github.com/klauspost/crc32/README.md b/Godeps/_workspace/src/github.com/klauspost/crc32/README.md new file mode 100644 index 0000000000..440541c7ff --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/crc32/README.md @@ -0,0 +1,84 @@ +# crc32 +CRC32 hash with x64 optimizations + +This package is a drop-in replacement for the standard library `hash/crc32` package, that features SSE 4.2 optimizations on x64 platforms, for a 10x speedup. + +[![Build Status](https://travis-ci.org/klauspost/crc32.svg?branch=master)](https://travis-ci.org/klauspost/crc32) + +# usage + +Install using `go get github.com/klauspost/crc32`. This library is based on Go 1.5 code and requires Go 1.3 or newer. + +Replace `import "hash/crc32"` with `import "github.com/klauspost/crc32"` and you are good to go. + +# changes + +* Dec 4, 2015: Uses the "slice-by-8" trick more extensively, which gives a 1.5 to 2.5x speedup if assembler is unavailable. + + +# performance + +For IEEE tables (the most common), there is approximately a factor 10 speedup with "CLMUL" (Carryless multiplication) instruction: +``` +benchmark old ns/op new ns/op delta +BenchmarkCrc32KB 99955 10258 -89.74% + +benchmark old MB/s new MB/s speedup +BenchmarkCrc32KB 327.83 3194.20 9.74x +``` + +For other tables and "CLMUL" capable machines the performance is the same as the standard library. + +Here are some detailed benchmarks, comparing to go 1.5 standard library with and without assembler enabled. + +``` +Std: Standard Go 1.5 library +Crc: Indicates IEEE type CRC. +40B: Size of each slice encoded. +NoAsm: Assembler was disabled (ie. not an AMD64 or SSE 4.2+ capable machine). +Castagnoli: Castagnoli CRC type. + +BenchmarkStdCrc40B-4 10000000 158 ns/op 252.88 MB/s +BenchmarkCrc40BNoAsm-4 20000000 105 ns/op 377.38 MB/s (slice8) +BenchmarkCrc40B-4 20000000 105 ns/op 378.77 MB/s (slice8) + +BenchmarkStdCrc1KB-4 500000 3604 ns/op 284.10 MB/s +BenchmarkCrc1KBNoAsm-4 1000000 1463 ns/op 699.79 MB/s (slice8) +BenchmarkCrc1KB-4 3000000 396 ns/op 2583.69 MB/s (asm) + +BenchmarkStdCrc8KB-4 200000 11417 ns/op 717.48 MB/s (slice8) +BenchmarkCrc8KBNoAsm-4 200000 11317 ns/op 723.85 MB/s (slice8) +BenchmarkCrc8KB-4 500000 2919 ns/op 2805.73 MB/s (asm) + +BenchmarkStdCrc32KB-4 30000 45749 ns/op 716.24 MB/s (slice8) +BenchmarkCrc32KBNoAsm-4 30000 45109 ns/op 726.42 MB/s (slice8) +BenchmarkCrc32KB-4 100000 11497 ns/op 2850.09 MB/s (asm) + +BenchmarkStdNoAsmCastagnol40B-4 10000000 161 ns/op 246.94 MB/s +BenchmarkStdCastagnoli40B-4 50000000 28.4 ns/op 1410.69 MB/s (asm) +BenchmarkCastagnoli40BNoAsm-4 20000000 100 ns/op 398.01 MB/s (slice8) +BenchmarkCastagnoli40B-4 50000000 28.2 ns/op 1419.54 MB/s (asm) + +BenchmarkStdNoAsmCastagnoli1KB-4 500000 3622 ns/op 282.67 MB/s +BenchmarkStdCastagnoli1KB-4 10000000 144 ns/op 7099.78 MB/s (asm) +BenchmarkCastagnoli1KBNoAsm-4 1000000 1475 ns/op 694.14 MB/s (slice8) +BenchmarkCastagnoli1KB-4 10000000 146 ns/op 6993.35 MB/s (asm) + +BenchmarkStdNoAsmCastagnoli8KB-4 50000 28781 ns/op 284.63 MB/s +BenchmarkStdCastagnoli8KB-4 1000000 1029 ns/op 7957.89 MB/s (asm) +BenchmarkCastagnoli8KBNoAsm-4 200000 11410 ns/op 717.94 MB/s (slice8) +BenchmarkCastagnoli8KB-4 1000000 1000 ns/op 8188.71 MB/s (asm) + +BenchmarkStdNoAsmCastagnoli32KB-4 10000 115426 ns/op 283.89 MB/s +BenchmarkStdCastagnoli32KB-4 300000 4065 ns/op 8059.13 MB/s (asm) +BenchmarkCastagnoli32KBNoAsm-4 30000 45171 ns/op 725.41 MB/s (slice8) +BenchmarkCastagnoli32KB-4 500000 4077 ns/op 8035.89 MB/s (asm) +``` + +The IEEE assembler optimizations has been submitted and will be part of the Go 1.6 standard library. + +However, the improved use of slice-by-8 has not, but will probably be submitted for Go 1.7. + +# license + +Standard Go license. Changes are Copyright (c) 2015 Klaus Post under same conditions. diff --git a/Godeps/_workspace/src/github.com/klauspost/crc32/crc32.go b/Godeps/_workspace/src/github.com/klauspost/crc32/crc32.go new file mode 100644 index 0000000000..8d6ba5d3dc --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/crc32/crc32.go @@ -0,0 +1,186 @@ +// 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. + +// Package crc32 implements the 32-bit cyclic redundancy check, or CRC-32, +// checksum. See http://en.wikipedia.org/wiki/Cyclic_redundancy_check for +// information. +// +// Polynomials are represented in LSB-first form also known as reversed representation. +// +// See http://en.wikipedia.org/wiki/Mathematics_of_cyclic_redundancy_checks#Reversed_representations_and_reciprocal_polynomials +// for information. +package crc32 + +import ( + "hash" + "sync" +) + +// The size of a CRC-32 checksum in bytes. +const Size = 4 + +// Predefined polynomials. +const ( + // IEEE is by far and away the most common CRC-32 polynomial. + // Used by ethernet (IEEE 802.3), v.42, fddi, gzip, zip, png, ... + IEEE = 0xedb88320 + + // Castagnoli's polynomial, used in iSCSI. + // Has better error detection characteristics than IEEE. + // http://dx.doi.org/10.1109/26.231911 + Castagnoli = 0x82f63b78 + + // Koopman's polynomial. + // Also has better error detection characteristics than IEEE. + // http://dx.doi.org/10.1109/DSN.2002.1028931 + Koopman = 0xeb31d82e +) + +// Table is a 256-word table representing the polynomial for efficient processing. +type Table [256]uint32 + +// castagnoliTable points to a lazily initialized Table for the Castagnoli +// polynomial. MakeTable will always return this value when asked to make a +// Castagnoli table so we can compare against it to find when the caller is +// using this polynomial. +var castagnoliTable *Table +var castagnoliTable8 *slicing8Table +var castagnoliOnce sync.Once + +func castagnoliInit() { + castagnoliTable = makeTable(Castagnoli) + castagnoliTable8 = makeTable8(Castagnoli) +} + +// IEEETable is the table for the IEEE polynomial. +var IEEETable = makeTable(IEEE) + +// slicing8Table is array of 8 Tables +type slicing8Table [8]Table + +// ieeeTable8 is the slicing8Table for IEEE +var ieeeTable8 *slicing8Table +var ieeeTable8Once sync.Once + +// MakeTable returns a Table constructed from the specified polynomial. +// The contents of this Table must not be modified. +func MakeTable(poly uint32) *Table { + switch poly { + case IEEE: + return IEEETable + case Castagnoli: + castagnoliOnce.Do(castagnoliInit) + return castagnoliTable + } + return makeTable(poly) +} + +// makeTable returns the Table constructed from the specified polynomial. +func makeTable(poly uint32) *Table { + t := new(Table) + for i := 0; i < 256; i++ { + crc := uint32(i) + for j := 0; j < 8; j++ { + if crc&1 == 1 { + crc = (crc >> 1) ^ poly + } else { + crc >>= 1 + } + } + t[i] = crc + } + return t +} + +// makeTable8 returns slicing8Table constructed from the specified polynomial. +func makeTable8(poly uint32) *slicing8Table { + t := new(slicing8Table) + t[0] = *makeTable(poly) + for i := 0; i < 256; i++ { + crc := t[0][i] + for j := 1; j < 8; j++ { + crc = t[0][crc&0xFF] ^ (crc >> 8) + t[j][i] = crc + } + } + return t +} + +// digest represents the partial evaluation of a checksum. +type digest struct { + crc uint32 + tab *Table +} + +// New creates a new hash.Hash32 computing the CRC-32 checksum +// using the polynomial represented by the Table. +// Its Sum method will lay the value out in big-endian byte order. +func New(tab *Table) hash.Hash32 { return &digest{0, tab} } + +// NewIEEE creates a new hash.Hash32 computing the CRC-32 checksum +// using the IEEE polynomial. +// Its Sum method will lay the value out in big-endian byte order. +func NewIEEE() hash.Hash32 { return New(IEEETable) } + +func (d *digest) Size() int { return Size } + +func (d *digest) BlockSize() int { return 1 } + +func (d *digest) Reset() { d.crc = 0 } + +func update(crc uint32, tab *Table, p []byte) uint32 { + crc = ^crc + for _, v := range p { + crc = tab[byte(crc)^v] ^ (crc >> 8) + } + return ^crc +} + +// updateSlicingBy8 updates CRC using Slicing-by-8 +func updateSlicingBy8(crc uint32, tab *slicing8Table, p []byte) uint32 { + crc = ^crc + for len(p) > 8 { + crc ^= uint32(p[0]) | uint32(p[1])<<8 | uint32(p[2])<<16 | uint32(p[3])<<24 + crc = tab[0][p[7]] ^ tab[1][p[6]] ^ tab[2][p[5]] ^ tab[3][p[4]] ^ + tab[4][crc>>24] ^ tab[5][(crc>>16)&0xFF] ^ + tab[6][(crc>>8)&0xFF] ^ tab[7][crc&0xFF] + p = p[8:] + } + crc = ^crc + if len(p) == 0 { + return crc + } + return update(crc, &tab[0], p) +} + +// Update returns the result of adding the bytes in p to the crc. +func Update(crc uint32, tab *Table, p []byte) uint32 { + if tab == castagnoliTable { + return updateCastagnoli(crc, p) + } + if tab == IEEETable { + return updateIEEE(crc, p) + } + return update(crc, tab, p) +} + +func (d *digest) Write(p []byte) (n int, err error) { + d.crc = Update(d.crc, d.tab, p) + return len(p), nil +} + +func (d *digest) Sum32() uint32 { return d.crc } + +func (d *digest) Sum(in []byte) []byte { + s := d.Sum32() + return append(in, byte(s>>24), byte(s>>16), byte(s>>8), byte(s)) +} + +// Checksum returns the CRC-32 checksum of data +// using the polynomial represented by the Table. +func Checksum(data []byte, tab *Table) uint32 { return Update(0, tab, data) } + +// ChecksumIEEE returns the CRC-32 checksum of data +// using the IEEE polynomial. +func ChecksumIEEE(data []byte) uint32 { return updateIEEE(0, data) } diff --git a/Godeps/_workspace/src/github.com/klauspost/crc32/crc32_amd64.go b/Godeps/_workspace/src/github.com/klauspost/crc32/crc32_amd64.go new file mode 100644 index 0000000000..4827128ea0 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/crc32/crc32_amd64.go @@ -0,0 +1,62 @@ +// 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 !appengine,!gccgo + +package crc32 + +// This file contains the code to call the SSE 4.2 version of the Castagnoli +// and IEEE CRC. + +// haveSSE41/haveSSE42/haveCLMUL are defined in crc_amd64.s and use +// CPUID to test for SSE 4.1, 4.2 and CLMUL support. +func haveSSE41() bool +func haveSSE42() bool +func haveCLMUL() bool + +// castagnoliSSE42 is defined in crc_amd64.s and uses the SSE4.2 CRC32 +// instruction. +//go:noescape +func castagnoliSSE42(crc uint32, p []byte) uint32 + +// ieeeCLMUL is defined in crc_amd64.s and uses the PCLMULQDQ +// instruction as well as SSE 4.1. +//go:noescape +func ieeeCLMUL(crc uint32, p []byte) uint32 + +var sse42 = haveSSE42() +var useFastIEEE = haveCLMUL() && haveSSE41() + +func updateCastagnoli(crc uint32, p []byte) uint32 { + if sse42 { + return castagnoliSSE42(crc, p) + } + // only use slicing-by-8 when input is >= 16 Bytes + if len(p) >= 16 { + return updateSlicingBy8(crc, castagnoliTable8, p) + } + return update(crc, castagnoliTable, p) +} + +func updateIEEE(crc uint32, p []byte) uint32 { + if useFastIEEE && len(p) >= 64 { + left := len(p) & 15 + do := len(p) - left + crc = ^ieeeCLMUL(^crc, p[:do]) + if left > 0 { + crc = update(crc, IEEETable, p[do:]) + } + return crc + } + + // only use slicing-by-8 when input is >= 16 Bytes + if len(p) >= 16 { + ieeeTable8Once.Do(func() { + ieeeTable8 = makeTable8(IEEE) + }) + return updateSlicingBy8(crc, ieeeTable8, p) + } + + return update(crc, IEEETable, p) +} diff --git a/Godeps/_workspace/src/github.com/klauspost/crc32/crc32_amd64.s b/Godeps/_workspace/src/github.com/klauspost/crc32/crc32_amd64.s new file mode 100644 index 0000000000..9bf05d89b8 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/crc32/crc32_amd64.s @@ -0,0 +1,237 @@ +// 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 gc + +#define NOSPLIT 4 +#define RODATA 8 + +// func castagnoliSSE42(crc uint32, p []byte) uint32 +TEXT ·castagnoliSSE42(SB), NOSPLIT, $0 + MOVL crc+0(FP), AX // CRC value + MOVQ p+8(FP), SI // data pointer + MOVQ p_len+16(FP), CX // len(p) + + NOTL AX + + // If there's less than 8 bytes to process, we do it byte-by-byte. + CMPQ CX, $8 + JL cleanup + + // Process individual bytes until the input is 8-byte aligned. +startup: + MOVQ SI, BX + ANDQ $7, BX + JZ aligned + + CRC32B (SI), AX + DECQ CX + INCQ SI + JMP startup + +aligned: + // The input is now 8-byte aligned and we can process 8-byte chunks. + CMPQ CX, $8 + JL cleanup + + CRC32Q (SI), AX + ADDQ $8, SI + SUBQ $8, CX + JMP aligned + +cleanup: + // We may have some bytes left over that we process one at a time. + CMPQ CX, $0 + JE done + + CRC32B (SI), AX + INCQ SI + DECQ CX + JMP cleanup + +done: + NOTL AX + MOVL AX, ret+32(FP) + RET + +// func haveSSE42() bool +TEXT ·haveSSE42(SB), NOSPLIT, $0 + XORQ AX, AX + INCL AX + CPUID + SHRQ $20, CX + ANDQ $1, CX + MOVB CX, ret+0(FP) + RET + +// func haveCLMUL() bool +TEXT ·haveCLMUL(SB), NOSPLIT, $0 + XORQ AX, AX + INCL AX + CPUID + SHRQ $1, CX + ANDQ $1, CX + MOVB CX, ret+0(FP) + RET + +// func haveSSE41() bool +TEXT ·haveSSE41(SB), NOSPLIT, $0 + XORQ AX, AX + INCL AX + CPUID + SHRQ $19, CX + ANDQ $1, CX + MOVB CX, ret+0(FP) + RET + +// CRC32 polynomial data +// +// These constants are lifted from the +// Linux kernel, since they avoid the costly +// PSHUFB 16 byte reversal proposed in the +// original Intel paper. +DATA r2r1kp<>+0(SB)/8, $0x154442bd4 +DATA r2r1kp<>+8(SB)/8, $0x1c6e41596 +DATA r4r3kp<>+0(SB)/8, $0x1751997d0 +DATA r4r3kp<>+8(SB)/8, $0x0ccaa009e +DATA rupolykp<>+0(SB)/8, $0x1db710641 +DATA rupolykp<>+8(SB)/8, $0x1f7011641 +DATA r5kp<>+0(SB)/8, $0x163cd6124 + +GLOBL r2r1kp<>(SB), RODATA, $16 +GLOBL r4r3kp<>(SB), RODATA, $16 +GLOBL rupolykp<>(SB), RODATA, $16 +GLOBL r5kp<>(SB), RODATA, $8 + +// Based on http://www.intel.com/content/dam/www/public/us/en/documents/white-papers/fast-crc-computation-generic-polynomials-pclmulqdq-paper.pdf +// len(p) must be at least 64, and must be a multiple of 16. + +// func ieeeCLMUL(crc uint32, p []byte) uint32 +TEXT ·ieeeCLMUL(SB), NOSPLIT, $0 + MOVL crc+0(FP), X0 // Initial CRC value + MOVQ p+8(FP), SI // data pointer + MOVQ p_len+16(FP), CX // len(p) + + MOVOU (SI), X1 + MOVOU 16(SI), X2 + MOVOU 32(SI), X3 + MOVOU 48(SI), X4 + PXOR X0, X1 + ADDQ $64, SI // buf+=64 + SUBQ $64, CX // len-=64 + CMPQ CX, $64 // Less than 64 bytes left + JB remain64 + + MOVOA r2r1kp<>+0(SB), X0 + +loopback64: + MOVOA X1, X5 + MOVOA X2, X6 + MOVOA X3, X7 + MOVOA X4, X8 + + PCLMULQDQ $0, X0, X1 + PCLMULQDQ $0, X0, X2 + PCLMULQDQ $0, X0, X3 + PCLMULQDQ $0, X0, X4 + + // Load next early + MOVOU (SI), X11 + MOVOU 16(SI), X12 + MOVOU 32(SI), X13 + MOVOU 48(SI), X14 + + PCLMULQDQ $0x11, X0, X5 + PCLMULQDQ $0x11, X0, X6 + PCLMULQDQ $0x11, X0, X7 + PCLMULQDQ $0x11, X0, X8 + + PXOR X5, X1 + PXOR X6, X2 + PXOR X7, X3 + PXOR X8, X4 + + PXOR X11, X1 + PXOR X12, X2 + PXOR X13, X3 + PXOR X14, X4 + + ADDQ $0x40, DI + ADDQ $64, SI // buf+=64 + SUBQ $64, CX // len-=64 + CMPQ CX, $64 // Less than 64 bytes left? + JGE loopback64 + + // Fold result into a single register (X1) +remain64: + MOVOA r4r3kp<>+0(SB), X0 + + MOVOA X1, X5 + PCLMULQDQ $0, X0, X1 + PCLMULQDQ $0x11, X0, X5 + PXOR X5, X1 + PXOR X2, X1 + + MOVOA X1, X5 + PCLMULQDQ $0, X0, X1 + PCLMULQDQ $0x11, X0, X5 + PXOR X5, X1 + PXOR X3, X1 + + MOVOA X1, X5 + PCLMULQDQ $0, X0, X1 + PCLMULQDQ $0x11, X0, X5 + PXOR X5, X1 + PXOR X4, X1 + + // More than 16 bytes left? + CMPQ CX, $16 + JB finish + + // Encode 16 bytes +remain16: + MOVOU (SI), X10 + MOVOA X1, X5 + PCLMULQDQ $0, X0, X1 + PCLMULQDQ $0x11, X0, X5 + PXOR X5, X1 + PXOR X10, X1 + SUBQ $16, CX + ADDQ $16, SI + CMPQ CX, $16 + JGE remain16 + +finish: + // Fold final result into 32 bits and return it + PCMPEQB X3, X3 + PCLMULQDQ $1, X1, X0 + PSRLDQ $8, X1 + PXOR X0, X1 + + MOVOA X1, X2 + MOVQ r5kp<>+0(SB), X0 + + // Creates 32 bit mask. Note that we don't care about upper half. + PSRLQ $32, X3 + + PSRLDQ $4, X2 + PAND X3, X1 + PCLMULQDQ $0, X0, X1 + PXOR X2, X1 + + MOVOA rupolykp<>+0(SB), X0 + + MOVOA X1, X2 + PAND X3, X1 + PCLMULQDQ $0x10, X0, X1 + PAND X3, X1 + PCLMULQDQ $0, X0, X1 + PXOR X2, X1 + + // PEXTRD $1, X1, AX (SSE 4.1) + BYTE $0x66; BYTE $0x0f; BYTE $0x3a + BYTE $0x16; BYTE $0xc8; BYTE $0x01 + MOVL AX, ret+32(FP) + + RET diff --git a/Godeps/_workspace/src/github.com/klauspost/crc32/crc32_amd64p32.go b/Godeps/_workspace/src/github.com/klauspost/crc32/crc32_amd64p32.go new file mode 100644 index 0000000000..926473e7c0 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/crc32/crc32_amd64p32.go @@ -0,0 +1,40 @@ +// 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 !appengine,!gccgo + +package crc32 + +// This file contains the code to call the SSE 4.2 version of the Castagnoli +// CRC. + +// haveSSE42 is defined in crc_amd64p32.s and uses CPUID to test for SSE 4.2 +// support. +func haveSSE42() bool + +// castagnoliSSE42 is defined in crc_amd64.s and uses the SSE4.2 CRC32 +// instruction. +//go:noescape +func castagnoliSSE42(crc uint32, p []byte) uint32 + +var sse42 = haveSSE42() + +func updateCastagnoli(crc uint32, p []byte) uint32 { + if sse42 { + return castagnoliSSE42(crc, p) + } + return update(crc, castagnoliTable, p) +} + +func updateIEEE(crc uint32, p []byte) uint32 { + // only use slicing-by-8 when input is >= 4KB + if len(p) >= 4096 { + ieeeTable8Once.Do(func() { + ieeeTable8 = makeTable8(IEEE) + }) + return updateSlicingBy8(crc, ieeeTable8, p) + } + + return update(crc, IEEETable, p) +} diff --git a/Godeps/_workspace/src/github.com/klauspost/crc32/crc32_amd64p32.s b/Godeps/_workspace/src/github.com/klauspost/crc32/crc32_amd64p32.s new file mode 100644 index 0000000000..a578d685cc --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/crc32/crc32_amd64p32.s @@ -0,0 +1,67 @@ +// 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 gc + +#define NOSPLIT 4 +#define RODATA 8 + +// func castagnoliSSE42(crc uint32, p []byte) uint32 +TEXT ·castagnoliSSE42(SB), NOSPLIT, $0 + MOVL crc+0(FP), AX // CRC value + MOVL p+4(FP), SI // data pointer + MOVL p_len+8(FP), CX // len(p) + + NOTL AX + + // If there's less than 8 bytes to process, we do it byte-by-byte. + CMPQ CX, $8 + JL cleanup + + // Process individual bytes until the input is 8-byte aligned. +startup: + MOVQ SI, BX + ANDQ $7, BX + JZ aligned + + CRC32B (SI), AX + DECQ CX + INCQ SI + JMP startup + +aligned: + // The input is now 8-byte aligned and we can process 8-byte chunks. + CMPQ CX, $8 + JL cleanup + + CRC32Q (SI), AX + ADDQ $8, SI + SUBQ $8, CX + JMP aligned + +cleanup: + // We may have some bytes left over that we process one at a time. + CMPQ CX, $0 + JE done + + CRC32B (SI), AX + INCQ SI + DECQ CX + JMP cleanup + +done: + NOTL AX + MOVL AX, ret+16(FP) + RET + +// func haveSSE42() bool +TEXT ·haveSSE42(SB), NOSPLIT, $0 + XORQ AX, AX + INCL AX + CPUID + SHRQ $20, CX + ANDQ $1, CX + MOVB CX, ret+0(FP) + RET + diff --git a/Godeps/_workspace/src/github.com/klauspost/crc32/crc32_generic.go b/Godeps/_workspace/src/github.com/klauspost/crc32/crc32_generic.go new file mode 100644 index 0000000000..a53cf96a00 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/crc32/crc32_generic.go @@ -0,0 +1,29 @@ +// 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 !amd64,!amd64p32 appengine gccgo + +package crc32 + +// This file contains the generic version of updateCastagnoli which does +// slicing-by-8, or uses the fallback for very small sizes. + +func updateCastagnoli(crc uint32, p []byte) uint32 { + // only use slicing-by-8 when input is >= 16 Bytes + if len(p) >= 16 { + return updateSlicingBy8(crc, castagnoliTable8, p) + } + return update(crc, castagnoliTable, p) +} + +func updateIEEE(crc uint32, p []byte) uint32 { + // only use slicing-by-8 when input is >= 16 Bytes + if len(p) >= 16 { + ieeeTable8Once.Do(func() { + ieeeTable8 = makeTable8(IEEE) + }) + return updateSlicingBy8(crc, ieeeTable8, p) + } + return update(crc, IEEETable, p) +} diff --git a/Godeps/_workspace/src/github.com/klauspost/pgzip/.gitignore b/Godeps/_workspace/src/github.com/klauspost/pgzip/.gitignore new file mode 100644 index 0000000000..daf913b1b3 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/pgzip/.gitignore @@ -0,0 +1,24 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test +*.prof diff --git a/Godeps/_workspace/src/github.com/klauspost/pgzip/.travis.yml b/Godeps/_workspace/src/github.com/klauspost/pgzip/.travis.yml new file mode 100644 index 0000000000..6284168510 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/pgzip/.travis.yml @@ -0,0 +1,18 @@ +language: go + +sudo: false + +os: + - linux + - osx + +go: + - 1.3 + - 1.4 + - 1.5 + - 1.6 + - tip + +script: + - go test -v -cpu=1,2,4 . + - go test -v -cpu=2 -race -short . diff --git a/Godeps/_workspace/src/github.com/klauspost/pgzip/GO_LICENSE b/Godeps/_workspace/src/github.com/klauspost/pgzip/GO_LICENSE new file mode 100644 index 0000000000..7448756763 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/pgzip/GO_LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2012 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. diff --git a/Godeps/_workspace/src/github.com/klauspost/pgzip/LICENSE b/Godeps/_workspace/src/github.com/klauspost/pgzip/LICENSE new file mode 100644 index 0000000000..2bdc0d7517 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/pgzip/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2014 Klaus Post + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/Godeps/_workspace/src/github.com/klauspost/pgzip/README.md b/Godeps/_workspace/src/github.com/klauspost/pgzip/README.md new file mode 100644 index 0000000000..c312f53f73 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/pgzip/README.md @@ -0,0 +1,115 @@ +pgzip +===== + +Go parallel gzip compression/decompression. This is a fully gzip compatible drop in replacement for "compress/gzip". + +This will split compression into blocks that are compressed in parallel. This can be useful for compressing big amounts of data. The output is a standard gzip file. + +The gzip decompression is modified so it decompresses ahead of the current reader. This means that reads will be non-blocking if the decompressor can keep ahead of your code reading from it. CRC calculation also takes place in a separate goroutine. + +You should only use this if you are (de)compressing big amounts of data, say **more than 1MB** at the time, otherwise you will not see any benefit, and it will likely be faster to use the internal gzip library. + +It is important to note that this library creates and reads *standard gzip files*. You do not have to match the compressor/decompressor to get the described speedups, and the gzip files are fully compatible with other gzip readers/writers. + +A golang variant of this is [bgzf](https://godoc.org/github.com/biogo/hts/bgzf), which has the same feature, as well as seeking in the resulting file. The only drawback is a slightly bigger overhead compared to this and pure gzip. See a comparison below. + +[![GoDoc][1]][2] [![Build Status][3]][4] + +[1]: https://godoc.org/github.com/klauspost/pgzip?status.svg +[2]: https://godoc.org/github.com/klauspost/pgzip +[3]: https://travis-ci.org/klauspost/pgzip.svg +[4]: https://travis-ci.org/klauspost/pgzip + +Installation +==== +```go get github.com/klauspost/pgzip``` + +Usage +==== +[Godoc Doumentation](https://godoc.org/github.com/klauspost/pgzip) + +To use as a replacement for gzip, exchange + +```import "compress/gzip"``` +with +```import gzip "github.com/klauspost/pgzip"```. + +# Changes + +* Dec 8, 2015: Decoder now supports the io.WriterTo interface, giving a speedup and less GC pressure. +* Oct 9, 2015: Reduced allocations by ~35 by using sync.Pool. ~15% overall speedup. + +Changes in [github.com/klauspost/compress](https://github.com/klauspost/compress#changelog) are also carried over, so see that for more changes. + +## Compression +The simplest way to use this is to simply do the same as you would when using [compress/gzip](http://golang.org/pkg/compress/gzip). + +To change the block size, use the added (*pgzip.Writer).SetConcurrency(blockSize, blocks int) function. With this you can control the approximate size of your blocks, as well as how many you want to be processing in parallel. Default values for this is SetConcurrency(250000, 16), meaning blocks are split at 250000 bytes and up to 16 blocks can be processing at once before the writer blocks. + + +Example: +``` +var b bytes.Buffer +w := gzip.NewWriter(&b) +w.SetConcurrency(100000, 10) +w.Write([]byte("hello, world\n")) +w.Close() +``` + +To get any performance gains, you should at least be compressing more than 1 megabyte of data at the time. + +You should at least have a block size of 100k and at least a number of blocks that match the number of cores your would like to utilize, but about twice the number of blocks would be the best. + +Another side effect of this is, that it is likely to speed up your other code, since writes to the compressor only blocks if the compressor is already compressing the number of blocks you have specified. This also means you don't have worry about buffering input to the compressor. + +## Decompression + +Decompression works similar to compression. That means that you simply call pgzip the same way as you would call [compress/gzip](http://golang.org/pkg/compress/gzip). + +The only difference is that if you want to specify your own readahead, you have to use `pgzip.NewReaderN(r io.Reader, blockSize, blocks int)` to get a reader with your custom blocksizes. The `blockSize` is the size of each block decoded, and `blocks` is the maximum number of blocks that is decoded ahead. + +See [Example on playground](http://play.golang.org/p/uHv1B5NbDh) + +Performance +==== +## Compression + +See my blog post in [Benchmarks of Golang Gzip](https://blog.klauspost.com/go-gzipdeflate-benchmarks/). + +Compression cost is usually about 0.2% with default settings with a block size of 250k. + +Example with GOMAXPROC set to 8 (quad core with 8 hyperthreads) + +Content is [Matt Mahoneys 10GB corpus](http://mattmahoney.net/dc/10gb.html). Compression level 6. + +Compressor | MB/sec | speedup | size | size overhead (lower=better) +------------|----------|---------|------|--------- +[gzip](http://golang.org/pkg/compress/gzip) (golang) | 7.21MB/s | 1.0x | 4786608902 | 0% +[gzip](http://github.com/klauspost/compress/gzip) (klauspost) | 10.98MB/s | 1.52x | 4781331645 | -0.11% +[pgzip](https://github.com/klauspost/pgzip) (klauspost) | 50.76MB/s|7.04x | 4784121440 | -0.052% +[bgzf](https://godoc.org/github.com/biogo/hts/bgzf) (biogo) | 38.65MB/s | 5.36x | 4924899484 | 2.889% +[pargzip](https://godoc.org/github.com/golang/build/pargzip) (builder) | 32.00MB/s | 4.44x | 4791226567 | 0.096% + +pgzip also contains a [linear time compression](https://github.com/klauspost/compress#linear-time-compression) mode, that will allow compression at ~150MB per core per second, independent of the content. + +See the [complete sheet](https://docs.google.com/spreadsheets/d/1nuNE2nPfuINCZJRMt6wFWhKpToF95I47XjSsc-1rbPQ/edit?usp=sharing) for different content types and compression settings. + +## Decompression + +The decompression speedup is there because it allows you to do other work while the decompression is taking place. + +In the example above, the numbers are as follows on a 4 CPU machine: + +Decompressor | Time | Speedup +-------------|------|-------- +[gzip](http://golang.org/pkg/compress/gzip) (golang) | 1m28.85s | 0% +[pgzip](https://github.com/klauspost/pgzip) (golang) | 43.48s | 104% + +But wait, since gzip decompression is inherently singlethreaded (aside from CRC calculation) how can it be more than 100% faster? Because pgzip due to its design also acts as a buffer. When using ubuffered gzip, you are also waiting for io when you are decompressing. If the gzip decoder can keep up, it will always have data ready for your reader, and you will not be waiting for input to the gzip decompressor to complete. + +This is pretty much an optimal situation for pgzip, but it reflects most common usecases for CPU intensive gzip usage. + +I haven't included [bgzf](https://godoc.org/github.com/biogo/hts/bgzf) in this comparision, since it only can decompress files created by a compatible encoder, and therefore cannot be considered a generic gzip decompressor. But if you are able to compress your files with a bgzf compatible program, you can expect it to scale beyond 100%. + +#License +This contains large portions of code from the go repository - see GO_LICENSE for more information. The changes are released under MIT License. See LICENSE for more information. diff --git a/Godeps/_workspace/src/github.com/klauspost/pgzip/circle.yml b/Godeps/_workspace/src/github.com/klauspost/pgzip/circle.yml new file mode 100644 index 0000000000..67b2b1628f --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/pgzip/circle.yml @@ -0,0 +1,7 @@ +test: + pre: + - go vet ./... + + override: + - go test -v -cpu=1,2,4 . + - go test -v -cpu=2 -race -short . \ No newline at end of file diff --git a/Godeps/_workspace/src/github.com/klauspost/pgzip/gunzip.go b/Godeps/_workspace/src/github.com/klauspost/pgzip/gunzip.go new file mode 100644 index 0000000000..45b846e020 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/pgzip/gunzip.go @@ -0,0 +1,564 @@ +// 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. + +// Package pgzip implements reading and writing of gzip format compressed files, +// as specified in RFC 1952. +// +// This is a drop in replacement for "compress/gzip". +// This will split compression into blocks that are compressed in parallel. +// This can be useful for compressing big amounts of data. +// The gzip decompression has not been modified, but remains in the package, +// so you can use it as a complete replacement for "compress/gzip". +// +// See more at https://github.com/klauspost/pgzip +package pgzip + +import ( + "bufio" + "errors" + "hash" + "io" + "sync" + "time" + + "github.com/klauspost/compress/flate" + "github.com/klauspost/crc32" +) + +const ( + gzipID1 = 0x1f + gzipID2 = 0x8b + gzipDeflate = 8 + flagText = 1 << 0 + flagHdrCrc = 1 << 1 + flagExtra = 1 << 2 + flagName = 1 << 3 + flagComment = 1 << 4 +) + +func makeReader(r io.Reader) flate.Reader { + if rr, ok := r.(flate.Reader); ok { + return rr + } + return bufio.NewReader(r) +} + +var ( + // ErrChecksum is returned when reading GZIP data that has an invalid checksum. + ErrChecksum = errors.New("gzip: invalid checksum") + // ErrHeader is returned when reading GZIP data that has an invalid header. + ErrHeader = errors.New("gzip: invalid header") +) + +// The gzip file stores a header giving metadata about the compressed file. +// That header is exposed as the fields of the Writer and Reader structs. +type Header struct { + Comment string // comment + Extra []byte // "extra data" + ModTime time.Time // modification time + Name string // file name + OS byte // operating system type +} + +// A Reader is an io.Reader that can be read to retrieve +// uncompressed data from a gzip-format compressed file. +// +// In general, a gzip file can be a concatenation of gzip files, +// each with its own header. Reads from the Reader +// return the concatenation of the uncompressed data of each. +// Only the first header is recorded in the Reader fields. +// +// Gzip files store a length and checksum of the uncompressed data. +// The Reader will return a ErrChecksum when Read +// reaches the end of the uncompressed data if it does not +// have the expected length or checksum. Clients should treat data +// returned by Read as tentative until they receive the io.EOF +// marking the end of the data. +type Reader struct { + Header + r flate.Reader + decompressor io.ReadCloser + digest hash.Hash32 + size uint32 + flg byte + buf [512]byte + err error + closeErr chan error + multistream bool + + readAhead chan read + roff int // read offset + current []byte + closeReader chan struct{} + lastBlock bool + blockSize int + blocks int + + activeRA bool // Indication if readahead is active + mu sync.Mutex // Lock for above + + blockPool chan []byte +} + +type read struct { + b []byte + err error +} + +// NewReader creates a new Reader reading the given reader. +// The implementation buffers input and may read more data than necessary from r. +// It is the caller's responsibility to call Close on the Reader when done. +func NewReader(r io.Reader) (*Reader, error) { + z := new(Reader) + z.blocks = defaultBlocks + z.blockSize = defaultBlockSize + z.r = makeReader(r) + z.digest = crc32.NewIEEE() + z.multistream = true + z.blockPool = make(chan []byte, z.blocks) + for i := 0; i < z.blocks; i++ { + z.blockPool <- make([]byte, z.blockSize) + } + if err := z.readHeader(true); err != nil { + return nil, err + } + return z, nil +} + +// NewReaderN creates a new Reader reading the given reader. +// The implementation buffers input and may read more data than necessary from r. +// It is the caller's responsibility to call Close on the Reader when done. +// +// With this you can control the approximate size of your blocks, +// as well as how many blocks you want to have prefetched. +// +// Default values for this is blockSize = 250000, blocks = 16, +// meaning up to 16 blocks of maximum 250000 bytes will be +// prefetched. +func NewReaderN(r io.Reader, blockSize, blocks int) (*Reader, error) { + z := new(Reader) + z.blocks = blocks + z.blockSize = blockSize + z.r = makeReader(r) + z.digest = crc32.NewIEEE() + z.multistream = true + + // Account for too small values + if z.blocks <= 0 { + z.blocks = defaultBlocks + } + if z.blockSize <= 512 { + z.blockSize = defaultBlockSize + } + z.blockPool = make(chan []byte, z.blocks) + for i := 0; i < z.blocks; i++ { + z.blockPool <- make([]byte, z.blockSize) + } + if err := z.readHeader(true); err != nil { + return nil, err + } + return z, nil +} + +// Reset discards the Reader z's state and makes it equivalent to the +// result of its original state from NewReader, but reading from r instead. +// This permits reusing a Reader rather than allocating a new one. +func (z *Reader) Reset(r io.Reader) error { + z.killReadAhead() + z.r = makeReader(r) + z.digest = crc32.NewIEEE() + z.size = 0 + z.err = nil + z.multistream = true + + // Account for uninitialized values + if z.blocks <= 0 { + z.blocks = defaultBlocks + } + if z.blockSize <= 512 { + z.blockSize = defaultBlockSize + } + + if z.blockPool == nil { + z.blockPool = make(chan []byte, z.blocks) + for i := 0; i < z.blocks; i++ { + z.blockPool <- make([]byte, z.blockSize) + } + } + + return z.readHeader(true) +} + +// Multistream controls whether the reader supports multistream files. +// +// If enabled (the default), the Reader expects the input to be a sequence +// of individually gzipped data streams, each with its own header and +// trailer, ending at EOF. The effect is that the concatenation of a sequence +// of gzipped files is treated as equivalent to the gzip of the concatenation +// of the sequence. This is standard behavior for gzip readers. +// +// Calling Multistream(false) disables this behavior; disabling the behavior +// can be useful when reading file formats that distinguish individual gzip +// data streams or mix gzip data streams with other data streams. +// In this mode, when the Reader reaches the end of the data stream, +// Read returns io.EOF. If the underlying reader implements io.ByteReader, +// it will be left positioned just after the gzip stream. +// To start the next stream, call z.Reset(r) followed by z.Multistream(false). +// If there is no next stream, z.Reset(r) will return io.EOF. +func (z *Reader) Multistream(ok bool) { + z.multistream = ok +} + +// GZIP (RFC 1952) is little-endian, unlike ZLIB (RFC 1950). +func get4(p []byte) uint32 { + return uint32(p[0]) | uint32(p[1])<<8 | uint32(p[2])<<16 | uint32(p[3])<<24 +} + +func (z *Reader) readString() (string, error) { + var err error + needconv := false + for i := 0; ; i++ { + if i >= len(z.buf) { + return "", ErrHeader + } + z.buf[i], err = z.r.ReadByte() + if err != nil { + return "", err + } + if z.buf[i] > 0x7f { + needconv = true + } + if z.buf[i] == 0 { + // GZIP (RFC 1952) specifies that strings are NUL-terminated ISO 8859-1 (Latin-1). + if needconv { + s := make([]rune, 0, i) + for _, v := range z.buf[0:i] { + s = append(s, rune(v)) + } + return string(s), nil + } + return string(z.buf[0:i]), nil + } + } +} + +func (z *Reader) read2() (uint32, error) { + _, err := io.ReadFull(z.r, z.buf[0:2]) + if err != nil { + return 0, err + } + return uint32(z.buf[0]) | uint32(z.buf[1])<<8, nil +} + +func (z *Reader) readHeader(save bool) error { + z.killReadAhead() + + _, err := io.ReadFull(z.r, z.buf[0:10]) + if err != nil { + return err + } + if z.buf[0] != gzipID1 || z.buf[1] != gzipID2 || z.buf[2] != gzipDeflate { + return ErrHeader + } + z.flg = z.buf[3] + if save { + z.ModTime = time.Unix(int64(get4(z.buf[4:8])), 0) + // z.buf[8] is xfl, ignored + z.OS = z.buf[9] + } + z.digest.Reset() + z.digest.Write(z.buf[0:10]) + + if z.flg&flagExtra != 0 { + n, err := z.read2() + if err != nil { + return err + } + data := make([]byte, n) + if _, err = io.ReadFull(z.r, data); err != nil { + return err + } + if save { + z.Extra = data + } + } + + var s string + if z.flg&flagName != 0 { + if s, err = z.readString(); err != nil { + return err + } + if save { + z.Name = s + } + } + + if z.flg&flagComment != 0 { + if s, err = z.readString(); err != nil { + return err + } + if save { + z.Comment = s + } + } + + if z.flg&flagHdrCrc != 0 { + n, err := z.read2() + if err != nil { + return err + } + sum := z.digest.Sum32() & 0xFFFF + if n != sum { + return ErrHeader + } + } + + z.digest.Reset() + z.decompressor = flate.NewReader(z.r) + z.doReadAhead() + return nil +} + +func (z *Reader) killReadAhead() error { + z.mu.Lock() + defer z.mu.Unlock() + if z.activeRA { + if z.closeReader != nil { + close(z.closeReader) + } + + // Wait for decompressor to be closed and return error, if any. + e, ok := <-z.closeErr + z.activeRA = false + if !ok { + // Channel is closed, so if there was any error it has already been returned. + return nil + } + return e + } + return nil +} + +// Starts readahead. +// Will return on error (including io.EOF) +// or when z.closeReader is closed. +func (z *Reader) doReadAhead() { + z.mu.Lock() + defer z.mu.Unlock() + z.activeRA = true + + if z.blocks <= 0 { + z.blocks = defaultBlocks + } + if z.blockSize <= 512 { + z.blockSize = defaultBlockSize + } + ra := make(chan read, z.blocks) + z.readAhead = ra + closeReader := make(chan struct{}, 0) + z.closeReader = closeReader + z.lastBlock = false + closeErr := make(chan error, 1) + z.closeErr = closeErr + z.size = 0 + z.roff = 0 + z.current = nil + decomp := z.decompressor + + go func() { + defer func() { + closeErr <- decomp.Close() + close(closeErr) + close(ra) + }() + + // We hold a local reference to digest, since + // it way be changed by reset. + digest := z.digest + var wg sync.WaitGroup + for { + var buf []byte + select { + case buf = <-z.blockPool: + case <-closeReader: + return + } + buf = buf[0:z.blockSize] + // Try to fill the buffer + n, err := io.ReadFull(decomp, buf) + if err == io.ErrUnexpectedEOF { + err = nil + } + if n < len(buf) { + buf = buf[0:n] + } + wg.Wait() + wg.Add(1) + go func() { + digest.Write(buf) + wg.Done() + }() + z.size += uint32(n) + + // If we return any error, out digest must be ready + if err != nil { + wg.Wait() + } + select { + case z.readAhead <- read{b: buf, err: err}: + case <-closeReader: + // Sent on close, we don't care about the next results + return + } + if err != nil { + return + } + } + }() +} + +func (z *Reader) Read(p []byte) (n int, err error) { + if z.err != nil { + return 0, z.err + } + if len(p) == 0 { + return 0, nil + } + + for { + if len(z.current) == 0 && !z.lastBlock { + read := <-z.readAhead + + if read.err != nil { + // If not nil, the reader will have exited + z.closeReader = nil + + if read.err != io.EOF { + z.err = read.err + return + } + if read.err == io.EOF { + z.lastBlock = true + err = nil + } + } + z.current = read.b + z.roff = 0 + } + avail := z.current[z.roff:] + if len(p) >= len(avail) { + // If len(p) >= len(current), return all content of current + n = copy(p, avail) + z.blockPool <- z.current + z.current = nil + if z.lastBlock { + err = io.EOF + break + } + } else { + // We copy as much as there is space for + n = copy(p, avail) + z.roff += n + } + return + } + + // Finished file; check checksum + size. + if _, err := io.ReadFull(z.r, z.buf[0:8]); err != nil { + z.err = err + return 0, err + } + crc32, isize := get4(z.buf[0:4]), get4(z.buf[4:8]) + sum := z.digest.Sum32() + if sum != crc32 || isize != z.size { + z.err = ErrChecksum + return 0, z.err + } + + // File is ok; should we attempt reading one more? + if !z.multistream { + return 0, io.EOF + } + + // Is there another? + if err = z.readHeader(false); err != nil { + z.err = err + return + } + + // Yes. Reset and read from it. + return z.Read(p) +} + +func (z *Reader) WriteTo(w io.Writer) (n int64, err error) { + total := int64(0) + for { + if z.err != nil { + return total, z.err + } + // We write both to output and digest. + for { + // Read from input + read := <-z.readAhead + if read.err != nil { + // If not nil, the reader will have exited + z.closeReader = nil + + if read.err != io.EOF { + z.err = read.err + return total, z.err + } + if read.err == io.EOF { + z.lastBlock = true + err = nil + } + } + // Write what we got + n, err := w.Write(read.b) + if n != len(read.b) { + return total, io.ErrShortWrite + } + total += int64(n) + if err != nil { + return total, err + } + // Put block back + z.blockPool <- read.b + if z.lastBlock { + break + } + } + + // Finished file; check checksum + size. + if _, err := io.ReadFull(z.r, z.buf[0:8]); err != nil { + z.err = err + return total, err + } + crc32, isize := get4(z.buf[0:4]), get4(z.buf[4:8]) + sum := z.digest.Sum32() + if sum != crc32 || isize != z.size { + z.err = ErrChecksum + return total, z.err + } + // File is ok; should we attempt reading one more? + if !z.multistream { + return total, nil + } + + // Is there another? + err = z.readHeader(false) + if err == io.EOF { + return total, nil + } + if err != nil { + z.err = err + return total, err + } + } +} + +// Close closes the Reader. It does not close the underlying io.Reader. +func (z *Reader) Close() error { + return z.killReadAhead() +} diff --git a/Godeps/_workspace/src/github.com/klauspost/pgzip/gzip.go b/Godeps/_workspace/src/github.com/klauspost/pgzip/gzip.go new file mode 100644 index 0000000000..872afe7eb0 --- /dev/null +++ b/Godeps/_workspace/src/github.com/klauspost/pgzip/gzip.go @@ -0,0 +1,485 @@ +// 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. + +package pgzip + +import ( + "bytes" + "errors" + "fmt" + "hash" + "io" + "sync" + + "github.com/klauspost/compress/flate" + "github.com/klauspost/crc32" +) + +const ( + defaultBlockSize = 250000 + tailSize = 16384 + defaultBlocks = 16 +) + +// These constants are copied from the flate package, so that code that imports +// "compress/gzip" does not also have to import "compress/flate". +const ( + NoCompression = flate.NoCompression + BestSpeed = flate.BestSpeed + BestCompression = flate.BestCompression + DefaultCompression = flate.DefaultCompression + ConstantCompression = flate.ConstantCompression +) + +// A Writer is an io.WriteCloser. +// Writes to a Writer are compressed and written to w. +type Writer struct { + Header + w io.Writer + level int + wroteHeader bool + blockSize int + blocks int + currentBuffer []byte + prevTail []byte + digest hash.Hash32 + size int + closed bool + buf [10]byte + err error + pushedErr chan error + results chan result + dictFlatePool *sync.Pool + dstPool *sync.Pool +} + +type result struct { + result chan []byte + notifyWritten chan struct{} +} + +// Use SetConcurrency to finetune the concurrency level if needed. +// +// With this you can control the approximate size of your blocks, +// as well as how many you want to be processing in parallel. +// +// Default values for this is SetConcurrency(250000, 16), +// meaning blocks are split at 250000 bytes and up to 16 blocks +// can be processing at once before the writer blocks. +func (z *Writer) SetConcurrency(blockSize, blocks int) error { + if blockSize <= tailSize { + return fmt.Errorf("gzip: block size cannot be less than or equal to %d", tailSize) + } + if blocks <= 0 { + return errors.New("gzip: blocks cannot be zero or less") + } + z.blockSize = blockSize + z.results = make(chan result, blocks) + z.blocks = blocks + return nil +} + +// NewWriter returns a new Writer. +// Writes to the returned writer are compressed and written to w. +// +// It is the caller's responsibility to call Close on the WriteCloser when done. +// Writes may be buffered and not flushed until Close. +// +// Callers that wish to set the fields in Writer.Header must do so before +// the first call to Write or Close. The Comment and Name header fields are +// UTF-8 strings in Go, but the underlying format requires NUL-terminated ISO +// 8859-1 (Latin-1). NUL or non-Latin-1 runes in those strings will lead to an +// error on Write. +func NewWriter(w io.Writer) *Writer { + z, _ := NewWriterLevel(w, DefaultCompression) + return z +} + +// NewWriterLevel is like NewWriter but specifies the compression level instead +// of assuming DefaultCompression. +// +// The compression level can be DefaultCompression, NoCompression, or any +// integer value between BestSpeed and BestCompression inclusive. The error +// returned will be nil if the level is valid. +func NewWriterLevel(w io.Writer, level int) (*Writer, error) { + if level < ConstantCompression || level > BestCompression { + return nil, fmt.Errorf("gzip: invalid compression level: %d", level) + } + z := new(Writer) + z.SetConcurrency(defaultBlockSize, defaultBlocks) + z.init(w, level) + return z, nil +} + +// This function must be used by goroutines to set an +// error condition, since z.err access is restricted +// to the callers goruotine. +func (z *Writer) pushError(err error) { + z.pushedErr <- err + close(z.pushedErr) +} + +func (z *Writer) init(w io.Writer, level int) { + digest := z.digest + if digest != nil { + digest.Reset() + } else { + digest = crc32.NewIEEE() + } + + *z = Writer{ + Header: Header{ + OS: 255, // unknown + }, + w: w, + level: level, + digest: digest, + pushedErr: make(chan error, 1), + results: make(chan result, z.blocks), + blockSize: z.blockSize, + blocks: z.blocks, + } + z.dictFlatePool = &sync.Pool{ + New: func() interface{} { + f, _ := flate.NewWriterDict(w, level, nil) + return f + }, + } + z.dstPool = &sync.Pool{New: func() interface{} { return make([]byte, 0, z.blockSize) }} + +} + +// Reset discards the Writer z's state and makes it equivalent to the +// result of its original state from NewWriter or NewWriterLevel, but +// writing to w instead. This permits reusing a Writer rather than +// allocating a new one. +func (z *Writer) Reset(w io.Writer) { + if z.results != nil && !z.closed { + close(z.results) + } + z.SetConcurrency(defaultBlockSize, defaultBlocks) + z.init(w, z.level) +} + +// GZIP (RFC 1952) is little-endian, unlike ZLIB (RFC 1950). +func put2(p []byte, v uint16) { + p[0] = uint8(v >> 0) + p[1] = uint8(v >> 8) +} + +func put4(p []byte, v uint32) { + p[0] = uint8(v >> 0) + p[1] = uint8(v >> 8) + p[2] = uint8(v >> 16) + p[3] = uint8(v >> 24) +} + +// writeBytes writes a length-prefixed byte slice to z.w. +func (z *Writer) writeBytes(b []byte) error { + if len(b) > 0xffff { + return errors.New("gzip.Write: Extra data is too large") + } + put2(z.buf[0:2], uint16(len(b))) + _, err := z.w.Write(z.buf[0:2]) + if err != nil { + return err + } + _, err = z.w.Write(b) + return err +} + +// writeString writes a UTF-8 string s in GZIP's format to z.w. +// GZIP (RFC 1952) specifies that strings are NUL-terminated ISO 8859-1 (Latin-1). +func (z *Writer) writeString(s string) (err error) { + // GZIP stores Latin-1 strings; error if non-Latin-1; convert if non-ASCII. + needconv := false + for _, v := range s { + if v == 0 || v > 0xff { + return errors.New("gzip.Write: non-Latin-1 header string") + } + if v > 0x7f { + needconv = true + } + } + if needconv { + b := make([]byte, 0, len(s)) + for _, v := range s { + b = append(b, byte(v)) + } + _, err = z.w.Write(b) + } else { + _, err = io.WriteString(z.w, s) + } + if err != nil { + return err + } + // GZIP strings are NUL-terminated. + z.buf[0] = 0 + _, err = z.w.Write(z.buf[0:1]) + return err +} + +// compressCurrent will compress the data currently buffered +// This should only be called from the main writer/flush/closer +func (z *Writer) compressCurrent(flush bool) { + r := result{} + r.result = make(chan []byte, 1) + r.notifyWritten = make(chan struct{}, 0) + z.results <- r + + // If block given is more than twice the block size, split it. + c := z.currentBuffer + if len(c) > z.blockSize*2 { + c = c[:z.blockSize] + go compressBlock(c, z.prevTail, *z, r) + z.prevTail = c[len(c)-tailSize:] + z.currentBuffer = z.currentBuffer[z.blockSize:] + z.compressCurrent(flush) + // Last one flushes if needed + return + } + + go compressBlock(c, z.prevTail, *z, r) + if len(c) > tailSize { + z.prevTail = c[len(c)-tailSize:] + } else { + z.prevTail = nil + } + z.currentBuffer = make([]byte, 0, z.blockSize+(z.blockSize/4)) + + // Wait if flushing + if flush { + _ = <-r.notifyWritten + } +} + +// Returns an error if it has been set. +// Cannot be used by functions that are from internal goroutines. +func (z *Writer) checkError() error { + if z.err != nil { + return z.err + } + select { + case err := <-z.pushedErr: + z.err = err + default: + } + return z.err +} + +// Write writes a compressed form of p to the underlying io.Writer. The +// compressed bytes are not necessarily flushed to output until +// the Writer is closed or Flush() is called. +// +// The function will return quickly, if there are unused buffers. +// The sent slice (p) is copied, and the caller is free to re-use the buffer +// when the function returns. +// +// Errors that occur during compression will be reported later, and a nil error +// does not signify that the compression succeeded (since it is most likely still running) +// That means that the call that returns an error may not be the call that caused it. +// Only Flush and Close functions are guaranteed to return any errors up to that point. +func (z *Writer) Write(p []byte) (int, error) { + if z.checkError() != nil { + return 0, z.err + } + // Write the GZIP header lazily. + if !z.wroteHeader { + z.wroteHeader = true + z.buf[0] = gzipID1 + z.buf[1] = gzipID2 + z.buf[2] = gzipDeflate + z.buf[3] = 0 + if z.Extra != nil { + z.buf[3] |= 0x04 + } + if z.Name != "" { + z.buf[3] |= 0x08 + } + if z.Comment != "" { + z.buf[3] |= 0x10 + } + put4(z.buf[4:8], uint32(z.ModTime.Unix())) + if z.level == BestCompression { + z.buf[8] = 2 + } else if z.level == BestSpeed { + z.buf[8] = 4 + } else { + z.buf[8] = 0 + } + z.buf[9] = z.OS + var n int + n, z.err = z.w.Write(z.buf[0:10]) + if z.err != nil { + return n, z.err + } + if z.Extra != nil { + z.err = z.writeBytes(z.Extra) + if z.err != nil { + return n, z.err + } + } + if z.Name != "" { + z.err = z.writeString(z.Name) + if z.err != nil { + return n, z.err + } + } + if z.Comment != "" { + z.err = z.writeString(z.Comment) + if z.err != nil { + return n, z.err + } + } + // Start receiving data from compressors + go func() { + listen := z.results + for { + r, ok := <-listen + // If closed, we are finished. + if !ok { + return + } + buf := <-r.result + n, err := z.w.Write(buf) + if err != nil { + z.pushError(err) + close(r.notifyWritten) + return + } + if n != len(buf) { + z.pushError(fmt.Errorf("gzip: short write %d should be %d", n, len(buf))) + close(r.notifyWritten) + return + } + z.dstPool.Put(buf) + close(r.notifyWritten) + } + }() + z.currentBuffer = make([]byte, 0, z.blockSize+(z.blockSize/4)) + } + // Handle very large writes in a loop + if len(p) > z.blockSize*z.blocks { + q := p + for len(q) > 0 { + length := len(q) + if length > z.blockSize { + length = z.blockSize + } + z.digest.Write(q[:length]) + z.currentBuffer = append(z.currentBuffer, q[:length]...) + if len(z.currentBuffer) >= z.blockSize { + z.compressCurrent(false) + if z.err != nil { + return len(p) - len(q) - length, z.err + } + } + z.size += length + q = q[length:] + } + return len(p), z.err + } else { + z.size += len(p) + z.digest.Write(p) + z.currentBuffer = append(z.currentBuffer, p...) + if len(z.currentBuffer) >= z.blockSize { + z.compressCurrent(false) + } + return len(p), z.err + } +} + +// Step 1: compresses buffer to buffer +// Step 2: send writer to channel +// Step 3: Close result channel to indicate we are done +func compressBlock(p, prevTail []byte, z Writer, r result) { + defer close(r.result) + buf := z.dstPool.Get().([]byte) + dest := bytes.NewBuffer(buf[:0]) + + compressor := z.dictFlatePool.Get().(*flate.Writer) + compressor.ResetDict(dest, prevTail) + compressor.Write(p) + + err := compressor.Flush() + if err != nil { + z.pushError(err) + return + } + if z.closed { + err = compressor.Close() + if err != nil { + z.pushError(err) + return + } + } + z.dictFlatePool.Put(compressor) + // Read back buffer + buf = dest.Bytes() + r.result <- buf +} + +// Flush flushes any pending compressed data to the underlying writer. +// +// It is useful mainly in compressed network protocols, to ensure that +// a remote reader has enough data to reconstruct a packet. Flush does +// not return until the data has been written. If the underlying +// writer returns an error, Flush returns that error. +// +// In the terminology of the zlib library, Flush is equivalent to Z_SYNC_FLUSH. +func (z *Writer) Flush() error { + if z.checkError() != nil { + return z.err + } + if z.closed { + return nil + } + if !z.wroteHeader { + _, err := z.Write(nil) + if err != nil { + return err + } + } + // We send current block to compression + z.compressCurrent(true) + if z.checkError() != nil { + return z.err + } + + return nil +} + +// UncompressedSize will return the number of bytes written. +// pgzip only, not a function in the official gzip package. +func (z Writer) UncompressedSize() int { + return z.size +} + +// Close closes the Writer, flushing any unwritten data to the underlying +// io.Writer, but does not close the underlying io.Writer. +func (z *Writer) Close() error { + if z.checkError() != nil { + return z.err + } + if z.closed { + return nil + } + + z.closed = true + if !z.wroteHeader { + z.Write(nil) + if z.err != nil { + return z.err + } + } + z.compressCurrent(true) + if z.checkError() != nil { + return z.err + } + close(z.results) + put4(z.buf[0:4], z.digest.Sum32()) + put4(z.buf[4:8], uint32(z.size)) + _, z.err = z.w.Write(z.buf[0:8]) + return z.err +} diff --git a/rkt/image/dockerfetcher.go b/rkt/image/dockerfetcher.go index c41c2e3ef6..e7d71b50fa 100644 --- a/rkt/image/dockerfetcher.go +++ b/rkt/image/dockerfetcher.go @@ -106,7 +106,10 @@ func (f *dockerFetcher) fetch(u *url.URL) (*os.File, error) { config := docker2aci.RemoteConfig{ Username: user, Password: password, - Insecure: f.InsecureFlags.AllowHTTP(), + Insecure: d2acommon.InsecureConfig{ + SkipVerify: f.InsecureFlags.SkipTLSCheck(), + AllowHTTP: f.InsecureFlags.AllowHTTP(), + }, CommonConfig: docker2aci.CommonConfig{ Squash: true, OutputDir: tmpDir, From 4c7cd429e55a0377cb822f0168342bb51c3ec860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 13 Apr 2016 15:28:09 +0200 Subject: [PATCH 0324/1304] rkt/gc: mount stage1 on GC It might happen that stage1 is unmounted between the time where the pod was stopped and it is GCd. This causes the stage1 GC or the CNI plugins not to be accessible. To fix it, we mount stage1 from the treestore at GC time. --- rkt/gc.go | 57 ++++++++++++++++++++++++++++++++++++++++++---------- stage0/gc.go | 7 +++++-- 2 files changed, 51 insertions(+), 13 deletions(-) diff --git a/rkt/gc.go b/rkt/gc.go index b671a9db12..2911101c17 100644 --- a/rkt/gc.go +++ b/rkt/gc.go @@ -17,13 +17,17 @@ package main import ( + "errors" "fmt" "os" + "path/filepath" "syscall" "time" + "github.com/coreos/rkt/common" "github.com/coreos/rkt/stage0" "github.com/coreos/rkt/store" + "github.com/hashicorp/errwrap" "github.com/spf13/cobra" ) @@ -191,6 +195,31 @@ func emptyGarbage() error { return nil } +func mountPodStage1(s *store.Store, p *pod) error { + if !p.usesOverlay() { + return nil + } + + s1Id, err := p.getStage1TreeStoreID() + if err != nil { + return errwrap.Wrap(errors.New("error getting stage1 treeStoreID"), err) + } + s1rootfs := s.GetTreeStoreRootFS(s1Id) + + stage1Dir := common.Stage1RootfsPath(p.path()) + overlayDir := filepath.Join(p.path(), "overlay") + imgDir := filepath.Join(overlayDir, s1Id) + upperDir := filepath.Join(imgDir, "upper") + workDir := filepath.Join(imgDir, "work") + + opts := fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", s1rootfs, upperDir, workDir) + if err := syscall.Mount("overlay", stage1Dir, "overlay", 0, opts); err != nil { + return errwrap.Wrap(errors.New("error mounting stage1"), err) + } + + return nil +} + // deletePod cleans up files and resource associated with the pod // pod must be under exclusive lock and be in either ExitedGarbage // or Garbage state @@ -207,19 +236,25 @@ func deletePod(p *pod) { } defer s.Close() - // execute stage1's GC - stage1TreeStoreID, err := p.getStage1TreeStoreID() - if err != nil { - stderr.PrintE("error getting stage1 treeStoreID", err) - stderr.Print("skipping stage1 GC") - } else { - if globalFlags.Debug { - stage0.InitDebug() - } - stage1RootFS := s.GetTreeStoreRootFS(stage1TreeStoreID) - if err = stage0.GC(p.path(), p.uuid, stage1RootFS); err != nil { + if globalFlags.Debug { + stage0.InitDebug() + } + + if err := mountPodStage1(s, p); err == nil { + if err = stage0.GC(p.path(), p.uuid); err != nil { stderr.PrintE(fmt.Sprintf("problem performing stage1 GC on %q", p.uuid), err) } + // an overlay fs can be mounted over itself, let's unmount it here + // if we mounted it before to avoid problems when running + // stage0.MountGC + if p.usesOverlay() { + stage1Mnt := common.Stage1RootfsPath(p.path()) + if err := syscall.Unmount(stage1Mnt, 0); err != nil { + stderr.PrintE("error unmounting stage1", err) + } + } + } else { + stderr.PrintE("skipping stage1 GC", err) } // unmount all leftover mounts diff --git a/stage0/gc.go b/stage0/gc.go index 3bb3f8781e..3f548611a0 100644 --- a/stage0/gc.go +++ b/stage0/gc.go @@ -29,20 +29,23 @@ import ( "strings" "syscall" + "github.com/coreos/rkt/common" + "github.com/appc/spec/schema/types" "github.com/hashicorp/errwrap" ) // GC enters the pod by fork/exec()ing the stage1's /gc similar to /init. // /gc can expect to have its CWD set to the pod root. -// stage1Path is the path of the stage1 rootfs -func GC(pdir string, uuid *types.UUID, stage1Path string) error { +func GC(pdir string, uuid *types.UUID) error { err := unregisterPod(pdir, uuid) if err != nil { // Probably not worth abandoning the rest log.PrintE("warning: could not unregister pod with metadata service", err) } + stage1Path := common.Stage1RootfsPath(pdir) + ep, err := getStage1Entrypoint(pdir, gcEntrypoint) if err != nil { return errwrap.Wrap(errors.New("error determining 'gc' entrypoint"), err) From 3d0eff1f631407e72174bbd13590953fe5c15275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Thu, 26 May 2016 16:10:19 +0200 Subject: [PATCH 0325/1304] functional tests: add GC-after-unmount test --- tests/rkt_gc_test.go | 74 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 61 insertions(+), 13 deletions(-) diff --git a/tests/rkt_gc_test.go b/tests/rkt_gc_test.go index 00a1c83e78..3dd4b9b780 100644 --- a/tests/rkt_gc_test.go +++ b/tests/rkt_gc_test.go @@ -21,8 +21,10 @@ import ( "io/ioutil" "os" "path/filepath" + "syscall" "testing" + "github.com/coreos/rkt/common" "github.com/coreos/rkt/tests/testutils" ) @@ -45,32 +47,78 @@ func TestGC(t *testing.T) { gcCmd := fmt.Sprintf("%s gc --mark-only=true --expire-prepared=0 --grace-period=0", ctx.Cmd()) spawnAndWaitOrFail(t, gcCmd, 0) + pods := podsRemaining(t, ctx) + if len(pods) == 0 { + t.Fatalf("pods should still be present in rkt's data directory") + } + + gcCmd = fmt.Sprintf("%s gc --mark-only=false --expire-prepared=0 --grace-period=0", ctx.Cmd()) + spawnAndWaitOrFail(t, gcCmd, 0) + + pods = podsRemaining(t, ctx) + if len(pods) != 0 { + t.Fatalf("no pods should exist rkt's data directory, but found: %v", pods) + } +} + +func podsRemaining(t *testing.T, ctx *testutils.RktRunCtx) []os.FileInfo { gcDirs := []string{ filepath.Join(ctx.DataDir(), "pods", "exited-garbage"), filepath.Join(ctx.DataDir(), "pods", "prepared"), filepath.Join(ctx.DataDir(), "pods", "garbage"), + filepath.Join(ctx.DataDir(), "pods", "run"), } + var remainingPods []os.FileInfo for _, dir := range gcDirs { pods, err := ioutil.ReadDir(dir) if err != nil { t.Fatalf("cannot read gc directory %q: %v", dir, err) } - if len(pods) == 0 { - t.Fatalf("pods should still exist in directory %q", dir) - } + remainingPods = append(remainingPods, pods...) } - gcCmd = fmt.Sprintf("%s gc --mark-only=false --expire-prepared=0 --grace-period=0", ctx.Cmd()) - spawnAndWaitOrFail(t, gcCmd, 0) + return remainingPods +} - for _, dir := range gcDirs { - pods, err := ioutil.ReadDir(dir) - if err != nil { - t.Fatalf("cannot read gc directory %q: %v", dir, err) - } - if len(pods) != 0 { - t.Fatalf("no pods should exist in directory %q, but found: %v", dir, pods) - } +func TestGCAfterUnmount(t *testing.T) { + if !common.SupportsOverlay() { + t.Skip("Overlay fs not supported.") + } + + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + imagePath := patchImportAndFetchHash("inspect-gc-test-run.aci", []string{"--exec=/inspect --print-msg=HELLO_API --exit-code=0"}, t, ctx) + defer os.Remove(imagePath) + cmd := fmt.Sprintf("%s --insecure-options=image prepare %s", ctx.Cmd(), imagePath) + uuid := runRktAndGetUUID(t, cmd) + + cmd = fmt.Sprintf("%s run-prepared %s", ctx.Cmd(), uuid) + runRktAndCheckOutput(t, cmd, "", false) + + stage1MntPath := filepath.Join(ctx.DataDir(), "pods", "run", uuid, "stage1", "rootfs") + stage2MntPath := filepath.Join(stage1MntPath, "opt", "stage2", "rkt-inspect", "rootfs") + + if err := syscall.Unmount(stage2MntPath, 0); err != nil { + t.Fatalf("cannot umount stage2: %v", err) + } + + if err := syscall.Unmount(stage1MntPath, 0); err != nil { + t.Fatalf("cannot umount stage1: %v", err) + } + + pods := podsRemaining(t, ctx) + if len(pods) == 0 { + t.Fatalf("pods should still be present in rkt's data directory") + } + + gcCmd := fmt.Sprintf("%s gc --mark-only=false --expire-prepared=0 --grace-period=0", ctx.Cmd()) + // check we don't get any output (an error) after "executing net-plugin..." + runRktAndCheckRegexOutput(t, gcCmd, `executing net-plugin .*\n\z`) + + pods = podsRemaining(t, ctx) + if len(pods) != 0 { + t.Fatalf("no pods should exist rkt's data directory, but found: %v", pods) } } From aef9bc41cdf40909957cd6042aa62fe4569beeb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Thu, 26 May 2016 16:52:50 +0200 Subject: [PATCH 0326/1304] functional tests: test GC with netns unmounted and rm'd --- tests/rkt_gc_test.go | 67 ++++++++++++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 24 deletions(-) diff --git a/tests/rkt_gc_test.go b/tests/rkt_gc_test.go index 3dd4b9b780..9c1a6e1920 100644 --- a/tests/rkt_gc_test.go +++ b/tests/rkt_gc_test.go @@ -89,36 +89,55 @@ func TestGCAfterUnmount(t *testing.T) { ctx := testutils.NewRktRunCtx() defer ctx.Cleanup() - imagePath := patchImportAndFetchHash("inspect-gc-test-run.aci", []string{"--exec=/inspect --print-msg=HELLO_API --exit-code=0"}, t, ctx) - defer os.Remove(imagePath) - cmd := fmt.Sprintf("%s --insecure-options=image prepare %s", ctx.Cmd(), imagePath) - uuid := runRktAndGetUUID(t, cmd) + for _, rmNetns := range []bool{false, true} { - cmd = fmt.Sprintf("%s run-prepared %s", ctx.Cmd(), uuid) - runRktAndCheckOutput(t, cmd, "", false) + imagePath := patchImportAndFetchHash("inspect-gc-test-run.aci", []string{"--exec=/inspect --print-msg=HELLO_API --exit-code=0"}, t, ctx) + defer os.Remove(imagePath) + cmd := fmt.Sprintf("%s --insecure-options=image prepare %s", ctx.Cmd(), imagePath) + uuid := runRktAndGetUUID(t, cmd) - stage1MntPath := filepath.Join(ctx.DataDir(), "pods", "run", uuid, "stage1", "rootfs") - stage2MntPath := filepath.Join(stage1MntPath, "opt", "stage2", "rkt-inspect", "rootfs") + cmd = fmt.Sprintf("%s run-prepared %s", ctx.Cmd(), uuid) + runRktAndCheckOutput(t, cmd, "", false) - if err := syscall.Unmount(stage2MntPath, 0); err != nil { - t.Fatalf("cannot umount stage2: %v", err) - } + podDir := filepath.Join(ctx.DataDir(), "pods", "run", uuid) + stage1MntPath := filepath.Join(podDir, "stage1", "rootfs") + stage2MntPath := filepath.Join(stage1MntPath, "opt", "stage2", "rkt-inspect", "rootfs") + netnsPath := filepath.Join(podDir, "netns") + podNetNSPathBytes, err := ioutil.ReadFile(netnsPath) + if err != nil { + t.Fatalf(`cannot read "netns" stage1: %v`, err) + } + podNetNSPath := string(podNetNSPathBytes) - if err := syscall.Unmount(stage1MntPath, 0); err != nil { - t.Fatalf("cannot umount stage1: %v", err) - } + if err := syscall.Unmount(stage2MntPath, 0); err != nil { + t.Fatalf("cannot umount stage2: %v", err) + } - pods := podsRemaining(t, ctx) - if len(pods) == 0 { - t.Fatalf("pods should still be present in rkt's data directory") - } + if err := syscall.Unmount(stage1MntPath, 0); err != nil { + t.Fatalf("cannot umount stage1: %v", err) + } - gcCmd := fmt.Sprintf("%s gc --mark-only=false --expire-prepared=0 --grace-period=0", ctx.Cmd()) - // check we don't get any output (an error) after "executing net-plugin..." - runRktAndCheckRegexOutput(t, gcCmd, `executing net-plugin .*\n\z`) + if err := syscall.Unmount(podNetNSPath, 0); err != nil { + t.Fatalf("cannot umount pod netns: %v", err) + } + + if rmNetns { + _ = os.RemoveAll(podNetNSPath) + } + + pods := podsRemaining(t, ctx) + if len(pods) == 0 { + t.Fatalf("pods should still be present in rkt's data directory") + } + + gcCmd := fmt.Sprintf("%s gc --mark-only=false --expire-prepared=0 --grace-period=0", ctx.Cmd()) + // check we don't get any output (an error) after "executing net-plugin..." + runRktAndCheckRegexOutput(t, gcCmd, `executing net-plugin .*\n\z`) + + pods = podsRemaining(t, ctx) + if len(pods) != 0 { + t.Fatalf("no pods should exist rkt's data directory, but found: %v", pods) + } - pods = podsRemaining(t, ctx) - if len(pods) != 0 { - t.Fatalf("no pods should exist rkt's data directory, but found: %v", pods) } } From 9672eab34be045bbf4cead38d5184cbe679e9e1a Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Fri, 27 May 2016 12:29:08 +0200 Subject: [PATCH 0327/1304] docs: re-order some steps in the release process --- Documentation/devel/release.md | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/Documentation/devel/release.md b/Documentation/devel/release.md index d6950fcfd6..8e6fdeae59 100644 --- a/Documentation/devel/release.md +++ b/Documentation/devel/release.md @@ -10,21 +10,22 @@ Let's get started: - Start at the relevant milestone on GitHub (e.g. https://github.com/coreos/rkt/milestones/v1.2.0): ensure all referenced issues are closed (or moved elsewhere, if they're not done). Close the milestone. - Update the [roadmap](https://github.com/coreos/rkt/blob/master/ROADMAP.md) to remove the release you're performing, if necessary +- Ensure that `stage1/aci/aci-manifest.in` is the same version of appc/spec vendored with rkt. Otherwise, update it. - Branch from the latest master, make sure your git status is clean - Ensure the build is clean! - `git clean -ffdx && ./autogen.sh && ./configure --enable-tpm=no --enable-functional-tests && make && make check` should work - Integration tests on CI should be green - Update the [release notes](https://github.com/coreos/rkt/blob/master/CHANGELOG.md). Try to capture most of the salient changes since the last release, but don't go into unnecessary detail (better to link/reference the documentation wherever possible). + `scripts/changelog.sh` will help generating an initial list of changes. Correct/fix entries if necessary, and group them by category. The rkt version is [hardcoded in the repository](https://github.com/coreos/rkt/blob/master/configure.ac#L2), so the first thing to do is bump it: - Run `scripts/bump-release v1.2.0`. - This should generate two commits: a bump to the actual release (e.g. v1.2.0), and then a bump to the release+git (e.g. v1.2.0+git). + This should generate two commits: a bump to the actual release (e.g. v1.2.0, including CHANGELOG updates), and then a bump to the release+git (e.g. v1.2.0+git). The actual release version should only exist in a single commit! - Sanity check what the script did with `git diff HEAD^^` or similar. As well as changing the actual version, it also attempts to fix a bunch of references in the documentation etc. -- Fix the commit `HEAD^` so that the version in `stage1/aci/aci-manifest.in` is the version of appc/spec vendored with rkt. - If the script didn't work, yell at the author and/or fix it. It can almost certainly be improved. - File a PR and get a review from another [MAINTAINER](https://github.com/coreos/rkt/blob/master/MAINTAINERS). @@ -97,30 +98,3 @@ Make sure to include a list of authors that contributed since the previous relea ``` git log v1.1.0..v1.2.0 --pretty=format:"%an" | sort | uniq | tr '\n' ',' | sed -e 's#,#, #g' -e 's#, $#\n#' ``` - -Add `CHANGELOG.md` entries: - -- Add a new version headline and a meaningful release summary: - -``` -## v1.2.0 - -This release includes a number of new features and bugfixes like a new config subcommand, man page, and bash completion generation during build time. -``` - -- Execute `scripts/changelog.sh` -- Copy/Paste the generated entries into `CHANGELOG.md` -- Group the generated entries according to the following headlines: - -``` -#### New features and UX changes -... -#### Improved documentation -... -#### Bug fixes -... -#### Other changes -... -``` - -- Correct/fix the changelog entries if necessary. From d6f2def58dfdd2dca5c9295955704ef689383dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Fri, 27 May 2016 12:13:13 +0200 Subject: [PATCH 0328/1304] functional tests: simplify gc/rm tests --- tests/rkt_gc_nspawn_test.go | 3 +-- tests/rkt_gc_test.go | 12 ++++++------ tests/rkt_rm_nspawn_test.go | 4 +--- tests/rkt_rm_test.go | 3 +-- tests/rkt_tests.go | 10 ++++++++++ 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/tests/rkt_gc_nspawn_test.go b/tests/rkt_gc_nspawn_test.go index 5324ba0b4c..72e7ce4dad 100644 --- a/tests/rkt_gc_nspawn_test.go +++ b/tests/rkt_gc_nspawn_test.go @@ -47,8 +47,7 @@ func TestGCCgroup(t *testing.T) { ctx := testutils.NewRktRunCtx() defer ctx.Cleanup() - imagePath := patchImportAndFetchHash("inspect-gc-test-run.aci", []string{"--exec=/inspect --print-msg=HELLO_API --exit-code=0"}, t, ctx) - defer os.Remove(imagePath) + imagePath := getInspectImagePath() cmd := fmt.Sprintf("%s --insecure-options=image prepare %s", ctx.Cmd(), imagePath) uuid := runRktAndGetUUID(t, cmd) shortUUID := strings.Split(uuid, "-")[0] diff --git a/tests/rkt_gc_test.go b/tests/rkt_gc_test.go index 9c1a6e1920..2e4f36e94a 100644 --- a/tests/rkt_gc_test.go +++ b/tests/rkt_gc_test.go @@ -32,15 +32,14 @@ func TestGC(t *testing.T) { ctx := testutils.NewRktRunCtx() defer ctx.Cleanup() + imagePath := getInspectImagePath() // Finished pods. - patchImportAndRun("inspect-gc-test-run.aci", []string{"--exec=/inspect --print-msg=HELLO_API --exit-code=0"}, t, ctx) + importImageAndRun(imagePath, t, ctx) // Prepared pods. - patchImportAndPrepare("inspect-gc-test-prepare.aci", []string{"--exec=/inspect --print-msg=HELLO_API --exit-code=0"}, t, ctx) + importImageAndPrepare(imagePath, t, ctx) // Abort prepare. - imagePath := patchTestACI("inspect-gc-test-abort.aci", []string{"--exec=/inspect --print-msg=HELLO_API --exit-code=0"}...) - defer os.Remove(imagePath) cmd := fmt.Sprintf("%s --insecure-options=image prepare %s %s", ctx.Cmd(), imagePath, imagePath) spawnAndWaitOrFail(t, cmd, 1) @@ -89,10 +88,11 @@ func TestGCAfterUnmount(t *testing.T) { ctx := testutils.NewRktRunCtx() defer ctx.Cleanup() + imagePath := getInspectImagePath() + for _, rmNetns := range []bool{false, true} { - imagePath := patchImportAndFetchHash("inspect-gc-test-run.aci", []string{"--exec=/inspect --print-msg=HELLO_API --exit-code=0"}, t, ctx) - defer os.Remove(imagePath) + importImageAndFetchHash(t, ctx, "", imagePath) cmd := fmt.Sprintf("%s --insecure-options=image prepare %s", ctx.Cmd(), imagePath) uuid := runRktAndGetUUID(t, cmd) diff --git a/tests/rkt_rm_nspawn_test.go b/tests/rkt_rm_nspawn_test.go index eb7e3205c1..6326241fe1 100644 --- a/tests/rkt_rm_nspawn_test.go +++ b/tests/rkt_rm_nspawn_test.go @@ -18,7 +18,6 @@ package main import ( "fmt" - "os" "strings" "testing" @@ -29,8 +28,7 @@ func TestRmCgroup(t *testing.T) { ctx := testutils.NewRktRunCtx() defer ctx.Cleanup() - imagePath := patchImportAndFetchHash("inspect-rm-test-run.aci", []string{"--exec=/inspect --print-msg=HELLO_API --exit-code=0"}, t, ctx) - defer os.Remove(imagePath) + imagePath := getInspectImagePath() cmd := fmt.Sprintf("%s --insecure-options=image prepare %s", ctx.Cmd(), imagePath) uuid := runRktAndGetUUID(t, cmd) shortUUID := strings.Split(uuid, "-")[0] diff --git a/tests/rkt_rm_test.go b/tests/rkt_rm_test.go index 38ef516001..c8c4b3a682 100644 --- a/tests/rkt_rm_test.go +++ b/tests/rkt_rm_test.go @@ -32,8 +32,7 @@ func TestRm(t *testing.T) { var uuids []string - img := patchTestACI("inspect-rm-test-run.aci", []string{"--exec=/inspect --print-msg=HELLO_API --exit-code=0"}...) - defer os.Remove(img) + img := getInspectImagePath() prepareCmd := fmt.Sprintf("%s --insecure-options=image prepare %s", ctx.Cmd(), img) // Finished pod. diff --git a/tests/rkt_tests.go b/tests/rkt_tests.go index 93d1670594..afea7a96fc 100644 --- a/tests/rkt_tests.go +++ b/tests/rkt_tests.go @@ -225,6 +225,16 @@ func importImageAndFetchHash(t *testing.T, ctx *testutils.RktRunCtx, fetchArgs s return importImageAndFetchHashAsGid(t, ctx, fetchArgs, img, 0) } +func importImageAndRun(imagePath string, t *testing.T, ctx *testutils.RktRunCtx) { + cmd := fmt.Sprintf("%s --insecure-options=image run %s", ctx.Cmd(), imagePath) + spawnAndWaitOrFail(t, cmd, 0) +} + +func importImageAndPrepare(imagePath string, t *testing.T, ctx *testutils.RktRunCtx) { + cmd := fmt.Sprintf("%s --insecure-options=image prepare %s", ctx.Cmd(), imagePath) + spawnAndWaitOrFail(t, cmd, 0) +} + func patchImportAndFetchHash(image string, patches []string, t *testing.T, ctx *testutils.RktRunCtx) string { imagePath := patchTestACI(image, patches...) defer os.Remove(imagePath) From 96f418f58aa82bc15c305ba42904aa6a59d59daf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Thu, 19 May 2016 10:56:32 +0200 Subject: [PATCH 0329/1304] *: add libsystemd-journal-dev dependency --- .travis.yml | 3 +++ Documentation/dependencies.md | 2 ++ configure.ac | 6 ++++++ scripts/acbuild-rkt-builder.sh | 2 +- scripts/install-common.sh | 2 +- scripts/install-deps-debian-sid.sh | 2 +- scripts/install-deps-fedora-22.sh | 2 +- tests/cloudinit/centos.cloudinit | 2 +- tests/cloudinit/fedora.cloudinit | 2 +- tests/cloudinit/ubuntu.cloudinit | 2 +- tests/install-deps.sh | 2 +- 11 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index a61b4039b6..ad3e395521 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,8 @@ # Configures rkt tests at Travis CI (https://travis-ci.org). language: go +sudo: required +dist: trusty go: - 1.5.3 @@ -11,6 +13,7 @@ install: - sudo apt-get install -y cpio realpath squashfs-tools - sudo apt-get install -y build-essential - sudo apt-get install -y libacl1-dev + - sudo apt-get install -y libsystemd-journal-dev script: - ./autogen.sh diff --git a/Documentation/dependencies.md b/Documentation/dependencies.md index f8339a7a79..00e7350b10 100644 --- a/Documentation/dependencies.md +++ b/Documentation/dependencies.md @@ -20,6 +20,8 @@ For the most part the codebase is self-contained (e.g. all dependencies are vend * TrouSerS (only when TPM is enabled) * development headers * the rkt binary links against the library +* libsystemd-journal + * development headers * gpg (when running functional tests) ### Additional dependencies when building any stage1 image diff --git a/configure.ac b/configure.ac index dce34b5c9c..8fe006bde7 100644 --- a/configure.ac +++ b/configure.ac @@ -563,6 +563,12 @@ AC_CHECK_LIB([c], [fork], # Check whether we can build TPM support code AC_CHECK_HEADER(trousers/tss.h, [HAVE_TPM=yes], [HAVE_TPM=no], [AC_INCLUDES_DEFAULT]) +# Check whether we have libsystemd-journal (needed by the API server) +AC_CHECK_HEADER([systemd/sd-journal.h], + [], + [AC_MSG_ERROR([*** No development headers for libsystemd-journal found])], + [AC_INCLUDES_DEFAULT]) + TPM_TAGS='' AS_CASE([${RKT_ENABLE_TPM}], [no], diff --git a/scripts/acbuild-rkt-builder.sh b/scripts/acbuild-rkt-builder.sh index d3bb62a776..41eabfa9f7 100755 --- a/scripts/acbuild-rkt-builder.sh +++ b/scripts/acbuild-rkt-builder.sh @@ -23,7 +23,7 @@ BUILDDIR=/opt/build-rkt SRC_DIR=/opt/rkt ACI_GOPATH=/go -DEBIAN_SID_DEPS="ca-certificates gcc libc6-dev make automake wget git golang-go cpio squashfs-tools realpath autoconf file xz-utils patch bc locales libacl1-dev libssl-dev" +DEBIAN_SID_DEPS="ca-certificates gcc libc6-dev make automake wget git golang-go cpio squashfs-tools realpath autoconf file xz-utils patch bc locales libacl1-dev libssl-dev libsystemd-dev" acbuildend () { export EXIT=$?; diff --git a/scripts/install-common.sh b/scripts/install-common.sh index c3bb61775b..a94468e305 100755 --- a/scripts/install-common.sh +++ b/scripts/install-common.sh @@ -4,7 +4,7 @@ set -e export DEBIAN_FRONTEND=noninteractive apt-get update -apt-get install -y --no-install-recommends ca-certificates gcc libc6-dev make automake wget git coreutils cpio squashfs-tools realpath autoconf file libacl1-dev libtspi-dev bc +apt-get install -y --no-install-recommends ca-certificates gcc libc6-dev make automake wget git coreutils cpio squashfs-tools realpath autoconf file libacl1-dev libtspi-dev bc libsystemd-dev ./scripts/install-go.sh . /etc/profile diff --git a/scripts/install-deps-debian-sid.sh b/scripts/install-deps-debian-sid.sh index b4edb2c102..a6755ecdfa 100755 --- a/scripts/install-deps-debian-sid.sh +++ b/scripts/install-deps-debian-sid.sh @@ -2,7 +2,7 @@ set -e -DEBIAN_SID_DEPS="ca-certificates gcc libc6-dev make automake wget git golang-go coreutils cpio squashfs-tools realpath autoconf file xz-utils patch bc locales libacl1-dev libssl-dev libtspi-dev" +DEBIAN_SID_DEPS="ca-certificates gcc libc6-dev make automake wget git golang-go coreutils cpio squashfs-tools realpath autoconf file xz-utils patch bc locales libacl1-dev libssl-dev libtspi-dev libsystemd-dev" export DEBIAN_FRONTEND=noninteractive apt-get update diff --git a/scripts/install-deps-fedora-22.sh b/scripts/install-deps-fedora-22.sh index d29bedfc16..adea45ba7f 100755 --- a/scripts/install-deps-fedora-22.sh +++ b/scripts/install-deps-fedora-22.sh @@ -2,6 +2,6 @@ set -e -FEDORA22_DEPS="make gcc glibc-devel glibc-static cpio squashfs-tools gpg autoconf automake golang file git wget tar xz patch bc hostname findutils openssl libacl-devel openssl-devel" +FEDORA22_DEPS="make gcc glibc-devel glibc-static cpio squashfs-tools gpg autoconf automake golang file git wget tar xz patch bc hostname findutils openssl libacl-devel openssl-devel systemd-devel" dnf install -y ${FEDORA22_DEPS} diff --git a/tests/cloudinit/centos.cloudinit b/tests/cloudinit/centos.cloudinit index 5e65d4abe1..c0956a12ae 100644 --- a/tests/cloudinit/centos.cloudinit +++ b/tests/cloudinit/centos.cloudinit @@ -13,7 +13,7 @@ gpasswd -a centos rkt #yum update -y yum -y -v groupinstall "Development Tools" -yum -y -v install wget squashfs-tools patch glibc-static gnupg libacl-devel +yum -y -v install wget squashfs-tools patch glibc-static gnupg libacl-devel systemd-devel pushd /tmp wget https://storage.googleapis.com/golang/go1.5.3.linux-amd64.tar.gz diff --git a/tests/cloudinit/fedora.cloudinit b/tests/cloudinit/fedora.cloudinit index aa900ef3d9..6bcbe179a9 100644 --- a/tests/cloudinit/fedora.cloudinit +++ b/tests/cloudinit/fedora.cloudinit @@ -25,7 +25,7 @@ gpasswd -a fedora rkt dnf -y -v update dnf -y -v groupinstall "Development Tools" dnf -y -v groupinstall "C Development Tools and Libraries" -dnf -y -v install wget squashfs-tools patch glibc-static gnupg golang libacl-devel file +dnf -y -v install wget squashfs-tools patch glibc-static gnupg golang libacl-devel file systemd-devel # systemd-container only available in newer versions of Fedora dnf -y -v install systemd-container || true diff --git a/tests/cloudinit/ubuntu.cloudinit b/tests/cloudinit/ubuntu.cloudinit index 22f848ec36..f5141cf24c 100644 --- a/tests/cloudinit/ubuntu.cloudinit +++ b/tests/cloudinit/ubuntu.cloudinit @@ -16,7 +16,7 @@ gpasswd -a ubuntu rkt apt-get update -y apt-get dist-upgrade -y --force-yes apt-get install -y build-essential autoconf -apt-get install -y wget squashfs-tools patch gnupg golang libacl1-dev systemd-container +apt-get install -y wget squashfs-tools patch gnupg golang libacl1-dev systemd-container libsystemd-dev su - ubuntu --command="cd /var/tmp ; git clone --branch @GIT_BRANCH@ @GIT_URL@ rkt" su - ubuntu --command="PATH=\$PATH ; cd /var/tmp/rkt ; ./tests/build-and-run-tests.sh -f @FLAVOR@" diff --git a/tests/install-deps.sh b/tests/install-deps.sh index 51baffa4f4..d9c40a6bae 100755 --- a/tests/install-deps.sh +++ b/tests/install-deps.sh @@ -25,7 +25,7 @@ if [ "${CI-}" == true ] ; then # install -y " after it. sudo apt-get update -qq || true - sudo apt-get install -y libacl1-dev bc + sudo apt-get install -y libacl1-dev bc libsystemd-journal-dev # libmount: https://github.com/systemd/systemd/pull/986#issuecomment-138451264 sudo add-apt-repository --yes ppa:pitti/systemd-semaphore From 68e1b0f929513f8a9545f5505af1d8caf75a96e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Thu, 19 May 2016 10:41:58 +0200 Subject: [PATCH 0330/1304] Godeps: update go-systemd Adds new dep on coreos/pkg --- Godeps/Godeps.json | 26 +- .../github.com/coreos/go-systemd/dbus/dbus.go | 17 +- .../coreos/go-systemd/dbus/methods.go | 5 + .../coreos/go-systemd/sdjournal/journal.go | 795 ++++++++++++++++++ .../coreos/go-systemd/sdjournal/read.go | 221 +++++ .../github.com/coreos/go-systemd/util/util.go | 85 +- .../github.com/coreos/pkg/dlopen/dlopen.go | 82 ++ .../coreos/pkg/dlopen/dlopen_example.go | 56 ++ 8 files changed, 1209 insertions(+), 78 deletions(-) create mode 100644 Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/journal.go create mode 100644 Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/read.go create mode 100644 Godeps/_workspace/src/github.com/coreos/pkg/dlopen/dlopen.go create mode 100644 Godeps/_workspace/src/github.com/coreos/pkg/dlopen/dlopen_example.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index f2e4bdf2de..e6ff3c9016 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -276,23 +276,28 @@ }, { "ImportPath": "github.com/coreos/go-systemd/activation", - "Comment": "v5", - "Rev": "7b2428fec40033549c68f54e26e89e7ca9a9ce31" + "Comment": "v8", + "Rev": "b9b5f5970662ce700ab6ee41f56186e5b131490c" }, { "ImportPath": "github.com/coreos/go-systemd/dbus", - "Comment": "v5", - "Rev": "7b2428fec40033549c68f54e26e89e7ca9a9ce31" + "Comment": "v8", + "Rev": "b9b5f5970662ce700ab6ee41f56186e5b131490c" + }, + { + "ImportPath": "github.com/coreos/go-systemd/sdjournal", + "Comment": "v8", + "Rev": "b9b5f5970662ce700ab6ee41f56186e5b131490c" }, { "ImportPath": "github.com/coreos/go-systemd/unit", - "Comment": "v5", - "Rev": "7b2428fec40033549c68f54e26e89e7ca9a9ce31" + "Comment": "v8", + "Rev": "b9b5f5970662ce700ab6ee41f56186e5b131490c" }, { "ImportPath": "github.com/coreos/go-systemd/util", - "Comment": "v5", - "Rev": "7b2428fec40033549c68f54e26e89e7ca9a9ce31" + "Comment": "v8", + "Rev": "b9b5f5970662ce700ab6ee41f56186e5b131490c" }, { "ImportPath": "github.com/coreos/go-tspi/tpmclient", @@ -313,6 +318,11 @@ "ImportPath": "github.com/coreos/ioprogress", "Rev": "e7fc03058804de5488baed8df5b89f3924b9ec9a" }, + { + "ImportPath": "github.com/coreos/pkg/dlopen", + "Comment": "v1", + "Rev": "160ae6282d8c48a33d8c150e4e4817fdef8a5cde" + }, { "ImportPath": "github.com/cpuguy83/go-md2man/md2man", "Comment": "v1.0.4", diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/dbus.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/dbus.go index 9404334796..1699b90332 100644 --- a/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/dbus.go +++ b/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/dbus.go @@ -86,7 +86,7 @@ type Conn struct { // New establishes a connection to the system bus and authenticates. // Callers should call Close() when done with the connection. func New() (*Conn, error) { - return newConnection(func() (*dbus.Conn, error) { + return NewConnection(func() (*dbus.Conn, error) { return dbusAuthHelloConnection(dbus.SystemBusPrivate) }) } @@ -95,7 +95,7 @@ func New() (*Conn, error) { // authenticates. This can be used to connect to systemd user instances. // Callers should call Close() when done with the connection. func NewUserConnection() (*Conn, error) { - return newConnection(func() (*dbus.Conn, error) { + return NewConnection(func() (*dbus.Conn, error) { return dbusAuthHelloConnection(dbus.SessionBusPrivate) }) } @@ -104,7 +104,7 @@ func NewUserConnection() (*Conn, error) { // This can be used for communicating with systemd without a dbus daemon. // Callers should call Close() when done with the connection. func NewSystemdConnection() (*Conn, error) { - return newConnection(func() (*dbus.Conn, error) { + return NewConnection(func() (*dbus.Conn, error) { // We skip Hello when talking directly to systemd. return dbusAuthConnection(func() (*dbus.Conn, error) { return dbus.Dial("unix:path=/run/systemd/private") @@ -118,13 +118,18 @@ func (c *Conn) Close() { c.sigconn.Close() } -func newConnection(createBus func() (*dbus.Conn, error)) (*Conn, error) { - sysconn, err := createBus() +// NewConnection establishes a connection to a bus using a caller-supplied function. +// This allows connecting to remote buses through a user-supplied mechanism. +// The supplied function may be called multiple times, and should return independent connections. +// The returned connection must be fully initialised: the org.freedesktop.DBus.Hello call must have succeeded, +// and any authentication should be handled by the function. +func NewConnection(dialBus func() (*dbus.Conn, error)) (*Conn, error) { + sysconn, err := dialBus() if err != nil { return nil, err } - sigconn, err := createBus() + sigconn, err := dialBus() if err != nil { sysconn.Close() return nil, err diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/methods.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/methods.go index f9552a3380..403c2f0f7b 100644 --- a/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/methods.go +++ b/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/methods.go @@ -199,6 +199,11 @@ func (c *Conn) GetUnitProperty(unit string, propertyName string) (*Property, err return c.getProperty(unit, "org.freedesktop.systemd1.Unit", propertyName) } +// GetServiceProperty returns property for given service name and property name +func (c *Conn) GetServiceProperty(service string, propertyName string) (*Property, error) { + return c.getProperty(service, "org.freedesktop.systemd1.Service", propertyName) +} + // GetUnitTypeProperties returns the extra properties for a unit, specific to the unit type. // Valid values for unitType: Service, Socket, Target, Device, Mount, Automount, Snapshot, Timer, Swap, Path, Slice, Scope // return "dbus.Error: Unknown interface" if the unitType is not the correct type of the unit diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/journal.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/journal.go new file mode 100644 index 0000000000..d3c5675b1d --- /dev/null +++ b/Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/journal.go @@ -0,0 +1,795 @@ +// Copyright 2015 RedHat, Inc. +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package sdjournal provides a low-level Go interface to the +// systemd journal wrapped around the sd-journal C API. +// +// All public read methods map closely to the sd-journal API functions. See the +// sd-journal.h documentation[1] for information about each function. +// +// To write to the journal, see the pure-Go "journal" package +// +// [1] http://www.freedesktop.org/software/systemd/man/sd-journal.html +package sdjournal + +// #include +// #include +// #include +// +// int +// my_sd_journal_open(void *f, sd_journal **ret, int flags) +// { +// int (*sd_journal_open)(sd_journal **, int); +// +// sd_journal_open = f; +// return sd_journal_open(ret, flags); +// } +// +// int +// my_sd_journal_open_directory(void *f, sd_journal **ret, const char *path, int flags) +// { +// int (*sd_journal_open_directory)(sd_journal **, const char *, int); +// +// sd_journal_open_directory = f; +// return sd_journal_open_directory(ret, path, flags); +// } +// +// void +// my_sd_journal_close(void *f, sd_journal *j) +// { +// int (*sd_journal_close)(sd_journal *); +// +// sd_journal_close = f; +// sd_journal_close(j); +// } +// +// int +// my_sd_journal_get_usage(void *f, sd_journal *j, uint64_t *bytes) +// { +// int (*sd_journal_get_usage)(sd_journal *, uint64_t *); +// +// sd_journal_get_usage = f; +// return sd_journal_get_usage(j, bytes); +// } +// +// int +// my_sd_journal_add_match(void *f, sd_journal *j, const void *data, size_t size) +// { +// int (*sd_journal_add_match)(sd_journal *, const void *, size_t); +// +// sd_journal_add_match = f; +// return sd_journal_add_match(j, data, size); +// } +// +// int +// my_sd_journal_add_disjunction(void *f, sd_journal *j) +// { +// int (*sd_journal_add_disjunction)(sd_journal *); +// +// sd_journal_add_disjunction = f; +// return sd_journal_add_disjunction(j); +// } +// +// int +// my_sd_journal_add_conjunction(void *f, sd_journal *j) +// { +// int (*sd_journal_add_conjunction)(sd_journal *); +// +// sd_journal_add_conjunction = f; +// return sd_journal_add_conjunction(j); +// } +// +// void +// my_sd_journal_flush_matches(void *f, sd_journal *j) +// { +// int (*sd_journal_flush_matches)(sd_journal *); +// +// sd_journal_flush_matches = f; +// sd_journal_flush_matches(j); +// } +// +// int +// my_sd_journal_next(void *f, sd_journal *j) +// { +// int (*sd_journal_next)(sd_journal *); +// +// sd_journal_next = f; +// return sd_journal_next(j); +// } +// +// int +// my_sd_journal_next_skip(void *f, sd_journal *j, uint64_t skip) +// { +// int (*sd_journal_next_skip)(sd_journal *, uint64_t); +// +// sd_journal_next_skip = f; +// return sd_journal_next_skip(j, skip); +// } +// +// int +// my_sd_journal_previous(void *f, sd_journal *j) +// { +// int (*sd_journal_previous)(sd_journal *); +// +// sd_journal_previous = f; +// return sd_journal_previous(j); +// } +// +// int +// my_sd_journal_previous_skip(void *f, sd_journal *j, uint64_t skip) +// { +// int (*sd_journal_previous_skip)(sd_journal *, uint64_t); +// +// sd_journal_previous_skip = f; +// return sd_journal_previous_skip(j, skip); +// } +// +// int +// my_sd_journal_get_data(void *f, sd_journal *j, const char *field, const void **data, size_t *length) +// { +// int (*sd_journal_get_data)(sd_journal *, const char *, const void **, size_t *); +// +// sd_journal_get_data = f; +// return sd_journal_get_data(j, field, data, length); +// } +// +// int +// my_sd_journal_set_data_threshold(void *f, sd_journal *j, size_t sz) +// { +// int (*sd_journal_set_data_threshold)(sd_journal *, size_t); +// +// sd_journal_set_data_threshold = f; +// return sd_journal_set_data_threshold(j, sz); +// } +// +// int +// my_sd_journal_get_cursor(void *f, sd_journal *j, char **cursor) +// { +// int (*sd_journal_get_cursor)(sd_journal *, char **); +// +// sd_journal_get_cursor = f; +// return sd_journal_get_cursor(j, cursor); +// } +// +// int +// my_sd_journal_test_cursor(void *f, sd_journal *j, const char *cursor) +// { +// int (*sd_journal_test_cursor)(sd_journal *, const char *); +// +// sd_journal_test_cursor = f; +// return sd_journal_test_cursor(j, cursor); +// } +// +// int +// my_sd_journal_get_realtime_usec(void *f, sd_journal *j, uint64_t *usec) +// { +// int (*sd_journal_get_realtime_usec)(sd_journal *, uint64_t *); +// +// sd_journal_get_realtime_usec = f; +// return sd_journal_get_realtime_usec(j, usec); +// } +// +// int +// my_sd_journal_seek_head(void *f, sd_journal *j) +// { +// int (*sd_journal_seek_head)(sd_journal *); +// +// sd_journal_seek_head = f; +// return sd_journal_seek_head(j); +// } +// +// int +// my_sd_journal_seek_tail(void *f, sd_journal *j) +// { +// int (*sd_journal_seek_tail)(sd_journal *); +// +// sd_journal_seek_tail = f; +// return sd_journal_seek_tail(j); +// } +// +// +// int +// my_sd_journal_seek_cursor(void *f, sd_journal *j, const char *cursor) +// { +// int (*sd_journal_seek_cursor)(sd_journal *, const char *); +// +// sd_journal_seek_cursor = f; +// return sd_journal_seek_cursor(j, cursor); +// } +// +// int +// my_sd_journal_seek_realtime_usec(void *f, sd_journal *j, uint64_t usec) +// { +// int (*sd_journal_seek_realtime_usec)(sd_journal *, uint64_t); +// +// sd_journal_seek_realtime_usec = f; +// return sd_journal_seek_realtime_usec(j, usec); +// } +// +// int +// my_sd_journal_wait(void *f, sd_journal *j, uint64_t timeout_usec) +// { +// int (*sd_journal_wait)(sd_journal *, uint64_t); +// +// sd_journal_wait = f; +// return sd_journal_wait(j, timeout_usec); +// } +// +import "C" +import ( + "fmt" + "path/filepath" + "strings" + "sync" + "syscall" + "time" + "unsafe" + + "github.com/coreos/pkg/dlopen" +) + +var libsystemdFunctions = map[string]unsafe.Pointer{} + +// Journal entry field strings which correspond to: +// http://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html +const ( + SD_JOURNAL_FIELD_SYSTEMD_UNIT = "_SYSTEMD_UNIT" + SD_JOURNAL_FIELD_SYSLOG_IDENTIFIER = "SYSLOG_IDENTIFIER" + SD_JOURNAL_FIELD_MESSAGE = "MESSAGE" + SD_JOURNAL_FIELD_PID = "_PID" + SD_JOURNAL_FIELD_UID = "_UID" + SD_JOURNAL_FIELD_GID = "_GID" + SD_JOURNAL_FIELD_HOSTNAME = "_HOSTNAME" + SD_JOURNAL_FIELD_MACHINE_ID = "_MACHINE_ID" + SD_JOURNAL_FIELD_TRANSPORT = "_TRANSPORT" +) + +// Journal event constants +const ( + SD_JOURNAL_NOP = int(C.SD_JOURNAL_NOP) + SD_JOURNAL_APPEND = int(C.SD_JOURNAL_APPEND) + SD_JOURNAL_INVALIDATE = int(C.SD_JOURNAL_INVALIDATE) +) + +const ( + // IndefiniteWait is a sentinel value that can be passed to + // sdjournal.Wait() to signal an indefinite wait for new journal + // events. It is implemented as the maximum value for a time.Duration: + // https://github.com/golang/go/blob/e4dcf5c8c22d98ac9eac7b9b226596229624cb1d/src/time/time.go#L434 + IndefiniteWait time.Duration = 1<<63 - 1 +) + +var libsystemdNames = []string{ + // systemd < 209 + "libsystemd-journal.so.0", + "libsystemd-journal.so", + + // systemd >= 209 merged libsystemd-journal into libsystemd proper + "libsystemd.so.0", + "libsystemd.so", +} + +// Journal is a Go wrapper of an sd_journal structure. +type Journal struct { + cjournal *C.sd_journal + mu sync.Mutex + lib *dlopen.LibHandle +} + +// Match is a convenience wrapper to describe filters supplied to AddMatch. +type Match struct { + Field string + Value string +} + +// String returns a string representation of a Match suitable for use with AddMatch. +func (m *Match) String() string { + return m.Field + "=" + m.Value +} + +func (j *Journal) getFunction(name string) (unsafe.Pointer, error) { + j.mu.Lock() + defer j.mu.Unlock() + f, ok := libsystemdFunctions[name] + if !ok { + var err error + f, err = j.lib.GetSymbolPointer(name) + if err != nil { + return nil, err + } + + libsystemdFunctions[name] = f + } + + return f, nil +} + +// NewJournal returns a new Journal instance pointing to the local journal +func NewJournal() (j *Journal, err error) { + h, err := dlopen.GetHandle(libsystemdNames) + if err != nil { + return nil, err + } + defer func() { + if err == nil { + return + } + err2 := h.Close() + if err2 != nil { + err = fmt.Errorf(`%q and "error closing handle: %v"`, err, err2) + } + }() + + j = &Journal{lib: h} + + sd_journal_open, err := j.getFunction("sd_journal_open") + if err != nil { + return nil, err + } + + r := C.my_sd_journal_open(sd_journal_open, &j.cjournal, C.SD_JOURNAL_LOCAL_ONLY) + + if r < 0 { + return nil, fmt.Errorf("failed to open journal: %d", syscall.Errno(-r)) + } + + return j, nil +} + +// NewJournalFromDir returns a new Journal instance pointing to a journal residing +// in a given directory. The supplied path may be relative or absolute; if +// relative, it will be converted to an absolute path before being opened. +func NewJournalFromDir(path string) (j *Journal, err error) { + h, err := dlopen.GetHandle(libsystemdNames) + if err != nil { + return nil, err + } + defer func() { + if err == nil { + return + } + err2 := h.Close() + if err2 != nil { + err = fmt.Errorf(`%q and "error closing handle: %v"`, err, err2) + } + }() + + path, err = filepath.Abs(path) + if err != nil { + return nil, err + } + + j = &Journal{lib: h} + + sd_journal_open_directory, err := j.getFunction("sd_journal_open_directory") + if err != nil { + return nil, err + } + + p := C.CString(path) + defer C.free(unsafe.Pointer(p)) + + r := C.my_sd_journal_open_directory(sd_journal_open_directory, &j.cjournal, p, 0) + if r < 0 { + return nil, fmt.Errorf("failed to open journal in directory %q: %d", path, syscall.Errno(-r)) + } + + return j, nil +} + +// Close closes a journal opened with NewJournal. +func (j *Journal) Close() error { + sd_journal_close, err := j.getFunction("sd_journal_close") + if err != nil { + return err + } + + j.mu.Lock() + C.my_sd_journal_close(sd_journal_close, j.cjournal) + j.mu.Unlock() + + return j.lib.Close() +} + +// AddMatch adds a match by which to filter the entries of the journal. +func (j *Journal) AddMatch(match string) error { + sd_journal_add_match, err := j.getFunction("sd_journal_add_match") + if err != nil { + return err + } + + m := C.CString(match) + defer C.free(unsafe.Pointer(m)) + + j.mu.Lock() + r := C.my_sd_journal_add_match(sd_journal_add_match, j.cjournal, unsafe.Pointer(m), C.size_t(len(match))) + j.mu.Unlock() + + if r < 0 { + return fmt.Errorf("failed to add match: %d", syscall.Errno(-r)) + } + + return nil +} + +// AddDisjunction inserts a logical OR in the match list. +func (j *Journal) AddDisjunction() error { + sd_journal_add_disjunction, err := j.getFunction("sd_journal_add_disjunction") + if err != nil { + return err + } + + j.mu.Lock() + r := C.my_sd_journal_add_disjunction(sd_journal_add_disjunction, j.cjournal) + j.mu.Unlock() + + if r < 0 { + return fmt.Errorf("failed to add a disjunction in the match list: %d", syscall.Errno(-r)) + } + + return nil +} + +// AddConjunction inserts a logical AND in the match list. +func (j *Journal) AddConjunction() error { + sd_journal_add_conjunction, err := j.getFunction("sd_journal_add_conjunction") + if err != nil { + return err + } + + j.mu.Lock() + r := C.my_sd_journal_add_conjunction(sd_journal_add_conjunction, j.cjournal) + j.mu.Unlock() + + if r < 0 { + return fmt.Errorf("failed to add a conjunction in the match list: %d", syscall.Errno(-r)) + } + + return nil +} + +// FlushMatches flushes all matches, disjunctions and conjunctions. +func (j *Journal) FlushMatches() { + sd_journal_flush_matches, err := j.getFunction("sd_journal_flush_matches") + if err != nil { + return + } + + j.mu.Lock() + C.my_sd_journal_flush_matches(sd_journal_flush_matches, j.cjournal) + j.mu.Unlock() +} + +// Next advances the read pointer into the journal by one entry. +func (j *Journal) Next() (int, error) { + sd_journal_next, err := j.getFunction("sd_journal_next") + if err != nil { + return -1, err + } + + j.mu.Lock() + r := C.my_sd_journal_next(sd_journal_next, j.cjournal) + j.mu.Unlock() + + if r < 0 { + return int(r), fmt.Errorf("failed to iterate journal: %d", syscall.Errno(-r)) + } + + return int(r), nil +} + +// NextSkip advances the read pointer by multiple entries at once, +// as specified by the skip parameter. +func (j *Journal) NextSkip(skip uint64) (uint64, error) { + sd_journal_next_skip, err := j.getFunction("sd_journal_next_skip") + if err != nil { + return 0, err + } + + j.mu.Lock() + r := C.my_sd_journal_next_skip(sd_journal_next_skip, j.cjournal, C.uint64_t(skip)) + j.mu.Unlock() + + if r < 0 { + return uint64(r), fmt.Errorf("failed to iterate journal: %d", syscall.Errno(-r)) + } + + return uint64(r), nil +} + +// Previous sets the read pointer into the journal back by one entry. +func (j *Journal) Previous() (uint64, error) { + sd_journal_previous, err := j.getFunction("sd_journal_previous") + if err != nil { + return 0, err + } + + j.mu.Lock() + r := C.my_sd_journal_previous(sd_journal_previous, j.cjournal) + j.mu.Unlock() + + if r < 0 { + return uint64(r), fmt.Errorf("failed to iterate journal: %d", syscall.Errno(-r)) + } + + return uint64(r), nil +} + +// PreviousSkip sets back the read pointer by multiple entries at once, +// as specified by the skip parameter. +func (j *Journal) PreviousSkip(skip uint64) (uint64, error) { + sd_journal_previous_skip, err := j.getFunction("sd_journal_previous_skip") + if err != nil { + return 0, err + } + + j.mu.Lock() + r := C.my_sd_journal_previous_skip(sd_journal_previous_skip, j.cjournal, C.uint64_t(skip)) + j.mu.Unlock() + + if r < 0 { + return uint64(r), fmt.Errorf("failed to iterate journal: %d", syscall.Errno(-r)) + } + + return uint64(r), nil +} + +// GetData gets the data object associated with a specific field from the +// current journal entry. +func (j *Journal) GetData(field string) (string, error) { + sd_journal_get_data, err := j.getFunction("sd_journal_get_data") + if err != nil { + return "", err + } + + f := C.CString(field) + defer C.free(unsafe.Pointer(f)) + + var d unsafe.Pointer + var l C.size_t + + j.mu.Lock() + r := C.my_sd_journal_get_data(sd_journal_get_data, j.cjournal, f, &d, &l) + j.mu.Unlock() + + if r < 0 { + return "", fmt.Errorf("failed to read message: %d", syscall.Errno(-r)) + } + + msg := C.GoStringN((*C.char)(d), C.int(l)) + + return msg, nil +} + +// GetDataValue gets the data object associated with a specific field from the +// current journal entry, returning only the value of the object. +func (j *Journal) GetDataValue(field string) (string, error) { + val, err := j.GetData(field) + if err != nil { + return "", err + } + return strings.SplitN(val, "=", 2)[1], nil +} + +// SetDataThresold sets the data field size threshold for data returned by +// GetData. To retrieve the complete data fields this threshold should be +// turned off by setting it to 0, so that the library always returns the +// complete data objects. +func (j *Journal) SetDataThreshold(threshold uint64) error { + sd_journal_set_data_threshold, err := j.getFunction("sd_journal_set_data_threshold") + if err != nil { + return err + } + + j.mu.Lock() + r := C.my_sd_journal_set_data_threshold(sd_journal_set_data_threshold, j.cjournal, C.size_t(threshold)) + j.mu.Unlock() + + if r < 0 { + return fmt.Errorf("failed to set data threshold: %d", syscall.Errno(-r)) + } + + return nil +} + +// GetRealtimeUsec gets the realtime (wallclock) timestamp of the current +// journal entry. +func (j *Journal) GetRealtimeUsec() (uint64, error) { + var usec C.uint64_t + + sd_journal_get_realtime_usec, err := j.getFunction("sd_journal_get_realtime_usec") + if err != nil { + return 0, err + } + + j.mu.Lock() + r := C.my_sd_journal_get_realtime_usec(sd_journal_get_realtime_usec, j.cjournal, &usec) + j.mu.Unlock() + + if r < 0 { + return 0, fmt.Errorf("error getting timestamp for entry: %d", syscall.Errno(-r)) + } + + return uint64(usec), nil +} + +// GetCursor gets the cursor of the current journal entry. +func (j *Journal) GetCursor() (string, error) { + var d *C.char + + sd_journal_get_cursor, err := j.getFunction("sd_journal_get_cursor") + if err != nil { + return "", err + } + + j.mu.Lock() + r := C.my_sd_journal_get_cursor(sd_journal_get_cursor, j.cjournal, &d) + j.mu.Unlock() + + if r < 0 { + return "", fmt.Errorf("failed to get cursor: %d", syscall.Errno(-r)) + } + + cursor := C.GoString(d) + + return cursor, nil +} + +// TestCursor checks whether the current position in the journal matches the +// specified cursor +func (j *Journal) TestCursor(cursor string) error { + sd_journal_test_cursor, err := j.getFunction("sd_journal_test_cursor") + if err != nil { + return err + } + + c := C.CString(cursor) + defer C.free(unsafe.Pointer(c)) + + j.mu.Lock() + r := C.my_sd_journal_test_cursor(sd_journal_test_cursor, j.cjournal, c) + j.mu.Unlock() + + if r < 0 { + return fmt.Errorf("failed to test to cursor %q: %d", cursor, syscall.Errno(-r)) + } + + return nil +} + +// SeekHead seeks to the beginning of the journal, i.e. the oldest available +// entry. +func (j *Journal) SeekHead() error { + sd_journal_seek_head, err := j.getFunction("sd_journal_seek_head") + if err != nil { + return err + } + + j.mu.Lock() + r := C.my_sd_journal_seek_head(sd_journal_seek_head, j.cjournal) + j.mu.Unlock() + + if r < 0 { + return fmt.Errorf("failed to seek to head of journal: %d", syscall.Errno(-r)) + } + + return nil +} + +// SeekTail may be used to seek to the end of the journal, i.e. the most recent +// available entry. +func (j *Journal) SeekTail() error { + sd_journal_seek_tail, err := j.getFunction("sd_journal_seek_tail") + if err != nil { + return err + } + + j.mu.Lock() + r := C.my_sd_journal_seek_tail(sd_journal_seek_tail, j.cjournal) + j.mu.Unlock() + + if r < 0 { + return fmt.Errorf("failed to seek to tail of journal: %d", syscall.Errno(-r)) + } + + return nil +} + +// SeekRealtimeUsec seeks to the entry with the specified realtime (wallclock) +// timestamp, i.e. CLOCK_REALTIME. +func (j *Journal) SeekRealtimeUsec(usec uint64) error { + sd_journal_seek_realtime_usec, err := j.getFunction("sd_journal_seek_realtime_usec") + if err != nil { + return err + } + + j.mu.Lock() + r := C.my_sd_journal_seek_realtime_usec(sd_journal_seek_realtime_usec, j.cjournal, C.uint64_t(usec)) + j.mu.Unlock() + + if r < 0 { + return fmt.Errorf("failed to seek to %d: %d", usec, syscall.Errno(-r)) + } + + return nil +} + +// SeekCursor seeks to a concrete journal cursor. +func (j *Journal) SeekCursor(cursor string) error { + sd_journal_seek_cursor, err := j.getFunction("sd_journal_seek_cursor") + if err != nil { + return err + } + + c := C.CString(cursor) + defer C.free(unsafe.Pointer(c)) + + j.mu.Lock() + r := C.my_sd_journal_seek_cursor(sd_journal_seek_cursor, j.cjournal, c) + j.mu.Unlock() + + if r < 0 { + return fmt.Errorf("failed to seek to cursor %q: %d", cursor, syscall.Errno(-r)) + } + + return nil +} + +// Wait will synchronously wait until the journal gets changed. The maximum time +// this call sleeps may be controlled with the timeout parameter. If +// sdjournal.IndefiniteWait is passed as the timeout parameter, Wait will +// wait indefinitely for a journal change. +func (j *Journal) Wait(timeout time.Duration) int { + var to uint64 + + sd_journal_wait, err := j.getFunction("sd_journal_wait") + if err != nil { + return -1 + } + + if timeout == IndefiniteWait { + // sd_journal_wait(3) calls for a (uint64_t) -1 to be passed to signify + // indefinite wait, but using a -1 overflows our C.uint64_t, so we use an + // equivalent hex value. + to = 0xffffffffffffffff + } else { + to = uint64(time.Now().Add(timeout).Unix() / 1000) + } + j.mu.Lock() + r := C.my_sd_journal_wait(sd_journal_wait, j.cjournal, C.uint64_t(to)) + j.mu.Unlock() + + return int(r) +} + +// GetUsage returns the journal disk space usage, in bytes. +func (j *Journal) GetUsage() (uint64, error) { + var out C.uint64_t + + sd_journal_get_usage, err := j.getFunction("sd_journal_get_usage") + if err != nil { + return 0, err + } + + j.mu.Lock() + r := C.my_sd_journal_get_usage(sd_journal_get_usage, j.cjournal, &out) + j.mu.Unlock() + + if r < 0 { + return 0, fmt.Errorf("failed to get journal disk space usage: %d", syscall.Errno(-r)) + } + + return uint64(out), nil +} diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/read.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/read.go new file mode 100644 index 0000000000..161577870b --- /dev/null +++ b/Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/read.go @@ -0,0 +1,221 @@ +// Copyright 2015 RedHat, Inc. +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package sdjournal + +import ( + "errors" + "fmt" + "io" + "log" + "time" +) + +var ( + ErrExpired = errors.New("Timeout expired") +) + +// JournalReaderConfig represents options to drive the behavior of a JournalReader. +type JournalReaderConfig struct { + // The Since and NumFromTail options are mutually exclusive and determine + // where the reading begins within the journal. + Since time.Duration // start relative to a Duration from now + NumFromTail uint64 // start relative to the tail + Cursor string // start relative to the cursor + + // Show only journal entries whose fields match the supplied values. If + // the array is empty, entries will not be filtered. + Matches []Match + + // If not empty, the journal instance will point to a journal residing + // in this directory. The supplied path may be relative or absolute. + Path string +} + +// JournalReader is an io.ReadCloser which provides a simple interface for iterating through the +// systemd journal. +type JournalReader struct { + journal *Journal +} + +// NewJournalReader creates a new JournalReader with configuration options that are similar to the +// systemd journalctl tool's iteration and filtering features. +func NewJournalReader(config JournalReaderConfig) (*JournalReader, error) { + r := &JournalReader{} + + // Open the journal + var err error + if config.Path != "" { + r.journal, err = NewJournalFromDir(config.Path) + } else { + r.journal, err = NewJournal() + } + if err != nil { + return nil, err + } + + // Add any supplied matches + for _, m := range config.Matches { + r.journal.AddMatch(m.String()) + } + + // Set the start position based on options + if config.Since != 0 { + // Start based on a relative time + start := time.Now().Add(config.Since) + if err := r.journal.SeekRealtimeUsec(uint64(start.UnixNano() / 1000)); err != nil { + return nil, err + } + } else if config.NumFromTail != 0 { + // Start based on a number of lines before the tail + if err := r.journal.SeekTail(); err != nil { + return nil, err + } + + // Move the read pointer into position near the tail. Go one further than + // the option so that the initial cursor advancement positions us at the + // correct starting point. + if _, err := r.journal.PreviousSkip(config.NumFromTail + 1); err != nil { + return nil, err + } + } else if config.Cursor != "" { + // Start based on a custom cursor + if err := r.journal.SeekCursor(config.Cursor); err != nil { + return nil, err + } + } + + return r, nil +} + +func (r *JournalReader) Read(b []byte) (int, error) { + var err error + var c int + + // Advance the journal cursor + c, err = r.journal.Next() + + // An unexpected error + if err != nil { + return 0, err + } + + // EOF detection + if c == 0 { + return 0, io.EOF + } + + // Build a message + var msg string + msg, err = r.buildMessage() + + if err != nil { + return 0, err + } + + // Copy and return the message + copy(b, []byte(msg)) + + return len(msg), nil +} + +// Close closes the JournalReader's handle to the journal. +func (r *JournalReader) Close() error { + return r.journal.Close() +} + +// Rewind attempts to rewind the JournalReader to the first entry. +func (r *JournalReader) Rewind() error { + return r.journal.SeekHead() +} + +// Follow synchronously follows the JournalReader, writing each new journal entry to writer. The +// follow will continue until a single time.Time is received on the until channel. +func (r *JournalReader) Follow(until <-chan time.Time, writer io.Writer) (err error) { + + // Process journal entries and events. Entries are flushed until the tail or + // timeout is reached, and then we wait for new events or the timeout. + var msg = make([]byte, 64*1<<(10)) +process: + for { + c, err := r.Read(msg) + if err != nil && err != io.EOF { + break process + } + + select { + case <-until: + return ErrExpired + default: + if c > 0 { + writer.Write(msg[:c]) + continue process + } + } + + // We're at the tail, so wait for new events or time out. + // Holds journal events to process. Tightly bounded for now unless there's a + // reason to unblock the journal watch routine more quickly. + events := make(chan int, 1) + pollDone := make(chan bool, 1) + go func() { + for { + select { + case <-pollDone: + return + default: + events <- r.journal.Wait(time.Duration(1) * time.Second) + } + } + }() + + select { + case <-until: + pollDone <- true + return ErrExpired + case e := <-events: + pollDone <- true + switch e { + case SD_JOURNAL_NOP, SD_JOURNAL_APPEND, SD_JOURNAL_INVALIDATE: + // TODO: need to account for any of these? + default: + log.Printf("Received unknown event: %d\n", e) + } + continue process + } + } + + return +} + +// buildMessage returns a string representing the current journal entry in a simple format which +// includes the entry timestamp and MESSAGE field. +func (r *JournalReader) buildMessage() (string, error) { + var msg string + var usec uint64 + var err error + + if msg, err = r.journal.GetData("MESSAGE"); err != nil { + return "", err + } + + if usec, err = r.journal.GetRealtimeUsec(); err != nil { + return "", err + } + + timestamp := time.Unix(0, int64(usec)*int64(time.Microsecond)) + + return fmt.Sprintf("%s %s\n", timestamp, msg), nil +} diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/util/util.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/util/util.go index f9f0b2a35a..e4ed8b2639 100644 --- a/Godeps/_workspace/src/github.com/coreos/go-systemd/util/util.go +++ b/Godeps/_workspace/src/github.com/coreos/go-systemd/util/util.go @@ -18,9 +18,7 @@ // than linking against them. package util -// #cgo LDFLAGS: -ldl // #include -// #include // #include // #include // @@ -58,56 +56,24 @@ package util // } import "C" import ( - "errors" "fmt" "io/ioutil" "os" "strings" "syscall" "unsafe" -) - -var ErrSoNotFound = errors.New("unable to open a handle to libsystemd") - -// libHandle represents an open handle to the systemd C library -type libHandle struct { - handle unsafe.Pointer - libname string -} -func (h *libHandle) Close() error { - if r := C.dlclose(h.handle); r != 0 { - return fmt.Errorf("error closing %v: %d", h.libname, r) - } - return nil -} + "github.com/coreos/pkg/dlopen" +) -// getHandle tries to get a handle to a systemd library (.so), attempting to -// access it by several different names and returning the first that is -// successfully opened. Callers are responsible for closing the handler. -// If no library can be successfully opened, an error is returned. -func getHandle() (*libHandle, error) { - for _, name := range []string{ - // systemd < 209 - "libsystemd-login.so", - "libsystemd-login.so.0", +var libsystemdNames = []string{ + // systemd < 209 + "libsystemd-login.so.0", + "libsystemd-login.so", - // systemd >= 209 merged libsystemd-login into libsystemd proper - "libsystemd.so", - "libsystemd.so.0", - } { - libname := C.CString(name) - defer C.free(unsafe.Pointer(libname)) - handle := C.dlopen(libname, C.RTLD_LAZY) - if handle != nil { - h := &libHandle{ - handle: handle, - libname: name, - } - return h, nil - } - } - return nil, ErrSoNotFound + // systemd >= 209 merged libsystemd-login into libsystemd proper + "libsystemd.so.0", + "libsystemd.so", } // GetRunningSlice attempts to retrieve the name of the systemd slice in which @@ -115,8 +81,8 @@ func getHandle() (*libHandle, error) { // This function is a wrapper around the libsystemd C library; if it cannot be // opened, an error is returned. func GetRunningSlice() (slice string, err error) { - var h *libHandle - h, err = getHandle() + var h *dlopen.LibHandle + h, err = dlopen.GetHandle(libsystemdNames) if err != nil { return } @@ -126,11 +92,8 @@ func GetRunningSlice() (slice string, err error) { } }() - sym := C.CString("sd_pid_get_slice") - defer C.free(unsafe.Pointer(sym)) - sd_pid_get_slice := C.dlsym(h.handle, sym) - if sd_pid_get_slice == nil { - err = fmt.Errorf("error resolving sd_pid_get_slice function") + sd_pid_get_slice, err := h.GetSymbolPointer("sd_pid_get_slice") + if err != nil { return } @@ -164,8 +127,8 @@ func GetRunningSlice() (slice string, err error) { // unable to successfully open a handle to the library for any reason (e.g. it // cannot be found), an errr will be returned func RunningFromSystemService() (ret bool, err error) { - var h *libHandle - h, err = getHandle() + var h *dlopen.LibHandle + h, err = dlopen.GetHandle(libsystemdNames) if err != nil { return } @@ -175,11 +138,8 @@ func RunningFromSystemService() (ret bool, err error) { } }() - sym := C.CString("sd_pid_get_owner_uid") - defer C.free(unsafe.Pointer(sym)) - sd_pid_get_owner_uid := C.dlsym(h.handle, sym) - if sd_pid_get_owner_uid == nil { - err = fmt.Errorf("error resolving sd_pid_get_owner_uid function") + sd_pid_get_owner_uid, err := h.GetSymbolPointer("sd_pid_get_owner_uid") + if err != nil { return } @@ -212,8 +172,8 @@ func RunningFromSystemService() (ret bool, err error) { // `sd_pid_get_unit` call, with the same caveat: for processes not part of a // systemd system unit, this function will return an error. func CurrentUnitName() (unit string, err error) { - var h *libHandle - h, err = getHandle() + var h *dlopen.LibHandle + h, err = dlopen.GetHandle(libsystemdNames) if err != nil { return } @@ -223,11 +183,8 @@ func CurrentUnitName() (unit string, err error) { } }() - sym := C.CString("sd_pid_get_unit") - defer C.free(unsafe.Pointer(sym)) - sd_pid_get_unit := C.dlsym(h.handle, sym) - if sd_pid_get_unit == nil { - err = fmt.Errorf("error resolving sd_pid_get_unit function") + sd_pid_get_unit, err := h.GetSymbolPointer("sd_pid_get_unit") + if err != nil { return } diff --git a/Godeps/_workspace/src/github.com/coreos/pkg/dlopen/dlopen.go b/Godeps/_workspace/src/github.com/coreos/pkg/dlopen/dlopen.go new file mode 100644 index 0000000000..23774f612e --- /dev/null +++ b/Godeps/_workspace/src/github.com/coreos/pkg/dlopen/dlopen.go @@ -0,0 +1,82 @@ +// Copyright 2016 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package dlopen provides some convenience functions to dlopen a library and +// get its symbols. +package dlopen + +// #cgo LDFLAGS: -ldl +// #include +// #include +import "C" +import ( + "errors" + "fmt" + "unsafe" +) + +var ErrSoNotFound = errors.New("unable to open a handle to the library") + +// LibHandle represents an open handle to a library (.so) +type LibHandle struct { + Handle unsafe.Pointer + Libname string +} + +// GetHandle tries to get a handle to a library (.so), attempting to access it +// by the names specified in libs and returning the first that is successfully +// opened. Callers are responsible for closing the handler. If no library can +// be successfully opened, an error is returned. +func GetHandle(libs []string) (*LibHandle, error) { + for _, name := range libs { + libname := C.CString(name) + defer C.free(unsafe.Pointer(libname)) + handle := C.dlopen(libname, C.RTLD_LAZY) + if handle != nil { + h := &LibHandle{ + Handle: handle, + Libname: name, + } + return h, nil + } + } + return nil, ErrSoNotFound +} + +// GetSymbolPointer takes a symbol name and returns a pointer to the symbol. +func (l *LibHandle) GetSymbolPointer(symbol string) (unsafe.Pointer, error) { + sym := C.CString(symbol) + defer C.free(unsafe.Pointer(sym)) + + C.dlerror() + p := C.dlsym(l.Handle, sym) + e := C.dlerror() + if e != nil { + return nil, fmt.Errorf("error resolving symbol %q: %v", symbol, errors.New(C.GoString(e))) + } + + return p, nil +} + +// Close closes a LibHandle. +func (l *LibHandle) Close() error { + C.dlerror() + C.dlclose(l.Handle) + e := C.dlerror() + if e != nil { + return fmt.Errorf("error closing %v: %v", l.Libname, errors.New(C.GoString(e))) + } + + return nil +} diff --git a/Godeps/_workspace/src/github.com/coreos/pkg/dlopen/dlopen_example.go b/Godeps/_workspace/src/github.com/coreos/pkg/dlopen/dlopen_example.go new file mode 100644 index 0000000000..48a660104f --- /dev/null +++ b/Godeps/_workspace/src/github.com/coreos/pkg/dlopen/dlopen_example.go @@ -0,0 +1,56 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +build linux + +package dlopen + +// #include +// #include +// +// int +// my_strlen(void *f, const char *s) +// { +// size_t (*strlen)(const char *); +// +// strlen = (size_t (*)(const char *))f; +// return strlen(s); +// } +import "C" + +import ( + "fmt" + "unsafe" +) + +func strlen(libs []string, s string) (int, error) { + h, err := GetHandle(libs) + if err != nil { + return -1, fmt.Errorf(`couldn't get a handle to the library: %v`, err) + } + defer h.Close() + + f := "strlen" + cs := C.CString(s) + defer C.free(unsafe.Pointer(cs)) + + strlen, err := h.GetSymbolPointer(f) + if err != nil { + return -1, fmt.Errorf(`couldn't get symbol %q: %v`, f, err) + } + + len := C.my_strlen(strlen, cs) + + return int(len), nil +} From 44fbabaf3689e16197b89cee370062a371d967fc Mon Sep 17 00:00:00 2001 From: Derek Parker Date: Wed, 27 Jan 2016 10:54:01 -0800 Subject: [PATCH 0331/1304] api_service: Implement GetLogs RPC request Fixes #1970 --- rkt/api_service.go | 74 ++++++++++++++++++++++++++++++++++++++++++++- stage1/init/init.go | 3 +- 2 files changed, 75 insertions(+), 2 deletions(-) diff --git a/rkt/api_service.go b/rkt/api_service.go index bcd1a6733b..28ccf53de5 100644 --- a/rkt/api_service.go +++ b/rkt/api_service.go @@ -17,6 +17,7 @@ package main import ( "encoding/json" "fmt" + "io/ioutil" "net" "os" "os/signal" @@ -24,13 +25,16 @@ import ( "path/filepath" "strings" "syscall" + "time" "github.com/appc/spec/schema" "github.com/appc/spec/schema/types" + "github.com/coreos/go-systemd/sdjournal" "github.com/coreos/rkt/api/v1alpha" "github.com/coreos/rkt/common" "github.com/coreos/rkt/common/cgroup" "github.com/coreos/rkt/pkg/set" + stage1common "github.com/coreos/rkt/stage1/init/common" "github.com/coreos/rkt/store" "github.com/coreos/rkt/version" "github.com/spf13/cobra" @@ -691,8 +695,76 @@ func (s *v1AlphaAPIServer) InspectImage(ctx context.Context, request *v1alpha.In return &v1alpha.InspectImageResponse{Image: image}, nil } +// LogsStreamWriter is a wrapper around a gRPC streaming server. +// Implements io.Writer interface. +type LogsStreamWriter struct { + server v1alpha.PublicAPI_GetLogsServer +} + +func (sw LogsStreamWriter) Write(b []byte) (int, error) { + if err := sw.server.SendMsg(b); err != nil { + return 0, err + } + return len(b), nil +} + func (s *v1AlphaAPIServer) GetLogs(request *v1alpha.GetLogsRequest, server v1alpha.PublicAPI_GetLogsServer) error { - return fmt.Errorf("not implemented yet") + uuid, err := types.NewUUID(request.PodId) + if err != nil { + return err + } + pod, err := getPod(uuid) + if err != nil { + return err + } + stage1Path := "stage1/rootfs" + if pod.usesOverlay() { + stage1TreeStoreID, err := pod.getStage1TreeStoreID() + if err != nil { + return err + } + stage1Path = fmt.Sprintf("/overlay/%s/upper/", stage1TreeStoreID) + } + path := filepath.Join(getDataDir(), "/pods/run/", request.PodId, stage1Path, "/var/log/journal/") + jconf := sdjournal.JournalReaderConfig{ + Path: path, + } + if request.AppName != "" { + acname, err := types.NewACName(request.AppName) + if err != nil { + return err + } + jconf.Matches = []sdjournal.Match{ + { + Field: sdjournal.SD_JOURNAL_FIELD_SYSTEMD_UNIT, + Value: stage1common.ServiceUnitName(*acname), + }, + } + } + if request.SinceTime != 0 { + t := time.Unix(request.SinceTime, 0) + jconf.Since = time.Since(t) + } + if request.Lines != 0 { + jconf.NumFromTail = uint64(request.Lines) + } + + jr, err := sdjournal.NewJournalReader(jconf) + if err != nil { + return err + } + defer jr.Close() + + if request.Follow { + return jr.Follow(nil, LogsStreamWriter{server: server}) + } + + data, err := ioutil.ReadAll(jr) + if err != nil { + return err + } + lines := strings.Split(string(data), "\n") + return server.Send(&v1alpha.GetLogsResponse{Lines: lines}) } func (s *v1AlphaAPIServer) ListenEvents(request *v1alpha.ListenEventsRequest, server v1alpha.PublicAPI_ListenEventsServer) error { diff --git a/stage1/init/init.go b/stage1/init/init.go index b98f84bcd7..d5b495d373 100644 --- a/stage1/init/init.go +++ b/stage1/init/init.go @@ -36,6 +36,7 @@ import ( "github.com/appc/goaci/proj2aci" "github.com/appc/spec/schema/types" "github.com/coreos/go-systemd/util" + "github.com/coreos/pkg/dlopen" "github.com/godbus/dbus" "github.com/godbus/dbus/introspect" "github.com/hashicorp/errwrap" @@ -397,7 +398,7 @@ func getArgsEnv(p *stage1commontypes.Pod, flavor string, debug bool, n *networki keepUnit, err := util.RunningFromSystemService() if err != nil { - if err == util.ErrSoNotFound { + if err == dlopen.ErrSoNotFound { log.Print("warning: libsystemd not found even though systemd is running. Cgroup limits set by the environment (e.g. a systemd service) won't be enforced.") } else { return nil, nil, errwrap.Wrap(errors.New("error determining if we're running from a system service"), err) From 448dd546367aaa8ed05ef3aff13649b127b0333b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Mon, 1 Feb 2016 18:45:17 +0100 Subject: [PATCH 0332/1304] api: add getlogs to the client example --- api/v1alpha/client_example.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/api/v1alpha/client_example.go b/api/v1alpha/client_example.go index ec807d9ee3..8ca4413ada 100644 --- a/api/v1alpha/client_example.go +++ b/api/v1alpha/client_example.go @@ -51,6 +51,24 @@ func main() { for _, p := range podResp.Pods { fmt.Printf("Pod %q is running\n", p.Id) + + logsResp, err := c.GetLogs(context.Background(), &v1alpha.GetLogsRequest{ + PodId: p.Id, + }) + if err != nil { + fmt.Println(err) + os.Exit(2) + } + + logsRecvResp, err := logsResp.Recv() + if err != nil { + fmt.Println(err) + os.Exit(2) + } + + for _, l := range logsRecvResp.Lines { + fmt.Println(l) + } } // List images. From 996489315f2c806cdf379d60452803e859c97030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Thu, 26 May 2016 15:00:33 +0200 Subject: [PATCH 0333/1304] api_service: SYSTEMD_UNIT -> SYSLOG_IDENTIFIER To avoid the race mentioned in https://github.com/coreos/rkt/issues/2630. --- rkt/api_service.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rkt/api_service.go b/rkt/api_service.go index 28ccf53de5..22182908b4 100644 --- a/rkt/api_service.go +++ b/rkt/api_service.go @@ -736,7 +736,7 @@ func (s *v1AlphaAPIServer) GetLogs(request *v1alpha.GetLogsRequest, server v1alp } jconf.Matches = []sdjournal.Match{ { - Field: sdjournal.SD_JOURNAL_FIELD_SYSTEMD_UNIT, + Field: sdjournal.SD_JOURNAL_FIELD_SYSLOG_IDENTIFIER, Value: stage1common.ServiceUnitName(*acname), }, } From d0a749a6a79d0aa747558fe6349bb5ab0156679b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Fri, 27 May 2016 14:35:51 +0200 Subject: [PATCH 0334/1304] api: exit with status 1 on error Sequential numbering of errors is evil. --- api/v1alpha/client_example.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/v1alpha/client_example.go b/api/v1alpha/client_example.go index 8ca4413ada..0cf1949f7a 100644 --- a/api/v1alpha/client_example.go +++ b/api/v1alpha/client_example.go @@ -46,7 +46,7 @@ func main() { }) if err != nil { fmt.Println(err) - os.Exit(2) + os.Exit(1) } for _, p := range podResp.Pods { @@ -57,13 +57,13 @@ func main() { }) if err != nil { fmt.Println(err) - os.Exit(2) + os.Exit(1) } logsRecvResp, err := logsResp.Recv() if err != nil { fmt.Println(err) - os.Exit(2) + os.Exit(1) } for _, l := range logsRecvResp.Lines { @@ -83,7 +83,7 @@ func main() { }) if err != nil { fmt.Println(err) - os.Exit(3) + os.Exit(1) } for _, im := range imgResp.Images { From a627ead79950a3ac568f126c8e0ccaf2fd1bdb03 Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Tue, 24 May 2016 23:30:11 +0200 Subject: [PATCH 0335/1304] cni: 0.2.3 -> 0.3.0-rc3 --- Godeps/Godeps.json | 97 +++++- .../containernetworking/cni/LICENSE | 202 +++++++++++ .../containernetworking/cni/pkg/ip/cidr.go | 51 +++ .../cni/pkg/ip/ipforward.go | 31 ++ .../containernetworking/cni/pkg/ip/ipmasq.go | 66 ++++ .../containernetworking/cni/pkg/ip/link.go | 153 +++++++++ .../containernetworking/cni/pkg/ip/route.go | 47 +++ .../containernetworking/cni/pkg/ns/README.md | 31 ++ .../containernetworking/cni/pkg/ns/ns.go | 315 ++++++++++++++++++ .../containernetworking/cni/pkg/types/args.go | 91 +++++ .../cni/pkg/types/types.go | 191 +++++++++++ .../cni/pkg/utils/utils.go | 41 +++ networking/kvm.go | 6 +- networking/net_plugin.go | 2 +- networking/netinfo/netinfo.go | 2 +- networking/networking.go | 4 +- stage1/init/kvm/network.go | 2 +- stage1/init/kvm/network_test.go | 2 +- vendoredApps | 17 +- 19 files changed, 1333 insertions(+), 18 deletions(-) create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/LICENSE create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/cidr.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/ipforward.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/ipmasq.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/link.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/route.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ns/README.md create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ns/ns.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/types/args.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/types/types.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/utils/utils.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 2effffa85b..119c66dc82 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,7 +1,7 @@ { "ImportPath": "github.com/coreos/rkt", "GoVersion": "go1.5", - "GodepVersion": "v70", + "GodepVersion": "v71", "Packages": [ "./...", "github.com/appc/spec/actool", @@ -260,6 +260,101 @@ "ImportPath": "github.com/camlistore/go4/lock", "Rev": "9ba773eba85ab9e258ff516630f7f6474bc4535b" }, + { + "ImportPath": "github.com/containernetworking/cni/pkg/invoke", + "Comment": "v0.3.0-rc3", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/pkg/ip", + "Comment": "v0.3.0-rc3", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/pkg/ipam", + "Comment": "v0.3.0-rc3", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/pkg/ns", + "Comment": "v0.3.0-rc3", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/pkg/skel", + "Comment": "v0.3.0-rc3", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/pkg/testutils", + "Comment": "v0.3.0-rc3", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/pkg/types", + "Comment": "v0.3.0-rc3", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/pkg/utils", + "Comment": "v0.3.0-rc3", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/pkg/utils/sysctl", + "Comment": "v0.3.0-rc3", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/plugins/ipam/dhcp", + "Comment": "v0.3.0-rc3", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/plugins/ipam/host-local", + "Comment": "v0.3.0-rc3", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/plugins/ipam/host-local/backend", + "Comment": "v0.3.0-rc3", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk", + "Comment": "v0.3.0-rc3", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/plugins/main/bridge", + "Comment": "v0.3.0-rc3", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/plugins/main/ipvlan", + "Comment": "v0.3.0-rc3", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/plugins/main/macvlan", + "Comment": "v0.3.0-rc3", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/plugins/main/ptp", + "Comment": "v0.3.0-rc3", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/plugins/meta/flannel", + "Comment": "v0.3.0-rc3", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/plugins/meta/tuning", + "Comment": "v0.3.0-rc3", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, { "ImportPath": "github.com/coreos/gexpect", "Comment": "v0.1.0", diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/LICENSE b/Godeps/_workspace/src/github.com/containernetworking/cni/LICENSE new file mode 100644 index 0000000000..8f71f43fee --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/LICENSE @@ -0,0 +1,202 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor 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, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/cidr.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/cidr.go new file mode 100644 index 0000000000..dae2c4d0e4 --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/cidr.go @@ -0,0 +1,51 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ip + +import ( + "math/big" + "net" +) + +// NextIP returns IP incremented by 1 +func NextIP(ip net.IP) net.IP { + i := ipToInt(ip) + return intToIP(i.Add(i, big.NewInt(1))) +} + +// PrevIP returns IP decremented by 1 +func PrevIP(ip net.IP) net.IP { + i := ipToInt(ip) + return intToIP(i.Sub(i, big.NewInt(1))) +} + +func ipToInt(ip net.IP) *big.Int { + if v := ip.To4(); v != nil { + return big.NewInt(0).SetBytes(v) + } + return big.NewInt(0).SetBytes(ip.To16()) +} + +func intToIP(i *big.Int) net.IP { + return net.IP(i.Bytes()) +} + +// Network masks off the host portion of the IP +func Network(ipn *net.IPNet) *net.IPNet { + return &net.IPNet{ + IP: ipn.IP.Mask(ipn.Mask), + Mask: ipn.Mask, + } +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/ipforward.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/ipforward.go new file mode 100644 index 0000000000..77ee74632a --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/ipforward.go @@ -0,0 +1,31 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ip + +import ( + "io/ioutil" +) + +func EnableIP4Forward() error { + return echo1("/proc/sys/net/ipv4/ip_forward") +} + +func EnableIP6Forward() error { + return echo1("/proc/sys/net/ipv6/conf/all/forwarding") +} + +func echo1(f string) error { + return ioutil.WriteFile(f, []byte("1"), 0644) +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/ipmasq.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/ipmasq.go new file mode 100644 index 0000000000..8ee279717a --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/ipmasq.go @@ -0,0 +1,66 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ip + +import ( + "fmt" + "net" + + "github.com/coreos/go-iptables/iptables" +) + +// SetupIPMasq installs iptables rules to masquerade traffic +// coming from ipn and going outside of it +func SetupIPMasq(ipn *net.IPNet, chain string, comment string) error { + ipt, err := iptables.New() + if err != nil { + return fmt.Errorf("failed to locate iptables: %v", err) + } + + if err = ipt.NewChain("nat", chain); err != nil { + if err.(*iptables.Error).ExitStatus() != 1 { + // TODO(eyakubovich): assumes exit status 1 implies chain exists + return err + } + } + + if err = ipt.AppendUnique("nat", chain, "-d", ipn.String(), "-j", "ACCEPT", "-m", "comment", "--comment", comment); err != nil { + return err + } + + if err = ipt.AppendUnique("nat", chain, "!", "-d", "224.0.0.0/4", "-j", "MASQUERADE", "-m", "comment", "--comment", comment); err != nil { + return err + } + + return ipt.AppendUnique("nat", "POSTROUTING", "-s", ipn.String(), "-j", chain, "-m", "comment", "--comment", comment) +} + +// TeardownIPMasq undoes the effects of SetupIPMasq +func TeardownIPMasq(ipn *net.IPNet, chain string, comment string) error { + ipt, err := iptables.New() + if err != nil { + return fmt.Errorf("failed to locate iptables: %v", err) + } + + if err = ipt.Delete("nat", "POSTROUTING", "-s", ipn.String(), "-j", chain, "-m", "comment", "--comment", comment); err != nil { + return err + } + + if err = ipt.ClearChain("nat", chain); err != nil { + return err + } + + return ipt.DeleteChain("nat", chain) +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/link.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/link.go new file mode 100644 index 0000000000..1b78567201 --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/link.go @@ -0,0 +1,153 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ip + +import ( + "crypto/rand" + "fmt" + "net" + "os" + + "github.com/containernetworking/cni/pkg/ns" + "github.com/vishvananda/netlink" +) + +func makeVethPair(name, peer string, mtu int) (netlink.Link, error) { + veth := &netlink.Veth{ + LinkAttrs: netlink.LinkAttrs{ + Name: name, + Flags: net.FlagUp, + MTU: mtu, + }, + PeerName: peer, + } + if err := netlink.LinkAdd(veth); err != nil { + return nil, err + } + + return veth, nil +} + +func makeVeth(name string, mtu int) (peerName string, veth netlink.Link, err error) { + for i := 0; i < 10; i++ { + peerName, err = RandomVethName() + if err != nil { + return + } + + veth, err = makeVethPair(name, peerName, mtu) + switch { + case err == nil: + return + + case os.IsExist(err): + continue + + default: + err = fmt.Errorf("failed to make veth pair: %v", err) + return + } + } + + // should really never be hit + err = fmt.Errorf("failed to find a unique veth name") + return +} + +// RandomVethName returns string "veth" with random prefix (hashed from entropy) +func RandomVethName() (string, error) { + entropy := make([]byte, 4) + _, err := rand.Reader.Read(entropy) + if err != nil { + return "", fmt.Errorf("failed to generate random veth name: %v", err) + } + + // NetworkManager (recent versions) will ignore veth devices that start with "veth" + return fmt.Sprintf("veth%x", entropy), nil +} + +// SetupVeth sets up a virtual ethernet link. +// Should be in container netns, and will switch back to hostNS to set the host +// veth end up. +func SetupVeth(contVethName string, mtu int, hostNS ns.NetNS) (hostVeth, contVeth netlink.Link, err error) { + var hostVethName string + hostVethName, contVeth, err = makeVeth(contVethName, mtu) + if err != nil { + return + } + + if err = netlink.LinkSetUp(contVeth); err != nil { + err = fmt.Errorf("failed to set %q up: %v", contVethName, err) + return + } + + hostVeth, err = netlink.LinkByName(hostVethName) + if err != nil { + err = fmt.Errorf("failed to lookup %q: %v", hostVethName, err) + return + } + + if err = netlink.LinkSetNsFd(hostVeth, int(hostNS.Fd())); err != nil { + err = fmt.Errorf("failed to move veth to host netns: %v", err) + return + } + + err = hostNS.Do(func(_ ns.NetNS) error { + hostVeth, err := netlink.LinkByName(hostVethName) + if err != nil { + return fmt.Errorf("failed to lookup %q in %q: %v", hostVethName, hostNS.Path(), err) + } + + if err = netlink.LinkSetUp(hostVeth); err != nil { + return fmt.Errorf("failed to set %q up: %v", hostVethName, err) + } + return nil + }) + return +} + +// DelLinkByName removes an interface link. +func DelLinkByName(ifName string) error { + iface, err := netlink.LinkByName(ifName) + if err != nil { + return fmt.Errorf("failed to lookup %q: %v", ifName, err) + } + + if err = netlink.LinkDel(iface); err != nil { + return fmt.Errorf("failed to delete %q: %v", ifName, err) + } + + return nil +} + +// DelLinkByNameAddr remove an interface returns its IP address +// of the specified family +func DelLinkByNameAddr(ifName string, family int) (*net.IPNet, error) { + iface, err := netlink.LinkByName(ifName) + if err != nil { + return nil, fmt.Errorf("failed to lookup %q: %v", ifName, err) + } + + addrs, err := netlink.AddrList(iface, family) + if err != nil || len(addrs) == 0 { + return nil, fmt.Errorf("failed to get IP addresses for %q: %v", ifName, err) + } + + if err = netlink.LinkDel(iface); err != nil { + return nil, fmt.Errorf("failed to delete %q: %v", ifName, err) + } + + return addrs[0].IPNet, nil +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/route.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/route.go new file mode 100644 index 0000000000..6c8658b2a2 --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/route.go @@ -0,0 +1,47 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ip + +import ( + "net" + + "github.com/vishvananda/netlink" +) + +// AddDefaultRoute sets the default route on the given gateway. +func AddDefaultRoute(gw net.IP, dev netlink.Link) error { + _, defNet, _ := net.ParseCIDR("0.0.0.0/0") + return AddRoute(defNet, gw, dev) +} + +// AddRoute adds a universally-scoped route to a device. +func AddRoute(ipn *net.IPNet, gw net.IP, dev netlink.Link) error { + return netlink.RouteAdd(&netlink.Route{ + LinkIndex: dev.Attrs().Index, + Scope: netlink.SCOPE_UNIVERSE, + Dst: ipn, + Gw: gw, + }) +} + +// AddHostRoute adds a host-scoped route to a device. +func AddHostRoute(ipn *net.IPNet, gw net.IP, dev netlink.Link) error { + return netlink.RouteAdd(&netlink.Route{ + LinkIndex: dev.Attrs().Index, + Scope: netlink.SCOPE_HOST, + Dst: ipn, + Gw: gw, + }) +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ns/README.md b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ns/README.md new file mode 100644 index 0000000000..e7b20c2f9b --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ns/README.md @@ -0,0 +1,31 @@ +### Namespaces, Threads, and Go +On Linux each OS thread can have a different network namespace. Go's thread scheduling model switches goroutines between OS threads based on OS thread load and whether the goroutine would block other goroutines. This can result in a goroutine switching network namespaces without notice and lead to errors in your code. + +### Namespace Switching +Switching namespaces with the `ns.Set()` method is not recommended without additional strategies to prevent unexpected namespace changes when your goroutines switch OS threads. + +Go provides the `runtime.LockOSThread()` function to ensure a specific goroutine executes on its current OS thread and prevents any other goroutine from running in that thread until the locked one exits. Careful usage of `LockOSThread()` and goroutines can provide good control over which network namespace a given goroutine executes in. + +For example, you cannot rely on the `ns.Set()` namespace being the current namespace after the `Set()` call unless you do two things. First, the goroutine calling `Set()` must have previously called `LockOSThread()`. Second, you must ensure `runtime.UnlockOSThread()` is not called somewhere in-between. You also cannot rely on the initial network namespace remaining the current network namespace if any other code in your program switches namespaces, unless you have already called `LockOSThread()` in that goroutine. Note that `LockOSThread()` prevents the Go scheduler from optimally scheduling goroutines for best performance, so `LockOSThread()` should only be used in small, isolated goroutines that release the lock quickly. + +### Do() The Recommended Thing +The `ns.Do()` method provides control over network namespaces for you by implementing these strategies. All code dependent on a particular network namespace should be wrapped in the `ns.Do()` method to ensure the correct namespace is selected for the duration of your code. For example: + +```go +targetNs, err := ns.NewNS() +if err != nil { + return err +} +err = targetNs.Do(func(hostNs ns.NetNS) error { + dummy := &netlink.Dummy{ + LinkAttrs: netlink.LinkAttrs{ + Name: "dummy0", + }, + } + return netlink.LinkAdd(dummy) +}) +``` + +### Further Reading + - https://github.com/golang/go/wiki/LockOSThread + - http://morsmachine.dk/go-scheduler diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ns/ns.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ns/ns.go new file mode 100644 index 0000000000..e29f712ce1 --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ns/ns.go @@ -0,0 +1,315 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ns + +import ( + "crypto/rand" + "fmt" + "os" + "path" + "runtime" + "strings" + "sync" + "syscall" + + "golang.org/x/sys/unix" +) + +type NetNS interface { + // Executes the passed closure in this object's network namespace, + // attemtping to restore the original namespace before returning. + // However, since each OS thread can have a different network namespace, + // and Go's thread scheduling is highly variable, callers cannot + // guarantee any specific namespace is set unless operations that + // require that namespace are wrapped with Do(). Also, no code called + // from Do() should call runtime.UnlockOSThread(), or the risk + // of executing code in an incorrect namespace will be greater. See + // https://github.com/golang/go/wiki/LockOSThread for further details. + Do(toRun func(NetNS) error) error + + // Sets the current network namespace to this object's network namespace. + // Note that since Go's thread scheduling is highly variable, callers + // cannot guarantee the requested namespace will be the current namespace + // after this function is called; to ensure this wrap operations that + // require the namespace with Do() instead. + Set() error + + // Returns the filesystem path representing this object's network namespace + Path() string + + // Returns a file descriptor representing this object's network namespace + Fd() uintptr + + // Cleans up this instance of the network namespace; if this instance + // is the last user the namespace will be destroyed + Close() error +} + +type netNS struct { + file *os.File + mounted bool + closed bool +} + +func getCurrentThreadNetNSPath() string { + // /proc/self/ns/net returns the namespace of the main thread, not + // of whatever thread this goroutine is running on. Make sure we + // use the thread's net namespace since the thread is switching around + return fmt.Sprintf("/proc/%d/task/%d/ns/net", os.Getpid(), unix.Gettid()) +} + +// Returns an object representing the current OS thread's network namespace +func GetCurrentNS() (NetNS, error) { + return GetNS(getCurrentThreadNetNSPath()) +} + +const ( + // https://github.com/torvalds/linux/blob/master/include/uapi/linux/magic.h + NSFS_MAGIC = 0x6e736673 + PROCFS_MAGIC = 0x9fa0 +) + +type NSPathNotExistErr struct{ msg string } + +func (e NSPathNotExistErr) Error() string { return e.msg } + +type NSPathNotNSErr struct{ msg string } + +func (e NSPathNotNSErr) Error() string { return e.msg } + +func IsNSorErr(nspath string) error { + stat := syscall.Statfs_t{} + if err := syscall.Statfs(nspath, &stat); err != nil { + if os.IsNotExist(err) { + err = NSPathNotExistErr{msg: fmt.Sprintf("failed to Statfs %q: %v", nspath, err)} + } else { + err = fmt.Errorf("failed to Statfs %q: %v", nspath, err) + } + return err + } + + switch stat.Type { + case PROCFS_MAGIC: + // Kernel < 3.19 + + validPathContent := "ns/" + validName := strings.Contains(nspath, validPathContent) + if !validName { + return NSPathNotNSErr{msg: fmt.Sprintf("path %q doesn't contain %q", nspath, validPathContent)} + } + + return nil + case NSFS_MAGIC: + // Kernel >= 3.19 + + return nil + default: + return NSPathNotNSErr{msg: fmt.Sprintf("unknown FS magic on %q: %x", nspath, stat.Type)} + } +} + +// Returns an object representing the namespace referred to by @path +func GetNS(nspath string) (NetNS, error) { + err := IsNSorErr(nspath) + if err != nil { + return nil, err + } + + fd, err := os.Open(nspath) + if err != nil { + return nil, err + } + + return &netNS{file: fd}, nil +} + +// Creates a new persistent network namespace and returns an object +// representing that namespace, without switching to it +func NewNS() (NetNS, error) { + const nsRunDir = "/var/run/netns" + + b := make([]byte, 16) + _, err := rand.Reader.Read(b) + if err != nil { + return nil, fmt.Errorf("failed to generate random netns name: %v", err) + } + + err = os.MkdirAll(nsRunDir, 0755) + if err != nil { + return nil, err + } + + // create an empty file at the mount point + nsName := fmt.Sprintf("cni-%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:]) + nsPath := path.Join(nsRunDir, nsName) + mountPointFd, err := os.Create(nsPath) + if err != nil { + return nil, err + } + mountPointFd.Close() + + // Ensure the mount point is cleaned up on errors; if the namespace + // was successfully mounted this will have no effect because the file + // is in-use + defer os.RemoveAll(nsPath) + + var wg sync.WaitGroup + wg.Add(1) + + // do namespace work in a dedicated goroutine, so that we can safely + // Lock/Unlock OSThread without upsetting the lock/unlock state of + // the caller of this function + var fd *os.File + go (func() { + defer wg.Done() + runtime.LockOSThread() + + var origNS NetNS + origNS, err = GetNS(getCurrentThreadNetNSPath()) + if err != nil { + return + } + defer origNS.Close() + + // create a new netns on the current thread + err = unix.Unshare(unix.CLONE_NEWNET) + if err != nil { + return + } + defer origNS.Set() + + // bind mount the new netns from the current thread onto the mount point + err = unix.Mount(getCurrentThreadNetNSPath(), nsPath, "none", unix.MS_BIND, "") + if err != nil { + return + } + + fd, err = os.Open(nsPath) + if err != nil { + return + } + })() + wg.Wait() + + if err != nil { + unix.Unmount(nsPath, unix.MNT_DETACH) + return nil, fmt.Errorf("failed to create namespace: %v", err) + } + + return &netNS{file: fd, mounted: true}, nil +} + +func (ns *netNS) Path() string { + return ns.file.Name() +} + +func (ns *netNS) Fd() uintptr { + return ns.file.Fd() +} + +func (ns *netNS) errorIfClosed() error { + if ns.closed { + return fmt.Errorf("%q has already been closed", ns.file.Name()) + } + return nil +} + +func (ns *netNS) Close() error { + if err := ns.errorIfClosed(); err != nil { + return err + } + + if err := ns.file.Close(); err != nil { + return fmt.Errorf("Failed to close %q: %v", ns.file.Name(), err) + } + ns.closed = true + + if ns.mounted { + if err := unix.Unmount(ns.file.Name(), unix.MNT_DETACH); err != nil { + return fmt.Errorf("Failed to unmount namespace %s: %v", ns.file.Name(), err) + } + if err := os.RemoveAll(ns.file.Name()); err != nil { + return fmt.Errorf("Failed to clean up namespace %s: %v", ns.file.Name(), err) + } + ns.mounted = false + } + + return nil +} + +func (ns *netNS) Do(toRun func(NetNS) error) error { + if err := ns.errorIfClosed(); err != nil { + return err + } + + containedCall := func(hostNS NetNS) error { + threadNS, err := GetNS(getCurrentThreadNetNSPath()) + if err != nil { + return fmt.Errorf("failed to open current netns: %v", err) + } + defer threadNS.Close() + + // switch to target namespace + if err = ns.Set(); err != nil { + return fmt.Errorf("error switching to ns %v: %v", ns.file.Name(), err) + } + defer threadNS.Set() // switch back + + return toRun(hostNS) + } + + // save a handle to current network namespace + hostNS, err := GetNS(getCurrentThreadNetNSPath()) + if err != nil { + return fmt.Errorf("Failed to open current namespace: %v", err) + } + defer hostNS.Close() + + var wg sync.WaitGroup + wg.Add(1) + + var innerError error + go func() { + defer wg.Done() + runtime.LockOSThread() + innerError = containedCall(hostNS) + }() + wg.Wait() + + return innerError +} + +func (ns *netNS) Set() error { + if err := ns.errorIfClosed(); err != nil { + return err + } + + if _, _, err := unix.Syscall(unix.SYS_SETNS, ns.Fd(), uintptr(unix.CLONE_NEWNET), 0); err != 0 { + return fmt.Errorf("Error switching to ns %v: %v", ns.file.Name(), err) + } + + return nil +} + +// WithNetNSPath executes the passed closure under the given network +// namespace, restoring the original namespace afterwards. +func WithNetNSPath(nspath string, toRun func(NetNS) error) error { + ns, err := GetNS(nspath) + if err != nil { + return err + } + defer ns.Close() + return ns.Do(toRun) +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/types/args.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/types/args.go new file mode 100644 index 0000000000..3b667b0f20 --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/types/args.go @@ -0,0 +1,91 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "encoding" + "fmt" + "reflect" + "strings" +) + +// UnmarshallableBool typedef for builtin bool +// because builtin type's methods can't be declared +type UnmarshallableBool bool + +// UnmarshalText implements the encoding.TextUnmarshaler interface. +// Returns boolean true if the string is "1" or "[Tt]rue" +// Returns boolean false if the string is "0" or "[Ff]alse" +func (b *UnmarshallableBool) UnmarshalText(data []byte) error { + s := strings.ToLower(string(data)) + switch s { + case "1", "true": + *b = true + case "0", "false": + *b = false + default: + return fmt.Errorf("Boolean unmarshal error: invalid input %s", s) + } + return nil +} + +// CommonArgs contains the IgnoreUnknown argument +// and must be embedded by all Arg structs +type CommonArgs struct { + IgnoreUnknown UnmarshallableBool `json:"ignoreunknown,omitempty"` +} + +// GetKeyField is a helper function to receive Values +// Values that represent a pointer to a struct +func GetKeyField(keyString string, v reflect.Value) reflect.Value { + return v.Elem().FieldByName(keyString) +} + +// LoadArgs parses args from a string in the form "K=V;K2=V2;..." +func LoadArgs(args string, container interface{}) error { + if args == "" { + return nil + } + + containerValue := reflect.ValueOf(container) + + pairs := strings.Split(args, ";") + unknownArgs := []string{} + for _, pair := range pairs { + kv := strings.Split(pair, "=") + if len(kv) != 2 { + return fmt.Errorf("ARGS: invalid pair %q", pair) + } + keyString := kv[0] + valueString := kv[1] + keyField := GetKeyField(keyString, containerValue) + if !keyField.IsValid() { + unknownArgs = append(unknownArgs, pair) + continue + } + + u := keyField.Addr().Interface().(encoding.TextUnmarshaler) + err := u.UnmarshalText([]byte(valueString)) + if err != nil { + return fmt.Errorf("ARGS: error parsing value of pair %q: %v)", pair, err) + } + } + + isIgnoreUnknown := GetKeyField("IgnoreUnknown", containerValue).Bool() + if len(unknownArgs) > 0 && !isIgnoreUnknown { + return fmt.Errorf("ARGS: unknown args %q", unknownArgs) + } + return nil +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/types/types.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/types/types.go new file mode 100644 index 0000000000..6948dcb1fb --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/types/types.go @@ -0,0 +1,191 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "encoding/json" + "fmt" + "net" + "os" +) + +// like net.IPNet but adds JSON marshalling and unmarshalling +type IPNet net.IPNet + +// ParseCIDR takes a string like "10.2.3.1/24" and +// return IPNet with "10.2.3.1" and /24 mask +func ParseCIDR(s string) (*net.IPNet, error) { + ip, ipn, err := net.ParseCIDR(s) + if err != nil { + return nil, err + } + + ipn.IP = ip + return ipn, nil +} + +func (n IPNet) MarshalJSON() ([]byte, error) { + return json.Marshal((*net.IPNet)(&n).String()) +} + +func (n *IPNet) UnmarshalJSON(data []byte) error { + var s string + if err := json.Unmarshal(data, &s); err != nil { + return err + } + + tmp, err := ParseCIDR(s) + if err != nil { + return err + } + + *n = IPNet(*tmp) + return nil +} + +// NetConf describes a network. +type NetConf struct { + Name string `json:"name,omitempty"` + Type string `json:"type,omitempty"` + IPAM struct { + Type string `json:"type,omitempty"` + } `json:"ipam,omitempty"` + DNS DNS `json:"dns"` +} + +// Result is what gets returned from the plugin (via stdout) to the caller +type Result struct { + IP4 *IPConfig `json:"ip4,omitempty"` + IP6 *IPConfig `json:"ip6,omitempty"` + DNS DNS `json:"dns,omitempty"` +} + +func (r *Result) Print() error { + return prettyPrint(r) +} + +// String returns a formatted string in the form of "[IP4: $1,][ IP6: $2,] DNS: $3" where +// $1 represents the receiver's IPv4, $2 represents the receiver's IPv6 and $3 the +// receiver's DNS. If $1 or $2 are nil, they won't be present in the returned string. +func (r *Result) String() string { + var str string + if r.IP4 != nil { + str = fmt.Sprintf("IP4:%+v, ", *r.IP4) + } + if r.IP6 != nil { + str += fmt.Sprintf("IP6:%+v, ", *r.IP6) + } + return fmt.Sprintf("%sDNS:%+v", str, r.DNS) +} + +// IPConfig contains values necessary to configure an interface +type IPConfig struct { + IP net.IPNet + Gateway net.IP + Routes []Route +} + +// DNS contains values interesting for DNS resolvers +type DNS struct { + Nameservers []string `json:"nameservers,omitempty"` + Domain string `json:"domain,omitempty"` + Search []string `json:"search,omitempty"` + Options []string `json:"options,omitempty"` +} + +type Route struct { + Dst net.IPNet + GW net.IP +} + +type Error struct { + Code uint `json:"code"` + Msg string `json:"msg"` + Details string `json:"details,omitempty"` +} + +func (e *Error) Error() string { + return e.Msg +} + +func (e *Error) Print() error { + return prettyPrint(e) +} + +// net.IPNet is not JSON (un)marshallable so this duality is needed +// for our custom IPNet type + +// JSON (un)marshallable types +type ipConfig struct { + IP IPNet `json:"ip"` + Gateway net.IP `json:"gateway,omitempty"` + Routes []Route `json:"routes,omitempty"` +} + +type route struct { + Dst IPNet `json:"dst"` + GW net.IP `json:"gw,omitempty"` +} + +func (c *IPConfig) MarshalJSON() ([]byte, error) { + ipc := ipConfig{ + IP: IPNet(c.IP), + Gateway: c.Gateway, + Routes: c.Routes, + } + + return json.Marshal(ipc) +} + +func (c *IPConfig) UnmarshalJSON(data []byte) error { + ipc := ipConfig{} + if err := json.Unmarshal(data, &ipc); err != nil { + return err + } + + c.IP = net.IPNet(ipc.IP) + c.Gateway = ipc.Gateway + c.Routes = ipc.Routes + return nil +} + +func (r *Route) UnmarshalJSON(data []byte) error { + rt := route{} + if err := json.Unmarshal(data, &rt); err != nil { + return err + } + + r.Dst = net.IPNet(rt.Dst) + r.GW = rt.GW + return nil +} + +func (r *Route) MarshalJSON() ([]byte, error) { + rt := route{ + Dst: IPNet(r.Dst), + GW: r.GW, + } + + return json.Marshal(rt) +} + +func prettyPrint(obj interface{}) error { + data, err := json.MarshalIndent(obj, "", " ") + if err != nil { + return err + } + _, err = os.Stdout.Write(data) + return err +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/utils/utils.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/utils/utils.go new file mode 100644 index 0000000000..33a2aa7960 --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/utils/utils.go @@ -0,0 +1,41 @@ +// Copyright 2016 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package utils + +import ( + "crypto/sha512" + "fmt" +) + +const ( + maxChainLength = 28 + chainPrefix = "CNI-" + prefixLength = len(chainPrefix) +) + +// Generates a chain name to be used with iptables. +// Ensures that the generated chain name is exactly +// maxChainLength chars in length +func FormatChainName(name string, id string) string { + chainBytes := sha512.Sum512([]byte(name + id)) + chain := fmt.Sprintf("%s%x", chainPrefix, chainBytes) + return chain[:maxChainLength] +} + +// FormatComment returns a comment used for easier +// rule identification within iptables. +func FormatComment(name string, id string) string { + return fmt.Sprintf("name: %q id: %q", name, id) +} diff --git a/networking/kvm.go b/networking/kvm.go index 4019370c97..e57cc99d91 100644 --- a/networking/kvm.go +++ b/networking/kvm.go @@ -27,10 +27,10 @@ import ( "strings" "syscall" - "github.com/appc/cni/pkg/ip" - cnitypes "github.com/appc/cni/pkg/types" - cniutils "github.com/appc/cni/pkg/utils" "github.com/appc/spec/schema/types" + "github.com/containernetworking/cni/pkg/ip" + cnitypes "github.com/containernetworking/cni/pkg/types" + cniutils "github.com/containernetworking/cni/pkg/utils" "github.com/hashicorp/errwrap" "github.com/vishvananda/netlink" diff --git a/networking/net_plugin.go b/networking/net_plugin.go index eb86c90d97..652233984b 100644 --- a/networking/net_plugin.go +++ b/networking/net_plugin.go @@ -24,7 +24,7 @@ import ( "path/filepath" "strings" - cnitypes "github.com/appc/cni/pkg/types" + cnitypes "github.com/containernetworking/cni/pkg/types" "github.com/hashicorp/errwrap" "github.com/coreos/rkt/common" diff --git a/networking/netinfo/netinfo.go b/networking/netinfo/netinfo.go index 05c20baba1..fcfa5908c7 100644 --- a/networking/netinfo/netinfo.go +++ b/networking/netinfo/netinfo.go @@ -21,7 +21,7 @@ import ( "path/filepath" "syscall" - "github.com/appc/cni/pkg/types" + "github.com/containernetworking/cni/pkg/types" ) const filename = "net-info.json" diff --git a/networking/networking.go b/networking/networking.go index 61ec25c0c4..f07ee923c0 100644 --- a/networking/networking.go +++ b/networking/networking.go @@ -24,9 +24,9 @@ import ( "strings" "syscall" - "github.com/appc/cni/pkg/ns" - cnitypes "github.com/appc/cni/pkg/types" "github.com/appc/spec/schema/types" + "github.com/containernetworking/cni/pkg/ns" + cnitypes "github.com/containernetworking/cni/pkg/types" "github.com/hashicorp/errwrap" "github.com/vishvananda/netlink" diff --git a/stage1/init/kvm/network.go b/stage1/init/kvm/network.go index e4eccc2011..68ce32e47d 100644 --- a/stage1/init/kvm/network.go +++ b/stage1/init/kvm/network.go @@ -22,7 +22,7 @@ import ( "net" "path/filepath" - "github.com/appc/cni/pkg/types" + "github.com/containernetworking/cni/pkg/types" "github.com/coreos/go-systemd/unit" "github.com/coreos/rkt/networking" "github.com/hashicorp/errwrap" diff --git a/stage1/init/kvm/network_test.go b/stage1/init/kvm/network_test.go index 019dd87c8c..16699d7fcf 100644 --- a/stage1/init/kvm/network_test.go +++ b/stage1/init/kvm/network_test.go @@ -18,7 +18,7 @@ import ( "net" "testing" - "github.com/appc/cni/pkg/types" + "github.com/containernetworking/cni/pkg/types" ) type testNetDescriber struct { diff --git a/vendoredApps b/vendoredApps index e8b00a1c35..45842df29c 100644 --- a/vendoredApps +++ b/vendoredApps @@ -2,14 +2,15 @@ github.com/appc/spec/actool # Vendor in CNI plugins, which will become a part of the stage1 image -github.com/appc/cni/plugins/ipam/dhcp -github.com/appc/cni/plugins/ipam/host-local -github.com/appc/cni/plugins/main/bridge -github.com/appc/cni/plugins/main/ipvlan -github.com/appc/cni/plugins/main/macvlan -github.com/appc/cni/plugins/main/ptp -github.com/appc/cni/plugins/meta/flannel -github.com/appc/cni/plugins/meta/tuning +github.com/containernetworking/cni/plugins/ipam/dhcp +github.com/containernetworking/cni/plugins/ipam/host-local +github.com/containernetworking/cni/plugins/main/bridge +github.com/containernetworking/cni/plugins/main/ipvlan +github.com/containernetworking/cni/plugins/main/lo +github.com/containernetworking/cni/plugins/main/macvlan +github.com/containernetworking/cni/plugins/main/ptp +github.com/containernetworking/cni/plugins/meta/flannel +github.com/containernetworking/cni/plugins/meta/tuning # Vendor in ACE, which is used in functional tests github.com/appc/spec/ace From f08211e095a3dfb8fc3bf1abba56a9cacbe4d867 Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Fri, 27 May 2016 15:08:49 +0200 Subject: [PATCH 0336/1304] deps: fix CNI location in various places --- Godeps/Godeps.json | 171 ++++----- .../cni/pkg/invoke/args.go | 76 ++++ .../cni/pkg/invoke/delegate.go | 53 +++ .../cni/pkg/invoke/exec.go | 75 ++++ .../cni/pkg/invoke/find.go | 47 +++ .../containernetworking/cni/pkg/ipam/ipam.go | 68 ++++ .../containernetworking/cni/pkg/skel/skel.go | 161 +++++++++ .../cni/pkg/testutils/cmd.go | 77 ++++ .../cni/pkg/utils/sysctl/sysctl_linux.go | 58 +++ .../cni/plugins/ipam/dhcp/daemon.go | 157 ++++++++ .../cni/plugins/ipam/dhcp/lease.go | 337 ++++++++++++++++++ .../cni/plugins/ipam/dhcp/main.go | 73 ++++ .../cni/plugins/ipam/dhcp/options.go | 139 ++++++++ .../cni/plugins/ipam/host-local/README.md | 86 +++++ .../cni/plugins/ipam/host-local/allocator.go | 165 +++++++++ .../ipam/host-local/backend/disk/backend.go | 88 +++++ .../ipam/host-local/backend/disk/lock.go | 50 +++ .../plugins/ipam/host-local/backend/store.go | 26 ++ .../cni/plugins/ipam/host-local/config.go | 70 ++++ .../cni/plugins/ipam/host-local/main.go | 74 ++++ .../cni/plugins/main/bridge/bridge.go | 319 +++++++++++++++++ .../cni/plugins/main/ipvlan/ipvlan.go | 175 +++++++++ .../cni/plugins/main/macvlan/macvlan.go | 193 ++++++++++ .../cni/plugins/main/ptp/ptp.go | 229 ++++++++++++ .../cni/plugins/meta/flannel/flannel.go | 253 +++++++++++++ .../cni/plugins/meta/tuning/tuning.go | 82 +++++ stage1/net-plugins/net-plugins.mk | 4 +- vendoredApps | 1 - 28 files changed, 3211 insertions(+), 96 deletions(-) create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/args.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/delegate.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/exec.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/find.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ipam/ipam.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/skel/skel.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/testutils/cmd.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/utils/sysctl/sysctl_linux.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/daemon.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/lease.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/main.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/options.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/README.md create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/allocator.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk/backend.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk/lock.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/backend/store.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/config.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/main.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/bridge/bridge.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/ipvlan/ipvlan.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/macvlan/macvlan.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/ptp/ptp.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/meta/flannel/flannel.go create mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/meta/tuning/tuning.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 119c66dc82..83b52305ce 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -5,14 +5,14 @@ "Packages": [ "./...", "github.com/appc/spec/actool", - "github.com/appc/cni/plugins/ipam/dhcp", - "github.com/appc/cni/plugins/ipam/host-local", - "github.com/appc/cni/plugins/main/bridge", - "github.com/appc/cni/plugins/main/ipvlan", - "github.com/appc/cni/plugins/main/macvlan", - "github.com/appc/cni/plugins/main/ptp", - "github.com/appc/cni/plugins/meta/flannel", - "github.com/appc/cni/plugins/meta/tuning", + "github.com/containernetworking/cni/plugins/ipam/dhcp", + "github.com/containernetworking/cni/plugins/ipam/host-local", + "github.com/containernetworking/cni/plugins/main/bridge", + "github.com/containernetworking/cni/plugins/main/ipvlan", + "github.com/containernetworking/cni/plugins/main/macvlan", + "github.com/containernetworking/cni/plugins/main/ptp", + "github.com/containernetworking/cni/plugins/meta/flannel", + "github.com/containernetworking/cni/plugins/meta/tuning", "github.com/appc/spec/ace", "github.com/golang/protobuf/protoc-gen-go" ], @@ -21,91 +21,6 @@ "ImportPath": "github.com/StackExchange/wmi", "Rev": "f3e2bae1e0cb5aef83e319133eabfee30013a4a5" }, - { - "ImportPath": "github.com/appc/cni/pkg/invoke", - "Comment": "v0.2.3", - "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" - }, - { - "ImportPath": "github.com/appc/cni/pkg/ip", - "Comment": "v0.2.3", - "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" - }, - { - "ImportPath": "github.com/appc/cni/pkg/ipam", - "Comment": "v0.2.3", - "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" - }, - { - "ImportPath": "github.com/appc/cni/pkg/ns", - "Comment": "v0.2.3", - "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" - }, - { - "ImportPath": "github.com/appc/cni/pkg/skel", - "Comment": "v0.2.3", - "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" - }, - { - "ImportPath": "github.com/appc/cni/pkg/types", - "Comment": "v0.2.3", - "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" - }, - { - "ImportPath": "github.com/appc/cni/pkg/utils", - "Comment": "v0.2.3", - "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" - }, - { - "ImportPath": "github.com/appc/cni/plugins/ipam/dhcp", - "Comment": "v0.2.3", - "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" - }, - { - "ImportPath": "github.com/appc/cni/plugins/ipam/host-local", - "Comment": "v0.2.3", - "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" - }, - { - "ImportPath": "github.com/appc/cni/plugins/ipam/host-local/backend", - "Comment": "v0.2.3", - "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" - }, - { - "ImportPath": "github.com/appc/cni/plugins/ipam/host-local/backend/disk", - "Comment": "v0.2.3", - "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" - }, - { - "ImportPath": "github.com/appc/cni/plugins/main/bridge", - "Comment": "v0.2.3", - "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" - }, - { - "ImportPath": "github.com/appc/cni/plugins/main/ipvlan", - "Comment": "v0.2.3", - "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" - }, - { - "ImportPath": "github.com/appc/cni/plugins/main/macvlan", - "Comment": "v0.2.3", - "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" - }, - { - "ImportPath": "github.com/appc/cni/plugins/main/ptp", - "Comment": "v0.2.3", - "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" - }, - { - "ImportPath": "github.com/appc/cni/plugins/meta/flannel", - "Comment": "v0.2.3", - "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" - }, - { - "ImportPath": "github.com/appc/cni/plugins/meta/tuning", - "Comment": "v0.2.3", - "Rev": "b634ff6bcd406a6f8ca9405b018787ef53d82dc2" - }, { "ImportPath": "github.com/appc/docker2aci/lib", "Comment": "v0.9.3", @@ -275,6 +190,11 @@ "Comment": "v0.3.0-rc3", "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" }, + { + "ImportPath": "github.com/containernetworking/cni/pkg/ipam", + "Comment": "v0.3.0-rc2-5-g35f3a09", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, { "ImportPath": "github.com/containernetworking/cni/pkg/ns", "Comment": "v0.3.0-rc3", @@ -290,6 +210,16 @@ "Comment": "v0.3.0-rc3", "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" }, + { + "ImportPath": "github.com/containernetworking/cni/pkg/skel", + "Comment": "v0.3.0-rc2-5-g35f3a09", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/pkg/testutils", + "Comment": "v0.3.0-rc2-5-g35f3a09", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, { "ImportPath": "github.com/containernetworking/cni/pkg/types", "Comment": "v0.3.0-rc3", @@ -355,6 +285,61 @@ "Comment": "v0.3.0-rc3", "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" }, + { + "ImportPath": "github.com/containernetworking/cni/pkg/utils/sysctl", + "Comment": "v0.3.0-rc2-5-g35f3a09", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/plugins/ipam/dhcp", + "Comment": "v0.3.0-rc2-5-g35f3a09", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/plugins/ipam/host-local", + "Comment": "v0.3.0-rc2-5-g35f3a09", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/plugins/ipam/host-local/backend", + "Comment": "v0.3.0-rc2-5-g35f3a09", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk", + "Comment": "v0.3.0-rc2-5-g35f3a09", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/plugins/main/bridge", + "Comment": "v0.3.0-rc2-5-g35f3a09", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/plugins/main/ipvlan", + "Comment": "v0.3.0-rc2-5-g35f3a09", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/plugins/main/macvlan", + "Comment": "v0.3.0-rc2-5-g35f3a09", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/plugins/main/ptp", + "Comment": "v0.3.0-rc2-5-g35f3a09", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/plugins/meta/flannel", + "Comment": "v0.3.0-rc2-5-g35f3a09", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, + { + "ImportPath": "github.com/containernetworking/cni/plugins/meta/tuning", + "Comment": "v0.3.0-rc2-5-g35f3a09", + "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" + }, { "ImportPath": "github.com/coreos/gexpect", "Comment": "v0.1.0", diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/args.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/args.go new file mode 100644 index 0000000000..be28ba621f --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/args.go @@ -0,0 +1,76 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package invoke + +import ( + "os" + "strings" +) + +type CNIArgs interface { + // For use with os/exec; i.e., return nil to inherit the + // environment from this process + AsEnv() []string +} + +type inherited struct{} + +var inheritArgsFromEnv inherited + +func (_ *inherited) AsEnv() []string { + return nil +} + +func ArgsFromEnv() CNIArgs { + return &inheritArgsFromEnv +} + +type Args struct { + Command string + ContainerID string + NetNS string + PluginArgs [][2]string + PluginArgsStr string + IfName string + Path string +} + +func (args *Args) AsEnv() []string { + env := os.Environ() + pluginArgsStr := args.PluginArgsStr + if pluginArgsStr == "" { + pluginArgsStr = stringify(args.PluginArgs) + } + + env = append(env, + "CNI_COMMAND="+args.Command, + "CNI_CONTAINERID="+args.ContainerID, + "CNI_NETNS="+args.NetNS, + "CNI_ARGS="+pluginArgsStr, + "CNI_IFNAME="+args.IfName, + "CNI_PATH="+args.Path) + return env +} + +// taken from rkt/networking/net_plugin.go +func stringify(pluginArgs [][2]string) string { + entries := make([]string, len(pluginArgs)) + + for i, kv := range pluginArgs { + entries[i] = strings.Join(kv[:], "=") + } + + return strings.Join(entries, ";") +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/delegate.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/delegate.go new file mode 100644 index 0000000000..ddf1d17274 --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/delegate.go @@ -0,0 +1,53 @@ +// Copyright 2016 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package invoke + +import ( + "fmt" + "os" + "strings" + + "github.com/containernetworking/cni/pkg/types" +) + +func DelegateAdd(delegatePlugin string, netconf []byte) (*types.Result, error) { + if os.Getenv("CNI_COMMAND") != "ADD" { + return nil, fmt.Errorf("CNI_COMMAND is not ADD") + } + + paths := strings.Split(os.Getenv("CNI_PATH"), ":") + + pluginPath, err := FindInPath(delegatePlugin, paths) + if err != nil { + return nil, err + } + + return ExecPluginWithResult(pluginPath, netconf, ArgsFromEnv()) +} + +func DelegateDel(delegatePlugin string, netconf []byte) error { + if os.Getenv("CNI_COMMAND") != "DEL" { + return fmt.Errorf("CNI_COMMAND is not DEL") + } + + paths := strings.Split(os.Getenv("CNI_PATH"), ":") + + pluginPath, err := FindInPath(delegatePlugin, paths) + if err != nil { + return err + } + + return ExecPluginWithoutResult(pluginPath, netconf, ArgsFromEnv()) +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/exec.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/exec.go new file mode 100644 index 0000000000..a85eede66a --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/exec.go @@ -0,0 +1,75 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package invoke + +import ( + "bytes" + "encoding/json" + "fmt" + "os" + "os/exec" + + "github.com/containernetworking/cni/pkg/types" +) + +func pluginErr(err error, output []byte) error { + if _, ok := err.(*exec.ExitError); ok { + emsg := types.Error{} + if perr := json.Unmarshal(output, &emsg); perr != nil { + return fmt.Errorf("netplugin failed but error parsing its diagnostic message %q: %v", string(output), perr) + } + details := "" + if emsg.Details != "" { + details = fmt.Sprintf("; %v", emsg.Details) + } + return fmt.Errorf("%v%v", emsg.Msg, details) + } + + return err +} + +func ExecPluginWithResult(pluginPath string, netconf []byte, args CNIArgs) (*types.Result, error) { + stdoutBytes, err := execPlugin(pluginPath, netconf, args) + if err != nil { + return nil, err + } + + res := &types.Result{} + err = json.Unmarshal(stdoutBytes, res) + return res, err +} + +func ExecPluginWithoutResult(pluginPath string, netconf []byte, args CNIArgs) error { + _, err := execPlugin(pluginPath, netconf, args) + return err +} + +func execPlugin(pluginPath string, netconf []byte, args CNIArgs) ([]byte, error) { + stdout := &bytes.Buffer{} + + c := exec.Cmd{ + Env: args.AsEnv(), + Path: pluginPath, + Args: []string{pluginPath}, + Stdin: bytes.NewBuffer(netconf), + Stdout: stdout, + Stderr: os.Stderr, + } + if err := c.Run(); err != nil { + return nil, pluginErr(err, stdout.Bytes()) + } + + return stdout.Bytes(), nil +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/find.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/find.go new file mode 100644 index 0000000000..3b03790711 --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/find.go @@ -0,0 +1,47 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package invoke + +import ( + "fmt" + "os" + "path/filepath" +) + +// FindInPath returns the full path of the plugin by searching in the provided path +func FindInPath(plugin string, paths []string) (string, error) { + if plugin == "" { + return "", fmt.Errorf("no plugin name provided") + } + + if len(paths) == 0 { + return "", fmt.Errorf("no paths provided") + } + + var fullpath string + for _, path := range paths { + full := filepath.Join(path, plugin) + if fi, err := os.Stat(full); err == nil && fi.Mode().IsRegular() { + fullpath = full + break + } + } + + if fullpath == "" { + return "", fmt.Errorf("failed to find plugin %q in path %s", plugin, paths) + } + + return fullpath, nil +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ipam/ipam.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ipam/ipam.go new file mode 100644 index 0000000000..d9fbff74c7 --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ipam/ipam.go @@ -0,0 +1,68 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ipam + +import ( + "fmt" + "os" + + "github.com/containernetworking/cni/pkg/invoke" + "github.com/containernetworking/cni/pkg/ip" + "github.com/containernetworking/cni/pkg/types" + + "github.com/vishvananda/netlink" +) + +func ExecAdd(plugin string, netconf []byte) (*types.Result, error) { + return invoke.DelegateAdd(plugin, netconf) +} + +func ExecDel(plugin string, netconf []byte) error { + return invoke.DelegateDel(plugin, netconf) +} + +// ConfigureIface takes the result of IPAM plugin and +// applies to the ifName interface +func ConfigureIface(ifName string, res *types.Result) error { + link, err := netlink.LinkByName(ifName) + if err != nil { + return fmt.Errorf("failed to lookup %q: %v", ifName, err) + } + + if err := netlink.LinkSetUp(link); err != nil { + return fmt.Errorf("failed to set %q UP: %v", ifName, err) + } + + // TODO(eyakubovich): IPv6 + addr := &netlink.Addr{IPNet: &res.IP4.IP, Label: ""} + if err = netlink.AddrAdd(link, addr); err != nil { + return fmt.Errorf("failed to add IP addr to %q: %v", ifName, err) + } + + for _, r := range res.IP4.Routes { + gw := r.GW + if gw == nil { + gw = res.IP4.Gateway + } + if err = ip.AddRoute(&r.Dst, gw, link); err != nil { + // we skip over duplicate routes as we assume the first one wins + if !os.IsExist(err) { + return fmt.Errorf("failed to add route '%v via %v dev %v': %v", r.Dst, gw, ifName, err) + } + } + } + + return nil +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/skel/skel.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/skel/skel.go new file mode 100644 index 0000000000..9cf03917b4 --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/skel/skel.go @@ -0,0 +1,161 @@ +// Copyright 2014 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package skel provides skeleton code for a CNI plugin. +// In particular, it implements argument parsing and validation. +package skel + +import ( + "fmt" + "io/ioutil" + "log" + "os" + + "github.com/containernetworking/cni/pkg/types" +) + +// CmdArgs captures all the arguments passed in to the plugin +// via both env vars and stdin +type CmdArgs struct { + ContainerID string + Netns string + IfName string + Args string + Path string + StdinData []byte +} + +type reqForCmdEntry map[string]bool + +// PluginMain is the "main" for a plugin. It accepts +// two callback functions for add and del commands. +func PluginMain(cmdAdd, cmdDel func(_ *CmdArgs) error) { + var cmd, contID, netns, ifName, args, path string + + vars := []struct { + name string + val *string + reqForCmd reqForCmdEntry + }{ + { + "CNI_COMMAND", + &cmd, + reqForCmdEntry{ + "ADD": true, + "DEL": true, + }, + }, + { + "CNI_CONTAINERID", + &contID, + reqForCmdEntry{ + "ADD": false, + "DEL": false, + }, + }, + { + "CNI_NETNS", + &netns, + reqForCmdEntry{ + "ADD": true, + "DEL": false, + }, + }, + { + "CNI_IFNAME", + &ifName, + reqForCmdEntry{ + "ADD": true, + "DEL": true, + }, + }, + { + "CNI_ARGS", + &args, + reqForCmdEntry{ + "ADD": false, + "DEL": false, + }, + }, + { + "CNI_PATH", + &path, + reqForCmdEntry{ + "ADD": true, + "DEL": true, + }, + }, + } + + argsMissing := false + for _, v := range vars { + *v.val = os.Getenv(v.name) + if v.reqForCmd[cmd] && *v.val == "" { + log.Printf("%v env variable missing", v.name) + argsMissing = true + } + } + + if argsMissing { + dieMsg("required env variables missing") + } + + stdinData, err := ioutil.ReadAll(os.Stdin) + if err != nil { + dieMsg("error reading from stdin: %v", err) + } + + cmdArgs := &CmdArgs{ + ContainerID: contID, + Netns: netns, + IfName: ifName, + Args: args, + Path: path, + StdinData: stdinData, + } + + switch cmd { + case "ADD": + err = cmdAdd(cmdArgs) + + case "DEL": + err = cmdDel(cmdArgs) + + default: + dieMsg("unknown CNI_COMMAND: %v", cmd) + } + + if err != nil { + if e, ok := err.(*types.Error); ok { + // don't wrap Error in Error + dieErr(e) + } + dieMsg(err.Error()) + } +} + +func dieMsg(f string, args ...interface{}) { + e := &types.Error{ + Code: 100, + Msg: fmt.Sprintf(f, args...), + } + dieErr(e) +} + +func dieErr(e *types.Error) { + if err := e.Print(); err != nil { + log.Print("Error writing error JSON to stdout: ", err) + } + os.Exit(1) +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/testutils/cmd.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/testutils/cmd.go new file mode 100644 index 0000000000..201b935f40 --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/testutils/cmd.go @@ -0,0 +1,77 @@ +// Copyright 2016 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package testutils + +import ( + "encoding/json" + "io/ioutil" + "os" + + "github.com/containernetworking/cni/pkg/types" +) + +func envCleanup() { + os.Unsetenv("CNI_COMMAND") + os.Unsetenv("CNI_PATH") + os.Unsetenv("CNI_NETNS") + os.Unsetenv("CNI_IFNAME") +} + +func CmdAddWithResult(cniNetns, cniIfname string, f func() error) (*types.Result, error) { + os.Setenv("CNI_COMMAND", "ADD") + os.Setenv("CNI_PATH", os.Getenv("PATH")) + os.Setenv("CNI_NETNS", cniNetns) + os.Setenv("CNI_IFNAME", cniIfname) + defer envCleanup() + + // Redirect stdout to capture plugin result + oldStdout := os.Stdout + r, w, err := os.Pipe() + if err != nil { + return nil, err + } + + os.Stdout = w + err = f() + w.Close() + if err != nil { + return nil, err + } + + // parse the result + out, err := ioutil.ReadAll(r) + os.Stdout = oldStdout + if err != nil { + return nil, err + } + + result := types.Result{} + err = json.Unmarshal(out, &result) + if err != nil { + return nil, err + } + + return &result, nil +} + +func CmdDelWithResult(cniNetns, cniIfname string, f func() error) error { + os.Setenv("CNI_COMMAND", "DEL") + os.Setenv("CNI_PATH", os.Getenv("PATH")) + os.Setenv("CNI_NETNS", cniNetns) + os.Setenv("CNI_IFNAME", cniIfname) + defer envCleanup() + + return f() +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/utils/sysctl/sysctl_linux.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/utils/sysctl/sysctl_linux.go new file mode 100644 index 0000000000..c0fba38290 --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/utils/sysctl/sysctl_linux.go @@ -0,0 +1,58 @@ +// Copyright 2016 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// build +linux + +package sysctl + +import ( + "fmt" + "io/ioutil" + "path/filepath" + "strings" +) + +// Sysctl provides a method to set/get values from /proc/sys - in linux systems +// new interface to set/get values of variables formerly handled by sysctl syscall +// If optional `params` have only one string value - this function will +// set this value into coresponding sysctl variable +func Sysctl(name string, params ...string) (string, error) { + if len(params) > 1 { + return "", fmt.Errorf("unexcepted additional parameters") + } else if len(params) == 1 { + return setSysctl(name, params[0]) + } + return getSysctl(name) +} + +func getSysctl(name string) (string, error) { + fullName := filepath.Join("/proc/sys", strings.Replace(name, ".", "/", -1)) + fullName = filepath.Clean(fullName) + data, err := ioutil.ReadFile(fullName) + if err != nil { + return "", err + } + + return string(data[:len(data)-1]), nil +} + +func setSysctl(name, value string) (string, error) { + fullName := filepath.Join("/proc/sys", strings.Replace(name, ".", "/", -1)) + fullName = filepath.Clean(fullName) + if err := ioutil.WriteFile(fullName, []byte(value), 0644); err != nil { + return "", err + } + + return getSysctl(name) +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/daemon.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/daemon.go new file mode 100644 index 0000000000..2386f9a9f4 --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/daemon.go @@ -0,0 +1,157 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "encoding/json" + "errors" + "fmt" + "log" + "net" + "net/http" + "net/rpc" + "os" + "path/filepath" + "runtime" + "sync" + + "github.com/containernetworking/cni/pkg/skel" + "github.com/containernetworking/cni/pkg/types" + "github.com/coreos/go-systemd/activation" +) + +const listenFdsStart = 3 +const resendCount = 3 + +var errNoMoreTries = errors.New("no more tries") + +type DHCP struct { + mux sync.Mutex + leases map[string]*DHCPLease +} + +func newDHCP() *DHCP { + return &DHCP{ + leases: make(map[string]*DHCPLease), + } +} + +// Allocate acquires an IP from a DHCP server for a specified container. +// The acquired lease will be maintained until Release() is called. +func (d *DHCP) Allocate(args *skel.CmdArgs, result *types.Result) error { + conf := types.NetConf{} + if err := json.Unmarshal(args.StdinData, &conf); err != nil { + return fmt.Errorf("error parsing netconf: %v", err) + } + + clientID := args.ContainerID + "/" + conf.Name + l, err := AcquireLease(clientID, args.Netns, args.IfName) + if err != nil { + return err + } + + ipn, err := l.IPNet() + if err != nil { + l.Stop() + return err + } + + d.setLease(args.ContainerID, conf.Name, l) + + result.IP4 = &types.IPConfig{ + IP: *ipn, + Gateway: l.Gateway(), + Routes: l.Routes(), + } + + return nil +} + +// Release stops maintenance of the lease acquired in Allocate() +// and sends a release msg to the DHCP server. +func (d *DHCP) Release(args *skel.CmdArgs, reply *struct{}) error { + conf := types.NetConf{} + if err := json.Unmarshal(args.StdinData, &conf); err != nil { + return fmt.Errorf("error parsing netconf: %v", err) + } + + if l := d.getLease(args.ContainerID, conf.Name); l != nil { + l.Stop() + return nil + } + + return fmt.Errorf("lease not found: %v/%v", args.ContainerID, conf.Name) +} + +func (d *DHCP) getLease(contID, netName string) *DHCPLease { + d.mux.Lock() + defer d.mux.Unlock() + + // TODO(eyakubovich): hash it to avoid collisions + l, ok := d.leases[contID+netName] + if !ok { + return nil + } + return l +} + +func (d *DHCP) setLease(contID, netName string, l *DHCPLease) { + d.mux.Lock() + defer d.mux.Unlock() + + // TODO(eyakubovich): hash it to avoid collisions + d.leases[contID+netName] = l +} + +func getListener() (net.Listener, error) { + l, err := activation.Listeners(true) + if err != nil { + return nil, err + } + + switch { + case len(l) == 0: + if err := os.MkdirAll(filepath.Dir(socketPath), 0700); err != nil { + return nil, err + } + return net.Listen("unix", socketPath) + + case len(l) == 1: + if l[0] == nil { + return nil, fmt.Errorf("LISTEN_FDS=1 but no FD found") + } + return l[0], nil + + default: + return nil, fmt.Errorf("Too many (%v) FDs passed through socket activation", len(l)) + } +} + +func runDaemon() { + // since other goroutines (on separate threads) will change namespaces, + // ensure the RPC server does not get scheduled onto those + runtime.LockOSThread() + + l, err := getListener() + if err != nil { + log.Printf("Error getting listener: %v", err) + return + } + + dhcp := newDHCP() + rpc.Register(dhcp) + rpc.HandleHTTP() + http.Serve(l, nil) +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/lease.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/lease.go new file mode 100644 index 0000000000..eb2b403130 --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/lease.go @@ -0,0 +1,337 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "fmt" + "log" + "math/rand" + "net" + "sync" + "time" + + "github.com/d2g/dhcp4" + "github.com/d2g/dhcp4client" + "github.com/vishvananda/netlink" + + "github.com/containernetworking/cni/pkg/ns" + "github.com/containernetworking/cni/pkg/types" +) + +// RFC 2131 suggests using exponential backoff, starting with 4sec +// and randomized to +/- 1sec +const resendDelay0 = 4 * time.Second +const resendDelayMax = 32 * time.Second + +const ( + leaseStateBound = iota + leaseStateRenewing + leaseStateRebinding +) + +// This implementation uses 1 OS thread per lease. This is because +// all the network operations have to be done in network namespace +// of the interface. This can be improved by switching to the proper +// namespace for network ops and using fewer threads. However, this +// needs to be done carefully as dhcp4client ops are blocking. + +type DHCPLease struct { + clientID string + ack *dhcp4.Packet + opts dhcp4.Options + link netlink.Link + renewalTime time.Time + rebindingTime time.Time + expireTime time.Time + stop chan struct{} + wg sync.WaitGroup +} + +// AcquireLease gets an DHCP lease and then maintains it in the background +// by periodically renewing it. The acquired lease can be released by +// calling DHCPLease.Stop() +func AcquireLease(clientID, netns, ifName string) (*DHCPLease, error) { + errCh := make(chan error, 1) + l := &DHCPLease{ + clientID: clientID, + stop: make(chan struct{}), + } + + log.Printf("%v: acquiring lease", clientID) + + l.wg.Add(1) + go func() { + errCh <- ns.WithNetNSPath(netns, func(_ ns.NetNS) error { + defer l.wg.Done() + + link, err := netlink.LinkByName(ifName) + if err != nil { + return fmt.Errorf("error looking up %q: %v", ifName, err) + } + + l.link = link + + if err = l.acquire(); err != nil { + return err + } + + log.Printf("%v: lease acquired, expiration is %v", l.clientID, l.expireTime) + + errCh <- nil + + l.maintain() + return nil + }) + }() + + if err := <-errCh; err != nil { + return nil, err + } + + return l, nil +} + +// Stop terminates the background task that maintains the lease +// and issues a DHCP Release +func (l *DHCPLease) Stop() { + close(l.stop) + l.wg.Wait() +} + +func (l *DHCPLease) acquire() error { + c, err := newDHCPClient(l.link) + if err != nil { + return err + } + defer c.Close() + + if (l.link.Attrs().Flags & net.FlagUp) != net.FlagUp { + log.Printf("Link %q down. Attempting to set up", l.link.Attrs().Name) + if err = netlink.LinkSetUp(l.link); err != nil { + return err + } + } + + pkt, err := backoffRetry(func() (*dhcp4.Packet, error) { + ok, ack, err := c.Request() + switch { + case err != nil: + return nil, err + case !ok: + return nil, fmt.Errorf("DHCP server NACK'd own offer") + default: + return &ack, nil + } + }) + if err != nil { + return err + } + + return l.commit(pkt) +} + +func (l *DHCPLease) commit(ack *dhcp4.Packet) error { + opts := ack.ParseOptions() + + leaseTime, err := parseLeaseTime(opts) + if err != nil { + return err + } + + rebindingTime, err := parseRebindingTime(opts) + if err != nil || rebindingTime > leaseTime { + // Per RFC 2131 Section 4.4.5, it should default to 85% of lease time + rebindingTime = leaseTime * 85 / 100 + } + + renewalTime, err := parseRenewalTime(opts) + if err != nil || renewalTime > rebindingTime { + // Per RFC 2131 Section 4.4.5, it should default to 50% of lease time + renewalTime = leaseTime / 2 + } + + now := time.Now() + l.expireTime = now.Add(leaseTime) + l.renewalTime = now.Add(renewalTime) + l.rebindingTime = now.Add(rebindingTime) + l.ack = ack + l.opts = opts + + return nil +} + +func (l *DHCPLease) maintain() { + state := leaseStateBound + + for { + var sleepDur time.Duration + + switch state { + case leaseStateBound: + sleepDur = l.renewalTime.Sub(time.Now()) + if sleepDur <= 0 { + log.Printf("%v: renewing lease", l.clientID) + state = leaseStateRenewing + continue + } + + case leaseStateRenewing: + if err := l.renew(); err != nil { + log.Printf("%v: %v", l.clientID, err) + + if time.Now().After(l.rebindingTime) { + log.Printf("%v: renawal time expired, rebinding", l.clientID) + state = leaseStateRebinding + } + } else { + log.Printf("%v: lease renewed, expiration is %v", l.clientID, l.expireTime) + state = leaseStateBound + } + + case leaseStateRebinding: + if err := l.acquire(); err != nil { + log.Printf("%v: %v", l.clientID, err) + + if time.Now().After(l.expireTime) { + log.Printf("%v: lease expired, bringing interface DOWN", l.clientID) + l.downIface() + return + } + } else { + log.Printf("%v: lease rebound, expiration is %v", l.clientID, l.expireTime) + state = leaseStateBound + } + } + + select { + case <-time.After(sleepDur): + + case <-l.stop: + if err := l.release(); err != nil { + log.Printf("%v: failed to release DHCP lease: %v", l.clientID, err) + } + return + } + } +} + +func (l *DHCPLease) downIface() { + if err := netlink.LinkSetDown(l.link); err != nil { + log.Printf("%v: failed to bring %v interface DOWN: %v", l.clientID, l.link.Attrs().Name, err) + } +} + +func (l *DHCPLease) renew() error { + c, err := newDHCPClient(l.link) + if err != nil { + return err + } + defer c.Close() + + pkt, err := backoffRetry(func() (*dhcp4.Packet, error) { + ok, ack, err := c.Renew(*l.ack) + switch { + case err != nil: + return nil, err + case !ok: + return nil, fmt.Errorf("DHCP server did not renew lease") + default: + return &ack, nil + } + }) + if err != nil { + return err + } + + l.commit(pkt) + return nil +} + +func (l *DHCPLease) release() error { + log.Printf("%v: releasing lease", l.clientID) + + c, err := newDHCPClient(l.link) + if err != nil { + return err + } + defer c.Close() + + if err = c.Release(*l.ack); err != nil { + return fmt.Errorf("failed to send DHCPRELEASE") + } + + return nil +} + +func (l *DHCPLease) IPNet() (*net.IPNet, error) { + mask := parseSubnetMask(l.opts) + if mask == nil { + return nil, fmt.Errorf("DHCP option Subnet Mask not found in DHCPACK") + } + + return &net.IPNet{ + IP: l.ack.YIAddr(), + Mask: mask, + }, nil +} + +func (l *DHCPLease) Gateway() net.IP { + return parseRouter(l.opts) +} + +func (l *DHCPLease) Routes() []types.Route { + routes := parseRoutes(l.opts) + return append(routes, parseCIDRRoutes(l.opts)...) +} + +// jitter returns a random value within [-span, span) range +func jitter(span time.Duration) time.Duration { + return time.Duration(float64(span) * (2.0*rand.Float64() - 1.0)) +} + +func backoffRetry(f func() (*dhcp4.Packet, error)) (*dhcp4.Packet, error) { + var baseDelay time.Duration = resendDelay0 + + for i := 0; i < resendCount; i++ { + pkt, err := f() + if err == nil { + return pkt, nil + } + + log.Print(err) + + time.Sleep(baseDelay + jitter(time.Second)) + + if baseDelay < resendDelayMax { + baseDelay *= 2 + } + } + + return nil, errNoMoreTries +} + +func newDHCPClient(link netlink.Link) (*dhcp4client.Client, error) { + pktsock, err := dhcp4client.NewPacketSock(link.Attrs().Index) + if err != nil { + return nil, err + } + + return dhcp4client.New( + dhcp4client.HardwareAddr(link.Attrs().HardwareAddr), + dhcp4client.Timeout(5*time.Second), + dhcp4client.Broadcast(false), + dhcp4client.Connection(pktsock), + ) +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/main.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/main.go new file mode 100644 index 0000000000..b537831506 --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/main.go @@ -0,0 +1,73 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "fmt" + "net/rpc" + "os" + "path/filepath" + + "github.com/containernetworking/cni/pkg/skel" + "github.com/containernetworking/cni/pkg/types" +) + +const socketPath = "/run/cni/dhcp.sock" + +func main() { + if len(os.Args) > 1 && os.Args[1] == "daemon" { + runDaemon() + } else { + skel.PluginMain(cmdAdd, cmdDel) + } +} + +func cmdAdd(args *skel.CmdArgs) error { + result := types.Result{} + if err := rpcCall("DHCP.Allocate", args, &result); err != nil { + return err + } + return result.Print() +} + +func cmdDel(args *skel.CmdArgs) error { + result := struct{}{} + if err := rpcCall("DHCP.Release", args, &result); err != nil { + return fmt.Errorf("error dialing DHCP daemon: %v", err) + } + return nil +} + +func rpcCall(method string, args *skel.CmdArgs, result interface{}) error { + client, err := rpc.DialHTTP("unix", socketPath) + if err != nil { + return fmt.Errorf("error dialing DHCP daemon: %v", err) + } + + // The daemon may be running under a different working dir + // so make sure the netns path is absolute. + netns, err := filepath.Abs(args.Netns) + if err != nil { + return fmt.Errorf("failed to make %q an absolute path: %v", args.Netns, err) + } + args.Netns = netns + + err = client.Call(method, args, result) + if err != nil { + return fmt.Errorf("error calling %v: %v", method, err) + } + + return nil +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/options.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/options.go new file mode 100644 index 0000000000..b11ec21d55 --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/options.go @@ -0,0 +1,139 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "encoding/binary" + "fmt" + "net" + "time" + + "github.com/containernetworking/cni/pkg/types" + "github.com/d2g/dhcp4" +) + +func parseRouter(opts dhcp4.Options) net.IP { + if opts, ok := opts[dhcp4.OptionRouter]; ok { + if len(opts) == 4 { + return net.IP(opts) + } + } + return nil +} + +func classfulSubnet(sn net.IP) net.IPNet { + return net.IPNet{ + IP: sn, + Mask: sn.DefaultMask(), + } +} + +func parseRoutes(opts dhcp4.Options) []types.Route { + // StaticRoutes format: pairs of: + // Dest = 4 bytes; Classful IP subnet + // Router = 4 bytes; IP address of router + + routes := []types.Route{} + if opt, ok := opts[dhcp4.OptionStaticRoute]; ok { + for len(opt) >= 8 { + sn := opt[0:4] + r := opt[4:8] + rt := types.Route{ + Dst: classfulSubnet(sn), + GW: r, + } + routes = append(routes, rt) + opt = opt[8:] + } + } + + return routes +} + +func parseCIDRRoutes(opts dhcp4.Options) []types.Route { + // See RFC4332 for format (http://tools.ietf.org/html/rfc3442) + + routes := []types.Route{} + if opt, ok := opts[dhcp4.OptionClasslessRouteFormat]; ok { + for len(opt) >= 5 { + width := int(opt[0]) + if width > 32 { + // error: can't have more than /32 + return nil + } + // network bits are compacted to avoid zeros + octets := 0 + if width > 0 { + octets = (width-1)/8 + 1 + } + + if len(opt) < 1+octets+4 { + // error: too short + return nil + } + + sn := make([]byte, 4) + copy(sn, opt[1:octets+1]) + + gw := net.IP(opt[octets+1 : octets+5]) + + rt := types.Route{ + Dst: net.IPNet{ + IP: net.IP(sn), + Mask: net.CIDRMask(width, 32), + }, + GW: gw, + } + routes = append(routes, rt) + + opt = opt[octets+5 : len(opt)] + } + } + return routes +} + +func parseSubnetMask(opts dhcp4.Options) net.IPMask { + mask, ok := opts[dhcp4.OptionSubnetMask] + if !ok { + return nil + } + + return net.IPMask(mask) +} + +func parseDuration(opts dhcp4.Options, code dhcp4.OptionCode, optName string) (time.Duration, error) { + val, ok := opts[code] + if !ok { + return 0, fmt.Errorf("option %v not found", optName) + } + if len(val) != 4 { + return 0, fmt.Errorf("option %v is not 4 bytes", optName) + } + + secs := binary.BigEndian.Uint32(val) + return time.Duration(secs) * time.Second, nil +} + +func parseLeaseTime(opts dhcp4.Options) (time.Duration, error) { + return parseDuration(opts, dhcp4.OptionIPAddressLeaseTime, "LeaseTime") +} + +func parseRenewalTime(opts dhcp4.Options) (time.Duration, error) { + return parseDuration(opts, dhcp4.OptionRenewalTimeValue, "RenewalTime") +} + +func parseRebindingTime(opts dhcp4.Options) (time.Duration, error) { + return parseDuration(opts, dhcp4.OptionRebindingTimeValue, "RebindingTime") +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/README.md b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/README.md new file mode 100644 index 0000000000..39e9ede217 --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/README.md @@ -0,0 +1,86 @@ +# host-local IP address manager + +host-local IPAM allocates IPv4 and IPv6 addresses out of a specified address range. + +## Usage + +### Obtain an IP + +Given the following network configuration: + +``` +{ + "name": "default", + "ipam": { + "type": "host-local", + "subnet": "203.0.113.0/24" + } +} +``` + +#### Using the command line interface + +``` +$ export CNI_COMMAND=ADD +$ export CNI_CONTAINERID=f81d4fae-7dec-11d0-a765-00a0c91e6bf6 +$ ./host-local < $conf +``` + +``` +{ + "ip4": { + "ip": "203.0.113.1/24" + } +} +``` + +## Backends + +By default ipmanager stores IP allocations on the local filesystem using the IP address as the file name and the ID as contents. For example: + +``` +$ ls /var/lib/cni/networks/default +``` +``` +203.0.113.1 203.0.113.2 +``` + +``` +$ cat /var/lib/cni/networks/default/203.0.113.1 +``` +``` +f81d4fae-7dec-11d0-a765-00a0c91e6bf6 +``` + +## Configuration Files + + +``` +{ + "name": "ipv6", + "ipam": { + "type": "host-local", + "subnet": "3ffe:ffff:0:01ff::/64", + "range-start": "3ffe:ffff:0:01ff::0010", + "range-end": "3ffe:ffff:0:01ff::0020", + "routes": [ + { "dst": "3ffe:ffff:0:01ff::1/64" } + ] + } +} +``` + +``` +{ + "name": "ipv4", + "ipam": { + "type": "host-local", + "subnet": "203.0.113.1/24", + "range-start": "203.0.113.10", + "range-end": "203.0.113.20", + "routes": [ + { "dst": "203.0.113.0/24" } + ] + } +} +``` diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/allocator.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/allocator.go new file mode 100644 index 0000000000..55a3ae6fa4 --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/allocator.go @@ -0,0 +1,165 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "fmt" + "net" + + "github.com/containernetworking/cni/pkg/ip" + "github.com/containernetworking/cni/pkg/types" + "github.com/containernetworking/cni/plugins/ipam/host-local/backend" +) + +type IPAllocator struct { + start net.IP + end net.IP + conf *IPAMConfig + store backend.Store +} + +func NewIPAllocator(conf *IPAMConfig, store backend.Store) (*IPAllocator, error) { + var ( + start net.IP + end net.IP + err error + ) + start, end, err = networkRange((*net.IPNet)(&conf.Subnet)) + if err != nil { + return nil, err + } + + // skip the .0 address + start = ip.NextIP(start) + + if conf.RangeStart != nil { + if err := validateRangeIP(conf.RangeStart, (*net.IPNet)(&conf.Subnet)); err != nil { + return nil, err + } + start = conf.RangeStart + } + if conf.RangeEnd != nil { + if err := validateRangeIP(conf.RangeEnd, (*net.IPNet)(&conf.Subnet)); err != nil { + return nil, err + } + // RangeEnd is inclusive + end = ip.NextIP(conf.RangeEnd) + } + + return &IPAllocator{start, end, conf, store}, nil +} + +func validateRangeIP(ip net.IP, ipnet *net.IPNet) error { + if !ipnet.Contains(ip) { + return fmt.Errorf("%s not in network: %s", ip, ipnet) + } + return nil +} + +// Returns newly allocated IP along with its config +func (a *IPAllocator) Get(id string) (*types.IPConfig, error) { + a.store.Lock() + defer a.store.Unlock() + + gw := a.conf.Gateway + if gw == nil { + gw = ip.NextIP(a.conf.Subnet.IP) + } + + var requestedIP net.IP + if a.conf.Args != nil { + requestedIP = a.conf.Args.IP + } + + if requestedIP != nil { + if gw != nil && gw.Equal(a.conf.Args.IP) { + return nil, fmt.Errorf("requested IP must differ gateway IP") + } + + subnet := net.IPNet{ + IP: a.conf.Subnet.IP, + Mask: a.conf.Subnet.Mask, + } + err := validateRangeIP(requestedIP, &subnet) + if err != nil { + return nil, err + } + + reserved, err := a.store.Reserve(id, requestedIP) + if err != nil { + return nil, err + } + + if reserved { + return &types.IPConfig{ + IP: net.IPNet{IP: requestedIP, Mask: a.conf.Subnet.Mask}, + Gateway: gw, + Routes: a.conf.Routes, + }, nil + } + return nil, fmt.Errorf("requested IP address %q is not available in network: %s", requestedIP, a.conf.Name) + } + + for cur := a.start; !cur.Equal(a.end); cur = ip.NextIP(cur) { + // don't allocate gateway IP + if gw != nil && cur.Equal(gw) { + continue + } + + reserved, err := a.store.Reserve(id, cur) + if err != nil { + return nil, err + } + if reserved { + return &types.IPConfig{ + IP: net.IPNet{IP: cur, Mask: a.conf.Subnet.Mask}, + Gateway: gw, + Routes: a.conf.Routes, + }, nil + } + } + return nil, fmt.Errorf("no IP addresses available in network: %s", a.conf.Name) +} + +// Releases all IPs allocated for the container with given ID +func (a *IPAllocator) Release(id string) error { + a.store.Lock() + defer a.store.Unlock() + + return a.store.ReleaseByID(id) +} + +func networkRange(ipnet *net.IPNet) (net.IP, net.IP, error) { + if ipnet.IP == nil { + return nil, nil, fmt.Errorf("missing field %q in IPAM configuration", "subnet") + } + ip := ipnet.IP.To4() + if ip == nil { + ip = ipnet.IP.To16() + if ip == nil { + return nil, nil, fmt.Errorf("IP not v4 nor v6") + } + } + + if len(ip) != len(ipnet.Mask) { + return nil, nil, fmt.Errorf("IPNet IP and Mask version mismatch") + } + + var end net.IP + for i := 0; i < len(ip); i++ { + end = append(end, ip[i]|^ipnet.Mask[i]) + } + return ipnet.IP, end, nil +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk/backend.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk/backend.go new file mode 100644 index 0000000000..88dc5e92bc --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk/backend.go @@ -0,0 +1,88 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package disk + +import ( + "io/ioutil" + "net" + "os" + "path/filepath" +) + +var defaultDataDir = "/var/lib/cni/networks" + +type Store struct { + FileLock + dataDir string +} + +func New(network string) (*Store, error) { + dir := filepath.Join(defaultDataDir, network) + if err := os.MkdirAll(dir, 0644); err != nil { + return nil, err + } + + lk, err := NewFileLock(dir) + if err != nil { + return nil, err + } + return &Store{*lk, dir}, nil +} + +func (s *Store) Reserve(id string, ip net.IP) (bool, error) { + fname := filepath.Join(s.dataDir, ip.String()) + f, err := os.OpenFile(fname, os.O_RDWR|os.O_EXCL|os.O_CREATE, 0644) + if os.IsExist(err) { + return false, nil + } + if err != nil { + return false, err + } + if _, err := f.WriteString(id); err != nil { + f.Close() + os.Remove(f.Name()) + return false, err + } + if err := f.Close(); err != nil { + os.Remove(f.Name()) + return false, err + } + return true, nil +} + +func (s *Store) Release(ip net.IP) error { + return os.Remove(filepath.Join(s.dataDir, ip.String())) +} + +// N.B. This function eats errors to be tolerant and +// release as much as possible +func (s *Store) ReleaseByID(id string) error { + err := filepath.Walk(s.dataDir, func(path string, info os.FileInfo, err error) error { + if err != nil || info.IsDir() { + return nil + } + data, err := ioutil.ReadFile(path) + if err != nil { + return nil + } + if string(data) == id { + if err := os.Remove(path); err != nil { + return nil + } + } + return nil + }) + return err +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk/lock.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk/lock.go new file mode 100644 index 0000000000..7241482515 --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk/lock.go @@ -0,0 +1,50 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package disk + +import ( + "os" + "syscall" +) + +// FileLock wraps os.File to be used as a lock using flock +type FileLock struct { + f *os.File +} + +// NewFileLock opens file/dir at path and returns unlocked FileLock object +func NewFileLock(path string) (*FileLock, error) { + f, err := os.Open(path) + if err != nil { + return nil, err + } + + return &FileLock{f}, nil +} + +// Close closes underlying file +func (l *FileLock) Close() error { + return l.f.Close() +} + +// Lock acquires an exclusive lock +func (l *FileLock) Lock() error { + return syscall.Flock(int(l.f.Fd()), syscall.LOCK_EX) +} + +// Unlock releases the lock +func (l *FileLock) Unlock() error { + return syscall.Flock(int(l.f.Fd()), syscall.LOCK_UN) +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/backend/store.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/backend/store.go new file mode 100644 index 0000000000..45a89b109c --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/backend/store.go @@ -0,0 +1,26 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package backend + +import "net" + +type Store interface { + Lock() error + Unlock() error + Close() error + Reserve(id string, ip net.IP) (bool, error) + Release(ip net.IP) error + ReleaseByID(id string) error +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/config.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/config.go new file mode 100644 index 0000000000..a0e493cd84 --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/config.go @@ -0,0 +1,70 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "encoding/json" + "fmt" + "net" + + "github.com/containernetworking/cni/pkg/types" +) + +// IPAMConfig represents the IP related network configuration. +type IPAMConfig struct { + Name string + Type string `json:"type"` + RangeStart net.IP `json:"rangeStart"` + RangeEnd net.IP `json:"rangeEnd"` + Subnet types.IPNet `json:"subnet"` + Gateway net.IP `json:"gateway"` + Routes []types.Route `json:"routes"` + Args *IPAMArgs `json:"-"` +} + +type IPAMArgs struct { + types.CommonArgs + IP net.IP `json:"ip,omitempty"` +} + +type Net struct { + Name string `json:"name"` + IPAM *IPAMConfig `json:"ipam"` +} + +// NewIPAMConfig creates a NetworkConfig from the given network name. +func LoadIPAMConfig(bytes []byte, args string) (*IPAMConfig, error) { + n := Net{} + if err := json.Unmarshal(bytes, &n); err != nil { + return nil, err + } + + if args != "" { + n.IPAM.Args = &IPAMArgs{} + err := types.LoadArgs(args, n.IPAM.Args) + if err != nil { + return nil, err + } + } + + if n.IPAM == nil { + return nil, fmt.Errorf("%q missing 'ipam' key") + } + + // Copy net name into IPAM so not to drag Net struct around + n.IPAM.Name = n.Name + + return n.IPAM, nil +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/main.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/main.go new file mode 100644 index 0000000000..d2f3c305a5 --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/main.go @@ -0,0 +1,74 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk" + + "github.com/containernetworking/cni/pkg/skel" + "github.com/containernetworking/cni/pkg/types" +) + +func main() { + skel.PluginMain(cmdAdd, cmdDel) +} + +func cmdAdd(args *skel.CmdArgs) error { + ipamConf, err := LoadIPAMConfig(args.StdinData, args.Args) + if err != nil { + return err + } + + store, err := disk.New(ipamConf.Name) + if err != nil { + return err + } + defer store.Close() + + allocator, err := NewIPAllocator(ipamConf, store) + if err != nil { + return err + } + + ipConf, err := allocator.Get(args.ContainerID) + if err != nil { + return err + } + + r := &types.Result{ + IP4: ipConf, + } + return r.Print() +} + +func cmdDel(args *skel.CmdArgs) error { + ipamConf, err := LoadIPAMConfig(args.StdinData, args.Args) + if err != nil { + return err + } + + store, err := disk.New(ipamConf.Name) + if err != nil { + return err + } + defer store.Close() + + allocator, err := NewIPAllocator(ipamConf, store) + if err != nil { + return err + } + + return allocator.Release(args.ContainerID) +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/bridge/bridge.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/bridge/bridge.go new file mode 100644 index 0000000000..d4fc89c3aa --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/bridge/bridge.go @@ -0,0 +1,319 @@ +// Copyright 2014 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "encoding/json" + "errors" + "fmt" + "net" + "runtime" + "syscall" + + "github.com/containernetworking/cni/pkg/ip" + "github.com/containernetworking/cni/pkg/ipam" + "github.com/containernetworking/cni/pkg/ns" + "github.com/containernetworking/cni/pkg/skel" + "github.com/containernetworking/cni/pkg/types" + "github.com/containernetworking/cni/pkg/utils" + "github.com/vishvananda/netlink" +) + +const defaultBrName = "cni0" + +type NetConf struct { + types.NetConf + BrName string `json:"bridge"` + IsGW bool `json:"isGateway"` + IsDefaultGW bool `json:"isDefaultGateway"` + IPMasq bool `json:"ipMasq"` + MTU int `json:"mtu"` + HairpinMode bool `json:"hairpinMode"` +} + +func init() { + // this ensures that main runs only on main thread (thread group leader). + // since namespace ops (unshare, setns) are done for a single thread, we + // must ensure that the goroutine does not jump from OS thread to thread + runtime.LockOSThread() +} + +func loadNetConf(bytes []byte) (*NetConf, error) { + n := &NetConf{ + BrName: defaultBrName, + } + if err := json.Unmarshal(bytes, n); err != nil { + return nil, fmt.Errorf("failed to load netconf: %v", err) + } + return n, nil +} + +func ensureBridgeAddr(br *netlink.Bridge, ipn *net.IPNet) error { + addrs, err := netlink.AddrList(br, syscall.AF_INET) + if err != nil && err != syscall.ENOENT { + return fmt.Errorf("could not get list of IP addresses: %v", err) + } + + // if there're no addresses on the bridge, it's ok -- we'll add one + if len(addrs) > 0 { + ipnStr := ipn.String() + for _, a := range addrs { + // string comp is actually easiest for doing IPNet comps + if a.IPNet.String() == ipnStr { + return nil + } + } + return fmt.Errorf("%q already has an IP address different from %v", br.Name, ipn.String()) + } + + addr := &netlink.Addr{IPNet: ipn, Label: ""} + if err := netlink.AddrAdd(br, addr); err != nil { + return fmt.Errorf("could not add IP address to %q: %v", br.Name, err) + } + return nil +} + +func bridgeByName(name string) (*netlink.Bridge, error) { + l, err := netlink.LinkByName(name) + if err != nil { + return nil, fmt.Errorf("could not lookup %q: %v", name, err) + } + br, ok := l.(*netlink.Bridge) + if !ok { + return nil, fmt.Errorf("%q already exists but is not a bridge", name) + } + return br, nil +} + +func ensureBridge(brName string, mtu int) (*netlink.Bridge, error) { + br := &netlink.Bridge{ + LinkAttrs: netlink.LinkAttrs{ + Name: brName, + MTU: mtu, + // Let kernel use default txqueuelen; leaving it unset + // means 0, and a zero-length TX queue messes up FIFO + // traffic shapers which use TX queue length as the + // default packet limit + TxQLen: -1, + }, + } + + if err := netlink.LinkAdd(br); err != nil { + if err != syscall.EEXIST { + return nil, fmt.Errorf("could not add %q: %v", brName, err) + } + + // it's ok if the device already exists as long as config is similar + br, err = bridgeByName(brName) + if err != nil { + return nil, err + } + } + + if err := netlink.LinkSetUp(br); err != nil { + return nil, err + } + + return br, nil +} + +func setupVeth(netns ns.NetNS, br *netlink.Bridge, ifName string, mtu int, hairpinMode bool) error { + var hostVethName string + + err := netns.Do(func(hostNS ns.NetNS) error { + // create the veth pair in the container and move host end into host netns + hostVeth, _, err := ip.SetupVeth(ifName, mtu, hostNS) + if err != nil { + return err + } + + hostVethName = hostVeth.Attrs().Name + return nil + }) + if err != nil { + return err + } + + // need to lookup hostVeth again as its index has changed during ns move + hostVeth, err := netlink.LinkByName(hostVethName) + if err != nil { + return fmt.Errorf("failed to lookup %q: %v", hostVethName, err) + } + + // connect host veth end to the bridge + if err = netlink.LinkSetMaster(hostVeth, br); err != nil { + return fmt.Errorf("failed to connect %q to bridge %v: %v", hostVethName, br.Attrs().Name, err) + } + + // set hairpin mode + if err = netlink.LinkSetHairpin(hostVeth, hairpinMode); err != nil { + return fmt.Errorf("failed to setup hairpin mode for %v: %v", hostVethName, err) + } + + return nil +} + +func calcGatewayIP(ipn *net.IPNet) net.IP { + nid := ipn.IP.Mask(ipn.Mask) + return ip.NextIP(nid) +} + +func setupBridge(n *NetConf) (*netlink.Bridge, error) { + // create bridge if necessary + br, err := ensureBridge(n.BrName, n.MTU) + if err != nil { + return nil, fmt.Errorf("failed to create bridge %q: %v", n.BrName, err) + } + + return br, nil +} + +func cmdAdd(args *skel.CmdArgs) error { + n, err := loadNetConf(args.StdinData) + if err != nil { + return err + } + + if n.IsDefaultGW { + n.IsGW = true + } + + br, err := setupBridge(n) + if err != nil { + return err + } + + netns, err := ns.GetNS(args.Netns) + if err != nil { + return fmt.Errorf("failed to open netns %q: %v", args.Netns, err) + } + defer netns.Close() + + if err = setupVeth(netns, br, args.IfName, n.MTU, n.HairpinMode); err != nil { + return err + } + + // run the IPAM plugin and get back the config to apply + result, err := ipam.ExecAdd(n.IPAM.Type, args.StdinData) + if err != nil { + return err + } + + // TODO: make this optional when IPv6 is supported + if result.IP4 == nil { + return errors.New("IPAM plugin returned missing IPv4 config") + } + + if result.IP4.Gateway == nil && n.IsGW { + result.IP4.Gateway = calcGatewayIP(&result.IP4.IP) + } + + if err := netns.Do(func(_ ns.NetNS) error { + // set the default gateway if requested + if n.IsDefaultGW { + _, defaultNet, err := net.ParseCIDR("0.0.0.0/0") + if err != nil { + return err + } + + for _, route := range result.IP4.Routes { + if defaultNet.String() == route.Dst.String() { + if route.GW != nil && !route.GW.Equal(result.IP4.Gateway) { + return fmt.Errorf( + "isDefaultGateway ineffective because IPAM sets default route via %q", + route.GW, + ) + } + } + } + + result.IP4.Routes = append( + result.IP4.Routes, + types.Route{Dst: *defaultNet, GW: result.IP4.Gateway}, + ) + + // TODO: IPV6 + } + + return ipam.ConfigureIface(args.IfName, result) + }); err != nil { + return err + } + + if n.IsGW { + gwn := &net.IPNet{ + IP: result.IP4.Gateway, + Mask: result.IP4.IP.Mask, + } + + if err = ensureBridgeAddr(br, gwn); err != nil { + return err + } + + if err := ip.EnableIP4Forward(); err != nil { + return fmt.Errorf("failed to enable forwarding: %v", err) + } + } + + if n.IPMasq { + chain := utils.FormatChainName(n.Name, args.ContainerID) + comment := utils.FormatComment(n.Name, args.ContainerID) + if err = ip.SetupIPMasq(ip.Network(&result.IP4.IP), chain, comment); err != nil { + return err + } + } + + result.DNS = n.DNS + return result.Print() +} + +func cmdDel(args *skel.CmdArgs) error { + n, err := loadNetConf(args.StdinData) + if err != nil { + return err + } + + if err := ipam.ExecDel(n.IPAM.Type, args.StdinData); err != nil { + return err + } + + if args.Netns == "" { + return nil + } + + var ipn *net.IPNet + err = ns.WithNetNSPath(args.Netns, func(_ ns.NetNS) error { + var err error + ipn, err = ip.DelLinkByNameAddr(args.IfName, netlink.FAMILY_V4) + return err + }) + if err != nil { + return err + } + + if n.IPMasq { + chain := utils.FormatChainName(n.Name, args.ContainerID) + comment := utils.FormatComment(n.Name, args.ContainerID) + if err = ip.TeardownIPMasq(ipn, chain, comment); err != nil { + return err + } + } + + return nil +} + +func main() { + skel.PluginMain(cmdAdd, cmdDel) +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/ipvlan/ipvlan.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/ipvlan/ipvlan.go new file mode 100644 index 0000000000..d7cfc39f4e --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/ipvlan/ipvlan.go @@ -0,0 +1,175 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "encoding/json" + "errors" + "fmt" + "runtime" + + "github.com/containernetworking/cni/pkg/ip" + "github.com/containernetworking/cni/pkg/ipam" + "github.com/containernetworking/cni/pkg/ns" + "github.com/containernetworking/cni/pkg/skel" + "github.com/containernetworking/cni/pkg/types" + "github.com/vishvananda/netlink" +) + +type NetConf struct { + types.NetConf + Master string `json:"master"` + Mode string `json:"mode"` + MTU int `json:"mtu"` +} + +func init() { + // this ensures that main runs only on main thread (thread group leader). + // since namespace ops (unshare, setns) are done for a single thread, we + // must ensure that the goroutine does not jump from OS thread to thread + runtime.LockOSThread() +} + +func loadConf(bytes []byte) (*NetConf, error) { + n := &NetConf{} + if err := json.Unmarshal(bytes, n); err != nil { + return nil, fmt.Errorf("failed to load netconf: %v", err) + } + if n.Master == "" { + return nil, fmt.Errorf(`"master" field is required. It specifies the host interface name to virtualize`) + } + return n, nil +} + +func modeFromString(s string) (netlink.IPVlanMode, error) { + switch s { + case "", "l2": + return netlink.IPVLAN_MODE_L2, nil + case "l3": + return netlink.IPVLAN_MODE_L3, nil + default: + return 0, fmt.Errorf("unknown ipvlan mode: %q", s) + } +} + +func createIpvlan(conf *NetConf, ifName string, netns ns.NetNS) error { + mode, err := modeFromString(conf.Mode) + if err != nil { + return err + } + + m, err := netlink.LinkByName(conf.Master) + if err != nil { + return fmt.Errorf("failed to lookup master %q: %v", conf.Master, err) + } + + // due to kernel bug we have to create with tmpname or it might + // collide with the name on the host and error out + tmpName, err := ip.RandomVethName() + if err != nil { + return err + } + + mv := &netlink.IPVlan{ + LinkAttrs: netlink.LinkAttrs{ + MTU: conf.MTU, + Name: tmpName, + ParentIndex: m.Attrs().Index, + Namespace: netlink.NsFd(int(netns.Fd())), + }, + Mode: mode, + } + + if err := netlink.LinkAdd(mv); err != nil { + return fmt.Errorf("failed to create ipvlan: %v", err) + } + + return netns.Do(func(_ ns.NetNS) error { + err := renameLink(tmpName, ifName) + if err != nil { + return fmt.Errorf("failed to rename ipvlan to %q: %v", ifName, err) + } + return nil + }) +} + +func cmdAdd(args *skel.CmdArgs) error { + n, err := loadConf(args.StdinData) + if err != nil { + return err + } + + netns, err := ns.GetNS(args.Netns) + if err != nil { + return fmt.Errorf("failed to open netns %q: %v", args.Netns, err) + } + defer netns.Close() + + if err = createIpvlan(n, args.IfName, netns); err != nil { + return err + } + + // run the IPAM plugin and get back the config to apply + result, err := ipam.ExecAdd(n.IPAM.Type, args.StdinData) + if err != nil { + return err + } + if result.IP4 == nil { + return errors.New("IPAM plugin returned missing IPv4 config") + } + + err = netns.Do(func(_ ns.NetNS) error { + return ipam.ConfigureIface(args.IfName, result) + }) + if err != nil { + return err + } + + result.DNS = n.DNS + return result.Print() +} + +func cmdDel(args *skel.CmdArgs) error { + n, err := loadConf(args.StdinData) + if err != nil { + return err + } + + err = ipam.ExecDel(n.IPAM.Type, args.StdinData) + if err != nil { + return err + } + + if args.Netns == "" { + return nil + } + + return ns.WithNetNSPath(args.Netns, func(_ ns.NetNS) error { + return ip.DelLinkByName(args.IfName) + }) +} + +func renameLink(curName, newName string) error { + link, err := netlink.LinkByName(curName) + if err != nil { + return err + } + + return netlink.LinkSetName(link, newName) +} + +func main() { + skel.PluginMain(cmdAdd, cmdDel) +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/macvlan/macvlan.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/macvlan/macvlan.go new file mode 100644 index 0000000000..7739d7b8eb --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/macvlan/macvlan.go @@ -0,0 +1,193 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "encoding/json" + "errors" + "fmt" + "runtime" + + "github.com/containernetworking/cni/pkg/ip" + "github.com/containernetworking/cni/pkg/ipam" + "github.com/containernetworking/cni/pkg/ns" + "github.com/containernetworking/cni/pkg/skel" + "github.com/containernetworking/cni/pkg/types" + "github.com/containernetworking/cni/pkg/utils/sysctl" + "github.com/vishvananda/netlink" +) + +const ( + IPv4InterfaceArpProxySysctlTemplate = "net.ipv4.conf.%s.proxy_arp" +) + +type NetConf struct { + types.NetConf + Master string `json:"master"` + Mode string `json:"mode"` + MTU int `json:"mtu"` +} + +func init() { + // this ensures that main runs only on main thread (thread group leader). + // since namespace ops (unshare, setns) are done for a single thread, we + // must ensure that the goroutine does not jump from OS thread to thread + runtime.LockOSThread() +} + +func loadConf(bytes []byte) (*NetConf, error) { + n := &NetConf{} + if err := json.Unmarshal(bytes, n); err != nil { + return nil, fmt.Errorf("failed to load netconf: %v", err) + } + if n.Master == "" { + return nil, fmt.Errorf(`"master" field is required. It specifies the host interface name to virtualize`) + } + return n, nil +} + +func modeFromString(s string) (netlink.MacvlanMode, error) { + switch s { + case "", "bridge": + return netlink.MACVLAN_MODE_BRIDGE, nil + case "private": + return netlink.MACVLAN_MODE_PRIVATE, nil + case "vepa": + return netlink.MACVLAN_MODE_VEPA, nil + case "passthru": + return netlink.MACVLAN_MODE_PASSTHRU, nil + default: + return 0, fmt.Errorf("unknown macvlan mode: %q", s) + } +} + +func createMacvlan(conf *NetConf, ifName string, netns ns.NetNS) error { + mode, err := modeFromString(conf.Mode) + if err != nil { + return err + } + + m, err := netlink.LinkByName(conf.Master) + if err != nil { + return fmt.Errorf("failed to lookup master %q: %v", conf.Master, err) + } + + // due to kernel bug we have to create with tmpName or it might + // collide with the name on the host and error out + tmpName, err := ip.RandomVethName() + if err != nil { + return err + } + + mv := &netlink.Macvlan{ + LinkAttrs: netlink.LinkAttrs{ + MTU: conf.MTU, + Name: tmpName, + ParentIndex: m.Attrs().Index, + Namespace: netlink.NsFd(int(netns.Fd())), + }, + Mode: mode, + } + + if err := netlink.LinkAdd(mv); err != nil { + return fmt.Errorf("failed to create macvlan: %v", err) + } + + return netns.Do(func(_ ns.NetNS) error { + // TODO: duplicate following lines for ipv6 support, when it will be added in other places + ipv4SysctlValueName := fmt.Sprintf(IPv4InterfaceArpProxySysctlTemplate, tmpName) + if _, err := sysctl.Sysctl(ipv4SysctlValueName, "1"); err != nil { + // remove the newly added link and ignore errors, because we already are in a failed state + _ = netlink.LinkDel(mv) + return fmt.Errorf("failed to set proxy_arp on newly added interface %q: %v", tmpName, err) + } + + err := renameLink(tmpName, ifName) + if err != nil { + _ = netlink.LinkDel(mv) + return fmt.Errorf("failed to rename macvlan to %q: %v", ifName, err) + } + return nil + }) +} + +func cmdAdd(args *skel.CmdArgs) error { + n, err := loadConf(args.StdinData) + if err != nil { + return err + } + + netns, err := ns.GetNS(args.Netns) + if err != nil { + return fmt.Errorf("failed to open netns %q: %v", netns, err) + } + defer netns.Close() + + if err = createMacvlan(n, args.IfName, netns); err != nil { + return err + } + + // run the IPAM plugin and get back the config to apply + result, err := ipam.ExecAdd(n.IPAM.Type, args.StdinData) + if err != nil { + return err + } + if result.IP4 == nil { + return errors.New("IPAM plugin returned missing IPv4 config") + } + + err = netns.Do(func(_ ns.NetNS) error { + return ipam.ConfigureIface(args.IfName, result) + }) + if err != nil { + return err + } + + result.DNS = n.DNS + return result.Print() +} + +func cmdDel(args *skel.CmdArgs) error { + n, err := loadConf(args.StdinData) + if err != nil { + return err + } + + err = ipam.ExecDel(n.IPAM.Type, args.StdinData) + if err != nil { + return err + } + + if args.Netns == "" { + return nil + } + + return ns.WithNetNSPath(args.Netns, func(_ ns.NetNS) error { + return ip.DelLinkByName(args.IfName) + }) +} + +func renameLink(curName, newName string) error { + link, err := netlink.LinkByName(curName) + if err != nil { + return err + } + + return netlink.LinkSetName(link, newName) +} + +func main() { + skel.PluginMain(cmdAdd, cmdDel) +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/ptp/ptp.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/ptp/ptp.go new file mode 100644 index 0000000000..aa695e39e2 --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/ptp/ptp.go @@ -0,0 +1,229 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "encoding/json" + "errors" + "fmt" + "net" + "os" + "runtime" + + "github.com/vishvananda/netlink" + + "github.com/containernetworking/cni/pkg/ip" + "github.com/containernetworking/cni/pkg/ipam" + "github.com/containernetworking/cni/pkg/ns" + "github.com/containernetworking/cni/pkg/skel" + "github.com/containernetworking/cni/pkg/types" + "github.com/containernetworking/cni/pkg/utils" +) + +func init() { + // this ensures that main runs only on main thread (thread group leader). + // since namespace ops (unshare, setns) are done for a single thread, we + // must ensure that the goroutine does not jump from OS thread to thread + runtime.LockOSThread() +} + +type NetConf struct { + types.NetConf + IPMasq bool `json:"ipMasq"` + MTU int `json:"mtu"` +} + +func setupContainerVeth(netns, ifName string, mtu int, pr *types.Result) (string, error) { + // The IPAM result will be something like IP=192.168.3.5/24, GW=192.168.3.1. + // What we want is really a point-to-point link but veth does not support IFF_POINTOPONT. + // Next best thing would be to let it ARP but set interface to 192.168.3.5/32 and + // add a route like "192.168.3.0/24 via 192.168.3.1 dev $ifName". + // Unfortunately that won't work as the GW will be outside the interface's subnet. + + // Our solution is to configure the interface with 192.168.3.5/24, then delete the + // "192.168.3.0/24 dev $ifName" route that was automatically added. Then we add + // "192.168.3.1/32 dev $ifName" and "192.168.3.0/24 via 192.168.3.1 dev $ifName". + // In other words we force all traffic to ARP via the gateway except for GW itself. + + var hostVethName string + err := ns.WithNetNSPath(netns, func(hostNS ns.NetNS) error { + hostVeth, _, err := ip.SetupVeth(ifName, mtu, hostNS) + if err != nil { + return err + } + + if err = ipam.ConfigureIface(ifName, pr); err != nil { + return err + } + + contVeth, err := netlink.LinkByName(ifName) + if err != nil { + return fmt.Errorf("failed to look up %q: %v", ifName, err) + } + + // Delete the route that was automatically added + route := netlink.Route{ + LinkIndex: contVeth.Attrs().Index, + Dst: &net.IPNet{ + IP: pr.IP4.IP.IP.Mask(pr.IP4.IP.Mask), + Mask: pr.IP4.IP.Mask, + }, + Scope: netlink.SCOPE_NOWHERE, + } + + if err := netlink.RouteDel(&route); err != nil { + return fmt.Errorf("failed to delete route %v: %v", route, err) + } + + for _, r := range []netlink.Route{ + netlink.Route{ + LinkIndex: contVeth.Attrs().Index, + Dst: &net.IPNet{ + IP: pr.IP4.Gateway, + Mask: net.CIDRMask(32, 32), + }, + Scope: netlink.SCOPE_LINK, + Src: pr.IP4.IP.IP, + }, + netlink.Route{ + LinkIndex: contVeth.Attrs().Index, + Dst: &net.IPNet{ + IP: pr.IP4.IP.IP.Mask(pr.IP4.IP.Mask), + Mask: pr.IP4.IP.Mask, + }, + Scope: netlink.SCOPE_UNIVERSE, + Gw: pr.IP4.Gateway, + Src: pr.IP4.IP.IP, + }, + } { + if err := netlink.RouteAdd(&r); err != nil { + return fmt.Errorf("failed to add route %v: %v", r, err) + } + } + + hostVethName = hostVeth.Attrs().Name + + return nil + }) + return hostVethName, err +} + +func setupHostVeth(vethName string, ipConf *types.IPConfig) error { + // hostVeth moved namespaces and may have a new ifindex + veth, err := netlink.LinkByName(vethName) + if err != nil { + return fmt.Errorf("failed to lookup %q: %v", vethName, err) + } + + // TODO(eyakubovich): IPv6 + ipn := &net.IPNet{ + IP: ipConf.Gateway, + Mask: net.CIDRMask(32, 32), + } + addr := &netlink.Addr{IPNet: ipn, Label: ""} + if err = netlink.AddrAdd(veth, addr); err != nil { + return fmt.Errorf("failed to add IP addr (%#v) to veth: %v", ipn, err) + } + + ipn = &net.IPNet{ + IP: ipConf.IP.IP, + Mask: net.CIDRMask(32, 32), + } + // dst happens to be the same as IP/net of host veth + if err = ip.AddHostRoute(ipn, nil, veth); err != nil && !os.IsExist(err) { + return fmt.Errorf("failed to add route on host: %v", err) + } + + return nil +} + +func cmdAdd(args *skel.CmdArgs) error { + conf := NetConf{} + if err := json.Unmarshal(args.StdinData, &conf); err != nil { + return fmt.Errorf("failed to load netconf: %v", err) + } + + if err := ip.EnableIP4Forward(); err != nil { + return fmt.Errorf("failed to enable forwarding: %v", err) + } + + // run the IPAM plugin and get back the config to apply + result, err := ipam.ExecAdd(conf.IPAM.Type, args.StdinData) + if err != nil { + return err + } + if result.IP4 == nil { + return errors.New("IPAM plugin returned missing IPv4 config") + } + + hostVethName, err := setupContainerVeth(args.Netns, args.IfName, conf.MTU, result) + if err != nil { + return err + } + + if err = setupHostVeth(hostVethName, result.IP4); err != nil { + return err + } + + if conf.IPMasq { + chain := utils.FormatChainName(conf.Name, args.ContainerID) + comment := utils.FormatComment(conf.Name, args.ContainerID) + if err = ip.SetupIPMasq(&result.IP4.IP, chain, comment); err != nil { + return err + } + } + + result.DNS = conf.DNS + return result.Print() +} + +func cmdDel(args *skel.CmdArgs) error { + conf := NetConf{} + if err := json.Unmarshal(args.StdinData, &conf); err != nil { + return fmt.Errorf("failed to load netconf: %v", err) + } + + if err := ipam.ExecDel(conf.IPAM.Type, args.StdinData); err != nil { + return err + } + + if args.Netns == "" { + return nil + } + + var ipn *net.IPNet + err := ns.WithNetNSPath(args.Netns, func(_ ns.NetNS) error { + var err error + ipn, err = ip.DelLinkByNameAddr(args.IfName, netlink.FAMILY_V4) + return err + }) + if err != nil { + return err + } + + if conf.IPMasq { + chain := utils.FormatChainName(conf.Name, args.ContainerID) + comment := utils.FormatComment(conf.Name, args.ContainerID) + if err = ip.TeardownIPMasq(ipn, chain, comment); err != nil { + return err + } + } + + return nil +} + +func main() { + skel.PluginMain(cmdAdd, cmdDel) +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/meta/flannel/flannel.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/meta/flannel/flannel.go new file mode 100644 index 0000000000..096fe6d677 --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/meta/flannel/flannel.go @@ -0,0 +1,253 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This is a "meta-plugin". It reads in its own netconf, combines it with +// the data from flannel generated subnet file and then invokes a plugin +// like bridge or ipvlan to do the real work. + +package main + +import ( + "bufio" + "encoding/json" + "fmt" + "io/ioutil" + "net" + "os" + "path/filepath" + "strconv" + "strings" + + "github.com/containernetworking/cni/pkg/invoke" + "github.com/containernetworking/cni/pkg/skel" + "github.com/containernetworking/cni/pkg/types" +) + +const ( + defaultSubnetFile = "/run/flannel/subnet.env" + stateDir = "/var/lib/cni/flannel" +) + +type NetConf struct { + types.NetConf + SubnetFile string `json:"subnetFile"` + Delegate map[string]interface{} `json:"delegate"` +} + +type subnetEnv struct { + nw *net.IPNet + sn *net.IPNet + mtu *uint + ipmasq *bool +} + +func (se *subnetEnv) missing() string { + m := []string{} + + if se.nw == nil { + m = append(m, "FLANNEL_NETWORK") + } + if se.sn == nil { + m = append(m, "FLANNEL_SUBNET") + } + if se.mtu == nil { + m = append(m, "FLANNEL_MTU") + } + if se.ipmasq == nil { + m = append(m, "FLANNEL_IPMASQ") + } + return strings.Join(m, ", ") +} + +func loadFlannelNetConf(bytes []byte) (*NetConf, error) { + n := &NetConf{ + SubnetFile: defaultSubnetFile, + } + if err := json.Unmarshal(bytes, n); err != nil { + return nil, fmt.Errorf("failed to load netconf: %v", err) + } + return n, nil +} + +func loadFlannelSubnetEnv(fn string) (*subnetEnv, error) { + f, err := os.Open(fn) + if err != nil { + return nil, err + } + defer f.Close() + + se := &subnetEnv{} + + s := bufio.NewScanner(f) + for s.Scan() { + parts := strings.SplitN(s.Text(), "=", 2) + switch parts[0] { + case "FLANNEL_NETWORK": + _, se.nw, err = net.ParseCIDR(parts[1]) + if err != nil { + return nil, err + } + + case "FLANNEL_SUBNET": + _, se.sn, err = net.ParseCIDR(parts[1]) + if err != nil { + return nil, err + } + + case "FLANNEL_MTU": + mtu, err := strconv.ParseUint(parts[1], 10, 32) + if err != nil { + return nil, err + } + se.mtu = new(uint) + *se.mtu = uint(mtu) + + case "FLANNEL_IPMASQ": + ipmasq := parts[1] == "true" + se.ipmasq = &ipmasq + } + } + if err := s.Err(); err != nil { + return nil, err + } + + if m := se.missing(); m != "" { + return nil, fmt.Errorf("%v is missing %v", fn, m) + } + + return se, nil +} + +func saveScratchNetConf(containerID string, netconf []byte) error { + if err := os.MkdirAll(stateDir, 0700); err != nil { + return err + } + path := filepath.Join(stateDir, containerID) + return ioutil.WriteFile(path, netconf, 0600) +} + +func consumeScratchNetConf(containerID string) ([]byte, error) { + path := filepath.Join(stateDir, containerID) + defer os.Remove(path) + + return ioutil.ReadFile(path) +} + +func delegateAdd(cid string, netconf map[string]interface{}) error { + netconfBytes, err := json.Marshal(netconf) + if err != nil { + return fmt.Errorf("error serializing delegate netconf: %v", err) + } + + // save the rendered netconf for cmdDel + if err = saveScratchNetConf(cid, netconfBytes); err != nil { + return err + } + + result, err := invoke.DelegateAdd(netconf["type"].(string), netconfBytes) + if err != nil { + return err + } + + return result.Print() +} + +func hasKey(m map[string]interface{}, k string) bool { + _, ok := m[k] + return ok +} + +func isString(i interface{}) bool { + _, ok := i.(string) + return ok +} + +func cmdAdd(args *skel.CmdArgs) error { + n, err := loadFlannelNetConf(args.StdinData) + if err != nil { + return err + } + + fenv, err := loadFlannelSubnetEnv(n.SubnetFile) + if err != nil { + return err + } + + if n.Delegate == nil { + n.Delegate = make(map[string]interface{}) + } else { + if hasKey(n.Delegate, "type") && !isString(n.Delegate["type"]) { + return fmt.Errorf("'delegate' dictionary, if present, must have (string) 'type' field") + } + if hasKey(n.Delegate, "name") { + return fmt.Errorf("'delegate' dictionary must not have 'name' field, it'll be set by flannel") + } + if hasKey(n.Delegate, "ipam") { + return fmt.Errorf("'delegate' dictionary must not have 'ipam' field, it'll be set by flannel") + } + } + + n.Delegate["name"] = n.Name + + if !hasKey(n.Delegate, "type") { + n.Delegate["type"] = "bridge" + } + + if !hasKey(n.Delegate, "ipMasq") { + // if flannel is not doing ipmasq, we should + ipmasq := !*fenv.ipmasq + n.Delegate["ipMasq"] = ipmasq + } + + if !hasKey(n.Delegate, "mtu") { + mtu := fenv.mtu + n.Delegate["mtu"] = mtu + } + + if n.Delegate["type"].(string) == "bridge" { + if !hasKey(n.Delegate, "isGateway") { + n.Delegate["isGateway"] = true + } + } + + n.Delegate["ipam"] = map[string]interface{}{ + "type": "host-local", + "subnet": fenv.sn.String(), + "routes": []types.Route{ + types.Route{ + Dst: *fenv.nw, + }, + }, + } + + return delegateAdd(args.ContainerID, n.Delegate) +} + +func cmdDel(args *skel.CmdArgs) error { + netconfBytes, err := consumeScratchNetConf(args.ContainerID) + if err != nil { + return err + } + + n := &types.NetConf{} + if err = json.Unmarshal(netconfBytes, n); err != nil { + return fmt.Errorf("failed to parse netconf: %v", err) + } + + return invoke.DelegateDel(n.Type, netconfBytes) +} + +func main() { + skel.PluginMain(cmdAdd, cmdDel) +} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/meta/tuning/tuning.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/meta/tuning/tuning.go new file mode 100644 index 0000000000..75ba852c00 --- /dev/null +++ b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/meta/tuning/tuning.go @@ -0,0 +1,82 @@ +// Copyright 2016 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This is a "meta-plugin". It reads in its own netconf, it does not create +// any network interface but just changes the network sysctl. + +package main + +import ( + "encoding/json" + "fmt" + "io/ioutil" + "path/filepath" + "strings" + + "github.com/containernetworking/cni/pkg/ns" + "github.com/containernetworking/cni/pkg/skel" + "github.com/containernetworking/cni/pkg/types" +) + +// TuningConf represents the network tuning configuration. +type TuningConf struct { + types.NetConf + SysCtl map[string]string `json:"sysctl"` +} + +func cmdAdd(args *skel.CmdArgs) error { + tuningConf := TuningConf{} + if err := json.Unmarshal(args.StdinData, &tuningConf); err != nil { + return fmt.Errorf("failed to load netconf: %v", err) + } + + // The directory /proc/sys/net is per network namespace. Enter in the + // network namespace before writing on it. + + err := ns.WithNetNSPath(args.Netns, func(_ ns.NetNS) error { + for key, value := range tuningConf.SysCtl { + fileName := filepath.Join("/proc/sys", strings.Replace(key, ".", "/", -1)) + fileName = filepath.Clean(fileName) + + // Refuse to modify sysctl parameters that don't belong + // to the network subsystem. + if !strings.HasPrefix(fileName, "/proc/sys/net/") { + return fmt.Errorf("invalid net sysctl key: %q", key) + } + content := []byte(value) + err := ioutil.WriteFile(fileName, content, 0644) + if err != nil { + return err + } + } + return nil + }) + if err != nil { + return err + } + + result := types.Result{} + return result.Print() +} + +func cmdDel(args *skel.CmdArgs) error { + // TODO: the settings are not reverted to the previous values. Reverting the + // settings is not useful when the whole container goes away but it could be + // useful in scenarios where plugins are added and removed at runtime. + return nil +} + +func main() { + skel.PluginMain(cmdAdd, cmdDel) +} diff --git a/stage1/net-plugins/net-plugins.mk b/stage1/net-plugins/net-plugins.mk index 0040831709..78ef0848c0 100644 --- a/stage1/net-plugins/net-plugins.mk +++ b/stage1/net-plugins/net-plugins.mk @@ -7,7 +7,7 @@ # 1. -# plugin names - taken from github.com/appc/cni/plugins +# plugin names - taken from github.com/containernetworking/cni/plugins NPM_PLUGIN_NAMES := \ main/ptp \ main/bridge \ @@ -38,7 +38,7 @@ $$(call setup-stamp-file,NPM_STAMP,$$(NPM_BASE)) # variables for makelib/build_go_bin.mk BGB_STAMP := $$(NPM_STAMP) BGB_BINARY := $$(NPM_PLUGIN) -BGB_PKG_IN_REPO := Godeps/_workspace/src/github.com/appc/cni/plugins/$1 +BGB_PKG_IN_REPO := Godeps/_workspace/src/github.com/containernetworking/cni/plugins/$1 include makelib/build_go_bin.mk $$(NPM_PLUGIN): | $$(TOOLSDIR) diff --git a/vendoredApps b/vendoredApps index 45842df29c..c65ebb2343 100644 --- a/vendoredApps +++ b/vendoredApps @@ -6,7 +6,6 @@ github.com/containernetworking/cni/plugins/ipam/dhcp github.com/containernetworking/cni/plugins/ipam/host-local github.com/containernetworking/cni/plugins/main/bridge github.com/containernetworking/cni/plugins/main/ipvlan -github.com/containernetworking/cni/plugins/main/lo github.com/containernetworking/cni/plugins/main/macvlan github.com/containernetworking/cni/plugins/main/ptp github.com/containernetworking/cni/plugins/meta/flannel From e1e8bc55df1f66b5874392c69922543defdd750c Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Fri, 27 May 2016 15:29:35 +0200 Subject: [PATCH 0337/1304] deps: delete appc/cni files --- .../src/github.com/appc/cni/LICENSE | 202 ----------- .../github.com/appc/cni/pkg/invoke/args.go | 76 ---- .../appc/cni/pkg/invoke/delegate.go | 39 -- .../github.com/appc/cni/pkg/invoke/exec.go | 75 ---- .../github.com/appc/cni/pkg/invoke/find.go | 47 --- .../src/github.com/appc/cni/pkg/ip/cidr.go | 51 --- .../github.com/appc/cni/pkg/ip/ipforward.go | 31 -- .../src/github.com/appc/cni/pkg/ip/ipmasq.go | 66 ---- .../src/github.com/appc/cni/pkg/ip/link.go | 153 -------- .../src/github.com/appc/cni/pkg/ip/route.go | 47 --- .../src/github.com/appc/cni/pkg/ipam/ipam.go | 68 ---- .../src/github.com/appc/cni/pkg/ns/ns.go | 93 ----- .../src/github.com/appc/cni/pkg/skel/skel.go | 117 ------ .../src/github.com/appc/cni/pkg/types/args.go | 91 ----- .../github.com/appc/cni/pkg/types/types.go | 191 ---------- .../github.com/appc/cni/pkg/utils/utils.go | 27 -- .../appc/cni/plugins/ipam/dhcp/daemon.go | 157 -------- .../appc/cni/plugins/ipam/dhcp/lease.go | 338 ------------------ .../appc/cni/plugins/ipam/dhcp/main.go | 73 ---- .../appc/cni/plugins/ipam/dhcp/options.go | 139 ------- .../cni/plugins/ipam/host-local/README.md | 86 ----- .../cni/plugins/ipam/host-local/allocator.go | 165 --------- .../ipam/host-local/backend/disk/backend.go | 88 ----- .../ipam/host-local/backend/disk/lock.go | 50 --- .../plugins/ipam/host-local/backend/store.go | 26 -- .../cni/plugins/ipam/host-local/config.go | 70 ---- .../appc/cni/plugins/ipam/host-local/main.go | 74 ---- .../appc/cni/plugins/main/bridge/bridge.go | 268 -------------- .../appc/cni/plugins/main/ipvlan/ipvlan.go | 172 --------- .../appc/cni/plugins/main/macvlan/macvlan.go | 176 --------- .../appc/cni/plugins/main/ptp/ptp.go | 225 ------------ .../appc/cni/plugins/meta/flannel/flannel.go | 253 ------------- .../appc/cni/plugins/meta/tuning/tuning.go | 83 ----- 33 files changed, 3817 deletions(-) delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/args.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/delegate.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/exec.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/find.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/pkg/ip/cidr.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/pkg/ip/ipforward.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/pkg/ip/ipmasq.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/pkg/ip/link.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/pkg/ip/route.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/pkg/ipam/ipam.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/pkg/ns/ns.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/pkg/skel/skel.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/pkg/types/args.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/pkg/types/types.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/pkg/utils/utils.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/dhcp/daemon.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/dhcp/lease.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/dhcp/main.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/dhcp/options.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/README.md delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/allocator.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/backend/disk/backend.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/backend/disk/lock.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/backend/store.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/config.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/main.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/plugins/main/bridge/bridge.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/plugins/main/ipvlan/ipvlan.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/plugins/main/macvlan/macvlan.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/plugins/main/ptp/ptp.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/plugins/meta/flannel/flannel.go delete mode 100644 Godeps/_workspace/src/github.com/appc/cni/plugins/meta/tuning/tuning.go diff --git a/Godeps/_workspace/src/github.com/appc/cni/LICENSE b/Godeps/_workspace/src/github.com/appc/cni/LICENSE deleted file mode 100644 index 8f71f43fee..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor 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, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - diff --git a/Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/args.go b/Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/args.go deleted file mode 100644 index be28ba621f..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/args.go +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package invoke - -import ( - "os" - "strings" -) - -type CNIArgs interface { - // For use with os/exec; i.e., return nil to inherit the - // environment from this process - AsEnv() []string -} - -type inherited struct{} - -var inheritArgsFromEnv inherited - -func (_ *inherited) AsEnv() []string { - return nil -} - -func ArgsFromEnv() CNIArgs { - return &inheritArgsFromEnv -} - -type Args struct { - Command string - ContainerID string - NetNS string - PluginArgs [][2]string - PluginArgsStr string - IfName string - Path string -} - -func (args *Args) AsEnv() []string { - env := os.Environ() - pluginArgsStr := args.PluginArgsStr - if pluginArgsStr == "" { - pluginArgsStr = stringify(args.PluginArgs) - } - - env = append(env, - "CNI_COMMAND="+args.Command, - "CNI_CONTAINERID="+args.ContainerID, - "CNI_NETNS="+args.NetNS, - "CNI_ARGS="+pluginArgsStr, - "CNI_IFNAME="+args.IfName, - "CNI_PATH="+args.Path) - return env -} - -// taken from rkt/networking/net_plugin.go -func stringify(pluginArgs [][2]string) string { - entries := make([]string, len(pluginArgs)) - - for i, kv := range pluginArgs { - entries[i] = strings.Join(kv[:], "=") - } - - return strings.Join(entries, ";") -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/delegate.go b/Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/delegate.go deleted file mode 100644 index 9864e6f53e..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/delegate.go +++ /dev/null @@ -1,39 +0,0 @@ -package invoke - -import ( - "fmt" - "os" - "strings" - - "github.com/appc/cni/pkg/types" -) - -func DelegateAdd(delegatePlugin string, netconf []byte) (*types.Result, error) { - if os.Getenv("CNI_COMMAND") != "ADD" { - return nil, fmt.Errorf("CNI_COMMAND is not ADD") - } - - paths := strings.Split(os.Getenv("CNI_PATH"), ":") - - pluginPath, err := FindInPath(delegatePlugin, paths) - if err != nil { - return nil, err - } - - return ExecPluginWithResult(pluginPath, netconf, ArgsFromEnv()) -} - -func DelegateDel(delegatePlugin string, netconf []byte) error { - if os.Getenv("CNI_COMMAND") != "DEL" { - return fmt.Errorf("CNI_COMMAND is not DEL") - } - - paths := strings.Split(os.Getenv("CNI_PATH"), ":") - - pluginPath, err := FindInPath(delegatePlugin, paths) - if err != nil { - return err - } - - return ExecPluginWithoutResult(pluginPath, netconf, ArgsFromEnv()) -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/exec.go b/Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/exec.go deleted file mode 100644 index 337bfcb870..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/exec.go +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package invoke - -import ( - "bytes" - "encoding/json" - "fmt" - "os" - "os/exec" - - "github.com/appc/cni/pkg/types" -) - -func pluginErr(err error, output []byte) error { - if _, ok := err.(*exec.ExitError); ok { - emsg := types.Error{} - if perr := json.Unmarshal(output, &emsg); perr != nil { - return fmt.Errorf("netplugin failed but error parsing its diagnostic message %q: %v", string(output), perr) - } - details := "" - if emsg.Details != "" { - details = fmt.Sprintf("; %v", emsg.Details) - } - return fmt.Errorf("%v%v", emsg.Msg, details) - } - - return err -} - -func ExecPluginWithResult(pluginPath string, netconf []byte, args CNIArgs) (*types.Result, error) { - stdoutBytes, err := execPlugin(pluginPath, netconf, args) - if err != nil { - return nil, err - } - - res := &types.Result{} - err = json.Unmarshal(stdoutBytes, res) - return res, err -} - -func ExecPluginWithoutResult(pluginPath string, netconf []byte, args CNIArgs) error { - _, err := execPlugin(pluginPath, netconf, args) - return err -} - -func execPlugin(pluginPath string, netconf []byte, args CNIArgs) ([]byte, error) { - stdout := &bytes.Buffer{} - - c := exec.Cmd{ - Env: args.AsEnv(), - Path: pluginPath, - Args: []string{pluginPath}, - Stdin: bytes.NewBuffer(netconf), - Stdout: stdout, - Stderr: os.Stderr, - } - if err := c.Run(); err != nil { - return nil, pluginErr(err, stdout.Bytes()) - } - - return stdout.Bytes(), nil -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/find.go b/Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/find.go deleted file mode 100644 index 3b03790711..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/pkg/invoke/find.go +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package invoke - -import ( - "fmt" - "os" - "path/filepath" -) - -// FindInPath returns the full path of the plugin by searching in the provided path -func FindInPath(plugin string, paths []string) (string, error) { - if plugin == "" { - return "", fmt.Errorf("no plugin name provided") - } - - if len(paths) == 0 { - return "", fmt.Errorf("no paths provided") - } - - var fullpath string - for _, path := range paths { - full := filepath.Join(path, plugin) - if fi, err := os.Stat(full); err == nil && fi.Mode().IsRegular() { - fullpath = full - break - } - } - - if fullpath == "" { - return "", fmt.Errorf("failed to find plugin %q in path %s", plugin, paths) - } - - return fullpath, nil -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/pkg/ip/cidr.go b/Godeps/_workspace/src/github.com/appc/cni/pkg/ip/cidr.go deleted file mode 100644 index dae2c4d0e4..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/pkg/ip/cidr.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ip - -import ( - "math/big" - "net" -) - -// NextIP returns IP incremented by 1 -func NextIP(ip net.IP) net.IP { - i := ipToInt(ip) - return intToIP(i.Add(i, big.NewInt(1))) -} - -// PrevIP returns IP decremented by 1 -func PrevIP(ip net.IP) net.IP { - i := ipToInt(ip) - return intToIP(i.Sub(i, big.NewInt(1))) -} - -func ipToInt(ip net.IP) *big.Int { - if v := ip.To4(); v != nil { - return big.NewInt(0).SetBytes(v) - } - return big.NewInt(0).SetBytes(ip.To16()) -} - -func intToIP(i *big.Int) net.IP { - return net.IP(i.Bytes()) -} - -// Network masks off the host portion of the IP -func Network(ipn *net.IPNet) *net.IPNet { - return &net.IPNet{ - IP: ipn.IP.Mask(ipn.Mask), - Mask: ipn.Mask, - } -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/pkg/ip/ipforward.go b/Godeps/_workspace/src/github.com/appc/cni/pkg/ip/ipforward.go deleted file mode 100644 index 77ee74632a..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/pkg/ip/ipforward.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ip - -import ( - "io/ioutil" -) - -func EnableIP4Forward() error { - return echo1("/proc/sys/net/ipv4/ip_forward") -} - -func EnableIP6Forward() error { - return echo1("/proc/sys/net/ipv6/conf/all/forwarding") -} - -func echo1(f string) error { - return ioutil.WriteFile(f, []byte("1"), 0644) -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/pkg/ip/ipmasq.go b/Godeps/_workspace/src/github.com/appc/cni/pkg/ip/ipmasq.go deleted file mode 100644 index 8ee279717a..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/pkg/ip/ipmasq.go +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ip - -import ( - "fmt" - "net" - - "github.com/coreos/go-iptables/iptables" -) - -// SetupIPMasq installs iptables rules to masquerade traffic -// coming from ipn and going outside of it -func SetupIPMasq(ipn *net.IPNet, chain string, comment string) error { - ipt, err := iptables.New() - if err != nil { - return fmt.Errorf("failed to locate iptables: %v", err) - } - - if err = ipt.NewChain("nat", chain); err != nil { - if err.(*iptables.Error).ExitStatus() != 1 { - // TODO(eyakubovich): assumes exit status 1 implies chain exists - return err - } - } - - if err = ipt.AppendUnique("nat", chain, "-d", ipn.String(), "-j", "ACCEPT", "-m", "comment", "--comment", comment); err != nil { - return err - } - - if err = ipt.AppendUnique("nat", chain, "!", "-d", "224.0.0.0/4", "-j", "MASQUERADE", "-m", "comment", "--comment", comment); err != nil { - return err - } - - return ipt.AppendUnique("nat", "POSTROUTING", "-s", ipn.String(), "-j", chain, "-m", "comment", "--comment", comment) -} - -// TeardownIPMasq undoes the effects of SetupIPMasq -func TeardownIPMasq(ipn *net.IPNet, chain string, comment string) error { - ipt, err := iptables.New() - if err != nil { - return fmt.Errorf("failed to locate iptables: %v", err) - } - - if err = ipt.Delete("nat", "POSTROUTING", "-s", ipn.String(), "-j", chain, "-m", "comment", "--comment", comment); err != nil { - return err - } - - if err = ipt.ClearChain("nat", chain); err != nil { - return err - } - - return ipt.DeleteChain("nat", chain) -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/pkg/ip/link.go b/Godeps/_workspace/src/github.com/appc/cni/pkg/ip/link.go deleted file mode 100644 index 1ba529da58..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/pkg/ip/link.go +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ip - -import ( - "crypto/rand" - "fmt" - "net" - "os" - - "github.com/appc/cni/pkg/ns" - "github.com/vishvananda/netlink" -) - -func makeVethPair(name, peer string, mtu int) (netlink.Link, error) { - veth := &netlink.Veth{ - LinkAttrs: netlink.LinkAttrs{ - Name: name, - Flags: net.FlagUp, - MTU: mtu, - }, - PeerName: peer, - } - if err := netlink.LinkAdd(veth); err != nil { - return nil, err - } - - return veth, nil -} - -func makeVeth(name string, mtu int) (peerName string, veth netlink.Link, err error) { - for i := 0; i < 10; i++ { - peerName, err = RandomVethName() - if err != nil { - return - } - - veth, err = makeVethPair(name, peerName, mtu) - switch { - case err == nil: - return - - case os.IsExist(err): - continue - - default: - err = fmt.Errorf("failed to make veth pair: %v", err) - return - } - } - - // should really never be hit - err = fmt.Errorf("failed to find a unique veth name") - return -} - -// RandomVethName returns string "veth" with random prefix (hashed from entropy) -func RandomVethName() (string, error) { - entropy := make([]byte, 4) - _, err := rand.Reader.Read(entropy) - if err != nil { - return "", fmt.Errorf("failed to generate random veth name: %v", err) - } - - // NetworkManager (recent versions) will ignore veth devices that start with "veth" - return fmt.Sprintf("veth%x", entropy), nil -} - -// SetupVeth sets up a virtual ethernet link. -// Should be in container netns, and will switch back to hostNS to set the host -// veth end up. -func SetupVeth(contVethName string, mtu int, hostNS *os.File) (hostVeth, contVeth netlink.Link, err error) { - var hostVethName string - hostVethName, contVeth, err = makeVeth(contVethName, mtu) - if err != nil { - return - } - - if err = netlink.LinkSetUp(contVeth); err != nil { - err = fmt.Errorf("failed to set %q up: %v", contVethName, err) - return - } - - hostVeth, err = netlink.LinkByName(hostVethName) - if err != nil { - err = fmt.Errorf("failed to lookup %q: %v", hostVethName, err) - return - } - - if err = netlink.LinkSetNsFd(hostVeth, int(hostNS.Fd())); err != nil { - err = fmt.Errorf("failed to move veth to host netns: %v", err) - return - } - - err = ns.WithNetNS(hostNS, false, func(_ *os.File) error { - hostVeth, err := netlink.LinkByName(hostVethName) - if err != nil { - return fmt.Errorf("failed to lookup %q in %q: %v", hostVethName, hostNS.Name(), err) - } - - if err = netlink.LinkSetUp(hostVeth); err != nil { - return fmt.Errorf("failed to set %q up: %v", hostVethName, err) - } - return nil - }) - return -} - -// DelLinkByName removes an interface link. -func DelLinkByName(ifName string) error { - iface, err := netlink.LinkByName(ifName) - if err != nil { - return fmt.Errorf("failed to lookup %q: %v", ifName, err) - } - - if err = netlink.LinkDel(iface); err != nil { - return fmt.Errorf("failed to delete %q: %v", ifName, err) - } - - return nil -} - -// DelLinkByNameAddr remove an interface returns its IP address -// of the specified family -func DelLinkByNameAddr(ifName string, family int) (*net.IPNet, error) { - iface, err := netlink.LinkByName(ifName) - if err != nil { - return nil, fmt.Errorf("failed to lookup %q: %v", ifName, err) - } - - addrs, err := netlink.AddrList(iface, family) - if err != nil || len(addrs) == 0 { - return nil, fmt.Errorf("failed to get IP addresses for %q: %v", ifName, err) - } - - if err = netlink.LinkDel(iface); err != nil { - return nil, fmt.Errorf("failed to delete %q: %v", ifName, err) - } - - return addrs[0].IPNet, nil -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/pkg/ip/route.go b/Godeps/_workspace/src/github.com/appc/cni/pkg/ip/route.go deleted file mode 100644 index 6c8658b2a2..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/pkg/ip/route.go +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ip - -import ( - "net" - - "github.com/vishvananda/netlink" -) - -// AddDefaultRoute sets the default route on the given gateway. -func AddDefaultRoute(gw net.IP, dev netlink.Link) error { - _, defNet, _ := net.ParseCIDR("0.0.0.0/0") - return AddRoute(defNet, gw, dev) -} - -// AddRoute adds a universally-scoped route to a device. -func AddRoute(ipn *net.IPNet, gw net.IP, dev netlink.Link) error { - return netlink.RouteAdd(&netlink.Route{ - LinkIndex: dev.Attrs().Index, - Scope: netlink.SCOPE_UNIVERSE, - Dst: ipn, - Gw: gw, - }) -} - -// AddHostRoute adds a host-scoped route to a device. -func AddHostRoute(ipn *net.IPNet, gw net.IP, dev netlink.Link) error { - return netlink.RouteAdd(&netlink.Route{ - LinkIndex: dev.Attrs().Index, - Scope: netlink.SCOPE_HOST, - Dst: ipn, - Gw: gw, - }) -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/pkg/ipam/ipam.go b/Godeps/_workspace/src/github.com/appc/cni/pkg/ipam/ipam.go deleted file mode 100644 index f0adfb7f60..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/pkg/ipam/ipam.go +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ipam - -import ( - "fmt" - "os" - - "github.com/appc/cni/pkg/invoke" - "github.com/appc/cni/pkg/ip" - "github.com/appc/cni/pkg/types" - - "github.com/vishvananda/netlink" -) - -func ExecAdd(plugin string, netconf []byte) (*types.Result, error) { - return invoke.DelegateAdd(plugin, netconf) -} - -func ExecDel(plugin string, netconf []byte) error { - return invoke.DelegateDel(plugin, netconf) -} - -// ConfigureIface takes the result of IPAM plugin and -// applies to the ifName interface -func ConfigureIface(ifName string, res *types.Result) error { - link, err := netlink.LinkByName(ifName) - if err != nil { - return fmt.Errorf("failed to lookup %q: %v", ifName, err) - } - - if err := netlink.LinkSetUp(link); err != nil { - return fmt.Errorf("failed to set %q UP: %v", ifName, err) - } - - // TODO(eyakubovich): IPv6 - addr := &netlink.Addr{IPNet: &res.IP4.IP, Label: ""} - if err = netlink.AddrAdd(link, addr); err != nil { - return fmt.Errorf("failed to add IP addr to %q: %v", ifName, err) - } - - for _, r := range res.IP4.Routes { - gw := r.GW - if gw == nil { - gw = res.IP4.Gateway - } - if err = ip.AddRoute(&r.Dst, gw, link); err != nil { - // we skip over duplicate routes as we assume the first one wins - if !os.IsExist(err) { - return fmt.Errorf("failed to add route '%v via %v dev %v': %v", r.Dst, gw, ifName, err) - } - } - } - - return nil -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/pkg/ns/ns.go b/Godeps/_workspace/src/github.com/appc/cni/pkg/ns/ns.go deleted file mode 100644 index 4f0814f1d6..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/pkg/ns/ns.go +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ns - -import ( - "fmt" - "os" - "runtime" - "syscall" -) - -var setNsMap = map[string]uintptr{ - "386": 346, - "amd64": 308, - "arm": 374, -} - -// SetNS sets the network namespace on a target file. -func SetNS(f *os.File, flags uintptr) error { - if runtime.GOOS != "linux" { - return fmt.Errorf("unsupported OS: %s", runtime.GOOS) - } - - trap, ok := setNsMap[runtime.GOARCH] - if !ok { - return fmt.Errorf("unsupported arch: %s", runtime.GOARCH) - } - - _, _, err := syscall.RawSyscall(trap, f.Fd(), flags, 0) - if err != 0 { - return err - } - - return nil -} - -// WithNetNSPath executes the passed closure under the given network -// namespace, restoring the original namespace afterwards. -// Changing namespaces must be done on a goroutine that has been -// locked to an OS thread. If lockThread arg is true, this function -// locks the goroutine prior to change namespace and unlocks before -// returning -func WithNetNSPath(nspath string, lockThread bool, f func(*os.File) error) error { - ns, err := os.Open(nspath) - if err != nil { - return fmt.Errorf("Failed to open %v: %v", nspath, err) - } - defer ns.Close() - return WithNetNS(ns, lockThread, f) -} - -// WithNetNS executes the passed closure under the given network -// namespace, restoring the original namespace afterwards. -// Changing namespaces must be done on a goroutine that has been -// locked to an OS thread. If lockThread arg is true, this function -// locks the goroutine prior to change namespace and unlocks before -// returning. If the closure returns an error, WithNetNS attempts to -// restore the original namespace before returning. -func WithNetNS(ns *os.File, lockThread bool, f func(*os.File) error) error { - if lockThread { - runtime.LockOSThread() - defer runtime.UnlockOSThread() - } - // save a handle to current (host) network namespace - thisNS, err := os.Open("/proc/self/ns/net") - if err != nil { - return fmt.Errorf("Failed to open /proc/self/ns/net: %v", err) - } - defer thisNS.Close() - - if err = SetNS(ns, syscall.CLONE_NEWNET); err != nil { - return fmt.Errorf("Error switching to ns %v: %v", ns.Name(), err) - } - defer SetNS(thisNS, syscall.CLONE_NEWNET) // switch back - - if err = f(thisNS); err != nil { - return err - } - - return nil -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/pkg/skel/skel.go b/Godeps/_workspace/src/github.com/appc/cni/pkg/skel/skel.go deleted file mode 100644 index 5c3532dbae..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/pkg/skel/skel.go +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright 2014 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package skel provides skeleton code for a CNI plugin. -// In particular, it implements argument parsing and validation. -package skel - -import ( - "fmt" - "io/ioutil" - "log" - "os" - - "github.com/appc/cni/pkg/types" -) - -// CmdArgs captures all the arguments passed in to the plugin -// via both env vars and stdin -type CmdArgs struct { - ContainerID string - Netns string - IfName string - Args string - Path string - StdinData []byte -} - -// PluginMain is the "main" for a plugin. It accepts -// two callback functions for add and del commands. -func PluginMain(cmdAdd, cmdDel func(_ *CmdArgs) error) { - var cmd, contID, netns, ifName, args, path string - - vars := []struct { - name string - val *string - req bool - }{ - {"CNI_COMMAND", &cmd, true}, - {"CNI_CONTAINERID", &contID, false}, - {"CNI_NETNS", &netns, true}, - {"CNI_IFNAME", &ifName, true}, - {"CNI_ARGS", &args, false}, - {"CNI_PATH", &path, true}, - } - - argsMissing := false - for _, v := range vars { - *v.val = os.Getenv(v.name) - if v.req && *v.val == "" { - log.Printf("%v env variable missing", v.name) - argsMissing = true - } - } - - if argsMissing { - dieMsg("required env variables missing") - } - - stdinData, err := ioutil.ReadAll(os.Stdin) - if err != nil { - dieMsg("error reading from stdin: %v", err) - } - - cmdArgs := &CmdArgs{ - ContainerID: contID, - Netns: netns, - IfName: ifName, - Args: args, - Path: path, - StdinData: stdinData, - } - - switch cmd { - case "ADD": - err = cmdAdd(cmdArgs) - - case "DEL": - err = cmdDel(cmdArgs) - - default: - dieMsg("unknown CNI_COMMAND: %v", cmd) - } - - if err != nil { - if e, ok := err.(*types.Error); ok { - // don't wrap Error in Error - dieErr(e) - } - dieMsg(err.Error()) - } -} - -func dieMsg(f string, args ...interface{}) { - e := &types.Error{ - Code: 100, - Msg: fmt.Sprintf(f, args...), - } - dieErr(e) -} - -func dieErr(e *types.Error) { - if err := e.Print(); err != nil { - log.Print("Error writing error JSON to stdout: ", err) - } - os.Exit(1) -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/pkg/types/args.go b/Godeps/_workspace/src/github.com/appc/cni/pkg/types/args.go deleted file mode 100644 index 3b667b0f20..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/pkg/types/args.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "encoding" - "fmt" - "reflect" - "strings" -) - -// UnmarshallableBool typedef for builtin bool -// because builtin type's methods can't be declared -type UnmarshallableBool bool - -// UnmarshalText implements the encoding.TextUnmarshaler interface. -// Returns boolean true if the string is "1" or "[Tt]rue" -// Returns boolean false if the string is "0" or "[Ff]alse" -func (b *UnmarshallableBool) UnmarshalText(data []byte) error { - s := strings.ToLower(string(data)) - switch s { - case "1", "true": - *b = true - case "0", "false": - *b = false - default: - return fmt.Errorf("Boolean unmarshal error: invalid input %s", s) - } - return nil -} - -// CommonArgs contains the IgnoreUnknown argument -// and must be embedded by all Arg structs -type CommonArgs struct { - IgnoreUnknown UnmarshallableBool `json:"ignoreunknown,omitempty"` -} - -// GetKeyField is a helper function to receive Values -// Values that represent a pointer to a struct -func GetKeyField(keyString string, v reflect.Value) reflect.Value { - return v.Elem().FieldByName(keyString) -} - -// LoadArgs parses args from a string in the form "K=V;K2=V2;..." -func LoadArgs(args string, container interface{}) error { - if args == "" { - return nil - } - - containerValue := reflect.ValueOf(container) - - pairs := strings.Split(args, ";") - unknownArgs := []string{} - for _, pair := range pairs { - kv := strings.Split(pair, "=") - if len(kv) != 2 { - return fmt.Errorf("ARGS: invalid pair %q", pair) - } - keyString := kv[0] - valueString := kv[1] - keyField := GetKeyField(keyString, containerValue) - if !keyField.IsValid() { - unknownArgs = append(unknownArgs, pair) - continue - } - - u := keyField.Addr().Interface().(encoding.TextUnmarshaler) - err := u.UnmarshalText([]byte(valueString)) - if err != nil { - return fmt.Errorf("ARGS: error parsing value of pair %q: %v)", pair, err) - } - } - - isIgnoreUnknown := GetKeyField("IgnoreUnknown", containerValue).Bool() - if len(unknownArgs) > 0 && !isIgnoreUnknown { - return fmt.Errorf("ARGS: unknown args %q", unknownArgs) - } - return nil -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/pkg/types/types.go b/Godeps/_workspace/src/github.com/appc/cni/pkg/types/types.go deleted file mode 100644 index 6948dcb1fb..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/pkg/types/types.go +++ /dev/null @@ -1,191 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "encoding/json" - "fmt" - "net" - "os" -) - -// like net.IPNet but adds JSON marshalling and unmarshalling -type IPNet net.IPNet - -// ParseCIDR takes a string like "10.2.3.1/24" and -// return IPNet with "10.2.3.1" and /24 mask -func ParseCIDR(s string) (*net.IPNet, error) { - ip, ipn, err := net.ParseCIDR(s) - if err != nil { - return nil, err - } - - ipn.IP = ip - return ipn, nil -} - -func (n IPNet) MarshalJSON() ([]byte, error) { - return json.Marshal((*net.IPNet)(&n).String()) -} - -func (n *IPNet) UnmarshalJSON(data []byte) error { - var s string - if err := json.Unmarshal(data, &s); err != nil { - return err - } - - tmp, err := ParseCIDR(s) - if err != nil { - return err - } - - *n = IPNet(*tmp) - return nil -} - -// NetConf describes a network. -type NetConf struct { - Name string `json:"name,omitempty"` - Type string `json:"type,omitempty"` - IPAM struct { - Type string `json:"type,omitempty"` - } `json:"ipam,omitempty"` - DNS DNS `json:"dns"` -} - -// Result is what gets returned from the plugin (via stdout) to the caller -type Result struct { - IP4 *IPConfig `json:"ip4,omitempty"` - IP6 *IPConfig `json:"ip6,omitempty"` - DNS DNS `json:"dns,omitempty"` -} - -func (r *Result) Print() error { - return prettyPrint(r) -} - -// String returns a formatted string in the form of "[IP4: $1,][ IP6: $2,] DNS: $3" where -// $1 represents the receiver's IPv4, $2 represents the receiver's IPv6 and $3 the -// receiver's DNS. If $1 or $2 are nil, they won't be present in the returned string. -func (r *Result) String() string { - var str string - if r.IP4 != nil { - str = fmt.Sprintf("IP4:%+v, ", *r.IP4) - } - if r.IP6 != nil { - str += fmt.Sprintf("IP6:%+v, ", *r.IP6) - } - return fmt.Sprintf("%sDNS:%+v", str, r.DNS) -} - -// IPConfig contains values necessary to configure an interface -type IPConfig struct { - IP net.IPNet - Gateway net.IP - Routes []Route -} - -// DNS contains values interesting for DNS resolvers -type DNS struct { - Nameservers []string `json:"nameservers,omitempty"` - Domain string `json:"domain,omitempty"` - Search []string `json:"search,omitempty"` - Options []string `json:"options,omitempty"` -} - -type Route struct { - Dst net.IPNet - GW net.IP -} - -type Error struct { - Code uint `json:"code"` - Msg string `json:"msg"` - Details string `json:"details,omitempty"` -} - -func (e *Error) Error() string { - return e.Msg -} - -func (e *Error) Print() error { - return prettyPrint(e) -} - -// net.IPNet is not JSON (un)marshallable so this duality is needed -// for our custom IPNet type - -// JSON (un)marshallable types -type ipConfig struct { - IP IPNet `json:"ip"` - Gateway net.IP `json:"gateway,omitempty"` - Routes []Route `json:"routes,omitempty"` -} - -type route struct { - Dst IPNet `json:"dst"` - GW net.IP `json:"gw,omitempty"` -} - -func (c *IPConfig) MarshalJSON() ([]byte, error) { - ipc := ipConfig{ - IP: IPNet(c.IP), - Gateway: c.Gateway, - Routes: c.Routes, - } - - return json.Marshal(ipc) -} - -func (c *IPConfig) UnmarshalJSON(data []byte) error { - ipc := ipConfig{} - if err := json.Unmarshal(data, &ipc); err != nil { - return err - } - - c.IP = net.IPNet(ipc.IP) - c.Gateway = ipc.Gateway - c.Routes = ipc.Routes - return nil -} - -func (r *Route) UnmarshalJSON(data []byte) error { - rt := route{} - if err := json.Unmarshal(data, &rt); err != nil { - return err - } - - r.Dst = net.IPNet(rt.Dst) - r.GW = rt.GW - return nil -} - -func (r *Route) MarshalJSON() ([]byte, error) { - rt := route{ - Dst: IPNet(r.Dst), - GW: r.GW, - } - - return json.Marshal(rt) -} - -func prettyPrint(obj interface{}) error { - data, err := json.MarshalIndent(obj, "", " ") - if err != nil { - return err - } - _, err = os.Stdout.Write(data) - return err -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/pkg/utils/utils.go b/Godeps/_workspace/src/github.com/appc/cni/pkg/utils/utils.go deleted file mode 100644 index 7ec139fd8f..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/pkg/utils/utils.go +++ /dev/null @@ -1,27 +0,0 @@ -package utils - -import ( - "crypto/sha512" - "fmt" -) - -const ( - maxChainLength = 28 - chainPrefix = "CNI-" - prefixLength = len(chainPrefix) -) - -// Generates a chain name to be used with iptables. -// Ensures that the generated chain name is exactly -// maxChainLength chars in length -func FormatChainName(name string, id string) string { - chainBytes := sha512.Sum512([]byte(name + id)) - chain := fmt.Sprintf("%s%x", chainPrefix, chainBytes) - return chain[:maxChainLength] -} - -// FormatComment returns a comment used for easier -// rule identification within iptables. -func FormatComment(name string, id string) string { - return fmt.Sprintf("name: %q id: %q", name, id) -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/dhcp/daemon.go b/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/dhcp/daemon.go deleted file mode 100644 index dabedf7241..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/dhcp/daemon.go +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "encoding/json" - "errors" - "fmt" - "log" - "net" - "net/http" - "net/rpc" - "os" - "path/filepath" - "runtime" - "sync" - - "github.com/appc/cni/pkg/skel" - "github.com/appc/cni/pkg/types" - "github.com/coreos/go-systemd/activation" -) - -const listenFdsStart = 3 -const resendCount = 3 - -var errNoMoreTries = errors.New("no more tries") - -type DHCP struct { - mux sync.Mutex - leases map[string]*DHCPLease -} - -func newDHCP() *DHCP { - return &DHCP{ - leases: make(map[string]*DHCPLease), - } -} - -// Allocate acquires an IP from a DHCP server for a specified container. -// The acquired lease will be maintained until Release() is called. -func (d *DHCP) Allocate(args *skel.CmdArgs, result *types.Result) error { - conf := types.NetConf{} - if err := json.Unmarshal(args.StdinData, &conf); err != nil { - return fmt.Errorf("error parsing netconf: %v", err) - } - - clientID := args.ContainerID + "/" + conf.Name - l, err := AcquireLease(clientID, args.Netns, args.IfName) - if err != nil { - return err - } - - ipn, err := l.IPNet() - if err != nil { - l.Stop() - return err - } - - d.setLease(args.ContainerID, conf.Name, l) - - result.IP4 = &types.IPConfig{ - IP: *ipn, - Gateway: l.Gateway(), - Routes: l.Routes(), - } - - return nil -} - -// Release stops maintenance of the lease acquired in Allocate() -// and sends a release msg to the DHCP server. -func (d *DHCP) Release(args *skel.CmdArgs, reply *struct{}) error { - conf := types.NetConf{} - if err := json.Unmarshal(args.StdinData, &conf); err != nil { - return fmt.Errorf("error parsing netconf: %v", err) - } - - if l := d.getLease(args.ContainerID, conf.Name); l != nil { - l.Stop() - return nil - } - - return fmt.Errorf("lease not found: %v/%v", args.ContainerID, conf.Name) -} - -func (d *DHCP) getLease(contID, netName string) *DHCPLease { - d.mux.Lock() - defer d.mux.Unlock() - - // TODO(eyakubovich): hash it to avoid collisions - l, ok := d.leases[contID+netName] - if !ok { - return nil - } - return l -} - -func (d *DHCP) setLease(contID, netName string, l *DHCPLease) { - d.mux.Lock() - defer d.mux.Unlock() - - // TODO(eyakubovich): hash it to avoid collisions - d.leases[contID+netName] = l -} - -func getListener() (net.Listener, error) { - l, err := activation.Listeners(true) - if err != nil { - return nil, err - } - - switch { - case len(l) == 0: - if err := os.MkdirAll(filepath.Dir(socketPath), 0700); err != nil { - return nil, err - } - return net.Listen("unix", socketPath) - - case len(l) == 1: - if l[0] == nil { - return nil, fmt.Errorf("LISTEN_FDS=1 but no FD found") - } - return l[0], nil - - default: - return nil, fmt.Errorf("Too many (%v) FDs passed through socket activation", len(l)) - } -} - -func runDaemon() { - // since other goroutines (on separate threads) will change namespaces, - // ensure the RPC server does not get scheduled onto those - runtime.LockOSThread() - - l, err := getListener() - if err != nil { - log.Printf("Error getting listener: %v", err) - return - } - - dhcp := newDHCP() - rpc.Register(dhcp) - rpc.HandleHTTP() - http.Serve(l, nil) -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/dhcp/lease.go b/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/dhcp/lease.go deleted file mode 100644 index 90c223c7c3..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/dhcp/lease.go +++ /dev/null @@ -1,338 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "fmt" - "log" - "math/rand" - "net" - "os" - "sync" - "time" - - "github.com/d2g/dhcp4" - "github.com/d2g/dhcp4client" - "github.com/vishvananda/netlink" - - "github.com/appc/cni/pkg/ns" - "github.com/appc/cni/pkg/types" -) - -// RFC 2131 suggests using exponential backoff, starting with 4sec -// and randomized to +/- 1sec -const resendDelay0 = 4 * time.Second -const resendDelayMax = 32 * time.Second - -const ( - leaseStateBound = iota - leaseStateRenewing - leaseStateRebinding -) - -// This implementation uses 1 OS thread per lease. This is because -// all the network operations have to be done in network namespace -// of the interface. This can be improved by switching to the proper -// namespace for network ops and using fewer threads. However, this -// needs to be done carefully as dhcp4client ops are blocking. - -type DHCPLease struct { - clientID string - ack *dhcp4.Packet - opts dhcp4.Options - link netlink.Link - renewalTime time.Time - rebindingTime time.Time - expireTime time.Time - stop chan struct{} - wg sync.WaitGroup -} - -// AcquireLease gets an DHCP lease and then maintains it in the background -// by periodically renewing it. The acquired lease can be released by -// calling DHCPLease.Stop() -func AcquireLease(clientID, netns, ifName string) (*DHCPLease, error) { - errCh := make(chan error, 1) - l := &DHCPLease{ - clientID: clientID, - stop: make(chan struct{}), - } - - log.Printf("%v: acquiring lease", clientID) - - l.wg.Add(1) - go func() { - errCh <- ns.WithNetNSPath(netns, true, func(_ *os.File) error { - defer l.wg.Done() - - link, err := netlink.LinkByName(ifName) - if err != nil { - return fmt.Errorf("error looking up %q: %v", ifName, err) - } - - l.link = link - - if err = l.acquire(); err != nil { - return err - } - - log.Printf("%v: lease acquired, expiration is %v", l.clientID, l.expireTime) - - errCh <- nil - - l.maintain() - return nil - }) - }() - - if err := <-errCh; err != nil { - return nil, err - } - - return l, nil -} - -// Stop terminates the background task that maintains the lease -// and issues a DHCP Release -func (l *DHCPLease) Stop() { - close(l.stop) - l.wg.Wait() -} - -func (l *DHCPLease) acquire() error { - c, err := newDHCPClient(l.link) - if err != nil { - return err - } - defer c.Close() - - if (l.link.Attrs().Flags & net.FlagUp) != net.FlagUp { - log.Printf("Link %q down. Attempting to set up", l.link.Attrs().Name) - if err = netlink.LinkSetUp(l.link); err != nil { - return err - } - } - - pkt, err := backoffRetry(func() (*dhcp4.Packet, error) { - ok, ack, err := c.Request() - switch { - case err != nil: - return nil, err - case !ok: - return nil, fmt.Errorf("DHCP server NACK'd own offer") - default: - return &ack, nil - } - }) - if err != nil { - return err - } - - return l.commit(pkt) -} - -func (l *DHCPLease) commit(ack *dhcp4.Packet) error { - opts := ack.ParseOptions() - - leaseTime, err := parseLeaseTime(opts) - if err != nil { - return err - } - - rebindingTime, err := parseRebindingTime(opts) - if err != nil || rebindingTime > leaseTime { - // Per RFC 2131 Section 4.4.5, it should default to 85% of lease time - rebindingTime = leaseTime * 85 / 100 - } - - renewalTime, err := parseRenewalTime(opts) - if err != nil || renewalTime > rebindingTime { - // Per RFC 2131 Section 4.4.5, it should default to 50% of lease time - renewalTime = leaseTime / 2 - } - - now := time.Now() - l.expireTime = now.Add(leaseTime) - l.renewalTime = now.Add(renewalTime) - l.rebindingTime = now.Add(rebindingTime) - l.ack = ack - l.opts = opts - - return nil -} - -func (l *DHCPLease) maintain() { - state := leaseStateBound - - for { - var sleepDur time.Duration - - switch state { - case leaseStateBound: - sleepDur = l.renewalTime.Sub(time.Now()) - if sleepDur <= 0 { - log.Printf("%v: renewing lease", l.clientID) - state = leaseStateRenewing - continue - } - - case leaseStateRenewing: - if err := l.renew(); err != nil { - log.Printf("%v: %v", l.clientID, err) - - if time.Now().After(l.rebindingTime) { - log.Printf("%v: renawal time expired, rebinding", l.clientID) - state = leaseStateRebinding - } - } else { - log.Printf("%v: lease renewed, expiration is %v", l.clientID, l.expireTime) - state = leaseStateBound - } - - case leaseStateRebinding: - if err := l.acquire(); err != nil { - log.Printf("%v: %v", l.clientID, err) - - if time.Now().After(l.expireTime) { - log.Printf("%v: lease expired, bringing interface DOWN", l.clientID) - l.downIface() - return - } - } else { - log.Printf("%v: lease rebound, expiration is %v", l.clientID, l.expireTime) - state = leaseStateBound - } - } - - select { - case <-time.After(sleepDur): - - case <-l.stop: - if err := l.release(); err != nil { - log.Printf("%v: failed to release DHCP lease: %v", l.clientID, err) - } - return - } - } -} - -func (l *DHCPLease) downIface() { - if err := netlink.LinkSetDown(l.link); err != nil { - log.Printf("%v: failed to bring %v interface DOWN: %v", l.clientID, l.link.Attrs().Name, err) - } -} - -func (l *DHCPLease) renew() error { - c, err := newDHCPClient(l.link) - if err != nil { - return err - } - defer c.Close() - - pkt, err := backoffRetry(func() (*dhcp4.Packet, error) { - ok, ack, err := c.Renew(*l.ack) - switch { - case err != nil: - return nil, err - case !ok: - return nil, fmt.Errorf("DHCP server did not renew lease") - default: - return &ack, nil - } - }) - if err != nil { - return err - } - - l.commit(pkt) - return nil -} - -func (l *DHCPLease) release() error { - log.Printf("%v: releasing lease", l.clientID) - - c, err := newDHCPClient(l.link) - if err != nil { - return err - } - defer c.Close() - - if err = c.Release(*l.ack); err != nil { - return fmt.Errorf("failed to send DHCPRELEASE") - } - - return nil -} - -func (l *DHCPLease) IPNet() (*net.IPNet, error) { - mask := parseSubnetMask(l.opts) - if mask == nil { - return nil, fmt.Errorf("DHCP option Subnet Mask not found in DHCPACK") - } - - return &net.IPNet{ - IP: l.ack.YIAddr(), - Mask: mask, - }, nil -} - -func (l *DHCPLease) Gateway() net.IP { - return parseRouter(l.opts) -} - -func (l *DHCPLease) Routes() []types.Route { - routes := parseRoutes(l.opts) - return append(routes, parseCIDRRoutes(l.opts)...) -} - -// jitter returns a random value within [-span, span) range -func jitter(span time.Duration) time.Duration { - return time.Duration(float64(span) * (2.0*rand.Float64() - 1.0)) -} - -func backoffRetry(f func() (*dhcp4.Packet, error)) (*dhcp4.Packet, error) { - var baseDelay time.Duration = resendDelay0 - - for i := 0; i < resendCount; i++ { - pkt, err := f() - if err == nil { - return pkt, nil - } - - log.Print(err) - - time.Sleep(baseDelay + jitter(time.Second)) - - if baseDelay < resendDelayMax { - baseDelay *= 2 - } - } - - return nil, errNoMoreTries -} - -func newDHCPClient(link netlink.Link) (*dhcp4client.Client, error) { - pktsock, err := dhcp4client.NewPacketSock(link.Attrs().Index) - if err != nil { - return nil, err - } - - return dhcp4client.New( - dhcp4client.HardwareAddr(link.Attrs().HardwareAddr), - dhcp4client.Timeout(5*time.Second), - dhcp4client.Broadcast(false), - dhcp4client.Connection(pktsock), - ) -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/dhcp/main.go b/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/dhcp/main.go deleted file mode 100644 index da44d5762e..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/dhcp/main.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "fmt" - "net/rpc" - "os" - "path/filepath" - - "github.com/appc/cni/pkg/skel" - "github.com/appc/cni/pkg/types" -) - -const socketPath = "/run/cni/dhcp.sock" - -func main() { - if len(os.Args) > 1 && os.Args[1] == "daemon" { - runDaemon() - } else { - skel.PluginMain(cmdAdd, cmdDel) - } -} - -func cmdAdd(args *skel.CmdArgs) error { - result := types.Result{} - if err := rpcCall("DHCP.Allocate", args, &result); err != nil { - return err - } - return result.Print() -} - -func cmdDel(args *skel.CmdArgs) error { - result := struct{}{} - if err := rpcCall("DHCP.Release", args, &result); err != nil { - return fmt.Errorf("error dialing DHCP daemon: %v", err) - } - return nil -} - -func rpcCall(method string, args *skel.CmdArgs, result interface{}) error { - client, err := rpc.DialHTTP("unix", socketPath) - if err != nil { - return fmt.Errorf("error dialing DHCP daemon: %v", err) - } - - // The daemon may be running under a different working dir - // so make sure the netns path is absolute. - netns, err := filepath.Abs(args.Netns) - if err != nil { - return fmt.Errorf("failed to make %q an absolute path: %v", args.Netns, err) - } - args.Netns = netns - - err = client.Call(method, args, result) - if err != nil { - return fmt.Errorf("error calling %v: %v", method, err) - } - - return nil -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/dhcp/options.go b/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/dhcp/options.go deleted file mode 100644 index f2712c28e6..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/dhcp/options.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "encoding/binary" - "fmt" - "net" - "time" - - "github.com/appc/cni/pkg/types" - "github.com/d2g/dhcp4" -) - -func parseRouter(opts dhcp4.Options) net.IP { - if opts, ok := opts[dhcp4.OptionRouter]; ok { - if len(opts) == 4 { - return net.IP(opts) - } - } - return nil -} - -func classfulSubnet(sn net.IP) net.IPNet { - return net.IPNet{ - IP: sn, - Mask: sn.DefaultMask(), - } -} - -func parseRoutes(opts dhcp4.Options) []types.Route { - // StaticRoutes format: pairs of: - // Dest = 4 bytes; Classful IP subnet - // Router = 4 bytes; IP address of router - - routes := []types.Route{} - if opt, ok := opts[dhcp4.OptionStaticRoute]; ok { - for len(opt) >= 8 { - sn := opt[0:4] - r := opt[4:8] - rt := types.Route{ - Dst: classfulSubnet(sn), - GW: r, - } - routes = append(routes, rt) - opt = opt[8:] - } - } - - return routes -} - -func parseCIDRRoutes(opts dhcp4.Options) []types.Route { - // See RFC4332 for format (http://tools.ietf.org/html/rfc3442) - - routes := []types.Route{} - if opt, ok := opts[dhcp4.OptionClasslessRouteFormat]; ok { - for len(opt) >= 5 { - width := int(opt[0]) - if width > 32 { - // error: can't have more than /32 - return nil - } - // network bits are compacted to avoid zeros - octets := 0 - if width > 0 { - octets = (width-1)/8 + 1 - } - - if len(opt) < 1+octets+4 { - // error: too short - return nil - } - - sn := make([]byte, 4) - copy(sn, opt[1:octets+1]) - - gw := net.IP(opt[octets+1 : octets+5]) - - rt := types.Route{ - Dst: net.IPNet{ - IP: net.IP(sn), - Mask: net.CIDRMask(width, 32), - }, - GW: gw, - } - routes = append(routes, rt) - - opt = opt[octets+5 : len(opt)] - } - } - return routes -} - -func parseSubnetMask(opts dhcp4.Options) net.IPMask { - mask, ok := opts[dhcp4.OptionSubnetMask] - if !ok { - return nil - } - - return net.IPMask(mask) -} - -func parseDuration(opts dhcp4.Options, code dhcp4.OptionCode, optName string) (time.Duration, error) { - val, ok := opts[code] - if !ok { - return 0, fmt.Errorf("option %v not found", optName) - } - if len(val) != 4 { - return 0, fmt.Errorf("option %v is not 4 bytes", optName) - } - - secs := binary.BigEndian.Uint32(val) - return time.Duration(secs) * time.Second, nil -} - -func parseLeaseTime(opts dhcp4.Options) (time.Duration, error) { - return parseDuration(opts, dhcp4.OptionIPAddressLeaseTime, "LeaseTime") -} - -func parseRenewalTime(opts dhcp4.Options) (time.Duration, error) { - return parseDuration(opts, dhcp4.OptionRenewalTimeValue, "RenewalTime") -} - -func parseRebindingTime(opts dhcp4.Options) (time.Duration, error) { - return parseDuration(opts, dhcp4.OptionRebindingTimeValue, "RebindingTime") -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/README.md b/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/README.md deleted file mode 100644 index 39e9ede217..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/README.md +++ /dev/null @@ -1,86 +0,0 @@ -# host-local IP address manager - -host-local IPAM allocates IPv4 and IPv6 addresses out of a specified address range. - -## Usage - -### Obtain an IP - -Given the following network configuration: - -``` -{ - "name": "default", - "ipam": { - "type": "host-local", - "subnet": "203.0.113.0/24" - } -} -``` - -#### Using the command line interface - -``` -$ export CNI_COMMAND=ADD -$ export CNI_CONTAINERID=f81d4fae-7dec-11d0-a765-00a0c91e6bf6 -$ ./host-local < $conf -``` - -``` -{ - "ip4": { - "ip": "203.0.113.1/24" - } -} -``` - -## Backends - -By default ipmanager stores IP allocations on the local filesystem using the IP address as the file name and the ID as contents. For example: - -``` -$ ls /var/lib/cni/networks/default -``` -``` -203.0.113.1 203.0.113.2 -``` - -``` -$ cat /var/lib/cni/networks/default/203.0.113.1 -``` -``` -f81d4fae-7dec-11d0-a765-00a0c91e6bf6 -``` - -## Configuration Files - - -``` -{ - "name": "ipv6", - "ipam": { - "type": "host-local", - "subnet": "3ffe:ffff:0:01ff::/64", - "range-start": "3ffe:ffff:0:01ff::0010", - "range-end": "3ffe:ffff:0:01ff::0020", - "routes": [ - { "dst": "3ffe:ffff:0:01ff::1/64" } - ] - } -} -``` - -``` -{ - "name": "ipv4", - "ipam": { - "type": "host-local", - "subnet": "203.0.113.1/24", - "range-start": "203.0.113.10", - "range-end": "203.0.113.20", - "routes": [ - { "dst": "203.0.113.0/24" } - ] - } -} -``` diff --git a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/allocator.go b/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/allocator.go deleted file mode 100644 index 2b867ce525..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/allocator.go +++ /dev/null @@ -1,165 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "fmt" - "net" - - "github.com/appc/cni/pkg/ip" - "github.com/appc/cni/pkg/types" - "github.com/appc/cni/plugins/ipam/host-local/backend" -) - -type IPAllocator struct { - start net.IP - end net.IP - conf *IPAMConfig - store backend.Store -} - -func NewIPAllocator(conf *IPAMConfig, store backend.Store) (*IPAllocator, error) { - var ( - start net.IP - end net.IP - err error - ) - start, end, err = networkRange((*net.IPNet)(&conf.Subnet)) - if err != nil { - return nil, err - } - - // skip the .0 address - start = ip.NextIP(start) - - if conf.RangeStart != nil { - if err := validateRangeIP(conf.RangeStart, (*net.IPNet)(&conf.Subnet)); err != nil { - return nil, err - } - start = conf.RangeStart - } - if conf.RangeEnd != nil { - if err := validateRangeIP(conf.RangeEnd, (*net.IPNet)(&conf.Subnet)); err != nil { - return nil, err - } - // RangeEnd is inclusive - end = ip.NextIP(conf.RangeEnd) - } - - return &IPAllocator{start, end, conf, store}, nil -} - -func validateRangeIP(ip net.IP, ipnet *net.IPNet) error { - if !ipnet.Contains(ip) { - return fmt.Errorf("%s not in network: %s", ip, ipnet) - } - return nil -} - -// Returns newly allocated IP along with its config -func (a *IPAllocator) Get(id string) (*types.IPConfig, error) { - a.store.Lock() - defer a.store.Unlock() - - gw := a.conf.Gateway - if gw == nil { - gw = ip.NextIP(a.conf.Subnet.IP) - } - - var requestedIP net.IP - if a.conf.Args != nil { - requestedIP = a.conf.Args.IP - } - - if requestedIP != nil { - if gw != nil && gw.Equal(a.conf.Args.IP) { - return nil, fmt.Errorf("requested IP must differ gateway IP") - } - - subnet := net.IPNet{ - IP: a.conf.Subnet.IP, - Mask: a.conf.Subnet.Mask, - } - err := validateRangeIP(requestedIP, &subnet) - if err != nil { - return nil, err - } - - reserved, err := a.store.Reserve(id, requestedIP) - if err != nil { - return nil, err - } - - if reserved { - return &types.IPConfig{ - IP: net.IPNet{IP: requestedIP, Mask: a.conf.Subnet.Mask}, - Gateway: gw, - Routes: a.conf.Routes, - }, nil - } - return nil, fmt.Errorf("requested IP address %q is not available in network: %s", requestedIP, a.conf.Name) - } - - for cur := a.start; !cur.Equal(a.end); cur = ip.NextIP(cur) { - // don't allocate gateway IP - if gw != nil && cur.Equal(gw) { - continue - } - - reserved, err := a.store.Reserve(id, cur) - if err != nil { - return nil, err - } - if reserved { - return &types.IPConfig{ - IP: net.IPNet{IP: cur, Mask: a.conf.Subnet.Mask}, - Gateway: gw, - Routes: a.conf.Routes, - }, nil - } - } - return nil, fmt.Errorf("no IP addresses available in network: %s", a.conf.Name) -} - -// Releases all IPs allocated for the container with given ID -func (a *IPAllocator) Release(id string) error { - a.store.Lock() - defer a.store.Unlock() - - return a.store.ReleaseByID(id) -} - -func networkRange(ipnet *net.IPNet) (net.IP, net.IP, error) { - if ipnet.IP == nil { - return nil, nil, fmt.Errorf("missing field %q in IPAM configuration", "subnet") - } - ip := ipnet.IP.To4() - if ip == nil { - ip = ipnet.IP.To16() - if ip == nil { - return nil, nil, fmt.Errorf("IP not v4 nor v6") - } - } - - if len(ip) != len(ipnet.Mask) { - return nil, nil, fmt.Errorf("IPNet IP and Mask version mismatch") - } - - var end net.IP - for i := 0; i < len(ip); i++ { - end = append(end, ip[i]|^ipnet.Mask[i]) - } - return ipnet.IP, end, nil -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/backend/disk/backend.go b/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/backend/disk/backend.go deleted file mode 100644 index 88dc5e92bc..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/backend/disk/backend.go +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package disk - -import ( - "io/ioutil" - "net" - "os" - "path/filepath" -) - -var defaultDataDir = "/var/lib/cni/networks" - -type Store struct { - FileLock - dataDir string -} - -func New(network string) (*Store, error) { - dir := filepath.Join(defaultDataDir, network) - if err := os.MkdirAll(dir, 0644); err != nil { - return nil, err - } - - lk, err := NewFileLock(dir) - if err != nil { - return nil, err - } - return &Store{*lk, dir}, nil -} - -func (s *Store) Reserve(id string, ip net.IP) (bool, error) { - fname := filepath.Join(s.dataDir, ip.String()) - f, err := os.OpenFile(fname, os.O_RDWR|os.O_EXCL|os.O_CREATE, 0644) - if os.IsExist(err) { - return false, nil - } - if err != nil { - return false, err - } - if _, err := f.WriteString(id); err != nil { - f.Close() - os.Remove(f.Name()) - return false, err - } - if err := f.Close(); err != nil { - os.Remove(f.Name()) - return false, err - } - return true, nil -} - -func (s *Store) Release(ip net.IP) error { - return os.Remove(filepath.Join(s.dataDir, ip.String())) -} - -// N.B. This function eats errors to be tolerant and -// release as much as possible -func (s *Store) ReleaseByID(id string) error { - err := filepath.Walk(s.dataDir, func(path string, info os.FileInfo, err error) error { - if err != nil || info.IsDir() { - return nil - } - data, err := ioutil.ReadFile(path) - if err != nil { - return nil - } - if string(data) == id { - if err := os.Remove(path); err != nil { - return nil - } - } - return nil - }) - return err -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/backend/disk/lock.go b/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/backend/disk/lock.go deleted file mode 100644 index 7241482515..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/backend/disk/lock.go +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package disk - -import ( - "os" - "syscall" -) - -// FileLock wraps os.File to be used as a lock using flock -type FileLock struct { - f *os.File -} - -// NewFileLock opens file/dir at path and returns unlocked FileLock object -func NewFileLock(path string) (*FileLock, error) { - f, err := os.Open(path) - if err != nil { - return nil, err - } - - return &FileLock{f}, nil -} - -// Close closes underlying file -func (l *FileLock) Close() error { - return l.f.Close() -} - -// Lock acquires an exclusive lock -func (l *FileLock) Lock() error { - return syscall.Flock(int(l.f.Fd()), syscall.LOCK_EX) -} - -// Unlock releases the lock -func (l *FileLock) Unlock() error { - return syscall.Flock(int(l.f.Fd()), syscall.LOCK_UN) -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/backend/store.go b/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/backend/store.go deleted file mode 100644 index 45a89b109c..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/backend/store.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package backend - -import "net" - -type Store interface { - Lock() error - Unlock() error - Close() error - Reserve(id string, ip net.IP) (bool, error) - Release(ip net.IP) error - ReleaseByID(id string) error -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/config.go b/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/config.go deleted file mode 100644 index 08ca07e384..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/config.go +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "encoding/json" - "fmt" - "net" - - "github.com/appc/cni/pkg/types" -) - -// IPAMConfig represents the IP related network configuration. -type IPAMConfig struct { - Name string - Type string `json:"type"` - RangeStart net.IP `json:"rangeStart"` - RangeEnd net.IP `json:"rangeEnd"` - Subnet types.IPNet `json:"subnet"` - Gateway net.IP `json:"gateway"` - Routes []types.Route `json:"routes"` - Args *IPAMArgs `json:"-"` -} - -type IPAMArgs struct { - types.CommonArgs - IP net.IP `json:"ip,omitempty"` -} - -type Net struct { - Name string `json:"name"` - IPAM *IPAMConfig `json:"ipam"` -} - -// NewIPAMConfig creates a NetworkConfig from the given network name. -func LoadIPAMConfig(bytes []byte, args string) (*IPAMConfig, error) { - n := Net{} - if err := json.Unmarshal(bytes, &n); err != nil { - return nil, err - } - - if args != "" { - n.IPAM.Args = &IPAMArgs{} - err := types.LoadArgs(args, n.IPAM.Args) - if err != nil { - return nil, err - } - } - - if n.IPAM == nil { - return nil, fmt.Errorf("%q missing 'ipam' key") - } - - // Copy net name into IPAM so not to drag Net struct around - n.IPAM.Name = n.Name - - return n.IPAM, nil -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/main.go b/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/main.go deleted file mode 100644 index 9f67e8a507..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/host-local/main.go +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "github.com/appc/cni/plugins/ipam/host-local/backend/disk" - - "github.com/appc/cni/pkg/skel" - "github.com/appc/cni/pkg/types" -) - -func main() { - skel.PluginMain(cmdAdd, cmdDel) -} - -func cmdAdd(args *skel.CmdArgs) error { - ipamConf, err := LoadIPAMConfig(args.StdinData, args.Args) - if err != nil { - return err - } - - store, err := disk.New(ipamConf.Name) - if err != nil { - return err - } - defer store.Close() - - allocator, err := NewIPAllocator(ipamConf, store) - if err != nil { - return err - } - - ipConf, err := allocator.Get(args.ContainerID) - if err != nil { - return err - } - - r := &types.Result{ - IP4: ipConf, - } - return r.Print() -} - -func cmdDel(args *skel.CmdArgs) error { - ipamConf, err := LoadIPAMConfig(args.StdinData, args.Args) - if err != nil { - return err - } - - store, err := disk.New(ipamConf.Name) - if err != nil { - return err - } - defer store.Close() - - allocator, err := NewIPAllocator(ipamConf, store) - if err != nil { - return err - } - - return allocator.Release(args.ContainerID) -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/plugins/main/bridge/bridge.go b/Godeps/_workspace/src/github.com/appc/cni/plugins/main/bridge/bridge.go deleted file mode 100644 index e87eb726fc..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/plugins/main/bridge/bridge.go +++ /dev/null @@ -1,268 +0,0 @@ -// Copyright 2014 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "encoding/json" - "errors" - "fmt" - "net" - "os" - "runtime" - "syscall" - - "github.com/appc/cni/pkg/ip" - "github.com/appc/cni/pkg/ipam" - "github.com/appc/cni/pkg/ns" - "github.com/appc/cni/pkg/skel" - "github.com/appc/cni/pkg/types" - "github.com/appc/cni/pkg/utils" - "github.com/vishvananda/netlink" -) - -const defaultBrName = "cni0" - -type NetConf struct { - types.NetConf - BrName string `json:"bridge"` - IsGW bool `json:"isGateway"` - IPMasq bool `json:"ipMasq"` - MTU int `json:"mtu"` -} - -func init() { - // this ensures that main runs only on main thread (thread group leader). - // since namespace ops (unshare, setns) are done for a single thread, we - // must ensure that the goroutine does not jump from OS thread to thread - runtime.LockOSThread() -} - -func loadNetConf(bytes []byte) (*NetConf, error) { - n := &NetConf{ - BrName: defaultBrName, - } - if err := json.Unmarshal(bytes, n); err != nil { - return nil, fmt.Errorf("failed to load netconf: %v", err) - } - return n, nil -} - -func ensureBridgeAddr(br *netlink.Bridge, ipn *net.IPNet) error { - addrs, err := netlink.AddrList(br, syscall.AF_INET) - if err != nil && err != syscall.ENOENT { - return fmt.Errorf("could not get list of IP addresses: %v", err) - } - - // if there're no addresses on the bridge, it's ok -- we'll add one - if len(addrs) > 0 { - ipnStr := ipn.String() - for _, a := range addrs { - // string comp is actually easiest for doing IPNet comps - if a.IPNet.String() == ipnStr { - return nil - } - } - return fmt.Errorf("%q already has an IP address different from %v", br.Name, ipn.String()) - } - - addr := &netlink.Addr{IPNet: ipn, Label: ""} - if err := netlink.AddrAdd(br, addr); err != nil { - return fmt.Errorf("could not add IP address to %q: %v", br.Name, err) - } - return nil -} - -func bridgeByName(name string) (*netlink.Bridge, error) { - l, err := netlink.LinkByName(name) - if err != nil { - return nil, fmt.Errorf("could not lookup %q: %v", name, err) - } - br, ok := l.(*netlink.Bridge) - if !ok { - return nil, fmt.Errorf("%q already exists but is not a bridge", name) - } - return br, nil -} - -func ensureBridge(brName string, mtu int) (*netlink.Bridge, error) { - br := &netlink.Bridge{ - LinkAttrs: netlink.LinkAttrs{ - Name: brName, - MTU: mtu, - }, - } - - if err := netlink.LinkAdd(br); err != nil { - if err != syscall.EEXIST { - return nil, fmt.Errorf("could not add %q: %v", brName, err) - } - - // it's ok if the device already exists as long as config is similar - br, err = bridgeByName(brName) - if err != nil { - return nil, err - } - } - - if err := netlink.LinkSetUp(br); err != nil { - return nil, err - } - - return br, nil -} - -func setupVeth(netns string, br *netlink.Bridge, ifName string, mtu int) error { - var hostVethName string - - err := ns.WithNetNSPath(netns, false, func(hostNS *os.File) error { - // create the veth pair in the container and move host end into host netns - hostVeth, _, err := ip.SetupVeth(ifName, mtu, hostNS) - if err != nil { - return err - } - - hostVethName = hostVeth.Attrs().Name - return nil - }) - if err != nil { - return err - } - - // need to lookup hostVeth again as its index has changed during ns move - hostVeth, err := netlink.LinkByName(hostVethName) - if err != nil { - return fmt.Errorf("failed to lookup %q: %v", hostVethName, err) - } - - // connect host veth end to the bridge - if err = netlink.LinkSetMaster(hostVeth, br); err != nil { - return fmt.Errorf("failed to connect %q to bridge %v: %v", hostVethName, br.Attrs().Name, err) - } - - return nil -} - -func calcGatewayIP(ipn *net.IPNet) net.IP { - nid := ipn.IP.Mask(ipn.Mask) - return ip.NextIP(nid) -} - -func setupBridge(n *NetConf) (*netlink.Bridge, error) { - // create bridge if necessary - br, err := ensureBridge(n.BrName, n.MTU) - if err != nil { - return nil, fmt.Errorf("failed to create bridge %q: %v", n.BrName, err) - } - - return br, nil -} - -func cmdAdd(args *skel.CmdArgs) error { - n, err := loadNetConf(args.StdinData) - if err != nil { - return err - } - - br, err := setupBridge(n) - if err != nil { - return err - } - - if err = setupVeth(args.Netns, br, args.IfName, n.MTU); err != nil { - return err - } - - // run the IPAM plugin and get back the config to apply - result, err := ipam.ExecAdd(n.IPAM.Type, args.StdinData) - if err != nil { - return err - } - - if result.IP4 == nil { - return errors.New("IPAM plugin returned missing IPv4 config") - } - - if result.IP4.Gateway == nil && n.IsGW { - result.IP4.Gateway = calcGatewayIP(&result.IP4.IP) - } - - err = ns.WithNetNSPath(args.Netns, false, func(hostNS *os.File) error { - return ipam.ConfigureIface(args.IfName, result) - }) - if err != nil { - return err - } - - if n.IsGW { - gwn := &net.IPNet{ - IP: result.IP4.Gateway, - Mask: result.IP4.IP.Mask, - } - - if err = ensureBridgeAddr(br, gwn); err != nil { - return err - } - - if err := ip.EnableIP4Forward(); err != nil { - return fmt.Errorf("failed to enable forwarding: %v", err) - } - } - - if n.IPMasq { - chain := utils.FormatChainName(n.Name, args.ContainerID) - comment := utils.FormatComment(n.Name, args.ContainerID) - if err = ip.SetupIPMasq(ip.Network(&result.IP4.IP), chain, comment); err != nil { - return err - } - } - - result.DNS = n.DNS - return result.Print() -} - -func cmdDel(args *skel.CmdArgs) error { - n, err := loadNetConf(args.StdinData) - if err != nil { - return err - } - - if err := ipam.ExecDel(n.IPAM.Type, args.StdinData); err != nil { - return err - } - - var ipn *net.IPNet - err = ns.WithNetNSPath(args.Netns, false, func(hostNS *os.File) error { - var err error - ipn, err = ip.DelLinkByNameAddr(args.IfName, netlink.FAMILY_V4) - return err - }) - if err != nil { - return err - } - - if n.IPMasq { - chain := utils.FormatChainName(n.Name, args.ContainerID) - comment := utils.FormatComment(n.Name, args.ContainerID) - if err = ip.TeardownIPMasq(ipn, chain, comment); err != nil { - return err - } - } - - return nil -} - -func main() { - skel.PluginMain(cmdAdd, cmdDel) -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/plugins/main/ipvlan/ipvlan.go b/Godeps/_workspace/src/github.com/appc/cni/plugins/main/ipvlan/ipvlan.go deleted file mode 100644 index 85919772d8..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/plugins/main/ipvlan/ipvlan.go +++ /dev/null @@ -1,172 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "encoding/json" - "errors" - "fmt" - "os" - "runtime" - - "github.com/appc/cni/pkg/ip" - "github.com/appc/cni/pkg/ipam" - "github.com/appc/cni/pkg/ns" - "github.com/appc/cni/pkg/skel" - "github.com/appc/cni/pkg/types" - "github.com/vishvananda/netlink" -) - -type NetConf struct { - types.NetConf - Master string `json:"master"` - Mode string `json:"mode"` - MTU int `json:"mtu"` -} - -func init() { - // this ensures that main runs only on main thread (thread group leader). - // since namespace ops (unshare, setns) are done for a single thread, we - // must ensure that the goroutine does not jump from OS thread to thread - runtime.LockOSThread() -} - -func loadConf(bytes []byte) (*NetConf, error) { - n := &NetConf{} - if err := json.Unmarshal(bytes, n); err != nil { - return nil, fmt.Errorf("failed to load netconf: %v", err) - } - if n.Master == "" { - return nil, fmt.Errorf(`"master" field is required. It specifies the host interface name to virtualize`) - } - return n, nil -} - -func modeFromString(s string) (netlink.IPVlanMode, error) { - switch s { - case "", "l2": - return netlink.IPVLAN_MODE_L2, nil - case "l3": - return netlink.IPVLAN_MODE_L3, nil - default: - return 0, fmt.Errorf("unknown ipvlan mode: %q", s) - } -} - -func createIpvlan(conf *NetConf, ifName string, netns *os.File) error { - mode, err := modeFromString(conf.Mode) - if err != nil { - return err - } - - m, err := netlink.LinkByName(conf.Master) - if err != nil { - return fmt.Errorf("failed to lookup master %q: %v", conf.Master, err) - } - - // due to kernel bug we have to create with tmpname or it might - // collide with the name on the host and error out - tmpName, err := ip.RandomVethName() - if err != nil { - return err - } - - mv := &netlink.IPVlan{ - LinkAttrs: netlink.LinkAttrs{ - MTU: conf.MTU, - Name: tmpName, - ParentIndex: m.Attrs().Index, - Namespace: netlink.NsFd(int(netns.Fd())), - }, - Mode: mode, - } - - if err := netlink.LinkAdd(mv); err != nil { - return fmt.Errorf("failed to create ipvlan: %v", err) - } - - return ns.WithNetNS(netns, false, func(_ *os.File) error { - err := renameLink(tmpName, ifName) - if err != nil { - return fmt.Errorf("failed to rename ipvlan to %q: %v", ifName, err) - } - return nil - }) -} - -func cmdAdd(args *skel.CmdArgs) error { - n, err := loadConf(args.StdinData) - if err != nil { - return err - } - - netns, err := os.Open(args.Netns) - if err != nil { - return fmt.Errorf("failed to open netns %q: %v", netns, err) - } - defer netns.Close() - - if err = createIpvlan(n, args.IfName, netns); err != nil { - return err - } - - // run the IPAM plugin and get back the config to apply - result, err := ipam.ExecAdd(n.IPAM.Type, args.StdinData) - if err != nil { - return err - } - if result.IP4 == nil { - return errors.New("IPAM plugin returned missing IPv4 config") - } - - err = ns.WithNetNS(netns, false, func(_ *os.File) error { - return ipam.ConfigureIface(args.IfName, result) - }) - if err != nil { - return err - } - - result.DNS = n.DNS - return result.Print() -} - -func cmdDel(args *skel.CmdArgs) error { - n, err := loadConf(args.StdinData) - if err != nil { - return err - } - - err = ipam.ExecDel(n.IPAM.Type, args.StdinData) - if err != nil { - return err - } - - return ns.WithNetNSPath(args.Netns, false, func(hostNS *os.File) error { - return ip.DelLinkByName(args.IfName) - }) -} - -func renameLink(curName, newName string) error { - link, err := netlink.LinkByName(curName) - if err != nil { - return err - } - - return netlink.LinkSetName(link, newName) -} - -func main() { - skel.PluginMain(cmdAdd, cmdDel) -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/plugins/main/macvlan/macvlan.go b/Godeps/_workspace/src/github.com/appc/cni/plugins/main/macvlan/macvlan.go deleted file mode 100644 index f6891a3491..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/plugins/main/macvlan/macvlan.go +++ /dev/null @@ -1,176 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "encoding/json" - "errors" - "fmt" - "os" - "runtime" - - "github.com/appc/cni/pkg/ip" - "github.com/appc/cni/pkg/ipam" - "github.com/appc/cni/pkg/ns" - "github.com/appc/cni/pkg/skel" - "github.com/appc/cni/pkg/types" - "github.com/vishvananda/netlink" -) - -type NetConf struct { - types.NetConf - Master string `json:"master"` - Mode string `json:"mode"` - MTU int `json:"mtu"` -} - -func init() { - // this ensures that main runs only on main thread (thread group leader). - // since namespace ops (unshare, setns) are done for a single thread, we - // must ensure that the goroutine does not jump from OS thread to thread - runtime.LockOSThread() -} - -func loadConf(bytes []byte) (*NetConf, error) { - n := &NetConf{} - if err := json.Unmarshal(bytes, n); err != nil { - return nil, fmt.Errorf("failed to load netconf: %v", err) - } - if n.Master == "" { - return nil, fmt.Errorf(`"master" field is required. It specifies the host interface name to virtualize`) - } - return n, nil -} - -func modeFromString(s string) (netlink.MacvlanMode, error) { - switch s { - case "", "bridge": - return netlink.MACVLAN_MODE_BRIDGE, nil - case "private": - return netlink.MACVLAN_MODE_PRIVATE, nil - case "vepa": - return netlink.MACVLAN_MODE_VEPA, nil - case "passthru": - return netlink.MACVLAN_MODE_PASSTHRU, nil - default: - return 0, fmt.Errorf("unknown macvlan mode: %q", s) - } -} - -func createMacvlan(conf *NetConf, ifName string, netns *os.File) error { - mode, err := modeFromString(conf.Mode) - if err != nil { - return err - } - - m, err := netlink.LinkByName(conf.Master) - if err != nil { - return fmt.Errorf("failed to lookup master %q: %v", conf.Master, err) - } - - // due to kernel bug we have to create with tmpname or it might - // collide with the name on the host and error out - tmpName, err := ip.RandomVethName() - if err != nil { - return err - } - - mv := &netlink.Macvlan{ - LinkAttrs: netlink.LinkAttrs{ - MTU: conf.MTU, - Name: tmpName, - ParentIndex: m.Attrs().Index, - Namespace: netlink.NsFd(int(netns.Fd())), - }, - Mode: mode, - } - - if err := netlink.LinkAdd(mv); err != nil { - return fmt.Errorf("failed to create macvlan: %v", err) - } - - return ns.WithNetNS(netns, false, func(_ *os.File) error { - err := renameLink(tmpName, ifName) - if err != nil { - return fmt.Errorf("failed to rename macvlan to %q: %v", ifName, err) - } - return nil - }) -} - -func cmdAdd(args *skel.CmdArgs) error { - n, err := loadConf(args.StdinData) - if err != nil { - return err - } - - netns, err := os.Open(args.Netns) - if err != nil { - return fmt.Errorf("failed to open netns %q: %v", netns, err) - } - defer netns.Close() - - if err = createMacvlan(n, args.IfName, netns); err != nil { - return err - } - - // run the IPAM plugin and get back the config to apply - result, err := ipam.ExecAdd(n.IPAM.Type, args.StdinData) - if err != nil { - return err - } - if result.IP4 == nil { - return errors.New("IPAM plugin returned missing IPv4 config") - } - - err = ns.WithNetNS(netns, false, func(_ *os.File) error { - return ipam.ConfigureIface(args.IfName, result) - }) - if err != nil { - return err - } - - result.DNS = n.DNS - return result.Print() -} - -func cmdDel(args *skel.CmdArgs) error { - n, err := loadConf(args.StdinData) - if err != nil { - return err - } - - err = ipam.ExecDel(n.IPAM.Type, args.StdinData) - if err != nil { - return err - } - - return ns.WithNetNSPath(args.Netns, false, func(hostNS *os.File) error { - return ip.DelLinkByName(args.IfName) - }) -} - -func renameLink(curName, newName string) error { - link, err := netlink.LinkByName(curName) - if err != nil { - return err - } - - return netlink.LinkSetName(link, newName) -} - -func main() { - skel.PluginMain(cmdAdd, cmdDel) -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/plugins/main/ptp/ptp.go b/Godeps/_workspace/src/github.com/appc/cni/plugins/main/ptp/ptp.go deleted file mode 100644 index 05b3b2a324..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/plugins/main/ptp/ptp.go +++ /dev/null @@ -1,225 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "encoding/json" - "errors" - "fmt" - "net" - "os" - "runtime" - - "github.com/vishvananda/netlink" - - "github.com/appc/cni/pkg/ip" - "github.com/appc/cni/pkg/ipam" - "github.com/appc/cni/pkg/ns" - "github.com/appc/cni/pkg/skel" - "github.com/appc/cni/pkg/types" - "github.com/appc/cni/pkg/utils" -) - -func init() { - // this ensures that main runs only on main thread (thread group leader). - // since namespace ops (unshare, setns) are done for a single thread, we - // must ensure that the goroutine does not jump from OS thread to thread - runtime.LockOSThread() -} - -type NetConf struct { - types.NetConf - IPMasq bool `json:"ipMasq"` - MTU int `json:"mtu"` -} - -func setupContainerVeth(netns, ifName string, mtu int, pr *types.Result) (string, error) { - // The IPAM result will be something like IP=192.168.3.5/24, GW=192.168.3.1. - // What we want is really a point-to-point link but veth does not support IFF_POINTOPONT. - // Next best thing would be to let it ARP but set interface to 192.168.3.5/32 and - // add a route like "192.168.3.0/24 via 192.168.3.1 dev $ifName". - // Unfortunately that won't work as the GW will be outside the interface's subnet. - - // Our solution is to configure the interface with 192.168.3.5/24, then delete the - // "192.168.3.0/24 dev $ifName" route that was automatically added. Then we add - // "192.168.3.1/32 dev $ifName" and "192.168.3.0/24 via 192.168.3.1 dev $ifName". - // In other words we force all traffic to ARP via the gateway except for GW itself. - - var hostVethName string - err := ns.WithNetNSPath(netns, false, func(hostNS *os.File) error { - hostVeth, _, err := ip.SetupVeth(ifName, mtu, hostNS) - if err != nil { - return err - } - - if err = ipam.ConfigureIface(ifName, pr); err != nil { - return err - } - - contVeth, err := netlink.LinkByName(ifName) - if err != nil { - return fmt.Errorf("failed to look up %q: %v", ifName, err) - } - - // Delete the route that was automatically added - route := netlink.Route{ - LinkIndex: contVeth.Attrs().Index, - Dst: &net.IPNet{ - IP: pr.IP4.IP.IP.Mask(pr.IP4.IP.Mask), - Mask: pr.IP4.IP.Mask, - }, - Scope: netlink.SCOPE_NOWHERE, - } - - if err := netlink.RouteDel(&route); err != nil { - return fmt.Errorf("failed to delete route %v: %v", route, err) - } - - for _, r := range []netlink.Route{ - netlink.Route{ - LinkIndex: contVeth.Attrs().Index, - Dst: &net.IPNet{ - IP: pr.IP4.Gateway, - Mask: net.CIDRMask(32, 32), - }, - Scope: netlink.SCOPE_LINK, - Src: pr.IP4.IP.IP, - }, - netlink.Route{ - LinkIndex: contVeth.Attrs().Index, - Dst: &net.IPNet{ - IP: pr.IP4.IP.IP.Mask(pr.IP4.IP.Mask), - Mask: pr.IP4.IP.Mask, - }, - Scope: netlink.SCOPE_UNIVERSE, - Gw: pr.IP4.Gateway, - Src: pr.IP4.IP.IP, - }, - } { - if err := netlink.RouteAdd(&r); err != nil { - return fmt.Errorf("failed to add route %v: %v", r, err) - } - } - - hostVethName = hostVeth.Attrs().Name - - return nil - }) - return hostVethName, err -} - -func setupHostVeth(vethName string, ipConf *types.IPConfig) error { - // hostVeth moved namespaces and may have a new ifindex - veth, err := netlink.LinkByName(vethName) - if err != nil { - return fmt.Errorf("failed to lookup %q: %v", vethName, err) - } - - // TODO(eyakubovich): IPv6 - ipn := &net.IPNet{ - IP: ipConf.Gateway, - Mask: net.CIDRMask(32, 32), - } - addr := &netlink.Addr{IPNet: ipn, Label: ""} - if err = netlink.AddrAdd(veth, addr); err != nil { - return fmt.Errorf("failed to add IP addr (%#v) to veth: %v", ipn, err) - } - - ipn = &net.IPNet{ - IP: ipConf.IP.IP, - Mask: net.CIDRMask(32, 32), - } - // dst happens to be the same as IP/net of host veth - if err = ip.AddHostRoute(ipn, nil, veth); err != nil && !os.IsExist(err) { - return fmt.Errorf("failed to add route on host: %v", err) - } - - return nil -} - -func cmdAdd(args *skel.CmdArgs) error { - conf := NetConf{} - if err := json.Unmarshal(args.StdinData, &conf); err != nil { - return fmt.Errorf("failed to load netconf: %v", err) - } - - if err := ip.EnableIP4Forward(); err != nil { - return fmt.Errorf("failed to enable forwarding: %v", err) - } - - // run the IPAM plugin and get back the config to apply - result, err := ipam.ExecAdd(conf.IPAM.Type, args.StdinData) - if err != nil { - return err - } - if result.IP4 == nil { - return errors.New("IPAM plugin returned missing IPv4 config") - } - - hostVethName, err := setupContainerVeth(args.Netns, args.IfName, conf.MTU, result) - if err != nil { - return err - } - - if err = setupHostVeth(hostVethName, result.IP4); err != nil { - return err - } - - if conf.IPMasq { - chain := utils.FormatChainName(conf.Name, args.ContainerID) - comment := utils.FormatComment(conf.Name, args.ContainerID) - if err = ip.SetupIPMasq(&result.IP4.IP, chain, comment); err != nil { - return err - } - } - - result.DNS = conf.DNS - return result.Print() -} - -func cmdDel(args *skel.CmdArgs) error { - conf := NetConf{} - if err := json.Unmarshal(args.StdinData, &conf); err != nil { - return fmt.Errorf("failed to load netconf: %v", err) - } - - if err := ipam.ExecDel(conf.IPAM.Type, args.StdinData); err != nil { - return err - } - - var ipn *net.IPNet - err := ns.WithNetNSPath(args.Netns, false, func(hostNS *os.File) error { - var err error - ipn, err = ip.DelLinkByNameAddr(args.IfName, netlink.FAMILY_V4) - return err - }) - if err != nil { - return err - } - - if conf.IPMasq { - chain := utils.FormatChainName(conf.Name, args.ContainerID) - comment := utils.FormatComment(conf.Name, args.ContainerID) - if err = ip.TeardownIPMasq(ipn, chain, comment); err != nil { - return err - } - } - - return nil -} - -func main() { - skel.PluginMain(cmdAdd, cmdDel) -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/plugins/meta/flannel/flannel.go b/Godeps/_workspace/src/github.com/appc/cni/plugins/meta/flannel/flannel.go deleted file mode 100644 index 6653baca2a..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/plugins/meta/flannel/flannel.go +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// This is a "meta-plugin". It reads in its own netconf, combines it with -// the data from flannel generated subnet file and then invokes a plugin -// like bridge or ipvlan to do the real work. - -package main - -import ( - "bufio" - "encoding/json" - "fmt" - "io/ioutil" - "net" - "os" - "path/filepath" - "strconv" - "strings" - - "github.com/appc/cni/pkg/invoke" - "github.com/appc/cni/pkg/skel" - "github.com/appc/cni/pkg/types" -) - -const ( - defaultSubnetFile = "/run/flannel/subnet.env" - stateDir = "/var/lib/cni/flannel" -) - -type NetConf struct { - types.NetConf - SubnetFile string `json:"subnetFile"` - Delegate map[string]interface{} `json:"delegate"` -} - -type subnetEnv struct { - nw *net.IPNet - sn *net.IPNet - mtu *uint - ipmasq *bool -} - -func (se *subnetEnv) missing() string { - m := []string{} - - if se.nw == nil { - m = append(m, "FLANNEL_NETWORK") - } - if se.sn == nil { - m = append(m, "FLANNEL_SUBNET") - } - if se.mtu == nil { - m = append(m, "FLANNEL_MTU") - } - if se.ipmasq == nil { - m = append(m, "FLANNEL_IPMASQ") - } - return strings.Join(m, ", ") -} - -func loadFlannelNetConf(bytes []byte) (*NetConf, error) { - n := &NetConf{ - SubnetFile: defaultSubnetFile, - } - if err := json.Unmarshal(bytes, n); err != nil { - return nil, fmt.Errorf("failed to load netconf: %v", err) - } - return n, nil -} - -func loadFlannelSubnetEnv(fn string) (*subnetEnv, error) { - f, err := os.Open(fn) - if err != nil { - return nil, err - } - defer f.Close() - - se := &subnetEnv{} - - s := bufio.NewScanner(f) - for s.Scan() { - parts := strings.SplitN(s.Text(), "=", 2) - switch parts[0] { - case "FLANNEL_NETWORK": - _, se.nw, err = net.ParseCIDR(parts[1]) - if err != nil { - return nil, err - } - - case "FLANNEL_SUBNET": - _, se.sn, err = net.ParseCIDR(parts[1]) - if err != nil { - return nil, err - } - - case "FLANNEL_MTU": - mtu, err := strconv.ParseUint(parts[1], 10, 32) - if err != nil { - return nil, err - } - se.mtu = new(uint) - *se.mtu = uint(mtu) - - case "FLANNEL_IPMASQ": - ipmasq := parts[1] == "true" - se.ipmasq = &ipmasq - } - } - if err := s.Err(); err != nil { - return nil, err - } - - if m := se.missing(); m != "" { - return nil, fmt.Errorf("%v is missing %v", fn, m) - } - - return se, nil -} - -func saveScratchNetConf(containerID string, netconf []byte) error { - if err := os.MkdirAll(stateDir, 0700); err != nil { - return err - } - path := filepath.Join(stateDir, containerID) - return ioutil.WriteFile(path, netconf, 0600) -} - -func consumeScratchNetConf(containerID string) ([]byte, error) { - path := filepath.Join(stateDir, containerID) - defer os.Remove(path) - - return ioutil.ReadFile(path) -} - -func delegateAdd(cid string, netconf map[string]interface{}) error { - netconfBytes, err := json.Marshal(netconf) - if err != nil { - return fmt.Errorf("error serializing delegate netconf: %v", err) - } - - // save the rendered netconf for cmdDel - if err = saveScratchNetConf(cid, netconfBytes); err != nil { - return err - } - - result, err := invoke.DelegateAdd(netconf["type"].(string), netconfBytes) - if err != nil { - return err - } - - return result.Print() -} - -func hasKey(m map[string]interface{}, k string) bool { - _, ok := m[k] - return ok -} - -func isString(i interface{}) bool { - _, ok := i.(string) - return ok -} - -func cmdAdd(args *skel.CmdArgs) error { - n, err := loadFlannelNetConf(args.StdinData) - if err != nil { - return err - } - - fenv, err := loadFlannelSubnetEnv(n.SubnetFile) - if err != nil { - return err - } - - if n.Delegate == nil { - n.Delegate = make(map[string]interface{}) - } else { - if hasKey(n.Delegate, "type") && !isString(n.Delegate["type"]) { - return fmt.Errorf("'delegate' dictionary, if present, must have (string) 'type' field") - } - if hasKey(n.Delegate, "name") { - return fmt.Errorf("'delegate' dictionary must not have 'name' field, it'll be set by flannel") - } - if hasKey(n.Delegate, "ipam") { - return fmt.Errorf("'delegate' dictionary must not have 'ipam' field, it'll be set by flannel") - } - } - - n.Delegate["name"] = n.Name - - if !hasKey(n.Delegate, "type") { - n.Delegate["type"] = "bridge" - } - - if !hasKey(n.Delegate, "ipMasq") { - // if flannel is not doing ipmasq, we should - ipmasq := !*fenv.ipmasq - n.Delegate["ipMasq"] = ipmasq - } - - if !hasKey(n.Delegate, "mtu") { - mtu := fenv.mtu - n.Delegate["mtu"] = mtu - } - - if n.Delegate["type"].(string) == "bridge" { - if !hasKey(n.Delegate, "isGateway") { - n.Delegate["isGateway"] = true - } - } - - n.Delegate["ipam"] = map[string]interface{}{ - "type": "host-local", - "subnet": fenv.sn.String(), - "routes": []types.Route{ - types.Route{ - Dst: *fenv.nw, - }, - }, - } - - return delegateAdd(args.ContainerID, n.Delegate) -} - -func cmdDel(args *skel.CmdArgs) error { - netconfBytes, err := consumeScratchNetConf(args.ContainerID) - if err != nil { - return err - } - - n := &types.NetConf{} - if err = json.Unmarshal(netconfBytes, n); err != nil { - return fmt.Errorf("failed to parse netconf: %v", err) - } - - return invoke.DelegateDel(n.Type, netconfBytes) -} - -func main() { - skel.PluginMain(cmdAdd, cmdDel) -} diff --git a/Godeps/_workspace/src/github.com/appc/cni/plugins/meta/tuning/tuning.go b/Godeps/_workspace/src/github.com/appc/cni/plugins/meta/tuning/tuning.go deleted file mode 100644 index 91118dfb1a..0000000000 --- a/Godeps/_workspace/src/github.com/appc/cni/plugins/meta/tuning/tuning.go +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2016 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// This is a "meta-plugin". It reads in its own netconf, it does not create -// any network interface but just changes the network sysctl. - -package main - -import ( - "encoding/json" - "fmt" - "io/ioutil" - "os" - "path/filepath" - "strings" - - "github.com/appc/cni/pkg/ns" - "github.com/appc/cni/pkg/skel" - "github.com/appc/cni/pkg/types" -) - -// TuningConf represents the network tuning configuration. -type TuningConf struct { - types.NetConf - SysCtl map[string]string `json:"sysctl"` -} - -func cmdAdd(args *skel.CmdArgs) error { - tuningConf := TuningConf{} - if err := json.Unmarshal(args.StdinData, &tuningConf); err != nil { - return fmt.Errorf("failed to load netconf: %v", err) - } - - // The directory /proc/sys/net is per network namespace. Enter in the - // network namespace before writing on it. - - err := ns.WithNetNSPath(args.Netns, false, func(hostNS *os.File) error { - for key, value := range tuningConf.SysCtl { - fileName := filepath.Join("/proc/sys", strings.Replace(key, ".", "/", -1)) - fileName = filepath.Clean(fileName) - - // Refuse to modify sysctl parameters that don't belong - // to the network subsystem. - if !strings.HasPrefix(fileName, "/proc/sys/net/") { - return fmt.Errorf("invalid net sysctl key: %q", key) - } - content := []byte(value) - err := ioutil.WriteFile(fileName, content, 0644) - if err != nil { - return err - } - } - return nil - }) - if err != nil { - return err - } - - result := types.Result{} - return result.Print() -} - -func cmdDel(args *skel.CmdArgs) error { - // TODO: the settings are not reverted to the previous values. Reverting the - // settings is not useful when the whole container goes away but it could be - // useful in scenarios where plugins are added and removed at runtime. - return nil -} - -func main() { - skel.PluginMain(cmdAdd, cmdDel) -} From 1b1bef814e99b62cbcc296dc62e3dd243058e5e8 Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Wed, 25 May 2016 17:27:06 +0200 Subject: [PATCH 0338/1304] networking: use CNI's ns package --- networking/networking.go | 200 ++++++++++++--------------------------- networking/podenv.go | 53 +++++++++-- tests/inspect/inspect.go | 4 + 3 files changed, 114 insertions(+), 143 deletions(-) diff --git a/networking/networking.go b/networking/networking.go index f07ee923c0..280cdbfab2 100644 --- a/networking/networking.go +++ b/networking/networking.go @@ -33,6 +33,8 @@ import ( "github.com/coreos/rkt/common" "github.com/coreos/rkt/networking/netinfo" "github.com/coreos/rkt/pkg/log" + + "golang.org/x/sys/unix" ) const ( @@ -44,8 +46,7 @@ const ( type Networking struct { podEnv - hostNS *os.File - nets []activeNet + nets []activeNet } // NetConf local struct extends cnitypes.NetConf with information about masquerading @@ -68,6 +69,12 @@ func Setup(podRoot string, podID types.UUID, fps []ForwardedPort, netList common return kvmSetup(podRoot, podID, fps, netList, localConfig) } + // Create namespace for Pod and write path to a file + podNS, err := ns.NewNS() + if err != nil { + return nil, err + } + // TODO(jonboulle): currently podRoot is _always_ ".", and behaviour in other // circumstances is untested. This should be cleaned up. n := Networking{ @@ -76,56 +83,39 @@ func Setup(podRoot string, podID types.UUID, fps []ForwardedPort, netList common podID: podID, netsLoadList: netList, localConfig: localConfig, + podNS: podNS, }, } - hostNS, podNS, err := basicNetNS() + n.nets, err = n.loadNets() if err != nil { - return nil, err + return nil, errwrap.Wrap(errors.New("error loading network definitions"), err) } - // we're in podNS! - n.hostNS = hostNS - - nspath := n.podNSPath() - if err = bindMountFile(selfNetNS, nspath); err != nil { + if err := n.setupNets(n.nets); err != nil { return nil, err } - defer func() { + if len(fps) > 0 { + if err = n.enableDefaultLocalnetRouting(); err != nil { + return nil, err + } + podIP, err := n.GetForwardableNetPodIP() if err != nil { - if err := syscall.Unmount(nspath, 0); err != nil { - stderr.PrintE(fmt.Sprintf("error unmounting %q", nspath), err) - } + return nil, err + } + if err := n.forwardPorts(fps, podIP); err != nil { + n.unforwardPorts() + return nil, err } - }() + } - n.nets, err = n.loadNets() - if err != nil { - return nil, errwrap.Wrap(errors.New("error loading network definitions"), err) + // Switch to the podNS + if err := podNS.Set(); err != nil { + return nil, err } - err = withNetNS(podNS, hostNS, func() error { - if err := n.setupNets(n.nets); err != nil { - return err - } - if len(fps) > 0 { - if err = n.enableDefaultLocalnetRouting(); err != nil { - return err - } - podIP, err := n.GetForwardableNetPodIP() - if err != nil { - return err - } - if err := n.forwardPorts(fps, podIP); err != nil { - n.unforwardPorts() - return err - } - return nil - } - return nil - }) - if err != nil { + if err = loUp(); err != nil { return nil, err } @@ -194,11 +184,6 @@ func Load(podRoot string, podID *types.UUID) (*Networking, error) { return nil, err } - hostNS, err := os.Open(selfNetNS) - if err != nil { - return nil, err - } - var nets []activeNet for _, ni := range nis { n, err := loadNet(ni.ConfPath) @@ -215,12 +200,19 @@ func Load(podRoot string, podID *types.UUID) (*Networking, error) { nets = append(nets, *n) } + p := podEnv{ + podRoot: podRoot, + podID: *podID, + } + + podNS, err := p.podNSLoad() + if err != nil { + return nil, err + } + p.podNS = podNS + return &Networking{ - podEnv: podEnv{ - podRoot: podRoot, - podID: *podID, - }, - hostNS: hostNS, + podEnv: p, nets: nets, }, nil } @@ -276,104 +268,49 @@ func (n *Networking) Teardown(flavor string, debug bool) { return } - if err := n.enterHostNS(); err != nil { - stderr.PrintE("error switching to host netns", err) - return - } - if err := n.unforwardPorts(); err != nil { stderr.PrintE("error removing forwarded ports", err) } - n.teardownNets(n.nets) - - if err := syscall.Unmount(n.podNSPath(), 0); err != nil { - // if already unmounted, umount(2) returns EINVAL - if !os.IsNotExist(err) && err != syscall.EINVAL { - stderr.PrintE(fmt.Sprintf("error unmounting %q", n.podNSPath()), err) - } - } -} - -// sets up new netns with just lo -func basicNetNS() (hostNS, podNS *os.File, err error) { - hostNS, podNS, err = newNetNS() + podNS, err := n.podNSLoad() if err != nil { - err = errwrap.Wrap(errors.New("failed to create new netns"), err) - return + stderr.PrintE("error loading podNS: %v", err) } - // we're in podNS!! + if podNS != nil { + defer func() { + n.podNS.Close() - if err = loUp(); err != nil { - hostNS.Close() - podNS.Close() - return nil, nil, err - } + if err := syscall.Unmount(n.podNS.Path(), unix.MNT_DETACH); err != nil { + // if already unmounted, umount(2) returns EINVAL + if !os.IsNotExist(err) && err != syscall.EINVAL { + stderr.PrintE(fmt.Sprintf("error unmounting %q", n.podNS.Path()), err) + } + } - return -} + if err := os.RemoveAll(n.podNS.Path()); err != nil { + stderr.PrintE(fmt.Sprintf("failed to remove namespace %s", n.podNS.Path()), err) + } + }() + } -// enterHostNS moves into the host's network namespace. -func (n *Networking) enterHostNS() error { - return ns.SetNS(n.hostNS, syscall.CLONE_NEWNET) + n.podNS = podNS + n.teardownNets(n.nets) } // Save writes out the info about active nets // for "rkt list" and friends to display func (e *Networking) Save() error { - var nis []netinfo.NetInfo - for _, n := range e.nets { - nis = append(nis, *n.runtime) - } - - return netinfo.Save(e.podRoot, nis) -} - -func newNetNS() (hostNS, childNS *os.File, err error) { - defer func() { - if err != nil { - if hostNS != nil { - hostNS.Close() - } - if childNS != nil { - childNS.Close() - } - } - }() - hostNS, err = os.Open(selfNetNS) - if err != nil { - return - } - - if err = syscall.Unshare(syscall.CLONE_NEWNET); err != nil { - return - } - - childNS, err = os.Open(selfNetNS) - if err != nil { - ns.SetNS(hostNS, syscall.CLONE_NEWNET) - return - } - - return -} - -// execute f() in tgtNS -func withNetNS(curNS, tgtNS *os.File, f func() error) error { - if err := ns.SetNS(tgtNS, syscall.CLONE_NEWNET); err != nil { + if err := e.podNSPathSave(); err != nil { return err } - if err := f(); err != nil { - // Attempt to revert the net ns in a known state - if err := ns.SetNS(curNS, syscall.CLONE_NEWNET); err != nil { - stderr.PrintE("cannot revert the net namespace", err) - } - return err + var nis []netinfo.NetInfo + for _, n := range e.nets { + nis = append(nis, *n.runtime) } - return ns.SetNS(curNS, syscall.CLONE_NEWNET) + return netinfo.Save(e.podRoot, nis) } func loUp() error { @@ -388,14 +325,3 @@ func loUp() error { return nil } - -func bindMountFile(src, dst string) error { - // mount point has to be an existing file - f, err := os.Create(dst) - if err != nil { - return err - } - f.Close() - - return syscall.Mount(src, dst, "none", syscall.MS_BIND, "") -} diff --git a/networking/podenv.go b/networking/podenv.go index 5fe95f4ed7..2f1a802f2f 100644 --- a/networking/podenv.go +++ b/networking/podenv.go @@ -28,6 +28,8 @@ import ( "github.com/appc/spec/schema/types" "github.com/hashicorp/errwrap" + "github.com/containernetworking/cni/pkg/ns" + "github.com/coreos/rkt/common" "github.com/coreos/rkt/networking/netinfo" ) @@ -49,6 +51,7 @@ type podEnv struct { podID types.UUID netsLoadList common.NetList localConfig string + podNS ns.NetNS } type activeNet struct { @@ -91,10 +94,46 @@ func (e *podEnv) loadNets() ([]activeNet, error) { return nets, nil } -func (e *podEnv) podNSPath() string { +func (e *podEnv) podNSFilePath() string { return filepath.Join(e.podRoot, "netns") } +func (e *podEnv) podNSPathLoad() (string, error) { + podNSPath, err := ioutil.ReadFile(e.podNSFilePath()) + if err != nil { + return "", err + } + + return string(podNSPath), nil +} + +func (e *podEnv) podNSLoad() (ns.NetNS, error) { + podNSPath, err := e.podNSPathLoad() + if err != nil { + return nil, err + } + + podNS, err := ns.GetNS(podNSPath) + if err != nil { + return nil, err + } + return podNS, nil +} + +func (e *podEnv) podNSPathSave() error { + podNSFile, err := os.OpenFile(e.podNSFilePath(), os.O_WRONLY|os.O_CREATE, 0) + if err != nil { + return err + } + defer podNSFile.Close() + + if _, err = io.WriteString(podNSFile, e.podNS.Path()); err != nil { + return err + } + + return nil +} + func (e *podEnv) netDir() string { return filepath.Join(e.podRoot, "net") } @@ -112,8 +151,6 @@ func (e *podEnv) setupNets(nets []activeNet) error { } }() - nspath := e.podNSPath() - n := activeNet{} for i, n = range nets { stderr.Printf("loading network %v with type %v", n.conf.Name, n.conf.Type) @@ -123,7 +160,7 @@ func (e *podEnv) setupNets(nets []activeNet) error { return errwrap.Wrap(fmt.Errorf("error copying %q to %q", n.runtime.ConfPath, e.netDir()), err) } - n.runtime.IP, n.runtime.HostIP, err = e.netPluginAdd(&n, nspath) + n.runtime.IP, n.runtime.HostIP, err = e.netPluginAdd(&n, e.podNS.Path()) if err != nil { return errwrap.Wrap(fmt.Errorf("error adding network %q", n.conf.Name), err) } @@ -132,12 +169,16 @@ func (e *podEnv) setupNets(nets []activeNet) error { } func (e *podEnv) teardownNets(nets []activeNet) { - nspath := e.podNSPath() for i := len(nets) - 1; i >= 0; i-- { stderr.Printf("teardown - executing net-plugin %v", nets[i].conf.Type) - err := e.netPluginDel(&nets[i], nspath) + podNSpath := "" + if e.podNS != nil { + podNSpath = e.podNS.Path() + } + + err := e.netPluginDel(&nets[i], podNSpath) if err != nil { stderr.PrintE(fmt.Sprintf("error deleting %q", nets[i].conf.Name), err) } diff --git a/tests/inspect/inspect.go b/tests/inspect/inspect.go index 6d05ba5891..b84d3c4914 100644 --- a/tests/inspect/inspect.go +++ b/tests/inspect/inspect.go @@ -390,6 +390,10 @@ func main() { fmt.Fprintf(os.Stderr, "%v\n", err) os.Exit(1) } + if len(ips) == 0 { + fmt.Fprintf(os.Stderr, "No IPv4 found for interface %+v:\n", iface) + os.Exit(1) + } fmt.Printf("%v IPv4: %s\n", iface, ips[0]) } From 8e60a31d01af2aa9671a65a128b16e47d63b5e5b Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Thu, 26 May 2016 00:14:00 +0200 Subject: [PATCH 0339/1304] networking: only save NS to file when set * Fixes KVM flavor, which doesn't use the NS file --- networking/networking.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/networking/networking.go b/networking/networking.go index 280cdbfab2..faae829003 100644 --- a/networking/networking.go +++ b/networking/networking.go @@ -301,8 +301,10 @@ func (n *Networking) Teardown(flavor string, debug bool) { // for "rkt list" and friends to display func (e *Networking) Save() error { - if err := e.podNSPathSave(); err != nil { - return err + if e.podNS != nil { + if err := e.podNSPathSave(); err != nil { + return err + } } var nis []netinfo.NetInfo From 667637fd74fd0f99cf88c43e2efe16e915b3d8ac Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Thu, 26 May 2016 16:17:57 +0200 Subject: [PATCH 0340/1304] tests/net: migrate remaining ones to testutil.Test This will implicitly disable these tests for the KVM flavor on which they are currently failing. --- tests/rkt_net_nspawn_test.go | 12 +++ tests/rkt_net_test.go | 172 ++++++++++++++++++----------------- 2 files changed, 101 insertions(+), 83 deletions(-) diff --git a/tests/rkt_net_nspawn_test.go b/tests/rkt_net_nspawn_test.go index 905c5a588d..376f2ca5e5 100644 --- a/tests/rkt_net_nspawn_test.go +++ b/tests/rkt_net_nspawn_test.go @@ -63,3 +63,15 @@ func TestNetCustomPtp(t *testing.T) { func TestNetDefaultConnectivity(t *testing.T) { NewNetDefaultConnectivityTest().Execute(t) } + +func TestNetDefaultNetNS(t *testing.T) { + NewTestNetDefaultNetNS().Execute(t) +} + +func TestNetLongName(t *testing.T) { + NewTestNetLongName().Execute(t) +} + +func TestNetDefaultRestrictedConnectivity(t *testing.T) { + NewTestNetDefaultRestrictedConnectivity().Execute(t) +} diff --git a/tests/rkt_net_test.go b/tests/rkt_net_test.go index 58eb30b4a7..8bd7c0be55 100644 --- a/tests/rkt_net_test.go +++ b/tests/rkt_net_test.go @@ -175,37 +175,39 @@ func NewNetNoneTest() testutils.Test { * --- * Container must be in a separate network namespace */ -func TestNetDefaultNetNS(t *testing.T) { - testImageArgs := []string{"--exec=/inspect --print-netns"} - testImage := patchTestACI("rkt-inspect-networking.aci", testImageArgs...) - defer os.Remove(testImage) +func NewTestNetDefaultNetNS() testutils.Test { + return testutils.TestFunc(func(t *testing.T) { + testImageArgs := []string{"--exec=/inspect --print-netns"} + testImage := patchTestACI("rkt-inspect-networking.aci", testImageArgs...) + defer os.Remove(testImage) - ctx := testutils.NewRktRunCtx() - defer ctx.Cleanup() + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() - f := func(argument string) { - cmd := fmt.Sprintf("%s --debug --insecure-options=image run %s --mds-register=false %s", ctx.Cmd(), argument, testImage) - child := spawnOrFail(t, cmd) - defer waitOrFail(t, child, 0) + f := func(argument string) { + cmd := fmt.Sprintf("%s --debug --insecure-options=image run %s --mds-register=false %s", ctx.Cmd(), argument, testImage) + child := spawnOrFail(t, cmd) + defer waitOrFail(t, child, 0) - expectedRegex := `NetNS: (net:\[\d+\])` - result, out, err := expectRegexWithOutput(child, expectedRegex) - if err != nil { - t.Fatalf("Error: %v\nOutput: %v", err, out) - } + expectedRegex := `NetNS: (net:\[\d+\])` + result, out, err := expectRegexWithOutput(child, expectedRegex) + if err != nil { + t.Fatalf("Error: %v\nOutput: %v", err, out) + } - ns, err := os.Readlink("/proc/self/ns/net") - if err != nil { - t.Fatalf("Cannot evaluate NetNS symlink: %v", err) - } + ns, err := os.Readlink("/proc/self/ns/net") + if err != nil { + t.Fatalf("Cannot evaluate NetNS symlink: %v", err) + } - if nsChanged := ns != result[1]; !nsChanged { - t.Fatalf("container did not leave host netns") - } + if nsChanged := ns != result[1]; !nsChanged { + t.Fatalf("container did not leave host netns") + } - } - f("--net=default") - f("") + } + f("--net=default") + f("") + }) } /* @@ -293,59 +295,61 @@ func NewNetDefaultConnectivityTest() testutils.Test { * eth0's IPv4 * TODO: verify that the container isn't NATed */ -func TestNetDefaultRestrictedConnectivity(t *testing.T) { - ctx := testutils.NewRktRunCtx() - defer ctx.Cleanup() +func NewTestNetDefaultRestrictedConnectivity() testutils.Test { + return testutils.TestFunc(func(t *testing.T) { + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() - f := func(argument string) { - httpPort, err := testutils.GetNextFreePort4() - if err != nil { - t.Fatalf("%v", err) - } - httpServeAddr := fmt.Sprintf("0.0.0.0:%v", httpPort) - iface := "eth0" + f := func(argument string) { + httpPort, err := testutils.GetNextFreePort4() + if err != nil { + t.Fatalf("%v", err) + } + httpServeAddr := fmt.Sprintf("0.0.0.0:%v", httpPort) + iface := "eth0" - testImageArgs := []string{fmt.Sprintf("--exec=/inspect --print-ipv4=%v --serve-http=%v", iface, httpServeAddr)} - testImage := patchTestACI("rkt-inspect-networking.aci", testImageArgs...) - defer os.Remove(testImage) + testImageArgs := []string{fmt.Sprintf("--exec=/inspect --print-ipv4=%v --serve-http=%v", iface, httpServeAddr)} + testImage := patchTestACI("rkt-inspect-networking.aci", testImageArgs...) + defer os.Remove(testImage) - cmd := fmt.Sprintf("%s --debug --insecure-options=image run %s --mds-register=false %s", ctx.Cmd(), argument, testImage) - child := spawnOrFail(t, cmd) + cmd := fmt.Sprintf("%s --debug --insecure-options=image run %s --mds-register=false %s", ctx.Cmd(), argument, testImage) + child := spawnOrFail(t, cmd) - expectedRegex := `IPv4: (\d+\.\d+\.\d+\.\d+)` - result, out, err := expectRegexWithOutput(child, expectedRegex) - if err != nil { - t.Fatalf("Error: %v\nOutput: %v", err, out) - } - httpGetAddr := fmt.Sprintf("http://%v:%v", result[1], httpPort) + expectedRegex := `IPv4: (\d+\.\d+\.\d+\.\d+)` + result, out, err := expectRegexWithOutput(child, expectedRegex) + if err != nil { + t.Fatalf("Error: %v\nOutput: %v", err, out) + } + httpGetAddr := fmt.Sprintf("http://%v:%v", result[1], httpPort) - ga := testutils.NewGoroutineAssistant(t) - ga.Add(2) + ga := testutils.NewGoroutineAssistant(t) + ga.Add(2) - // Child opens the server - go func() { - defer ga.Done() - ga.WaitOrFail(child) - }() + // Child opens the server + go func() { + defer ga.Done() + ga.WaitOrFail(child) + }() - // Host connects to the child - go func() { - defer ga.Done() - expectedRegex := `serving on` - _, out, err := expectRegexWithOutput(child, expectedRegex) - if err != nil { - ga.Fatalf("Error: %v\nOutput: %v", err, out) - } - body, err := testutils.HTTPGet(httpGetAddr) - if err != nil { - ga.Fatalf("%v\n", err) - } - t.Logf("HTTP-Get received: %s", body) - }() + // Host connects to the child + go func() { + defer ga.Done() + expectedRegex := `serving on` + _, out, err := expectRegexWithOutput(child, expectedRegex) + if err != nil { + ga.Fatalf("Error: %v\nOutput: %v", err, out) + } + body, err := testutils.HTTPGet(httpGetAddr) + if err != nil { + ga.Fatalf("%v\n", err) + } + t.Logf("HTTP-Get received: %s", body) + }() - ga.Wait() - } - f("--net=default-restricted") + ga.Wait() + } + f("--net=default-restricted") + }) } type PortFwdCase struct { @@ -817,18 +821,20 @@ func NewNetOverrideTest() testutils.Test { }) } -func TestNetLongName(t *testing.T) { - nt := networkTemplateT{ - Name: "thisnameiswaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaytoolong", - Type: "ptp", - IpMasq: true, - Ipam: ipamTemplateT{ - Type: "host-local", - Subnet: "11.11.6.0/24", - Routes: []map[string]string{ - {"dst": "0.0.0.0/0"}, +func NewTestNetLongName() testutils.Test { + return testutils.TestFunc(func(t *testing.T) { + nt := networkTemplateT{ + Name: "thisnameiswaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaytoolong", + Type: "ptp", + IpMasq: true, + Ipam: ipamTemplateT{ + Type: "host-local", + Subnet: "11.11.6.0/24", + Routes: []map[string]string{ + {"dst": "0.0.0.0/0"}, + }, }, - }, - } - testNetCustomNatConnectivity(t, nt) + } + testNetCustomNatConnectivity(t, nt) + }) } From 8fe3c158b0a1d38fe65de88e120827b249727233 Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Fri, 27 May 2016 14:21:13 +0200 Subject: [PATCH 0341/1304] networking: use error types to check NS loading --- networking/podenv.go | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/networking/podenv.go b/networking/podenv.go index 2f1a802f2f..c5b5f33226 100644 --- a/networking/podenv.go +++ b/networking/podenv.go @@ -107,17 +107,32 @@ func (e *podEnv) podNSPathLoad() (string, error) { return string(podNSPath), nil } -func (e *podEnv) podNSLoad() (ns.NetNS, error) { - podNSPath, err := e.podNSPathLoad() - if err != nil { - return nil, err +func podNSerrorOK(podNSPath string, err error) bool { + switch err.(type) { + case ns.NSPathNotExistErr: + return true + case ns.NSPathNotNSErr: + return true + + default: + if os.IsNotExist(err) { + return true + } + return false } +} - podNS, err := ns.GetNS(podNSPath) - if err != nil { +func (e *podEnv) podNSLoad() (ns.NetNS, error) { + podNSPath, err := e.podNSPathLoad() + if err != nil && !podNSerrorOK(podNSPath, err) { return nil, err + } else { + podNS, err := ns.GetNS(podNSPath) + if err != nil && !podNSerrorOK(podNSPath, err) { + return nil, err + } + return podNS, nil } - return podNS, nil } func (e *podEnv) podNSPathSave() error { From f09d6a97eaa2968521c421a42aeb08a93124a9ad Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Fri, 27 May 2016 16:50:27 +0200 Subject: [PATCH 0342/1304] tests/kvm: re-enable previously failing cases --- tests/rkt_net_kvm_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/rkt_net_kvm_test.go b/tests/rkt_net_kvm_test.go index 79acb909b8..70fac2773a 100644 --- a/tests/rkt_net_kvm_test.go +++ b/tests/rkt_net_kvm_test.go @@ -28,3 +28,15 @@ func TestNetCustomPtp(t *testing.T) { // PTP means connection Point-To-Point. That is, connections to other pods/containers should be forbidden NewNetCustomPtpTest(false) } + +func TestNetDefaultNetNS(t *testing.T) { + NewTestNetDefaultNetNS().Execute(t) +} + +func TestNetLongName(t *testing.T) { + NewTestNetLongName().Execute(t) +} + +func TestNetDefaultRestrictedConnectivity(t *testing.T) { + NewTestNetDefaultRestrictedConnectivity().Execute(t) +} From 597bb9fc761b88a208cfac88ad874c4f26a30257 Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Fri, 27 May 2016 18:06:11 +0200 Subject: [PATCH 0343/1304] Godeps: fix gopsutil/load reference Per OOB, thanks to the calamity that is GitHub, this inconsistency slipped in as a mix of https://github.com/coreos/rkt/pull/2587/files#diff-681659ab9abb4b4883e78e8aaa980dbaR510 and https://github.com/coreos/rkt/pull/2705/files --- Godeps/Godeps.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 0b561989b4..33473adae4 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -593,8 +593,8 @@ }, { "ImportPath": "github.com/shirou/gopsutil/load", - "Comment": "v2.0.0-10-g9ef3410", - "Rev": "9ef341037b1bcadeeee79e77da4f6baf63de4feb" + "Comment": "v2.0.0", + "Rev": "e8f7a95747d711f34ddfe9dd9b825a84bd059dec" }, { "ImportPath": "github.com/shirou/gopsutil/mem", From be74c323adfa99fd63fd1e29906627b1f7b7a641 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Mon, 30 May 2016 14:44:55 +0200 Subject: [PATCH 0344/1304] Godeps: update appc/docker2aci (0.11.1) and coreos/pkg (v2) --- Godeps/Godeps.json | 50 ++++----- .../backend/repository/repository2.go | 16 ++- .../github.com/appc/docker2aci/lib/version.go | 2 +- .../coreos/pkg/progressutil/iocopy.go | 104 ++++++++++------- .../coreos/pkg/progressutil/progressbar.go | 105 +++++++++++++----- 5 files changed, 179 insertions(+), 98 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 33473adae4..f4fe087376 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,7 +1,7 @@ { "ImportPath": "github.com/coreos/rkt", "GoVersion": "go1.5", - "GodepVersion": "v71", + "GodepVersion": "v72", "Packages": [ "./...", "github.com/appc/spec/actool", @@ -23,53 +23,53 @@ }, { "ImportPath": "github.com/appc/docker2aci/lib", - "Comment": "v0.11.0", - "Rev": "abe598e6384a9978e419a3f43d3e389218407624" + "Comment": "v0.11.1", + "Rev": "355af275fa8d48b4ecdd361a5feaf173abff81e7" }, { "ImportPath": "github.com/appc/docker2aci/lib/common", - "Comment": "v0.11.0", - "Rev": "abe598e6384a9978e419a3f43d3e389218407624" + "Comment": "v0.11.1", + "Rev": "355af275fa8d48b4ecdd361a5feaf173abff81e7" }, { "ImportPath": "github.com/appc/docker2aci/lib/internal", - "Comment": "v0.11.0", - "Rev": "abe598e6384a9978e419a3f43d3e389218407624" + "Comment": "v0.11.1", + "Rev": "355af275fa8d48b4ecdd361a5feaf173abff81e7" }, { "ImportPath": "github.com/appc/docker2aci/lib/internal/backend/file", - "Comment": "v0.11.0", - "Rev": "abe598e6384a9978e419a3f43d3e389218407624" + "Comment": "v0.11.1", + "Rev": "355af275fa8d48b4ecdd361a5feaf173abff81e7" }, { "ImportPath": "github.com/appc/docker2aci/lib/internal/backend/repository", - "Comment": "v0.11.0", - "Rev": "abe598e6384a9978e419a3f43d3e389218407624" + "Comment": "v0.11.1", + "Rev": "355af275fa8d48b4ecdd361a5feaf173abff81e7" }, { "ImportPath": "github.com/appc/docker2aci/lib/internal/docker", - "Comment": "v0.11.0", - "Rev": "abe598e6384a9978e419a3f43d3e389218407624" + "Comment": "v0.11.1", + "Rev": "355af275fa8d48b4ecdd361a5feaf173abff81e7" }, { "ImportPath": "github.com/appc/docker2aci/lib/internal/tarball", - "Comment": "v0.11.0", - "Rev": "abe598e6384a9978e419a3f43d3e389218407624" + "Comment": "v0.11.1", + "Rev": "355af275fa8d48b4ecdd361a5feaf173abff81e7" }, { "ImportPath": "github.com/appc/docker2aci/lib/internal/types", - "Comment": "v0.11.0", - "Rev": "abe598e6384a9978e419a3f43d3e389218407624" + "Comment": "v0.11.1", + "Rev": "355af275fa8d48b4ecdd361a5feaf173abff81e7" }, { "ImportPath": "github.com/appc/docker2aci/lib/internal/util", - "Comment": "v0.11.0", - "Rev": "abe598e6384a9978e419a3f43d3e389218407624" + "Comment": "v0.11.1", + "Rev": "355af275fa8d48b4ecdd361a5feaf173abff81e7" }, { "ImportPath": "github.com/appc/docker2aci/pkg/log", - "Comment": "v0.11.0", - "Rev": "abe598e6384a9978e419a3f43d3e389218407624" + "Comment": "v0.11.1", + "Rev": "355af275fa8d48b4ecdd361a5feaf173abff81e7" }, { "ImportPath": "github.com/appc/goaci/proj2aci", @@ -400,8 +400,8 @@ }, { "ImportPath": "github.com/coreos/pkg/dlopen", - "Comment": "v1", - "Rev": "160ae6282d8c48a33d8c150e4e4817fdef8a5cde" + "Comment": "v2", + "Rev": "7f080b6c11ac2d2347c3cd7521e810207ea1a041" }, { "ImportPath": "github.com/cpuguy83/go-md2man/md2man", @@ -774,8 +774,8 @@ }, { "ImportPath": "github.com/coreos/pkg/progressutil", - "Comment": "v1", - "Rev": "160ae6282d8c48a33d8c150e4e4817fdef8a5cde" + "Comment": "v2", + "Rev": "7f080b6c11ac2d2347c3cd7521e810207ea1a041" }, { "ImportPath": "github.com/klauspost/compress/flate", diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository2.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository2.go index 6a0c8907da..356d6f9bee 100644 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository2.go +++ b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository2.go @@ -26,6 +26,7 @@ import ( "regexp" "strconv" "strings" + "sync" "time" "github.com/appc/docker2aci/lib/common" @@ -76,17 +77,21 @@ func (rb *RepositoryBackend) buildACIV2(layerIDs []string, dockerURL *types.Pars } defer os.RemoveAll(tmpParentDir) - copier := &progressutil.CopyProgressPrinter{} + copier := progressutil.NewCopyProgressPrinter() var errChannels []chan error closers := make([]io.ReadCloser, len(layerIDs)) + var wg sync.WaitGroup for i, layerID := range layerIDs { - errChan := make(chan error) + wg.Add(1) + errChan := make(chan error, 1) errChannels = append(errChannels, errChan) // https://github.com/golang/go/wiki/CommonMistakes i := i // golang-- layerID := layerID go func() { + defer wg.Done() + manifest := rb.imageManifests[*dockerURL] layerIndex, err := getLayerIndex(layerID, manifest) @@ -120,6 +125,8 @@ func (rb *RepositoryBackend) buildACIV2(layerIDs []string, dockerURL *types.Pars errChan <- nil }() } + // Need to wait for all of the readers to be added to the copier (which happens during rb.getLayerV2) + wg.Wait() err = copier.PrintAndWait(os.Stderr, 500*time.Millisecond, nil) if err != nil { return nil, nil, err @@ -332,7 +339,10 @@ func (rb *RepositoryBackend) getLayerV2(layerID string, dockerURL *types.ParsedD return nil, nil, err } - copier.AddCopy(in, name, size, layerFile) + err = copier.AddCopy(in, name, size, layerFile) + if err != nil { + return nil, nil, err + } return layerFile, res.Body, nil } diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/version.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/version.go index f8fe2eba80..487c4bc50e 100644 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/version.go +++ b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/version.go @@ -16,5 +16,5 @@ package docker2aci import "github.com/appc/spec/schema" -var Version = "0.11.0" +var Version = "0.11.1" var AppcVersion = schema.AppContainerVersion diff --git a/Godeps/_workspace/src/github.com/coreos/pkg/progressutil/iocopy.go b/Godeps/_workspace/src/github.com/coreos/pkg/progressutil/iocopy.go index d897dc86b9..04cd0dfa30 100644 --- a/Godeps/_workspace/src/github.com/coreos/pkg/progressutil/iocopy.go +++ b/Godeps/_workspace/src/github.com/coreos/pkg/progressutil/iocopy.go @@ -15,17 +15,21 @@ package progressutil import ( + "errors" "fmt" "io" "sync" "time" ) +var ( + ErrAlreadyStarted = errors.New("cannot add copies after PrintAndWait has been called") +) + type copyReader struct { reader io.Reader current int64 total int64 - done bool pb *ProgressBar } @@ -36,9 +40,6 @@ func (cr *copyReader) Read(p []byte) (int, error) { if err == nil { err = err1 } - if err != nil { - cr.done = true - } return n, err } @@ -52,12 +53,21 @@ func (cr *copyReader) updateProgressBar() error { return cr.pb.SetCurrentProgress(progress) } +// NewCopyProgressPrinter returns a new CopyProgressPrinter +func NewCopyProgressPrinter() *CopyProgressPrinter { + return &CopyProgressPrinter{results: make(chan error), cancel: make(chan struct{})} +} + // CopyProgressPrinter will perform an arbitrary number of io.Copy calls, while // continually printing the progress of each copy. type CopyProgressPrinter struct { - readers []*copyReader - errors []error + results chan error + cancel chan struct{} + + // `lock` mutex protects all fields below it in CopyProgressPrinter struct lock sync.Mutex + readers []*copyReader + started bool pbp *ProgressBarPrinter } @@ -65,8 +75,15 @@ type CopyProgressPrinter struct { // will be made to copy bytes from reader to dest, and name and size will be // used to label the progress bar and display how much progress has been made. // If size is 0, the total size of the reader is assumed to be unknown. -func (cpp *CopyProgressPrinter) AddCopy(reader io.Reader, name string, size int64, dest io.Writer) { +// AddCopy can only be called before PrintAndWait; otherwise, ErrAlreadyStarted +// will be returned. +func (cpp *CopyProgressPrinter) AddCopy(reader io.Reader, name string, size int64, dest io.Writer) error { cpp.lock.Lock() + defer cpp.lock.Unlock() + + if cpp.started { + return ErrAlreadyStarted + } if cpp.pbp == nil { cpp.pbp = &ProgressBarPrinter{} cpp.pbp.PadToBeEven = true @@ -82,60 +99,65 @@ func (cpp *CopyProgressPrinter) AddCopy(reader io.Reader, name string, size int6 cr.pb.SetPrintAfter(cr.formattedProgress()) cpp.readers = append(cpp.readers, cr) - cpp.lock.Unlock() go func() { _, err := io.Copy(dest, cr) - if err != nil { - cpp.lock.Lock() - cpp.errors = append(cpp.errors, err) - cpp.lock.Unlock() + select { + case <-cpp.cancel: + return + case cpp.results <- err: + return } }() + return nil } // PrintAndWait will print the progress for each copy operation added with // AddCopy to printTo every printInterval. This will continue until every added // copy is finished, or until cancel is written to. +// PrintAndWait may only be called once; any subsequent calls will immediately +// return ErrAlreadyStarted. After PrintAndWait has been called, no more +// copies may be added to the CopyProgressPrinter. func (cpp *CopyProgressPrinter) PrintAndWait(printTo io.Writer, printInterval time.Duration, cancel chan struct{}) error { - for { - // If cancel is not nil, see if anything has been written to it. If - // something has, return, otherwise keep drawing. - if cancel != nil { - select { - case <-cancel: - return nil - default: - } - } - - cpp.lock.Lock() - readers := cpp.readers - errors := cpp.errors + cpp.lock.Lock() + if cpp.started { cpp.lock.Unlock() + return ErrAlreadyStarted + } + cpp.started = true + cpp.lock.Unlock() - if len(errors) > 0 { - return errors[0] - } + n := len(cpp.readers) + if n == 0 { + // Nothing to do. + return nil + } - if len(readers) > 0 { + defer close(cpp.cancel) + t := time.NewTicker(printInterval) + allDone := false + for i := 0; i < n; { + select { + case <-cancel: + return nil + case <-t.C: _, err := cpp.pbp.Print(printTo) if err != nil { return err } - } else { - } - - allDone := true - for _, r := range readers { - allDone = allDone && r.done - } - if allDone && len(readers) > 0 { - return nil + case err := <-cpp.results: + i++ + // Once completion is signaled, further on this just drains + // (unlikely) errors from the channel. + if err == nil && !allDone { + allDone, err = cpp.pbp.Print(printTo) + } + if err != nil { + return err + } } - - time.Sleep(printInterval) } + return nil } func (cr *copyReader) formattedProgress() string { diff --git a/Godeps/_workspace/src/github.com/coreos/pkg/progressutil/progressbar.go b/Godeps/_workspace/src/github.com/coreos/pkg/progressutil/progressbar.go index 76d2bff1ca..224c124acd 100644 --- a/Godeps/_workspace/src/github.com/coreos/pkg/progressutil/progressbar.go +++ b/Godeps/_workspace/src/github.com/coreos/pkg/progressutil/progressbar.go @@ -38,13 +38,33 @@ var ( // be created directly, use the AddProgressBar on a ProgressBarPrinter to // create these. type ProgressBar struct { + lock sync.Mutex + currentProgress float64 printBefore string printAfter string - lock sync.Mutex done bool } +func (pb *ProgressBar) clone() *ProgressBar { + pb.lock.Lock() + pbClone := &ProgressBar{ + currentProgress: pb.currentProgress, + printBefore: pb.printBefore, + printAfter: pb.printAfter, + done: pb.done, + } + pb.lock.Unlock() + return pbClone +} + +func (pb *ProgressBar) GetCurrentProgress() float64 { + pb.lock.Lock() + val := pb.currentProgress + pb.lock.Unlock() + return val +} + // SetCurrentProgress sets the progress of this ProgressBar. The progress must // be between 0 and 1 inclusive. func (pb *ProgressBar) SetCurrentProgress(progress float64) error { @@ -57,6 +77,29 @@ func (pb *ProgressBar) SetCurrentProgress(progress float64) error { return nil } +// GetDone returns whether or not this progress bar is done +func (pb *ProgressBar) GetDone() bool { + pb.lock.Lock() + val := pb.done + pb.lock.Unlock() + return val +} + +// SetDone sets whether or not this progress bar is done +func (pb *ProgressBar) SetDone(val bool) { + pb.lock.Lock() + pb.done = val + pb.lock.Unlock() +} + +// GetPrintBefore gets the text printed on the line before the progress bar. +func (pb *ProgressBar) GetPrintBefore() string { + pb.lock.Lock() + val := pb.printBefore + pb.lock.Unlock() + return val +} + // SetPrintBefore sets the text printed on the line before the progress bar. func (pb *ProgressBar) SetPrintBefore(before string) { pb.lock.Lock() @@ -64,6 +107,14 @@ func (pb *ProgressBar) SetPrintBefore(before string) { pb.lock.Unlock() } +// GetPrintAfter gets the text printed on the line after the progress bar. +func (pb *ProgressBar) GetPrintAfter() string { + pb.lock.Lock() + val := pb.printAfter + pb.lock.Unlock() + return val +} + // SetPrintAfter sets the text printed on the line after the progress bar. func (pb *ProgressBar) SetPrintAfter(after string) { pb.lock.Lock() @@ -74,6 +125,8 @@ func (pb *ProgressBar) SetPrintAfter(after string) { // ProgressBarPrinter will print out the progress of some number of // ProgressBars. type ProgressBarPrinter struct { + lock sync.Mutex + // DisplayWidth can be set to influence how large the progress bars are. // The bars will be scaled to attempt to produce lines of this number of // characters, but lines of different lengths may still be printed. When @@ -85,7 +138,8 @@ type ProgressBarPrinter struct { PadToBeEven bool numLinesInLastPrint int progressBars []*ProgressBar - lock sync.Mutex + maxBefore int + maxAfter int } // AddProgressBar will create a new ProgressBar, register it with this @@ -107,7 +161,10 @@ func (pbp *ProgressBarPrinter) AddProgressBar() *ProgressBar { // the previously printed bars. func (pbp *ProgressBarPrinter) Print(printTo io.Writer) (bool, error) { pbp.lock.Lock() - bars := pbp.progressBars + var bars []*ProgressBar + for _, bar := range pbp.progressBars { + bars = append(bars, bar.clone()) + } numColumns := pbp.DisplayWidth pbp.lock.Unlock() @@ -123,29 +180,25 @@ func (pbp *ProgressBarPrinter) Print(printTo io.Writer) (bool, error) { moveCursorUp(printTo, pbp.numLinesInLastPrint) } - maxBefore := 0 - maxAfter := 0 for _, bar := range bars { - bar.lock.Lock() - beforeSize := len(bar.printBefore) - afterSize := len(bar.printAfter) - bar.lock.Unlock() - if beforeSize > maxBefore { - maxBefore = beforeSize + beforeSize := len(bar.GetPrintBefore()) + afterSize := len(bar.GetPrintAfter()) + if beforeSize > pbp.maxBefore { + pbp.maxBefore = beforeSize } - if afterSize > maxAfter { - maxAfter = afterSize + if afterSize > pbp.maxAfter { + pbp.maxAfter = afterSize } } - allDone := false + allDone := true for _, bar := range bars { if isTerminal(printTo) { - bar.printToTerminal(printTo, numColumns, pbp.PadToBeEven, maxBefore, maxAfter) + bar.printToTerminal(printTo, numColumns, pbp.PadToBeEven, pbp.maxBefore, pbp.maxAfter) } else { bar.printToNonTerminal(printTo) } - allDone = allDone || bar.currentProgress == 1 + allDone = allDone && bar.GetCurrentProgress() == 1 } pbp.numLinesInLastPrint = len(bars) @@ -161,9 +214,8 @@ func moveCursorUp(printTo io.Writer, numLines int) { } func (pb *ProgressBar) printToTerminal(printTo io.Writer, numColumns int, padding bool, maxBefore, maxAfter int) { - pb.lock.Lock() - before := pb.printBefore - after := pb.printAfter + before := pb.GetPrintBefore() + after := pb.GetPrintAfter() if padding { before = before + strings.Repeat(" ", maxBefore-len(before)) @@ -173,29 +225,26 @@ func (pb *ProgressBar) printToTerminal(printTo io.Writer, numColumns int, paddin progressBarSize := numColumns - (len(fmt.Sprintf("%s [] %s", before, after))) progressBar := "" if progressBarSize > 0 { - currentProgress := int(pb.currentProgress * float64(progressBarSize)) + currentProgress := int(pb.GetCurrentProgress() * float64(progressBarSize)) progressBar = fmt.Sprintf("[%s%s] ", strings.Repeat("=", currentProgress), strings.Repeat(" ", progressBarSize-currentProgress)) } else { // If we can't fit the progress bar, better to not pad the before/after. - before = pb.printBefore - after = pb.printAfter + before = pb.GetPrintBefore() + after = pb.GetPrintAfter() } fmt.Fprintf(printTo, "%s %s%s\n", before, progressBar, after) - pb.lock.Unlock() } func (pb *ProgressBar) printToNonTerminal(printTo io.Writer) { - pb.lock.Lock() - if !pb.done { + if !pb.GetDone() { fmt.Fprintf(printTo, "%s %s\n", pb.printBefore, pb.printAfter) - if pb.currentProgress == 1 { - pb.done = true + if pb.GetCurrentProgress() == 1 { + pb.SetDone(true) } } - pb.lock.Unlock() } // isTerminal returns True when w is going to a tty, and false otherwise. From 9549a059c85915f1136a4ce1e7fdd7b8cf25fd08 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Fri, 27 May 2016 17:48:18 +0200 Subject: [PATCH 0345/1304] version: bump to v1.7.0 --- CHANGELOG.md | 38 +++++++++++++++++++++++++ Documentation/getting-started-ubuntu.md | 6 ++-- Documentation/running-fly-stage1.md | 4 +-- Documentation/running-lkvm-stage1.md | 4 +-- Documentation/subcommands/prepare.md | 2 +- Documentation/subcommands/version.md | 2 +- Documentation/trying-out-rkt.md | 6 ++-- ROADMAP.md | 9 +++--- configure.ac | 2 +- scripts/acbuild-rkt-builder.sh | 2 +- scripts/build-rir.sh | 2 +- stage1/aci/aci-manifest.in | 2 +- tests/empty-image/manifest | 2 +- tests/image/manifest | 2 +- tests/rkt_exec_test.go | 2 +- tests/rkt_image_cat_manifest_test.go | 2 +- tests/rkt_image_export_test.go | 2 +- tests/rkt_image_render_test.go | 2 +- tests/rkt_os_arch_test.go | 2 +- 19 files changed, 66 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2abcde86f0..44ea24ac44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,41 @@ +## v1.7.0 + +This release introduces some new security features, including a "no-new-privileges" isolator and initial (partial) restrictions on /proc and /sys access. +Cgroups handling has also been improved with regards to setup and cleaning. Many bugfixes and new documentation are included too. + +#### New features and UX changes + +- stage1: implement no-new-privs linux isolator ([#2677](https://github.com/coreos/rkt/pull/2677)). +- stage0: disable OverlayFS by default when working on ZFS ([#2600](https://github.com/coreos/rkt/pull/2600)). +- stage1: (partially) restrict access to procfs and sysfs paths ([#2683](https://github.com/coreos/rkt/pull/2683)). +- stage1: clean up pod cgroups on GC ([#2655](https://github.com/coreos/rkt/pull/2655)). +- stage1/prepare-app: don't mount /sys/fs/cgroup in stage2 ([#2681](https://github.com/coreos/rkt/pull/2681)). +- stage0: complain and abort on conflicting CLI flags ([#2666](https://github.com/coreos/rkt/pull/2666)). +- stage1: update CoreOS image signing key ([#2659](https://github.com/coreos/rkt/pull/2659)). +- api_service: Implement GetLogs RPC request ([#2662](https://github.com/coreos/rkt/pull/2662)). +- networking: update to CNI v0.3.0 ([#3696](https://github.com/coreos/rkt/pull/2696)). + +#### Bug fixes + +- api: fix image size reporting ([#2501](https://github.com/coreos/rkt/pull/2501)). +- build: fix build failures on manpages/bash-completion target due to missing GOPATH ([#2646](https://github.com/coreos/rkt/pull/2646)). +- dist: fix "other" permissions so rkt list can work without root/rkt-admin ([#2698](https://github.com/coreos/rkt/pull/2698)). +- kvm: fix logging network plugin type ([#2635](https://github.com/coreos/rkt/pull/2635)). +- kvm: transform flannel network to allow teardown ([#2647](https://github.com/coreos/rkt/pull/2647)). +- rkt: fix panic on rm a non-existing pod with uuid-file ([#2679](https://github.com/coreos/rkt/pull/2679)). +- stage1/init: work around `cgroup/SCM_CREDENTIALS` race ([#2645](https://github.com/coreos/rkt/pull/2645)). +- gc: mount stage1 on GC ([#2704](https://github.com/coreos/rkt/pull/2704)). +- stage1: fix network files leak on GC ([#2319](https://github.com/coreos/rkt/issues/2319)). + +#### Other changes + +- deps: remove unused dependencies ([#2703](https://github.com/coreos/rkt/pull/2703)). +- deps: appc/spec, k8s, protobuf updates ([#2697](https://github.com/coreos/rkt/pull/2697)). +- deps: use tagged release of github.com/shirou/gopsutil ([#2705](https://github.com/coreos/rkt/pull/2705)). +- deps: bump docker2aci to v0.11.1 ([#2719](https://github.com/coreos/rkt/pull/2719)). +- Documentation updates ([#2620](https://github.com/coreos/rkt/pull/2620), [#2700](https://github.com/coreos/rkt/pull/2700), [#2637](https://github.com/coreos/rkt/pull/2637), [#2591](https://github.com/coreos/rkt/pull/2591), [#2651](https://github.com/coreos/rkt/pull/2651), [#2699](https://github.com/coreos/rkt/pull/2699), [#2631](https://github.com/coreos/rkt/pull/2631)). +- Test improvements ([#2587](https://github.com/coreos/rkt/pull/2587), [#2656](https://github.com/coreos/rkt/pull/2656), [#2676](https://github.com/coreos/rkt/pull/2676), [#2554](https://github.com/coreos/rkt/pull/2554), [#2690](https://github.com/coreos/rkt/pull/2690), [#2674](https://github.com/coreos/rkt/pull/2674), [#2665](https://github.com/coreos/rkt/pull/2665), [#2649](https://github.com/coreos/rkt/pull/2649), [#2643](https://github.com/coreos/rkt/pull/2643), [#2637](https://github.com/coreos/rkt/pull/2637), [#2633](https://github.com/coreos/rkt/pull/2633)). + ## v1.6.0 This release focuses on security enhancements. It provides additional isolators, creating a new mount namespace per app. Also a new version of CoreOS 1032.0.0 with systemd v229 is being used in stage1. diff --git a/Documentation/getting-started-ubuntu.md b/Documentation/getting-started-ubuntu.md index 73bbaec11b..413d3b1c97 100644 --- a/Documentation/getting-started-ubuntu.md +++ b/Documentation/getting-started-ubuntu.md @@ -15,9 +15,9 @@ vagrant up --provider virtualbox vagrant ssh sudo -s -wget https://github.com/coreos/rkt/releases/download/v1.6.0/rkt-v1.6.0.tar.gz -tar xzvf rkt-v1.6.0.tar.gz -cd rkt-v1.6.0 +wget https://github.com/coreos/rkt/releases/download/v1.7.0/rkt-v1.7.0.tar.gz +tar xzvf rkt-v1.7.0.tar.gz +cd rkt-v1.7.0 ./rkt help ``` diff --git a/Documentation/running-fly-stage1.md b/Documentation/running-fly-stage1.md index 1d145e8031..8b4b0378f0 100644 --- a/Documentation/running-fly-stage1.md +++ b/Documentation/running-fly-stage1.md @@ -60,14 +60,14 @@ $ ./autogen.sh && ./configure --with-stage1-flavors=fly && make ``` For more details about configure parameters, see the [configure script parameters documentation](build-configure.md). -This will build the rkt binary and the stage1-fly.aci in `build-rkt-1.6.0+git/bin/`. +This will build the rkt binary and the stage1-fly.aci in `build-rkt-1.7.0+git/bin/`. ### Selecting stage1 at runtime Here is a quick example of how to use a container with the official fly stage1: ``` -# rkt run --stage1-name=coreos.com/rkt/stage1-fly:1.6.0 coreos.com/etcd:v2.2.5 +# rkt run --stage1-name=coreos.com/rkt/stage1-fly:1.7.0 coreos.com/etcd:v2.2.5 ``` If the image is not in the store, `--stage1-name` will perform discovery and fetch the image. diff --git a/Documentation/running-lkvm-stage1.md b/Documentation/running-lkvm-stage1.md index d75391b533..01c5a5b7ac 100644 --- a/Documentation/running-lkvm-stage1.md +++ b/Documentation/running-lkvm-stage1.md @@ -13,7 +13,7 @@ $ ./autogen.sh && ./configure --with-stage1-flavors=kvm && make ``` For more details about configure parameters, see [configure script parameters documentation](build-configure.md). -This will build the rkt binary and the LKVM stage1-kvm.aci in `build-rkt-1.6.0+git/bin/`. +This will build the rkt binary and the LKVM stage1-kvm.aci in `build-rkt-1.7.0+git/bin/`. Provided you have hardware virtualization support and the [kernel KVM module](http://www.linux-kvm.org/page/Getting_the_kvm_kernel_modules) loaded (refer to your distribution for instructions), you can then run an image like you would normally do with rkt: @@ -84,7 +84,7 @@ If you want to run software that requires hypervisor isolation along with truste For example, to use the official lkvm stage1: ``` -# rkt run --stage1-name=coreos.com/rkt/stage1-kvm:1.6.0 coreos.com/etcd:v2.0.9 +# rkt run --stage1-name=coreos.com/rkt/stage1-kvm:1.7.0 coreos.com/etcd:v2.0.9 ... ``` diff --git a/Documentation/subcommands/prepare.md b/Documentation/subcommands/prepare.md index 5e55a81f8c..2791f20968 100644 --- a/Documentation/subcommands/prepare.md +++ b/Documentation/subcommands/prepare.md @@ -14,7 +14,7 @@ Therefore, the supported arguments are mostly the same as in `run` except runtim ``` # rkt prepare coreos.com/etcd:v2.0.10 rkt prepare coreos.com/etcd:v2.0.10 -rkt: using image from local store for image name coreos.com/rkt/stage1-coreos:1.6.0 +rkt: using image from local store for image name coreos.com/rkt/stage1-coreos:1.7.0 rkt: searching for app image coreos.com/etcd:v2.0.10 rkt: remote fetching from url https://github.com/coreos/etcd/releases/download/v2.0.10/etcd-v2.0.10-linux-amd64.aci prefix: "coreos.com/etcd" diff --git a/Documentation/subcommands/version.md b/Documentation/subcommands/version.md index 56b5c9c937..d23ae66475 100644 --- a/Documentation/subcommands/version.md +++ b/Documentation/subcommands/version.md @@ -6,7 +6,7 @@ This command prints the rkt version, the appc version rkt is built against, and ``` $ rkt version -rkt Version: 1.6.0 +rkt Version: 1.7.0 appc Version: 0.7.4 Go Version: go1.5.3 Go OS/Arch: linux/amd64 diff --git a/Documentation/trying-out-rkt.md b/Documentation/trying-out-rkt.md index 96736c4aa1..dec49926d4 100644 --- a/Documentation/trying-out-rkt.md +++ b/Documentation/trying-out-rkt.md @@ -10,9 +10,9 @@ rkt consists of a single CLI tool, and is currently supported on amd64 Linux. A To download the rkt binary, simply grab the latest release directly from GitHub: ``` -wget https://github.com/coreos/rkt/releases/download/v1.6.0/rkt-v1.6.0.tar.gz -tar xzvf rkt-v1.6.0.tar.gz -cd rkt-v1.6.0 +wget https://github.com/coreos/rkt/releases/download/v1.7.0/rkt-v1.7.0.tar.gz +tar xzvf rkt-v1.7.0.tar.gz +cd rkt-v1.7.0 ./rkt help ``` diff --git a/ROADMAP.md b/ROADMAP.md index d04c5ab900..a5e9422d2b 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -9,13 +9,10 @@ The version of the spec that rkt implements can be seen in the output of `rkt ve rkt's version 1.0 release marks the command line user interface and on-disk data structures as stable and reliable for external development. The (optional) API for pod inspection is not yet completely stabilized, but is quite usable. -### rkt 1.7 (May) - -- enhanced DNS configuration [#2044](https://github.com/coreos/rkt/issues/2044) -- app-level seccomp support [#1614](https://github.com/coreos/rkt/issues/1614) ### rkt 1.8 (June) +- app-level seccomp support [#1614](https://github.com/coreos/rkt/issues/1614) - stable gRPC [API](https://github.com/coreos/rkt/tree/master/api/v1alpha) - IPv6 support [appc/cni#31](https://github.com/appc/cni/issues/31) - full integration with Kubernetes (aka "rktnetes") @@ -25,3 +22,7 @@ rkt's version 1.0 release marks the command line user interface and on-disk data - packaged for more distributions - CentOS [#1305](https://github.com/coreos/rkt/issues/1305) - user configuration for stage1 [#2013](https://github.com/coreos/rkt/issues/2013) + +### rkt 1.9 (June) + +- enhanced DNS configuration [#2044](https://github.com/coreos/rkt/issues/2044) diff --git a/configure.ac b/configure.ac index 8fe006bde7..5f547b31b1 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.63]) -AC_INIT([rkt], [1.6.0+git], [https://github.com/coreos/rkt/issues]) +AC_INIT([rkt], [1.7.0], [https://github.com/coreos/rkt/issues]) AC_DEFUN([RKT_CHECK_PROG], [AS_VAR_IF([$1], [], diff --git a/scripts/acbuild-rkt-builder.sh b/scripts/acbuild-rkt-builder.sh index 41eabfa9f7..d39f925e59 100755 --- a/scripts/acbuild-rkt-builder.sh +++ b/scripts/acbuild-rkt-builder.sh @@ -17,7 +17,7 @@ fi MODIFY=${MODIFY:-""} FLAGS=${FLAGS:-""} IMG_NAME="coreos.com/rkt/builder" -IMG_VERSION=${VERSION:-"v1.6.0+git"} +IMG_VERSION=${VERSION:-"v1.7.0"} ACI_FILE=rkt-builder.aci BUILDDIR=/opt/build-rkt SRC_DIR=/opt/rkt diff --git a/scripts/build-rir.sh b/scripts/build-rir.sh index 6f771b6bda..117190119f 100755 --- a/scripts/build-rir.sh +++ b/scripts/build-rir.sh @@ -4,7 +4,7 @@ set -xe SRC_DIR="${SRC_DIR:-$PWD}" BUILDDIR="${BUILDDIR:-$PWD/build-rir}" -RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.6.0+git}" +RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.7.0}" mkdir -p $BUILDDIR diff --git a/stage1/aci/aci-manifest.in b/stage1/aci/aci-manifest.in index bca4bce96d..b9e7b1a3dc 100644 --- a/stage1/aci/aci-manifest.in +++ b/stage1/aci/aci-manifest.in @@ -1,6 +1,6 @@ { "acKind": "ImageManifest", - "acVersion": "0.7.4", + "acVersion": "0.8.4", "name": "@RKT_STAGE1_NAME@", "labels": [ { diff --git a/tests/empty-image/manifest b/tests/empty-image/manifest index 7ef4622e87..9e3ee0a986 100644 --- a/tests/empty-image/manifest +++ b/tests/empty-image/manifest @@ -5,7 +5,7 @@ "labels": [ { "name": "version", - "value": "1.6.0" + "value": "1.7.0" }, { "name": "arch", diff --git a/tests/image/manifest b/tests/image/manifest index d4abdfe4dc..228c2ce830 100644 --- a/tests/image/manifest +++ b/tests/image/manifest @@ -5,7 +5,7 @@ "labels": [ { "name": "version", - "value": "1.6.0" + "value": "1.7.0" }, { "name": "arch", diff --git a/tests/rkt_exec_test.go b/tests/rkt_exec_test.go index b9e3be307d..b3c8c0224b 100644 --- a/tests/rkt_exec_test.go +++ b/tests/rkt_exec_test.go @@ -26,7 +26,7 @@ import ( ) const ( - noappManifestStr = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"coreos.com/rkt-inspect","labels":[{"name":"version","value":"1.6.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}]}` + noappManifestStr = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"coreos.com/rkt-inspect","labels":[{"name":"version","value":"1.7.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}]}` ) func TestRunOverrideExec(t *testing.T) { diff --git a/tests/rkt_image_cat_manifest_test.go b/tests/rkt_image_cat_manifest_test.go index 9831833c66..5ec32f02c9 100644 --- a/tests/rkt_image_cat_manifest_test.go +++ b/tests/rkt_image_cat_manifest_test.go @@ -29,7 +29,7 @@ import ( const ( // The expected image manifest of the 'rkt-inspect-image-cat-manifest.aci'. - manifestTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.6.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.7.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageCatManifest tests 'rkt image cat-manifest', it will: diff --git a/tests/rkt_image_export_test.go b/tests/rkt_image_export_test.go index 80a203961b..eb4adcdf85 100644 --- a/tests/rkt_image_export_test.go +++ b/tests/rkt_image_export_test.go @@ -28,7 +28,7 @@ import ( ) const ( - manifestExportTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.6.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestExportTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.7.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageExport tests 'rkt image export', it will import some existing diff --git a/tests/rkt_image_render_test.go b/tests/rkt_image_render_test.go index 191b7d6388..d86a9cb711 100644 --- a/tests/rkt_image_render_test.go +++ b/tests/rkt_image_render_test.go @@ -28,7 +28,7 @@ import ( ) const ( - manifestRenderTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.6.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"dependencies":[{"imageName":"coreos.com/rkt-inspect"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestRenderTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.7.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"dependencies":[{"imageName":"coreos.com/rkt-inspect"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageRender tests 'rkt image render', it will import some existing empty diff --git a/tests/rkt_os_arch_test.go b/tests/rkt_os_arch_test.go index 172a80d74e..357ee15c20 100644 --- a/tests/rkt_os_arch_test.go +++ b/tests/rkt_os_arch_test.go @@ -27,7 +27,7 @@ import ( ) const ( - manifestOSArchTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.6.0"}ARCH_OS],"app":{"exec":["/inspect", "--print-msg=HelloWorld"],"user":"0","group":"0","workingDirectory":"/"}}` + manifestOSArchTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.7.0"}ARCH_OS],"app":{"exec":["/inspect", "--print-msg=HelloWorld"],"user":"0","group":"0","workingDirectory":"/"}}` ) type osArchTest struct { From 74424a0cd730a7548560b600cc1baa719efffe45 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Fri, 27 May 2016 17:48:19 +0200 Subject: [PATCH 0346/1304] version: bump to v1.7.0+git --- configure.ac | 2 +- scripts/acbuild-rkt-builder.sh | 2 +- scripts/build-rir.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 5f547b31b1..a65bdd62f1 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.63]) -AC_INIT([rkt], [1.7.0], [https://github.com/coreos/rkt/issues]) +AC_INIT([rkt], [1.7.0+git], [https://github.com/coreos/rkt/issues]) AC_DEFUN([RKT_CHECK_PROG], [AS_VAR_IF([$1], [], diff --git a/scripts/acbuild-rkt-builder.sh b/scripts/acbuild-rkt-builder.sh index d39f925e59..9b66b9c421 100755 --- a/scripts/acbuild-rkt-builder.sh +++ b/scripts/acbuild-rkt-builder.sh @@ -17,7 +17,7 @@ fi MODIFY=${MODIFY:-""} FLAGS=${FLAGS:-""} IMG_NAME="coreos.com/rkt/builder" -IMG_VERSION=${VERSION:-"v1.7.0"} +IMG_VERSION=${VERSION:-"v1.7.0+git"} ACI_FILE=rkt-builder.aci BUILDDIR=/opt/build-rkt SRC_DIR=/opt/rkt diff --git a/scripts/build-rir.sh b/scripts/build-rir.sh index 117190119f..fa5d54e35d 100755 --- a/scripts/build-rir.sh +++ b/scripts/build-rir.sh @@ -4,7 +4,7 @@ set -xe SRC_DIR="${SRC_DIR:-$PWD}" BUILDDIR="${BUILDDIR:-$PWD/build-rir}" -RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.7.0}" +RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.7.0+git}" mkdir -p $BUILDDIR From fa90728abf1e8cb8c4c50304d1a08956075ac9f2 Mon Sep 17 00:00:00 2001 From: Piotr Skamruk Date: Fri, 27 May 2016 13:01:11 +0200 Subject: [PATCH 0347/1304] kvm: add proxy arp support to macvtap --- networking/kvm.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/networking/kvm.go b/networking/kvm.go index e57cc99d91..1dd0c5bedb 100644 --- a/networking/kvm.go +++ b/networking/kvm.go @@ -31,6 +31,7 @@ import ( "github.com/containernetworking/cni/pkg/ip" cnitypes "github.com/containernetworking/cni/pkg/types" cniutils "github.com/containernetworking/cni/pkg/utils" + cnisysctl "github.com/containernetworking/cni/pkg/utils/sysctl" "github.com/hashicorp/errwrap" "github.com/vishvananda/netlink" @@ -78,6 +79,10 @@ type MacVTapNetConf struct { Mode string `json:"mode"` } +const ( + IPv4InterfaceArpProxySysctlTemplate = "net.ipv4.conf.%s.proxy_arp" +) + // setupTapDevice creates persistent macvtap device // and returns a newly created netlink.Link structure // using part of pod hash and interface number in interface name @@ -120,6 +125,15 @@ func setupMacVTapDevice(podID types.UUID, config MacVTapNetConf, interfaceNumber if err := netlink.LinkAdd(link); err != nil { return nil, errwrap.Wrap(errors.New("cannot create macvtap interface"), err) } + + // TODO: duplicate following lines for ipv6 support, when it will be added in other places + ipv4SysctlValueName := fmt.Sprintf(IPv4InterfaceArpProxySysctlTemplate, interfaceName) + if _, err := cnisysctl.Sysctl(ipv4SysctlValueName, "1"); err != nil { + // remove the newly added link and ignore errors, because we already are in a failed state + _ = netlink.LinkDel(link) + return nil, errwrap.Wrap(fmt.Errorf("failed to set proxy_arp on newly added interface %q", interfaceName), err) + } + if err := netlink.LinkSetUp(link); err != nil { // remove the newly added link and ignore errors, because we already are in a failed state _ = netlink.LinkDel(link) From ad0c46dc744adb6544f02efe0c2658e1233cc32f Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Tue, 31 May 2016 11:24:29 +0200 Subject: [PATCH 0348/1304] MAINTAINERS: add Piotr Skamruk (@jellonek) Piotr has provided invaluable contributions to the project, mostly around the KVM stage1 but also more generally. This proposes adding him as a maintainer of all KVM-related areas. This format is taken straight from https://github.com/coreos/etcd/blob/master/MAINTAINERS but open to better suggestions. I don't think it's necessary yet to go to a fully structured approach (i.e. human parseable is fine for now). --- MAINTAINERS | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 1df9151f47..f05557c361 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1,12 +1,15 @@ -Alban Crequy (@alban) -Brandon Philips (@philips) -Derek Gonyeo (@dgonyeo) -Iago López Galeiras (@iaguis) -Jonathan Boulle (@jonboulle) -Krzesimir Nowak (@krnowak) -Luca Bruno (@lucab) -Sergiusz Urbaniak (@s-urbaniak) -Stefan Junker (@steveeJ) -Tamer Tas (@tmrts) -Vito Caputo (@vcaputo) -Yifan Gu (@yifan-gu) +Alban Crequy (@alban) pkg: * +Brandon Philips (@philips) pkg: * +Derek Gonyeo (@dgonyeo) pkg: * +Euan Kemp (@euank) pkg: * +Iago López Galeiras (@iaguis) pkg: * +Jonathan Boulle (@jonboulle) pkg: * +Krzesimir Nowak (@krnowak) pkg: * +Luca Bruno (@lucab) pkg: * +Sergiusz Urbaniak (@s-urbaniak) pkg: * +Stefan Junker (@steveeJ) pkg: * +Tamer Tas (@tmrts) pkg: * +Vito Caputo (@vcaputo) pkg: * +Yifan Gu (@yifan-gu) pkg: * + +Piotr Skamruk (@jellonek) pkg: *kvm* From e1b3a1b04ee4c49b40d8b650dc72406d16fc67cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Tue, 31 May 2016 13:24:28 +0200 Subject: [PATCH 0349/1304] functional tests: print details on check-cgroup error --- tests/inspect/inspect.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/inspect/inspect.go b/tests/inspect/inspect.go index 6b66e80d9d..5899fb0218 100644 --- a/tests/inspect/inspect.go +++ b/tests/inspect/inspect.go @@ -380,7 +380,7 @@ func main() { for _, p := range testPaths { if err := syscall.Mkdir(filepath.Join(p, "test"), 0600); err == nil || err != syscall.EROFS { - fmt.Println("check-cgroups: FAIL") + fmt.Fprintf(os.Stderr, "check-cgroups: FAIL (%v)", err) os.Exit(1) } } From 6fa67781a0eaf732350c2023dd0c396becc827ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Tue, 31 May 2016 13:54:21 +0200 Subject: [PATCH 0350/1304] functional tests: fix check-cgroup on inspect We're not mounting `/sys/fs/cgroup` on stage2 anymore so this check doesn't make sense. Let's just check on `/proc/1/root/sys/fs/cgroup/...`. --- tests/inspect/inspect.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/inspect/inspect.go b/tests/inspect/inspect.go index 5899fb0218..b8140233e2 100644 --- a/tests/inspect/inspect.go +++ b/tests/inspect/inspect.go @@ -371,10 +371,10 @@ func main() { testPaths := []string{rootCgroupPath} // test a couple of controllers if they're available - if cgroup.IsIsolatorSupported("memory") { + if _, err := os.Stat(filepath.Join(rootCgroupPath, "memory")); err == nil { testPaths = append(testPaths, filepath.Join(rootCgroupPath, "memory")) } - if cgroup.IsIsolatorSupported("cpu") { + if _, err := os.Stat(filepath.Join(rootCgroupPath, "cpu")); err == nil { testPaths = append(testPaths, filepath.Join(rootCgroupPath, "cpu")) } From 9f8471640c31bbf7b6384555b8c6d881abed75fe Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Tue, 31 May 2016 11:26:28 +0200 Subject: [PATCH 0351/1304] MAINTAINERS: remove @vcaputo for now Vito is not currently actively working on the project so remove him for now. He'll be gladly welcomed back as a maintainer at any time if he wishes to resume involvement. --- MAINTAINERS | 1 - 1 file changed, 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index f05557c361..c99999bc20 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9,7 +9,6 @@ Luca Bruno (@lucab) pkg: * Sergiusz Urbaniak (@s-urbaniak) pkg: * Stefan Junker (@steveeJ) pkg: * Tamer Tas (@tmrts) pkg: * -Vito Caputo (@vcaputo) pkg: * Yifan Gu (@yifan-gu) pkg: * Piotr Skamruk (@jellonek) pkg: *kvm* From d2c085c4827195f54c30599dd1c3b680adcd0d41 Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Tue, 31 May 2016 13:34:24 +0200 Subject: [PATCH 0352/1304] MAINTAINERS: update Krzesimir's email address --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index c99999bc20..18df4b9f75 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4,7 +4,7 @@ Derek Gonyeo (@dgonyeo) pkg: * Euan Kemp (@euank) pkg: * Iago López Galeiras (@iaguis) pkg: * Jonathan Boulle (@jonboulle) pkg: * -Krzesimir Nowak (@krnowak) pkg: * +Krzesimir Nowak (@krnowak) pkg: * Luca Bruno (@lucab) pkg: * Sergiusz Urbaniak (@s-urbaniak) pkg: * Stefan Junker (@steveeJ) pkg: * From c8ed37e883df0fe40a146e43d40925c361950f79 Mon Sep 17 00:00:00 2001 From: Josh Wood Date: Tue, 31 May 2016 14:27:59 -0700 Subject: [PATCH 0353/1304] Documentation: Fix issues from downstream: fmt and link - Fix formatting of code blocks and lists in capabilities doc - Fix broken link to networking/overview. --- Documentation/capabilities-guide.md | 36 ++++++++++++++++------------- Documentation/subcommands/run.md | 2 +- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Documentation/capabilities-guide.md b/Documentation/capabilities-guide.md index 5ca541aec0..4dec8194cd 100644 --- a/Documentation/capabilities-guide.md +++ b/Documentation/capabilities-guide.md @@ -24,8 +24,9 @@ Once running, each process has a bounding set of capabilities which it can enable and use; such process cannot get further capabilities outside of this set. In the context of containers, capabilities are useful for: - * restricting the effective privileges of applications running as root - * allowing applications to perform specific privileged operations, without + +* Restricting the effective privileges of applications running as root +* Allowing applications to perform specific privileged operations, without having to run them as root For the complete list of existing Linux capabilities and a detailed description @@ -36,7 +37,7 @@ of this security mechanism, see [capabilities(7)](http://man7.org/linux/man-page By default, rkt enforces [a default set of capabilities](https://github.com/appc/spec/blob/master/spec/ace.md#oslinuxcapabilities-remove-set) onto applications. -This default set is tailored to stop applications from performing a large +This default set is tailored to stop applications from performing a large variety of privileged actions, while not impacting their normal behavior. Operations which are typically not needed in containers and which may impact host state, eg. invoking `reboot(2)`, are denied in this way. @@ -50,12 +51,13 @@ of the customizable isolators available in rkt. When running Linux containers, rkt provides two mutually exclusive isolators to define the bounding set under which an application will be run: - * `os/linux/capabilities-retain-set` - * `os/linux/capabilities-remove-set` + +* `os/linux/capabilities-retain-set` +* `os/linux/capabilities-remove-set` Those isolators cover different use-cases and employ different techniques to achieve the same goal of limiting available capabilities. As such, they cannot -be used together at the same time, and recommended usage varies on a +be used together at the same time, and recommended usage varies on a case-by-case basis. As the granularity of capabilities varies for specific permission cases, a word @@ -69,12 +71,12 @@ Many other ways to maliciously transition across capabilities have already been ### Retain-set -`os/linux/capabilities-retain-set` allows for an additive approach to +`os/linux/capabilities-retain-set` allows for an additive approach to capabilities: applications will be stripped of all capabilities, except the ones listed in this isolator. This whitelisting approach is useful for completely locking down environments -and whenever application requirements (in terms of capabilities) are +and whenever application requirements (in terms of capabilities) are well-defined in advance. It allows one to ensure that exactly and only the specified capabilities could ever be used. @@ -84,7 +86,7 @@ its "retain-set". ### Remove-set -`os/linux/capabilities-remove-set` tackles capabilities in a subtractive way: +`os/linux/capabilities-remove-set` tackles capabilities in a subtractive way: starting from the default set of capabilities, single entries can be further forbidden in order to prevent specific actions. @@ -92,7 +94,7 @@ This blacklisting approach is useful to somehow limit applications which have broad requirements in terms of privileged operations, in order to deny some potentially malicious operations. -For example, an application that will need to perform multiple privileged +For example, an application that will need to perform multiple privileged operations but is known to never open a raw socket, will have `CAP_NET_RAW` specified in its "remove-set". @@ -105,12 +107,12 @@ CoreOS which ships with `ping` and `nc` commands (from busybox). Those commands respectively requires `CAP_NET_RAW` and `CAP_NET_BIND_SERVICE` capabilities in order to perform privileged operations. To block their usage, capabilities bounding set -can be manipulated via `os/linux/capabilities-remove-set` or +can be manipulated via `os/linux/capabilities-remove-set` or `os/linux/capabilities-retain-set`; both approaches are shown here. ### Removing specific capabilities -This example shows how to block `ping` only, by removing `CAP_NET_RAW` from +This example shows how to block `ping` only, by removing `CAP_NET_RAW` from capabilities bounding set. First, a local image is built with an explicit "remove-set" isolator. @@ -129,8 +131,9 @@ $ acbuild end Once properly built, this image can be run in order to check that `ping` usage has been effectively disabled: + ``` -$ sudo rkt run --interactive --insecure-options=image caps-remove-set-example.aci +$ sudo rkt run --interactive --insecure-options=image caps-remove-set-example.aci image: using image from file stage1-coreos.aci image: using image from file caps-remove-set-example.aci image: using image from local store for image name quay.io/coreos/alpine-sh @@ -146,8 +149,9 @@ ping: permission denied (are you root?) This means that `CAP_NET_RAW` had been effectively disabled inside the container. At the same time, `CAP_NET_BIND_SERVICE` is still available in the default bounding set, so the `nc` command will be able to bind to port 80: + ``` -$ sudo rkt run --interactive --insecure-options=image caps-remove-set-example.aci +$ sudo rkt run --interactive --insecure-options=image caps-remove-set-example.aci image: using image from file stage1-coreos.aci image: using image from file caps-remove-set-example.aci image: using image from local store for image name quay.io/coreos/alpine-sh @@ -184,7 +188,7 @@ Once run, it can be easily verified that `ping` from inside the container is now functional: ``` -$ sudo rkt run --interactive --insecure-options=image caps-retain-set-example.aci +$ sudo rkt run --interactive --insecure-options=image caps-retain-set-example.aci image: using image from file stage1-coreos.aci image: using image from file caps-retain-set-example.aci image: using image from local store for image name quay.io/coreos/alpine-sh @@ -206,7 +210,7 @@ For example, using `nc` to bind to port 80 will now result in a failure due to the missing `CAP_NET_BIND_SERVICE` capability: ``` -$ sudo rkt run --interactive --insecure-options=image caps-remove-set-example.aci +$ sudo rkt run --interactive --insecure-options=image caps-remove-set-example.aci image: using image from file stage1-coreos.aci image: using image from file caps-remove-set-example.aci image: using image from local store for image name quay.io/coreos/alpine-sh diff --git a/Documentation/subcommands/run.md b/Documentation/subcommands/run.md index 1ffb5b0629..ee3c2f7cc5 100644 --- a/Documentation/subcommands/run.md +++ b/Documentation/subcommands/run.md @@ -309,7 +309,7 @@ Strictly seen, this is only true when `rkt run` is invoked on the host directly, ### Other Networking Examples -More details about rkt's networking options and examples can be found in the [networking documentation](https://github.com/coreos/rkt/blob/master/Documentation/networking.md) +More details about rkt's networking options and examples can be found in the [networking documentation](../networking/overview.md) ## Run rkt as a Daemon From 915720def3e2d59ed44bdd32b18bad71886b5880 Mon Sep 17 00:00:00 2001 From: Josh Wood Date: Tue, 31 May 2016 15:22:16 -0700 Subject: [PATCH 0354/1304] Doc/devel/stage1-implementors-guide: Fix heading fmt Switch to all atx-style markdown for headings and sort the hierarchy. Ref https://github.com/coreos/rkt/issues/2707 --- .../devel/stage1-implementors-guide.md | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/Documentation/devel/stage1-implementors-guide.md b/Documentation/devel/stage1-implementors-guide.md index eda3915d68..daaf58f4e1 100644 --- a/Documentation/devel/stage1-implementors-guide.md +++ b/Documentation/devel/stage1-implementors-guide.md @@ -1,8 +1,6 @@ -Stage1 ACI implementor's guide -============================= +# Stage1 ACI implementor's guide -Background ----------- +## Background rkt's execution of pods is divided roughly into three separate stages: @@ -25,8 +23,7 @@ Stage1 is the vehicle for getting there from stage0. For any given pod instance, stage1 may be replaced by a completely different implementation. This allows users to employ different containment strategies on the same host running the same interchangeable ACIs. -Entrypoints ------------ +## Entrypoints ### `rkt run` => `coreos.com/rkt/stage1/run` @@ -47,7 +44,7 @@ Systemd-nspawn then boots the stage1 systemd with the just-written unit files fo The `/init` program's primary job is translating a pod manifest to systemd-nspawn systemd.services. An alternative stage1 could forego systemd-nspawn and systemd altogether, or retain these and introduce something like novm or qemu-kvm for greater isolation by first starting a VM. -All that is required is an executable at the place indicated by the `coreos.com/rkt/stage1/run` entrypoint that knows how to apply the pod manifest and prepared ACI file-systems to good effect. +All that is required is an executable at the place indicated by the `coreos.com/rkt/stage1/run` entrypoint that knows how to apply the pod manifest and prepared ACI file-systems. The resolved entrypoint must inform rkt of its PID for the benefit of `rkt enter`. Stage1 implementors have two options for doing so; only one must be implemented: @@ -65,7 +62,7 @@ Stage1 implementors have two options for doing so; only one must be implemented: * `--local-config=$PATH` to override the local configuration directory * `--private-users=$SHIFT` to define a UID/GID shift when using user namespaces. SHIFT is a two-value colon-separated parameter, the first value is the first host UID to assign to the container and the second one is the number of host UIDs to assign. -##### Arguments added in interface version 2 +#### Arguments added in interface version 2 * `--hostname=$HOSTNAME` configures the host name of the pod. If empty, it will be "rkt-$PODUUID". @@ -101,16 +98,14 @@ For example, it removes the network namespace of a pod. * `--debug` to activate debugging * UUID of the pod -Versioning ----------- +## Versioning The stage1 command line interface is versioned using an annotation with the name `coreos.com/rkt/stage1/interface-version`. If the annotation is not present, rkt assumes the version is 1. The current version of the stage1 interface is 2. -Examples --------- +## Examples ### Stage1 ACI manifest From 5063cde45cf6bb930e5c0dd7fa7426301cd0ca92 Mon Sep 17 00:00:00 2001 From: John Pettigrew Date: Tue, 31 May 2016 20:05:33 -0500 Subject: [PATCH 0355/1304] Don't remove the cleanSrc if it equals '.' This fixes the issue where when cleanSrc equals '.', copied files are missing the first character from their names. Fixes appc/acbuild#211 --- pkg/fileutil/fileutil.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/fileutil/fileutil.go b/pkg/fileutil/fileutil.go index 9b22e5e12f..ec4b234d13 100644 --- a/pkg/fileutil/fileutil.go +++ b/pkg/fileutil/fileutil.go @@ -62,13 +62,15 @@ func CopySymlink(src, dest string) error { func CopyTree(src, dest string, uidRange *user.UidRange) error { cleanSrc := filepath.Clean(src) - dirs := make(map[string][]syscall.Timespec) copyWalker := func(path string, info os.FileInfo, err error) error { if err != nil { return err } rootLess := path[len(cleanSrc):] + if cleanSrc == "." { + rootLess = path + } target := filepath.Join(dest, rootLess) mode := info.Mode() switch { From 967b6a6c7cb42b82c6c9e5719aa08bfbf2223da5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 1 Jun 2016 10:59:18 +0200 Subject: [PATCH 0356/1304] pkg/selinux: fix TestSELinux TestSELinux was not setting the MCS dir which caused the paths of every MCS to be in the root of the file system (the path is calculated as fmt.Sprintf("%s/%s", mcsdir, mcs) and mcsdir was the empty string by default). This was making the test to fail when it runs as non-root. The test failure was non-obvious because of the way the algorithm to get a unique MCS is implemented. We first try to create the MCS file with a random category pair and, if it doesn't work, we continue with a different random category pair. Since we can't write to the MCS directory, we'll continue doing this until the test times out and we don't print any errors when we can't create the MCS file. Also, clean up test code a bit. --- pkg/selinux/selinux_test.go | 109 ++++++++++++++++++++---------------- 1 file changed, 60 insertions(+), 49 deletions(-) diff --git a/pkg/selinux/selinux_test.go b/pkg/selinux/selinux_test.go index f63d19bc61..38c9b6cdc1 100644 --- a/pkg/selinux/selinux_test.go +++ b/pkg/selinux/selinux_test.go @@ -1,3 +1,4 @@ +// Copyright 2016 The rkt Authors // Copyright 2014,2015 Red Hat, Inc // Copyright 2014,2015 Docker, Inc // @@ -18,66 +19,76 @@ package selinux_test import ( + "fmt" + "io/ioutil" "os" "testing" "github.com/coreos/rkt/pkg/selinux" ) -func testSetfilecon(t *testing.T) { - if selinux.SelinuxEnabled() { - tmp := "selinux_test" - out, _ := os.OpenFile(tmp, os.O_WRONLY, 0) - out.Close() - err := selinux.Setfilecon(tmp, "system_u:object_r:bin_t:s0") - if err != nil { - t.Log("Setfilecon failed") - t.Fatal(err) - } - os.Remove(tmp) +func TestSetfilecon(t *testing.T) { + if !selinux.SelinuxEnabled() { + t.Skip("SELinux not enabled") + } + + f, err := ioutil.TempFile("", "rkt-selinux-test") + if err != nil { + panic(fmt.Sprintf("unable to create tempfile: %v", err)) + } + f.Close() + defer os.Remove(f.Name()) + err = selinux.Setfilecon(f.Name(), "system_u:object_r:bin_t:s0") + if err != nil { + t.Log("Setfilecon failed") + t.Fatal(err) } } func TestSELinux(t *testing.T) { - var ( - err error - plabel, flabel string - ) + if !selinux.SelinuxEnabled() { + t.Skip("SELinux not enabled") + } - if selinux.SelinuxEnabled() { - t.Log("Enabled") - plabel, flabel = selinux.GetLxcContexts() - if plabel == "" { - t.Log("No lxc contexts, skipping tests") - return - } - t.Log(plabel) - t.Log(flabel) - selinux.FreeLxcContexts(plabel) - plabel, flabel = selinux.GetLxcContexts() - t.Log(plabel) - t.Log(flabel) - selinux.FreeLxcContexts(plabel) - t.Log("getenforce ", selinux.SelinuxGetEnforce()) - t.Log("getenforcemode ", selinux.SelinuxGetEnforceMode()) - pid := os.Getpid() - t.Logf("PID:%d MCS:%s\n", pid, selinux.IntToMcs(pid, 1023)) - err = selinux.Setfscreatecon("unconfined_u:unconfined_r:unconfined_t:s0") - if err == nil { - t.Log(selinux.Getfscreatecon()) - } else { - t.Log("setfscreatecon failed", err) - t.Fatal(err) - } - err = selinux.Setfscreatecon("") - if err == nil { - t.Log(selinux.Getfscreatecon()) - } else { - t.Log("setfscreatecon failed", err) - t.Fatal(err) - } - t.Log(selinux.Getpidcon(1)) + dir, err := ioutil.TempDir("", "rkt-selinux-test") + if err != nil { + panic(fmt.Sprintf("unable to create temp dir: %v", err)) + } + defer os.RemoveAll(dir) + if err := selinux.SetMCSDir(dir); err != nil { + t.Errorf("error setting MCS directory: %v", err) + } + + var plabel, flabel string + + plabel, flabel = selinux.GetLxcContexts() + if plabel == "" { + t.Skip("No LXC contexts, skipping tests") + } + t.Log(plabel) + t.Log(flabel) + selinux.FreeLxcContexts(plabel) + plabel, flabel = selinux.GetLxcContexts() + t.Log(plabel) + t.Log(flabel) + selinux.FreeLxcContexts(plabel) + t.Log("getenforce ", selinux.SelinuxGetEnforce()) + t.Log("getenforcemode ", selinux.SelinuxGetEnforceMode()) + pid := os.Getpid() + t.Logf("PID:%d MCS:%s\n", pid, selinux.IntToMcs(pid, 1023)) + err = selinux.Setfscreatecon("unconfined_u:unconfined_r:unconfined_t:s0") + if err == nil { + t.Log(selinux.Getfscreatecon()) + } else { + t.Log("setfscreatecon failed", err) + t.Fatal(err) + } + err = selinux.Setfscreatecon("") + if err == nil { + t.Log(selinux.Getfscreatecon()) } else { - t.Log("Disabled") + t.Log("setfscreatecon failed", err) + t.Fatal(err) } + t.Log(selinux.Getpidcon(1)) } From b4bc6c6a9efbbdb4e2f6b8f01c205ce6d0172224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 1 Jun 2016 11:00:39 +0200 Subject: [PATCH 0357/1304] pkg/selinux: cleanup --- pkg/label/label_selinux.go | 5 +++- pkg/selinux/selinux.go | 52 ++++++++++++++++++------------------- pkg/selinux/selinux_test.go | 10 +++++-- 3 files changed, 38 insertions(+), 29 deletions(-) diff --git a/pkg/label/label_selinux.go b/pkg/label/label_selinux.go index 4992125545..a806f40352 100644 --- a/pkg/label/label_selinux.go +++ b/pkg/label/label_selinux.go @@ -34,7 +34,10 @@ func InitLabels(options []string) (string, string, error) { if !selinux.SelinuxEnabled() { return "", "", nil } - processLabel, mountLabel := selinux.GetLxcContexts() + processLabel, mountLabel, err := selinux.GetLxcContexts() + if err != nil { + return "", "", err + } if processLabel != "" { pcon := selinux.NewContext(processLabel) mcon := selinux.NewContext(mountLabel) diff --git a/pkg/selinux/selinux.go b/pkg/selinux/selinux.go index 0e05621918..a1b182a965 100644 --- a/pkg/selinux/selinux.go +++ b/pkg/selinux/selinux.go @@ -1,3 +1,4 @@ +// Copyright 2016 The rkt Authors // Copyright 2014,2015 Red Hat, Inc // Copyright 2014,2015 Docker, Inc // @@ -21,7 +22,6 @@ import ( "bufio" "crypto/rand" "encoding/binary" - "errors" "fmt" "io" "os" @@ -32,7 +32,6 @@ import ( "syscall" "github.com/coreos/rkt/pkg/fileutil" - "github.com/hashicorp/errwrap" ) const ( @@ -55,6 +54,8 @@ var ( selinuxEnabled = false // Stores whether selinux is currently enabled selinuxEnabledChecked = false // Stores whether selinux enablement has been checked or established yet mcsdir = "" // Directory to use for MCS storage + + errMCSAlreadyExists = fmt.Errorf("MCS label already exists") ) type SELinuxContext map[string]string @@ -281,10 +282,9 @@ func mcsAdd(mcs string) error { file, err := os.OpenFile(filename, os.O_CREATE|os.O_EXCL|os.O_RDONLY, 0644) if err != nil { if os.IsExist(err) { - return fmt.Errorf("MCS label already exists") - } else { - return errwrap.Wrap(errors.New("unable to test MCS"), err) + return errMCSAlreadyExists } + return fmt.Errorf("unable to create MCS: %v", err) } file.Close() return nil @@ -324,34 +324,33 @@ func IntToMcs(id int, catRange uint32) string { return fmt.Sprintf("s0:c%d,c%d", TIER, ORD) } -func uniqMcs(catRange uint32) string { +func makeUniqueMcs(catRange uint32) (string, error) { var ( n uint32 c1, c2 uint32 mcs string + tries = 1000000 + err error ) - for { + for i := 0; i < tries; i++ { binary.Read(rand.Reader, binary.LittleEndian, &n) c1 = n % catRange binary.Read(rand.Reader, binary.LittleEndian, &n) c2 = n % catRange if c1 == c2 { continue - } else { - if c1 > c2 { - t := c1 - c1 = c2 - c2 = t - } + } + if c1 > c2 { + c1, c2 = c2, c1 } mcs = fmt.Sprintf("s0:c%d,c%d", c1, c2) - if err := mcsAdd(mcs); err != nil { - continue + err = mcsAdd(mcs) + if err == nil { + return mcs, nil } - break } - return mcs + return "", fmt.Errorf("couldn't generate unique MCS after %d tries! (last err=%v)", tries, err) } func FreeLxcContexts(scon string) { @@ -361,19 +360,19 @@ func FreeLxcContexts(scon string) { } } -func GetLxcContexts() (processLabel string, fileLabel string) { +func GetLxcContexts() (processLabel string, fileLabel string, err error) { var ( val, key string bufin *bufio.Reader ) if !SelinuxEnabled() { - return "", "" + return "", "", nil } lxcPath := fmt.Sprintf("%s/contexts/lxc_contexts", getSELinuxPolicyRoot()) in, err := os.Open(lxcPath) if err != nil { - return "", "" + return "", "", nil } defer in.Close() @@ -409,19 +408,21 @@ func GetLxcContexts() (processLabel string, fileLabel string) { } if processLabel == "" || fileLabel == "" { - return "", "" + return "", "", nil } exit: - // mcs := IntToMcs(os.Getpid(), 1024) - mcs := uniqMcs(1024) + mcs, err := makeUniqueMcs(1024) + if err != nil { + return "", "", err + } scon := NewContext(processLabel) scon["level"] = mcs processLabel = scon.Get() scon = NewContext(fileLabel) scon["level"] = mcs fileLabel = scon.Get() - return processLabel, fileLabel + return processLabel, fileLabel, nil } func SecurityCheckContext(val string) error { @@ -507,6 +508,5 @@ func DisableSecOpt() []string { // Set the directory used for storage of used MCS contexts func SetMCSDir(arg string) error { mcsdir = arg - err := os.MkdirAll(mcsdir, 0755) - return err + return os.MkdirAll(mcsdir, 0755) } diff --git a/pkg/selinux/selinux_test.go b/pkg/selinux/selinux_test.go index 38c9b6cdc1..f0e6781b10 100644 --- a/pkg/selinux/selinux_test.go +++ b/pkg/selinux/selinux_test.go @@ -61,14 +61,20 @@ func TestSELinux(t *testing.T) { var plabel, flabel string - plabel, flabel = selinux.GetLxcContexts() + plabel, flabel, err = selinux.GetLxcContexts() + if err != nil { + t.Fatal(err) + } if plabel == "" { t.Skip("No LXC contexts, skipping tests") } t.Log(plabel) t.Log(flabel) selinux.FreeLxcContexts(plabel) - plabel, flabel = selinux.GetLxcContexts() + plabel, flabel, err = selinux.GetLxcContexts() + if err != nil { + t.Fatal(err) + } t.Log(plabel) t.Log(flabel) selinux.FreeLxcContexts(plabel) From 926b4f566bf26e919ea9694dbd493fb99443cc45 Mon Sep 17 00:00:00 2001 From: Josh Wood Date: Tue, 31 May 2016 15:22:16 -0700 Subject: [PATCH 0358/1304] Doc/devel/stage1-implementors-guide: Fix heading fmt Switch to all atx-style markdown for headings and sort the hierarchy. Ref https://github.com/coreos/rkt/issues/2707 --- .../devel/stage1-implementors-guide.md | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/Documentation/devel/stage1-implementors-guide.md b/Documentation/devel/stage1-implementors-guide.md index eda3915d68..81444b70ed 100644 --- a/Documentation/devel/stage1-implementors-guide.md +++ b/Documentation/devel/stage1-implementors-guide.md @@ -1,8 +1,6 @@ -Stage1 ACI implementor's guide -============================= +# Stage1 ACI implementor's guide -Background ----------- +## Background rkt's execution of pods is divided roughly into three separate stages: @@ -25,10 +23,11 @@ Stage1 is the vehicle for getting there from stage0. For any given pod instance, stage1 may be replaced by a completely different implementation. This allows users to employ different containment strategies on the same host running the same interchangeable ACIs. -Entrypoints ------------ +## Entrypoints -### `rkt run` => `coreos.com/rkt/stage1/run` +### rkt run + +`coreos.com/rkt/stage1/run` 1. rkt prepares the pod's stage1 and stage2 images and pod manifest under `/var/lib/rkt/pods/prepare/$uuid`, acquiring an exclusive advisory lock on the directory. Upon a successful preparation, the directory will be renamed to `/var/lib/rkt/pods/run/$uuid`. @@ -59,17 +58,19 @@ Stage1 implementors have two options for doing so; only one must be implemented: * `--debug` to activate debugging * `--net[=$NET1,$NET2,...]` to configure the creation of a contained network. - See the [rkt networking documentation](../networking.md) for details. + See the [rkt networking documentation](../networking.html) for details. * `--mds-token=$TOKEN` passes the auth token to the apps via `AC_METADATA_URL` env var * `--interactive` to run a pod interactively, that is, pass standard input to the application (only for pods with one application) * `--local-config=$PATH` to override the local configuration directory * `--private-users=$SHIFT` to define a UID/GID shift when using user namespaces. SHIFT is a two-value colon-separated parameter, the first value is the first host UID to assign to the container and the second one is the number of host UIDs to assign. -##### Arguments added in interface version 2 +#### Arguments added in interface version 2 * `--hostname=$HOSTNAME` configures the host name of the pod. If empty, it will be "rkt-$PODUUID". -### `rkt enter` => `coreos.com/rkt/stage1/enter` +### rkt enter + +`coreos.com/rkt/stage1/enter` 1. rkt verifies the pod and image to enter are valid and running 2. chdirs to `/var/lib/rkt/pods/run/$uuid` @@ -91,7 +92,9 @@ An alternative stage1 would need to do whatever is appropriate for entering the 4. cmd to execute. 5. optionally, any cmd arguments. -### `rkt gc` => `coreos.com/rkt/stage1/gc` +### rkt gc + +`coreos.com/rkt/stage1/gc` The gc entrypoint deals with garbage collecting resources allocated by stage1. For example, it removes the network namespace of a pod. @@ -101,16 +104,14 @@ For example, it removes the network namespace of a pod. * `--debug` to activate debugging * UUID of the pod -Versioning ----------- +## Versioning The stage1 command line interface is versioned using an annotation with the name `coreos.com/rkt/stage1/interface-version`. If the annotation is not present, rkt assumes the version is 1. The current version of the stage1 interface is 2. -Examples --------- +## Examples ### Stage1 ACI manifest @@ -159,20 +160,26 @@ Examples The following paths are reserved for the stage1 image, and they will be created during stage0. When creating a stage1 image, developers SHOULD NOT create or use these paths in the image's filesystem. -### opt/stage2 +### stage2 + +`opt/stage2` This directory path is used for extracting the ACI of every app in the pod. Each app's rootfs will appear under this directory, e.g. `/var/lib/rkt/pods/run/$uuid/stage1/rootfs/opt/stage2/$appname/rootfs`. -### rkt/status +### status + +`rkt/status` This directory path is used for storing the apps' exit statuses. For example, if an app named `foo` exits with status = `42`, stage1 should write `42` in `/var/lib/rkt/pods/run/$uuid/stage1/rootfs/rkt/status/foo`. Later the exit status can be retrieved and shown by `rkt status $uuid`. -### rkt/env +### env + +`rkt/env` This directory path is used for passing environment variables to each app. For example, environment variables for an app named `foo` will be stored in `rkt/env/foo`. From 226eae1bc9df7926a6fd89bd1cb2312ad31945c8 Mon Sep 17 00:00:00 2001 From: Euan Kemp Date: Wed, 1 Jun 2016 16:37:32 -0700 Subject: [PATCH 0359/1304] api_service: Only fill in image info if we have it Fixes #2738 --- rkt/api_service.go | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/rkt/api_service.go b/rkt/api_service.go index 22182908b4..ff328a5877 100644 --- a/rkt/api_service.go +++ b/rkt/api_service.go @@ -442,16 +442,7 @@ func fillAppInfo(store *store.Store, p *pod, v1pod *v1alpha.Pod) { stderr.PrintE(fmt.Sprintf("failed to resolve the image ID %q", app.Image.Id), err) } - im, err := p.getAppImageManifest(*types.MustACName(app.Name)) - if err != nil { - stderr.PrintE(fmt.Sprintf("failed to get image manifests for app %q", app.Name), err) - } - - version, ok := im.Labels.Get("version") - if !ok { - version = "latest" - } - + // The following information is always known app.Image = &v1alpha.Image{ BaseFormat: &v1alpha.ImageFormat{ // Only support appc image now. If it's a docker image, then it @@ -459,11 +450,22 @@ func fillAppInfo(store *store.Store, p *pod, v1pod *v1alpha.Pod) { Type: v1alpha.ImageType_IMAGE_TYPE_APPC, Version: schema.AppContainerVersion.String(), }, - Id: fullImageID, - Name: im.Name.String(), - Version: version, + Id: fullImageID, // Other information are not available because they require the image - // info from store. + // info from store. Some of it is filled in below if possible. + } + + im, err := p.getAppImageManifest(*types.MustACName(app.Name)) + if err != nil { + stderr.PrintE(fmt.Sprintf("failed to get image manifests for app %q", app.Name), err) + } else { + app.Image.Name = im.Name.String() + + version, ok := im.Labels.Get("version") + if !ok { + version = "latest" + } + app.Image.Version = version } if readStatus { From 96fcd97d4d6b7723a1d65b028a1fc6aa089fd461 Mon Sep 17 00:00:00 2001 From: Euan Kemp Date: Wed, 1 Jun 2016 16:39:04 -0700 Subject: [PATCH 0360/1304] tests/api_service: Add list partial pod test This test verifies that a partial pod (one with an apps manifest file unreadable) does not cause the api service to panic --- tests/rkt_api_service_test.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/rkt_api_service_test.go b/tests/rkt_api_service_test.go index 1cd172f8ef..60182a5594 100644 --- a/tests/rkt_api_service_test.go +++ b/tests/rkt_api_service_test.go @@ -437,6 +437,38 @@ func NewAPIServiceListInspectPodsTest() testutils.Test { for _, p := range resp.Pods { checkPodDetails(t, ctx, p) } + + // ListPods with corrupt pod directory + // Note that we don't checkPodDetails here, the failure this is testing is + // the api server panicing, which results in a list call hanging for ages + // and then failing. + // TODO: do further validation on the partial pods returned + for _, p := range resp.Pods { + numRemoved := 0 + podDir := getPodDir(t, ctx, p.Id) + filepath.Walk(filepath.Join(podDir, "appsinfo"), filepath.WalkFunc(func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + if info.Name() == "manifest" { + os.Remove(path) + numRemoved++ + } + return nil + })) + if numRemoved == 0 { + t.Fatalf("Expected to remove at least one app manifest for pod %v", p) + } + } + + // ListPods(detail=true). + resp, err = c.ListPods(context.Background(), &v1alpha.ListPodsRequest{Detail: true}) + if err != nil { + t.Fatalf("Unexpected error: %v", err) + } + if len(resp.Pods) != len(podManifests) { + t.Fatalf("Expected %v pods, got %v pods", len(podManifests), len(resp.Pods)) + } }) } From 4abed9fe72e9806ef05054e547d162c883d0d16d Mon Sep 17 00:00:00 2001 From: Josh Wood Date: Thu, 2 Jun 2016 18:32:46 -0700 Subject: [PATCH 0361/1304] Documentation/subcmd/rm: Correct --uuid-file-save typo --- Documentation/subcommands/rm.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/subcommands/rm.md b/Documentation/subcommands/rm.md index 30b888201f..005825870a 100644 --- a/Documentation/subcommands/rm.md +++ b/Documentation/subcommands/rm.md @@ -11,7 +11,7 @@ Instead of passing UUID on command line, rm command can read the UUID from a tex This can be paired with `--uuid-file-save` to remove pods by name: ``` -rkt run --uuid-files-save=/run/rkt-uuids/mypod ... +rkt run --uuid-file-save=/run/rkt-uuids/mypod ... rkt rm --uuid-file=/run/rkt-uuids/mypod ``` From fc4753436500238a6a4d4d925536b1e63917c4e9 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Thu, 2 Jun 2016 12:49:04 +0200 Subject: [PATCH 0362/1304] docs: document rkt release cycle This tries to document current release model, tentatively introducing a buffer day to stabilize the release and better plan next ones. --- Documentation/devel/release.md | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Documentation/devel/release.md b/Documentation/devel/release.md index 8e6fdeae59..4c2347a6ca 100644 --- a/Documentation/devel/release.md +++ b/Documentation/devel/release.md @@ -1,9 +1,24 @@ # rkt release guide -How to perform a release of rkt. -This guide is probably unnecessarily verbose, so improvements welcomed. -Only parts of the procedure are automated; this is somewhat intentional (manual steps for sanity checking) but it can probably be further scripted, please help. +## Release cycle + +This section describes the typical release cycle of rkt: + +1. A GitHub [milestone](https://github.com/coreos/rkt/milestones) sets the target date for a future rkt release. Releases occur approximately every two to three weeks. +2. Issues grouped into the next release milestone are worked on in order of priority. +3. Changes are submitted for review in the form of a GitHub Pull Request (PR). Each PR undergoes review and must pass continuous integration (CI) tests before being accepted and merged into the main line of rkt source code. +4. The day before each release is a short code freeze during which no new code or dependencies may be merged. Instead, this period focuses on polishing the release, with tasks concerning: + * Documentation + * Usability tests + * Issues triaging + * Roadmap planning and scheduling the next release milestone + * Organizational and backlog review + * Build, distribution, and install testing by release manager +## Release process + +This section shows how to perform a release of rkt. +Only parts of the procedure are automated; this is somewhat intentional (manual steps for sanity checking) but it can probably be further scripted, please help. The following example assumes we're going from version 1.1.0 (`v1.1.0`) to 1.2.0 (`v1.2.0`). Let's get started: From e9e31ae2ca66566f21726e9fe05987460247ad64 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Fri, 3 Jun 2016 13:22:08 +0200 Subject: [PATCH 0363/1304] stage1: split out procfs restrictions logic `appToSystemd()` is already quite large and will keep growing when adding new procfs restrictions. This commit refactors filtering logic in its own function. Ref #2616 --- stage1/init/common/pod.go | 78 +++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 36 deletions(-) diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index 5895e24fdf..814dcb047b 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -457,42 +457,8 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b unit.NewUnitOption("Service", "SyslogIdentifier", appName.String()), } - // Restrict access to some security-sensitive paths under /proc and /sys. - // Those entries can be hidden or just made read-only to app. - roPaths := []string{ - "/proc/sys/kernel/core_pattern", - "/proc/sys/kernel/modprobe", - "/proc/sys/vm/panic_on_oom", - "/proc/sysrq-trigger", - "/sys/block/", - "/sys/bus/", - "/sys/class/", - "/sys/dev/", - "/sys/devices/", - "/sys/kernel/", - } - hiddenPaths := []string{ - // TODO(lucab): file-paths restrictions need support in systemd first - //"/proc/config.gz", - //"/proc/kallsyms", - //"/proc/sched_debug", - //"/proc/kcore", - //"/proc/kmem", - //"/proc/mem", - "/sys/firmware/", - "/sys/fs/", - "/sys/hypervisor/", - "/sys/module/", - "/sys/power/", - } - // Paths prefixed with "-" are ignored if they do not exist: - // [https://www.freedesktop.org/software/systemd/man/systemd.exec.html#ReadWriteDirectories=] - for _, p := range hiddenPaths { - opts = append(opts, unit.NewUnitOption("Service", "InaccessibleDirectories", fmt.Sprintf("-%s", filepath.Join(common.RelAppRootfsPath(appName), p)))) - } - for _, p := range roPaths { - opts = append(opts, unit.NewUnitOption("Service", "ReadOnlyDirectories", fmt.Sprintf("-%s", filepath.Join(common.RelAppRootfsPath(appName), p)))) - } + // Restrict access to sensitive paths (eg. procfs) + opts = protectSystemFiles(opts, appName) if ra.ReadOnlyRootFS { opts = append(opts, unit.NewUnitOption("Service", "ReadOnlyDirectories", common.RelAppRootfsPath(appName))) @@ -1098,3 +1064,43 @@ func getAppNoNewPrivileges(isolators types.Isolators) bool { return false } + +// restrictProcFS restricts access to some security-sensitive paths under +// /proc and /sys. Entries are either hidden or just made read-only to app. +func protectSystemFiles(opts []*unit.UnitOption, appName types.ACName) []*unit.UnitOption { + roPaths := []string{ + "/proc/sys/kernel/core_pattern", + "/proc/sys/kernel/modprobe", + "/proc/sys/vm/panic_on_oom", + "/proc/sysrq-trigger", + "/sys/block/", + "/sys/bus/", + "/sys/class/", + "/sys/dev/", + "/sys/devices/", + "/sys/kernel/", + } + hiddenPaths := []string{ + // TODO(lucab): file-paths restrictions need support in systemd first + //"/proc/config.gz", + //"/proc/kallsyms", + //"/proc/sched_debug", + //"/proc/kcore", + //"/proc/kmem", + //"/proc/mem", + "/sys/firmware/", + "/sys/fs/", + "/sys/hypervisor/", + "/sys/module/", + "/sys/power/", + } + // Paths prefixed with "-" are ignored if they do not exist: + // https://www.freedesktop.org/software/systemd/man/systemd.exec.html#ReadWriteDirectories= + for _, p := range hiddenPaths { + opts = append(opts, unit.NewUnitOption("Service", "InaccessibleDirectories", fmt.Sprintf("-%s", filepath.Join(common.RelAppRootfsPath(appName), p)))) + } + for _, p := range roPaths { + opts = append(opts, unit.NewUnitOption("Service", "ReadOnlyDirectories", fmt.Sprintf("-%s", filepath.Join(common.RelAppRootfsPath(appName), p)))) + } + return opts +} From 414fddf1d9136092861954cfca7d59af3315c1b5 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Fri, 3 Jun 2016 13:35:54 +0200 Subject: [PATCH 0364/1304] stage1: make /proc/bus/ read-only This removes write access to /proc/bus/, stopping malicious apps from directly accessing devices through procfs. This blocks direct manipulation of PCI devices as shown in Appendix IV of https://www.nccgroup.trust/globalassets/our-research/us/whitepapers/2016/june/abusing-privileged-and-unprivileged-linux-containerspdf --- stage1/init/common/pod.go | 1 + 1 file changed, 1 insertion(+) diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index 814dcb047b..13aba46a98 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -1069,6 +1069,7 @@ func getAppNoNewPrivileges(isolators types.Isolators) bool { // /proc and /sys. Entries are either hidden or just made read-only to app. func protectSystemFiles(opts []*unit.UnitOption, appName types.ACName) []*unit.UnitOption { roPaths := []string{ + "/proc/bus/", "/proc/sys/kernel/core_pattern", "/proc/sys/kernel/modprobe", "/proc/sys/vm/panic_on_oom", From 3bbee24710a778b43e7ecf3875d92498664f10fe Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Fri, 3 Jun 2016 17:46:53 +0200 Subject: [PATCH 0365/1304] api: GetLogs: use the correct type in LogsStreamWriter Symptoms: > panic: interface conversion: []uint8 is not proto.Message: missing > method ProtoMessage This patch fixes the panic, but there are other crashes that are not related to LogsStreamWriter. I'll file a separate PR. Helps with https://github.com/coreos/rkt/issues/2740 --- rkt/api_service.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rkt/api_service.go b/rkt/api_service.go index 22182908b4..84f5332fe4 100644 --- a/rkt/api_service.go +++ b/rkt/api_service.go @@ -702,7 +702,8 @@ type LogsStreamWriter struct { } func (sw LogsStreamWriter) Write(b []byte) (int, error) { - if err := sw.server.SendMsg(b); err != nil { + lines := strings.Split(string(b), "\n") + if err := sw.server.Send(&v1alpha.GetLogsResponse{Lines: lines}); err != nil { return 0, err } return len(b), nil From 459f00de3230968b353b8b59d9c9570fa5cef169 Mon Sep 17 00:00:00 2001 From: Abhishek Chanda Date: Fri, 3 Jun 2016 22:37:38 -0700 Subject: [PATCH 0366/1304] CLI: add a flag to pretty print json in config command Pretty printing makes it easier to read for humans. Since it is still json, it's still easy to automate. A script still has the option to enable or disable pretty printing. --- rkt/config.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rkt/config.go b/rkt/config.go index afaf6a1c2f..6992b1b3ad 100644 --- a/rkt/config.go +++ b/rkt/config.go @@ -28,10 +28,12 @@ var ( The generated configuration entries resemble the original rkt configuration format.`, Run: runWrapper(runConfig), } + flagConfigPrettyPrint bool ) func init() { cmdRkt.AddCommand(cmdConfig) + cmdConfig.Flags().BoolVar(&flagConfigPrettyPrint, "pretty-print", false, "apply indent to format the output") } func runConfig(cmd *cobra.Command, args []string) int { @@ -41,7 +43,12 @@ func runConfig(cmd *cobra.Command, args []string) int { return 1 } - b, err := json.Marshal(config) + var b []byte + if flagConfigPrettyPrint { + b, err = json.MarshalIndent(config, "", "\t") + } else { + b, err = json.Marshal(config) + } if err != nil { stderr.PanicE("error marshaling configuration", err) } From 741d9dfb8fbb7bc5a11fcf96989d1c5605bd976a Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Sun, 5 Jun 2016 18:28:10 +0200 Subject: [PATCH 0367/1304] api: client_example: GetLogs with follow Previously, client_example was only able to call GetLogs without the 'Follow' option. This patch updates client_example.go to show how to test calls to GetLogs both with and without the 'Follow' option. --- api/v1alpha/client_example.go | 77 +++++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 18 deletions(-) diff --git a/api/v1alpha/client_example.go b/api/v1alpha/client_example.go index 0cf1949f7a..861823aa1d 100644 --- a/api/v1alpha/client_example.go +++ b/api/v1alpha/client_example.go @@ -17,7 +17,9 @@ package main import ( + "flag" "fmt" + "io" "os" "github.com/coreos/rkt/api/v1alpha" @@ -25,7 +27,58 @@ import ( "google.golang.org/grpc" ) +func getLogsWithoutFollow(c v1alpha.PublicAPIClient, p *v1alpha.Pod) { + logsResp, err := c.GetLogs(context.Background(), &v1alpha.GetLogsRequest{ + PodId: p.Id, + Follow: false, + }) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + logsRecvResp, err := logsResp.Recv() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + for _, l := range logsRecvResp.Lines { + fmt.Println(l) + } +} + +func getLogsWithFollow(c v1alpha.PublicAPIClient, p *v1alpha.Pod) { + logsResp, err := c.GetLogs(context.Background(), &v1alpha.GetLogsRequest{ + PodId: p.Id, + Follow: true, + }) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + for { + logsRecvResp, err := logsResp.Recv() + if err == io.EOF { + return + } + + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + for _, l := range logsRecvResp.Lines { + fmt.Println(l) + } + } +} + func main() { + followFlag := flag.Bool("follow", false, "enable 'follow' option on GetLogs") + flag.Parse() + conn, err := grpc.Dial("localhost:15441", grpc.WithInsecure()) if err != nil { fmt.Println(err) @@ -50,24 +103,12 @@ func main() { } for _, p := range podResp.Pods { - fmt.Printf("Pod %q is running\n", p.Id) - - logsResp, err := c.GetLogs(context.Background(), &v1alpha.GetLogsRequest{ - PodId: p.Id, - }) - if err != nil { - fmt.Println(err) - os.Exit(1) - } - - logsRecvResp, err := logsResp.Recv() - if err != nil { - fmt.Println(err) - os.Exit(1) - } - - for _, l := range logsRecvResp.Lines { - fmt.Println(l) + if *followFlag { + fmt.Printf("Pod %q is running. Following logs:\n", p.Id) + getLogsWithFollow(c, p) + } else { + fmt.Printf("Pod %q is running.\n", p.Id) + getLogsWithoutFollow(c, p) } } From fcd4ee0beb2b1787094d08a4d18fb9952919780d Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Sun, 5 Jun 2016 20:14:49 +0200 Subject: [PATCH 0368/1304] api: GetLogs: remove empty lines --- rkt/api_service.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/rkt/api_service.go b/rkt/api_service.go index 8fe44c0db1..6cb0eaa82a 100644 --- a/rkt/api_service.go +++ b/rkt/api_service.go @@ -704,7 +704,14 @@ type LogsStreamWriter struct { } func (sw LogsStreamWriter) Write(b []byte) (int, error) { - lines := strings.Split(string(b), "\n") + // Remove empty lines + lines := make([]string, 0) + for _, v := range strings.Split(string(b), "\n") { + if len(v) > 0 { + lines = append(lines, v) + } + } + if err := sw.server.Send(&v1alpha.GetLogsResponse{Lines: lines}); err != nil { return 0, err } @@ -766,7 +773,13 @@ func (s *v1AlphaAPIServer) GetLogs(request *v1alpha.GetLogsRequest, server v1alp if err != nil { return err } - lines := strings.Split(string(data), "\n") + // Remove empty lines + lines := make([]string, 0) + for _, v := range strings.Split(string(data), "\n") { + if len(v) > 0 { + lines = append(lines, v) + } + } return server.Send(&v1alpha.GetLogsResponse{Lines: lines}) } From b8d5cdcfc9e713f9725e12d4441142cad1463e1c Mon Sep 17 00:00:00 2001 From: Mark Petrovic Date: Mon, 6 Jun 2016 12:19:18 -0700 Subject: [PATCH 0369/1304] stage0: remove superfluous %v Printf verb from logged message when tree cache is bad Fixes #2749 --- stage0/run.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stage0/run.go b/stage0/run.go index 8c3acf9a46..110b5ea66e 100644 --- a/stage0/run.go +++ b/stage0/run.go @@ -576,7 +576,7 @@ func prepareAppImage(cfg PrepareConfig, appName types.ACName, img types.Hash, cd if !cfg.SkipTreeStoreCheck { hash, err := cfg.Store.CheckTreeStore(treeStoreID) if err != nil { - log.PrintE("warning: tree cache is in a bad state: %v. Rebuilding...", err) + log.PrintE("warning: tree cache is in a bad state. Rebuilding...", err) var err error treeStoreID, hash, err = cfg.Store.RenderTreeStore(img.String(), true) if err != nil { From 1e0ec65dcaf5e26afbc302a00b8d0669abcb315f Mon Sep 17 00:00:00 2001 From: Abhishek Chanda Date: Mon, 6 Jun 2016 22:13:38 -0700 Subject: [PATCH 0370/1304] CLI: default to pretty printing for all json Also change some docs accordingly --- Documentation/subcommands/cat-manifest.md | 2 +- Documentation/subcommands/image.md | 2 +- rkt/cat_manifest.go | 2 +- rkt/config.go | 2 +- rkt/image_cat_manifest.go | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Documentation/subcommands/cat-manifest.md b/Documentation/subcommands/cat-manifest.md index d350b26add..d3f91e2afb 100644 --- a/Documentation/subcommands/cat-manifest.md +++ b/Documentation/subcommands/cat-manifest.md @@ -14,7 +14,7 @@ For debugging or inspection you may want to extract the PodManifest to stdout. | Flag | Default | Options | Description | | --- | --- | --- | --- | -| `--pretty-print` | `false` | `true` or `false` | Apply indent to format the output | +| `--pretty-print` | `true` | `true` or `false` | Apply indent to format the output | ## Global options diff --git a/Documentation/subcommands/image.md b/Documentation/subcommands/image.md index 150f7ed364..b89019020f 100644 --- a/Documentation/subcommands/image.md +++ b/Documentation/subcommands/image.md @@ -16,7 +16,7 @@ For debugging or inspection you may want to extract an ACI manifest to stdout. | Flag | Default | Options | Description | | --- | --- | --- | --- | -| `--pretty-print` | `false` | `true` or `false` | Apply indent to format the output | +| `--pretty-print` | `true` | `true` or `false` | Apply indent to format the output | ## rkt image export diff --git a/rkt/cat_manifest.go b/rkt/cat_manifest.go index d872dd98cd..4a96c11cf8 100644 --- a/rkt/cat_manifest.go +++ b/rkt/cat_manifest.go @@ -32,7 +32,7 @@ var ( func init() { cmdRkt.AddCommand(cmdCatManifest) - cmdCatManifest.Flags().BoolVar(&flagPMPrettyPrint, "pretty-print", false, "apply indent to format the output") + cmdCatManifest.Flags().BoolVar(&flagPMPrettyPrint, "pretty-print", true, "apply indent to format the output") } func runCatManifest(cmd *cobra.Command, args []string) (exit int) { diff --git a/rkt/config.go b/rkt/config.go index 6992b1b3ad..8b61b1bc6a 100644 --- a/rkt/config.go +++ b/rkt/config.go @@ -33,7 +33,7 @@ The generated configuration entries resemble the original rkt configuration form func init() { cmdRkt.AddCommand(cmdConfig) - cmdConfig.Flags().BoolVar(&flagConfigPrettyPrint, "pretty-print", false, "apply indent to format the output") + cmdConfig.Flags().BoolVar(&flagConfigPrettyPrint, "pretty-print", true, "apply indent to format the output") } func runConfig(cmd *cobra.Command, args []string) int { diff --git a/rkt/image_cat_manifest.go b/rkt/image_cat_manifest.go index e696a73297..490a59432b 100644 --- a/rkt/image_cat_manifest.go +++ b/rkt/image_cat_manifest.go @@ -34,7 +34,7 @@ var ( func init() { cmdImage.AddCommand(cmdImageCatManifest) - cmdImageCatManifest.Flags().BoolVar(&flagPrettyPrint, "pretty-print", false, "apply indent to format the output") + cmdImageCatManifest.Flags().BoolVar(&flagPrettyPrint, "pretty-print", true, "apply indent to format the output") } func runImageCatManifest(cmd *cobra.Command, args []string) (exit int) { From 3ad94f52d1715570afa0b2ffb7ec88e7992aa4fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chris=20K=C3=BChl?= Date: Tue, 7 Jun 2016 16:42:19 +0200 Subject: [PATCH 0371/1304] kvm: use diagnostic messages for diagnostics This switches the kvm package to using a diagnostic logger whose messages are only sent to stderr when debugging is switched on. Otherwise messages are discarded. --- stage1/init/init.go | 1 + stage1/init/kvm/log.go | 12 ++++++++++-- stage1/init/kvm/network.go | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/stage1/init/init.go b/stage1/init/init.go index d5b495d373..52a1850843 100644 --- a/stage1/init/init.go +++ b/stage1/init/init.go @@ -566,6 +566,7 @@ func stage1() int { } if flavor == "kvm" { + kvm.InitDebug(debug) if err := KvmNetworkingToSystemd(p, n); err != nil { log.PrintE("failed to configure systemd for kvm", err) return 1 diff --git a/stage1/init/kvm/log.go b/stage1/init/kvm/log.go index 55d0a2554b..8caf970f9b 100644 --- a/stage1/init/kvm/log.go +++ b/stage1/init/kvm/log.go @@ -15,13 +15,21 @@ package kvm import ( + "io/ioutil" "os" rktlog "github.com/coreos/rkt/pkg/log" ) -var rlog *rktlog.Logger +var diag *rktlog.Logger func init() { - rlog = rktlog.New(os.Stderr, "kvm", false) + diag = rktlog.New(os.Stderr, "kvm", false) +} + +func InitDebug(debug bool) { + diag.SetDebug(debug) + if !debug { + diag.SetOutput(ioutil.Discard) + } } diff --git a/stage1/init/kvm/network.go b/stage1/init/kvm/network.go index 68ce32e47d..6724983fe3 100644 --- a/stage1/init/kvm/network.go +++ b/stage1/init/kvm/network.go @@ -158,7 +158,7 @@ func GenerateNetworkInterfaceUnits(unitsPath string, netDescriptions []netDescri return errwrap.Wrap(fmt.Errorf("failed to create network unit file %q", unitName), err) } - rlog.Printf("network unit created: %q in %q (iface=%q, addr=%q)", unitName, unitsPath, ifName, address) + diag.Printf("network unit created: %q in %q (iface=%q, addr=%q)", unitName, unitsPath, ifName, address) } return nil } From fc0d9b6d2a0eb0f702e9b075819209b485962beb Mon Sep 17 00:00:00 2001 From: Vincent De Smet Date: Tue, 7 Jun 2016 23:54:48 +0800 Subject: [PATCH 0372/1304] Clarify the URL for the discovery example --- Documentation/signing-and-verification-guide.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/signing-and-verification-guide.md b/Documentation/signing-and-verification-guide.md index c58b570080..48431c9a0e 100644 --- a/Documentation/signing-and-verification-guide.md +++ b/Documentation/signing-and-verification-guide.md @@ -143,7 +143,7 @@ pubkeys.gpg ## Distributing Images via Meta Discovery -Host an HTML page with the following meta tags: +Host `example.com/hello` with the following HTML contents and meta tags: ```html @@ -152,8 +152,8 @@ Host an HTML page with the following meta tags: - - + + ``` Serve the following files at the locations described in the meta tags: From 524bdd90bd050efddcb91b5be1e9be610ef9cae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Tue, 7 Jun 2016 16:23:50 +0200 Subject: [PATCH 0373/1304] Godeps: bump go-systemd Fixes a panic on the api-service when calling GetLogs(). --- Godeps/Godeps.json | 22 +- .../coreos/go-systemd/dbus/methods.go | 53 ++++- .../coreos/go-systemd/sdjournal/journal.go | 196 +++++++++++++++++- .../coreos/go-systemd/sdjournal/read.go | 5 +- 4 files changed, 245 insertions(+), 31 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index f4fe087376..e7b5125206 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,7 +1,7 @@ { "ImportPath": "github.com/coreos/rkt", "GoVersion": "go1.5", - "GodepVersion": "v72", + "GodepVersion": "v74", "Packages": [ "./...", "github.com/appc/spec/actool", @@ -356,28 +356,28 @@ }, { "ImportPath": "github.com/coreos/go-systemd/activation", - "Comment": "v8", - "Rev": "b9b5f5970662ce700ab6ee41f56186e5b131490c" + "Comment": "v9", + "Rev": "6dc8b843c670f2027cc26b164935635840a40526" }, { "ImportPath": "github.com/coreos/go-systemd/dbus", - "Comment": "v8", - "Rev": "b9b5f5970662ce700ab6ee41f56186e5b131490c" + "Comment": "v9", + "Rev": "6dc8b843c670f2027cc26b164935635840a40526" }, { "ImportPath": "github.com/coreos/go-systemd/sdjournal", - "Comment": "v8", - "Rev": "b9b5f5970662ce700ab6ee41f56186e5b131490c" + "Comment": "v9", + "Rev": "6dc8b843c670f2027cc26b164935635840a40526" }, { "ImportPath": "github.com/coreos/go-systemd/unit", - "Comment": "v8", - "Rev": "b9b5f5970662ce700ab6ee41f56186e5b131490c" + "Comment": "v9", + "Rev": "6dc8b843c670f2027cc26b164935635840a40526" }, { "ImportPath": "github.com/coreos/go-systemd/util", - "Comment": "v8", - "Rev": "b9b5f5970662ce700ab6ee41f56186e5b131490c" + "Comment": "v9", + "Rev": "6dc8b843c670f2027cc26b164935635840a40526" }, { "ImportPath": "github.com/coreos/go-tspi/tpmclient", diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/methods.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/methods.go index 403c2f0f7b..8f32fe8a7d 100644 --- a/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/methods.go +++ b/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/methods.go @@ -239,12 +239,11 @@ type UnitStatus struct { JobPath dbus.ObjectPath // The job object path } -// ListUnits returns an array with all currently loaded units. Note that -// units may be known by multiple names at the same time, and hence there might -// be more unit names loaded than actual units behind them. -func (c *Conn) ListUnits() ([]UnitStatus, error) { +type storeFunc func(retvalues ...interface{}) error + +func (c *Conn) listUnitsInternal(f storeFunc) ([]UnitStatus, error) { result := make([][]interface{}, 0) - err := c.sysobj.Call("org.freedesktop.systemd1.Manager.ListUnits", 0).Store(&result) + err := f(&result) if err != nil { return nil, err } @@ -268,15 +267,43 @@ func (c *Conn) ListUnits() ([]UnitStatus, error) { return status, nil } +// ListUnits returns an array with all currently loaded units. Note that +// units may be known by multiple names at the same time, and hence there might +// be more unit names loaded than actual units behind them. +func (c *Conn) ListUnits() ([]UnitStatus, error) { + return c.listUnitsInternal(c.sysobj.Call("org.freedesktop.systemd1.Manager.ListUnits", 0).Store) +} + +// ListUnitsFiltered returns an array with units filtered by state. +// It takes a list of units' statuses to filter. +func (c *Conn) ListUnitsFiltered(states []string) ([]UnitStatus, error) { + return c.listUnitsInternal(c.sysobj.Call("org.freedesktop.systemd1.Manager.ListUnitsFiltered", 0, states).Store) +} + +// ListUnitsByPatterns returns an array with units. +// It takes a list of units' statuses and names to filter. +// Note that units may be known by multiple names at the same time, +// and hence there might be more unit names loaded than actual units behind them. +func (c *Conn) ListUnitsByPatterns(states []string, patterns []string) ([]UnitStatus, error) { + return c.listUnitsInternal(c.sysobj.Call("org.freedesktop.systemd1.Manager.ListUnitsByPatterns", 0, states, patterns).Store) +} + +// ListUnitsByNames returns an array with units. It takes a list of units' +// names and returns an UnitStatus array. Comparing to ListUnitsByPatterns +// method, this method returns statuses even for inactive or non-existing +// units. Input array should contain exact unit names, but not patterns. +func (c *Conn) ListUnitsByNames(units []string) ([]UnitStatus, error) { + return c.listUnitsInternal(c.sysobj.Call("org.freedesktop.systemd1.Manager.ListUnitsByNames", 0, units).Store) +} + type UnitFile struct { Path string Type string } -// ListUnitFiles returns an array of all available units on disk. -func (c *Conn) ListUnitFiles() ([]UnitFile, error) { +func (c *Conn) listUnitFilesInternal(f storeFunc) ([]UnitFile, error) { result := make([][]interface{}, 0) - err := c.sysobj.Call("org.freedesktop.systemd1.Manager.ListUnitFiles", 0).Store(&result) + err := f(&result) if err != nil { return nil, err } @@ -300,6 +327,16 @@ func (c *Conn) ListUnitFiles() ([]UnitFile, error) { return files, nil } +// ListUnitFiles returns an array of all available units on disk. +func (c *Conn) ListUnitFiles() ([]UnitFile, error) { + return c.listUnitFilesInternal(c.sysobj.Call("org.freedesktop.systemd1.Manager.ListUnitFiles", 0).Store) +} + +// ListUnitFilesByPatterns returns an array of all available units on disk matched the patterns. +func (c *Conn) ListUnitFilesByPatterns(states []string, patterns []string) ([]UnitFile, error) { + return c.listUnitFilesInternal(c.sysobj.Call("org.freedesktop.systemd1.Manager.ListUnitFilesByPatterns", 0, states, patterns).Store) +} + type LinkUnitFileChange EnableUnitFileChange // LinkUnitFiles() links unit files (that are located outside of the diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/journal.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/journal.go index d3c5675b1d..4fd29c66f1 100644 --- a/Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/journal.go +++ b/Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/journal.go @@ -25,6 +25,7 @@ package sdjournal // #include +// #include // #include // #include // @@ -182,6 +183,15 @@ package sdjournal // } // // int +// my_sd_journal_get_monotonic_usec(void *f, sd_journal *j, uint64_t *usec, sd_id128_t *boot_id) +// { +// int (*sd_journal_get_monotonic_usec)(sd_journal *, uint64_t *, sd_id128_t *); +// +// sd_journal_get_monotonic_usec = f; +// return sd_journal_get_monotonic_usec(j, usec, boot_id); +// } +// +// int // my_sd_journal_seek_head(void *f, sd_journal *j) // { // int (*sd_journal_seek_head)(sd_journal *); @@ -227,6 +237,24 @@ package sdjournal // return sd_journal_wait(j, timeout_usec); // } // +// void +// my_sd_journal_restart_data(void *f, sd_journal *j) +// { +// void (*sd_journal_restart_data)(sd_journal *); +// +// sd_journal_restart_data = f; +// sd_journal_restart_data(j); +// } +// +// int +// my_sd_journal_enumerate_data(void *f, sd_journal *j, const void **data, size_t *length) +// { +// int (*sd_journal_enumerate_data)(sd_journal *, const void **, size_t *); +// +// sd_journal_enumerate_data = f; +// return sd_journal_enumerate_data(j, data, length); +// } +// import "C" import ( "fmt" @@ -245,15 +273,45 @@ var libsystemdFunctions = map[string]unsafe.Pointer{} // Journal entry field strings which correspond to: // http://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html const ( - SD_JOURNAL_FIELD_SYSTEMD_UNIT = "_SYSTEMD_UNIT" - SD_JOURNAL_FIELD_SYSLOG_IDENTIFIER = "SYSLOG_IDENTIFIER" + // User Journal Fields SD_JOURNAL_FIELD_MESSAGE = "MESSAGE" - SD_JOURNAL_FIELD_PID = "_PID" - SD_JOURNAL_FIELD_UID = "_UID" - SD_JOURNAL_FIELD_GID = "_GID" - SD_JOURNAL_FIELD_HOSTNAME = "_HOSTNAME" - SD_JOURNAL_FIELD_MACHINE_ID = "_MACHINE_ID" - SD_JOURNAL_FIELD_TRANSPORT = "_TRANSPORT" + SD_JOURNAL_FIELD_MESSAGE_ID = "MESSAGE_ID" + SD_JOURNAL_FIELD_PRIORITY = "PRIORITY" + SD_JOURNAL_FIELD_CODE_FILE = "CODE_FILE" + SD_JOURNAL_FIELD_CODE_LINE = "CODE_LINE" + SD_JOURNAL_FIELD_CODE_FUNC = "CODE_FUNC" + SD_JOURNAL_FIELD_ERRNO = "ERRNO" + SD_JOURNAL_FIELD_SYSLOG_FACILITY = "SYSLOG_FACILITY" + SD_JOURNAL_FIELD_SYSLOG_IDENTIFIER = "SYSLOG_IDENTIFIER" + SD_JOURNAL_FIELD_SYSLOG_PID = "SYSLOG_PID" + + // Trusted Journal Fields + SD_JOURNAL_FIELD_PID = "_PID" + SD_JOURNAL_FIELD_UID = "_UID" + SD_JOURNAL_FIELD_GID = "_GID" + SD_JOURNAL_FIELD_COMM = "_COMM" + SD_JOURNAL_FIELD_EXE = "_EXE" + SD_JOURNAL_FIELD_CMDLINE = "_CMDLINE" + SD_JOURNAL_FIELD_CAP_EFFECTIVE = "_CAP_EFFECTIVE" + SD_JOURNAL_FIELD_AUDIT_SESSION = "_AUDIT_SESSION" + SD_JOURNAL_FIELD_AUDIT_LOGINUID = "_AUDIT_LOGINUID" + SD_JOURNAL_FIELD_SYSTEMD_CGROUP = "_SYSTEMD_CGROUP" + SD_JOURNAL_FIELD_SYSTEMD_SESSION = "_SYSTEMD_SESSION" + SD_JOURNAL_FIELD_SYSTEMD_UNIT = "_SYSTEMD_UNIT" + SD_JOURNAL_FIELD_SYSTEMD_USER_UNIT = "_SYSTEMD_USER_UNIT" + SD_JOURNAL_FIELD_SYSTEMD_OWNER_UID = "_SYSTEMD_OWNER_UID" + SD_JOURNAL_FIELD_SYSTEMD_SLICE = "_SYSTEMD_SLICE" + SD_JOURNAL_FIELD_SELINUX_CONTEXT = "_SELINUX_CONTEXT" + SD_JOURNAL_FIELD_SOURCE_REALTIME_TIMESTAMP = "_SOURCE_REALTIME_TIMESTAMP" + SD_JOURNAL_FIELD_BOOT_ID = "_BOOT_ID" + SD_JOURNAL_FIELD_MACHINE_ID = "_MACHINE_ID" + SD_JOURNAL_FIELD_HOSTNAME = "_HOSTNAME" + SD_JOURNAL_FIELD_TRANSPORT = "_TRANSPORT" + + // Address Fields + SD_JOURNAL_FIELD_CURSOR = "__CURSOR" + SD_JOURNAL_FIELD_REALTIME_TIMESTAMP = "__REALTIME_TIMESTAMP" + SD_JOURNAL_FIELD_MONOTONIC_TIMESTAMP = "__MONOTONIC_TIMESTAMP" ) // Journal event constants @@ -288,6 +346,14 @@ type Journal struct { lib *dlopen.LibHandle } +// JournalEntry represents all fields of a journal entry plus address fields. +type JournalEntry struct { + Fields map[string]string + Cursor string + RealtimeTimestamp uint64 + MonotonicTimestamp uint64 +} + // Match is a convenience wrapper to describe filters supplied to AddMatch. type Match struct { Field string @@ -400,7 +466,9 @@ func (j *Journal) Close() error { C.my_sd_journal_close(sd_journal_close, j.cjournal) j.mu.Unlock() - return j.lib.Close() + // we don't close the handle to reuse the symbol cache between Journal + // instances. It will go away when the process exits. + return nil } // AddMatch adds a match by which to filter the entries of the journal. @@ -583,6 +651,93 @@ func (j *Journal) GetDataValue(field string) (string, error) { return strings.SplitN(val, "=", 2)[1], nil } +// GetEntry returns a full representation of a journal entry with +// all key-value pairs of data as well as address fields (cursor, realtime +// timestamp and monotonic timestamp) +func (j *Journal) GetEntry() (*JournalEntry, error) { + sd_journal_get_realtime_usec, err := j.getFunction("sd_journal_get_realtime_usec") + if err != nil { + return nil, err + } + + sd_journal_get_monotonic_usec, err := j.getFunction("sd_journal_get_monotonic_usec") + if err != nil { + return nil, err + } + + sd_journal_get_cursor, err := j.getFunction("sd_journal_get_cursor") + if err != nil { + return nil, err + } + + sd_journal_restart_data, err := j.getFunction("sd_journal_restart_data") + if err != nil { + return nil, err + } + + sd_journal_enumerate_data, err := j.getFunction("sd_journal_enumerate_data") + if err != nil { + return nil, err + } + + j.mu.Lock() + defer j.mu.Unlock() + + var r C.int + entry := &JournalEntry{Fields: make(map[string]string)} + + var realtimeUsec C.uint64_t + r = C.my_sd_journal_get_realtime_usec(sd_journal_get_realtime_usec, j.cjournal, &realtimeUsec) + if r < 0 { + return nil, fmt.Errorf("failed to get realtime timestamp: %d", syscall.Errno(-r)) + } + + entry.RealtimeTimestamp = uint64(realtimeUsec) + + var monotonicUsec C.uint64_t + var boot_id C.sd_id128_t + + r = C.my_sd_journal_get_monotonic_usec(sd_journal_get_monotonic_usec, j.cjournal, &monotonicUsec, &boot_id) + if r < 0 { + return nil, fmt.Errorf("failed to get monotonic timestamp: %d", syscall.Errno(-r)) + } + + entry.MonotonicTimestamp = uint64(monotonicUsec) + + var c *C.char + r = C.my_sd_journal_get_cursor(sd_journal_get_cursor, j.cjournal, &c) + if r < 0 { + return nil, fmt.Errorf("failed to get cursor: %d", syscall.Errno(-r)) + } + + entry.Cursor = C.GoString(c) + + // Implements the JOURNAL_FOREACH_DATA_RETVAL macro from journal-internal.h + var d unsafe.Pointer + var l C.size_t + C.my_sd_journal_restart_data(sd_journal_restart_data, j.cjournal) + for { + r = C.my_sd_journal_enumerate_data(sd_journal_enumerate_data, j.cjournal, &d, &l) + if r == 0 { + break + } + + if r < 0 { + return nil, fmt.Errorf("failed to read message field: %d", syscall.Errno(-r)) + } + + msg := C.GoStringN((*C.char)(d), C.int(l)) + kv := strings.SplitN(msg, "=", 2) + if len(kv) < 2 { + return nil, fmt.Errorf("failed to parse field") + } + + entry.Fields[kv[0]] = kv[1] + } + + return entry, nil +} + // SetDataThresold sets the data field size threshold for data returned by // GetData. To retrieve the complete data fields this threshold should be // turned off by setting it to 0, so that the library always returns the @@ -619,7 +774,28 @@ func (j *Journal) GetRealtimeUsec() (uint64, error) { j.mu.Unlock() if r < 0 { - return 0, fmt.Errorf("error getting timestamp for entry: %d", syscall.Errno(-r)) + return 0, fmt.Errorf("failed to get realtime timestamp: %d", syscall.Errno(-r)) + } + + return uint64(usec), nil +} + +// GetMonotonicUsec gets the monotonic timestamp of the current journal entry. +func (j *Journal) GetMonotonicUsec() (uint64, error) { + var usec C.uint64_t + var boot_id C.sd_id128_t + + sd_journal_get_monotonic_usec, err := j.getFunction("sd_journal_get_monotonic_usec") + if err != nil { + return 0, err + } + + j.mu.Lock() + r := C.my_sd_journal_get_monotonic_usec(sd_journal_get_monotonic_usec, j.cjournal, &usec, &boot_id) + j.mu.Unlock() + + if r < 0 { + return 0, fmt.Errorf("failed to get monotonic timestamp: %d", syscall.Errno(-r)) } return uint64(usec), nil diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/read.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/read.go index 161577870b..73a0d51e96 100644 --- a/Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/read.go +++ b/Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/read.go @@ -29,8 +29,9 @@ var ( // JournalReaderConfig represents options to drive the behavior of a JournalReader. type JournalReaderConfig struct { - // The Since and NumFromTail options are mutually exclusive and determine - // where the reading begins within the journal. + // The Since, NumFromTail and Cursor options are mutually exclusive and + // determine where the reading begins within the journal. The order in which + // options are written is exactly the order of precedence. Since time.Duration // start relative to a Duration from now NumFromTail uint64 // start relative to the tail Cursor string // start relative to the cursor From 345af3e81c8152dcf54fb37417d71f78d7782d88 Mon Sep 17 00:00:00 2001 From: Mark Petrovic Date: Tue, 7 Jun 2016 09:59:19 -0700 Subject: [PATCH 0374/1304] networking: remove superfluous %v printf verb in stderr.PrintE("error loading podNS: %v", err) in networking.go Fixes #2749 --- networking/networking.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/networking/networking.go b/networking/networking.go index faae829003..1d6cd4b10a 100644 --- a/networking/networking.go +++ b/networking/networking.go @@ -274,7 +274,7 @@ func (n *Networking) Teardown(flavor string, debug bool) { podNS, err := n.podNSLoad() if err != nil { - stderr.PrintE("error loading podNS: %v", err) + stderr.PrintE("error loading podNS", err) } if podNS != nil { defer func() { From da00c01acd536656d98b37a171e01b5b18f78e33 Mon Sep 17 00:00:00 2001 From: Angus Lees Date: Wed, 8 Jun 2016 12:08:31 +1000 Subject: [PATCH 0375/1304] common: Use untyped FsMagic constants The size of Statfs_t.Type varies by platform. Use untyped constants to avoid a compile error on non-64bit platforms. --- common/common.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/common.go b/common/common.go index 4320edfd0a..e1ab87f871 100644 --- a/common/common.go +++ b/common/common.go @@ -58,8 +58,8 @@ const ( ) const ( - FsMagicAUFS = int64(0x61756673) // https://goo.gl/CBwx43 - FsMagicZFS = int64(0x2FC12FC1) // https://goo.gl/xTvzO5 + FsMagicAUFS = 0x61756673 // https://goo.gl/CBwx43 + FsMagicZFS = 0x2FC12FC1 // https://goo.gl/xTvzO5 ) // Stage1ImagePath returns the path where the stage1 app image (unpacked ACI) is rooted, From b75eee20b285769a43d73300832e083ff78c3836 Mon Sep 17 00:00:00 2001 From: Angus Lees Date: Wed, 8 Jun 2016 12:11:59 +1000 Subject: [PATCH 0376/1304] rkt.mk: Compile generators for *build* platform manpages_gen and bash_completion_gen are compiled and run at build time, so need to be built for the build platform, not the target platform. This change overrides GOARCH/CC appropriately for these two targets. Note building these tools requires that the systemd and acl C headers are also available for the build architecture. --- rkt/rkt.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rkt/rkt.mk b/rkt/rkt.mk index e04e893dbd..48a26773f4 100644 --- a/rkt/rkt.mk +++ b/rkt/rkt.mk @@ -29,10 +29,12 @@ $(BGB_BINARY): $(MK_PATH) | $(BINDIR) include makelib/build_go_bin.mk +manpages: GO_ENV += GOARCH=$(GOARCH_FOR_BUILD) CC=$(CC_FOR_BUILD) manpages: | $(GOPATH_TO_CREATE)/src/$(REPO_PATH) mkdir -p dist/manpages/ ls rkt/*.go | grep -vE '_test.go|main.go|_gen.go' | $(GO_ENV) xargs "$(GO)" run rkt/manpages_gen.go +bash-completion: GO_ENV += GOARCH=$(GOARCH_FOR_BUILD) CC=$(CC_FOR_BUILD) bash-completion: | $(GOPATH_TO_CREATE)/src/$(REPO_PATH) mkdir -p dist/bash_completion/ ls rkt/*.go | grep -vE '_test.go|main.go|_gen.go' | $(GO_ENV) xargs "$(GO)" run rkt/bash_completion_gen.go From c3bc7cc7956be56fcc0f647622effabf0f1b98da Mon Sep 17 00:00:00 2001 From: Matthias Jahn Date: Thu, 19 May 2016 10:52:36 +0200 Subject: [PATCH 0377/1304] trust: change error message if prefix/root flag missing Error message is not helpful at the moment for the user Fixes #480 --- Documentation/subcommands/trust.md | 2 +- rkt/trust.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Documentation/subcommands/trust.md b/Documentation/subcommands/trust.md index 68611f0095..3841af8afb 100644 --- a/Documentation/subcommands/trust.md +++ b/Documentation/subcommands/trust.md @@ -16,7 +16,7 @@ A few examples: # rkt trust --prefix=coreos.com/etcd ``` -To trust a key for an entire root domain, you must use the `--root` flag, with a path to a local key file (no discovery). +To trust a key for an entire root domain, you must use the `--root` flag, with a path to a key file (no discovery). ``` # rkt trust --root ~/aci-pubkeys.gpg diff --git a/rkt/trust.go b/rkt/trust.go index 14d6c2bbd0..0679bf2e9e 100644 --- a/rkt/trust.go +++ b/rkt/trust.go @@ -59,7 +59,12 @@ func init() { func runTrust(cmd *cobra.Command, args []string) (exit int) { if flagPrefix == "" && !flagRoot { if len(args) != 0 { - stderr.Print("--root required for non-prefixed (root) keys") + stderr.Print(`aborting due to implicit unbounded trust (root domain) +Please provide a specific domain prefix to trust: + rkt trust --prefix "example.com/foo" [PUBKEY] + rkt trust --prefix "example.com/foo/*" [PUBKEY] +Otherwise, trust at the root domain (not recommended) must be explicitly requested: + rkt trust --root PUBKEY`) } else { cmd.Usage() } From 6af0d3097ae2cb14f860b1096a92ea77f920d63c Mon Sep 17 00:00:00 2001 From: Yifan Gu Date: Wed, 8 Jun 2016 13:34:59 -0700 Subject: [PATCH 0378/1304] api_service: Fix the GetLogs() when appname is given. When appname is given, we should set SYSLOG_IDENTIFIER=appname instead of the service name. --- api/v1alpha/client_example.go | 10 ++++++---- rkt/api_service.go | 7 +------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/api/v1alpha/client_example.go b/api/v1alpha/client_example.go index 861823aa1d..631098298b 100644 --- a/api/v1alpha/client_example.go +++ b/api/v1alpha/client_example.go @@ -29,8 +29,9 @@ import ( func getLogsWithoutFollow(c v1alpha.PublicAPIClient, p *v1alpha.Pod) { logsResp, err := c.GetLogs(context.Background(), &v1alpha.GetLogsRequest{ - PodId: p.Id, - Follow: false, + PodId: p.Id, + Follow: false, + AppName: p.Apps[0].Name, }) if err != nil { fmt.Println(err) @@ -50,8 +51,9 @@ func getLogsWithoutFollow(c v1alpha.PublicAPIClient, p *v1alpha.Pod) { func getLogsWithFollow(c v1alpha.PublicAPIClient, p *v1alpha.Pod) { logsResp, err := c.GetLogs(context.Background(), &v1alpha.GetLogsRequest{ - PodId: p.Id, - Follow: true, + PodId: p.Id, + Follow: true, + AppName: p.Apps[0].Name, }) if err != nil { fmt.Println(err) diff --git a/rkt/api_service.go b/rkt/api_service.go index 6cb0eaa82a..b957d09afe 100644 --- a/rkt/api_service.go +++ b/rkt/api_service.go @@ -34,7 +34,6 @@ import ( "github.com/coreos/rkt/common" "github.com/coreos/rkt/common/cgroup" "github.com/coreos/rkt/pkg/set" - stage1common "github.com/coreos/rkt/stage1/init/common" "github.com/coreos/rkt/store" "github.com/coreos/rkt/version" "github.com/spf13/cobra" @@ -740,14 +739,10 @@ func (s *v1AlphaAPIServer) GetLogs(request *v1alpha.GetLogsRequest, server v1alp Path: path, } if request.AppName != "" { - acname, err := types.NewACName(request.AppName) - if err != nil { - return err - } jconf.Matches = []sdjournal.Match{ { Field: sdjournal.SD_JOURNAL_FIELD_SYSLOG_IDENTIFIER, - Value: stage1common.ServiceUnitName(*acname), + Value: request.AppName, }, } } From 2a343ee1eb85b2e95cf87bc4c3aaa24267a19a34 Mon Sep 17 00:00:00 2001 From: Yifan Gu Date: Wed, 8 Jun 2016 14:02:21 -0700 Subject: [PATCH 0379/1304] api_service: Fix the 'Since' in Getlogs(). The go-systemd will expect a positive 'Since' duration for logs in the future, and a negative 'Since' duration for logs in the past. --- api/v1alpha/client_example.go | 9 ++++++--- rkt/api_service.go | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/api/v1alpha/client_example.go b/api/v1alpha/client_example.go index 631098298b..e4ebfb31a2 100644 --- a/api/v1alpha/client_example.go +++ b/api/v1alpha/client_example.go @@ -21,6 +21,7 @@ import ( "fmt" "io" "os" + "time" "github.com/coreos/rkt/api/v1alpha" "golang.org/x/net/context" @@ -29,9 +30,11 @@ import ( func getLogsWithoutFollow(c v1alpha.PublicAPIClient, p *v1alpha.Pod) { logsResp, err := c.GetLogs(context.Background(), &v1alpha.GetLogsRequest{ - PodId: p.Id, - Follow: false, - AppName: p.Apps[0].Name, + PodId: p.Id, + Follow: false, + AppName: p.Apps[0].Name, + SinceTime: time.Now().Add(-time.Second * 5).Unix(), + Lines: 10, }) if err != nil { fmt.Println(err) diff --git a/rkt/api_service.go b/rkt/api_service.go index b957d09afe..d98afc152d 100644 --- a/rkt/api_service.go +++ b/rkt/api_service.go @@ -748,7 +748,7 @@ func (s *v1AlphaAPIServer) GetLogs(request *v1alpha.GetLogsRequest, server v1alp } if request.SinceTime != 0 { t := time.Unix(request.SinceTime, 0) - jconf.Since = time.Since(t) + jconf.Since = -time.Since(t) } if request.Lines != 0 { jconf.NumFromTail = uint64(request.Lines) From 1559cc2802df06ef11b906720b463d38e9534152 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Thu, 9 Jun 2016 11:45:24 +0200 Subject: [PATCH 0380/1304] api/client_example: fix panic if pod has no apps --- api/v1alpha/client_example.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/api/v1alpha/client_example.go b/api/v1alpha/client_example.go index e4ebfb31a2..6be7c32ac0 100644 --- a/api/v1alpha/client_example.go +++ b/api/v1alpha/client_example.go @@ -29,6 +29,11 @@ import ( ) func getLogsWithoutFollow(c v1alpha.PublicAPIClient, p *v1alpha.Pod) { + if len(p.Apps) == 0 { + fmt.Printf("Pod %q has no apps\n", p.Id) + return + } + logsResp, err := c.GetLogs(context.Background(), &v1alpha.GetLogsRequest{ PodId: p.Id, Follow: false, @@ -53,6 +58,11 @@ func getLogsWithoutFollow(c v1alpha.PublicAPIClient, p *v1alpha.Pod) { } func getLogsWithFollow(c v1alpha.PublicAPIClient, p *v1alpha.Pod) { + if len(p.Apps) == 0 { + fmt.Printf("Pod %q has no apps\n", p.Id) + return + } + logsResp, err := c.GetLogs(context.Background(), &v1alpha.GetLogsRequest{ PodId: p.Id, Follow: true, From 5393f2e99b1ae3d3b6b232bf428dd15a88714663 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Thu, 9 Jun 2016 11:45:38 +0200 Subject: [PATCH 0381/1304] version: bump to v1.8.0 --- CHANGELOG.md | 26 +++++++++++++++++++++++++ Documentation/getting-started-ubuntu.md | 6 +++--- Documentation/running-fly-stage1.md | 4 ++-- Documentation/running-lkvm-stage1.md | 4 ++-- Documentation/subcommands/prepare.md | 2 +- Documentation/subcommands/version.md | 2 +- Documentation/trying-out-rkt.md | 6 +++--- ROADMAP.md | 22 +++++++++++++-------- configure.ac | 2 +- scripts/acbuild-rkt-builder.sh | 2 +- scripts/build-rir.sh | 2 +- tests/empty-image/manifest | 2 +- tests/image/manifest | 2 +- tests/rkt_exec_test.go | 2 +- tests/rkt_image_cat_manifest_test.go | 2 +- tests/rkt_image_export_test.go | 2 +- tests/rkt_image_render_test.go | 2 +- tests/rkt_os_arch_test.go | 2 +- 18 files changed, 62 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44ea24ac44..7e7ebf54dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,29 @@ +## v1.8.0 + +This release focuses on stabilizing the API service, fixing multiple issues in the logging subsystem. + +#### New features and UX changes + +- api: GetLogs: improve client example with 'Follow' ([#2747](https://github.com/coreos/rkt/pull/2747)). +- kvm: add proxy arp support to macvtap ([#2715](https://github.com/coreos/rkt/pull/2715)). +- stage0/config: add a CLI flag to pretty print json ([#2745](https://github.com/coreos/rkt/pull/2745)). +- stage1: make /proc/bus/ read-only ([#2743](https://github.com/coreos/rkt/pull/2743)). + +#### Bug fixes + +- api: GetLogs: use the correct type in LogsStreamWriter ([#2744](https://github.com/coreos/rkt/pull/2744)). +- api: fix service panic on incomplete pods ([#2739](https://github.com/coreos/rkt/pull/2739)). +- api: Fix the GetLogs() when appname is given ([#2763](https://github.com/coreos/rkt/pull/2763)). +- pkg/selinux: various fixes ([#2723](https://github.com/coreos/rkt/pull/2723)). +- pkg/fileutil: don't remove the cleanSrc if it equals '.' ([#2731](https://github.com/coreos/rkt/pull/2731)). +- stage0: remove superfluous error verbs ([#2750](https://github.com/coreos/rkt/pull/2750)). + +#### Other changes + +- Godeps: bump go-systemd ([#2754](https://github.com/coreos/rkt/pull/2754)). Fixes a panic on the api-service when calling GetLogs(). +- Documentation updates ([#2756](https://github.com/coreos/rkt/pull/2756), [#2741](https://github.com/coreos/rkt/pull/2741), [#2737](https://github.com/coreos/rkt/pull/2737), [#2742](https://github.com/coreos/rkt/pull/2742), [#2730](https://github.com/coreos/rkt/pull/2730), [#2729](https://github.com/coreos/rkt/pull/2729)) +- Test improvements ([#2726](https://github.com/coreos/rkt/pull/2726)). + ## v1.7.0 This release introduces some new security features, including a "no-new-privileges" isolator and initial (partial) restrictions on /proc and /sys access. diff --git a/Documentation/getting-started-ubuntu.md b/Documentation/getting-started-ubuntu.md index 413d3b1c97..83eb6208e9 100644 --- a/Documentation/getting-started-ubuntu.md +++ b/Documentation/getting-started-ubuntu.md @@ -15,9 +15,9 @@ vagrant up --provider virtualbox vagrant ssh sudo -s -wget https://github.com/coreos/rkt/releases/download/v1.7.0/rkt-v1.7.0.tar.gz -tar xzvf rkt-v1.7.0.tar.gz -cd rkt-v1.7.0 +wget https://github.com/coreos/rkt/releases/download/v1.8.0/rkt-v1.8.0.tar.gz +tar xzvf rkt-v1.8.0.tar.gz +cd rkt-v1.8.0 ./rkt help ``` diff --git a/Documentation/running-fly-stage1.md b/Documentation/running-fly-stage1.md index 8b4b0378f0..b391e90754 100644 --- a/Documentation/running-fly-stage1.md +++ b/Documentation/running-fly-stage1.md @@ -60,14 +60,14 @@ $ ./autogen.sh && ./configure --with-stage1-flavors=fly && make ``` For more details about configure parameters, see the [configure script parameters documentation](build-configure.md). -This will build the rkt binary and the stage1-fly.aci in `build-rkt-1.7.0+git/bin/`. +This will build the rkt binary and the stage1-fly.aci in `build-rkt-1.8.0+git/bin/`. ### Selecting stage1 at runtime Here is a quick example of how to use a container with the official fly stage1: ``` -# rkt run --stage1-name=coreos.com/rkt/stage1-fly:1.7.0 coreos.com/etcd:v2.2.5 +# rkt run --stage1-name=coreos.com/rkt/stage1-fly:1.8.0 coreos.com/etcd:v2.2.5 ``` If the image is not in the store, `--stage1-name` will perform discovery and fetch the image. diff --git a/Documentation/running-lkvm-stage1.md b/Documentation/running-lkvm-stage1.md index 01c5a5b7ac..666b5a6c76 100644 --- a/Documentation/running-lkvm-stage1.md +++ b/Documentation/running-lkvm-stage1.md @@ -13,7 +13,7 @@ $ ./autogen.sh && ./configure --with-stage1-flavors=kvm && make ``` For more details about configure parameters, see [configure script parameters documentation](build-configure.md). -This will build the rkt binary and the LKVM stage1-kvm.aci in `build-rkt-1.7.0+git/bin/`. +This will build the rkt binary and the LKVM stage1-kvm.aci in `build-rkt-1.8.0+git/bin/`. Provided you have hardware virtualization support and the [kernel KVM module](http://www.linux-kvm.org/page/Getting_the_kvm_kernel_modules) loaded (refer to your distribution for instructions), you can then run an image like you would normally do with rkt: @@ -84,7 +84,7 @@ If you want to run software that requires hypervisor isolation along with truste For example, to use the official lkvm stage1: ``` -# rkt run --stage1-name=coreos.com/rkt/stage1-kvm:1.7.0 coreos.com/etcd:v2.0.9 +# rkt run --stage1-name=coreos.com/rkt/stage1-kvm:1.8.0 coreos.com/etcd:v2.0.9 ... ``` diff --git a/Documentation/subcommands/prepare.md b/Documentation/subcommands/prepare.md index 2791f20968..0cbb1e1fcc 100644 --- a/Documentation/subcommands/prepare.md +++ b/Documentation/subcommands/prepare.md @@ -14,7 +14,7 @@ Therefore, the supported arguments are mostly the same as in `run` except runtim ``` # rkt prepare coreos.com/etcd:v2.0.10 rkt prepare coreos.com/etcd:v2.0.10 -rkt: using image from local store for image name coreos.com/rkt/stage1-coreos:1.7.0 +rkt: using image from local store for image name coreos.com/rkt/stage1-coreos:1.8.0 rkt: searching for app image coreos.com/etcd:v2.0.10 rkt: remote fetching from url https://github.com/coreos/etcd/releases/download/v2.0.10/etcd-v2.0.10-linux-amd64.aci prefix: "coreos.com/etcd" diff --git a/Documentation/subcommands/version.md b/Documentation/subcommands/version.md index d23ae66475..b9ff8fe7a1 100644 --- a/Documentation/subcommands/version.md +++ b/Documentation/subcommands/version.md @@ -6,7 +6,7 @@ This command prints the rkt version, the appc version rkt is built against, and ``` $ rkt version -rkt Version: 1.7.0 +rkt Version: 1.8.0 appc Version: 0.7.4 Go Version: go1.5.3 Go OS/Arch: linux/amd64 diff --git a/Documentation/trying-out-rkt.md b/Documentation/trying-out-rkt.md index dec49926d4..b8f2b7b2a0 100644 --- a/Documentation/trying-out-rkt.md +++ b/Documentation/trying-out-rkt.md @@ -10,9 +10,9 @@ rkt consists of a single CLI tool, and is currently supported on amd64 Linux. A To download the rkt binary, simply grab the latest release directly from GitHub: ``` -wget https://github.com/coreos/rkt/releases/download/v1.7.0/rkt-v1.7.0.tar.gz -tar xzvf rkt-v1.7.0.tar.gz -cd rkt-v1.7.0 +wget https://github.com/coreos/rkt/releases/download/v1.8.0/rkt-v1.8.0.tar.gz +tar xzvf rkt-v1.8.0.tar.gz +cd rkt-v1.8.0 ./rkt help ``` diff --git a/ROADMAP.md b/ROADMAP.md index a5e9422d2b..73618c88ed 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -10,19 +10,25 @@ The version of the spec that rkt implements can be seen in the output of `rkt ve rkt's version 1.0 release marks the command line user interface and on-disk data structures as stable and reliable for external development. The (optional) API for pod inspection is not yet completely stabilized, but is quite usable. -### rkt 1.8 (June) +### rkt 1.9.0 (June) +- full integration with Kubernetes (aka "rktnetes") - app-level seccomp support [#1614](https://github.com/coreos/rkt/issues/1614) -- stable gRPC [API](https://github.com/coreos/rkt/tree/master/api/v1alpha) +- enhanced DNS configuration [#2044](https://github.com/coreos/rkt/issues/2044) - IPv6 support [appc/cni#31](https://github.com/appc/cni/issues/31) -- full integration with Kubernetes (aka "rktnetes") + +### rkt 1.10.0 (July) + +- stable gRPC [API](https://github.com/coreos/rkt/tree/master/api/v1alpha) +- further improvements for SELinux environments, especially Fedora in enforcing mode - full integration with `machinectl login` and `systemd-run` [#1463](https://github.com/coreos/rkt/issues/1463) -- `rkt fly` as top-level command [#1889](https://github.com/coreos/rkt/issues/1889) -- rkt runs on Fedora with SELinux in enforcing mode + +### rkt 1.11.0 (July) + - packaged for more distributions - CentOS [#1305](https://github.com/coreos/rkt/issues/1305) -- user configuration for stage1 [#2013](https://github.com/coreos/rkt/issues/2013) -### rkt 1.9 (June) +### rkt 1.12.0 (August) -- enhanced DNS configuration [#2044](https://github.com/coreos/rkt/issues/2044) +- `rkt fly` as top-level command [#1889](https://github.com/coreos/rkt/issues/1889) +- user configuration for stage1 [#2013](https://github.com/coreos/rkt/issues/2013) diff --git a/configure.ac b/configure.ac index a65bdd62f1..00833d1223 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.63]) -AC_INIT([rkt], [1.7.0+git], [https://github.com/coreos/rkt/issues]) +AC_INIT([rkt], [1.8.0], [https://github.com/coreos/rkt/issues]) AC_DEFUN([RKT_CHECK_PROG], [AS_VAR_IF([$1], [], diff --git a/scripts/acbuild-rkt-builder.sh b/scripts/acbuild-rkt-builder.sh index 9b66b9c421..aa409ce939 100755 --- a/scripts/acbuild-rkt-builder.sh +++ b/scripts/acbuild-rkt-builder.sh @@ -17,7 +17,7 @@ fi MODIFY=${MODIFY:-""} FLAGS=${FLAGS:-""} IMG_NAME="coreos.com/rkt/builder" -IMG_VERSION=${VERSION:-"v1.7.0+git"} +IMG_VERSION=${VERSION:-"v1.8.0"} ACI_FILE=rkt-builder.aci BUILDDIR=/opt/build-rkt SRC_DIR=/opt/rkt diff --git a/scripts/build-rir.sh b/scripts/build-rir.sh index fa5d54e35d..b586925846 100755 --- a/scripts/build-rir.sh +++ b/scripts/build-rir.sh @@ -4,7 +4,7 @@ set -xe SRC_DIR="${SRC_DIR:-$PWD}" BUILDDIR="${BUILDDIR:-$PWD/build-rir}" -RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.7.0+git}" +RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.8.0}" mkdir -p $BUILDDIR diff --git a/tests/empty-image/manifest b/tests/empty-image/manifest index 9e3ee0a986..b477c36f3f 100644 --- a/tests/empty-image/manifest +++ b/tests/empty-image/manifest @@ -5,7 +5,7 @@ "labels": [ { "name": "version", - "value": "1.7.0" + "value": "1.8.0" }, { "name": "arch", diff --git a/tests/image/manifest b/tests/image/manifest index 228c2ce830..590a406418 100644 --- a/tests/image/manifest +++ b/tests/image/manifest @@ -5,7 +5,7 @@ "labels": [ { "name": "version", - "value": "1.7.0" + "value": "1.8.0" }, { "name": "arch", diff --git a/tests/rkt_exec_test.go b/tests/rkt_exec_test.go index b3c8c0224b..1565d7a79f 100644 --- a/tests/rkt_exec_test.go +++ b/tests/rkt_exec_test.go @@ -26,7 +26,7 @@ import ( ) const ( - noappManifestStr = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"coreos.com/rkt-inspect","labels":[{"name":"version","value":"1.7.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}]}` + noappManifestStr = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"coreos.com/rkt-inspect","labels":[{"name":"version","value":"1.8.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}]}` ) func TestRunOverrideExec(t *testing.T) { diff --git a/tests/rkt_image_cat_manifest_test.go b/tests/rkt_image_cat_manifest_test.go index 5ec32f02c9..1393f8b6cc 100644 --- a/tests/rkt_image_cat_manifest_test.go +++ b/tests/rkt_image_cat_manifest_test.go @@ -29,7 +29,7 @@ import ( const ( // The expected image manifest of the 'rkt-inspect-image-cat-manifest.aci'. - manifestTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.7.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.8.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageCatManifest tests 'rkt image cat-manifest', it will: diff --git a/tests/rkt_image_export_test.go b/tests/rkt_image_export_test.go index eb4adcdf85..5c1f006d08 100644 --- a/tests/rkt_image_export_test.go +++ b/tests/rkt_image_export_test.go @@ -28,7 +28,7 @@ import ( ) const ( - manifestExportTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.7.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestExportTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.8.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageExport tests 'rkt image export', it will import some existing diff --git a/tests/rkt_image_render_test.go b/tests/rkt_image_render_test.go index d86a9cb711..a2bbacb107 100644 --- a/tests/rkt_image_render_test.go +++ b/tests/rkt_image_render_test.go @@ -28,7 +28,7 @@ import ( ) const ( - manifestRenderTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.7.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"dependencies":[{"imageName":"coreos.com/rkt-inspect"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestRenderTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.8.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"dependencies":[{"imageName":"coreos.com/rkt-inspect"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageRender tests 'rkt image render', it will import some existing empty diff --git a/tests/rkt_os_arch_test.go b/tests/rkt_os_arch_test.go index 357ee15c20..c7236d717f 100644 --- a/tests/rkt_os_arch_test.go +++ b/tests/rkt_os_arch_test.go @@ -27,7 +27,7 @@ import ( ) const ( - manifestOSArchTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.7.0"}ARCH_OS],"app":{"exec":["/inspect", "--print-msg=HelloWorld"],"user":"0","group":"0","workingDirectory":"/"}}` + manifestOSArchTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.8.0"}ARCH_OS],"app":{"exec":["/inspect", "--print-msg=HelloWorld"],"user":"0","group":"0","workingDirectory":"/"}}` ) type osArchTest struct { From 6633dc73d67c76a8201f5b0548312207ba1e931b Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Thu, 9 Jun 2016 11:45:38 +0200 Subject: [PATCH 0382/1304] version: bump to v1.8.0+git --- configure.ac | 2 +- scripts/acbuild-rkt-builder.sh | 2 +- scripts/build-rir.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 00833d1223..1cb0980034 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.63]) -AC_INIT([rkt], [1.8.0], [https://github.com/coreos/rkt/issues]) +AC_INIT([rkt], [1.8.0+git], [https://github.com/coreos/rkt/issues]) AC_DEFUN([RKT_CHECK_PROG], [AS_VAR_IF([$1], [], diff --git a/scripts/acbuild-rkt-builder.sh b/scripts/acbuild-rkt-builder.sh index aa409ce939..4bfe9763d6 100755 --- a/scripts/acbuild-rkt-builder.sh +++ b/scripts/acbuild-rkt-builder.sh @@ -17,7 +17,7 @@ fi MODIFY=${MODIFY:-""} FLAGS=${FLAGS:-""} IMG_NAME="coreos.com/rkt/builder" -IMG_VERSION=${VERSION:-"v1.8.0"} +IMG_VERSION=${VERSION:-"v1.8.0+git"} ACI_FILE=rkt-builder.aci BUILDDIR=/opt/build-rkt SRC_DIR=/opt/rkt diff --git a/scripts/build-rir.sh b/scripts/build-rir.sh index b586925846..c18a070acf 100755 --- a/scripts/build-rir.sh +++ b/scripts/build-rir.sh @@ -4,7 +4,7 @@ set -xe SRC_DIR="${SRC_DIR:-$PWD}" BUILDDIR="${BUILDDIR:-$PWD/build-rir}" -RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.8.0}" +RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.8.0+git}" mkdir -p $BUILDDIR From ff7820c44f4ea4a3fa80e01324546c63af1feb83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20=C5=BBy=C5=82owski?= Date: Fri, 13 May 2016 18:24:34 +0200 Subject: [PATCH 0383/1304] docs: New file in documentation - instruction for new developers in rkt My write up about first steps in preparing development environment --- Documentation/devel/quickstart-dev.md | 124 ++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 Documentation/devel/quickstart-dev.md diff --git a/Documentation/devel/quickstart-dev.md b/Documentation/devel/quickstart-dev.md new file mode 100644 index 0000000000..63d4528d97 --- /dev/null +++ b/Documentation/devel/quickstart-dev.md @@ -0,0 +1,124 @@ +# Preparing development environment and first rkt build + +This is an example configuration and quick start guide for the installation of rkt from source on Ubuntu 16.04 GNOME. For a detailed developer's reference, see [the rkt hacking guide][rkt-hacking]. + +## Get rkt repo and install dependencies + +In this example ~/Repos is a personal workspace where all repos are stored + +```sh +$ mkdir ~/Repos && cd ~/Repos +$ mkdir -p ~/.local/gopath/src/github.com/coreos +$ sudo apt-get install git +$ git -C ~/.local/gopath/src/github.com/coreos clone https://github.com/coreos/rkt.git +$ ln -s ~/.local/gopath/src/github.com/coreos/rkt rkt +``` + +On a fresh system installation, few additional software packages are needed to correctly build rkt: + +```sh +$ sudo ~/Repos/rkt/scripts/install-deps-debian-sid.sh +``` + +See also [the dependencies page][rkt-dependencies]. + +## Installing Go Programming Language for a single-user + +``` +$ cd ~/Downloads +$ wget https://storage.googleapis.com/golang/go1.6.1.linux-amd64.tar.gz +$ tar -xvf go1.6.1.linux-amd64.tar.gz +$ mv go ~/.local +``` + +Add GO variables to .bashrc file: + +```sh +export PATH=~/.local/bin:~/.local/go/bin:$PATH +export GOPATH=~/.local/gopath +export GOROOT=~/.local/go +``` + +## Install ccache (optional step) + +Ccache can save a lot of time. If you build a kernel once, most of the compiled code can just be taken from the cache. +Ccache can be configured in a few easy steps: + +```sh +$ sudo apt-get install ccache +$ ccache --max-size=10G +$ sudo ln -s /usr/bin/ccache /usr/local/bin/gcc +``` + +The maximum cache size is 10GB now (the default value is too small to cache kernel compilation). + +## Building rkt + +Run the autogen and configure commands with the relevant arguments, for example (kvm as flavor): + +```sh +$ cd ~/Repos/rkt +$ ./autogen.sh && ./configure --enable-functional-tests --with-stage1-flavors=kvm +``` + +Now build rkt with: + +```sh +$ make V=2 -j +``` + +REMEMBER: If you want to test somebody else's changes: + +```sh +$ git checkout +$ make clean +$ ./autogen.sh && ./configure +``` + +## A few useful commands + +### Just build and run tests: + +```sh +$ ./tests/build-and-run-tests.sh -f kvm +``` + +### Run only functional tests after build: + +```sh +$ make functional-check +``` + +### Check only one test: + +```sh +$ make functional-check GO_TEST_FUNC_ARGS='-run TEST_NAME_HERE' +``` + +See more in [the tests readme][rkt-tests-readme] page. + +### Simple usage of rkt container (run, exit, remove): + +```sh +$ sudo ./build-rkt-*/bin/rkt run --insecure-options=image --interactive docker://busybox +$ exit +$ sudo ./build-rkt-*/bin/rkt gc --grace-period=0 +``` + +### Remove all network interfaces created by rkt: + +```sh +for link in $(ip link | grep rkt | cut -d':' -f2 | cut -d'@' -f1); + sudo ip link del "${link}" +done +``` + +### Simplify changes in go files, before commit: + +```sh +gofmt -s -w file.go +``` + +[rkt-hacking]: ../hacking.md +[rkt-dependencies]: ../dependencies.md +[rkt-tests-readme]: ../../tests/README.md From 9c4f29fc21c9b59112b02677f33f0425698788d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Thu, 9 Jun 2016 15:50:16 +0200 Subject: [PATCH 0384/1304] store: update goroutine leak check The code this check was based on changed lately and we've been getting some occurrences of a goroutine leak when running unit tests. Update the code to match golang upstream [1][1], which waits a bit for goroutines to finish, in the hope of getting rid of those issues. [1]: https://github.com/golang/go/blob/release-branch.go1.6/src/net/http/main_test.go#L21 --- store/main_test.go | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/store/main_test.go b/store/main_test.go index b12ced44cb..abb54300ba 100644 --- a/store/main_test.go +++ b/store/main_test.go @@ -12,6 +12,7 @@ import ( "sort" "strings" "testing" + "time" ) func interestingGoroutines() (gs []string) { @@ -52,17 +53,21 @@ func goroutineLeaked() bool { // not counting goroutines for leakage in -short mode return false } - gs := interestingGoroutines() - n := 0 - stackCount := make(map[string]int) - for _, g := range gs { - stackCount[g]++ - n++ - } - - if n == 0 { - return false + var stackCount map[string]int + for i := 0; i < 5; i++ { + n := 0 + stackCount = make(map[string]int) + gs := interestingGoroutines() + for _, g := range gs { + stackCount[g]++ + n++ + } + if n == 0 { + return false + } + // Wait for goroutines to schedule and die off: + time.Sleep(100 * time.Millisecond) } fmt.Fprintf(os.Stderr, "Too many goroutines running after integration test(s).\n") for stack, count := range stackCount { From dae07cfe9e33c47329d12c1ea5e13da28ea3bb9c Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Wed, 8 Jun 2016 15:37:56 +0200 Subject: [PATCH 0385/1304] stage1/prepare-app: always adjust /etc/hostname This commit lets prepare-app bind mount /proc/sys/kernel/hostname over /etc/hostname, so that applications have a consistent hostname view. --- stage1/prepare-app/prepare-app.c | 1 + tests/rkt_etc_hosts_test.go | 43 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/stage1/prepare-app/prepare-app.c b/stage1/prepare-app/prepare-app.c index db42773a4b..a5a89bd60a 100644 --- a/stage1/prepare-app/prepare-app.c +++ b/stage1/prepare-app/prepare-app.c @@ -230,6 +230,7 @@ int main(int argc, char *argv[]) }; static const mount_point files_mount_table[] = { { "/etc/rkt-resolv.conf", "/etc/resolv.conf", "bind", NULL, MS_BIND }, + { "/proc/sys/kernel/hostname", "/etc/hostname", "bind", NULL, MS_BIND }, }; const char *root; int rootfd; diff --git a/tests/rkt_etc_hosts_test.go b/tests/rkt_etc_hosts_test.go index 24196cfeee..f19e91e65b 100644 --- a/tests/rkt_etc_hosts_test.go +++ b/tests/rkt_etc_hosts_test.go @@ -17,6 +17,7 @@ package main import ( + "fmt" "io/ioutil" "os" "path/filepath" @@ -87,3 +88,45 @@ func TestPrepareAppEnsureEtcHosts(t *testing.T) { } } } + +// stage1/prepare-app will bind mount /proc/sys/kernel/hostname on /etc/hostname, +// see https://github.com/coreos/rkt/issues/2657 +var etcHostnameTests = []struct { + aciBuildArgs []string + runArgs []string + expectedOutput string + expectErr bool +}{ + { + []string{"--exec=/inspect -file-name /etc/hostname -stat-file"}, + nil, + `/etc/hostname: mode: -rw-r--r--`, + false, + }, + { + []string{"--exec=/inspect -file-name /etc/hostname -read-file"}, + []string{"--hostname custom_hostname_setting"}, + `<< Date: Thu, 9 Jun 2016 17:37:37 +0200 Subject: [PATCH 0386/1304] docs: update release guide with signing details This commit updates the release guide with detailed steps for signing tags and release artifacts in a consistent way. Fixes #2734 --- Documentation/devel/release.md | 46 +++++++++++++++++----------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/Documentation/devel/release.md b/Documentation/devel/release.md index 4c2347a6ca..0d424082d3 100644 --- a/Documentation/devel/release.md +++ b/Documentation/devel/release.md @@ -55,10 +55,9 @@ After merging and going back to master branch, we check out the release version - `rkt --insecure-options=image fetch ./rkt-builder.aci` - `export BUILDDIR=$PWD/release-build && mkdir -p $BUILDDIR && sudo BUILDDIR=$BUILDDIR ./scripts/build-rir.sh` - Sanity check `release-build/bin/rkt version` - - Sanity check `ldd release-build/bin/rkt`: it can contain linux-vdso.so, libpthread.so, libc.so, ld-linux-x86-64.so but nothing else. - - Sanity check `ldd release-build/tools/init`: in addition to the previous list, it can contain libdl.so, but nothing else. -- Add a signed tag: `git tag -s v1.2.0`. - (We previously used tags for release notes, but now we store them in CHANGELOG.md, so a short tag with the release name is fine). + - Sanity check `ldd release-build/bin/rkt`: it can contain linux-vdso.so, libpthread.so, libc.so, libdl.so and ld-linux-x86-64.so but nothing else. + - Sanity check `ldd release-build/tools/init`: same as above. +- Grab the release key (see details below) and add a signed tag: `GIT_COMMITTER_NAME="CoreOS Application Signing Key" GIT_COMMITTER_EMAIL="security@coreos.com" git tag -u $RKTSUBKEYID'!' -s v1.2.0 -m "rkt v1.2.0"` - Push the tag to GitHub: `git push --tags` Now we switch to the GitHub web UI to conduct the release: @@ -71,36 +70,37 @@ Now we switch to the GitHub web UI to conduct the release: This is a simple tarball: ``` - export NAME="rkt-v1.2.0" - mkdir $NAME - cp release-build/bin/rkt release-build/bin/stage1-{coreos,kvm,fly}.aci $NAME/ - cp -r dist/* $NAME/ - sudo chown -R root:root $NAME/ - tar czvf $NAME.tar.gz --numeric-owner $NAME/ +export RKTVER="1.2.0" +export NAME="rkt-v$RKTVER" +mkdir $NAME +cp release-build/bin/rkt release-build/bin/stage1-{coreos,kvm,fly}.aci $NAME/ +cp -r dist/* $NAME/ +sudo chown -R root:root $NAME/ +tar czvf $NAME.tar.gz --numeric-owner $NAME/ ``` -- Attach the release signature; your personal GPG is okay for now: +- Attach each stage1 file individually so they can be fetched by the ACI discovery mechanism. The files must be named as follows: ``` - gpg --detach-sign $NAME.tar.gz +cp release-build/bin/stage1-coreos.aci stage1-coreos-$RKTVER-linux-amd64.aci +cp release-build/bin/stage1-kvm.aci stage1-kvm-$RKTVER-linux-amd64.aci +cp release-build/bin/stage1-fly.aci stage1-fly-$RKTVER-linux-amd64.aci ``` -- Attach each stage1 file individually so they can be fetched by the ACI discovery mechanism. The files must be named as follows: +- Sign all release artifacts. -``` - cp release-build/bin/stage1-coreos.aci stage1-coreos-1.2.0-linux-amd64.aci - cp release-build/bin/stage1-kvm.aci stage1-kvm-1.2.0-linux-amd64.aci - cp release-build/bin/stage1-fly.aci stage1-fly-1.2.0-linux-amd64.aci -``` +rkt project key must be used to sign the generated binaries and images.`$RKTSUBKEYID` is the key ID of rkt project Yubikey. Connect the key and run `gpg2 --card-status` to get the ID. +The public key for GPG signing can be found at [CoreOS Application Signing Key](https://coreos.com/security/app-signing-key) and is assumed as trusted. -- Attach the signature of each stage1 file: +The following commands are used for public release signing: ``` - gpg --armor --detach-sign stage1-coreos-1.2.0-linux-amd64.aci - gpg --armor --detach-sign stage1-kvm-1.2.0-linux-amd64.aci - gpg --armor --detach-sign stage1-fly-1.2.0-linux-amd64.aci +for i in $NAME.tar.gz stage1-*.aci; do gpg2 -u $RKTSUBKEYID'!' --armor --output ${i}.asc --detach-sign ${i}; done +for i in $NAME.tar.gz stage1-*.aci; do gpg2 --verify ${i}.asc ${i}; done ``` +- Once signed and uploaded, double-check that all artifacts and signatures are on github. There should be 8 files in attachments (1x tar.gz, 3x ACI, 4x armored signatures). + - Publish the release! - Clean your git tree: `sudo git clean -ffdx`. @@ -111,5 +111,5 @@ Use your discretion and see [previous release emails](https://groups.google.com/ Make sure to include a list of authors that contributed since the previous release - something like the following might be handy: ``` - git log v1.1.0..v1.2.0 --pretty=format:"%an" | sort | uniq | tr '\n' ',' | sed -e 's#,#, #g' -e 's#, $#\n#' +git log v1.1.0..v1.2.0 --pretty=format:"%an" | sort | uniq | tr '\n' ',' | sed -e 's#,#, #g' -e 's#, $#\n#' ``` From 701c0f07b9e03cc7cced48364aa370ad3ba35bed Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Fri, 15 Apr 2016 17:12:08 +0200 Subject: [PATCH 0387/1304] stage1: always write /etc/machine-id Prepare rkt for systemd-v230 in stage1. rkt was previously only writing /etc/machine-id in the stage1 rootfs if systemd was running on the host. However, new versions of systemd always require /etc/machine-id, see: https://github.com/systemd/systemd/commit/e01ff70a77e781734e1e73a2238af2e9bf7967a8 This patch will be in systemd-v230. This is currently not a problem because stage1 does not use systemd-v230 (and systemd-v230 is not released yet), but we want rkt to be ready. Fixes https://github.com/coreos/rkt/issues/2416 --- stage1/init/init.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/stage1/init/init.go b/stage1/init/init.go index 52a1850843..7955e432da 100644 --- a/stage1/init/init.go +++ b/stage1/init/init.go @@ -383,17 +383,18 @@ func getArgsEnv(p *stage1commontypes.Pod, flavor string, debug bool, n *networki return nil, nil, fmt.Errorf("unrecognized stage1 flavor: %q", flavor) } - // link journal only if the host is running systemd - if util.IsRunningSystemd() { - // we write /etc/machine-id here because systemd-nspawn needs it to link - // the container's journal to the host - mPath := filepath.Join(common.Stage1RootfsPath(p.Root), "etc", "machine-id") - mID := strings.Replace(p.UUID.String(), "-", "", -1) + // systemd-nspawn needs /etc/machine-id to link the container's journal + // to the host. Since systemd-v230, /etc/machine-id is mandatory, see + // https://github.com/systemd/systemd/commit/e01ff70a77e781734e1e73a2238af2e9bf7967a8 + mPath := filepath.Join(common.Stage1RootfsPath(p.Root), "etc", "machine-id") + mID := strings.Replace(p.UUID.String(), "-", "", -1) - if err := ioutil.WriteFile(mPath, []byte(mID), 0644); err != nil { - log.FatalE("error writing /etc/machine-id", err) - } + if err := ioutil.WriteFile(mPath, []byte(mID), 0644); err != nil { + log.FatalE("error writing /etc/machine-id", err) + } + // link journal only if the host is running systemd + if util.IsRunningSystemd() { args = append(args, "--link-journal=try-guest") keepUnit, err := util.RunningFromSystemService() @@ -408,6 +409,8 @@ func getArgsEnv(p *stage1commontypes.Pod, flavor string, debug bool, n *networki if keepUnit { args = append(args, "--keep-unit") } + } else { + args = append(args, "--link-journal=no") } if !debug { From 0bf7491d85be60f678a76a6b0d414d7830424ab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 8 Jun 2016 17:06:03 +0200 Subject: [PATCH 0388/1304] functional tests: increase timeout to 60min Some of our Jenkins machines reach the previous 45min limit, let's increase it a bit more. --- tests/functional.mk | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/functional.mk b/tests/functional.mk index e90d8d6c42..2e8d383d89 100644 --- a/tests/functional.mk +++ b/tests/functional.mk @@ -71,15 +71,17 @@ CLEAN_DIRS += \ CLEAN_SYMLINKS += \ $(FTST_IMAGE_ROOTFSDIR)/inspect-link \ $(FTST_IMAGE_ROOTFSDIR)/bin/inspect-link-bin +FTST_FUNCTIONAL_TESTS_TIMEOUT := 60m $(call forward-vars,$(FTST_FUNCTIONAL_TESTS_STAMP), \ FTST_RKT_PATH ACTOOL FTST_IMAGE FTST_EMPTY_IMAGE FTST_TEST_TMP ABS_GO \ FTST_INSPECT_BINARY GO_ENV GO_TEST_FUNC_ARGS REPO_PATH \ - FTST_ACE_MAIN_IMAGE FTST_ACE_SIDEKICK_IMAGE RKT_STAGE1_DEFAULT_FLAVOR FTST_SS1_IMAGE) + FTST_ACE_MAIN_IMAGE FTST_ACE_SIDEKICK_IMAGE RKT_STAGE1_DEFAULT_FLAVOR FTST_SS1_IMAGE \ + FTST_FUNCTIONAL_TESTS_TIMEOUT) $(FTST_FUNCTIONAL_TESTS_STAMP): $(FTST_IMAGE) $(FTST_EMPTY_IMAGE) $(ACTOOL_STAMP) $(RKT_STAMP) $(FTST_ACE_MAIN_IMAGE) $(FTST_ACE_SIDEKICK_IMAGE) $(FTST_SS1_STAMP) | $(FTST_TEST_TMP) $(FTST_RKT_PATH) $(FTST_STAGE1_ALL_FLAVOR_SYMLINKS) $(VQ) \ $(call vb,vt,GO TEST,$(REPO_PATH)/tests) \ - sudo RKT_STAGE1_DEFAULT_FLAVOR="$(RKT_STAGE1_DEFAULT_FLAVOR)" RKT="$(FTST_RKT_PATH)" ACTOOL="$(ACTOOL)" RKT_INSPECT_IMAGE="$(FTST_IMAGE)" RKT_EMPTY_IMAGE="$(FTST_EMPTY_IMAGE)" RKT_ACE_MAIN_IMAGE=$(FTST_ACE_MAIN_IMAGE) RKT_ACE_SIDEKICK_IMAGE=$(FTST_ACE_SIDEKICK_IMAGE) FUNCTIONAL_TMP="$(FTST_TEST_TMP)" INSPECT_BINARY="$(FTST_INSPECT_BINARY)" STUB_STAGE1="$(FTST_SS1_IMAGE)" $(GO_ENV) "$(ABS_GO)" test -tags $(RKT_STAGE1_DEFAULT_FLAVOR) -timeout 45m -v $(GO_TEST_FUNC_ARGS) $(REPO_PATH)/tests + sudo RKT_STAGE1_DEFAULT_FLAVOR="$(RKT_STAGE1_DEFAULT_FLAVOR)" RKT="$(FTST_RKT_PATH)" ACTOOL="$(ACTOOL)" RKT_INSPECT_IMAGE="$(FTST_IMAGE)" RKT_EMPTY_IMAGE="$(FTST_EMPTY_IMAGE)" RKT_ACE_MAIN_IMAGE=$(FTST_ACE_MAIN_IMAGE) RKT_ACE_SIDEKICK_IMAGE=$(FTST_ACE_SIDEKICK_IMAGE) FUNCTIONAL_TMP="$(FTST_TEST_TMP)" INSPECT_BINARY="$(FTST_INSPECT_BINARY)" STUB_STAGE1="$(FTST_SS1_IMAGE)" $(GO_ENV) "$(ABS_GO)" test -tags $(RKT_STAGE1_DEFAULT_FLAVOR) -timeout $(FTST_FUNCTIONAL_TESTS_TIMEOUT) -v $(GO_TEST_FUNC_ARGS) $(REPO_PATH)/tests $(call forward-vars,$(FTST_IMAGE), \ FTST_IMAGE_ROOTFSDIR ACTOOL FTST_IMAGE_DIR) From 264503d374ff699b5e5ffbebf307f21eab2234c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 8 Jun 2016 17:07:17 +0200 Subject: [PATCH 0389/1304] functional tests: increase API service test timeout Some of our Jenkins machine seem to take longer to start the pods, increase a bit the timeout. --- tests/rkt_api_service_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/rkt_api_service_test.go b/tests/rkt_api_service_test.go index 60182a5594..50de85f065 100644 --- a/tests/rkt_api_service_test.go +++ b/tests/rkt_api_service_test.go @@ -578,7 +578,7 @@ func NewAPIServiceCgroupTest() testutils.Test { } }() - testutils.WaitOrTimeout(t, time.Second*30, done) + testutils.WaitOrTimeout(t, time.Second*60, done) var cgroups []string var subcgroups []string From 451cc00d5eb038460a73a61fc4d0c21099bf05ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 8 Jun 2016 17:11:21 +0200 Subject: [PATCH 0390/1304] functional tests: don't error if a cgroup knob doesn't exist We've seen some errors in the functional tests where some knob didn't exist. We're not sure why but we're really only interested in not having any cgroups remaining after running GC so let's ignore that error. --- tests/rkt_gc_nspawn_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/rkt_gc_nspawn_test.go b/tests/rkt_gc_nspawn_test.go index 72e7ce4dad..3c1b67ef81 100644 --- a/tests/rkt_gc_nspawn_test.go +++ b/tests/rkt_gc_nspawn_test.go @@ -29,6 +29,11 @@ import ( func getPodCgroups(shortUUID string) ([]string, error) { var podCgroups []string walkCgroups := func(path string, info os.FileInfo, err error) error { + // Maybe the file doesn't exist anymore. We've seen this during tests, + // not sure about the reason though. + if os.IsNotExist(err) { + return nil + } if err != nil { return err } From eed65378a39a427552b2c638ec17d7c07e4b0e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 8 Jun 2016 17:16:13 +0200 Subject: [PATCH 0391/1304] functional tests: skip test if a remote fetching fails It was provoking so many false positives. This means we won't always be doing a full TestFetch but in some distributions the test will run until the end so we can verify we didn't break anything. Later we can consider retrying if a remote fetch fails. Or even better, always fetch from the local test ACI server and implement/run our own Docker server and fetch from that. Or wait for OCI support and implement a local OCI server :). --- tests/rkt_fetch_test.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/rkt_fetch_test.go b/tests/rkt_fetch_test.go index d0c1a453a9..945ef98754 100644 --- a/tests/rkt_fetch_test.go +++ b/tests/rkt_fetch_test.go @@ -161,7 +161,11 @@ func testFetchDefault(t *testing.T, arg string, image string, imageArgs string, if err := expectWithOutput(child, remoteFetchMsg); err != nil { t.Fatalf("%q should be found: %v", remoteFetchMsg, err) } - child.Wait() + err := child.Wait() + status := getExitStatus(err) + if status != 0 { + t.Skip("remote fetching failed, probably a network failure. Skipping...") + } // 2. Run cmd with the image available in the store, should get $storeMsg. runRktAndCheckRegexOutput(t, cmd, storeMsg) @@ -203,7 +207,11 @@ func testFetchNoStore(t *testing.T, args string, image string, imageArgs string, if err := expectWithOutput(child, remoteFetchMsg); err != nil { t.Fatalf("%q should be found: %v", remoteFetchMsg, err) } - child.Wait() + err := child.Wait() + status := getExitStatus(err) + if status != 0 { + t.Skip("remote fetching failed, probably a network failure. Skipping...") + } } type synchronizedBool struct { From fd4cc976a17b6098cffb0841f80b82e84e3e7d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Thu, 9 Jun 2016 11:35:32 +0200 Subject: [PATCH 0392/1304] functional tests: exec real binaries on TestFetch If we exec /dev/null, rkt's exit status will be 203 and it will be a failure. Instead, exec /etcdctl which will immediately exit with a success status. --- tests/rkt_fetch_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/rkt_fetch_test.go b/tests/rkt_fetch_test.go index 945ef98754..d7029633ff 100644 --- a/tests/rkt_fetch_test.go +++ b/tests/rkt_fetch_test.go @@ -101,8 +101,8 @@ func TestFetch(t *testing.T) { {"--insecure-options=image fetch", "https://github.com/coreos/etcd/releases/download/v2.1.2/etcd-v2.1.2-linux-amd64.aci", "", "https://github.com/coreos/etcd/releases/download/v2.1.2/etcd-v2.1.2-linux-amd64.aci"}, {"--insecure-options=image fetch", "docker://busybox", "", "docker://busybox"}, {"--insecure-options=image fetch", "docker://busybox:latest", "", "docker://busybox:latest"}, - {"--insecure-options=image run --mds-register=false", "coreos.com/etcd:v2.1.2", "--exec /dev/null", "https://github.com/coreos/etcd/releases/download/v2.1.2/etcd-v2.1.2-linux-amd64.aci"}, - {"--insecure-options=image run --mds-register=false", "https://github.com/coreos/etcd/releases/download/v2.1.2/etcd-v2.1.2-linux-amd64.aci", "--exec /dev/null", "https://github.com/coreos/etcd/releases/download/v2.1.2/etcd-v2.1.2-linux-amd64.aci"}, + {"--insecure-options=image run --mds-register=false", "coreos.com/etcd:v2.1.2", "--exec /etcdctl", "https://github.com/coreos/etcd/releases/download/v2.1.2/etcd-v2.1.2-linux-amd64.aci"}, + {"--insecure-options=image run --mds-register=false", "https://github.com/coreos/etcd/releases/download/v2.1.2/etcd-v2.1.2-linux-amd64.aci", "--exec /etcdctl", "https://github.com/coreos/etcd/releases/download/v2.1.2/etcd-v2.1.2-linux-amd64.aci"}, {"--insecure-options=image run --mds-register=false", "docker://busybox", "", "docker://busybox"}, {"--insecure-options=image run --mds-register=false", "docker://busybox:latest", "", "docker://busybox:latest"}, {"--insecure-options=image prepare", "https://github.com/coreos/etcd/releases/download/v2.1.2/etcd-v2.1.2-linux-amd64.aci", "", "https://github.com/coreos/etcd/releases/download/v2.1.2/etcd-v2.1.2-linux-amd64.aci"}, From 98545e1c7b22480679aa7e75cb61d2a3f9188b48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Thu, 9 Jun 2016 11:36:57 +0200 Subject: [PATCH 0393/1304] functional tests: add more info if we skip TestFetch Namely, rkt's output. --- tests/rkt_fetch_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/rkt_fetch_test.go b/tests/rkt_fetch_test.go index d7029633ff..3c3d56ae27 100644 --- a/tests/rkt_fetch_test.go +++ b/tests/rkt_fetch_test.go @@ -164,6 +164,7 @@ func testFetchDefault(t *testing.T, arg string, image string, imageArgs string, err := child.Wait() status := getExitStatus(err) if status != 0 { + t.Errorf("rkt terminated with unexpected status %d, expected %d\nOutput:\n%s", status, 0, child.Collect()) t.Skip("remote fetching failed, probably a network failure. Skipping...") } @@ -210,6 +211,7 @@ func testFetchNoStore(t *testing.T, args string, image string, imageArgs string, err := child.Wait() status := getExitStatus(err) if status != 0 { + t.Errorf("rkt terminated with unexpected status %d, expected %d\nOutput:\n%s", status, 0, child.Collect()) t.Skip("remote fetching failed, probably a network failure. Skipping...") } } From dc7369e3bd5f76341dbfd0d7c2fb860085e16cb3 Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Fri, 10 Jun 2016 11:19:58 -0700 Subject: [PATCH 0394/1304] Godeps: Update sys/unix to get arm64 support Update to golang/sys@b44883b. Signed-off-by: Geoff Levand --- Godeps/Godeps.json | 2 +- .../src/golang.org/x/sys/unix/.gitignore | 1 + .../golang.org/x/sys/unix/asm_darwin_arm.s | 30 + .../golang.org/x/sys/unix/asm_darwin_arm64.s | 30 + .../golang.org/x/sys/unix/asm_linux_arm64.s | 24 + ...sm_dragonfly_386.s => asm_linux_mips64x.s} | 17 +- .../golang.org/x/sys/unix/asm_linux_ppc64x.s | 28 + .../golang.org/x/sys/unix/asm_linux_s390x.s | 28 + .../golang.org/x/sys/unix/asm_solaris_amd64.s | 17 +- .../golang.org/x/sys/unix/bluetooth_linux.go | 35 + .../src/golang.org/x/sys/unix/gccgo.go | 17 +- .../src/golang.org/x/sys/unix/gccgo_c.c | 4 +- .../src/golang.org/x/sys/unix/mkall.sh | 62 +- .../src/golang.org/x/sys/unix/mkerrors.sh | 48 +- .../src/golang.org/x/sys/unix/mkpost.go | 62 + .../src/golang.org/x/sys/unix/mksyscall.pl | 7 + .../x/sys/unix/mksyscall_solaris.pl | 46 +- .../golang.org/x/sys/unix/mksysctl_openbsd.pl | 7 + .../golang.org/x/sys/unix/mksysnum_darwin.pl | 7 + .../x/sys/unix/mksysnum_dragonfly.pl | 7 + .../golang.org/x/sys/unix/mksysnum_freebsd.pl | 7 + .../golang.org/x/sys/unix/mksysnum_linux.pl | 24 +- .../golang.org/x/sys/unix/mksysnum_netbsd.pl | 7 + .../golang.org/x/sys/unix/mksysnum_openbsd.pl | 7 + .../src/golang.org/x/sys/unix/so_solaris.go | 261 --- .../golang.org/x/sys/unix/sockcmsg_unix.go | 8 +- .../src/golang.org/x/sys/unix/str.go | 6 +- .../src/golang.org/x/sys/unix/syscall.go | 2 + .../src/golang.org/x/sys/unix/syscall_bsd.go | 92 +- .../x/sys/unix/syscall_darwin_386.go | 8 +- .../x/sys/unix/syscall_darwin_amd64.go | 10 +- ...dragonfly_386.go => syscall_darwin_arm.go} | 24 +- .../x/sys/unix/syscall_darwin_arm64.go | 77 + .../x/sys/unix/syscall_dragonfly_amd64.go | 4 +- .../x/sys/unix/syscall_freebsd_386.go | 4 +- .../x/sys/unix/syscall_freebsd_amd64.go | 4 +- .../x/sys/unix/syscall_freebsd_arm.go | 4 +- .../golang.org/x/sys/unix/syscall_linux.go | 152 +- .../x/sys/unix/syscall_linux_386.go | 37 +- .../x/sys/unix/syscall_linux_amd64.go | 41 +- .../x/sys/unix/syscall_linux_arm.go | 54 +- .../x/sys/unix/syscall_linux_arm64.go | 180 ++ .../x/sys/unix/syscall_linux_mips64x.go | 206 ++ .../x/sys/unix/syscall_linux_ppc64x.go | 126 + .../x/sys/unix/syscall_linux_s390x.go | 320 +++ .../x/sys/unix/syscall_netbsd_386.go | 4 +- .../x/sys/unix/syscall_netbsd_amd64.go | 4 +- .../x/sys/unix/syscall_netbsd_arm.go | 4 +- .../x/sys/unix/syscall_openbsd_386.go | 4 +- .../x/sys/unix/syscall_openbsd_amd64.go | 4 +- .../golang.org/x/sys/unix/syscall_solaris.go | 247 +- .../x/sys/unix/syscall_solaris_amd64.go | 6 +- .../src/golang.org/x/sys/unix/types_darwin.go | 7 + .../src/golang.org/x/sys/unix/types_linux.go | 48 +- .../golang.org/x/sys/unix/types_solaris.go | 38 + .../x/sys/unix/zerrors_darwin_386.go | 197 +- .../x/sys/unix/zerrors_darwin_amd64.go | 15 +- .../x/sys/unix/zerrors_darwin_arm.go | 1293 +++++++++++ ...agonfly_386.go => zerrors_darwin_arm64.go} | 1040 +++++---- .../x/sys/unix/zerrors_dragonfly_amd64.go | 2 + .../x/sys/unix/zerrors_freebsd_386.go | 16 + .../x/sys/unix/zerrors_freebsd_amd64.go | 16 + .../x/sys/unix/zerrors_freebsd_arm.go | 2 + .../x/sys/unix/zerrors_linux_386.go | 60 + .../x/sys/unix/zerrors_linux_amd64.go | 60 + .../x/sys/unix/zerrors_linux_arm.go | 168 ++ .../x/sys/unix/zerrors_linux_arm64.go | 1897 +++++++++++++++ .../x/sys/unix/zerrors_linux_mips64.go | 1917 ++++++++++++++++ .../x/sys/unix/zerrors_linux_mips64le.go | 1917 ++++++++++++++++ .../x/sys/unix/zerrors_linux_ppc64.go | 1970 ++++++++++++++++ .../x/sys/unix/zerrors_linux_ppc64le.go | 1969 ++++++++++++++++ .../x/sys/unix/zerrors_linux_s390x.go | 2027 +++++++++++++++++ .../x/sys/unix/zerrors_netbsd_386.go | 2 + .../x/sys/unix/zerrors_netbsd_amd64.go | 2 + .../x/sys/unix/zerrors_netbsd_arm.go | 2 + .../x/sys/unix/zerrors_openbsd_386.go | 2 + .../x/sys/unix/zerrors_openbsd_amd64.go | 2 + .../x/sys/unix/zerrors_solaris_amd64.go | 28 +- .../x/sys/unix/zsyscall_darwin_386.go | 3 + .../x/sys/unix/zsyscall_darwin_amd64.go | 19 + ...ragonfly_386.go => zsyscall_darwin_arm.go} | 181 +- .../x/sys/unix/zsyscall_darwin_arm64.go | 1427 ++++++++++++ .../x/sys/unix/zsyscall_dragonfly_amd64.go | 3 + .../x/sys/unix/zsyscall_freebsd_386.go | 3 + .../x/sys/unix/zsyscall_freebsd_amd64.go | 3 + .../x/sys/unix/zsyscall_freebsd_arm.go | 3 + .../x/sys/unix/zsyscall_linux_386.go | 444 ++-- .../x/sys/unix/zsyscall_linux_amd64.go | 444 ++-- .../x/sys/unix/zsyscall_linux_arm.go | 417 +--- .../x/sys/unix/zsyscall_linux_arm64.go | 1723 ++++++++++++++ .../x/sys/unix/zsyscall_linux_mips64.go | 1781 +++++++++++++++ .../x/sys/unix/zsyscall_linux_mips64le.go | 1781 +++++++++++++++ .../x/sys/unix/zsyscall_linux_ppc64.go | 1843 +++++++++++++++ .../x/sys/unix/zsyscall_linux_ppc64le.go | 1843 +++++++++++++++ .../x/sys/unix/zsyscall_linux_s390x.go | 1623 +++++++++++++ .../x/sys/unix/zsyscall_netbsd_386.go | 3 + .../x/sys/unix/zsyscall_netbsd_amd64.go | 3 + .../x/sys/unix/zsyscall_netbsd_arm.go | 3 + .../x/sys/unix/zsyscall_openbsd_386.go | 3 + .../x/sys/unix/zsyscall_openbsd_amd64.go | 3 + .../x/sys/unix/zsyscall_solaris_amd64.go | 1003 ++++++-- .../x/sys/unix/zsysnum_darwin_386.go | 80 +- .../x/sys/unix/zsysnum_darwin_amd64.go | 80 +- .../x/sys/unix/zsysnum_darwin_arm.go | 358 +++ .../x/sys/unix/zsysnum_darwin_arm64.go | 398 ++++ .../x/sys/unix/zsysnum_dragonfly_386.go | 302 --- .../x/sys/unix/zsysnum_dragonfly_amd64.go | 2 + .../x/sys/unix/zsysnum_freebsd_386.go | 2 + .../x/sys/unix/zsysnum_freebsd_amd64.go | 2 + .../x/sys/unix/zsysnum_freebsd_arm.go | 2 + .../x/sys/unix/zsysnum_linux_386.go | 2 + .../x/sys/unix/zsysnum_linux_amd64.go | 2 + .../x/sys/unix/zsysnum_linux_arm.go | 2 + .../x/sys/unix/zsysnum_linux_arm64.go | 272 +++ .../x/sys/unix/zsysnum_linux_mips64.go | 327 +++ .../x/sys/unix/zsysnum_linux_mips64le.go | 327 +++ .../x/sys/unix/zsysnum_linux_ppc64.go | 360 +++ .../x/sys/unix/zsysnum_linux_ppc64le.go | 353 +++ .../x/sys/unix/zsysnum_linux_s390x.go | 328 +++ .../x/sys/unix/zsysnum_netbsd_386.go | 2 + .../x/sys/unix/zsysnum_netbsd_amd64.go | 2 + .../x/sys/unix/zsysnum_netbsd_arm.go | 2 + .../x/sys/unix/zsysnum_openbsd_386.go | 2 + .../x/sys/unix/zsysnum_openbsd_amd64.go | 2 + .../x/sys/unix/zsysnum_solaris_amd64.go | 2 + .../x/sys/unix/ztypes_darwin_386.go | 3 +- .../x/sys/unix/ztypes_darwin_amd64.go | 12 +- ..._dragonfly_386.go => ztypes_darwin_arm.go} | 218 +- .../x/sys/unix/ztypes_darwin_arm64.go | 457 ++++ .../x/sys/unix/ztypes_dragonfly_amd64.go | 2 + .../x/sys/unix/ztypes_freebsd_386.go | 10 + .../x/sys/unix/ztypes_freebsd_amd64.go | 10 + .../x/sys/unix/ztypes_freebsd_arm.go | 2 + .../golang.org/x/sys/unix/ztypes_linux_386.go | 37 +- .../x/sys/unix/ztypes_linux_amd64.go | 37 +- .../golang.org/x/sys/unix/ztypes_linux_arm.go | 130 +- .../x/sys/unix/ztypes_linux_arm64.go | 604 +++++ .../x/sys/unix/ztypes_linux_mips64.go | 607 +++++ .../x/sys/unix/ztypes_linux_mips64le.go | 607 +++++ .../x/sys/unix/ztypes_linux_ppc64.go | 614 +++++ .../x/sys/unix/ztypes_linux_ppc64le.go | 614 +++++ .../x/sys/unix/ztypes_linux_s390x.go | 629 +++++ .../x/sys/unix/ztypes_netbsd_386.go | 2 + .../x/sys/unix/ztypes_netbsd_amd64.go | 2 + .../x/sys/unix/ztypes_netbsd_arm.go | 2 + .../x/sys/unix/ztypes_openbsd_386.go | 2 + .../x/sys/unix/ztypes_openbsd_amd64.go | 2 + .../x/sys/unix/ztypes_solaris_amd64.go | 57 + 148 files changed, 36824 insertions(+), 2720 deletions(-) create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/.gitignore create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_arm.s create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_arm64.s create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_arm64.s rename Godeps/_workspace/src/golang.org/x/sys/unix/{asm_dragonfly_386.s => asm_linux_mips64x.s} (56%) create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_ppc64x.s create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_s390x.s create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/bluetooth_linux.go mode change 100644 => 100755 Godeps/_workspace/src/golang.org/x/sys/unix/mkall.sh mode change 100644 => 100755 Godeps/_workspace/src/golang.org/x/sys/unix/mkerrors.sh create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/mkpost.go mode change 100644 => 100755 Godeps/_workspace/src/golang.org/x/sys/unix/mksyscall.pl mode change 100644 => 100755 Godeps/_workspace/src/golang.org/x/sys/unix/mksyscall_solaris.pl mode change 100644 => 100755 Godeps/_workspace/src/golang.org/x/sys/unix/mksysctl_openbsd.pl mode change 100644 => 100755 Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_darwin.pl mode change 100644 => 100755 Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_dragonfly.pl mode change 100644 => 100755 Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_freebsd.pl mode change 100644 => 100755 Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_linux.pl mode change 100644 => 100755 Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_netbsd.pl mode change 100644 => 100755 Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_openbsd.pl delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/so_solaris.go rename Godeps/_workspace/src/golang.org/x/sys/unix/{syscall_dragonfly_386.go => syscall_darwin_arm.go} (67%) create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_arm64.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_arm64.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_mips64x.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_ppc64x.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_s390x.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_darwin_arm.go rename Godeps/_workspace/src/golang.org/x/sys/unix/{zerrors_dragonfly_386.go => zerrors_darwin_arm64.go} (66%) create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_arm64.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_mips64.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_mips64le.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_ppc64.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_ppc64le.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_s390x.go rename Godeps/_workspace/src/golang.org/x/sys/unix/{zsyscall_dragonfly_386.go => zsyscall_darwin_arm.go} (92%) create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_darwin_arm64.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_arm64.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_mips64.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_mips64le.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_ppc64.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_s390x.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_darwin_arm.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_darwin_arm64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_dragonfly_386.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_arm64.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_mips64.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_mips64le.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_ppc64.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_s390x.go rename Godeps/_workspace/src/golang.org/x/sys/unix/{ztypes_dragonfly_386.go => ztypes_darwin_arm.go} (68%) create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_darwin_arm64.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_arm64.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_mips64.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_mips64le.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_ppc64.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_ppc64le.go create mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_s390x.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index e7b5125206..141351f8d0 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -709,7 +709,7 @@ }, { "ImportPath": "golang.org/x/sys/unix", - "Rev": "e11762ca30adc5b39fdbfd8c4250dabeb8e456d3" + "Rev": "b44883b474ffefa37335017174e397412b633a4f" }, { "ImportPath": "golang.org/x/tools/go/vcs", diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/.gitignore b/Godeps/_workspace/src/golang.org/x/sys/unix/.gitignore new file mode 100644 index 0000000000..e482715909 --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/.gitignore @@ -0,0 +1 @@ +_obj/ diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_arm.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_arm.s new file mode 100644 index 0000000000..333242d506 --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_arm.s @@ -0,0 +1,30 @@ +// 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) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_arm64.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_arm64.s new file mode 100644 index 0000000000..97e0174371 --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_arm64.s @@ -0,0 +1,30 @@ +// 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) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_arm64.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_arm64.s new file mode 100644 index 0000000000..4be9bfedea --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_arm64.s @@ -0,0 +1,24 @@ +// 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) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_dragonfly_386.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_mips64x.s similarity index 56% rename from Godeps/_workspace/src/golang.org/x/sys/unix/asm_dragonfly_386.s rename to Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_mips64x.s index 7e55e0d317..724e580c4e 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_dragonfly_386.s +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_mips64x.s @@ -1,29 +1,28 @@ -// Copyright 2009 The Go Authors. All rights reserved. +// 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 call support for 386, FreeBSD +// 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-32 +TEXT ·Syscall(SB),NOSPLIT,$0-56 JMP syscall·Syscall(SB) -TEXT ·Syscall6(SB),NOSPLIT,$0-44 +TEXT ·Syscall6(SB),NOSPLIT,$0-80 JMP syscall·Syscall6(SB) -TEXT ·Syscall9(SB),NOSPLIT,$0-56 - JMP syscall·Syscall9(SB) - -TEXT ·RawSyscall(SB),NOSPLIT,$0-32 +TEXT ·RawSyscall(SB),NOSPLIT,$0-56 JMP syscall·RawSyscall(SB) -TEXT ·RawSyscall6(SB),NOSPLIT,$0-44 +TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 JMP syscall·RawSyscall6(SB) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_ppc64x.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_ppc64x.s new file mode 100644 index 0000000000..8d231feb4b --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_ppc64x.s @@ -0,0 +1,28 @@ +// 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) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_s390x.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_s390x.s new file mode 100644 index 0000000000..11889859fb --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_s390x.s @@ -0,0 +1,28 @@ +// 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) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_solaris_amd64.s b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_solaris_amd64.s index a33708f0c0..43ed17a05f 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/asm_solaris_amd64.s +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/asm_solaris_amd64.s @@ -4,21 +4,14 @@ // +build !gccgo +#include "textflag.h" + // -// System calls for amd64, Solaris are implemented in runtime/syscall_solaris.goc +// System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go // -TEXT ·sysvicall6(SB), 7, $0-64 +TEXT ·sysvicall6(SB),NOSPLIT,$0-64 JMP syscall·sysvicall6(SB) -TEXT ·rawSysvicall6(SB), 7, $0-64 +TEXT ·rawSysvicall6(SB),NOSPLIT,$0-64 JMP syscall·rawSysvicall6(SB) - -TEXT ·dlopen(SB), 7, $0-16 - JMP syscall·dlopen(SB) - -TEXT ·dlclose(SB), 7, $0-8 - JMP syscall·dlclose(SB) - -TEXT ·dlsym(SB), 7, $0-16 - JMP syscall·dlsym(SB) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/bluetooth_linux.go b/Godeps/_workspace/src/golang.org/x/sys/unix/bluetooth_linux.go new file mode 100644 index 0000000000..6e32296970 --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/bluetooth_linux.go @@ -0,0 +1,35 @@ +// 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 +) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/gccgo.go b/Godeps/_workspace/src/golang.org/x/sys/unix/gccgo.go index 5fc9bc9045..94c8232124 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/gccgo.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/gccgo.go @@ -12,28 +12,35 @@ import "syscall" // much of the functionality can be written directly in Go. //extern gccgoRealSyscall -func realSyscall(trap, a1, a2, a3, a4, a5, a6 uintptr) (r, errno uintptr) +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) + 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) + 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) + 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) + r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) return r, 0, syscall.Errno(errno) } diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/gccgo_c.c b/Godeps/_workspace/src/golang.org/x/sys/unix/gccgo_c.c index 991980eaf7..07f6be0392 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/gccgo_c.c +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/gccgo_c.c @@ -21,12 +21,12 @@ struct ret { }; struct ret -gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6) +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); + r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); r.err = errno; return r; } diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/mkall.sh b/Godeps/_workspace/src/golang.org/x/sys/unix/mkall.sh old mode 100644 new mode 100755 index 4632f89499..3e224c57e2 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/mkall.sh +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/mkall.sh @@ -107,6 +107,7 @@ case "$#" in exit 2 esac +GOOSARCH_in=syscall_$GOOSARCH.go case "$GOOSARCH" in _* | *_ | _) echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2 @@ -115,12 +116,22 @@ _* | *_ | _) darwin_386) mkerrors="$mkerrors -m32" mksyscall="./mksyscall.pl -l32" - mksysnum="./mksysnum_darwin.pl /usr/include/sys/syscall.h" + 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 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/sys/syscall.h" + 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) @@ -150,7 +161,7 @@ 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 singed for making the bare syscall + # 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" ;; @@ -173,9 +184,45 @@ linux_amd64) linux_arm) mkerrors="$mkerrors" mksyscall="./mksyscall.pl -l32 -arm" - mksysnum="curl -s 'http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/arch/arm/include/uapi/asm/unistd.h' | ./mksysnum_linux.pl" + mksysnum="curl -s 'http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/arch/arm/include/uapi/asm/unistd.h' | ./mksysnum_linux.pl -" mktypes="GOARCH=$GOARCH go tool cgo -godefs" ;; +linux_arm64) + unistd_h=$(ls -1 /usr/include/asm/unistd.h /usr/include/asm-generic/unistd.h 2>/dev/null | head -1) + if [ "$unistd_h" = "" ]; then + echo >&2 cannot find unistd_64.h + exit 1 + fi + mksysnum="./mksysnum_linux.pl $unistd_h" + # 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_ppc64) + GOOSARCH_in=syscall_linux_ppc64x.go + unistd_h=/usr/include/asm/unistd.h + mkerrors="$mkerrors -m64" + mksysnum="./mksysnum_linux.pl $unistd_h" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +linux_ppc64le) + GOOSARCH_in=syscall_linux_ppc64x.go + unistd_h=/usr/include/powerpc64le-linux-gnu/asm/unistd.h + mkerrors="$mkerrors -m64" + mksysnum="./mksysnum_linux.pl $unistd_h" + mktypes="GOARCH=$GOARCH go tool cgo -godefs" + ;; +linux_s390x) + GOOSARCH_in=syscall_linux_s390x.go + unistd_h=/usr/include/asm/unistd.h + mkerrors="$mkerrors -m64" + mksysnum="./mksysnum_linux.pl $unistd_h" + # Let the type of C char be signed to make the bare sys + # API more consistent between platforms. + # This is a deliberate departure from the way the syscall + # package generates its version of the types file. + mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char" + ;; netbsd_386) mkerrors="$mkerrors -m32" mksyscall="./mksyscall.pl -l32 -netbsd" @@ -226,10 +273,13 @@ esac syscall_goos="syscall_bsd.go $syscall_goos" ;; esac - if [ -n "$mksyscall" ]; then echo "$mksyscall $syscall_goos syscall_$GOOSARCH.go |gofmt >zsyscall_$GOOSARCH.go"; fi + if [ -n "$mksyscall" ]; then echo "$mksyscall $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 |gofmt >ztypes_$GOOSARCH.go"; fi + if [ -n "$mktypes" ]; then + echo "echo // +build $GOARCH,$GOOS > ztypes_$GOOSARCH.go"; + echo "$mktypes types_$GOOS.go | go run mkpost.go >>ztypes_$GOOSARCH.go"; + fi ) | $run diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/mkerrors.sh b/Godeps/_workspace/src/golang.org/x/sys/unix/mkerrors.sh old mode 100644 new mode 100755 index 29813778c0..c40d788c4a --- a/Godeps/_workspace/src/golang.org/x/sys/unix/mkerrors.sh +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/mkerrors.sh @@ -11,7 +11,17 @@ unset LANG export LC_ALL=C export LC_CTYPE=C -CC=${CC:-gcc} +if test -z "$GOARCH" -o -z "$GOOS"; then + echo 1>&2 "GOARCH or GOOS not defined in environment" + exit 1 +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) @@ -33,7 +43,6 @@ includes_Darwin=' #include #include #include -#include #include ' @@ -88,7 +97,9 @@ includes_FreeBSD=' includes_Linux=' #define _LARGEFILE_SOURCE #define _LARGEFILE64_SOURCE +#ifndef __LP64__ #define _FILE_OFFSET_BITS 64 +#endif #define _GNU_SOURCE #include @@ -117,11 +128,19 @@ includes_Linux=' #include #include #include -#include +#include #ifndef MSG_FASTOPEN #define MSG_FASTOPEN 0x20000000 #endif + +#ifndef PTRACE_GETREGS +#define PTRACE_GETREGS 0xc +#endif + +#ifndef PTRACE_SETREGS +#define PTRACE_SETREGS 0xd +#endif ' includes_NetBSD=' @@ -186,6 +205,7 @@ includes_OpenBSD=' ' includes_SunOS=' +#include #include #include #include @@ -245,6 +265,7 @@ ccflags="$@" $2 ~ /^(SIGEV_|SIGSTKSZ|SIGRT(MIN|MAX))/ {next} $2 ~ /^(SCM_SRCRT)$/ {next} $2 ~ /^(MAP_FAILED)$/ {next} + $2 ~ /^ELF_.*$/ {next}# contains ELF_ARCH, etc. $2 ~ /^EXTATTR_NAMESPACE_NAMES/ || $2 ~ /^EXTATTR_NAMESPACE_[A-Z]+_STRING/ {next} @@ -255,21 +276,31 @@ ccflags="$@" $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|EXTEN|MAXBEL|STRIP|UTF8)$/ || + $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)$/ || + $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[CNPFP][A-Z]+[^_][A-Z]+$/ || + $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)_/ || @@ -288,6 +319,9 @@ ccflags="$@" $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/ || @@ -336,6 +370,8 @@ echo '#include ' | $CC -x c - -E -dM $ccflags | echo '// mkerrors.sh' "$@" echo '// MACHINE GENERATED BY THE COMMAND ABOVE; 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 diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/mkpost.go b/Godeps/_workspace/src/golang.org/x/sys/unix/mkpost.go new file mode 100644 index 0000000000..ed50d902af --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/mkpost.go @@ -0,0 +1,62 @@ +// 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 by mkall.sh. +package main + +import ( + "fmt" + "go/format" + "io/ioutil" + "log" + "os" + "regexp" +) + +func main() { + b, err := ioutil.ReadAll(os.Stdin) + if err != nil { + log.Fatal(err) + } + s := string(b) + + goarch := os.Getenv("GOARCH") + goos := os.Getenv("GOOS") + if goarch == "s390x" && goos == "linux" { + // Export the types of PtraceRegs fields. + re := regexp.MustCompile("ptrace(Psw|Fpregs|Per)") + s = re.ReplaceAllString(s, "Ptrace$1") + + // Replace padding fields inserted by cgo with blank identifiers. + re = regexp.MustCompile("Pad_cgo[A-Za-z0-9_]*") + s = re.ReplaceAllString(s, "_") + + // Replace other unwanted fields with blank identifiers. + re = regexp.MustCompile("X_[A-Za-z0-9_]*") + s = re.ReplaceAllString(s, "_") + + // Replace the control_regs union with a blank identifier for now. + re = regexp.MustCompile("(Control_regs)\\s+\\[0\\]uint64") + s = re.ReplaceAllString(s, "_ [0]uint64") + } + + // gofmt + b, err = format.Source([]byte(s)) + if err != nil { + log.Fatal(err) + } + + // Append this command to the header to show where the new file + // came from. + re := regexp.MustCompile("(cgo -godefs [a-zA-Z0-9_]+\\.go.*)") + b = re.ReplaceAll(b, []byte("$1 | go run mkpost.go")) + + fmt.Printf("%s", b) +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/mksyscall.pl b/Godeps/_workspace/src/golang.org/x/sys/unix/mksyscall.pl old mode 100644 new mode 100755 index ec0103ca30..b1e7766dae --- a/Godeps/_workspace/src/golang.org/x/sys/unix/mksyscall.pl +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/mksyscall.pl @@ -63,6 +63,11 @@ exit 1; } +if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { + print STDERR "GOARCH or GOOS not defined in environment\n"; + exit 1; +} + sub parseparamlist($) { my ($list) = @_; $list =~ s/^\s*//; @@ -302,6 +307,8 @@ ($) // $cmdline // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build $ENV{'GOARCH'},$ENV{'GOOS'} + package unix import ( diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/mksyscall_solaris.pl b/Godeps/_workspace/src/golang.org/x/sys/unix/mksyscall_solaris.pl old mode 100644 new mode 100755 index e8ec976fea..06bade7687 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/mksyscall_solaris.pl +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/mksyscall_solaris.pl @@ -38,6 +38,11 @@ exit 1; } +if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { + print STDERR "GOARCH or GOOS not defined in environment\n"; + exit 1; +} + sub parseparamlist($) { my ($list) = @_; $list =~ s/^\s*//; @@ -60,9 +65,9 @@ ($) my $package = ""; my $text = ""; -my $vars = ""; -my $mods = ""; -my $modnames = ""; +my $dynimports = ""; +my $linknames = ""; +my @vars = (); while(<>) { chomp; s/\s+/ /g; @@ -90,11 +95,6 @@ ($) if($modname eq "") { $modname = "libc"; } - my $modvname = "mod$modname"; - if($modnames !~ /$modname/) { - $modnames .= ".$modname"; - $mods .= "\t$modvname = newLazySO(\"$modname.so\")\n"; - } # System call name. if($sysname eq "") { @@ -107,9 +107,14 @@ ($) my $strconvfunc = "BytePtrFromString"; my $strconvtype = "*byte"; - # Library proc address variable. $sysname =~ y/A-Z/a-z/; # All libc functions are lowercase. - $vars .= "\t$sysvarname = $modvname.NewProc(\"$sysname\")\n"; + + # 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); @@ -193,7 +198,7 @@ ($) # Actual call. my $args = join(', ', @args); - my $call = "$asm($sysvarname.Addr(), $nargs, $args)"; + my $call = "$asm(uintptr(unsafe.Pointer(&$sysvarname)), $nargs, $args)"; # Assign return values. my $body = ""; @@ -260,21 +265,30 @@ ($) // $cmdline // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build $ENV{'GOARCH'},$ENV{'GOOS'} + package $package -import "unsafe" +import ( + "syscall" + "unsafe" +) EOF print "import \"golang.org/x/sys/unix\"\n" if $package ne "unix"; -print < 999){ + # ignore deprecated syscalls that are no longer implemented + # https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h?id=refs/heads/master#n716 + return; + } $name =~ y/a-z/A-Z/; print " SYS_$name = $num;\n"; } my $prev; -while(<>){ - if(/^#define __NR_(\w+)\s+([0-9]+)/){ +open(GCC, "gcc -E -dD $ARGV[0] |") || die "can't run gcc"; +while(){ + if(/^#define __NR_syscalls\s+/) { + # ignore redefinitions of __NR_syscalls + } + elsif(/^#define __NR_(\w+)\s+([0-9]+)/){ + $prev = $2; + fmt($1, $2); + } + elsif(/^#define __NR3264_(\w+)\s+([0-9]+)/){ $prev = $2; fmt($1, $2); } diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_netbsd.pl b/Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_netbsd.pl old mode 100644 new mode 100755 index fc16fccb03..e74616a65a --- a/Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_netbsd.pl +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_netbsd.pl @@ -8,12 +8,19 @@ 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 < len(b) { + if h.Len < SizeofCmsghdr || uint64(h.Len) > uint64(len(b)) { return nil, nil, EINVAL } return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil @@ -77,10 +77,10 @@ func UnixRights(fds ...int) []byte { h.Level = SOL_SOCKET h.Type = SCM_RIGHTS h.SetLen(CmsgLen(datalen)) - data := uintptr(cmsgData(h)) + data := cmsgData(h) for _, fd := range fds { - *(*int32)(unsafe.Pointer(data)) = int32(fd) - data += 4 + *(*int32)(data) = int32(fd) + data = unsafe.Pointer(uintptr(data) + 4) } return b } diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/str.go b/Godeps/_workspace/src/golang.org/x/sys/unix/str.go index f873edecc7..35ed664353 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/str.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/str.go @@ -8,8 +8,12 @@ package unix func itoa(val int) string { // do it here rather than with fmt to avoid dependency if val < 0 { - return "-" + itoa(-val) + 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 { diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall.go index a48d47cff8..571e6993c3 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall.go @@ -68,6 +68,8 @@ 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 } + // use is a no-op, but the compiler cannot see that it is. // Calling use(p) ensures that p is kept live until that point. //go:noescape diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_bsd.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_bsd.go index 7b08113bf3..e9671764cc 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_bsd.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_bsd.go @@ -450,16 +450,34 @@ func Kevent(kq int, changes, events []Kevent_t, timeout *Timespec) (n int, err e //sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL -func Sysctl(name string) (value string, err error) { +// sysctlmib translates name to mib number and appends any additional args. +func sysctlmib(name string, args ...int) ([]_C_int, error) { // Translate name to mib number. mib, err := nametomib(name) + if err != nil { + return nil, err + } + + for _, a := range args { + mib = append(mib, _C_int(a)) + } + + return mib, nil +} + +func Sysctl(name string) (string, error) { + return SysctlArgs(name) +} + +func SysctlArgs(name string, args ...int) (string, error) { + mib, err := sysctlmib(name, args...) if err != nil { return "", err } // Find size. n := uintptr(0) - if err = sysctl(mib, nil, &n, nil, 0); err != nil { + if err := sysctl(mib, nil, &n, nil, 0); err != nil { return "", err } if n == 0 { @@ -468,7 +486,7 @@ func Sysctl(name string) (value string, err error) { // Read into buffer of that size. buf := make([]byte, n) - if err = sysctl(mib, &buf[0], &n, nil, 0); err != nil { + if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil { return "", err } @@ -479,17 +497,19 @@ func Sysctl(name string) (value string, err error) { return string(buf[0:n]), nil } -func SysctlUint32(name string) (value uint32, err error) { - // Translate name to mib number. - mib, err := nametomib(name) +func SysctlUint32(name string) (uint32, error) { + return SysctlUint32Args(name) +} + +func SysctlUint32Args(name string, args ...int) (uint32, error) { + mib, err := sysctlmib(name, args...) if err != nil { return 0, err } - // Read into buffer of that size. n := uintptr(4) buf := make([]byte, 4) - if err = sysctl(mib, &buf[0], &n, nil, 0); err != nil { + if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil { return 0, err } if n != 4 { @@ -498,9 +518,55 @@ func SysctlUint32(name string) (value uint32, err error) { return *(*uint32)(unsafe.Pointer(&buf[0])), nil } +func SysctlUint64(name string, args ...int) (uint64, error) { + mib, err := sysctlmib(name, args...) + if err != nil { + return 0, err + } + + n := uintptr(8) + buf := make([]byte, 8) + if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil { + return 0, err + } + if n != 8 { + return 0, EIO + } + return *(*uint64)(unsafe.Pointer(&buf[0])), nil +} + +func SysctlRaw(name string, args ...int) ([]byte, error) { + mib, err := sysctlmib(name, args...) + if err != nil { + return nil, err + } + + // Find size. + n := uintptr(0) + if err := sysctl(mib, nil, &n, nil, 0); err != nil { + return nil, err + } + if n == 0 { + return nil, nil + } + + // Read into buffer of that size. + buf := make([]byte, n) + if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil { + return nil, err + } + + // The actual call may return less than the original reported required + // size so ensure we deal with that. + return buf[:n], nil +} + //sys utimes(path string, timeval *[2]Timeval) (err error) -func Utimes(path string, tv []Timeval) (err error) { +func Utimes(path string, tv []Timeval) error { + if tv == nil { + return utimes(path, nil) + } if len(tv) != 2 { return EINVAL } @@ -508,6 +574,9 @@ func Utimes(path string, tv []Timeval) (err error) { } func UtimesNano(path string, ts []Timespec) error { + if ts == nil { + return utimes(path, nil) + } // TODO: The BSDs can do utimensat with SYS_UTIMENSAT but it // isn't supported by darwin so this uses utimes instead if len(ts) != 2 { @@ -524,7 +593,10 @@ func UtimesNano(path string, ts []Timespec) error { //sys futimes(fd int, timeval *[2]Timeval) (err error) -func Futimes(fd int, tv []Timeval) (err error) { +func Futimes(fd int, tv []Timeval) error { + if tv == nil { + return futimes(fd, nil) + } if len(tv) != 2 { return EINVAL } diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_386.go index 40bef13ce0..c172a3da5a 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_386.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build 386,darwin + package unix import ( @@ -19,8 +21,6 @@ func NsecToTimespec(nsec int64) (ts Timespec) { return } -func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } - func NsecToTimeval(nsec int64) (tv Timeval) { nsec += 999 // round up to microsecond tv.Usec = int32(nsec % 1e9 / 1e3) @@ -71,3 +71,7 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e } func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) + +// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions +// of darwin/386 the syscall is called sysctl instead of __sysctl. +const SYS___SYSCTL = SYS_SYSCTL diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_amd64.go index 57bd190319..fc1e5a4a82 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_amd64.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build amd64,darwin + package unix import ( @@ -9,6 +11,8 @@ import ( "unsafe" ) +//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) + func Getpagesize() int { return 4096 } func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } @@ -19,8 +23,6 @@ func NsecToTimespec(nsec int64) (ts Timespec) { return } -func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } - func NsecToTimeval(nsec int64) (tv Timeval) { nsec += 999 // round up to microsecond tv.Usec = int32(nsec % 1e9 / 1e3) @@ -71,3 +73,7 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e } func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) + +// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions +// of darwin/amd64 the syscall is called sysctl instead of __sysctl. +const SYS___SYSCTL = SYS_SYSCTL diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_dragonfly_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_arm.go similarity index 67% rename from Godeps/_workspace/src/golang.org/x/sys/unix/syscall_dragonfly_386.go rename to Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_arm.go index b3b02d4dbc..d286cf408d 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_dragonfly_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_arm.go @@ -1,4 +1,4 @@ -// Copyright 2009 The Go Authors. All rights reserved. +// 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. @@ -19,8 +19,6 @@ func NsecToTimespec(nsec int64) (ts Timespec) { return } -func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } - func NsecToTimeval(nsec int64) (tv Timeval) { nsec += 999 // round up to microsecond tv.Usec = int32(nsec % 1e9 / 1e3) @@ -28,6 +26,17 @@ func NsecToTimeval(nsec int64) (tv Timeval) { return } +//sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) +func Gettimeofday(tv *Timeval) (err error) { + // The tv passed to gettimeofday must be non-nil + // but is otherwise unused. The answers come back + // in the two registers. + sec, usec, err := gettimeofday(tv) + tv.Sec = int32(sec) + tv.Usec = int32(usec) + return err +} + func SetKevent(k *Kevent_t, fd, mode, flags int) { k.Ident = uint32(fd) k.Filter = int16(mode) @@ -47,10 +56,11 @@ func (cmsg *Cmsghdr) SetLen(length int) { } func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { - var writtenOut uint64 = 0 - _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) + var length = uint64(count) + + _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) - written = int(writtenOut) + written = int(length) if e1 != 0 { err = e1 @@ -58,4 +68,4 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e return } -func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) +func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_arm64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_arm64.go new file mode 100644 index 0000000000..c33905cdcd --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_arm64.go @@ -0,0 +1,77 @@ +// 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 arm64,darwin + +package unix + +import ( + "syscall" + "unsafe" +) + +func Getpagesize() int { return 16384 } + +func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = nsec / 1e9 + ts.Nsec = nsec % 1e9 + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Usec = int32(nsec % 1e9 / 1e3) + tv.Sec = int64(nsec / 1e9) + return +} + +//sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) +func Gettimeofday(tv *Timeval) (err error) { + // The tv passed to gettimeofday must be non-nil + // but is otherwise unused. The answers come back + // in the two registers. + sec, usec, err := gettimeofday(tv) + tv.Sec = sec + tv.Usec = usec + return err +} + +func SetKevent(k *Kevent_t, fd, mode, flags int) { + k.Ident = uint64(fd) + k.Filter = int16(mode) + k.Flags = uint16(flags) +} + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint64(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint32(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint32(length) +} + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + var length = uint64(count) + + _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) + + written = int(length) + + if e1 != 0 { + err = e1 + } + return +} + +func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic + +// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions +// of darwin/arm64 the syscall is called sysctl instead of __sysctl. +const SYS___SYSCTL = SYS_SYSCTL diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_dragonfly_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_dragonfly_amd64.go index 568ada119b..da7cb7982c 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_dragonfly_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_dragonfly_amd64.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build amd64,dragonfly + package unix import ( @@ -19,8 +21,6 @@ func NsecToTimespec(nsec int64) (ts Timespec) { return } -func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } - func NsecToTimeval(nsec int64) (tv Timeval) { nsec += 999 // round up to microsecond tv.Usec = nsec % 1e9 / 1e3 diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_386.go index b3b02d4dbc..6a0cd804d8 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_386.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build 386,freebsd + package unix import ( @@ -19,8 +21,6 @@ func NsecToTimespec(nsec int64) (ts Timespec) { return } -func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } - func NsecToTimeval(nsec int64) (tv Timeval) { nsec += 999 // round up to microsecond tv.Usec = int32(nsec % 1e9 / 1e3) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_amd64.go index 568ada119b..e142540efa 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_amd64.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build amd64,freebsd + package unix import ( @@ -19,8 +21,6 @@ func NsecToTimespec(nsec int64) (ts Timespec) { return } -func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } - func NsecToTimeval(nsec int64) (tv Timeval) { nsec += 999 // round up to microsecond tv.Usec = nsec % 1e9 / 1e3 diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_arm.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_arm.go index 4cf79fb43a..5504cb1255 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_arm.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_arm.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build arm,freebsd + package unix import ( @@ -19,8 +21,6 @@ func NsecToTimespec(nsec int64) (ts Timespec) { return } -func TimevalToNsec(tv Timeval) int64 { return tv.Sec*1e9 + int64(tv.Usec)*1e3 } - func NsecToTimeval(nsec int64) (tv Timeval) { nsec += 999 // round up to microsecond tv.Usec = int32(nsec % 1e9 / 1e3) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux.go index e35959fe9a..9ca104c957 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux.go @@ -20,10 +20,38 @@ import ( * Wrapped */ -//sys open(path string, mode int, perm uint32) (fd int, err error) +func Access(path string, mode uint32) (err error) { + return Faccessat(AT_FDCWD, path, mode, 0) +} + +func Chmod(path string, mode uint32) (err error) { + return Fchmodat(AT_FDCWD, path, mode, 0) +} + +func Chown(path string, uid int, gid int) (err error) { + return Fchownat(AT_FDCWD, path, uid, gid, 0) +} + +func Creat(path string, mode uint32) (fd int, err error) { + return Open(path, O_CREAT|O_WRONLY|O_TRUNC, mode) +} + +//sys Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) + +func Link(oldpath string, newpath string) (err error) { + return Linkat(AT_FDCWD, oldpath, AT_FDCWD, newpath, 0) +} + +func Mkdir(path string, mode uint32) (err error) { + return Mkdirat(AT_FDCWD, path, mode) +} + +func Mknod(path string, mode uint32, dev int) (err error) { + return Mknodat(AT_FDCWD, path, mode, dev) +} func Open(path string, mode int, perm uint32) (fd int, err error) { - return open(path, mode|O_LARGEFILE, perm) + return openat(AT_FDCWD, path, mode|O_LARGEFILE, perm) } //sys openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) @@ -32,48 +60,73 @@ func Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) return openat(dirfd, path, flags|O_LARGEFILE, mode) } -//sysnb pipe(p *[2]_C_int) (err error) +//sys readlinkat(dirfd int, path string, buf []byte) (n int, err error) -func Pipe(p []int) (err error) { - if len(p) != 2 { - return EINVAL - } - var pp [2]_C_int - err = pipe(&pp) - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return +func Readlink(path string, buf []byte) (n int, err error) { + return readlinkat(AT_FDCWD, path, buf) +} + +func Rename(oldpath string, newpath string) (err error) { + return Renameat(AT_FDCWD, oldpath, AT_FDCWD, newpath) } -//sysnb pipe2(p *[2]_C_int, flags int) (err error) +func Rmdir(path string) error { + return unlinkat(AT_FDCWD, path, AT_REMOVEDIR) +} -func Pipe2(p []int, flags int) (err error) { - if len(p) != 2 { - return EINVAL - } - var pp [2]_C_int - err = pipe2(&pp, flags) - p[0] = int(pp[0]) - p[1] = int(pp[1]) - return +//sys symlinkat(oldpath string, newdirfd int, newpath string) (err error) + +func Symlink(oldpath string, newpath string) (err error) { + return symlinkat(oldpath, AT_FDCWD, newpath) +} + +func Unlink(path string) error { + return unlinkat(AT_FDCWD, path, 0) +} + +//sys unlinkat(dirfd int, path string, flags int) (err error) + +func Unlinkat(dirfd int, path string, flags int) error { + return unlinkat(dirfd, path, flags) } //sys utimes(path string, times *[2]Timeval) (err error) -func Utimes(path string, tv []Timeval) (err error) { +func Utimes(path string, tv []Timeval) error { + if tv == nil { + err := utimensat(AT_FDCWD, path, nil, 0) + if err != ENOSYS { + return err + } + return utimes(path, nil) + } if len(tv) != 2 { return EINVAL } + var ts [2]Timespec + ts[0] = NsecToTimespec(TimevalToNsec(tv[0])) + ts[1] = NsecToTimespec(TimevalToNsec(tv[1])) + err := utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) + if err != ENOSYS { + return err + } return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) } //sys utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) -func UtimesNano(path string, ts []Timespec) (err error) { +func UtimesNano(path string, ts []Timespec) error { + if ts == nil { + err := utimensat(AT_FDCWD, path, nil, 0) + if err != ENOSYS { + return err + } + return utimes(path, nil) + } if len(ts) != 2 { return EINVAL } - err = utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) + err := utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) if err != ENOSYS { return err } @@ -87,7 +140,10 @@ func UtimesNano(path string, ts []Timespec) (err error) { return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) } -func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) (err error) { +func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) error { + if ts == nil { + return utimensat(dirfd, path, nil, flags) + } if len(ts) != 2 { return EINVAL } @@ -96,14 +152,17 @@ func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) (err error) //sys futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) -func Futimesat(dirfd int, path string, tv []Timeval) (err error) { - if len(tv) != 2 { - return EINVAL - } +func Futimesat(dirfd int, path string, tv []Timeval) error { pathp, err := BytePtrFromString(path) if err != nil { return err } + if tv == nil { + return futimesat(dirfd, pathp, nil) + } + if len(tv) != 2 { + return EINVAL + } return futimesat(dirfd, pathp, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) } @@ -335,6 +394,19 @@ func (sa *SockaddrNetlink) sockaddr() (unsafe.Pointer, _Socklen, error) { return unsafe.Pointer(&sa.raw), SizeofSockaddrNetlink, nil } +type SockaddrHCI struct { + Dev uint16 + Channel uint16 + raw RawSockaddrHCI +} + +func (sa *SockaddrHCI) sockaddr() (unsafe.Pointer, _Socklen, error) { + sa.raw.Family = AF_BLUETOOTH + sa.raw.Dev = sa.Dev + sa.raw.Channel = sa.Channel + return unsafe.Pointer(&sa.raw), SizeofSockaddrHCI, nil +} + func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) { switch rsa.Addr.Family { case AF_NETLINK: @@ -789,22 +861,17 @@ func Mount(source string, target string, fstype string, flags uintptr, data stri /* * Direct access */ -//sys Access(path string, mode uint32) (err error) //sys Acct(path string) (err error) //sys Adjtimex(buf *Timex) (state int, err error) //sys Chdir(path string) (err error) -//sys Chmod(path string, mode uint32) (err error) //sys Chroot(path string) (err error) //sys ClockGettime(clockid int32, time *Timespec) (err error) //sys Close(fd int) (err error) -//sys Creat(path string, mode uint32) (fd int, err error) //sys Dup(oldfd int) (fd int, err error) -//sys Dup2(oldfd int, newfd int) (err error) //sys Dup3(oldfd int, newfd int, flags int) (err error) //sysnb EpollCreate(size int) (fd int, err error) //sysnb EpollCreate1(flag int) (fd int, err error) //sysnb EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) -//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys Exit(code int) = SYS_EXIT_GROUP //sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error) //sys Fallocate(fd int, mode uint32, off int64, len int64) (err error) @@ -831,32 +898,26 @@ func Getpgrp() (pid int) { //sysnb Gettid() (tid int) //sys Getxattr(path string, attr string, dest []byte) (sz int, err error) //sys InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) -//sysnb InotifyInit() (fd int, err error) //sysnb InotifyInit1(flags int) (fd int, err error) //sysnb InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) //sysnb Kill(pid int, sig syscall.Signal) (err error) //sys Klogctl(typ int, buf []byte) (n int, err error) = SYS_SYSLOG -//sys Link(oldpath string, newpath string) (err error) //sys Listxattr(path string, dest []byte) (sz int, err error) -//sys Mkdir(path string, mode uint32) (err error) //sys Mkdirat(dirfd int, path string, mode uint32) (err error) -//sys Mknod(path string, mode uint32, dev int) (err error) //sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error) //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) -//sys Pause() (err error) //sys PivotRoot(newroot string, putold string) (err error) = SYS_PIVOT_ROOT //sysnb prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) = SYS_PRLIMIT64 +//sys Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) //sys read(fd int, p []byte) (n int, err error) -//sys Readlink(path string, buf []byte) (n int, err error) //sys Removexattr(path string, attr string) (err error) -//sys Rename(oldpath string, newpath string) (err error) //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) -//sys Rmdir(path string) (err error) //sys Setdomainname(p []byte) (err error) //sys Sethostname(p []byte) (err error) //sysnb Setpgid(pid int, pgid int) (err error) //sysnb Setsid() (pid int, err error) //sysnb Settimeofday(tv *Timeval) (err error) +//sys Setns(fd int, nstype int) (err error) // issue 1435. // On linux Setuid and Setgid only affects the current thread, not the process. @@ -873,7 +934,6 @@ func Setgid(uid int) (err error) { //sys Setpriority(which int, who int, prio int) (err error) //sys Setxattr(path string, attr string, data []byte, flags int) (err error) -//sys Symlink(oldpath string, newpath string) (err error) //sys Sync() //sysnb Sysinfo(info *Sysinfo_t) (err error) //sys Tee(rfd int, wfd int, len int, flags int) (n int64, err error) @@ -881,12 +941,9 @@ func Setgid(uid int) (err error) { //sysnb Times(tms *Tms) (ticks uintptr, err error) //sysnb Umask(mask int) (oldmask int) //sysnb Uname(buf *Utsname) (err error) -//sys Unlink(path string) (err error) -//sys Unlinkat(dirfd int, path string, flags int) (err error) //sys Unmount(target string, flags int) (err error) = SYS_UMOUNT2 //sys Unshare(flags int) (err error) //sys Ustat(dev int, ubuf *Ustat_t) (err error) -//sys Utime(path string, buf *Utimbuf) (err error) //sys write(fd int, p []byte) (n int, err error) //sys exitThread(code int) (err error) = SYS_EXIT //sys readlen(fd int, p *byte, np int) (n int, err error) = SYS_READ @@ -988,7 +1045,6 @@ func Munmap(b []byte) (err error) { // Personality // Poll // Ppoll -// Prctl // Pselect6 // Ptrace // Putpmsg diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_386.go index 3e1eab0da6..bea01cb506 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_386.go @@ -5,6 +5,8 @@ // TODO(rsc): Rewrite all nn(SP) references into name+(nn-8)(FP) // so that go vet can check that they are correct. +// +build 386,linux + package unix import ( @@ -22,8 +24,6 @@ func NsecToTimespec(nsec int64) (ts Timespec) { return } -func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } - func NsecToTimeval(nsec int64) (tv Timeval) { nsec += 999 // round up to microsecond tv.Sec = int32(nsec / 1e9) @@ -31,9 +31,35 @@ func NsecToTimeval(nsec int64) (tv Timeval) { return } +//sysnb pipe(p *[2]_C_int) (err error) + +func Pipe(p []int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe(&pp) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + +//sysnb pipe2(p *[2]_C_int, flags int) (err error) + +func Pipe2(p []int, flags int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe2(&pp, flags) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + // 64-bit file system and 32-bit uid calls // (386 default is 32-bit file system and 16-bit uid). -//sys Chown(path string, uid int, gid int) (err error) = SYS_CHOWN32 +//sys Dup2(oldfd int, newfd int) (err error) //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64_64 //sys Fchown(fd int, uid int, gid int) (err error) = SYS_FCHOWN32 //sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 @@ -42,6 +68,7 @@ func NsecToTimeval(nsec int64) (tv Timeval) { //sysnb Geteuid() (euid int) = SYS_GETEUID32 //sysnb Getgid() (gid int) = SYS_GETGID32 //sysnb Getuid() (uid int) = SYS_GETUID32 +//sysnb InotifyInit() (fd int, err error) //sys Ioperm(from int, num int, on int) (err error) //sys Iopl(level int) (err error) //sys Lchown(path string, uid int, gid int) (err error) = SYS_LCHOWN32 @@ -64,6 +91,8 @@ func NsecToTimeval(nsec int64) (tv Timeval) { //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT //sys mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error) +//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) +//sys Pause() (err error) func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { page := uintptr(offset / 4096) @@ -152,6 +181,8 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { //sysnb Gettimeofday(tv *Timeval) (err error) //sysnb Time(t *Time_t) (tt Time_t, err error) +//sys Utime(path string, buf *Utimbuf) (err error) + // On x86 Linux, all the socket calls go through an extra indirection, // I think because the 5-register system call interface can't handle // the 6-argument calls like sendto and recvfrom. Instead the diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_amd64.go index 7a89584ba8..721f24b68d 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_amd64.go @@ -2,11 +2,14 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build amd64,linux + package unix import "syscall" -//sys Chown(path string, uid int, gid int) (err error) +//sys Dup2(oldfd int, newfd int) (err error) +//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 //sys Fchown(fd int, uid int, gid int) (err error) //sys Fstat(fd int, stat *Stat_t) (err error) @@ -17,11 +20,13 @@ import "syscall" //sysnb Getgid() (gid int) //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) //sysnb Getuid() (uid int) +//sysnb InotifyInit() (fd int, err error) //sys Ioperm(from int, num int, on int) (err error) //sys Iopl(level int) (err error) //sys Lchown(path string, uid int, gid int) (err error) //sys Listen(s int, n int) (err error) //sys Lstat(path string, stat *Stat_t) (err error) +//sys Pause() (err error) //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK @@ -58,8 +63,6 @@ import "syscall" //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) -func Getpagesize() int { return 4096 } - //go:noescape func gettimeofday(tv *Timeval) (err syscall.Errno) @@ -71,6 +74,8 @@ func Gettimeofday(tv *Timeval) (err error) { return nil } +func Getpagesize() int { return 4096 } + func Time(t *Time_t) (tt Time_t, err error) { var tv Timeval errno := gettimeofday(&tv) @@ -83,6 +88,8 @@ func Time(t *Time_t) (tt Time_t, err error) { return Time_t(tv.Sec), nil } +//sys Utime(path string, buf *Utimbuf) (err error) + func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } func NsecToTimespec(nsec int64) (ts Timespec) { @@ -91,8 +98,6 @@ func NsecToTimespec(nsec int64) (ts Timespec) { return } -func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } - func NsecToTimeval(nsec int64) (tv Timeval) { nsec += 999 // round up to microsecond tv.Sec = nsec / 1e9 @@ -100,6 +105,32 @@ func NsecToTimeval(nsec int64) (tv Timeval) { return } +//sysnb pipe(p *[2]_C_int) (err error) + +func Pipe(p []int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe(&pp) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + +//sysnb pipe2(p *[2]_C_int, flags int) (err error) + +func Pipe2(p []int, flags int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe2(&pp, flags) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + func (r *PtraceRegs) PC() uint64 { return r.Rip } func (r *PtraceRegs) SetPC(pc uint64) { r.Rip = pc } diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_arm.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_arm.go index 073a7a3c6a..122df649af 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_arm.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_arm.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build arm,linux + package unix import ( @@ -26,6 +28,30 @@ func NsecToTimeval(nsec int64) (tv Timeval) { return } +func Pipe(p []int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe2(&pp, 0) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + +//sysnb pipe2(p *[2]_C_int, flags int) (err error) + +func Pipe2(p []int, flags int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe2(&pp, flags) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + // Underlying system call writes to newoffset via pointer. // Implemented in assembly to avoid allocation. func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) @@ -57,13 +83,14 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { // 64-bit file system and 32-bit uid calls // (16-bit uid calls are not always supported in newer kernels) -//sys Chown(path string, uid int, gid int) (err error) = SYS_CHOWN32 +//sys Dup2(oldfd int, newfd int) (err error) //sys Fchown(fd int, uid int, gid int) (err error) = SYS_FCHOWN32 //sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 //sysnb Getegid() (egid int) = SYS_GETEGID32 //sysnb Geteuid() (euid int) = SYS_GETEUID32 //sysnb Getgid() (gid int) = SYS_GETGID32 //sysnb Getuid() (uid int) = SYS_GETUID32 +//sysnb InotifyInit() (fd int, err error) //sys Lchown(path string, uid int, gid int) (err error) = SYS_LCHOWN32 //sys Listen(s int, n int) (err error) //sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64 @@ -81,7 +108,28 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { // Vsyscalls on amd64. //sysnb Gettimeofday(tv *Timeval) (err error) -//sysnb Time(t *Time_t) (tt Time_t, err error) +//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) +//sys Pause() (err error) + +func Time(t *Time_t) (Time_t, error) { + var tv Timeval + err := Gettimeofday(&tv) + if err != nil { + return 0, err + } + if t != nil { + *t = Time_t(tv.Sec) + } + return Time_t(tv.Sec), nil +} + +func Utime(path string, buf *Utimbuf) error { + tv := []Timeval{ + {Sec: buf.Actime}, + {Sec: buf.Modtime}, + } + return Utimes(path, tv) +} //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 @@ -131,7 +179,7 @@ type rlimit32 struct { Max uint32 } -//sysnb getrlimit(resource int, rlim *rlimit32) (err error) = SYS_GETRLIMIT +//sysnb getrlimit(resource int, rlim *rlimit32) (err error) = SYS_UGETRLIMIT const rlimInf32 = ^uint32(0) const rlimInf64 = ^uint64(0) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_arm64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_arm64.go new file mode 100644 index 0000000000..d105186803 --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_arm64.go @@ -0,0 +1,180 @@ +// 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 arm64,linux + +package unix + +const _SYS_dup = SYS_DUP3 + +//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) = SYS_EPOLL_PWAIT +//sys Fchown(fd int, uid int, gid int) (err error) +//sys Fstat(fd int, stat *Stat_t) (err error) +//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) +//sys Fstatfs(fd int, buf *Statfs_t) (err error) +//sys Ftruncate(fd int, length int64) (err error) +//sysnb Getegid() (egid int) +//sysnb Geteuid() (euid int) +//sysnb Getgid() (gid int) +//sysnb Getrlimit(resource int, rlim *Rlimit) (err error) +//sysnb Getuid() (uid int) +//sys Listen(s int, n int) (err error) +//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK +//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS_PSELECT6 +//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) +//sys Setfsgid(gid int) (err error) +//sys Setfsuid(uid int) (err error) +//sysnb Setregid(rgid int, egid int) (err error) +//sysnb Setresgid(rgid int, egid int, sgid int) (err error) +//sysnb Setresuid(ruid int, euid int, suid int) (err error) +//sysnb Setrlimit(resource int, rlim *Rlimit) (err error) +//sysnb Setreuid(ruid int, euid int) (err error) +//sys Shutdown(fd int, how int) (err error) +//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) + +func Stat(path string, stat *Stat_t) (err error) { + return Fstatat(AT_FDCWD, path, stat, 0) +} + +func Lchown(path string, uid int, gid int) (err error) { + return Fchownat(AT_FDCWD, path, uid, gid, AT_SYMLINK_NOFOLLOW) +} + +func Lstat(path string, stat *Stat_t) (err error) { + return Fstatat(AT_FDCWD, path, stat, AT_SYMLINK_NOFOLLOW) +} + +//sys Statfs(path string, buf *Statfs_t) (err error) +//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) +//sys Truncate(path string, length int64) (err error) +//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) +//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) +//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) +//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) +//sysnb getgroups(n int, list *_Gid_t) (nn int, err error) +//sysnb setgroups(n int, list *_Gid_t) (err error) +//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) +//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) +//sysnb socket(domain int, typ int, proto int) (fd int, err error) +//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) +//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) +//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) +//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) +//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) +//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) +//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) +//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) + +func Getpagesize() int { return 65536 } + +//sysnb Gettimeofday(tv *Timeval) (err error) + +func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = nsec / 1e9 + ts.Nsec = nsec % 1e9 + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Sec = nsec / 1e9 + tv.Usec = nsec % 1e9 / 1e3 + return +} + +func Time(t *Time_t) (Time_t, error) { + var tv Timeval + err := Gettimeofday(&tv) + if err != nil { + return 0, err + } + if t != nil { + *t = Time_t(tv.Sec) + } + return Time_t(tv.Sec), nil +} + +func Utime(path string, buf *Utimbuf) error { + tv := []Timeval{ + {Sec: buf.Actime}, + {Sec: buf.Modtime}, + } + return Utimes(path, tv) +} + +func Pipe(p []int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe2(&pp, 0) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + +//sysnb pipe2(p *[2]_C_int, flags int) (err error) + +func Pipe2(p []int, flags int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe2(&pp, flags) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + +func (r *PtraceRegs) PC() uint64 { return r.Pc } + +func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc } + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint64(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint64(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint64(length) +} + +func InotifyInit() (fd int, err error) { + return InotifyInit1(0) +} + +func Dup2(oldfd int, newfd int) (err error) { + return Dup3(oldfd, newfd, 0) +} + +func Pause() (err error) { + _, _, e1 := Syscall6(SYS_PPOLL, 0, 0, 0, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// TODO(dfc): constants that should be in zsysnum_linux_arm64.go, remove +// these when the deprecated syscalls that the syscall package relies on +// are removed. +const ( + SYS_GETPGRP = 1060 + SYS_UTIMES = 1037 + SYS_FUTIMESAT = 1066 + SYS_PAUSE = 1061 + SYS_USTAT = 1070 + SYS_UTIME = 1063 + SYS_LCHOWN = 1032 + SYS_TIME = 1062 + SYS_EPOLL_CREATE = 1042 + SYS_EPOLL_WAIT = 1069 +) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_mips64x.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_mips64x.go new file mode 100644 index 0000000000..bb15ba3e68 --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_mips64x.go @@ -0,0 +1,206 @@ +// 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 + +package unix + +// Linux introduced getdents64 syscall for N64 ABI only in 3.10 +// (May 21 2013, rev dec33abaafc89bcbd78f85fad0513170415a26d5), +// to support older kernels, we have to use getdents for mips64. +// Also note that struct dirent is different for these two. +// Lookup linux_dirent{,64} in kernel source code for details. +const _SYS_getdents = SYS_GETDENTS + +//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) +//sys Fchown(fd int, uid int, gid int) (err error) +//sys Fstatfs(fd int, buf *Statfs_t) (err error) +//sys Ftruncate(fd int, length int64) (err error) +//sysnb Getegid() (egid int) +//sysnb Geteuid() (euid int) +//sysnb Getgid() (gid int) +//sysnb Getrlimit(resource int, rlim *Rlimit) (err error) +//sysnb Getuid() (uid int) +//sys Lchown(path string, uid int, gid int) (err error) +//sys Listen(s int, n int) (err error) +//sys Pause() (err error) +//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK +//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS_PSELECT6 +//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) +//sys Setfsgid(gid int) (err error) +//sys Setfsuid(uid int) (err error) +//sysnb Setregid(rgid int, egid int) (err error) +//sysnb Setresgid(rgid int, egid int, sgid int) (err error) +//sysnb Setresuid(ruid int, euid int, suid int) (err error) +//sysnb Setrlimit(resource int, rlim *Rlimit) (err error) +//sysnb Setreuid(ruid int, euid int) (err error) +//sys Shutdown(fd int, how int) (err error) +//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) +//sys Statfs(path string, buf *Statfs_t) (err error) +//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) +//sys Truncate(path string, length int64) (err error) +//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) +//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) +//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) +//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) +//sysnb getgroups(n int, list *_Gid_t) (nn int, err error) +//sysnb setgroups(n int, list *_Gid_t) (err error) +//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) +//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) +//sysnb socket(domain int, typ int, proto int) (fd int, err error) +//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) +//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) +//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) +//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) +//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) +//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) +//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) +//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) + +func Getpagesize() int { return 65536 } + +//sysnb Gettimeofday(tv *Timeval) (err error) + +func Time(t *Time_t) (tt Time_t, err error) { + var tv Timeval + err = Gettimeofday(&tv) + if err != nil { + return 0, err + } + if t != nil { + *t = Time_t(tv.Sec) + } + return Time_t(tv.Sec), nil +} + +//sys Utime(path string, buf *Utimbuf) (err error) + +func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = nsec / 1e9 + ts.Nsec = nsec % 1e9 + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Sec = nsec / 1e9 + tv.Usec = nsec % 1e9 / 1e3 + return +} + +func Pipe(p []int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe2(&pp, 0) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + +//sysnb pipe2(p *[2]_C_int, flags int) (err error) + +func Pipe2(p []int, flags int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe2(&pp, flags) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + +func Ioperm(from int, num int, on int) (err error) { + return ENOSYS +} + +func Iopl(level int) (err error) { + return ENOSYS +} + +type stat_t struct { + Dev uint32 + Pad0 [3]int32 + Ino uint64 + Mode uint32 + Nlink uint32 + Uid uint32 + Gid uint32 + Rdev uint32 + Pad1 [3]uint32 + Size int64 + Atime uint32 + Atime_nsec uint32 + Mtime uint32 + Mtime_nsec uint32 + Ctime uint32 + Ctime_nsec uint32 + Blksize uint32 + Pad2 uint32 + Blocks int64 +} + +//sys fstat(fd int, st *stat_t) (err error) +//sys lstat(path string, st *stat_t) (err error) +//sys stat(path string, st *stat_t) (err error) + +func Fstat(fd int, s *Stat_t) (err error) { + st := &stat_t{} + err = fstat(fd, st) + fillStat_t(s, st) + return +} + +func Lstat(path string, s *Stat_t) (err error) { + st := &stat_t{} + err = lstat(path, st) + fillStat_t(s, st) + return +} + +func Stat(path string, s *Stat_t) (err error) { + st := &stat_t{} + err = stat(path, st) + fillStat_t(s, st) + return +} + +func fillStat_t(s *Stat_t, st *stat_t) { + s.Dev = st.Dev + s.Ino = st.Ino + s.Mode = st.Mode + s.Nlink = st.Nlink + s.Uid = st.Uid + s.Gid = st.Gid + s.Rdev = st.Rdev + s.Size = st.Size + s.Atim = Timespec{int64(st.Atime), int64(st.Atime_nsec)} + s.Mtim = Timespec{int64(st.Mtime), int64(st.Mtime_nsec)} + s.Ctim = Timespec{int64(st.Ctime), int64(st.Ctime_nsec)} + s.Blksize = st.Blksize + s.Blocks = st.Blocks +} + +func (r *PtraceRegs) PC() uint64 { return r.Regs[64] } + +func (r *PtraceRegs) SetPC(pc uint64) { r.Regs[64] = pc } + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint64(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint64(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint64(length) +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_ppc64x.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_ppc64x.go new file mode 100644 index 0000000000..acd2e1c789 --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_ppc64x.go @@ -0,0 +1,126 @@ +// 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 linux +// +build ppc64 ppc64le + +package unix + +//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) +//sys Dup2(oldfd int, newfd int) (err error) +//sys Fchown(fd int, uid int, gid int) (err error) +//sys Fstat(fd int, stat *Stat_t) (err error) +//sys Fstatfs(fd int, buf *Statfs_t) (err error) +//sys Ftruncate(fd int, length int64) (err error) +//sysnb Getegid() (egid int) +//sysnb Geteuid() (euid int) +//sysnb Getgid() (gid int) +//sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = SYS_UGETRLIMIT +//sysnb Getuid() (uid int) +//sysnb InotifyInit() (fd int, err error) +//sys Ioperm(from int, num int, on int) (err error) +//sys Iopl(level int) (err error) +//sys Lchown(path string, uid int, gid int) (err error) +//sys Listen(s int, n int) (err error) +//sys Lstat(path string, stat *Stat_t) (err error) +//sys Pause() (err error) +//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK +//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) +//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) +//sys Setfsgid(gid int) (err error) +//sys Setfsuid(uid int) (err error) +//sysnb Setregid(rgid int, egid int) (err error) +//sysnb Setresgid(rgid int, egid int, sgid int) (err error) +//sysnb Setresuid(ruid int, euid int, suid int) (err error) +//sysnb Setrlimit(resource int, rlim *Rlimit) (err error) +//sysnb Setreuid(ruid int, euid int) (err error) +//sys Shutdown(fd int, how int) (err error) +//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) +//sys Stat(path string, stat *Stat_t) (err error) +//sys Statfs(path string, buf *Statfs_t) (err error) +//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) = SYS_SYNC_FILE_RANGE2 +//sys Truncate(path string, length int64) (err error) +//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) +//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) +//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) +//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) +//sysnb getgroups(n int, list *_Gid_t) (nn int, err error) +//sysnb setgroups(n int, list *_Gid_t) (err error) +//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) +//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) +//sysnb socket(domain int, typ int, proto int) (fd int, err error) +//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) +//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) +//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) +//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) +//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) +//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) +//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) +//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) + +func Getpagesize() int { return 65536 } + +//sysnb Gettimeofday(tv *Timeval) (err error) +//sysnb Time(t *Time_t) (tt Time_t, err error) + +//sys Utime(path string, buf *Utimbuf) (err error) + +func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = nsec / 1e9 + ts.Nsec = nsec % 1e9 + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Sec = nsec / 1e9 + tv.Usec = nsec % 1e9 / 1e3 + return +} + +func (r *PtraceRegs) PC() uint64 { return r.Nip } + +func (r *PtraceRegs) SetPC(pc uint64) { r.Nip = pc } + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint64(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint64(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint64(length) +} + +//sysnb pipe(p *[2]_C_int) (err error) + +func Pipe(p []int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe(&pp) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + +//sysnb pipe2(p *[2]_C_int, flags int) (err error) + +func Pipe2(p []int, flags int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe2(&pp, flags) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_s390x.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_s390x.go new file mode 100644 index 0000000000..3f98904e3c --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_s390x.go @@ -0,0 +1,320 @@ +// 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,linux + +package unix + +import ( + "unsafe" +) + +//sys Dup2(oldfd int, newfd int) (err error) +//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) +//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 +//sys Fchown(fd int, uid int, gid int) (err error) +//sys Fstat(fd int, stat *Stat_t) (err error) +//sys Fstatfs(fd int, buf *Statfs_t) (err error) +//sys Ftruncate(fd int, length int64) (err error) +//sysnb Getegid() (egid int) +//sysnb Geteuid() (euid int) +//sysnb Getgid() (gid int) +//sysnb Getrlimit(resource int, rlim *Rlimit) (err error) +//sysnb Getuid() (uid int) +//sysnb InotifyInit() (fd int, err error) +//sys Lchown(path string, uid int, gid int) (err error) +//sys Lstat(path string, stat *Stat_t) (err error) +//sys Pause() (err error) +//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK +//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) +//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) +//sys Setfsgid(gid int) (err error) +//sys Setfsuid(uid int) (err error) +//sysnb Setregid(rgid int, egid int) (err error) +//sysnb Setresgid(rgid int, egid int, sgid int) (err error) +//sysnb Setresuid(ruid int, euid int, suid int) (err error) +//sysnb Setrlimit(resource int, rlim *Rlimit) (err error) +//sysnb Setreuid(ruid int, euid int) (err error) +//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) +//sys Stat(path string, stat *Stat_t) (err error) +//sys Statfs(path string, buf *Statfs_t) (err error) +//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) +//sys Truncate(path string, length int64) (err error) +//sysnb getgroups(n int, list *_Gid_t) (nn int, err error) +//sysnb setgroups(n int, list *_Gid_t) (err error) + +func Getpagesize() int { return 4096 } + +//sysnb Gettimeofday(tv *Timeval) (err error) + +func Time(t *Time_t) (tt Time_t, err error) { + var tv Timeval + err = Gettimeofday(&tv) + if err != nil { + return 0, err + } + if t != nil { + *t = Time_t(tv.Sec) + } + return Time_t(tv.Sec), nil +} + +//sys Utime(path string, buf *Utimbuf) (err error) + +func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = nsec / 1e9 + ts.Nsec = nsec % 1e9 + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Sec = nsec / 1e9 + tv.Usec = nsec % 1e9 / 1e3 + return +} + +//sysnb pipe2(p *[2]_C_int, flags int) (err error) + +func Pipe(p []int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe2(&pp, 0) // pipe2 is the same as pipe when flags are set to 0. + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + +func Pipe2(p []int, flags int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe2(&pp, flags) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + +func Ioperm(from int, num int, on int) (err error) { + return ENOSYS +} + +func Iopl(level int) (err error) { + return ENOSYS +} + +func (r *PtraceRegs) PC() uint64 { return r.Psw.Addr } + +func (r *PtraceRegs) SetPC(pc uint64) { r.Psw.Addr = pc } + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint64(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint64(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint64(length) +} + +// Linux on s390x uses the old mmap interface, which requires arguments to be passed in a struct. +// mmap2 also requires arguments to be passed in a struct; it is currently not exposed in . +func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { + mmap_args := [6]uintptr{addr, length, uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset)} + r0, _, e1 := Syscall(SYS_MMAP, uintptr(unsafe.Pointer(&mmap_args[0])), 0, 0) + use(unsafe.Pointer(&mmap_args[0])) + xaddr = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// On s390x Linux, all the socket calls go through an extra indirection. +// The arguments to the underlying system call (SYS_SOCKETCALL) are the +// number below and a pointer to an array of uintptr. +const ( + // see linux/net.h + netSocket = 1 + netBind = 2 + netConnect = 3 + netListen = 4 + netAccept = 5 + netGetSockName = 6 + netGetPeerName = 7 + netSocketPair = 8 + netSend = 9 + netRecv = 10 + netSendTo = 11 + netRecvFrom = 12 + netShutdown = 13 + netSetSockOpt = 14 + netGetSockOpt = 15 + netSendMsg = 16 + netRecvMsg = 17 + netAccept4 = 18 + netRecvMMsg = 19 + netSendMMsg = 20 +) + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (int, error) { + args := [3]uintptr{uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))} + fd, _, err := Syscall(SYS_SOCKETCALL, netAccept, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return 0, err + } + return int(fd), nil +} + +func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (int, error) { + args := [4]uintptr{uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags)} + fd, _, err := Syscall(SYS_SOCKETCALL, netAccept4, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return 0, err + } + return int(fd), nil +} + +func getsockname(s int, rsa *RawSockaddrAny, addrlen *_Socklen) error { + args := [3]uintptr{uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))} + _, _, err := RawSyscall(SYS_SOCKETCALL, netGetSockName, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return err + } + return nil +} + +func getpeername(s int, rsa *RawSockaddrAny, addrlen *_Socklen) error { + args := [3]uintptr{uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))} + _, _, err := RawSyscall(SYS_SOCKETCALL, netGetPeerName, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return err + } + return nil +} + +func socketpair(domain int, typ int, flags int, fd *[2]int32) error { + args := [4]uintptr{uintptr(domain), uintptr(typ), uintptr(flags), uintptr(unsafe.Pointer(fd))} + _, _, err := RawSyscall(SYS_SOCKETCALL, netSocketPair, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return err + } + return nil +} + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) error { + args := [3]uintptr{uintptr(s), uintptr(addr), uintptr(addrlen)} + _, _, err := Syscall(SYS_SOCKETCALL, netBind, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return err + } + return nil +} + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) error { + args := [3]uintptr{uintptr(s), uintptr(addr), uintptr(addrlen)} + _, _, err := Syscall(SYS_SOCKETCALL, netConnect, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return err + } + return nil +} + +func socket(domain int, typ int, proto int) (int, error) { + args := [3]uintptr{uintptr(domain), uintptr(typ), uintptr(proto)} + fd, _, err := RawSyscall(SYS_SOCKETCALL, netSocket, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return 0, err + } + return int(fd), nil +} + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) error { + args := [5]uintptr{uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen))} + _, _, err := Syscall(SYS_SOCKETCALL, netGetSockOpt, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return err + } + return nil +} + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) error { + args := [4]uintptr{uintptr(s), uintptr(level), uintptr(name), uintptr(val)} + _, _, err := Syscall(SYS_SOCKETCALL, netSetSockOpt, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return err + } + return nil +} + +func recvfrom(s int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (int, error) { + var base uintptr + if len(p) > 0 { + base = uintptr(unsafe.Pointer(&p[0])) + } + args := [6]uintptr{uintptr(s), base, uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))} + n, _, err := Syscall(SYS_SOCKETCALL, netRecvFrom, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return 0, err + } + return int(n), nil +} + +func sendto(s int, p []byte, flags int, to unsafe.Pointer, addrlen _Socklen) error { + var base uintptr + if len(p) > 0 { + base = uintptr(unsafe.Pointer(&p[0])) + } + args := [6]uintptr{uintptr(s), base, uintptr(len(p)), uintptr(flags), uintptr(to), uintptr(addrlen)} + _, _, err := Syscall(SYS_SOCKETCALL, netSendTo, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return err + } + return nil +} + +func recvmsg(s int, msg *Msghdr, flags int) (int, error) { + args := [3]uintptr{uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)} + n, _, err := Syscall(SYS_SOCKETCALL, netRecvMsg, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return 0, err + } + return int(n), nil +} + +func sendmsg(s int, msg *Msghdr, flags int) (int, error) { + args := [3]uintptr{uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)} + n, _, err := Syscall(SYS_SOCKETCALL, netSendMsg, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return 0, err + } + return int(n), nil +} + +func Listen(s int, n int) error { + args := [2]uintptr{uintptr(s), uintptr(n)} + _, _, err := Syscall(SYS_SOCKETCALL, netListen, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return err + } + return nil +} + +func Shutdown(s, how int) error { + args := [2]uintptr{uintptr(s), uintptr(how)} + _, _, err := Syscall(SYS_SOCKETCALL, netShutdown, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return err + } + return nil +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_386.go index bf73fff2e9..afaca09838 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_386.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build 386,netbsd + package unix func Getpagesize() int { return 4096 } @@ -14,8 +16,6 @@ func NsecToTimespec(nsec int64) (ts Timespec) { return } -func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } - func NsecToTimeval(nsec int64) (tv Timeval) { nsec += 999 // round up to microsecond tv.Usec = int32(nsec % 1e9 / 1e3) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_amd64.go index 474a092cbd..a6ff04ce5b 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_amd64.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build amd64,netbsd + package unix func Getpagesize() int { return 4096 } @@ -14,8 +16,6 @@ func NsecToTimespec(nsec int64) (ts Timespec) { return } -func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } - func NsecToTimeval(nsec int64) (tv Timeval) { nsec += 999 // round up to microsecond tv.Usec = int32(nsec % 1e9 / 1e3) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_arm.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_arm.go index 3c6755b3ed..68a6969b28 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_arm.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_arm.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build arm,netbsd + package unix func Getpagesize() int { return 4096 } @@ -14,8 +16,6 @@ func NsecToTimespec(nsec int64) (ts Timespec) { return } -func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } - func NsecToTimeval(nsec int64) (tv Timeval) { nsec += 999 // round up to microsecond tv.Usec = int32(nsec % 1e9 / 1e3) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_openbsd_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_openbsd_386.go index 23b665c069..a66ddc59ce 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_openbsd_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_openbsd_386.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build 386,openbsd + package unix func Getpagesize() int { return 4096 } @@ -14,8 +16,6 @@ func NsecToTimespec(nsec int64) (ts Timespec) { return } -func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } - func NsecToTimeval(nsec int64) (tv Timeval) { nsec += 999 // round up to microsecond tv.Usec = int32(nsec % 1e9 / 1e3) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_openbsd_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_openbsd_amd64.go index e5513534da..0776c1faf9 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_openbsd_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_openbsd_amd64.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build amd64,openbsd + package unix func Getpagesize() int { return 4096 } @@ -14,8 +16,6 @@ func NsecToTimespec(nsec int64) (ts Timespec) { return } -func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } - func NsecToTimeval(nsec int64) (tv Timeval) { nsec += 999 // round up to microsecond tv.Usec = nsec % 1e9 / 1e3 diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_solaris.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_solaris.go index 7e9626ad0d..eb489b159f 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_solaris.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_solaris.go @@ -13,10 +13,17 @@ package unix import ( + "sync/atomic" "syscall" "unsafe" ) +// Implemented in runtime/syscall_solaris.go. +type syscallFunc uintptr + +func rawSysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) +func sysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) + type SockaddrDatalink struct { Family uint16 Index uint16 @@ -132,6 +139,8 @@ func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) { return unsafe.Pointer(&sa.raw), sl, nil } +//sys getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) = libsocket.getsockname + func Getsockname(fd int) (sa Sockaddr, err error) { var rsa RawSockaddrAny var len _Socklen = SizeofSockaddrAny @@ -141,12 +150,23 @@ func Getsockname(fd int) (sa Sockaddr, err error) { return anyToSockaddr(&rsa) } -// The const provides a compile-time constant so clients -// can adjust to whether there is a working Getwd and avoid -// even linking this function into the binary. See ../os/getwd.go. -const ImplementsGetwd = false +const ImplementsGetwd = true + +//sys Getcwd(buf []byte) (n int, err error) -func Getwd() (string, error) { return "", ENOTSUP } +func Getwd() (wd string, err error) { + var buf [PathMax]byte + // Getcwd will return an error if it failed for any reason. + _, err = Getcwd(buf[0:]) + if err != nil { + return "", err + } + n := clen(buf[:]) + if n < 1 { + return "", EINVAL + } + return string(buf[:n]), nil +} /* * Wrapped @@ -157,21 +177,20 @@ func Getwd() (string, error) { return "", ENOTSUP } func Getgroups() (gids []int, err error) { n, err := getgroups(0, nil) - if err != nil { - return nil, err - } - if n == 0 { - return nil, nil - } - - // Sanity check group count. Max is 16 on BSD. - if n < 0 || n > 1000 { + // Check for error and sanity check group count. Newer versions of + // Solaris allow up to 1024 (NGROUPS_MAX). + if n < 0 || n > 1024 { + if err != nil { + return nil, err + } return nil, EINVAL + } else if n == 0 { + return nil, nil } a := make([]_Gid_t, n) n, err = getgroups(n, &a[0]) - if err != nil { + if n == -1 { return nil, err } gids = make([]int, n) @@ -270,29 +289,80 @@ func Gethostname() (name string, err error) { return name, err } -func UtimesNano(path string, ts []Timespec) (err error) { +//sys utimes(path string, times *[2]Timeval) (err error) + +func Utimes(path string, tv []Timeval) (err error) { + if tv == nil { + return utimes(path, nil) + } + if len(tv) != 2 { + return EINVAL + } + return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) +} + +//sys utimensat(fd int, path string, times *[2]Timespec, flag int) (err error) + +func UtimesNano(path string, ts []Timespec) error { + if ts == nil { + return utimensat(AT_FDCWD, path, nil, 0) + } if len(ts) != 2 { return EINVAL } - var tv [2]Timeval - for i := 0; i < 2; i++ { - tv[i].Sec = ts[i].Sec - tv[i].Usec = ts[i].Nsec / 1000 + return utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) +} + +func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) error { + if ts == nil { + return utimensat(dirfd, path, nil, flags) } - return Utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) + if len(ts) != 2 { + return EINVAL + } + return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), flags) } //sys fcntl(fd int, cmd int, arg int) (val int, err error) // 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 { - _, _, e1 := sysvicall6(procfcntl.Addr(), 3, uintptr(fd), uintptr(cmd), uintptr(unsafe.Pointer(lk)), 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procfcntl)), 3, uintptr(fd), uintptr(cmd), uintptr(unsafe.Pointer(lk)), 0, 0, 0) if e1 != 0 { return e1 } return nil } +//sys futimesat(fildes int, path *byte, times *[2]Timeval) (err error) + +func Futimesat(dirfd int, path string, tv []Timeval) error { + pathp, err := BytePtrFromString(path) + if err != nil { + return err + } + if tv == nil { + return futimesat(dirfd, pathp, nil) + } + if len(tv) != 2 { + return EINVAL + } + return futimesat(dirfd, pathp, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) +} + +// Solaris doesn't have an futimes function because it allows NULL to be +// specified as the path for futimesat. However, Go doesn't like +// NULL-style string interfaces, so this simple wrapper is provided. +func Futimes(fd int, tv []Timeval) error { + if tv == nil { + return futimesat(fd, nil, nil) + } + if len(tv) != 2 { + return EINVAL + } + return futimesat(fd, nil, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) +} + func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) { switch rsa.Addr.Family { case AF_UNIX: @@ -341,7 +411,7 @@ func Accept(fd int) (nfd int, sa Sockaddr, err error) { var rsa RawSockaddrAny var len _Socklen = SizeofSockaddrAny nfd, err = accept(fd, &rsa, &len) - if err != nil { + if nfd == -1 { return } sa, err = anyToSockaddr(&rsa) @@ -352,6 +422,8 @@ func Accept(fd int) (nfd int, sa Sockaddr, err error) { return } +//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) = libsocket.recvmsg + func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) { var msg Msghdr var rsa RawSockaddrAny @@ -373,7 +445,7 @@ func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from } msg.Iov = &iov msg.Iovlen = 1 - if n, err = recvmsg(fd, &msg, flags); err != nil { + if n, err = recvmsg(fd, &msg, flags); n == -1 { return } oobn = int(msg.Accrightslen) @@ -428,6 +500,67 @@ func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) return n, nil } +//sys acct(path *byte) (err error) + +func Acct(path string) (err error) { + if len(path) == 0 { + // Assume caller wants to disable accounting. + return acct(nil) + } + + pathp, err := BytePtrFromString(path) + if err != nil { + return err + } + return acct(pathp) +} + +/* + * Expose the ioctl function + */ + +//sys ioctl(fd int, req int, arg uintptr) (err error) + +func IoctlSetInt(fd int, req int, value int) (err error) { + return ioctl(fd, req, uintptr(value)) +} + +func IoctlSetWinsize(fd int, req int, value *Winsize) (err error) { + return ioctl(fd, req, uintptr(unsafe.Pointer(value))) +} + +func IoctlSetTermios(fd int, req int, value *Termios) (err error) { + return ioctl(fd, req, uintptr(unsafe.Pointer(value))) +} + +func IoctlSetTermio(fd int, req int, value *Termio) (err error) { + return ioctl(fd, req, uintptr(unsafe.Pointer(value))) +} + +func IoctlGetInt(fd int, req int) (int, error) { + var value int + err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) + return value, err +} + +func IoctlGetWinsize(fd int, req int) (*Winsize, error) { + var value Winsize + err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) + return &value, err +} + +func IoctlGetTermios(fd int, req int) (*Termios, error) { + var value Termios + err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) + return &value, err +} + +func IoctlGetTermio(fd int, req int) (*Termio, error) { + var value Termio + err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) + return &value, err +} + /* * Exposed directly */ @@ -438,21 +571,29 @@ func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) //sys Chown(path string, uid int, gid int) (err error) //sys Chroot(path string) (err error) //sys Close(fd int) (err error) +//sys Creat(path string, mode uint32) (fd int, err error) //sys Dup(fd int) (nfd int, err error) +//sys Dup2(oldfd int, newfd int) (err error) //sys Exit(code int) //sys Fchdir(fd int) (err error) //sys Fchmod(fd int, mode uint32) (err error) +//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) //sys Fchown(fd int, uid int, gid int) (err error) +//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) +//sys Fdatasync(fd int) (err error) //sys Fpathconf(fd int, name int) (val int, err error) //sys Fstat(fd int, stat *Stat_t) (err error) //sys Getdents(fd int, buf []byte, basep *uintptr) (n int, err error) //sysnb Getgid() (gid int) //sysnb Getpid() (pid int) +//sysnb Getpgid(pid int) (pgid int, err error) +//sysnb Getpgrp() (pgid int, err error) //sys Geteuid() (euid int) //sys Getegid() (egid int) //sys Getppid() (ppid int) //sys Getpriority(which int, who int) (n int, err error) //sysnb Getrlimit(which int, lim *Rlimit) (err error) +//sysnb Getrusage(who int, rusage *Rusage) (err error) //sysnb Gettimeofday(tv *Timeval) (err error) //sysnb Getuid() (uid int) //sys Kill(pid int, signum syscall.Signal) (err error) @@ -460,21 +601,35 @@ func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) //sys Link(path string, link string) (err error) //sys Listen(s int, backlog int) (err error) = libsocket.listen //sys Lstat(path string, stat *Stat_t) (err error) +//sys Madvise(b []byte, advice int) (err error) //sys Mkdir(path string, mode uint32) (err error) +//sys Mkdirat(dirfd int, path string, mode uint32) (err error) +//sys Mkfifo(path string, mode uint32) (err error) +//sys Mkfifoat(dirfd int, path string, mode uint32) (err error) //sys Mknod(path string, mode uint32, dev int) (err error) +//sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error) +//sys Mlock(b []byte) (err error) +//sys Mlockall(flags int) (err error) +//sys Mprotect(b []byte, prot int) (err error) +//sys Munlock(b []byte) (err error) +//sys Munlockall() (err error) //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) //sys Open(path string, mode int, perm uint32) (fd int, err error) +//sys Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) //sys Pathconf(path string, name int) (val int, err error) +//sys Pause() (err error) //sys Pread(fd int, p []byte, offset int64) (n int, err error) //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) //sys read(fd int, p []byte) (n int, err error) //sys Readlink(path string, buf []byte) (n int, err error) //sys Rename(from string, to string) (err error) +//sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) //sys Rmdir(path string) (err error) //sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = lseek //sysnb Setegid(egid int) (err error) //sysnb Seteuid(euid int) (err error) //sysnb Setgid(gid int) (err error) +//sys Sethostname(p []byte) (err error) //sysnb Setpgid(pid int, pgid int) (err error) //sys Setpriority(which int, who int, prio int) (err error) //sysnb Setregid(rgid int, egid int) (err error) @@ -486,12 +641,17 @@ func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) //sys Stat(path string, stat *Stat_t) (err error) //sys Symlink(path string, link string) (err error) //sys Sync() (err error) +//sysnb Times(tms *Tms) (ticks uintptr, err error) //sys Truncate(path string, length int64) (err error) //sys Fsync(fd int) (err error) //sys Ftruncate(fd int, length int64) (err error) -//sys Umask(newmask int) (oldmask int) +//sys Umask(mask int) (oldmask int) +//sysnb Uname(buf *Utsname) (err error) +//sys Unmount(target string, flags int) (err error) = libc.umount //sys Unlink(path string) (err error) -//sys Utimes(path string, times *[2]Timeval) (err error) +//sys Unlinkat(dirfd int, path string, flags int) (err error) +//sys Ustat(dev int, ubuf *Ustat_t) (err error) +//sys Utime(path string, buf *Utimbuf) (err error) //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.bind //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.connect //sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) @@ -502,13 +662,11 @@ func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) //sys write(fd int, p []byte) (n int, err error) //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) = libsocket.getsockopt //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) = libsocket.getpeername -//sys getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) = libsocket.getsockname //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) = libsocket.setsockopt //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) = libsocket.recvfrom -//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) = libsocket.recvmsg func readlen(fd int, buf *byte, nbuf int) (n int, err error) { - r0, _, e1 := sysvicall6(procread.Addr(), 3, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf), 0, 0, 0) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procread)), 3, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf), 0, 0, 0) n = int(r0) if e1 != 0 { err = e1 @@ -517,10 +675,39 @@ func readlen(fd int, buf *byte, nbuf int) (n int, err error) { } func writelen(fd int, buf *byte, nbuf int) (n int, err error) { - r0, _, e1 := sysvicall6(procwrite.Addr(), 3, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf), 0, 0, 0) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procwrite)), 3, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf), 0, 0, 0) n = int(r0) if e1 != 0 { err = e1 } return } + +var mapper = &mmapper{ + active: make(map[*byte][]byte), + mmap: mmap, + munmap: munmap, +} + +func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) { + return mapper.Mmap(fd, offset, length, prot, flags) +} + +func Munmap(b []byte) (err error) { + return mapper.Munmap(b) +} + +//sys sysconf(name int) (n int64, err error) + +// pageSize caches the value of Getpagesize, since it can't change +// once the system is booted. +var pageSize int64 // accessed atomically + +func Getpagesize() int { + n := atomic.LoadInt64(&pageSize) + if n == 0 { + n, _ = sysconf(_SC_PAGESIZE) + atomic.StoreInt64(&pageSize, n) + } + return int(n) +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_solaris_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_solaris_amd64.go index 4795f524a4..5aff62c3bb 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_solaris_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/syscall_solaris_amd64.go @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package unix +// +build amd64,solaris -func Getpagesize() int { return 4096 } +package unix func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } @@ -14,8 +14,6 @@ func NsecToTimespec(nsec int64) (ts Timespec) { return } -func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } - func NsecToTimeval(nsec int64) (tv Timeval) { nsec += 999 // round up to microsecond tv.Usec = nsec % 1e9 / 1e3 diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/types_darwin.go b/Godeps/_workspace/src/golang.org/x/sys/unix/types_darwin.go index 2bb15cb8b7..1153261822 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/types_darwin.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/types_darwin.go @@ -241,3 +241,10 @@ type BpfHdr C.struct_bpf_hdr // Terminal handling type Termios C.struct_termios + +// fchmodat-like syscalls. + +const ( + AT_FDCWD = C.AT_FDCWD + AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW +) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/types_linux.go b/Godeps/_workspace/src/golang.org/x/sys/unix/types_linux.go index 49d9e1fedb..d004b4a484 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/types_linux.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/types_linux.go @@ -50,11 +50,20 @@ package unix #include #include #include -#include +#include #include #include #include #include +#include +#include + +#ifdef TCSETS2 +// On systems that have "struct termios2" use this as type Termios. +typedef struct termios2 termios_t; +#else +typedef struct termios termios_t; +#endif enum { sizeofPtr = sizeof(void*), @@ -77,7 +86,7 @@ struct sockaddr_any { // copied from /usr/include/linux/un.h struct my_sockaddr_un { sa_family_t sun_family; -#ifdef __ARM_EABI__ +#if defined(__ARM_EABI__) || defined(__powerpc64__) // on ARM char is by default unsigned signed char sun_path[108]; #else @@ -87,17 +96,37 @@ struct my_sockaddr_un { #ifdef __ARM_EABI__ typedef struct user_regs PtraceRegs; +#elif defined(__aarch64__) +typedef struct user_pt_regs PtraceRegs; +#elif defined(__powerpc64__) +typedef struct pt_regs PtraceRegs; +#elif defined(__mips__) +typedef struct user PtraceRegs; +#elif defined(__s390x__) +typedef struct _user_regs_struct PtraceRegs; #else typedef struct user_regs_struct PtraceRegs; #endif +#if defined(__s390x__) +typedef struct _user_psw_struct ptracePsw; +typedef struct _user_fpregs_struct ptraceFpregs; +typedef struct _user_per_struct ptracePer; +#else +typedef struct {} ptracePsw; +typedef struct {} ptraceFpregs; +typedef struct {} ptracePer; +#endif + // The real epoll_event is a union, and godefs doesn't handle it well. struct my_epoll_event { uint32_t events; -#ifdef __ARM_EABI__ +#if defined(__ARM_EABI__) || defined(__aarch64__) // padding is not specified in linux/eventpoll.h but added to conform to the // alignment requirements of EABI int32_t padFd; +#elif defined(__powerpc64__) || defined(__s390x__) + int32_t _padFd; #endif int32_t fd; int32_t pad; @@ -183,6 +212,8 @@ type RawSockaddrLinklayer C.struct_sockaddr_ll type RawSockaddrNetlink C.struct_sockaddr_nl +type RawSockaddrHCI C.struct_sockaddr_hci + type RawSockaddr C.struct_sockaddr type RawSockaddrAny C.struct_sockaddr_any @@ -222,6 +253,7 @@ const ( SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un SizeofSockaddrLinklayer = C.sizeof_struct_sockaddr_ll SizeofSockaddrNetlink = C.sizeof_struct_sockaddr_nl + SizeofSockaddrHCI = C.sizeof_struct_sockaddr_hci SizeofLinger = C.sizeof_struct_linger SizeofIPMreq = C.sizeof_struct_ip_mreq SizeofIPMreqn = C.sizeof_struct_ip_mreqn @@ -372,6 +404,13 @@ const SizeofInotifyEvent = C.sizeof_struct_inotify_event // Register structures type PtraceRegs C.PtraceRegs +// Structures contained in PtraceRegs on s390x (exported by mkpost.go) +type ptracePsw C.ptracePsw + +type ptraceFpregs C.ptraceFpregs + +type ptracePer C.ptracePer + // Misc type FdSet C.fd_set @@ -387,9 +426,10 @@ type EpollEvent C.struct_my_epoll_event const ( AT_FDCWD = C.AT_FDCWD AT_REMOVEDIR = C.AT_REMOVEDIR + AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW ) // Terminal handling -type Termios C.struct_termios +type Termios C.termios_t diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/types_solaris.go b/Godeps/_workspace/src/golang.org/x/sys/unix/types_solaris.go index 753c7996b1..6ad50eaba6 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/types_solaris.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/types_solaris.go @@ -15,10 +15,17 @@ package unix /* #define KERNEL +// These defines ensure that builds done on newer versions of Solaris are +// backwards-compatible with older versions of Solaris and +// OpenSolaris-based derivatives. +#define __USE_SUNOS_SOCKETS__ // msghdr +#define __USE_LEGACY_PROTOTYPES__ // iovec #include #include +#include #include #include +#include #include #include #include @@ -30,7 +37,9 @@ package unix #include #include #include +#include #include +#include #include #include #include @@ -40,6 +49,8 @@ package unix #include #include #include +#include +#include enum { sizeofPtr = sizeof(void*), @@ -69,6 +80,7 @@ const ( sizeofInt = C.sizeof_int sizeofLong = C.sizeof_long sizeofLongLong = C.sizeof_longlong + PathMax = C.PATH_MAX ) // Basic types @@ -88,6 +100,10 @@ type Timeval C.struct_timeval type Timeval32 C.struct_timeval32 +type Tms C.struct_tms + +type Utimbuf C.struct_utimbuf + // Processes type Rusage C.struct_rusage @@ -175,6 +191,20 @@ const ( type FdSet C.fd_set +// Misc + +type Utsname C.struct_utsname + +type Ustat_t C.struct_ustat + +const ( + AT_FDCWD = C.AT_FDCWD + AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW + AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW + AT_REMOVEDIR = C.AT_REMOVEDIR + AT_EACCESS = C.AT_EACCESS +) + // Routing and interface messages const ( @@ -217,6 +247,14 @@ type BpfTimeval C.struct_bpf_timeval type BpfHdr C.struct_bpf_hdr +// sysconf information + +const _SC_PAGESIZE = C._SC_PAGESIZE + // Terminal handling type Termios C.struct_termios + +type Termio C.struct_termio + +type Winsize C.struct_winsize diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_darwin_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_darwin_386.go index 15204b9c7d..8e63888351 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_darwin_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_darwin_386.go @@ -1,6 +1,8 @@ // mkerrors.sh -m32 // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build 386,darwin + // Created by cgo -godefs - DO NOT EDIT // cgo -godefs -- -m32 _const.go @@ -30,7 +32,7 @@ const ( AF_LAT = 0xe AF_LINK = 0x12 AF_LOCAL = 0x1 - AF_MAX = 0x26 + AF_MAX = 0x28 AF_NATM = 0x1f AF_NDRV = 0x1b AF_NETBIOS = 0x21 @@ -45,6 +47,7 @@ const ( AF_SYSTEM = 0x20 AF_UNIX = 0x1 AF_UNSPEC = 0x0 + AF_UTUN = 0x26 B0 = 0x0 B110 = 0x6e B115200 = 0x1c200 @@ -83,6 +86,7 @@ const ( BIOCSBLEN = 0xc0044266 BIOCSDLT = 0x80044278 BIOCSETF = 0x80084267 + BIOCSETFNR = 0x8008427e BIOCSETIF = 0x8020426c BIOCSHDRCMPLT = 0x80044275 BIOCSRSIG = 0x80044273 @@ -149,33 +153,168 @@ const ( CSUSP = 0x1a CTL_MAXNAME = 0xc CTL_NET = 0x4 + DLT_A429 = 0xb8 + DLT_A653_ICM = 0xb9 + DLT_AIRONET_HEADER = 0x78 + DLT_AOS = 0xde DLT_APPLE_IP_OVER_IEEE1394 = 0x8a DLT_ARCNET = 0x7 + DLT_ARCNET_LINUX = 0x81 DLT_ATM_CLIP = 0x13 DLT_ATM_RFC1483 = 0xb + DLT_AURORA = 0x7e DLT_AX25 = 0x3 + DLT_AX25_KISS = 0xca + DLT_BACNET_MS_TP = 0xa5 + DLT_BLUETOOTH_HCI_H4 = 0xbb + DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9 + DLT_CAN20B = 0xbe + DLT_CAN_SOCKETCAN = 0xe3 DLT_CHAOS = 0x5 DLT_CHDLC = 0x68 + DLT_CISCO_IOS = 0x76 DLT_C_HDLC = 0x68 + DLT_C_HDLC_WITH_DIR = 0xcd + DLT_DBUS = 0xe7 + DLT_DECT = 0xdd + DLT_DOCSIS = 0x8f + DLT_DVB_CI = 0xeb + DLT_ECONET = 0x73 DLT_EN10MB = 0x1 DLT_EN3MB = 0x2 + DLT_ENC = 0x6d + DLT_ERF = 0xc5 + DLT_ERF_ETH = 0xaf + DLT_ERF_POS = 0xb0 + DLT_FC_2 = 0xe0 + DLT_FC_2_WITH_FRAME_DELIMS = 0xe1 DLT_FDDI = 0xa + DLT_FLEXRAY = 0xd2 + DLT_FRELAY = 0x6b + DLT_FRELAY_WITH_DIR = 0xce + DLT_GCOM_SERIAL = 0xad + DLT_GCOM_T1E1 = 0xac + DLT_GPF_F = 0xab + DLT_GPF_T = 0xaa + DLT_GPRS_LLC = 0xa9 + DLT_GSMTAP_ABIS = 0xda + DLT_GSMTAP_UM = 0xd9 + DLT_HHDLC = 0x79 + DLT_IBM_SN = 0x92 + DLT_IBM_SP = 0x91 DLT_IEEE802 = 0x6 DLT_IEEE802_11 = 0x69 DLT_IEEE802_11_RADIO = 0x7f DLT_IEEE802_11_RADIO_AVS = 0xa3 + DLT_IEEE802_15_4 = 0xc3 + DLT_IEEE802_15_4_LINUX = 0xbf + DLT_IEEE802_15_4_NOFCS = 0xe6 + DLT_IEEE802_15_4_NONASK_PHY = 0xd7 + DLT_IEEE802_16_MAC_CPS = 0xbc + DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1 + DLT_IPFILTER = 0x74 + DLT_IPMB = 0xc7 + DLT_IPMB_LINUX = 0xd1 + DLT_IPNET = 0xe2 + DLT_IPOIB = 0xf2 + DLT_IPV4 = 0xe4 + DLT_IPV6 = 0xe5 + DLT_IP_OVER_FC = 0x7a + DLT_JUNIPER_ATM1 = 0x89 + DLT_JUNIPER_ATM2 = 0x87 + DLT_JUNIPER_ATM_CEMIC = 0xee + DLT_JUNIPER_CHDLC = 0xb5 + DLT_JUNIPER_ES = 0x84 + DLT_JUNIPER_ETHER = 0xb2 + DLT_JUNIPER_FIBRECHANNEL = 0xea + DLT_JUNIPER_FRELAY = 0xb4 + DLT_JUNIPER_GGSN = 0x85 + DLT_JUNIPER_ISM = 0xc2 + DLT_JUNIPER_MFR = 0x86 + DLT_JUNIPER_MLFR = 0x83 + DLT_JUNIPER_MLPPP = 0x82 + DLT_JUNIPER_MONITOR = 0xa4 + DLT_JUNIPER_PIC_PEER = 0xae + DLT_JUNIPER_PPP = 0xb3 + DLT_JUNIPER_PPPOE = 0xa7 + DLT_JUNIPER_PPPOE_ATM = 0xa8 + DLT_JUNIPER_SERVICES = 0x88 + DLT_JUNIPER_SRX_E2E = 0xe9 + DLT_JUNIPER_ST = 0xc8 + DLT_JUNIPER_VP = 0xb7 + DLT_JUNIPER_VS = 0xe8 + DLT_LAPB_WITH_DIR = 0xcf + DLT_LAPD = 0xcb + DLT_LIN = 0xd4 + DLT_LINUX_EVDEV = 0xd8 + DLT_LINUX_IRDA = 0x90 + DLT_LINUX_LAPD = 0xb1 + DLT_LINUX_PPP_WITHDIRECTION = 0xa6 DLT_LINUX_SLL = 0x71 DLT_LOOP = 0x6c + DLT_LTALK = 0x72 + DLT_MATCHING_MAX = 0xf5 + DLT_MATCHING_MIN = 0x68 + DLT_MFR = 0xb6 + DLT_MOST = 0xd3 + DLT_MPEG_2_TS = 0xf3 + DLT_MPLS = 0xdb + DLT_MTP2 = 0x8c + DLT_MTP2_WITH_PHDR = 0x8b + DLT_MTP3 = 0x8d + DLT_MUX27010 = 0xec + DLT_NETANALYZER = 0xf0 + DLT_NETANALYZER_TRANSPARENT = 0xf1 + DLT_NFC_LLCP = 0xf5 + DLT_NFLOG = 0xef + DLT_NG40 = 0xf4 DLT_NULL = 0x0 + DLT_PCI_EXP = 0x7d DLT_PFLOG = 0x75 DLT_PFSYNC = 0x12 + DLT_PPI = 0xc0 DLT_PPP = 0x9 DLT_PPP_BSDOS = 0x10 + DLT_PPP_ETHER = 0x33 + DLT_PPP_PPPD = 0xa6 DLT_PPP_SERIAL = 0x32 + DLT_PPP_WITH_DIR = 0xcc + DLT_PPP_WITH_DIRECTION = 0xa6 + DLT_PRISM_HEADER = 0x77 DLT_PRONET = 0x4 + DLT_RAIF1 = 0xc6 DLT_RAW = 0xc + DLT_RIO = 0x7c + DLT_SCCP = 0x8e + DLT_SITA = 0xc4 DLT_SLIP = 0x8 DLT_SLIP_BSDOS = 0xf + DLT_STANAG_5066_D_PDU = 0xed + DLT_SUNATM = 0x7b + DLT_SYMANTEC_FIREWALL = 0x63 + DLT_TZSP = 0x80 + DLT_USB = 0xba + DLT_USB_LINUX = 0xbd + DLT_USB_LINUX_MMAPPED = 0xdc + DLT_USER0 = 0x93 + DLT_USER1 = 0x94 + DLT_USER10 = 0x9d + DLT_USER11 = 0x9e + DLT_USER12 = 0x9f + DLT_USER13 = 0xa0 + DLT_USER14 = 0xa1 + DLT_USER15 = 0xa2 + DLT_USER2 = 0x95 + DLT_USER3 = 0x96 + DLT_USER4 = 0x97 + DLT_USER5 = 0x98 + DLT_USER6 = 0x99 + DLT_USER7 = 0x9a + DLT_USER8 = 0x9b + DLT_USER9 = 0x9c + DLT_WIHART = 0xdf + DLT_X2E_SERIAL = 0xd5 + DLT_X2E_XORAYA = 0xd6 DT_BLK = 0x6 DT_CHR = 0x2 DT_DIR = 0x4 @@ -198,8 +337,8 @@ const ( EVFILT_PROC = -0x5 EVFILT_READ = -0x1 EVFILT_SIGNAL = -0x6 - EVFILT_SYSCOUNT = 0xc - EVFILT_THREADMARKER = 0xc + EVFILT_SYSCOUNT = 0xe + EVFILT_THREADMARKER = 0xe EVFILT_TIMER = -0x7 EVFILT_USER = -0xa EVFILT_VM = -0xc @@ -233,9 +372,11 @@ const ( F_CHKCLEAN = 0x29 F_DUPFD = 0x0 F_DUPFD_CLOEXEC = 0x43 + F_FINDSIGS = 0x4e F_FLUSH_DATA = 0x28 F_FREEZE_FS = 0x35 F_FULLFSYNC = 0x33 + F_GETCODEDIR = 0x48 F_GETFD = 0x1 F_GETFL = 0x3 F_GETLK = 0x7 @@ -245,10 +386,10 @@ const ( F_GETPATH = 0x32 F_GETPATH_MTMINFO = 0x47 F_GETPROTECTIONCLASS = 0x3f + F_GETPROTECTIONLEVEL = 0x4d F_GLOBAL_NOCACHE = 0x37 F_LOG2PHYS = 0x31 F_LOG2PHYS_EXT = 0x41 - F_MARKDEPENDENCY = 0x3c F_NOCACHE = 0x30 F_NODIRECT = 0x3e F_OK = 0x0 @@ -258,20 +399,21 @@ const ( F_RDADVISE = 0x2c F_RDAHEAD = 0x2d F_RDLCK = 0x1 - F_READBOOTSTRAP = 0x2e F_SETBACKINGSTORE = 0x46 F_SETFD = 0x2 F_SETFL = 0x4 F_SETLK = 0x8 F_SETLKW = 0x9 + F_SETLKWTIMEOUT = 0xa F_SETNOSIGPIPE = 0x49 F_SETOWN = 0x6 F_SETPROTECTIONCLASS = 0x40 F_SETSIZE = 0x2b + F_SINGLE_WRITER = 0x4c F_THAW_FS = 0x36 + F_TRANSCODEKEY = 0x4b F_UNLCK = 0x2 F_VOLPOSMODE = 0x4 - F_WRITEBOOTSTRAP = 0x2f F_WRLCK = 0x3 HUPCL = 0x4000 ICANON = 0x100 @@ -341,6 +483,7 @@ const ( IFT_PDP = 0xff IFT_PFLOG = 0xf5 IFT_PFSYNC = 0xf6 + IFT_PKTAP = 0xfe IFT_PPP = 0x17 IFT_PROPMUX = 0x36 IFT_PROPVIRTUAL = 0x35 @@ -509,7 +652,7 @@ const ( IPV6_FAITH = 0x1d IPV6_FLOWINFO_MASK = 0xffffff0f IPV6_FLOWLABEL_MASK = 0xffff0f00 - IPV6_FRAGTTL = 0x78 + IPV6_FRAGTTL = 0x3c IPV6_FW_ADD = 0x1e IPV6_FW_DEL = 0x1f IPV6_FW_FLUSH = 0x20 @@ -679,11 +822,19 @@ const ( NOFLSH = 0x80000000 NOTE_ABSOLUTE = 0x8 NOTE_ATTRIB = 0x8 + NOTE_BACKGROUND = 0x40 NOTE_CHILD = 0x4 + NOTE_CRITICAL = 0x20 NOTE_DELETE = 0x1 NOTE_EXEC = 0x20000000 NOTE_EXIT = 0x80000000 NOTE_EXITSTATUS = 0x4000000 + NOTE_EXIT_CSERROR = 0x40000 + NOTE_EXIT_DECRYPTFAIL = 0x10000 + NOTE_EXIT_DETAIL = 0x2000000 + NOTE_EXIT_DETAIL_MASK = 0x70000 + NOTE_EXIT_MEMORY = 0x20000 + NOTE_EXIT_REPARENTED = 0x80000 NOTE_EXTEND = 0x4 NOTE_FFAND = 0x40000000 NOTE_FFCOPY = 0xc0000000 @@ -692,6 +843,7 @@ const ( NOTE_FFNOP = 0x0 NOTE_FFOR = 0x80000000 NOTE_FORK = 0x40000000 + NOTE_LEEWAY = 0x10 NOTE_LINK = 0x10 NOTE_LOWAT = 0x1 NOTE_NONE = 0x80 @@ -700,7 +852,6 @@ const ( NOTE_PDATAMASK = 0xfffff NOTE_REAP = 0x10000000 NOTE_RENAME = 0x20 - NOTE_RESOURCEEND = 0x2000000 NOTE_REVOKE = 0x40 NOTE_SECONDS = 0x1 NOTE_SIGNAL = 0x8000000 @@ -728,6 +879,7 @@ const ( O_CLOEXEC = 0x1000000 O_CREAT = 0x200 O_DIRECTORY = 0x100000 + O_DP_GETRAWENCRYPTED = 0x1 O_DSYNC = 0x400000 O_EVTONLY = 0x8000 O_EXCL = 0x800 @@ -777,6 +929,7 @@ const ( RLIMIT_AS = 0x5 RLIMIT_CORE = 0x4 RLIMIT_CPU = 0x0 + RLIMIT_CPU_USAGE_MONITOR = 0x2 RLIMIT_DATA = 0x2 RLIMIT_FSIZE = 0x1 RLIMIT_NOFILE = 0x8 @@ -814,12 +967,15 @@ const ( RTF_LOCAL = 0x200000 RTF_MODIFIED = 0x20 RTF_MULTICAST = 0x800000 + RTF_NOIFREF = 0x2000 RTF_PINNED = 0x100000 RTF_PRCLONING = 0x10000 RTF_PROTO1 = 0x8000 RTF_PROTO2 = 0x4000 RTF_PROTO3 = 0x40000 + RTF_PROXY = 0x8000000 RTF_REJECT = 0x8 + RTF_ROUTER = 0x10000000 RTF_STATIC = 0x800 RTF_UP = 0x1 RTF_WASCLONED = 0x20000 @@ -864,7 +1020,6 @@ const ( SHUT_WR = 0x1 SIOCADDMULTI = 0x80206931 SIOCAIFADDR = 0x8040691a - SIOCALIFADDR = 0x8118691d SIOCARPIPLL = 0xc0206928 SIOCATMARK = 0x40047307 SIOCAUTOADDR = 0xc0206926 @@ -872,10 +1027,7 @@ const ( SIOCDELMULTI = 0x80206932 SIOCDIFADDR = 0x80206919 SIOCDIFPHYADDR = 0x80206941 - SIOCDLIFADDR = 0x8118691f SIOCGDRVSPEC = 0xc01c697b - SIOCGETSGCNT = 0xc014721c - SIOCGETVIFCNT = 0xc014721b SIOCGETVLAN = 0xc020697f SIOCGHIWAT = 0x40047301 SIOCGIFADDR = 0xc0206921 @@ -901,13 +1053,12 @@ const ( SIOCGIFSTATUS = 0xc331693d SIOCGIFVLAN = 0xc020697f SIOCGIFWAKEFLAGS = 0xc0206988 - SIOCGLIFADDR = 0xc118691e - SIOCGLIFPHYADDR = 0xc1186943 SIOCGLOWAT = 0x40047303 SIOCGPGRP = 0x40047309 SIOCIFCREATE = 0xc0206978 SIOCIFCREATE2 = 0xc020697a SIOCIFDESTROY = 0x80206979 + SIOCIFGCLONERS = 0xc00c6981 SIOCRSLVMULTI = 0xc008693b SIOCSDRVSPEC = 0x801c697b SIOCSETVLAN = 0x8020697e @@ -931,7 +1082,6 @@ const ( SIOCSIFPHYADDR = 0x8040693e SIOCSIFPHYS = 0x80206936 SIOCSIFVLAN = 0x8020697e - SIOCSLIFPHYADDR = 0x81186942 SIOCSLOWAT = 0x80047302 SIOCSPGRP = 0x80047308 SOCK_DGRAM = 0x2 @@ -958,6 +1108,7 @@ const ( SO_NOTIFYCONFLICT = 0x1026 SO_NP_EXTENSIONS = 0x1083 SO_NREAD = 0x1020 + SO_NUMRCVPKT = 0x1112 SO_NWRITE = 0x1024 SO_OOBINLINE = 0x100 SO_PEERLABEL = 0x1011 @@ -965,10 +1116,6 @@ const ( SO_RCVBUF = 0x1002 SO_RCVLOWAT = 0x1004 SO_RCVTIMEO = 0x1006 - SO_RESTRICTIONS = 0x1081 - SO_RESTRICT_DENYIN = 0x1 - SO_RESTRICT_DENYOUT = 0x2 - SO_RESTRICT_DENYSET = 0x80000000 SO_REUSEADDR = 0x4 SO_REUSEPORT = 0x200 SO_REUSESHAREUID = 0x1025 @@ -1014,21 +1161,25 @@ const ( TCIOFLUSH = 0x3 TCOFLUSH = 0x2 TCP_CONNECTIONTIMEOUT = 0x20 + TCP_ENABLE_ECN = 0x104 TCP_KEEPALIVE = 0x10 + TCP_KEEPCNT = 0x102 + TCP_KEEPINTVL = 0x101 TCP_MAXHLEN = 0x3c TCP_MAXOLEN = 0x28 TCP_MAXSEG = 0x2 TCP_MAXWIN = 0xffff - TCP_MAX_SACK = 0x3 + TCP_MAX_SACK = 0x4 TCP_MAX_WINSHIFT = 0xe TCP_MINMSS = 0xd8 - TCP_MINMSSOVERLOAD = 0x3e8 TCP_MSS = 0x200 TCP_NODELAY = 0x1 TCP_NOOPT = 0x8 TCP_NOPUSH = 0x4 + TCP_NOTSENT_LOWAT = 0x201 TCP_RXT_CONNDROPTIME = 0x80 TCP_RXT_FINDROP = 0x100 + TCP_SENDMOREACKS = 0x103 TCSAFLUSH = 0x2 TIOCCBRK = 0x2000747a TIOCCDTR = 0x20007478 @@ -1172,7 +1323,7 @@ const ( EIO = syscall.Errno(0x5) EISCONN = syscall.Errno(0x38) EISDIR = syscall.Errno(0x15) - ELAST = syscall.Errno(0x69) + ELAST = syscall.Errno(0x6a) ELOOP = syscall.Errno(0x3e) EMFILE = syscall.Errno(0x18) EMLINK = syscall.Errno(0x1f) @@ -1223,6 +1374,7 @@ const ( EPROTONOSUPPORT = syscall.Errno(0x2b) EPROTOTYPE = syscall.Errno(0x29) EPWROFF = syscall.Errno(0x52) + EQFULL = syscall.Errno(0x6a) ERANGE = syscall.Errno(0x22) EREMOTE = syscall.Errno(0x47) EROFS = syscall.Errno(0x1e) @@ -1385,6 +1537,7 @@ var errors = [...]string{ 103: "policy not found", 104: "state not recoverable", 105: "previous owner died", + 106: "interface output queue is full", } // Signal table diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_darwin_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_darwin_amd64.go index 095b6f3a5c..9594f93817 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_darwin_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_darwin_amd64.go @@ -1,6 +1,8 @@ // mkerrors.sh -m64 // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build amd64,darwin + // Created by cgo -godefs - DO NOT EDIT // cgo -godefs -- -m64 _const.go @@ -374,6 +376,7 @@ const ( F_FLUSH_DATA = 0x28 F_FREEZE_FS = 0x35 F_FULLFSYNC = 0x33 + F_GETCODEDIR = 0x48 F_GETFD = 0x1 F_GETFL = 0x3 F_GETLK = 0x7 @@ -1017,7 +1020,6 @@ const ( SHUT_WR = 0x1 SIOCADDMULTI = 0x80206931 SIOCAIFADDR = 0x8040691a - SIOCALIFADDR = 0x8118691d SIOCARPIPLL = 0xc0206928 SIOCATMARK = 0x40047307 SIOCAUTOADDR = 0xc0206926 @@ -1025,10 +1027,7 @@ const ( SIOCDELMULTI = 0x80206932 SIOCDIFADDR = 0x80206919 SIOCDIFPHYADDR = 0x80206941 - SIOCDLIFADDR = 0x8118691f SIOCGDRVSPEC = 0xc028697b - SIOCGETSGCNT = 0xc014721c - SIOCGETVIFCNT = 0xc014721b SIOCGETVLAN = 0xc020697f SIOCGHIWAT = 0x40047301 SIOCGIFADDR = 0xc0206921 @@ -1054,8 +1053,6 @@ const ( SIOCGIFSTATUS = 0xc331693d SIOCGIFVLAN = 0xc020697f SIOCGIFWAKEFLAGS = 0xc0206988 - SIOCGLIFADDR = 0xc118691e - SIOCGLIFPHYADDR = 0xc1186943 SIOCGLOWAT = 0x40047303 SIOCGPGRP = 0x40047309 SIOCIFCREATE = 0xc0206978 @@ -1085,7 +1082,6 @@ const ( SIOCSIFPHYADDR = 0x8040693e SIOCSIFPHYS = 0x80206936 SIOCSIFVLAN = 0x8020697e - SIOCSLIFPHYADDR = 0x81186942 SIOCSLOWAT = 0x80047302 SIOCSPGRP = 0x80047308 SOCK_DGRAM = 0x2 @@ -1112,6 +1108,7 @@ const ( SO_NOTIFYCONFLICT = 0x1026 SO_NP_EXTENSIONS = 0x1083 SO_NREAD = 0x1020 + SO_NUMRCVPKT = 0x1112 SO_NWRITE = 0x1024 SO_OOBINLINE = 0x100 SO_PEERLABEL = 0x1011 @@ -1164,6 +1161,7 @@ const ( TCIOFLUSH = 0x3 TCOFLUSH = 0x2 TCP_CONNECTIONTIMEOUT = 0x20 + TCP_ENABLE_ECN = 0x104 TCP_KEEPALIVE = 0x10 TCP_KEEPCNT = 0x102 TCP_KEEPINTVL = 0x101 @@ -1171,13 +1169,14 @@ const ( TCP_MAXOLEN = 0x28 TCP_MAXSEG = 0x2 TCP_MAXWIN = 0xffff - TCP_MAX_SACK = 0x3 + TCP_MAX_SACK = 0x4 TCP_MAX_WINSHIFT = 0xe TCP_MINMSS = 0xd8 TCP_MSS = 0x200 TCP_NODELAY = 0x1 TCP_NOOPT = 0x8 TCP_NOPUSH = 0x4 + TCP_NOTSENT_LOWAT = 0x201 TCP_RXT_CONNDROPTIME = 0x80 TCP_RXT_FINDROP = 0x100 TCP_SENDMOREACKS = 0x103 diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_darwin_arm.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_darwin_arm.go new file mode 100644 index 0000000000..a410e88edd --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_darwin_arm.go @@ -0,0 +1,1293 @@ +// mkerrors.sh +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- _const.go + +// +build arm,darwin + +package unix + +import "syscall" + +const ( + AF_APPLETALK = 0x10 + AF_CCITT = 0xa + AF_CHAOS = 0x5 + AF_CNT = 0x15 + AF_COIP = 0x14 + AF_DATAKIT = 0x9 + AF_DECnet = 0xc + AF_DLI = 0xd + AF_E164 = 0x1c + AF_ECMA = 0x8 + AF_HYLINK = 0xf + AF_IEEE80211 = 0x25 + AF_IMPLINK = 0x3 + AF_INET = 0x2 + AF_INET6 = 0x1e + AF_IPX = 0x17 + AF_ISDN = 0x1c + AF_ISO = 0x7 + AF_LAT = 0xe + AF_LINK = 0x12 + AF_LOCAL = 0x1 + AF_MAX = 0x28 + AF_NATM = 0x1f + AF_NDRV = 0x1b + AF_NETBIOS = 0x21 + AF_NS = 0x6 + AF_OSI = 0x7 + AF_PPP = 0x22 + AF_PUP = 0x4 + AF_RESERVED_36 = 0x24 + AF_ROUTE = 0x11 + AF_SIP = 0x18 + AF_SNA = 0xb + AF_SYSTEM = 0x20 + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_UTUN = 0x26 + B0 = 0x0 + B110 = 0x6e + B115200 = 0x1c200 + B1200 = 0x4b0 + B134 = 0x86 + B14400 = 0x3840 + B150 = 0x96 + B1800 = 0x708 + B19200 = 0x4b00 + B200 = 0xc8 + B230400 = 0x38400 + B2400 = 0x960 + B28800 = 0x7080 + B300 = 0x12c + B38400 = 0x9600 + B4800 = 0x12c0 + B50 = 0x32 + B57600 = 0xe100 + B600 = 0x258 + B7200 = 0x1c20 + B75 = 0x4b + B76800 = 0x12c00 + B9600 = 0x2580 + BIOCFLUSH = 0x20004268 + BIOCGBLEN = 0x40044266 + BIOCGDLT = 0x4004426a + BIOCGDLTLIST = 0xc00c4279 + BIOCGETIF = 0x4020426b + BIOCGHDRCMPLT = 0x40044274 + BIOCGRSIG = 0x40044272 + BIOCGRTIMEOUT = 0x4010426e + BIOCGSEESENT = 0x40044276 + BIOCGSTATS = 0x4008426f + BIOCIMMEDIATE = 0x80044270 + BIOCPROMISC = 0x20004269 + BIOCSBLEN = 0xc0044266 + BIOCSDLT = 0x80044278 + BIOCSETF = 0x80104267 + BIOCSETIF = 0x8020426c + BIOCSHDRCMPLT = 0x80044275 + BIOCSRSIG = 0x80044273 + BIOCSRTIMEOUT = 0x8010426d + BIOCSSEESENT = 0x80044277 + BIOCVERSION = 0x40044271 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALIGNMENT = 0x4 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXBUFSIZE = 0x80000 + BPF_MAXINSNS = 0x200 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINBUFSIZE = 0x20 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RELEASE = 0x30bb6 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BRKINT = 0x2 + CFLUSH = 0xf + CLOCAL = 0x8000 + CREAD = 0x800 + CS5 = 0x0 + CS6 = 0x100 + CS7 = 0x200 + CS8 = 0x300 + CSIZE = 0x300 + CSTART = 0x11 + CSTATUS = 0x14 + CSTOP = 0x13 + CSTOPB = 0x400 + CSUSP = 0x1a + CTL_MAXNAME = 0xc + CTL_NET = 0x4 + DLT_APPLE_IP_OVER_IEEE1394 = 0x8a + DLT_ARCNET = 0x7 + DLT_ATM_CLIP = 0x13 + DLT_ATM_RFC1483 = 0xb + DLT_AX25 = 0x3 + DLT_CHAOS = 0x5 + DLT_CHDLC = 0x68 + DLT_C_HDLC = 0x68 + DLT_EN10MB = 0x1 + DLT_EN3MB = 0x2 + DLT_FDDI = 0xa + DLT_IEEE802 = 0x6 + DLT_IEEE802_11 = 0x69 + DLT_IEEE802_11_RADIO = 0x7f + DLT_IEEE802_11_RADIO_AVS = 0xa3 + DLT_LINUX_SLL = 0x71 + DLT_LOOP = 0x6c + DLT_NULL = 0x0 + DLT_PFLOG = 0x75 + DLT_PFSYNC = 0x12 + DLT_PPP = 0x9 + DLT_PPP_BSDOS = 0x10 + DLT_PPP_SERIAL = 0x32 + DLT_PRONET = 0x4 + DLT_RAW = 0xc + DLT_SLIP = 0x8 + DLT_SLIP_BSDOS = 0xf + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x40 + ECHOE = 0x2 + ECHOK = 0x4 + ECHOKE = 0x1 + ECHONL = 0x10 + ECHOPRT = 0x20 + EVFILT_AIO = -0x3 + EVFILT_FS = -0x9 + EVFILT_MACHPORT = -0x8 + EVFILT_PROC = -0x5 + EVFILT_READ = -0x1 + EVFILT_SIGNAL = -0x6 + EVFILT_SYSCOUNT = 0xe + EVFILT_THREADMARKER = 0xe + EVFILT_TIMER = -0x7 + EVFILT_USER = -0xa + EVFILT_VM = -0xc + EVFILT_VNODE = -0x4 + EVFILT_WRITE = -0x2 + EV_ADD = 0x1 + EV_CLEAR = 0x20 + EV_DELETE = 0x2 + EV_DISABLE = 0x8 + EV_DISPATCH = 0x80 + EV_ENABLE = 0x4 + EV_EOF = 0x8000 + EV_ERROR = 0x4000 + EV_FLAG0 = 0x1000 + EV_FLAG1 = 0x2000 + EV_ONESHOT = 0x10 + EV_OOBAND = 0x2000 + EV_POLL = 0x1000 + EV_RECEIPT = 0x40 + EV_SYSFLAGS = 0xf000 + EXTA = 0x4b00 + EXTB = 0x9600 + EXTPROC = 0x800 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FLUSHO = 0x800000 + F_ADDFILESIGS = 0x3d + F_ADDSIGS = 0x3b + F_ALLOCATEALL = 0x4 + F_ALLOCATECONTIG = 0x2 + F_CHKCLEAN = 0x29 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x43 + F_FINDSIGS = 0x4e + F_FLUSH_DATA = 0x28 + F_FREEZE_FS = 0x35 + F_FULLFSYNC = 0x33 + F_GETCODEDIR = 0x48 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLK = 0x7 + F_GETLKPID = 0x42 + F_GETNOSIGPIPE = 0x4a + F_GETOWN = 0x5 + F_GETPATH = 0x32 + F_GETPATH_MTMINFO = 0x47 + F_GETPROTECTIONCLASS = 0x3f + F_GETPROTECTIONLEVEL = 0x4d + F_GLOBAL_NOCACHE = 0x37 + F_LOG2PHYS = 0x31 + F_LOG2PHYS_EXT = 0x41 + F_NOCACHE = 0x30 + F_NODIRECT = 0x3e + F_OK = 0x0 + F_PATHPKG_CHECK = 0x34 + F_PEOFPOSMODE = 0x3 + F_PREALLOCATE = 0x2a + F_RDADVISE = 0x2c + F_RDAHEAD = 0x2d + F_RDLCK = 0x1 + F_SETBACKINGSTORE = 0x46 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLK = 0x8 + F_SETLKW = 0x9 + F_SETLKWTIMEOUT = 0xa + F_SETNOSIGPIPE = 0x49 + F_SETOWN = 0x6 + F_SETPROTECTIONCLASS = 0x40 + F_SETSIZE = 0x2b + F_SINGLE_WRITER = 0x4c + F_THAW_FS = 0x36 + F_TRANSCODEKEY = 0x4b + F_UNLCK = 0x2 + F_VOLPOSMODE = 0x4 + F_WRLCK = 0x3 + HUPCL = 0x4000 + ICANON = 0x100 + ICMP6_FILTER = 0x12 + ICRNL = 0x100 + IEXTEN = 0x400 + IFF_ALLMULTI = 0x200 + IFF_ALTPHYS = 0x4000 + IFF_BROADCAST = 0x2 + IFF_DEBUG = 0x4 + IFF_LINK0 = 0x1000 + IFF_LINK1 = 0x2000 + IFF_LINK2 = 0x4000 + IFF_LOOPBACK = 0x8 + IFF_MULTICAST = 0x8000 + IFF_NOARP = 0x80 + IFF_NOTRAILERS = 0x20 + IFF_OACTIVE = 0x400 + IFF_POINTOPOINT = 0x10 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SIMPLEX = 0x800 + IFF_UP = 0x1 + IFNAMSIZ = 0x10 + IFT_1822 = 0x2 + IFT_AAL5 = 0x31 + IFT_ARCNET = 0x23 + IFT_ARCNETPLUS = 0x24 + IFT_ATM = 0x25 + IFT_BRIDGE = 0xd1 + IFT_CARP = 0xf8 + IFT_CELLULAR = 0xff + IFT_CEPT = 0x13 + IFT_DS3 = 0x1e + IFT_ENC = 0xf4 + IFT_EON = 0x19 + IFT_ETHER = 0x6 + IFT_FAITH = 0x38 + IFT_FDDI = 0xf + IFT_FRELAY = 0x20 + IFT_FRELAYDCE = 0x2c + IFT_GIF = 0x37 + IFT_HDH1822 = 0x3 + IFT_HIPPI = 0x2f + IFT_HSSI = 0x2e + IFT_HY = 0xe + IFT_IEEE1394 = 0x90 + IFT_IEEE8023ADLAG = 0x88 + IFT_ISDNBASIC = 0x14 + IFT_ISDNPRIMARY = 0x15 + IFT_ISO88022LLC = 0x29 + IFT_ISO88023 = 0x7 + IFT_ISO88024 = 0x8 + IFT_ISO88025 = 0x9 + IFT_ISO88026 = 0xa + IFT_L2VLAN = 0x87 + IFT_LAPB = 0x10 + IFT_LOCALTALK = 0x2a + IFT_LOOP = 0x18 + IFT_MIOX25 = 0x26 + IFT_MODEM = 0x30 + IFT_NSIP = 0x1b + IFT_OTHER = 0x1 + IFT_P10 = 0xc + IFT_P80 = 0xd + IFT_PARA = 0x22 + IFT_PDP = 0xff + IFT_PFLOG = 0xf5 + IFT_PFSYNC = 0xf6 + IFT_PPP = 0x17 + IFT_PROPMUX = 0x36 + IFT_PROPVIRTUAL = 0x35 + IFT_PTPSERIAL = 0x16 + IFT_RS232 = 0x21 + IFT_SDLC = 0x11 + IFT_SIP = 0x1f + IFT_SLIP = 0x1c + IFT_SMDSDXI = 0x2b + IFT_SMDSICIP = 0x34 + IFT_SONET = 0x27 + IFT_SONETPATH = 0x32 + IFT_SONETVT = 0x33 + IFT_STARLAN = 0xb + IFT_STF = 0x39 + IFT_T1 = 0x12 + IFT_ULTRA = 0x1d + IFT_V35 = 0x2d + IFT_X25 = 0x5 + IFT_X25DDN = 0x4 + IFT_X25PLE = 0x28 + IFT_XETHER = 0x1a + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLASSD_HOST = 0xfffffff + IN_CLASSD_NET = 0xf0000000 + IN_CLASSD_NSHIFT = 0x1c + IN_LINKLOCALNETNUM = 0xa9fe0000 + IN_LOOPBACKNET = 0x7f + IPPROTO_3PC = 0x22 + IPPROTO_ADFS = 0x44 + IPPROTO_AH = 0x33 + IPPROTO_AHIP = 0x3d + IPPROTO_APES = 0x63 + IPPROTO_ARGUS = 0xd + IPPROTO_AX25 = 0x5d + IPPROTO_BHA = 0x31 + IPPROTO_BLT = 0x1e + IPPROTO_BRSATMON = 0x4c + IPPROTO_CFTP = 0x3e + IPPROTO_CHAOS = 0x10 + IPPROTO_CMTP = 0x26 + IPPROTO_CPHB = 0x49 + IPPROTO_CPNX = 0x48 + IPPROTO_DDP = 0x25 + IPPROTO_DGP = 0x56 + IPPROTO_DIVERT = 0xfe + IPPROTO_DONE = 0x101 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_EMCON = 0xe + IPPROTO_ENCAP = 0x62 + IPPROTO_EON = 0x50 + IPPROTO_ESP = 0x32 + IPPROTO_ETHERIP = 0x61 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GGP = 0x3 + IPPROTO_GMTP = 0x64 + IPPROTO_GRE = 0x2f + IPPROTO_HELLO = 0x3f + IPPROTO_HMP = 0x14 + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IDPR = 0x23 + IPPROTO_IDRP = 0x2d + IPPROTO_IGMP = 0x2 + IPPROTO_IGP = 0x55 + IPPROTO_IGRP = 0x58 + IPPROTO_IL = 0x28 + IPPROTO_INLSP = 0x34 + IPPROTO_INP = 0x20 + IPPROTO_IP = 0x0 + IPPROTO_IPCOMP = 0x6c + IPPROTO_IPCV = 0x47 + IPPROTO_IPEIP = 0x5e + IPPROTO_IPIP = 0x4 + IPPROTO_IPPC = 0x43 + IPPROTO_IPV4 = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_IRTP = 0x1c + IPPROTO_KRYPTOLAN = 0x41 + IPPROTO_LARP = 0x5b + IPPROTO_LEAF1 = 0x19 + IPPROTO_LEAF2 = 0x1a + IPPROTO_MAX = 0x100 + IPPROTO_MAXID = 0x34 + IPPROTO_MEAS = 0x13 + IPPROTO_MHRP = 0x30 + IPPROTO_MICP = 0x5f + IPPROTO_MTP = 0x5c + IPPROTO_MUX = 0x12 + IPPROTO_ND = 0x4d + IPPROTO_NHRP = 0x36 + IPPROTO_NONE = 0x3b + IPPROTO_NSP = 0x1f + IPPROTO_NVPII = 0xb + IPPROTO_OSPFIGP = 0x59 + IPPROTO_PGM = 0x71 + IPPROTO_PIGP = 0x9 + IPPROTO_PIM = 0x67 + IPPROTO_PRM = 0x15 + IPPROTO_PUP = 0xc + IPPROTO_PVP = 0x4b + IPPROTO_RAW = 0xff + IPPROTO_RCCMON = 0xa + IPPROTO_RDP = 0x1b + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_RVD = 0x42 + IPPROTO_SATEXPAK = 0x40 + IPPROTO_SATMON = 0x45 + IPPROTO_SCCSP = 0x60 + IPPROTO_SCTP = 0x84 + IPPROTO_SDRP = 0x2a + IPPROTO_SEP = 0x21 + IPPROTO_SRPC = 0x5a + IPPROTO_ST = 0x7 + IPPROTO_SVMTP = 0x52 + IPPROTO_SWIPE = 0x35 + IPPROTO_TCF = 0x57 + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_TPXX = 0x27 + IPPROTO_TRUNK1 = 0x17 + IPPROTO_TRUNK2 = 0x18 + IPPROTO_TTP = 0x54 + IPPROTO_UDP = 0x11 + IPPROTO_VINES = 0x53 + IPPROTO_VISA = 0x46 + IPPROTO_VMTP = 0x51 + IPPROTO_WBEXPAK = 0x4f + IPPROTO_WBMON = 0x4e + IPPROTO_WSN = 0x4a + IPPROTO_XNET = 0xf + IPPROTO_XTP = 0x24 + IPV6_2292DSTOPTS = 0x17 + IPV6_2292HOPLIMIT = 0x14 + IPV6_2292HOPOPTS = 0x16 + IPV6_2292NEXTHOP = 0x15 + IPV6_2292PKTINFO = 0x13 + IPV6_2292PKTOPTIONS = 0x19 + IPV6_2292RTHDR = 0x18 + IPV6_BINDV6ONLY = 0x1b + IPV6_BOUND_IF = 0x7d + IPV6_CHECKSUM = 0x1a + IPV6_DEFAULT_MULTICAST_HOPS = 0x1 + IPV6_DEFAULT_MULTICAST_LOOP = 0x1 + IPV6_DEFHLIM = 0x40 + IPV6_FAITH = 0x1d + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 + IPV6_FRAGTTL = 0x78 + IPV6_FW_ADD = 0x1e + IPV6_FW_DEL = 0x1f + IPV6_FW_FLUSH = 0x20 + IPV6_FW_GET = 0x22 + IPV6_FW_ZERO = 0x21 + IPV6_HLIMDEC = 0x1 + IPV6_IPSEC_POLICY = 0x1c + IPV6_JOIN_GROUP = 0xc + IPV6_LEAVE_GROUP = 0xd + IPV6_MAXHLIM = 0xff + IPV6_MAXOPTHDR = 0x800 + IPV6_MAXPACKET = 0xffff + IPV6_MAX_GROUP_SRC_FILTER = 0x200 + IPV6_MAX_MEMBERSHIPS = 0xfff + IPV6_MAX_SOCK_SRC_FILTER = 0x80 + IPV6_MIN_MEMBERSHIPS = 0x1f + IPV6_MMTU = 0x500 + IPV6_MULTICAST_HOPS = 0xa + IPV6_MULTICAST_IF = 0x9 + IPV6_MULTICAST_LOOP = 0xb + IPV6_PORTRANGE = 0xe + IPV6_PORTRANGE_DEFAULT = 0x0 + IPV6_PORTRANGE_HIGH = 0x1 + IPV6_PORTRANGE_LOW = 0x2 + IPV6_RECVTCLASS = 0x23 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_SOCKOPT_RESERVED1 = 0x3 + IPV6_TCLASS = 0x24 + IPV6_UNICAST_HOPS = 0x4 + IPV6_V6ONLY = 0x1b + IPV6_VERSION = 0x60 + IPV6_VERSION_MASK = 0xf0 + IP_ADD_MEMBERSHIP = 0xc + IP_ADD_SOURCE_MEMBERSHIP = 0x46 + IP_BLOCK_SOURCE = 0x48 + IP_BOUND_IF = 0x19 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DROP_MEMBERSHIP = 0xd + IP_DROP_SOURCE_MEMBERSHIP = 0x47 + IP_DUMMYNET_CONFIGURE = 0x3c + IP_DUMMYNET_DEL = 0x3d + IP_DUMMYNET_FLUSH = 0x3e + IP_DUMMYNET_GET = 0x40 + IP_FAITH = 0x16 + IP_FW_ADD = 0x28 + IP_FW_DEL = 0x29 + IP_FW_FLUSH = 0x2a + IP_FW_GET = 0x2c + IP_FW_RESETLOG = 0x2d + IP_FW_ZERO = 0x2b + IP_HDRINCL = 0x2 + IP_IPSEC_POLICY = 0x15 + IP_MAXPACKET = 0xffff + IP_MAX_GROUP_SRC_FILTER = 0x200 + IP_MAX_MEMBERSHIPS = 0xfff + IP_MAX_SOCK_MUTE_FILTER = 0x80 + IP_MAX_SOCK_SRC_FILTER = 0x80 + IP_MF = 0x2000 + IP_MIN_MEMBERSHIPS = 0x1f + IP_MSFILTER = 0x4a + IP_MSS = 0x240 + IP_MULTICAST_IF = 0x9 + IP_MULTICAST_IFINDEX = 0x42 + IP_MULTICAST_LOOP = 0xb + IP_MULTICAST_TTL = 0xa + IP_MULTICAST_VIF = 0xe + IP_NAT__XXX = 0x37 + IP_OFFMASK = 0x1fff + IP_OLD_FW_ADD = 0x32 + IP_OLD_FW_DEL = 0x33 + IP_OLD_FW_FLUSH = 0x34 + IP_OLD_FW_GET = 0x36 + IP_OLD_FW_RESETLOG = 0x38 + IP_OLD_FW_ZERO = 0x35 + IP_OPTIONS = 0x1 + IP_PKTINFO = 0x1a + IP_PORTRANGE = 0x13 + IP_PORTRANGE_DEFAULT = 0x0 + IP_PORTRANGE_HIGH = 0x1 + IP_PORTRANGE_LOW = 0x2 + IP_RECVDSTADDR = 0x7 + IP_RECVIF = 0x14 + IP_RECVOPTS = 0x5 + IP_RECVPKTINFO = 0x1a + IP_RECVRETOPTS = 0x6 + IP_RECVTTL = 0x18 + IP_RETOPTS = 0x8 + IP_RF = 0x8000 + IP_RSVP_OFF = 0x10 + IP_RSVP_ON = 0xf + IP_RSVP_VIF_OFF = 0x12 + IP_RSVP_VIF_ON = 0x11 + IP_STRIPHDR = 0x17 + IP_TOS = 0x3 + IP_TRAFFIC_MGT_BACKGROUND = 0x41 + IP_TTL = 0x4 + IP_UNBLOCK_SOURCE = 0x49 + ISIG = 0x80 + ISTRIP = 0x20 + IUTF8 = 0x4000 + IXANY = 0x800 + IXOFF = 0x400 + IXON = 0x200 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_CAN_REUSE = 0x9 + MADV_DONTNEED = 0x4 + MADV_FREE = 0x5 + MADV_FREE_REUSABLE = 0x7 + MADV_FREE_REUSE = 0x8 + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_SEQUENTIAL = 0x2 + MADV_WILLNEED = 0x3 + MADV_ZERO_WIRED_PAGES = 0x6 + MAP_ANON = 0x1000 + MAP_COPY = 0x2 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_HASSEMAPHORE = 0x200 + MAP_JIT = 0x800 + MAP_NOCACHE = 0x400 + MAP_NOEXTEND = 0x100 + MAP_NORESERVE = 0x40 + MAP_PRIVATE = 0x2 + MAP_RENAME = 0x20 + MAP_RESERVED0080 = 0x80 + MAP_SHARED = 0x1 + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MSG_CTRUNC = 0x20 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x80 + MSG_EOF = 0x100 + MSG_EOR = 0x8 + MSG_FLUSH = 0x400 + MSG_HAVEMORE = 0x2000 + MSG_HOLD = 0x800 + MSG_NEEDSA = 0x10000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_RCVMORE = 0x4000 + MSG_SEND = 0x1000 + MSG_TRUNC = 0x10 + MSG_WAITALL = 0x40 + MSG_WAITSTREAM = 0x200 + MS_ASYNC = 0x1 + MS_DEACTIVATE = 0x8 + MS_INVALIDATE = 0x2 + MS_KILLPAGES = 0x4 + MS_SYNC = 0x10 + NAME_MAX = 0xff + NET_RT_DUMP = 0x1 + NET_RT_DUMP2 = 0x7 + NET_RT_FLAGS = 0x2 + NET_RT_IFLIST = 0x3 + NET_RT_IFLIST2 = 0x6 + NET_RT_MAXID = 0xa + NET_RT_STAT = 0x4 + NET_RT_TRASH = 0x5 + NOFLSH = 0x80000000 + NOTE_ABSOLUTE = 0x8 + NOTE_ATTRIB = 0x8 + NOTE_BACKGROUND = 0x40 + NOTE_CHILD = 0x4 + NOTE_CRITICAL = 0x20 + NOTE_DELETE = 0x1 + NOTE_EXEC = 0x20000000 + NOTE_EXIT = 0x80000000 + NOTE_EXITSTATUS = 0x4000000 + NOTE_EXIT_CSERROR = 0x40000 + NOTE_EXIT_DECRYPTFAIL = 0x10000 + NOTE_EXIT_DETAIL = 0x2000000 + NOTE_EXIT_DETAIL_MASK = 0x70000 + NOTE_EXIT_MEMORY = 0x20000 + NOTE_EXIT_REPARENTED = 0x80000 + NOTE_EXTEND = 0x4 + NOTE_FFAND = 0x40000000 + NOTE_FFCOPY = 0xc0000000 + NOTE_FFCTRLMASK = 0xc0000000 + NOTE_FFLAGSMASK = 0xffffff + NOTE_FFNOP = 0x0 + NOTE_FFOR = 0x80000000 + NOTE_FORK = 0x40000000 + NOTE_LEEWAY = 0x10 + NOTE_LINK = 0x10 + NOTE_LOWAT = 0x1 + NOTE_NONE = 0x80 + NOTE_NSECONDS = 0x4 + NOTE_PCTRLMASK = -0x100000 + NOTE_PDATAMASK = 0xfffff + NOTE_REAP = 0x10000000 + NOTE_RENAME = 0x20 + NOTE_REVOKE = 0x40 + NOTE_SECONDS = 0x1 + NOTE_SIGNAL = 0x8000000 + NOTE_TRACK = 0x1 + NOTE_TRACKERR = 0x2 + NOTE_TRIGGER = 0x1000000 + NOTE_USECONDS = 0x2 + NOTE_VM_ERROR = 0x10000000 + NOTE_VM_PRESSURE = 0x80000000 + NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000 + NOTE_VM_PRESSURE_TERMINATE = 0x40000000 + NOTE_WRITE = 0x2 + OCRNL = 0x10 + OFDEL = 0x20000 + OFILL = 0x80 + ONLCR = 0x2 + ONLRET = 0x40 + ONOCR = 0x20 + ONOEOT = 0x8 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_ALERT = 0x20000000 + O_APPEND = 0x8 + O_ASYNC = 0x40 + O_CLOEXEC = 0x1000000 + O_CREAT = 0x200 + O_DIRECTORY = 0x100000 + O_DP_GETRAWENCRYPTED = 0x1 + O_DSYNC = 0x400000 + O_EVTONLY = 0x8000 + O_EXCL = 0x800 + O_EXLOCK = 0x20 + O_FSYNC = 0x80 + O_NDELAY = 0x4 + O_NOCTTY = 0x20000 + O_NOFOLLOW = 0x100 + O_NONBLOCK = 0x4 + O_POPUP = 0x80000000 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_SHLOCK = 0x10 + O_SYMLINK = 0x200000 + O_SYNC = 0x80 + O_TRUNC = 0x400 + O_WRONLY = 0x1 + PARENB = 0x1000 + PARMRK = 0x8 + PARODD = 0x2000 + PENDIN = 0x20000000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + PT_ATTACH = 0xa + PT_ATTACHEXC = 0xe + PT_CONTINUE = 0x7 + PT_DENY_ATTACH = 0x1f + PT_DETACH = 0xb + PT_FIRSTMACH = 0x20 + PT_FORCEQUOTA = 0x1e + PT_KILL = 0x8 + PT_READ_D = 0x2 + PT_READ_I = 0x1 + PT_READ_U = 0x3 + PT_SIGEXC = 0xc + PT_STEP = 0x9 + PT_THUPDATE = 0xd + PT_TRACE_ME = 0x0 + PT_WRITE_D = 0x5 + PT_WRITE_I = 0x4 + PT_WRITE_U = 0x6 + RLIMIT_AS = 0x5 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_CPU_USAGE_MONITOR = 0x2 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x8 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = 0x7fffffffffffffff + RTAX_AUTHOR = 0x6 + RTAX_BRD = 0x7 + RTAX_DST = 0x0 + RTAX_GATEWAY = 0x1 + RTAX_GENMASK = 0x3 + RTAX_IFA = 0x5 + RTAX_IFP = 0x4 + RTAX_MAX = 0x8 + RTAX_NETMASK = 0x2 + RTA_AUTHOR = 0x40 + RTA_BRD = 0x80 + RTA_DST = 0x1 + RTA_GATEWAY = 0x2 + RTA_GENMASK = 0x8 + RTA_IFA = 0x20 + RTA_IFP = 0x10 + RTA_NETMASK = 0x4 + RTF_BLACKHOLE = 0x1000 + RTF_BROADCAST = 0x400000 + RTF_CLONING = 0x100 + RTF_CONDEMNED = 0x2000000 + RTF_DELCLONE = 0x80 + RTF_DONE = 0x40 + RTF_DYNAMIC = 0x10 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_IFREF = 0x4000000 + RTF_IFSCOPE = 0x1000000 + RTF_LLINFO = 0x400 + RTF_LOCAL = 0x200000 + RTF_MODIFIED = 0x20 + RTF_MULTICAST = 0x800000 + RTF_PINNED = 0x100000 + RTF_PRCLONING = 0x10000 + RTF_PROTO1 = 0x8000 + RTF_PROTO2 = 0x4000 + RTF_PROTO3 = 0x40000 + RTF_PROXY = 0x8000000 + RTF_REJECT = 0x8 + RTF_ROUTER = 0x10000000 + RTF_STATIC = 0x800 + RTF_UP = 0x1 + RTF_WASCLONED = 0x20000 + RTF_XRESOLVE = 0x200 + RTM_ADD = 0x1 + RTM_CHANGE = 0x3 + RTM_DELADDR = 0xd + RTM_DELETE = 0x2 + RTM_DELMADDR = 0x10 + RTM_GET = 0x4 + RTM_GET2 = 0x14 + RTM_IFINFO = 0xe + RTM_IFINFO2 = 0x12 + RTM_LOCK = 0x8 + RTM_LOSING = 0x5 + RTM_MISS = 0x7 + RTM_NEWADDR = 0xc + RTM_NEWMADDR = 0xf + RTM_NEWMADDR2 = 0x13 + RTM_OLDADD = 0x9 + RTM_OLDDEL = 0xa + RTM_REDIRECT = 0x6 + RTM_RESOLVE = 0xb + RTM_RTTUNIT = 0xf4240 + RTM_VERSION = 0x5 + RTV_EXPIRE = 0x4 + RTV_HOPCOUNT = 0x2 + RTV_MTU = 0x1 + RTV_RPIPE = 0x8 + RTV_RTT = 0x40 + RTV_RTTVAR = 0x80 + RTV_SPIPE = 0x10 + RTV_SSTHRESH = 0x20 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + SCM_CREDS = 0x3 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x2 + SCM_TIMESTAMP_MONOTONIC = 0x4 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDMULTI = 0x80206931 + SIOCAIFADDR = 0x8040691a + SIOCARPIPLL = 0xc0206928 + SIOCATMARK = 0x40047307 + SIOCAUTOADDR = 0xc0206926 + SIOCAUTONETMASK = 0x80206927 + SIOCDELMULTI = 0x80206932 + SIOCDIFADDR = 0x80206919 + SIOCDIFPHYADDR = 0x80206941 + SIOCGDRVSPEC = 0xc028697b + SIOCGETVLAN = 0xc020697f + SIOCGHIWAT = 0x40047301 + SIOCGIFADDR = 0xc0206921 + SIOCGIFALTMTU = 0xc0206948 + SIOCGIFASYNCMAP = 0xc020697c + SIOCGIFBOND = 0xc0206947 + SIOCGIFBRDADDR = 0xc0206923 + SIOCGIFCAP = 0xc020695b + SIOCGIFCONF = 0xc00c6924 + SIOCGIFDEVMTU = 0xc0206944 + SIOCGIFDSTADDR = 0xc0206922 + SIOCGIFFLAGS = 0xc0206911 + SIOCGIFGENERIC = 0xc020693a + SIOCGIFKPI = 0xc0206987 + SIOCGIFMAC = 0xc0206982 + SIOCGIFMEDIA = 0xc02c6938 + SIOCGIFMETRIC = 0xc0206917 + SIOCGIFMTU = 0xc0206933 + SIOCGIFNETMASK = 0xc0206925 + SIOCGIFPDSTADDR = 0xc0206940 + SIOCGIFPHYS = 0xc0206935 + SIOCGIFPSRCADDR = 0xc020693f + SIOCGIFSTATUS = 0xc331693d + SIOCGIFVLAN = 0xc020697f + SIOCGIFWAKEFLAGS = 0xc0206988 + SIOCGLOWAT = 0x40047303 + SIOCGPGRP = 0x40047309 + SIOCIFCREATE = 0xc0206978 + SIOCIFCREATE2 = 0xc020697a + SIOCIFDESTROY = 0x80206979 + SIOCIFGCLONERS = 0xc0106981 + SIOCRSLVMULTI = 0xc010693b + SIOCSDRVSPEC = 0x8028697b + SIOCSETVLAN = 0x8020697e + SIOCSHIWAT = 0x80047300 + SIOCSIFADDR = 0x8020690c + SIOCSIFALTMTU = 0x80206945 + SIOCSIFASYNCMAP = 0x8020697d + SIOCSIFBOND = 0x80206946 + SIOCSIFBRDADDR = 0x80206913 + SIOCSIFCAP = 0x8020695a + SIOCSIFDSTADDR = 0x8020690e + SIOCSIFFLAGS = 0x80206910 + SIOCSIFGENERIC = 0x80206939 + SIOCSIFKPI = 0x80206986 + SIOCSIFLLADDR = 0x8020693c + SIOCSIFMAC = 0x80206983 + SIOCSIFMEDIA = 0xc0206937 + SIOCSIFMETRIC = 0x80206918 + SIOCSIFMTU = 0x80206934 + SIOCSIFNETMASK = 0x80206916 + SIOCSIFPHYADDR = 0x8040693e + SIOCSIFPHYS = 0x80206936 + SIOCSIFVLAN = 0x8020697e + SIOCSLOWAT = 0x80047302 + SIOCSPGRP = 0x80047308 + SOCK_DGRAM = 0x2 + SOCK_MAXADDRLEN = 0xff + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_SOCKET = 0xffff + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x2 + SO_BROADCAST = 0x20 + SO_DEBUG = 0x1 + SO_DONTROUTE = 0x10 + SO_DONTTRUNC = 0x2000 + SO_ERROR = 0x1007 + SO_KEEPALIVE = 0x8 + SO_LABEL = 0x1010 + SO_LINGER = 0x80 + SO_LINGER_SEC = 0x1080 + SO_NKE = 0x1021 + SO_NOADDRERR = 0x1023 + SO_NOSIGPIPE = 0x1022 + SO_NOTIFYCONFLICT = 0x1026 + SO_NP_EXTENSIONS = 0x1083 + SO_NREAD = 0x1020 + SO_NUMRCVPKT = 0x1112 + SO_NWRITE = 0x1024 + SO_OOBINLINE = 0x100 + SO_PEERLABEL = 0x1011 + SO_RANDOMPORT = 0x1082 + SO_RCVBUF = 0x1002 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x1006 + SO_REUSEADDR = 0x4 + SO_REUSEPORT = 0x200 + SO_REUSESHAREUID = 0x1025 + SO_SNDBUF = 0x1001 + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x1005 + SO_TIMESTAMP = 0x400 + SO_TIMESTAMP_MONOTONIC = 0x800 + SO_TYPE = 0x1008 + SO_UPCALLCLOSEWAIT = 0x1027 + SO_USELOOPBACK = 0x40 + SO_WANTMORE = 0x4000 + SO_WANTOOBFLAG = 0x8000 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IFWHT = 0xe000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISTXT = 0x200 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + TCIFLUSH = 0x1 + TCIOFLUSH = 0x3 + TCOFLUSH = 0x2 + TCP_CONNECTIONTIMEOUT = 0x20 + TCP_ENABLE_ECN = 0x104 + TCP_KEEPALIVE = 0x10 + TCP_KEEPCNT = 0x102 + TCP_KEEPINTVL = 0x101 + TCP_MAXHLEN = 0x3c + TCP_MAXOLEN = 0x28 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_SACK = 0x4 + TCP_MAX_WINSHIFT = 0xe + TCP_MINMSS = 0xd8 + TCP_MSS = 0x200 + TCP_NODELAY = 0x1 + TCP_NOOPT = 0x8 + TCP_NOPUSH = 0x4 + TCP_NOTSENT_LOWAT = 0x201 + TCP_RXT_CONNDROPTIME = 0x80 + TCP_RXT_FINDROP = 0x100 + TCP_SENDMOREACKS = 0x103 + TCSAFLUSH = 0x2 + TIOCCBRK = 0x2000747a + TIOCCDTR = 0x20007478 + TIOCCONS = 0x80047462 + TIOCDCDTIMESTAMP = 0x40107458 + TIOCDRAIN = 0x2000745e + TIOCDSIMICROCODE = 0x20007455 + TIOCEXCL = 0x2000740d + TIOCEXT = 0x80047460 + TIOCFLUSH = 0x80047410 + TIOCGDRAINWAIT = 0x40047456 + TIOCGETA = 0x40487413 + TIOCGETD = 0x4004741a + TIOCGPGRP = 0x40047477 + TIOCGWINSZ = 0x40087468 + TIOCIXOFF = 0x20007480 + TIOCIXON = 0x20007481 + TIOCMBIC = 0x8004746b + TIOCMBIS = 0x8004746c + TIOCMGDTRWAIT = 0x4004745a + TIOCMGET = 0x4004746a + TIOCMODG = 0x40047403 + TIOCMODS = 0x80047404 + TIOCMSDTRWAIT = 0x8004745b + TIOCMSET = 0x8004746d + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x20007471 + TIOCNXCL = 0x2000740e + TIOCOUTQ = 0x40047473 + TIOCPKT = 0x80047470 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCPTYGNAME = 0x40807453 + TIOCPTYGRANT = 0x20007454 + TIOCPTYUNLK = 0x20007452 + TIOCREMOTE = 0x80047469 + TIOCSBRK = 0x2000747b + TIOCSCONS = 0x20007463 + TIOCSCTTY = 0x20007461 + TIOCSDRAINWAIT = 0x80047457 + TIOCSDTR = 0x20007479 + TIOCSETA = 0x80487414 + TIOCSETAF = 0x80487416 + TIOCSETAW = 0x80487415 + TIOCSETD = 0x8004741b + TIOCSIG = 0x2000745f + TIOCSPGRP = 0x80047476 + TIOCSTART = 0x2000746e + TIOCSTAT = 0x20007465 + TIOCSTI = 0x80017472 + TIOCSTOP = 0x2000746f + TIOCSWINSZ = 0x80087467 + TIOCTIMESTAMP = 0x40107459 + TIOCUCNTL = 0x80047466 + TOSTOP = 0x400000 + VDISCARD = 0xf + VDSUSP = 0xb + VEOF = 0x0 + VEOL = 0x1 + VEOL2 = 0x2 + VERASE = 0x3 + VINTR = 0x8 + VKILL = 0x5 + VLNEXT = 0xe + VMIN = 0x10 + VQUIT = 0x9 + VREPRINT = 0x6 + VSTART = 0xc + VSTATUS = 0x12 + VSTOP = 0xd + VSUSP = 0xa + VT0 = 0x0 + VT1 = 0x10000 + VTDLY = 0x10000 + VTIME = 0x11 + VWERASE = 0x4 + WCONTINUED = 0x10 + WCOREFLAG = 0x80 + WEXITED = 0x4 + WNOHANG = 0x1 + WNOWAIT = 0x20 + WORDSIZE = 0x40 + WSTOPPED = 0x8 + WUNTRACED = 0x2 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x30) + EADDRNOTAVAIL = syscall.Errno(0x31) + EAFNOSUPPORT = syscall.Errno(0x2f) + EAGAIN = syscall.Errno(0x23) + EALREADY = syscall.Errno(0x25) + EAUTH = syscall.Errno(0x50) + EBADARCH = syscall.Errno(0x56) + EBADEXEC = syscall.Errno(0x55) + EBADF = syscall.Errno(0x9) + EBADMACHO = syscall.Errno(0x58) + EBADMSG = syscall.Errno(0x5e) + EBADRPC = syscall.Errno(0x48) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x59) + ECHILD = syscall.Errno(0xa) + ECONNABORTED = syscall.Errno(0x35) + ECONNREFUSED = syscall.Errno(0x3d) + ECONNRESET = syscall.Errno(0x36) + EDEADLK = syscall.Errno(0xb) + EDESTADDRREQ = syscall.Errno(0x27) + EDEVERR = syscall.Errno(0x53) + EDOM = syscall.Errno(0x21) + EDQUOT = syscall.Errno(0x45) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EFTYPE = syscall.Errno(0x4f) + EHOSTDOWN = syscall.Errno(0x40) + EHOSTUNREACH = syscall.Errno(0x41) + EIDRM = syscall.Errno(0x5a) + EILSEQ = syscall.Errno(0x5c) + EINPROGRESS = syscall.Errno(0x24) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x38) + EISDIR = syscall.Errno(0x15) + ELAST = syscall.Errno(0x6a) + ELOOP = syscall.Errno(0x3e) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x28) + EMULTIHOP = syscall.Errno(0x5f) + ENAMETOOLONG = syscall.Errno(0x3f) + ENEEDAUTH = syscall.Errno(0x51) + ENETDOWN = syscall.Errno(0x32) + ENETRESET = syscall.Errno(0x34) + ENETUNREACH = syscall.Errno(0x33) + ENFILE = syscall.Errno(0x17) + ENOATTR = syscall.Errno(0x5d) + ENOBUFS = syscall.Errno(0x37) + ENODATA = syscall.Errno(0x60) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOLCK = syscall.Errno(0x4d) + ENOLINK = syscall.Errno(0x61) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x5b) + ENOPOLICY = syscall.Errno(0x67) + ENOPROTOOPT = syscall.Errno(0x2a) + ENOSPC = syscall.Errno(0x1c) + ENOSR = syscall.Errno(0x62) + ENOSTR = syscall.Errno(0x63) + ENOSYS = syscall.Errno(0x4e) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x39) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x42) + ENOTRECOVERABLE = syscall.Errno(0x68) + ENOTSOCK = syscall.Errno(0x26) + ENOTSUP = syscall.Errno(0x2d) + ENOTTY = syscall.Errno(0x19) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x66) + EOVERFLOW = syscall.Errno(0x54) + EOWNERDEAD = syscall.Errno(0x69) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x2e) + EPIPE = syscall.Errno(0x20) + EPROCLIM = syscall.Errno(0x43) + EPROCUNAVAIL = syscall.Errno(0x4c) + EPROGMISMATCH = syscall.Errno(0x4b) + EPROGUNAVAIL = syscall.Errno(0x4a) + EPROTO = syscall.Errno(0x64) + EPROTONOSUPPORT = syscall.Errno(0x2b) + EPROTOTYPE = syscall.Errno(0x29) + EPWROFF = syscall.Errno(0x52) + EQFULL = syscall.Errno(0x6a) + ERANGE = syscall.Errno(0x22) + EREMOTE = syscall.Errno(0x47) + EROFS = syscall.Errno(0x1e) + ERPCMISMATCH = syscall.Errno(0x49) + ESHLIBVERS = syscall.Errno(0x57) + ESHUTDOWN = syscall.Errno(0x3a) + ESOCKTNOSUPPORT = syscall.Errno(0x2c) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESTALE = syscall.Errno(0x46) + ETIME = syscall.Errno(0x65) + ETIMEDOUT = syscall.Errno(0x3c) + ETOOMANYREFS = syscall.Errno(0x3b) + ETXTBSY = syscall.Errno(0x1a) + EUSERS = syscall.Errno(0x44) + EWOULDBLOCK = syscall.Errno(0x23) + EXDEV = syscall.Errno(0x12) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0xa) + SIGCHLD = syscall.Signal(0x14) + SIGCONT = syscall.Signal(0x13) + SIGEMT = syscall.Signal(0x7) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINFO = syscall.Signal(0x1d) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x17) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPROF = syscall.Signal(0x1b) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTOP = syscall.Signal(0x11) + SIGSYS = syscall.Signal(0xc) + SIGTERM = syscall.Signal(0xf) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x12) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGURG = syscall.Signal(0x10) + SIGUSR1 = syscall.Signal(0x1e) + SIGUSR2 = syscall.Signal(0x1f) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_dragonfly_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_darwin_arm64.go similarity index 66% rename from Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_dragonfly_386.go rename to Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_darwin_arm64.go index 85988c0eaf..3189c6b345 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_dragonfly_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_darwin_arm64.go @@ -1,8 +1,10 @@ -// mkerrors.sh -m32 +// mkerrors.sh -m64 // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build arm64,darwin + // Created by cgo -godefs - DO NOT EDIT -// cgo -godefs -- -m32 _const.go +// cgo -godefs -- -m64 _const.go package unix @@ -10,8 +12,6 @@ import "syscall" const ( AF_APPLETALK = 0x10 - AF_ATM = 0x1e - AF_BLUETOOTH = 0x21 AF_CCITT = 0xa AF_CHAOS = 0x5 AF_CNT = 0x15 @@ -19,31 +19,35 @@ const ( AF_DATAKIT = 0x9 AF_DECnet = 0xc AF_DLI = 0xd - AF_E164 = 0x1a + AF_E164 = 0x1c AF_ECMA = 0x8 AF_HYLINK = 0xf - AF_IEEE80211 = 0x23 + AF_IEEE80211 = 0x25 AF_IMPLINK = 0x3 AF_INET = 0x2 - AF_INET6 = 0x1c + AF_INET6 = 0x1e AF_IPX = 0x17 - AF_ISDN = 0x1a + AF_ISDN = 0x1c AF_ISO = 0x7 AF_LAT = 0xe AF_LINK = 0x12 AF_LOCAL = 0x1 - AF_MAX = 0x24 - AF_MPLS = 0x22 - AF_NATM = 0x1d - AF_NETGRAPH = 0x20 + AF_MAX = 0x28 + AF_NATM = 0x1f + AF_NDRV = 0x1b + AF_NETBIOS = 0x21 AF_NS = 0x6 AF_OSI = 0x7 + AF_PPP = 0x22 AF_PUP = 0x4 + AF_RESERVED_36 = 0x24 AF_ROUTE = 0x11 AF_SIP = 0x18 AF_SNA = 0xb + AF_SYSTEM = 0x20 AF_UNIX = 0x1 AF_UNSPEC = 0x0 + AF_UTUN = 0x26 B0 = 0x0 B110 = 0x6e B115200 = 0x1c200 @@ -70,24 +74,23 @@ const ( BIOCFLUSH = 0x20004268 BIOCGBLEN = 0x40044266 BIOCGDLT = 0x4004426a - BIOCGDLTLIST = 0xc0084279 + BIOCGDLTLIST = 0xc00c4279 BIOCGETIF = 0x4020426b BIOCGHDRCMPLT = 0x40044274 BIOCGRSIG = 0x40044272 - BIOCGRTIMEOUT = 0x4008426e + BIOCGRTIMEOUT = 0x4010426e BIOCGSEESENT = 0x40044276 BIOCGSTATS = 0x4008426f BIOCIMMEDIATE = 0x80044270 - BIOCLOCK = 0x2000427a BIOCPROMISC = 0x20004269 BIOCSBLEN = 0xc0044266 BIOCSDLT = 0x80044278 - BIOCSETF = 0x80084267 + BIOCSETF = 0x80104267 + BIOCSETFNR = 0x8010427e BIOCSETIF = 0x8020426c - BIOCSETWF = 0x8008427b BIOCSHDRCMPLT = 0x80044275 BIOCSRSIG = 0x80044273 - BIOCSRTIMEOUT = 0x8008426d + BIOCSRTIMEOUT = 0x8010426d BIOCSSEESENT = 0x80044277 BIOCVERSION = 0x40044271 BPF_A = 0x10 @@ -97,7 +100,6 @@ const ( BPF_ALU = 0x4 BPF_AND = 0x50 BPF_B = 0x10 - BPF_DEFAULTBUFSIZE = 0x1000 BPF_DIV = 0x30 BPF_H = 0x8 BPF_IMM = 0x0 @@ -116,7 +118,6 @@ const ( BPF_MAJOR_VERSION = 0x1 BPF_MAXBUFSIZE = 0x80000 BPF_MAXINSNS = 0x200 - BPF_MAX_CLONES = 0x80 BPF_MEM = 0x60 BPF_MEMWORDS = 0x10 BPF_MINBUFSIZE = 0x20 @@ -155,6 +156,7 @@ const ( DLT_A429 = 0xb8 DLT_A653_ICM = 0xb9 DLT_AIRONET_HEADER = 0x78 + DLT_AOS = 0xde DLT_APPLE_IP_OVER_IEEE1394 = 0x8a DLT_ARCNET = 0x7 DLT_ARCNET_LINUX = 0x81 @@ -167,12 +169,16 @@ const ( DLT_BLUETOOTH_HCI_H4 = 0xbb DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9 DLT_CAN20B = 0xbe + DLT_CAN_SOCKETCAN = 0xe3 DLT_CHAOS = 0x5 DLT_CHDLC = 0x68 DLT_CISCO_IOS = 0x76 DLT_C_HDLC = 0x68 DLT_C_HDLC_WITH_DIR = 0xcd + DLT_DBUS = 0xe7 + DLT_DECT = 0xdd DLT_DOCSIS = 0x8f + DLT_DVB_CI = 0xeb DLT_ECONET = 0x73 DLT_EN10MB = 0x1 DLT_EN3MB = 0x2 @@ -180,6 +186,8 @@ const ( DLT_ERF = 0xc5 DLT_ERF_ETH = 0xaf DLT_ERF_POS = 0xb0 + DLT_FC_2 = 0xe0 + DLT_FC_2_WITH_FRAME_DELIMS = 0xe1 DLT_FDDI = 0xa DLT_FLEXRAY = 0xd2 DLT_FRELAY = 0x6b @@ -189,6 +197,8 @@ const ( DLT_GPF_F = 0xab DLT_GPF_T = 0xaa DLT_GPRS_LLC = 0xa9 + DLT_GSMTAP_ABIS = 0xda + DLT_GSMTAP_UM = 0xd9 DLT_HHDLC = 0x79 DLT_IBM_SN = 0x92 DLT_IBM_SP = 0x91 @@ -198,18 +208,25 @@ const ( DLT_IEEE802_11_RADIO_AVS = 0xa3 DLT_IEEE802_15_4 = 0xc3 DLT_IEEE802_15_4_LINUX = 0xbf + DLT_IEEE802_15_4_NOFCS = 0xe6 DLT_IEEE802_15_4_NONASK_PHY = 0xd7 DLT_IEEE802_16_MAC_CPS = 0xbc DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1 DLT_IPFILTER = 0x74 DLT_IPMB = 0xc7 DLT_IPMB_LINUX = 0xd1 + DLT_IPNET = 0xe2 + DLT_IPOIB = 0xf2 + DLT_IPV4 = 0xe4 + DLT_IPV6 = 0xe5 DLT_IP_OVER_FC = 0x7a DLT_JUNIPER_ATM1 = 0x89 DLT_JUNIPER_ATM2 = 0x87 + DLT_JUNIPER_ATM_CEMIC = 0xee DLT_JUNIPER_CHDLC = 0xb5 DLT_JUNIPER_ES = 0x84 DLT_JUNIPER_ETHER = 0xb2 + DLT_JUNIPER_FIBRECHANNEL = 0xea DLT_JUNIPER_FRELAY = 0xb4 DLT_JUNIPER_GGSN = 0x85 DLT_JUNIPER_ISM = 0xc2 @@ -222,21 +239,35 @@ const ( DLT_JUNIPER_PPPOE = 0xa7 DLT_JUNIPER_PPPOE_ATM = 0xa8 DLT_JUNIPER_SERVICES = 0x88 + DLT_JUNIPER_SRX_E2E = 0xe9 DLT_JUNIPER_ST = 0xc8 DLT_JUNIPER_VP = 0xb7 + DLT_JUNIPER_VS = 0xe8 DLT_LAPB_WITH_DIR = 0xcf DLT_LAPD = 0xcb DLT_LIN = 0xd4 + DLT_LINUX_EVDEV = 0xd8 DLT_LINUX_IRDA = 0x90 DLT_LINUX_LAPD = 0xb1 + DLT_LINUX_PPP_WITHDIRECTION = 0xa6 DLT_LINUX_SLL = 0x71 DLT_LOOP = 0x6c DLT_LTALK = 0x72 + DLT_MATCHING_MAX = 0xf5 + DLT_MATCHING_MIN = 0x68 DLT_MFR = 0xb6 DLT_MOST = 0xd3 + DLT_MPEG_2_TS = 0xf3 + DLT_MPLS = 0xdb DLT_MTP2 = 0x8c DLT_MTP2_WITH_PHDR = 0x8b DLT_MTP3 = 0x8d + DLT_MUX27010 = 0xec + DLT_NETANALYZER = 0xf0 + DLT_NETANALYZER_TRANSPARENT = 0xf1 + DLT_NFC_LLCP = 0xf5 + DLT_NFLOG = 0xef + DLT_NG40 = 0xf4 DLT_NULL = 0x0 DLT_PCI_EXP = 0x7d DLT_PFLOG = 0x75 @@ -248,26 +279,44 @@ const ( DLT_PPP_PPPD = 0xa6 DLT_PPP_SERIAL = 0x32 DLT_PPP_WITH_DIR = 0xcc + DLT_PPP_WITH_DIRECTION = 0xa6 DLT_PRISM_HEADER = 0x77 DLT_PRONET = 0x4 DLT_RAIF1 = 0xc6 DLT_RAW = 0xc - DLT_REDBACK_SMARTEDGE = 0x20 DLT_RIO = 0x7c DLT_SCCP = 0x8e DLT_SITA = 0xc4 DLT_SLIP = 0x8 DLT_SLIP_BSDOS = 0xf + DLT_STANAG_5066_D_PDU = 0xed DLT_SUNATM = 0x7b DLT_SYMANTEC_FIREWALL = 0x63 DLT_TZSP = 0x80 DLT_USB = 0xba DLT_USB_LINUX = 0xbd + DLT_USB_LINUX_MMAPPED = 0xdc + DLT_USER0 = 0x93 + DLT_USER1 = 0x94 + DLT_USER10 = 0x9d + DLT_USER11 = 0x9e + DLT_USER12 = 0x9f + DLT_USER13 = 0xa0 + DLT_USER14 = 0xa1 + DLT_USER15 = 0xa2 + DLT_USER2 = 0x95 + DLT_USER3 = 0x96 + DLT_USER4 = 0x97 + DLT_USER5 = 0x98 + DLT_USER6 = 0x99 + DLT_USER7 = 0x9a + DLT_USER8 = 0x9b + DLT_USER9 = 0x9c + DLT_WIHART = 0xdf DLT_X2E_SERIAL = 0xd5 DLT_X2E_XORAYA = 0xd6 DT_BLK = 0x6 DT_CHR = 0x2 - DT_DBF = 0xf DT_DIR = 0x4 DT_FIFO = 0x1 DT_LNK = 0xa @@ -283,289 +332,178 @@ const ( ECHONL = 0x10 ECHOPRT = 0x20 EVFILT_AIO = -0x3 - EVFILT_EXCEPT = -0x8 - EVFILT_MARKER = 0xf + EVFILT_FS = -0x9 + EVFILT_MACHPORT = -0x8 EVFILT_PROC = -0x5 EVFILT_READ = -0x1 EVFILT_SIGNAL = -0x6 - EVFILT_SYSCOUNT = 0x8 + EVFILT_SYSCOUNT = 0xe + EVFILT_THREADMARKER = 0xe EVFILT_TIMER = -0x7 + EVFILT_USER = -0xa + EVFILT_VM = -0xc EVFILT_VNODE = -0x4 EVFILT_WRITE = -0x2 EV_ADD = 0x1 EV_CLEAR = 0x20 EV_DELETE = 0x2 EV_DISABLE = 0x8 + EV_DISPATCH = 0x80 EV_ENABLE = 0x4 EV_EOF = 0x8000 EV_ERROR = 0x4000 + EV_FLAG0 = 0x1000 EV_FLAG1 = 0x2000 - EV_NODATA = 0x1000 EV_ONESHOT = 0x10 + EV_OOBAND = 0x2000 + EV_POLL = 0x1000 + EV_RECEIPT = 0x40 EV_SYSFLAGS = 0xf000 EXTA = 0x4b00 EXTB = 0x9600 - EXTEXIT_LWP = 0x10000 - EXTEXIT_PROC = 0x0 - EXTEXIT_SETINT = 0x1 - EXTEXIT_SIMPLE = 0x0 EXTPROC = 0x800 FD_CLOEXEC = 0x1 FD_SETSIZE = 0x400 FLUSHO = 0x800000 - F_DUP2FD = 0xa - F_DUP2FD_CLOEXEC = 0x12 + F_ADDFILESIGS = 0x3d + F_ADDSIGS = 0x3b + F_ALLOCATEALL = 0x4 + F_ALLOCATECONTIG = 0x2 + F_CHKCLEAN = 0x29 F_DUPFD = 0x0 - F_DUPFD_CLOEXEC = 0x11 + F_DUPFD_CLOEXEC = 0x43 + F_FINDSIGS = 0x4e + F_FLUSH_DATA = 0x28 + F_FREEZE_FS = 0x35 + F_FULLFSYNC = 0x33 + F_GETCODEDIR = 0x48 F_GETFD = 0x1 F_GETFL = 0x3 F_GETLK = 0x7 + F_GETLKPID = 0x42 + F_GETNOSIGPIPE = 0x4a F_GETOWN = 0x5 + F_GETPATH = 0x32 + F_GETPATH_MTMINFO = 0x47 + F_GETPROTECTIONCLASS = 0x3f + F_GETPROTECTIONLEVEL = 0x4d + F_GLOBAL_NOCACHE = 0x37 + F_LOG2PHYS = 0x31 + F_LOG2PHYS_EXT = 0x41 + F_NOCACHE = 0x30 + F_NODIRECT = 0x3e F_OK = 0x0 + F_PATHPKG_CHECK = 0x34 + F_PEOFPOSMODE = 0x3 + F_PREALLOCATE = 0x2a + F_RDADVISE = 0x2c + F_RDAHEAD = 0x2d F_RDLCK = 0x1 + F_SETBACKINGSTORE = 0x46 F_SETFD = 0x2 F_SETFL = 0x4 F_SETLK = 0x8 F_SETLKW = 0x9 + F_SETLKWTIMEOUT = 0xa + F_SETNOSIGPIPE = 0x49 F_SETOWN = 0x6 + F_SETPROTECTIONCLASS = 0x40 + F_SETSIZE = 0x2b + F_SINGLE_WRITER = 0x4c + F_THAW_FS = 0x36 + F_TRANSCODEKEY = 0x4b F_UNLCK = 0x2 + F_VOLPOSMODE = 0x4 F_WRLCK = 0x3 HUPCL = 0x4000 ICANON = 0x100 ICMP6_FILTER = 0x12 ICRNL = 0x100 IEXTEN = 0x400 - IFAN_ARRIVAL = 0x0 - IFAN_DEPARTURE = 0x1 IFF_ALLMULTI = 0x200 IFF_ALTPHYS = 0x4000 IFF_BROADCAST = 0x2 - IFF_CANTCHANGE = 0x118e72 IFF_DEBUG = 0x4 IFF_LINK0 = 0x1000 IFF_LINK1 = 0x2000 IFF_LINK2 = 0x4000 IFF_LOOPBACK = 0x8 - IFF_MONITOR = 0x40000 IFF_MULTICAST = 0x8000 IFF_NOARP = 0x80 - IFF_NPOLLING = 0x100000 + IFF_NOTRAILERS = 0x20 IFF_OACTIVE = 0x400 - IFF_OACTIVE_COMPAT = 0x400 IFF_POINTOPOINT = 0x10 - IFF_POLLING = 0x10000 - IFF_POLLING_COMPAT = 0x10000 - IFF_PPROMISC = 0x20000 IFF_PROMISC = 0x100 IFF_RUNNING = 0x40 IFF_SIMPLEX = 0x800 - IFF_SMART = 0x20 - IFF_STATICARP = 0x80000 IFF_UP = 0x1 IFNAMSIZ = 0x10 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_BRIDGE = 0xd1 - IFT_BSC = 0x53 IFT_CARP = 0xf8 - IFT_CCTEMUL = 0x3d + IFT_CELLULAR = 0xff 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_FAITH = 0x38 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_GIF = 0x37 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_IEEE1394 = 0x90 - 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_ISDN = 0x3f + IFT_IEEE8023ADLAG = 0x88 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_L2VLAN = 0x87 - IFT_L3IPVLAN = 0x88 - 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_PDP = 0xff IFT_PFLOG = 0xf5 IFT_PFSYNC = 0xf6 - IFT_PLC = 0xae - IFT_POS = 0xab + IFT_PKTAP = 0xfe IFT_PPP = 0x17 - IFT_PPPMULTILINKBUNDLE = 0x6c - IFT_PROPBWAP2MP = 0xb8 - IFT_PROPCNLS = 0x59 - IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5 - IFT_PROPDOCSWIRELESSMACLAYER = 0xb4 - IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6 IFT_PROPMUX = 0x36 IFT_PROPVIRTUAL = 0x35 - 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 = 0xf3 + IFT_STF = 0x39 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 IGNBRK = 0x1 @@ -588,6 +526,7 @@ const ( IN_CLASSD_HOST = 0xfffffff IN_CLASSD_NET = 0xf0000000 IN_CLASSD_NSHIFT = 0x1c + IN_LINKLOCALNETNUM = 0xa9fe0000 IN_LOOPBACKNET = 0x7f IPPROTO_3PC = 0x22 IPPROTO_ADFS = 0x44 @@ -599,7 +538,6 @@ const ( IPPROTO_BHA = 0x31 IPPROTO_BLT = 0x1e IPPROTO_BRSATMON = 0x4c - IPPROTO_CARP = 0x70 IPPROTO_CFTP = 0x3e IPPROTO_CHAOS = 0x10 IPPROTO_CMTP = 0x26 @@ -652,7 +590,6 @@ const ( IPPROTO_MEAS = 0x13 IPPROTO_MHRP = 0x30 IPPROTO_MICP = 0x5f - IPPROTO_MOBILE = 0x37 IPPROTO_MTP = 0x5c IPPROTO_MUX = 0x12 IPPROTO_ND = 0x4d @@ -661,7 +598,6 @@ const ( IPPROTO_NSP = 0x1f IPPROTO_NVPII = 0xb IPPROTO_OSPFIGP = 0x59 - IPPROTO_PFSYNC = 0xf0 IPPROTO_PGM = 0x71 IPPROTO_PIGP = 0x9 IPPROTO_PIM = 0x67 @@ -680,21 +616,18 @@ const ( IPPROTO_SCTP = 0x84 IPPROTO_SDRP = 0x2a IPPROTO_SEP = 0x21 - IPPROTO_SKIP = 0x39 IPPROTO_SRPC = 0x5a IPPROTO_ST = 0x7 IPPROTO_SVMTP = 0x52 IPPROTO_SWIPE = 0x35 IPPROTO_TCF = 0x57 IPPROTO_TCP = 0x6 - IPPROTO_TLSP = 0x38 IPPROTO_TP = 0x1d IPPROTO_TPXX = 0x27 IPPROTO_TRUNK1 = 0x17 IPPROTO_TRUNK2 = 0x18 IPPROTO_TTP = 0x54 IPPROTO_UDP = 0x11 - IPPROTO_UNKNOWN = 0x102 IPPROTO_VINES = 0x53 IPPROTO_VISA = 0x46 IPPROTO_VMTP = 0x51 @@ -703,93 +636,103 @@ const ( IPPROTO_WSN = 0x4a IPPROTO_XNET = 0xf IPPROTO_XTP = 0x24 - IPV6_AUTOFLOWLABEL = 0x3b + IPV6_2292DSTOPTS = 0x17 + IPV6_2292HOPLIMIT = 0x14 + IPV6_2292HOPOPTS = 0x16 + IPV6_2292NEXTHOP = 0x15 + IPV6_2292PKTINFO = 0x13 + IPV6_2292PKTOPTIONS = 0x19 + IPV6_2292RTHDR = 0x18 IPV6_BINDV6ONLY = 0x1b + IPV6_BOUND_IF = 0x7d IPV6_CHECKSUM = 0x1a IPV6_DEFAULT_MULTICAST_HOPS = 0x1 IPV6_DEFAULT_MULTICAST_LOOP = 0x1 IPV6_DEFHLIM = 0x40 - IPV6_DONTFRAG = 0x3e - IPV6_DSTOPTS = 0x32 IPV6_FAITH = 0x1d IPV6_FLOWINFO_MASK = 0xffffff0f IPV6_FLOWLABEL_MASK = 0xffff0f00 - IPV6_FRAGTTL = 0x78 + IPV6_FRAGTTL = 0x3c IPV6_FW_ADD = 0x1e IPV6_FW_DEL = 0x1f IPV6_FW_FLUSH = 0x20 IPV6_FW_GET = 0x22 IPV6_FW_ZERO = 0x21 IPV6_HLIMDEC = 0x1 - IPV6_HOPLIMIT = 0x2f - IPV6_HOPOPTS = 0x31 IPV6_IPSEC_POLICY = 0x1c IPV6_JOIN_GROUP = 0xc IPV6_LEAVE_GROUP = 0xd IPV6_MAXHLIM = 0xff + IPV6_MAXOPTHDR = 0x800 IPV6_MAXPACKET = 0xffff + IPV6_MAX_GROUP_SRC_FILTER = 0x200 + IPV6_MAX_MEMBERSHIPS = 0xfff + IPV6_MAX_SOCK_SRC_FILTER = 0x80 + IPV6_MIN_MEMBERSHIPS = 0x1f IPV6_MMTU = 0x500 - IPV6_MSFILTER = 0x4a IPV6_MULTICAST_HOPS = 0xa IPV6_MULTICAST_IF = 0x9 IPV6_MULTICAST_LOOP = 0xb - IPV6_NEXTHOP = 0x30 - IPV6_PATHMTU = 0x2c - IPV6_PKTINFO = 0x2e - IPV6_PKTOPTIONS = 0x34 IPV6_PORTRANGE = 0xe IPV6_PORTRANGE_DEFAULT = 0x0 IPV6_PORTRANGE_HIGH = 0x1 IPV6_PORTRANGE_LOW = 0x2 - IPV6_PREFER_TEMPADDR = 0x3f - IPV6_RECVDSTOPTS = 0x28 - IPV6_RECVHOPLIMIT = 0x25 - IPV6_RECVHOPOPTS = 0x27 - IPV6_RECVPATHMTU = 0x2b - IPV6_RECVPKTINFO = 0x24 - IPV6_RECVRTHDR = 0x26 - IPV6_RECVTCLASS = 0x39 - IPV6_RTHDR = 0x33 - IPV6_RTHDRDSTOPTS = 0x23 + IPV6_RECVTCLASS = 0x23 IPV6_RTHDR_LOOSE = 0x0 IPV6_RTHDR_STRICT = 0x1 IPV6_RTHDR_TYPE_0 = 0x0 IPV6_SOCKOPT_RESERVED1 = 0x3 - IPV6_TCLASS = 0x3d + IPV6_TCLASS = 0x24 IPV6_UNICAST_HOPS = 0x4 - IPV6_USE_MIN_MTU = 0x2a IPV6_V6ONLY = 0x1b IPV6_VERSION = 0x60 IPV6_VERSION_MASK = 0xf0 IP_ADD_MEMBERSHIP = 0xc + IP_ADD_SOURCE_MEMBERSHIP = 0x46 + IP_BLOCK_SOURCE = 0x48 + IP_BOUND_IF = 0x19 IP_DEFAULT_MULTICAST_LOOP = 0x1 IP_DEFAULT_MULTICAST_TTL = 0x1 IP_DF = 0x4000 IP_DROP_MEMBERSHIP = 0xd + IP_DROP_SOURCE_MEMBERSHIP = 0x47 IP_DUMMYNET_CONFIGURE = 0x3c IP_DUMMYNET_DEL = 0x3d IP_DUMMYNET_FLUSH = 0x3e IP_DUMMYNET_GET = 0x40 IP_FAITH = 0x16 - IP_FW_ADD = 0x32 - IP_FW_DEL = 0x33 - IP_FW_FLUSH = 0x34 - IP_FW_GET = 0x36 - IP_FW_RESETLOG = 0x37 - IP_FW_ZERO = 0x35 + IP_FW_ADD = 0x28 + IP_FW_DEL = 0x29 + IP_FW_FLUSH = 0x2a + IP_FW_GET = 0x2c + IP_FW_RESETLOG = 0x2d + IP_FW_ZERO = 0x2b IP_HDRINCL = 0x2 IP_IPSEC_POLICY = 0x15 IP_MAXPACKET = 0xffff - IP_MAX_MEMBERSHIPS = 0x14 + IP_MAX_GROUP_SRC_FILTER = 0x200 + IP_MAX_MEMBERSHIPS = 0xfff + IP_MAX_SOCK_MUTE_FILTER = 0x80 + IP_MAX_SOCK_SRC_FILTER = 0x80 IP_MF = 0x2000 - IP_MINTTL = 0x42 + IP_MIN_MEMBERSHIPS = 0x1f + IP_MSFILTER = 0x4a IP_MSS = 0x240 IP_MULTICAST_IF = 0x9 + IP_MULTICAST_IFINDEX = 0x42 IP_MULTICAST_LOOP = 0xb IP_MULTICAST_TTL = 0xa IP_MULTICAST_VIF = 0xe + IP_NAT__XXX = 0x37 IP_OFFMASK = 0x1fff + IP_OLD_FW_ADD = 0x32 + IP_OLD_FW_DEL = 0x33 + IP_OLD_FW_FLUSH = 0x34 + IP_OLD_FW_GET = 0x36 + IP_OLD_FW_RESETLOG = 0x38 + IP_OLD_FW_ZERO = 0x35 IP_OPTIONS = 0x1 + IP_PKTINFO = 0x1a IP_PORTRANGE = 0x13 IP_PORTRANGE_DEFAULT = 0x0 IP_PORTRANGE_HIGH = 0x1 @@ -797,18 +740,23 @@ const ( IP_RECVDSTADDR = 0x7 IP_RECVIF = 0x14 IP_RECVOPTS = 0x5 + IP_RECVPKTINFO = 0x1a IP_RECVRETOPTS = 0x6 - IP_RECVTTL = 0x41 + IP_RECVTTL = 0x18 IP_RETOPTS = 0x8 IP_RF = 0x8000 IP_RSVP_OFF = 0x10 IP_RSVP_ON = 0xf IP_RSVP_VIF_OFF = 0x12 IP_RSVP_VIF_ON = 0x11 + IP_STRIPHDR = 0x17 IP_TOS = 0x3 + IP_TRAFFIC_MGT_BACKGROUND = 0x41 IP_TTL = 0x4 + IP_UNBLOCK_SOURCE = 0x49 ISIG = 0x80 ISTRIP = 0x20 + IUTF8 = 0x4000 IXANY = 0x800 IXOFF = 0x400 IXON = 0x200 @@ -816,37 +764,29 @@ const ( LOCK_NB = 0x4 LOCK_SH = 0x1 LOCK_UN = 0x8 - MADV_AUTOSYNC = 0x7 - MADV_CONTROL_END = 0xb - MADV_CONTROL_START = 0xa - MADV_CORE = 0x9 + MADV_CAN_REUSE = 0x9 MADV_DONTNEED = 0x4 MADV_FREE = 0x5 - MADV_INVAL = 0xa - MADV_NOCORE = 0x8 + MADV_FREE_REUSABLE = 0x7 + MADV_FREE_REUSE = 0x8 MADV_NORMAL = 0x0 - MADV_NOSYNC = 0x6 MADV_RANDOM = 0x1 MADV_SEQUENTIAL = 0x2 - MADV_SETMAP = 0xb MADV_WILLNEED = 0x3 + MADV_ZERO_WIRED_PAGES = 0x6 MAP_ANON = 0x1000 MAP_COPY = 0x2 MAP_FILE = 0x0 MAP_FIXED = 0x10 MAP_HASSEMAPHORE = 0x200 - MAP_INHERIT = 0x80 - MAP_NOCORE = 0x20000 + MAP_JIT = 0x800 + MAP_NOCACHE = 0x400 MAP_NOEXTEND = 0x100 MAP_NORESERVE = 0x40 - MAP_NOSYNC = 0x800 MAP_PRIVATE = 0x2 MAP_RENAME = 0x20 + MAP_RESERVED0080 = 0x80 MAP_SHARED = 0x1 - MAP_SIZEALIGN = 0x40000 - MAP_STACK = 0x400 - MAP_TRYFIXED = 0x10000 - MAP_VPAGETABLE = 0x2000 MCL_CURRENT = 0x1 MCL_FUTURE = 0x2 MSG_CTRUNC = 0x20 @@ -854,75 +794,106 @@ const ( MSG_DONTWAIT = 0x80 MSG_EOF = 0x100 MSG_EOR = 0x8 - MSG_FBLOCKING = 0x10000 - MSG_FMASK = 0xffff0000 - MSG_FNONBLOCKING = 0x20000 - MSG_NOSIGNAL = 0x400 - MSG_NOTIFICATION = 0x200 + MSG_FLUSH = 0x400 + MSG_HAVEMORE = 0x2000 + MSG_HOLD = 0x800 + MSG_NEEDSA = 0x10000 MSG_OOB = 0x1 MSG_PEEK = 0x2 - MSG_SYNC = 0x800 + MSG_RCVMORE = 0x4000 + MSG_SEND = 0x1000 MSG_TRUNC = 0x10 MSG_WAITALL = 0x40 + MSG_WAITSTREAM = 0x200 MS_ASYNC = 0x1 + MS_DEACTIVATE = 0x8 MS_INVALIDATE = 0x2 - MS_SYNC = 0x0 + MS_KILLPAGES = 0x4 + MS_SYNC = 0x10 NAME_MAX = 0xff NET_RT_DUMP = 0x1 + NET_RT_DUMP2 = 0x7 NET_RT_FLAGS = 0x2 NET_RT_IFLIST = 0x3 - NET_RT_MAXID = 0x4 + NET_RT_IFLIST2 = 0x6 + NET_RT_MAXID = 0xa + NET_RT_STAT = 0x4 + NET_RT_TRASH = 0x5 NOFLSH = 0x80000000 + NOTE_ABSOLUTE = 0x8 NOTE_ATTRIB = 0x8 + NOTE_BACKGROUND = 0x40 NOTE_CHILD = 0x4 + NOTE_CRITICAL = 0x20 NOTE_DELETE = 0x1 NOTE_EXEC = 0x20000000 NOTE_EXIT = 0x80000000 + NOTE_EXITSTATUS = 0x4000000 + NOTE_EXIT_CSERROR = 0x40000 + NOTE_EXIT_DECRYPTFAIL = 0x10000 + NOTE_EXIT_DETAIL = 0x2000000 + NOTE_EXIT_DETAIL_MASK = 0x70000 + NOTE_EXIT_MEMORY = 0x20000 + NOTE_EXIT_REPARENTED = 0x80000 NOTE_EXTEND = 0x4 + NOTE_FFAND = 0x40000000 + NOTE_FFCOPY = 0xc0000000 + NOTE_FFCTRLMASK = 0xc0000000 + NOTE_FFLAGSMASK = 0xffffff + NOTE_FFNOP = 0x0 + NOTE_FFOR = 0x80000000 NOTE_FORK = 0x40000000 + NOTE_LEEWAY = 0x10 NOTE_LINK = 0x10 NOTE_LOWAT = 0x1 - NOTE_OOB = 0x2 - NOTE_PCTRLMASK = 0xf0000000 + NOTE_NONE = 0x80 + NOTE_NSECONDS = 0x4 + NOTE_PCTRLMASK = -0x100000 NOTE_PDATAMASK = 0xfffff + NOTE_REAP = 0x10000000 NOTE_RENAME = 0x20 NOTE_REVOKE = 0x40 + NOTE_SECONDS = 0x1 + NOTE_SIGNAL = 0x8000000 NOTE_TRACK = 0x1 NOTE_TRACKERR = 0x2 + NOTE_TRIGGER = 0x1000000 + NOTE_USECONDS = 0x2 + NOTE_VM_ERROR = 0x10000000 + NOTE_VM_PRESSURE = 0x80000000 + NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000 + NOTE_VM_PRESSURE_TERMINATE = 0x40000000 NOTE_WRITE = 0x2 OCRNL = 0x10 + OFDEL = 0x20000 + OFILL = 0x80 ONLCR = 0x2 ONLRET = 0x40 ONOCR = 0x20 ONOEOT = 0x8 OPOST = 0x1 O_ACCMODE = 0x3 + O_ALERT = 0x20000000 O_APPEND = 0x8 O_ASYNC = 0x40 - O_CLOEXEC = 0x20000 + O_CLOEXEC = 0x1000000 O_CREAT = 0x200 - O_DIRECT = 0x10000 - O_DIRECTORY = 0x8000000 + O_DIRECTORY = 0x100000 + O_DP_GETRAWENCRYPTED = 0x1 + O_DSYNC = 0x400000 + O_EVTONLY = 0x8000 O_EXCL = 0x800 O_EXLOCK = 0x20 - O_FAPPEND = 0x100000 - O_FASYNCWRITE = 0x800000 - O_FBLOCKING = 0x40000 - O_FBUFFERED = 0x2000000 - O_FMASK = 0x7fc0000 - O_FNONBLOCKING = 0x80000 - O_FOFFSET = 0x200000 O_FSYNC = 0x80 - O_FSYNCWRITE = 0x400000 - O_FUNBUFFERED = 0x1000000 - O_MAPONREAD = 0x4000000 O_NDELAY = 0x4 - O_NOCTTY = 0x8000 + O_NOCTTY = 0x20000 O_NOFOLLOW = 0x100 O_NONBLOCK = 0x4 + O_POPUP = 0x80000000 O_RDONLY = 0x0 O_RDWR = 0x2 O_SHLOCK = 0x10 + O_SYMLINK = 0x200000 O_SYNC = 0x80 O_TRUNC = 0x400 O_WRONLY = 0x1 @@ -937,9 +908,28 @@ const ( PROT_NONE = 0x0 PROT_READ = 0x1 PROT_WRITE = 0x2 - RLIMIT_AS = 0xa + PT_ATTACH = 0xa + PT_ATTACHEXC = 0xe + PT_CONTINUE = 0x7 + PT_DENY_ATTACH = 0x1f + PT_DETACH = 0xb + PT_FIRSTMACH = 0x20 + PT_FORCEQUOTA = 0x1e + PT_KILL = 0x8 + PT_READ_D = 0x2 + PT_READ_I = 0x1 + PT_READ_U = 0x3 + PT_SIGEXC = 0xc + PT_STEP = 0x9 + PT_THUPDATE = 0xd + PT_TRACE_ME = 0x0 + PT_WRITE_D = 0x5 + PT_WRITE_I = 0x4 + PT_WRITE_U = 0x6 + RLIMIT_AS = 0x5 RLIMIT_CORE = 0x4 RLIMIT_CPU = 0x0 + RLIMIT_CPU_USAGE_MONITOR = 0x2 RLIMIT_DATA = 0x2 RLIMIT_FSIZE = 0x1 RLIMIT_NOFILE = 0x8 @@ -952,10 +942,7 @@ const ( RTAX_GENMASK = 0x3 RTAX_IFA = 0x5 RTAX_IFP = 0x4 - RTAX_MAX = 0xb - RTAX_MPLS1 = 0x8 - RTAX_MPLS2 = 0x9 - RTAX_MPLS3 = 0xa + RTAX_MAX = 0x8 RTAX_NETMASK = 0x2 RTA_AUTHOR = 0x40 RTA_BRD = 0x80 @@ -964,28 +951,31 @@ const ( RTA_GENMASK = 0x8 RTA_IFA = 0x20 RTA_IFP = 0x10 - RTA_MPLS1 = 0x100 - RTA_MPLS2 = 0x200 - RTA_MPLS3 = 0x400 RTA_NETMASK = 0x4 RTF_BLACKHOLE = 0x1000 RTF_BROADCAST = 0x400000 RTF_CLONING = 0x100 + RTF_CONDEMNED = 0x2000000 + RTF_DELCLONE = 0x80 RTF_DONE = 0x40 RTF_DYNAMIC = 0x10 RTF_GATEWAY = 0x2 RTF_HOST = 0x4 + RTF_IFREF = 0x4000000 + RTF_IFSCOPE = 0x1000000 RTF_LLINFO = 0x400 RTF_LOCAL = 0x200000 RTF_MODIFIED = 0x20 - RTF_MPLSOPS = 0x1000000 RTF_MULTICAST = 0x800000 + RTF_NOIFREF = 0x2000 RTF_PINNED = 0x100000 RTF_PRCLONING = 0x10000 RTF_PROTO1 = 0x8000 RTF_PROTO2 = 0x4000 RTF_PROTO3 = 0x40000 + RTF_PROXY = 0x8000000 RTF_REJECT = 0x8 + RTF_ROUTER = 0x10000000 RTF_STATIC = 0x800 RTF_UP = 0x1 RTF_WASCLONED = 0x20000 @@ -996,25 +986,23 @@ const ( RTM_DELETE = 0x2 RTM_DELMADDR = 0x10 RTM_GET = 0x4 - RTM_IEEE80211 = 0x12 - RTM_IFANNOUNCE = 0x11 + RTM_GET2 = 0x14 RTM_IFINFO = 0xe + RTM_IFINFO2 = 0x12 RTM_LOCK = 0x8 RTM_LOSING = 0x5 RTM_MISS = 0x7 RTM_NEWADDR = 0xc RTM_NEWMADDR = 0xf + RTM_NEWMADDR2 = 0x13 RTM_OLDADD = 0x9 RTM_OLDDEL = 0xa RTM_REDIRECT = 0x6 RTM_RESOLVE = 0xb RTM_RTTUNIT = 0xf4240 - RTM_VERSION = 0x6 + RTM_VERSION = 0x5 RTV_EXPIRE = 0x4 RTV_HOPCOUNT = 0x2 - RTV_IWCAPSEGS = 0x400 - RTV_IWMAXSEGS = 0x200 - RTV_MSL = 0x100 RTV_MTU = 0x1 RTV_RPIPE = 0x8 RTV_RTT = 0x40 @@ -1026,72 +1014,74 @@ const ( SCM_CREDS = 0x3 SCM_RIGHTS = 0x1 SCM_TIMESTAMP = 0x2 + SCM_TIMESTAMP_MONOTONIC = 0x4 SHUT_RD = 0x0 SHUT_RDWR = 0x2 SHUT_WR = 0x1 SIOCADDMULTI = 0x80206931 - SIOCADDRT = 0x8030720a SIOCAIFADDR = 0x8040691a - SIOCALIFADDR = 0x8118691b + SIOCARPIPLL = 0xc0206928 SIOCATMARK = 0x40047307 + SIOCAUTOADDR = 0xc0206926 + SIOCAUTONETMASK = 0x80206927 SIOCDELMULTI = 0x80206932 - SIOCDELRT = 0x8030720b SIOCDIFADDR = 0x80206919 - SIOCDIFPHYADDR = 0x80206949 - SIOCDLIFADDR = 0x8118691d - SIOCGDRVSPEC = 0xc01c697b - SIOCGETSGCNT = 0xc0147210 - SIOCGETVIFCNT = 0xc014720f + SIOCDIFPHYADDR = 0x80206941 + SIOCGDRVSPEC = 0xc028697b + SIOCGETVLAN = 0xc020697f SIOCGHIWAT = 0x40047301 SIOCGIFADDR = 0xc0206921 + SIOCGIFALTMTU = 0xc0206948 + SIOCGIFASYNCMAP = 0xc020697c + SIOCGIFBOND = 0xc0206947 SIOCGIFBRDADDR = 0xc0206923 - SIOCGIFCAP = 0xc020691f - SIOCGIFCONF = 0xc0086924 - SIOCGIFDATA = 0xc0206926 + SIOCGIFCAP = 0xc020695b + SIOCGIFCONF = 0xc00c6924 + SIOCGIFDEVMTU = 0xc0206944 SIOCGIFDSTADDR = 0xc0206922 SIOCGIFFLAGS = 0xc0206911 SIOCGIFGENERIC = 0xc020693a - SIOCGIFGMEMB = 0xc024698a - SIOCGIFINDEX = 0xc0206920 - SIOCGIFMEDIA = 0xc0286938 + SIOCGIFKPI = 0xc0206987 + SIOCGIFMAC = 0xc0206982 + SIOCGIFMEDIA = 0xc02c6938 SIOCGIFMETRIC = 0xc0206917 SIOCGIFMTU = 0xc0206933 SIOCGIFNETMASK = 0xc0206925 - SIOCGIFPDSTADDR = 0xc0206948 + SIOCGIFPDSTADDR = 0xc0206940 SIOCGIFPHYS = 0xc0206935 - SIOCGIFPOLLCPU = 0xc020697e - SIOCGIFPSRCADDR = 0xc0206947 - SIOCGIFSTATUS = 0xc331693b - SIOCGIFTSOLEN = 0xc0206980 - SIOCGLIFADDR = 0xc118691c - SIOCGLIFPHYADDR = 0xc118694b + SIOCGIFPSRCADDR = 0xc020693f + SIOCGIFSTATUS = 0xc331693d + SIOCGIFVLAN = 0xc020697f + SIOCGIFWAKEFLAGS = 0xc0206988 SIOCGLOWAT = 0x40047303 SIOCGPGRP = 0x40047309 - SIOCGPRIVATE_0 = 0xc0206950 - SIOCGPRIVATE_1 = 0xc0206951 - SIOCIFCREATE = 0xc020697a - SIOCIFCREATE2 = 0xc020697c + SIOCIFCREATE = 0xc0206978 + SIOCIFCREATE2 = 0xc020697a SIOCIFDESTROY = 0x80206979 - SIOCIFGCLONERS = 0xc00c6978 - SIOCSDRVSPEC = 0x801c697b + SIOCIFGCLONERS = 0xc0106981 + SIOCRSLVMULTI = 0xc010693b + SIOCSDRVSPEC = 0x8028697b + SIOCSETVLAN = 0x8020697e SIOCSHIWAT = 0x80047300 SIOCSIFADDR = 0x8020690c + SIOCSIFALTMTU = 0x80206945 + SIOCSIFASYNCMAP = 0x8020697d + SIOCSIFBOND = 0x80206946 SIOCSIFBRDADDR = 0x80206913 - SIOCSIFCAP = 0x8020691e + SIOCSIFCAP = 0x8020695a SIOCSIFDSTADDR = 0x8020690e SIOCSIFFLAGS = 0x80206910 SIOCSIFGENERIC = 0x80206939 + SIOCSIFKPI = 0x80206986 SIOCSIFLLADDR = 0x8020693c + SIOCSIFMAC = 0x80206983 SIOCSIFMEDIA = 0xc0206937 SIOCSIFMETRIC = 0x80206918 SIOCSIFMTU = 0x80206934 - SIOCSIFNAME = 0x80206928 SIOCSIFNETMASK = 0x80206916 - SIOCSIFPHYADDR = 0x80406946 + SIOCSIFPHYADDR = 0x8040693e SIOCSIFPHYS = 0x80206936 - SIOCSIFPOLLCPU = 0x8020697d - SIOCSIFTSOLEN = 0x8020697f - SIOCSLIFPHYADDR = 0x8118694a + SIOCSIFVLAN = 0x8020697e SIOCSLOWAT = 0x80047302 SIOCSPGRP = 0x80047308 SOCK_DGRAM = 0x2 @@ -1103,65 +1093,110 @@ const ( SOL_SOCKET = 0xffff SOMAXCONN = 0x80 SO_ACCEPTCONN = 0x2 - SO_ACCEPTFILTER = 0x1000 SO_BROADCAST = 0x20 SO_DEBUG = 0x1 SO_DONTROUTE = 0x10 + SO_DONTTRUNC = 0x2000 SO_ERROR = 0x1007 SO_KEEPALIVE = 0x8 + SO_LABEL = 0x1010 SO_LINGER = 0x80 - SO_NOSIGPIPE = 0x800 + SO_LINGER_SEC = 0x1080 + SO_NKE = 0x1021 + SO_NOADDRERR = 0x1023 + SO_NOSIGPIPE = 0x1022 + SO_NOTIFYCONFLICT = 0x1026 + SO_NP_EXTENSIONS = 0x1083 + SO_NREAD = 0x1020 + SO_NUMRCVPKT = 0x1112 + SO_NWRITE = 0x1024 SO_OOBINLINE = 0x100 + SO_PEERLABEL = 0x1011 + SO_RANDOMPORT = 0x1082 SO_RCVBUF = 0x1002 SO_RCVLOWAT = 0x1004 SO_RCVTIMEO = 0x1006 SO_REUSEADDR = 0x4 SO_REUSEPORT = 0x200 + SO_REUSESHAREUID = 0x1025 SO_SNDBUF = 0x1001 SO_SNDLOWAT = 0x1003 - SO_SNDSPACE = 0x100a SO_SNDTIMEO = 0x1005 SO_TIMESTAMP = 0x400 + SO_TIMESTAMP_MONOTONIC = 0x800 SO_TYPE = 0x1008 + SO_UPCALLCLOSEWAIT = 0x1027 SO_USELOOPBACK = 0x40 + SO_WANTMORE = 0x4000 + SO_WANTOOBFLAG = 0x8000 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IFWHT = 0xe000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISTXT = 0x200 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 TCIFLUSH = 0x1 TCIOFLUSH = 0x3 TCOFLUSH = 0x2 - TCP_FASTKEEP = 0x80 - TCP_KEEPCNT = 0x400 - TCP_KEEPIDLE = 0x100 - TCP_KEEPINIT = 0x20 - TCP_KEEPINTVL = 0x200 - TCP_MAXBURST = 0x4 + TCP_CONNECTIONTIMEOUT = 0x20 + TCP_ENABLE_ECN = 0x104 + TCP_KEEPALIVE = 0x10 + TCP_KEEPCNT = 0x102 + TCP_KEEPINTVL = 0x101 TCP_MAXHLEN = 0x3c TCP_MAXOLEN = 0x28 TCP_MAXSEG = 0x2 TCP_MAXWIN = 0xffff + TCP_MAX_SACK = 0x4 TCP_MAX_WINSHIFT = 0xe - TCP_MINMSS = 0x100 - TCP_MIN_WINSHIFT = 0x5 + TCP_MINMSS = 0xd8 TCP_MSS = 0x200 TCP_NODELAY = 0x1 TCP_NOOPT = 0x8 TCP_NOPUSH = 0x4 - TCP_SIGNATURE_ENABLE = 0x10 + TCP_NOTSENT_LOWAT = 0x201 + TCP_RXT_CONNDROPTIME = 0x80 + TCP_RXT_FINDROP = 0x100 + TCP_SENDMOREACKS = 0x103 TCSAFLUSH = 0x2 TIOCCBRK = 0x2000747a TIOCCDTR = 0x20007478 TIOCCONS = 0x80047462 - TIOCDCDTIMESTAMP = 0x40087458 + TIOCDCDTIMESTAMP = 0x40107458 TIOCDRAIN = 0x2000745e + TIOCDSIMICROCODE = 0x20007455 TIOCEXCL = 0x2000740d TIOCEXT = 0x80047460 TIOCFLUSH = 0x80047410 TIOCGDRAINWAIT = 0x40047456 - TIOCGETA = 0x402c7413 + TIOCGETA = 0x40487413 TIOCGETD = 0x4004741a TIOCGPGRP = 0x40047477 - TIOCGSID = 0x40047463 - TIOCGSIZE = 0x40087468 TIOCGWINSZ = 0x40087468 - TIOCISPTMASTER = 0x20007455 + TIOCIXOFF = 0x20007480 + TIOCIXON = 0x20007481 TIOCMBIC = 0x8004746b TIOCMBIS = 0x8004746c TIOCMGDTRWAIT = 0x4004745a @@ -1193,34 +1228,35 @@ const ( TIOCPKT_NOSTOP = 0x10 TIOCPKT_START = 0x8 TIOCPKT_STOP = 0x4 + TIOCPTYGNAME = 0x40807453 + TIOCPTYGRANT = 0x20007454 + TIOCPTYUNLK = 0x20007452 TIOCREMOTE = 0x80047469 TIOCSBRK = 0x2000747b + TIOCSCONS = 0x20007463 TIOCSCTTY = 0x20007461 TIOCSDRAINWAIT = 0x80047457 TIOCSDTR = 0x20007479 - TIOCSETA = 0x802c7414 - TIOCSETAF = 0x802c7416 - TIOCSETAW = 0x802c7415 + TIOCSETA = 0x80487414 + TIOCSETAF = 0x80487416 + TIOCSETAW = 0x80487415 TIOCSETD = 0x8004741b TIOCSIG = 0x2000745f TIOCSPGRP = 0x80047476 - TIOCSSIZE = 0x80087467 TIOCSTART = 0x2000746e TIOCSTAT = 0x20007465 TIOCSTI = 0x80017472 TIOCSTOP = 0x2000746f TIOCSWINSZ = 0x80087467 - TIOCTIMESTAMP = 0x40087459 + TIOCTIMESTAMP = 0x40107459 TIOCUCNTL = 0x80047466 TOSTOP = 0x400000 - VCHECKPT = 0x13 VDISCARD = 0xf VDSUSP = 0xb VEOF = 0x0 VEOL = 0x1 VEOL2 = 0x2 VERASE = 0x3 - VERASE2 = 0x7 VINTR = 0x8 VKILL = 0x5 VLNEXT = 0xe @@ -1231,13 +1267,18 @@ const ( VSTATUS = 0x12 VSTOP = 0xd VSUSP = 0xa + VT0 = 0x0 + VT1 = 0x10000 + VTDLY = 0x10000 VTIME = 0x11 VWERASE = 0x4 - WCONTINUED = 0x4 + WCONTINUED = 0x10 WCOREFLAG = 0x80 - WLINUXCLONE = 0x80000000 + WEXITED = 0x4 WNOHANG = 0x1 - WSTOPPED = 0x7f + WNOWAIT = 0x20 + WORDSIZE = 0x40 + WSTOPPED = 0x8 WUNTRACED = 0x2 ) @@ -1250,21 +1291,23 @@ const ( EAFNOSUPPORT = syscall.Errno(0x2f) EAGAIN = syscall.Errno(0x23) EALREADY = syscall.Errno(0x25) - EASYNC = syscall.Errno(0x63) EAUTH = syscall.Errno(0x50) + EBADARCH = syscall.Errno(0x56) + EBADEXEC = syscall.Errno(0x55) EBADF = syscall.Errno(0x9) - EBADMSG = syscall.Errno(0x59) + EBADMACHO = syscall.Errno(0x58) + EBADMSG = syscall.Errno(0x5e) EBADRPC = syscall.Errno(0x48) EBUSY = syscall.Errno(0x10) - ECANCELED = syscall.Errno(0x55) + ECANCELED = syscall.Errno(0x59) ECHILD = syscall.Errno(0xa) ECONNABORTED = syscall.Errno(0x35) ECONNREFUSED = syscall.Errno(0x3d) ECONNRESET = syscall.Errno(0x36) EDEADLK = syscall.Errno(0xb) EDESTADDRREQ = syscall.Errno(0x27) + EDEVERR = syscall.Errno(0x53) EDOM = syscall.Errno(0x21) - EDOOFUS = syscall.Errno(0x58) EDQUOT = syscall.Errno(0x45) EEXIST = syscall.Errno(0x11) EFAULT = syscall.Errno(0xe) @@ -1272,49 +1315,54 @@ const ( EFTYPE = syscall.Errno(0x4f) EHOSTDOWN = syscall.Errno(0x40) EHOSTUNREACH = syscall.Errno(0x41) - EIDRM = syscall.Errno(0x52) - EILSEQ = syscall.Errno(0x56) + EIDRM = syscall.Errno(0x5a) + EILSEQ = syscall.Errno(0x5c) EINPROGRESS = syscall.Errno(0x24) EINTR = syscall.Errno(0x4) EINVAL = syscall.Errno(0x16) EIO = syscall.Errno(0x5) EISCONN = syscall.Errno(0x38) EISDIR = syscall.Errno(0x15) - ELAST = syscall.Errno(0x63) + ELAST = syscall.Errno(0x6a) ELOOP = syscall.Errno(0x3e) EMFILE = syscall.Errno(0x18) EMLINK = syscall.Errno(0x1f) EMSGSIZE = syscall.Errno(0x28) - EMULTIHOP = syscall.Errno(0x5a) + EMULTIHOP = syscall.Errno(0x5f) ENAMETOOLONG = syscall.Errno(0x3f) ENEEDAUTH = syscall.Errno(0x51) ENETDOWN = syscall.Errno(0x32) ENETRESET = syscall.Errno(0x34) ENETUNREACH = syscall.Errno(0x33) ENFILE = syscall.Errno(0x17) - ENOATTR = syscall.Errno(0x57) + ENOATTR = syscall.Errno(0x5d) ENOBUFS = syscall.Errno(0x37) + ENODATA = syscall.Errno(0x60) ENODEV = syscall.Errno(0x13) ENOENT = syscall.Errno(0x2) ENOEXEC = syscall.Errno(0x8) ENOLCK = syscall.Errno(0x4d) - ENOLINK = syscall.Errno(0x5b) - ENOMEDIUM = syscall.Errno(0x5d) + ENOLINK = syscall.Errno(0x61) ENOMEM = syscall.Errno(0xc) - ENOMSG = syscall.Errno(0x53) + ENOMSG = syscall.Errno(0x5b) + ENOPOLICY = syscall.Errno(0x67) ENOPROTOOPT = syscall.Errno(0x2a) ENOSPC = syscall.Errno(0x1c) + ENOSR = syscall.Errno(0x62) + ENOSTR = syscall.Errno(0x63) ENOSYS = syscall.Errno(0x4e) ENOTBLK = syscall.Errno(0xf) ENOTCONN = syscall.Errno(0x39) ENOTDIR = syscall.Errno(0x14) ENOTEMPTY = syscall.Errno(0x42) + ENOTRECOVERABLE = syscall.Errno(0x68) ENOTSOCK = syscall.Errno(0x26) ENOTSUP = syscall.Errno(0x2d) ENOTTY = syscall.Errno(0x19) ENXIO = syscall.Errno(0x6) - EOPNOTSUPP = syscall.Errno(0x2d) + EOPNOTSUPP = syscall.Errno(0x66) EOVERFLOW = syscall.Errno(0x54) + EOWNERDEAD = syscall.Errno(0x69) EPERM = syscall.Errno(0x1) EPFNOSUPPORT = syscall.Errno(0x2e) EPIPE = syscall.Errno(0x20) @@ -1322,26 +1370,25 @@ const ( EPROCUNAVAIL = syscall.Errno(0x4c) EPROGMISMATCH = syscall.Errno(0x4b) EPROGUNAVAIL = syscall.Errno(0x4a) - EPROTO = syscall.Errno(0x5c) + EPROTO = syscall.Errno(0x64) EPROTONOSUPPORT = syscall.Errno(0x2b) EPROTOTYPE = syscall.Errno(0x29) + EPWROFF = syscall.Errno(0x52) + EQFULL = syscall.Errno(0x6a) ERANGE = syscall.Errno(0x22) EREMOTE = syscall.Errno(0x47) EROFS = syscall.Errno(0x1e) ERPCMISMATCH = syscall.Errno(0x49) + ESHLIBVERS = syscall.Errno(0x57) ESHUTDOWN = syscall.Errno(0x3a) ESOCKTNOSUPPORT = syscall.Errno(0x2c) ESPIPE = syscall.Errno(0x1d) ESRCH = syscall.Errno(0x3) ESTALE = syscall.Errno(0x46) + ETIME = syscall.Errno(0x65) ETIMEDOUT = syscall.Errno(0x3c) ETOOMANYREFS = syscall.Errno(0x3b) ETXTBSY = syscall.Errno(0x1a) - EUNUSED94 = syscall.Errno(0x5e) - EUNUSED95 = syscall.Errno(0x5f) - EUNUSED96 = syscall.Errno(0x60) - EUNUSED97 = syscall.Errno(0x61) - EUNUSED98 = syscall.Errno(0x62) EUSERS = syscall.Errno(0x44) EWOULDBLOCK = syscall.Errno(0x23) EXDEV = syscall.Errno(0x12) @@ -1349,144 +1396,148 @@ const ( // Signals const ( - SIGABRT = syscall.Signal(0x6) - SIGALRM = syscall.Signal(0xe) - SIGBUS = syscall.Signal(0xa) - SIGCHLD = syscall.Signal(0x14) - SIGCKPT = syscall.Signal(0x21) - SIGCKPTEXIT = syscall.Signal(0x22) - SIGCONT = syscall.Signal(0x13) - SIGEMT = syscall.Signal(0x7) - SIGFPE = syscall.Signal(0x8) - SIGHUP = syscall.Signal(0x1) - SIGILL = syscall.Signal(0x4) - SIGINFO = syscall.Signal(0x1d) - SIGINT = syscall.Signal(0x2) - SIGIO = syscall.Signal(0x17) - SIGIOT = syscall.Signal(0x6) - SIGKILL = syscall.Signal(0x9) - SIGPIPE = syscall.Signal(0xd) - SIGPROF = syscall.Signal(0x1b) - SIGQUIT = syscall.Signal(0x3) - SIGSEGV = syscall.Signal(0xb) - SIGSTOP = syscall.Signal(0x11) - SIGSYS = syscall.Signal(0xc) - SIGTERM = syscall.Signal(0xf) - SIGTHR = syscall.Signal(0x20) - SIGTRAP = syscall.Signal(0x5) - SIGTSTP = syscall.Signal(0x12) - SIGTTIN = syscall.Signal(0x15) - SIGTTOU = syscall.Signal(0x16) - SIGURG = syscall.Signal(0x10) - SIGUSR1 = syscall.Signal(0x1e) - SIGUSR2 = syscall.Signal(0x1f) - SIGVTALRM = syscall.Signal(0x1a) - SIGWINCH = syscall.Signal(0x1c) - SIGXCPU = syscall.Signal(0x18) - SIGXFSZ = syscall.Signal(0x19) + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0xa) + SIGCHLD = syscall.Signal(0x14) + SIGCONT = syscall.Signal(0x13) + SIGEMT = syscall.Signal(0x7) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINFO = syscall.Signal(0x1d) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x17) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPROF = syscall.Signal(0x1b) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTOP = syscall.Signal(0x11) + SIGSYS = syscall.Signal(0xc) + SIGTERM = syscall.Signal(0xf) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x12) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGURG = syscall.Signal(0x10) + SIGUSR1 = syscall.Signal(0x1e) + SIGUSR2 = syscall.Signal(0x1f) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) ) // Error table var errors = [...]string{ - 1: "operation not permitted", - 2: "no such file or directory", - 3: "no such process", - 4: "interrupted system call", - 5: "input/output error", - 6: "device not configured", - 7: "argument list too long", - 8: "exec format error", - 9: "bad file descriptor", - 10: "no child processes", - 11: "resource deadlock avoided", - 12: "cannot allocate memory", - 13: "permission denied", - 14: "bad address", - 15: "block device required", - 16: "device busy", - 17: "file exists", - 18: "cross-device link", - 19: "operation not supported by device", - 20: "not a directory", - 21: "is a directory", - 22: "invalid argument", - 23: "too many open files in system", - 24: "too many open files", - 25: "inappropriate ioctl for device", - 26: "text file busy", - 27: "file too large", - 28: "no space left on device", - 29: "illegal seek", - 30: "read-only file system", - 31: "too many links", - 32: "broken pipe", - 33: "numerical argument out of domain", - 34: "result too large", - 35: "resource temporarily unavailable", - 36: "operation now in progress", - 37: "operation already in progress", - 38: "socket operation on non-socket", - 39: "destination address required", - 40: "message too long", - 41: "protocol wrong type for socket", - 42: "protocol not available", - 43: "protocol not supported", - 44: "socket type not supported", - 45: "operation not supported", - 46: "protocol family not supported", - 47: "address family not supported by protocol family", - 48: "address already in use", - 49: "can't assign requested address", - 50: "network is down", - 51: "network is unreachable", - 52: "network dropped connection on reset", - 53: "software caused connection abort", - 54: "connection reset by peer", - 55: "no buffer space available", - 56: "socket is already connected", - 57: "socket is not connected", - 58: "can't send after socket shutdown", - 59: "too many references: can't splice", - 60: "operation timed out", - 61: "connection refused", - 62: "too many levels of symbolic links", - 63: "file name too long", - 64: "host is down", - 65: "no route to host", - 66: "directory not empty", - 67: "too many processes", - 68: "too many users", - 69: "disc quota exceeded", - 70: "stale NFS file handle", - 71: "too many levels of remote in path", - 72: "RPC struct is bad", - 73: "RPC version wrong", - 74: "RPC prog. not avail", - 75: "program version wrong", - 76: "bad procedure for program", - 77: "no locks available", - 78: "function not implemented", - 79: "inappropriate file type or format", - 80: "authentication error", - 81: "need authenticator", - 82: "identifier removed", - 83: "no message of desired type", - 84: "value too large to be stored in data type", - 85: "operation canceled", - 86: "illegal byte sequence", - 87: "attribute not found", - 88: "programming error", - 89: "bad message", - 90: "multihop attempted", - 91: "link has been severed", - 92: "protocol error", - 93: "no medium found", - 94: "unknown error: 94", - 95: "unknown error: 95", - 96: "unknown error: 96", - 97: "unknown error: 97", - 98: "unknown error: 98", - 99: "unknown error: 99", + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "device not configured", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource deadlock avoided", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "resource busy", + 17: "file exists", + 18: "cross-device link", + 19: "operation not supported by device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "result too large", + 35: "resource temporarily unavailable", + 36: "operation now in progress", + 37: "operation already in progress", + 38: "socket operation on non-socket", + 39: "destination address required", + 40: "message too long", + 41: "protocol wrong type for socket", + 42: "protocol not available", + 43: "protocol not supported", + 44: "socket type not supported", + 45: "operation not supported", + 46: "protocol family not supported", + 47: "address family not supported by protocol family", + 48: "address already in use", + 49: "can't assign requested address", + 50: "network is down", + 51: "network is unreachable", + 52: "network dropped connection on reset", + 53: "software caused connection abort", + 54: "connection reset by peer", + 55: "no buffer space available", + 56: "socket is already connected", + 57: "socket is not connected", + 58: "can't send after socket shutdown", + 59: "too many references: can't splice", + 60: "operation timed out", + 61: "connection refused", + 62: "too many levels of symbolic links", + 63: "file name too long", + 64: "host is down", + 65: "no route to host", + 66: "directory not empty", + 67: "too many processes", + 68: "too many users", + 69: "disc quota exceeded", + 70: "stale NFS file handle", + 71: "too many levels of remote in path", + 72: "RPC struct is bad", + 73: "RPC version wrong", + 74: "RPC prog. not avail", + 75: "program version wrong", + 76: "bad procedure for program", + 77: "no locks available", + 78: "function not implemented", + 79: "inappropriate file type or format", + 80: "authentication error", + 81: "need authenticator", + 82: "device power is off", + 83: "device error", + 84: "value too large to be stored in data type", + 85: "bad executable (or shared library)", + 86: "bad CPU type in executable", + 87: "shared library version mismatch", + 88: "malformed Mach-o file", + 89: "operation canceled", + 90: "identifier removed", + 91: "no message of desired type", + 92: "illegal byte sequence", + 93: "attribute not found", + 94: "bad message", + 95: "EMULTIHOP (Reserved)", + 96: "no message available on STREAM", + 97: "ENOLINK (Reserved)", + 98: "no STREAM resources", + 99: "not a STREAM", + 100: "protocol error", + 101: "STREAM ioctl timeout", + 102: "operation not supported on socket", + 103: "policy not found", + 104: "state not recoverable", + 105: "previous owner died", + 106: "interface output queue is full", } // Signal table @@ -1522,7 +1573,4 @@ var signals = [...]string{ 29: "information request", 30: "user defined signal 1", 31: "user defined signal 2", - 32: "thread Scheduler", - 33: "checkPoint", - 34: "checkPointExit", } diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go index 914fa96a78..0feceee151 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go @@ -1,6 +1,8 @@ // mkerrors.sh -m64 // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build amd64,dragonfly + // Created by cgo -godefs - DO NOT EDIT // cgo -godefs -- -m64 _const.go diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_freebsd_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_freebsd_386.go index 199c63fe61..7b95751c3d 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_freebsd_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_freebsd_386.go @@ -1,6 +1,8 @@ // mkerrors.sh -m32 // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build 386,freebsd + // Created by cgo -godefs - DO NOT EDIT // cgo -godefs -- -m32 _const.go @@ -223,6 +225,20 @@ const ( BRKINT = 0x2 CFLUSH = 0xf CLOCAL = 0x8000 + CLOCK_MONOTONIC = 0x4 + CLOCK_MONOTONIC_FAST = 0xc + CLOCK_MONOTONIC_PRECISE = 0xb + CLOCK_PROCESS_CPUTIME_ID = 0xf + CLOCK_PROF = 0x2 + CLOCK_REALTIME = 0x0 + CLOCK_REALTIME_FAST = 0xa + CLOCK_REALTIME_PRECISE = 0x9 + CLOCK_SECOND = 0xd + CLOCK_THREAD_CPUTIME_ID = 0xe + CLOCK_UPTIME = 0x5 + CLOCK_UPTIME_FAST = 0x8 + CLOCK_UPTIME_PRECISE = 0x7 + CLOCK_VIRTUAL = 0x1 CREAD = 0x800 CS5 = 0x0 CS6 = 0x100 diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_freebsd_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_freebsd_amd64.go index f3ca90af1b..e48e7799a1 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_freebsd_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_freebsd_amd64.go @@ -1,6 +1,8 @@ // mkerrors.sh -m64 // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build amd64,freebsd + // Created by cgo -godefs - DO NOT EDIT // cgo -godefs -- -m64 _const.go @@ -223,6 +225,20 @@ const ( BRKINT = 0x2 CFLUSH = 0xf CLOCAL = 0x8000 + CLOCK_MONOTONIC = 0x4 + CLOCK_MONOTONIC_FAST = 0xc + CLOCK_MONOTONIC_PRECISE = 0xb + CLOCK_PROCESS_CPUTIME_ID = 0xf + CLOCK_PROF = 0x2 + CLOCK_REALTIME = 0x0 + CLOCK_REALTIME_FAST = 0xa + CLOCK_REALTIME_PRECISE = 0x9 + CLOCK_SECOND = 0xd + CLOCK_THREAD_CPUTIME_ID = 0xe + CLOCK_UPTIME = 0x5 + CLOCK_UPTIME_FAST = 0x8 + CLOCK_UPTIME_PRECISE = 0x7 + CLOCK_VIRTUAL = 0x1 CREAD = 0x800 CS5 = 0x0 CS6 = 0x100 diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_freebsd_arm.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_freebsd_arm.go index 2d9d5e228d..2afbe2d5ed 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_freebsd_arm.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_freebsd_arm.go @@ -1,6 +1,8 @@ // mkerrors.sh // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build arm,freebsd + // Created by cgo -godefs - DO NOT EDIT // cgo -godefs -- _const.go diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_386.go index fcee4fcef4..8f920124b8 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_386.go @@ -1,6 +1,8 @@ // mkerrors.sh -m32 // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build 386,linux + // Created by cgo -godefs - DO NOT EDIT // cgo -godefs -- -m32 _const.go @@ -143,6 +145,7 @@ const ( B75 = 0x2 B921600 = 0x1007 B9600 = 0xd + BOTHER = 0x1000 BPF_A = 0x10 BPF_ABS = 0x20 BPF_ADD = 0x0 @@ -184,7 +187,13 @@ const ( BPF_W = 0x0 BPF_X = 0x8 BRKINT = 0x2 + BS0 = 0x0 + BS1 = 0x2000 + BSDLY = 0x2000 + CBAUD = 0x100f + CBAUDEX = 0x1000 CFLUSH = 0xf + CIBAUD = 0x100f0000 CLOCAL = 0x800 CLOCK_BOOTTIME = 0x7 CLOCK_BOOTTIME_ALARM = 0x9 @@ -207,6 +216,7 @@ const ( CLONE_FILES = 0x400 CLONE_FS = 0x200 CLONE_IO = 0x80000000 + CLONE_NEWCGROUP = 0x2000000 CLONE_NEWIPC = 0x8000000 CLONE_NEWNET = 0x40000000 CLONE_NEWNS = 0x20000 @@ -223,7 +233,14 @@ const ( CLONE_UNTRACED = 0x800000 CLONE_VFORK = 0x4000 CLONE_VM = 0x100 + CMSPAR = 0x40000000 + CR0 = 0x0 + CR1 = 0x200 + CR2 = 0x400 + CR3 = 0x600 + CRDLY = 0x600 CREAD = 0x80 + CRTSCTS = 0x80000000 CS5 = 0x0 CS6 = 0x10 CS7 = 0x20 @@ -351,6 +368,9 @@ const ( EXTPROC = 0x10000 FD_CLOEXEC = 0x1 FD_SETSIZE = 0x400 + FF0 = 0x0 + FF1 = 0x8000 + FFDLY = 0x8000 FLUSHO = 0x1000 F_DUPFD = 0x0 F_DUPFD_CLOEXEC = 0x406 @@ -386,6 +406,7 @@ const ( F_UNLCK = 0x2 F_WRLCK = 0x1 HUPCL = 0x400 + IBSHIFT = 0x10 ICANON = 0x2 ICMPV6_FILTER = 0x1 ICRNL = 0x100 @@ -617,6 +638,7 @@ const ( IP_XFRM_POLICY = 0x11 ISIG = 0x1 ISTRIP = 0x20 + IUCLC = 0x200 IUTF8 = 0x4000 IXANY = 0x800 IXOFF = 0x1000 @@ -748,10 +770,13 @@ const ( NETLINK_UNUSED = 0x1 NETLINK_USERSOCK = 0x2 NETLINK_XFRM = 0x6 + NL0 = 0x0 + NL1 = 0x100 NLA_ALIGNTO = 0x4 NLA_F_NESTED = 0x8000 NLA_F_NET_BYTEORDER = 0x4000 NLA_HDRLEN = 0x4 + NLDLY = 0x100 NLMSG_ALIGNTO = 0x4 NLMSG_DONE = 0x3 NLMSG_ERROR = 0x2 @@ -776,6 +801,7 @@ const ( OCRNL = 0x8 OFDEL = 0x80 OFILL = 0x40 + OLCUC = 0x2 ONLCR = 0x4 ONLRET = 0x20 ONOCR = 0x10 @@ -801,6 +827,7 @@ const ( O_RDWR = 0x2 O_RSYNC = 0x101000 O_SYNC = 0x101000 + O_TMPFILE = 0x410000 O_TRUNC = 0x200 O_WRONLY = 0x1 PACKET_ADD_MEMBERSHIP = 0x1 @@ -1273,10 +1300,23 @@ const ( S_IXGRP = 0x8 S_IXOTH = 0x1 S_IXUSR = 0x40 + TAB0 = 0x0 + TAB1 = 0x800 + TAB2 = 0x1000 + TAB3 = 0x1800 + TABDLY = 0x1800 TCFLSH = 0x540b + TCGETA = 0x5405 + TCGETS = 0x5401 + TCGETS2 = 0x802c542a + TCGETX = 0x5432 TCIFLUSH = 0x0 + TCIOFF = 0x2 TCIOFLUSH = 0x2 + TCION = 0x3 TCOFLUSH = 0x1 + TCOOFF = 0x0 + TCOON = 0x1 TCP_CONGESTION = 0xd TCP_CORK = 0x3 TCP_DEFER_ACCEPT = 0x9 @@ -1296,14 +1336,32 @@ const ( TCP_SYNCNT = 0x7 TCP_WINDOW_CLAMP = 0xa TCSAFLUSH = 0x2 + TCSBRK = 0x5409 + TCSBRKP = 0x5425 + TCSETA = 0x5406 + TCSETAF = 0x5408 + TCSETAW = 0x5407 + TCSETS = 0x5402 + TCSETS2 = 0x402c542b + TCSETSF = 0x5404 + TCSETSF2 = 0x402c542d + TCSETSW = 0x5403 + TCSETSW2 = 0x402c542c + TCSETX = 0x5433 + TCSETXF = 0x5434 + TCSETXW = 0x5435 + TCXONC = 0x540a TIOCCBRK = 0x5428 TIOCCONS = 0x541d TIOCEXCL = 0x540c TIOCGDEV = 0x80045432 TIOCGETD = 0x5424 + TIOCGEXCL = 0x80045440 TIOCGICOUNT = 0x545d TIOCGLCKTRMIOS = 0x5456 TIOCGPGRP = 0x540f + TIOCGPKT = 0x80045438 + TIOCGPTLCK = 0x80045439 TIOCGPTN = 0x80045430 TIOCGRS485 = 0x542e TIOCGSERIAL = 0x541e @@ -1409,6 +1467,8 @@ const ( WORDSIZE = 0x20 WSTOPPED = 0x2 WUNTRACED = 0x2 + XCASE = 0x4 + XTABS = 0x1800 ) // Errors diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_amd64.go index 52d05b1282..49b6c35467 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -1,6 +1,8 @@ // mkerrors.sh -m64 // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build amd64,linux + // Created by cgo -godefs - DO NOT EDIT // cgo -godefs -- -m64 _const.go @@ -143,6 +145,7 @@ const ( B75 = 0x2 B921600 = 0x1007 B9600 = 0xd + BOTHER = 0x1000 BPF_A = 0x10 BPF_ABS = 0x20 BPF_ADD = 0x0 @@ -184,7 +187,13 @@ const ( BPF_W = 0x0 BPF_X = 0x8 BRKINT = 0x2 + BS0 = 0x0 + BS1 = 0x2000 + BSDLY = 0x2000 + CBAUD = 0x100f + CBAUDEX = 0x1000 CFLUSH = 0xf + CIBAUD = 0x100f0000 CLOCAL = 0x800 CLOCK_BOOTTIME = 0x7 CLOCK_BOOTTIME_ALARM = 0x9 @@ -207,6 +216,7 @@ const ( CLONE_FILES = 0x400 CLONE_FS = 0x200 CLONE_IO = 0x80000000 + CLONE_NEWCGROUP = 0x2000000 CLONE_NEWIPC = 0x8000000 CLONE_NEWNET = 0x40000000 CLONE_NEWNS = 0x20000 @@ -223,7 +233,14 @@ const ( CLONE_UNTRACED = 0x800000 CLONE_VFORK = 0x4000 CLONE_VM = 0x100 + CMSPAR = 0x40000000 + CR0 = 0x0 + CR1 = 0x200 + CR2 = 0x400 + CR3 = 0x600 + CRDLY = 0x600 CREAD = 0x80 + CRTSCTS = 0x80000000 CS5 = 0x0 CS6 = 0x10 CS7 = 0x20 @@ -351,6 +368,9 @@ const ( EXTPROC = 0x10000 FD_CLOEXEC = 0x1 FD_SETSIZE = 0x400 + FF0 = 0x0 + FF1 = 0x8000 + FFDLY = 0x8000 FLUSHO = 0x1000 F_DUPFD = 0x0 F_DUPFD_CLOEXEC = 0x406 @@ -386,6 +406,7 @@ const ( F_UNLCK = 0x2 F_WRLCK = 0x1 HUPCL = 0x400 + IBSHIFT = 0x10 ICANON = 0x2 ICMPV6_FILTER = 0x1 ICRNL = 0x100 @@ -617,6 +638,7 @@ const ( IP_XFRM_POLICY = 0x11 ISIG = 0x1 ISTRIP = 0x20 + IUCLC = 0x200 IUTF8 = 0x4000 IXANY = 0x800 IXOFF = 0x1000 @@ -748,10 +770,13 @@ const ( NETLINK_UNUSED = 0x1 NETLINK_USERSOCK = 0x2 NETLINK_XFRM = 0x6 + NL0 = 0x0 + NL1 = 0x100 NLA_ALIGNTO = 0x4 NLA_F_NESTED = 0x8000 NLA_F_NET_BYTEORDER = 0x4000 NLA_HDRLEN = 0x4 + NLDLY = 0x100 NLMSG_ALIGNTO = 0x4 NLMSG_DONE = 0x3 NLMSG_ERROR = 0x2 @@ -776,6 +801,7 @@ const ( OCRNL = 0x8 OFDEL = 0x80 OFILL = 0x40 + OLCUC = 0x2 ONLCR = 0x4 ONLRET = 0x20 ONOCR = 0x10 @@ -801,6 +827,7 @@ const ( O_RDWR = 0x2 O_RSYNC = 0x101000 O_SYNC = 0x101000 + O_TMPFILE = 0x410000 O_TRUNC = 0x200 O_WRONLY = 0x1 PACKET_ADD_MEMBERSHIP = 0x1 @@ -1274,10 +1301,23 @@ const ( S_IXGRP = 0x8 S_IXOTH = 0x1 S_IXUSR = 0x40 + TAB0 = 0x0 + TAB1 = 0x800 + TAB2 = 0x1000 + TAB3 = 0x1800 + TABDLY = 0x1800 TCFLSH = 0x540b + TCGETA = 0x5405 + TCGETS = 0x5401 + TCGETS2 = 0x802c542a + TCGETX = 0x5432 TCIFLUSH = 0x0 + TCIOFF = 0x2 TCIOFLUSH = 0x2 + TCION = 0x3 TCOFLUSH = 0x1 + TCOOFF = 0x0 + TCOON = 0x1 TCP_CONGESTION = 0xd TCP_CORK = 0x3 TCP_DEFER_ACCEPT = 0x9 @@ -1297,14 +1337,32 @@ const ( TCP_SYNCNT = 0x7 TCP_WINDOW_CLAMP = 0xa TCSAFLUSH = 0x2 + TCSBRK = 0x5409 + TCSBRKP = 0x5425 + TCSETA = 0x5406 + TCSETAF = 0x5408 + TCSETAW = 0x5407 + TCSETS = 0x5402 + TCSETS2 = 0x402c542b + TCSETSF = 0x5404 + TCSETSF2 = 0x402c542d + TCSETSW = 0x5403 + TCSETSW2 = 0x402c542c + TCSETX = 0x5433 + TCSETXF = 0x5434 + TCSETXW = 0x5435 + TCXONC = 0x540a TIOCCBRK = 0x5428 TIOCCONS = 0x541d TIOCEXCL = 0x540c TIOCGDEV = 0x80045432 TIOCGETD = 0x5424 + TIOCGEXCL = 0x80045440 TIOCGICOUNT = 0x545d TIOCGLCKTRMIOS = 0x5456 TIOCGPGRP = 0x540f + TIOCGPKT = 0x80045438 + TIOCGPTLCK = 0x80045439 TIOCGPTN = 0x80045430 TIOCGRS485 = 0x542e TIOCGSERIAL = 0x541e @@ -1410,6 +1468,8 @@ const ( WORDSIZE = 0x40 WSTOPPED = 0x2 WUNTRACED = 0x2 + XCASE = 0x4 + XTABS = 0x1800 ) // Errors diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_arm.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_arm.go index 7f57070a0d..f036758f92 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_arm.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -1,6 +1,8 @@ // mkerrors.sh // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build arm,linux + // Created by cgo -godefs - DO NOT EDIT // cgo -godefs -- _const.go @@ -108,6 +110,38 @@ const ( ARPHRD_TUNNEL6 = 0x301 ARPHRD_VOID = 0xffff ARPHRD_X25 = 0x10f + B0 = 0x0 + B1000000 = 0x1008 + B110 = 0x3 + B115200 = 0x1002 + B1152000 = 0x1009 + B1200 = 0x9 + B134 = 0x4 + B150 = 0x5 + B1500000 = 0x100a + B1800 = 0xa + B19200 = 0xe + B200 = 0x6 + B2000000 = 0x100b + B230400 = 0x1003 + B2400 = 0xb + B2500000 = 0x100c + B300 = 0x7 + B3000000 = 0x100d + B3500000 = 0x100e + B38400 = 0xf + B4000000 = 0x100f + B460800 = 0x1004 + B4800 = 0xc + B50 = 0x1 + B500000 = 0x1005 + B57600 = 0x1001 + B576000 = 0x1006 + B600 = 0x8 + B75 = 0x2 + B921600 = 0x1007 + B9600 = 0xd + BOTHER = 0x1000 BPF_A = 0x10 BPF_ABS = 0x20 BPF_ADD = 0x0 @@ -148,6 +182,15 @@ const ( BPF_TXA = 0x80 BPF_W = 0x0 BPF_X = 0x8 + BRKINT = 0x2 + BS0 = 0x0 + BS1 = 0x2000 + BSDLY = 0x2000 + CBAUD = 0x100f + CBAUDEX = 0x1000 + CFLUSH = 0xf + CIBAUD = 0x100f0000 + CLOCAL = 0x800 CLOCK_BOOTTIME = 0x7 CLOCK_BOOTTIME_ALARM = 0x9 CLOCK_DEFAULT = 0x0 @@ -169,6 +212,7 @@ const ( CLONE_FILES = 0x400 CLONE_FS = 0x200 CLONE_IO = 0x80000000 + CLONE_NEWCGROUP = 0x2000000 CLONE_NEWIPC = 0x8000000 CLONE_NEWNET = 0x40000000 CLONE_NEWNS = 0x20000 @@ -185,6 +229,25 @@ const ( CLONE_UNTRACED = 0x800000 CLONE_VFORK = 0x4000 CLONE_VM = 0x100 + CMSPAR = 0x40000000 + CR0 = 0x0 + CR1 = 0x200 + CR2 = 0x400 + CR3 = 0x600 + CRDLY = 0x600 + CREAD = 0x80 + CRTSCTS = 0x80000000 + CS5 = 0x0 + CS6 = 0x10 + CS7 = 0x20 + CS8 = 0x30 + CSIGNAL = 0xff + CSIZE = 0x30 + CSTART = 0x11 + CSTATUS = 0x0 + CSTOP = 0x13 + CSTOPB = 0x40 + CSUSP = 0x1a DT_BLK = 0x6 DT_CHR = 0x2 DT_DIR = 0x4 @@ -196,6 +259,13 @@ const ( DT_WHT = 0xe ELF_NGREG = 0x12 ELF_PRARGSZ = 0x50 + ECHO = 0x8 + ECHOCTL = 0x200 + ECHOE = 0x10 + ECHOK = 0x20 + ECHOKE = 0x800 + ECHONL = 0x40 + ECHOPRT = 0x400 EPOLLERR = 0x8 EPOLLET = -0x80000000 EPOLLHUP = 0x10 @@ -278,8 +348,15 @@ const ( ETH_P_WAN_PPP = 0x7 ETH_P_WCCP = 0x883e ETH_P_X25 = 0x805 + EXTA = 0xe + EXTB = 0xf + EXTPROC = 0x10000 FD_CLOEXEC = 0x1 FD_SETSIZE = 0x400 + FF0 = 0x0 + FF1 = 0x8000 + FFDLY = 0x8000 + FLUSHO = 0x1000 F_DUPFD = 0x0 F_DUPFD_CLOEXEC = 0x406 F_EXLCK = 0x4 @@ -313,7 +390,12 @@ const ( F_ULOCK = 0x0 F_UNLCK = 0x2 F_WRLCK = 0x1 + HUPCL = 0x400 + IBSHIFT = 0x10 + ICANON = 0x2 ICMPV6_FILTER = 0x1 + ICRNL = 0x100 + IEXTEN = 0x8000 IFA_F_DADFAILED = 0x8 IFA_F_DEPRECATED = 0x20 IFA_F_HOMEADDRESS = 0x10 @@ -347,6 +429,12 @@ const ( IFF_UP = 0x1 IFF_VNET_HDR = 0x4000 IFNAMSIZ = 0x10 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 IN_ACCESS = 0x1 IN_ALL_EVENTS = 0xfff IN_ATTRIB = 0x4 @@ -510,6 +598,13 @@ const ( IP_TTL = 0x2 IP_UNBLOCK_SOURCE = 0x25 IP_XFRM_POLICY = 0x11 + ISIG = 0x1 + ISTRIP = 0x20 + IUCLC = 0x200 + IUTF8 = 0x4000 + IXANY = 0x800 + IXOFF = 0x1000 + IXON = 0x400 LINUX_REBOOT_CMD_CAD_OFF = 0x0 LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef LINUX_REBOOT_CMD_HALT = 0xcdef0123 @@ -633,10 +728,13 @@ const ( NETLINK_UNUSED = 0x1 NETLINK_USERSOCK = 0x2 NETLINK_XFRM = 0x6 + NL0 = 0x0 + NL1 = 0x100 NLA_ALIGNTO = 0x4 NLA_F_NESTED = 0x8000 NLA_F_NET_BYTEORDER = 0x4000 NLA_HDRLEN = 0x4 + NLDLY = 0x100 NLMSG_ALIGNTO = 0x4 NLMSG_DONE = 0x3 NLMSG_ERROR = 0x2 @@ -656,6 +754,15 @@ const ( NLM_F_REPLACE = 0x100 NLM_F_REQUEST = 0x1 NLM_F_ROOT = 0x100 + NOFLSH = 0x80 + OCRNL = 0x8 + OFDEL = 0x80 + OFILL = 0x40 + OLCUC = 0x2 + ONLCR = 0x4 + ONLRET = 0x20 + ONOCR = 0x10 + OPOST = 0x1 O_ACCMODE = 0x3 O_APPEND = 0x400 O_ASYNC = 0x2000 @@ -672,6 +779,7 @@ const ( O_NOCTTY = 0x100 O_NOFOLLOW = 0x8000 O_NONBLOCK = 0x800 + O_PATH = 0x200000 O_RDONLY = 0x0 O_RDWR = 0x2 O_RSYNC = 0x1000 @@ -693,6 +801,10 @@ const ( PACKET_RECV_OUTPUT = 0x3 PACKET_RX_RING = 0x5 PACKET_STATISTICS = 0x6 + PARENB = 0x100 + PARMRK = 0x8 + PARODD = 0x200 + PENDIN = 0x4000 PRIO_PGRP = 0x1 PRIO_PROCESS = 0x0 PRIO_USER = 0x2 @@ -1112,9 +1224,23 @@ const ( S_IXGRP = 0x8 S_IXOTH = 0x1 S_IXUSR = 0x40 + TAB0 = 0x0 + TAB1 = 0x800 + TAB2 = 0x1000 + TAB3 = 0x1800 + TABDLY = 0x1800 + TCFLSH = 0x540b + TCGETA = 0x5405 + TCGETS = 0x5401 + TCGETS2 = 0x802c542a + TCGETX = 0x5432 TCIFLUSH = 0x0 + TCIOFF = 0x2 TCIOFLUSH = 0x2 + TCION = 0x3 TCOFLUSH = 0x1 + TCOOFF = 0x0 + TCOON = 0x1 TCP_CONGESTION = 0xd TCP_CORK = 0x3 TCP_DEFER_ACCEPT = 0x9 @@ -1133,14 +1259,33 @@ const ( TCP_QUICKACK = 0xc TCP_SYNCNT = 0x7 TCP_WINDOW_CLAMP = 0xa + TCSAFLUSH = 0x2 + TCSBRK = 0x5409 + TCSBRKP = 0x5425 + TCSETA = 0x5406 + TCSETAF = 0x5408 + TCSETAW = 0x5407 + TCSETS = 0x5402 + TCSETS2 = 0x402c542b + TCSETSF = 0x5404 + TCSETSF2 = 0x402c542d + TCSETSW = 0x5403 + TCSETSW2 = 0x402c542c + TCSETX = 0x5433 + TCSETXF = 0x5434 + TCSETXW = 0x5435 + TCXONC = 0x540a TIOCCBRK = 0x5428 TIOCCONS = 0x541d TIOCEXCL = 0x540c TIOCGDEV = 0x80045432 TIOCGETD = 0x5424 + TIOCGEXCL = 0x80045440 TIOCGICOUNT = 0x545d TIOCGLCKTRMIOS = 0x5456 TIOCGPGRP = 0x540f + TIOCGPKT = 0x80045438 + TIOCGPTLCK = 0x80045439 TIOCGPTN = 0x80045430 TIOCGRS485 = 0x542e TIOCGSERIAL = 0x541e @@ -1198,6 +1343,7 @@ const ( TIOCSTI = 0x5412 TIOCSWINSZ = 0x5414 TIOCVHANGUP = 0x5437 + TOSTOP = 0x100 TUNATTACHFILTER = 0x400854d5 TUNDETACHFILTER = 0x400854d6 TUNGETFEATURES = 0x800454cf @@ -1215,6 +1361,26 @@ const ( TUNSETSNDBUF = 0x400454d4 TUNSETTXFILTER = 0x400454d1 TUNSETVNETHDRSZ = 0x400454d8 + VDISCARD = 0xd + VEOF = 0x4 + VEOL = 0xb + VEOL2 = 0x10 + VERASE = 0x2 + VINTR = 0x0 + VKILL = 0x3 + VLNEXT = 0xf + VMIN = 0x6 + VQUIT = 0x1 + VREPRINT = 0xc + VSTART = 0x8 + VSTOP = 0x9 + VSUSP = 0xa + VSWTC = 0x7 + VT0 = 0x0 + VT1 = 0x4000 + VTDLY = 0x4000 + VTIME = 0x5 + VWERASE = 0xe WALL = 0x40000000 WCLONE = 0x80000000 WCONTINUED = 0x8 @@ -1225,6 +1391,8 @@ const ( WORDSIZE = 0x20 WSTOPPED = 0x2 WUNTRACED = 0x2 + XCASE = 0x4 + XTABS = 0x1800 ) // Errors diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_arm64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_arm64.go new file mode 100644 index 0000000000..16dcbc9cb2 --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -0,0 +1,1897 @@ +// mkerrors.sh +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build arm64,linux + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- _const.go + +package unix + +import "syscall" + +const ( + AF_ALG = 0x26 + AF_APPLETALK = 0x5 + AF_ASH = 0x12 + AF_ATMPVC = 0x8 + AF_ATMSVC = 0x14 + AF_AX25 = 0x3 + AF_BLUETOOTH = 0x1f + AF_BRIDGE = 0x7 + AF_CAIF = 0x25 + AF_CAN = 0x1d + AF_DECnet = 0xc + AF_ECONET = 0x13 + AF_FILE = 0x1 + AF_IEEE802154 = 0x24 + AF_INET = 0x2 + AF_INET6 = 0xa + AF_IPX = 0x4 + AF_IRDA = 0x17 + AF_ISDN = 0x22 + AF_IUCV = 0x20 + AF_KEY = 0xf + AF_LLC = 0x1a + AF_LOCAL = 0x1 + AF_MAX = 0x29 + AF_NETBEUI = 0xd + AF_NETLINK = 0x10 + AF_NETROM = 0x6 + AF_NFC = 0x27 + AF_PACKET = 0x11 + AF_PHONET = 0x23 + AF_PPPOX = 0x18 + AF_RDS = 0x15 + AF_ROSE = 0xb + AF_ROUTE = 0x10 + AF_RXRPC = 0x21 + AF_SECURITY = 0xe + AF_SNA = 0x16 + AF_TIPC = 0x1e + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_VSOCK = 0x28 + AF_WANPIPE = 0x19 + AF_X25 = 0x9 + ARPHRD_ADAPT = 0x108 + ARPHRD_APPLETLK = 0x8 + ARPHRD_ARCNET = 0x7 + ARPHRD_ASH = 0x30d + ARPHRD_ATM = 0x13 + ARPHRD_AX25 = 0x3 + ARPHRD_BIF = 0x307 + ARPHRD_CAIF = 0x336 + ARPHRD_CAN = 0x118 + ARPHRD_CHAOS = 0x5 + ARPHRD_CISCO = 0x201 + ARPHRD_CSLIP = 0x101 + ARPHRD_CSLIP6 = 0x103 + ARPHRD_DDCMP = 0x205 + ARPHRD_DLCI = 0xf + ARPHRD_ECONET = 0x30e + ARPHRD_EETHER = 0x2 + ARPHRD_ETHER = 0x1 + ARPHRD_EUI64 = 0x1b + ARPHRD_FCAL = 0x311 + ARPHRD_FCFABRIC = 0x313 + ARPHRD_FCPL = 0x312 + ARPHRD_FCPP = 0x310 + ARPHRD_FDDI = 0x306 + ARPHRD_FRAD = 0x302 + ARPHRD_HDLC = 0x201 + ARPHRD_HIPPI = 0x30c + ARPHRD_HWX25 = 0x110 + ARPHRD_IEEE1394 = 0x18 + ARPHRD_IEEE802 = 0x6 + ARPHRD_IEEE80211 = 0x321 + ARPHRD_IEEE80211_PRISM = 0x322 + ARPHRD_IEEE80211_RADIOTAP = 0x323 + ARPHRD_IEEE802154 = 0x324 + ARPHRD_IEEE802154_MONITOR = 0x325 + ARPHRD_IEEE802_TR = 0x320 + ARPHRD_INFINIBAND = 0x20 + ARPHRD_IP6GRE = 0x337 + ARPHRD_IPDDP = 0x309 + ARPHRD_IPGRE = 0x30a + ARPHRD_IRDA = 0x30f + ARPHRD_LAPB = 0x204 + ARPHRD_LOCALTLK = 0x305 + ARPHRD_LOOPBACK = 0x304 + ARPHRD_METRICOM = 0x17 + ARPHRD_NETLINK = 0x338 + ARPHRD_NETROM = 0x0 + ARPHRD_NONE = 0xfffe + ARPHRD_PHONET = 0x334 + ARPHRD_PHONET_PIPE = 0x335 + ARPHRD_PIMREG = 0x30b + ARPHRD_PPP = 0x200 + ARPHRD_PRONET = 0x4 + ARPHRD_RAWHDLC = 0x206 + ARPHRD_ROSE = 0x10e + ARPHRD_RSRVD = 0x104 + ARPHRD_SIT = 0x308 + ARPHRD_SKIP = 0x303 + ARPHRD_SLIP = 0x100 + ARPHRD_SLIP6 = 0x102 + ARPHRD_TUNNEL = 0x300 + ARPHRD_TUNNEL6 = 0x301 + ARPHRD_VOID = 0xffff + ARPHRD_X25 = 0x10f + B0 = 0x0 + B1000000 = 0x1008 + B110 = 0x3 + B115200 = 0x1002 + B1152000 = 0x1009 + B1200 = 0x9 + B134 = 0x4 + B150 = 0x5 + B1500000 = 0x100a + B1800 = 0xa + B19200 = 0xe + B200 = 0x6 + B2000000 = 0x100b + B230400 = 0x1003 + B2400 = 0xb + B2500000 = 0x100c + B300 = 0x7 + B3000000 = 0x100d + B3500000 = 0x100e + B38400 = 0xf + B4000000 = 0x100f + B460800 = 0x1004 + B4800 = 0xc + B50 = 0x1 + B500000 = 0x1005 + B57600 = 0x1001 + B576000 = 0x1006 + B600 = 0x8 + B75 = 0x2 + B921600 = 0x1007 + B9600 = 0xd + BOTHER = 0x1000 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXINSNS = 0x1000 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MOD = 0x90 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BPF_XOR = 0xa0 + BRKINT = 0x2 + BS0 = 0x0 + BS1 = 0x2000 + BSDLY = 0x2000 + CBAUD = 0x100f + CBAUDEX = 0x1000 + CFLUSH = 0xf + CIBAUD = 0x100f0000 + CLOCAL = 0x800 + CLOCK_BOOTTIME = 0x7 + CLOCK_BOOTTIME_ALARM = 0x9 + CLOCK_DEFAULT = 0x0 + CLOCK_EXT = 0x1 + CLOCK_INT = 0x2 + CLOCK_MONOTONIC = 0x1 + CLOCK_MONOTONIC_COARSE = 0x6 + CLOCK_MONOTONIC_RAW = 0x4 + CLOCK_PROCESS_CPUTIME_ID = 0x2 + CLOCK_REALTIME = 0x0 + CLOCK_REALTIME_ALARM = 0x8 + CLOCK_REALTIME_COARSE = 0x5 + CLOCK_THREAD_CPUTIME_ID = 0x3 + CLOCK_TXFROMRX = 0x4 + CLOCK_TXINT = 0x3 + CLONE_CHILD_CLEARTID = 0x200000 + CLONE_CHILD_SETTID = 0x1000000 + CLONE_DETACHED = 0x400000 + CLONE_FILES = 0x400 + CLONE_FS = 0x200 + CLONE_IO = 0x80000000 + CLONE_NEWCGROUP = 0x2000000 + CLONE_NEWIPC = 0x8000000 + CLONE_NEWNET = 0x40000000 + CLONE_NEWNS = 0x20000 + CLONE_NEWPID = 0x20000000 + CLONE_NEWUSER = 0x10000000 + CLONE_NEWUTS = 0x4000000 + CLONE_PARENT = 0x8000 + CLONE_PARENT_SETTID = 0x100000 + CLONE_PTRACE = 0x2000 + CLONE_SETTLS = 0x80000 + CLONE_SIGHAND = 0x800 + CLONE_SYSVSEM = 0x40000 + CLONE_THREAD = 0x10000 + CLONE_UNTRACED = 0x800000 + CLONE_VFORK = 0x4000 + CLONE_VM = 0x100 + CMSPAR = 0x40000000 + CR0 = 0x0 + CR1 = 0x200 + CR2 = 0x400 + CR3 = 0x600 + CRDLY = 0x600 + CREAD = 0x80 + CRTSCTS = 0x80000000 + CS5 = 0x0 + CS6 = 0x10 + CS7 = 0x20 + CS8 = 0x30 + CSIGNAL = 0xff + CSIZE = 0x30 + CSTART = 0x11 + CSTATUS = 0x0 + CSTOP = 0x13 + CSTOPB = 0x40 + CSUSP = 0x1a + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x200 + ECHOE = 0x10 + ECHOK = 0x20 + ECHOKE = 0x800 + ECHONL = 0x40 + ECHOPRT = 0x400 + ELF_NGREG = 0x22 + ELF_PRARGSZ = 0x50 + ENCODING_DEFAULT = 0x0 + ENCODING_FM_MARK = 0x3 + ENCODING_FM_SPACE = 0x4 + ENCODING_MANCHESTER = 0x5 + ENCODING_NRZ = 0x1 + ENCODING_NRZI = 0x2 + EPOLLERR = 0x8 + EPOLLET = 0x80000000 + EPOLLHUP = 0x10 + EPOLLIN = 0x1 + EPOLLMSG = 0x400 + EPOLLONESHOT = 0x40000000 + EPOLLOUT = 0x4 + EPOLLPRI = 0x2 + EPOLLRDBAND = 0x80 + EPOLLRDHUP = 0x2000 + EPOLLRDNORM = 0x40 + EPOLLWAKEUP = 0x20000000 + EPOLLWRBAND = 0x200 + EPOLLWRNORM = 0x100 + EPOLL_CLOEXEC = 0x80000 + EPOLL_CTL_ADD = 0x1 + EPOLL_CTL_DEL = 0x2 + EPOLL_CTL_MOD = 0x3 + ETH_P_1588 = 0x88f7 + ETH_P_8021AD = 0x88a8 + ETH_P_8021AH = 0x88e7 + ETH_P_8021Q = 0x8100 + ETH_P_802_2 = 0x4 + ETH_P_802_3 = 0x1 + ETH_P_802_3_MIN = 0x600 + ETH_P_802_EX1 = 0x88b5 + ETH_P_AARP = 0x80f3 + ETH_P_AF_IUCV = 0xfbfb + ETH_P_ALL = 0x3 + ETH_P_AOE = 0x88a2 + ETH_P_ARCNET = 0x1a + ETH_P_ARP = 0x806 + ETH_P_ATALK = 0x809b + ETH_P_ATMFATE = 0x8884 + ETH_P_ATMMPOA = 0x884c + ETH_P_AX25 = 0x2 + ETH_P_BATMAN = 0x4305 + ETH_P_BPQ = 0x8ff + ETH_P_CAIF = 0xf7 + ETH_P_CAN = 0xc + ETH_P_CANFD = 0xd + ETH_P_CONTROL = 0x16 + ETH_P_CUST = 0x6006 + ETH_P_DDCMP = 0x6 + ETH_P_DEC = 0x6000 + ETH_P_DIAG = 0x6005 + ETH_P_DNA_DL = 0x6001 + ETH_P_DNA_RC = 0x6002 + ETH_P_DNA_RT = 0x6003 + ETH_P_DSA = 0x1b + ETH_P_ECONET = 0x18 + ETH_P_EDSA = 0xdada + ETH_P_FCOE = 0x8906 + ETH_P_FIP = 0x8914 + ETH_P_HDLC = 0x19 + ETH_P_IEEE802154 = 0xf6 + ETH_P_IEEEPUP = 0xa00 + ETH_P_IEEEPUPAT = 0xa01 + ETH_P_IP = 0x800 + ETH_P_IPV6 = 0x86dd + ETH_P_IPX = 0x8137 + ETH_P_IRDA = 0x17 + ETH_P_LAT = 0x6004 + ETH_P_LINK_CTL = 0x886c + ETH_P_LOCALTALK = 0x9 + ETH_P_LOOP = 0x60 + ETH_P_MOBITEX = 0x15 + ETH_P_MPLS_MC = 0x8848 + ETH_P_MPLS_UC = 0x8847 + ETH_P_MVRP = 0x88f5 + ETH_P_PAE = 0x888e + ETH_P_PAUSE = 0x8808 + ETH_P_PHONET = 0xf5 + ETH_P_PPPTALK = 0x10 + ETH_P_PPP_DISC = 0x8863 + ETH_P_PPP_MP = 0x8 + ETH_P_PPP_SES = 0x8864 + ETH_P_PRP = 0x88fb + ETH_P_PUP = 0x200 + ETH_P_PUPAT = 0x201 + ETH_P_QINQ1 = 0x9100 + ETH_P_QINQ2 = 0x9200 + ETH_P_QINQ3 = 0x9300 + ETH_P_RARP = 0x8035 + ETH_P_SCA = 0x6007 + ETH_P_SLOW = 0x8809 + ETH_P_SNAP = 0x5 + ETH_P_TDLS = 0x890d + ETH_P_TEB = 0x6558 + ETH_P_TIPC = 0x88ca + ETH_P_TRAILER = 0x1c + ETH_P_TR_802_2 = 0x11 + ETH_P_WAN_PPP = 0x7 + ETH_P_WCCP = 0x883e + ETH_P_X25 = 0x805 + EXTA = 0xe + EXTB = 0xf + EXTPROC = 0x10000 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FF0 = 0x0 + FF1 = 0x8000 + FFDLY = 0x8000 + FLUSHO = 0x1000 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x406 + F_EXLCK = 0x4 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLEASE = 0x401 + F_GETLK = 0x5 + F_GETLK64 = 0x5 + F_GETOWN = 0x9 + F_GETOWN_EX = 0x10 + F_GETPIPE_SZ = 0x408 + F_GETSIG = 0xb + F_LOCK = 0x1 + F_NOTIFY = 0x402 + F_OK = 0x0 + F_RDLCK = 0x0 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLEASE = 0x400 + F_SETLK = 0x6 + F_SETLK64 = 0x6 + F_SETLKW = 0x7 + F_SETLKW64 = 0x7 + F_SETOWN = 0x8 + F_SETOWN_EX = 0xf + F_SETPIPE_SZ = 0x407 + F_SETSIG = 0xa + F_SHLCK = 0x8 + F_TEST = 0x3 + F_TLOCK = 0x2 + F_ULOCK = 0x0 + F_UNLCK = 0x2 + F_WRLCK = 0x1 + HUPCL = 0x400 + IBSHIFT = 0x10 + ICANON = 0x2 + ICMPV6_FILTER = 0x1 + ICRNL = 0x100 + IEXTEN = 0x8000 + IFA_F_DADFAILED = 0x8 + IFA_F_DEPRECATED = 0x20 + IFA_F_HOMEADDRESS = 0x10 + IFA_F_NODAD = 0x2 + IFA_F_OPTIMISTIC = 0x4 + IFA_F_PERMANENT = 0x80 + IFA_F_SECONDARY = 0x1 + IFA_F_TEMPORARY = 0x1 + IFA_F_TENTATIVE = 0x40 + IFA_MAX = 0x7 + IFF_802_1Q_VLAN = 0x1 + IFF_ALLMULTI = 0x200 + IFF_ATTACH_QUEUE = 0x200 + IFF_AUTOMEDIA = 0x4000 + IFF_BONDING = 0x20 + IFF_BRIDGE_PORT = 0x4000 + IFF_BROADCAST = 0x2 + IFF_DEBUG = 0x4 + IFF_DETACH_QUEUE = 0x400 + IFF_DISABLE_NETPOLL = 0x1000 + IFF_DONT_BRIDGE = 0x800 + IFF_DORMANT = 0x20000 + IFF_DYNAMIC = 0x8000 + IFF_EBRIDGE = 0x2 + IFF_ECHO = 0x40000 + IFF_ISATAP = 0x80 + IFF_LIVE_ADDR_CHANGE = 0x100000 + IFF_LOOPBACK = 0x8 + IFF_LOWER_UP = 0x10000 + IFF_MACVLAN = 0x200000 + IFF_MACVLAN_PORT = 0x2000 + IFF_MASTER = 0x400 + IFF_MASTER_8023AD = 0x8 + IFF_MASTER_ALB = 0x10 + IFF_MASTER_ARPMON = 0x100 + IFF_MULTICAST = 0x1000 + IFF_MULTI_QUEUE = 0x100 + IFF_NOARP = 0x80 + IFF_NOFILTER = 0x1000 + IFF_NOTRAILERS = 0x20 + IFF_NO_PI = 0x1000 + IFF_ONE_QUEUE = 0x2000 + IFF_OVS_DATAPATH = 0x8000 + IFF_PERSIST = 0x800 + IFF_POINTOPOINT = 0x10 + IFF_PORTSEL = 0x2000 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SLAVE = 0x800 + IFF_SLAVE_INACTIVE = 0x4 + IFF_SLAVE_NEEDARP = 0x40 + IFF_SUPP_NOFCS = 0x80000 + IFF_TAP = 0x2 + IFF_TEAM_PORT = 0x40000 + IFF_TUN = 0x1 + IFF_TUN_EXCL = 0x8000 + IFF_TX_SKB_SHARING = 0x10000 + IFF_UNICAST_FLT = 0x20000 + IFF_UP = 0x1 + IFF_VNET_HDR = 0x4000 + IFF_VOLATILE = 0x70c5a + IFF_WAN_HDLC = 0x200 + IFF_XMIT_DST_RELEASE = 0x400 + IFNAMSIZ = 0x10 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_ACCESS = 0x1 + IN_ALL_EVENTS = 0xfff + IN_ATTRIB = 0x4 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLOEXEC = 0x80000 + IN_CLOSE = 0x18 + IN_CLOSE_NOWRITE = 0x10 + IN_CLOSE_WRITE = 0x8 + IN_CREATE = 0x100 + IN_DELETE = 0x200 + IN_DELETE_SELF = 0x400 + IN_DONT_FOLLOW = 0x2000000 + IN_EXCL_UNLINK = 0x4000000 + IN_IGNORED = 0x8000 + IN_ISDIR = 0x40000000 + IN_LOOPBACKNET = 0x7f + IN_MASK_ADD = 0x20000000 + IN_MODIFY = 0x2 + IN_MOVE = 0xc0 + IN_MOVED_FROM = 0x40 + IN_MOVED_TO = 0x80 + IN_MOVE_SELF = 0x800 + IN_NONBLOCK = 0x800 + IN_ONESHOT = 0x80000000 + IN_ONLYDIR = 0x1000000 + IN_OPEN = 0x20 + IN_Q_OVERFLOW = 0x4000 + IN_UNMOUNT = 0x2000 + IPPROTO_AH = 0x33 + IPPROTO_BEETPH = 0x5e + IPPROTO_COMP = 0x6c + IPPROTO_DCCP = 0x21 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_ENCAP = 0x62 + IPPROTO_ESP = 0x32 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GRE = 0x2f + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IGMP = 0x2 + IPPROTO_IP = 0x0 + IPPROTO_IPIP = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_MH = 0x87 + IPPROTO_MTP = 0x5c + IPPROTO_NONE = 0x3b + IPPROTO_PIM = 0x67 + IPPROTO_PUP = 0xc + IPPROTO_RAW = 0xff + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_SCTP = 0x84 + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_UDP = 0x11 + IPPROTO_UDPLITE = 0x88 + IPV6_2292DSTOPTS = 0x4 + IPV6_2292HOPLIMIT = 0x8 + IPV6_2292HOPOPTS = 0x3 + IPV6_2292PKTINFO = 0x2 + IPV6_2292PKTOPTIONS = 0x6 + IPV6_2292RTHDR = 0x5 + IPV6_ADDRFORM = 0x1 + IPV6_ADD_MEMBERSHIP = 0x14 + IPV6_AUTHHDR = 0xa + IPV6_CHECKSUM = 0x7 + IPV6_DROP_MEMBERSHIP = 0x15 + IPV6_DSTOPTS = 0x3b + IPV6_HOPLIMIT = 0x34 + IPV6_HOPOPTS = 0x36 + IPV6_IPSEC_POLICY = 0x22 + IPV6_JOIN_ANYCAST = 0x1b + IPV6_JOIN_GROUP = 0x14 + IPV6_LEAVE_ANYCAST = 0x1c + IPV6_LEAVE_GROUP = 0x15 + IPV6_MTU = 0x18 + IPV6_MTU_DISCOVER = 0x17 + IPV6_MULTICAST_HOPS = 0x12 + IPV6_MULTICAST_IF = 0x11 + IPV6_MULTICAST_LOOP = 0x13 + IPV6_NEXTHOP = 0x9 + IPV6_PKTINFO = 0x32 + IPV6_PMTUDISC_DO = 0x2 + IPV6_PMTUDISC_DONT = 0x0 + IPV6_PMTUDISC_PROBE = 0x3 + IPV6_PMTUDISC_WANT = 0x1 + IPV6_RECVDSTOPTS = 0x3a + IPV6_RECVERR = 0x19 + IPV6_RECVHOPLIMIT = 0x33 + IPV6_RECVHOPOPTS = 0x35 + IPV6_RECVPKTINFO = 0x31 + IPV6_RECVRTHDR = 0x38 + IPV6_RECVTCLASS = 0x42 + IPV6_ROUTER_ALERT = 0x16 + IPV6_RTHDR = 0x39 + IPV6_RTHDRDSTOPTS = 0x37 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_RXDSTOPTS = 0x3b + IPV6_RXHOPOPTS = 0x36 + IPV6_TCLASS = 0x43 + IPV6_UNICAST_HOPS = 0x10 + IPV6_V6ONLY = 0x1a + IPV6_XFRM_POLICY = 0x23 + IP_ADD_MEMBERSHIP = 0x23 + IP_ADD_SOURCE_MEMBERSHIP = 0x27 + IP_BLOCK_SOURCE = 0x26 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DROP_MEMBERSHIP = 0x24 + IP_DROP_SOURCE_MEMBERSHIP = 0x28 + IP_FREEBIND = 0xf + IP_HDRINCL = 0x3 + IP_IPSEC_POLICY = 0x10 + IP_MAXPACKET = 0xffff + IP_MAX_MEMBERSHIPS = 0x14 + IP_MF = 0x2000 + IP_MINTTL = 0x15 + IP_MSFILTER = 0x29 + IP_MSS = 0x240 + IP_MTU = 0xe + IP_MTU_DISCOVER = 0xa + IP_MULTICAST_ALL = 0x31 + IP_MULTICAST_IF = 0x20 + IP_MULTICAST_LOOP = 0x22 + IP_MULTICAST_TTL = 0x21 + IP_OFFMASK = 0x1fff + IP_OPTIONS = 0x4 + IP_ORIGDSTADDR = 0x14 + IP_PASSSEC = 0x12 + IP_PKTINFO = 0x8 + IP_PKTOPTIONS = 0x9 + IP_PMTUDISC = 0xa + IP_PMTUDISC_DO = 0x2 + IP_PMTUDISC_DONT = 0x0 + IP_PMTUDISC_PROBE = 0x3 + IP_PMTUDISC_WANT = 0x1 + IP_RECVERR = 0xb + IP_RECVOPTS = 0x6 + IP_RECVORIGDSTADDR = 0x14 + IP_RECVRETOPTS = 0x7 + IP_RECVTOS = 0xd + IP_RECVTTL = 0xc + IP_RETOPTS = 0x7 + IP_RF = 0x8000 + IP_ROUTER_ALERT = 0x5 + IP_TOS = 0x1 + IP_TRANSPARENT = 0x13 + IP_TTL = 0x2 + IP_UNBLOCK_SOURCE = 0x25 + IP_UNICAST_IF = 0x32 + IP_XFRM_POLICY = 0x11 + ISIG = 0x1 + ISTRIP = 0x20 + IUCLC = 0x200 + IUTF8 = 0x4000 + IXANY = 0x800 + IXOFF = 0x1000 + IXON = 0x400 + LINUX_REBOOT_CMD_CAD_OFF = 0x0 + LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef + LINUX_REBOOT_CMD_HALT = 0xcdef0123 + LINUX_REBOOT_CMD_KEXEC = 0x45584543 + LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc + LINUX_REBOOT_CMD_RESTART = 0x1234567 + LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4 + LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2 + LINUX_REBOOT_MAGIC1 = 0xfee1dead + LINUX_REBOOT_MAGIC2 = 0x28121969 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_DODUMP = 0x11 + MADV_DOFORK = 0xb + MADV_DONTDUMP = 0x10 + MADV_DONTFORK = 0xa + MADV_DONTNEED = 0x4 + MADV_HUGEPAGE = 0xe + MADV_HWPOISON = 0x64 + MADV_MERGEABLE = 0xc + MADV_NOHUGEPAGE = 0xf + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_REMOVE = 0x9 + MADV_SEQUENTIAL = 0x2 + MADV_UNMERGEABLE = 0xd + MADV_WILLNEED = 0x3 + MAP_ANON = 0x20 + MAP_ANONYMOUS = 0x20 + MAP_DENYWRITE = 0x800 + MAP_EXECUTABLE = 0x1000 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_GROWSDOWN = 0x100 + MAP_HUGETLB = 0x40000 + MAP_HUGE_MASK = 0x3f + MAP_HUGE_SHIFT = 0x1a + MAP_LOCKED = 0x2000 + MAP_NONBLOCK = 0x10000 + MAP_NORESERVE = 0x4000 + MAP_POPULATE = 0x8000 + MAP_PRIVATE = 0x2 + MAP_SHARED = 0x1 + MAP_STACK = 0x20000 + MAP_TYPE = 0xf + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MNT_DETACH = 0x2 + MNT_EXPIRE = 0x4 + MNT_FORCE = 0x1 + MSG_CMSG_CLOEXEC = 0x40000000 + MSG_CONFIRM = 0x800 + MSG_CTRUNC = 0x8 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x40 + MSG_EOR = 0x80 + MSG_ERRQUEUE = 0x2000 + MSG_FASTOPEN = 0x20000000 + MSG_FIN = 0x200 + MSG_MORE = 0x8000 + MSG_NOSIGNAL = 0x4000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_PROXY = 0x10 + MSG_RST = 0x1000 + MSG_SYN = 0x400 + MSG_TRUNC = 0x20 + MSG_TRYHARD = 0x4 + MSG_WAITALL = 0x100 + MSG_WAITFORONE = 0x10000 + MS_ACTIVE = 0x40000000 + MS_ASYNC = 0x1 + MS_BIND = 0x1000 + MS_DIRSYNC = 0x80 + MS_INVALIDATE = 0x2 + MS_I_VERSION = 0x800000 + MS_KERNMOUNT = 0x400000 + MS_MANDLOCK = 0x40 + MS_MGC_MSK = 0xffff0000 + MS_MGC_VAL = 0xc0ed0000 + MS_MOVE = 0x2000 + MS_NOATIME = 0x400 + MS_NODEV = 0x4 + MS_NODIRATIME = 0x800 + MS_NOEXEC = 0x8 + MS_NOSUID = 0x2 + MS_NOUSER = -0x80000000 + MS_POSIXACL = 0x10000 + MS_PRIVATE = 0x40000 + MS_RDONLY = 0x1 + MS_REC = 0x4000 + MS_RELATIME = 0x200000 + MS_REMOUNT = 0x20 + MS_RMT_MASK = 0x800051 + MS_SHARED = 0x100000 + MS_SILENT = 0x8000 + MS_SLAVE = 0x80000 + MS_STRICTATIME = 0x1000000 + MS_SYNC = 0x4 + MS_SYNCHRONOUS = 0x10 + MS_UNBINDABLE = 0x20000 + NAME_MAX = 0xff + NETLINK_ADD_MEMBERSHIP = 0x1 + NETLINK_AUDIT = 0x9 + NETLINK_BROADCAST_ERROR = 0x4 + NETLINK_CONNECTOR = 0xb + NETLINK_CRYPTO = 0x15 + NETLINK_DNRTMSG = 0xe + NETLINK_DROP_MEMBERSHIP = 0x2 + NETLINK_ECRYPTFS = 0x13 + NETLINK_FIB_LOOKUP = 0xa + NETLINK_FIREWALL = 0x3 + NETLINK_GENERIC = 0x10 + NETLINK_INET_DIAG = 0x4 + NETLINK_IP6_FW = 0xd + NETLINK_ISCSI = 0x8 + NETLINK_KOBJECT_UEVENT = 0xf + NETLINK_NETFILTER = 0xc + NETLINK_NFLOG = 0x5 + NETLINK_NO_ENOBUFS = 0x5 + NETLINK_PKTINFO = 0x3 + NETLINK_RDMA = 0x14 + NETLINK_ROUTE = 0x0 + NETLINK_RX_RING = 0x6 + NETLINK_SCSITRANSPORT = 0x12 + NETLINK_SELINUX = 0x7 + NETLINK_SOCK_DIAG = 0x4 + NETLINK_TX_RING = 0x7 + NETLINK_UNUSED = 0x1 + NETLINK_USERSOCK = 0x2 + NETLINK_XFRM = 0x6 + NL0 = 0x0 + NL1 = 0x100 + NLA_ALIGNTO = 0x4 + NLA_F_NESTED = 0x8000 + NLA_F_NET_BYTEORDER = 0x4000 + NLA_HDRLEN = 0x4 + NLDLY = 0x100 + NLMSG_ALIGNTO = 0x4 + NLMSG_DONE = 0x3 + NLMSG_ERROR = 0x2 + NLMSG_HDRLEN = 0x10 + NLMSG_MIN_TYPE = 0x10 + NLMSG_NOOP = 0x1 + NLMSG_OVERRUN = 0x4 + NLM_F_ACK = 0x4 + NLM_F_APPEND = 0x800 + NLM_F_ATOMIC = 0x400 + NLM_F_CREATE = 0x400 + NLM_F_DUMP = 0x300 + NLM_F_DUMP_INTR = 0x10 + NLM_F_ECHO = 0x8 + NLM_F_EXCL = 0x200 + NLM_F_MATCH = 0x200 + NLM_F_MULTI = 0x2 + NLM_F_REPLACE = 0x100 + NLM_F_REQUEST = 0x1 + NLM_F_ROOT = 0x100 + NOFLSH = 0x80 + OCRNL = 0x8 + OFDEL = 0x80 + OFILL = 0x40 + OLCUC = 0x2 + ONLCR = 0x4 + ONLRET = 0x20 + ONOCR = 0x10 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_APPEND = 0x400 + O_ASYNC = 0x2000 + O_CLOEXEC = 0x80000 + O_CREAT = 0x40 + O_DIRECT = 0x10000 + O_DIRECTORY = 0x4000 + O_DSYNC = 0x1000 + O_EXCL = 0x80 + O_FSYNC = 0x101000 + O_LARGEFILE = 0x0 + O_NDELAY = 0x800 + O_NOATIME = 0x40000 + O_NOCTTY = 0x100 + O_NOFOLLOW = 0x8000 + O_NONBLOCK = 0x800 + O_PATH = 0x200000 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_RSYNC = 0x101000 + O_SYNC = 0x101000 + O_TMPFILE = 0x410000 + O_TRUNC = 0x200 + O_WRONLY = 0x1 + PACKET_ADD_MEMBERSHIP = 0x1 + PACKET_AUXDATA = 0x8 + PACKET_BROADCAST = 0x1 + PACKET_COPY_THRESH = 0x7 + PACKET_DROP_MEMBERSHIP = 0x2 + PACKET_FANOUT = 0x12 + PACKET_FANOUT_CPU = 0x2 + PACKET_FANOUT_FLAG_DEFRAG = 0x8000 + PACKET_FANOUT_FLAG_ROLLOVER = 0x1000 + PACKET_FANOUT_HASH = 0x0 + PACKET_FANOUT_LB = 0x1 + PACKET_FANOUT_RND = 0x4 + PACKET_FANOUT_ROLLOVER = 0x3 + PACKET_FASTROUTE = 0x6 + PACKET_HDRLEN = 0xb + PACKET_HOST = 0x0 + PACKET_LOOPBACK = 0x5 + PACKET_LOSS = 0xe + PACKET_MR_ALLMULTI = 0x2 + PACKET_MR_MULTICAST = 0x0 + PACKET_MR_PROMISC = 0x1 + PACKET_MR_UNICAST = 0x3 + PACKET_MULTICAST = 0x2 + PACKET_ORIGDEV = 0x9 + PACKET_OTHERHOST = 0x3 + PACKET_OUTGOING = 0x4 + PACKET_RECV_OUTPUT = 0x3 + PACKET_RESERVE = 0xc + PACKET_RX_RING = 0x5 + PACKET_STATISTICS = 0x6 + PACKET_TIMESTAMP = 0x11 + PACKET_TX_HAS_OFF = 0x13 + PACKET_TX_RING = 0xd + PACKET_TX_TIMESTAMP = 0x10 + PACKET_VERSION = 0xa + PACKET_VNET_HDR = 0xf + PARENB = 0x100 + PARITY_CRC16_PR0 = 0x2 + PARITY_CRC16_PR0_CCITT = 0x4 + PARITY_CRC16_PR1 = 0x3 + PARITY_CRC16_PR1_CCITT = 0x5 + PARITY_CRC32_PR0_CCITT = 0x6 + PARITY_CRC32_PR1_CCITT = 0x7 + PARITY_DEFAULT = 0x0 + PARITY_NONE = 0x1 + PARMRK = 0x8 + PARODD = 0x200 + PENDIN = 0x4000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_GROWSDOWN = 0x1000000 + PROT_GROWSUP = 0x2000000 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + PR_CAPBSET_DROP = 0x18 + PR_CAPBSET_READ = 0x17 + PR_ENDIAN_BIG = 0x0 + PR_ENDIAN_LITTLE = 0x1 + PR_ENDIAN_PPC_LITTLE = 0x2 + PR_FPEMU_NOPRINT = 0x1 + PR_FPEMU_SIGFPE = 0x2 + PR_FP_EXC_ASYNC = 0x2 + PR_FP_EXC_DISABLED = 0x0 + PR_FP_EXC_DIV = 0x10000 + PR_FP_EXC_INV = 0x100000 + PR_FP_EXC_NONRECOV = 0x1 + PR_FP_EXC_OVF = 0x20000 + PR_FP_EXC_PRECISE = 0x3 + PR_FP_EXC_RES = 0x80000 + PR_FP_EXC_SW_ENABLE = 0x80 + PR_FP_EXC_UND = 0x40000 + PR_GET_CHILD_SUBREAPER = 0x25 + PR_GET_DUMPABLE = 0x3 + PR_GET_ENDIAN = 0x13 + PR_GET_FPEMU = 0x9 + PR_GET_FPEXC = 0xb + PR_GET_KEEPCAPS = 0x7 + PR_GET_NAME = 0x10 + PR_GET_NO_NEW_PRIVS = 0x27 + PR_GET_PDEATHSIG = 0x2 + PR_GET_SECCOMP = 0x15 + PR_GET_SECUREBITS = 0x1b + PR_GET_TID_ADDRESS = 0x28 + PR_GET_TIMERSLACK = 0x1e + PR_GET_TIMING = 0xd + PR_GET_TSC = 0x19 + PR_GET_UNALIGN = 0x5 + PR_MCE_KILL = 0x21 + PR_MCE_KILL_CLEAR = 0x0 + PR_MCE_KILL_DEFAULT = 0x2 + PR_MCE_KILL_EARLY = 0x1 + PR_MCE_KILL_GET = 0x22 + PR_MCE_KILL_LATE = 0x0 + PR_MCE_KILL_SET = 0x1 + PR_SET_CHILD_SUBREAPER = 0x24 + PR_SET_DUMPABLE = 0x4 + PR_SET_ENDIAN = 0x14 + PR_SET_FPEMU = 0xa + PR_SET_FPEXC = 0xc + PR_SET_KEEPCAPS = 0x8 + PR_SET_MM = 0x23 + PR_SET_MM_ARG_END = 0x9 + PR_SET_MM_ARG_START = 0x8 + PR_SET_MM_AUXV = 0xc + PR_SET_MM_BRK = 0x7 + PR_SET_MM_END_CODE = 0x2 + PR_SET_MM_END_DATA = 0x4 + PR_SET_MM_ENV_END = 0xb + PR_SET_MM_ENV_START = 0xa + PR_SET_MM_EXE_FILE = 0xd + PR_SET_MM_START_BRK = 0x6 + PR_SET_MM_START_CODE = 0x1 + PR_SET_MM_START_DATA = 0x3 + PR_SET_MM_START_STACK = 0x5 + PR_SET_NAME = 0xf + PR_SET_NO_NEW_PRIVS = 0x26 + PR_SET_PDEATHSIG = 0x1 + PR_SET_PTRACER = 0x59616d61 + PR_SET_PTRACER_ANY = -0x1 + PR_SET_SECCOMP = 0x16 + PR_SET_SECUREBITS = 0x1c + PR_SET_TIMERSLACK = 0x1d + PR_SET_TIMING = 0xe + PR_SET_TSC = 0x1a + PR_SET_UNALIGN = 0x6 + PR_TASK_PERF_EVENTS_DISABLE = 0x1f + PR_TASK_PERF_EVENTS_ENABLE = 0x20 + PR_TIMING_STATISTICAL = 0x0 + PR_TIMING_TIMESTAMP = 0x1 + PR_TSC_ENABLE = 0x1 + PR_TSC_SIGSEGV = 0x2 + PR_UNALIGN_NOPRINT = 0x1 + PR_UNALIGN_SIGBUS = 0x2 + PTRACE_ATTACH = 0x10 + PTRACE_CONT = 0x7 + PTRACE_DETACH = 0x11 + PTRACE_EVENT_CLONE = 0x3 + PTRACE_EVENT_EXEC = 0x4 + PTRACE_EVENT_EXIT = 0x6 + PTRACE_EVENT_FORK = 0x1 + PTRACE_EVENT_SECCOMP = 0x7 + PTRACE_EVENT_STOP = 0x80 + PTRACE_EVENT_VFORK = 0x2 + PTRACE_EVENT_VFORK_DONE = 0x5 + PTRACE_GETEVENTMSG = 0x4201 + PTRACE_GETREGS = 0xc + PTRACE_GETREGSET = 0x4204 + PTRACE_GETSIGINFO = 0x4202 + PTRACE_GETSIGMASK = 0x420a + PTRACE_INTERRUPT = 0x4207 + PTRACE_KILL = 0x8 + PTRACE_LISTEN = 0x4208 + PTRACE_O_EXITKILL = 0x100000 + PTRACE_O_MASK = 0x1000ff + PTRACE_O_TRACECLONE = 0x8 + PTRACE_O_TRACEEXEC = 0x10 + PTRACE_O_TRACEEXIT = 0x40 + PTRACE_O_TRACEFORK = 0x2 + PTRACE_O_TRACESECCOMP = 0x80 + PTRACE_O_TRACESYSGOOD = 0x1 + PTRACE_O_TRACEVFORK = 0x4 + PTRACE_O_TRACEVFORKDONE = 0x20 + PTRACE_PEEKDATA = 0x2 + PTRACE_PEEKSIGINFO = 0x4209 + PTRACE_PEEKSIGINFO_SHARED = 0x1 + PTRACE_PEEKTEXT = 0x1 + PTRACE_PEEKUSR = 0x3 + PTRACE_POKEDATA = 0x5 + PTRACE_POKETEXT = 0x4 + PTRACE_POKEUSR = 0x6 + PTRACE_SEIZE = 0x4206 + PTRACE_SETOPTIONS = 0x4200 + PTRACE_SETREGS = 0xd + PTRACE_SETREGSET = 0x4205 + PTRACE_SETSIGINFO = 0x4203 + PTRACE_SETSIGMASK = 0x420b + PTRACE_SINGLESTEP = 0x9 + PTRACE_SYSCALL = 0x18 + PTRACE_TRACEME = 0x0 + RLIMIT_AS = 0x9 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x7 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = -0x1 + RTAX_ADVMSS = 0x8 + RTAX_CWND = 0x7 + RTAX_FEATURES = 0xc + RTAX_FEATURE_ALLFRAG = 0x8 + RTAX_FEATURE_ECN = 0x1 + RTAX_FEATURE_SACK = 0x2 + RTAX_FEATURE_TIMESTAMP = 0x4 + RTAX_HOPLIMIT = 0xa + RTAX_INITCWND = 0xb + RTAX_INITRWND = 0xe + RTAX_LOCK = 0x1 + RTAX_MAX = 0xf + RTAX_MTU = 0x2 + RTAX_QUICKACK = 0xf + RTAX_REORDERING = 0x9 + RTAX_RTO_MIN = 0xd + RTAX_RTT = 0x4 + RTAX_RTTVAR = 0x5 + RTAX_SSTHRESH = 0x6 + RTAX_UNSPEC = 0x0 + RTAX_WINDOW = 0x3 + RTA_ALIGNTO = 0x4 + RTA_MAX = 0x11 + RTCF_DIRECTSRC = 0x4000000 + RTCF_DOREDIRECT = 0x1000000 + RTCF_LOG = 0x2000000 + RTCF_MASQ = 0x400000 + RTCF_NAT = 0x800000 + RTCF_VALVE = 0x200000 + RTF_ADDRCLASSMASK = 0xf8000000 + RTF_ADDRCONF = 0x40000 + RTF_ALLONLINK = 0x20000 + RTF_BROADCAST = 0x10000000 + RTF_CACHE = 0x1000000 + RTF_DEFAULT = 0x10000 + RTF_DYNAMIC = 0x10 + RTF_FLOW = 0x2000000 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_INTERFACE = 0x40000000 + RTF_IRTT = 0x100 + RTF_LINKRT = 0x100000 + RTF_LOCAL = 0x80000000 + RTF_MODIFIED = 0x20 + RTF_MSS = 0x40 + RTF_MTU = 0x40 + RTF_MULTICAST = 0x20000000 + RTF_NAT = 0x8000000 + RTF_NOFORWARD = 0x1000 + RTF_NONEXTHOP = 0x200000 + RTF_NOPMTUDISC = 0x4000 + RTF_POLICY = 0x4000000 + RTF_REINSTATE = 0x8 + RTF_REJECT = 0x200 + RTF_STATIC = 0x400 + RTF_THROW = 0x2000 + RTF_UP = 0x1 + RTF_WINDOW = 0x80 + RTF_XRESOLVE = 0x800 + RTM_BASE = 0x10 + RTM_DELACTION = 0x31 + RTM_DELADDR = 0x15 + RTM_DELADDRLABEL = 0x49 + RTM_DELLINK = 0x11 + RTM_DELMDB = 0x55 + RTM_DELNEIGH = 0x1d + RTM_DELQDISC = 0x25 + RTM_DELROUTE = 0x19 + RTM_DELRULE = 0x21 + RTM_DELTCLASS = 0x29 + RTM_DELTFILTER = 0x2d + RTM_F_CLONED = 0x200 + RTM_F_EQUALIZE = 0x400 + RTM_F_NOTIFY = 0x100 + RTM_F_PREFIX = 0x800 + RTM_GETACTION = 0x32 + RTM_GETADDR = 0x16 + RTM_GETADDRLABEL = 0x4a + RTM_GETANYCAST = 0x3e + RTM_GETDCB = 0x4e + RTM_GETLINK = 0x12 + RTM_GETMDB = 0x56 + RTM_GETMULTICAST = 0x3a + RTM_GETNEIGH = 0x1e + RTM_GETNEIGHTBL = 0x42 + RTM_GETNETCONF = 0x52 + RTM_GETQDISC = 0x26 + RTM_GETROUTE = 0x1a + RTM_GETRULE = 0x22 + RTM_GETTCLASS = 0x2a + RTM_GETTFILTER = 0x2e + RTM_MAX = 0x57 + RTM_NEWACTION = 0x30 + RTM_NEWADDR = 0x14 + RTM_NEWADDRLABEL = 0x48 + RTM_NEWLINK = 0x10 + RTM_NEWMDB = 0x54 + RTM_NEWNDUSEROPT = 0x44 + RTM_NEWNEIGH = 0x1c + RTM_NEWNEIGHTBL = 0x40 + RTM_NEWNETCONF = 0x50 + RTM_NEWPREFIX = 0x34 + RTM_NEWQDISC = 0x24 + RTM_NEWROUTE = 0x18 + RTM_NEWRULE = 0x20 + RTM_NEWTCLASS = 0x28 + RTM_NEWTFILTER = 0x2c + RTM_NR_FAMILIES = 0x12 + RTM_NR_MSGTYPES = 0x48 + RTM_SETDCB = 0x4f + RTM_SETLINK = 0x13 + RTM_SETNEIGHTBL = 0x43 + RTNH_ALIGNTO = 0x4 + RTNH_F_DEAD = 0x1 + RTNH_F_ONLINK = 0x4 + RTNH_F_PERVASIVE = 0x2 + RTN_MAX = 0xb + RTPROT_BIRD = 0xc + RTPROT_BOOT = 0x3 + RTPROT_DHCP = 0x10 + RTPROT_DNROUTED = 0xd + RTPROT_GATED = 0x8 + RTPROT_KERNEL = 0x2 + RTPROT_MROUTED = 0x11 + RTPROT_MRT = 0xa + RTPROT_NTK = 0xf + RTPROT_RA = 0x9 + RTPROT_REDIRECT = 0x1 + RTPROT_STATIC = 0x4 + RTPROT_UNSPEC = 0x0 + RTPROT_XORP = 0xe + RTPROT_ZEBRA = 0xb + RT_CLASS_DEFAULT = 0xfd + RT_CLASS_LOCAL = 0xff + RT_CLASS_MAIN = 0xfe + RT_CLASS_MAX = 0xff + RT_CLASS_UNSPEC = 0x0 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + RUSAGE_THREAD = 0x1 + SCM_CREDENTIALS = 0x2 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x1d + SCM_TIMESTAMPING = 0x25 + SCM_TIMESTAMPNS = 0x23 + SCM_WIFI_STATUS = 0x29 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDDLCI = 0x8980 + SIOCADDMULTI = 0x8931 + SIOCADDRT = 0x890b + SIOCATMARK = 0x8905 + SIOCDARP = 0x8953 + SIOCDELDLCI = 0x8981 + SIOCDELMULTI = 0x8932 + SIOCDELRT = 0x890c + SIOCDEVPRIVATE = 0x89f0 + SIOCDIFADDR = 0x8936 + SIOCDRARP = 0x8960 + SIOCGARP = 0x8954 + SIOCGIFADDR = 0x8915 + SIOCGIFBR = 0x8940 + SIOCGIFBRDADDR = 0x8919 + SIOCGIFCONF = 0x8912 + SIOCGIFCOUNT = 0x8938 + SIOCGIFDSTADDR = 0x8917 + SIOCGIFENCAP = 0x8925 + SIOCGIFFLAGS = 0x8913 + SIOCGIFHWADDR = 0x8927 + SIOCGIFINDEX = 0x8933 + SIOCGIFMAP = 0x8970 + SIOCGIFMEM = 0x891f + SIOCGIFMETRIC = 0x891d + SIOCGIFMTU = 0x8921 + SIOCGIFNAME = 0x8910 + SIOCGIFNETMASK = 0x891b + SIOCGIFPFLAGS = 0x8935 + SIOCGIFSLAVE = 0x8929 + SIOCGIFTXQLEN = 0x8942 + SIOCGPGRP = 0x8904 + SIOCGRARP = 0x8961 + SIOCGSTAMP = 0x8906 + SIOCGSTAMPNS = 0x8907 + SIOCPROTOPRIVATE = 0x89e0 + SIOCRTMSG = 0x890d + SIOCSARP = 0x8955 + SIOCSIFADDR = 0x8916 + SIOCSIFBR = 0x8941 + SIOCSIFBRDADDR = 0x891a + SIOCSIFDSTADDR = 0x8918 + SIOCSIFENCAP = 0x8926 + SIOCSIFFLAGS = 0x8914 + SIOCSIFHWADDR = 0x8924 + SIOCSIFHWBROADCAST = 0x8937 + SIOCSIFLINK = 0x8911 + SIOCSIFMAP = 0x8971 + SIOCSIFMEM = 0x8920 + SIOCSIFMETRIC = 0x891e + SIOCSIFMTU = 0x8922 + SIOCSIFNAME = 0x8923 + SIOCSIFNETMASK = 0x891c + SIOCSIFPFLAGS = 0x8934 + SIOCSIFSLAVE = 0x8930 + SIOCSIFTXQLEN = 0x8943 + SIOCSPGRP = 0x8902 + SIOCSRARP = 0x8962 + SOCK_CLOEXEC = 0x80000 + SOCK_DCCP = 0x6 + SOCK_DGRAM = 0x2 + SOCK_NONBLOCK = 0x800 + SOCK_PACKET = 0xa + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_AAL = 0x109 + SOL_ATM = 0x108 + SOL_DECNET = 0x105 + SOL_ICMPV6 = 0x3a + SOL_IP = 0x0 + SOL_IPV6 = 0x29 + SOL_IRDA = 0x10a + SOL_PACKET = 0x107 + SOL_RAW = 0xff + SOL_SOCKET = 0x1 + SOL_TCP = 0x6 + SOL_X25 = 0x106 + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x1e + SO_ATTACH_FILTER = 0x1a + SO_BINDTODEVICE = 0x19 + SO_BROADCAST = 0x6 + SO_BSDCOMPAT = 0xe + SO_BUSY_POLL = 0x2e + SO_DEBUG = 0x1 + SO_DETACH_FILTER = 0x1b + SO_DOMAIN = 0x27 + SO_DONTROUTE = 0x5 + SO_ERROR = 0x4 + SO_GET_FILTER = 0x1a + SO_KEEPALIVE = 0x9 + SO_LINGER = 0xd + SO_LOCK_FILTER = 0x2c + SO_MARK = 0x24 + SO_MAX_PACING_RATE = 0x2f + SO_NOFCS = 0x2b + SO_NO_CHECK = 0xb + SO_OOBINLINE = 0xa + SO_PASSCRED = 0x10 + SO_PASSSEC = 0x22 + SO_PEEK_OFF = 0x2a + SO_PEERCRED = 0x11 + SO_PEERNAME = 0x1c + SO_PEERSEC = 0x1f + SO_PRIORITY = 0xc + SO_PROTOCOL = 0x26 + SO_RCVBUF = 0x8 + SO_RCVBUFFORCE = 0x21 + SO_RCVLOWAT = 0x12 + SO_RCVTIMEO = 0x14 + SO_REUSEADDR = 0x2 + SO_REUSEPORT = 0xf + SO_RXQ_OVFL = 0x28 + SO_SECURITY_AUTHENTICATION = 0x16 + SO_SECURITY_ENCRYPTION_NETWORK = 0x18 + SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17 + SO_SELECT_ERR_QUEUE = 0x2d + SO_SNDBUF = 0x7 + SO_SNDBUFFORCE = 0x20 + SO_SNDLOWAT = 0x13 + SO_SNDTIMEO = 0x15 + SO_TIMESTAMP = 0x1d + SO_TIMESTAMPING = 0x25 + SO_TIMESTAMPNS = 0x23 + SO_TYPE = 0x3 + SO_WIFI_STATUS = 0x29 + S_BLKSIZE = 0x200 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + TAB0 = 0x0 + TAB1 = 0x800 + TAB2 = 0x1000 + TAB3 = 0x1800 + TABDLY = 0x1800 + TCFLSH = 0x540b + TCGETA = 0x5405 + TCGETS = 0x5401 + TCGETS2 = 0x802c542a + TCGETX = 0x5432 + TCIFLUSH = 0x0 + TCIOFF = 0x2 + TCIOFLUSH = 0x2 + TCION = 0x3 + TCOFLUSH = 0x1 + TCOOFF = 0x0 + TCOON = 0x1 + TCP_CONGESTION = 0xd + TCP_COOKIE_IN_ALWAYS = 0x1 + TCP_COOKIE_MAX = 0x10 + TCP_COOKIE_MIN = 0x8 + TCP_COOKIE_OUT_NEVER = 0x2 + TCP_COOKIE_PAIR_SIZE = 0x20 + TCP_COOKIE_TRANSACTIONS = 0xf + TCP_CORK = 0x3 + TCP_DEFER_ACCEPT = 0x9 + TCP_FASTOPEN = 0x17 + TCP_INFO = 0xb + TCP_KEEPCNT = 0x6 + TCP_KEEPIDLE = 0x4 + TCP_KEEPINTVL = 0x5 + TCP_LINGER2 = 0x8 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0xe + TCP_MD5SIG_MAXKEYLEN = 0x50 + TCP_MSS = 0x200 + TCP_MSS_DEFAULT = 0x218 + TCP_MSS_DESIRED = 0x4c4 + TCP_NODELAY = 0x1 + TCP_QUEUE_SEQ = 0x15 + TCP_QUICKACK = 0xc + TCP_REPAIR = 0x13 + TCP_REPAIR_OPTIONS = 0x16 + TCP_REPAIR_QUEUE = 0x14 + TCP_SYNCNT = 0x7 + TCP_S_DATA_IN = 0x4 + TCP_S_DATA_OUT = 0x8 + TCP_THIN_DUPACK = 0x11 + TCP_THIN_LINEAR_TIMEOUTS = 0x10 + TCP_TIMESTAMP = 0x18 + TCP_USER_TIMEOUT = 0x12 + TCP_WINDOW_CLAMP = 0xa + TCSAFLUSH = 0x2 + TCSBRK = 0x5409 + TCSBRKP = 0x5425 + TCSETA = 0x5406 + TCSETAF = 0x5408 + TCSETAW = 0x5407 + TCSETS = 0x5402 + TCSETS2 = 0x402c542b + TCSETSF = 0x5404 + TCSETSF2 = 0x402c542d + TCSETSW = 0x5403 + TCSETSW2 = 0x402c542c + TCSETX = 0x5433 + TCSETXF = 0x5434 + TCSETXW = 0x5435 + TCXONC = 0x540a + TIOCCBRK = 0x5428 + TIOCCONS = 0x541d + TIOCEXCL = 0x540c + TIOCGDEV = 0x80045432 + TIOCGETD = 0x5424 + TIOCGEXCL = 0x80045440 + TIOCGICOUNT = 0x545d + TIOCGLCKTRMIOS = 0x5456 + TIOCGPGRP = 0x540f + TIOCGPKT = 0x80045438 + TIOCGPTLCK = 0x80045439 + TIOCGPTN = 0x80045430 + TIOCGRS485 = 0x542e + TIOCGSERIAL = 0x541e + TIOCGSID = 0x5429 + TIOCGSOFTCAR = 0x5419 + TIOCGWINSZ = 0x5413 + TIOCINQ = 0x541b + TIOCLINUX = 0x541c + TIOCMBIC = 0x5417 + TIOCMBIS = 0x5416 + TIOCMGET = 0x5415 + TIOCMIWAIT = 0x545c + TIOCMSET = 0x5418 + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x5422 + TIOCNXCL = 0x540d + TIOCOUTQ = 0x5411 + TIOCPKT = 0x5420 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCSBRK = 0x5427 + TIOCSCTTY = 0x540e + TIOCSERCONFIG = 0x5453 + TIOCSERGETLSR = 0x5459 + TIOCSERGETMULTI = 0x545a + TIOCSERGSTRUCT = 0x5458 + TIOCSERGWILD = 0x5454 + TIOCSERSETMULTI = 0x545b + TIOCSERSWILD = 0x5455 + TIOCSER_TEMT = 0x1 + TIOCSETD = 0x5423 + TIOCSIG = 0x40045436 + TIOCSLCKTRMIOS = 0x5457 + TIOCSPGRP = 0x5410 + TIOCSPTLCK = 0x40045431 + TIOCSRS485 = 0x542f + TIOCSSERIAL = 0x541f + TIOCSSOFTCAR = 0x541a + TIOCSTI = 0x5412 + TIOCSWINSZ = 0x5414 + TIOCVHANGUP = 0x5437 + TOSTOP = 0x100 + TUNATTACHFILTER = 0x401054d5 + TUNDETACHFILTER = 0x401054d6 + TUNGETFEATURES = 0x800454cf + TUNGETFILTER = 0x801054db + TUNGETIFF = 0x800454d2 + TUNGETSNDBUF = 0x800454d3 + TUNGETVNETHDRSZ = 0x800454d7 + TUNSETDEBUG = 0x400454c9 + TUNSETGROUP = 0x400454ce + TUNSETIFF = 0x400454ca + TUNSETIFINDEX = 0x400454da + TUNSETLINK = 0x400454cd + TUNSETNOCSUM = 0x400454c8 + TUNSETOFFLOAD = 0x400454d0 + TUNSETOWNER = 0x400454cc + TUNSETPERSIST = 0x400454cb + TUNSETQUEUE = 0x400454d9 + TUNSETSNDBUF = 0x400454d4 + TUNSETTXFILTER = 0x400454d1 + TUNSETVNETHDRSZ = 0x400454d8 + VDISCARD = 0xd + VEOF = 0x4 + VEOL = 0xb + VEOL2 = 0x10 + VERASE = 0x2 + VINTR = 0x0 + VKILL = 0x3 + VLNEXT = 0xf + VMIN = 0x6 + VQUIT = 0x1 + VREPRINT = 0xc + VSTART = 0x8 + VSTOP = 0x9 + VSUSP = 0xa + VSWTC = 0x7 + VT0 = 0x0 + VT1 = 0x4000 + VTDLY = 0x4000 + VTIME = 0x5 + VWERASE = 0xe + WALL = 0x40000000 + WCLONE = 0x80000000 + WCONTINUED = 0x8 + WEXITED = 0x4 + WNOHANG = 0x1 + WNOTHREAD = 0x20000000 + WNOWAIT = 0x1000000 + WORDSIZE = 0x40 + WSTOPPED = 0x2 + WUNTRACED = 0x2 + XCASE = 0x4 + XTABS = 0x1800 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x62) + EADDRNOTAVAIL = syscall.Errno(0x63) + EADV = syscall.Errno(0x44) + EAFNOSUPPORT = syscall.Errno(0x61) + EAGAIN = syscall.Errno(0xb) + EALREADY = syscall.Errno(0x72) + EBADE = syscall.Errno(0x34) + EBADF = syscall.Errno(0x9) + EBADFD = syscall.Errno(0x4d) + EBADMSG = syscall.Errno(0x4a) + EBADR = syscall.Errno(0x35) + EBADRQC = syscall.Errno(0x38) + EBADSLT = syscall.Errno(0x39) + EBFONT = syscall.Errno(0x3b) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x7d) + ECHILD = syscall.Errno(0xa) + ECHRNG = syscall.Errno(0x2c) + ECOMM = syscall.Errno(0x46) + ECONNABORTED = syscall.Errno(0x67) + ECONNREFUSED = syscall.Errno(0x6f) + ECONNRESET = syscall.Errno(0x68) + EDEADLK = syscall.Errno(0x23) + EDEADLOCK = syscall.Errno(0x23) + EDESTADDRREQ = syscall.Errno(0x59) + EDOM = syscall.Errno(0x21) + EDOTDOT = syscall.Errno(0x49) + EDQUOT = syscall.Errno(0x7a) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EHOSTDOWN = syscall.Errno(0x70) + EHOSTUNREACH = syscall.Errno(0x71) + EHWPOISON = syscall.Errno(0x85) + EIDRM = syscall.Errno(0x2b) + EILSEQ = syscall.Errno(0x54) + EINPROGRESS = syscall.Errno(0x73) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x6a) + EISDIR = syscall.Errno(0x15) + EISNAM = syscall.Errno(0x78) + EKEYEXPIRED = syscall.Errno(0x7f) + EKEYREJECTED = syscall.Errno(0x81) + EKEYREVOKED = syscall.Errno(0x80) + EL2HLT = syscall.Errno(0x33) + EL2NSYNC = syscall.Errno(0x2d) + EL3HLT = syscall.Errno(0x2e) + EL3RST = syscall.Errno(0x2f) + ELIBACC = syscall.Errno(0x4f) + ELIBBAD = syscall.Errno(0x50) + ELIBEXEC = syscall.Errno(0x53) + ELIBMAX = syscall.Errno(0x52) + ELIBSCN = syscall.Errno(0x51) + ELNRNG = syscall.Errno(0x30) + ELOOP = syscall.Errno(0x28) + EMEDIUMTYPE = syscall.Errno(0x7c) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x5a) + EMULTIHOP = syscall.Errno(0x48) + ENAMETOOLONG = syscall.Errno(0x24) + ENAVAIL = syscall.Errno(0x77) + ENETDOWN = syscall.Errno(0x64) + ENETRESET = syscall.Errno(0x66) + ENETUNREACH = syscall.Errno(0x65) + ENFILE = syscall.Errno(0x17) + ENOANO = syscall.Errno(0x37) + ENOBUFS = syscall.Errno(0x69) + ENOCSI = syscall.Errno(0x32) + ENODATA = syscall.Errno(0x3d) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOKEY = syscall.Errno(0x7e) + ENOLCK = syscall.Errno(0x25) + ENOLINK = syscall.Errno(0x43) + ENOMEDIUM = syscall.Errno(0x7b) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x2a) + ENONET = syscall.Errno(0x40) + ENOPKG = syscall.Errno(0x41) + ENOPROTOOPT = syscall.Errno(0x5c) + ENOSPC = syscall.Errno(0x1c) + ENOSR = syscall.Errno(0x3f) + ENOSTR = syscall.Errno(0x3c) + ENOSYS = syscall.Errno(0x26) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x6b) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x27) + ENOTNAM = syscall.Errno(0x76) + ENOTRECOVERABLE = syscall.Errno(0x83) + ENOTSOCK = syscall.Errno(0x58) + ENOTSUP = syscall.Errno(0x5f) + ENOTTY = syscall.Errno(0x19) + ENOTUNIQ = syscall.Errno(0x4c) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x5f) + EOVERFLOW = syscall.Errno(0x4b) + EOWNERDEAD = syscall.Errno(0x82) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x60) + EPIPE = syscall.Errno(0x20) + EPROTO = syscall.Errno(0x47) + EPROTONOSUPPORT = syscall.Errno(0x5d) + EPROTOTYPE = syscall.Errno(0x5b) + ERANGE = syscall.Errno(0x22) + EREMCHG = syscall.Errno(0x4e) + EREMOTE = syscall.Errno(0x42) + EREMOTEIO = syscall.Errno(0x79) + ERESTART = syscall.Errno(0x55) + ERFKILL = syscall.Errno(0x84) + EROFS = syscall.Errno(0x1e) + ESHUTDOWN = syscall.Errno(0x6c) + ESOCKTNOSUPPORT = syscall.Errno(0x5e) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESRMNT = syscall.Errno(0x45) + ESTALE = syscall.Errno(0x74) + ESTRPIPE = syscall.Errno(0x56) + ETIME = syscall.Errno(0x3e) + ETIMEDOUT = syscall.Errno(0x6e) + ETOOMANYREFS = syscall.Errno(0x6d) + ETXTBSY = syscall.Errno(0x1a) + EUCLEAN = syscall.Errno(0x75) + EUNATCH = syscall.Errno(0x31) + EUSERS = syscall.Errno(0x57) + EWOULDBLOCK = syscall.Errno(0xb) + EXDEV = syscall.Errno(0x12) + EXFULL = syscall.Errno(0x36) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0x7) + SIGCHLD = syscall.Signal(0x11) + SIGCLD = syscall.Signal(0x11) + SIGCONT = syscall.Signal(0x12) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x1d) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPOLL = syscall.Signal(0x1d) + SIGPROF = syscall.Signal(0x1b) + SIGPWR = syscall.Signal(0x1e) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTKFLT = syscall.Signal(0x10) + SIGSTOP = syscall.Signal(0x13) + SIGSYS = syscall.Signal(0x1f) + SIGTERM = syscall.Signal(0xf) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x14) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGUNUSED = syscall.Signal(0x1f) + SIGURG = syscall.Signal(0x17) + SIGUSR1 = syscall.Signal(0xa) + SIGUSR2 = syscall.Signal(0xc) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "no such device or address", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource temporarily unavailable", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device or resource busy", + 17: "file exists", + 18: "invalid cross-device link", + 19: "no such device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "numerical result out of range", + 35: "resource deadlock avoided", + 36: "file name too long", + 37: "no locks available", + 38: "function not implemented", + 39: "directory not empty", + 40: "too many levels of symbolic links", + 42: "no message of desired type", + 43: "identifier removed", + 44: "channel number out of range", + 45: "level 2 not synchronized", + 46: "level 3 halted", + 47: "level 3 reset", + 48: "link number out of range", + 49: "protocol driver not attached", + 50: "no CSI structure available", + 51: "level 2 halted", + 52: "invalid exchange", + 53: "invalid request descriptor", + 54: "exchange full", + 55: "no anode", + 56: "invalid request code", + 57: "invalid slot", + 59: "bad font file format", + 60: "device not a stream", + 61: "no data available", + 62: "timer expired", + 63: "out of streams resources", + 64: "machine is not on the network", + 65: "package not installed", + 66: "object is remote", + 67: "link has been severed", + 68: "advertise error", + 69: "srmount error", + 70: "communication error on send", + 71: "protocol error", + 72: "multihop attempted", + 73: "RFS specific error", + 74: "bad message", + 75: "value too large for defined data type", + 76: "name not unique on network", + 77: "file descriptor in bad state", + 78: "remote address changed", + 79: "can not access a needed shared library", + 80: "accessing a corrupted shared library", + 81: ".lib section in a.out corrupted", + 82: "attempting to link in too many shared libraries", + 83: "cannot exec a shared library directly", + 84: "invalid or incomplete multibyte or wide character", + 85: "interrupted system call should be restarted", + 86: "streams pipe error", + 87: "too many users", + 88: "socket operation on non-socket", + 89: "destination address required", + 90: "message too long", + 91: "protocol wrong type for socket", + 92: "protocol not available", + 93: "protocol not supported", + 94: "socket type not supported", + 95: "operation not supported", + 96: "protocol family not supported", + 97: "address family not supported by protocol", + 98: "address already in use", + 99: "cannot assign requested address", + 100: "network is down", + 101: "network is unreachable", + 102: "network dropped connection on reset", + 103: "software caused connection abort", + 104: "connection reset by peer", + 105: "no buffer space available", + 106: "transport endpoint is already connected", + 107: "transport endpoint is not connected", + 108: "cannot send after transport endpoint shutdown", + 109: "too many references: cannot splice", + 110: "connection timed out", + 111: "connection refused", + 112: "host is down", + 113: "no route to host", + 114: "operation already in progress", + 115: "operation now in progress", + 116: "stale file handle", + 117: "structure needs cleaning", + 118: "not a XENIX named type file", + 119: "no XENIX semaphores available", + 120: "is a named type file", + 121: "remote I/O error", + 122: "disk quota exceeded", + 123: "no medium found", + 124: "wrong medium type", + 125: "operation canceled", + 126: "required key not available", + 127: "key has expired", + 128: "key has been revoked", + 129: "key was rejected by service", + 130: "owner died", + 131: "state not recoverable", + 132: "operation not possible due to RF-kill", + 133: "memory page has hardware error", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/breakpoint trap", + 6: "aborted", + 7: "bus error", + 8: "floating point exception", + 9: "killed", + 10: "user defined signal 1", + 11: "segmentation fault", + 12: "user defined signal 2", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "stack fault", + 17: "child exited", + 18: "continued", + 19: "stopped (signal)", + 20: "stopped", + 21: "stopped (tty input)", + 22: "stopped (tty output)", + 23: "urgent I/O condition", + 24: "CPU time limit exceeded", + 25: "file size limit exceeded", + 26: "virtual timer expired", + 27: "profiling timer expired", + 28: "window changed", + 29: "I/O possible", + 30: "power failure", + 31: "bad system call", +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_mips64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_mips64.go new file mode 100644 index 0000000000..36535b242d --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -0,0 +1,1917 @@ +// mkerrors.sh +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build mips64,linux + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- _const.go + +package unix + +import "syscall" + +const ( + AF_ALG = 0x26 + AF_APPLETALK = 0x5 + AF_ASH = 0x12 + AF_ATMPVC = 0x8 + AF_ATMSVC = 0x14 + AF_AX25 = 0x3 + AF_BLUETOOTH = 0x1f + AF_BRIDGE = 0x7 + AF_CAIF = 0x25 + AF_CAN = 0x1d + AF_DECnet = 0xc + AF_ECONET = 0x13 + AF_FILE = 0x1 + AF_IB = 0x1b + AF_IEEE802154 = 0x24 + AF_INET = 0x2 + AF_INET6 = 0xa + AF_IPX = 0x4 + AF_IRDA = 0x17 + AF_ISDN = 0x22 + AF_IUCV = 0x20 + AF_KEY = 0xf + AF_LLC = 0x1a + AF_LOCAL = 0x1 + AF_MAX = 0x29 + AF_MPLS = 0x1c + AF_NETBEUI = 0xd + AF_NETLINK = 0x10 + AF_NETROM = 0x6 + AF_NFC = 0x27 + AF_PACKET = 0x11 + AF_PHONET = 0x23 + AF_PPPOX = 0x18 + AF_RDS = 0x15 + AF_ROSE = 0xb + AF_ROUTE = 0x10 + AF_RXRPC = 0x21 + AF_SECURITY = 0xe + AF_SNA = 0x16 + AF_TIPC = 0x1e + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_VSOCK = 0x28 + AF_WANPIPE = 0x19 + AF_X25 = 0x9 + ARPHRD_6LOWPAN = 0x339 + ARPHRD_ADAPT = 0x108 + ARPHRD_APPLETLK = 0x8 + ARPHRD_ARCNET = 0x7 + ARPHRD_ASH = 0x30d + ARPHRD_ATM = 0x13 + ARPHRD_AX25 = 0x3 + ARPHRD_BIF = 0x307 + ARPHRD_CAIF = 0x336 + ARPHRD_CAN = 0x118 + ARPHRD_CHAOS = 0x5 + ARPHRD_CISCO = 0x201 + ARPHRD_CSLIP = 0x101 + ARPHRD_CSLIP6 = 0x103 + ARPHRD_DDCMP = 0x205 + ARPHRD_DLCI = 0xf + ARPHRD_ECONET = 0x30e + ARPHRD_EETHER = 0x2 + ARPHRD_ETHER = 0x1 + ARPHRD_EUI64 = 0x1b + ARPHRD_FCAL = 0x311 + ARPHRD_FCFABRIC = 0x313 + ARPHRD_FCPL = 0x312 + ARPHRD_FCPP = 0x310 + ARPHRD_FDDI = 0x306 + ARPHRD_FRAD = 0x302 + ARPHRD_HDLC = 0x201 + ARPHRD_HIPPI = 0x30c + ARPHRD_HWX25 = 0x110 + ARPHRD_IEEE1394 = 0x18 + ARPHRD_IEEE802 = 0x6 + ARPHRD_IEEE80211 = 0x321 + ARPHRD_IEEE80211_PRISM = 0x322 + ARPHRD_IEEE80211_RADIOTAP = 0x323 + ARPHRD_IEEE802154 = 0x324 + ARPHRD_IEEE802154_MONITOR = 0x325 + ARPHRD_IEEE802_TR = 0x320 + ARPHRD_INFINIBAND = 0x20 + ARPHRD_IP6GRE = 0x337 + ARPHRD_IPDDP = 0x309 + ARPHRD_IPGRE = 0x30a + ARPHRD_IRDA = 0x30f + ARPHRD_LAPB = 0x204 + ARPHRD_LOCALTLK = 0x305 + ARPHRD_LOOPBACK = 0x304 + ARPHRD_METRICOM = 0x17 + ARPHRD_NETLINK = 0x338 + ARPHRD_NETROM = 0x0 + ARPHRD_NONE = 0xfffe + ARPHRD_PHONET = 0x334 + ARPHRD_PHONET_PIPE = 0x335 + ARPHRD_PIMREG = 0x30b + ARPHRD_PPP = 0x200 + ARPHRD_PRONET = 0x4 + ARPHRD_RAWHDLC = 0x206 + ARPHRD_ROSE = 0x10e + ARPHRD_RSRVD = 0x104 + ARPHRD_SIT = 0x308 + ARPHRD_SKIP = 0x303 + ARPHRD_SLIP = 0x100 + ARPHRD_SLIP6 = 0x102 + ARPHRD_TUNNEL = 0x300 + ARPHRD_TUNNEL6 = 0x301 + ARPHRD_VOID = 0xffff + ARPHRD_X25 = 0x10f + B0 = 0x0 + B1000000 = 0x1008 + B110 = 0x3 + B115200 = 0x1002 + B1152000 = 0x1009 + B1200 = 0x9 + B134 = 0x4 + B150 = 0x5 + B1500000 = 0x100a + B1800 = 0xa + B19200 = 0xe + B200 = 0x6 + B2000000 = 0x100b + B230400 = 0x1003 + B2400 = 0xb + B2500000 = 0x100c + B300 = 0x7 + B3000000 = 0x100d + B3500000 = 0x100e + B38400 = 0xf + B4000000 = 0x100f + B460800 = 0x1004 + B4800 = 0xc + B50 = 0x1 + B500000 = 0x1005 + B57600 = 0x1001 + B576000 = 0x1006 + B600 = 0x8 + B75 = 0x2 + B921600 = 0x1007 + B9600 = 0xd + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LL_OFF = -0x200000 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXINSNS = 0x1000 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MOD = 0x90 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_NET_OFF = -0x100000 + BPF_OR = 0x40 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BPF_XOR = 0xa0 + BRKINT = 0x2 + CFLUSH = 0xf + CLOCAL = 0x800 + CLOCK_BOOTTIME = 0x7 + CLOCK_BOOTTIME_ALARM = 0x9 + CLOCK_DEFAULT = 0x0 + CLOCK_EXT = 0x1 + CLOCK_INT = 0x2 + CLOCK_MONOTONIC = 0x1 + CLOCK_MONOTONIC_COARSE = 0x6 + CLOCK_MONOTONIC_RAW = 0x4 + CLOCK_PROCESS_CPUTIME_ID = 0x2 + CLOCK_REALTIME = 0x0 + CLOCK_REALTIME_ALARM = 0x8 + CLOCK_REALTIME_COARSE = 0x5 + CLOCK_TAI = 0xb + CLOCK_THREAD_CPUTIME_ID = 0x3 + CLOCK_TXFROMRX = 0x4 + CLOCK_TXINT = 0x3 + CLONE_CHILD_CLEARTID = 0x200000 + CLONE_CHILD_SETTID = 0x1000000 + CLONE_DETACHED = 0x400000 + CLONE_FILES = 0x400 + CLONE_FS = 0x200 + CLONE_IO = 0x80000000 + CLONE_NEWCGROUP = 0x2000000 + CLONE_NEWIPC = 0x8000000 + CLONE_NEWNET = 0x40000000 + CLONE_NEWNS = 0x20000 + CLONE_NEWPID = 0x20000000 + CLONE_NEWUSER = 0x10000000 + CLONE_NEWUTS = 0x4000000 + CLONE_PARENT = 0x8000 + CLONE_PARENT_SETTID = 0x100000 + CLONE_PTRACE = 0x2000 + CLONE_SETTLS = 0x80000 + CLONE_SIGHAND = 0x800 + CLONE_SYSVSEM = 0x40000 + CLONE_THREAD = 0x10000 + CLONE_UNTRACED = 0x800000 + CLONE_VFORK = 0x4000 + CLONE_VM = 0x100 + CREAD = 0x80 + CS5 = 0x0 + CS6 = 0x10 + CS7 = 0x20 + CS8 = 0x30 + CSIGNAL = 0xff + CSIZE = 0x30 + CSTART = 0x11 + CSTATUS = 0x0 + CSTOP = 0x13 + CSTOPB = 0x40 + CSUSP = 0x1a + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x200 + ECHOE = 0x10 + ECHOK = 0x20 + ECHOKE = 0x800 + ECHONL = 0x40 + ECHOPRT = 0x400 + ENCODING_DEFAULT = 0x0 + ENCODING_FM_MARK = 0x3 + ENCODING_FM_SPACE = 0x4 + ENCODING_MANCHESTER = 0x5 + ENCODING_NRZ = 0x1 + ENCODING_NRZI = 0x2 + EPOLLERR = 0x8 + EPOLLET = 0x80000000 + EPOLLHUP = 0x10 + EPOLLIN = 0x1 + EPOLLMSG = 0x400 + EPOLLONESHOT = 0x40000000 + EPOLLOUT = 0x4 + EPOLLPRI = 0x2 + EPOLLRDBAND = 0x80 + EPOLLRDHUP = 0x2000 + EPOLLRDNORM = 0x40 + EPOLLWAKEUP = 0x20000000 + EPOLLWRBAND = 0x200 + EPOLLWRNORM = 0x100 + EPOLL_CLOEXEC = 0x80000 + EPOLL_CTL_ADD = 0x1 + EPOLL_CTL_DEL = 0x2 + EPOLL_CTL_MOD = 0x3 + ETH_P_1588 = 0x88f7 + ETH_P_8021AD = 0x88a8 + ETH_P_8021AH = 0x88e7 + ETH_P_8021Q = 0x8100 + ETH_P_80221 = 0x8917 + ETH_P_802_2 = 0x4 + ETH_P_802_3 = 0x1 + ETH_P_802_3_MIN = 0x600 + ETH_P_802_EX1 = 0x88b5 + ETH_P_AARP = 0x80f3 + ETH_P_AF_IUCV = 0xfbfb + ETH_P_ALL = 0x3 + ETH_P_AOE = 0x88a2 + ETH_P_ARCNET = 0x1a + ETH_P_ARP = 0x806 + ETH_P_ATALK = 0x809b + ETH_P_ATMFATE = 0x8884 + ETH_P_ATMMPOA = 0x884c + ETH_P_AX25 = 0x2 + ETH_P_BATMAN = 0x4305 + ETH_P_BPQ = 0x8ff + ETH_P_CAIF = 0xf7 + ETH_P_CAN = 0xc + ETH_P_CANFD = 0xd + ETH_P_CONTROL = 0x16 + ETH_P_CUST = 0x6006 + ETH_P_DDCMP = 0x6 + ETH_P_DEC = 0x6000 + ETH_P_DIAG = 0x6005 + ETH_P_DNA_DL = 0x6001 + ETH_P_DNA_RC = 0x6002 + ETH_P_DNA_RT = 0x6003 + ETH_P_DSA = 0x1b + ETH_P_ECONET = 0x18 + ETH_P_EDSA = 0xdada + ETH_P_FCOE = 0x8906 + ETH_P_FIP = 0x8914 + ETH_P_HDLC = 0x19 + ETH_P_IEEE802154 = 0xf6 + ETH_P_IEEEPUP = 0xa00 + ETH_P_IEEEPUPAT = 0xa01 + ETH_P_IP = 0x800 + ETH_P_IPV6 = 0x86dd + ETH_P_IPX = 0x8137 + ETH_P_IRDA = 0x17 + ETH_P_LAT = 0x6004 + ETH_P_LINK_CTL = 0x886c + ETH_P_LOCALTALK = 0x9 + ETH_P_LOOP = 0x60 + ETH_P_LOOPBACK = 0x9000 + ETH_P_MOBITEX = 0x15 + ETH_P_MPLS_MC = 0x8848 + ETH_P_MPLS_UC = 0x8847 + ETH_P_MVRP = 0x88f5 + ETH_P_PAE = 0x888e + ETH_P_PAUSE = 0x8808 + ETH_P_PHONET = 0xf5 + ETH_P_PPPTALK = 0x10 + ETH_P_PPP_DISC = 0x8863 + ETH_P_PPP_MP = 0x8 + ETH_P_PPP_SES = 0x8864 + ETH_P_PRP = 0x88fb + ETH_P_PUP = 0x200 + ETH_P_PUPAT = 0x201 + ETH_P_QINQ1 = 0x9100 + ETH_P_QINQ2 = 0x9200 + ETH_P_QINQ3 = 0x9300 + ETH_P_RARP = 0x8035 + ETH_P_SCA = 0x6007 + ETH_P_SLOW = 0x8809 + ETH_P_SNAP = 0x5 + ETH_P_TDLS = 0x890d + ETH_P_TEB = 0x6558 + ETH_P_TIPC = 0x88ca + ETH_P_TRAILER = 0x1c + ETH_P_TR_802_2 = 0x11 + ETH_P_TSN = 0x22f0 + ETH_P_WAN_PPP = 0x7 + ETH_P_WCCP = 0x883e + ETH_P_X25 = 0x805 + ETH_P_XDSA = 0xf8 + EXTA = 0xe + EXTB = 0xf + EXTPROC = 0x10000 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FLUSHO = 0x2000 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x406 + F_EXLCK = 0x4 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLEASE = 0x401 + F_GETLK = 0xe + F_GETLK64 = 0xe + F_GETOWN = 0x17 + F_GETOWN_EX = 0x10 + F_GETPIPE_SZ = 0x408 + F_GETSIG = 0xb + F_LOCK = 0x1 + F_NOTIFY = 0x402 + F_OFD_GETLK = 0x24 + F_OFD_SETLK = 0x25 + F_OFD_SETLKW = 0x26 + F_OK = 0x0 + F_RDLCK = 0x0 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLEASE = 0x400 + F_SETLK = 0x6 + F_SETLK64 = 0x6 + F_SETLKW = 0x7 + F_SETLKW64 = 0x7 + F_SETOWN = 0x18 + F_SETOWN_EX = 0xf + F_SETPIPE_SZ = 0x407 + F_SETSIG = 0xa + F_SHLCK = 0x8 + F_TEST = 0x3 + F_TLOCK = 0x2 + F_ULOCK = 0x0 + F_UNLCK = 0x2 + F_WRLCK = 0x1 + HUPCL = 0x400 + ICANON = 0x2 + ICMPV6_FILTER = 0x1 + ICRNL = 0x100 + IEXTEN = 0x100 + IFA_F_DADFAILED = 0x8 + IFA_F_DEPRECATED = 0x20 + IFA_F_HOMEADDRESS = 0x10 + IFA_F_MANAGETEMPADDR = 0x100 + IFA_F_MCAUTOJOIN = 0x400 + IFA_F_NODAD = 0x2 + IFA_F_NOPREFIXROUTE = 0x200 + IFA_F_OPTIMISTIC = 0x4 + IFA_F_PERMANENT = 0x80 + IFA_F_SECONDARY = 0x1 + IFA_F_STABLE_PRIVACY = 0x800 + IFA_F_TEMPORARY = 0x1 + IFA_F_TENTATIVE = 0x40 + IFA_MAX = 0x8 + IFF_ALLMULTI = 0x200 + IFF_ATTACH_QUEUE = 0x200 + IFF_AUTOMEDIA = 0x4000 + IFF_BROADCAST = 0x2 + IFF_DEBUG = 0x4 + IFF_DETACH_QUEUE = 0x400 + IFF_DORMANT = 0x20000 + IFF_DYNAMIC = 0x8000 + IFF_ECHO = 0x40000 + IFF_LOOPBACK = 0x8 + IFF_LOWER_UP = 0x10000 + IFF_MASTER = 0x400 + IFF_MULTICAST = 0x1000 + IFF_MULTI_QUEUE = 0x100 + IFF_NOARP = 0x80 + IFF_NOFILTER = 0x1000 + IFF_NOTRAILERS = 0x20 + IFF_NO_PI = 0x1000 + IFF_ONE_QUEUE = 0x2000 + IFF_PERSIST = 0x800 + IFF_POINTOPOINT = 0x10 + IFF_PORTSEL = 0x2000 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SLAVE = 0x800 + IFF_TAP = 0x2 + IFF_TUN = 0x1 + IFF_TUN_EXCL = 0x8000 + IFF_UP = 0x1 + IFF_VNET_HDR = 0x4000 + IFF_VOLATILE = 0x70c5a + IFNAMSIZ = 0x10 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_ACCESS = 0x1 + IN_ALL_EVENTS = 0xfff + IN_ATTRIB = 0x4 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLOEXEC = 0x80000 + IN_CLOSE = 0x18 + IN_CLOSE_NOWRITE = 0x10 + IN_CLOSE_WRITE = 0x8 + IN_CREATE = 0x100 + IN_DELETE = 0x200 + IN_DELETE_SELF = 0x400 + IN_DONT_FOLLOW = 0x2000000 + IN_EXCL_UNLINK = 0x4000000 + IN_IGNORED = 0x8000 + IN_ISDIR = 0x40000000 + IN_LOOPBACKNET = 0x7f + IN_MASK_ADD = 0x20000000 + IN_MODIFY = 0x2 + IN_MOVE = 0xc0 + IN_MOVED_FROM = 0x40 + IN_MOVED_TO = 0x80 + IN_MOVE_SELF = 0x800 + IN_NONBLOCK = 0x80 + IN_ONESHOT = 0x80000000 + IN_ONLYDIR = 0x1000000 + IN_OPEN = 0x20 + IN_Q_OVERFLOW = 0x4000 + IN_UNMOUNT = 0x2000 + IPPROTO_AH = 0x33 + IPPROTO_BEETPH = 0x5e + IPPROTO_COMP = 0x6c + IPPROTO_DCCP = 0x21 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_ENCAP = 0x62 + IPPROTO_ESP = 0x32 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GRE = 0x2f + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IGMP = 0x2 + IPPROTO_IP = 0x0 + IPPROTO_IPIP = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_MH = 0x87 + IPPROTO_MTP = 0x5c + IPPROTO_NONE = 0x3b + IPPROTO_PIM = 0x67 + IPPROTO_PUP = 0xc + IPPROTO_RAW = 0xff + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_SCTP = 0x84 + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_UDP = 0x11 + IPPROTO_UDPLITE = 0x88 + IPV6_2292DSTOPTS = 0x4 + IPV6_2292HOPLIMIT = 0x8 + IPV6_2292HOPOPTS = 0x3 + IPV6_2292PKTINFO = 0x2 + IPV6_2292PKTOPTIONS = 0x6 + IPV6_2292RTHDR = 0x5 + IPV6_ADDRFORM = 0x1 + IPV6_ADD_MEMBERSHIP = 0x14 + IPV6_AUTHHDR = 0xa + IPV6_CHECKSUM = 0x7 + IPV6_DONTFRAG = 0x3e + IPV6_DROP_MEMBERSHIP = 0x15 + IPV6_DSTOPTS = 0x3b + IPV6_HOPLIMIT = 0x34 + IPV6_HOPOPTS = 0x36 + IPV6_IPSEC_POLICY = 0x22 + IPV6_JOIN_ANYCAST = 0x1b + IPV6_JOIN_GROUP = 0x14 + IPV6_LEAVE_ANYCAST = 0x1c + IPV6_LEAVE_GROUP = 0x15 + IPV6_MTU = 0x18 + IPV6_MTU_DISCOVER = 0x17 + IPV6_MULTICAST_HOPS = 0x12 + IPV6_MULTICAST_IF = 0x11 + IPV6_MULTICAST_LOOP = 0x13 + IPV6_NEXTHOP = 0x9 + IPV6_PATHMTU = 0x3d + IPV6_PKTINFO = 0x32 + IPV6_PMTUDISC_DO = 0x2 + IPV6_PMTUDISC_DONT = 0x0 + IPV6_PMTUDISC_INTERFACE = 0x4 + IPV6_PMTUDISC_OMIT = 0x5 + IPV6_PMTUDISC_PROBE = 0x3 + IPV6_PMTUDISC_WANT = 0x1 + IPV6_RECVDSTOPTS = 0x3a + IPV6_RECVERR = 0x19 + IPV6_RECVHOPLIMIT = 0x33 + IPV6_RECVHOPOPTS = 0x35 + IPV6_RECVPATHMTU = 0x3c + IPV6_RECVPKTINFO = 0x31 + IPV6_RECVRTHDR = 0x38 + IPV6_RECVTCLASS = 0x42 + IPV6_ROUTER_ALERT = 0x16 + IPV6_RTHDR = 0x39 + IPV6_RTHDRDSTOPTS = 0x37 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_RXDSTOPTS = 0x3b + IPV6_RXHOPOPTS = 0x36 + IPV6_TCLASS = 0x43 + IPV6_UNICAST_HOPS = 0x10 + IPV6_V6ONLY = 0x1a + IPV6_XFRM_POLICY = 0x23 + IP_ADD_MEMBERSHIP = 0x23 + IP_ADD_SOURCE_MEMBERSHIP = 0x27 + IP_BLOCK_SOURCE = 0x26 + IP_CHECKSUM = 0x17 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DROP_MEMBERSHIP = 0x24 + IP_DROP_SOURCE_MEMBERSHIP = 0x28 + IP_FREEBIND = 0xf + IP_HDRINCL = 0x3 + IP_IPSEC_POLICY = 0x10 + IP_MAXPACKET = 0xffff + IP_MAX_MEMBERSHIPS = 0x14 + IP_MF = 0x2000 + IP_MINTTL = 0x15 + IP_MSFILTER = 0x29 + IP_MSS = 0x240 + IP_MTU = 0xe + IP_MTU_DISCOVER = 0xa + IP_MULTICAST_ALL = 0x31 + IP_MULTICAST_IF = 0x20 + IP_MULTICAST_LOOP = 0x22 + IP_MULTICAST_TTL = 0x21 + IP_NODEFRAG = 0x16 + IP_OFFMASK = 0x1fff + IP_OPTIONS = 0x4 + IP_ORIGDSTADDR = 0x14 + IP_PASSSEC = 0x12 + IP_PKTINFO = 0x8 + IP_PKTOPTIONS = 0x9 + IP_PMTUDISC = 0xa + IP_PMTUDISC_DO = 0x2 + IP_PMTUDISC_DONT = 0x0 + IP_PMTUDISC_INTERFACE = 0x4 + IP_PMTUDISC_OMIT = 0x5 + IP_PMTUDISC_PROBE = 0x3 + IP_PMTUDISC_WANT = 0x1 + IP_RECVERR = 0xb + IP_RECVOPTS = 0x6 + IP_RECVORIGDSTADDR = 0x14 + IP_RECVRETOPTS = 0x7 + IP_RECVTOS = 0xd + IP_RECVTTL = 0xc + IP_RETOPTS = 0x7 + IP_RF = 0x8000 + IP_ROUTER_ALERT = 0x5 + IP_TOS = 0x1 + IP_TRANSPARENT = 0x13 + IP_TTL = 0x2 + IP_UNBLOCK_SOURCE = 0x25 + IP_UNICAST_IF = 0x32 + IP_XFRM_POLICY = 0x11 + ISIG = 0x1 + ISTRIP = 0x20 + IUTF8 = 0x4000 + IXANY = 0x800 + IXOFF = 0x1000 + IXON = 0x400 + LINUX_REBOOT_CMD_CAD_OFF = 0x0 + LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef + LINUX_REBOOT_CMD_HALT = 0xcdef0123 + LINUX_REBOOT_CMD_KEXEC = 0x45584543 + LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc + LINUX_REBOOT_CMD_RESTART = 0x1234567 + LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4 + LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2 + LINUX_REBOOT_MAGIC1 = 0xfee1dead + LINUX_REBOOT_MAGIC2 = 0x28121969 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_DODUMP = 0x11 + MADV_DOFORK = 0xb + MADV_DONTDUMP = 0x10 + MADV_DONTFORK = 0xa + MADV_DONTNEED = 0x4 + MADV_HUGEPAGE = 0xe + MADV_HWPOISON = 0x64 + MADV_MERGEABLE = 0xc + MADV_NOHUGEPAGE = 0xf + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_REMOVE = 0x9 + MADV_SEQUENTIAL = 0x2 + MADV_UNMERGEABLE = 0xd + MADV_WILLNEED = 0x3 + MAP_ANON = 0x800 + MAP_ANONYMOUS = 0x800 + MAP_DENYWRITE = 0x2000 + MAP_EXECUTABLE = 0x4000 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_GROWSDOWN = 0x1000 + MAP_HUGETLB = 0x80000 + MAP_HUGE_MASK = 0x3f + MAP_HUGE_SHIFT = 0x1a + MAP_LOCKED = 0x8000 + MAP_NONBLOCK = 0x20000 + MAP_NORESERVE = 0x400 + MAP_POPULATE = 0x10000 + MAP_PRIVATE = 0x2 + MAP_RENAME = 0x800 + MAP_SHARED = 0x1 + MAP_STACK = 0x40000 + MAP_TYPE = 0xf + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MNT_DETACH = 0x2 + MNT_EXPIRE = 0x4 + MNT_FORCE = 0x1 + MSG_CMSG_CLOEXEC = 0x40000000 + MSG_CONFIRM = 0x800 + MSG_CTRUNC = 0x8 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x40 + MSG_EOR = 0x80 + MSG_ERRQUEUE = 0x2000 + MSG_FASTOPEN = 0x20000000 + MSG_FIN = 0x200 + MSG_MORE = 0x8000 + MSG_NOSIGNAL = 0x4000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_PROXY = 0x10 + MSG_RST = 0x1000 + MSG_SYN = 0x400 + MSG_TRUNC = 0x20 + MSG_TRYHARD = 0x4 + MSG_WAITALL = 0x100 + MSG_WAITFORONE = 0x10000 + MS_ACTIVE = 0x40000000 + MS_ASYNC = 0x1 + MS_BIND = 0x1000 + MS_DIRSYNC = 0x80 + MS_INVALIDATE = 0x2 + MS_I_VERSION = 0x800000 + MS_KERNMOUNT = 0x400000 + MS_LAZYTIME = 0x2000000 + MS_MANDLOCK = 0x40 + MS_MGC_MSK = 0xffff0000 + MS_MGC_VAL = 0xc0ed0000 + MS_MOVE = 0x2000 + MS_NOATIME = 0x400 + MS_NODEV = 0x4 + MS_NODIRATIME = 0x800 + MS_NOEXEC = 0x8 + MS_NOSUID = 0x2 + MS_NOUSER = -0x80000000 + MS_POSIXACL = 0x10000 + MS_PRIVATE = 0x40000 + MS_RDONLY = 0x1 + MS_REC = 0x4000 + MS_RELATIME = 0x200000 + MS_REMOUNT = 0x20 + MS_RMT_MASK = 0x2800051 + MS_SHARED = 0x100000 + MS_SILENT = 0x8000 + MS_SLAVE = 0x80000 + MS_STRICTATIME = 0x1000000 + MS_SYNC = 0x4 + MS_SYNCHRONOUS = 0x10 + MS_UNBINDABLE = 0x20000 + NAME_MAX = 0xff + NETLINK_ADD_MEMBERSHIP = 0x1 + NETLINK_AUDIT = 0x9 + NETLINK_BROADCAST_ERROR = 0x4 + NETLINK_CAP_ACK = 0xa + NETLINK_CONNECTOR = 0xb + NETLINK_CRYPTO = 0x15 + NETLINK_DNRTMSG = 0xe + NETLINK_DROP_MEMBERSHIP = 0x2 + NETLINK_ECRYPTFS = 0x13 + NETLINK_FIB_LOOKUP = 0xa + NETLINK_FIREWALL = 0x3 + NETLINK_GENERIC = 0x10 + NETLINK_INET_DIAG = 0x4 + NETLINK_IP6_FW = 0xd + NETLINK_ISCSI = 0x8 + NETLINK_KOBJECT_UEVENT = 0xf + NETLINK_LISTEN_ALL_NSID = 0x8 + NETLINK_LIST_MEMBERSHIPS = 0x9 + NETLINK_NETFILTER = 0xc + NETLINK_NFLOG = 0x5 + NETLINK_NO_ENOBUFS = 0x5 + NETLINK_PKTINFO = 0x3 + NETLINK_RDMA = 0x14 + NETLINK_ROUTE = 0x0 + NETLINK_RX_RING = 0x6 + NETLINK_SCSITRANSPORT = 0x12 + NETLINK_SELINUX = 0x7 + NETLINK_SOCK_DIAG = 0x4 + NETLINK_TX_RING = 0x7 + NETLINK_UNUSED = 0x1 + NETLINK_USERSOCK = 0x2 + NETLINK_XFRM = 0x6 + NLA_ALIGNTO = 0x4 + NLA_F_NESTED = 0x8000 + NLA_F_NET_BYTEORDER = 0x4000 + NLA_HDRLEN = 0x4 + NLMSG_ALIGNTO = 0x4 + NLMSG_DONE = 0x3 + NLMSG_ERROR = 0x2 + NLMSG_HDRLEN = 0x10 + NLMSG_MIN_TYPE = 0x10 + NLMSG_NOOP = 0x1 + NLMSG_OVERRUN = 0x4 + NLM_F_ACK = 0x4 + NLM_F_APPEND = 0x800 + NLM_F_ATOMIC = 0x400 + NLM_F_CREATE = 0x400 + NLM_F_DUMP = 0x300 + NLM_F_DUMP_INTR = 0x10 + NLM_F_ECHO = 0x8 + NLM_F_EXCL = 0x200 + NLM_F_MATCH = 0x200 + NLM_F_MULTI = 0x2 + NLM_F_REPLACE = 0x100 + NLM_F_REQUEST = 0x1 + NLM_F_ROOT = 0x100 + NOFLSH = 0x80 + OCRNL = 0x8 + OFDEL = 0x80 + OFILL = 0x40 + ONLCR = 0x4 + ONLRET = 0x20 + ONOCR = 0x10 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_APPEND = 0x8 + O_ASYNC = 0x1000 + O_CLOEXEC = 0x80000 + O_CREAT = 0x100 + O_DIRECT = 0x8000 + O_DIRECTORY = 0x10000 + O_DSYNC = 0x10 + O_EXCL = 0x400 + O_FSYNC = 0x4010 + O_LARGEFILE = 0x0 + O_NDELAY = 0x80 + O_NOATIME = 0x40000 + O_NOCTTY = 0x800 + O_NOFOLLOW = 0x20000 + O_NONBLOCK = 0x80 + O_PATH = 0x200000 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_RSYNC = 0x4010 + O_SYNC = 0x4010 + O_TMPFILE = 0x410000 + O_TRUNC = 0x200 + O_WRONLY = 0x1 + PACKET_ADD_MEMBERSHIP = 0x1 + PACKET_AUXDATA = 0x8 + PACKET_BROADCAST = 0x1 + PACKET_COPY_THRESH = 0x7 + PACKET_DROP_MEMBERSHIP = 0x2 + PACKET_FANOUT = 0x12 + PACKET_FANOUT_CBPF = 0x6 + PACKET_FANOUT_CPU = 0x2 + PACKET_FANOUT_DATA = 0x16 + PACKET_FANOUT_EBPF = 0x7 + PACKET_FANOUT_FLAG_DEFRAG = 0x8000 + PACKET_FANOUT_FLAG_ROLLOVER = 0x1000 + PACKET_FANOUT_HASH = 0x0 + PACKET_FANOUT_LB = 0x1 + PACKET_FANOUT_QM = 0x5 + PACKET_FANOUT_RND = 0x4 + PACKET_FANOUT_ROLLOVER = 0x3 + PACKET_FASTROUTE = 0x6 + PACKET_HDRLEN = 0xb + PACKET_HOST = 0x0 + PACKET_KERNEL = 0x7 + PACKET_LOOPBACK = 0x5 + PACKET_LOSS = 0xe + PACKET_MR_ALLMULTI = 0x2 + PACKET_MR_MULTICAST = 0x0 + PACKET_MR_PROMISC = 0x1 + PACKET_MR_UNICAST = 0x3 + PACKET_MULTICAST = 0x2 + PACKET_ORIGDEV = 0x9 + PACKET_OTHERHOST = 0x3 + PACKET_OUTGOING = 0x4 + PACKET_QDISC_BYPASS = 0x14 + PACKET_RECV_OUTPUT = 0x3 + PACKET_RESERVE = 0xc + PACKET_ROLLOVER_STATS = 0x15 + PACKET_RX_RING = 0x5 + PACKET_STATISTICS = 0x6 + PACKET_TIMESTAMP = 0x11 + PACKET_TX_HAS_OFF = 0x13 + PACKET_TX_RING = 0xd + PACKET_TX_TIMESTAMP = 0x10 + PACKET_USER = 0x6 + PACKET_VERSION = 0xa + PACKET_VNET_HDR = 0xf + PARENB = 0x100 + PARITY_CRC16_PR0 = 0x2 + PARITY_CRC16_PR0_CCITT = 0x4 + PARITY_CRC16_PR1 = 0x3 + PARITY_CRC16_PR1_CCITT = 0x5 + PARITY_CRC32_PR0_CCITT = 0x6 + PARITY_CRC32_PR1_CCITT = 0x7 + PARITY_DEFAULT = 0x0 + PARITY_NONE = 0x1 + PARMRK = 0x8 + PARODD = 0x200 + PENDIN = 0x4000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_GROWSDOWN = 0x1000000 + PROT_GROWSUP = 0x2000000 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + PR_CAPBSET_DROP = 0x18 + PR_CAPBSET_READ = 0x17 + PR_CAP_AMBIENT = 0x2f + PR_CAP_AMBIENT_CLEAR_ALL = 0x4 + PR_CAP_AMBIENT_IS_SET = 0x1 + PR_CAP_AMBIENT_LOWER = 0x3 + PR_CAP_AMBIENT_RAISE = 0x2 + PR_ENDIAN_BIG = 0x0 + PR_ENDIAN_LITTLE = 0x1 + PR_ENDIAN_PPC_LITTLE = 0x2 + PR_FPEMU_NOPRINT = 0x1 + PR_FPEMU_SIGFPE = 0x2 + PR_FP_EXC_ASYNC = 0x2 + PR_FP_EXC_DISABLED = 0x0 + PR_FP_EXC_DIV = 0x10000 + PR_FP_EXC_INV = 0x100000 + PR_FP_EXC_NONRECOV = 0x1 + PR_FP_EXC_OVF = 0x20000 + PR_FP_EXC_PRECISE = 0x3 + PR_FP_EXC_RES = 0x80000 + PR_FP_EXC_SW_ENABLE = 0x80 + PR_FP_EXC_UND = 0x40000 + PR_FP_MODE_FR = 0x1 + PR_FP_MODE_FRE = 0x2 + PR_GET_CHILD_SUBREAPER = 0x25 + PR_GET_DUMPABLE = 0x3 + PR_GET_ENDIAN = 0x13 + PR_GET_FPEMU = 0x9 + PR_GET_FPEXC = 0xb + PR_GET_FP_MODE = 0x2e + PR_GET_KEEPCAPS = 0x7 + PR_GET_NAME = 0x10 + PR_GET_NO_NEW_PRIVS = 0x27 + PR_GET_PDEATHSIG = 0x2 + PR_GET_SECCOMP = 0x15 + PR_GET_SECUREBITS = 0x1b + PR_GET_THP_DISABLE = 0x2a + PR_GET_TID_ADDRESS = 0x28 + PR_GET_TIMERSLACK = 0x1e + PR_GET_TIMING = 0xd + PR_GET_TSC = 0x19 + PR_GET_UNALIGN = 0x5 + PR_MCE_KILL = 0x21 + PR_MCE_KILL_CLEAR = 0x0 + PR_MCE_KILL_DEFAULT = 0x2 + PR_MCE_KILL_EARLY = 0x1 + PR_MCE_KILL_GET = 0x22 + PR_MCE_KILL_LATE = 0x0 + PR_MCE_KILL_SET = 0x1 + PR_MPX_DISABLE_MANAGEMENT = 0x2c + PR_MPX_ENABLE_MANAGEMENT = 0x2b + PR_SET_CHILD_SUBREAPER = 0x24 + PR_SET_DUMPABLE = 0x4 + PR_SET_ENDIAN = 0x14 + PR_SET_FPEMU = 0xa + PR_SET_FPEXC = 0xc + PR_SET_FP_MODE = 0x2d + PR_SET_KEEPCAPS = 0x8 + PR_SET_MM = 0x23 + PR_SET_MM_ARG_END = 0x9 + PR_SET_MM_ARG_START = 0x8 + PR_SET_MM_AUXV = 0xc + PR_SET_MM_BRK = 0x7 + PR_SET_MM_END_CODE = 0x2 + PR_SET_MM_END_DATA = 0x4 + PR_SET_MM_ENV_END = 0xb + PR_SET_MM_ENV_START = 0xa + PR_SET_MM_EXE_FILE = 0xd + PR_SET_MM_MAP = 0xe + PR_SET_MM_MAP_SIZE = 0xf + PR_SET_MM_START_BRK = 0x6 + PR_SET_MM_START_CODE = 0x1 + PR_SET_MM_START_DATA = 0x3 + PR_SET_MM_START_STACK = 0x5 + PR_SET_NAME = 0xf + PR_SET_NO_NEW_PRIVS = 0x26 + PR_SET_PDEATHSIG = 0x1 + PR_SET_PTRACER = 0x59616d61 + PR_SET_PTRACER_ANY = -0x1 + PR_SET_SECCOMP = 0x16 + PR_SET_SECUREBITS = 0x1c + PR_SET_THP_DISABLE = 0x29 + PR_SET_TIMERSLACK = 0x1d + PR_SET_TIMING = 0xe + PR_SET_TSC = 0x1a + PR_SET_UNALIGN = 0x6 + PR_TASK_PERF_EVENTS_DISABLE = 0x1f + PR_TASK_PERF_EVENTS_ENABLE = 0x20 + PR_TIMING_STATISTICAL = 0x0 + PR_TIMING_TIMESTAMP = 0x1 + PR_TSC_ENABLE = 0x1 + PR_TSC_SIGSEGV = 0x2 + PR_UNALIGN_NOPRINT = 0x1 + PR_UNALIGN_SIGBUS = 0x2 + PTRACE_ATTACH = 0x10 + PTRACE_CONT = 0x7 + PTRACE_DETACH = 0x11 + PTRACE_EVENT_CLONE = 0x3 + PTRACE_EVENT_EXEC = 0x4 + PTRACE_EVENT_EXIT = 0x6 + PTRACE_EVENT_FORK = 0x1 + PTRACE_EVENT_SECCOMP = 0x7 + PTRACE_EVENT_STOP = 0x80 + PTRACE_EVENT_VFORK = 0x2 + PTRACE_EVENT_VFORK_DONE = 0x5 + PTRACE_GETEVENTMSG = 0x4201 + PTRACE_GETFPREGS = 0xe + PTRACE_GETREGS = 0xc + PTRACE_GETREGSET = 0x4204 + PTRACE_GETSIGINFO = 0x4202 + PTRACE_GETSIGMASK = 0x420a + PTRACE_GET_THREAD_AREA = 0x19 + PTRACE_GET_THREAD_AREA_3264 = 0xc4 + PTRACE_GET_WATCH_REGS = 0xd0 + PTRACE_INTERRUPT = 0x4207 + PTRACE_KILL = 0x8 + PTRACE_LISTEN = 0x4208 + PTRACE_OLDSETOPTIONS = 0x15 + PTRACE_O_EXITKILL = 0x100000 + PTRACE_O_MASK = 0x3000ff + PTRACE_O_SUSPEND_SECCOMP = 0x200000 + PTRACE_O_TRACECLONE = 0x8 + PTRACE_O_TRACEEXEC = 0x10 + PTRACE_O_TRACEEXIT = 0x40 + PTRACE_O_TRACEFORK = 0x2 + PTRACE_O_TRACESECCOMP = 0x80 + PTRACE_O_TRACESYSGOOD = 0x1 + PTRACE_O_TRACEVFORK = 0x4 + PTRACE_O_TRACEVFORKDONE = 0x20 + PTRACE_PEEKDATA = 0x2 + PTRACE_PEEKDATA_3264 = 0xc1 + PTRACE_PEEKSIGINFO = 0x4209 + PTRACE_PEEKSIGINFO_SHARED = 0x1 + PTRACE_PEEKTEXT = 0x1 + PTRACE_PEEKTEXT_3264 = 0xc0 + PTRACE_PEEKUSR = 0x3 + PTRACE_POKEDATA = 0x5 + PTRACE_POKEDATA_3264 = 0xc3 + PTRACE_POKETEXT = 0x4 + PTRACE_POKETEXT_3264 = 0xc2 + PTRACE_POKEUSR = 0x6 + PTRACE_SEIZE = 0x4206 + PTRACE_SETFPREGS = 0xf + PTRACE_SETOPTIONS = 0x4200 + PTRACE_SETREGS = 0xd + PTRACE_SETREGSET = 0x4205 + PTRACE_SETSIGINFO = 0x4203 + PTRACE_SETSIGMASK = 0x420b + PTRACE_SET_THREAD_AREA = 0x1a + PTRACE_SET_WATCH_REGS = 0xd1 + PTRACE_SINGLESTEP = 0x9 + PTRACE_SYSCALL = 0x18 + PTRACE_TRACEME = 0x0 + RLIMIT_AS = 0x6 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x5 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = -0x1 + RTAX_ADVMSS = 0x8 + RTAX_CC_ALGO = 0x10 + RTAX_CWND = 0x7 + RTAX_FEATURES = 0xc + RTAX_FEATURE_ALLFRAG = 0x8 + RTAX_FEATURE_ECN = 0x1 + RTAX_FEATURE_MASK = 0xf + RTAX_FEATURE_SACK = 0x2 + RTAX_FEATURE_TIMESTAMP = 0x4 + RTAX_HOPLIMIT = 0xa + RTAX_INITCWND = 0xb + RTAX_INITRWND = 0xe + RTAX_LOCK = 0x1 + RTAX_MAX = 0x10 + RTAX_MTU = 0x2 + RTAX_QUICKACK = 0xf + RTAX_REORDERING = 0x9 + RTAX_RTO_MIN = 0xd + RTAX_RTT = 0x4 + RTAX_RTTVAR = 0x5 + RTAX_SSTHRESH = 0x6 + RTAX_UNSPEC = 0x0 + RTAX_WINDOW = 0x3 + RTA_ALIGNTO = 0x4 + RTA_MAX = 0x16 + RTCF_DIRECTSRC = 0x4000000 + RTCF_DOREDIRECT = 0x1000000 + RTCF_LOG = 0x2000000 + RTCF_MASQ = 0x400000 + RTCF_NAT = 0x800000 + RTCF_VALVE = 0x200000 + RTF_ADDRCLASSMASK = 0xf8000000 + RTF_ADDRCONF = 0x40000 + RTF_ALLONLINK = 0x20000 + RTF_BROADCAST = 0x10000000 + RTF_CACHE = 0x1000000 + RTF_DEFAULT = 0x10000 + RTF_DYNAMIC = 0x10 + RTF_FLOW = 0x2000000 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_INTERFACE = 0x40000000 + RTF_IRTT = 0x100 + RTF_LINKRT = 0x100000 + RTF_LOCAL = 0x80000000 + RTF_MODIFIED = 0x20 + RTF_MSS = 0x40 + RTF_MTU = 0x40 + RTF_MULTICAST = 0x20000000 + RTF_NAT = 0x8000000 + RTF_NOFORWARD = 0x1000 + RTF_NONEXTHOP = 0x200000 + RTF_NOPMTUDISC = 0x4000 + RTF_POLICY = 0x4000000 + RTF_REINSTATE = 0x8 + RTF_REJECT = 0x200 + RTF_STATIC = 0x400 + RTF_THROW = 0x2000 + RTF_UP = 0x1 + RTF_WINDOW = 0x80 + RTF_XRESOLVE = 0x800 + RTM_BASE = 0x10 + RTM_DELACTION = 0x31 + RTM_DELADDR = 0x15 + RTM_DELADDRLABEL = 0x49 + RTM_DELLINK = 0x11 + RTM_DELMDB = 0x55 + RTM_DELNEIGH = 0x1d + RTM_DELNSID = 0x59 + RTM_DELQDISC = 0x25 + RTM_DELROUTE = 0x19 + RTM_DELRULE = 0x21 + RTM_DELTCLASS = 0x29 + RTM_DELTFILTER = 0x2d + RTM_F_CLONED = 0x200 + RTM_F_EQUALIZE = 0x400 + RTM_F_NOTIFY = 0x100 + RTM_F_PREFIX = 0x800 + RTM_GETACTION = 0x32 + RTM_GETADDR = 0x16 + RTM_GETADDRLABEL = 0x4a + RTM_GETANYCAST = 0x3e + RTM_GETDCB = 0x4e + RTM_GETLINK = 0x12 + RTM_GETMDB = 0x56 + RTM_GETMULTICAST = 0x3a + RTM_GETNEIGH = 0x1e + RTM_GETNEIGHTBL = 0x42 + RTM_GETNETCONF = 0x52 + RTM_GETNSID = 0x5a + RTM_GETQDISC = 0x26 + RTM_GETROUTE = 0x1a + RTM_GETRULE = 0x22 + RTM_GETTCLASS = 0x2a + RTM_GETTFILTER = 0x2e + RTM_MAX = 0x5b + RTM_NEWACTION = 0x30 + RTM_NEWADDR = 0x14 + RTM_NEWADDRLABEL = 0x48 + RTM_NEWLINK = 0x10 + RTM_NEWMDB = 0x54 + RTM_NEWNDUSEROPT = 0x44 + RTM_NEWNEIGH = 0x1c + RTM_NEWNEIGHTBL = 0x40 + RTM_NEWNETCONF = 0x50 + RTM_NEWNSID = 0x58 + RTM_NEWPREFIX = 0x34 + RTM_NEWQDISC = 0x24 + RTM_NEWROUTE = 0x18 + RTM_NEWRULE = 0x20 + RTM_NEWTCLASS = 0x28 + RTM_NEWTFILTER = 0x2c + RTM_NR_FAMILIES = 0x13 + RTM_NR_MSGTYPES = 0x4c + RTM_SETDCB = 0x4f + RTM_SETLINK = 0x13 + RTM_SETNEIGHTBL = 0x43 + RTNH_ALIGNTO = 0x4 + RTNH_COMPARE_MASK = 0x11 + RTNH_F_DEAD = 0x1 + RTNH_F_LINKDOWN = 0x10 + RTNH_F_OFFLOAD = 0x8 + RTNH_F_ONLINK = 0x4 + RTNH_F_PERVASIVE = 0x2 + RTN_MAX = 0xb + RTPROT_BABEL = 0x2a + RTPROT_BIRD = 0xc + RTPROT_BOOT = 0x3 + RTPROT_DHCP = 0x10 + RTPROT_DNROUTED = 0xd + RTPROT_GATED = 0x8 + RTPROT_KERNEL = 0x2 + RTPROT_MROUTED = 0x11 + RTPROT_MRT = 0xa + RTPROT_NTK = 0xf + RTPROT_RA = 0x9 + RTPROT_REDIRECT = 0x1 + RTPROT_STATIC = 0x4 + RTPROT_UNSPEC = 0x0 + RTPROT_XORP = 0xe + RTPROT_ZEBRA = 0xb + RT_CLASS_DEFAULT = 0xfd + RT_CLASS_LOCAL = 0xff + RT_CLASS_MAIN = 0xfe + RT_CLASS_MAX = 0xff + RT_CLASS_UNSPEC = 0x0 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + RUSAGE_THREAD = 0x1 + SCM_CREDENTIALS = 0x2 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x1d + SCM_TIMESTAMPING = 0x25 + SCM_TIMESTAMPNS = 0x23 + SCM_WIFI_STATUS = 0x29 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDDLCI = 0x8980 + SIOCADDMULTI = 0x8931 + SIOCADDRT = 0x890b + SIOCATMARK = 0x40047307 + SIOCDARP = 0x8953 + SIOCDELDLCI = 0x8981 + SIOCDELMULTI = 0x8932 + SIOCDELRT = 0x890c + SIOCDEVPRIVATE = 0x89f0 + SIOCDIFADDR = 0x8936 + SIOCDRARP = 0x8960 + SIOCGARP = 0x8954 + SIOCGIFADDR = 0x8915 + SIOCGIFBR = 0x8940 + SIOCGIFBRDADDR = 0x8919 + SIOCGIFCONF = 0x8912 + SIOCGIFCOUNT = 0x8938 + SIOCGIFDSTADDR = 0x8917 + SIOCGIFENCAP = 0x8925 + SIOCGIFFLAGS = 0x8913 + SIOCGIFHWADDR = 0x8927 + SIOCGIFINDEX = 0x8933 + SIOCGIFMAP = 0x8970 + SIOCGIFMEM = 0x891f + SIOCGIFMETRIC = 0x891d + SIOCGIFMTU = 0x8921 + SIOCGIFNAME = 0x8910 + SIOCGIFNETMASK = 0x891b + SIOCGIFPFLAGS = 0x8935 + SIOCGIFSLAVE = 0x8929 + SIOCGIFTXQLEN = 0x8942 + SIOCGPGRP = 0x40047309 + SIOCGRARP = 0x8961 + SIOCGSTAMP = 0x8906 + SIOCGSTAMPNS = 0x8907 + SIOCPROTOPRIVATE = 0x89e0 + SIOCRTMSG = 0x890d + SIOCSARP = 0x8955 + SIOCSIFADDR = 0x8916 + SIOCSIFBR = 0x8941 + SIOCSIFBRDADDR = 0x891a + SIOCSIFDSTADDR = 0x8918 + SIOCSIFENCAP = 0x8926 + SIOCSIFFLAGS = 0x8914 + SIOCSIFHWADDR = 0x8924 + SIOCSIFHWBROADCAST = 0x8937 + SIOCSIFLINK = 0x8911 + SIOCSIFMAP = 0x8971 + SIOCSIFMEM = 0x8920 + SIOCSIFMETRIC = 0x891e + SIOCSIFMTU = 0x8922 + SIOCSIFNAME = 0x8923 + SIOCSIFNETMASK = 0x891c + SIOCSIFPFLAGS = 0x8934 + SIOCSIFSLAVE = 0x8930 + SIOCSIFTXQLEN = 0x8943 + SIOCSPGRP = 0x80047308 + SIOCSRARP = 0x8962 + SOCK_CLOEXEC = 0x80000 + SOCK_DCCP = 0x6 + SOCK_DGRAM = 0x1 + SOCK_NONBLOCK = 0x80 + SOCK_PACKET = 0xa + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x2 + SOL_AAL = 0x109 + SOL_ATM = 0x108 + SOL_DECNET = 0x105 + SOL_ICMPV6 = 0x3a + SOL_IP = 0x0 + SOL_IPV6 = 0x29 + SOL_IRDA = 0x10a + SOL_PACKET = 0x107 + SOL_RAW = 0xff + SOL_SOCKET = 0xffff + SOL_TCP = 0x6 + SOL_X25 = 0x106 + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x1009 + SO_ATTACH_BPF = 0x32 + SO_ATTACH_FILTER = 0x1a + SO_BINDTODEVICE = 0x19 + SO_BPF_EXTENSIONS = 0x30 + SO_BROADCAST = 0x20 + SO_BSDCOMPAT = 0xe + SO_BUSY_POLL = 0x2e + SO_DEBUG = 0x1 + SO_DETACH_BPF = 0x1b + SO_DETACH_FILTER = 0x1b + SO_DOMAIN = 0x1029 + SO_DONTROUTE = 0x10 + SO_ERROR = 0x1007 + SO_GET_FILTER = 0x1a + SO_INCOMING_CPU = 0x31 + SO_KEEPALIVE = 0x8 + SO_LINGER = 0x80 + SO_LOCK_FILTER = 0x2c + SO_MARK = 0x24 + SO_MAX_PACING_RATE = 0x2f + SO_NOFCS = 0x2b + SO_NO_CHECK = 0xb + SO_OOBINLINE = 0x100 + SO_PASSCRED = 0x11 + SO_PASSSEC = 0x22 + SO_PEEK_OFF = 0x2a + SO_PEERCRED = 0x12 + SO_PEERNAME = 0x1c + SO_PEERSEC = 0x1e + SO_PRIORITY = 0xc + SO_PROTOCOL = 0x1028 + SO_RCVBUF = 0x1002 + SO_RCVBUFFORCE = 0x21 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x1006 + SO_REUSEADDR = 0x4 + SO_REUSEPORT = 0x200 + SO_RXQ_OVFL = 0x28 + SO_SECURITY_AUTHENTICATION = 0x16 + SO_SECURITY_ENCRYPTION_NETWORK = 0x18 + SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17 + SO_SELECT_ERR_QUEUE = 0x2d + SO_SNDBUF = 0x1001 + SO_SNDBUFFORCE = 0x1f + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x1005 + SO_STYLE = 0x1008 + SO_TIMESTAMP = 0x1d + SO_TIMESTAMPING = 0x25 + SO_TIMESTAMPNS = 0x23 + SO_TYPE = 0x1008 + SO_WIFI_STATUS = 0x29 + S_BLKSIZE = 0x200 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + TCFLSH = 0x5407 + TCIFLUSH = 0x0 + TCIOFLUSH = 0x2 + TCOFLUSH = 0x1 + TCP_CONGESTION = 0xd + TCP_COOKIE_IN_ALWAYS = 0x1 + TCP_COOKIE_MAX = 0x10 + TCP_COOKIE_MIN = 0x8 + TCP_COOKIE_OUT_NEVER = 0x2 + TCP_COOKIE_PAIR_SIZE = 0x20 + TCP_COOKIE_TRANSACTIONS = 0xf + TCP_CORK = 0x3 + TCP_DEFER_ACCEPT = 0x9 + TCP_FASTOPEN = 0x17 + TCP_INFO = 0xb + TCP_KEEPCNT = 0x6 + TCP_KEEPIDLE = 0x4 + TCP_KEEPINTVL = 0x5 + TCP_LINGER2 = 0x8 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0xe + TCP_MD5SIG_MAXKEYLEN = 0x50 + TCP_MSS = 0x200 + TCP_MSS_DEFAULT = 0x218 + TCP_MSS_DESIRED = 0x4c4 + TCP_NODELAY = 0x1 + TCP_QUEUE_SEQ = 0x15 + TCP_QUICKACK = 0xc + TCP_REPAIR = 0x13 + TCP_REPAIR_OPTIONS = 0x16 + TCP_REPAIR_QUEUE = 0x14 + TCP_SYNCNT = 0x7 + TCP_S_DATA_IN = 0x4 + TCP_S_DATA_OUT = 0x8 + TCP_THIN_DUPACK = 0x11 + TCP_THIN_LINEAR_TIMEOUTS = 0x10 + TCP_TIMESTAMP = 0x18 + TCP_USER_TIMEOUT = 0x12 + TCP_WINDOW_CLAMP = 0xa + TCSAFLUSH = 0x5410 + TCSBRK = 0x5405 + TCXONC = 0x5406 + TIOCCBRK = 0x5428 + TIOCCONS = 0x80047478 + TIOCEXCL = 0x740d + TIOCGDEV = 0x40045432 + TIOCGETD = 0x7400 + TIOCGETP = 0x7408 + TIOCGEXCL = 0x40045440 + TIOCGICOUNT = 0x5492 + TIOCGLCKTRMIOS = 0x548b + TIOCGLTC = 0x7474 + TIOCGPGRP = 0x40047477 + TIOCGPKT = 0x40045438 + TIOCGPTLCK = 0x40045439 + TIOCGPTN = 0x40045430 + TIOCGRS485 = 0x4020542e + TIOCGSERIAL = 0x5484 + TIOCGSID = 0x7416 + TIOCGSOFTCAR = 0x5481 + TIOCGWINSZ = 0x40087468 + TIOCINQ = 0x467f + TIOCLINUX = 0x5483 + TIOCMBIC = 0x741c + TIOCMBIS = 0x741b + TIOCMGET = 0x741d + TIOCMIWAIT = 0x5491 + TIOCMSET = 0x741a + TIOCM_CAR = 0x100 + TIOCM_CD = 0x100 + TIOCM_CTS = 0x40 + TIOCM_DSR = 0x400 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x200 + TIOCM_RNG = 0x200 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x20 + TIOCM_ST = 0x10 + TIOCNOTTY = 0x5471 + TIOCNXCL = 0x740e + TIOCOUTQ = 0x7472 + TIOCPKT = 0x5470 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCSBRK = 0x5427 + TIOCSCTTY = 0x5480 + TIOCSERCONFIG = 0x5488 + TIOCSERGETLSR = 0x548e + TIOCSERGETMULTI = 0x548f + TIOCSERGSTRUCT = 0x548d + TIOCSERGWILD = 0x5489 + TIOCSERSETMULTI = 0x5490 + TIOCSERSWILD = 0x548a + TIOCSER_TEMT = 0x1 + TIOCSETD = 0x7401 + TIOCSETN = 0x740a + TIOCSETP = 0x7409 + TIOCSIG = 0x80045436 + TIOCSLCKTRMIOS = 0x548c + TIOCSLTC = 0x7475 + TIOCSPGRP = 0x80047476 + TIOCSPTLCK = 0x80045431 + TIOCSRS485 = 0xc020542f + TIOCSSERIAL = 0x5485 + TIOCSSOFTCAR = 0x5482 + TIOCSTI = 0x5472 + TIOCSWINSZ = 0x80087467 + TIOCVHANGUP = 0x5437 + TOSTOP = 0x8000 + TUNATTACHFILTER = 0x801054d5 + TUNDETACHFILTER = 0x801054d6 + TUNGETFEATURES = 0x400454cf + TUNGETFILTER = 0x401054db + TUNGETIFF = 0x400454d2 + TUNGETSNDBUF = 0x400454d3 + TUNGETVNETBE = 0x400454df + TUNGETVNETHDRSZ = 0x400454d7 + TUNGETVNETLE = 0x400454dd + TUNSETDEBUG = 0x800454c9 + TUNSETGROUP = 0x800454ce + TUNSETIFF = 0x800454ca + TUNSETIFINDEX = 0x800454da + TUNSETLINK = 0x800454cd + TUNSETNOCSUM = 0x800454c8 + TUNSETOFFLOAD = 0x800454d0 + TUNSETOWNER = 0x800454cc + TUNSETPERSIST = 0x800454cb + TUNSETQUEUE = 0x800454d9 + TUNSETSNDBUF = 0x800454d4 + TUNSETTXFILTER = 0x800454d1 + TUNSETVNETBE = 0x800454de + TUNSETVNETHDRSZ = 0x800454d8 + TUNSETVNETLE = 0x800454dc + VDISCARD = 0xd + VEOF = 0x10 + VEOL = 0x11 + VEOL2 = 0x6 + VERASE = 0x2 + VINTR = 0x0 + VKILL = 0x3 + VLNEXT = 0xf + VMIN = 0x4 + VQUIT = 0x1 + VREPRINT = 0xc + VSTART = 0x8 + VSTOP = 0x9 + VSUSP = 0xa + VSWTC = 0x7 + VSWTCH = 0x7 + VT0 = 0x0 + VT1 = 0x4000 + VTDLY = 0x4000 + VTIME = 0x5 + VWERASE = 0xe + WALL = 0x40000000 + WCLONE = 0x80000000 + WCONTINUED = 0x8 + WEXITED = 0x4 + WNOHANG = 0x1 + WNOTHREAD = 0x20000000 + WNOWAIT = 0x1000000 + WORDSIZE = 0x40 + WSTOPPED = 0x2 + WUNTRACED = 0x2 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x7d) + EADDRNOTAVAIL = syscall.Errno(0x7e) + EADV = syscall.Errno(0x44) + EAFNOSUPPORT = syscall.Errno(0x7c) + EAGAIN = syscall.Errno(0xb) + EALREADY = syscall.Errno(0x95) + EBADE = syscall.Errno(0x32) + EBADF = syscall.Errno(0x9) + EBADFD = syscall.Errno(0x51) + EBADMSG = syscall.Errno(0x4d) + EBADR = syscall.Errno(0x33) + EBADRQC = syscall.Errno(0x36) + EBADSLT = syscall.Errno(0x37) + EBFONT = syscall.Errno(0x3b) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x9e) + ECHILD = syscall.Errno(0xa) + ECHRNG = syscall.Errno(0x25) + ECOMM = syscall.Errno(0x46) + ECONNABORTED = syscall.Errno(0x82) + ECONNREFUSED = syscall.Errno(0x92) + ECONNRESET = syscall.Errno(0x83) + EDEADLK = syscall.Errno(0x2d) + EDEADLOCK = syscall.Errno(0x38) + EDESTADDRREQ = syscall.Errno(0x60) + EDOM = syscall.Errno(0x21) + EDOTDOT = syscall.Errno(0x49) + EDQUOT = syscall.Errno(0x46d) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EHOSTDOWN = syscall.Errno(0x93) + EHOSTUNREACH = syscall.Errno(0x94) + EHWPOISON = syscall.Errno(0xa8) + EIDRM = syscall.Errno(0x24) + EILSEQ = syscall.Errno(0x58) + EINIT = syscall.Errno(0x8d) + EINPROGRESS = syscall.Errno(0x96) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x85) + EISDIR = syscall.Errno(0x15) + EISNAM = syscall.Errno(0x8b) + EKEYEXPIRED = syscall.Errno(0xa2) + EKEYREJECTED = syscall.Errno(0xa4) + EKEYREVOKED = syscall.Errno(0xa3) + EL2HLT = syscall.Errno(0x2c) + EL2NSYNC = syscall.Errno(0x26) + EL3HLT = syscall.Errno(0x27) + EL3RST = syscall.Errno(0x28) + ELIBACC = syscall.Errno(0x53) + ELIBBAD = syscall.Errno(0x54) + ELIBEXEC = syscall.Errno(0x57) + ELIBMAX = syscall.Errno(0x56) + ELIBSCN = syscall.Errno(0x55) + ELNRNG = syscall.Errno(0x29) + ELOOP = syscall.Errno(0x5a) + EMEDIUMTYPE = syscall.Errno(0xa0) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x61) + EMULTIHOP = syscall.Errno(0x4a) + ENAMETOOLONG = syscall.Errno(0x4e) + ENAVAIL = syscall.Errno(0x8a) + ENETDOWN = syscall.Errno(0x7f) + ENETRESET = syscall.Errno(0x81) + ENETUNREACH = syscall.Errno(0x80) + ENFILE = syscall.Errno(0x17) + ENOANO = syscall.Errno(0x35) + ENOBUFS = syscall.Errno(0x84) + ENOCSI = syscall.Errno(0x2b) + ENODATA = syscall.Errno(0x3d) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOKEY = syscall.Errno(0xa1) + ENOLCK = syscall.Errno(0x2e) + ENOLINK = syscall.Errno(0x43) + ENOMEDIUM = syscall.Errno(0x9f) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x23) + ENONET = syscall.Errno(0x40) + ENOPKG = syscall.Errno(0x41) + ENOPROTOOPT = syscall.Errno(0x63) + ENOSPC = syscall.Errno(0x1c) + ENOSR = syscall.Errno(0x3f) + ENOSTR = syscall.Errno(0x3c) + ENOSYS = syscall.Errno(0x59) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x86) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x5d) + ENOTNAM = syscall.Errno(0x89) + ENOTRECOVERABLE = syscall.Errno(0xa6) + ENOTSOCK = syscall.Errno(0x5f) + ENOTSUP = syscall.Errno(0x7a) + ENOTTY = syscall.Errno(0x19) + ENOTUNIQ = syscall.Errno(0x50) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x7a) + EOVERFLOW = syscall.Errno(0x4f) + EOWNERDEAD = syscall.Errno(0xa5) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x7b) + EPIPE = syscall.Errno(0x20) + EPROTO = syscall.Errno(0x47) + EPROTONOSUPPORT = syscall.Errno(0x78) + EPROTOTYPE = syscall.Errno(0x62) + ERANGE = syscall.Errno(0x22) + EREMCHG = syscall.Errno(0x52) + EREMDEV = syscall.Errno(0x8e) + EREMOTE = syscall.Errno(0x42) + EREMOTEIO = syscall.Errno(0x8c) + ERESTART = syscall.Errno(0x5b) + ERFKILL = syscall.Errno(0xa7) + EROFS = syscall.Errno(0x1e) + ESHUTDOWN = syscall.Errno(0x8f) + ESOCKTNOSUPPORT = syscall.Errno(0x79) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESRMNT = syscall.Errno(0x45) + ESTALE = syscall.Errno(0x97) + ESTRPIPE = syscall.Errno(0x5c) + ETIME = syscall.Errno(0x3e) + ETIMEDOUT = syscall.Errno(0x91) + ETOOMANYREFS = syscall.Errno(0x90) + ETXTBSY = syscall.Errno(0x1a) + EUCLEAN = syscall.Errno(0x87) + EUNATCH = syscall.Errno(0x2a) + EUSERS = syscall.Errno(0x5e) + EWOULDBLOCK = syscall.Errno(0xb) + EXDEV = syscall.Errno(0x12) + EXFULL = syscall.Errno(0x34) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0xa) + SIGCHLD = syscall.Signal(0x12) + SIGCLD = syscall.Signal(0x12) + SIGCONT = syscall.Signal(0x19) + SIGEMT = syscall.Signal(0x7) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x16) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPOLL = syscall.Signal(0x16) + SIGPROF = syscall.Signal(0x1d) + SIGPWR = syscall.Signal(0x13) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTOP = syscall.Signal(0x17) + SIGSYS = syscall.Signal(0xc) + SIGTERM = syscall.Signal(0xf) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x18) + SIGTTIN = syscall.Signal(0x1a) + SIGTTOU = syscall.Signal(0x1b) + SIGURG = syscall.Signal(0x15) + SIGUSR1 = syscall.Signal(0x10) + SIGUSR2 = syscall.Signal(0x11) + SIGVTALRM = syscall.Signal(0x1c) + SIGWINCH = syscall.Signal(0x14) + SIGXCPU = syscall.Signal(0x1e) + SIGXFSZ = syscall.Signal(0x1f) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "no such device or address", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource temporarily unavailable", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device or resource busy", + 17: "file exists", + 18: "invalid cross-device link", + 19: "no such device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "numerical result out of range", + 35: "no message of desired type", + 36: "identifier removed", + 37: "channel number out of range", + 38: "level 2 not synchronized", + 39: "level 3 halted", + 40: "level 3 reset", + 41: "link number out of range", + 42: "protocol driver not attached", + 43: "no CSI structure available", + 44: "level 2 halted", + 45: "resource deadlock avoided", + 46: "no locks available", + 50: "invalid exchange", + 51: "invalid request descriptor", + 52: "exchange full", + 53: "no anode", + 54: "invalid request code", + 55: "invalid slot", + 56: "file locking deadlock error", + 59: "bad font file format", + 60: "device not a stream", + 61: "no data available", + 62: "timer expired", + 63: "out of streams resources", + 64: "machine is not on the network", + 65: "package not installed", + 66: "object is remote", + 67: "link has been severed", + 68: "advertise error", + 69: "srmount error", + 70: "communication error on send", + 71: "protocol error", + 73: "RFS specific error", + 74: "multihop attempted", + 77: "bad message", + 78: "file name too long", + 79: "value too large for defined data type", + 80: "name not unique on network", + 81: "file descriptor in bad state", + 82: "remote address changed", + 83: "can not access a needed shared library", + 84: "accessing a corrupted shared library", + 85: ".lib section in a.out corrupted", + 86: "attempting to link in too many shared libraries", + 87: "cannot exec a shared library directly", + 88: "invalid or incomplete multibyte or wide character", + 89: "function not implemented", + 90: "too many levels of symbolic links", + 91: "interrupted system call should be restarted", + 92: "streams pipe error", + 93: "directory not empty", + 94: "too many users", + 95: "socket operation on non-socket", + 96: "destination address required", + 97: "message too long", + 98: "protocol wrong type for socket", + 99: "protocol not available", + 120: "protocol not supported", + 121: "socket type not supported", + 122: "operation not supported", + 123: "protocol family not supported", + 124: "address family not supported by protocol", + 125: "address already in use", + 126: "cannot assign requested address", + 127: "network is down", + 128: "network is unreachable", + 129: "network dropped connection on reset", + 130: "software caused connection abort", + 131: "connection reset by peer", + 132: "no buffer space available", + 133: "transport endpoint is already connected", + 134: "transport endpoint is not connected", + 135: "structure needs cleaning", + 137: "not a XENIX named type file", + 138: "no XENIX semaphores available", + 139: "is a named type file", + 140: "remote I/O error", + 141: "unknown error 141", + 142: "unknown error 142", + 143: "cannot send after transport endpoint shutdown", + 144: "too many references: cannot splice", + 145: "connection timed out", + 146: "connection refused", + 147: "host is down", + 148: "no route to host", + 149: "operation already in progress", + 150: "operation now in progress", + 151: "stale file handle", + 158: "operation canceled", + 159: "no medium found", + 160: "wrong medium type", + 161: "required key not available", + 162: "key has expired", + 163: "key has been revoked", + 164: "key was rejected by service", + 165: "owner died", + 166: "state not recoverable", + 167: "operation not possible due to RF-kill", + 168: "memory page has hardware error", + 1133: "disk quota exceeded", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/breakpoint trap", + 6: "aborted", + 7: "EMT trap", + 8: "floating point exception", + 9: "killed", + 10: "bus error", + 11: "segmentation fault", + 12: "bad system call", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "user defined signal 1", + 17: "user defined signal 2", + 18: "child exited", + 19: "power failure", + 20: "window changed", + 21: "urgent I/O condition", + 22: "I/O possible", + 23: "stopped (signal)", + 24: "stopped", + 25: "continued", + 26: "stopped (tty input)", + 27: "stopped (tty output)", + 28: "virtual timer expired", + 29: "profiling timer expired", + 30: "CPU time limit exceeded", + 31: "file size limit exceeded", +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_mips64le.go new file mode 100644 index 0000000000..112f05de56 --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -0,0 +1,1917 @@ +// mkerrors.sh +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build mips64le,linux + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- _const.go + +package unix + +import "syscall" + +const ( + AF_ALG = 0x26 + AF_APPLETALK = 0x5 + AF_ASH = 0x12 + AF_ATMPVC = 0x8 + AF_ATMSVC = 0x14 + AF_AX25 = 0x3 + AF_BLUETOOTH = 0x1f + AF_BRIDGE = 0x7 + AF_CAIF = 0x25 + AF_CAN = 0x1d + AF_DECnet = 0xc + AF_ECONET = 0x13 + AF_FILE = 0x1 + AF_IB = 0x1b + AF_IEEE802154 = 0x24 + AF_INET = 0x2 + AF_INET6 = 0xa + AF_IPX = 0x4 + AF_IRDA = 0x17 + AF_ISDN = 0x22 + AF_IUCV = 0x20 + AF_KEY = 0xf + AF_LLC = 0x1a + AF_LOCAL = 0x1 + AF_MAX = 0x29 + AF_MPLS = 0x1c + AF_NETBEUI = 0xd + AF_NETLINK = 0x10 + AF_NETROM = 0x6 + AF_NFC = 0x27 + AF_PACKET = 0x11 + AF_PHONET = 0x23 + AF_PPPOX = 0x18 + AF_RDS = 0x15 + AF_ROSE = 0xb + AF_ROUTE = 0x10 + AF_RXRPC = 0x21 + AF_SECURITY = 0xe + AF_SNA = 0x16 + AF_TIPC = 0x1e + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_VSOCK = 0x28 + AF_WANPIPE = 0x19 + AF_X25 = 0x9 + ARPHRD_6LOWPAN = 0x339 + ARPHRD_ADAPT = 0x108 + ARPHRD_APPLETLK = 0x8 + ARPHRD_ARCNET = 0x7 + ARPHRD_ASH = 0x30d + ARPHRD_ATM = 0x13 + ARPHRD_AX25 = 0x3 + ARPHRD_BIF = 0x307 + ARPHRD_CAIF = 0x336 + ARPHRD_CAN = 0x118 + ARPHRD_CHAOS = 0x5 + ARPHRD_CISCO = 0x201 + ARPHRD_CSLIP = 0x101 + ARPHRD_CSLIP6 = 0x103 + ARPHRD_DDCMP = 0x205 + ARPHRD_DLCI = 0xf + ARPHRD_ECONET = 0x30e + ARPHRD_EETHER = 0x2 + ARPHRD_ETHER = 0x1 + ARPHRD_EUI64 = 0x1b + ARPHRD_FCAL = 0x311 + ARPHRD_FCFABRIC = 0x313 + ARPHRD_FCPL = 0x312 + ARPHRD_FCPP = 0x310 + ARPHRD_FDDI = 0x306 + ARPHRD_FRAD = 0x302 + ARPHRD_HDLC = 0x201 + ARPHRD_HIPPI = 0x30c + ARPHRD_HWX25 = 0x110 + ARPHRD_IEEE1394 = 0x18 + ARPHRD_IEEE802 = 0x6 + ARPHRD_IEEE80211 = 0x321 + ARPHRD_IEEE80211_PRISM = 0x322 + ARPHRD_IEEE80211_RADIOTAP = 0x323 + ARPHRD_IEEE802154 = 0x324 + ARPHRD_IEEE802154_MONITOR = 0x325 + ARPHRD_IEEE802_TR = 0x320 + ARPHRD_INFINIBAND = 0x20 + ARPHRD_IP6GRE = 0x337 + ARPHRD_IPDDP = 0x309 + ARPHRD_IPGRE = 0x30a + ARPHRD_IRDA = 0x30f + ARPHRD_LAPB = 0x204 + ARPHRD_LOCALTLK = 0x305 + ARPHRD_LOOPBACK = 0x304 + ARPHRD_METRICOM = 0x17 + ARPHRD_NETLINK = 0x338 + ARPHRD_NETROM = 0x0 + ARPHRD_NONE = 0xfffe + ARPHRD_PHONET = 0x334 + ARPHRD_PHONET_PIPE = 0x335 + ARPHRD_PIMREG = 0x30b + ARPHRD_PPP = 0x200 + ARPHRD_PRONET = 0x4 + ARPHRD_RAWHDLC = 0x206 + ARPHRD_ROSE = 0x10e + ARPHRD_RSRVD = 0x104 + ARPHRD_SIT = 0x308 + ARPHRD_SKIP = 0x303 + ARPHRD_SLIP = 0x100 + ARPHRD_SLIP6 = 0x102 + ARPHRD_TUNNEL = 0x300 + ARPHRD_TUNNEL6 = 0x301 + ARPHRD_VOID = 0xffff + ARPHRD_X25 = 0x10f + B0 = 0x0 + B1000000 = 0x1008 + B110 = 0x3 + B115200 = 0x1002 + B1152000 = 0x1009 + B1200 = 0x9 + B134 = 0x4 + B150 = 0x5 + B1500000 = 0x100a + B1800 = 0xa + B19200 = 0xe + B200 = 0x6 + B2000000 = 0x100b + B230400 = 0x1003 + B2400 = 0xb + B2500000 = 0x100c + B300 = 0x7 + B3000000 = 0x100d + B3500000 = 0x100e + B38400 = 0xf + B4000000 = 0x100f + B460800 = 0x1004 + B4800 = 0xc + B50 = 0x1 + B500000 = 0x1005 + B57600 = 0x1001 + B576000 = 0x1006 + B600 = 0x8 + B75 = 0x2 + B921600 = 0x1007 + B9600 = 0xd + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LL_OFF = -0x200000 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXINSNS = 0x1000 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MOD = 0x90 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_NET_OFF = -0x100000 + BPF_OR = 0x40 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BPF_XOR = 0xa0 + BRKINT = 0x2 + CFLUSH = 0xf + CLOCAL = 0x800 + CLOCK_BOOTTIME = 0x7 + CLOCK_BOOTTIME_ALARM = 0x9 + CLOCK_DEFAULT = 0x0 + CLOCK_EXT = 0x1 + CLOCK_INT = 0x2 + CLOCK_MONOTONIC = 0x1 + CLOCK_MONOTONIC_COARSE = 0x6 + CLOCK_MONOTONIC_RAW = 0x4 + CLOCK_PROCESS_CPUTIME_ID = 0x2 + CLOCK_REALTIME = 0x0 + CLOCK_REALTIME_ALARM = 0x8 + CLOCK_REALTIME_COARSE = 0x5 + CLOCK_TAI = 0xb + CLOCK_THREAD_CPUTIME_ID = 0x3 + CLOCK_TXFROMRX = 0x4 + CLOCK_TXINT = 0x3 + CLONE_CHILD_CLEARTID = 0x200000 + CLONE_CHILD_SETTID = 0x1000000 + CLONE_DETACHED = 0x400000 + CLONE_FILES = 0x400 + CLONE_FS = 0x200 + CLONE_IO = 0x80000000 + CLONE_NEWCGROUP = 0x2000000 + CLONE_NEWIPC = 0x8000000 + CLONE_NEWNET = 0x40000000 + CLONE_NEWNS = 0x20000 + CLONE_NEWPID = 0x20000000 + CLONE_NEWUSER = 0x10000000 + CLONE_NEWUTS = 0x4000000 + CLONE_PARENT = 0x8000 + CLONE_PARENT_SETTID = 0x100000 + CLONE_PTRACE = 0x2000 + CLONE_SETTLS = 0x80000 + CLONE_SIGHAND = 0x800 + CLONE_SYSVSEM = 0x40000 + CLONE_THREAD = 0x10000 + CLONE_UNTRACED = 0x800000 + CLONE_VFORK = 0x4000 + CLONE_VM = 0x100 + CREAD = 0x80 + CS5 = 0x0 + CS6 = 0x10 + CS7 = 0x20 + CS8 = 0x30 + CSIGNAL = 0xff + CSIZE = 0x30 + CSTART = 0x11 + CSTATUS = 0x0 + CSTOP = 0x13 + CSTOPB = 0x40 + CSUSP = 0x1a + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x200 + ECHOE = 0x10 + ECHOK = 0x20 + ECHOKE = 0x800 + ECHONL = 0x40 + ECHOPRT = 0x400 + ENCODING_DEFAULT = 0x0 + ENCODING_FM_MARK = 0x3 + ENCODING_FM_SPACE = 0x4 + ENCODING_MANCHESTER = 0x5 + ENCODING_NRZ = 0x1 + ENCODING_NRZI = 0x2 + EPOLLERR = 0x8 + EPOLLET = 0x80000000 + EPOLLHUP = 0x10 + EPOLLIN = 0x1 + EPOLLMSG = 0x400 + EPOLLONESHOT = 0x40000000 + EPOLLOUT = 0x4 + EPOLLPRI = 0x2 + EPOLLRDBAND = 0x80 + EPOLLRDHUP = 0x2000 + EPOLLRDNORM = 0x40 + EPOLLWAKEUP = 0x20000000 + EPOLLWRBAND = 0x200 + EPOLLWRNORM = 0x100 + EPOLL_CLOEXEC = 0x80000 + EPOLL_CTL_ADD = 0x1 + EPOLL_CTL_DEL = 0x2 + EPOLL_CTL_MOD = 0x3 + ETH_P_1588 = 0x88f7 + ETH_P_8021AD = 0x88a8 + ETH_P_8021AH = 0x88e7 + ETH_P_8021Q = 0x8100 + ETH_P_80221 = 0x8917 + ETH_P_802_2 = 0x4 + ETH_P_802_3 = 0x1 + ETH_P_802_3_MIN = 0x600 + ETH_P_802_EX1 = 0x88b5 + ETH_P_AARP = 0x80f3 + ETH_P_AF_IUCV = 0xfbfb + ETH_P_ALL = 0x3 + ETH_P_AOE = 0x88a2 + ETH_P_ARCNET = 0x1a + ETH_P_ARP = 0x806 + ETH_P_ATALK = 0x809b + ETH_P_ATMFATE = 0x8884 + ETH_P_ATMMPOA = 0x884c + ETH_P_AX25 = 0x2 + ETH_P_BATMAN = 0x4305 + ETH_P_BPQ = 0x8ff + ETH_P_CAIF = 0xf7 + ETH_P_CAN = 0xc + ETH_P_CANFD = 0xd + ETH_P_CONTROL = 0x16 + ETH_P_CUST = 0x6006 + ETH_P_DDCMP = 0x6 + ETH_P_DEC = 0x6000 + ETH_P_DIAG = 0x6005 + ETH_P_DNA_DL = 0x6001 + ETH_P_DNA_RC = 0x6002 + ETH_P_DNA_RT = 0x6003 + ETH_P_DSA = 0x1b + ETH_P_ECONET = 0x18 + ETH_P_EDSA = 0xdada + ETH_P_FCOE = 0x8906 + ETH_P_FIP = 0x8914 + ETH_P_HDLC = 0x19 + ETH_P_IEEE802154 = 0xf6 + ETH_P_IEEEPUP = 0xa00 + ETH_P_IEEEPUPAT = 0xa01 + ETH_P_IP = 0x800 + ETH_P_IPV6 = 0x86dd + ETH_P_IPX = 0x8137 + ETH_P_IRDA = 0x17 + ETH_P_LAT = 0x6004 + ETH_P_LINK_CTL = 0x886c + ETH_P_LOCALTALK = 0x9 + ETH_P_LOOP = 0x60 + ETH_P_LOOPBACK = 0x9000 + ETH_P_MOBITEX = 0x15 + ETH_P_MPLS_MC = 0x8848 + ETH_P_MPLS_UC = 0x8847 + ETH_P_MVRP = 0x88f5 + ETH_P_PAE = 0x888e + ETH_P_PAUSE = 0x8808 + ETH_P_PHONET = 0xf5 + ETH_P_PPPTALK = 0x10 + ETH_P_PPP_DISC = 0x8863 + ETH_P_PPP_MP = 0x8 + ETH_P_PPP_SES = 0x8864 + ETH_P_PRP = 0x88fb + ETH_P_PUP = 0x200 + ETH_P_PUPAT = 0x201 + ETH_P_QINQ1 = 0x9100 + ETH_P_QINQ2 = 0x9200 + ETH_P_QINQ3 = 0x9300 + ETH_P_RARP = 0x8035 + ETH_P_SCA = 0x6007 + ETH_P_SLOW = 0x8809 + ETH_P_SNAP = 0x5 + ETH_P_TDLS = 0x890d + ETH_P_TEB = 0x6558 + ETH_P_TIPC = 0x88ca + ETH_P_TRAILER = 0x1c + ETH_P_TR_802_2 = 0x11 + ETH_P_TSN = 0x22f0 + ETH_P_WAN_PPP = 0x7 + ETH_P_WCCP = 0x883e + ETH_P_X25 = 0x805 + ETH_P_XDSA = 0xf8 + EXTA = 0xe + EXTB = 0xf + EXTPROC = 0x10000 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FLUSHO = 0x2000 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x406 + F_EXLCK = 0x4 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLEASE = 0x401 + F_GETLK = 0xe + F_GETLK64 = 0xe + F_GETOWN = 0x17 + F_GETOWN_EX = 0x10 + F_GETPIPE_SZ = 0x408 + F_GETSIG = 0xb + F_LOCK = 0x1 + F_NOTIFY = 0x402 + F_OFD_GETLK = 0x24 + F_OFD_SETLK = 0x25 + F_OFD_SETLKW = 0x26 + F_OK = 0x0 + F_RDLCK = 0x0 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLEASE = 0x400 + F_SETLK = 0x6 + F_SETLK64 = 0x6 + F_SETLKW = 0x7 + F_SETLKW64 = 0x7 + F_SETOWN = 0x18 + F_SETOWN_EX = 0xf + F_SETPIPE_SZ = 0x407 + F_SETSIG = 0xa + F_SHLCK = 0x8 + F_TEST = 0x3 + F_TLOCK = 0x2 + F_ULOCK = 0x0 + F_UNLCK = 0x2 + F_WRLCK = 0x1 + HUPCL = 0x400 + ICANON = 0x2 + ICMPV6_FILTER = 0x1 + ICRNL = 0x100 + IEXTEN = 0x100 + IFA_F_DADFAILED = 0x8 + IFA_F_DEPRECATED = 0x20 + IFA_F_HOMEADDRESS = 0x10 + IFA_F_MANAGETEMPADDR = 0x100 + IFA_F_MCAUTOJOIN = 0x400 + IFA_F_NODAD = 0x2 + IFA_F_NOPREFIXROUTE = 0x200 + IFA_F_OPTIMISTIC = 0x4 + IFA_F_PERMANENT = 0x80 + IFA_F_SECONDARY = 0x1 + IFA_F_STABLE_PRIVACY = 0x800 + IFA_F_TEMPORARY = 0x1 + IFA_F_TENTATIVE = 0x40 + IFA_MAX = 0x8 + IFF_ALLMULTI = 0x200 + IFF_ATTACH_QUEUE = 0x200 + IFF_AUTOMEDIA = 0x4000 + IFF_BROADCAST = 0x2 + IFF_DEBUG = 0x4 + IFF_DETACH_QUEUE = 0x400 + IFF_DORMANT = 0x20000 + IFF_DYNAMIC = 0x8000 + IFF_ECHO = 0x40000 + IFF_LOOPBACK = 0x8 + IFF_LOWER_UP = 0x10000 + IFF_MASTER = 0x400 + IFF_MULTICAST = 0x1000 + IFF_MULTI_QUEUE = 0x100 + IFF_NOARP = 0x80 + IFF_NOFILTER = 0x1000 + IFF_NOTRAILERS = 0x20 + IFF_NO_PI = 0x1000 + IFF_ONE_QUEUE = 0x2000 + IFF_PERSIST = 0x800 + IFF_POINTOPOINT = 0x10 + IFF_PORTSEL = 0x2000 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SLAVE = 0x800 + IFF_TAP = 0x2 + IFF_TUN = 0x1 + IFF_TUN_EXCL = 0x8000 + IFF_UP = 0x1 + IFF_VNET_HDR = 0x4000 + IFF_VOLATILE = 0x70c5a + IFNAMSIZ = 0x10 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_ACCESS = 0x1 + IN_ALL_EVENTS = 0xfff + IN_ATTRIB = 0x4 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLOEXEC = 0x80000 + IN_CLOSE = 0x18 + IN_CLOSE_NOWRITE = 0x10 + IN_CLOSE_WRITE = 0x8 + IN_CREATE = 0x100 + IN_DELETE = 0x200 + IN_DELETE_SELF = 0x400 + IN_DONT_FOLLOW = 0x2000000 + IN_EXCL_UNLINK = 0x4000000 + IN_IGNORED = 0x8000 + IN_ISDIR = 0x40000000 + IN_LOOPBACKNET = 0x7f + IN_MASK_ADD = 0x20000000 + IN_MODIFY = 0x2 + IN_MOVE = 0xc0 + IN_MOVED_FROM = 0x40 + IN_MOVED_TO = 0x80 + IN_MOVE_SELF = 0x800 + IN_NONBLOCK = 0x80 + IN_ONESHOT = 0x80000000 + IN_ONLYDIR = 0x1000000 + IN_OPEN = 0x20 + IN_Q_OVERFLOW = 0x4000 + IN_UNMOUNT = 0x2000 + IPPROTO_AH = 0x33 + IPPROTO_BEETPH = 0x5e + IPPROTO_COMP = 0x6c + IPPROTO_DCCP = 0x21 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_ENCAP = 0x62 + IPPROTO_ESP = 0x32 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GRE = 0x2f + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IGMP = 0x2 + IPPROTO_IP = 0x0 + IPPROTO_IPIP = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_MH = 0x87 + IPPROTO_MTP = 0x5c + IPPROTO_NONE = 0x3b + IPPROTO_PIM = 0x67 + IPPROTO_PUP = 0xc + IPPROTO_RAW = 0xff + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_SCTP = 0x84 + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_UDP = 0x11 + IPPROTO_UDPLITE = 0x88 + IPV6_2292DSTOPTS = 0x4 + IPV6_2292HOPLIMIT = 0x8 + IPV6_2292HOPOPTS = 0x3 + IPV6_2292PKTINFO = 0x2 + IPV6_2292PKTOPTIONS = 0x6 + IPV6_2292RTHDR = 0x5 + IPV6_ADDRFORM = 0x1 + IPV6_ADD_MEMBERSHIP = 0x14 + IPV6_AUTHHDR = 0xa + IPV6_CHECKSUM = 0x7 + IPV6_DONTFRAG = 0x3e + IPV6_DROP_MEMBERSHIP = 0x15 + IPV6_DSTOPTS = 0x3b + IPV6_HOPLIMIT = 0x34 + IPV6_HOPOPTS = 0x36 + IPV6_IPSEC_POLICY = 0x22 + IPV6_JOIN_ANYCAST = 0x1b + IPV6_JOIN_GROUP = 0x14 + IPV6_LEAVE_ANYCAST = 0x1c + IPV6_LEAVE_GROUP = 0x15 + IPV6_MTU = 0x18 + IPV6_MTU_DISCOVER = 0x17 + IPV6_MULTICAST_HOPS = 0x12 + IPV6_MULTICAST_IF = 0x11 + IPV6_MULTICAST_LOOP = 0x13 + IPV6_NEXTHOP = 0x9 + IPV6_PATHMTU = 0x3d + IPV6_PKTINFO = 0x32 + IPV6_PMTUDISC_DO = 0x2 + IPV6_PMTUDISC_DONT = 0x0 + IPV6_PMTUDISC_INTERFACE = 0x4 + IPV6_PMTUDISC_OMIT = 0x5 + IPV6_PMTUDISC_PROBE = 0x3 + IPV6_PMTUDISC_WANT = 0x1 + IPV6_RECVDSTOPTS = 0x3a + IPV6_RECVERR = 0x19 + IPV6_RECVHOPLIMIT = 0x33 + IPV6_RECVHOPOPTS = 0x35 + IPV6_RECVPATHMTU = 0x3c + IPV6_RECVPKTINFO = 0x31 + IPV6_RECVRTHDR = 0x38 + IPV6_RECVTCLASS = 0x42 + IPV6_ROUTER_ALERT = 0x16 + IPV6_RTHDR = 0x39 + IPV6_RTHDRDSTOPTS = 0x37 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_RXDSTOPTS = 0x3b + IPV6_RXHOPOPTS = 0x36 + IPV6_TCLASS = 0x43 + IPV6_UNICAST_HOPS = 0x10 + IPV6_V6ONLY = 0x1a + IPV6_XFRM_POLICY = 0x23 + IP_ADD_MEMBERSHIP = 0x23 + IP_ADD_SOURCE_MEMBERSHIP = 0x27 + IP_BLOCK_SOURCE = 0x26 + IP_CHECKSUM = 0x17 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DROP_MEMBERSHIP = 0x24 + IP_DROP_SOURCE_MEMBERSHIP = 0x28 + IP_FREEBIND = 0xf + IP_HDRINCL = 0x3 + IP_IPSEC_POLICY = 0x10 + IP_MAXPACKET = 0xffff + IP_MAX_MEMBERSHIPS = 0x14 + IP_MF = 0x2000 + IP_MINTTL = 0x15 + IP_MSFILTER = 0x29 + IP_MSS = 0x240 + IP_MTU = 0xe + IP_MTU_DISCOVER = 0xa + IP_MULTICAST_ALL = 0x31 + IP_MULTICAST_IF = 0x20 + IP_MULTICAST_LOOP = 0x22 + IP_MULTICAST_TTL = 0x21 + IP_NODEFRAG = 0x16 + IP_OFFMASK = 0x1fff + IP_OPTIONS = 0x4 + IP_ORIGDSTADDR = 0x14 + IP_PASSSEC = 0x12 + IP_PKTINFO = 0x8 + IP_PKTOPTIONS = 0x9 + IP_PMTUDISC = 0xa + IP_PMTUDISC_DO = 0x2 + IP_PMTUDISC_DONT = 0x0 + IP_PMTUDISC_INTERFACE = 0x4 + IP_PMTUDISC_OMIT = 0x5 + IP_PMTUDISC_PROBE = 0x3 + IP_PMTUDISC_WANT = 0x1 + IP_RECVERR = 0xb + IP_RECVOPTS = 0x6 + IP_RECVORIGDSTADDR = 0x14 + IP_RECVRETOPTS = 0x7 + IP_RECVTOS = 0xd + IP_RECVTTL = 0xc + IP_RETOPTS = 0x7 + IP_RF = 0x8000 + IP_ROUTER_ALERT = 0x5 + IP_TOS = 0x1 + IP_TRANSPARENT = 0x13 + IP_TTL = 0x2 + IP_UNBLOCK_SOURCE = 0x25 + IP_UNICAST_IF = 0x32 + IP_XFRM_POLICY = 0x11 + ISIG = 0x1 + ISTRIP = 0x20 + IUTF8 = 0x4000 + IXANY = 0x800 + IXOFF = 0x1000 + IXON = 0x400 + LINUX_REBOOT_CMD_CAD_OFF = 0x0 + LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef + LINUX_REBOOT_CMD_HALT = 0xcdef0123 + LINUX_REBOOT_CMD_KEXEC = 0x45584543 + LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc + LINUX_REBOOT_CMD_RESTART = 0x1234567 + LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4 + LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2 + LINUX_REBOOT_MAGIC1 = 0xfee1dead + LINUX_REBOOT_MAGIC2 = 0x28121969 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_DODUMP = 0x11 + MADV_DOFORK = 0xb + MADV_DONTDUMP = 0x10 + MADV_DONTFORK = 0xa + MADV_DONTNEED = 0x4 + MADV_HUGEPAGE = 0xe + MADV_HWPOISON = 0x64 + MADV_MERGEABLE = 0xc + MADV_NOHUGEPAGE = 0xf + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_REMOVE = 0x9 + MADV_SEQUENTIAL = 0x2 + MADV_UNMERGEABLE = 0xd + MADV_WILLNEED = 0x3 + MAP_ANON = 0x800 + MAP_ANONYMOUS = 0x800 + MAP_DENYWRITE = 0x2000 + MAP_EXECUTABLE = 0x4000 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_GROWSDOWN = 0x1000 + MAP_HUGETLB = 0x80000 + MAP_HUGE_MASK = 0x3f + MAP_HUGE_SHIFT = 0x1a + MAP_LOCKED = 0x8000 + MAP_NONBLOCK = 0x20000 + MAP_NORESERVE = 0x400 + MAP_POPULATE = 0x10000 + MAP_PRIVATE = 0x2 + MAP_RENAME = 0x800 + MAP_SHARED = 0x1 + MAP_STACK = 0x40000 + MAP_TYPE = 0xf + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MNT_DETACH = 0x2 + MNT_EXPIRE = 0x4 + MNT_FORCE = 0x1 + MSG_CMSG_CLOEXEC = 0x40000000 + MSG_CONFIRM = 0x800 + MSG_CTRUNC = 0x8 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x40 + MSG_EOR = 0x80 + MSG_ERRQUEUE = 0x2000 + MSG_FASTOPEN = 0x20000000 + MSG_FIN = 0x200 + MSG_MORE = 0x8000 + MSG_NOSIGNAL = 0x4000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_PROXY = 0x10 + MSG_RST = 0x1000 + MSG_SYN = 0x400 + MSG_TRUNC = 0x20 + MSG_TRYHARD = 0x4 + MSG_WAITALL = 0x100 + MSG_WAITFORONE = 0x10000 + MS_ACTIVE = 0x40000000 + MS_ASYNC = 0x1 + MS_BIND = 0x1000 + MS_DIRSYNC = 0x80 + MS_INVALIDATE = 0x2 + MS_I_VERSION = 0x800000 + MS_KERNMOUNT = 0x400000 + MS_LAZYTIME = 0x2000000 + MS_MANDLOCK = 0x40 + MS_MGC_MSK = 0xffff0000 + MS_MGC_VAL = 0xc0ed0000 + MS_MOVE = 0x2000 + MS_NOATIME = 0x400 + MS_NODEV = 0x4 + MS_NODIRATIME = 0x800 + MS_NOEXEC = 0x8 + MS_NOSUID = 0x2 + MS_NOUSER = -0x80000000 + MS_POSIXACL = 0x10000 + MS_PRIVATE = 0x40000 + MS_RDONLY = 0x1 + MS_REC = 0x4000 + MS_RELATIME = 0x200000 + MS_REMOUNT = 0x20 + MS_RMT_MASK = 0x2800051 + MS_SHARED = 0x100000 + MS_SILENT = 0x8000 + MS_SLAVE = 0x80000 + MS_STRICTATIME = 0x1000000 + MS_SYNC = 0x4 + MS_SYNCHRONOUS = 0x10 + MS_UNBINDABLE = 0x20000 + NAME_MAX = 0xff + NETLINK_ADD_MEMBERSHIP = 0x1 + NETLINK_AUDIT = 0x9 + NETLINK_BROADCAST_ERROR = 0x4 + NETLINK_CAP_ACK = 0xa + NETLINK_CONNECTOR = 0xb + NETLINK_CRYPTO = 0x15 + NETLINK_DNRTMSG = 0xe + NETLINK_DROP_MEMBERSHIP = 0x2 + NETLINK_ECRYPTFS = 0x13 + NETLINK_FIB_LOOKUP = 0xa + NETLINK_FIREWALL = 0x3 + NETLINK_GENERIC = 0x10 + NETLINK_INET_DIAG = 0x4 + NETLINK_IP6_FW = 0xd + NETLINK_ISCSI = 0x8 + NETLINK_KOBJECT_UEVENT = 0xf + NETLINK_LISTEN_ALL_NSID = 0x8 + NETLINK_LIST_MEMBERSHIPS = 0x9 + NETLINK_NETFILTER = 0xc + NETLINK_NFLOG = 0x5 + NETLINK_NO_ENOBUFS = 0x5 + NETLINK_PKTINFO = 0x3 + NETLINK_RDMA = 0x14 + NETLINK_ROUTE = 0x0 + NETLINK_RX_RING = 0x6 + NETLINK_SCSITRANSPORT = 0x12 + NETLINK_SELINUX = 0x7 + NETLINK_SOCK_DIAG = 0x4 + NETLINK_TX_RING = 0x7 + NETLINK_UNUSED = 0x1 + NETLINK_USERSOCK = 0x2 + NETLINK_XFRM = 0x6 + NLA_ALIGNTO = 0x4 + NLA_F_NESTED = 0x8000 + NLA_F_NET_BYTEORDER = 0x4000 + NLA_HDRLEN = 0x4 + NLMSG_ALIGNTO = 0x4 + NLMSG_DONE = 0x3 + NLMSG_ERROR = 0x2 + NLMSG_HDRLEN = 0x10 + NLMSG_MIN_TYPE = 0x10 + NLMSG_NOOP = 0x1 + NLMSG_OVERRUN = 0x4 + NLM_F_ACK = 0x4 + NLM_F_APPEND = 0x800 + NLM_F_ATOMIC = 0x400 + NLM_F_CREATE = 0x400 + NLM_F_DUMP = 0x300 + NLM_F_DUMP_INTR = 0x10 + NLM_F_ECHO = 0x8 + NLM_F_EXCL = 0x200 + NLM_F_MATCH = 0x200 + NLM_F_MULTI = 0x2 + NLM_F_REPLACE = 0x100 + NLM_F_REQUEST = 0x1 + NLM_F_ROOT = 0x100 + NOFLSH = 0x80 + OCRNL = 0x8 + OFDEL = 0x80 + OFILL = 0x40 + ONLCR = 0x4 + ONLRET = 0x20 + ONOCR = 0x10 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_APPEND = 0x8 + O_ASYNC = 0x1000 + O_CLOEXEC = 0x80000 + O_CREAT = 0x100 + O_DIRECT = 0x8000 + O_DIRECTORY = 0x10000 + O_DSYNC = 0x10 + O_EXCL = 0x400 + O_FSYNC = 0x4010 + O_LARGEFILE = 0x0 + O_NDELAY = 0x80 + O_NOATIME = 0x40000 + O_NOCTTY = 0x800 + O_NOFOLLOW = 0x20000 + O_NONBLOCK = 0x80 + O_PATH = 0x200000 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_RSYNC = 0x4010 + O_SYNC = 0x4010 + O_TMPFILE = 0x410000 + O_TRUNC = 0x200 + O_WRONLY = 0x1 + PACKET_ADD_MEMBERSHIP = 0x1 + PACKET_AUXDATA = 0x8 + PACKET_BROADCAST = 0x1 + PACKET_COPY_THRESH = 0x7 + PACKET_DROP_MEMBERSHIP = 0x2 + PACKET_FANOUT = 0x12 + PACKET_FANOUT_CBPF = 0x6 + PACKET_FANOUT_CPU = 0x2 + PACKET_FANOUT_DATA = 0x16 + PACKET_FANOUT_EBPF = 0x7 + PACKET_FANOUT_FLAG_DEFRAG = 0x8000 + PACKET_FANOUT_FLAG_ROLLOVER = 0x1000 + PACKET_FANOUT_HASH = 0x0 + PACKET_FANOUT_LB = 0x1 + PACKET_FANOUT_QM = 0x5 + PACKET_FANOUT_RND = 0x4 + PACKET_FANOUT_ROLLOVER = 0x3 + PACKET_FASTROUTE = 0x6 + PACKET_HDRLEN = 0xb + PACKET_HOST = 0x0 + PACKET_KERNEL = 0x7 + PACKET_LOOPBACK = 0x5 + PACKET_LOSS = 0xe + PACKET_MR_ALLMULTI = 0x2 + PACKET_MR_MULTICAST = 0x0 + PACKET_MR_PROMISC = 0x1 + PACKET_MR_UNICAST = 0x3 + PACKET_MULTICAST = 0x2 + PACKET_ORIGDEV = 0x9 + PACKET_OTHERHOST = 0x3 + PACKET_OUTGOING = 0x4 + PACKET_QDISC_BYPASS = 0x14 + PACKET_RECV_OUTPUT = 0x3 + PACKET_RESERVE = 0xc + PACKET_ROLLOVER_STATS = 0x15 + PACKET_RX_RING = 0x5 + PACKET_STATISTICS = 0x6 + PACKET_TIMESTAMP = 0x11 + PACKET_TX_HAS_OFF = 0x13 + PACKET_TX_RING = 0xd + PACKET_TX_TIMESTAMP = 0x10 + PACKET_USER = 0x6 + PACKET_VERSION = 0xa + PACKET_VNET_HDR = 0xf + PARENB = 0x100 + PARITY_CRC16_PR0 = 0x2 + PARITY_CRC16_PR0_CCITT = 0x4 + PARITY_CRC16_PR1 = 0x3 + PARITY_CRC16_PR1_CCITT = 0x5 + PARITY_CRC32_PR0_CCITT = 0x6 + PARITY_CRC32_PR1_CCITT = 0x7 + PARITY_DEFAULT = 0x0 + PARITY_NONE = 0x1 + PARMRK = 0x8 + PARODD = 0x200 + PENDIN = 0x4000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_GROWSDOWN = 0x1000000 + PROT_GROWSUP = 0x2000000 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + PR_CAPBSET_DROP = 0x18 + PR_CAPBSET_READ = 0x17 + PR_CAP_AMBIENT = 0x2f + PR_CAP_AMBIENT_CLEAR_ALL = 0x4 + PR_CAP_AMBIENT_IS_SET = 0x1 + PR_CAP_AMBIENT_LOWER = 0x3 + PR_CAP_AMBIENT_RAISE = 0x2 + PR_ENDIAN_BIG = 0x0 + PR_ENDIAN_LITTLE = 0x1 + PR_ENDIAN_PPC_LITTLE = 0x2 + PR_FPEMU_NOPRINT = 0x1 + PR_FPEMU_SIGFPE = 0x2 + PR_FP_EXC_ASYNC = 0x2 + PR_FP_EXC_DISABLED = 0x0 + PR_FP_EXC_DIV = 0x10000 + PR_FP_EXC_INV = 0x100000 + PR_FP_EXC_NONRECOV = 0x1 + PR_FP_EXC_OVF = 0x20000 + PR_FP_EXC_PRECISE = 0x3 + PR_FP_EXC_RES = 0x80000 + PR_FP_EXC_SW_ENABLE = 0x80 + PR_FP_EXC_UND = 0x40000 + PR_FP_MODE_FR = 0x1 + PR_FP_MODE_FRE = 0x2 + PR_GET_CHILD_SUBREAPER = 0x25 + PR_GET_DUMPABLE = 0x3 + PR_GET_ENDIAN = 0x13 + PR_GET_FPEMU = 0x9 + PR_GET_FPEXC = 0xb + PR_GET_FP_MODE = 0x2e + PR_GET_KEEPCAPS = 0x7 + PR_GET_NAME = 0x10 + PR_GET_NO_NEW_PRIVS = 0x27 + PR_GET_PDEATHSIG = 0x2 + PR_GET_SECCOMP = 0x15 + PR_GET_SECUREBITS = 0x1b + PR_GET_THP_DISABLE = 0x2a + PR_GET_TID_ADDRESS = 0x28 + PR_GET_TIMERSLACK = 0x1e + PR_GET_TIMING = 0xd + PR_GET_TSC = 0x19 + PR_GET_UNALIGN = 0x5 + PR_MCE_KILL = 0x21 + PR_MCE_KILL_CLEAR = 0x0 + PR_MCE_KILL_DEFAULT = 0x2 + PR_MCE_KILL_EARLY = 0x1 + PR_MCE_KILL_GET = 0x22 + PR_MCE_KILL_LATE = 0x0 + PR_MCE_KILL_SET = 0x1 + PR_MPX_DISABLE_MANAGEMENT = 0x2c + PR_MPX_ENABLE_MANAGEMENT = 0x2b + PR_SET_CHILD_SUBREAPER = 0x24 + PR_SET_DUMPABLE = 0x4 + PR_SET_ENDIAN = 0x14 + PR_SET_FPEMU = 0xa + PR_SET_FPEXC = 0xc + PR_SET_FP_MODE = 0x2d + PR_SET_KEEPCAPS = 0x8 + PR_SET_MM = 0x23 + PR_SET_MM_ARG_END = 0x9 + PR_SET_MM_ARG_START = 0x8 + PR_SET_MM_AUXV = 0xc + PR_SET_MM_BRK = 0x7 + PR_SET_MM_END_CODE = 0x2 + PR_SET_MM_END_DATA = 0x4 + PR_SET_MM_ENV_END = 0xb + PR_SET_MM_ENV_START = 0xa + PR_SET_MM_EXE_FILE = 0xd + PR_SET_MM_MAP = 0xe + PR_SET_MM_MAP_SIZE = 0xf + PR_SET_MM_START_BRK = 0x6 + PR_SET_MM_START_CODE = 0x1 + PR_SET_MM_START_DATA = 0x3 + PR_SET_MM_START_STACK = 0x5 + PR_SET_NAME = 0xf + PR_SET_NO_NEW_PRIVS = 0x26 + PR_SET_PDEATHSIG = 0x1 + PR_SET_PTRACER = 0x59616d61 + PR_SET_PTRACER_ANY = -0x1 + PR_SET_SECCOMP = 0x16 + PR_SET_SECUREBITS = 0x1c + PR_SET_THP_DISABLE = 0x29 + PR_SET_TIMERSLACK = 0x1d + PR_SET_TIMING = 0xe + PR_SET_TSC = 0x1a + PR_SET_UNALIGN = 0x6 + PR_TASK_PERF_EVENTS_DISABLE = 0x1f + PR_TASK_PERF_EVENTS_ENABLE = 0x20 + PR_TIMING_STATISTICAL = 0x0 + PR_TIMING_TIMESTAMP = 0x1 + PR_TSC_ENABLE = 0x1 + PR_TSC_SIGSEGV = 0x2 + PR_UNALIGN_NOPRINT = 0x1 + PR_UNALIGN_SIGBUS = 0x2 + PTRACE_ATTACH = 0x10 + PTRACE_CONT = 0x7 + PTRACE_DETACH = 0x11 + PTRACE_EVENT_CLONE = 0x3 + PTRACE_EVENT_EXEC = 0x4 + PTRACE_EVENT_EXIT = 0x6 + PTRACE_EVENT_FORK = 0x1 + PTRACE_EVENT_SECCOMP = 0x7 + PTRACE_EVENT_STOP = 0x80 + PTRACE_EVENT_VFORK = 0x2 + PTRACE_EVENT_VFORK_DONE = 0x5 + PTRACE_GETEVENTMSG = 0x4201 + PTRACE_GETFPREGS = 0xe + PTRACE_GETREGS = 0xc + PTRACE_GETREGSET = 0x4204 + PTRACE_GETSIGINFO = 0x4202 + PTRACE_GETSIGMASK = 0x420a + PTRACE_GET_THREAD_AREA = 0x19 + PTRACE_GET_THREAD_AREA_3264 = 0xc4 + PTRACE_GET_WATCH_REGS = 0xd0 + PTRACE_INTERRUPT = 0x4207 + PTRACE_KILL = 0x8 + PTRACE_LISTEN = 0x4208 + PTRACE_OLDSETOPTIONS = 0x15 + PTRACE_O_EXITKILL = 0x100000 + PTRACE_O_MASK = 0x3000ff + PTRACE_O_SUSPEND_SECCOMP = 0x200000 + PTRACE_O_TRACECLONE = 0x8 + PTRACE_O_TRACEEXEC = 0x10 + PTRACE_O_TRACEEXIT = 0x40 + PTRACE_O_TRACEFORK = 0x2 + PTRACE_O_TRACESECCOMP = 0x80 + PTRACE_O_TRACESYSGOOD = 0x1 + PTRACE_O_TRACEVFORK = 0x4 + PTRACE_O_TRACEVFORKDONE = 0x20 + PTRACE_PEEKDATA = 0x2 + PTRACE_PEEKDATA_3264 = 0xc1 + PTRACE_PEEKSIGINFO = 0x4209 + PTRACE_PEEKSIGINFO_SHARED = 0x1 + PTRACE_PEEKTEXT = 0x1 + PTRACE_PEEKTEXT_3264 = 0xc0 + PTRACE_PEEKUSR = 0x3 + PTRACE_POKEDATA = 0x5 + PTRACE_POKEDATA_3264 = 0xc3 + PTRACE_POKETEXT = 0x4 + PTRACE_POKETEXT_3264 = 0xc2 + PTRACE_POKEUSR = 0x6 + PTRACE_SEIZE = 0x4206 + PTRACE_SETFPREGS = 0xf + PTRACE_SETOPTIONS = 0x4200 + PTRACE_SETREGS = 0xd + PTRACE_SETREGSET = 0x4205 + PTRACE_SETSIGINFO = 0x4203 + PTRACE_SETSIGMASK = 0x420b + PTRACE_SET_THREAD_AREA = 0x1a + PTRACE_SET_WATCH_REGS = 0xd1 + PTRACE_SINGLESTEP = 0x9 + PTRACE_SYSCALL = 0x18 + PTRACE_TRACEME = 0x0 + RLIMIT_AS = 0x6 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x5 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = -0x1 + RTAX_ADVMSS = 0x8 + RTAX_CC_ALGO = 0x10 + RTAX_CWND = 0x7 + RTAX_FEATURES = 0xc + RTAX_FEATURE_ALLFRAG = 0x8 + RTAX_FEATURE_ECN = 0x1 + RTAX_FEATURE_MASK = 0xf + RTAX_FEATURE_SACK = 0x2 + RTAX_FEATURE_TIMESTAMP = 0x4 + RTAX_HOPLIMIT = 0xa + RTAX_INITCWND = 0xb + RTAX_INITRWND = 0xe + RTAX_LOCK = 0x1 + RTAX_MAX = 0x10 + RTAX_MTU = 0x2 + RTAX_QUICKACK = 0xf + RTAX_REORDERING = 0x9 + RTAX_RTO_MIN = 0xd + RTAX_RTT = 0x4 + RTAX_RTTVAR = 0x5 + RTAX_SSTHRESH = 0x6 + RTAX_UNSPEC = 0x0 + RTAX_WINDOW = 0x3 + RTA_ALIGNTO = 0x4 + RTA_MAX = 0x16 + RTCF_DIRECTSRC = 0x4000000 + RTCF_DOREDIRECT = 0x1000000 + RTCF_LOG = 0x2000000 + RTCF_MASQ = 0x400000 + RTCF_NAT = 0x800000 + RTCF_VALVE = 0x200000 + RTF_ADDRCLASSMASK = 0xf8000000 + RTF_ADDRCONF = 0x40000 + RTF_ALLONLINK = 0x20000 + RTF_BROADCAST = 0x10000000 + RTF_CACHE = 0x1000000 + RTF_DEFAULT = 0x10000 + RTF_DYNAMIC = 0x10 + RTF_FLOW = 0x2000000 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_INTERFACE = 0x40000000 + RTF_IRTT = 0x100 + RTF_LINKRT = 0x100000 + RTF_LOCAL = 0x80000000 + RTF_MODIFIED = 0x20 + RTF_MSS = 0x40 + RTF_MTU = 0x40 + RTF_MULTICAST = 0x20000000 + RTF_NAT = 0x8000000 + RTF_NOFORWARD = 0x1000 + RTF_NONEXTHOP = 0x200000 + RTF_NOPMTUDISC = 0x4000 + RTF_POLICY = 0x4000000 + RTF_REINSTATE = 0x8 + RTF_REJECT = 0x200 + RTF_STATIC = 0x400 + RTF_THROW = 0x2000 + RTF_UP = 0x1 + RTF_WINDOW = 0x80 + RTF_XRESOLVE = 0x800 + RTM_BASE = 0x10 + RTM_DELACTION = 0x31 + RTM_DELADDR = 0x15 + RTM_DELADDRLABEL = 0x49 + RTM_DELLINK = 0x11 + RTM_DELMDB = 0x55 + RTM_DELNEIGH = 0x1d + RTM_DELNSID = 0x59 + RTM_DELQDISC = 0x25 + RTM_DELROUTE = 0x19 + RTM_DELRULE = 0x21 + RTM_DELTCLASS = 0x29 + RTM_DELTFILTER = 0x2d + RTM_F_CLONED = 0x200 + RTM_F_EQUALIZE = 0x400 + RTM_F_NOTIFY = 0x100 + RTM_F_PREFIX = 0x800 + RTM_GETACTION = 0x32 + RTM_GETADDR = 0x16 + RTM_GETADDRLABEL = 0x4a + RTM_GETANYCAST = 0x3e + RTM_GETDCB = 0x4e + RTM_GETLINK = 0x12 + RTM_GETMDB = 0x56 + RTM_GETMULTICAST = 0x3a + RTM_GETNEIGH = 0x1e + RTM_GETNEIGHTBL = 0x42 + RTM_GETNETCONF = 0x52 + RTM_GETNSID = 0x5a + RTM_GETQDISC = 0x26 + RTM_GETROUTE = 0x1a + RTM_GETRULE = 0x22 + RTM_GETTCLASS = 0x2a + RTM_GETTFILTER = 0x2e + RTM_MAX = 0x5b + RTM_NEWACTION = 0x30 + RTM_NEWADDR = 0x14 + RTM_NEWADDRLABEL = 0x48 + RTM_NEWLINK = 0x10 + RTM_NEWMDB = 0x54 + RTM_NEWNDUSEROPT = 0x44 + RTM_NEWNEIGH = 0x1c + RTM_NEWNEIGHTBL = 0x40 + RTM_NEWNETCONF = 0x50 + RTM_NEWNSID = 0x58 + RTM_NEWPREFIX = 0x34 + RTM_NEWQDISC = 0x24 + RTM_NEWROUTE = 0x18 + RTM_NEWRULE = 0x20 + RTM_NEWTCLASS = 0x28 + RTM_NEWTFILTER = 0x2c + RTM_NR_FAMILIES = 0x13 + RTM_NR_MSGTYPES = 0x4c + RTM_SETDCB = 0x4f + RTM_SETLINK = 0x13 + RTM_SETNEIGHTBL = 0x43 + RTNH_ALIGNTO = 0x4 + RTNH_COMPARE_MASK = 0x11 + RTNH_F_DEAD = 0x1 + RTNH_F_LINKDOWN = 0x10 + RTNH_F_OFFLOAD = 0x8 + RTNH_F_ONLINK = 0x4 + RTNH_F_PERVASIVE = 0x2 + RTN_MAX = 0xb + RTPROT_BABEL = 0x2a + RTPROT_BIRD = 0xc + RTPROT_BOOT = 0x3 + RTPROT_DHCP = 0x10 + RTPROT_DNROUTED = 0xd + RTPROT_GATED = 0x8 + RTPROT_KERNEL = 0x2 + RTPROT_MROUTED = 0x11 + RTPROT_MRT = 0xa + RTPROT_NTK = 0xf + RTPROT_RA = 0x9 + RTPROT_REDIRECT = 0x1 + RTPROT_STATIC = 0x4 + RTPROT_UNSPEC = 0x0 + RTPROT_XORP = 0xe + RTPROT_ZEBRA = 0xb + RT_CLASS_DEFAULT = 0xfd + RT_CLASS_LOCAL = 0xff + RT_CLASS_MAIN = 0xfe + RT_CLASS_MAX = 0xff + RT_CLASS_UNSPEC = 0x0 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + RUSAGE_THREAD = 0x1 + SCM_CREDENTIALS = 0x2 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x1d + SCM_TIMESTAMPING = 0x25 + SCM_TIMESTAMPNS = 0x23 + SCM_WIFI_STATUS = 0x29 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDDLCI = 0x8980 + SIOCADDMULTI = 0x8931 + SIOCADDRT = 0x890b + SIOCATMARK = 0x40047307 + SIOCDARP = 0x8953 + SIOCDELDLCI = 0x8981 + SIOCDELMULTI = 0x8932 + SIOCDELRT = 0x890c + SIOCDEVPRIVATE = 0x89f0 + SIOCDIFADDR = 0x8936 + SIOCDRARP = 0x8960 + SIOCGARP = 0x8954 + SIOCGIFADDR = 0x8915 + SIOCGIFBR = 0x8940 + SIOCGIFBRDADDR = 0x8919 + SIOCGIFCONF = 0x8912 + SIOCGIFCOUNT = 0x8938 + SIOCGIFDSTADDR = 0x8917 + SIOCGIFENCAP = 0x8925 + SIOCGIFFLAGS = 0x8913 + SIOCGIFHWADDR = 0x8927 + SIOCGIFINDEX = 0x8933 + SIOCGIFMAP = 0x8970 + SIOCGIFMEM = 0x891f + SIOCGIFMETRIC = 0x891d + SIOCGIFMTU = 0x8921 + SIOCGIFNAME = 0x8910 + SIOCGIFNETMASK = 0x891b + SIOCGIFPFLAGS = 0x8935 + SIOCGIFSLAVE = 0x8929 + SIOCGIFTXQLEN = 0x8942 + SIOCGPGRP = 0x40047309 + SIOCGRARP = 0x8961 + SIOCGSTAMP = 0x8906 + SIOCGSTAMPNS = 0x8907 + SIOCPROTOPRIVATE = 0x89e0 + SIOCRTMSG = 0x890d + SIOCSARP = 0x8955 + SIOCSIFADDR = 0x8916 + SIOCSIFBR = 0x8941 + SIOCSIFBRDADDR = 0x891a + SIOCSIFDSTADDR = 0x8918 + SIOCSIFENCAP = 0x8926 + SIOCSIFFLAGS = 0x8914 + SIOCSIFHWADDR = 0x8924 + SIOCSIFHWBROADCAST = 0x8937 + SIOCSIFLINK = 0x8911 + SIOCSIFMAP = 0x8971 + SIOCSIFMEM = 0x8920 + SIOCSIFMETRIC = 0x891e + SIOCSIFMTU = 0x8922 + SIOCSIFNAME = 0x8923 + SIOCSIFNETMASK = 0x891c + SIOCSIFPFLAGS = 0x8934 + SIOCSIFSLAVE = 0x8930 + SIOCSIFTXQLEN = 0x8943 + SIOCSPGRP = 0x80047308 + SIOCSRARP = 0x8962 + SOCK_CLOEXEC = 0x80000 + SOCK_DCCP = 0x6 + SOCK_DGRAM = 0x1 + SOCK_NONBLOCK = 0x80 + SOCK_PACKET = 0xa + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x2 + SOL_AAL = 0x109 + SOL_ATM = 0x108 + SOL_DECNET = 0x105 + SOL_ICMPV6 = 0x3a + SOL_IP = 0x0 + SOL_IPV6 = 0x29 + SOL_IRDA = 0x10a + SOL_PACKET = 0x107 + SOL_RAW = 0xff + SOL_SOCKET = 0xffff + SOL_TCP = 0x6 + SOL_X25 = 0x106 + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x1009 + SO_ATTACH_BPF = 0x32 + SO_ATTACH_FILTER = 0x1a + SO_BINDTODEVICE = 0x19 + SO_BPF_EXTENSIONS = 0x30 + SO_BROADCAST = 0x20 + SO_BSDCOMPAT = 0xe + SO_BUSY_POLL = 0x2e + SO_DEBUG = 0x1 + SO_DETACH_BPF = 0x1b + SO_DETACH_FILTER = 0x1b + SO_DOMAIN = 0x1029 + SO_DONTROUTE = 0x10 + SO_ERROR = 0x1007 + SO_GET_FILTER = 0x1a + SO_INCOMING_CPU = 0x31 + SO_KEEPALIVE = 0x8 + SO_LINGER = 0x80 + SO_LOCK_FILTER = 0x2c + SO_MARK = 0x24 + SO_MAX_PACING_RATE = 0x2f + SO_NOFCS = 0x2b + SO_NO_CHECK = 0xb + SO_OOBINLINE = 0x100 + SO_PASSCRED = 0x11 + SO_PASSSEC = 0x22 + SO_PEEK_OFF = 0x2a + SO_PEERCRED = 0x12 + SO_PEERNAME = 0x1c + SO_PEERSEC = 0x1e + SO_PRIORITY = 0xc + SO_PROTOCOL = 0x1028 + SO_RCVBUF = 0x1002 + SO_RCVBUFFORCE = 0x21 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x1006 + SO_REUSEADDR = 0x4 + SO_REUSEPORT = 0x200 + SO_RXQ_OVFL = 0x28 + SO_SECURITY_AUTHENTICATION = 0x16 + SO_SECURITY_ENCRYPTION_NETWORK = 0x18 + SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17 + SO_SELECT_ERR_QUEUE = 0x2d + SO_SNDBUF = 0x1001 + SO_SNDBUFFORCE = 0x1f + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x1005 + SO_STYLE = 0x1008 + SO_TIMESTAMP = 0x1d + SO_TIMESTAMPING = 0x25 + SO_TIMESTAMPNS = 0x23 + SO_TYPE = 0x1008 + SO_WIFI_STATUS = 0x29 + S_BLKSIZE = 0x200 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + TCFLSH = 0x5407 + TCIFLUSH = 0x0 + TCIOFLUSH = 0x2 + TCOFLUSH = 0x1 + TCP_CONGESTION = 0xd + TCP_COOKIE_IN_ALWAYS = 0x1 + TCP_COOKIE_MAX = 0x10 + TCP_COOKIE_MIN = 0x8 + TCP_COOKIE_OUT_NEVER = 0x2 + TCP_COOKIE_PAIR_SIZE = 0x20 + TCP_COOKIE_TRANSACTIONS = 0xf + TCP_CORK = 0x3 + TCP_DEFER_ACCEPT = 0x9 + TCP_FASTOPEN = 0x17 + TCP_INFO = 0xb + TCP_KEEPCNT = 0x6 + TCP_KEEPIDLE = 0x4 + TCP_KEEPINTVL = 0x5 + TCP_LINGER2 = 0x8 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0xe + TCP_MD5SIG_MAXKEYLEN = 0x50 + TCP_MSS = 0x200 + TCP_MSS_DEFAULT = 0x218 + TCP_MSS_DESIRED = 0x4c4 + TCP_NODELAY = 0x1 + TCP_QUEUE_SEQ = 0x15 + TCP_QUICKACK = 0xc + TCP_REPAIR = 0x13 + TCP_REPAIR_OPTIONS = 0x16 + TCP_REPAIR_QUEUE = 0x14 + TCP_SYNCNT = 0x7 + TCP_S_DATA_IN = 0x4 + TCP_S_DATA_OUT = 0x8 + TCP_THIN_DUPACK = 0x11 + TCP_THIN_LINEAR_TIMEOUTS = 0x10 + TCP_TIMESTAMP = 0x18 + TCP_USER_TIMEOUT = 0x12 + TCP_WINDOW_CLAMP = 0xa + TCSAFLUSH = 0x5410 + TCSBRK = 0x5405 + TCXONC = 0x5406 + TIOCCBRK = 0x5428 + TIOCCONS = 0x80047478 + TIOCEXCL = 0x740d + TIOCGDEV = 0x40045432 + TIOCGETD = 0x7400 + TIOCGETP = 0x7408 + TIOCGEXCL = 0x40045440 + TIOCGICOUNT = 0x5492 + TIOCGLCKTRMIOS = 0x548b + TIOCGLTC = 0x7474 + TIOCGPGRP = 0x40047477 + TIOCGPKT = 0x40045438 + TIOCGPTLCK = 0x40045439 + TIOCGPTN = 0x40045430 + TIOCGRS485 = 0x4020542e + TIOCGSERIAL = 0x5484 + TIOCGSID = 0x7416 + TIOCGSOFTCAR = 0x5481 + TIOCGWINSZ = 0x40087468 + TIOCINQ = 0x467f + TIOCLINUX = 0x5483 + TIOCMBIC = 0x741c + TIOCMBIS = 0x741b + TIOCMGET = 0x741d + TIOCMIWAIT = 0x5491 + TIOCMSET = 0x741a + TIOCM_CAR = 0x100 + TIOCM_CD = 0x100 + TIOCM_CTS = 0x40 + TIOCM_DSR = 0x400 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x200 + TIOCM_RNG = 0x200 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x20 + TIOCM_ST = 0x10 + TIOCNOTTY = 0x5471 + TIOCNXCL = 0x740e + TIOCOUTQ = 0x7472 + TIOCPKT = 0x5470 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCSBRK = 0x5427 + TIOCSCTTY = 0x5480 + TIOCSERCONFIG = 0x5488 + TIOCSERGETLSR = 0x548e + TIOCSERGETMULTI = 0x548f + TIOCSERGSTRUCT = 0x548d + TIOCSERGWILD = 0x5489 + TIOCSERSETMULTI = 0x5490 + TIOCSERSWILD = 0x548a + TIOCSER_TEMT = 0x1 + TIOCSETD = 0x7401 + TIOCSETN = 0x740a + TIOCSETP = 0x7409 + TIOCSIG = 0x80045436 + TIOCSLCKTRMIOS = 0x548c + TIOCSLTC = 0x7475 + TIOCSPGRP = 0x80047476 + TIOCSPTLCK = 0x80045431 + TIOCSRS485 = 0xc020542f + TIOCSSERIAL = 0x5485 + TIOCSSOFTCAR = 0x5482 + TIOCSTI = 0x5472 + TIOCSWINSZ = 0x80087467 + TIOCVHANGUP = 0x5437 + TOSTOP = 0x8000 + TUNATTACHFILTER = 0x801054d5 + TUNDETACHFILTER = 0x801054d6 + TUNGETFEATURES = 0x400454cf + TUNGETFILTER = 0x401054db + TUNGETIFF = 0x400454d2 + TUNGETSNDBUF = 0x400454d3 + TUNGETVNETBE = 0x400454df + TUNGETVNETHDRSZ = 0x400454d7 + TUNGETVNETLE = 0x400454dd + TUNSETDEBUG = 0x800454c9 + TUNSETGROUP = 0x800454ce + TUNSETIFF = 0x800454ca + TUNSETIFINDEX = 0x800454da + TUNSETLINK = 0x800454cd + TUNSETNOCSUM = 0x800454c8 + TUNSETOFFLOAD = 0x800454d0 + TUNSETOWNER = 0x800454cc + TUNSETPERSIST = 0x800454cb + TUNSETQUEUE = 0x800454d9 + TUNSETSNDBUF = 0x800454d4 + TUNSETTXFILTER = 0x800454d1 + TUNSETVNETBE = 0x800454de + TUNSETVNETHDRSZ = 0x800454d8 + TUNSETVNETLE = 0x800454dc + VDISCARD = 0xd + VEOF = 0x10 + VEOL = 0x11 + VEOL2 = 0x6 + VERASE = 0x2 + VINTR = 0x0 + VKILL = 0x3 + VLNEXT = 0xf + VMIN = 0x4 + VQUIT = 0x1 + VREPRINT = 0xc + VSTART = 0x8 + VSTOP = 0x9 + VSUSP = 0xa + VSWTC = 0x7 + VSWTCH = 0x7 + VT0 = 0x0 + VT1 = 0x4000 + VTDLY = 0x4000 + VTIME = 0x5 + VWERASE = 0xe + WALL = 0x40000000 + WCLONE = 0x80000000 + WCONTINUED = 0x8 + WEXITED = 0x4 + WNOHANG = 0x1 + WNOTHREAD = 0x20000000 + WNOWAIT = 0x1000000 + WORDSIZE = 0x40 + WSTOPPED = 0x2 + WUNTRACED = 0x2 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x7d) + EADDRNOTAVAIL = syscall.Errno(0x7e) + EADV = syscall.Errno(0x44) + EAFNOSUPPORT = syscall.Errno(0x7c) + EAGAIN = syscall.Errno(0xb) + EALREADY = syscall.Errno(0x95) + EBADE = syscall.Errno(0x32) + EBADF = syscall.Errno(0x9) + EBADFD = syscall.Errno(0x51) + EBADMSG = syscall.Errno(0x4d) + EBADR = syscall.Errno(0x33) + EBADRQC = syscall.Errno(0x36) + EBADSLT = syscall.Errno(0x37) + EBFONT = syscall.Errno(0x3b) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x9e) + ECHILD = syscall.Errno(0xa) + ECHRNG = syscall.Errno(0x25) + ECOMM = syscall.Errno(0x46) + ECONNABORTED = syscall.Errno(0x82) + ECONNREFUSED = syscall.Errno(0x92) + ECONNRESET = syscall.Errno(0x83) + EDEADLK = syscall.Errno(0x2d) + EDEADLOCK = syscall.Errno(0x38) + EDESTADDRREQ = syscall.Errno(0x60) + EDOM = syscall.Errno(0x21) + EDOTDOT = syscall.Errno(0x49) + EDQUOT = syscall.Errno(0x46d) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EHOSTDOWN = syscall.Errno(0x93) + EHOSTUNREACH = syscall.Errno(0x94) + EHWPOISON = syscall.Errno(0xa8) + EIDRM = syscall.Errno(0x24) + EILSEQ = syscall.Errno(0x58) + EINIT = syscall.Errno(0x8d) + EINPROGRESS = syscall.Errno(0x96) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x85) + EISDIR = syscall.Errno(0x15) + EISNAM = syscall.Errno(0x8b) + EKEYEXPIRED = syscall.Errno(0xa2) + EKEYREJECTED = syscall.Errno(0xa4) + EKEYREVOKED = syscall.Errno(0xa3) + EL2HLT = syscall.Errno(0x2c) + EL2NSYNC = syscall.Errno(0x26) + EL3HLT = syscall.Errno(0x27) + EL3RST = syscall.Errno(0x28) + ELIBACC = syscall.Errno(0x53) + ELIBBAD = syscall.Errno(0x54) + ELIBEXEC = syscall.Errno(0x57) + ELIBMAX = syscall.Errno(0x56) + ELIBSCN = syscall.Errno(0x55) + ELNRNG = syscall.Errno(0x29) + ELOOP = syscall.Errno(0x5a) + EMEDIUMTYPE = syscall.Errno(0xa0) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x61) + EMULTIHOP = syscall.Errno(0x4a) + ENAMETOOLONG = syscall.Errno(0x4e) + ENAVAIL = syscall.Errno(0x8a) + ENETDOWN = syscall.Errno(0x7f) + ENETRESET = syscall.Errno(0x81) + ENETUNREACH = syscall.Errno(0x80) + ENFILE = syscall.Errno(0x17) + ENOANO = syscall.Errno(0x35) + ENOBUFS = syscall.Errno(0x84) + ENOCSI = syscall.Errno(0x2b) + ENODATA = syscall.Errno(0x3d) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOKEY = syscall.Errno(0xa1) + ENOLCK = syscall.Errno(0x2e) + ENOLINK = syscall.Errno(0x43) + ENOMEDIUM = syscall.Errno(0x9f) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x23) + ENONET = syscall.Errno(0x40) + ENOPKG = syscall.Errno(0x41) + ENOPROTOOPT = syscall.Errno(0x63) + ENOSPC = syscall.Errno(0x1c) + ENOSR = syscall.Errno(0x3f) + ENOSTR = syscall.Errno(0x3c) + ENOSYS = syscall.Errno(0x59) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x86) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x5d) + ENOTNAM = syscall.Errno(0x89) + ENOTRECOVERABLE = syscall.Errno(0xa6) + ENOTSOCK = syscall.Errno(0x5f) + ENOTSUP = syscall.Errno(0x7a) + ENOTTY = syscall.Errno(0x19) + ENOTUNIQ = syscall.Errno(0x50) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x7a) + EOVERFLOW = syscall.Errno(0x4f) + EOWNERDEAD = syscall.Errno(0xa5) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x7b) + EPIPE = syscall.Errno(0x20) + EPROTO = syscall.Errno(0x47) + EPROTONOSUPPORT = syscall.Errno(0x78) + EPROTOTYPE = syscall.Errno(0x62) + ERANGE = syscall.Errno(0x22) + EREMCHG = syscall.Errno(0x52) + EREMDEV = syscall.Errno(0x8e) + EREMOTE = syscall.Errno(0x42) + EREMOTEIO = syscall.Errno(0x8c) + ERESTART = syscall.Errno(0x5b) + ERFKILL = syscall.Errno(0xa7) + EROFS = syscall.Errno(0x1e) + ESHUTDOWN = syscall.Errno(0x8f) + ESOCKTNOSUPPORT = syscall.Errno(0x79) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESRMNT = syscall.Errno(0x45) + ESTALE = syscall.Errno(0x97) + ESTRPIPE = syscall.Errno(0x5c) + ETIME = syscall.Errno(0x3e) + ETIMEDOUT = syscall.Errno(0x91) + ETOOMANYREFS = syscall.Errno(0x90) + ETXTBSY = syscall.Errno(0x1a) + EUCLEAN = syscall.Errno(0x87) + EUNATCH = syscall.Errno(0x2a) + EUSERS = syscall.Errno(0x5e) + EWOULDBLOCK = syscall.Errno(0xb) + EXDEV = syscall.Errno(0x12) + EXFULL = syscall.Errno(0x34) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0xa) + SIGCHLD = syscall.Signal(0x12) + SIGCLD = syscall.Signal(0x12) + SIGCONT = syscall.Signal(0x19) + SIGEMT = syscall.Signal(0x7) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x16) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPOLL = syscall.Signal(0x16) + SIGPROF = syscall.Signal(0x1d) + SIGPWR = syscall.Signal(0x13) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTOP = syscall.Signal(0x17) + SIGSYS = syscall.Signal(0xc) + SIGTERM = syscall.Signal(0xf) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x18) + SIGTTIN = syscall.Signal(0x1a) + SIGTTOU = syscall.Signal(0x1b) + SIGURG = syscall.Signal(0x15) + SIGUSR1 = syscall.Signal(0x10) + SIGUSR2 = syscall.Signal(0x11) + SIGVTALRM = syscall.Signal(0x1c) + SIGWINCH = syscall.Signal(0x14) + SIGXCPU = syscall.Signal(0x1e) + SIGXFSZ = syscall.Signal(0x1f) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "no such device or address", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource temporarily unavailable", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device or resource busy", + 17: "file exists", + 18: "invalid cross-device link", + 19: "no such device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "numerical result out of range", + 35: "no message of desired type", + 36: "identifier removed", + 37: "channel number out of range", + 38: "level 2 not synchronized", + 39: "level 3 halted", + 40: "level 3 reset", + 41: "link number out of range", + 42: "protocol driver not attached", + 43: "no CSI structure available", + 44: "level 2 halted", + 45: "resource deadlock avoided", + 46: "no locks available", + 50: "invalid exchange", + 51: "invalid request descriptor", + 52: "exchange full", + 53: "no anode", + 54: "invalid request code", + 55: "invalid slot", + 56: "file locking deadlock error", + 59: "bad font file format", + 60: "device not a stream", + 61: "no data available", + 62: "timer expired", + 63: "out of streams resources", + 64: "machine is not on the network", + 65: "package not installed", + 66: "object is remote", + 67: "link has been severed", + 68: "advertise error", + 69: "srmount error", + 70: "communication error on send", + 71: "protocol error", + 73: "RFS specific error", + 74: "multihop attempted", + 77: "bad message", + 78: "file name too long", + 79: "value too large for defined data type", + 80: "name not unique on network", + 81: "file descriptor in bad state", + 82: "remote address changed", + 83: "can not access a needed shared library", + 84: "accessing a corrupted shared library", + 85: ".lib section in a.out corrupted", + 86: "attempting to link in too many shared libraries", + 87: "cannot exec a shared library directly", + 88: "invalid or incomplete multibyte or wide character", + 89: "function not implemented", + 90: "too many levels of symbolic links", + 91: "interrupted system call should be restarted", + 92: "streams pipe error", + 93: "directory not empty", + 94: "too many users", + 95: "socket operation on non-socket", + 96: "destination address required", + 97: "message too long", + 98: "protocol wrong type for socket", + 99: "protocol not available", + 120: "protocol not supported", + 121: "socket type not supported", + 122: "operation not supported", + 123: "protocol family not supported", + 124: "address family not supported by protocol", + 125: "address already in use", + 126: "cannot assign requested address", + 127: "network is down", + 128: "network is unreachable", + 129: "network dropped connection on reset", + 130: "software caused connection abort", + 131: "connection reset by peer", + 132: "no buffer space available", + 133: "transport endpoint is already connected", + 134: "transport endpoint is not connected", + 135: "structure needs cleaning", + 137: "not a XENIX named type file", + 138: "no XENIX semaphores available", + 139: "is a named type file", + 140: "remote I/O error", + 141: "unknown error 141", + 142: "unknown error 142", + 143: "cannot send after transport endpoint shutdown", + 144: "too many references: cannot splice", + 145: "connection timed out", + 146: "connection refused", + 147: "host is down", + 148: "no route to host", + 149: "operation already in progress", + 150: "operation now in progress", + 151: "stale file handle", + 158: "operation canceled", + 159: "no medium found", + 160: "wrong medium type", + 161: "required key not available", + 162: "key has expired", + 163: "key has been revoked", + 164: "key was rejected by service", + 165: "owner died", + 166: "state not recoverable", + 167: "operation not possible due to RF-kill", + 168: "memory page has hardware error", + 1133: "disk quota exceeded", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/breakpoint trap", + 6: "aborted", + 7: "EMT trap", + 8: "floating point exception", + 9: "killed", + 10: "bus error", + 11: "segmentation fault", + 12: "bad system call", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "user defined signal 1", + 17: "user defined signal 2", + 18: "child exited", + 19: "power failure", + 20: "window changed", + 21: "urgent I/O condition", + 22: "I/O possible", + 23: "stopped (signal)", + 24: "stopped", + 25: "continued", + 26: "stopped (tty input)", + 27: "stopped (tty output)", + 28: "virtual timer expired", + 29: "profiling timer expired", + 30: "CPU time limit exceeded", + 31: "file size limit exceeded", +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_ppc64.go new file mode 100644 index 0000000000..8b42ca2fe9 --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -0,0 +1,1970 @@ +// mkerrors.sh -m64 +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build ppc64,linux + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -m64 _const.go + +package unix + +import "syscall" + +const ( + AF_ALG = 0x26 + AF_APPLETALK = 0x5 + AF_ASH = 0x12 + AF_ATMPVC = 0x8 + AF_ATMSVC = 0x14 + AF_AX25 = 0x3 + AF_BLUETOOTH = 0x1f + AF_BRIDGE = 0x7 + AF_CAIF = 0x25 + AF_CAN = 0x1d + AF_DECnet = 0xc + AF_ECONET = 0x13 + AF_FILE = 0x1 + AF_IEEE802154 = 0x24 + AF_INET = 0x2 + AF_INET6 = 0xa + AF_IPX = 0x4 + AF_IRDA = 0x17 + AF_ISDN = 0x22 + AF_IUCV = 0x20 + AF_KEY = 0xf + AF_LLC = 0x1a + AF_LOCAL = 0x1 + AF_MAX = 0x29 + AF_NETBEUI = 0xd + AF_NETLINK = 0x10 + AF_NETROM = 0x6 + AF_NFC = 0x27 + AF_PACKET = 0x11 + AF_PHONET = 0x23 + AF_PPPOX = 0x18 + AF_RDS = 0x15 + AF_ROSE = 0xb + AF_ROUTE = 0x10 + AF_RXRPC = 0x21 + AF_SECURITY = 0xe + AF_SNA = 0x16 + AF_TIPC = 0x1e + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_VSOCK = 0x28 + AF_WANPIPE = 0x19 + AF_X25 = 0x9 + ARPHRD_6LOWPAN = 0x339 + ARPHRD_ADAPT = 0x108 + ARPHRD_APPLETLK = 0x8 + ARPHRD_ARCNET = 0x7 + ARPHRD_ASH = 0x30d + ARPHRD_ATM = 0x13 + ARPHRD_AX25 = 0x3 + ARPHRD_BIF = 0x307 + ARPHRD_CAIF = 0x336 + ARPHRD_CAN = 0x118 + ARPHRD_CHAOS = 0x5 + ARPHRD_CISCO = 0x201 + ARPHRD_CSLIP = 0x101 + ARPHRD_CSLIP6 = 0x103 + ARPHRD_DDCMP = 0x205 + ARPHRD_DLCI = 0xf + ARPHRD_ECONET = 0x30e + ARPHRD_EETHER = 0x2 + ARPHRD_ETHER = 0x1 + ARPHRD_EUI64 = 0x1b + ARPHRD_FCAL = 0x311 + ARPHRD_FCFABRIC = 0x313 + ARPHRD_FCPL = 0x312 + ARPHRD_FCPP = 0x310 + ARPHRD_FDDI = 0x306 + ARPHRD_FRAD = 0x302 + ARPHRD_HDLC = 0x201 + ARPHRD_HIPPI = 0x30c + ARPHRD_HWX25 = 0x110 + ARPHRD_IEEE1394 = 0x18 + ARPHRD_IEEE802 = 0x6 + ARPHRD_IEEE80211 = 0x321 + ARPHRD_IEEE80211_PRISM = 0x322 + ARPHRD_IEEE80211_RADIOTAP = 0x323 + ARPHRD_IEEE802154 = 0x324 + ARPHRD_IEEE802154_MONITOR = 0x325 + ARPHRD_IEEE802_TR = 0x320 + ARPHRD_INFINIBAND = 0x20 + ARPHRD_IP6GRE = 0x337 + ARPHRD_IPDDP = 0x309 + ARPHRD_IPGRE = 0x30a + ARPHRD_IRDA = 0x30f + ARPHRD_LAPB = 0x204 + ARPHRD_LOCALTLK = 0x305 + ARPHRD_LOOPBACK = 0x304 + ARPHRD_METRICOM = 0x17 + ARPHRD_NETLINK = 0x338 + ARPHRD_NETROM = 0x0 + ARPHRD_NONE = 0xfffe + ARPHRD_PHONET = 0x334 + ARPHRD_PHONET_PIPE = 0x335 + ARPHRD_PIMREG = 0x30b + ARPHRD_PPP = 0x200 + ARPHRD_PRONET = 0x4 + ARPHRD_RAWHDLC = 0x206 + ARPHRD_ROSE = 0x10e + ARPHRD_RSRVD = 0x104 + ARPHRD_SIT = 0x308 + ARPHRD_SKIP = 0x303 + ARPHRD_SLIP = 0x100 + ARPHRD_SLIP6 = 0x102 + ARPHRD_TUNNEL = 0x300 + ARPHRD_TUNNEL6 = 0x301 + ARPHRD_VOID = 0xffff + ARPHRD_X25 = 0x10f + B0 = 0x0 + B1000000 = 0x17 + B110 = 0x3 + B115200 = 0x11 + B1152000 = 0x18 + B1200 = 0x9 + B134 = 0x4 + B150 = 0x5 + B1500000 = 0x19 + B1800 = 0xa + B19200 = 0xe + B200 = 0x6 + B2000000 = 0x1a + B230400 = 0x12 + B2400 = 0xb + B2500000 = 0x1b + B300 = 0x7 + B3000000 = 0x1c + B3500000 = 0x1d + B38400 = 0xf + B4000000 = 0x1e + B460800 = 0x13 + B4800 = 0xc + B50 = 0x1 + B500000 = 0x14 + B57600 = 0x10 + B576000 = 0x15 + B600 = 0x8 + B75 = 0x2 + B921600 = 0x16 + B9600 = 0xd + BOTHER = 0x1f + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXINSNS = 0x1000 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MOD = 0x90 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BPF_XOR = 0xa0 + BRKINT = 0x2 + BS0 = 0x0 + BS1 = 0x8000 + BSDLY = 0x8000 + CBAUD = 0xff + CBAUDEX = 0x0 + CFLUSH = 0xf + CIBAUD = 0xff0000 + CLOCAL = 0x8000 + CLOCK_BOOTTIME = 0x7 + CLOCK_BOOTTIME_ALARM = 0x9 + CLOCK_DEFAULT = 0x0 + CLOCK_EXT = 0x1 + CLOCK_INT = 0x2 + CLOCK_MONOTONIC = 0x1 + CLOCK_MONOTONIC_COARSE = 0x6 + CLOCK_MONOTONIC_RAW = 0x4 + CLOCK_PROCESS_CPUTIME_ID = 0x2 + CLOCK_REALTIME = 0x0 + CLOCK_REALTIME_ALARM = 0x8 + CLOCK_REALTIME_COARSE = 0x5 + CLOCK_THREAD_CPUTIME_ID = 0x3 + CLOCK_TXFROMRX = 0x4 + CLOCK_TXINT = 0x3 + CLONE_CHILD_CLEARTID = 0x200000 + CLONE_CHILD_SETTID = 0x1000000 + CLONE_DETACHED = 0x400000 + CLONE_FILES = 0x400 + CLONE_FS = 0x200 + CLONE_IO = 0x80000000 + CLONE_NEWCGROUP = 0x2000000 + CLONE_NEWIPC = 0x8000000 + CLONE_NEWNET = 0x40000000 + CLONE_NEWNS = 0x20000 + CLONE_NEWPID = 0x20000000 + CLONE_NEWUSER = 0x10000000 + CLONE_NEWUTS = 0x4000000 + CLONE_PARENT = 0x8000 + CLONE_PARENT_SETTID = 0x100000 + CLONE_PTRACE = 0x2000 + CLONE_SETTLS = 0x80000 + CLONE_SIGHAND = 0x800 + CLONE_SYSVSEM = 0x40000 + CLONE_THREAD = 0x10000 + CLONE_UNTRACED = 0x800000 + CLONE_VFORK = 0x4000 + CLONE_VM = 0x100 + CMSPAR = 0x40000000 + CR0 = 0x0 + CR1 = 0x1000 + CR2 = 0x2000 + CR3 = 0x3000 + CRDLY = 0x3000 + CREAD = 0x800 + CRTSCTS = 0x80000000 + CS5 = 0x0 + CS6 = 0x100 + CS7 = 0x200 + CS8 = 0x300 + CSIGNAL = 0xff + CSIZE = 0x300 + CSTART = 0x11 + CSTATUS = 0x0 + CSTOP = 0x13 + CSTOPB = 0x400 + CSUSP = 0x1a + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x40 + ECHOE = 0x2 + ECHOK = 0x4 + ECHOKE = 0x1 + ECHONL = 0x10 + ECHOPRT = 0x20 + ENCODING_DEFAULT = 0x0 + ENCODING_FM_MARK = 0x3 + ENCODING_FM_SPACE = 0x4 + ENCODING_MANCHESTER = 0x5 + ENCODING_NRZ = 0x1 + ENCODING_NRZI = 0x2 + EPOLLERR = 0x8 + EPOLLET = 0x80000000 + EPOLLHUP = 0x10 + EPOLLIN = 0x1 + EPOLLMSG = 0x400 + EPOLLONESHOT = 0x40000000 + EPOLLOUT = 0x4 + EPOLLPRI = 0x2 + EPOLLRDBAND = 0x80 + EPOLLRDHUP = 0x2000 + EPOLLRDNORM = 0x40 + EPOLLWAKEUP = 0x20000000 + EPOLLWRBAND = 0x200 + EPOLLWRNORM = 0x100 + EPOLL_CLOEXEC = 0x80000 + EPOLL_CTL_ADD = 0x1 + EPOLL_CTL_DEL = 0x2 + EPOLL_CTL_MOD = 0x3 + ETH_P_1588 = 0x88f7 + ETH_P_8021AD = 0x88a8 + ETH_P_8021AH = 0x88e7 + ETH_P_8021Q = 0x8100 + ETH_P_80221 = 0x8917 + ETH_P_802_2 = 0x4 + ETH_P_802_3 = 0x1 + ETH_P_802_3_MIN = 0x600 + ETH_P_802_EX1 = 0x88b5 + ETH_P_AARP = 0x80f3 + ETH_P_AF_IUCV = 0xfbfb + ETH_P_ALL = 0x3 + ETH_P_AOE = 0x88a2 + ETH_P_ARCNET = 0x1a + ETH_P_ARP = 0x806 + ETH_P_ATALK = 0x809b + ETH_P_ATMFATE = 0x8884 + ETH_P_ATMMPOA = 0x884c + ETH_P_AX25 = 0x2 + ETH_P_BATMAN = 0x4305 + ETH_P_BPQ = 0x8ff + ETH_P_CAIF = 0xf7 + ETH_P_CAN = 0xc + ETH_P_CANFD = 0xd + ETH_P_CONTROL = 0x16 + ETH_P_CUST = 0x6006 + ETH_P_DDCMP = 0x6 + ETH_P_DEC = 0x6000 + ETH_P_DIAG = 0x6005 + ETH_P_DNA_DL = 0x6001 + ETH_P_DNA_RC = 0x6002 + ETH_P_DNA_RT = 0x6003 + ETH_P_DSA = 0x1b + ETH_P_ECONET = 0x18 + ETH_P_EDSA = 0xdada + ETH_P_FCOE = 0x8906 + ETH_P_FIP = 0x8914 + ETH_P_HDLC = 0x19 + ETH_P_IEEE802154 = 0xf6 + ETH_P_IEEEPUP = 0xa00 + ETH_P_IEEEPUPAT = 0xa01 + ETH_P_IP = 0x800 + ETH_P_IPV6 = 0x86dd + ETH_P_IPX = 0x8137 + ETH_P_IRDA = 0x17 + ETH_P_LAT = 0x6004 + ETH_P_LINK_CTL = 0x886c + ETH_P_LOCALTALK = 0x9 + ETH_P_LOOP = 0x60 + ETH_P_LOOPBACK = 0x9000 + ETH_P_MOBITEX = 0x15 + ETH_P_MPLS_MC = 0x8848 + ETH_P_MPLS_UC = 0x8847 + ETH_P_MVRP = 0x88f5 + ETH_P_PAE = 0x888e + ETH_P_PAUSE = 0x8808 + ETH_P_PHONET = 0xf5 + ETH_P_PPPTALK = 0x10 + ETH_P_PPP_DISC = 0x8863 + ETH_P_PPP_MP = 0x8 + ETH_P_PPP_SES = 0x8864 + ETH_P_PRP = 0x88fb + ETH_P_PUP = 0x200 + ETH_P_PUPAT = 0x201 + ETH_P_QINQ1 = 0x9100 + ETH_P_QINQ2 = 0x9200 + ETH_P_QINQ3 = 0x9300 + ETH_P_RARP = 0x8035 + ETH_P_SCA = 0x6007 + ETH_P_SLOW = 0x8809 + ETH_P_SNAP = 0x5 + ETH_P_TDLS = 0x890d + ETH_P_TEB = 0x6558 + ETH_P_TIPC = 0x88ca + ETH_P_TRAILER = 0x1c + ETH_P_TR_802_2 = 0x11 + ETH_P_WAN_PPP = 0x7 + ETH_P_WCCP = 0x883e + ETH_P_X25 = 0x805 + ETH_P_XDSA = 0xf8 + EXTA = 0xe + EXTB = 0xf + EXTPROC = 0x10000000 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FF0 = 0x0 + FF1 = 0x4000 + FFDLY = 0x4000 + FLUSHO = 0x800000 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x406 + F_EXLCK = 0x4 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLEASE = 0x401 + F_GETLK = 0x5 + F_GETLK64 = 0xc + F_GETOWN = 0x9 + F_GETOWN_EX = 0x10 + F_GETPIPE_SZ = 0x408 + F_GETSIG = 0xb + F_LOCK = 0x1 + F_NOTIFY = 0x402 + F_OFD_GETLK = 0x24 + F_OFD_SETLK = 0x25 + F_OFD_SETLKW = 0x26 + F_OK = 0x0 + F_RDLCK = 0x0 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLEASE = 0x400 + F_SETLK = 0x6 + F_SETLK64 = 0xd + F_SETLKW = 0x7 + F_SETLKW64 = 0xe + F_SETOWN = 0x8 + F_SETOWN_EX = 0xf + F_SETPIPE_SZ = 0x407 + F_SETSIG = 0xa + F_SHLCK = 0x8 + F_TEST = 0x3 + F_TLOCK = 0x2 + F_ULOCK = 0x0 + F_UNLCK = 0x2 + F_WRLCK = 0x1 + HUPCL = 0x4000 + IBSHIFT = 0x10 + ICANON = 0x100 + ICMPV6_FILTER = 0x1 + ICRNL = 0x100 + IEXTEN = 0x400 + IFA_F_DADFAILED = 0x8 + IFA_F_DEPRECATED = 0x20 + IFA_F_HOMEADDRESS = 0x10 + IFA_F_MANAGETEMPADDR = 0x100 + IFA_F_NODAD = 0x2 + IFA_F_NOPREFIXROUTE = 0x200 + IFA_F_OPTIMISTIC = 0x4 + IFA_F_PERMANENT = 0x80 + IFA_F_SECONDARY = 0x1 + IFA_F_TEMPORARY = 0x1 + IFA_F_TENTATIVE = 0x40 + IFA_MAX = 0x8 + IFF_ALLMULTI = 0x200 + IFF_ATTACH_QUEUE = 0x200 + IFF_AUTOMEDIA = 0x4000 + IFF_BROADCAST = 0x2 + IFF_DEBUG = 0x4 + IFF_DETACH_QUEUE = 0x400 + IFF_DORMANT = 0x20000 + IFF_DYNAMIC = 0x8000 + IFF_ECHO = 0x40000 + IFF_LOOPBACK = 0x8 + IFF_LOWER_UP = 0x10000 + IFF_MASTER = 0x400 + IFF_MULTICAST = 0x1000 + IFF_MULTI_QUEUE = 0x100 + IFF_NOARP = 0x80 + IFF_NOFILTER = 0x1000 + IFF_NOTRAILERS = 0x20 + IFF_NO_PI = 0x1000 + IFF_ONE_QUEUE = 0x2000 + IFF_PERSIST = 0x800 + IFF_POINTOPOINT = 0x10 + IFF_PORTSEL = 0x2000 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SLAVE = 0x800 + IFF_TAP = 0x2 + IFF_TUN = 0x1 + IFF_TUN_EXCL = 0x8000 + IFF_UP = 0x1 + IFF_VNET_HDR = 0x4000 + IFF_VOLATILE = 0x70c5a + IFNAMSIZ = 0x10 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_ACCESS = 0x1 + IN_ALL_EVENTS = 0xfff + IN_ATTRIB = 0x4 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLOEXEC = 0x80000 + IN_CLOSE = 0x18 + IN_CLOSE_NOWRITE = 0x10 + IN_CLOSE_WRITE = 0x8 + IN_CREATE = 0x100 + IN_DELETE = 0x200 + IN_DELETE_SELF = 0x400 + IN_DONT_FOLLOW = 0x2000000 + IN_EXCL_UNLINK = 0x4000000 + IN_IGNORED = 0x8000 + IN_ISDIR = 0x40000000 + IN_LOOPBACKNET = 0x7f + IN_MASK_ADD = 0x20000000 + IN_MODIFY = 0x2 + IN_MOVE = 0xc0 + IN_MOVED_FROM = 0x40 + IN_MOVED_TO = 0x80 + IN_MOVE_SELF = 0x800 + IN_NONBLOCK = 0x800 + IN_ONESHOT = 0x80000000 + IN_ONLYDIR = 0x1000000 + IN_OPEN = 0x20 + IN_Q_OVERFLOW = 0x4000 + IN_UNMOUNT = 0x2000 + IPPROTO_AH = 0x33 + IPPROTO_BEETPH = 0x5e + IPPROTO_COMP = 0x6c + IPPROTO_DCCP = 0x21 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_ENCAP = 0x62 + IPPROTO_ESP = 0x32 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GRE = 0x2f + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IGMP = 0x2 + IPPROTO_IP = 0x0 + IPPROTO_IPIP = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_MH = 0x87 + IPPROTO_MTP = 0x5c + IPPROTO_NONE = 0x3b + IPPROTO_PIM = 0x67 + IPPROTO_PUP = 0xc + IPPROTO_RAW = 0xff + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_SCTP = 0x84 + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_UDP = 0x11 + IPPROTO_UDPLITE = 0x88 + IPV6_2292DSTOPTS = 0x4 + IPV6_2292HOPLIMIT = 0x8 + IPV6_2292HOPOPTS = 0x3 + IPV6_2292PKTINFO = 0x2 + IPV6_2292PKTOPTIONS = 0x6 + IPV6_2292RTHDR = 0x5 + IPV6_ADDRFORM = 0x1 + IPV6_ADD_MEMBERSHIP = 0x14 + IPV6_AUTHHDR = 0xa + IPV6_CHECKSUM = 0x7 + IPV6_DROP_MEMBERSHIP = 0x15 + IPV6_DSTOPTS = 0x3b + IPV6_HOPLIMIT = 0x34 + IPV6_HOPOPTS = 0x36 + IPV6_IPSEC_POLICY = 0x22 + IPV6_JOIN_ANYCAST = 0x1b + IPV6_JOIN_GROUP = 0x14 + IPV6_LEAVE_ANYCAST = 0x1c + IPV6_LEAVE_GROUP = 0x15 + IPV6_MTU = 0x18 + IPV6_MTU_DISCOVER = 0x17 + IPV6_MULTICAST_HOPS = 0x12 + IPV6_MULTICAST_IF = 0x11 + IPV6_MULTICAST_LOOP = 0x13 + IPV6_NEXTHOP = 0x9 + IPV6_PKTINFO = 0x32 + IPV6_PMTUDISC_DO = 0x2 + IPV6_PMTUDISC_DONT = 0x0 + IPV6_PMTUDISC_INTERFACE = 0x4 + IPV6_PMTUDISC_OMIT = 0x5 + IPV6_PMTUDISC_PROBE = 0x3 + IPV6_PMTUDISC_WANT = 0x1 + IPV6_RECVDSTOPTS = 0x3a + IPV6_RECVERR = 0x19 + IPV6_RECVHOPLIMIT = 0x33 + IPV6_RECVHOPOPTS = 0x35 + IPV6_RECVPKTINFO = 0x31 + IPV6_RECVRTHDR = 0x38 + IPV6_RECVTCLASS = 0x42 + IPV6_ROUTER_ALERT = 0x16 + IPV6_RTHDR = 0x39 + IPV6_RTHDRDSTOPTS = 0x37 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_RXDSTOPTS = 0x3b + IPV6_RXHOPOPTS = 0x36 + IPV6_TCLASS = 0x43 + IPV6_UNICAST_HOPS = 0x10 + IPV6_V6ONLY = 0x1a + IPV6_XFRM_POLICY = 0x23 + IP_ADD_MEMBERSHIP = 0x23 + IP_ADD_SOURCE_MEMBERSHIP = 0x27 + IP_BLOCK_SOURCE = 0x26 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DROP_MEMBERSHIP = 0x24 + IP_DROP_SOURCE_MEMBERSHIP = 0x28 + IP_FREEBIND = 0xf + IP_HDRINCL = 0x3 + IP_IPSEC_POLICY = 0x10 + IP_MAXPACKET = 0xffff + IP_MAX_MEMBERSHIPS = 0x14 + IP_MF = 0x2000 + IP_MINTTL = 0x15 + IP_MSFILTER = 0x29 + IP_MSS = 0x240 + IP_MTU = 0xe + IP_MTU_DISCOVER = 0xa + IP_MULTICAST_ALL = 0x31 + IP_MULTICAST_IF = 0x20 + IP_MULTICAST_LOOP = 0x22 + IP_MULTICAST_TTL = 0x21 + IP_NODEFRAG = 0x16 + IP_OFFMASK = 0x1fff + IP_OPTIONS = 0x4 + IP_ORIGDSTADDR = 0x14 + IP_PASSSEC = 0x12 + IP_PKTINFO = 0x8 + IP_PKTOPTIONS = 0x9 + IP_PMTUDISC = 0xa + IP_PMTUDISC_DO = 0x2 + IP_PMTUDISC_DONT = 0x0 + IP_PMTUDISC_INTERFACE = 0x4 + IP_PMTUDISC_OMIT = 0x5 + IP_PMTUDISC_PROBE = 0x3 + IP_PMTUDISC_WANT = 0x1 + IP_RECVERR = 0xb + IP_RECVOPTS = 0x6 + IP_RECVORIGDSTADDR = 0x14 + IP_RECVRETOPTS = 0x7 + IP_RECVTOS = 0xd + IP_RECVTTL = 0xc + IP_RETOPTS = 0x7 + IP_RF = 0x8000 + IP_ROUTER_ALERT = 0x5 + IP_TOS = 0x1 + IP_TRANSPARENT = 0x13 + IP_TTL = 0x2 + IP_UNBLOCK_SOURCE = 0x25 + IP_UNICAST_IF = 0x32 + IP_XFRM_POLICY = 0x11 + ISIG = 0x80 + ISTRIP = 0x20 + IUCLC = 0x1000 + IUTF8 = 0x4000 + IXANY = 0x800 + IXOFF = 0x400 + IXON = 0x200 + LINUX_REBOOT_CMD_CAD_OFF = 0x0 + LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef + LINUX_REBOOT_CMD_HALT = 0xcdef0123 + LINUX_REBOOT_CMD_KEXEC = 0x45584543 + LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc + LINUX_REBOOT_CMD_RESTART = 0x1234567 + LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4 + LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2 + LINUX_REBOOT_MAGIC1 = 0xfee1dead + LINUX_REBOOT_MAGIC2 = 0x28121969 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_DODUMP = 0x11 + MADV_DOFORK = 0xb + MADV_DONTDUMP = 0x10 + MADV_DONTFORK = 0xa + MADV_DONTNEED = 0x4 + MADV_HUGEPAGE = 0xe + MADV_HWPOISON = 0x64 + MADV_MERGEABLE = 0xc + MADV_NOHUGEPAGE = 0xf + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_REMOVE = 0x9 + MADV_SEQUENTIAL = 0x2 + MADV_UNMERGEABLE = 0xd + MADV_WILLNEED = 0x3 + MAP_ANON = 0x20 + MAP_ANONYMOUS = 0x20 + MAP_DENYWRITE = 0x800 + MAP_EXECUTABLE = 0x1000 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_GROWSDOWN = 0x100 + MAP_HUGETLB = 0x40000 + MAP_HUGE_MASK = 0x3f + MAP_HUGE_SHIFT = 0x1a + MAP_LOCKED = 0x80 + MAP_NONBLOCK = 0x10000 + MAP_NORESERVE = 0x40 + MAP_POPULATE = 0x8000 + MAP_PRIVATE = 0x2 + MAP_SHARED = 0x1 + MAP_STACK = 0x20000 + MAP_TYPE = 0xf + MCL_CURRENT = 0x2000 + MCL_FUTURE = 0x4000 + MNT_DETACH = 0x2 + MNT_EXPIRE = 0x4 + MNT_FORCE = 0x1 + MSG_CMSG_CLOEXEC = 0x40000000 + MSG_CONFIRM = 0x800 + MSG_CTRUNC = 0x8 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x40 + MSG_EOR = 0x80 + MSG_ERRQUEUE = 0x2000 + MSG_FASTOPEN = 0x20000000 + MSG_FIN = 0x200 + MSG_MORE = 0x8000 + MSG_NOSIGNAL = 0x4000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_PROXY = 0x10 + MSG_RST = 0x1000 + MSG_SYN = 0x400 + MSG_TRUNC = 0x20 + MSG_TRYHARD = 0x4 + MSG_WAITALL = 0x100 + MSG_WAITFORONE = 0x10000 + MS_ACTIVE = 0x40000000 + MS_ASYNC = 0x1 + MS_BIND = 0x1000 + MS_DIRSYNC = 0x80 + MS_INVALIDATE = 0x2 + MS_I_VERSION = 0x800000 + MS_KERNMOUNT = 0x400000 + MS_MANDLOCK = 0x40 + MS_MGC_MSK = 0xffff0000 + MS_MGC_VAL = 0xc0ed0000 + MS_MOVE = 0x2000 + MS_NOATIME = 0x400 + MS_NODEV = 0x4 + MS_NODIRATIME = 0x800 + MS_NOEXEC = 0x8 + MS_NOSUID = 0x2 + MS_NOUSER = -0x80000000 + MS_POSIXACL = 0x10000 + MS_PRIVATE = 0x40000 + MS_RDONLY = 0x1 + MS_REC = 0x4000 + MS_RELATIME = 0x200000 + MS_REMOUNT = 0x20 + MS_RMT_MASK = 0x800051 + MS_SHARED = 0x100000 + MS_SILENT = 0x8000 + MS_SLAVE = 0x80000 + MS_STRICTATIME = 0x1000000 + MS_SYNC = 0x4 + MS_SYNCHRONOUS = 0x10 + MS_UNBINDABLE = 0x20000 + NAME_MAX = 0xff + NETLINK_ADD_MEMBERSHIP = 0x1 + NETLINK_AUDIT = 0x9 + NETLINK_BROADCAST_ERROR = 0x4 + NETLINK_CONNECTOR = 0xb + NETLINK_CRYPTO = 0x15 + NETLINK_DNRTMSG = 0xe + NETLINK_DROP_MEMBERSHIP = 0x2 + NETLINK_ECRYPTFS = 0x13 + NETLINK_FIB_LOOKUP = 0xa + NETLINK_FIREWALL = 0x3 + NETLINK_GENERIC = 0x10 + NETLINK_INET_DIAG = 0x4 + NETLINK_IP6_FW = 0xd + NETLINK_ISCSI = 0x8 + NETLINK_KOBJECT_UEVENT = 0xf + NETLINK_NETFILTER = 0xc + NETLINK_NFLOG = 0x5 + NETLINK_NO_ENOBUFS = 0x5 + NETLINK_PKTINFO = 0x3 + NETLINK_RDMA = 0x14 + NETLINK_ROUTE = 0x0 + NETLINK_RX_RING = 0x6 + NETLINK_SCSITRANSPORT = 0x12 + NETLINK_SELINUX = 0x7 + NETLINK_SOCK_DIAG = 0x4 + NETLINK_TX_RING = 0x7 + NETLINK_UNUSED = 0x1 + NETLINK_USERSOCK = 0x2 + NETLINK_XFRM = 0x6 + NL0 = 0x0 + NL1 = 0x100 + NL2 = 0x200 + NL3 = 0x300 + NLA_ALIGNTO = 0x4 + NLA_F_NESTED = 0x8000 + NLA_F_NET_BYTEORDER = 0x4000 + NLA_HDRLEN = 0x4 + NLDLY = 0x300 + NLMSG_ALIGNTO = 0x4 + NLMSG_DONE = 0x3 + NLMSG_ERROR = 0x2 + NLMSG_HDRLEN = 0x10 + NLMSG_MIN_TYPE = 0x10 + NLMSG_NOOP = 0x1 + NLMSG_OVERRUN = 0x4 + NLM_F_ACK = 0x4 + NLM_F_APPEND = 0x800 + NLM_F_ATOMIC = 0x400 + NLM_F_CREATE = 0x400 + NLM_F_DUMP = 0x300 + NLM_F_DUMP_INTR = 0x10 + NLM_F_ECHO = 0x8 + NLM_F_EXCL = 0x200 + NLM_F_MATCH = 0x200 + NLM_F_MULTI = 0x2 + NLM_F_REPLACE = 0x100 + NLM_F_REQUEST = 0x1 + NLM_F_ROOT = 0x100 + NOFLSH = 0x80000000 + OCRNL = 0x8 + OFDEL = 0x80 + OFILL = 0x40 + OLCUC = 0x4 + ONLCR = 0x2 + ONLRET = 0x20 + ONOCR = 0x10 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_APPEND = 0x400 + O_ASYNC = 0x2000 + O_CLOEXEC = 0x80000 + O_CREAT = 0x40 + O_DIRECT = 0x20000 + O_DIRECTORY = 0x4000 + O_DSYNC = 0x1000 + O_EXCL = 0x80 + O_FSYNC = 0x101000 + O_LARGEFILE = 0x0 + O_NDELAY = 0x800 + O_NOATIME = 0x40000 + O_NOCTTY = 0x100 + O_NOFOLLOW = 0x8000 + O_NONBLOCK = 0x800 + O_PATH = 0x200000 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_RSYNC = 0x101000 + O_SYNC = 0x101000 + O_TMPFILE = 0x410000 + O_TRUNC = 0x200 + O_WRONLY = 0x1 + PACKET_ADD_MEMBERSHIP = 0x1 + PACKET_AUXDATA = 0x8 + PACKET_BROADCAST = 0x1 + PACKET_COPY_THRESH = 0x7 + PACKET_DROP_MEMBERSHIP = 0x2 + PACKET_FANOUT = 0x12 + PACKET_FANOUT_CPU = 0x2 + PACKET_FANOUT_FLAG_DEFRAG = 0x8000 + PACKET_FANOUT_FLAG_ROLLOVER = 0x1000 + PACKET_FANOUT_HASH = 0x0 + PACKET_FANOUT_LB = 0x1 + PACKET_FANOUT_QM = 0x5 + PACKET_FANOUT_RND = 0x4 + PACKET_FANOUT_ROLLOVER = 0x3 + PACKET_FASTROUTE = 0x6 + PACKET_HDRLEN = 0xb + PACKET_HOST = 0x0 + PACKET_KERNEL = 0x7 + PACKET_LOOPBACK = 0x5 + PACKET_LOSS = 0xe + PACKET_MR_ALLMULTI = 0x2 + PACKET_MR_MULTICAST = 0x0 + PACKET_MR_PROMISC = 0x1 + PACKET_MR_UNICAST = 0x3 + PACKET_MULTICAST = 0x2 + PACKET_ORIGDEV = 0x9 + PACKET_OTHERHOST = 0x3 + PACKET_OUTGOING = 0x4 + PACKET_QDISC_BYPASS = 0x14 + PACKET_RECV_OUTPUT = 0x3 + PACKET_RESERVE = 0xc + PACKET_RX_RING = 0x5 + PACKET_STATISTICS = 0x6 + PACKET_TIMESTAMP = 0x11 + PACKET_TX_HAS_OFF = 0x13 + PACKET_TX_RING = 0xd + PACKET_TX_TIMESTAMP = 0x10 + PACKET_USER = 0x6 + PACKET_VERSION = 0xa + PACKET_VNET_HDR = 0xf + PARENB = 0x1000 + PARITY_CRC16_PR0 = 0x2 + PARITY_CRC16_PR0_CCITT = 0x4 + PARITY_CRC16_PR1 = 0x3 + PARITY_CRC16_PR1_CCITT = 0x5 + PARITY_CRC32_PR0_CCITT = 0x6 + PARITY_CRC32_PR1_CCITT = 0x7 + PARITY_DEFAULT = 0x0 + PARITY_NONE = 0x1 + PARMRK = 0x8 + PARODD = 0x2000 + PENDIN = 0x20000000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_GROWSDOWN = 0x1000000 + PROT_GROWSUP = 0x2000000 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_SAO = 0x10 + PROT_WRITE = 0x2 + PR_CAPBSET_DROP = 0x18 + PR_CAPBSET_READ = 0x17 + PR_ENDIAN_BIG = 0x0 + PR_ENDIAN_LITTLE = 0x1 + PR_ENDIAN_PPC_LITTLE = 0x2 + PR_FPEMU_NOPRINT = 0x1 + PR_FPEMU_SIGFPE = 0x2 + PR_FP_EXC_ASYNC = 0x2 + PR_FP_EXC_DISABLED = 0x0 + PR_FP_EXC_DIV = 0x10000 + PR_FP_EXC_INV = 0x100000 + PR_FP_EXC_NONRECOV = 0x1 + PR_FP_EXC_OVF = 0x20000 + PR_FP_EXC_PRECISE = 0x3 + PR_FP_EXC_RES = 0x80000 + PR_FP_EXC_SW_ENABLE = 0x80 + PR_FP_EXC_UND = 0x40000 + PR_GET_CHILD_SUBREAPER = 0x25 + PR_GET_DUMPABLE = 0x3 + PR_GET_ENDIAN = 0x13 + PR_GET_FPEMU = 0x9 + PR_GET_FPEXC = 0xb + PR_GET_KEEPCAPS = 0x7 + PR_GET_NAME = 0x10 + PR_GET_NO_NEW_PRIVS = 0x27 + PR_GET_PDEATHSIG = 0x2 + PR_GET_SECCOMP = 0x15 + PR_GET_SECUREBITS = 0x1b + PR_GET_THP_DISABLE = 0x2a + PR_GET_TID_ADDRESS = 0x28 + PR_GET_TIMERSLACK = 0x1e + PR_GET_TIMING = 0xd + PR_GET_TSC = 0x19 + PR_GET_UNALIGN = 0x5 + PR_MCE_KILL = 0x21 + PR_MCE_KILL_CLEAR = 0x0 + PR_MCE_KILL_DEFAULT = 0x2 + PR_MCE_KILL_EARLY = 0x1 + PR_MCE_KILL_GET = 0x22 + PR_MCE_KILL_LATE = 0x0 + PR_MCE_KILL_SET = 0x1 + PR_SET_CHILD_SUBREAPER = 0x24 + PR_SET_DUMPABLE = 0x4 + PR_SET_ENDIAN = 0x14 + PR_SET_FPEMU = 0xa + PR_SET_FPEXC = 0xc + PR_SET_KEEPCAPS = 0x8 + PR_SET_MM = 0x23 + PR_SET_MM_ARG_END = 0x9 + PR_SET_MM_ARG_START = 0x8 + PR_SET_MM_AUXV = 0xc + PR_SET_MM_BRK = 0x7 + PR_SET_MM_END_CODE = 0x2 + PR_SET_MM_END_DATA = 0x4 + PR_SET_MM_ENV_END = 0xb + PR_SET_MM_ENV_START = 0xa + PR_SET_MM_EXE_FILE = 0xd + PR_SET_MM_MAP = 0xe + PR_SET_MM_MAP_SIZE = 0xf + PR_SET_MM_START_BRK = 0x6 + PR_SET_MM_START_CODE = 0x1 + PR_SET_MM_START_DATA = 0x3 + PR_SET_MM_START_STACK = 0x5 + PR_SET_NAME = 0xf + PR_SET_NO_NEW_PRIVS = 0x26 + PR_SET_PDEATHSIG = 0x1 + PR_SET_PTRACER = 0x59616d61 + PR_SET_PTRACER_ANY = -0x1 + PR_SET_SECCOMP = 0x16 + PR_SET_SECUREBITS = 0x1c + PR_SET_THP_DISABLE = 0x29 + PR_SET_TIMERSLACK = 0x1d + PR_SET_TIMING = 0xe + PR_SET_TSC = 0x1a + PR_SET_UNALIGN = 0x6 + PR_TASK_PERF_EVENTS_DISABLE = 0x1f + PR_TASK_PERF_EVENTS_ENABLE = 0x20 + PR_TIMING_STATISTICAL = 0x0 + PR_TIMING_TIMESTAMP = 0x1 + PR_TSC_ENABLE = 0x1 + PR_TSC_SIGSEGV = 0x2 + PR_UNALIGN_NOPRINT = 0x1 + PR_UNALIGN_SIGBUS = 0x2 + PTRACE_ATTACH = 0x10 + PTRACE_CONT = 0x7 + PTRACE_DETACH = 0x11 + PTRACE_EVENT_CLONE = 0x3 + PTRACE_EVENT_EXEC = 0x4 + PTRACE_EVENT_EXIT = 0x6 + PTRACE_EVENT_FORK = 0x1 + PTRACE_EVENT_SECCOMP = 0x7 + PTRACE_EVENT_STOP = 0x80 + PTRACE_EVENT_VFORK = 0x2 + PTRACE_EVENT_VFORK_DONE = 0x5 + PTRACE_GETEVENTMSG = 0x4201 + PTRACE_GETEVRREGS = 0x14 + PTRACE_GETFPREGS = 0xe + PTRACE_GETREGS = 0xc + PTRACE_GETREGS64 = 0x16 + PTRACE_GETREGSET = 0x4204 + PTRACE_GETSIGINFO = 0x4202 + PTRACE_GETSIGMASK = 0x420a + PTRACE_GETVRREGS = 0x12 + PTRACE_GETVSRREGS = 0x1b + PTRACE_GET_DEBUGREG = 0x19 + PTRACE_INTERRUPT = 0x4207 + PTRACE_KILL = 0x8 + PTRACE_LISTEN = 0x4208 + PTRACE_O_EXITKILL = 0x100000 + PTRACE_O_MASK = 0x1000ff + PTRACE_O_TRACECLONE = 0x8 + PTRACE_O_TRACEEXEC = 0x10 + PTRACE_O_TRACEEXIT = 0x40 + PTRACE_O_TRACEFORK = 0x2 + PTRACE_O_TRACESECCOMP = 0x80 + PTRACE_O_TRACESYSGOOD = 0x1 + PTRACE_O_TRACEVFORK = 0x4 + PTRACE_O_TRACEVFORKDONE = 0x20 + PTRACE_PEEKDATA = 0x2 + PTRACE_PEEKSIGINFO = 0x4209 + PTRACE_PEEKSIGINFO_SHARED = 0x1 + PTRACE_PEEKTEXT = 0x1 + PTRACE_PEEKUSR = 0x3 + PTRACE_POKEDATA = 0x5 + PTRACE_POKETEXT = 0x4 + PTRACE_POKEUSR = 0x6 + PTRACE_SEIZE = 0x4206 + PTRACE_SETEVRREGS = 0x15 + PTRACE_SETFPREGS = 0xf + PTRACE_SETOPTIONS = 0x4200 + PTRACE_SETREGS = 0xd + PTRACE_SETREGS64 = 0x17 + PTRACE_SETREGSET = 0x4205 + PTRACE_SETSIGINFO = 0x4203 + PTRACE_SETSIGMASK = 0x420b + PTRACE_SETVRREGS = 0x13 + PTRACE_SETVSRREGS = 0x1c + PTRACE_SET_DEBUGREG = 0x1a + PTRACE_SINGLEBLOCK = 0x100 + PTRACE_SINGLESTEP = 0x9 + PTRACE_SYSCALL = 0x18 + PTRACE_TRACEME = 0x0 + PT_CCR = 0x26 + PT_CTR = 0x23 + PT_DAR = 0x29 + PT_DSCR = 0x2c + PT_DSISR = 0x2a + PT_FPR0 = 0x30 + PT_FPSCR = 0x50 + PT_LNK = 0x24 + PT_MSR = 0x21 + PT_NIP = 0x20 + PT_ORIG_R3 = 0x22 + PT_R0 = 0x0 + PT_R1 = 0x1 + PT_R10 = 0xa + PT_R11 = 0xb + PT_R12 = 0xc + PT_R13 = 0xd + PT_R14 = 0xe + PT_R15 = 0xf + PT_R16 = 0x10 + PT_R17 = 0x11 + PT_R18 = 0x12 + PT_R19 = 0x13 + PT_R2 = 0x2 + PT_R20 = 0x14 + PT_R21 = 0x15 + PT_R22 = 0x16 + PT_R23 = 0x17 + PT_R24 = 0x18 + PT_R25 = 0x19 + PT_R26 = 0x1a + PT_R27 = 0x1b + PT_R28 = 0x1c + PT_R29 = 0x1d + PT_R3 = 0x3 + PT_R30 = 0x1e + PT_R31 = 0x1f + PT_R4 = 0x4 + PT_R5 = 0x5 + PT_R6 = 0x6 + PT_R7 = 0x7 + PT_R8 = 0x8 + PT_R9 = 0x9 + PT_REGS_COUNT = 0x2c + PT_RESULT = 0x2b + PT_SOFTE = 0x27 + PT_TRAP = 0x28 + PT_VR0 = 0x52 + PT_VRSAVE = 0x94 + PT_VSCR = 0x93 + PT_VSR0 = 0x96 + PT_VSR31 = 0xd4 + PT_XER = 0x25 + RLIMIT_AS = 0x9 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x7 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = -0x1 + RTAX_ADVMSS = 0x8 + RTAX_CWND = 0x7 + RTAX_FEATURES = 0xc + RTAX_FEATURE_ALLFRAG = 0x8 + RTAX_FEATURE_ECN = 0x1 + RTAX_FEATURE_SACK = 0x2 + RTAX_FEATURE_TIMESTAMP = 0x4 + RTAX_HOPLIMIT = 0xa + RTAX_INITCWND = 0xb + RTAX_INITRWND = 0xe + RTAX_LOCK = 0x1 + RTAX_MAX = 0xf + RTAX_MTU = 0x2 + RTAX_QUICKACK = 0xf + RTAX_REORDERING = 0x9 + RTAX_RTO_MIN = 0xd + RTAX_RTT = 0x4 + RTAX_RTTVAR = 0x5 + RTAX_SSTHRESH = 0x6 + RTAX_UNSPEC = 0x0 + RTAX_WINDOW = 0x3 + RTA_ALIGNTO = 0x4 + RTA_MAX = 0x11 + RTCF_DIRECTSRC = 0x4000000 + RTCF_DOREDIRECT = 0x1000000 + RTCF_LOG = 0x2000000 + RTCF_MASQ = 0x400000 + RTCF_NAT = 0x800000 + RTCF_VALVE = 0x200000 + RTF_ADDRCLASSMASK = 0xf8000000 + RTF_ADDRCONF = 0x40000 + RTF_ALLONLINK = 0x20000 + RTF_BROADCAST = 0x10000000 + RTF_CACHE = 0x1000000 + RTF_DEFAULT = 0x10000 + RTF_DYNAMIC = 0x10 + RTF_FLOW = 0x2000000 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_INTERFACE = 0x40000000 + RTF_IRTT = 0x100 + RTF_LINKRT = 0x100000 + RTF_LOCAL = 0x80000000 + RTF_MODIFIED = 0x20 + RTF_MSS = 0x40 + RTF_MTU = 0x40 + RTF_MULTICAST = 0x20000000 + RTF_NAT = 0x8000000 + RTF_NOFORWARD = 0x1000 + RTF_NONEXTHOP = 0x200000 + RTF_NOPMTUDISC = 0x4000 + RTF_POLICY = 0x4000000 + RTF_REINSTATE = 0x8 + RTF_REJECT = 0x200 + RTF_STATIC = 0x400 + RTF_THROW = 0x2000 + RTF_UP = 0x1 + RTF_WINDOW = 0x80 + RTF_XRESOLVE = 0x800 + RTM_BASE = 0x10 + RTM_DELACTION = 0x31 + RTM_DELADDR = 0x15 + RTM_DELADDRLABEL = 0x49 + RTM_DELLINK = 0x11 + RTM_DELMDB = 0x55 + RTM_DELNEIGH = 0x1d + RTM_DELQDISC = 0x25 + RTM_DELROUTE = 0x19 + RTM_DELRULE = 0x21 + RTM_DELTCLASS = 0x29 + RTM_DELTFILTER = 0x2d + RTM_F_CLONED = 0x200 + RTM_F_EQUALIZE = 0x400 + RTM_F_NOTIFY = 0x100 + RTM_F_PREFIX = 0x800 + RTM_GETACTION = 0x32 + RTM_GETADDR = 0x16 + RTM_GETADDRLABEL = 0x4a + RTM_GETANYCAST = 0x3e + RTM_GETDCB = 0x4e + RTM_GETLINK = 0x12 + RTM_GETMDB = 0x56 + RTM_GETMULTICAST = 0x3a + RTM_GETNEIGH = 0x1e + RTM_GETNEIGHTBL = 0x42 + RTM_GETNETCONF = 0x52 + RTM_GETQDISC = 0x26 + RTM_GETROUTE = 0x1a + RTM_GETRULE = 0x22 + RTM_GETTCLASS = 0x2a + RTM_GETTFILTER = 0x2e + RTM_MAX = 0x57 + RTM_NEWACTION = 0x30 + RTM_NEWADDR = 0x14 + RTM_NEWADDRLABEL = 0x48 + RTM_NEWLINK = 0x10 + RTM_NEWMDB = 0x54 + RTM_NEWNDUSEROPT = 0x44 + RTM_NEWNEIGH = 0x1c + RTM_NEWNEIGHTBL = 0x40 + RTM_NEWNETCONF = 0x50 + RTM_NEWPREFIX = 0x34 + RTM_NEWQDISC = 0x24 + RTM_NEWROUTE = 0x18 + RTM_NEWRULE = 0x20 + RTM_NEWTCLASS = 0x28 + RTM_NEWTFILTER = 0x2c + RTM_NR_FAMILIES = 0x12 + RTM_NR_MSGTYPES = 0x48 + RTM_SETDCB = 0x4f + RTM_SETLINK = 0x13 + RTM_SETNEIGHTBL = 0x43 + RTNH_ALIGNTO = 0x4 + RTNH_F_DEAD = 0x1 + RTNH_F_ONLINK = 0x4 + RTNH_F_PERVASIVE = 0x2 + RTN_MAX = 0xb + RTPROT_BIRD = 0xc + RTPROT_BOOT = 0x3 + RTPROT_DHCP = 0x10 + RTPROT_DNROUTED = 0xd + RTPROT_GATED = 0x8 + RTPROT_KERNEL = 0x2 + RTPROT_MROUTED = 0x11 + RTPROT_MRT = 0xa + RTPROT_NTK = 0xf + RTPROT_RA = 0x9 + RTPROT_REDIRECT = 0x1 + RTPROT_STATIC = 0x4 + RTPROT_UNSPEC = 0x0 + RTPROT_XORP = 0xe + RTPROT_ZEBRA = 0xb + RT_CLASS_DEFAULT = 0xfd + RT_CLASS_LOCAL = 0xff + RT_CLASS_MAIN = 0xfe + RT_CLASS_MAX = 0xff + RT_CLASS_UNSPEC = 0x0 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + RUSAGE_THREAD = 0x1 + SCM_CREDENTIALS = 0x2 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x1d + SCM_TIMESTAMPING = 0x25 + SCM_TIMESTAMPNS = 0x23 + SCM_WIFI_STATUS = 0x29 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDDLCI = 0x8980 + SIOCADDMULTI = 0x8931 + SIOCADDRT = 0x890b + SIOCATMARK = 0x8905 + SIOCDARP = 0x8953 + SIOCDELDLCI = 0x8981 + SIOCDELMULTI = 0x8932 + SIOCDELRT = 0x890c + SIOCDEVPRIVATE = 0x89f0 + SIOCDIFADDR = 0x8936 + SIOCDRARP = 0x8960 + SIOCGARP = 0x8954 + SIOCGIFADDR = 0x8915 + SIOCGIFBR = 0x8940 + SIOCGIFBRDADDR = 0x8919 + SIOCGIFCONF = 0x8912 + SIOCGIFCOUNT = 0x8938 + SIOCGIFDSTADDR = 0x8917 + SIOCGIFENCAP = 0x8925 + SIOCGIFFLAGS = 0x8913 + SIOCGIFHWADDR = 0x8927 + SIOCGIFINDEX = 0x8933 + SIOCGIFMAP = 0x8970 + SIOCGIFMEM = 0x891f + SIOCGIFMETRIC = 0x891d + SIOCGIFMTU = 0x8921 + SIOCGIFNAME = 0x8910 + SIOCGIFNETMASK = 0x891b + SIOCGIFPFLAGS = 0x8935 + SIOCGIFSLAVE = 0x8929 + SIOCGIFTXQLEN = 0x8942 + SIOCGPGRP = 0x8904 + SIOCGRARP = 0x8961 + SIOCGSTAMP = 0x8906 + SIOCGSTAMPNS = 0x8907 + SIOCPROTOPRIVATE = 0x89e0 + SIOCRTMSG = 0x890d + SIOCSARP = 0x8955 + SIOCSIFADDR = 0x8916 + SIOCSIFBR = 0x8941 + SIOCSIFBRDADDR = 0x891a + SIOCSIFDSTADDR = 0x8918 + SIOCSIFENCAP = 0x8926 + SIOCSIFFLAGS = 0x8914 + SIOCSIFHWADDR = 0x8924 + SIOCSIFHWBROADCAST = 0x8937 + SIOCSIFLINK = 0x8911 + SIOCSIFMAP = 0x8971 + SIOCSIFMEM = 0x8920 + SIOCSIFMETRIC = 0x891e + SIOCSIFMTU = 0x8922 + SIOCSIFNAME = 0x8923 + SIOCSIFNETMASK = 0x891c + SIOCSIFPFLAGS = 0x8934 + SIOCSIFSLAVE = 0x8930 + SIOCSIFTXQLEN = 0x8943 + SIOCSPGRP = 0x8902 + SIOCSRARP = 0x8962 + SOCK_CLOEXEC = 0x80000 + SOCK_DCCP = 0x6 + SOCK_DGRAM = 0x2 + SOCK_NONBLOCK = 0x800 + SOCK_PACKET = 0xa + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_AAL = 0x109 + SOL_ATM = 0x108 + SOL_DECNET = 0x105 + SOL_ICMPV6 = 0x3a + SOL_IP = 0x0 + SOL_IPV6 = 0x29 + SOL_IRDA = 0x10a + SOL_PACKET = 0x107 + SOL_RAW = 0xff + SOL_SOCKET = 0x1 + SOL_TCP = 0x6 + SOL_X25 = 0x106 + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x1e + SO_ATTACH_FILTER = 0x1a + SO_BINDTODEVICE = 0x19 + SO_BPF_EXTENSIONS = 0x30 + SO_BROADCAST = 0x6 + SO_BSDCOMPAT = 0xe + SO_BUSY_POLL = 0x2e + SO_DEBUG = 0x1 + SO_DETACH_FILTER = 0x1b + SO_DOMAIN = 0x27 + SO_DONTROUTE = 0x5 + SO_ERROR = 0x4 + SO_GET_FILTER = 0x1a + SO_KEEPALIVE = 0x9 + SO_LINGER = 0xd + SO_LOCK_FILTER = 0x2c + SO_MARK = 0x24 + SO_MAX_PACING_RATE = 0x2f + SO_NOFCS = 0x2b + SO_NO_CHECK = 0xb + SO_OOBINLINE = 0xa + SO_PASSCRED = 0x14 + SO_PASSSEC = 0x22 + SO_PEEK_OFF = 0x2a + SO_PEERCRED = 0x15 + SO_PEERNAME = 0x1c + SO_PEERSEC = 0x1f + SO_PRIORITY = 0xc + SO_PROTOCOL = 0x26 + SO_RCVBUF = 0x8 + SO_RCVBUFFORCE = 0x21 + SO_RCVLOWAT = 0x10 + SO_RCVTIMEO = 0x12 + SO_REUSEADDR = 0x2 + SO_REUSEPORT = 0xf + SO_RXQ_OVFL = 0x28 + SO_SECURITY_AUTHENTICATION = 0x16 + SO_SECURITY_ENCRYPTION_NETWORK = 0x18 + SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17 + SO_SELECT_ERR_QUEUE = 0x2d + SO_SNDBUF = 0x7 + SO_SNDBUFFORCE = 0x20 + SO_SNDLOWAT = 0x11 + SO_SNDTIMEO = 0x13 + SO_TIMESTAMP = 0x1d + SO_TIMESTAMPING = 0x25 + SO_TIMESTAMPNS = 0x23 + SO_TYPE = 0x3 + SO_WIFI_STATUS = 0x29 + S_BLKSIZE = 0x200 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + TAB0 = 0x0 + TAB1 = 0x400 + TAB2 = 0x800 + TAB3 = 0xc00 + TABDLY = 0xc00 + TCFLSH = 0x2000741f + TCGETA = 0x40147417 + TCGETS = 0x402c7413 + TCIFLUSH = 0x0 + TCIOFF = 0x2 + TCIOFLUSH = 0x2 + TCION = 0x3 + TCOFLUSH = 0x1 + TCOOFF = 0x0 + TCOON = 0x1 + TCP_CONGESTION = 0xd + TCP_COOKIE_IN_ALWAYS = 0x1 + TCP_COOKIE_MAX = 0x10 + TCP_COOKIE_MIN = 0x8 + TCP_COOKIE_OUT_NEVER = 0x2 + TCP_COOKIE_PAIR_SIZE = 0x20 + TCP_COOKIE_TRANSACTIONS = 0xf + TCP_CORK = 0x3 + TCP_DEFER_ACCEPT = 0x9 + TCP_FASTOPEN = 0x17 + TCP_INFO = 0xb + TCP_KEEPCNT = 0x6 + TCP_KEEPIDLE = 0x4 + TCP_KEEPINTVL = 0x5 + TCP_LINGER2 = 0x8 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0xe + TCP_MD5SIG_MAXKEYLEN = 0x50 + TCP_MSS = 0x200 + TCP_MSS_DEFAULT = 0x218 + TCP_MSS_DESIRED = 0x4c4 + TCP_NODELAY = 0x1 + TCP_QUEUE_SEQ = 0x15 + TCP_QUICKACK = 0xc + TCP_REPAIR = 0x13 + TCP_REPAIR_OPTIONS = 0x16 + TCP_REPAIR_QUEUE = 0x14 + TCP_SYNCNT = 0x7 + TCP_S_DATA_IN = 0x4 + TCP_S_DATA_OUT = 0x8 + TCP_THIN_DUPACK = 0x11 + TCP_THIN_LINEAR_TIMEOUTS = 0x10 + TCP_TIMESTAMP = 0x18 + TCP_USER_TIMEOUT = 0x12 + TCP_WINDOW_CLAMP = 0xa + TCSAFLUSH = 0x2 + TCSBRK = 0x2000741d + TCSBRKP = 0x5425 + TCSETA = 0x80147418 + TCSETAF = 0x8014741c + TCSETAW = 0x80147419 + TCSETS = 0x802c7414 + TCSETSF = 0x802c7416 + TCSETSW = 0x802c7415 + TCXONC = 0x2000741e + TIOCCBRK = 0x5428 + TIOCCONS = 0x541d + TIOCEXCL = 0x540c + TIOCGDEV = 0x40045432 + TIOCGETC = 0x40067412 + TIOCGETD = 0x5424 + TIOCGETP = 0x40067408 + TIOCGEXCL = 0x40045440 + TIOCGICOUNT = 0x545d + TIOCGLCKTRMIOS = 0x5456 + TIOCGLTC = 0x40067474 + TIOCGPGRP = 0x40047477 + TIOCGPKT = 0x40045438 + TIOCGPTLCK = 0x40045439 + TIOCGPTN = 0x40045430 + TIOCGRS485 = 0x542e + TIOCGSERIAL = 0x541e + TIOCGSID = 0x5429 + TIOCGSOFTCAR = 0x5419 + TIOCGWINSZ = 0x40087468 + TIOCINQ = 0x4004667f + TIOCLINUX = 0x541c + TIOCMBIC = 0x5417 + TIOCMBIS = 0x5416 + TIOCMGET = 0x5415 + TIOCMIWAIT = 0x545c + TIOCMSET = 0x5418 + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_LOOP = 0x8000 + TIOCM_OUT1 = 0x2000 + TIOCM_OUT2 = 0x4000 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x5422 + TIOCNXCL = 0x540d + TIOCOUTQ = 0x40047473 + TIOCPKT = 0x5420 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCSBRK = 0x5427 + TIOCSCTTY = 0x540e + TIOCSERCONFIG = 0x5453 + TIOCSERGETLSR = 0x5459 + TIOCSERGETMULTI = 0x545a + TIOCSERGSTRUCT = 0x5458 + TIOCSERGWILD = 0x5454 + TIOCSERSETMULTI = 0x545b + TIOCSERSWILD = 0x5455 + TIOCSER_TEMT = 0x1 + TIOCSETC = 0x80067411 + TIOCSETD = 0x5423 + TIOCSETN = 0x8006740a + TIOCSETP = 0x80067409 + TIOCSIG = 0x80045436 + TIOCSLCKTRMIOS = 0x5457 + TIOCSLTC = 0x80067475 + TIOCSPGRP = 0x80047476 + TIOCSPTLCK = 0x80045431 + TIOCSRS485 = 0x542f + TIOCSSERIAL = 0x541f + TIOCSSOFTCAR = 0x541a + TIOCSTART = 0x2000746e + TIOCSTI = 0x5412 + TIOCSTOP = 0x2000746f + TIOCSWINSZ = 0x80087467 + TIOCVHANGUP = 0x5437 + TOSTOP = 0x400000 + TUNATTACHFILTER = 0x801054d5 + TUNDETACHFILTER = 0x801054d6 + TUNGETFEATURES = 0x400454cf + TUNGETFILTER = 0x401054db + TUNGETIFF = 0x400454d2 + TUNGETSNDBUF = 0x400454d3 + TUNGETVNETHDRSZ = 0x400454d7 + TUNSETDEBUG = 0x800454c9 + TUNSETGROUP = 0x800454ce + TUNSETIFF = 0x800454ca + TUNSETIFINDEX = 0x800454da + TUNSETLINK = 0x800454cd + TUNSETNOCSUM = 0x800454c8 + TUNSETOFFLOAD = 0x800454d0 + TUNSETOWNER = 0x800454cc + TUNSETPERSIST = 0x800454cb + TUNSETQUEUE = 0x800454d9 + TUNSETSNDBUF = 0x800454d4 + TUNSETTXFILTER = 0x800454d1 + TUNSETVNETHDRSZ = 0x800454d8 + VDISCARD = 0x10 + VEOF = 0x4 + VEOL = 0x6 + VEOL2 = 0x8 + VERASE = 0x2 + VINTR = 0x0 + VKILL = 0x3 + VLNEXT = 0xf + VMIN = 0x5 + VQUIT = 0x1 + VREPRINT = 0xb + VSTART = 0xd + VSTOP = 0xe + VSUSP = 0xc + VSWTC = 0x9 + VT0 = 0x0 + VT1 = 0x10000 + VTDLY = 0x10000 + VTIME = 0x7 + VWERASE = 0xa + WALL = 0x40000000 + WCLONE = 0x80000000 + WCONTINUED = 0x8 + WEXITED = 0x4 + WNOHANG = 0x1 + WNOTHREAD = 0x20000000 + WNOWAIT = 0x1000000 + WORDSIZE = 0x40 + WSTOPPED = 0x2 + WUNTRACED = 0x2 + XCASE = 0x4000 + XTABS = 0xc00 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x62) + EADDRNOTAVAIL = syscall.Errno(0x63) + EADV = syscall.Errno(0x44) + EAFNOSUPPORT = syscall.Errno(0x61) + EAGAIN = syscall.Errno(0xb) + EALREADY = syscall.Errno(0x72) + EBADE = syscall.Errno(0x34) + EBADF = syscall.Errno(0x9) + EBADFD = syscall.Errno(0x4d) + EBADMSG = syscall.Errno(0x4a) + EBADR = syscall.Errno(0x35) + EBADRQC = syscall.Errno(0x38) + EBADSLT = syscall.Errno(0x39) + EBFONT = syscall.Errno(0x3b) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x7d) + ECHILD = syscall.Errno(0xa) + ECHRNG = syscall.Errno(0x2c) + ECOMM = syscall.Errno(0x46) + ECONNABORTED = syscall.Errno(0x67) + ECONNREFUSED = syscall.Errno(0x6f) + ECONNRESET = syscall.Errno(0x68) + EDEADLK = syscall.Errno(0x23) + EDEADLOCK = syscall.Errno(0x3a) + EDESTADDRREQ = syscall.Errno(0x59) + EDOM = syscall.Errno(0x21) + EDOTDOT = syscall.Errno(0x49) + EDQUOT = syscall.Errno(0x7a) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EHOSTDOWN = syscall.Errno(0x70) + EHOSTUNREACH = syscall.Errno(0x71) + EHWPOISON = syscall.Errno(0x85) + EIDRM = syscall.Errno(0x2b) + EILSEQ = syscall.Errno(0x54) + EINPROGRESS = syscall.Errno(0x73) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x6a) + EISDIR = syscall.Errno(0x15) + EISNAM = syscall.Errno(0x78) + EKEYEXPIRED = syscall.Errno(0x7f) + EKEYREJECTED = syscall.Errno(0x81) + EKEYREVOKED = syscall.Errno(0x80) + EL2HLT = syscall.Errno(0x33) + EL2NSYNC = syscall.Errno(0x2d) + EL3HLT = syscall.Errno(0x2e) + EL3RST = syscall.Errno(0x2f) + ELIBACC = syscall.Errno(0x4f) + ELIBBAD = syscall.Errno(0x50) + ELIBEXEC = syscall.Errno(0x53) + ELIBMAX = syscall.Errno(0x52) + ELIBSCN = syscall.Errno(0x51) + ELNRNG = syscall.Errno(0x30) + ELOOP = syscall.Errno(0x28) + EMEDIUMTYPE = syscall.Errno(0x7c) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x5a) + EMULTIHOP = syscall.Errno(0x48) + ENAMETOOLONG = syscall.Errno(0x24) + ENAVAIL = syscall.Errno(0x77) + ENETDOWN = syscall.Errno(0x64) + ENETRESET = syscall.Errno(0x66) + ENETUNREACH = syscall.Errno(0x65) + ENFILE = syscall.Errno(0x17) + ENOANO = syscall.Errno(0x37) + ENOBUFS = syscall.Errno(0x69) + ENOCSI = syscall.Errno(0x32) + ENODATA = syscall.Errno(0x3d) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOKEY = syscall.Errno(0x7e) + ENOLCK = syscall.Errno(0x25) + ENOLINK = syscall.Errno(0x43) + ENOMEDIUM = syscall.Errno(0x7b) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x2a) + ENONET = syscall.Errno(0x40) + ENOPKG = syscall.Errno(0x41) + ENOPROTOOPT = syscall.Errno(0x5c) + ENOSPC = syscall.Errno(0x1c) + ENOSR = syscall.Errno(0x3f) + ENOSTR = syscall.Errno(0x3c) + ENOSYS = syscall.Errno(0x26) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x6b) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x27) + ENOTNAM = syscall.Errno(0x76) + ENOTRECOVERABLE = syscall.Errno(0x83) + ENOTSOCK = syscall.Errno(0x58) + ENOTSUP = syscall.Errno(0x5f) + ENOTTY = syscall.Errno(0x19) + ENOTUNIQ = syscall.Errno(0x4c) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x5f) + EOVERFLOW = syscall.Errno(0x4b) + EOWNERDEAD = syscall.Errno(0x82) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x60) + EPIPE = syscall.Errno(0x20) + EPROTO = syscall.Errno(0x47) + EPROTONOSUPPORT = syscall.Errno(0x5d) + EPROTOTYPE = syscall.Errno(0x5b) + ERANGE = syscall.Errno(0x22) + EREMCHG = syscall.Errno(0x4e) + EREMOTE = syscall.Errno(0x42) + EREMOTEIO = syscall.Errno(0x79) + ERESTART = syscall.Errno(0x55) + ERFKILL = syscall.Errno(0x84) + EROFS = syscall.Errno(0x1e) + ESHUTDOWN = syscall.Errno(0x6c) + ESOCKTNOSUPPORT = syscall.Errno(0x5e) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESRMNT = syscall.Errno(0x45) + ESTALE = syscall.Errno(0x74) + ESTRPIPE = syscall.Errno(0x56) + ETIME = syscall.Errno(0x3e) + ETIMEDOUT = syscall.Errno(0x6e) + ETOOMANYREFS = syscall.Errno(0x6d) + ETXTBSY = syscall.Errno(0x1a) + EUCLEAN = syscall.Errno(0x75) + EUNATCH = syscall.Errno(0x31) + EUSERS = syscall.Errno(0x57) + EWOULDBLOCK = syscall.Errno(0xb) + EXDEV = syscall.Errno(0x12) + EXFULL = syscall.Errno(0x36) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0x7) + SIGCHLD = syscall.Signal(0x11) + SIGCLD = syscall.Signal(0x11) + SIGCONT = syscall.Signal(0x12) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x1d) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPOLL = syscall.Signal(0x1d) + SIGPROF = syscall.Signal(0x1b) + SIGPWR = syscall.Signal(0x1e) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTKFLT = syscall.Signal(0x10) + SIGSTOP = syscall.Signal(0x13) + SIGSYS = syscall.Signal(0x1f) + SIGTERM = syscall.Signal(0xf) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x14) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGUNUSED = syscall.Signal(0x1f) + SIGURG = syscall.Signal(0x17) + SIGUSR1 = syscall.Signal(0xa) + SIGUSR2 = syscall.Signal(0xc) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "no such device or address", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource temporarily unavailable", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device or resource busy", + 17: "file exists", + 18: "invalid cross-device link", + 19: "no such device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "numerical result out of range", + 35: "resource deadlock avoided", + 36: "file name too long", + 37: "no locks available", + 38: "function not implemented", + 39: "directory not empty", + 40: "too many levels of symbolic links", + 42: "no message of desired type", + 43: "identifier removed", + 44: "channel number out of range", + 45: "level 2 not synchronized", + 46: "level 3 halted", + 47: "level 3 reset", + 48: "link number out of range", + 49: "protocol driver not attached", + 50: "no CSI structure available", + 51: "level 2 halted", + 52: "invalid exchange", + 53: "invalid request descriptor", + 54: "exchange full", + 55: "no anode", + 56: "invalid request code", + 57: "invalid slot", + 58: "file locking deadlock error", + 59: "bad font file format", + 60: "device not a stream", + 61: "no data available", + 62: "timer expired", + 63: "out of streams resources", + 64: "machine is not on the network", + 65: "package not installed", + 66: "object is remote", + 67: "link has been severed", + 68: "advertise error", + 69: "srmount error", + 70: "communication error on send", + 71: "protocol error", + 72: "multihop attempted", + 73: "RFS specific error", + 74: "bad message", + 75: "value too large for defined data type", + 76: "name not unique on network", + 77: "file descriptor in bad state", + 78: "remote address changed", + 79: "can not access a needed shared library", + 80: "accessing a corrupted shared library", + 81: ".lib section in a.out corrupted", + 82: "attempting to link in too many shared libraries", + 83: "cannot exec a shared library directly", + 84: "invalid or incomplete multibyte or wide character", + 85: "interrupted system call should be restarted", + 86: "streams pipe error", + 87: "too many users", + 88: "socket operation on non-socket", + 89: "destination address required", + 90: "message too long", + 91: "protocol wrong type for socket", + 92: "protocol not available", + 93: "protocol not supported", + 94: "socket type not supported", + 95: "operation not supported", + 96: "protocol family not supported", + 97: "address family not supported by protocol", + 98: "address already in use", + 99: "cannot assign requested address", + 100: "network is down", + 101: "network is unreachable", + 102: "network dropped connection on reset", + 103: "software caused connection abort", + 104: "connection reset by peer", + 105: "no buffer space available", + 106: "transport endpoint is already connected", + 107: "transport endpoint is not connected", + 108: "cannot send after transport endpoint shutdown", + 109: "too many references: cannot splice", + 110: "connection timed out", + 111: "connection refused", + 112: "host is down", + 113: "no route to host", + 114: "operation already in progress", + 115: "operation now in progress", + 116: "stale file handle", + 117: "structure needs cleaning", + 118: "not a XENIX named type file", + 119: "no XENIX semaphores available", + 120: "is a named type file", + 121: "remote I/O error", + 122: "disk quota exceeded", + 123: "no medium found", + 124: "wrong medium type", + 125: "operation canceled", + 126: "required key not available", + 127: "key has expired", + 128: "key has been revoked", + 129: "key was rejected by service", + 130: "owner died", + 131: "state not recoverable", + 132: "operation not possible due to RF-kill", + 133: "memory page has hardware error", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/breakpoint trap", + 6: "aborted", + 7: "bus error", + 8: "floating point exception", + 9: "killed", + 10: "user defined signal 1", + 11: "segmentation fault", + 12: "user defined signal 2", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "stack fault", + 17: "child exited", + 18: "continued", + 19: "stopped (signal)", + 20: "stopped", + 21: "stopped (tty input)", + 22: "stopped (tty output)", + 23: "urgent I/O condition", + 24: "CPU time limit exceeded", + 25: "file size limit exceeded", + 26: "virtual timer expired", + 27: "profiling timer expired", + 28: "window changed", + 29: "I/O possible", + 30: "power failure", + 31: "bad system call", +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_ppc64le.go new file mode 100644 index 0000000000..e8d12b5d6d --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -0,0 +1,1969 @@ +// mkerrors.sh -m64 +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build ppc64le,linux + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -m64 _const.go + +package unix + +import "syscall" + +const ( + AF_ALG = 0x26 + AF_APPLETALK = 0x5 + AF_ASH = 0x12 + AF_ATMPVC = 0x8 + AF_ATMSVC = 0x14 + AF_AX25 = 0x3 + AF_BLUETOOTH = 0x1f + AF_BRIDGE = 0x7 + AF_CAIF = 0x25 + AF_CAN = 0x1d + AF_DECnet = 0xc + AF_ECONET = 0x13 + AF_FILE = 0x1 + AF_IEEE802154 = 0x24 + AF_INET = 0x2 + AF_INET6 = 0xa + AF_IPX = 0x4 + AF_IRDA = 0x17 + AF_ISDN = 0x22 + AF_IUCV = 0x20 + AF_KEY = 0xf + AF_LLC = 0x1a + AF_LOCAL = 0x1 + AF_MAX = 0x29 + AF_NETBEUI = 0xd + AF_NETLINK = 0x10 + AF_NETROM = 0x6 + AF_NFC = 0x27 + AF_PACKET = 0x11 + AF_PHONET = 0x23 + AF_PPPOX = 0x18 + AF_RDS = 0x15 + AF_ROSE = 0xb + AF_ROUTE = 0x10 + AF_RXRPC = 0x21 + AF_SECURITY = 0xe + AF_SNA = 0x16 + AF_TIPC = 0x1e + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_VSOCK = 0x28 + AF_WANPIPE = 0x19 + AF_X25 = 0x9 + ARPHRD_ADAPT = 0x108 + ARPHRD_APPLETLK = 0x8 + ARPHRD_ARCNET = 0x7 + ARPHRD_ASH = 0x30d + ARPHRD_ATM = 0x13 + ARPHRD_AX25 = 0x3 + ARPHRD_BIF = 0x307 + ARPHRD_CAIF = 0x336 + ARPHRD_CAN = 0x118 + ARPHRD_CHAOS = 0x5 + ARPHRD_CISCO = 0x201 + ARPHRD_CSLIP = 0x101 + ARPHRD_CSLIP6 = 0x103 + ARPHRD_DDCMP = 0x205 + ARPHRD_DLCI = 0xf + ARPHRD_ECONET = 0x30e + ARPHRD_EETHER = 0x2 + ARPHRD_ETHER = 0x1 + ARPHRD_EUI64 = 0x1b + ARPHRD_FCAL = 0x311 + ARPHRD_FCFABRIC = 0x313 + ARPHRD_FCPL = 0x312 + ARPHRD_FCPP = 0x310 + ARPHRD_FDDI = 0x306 + ARPHRD_FRAD = 0x302 + ARPHRD_HDLC = 0x201 + ARPHRD_HIPPI = 0x30c + ARPHRD_HWX25 = 0x110 + ARPHRD_IEEE1394 = 0x18 + ARPHRD_IEEE802 = 0x6 + ARPHRD_IEEE80211 = 0x321 + ARPHRD_IEEE80211_PRISM = 0x322 + ARPHRD_IEEE80211_RADIOTAP = 0x323 + ARPHRD_IEEE802154 = 0x324 + ARPHRD_IEEE802154_MONITOR = 0x325 + ARPHRD_IEEE802_TR = 0x320 + ARPHRD_INFINIBAND = 0x20 + ARPHRD_IP6GRE = 0x337 + ARPHRD_IPDDP = 0x309 + ARPHRD_IPGRE = 0x30a + ARPHRD_IRDA = 0x30f + ARPHRD_LAPB = 0x204 + ARPHRD_LOCALTLK = 0x305 + ARPHRD_LOOPBACK = 0x304 + ARPHRD_METRICOM = 0x17 + ARPHRD_NETLINK = 0x338 + ARPHRD_NETROM = 0x0 + ARPHRD_NONE = 0xfffe + ARPHRD_PHONET = 0x334 + ARPHRD_PHONET_PIPE = 0x335 + ARPHRD_PIMREG = 0x30b + ARPHRD_PPP = 0x200 + ARPHRD_PRONET = 0x4 + ARPHRD_RAWHDLC = 0x206 + ARPHRD_ROSE = 0x10e + ARPHRD_RSRVD = 0x104 + ARPHRD_SIT = 0x308 + ARPHRD_SKIP = 0x303 + ARPHRD_SLIP = 0x100 + ARPHRD_SLIP6 = 0x102 + ARPHRD_TUNNEL = 0x300 + ARPHRD_TUNNEL6 = 0x301 + ARPHRD_VOID = 0xffff + ARPHRD_X25 = 0x10f + B0 = 0x0 + B1000000 = 0x17 + B110 = 0x3 + B115200 = 0x11 + B1152000 = 0x18 + B1200 = 0x9 + B134 = 0x4 + B150 = 0x5 + B1500000 = 0x19 + B1800 = 0xa + B19200 = 0xe + B200 = 0x6 + B2000000 = 0x1a + B230400 = 0x12 + B2400 = 0xb + B2500000 = 0x1b + B300 = 0x7 + B3000000 = 0x1c + B3500000 = 0x1d + B38400 = 0xf + B4000000 = 0x1e + B460800 = 0x13 + B4800 = 0xc + B50 = 0x1 + B500000 = 0x14 + B57600 = 0x10 + B576000 = 0x15 + B600 = 0x8 + B75 = 0x2 + B921600 = 0x16 + B9600 = 0xd + BOTHER = 0x1f + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXINSNS = 0x1000 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MOD = 0x90 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BPF_XOR = 0xa0 + BRKINT = 0x2 + BS0 = 0x0 + BS1 = 0x8000 + BSDLY = 0x8000 + CBAUD = 0xff + CBAUDEX = 0x0 + CFLUSH = 0xf + CIBAUD = 0xff0000 + CLOCAL = 0x8000 + CLOCK_BOOTTIME = 0x7 + CLOCK_BOOTTIME_ALARM = 0x9 + CLOCK_DEFAULT = 0x0 + CLOCK_EXT = 0x1 + CLOCK_INT = 0x2 + CLOCK_MONOTONIC = 0x1 + CLOCK_MONOTONIC_COARSE = 0x6 + CLOCK_MONOTONIC_RAW = 0x4 + CLOCK_PROCESS_CPUTIME_ID = 0x2 + CLOCK_REALTIME = 0x0 + CLOCK_REALTIME_ALARM = 0x8 + CLOCK_REALTIME_COARSE = 0x5 + CLOCK_THREAD_CPUTIME_ID = 0x3 + CLOCK_TXFROMRX = 0x4 + CLOCK_TXINT = 0x3 + CLONE_CHILD_CLEARTID = 0x200000 + CLONE_CHILD_SETTID = 0x1000000 + CLONE_DETACHED = 0x400000 + CLONE_FILES = 0x400 + CLONE_FS = 0x200 + CLONE_IO = 0x80000000 + CLONE_NEWCGROUP = 0x2000000 + CLONE_NEWIPC = 0x8000000 + CLONE_NEWNET = 0x40000000 + CLONE_NEWNS = 0x20000 + CLONE_NEWPID = 0x20000000 + CLONE_NEWUSER = 0x10000000 + CLONE_NEWUTS = 0x4000000 + CLONE_PARENT = 0x8000 + CLONE_PARENT_SETTID = 0x100000 + CLONE_PTRACE = 0x2000 + CLONE_SETTLS = 0x80000 + CLONE_SIGHAND = 0x800 + CLONE_SYSVSEM = 0x40000 + CLONE_THREAD = 0x10000 + CLONE_UNTRACED = 0x800000 + CLONE_VFORK = 0x4000 + CLONE_VM = 0x100 + CMSPAR = 0x40000000 + CR0 = 0x0 + CR1 = 0x1000 + CR2 = 0x2000 + CR3 = 0x3000 + CRDLY = 0x3000 + CREAD = 0x800 + CRTSCTS = 0x80000000 + CS5 = 0x0 + CS6 = 0x100 + CS7 = 0x200 + CS8 = 0x300 + CSIGNAL = 0xff + CSIZE = 0x300 + CSTART = 0x11 + CSTATUS = 0x0 + CSTOP = 0x13 + CSTOPB = 0x400 + CSUSP = 0x1a + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x40 + ECHOE = 0x2 + ECHOK = 0x4 + ECHOKE = 0x1 + ECHONL = 0x10 + ECHOPRT = 0x20 + ENCODING_DEFAULT = 0x0 + ENCODING_FM_MARK = 0x3 + ENCODING_FM_SPACE = 0x4 + ENCODING_MANCHESTER = 0x5 + ENCODING_NRZ = 0x1 + ENCODING_NRZI = 0x2 + EPOLLERR = 0x8 + EPOLLET = 0x80000000 + EPOLLHUP = 0x10 + EPOLLIN = 0x1 + EPOLLMSG = 0x400 + EPOLLONESHOT = 0x40000000 + EPOLLOUT = 0x4 + EPOLLPRI = 0x2 + EPOLLRDBAND = 0x80 + EPOLLRDHUP = 0x2000 + EPOLLRDNORM = 0x40 + EPOLLWAKEUP = 0x20000000 + EPOLLWRBAND = 0x200 + EPOLLWRNORM = 0x100 + EPOLL_CLOEXEC = 0x80000 + EPOLL_CTL_ADD = 0x1 + EPOLL_CTL_DEL = 0x2 + EPOLL_CTL_MOD = 0x3 + ETH_P_1588 = 0x88f7 + ETH_P_8021AD = 0x88a8 + ETH_P_8021AH = 0x88e7 + ETH_P_8021Q = 0x8100 + ETH_P_802_2 = 0x4 + ETH_P_802_3 = 0x1 + ETH_P_802_3_MIN = 0x600 + ETH_P_802_EX1 = 0x88b5 + ETH_P_AARP = 0x80f3 + ETH_P_AF_IUCV = 0xfbfb + ETH_P_ALL = 0x3 + ETH_P_AOE = 0x88a2 + ETH_P_ARCNET = 0x1a + ETH_P_ARP = 0x806 + ETH_P_ATALK = 0x809b + ETH_P_ATMFATE = 0x8884 + ETH_P_ATMMPOA = 0x884c + ETH_P_AX25 = 0x2 + ETH_P_BATMAN = 0x4305 + ETH_P_BPQ = 0x8ff + ETH_P_CAIF = 0xf7 + ETH_P_CAN = 0xc + ETH_P_CANFD = 0xd + ETH_P_CONTROL = 0x16 + ETH_P_CUST = 0x6006 + ETH_P_DDCMP = 0x6 + ETH_P_DEC = 0x6000 + ETH_P_DIAG = 0x6005 + ETH_P_DNA_DL = 0x6001 + ETH_P_DNA_RC = 0x6002 + ETH_P_DNA_RT = 0x6003 + ETH_P_DSA = 0x1b + ETH_P_ECONET = 0x18 + ETH_P_EDSA = 0xdada + ETH_P_FCOE = 0x8906 + ETH_P_FIP = 0x8914 + ETH_P_HDLC = 0x19 + ETH_P_IEEE802154 = 0xf6 + ETH_P_IEEEPUP = 0xa00 + ETH_P_IEEEPUPAT = 0xa01 + ETH_P_IP = 0x800 + ETH_P_IPV6 = 0x86dd + ETH_P_IPX = 0x8137 + ETH_P_IRDA = 0x17 + ETH_P_LAT = 0x6004 + ETH_P_LINK_CTL = 0x886c + ETH_P_LOCALTALK = 0x9 + ETH_P_LOOP = 0x60 + ETH_P_MOBITEX = 0x15 + ETH_P_MPLS_MC = 0x8848 + ETH_P_MPLS_UC = 0x8847 + ETH_P_MVRP = 0x88f5 + ETH_P_PAE = 0x888e + ETH_P_PAUSE = 0x8808 + ETH_P_PHONET = 0xf5 + ETH_P_PPPTALK = 0x10 + ETH_P_PPP_DISC = 0x8863 + ETH_P_PPP_MP = 0x8 + ETH_P_PPP_SES = 0x8864 + ETH_P_PRP = 0x88fb + ETH_P_PUP = 0x200 + ETH_P_PUPAT = 0x201 + ETH_P_QINQ1 = 0x9100 + ETH_P_QINQ2 = 0x9200 + ETH_P_QINQ3 = 0x9300 + ETH_P_RARP = 0x8035 + ETH_P_SCA = 0x6007 + ETH_P_SLOW = 0x8809 + ETH_P_SNAP = 0x5 + ETH_P_TDLS = 0x890d + ETH_P_TEB = 0x6558 + ETH_P_TIPC = 0x88ca + ETH_P_TRAILER = 0x1c + ETH_P_TR_802_2 = 0x11 + ETH_P_WAN_PPP = 0x7 + ETH_P_WCCP = 0x883e + ETH_P_X25 = 0x805 + EXTA = 0xe + EXTB = 0xf + EXTPROC = 0x10000000 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FF0 = 0x0 + FF1 = 0x4000 + FFDLY = 0x4000 + FLUSHO = 0x800000 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x406 + F_EXLCK = 0x4 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLEASE = 0x401 + F_GETLK = 0x5 + F_GETLK64 = 0xc + F_GETOWN = 0x9 + F_GETOWN_EX = 0x10 + F_GETPIPE_SZ = 0x408 + F_GETSIG = 0xb + F_LOCK = 0x1 + F_NOTIFY = 0x402 + F_OK = 0x0 + F_RDLCK = 0x0 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLEASE = 0x400 + F_SETLK = 0x6 + F_SETLK64 = 0xd + F_SETLKW = 0x7 + F_SETLKW64 = 0xe + F_SETOWN = 0x8 + F_SETOWN_EX = 0xf + F_SETPIPE_SZ = 0x407 + F_SETSIG = 0xa + F_SHLCK = 0x8 + F_TEST = 0x3 + F_TLOCK = 0x2 + F_ULOCK = 0x0 + F_UNLCK = 0x2 + F_WRLCK = 0x1 + HUPCL = 0x4000 + IBSHIFT = 0x10 + ICANON = 0x100 + ICMPV6_FILTER = 0x1 + ICRNL = 0x100 + IEXTEN = 0x400 + IFA_F_DADFAILED = 0x8 + IFA_F_DEPRECATED = 0x20 + IFA_F_HOMEADDRESS = 0x10 + IFA_F_NODAD = 0x2 + IFA_F_OPTIMISTIC = 0x4 + IFA_F_PERMANENT = 0x80 + IFA_F_SECONDARY = 0x1 + IFA_F_TEMPORARY = 0x1 + IFA_F_TENTATIVE = 0x40 + IFA_MAX = 0x7 + IFF_802_1Q_VLAN = 0x1 + IFF_ALLMULTI = 0x200 + IFF_ATTACH_QUEUE = 0x200 + IFF_AUTOMEDIA = 0x4000 + IFF_BONDING = 0x20 + IFF_BRIDGE_PORT = 0x4000 + IFF_BROADCAST = 0x2 + IFF_DEBUG = 0x4 + IFF_DETACH_QUEUE = 0x400 + IFF_DISABLE_NETPOLL = 0x1000 + IFF_DONT_BRIDGE = 0x800 + IFF_DORMANT = 0x20000 + IFF_DYNAMIC = 0x8000 + IFF_EBRIDGE = 0x2 + IFF_ECHO = 0x40000 + IFF_ISATAP = 0x80 + IFF_LIVE_ADDR_CHANGE = 0x100000 + IFF_LOOPBACK = 0x8 + IFF_LOWER_UP = 0x10000 + IFF_MACVLAN = 0x200000 + IFF_MACVLAN_PORT = 0x2000 + IFF_MASTER = 0x400 + IFF_MASTER_8023AD = 0x8 + IFF_MASTER_ALB = 0x10 + IFF_MASTER_ARPMON = 0x100 + IFF_MULTICAST = 0x1000 + IFF_MULTI_QUEUE = 0x100 + IFF_NOARP = 0x80 + IFF_NOFILTER = 0x1000 + IFF_NOTRAILERS = 0x20 + IFF_NO_PI = 0x1000 + IFF_ONE_QUEUE = 0x2000 + IFF_OVS_DATAPATH = 0x8000 + IFF_PERSIST = 0x800 + IFF_POINTOPOINT = 0x10 + IFF_PORTSEL = 0x2000 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SLAVE = 0x800 + IFF_SLAVE_INACTIVE = 0x4 + IFF_SLAVE_NEEDARP = 0x40 + IFF_SUPP_NOFCS = 0x80000 + IFF_TAP = 0x2 + IFF_TEAM_PORT = 0x40000 + IFF_TUN = 0x1 + IFF_TUN_EXCL = 0x8000 + IFF_TX_SKB_SHARING = 0x10000 + IFF_UNICAST_FLT = 0x20000 + IFF_UP = 0x1 + IFF_VNET_HDR = 0x4000 + IFF_VOLATILE = 0x70c5a + IFF_WAN_HDLC = 0x200 + IFF_XMIT_DST_RELEASE = 0x400 + IFNAMSIZ = 0x10 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_ACCESS = 0x1 + IN_ALL_EVENTS = 0xfff + IN_ATTRIB = 0x4 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLOEXEC = 0x80000 + IN_CLOSE = 0x18 + IN_CLOSE_NOWRITE = 0x10 + IN_CLOSE_WRITE = 0x8 + IN_CREATE = 0x100 + IN_DELETE = 0x200 + IN_DELETE_SELF = 0x400 + IN_DONT_FOLLOW = 0x2000000 + IN_EXCL_UNLINK = 0x4000000 + IN_IGNORED = 0x8000 + IN_ISDIR = 0x40000000 + IN_LOOPBACKNET = 0x7f + IN_MASK_ADD = 0x20000000 + IN_MODIFY = 0x2 + IN_MOVE = 0xc0 + IN_MOVED_FROM = 0x40 + IN_MOVED_TO = 0x80 + IN_MOVE_SELF = 0x800 + IN_NONBLOCK = 0x800 + IN_ONESHOT = 0x80000000 + IN_ONLYDIR = 0x1000000 + IN_OPEN = 0x20 + IN_Q_OVERFLOW = 0x4000 + IN_UNMOUNT = 0x2000 + IPPROTO_AH = 0x33 + IPPROTO_BEETPH = 0x5e + IPPROTO_COMP = 0x6c + IPPROTO_DCCP = 0x21 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_ENCAP = 0x62 + IPPROTO_ESP = 0x32 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GRE = 0x2f + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IGMP = 0x2 + IPPROTO_IP = 0x0 + IPPROTO_IPIP = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_MH = 0x87 + IPPROTO_MTP = 0x5c + IPPROTO_NONE = 0x3b + IPPROTO_PIM = 0x67 + IPPROTO_PUP = 0xc + IPPROTO_RAW = 0xff + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_SCTP = 0x84 + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_UDP = 0x11 + IPPROTO_UDPLITE = 0x88 + IPV6_2292DSTOPTS = 0x4 + IPV6_2292HOPLIMIT = 0x8 + IPV6_2292HOPOPTS = 0x3 + IPV6_2292PKTINFO = 0x2 + IPV6_2292PKTOPTIONS = 0x6 + IPV6_2292RTHDR = 0x5 + IPV6_ADDRFORM = 0x1 + IPV6_ADD_MEMBERSHIP = 0x14 + IPV6_AUTHHDR = 0xa + IPV6_CHECKSUM = 0x7 + IPV6_DROP_MEMBERSHIP = 0x15 + IPV6_DSTOPTS = 0x3b + IPV6_HOPLIMIT = 0x34 + IPV6_HOPOPTS = 0x36 + IPV6_IPSEC_POLICY = 0x22 + IPV6_JOIN_ANYCAST = 0x1b + IPV6_JOIN_GROUP = 0x14 + IPV6_LEAVE_ANYCAST = 0x1c + IPV6_LEAVE_GROUP = 0x15 + IPV6_MTU = 0x18 + IPV6_MTU_DISCOVER = 0x17 + IPV6_MULTICAST_HOPS = 0x12 + IPV6_MULTICAST_IF = 0x11 + IPV6_MULTICAST_LOOP = 0x13 + IPV6_NEXTHOP = 0x9 + IPV6_PKTINFO = 0x32 + IPV6_PMTUDISC_DO = 0x2 + IPV6_PMTUDISC_DONT = 0x0 + IPV6_PMTUDISC_PROBE = 0x3 + IPV6_PMTUDISC_WANT = 0x1 + IPV6_RECVDSTOPTS = 0x3a + IPV6_RECVERR = 0x19 + IPV6_RECVHOPLIMIT = 0x33 + IPV6_RECVHOPOPTS = 0x35 + IPV6_RECVPKTINFO = 0x31 + IPV6_RECVRTHDR = 0x38 + IPV6_RECVTCLASS = 0x42 + IPV6_ROUTER_ALERT = 0x16 + IPV6_RTHDR = 0x39 + IPV6_RTHDRDSTOPTS = 0x37 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_RXDSTOPTS = 0x3b + IPV6_RXHOPOPTS = 0x36 + IPV6_TCLASS = 0x43 + IPV6_UNICAST_HOPS = 0x10 + IPV6_V6ONLY = 0x1a + IPV6_XFRM_POLICY = 0x23 + IP_ADD_MEMBERSHIP = 0x23 + IP_ADD_SOURCE_MEMBERSHIP = 0x27 + IP_BLOCK_SOURCE = 0x26 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DROP_MEMBERSHIP = 0x24 + IP_DROP_SOURCE_MEMBERSHIP = 0x28 + IP_FREEBIND = 0xf + IP_HDRINCL = 0x3 + IP_IPSEC_POLICY = 0x10 + IP_MAXPACKET = 0xffff + IP_MAX_MEMBERSHIPS = 0x14 + IP_MF = 0x2000 + IP_MINTTL = 0x15 + IP_MSFILTER = 0x29 + IP_MSS = 0x240 + IP_MTU = 0xe + IP_MTU_DISCOVER = 0xa + IP_MULTICAST_ALL = 0x31 + IP_MULTICAST_IF = 0x20 + IP_MULTICAST_LOOP = 0x22 + IP_MULTICAST_TTL = 0x21 + IP_OFFMASK = 0x1fff + IP_OPTIONS = 0x4 + IP_ORIGDSTADDR = 0x14 + IP_PASSSEC = 0x12 + IP_PKTINFO = 0x8 + IP_PKTOPTIONS = 0x9 + IP_PMTUDISC = 0xa + IP_PMTUDISC_DO = 0x2 + IP_PMTUDISC_DONT = 0x0 + IP_PMTUDISC_PROBE = 0x3 + IP_PMTUDISC_WANT = 0x1 + IP_RECVERR = 0xb + IP_RECVOPTS = 0x6 + IP_RECVORIGDSTADDR = 0x14 + IP_RECVRETOPTS = 0x7 + IP_RECVTOS = 0xd + IP_RECVTTL = 0xc + IP_RETOPTS = 0x7 + IP_RF = 0x8000 + IP_ROUTER_ALERT = 0x5 + IP_TOS = 0x1 + IP_TRANSPARENT = 0x13 + IP_TTL = 0x2 + IP_UNBLOCK_SOURCE = 0x25 + IP_UNICAST_IF = 0x32 + IP_XFRM_POLICY = 0x11 + ISIG = 0x80 + ISTRIP = 0x20 + IUCLC = 0x1000 + IUTF8 = 0x4000 + IXANY = 0x800 + IXOFF = 0x400 + IXON = 0x200 + LINUX_REBOOT_CMD_CAD_OFF = 0x0 + LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef + LINUX_REBOOT_CMD_HALT = 0xcdef0123 + LINUX_REBOOT_CMD_KEXEC = 0x45584543 + LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc + LINUX_REBOOT_CMD_RESTART = 0x1234567 + LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4 + LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2 + LINUX_REBOOT_MAGIC1 = 0xfee1dead + LINUX_REBOOT_MAGIC2 = 0x28121969 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_DODUMP = 0x11 + MADV_DOFORK = 0xb + MADV_DONTDUMP = 0x10 + MADV_DONTFORK = 0xa + MADV_DONTNEED = 0x4 + MADV_HUGEPAGE = 0xe + MADV_HWPOISON = 0x64 + MADV_MERGEABLE = 0xc + MADV_NOHUGEPAGE = 0xf + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_REMOVE = 0x9 + MADV_SEQUENTIAL = 0x2 + MADV_UNMERGEABLE = 0xd + MADV_WILLNEED = 0x3 + MAP_ANON = 0x20 + MAP_ANONYMOUS = 0x20 + MAP_DENYWRITE = 0x800 + MAP_EXECUTABLE = 0x1000 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_GROWSDOWN = 0x100 + MAP_HUGETLB = 0x40000 + MAP_HUGE_MASK = 0x3f + MAP_HUGE_SHIFT = 0x1a + MAP_LOCKED = 0x80 + MAP_NONBLOCK = 0x10000 + MAP_NORESERVE = 0x40 + MAP_POPULATE = 0x8000 + MAP_PRIVATE = 0x2 + MAP_SHARED = 0x1 + MAP_STACK = 0x20000 + MAP_TYPE = 0xf + MCL_CURRENT = 0x2000 + MCL_FUTURE = 0x4000 + MNT_DETACH = 0x2 + MNT_EXPIRE = 0x4 + MNT_FORCE = 0x1 + MSG_CMSG_CLOEXEC = 0x40000000 + MSG_CONFIRM = 0x800 + MSG_CTRUNC = 0x8 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x40 + MSG_EOR = 0x80 + MSG_ERRQUEUE = 0x2000 + MSG_FASTOPEN = 0x20000000 + MSG_FIN = 0x200 + MSG_MORE = 0x8000 + MSG_NOSIGNAL = 0x4000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_PROXY = 0x10 + MSG_RST = 0x1000 + MSG_SYN = 0x400 + MSG_TRUNC = 0x20 + MSG_TRYHARD = 0x4 + MSG_WAITALL = 0x100 + MSG_WAITFORONE = 0x10000 + MS_ACTIVE = 0x40000000 + MS_ASYNC = 0x1 + MS_BIND = 0x1000 + MS_DIRSYNC = 0x80 + MS_INVALIDATE = 0x2 + MS_I_VERSION = 0x800000 + MS_KERNMOUNT = 0x400000 + MS_MANDLOCK = 0x40 + MS_MGC_MSK = 0xffff0000 + MS_MGC_VAL = 0xc0ed0000 + MS_MOVE = 0x2000 + MS_NOATIME = 0x400 + MS_NODEV = 0x4 + MS_NODIRATIME = 0x800 + MS_NOEXEC = 0x8 + MS_NOSUID = 0x2 + MS_NOUSER = -0x80000000 + MS_POSIXACL = 0x10000 + MS_PRIVATE = 0x40000 + MS_RDONLY = 0x1 + MS_REC = 0x4000 + MS_RELATIME = 0x200000 + MS_REMOUNT = 0x20 + MS_RMT_MASK = 0x800051 + MS_SHARED = 0x100000 + MS_SILENT = 0x8000 + MS_SLAVE = 0x80000 + MS_STRICTATIME = 0x1000000 + MS_SYNC = 0x4 + MS_SYNCHRONOUS = 0x10 + MS_UNBINDABLE = 0x20000 + NAME_MAX = 0xff + NETLINK_ADD_MEMBERSHIP = 0x1 + NETLINK_AUDIT = 0x9 + NETLINK_BROADCAST_ERROR = 0x4 + NETLINK_CONNECTOR = 0xb + NETLINK_CRYPTO = 0x15 + NETLINK_DNRTMSG = 0xe + NETLINK_DROP_MEMBERSHIP = 0x2 + NETLINK_ECRYPTFS = 0x13 + NETLINK_FIB_LOOKUP = 0xa + NETLINK_FIREWALL = 0x3 + NETLINK_GENERIC = 0x10 + NETLINK_INET_DIAG = 0x4 + NETLINK_IP6_FW = 0xd + NETLINK_ISCSI = 0x8 + NETLINK_KOBJECT_UEVENT = 0xf + NETLINK_NETFILTER = 0xc + NETLINK_NFLOG = 0x5 + NETLINK_NO_ENOBUFS = 0x5 + NETLINK_PKTINFO = 0x3 + NETLINK_RDMA = 0x14 + NETLINK_ROUTE = 0x0 + NETLINK_RX_RING = 0x6 + NETLINK_SCSITRANSPORT = 0x12 + NETLINK_SELINUX = 0x7 + NETLINK_SOCK_DIAG = 0x4 + NETLINK_TX_RING = 0x7 + NETLINK_UNUSED = 0x1 + NETLINK_USERSOCK = 0x2 + NETLINK_XFRM = 0x6 + NL0 = 0x0 + NL1 = 0x100 + NL2 = 0x200 + NL3 = 0x300 + NLA_ALIGNTO = 0x4 + NLA_F_NESTED = 0x8000 + NLA_F_NET_BYTEORDER = 0x4000 + NLA_HDRLEN = 0x4 + NLDLY = 0x300 + NLMSG_ALIGNTO = 0x4 + NLMSG_DONE = 0x3 + NLMSG_ERROR = 0x2 + NLMSG_HDRLEN = 0x10 + NLMSG_MIN_TYPE = 0x10 + NLMSG_NOOP = 0x1 + NLMSG_OVERRUN = 0x4 + NLM_F_ACK = 0x4 + NLM_F_APPEND = 0x800 + NLM_F_ATOMIC = 0x400 + NLM_F_CREATE = 0x400 + NLM_F_DUMP = 0x300 + NLM_F_DUMP_INTR = 0x10 + NLM_F_ECHO = 0x8 + NLM_F_EXCL = 0x200 + NLM_F_MATCH = 0x200 + NLM_F_MULTI = 0x2 + NLM_F_REPLACE = 0x100 + NLM_F_REQUEST = 0x1 + NLM_F_ROOT = 0x100 + NOFLSH = 0x80000000 + OCRNL = 0x8 + OFDEL = 0x80 + OFILL = 0x40 + OLCUC = 0x4 + ONLCR = 0x2 + ONLRET = 0x20 + ONOCR = 0x10 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_APPEND = 0x400 + O_ASYNC = 0x2000 + O_CLOEXEC = 0x80000 + O_CREAT = 0x40 + O_DIRECT = 0x20000 + O_DIRECTORY = 0x4000 + O_DSYNC = 0x1000 + O_EXCL = 0x80 + O_FSYNC = 0x101000 + O_LARGEFILE = 0x0 + O_NDELAY = 0x800 + O_NOATIME = 0x40000 + O_NOCTTY = 0x100 + O_NOFOLLOW = 0x8000 + O_NONBLOCK = 0x800 + O_PATH = 0x200000 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_RSYNC = 0x101000 + O_SYNC = 0x101000 + O_TMPFILE = 0x410000 + O_TRUNC = 0x200 + O_WRONLY = 0x1 + PACKET_ADD_MEMBERSHIP = 0x1 + PACKET_AUXDATA = 0x8 + PACKET_BROADCAST = 0x1 + PACKET_COPY_THRESH = 0x7 + PACKET_DROP_MEMBERSHIP = 0x2 + PACKET_FANOUT = 0x12 + PACKET_FANOUT_CPU = 0x2 + PACKET_FANOUT_FLAG_DEFRAG = 0x8000 + PACKET_FANOUT_FLAG_ROLLOVER = 0x1000 + PACKET_FANOUT_HASH = 0x0 + PACKET_FANOUT_LB = 0x1 + PACKET_FANOUT_RND = 0x4 + PACKET_FANOUT_ROLLOVER = 0x3 + PACKET_FASTROUTE = 0x6 + PACKET_HDRLEN = 0xb + PACKET_HOST = 0x0 + PACKET_LOOPBACK = 0x5 + PACKET_LOSS = 0xe + PACKET_MR_ALLMULTI = 0x2 + PACKET_MR_MULTICAST = 0x0 + PACKET_MR_PROMISC = 0x1 + PACKET_MR_UNICAST = 0x3 + PACKET_MULTICAST = 0x2 + PACKET_ORIGDEV = 0x9 + PACKET_OTHERHOST = 0x3 + PACKET_OUTGOING = 0x4 + PACKET_RECV_OUTPUT = 0x3 + PACKET_RESERVE = 0xc + PACKET_RX_RING = 0x5 + PACKET_STATISTICS = 0x6 + PACKET_TIMESTAMP = 0x11 + PACKET_TX_HAS_OFF = 0x13 + PACKET_TX_RING = 0xd + PACKET_TX_TIMESTAMP = 0x10 + PACKET_VERSION = 0xa + PACKET_VNET_HDR = 0xf + PARENB = 0x1000 + PARITY_CRC16_PR0 = 0x2 + PARITY_CRC16_PR0_CCITT = 0x4 + PARITY_CRC16_PR1 = 0x3 + PARITY_CRC16_PR1_CCITT = 0x5 + PARITY_CRC32_PR0_CCITT = 0x6 + PARITY_CRC32_PR1_CCITT = 0x7 + PARITY_DEFAULT = 0x0 + PARITY_NONE = 0x1 + PARMRK = 0x8 + PARODD = 0x2000 + PENDIN = 0x20000000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_GROWSDOWN = 0x1000000 + PROT_GROWSUP = 0x2000000 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_SAO = 0x10 + PROT_WRITE = 0x2 + PR_CAPBSET_DROP = 0x18 + PR_CAPBSET_READ = 0x17 + PR_ENDIAN_BIG = 0x0 + PR_ENDIAN_LITTLE = 0x1 + PR_ENDIAN_PPC_LITTLE = 0x2 + PR_FPEMU_NOPRINT = 0x1 + PR_FPEMU_SIGFPE = 0x2 + PR_FP_EXC_ASYNC = 0x2 + PR_FP_EXC_DISABLED = 0x0 + PR_FP_EXC_DIV = 0x10000 + PR_FP_EXC_INV = 0x100000 + PR_FP_EXC_NONRECOV = 0x1 + PR_FP_EXC_OVF = 0x20000 + PR_FP_EXC_PRECISE = 0x3 + PR_FP_EXC_RES = 0x80000 + PR_FP_EXC_SW_ENABLE = 0x80 + PR_FP_EXC_UND = 0x40000 + PR_GET_CHILD_SUBREAPER = 0x25 + PR_GET_DUMPABLE = 0x3 + PR_GET_ENDIAN = 0x13 + PR_GET_FPEMU = 0x9 + PR_GET_FPEXC = 0xb + PR_GET_KEEPCAPS = 0x7 + PR_GET_NAME = 0x10 + PR_GET_NO_NEW_PRIVS = 0x27 + PR_GET_PDEATHSIG = 0x2 + PR_GET_SECCOMP = 0x15 + PR_GET_SECUREBITS = 0x1b + PR_GET_TID_ADDRESS = 0x28 + PR_GET_TIMERSLACK = 0x1e + PR_GET_TIMING = 0xd + PR_GET_TSC = 0x19 + PR_GET_UNALIGN = 0x5 + PR_MCE_KILL = 0x21 + PR_MCE_KILL_CLEAR = 0x0 + PR_MCE_KILL_DEFAULT = 0x2 + PR_MCE_KILL_EARLY = 0x1 + PR_MCE_KILL_GET = 0x22 + PR_MCE_KILL_LATE = 0x0 + PR_MCE_KILL_SET = 0x1 + PR_SET_CHILD_SUBREAPER = 0x24 + PR_SET_DUMPABLE = 0x4 + PR_SET_ENDIAN = 0x14 + PR_SET_FPEMU = 0xa + PR_SET_FPEXC = 0xc + PR_SET_KEEPCAPS = 0x8 + PR_SET_MM = 0x23 + PR_SET_MM_ARG_END = 0x9 + PR_SET_MM_ARG_START = 0x8 + PR_SET_MM_AUXV = 0xc + PR_SET_MM_BRK = 0x7 + PR_SET_MM_END_CODE = 0x2 + PR_SET_MM_END_DATA = 0x4 + PR_SET_MM_ENV_END = 0xb + PR_SET_MM_ENV_START = 0xa + PR_SET_MM_EXE_FILE = 0xd + PR_SET_MM_START_BRK = 0x6 + PR_SET_MM_START_CODE = 0x1 + PR_SET_MM_START_DATA = 0x3 + PR_SET_MM_START_STACK = 0x5 + PR_SET_NAME = 0xf + PR_SET_NO_NEW_PRIVS = 0x26 + PR_SET_PDEATHSIG = 0x1 + PR_SET_PTRACER = 0x59616d61 + PR_SET_PTRACER_ANY = -0x1 + PR_SET_SECCOMP = 0x16 + PR_SET_SECUREBITS = 0x1c + PR_SET_TIMERSLACK = 0x1d + PR_SET_TIMING = 0xe + PR_SET_TSC = 0x1a + PR_SET_UNALIGN = 0x6 + PR_TASK_PERF_EVENTS_DISABLE = 0x1f + PR_TASK_PERF_EVENTS_ENABLE = 0x20 + PR_TIMING_STATISTICAL = 0x0 + PR_TIMING_TIMESTAMP = 0x1 + PR_TSC_ENABLE = 0x1 + PR_TSC_SIGSEGV = 0x2 + PR_UNALIGN_NOPRINT = 0x1 + PR_UNALIGN_SIGBUS = 0x2 + PTRACE_ATTACH = 0x10 + PTRACE_CONT = 0x7 + PTRACE_DETACH = 0x11 + PTRACE_EVENT_CLONE = 0x3 + PTRACE_EVENT_EXEC = 0x4 + PTRACE_EVENT_EXIT = 0x6 + PTRACE_EVENT_FORK = 0x1 + PTRACE_EVENT_SECCOMP = 0x7 + PTRACE_EVENT_STOP = 0x80 + PTRACE_EVENT_VFORK = 0x2 + PTRACE_EVENT_VFORK_DONE = 0x5 + PTRACE_GETEVENTMSG = 0x4201 + PTRACE_GETEVRREGS = 0x14 + PTRACE_GETFPREGS = 0xe + PTRACE_GETREGS = 0xc + PTRACE_GETREGS64 = 0x16 + PTRACE_GETREGSET = 0x4204 + PTRACE_GETSIGINFO = 0x4202 + PTRACE_GETSIGMASK = 0x420a + PTRACE_GETVRREGS = 0x12 + PTRACE_GETVSRREGS = 0x1b + PTRACE_GET_DEBUGREG = 0x19 + PTRACE_INTERRUPT = 0x4207 + PTRACE_KILL = 0x8 + PTRACE_LISTEN = 0x4208 + PTRACE_O_EXITKILL = 0x100000 + PTRACE_O_MASK = 0x1000ff + PTRACE_O_TRACECLONE = 0x8 + PTRACE_O_TRACEEXEC = 0x10 + PTRACE_O_TRACEEXIT = 0x40 + PTRACE_O_TRACEFORK = 0x2 + PTRACE_O_TRACESECCOMP = 0x80 + PTRACE_O_TRACESYSGOOD = 0x1 + PTRACE_O_TRACEVFORK = 0x4 + PTRACE_O_TRACEVFORKDONE = 0x20 + PTRACE_PEEKDATA = 0x2 + PTRACE_PEEKSIGINFO = 0x4209 + PTRACE_PEEKSIGINFO_SHARED = 0x1 + PTRACE_PEEKTEXT = 0x1 + PTRACE_PEEKUSR = 0x3 + PTRACE_POKEDATA = 0x5 + PTRACE_POKETEXT = 0x4 + PTRACE_POKEUSR = 0x6 + PTRACE_SEIZE = 0x4206 + PTRACE_SETEVRREGS = 0x15 + PTRACE_SETFPREGS = 0xf + PTRACE_SETOPTIONS = 0x4200 + PTRACE_SETREGS = 0xd + PTRACE_SETREGS64 = 0x17 + PTRACE_SETREGSET = 0x4205 + PTRACE_SETSIGINFO = 0x4203 + PTRACE_SETSIGMASK = 0x420b + PTRACE_SETVRREGS = 0x13 + PTRACE_SETVSRREGS = 0x1c + PTRACE_SET_DEBUGREG = 0x1a + PTRACE_SINGLEBLOCK = 0x100 + PTRACE_SINGLESTEP = 0x9 + PTRACE_SYSCALL = 0x18 + PTRACE_TRACEME = 0x0 + PT_CCR = 0x26 + PT_CTR = 0x23 + PT_DAR = 0x29 + PT_DSCR = 0x2c + PT_DSISR = 0x2a + PT_FPR0 = 0x30 + PT_FPSCR = 0x50 + PT_LNK = 0x24 + PT_MSR = 0x21 + PT_NIP = 0x20 + PT_ORIG_R3 = 0x22 + PT_R0 = 0x0 + PT_R1 = 0x1 + PT_R10 = 0xa + PT_R11 = 0xb + PT_R12 = 0xc + PT_R13 = 0xd + PT_R14 = 0xe + PT_R15 = 0xf + PT_R16 = 0x10 + PT_R17 = 0x11 + PT_R18 = 0x12 + PT_R19 = 0x13 + PT_R2 = 0x2 + PT_R20 = 0x14 + PT_R21 = 0x15 + PT_R22 = 0x16 + PT_R23 = 0x17 + PT_R24 = 0x18 + PT_R25 = 0x19 + PT_R26 = 0x1a + PT_R27 = 0x1b + PT_R28 = 0x1c + PT_R29 = 0x1d + PT_R3 = 0x3 + PT_R30 = 0x1e + PT_R31 = 0x1f + PT_R4 = 0x4 + PT_R5 = 0x5 + PT_R6 = 0x6 + PT_R7 = 0x7 + PT_R8 = 0x8 + PT_R9 = 0x9 + PT_REGS_COUNT = 0x2c + PT_RESULT = 0x2b + PT_SOFTE = 0x27 + PT_TRAP = 0x28 + PT_VR0 = 0x52 + PT_VRSAVE = 0x94 + PT_VSCR = 0x93 + PT_VSR0 = 0x96 + PT_VSR31 = 0xd4 + PT_XER = 0x25 + RLIMIT_AS = 0x9 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x7 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = -0x1 + RTAX_ADVMSS = 0x8 + RTAX_CWND = 0x7 + RTAX_FEATURES = 0xc + RTAX_FEATURE_ALLFRAG = 0x8 + RTAX_FEATURE_ECN = 0x1 + RTAX_FEATURE_SACK = 0x2 + RTAX_FEATURE_TIMESTAMP = 0x4 + RTAX_HOPLIMIT = 0xa + RTAX_INITCWND = 0xb + RTAX_INITRWND = 0xe + RTAX_LOCK = 0x1 + RTAX_MAX = 0xf + RTAX_MTU = 0x2 + RTAX_QUICKACK = 0xf + RTAX_REORDERING = 0x9 + RTAX_RTO_MIN = 0xd + RTAX_RTT = 0x4 + RTAX_RTTVAR = 0x5 + RTAX_SSTHRESH = 0x6 + RTAX_UNSPEC = 0x0 + RTAX_WINDOW = 0x3 + RTA_ALIGNTO = 0x4 + RTA_MAX = 0x11 + RTCF_DIRECTSRC = 0x4000000 + RTCF_DOREDIRECT = 0x1000000 + RTCF_LOG = 0x2000000 + RTCF_MASQ = 0x400000 + RTCF_NAT = 0x800000 + RTCF_VALVE = 0x200000 + RTF_ADDRCLASSMASK = 0xf8000000 + RTF_ADDRCONF = 0x40000 + RTF_ALLONLINK = 0x20000 + RTF_BROADCAST = 0x10000000 + RTF_CACHE = 0x1000000 + RTF_DEFAULT = 0x10000 + RTF_DYNAMIC = 0x10 + RTF_FLOW = 0x2000000 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_INTERFACE = 0x40000000 + RTF_IRTT = 0x100 + RTF_LINKRT = 0x100000 + RTF_LOCAL = 0x80000000 + RTF_MODIFIED = 0x20 + RTF_MSS = 0x40 + RTF_MTU = 0x40 + RTF_MULTICAST = 0x20000000 + RTF_NAT = 0x8000000 + RTF_NOFORWARD = 0x1000 + RTF_NONEXTHOP = 0x200000 + RTF_NOPMTUDISC = 0x4000 + RTF_POLICY = 0x4000000 + RTF_REINSTATE = 0x8 + RTF_REJECT = 0x200 + RTF_STATIC = 0x400 + RTF_THROW = 0x2000 + RTF_UP = 0x1 + RTF_WINDOW = 0x80 + RTF_XRESOLVE = 0x800 + RTM_BASE = 0x10 + RTM_DELACTION = 0x31 + RTM_DELADDR = 0x15 + RTM_DELADDRLABEL = 0x49 + RTM_DELLINK = 0x11 + RTM_DELMDB = 0x55 + RTM_DELNEIGH = 0x1d + RTM_DELQDISC = 0x25 + RTM_DELROUTE = 0x19 + RTM_DELRULE = 0x21 + RTM_DELTCLASS = 0x29 + RTM_DELTFILTER = 0x2d + RTM_F_CLONED = 0x200 + RTM_F_EQUALIZE = 0x400 + RTM_F_NOTIFY = 0x100 + RTM_F_PREFIX = 0x800 + RTM_GETACTION = 0x32 + RTM_GETADDR = 0x16 + RTM_GETADDRLABEL = 0x4a + RTM_GETANYCAST = 0x3e + RTM_GETDCB = 0x4e + RTM_GETLINK = 0x12 + RTM_GETMDB = 0x56 + RTM_GETMULTICAST = 0x3a + RTM_GETNEIGH = 0x1e + RTM_GETNEIGHTBL = 0x42 + RTM_GETNETCONF = 0x52 + RTM_GETQDISC = 0x26 + RTM_GETROUTE = 0x1a + RTM_GETRULE = 0x22 + RTM_GETTCLASS = 0x2a + RTM_GETTFILTER = 0x2e + RTM_MAX = 0x57 + RTM_NEWACTION = 0x30 + RTM_NEWADDR = 0x14 + RTM_NEWADDRLABEL = 0x48 + RTM_NEWLINK = 0x10 + RTM_NEWMDB = 0x54 + RTM_NEWNDUSEROPT = 0x44 + RTM_NEWNEIGH = 0x1c + RTM_NEWNEIGHTBL = 0x40 + RTM_NEWNETCONF = 0x50 + RTM_NEWPREFIX = 0x34 + RTM_NEWQDISC = 0x24 + RTM_NEWROUTE = 0x18 + RTM_NEWRULE = 0x20 + RTM_NEWTCLASS = 0x28 + RTM_NEWTFILTER = 0x2c + RTM_NR_FAMILIES = 0x12 + RTM_NR_MSGTYPES = 0x48 + RTM_SETDCB = 0x4f + RTM_SETLINK = 0x13 + RTM_SETNEIGHTBL = 0x43 + RTNH_ALIGNTO = 0x4 + RTNH_F_DEAD = 0x1 + RTNH_F_ONLINK = 0x4 + RTNH_F_PERVASIVE = 0x2 + RTN_MAX = 0xb + RTPROT_BIRD = 0xc + RTPROT_BOOT = 0x3 + RTPROT_DHCP = 0x10 + RTPROT_DNROUTED = 0xd + RTPROT_GATED = 0x8 + RTPROT_KERNEL = 0x2 + RTPROT_MROUTED = 0x11 + RTPROT_MRT = 0xa + RTPROT_NTK = 0xf + RTPROT_RA = 0x9 + RTPROT_REDIRECT = 0x1 + RTPROT_STATIC = 0x4 + RTPROT_UNSPEC = 0x0 + RTPROT_XORP = 0xe + RTPROT_ZEBRA = 0xb + RT_CLASS_DEFAULT = 0xfd + RT_CLASS_LOCAL = 0xff + RT_CLASS_MAIN = 0xfe + RT_CLASS_MAX = 0xff + RT_CLASS_UNSPEC = 0x0 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + RUSAGE_THREAD = 0x1 + SCM_CREDENTIALS = 0x2 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x1d + SCM_TIMESTAMPING = 0x25 + SCM_TIMESTAMPNS = 0x23 + SCM_WIFI_STATUS = 0x29 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDDLCI = 0x8980 + SIOCADDMULTI = 0x8931 + SIOCADDRT = 0x890b + SIOCATMARK = 0x8905 + SIOCDARP = 0x8953 + SIOCDELDLCI = 0x8981 + SIOCDELMULTI = 0x8932 + SIOCDELRT = 0x890c + SIOCDEVPRIVATE = 0x89f0 + SIOCDIFADDR = 0x8936 + SIOCDRARP = 0x8960 + SIOCGARP = 0x8954 + SIOCGIFADDR = 0x8915 + SIOCGIFBR = 0x8940 + SIOCGIFBRDADDR = 0x8919 + SIOCGIFCONF = 0x8912 + SIOCGIFCOUNT = 0x8938 + SIOCGIFDSTADDR = 0x8917 + SIOCGIFENCAP = 0x8925 + SIOCGIFFLAGS = 0x8913 + SIOCGIFHWADDR = 0x8927 + SIOCGIFINDEX = 0x8933 + SIOCGIFMAP = 0x8970 + SIOCGIFMEM = 0x891f + SIOCGIFMETRIC = 0x891d + SIOCGIFMTU = 0x8921 + SIOCGIFNAME = 0x8910 + SIOCGIFNETMASK = 0x891b + SIOCGIFPFLAGS = 0x8935 + SIOCGIFSLAVE = 0x8929 + SIOCGIFTXQLEN = 0x8942 + SIOCGPGRP = 0x8904 + SIOCGRARP = 0x8961 + SIOCGSTAMP = 0x8906 + SIOCGSTAMPNS = 0x8907 + SIOCPROTOPRIVATE = 0x89e0 + SIOCRTMSG = 0x890d + SIOCSARP = 0x8955 + SIOCSIFADDR = 0x8916 + SIOCSIFBR = 0x8941 + SIOCSIFBRDADDR = 0x891a + SIOCSIFDSTADDR = 0x8918 + SIOCSIFENCAP = 0x8926 + SIOCSIFFLAGS = 0x8914 + SIOCSIFHWADDR = 0x8924 + SIOCSIFHWBROADCAST = 0x8937 + SIOCSIFLINK = 0x8911 + SIOCSIFMAP = 0x8971 + SIOCSIFMEM = 0x8920 + SIOCSIFMETRIC = 0x891e + SIOCSIFMTU = 0x8922 + SIOCSIFNAME = 0x8923 + SIOCSIFNETMASK = 0x891c + SIOCSIFPFLAGS = 0x8934 + SIOCSIFSLAVE = 0x8930 + SIOCSIFTXQLEN = 0x8943 + SIOCSPGRP = 0x8902 + SIOCSRARP = 0x8962 + SOCK_CLOEXEC = 0x80000 + SOCK_DCCP = 0x6 + SOCK_DGRAM = 0x2 + SOCK_NONBLOCK = 0x800 + SOCK_PACKET = 0xa + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_AAL = 0x109 + SOL_ATM = 0x108 + SOL_DECNET = 0x105 + SOL_ICMPV6 = 0x3a + SOL_IP = 0x0 + SOL_IPV6 = 0x29 + SOL_IRDA = 0x10a + SOL_PACKET = 0x107 + SOL_RAW = 0xff + SOL_SOCKET = 0x1 + SOL_TCP = 0x6 + SOL_X25 = 0x106 + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x1e + SO_ATTACH_FILTER = 0x1a + SO_BINDTODEVICE = 0x19 + SO_BROADCAST = 0x6 + SO_BSDCOMPAT = 0xe + SO_BUSY_POLL = 0x2e + SO_DEBUG = 0x1 + SO_DETACH_FILTER = 0x1b + SO_DOMAIN = 0x27 + SO_DONTROUTE = 0x5 + SO_ERROR = 0x4 + SO_GET_FILTER = 0x1a + SO_KEEPALIVE = 0x9 + SO_LINGER = 0xd + SO_LOCK_FILTER = 0x2c + SO_MARK = 0x24 + SO_MAX_PACING_RATE = 0x2f + SO_NOFCS = 0x2b + SO_NO_CHECK = 0xb + SO_OOBINLINE = 0xa + SO_PASSCRED = 0x14 + SO_PASSSEC = 0x22 + SO_PEEK_OFF = 0x2a + SO_PEERCRED = 0x15 + SO_PEERNAME = 0x1c + SO_PEERSEC = 0x1f + SO_PRIORITY = 0xc + SO_PROTOCOL = 0x26 + SO_RCVBUF = 0x8 + SO_RCVBUFFORCE = 0x21 + SO_RCVLOWAT = 0x10 + SO_RCVTIMEO = 0x12 + SO_REUSEADDR = 0x2 + SO_REUSEPORT = 0xf + SO_RXQ_OVFL = 0x28 + SO_SECURITY_AUTHENTICATION = 0x16 + SO_SECURITY_ENCRYPTION_NETWORK = 0x18 + SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17 + SO_SELECT_ERR_QUEUE = 0x2d + SO_SNDBUF = 0x7 + SO_SNDBUFFORCE = 0x20 + SO_SNDLOWAT = 0x11 + SO_SNDTIMEO = 0x13 + SO_TIMESTAMP = 0x1d + SO_TIMESTAMPING = 0x25 + SO_TIMESTAMPNS = 0x23 + SO_TYPE = 0x3 + SO_WIFI_STATUS = 0x29 + S_BLKSIZE = 0x200 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + TAB0 = 0x0 + TAB1 = 0x400 + TAB2 = 0x800 + TAB3 = 0xc00 + TABDLY = 0xc00 + TCFLSH = 0x2000741f + TCGETA = 0x40147417 + TCGETS = 0x402c7413 + TCIFLUSH = 0x0 + TCIOFF = 0x2 + TCIOFLUSH = 0x2 + TCION = 0x3 + TCOFLUSH = 0x1 + TCOOFF = 0x0 + TCOON = 0x1 + TCP_CONGESTION = 0xd + TCP_COOKIE_IN_ALWAYS = 0x1 + TCP_COOKIE_MAX = 0x10 + TCP_COOKIE_MIN = 0x8 + TCP_COOKIE_OUT_NEVER = 0x2 + TCP_COOKIE_PAIR_SIZE = 0x20 + TCP_COOKIE_TRANSACTIONS = 0xf + TCP_CORK = 0x3 + TCP_DEFER_ACCEPT = 0x9 + TCP_FASTOPEN = 0x17 + TCP_INFO = 0xb + TCP_KEEPCNT = 0x6 + TCP_KEEPIDLE = 0x4 + TCP_KEEPINTVL = 0x5 + TCP_LINGER2 = 0x8 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0xe + TCP_MD5SIG_MAXKEYLEN = 0x50 + TCP_MSS = 0x200 + TCP_MSS_DEFAULT = 0x218 + TCP_MSS_DESIRED = 0x4c4 + TCP_NODELAY = 0x1 + TCP_QUEUE_SEQ = 0x15 + TCP_QUICKACK = 0xc + TCP_REPAIR = 0x13 + TCP_REPAIR_OPTIONS = 0x16 + TCP_REPAIR_QUEUE = 0x14 + TCP_SYNCNT = 0x7 + TCP_S_DATA_IN = 0x4 + TCP_S_DATA_OUT = 0x8 + TCP_THIN_DUPACK = 0x11 + TCP_THIN_LINEAR_TIMEOUTS = 0x10 + TCP_TIMESTAMP = 0x18 + TCP_USER_TIMEOUT = 0x12 + TCP_WINDOW_CLAMP = 0xa + TCSAFLUSH = 0x2 + TCSBRK = 0x2000741d + TCSBRKP = 0x5425 + TCSETA = 0x80147418 + TCSETAF = 0x8014741c + TCSETAW = 0x80147419 + TCSETS = 0x802c7414 + TCSETSF = 0x802c7416 + TCSETSW = 0x802c7415 + TCXONC = 0x2000741e + TIOCCBRK = 0x5428 + TIOCCONS = 0x541d + TIOCEXCL = 0x540c + TIOCGDEV = 0x40045432 + TIOCGETC = 0x40067412 + TIOCGETD = 0x5424 + TIOCGETP = 0x40067408 + TIOCGEXCL = 0x40045440 + TIOCGICOUNT = 0x545d + TIOCGLCKTRMIOS = 0x5456 + TIOCGLTC = 0x40067474 + TIOCGPGRP = 0x40047477 + TIOCGPKT = 0x40045438 + TIOCGPTLCK = 0x40045439 + TIOCGPTN = 0x40045430 + TIOCGRS485 = 0x542e + TIOCGSERIAL = 0x541e + TIOCGSID = 0x5429 + TIOCGSOFTCAR = 0x5419 + TIOCGWINSZ = 0x40087468 + TIOCINQ = 0x4004667f + TIOCLINUX = 0x541c + TIOCMBIC = 0x5417 + TIOCMBIS = 0x5416 + TIOCMGET = 0x5415 + TIOCMIWAIT = 0x545c + TIOCMSET = 0x5418 + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_LOOP = 0x8000 + TIOCM_OUT1 = 0x2000 + TIOCM_OUT2 = 0x4000 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x5422 + TIOCNXCL = 0x540d + TIOCOUTQ = 0x40047473 + TIOCPKT = 0x5420 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCSBRK = 0x5427 + TIOCSCTTY = 0x540e + TIOCSERCONFIG = 0x5453 + TIOCSERGETLSR = 0x5459 + TIOCSERGETMULTI = 0x545a + TIOCSERGSTRUCT = 0x5458 + TIOCSERGWILD = 0x5454 + TIOCSERSETMULTI = 0x545b + TIOCSERSWILD = 0x5455 + TIOCSER_TEMT = 0x1 + TIOCSETC = 0x80067411 + TIOCSETD = 0x5423 + TIOCSETN = 0x8006740a + TIOCSETP = 0x80067409 + TIOCSIG = 0x80045436 + TIOCSLCKTRMIOS = 0x5457 + TIOCSLTC = 0x80067475 + TIOCSPGRP = 0x80047476 + TIOCSPTLCK = 0x80045431 + TIOCSRS485 = 0x542f + TIOCSSERIAL = 0x541f + TIOCSSOFTCAR = 0x541a + TIOCSTART = 0x2000746e + TIOCSTI = 0x5412 + TIOCSTOP = 0x2000746f + TIOCSWINSZ = 0x80087467 + TIOCVHANGUP = 0x5437 + TOSTOP = 0x400000 + TUNATTACHFILTER = 0x801054d5 + TUNDETACHFILTER = 0x801054d6 + TUNGETFEATURES = 0x400454cf + TUNGETFILTER = 0x401054db + TUNGETIFF = 0x400454d2 + TUNGETSNDBUF = 0x400454d3 + TUNGETVNETHDRSZ = 0x400454d7 + TUNSETDEBUG = 0x800454c9 + TUNSETGROUP = 0x800454ce + TUNSETIFF = 0x800454ca + TUNSETIFINDEX = 0x800454da + TUNSETLINK = 0x800454cd + TUNSETNOCSUM = 0x800454c8 + TUNSETOFFLOAD = 0x800454d0 + TUNSETOWNER = 0x800454cc + TUNSETPERSIST = 0x800454cb + TUNSETQUEUE = 0x800454d9 + TUNSETSNDBUF = 0x800454d4 + TUNSETTXFILTER = 0x800454d1 + TUNSETVNETHDRSZ = 0x800454d8 + VDISCARD = 0x10 + VEOF = 0x4 + VEOL = 0x6 + VEOL2 = 0x8 + VERASE = 0x2 + VINTR = 0x0 + VKILL = 0x3 + VLNEXT = 0xf + VMIN = 0x5 + VQUIT = 0x1 + VREPRINT = 0xb + VSTART = 0xd + VSTOP = 0xe + VSUSP = 0xc + VSWTC = 0x9 + VT0 = 0x0 + VT1 = 0x10000 + VTDLY = 0x10000 + VTIME = 0x7 + VWERASE = 0xa + WALL = 0x40000000 + WCLONE = 0x80000000 + WCONTINUED = 0x8 + WEXITED = 0x4 + WNOHANG = 0x1 + WNOTHREAD = 0x20000000 + WNOWAIT = 0x1000000 + WORDSIZE = 0x40 + WSTOPPED = 0x2 + WUNTRACED = 0x2 + XCASE = 0x4000 + XTABS = 0xc00 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x62) + EADDRNOTAVAIL = syscall.Errno(0x63) + EADV = syscall.Errno(0x44) + EAFNOSUPPORT = syscall.Errno(0x61) + EAGAIN = syscall.Errno(0xb) + EALREADY = syscall.Errno(0x72) + EBADE = syscall.Errno(0x34) + EBADF = syscall.Errno(0x9) + EBADFD = syscall.Errno(0x4d) + EBADMSG = syscall.Errno(0x4a) + EBADR = syscall.Errno(0x35) + EBADRQC = syscall.Errno(0x38) + EBADSLT = syscall.Errno(0x39) + EBFONT = syscall.Errno(0x3b) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x7d) + ECHILD = syscall.Errno(0xa) + ECHRNG = syscall.Errno(0x2c) + ECOMM = syscall.Errno(0x46) + ECONNABORTED = syscall.Errno(0x67) + ECONNREFUSED = syscall.Errno(0x6f) + ECONNRESET = syscall.Errno(0x68) + EDEADLK = syscall.Errno(0x23) + EDEADLOCK = syscall.Errno(0x3a) + EDESTADDRREQ = syscall.Errno(0x59) + EDOM = syscall.Errno(0x21) + EDOTDOT = syscall.Errno(0x49) + EDQUOT = syscall.Errno(0x7a) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EHOSTDOWN = syscall.Errno(0x70) + EHOSTUNREACH = syscall.Errno(0x71) + EHWPOISON = syscall.Errno(0x85) + EIDRM = syscall.Errno(0x2b) + EILSEQ = syscall.Errno(0x54) + EINPROGRESS = syscall.Errno(0x73) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x6a) + EISDIR = syscall.Errno(0x15) + EISNAM = syscall.Errno(0x78) + EKEYEXPIRED = syscall.Errno(0x7f) + EKEYREJECTED = syscall.Errno(0x81) + EKEYREVOKED = syscall.Errno(0x80) + EL2HLT = syscall.Errno(0x33) + EL2NSYNC = syscall.Errno(0x2d) + EL3HLT = syscall.Errno(0x2e) + EL3RST = syscall.Errno(0x2f) + ELIBACC = syscall.Errno(0x4f) + ELIBBAD = syscall.Errno(0x50) + ELIBEXEC = syscall.Errno(0x53) + ELIBMAX = syscall.Errno(0x52) + ELIBSCN = syscall.Errno(0x51) + ELNRNG = syscall.Errno(0x30) + ELOOP = syscall.Errno(0x28) + EMEDIUMTYPE = syscall.Errno(0x7c) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x5a) + EMULTIHOP = syscall.Errno(0x48) + ENAMETOOLONG = syscall.Errno(0x24) + ENAVAIL = syscall.Errno(0x77) + ENETDOWN = syscall.Errno(0x64) + ENETRESET = syscall.Errno(0x66) + ENETUNREACH = syscall.Errno(0x65) + ENFILE = syscall.Errno(0x17) + ENOANO = syscall.Errno(0x37) + ENOBUFS = syscall.Errno(0x69) + ENOCSI = syscall.Errno(0x32) + ENODATA = syscall.Errno(0x3d) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOKEY = syscall.Errno(0x7e) + ENOLCK = syscall.Errno(0x25) + ENOLINK = syscall.Errno(0x43) + ENOMEDIUM = syscall.Errno(0x7b) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x2a) + ENONET = syscall.Errno(0x40) + ENOPKG = syscall.Errno(0x41) + ENOPROTOOPT = syscall.Errno(0x5c) + ENOSPC = syscall.Errno(0x1c) + ENOSR = syscall.Errno(0x3f) + ENOSTR = syscall.Errno(0x3c) + ENOSYS = syscall.Errno(0x26) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x6b) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x27) + ENOTNAM = syscall.Errno(0x76) + ENOTRECOVERABLE = syscall.Errno(0x83) + ENOTSOCK = syscall.Errno(0x58) + ENOTSUP = syscall.Errno(0x5f) + ENOTTY = syscall.Errno(0x19) + ENOTUNIQ = syscall.Errno(0x4c) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x5f) + EOVERFLOW = syscall.Errno(0x4b) + EOWNERDEAD = syscall.Errno(0x82) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x60) + EPIPE = syscall.Errno(0x20) + EPROTO = syscall.Errno(0x47) + EPROTONOSUPPORT = syscall.Errno(0x5d) + EPROTOTYPE = syscall.Errno(0x5b) + ERANGE = syscall.Errno(0x22) + EREMCHG = syscall.Errno(0x4e) + EREMOTE = syscall.Errno(0x42) + EREMOTEIO = syscall.Errno(0x79) + ERESTART = syscall.Errno(0x55) + ERFKILL = syscall.Errno(0x84) + EROFS = syscall.Errno(0x1e) + ESHUTDOWN = syscall.Errno(0x6c) + ESOCKTNOSUPPORT = syscall.Errno(0x5e) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESRMNT = syscall.Errno(0x45) + ESTALE = syscall.Errno(0x74) + ESTRPIPE = syscall.Errno(0x56) + ETIME = syscall.Errno(0x3e) + ETIMEDOUT = syscall.Errno(0x6e) + ETOOMANYREFS = syscall.Errno(0x6d) + ETXTBSY = syscall.Errno(0x1a) + EUCLEAN = syscall.Errno(0x75) + EUNATCH = syscall.Errno(0x31) + EUSERS = syscall.Errno(0x57) + EWOULDBLOCK = syscall.Errno(0xb) + EXDEV = syscall.Errno(0x12) + EXFULL = syscall.Errno(0x36) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0x7) + SIGCHLD = syscall.Signal(0x11) + SIGCLD = syscall.Signal(0x11) + SIGCONT = syscall.Signal(0x12) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x1d) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPOLL = syscall.Signal(0x1d) + SIGPROF = syscall.Signal(0x1b) + SIGPWR = syscall.Signal(0x1e) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTKFLT = syscall.Signal(0x10) + SIGSTOP = syscall.Signal(0x13) + SIGSYS = syscall.Signal(0x1f) + SIGTERM = syscall.Signal(0xf) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x14) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGUNUSED = syscall.Signal(0x1f) + SIGURG = syscall.Signal(0x17) + SIGUSR1 = syscall.Signal(0xa) + SIGUSR2 = syscall.Signal(0xc) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "no such device or address", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource temporarily unavailable", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device or resource busy", + 17: "file exists", + 18: "invalid cross-device link", + 19: "no such device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "numerical result out of range", + 35: "resource deadlock avoided", + 36: "file name too long", + 37: "no locks available", + 38: "function not implemented", + 39: "directory not empty", + 40: "too many levels of symbolic links", + 42: "no message of desired type", + 43: "identifier removed", + 44: "channel number out of range", + 45: "level 2 not synchronized", + 46: "level 3 halted", + 47: "level 3 reset", + 48: "link number out of range", + 49: "protocol driver not attached", + 50: "no CSI structure available", + 51: "level 2 halted", + 52: "invalid exchange", + 53: "invalid request descriptor", + 54: "exchange full", + 55: "no anode", + 56: "invalid request code", + 57: "invalid slot", + 58: "file locking deadlock error", + 59: "bad font file format", + 60: "device not a stream", + 61: "no data available", + 62: "timer expired", + 63: "out of streams resources", + 64: "machine is not on the network", + 65: "package not installed", + 66: "object is remote", + 67: "link has been severed", + 68: "advertise error", + 69: "srmount error", + 70: "communication error on send", + 71: "protocol error", + 72: "multihop attempted", + 73: "RFS specific error", + 74: "bad message", + 75: "value too large for defined data type", + 76: "name not unique on network", + 77: "file descriptor in bad state", + 78: "remote address changed", + 79: "can not access a needed shared library", + 80: "accessing a corrupted shared library", + 81: ".lib section in a.out corrupted", + 82: "attempting to link in too many shared libraries", + 83: "cannot exec a shared library directly", + 84: "invalid or incomplete multibyte or wide character", + 85: "interrupted system call should be restarted", + 86: "streams pipe error", + 87: "too many users", + 88: "socket operation on non-socket", + 89: "destination address required", + 90: "message too long", + 91: "protocol wrong type for socket", + 92: "protocol not available", + 93: "protocol not supported", + 94: "socket type not supported", + 95: "operation not supported", + 96: "protocol family not supported", + 97: "address family not supported by protocol", + 98: "address already in use", + 99: "cannot assign requested address", + 100: "network is down", + 101: "network is unreachable", + 102: "network dropped connection on reset", + 103: "software caused connection abort", + 104: "connection reset by peer", + 105: "no buffer space available", + 106: "transport endpoint is already connected", + 107: "transport endpoint is not connected", + 108: "cannot send after transport endpoint shutdown", + 109: "too many references: cannot splice", + 110: "connection timed out", + 111: "connection refused", + 112: "host is down", + 113: "no route to host", + 114: "operation already in progress", + 115: "operation now in progress", + 116: "stale file handle", + 117: "structure needs cleaning", + 118: "not a XENIX named type file", + 119: "no XENIX semaphores available", + 120: "is a named type file", + 121: "remote I/O error", + 122: "disk quota exceeded", + 123: "no medium found", + 124: "wrong medium type", + 125: "operation canceled", + 126: "required key not available", + 127: "key has expired", + 128: "key has been revoked", + 129: "key was rejected by service", + 130: "owner died", + 131: "state not recoverable", + 132: "operation not possible due to RF-kill", + 133: "memory page has hardware error", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/breakpoint trap", + 6: "aborted", + 7: "bus error", + 8: "floating point exception", + 9: "killed", + 10: "user defined signal 1", + 11: "segmentation fault", + 12: "user defined signal 2", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "stack fault", + 17: "child exited", + 18: "continued", + 19: "stopped (signal)", + 20: "stopped", + 21: "stopped (tty input)", + 22: "stopped (tty output)", + 23: "urgent I/O condition", + 24: "CPU time limit exceeded", + 25: "file size limit exceeded", + 26: "virtual timer expired", + 27: "profiling timer expired", + 28: "window changed", + 29: "I/O possible", + 30: "power failure", + 31: "bad system call", +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_s390x.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_s390x.go new file mode 100644 index 0000000000..329f25e7cf --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_s390x.go @@ -0,0 +1,2027 @@ +// mkerrors.sh -m64 +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build s390x,linux + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -m64 _const.go + +package unix + +import "syscall" + +const ( + AF_ALG = 0x26 + AF_APPLETALK = 0x5 + AF_ASH = 0x12 + AF_ATMPVC = 0x8 + AF_ATMSVC = 0x14 + AF_AX25 = 0x3 + AF_BLUETOOTH = 0x1f + AF_BRIDGE = 0x7 + AF_CAIF = 0x25 + AF_CAN = 0x1d + AF_DECnet = 0xc + AF_ECONET = 0x13 + AF_FILE = 0x1 + AF_IB = 0x1b + AF_IEEE802154 = 0x24 + AF_INET = 0x2 + AF_INET6 = 0xa + AF_IPX = 0x4 + AF_IRDA = 0x17 + AF_ISDN = 0x22 + AF_IUCV = 0x20 + AF_KEY = 0xf + AF_LLC = 0x1a + AF_LOCAL = 0x1 + AF_MAX = 0x29 + AF_MPLS = 0x1c + AF_NETBEUI = 0xd + AF_NETLINK = 0x10 + AF_NETROM = 0x6 + AF_NFC = 0x27 + AF_PACKET = 0x11 + AF_PHONET = 0x23 + AF_PPPOX = 0x18 + AF_RDS = 0x15 + AF_ROSE = 0xb + AF_ROUTE = 0x10 + AF_RXRPC = 0x21 + AF_SECURITY = 0xe + AF_SNA = 0x16 + AF_TIPC = 0x1e + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_VSOCK = 0x28 + AF_WANPIPE = 0x19 + AF_X25 = 0x9 + ARPHRD_6LOWPAN = 0x339 + ARPHRD_ADAPT = 0x108 + ARPHRD_APPLETLK = 0x8 + ARPHRD_ARCNET = 0x7 + ARPHRD_ASH = 0x30d + ARPHRD_ATM = 0x13 + ARPHRD_AX25 = 0x3 + ARPHRD_BIF = 0x307 + ARPHRD_CAIF = 0x336 + ARPHRD_CAN = 0x118 + ARPHRD_CHAOS = 0x5 + ARPHRD_CISCO = 0x201 + ARPHRD_CSLIP = 0x101 + ARPHRD_CSLIP6 = 0x103 + ARPHRD_DDCMP = 0x205 + ARPHRD_DLCI = 0xf + ARPHRD_ECONET = 0x30e + ARPHRD_EETHER = 0x2 + ARPHRD_ETHER = 0x1 + ARPHRD_EUI64 = 0x1b + ARPHRD_FCAL = 0x311 + ARPHRD_FCFABRIC = 0x313 + ARPHRD_FCPL = 0x312 + ARPHRD_FCPP = 0x310 + ARPHRD_FDDI = 0x306 + ARPHRD_FRAD = 0x302 + ARPHRD_HDLC = 0x201 + ARPHRD_HIPPI = 0x30c + ARPHRD_HWX25 = 0x110 + ARPHRD_IEEE1394 = 0x18 + ARPHRD_IEEE802 = 0x6 + ARPHRD_IEEE80211 = 0x321 + ARPHRD_IEEE80211_PRISM = 0x322 + ARPHRD_IEEE80211_RADIOTAP = 0x323 + ARPHRD_IEEE802154 = 0x324 + ARPHRD_IEEE802154_MONITOR = 0x325 + ARPHRD_IEEE802_TR = 0x320 + ARPHRD_INFINIBAND = 0x20 + ARPHRD_IP6GRE = 0x337 + ARPHRD_IPDDP = 0x309 + ARPHRD_IPGRE = 0x30a + ARPHRD_IRDA = 0x30f + ARPHRD_LAPB = 0x204 + ARPHRD_LOCALTLK = 0x305 + ARPHRD_LOOPBACK = 0x304 + ARPHRD_METRICOM = 0x17 + ARPHRD_NETLINK = 0x338 + ARPHRD_NETROM = 0x0 + ARPHRD_NONE = 0xfffe + ARPHRD_PHONET = 0x334 + ARPHRD_PHONET_PIPE = 0x335 + ARPHRD_PIMREG = 0x30b + ARPHRD_PPP = 0x200 + ARPHRD_PRONET = 0x4 + ARPHRD_RAWHDLC = 0x206 + ARPHRD_ROSE = 0x10e + ARPHRD_RSRVD = 0x104 + ARPHRD_SIT = 0x308 + ARPHRD_SKIP = 0x303 + ARPHRD_SLIP = 0x100 + ARPHRD_SLIP6 = 0x102 + ARPHRD_TUNNEL = 0x300 + ARPHRD_TUNNEL6 = 0x301 + ARPHRD_VOID = 0xffff + ARPHRD_X25 = 0x10f + B0 = 0x0 + B1000000 = 0x1008 + B110 = 0x3 + B115200 = 0x1002 + B1152000 = 0x1009 + B1200 = 0x9 + B134 = 0x4 + B150 = 0x5 + B1500000 = 0x100a + B1800 = 0xa + B19200 = 0xe + B200 = 0x6 + B2000000 = 0x100b + B230400 = 0x1003 + B2400 = 0xb + B2500000 = 0x100c + B300 = 0x7 + B3000000 = 0x100d + B3500000 = 0x100e + B38400 = 0xf + B4000000 = 0x100f + B460800 = 0x1004 + B4800 = 0xc + B50 = 0x1 + B500000 = 0x1005 + B57600 = 0x1001 + B576000 = 0x1006 + B600 = 0x8 + B75 = 0x2 + B921600 = 0x1007 + B9600 = 0xd + BOTHER = 0x1000 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LL_OFF = -0x200000 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXINSNS = 0x1000 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MOD = 0x90 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_NET_OFF = -0x100000 + BPF_OR = 0x40 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BPF_XOR = 0xa0 + BRKINT = 0x2 + BS0 = 0x0 + BS1 = 0x2000 + BSDLY = 0x2000 + CBAUD = 0x100f + CBAUDEX = 0x1000 + CFLUSH = 0xf + CIBAUD = 0x100f0000 + CLOCAL = 0x800 + CLOCK_BOOTTIME = 0x7 + CLOCK_BOOTTIME_ALARM = 0x9 + CLOCK_DEFAULT = 0x0 + CLOCK_EXT = 0x1 + CLOCK_INT = 0x2 + CLOCK_MONOTONIC = 0x1 + CLOCK_MONOTONIC_COARSE = 0x6 + CLOCK_MONOTONIC_RAW = 0x4 + CLOCK_PROCESS_CPUTIME_ID = 0x2 + CLOCK_REALTIME = 0x0 + CLOCK_REALTIME_ALARM = 0x8 + CLOCK_REALTIME_COARSE = 0x5 + CLOCK_TAI = 0xb + CLOCK_THREAD_CPUTIME_ID = 0x3 + CLOCK_TXFROMRX = 0x4 + CLOCK_TXINT = 0x3 + CLONE_CHILD_CLEARTID = 0x200000 + CLONE_CHILD_SETTID = 0x1000000 + CLONE_DETACHED = 0x400000 + CLONE_FILES = 0x400 + CLONE_FS = 0x200 + CLONE_IO = 0x80000000 + CLONE_NEWCGROUP = 0x2000000 + CLONE_NEWIPC = 0x8000000 + CLONE_NEWNET = 0x40000000 + CLONE_NEWNS = 0x20000 + CLONE_NEWPID = 0x20000000 + CLONE_NEWUSER = 0x10000000 + CLONE_NEWUTS = 0x4000000 + CLONE_PARENT = 0x8000 + CLONE_PARENT_SETTID = 0x100000 + CLONE_PTRACE = 0x2000 + CLONE_SETTLS = 0x80000 + CLONE_SIGHAND = 0x800 + CLONE_SYSVSEM = 0x40000 + CLONE_THREAD = 0x10000 + CLONE_UNTRACED = 0x800000 + CLONE_VFORK = 0x4000 + CLONE_VM = 0x100 + CMSPAR = 0x40000000 + CR0 = 0x0 + CR1 = 0x200 + CR2 = 0x400 + CR3 = 0x600 + CRDLY = 0x600 + CREAD = 0x80 + CRTSCTS = 0x80000000 + CS5 = 0x0 + CS6 = 0x10 + CS7 = 0x20 + CS8 = 0x30 + CSIGNAL = 0xff + CSIZE = 0x30 + CSTART = 0x11 + CSTATUS = 0x0 + CSTOP = 0x13 + CSTOPB = 0x40 + CSUSP = 0x1a + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x200 + ECHOE = 0x10 + ECHOK = 0x20 + ECHOKE = 0x800 + ECHONL = 0x40 + ECHOPRT = 0x400 + ENCODING_DEFAULT = 0x0 + ENCODING_FM_MARK = 0x3 + ENCODING_FM_SPACE = 0x4 + ENCODING_MANCHESTER = 0x5 + ENCODING_NRZ = 0x1 + ENCODING_NRZI = 0x2 + EPOLLERR = 0x8 + EPOLLET = 0x80000000 + EPOLLHUP = 0x10 + EPOLLIN = 0x1 + EPOLLMSG = 0x400 + EPOLLONESHOT = 0x40000000 + EPOLLOUT = 0x4 + EPOLLPRI = 0x2 + EPOLLRDBAND = 0x80 + EPOLLRDHUP = 0x2000 + EPOLLRDNORM = 0x40 + EPOLLWAKEUP = 0x20000000 + EPOLLWRBAND = 0x200 + EPOLLWRNORM = 0x100 + EPOLL_CLOEXEC = 0x80000 + EPOLL_CTL_ADD = 0x1 + EPOLL_CTL_DEL = 0x2 + EPOLL_CTL_MOD = 0x3 + ETH_P_1588 = 0x88f7 + ETH_P_8021AD = 0x88a8 + ETH_P_8021AH = 0x88e7 + ETH_P_8021Q = 0x8100 + ETH_P_80221 = 0x8917 + ETH_P_802_2 = 0x4 + ETH_P_802_3 = 0x1 + ETH_P_802_3_MIN = 0x600 + ETH_P_802_EX1 = 0x88b5 + ETH_P_AARP = 0x80f3 + ETH_P_AF_IUCV = 0xfbfb + ETH_P_ALL = 0x3 + ETH_P_AOE = 0x88a2 + ETH_P_ARCNET = 0x1a + ETH_P_ARP = 0x806 + ETH_P_ATALK = 0x809b + ETH_P_ATMFATE = 0x8884 + ETH_P_ATMMPOA = 0x884c + ETH_P_AX25 = 0x2 + ETH_P_BATMAN = 0x4305 + ETH_P_BPQ = 0x8ff + ETH_P_CAIF = 0xf7 + ETH_P_CAN = 0xc + ETH_P_CANFD = 0xd + ETH_P_CONTROL = 0x16 + ETH_P_CUST = 0x6006 + ETH_P_DDCMP = 0x6 + ETH_P_DEC = 0x6000 + ETH_P_DIAG = 0x6005 + ETH_P_DNA_DL = 0x6001 + ETH_P_DNA_RC = 0x6002 + ETH_P_DNA_RT = 0x6003 + ETH_P_DSA = 0x1b + ETH_P_ECONET = 0x18 + ETH_P_EDSA = 0xdada + ETH_P_FCOE = 0x8906 + ETH_P_FIP = 0x8914 + ETH_P_HDLC = 0x19 + ETH_P_IEEE802154 = 0xf6 + ETH_P_IEEEPUP = 0xa00 + ETH_P_IEEEPUPAT = 0xa01 + ETH_P_IP = 0x800 + ETH_P_IPV6 = 0x86dd + ETH_P_IPX = 0x8137 + ETH_P_IRDA = 0x17 + ETH_P_LAT = 0x6004 + ETH_P_LINK_CTL = 0x886c + ETH_P_LOCALTALK = 0x9 + ETH_P_LOOP = 0x60 + ETH_P_LOOPBACK = 0x9000 + ETH_P_MOBITEX = 0x15 + ETH_P_MPLS_MC = 0x8848 + ETH_P_MPLS_UC = 0x8847 + ETH_P_MVRP = 0x88f5 + ETH_P_PAE = 0x888e + ETH_P_PAUSE = 0x8808 + ETH_P_PHONET = 0xf5 + ETH_P_PPPTALK = 0x10 + ETH_P_PPP_DISC = 0x8863 + ETH_P_PPP_MP = 0x8 + ETH_P_PPP_SES = 0x8864 + ETH_P_PRP = 0x88fb + ETH_P_PUP = 0x200 + ETH_P_PUPAT = 0x201 + ETH_P_QINQ1 = 0x9100 + ETH_P_QINQ2 = 0x9200 + ETH_P_QINQ3 = 0x9300 + ETH_P_RARP = 0x8035 + ETH_P_SCA = 0x6007 + ETH_P_SLOW = 0x8809 + ETH_P_SNAP = 0x5 + ETH_P_TDLS = 0x890d + ETH_P_TEB = 0x6558 + ETH_P_TIPC = 0x88ca + ETH_P_TRAILER = 0x1c + ETH_P_TR_802_2 = 0x11 + ETH_P_TSN = 0x22f0 + ETH_P_WAN_PPP = 0x7 + ETH_P_WCCP = 0x883e + ETH_P_X25 = 0x805 + ETH_P_XDSA = 0xf8 + EXTA = 0xe + EXTB = 0xf + EXTPROC = 0x10000 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FF0 = 0x0 + FF1 = 0x8000 + FFDLY = 0x8000 + FLUSHO = 0x1000 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x406 + F_EXLCK = 0x4 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLEASE = 0x401 + F_GETLK = 0x5 + F_GETLK64 = 0x5 + F_GETOWN = 0x9 + F_GETOWN_EX = 0x10 + F_GETPIPE_SZ = 0x408 + F_GETSIG = 0xb + F_LOCK = 0x1 + F_NOTIFY = 0x402 + F_OFD_GETLK = 0x24 + F_OFD_SETLK = 0x25 + F_OFD_SETLKW = 0x26 + F_OK = 0x0 + F_RDLCK = 0x0 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLEASE = 0x400 + F_SETLK = 0x6 + F_SETLK64 = 0x6 + F_SETLKW = 0x7 + F_SETLKW64 = 0x7 + F_SETOWN = 0x8 + F_SETOWN_EX = 0xf + F_SETPIPE_SZ = 0x407 + F_SETSIG = 0xa + F_SHLCK = 0x8 + F_TEST = 0x3 + F_TLOCK = 0x2 + F_ULOCK = 0x0 + F_UNLCK = 0x2 + F_WRLCK = 0x1 + HUPCL = 0x400 + IBSHIFT = 0x10 + ICANON = 0x2 + ICMPV6_FILTER = 0x1 + ICRNL = 0x100 + IEXTEN = 0x8000 + IFA_F_DADFAILED = 0x8 + IFA_F_DEPRECATED = 0x20 + IFA_F_HOMEADDRESS = 0x10 + IFA_F_MANAGETEMPADDR = 0x100 + IFA_F_MCAUTOJOIN = 0x400 + IFA_F_NODAD = 0x2 + IFA_F_NOPREFIXROUTE = 0x200 + IFA_F_OPTIMISTIC = 0x4 + IFA_F_PERMANENT = 0x80 + IFA_F_SECONDARY = 0x1 + IFA_F_STABLE_PRIVACY = 0x800 + IFA_F_TEMPORARY = 0x1 + IFA_F_TENTATIVE = 0x40 + IFA_MAX = 0x8 + IFF_ALLMULTI = 0x200 + IFF_ATTACH_QUEUE = 0x200 + IFF_AUTOMEDIA = 0x4000 + IFF_BROADCAST = 0x2 + IFF_DEBUG = 0x4 + IFF_DETACH_QUEUE = 0x400 + IFF_DORMANT = 0x20000 + IFF_DYNAMIC = 0x8000 + IFF_ECHO = 0x40000 + IFF_LOOPBACK = 0x8 + IFF_LOWER_UP = 0x10000 + IFF_MASTER = 0x400 + IFF_MULTICAST = 0x1000 + IFF_MULTI_QUEUE = 0x100 + IFF_NOARP = 0x80 + IFF_NOFILTER = 0x1000 + IFF_NOTRAILERS = 0x20 + IFF_NO_PI = 0x1000 + IFF_ONE_QUEUE = 0x2000 + IFF_PERSIST = 0x800 + IFF_POINTOPOINT = 0x10 + IFF_PORTSEL = 0x2000 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SLAVE = 0x800 + IFF_TAP = 0x2 + IFF_TUN = 0x1 + IFF_TUN_EXCL = 0x8000 + IFF_UP = 0x1 + IFF_VNET_HDR = 0x4000 + IFF_VOLATILE = 0x70c5a + IFNAMSIZ = 0x10 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_ACCESS = 0x1 + IN_ALL_EVENTS = 0xfff + IN_ATTRIB = 0x4 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLOEXEC = 0x80000 + IN_CLOSE = 0x18 + IN_CLOSE_NOWRITE = 0x10 + IN_CLOSE_WRITE = 0x8 + IN_CREATE = 0x100 + IN_DELETE = 0x200 + IN_DELETE_SELF = 0x400 + IN_DONT_FOLLOW = 0x2000000 + IN_EXCL_UNLINK = 0x4000000 + IN_IGNORED = 0x8000 + IN_ISDIR = 0x40000000 + IN_LOOPBACKNET = 0x7f + IN_MASK_ADD = 0x20000000 + IN_MODIFY = 0x2 + IN_MOVE = 0xc0 + IN_MOVED_FROM = 0x40 + IN_MOVED_TO = 0x80 + IN_MOVE_SELF = 0x800 + IN_NONBLOCK = 0x800 + IN_ONESHOT = 0x80000000 + IN_ONLYDIR = 0x1000000 + IN_OPEN = 0x20 + IN_Q_OVERFLOW = 0x4000 + IN_UNMOUNT = 0x2000 + IPPROTO_AH = 0x33 + IPPROTO_BEETPH = 0x5e + IPPROTO_COMP = 0x6c + IPPROTO_DCCP = 0x21 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_ENCAP = 0x62 + IPPROTO_ESP = 0x32 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GRE = 0x2f + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IGMP = 0x2 + IPPROTO_IP = 0x0 + IPPROTO_IPIP = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_MH = 0x87 + IPPROTO_MPLS = 0x89 + IPPROTO_MTP = 0x5c + IPPROTO_NONE = 0x3b + IPPROTO_PIM = 0x67 + IPPROTO_PUP = 0xc + IPPROTO_RAW = 0xff + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_SCTP = 0x84 + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_UDP = 0x11 + IPPROTO_UDPLITE = 0x88 + IPV6_2292DSTOPTS = 0x4 + IPV6_2292HOPLIMIT = 0x8 + IPV6_2292HOPOPTS = 0x3 + IPV6_2292PKTINFO = 0x2 + IPV6_2292PKTOPTIONS = 0x6 + IPV6_2292RTHDR = 0x5 + IPV6_ADDRFORM = 0x1 + IPV6_ADD_MEMBERSHIP = 0x14 + IPV6_AUTHHDR = 0xa + IPV6_CHECKSUM = 0x7 + IPV6_DONTFRAG = 0x3e + IPV6_DROP_MEMBERSHIP = 0x15 + IPV6_DSTOPTS = 0x3b + IPV6_HOPLIMIT = 0x34 + IPV6_HOPOPTS = 0x36 + IPV6_IPSEC_POLICY = 0x22 + IPV6_JOIN_ANYCAST = 0x1b + IPV6_JOIN_GROUP = 0x14 + IPV6_LEAVE_ANYCAST = 0x1c + IPV6_LEAVE_GROUP = 0x15 + IPV6_MTU = 0x18 + IPV6_MTU_DISCOVER = 0x17 + IPV6_MULTICAST_HOPS = 0x12 + IPV6_MULTICAST_IF = 0x11 + IPV6_MULTICAST_LOOP = 0x13 + IPV6_NEXTHOP = 0x9 + IPV6_PATHMTU = 0x3d + IPV6_PKTINFO = 0x32 + IPV6_PMTUDISC_DO = 0x2 + IPV6_PMTUDISC_DONT = 0x0 + IPV6_PMTUDISC_INTERFACE = 0x4 + IPV6_PMTUDISC_OMIT = 0x5 + IPV6_PMTUDISC_PROBE = 0x3 + IPV6_PMTUDISC_WANT = 0x1 + IPV6_RECVDSTOPTS = 0x3a + IPV6_RECVERR = 0x19 + IPV6_RECVHOPLIMIT = 0x33 + IPV6_RECVHOPOPTS = 0x35 + IPV6_RECVPATHMTU = 0x3c + IPV6_RECVPKTINFO = 0x31 + IPV6_RECVRTHDR = 0x38 + IPV6_RECVTCLASS = 0x42 + IPV6_ROUTER_ALERT = 0x16 + IPV6_RTHDR = 0x39 + IPV6_RTHDRDSTOPTS = 0x37 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_RXDSTOPTS = 0x3b + IPV6_RXHOPOPTS = 0x36 + IPV6_TCLASS = 0x43 + IPV6_UNICAST_HOPS = 0x10 + IPV6_V6ONLY = 0x1a + IPV6_XFRM_POLICY = 0x23 + IP_ADD_MEMBERSHIP = 0x23 + IP_ADD_SOURCE_MEMBERSHIP = 0x27 + IP_BIND_ADDRESS_NO_PORT = 0x18 + IP_BLOCK_SOURCE = 0x26 + IP_CHECKSUM = 0x17 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DROP_MEMBERSHIP = 0x24 + IP_DROP_SOURCE_MEMBERSHIP = 0x28 + IP_FREEBIND = 0xf + IP_HDRINCL = 0x3 + IP_IPSEC_POLICY = 0x10 + IP_MAXPACKET = 0xffff + IP_MAX_MEMBERSHIPS = 0x14 + IP_MF = 0x2000 + IP_MINTTL = 0x15 + IP_MSFILTER = 0x29 + IP_MSS = 0x240 + IP_MTU = 0xe + IP_MTU_DISCOVER = 0xa + IP_MULTICAST_ALL = 0x31 + IP_MULTICAST_IF = 0x20 + IP_MULTICAST_LOOP = 0x22 + IP_MULTICAST_TTL = 0x21 + IP_NODEFRAG = 0x16 + IP_OFFMASK = 0x1fff + IP_OPTIONS = 0x4 + IP_ORIGDSTADDR = 0x14 + IP_PASSSEC = 0x12 + IP_PKTINFO = 0x8 + IP_PKTOPTIONS = 0x9 + IP_PMTUDISC = 0xa + IP_PMTUDISC_DO = 0x2 + IP_PMTUDISC_DONT = 0x0 + IP_PMTUDISC_INTERFACE = 0x4 + IP_PMTUDISC_OMIT = 0x5 + IP_PMTUDISC_PROBE = 0x3 + IP_PMTUDISC_WANT = 0x1 + IP_RECVERR = 0xb + IP_RECVOPTS = 0x6 + IP_RECVORIGDSTADDR = 0x14 + IP_RECVRETOPTS = 0x7 + IP_RECVTOS = 0xd + IP_RECVTTL = 0xc + IP_RETOPTS = 0x7 + IP_RF = 0x8000 + IP_ROUTER_ALERT = 0x5 + IP_TOS = 0x1 + IP_TRANSPARENT = 0x13 + IP_TTL = 0x2 + IP_UNBLOCK_SOURCE = 0x25 + IP_UNICAST_IF = 0x32 + IP_XFRM_POLICY = 0x11 + ISIG = 0x1 + ISTRIP = 0x20 + IUCLC = 0x200 + IUTF8 = 0x4000 + IXANY = 0x800 + IXOFF = 0x1000 + IXON = 0x400 + LINUX_REBOOT_CMD_CAD_OFF = 0x0 + LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef + LINUX_REBOOT_CMD_HALT = 0xcdef0123 + LINUX_REBOOT_CMD_KEXEC = 0x45584543 + LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc + LINUX_REBOOT_CMD_RESTART = 0x1234567 + LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4 + LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2 + LINUX_REBOOT_MAGIC1 = 0xfee1dead + LINUX_REBOOT_MAGIC2 = 0x28121969 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_DODUMP = 0x11 + MADV_DOFORK = 0xb + MADV_DONTDUMP = 0x10 + MADV_DONTFORK = 0xa + MADV_DONTNEED = 0x4 + MADV_HUGEPAGE = 0xe + MADV_HWPOISON = 0x64 + MADV_MERGEABLE = 0xc + MADV_NOHUGEPAGE = 0xf + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_REMOVE = 0x9 + MADV_SEQUENTIAL = 0x2 + MADV_UNMERGEABLE = 0xd + MADV_WILLNEED = 0x3 + MAP_ANON = 0x20 + MAP_ANONYMOUS = 0x20 + MAP_DENYWRITE = 0x800 + MAP_EXECUTABLE = 0x1000 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_GROWSDOWN = 0x100 + MAP_HUGETLB = 0x40000 + MAP_HUGE_MASK = 0x3f + MAP_HUGE_SHIFT = 0x1a + MAP_LOCKED = 0x2000 + MAP_NONBLOCK = 0x10000 + MAP_NORESERVE = 0x4000 + MAP_POPULATE = 0x8000 + MAP_PRIVATE = 0x2 + MAP_SHARED = 0x1 + MAP_STACK = 0x20000 + MAP_TYPE = 0xf + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MCL_ONFAULT = 0x4 + MNT_DETACH = 0x2 + MNT_EXPIRE = 0x4 + MNT_FORCE = 0x1 + MSG_CMSG_CLOEXEC = 0x40000000 + MSG_CONFIRM = 0x800 + MSG_CTRUNC = 0x8 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x40 + MSG_EOR = 0x80 + MSG_ERRQUEUE = 0x2000 + MSG_FASTOPEN = 0x20000000 + MSG_FIN = 0x200 + MSG_MORE = 0x8000 + MSG_NOSIGNAL = 0x4000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_PROXY = 0x10 + MSG_RST = 0x1000 + MSG_SYN = 0x400 + MSG_TRUNC = 0x20 + MSG_TRYHARD = 0x4 + MSG_WAITALL = 0x100 + MSG_WAITFORONE = 0x10000 + MS_ACTIVE = 0x40000000 + MS_ASYNC = 0x1 + MS_BIND = 0x1000 + MS_DIRSYNC = 0x80 + MS_INVALIDATE = 0x2 + MS_I_VERSION = 0x800000 + MS_KERNMOUNT = 0x400000 + MS_LAZYTIME = 0x2000000 + MS_MANDLOCK = 0x40 + MS_MGC_MSK = 0xffff0000 + MS_MGC_VAL = 0xc0ed0000 + MS_MOVE = 0x2000 + MS_NOATIME = 0x400 + MS_NODEV = 0x4 + MS_NODIRATIME = 0x800 + MS_NOEXEC = 0x8 + MS_NOSUID = 0x2 + MS_NOUSER = -0x80000000 + MS_POSIXACL = 0x10000 + MS_PRIVATE = 0x40000 + MS_RDONLY = 0x1 + MS_REC = 0x4000 + MS_RELATIME = 0x200000 + MS_REMOUNT = 0x20 + MS_RMT_MASK = 0x2800051 + MS_SHARED = 0x100000 + MS_SILENT = 0x8000 + MS_SLAVE = 0x80000 + MS_STRICTATIME = 0x1000000 + MS_SYNC = 0x4 + MS_SYNCHRONOUS = 0x10 + MS_UNBINDABLE = 0x20000 + NAME_MAX = 0xff + NETLINK_ADD_MEMBERSHIP = 0x1 + NETLINK_AUDIT = 0x9 + NETLINK_BROADCAST_ERROR = 0x4 + NETLINK_CAP_ACK = 0xa + NETLINK_CONNECTOR = 0xb + NETLINK_CRYPTO = 0x15 + NETLINK_DNRTMSG = 0xe + NETLINK_DROP_MEMBERSHIP = 0x2 + NETLINK_ECRYPTFS = 0x13 + NETLINK_FIB_LOOKUP = 0xa + NETLINK_FIREWALL = 0x3 + NETLINK_GENERIC = 0x10 + NETLINK_INET_DIAG = 0x4 + NETLINK_IP6_FW = 0xd + NETLINK_ISCSI = 0x8 + NETLINK_KOBJECT_UEVENT = 0xf + NETLINK_LISTEN_ALL_NSID = 0x8 + NETLINK_LIST_MEMBERSHIPS = 0x9 + NETLINK_NETFILTER = 0xc + NETLINK_NFLOG = 0x5 + NETLINK_NO_ENOBUFS = 0x5 + NETLINK_PKTINFO = 0x3 + NETLINK_RDMA = 0x14 + NETLINK_ROUTE = 0x0 + NETLINK_RX_RING = 0x6 + NETLINK_SCSITRANSPORT = 0x12 + NETLINK_SELINUX = 0x7 + NETLINK_SOCK_DIAG = 0x4 + NETLINK_TX_RING = 0x7 + NETLINK_UNUSED = 0x1 + NETLINK_USERSOCK = 0x2 + NETLINK_XFRM = 0x6 + NL0 = 0x0 + NL1 = 0x100 + NLA_ALIGNTO = 0x4 + NLA_F_NESTED = 0x8000 + NLA_F_NET_BYTEORDER = 0x4000 + NLA_HDRLEN = 0x4 + NLDLY = 0x100 + NLMSG_ALIGNTO = 0x4 + NLMSG_DONE = 0x3 + NLMSG_ERROR = 0x2 + NLMSG_HDRLEN = 0x10 + NLMSG_MIN_TYPE = 0x10 + NLMSG_NOOP = 0x1 + NLMSG_OVERRUN = 0x4 + NLM_F_ACK = 0x4 + NLM_F_APPEND = 0x800 + NLM_F_ATOMIC = 0x400 + NLM_F_CREATE = 0x400 + NLM_F_DUMP = 0x300 + NLM_F_DUMP_FILTERED = 0x20 + NLM_F_DUMP_INTR = 0x10 + NLM_F_ECHO = 0x8 + NLM_F_EXCL = 0x200 + NLM_F_MATCH = 0x200 + NLM_F_MULTI = 0x2 + NLM_F_REPLACE = 0x100 + NLM_F_REQUEST = 0x1 + NLM_F_ROOT = 0x100 + NOFLSH = 0x80 + OCRNL = 0x8 + OFDEL = 0x80 + OFILL = 0x40 + OLCUC = 0x2 + ONLCR = 0x4 + ONLRET = 0x20 + ONOCR = 0x10 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_APPEND = 0x400 + O_ASYNC = 0x2000 + O_CLOEXEC = 0x80000 + O_CREAT = 0x40 + O_DIRECT = 0x4000 + O_DIRECTORY = 0x10000 + O_DSYNC = 0x1000 + O_EXCL = 0x80 + O_FSYNC = 0x101000 + O_LARGEFILE = 0x0 + O_NDELAY = 0x800 + O_NOATIME = 0x40000 + O_NOCTTY = 0x100 + O_NOFOLLOW = 0x20000 + O_NONBLOCK = 0x800 + O_PATH = 0x200000 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_RSYNC = 0x101000 + O_SYNC = 0x101000 + O_TMPFILE = 0x410000 + O_TRUNC = 0x200 + O_WRONLY = 0x1 + PACKET_ADD_MEMBERSHIP = 0x1 + PACKET_AUXDATA = 0x8 + PACKET_BROADCAST = 0x1 + PACKET_COPY_THRESH = 0x7 + PACKET_DROP_MEMBERSHIP = 0x2 + PACKET_FANOUT = 0x12 + PACKET_FANOUT_CBPF = 0x6 + PACKET_FANOUT_CPU = 0x2 + PACKET_FANOUT_DATA = 0x16 + PACKET_FANOUT_EBPF = 0x7 + PACKET_FANOUT_FLAG_DEFRAG = 0x8000 + PACKET_FANOUT_FLAG_ROLLOVER = 0x1000 + PACKET_FANOUT_HASH = 0x0 + PACKET_FANOUT_LB = 0x1 + PACKET_FANOUT_QM = 0x5 + PACKET_FANOUT_RND = 0x4 + PACKET_FANOUT_ROLLOVER = 0x3 + PACKET_FASTROUTE = 0x6 + PACKET_HDRLEN = 0xb + PACKET_HOST = 0x0 + PACKET_KERNEL = 0x7 + PACKET_LOOPBACK = 0x5 + PACKET_LOSS = 0xe + PACKET_MR_ALLMULTI = 0x2 + PACKET_MR_MULTICAST = 0x0 + PACKET_MR_PROMISC = 0x1 + PACKET_MR_UNICAST = 0x3 + PACKET_MULTICAST = 0x2 + PACKET_ORIGDEV = 0x9 + PACKET_OTHERHOST = 0x3 + PACKET_OUTGOING = 0x4 + PACKET_QDISC_BYPASS = 0x14 + PACKET_RECV_OUTPUT = 0x3 + PACKET_RESERVE = 0xc + PACKET_ROLLOVER_STATS = 0x15 + PACKET_RX_RING = 0x5 + PACKET_STATISTICS = 0x6 + PACKET_TIMESTAMP = 0x11 + PACKET_TX_HAS_OFF = 0x13 + PACKET_TX_RING = 0xd + PACKET_TX_TIMESTAMP = 0x10 + PACKET_USER = 0x6 + PACKET_VERSION = 0xa + PACKET_VNET_HDR = 0xf + PARENB = 0x100 + PARITY_CRC16_PR0 = 0x2 + PARITY_CRC16_PR0_CCITT = 0x4 + PARITY_CRC16_PR1 = 0x3 + PARITY_CRC16_PR1_CCITT = 0x5 + PARITY_CRC32_PR0_CCITT = 0x6 + PARITY_CRC32_PR1_CCITT = 0x7 + PARITY_DEFAULT = 0x0 + PARITY_NONE = 0x1 + PARMRK = 0x8 + PARODD = 0x200 + PENDIN = 0x4000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_GROWSDOWN = 0x1000000 + PROT_GROWSUP = 0x2000000 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + PR_CAPBSET_DROP = 0x18 + PR_CAPBSET_READ = 0x17 + PR_CAP_AMBIENT = 0x2f + PR_CAP_AMBIENT_CLEAR_ALL = 0x4 + PR_CAP_AMBIENT_IS_SET = 0x1 + PR_CAP_AMBIENT_LOWER = 0x3 + PR_CAP_AMBIENT_RAISE = 0x2 + PR_ENDIAN_BIG = 0x0 + PR_ENDIAN_LITTLE = 0x1 + PR_ENDIAN_PPC_LITTLE = 0x2 + PR_FPEMU_NOPRINT = 0x1 + PR_FPEMU_SIGFPE = 0x2 + PR_FP_EXC_ASYNC = 0x2 + PR_FP_EXC_DISABLED = 0x0 + PR_FP_EXC_DIV = 0x10000 + PR_FP_EXC_INV = 0x100000 + PR_FP_EXC_NONRECOV = 0x1 + PR_FP_EXC_OVF = 0x20000 + PR_FP_EXC_PRECISE = 0x3 + PR_FP_EXC_RES = 0x80000 + PR_FP_EXC_SW_ENABLE = 0x80 + PR_FP_EXC_UND = 0x40000 + PR_FP_MODE_FR = 0x1 + PR_FP_MODE_FRE = 0x2 + PR_GET_CHILD_SUBREAPER = 0x25 + PR_GET_DUMPABLE = 0x3 + PR_GET_ENDIAN = 0x13 + PR_GET_FPEMU = 0x9 + PR_GET_FPEXC = 0xb + PR_GET_FP_MODE = 0x2e + PR_GET_KEEPCAPS = 0x7 + PR_GET_NAME = 0x10 + PR_GET_NO_NEW_PRIVS = 0x27 + PR_GET_PDEATHSIG = 0x2 + PR_GET_SECCOMP = 0x15 + PR_GET_SECUREBITS = 0x1b + PR_GET_THP_DISABLE = 0x2a + PR_GET_TID_ADDRESS = 0x28 + PR_GET_TIMERSLACK = 0x1e + PR_GET_TIMING = 0xd + PR_GET_TSC = 0x19 + PR_GET_UNALIGN = 0x5 + PR_MCE_KILL = 0x21 + PR_MCE_KILL_CLEAR = 0x0 + PR_MCE_KILL_DEFAULT = 0x2 + PR_MCE_KILL_EARLY = 0x1 + PR_MCE_KILL_GET = 0x22 + PR_MCE_KILL_LATE = 0x0 + PR_MCE_KILL_SET = 0x1 + PR_MPX_DISABLE_MANAGEMENT = 0x2c + PR_MPX_ENABLE_MANAGEMENT = 0x2b + PR_SET_CHILD_SUBREAPER = 0x24 + PR_SET_DUMPABLE = 0x4 + PR_SET_ENDIAN = 0x14 + PR_SET_FPEMU = 0xa + PR_SET_FPEXC = 0xc + PR_SET_FP_MODE = 0x2d + PR_SET_KEEPCAPS = 0x8 + PR_SET_MM = 0x23 + PR_SET_MM_ARG_END = 0x9 + PR_SET_MM_ARG_START = 0x8 + PR_SET_MM_AUXV = 0xc + PR_SET_MM_BRK = 0x7 + PR_SET_MM_END_CODE = 0x2 + PR_SET_MM_END_DATA = 0x4 + PR_SET_MM_ENV_END = 0xb + PR_SET_MM_ENV_START = 0xa + PR_SET_MM_EXE_FILE = 0xd + PR_SET_MM_MAP = 0xe + PR_SET_MM_MAP_SIZE = 0xf + PR_SET_MM_START_BRK = 0x6 + PR_SET_MM_START_CODE = 0x1 + PR_SET_MM_START_DATA = 0x3 + PR_SET_MM_START_STACK = 0x5 + PR_SET_NAME = 0xf + PR_SET_NO_NEW_PRIVS = 0x26 + PR_SET_PDEATHSIG = 0x1 + PR_SET_PTRACER = 0x59616d61 + PR_SET_PTRACER_ANY = -0x1 + PR_SET_SECCOMP = 0x16 + PR_SET_SECUREBITS = 0x1c + PR_SET_THP_DISABLE = 0x29 + PR_SET_TIMERSLACK = 0x1d + PR_SET_TIMING = 0xe + PR_SET_TSC = 0x1a + PR_SET_UNALIGN = 0x6 + PR_TASK_PERF_EVENTS_DISABLE = 0x1f + PR_TASK_PERF_EVENTS_ENABLE = 0x20 + PR_TIMING_STATISTICAL = 0x0 + PR_TIMING_TIMESTAMP = 0x1 + PR_TSC_ENABLE = 0x1 + PR_TSC_SIGSEGV = 0x2 + PR_UNALIGN_NOPRINT = 0x1 + PR_UNALIGN_SIGBUS = 0x2 + PTRACE_ATTACH = 0x10 + PTRACE_CONT = 0x7 + PTRACE_DETACH = 0x11 + PTRACE_DISABLE_TE = 0x5010 + PTRACE_ENABLE_TE = 0x5009 + PTRACE_EVENT_CLONE = 0x3 + PTRACE_EVENT_EXEC = 0x4 + PTRACE_EVENT_EXIT = 0x6 + PTRACE_EVENT_FORK = 0x1 + PTRACE_EVENT_SECCOMP = 0x7 + PTRACE_EVENT_STOP = 0x80 + PTRACE_EVENT_VFORK = 0x2 + PTRACE_EVENT_VFORK_DONE = 0x5 + PTRACE_GETEVENTMSG = 0x4201 + PTRACE_GETREGS = 0xc + PTRACE_GETREGSET = 0x4204 + PTRACE_GETSIGINFO = 0x4202 + PTRACE_GETSIGMASK = 0x420a + PTRACE_GET_LAST_BREAK = 0x5006 + PTRACE_INTERRUPT = 0x4207 + PTRACE_KILL = 0x8 + PTRACE_LISTEN = 0x4208 + PTRACE_OLDSETOPTIONS = 0x15 + PTRACE_O_EXITKILL = 0x100000 + PTRACE_O_MASK = 0x3000ff + PTRACE_O_SUSPEND_SECCOMP = 0x200000 + PTRACE_O_TRACECLONE = 0x8 + PTRACE_O_TRACEEXEC = 0x10 + PTRACE_O_TRACEEXIT = 0x40 + PTRACE_O_TRACEFORK = 0x2 + PTRACE_O_TRACESECCOMP = 0x80 + PTRACE_O_TRACESYSGOOD = 0x1 + PTRACE_O_TRACEVFORK = 0x4 + PTRACE_O_TRACEVFORKDONE = 0x20 + PTRACE_PEEKDATA = 0x2 + PTRACE_PEEKDATA_AREA = 0x5003 + PTRACE_PEEKSIGINFO = 0x4209 + PTRACE_PEEKSIGINFO_SHARED = 0x1 + PTRACE_PEEKTEXT = 0x1 + PTRACE_PEEKTEXT_AREA = 0x5002 + PTRACE_PEEKUSR = 0x3 + PTRACE_PEEKUSR_AREA = 0x5000 + PTRACE_PEEK_SYSTEM_CALL = 0x5007 + PTRACE_POKEDATA = 0x5 + PTRACE_POKEDATA_AREA = 0x5005 + PTRACE_POKETEXT = 0x4 + PTRACE_POKETEXT_AREA = 0x5004 + PTRACE_POKEUSR = 0x6 + PTRACE_POKEUSR_AREA = 0x5001 + PTRACE_POKE_SYSTEM_CALL = 0x5008 + PTRACE_PROT = 0x15 + PTRACE_SECCOMP_GET_FILTER = 0x420c + PTRACE_SEIZE = 0x4206 + PTRACE_SETOPTIONS = 0x4200 + PTRACE_SETREGS = 0xd + PTRACE_SETREGSET = 0x4205 + PTRACE_SETSIGINFO = 0x4203 + PTRACE_SETSIGMASK = 0x420b + PTRACE_SINGLEBLOCK = 0xc + PTRACE_SINGLESTEP = 0x9 + PTRACE_SYSCALL = 0x18 + PTRACE_TE_ABORT_RAND = 0x5011 + PTRACE_TRACEME = 0x0 + PT_ACR0 = 0x90 + PT_ACR1 = 0x94 + PT_ACR10 = 0xb8 + PT_ACR11 = 0xbc + PT_ACR12 = 0xc0 + PT_ACR13 = 0xc4 + PT_ACR14 = 0xc8 + PT_ACR15 = 0xcc + PT_ACR2 = 0x98 + PT_ACR3 = 0x9c + PT_ACR4 = 0xa0 + PT_ACR5 = 0xa4 + PT_ACR6 = 0xa8 + PT_ACR7 = 0xac + PT_ACR8 = 0xb0 + PT_ACR9 = 0xb4 + PT_CR_10 = 0x168 + PT_CR_11 = 0x170 + PT_CR_9 = 0x160 + PT_ENDREGS = 0x1af + PT_FPC = 0xd8 + PT_FPR0 = 0xe0 + PT_FPR1 = 0xe8 + PT_FPR10 = 0x130 + PT_FPR11 = 0x138 + PT_FPR12 = 0x140 + PT_FPR13 = 0x148 + PT_FPR14 = 0x150 + PT_FPR15 = 0x158 + PT_FPR2 = 0xf0 + PT_FPR3 = 0xf8 + PT_FPR4 = 0x100 + PT_FPR5 = 0x108 + PT_FPR6 = 0x110 + PT_FPR7 = 0x118 + PT_FPR8 = 0x120 + PT_FPR9 = 0x128 + PT_GPR0 = 0x10 + PT_GPR1 = 0x18 + PT_GPR10 = 0x60 + PT_GPR11 = 0x68 + PT_GPR12 = 0x70 + PT_GPR13 = 0x78 + PT_GPR14 = 0x80 + PT_GPR15 = 0x88 + PT_GPR2 = 0x20 + PT_GPR3 = 0x28 + PT_GPR4 = 0x30 + PT_GPR5 = 0x38 + PT_GPR6 = 0x40 + PT_GPR7 = 0x48 + PT_GPR8 = 0x50 + PT_GPR9 = 0x58 + PT_IEEE_IP = 0x1a8 + PT_LASTOFF = 0x1a8 + PT_ORIGGPR2 = 0xd0 + PT_PSWADDR = 0x8 + PT_PSWMASK = 0x0 + RLIMIT_AS = 0x9 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x7 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = -0x1 + RTAX_ADVMSS = 0x8 + RTAX_CC_ALGO = 0x10 + RTAX_CWND = 0x7 + RTAX_FEATURES = 0xc + RTAX_FEATURE_ALLFRAG = 0x8 + RTAX_FEATURE_ECN = 0x1 + RTAX_FEATURE_MASK = 0xf + RTAX_FEATURE_SACK = 0x2 + RTAX_FEATURE_TIMESTAMP = 0x4 + RTAX_HOPLIMIT = 0xa + RTAX_INITCWND = 0xb + RTAX_INITRWND = 0xe + RTAX_LOCK = 0x1 + RTAX_MAX = 0x10 + RTAX_MTU = 0x2 + RTAX_QUICKACK = 0xf + RTAX_REORDERING = 0x9 + RTAX_RTO_MIN = 0xd + RTAX_RTT = 0x4 + RTAX_RTTVAR = 0x5 + RTAX_SSTHRESH = 0x6 + RTAX_UNSPEC = 0x0 + RTAX_WINDOW = 0x3 + RTA_ALIGNTO = 0x4 + RTA_MAX = 0x16 + RTCF_DIRECTSRC = 0x4000000 + RTCF_DOREDIRECT = 0x1000000 + RTCF_LOG = 0x2000000 + RTCF_MASQ = 0x400000 + RTCF_NAT = 0x800000 + RTCF_VALVE = 0x200000 + RTF_ADDRCLASSMASK = 0xf8000000 + RTF_ADDRCONF = 0x40000 + RTF_ALLONLINK = 0x20000 + RTF_BROADCAST = 0x10000000 + RTF_CACHE = 0x1000000 + RTF_DEFAULT = 0x10000 + RTF_DYNAMIC = 0x10 + RTF_FLOW = 0x2000000 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_INTERFACE = 0x40000000 + RTF_IRTT = 0x100 + RTF_LINKRT = 0x100000 + RTF_LOCAL = 0x80000000 + RTF_MODIFIED = 0x20 + RTF_MSS = 0x40 + RTF_MTU = 0x40 + RTF_MULTICAST = 0x20000000 + RTF_NAT = 0x8000000 + RTF_NOFORWARD = 0x1000 + RTF_NONEXTHOP = 0x200000 + RTF_NOPMTUDISC = 0x4000 + RTF_POLICY = 0x4000000 + RTF_REINSTATE = 0x8 + RTF_REJECT = 0x200 + RTF_STATIC = 0x400 + RTF_THROW = 0x2000 + RTF_UP = 0x1 + RTF_WINDOW = 0x80 + RTF_XRESOLVE = 0x800 + RTM_BASE = 0x10 + RTM_DELACTION = 0x31 + RTM_DELADDR = 0x15 + RTM_DELADDRLABEL = 0x49 + RTM_DELLINK = 0x11 + RTM_DELMDB = 0x55 + RTM_DELNEIGH = 0x1d + RTM_DELNSID = 0x59 + RTM_DELQDISC = 0x25 + RTM_DELROUTE = 0x19 + RTM_DELRULE = 0x21 + RTM_DELTCLASS = 0x29 + RTM_DELTFILTER = 0x2d + RTM_F_CLONED = 0x200 + RTM_F_EQUALIZE = 0x400 + RTM_F_LOOKUP_TABLE = 0x1000 + RTM_F_NOTIFY = 0x100 + RTM_F_PREFIX = 0x800 + RTM_GETACTION = 0x32 + RTM_GETADDR = 0x16 + RTM_GETADDRLABEL = 0x4a + RTM_GETANYCAST = 0x3e + RTM_GETDCB = 0x4e + RTM_GETLINK = 0x12 + RTM_GETMDB = 0x56 + RTM_GETMULTICAST = 0x3a + RTM_GETNEIGH = 0x1e + RTM_GETNEIGHTBL = 0x42 + RTM_GETNETCONF = 0x52 + RTM_GETNSID = 0x5a + RTM_GETQDISC = 0x26 + RTM_GETROUTE = 0x1a + RTM_GETRULE = 0x22 + RTM_GETTCLASS = 0x2a + RTM_GETTFILTER = 0x2e + RTM_MAX = 0x5b + RTM_NEWACTION = 0x30 + RTM_NEWADDR = 0x14 + RTM_NEWADDRLABEL = 0x48 + RTM_NEWLINK = 0x10 + RTM_NEWMDB = 0x54 + RTM_NEWNDUSEROPT = 0x44 + RTM_NEWNEIGH = 0x1c + RTM_NEWNEIGHTBL = 0x40 + RTM_NEWNETCONF = 0x50 + RTM_NEWNSID = 0x58 + RTM_NEWPREFIX = 0x34 + RTM_NEWQDISC = 0x24 + RTM_NEWROUTE = 0x18 + RTM_NEWRULE = 0x20 + RTM_NEWTCLASS = 0x28 + RTM_NEWTFILTER = 0x2c + RTM_NR_FAMILIES = 0x13 + RTM_NR_MSGTYPES = 0x4c + RTM_SETDCB = 0x4f + RTM_SETLINK = 0x13 + RTM_SETNEIGHTBL = 0x43 + RTNH_ALIGNTO = 0x4 + RTNH_COMPARE_MASK = 0x11 + RTNH_F_DEAD = 0x1 + RTNH_F_LINKDOWN = 0x10 + RTNH_F_OFFLOAD = 0x8 + RTNH_F_ONLINK = 0x4 + RTNH_F_PERVASIVE = 0x2 + RTN_MAX = 0xb + RTPROT_BABEL = 0x2a + RTPROT_BIRD = 0xc + RTPROT_BOOT = 0x3 + RTPROT_DHCP = 0x10 + RTPROT_DNROUTED = 0xd + RTPROT_GATED = 0x8 + RTPROT_KERNEL = 0x2 + RTPROT_MROUTED = 0x11 + RTPROT_MRT = 0xa + RTPROT_NTK = 0xf + RTPROT_RA = 0x9 + RTPROT_REDIRECT = 0x1 + RTPROT_STATIC = 0x4 + RTPROT_UNSPEC = 0x0 + RTPROT_XORP = 0xe + RTPROT_ZEBRA = 0xb + RT_CLASS_DEFAULT = 0xfd + RT_CLASS_LOCAL = 0xff + RT_CLASS_MAIN = 0xfe + RT_CLASS_MAX = 0xff + RT_CLASS_UNSPEC = 0x0 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + RUSAGE_THREAD = 0x1 + SCM_CREDENTIALS = 0x2 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x1d + SCM_TIMESTAMPING = 0x25 + SCM_TIMESTAMPNS = 0x23 + SCM_WIFI_STATUS = 0x29 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDDLCI = 0x8980 + SIOCADDMULTI = 0x8931 + SIOCADDRT = 0x890b + SIOCATMARK = 0x8905 + SIOCDARP = 0x8953 + SIOCDELDLCI = 0x8981 + SIOCDELMULTI = 0x8932 + SIOCDELRT = 0x890c + SIOCDEVPRIVATE = 0x89f0 + SIOCDIFADDR = 0x8936 + SIOCDRARP = 0x8960 + SIOCGARP = 0x8954 + SIOCGIFADDR = 0x8915 + SIOCGIFBR = 0x8940 + SIOCGIFBRDADDR = 0x8919 + SIOCGIFCONF = 0x8912 + SIOCGIFCOUNT = 0x8938 + SIOCGIFDSTADDR = 0x8917 + SIOCGIFENCAP = 0x8925 + SIOCGIFFLAGS = 0x8913 + SIOCGIFHWADDR = 0x8927 + SIOCGIFINDEX = 0x8933 + SIOCGIFMAP = 0x8970 + SIOCGIFMEM = 0x891f + SIOCGIFMETRIC = 0x891d + SIOCGIFMTU = 0x8921 + SIOCGIFNAME = 0x8910 + SIOCGIFNETMASK = 0x891b + SIOCGIFPFLAGS = 0x8935 + SIOCGIFSLAVE = 0x8929 + SIOCGIFTXQLEN = 0x8942 + SIOCGPGRP = 0x8904 + SIOCGRARP = 0x8961 + SIOCGSTAMP = 0x8906 + SIOCGSTAMPNS = 0x8907 + SIOCPROTOPRIVATE = 0x89e0 + SIOCRTMSG = 0x890d + SIOCSARP = 0x8955 + SIOCSIFADDR = 0x8916 + SIOCSIFBR = 0x8941 + SIOCSIFBRDADDR = 0x891a + SIOCSIFDSTADDR = 0x8918 + SIOCSIFENCAP = 0x8926 + SIOCSIFFLAGS = 0x8914 + SIOCSIFHWADDR = 0x8924 + SIOCSIFHWBROADCAST = 0x8937 + SIOCSIFLINK = 0x8911 + SIOCSIFMAP = 0x8971 + SIOCSIFMEM = 0x8920 + SIOCSIFMETRIC = 0x891e + SIOCSIFMTU = 0x8922 + SIOCSIFNAME = 0x8923 + SIOCSIFNETMASK = 0x891c + SIOCSIFPFLAGS = 0x8934 + SIOCSIFSLAVE = 0x8930 + SIOCSIFTXQLEN = 0x8943 + SIOCSPGRP = 0x8902 + SIOCSRARP = 0x8962 + SOCK_CLOEXEC = 0x80000 + SOCK_DCCP = 0x6 + SOCK_DGRAM = 0x2 + SOCK_NONBLOCK = 0x800 + SOCK_PACKET = 0xa + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_AAL = 0x109 + SOL_ATM = 0x108 + SOL_DECNET = 0x105 + SOL_ICMPV6 = 0x3a + SOL_IP = 0x0 + SOL_IPV6 = 0x29 + SOL_IRDA = 0x10a + SOL_PACKET = 0x107 + SOL_RAW = 0xff + SOL_SOCKET = 0x1 + SOL_TCP = 0x6 + SOL_X25 = 0x106 + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x1e + SO_ATTACH_BPF = 0x32 + SO_ATTACH_FILTER = 0x1a + SO_BINDTODEVICE = 0x19 + SO_BPF_EXTENSIONS = 0x30 + SO_BROADCAST = 0x6 + SO_BSDCOMPAT = 0xe + SO_BUSY_POLL = 0x2e + SO_DEBUG = 0x1 + SO_DETACH_BPF = 0x1b + SO_DETACH_FILTER = 0x1b + SO_DOMAIN = 0x27 + SO_DONTROUTE = 0x5 + SO_ERROR = 0x4 + SO_GET_FILTER = 0x1a + SO_INCOMING_CPU = 0x31 + SO_KEEPALIVE = 0x9 + SO_LINGER = 0xd + SO_LOCK_FILTER = 0x2c + SO_MARK = 0x24 + SO_MAX_PACING_RATE = 0x2f + SO_NOFCS = 0x2b + SO_NO_CHECK = 0xb + SO_OOBINLINE = 0xa + SO_PASSCRED = 0x10 + SO_PASSSEC = 0x22 + SO_PEEK_OFF = 0x2a + SO_PEERCRED = 0x11 + SO_PEERNAME = 0x1c + SO_PEERSEC = 0x1f + SO_PRIORITY = 0xc + SO_PROTOCOL = 0x26 + SO_RCVBUF = 0x8 + SO_RCVBUFFORCE = 0x21 + SO_RCVLOWAT = 0x12 + SO_RCVTIMEO = 0x14 + SO_REUSEADDR = 0x2 + SO_REUSEPORT = 0xf + SO_RXQ_OVFL = 0x28 + SO_SECURITY_AUTHENTICATION = 0x16 + SO_SECURITY_ENCRYPTION_NETWORK = 0x18 + SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17 + SO_SELECT_ERR_QUEUE = 0x2d + SO_SNDBUF = 0x7 + SO_SNDBUFFORCE = 0x20 + SO_SNDLOWAT = 0x13 + SO_SNDTIMEO = 0x15 + SO_TIMESTAMP = 0x1d + SO_TIMESTAMPING = 0x25 + SO_TIMESTAMPNS = 0x23 + SO_TYPE = 0x3 + SO_WIFI_STATUS = 0x29 + S_BLKSIZE = 0x200 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + TAB0 = 0x0 + TAB1 = 0x800 + TAB2 = 0x1000 + TAB3 = 0x1800 + TABDLY = 0x1800 + TCFLSH = 0x540b + TCGETA = 0x5405 + TCGETS = 0x5401 + TCGETS2 = 0x802c542a + TCGETX = 0x5432 + TCIFLUSH = 0x0 + TCIOFF = 0x2 + TCIOFLUSH = 0x2 + TCION = 0x3 + TCOFLUSH = 0x1 + TCOOFF = 0x0 + TCOON = 0x1 + TCP_CC_INFO = 0x1a + TCP_CONGESTION = 0xd + TCP_COOKIE_IN_ALWAYS = 0x1 + TCP_COOKIE_MAX = 0x10 + TCP_COOKIE_MIN = 0x8 + TCP_COOKIE_OUT_NEVER = 0x2 + TCP_COOKIE_PAIR_SIZE = 0x20 + TCP_COOKIE_TRANSACTIONS = 0xf + TCP_CORK = 0x3 + TCP_DEFER_ACCEPT = 0x9 + TCP_FASTOPEN = 0x17 + TCP_INFO = 0xb + TCP_KEEPCNT = 0x6 + TCP_KEEPIDLE = 0x4 + TCP_KEEPINTVL = 0x5 + TCP_LINGER2 = 0x8 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0xe + TCP_MD5SIG_MAXKEYLEN = 0x50 + TCP_MSS = 0x200 + TCP_MSS_DEFAULT = 0x218 + TCP_MSS_DESIRED = 0x4c4 + TCP_NODELAY = 0x1 + TCP_NOTSENT_LOWAT = 0x19 + TCP_QUEUE_SEQ = 0x15 + TCP_QUICKACK = 0xc + TCP_REPAIR = 0x13 + TCP_REPAIR_OPTIONS = 0x16 + TCP_REPAIR_QUEUE = 0x14 + TCP_SAVED_SYN = 0x1c + TCP_SAVE_SYN = 0x1b + TCP_SYNCNT = 0x7 + TCP_S_DATA_IN = 0x4 + TCP_S_DATA_OUT = 0x8 + TCP_THIN_DUPACK = 0x11 + TCP_THIN_LINEAR_TIMEOUTS = 0x10 + TCP_TIMESTAMP = 0x18 + TCP_USER_TIMEOUT = 0x12 + TCP_WINDOW_CLAMP = 0xa + TCSAFLUSH = 0x2 + TCSBRK = 0x5409 + TCSBRKP = 0x5425 + TCSETA = 0x5406 + TCSETAF = 0x5408 + TCSETAW = 0x5407 + TCSETS = 0x5402 + TCSETS2 = 0x402c542b + TCSETSF = 0x5404 + TCSETSF2 = 0x402c542d + TCSETSW = 0x5403 + TCSETSW2 = 0x402c542c + TCSETX = 0x5433 + TCSETXF = 0x5434 + TCSETXW = 0x5435 + TCXONC = 0x540a + TIOCCBRK = 0x5428 + TIOCCONS = 0x541d + TIOCEXCL = 0x540c + TIOCGDEV = 0x80045432 + TIOCGETD = 0x5424 + TIOCGEXCL = 0x80045440 + TIOCGICOUNT = 0x545d + TIOCGLCKTRMIOS = 0x5456 + TIOCGPGRP = 0x540f + TIOCGPKT = 0x80045438 + TIOCGPTLCK = 0x80045439 + TIOCGPTN = 0x80045430 + TIOCGRS485 = 0x542e + TIOCGSERIAL = 0x541e + TIOCGSID = 0x5429 + TIOCGSOFTCAR = 0x5419 + TIOCGWINSZ = 0x5413 + TIOCINQ = 0x541b + TIOCLINUX = 0x541c + TIOCMBIC = 0x5417 + TIOCMBIS = 0x5416 + TIOCMGET = 0x5415 + TIOCMIWAIT = 0x545c + TIOCMSET = 0x5418 + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x5422 + TIOCNXCL = 0x540d + TIOCOUTQ = 0x5411 + TIOCPKT = 0x5420 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCSBRK = 0x5427 + TIOCSCTTY = 0x540e + TIOCSERCONFIG = 0x5453 + TIOCSERGETLSR = 0x5459 + TIOCSERGETMULTI = 0x545a + TIOCSERGSTRUCT = 0x5458 + TIOCSERGWILD = 0x5454 + TIOCSERSETMULTI = 0x545b + TIOCSERSWILD = 0x5455 + TIOCSER_TEMT = 0x1 + TIOCSETD = 0x5423 + TIOCSIG = 0x40045436 + TIOCSLCKTRMIOS = 0x5457 + TIOCSPGRP = 0x5410 + TIOCSPTLCK = 0x40045431 + TIOCSRS485 = 0x542f + TIOCSSERIAL = 0x541f + TIOCSSOFTCAR = 0x541a + TIOCSTI = 0x5412 + TIOCSWINSZ = 0x5414 + TIOCVHANGUP = 0x5437 + TOSTOP = 0x100 + TUNATTACHFILTER = 0x401054d5 + TUNDETACHFILTER = 0x401054d6 + TUNGETFEATURES = 0x800454cf + TUNGETFILTER = 0x801054db + TUNGETIFF = 0x800454d2 + TUNGETSNDBUF = 0x800454d3 + TUNGETVNETBE = 0x800454df + TUNGETVNETHDRSZ = 0x800454d7 + TUNGETVNETLE = 0x800454dd + TUNSETDEBUG = 0x400454c9 + TUNSETGROUP = 0x400454ce + TUNSETIFF = 0x400454ca + TUNSETIFINDEX = 0x400454da + TUNSETLINK = 0x400454cd + TUNSETNOCSUM = 0x400454c8 + TUNSETOFFLOAD = 0x400454d0 + TUNSETOWNER = 0x400454cc + TUNSETPERSIST = 0x400454cb + TUNSETQUEUE = 0x400454d9 + TUNSETSNDBUF = 0x400454d4 + TUNSETTXFILTER = 0x400454d1 + TUNSETVNETBE = 0x400454de + TUNSETVNETHDRSZ = 0x400454d8 + TUNSETVNETLE = 0x400454dc + VDISCARD = 0xd + VEOF = 0x4 + VEOL = 0xb + VEOL2 = 0x10 + VERASE = 0x2 + VINTR = 0x0 + VKILL = 0x3 + VLNEXT = 0xf + VMIN = 0x6 + VQUIT = 0x1 + VREPRINT = 0xc + VSTART = 0x8 + VSTOP = 0x9 + VSUSP = 0xa + VSWTC = 0x7 + VT0 = 0x0 + VT1 = 0x4000 + VTDLY = 0x4000 + VTIME = 0x5 + VWERASE = 0xe + WALL = 0x40000000 + WCLONE = 0x80000000 + WCONTINUED = 0x8 + WEXITED = 0x4 + WNOHANG = 0x1 + WNOTHREAD = 0x20000000 + WNOWAIT = 0x1000000 + WORDSIZE = 0x40 + WSTOPPED = 0x2 + WUNTRACED = 0x2 + XCASE = 0x4 + XTABS = 0x1800 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x62) + EADDRNOTAVAIL = syscall.Errno(0x63) + EADV = syscall.Errno(0x44) + EAFNOSUPPORT = syscall.Errno(0x61) + EAGAIN = syscall.Errno(0xb) + EALREADY = syscall.Errno(0x72) + EBADE = syscall.Errno(0x34) + EBADF = syscall.Errno(0x9) + EBADFD = syscall.Errno(0x4d) + EBADMSG = syscall.Errno(0x4a) + EBADR = syscall.Errno(0x35) + EBADRQC = syscall.Errno(0x38) + EBADSLT = syscall.Errno(0x39) + EBFONT = syscall.Errno(0x3b) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x7d) + ECHILD = syscall.Errno(0xa) + ECHRNG = syscall.Errno(0x2c) + ECOMM = syscall.Errno(0x46) + ECONNABORTED = syscall.Errno(0x67) + ECONNREFUSED = syscall.Errno(0x6f) + ECONNRESET = syscall.Errno(0x68) + EDEADLK = syscall.Errno(0x23) + EDEADLOCK = syscall.Errno(0x23) + EDESTADDRREQ = syscall.Errno(0x59) + EDOM = syscall.Errno(0x21) + EDOTDOT = syscall.Errno(0x49) + EDQUOT = syscall.Errno(0x7a) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EHOSTDOWN = syscall.Errno(0x70) + EHOSTUNREACH = syscall.Errno(0x71) + EHWPOISON = syscall.Errno(0x85) + EIDRM = syscall.Errno(0x2b) + EILSEQ = syscall.Errno(0x54) + EINPROGRESS = syscall.Errno(0x73) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x6a) + EISDIR = syscall.Errno(0x15) + EISNAM = syscall.Errno(0x78) + EKEYEXPIRED = syscall.Errno(0x7f) + EKEYREJECTED = syscall.Errno(0x81) + EKEYREVOKED = syscall.Errno(0x80) + EL2HLT = syscall.Errno(0x33) + EL2NSYNC = syscall.Errno(0x2d) + EL3HLT = syscall.Errno(0x2e) + EL3RST = syscall.Errno(0x2f) + ELIBACC = syscall.Errno(0x4f) + ELIBBAD = syscall.Errno(0x50) + ELIBEXEC = syscall.Errno(0x53) + ELIBMAX = syscall.Errno(0x52) + ELIBSCN = syscall.Errno(0x51) + ELNRNG = syscall.Errno(0x30) + ELOOP = syscall.Errno(0x28) + EMEDIUMTYPE = syscall.Errno(0x7c) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x5a) + EMULTIHOP = syscall.Errno(0x48) + ENAMETOOLONG = syscall.Errno(0x24) + ENAVAIL = syscall.Errno(0x77) + ENETDOWN = syscall.Errno(0x64) + ENETRESET = syscall.Errno(0x66) + ENETUNREACH = syscall.Errno(0x65) + ENFILE = syscall.Errno(0x17) + ENOANO = syscall.Errno(0x37) + ENOBUFS = syscall.Errno(0x69) + ENOCSI = syscall.Errno(0x32) + ENODATA = syscall.Errno(0x3d) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOKEY = syscall.Errno(0x7e) + ENOLCK = syscall.Errno(0x25) + ENOLINK = syscall.Errno(0x43) + ENOMEDIUM = syscall.Errno(0x7b) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x2a) + ENONET = syscall.Errno(0x40) + ENOPKG = syscall.Errno(0x41) + ENOPROTOOPT = syscall.Errno(0x5c) + ENOSPC = syscall.Errno(0x1c) + ENOSR = syscall.Errno(0x3f) + ENOSTR = syscall.Errno(0x3c) + ENOSYS = syscall.Errno(0x26) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x6b) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x27) + ENOTNAM = syscall.Errno(0x76) + ENOTRECOVERABLE = syscall.Errno(0x83) + ENOTSOCK = syscall.Errno(0x58) + ENOTSUP = syscall.Errno(0x5f) + ENOTTY = syscall.Errno(0x19) + ENOTUNIQ = syscall.Errno(0x4c) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x5f) + EOVERFLOW = syscall.Errno(0x4b) + EOWNERDEAD = syscall.Errno(0x82) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x60) + EPIPE = syscall.Errno(0x20) + EPROTO = syscall.Errno(0x47) + EPROTONOSUPPORT = syscall.Errno(0x5d) + EPROTOTYPE = syscall.Errno(0x5b) + ERANGE = syscall.Errno(0x22) + EREMCHG = syscall.Errno(0x4e) + EREMOTE = syscall.Errno(0x42) + EREMOTEIO = syscall.Errno(0x79) + ERESTART = syscall.Errno(0x55) + ERFKILL = syscall.Errno(0x84) + EROFS = syscall.Errno(0x1e) + ESHUTDOWN = syscall.Errno(0x6c) + ESOCKTNOSUPPORT = syscall.Errno(0x5e) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESRMNT = syscall.Errno(0x45) + ESTALE = syscall.Errno(0x74) + ESTRPIPE = syscall.Errno(0x56) + ETIME = syscall.Errno(0x3e) + ETIMEDOUT = syscall.Errno(0x6e) + ETOOMANYREFS = syscall.Errno(0x6d) + ETXTBSY = syscall.Errno(0x1a) + EUCLEAN = syscall.Errno(0x75) + EUNATCH = syscall.Errno(0x31) + EUSERS = syscall.Errno(0x57) + EWOULDBLOCK = syscall.Errno(0xb) + EXDEV = syscall.Errno(0x12) + EXFULL = syscall.Errno(0x36) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0x7) + SIGCHLD = syscall.Signal(0x11) + SIGCLD = syscall.Signal(0x11) + SIGCONT = syscall.Signal(0x12) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x1d) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPOLL = syscall.Signal(0x1d) + SIGPROF = syscall.Signal(0x1b) + SIGPWR = syscall.Signal(0x1e) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTKFLT = syscall.Signal(0x10) + SIGSTOP = syscall.Signal(0x13) + SIGSYS = syscall.Signal(0x1f) + SIGTERM = syscall.Signal(0xf) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x14) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGUNUSED = syscall.Signal(0x1f) + SIGURG = syscall.Signal(0x17) + SIGUSR1 = syscall.Signal(0xa) + SIGUSR2 = syscall.Signal(0xc) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "no such device or address", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource temporarily unavailable", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device or resource busy", + 17: "file exists", + 18: "invalid cross-device link", + 19: "no such device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "numerical result out of range", + 35: "resource deadlock avoided", + 36: "file name too long", + 37: "no locks available", + 38: "function not implemented", + 39: "directory not empty", + 40: "too many levels of symbolic links", + 42: "no message of desired type", + 43: "identifier removed", + 44: "channel number out of range", + 45: "level 2 not synchronized", + 46: "level 3 halted", + 47: "level 3 reset", + 48: "link number out of range", + 49: "protocol driver not attached", + 50: "no CSI structure available", + 51: "level 2 halted", + 52: "invalid exchange", + 53: "invalid request descriptor", + 54: "exchange full", + 55: "no anode", + 56: "invalid request code", + 57: "invalid slot", + 59: "bad font file format", + 60: "device not a stream", + 61: "no data available", + 62: "timer expired", + 63: "out of streams resources", + 64: "machine is not on the network", + 65: "package not installed", + 66: "object is remote", + 67: "link has been severed", + 68: "advertise error", + 69: "srmount error", + 70: "communication error on send", + 71: "protocol error", + 72: "multihop attempted", + 73: "RFS specific error", + 74: "bad message", + 75: "value too large for defined data type", + 76: "name not unique on network", + 77: "file descriptor in bad state", + 78: "remote address changed", + 79: "can not access a needed shared library", + 80: "accessing a corrupted shared library", + 81: ".lib section in a.out corrupted", + 82: "attempting to link in too many shared libraries", + 83: "cannot exec a shared library directly", + 84: "invalid or incomplete multibyte or wide character", + 85: "interrupted system call should be restarted", + 86: "streams pipe error", + 87: "too many users", + 88: "socket operation on non-socket", + 89: "destination address required", + 90: "message too long", + 91: "protocol wrong type for socket", + 92: "protocol not available", + 93: "protocol not supported", + 94: "socket type not supported", + 95: "operation not supported", + 96: "protocol family not supported", + 97: "address family not supported by protocol", + 98: "address already in use", + 99: "cannot assign requested address", + 100: "network is down", + 101: "network is unreachable", + 102: "network dropped connection on reset", + 103: "software caused connection abort", + 104: "connection reset by peer", + 105: "no buffer space available", + 106: "transport endpoint is already connected", + 107: "transport endpoint is not connected", + 108: "cannot send after transport endpoint shutdown", + 109: "too many references: cannot splice", + 110: "connection timed out", + 111: "connection refused", + 112: "host is down", + 113: "no route to host", + 114: "operation already in progress", + 115: "operation now in progress", + 116: "stale file handle", + 117: "structure needs cleaning", + 118: "not a XENIX named type file", + 119: "no XENIX semaphores available", + 120: "is a named type file", + 121: "remote I/O error", + 122: "disk quota exceeded", + 123: "no medium found", + 124: "wrong medium type", + 125: "operation canceled", + 126: "required key not available", + 127: "key has expired", + 128: "key has been revoked", + 129: "key was rejected by service", + 130: "owner died", + 131: "state not recoverable", + 132: "operation not possible due to RF-kill", + 133: "memory page has hardware error", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/breakpoint trap", + 6: "aborted", + 7: "bus error", + 8: "floating point exception", + 9: "killed", + 10: "user defined signal 1", + 11: "segmentation fault", + 12: "user defined signal 2", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "stack fault", + 17: "child exited", + 18: "continued", + 19: "stopped (signal)", + 20: "stopped", + 21: "stopped (tty input)", + 22: "stopped (tty output)", + 23: "urgent I/O condition", + 24: "CPU time limit exceeded", + 25: "file size limit exceeded", + 26: "virtual timer expired", + 27: "profiling timer expired", + 28: "window changed", + 29: "I/O possible", + 30: "power failure", + 31: "bad system call", +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_netbsd_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_netbsd_386.go index 147bcd3df0..b4338d5f26 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_netbsd_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_netbsd_386.go @@ -1,6 +1,8 @@ // mkerrors.sh -m32 // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build 386,netbsd + // Created by cgo -godefs - DO NOT EDIT // cgo -godefs -- -m32 _const.go diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_netbsd_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_netbsd_amd64.go index cae48d1e7e..4994437b63 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_netbsd_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_netbsd_amd64.go @@ -1,6 +1,8 @@ // mkerrors.sh -m64 // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build amd64,netbsd + // Created by cgo -godefs - DO NOT EDIT // cgo -godefs -- -m64 _const.go diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_netbsd_arm.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_netbsd_arm.go index 95a0a25163..ac85ca6452 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_netbsd_arm.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_netbsd_arm.go @@ -1,6 +1,8 @@ // mkerrors.sh -marm // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build arm,netbsd + // Created by cgo -godefs - DO NOT EDIT // cgo -godefs -- -marm _const.go diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_openbsd_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_openbsd_386.go index 8558737b84..3322e998d3 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_openbsd_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_openbsd_386.go @@ -1,6 +1,8 @@ // mkerrors.sh -m32 // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build 386,openbsd + // Created by cgo -godefs - DO NOT EDIT // cgo -godefs -- -m32 _const.go diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_openbsd_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_openbsd_amd64.go index c1d382a421..1758ecca93 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_openbsd_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_openbsd_amd64.go @@ -1,6 +1,8 @@ // mkerrors.sh -m64 // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build amd64,openbsd + // Created by cgo -godefs - DO NOT EDIT // cgo -godefs -- -m64 _const.go diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_solaris_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_solaris_amd64.go index f60e1f8313..a08922b981 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_solaris_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_solaris_amd64.go @@ -1,6 +1,8 @@ // mkerrors.sh -m64 // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build amd64,solaris + // Created by cgo -godefs - DO NOT EDIT // cgo -godefs -- -m64 _const.go @@ -159,6 +161,14 @@ const ( BRKINT = 0x2 CFLUSH = 0xf CLOCAL = 0x800 + CLOCK_HIGHRES = 0x4 + CLOCK_LEVEL = 0xa + CLOCK_MONOTONIC = 0x4 + CLOCK_PROCESS_CPUTIME_ID = 0x5 + CLOCK_PROF = 0x2 + CLOCK_REALTIME = 0x3 + CLOCK_THREAD_CPUTIME_ID = 0x2 + CLOCK_VIRTUAL = 0x1 CREAD = 0x80 CS5 = 0x0 CS6 = 0x10 @@ -166,6 +176,7 @@ const ( CS8 = 0x30 CSIZE = 0x30 CSTART = 0x11 + CSTATUS = 0x14 CSTOP = 0x13 CSTOPB = 0x40 CSUSP = 0x1a @@ -755,9 +766,7 @@ const ( SIOCDARP = -0x7fdb96e0 SIOCDELMULTI = -0x7fdf96ce SIOCDELRT = -0x7fcf8df5 - SIOCDIPSECONFIG = -0x7ffb9669 SIOCDXARP = -0x7fff9658 - SIOCFIPSECONFIG = -0x7ffb966b SIOCGARP = -0x3fdb96e1 SIOCGDSTINFO = -0x3fff965c SIOCGENADDR = -0x3fdf96ab @@ -819,7 +828,6 @@ const ( SIOCLIFGETND = -0x3f879672 SIOCLIFREMOVEIF = -0x7f879692 SIOCLIFSETND = -0x7f879671 - SIOCLIPSECONFIG = -0x7ffb9668 SIOCLOWER = -0x7fdf96d7 SIOCSARP = -0x7fdb96e2 SIOCSCTPGOPT = -0x3fef9653 @@ -842,7 +850,6 @@ const ( SIOCSIFNETMASK = -0x7fdf96e6 SIOCSIP6ADDRPOLICY = -0x7fff965d SIOCSIPMSFILTER = -0x7ffb964b - SIOCSIPSECONFIG = -0x7ffb966a SIOCSLGETREQ = -0x3fdf96b9 SIOCSLIFADDR = -0x7f879690 SIOCSLIFBRDADDR = -0x7f879684 @@ -949,6 +956,8 @@ const ( SO_VRRP = 0x1017 SO_WROFF = 0x2 TCFLSH = 0x5407 + TCGETA = 0x5401 + TCGETS = 0x540d TCIFLUSH = 0x0 TCIOFLUSH = 0x2 TCOFLUSH = 0x1 @@ -975,6 +984,14 @@ const ( TCP_RTO_MAX = 0x1b TCP_RTO_MIN = 0x1a TCSAFLUSH = 0x5410 + TCSBRK = 0x5405 + TCSETA = 0x5402 + TCSETAF = 0x5404 + TCSETAW = 0x5403 + TCSETS = 0x540e + TCSETSF = 0x5410 + TCSETSW = 0x540f + TCXONC = 0x5406 TIOC = 0x5400 TIOCCBRK = 0x747a TIOCCDTR = 0x7478 @@ -1050,6 +1067,7 @@ const ( VQUIT = 0x1 VREPRINT = 0xc VSTART = 0x8 + VSTATUS = 0x10 VSTOP = 0x9 VSUSP = 0xa VSWTCH = 0x7 @@ -1213,6 +1231,7 @@ const ( SIGFREEZE = syscall.Signal(0x22) SIGHUP = syscall.Signal(0x1) SIGILL = syscall.Signal(0x4) + SIGINFO = syscall.Signal(0x29) SIGINT = syscall.Signal(0x2) SIGIO = syscall.Signal(0x16) SIGIOT = syscall.Signal(0x6) @@ -1413,4 +1432,5 @@ var signals = [...]string{ 38: "resource Control Exceeded", 39: "reserved for JVM 1", 40: "reserved for JVM 2", + 41: "information Request", } diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_darwin_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_darwin_386.go index a6bcbed346..031034a345 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_darwin_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_darwin_386.go @@ -1,6 +1,8 @@ // mksyscall.pl -l32 syscall_bsd.go syscall_darwin.go syscall_darwin_386.go // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build 386,darwin + package unix import ( @@ -220,6 +222,7 @@ func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + use(_p0) if e1 != 0 { err = errnoErr(e1) } diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_darwin_amd64.go index 14b367b9e4..ee96f78bad 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_darwin_amd64.go @@ -1,6 +1,8 @@ // mksyscall.pl syscall_bsd.go syscall_darwin.go syscall_darwin_amd64.go // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build amd64,darwin + package unix import ( @@ -220,6 +222,7 @@ func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + use(_p0) if e1 != 0 { err = errnoErr(e1) } @@ -1413,6 +1416,22 @@ func writelen(fd int, buf *byte, nbuf int) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func gettimeofday(tp *Timeval) (sec int64, usec int32, err error) { r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0) sec = int64(r0) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_dragonfly_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_darwin_arm.go similarity index 92% rename from Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_dragonfly_386.go rename to Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_darwin_arm.go index 8c20019c6a..e52cd0d54c 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_dragonfly_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_darwin_arm.go @@ -1,6 +1,8 @@ -// mksyscall.pl -l32 -dragonfly syscall_bsd.go syscall_dragonfly.go syscall_dragonfly_386.go +// mksyscall.pl syscall_bsd.go syscall_darwin.go syscall_darwin_arm.go // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build arm,darwin + package unix import ( @@ -220,6 +222,7 @@ func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + use(_p0) if e1 != 0 { err = errnoErr(e1) } @@ -265,10 +268,8 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe() (r int, w int, err error) { - r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) - r = int(r0) - w = int(r1) +func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) if e1 != 0 { err = errnoErr(e1) } @@ -277,15 +278,10 @@ func pipe() (r int, w int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func extpread(fd int, p []byte, flags int, offset int64) (n int, err error) { - var _p0 unsafe.Pointer - if len(p) > 0 { - _p0 = unsafe.Pointer(&p[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall6(SYS_EXTPREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(offset), uintptr(offset>>32)) - n = int(r0) +func pipe() (r int, w int, err error) { + r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) + r = int(r0) + w = int(r1) if e1 != 0 { err = errnoErr(e1) } @@ -294,15 +290,8 @@ func extpread(fd int, p []byte, flags int, offset int64) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func extpwrite(fd int, p []byte, flags int, offset int64) (n int, err error) { - var _p0 unsafe.Pointer - if len(p) > 0 { - _p0 = unsafe.Pointer(&p[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall6(SYS_EXTPWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(offset), uintptr(offset>>32)) - n = int(r0) +func kill(pid int, signum int, posix int) (err error) { + _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix)) if e1 != 0 { err = errnoErr(e1) } @@ -448,6 +437,28 @@ func Dup2(from int, to int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Exchangedata(path1 string, path2 string, options int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path1) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(path2) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_EXCHANGEDATA, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options)) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Exit(code int) { Syscall(SYS_EXIT, uintptr(code), 0, 0) return @@ -517,7 +528,7 @@ func Fpathconf(fd int, name int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Fstat(fd int, stat *Stat_t) (err error) { - _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + _, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) if e1 != 0 { err = errnoErr(e1) } @@ -527,7 +538,7 @@ func Fstat(fd int, stat *Stat_t) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Fstatfs(fd int, stat *Statfs_t) (err error) { - _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + _, _, e1 := Syscall(SYS_FSTATFS64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) if e1 != 0 { err = errnoErr(e1) } @@ -547,7 +558,7 @@ func Fsync(fd int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Ftruncate(fd int, length int64) (err error) { - _, _, e1 := Syscall6(SYS_FTRUNCATE, uintptr(fd), 0, uintptr(length), uintptr(length>>32), 0, 0) + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0) if e1 != 0 { err = errnoErr(e1) } @@ -563,7 +574,7 @@ func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { } else { _p0 = unsafe.Pointer(&_zero) } - r0, _, e1 := Syscall6(SYS_GETDIRENTRIES, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0) + r0, _, e1 := Syscall6(SYS_GETDIRENTRIES64, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0) n = int(r0) if e1 != 0 { err = errnoErr(e1) @@ -682,16 +693,6 @@ func Getsid(pid int) (sid int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Gettimeofday(tv *Timeval) (err error) { - _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Getuid() (uid int) { r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) uid = int(r0) @@ -701,23 +702,13 @@ func Getuid() (uid int) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Issetugid() (tainted bool) { - r0, _, _ := Syscall(SYS_ISSETUGID, 0, 0, 0) + r0, _, _ := RawSyscall(SYS_ISSETUGID, 0, 0, 0) tainted = bool(r0 != 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Kill(pid int, signum syscall.Signal) (err error) { - _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Kqueue() (fd int, err error) { r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0) fd = int(r0) @@ -783,7 +774,7 @@ func Lstat(path string, stat *Stat_t) (err error) { if err != nil { return } - _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + _, _, e1 := Syscall(SYS_LSTAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) use(unsafe.Pointer(_p0)) if e1 != 0 { err = errnoErr(e1) @@ -909,16 +900,6 @@ func Munlockall() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Nanosleep(time *Timespec, leftover *Timespec) (err error) { - _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Open(path string, mode int, perm uint32) (fd int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -953,6 +934,40 @@ func Pathconf(path string, name int) (val int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func read(fd int, p []byte) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { @@ -1048,8 +1063,8 @@ func Rmdir(path string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { - r0, r1, e1 := Syscall6(SYS_LSEEK, uintptr(fd), 0, uintptr(offset), uintptr(offset>>32), uintptr(whence), 0) - newoffset = int64(int64(r1)<<32 | int64(r0)) + r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence)) + newoffset = int64(r0) if e1 != 0 { err = errnoErr(e1) } @@ -1069,7 +1084,7 @@ func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Setegid(egid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETEGID, uintptr(egid), 0, 0) + _, _, e1 := Syscall(SYS_SETEGID, uintptr(egid), 0, 0) if e1 != 0 { err = errnoErr(e1) } @@ -1134,8 +1149,8 @@ func Setpriority(which int, who int, prio int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setregid(rgid int, egid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) +func Setprivexec(flag int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIVEXEC, uintptr(flag), 0, 0) if e1 != 0 { err = errnoErr(e1) } @@ -1144,18 +1159,8 @@ func Setregid(rgid int, egid int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setreuid(ruid int, euid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresgid(rgid int, egid int, sgid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) if e1 != 0 { err = errnoErr(e1) } @@ -1164,8 +1169,8 @@ func Setresgid(rgid int, egid int, sgid int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setresuid(ruid int, euid int, suid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) if e1 != 0 { err = errnoErr(e1) } @@ -1221,7 +1226,7 @@ func Stat(path string, stat *Stat_t) (err error) { if err != nil { return } - _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + _, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) use(unsafe.Pointer(_p0)) if e1 != 0 { err = errnoErr(e1) @@ -1237,7 +1242,7 @@ func Statfs(path string, stat *Statfs_t) (err error) { if err != nil { return } - _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + _, _, e1 := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) use(unsafe.Pointer(_p0)) if e1 != 0 { err = errnoErr(e1) @@ -1285,7 +1290,7 @@ func Truncate(path string, length int64) (err error) { if err != nil { return } - _, _, e1 := Syscall6(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), 0, uintptr(length), uintptr(length>>32), 0, 0) + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0) use(unsafe.Pointer(_p0)) if e1 != 0 { err = errnoErr(e1) @@ -1369,7 +1374,7 @@ func write(fd int, p []byte) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { - r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), 0, uintptr(pos), uintptr(pos>>32), 0) + r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos)) ret = uintptr(r0) if e1 != 0 { err = errnoErr(e1) @@ -1408,3 +1413,15 @@ func writelen(fd int, buf *byte, nbuf int) (n int, err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func gettimeofday(tp *Timeval) (sec int32, usec int32, err error) { + r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0) + sec = int32(r0) + usec = int32(r1) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_darwin_arm64.go new file mode 100644 index 0000000000..9863ef99e3 --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_darwin_arm64.go @@ -0,0 +1,1427 @@ +// mksyscall.pl syscall_bsd.go syscall_darwin.go syscall_darwin_arm64.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build arm64,darwin + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(ngid int, gid *_Gid_t) (n int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(ngid int, gid *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(s int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) { + r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { + var _p0 unsafe.Pointer + if len(mib) > 0 { + _p0 = unsafe.Pointer(&mib[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + use(_p0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, timeval *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimes(fd int, timeval *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe() (r int, w int, err error) { + r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) + r = int(r0) + w = int(r1) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kill(pid int, signum int, posix int) (err error) { + _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Access(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { + _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chflags(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chmod(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(fd int) (nfd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0) + nfd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(from int, to int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exchangedata(path1 string, path2 string, options int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path1) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(path2) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_EXCHANGEDATA, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options)) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchflags(fd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fpathconf(fd int, name int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, stat *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_GETDIRENTRIES64, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdtablesize() (size int) { + r0, _, _ := Syscall(SYS_GETDTABLESIZE, 0, 0, 0) + size = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgrp() (pgrp int) { + r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0) + pgrp = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Issetugid() (tainted bool) { + r0, _, _ := RawSyscall(SYS_ISSETUGID, 0, 0, 0) + tainted = bool(r0 != 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kqueue() (fd int, err error) { + r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Link(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, backlog int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdir(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkfifo(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknod(path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Open(path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pathconf(path string, name int) (val int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0) + use(unsafe.Pointer(_p0)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Readlink(path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf))) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rename(from string, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Revoke(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rmdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { + r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence)) + newoffset = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) { + _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setegid(egid int) (err error) { + _, _, e1 := Syscall(SYS_SETEGID, uintptr(egid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seteuid(euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setgid(gid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setlogin(name string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(name) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setprivexec(flag int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIVEXEC, uintptr(flag), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tp *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setuid(uid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, stat *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Symlink(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() (err error) { + _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(newmask int) (oldmask int) { + r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Undelete(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unlink(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { + r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos)) + ret = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func gettimeofday(tp *Timeval) (sec int64, usec int32, err error) { + r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0) + sec = int64(r0) + usec = int32(r1) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go index 2ae6f6a620..78de48dcf3 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go @@ -1,6 +1,8 @@ // mksyscall.pl -dragonfly syscall_bsd.go syscall_dragonfly.go syscall_dragonfly_amd64.go // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build amd64,dragonfly + package unix import ( @@ -220,6 +222,7 @@ func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + use(_p0) if e1 != 0 { err = errnoErr(e1) } diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_freebsd_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_freebsd_386.go index eef8eca6f0..fade994dcf 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_freebsd_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_freebsd_386.go @@ -1,6 +1,8 @@ // mksyscall.pl -l32 syscall_bsd.go syscall_freebsd.go syscall_freebsd_386.go // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build 386,freebsd + package unix import ( @@ -220,6 +222,7 @@ func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + use(_p0) if e1 != 0 { err = errnoErr(e1) } diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go index 507166bcfc..c28281e83e 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go @@ -1,6 +1,8 @@ // mksyscall.pl syscall_bsd.go syscall_freebsd.go syscall_freebsd_amd64.go // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build amd64,freebsd + package unix import ( @@ -220,6 +222,7 @@ func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + use(_p0) if e1 != 0 { err = errnoErr(e1) } diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_freebsd_arm.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_freebsd_arm.go index 0b7a34eb1b..a18ba5c88b 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_freebsd_arm.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_freebsd_arm.go @@ -1,6 +1,8 @@ // mksyscall.pl -l32 -arm syscall_bsd.go syscall_freebsd.go syscall_freebsd_arm.go // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build arm,freebsd + package unix import ( @@ -220,6 +222,7 @@ func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + use(_p0) if e1 != 0 { err = errnoErr(e1) } diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_386.go index 5a881ce6b2..749f3e46e6 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_386.go @@ -1,6 +1,8 @@ // mksyscall.pl -l32 syscall_linux.go syscall_linux_386.go // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build 386,linux + package unix import ( @@ -12,15 +14,20 @@ var _ syscall.Errno // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func open(path string, mode int, perm uint32) (fd int, err error) { +func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { var _p0 *byte - _p0, err = BytePtrFromString(path) + _p0, err = BytePtrFromString(oldpath) if err != nil { return } - r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) use(unsafe.Pointer(_p0)) - fd = int(r0) + use(unsafe.Pointer(_p1)) if e1 != 0 { err = errnoErr(e1) } @@ -46,8 +53,21 @@ func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe(p *[2]_C_int) (err error) { - _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) +func readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + use(unsafe.Pointer(_p0)) + n = int(r0) if e1 != 0 { err = errnoErr(e1) } @@ -56,8 +76,36 @@ func pipe(p *[2]_C_int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe2(p *[2]_C_int, flags int) (err error) { - _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) +func symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + use(unsafe.Pointer(_p0)) if e1 != 0 { err = errnoErr(e1) } @@ -190,22 +238,6 @@ func mount(source string, target string, fstype string, flags uintptr, data *byt // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Access(path string, mode uint32) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) - use(unsafe.Pointer(_p0)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Acct(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -249,22 +281,6 @@ func Chdir(path string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Chmod(path string, mode uint32) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) - use(unsafe.Pointer(_p0)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Chroot(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -301,23 +317,6 @@ func Close(fd int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Creat(path string, mode uint32) (fd int, err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - r0, _, e1 := Syscall(SYS_CREAT, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) - use(unsafe.Pointer(_p0)) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Dup(oldfd int) (fd int, err error) { r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) fd = int(r0) @@ -329,16 +328,6 @@ func Dup(oldfd int) (fd int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Dup2(oldfd int, newfd int) (err error) { - _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Dup3(oldfd int, newfd int, flags int) (err error) { _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags)) if e1 != 0 { @@ -381,23 +370,6 @@ func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { - var _p0 unsafe.Pointer - if len(events) > 0 { - _p0 = unsafe.Pointer(&events[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Exit(code int) { Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0) return @@ -643,17 +615,6 @@ func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err e // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func InotifyInit() (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func InotifyInit1(flags int) (fd int, err error) { r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0) fd = int(r0) @@ -703,28 +664,6 @@ func Klogctl(typ int, buf []byte) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Link(oldpath string, newpath string) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(oldpath) - if err != nil { - return - } - var _p1 *byte - _p1, err = BytePtrFromString(newpath) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) - use(unsafe.Pointer(_p0)) - use(unsafe.Pointer(_p1)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Listxattr(path string, dest []byte) (sz int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -748,22 +687,6 @@ func Listxattr(path string, dest []byte) (sz int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mkdir(path string, mode uint32) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) - use(unsafe.Pointer(_p0)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Mkdirat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -780,22 +703,6 @@ func Mkdirat(dirfd int, path string, mode uint32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mknod(path string, mode uint32, dev int) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) - use(unsafe.Pointer(_p0)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -822,16 +729,6 @@ func Nanosleep(time *Timespec, leftover *Timespec) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pause() (err error) { - _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func PivotRoot(newroot string, putold string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(newroot) @@ -864,15 +761,8 @@ func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func read(fd int, p []byte) (n int, err error) { - var _p0 unsafe.Pointer - if len(p) > 0 { - _p0 = unsafe.Pointer(&p[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) - n = int(r0) +func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0) if e1 != 0 { err = errnoErr(e1) } @@ -881,20 +771,14 @@ func read(fd int, p []byte) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Readlink(path string, buf []byte) (n int, err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - var _p1 unsafe.Pointer - if len(buf) > 0 { - _p1 = unsafe.Pointer(&buf[0]) +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) } else { - _p1 = unsafe.Pointer(&_zero) + _p0 = unsafe.Pointer(&_zero) } - r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf))) - use(unsafe.Pointer(_p0)) + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) n = int(r0) if e1 != 0 { err = errnoErr(e1) @@ -926,28 +810,6 @@ func Removexattr(path string, attr string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Rename(oldpath string, newpath string) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(oldpath) - if err != nil { - return - } - var _p1 *byte - _p1, err = BytePtrFromString(newpath) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) - use(unsafe.Pointer(_p0)) - use(unsafe.Pointer(_p1)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(oldpath) @@ -970,22 +832,6 @@ func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err e // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Rmdir(path string) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) - use(unsafe.Pointer(_p0)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setdomainname(p []byte) (err error) { var _p0 unsafe.Pointer if len(p) > 0 { @@ -1049,6 +895,16 @@ func Settimeofday(tv *Timeval) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Setns(fd int, nstype int) (err error) { + _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Setpriority(which int, who int, prio int) (err error) { _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) if e1 != 0 { @@ -1087,28 +943,6 @@ func Setxattr(path string, attr string, data []byte, flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Symlink(oldpath string, newpath string) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(oldpath) - if err != nil { - return - } - var _p1 *byte - _p1, err = BytePtrFromString(newpath) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) - use(unsafe.Pointer(_p0)) - use(unsafe.Pointer(_p1)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Sync() { Syscall(SYS_SYNC, 0, 0, 0) return @@ -1176,38 +1010,6 @@ func Uname(buf *Utsname) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Unlink(path string) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0) - use(unsafe.Pointer(_p0)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Unlinkat(dirfd int, path string, flags int) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) - use(unsafe.Pointer(_p0)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Unmount(target string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(target) @@ -1244,22 +1046,6 @@ func Ustat(dev int, ubuf *Ustat_t) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Utime(path string, buf *Utimbuf) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) - use(unsafe.Pointer(_p0)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func write(fd int, p []byte) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { @@ -1403,14 +1189,28 @@ func Munlockall() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Chown(path string, uid int, gid int) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return +func pipe(p *[2]_C_int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) } - _, _, e1 := Syscall(SYS_CHOWN32, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) - use(unsafe.Pointer(_p0)) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(oldfd int, newfd int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) if e1 != 0 { err = errnoErr(e1) } @@ -1491,6 +1291,17 @@ func Getuid() (uid int) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func InotifyInit() (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Ioperm(from int, num int, on int) (err error) { _, _, e1 := Syscall(SYS_IOPERM, uintptr(from), uintptr(num), uintptr(on)) if e1 != 0 { @@ -1744,6 +1555,33 @@ func mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { + var _p0 unsafe.Pointer + if len(events) > 0 { + _p0 = unsafe.Pointer(&events[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pause() (err error) { + _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func getrlimit(resource int, rlim *rlimit32) (err error) { _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) if e1 != 0 { @@ -1782,3 +1620,19 @@ func Time(t *Time_t) (tt Time_t, err error) { } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Utime(path string, buf *Utimbuf) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_amd64.go index d0092b59bb..1096aa5443 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_amd64.go @@ -1,6 +1,8 @@ // mksyscall.pl syscall_linux.go syscall_linux_amd64.go // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build amd64,linux + package unix import ( @@ -12,15 +14,20 @@ var _ syscall.Errno // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func open(path string, mode int, perm uint32) (fd int, err error) { +func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { var _p0 *byte - _p0, err = BytePtrFromString(path) + _p0, err = BytePtrFromString(oldpath) if err != nil { return } - r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) use(unsafe.Pointer(_p0)) - fd = int(r0) + use(unsafe.Pointer(_p1)) if e1 != 0 { err = errnoErr(e1) } @@ -46,8 +53,21 @@ func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe(p *[2]_C_int) (err error) { - _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) +func readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + use(unsafe.Pointer(_p0)) + n = int(r0) if e1 != 0 { err = errnoErr(e1) } @@ -56,8 +76,36 @@ func pipe(p *[2]_C_int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe2(p *[2]_C_int, flags int) (err error) { - _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) +func symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + use(unsafe.Pointer(_p0)) if e1 != 0 { err = errnoErr(e1) } @@ -190,22 +238,6 @@ func mount(source string, target string, fstype string, flags uintptr, data *byt // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Access(path string, mode uint32) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) - use(unsafe.Pointer(_p0)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Acct(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -249,22 +281,6 @@ func Chdir(path string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Chmod(path string, mode uint32) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) - use(unsafe.Pointer(_p0)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Chroot(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -301,23 +317,6 @@ func Close(fd int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Creat(path string, mode uint32) (fd int, err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - r0, _, e1 := Syscall(SYS_CREAT, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) - use(unsafe.Pointer(_p0)) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Dup(oldfd int) (fd int, err error) { r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) fd = int(r0) @@ -329,16 +328,6 @@ func Dup(oldfd int) (fd int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Dup2(oldfd int, newfd int) (err error) { - _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Dup3(oldfd int, newfd int, flags int) (err error) { _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags)) if e1 != 0 { @@ -381,23 +370,6 @@ func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { - var _p0 unsafe.Pointer - if len(events) > 0 { - _p0 = unsafe.Pointer(&events[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Exit(code int) { Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0) return @@ -643,17 +615,6 @@ func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err e // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func InotifyInit() (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func InotifyInit1(flags int) (fd int, err error) { r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0) fd = int(r0) @@ -703,28 +664,6 @@ func Klogctl(typ int, buf []byte) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Link(oldpath string, newpath string) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(oldpath) - if err != nil { - return - } - var _p1 *byte - _p1, err = BytePtrFromString(newpath) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) - use(unsafe.Pointer(_p0)) - use(unsafe.Pointer(_p1)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Listxattr(path string, dest []byte) (sz int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -748,22 +687,6 @@ func Listxattr(path string, dest []byte) (sz int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mkdir(path string, mode uint32) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) - use(unsafe.Pointer(_p0)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Mkdirat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -780,22 +703,6 @@ func Mkdirat(dirfd int, path string, mode uint32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mknod(path string, mode uint32, dev int) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) - use(unsafe.Pointer(_p0)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -822,16 +729,6 @@ func Nanosleep(time *Timespec, leftover *Timespec) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pause() (err error) { - _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func PivotRoot(newroot string, putold string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(newroot) @@ -864,15 +761,8 @@ func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func read(fd int, p []byte) (n int, err error) { - var _p0 unsafe.Pointer - if len(p) > 0 { - _p0 = unsafe.Pointer(&p[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) - n = int(r0) +func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0) if e1 != 0 { err = errnoErr(e1) } @@ -881,20 +771,14 @@ func read(fd int, p []byte) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Readlink(path string, buf []byte) (n int, err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - var _p1 unsafe.Pointer - if len(buf) > 0 { - _p1 = unsafe.Pointer(&buf[0]) +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) } else { - _p1 = unsafe.Pointer(&_zero) + _p0 = unsafe.Pointer(&_zero) } - r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf))) - use(unsafe.Pointer(_p0)) + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) n = int(r0) if e1 != 0 { err = errnoErr(e1) @@ -926,28 +810,6 @@ func Removexattr(path string, attr string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Rename(oldpath string, newpath string) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(oldpath) - if err != nil { - return - } - var _p1 *byte - _p1, err = BytePtrFromString(newpath) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) - use(unsafe.Pointer(_p0)) - use(unsafe.Pointer(_p1)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(oldpath) @@ -970,22 +832,6 @@ func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err e // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Rmdir(path string) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) - use(unsafe.Pointer(_p0)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setdomainname(p []byte) (err error) { var _p0 unsafe.Pointer if len(p) > 0 { @@ -1049,6 +895,16 @@ func Settimeofday(tv *Timeval) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Setns(fd int, nstype int) (err error) { + _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Setpriority(which int, who int, prio int) (err error) { _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) if e1 != 0 { @@ -1087,28 +943,6 @@ func Setxattr(path string, attr string, data []byte, flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Symlink(oldpath string, newpath string) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(oldpath) - if err != nil { - return - } - var _p1 *byte - _p1, err = BytePtrFromString(newpath) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) - use(unsafe.Pointer(_p0)) - use(unsafe.Pointer(_p1)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Sync() { Syscall(SYS_SYNC, 0, 0, 0) return @@ -1176,38 +1010,6 @@ func Uname(buf *Utsname) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Unlink(path string) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0) - use(unsafe.Pointer(_p0)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Unlinkat(dirfd int, path string, flags int) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) - use(unsafe.Pointer(_p0)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Unmount(target string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(target) @@ -1244,22 +1046,6 @@ func Ustat(dev int, ubuf *Ustat_t) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Utime(path string, buf *Utimbuf) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) - use(unsafe.Pointer(_p0)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func write(fd int, p []byte) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { @@ -1403,14 +1189,25 @@ func Munlockall() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Chown(path string, uid int, gid int) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return +func Dup2(oldfd int, newfd int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) + if e1 != 0 { + err = errnoErr(e1) } - _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) - use(unsafe.Pointer(_p0)) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { + var _p0 unsafe.Pointer + if len(events) > 0 { + _p0 = unsafe.Pointer(&events[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) + n = int(r0) if e1 != 0 { err = errnoErr(e1) } @@ -1511,6 +1308,17 @@ func Getuid() (uid int) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func InotifyInit() (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Ioperm(from int, num int, on int) (err error) { _, _, e1 := Syscall(SYS_IOPERM, uintptr(from), uintptr(num), uintptr(on)) if e1 != 0 { @@ -1573,6 +1381,16 @@ func Lstat(path string, stat *Stat_t) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Pause() (err error) { + _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { @@ -1976,3 +1794,39 @@ func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int6 } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Utime(path string, buf *Utimbuf) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe(p *[2]_C_int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_arm.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_arm.go index 4e42e81e89..9066e1cb77 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_arm.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_arm.go @@ -1,6 +1,8 @@ // mksyscall.pl -l32 -arm syscall_linux.go syscall_linux_arm.go // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build arm,linux + package unix import ( @@ -12,15 +14,20 @@ var _ syscall.Errno // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func open(path string, mode int, perm uint32) (fd int, err error) { +func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { var _p0 *byte - _p0, err = BytePtrFromString(path) + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) if err != nil { return } - r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) use(unsafe.Pointer(_p0)) - fd = int(r0) + use(unsafe.Pointer(_p1)) if e1 != 0 { err = errnoErr(e1) } @@ -46,8 +53,21 @@ func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe(p *[2]_C_int) (err error) { - _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) +func readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + use(unsafe.Pointer(_p0)) + n = int(r0) if e1 != 0 { err = errnoErr(e1) } @@ -56,8 +76,36 @@ func pipe(p *[2]_C_int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func pipe2(p *[2]_C_int, flags int) (err error) { - _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) +func symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + use(unsafe.Pointer(_p0)) if e1 != 0 { err = errnoErr(e1) } @@ -190,22 +238,6 @@ func mount(source string, target string, fstype string, flags uintptr, data *byt // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Access(path string, mode uint32) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) - use(unsafe.Pointer(_p0)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Acct(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -249,22 +281,6 @@ func Chdir(path string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Chmod(path string, mode uint32) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) - use(unsafe.Pointer(_p0)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Chroot(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -301,23 +317,6 @@ func Close(fd int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Creat(path string, mode uint32) (fd int, err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - r0, _, e1 := Syscall(SYS_CREAT, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) - use(unsafe.Pointer(_p0)) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Dup(oldfd int) (fd int, err error) { r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) fd = int(r0) @@ -329,16 +328,6 @@ func Dup(oldfd int) (fd int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Dup2(oldfd int, newfd int) (err error) { - _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Dup3(oldfd int, newfd int, flags int) (err error) { _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags)) if e1 != 0 { @@ -381,23 +370,6 @@ func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { - var _p0 unsafe.Pointer - if len(events) > 0 { - _p0 = unsafe.Pointer(&events[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Exit(code int) { Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0) return @@ -643,17 +615,6 @@ func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err e // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func InotifyInit() (fd int, err error) { - r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0) - fd = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func InotifyInit1(flags int) (fd int, err error) { r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0) fd = int(r0) @@ -703,28 +664,6 @@ func Klogctl(typ int, buf []byte) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Link(oldpath string, newpath string) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(oldpath) - if err != nil { - return - } - var _p1 *byte - _p1, err = BytePtrFromString(newpath) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) - use(unsafe.Pointer(_p0)) - use(unsafe.Pointer(_p1)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Listxattr(path string, dest []byte) (sz int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -748,22 +687,6 @@ func Listxattr(path string, dest []byte) (sz int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mkdir(path string, mode uint32) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) - use(unsafe.Pointer(_p0)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Mkdirat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -780,22 +703,6 @@ func Mkdirat(dirfd int, path string, mode uint32) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Mknod(path string, mode uint32, dev int) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) - use(unsafe.Pointer(_p0)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -822,16 +729,6 @@ func Nanosleep(time *Timespec, leftover *Timespec) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Pause() (err error) { - _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func PivotRoot(newroot string, putold string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(newroot) @@ -864,15 +761,8 @@ func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func read(fd int, p []byte) (n int, err error) { - var _p0 unsafe.Pointer - if len(p) > 0 { - _p0 = unsafe.Pointer(&p[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) - n = int(r0) +func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0) if e1 != 0 { err = errnoErr(e1) } @@ -881,20 +771,14 @@ func read(fd int, p []byte) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Readlink(path string, buf []byte) (n int, err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - var _p1 unsafe.Pointer - if len(buf) > 0 { - _p1 = unsafe.Pointer(&buf[0]) +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) } else { - _p1 = unsafe.Pointer(&_zero) + _p0 = unsafe.Pointer(&_zero) } - r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf))) - use(unsafe.Pointer(_p0)) + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) n = int(r0) if e1 != 0 { err = errnoErr(e1) @@ -926,28 +810,6 @@ func Removexattr(path string, attr string) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Rename(oldpath string, newpath string) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(oldpath) - if err != nil { - return - } - var _p1 *byte - _p1, err = BytePtrFromString(newpath) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) - use(unsafe.Pointer(_p0)) - use(unsafe.Pointer(_p1)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(oldpath) @@ -970,22 +832,6 @@ func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err e // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Rmdir(path string) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) - use(unsafe.Pointer(_p0)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setdomainname(p []byte) (err error) { var _p0 unsafe.Pointer if len(p) > 0 { @@ -1049,6 +895,16 @@ func Settimeofday(tv *Timeval) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Setns(fd int, nstype int) (err error) { + _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Setpriority(which int, who int, prio int) (err error) { _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) if e1 != 0 { @@ -1087,28 +943,6 @@ func Setxattr(path string, attr string, data []byte, flags int) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Symlink(oldpath string, newpath string) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(oldpath) - if err != nil { - return - } - var _p1 *byte - _p1, err = BytePtrFromString(newpath) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) - use(unsafe.Pointer(_p0)) - use(unsafe.Pointer(_p1)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Sync() { Syscall(SYS_SYNC, 0, 0, 0) return @@ -1176,38 +1010,6 @@ func Uname(buf *Utsname) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Unlink(path string) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0) - use(unsafe.Pointer(_p0)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Unlinkat(dirfd int, path string, flags int) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) - use(unsafe.Pointer(_p0)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Unmount(target string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(target) @@ -1244,22 +1046,6 @@ func Ustat(dev int, ubuf *Ustat_t) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Utime(path string, buf *Utimbuf) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) - use(unsafe.Pointer(_p0)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func write(fd int, p []byte) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { @@ -1403,6 +1189,16 @@ func Munlockall() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) fd = int(r0) @@ -1582,14 +1378,8 @@ func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Chown(path string, uid int, gid int) (err error) { - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return - } - _, _, e1 := Syscall(SYS_CHOWN32, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) - use(unsafe.Pointer(_p0)) +func Dup2(oldfd int, newfd int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) if e1 != 0 { err = errnoErr(e1) } @@ -1650,6 +1440,17 @@ func Getuid() (uid int) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func InotifyInit() (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Lchown(path string, uid int, gid int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) @@ -1821,9 +1622,25 @@ func Gettimeofday(tv *Timeval) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Time(t *Time_t) (tt Time_t, err error) { - r0, _, e1 := RawSyscall(SYS_TIME, uintptr(unsafe.Pointer(t)), 0, 0) - tt = Time_t(r0) +func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { + var _p0 unsafe.Pointer + if len(events) > 0 { + _p0 = unsafe.Pointer(&events[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pause() (err error) { + _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0) if e1 != 0 { err = errnoErr(e1) } @@ -1904,7 +1721,7 @@ func mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func getrlimit(resource int, rlim *rlimit32) (err error) { - _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + _, _, e1 := RawSyscall(SYS_UGETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) if e1 != 0 { err = errnoErr(e1) } diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_arm64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_arm64.go new file mode 100644 index 0000000000..5b91612265 --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_arm64.go @@ -0,0 +1,1723 @@ +// mksyscall.pl syscall_linux.go syscall_linux_arm64.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build arm64,linux + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, times *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getcwd(buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETCWD, uintptr(_p0), uintptr(len(buf)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(arg) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(source) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(target) + if err != nil { + return + } + var _p2 *byte + _p2, err = BytePtrFromString(fstype) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(flags), uintptr(unsafe.Pointer(data)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + use(unsafe.Pointer(_p2)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Acct(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtimex(buf *Timex) (state int, err error) { + r0, _, e1 := Syscall(SYS_ADJTIMEX, uintptr(unsafe.Pointer(buf)), 0, 0) + state = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ClockGettime(clockid int32, time *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(oldfd int) (fd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup3(oldfd int, newfd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate(size int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate1(flag int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE1, uintptr(flag), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) { + _, _, e1 := RawSyscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fallocate(fd int, mode uint32, off int64, len int64) (err error) { + _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(len), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fdatasync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdents(fd int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettid() (tid int) { + r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0) + tid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getxattr(path string, attr string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(dest) > 0 { + _p2 = unsafe.Pointer(&dest[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(pathname) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(mask)) + use(unsafe.Pointer(_p0)) + watchdesc = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyInit1(flags int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0) + success = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Klogctl(typ int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listxattr(path string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(dest) > 0 { + _p1 = unsafe.Pointer(&dest[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest))) + use(unsafe.Pointer(_p0)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdirat(dirfd int, path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func PivotRoot(newroot string, putold string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(newroot) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(putold) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_PIVOT_ROOT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { + _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(newlimit)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Removexattr(path string, attr string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setdomainname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETDOMAINNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sethostname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETHOSTNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setns(fd int, nstype int) (err error) { + _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setxattr(path string, attr string, data []byte, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(data) > 0 { + _p2 = unsafe.Pointer(&data[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() { + Syscall(SYS_SYNC, 0, 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sysinfo(info *Sysinfo_t) (err error) { + _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Times(tms *Tms) (ticks uintptr, err error) { + r0, _, e1 := RawSyscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0) + ticks = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(mask int) (oldmask int) { + r0, _, _ := RawSyscall(SYS_UMASK, uintptr(mask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Uname(buf *Utsname) (err error) { + _, _, e1 := RawSyscall(SYS_UNAME, uintptr(unsafe.Pointer(buf)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(target string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(target) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unshare(flags int) (err error) { + _, _, e1 := Syscall(SYS_UNSHARE, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ustat(dev int, ubuf *Ustat_t) (err error) { + _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func exitThread(code int) (err error) { + _, _, e1 := Syscall(SYS_EXIT, uintptr(code), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Madvise(b []byte, advice int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { + var _p0 unsafe.Pointer + if len(events) > 0 { + _p0 = unsafe.Pointer(&events[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_EPOLL_PWAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FSTATAT, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, buf *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (euid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + euid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, n int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (off int64, err error) { + r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence)) + off = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { + r0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0) + written = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsgid(gid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsuid(uid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresgid(rgid int, egid int, sgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresuid(ruid int, euid int, suid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, buf *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func SyncFileRange(fd int, off int64, n int64, flags int) (err error) { + _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { + r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(n int, list *_Gid_t) (nn int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + nn = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(n int, list *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { + r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset)) + xaddr = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_mips64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_mips64.go new file mode 100644 index 0000000000..738c830914 --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_mips64.go @@ -0,0 +1,1781 @@ +// mksyscall.pl syscall_linux.go syscall_linux_mips64x.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build mips64,linux + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, times *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getcwd(buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETCWD, uintptr(_p0), uintptr(len(buf)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(arg) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(source) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(target) + if err != nil { + return + } + var _p2 *byte + _p2, err = BytePtrFromString(fstype) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(flags), uintptr(unsafe.Pointer(data)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + use(unsafe.Pointer(_p2)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Acct(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtimex(buf *Timex) (state int, err error) { + r0, _, e1 := Syscall(SYS_ADJTIMEX, uintptr(unsafe.Pointer(buf)), 0, 0) + state = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ClockGettime(clockid int32, time *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(oldfd int) (fd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup3(oldfd int, newfd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate(size int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate1(flag int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE1, uintptr(flag), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) { + _, _, e1 := RawSyscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fallocate(fd int, mode uint32, off int64, len int64) (err error) { + _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(len), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fdatasync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdents(fd int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettid() (tid int) { + r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0) + tid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getxattr(path string, attr string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(dest) > 0 { + _p2 = unsafe.Pointer(&dest[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(pathname) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(mask)) + use(unsafe.Pointer(_p0)) + watchdesc = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyInit1(flags int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0) + success = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Klogctl(typ int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listxattr(path string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(dest) > 0 { + _p1 = unsafe.Pointer(&dest[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest))) + use(unsafe.Pointer(_p0)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdirat(dirfd int, path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func PivotRoot(newroot string, putold string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(newroot) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(putold) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_PIVOT_ROOT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { + _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(newlimit)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Removexattr(path string, attr string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setdomainname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETDOMAINNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sethostname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETHOSTNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setns(fd int, nstype int) (err error) { + _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setxattr(path string, attr string, data []byte, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(data) > 0 { + _p2 = unsafe.Pointer(&data[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() { + Syscall(SYS_SYNC, 0, 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sysinfo(info *Sysinfo_t) (err error) { + _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Times(tms *Tms) (ticks uintptr, err error) { + r0, _, e1 := RawSyscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0) + ticks = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(mask int) (oldmask int) { + r0, _, _ := RawSyscall(SYS_UMASK, uintptr(mask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Uname(buf *Utsname) (err error) { + _, _, e1 := RawSyscall(SYS_UNAME, uintptr(unsafe.Pointer(buf)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(target string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(target) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unshare(flags int) (err error) { + _, _, e1 := Syscall(SYS_UNSHARE, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ustat(dev int, ubuf *Ustat_t) (err error) { + _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func exitThread(code int) (err error) { + _, _, e1 := Syscall(SYS_EXIT, uintptr(code), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Madvise(b []byte, advice int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { + var _p0 unsafe.Pointer + if len(events) > 0 { + _p0 = unsafe.Pointer(&events[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, buf *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (euid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + euid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, n int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pause() (err error) { + _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (off int64, err error) { + r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence)) + off = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { + r0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0) + written = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsgid(gid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsuid(uid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresgid(rgid int, egid int, sgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresuid(ruid int, euid int, suid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, buf *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func SyncFileRange(fd int, off int64, n int64, flags int) (err error) { + _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { + r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(n int, list *_Gid_t) (nn int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + nn = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(n int, list *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { + r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset)) + xaddr = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Utime(path string, buf *Utimbuf) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fstat(fd int, st *stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(st)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func lstat(path string, st *stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(st)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func stat(path string, st *stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(st)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_mips64le.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_mips64le.go new file mode 100644 index 0000000000..2a03578322 --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_mips64le.go @@ -0,0 +1,1781 @@ +// mksyscall.pl syscall_linux.go syscall_linux_mips64x.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build mips64le,linux + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, times *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getcwd(buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETCWD, uintptr(_p0), uintptr(len(buf)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(arg) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(source) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(target) + if err != nil { + return + } + var _p2 *byte + _p2, err = BytePtrFromString(fstype) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(flags), uintptr(unsafe.Pointer(data)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + use(unsafe.Pointer(_p2)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Acct(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtimex(buf *Timex) (state int, err error) { + r0, _, e1 := Syscall(SYS_ADJTIMEX, uintptr(unsafe.Pointer(buf)), 0, 0) + state = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ClockGettime(clockid int32, time *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(oldfd int) (fd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup3(oldfd int, newfd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate(size int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate1(flag int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE1, uintptr(flag), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) { + _, _, e1 := RawSyscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fallocate(fd int, mode uint32, off int64, len int64) (err error) { + _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(len), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fdatasync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdents(fd int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettid() (tid int) { + r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0) + tid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getxattr(path string, attr string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(dest) > 0 { + _p2 = unsafe.Pointer(&dest[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(pathname) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(mask)) + use(unsafe.Pointer(_p0)) + watchdesc = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyInit1(flags int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0) + success = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Klogctl(typ int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listxattr(path string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(dest) > 0 { + _p1 = unsafe.Pointer(&dest[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest))) + use(unsafe.Pointer(_p0)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdirat(dirfd int, path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func PivotRoot(newroot string, putold string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(newroot) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(putold) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_PIVOT_ROOT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { + _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(newlimit)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Removexattr(path string, attr string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setdomainname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETDOMAINNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sethostname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETHOSTNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setns(fd int, nstype int) (err error) { + _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setxattr(path string, attr string, data []byte, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(data) > 0 { + _p2 = unsafe.Pointer(&data[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() { + Syscall(SYS_SYNC, 0, 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sysinfo(info *Sysinfo_t) (err error) { + _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Times(tms *Tms) (ticks uintptr, err error) { + r0, _, e1 := RawSyscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0) + ticks = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(mask int) (oldmask int) { + r0, _, _ := RawSyscall(SYS_UMASK, uintptr(mask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Uname(buf *Utsname) (err error) { + _, _, e1 := RawSyscall(SYS_UNAME, uintptr(unsafe.Pointer(buf)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(target string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(target) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unshare(flags int) (err error) { + _, _, e1 := Syscall(SYS_UNSHARE, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ustat(dev int, ubuf *Ustat_t) (err error) { + _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func exitThread(code int) (err error) { + _, _, e1 := Syscall(SYS_EXIT, uintptr(code), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Madvise(b []byte, advice int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { + var _p0 unsafe.Pointer + if len(events) > 0 { + _p0 = unsafe.Pointer(&events[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, buf *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (euid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + euid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, n int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pause() (err error) { + _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (off int64, err error) { + r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence)) + off = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { + r0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0) + written = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsgid(gid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsuid(uid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresgid(rgid int, egid int, sgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresuid(ruid int, euid int, suid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, buf *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func SyncFileRange(fd int, off int64, n int64, flags int) (err error) { + _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { + r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(n int, list *_Gid_t) (nn int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + nn = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(n int, list *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { + r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset)) + xaddr = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Utime(path string, buf *Utimbuf) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fstat(fd int, st *stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(st)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func lstat(path string, st *stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(st)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func stat(path string, st *stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(st)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_ppc64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_ppc64.go new file mode 100644 index 0000000000..4bd18dcee6 --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_ppc64.go @@ -0,0 +1,1843 @@ +// mksyscall.pl syscall_linux.go syscall_linux_ppc64x.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build ppc64,linux + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, times *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getcwd(buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETCWD, uintptr(_p0), uintptr(len(buf)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(arg) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(source) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(target) + if err != nil { + return + } + var _p2 *byte + _p2, err = BytePtrFromString(fstype) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(flags), uintptr(unsafe.Pointer(data)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + use(unsafe.Pointer(_p2)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Acct(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtimex(buf *Timex) (state int, err error) { + r0, _, e1 := Syscall(SYS_ADJTIMEX, uintptr(unsafe.Pointer(buf)), 0, 0) + state = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ClockGettime(clockid int32, time *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(oldfd int) (fd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup3(oldfd int, newfd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate(size int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate1(flag int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE1, uintptr(flag), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) { + _, _, e1 := RawSyscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fallocate(fd int, mode uint32, off int64, len int64) (err error) { + _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(len), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fdatasync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdents(fd int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettid() (tid int) { + r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0) + tid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getxattr(path string, attr string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(dest) > 0 { + _p2 = unsafe.Pointer(&dest[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(pathname) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(mask)) + use(unsafe.Pointer(_p0)) + watchdesc = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyInit1(flags int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0) + success = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Klogctl(typ int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listxattr(path string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(dest) > 0 { + _p1 = unsafe.Pointer(&dest[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest))) + use(unsafe.Pointer(_p0)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdirat(dirfd int, path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func PivotRoot(newroot string, putold string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(newroot) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(putold) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_PIVOT_ROOT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { + _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(newlimit)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Removexattr(path string, attr string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setdomainname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETDOMAINNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sethostname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETHOSTNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setns(fd int, nstype int) (err error) { + _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setxattr(path string, attr string, data []byte, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(data) > 0 { + _p2 = unsafe.Pointer(&data[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() { + Syscall(SYS_SYNC, 0, 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sysinfo(info *Sysinfo_t) (err error) { + _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Times(tms *Tms) (ticks uintptr, err error) { + r0, _, e1 := RawSyscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0) + ticks = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(mask int) (oldmask int) { + r0, _, _ := RawSyscall(SYS_UMASK, uintptr(mask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Uname(buf *Utsname) (err error) { + _, _, e1 := RawSyscall(SYS_UNAME, uintptr(unsafe.Pointer(buf)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(target string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(target) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unshare(flags int) (err error) { + _, _, e1 := Syscall(SYS_UNSHARE, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ustat(dev int, ubuf *Ustat_t) (err error) { + _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func exitThread(code int) (err error) { + _, _, e1 := Syscall(SYS_EXIT, uintptr(code), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Madvise(b []byte, advice int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { + var _p0 unsafe.Pointer + if len(events) > 0 { + _p0 = unsafe.Pointer(&events[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(oldfd int, newfd int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, buf *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (euid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + euid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_UGETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyInit() (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ioperm(from int, num int, on int) (err error) { + _, _, e1 := Syscall(SYS_IOPERM, uintptr(from), uintptr(num), uintptr(on)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Iopl(level int) (err error) { + _, _, e1 := Syscall(SYS_IOPL, uintptr(level), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, n int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pause() (err error) { + _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (off int64, err error) { + r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence)) + off = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { + r0, _, e1 := Syscall6(SYS_SELECT, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0) + written = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsgid(gid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsuid(uid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresgid(rgid int, egid int, sgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresuid(ruid int, euid int, suid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, buf *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func SyncFileRange(fd int, off int64, n int64, flags int) (err error) { + _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE2, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { + r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(n int, list *_Gid_t) (nn int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + nn = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(n int, list *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { + r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset)) + xaddr = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Time(t *Time_t) (tt Time_t, err error) { + r0, _, e1 := RawSyscall(SYS_TIME, uintptr(unsafe.Pointer(t)), 0, 0) + tt = Time_t(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Utime(path string, buf *Utimbuf) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe(p *[2]_C_int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go new file mode 100644 index 0000000000..fbb43516cc --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go @@ -0,0 +1,1843 @@ +// mksyscall.pl syscall_linux.go syscall_linux_ppc64x.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build ppc64le,linux + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, times *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getcwd(buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETCWD, uintptr(_p0), uintptr(len(buf)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(arg) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(source) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(target) + if err != nil { + return + } + var _p2 *byte + _p2, err = BytePtrFromString(fstype) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(flags), uintptr(unsafe.Pointer(data)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + use(unsafe.Pointer(_p2)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Acct(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtimex(buf *Timex) (state int, err error) { + r0, _, e1 := Syscall(SYS_ADJTIMEX, uintptr(unsafe.Pointer(buf)), 0, 0) + state = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ClockGettime(clockid int32, time *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(oldfd int) (fd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup3(oldfd int, newfd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate(size int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate1(flag int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE1, uintptr(flag), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) { + _, _, e1 := RawSyscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fallocate(fd int, mode uint32, off int64, len int64) (err error) { + _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(len), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fdatasync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdents(fd int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettid() (tid int) { + r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0) + tid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getxattr(path string, attr string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(dest) > 0 { + _p2 = unsafe.Pointer(&dest[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(pathname) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(mask)) + use(unsafe.Pointer(_p0)) + watchdesc = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyInit1(flags int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0) + success = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Klogctl(typ int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listxattr(path string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(dest) > 0 { + _p1 = unsafe.Pointer(&dest[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest))) + use(unsafe.Pointer(_p0)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdirat(dirfd int, path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func PivotRoot(newroot string, putold string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(newroot) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(putold) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_PIVOT_ROOT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { + _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(newlimit)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Removexattr(path string, attr string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setdomainname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETDOMAINNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sethostname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETHOSTNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setns(fd int, nstype int) (err error) { + _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setxattr(path string, attr string, data []byte, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(data) > 0 { + _p2 = unsafe.Pointer(&data[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() { + Syscall(SYS_SYNC, 0, 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sysinfo(info *Sysinfo_t) (err error) { + _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Times(tms *Tms) (ticks uintptr, err error) { + r0, _, e1 := RawSyscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0) + ticks = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(mask int) (oldmask int) { + r0, _, _ := RawSyscall(SYS_UMASK, uintptr(mask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Uname(buf *Utsname) (err error) { + _, _, e1 := RawSyscall(SYS_UNAME, uintptr(unsafe.Pointer(buf)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(target string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(target) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unshare(flags int) (err error) { + _, _, e1 := Syscall(SYS_UNSHARE, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ustat(dev int, ubuf *Ustat_t) (err error) { + _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func exitThread(code int) (err error) { + _, _, e1 := Syscall(SYS_EXIT, uintptr(code), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Madvise(b []byte, advice int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { + var _p0 unsafe.Pointer + if len(events) > 0 { + _p0 = unsafe.Pointer(&events[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(oldfd int, newfd int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, buf *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (euid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + euid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_UGETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyInit() (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ioperm(from int, num int, on int) (err error) { + _, _, e1 := Syscall(SYS_IOPERM, uintptr(from), uintptr(num), uintptr(on)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Iopl(level int) (err error) { + _, _, e1 := Syscall(SYS_IOPL, uintptr(level), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, n int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pause() (err error) { + _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (off int64, err error) { + r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence)) + off = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { + r0, _, e1 := Syscall6(SYS_SELECT, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0) + written = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsgid(gid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsuid(uid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresgid(rgid int, egid int, sgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresuid(ruid int, euid int, suid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, buf *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func SyncFileRange(fd int, off int64, n int64, flags int) (err error) { + _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE2, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { + r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(n int, list *_Gid_t) (nn int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + nn = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(n int, list *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { + r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset)) + xaddr = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Time(t *Time_t) (tt Time_t, err error) { + r0, _, e1 := RawSyscall(SYS_TIME, uintptr(unsafe.Pointer(t)), 0, 0) + tt = Time_t(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Utime(path string, buf *Utimbuf) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe(p *[2]_C_int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_s390x.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_s390x.go new file mode 100644 index 0000000000..f8aa91f149 --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_s390x.go @@ -0,0 +1,1623 @@ +// mksyscall.pl syscall_linux.go syscall_linux_s390x.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build s390x,linux + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, times *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getcwd(buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETCWD, uintptr(_p0), uintptr(len(buf)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(arg) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(source) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(target) + if err != nil { + return + } + var _p2 *byte + _p2, err = BytePtrFromString(fstype) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(flags), uintptr(unsafe.Pointer(data)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + use(unsafe.Pointer(_p2)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Acct(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtimex(buf *Timex) (state int, err error) { + r0, _, e1 := Syscall(SYS_ADJTIMEX, uintptr(unsafe.Pointer(buf)), 0, 0) + state = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ClockGettime(clockid int32, time *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(oldfd int) (fd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup3(oldfd int, newfd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate(size int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate1(flag int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE1, uintptr(flag), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) { + _, _, e1 := RawSyscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fallocate(fd int, mode uint32, off int64, len int64) (err error) { + _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(len), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fdatasync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdents(fd int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettid() (tid int) { + r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0) + tid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getxattr(path string, attr string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(dest) > 0 { + _p2 = unsafe.Pointer(&dest[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(pathname) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(mask)) + use(unsafe.Pointer(_p0)) + watchdesc = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyInit1(flags int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0) + success = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Klogctl(typ int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listxattr(path string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(dest) > 0 { + _p1 = unsafe.Pointer(&dest[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest))) + use(unsafe.Pointer(_p0)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdirat(dirfd int, path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func PivotRoot(newroot string, putold string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(newroot) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(putold) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_PIVOT_ROOT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { + _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(newlimit)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Removexattr(path string, attr string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setdomainname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETDOMAINNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sethostname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETHOSTNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setns(fd int, nstype int) (err error) { + _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setxattr(path string, attr string, data []byte, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(data) > 0 { + _p2 = unsafe.Pointer(&data[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() { + Syscall(SYS_SYNC, 0, 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sysinfo(info *Sysinfo_t) (err error) { + _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Times(tms *Tms) (ticks uintptr, err error) { + r0, _, e1 := RawSyscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0) + ticks = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(mask int) (oldmask int) { + r0, _, _ := RawSyscall(SYS_UMASK, uintptr(mask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Uname(buf *Utsname) (err error) { + _, _, e1 := RawSyscall(SYS_UNAME, uintptr(unsafe.Pointer(buf)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(target string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(target) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unshare(flags int) (err error) { + _, _, e1 := Syscall(SYS_UNSHARE, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ustat(dev int, ubuf *Ustat_t) (err error) { + _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func exitThread(code int) (err error) { + _, _, e1 := Syscall(SYS_EXIT, uintptr(code), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Madvise(b []byte, advice int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(oldfd int, newfd int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { + var _p0 unsafe.Pointer + if len(events) > 0 { + _p0 = unsafe.Pointer(&events[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fadvise(fd int, offset int64, length int64, advice int) (err error) { + _, _, e1 := Syscall6(SYS_FADVISE64, uintptr(fd), uintptr(offset), uintptr(length), uintptr(advice), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, buf *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (euid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + euid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyInit() (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pause() (err error) { + _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (off int64, err error) { + r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence)) + off = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { + r0, _, e1 := Syscall6(SYS_SELECT, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0) + written = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsgid(gid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsuid(uid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresgid(rgid int, egid int, sgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresuid(ruid int, euid int, suid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, buf *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func SyncFileRange(fd int, off int64, n int64, flags int) (err error) { + _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(n int, list *_Gid_t) (nn int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + nn = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(n int, list *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Utime(path string, buf *Utimbuf) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_netbsd_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_netbsd_386.go index 2dde52ae6b..b16e1d0ee3 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_netbsd_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_netbsd_386.go @@ -1,6 +1,8 @@ // mksyscall.pl -l32 -netbsd syscall_bsd.go syscall_netbsd.go syscall_netbsd_386.go // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build 386,netbsd + package unix import ( @@ -220,6 +222,7 @@ func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + use(_p0) if e1 != 0 { err = errnoErr(e1) } diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go index b16c66ced3..b63667da9c 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go @@ -1,6 +1,8 @@ // mksyscall.pl -netbsd syscall_bsd.go syscall_netbsd.go syscall_netbsd_amd64.go // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build amd64,netbsd + package unix import ( @@ -220,6 +222,7 @@ func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + use(_p0) if e1 != 0 { err = errnoErr(e1) } diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_netbsd_arm.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_netbsd_arm.go index cae18cabd3..b0d19038d2 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_netbsd_arm.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_netbsd_arm.go @@ -1,6 +1,8 @@ // mksyscall.pl -l32 -arm syscall_bsd.go syscall_netbsd.go syscall_netbsd_arm.go // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build arm,netbsd + package unix import ( @@ -220,6 +222,7 @@ func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + use(_p0) if e1 != 0 { err = errnoErr(e1) } diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_openbsd_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_openbsd_386.go index e9ec117441..f91a5b8564 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_openbsd_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_openbsd_386.go @@ -1,6 +1,8 @@ // mksyscall.pl -l32 -openbsd syscall_bsd.go syscall_openbsd.go syscall_openbsd_386.go // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build 386,openbsd + package unix import ( @@ -220,6 +222,7 @@ func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + use(_p0) if e1 != 0 { err = errnoErr(e1) } diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go index 3c8535f4d2..2e8d59d724 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go @@ -1,6 +1,8 @@ // mksyscall.pl -openbsd syscall_bsd.go syscall_openbsd.go syscall_openbsd_amd64.go // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build amd64,openbsd + package unix import ( @@ -220,6 +222,7 @@ func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + use(_p0) if e1 != 0 { err = errnoErr(e1) } diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_solaris_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_solaris_amd64.go index 9ee51e3e3a..4326427817 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_solaris_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_solaris_amd64.go @@ -1,98 +1,385 @@ // mksyscall_solaris.pl syscall_solaris.go syscall_solaris_amd64.go // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// +build amd64,solaris + package unix -import "unsafe" +import ( + "syscall" + "unsafe" +) + +//go:cgo_import_dynamic libc_getsockname getsockname "libsocket.so" +//go:cgo_import_dynamic libc_getcwd getcwd "libc.so" +//go:cgo_import_dynamic libc_getgroups getgroups "libc.so" +//go:cgo_import_dynamic libc_setgroups setgroups "libc.so" +//go:cgo_import_dynamic libc_utimes utimes "libc.so" +//go:cgo_import_dynamic libc_utimensat utimensat "libc.so" +//go:cgo_import_dynamic libc_fcntl fcntl "libc.so" +//go:cgo_import_dynamic libc_futimesat futimesat "libc.so" +//go:cgo_import_dynamic libc_accept accept "libsocket.so" +//go:cgo_import_dynamic libc_recvmsg recvmsg "libsocket.so" +//go:cgo_import_dynamic libc_sendmsg sendmsg "libsocket.so" +//go:cgo_import_dynamic libc_acct acct "libc.so" +//go:cgo_import_dynamic libc_ioctl ioctl "libc.so" +//go:cgo_import_dynamic libc_access access "libc.so" +//go:cgo_import_dynamic libc_adjtime adjtime "libc.so" +//go:cgo_import_dynamic libc_chdir chdir "libc.so" +//go:cgo_import_dynamic libc_chmod chmod "libc.so" +//go:cgo_import_dynamic libc_chown chown "libc.so" +//go:cgo_import_dynamic libc_chroot chroot "libc.so" +//go:cgo_import_dynamic libc_close close "libc.so" +//go:cgo_import_dynamic libc_creat creat "libc.so" +//go:cgo_import_dynamic libc_dup dup "libc.so" +//go:cgo_import_dynamic libc_dup2 dup2 "libc.so" +//go:cgo_import_dynamic libc_exit exit "libc.so" +//go:cgo_import_dynamic libc_fchdir fchdir "libc.so" +//go:cgo_import_dynamic libc_fchmod fchmod "libc.so" +//go:cgo_import_dynamic libc_fchmodat fchmodat "libc.so" +//go:cgo_import_dynamic libc_fchown fchown "libc.so" +//go:cgo_import_dynamic libc_fchownat fchownat "libc.so" +//go:cgo_import_dynamic libc_fdatasync fdatasync "libc.so" +//go:cgo_import_dynamic libc_fpathconf fpathconf "libc.so" +//go:cgo_import_dynamic libc_fstat fstat "libc.so" +//go:cgo_import_dynamic libc_getdents getdents "libc.so" +//go:cgo_import_dynamic libc_getgid getgid "libc.so" +//go:cgo_import_dynamic libc_getpid getpid "libc.so" +//go:cgo_import_dynamic libc_getpgid getpgid "libc.so" +//go:cgo_import_dynamic libc_getpgrp getpgrp "libc.so" +//go:cgo_import_dynamic libc_geteuid geteuid "libc.so" +//go:cgo_import_dynamic libc_getegid getegid "libc.so" +//go:cgo_import_dynamic libc_getppid getppid "libc.so" +//go:cgo_import_dynamic libc_getpriority getpriority "libc.so" +//go:cgo_import_dynamic libc_getrlimit getrlimit "libc.so" +//go:cgo_import_dynamic libc_getrusage getrusage "libc.so" +//go:cgo_import_dynamic libc_gettimeofday gettimeofday "libc.so" +//go:cgo_import_dynamic libc_getuid getuid "libc.so" +//go:cgo_import_dynamic libc_kill kill "libc.so" +//go:cgo_import_dynamic libc_lchown lchown "libc.so" +//go:cgo_import_dynamic libc_link link "libc.so" +//go:cgo_import_dynamic libc_listen listen "libsocket.so" +//go:cgo_import_dynamic libc_lstat lstat "libc.so" +//go:cgo_import_dynamic libc_madvise madvise "libc.so" +//go:cgo_import_dynamic libc_mkdir mkdir "libc.so" +//go:cgo_import_dynamic libc_mkdirat mkdirat "libc.so" +//go:cgo_import_dynamic libc_mkfifo mkfifo "libc.so" +//go:cgo_import_dynamic libc_mkfifoat mkfifoat "libc.so" +//go:cgo_import_dynamic libc_mknod mknod "libc.so" +//go:cgo_import_dynamic libc_mknodat mknodat "libc.so" +//go:cgo_import_dynamic libc_mlock mlock "libc.so" +//go:cgo_import_dynamic libc_mlockall mlockall "libc.so" +//go:cgo_import_dynamic libc_mprotect mprotect "libc.so" +//go:cgo_import_dynamic libc_munlock munlock "libc.so" +//go:cgo_import_dynamic libc_munlockall munlockall "libc.so" +//go:cgo_import_dynamic libc_nanosleep nanosleep "libc.so" +//go:cgo_import_dynamic libc_open open "libc.so" +//go:cgo_import_dynamic libc_openat openat "libc.so" +//go:cgo_import_dynamic libc_pathconf pathconf "libc.so" +//go:cgo_import_dynamic libc_pause pause "libc.so" +//go:cgo_import_dynamic libc_pread pread "libc.so" +//go:cgo_import_dynamic libc_pwrite pwrite "libc.so" +//go:cgo_import_dynamic libc_read read "libc.so" +//go:cgo_import_dynamic libc_readlink readlink "libc.so" +//go:cgo_import_dynamic libc_rename rename "libc.so" +//go:cgo_import_dynamic libc_renameat renameat "libc.so" +//go:cgo_import_dynamic libc_rmdir rmdir "libc.so" +//go:cgo_import_dynamic libc_lseek lseek "libc.so" +//go:cgo_import_dynamic libc_setegid setegid "libc.so" +//go:cgo_import_dynamic libc_seteuid seteuid "libc.so" +//go:cgo_import_dynamic libc_setgid setgid "libc.so" +//go:cgo_import_dynamic libc_sethostname sethostname "libc.so" +//go:cgo_import_dynamic libc_setpgid setpgid "libc.so" +//go:cgo_import_dynamic libc_setpriority setpriority "libc.so" +//go:cgo_import_dynamic libc_setregid setregid "libc.so" +//go:cgo_import_dynamic libc_setreuid setreuid "libc.so" +//go:cgo_import_dynamic libc_setrlimit setrlimit "libc.so" +//go:cgo_import_dynamic libc_setsid setsid "libc.so" +//go:cgo_import_dynamic libc_setuid setuid "libc.so" +//go:cgo_import_dynamic libc_shutdown shutdown "libsocket.so" +//go:cgo_import_dynamic libc_stat stat "libc.so" +//go:cgo_import_dynamic libc_symlink symlink "libc.so" +//go:cgo_import_dynamic libc_sync sync "libc.so" +//go:cgo_import_dynamic libc_times times "libc.so" +//go:cgo_import_dynamic libc_truncate truncate "libc.so" +//go:cgo_import_dynamic libc_fsync fsync "libc.so" +//go:cgo_import_dynamic libc_ftruncate ftruncate "libc.so" +//go:cgo_import_dynamic libc_umask umask "libc.so" +//go:cgo_import_dynamic libc_uname uname "libc.so" +//go:cgo_import_dynamic libc_umount umount "libc.so" +//go:cgo_import_dynamic libc_unlink unlink "libc.so" +//go:cgo_import_dynamic libc_unlinkat unlinkat "libc.so" +//go:cgo_import_dynamic libc_ustat ustat "libc.so" +//go:cgo_import_dynamic libc_utime utime "libc.so" +//go:cgo_import_dynamic libc_bind bind "libsocket.so" +//go:cgo_import_dynamic libc_connect connect "libsocket.so" +//go:cgo_import_dynamic libc_mmap mmap "libc.so" +//go:cgo_import_dynamic libc_munmap munmap "libc.so" +//go:cgo_import_dynamic libc_sendto sendto "libsocket.so" +//go:cgo_import_dynamic libc_socket socket "libsocket.so" +//go:cgo_import_dynamic libc_socketpair socketpair "libsocket.so" +//go:cgo_import_dynamic libc_write write "libc.so" +//go:cgo_import_dynamic libc_getsockopt getsockopt "libsocket.so" +//go:cgo_import_dynamic libc_getpeername getpeername "libsocket.so" +//go:cgo_import_dynamic libc_setsockopt setsockopt "libsocket.so" +//go:cgo_import_dynamic libc_recvfrom recvfrom "libsocket.so" +//go:cgo_import_dynamic libc_sysconf sysconf "libc.so" + +//go:linkname procgetsockname libc_getsockname +//go:linkname procGetcwd libc_getcwd +//go:linkname procgetgroups libc_getgroups +//go:linkname procsetgroups libc_setgroups +//go:linkname procutimes libc_utimes +//go:linkname procutimensat libc_utimensat +//go:linkname procfcntl libc_fcntl +//go:linkname procfutimesat libc_futimesat +//go:linkname procaccept libc_accept +//go:linkname procrecvmsg libc_recvmsg +//go:linkname procsendmsg libc_sendmsg +//go:linkname procacct libc_acct +//go:linkname procioctl libc_ioctl +//go:linkname procAccess libc_access +//go:linkname procAdjtime libc_adjtime +//go:linkname procChdir libc_chdir +//go:linkname procChmod libc_chmod +//go:linkname procChown libc_chown +//go:linkname procChroot libc_chroot +//go:linkname procClose libc_close +//go:linkname procCreat libc_creat +//go:linkname procDup libc_dup +//go:linkname procDup2 libc_dup2 +//go:linkname procExit libc_exit +//go:linkname procFchdir libc_fchdir +//go:linkname procFchmod libc_fchmod +//go:linkname procFchmodat libc_fchmodat +//go:linkname procFchown libc_fchown +//go:linkname procFchownat libc_fchownat +//go:linkname procFdatasync libc_fdatasync +//go:linkname procFpathconf libc_fpathconf +//go:linkname procFstat libc_fstat +//go:linkname procGetdents libc_getdents +//go:linkname procGetgid libc_getgid +//go:linkname procGetpid libc_getpid +//go:linkname procGetpgid libc_getpgid +//go:linkname procGetpgrp libc_getpgrp +//go:linkname procGeteuid libc_geteuid +//go:linkname procGetegid libc_getegid +//go:linkname procGetppid libc_getppid +//go:linkname procGetpriority libc_getpriority +//go:linkname procGetrlimit libc_getrlimit +//go:linkname procGetrusage libc_getrusage +//go:linkname procGettimeofday libc_gettimeofday +//go:linkname procGetuid libc_getuid +//go:linkname procKill libc_kill +//go:linkname procLchown libc_lchown +//go:linkname procLink libc_link +//go:linkname proclisten libc_listen +//go:linkname procLstat libc_lstat +//go:linkname procMadvise libc_madvise +//go:linkname procMkdir libc_mkdir +//go:linkname procMkdirat libc_mkdirat +//go:linkname procMkfifo libc_mkfifo +//go:linkname procMkfifoat libc_mkfifoat +//go:linkname procMknod libc_mknod +//go:linkname procMknodat libc_mknodat +//go:linkname procMlock libc_mlock +//go:linkname procMlockall libc_mlockall +//go:linkname procMprotect libc_mprotect +//go:linkname procMunlock libc_munlock +//go:linkname procMunlockall libc_munlockall +//go:linkname procNanosleep libc_nanosleep +//go:linkname procOpen libc_open +//go:linkname procOpenat libc_openat +//go:linkname procPathconf libc_pathconf +//go:linkname procPause libc_pause +//go:linkname procPread libc_pread +//go:linkname procPwrite libc_pwrite +//go:linkname procread libc_read +//go:linkname procReadlink libc_readlink +//go:linkname procRename libc_rename +//go:linkname procRenameat libc_renameat +//go:linkname procRmdir libc_rmdir +//go:linkname proclseek libc_lseek +//go:linkname procSetegid libc_setegid +//go:linkname procSeteuid libc_seteuid +//go:linkname procSetgid libc_setgid +//go:linkname procSethostname libc_sethostname +//go:linkname procSetpgid libc_setpgid +//go:linkname procSetpriority libc_setpriority +//go:linkname procSetregid libc_setregid +//go:linkname procSetreuid libc_setreuid +//go:linkname procSetrlimit libc_setrlimit +//go:linkname procSetsid libc_setsid +//go:linkname procSetuid libc_setuid +//go:linkname procshutdown libc_shutdown +//go:linkname procStat libc_stat +//go:linkname procSymlink libc_symlink +//go:linkname procSync libc_sync +//go:linkname procTimes libc_times +//go:linkname procTruncate libc_truncate +//go:linkname procFsync libc_fsync +//go:linkname procFtruncate libc_ftruncate +//go:linkname procUmask libc_umask +//go:linkname procUname libc_uname +//go:linkname procumount libc_umount +//go:linkname procUnlink libc_unlink +//go:linkname procUnlinkat libc_unlinkat +//go:linkname procUstat libc_ustat +//go:linkname procUtime libc_utime +//go:linkname procbind libc_bind +//go:linkname procconnect libc_connect +//go:linkname procmmap libc_mmap +//go:linkname procmunmap libc_munmap +//go:linkname procsendto libc_sendto +//go:linkname procsocket libc_socket +//go:linkname procsocketpair libc_socketpair +//go:linkname procwrite libc_write +//go:linkname procgetsockopt libc_getsockopt +//go:linkname procgetpeername libc_getpeername +//go:linkname procsetsockopt libc_setsockopt +//go:linkname procrecvfrom libc_recvfrom +//go:linkname procsysconf libc_sysconf var ( - modlibc = syscall.newLazySO("libc.so") - modlibsocket = syscall.newLazySO("libsocket.so") - - procgetgroups = modlibc.NewProc("getgroups") - procsetgroups = modlibc.NewProc("setgroups") - procfcntl = modlibc.NewProc("fcntl") - procaccept = modlibsocket.NewProc("accept") - procsendmsg = modlibsocket.NewProc("sendmsg") - procAccess = modlibc.NewProc("access") - procAdjtime = modlibc.NewProc("adjtime") - procChdir = modlibc.NewProc("chdir") - procChmod = modlibc.NewProc("chmod") - procChown = modlibc.NewProc("chown") - procChroot = modlibc.NewProc("chroot") - procClose = modlibc.NewProc("close") - procDup = modlibc.NewProc("dup") - procExit = modlibc.NewProc("exit") - procFchdir = modlibc.NewProc("fchdir") - procFchmod = modlibc.NewProc("fchmod") - procFchown = modlibc.NewProc("fchown") - procFpathconf = modlibc.NewProc("fpathconf") - procFstat = modlibc.NewProc("fstat") - procGetdents = modlibc.NewProc("getdents") - procGetgid = modlibc.NewProc("getgid") - procGetpid = modlibc.NewProc("getpid") - procGeteuid = modlibc.NewProc("geteuid") - procGetegid = modlibc.NewProc("getegid") - procGetppid = modlibc.NewProc("getppid") - procGetpriority = modlibc.NewProc("getpriority") - procGetrlimit = modlibc.NewProc("getrlimit") - procGettimeofday = modlibc.NewProc("gettimeofday") - procGetuid = modlibc.NewProc("getuid") - procKill = modlibc.NewProc("kill") - procLchown = modlibc.NewProc("lchown") - procLink = modlibc.NewProc("link") - proclisten = modlibsocket.NewProc("listen") - procLstat = modlibc.NewProc("lstat") - procMkdir = modlibc.NewProc("mkdir") - procMknod = modlibc.NewProc("mknod") - procNanosleep = modlibc.NewProc("nanosleep") - procOpen = modlibc.NewProc("open") - procPathconf = modlibc.NewProc("pathconf") - procPread = modlibc.NewProc("pread") - procPwrite = modlibc.NewProc("pwrite") - procread = modlibc.NewProc("read") - procReadlink = modlibc.NewProc("readlink") - procRename = modlibc.NewProc("rename") - procRmdir = modlibc.NewProc("rmdir") - proclseek = modlibc.NewProc("lseek") - procSetegid = modlibc.NewProc("setegid") - procSeteuid = modlibc.NewProc("seteuid") - procSetgid = modlibc.NewProc("setgid") - procSetpgid = modlibc.NewProc("setpgid") - procSetpriority = modlibc.NewProc("setpriority") - procSetregid = modlibc.NewProc("setregid") - procSetreuid = modlibc.NewProc("setreuid") - procSetrlimit = modlibc.NewProc("setrlimit") - procSetsid = modlibc.NewProc("setsid") - procSetuid = modlibc.NewProc("setuid") - procshutdown = modlibsocket.NewProc("shutdown") - procStat = modlibc.NewProc("stat") - procSymlink = modlibc.NewProc("symlink") - procSync = modlibc.NewProc("sync") - procTruncate = modlibc.NewProc("truncate") - procFsync = modlibc.NewProc("fsync") - procFtruncate = modlibc.NewProc("ftruncate") - procUmask = modlibc.NewProc("umask") - procUnlink = modlibc.NewProc("unlink") - procUtimes = modlibc.NewProc("utimes") - procbind = modlibsocket.NewProc("bind") - procconnect = modlibsocket.NewProc("connect") - procmmap = modlibc.NewProc("mmap") - procmunmap = modlibc.NewProc("munmap") - procsendto = modlibsocket.NewProc("sendto") - procsocket = modlibsocket.NewProc("socket") - procsocketpair = modlibsocket.NewProc("socketpair") - procwrite = modlibc.NewProc("write") - procgetsockopt = modlibsocket.NewProc("getsockopt") - procgetpeername = modlibsocket.NewProc("getpeername") - procgetsockname = modlibsocket.NewProc("getsockname") - procsetsockopt = modlibsocket.NewProc("setsockopt") - procrecvfrom = modlibsocket.NewProc("recvfrom") - procrecvmsg = modlibsocket.NewProc("recvmsg") + procgetsockname, + procGetcwd, + procgetgroups, + procsetgroups, + procutimes, + procutimensat, + procfcntl, + procfutimesat, + procaccept, + procrecvmsg, + procsendmsg, + procacct, + procioctl, + procAccess, + procAdjtime, + procChdir, + procChmod, + procChown, + procChroot, + procClose, + procCreat, + procDup, + procDup2, + procExit, + procFchdir, + procFchmod, + procFchmodat, + procFchown, + procFchownat, + procFdatasync, + procFpathconf, + procFstat, + procGetdents, + procGetgid, + procGetpid, + procGetpgid, + procGetpgrp, + procGeteuid, + procGetegid, + procGetppid, + procGetpriority, + procGetrlimit, + procGetrusage, + procGettimeofday, + procGetuid, + procKill, + procLchown, + procLink, + proclisten, + procLstat, + procMadvise, + procMkdir, + procMkdirat, + procMkfifo, + procMkfifoat, + procMknod, + procMknodat, + procMlock, + procMlockall, + procMprotect, + procMunlock, + procMunlockall, + procNanosleep, + procOpen, + procOpenat, + procPathconf, + procPause, + procPread, + procPwrite, + procread, + procReadlink, + procRename, + procRenameat, + procRmdir, + proclseek, + procSetegid, + procSeteuid, + procSetgid, + procSethostname, + procSetpgid, + procSetpriority, + procSetregid, + procSetreuid, + procSetrlimit, + procSetsid, + procSetuid, + procshutdown, + procStat, + procSymlink, + procSync, + procTimes, + procTruncate, + procFsync, + procFtruncate, + procUmask, + procUname, + procumount, + procUnlink, + procUnlinkat, + procUstat, + procUtime, + procbind, + procconnect, + procmmap, + procmunmap, + procsendto, + procsocket, + procsocketpair, + procwrite, + procgetsockopt, + procgetpeername, + procsetsockopt, + procrecvfrom, + procsysconf syscallFunc ) +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procgetsockname)), 3, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Getcwd(buf []byte) (n int, err error) { + var _p0 *byte + if len(buf) > 0 { + _p0 = &buf[0] + } + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procGetcwd)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), 0, 0, 0, 0) + n = int(r0) + if e1 != 0 { + err = e1 + } + return +} + func getgroups(ngid int, gid *_Gid_t) (n int, err error) { - r0, _, e1 := rawSysvicall6(procgetgroups.Addr(), 2, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0, 0, 0, 0) + r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procgetgroups)), 2, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0, 0, 0, 0) n = int(r0) if e1 != 0 { err = e1 @@ -101,7 +388,35 @@ func getgroups(ngid int, gid *_Gid_t) (n int, err error) { } func setgroups(ngid int, gid *_Gid_t) (err error) { - _, _, e1 := rawSysvicall6(procsetgroups.Addr(), 2, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0, 0, 0, 0) + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procsetgroups)), 2, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func utimes(path string, times *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procutimes)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0, 0, 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func utimensat(fd int, path string, times *[2]Timespec, flag int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procutimensat)), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flag), 0, 0) + use(unsafe.Pointer(_p0)) if e1 != 0 { err = e1 } @@ -109,7 +424,7 @@ func setgroups(ngid int, gid *_Gid_t) (err error) { } func fcntl(fd int, cmd int, arg int) (val int, err error) { - r0, _, e1 := sysvicall6(procfcntl.Addr(), 3, uintptr(fd), uintptr(cmd), uintptr(arg), 0, 0, 0) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procfcntl)), 3, uintptr(fd), uintptr(cmd), uintptr(arg), 0, 0, 0) val = int(r0) if e1 != 0 { err = e1 @@ -117,8 +432,16 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) { return } +func futimesat(fildes int, path *byte, times *[2]Timeval) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procfutimesat)), 3, uintptr(fildes), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times)), 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { - r0, _, e1 := sysvicall6(procaccept.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procaccept)), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0) fd = int(r0) if e1 != 0 { err = e1 @@ -126,8 +449,17 @@ func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { return } +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procrecvmsg)), 3, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags), 0, 0, 0) + n = int(r0) + if e1 != 0 { + err = e1 + } + return +} + func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { - r0, _, e1 := sysvicall6(procsendmsg.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags), 0, 0, 0) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procsendmsg)), 3, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags), 0, 0, 0) n = int(r0) if e1 != 0 { err = e1 @@ -135,13 +467,29 @@ func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { return } +func acct(path *byte) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procacct)), 1, uintptr(unsafe.Pointer(path)), 0, 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func ioctl(fd int, req int, arg uintptr) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procioctl)), 3, uintptr(fd), uintptr(req), uintptr(arg), 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + func Access(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - _, _, e1 := sysvicall6(procAccess.Addr(), 2, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procAccess)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0, 0, 0, 0) use(unsafe.Pointer(_p0)) if e1 != 0 { err = e1 @@ -150,7 +498,7 @@ func Access(path string, mode uint32) (err error) { } func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { - _, _, e1 := sysvicall6(procAdjtime.Addr(), 2, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procAdjtime)), 2, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0, 0, 0, 0) if e1 != 0 { err = e1 } @@ -163,7 +511,7 @@ func Chdir(path string) (err error) { if err != nil { return } - _, _, e1 := sysvicall6(procChdir.Addr(), 1, uintptr(unsafe.Pointer(_p0)), 0, 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procChdir)), 1, uintptr(unsafe.Pointer(_p0)), 0, 0, 0, 0, 0) use(unsafe.Pointer(_p0)) if e1 != 0 { err = e1 @@ -177,7 +525,7 @@ func Chmod(path string, mode uint32) (err error) { if err != nil { return } - _, _, e1 := sysvicall6(procChmod.Addr(), 2, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procChmod)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0, 0, 0, 0) use(unsafe.Pointer(_p0)) if e1 != 0 { err = e1 @@ -191,7 +539,7 @@ func Chown(path string, uid int, gid int) (err error) { if err != nil { return } - _, _, e1 := sysvicall6(procChown.Addr(), 3, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procChown)), 3, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), 0, 0, 0) use(unsafe.Pointer(_p0)) if e1 != 0 { err = e1 @@ -205,7 +553,7 @@ func Chroot(path string) (err error) { if err != nil { return } - _, _, e1 := sysvicall6(procChroot.Addr(), 1, uintptr(unsafe.Pointer(_p0)), 0, 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procChroot)), 1, uintptr(unsafe.Pointer(_p0)), 0, 0, 0, 0, 0) use(unsafe.Pointer(_p0)) if e1 != 0 { err = e1 @@ -214,7 +562,22 @@ func Chroot(path string) (err error) { } func Close(fd int) (err error) { - _, _, e1 := sysvicall6(procClose.Addr(), 1, uintptr(fd), 0, 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procClose)), 1, uintptr(fd), 0, 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Creat(path string, mode uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procCreat)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0, 0, 0, 0) + use(unsafe.Pointer(_p0)) + fd = int(r0) if e1 != 0 { err = e1 } @@ -222,7 +585,7 @@ func Close(fd int) (err error) { } func Dup(fd int) (nfd int, err error) { - r0, _, e1 := sysvicall6(procDup.Addr(), 1, uintptr(fd), 0, 0, 0, 0, 0) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procDup)), 1, uintptr(fd), 0, 0, 0, 0, 0) nfd = int(r0) if e1 != 0 { err = e1 @@ -230,13 +593,21 @@ func Dup(fd int) (nfd int, err error) { return } +func Dup2(oldfd int, newfd int) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procDup2)), 2, uintptr(oldfd), uintptr(newfd), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + func Exit(code int) { - sysvicall6(procExit.Addr(), 1, uintptr(code), 0, 0, 0, 0, 0) + sysvicall6(uintptr(unsafe.Pointer(&procExit)), 1, uintptr(code), 0, 0, 0, 0, 0) return } func Fchdir(fd int) (err error) { - _, _, e1 := sysvicall6(procFchdir.Addr(), 1, uintptr(fd), 0, 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFchdir)), 1, uintptr(fd), 0, 0, 0, 0, 0) if e1 != 0 { err = e1 } @@ -244,7 +615,21 @@ func Fchdir(fd int) (err error) { } func Fchmod(fd int, mode uint32) (err error) { - _, _, e1 := sysvicall6(procFchmod.Addr(), 2, uintptr(fd), uintptr(mode), 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFchmod)), 2, uintptr(fd), uintptr(mode), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFchmodat)), 4, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) if e1 != 0 { err = e1 } @@ -252,7 +637,29 @@ func Fchmod(fd int, mode uint32) (err error) { } func Fchown(fd int, uid int, gid int) (err error) { - _, _, e1 := sysvicall6(procFchown.Addr(), 3, uintptr(fd), uintptr(uid), uintptr(gid), 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFchown)), 3, uintptr(fd), uintptr(uid), uintptr(gid), 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFchownat)), 5, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Fdatasync(fd int) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFdatasync)), 1, uintptr(fd), 0, 0, 0, 0, 0) if e1 != 0 { err = e1 } @@ -260,7 +667,7 @@ func Fchown(fd int, uid int, gid int) (err error) { } func Fpathconf(fd int, name int) (val int, err error) { - r0, _, e1 := sysvicall6(procFpathconf.Addr(), 2, uintptr(fd), uintptr(name), 0, 0, 0, 0) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFpathconf)), 2, uintptr(fd), uintptr(name), 0, 0, 0, 0) val = int(r0) if e1 != 0 { err = e1 @@ -269,7 +676,7 @@ func Fpathconf(fd int, name int) (val int, err error) { } func Fstat(fd int, stat *Stat_t) (err error) { - _, _, e1 := sysvicall6(procFstat.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFstat)), 2, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0, 0, 0, 0) if e1 != 0 { err = e1 } @@ -281,7 +688,7 @@ func Getdents(fd int, buf []byte, basep *uintptr) (n int, err error) { if len(buf) > 0 { _p0 = &buf[0] } - r0, _, e1 := sysvicall6(procGetdents.Addr(), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procGetdents)), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0) n = int(r0) if e1 != 0 { err = e1 @@ -290,37 +697,55 @@ func Getdents(fd int, buf []byte, basep *uintptr) (n int, err error) { } func Getgid() (gid int) { - r0, _, _ := rawSysvicall6(procGetgid.Addr(), 0, 0, 0, 0, 0, 0, 0) + r0, _, _ := rawSysvicall6(uintptr(unsafe.Pointer(&procGetgid)), 0, 0, 0, 0, 0, 0, 0) gid = int(r0) return } func Getpid() (pid int) { - r0, _, _ := rawSysvicall6(procGetpid.Addr(), 0, 0, 0, 0, 0, 0, 0) + r0, _, _ := rawSysvicall6(uintptr(unsafe.Pointer(&procGetpid)), 0, 0, 0, 0, 0, 0, 0) pid = int(r0) return } +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procGetpgid)), 1, uintptr(pid), 0, 0, 0, 0, 0) + pgid = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func Getpgrp() (pgid int, err error) { + r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procGetpgrp)), 0, 0, 0, 0, 0, 0, 0) + pgid = int(r0) + if e1 != 0 { + err = e1 + } + return +} + func Geteuid() (euid int) { - r0, _, _ := sysvicall6(procGeteuid.Addr(), 0, 0, 0, 0, 0, 0, 0) + r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procGeteuid)), 0, 0, 0, 0, 0, 0, 0) euid = int(r0) return } func Getegid() (egid int) { - r0, _, _ := sysvicall6(procGetegid.Addr(), 0, 0, 0, 0, 0, 0, 0) + r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procGetegid)), 0, 0, 0, 0, 0, 0, 0) egid = int(r0) return } func Getppid() (ppid int) { - r0, _, _ := sysvicall6(procGetppid.Addr(), 0, 0, 0, 0, 0, 0, 0) + r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procGetppid)), 0, 0, 0, 0, 0, 0, 0) ppid = int(r0) return } func Getpriority(which int, who int) (n int, err error) { - r0, _, e1 := sysvicall6(procGetpriority.Addr(), 2, uintptr(which), uintptr(who), 0, 0, 0, 0) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procGetpriority)), 2, uintptr(which), uintptr(who), 0, 0, 0, 0) n = int(r0) if e1 != 0 { err = e1 @@ -329,7 +754,15 @@ func Getpriority(which int, who int) (n int, err error) { } func Getrlimit(which int, lim *Rlimit) (err error) { - _, _, e1 := rawSysvicall6(procGetrlimit.Addr(), 2, uintptr(which), uintptr(unsafe.Pointer(lim)), 0, 0, 0, 0) + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procGetrlimit)), 2, uintptr(which), uintptr(unsafe.Pointer(lim)), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procGetrusage)), 2, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0, 0, 0, 0) if e1 != 0 { err = e1 } @@ -337,7 +770,7 @@ func Getrlimit(which int, lim *Rlimit) (err error) { } func Gettimeofday(tv *Timeval) (err error) { - _, _, e1 := rawSysvicall6(procGettimeofday.Addr(), 1, uintptr(unsafe.Pointer(tv)), 0, 0, 0, 0, 0) + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procGettimeofday)), 1, uintptr(unsafe.Pointer(tv)), 0, 0, 0, 0, 0) if e1 != 0 { err = e1 } @@ -345,13 +778,13 @@ func Gettimeofday(tv *Timeval) (err error) { } func Getuid() (uid int) { - r0, _, _ := rawSysvicall6(procGetuid.Addr(), 0, 0, 0, 0, 0, 0, 0) + r0, _, _ := rawSysvicall6(uintptr(unsafe.Pointer(&procGetuid)), 0, 0, 0, 0, 0, 0, 0) uid = int(r0) return } func Kill(pid int, signum syscall.Signal) (err error) { - _, _, e1 := sysvicall6(procKill.Addr(), 2, uintptr(pid), uintptr(signum), 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procKill)), 2, uintptr(pid), uintptr(signum), 0, 0, 0, 0) if e1 != 0 { err = e1 } @@ -364,7 +797,7 @@ func Lchown(path string, uid int, gid int) (err error) { if err != nil { return } - _, _, e1 := sysvicall6(procLchown.Addr(), 3, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procLchown)), 3, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), 0, 0, 0) use(unsafe.Pointer(_p0)) if e1 != 0 { err = e1 @@ -383,7 +816,7 @@ func Link(path string, link string) (err error) { if err != nil { return } - _, _, e1 := sysvicall6(procLink.Addr(), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procLink)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0, 0, 0, 0) use(unsafe.Pointer(_p0)) use(unsafe.Pointer(_p1)) if e1 != 0 { @@ -393,7 +826,7 @@ func Link(path string, link string) (err error) { } func Listen(s int, backlog int) (err error) { - _, _, e1 := sysvicall6(proclisten.Addr(), 2, uintptr(s), uintptr(backlog), 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proclisten)), 2, uintptr(s), uintptr(backlog), 0, 0, 0, 0) if e1 != 0 { err = e1 } @@ -406,7 +839,7 @@ func Lstat(path string, stat *Stat_t) (err error) { if err != nil { return } - _, _, e1 := sysvicall6(procLstat.Addr(), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procLstat)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0, 0, 0, 0) use(unsafe.Pointer(_p0)) if e1 != 0 { err = e1 @@ -414,13 +847,67 @@ func Lstat(path string, stat *Stat_t) (err error) { return } +func Madvise(b []byte, advice int) (err error) { + var _p0 *byte + if len(b) > 0 { + _p0 = &b[0] + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMadvise)), 3, uintptr(unsafe.Pointer(_p0)), uintptr(len(b)), uintptr(advice), 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + func Mkdir(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - _, _, e1 := sysvicall6(procMkdir.Addr(), 2, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMkdir)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0, 0, 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Mkdirat(dirfd int, path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMkdirat)), 3, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0, 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Mkfifo(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMkfifo)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0, 0, 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Mkfifoat(dirfd int, path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMkfifoat)), 3, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0, 0, 0) use(unsafe.Pointer(_p0)) if e1 != 0 { err = e1 @@ -434,7 +921,7 @@ func Mknod(path string, mode uint32, dev int) (err error) { if err != nil { return } - _, _, e1 := sysvicall6(procMknod.Addr(), 3, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMknod)), 3, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0, 0) use(unsafe.Pointer(_p0)) if e1 != 0 { err = e1 @@ -442,8 +929,74 @@ func Mknod(path string, mode uint32, dev int) (err error) { return } +func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMknodat)), 4, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Mlock(b []byte) (err error) { + var _p0 *byte + if len(b) > 0 { + _p0 = &b[0] + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMlock)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(len(b)), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Mlockall(flags int) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMlockall)), 1, uintptr(flags), 0, 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Mprotect(b []byte, prot int) (err error) { + var _p0 *byte + if len(b) > 0 { + _p0 = &b[0] + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMprotect)), 3, uintptr(unsafe.Pointer(_p0)), uintptr(len(b)), uintptr(prot), 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Munlock(b []byte) (err error) { + var _p0 *byte + if len(b) > 0 { + _p0 = &b[0] + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMunlock)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(len(b)), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Munlockall() (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMunlockall)), 0, 0, 0, 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { - _, _, e1 := sysvicall6(procNanosleep.Addr(), 2, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procNanosleep)), 2, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0, 0, 0, 0) if e1 != 0 { err = e1 } @@ -456,7 +1009,22 @@ func Open(path string, mode int, perm uint32) (fd int, err error) { if err != nil { return } - r0, _, e1 := sysvicall6(procOpen.Addr(), 3, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0, 0) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procOpen)), 3, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0, 0) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procOpenat)), 4, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0) use(unsafe.Pointer(_p0)) fd = int(r0) if e1 != 0 { @@ -471,7 +1039,7 @@ func Pathconf(path string, name int) (val int, err error) { if err != nil { return } - r0, _, e1 := sysvicall6(procPathconf.Addr(), 2, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0, 0, 0, 0) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procPathconf)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0, 0, 0, 0) use(unsafe.Pointer(_p0)) val = int(r0) if e1 != 0 { @@ -480,12 +1048,20 @@ func Pathconf(path string, name int) (val int, err error) { return } +func Pause() (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procPause)), 0, 0, 0, 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + func Pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 *byte if len(p) > 0 { _p0 = &p[0] } - r0, _, e1 := sysvicall6(procPread.Addr(), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), uintptr(offset), 0, 0) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procPread)), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), uintptr(offset), 0, 0) n = int(r0) if e1 != 0 { err = e1 @@ -498,7 +1074,7 @@ func Pwrite(fd int, p []byte, offset int64) (n int, err error) { if len(p) > 0 { _p0 = &p[0] } - r0, _, e1 := sysvicall6(procPwrite.Addr(), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), uintptr(offset), 0, 0) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procPwrite)), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), uintptr(offset), 0, 0) n = int(r0) if e1 != 0 { err = e1 @@ -511,7 +1087,7 @@ func read(fd int, p []byte) (n int, err error) { if len(p) > 0 { _p0 = &p[0] } - r0, _, e1 := sysvicall6(procread.Addr(), 3, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), 0, 0, 0) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procread)), 3, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), 0, 0, 0) n = int(r0) if e1 != 0 { err = e1 @@ -529,7 +1105,7 @@ func Readlink(path string, buf []byte) (n int, err error) { if len(buf) > 0 { _p1 = &buf[0] } - r0, _, e1 := sysvicall6(procReadlink.Addr(), 3, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(len(buf)), 0, 0, 0) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procReadlink)), 3, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(len(buf)), 0, 0, 0) use(unsafe.Pointer(_p0)) n = int(r0) if e1 != 0 { @@ -549,7 +1125,27 @@ func Rename(from string, to string) (err error) { if err != nil { return } - _, _, e1 := sysvicall6(procRename.Addr(), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procRename)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0, 0, 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = e1 + } + return +} + +func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procRenameat)), 4, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0) use(unsafe.Pointer(_p0)) use(unsafe.Pointer(_p1)) if e1 != 0 { @@ -564,7 +1160,7 @@ func Rmdir(path string) (err error) { if err != nil { return } - _, _, e1 := sysvicall6(procRmdir.Addr(), 1, uintptr(unsafe.Pointer(_p0)), 0, 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procRmdir)), 1, uintptr(unsafe.Pointer(_p0)), 0, 0, 0, 0, 0) use(unsafe.Pointer(_p0)) if e1 != 0 { err = e1 @@ -573,7 +1169,7 @@ func Rmdir(path string) (err error) { } func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { - r0, _, e1 := sysvicall6(proclseek.Addr(), 3, uintptr(fd), uintptr(offset), uintptr(whence), 0, 0, 0) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proclseek)), 3, uintptr(fd), uintptr(offset), uintptr(whence), 0, 0, 0) newoffset = int64(r0) if e1 != 0 { err = e1 @@ -582,7 +1178,7 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { } func Setegid(egid int) (err error) { - _, _, e1 := rawSysvicall6(procSetegid.Addr(), 1, uintptr(egid), 0, 0, 0, 0, 0) + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetegid)), 1, uintptr(egid), 0, 0, 0, 0, 0) if e1 != 0 { err = e1 } @@ -590,7 +1186,7 @@ func Setegid(egid int) (err error) { } func Seteuid(euid int) (err error) { - _, _, e1 := rawSysvicall6(procSeteuid.Addr(), 1, uintptr(euid), 0, 0, 0, 0, 0) + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSeteuid)), 1, uintptr(euid), 0, 0, 0, 0, 0) if e1 != 0 { err = e1 } @@ -598,7 +1194,19 @@ func Seteuid(euid int) (err error) { } func Setgid(gid int) (err error) { - _, _, e1 := rawSysvicall6(procSetgid.Addr(), 1, uintptr(gid), 0, 0, 0, 0, 0) + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetgid)), 1, uintptr(gid), 0, 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Sethostname(p []byte) (err error) { + var _p0 *byte + if len(p) > 0 { + _p0 = &p[0] + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procSethostname)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), 0, 0, 0, 0) if e1 != 0 { err = e1 } @@ -606,7 +1214,7 @@ func Setgid(gid int) (err error) { } func Setpgid(pid int, pgid int) (err error) { - _, _, e1 := rawSysvicall6(procSetpgid.Addr(), 2, uintptr(pid), uintptr(pgid), 0, 0, 0, 0) + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetpgid)), 2, uintptr(pid), uintptr(pgid), 0, 0, 0, 0) if e1 != 0 { err = e1 } @@ -614,7 +1222,7 @@ func Setpgid(pid int, pgid int) (err error) { } func Setpriority(which int, who int, prio int) (err error) { - _, _, e1 := sysvicall6(procSetpriority.Addr(), 3, uintptr(which), uintptr(who), uintptr(prio), 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procSetpriority)), 3, uintptr(which), uintptr(who), uintptr(prio), 0, 0, 0) if e1 != 0 { err = e1 } @@ -622,7 +1230,7 @@ func Setpriority(which int, who int, prio int) (err error) { } func Setregid(rgid int, egid int) (err error) { - _, _, e1 := rawSysvicall6(procSetregid.Addr(), 2, uintptr(rgid), uintptr(egid), 0, 0, 0, 0) + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetregid)), 2, uintptr(rgid), uintptr(egid), 0, 0, 0, 0) if e1 != 0 { err = e1 } @@ -630,7 +1238,7 @@ func Setregid(rgid int, egid int) (err error) { } func Setreuid(ruid int, euid int) (err error) { - _, _, e1 := rawSysvicall6(procSetreuid.Addr(), 2, uintptr(ruid), uintptr(euid), 0, 0, 0, 0) + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetreuid)), 2, uintptr(ruid), uintptr(euid), 0, 0, 0, 0) if e1 != 0 { err = e1 } @@ -638,7 +1246,7 @@ func Setreuid(ruid int, euid int) (err error) { } func Setrlimit(which int, lim *Rlimit) (err error) { - _, _, e1 := rawSysvicall6(procSetrlimit.Addr(), 2, uintptr(which), uintptr(unsafe.Pointer(lim)), 0, 0, 0, 0) + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetrlimit)), 2, uintptr(which), uintptr(unsafe.Pointer(lim)), 0, 0, 0, 0) if e1 != 0 { err = e1 } @@ -646,7 +1254,7 @@ func Setrlimit(which int, lim *Rlimit) (err error) { } func Setsid() (pid int, err error) { - r0, _, e1 := rawSysvicall6(procSetsid.Addr(), 0, 0, 0, 0, 0, 0, 0) + r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetsid)), 0, 0, 0, 0, 0, 0, 0) pid = int(r0) if e1 != 0 { err = e1 @@ -655,7 +1263,7 @@ func Setsid() (pid int, err error) { } func Setuid(uid int) (err error) { - _, _, e1 := rawSysvicall6(procSetuid.Addr(), 1, uintptr(uid), 0, 0, 0, 0, 0) + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetuid)), 1, uintptr(uid), 0, 0, 0, 0, 0) if e1 != 0 { err = e1 } @@ -663,7 +1271,7 @@ func Setuid(uid int) (err error) { } func Shutdown(s int, how int) (err error) { - _, _, e1 := sysvicall6(procshutdown.Addr(), 2, uintptr(s), uintptr(how), 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procshutdown)), 2, uintptr(s), uintptr(how), 0, 0, 0, 0) if e1 != 0 { err = e1 } @@ -676,7 +1284,7 @@ func Stat(path string, stat *Stat_t) (err error) { if err != nil { return } - _, _, e1 := sysvicall6(procStat.Addr(), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procStat)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0, 0, 0, 0) use(unsafe.Pointer(_p0)) if e1 != 0 { err = e1 @@ -695,7 +1303,7 @@ func Symlink(path string, link string) (err error) { if err != nil { return } - _, _, e1 := sysvicall6(procSymlink.Addr(), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procSymlink)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0, 0, 0, 0) use(unsafe.Pointer(_p0)) use(unsafe.Pointer(_p1)) if e1 != 0 { @@ -705,7 +1313,16 @@ func Symlink(path string, link string) (err error) { } func Sync() (err error) { - _, _, e1 := sysvicall6(procSync.Addr(), 0, 0, 0, 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procSync)), 0, 0, 0, 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Times(tms *Tms) (ticks uintptr, err error) { + r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procTimes)), 1, uintptr(unsafe.Pointer(tms)), 0, 0, 0, 0, 0) + ticks = uintptr(r0) if e1 != 0 { err = e1 } @@ -718,7 +1335,7 @@ func Truncate(path string, length int64) (err error) { if err != nil { return } - _, _, e1 := sysvicall6(procTruncate.Addr(), 2, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procTruncate)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0, 0, 0, 0) use(unsafe.Pointer(_p0)) if e1 != 0 { err = e1 @@ -727,7 +1344,7 @@ func Truncate(path string, length int64) (err error) { } func Fsync(fd int) (err error) { - _, _, e1 := sysvicall6(procFsync.Addr(), 1, uintptr(fd), 0, 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFsync)), 1, uintptr(fd), 0, 0, 0, 0, 0) if e1 != 0 { err = e1 } @@ -735,26 +1352,62 @@ func Fsync(fd int) (err error) { } func Ftruncate(fd int, length int64) (err error) { - _, _, e1 := sysvicall6(procFtruncate.Addr(), 2, uintptr(fd), uintptr(length), 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFtruncate)), 2, uintptr(fd), uintptr(length), 0, 0, 0, 0) if e1 != 0 { err = e1 } return } -func Umask(newmask int) (oldmask int) { - r0, _, _ := sysvicall6(procUmask.Addr(), 1, uintptr(newmask), 0, 0, 0, 0, 0) +func Umask(mask int) (oldmask int) { + r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procUmask)), 1, uintptr(mask), 0, 0, 0, 0, 0) oldmask = int(r0) return } +func Uname(buf *Utsname) (err error) { + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procUname)), 1, uintptr(unsafe.Pointer(buf)), 0, 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Unmount(target string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(target) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procumount)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0, 0, 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + func Unlink(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - _, _, e1 := sysvicall6(procUnlink.Addr(), 1, uintptr(unsafe.Pointer(_p0)), 0, 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procUnlink)), 1, uintptr(unsafe.Pointer(_p0)), 0, 0, 0, 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procUnlinkat)), 3, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0, 0, 0) use(unsafe.Pointer(_p0)) if e1 != 0 { err = e1 @@ -762,13 +1415,21 @@ func Unlink(path string) (err error) { return } -func Utimes(path string, times *[2]Timeval) (err error) { +func Ustat(dev int, ubuf *Ustat_t) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procUstat)), 2, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Utime(path string, buf *Utimbuf) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } - _, _, e1 := sysvicall6(procUtimes.Addr(), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procUtime)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0, 0, 0, 0) use(unsafe.Pointer(_p0)) if e1 != 0 { err = e1 @@ -777,7 +1438,7 @@ func Utimes(path string, times *[2]Timeval) (err error) { } func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { - _, _, e1 := sysvicall6(procbind.Addr(), 3, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procbind)), 3, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0) if e1 != 0 { err = e1 } @@ -785,7 +1446,7 @@ func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { } func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { - _, _, e1 := sysvicall6(procconnect.Addr(), 3, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procconnect)), 3, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0) if e1 != 0 { err = e1 } @@ -793,7 +1454,7 @@ func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { } func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { - r0, _, e1 := sysvicall6(procmmap.Addr(), 6, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos)) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procmmap)), 6, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos)) ret = uintptr(r0) if e1 != 0 { err = e1 @@ -802,7 +1463,7 @@ func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) ( } func munmap(addr uintptr, length uintptr) (err error) { - _, _, e1 := sysvicall6(procmunmap.Addr(), 2, uintptr(addr), uintptr(length), 0, 0, 0, 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procmunmap)), 2, uintptr(addr), uintptr(length), 0, 0, 0, 0) if e1 != 0 { err = e1 } @@ -814,7 +1475,7 @@ func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) ( if len(buf) > 0 { _p0 = &buf[0] } - _, _, e1 := sysvicall6(procsendto.Addr(), 6, uintptr(s), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procsendto)), 6, uintptr(s), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) if e1 != 0 { err = e1 } @@ -822,7 +1483,7 @@ func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) ( } func socket(domain int, typ int, proto int) (fd int, err error) { - r0, _, e1 := sysvicall6(procsocket.Addr(), 3, uintptr(domain), uintptr(typ), uintptr(proto), 0, 0, 0) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procsocket)), 3, uintptr(domain), uintptr(typ), uintptr(proto), 0, 0, 0) fd = int(r0) if e1 != 0 { err = e1 @@ -831,7 +1492,7 @@ func socket(domain int, typ int, proto int) (fd int, err error) { } func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { - _, _, e1 := rawSysvicall6(procsocketpair.Addr(), 4, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procsocketpair)), 4, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) if e1 != 0 { err = e1 } @@ -843,7 +1504,7 @@ func write(fd int, p []byte) (n int, err error) { if len(p) > 0 { _p0 = &p[0] } - r0, _, e1 := sysvicall6(procwrite.Addr(), 3, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), 0, 0, 0) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procwrite)), 3, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), 0, 0, 0) n = int(r0) if e1 != 0 { err = e1 @@ -852,7 +1513,7 @@ func write(fd int, p []byte) (n int, err error) { } func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { - _, _, e1 := sysvicall6(procgetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procgetsockopt)), 5, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) if e1 != 0 { err = e1 } @@ -860,15 +1521,7 @@ func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen } func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { - _, _, e1 := rawSysvicall6(procgetpeername.Addr(), 3, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0) - if e1 != 0 { - err = e1 - } - return -} - -func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { - _, _, e1 := sysvicall6(procgetsockname.Addr(), 3, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0) + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procgetpeername)), 3, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0) if e1 != 0 { err = e1 } @@ -876,7 +1529,7 @@ func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { } func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { - _, _, e1 := sysvicall6(procsetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procsetsockopt)), 5, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) if e1 != 0 { err = e1 } @@ -888,7 +1541,7 @@ func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Sockl if len(p) > 0 { _p0 = &p[0] } - r0, _, e1 := sysvicall6(procrecvfrom.Addr(), 6, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procrecvfrom)), 6, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) n = int(r0) if e1 != 0 { err = e1 @@ -896,9 +1549,9 @@ func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Sockl return } -func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { - r0, _, e1 := sysvicall6(procrecvmsg.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags), 0, 0, 0) - n = int(r0) +func sysconf(name int) (n int64, err error) { + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procsysconf)), 1, uintptr(name), 0, 0, 0, 0, 0) + n = int64(r0) if e1 != 0 { err = e1 } diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_darwin_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_darwin_386.go index 645426a8d5..2786773ba3 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_darwin_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_darwin_386.go @@ -1,6 +1,8 @@ -// mksysnum_darwin.pl /usr/include/sys/unix.h +// mksysnum_darwin.pl /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/sys/syscall.h // MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT +// +build 386,darwin + package unix const ( @@ -40,7 +42,6 @@ const ( SYS_DUP = 41 SYS_PIPE = 42 SYS_GETEGID = 43 - SYS_PROFIL = 44 SYS_SIGACTION = 46 SYS_GETGID = 47 SYS_SIGPROCMASK = 48 @@ -118,8 +119,9 @@ const ( SYS_QUOTACTL = 165 SYS_MOUNT = 167 SYS_CSOPS = 169 + SYS_CSOPS_AUDITTOKEN = 170 SYS_WAITID = 173 - SYS_ADD_PROFIL = 176 + SYS_KDEBUG_TRACE64 = 179 SYS_KDEBUG_TRACE = 180 SYS_SETGID = 181 SYS_SETEGID = 182 @@ -139,21 +141,11 @@ const ( SYS_LSEEK = 199 SYS_TRUNCATE = 200 SYS_FTRUNCATE = 201 - SYS___SYSCTL = 202 + SYS_SYSCTL = 202 SYS_MLOCK = 203 SYS_MUNLOCK = 204 SYS_UNDELETE = 205 - SYS_ATSOCKET = 206 - SYS_ATGETMSG = 207 - SYS_ATPUTMSG = 208 - SYS_ATPSNDREQ = 209 - SYS_ATPSNDRSP = 210 - SYS_ATPGETREQ = 211 - SYS_ATPGETRSP = 212 - SYS_MKCOMPLEX = 216 - SYS_STATV = 217 - SYS_LSTATV = 218 - SYS_FSTATV = 219 + SYS_OPEN_DPROTECTED_NP = 216 SYS_GETATTRLIST = 220 SYS_SETATTRLIST = 221 SYS_GETDIRENTRIESATTR = 222 @@ -204,9 +196,7 @@ const ( SYS_SEM_WAIT = 271 SYS_SEM_TRYWAIT = 272 SYS_SEM_POST = 273 - SYS_SEM_GETVALUE = 274 - SYS_SEM_INIT = 275 - SYS_SEM_DESTROY = 276 + SYS_SYSCTLBYNAME = 274 SYS_OPEN_EXTENDED = 277 SYS_UMASK_EXTENDED = 278 SYS_STAT_EXTENDED = 279 @@ -280,8 +270,6 @@ const ( SYS_AUDITON = 351 SYS_GETAUID = 353 SYS_SETAUID = 354 - SYS_GETAUDIT = 355 - SYS_SETAUDIT = 356 SYS_GETAUDIT_ADDR = 357 SYS_SETAUDIT_ADDR = 358 SYS_AUDITCTL = 359 @@ -298,6 +286,7 @@ const ( SYS___OLD_SEMWAIT_SIGNAL = 370 SYS___OLD_SEMWAIT_SIGNAL_NOCANCEL = 371 SYS_THREAD_SELFID = 372 + SYS_LEDGER = 373 SYS___MAC_EXECVE = 380 SYS___MAC_SYSCALL = 381 SYS___MAC_GET_FILE = 382 @@ -356,5 +345,54 @@ const ( SYS_PID_HIBERNATE = 435 SYS_PID_SHUTDOWN_SOCKETS = 436 SYS_SHARED_REGION_MAP_AND_SLIDE_NP = 438 - SYS_MAXSYSCALL = 439 + SYS_KAS_INFO = 439 + SYS_MEMORYSTATUS_CONTROL = 440 + SYS_GUARDED_OPEN_NP = 441 + SYS_GUARDED_CLOSE_NP = 442 + SYS_GUARDED_KQUEUE_NP = 443 + SYS_CHANGE_FDGUARD_NP = 444 + SYS_PROC_RLIMIT_CONTROL = 446 + SYS_CONNECTX = 447 + SYS_DISCONNECTX = 448 + SYS_PEELOFF = 449 + SYS_SOCKET_DELEGATE = 450 + SYS_TELEMETRY = 451 + SYS_PROC_UUID_POLICY = 452 + SYS_MEMORYSTATUS_GET_LEVEL = 453 + SYS_SYSTEM_OVERRIDE = 454 + SYS_VFS_PURGE = 455 + SYS_SFI_CTL = 456 + SYS_SFI_PIDCTL = 457 + SYS_COALITION = 458 + SYS_COALITION_INFO = 459 + SYS_NECP_MATCH_POLICY = 460 + SYS_GETATTRLISTBULK = 461 + SYS_OPENAT = 463 + SYS_OPENAT_NOCANCEL = 464 + SYS_RENAMEAT = 465 + SYS_FACCESSAT = 466 + SYS_FCHMODAT = 467 + SYS_FCHOWNAT = 468 + SYS_FSTATAT = 469 + SYS_FSTATAT64 = 470 + SYS_LINKAT = 471 + SYS_UNLINKAT = 472 + SYS_READLINKAT = 473 + SYS_SYMLINKAT = 474 + SYS_MKDIRAT = 475 + SYS_GETATTRLISTAT = 476 + SYS_PROC_TRACE_LOG = 477 + SYS_BSDTHREAD_CTL = 478 + SYS_OPENBYID_NP = 479 + SYS_RECVMSG_X = 480 + SYS_SENDMSG_X = 481 + SYS_THREAD_SELFUSAGE = 482 + SYS_CSRCTL = 483 + SYS_GUARDED_OPEN_DPROTECTED_NP = 484 + SYS_GUARDED_WRITE_NP = 485 + SYS_GUARDED_PWRITE_NP = 486 + SYS_GUARDED_WRITEV_NP = 487 + SYS_RENAME_EXT = 488 + SYS_MREMAP_ENCRYPTED = 489 + SYS_MAXSYSCALL = 490 ) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_darwin_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_darwin_amd64.go index 645426a8d5..09de240c8f 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_darwin_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_darwin_amd64.go @@ -1,6 +1,8 @@ -// mksysnum_darwin.pl /usr/include/sys/unix.h +// mksysnum_darwin.pl /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/sys/syscall.h // MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT +// +build amd64,darwin + package unix const ( @@ -40,7 +42,6 @@ const ( SYS_DUP = 41 SYS_PIPE = 42 SYS_GETEGID = 43 - SYS_PROFIL = 44 SYS_SIGACTION = 46 SYS_GETGID = 47 SYS_SIGPROCMASK = 48 @@ -118,8 +119,9 @@ const ( SYS_QUOTACTL = 165 SYS_MOUNT = 167 SYS_CSOPS = 169 + SYS_CSOPS_AUDITTOKEN = 170 SYS_WAITID = 173 - SYS_ADD_PROFIL = 176 + SYS_KDEBUG_TRACE64 = 179 SYS_KDEBUG_TRACE = 180 SYS_SETGID = 181 SYS_SETEGID = 182 @@ -139,21 +141,11 @@ const ( SYS_LSEEK = 199 SYS_TRUNCATE = 200 SYS_FTRUNCATE = 201 - SYS___SYSCTL = 202 + SYS_SYSCTL = 202 SYS_MLOCK = 203 SYS_MUNLOCK = 204 SYS_UNDELETE = 205 - SYS_ATSOCKET = 206 - SYS_ATGETMSG = 207 - SYS_ATPUTMSG = 208 - SYS_ATPSNDREQ = 209 - SYS_ATPSNDRSP = 210 - SYS_ATPGETREQ = 211 - SYS_ATPGETRSP = 212 - SYS_MKCOMPLEX = 216 - SYS_STATV = 217 - SYS_LSTATV = 218 - SYS_FSTATV = 219 + SYS_OPEN_DPROTECTED_NP = 216 SYS_GETATTRLIST = 220 SYS_SETATTRLIST = 221 SYS_GETDIRENTRIESATTR = 222 @@ -204,9 +196,7 @@ const ( SYS_SEM_WAIT = 271 SYS_SEM_TRYWAIT = 272 SYS_SEM_POST = 273 - SYS_SEM_GETVALUE = 274 - SYS_SEM_INIT = 275 - SYS_SEM_DESTROY = 276 + SYS_SYSCTLBYNAME = 274 SYS_OPEN_EXTENDED = 277 SYS_UMASK_EXTENDED = 278 SYS_STAT_EXTENDED = 279 @@ -280,8 +270,6 @@ const ( SYS_AUDITON = 351 SYS_GETAUID = 353 SYS_SETAUID = 354 - SYS_GETAUDIT = 355 - SYS_SETAUDIT = 356 SYS_GETAUDIT_ADDR = 357 SYS_SETAUDIT_ADDR = 358 SYS_AUDITCTL = 359 @@ -298,6 +286,7 @@ const ( SYS___OLD_SEMWAIT_SIGNAL = 370 SYS___OLD_SEMWAIT_SIGNAL_NOCANCEL = 371 SYS_THREAD_SELFID = 372 + SYS_LEDGER = 373 SYS___MAC_EXECVE = 380 SYS___MAC_SYSCALL = 381 SYS___MAC_GET_FILE = 382 @@ -356,5 +345,54 @@ const ( SYS_PID_HIBERNATE = 435 SYS_PID_SHUTDOWN_SOCKETS = 436 SYS_SHARED_REGION_MAP_AND_SLIDE_NP = 438 - SYS_MAXSYSCALL = 439 + SYS_KAS_INFO = 439 + SYS_MEMORYSTATUS_CONTROL = 440 + SYS_GUARDED_OPEN_NP = 441 + SYS_GUARDED_CLOSE_NP = 442 + SYS_GUARDED_KQUEUE_NP = 443 + SYS_CHANGE_FDGUARD_NP = 444 + SYS_PROC_RLIMIT_CONTROL = 446 + SYS_CONNECTX = 447 + SYS_DISCONNECTX = 448 + SYS_PEELOFF = 449 + SYS_SOCKET_DELEGATE = 450 + SYS_TELEMETRY = 451 + SYS_PROC_UUID_POLICY = 452 + SYS_MEMORYSTATUS_GET_LEVEL = 453 + SYS_SYSTEM_OVERRIDE = 454 + SYS_VFS_PURGE = 455 + SYS_SFI_CTL = 456 + SYS_SFI_PIDCTL = 457 + SYS_COALITION = 458 + SYS_COALITION_INFO = 459 + SYS_NECP_MATCH_POLICY = 460 + SYS_GETATTRLISTBULK = 461 + SYS_OPENAT = 463 + SYS_OPENAT_NOCANCEL = 464 + SYS_RENAMEAT = 465 + SYS_FACCESSAT = 466 + SYS_FCHMODAT = 467 + SYS_FCHOWNAT = 468 + SYS_FSTATAT = 469 + SYS_FSTATAT64 = 470 + SYS_LINKAT = 471 + SYS_UNLINKAT = 472 + SYS_READLINKAT = 473 + SYS_SYMLINKAT = 474 + SYS_MKDIRAT = 475 + SYS_GETATTRLISTAT = 476 + SYS_PROC_TRACE_LOG = 477 + SYS_BSDTHREAD_CTL = 478 + SYS_OPENBYID_NP = 479 + SYS_RECVMSG_X = 480 + SYS_SENDMSG_X = 481 + SYS_THREAD_SELFUSAGE = 482 + SYS_CSRCTL = 483 + SYS_GUARDED_OPEN_DPROTECTED_NP = 484 + SYS_GUARDED_WRITE_NP = 485 + SYS_GUARDED_PWRITE_NP = 486 + SYS_GUARDED_WRITEV_NP = 487 + SYS_RENAME_EXT = 488 + SYS_MREMAP_ENCRYPTED = 489 + SYS_MAXSYSCALL = 490 ) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_darwin_arm.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_darwin_arm.go new file mode 100644 index 0000000000..b8c9aea852 --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_darwin_arm.go @@ -0,0 +1,358 @@ +// mksysnum_darwin.pl /usr/include/sys/syscall.h +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build arm,darwin + +package unix + +const ( + SYS_SYSCALL = 0 + SYS_EXIT = 1 + SYS_FORK = 2 + SYS_READ = 3 + SYS_WRITE = 4 + SYS_OPEN = 5 + SYS_CLOSE = 6 + SYS_WAIT4 = 7 + SYS_LINK = 9 + SYS_UNLINK = 10 + SYS_CHDIR = 12 + SYS_FCHDIR = 13 + SYS_MKNOD = 14 + SYS_CHMOD = 15 + SYS_CHOWN = 16 + SYS_GETFSSTAT = 18 + SYS_GETPID = 20 + SYS_SETUID = 23 + SYS_GETUID = 24 + SYS_GETEUID = 25 + SYS_PTRACE = 26 + SYS_RECVMSG = 27 + SYS_SENDMSG = 28 + SYS_RECVFROM = 29 + SYS_ACCEPT = 30 + SYS_GETPEERNAME = 31 + SYS_GETSOCKNAME = 32 + SYS_ACCESS = 33 + SYS_CHFLAGS = 34 + SYS_FCHFLAGS = 35 + SYS_SYNC = 36 + SYS_KILL = 37 + SYS_GETPPID = 39 + SYS_DUP = 41 + SYS_PIPE = 42 + SYS_GETEGID = 43 + SYS_SIGACTION = 46 + SYS_GETGID = 47 + SYS_SIGPROCMASK = 48 + SYS_GETLOGIN = 49 + SYS_SETLOGIN = 50 + SYS_ACCT = 51 + SYS_SIGPENDING = 52 + SYS_SIGALTSTACK = 53 + SYS_IOCTL = 54 + SYS_REBOOT = 55 + SYS_REVOKE = 56 + SYS_SYMLINK = 57 + SYS_READLINK = 58 + SYS_EXECVE = 59 + SYS_UMASK = 60 + SYS_CHROOT = 61 + SYS_MSYNC = 65 + SYS_VFORK = 66 + SYS_MUNMAP = 73 + SYS_MPROTECT = 74 + SYS_MADVISE = 75 + SYS_MINCORE = 78 + SYS_GETGROUPS = 79 + SYS_SETGROUPS = 80 + SYS_GETPGRP = 81 + SYS_SETPGID = 82 + SYS_SETITIMER = 83 + SYS_SWAPON = 85 + SYS_GETITIMER = 86 + SYS_GETDTABLESIZE = 89 + SYS_DUP2 = 90 + SYS_FCNTL = 92 + SYS_SELECT = 93 + SYS_FSYNC = 95 + SYS_SETPRIORITY = 96 + SYS_SOCKET = 97 + SYS_CONNECT = 98 + SYS_GETPRIORITY = 100 + SYS_BIND = 104 + SYS_SETSOCKOPT = 105 + SYS_LISTEN = 106 + SYS_SIGSUSPEND = 111 + SYS_GETTIMEOFDAY = 116 + SYS_GETRUSAGE = 117 + SYS_GETSOCKOPT = 118 + SYS_READV = 120 + SYS_WRITEV = 121 + SYS_SETTIMEOFDAY = 122 + SYS_FCHOWN = 123 + SYS_FCHMOD = 124 + SYS_SETREUID = 126 + SYS_SETREGID = 127 + SYS_RENAME = 128 + SYS_FLOCK = 131 + SYS_MKFIFO = 132 + SYS_SENDTO = 133 + SYS_SHUTDOWN = 134 + SYS_SOCKETPAIR = 135 + SYS_MKDIR = 136 + SYS_RMDIR = 137 + SYS_UTIMES = 138 + SYS_FUTIMES = 139 + SYS_ADJTIME = 140 + SYS_GETHOSTUUID = 142 + SYS_SETSID = 147 + SYS_GETPGID = 151 + SYS_SETPRIVEXEC = 152 + SYS_PREAD = 153 + SYS_PWRITE = 154 + SYS_NFSSVC = 155 + SYS_STATFS = 157 + SYS_FSTATFS = 158 + SYS_UNMOUNT = 159 + SYS_GETFH = 161 + SYS_QUOTACTL = 165 + SYS_MOUNT = 167 + SYS_CSOPS = 169 + SYS_CSOPS_AUDITTOKEN = 170 + SYS_WAITID = 173 + SYS_KDEBUG_TRACE = 180 + SYS_SETGID = 181 + SYS_SETEGID = 182 + SYS_SETEUID = 183 + SYS_SIGRETURN = 184 + SYS_CHUD = 185 + SYS_FDATASYNC = 187 + SYS_STAT = 188 + SYS_FSTAT = 189 + SYS_LSTAT = 190 + SYS_PATHCONF = 191 + SYS_FPATHCONF = 192 + SYS_GETRLIMIT = 194 + SYS_SETRLIMIT = 195 + SYS_GETDIRENTRIES = 196 + SYS_MMAP = 197 + SYS_LSEEK = 199 + SYS_TRUNCATE = 200 + SYS_FTRUNCATE = 201 + SYS___SYSCTL = 202 + SYS_MLOCK = 203 + SYS_MUNLOCK = 204 + SYS_UNDELETE = 205 + SYS_ATSOCKET = 206 + SYS_ATGETMSG = 207 + SYS_ATPUTMSG = 208 + SYS_ATPSNDREQ = 209 + SYS_ATPSNDRSP = 210 + SYS_ATPGETREQ = 211 + SYS_ATPGETRSP = 212 + SYS_OPEN_DPROTECTED_NP = 216 + SYS_GETATTRLIST = 220 + SYS_SETATTRLIST = 221 + SYS_GETDIRENTRIESATTR = 222 + SYS_EXCHANGEDATA = 223 + SYS_SEARCHFS = 225 + SYS_DELETE = 226 + SYS_COPYFILE = 227 + SYS_FGETATTRLIST = 228 + SYS_FSETATTRLIST = 229 + SYS_POLL = 230 + SYS_WATCHEVENT = 231 + SYS_WAITEVENT = 232 + SYS_MODWATCH = 233 + SYS_GETXATTR = 234 + SYS_FGETXATTR = 235 + SYS_SETXATTR = 236 + SYS_FSETXATTR = 237 + SYS_REMOVEXATTR = 238 + SYS_FREMOVEXATTR = 239 + SYS_LISTXATTR = 240 + SYS_FLISTXATTR = 241 + SYS_FSCTL = 242 + SYS_INITGROUPS = 243 + SYS_POSIX_SPAWN = 244 + SYS_FFSCTL = 245 + SYS_NFSCLNT = 247 + SYS_FHOPEN = 248 + SYS_MINHERIT = 250 + SYS_SEMSYS = 251 + SYS_MSGSYS = 252 + SYS_SHMSYS = 253 + SYS_SEMCTL = 254 + SYS_SEMGET = 255 + SYS_SEMOP = 256 + SYS_MSGCTL = 258 + SYS_MSGGET = 259 + SYS_MSGSND = 260 + SYS_MSGRCV = 261 + SYS_SHMAT = 262 + SYS_SHMCTL = 263 + SYS_SHMDT = 264 + SYS_SHMGET = 265 + SYS_SHM_OPEN = 266 + SYS_SHM_UNLINK = 267 + SYS_SEM_OPEN = 268 + SYS_SEM_CLOSE = 269 + SYS_SEM_UNLINK = 270 + SYS_SEM_WAIT = 271 + SYS_SEM_TRYWAIT = 272 + SYS_SEM_POST = 273 + SYS_SEM_GETVALUE = 274 + SYS_SEM_INIT = 275 + SYS_SEM_DESTROY = 276 + SYS_OPEN_EXTENDED = 277 + SYS_UMASK_EXTENDED = 278 + SYS_STAT_EXTENDED = 279 + SYS_LSTAT_EXTENDED = 280 + SYS_FSTAT_EXTENDED = 281 + SYS_CHMOD_EXTENDED = 282 + SYS_FCHMOD_EXTENDED = 283 + SYS_ACCESS_EXTENDED = 284 + SYS_SETTID = 285 + SYS_GETTID = 286 + SYS_SETSGROUPS = 287 + SYS_GETSGROUPS = 288 + SYS_SETWGROUPS = 289 + SYS_GETWGROUPS = 290 + SYS_MKFIFO_EXTENDED = 291 + SYS_MKDIR_EXTENDED = 292 + SYS_IDENTITYSVC = 293 + SYS_SHARED_REGION_CHECK_NP = 294 + SYS_VM_PRESSURE_MONITOR = 296 + SYS_PSYNCH_RW_LONGRDLOCK = 297 + SYS_PSYNCH_RW_YIELDWRLOCK = 298 + SYS_PSYNCH_RW_DOWNGRADE = 299 + SYS_PSYNCH_RW_UPGRADE = 300 + SYS_PSYNCH_MUTEXWAIT = 301 + SYS_PSYNCH_MUTEXDROP = 302 + SYS_PSYNCH_CVBROAD = 303 + SYS_PSYNCH_CVSIGNAL = 304 + SYS_PSYNCH_CVWAIT = 305 + SYS_PSYNCH_RW_RDLOCK = 306 + SYS_PSYNCH_RW_WRLOCK = 307 + SYS_PSYNCH_RW_UNLOCK = 308 + SYS_PSYNCH_RW_UNLOCK2 = 309 + SYS_GETSID = 310 + SYS_SETTID_WITH_PID = 311 + SYS_PSYNCH_CVCLRPREPOST = 312 + SYS_AIO_FSYNC = 313 + SYS_AIO_RETURN = 314 + SYS_AIO_SUSPEND = 315 + SYS_AIO_CANCEL = 316 + SYS_AIO_ERROR = 317 + SYS_AIO_READ = 318 + SYS_AIO_WRITE = 319 + SYS_LIO_LISTIO = 320 + SYS_IOPOLICYSYS = 322 + SYS_PROCESS_POLICY = 323 + SYS_MLOCKALL = 324 + SYS_MUNLOCKALL = 325 + SYS_ISSETUGID = 327 + SYS___PTHREAD_KILL = 328 + SYS___PTHREAD_SIGMASK = 329 + SYS___SIGWAIT = 330 + SYS___DISABLE_THREADSIGNAL = 331 + SYS___PTHREAD_MARKCANCEL = 332 + SYS___PTHREAD_CANCELED = 333 + SYS___SEMWAIT_SIGNAL = 334 + SYS_PROC_INFO = 336 + SYS_SENDFILE = 337 + SYS_STAT64 = 338 + SYS_FSTAT64 = 339 + SYS_LSTAT64 = 340 + SYS_STAT64_EXTENDED = 341 + SYS_LSTAT64_EXTENDED = 342 + SYS_FSTAT64_EXTENDED = 343 + SYS_GETDIRENTRIES64 = 344 + SYS_STATFS64 = 345 + SYS_FSTATFS64 = 346 + SYS_GETFSSTAT64 = 347 + SYS___PTHREAD_CHDIR = 348 + SYS___PTHREAD_FCHDIR = 349 + SYS_AUDIT = 350 + SYS_AUDITON = 351 + SYS_GETAUID = 353 + SYS_SETAUID = 354 + SYS_GETAUDIT_ADDR = 357 + SYS_SETAUDIT_ADDR = 358 + SYS_AUDITCTL = 359 + SYS_BSDTHREAD_CREATE = 360 + SYS_BSDTHREAD_TERMINATE = 361 + SYS_KQUEUE = 362 + SYS_KEVENT = 363 + SYS_LCHOWN = 364 + SYS_STACK_SNAPSHOT = 365 + SYS_BSDTHREAD_REGISTER = 366 + SYS_WORKQ_OPEN = 367 + SYS_WORKQ_KERNRETURN = 368 + SYS_KEVENT64 = 369 + SYS___OLD_SEMWAIT_SIGNAL = 370 + SYS___OLD_SEMWAIT_SIGNAL_NOCANCEL = 371 + SYS_THREAD_SELFID = 372 + SYS_LEDGER = 373 + SYS___MAC_EXECVE = 380 + SYS___MAC_SYSCALL = 381 + SYS___MAC_GET_FILE = 382 + SYS___MAC_SET_FILE = 383 + SYS___MAC_GET_LINK = 384 + SYS___MAC_SET_LINK = 385 + SYS___MAC_GET_PROC = 386 + SYS___MAC_SET_PROC = 387 + SYS___MAC_GET_FD = 388 + SYS___MAC_SET_FD = 389 + SYS___MAC_GET_PID = 390 + SYS___MAC_GET_LCID = 391 + SYS___MAC_GET_LCTX = 392 + SYS___MAC_SET_LCTX = 393 + SYS_SETLCID = 394 + SYS_GETLCID = 395 + SYS_READ_NOCANCEL = 396 + SYS_WRITE_NOCANCEL = 397 + SYS_OPEN_NOCANCEL = 398 + SYS_CLOSE_NOCANCEL = 399 + SYS_WAIT4_NOCANCEL = 400 + SYS_RECVMSG_NOCANCEL = 401 + SYS_SENDMSG_NOCANCEL = 402 + SYS_RECVFROM_NOCANCEL = 403 + SYS_ACCEPT_NOCANCEL = 404 + SYS_MSYNC_NOCANCEL = 405 + SYS_FCNTL_NOCANCEL = 406 + SYS_SELECT_NOCANCEL = 407 + SYS_FSYNC_NOCANCEL = 408 + SYS_CONNECT_NOCANCEL = 409 + SYS_SIGSUSPEND_NOCANCEL = 410 + SYS_READV_NOCANCEL = 411 + SYS_WRITEV_NOCANCEL = 412 + SYS_SENDTO_NOCANCEL = 413 + SYS_PREAD_NOCANCEL = 414 + SYS_PWRITE_NOCANCEL = 415 + SYS_WAITID_NOCANCEL = 416 + SYS_POLL_NOCANCEL = 417 + SYS_MSGSND_NOCANCEL = 418 + SYS_MSGRCV_NOCANCEL = 419 + SYS_SEM_WAIT_NOCANCEL = 420 + SYS_AIO_SUSPEND_NOCANCEL = 421 + SYS___SIGWAIT_NOCANCEL = 422 + SYS___SEMWAIT_SIGNAL_NOCANCEL = 423 + SYS___MAC_MOUNT = 424 + SYS___MAC_GET_MOUNT = 425 + SYS___MAC_GETFSSTAT = 426 + SYS_FSGETPATH = 427 + SYS_AUDIT_SESSION_SELF = 428 + SYS_AUDIT_SESSION_JOIN = 429 + SYS_FILEPORT_MAKEPORT = 430 + SYS_FILEPORT_MAKEFD = 431 + SYS_AUDIT_SESSION_PORT = 432 + SYS_PID_SUSPEND = 433 + SYS_PID_RESUME = 434 + SYS_PID_HIBERNATE = 435 + SYS_PID_SHUTDOWN_SOCKETS = 436 + SYS_SHARED_REGION_MAP_AND_SLIDE_NP = 438 + SYS_KAS_INFO = 439 + SYS_MAXSYSCALL = 440 +) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_darwin_arm64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_darwin_arm64.go new file mode 100644 index 0000000000..26677ebbf5 --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_darwin_arm64.go @@ -0,0 +1,398 @@ +// mksysnum_darwin.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.4.sdk/usr/include/sys/syscall.h +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build arm64,darwin + +package unix + +const ( + SYS_SYSCALL = 0 + SYS_EXIT = 1 + SYS_FORK = 2 + SYS_READ = 3 + SYS_WRITE = 4 + SYS_OPEN = 5 + SYS_CLOSE = 6 + SYS_WAIT4 = 7 + SYS_LINK = 9 + SYS_UNLINK = 10 + SYS_CHDIR = 12 + SYS_FCHDIR = 13 + SYS_MKNOD = 14 + SYS_CHMOD = 15 + SYS_CHOWN = 16 + SYS_GETFSSTAT = 18 + SYS_GETPID = 20 + SYS_SETUID = 23 + SYS_GETUID = 24 + SYS_GETEUID = 25 + SYS_PTRACE = 26 + SYS_RECVMSG = 27 + SYS_SENDMSG = 28 + SYS_RECVFROM = 29 + SYS_ACCEPT = 30 + SYS_GETPEERNAME = 31 + SYS_GETSOCKNAME = 32 + SYS_ACCESS = 33 + SYS_CHFLAGS = 34 + SYS_FCHFLAGS = 35 + SYS_SYNC = 36 + SYS_KILL = 37 + SYS_GETPPID = 39 + SYS_DUP = 41 + SYS_PIPE = 42 + SYS_GETEGID = 43 + SYS_SIGACTION = 46 + SYS_GETGID = 47 + SYS_SIGPROCMASK = 48 + SYS_GETLOGIN = 49 + SYS_SETLOGIN = 50 + SYS_ACCT = 51 + SYS_SIGPENDING = 52 + SYS_SIGALTSTACK = 53 + SYS_IOCTL = 54 + SYS_REBOOT = 55 + SYS_REVOKE = 56 + SYS_SYMLINK = 57 + SYS_READLINK = 58 + SYS_EXECVE = 59 + SYS_UMASK = 60 + SYS_CHROOT = 61 + SYS_MSYNC = 65 + SYS_VFORK = 66 + SYS_MUNMAP = 73 + SYS_MPROTECT = 74 + SYS_MADVISE = 75 + SYS_MINCORE = 78 + SYS_GETGROUPS = 79 + SYS_SETGROUPS = 80 + SYS_GETPGRP = 81 + SYS_SETPGID = 82 + SYS_SETITIMER = 83 + SYS_SWAPON = 85 + SYS_GETITIMER = 86 + SYS_GETDTABLESIZE = 89 + SYS_DUP2 = 90 + SYS_FCNTL = 92 + SYS_SELECT = 93 + SYS_FSYNC = 95 + SYS_SETPRIORITY = 96 + SYS_SOCKET = 97 + SYS_CONNECT = 98 + SYS_GETPRIORITY = 100 + SYS_BIND = 104 + SYS_SETSOCKOPT = 105 + SYS_LISTEN = 106 + SYS_SIGSUSPEND = 111 + SYS_GETTIMEOFDAY = 116 + SYS_GETRUSAGE = 117 + SYS_GETSOCKOPT = 118 + SYS_READV = 120 + SYS_WRITEV = 121 + SYS_SETTIMEOFDAY = 122 + SYS_FCHOWN = 123 + SYS_FCHMOD = 124 + SYS_SETREUID = 126 + SYS_SETREGID = 127 + SYS_RENAME = 128 + SYS_FLOCK = 131 + SYS_MKFIFO = 132 + SYS_SENDTO = 133 + SYS_SHUTDOWN = 134 + SYS_SOCKETPAIR = 135 + SYS_MKDIR = 136 + SYS_RMDIR = 137 + SYS_UTIMES = 138 + SYS_FUTIMES = 139 + SYS_ADJTIME = 140 + SYS_GETHOSTUUID = 142 + SYS_SETSID = 147 + SYS_GETPGID = 151 + SYS_SETPRIVEXEC = 152 + SYS_PREAD = 153 + SYS_PWRITE = 154 + SYS_NFSSVC = 155 + SYS_STATFS = 157 + SYS_FSTATFS = 158 + SYS_UNMOUNT = 159 + SYS_GETFH = 161 + SYS_QUOTACTL = 165 + SYS_MOUNT = 167 + SYS_CSOPS = 169 + SYS_CSOPS_AUDITTOKEN = 170 + SYS_WAITID = 173 + SYS_KDEBUG_TRACE64 = 179 + SYS_KDEBUG_TRACE = 180 + SYS_SETGID = 181 + SYS_SETEGID = 182 + SYS_SETEUID = 183 + SYS_SIGRETURN = 184 + SYS_CHUD = 185 + SYS_FDATASYNC = 187 + SYS_STAT = 188 + SYS_FSTAT = 189 + SYS_LSTAT = 190 + SYS_PATHCONF = 191 + SYS_FPATHCONF = 192 + SYS_GETRLIMIT = 194 + SYS_SETRLIMIT = 195 + SYS_GETDIRENTRIES = 196 + SYS_MMAP = 197 + SYS_LSEEK = 199 + SYS_TRUNCATE = 200 + SYS_FTRUNCATE = 201 + SYS_SYSCTL = 202 + SYS_MLOCK = 203 + SYS_MUNLOCK = 204 + SYS_UNDELETE = 205 + SYS_OPEN_DPROTECTED_NP = 216 + SYS_GETATTRLIST = 220 + SYS_SETATTRLIST = 221 + SYS_GETDIRENTRIESATTR = 222 + SYS_EXCHANGEDATA = 223 + SYS_SEARCHFS = 225 + SYS_DELETE = 226 + SYS_COPYFILE = 227 + SYS_FGETATTRLIST = 228 + SYS_FSETATTRLIST = 229 + SYS_POLL = 230 + SYS_WATCHEVENT = 231 + SYS_WAITEVENT = 232 + SYS_MODWATCH = 233 + SYS_GETXATTR = 234 + SYS_FGETXATTR = 235 + SYS_SETXATTR = 236 + SYS_FSETXATTR = 237 + SYS_REMOVEXATTR = 238 + SYS_FREMOVEXATTR = 239 + SYS_LISTXATTR = 240 + SYS_FLISTXATTR = 241 + SYS_FSCTL = 242 + SYS_INITGROUPS = 243 + SYS_POSIX_SPAWN = 244 + SYS_FFSCTL = 245 + SYS_NFSCLNT = 247 + SYS_FHOPEN = 248 + SYS_MINHERIT = 250 + SYS_SEMSYS = 251 + SYS_MSGSYS = 252 + SYS_SHMSYS = 253 + SYS_SEMCTL = 254 + SYS_SEMGET = 255 + SYS_SEMOP = 256 + SYS_MSGCTL = 258 + SYS_MSGGET = 259 + SYS_MSGSND = 260 + SYS_MSGRCV = 261 + SYS_SHMAT = 262 + SYS_SHMCTL = 263 + SYS_SHMDT = 264 + SYS_SHMGET = 265 + SYS_SHM_OPEN = 266 + SYS_SHM_UNLINK = 267 + SYS_SEM_OPEN = 268 + SYS_SEM_CLOSE = 269 + SYS_SEM_UNLINK = 270 + SYS_SEM_WAIT = 271 + SYS_SEM_TRYWAIT = 272 + SYS_SEM_POST = 273 + SYS_SYSCTLBYNAME = 274 + SYS_OPEN_EXTENDED = 277 + SYS_UMASK_EXTENDED = 278 + SYS_STAT_EXTENDED = 279 + SYS_LSTAT_EXTENDED = 280 + SYS_FSTAT_EXTENDED = 281 + SYS_CHMOD_EXTENDED = 282 + SYS_FCHMOD_EXTENDED = 283 + SYS_ACCESS_EXTENDED = 284 + SYS_SETTID = 285 + SYS_GETTID = 286 + SYS_SETSGROUPS = 287 + SYS_GETSGROUPS = 288 + SYS_SETWGROUPS = 289 + SYS_GETWGROUPS = 290 + SYS_MKFIFO_EXTENDED = 291 + SYS_MKDIR_EXTENDED = 292 + SYS_IDENTITYSVC = 293 + SYS_SHARED_REGION_CHECK_NP = 294 + SYS_VM_PRESSURE_MONITOR = 296 + SYS_PSYNCH_RW_LONGRDLOCK = 297 + SYS_PSYNCH_RW_YIELDWRLOCK = 298 + SYS_PSYNCH_RW_DOWNGRADE = 299 + SYS_PSYNCH_RW_UPGRADE = 300 + SYS_PSYNCH_MUTEXWAIT = 301 + SYS_PSYNCH_MUTEXDROP = 302 + SYS_PSYNCH_CVBROAD = 303 + SYS_PSYNCH_CVSIGNAL = 304 + SYS_PSYNCH_CVWAIT = 305 + SYS_PSYNCH_RW_RDLOCK = 306 + SYS_PSYNCH_RW_WRLOCK = 307 + SYS_PSYNCH_RW_UNLOCK = 308 + SYS_PSYNCH_RW_UNLOCK2 = 309 + SYS_GETSID = 310 + SYS_SETTID_WITH_PID = 311 + SYS_PSYNCH_CVCLRPREPOST = 312 + SYS_AIO_FSYNC = 313 + SYS_AIO_RETURN = 314 + SYS_AIO_SUSPEND = 315 + SYS_AIO_CANCEL = 316 + SYS_AIO_ERROR = 317 + SYS_AIO_READ = 318 + SYS_AIO_WRITE = 319 + SYS_LIO_LISTIO = 320 + SYS_IOPOLICYSYS = 322 + SYS_PROCESS_POLICY = 323 + SYS_MLOCKALL = 324 + SYS_MUNLOCKALL = 325 + SYS_ISSETUGID = 327 + SYS___PTHREAD_KILL = 328 + SYS___PTHREAD_SIGMASK = 329 + SYS___SIGWAIT = 330 + SYS___DISABLE_THREADSIGNAL = 331 + SYS___PTHREAD_MARKCANCEL = 332 + SYS___PTHREAD_CANCELED = 333 + SYS___SEMWAIT_SIGNAL = 334 + SYS_PROC_INFO = 336 + SYS_SENDFILE = 337 + SYS_STAT64 = 338 + SYS_FSTAT64 = 339 + SYS_LSTAT64 = 340 + SYS_STAT64_EXTENDED = 341 + SYS_LSTAT64_EXTENDED = 342 + SYS_FSTAT64_EXTENDED = 343 + SYS_GETDIRENTRIES64 = 344 + SYS_STATFS64 = 345 + SYS_FSTATFS64 = 346 + SYS_GETFSSTAT64 = 347 + SYS___PTHREAD_CHDIR = 348 + SYS___PTHREAD_FCHDIR = 349 + SYS_AUDIT = 350 + SYS_AUDITON = 351 + SYS_GETAUID = 353 + SYS_SETAUID = 354 + SYS_GETAUDIT_ADDR = 357 + SYS_SETAUDIT_ADDR = 358 + SYS_AUDITCTL = 359 + SYS_BSDTHREAD_CREATE = 360 + SYS_BSDTHREAD_TERMINATE = 361 + SYS_KQUEUE = 362 + SYS_KEVENT = 363 + SYS_LCHOWN = 364 + SYS_STACK_SNAPSHOT = 365 + SYS_BSDTHREAD_REGISTER = 366 + SYS_WORKQ_OPEN = 367 + SYS_WORKQ_KERNRETURN = 368 + SYS_KEVENT64 = 369 + SYS___OLD_SEMWAIT_SIGNAL = 370 + SYS___OLD_SEMWAIT_SIGNAL_NOCANCEL = 371 + SYS_THREAD_SELFID = 372 + SYS_LEDGER = 373 + SYS___MAC_EXECVE = 380 + SYS___MAC_SYSCALL = 381 + SYS___MAC_GET_FILE = 382 + SYS___MAC_SET_FILE = 383 + SYS___MAC_GET_LINK = 384 + SYS___MAC_SET_LINK = 385 + SYS___MAC_GET_PROC = 386 + SYS___MAC_SET_PROC = 387 + SYS___MAC_GET_FD = 388 + SYS___MAC_SET_FD = 389 + SYS___MAC_GET_PID = 390 + SYS___MAC_GET_LCID = 391 + SYS___MAC_GET_LCTX = 392 + SYS___MAC_SET_LCTX = 393 + SYS_SETLCID = 394 + SYS_GETLCID = 395 + SYS_READ_NOCANCEL = 396 + SYS_WRITE_NOCANCEL = 397 + SYS_OPEN_NOCANCEL = 398 + SYS_CLOSE_NOCANCEL = 399 + SYS_WAIT4_NOCANCEL = 400 + SYS_RECVMSG_NOCANCEL = 401 + SYS_SENDMSG_NOCANCEL = 402 + SYS_RECVFROM_NOCANCEL = 403 + SYS_ACCEPT_NOCANCEL = 404 + SYS_MSYNC_NOCANCEL = 405 + SYS_FCNTL_NOCANCEL = 406 + SYS_SELECT_NOCANCEL = 407 + SYS_FSYNC_NOCANCEL = 408 + SYS_CONNECT_NOCANCEL = 409 + SYS_SIGSUSPEND_NOCANCEL = 410 + SYS_READV_NOCANCEL = 411 + SYS_WRITEV_NOCANCEL = 412 + SYS_SENDTO_NOCANCEL = 413 + SYS_PREAD_NOCANCEL = 414 + SYS_PWRITE_NOCANCEL = 415 + SYS_WAITID_NOCANCEL = 416 + SYS_POLL_NOCANCEL = 417 + SYS_MSGSND_NOCANCEL = 418 + SYS_MSGRCV_NOCANCEL = 419 + SYS_SEM_WAIT_NOCANCEL = 420 + SYS_AIO_SUSPEND_NOCANCEL = 421 + SYS___SIGWAIT_NOCANCEL = 422 + SYS___SEMWAIT_SIGNAL_NOCANCEL = 423 + SYS___MAC_MOUNT = 424 + SYS___MAC_GET_MOUNT = 425 + SYS___MAC_GETFSSTAT = 426 + SYS_FSGETPATH = 427 + SYS_AUDIT_SESSION_SELF = 428 + SYS_AUDIT_SESSION_JOIN = 429 + SYS_FILEPORT_MAKEPORT = 430 + SYS_FILEPORT_MAKEFD = 431 + SYS_AUDIT_SESSION_PORT = 432 + SYS_PID_SUSPEND = 433 + SYS_PID_RESUME = 434 + SYS_PID_HIBERNATE = 435 + SYS_PID_SHUTDOWN_SOCKETS = 436 + SYS_SHARED_REGION_MAP_AND_SLIDE_NP = 438 + SYS_KAS_INFO = 439 + SYS_MEMORYSTATUS_CONTROL = 440 + SYS_GUARDED_OPEN_NP = 441 + SYS_GUARDED_CLOSE_NP = 442 + SYS_GUARDED_KQUEUE_NP = 443 + SYS_CHANGE_FDGUARD_NP = 444 + SYS_PROC_RLIMIT_CONTROL = 446 + SYS_CONNECTX = 447 + SYS_DISCONNECTX = 448 + SYS_PEELOFF = 449 + SYS_SOCKET_DELEGATE = 450 + SYS_TELEMETRY = 451 + SYS_PROC_UUID_POLICY = 452 + SYS_MEMORYSTATUS_GET_LEVEL = 453 + SYS_SYSTEM_OVERRIDE = 454 + SYS_VFS_PURGE = 455 + SYS_SFI_CTL = 456 + SYS_SFI_PIDCTL = 457 + SYS_COALITION = 458 + SYS_COALITION_INFO = 459 + SYS_NECP_MATCH_POLICY = 460 + SYS_GETATTRLISTBULK = 461 + SYS_OPENAT = 463 + SYS_OPENAT_NOCANCEL = 464 + SYS_RENAMEAT = 465 + SYS_FACCESSAT = 466 + SYS_FCHMODAT = 467 + SYS_FCHOWNAT = 468 + SYS_FSTATAT = 469 + SYS_FSTATAT64 = 470 + SYS_LINKAT = 471 + SYS_UNLINKAT = 472 + SYS_READLINKAT = 473 + SYS_SYMLINKAT = 474 + SYS_MKDIRAT = 475 + SYS_GETATTRLISTAT = 476 + SYS_PROC_TRACE_LOG = 477 + SYS_BSDTHREAD_CTL = 478 + SYS_OPENBYID_NP = 479 + SYS_RECVMSG_X = 480 + SYS_SENDMSG_X = 481 + SYS_THREAD_SELFUSAGE = 482 + SYS_CSRCTL = 483 + SYS_GUARDED_OPEN_DPROTECTED_NP = 484 + SYS_GUARDED_WRITE_NP = 485 + SYS_GUARDED_PWRITE_NP = 486 + SYS_GUARDED_WRITEV_NP = 487 + SYS_RENAME_EXT = 488 + SYS_MREMAP_ENCRYPTED = 489 + SYS_MAXSYSCALL = 490 +) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_dragonfly_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_dragonfly_386.go deleted file mode 100644 index 09c3515804..0000000000 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_dragonfly_386.go +++ /dev/null @@ -1,302 +0,0 @@ -// mksysnum_dragonfly.pl -// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT - -package unix - -const ( - // SYS_NOSYS = 0; // { int nosys(void); } syscall nosys_args int - SYS_EXIT = 1 // { void exit(int rval); } - SYS_FORK = 2 // { int fork(void); } - SYS_READ = 3 // { ssize_t read(int fd, void *buf, size_t nbyte); } - SYS_WRITE = 4 // { ssize_t write(int fd, const void *buf, size_t nbyte); } - SYS_OPEN = 5 // { int open(char *path, int flags, int mode); } - SYS_CLOSE = 6 // { int close(int fd); } - SYS_WAIT4 = 7 // { int wait4(int pid, int *status, int options, \ - SYS_LINK = 9 // { int link(char *path, char *link); } - SYS_UNLINK = 10 // { int unlink(char *path); } - SYS_CHDIR = 12 // { int chdir(char *path); } - SYS_FCHDIR = 13 // { int fchdir(int fd); } - SYS_MKNOD = 14 // { int mknod(char *path, int mode, int dev); } - SYS_CHMOD = 15 // { int chmod(char *path, int mode); } - SYS_CHOWN = 16 // { int chown(char *path, int uid, int gid); } - SYS_OBREAK = 17 // { int obreak(char *nsize); } break obreak_args int - SYS_GETFSSTAT = 18 // { int getfsstat(struct statfs *buf, long bufsize, \ - SYS_GETPID = 20 // { pid_t getpid(void); } - SYS_MOUNT = 21 // { int mount(char *type, char *path, int flags, \ - SYS_UNMOUNT = 22 // { int unmount(char *path, int flags); } - SYS_SETUID = 23 // { int setuid(uid_t uid); } - SYS_GETUID = 24 // { uid_t getuid(void); } - SYS_GETEUID = 25 // { uid_t geteuid(void); } - SYS_PTRACE = 26 // { int ptrace(int req, pid_t pid, caddr_t addr, \ - SYS_RECVMSG = 27 // { int recvmsg(int s, struct msghdr *msg, int flags); } - SYS_SENDMSG = 28 // { int sendmsg(int s, caddr_t msg, int flags); } - SYS_RECVFROM = 29 // { int recvfrom(int s, caddr_t buf, size_t len, \ - SYS_ACCEPT = 30 // { int accept(int s, caddr_t name, int *anamelen); } - SYS_GETPEERNAME = 31 // { int getpeername(int fdes, caddr_t asa, int *alen); } - SYS_GETSOCKNAME = 32 // { int getsockname(int fdes, caddr_t asa, int *alen); } - SYS_ACCESS = 33 // { int access(char *path, int flags); } - SYS_CHFLAGS = 34 // { int chflags(char *path, int flags); } - SYS_FCHFLAGS = 35 // { int fchflags(int fd, int flags); } - SYS_SYNC = 36 // { int sync(void); } - SYS_KILL = 37 // { int kill(int pid, int signum); } - SYS_GETPPID = 39 // { pid_t getppid(void); } - SYS_DUP = 41 // { int dup(u_int fd); } - SYS_PIPE = 42 // { int pipe(void); } - SYS_GETEGID = 43 // { gid_t getegid(void); } - SYS_PROFIL = 44 // { int profil(caddr_t samples, size_t size, \ - SYS_KTRACE = 45 // { int ktrace(const char *fname, int ops, int facs, \ - SYS_GETGID = 47 // { gid_t getgid(void); } - SYS_GETLOGIN = 49 // { int getlogin(char *namebuf, u_int namelen); } - SYS_SETLOGIN = 50 // { int setlogin(char *namebuf); } - SYS_ACCT = 51 // { int acct(char *path); } - SYS_SIGALTSTACK = 53 // { int sigaltstack(stack_t *ss, stack_t *oss); } - SYS_IOCTL = 54 // { int ioctl(int fd, u_long com, caddr_t data); } - SYS_REBOOT = 55 // { int reboot(int opt); } - SYS_REVOKE = 56 // { int revoke(char *path); } - SYS_SYMLINK = 57 // { int symlink(char *path, char *link); } - SYS_READLINK = 58 // { int readlink(char *path, char *buf, int count); } - SYS_EXECVE = 59 // { int execve(char *fname, char **argv, char **envv); } - SYS_UMASK = 60 // { int umask(int newmask); } umask umask_args int - SYS_CHROOT = 61 // { int chroot(char *path); } - SYS_MSYNC = 65 // { int msync(void *addr, size_t len, int flags); } - SYS_VFORK = 66 // { pid_t vfork(void); } - SYS_SBRK = 69 // { int sbrk(int incr); } - SYS_SSTK = 70 // { int sstk(int incr); } - SYS_MUNMAP = 73 // { int munmap(void *addr, size_t len); } - SYS_MPROTECT = 74 // { int mprotect(void *addr, size_t len, int prot); } - SYS_MADVISE = 75 // { int madvise(void *addr, size_t len, int behav); } - SYS_MINCORE = 78 // { int mincore(const void *addr, size_t len, \ - SYS_GETGROUPS = 79 // { int getgroups(u_int gidsetsize, gid_t *gidset); } - SYS_SETGROUPS = 80 // { int setgroups(u_int gidsetsize, gid_t *gidset); } - SYS_GETPGRP = 81 // { int getpgrp(void); } - SYS_SETPGID = 82 // { int setpgid(int pid, int pgid); } - SYS_SETITIMER = 83 // { int setitimer(u_int which, struct itimerval *itv, \ - SYS_SWAPON = 85 // { int swapon(char *name); } - SYS_GETITIMER = 86 // { int getitimer(u_int which, struct itimerval *itv); } - SYS_GETDTABLESIZE = 89 // { int getdtablesize(void); } - SYS_DUP2 = 90 // { int dup2(u_int from, u_int to); } - SYS_FCNTL = 92 // { int fcntl(int fd, int cmd, long arg); } - SYS_SELECT = 93 // { int select(int nd, fd_set *in, fd_set *ou, \ - SYS_FSYNC = 95 // { int fsync(int fd); } - SYS_SETPRIORITY = 96 // { int setpriority(int which, int who, int prio); } - SYS_SOCKET = 97 // { int socket(int domain, int type, int protocol); } - SYS_CONNECT = 98 // { int connect(int s, caddr_t name, int namelen); } - SYS_GETPRIORITY = 100 // { int getpriority(int which, int who); } - SYS_BIND = 104 // { int bind(int s, caddr_t name, int namelen); } - SYS_SETSOCKOPT = 105 // { int setsockopt(int s, int level, int name, \ - SYS_LISTEN = 106 // { int listen(int s, int backlog); } - SYS_GETTIMEOFDAY = 116 // { int gettimeofday(struct timeval *tp, \ - SYS_GETRUSAGE = 117 // { int getrusage(int who, struct rusage *rusage); } - SYS_GETSOCKOPT = 118 // { int getsockopt(int s, int level, int name, \ - SYS_READV = 120 // { int readv(int fd, struct iovec *iovp, u_int iovcnt); } - SYS_WRITEV = 121 // { int writev(int fd, struct iovec *iovp, \ - SYS_SETTIMEOFDAY = 122 // { int settimeofday(struct timeval *tv, \ - SYS_FCHOWN = 123 // { int fchown(int fd, int uid, int gid); } - SYS_FCHMOD = 124 // { int fchmod(int fd, int mode); } - SYS_SETREUID = 126 // { int setreuid(int ruid, int euid); } - SYS_SETREGID = 127 // { int setregid(int rgid, int egid); } - SYS_RENAME = 128 // { int rename(char *from, char *to); } - SYS_FLOCK = 131 // { int flock(int fd, int how); } - SYS_MKFIFO = 132 // { int mkfifo(char *path, int mode); } - SYS_SENDTO = 133 // { int sendto(int s, caddr_t buf, size_t len, \ - SYS_SHUTDOWN = 134 // { int shutdown(int s, int how); } - SYS_SOCKETPAIR = 135 // { int socketpair(int domain, int type, int protocol, \ - SYS_MKDIR = 136 // { int mkdir(char *path, int mode); } - SYS_RMDIR = 137 // { int rmdir(char *path); } - SYS_UTIMES = 138 // { int utimes(char *path, struct timeval *tptr); } - SYS_ADJTIME = 140 // { int adjtime(struct timeval *delta, \ - SYS_SETSID = 147 // { int setsid(void); } - SYS_QUOTACTL = 148 // { int quotactl(char *path, int cmd, int uid, \ - SYS_STATFS = 157 // { int statfs(char *path, struct statfs *buf); } - SYS_FSTATFS = 158 // { int fstatfs(int fd, struct statfs *buf); } - SYS_GETFH = 161 // { int getfh(char *fname, struct fhandle *fhp); } - SYS_GETDOMAINNAME = 162 // { int getdomainname(char *domainname, int len); } - SYS_SETDOMAINNAME = 163 // { int setdomainname(char *domainname, int len); } - SYS_UNAME = 164 // { int uname(struct utsname *name); } - SYS_SYSARCH = 165 // { int sysarch(int op, char *parms); } - SYS_RTPRIO = 166 // { int rtprio(int function, pid_t pid, \ - SYS_EXTPREAD = 173 // { ssize_t extpread(int fd, void *buf, \ - SYS_EXTPWRITE = 174 // { ssize_t extpwrite(int fd, const void *buf, \ - SYS_NTP_ADJTIME = 176 // { int ntp_adjtime(struct timex *tp); } - SYS_SETGID = 181 // { int setgid(gid_t gid); } - SYS_SETEGID = 182 // { int setegid(gid_t egid); } - SYS_SETEUID = 183 // { int seteuid(uid_t euid); } - SYS_PATHCONF = 191 // { int pathconf(char *path, int name); } - SYS_FPATHCONF = 192 // { int fpathconf(int fd, int name); } - SYS_GETRLIMIT = 194 // { int getrlimit(u_int which, \ - SYS_SETRLIMIT = 195 // { int setrlimit(u_int which, \ - SYS_MMAP = 197 // { caddr_t mmap(caddr_t addr, size_t len, int prot, \ - // SYS_NOSYS = 198; // { int nosys(void); } __syscall __syscall_args int - SYS_LSEEK = 199 // { off_t lseek(int fd, int pad, off_t offset, \ - SYS_TRUNCATE = 200 // { int truncate(char *path, int pad, off_t length); } - SYS_FTRUNCATE = 201 // { int ftruncate(int fd, int pad, off_t length); } - SYS___SYSCTL = 202 // { int __sysctl(int *name, u_int namelen, void *old, \ - SYS_MLOCK = 203 // { int mlock(const void *addr, size_t len); } - SYS_MUNLOCK = 204 // { int munlock(const void *addr, size_t len); } - SYS_UNDELETE = 205 // { int undelete(char *path); } - SYS_FUTIMES = 206 // { int futimes(int fd, struct timeval *tptr); } - SYS_GETPGID = 207 // { int getpgid(pid_t pid); } - SYS_POLL = 209 // { int poll(struct pollfd *fds, u_int nfds, \ - SYS___SEMCTL = 220 // { int __semctl(int semid, int semnum, int cmd, \ - SYS_SEMGET = 221 // { int semget(key_t key, int nsems, int semflg); } - SYS_SEMOP = 222 // { int semop(int semid, struct sembuf *sops, \ - SYS_MSGCTL = 224 // { int msgctl(int msqid, int cmd, \ - SYS_MSGGET = 225 // { int msgget(key_t key, int msgflg); } - SYS_MSGSND = 226 // { int msgsnd(int msqid, void *msgp, size_t msgsz, \ - SYS_MSGRCV = 227 // { int msgrcv(int msqid, void *msgp, size_t msgsz, \ - SYS_SHMAT = 228 // { caddr_t shmat(int shmid, const void *shmaddr, \ - SYS_SHMCTL = 229 // { int shmctl(int shmid, int cmd, \ - SYS_SHMDT = 230 // { int shmdt(const void *shmaddr); } - SYS_SHMGET = 231 // { int shmget(key_t key, size_t size, int shmflg); } - SYS_CLOCK_GETTIME = 232 // { int clock_gettime(clockid_t clock_id, \ - SYS_CLOCK_SETTIME = 233 // { int clock_settime(clockid_t clock_id, \ - SYS_CLOCK_GETRES = 234 // { int clock_getres(clockid_t clock_id, \ - SYS_NANOSLEEP = 240 // { int nanosleep(const struct timespec *rqtp, \ - SYS_MINHERIT = 250 // { int minherit(void *addr, size_t len, int inherit); } - SYS_RFORK = 251 // { int rfork(int flags); } - SYS_OPENBSD_POLL = 252 // { int openbsd_poll(struct pollfd *fds, u_int nfds, \ - SYS_ISSETUGID = 253 // { int issetugid(void); } - SYS_LCHOWN = 254 // { int lchown(char *path, int uid, int gid); } - SYS_LCHMOD = 274 // { int lchmod(char *path, mode_t mode); } - SYS_LUTIMES = 276 // { int lutimes(char *path, struct timeval *tptr); } - SYS_EXTPREADV = 289 // { ssize_t extpreadv(int fd, struct iovec *iovp, \ - SYS_EXTPWRITEV = 290 // { ssize_t extpwritev(int fd, struct iovec *iovp,\ - SYS_FHSTATFS = 297 // { int fhstatfs(const struct fhandle *u_fhp, struct statfs *buf); } - SYS_FHOPEN = 298 // { int fhopen(const struct fhandle *u_fhp, int flags); } - SYS_MODNEXT = 300 // { int modnext(int modid); } - SYS_MODSTAT = 301 // { int modstat(int modid, struct module_stat* stat); } - SYS_MODFNEXT = 302 // { int modfnext(int modid); } - SYS_MODFIND = 303 // { int modfind(const char *name); } - SYS_KLDLOAD = 304 // { int kldload(const char *file); } - SYS_KLDUNLOAD = 305 // { int kldunload(int fileid); } - SYS_KLDFIND = 306 // { int kldfind(const char *file); } - SYS_KLDNEXT = 307 // { int kldnext(int fileid); } - SYS_KLDSTAT = 308 // { int kldstat(int fileid, struct kld_file_stat* stat); } - SYS_KLDFIRSTMOD = 309 // { int kldfirstmod(int fileid); } - SYS_GETSID = 310 // { int getsid(pid_t pid); } - SYS_SETRESUID = 311 // { int setresuid(uid_t ruid, uid_t euid, uid_t suid); } - SYS_SETRESGID = 312 // { int setresgid(gid_t rgid, gid_t egid, gid_t sgid); } - SYS_AIO_RETURN = 314 // { int aio_return(struct aiocb *aiocbp); } - SYS_AIO_SUSPEND = 315 // { int aio_suspend(struct aiocb * const * aiocbp, int nent, const struct timespec *timeout); } - SYS_AIO_CANCEL = 316 // { int aio_cancel(int fd, struct aiocb *aiocbp); } - SYS_AIO_ERROR = 317 // { int aio_error(struct aiocb *aiocbp); } - SYS_AIO_READ = 318 // { int aio_read(struct aiocb *aiocbp); } - SYS_AIO_WRITE = 319 // { int aio_write(struct aiocb *aiocbp); } - SYS_LIO_LISTIO = 320 // { int lio_listio(int mode, struct aiocb * const *acb_list, int nent, struct sigevent *sig); } - SYS_YIELD = 321 // { int yield(void); } - SYS_MLOCKALL = 324 // { int mlockall(int how); } - SYS_MUNLOCKALL = 325 // { int munlockall(void); } - SYS___GETCWD = 326 // { int __getcwd(u_char *buf, u_int buflen); } - SYS_SCHED_SETPARAM = 327 // { int sched_setparam (pid_t pid, const struct sched_param *param); } - SYS_SCHED_GETPARAM = 328 // { int sched_getparam (pid_t pid, struct sched_param *param); } - SYS_SCHED_SETSCHEDULER = 329 // { int sched_setscheduler (pid_t pid, int policy, const struct sched_param *param); } - SYS_SCHED_GETSCHEDULER = 330 // { int sched_getscheduler (pid_t pid); } - SYS_SCHED_YIELD = 331 // { int sched_yield (void); } - SYS_SCHED_GET_PRIORITY_MAX = 332 // { int sched_get_priority_max (int policy); } - SYS_SCHED_GET_PRIORITY_MIN = 333 // { int sched_get_priority_min (int policy); } - SYS_SCHED_RR_GET_INTERVAL = 334 // { int sched_rr_get_interval (pid_t pid, struct timespec *interval); } - SYS_UTRACE = 335 // { int utrace(const void *addr, size_t len); } - SYS_KLDSYM = 337 // { int kldsym(int fileid, int cmd, void *data); } - SYS_JAIL = 338 // { int jail(struct jail *jail); } - SYS_SIGPROCMASK = 340 // { int sigprocmask(int how, const sigset_t *set, \ - SYS_SIGSUSPEND = 341 // { int sigsuspend(const sigset_t *sigmask); } - SYS_SIGACTION = 342 // { int sigaction(int sig, const struct sigaction *act, \ - SYS_SIGPENDING = 343 // { int sigpending(sigset_t *set); } - SYS_SIGRETURN = 344 // { int sigreturn(ucontext_t *sigcntxp); } - SYS_SIGTIMEDWAIT = 345 // { int sigtimedwait(const sigset_t *set,\ - SYS_SIGWAITINFO = 346 // { int sigwaitinfo(const sigset_t *set,\ - SYS___ACL_GET_FILE = 347 // { int __acl_get_file(const char *path, \ - SYS___ACL_SET_FILE = 348 // { int __acl_set_file(const char *path, \ - SYS___ACL_GET_FD = 349 // { int __acl_get_fd(int filedes, acl_type_t type, \ - SYS___ACL_SET_FD = 350 // { int __acl_set_fd(int filedes, acl_type_t type, \ - SYS___ACL_DELETE_FILE = 351 // { int __acl_delete_file(const char *path, \ - SYS___ACL_DELETE_FD = 352 // { int __acl_delete_fd(int filedes, acl_type_t type); } - SYS___ACL_ACLCHECK_FILE = 353 // { int __acl_aclcheck_file(const char *path, \ - SYS___ACL_ACLCHECK_FD = 354 // { int __acl_aclcheck_fd(int filedes, acl_type_t type, \ - SYS_EXTATTRCTL = 355 // { int extattrctl(const char *path, int cmd, \ - SYS_EXTATTR_SET_FILE = 356 // { int extattr_set_file(const char *path, \ - SYS_EXTATTR_GET_FILE = 357 // { int extattr_get_file(const char *path, \ - SYS_EXTATTR_DELETE_FILE = 358 // { int extattr_delete_file(const char *path, \ - SYS_AIO_WAITCOMPLETE = 359 // { int aio_waitcomplete(struct aiocb **aiocbp, struct timespec *timeout); } - SYS_GETRESUID = 360 // { int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid); } - SYS_GETRESGID = 361 // { int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid); } - SYS_KQUEUE = 362 // { int kqueue(void); } - SYS_KEVENT = 363 // { int kevent(int fd, \ - SYS_SCTP_PEELOFF = 364 // { int sctp_peeloff(int sd, caddr_t name ); } - SYS_LCHFLAGS = 391 // { int lchflags(char *path, int flags); } - SYS_UUIDGEN = 392 // { int uuidgen(struct uuid *store, int count); } - SYS_SENDFILE = 393 // { int sendfile(int fd, int s, off_t offset, size_t nbytes, \ - SYS_VARSYM_SET = 450 // { int varsym_set(int level, const char *name, const char *data); } - SYS_VARSYM_GET = 451 // { int varsym_get(int mask, const char *wild, char *buf, int bufsize); } - SYS_VARSYM_LIST = 452 // { int varsym_list(int level, char *buf, int maxsize, int *marker); } - SYS_EXEC_SYS_REGISTER = 465 // { int exec_sys_register(void *entry); } - SYS_EXEC_SYS_UNREGISTER = 466 // { int exec_sys_unregister(int id); } - SYS_SYS_CHECKPOINT = 467 // { int sys_checkpoint(int type, int fd, pid_t pid, int retval); } - SYS_MOUNTCTL = 468 // { int mountctl(const char *path, int op, int fd, const void *ctl, int ctllen, void *buf, int buflen); } - SYS_UMTX_SLEEP = 469 // { int umtx_sleep(volatile const int *ptr, int value, int timeout); } - SYS_UMTX_WAKEUP = 470 // { int umtx_wakeup(volatile const int *ptr, int count); } - SYS_JAIL_ATTACH = 471 // { int jail_attach(int jid); } - SYS_SET_TLS_AREA = 472 // { int set_tls_area(int which, struct tls_info *info, size_t infosize); } - SYS_GET_TLS_AREA = 473 // { int get_tls_area(int which, struct tls_info *info, size_t infosize); } - SYS_CLOSEFROM = 474 // { int closefrom(int fd); } - SYS_STAT = 475 // { int stat(const char *path, struct stat *ub); } - SYS_FSTAT = 476 // { int fstat(int fd, struct stat *sb); } - SYS_LSTAT = 477 // { int lstat(const char *path, struct stat *ub); } - SYS_FHSTAT = 478 // { int fhstat(const struct fhandle *u_fhp, struct stat *sb); } - SYS_GETDIRENTRIES = 479 // { int getdirentries(int fd, char *buf, u_int count, \ - SYS_GETDENTS = 480 // { int getdents(int fd, char *buf, size_t count); } - SYS_USCHED_SET = 481 // { int usched_set(pid_t pid, int cmd, void *data, \ - SYS_EXTACCEPT = 482 // { int extaccept(int s, int flags, caddr_t name, int *anamelen); } - SYS_EXTCONNECT = 483 // { int extconnect(int s, int flags, caddr_t name, int namelen); } - SYS_MCONTROL = 485 // { int mcontrol(void *addr, size_t len, int behav, off_t value); } - SYS_VMSPACE_CREATE = 486 // { int vmspace_create(void *id, int type, void *data); } - SYS_VMSPACE_DESTROY = 487 // { int vmspace_destroy(void *id); } - SYS_VMSPACE_CTL = 488 // { int vmspace_ctl(void *id, int cmd, \ - SYS_VMSPACE_MMAP = 489 // { int vmspace_mmap(void *id, void *addr, size_t len, \ - SYS_VMSPACE_MUNMAP = 490 // { int vmspace_munmap(void *id, void *addr, \ - SYS_VMSPACE_MCONTROL = 491 // { int vmspace_mcontrol(void *id, void *addr, \ - SYS_VMSPACE_PREAD = 492 // { ssize_t vmspace_pread(void *id, void *buf, \ - SYS_VMSPACE_PWRITE = 493 // { ssize_t vmspace_pwrite(void *id, const void *buf, \ - SYS_EXTEXIT = 494 // { void extexit(int how, int status, void *addr); } - SYS_LWP_CREATE = 495 // { int lwp_create(struct lwp_params *params); } - SYS_LWP_GETTID = 496 // { lwpid_t lwp_gettid(void); } - SYS_LWP_KILL = 497 // { int lwp_kill(pid_t pid, lwpid_t tid, int signum); } - SYS_LWP_RTPRIO = 498 // { int lwp_rtprio(int function, pid_t pid, lwpid_t tid, struct rtprio *rtp); } - SYS_PSELECT = 499 // { int pselect(int nd, fd_set *in, fd_set *ou, \ - SYS_STATVFS = 500 // { int statvfs(const char *path, struct statvfs *buf); } - SYS_FSTATVFS = 501 // { int fstatvfs(int fd, struct statvfs *buf); } - SYS_FHSTATVFS = 502 // { int fhstatvfs(const struct fhandle *u_fhp, struct statvfs *buf); } - SYS_GETVFSSTAT = 503 // { int getvfsstat(struct statfs *buf, \ - SYS_OPENAT = 504 // { int openat(int fd, char *path, int flags, int mode); } - SYS_FSTATAT = 505 // { int fstatat(int fd, char *path, \ - SYS_FCHMODAT = 506 // { int fchmodat(int fd, char *path, int mode, \ - SYS_FCHOWNAT = 507 // { int fchownat(int fd, char *path, int uid, int gid, \ - SYS_UNLINKAT = 508 // { int unlinkat(int fd, char *path, int flags); } - SYS_FACCESSAT = 509 // { int faccessat(int fd, char *path, int amode, \ - SYS_MQ_OPEN = 510 // { mqd_t mq_open(const char * name, int oflag, \ - SYS_MQ_CLOSE = 511 // { int mq_close(mqd_t mqdes); } - SYS_MQ_UNLINK = 512 // { int mq_unlink(const char *name); } - SYS_MQ_GETATTR = 513 // { int mq_getattr(mqd_t mqdes, \ - SYS_MQ_SETATTR = 514 // { int mq_setattr(mqd_t mqdes, \ - SYS_MQ_NOTIFY = 515 // { int mq_notify(mqd_t mqdes, \ - SYS_MQ_SEND = 516 // { int mq_send(mqd_t mqdes, const char *msg_ptr, \ - SYS_MQ_RECEIVE = 517 // { ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, \ - SYS_MQ_TIMEDSEND = 518 // { int mq_timedsend(mqd_t mqdes, \ - SYS_MQ_TIMEDRECEIVE = 519 // { ssize_t mq_timedreceive(mqd_t mqdes, \ - SYS_IOPRIO_SET = 520 // { int ioprio_set(int which, int who, int prio); } - SYS_IOPRIO_GET = 521 // { int ioprio_get(int which, int who); } - SYS_CHROOT_KERNEL = 522 // { int chroot_kernel(char *path); } - SYS_RENAMEAT = 523 // { int renameat(int oldfd, char *old, int newfd, \ - SYS_MKDIRAT = 524 // { int mkdirat(int fd, char *path, mode_t mode); } - SYS_MKFIFOAT = 525 // { int mkfifoat(int fd, char *path, mode_t mode); } - SYS_MKNODAT = 526 // { int mknodat(int fd, char *path, mode_t mode, \ - SYS_READLINKAT = 527 // { int readlinkat(int fd, char *path, char *buf, \ - SYS_SYMLINKAT = 528 // { int symlinkat(char *path1, int fd, char *path2); } - SYS_SWAPOFF = 529 // { int swapoff(char *name); } - SYS_VQUOTACTL = 530 // { int vquotactl(const char *path, \ - SYS_LINKAT = 531 // { int linkat(int fd1, char *path1, int fd2, \ - SYS_EACCESS = 532 // { int eaccess(char *path, int flags); } - SYS_LPATHCONF = 533 // { int lpathconf(char *path, int name); } - SYS_VMM_GUEST_CTL = 534 // { int vmm_guest_ctl(int op, struct vmm_guest_options *options); } - SYS_VMM_GUEST_SYNC_ADDR = 535 // { int vmm_guest_sync_addr(long *dstaddr, long *srcaddr); } -) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go index 09c3515804..d6038fa9b0 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go @@ -1,6 +1,8 @@ // mksysnum_dragonfly.pl // MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT +// +build amd64,dragonfly + package unix const ( diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_freebsd_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_freebsd_386.go index 782eb91721..262a84536a 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_freebsd_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_freebsd_386.go @@ -1,6 +1,8 @@ // mksysnum_freebsd.pl // MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT +// +build 386,freebsd + package unix const ( diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go index 782eb91721..57a60ea126 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go @@ -1,6 +1,8 @@ // mksysnum_freebsd.pl // MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT +// +build amd64,freebsd + package unix const ( diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_freebsd_arm.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_freebsd_arm.go index 782eb91721..206b9f612d 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_freebsd_arm.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_freebsd_arm.go @@ -1,6 +1,8 @@ // mksysnum_freebsd.pl // MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT +// +build arm,freebsd + package unix const ( diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_386.go index b6f993f7bc..ba952c6754 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_386.go @@ -1,6 +1,8 @@ // mksysnum_linux.pl /usr/include/asm/unistd_32.h // MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT +// +build 386,linux + package unix const ( diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_amd64.go index c2da210c5e..ddac31f58a 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_amd64.go @@ -1,6 +1,8 @@ // mksysnum_linux.pl /usr/include/asm/unistd_64.h // MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT +// +build amd64,linux + package unix const ( diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_arm.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_arm.go index e2b7d19d79..45ced17fc4 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_arm.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_arm.go @@ -1,6 +1,8 @@ // mksysnum_linux.pl // MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT +// +build arm,linux + package unix const ( diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_arm64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_arm64.go new file mode 100644 index 0000000000..2e9514f280 --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_arm64.go @@ -0,0 +1,272 @@ +// mksysnum_linux.pl /usr/include/asm-generic/unistd.h +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build arm64,linux + +package unix + +const ( + SYS_IO_SETUP = 0 + SYS_IO_DESTROY = 1 + SYS_IO_SUBMIT = 2 + SYS_IO_CANCEL = 3 + SYS_IO_GETEVENTS = 4 + SYS_SETXATTR = 5 + SYS_LSETXATTR = 6 + SYS_FSETXATTR = 7 + SYS_GETXATTR = 8 + SYS_LGETXATTR = 9 + SYS_FGETXATTR = 10 + SYS_LISTXATTR = 11 + SYS_LLISTXATTR = 12 + SYS_FLISTXATTR = 13 + SYS_REMOVEXATTR = 14 + SYS_LREMOVEXATTR = 15 + SYS_FREMOVEXATTR = 16 + SYS_GETCWD = 17 + SYS_LOOKUP_DCOOKIE = 18 + SYS_EVENTFD2 = 19 + SYS_EPOLL_CREATE1 = 20 + SYS_EPOLL_CTL = 21 + SYS_EPOLL_PWAIT = 22 + SYS_DUP = 23 + SYS_DUP3 = 24 + SYS_FCNTL = 25 + SYS_INOTIFY_INIT1 = 26 + SYS_INOTIFY_ADD_WATCH = 27 + SYS_INOTIFY_RM_WATCH = 28 + SYS_IOCTL = 29 + SYS_IOPRIO_SET = 30 + SYS_IOPRIO_GET = 31 + SYS_FLOCK = 32 + SYS_MKNODAT = 33 + SYS_MKDIRAT = 34 + SYS_UNLINKAT = 35 + SYS_SYMLINKAT = 36 + SYS_LINKAT = 37 + SYS_RENAMEAT = 38 + SYS_UMOUNT2 = 39 + SYS_MOUNT = 40 + SYS_PIVOT_ROOT = 41 + SYS_NFSSERVCTL = 42 + SYS_STATFS = 43 + SYS_FSTATFS = 44 + SYS_TRUNCATE = 45 + SYS_FTRUNCATE = 46 + SYS_FALLOCATE = 47 + SYS_FACCESSAT = 48 + SYS_CHDIR = 49 + SYS_FCHDIR = 50 + SYS_CHROOT = 51 + SYS_FCHMOD = 52 + SYS_FCHMODAT = 53 + SYS_FCHOWNAT = 54 + SYS_FCHOWN = 55 + SYS_OPENAT = 56 + SYS_CLOSE = 57 + SYS_VHANGUP = 58 + SYS_PIPE2 = 59 + SYS_QUOTACTL = 60 + SYS_GETDENTS64 = 61 + SYS_LSEEK = 62 + SYS_READ = 63 + SYS_WRITE = 64 + SYS_READV = 65 + SYS_WRITEV = 66 + SYS_PREAD64 = 67 + SYS_PWRITE64 = 68 + SYS_PREADV = 69 + SYS_PWRITEV = 70 + SYS_SENDFILE = 71 + SYS_PSELECT6 = 72 + SYS_PPOLL = 73 + SYS_SIGNALFD4 = 74 + SYS_VMSPLICE = 75 + SYS_SPLICE = 76 + SYS_TEE = 77 + SYS_READLINKAT = 78 + SYS_FSTATAT = 79 + SYS_FSTAT = 80 + SYS_SYNC = 81 + SYS_FSYNC = 82 + SYS_FDATASYNC = 83 + SYS_SYNC_FILE_RANGE = 84 + SYS_TIMERFD_CREATE = 85 + SYS_TIMERFD_SETTIME = 86 + SYS_TIMERFD_GETTIME = 87 + SYS_UTIMENSAT = 88 + SYS_ACCT = 89 + SYS_CAPGET = 90 + SYS_CAPSET = 91 + SYS_PERSONALITY = 92 + SYS_EXIT = 93 + SYS_EXIT_GROUP = 94 + SYS_WAITID = 95 + SYS_SET_TID_ADDRESS = 96 + SYS_UNSHARE = 97 + SYS_FUTEX = 98 + SYS_SET_ROBUST_LIST = 99 + SYS_GET_ROBUST_LIST = 100 + SYS_NANOSLEEP = 101 + SYS_GETITIMER = 102 + SYS_SETITIMER = 103 + SYS_KEXEC_LOAD = 104 + SYS_INIT_MODULE = 105 + SYS_DELETE_MODULE = 106 + SYS_TIMER_CREATE = 107 + SYS_TIMER_GETTIME = 108 + SYS_TIMER_GETOVERRUN = 109 + SYS_TIMER_SETTIME = 110 + SYS_TIMER_DELETE = 111 + SYS_CLOCK_SETTIME = 112 + SYS_CLOCK_GETTIME = 113 + SYS_CLOCK_GETRES = 114 + SYS_CLOCK_NANOSLEEP = 115 + SYS_SYSLOG = 116 + SYS_PTRACE = 117 + SYS_SCHED_SETPARAM = 118 + SYS_SCHED_SETSCHEDULER = 119 + SYS_SCHED_GETSCHEDULER = 120 + SYS_SCHED_GETPARAM = 121 + SYS_SCHED_SETAFFINITY = 122 + SYS_SCHED_GETAFFINITY = 123 + SYS_SCHED_YIELD = 124 + SYS_SCHED_GET_PRIORITY_MAX = 125 + SYS_SCHED_GET_PRIORITY_MIN = 126 + SYS_SCHED_RR_GET_INTERVAL = 127 + SYS_RESTART_SYSCALL = 128 + SYS_KILL = 129 + SYS_TKILL = 130 + SYS_TGKILL = 131 + SYS_SIGALTSTACK = 132 + SYS_RT_SIGSUSPEND = 133 + SYS_RT_SIGACTION = 134 + SYS_RT_SIGPROCMASK = 135 + SYS_RT_SIGPENDING = 136 + SYS_RT_SIGTIMEDWAIT = 137 + SYS_RT_SIGQUEUEINFO = 138 + SYS_RT_SIGRETURN = 139 + SYS_SETPRIORITY = 140 + SYS_GETPRIORITY = 141 + SYS_REBOOT = 142 + SYS_SETREGID = 143 + SYS_SETGID = 144 + SYS_SETREUID = 145 + SYS_SETUID = 146 + SYS_SETRESUID = 147 + SYS_GETRESUID = 148 + SYS_SETRESGID = 149 + SYS_GETRESGID = 150 + SYS_SETFSUID = 151 + SYS_SETFSGID = 152 + SYS_TIMES = 153 + SYS_SETPGID = 154 + SYS_GETPGID = 155 + SYS_GETSID = 156 + SYS_SETSID = 157 + SYS_GETGROUPS = 158 + SYS_SETGROUPS = 159 + SYS_UNAME = 160 + SYS_SETHOSTNAME = 161 + SYS_SETDOMAINNAME = 162 + SYS_GETRLIMIT = 163 + SYS_SETRLIMIT = 164 + SYS_GETRUSAGE = 165 + SYS_UMASK = 166 + SYS_PRCTL = 167 + SYS_GETCPU = 168 + SYS_GETTIMEOFDAY = 169 + SYS_SETTIMEOFDAY = 170 + SYS_ADJTIMEX = 171 + SYS_GETPID = 172 + SYS_GETPPID = 173 + SYS_GETUID = 174 + SYS_GETEUID = 175 + SYS_GETGID = 176 + SYS_GETEGID = 177 + SYS_GETTID = 178 + SYS_SYSINFO = 179 + SYS_MQ_OPEN = 180 + SYS_MQ_UNLINK = 181 + SYS_MQ_TIMEDSEND = 182 + SYS_MQ_TIMEDRECEIVE = 183 + SYS_MQ_NOTIFY = 184 + SYS_MQ_GETSETATTR = 185 + SYS_MSGGET = 186 + SYS_MSGCTL = 187 + SYS_MSGRCV = 188 + SYS_MSGSND = 189 + SYS_SEMGET = 190 + SYS_SEMCTL = 191 + SYS_SEMTIMEDOP = 192 + SYS_SEMOP = 193 + SYS_SHMGET = 194 + SYS_SHMCTL = 195 + SYS_SHMAT = 196 + SYS_SHMDT = 197 + SYS_SOCKET = 198 + SYS_SOCKETPAIR = 199 + SYS_BIND = 200 + SYS_LISTEN = 201 + SYS_ACCEPT = 202 + SYS_CONNECT = 203 + SYS_GETSOCKNAME = 204 + SYS_GETPEERNAME = 205 + SYS_SENDTO = 206 + SYS_RECVFROM = 207 + SYS_SETSOCKOPT = 208 + SYS_GETSOCKOPT = 209 + SYS_SHUTDOWN = 210 + SYS_SENDMSG = 211 + SYS_RECVMSG = 212 + SYS_READAHEAD = 213 + SYS_BRK = 214 + SYS_MUNMAP = 215 + SYS_MREMAP = 216 + SYS_ADD_KEY = 217 + SYS_REQUEST_KEY = 218 + SYS_KEYCTL = 219 + SYS_CLONE = 220 + SYS_EXECVE = 221 + SYS_MMAP = 222 + SYS_FADVISE64 = 223 + SYS_SWAPON = 224 + SYS_SWAPOFF = 225 + SYS_MPROTECT = 226 + SYS_MSYNC = 227 + SYS_MLOCK = 228 + SYS_MUNLOCK = 229 + SYS_MLOCKALL = 230 + SYS_MUNLOCKALL = 231 + SYS_MINCORE = 232 + SYS_MADVISE = 233 + SYS_REMAP_FILE_PAGES = 234 + SYS_MBIND = 235 + SYS_GET_MEMPOLICY = 236 + SYS_SET_MEMPOLICY = 237 + SYS_MIGRATE_PAGES = 238 + SYS_MOVE_PAGES = 239 + SYS_RT_TGSIGQUEUEINFO = 240 + SYS_PERF_EVENT_OPEN = 241 + SYS_ACCEPT4 = 242 + SYS_RECVMMSG = 243 + SYS_ARCH_SPECIFIC_SYSCALL = 244 + SYS_WAIT4 = 260 + SYS_PRLIMIT64 = 261 + SYS_FANOTIFY_INIT = 262 + SYS_FANOTIFY_MARK = 263 + SYS_NAME_TO_HANDLE_AT = 264 + SYS_OPEN_BY_HANDLE_AT = 265 + SYS_CLOCK_ADJTIME = 266 + SYS_SYNCFS = 267 + SYS_SETNS = 268 + SYS_SENDMMSG = 269 + SYS_PROCESS_VM_READV = 270 + SYS_PROCESS_VM_WRITEV = 271 + SYS_KCMP = 272 + SYS_FINIT_MODULE = 273 + SYS_SCHED_SETATTR = 274 + SYS_SCHED_GETATTR = 275 + SYS_RENAMEAT2 = 276 + SYS_SECCOMP = 277 +) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_mips64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_mips64.go new file mode 100644 index 0000000000..5ffe1c7191 --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_mips64.go @@ -0,0 +1,327 @@ +// mksysnum_linux.pl /usr/include/asm/unistd.h +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build mips64,linux + +package unix + +const ( + SYS_READ = 5000 + SYS_WRITE = 5001 + SYS_OPEN = 5002 + SYS_CLOSE = 5003 + SYS_STAT = 5004 + SYS_FSTAT = 5005 + SYS_LSTAT = 5006 + SYS_POLL = 5007 + SYS_LSEEK = 5008 + SYS_MMAP = 5009 + SYS_MPROTECT = 5010 + SYS_MUNMAP = 5011 + SYS_BRK = 5012 + SYS_RT_SIGACTION = 5013 + SYS_RT_SIGPROCMASK = 5014 + SYS_IOCTL = 5015 + SYS_PREAD64 = 5016 + SYS_PWRITE64 = 5017 + SYS_READV = 5018 + SYS_WRITEV = 5019 + SYS_ACCESS = 5020 + SYS_PIPE = 5021 + SYS__NEWSELECT = 5022 + SYS_SCHED_YIELD = 5023 + SYS_MREMAP = 5024 + SYS_MSYNC = 5025 + SYS_MINCORE = 5026 + SYS_MADVISE = 5027 + SYS_SHMGET = 5028 + SYS_SHMAT = 5029 + SYS_SHMCTL = 5030 + SYS_DUP = 5031 + SYS_DUP2 = 5032 + SYS_PAUSE = 5033 + SYS_NANOSLEEP = 5034 + SYS_GETITIMER = 5035 + SYS_SETITIMER = 5036 + SYS_ALARM = 5037 + SYS_GETPID = 5038 + SYS_SENDFILE = 5039 + SYS_SOCKET = 5040 + SYS_CONNECT = 5041 + SYS_ACCEPT = 5042 + SYS_SENDTO = 5043 + SYS_RECVFROM = 5044 + SYS_SENDMSG = 5045 + SYS_RECVMSG = 5046 + SYS_SHUTDOWN = 5047 + SYS_BIND = 5048 + SYS_LISTEN = 5049 + SYS_GETSOCKNAME = 5050 + SYS_GETPEERNAME = 5051 + SYS_SOCKETPAIR = 5052 + SYS_SETSOCKOPT = 5053 + SYS_GETSOCKOPT = 5054 + SYS_CLONE = 5055 + SYS_FORK = 5056 + SYS_EXECVE = 5057 + SYS_EXIT = 5058 + SYS_WAIT4 = 5059 + SYS_KILL = 5060 + SYS_UNAME = 5061 + SYS_SEMGET = 5062 + SYS_SEMOP = 5063 + SYS_SEMCTL = 5064 + SYS_SHMDT = 5065 + SYS_MSGGET = 5066 + SYS_MSGSND = 5067 + SYS_MSGRCV = 5068 + SYS_MSGCTL = 5069 + SYS_FCNTL = 5070 + SYS_FLOCK = 5071 + SYS_FSYNC = 5072 + SYS_FDATASYNC = 5073 + SYS_TRUNCATE = 5074 + SYS_FTRUNCATE = 5075 + SYS_GETDENTS = 5076 + SYS_GETCWD = 5077 + SYS_CHDIR = 5078 + SYS_FCHDIR = 5079 + SYS_RENAME = 5080 + SYS_MKDIR = 5081 + SYS_RMDIR = 5082 + SYS_CREAT = 5083 + SYS_LINK = 5084 + SYS_UNLINK = 5085 + SYS_SYMLINK = 5086 + SYS_READLINK = 5087 + SYS_CHMOD = 5088 + SYS_FCHMOD = 5089 + SYS_CHOWN = 5090 + SYS_FCHOWN = 5091 + SYS_LCHOWN = 5092 + SYS_UMASK = 5093 + SYS_GETTIMEOFDAY = 5094 + SYS_GETRLIMIT = 5095 + SYS_GETRUSAGE = 5096 + SYS_SYSINFO = 5097 + SYS_TIMES = 5098 + SYS_PTRACE = 5099 + SYS_GETUID = 5100 + SYS_SYSLOG = 5101 + SYS_GETGID = 5102 + SYS_SETUID = 5103 + SYS_SETGID = 5104 + SYS_GETEUID = 5105 + SYS_GETEGID = 5106 + SYS_SETPGID = 5107 + SYS_GETPPID = 5108 + SYS_GETPGRP = 5109 + SYS_SETSID = 5110 + SYS_SETREUID = 5111 + SYS_SETREGID = 5112 + SYS_GETGROUPS = 5113 + SYS_SETGROUPS = 5114 + SYS_SETRESUID = 5115 + SYS_GETRESUID = 5116 + SYS_SETRESGID = 5117 + SYS_GETRESGID = 5118 + SYS_GETPGID = 5119 + SYS_SETFSUID = 5120 + SYS_SETFSGID = 5121 + SYS_GETSID = 5122 + SYS_CAPGET = 5123 + SYS_CAPSET = 5124 + SYS_RT_SIGPENDING = 5125 + SYS_RT_SIGTIMEDWAIT = 5126 + SYS_RT_SIGQUEUEINFO = 5127 + SYS_RT_SIGSUSPEND = 5128 + SYS_SIGALTSTACK = 5129 + SYS_UTIME = 5130 + SYS_MKNOD = 5131 + SYS_PERSONALITY = 5132 + SYS_USTAT = 5133 + SYS_STATFS = 5134 + SYS_FSTATFS = 5135 + SYS_SYSFS = 5136 + SYS_GETPRIORITY = 5137 + SYS_SETPRIORITY = 5138 + SYS_SCHED_SETPARAM = 5139 + SYS_SCHED_GETPARAM = 5140 + SYS_SCHED_SETSCHEDULER = 5141 + SYS_SCHED_GETSCHEDULER = 5142 + SYS_SCHED_GET_PRIORITY_MAX = 5143 + SYS_SCHED_GET_PRIORITY_MIN = 5144 + SYS_SCHED_RR_GET_INTERVAL = 5145 + SYS_MLOCK = 5146 + SYS_MUNLOCK = 5147 + SYS_MLOCKALL = 5148 + SYS_MUNLOCKALL = 5149 + SYS_VHANGUP = 5150 + SYS_PIVOT_ROOT = 5151 + SYS__SYSCTL = 5152 + SYS_PRCTL = 5153 + SYS_ADJTIMEX = 5154 + SYS_SETRLIMIT = 5155 + SYS_CHROOT = 5156 + SYS_SYNC = 5157 + SYS_ACCT = 5158 + SYS_SETTIMEOFDAY = 5159 + SYS_MOUNT = 5160 + SYS_UMOUNT2 = 5161 + SYS_SWAPON = 5162 + SYS_SWAPOFF = 5163 + SYS_REBOOT = 5164 + SYS_SETHOSTNAME = 5165 + SYS_SETDOMAINNAME = 5166 + SYS_CREATE_MODULE = 5167 + SYS_INIT_MODULE = 5168 + SYS_DELETE_MODULE = 5169 + SYS_GET_KERNEL_SYMS = 5170 + SYS_QUERY_MODULE = 5171 + SYS_QUOTACTL = 5172 + SYS_NFSSERVCTL = 5173 + SYS_GETPMSG = 5174 + SYS_PUTPMSG = 5175 + SYS_AFS_SYSCALL = 5176 + SYS_RESERVED177 = 5177 + SYS_GETTID = 5178 + SYS_READAHEAD = 5179 + SYS_SETXATTR = 5180 + SYS_LSETXATTR = 5181 + SYS_FSETXATTR = 5182 + SYS_GETXATTR = 5183 + SYS_LGETXATTR = 5184 + SYS_FGETXATTR = 5185 + SYS_LISTXATTR = 5186 + SYS_LLISTXATTR = 5187 + SYS_FLISTXATTR = 5188 + SYS_REMOVEXATTR = 5189 + SYS_LREMOVEXATTR = 5190 + SYS_FREMOVEXATTR = 5191 + SYS_TKILL = 5192 + SYS_RESERVED193 = 5193 + SYS_FUTEX = 5194 + SYS_SCHED_SETAFFINITY = 5195 + SYS_SCHED_GETAFFINITY = 5196 + SYS_CACHEFLUSH = 5197 + SYS_CACHECTL = 5198 + SYS_SYSMIPS = 5199 + SYS_IO_SETUP = 5200 + SYS_IO_DESTROY = 5201 + SYS_IO_GETEVENTS = 5202 + SYS_IO_SUBMIT = 5203 + SYS_IO_CANCEL = 5204 + SYS_EXIT_GROUP = 5205 + SYS_LOOKUP_DCOOKIE = 5206 + SYS_EPOLL_CREATE = 5207 + SYS_EPOLL_CTL = 5208 + SYS_EPOLL_WAIT = 5209 + SYS_REMAP_FILE_PAGES = 5210 + SYS_RT_SIGRETURN = 5211 + SYS_SET_TID_ADDRESS = 5212 + SYS_RESTART_SYSCALL = 5213 + SYS_SEMTIMEDOP = 5214 + SYS_FADVISE64 = 5215 + SYS_TIMER_CREATE = 5216 + SYS_TIMER_SETTIME = 5217 + SYS_TIMER_GETTIME = 5218 + SYS_TIMER_GETOVERRUN = 5219 + SYS_TIMER_DELETE = 5220 + SYS_CLOCK_SETTIME = 5221 + SYS_CLOCK_GETTIME = 5222 + SYS_CLOCK_GETRES = 5223 + SYS_CLOCK_NANOSLEEP = 5224 + SYS_TGKILL = 5225 + SYS_UTIMES = 5226 + SYS_MBIND = 5227 + SYS_GET_MEMPOLICY = 5228 + SYS_SET_MEMPOLICY = 5229 + SYS_MQ_OPEN = 5230 + SYS_MQ_UNLINK = 5231 + SYS_MQ_TIMEDSEND = 5232 + SYS_MQ_TIMEDRECEIVE = 5233 + SYS_MQ_NOTIFY = 5234 + SYS_MQ_GETSETATTR = 5235 + SYS_VSERVER = 5236 + SYS_WAITID = 5237 + SYS_ADD_KEY = 5239 + SYS_REQUEST_KEY = 5240 + SYS_KEYCTL = 5241 + SYS_SET_THREAD_AREA = 5242 + SYS_INOTIFY_INIT = 5243 + SYS_INOTIFY_ADD_WATCH = 5244 + SYS_INOTIFY_RM_WATCH = 5245 + SYS_MIGRATE_PAGES = 5246 + SYS_OPENAT = 5247 + SYS_MKDIRAT = 5248 + SYS_MKNODAT = 5249 + SYS_FCHOWNAT = 5250 + SYS_FUTIMESAT = 5251 + SYS_NEWFSTATAT = 5252 + SYS_UNLINKAT = 5253 + SYS_RENAMEAT = 5254 + SYS_LINKAT = 5255 + SYS_SYMLINKAT = 5256 + SYS_READLINKAT = 5257 + SYS_FCHMODAT = 5258 + SYS_FACCESSAT = 5259 + SYS_PSELECT6 = 5260 + SYS_PPOLL = 5261 + SYS_UNSHARE = 5262 + SYS_SPLICE = 5263 + SYS_SYNC_FILE_RANGE = 5264 + SYS_TEE = 5265 + SYS_VMSPLICE = 5266 + SYS_MOVE_PAGES = 5267 + SYS_SET_ROBUST_LIST = 5268 + SYS_GET_ROBUST_LIST = 5269 + SYS_KEXEC_LOAD = 5270 + SYS_GETCPU = 5271 + SYS_EPOLL_PWAIT = 5272 + SYS_IOPRIO_SET = 5273 + SYS_IOPRIO_GET = 5274 + SYS_UTIMENSAT = 5275 + SYS_SIGNALFD = 5276 + SYS_TIMERFD = 5277 + SYS_EVENTFD = 5278 + SYS_FALLOCATE = 5279 + SYS_TIMERFD_CREATE = 5280 + SYS_TIMERFD_GETTIME = 5281 + SYS_TIMERFD_SETTIME = 5282 + SYS_SIGNALFD4 = 5283 + SYS_EVENTFD2 = 5284 + SYS_EPOLL_CREATE1 = 5285 + SYS_DUP3 = 5286 + SYS_PIPE2 = 5287 + SYS_INOTIFY_INIT1 = 5288 + SYS_PREADV = 5289 + SYS_PWRITEV = 5290 + SYS_RT_TGSIGQUEUEINFO = 5291 + SYS_PERF_EVENT_OPEN = 5292 + SYS_ACCEPT4 = 5293 + SYS_RECVMMSG = 5294 + SYS_FANOTIFY_INIT = 5295 + SYS_FANOTIFY_MARK = 5296 + SYS_PRLIMIT64 = 5297 + SYS_NAME_TO_HANDLE_AT = 5298 + SYS_OPEN_BY_HANDLE_AT = 5299 + SYS_CLOCK_ADJTIME = 5300 + SYS_SYNCFS = 5301 + SYS_SENDMMSG = 5302 + SYS_SETNS = 5303 + SYS_PROCESS_VM_READV = 5304 + SYS_PROCESS_VM_WRITEV = 5305 + SYS_KCMP = 5306 + SYS_FINIT_MODULE = 5307 + SYS_GETDENTS64 = 5308 + SYS_SCHED_SETATTR = 5309 + SYS_SCHED_GETATTR = 5310 + SYS_RENAMEAT2 = 5311 + SYS_SECCOMP = 5312 + SYS_GETRANDOM = 5313 + SYS_MEMFD_CREATE = 5314 + SYS_BPF = 5315 + SYS_EXECVEAT = 5316 + SYS_USERFAULTFD = 5317 + SYS_MEMBARRIER = 5318 +) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_mips64le.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_mips64le.go new file mode 100644 index 0000000000..d192b940ce --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_mips64le.go @@ -0,0 +1,327 @@ +// mksysnum_linux.pl /usr/include/asm/unistd.h +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build mips64le,linux + +package unix + +const ( + SYS_READ = 5000 + SYS_WRITE = 5001 + SYS_OPEN = 5002 + SYS_CLOSE = 5003 + SYS_STAT = 5004 + SYS_FSTAT = 5005 + SYS_LSTAT = 5006 + SYS_POLL = 5007 + SYS_LSEEK = 5008 + SYS_MMAP = 5009 + SYS_MPROTECT = 5010 + SYS_MUNMAP = 5011 + SYS_BRK = 5012 + SYS_RT_SIGACTION = 5013 + SYS_RT_SIGPROCMASK = 5014 + SYS_IOCTL = 5015 + SYS_PREAD64 = 5016 + SYS_PWRITE64 = 5017 + SYS_READV = 5018 + SYS_WRITEV = 5019 + SYS_ACCESS = 5020 + SYS_PIPE = 5021 + SYS__NEWSELECT = 5022 + SYS_SCHED_YIELD = 5023 + SYS_MREMAP = 5024 + SYS_MSYNC = 5025 + SYS_MINCORE = 5026 + SYS_MADVISE = 5027 + SYS_SHMGET = 5028 + SYS_SHMAT = 5029 + SYS_SHMCTL = 5030 + SYS_DUP = 5031 + SYS_DUP2 = 5032 + SYS_PAUSE = 5033 + SYS_NANOSLEEP = 5034 + SYS_GETITIMER = 5035 + SYS_SETITIMER = 5036 + SYS_ALARM = 5037 + SYS_GETPID = 5038 + SYS_SENDFILE = 5039 + SYS_SOCKET = 5040 + SYS_CONNECT = 5041 + SYS_ACCEPT = 5042 + SYS_SENDTO = 5043 + SYS_RECVFROM = 5044 + SYS_SENDMSG = 5045 + SYS_RECVMSG = 5046 + SYS_SHUTDOWN = 5047 + SYS_BIND = 5048 + SYS_LISTEN = 5049 + SYS_GETSOCKNAME = 5050 + SYS_GETPEERNAME = 5051 + SYS_SOCKETPAIR = 5052 + SYS_SETSOCKOPT = 5053 + SYS_GETSOCKOPT = 5054 + SYS_CLONE = 5055 + SYS_FORK = 5056 + SYS_EXECVE = 5057 + SYS_EXIT = 5058 + SYS_WAIT4 = 5059 + SYS_KILL = 5060 + SYS_UNAME = 5061 + SYS_SEMGET = 5062 + SYS_SEMOP = 5063 + SYS_SEMCTL = 5064 + SYS_SHMDT = 5065 + SYS_MSGGET = 5066 + SYS_MSGSND = 5067 + SYS_MSGRCV = 5068 + SYS_MSGCTL = 5069 + SYS_FCNTL = 5070 + SYS_FLOCK = 5071 + SYS_FSYNC = 5072 + SYS_FDATASYNC = 5073 + SYS_TRUNCATE = 5074 + SYS_FTRUNCATE = 5075 + SYS_GETDENTS = 5076 + SYS_GETCWD = 5077 + SYS_CHDIR = 5078 + SYS_FCHDIR = 5079 + SYS_RENAME = 5080 + SYS_MKDIR = 5081 + SYS_RMDIR = 5082 + SYS_CREAT = 5083 + SYS_LINK = 5084 + SYS_UNLINK = 5085 + SYS_SYMLINK = 5086 + SYS_READLINK = 5087 + SYS_CHMOD = 5088 + SYS_FCHMOD = 5089 + SYS_CHOWN = 5090 + SYS_FCHOWN = 5091 + SYS_LCHOWN = 5092 + SYS_UMASK = 5093 + SYS_GETTIMEOFDAY = 5094 + SYS_GETRLIMIT = 5095 + SYS_GETRUSAGE = 5096 + SYS_SYSINFO = 5097 + SYS_TIMES = 5098 + SYS_PTRACE = 5099 + SYS_GETUID = 5100 + SYS_SYSLOG = 5101 + SYS_GETGID = 5102 + SYS_SETUID = 5103 + SYS_SETGID = 5104 + SYS_GETEUID = 5105 + SYS_GETEGID = 5106 + SYS_SETPGID = 5107 + SYS_GETPPID = 5108 + SYS_GETPGRP = 5109 + SYS_SETSID = 5110 + SYS_SETREUID = 5111 + SYS_SETREGID = 5112 + SYS_GETGROUPS = 5113 + SYS_SETGROUPS = 5114 + SYS_SETRESUID = 5115 + SYS_GETRESUID = 5116 + SYS_SETRESGID = 5117 + SYS_GETRESGID = 5118 + SYS_GETPGID = 5119 + SYS_SETFSUID = 5120 + SYS_SETFSGID = 5121 + SYS_GETSID = 5122 + SYS_CAPGET = 5123 + SYS_CAPSET = 5124 + SYS_RT_SIGPENDING = 5125 + SYS_RT_SIGTIMEDWAIT = 5126 + SYS_RT_SIGQUEUEINFO = 5127 + SYS_RT_SIGSUSPEND = 5128 + SYS_SIGALTSTACK = 5129 + SYS_UTIME = 5130 + SYS_MKNOD = 5131 + SYS_PERSONALITY = 5132 + SYS_USTAT = 5133 + SYS_STATFS = 5134 + SYS_FSTATFS = 5135 + SYS_SYSFS = 5136 + SYS_GETPRIORITY = 5137 + SYS_SETPRIORITY = 5138 + SYS_SCHED_SETPARAM = 5139 + SYS_SCHED_GETPARAM = 5140 + SYS_SCHED_SETSCHEDULER = 5141 + SYS_SCHED_GETSCHEDULER = 5142 + SYS_SCHED_GET_PRIORITY_MAX = 5143 + SYS_SCHED_GET_PRIORITY_MIN = 5144 + SYS_SCHED_RR_GET_INTERVAL = 5145 + SYS_MLOCK = 5146 + SYS_MUNLOCK = 5147 + SYS_MLOCKALL = 5148 + SYS_MUNLOCKALL = 5149 + SYS_VHANGUP = 5150 + SYS_PIVOT_ROOT = 5151 + SYS__SYSCTL = 5152 + SYS_PRCTL = 5153 + SYS_ADJTIMEX = 5154 + SYS_SETRLIMIT = 5155 + SYS_CHROOT = 5156 + SYS_SYNC = 5157 + SYS_ACCT = 5158 + SYS_SETTIMEOFDAY = 5159 + SYS_MOUNT = 5160 + SYS_UMOUNT2 = 5161 + SYS_SWAPON = 5162 + SYS_SWAPOFF = 5163 + SYS_REBOOT = 5164 + SYS_SETHOSTNAME = 5165 + SYS_SETDOMAINNAME = 5166 + SYS_CREATE_MODULE = 5167 + SYS_INIT_MODULE = 5168 + SYS_DELETE_MODULE = 5169 + SYS_GET_KERNEL_SYMS = 5170 + SYS_QUERY_MODULE = 5171 + SYS_QUOTACTL = 5172 + SYS_NFSSERVCTL = 5173 + SYS_GETPMSG = 5174 + SYS_PUTPMSG = 5175 + SYS_AFS_SYSCALL = 5176 + SYS_RESERVED177 = 5177 + SYS_GETTID = 5178 + SYS_READAHEAD = 5179 + SYS_SETXATTR = 5180 + SYS_LSETXATTR = 5181 + SYS_FSETXATTR = 5182 + SYS_GETXATTR = 5183 + SYS_LGETXATTR = 5184 + SYS_FGETXATTR = 5185 + SYS_LISTXATTR = 5186 + SYS_LLISTXATTR = 5187 + SYS_FLISTXATTR = 5188 + SYS_REMOVEXATTR = 5189 + SYS_LREMOVEXATTR = 5190 + SYS_FREMOVEXATTR = 5191 + SYS_TKILL = 5192 + SYS_RESERVED193 = 5193 + SYS_FUTEX = 5194 + SYS_SCHED_SETAFFINITY = 5195 + SYS_SCHED_GETAFFINITY = 5196 + SYS_CACHEFLUSH = 5197 + SYS_CACHECTL = 5198 + SYS_SYSMIPS = 5199 + SYS_IO_SETUP = 5200 + SYS_IO_DESTROY = 5201 + SYS_IO_GETEVENTS = 5202 + SYS_IO_SUBMIT = 5203 + SYS_IO_CANCEL = 5204 + SYS_EXIT_GROUP = 5205 + SYS_LOOKUP_DCOOKIE = 5206 + SYS_EPOLL_CREATE = 5207 + SYS_EPOLL_CTL = 5208 + SYS_EPOLL_WAIT = 5209 + SYS_REMAP_FILE_PAGES = 5210 + SYS_RT_SIGRETURN = 5211 + SYS_SET_TID_ADDRESS = 5212 + SYS_RESTART_SYSCALL = 5213 + SYS_SEMTIMEDOP = 5214 + SYS_FADVISE64 = 5215 + SYS_TIMER_CREATE = 5216 + SYS_TIMER_SETTIME = 5217 + SYS_TIMER_GETTIME = 5218 + SYS_TIMER_GETOVERRUN = 5219 + SYS_TIMER_DELETE = 5220 + SYS_CLOCK_SETTIME = 5221 + SYS_CLOCK_GETTIME = 5222 + SYS_CLOCK_GETRES = 5223 + SYS_CLOCK_NANOSLEEP = 5224 + SYS_TGKILL = 5225 + SYS_UTIMES = 5226 + SYS_MBIND = 5227 + SYS_GET_MEMPOLICY = 5228 + SYS_SET_MEMPOLICY = 5229 + SYS_MQ_OPEN = 5230 + SYS_MQ_UNLINK = 5231 + SYS_MQ_TIMEDSEND = 5232 + SYS_MQ_TIMEDRECEIVE = 5233 + SYS_MQ_NOTIFY = 5234 + SYS_MQ_GETSETATTR = 5235 + SYS_VSERVER = 5236 + SYS_WAITID = 5237 + SYS_ADD_KEY = 5239 + SYS_REQUEST_KEY = 5240 + SYS_KEYCTL = 5241 + SYS_SET_THREAD_AREA = 5242 + SYS_INOTIFY_INIT = 5243 + SYS_INOTIFY_ADD_WATCH = 5244 + SYS_INOTIFY_RM_WATCH = 5245 + SYS_MIGRATE_PAGES = 5246 + SYS_OPENAT = 5247 + SYS_MKDIRAT = 5248 + SYS_MKNODAT = 5249 + SYS_FCHOWNAT = 5250 + SYS_FUTIMESAT = 5251 + SYS_NEWFSTATAT = 5252 + SYS_UNLINKAT = 5253 + SYS_RENAMEAT = 5254 + SYS_LINKAT = 5255 + SYS_SYMLINKAT = 5256 + SYS_READLINKAT = 5257 + SYS_FCHMODAT = 5258 + SYS_FACCESSAT = 5259 + SYS_PSELECT6 = 5260 + SYS_PPOLL = 5261 + SYS_UNSHARE = 5262 + SYS_SPLICE = 5263 + SYS_SYNC_FILE_RANGE = 5264 + SYS_TEE = 5265 + SYS_VMSPLICE = 5266 + SYS_MOVE_PAGES = 5267 + SYS_SET_ROBUST_LIST = 5268 + SYS_GET_ROBUST_LIST = 5269 + SYS_KEXEC_LOAD = 5270 + SYS_GETCPU = 5271 + SYS_EPOLL_PWAIT = 5272 + SYS_IOPRIO_SET = 5273 + SYS_IOPRIO_GET = 5274 + SYS_UTIMENSAT = 5275 + SYS_SIGNALFD = 5276 + SYS_TIMERFD = 5277 + SYS_EVENTFD = 5278 + SYS_FALLOCATE = 5279 + SYS_TIMERFD_CREATE = 5280 + SYS_TIMERFD_GETTIME = 5281 + SYS_TIMERFD_SETTIME = 5282 + SYS_SIGNALFD4 = 5283 + SYS_EVENTFD2 = 5284 + SYS_EPOLL_CREATE1 = 5285 + SYS_DUP3 = 5286 + SYS_PIPE2 = 5287 + SYS_INOTIFY_INIT1 = 5288 + SYS_PREADV = 5289 + SYS_PWRITEV = 5290 + SYS_RT_TGSIGQUEUEINFO = 5291 + SYS_PERF_EVENT_OPEN = 5292 + SYS_ACCEPT4 = 5293 + SYS_RECVMMSG = 5294 + SYS_FANOTIFY_INIT = 5295 + SYS_FANOTIFY_MARK = 5296 + SYS_PRLIMIT64 = 5297 + SYS_NAME_TO_HANDLE_AT = 5298 + SYS_OPEN_BY_HANDLE_AT = 5299 + SYS_CLOCK_ADJTIME = 5300 + SYS_SYNCFS = 5301 + SYS_SENDMMSG = 5302 + SYS_SETNS = 5303 + SYS_PROCESS_VM_READV = 5304 + SYS_PROCESS_VM_WRITEV = 5305 + SYS_KCMP = 5306 + SYS_FINIT_MODULE = 5307 + SYS_GETDENTS64 = 5308 + SYS_SCHED_SETATTR = 5309 + SYS_SCHED_GETATTR = 5310 + SYS_RENAMEAT2 = 5311 + SYS_SECCOMP = 5312 + SYS_GETRANDOM = 5313 + SYS_MEMFD_CREATE = 5314 + SYS_BPF = 5315 + SYS_EXECVEAT = 5316 + SYS_USERFAULTFD = 5317 + SYS_MEMBARRIER = 5318 +) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_ppc64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_ppc64.go new file mode 100644 index 0000000000..e1b08f00d3 --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_ppc64.go @@ -0,0 +1,360 @@ +// mksysnum_linux.pl /usr/include/asm/unistd.h +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build ppc64,linux + +package unix + +const ( + SYS_RESTART_SYSCALL = 0 + SYS_EXIT = 1 + SYS_FORK = 2 + SYS_READ = 3 + SYS_WRITE = 4 + SYS_OPEN = 5 + SYS_CLOSE = 6 + SYS_WAITPID = 7 + SYS_CREAT = 8 + SYS_LINK = 9 + SYS_UNLINK = 10 + SYS_EXECVE = 11 + SYS_CHDIR = 12 + SYS_TIME = 13 + SYS_MKNOD = 14 + SYS_CHMOD = 15 + SYS_LCHOWN = 16 + SYS_BREAK = 17 + SYS_OLDSTAT = 18 + SYS_LSEEK = 19 + SYS_GETPID = 20 + SYS_MOUNT = 21 + SYS_UMOUNT = 22 + SYS_SETUID = 23 + SYS_GETUID = 24 + SYS_STIME = 25 + SYS_PTRACE = 26 + SYS_ALARM = 27 + SYS_OLDFSTAT = 28 + SYS_PAUSE = 29 + SYS_UTIME = 30 + SYS_STTY = 31 + SYS_GTTY = 32 + SYS_ACCESS = 33 + SYS_NICE = 34 + SYS_FTIME = 35 + SYS_SYNC = 36 + SYS_KILL = 37 + SYS_RENAME = 38 + SYS_MKDIR = 39 + SYS_RMDIR = 40 + SYS_DUP = 41 + SYS_PIPE = 42 + SYS_TIMES = 43 + SYS_PROF = 44 + SYS_BRK = 45 + SYS_SETGID = 46 + SYS_GETGID = 47 + SYS_SIGNAL = 48 + SYS_GETEUID = 49 + SYS_GETEGID = 50 + SYS_ACCT = 51 + SYS_UMOUNT2 = 52 + SYS_LOCK = 53 + SYS_IOCTL = 54 + SYS_FCNTL = 55 + SYS_MPX = 56 + SYS_SETPGID = 57 + SYS_ULIMIT = 58 + SYS_OLDOLDUNAME = 59 + SYS_UMASK = 60 + SYS_CHROOT = 61 + SYS_USTAT = 62 + SYS_DUP2 = 63 + SYS_GETPPID = 64 + SYS_GETPGRP = 65 + SYS_SETSID = 66 + SYS_SIGACTION = 67 + SYS_SGETMASK = 68 + SYS_SSETMASK = 69 + SYS_SETREUID = 70 + SYS_SETREGID = 71 + SYS_SIGSUSPEND = 72 + SYS_SIGPENDING = 73 + SYS_SETHOSTNAME = 74 + SYS_SETRLIMIT = 75 + SYS_GETRLIMIT = 76 + SYS_GETRUSAGE = 77 + SYS_GETTIMEOFDAY = 78 + SYS_SETTIMEOFDAY = 79 + SYS_GETGROUPS = 80 + SYS_SETGROUPS = 81 + SYS_SELECT = 82 + SYS_SYMLINK = 83 + SYS_OLDLSTAT = 84 + SYS_READLINK = 85 + SYS_USELIB = 86 + SYS_SWAPON = 87 + SYS_REBOOT = 88 + SYS_READDIR = 89 + SYS_MMAP = 90 + SYS_MUNMAP = 91 + SYS_TRUNCATE = 92 + SYS_FTRUNCATE = 93 + SYS_FCHMOD = 94 + SYS_FCHOWN = 95 + SYS_GETPRIORITY = 96 + SYS_SETPRIORITY = 97 + SYS_PROFIL = 98 + SYS_STATFS = 99 + SYS_FSTATFS = 100 + SYS_IOPERM = 101 + SYS_SOCKETCALL = 102 + SYS_SYSLOG = 103 + SYS_SETITIMER = 104 + SYS_GETITIMER = 105 + SYS_STAT = 106 + SYS_LSTAT = 107 + SYS_FSTAT = 108 + SYS_OLDUNAME = 109 + SYS_IOPL = 110 + SYS_VHANGUP = 111 + SYS_IDLE = 112 + SYS_VM86 = 113 + SYS_WAIT4 = 114 + SYS_SWAPOFF = 115 + SYS_SYSINFO = 116 + SYS_IPC = 117 + SYS_FSYNC = 118 + SYS_SIGRETURN = 119 + SYS_CLONE = 120 + SYS_SETDOMAINNAME = 121 + SYS_UNAME = 122 + SYS_MODIFY_LDT = 123 + SYS_ADJTIMEX = 124 + SYS_MPROTECT = 125 + SYS_SIGPROCMASK = 126 + SYS_CREATE_MODULE = 127 + SYS_INIT_MODULE = 128 + SYS_DELETE_MODULE = 129 + SYS_GET_KERNEL_SYMS = 130 + SYS_QUOTACTL = 131 + SYS_GETPGID = 132 + SYS_FCHDIR = 133 + SYS_BDFLUSH = 134 + SYS_SYSFS = 135 + SYS_PERSONALITY = 136 + SYS_AFS_SYSCALL = 137 + SYS_SETFSUID = 138 + SYS_SETFSGID = 139 + SYS__LLSEEK = 140 + SYS_GETDENTS = 141 + SYS__NEWSELECT = 142 + SYS_FLOCK = 143 + SYS_MSYNC = 144 + SYS_READV = 145 + SYS_WRITEV = 146 + SYS_GETSID = 147 + SYS_FDATASYNC = 148 + SYS__SYSCTL = 149 + SYS_MLOCK = 150 + SYS_MUNLOCK = 151 + SYS_MLOCKALL = 152 + SYS_MUNLOCKALL = 153 + SYS_SCHED_SETPARAM = 154 + SYS_SCHED_GETPARAM = 155 + SYS_SCHED_SETSCHEDULER = 156 + SYS_SCHED_GETSCHEDULER = 157 + SYS_SCHED_YIELD = 158 + SYS_SCHED_GET_PRIORITY_MAX = 159 + SYS_SCHED_GET_PRIORITY_MIN = 160 + SYS_SCHED_RR_GET_INTERVAL = 161 + SYS_NANOSLEEP = 162 + SYS_MREMAP = 163 + SYS_SETRESUID = 164 + SYS_GETRESUID = 165 + SYS_QUERY_MODULE = 166 + SYS_POLL = 167 + SYS_NFSSERVCTL = 168 + SYS_SETRESGID = 169 + SYS_GETRESGID = 170 + SYS_PRCTL = 171 + SYS_RT_SIGRETURN = 172 + SYS_RT_SIGACTION = 173 + SYS_RT_SIGPROCMASK = 174 + SYS_RT_SIGPENDING = 175 + SYS_RT_SIGTIMEDWAIT = 176 + SYS_RT_SIGQUEUEINFO = 177 + SYS_RT_SIGSUSPEND = 178 + SYS_PREAD64 = 179 + SYS_PWRITE64 = 180 + SYS_CHOWN = 181 + SYS_GETCWD = 182 + SYS_CAPGET = 183 + SYS_CAPSET = 184 + SYS_SIGALTSTACK = 185 + SYS_SENDFILE = 186 + SYS_GETPMSG = 187 + SYS_PUTPMSG = 188 + SYS_VFORK = 189 + SYS_UGETRLIMIT = 190 + SYS_READAHEAD = 191 + SYS_PCICONFIG_READ = 198 + SYS_PCICONFIG_WRITE = 199 + SYS_PCICONFIG_IOBASE = 200 + SYS_MULTIPLEXER = 201 + SYS_GETDENTS64 = 202 + SYS_PIVOT_ROOT = 203 + SYS_MADVISE = 205 + SYS_MINCORE = 206 + SYS_GETTID = 207 + SYS_TKILL = 208 + SYS_SETXATTR = 209 + SYS_LSETXATTR = 210 + SYS_FSETXATTR = 211 + SYS_GETXATTR = 212 + SYS_LGETXATTR = 213 + SYS_FGETXATTR = 214 + SYS_LISTXATTR = 215 + SYS_LLISTXATTR = 216 + SYS_FLISTXATTR = 217 + SYS_REMOVEXATTR = 218 + SYS_LREMOVEXATTR = 219 + SYS_FREMOVEXATTR = 220 + SYS_FUTEX = 221 + SYS_SCHED_SETAFFINITY = 222 + SYS_SCHED_GETAFFINITY = 223 + SYS_TUXCALL = 225 + SYS_IO_SETUP = 227 + SYS_IO_DESTROY = 228 + SYS_IO_GETEVENTS = 229 + SYS_IO_SUBMIT = 230 + SYS_IO_CANCEL = 231 + SYS_SET_TID_ADDRESS = 232 + SYS_FADVISE64 = 233 + SYS_EXIT_GROUP = 234 + SYS_LOOKUP_DCOOKIE = 235 + SYS_EPOLL_CREATE = 236 + SYS_EPOLL_CTL = 237 + SYS_EPOLL_WAIT = 238 + SYS_REMAP_FILE_PAGES = 239 + SYS_TIMER_CREATE = 240 + SYS_TIMER_SETTIME = 241 + SYS_TIMER_GETTIME = 242 + SYS_TIMER_GETOVERRUN = 243 + SYS_TIMER_DELETE = 244 + SYS_CLOCK_SETTIME = 245 + SYS_CLOCK_GETTIME = 246 + SYS_CLOCK_GETRES = 247 + SYS_CLOCK_NANOSLEEP = 248 + SYS_SWAPCONTEXT = 249 + SYS_TGKILL = 250 + SYS_UTIMES = 251 + SYS_STATFS64 = 252 + SYS_FSTATFS64 = 253 + SYS_RTAS = 255 + SYS_SYS_DEBUG_SETCONTEXT = 256 + SYS_MIGRATE_PAGES = 258 + SYS_MBIND = 259 + SYS_GET_MEMPOLICY = 260 + SYS_SET_MEMPOLICY = 261 + SYS_MQ_OPEN = 262 + SYS_MQ_UNLINK = 263 + SYS_MQ_TIMEDSEND = 264 + SYS_MQ_TIMEDRECEIVE = 265 + SYS_MQ_NOTIFY = 266 + SYS_MQ_GETSETATTR = 267 + SYS_KEXEC_LOAD = 268 + SYS_ADD_KEY = 269 + SYS_REQUEST_KEY = 270 + SYS_KEYCTL = 271 + SYS_WAITID = 272 + SYS_IOPRIO_SET = 273 + SYS_IOPRIO_GET = 274 + SYS_INOTIFY_INIT = 275 + SYS_INOTIFY_ADD_WATCH = 276 + SYS_INOTIFY_RM_WATCH = 277 + SYS_SPU_RUN = 278 + SYS_SPU_CREATE = 279 + SYS_PSELECT6 = 280 + SYS_PPOLL = 281 + SYS_UNSHARE = 282 + SYS_SPLICE = 283 + SYS_TEE = 284 + SYS_VMSPLICE = 285 + SYS_OPENAT = 286 + SYS_MKDIRAT = 287 + SYS_MKNODAT = 288 + SYS_FCHOWNAT = 289 + SYS_FUTIMESAT = 290 + SYS_NEWFSTATAT = 291 + SYS_UNLINKAT = 292 + SYS_RENAMEAT = 293 + SYS_LINKAT = 294 + SYS_SYMLINKAT = 295 + SYS_READLINKAT = 296 + SYS_FCHMODAT = 297 + SYS_FACCESSAT = 298 + SYS_GET_ROBUST_LIST = 299 + SYS_SET_ROBUST_LIST = 300 + SYS_MOVE_PAGES = 301 + SYS_GETCPU = 302 + SYS_EPOLL_PWAIT = 303 + SYS_UTIMENSAT = 304 + SYS_SIGNALFD = 305 + SYS_TIMERFD_CREATE = 306 + SYS_EVENTFD = 307 + SYS_SYNC_FILE_RANGE2 = 308 + SYS_FALLOCATE = 309 + SYS_SUBPAGE_PROT = 310 + SYS_TIMERFD_SETTIME = 311 + SYS_TIMERFD_GETTIME = 312 + SYS_SIGNALFD4 = 313 + SYS_EVENTFD2 = 314 + SYS_EPOLL_CREATE1 = 315 + SYS_DUP3 = 316 + SYS_PIPE2 = 317 + SYS_INOTIFY_INIT1 = 318 + SYS_PERF_EVENT_OPEN = 319 + SYS_PREADV = 320 + SYS_PWRITEV = 321 + SYS_RT_TGSIGQUEUEINFO = 322 + SYS_FANOTIFY_INIT = 323 + SYS_FANOTIFY_MARK = 324 + SYS_PRLIMIT64 = 325 + SYS_SOCKET = 326 + SYS_BIND = 327 + SYS_CONNECT = 328 + SYS_LISTEN = 329 + SYS_ACCEPT = 330 + SYS_GETSOCKNAME = 331 + SYS_GETPEERNAME = 332 + SYS_SOCKETPAIR = 333 + SYS_SEND = 334 + SYS_SENDTO = 335 + SYS_RECV = 336 + SYS_RECVFROM = 337 + SYS_SHUTDOWN = 338 + SYS_SETSOCKOPT = 339 + SYS_GETSOCKOPT = 340 + SYS_SENDMSG = 341 + SYS_RECVMSG = 342 + SYS_RECVMMSG = 343 + SYS_ACCEPT4 = 344 + SYS_NAME_TO_HANDLE_AT = 345 + SYS_OPEN_BY_HANDLE_AT = 346 + SYS_CLOCK_ADJTIME = 347 + SYS_SYNCFS = 348 + SYS_SENDMMSG = 349 + SYS_SETNS = 350 + SYS_PROCESS_VM_READV = 351 + SYS_PROCESS_VM_WRITEV = 352 + SYS_FINIT_MODULE = 353 + SYS_KCMP = 354 + SYS_SCHED_SETATTR = 355 + SYS_SCHED_GETATTR = 356 + SYS_RENAMEAT2 = 357 + SYS_SECCOMP = 358 + SYS_GETRANDOM = 359 + SYS_MEMFD_CREATE = 360 + SYS_BPF = 361 +) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go new file mode 100644 index 0000000000..45e63f51a4 --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go @@ -0,0 +1,353 @@ +// mksysnum_linux.pl /usr/include/powerpc64le-linux-gnu/asm/unistd.h +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build ppc64le,linux + +package unix + +const ( + SYS_RESTART_SYSCALL = 0 + SYS_EXIT = 1 + SYS_FORK = 2 + SYS_READ = 3 + SYS_WRITE = 4 + SYS_OPEN = 5 + SYS_CLOSE = 6 + SYS_WAITPID = 7 + SYS_CREAT = 8 + SYS_LINK = 9 + SYS_UNLINK = 10 + SYS_EXECVE = 11 + SYS_CHDIR = 12 + SYS_TIME = 13 + SYS_MKNOD = 14 + SYS_CHMOD = 15 + SYS_LCHOWN = 16 + SYS_BREAK = 17 + SYS_OLDSTAT = 18 + SYS_LSEEK = 19 + SYS_GETPID = 20 + SYS_MOUNT = 21 + SYS_UMOUNT = 22 + SYS_SETUID = 23 + SYS_GETUID = 24 + SYS_STIME = 25 + SYS_PTRACE = 26 + SYS_ALARM = 27 + SYS_OLDFSTAT = 28 + SYS_PAUSE = 29 + SYS_UTIME = 30 + SYS_STTY = 31 + SYS_GTTY = 32 + SYS_ACCESS = 33 + SYS_NICE = 34 + SYS_FTIME = 35 + SYS_SYNC = 36 + SYS_KILL = 37 + SYS_RENAME = 38 + SYS_MKDIR = 39 + SYS_RMDIR = 40 + SYS_DUP = 41 + SYS_PIPE = 42 + SYS_TIMES = 43 + SYS_PROF = 44 + SYS_BRK = 45 + SYS_SETGID = 46 + SYS_GETGID = 47 + SYS_SIGNAL = 48 + SYS_GETEUID = 49 + SYS_GETEGID = 50 + SYS_ACCT = 51 + SYS_UMOUNT2 = 52 + SYS_LOCK = 53 + SYS_IOCTL = 54 + SYS_FCNTL = 55 + SYS_MPX = 56 + SYS_SETPGID = 57 + SYS_ULIMIT = 58 + SYS_OLDOLDUNAME = 59 + SYS_UMASK = 60 + SYS_CHROOT = 61 + SYS_USTAT = 62 + SYS_DUP2 = 63 + SYS_GETPPID = 64 + SYS_GETPGRP = 65 + SYS_SETSID = 66 + SYS_SIGACTION = 67 + SYS_SGETMASK = 68 + SYS_SSETMASK = 69 + SYS_SETREUID = 70 + SYS_SETREGID = 71 + SYS_SIGSUSPEND = 72 + SYS_SIGPENDING = 73 + SYS_SETHOSTNAME = 74 + SYS_SETRLIMIT = 75 + SYS_GETRLIMIT = 76 + SYS_GETRUSAGE = 77 + SYS_GETTIMEOFDAY = 78 + SYS_SETTIMEOFDAY = 79 + SYS_GETGROUPS = 80 + SYS_SETGROUPS = 81 + SYS_SELECT = 82 + SYS_SYMLINK = 83 + SYS_OLDLSTAT = 84 + SYS_READLINK = 85 + SYS_USELIB = 86 + SYS_SWAPON = 87 + SYS_REBOOT = 88 + SYS_READDIR = 89 + SYS_MMAP = 90 + SYS_MUNMAP = 91 + SYS_TRUNCATE = 92 + SYS_FTRUNCATE = 93 + SYS_FCHMOD = 94 + SYS_FCHOWN = 95 + SYS_GETPRIORITY = 96 + SYS_SETPRIORITY = 97 + SYS_PROFIL = 98 + SYS_STATFS = 99 + SYS_FSTATFS = 100 + SYS_IOPERM = 101 + SYS_SOCKETCALL = 102 + SYS_SYSLOG = 103 + SYS_SETITIMER = 104 + SYS_GETITIMER = 105 + SYS_STAT = 106 + SYS_LSTAT = 107 + SYS_FSTAT = 108 + SYS_OLDUNAME = 109 + SYS_IOPL = 110 + SYS_VHANGUP = 111 + SYS_IDLE = 112 + SYS_VM86 = 113 + SYS_WAIT4 = 114 + SYS_SWAPOFF = 115 + SYS_SYSINFO = 116 + SYS_IPC = 117 + SYS_FSYNC = 118 + SYS_SIGRETURN = 119 + SYS_CLONE = 120 + SYS_SETDOMAINNAME = 121 + SYS_UNAME = 122 + SYS_MODIFY_LDT = 123 + SYS_ADJTIMEX = 124 + SYS_MPROTECT = 125 + SYS_SIGPROCMASK = 126 + SYS_CREATE_MODULE = 127 + SYS_INIT_MODULE = 128 + SYS_DELETE_MODULE = 129 + SYS_GET_KERNEL_SYMS = 130 + SYS_QUOTACTL = 131 + SYS_GETPGID = 132 + SYS_FCHDIR = 133 + SYS_BDFLUSH = 134 + SYS_SYSFS = 135 + SYS_PERSONALITY = 136 + SYS_AFS_SYSCALL = 137 + SYS_SETFSUID = 138 + SYS_SETFSGID = 139 + SYS__LLSEEK = 140 + SYS_GETDENTS = 141 + SYS__NEWSELECT = 142 + SYS_FLOCK = 143 + SYS_MSYNC = 144 + SYS_READV = 145 + SYS_WRITEV = 146 + SYS_GETSID = 147 + SYS_FDATASYNC = 148 + SYS__SYSCTL = 149 + SYS_MLOCK = 150 + SYS_MUNLOCK = 151 + SYS_MLOCKALL = 152 + SYS_MUNLOCKALL = 153 + SYS_SCHED_SETPARAM = 154 + SYS_SCHED_GETPARAM = 155 + SYS_SCHED_SETSCHEDULER = 156 + SYS_SCHED_GETSCHEDULER = 157 + SYS_SCHED_YIELD = 158 + SYS_SCHED_GET_PRIORITY_MAX = 159 + SYS_SCHED_GET_PRIORITY_MIN = 160 + SYS_SCHED_RR_GET_INTERVAL = 161 + SYS_NANOSLEEP = 162 + SYS_MREMAP = 163 + SYS_SETRESUID = 164 + SYS_GETRESUID = 165 + SYS_QUERY_MODULE = 166 + SYS_POLL = 167 + SYS_NFSSERVCTL = 168 + SYS_SETRESGID = 169 + SYS_GETRESGID = 170 + SYS_PRCTL = 171 + SYS_RT_SIGRETURN = 172 + SYS_RT_SIGACTION = 173 + SYS_RT_SIGPROCMASK = 174 + SYS_RT_SIGPENDING = 175 + SYS_RT_SIGTIMEDWAIT = 176 + SYS_RT_SIGQUEUEINFO = 177 + SYS_RT_SIGSUSPEND = 178 + SYS_PREAD64 = 179 + SYS_PWRITE64 = 180 + SYS_CHOWN = 181 + SYS_GETCWD = 182 + SYS_CAPGET = 183 + SYS_CAPSET = 184 + SYS_SIGALTSTACK = 185 + SYS_SENDFILE = 186 + SYS_GETPMSG = 187 + SYS_PUTPMSG = 188 + SYS_VFORK = 189 + SYS_UGETRLIMIT = 190 + SYS_READAHEAD = 191 + SYS_PCICONFIG_READ = 198 + SYS_PCICONFIG_WRITE = 199 + SYS_PCICONFIG_IOBASE = 200 + SYS_MULTIPLEXER = 201 + SYS_GETDENTS64 = 202 + SYS_PIVOT_ROOT = 203 + SYS_MADVISE = 205 + SYS_MINCORE = 206 + SYS_GETTID = 207 + SYS_TKILL = 208 + SYS_SETXATTR = 209 + SYS_LSETXATTR = 210 + SYS_FSETXATTR = 211 + SYS_GETXATTR = 212 + SYS_LGETXATTR = 213 + SYS_FGETXATTR = 214 + SYS_LISTXATTR = 215 + SYS_LLISTXATTR = 216 + SYS_FLISTXATTR = 217 + SYS_REMOVEXATTR = 218 + SYS_LREMOVEXATTR = 219 + SYS_FREMOVEXATTR = 220 + SYS_FUTEX = 221 + SYS_SCHED_SETAFFINITY = 222 + SYS_SCHED_GETAFFINITY = 223 + SYS_TUXCALL = 225 + SYS_IO_SETUP = 227 + SYS_IO_DESTROY = 228 + SYS_IO_GETEVENTS = 229 + SYS_IO_SUBMIT = 230 + SYS_IO_CANCEL = 231 + SYS_SET_TID_ADDRESS = 232 + SYS_FADVISE64 = 233 + SYS_EXIT_GROUP = 234 + SYS_LOOKUP_DCOOKIE = 235 + SYS_EPOLL_CREATE = 236 + SYS_EPOLL_CTL = 237 + SYS_EPOLL_WAIT = 238 + SYS_REMAP_FILE_PAGES = 239 + SYS_TIMER_CREATE = 240 + SYS_TIMER_SETTIME = 241 + SYS_TIMER_GETTIME = 242 + SYS_TIMER_GETOVERRUN = 243 + SYS_TIMER_DELETE = 244 + SYS_CLOCK_SETTIME = 245 + SYS_CLOCK_GETTIME = 246 + SYS_CLOCK_GETRES = 247 + SYS_CLOCK_NANOSLEEP = 248 + SYS_SWAPCONTEXT = 249 + SYS_TGKILL = 250 + SYS_UTIMES = 251 + SYS_STATFS64 = 252 + SYS_FSTATFS64 = 253 + SYS_RTAS = 255 + SYS_SYS_DEBUG_SETCONTEXT = 256 + SYS_MIGRATE_PAGES = 258 + SYS_MBIND = 259 + SYS_GET_MEMPOLICY = 260 + SYS_SET_MEMPOLICY = 261 + SYS_MQ_OPEN = 262 + SYS_MQ_UNLINK = 263 + SYS_MQ_TIMEDSEND = 264 + SYS_MQ_TIMEDRECEIVE = 265 + SYS_MQ_NOTIFY = 266 + SYS_MQ_GETSETATTR = 267 + SYS_KEXEC_LOAD = 268 + SYS_ADD_KEY = 269 + SYS_REQUEST_KEY = 270 + SYS_KEYCTL = 271 + SYS_WAITID = 272 + SYS_IOPRIO_SET = 273 + SYS_IOPRIO_GET = 274 + SYS_INOTIFY_INIT = 275 + SYS_INOTIFY_ADD_WATCH = 276 + SYS_INOTIFY_RM_WATCH = 277 + SYS_SPU_RUN = 278 + SYS_SPU_CREATE = 279 + SYS_PSELECT6 = 280 + SYS_PPOLL = 281 + SYS_UNSHARE = 282 + SYS_SPLICE = 283 + SYS_TEE = 284 + SYS_VMSPLICE = 285 + SYS_OPENAT = 286 + SYS_MKDIRAT = 287 + SYS_MKNODAT = 288 + SYS_FCHOWNAT = 289 + SYS_FUTIMESAT = 290 + SYS_NEWFSTATAT = 291 + SYS_UNLINKAT = 292 + SYS_RENAMEAT = 293 + SYS_LINKAT = 294 + SYS_SYMLINKAT = 295 + SYS_READLINKAT = 296 + SYS_FCHMODAT = 297 + SYS_FACCESSAT = 298 + SYS_GET_ROBUST_LIST = 299 + SYS_SET_ROBUST_LIST = 300 + SYS_MOVE_PAGES = 301 + SYS_GETCPU = 302 + SYS_EPOLL_PWAIT = 303 + SYS_UTIMENSAT = 304 + SYS_SIGNALFD = 305 + SYS_TIMERFD_CREATE = 306 + SYS_EVENTFD = 307 + SYS_SYNC_FILE_RANGE2 = 308 + SYS_FALLOCATE = 309 + SYS_SUBPAGE_PROT = 310 + SYS_TIMERFD_SETTIME = 311 + SYS_TIMERFD_GETTIME = 312 + SYS_SIGNALFD4 = 313 + SYS_EVENTFD2 = 314 + SYS_EPOLL_CREATE1 = 315 + SYS_DUP3 = 316 + SYS_PIPE2 = 317 + SYS_INOTIFY_INIT1 = 318 + SYS_PERF_EVENT_OPEN = 319 + SYS_PREADV = 320 + SYS_PWRITEV = 321 + SYS_RT_TGSIGQUEUEINFO = 322 + SYS_FANOTIFY_INIT = 323 + SYS_FANOTIFY_MARK = 324 + SYS_PRLIMIT64 = 325 + SYS_SOCKET = 326 + SYS_BIND = 327 + SYS_CONNECT = 328 + SYS_LISTEN = 329 + SYS_ACCEPT = 330 + SYS_GETSOCKNAME = 331 + SYS_GETPEERNAME = 332 + SYS_SOCKETPAIR = 333 + SYS_SEND = 334 + SYS_SENDTO = 335 + SYS_RECV = 336 + SYS_RECVFROM = 337 + SYS_SHUTDOWN = 338 + SYS_SETSOCKOPT = 339 + SYS_GETSOCKOPT = 340 + SYS_SENDMSG = 341 + SYS_RECVMSG = 342 + SYS_RECVMMSG = 343 + SYS_ACCEPT4 = 344 + SYS_NAME_TO_HANDLE_AT = 345 + SYS_OPEN_BY_HANDLE_AT = 346 + SYS_CLOCK_ADJTIME = 347 + SYS_SYNCFS = 348 + SYS_SENDMMSG = 349 + SYS_SETNS = 350 + SYS_PROCESS_VM_READV = 351 + SYS_PROCESS_VM_WRITEV = 352 + SYS_FINIT_MODULE = 353 + SYS_KCMP = 354 +) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_s390x.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_s390x.go new file mode 100644 index 0000000000..42d4f5cda8 --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_s390x.go @@ -0,0 +1,328 @@ +// mksysnum_linux.pl /usr/include/asm/unistd.h +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build s390x,linux + +package unix + +const ( + SYS_EXIT = 1 + SYS_FORK = 2 + SYS_READ = 3 + SYS_WRITE = 4 + SYS_OPEN = 5 + SYS_CLOSE = 6 + SYS_RESTART_SYSCALL = 7 + SYS_CREAT = 8 + SYS_LINK = 9 + SYS_UNLINK = 10 + SYS_EXECVE = 11 + SYS_CHDIR = 12 + SYS_MKNOD = 14 + SYS_CHMOD = 15 + SYS_LSEEK = 19 + SYS_GETPID = 20 + SYS_MOUNT = 21 + SYS_UMOUNT = 22 + SYS_PTRACE = 26 + SYS_ALARM = 27 + SYS_PAUSE = 29 + SYS_UTIME = 30 + SYS_ACCESS = 33 + SYS_NICE = 34 + SYS_SYNC = 36 + SYS_KILL = 37 + SYS_RENAME = 38 + SYS_MKDIR = 39 + SYS_RMDIR = 40 + SYS_DUP = 41 + SYS_PIPE = 42 + SYS_TIMES = 43 + SYS_BRK = 45 + SYS_SIGNAL = 48 + SYS_ACCT = 51 + SYS_UMOUNT2 = 52 + SYS_IOCTL = 54 + SYS_FCNTL = 55 + SYS_SETPGID = 57 + SYS_UMASK = 60 + SYS_CHROOT = 61 + SYS_USTAT = 62 + SYS_DUP2 = 63 + SYS_GETPPID = 64 + SYS_GETPGRP = 65 + SYS_SETSID = 66 + SYS_SIGACTION = 67 + SYS_SIGSUSPEND = 72 + SYS_SIGPENDING = 73 + SYS_SETHOSTNAME = 74 + SYS_SETRLIMIT = 75 + SYS_GETRUSAGE = 77 + SYS_GETTIMEOFDAY = 78 + SYS_SETTIMEOFDAY = 79 + SYS_SYMLINK = 83 + SYS_READLINK = 85 + SYS_USELIB = 86 + SYS_SWAPON = 87 + SYS_REBOOT = 88 + SYS_READDIR = 89 + SYS_MMAP = 90 + SYS_MUNMAP = 91 + SYS_TRUNCATE = 92 + SYS_FTRUNCATE = 93 + SYS_FCHMOD = 94 + SYS_GETPRIORITY = 96 + SYS_SETPRIORITY = 97 + SYS_STATFS = 99 + SYS_FSTATFS = 100 + SYS_SOCKETCALL = 102 + SYS_SYSLOG = 103 + SYS_SETITIMER = 104 + SYS_GETITIMER = 105 + SYS_STAT = 106 + SYS_LSTAT = 107 + SYS_FSTAT = 108 + SYS_LOOKUP_DCOOKIE = 110 + SYS_VHANGUP = 111 + SYS_IDLE = 112 + SYS_WAIT4 = 114 + SYS_SWAPOFF = 115 + SYS_SYSINFO = 116 + SYS_IPC = 117 + SYS_FSYNC = 118 + SYS_SIGRETURN = 119 + SYS_CLONE = 120 + SYS_SETDOMAINNAME = 121 + SYS_UNAME = 122 + SYS_ADJTIMEX = 124 + SYS_MPROTECT = 125 + SYS_SIGPROCMASK = 126 + SYS_CREATE_MODULE = 127 + SYS_INIT_MODULE = 128 + SYS_DELETE_MODULE = 129 + SYS_GET_KERNEL_SYMS = 130 + SYS_QUOTACTL = 131 + SYS_GETPGID = 132 + SYS_FCHDIR = 133 + SYS_BDFLUSH = 134 + SYS_SYSFS = 135 + SYS_PERSONALITY = 136 + SYS_AFS_SYSCALL = 137 + SYS_GETDENTS = 141 + SYS_FLOCK = 143 + SYS_MSYNC = 144 + SYS_READV = 145 + SYS_WRITEV = 146 + SYS_GETSID = 147 + SYS_FDATASYNC = 148 + SYS__SYSCTL = 149 + SYS_MLOCK = 150 + SYS_MUNLOCK = 151 + SYS_MLOCKALL = 152 + SYS_MUNLOCKALL = 153 + SYS_SCHED_SETPARAM = 154 + SYS_SCHED_GETPARAM = 155 + SYS_SCHED_SETSCHEDULER = 156 + SYS_SCHED_GETSCHEDULER = 157 + SYS_SCHED_YIELD = 158 + SYS_SCHED_GET_PRIORITY_MAX = 159 + SYS_SCHED_GET_PRIORITY_MIN = 160 + SYS_SCHED_RR_GET_INTERVAL = 161 + SYS_NANOSLEEP = 162 + SYS_MREMAP = 163 + SYS_QUERY_MODULE = 167 + SYS_POLL = 168 + SYS_NFSSERVCTL = 169 + SYS_PRCTL = 172 + SYS_RT_SIGRETURN = 173 + SYS_RT_SIGACTION = 174 + SYS_RT_SIGPROCMASK = 175 + SYS_RT_SIGPENDING = 176 + SYS_RT_SIGTIMEDWAIT = 177 + SYS_RT_SIGQUEUEINFO = 178 + SYS_RT_SIGSUSPEND = 179 + SYS_PREAD64 = 180 + SYS_PWRITE64 = 181 + SYS_GETCWD = 183 + SYS_CAPGET = 184 + SYS_CAPSET = 185 + SYS_SIGALTSTACK = 186 + SYS_SENDFILE = 187 + SYS_GETPMSG = 188 + SYS_PUTPMSG = 189 + SYS_VFORK = 190 + SYS_PIVOT_ROOT = 217 + SYS_MINCORE = 218 + SYS_MADVISE = 219 + SYS_GETDENTS64 = 220 + SYS_READAHEAD = 222 + SYS_SETXATTR = 224 + SYS_LSETXATTR = 225 + SYS_FSETXATTR = 226 + SYS_GETXATTR = 227 + SYS_LGETXATTR = 228 + SYS_FGETXATTR = 229 + SYS_LISTXATTR = 230 + SYS_LLISTXATTR = 231 + SYS_FLISTXATTR = 232 + SYS_REMOVEXATTR = 233 + SYS_LREMOVEXATTR = 234 + SYS_FREMOVEXATTR = 235 + SYS_GETTID = 236 + SYS_TKILL = 237 + SYS_FUTEX = 238 + SYS_SCHED_SETAFFINITY = 239 + SYS_SCHED_GETAFFINITY = 240 + SYS_TGKILL = 241 + SYS_IO_SETUP = 243 + SYS_IO_DESTROY = 244 + SYS_IO_GETEVENTS = 245 + SYS_IO_SUBMIT = 246 + SYS_IO_CANCEL = 247 + SYS_EXIT_GROUP = 248 + SYS_EPOLL_CREATE = 249 + SYS_EPOLL_CTL = 250 + SYS_EPOLL_WAIT = 251 + SYS_SET_TID_ADDRESS = 252 + SYS_FADVISE64 = 253 + SYS_TIMER_CREATE = 254 + SYS_TIMER_SETTIME = 255 + SYS_TIMER_GETTIME = 256 + SYS_TIMER_GETOVERRUN = 257 + SYS_TIMER_DELETE = 258 + SYS_CLOCK_SETTIME = 259 + SYS_CLOCK_GETTIME = 260 + SYS_CLOCK_GETRES = 261 + SYS_CLOCK_NANOSLEEP = 262 + SYS_STATFS64 = 265 + SYS_FSTATFS64 = 266 + SYS_REMAP_FILE_PAGES = 267 + SYS_MBIND = 268 + SYS_GET_MEMPOLICY = 269 + SYS_SET_MEMPOLICY = 270 + SYS_MQ_OPEN = 271 + SYS_MQ_UNLINK = 272 + SYS_MQ_TIMEDSEND = 273 + SYS_MQ_TIMEDRECEIVE = 274 + SYS_MQ_NOTIFY = 275 + SYS_MQ_GETSETATTR = 276 + SYS_KEXEC_LOAD = 277 + SYS_ADD_KEY = 278 + SYS_REQUEST_KEY = 279 + SYS_KEYCTL = 280 + SYS_WAITID = 281 + SYS_IOPRIO_SET = 282 + SYS_IOPRIO_GET = 283 + SYS_INOTIFY_INIT = 284 + SYS_INOTIFY_ADD_WATCH = 285 + SYS_INOTIFY_RM_WATCH = 286 + SYS_MIGRATE_PAGES = 287 + SYS_OPENAT = 288 + SYS_MKDIRAT = 289 + SYS_MKNODAT = 290 + SYS_FCHOWNAT = 291 + SYS_FUTIMESAT = 292 + SYS_UNLINKAT = 294 + SYS_RENAMEAT = 295 + SYS_LINKAT = 296 + SYS_SYMLINKAT = 297 + SYS_READLINKAT = 298 + SYS_FCHMODAT = 299 + SYS_FACCESSAT = 300 + SYS_PSELECT6 = 301 + SYS_PPOLL = 302 + SYS_UNSHARE = 303 + SYS_SET_ROBUST_LIST = 304 + SYS_GET_ROBUST_LIST = 305 + SYS_SPLICE = 306 + SYS_SYNC_FILE_RANGE = 307 + SYS_TEE = 308 + SYS_VMSPLICE = 309 + SYS_MOVE_PAGES = 310 + SYS_GETCPU = 311 + SYS_EPOLL_PWAIT = 312 + SYS_UTIMES = 313 + SYS_FALLOCATE = 314 + SYS_UTIMENSAT = 315 + SYS_SIGNALFD = 316 + SYS_TIMERFD = 317 + SYS_EVENTFD = 318 + SYS_TIMERFD_CREATE = 319 + SYS_TIMERFD_SETTIME = 320 + SYS_TIMERFD_GETTIME = 321 + SYS_SIGNALFD4 = 322 + SYS_EVENTFD2 = 323 + SYS_INOTIFY_INIT1 = 324 + SYS_PIPE2 = 325 + SYS_DUP3 = 326 + SYS_EPOLL_CREATE1 = 327 + SYS_PREADV = 328 + SYS_PWRITEV = 329 + SYS_RT_TGSIGQUEUEINFO = 330 + SYS_PERF_EVENT_OPEN = 331 + SYS_FANOTIFY_INIT = 332 + SYS_FANOTIFY_MARK = 333 + SYS_PRLIMIT64 = 334 + SYS_NAME_TO_HANDLE_AT = 335 + SYS_OPEN_BY_HANDLE_AT = 336 + SYS_CLOCK_ADJTIME = 337 + SYS_SYNCFS = 338 + SYS_SETNS = 339 + SYS_PROCESS_VM_READV = 340 + SYS_PROCESS_VM_WRITEV = 341 + SYS_S390_RUNTIME_INSTR = 342 + SYS_KCMP = 343 + SYS_FINIT_MODULE = 344 + SYS_SCHED_SETATTR = 345 + SYS_SCHED_GETATTR = 346 + SYS_RENAMEAT2 = 347 + SYS_SECCOMP = 348 + SYS_GETRANDOM = 349 + SYS_MEMFD_CREATE = 350 + SYS_BPF = 351 + SYS_S390_PCI_MMIO_WRITE = 352 + SYS_S390_PCI_MMIO_READ = 353 + SYS_EXECVEAT = 354 + SYS_USERFAULTFD = 355 + SYS_MEMBARRIER = 356 + SYS_RECVMMSG = 357 + SYS_SENDMMSG = 358 + SYS_SOCKET = 359 + SYS_SOCKETPAIR = 360 + SYS_BIND = 361 + SYS_CONNECT = 362 + SYS_LISTEN = 363 + SYS_ACCEPT4 = 364 + SYS_GETSOCKOPT = 365 + SYS_SETSOCKOPT = 366 + SYS_GETSOCKNAME = 367 + SYS_GETPEERNAME = 368 + SYS_SENDTO = 369 + SYS_SENDMSG = 370 + SYS_RECVFROM = 371 + SYS_RECVMSG = 372 + SYS_SHUTDOWN = 373 + SYS_MLOCK2 = 374 + SYS_SELECT = 142 + SYS_GETRLIMIT = 191 + SYS_LCHOWN = 198 + SYS_GETUID = 199 + SYS_GETGID = 200 + SYS_GETEUID = 201 + SYS_GETEGID = 202 + SYS_SETREUID = 203 + SYS_SETREGID = 204 + SYS_GETGROUPS = 205 + SYS_SETGROUPS = 206 + SYS_FCHOWN = 207 + SYS_SETRESUID = 208 + SYS_GETRESUID = 209 + SYS_SETRESGID = 210 + SYS_GETRESGID = 211 + SYS_CHOWN = 212 + SYS_SETUID = 213 + SYS_SETGID = 214 + SYS_SETFSUID = 215 + SYS_SETFSGID = 216 + SYS_NEWFSTATAT = 293 +) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_netbsd_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_netbsd_386.go index bf00385b85..f60d8f9882 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_netbsd_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_netbsd_386.go @@ -1,6 +1,8 @@ // mksysnum_netbsd.pl // MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT +// +build 386,netbsd + package unix const ( diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go index bf00385b85..48a91d4646 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go @@ -1,6 +1,8 @@ // mksysnum_netbsd.pl // MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT +// +build amd64,netbsd + package unix const ( diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_netbsd_arm.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_netbsd_arm.go index bf00385b85..612ba662cb 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_netbsd_arm.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_netbsd_arm.go @@ -1,6 +1,8 @@ // mksysnum_netbsd.pl // MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT +// +build arm,netbsd + package unix const ( diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_openbsd_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_openbsd_386.go index a3cae50590..3e8ce2a1dd 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_openbsd_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_openbsd_386.go @@ -1,6 +1,8 @@ // mksysnum_openbsd.pl // MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT +// +build 386,openbsd + package unix const ( diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_openbsd_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_openbsd_amd64.go index a3cae50590..bd28146ddd 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_openbsd_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_openbsd_amd64.go @@ -1,6 +1,8 @@ // mksysnum_openbsd.pl // MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT +// +build amd64,openbsd + package unix const ( diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_solaris_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_solaris_amd64.go index da00f9ee13..c708659859 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_solaris_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_solaris_amd64.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build amd64,solaris + package unix // TODO(aram): remove these before Go 1.3. diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_darwin_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_darwin_386.go index 75dc532c5d..2de1d44e28 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_darwin_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_darwin_386.go @@ -1,3 +1,4 @@ +// +build 386,darwin // Created by cgo -godefs - DO NOT EDIT // cgo -godefs types_darwin.go @@ -28,7 +29,7 @@ type Timeval struct { Usec int32 } -type Timeval32 [0]byte +type Timeval32 struct{} type Rusage struct { Utime Timeval diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_darwin_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_darwin_amd64.go index 93d6d28626..044657878c 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_darwin_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_darwin_amd64.go @@ -1,3 +1,4 @@ +// +build amd64,darwin // Created by cgo -godefs - DO NOT EDIT // cgo -godefs types_darwin.go @@ -130,9 +131,9 @@ type Fbootstraptransfer_t struct { } type Log2phys_t struct { - Flags uint32 - Contigbytes int64 - Devoffset int64 + Flags uint32 + Pad_cgo_0 [8]byte + Pad_cgo_1 [8]byte } type Fsid struct { @@ -454,3 +455,8 @@ type Termios struct { Ispeed uint64 Ospeed uint64 } + +const ( + AT_FDCWD = -0x2 + AT_SYMLINK_NOFOLLOW = 0x20 +) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_dragonfly_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_darwin_arm.go similarity index 68% rename from Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_dragonfly_386.go rename to Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_darwin_arm.go index e1b97ffd12..66df363ce5 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_dragonfly_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_darwin_arm.go @@ -1,5 +1,8 @@ +// NOTE: cgo can't generate struct Stat_t and struct Statfs_t yet // Created by cgo -godefs - DO NOT EDIT -// cgo -godefs types_dragonfly.go +// cgo -godefs types_darwin.go + +// +build arm,darwin package unix @@ -28,6 +31,8 @@ type Timeval struct { Usec int32 } +type Timeval32 [0]byte + type Rusage struct { Utime Timeval Stime Timeval @@ -48,74 +53,50 @@ type Rusage struct { } type Rlimit struct { - Cur int64 - Max int64 + Cur uint64 + Max uint64 } type _Gid_t uint32 -const ( - S_IFMT = 0xf000 - S_IFIFO = 0x1000 - S_IFCHR = 0x2000 - S_IFDIR = 0x4000 - S_IFBLK = 0x6000 - S_IFREG = 0x8000 - S_IFLNK = 0xa000 - S_IFSOCK = 0xc000 - S_ISUID = 0x800 - S_ISGID = 0x400 - S_ISVTX = 0x200 - S_IRUSR = 0x100 - S_IWUSR = 0x80 - S_IXUSR = 0x40 -) - type Stat_t struct { - Ino uint64 - Nlink uint32 - Dev uint32 - Mode uint16 - Padding1 uint16 - Uid uint32 - Gid uint32 - Rdev uint32 - Atim Timespec - Mtim Timespec - Ctim Timespec - Size int64 - Blocks int64 - Blksize uint32 - Flags uint32 - Gen uint32 - Lspare int32 - Qspare1 int64 - Qspare2 int64 + Dev int32 + Mode uint16 + Nlink uint16 + Ino uint64 + Uid uint32 + Gid uint32 + Rdev int32 + Atimespec Timespec + Mtimespec Timespec + Ctimespec Timespec + Birthtimespec Timespec + Size int64 + Blocks int64 + Blksize int32 + Flags uint32 + Gen uint32 + Lspare int32 + Qspare [2]int64 } type Statfs_t struct { - Spare2 int32 - Bsize int32 + Bsize uint32 Iosize int32 - Blocks int32 - Bfree int32 - Bavail int32 - Files int32 - Ffree int32 + Blocks uint64 + Bfree uint64 + Bavail uint64 + Files uint64 + Ffree uint64 Fsid Fsid Owner uint32 - Type int32 - Flags int32 - Syncwrites int32 - Asyncwrites int32 + Type uint32 + Flags uint32 + Fssubtype uint32 Fstypename [16]int8 - Mntonname [80]int8 - Syncreads int32 - Asyncreads int32 - Spares1 int16 - Mntfromname [80]int8 - Spares2 int16 - Spare [2]int32 + Mntonname [1024]int8 + Mntfromname [1024]int8 + Reserved [8]uint32 } type Flock_t struct { @@ -126,19 +107,45 @@ type Flock_t struct { Whence int16 } -type Dirent struct { - Fileno uint64 - Namlen uint16 - Type uint8 - Unused1 uint8 - Unused2 uint32 - Name [256]int8 +type Fstore_t struct { + Flags uint32 + Posmode int32 + Offset int64 + Length int64 + Bytesalloc int64 +} + +type Radvisory_t struct { + Offset int64 + Count int32 +} + +type Fbootstraptransfer_t struct { + Offset int64 + Length uint32 + Buffer *byte +} + +type Log2phys_t struct { + Flags uint32 + Contigbytes int64 + Devoffset int64 } type Fsid struct { Val [2]int32 } +type Dirent struct { + Ino uint64 + Seekoff uint64 + Reclen uint16 + Namlen uint16 + Type uint8 + Name [1024]int8 + Pad_cgo_0 [3]byte +} + type RawSockaddrInet4 struct { Len uint8 Family uint8 @@ -171,8 +178,6 @@ type RawSockaddrDatalink struct { Alen uint8 Slen uint8 Data [12]int8 - Rcf uint16 - Route [16]uint16 } type RawSockaddr struct { @@ -224,6 +229,12 @@ type Cmsghdr struct { Type int32 } +type Inet4Pktinfo struct { + Ifindex uint32 + Spec_dst [4]byte /* in_addr */ + Addr [4]byte /* in_addr */ +} + type Inet6Pktinfo struct { Addr [16]byte /* in6_addr */ Ifindex uint32 @@ -243,12 +254,13 @@ const ( SizeofSockaddrInet6 = 0x1c SizeofSockaddrAny = 0x6c SizeofSockaddrUnix = 0x6a - SizeofSockaddrDatalink = 0x36 + SizeofSockaddrDatalink = 0x14 SizeofLinger = 0x8 SizeofIPMreq = 0x8 SizeofIPv6Mreq = 0x14 SizeofMsghdr = 0x1c SizeofCmsghdr = 0xc + SizeofInet4Pktinfo = 0xc SizeofInet6Pktinfo = 0x14 SizeofIPv6MTUInfo = 0x20 SizeofICMPv6Filter = 0x20 @@ -270,17 +282,17 @@ type Kevent_t struct { } type FdSet struct { - Bits [32]uint32 + Bits [32]int32 } const ( - SizeofIfMsghdr = 0x68 - SizeofIfData = 0x58 - SizeofIfaMsghdr = 0x14 - SizeofIfmaMsghdr = 0x10 - SizeofIfAnnounceMsghdr = 0x18 - SizeofRtMsghdr = 0x5c - SizeofRtMetrics = 0x38 + SizeofIfMsghdr = 0x70 + SizeofIfData = 0x60 + SizeofIfaMsghdr = 0x14 + SizeofIfmaMsghdr = 0x10 + SizeofIfmaMsghdr2 = 0x14 + SizeofRtMsghdr = 0x5c + SizeofRtMetrics = 0x38 ) type IfMsghdr struct { @@ -296,16 +308,16 @@ type IfMsghdr struct { type IfData struct { Type uint8 + Typelen uint8 Physical uint8 Addrlen uint8 Hdrlen uint8 Recvquota uint8 Xmitquota uint8 - Pad_cgo_0 [2]byte + Unused1 uint8 Mtu uint32 Metric uint32 - Link_state uint32 - Baudrate uint64 + Baudrate uint32 Ipackets uint32 Ierrors uint32 Opackets uint32 @@ -317,9 +329,13 @@ type IfData struct { Omcasts uint32 Iqdrops uint32 Noproto uint32 - Hwassist uint32 - Unused uint32 + Recvtiming uint32 + Xmittiming uint32 Lastchange Timeval + Unused2 uint32 + Hwassist uint32 + Reserved1 uint32 + Reserved2 uint32 } type IfaMsghdr struct { @@ -343,13 +359,15 @@ type IfmaMsghdr struct { Pad_cgo_0 [2]byte } -type IfAnnounceMsghdr struct { - Msglen uint16 - Version uint8 - Type uint8 - Index uint16 - Name [16]int8 - What uint16 +type IfmaMsghdr2 struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Refcount int32 } type RtMsghdr struct { @@ -369,21 +387,17 @@ type RtMsghdr struct { } type RtMetrics struct { - Locks uint32 - Mtu uint32 - Pksent uint32 - Expire uint32 - Sendpipe uint32 - Ssthresh uint32 - Rtt uint32 - Rttvar uint32 - Recvpipe uint32 - Hopcount uint32 - Mssopt uint16 - Pad uint16 - Msl uint32 - Iwmaxsegs uint32 - Iwcapsegs uint32 + Locks uint32 + Mtu uint32 + Hopcount uint32 + Expire int32 + Recvpipe uint32 + Sendpipe uint32 + Ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Pksent uint32 + Filler [4]uint32 } const ( diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_darwin_arm64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_darwin_arm64.go new file mode 100644 index 0000000000..85d56eabd3 --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_darwin_arm64.go @@ -0,0 +1,457 @@ +// +build arm64,darwin +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_darwin.go + +package unix + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int32 + Pad_cgo_0 [4]byte +} + +type Timeval32 struct { + Sec int32 + Usec int32 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +type Stat_t struct { + Dev int32 + Mode uint16 + Nlink uint16 + Ino uint64 + Uid uint32 + Gid uint32 + Rdev int32 + Pad_cgo_0 [4]byte + Atimespec Timespec + Mtimespec Timespec + Ctimespec Timespec + Birthtimespec Timespec + Size int64 + Blocks int64 + Blksize int32 + Flags uint32 + Gen uint32 + Lspare int32 + Qspare [2]int64 +} + +type Statfs_t struct { + Bsize uint32 + Iosize int32 + Blocks uint64 + Bfree uint64 + Bavail uint64 + Files uint64 + Ffree uint64 + Fsid Fsid + Owner uint32 + Type uint32 + Flags uint32 + Fssubtype uint32 + Fstypename [16]int8 + Mntonname [1024]int8 + Mntfromname [1024]int8 + Reserved [8]uint32 +} + +type Flock_t struct { + Start int64 + Len int64 + Pid int32 + Type int16 + Whence int16 +} + +type Fstore_t struct { + Flags uint32 + Posmode int32 + Offset int64 + Length int64 + Bytesalloc int64 +} + +type Radvisory_t struct { + Offset int64 + Count int32 + Pad_cgo_0 [4]byte +} + +type Fbootstraptransfer_t struct { + Offset int64 + Length uint64 + Buffer *byte +} + +type Log2phys_t struct { + Flags uint32 + Pad_cgo_0 [8]byte + Pad_cgo_1 [8]byte +} + +type Fsid struct { + Val [2]int32 +} + +type Dirent struct { + Ino uint64 + Seekoff uint64 + Reclen uint16 + Namlen uint16 + Type uint8 + Name [1024]int8 + Pad_cgo_0 [3]byte +} + +type RawSockaddrInet4 struct { + Len uint8 + Family uint8 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]int8 +} + +type RawSockaddrInet6 struct { + Len uint8 + Family uint8 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Len uint8 + Family uint8 + Path [104]int8 +} + +type RawSockaddrDatalink struct { + Len uint8 + Family uint8 + Index uint16 + Type uint8 + Nlen uint8 + Alen uint8 + Slen uint8 + Data [12]int8 +} + +type RawSockaddr struct { + Len uint8 + Family uint8 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [92]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint64 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Pad_cgo_0 [4]byte + Iov *Iovec + Iovlen int32 + Pad_cgo_1 [4]byte + Control *byte + Controllen uint32 + Flags int32 +} + +type Cmsghdr struct { + Len uint32 + Level int32 + Type int32 +} + +type Inet4Pktinfo struct { + Ifindex uint32 + Spec_dst [4]byte /* in_addr */ + Addr [4]byte /* in_addr */ +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Filt [8]uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x6c + SizeofSockaddrUnix = 0x6a + SizeofSockaddrDatalink = 0x14 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x30 + SizeofCmsghdr = 0xc + SizeofInet4Pktinfo = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 +) + +const ( + PTRACE_TRACEME = 0x0 + PTRACE_CONT = 0x7 + PTRACE_KILL = 0x8 +) + +type Kevent_t struct { + Ident uint64 + Filter int16 + Flags uint16 + Fflags uint32 + Data int64 + Udata *byte +} + +type FdSet struct { + Bits [32]int32 +} + +const ( + SizeofIfMsghdr = 0x70 + SizeofIfData = 0x60 + SizeofIfaMsghdr = 0x14 + SizeofIfmaMsghdr = 0x10 + SizeofIfmaMsghdr2 = 0x14 + SizeofRtMsghdr = 0x5c + SizeofRtMetrics = 0x38 +) + +type IfMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Data IfData +} + +type IfData struct { + Type uint8 + Typelen uint8 + Physical uint8 + Addrlen uint8 + Hdrlen uint8 + Recvquota uint8 + Xmitquota uint8 + Unused1 uint8 + Mtu uint32 + Metric uint32 + Baudrate uint32 + Ipackets uint32 + Ierrors uint32 + Opackets uint32 + Oerrors uint32 + Collisions uint32 + Ibytes uint32 + Obytes uint32 + Imcasts uint32 + Omcasts uint32 + Iqdrops uint32 + Noproto uint32 + Recvtiming uint32 + Xmittiming uint32 + Lastchange Timeval32 + Unused2 uint32 + Hwassist uint32 + Reserved1 uint32 + Reserved2 uint32 +} + +type IfaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Metric int32 +} + +type IfmaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte +} + +type IfmaMsghdr2 struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Refcount int32 +} + +type RtMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Index uint16 + Pad_cgo_0 [2]byte + Flags int32 + Addrs int32 + Pid int32 + Seq int32 + Errno int32 + Use int32 + Inits uint32 + Rmx RtMetrics +} + +type RtMetrics struct { + Locks uint32 + Mtu uint32 + Hopcount uint32 + Expire int32 + Recvpipe uint32 + Sendpipe uint32 + Ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Pksent uint32 + Filler [4]uint32 +} + +const ( + SizeofBpfVersion = 0x4 + SizeofBpfStat = 0x8 + SizeofBpfProgram = 0x10 + SizeofBpfInsn = 0x8 + SizeofBpfHdr = 0x14 +) + +type BpfVersion struct { + Major uint16 + Minor uint16 +} + +type BpfStat struct { + Recv uint32 + Drop uint32 +} + +type BpfProgram struct { + Len uint32 + Pad_cgo_0 [4]byte + Insns *BpfInsn +} + +type BpfInsn struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type BpfHdr struct { + Tstamp Timeval32 + Caplen uint32 + Datalen uint32 + Hdrlen uint16 + Pad_cgo_0 [2]byte +} + +type Termios struct { + Iflag uint64 + Oflag uint64 + Cflag uint64 + Lflag uint64 + Cc [20]uint8 + Pad_cgo_0 [4]byte + Ispeed uint64 + Ospeed uint64 +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go index b94a4ff02a..8a6f4e1ce3 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go @@ -1,6 +1,8 @@ // Created by cgo -godefs - DO NOT EDIT // cgo -godefs types_dragonfly.go +// +build amd64,dragonfly + package unix const ( diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_freebsd_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_freebsd_386.go index d9d5ce46ff..8cf30947b4 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_freebsd_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_freebsd_386.go @@ -1,3 +1,4 @@ +// +build 386,freebsd // Created by cgo -godefs - DO NOT EDIT // cgo -godefs types_freebsd.go @@ -138,6 +139,15 @@ type Fsid struct { Val [2]int32 } +const ( + FADV_NORMAL = 0x0 + FADV_RANDOM = 0x1 + FADV_SEQUENTIAL = 0x2 + FADV_WILLNEED = 0x3 + FADV_DONTNEED = 0x4 + FADV_NOREUSE = 0x5 +) + type RawSockaddrInet4 struct { Len uint8 Family uint8 diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_freebsd_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_freebsd_amd64.go index 80c6b81254..e5feb207be 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_freebsd_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_freebsd_amd64.go @@ -1,3 +1,4 @@ +// +build amd64,freebsd // Created by cgo -godefs - DO NOT EDIT // cgo -godefs types_freebsd.go @@ -138,6 +139,15 @@ type Fsid struct { Val [2]int32 } +const ( + FADV_NORMAL = 0x0 + FADV_RANDOM = 0x1 + FADV_SEQUENTIAL = 0x2 + FADV_WILLNEED = 0x3 + FADV_DONTNEED = 0x4 + FADV_NOREUSE = 0x5 +) + type RawSockaddrInet4 struct { Len uint8 Family uint8 diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_freebsd_arm.go b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_freebsd_arm.go index bd971b5647..5472b54284 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_freebsd_arm.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_freebsd_arm.go @@ -1,6 +1,8 @@ // Created by cgo -godefs - DO NOT EDIT // cgo -godefs -- -fsigned-char types_freebsd.go +// +build arm,freebsd + package unix const ( diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_386.go index 3b1dcc65e3..fb1257ae02 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_386.go @@ -1,3 +1,4 @@ +// +build 386,linux // Created by cgo -godefs - DO NOT EDIT // cgo -godefs types_linux.go @@ -150,6 +151,15 @@ type Flock_t struct { Pid int32 } +const ( + FADV_NORMAL = 0x0 + FADV_RANDOM = 0x1 + FADV_SEQUENTIAL = 0x2 + FADV_WILLNEED = 0x3 + FADV_DONTNEED = 0x4 + FADV_NOREUSE = 0x5 +) + type RawSockaddrInet4 struct { Family uint16 Port uint16 @@ -187,6 +197,12 @@ type RawSockaddrNetlink struct { Groups uint32 } +type RawSockaddrHCI struct { + Family uint16 + Dev uint16 + Channel uint16 +} + type RawSockaddr struct { Family uint16 Data [14]int8 @@ -309,6 +325,7 @@ const ( SizeofSockaddrUnix = 0x6e SizeofSockaddrLinklayer = 0x14 SizeofSockaddrNetlink = 0xc + SizeofSockaddrHCI = 0x6 SizeofLinger = 0x8 SizeofIPMreq = 0x8 SizeofIPMreqn = 0xc @@ -573,18 +590,18 @@ type EpollEvent struct { const ( AT_FDCWD = -0x64 - AT_SYMLINK_NOFOLLOW = 0x100 AT_REMOVEDIR = 0x200 + AT_SYMLINK_FOLLOW = 0x400 + AT_SYMLINK_NOFOLLOW = 0x100 ) type Termios struct { - Iflag uint32 - Oflag uint32 - Cflag uint32 - Lflag uint32 - Line uint8 - Cc [32]uint8 - Pad_cgo_0 [3]byte - Ispeed uint32 - Ospeed uint32 + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Line uint8 + Cc [19]uint8 + Ispeed uint32 + Ospeed uint32 } diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_amd64.go index 8e6bd61e0c..34edb3685f 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_amd64.go @@ -1,3 +1,4 @@ +// +build amd64,linux // Created by cgo -godefs - DO NOT EDIT // cgo -godefs types_linux.go @@ -152,6 +153,15 @@ type Flock_t struct { Pad_cgo_1 [4]byte } +const ( + FADV_NORMAL = 0x0 + FADV_RANDOM = 0x1 + FADV_SEQUENTIAL = 0x2 + FADV_WILLNEED = 0x3 + FADV_DONTNEED = 0x4 + FADV_NOREUSE = 0x5 +) + type RawSockaddrInet4 struct { Family uint16 Port uint16 @@ -189,6 +199,12 @@ type RawSockaddrNetlink struct { Groups uint32 } +type RawSockaddrHCI struct { + Family uint16 + Dev uint16 + Channel uint16 +} + type RawSockaddr struct { Family uint16 Data [14]int8 @@ -313,6 +329,7 @@ const ( SizeofSockaddrUnix = 0x6e SizeofSockaddrLinklayer = 0x14 SizeofSockaddrNetlink = 0xc + SizeofSockaddrHCI = 0x6 SizeofLinger = 0x8 SizeofIPMreq = 0x8 SizeofIPMreqn = 0xc @@ -591,18 +608,18 @@ type EpollEvent struct { const ( AT_FDCWD = -0x64 - AT_SYMLINK_NOFOLLOW = 0x100 AT_REMOVEDIR = 0x200 + AT_SYMLINK_FOLLOW = 0x400 + AT_SYMLINK_NOFOLLOW = 0x100 ) type Termios struct { - Iflag uint32 - Oflag uint32 - Cflag uint32 - Lflag uint32 - Line uint8 - Cc [32]uint8 - Pad_cgo_0 [3]byte - Ispeed uint32 - Ospeed uint32 + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Line uint8 + Cc [19]uint8 + Ispeed uint32 + Ospeed uint32 } diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_arm.go b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_arm.go index 7a8e03943b..0fef350b14 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_arm.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_arm.go @@ -1,3 +1,4 @@ +// +build arm,linux // Created by cgo -godefs - DO NOT EDIT // cgo -godefs types_linux.go @@ -191,6 +192,12 @@ type RawSockaddrNetlink struct { Groups uint32 } +type RawSockaddrHCI struct { + Family uint16 + Dev uint16 + Channel uint16 +} + type RawSockaddr struct { Family uint16 Data [14]uint8 @@ -313,6 +320,7 @@ const ( SizeofSockaddrUnix = 0x6e SizeofSockaddrLinklayer = 0x14 SizeofSockaddrNetlink = 0xc + SizeofSockaddrHCI = 0x6 SizeofLinger = 0x8 SizeofIPMreq = 0x8 SizeofIPMreqn = 0xc @@ -562,120 +570,18 @@ type EpollEvent struct { const ( AT_FDCWD = -0x64 - AT_SYMLINK_NOFOLLOW = 0x100 AT_REMOVEDIR = 0x200 + AT_SYMLINK_FOLLOW = 0x400 + AT_SYMLINK_NOFOLLOW = 0x100 ) type Termios struct { - Iflag uint32 - Oflag uint32 - Cflag uint32 - Lflag uint32 - Line uint8 - Cc [32]uint8 - Pad_cgo_0 [3]byte - Ispeed uint32 - Ospeed uint32 + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Line uint8 + Cc [19]uint8 + Ispeed uint32 + Ospeed uint32 } - -const ( - VINTR = 0x0 - VQUIT = 0x1 - VERASE = 0x2 - VKILL = 0x3 - VEOF = 0x4 - VTIME = 0x5 - VMIN = 0x6 - VSWTC = 0x7 - VSTART = 0x8 - VSTOP = 0x9 - VSUSP = 0xa - VEOL = 0xb - VREPRINT = 0xc - VDISCARD = 0xd - VWERASE = 0xe - VLNEXT = 0xf - VEOL2 = 0x10 - IGNBRK = 0x1 - BRKINT = 0x2 - IGNPAR = 0x4 - PARMRK = 0x8 - INPCK = 0x10 - ISTRIP = 0x20 - INLCR = 0x40 - IGNCR = 0x80 - ICRNL = 0x100 - IUCLC = 0x200 - IXON = 0x400 - IXANY = 0x800 - IXOFF = 0x1000 - IMAXBEL = 0x2000 - IUTF8 = 0x4000 - OPOST = 0x1 - OLCUC = 0x2 - ONLCR = 0x4 - OCRNL = 0x8 - ONOCR = 0x10 - ONLRET = 0x20 - OFILL = 0x40 - OFDEL = 0x80 - B0 = 0x0 - B50 = 0x1 - B75 = 0x2 - B110 = 0x3 - B134 = 0x4 - B150 = 0x5 - B200 = 0x6 - B300 = 0x7 - B600 = 0x8 - B1200 = 0x9 - B1800 = 0xa - B2400 = 0xb - B4800 = 0xc - B9600 = 0xd - B19200 = 0xe - B38400 = 0xf - CSIZE = 0x30 - CS5 = 0x0 - CS6 = 0x10 - CS7 = 0x20 - CS8 = 0x30 - CSTOPB = 0x40 - CREAD = 0x80 - PARENB = 0x100 - PARODD = 0x200 - HUPCL = 0x400 - CLOCAL = 0x800 - B57600 = 0x1001 - B115200 = 0x1002 - B230400 = 0x1003 - B460800 = 0x1004 - B500000 = 0x1005 - B576000 = 0x1006 - B921600 = 0x1007 - B1000000 = 0x1008 - B1152000 = 0x1009 - B1500000 = 0x100a - B2000000 = 0x100b - B2500000 = 0x100c - B3000000 = 0x100d - B3500000 = 0x100e - B4000000 = 0x100f - ISIG = 0x1 - ICANON = 0x2 - XCASE = 0x4 - ECHO = 0x8 - ECHOE = 0x10 - ECHOK = 0x20 - ECHONL = 0x40 - NOFLSH = 0x80 - TOSTOP = 0x100 - ECHOCTL = 0x200 - ECHOPRT = 0x400 - ECHOKE = 0x800 - FLUSHO = 0x1000 - PENDIN = 0x4000 - IEXTEN = 0x8000 - TCGETS = 0x5401 - TCSETS = 0x5402 -) diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_arm64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_arm64.go new file mode 100644 index 0000000000..28b7cd43ce --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_arm64.go @@ -0,0 +1,604 @@ +// +build arm64,linux +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -fsigned-char types_linux.go + +package unix + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 + PathMax = 0x1000 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int64 +} + +type Timex struct { + Modes uint32 + Pad_cgo_0 [4]byte + Offset int64 + Freq int64 + Maxerror int64 + Esterror int64 + Status int32 + Pad_cgo_1 [4]byte + Constant int64 + Precision int64 + Tolerance int64 + Time Timeval + Tick int64 + Ppsfreq int64 + Jitter int64 + Shift int32 + Pad_cgo_2 [4]byte + Stabil int64 + Jitcnt int64 + Calcnt int64 + Errcnt int64 + Stbcnt int64 + Tai int32 + Pad_cgo_3 [44]byte +} + +type Time_t int64 + +type Tms struct { + Utime int64 + Stime int64 + Cutime int64 + Cstime int64 +} + +type Utimbuf struct { + Actime int64 + Modtime int64 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +type Stat_t struct { + Dev uint64 + Ino uint64 + Mode uint32 + Nlink uint32 + Uid uint32 + Gid uint32 + Rdev uint64 + X__pad1 uint64 + Size int64 + Blksize int32 + X__pad2 int32 + Blocks int64 + Atim Timespec + Mtim Timespec + Ctim Timespec + X__glibc_reserved [2]int32 +} + +type Statfs_t struct { + Type int64 + Bsize int64 + Blocks uint64 + Bfree uint64 + Bavail uint64 + Files uint64 + Ffree uint64 + Fsid Fsid + Namelen int64 + Frsize int64 + Flags int64 + Spare [4]int64 +} + +type Dirent struct { + Ino uint64 + Off int64 + Reclen uint16 + Type uint8 + Name [256]int8 + Pad_cgo_0 [5]byte +} + +type Fsid struct { + X__val [2]int32 +} + +type Flock_t struct { + Type int16 + Whence int16 + Pad_cgo_0 [4]byte + Start int64 + Len int64 + Pid int32 + Pad_cgo_1 [4]byte +} + +const ( + FADV_NORMAL = 0x0 + FADV_RANDOM = 0x1 + FADV_SEQUENTIAL = 0x2 + FADV_WILLNEED = 0x3 + FADV_DONTNEED = 0x4 + FADV_NOREUSE = 0x5 +) + +type RawSockaddrInet4 struct { + Family uint16 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]uint8 +} + +type RawSockaddrInet6 struct { + Family uint16 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Family uint16 + Path [108]int8 +} + +type RawSockaddrLinklayer struct { + Family uint16 + Protocol uint16 + Ifindex int32 + Hatype uint16 + Pkttype uint8 + Halen uint8 + Addr [8]uint8 +} + +type RawSockaddrNetlink struct { + Family uint16 + Pad uint16 + Pid uint32 + Groups uint32 +} + +type RawSockaddrHCI struct { + Family uint16 + Dev uint16 + Channel uint16 +} + +type RawSockaddr struct { + Family uint16 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [96]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint64 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPMreqn struct { + Multiaddr [4]byte /* in_addr */ + Address [4]byte /* in_addr */ + Ifindex int32 +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Pad_cgo_0 [4]byte + Iov *Iovec + Iovlen uint64 + Control *byte + Controllen uint64 + Flags int32 + Pad_cgo_1 [4]byte +} + +type Cmsghdr struct { + Len uint64 + Level int32 + Type int32 + X__cmsg_data [0]uint8 +} + +type Inet4Pktinfo struct { + Ifindex int32 + Spec_dst [4]byte /* in_addr */ + Addr [4]byte /* in_addr */ +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Data [8]uint32 +} + +type Ucred struct { + Pid int32 + Uid uint32 + Gid uint32 +} + +type TCPInfo struct { + State uint8 + Ca_state uint8 + Retransmits uint8 + Probes uint8 + Backoff uint8 + Options uint8 + Pad_cgo_0 [2]byte + Rto uint32 + Ato uint32 + Snd_mss uint32 + Rcv_mss uint32 + Unacked uint32 + Sacked uint32 + Lost uint32 + Retrans uint32 + Fackets uint32 + Last_data_sent uint32 + Last_ack_sent uint32 + Last_data_recv uint32 + Last_ack_recv uint32 + Pmtu uint32 + Rcv_ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Snd_ssthresh uint32 + Snd_cwnd uint32 + Advmss uint32 + Reordering uint32 + Rcv_rtt uint32 + Rcv_space uint32 + Total_retrans uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x70 + SizeofSockaddrUnix = 0x6e + SizeofSockaddrLinklayer = 0x14 + SizeofSockaddrNetlink = 0xc + SizeofSockaddrHCI = 0x6 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPMreqn = 0xc + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x38 + SizeofCmsghdr = 0x10 + SizeofInet4Pktinfo = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 + SizeofUcred = 0xc + SizeofTCPInfo = 0x68 +) + +const ( + IFA_UNSPEC = 0x0 + IFA_ADDRESS = 0x1 + IFA_LOCAL = 0x2 + IFA_LABEL = 0x3 + IFA_BROADCAST = 0x4 + IFA_ANYCAST = 0x5 + IFA_CACHEINFO = 0x6 + IFA_MULTICAST = 0x7 + IFLA_UNSPEC = 0x0 + IFLA_ADDRESS = 0x1 + IFLA_BROADCAST = 0x2 + IFLA_IFNAME = 0x3 + IFLA_MTU = 0x4 + IFLA_LINK = 0x5 + IFLA_QDISC = 0x6 + IFLA_STATS = 0x7 + IFLA_COST = 0x8 + IFLA_PRIORITY = 0x9 + IFLA_MASTER = 0xa + IFLA_WIRELESS = 0xb + IFLA_PROTINFO = 0xc + IFLA_TXQLEN = 0xd + IFLA_MAP = 0xe + IFLA_WEIGHT = 0xf + IFLA_OPERSTATE = 0x10 + IFLA_LINKMODE = 0x11 + IFLA_LINKINFO = 0x12 + IFLA_NET_NS_PID = 0x13 + IFLA_IFALIAS = 0x14 + IFLA_MAX = 0x22 + RT_SCOPE_UNIVERSE = 0x0 + RT_SCOPE_SITE = 0xc8 + RT_SCOPE_LINK = 0xfd + RT_SCOPE_HOST = 0xfe + RT_SCOPE_NOWHERE = 0xff + RT_TABLE_UNSPEC = 0x0 + RT_TABLE_COMPAT = 0xfc + RT_TABLE_DEFAULT = 0xfd + RT_TABLE_MAIN = 0xfe + RT_TABLE_LOCAL = 0xff + RT_TABLE_MAX = 0xffffffff + RTA_UNSPEC = 0x0 + RTA_DST = 0x1 + RTA_SRC = 0x2 + RTA_IIF = 0x3 + RTA_OIF = 0x4 + RTA_GATEWAY = 0x5 + RTA_PRIORITY = 0x6 + RTA_PREFSRC = 0x7 + RTA_METRICS = 0x8 + RTA_MULTIPATH = 0x9 + RTA_FLOW = 0xb + RTA_CACHEINFO = 0xc + RTA_TABLE = 0xf + RTN_UNSPEC = 0x0 + RTN_UNICAST = 0x1 + RTN_LOCAL = 0x2 + RTN_BROADCAST = 0x3 + RTN_ANYCAST = 0x4 + RTN_MULTICAST = 0x5 + RTN_BLACKHOLE = 0x6 + RTN_UNREACHABLE = 0x7 + RTN_PROHIBIT = 0x8 + RTN_THROW = 0x9 + RTN_NAT = 0xa + RTN_XRESOLVE = 0xb + RTNLGRP_NONE = 0x0 + RTNLGRP_LINK = 0x1 + RTNLGRP_NOTIFY = 0x2 + RTNLGRP_NEIGH = 0x3 + RTNLGRP_TC = 0x4 + RTNLGRP_IPV4_IFADDR = 0x5 + RTNLGRP_IPV4_MROUTE = 0x6 + RTNLGRP_IPV4_ROUTE = 0x7 + RTNLGRP_IPV4_RULE = 0x8 + RTNLGRP_IPV6_IFADDR = 0x9 + RTNLGRP_IPV6_MROUTE = 0xa + RTNLGRP_IPV6_ROUTE = 0xb + RTNLGRP_IPV6_IFINFO = 0xc + RTNLGRP_IPV6_PREFIX = 0x12 + RTNLGRP_IPV6_RULE = 0x13 + RTNLGRP_ND_USEROPT = 0x14 + SizeofNlMsghdr = 0x10 + SizeofNlMsgerr = 0x14 + SizeofRtGenmsg = 0x1 + SizeofNlAttr = 0x4 + SizeofRtAttr = 0x4 + SizeofIfInfomsg = 0x10 + SizeofIfAddrmsg = 0x8 + SizeofRtMsg = 0xc + SizeofRtNexthop = 0x8 +) + +type NlMsghdr struct { + Len uint32 + Type uint16 + Flags uint16 + Seq uint32 + Pid uint32 +} + +type NlMsgerr struct { + Error int32 + Msg NlMsghdr +} + +type RtGenmsg struct { + Family uint8 +} + +type NlAttr struct { + Len uint16 + Type uint16 +} + +type RtAttr struct { + Len uint16 + Type uint16 +} + +type IfInfomsg struct { + Family uint8 + X__ifi_pad uint8 + Type uint16 + Index int32 + Flags uint32 + Change uint32 +} + +type IfAddrmsg struct { + Family uint8 + Prefixlen uint8 + Flags uint8 + Scope uint8 + Index uint32 +} + +type RtMsg struct { + Family uint8 + Dst_len uint8 + Src_len uint8 + Tos uint8 + Table uint8 + Protocol uint8 + Scope uint8 + Type uint8 + Flags uint32 +} + +type RtNexthop struct { + Len uint16 + Flags uint8 + Hops uint8 + Ifindex int32 +} + +const ( + SizeofSockFilter = 0x8 + SizeofSockFprog = 0x10 +) + +type SockFilter struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type SockFprog struct { + Len uint16 + Pad_cgo_0 [6]byte + Filter *SockFilter +} + +type InotifyEvent struct { + Wd int32 + Mask uint32 + Cookie uint32 + Len uint32 + Name [0]int8 +} + +const SizeofInotifyEvent = 0x10 + +type PtraceRegs struct { + Regs [31]uint64 + Sp uint64 + Pc uint64 + Pstate uint64 +} + +type FdSet struct { + Bits [16]int64 +} + +type Sysinfo_t struct { + Uptime int64 + Loads [3]uint64 + Totalram uint64 + Freeram uint64 + Sharedram uint64 + Bufferram uint64 + Totalswap uint64 + Freeswap uint64 + Procs uint16 + Pad uint16 + Pad_cgo_0 [4]byte + Totalhigh uint64 + Freehigh uint64 + Unit uint32 + X_f [0]int8 + Pad_cgo_1 [4]byte +} + +type Utsname struct { + Sysname [65]int8 + Nodename [65]int8 + Release [65]int8 + Version [65]int8 + Machine [65]int8 + Domainname [65]int8 +} + +type Ustat_t struct { + Tfree int32 + Pad_cgo_0 [4]byte + Tinode uint64 + Fname [6]int8 + Fpack [6]int8 + Pad_cgo_1 [4]byte +} + +type EpollEvent struct { + Events uint32 + PadFd int32 + Fd int32 + Pad int32 +} + +const ( + AT_FDCWD = -0x64 + AT_REMOVEDIR = 0x200 + AT_SYMLINK_FOLLOW = 0x400 + AT_SYMLINK_NOFOLLOW = 0x100 +) + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Line uint8 + Cc [19]uint8 + Ispeed uint32 + Ospeed uint32 +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_mips64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_mips64.go new file mode 100644 index 0000000000..8fe5af2628 --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_mips64.go @@ -0,0 +1,607 @@ +// +build mips64,linux +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_linux.go + +package unix + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 + PathMax = 0x1000 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int64 +} + +type Timex struct { + Modes uint32 + Pad_cgo_0 [4]byte + Offset int64 + Freq int64 + Maxerror int64 + Esterror int64 + Status int32 + Pad_cgo_1 [4]byte + Constant int64 + Precision int64 + Tolerance int64 + Time Timeval + Tick int64 + Ppsfreq int64 + Jitter int64 + Shift int32 + Pad_cgo_2 [4]byte + Stabil int64 + Jitcnt int64 + Calcnt int64 + Errcnt int64 + Stbcnt int64 + Tai int32 + Pad_cgo_3 [44]byte +} + +type Time_t int64 + +type Tms struct { + Utime int64 + Stime int64 + Cutime int64 + Cstime int64 +} + +type Utimbuf struct { + Actime int64 + Modtime int64 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +type Stat_t struct { + Dev uint32 + Pad1 [3]int32 + Ino uint64 + Mode uint32 + Nlink uint32 + Uid uint32 + Gid uint32 + Rdev uint32 + Pad2 [3]uint32 + Size int64 + Atim Timespec + Mtim Timespec + Ctim Timespec + Blksize uint32 + Pad4 uint32 + Blocks int64 +} + +type Statfs_t struct { + Type int64 + Bsize int64 + Frsize int64 + Blocks uint64 + Bfree uint64 + Files uint64 + Ffree uint64 + Bavail uint64 + Fsid Fsid + Namelen int64 + Flags int64 + Spare [5]int64 +} + +type Dirent struct { + Ino uint64 + Off int64 + Reclen uint16 + Type uint8 + Name [256]int8 + Pad_cgo_0 [5]byte +} + +type Fsid struct { + X__val [2]int32 +} + +type Flock_t struct { + Type int16 + Whence int16 + Pad_cgo_0 [4]byte + Start int64 + Len int64 + Pid int32 + Pad_cgo_1 [4]byte +} + +const ( + FADV_NORMAL = 0x0 + FADV_RANDOM = 0x1 + FADV_SEQUENTIAL = 0x2 + FADV_WILLNEED = 0x3 + FADV_DONTNEED = 0x4 + FADV_NOREUSE = 0x5 +) + +type RawSockaddrInet4 struct { + Family uint16 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]uint8 +} + +type RawSockaddrInet6 struct { + Family uint16 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Family uint16 + Path [108]int8 +} + +type RawSockaddrLinklayer struct { + Family uint16 + Protocol uint16 + Ifindex int32 + Hatype uint16 + Pkttype uint8 + Halen uint8 + Addr [8]uint8 +} + +type RawSockaddrNetlink struct { + Family uint16 + Pad uint16 + Pid uint32 + Groups uint32 +} + +type RawSockaddrHCI struct { + Family uint16 + Dev uint16 + Channel uint16 +} + +type RawSockaddr struct { + Family uint16 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [96]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint64 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPMreqn struct { + Multiaddr [4]byte /* in_addr */ + Address [4]byte /* in_addr */ + Ifindex int32 +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Pad_cgo_0 [4]byte + Iov *Iovec + Iovlen uint64 + Control *byte + Controllen uint64 + Flags int32 + Pad_cgo_1 [4]byte +} + +type Cmsghdr struct { + Len uint64 + Level int32 + Type int32 +} + +type Inet4Pktinfo struct { + Ifindex int32 + Spec_dst [4]byte /* in_addr */ + Addr [4]byte /* in_addr */ +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Data [8]uint32 +} + +type Ucred struct { + Pid int32 + Uid uint32 + Gid uint32 +} + +type TCPInfo struct { + State uint8 + Ca_state uint8 + Retransmits uint8 + Probes uint8 + Backoff uint8 + Options uint8 + Pad_cgo_0 [2]byte + Rto uint32 + Ato uint32 + Snd_mss uint32 + Rcv_mss uint32 + Unacked uint32 + Sacked uint32 + Lost uint32 + Retrans uint32 + Fackets uint32 + Last_data_sent uint32 + Last_ack_sent uint32 + Last_data_recv uint32 + Last_ack_recv uint32 + Pmtu uint32 + Rcv_ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Snd_ssthresh uint32 + Snd_cwnd uint32 + Advmss uint32 + Reordering uint32 + Rcv_rtt uint32 + Rcv_space uint32 + Total_retrans uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x70 + SizeofSockaddrUnix = 0x6e + SizeofSockaddrLinklayer = 0x14 + SizeofSockaddrNetlink = 0xc + SizeofSockaddrHCI = 0x6 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPMreqn = 0xc + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x38 + SizeofCmsghdr = 0x10 + SizeofInet4Pktinfo = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 + SizeofUcred = 0xc + SizeofTCPInfo = 0x68 +) + +const ( + IFA_UNSPEC = 0x0 + IFA_ADDRESS = 0x1 + IFA_LOCAL = 0x2 + IFA_LABEL = 0x3 + IFA_BROADCAST = 0x4 + IFA_ANYCAST = 0x5 + IFA_CACHEINFO = 0x6 + IFA_MULTICAST = 0x7 + IFLA_UNSPEC = 0x0 + IFLA_ADDRESS = 0x1 + IFLA_BROADCAST = 0x2 + IFLA_IFNAME = 0x3 + IFLA_MTU = 0x4 + IFLA_LINK = 0x5 + IFLA_QDISC = 0x6 + IFLA_STATS = 0x7 + IFLA_COST = 0x8 + IFLA_PRIORITY = 0x9 + IFLA_MASTER = 0xa + IFLA_WIRELESS = 0xb + IFLA_PROTINFO = 0xc + IFLA_TXQLEN = 0xd + IFLA_MAP = 0xe + IFLA_WEIGHT = 0xf + IFLA_OPERSTATE = 0x10 + IFLA_LINKMODE = 0x11 + IFLA_LINKINFO = 0x12 + IFLA_NET_NS_PID = 0x13 + IFLA_IFALIAS = 0x14 + IFLA_MAX = 0x27 + RT_SCOPE_UNIVERSE = 0x0 + RT_SCOPE_SITE = 0xc8 + RT_SCOPE_LINK = 0xfd + RT_SCOPE_HOST = 0xfe + RT_SCOPE_NOWHERE = 0xff + RT_TABLE_UNSPEC = 0x0 + RT_TABLE_COMPAT = 0xfc + RT_TABLE_DEFAULT = 0xfd + RT_TABLE_MAIN = 0xfe + RT_TABLE_LOCAL = 0xff + RT_TABLE_MAX = 0xffffffff + RTA_UNSPEC = 0x0 + RTA_DST = 0x1 + RTA_SRC = 0x2 + RTA_IIF = 0x3 + RTA_OIF = 0x4 + RTA_GATEWAY = 0x5 + RTA_PRIORITY = 0x6 + RTA_PREFSRC = 0x7 + RTA_METRICS = 0x8 + RTA_MULTIPATH = 0x9 + RTA_FLOW = 0xb + RTA_CACHEINFO = 0xc + RTA_TABLE = 0xf + RTN_UNSPEC = 0x0 + RTN_UNICAST = 0x1 + RTN_LOCAL = 0x2 + RTN_BROADCAST = 0x3 + RTN_ANYCAST = 0x4 + RTN_MULTICAST = 0x5 + RTN_BLACKHOLE = 0x6 + RTN_UNREACHABLE = 0x7 + RTN_PROHIBIT = 0x8 + RTN_THROW = 0x9 + RTN_NAT = 0xa + RTN_XRESOLVE = 0xb + RTNLGRP_NONE = 0x0 + RTNLGRP_LINK = 0x1 + RTNLGRP_NOTIFY = 0x2 + RTNLGRP_NEIGH = 0x3 + RTNLGRP_TC = 0x4 + RTNLGRP_IPV4_IFADDR = 0x5 + RTNLGRP_IPV4_MROUTE = 0x6 + RTNLGRP_IPV4_ROUTE = 0x7 + RTNLGRP_IPV4_RULE = 0x8 + RTNLGRP_IPV6_IFADDR = 0x9 + RTNLGRP_IPV6_MROUTE = 0xa + RTNLGRP_IPV6_ROUTE = 0xb + RTNLGRP_IPV6_IFINFO = 0xc + RTNLGRP_IPV6_PREFIX = 0x12 + RTNLGRP_IPV6_RULE = 0x13 + RTNLGRP_ND_USEROPT = 0x14 + SizeofNlMsghdr = 0x10 + SizeofNlMsgerr = 0x14 + SizeofRtGenmsg = 0x1 + SizeofNlAttr = 0x4 + SizeofRtAttr = 0x4 + SizeofIfInfomsg = 0x10 + SizeofIfAddrmsg = 0x8 + SizeofRtMsg = 0xc + SizeofRtNexthop = 0x8 +) + +type NlMsghdr struct { + Len uint32 + Type uint16 + Flags uint16 + Seq uint32 + Pid uint32 +} + +type NlMsgerr struct { + Error int32 + Msg NlMsghdr +} + +type RtGenmsg struct { + Family uint8 +} + +type NlAttr struct { + Len uint16 + Type uint16 +} + +type RtAttr struct { + Len uint16 + Type uint16 +} + +type IfInfomsg struct { + Family uint8 + X__ifi_pad uint8 + Type uint16 + Index int32 + Flags uint32 + Change uint32 +} + +type IfAddrmsg struct { + Family uint8 + Prefixlen uint8 + Flags uint8 + Scope uint8 + Index uint32 +} + +type RtMsg struct { + Family uint8 + Dst_len uint8 + Src_len uint8 + Tos uint8 + Table uint8 + Protocol uint8 + Scope uint8 + Type uint8 + Flags uint32 +} + +type RtNexthop struct { + Len uint16 + Flags uint8 + Hops uint8 + Ifindex int32 +} + +const ( + SizeofSockFilter = 0x8 + SizeofSockFprog = 0x10 +) + +type SockFilter struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type SockFprog struct { + Len uint16 + Pad_cgo_0 [6]byte + Filter *SockFilter +} + +type InotifyEvent struct { + Wd int32 + Mask uint32 + Cookie uint32 + Len uint32 +} + +const SizeofInotifyEvent = 0x10 + +type PtraceRegs struct { + Regs [102]uint64 + U_tsize uint64 + U_dsize uint64 + U_ssize uint64 + Start_code uint64 + Start_data uint64 + Start_stack uint64 + Signal int64 + U_ar0 uint64 + Magic uint64 + U_comm [32]int8 +} + +type FdSet struct { + Bits [16]int64 +} + +type Sysinfo_t struct { + Uptime int64 + Loads [3]uint64 + Totalram uint64 + Freeram uint64 + Sharedram uint64 + Bufferram uint64 + Totalswap uint64 + Freeswap uint64 + Procs uint16 + Pad uint16 + Pad_cgo_0 [4]byte + Totalhigh uint64 + Freehigh uint64 + Unit uint32 + X_f [0]int8 + Pad_cgo_1 [4]byte +} + +type Utsname struct { + Sysname [65]int8 + Nodename [65]int8 + Release [65]int8 + Version [65]int8 + Machine [65]int8 + Domainname [65]int8 +} + +type Ustat_t struct { + Tfree int32 + Pad_cgo_0 [4]byte + Tinode uint64 + Fname [6]int8 + Fpack [6]int8 + Pad_cgo_1 [4]byte +} + +type EpollEvent struct { + Events uint32 + Fd int32 + Pad int32 +} + +const ( + AT_FDCWD = -0x64 + AT_REMOVEDIR = 0x200 + AT_SYMLINK_FOLLOW = 0x400 + AT_SYMLINK_NOFOLLOW = 0x100 +) + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Line uint8 + Cc [32]uint8 + Pad_cgo_0 [3]byte +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_mips64le.go b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_mips64le.go new file mode 100644 index 0000000000..df16e83c5b --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_mips64le.go @@ -0,0 +1,607 @@ +// +build mips64le,linux +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_linux.go + +package unix + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 + PathMax = 0x1000 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int64 +} + +type Timex struct { + Modes uint32 + Pad_cgo_0 [4]byte + Offset int64 + Freq int64 + Maxerror int64 + Esterror int64 + Status int32 + Pad_cgo_1 [4]byte + Constant int64 + Precision int64 + Tolerance int64 + Time Timeval + Tick int64 + Ppsfreq int64 + Jitter int64 + Shift int32 + Pad_cgo_2 [4]byte + Stabil int64 + Jitcnt int64 + Calcnt int64 + Errcnt int64 + Stbcnt int64 + Tai int32 + Pad_cgo_3 [44]byte +} + +type Time_t int64 + +type Tms struct { + Utime int64 + Stime int64 + Cutime int64 + Cstime int64 +} + +type Utimbuf struct { + Actime int64 + Modtime int64 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +type Stat_t struct { + Dev uint32 + Pad1 [3]int32 + Ino uint64 + Mode uint32 + Nlink uint32 + Uid uint32 + Gid uint32 + Rdev uint32 + Pad2 [3]uint32 + Size int64 + Atim Timespec + Mtim Timespec + Ctim Timespec + Blksize uint32 + Pad4 uint32 + Blocks int64 +} + +type Statfs_t struct { + Type int64 + Bsize int64 + Frsize int64 + Blocks uint64 + Bfree uint64 + Files uint64 + Ffree uint64 + Bavail uint64 + Fsid Fsid + Namelen int64 + Flags int64 + Spare [5]int64 +} + +type Dirent struct { + Ino uint64 + Off int64 + Reclen uint16 + Type uint8 + Name [256]int8 + Pad_cgo_0 [5]byte +} + +type Fsid struct { + X__val [2]int32 +} + +type Flock_t struct { + Type int16 + Whence int16 + Pad_cgo_0 [4]byte + Start int64 + Len int64 + Pid int32 + Pad_cgo_1 [4]byte +} + +const ( + FADV_NORMAL = 0x0 + FADV_RANDOM = 0x1 + FADV_SEQUENTIAL = 0x2 + FADV_WILLNEED = 0x3 + FADV_DONTNEED = 0x4 + FADV_NOREUSE = 0x5 +) + +type RawSockaddrInet4 struct { + Family uint16 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]uint8 +} + +type RawSockaddrInet6 struct { + Family uint16 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Family uint16 + Path [108]int8 +} + +type RawSockaddrLinklayer struct { + Family uint16 + Protocol uint16 + Ifindex int32 + Hatype uint16 + Pkttype uint8 + Halen uint8 + Addr [8]uint8 +} + +type RawSockaddrNetlink struct { + Family uint16 + Pad uint16 + Pid uint32 + Groups uint32 +} + +type RawSockaddrHCI struct { + Family uint16 + Dev uint16 + Channel uint16 +} + +type RawSockaddr struct { + Family uint16 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [96]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint64 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPMreqn struct { + Multiaddr [4]byte /* in_addr */ + Address [4]byte /* in_addr */ + Ifindex int32 +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Pad_cgo_0 [4]byte + Iov *Iovec + Iovlen uint64 + Control *byte + Controllen uint64 + Flags int32 + Pad_cgo_1 [4]byte +} + +type Cmsghdr struct { + Len uint64 + Level int32 + Type int32 +} + +type Inet4Pktinfo struct { + Ifindex int32 + Spec_dst [4]byte /* in_addr */ + Addr [4]byte /* in_addr */ +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Data [8]uint32 +} + +type Ucred struct { + Pid int32 + Uid uint32 + Gid uint32 +} + +type TCPInfo struct { + State uint8 + Ca_state uint8 + Retransmits uint8 + Probes uint8 + Backoff uint8 + Options uint8 + Pad_cgo_0 [2]byte + Rto uint32 + Ato uint32 + Snd_mss uint32 + Rcv_mss uint32 + Unacked uint32 + Sacked uint32 + Lost uint32 + Retrans uint32 + Fackets uint32 + Last_data_sent uint32 + Last_ack_sent uint32 + Last_data_recv uint32 + Last_ack_recv uint32 + Pmtu uint32 + Rcv_ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Snd_ssthresh uint32 + Snd_cwnd uint32 + Advmss uint32 + Reordering uint32 + Rcv_rtt uint32 + Rcv_space uint32 + Total_retrans uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x70 + SizeofSockaddrUnix = 0x6e + SizeofSockaddrLinklayer = 0x14 + SizeofSockaddrNetlink = 0xc + SizeofSockaddrHCI = 0x6 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPMreqn = 0xc + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x38 + SizeofCmsghdr = 0x10 + SizeofInet4Pktinfo = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 + SizeofUcred = 0xc + SizeofTCPInfo = 0x68 +) + +const ( + IFA_UNSPEC = 0x0 + IFA_ADDRESS = 0x1 + IFA_LOCAL = 0x2 + IFA_LABEL = 0x3 + IFA_BROADCAST = 0x4 + IFA_ANYCAST = 0x5 + IFA_CACHEINFO = 0x6 + IFA_MULTICAST = 0x7 + IFLA_UNSPEC = 0x0 + IFLA_ADDRESS = 0x1 + IFLA_BROADCAST = 0x2 + IFLA_IFNAME = 0x3 + IFLA_MTU = 0x4 + IFLA_LINK = 0x5 + IFLA_QDISC = 0x6 + IFLA_STATS = 0x7 + IFLA_COST = 0x8 + IFLA_PRIORITY = 0x9 + IFLA_MASTER = 0xa + IFLA_WIRELESS = 0xb + IFLA_PROTINFO = 0xc + IFLA_TXQLEN = 0xd + IFLA_MAP = 0xe + IFLA_WEIGHT = 0xf + IFLA_OPERSTATE = 0x10 + IFLA_LINKMODE = 0x11 + IFLA_LINKINFO = 0x12 + IFLA_NET_NS_PID = 0x13 + IFLA_IFALIAS = 0x14 + IFLA_MAX = 0x27 + RT_SCOPE_UNIVERSE = 0x0 + RT_SCOPE_SITE = 0xc8 + RT_SCOPE_LINK = 0xfd + RT_SCOPE_HOST = 0xfe + RT_SCOPE_NOWHERE = 0xff + RT_TABLE_UNSPEC = 0x0 + RT_TABLE_COMPAT = 0xfc + RT_TABLE_DEFAULT = 0xfd + RT_TABLE_MAIN = 0xfe + RT_TABLE_LOCAL = 0xff + RT_TABLE_MAX = 0xffffffff + RTA_UNSPEC = 0x0 + RTA_DST = 0x1 + RTA_SRC = 0x2 + RTA_IIF = 0x3 + RTA_OIF = 0x4 + RTA_GATEWAY = 0x5 + RTA_PRIORITY = 0x6 + RTA_PREFSRC = 0x7 + RTA_METRICS = 0x8 + RTA_MULTIPATH = 0x9 + RTA_FLOW = 0xb + RTA_CACHEINFO = 0xc + RTA_TABLE = 0xf + RTN_UNSPEC = 0x0 + RTN_UNICAST = 0x1 + RTN_LOCAL = 0x2 + RTN_BROADCAST = 0x3 + RTN_ANYCAST = 0x4 + RTN_MULTICAST = 0x5 + RTN_BLACKHOLE = 0x6 + RTN_UNREACHABLE = 0x7 + RTN_PROHIBIT = 0x8 + RTN_THROW = 0x9 + RTN_NAT = 0xa + RTN_XRESOLVE = 0xb + RTNLGRP_NONE = 0x0 + RTNLGRP_LINK = 0x1 + RTNLGRP_NOTIFY = 0x2 + RTNLGRP_NEIGH = 0x3 + RTNLGRP_TC = 0x4 + RTNLGRP_IPV4_IFADDR = 0x5 + RTNLGRP_IPV4_MROUTE = 0x6 + RTNLGRP_IPV4_ROUTE = 0x7 + RTNLGRP_IPV4_RULE = 0x8 + RTNLGRP_IPV6_IFADDR = 0x9 + RTNLGRP_IPV6_MROUTE = 0xa + RTNLGRP_IPV6_ROUTE = 0xb + RTNLGRP_IPV6_IFINFO = 0xc + RTNLGRP_IPV6_PREFIX = 0x12 + RTNLGRP_IPV6_RULE = 0x13 + RTNLGRP_ND_USEROPT = 0x14 + SizeofNlMsghdr = 0x10 + SizeofNlMsgerr = 0x14 + SizeofRtGenmsg = 0x1 + SizeofNlAttr = 0x4 + SizeofRtAttr = 0x4 + SizeofIfInfomsg = 0x10 + SizeofIfAddrmsg = 0x8 + SizeofRtMsg = 0xc + SizeofRtNexthop = 0x8 +) + +type NlMsghdr struct { + Len uint32 + Type uint16 + Flags uint16 + Seq uint32 + Pid uint32 +} + +type NlMsgerr struct { + Error int32 + Msg NlMsghdr +} + +type RtGenmsg struct { + Family uint8 +} + +type NlAttr struct { + Len uint16 + Type uint16 +} + +type RtAttr struct { + Len uint16 + Type uint16 +} + +type IfInfomsg struct { + Family uint8 + X__ifi_pad uint8 + Type uint16 + Index int32 + Flags uint32 + Change uint32 +} + +type IfAddrmsg struct { + Family uint8 + Prefixlen uint8 + Flags uint8 + Scope uint8 + Index uint32 +} + +type RtMsg struct { + Family uint8 + Dst_len uint8 + Src_len uint8 + Tos uint8 + Table uint8 + Protocol uint8 + Scope uint8 + Type uint8 + Flags uint32 +} + +type RtNexthop struct { + Len uint16 + Flags uint8 + Hops uint8 + Ifindex int32 +} + +const ( + SizeofSockFilter = 0x8 + SizeofSockFprog = 0x10 +) + +type SockFilter struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type SockFprog struct { + Len uint16 + Pad_cgo_0 [6]byte + Filter *SockFilter +} + +type InotifyEvent struct { + Wd int32 + Mask uint32 + Cookie uint32 + Len uint32 +} + +const SizeofInotifyEvent = 0x10 + +type PtraceRegs struct { + Regs [102]uint64 + U_tsize uint64 + U_dsize uint64 + U_ssize uint64 + Start_code uint64 + Start_data uint64 + Start_stack uint64 + Signal int64 + U_ar0 uint64 + Magic uint64 + U_comm [32]int8 +} + +type FdSet struct { + Bits [16]int64 +} + +type Sysinfo_t struct { + Uptime int64 + Loads [3]uint64 + Totalram uint64 + Freeram uint64 + Sharedram uint64 + Bufferram uint64 + Totalswap uint64 + Freeswap uint64 + Procs uint16 + Pad uint16 + Pad_cgo_0 [4]byte + Totalhigh uint64 + Freehigh uint64 + Unit uint32 + X_f [0]int8 + Pad_cgo_1 [4]byte +} + +type Utsname struct { + Sysname [65]int8 + Nodename [65]int8 + Release [65]int8 + Version [65]int8 + Machine [65]int8 + Domainname [65]int8 +} + +type Ustat_t struct { + Tfree int32 + Pad_cgo_0 [4]byte + Tinode uint64 + Fname [6]int8 + Fpack [6]int8 + Pad_cgo_1 [4]byte +} + +type EpollEvent struct { + Events uint32 + Fd int32 + Pad int32 +} + +const ( + AT_FDCWD = -0x64 + AT_REMOVEDIR = 0x200 + AT_SYMLINK_FOLLOW = 0x400 + AT_SYMLINK_NOFOLLOW = 0x100 +) + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Line uint8 + Cc [32]uint8 + Pad_cgo_0 [3]byte +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_ppc64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_ppc64.go new file mode 100644 index 0000000000..d1105402ec --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_ppc64.go @@ -0,0 +1,614 @@ +// +build ppc64,linux +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_linux.go + +package unix + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 + PathMax = 0x1000 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int64 +} + +type Timex struct { + Modes uint32 + Pad_cgo_0 [4]byte + Offset int64 + Freq int64 + Maxerror int64 + Esterror int64 + Status int32 + Pad_cgo_1 [4]byte + Constant int64 + Precision int64 + Tolerance int64 + Time Timeval + Tick int64 + Ppsfreq int64 + Jitter int64 + Shift int32 + Pad_cgo_2 [4]byte + Stabil int64 + Jitcnt int64 + Calcnt int64 + Errcnt int64 + Stbcnt int64 + Tai int32 + Pad_cgo_3 [44]byte +} + +type Time_t int64 + +type Tms struct { + Utime int64 + Stime int64 + Cutime int64 + Cstime int64 +} + +type Utimbuf struct { + Actime int64 + Modtime int64 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +type Stat_t struct { + Dev uint64 + Ino uint64 + Nlink uint64 + Mode uint32 + Uid uint32 + Gid uint32 + X__pad2 int32 + Rdev uint64 + Size int64 + Blksize int64 + Blocks int64 + Atim Timespec + Mtim Timespec + Ctim Timespec + X__glibc_reserved4 uint64 + X__glibc_reserved5 uint64 + X__glibc_reserved6 uint64 +} + +type Statfs_t struct { + Type int64 + Bsize int64 + Blocks uint64 + Bfree uint64 + Bavail uint64 + Files uint64 + Ffree uint64 + Fsid Fsid + Namelen int64 + Frsize int64 + Flags int64 + Spare [4]int64 +} + +type Dirent struct { + Ino uint64 + Off int64 + Reclen uint16 + Type uint8 + Name [256]uint8 + Pad_cgo_0 [5]byte +} + +type Fsid struct { + X__val [2]int32 +} + +type Flock_t struct { + Type int16 + Whence int16 + Pad_cgo_0 [4]byte + Start int64 + Len int64 + Pid int32 + Pad_cgo_1 [4]byte +} + +const ( + FADV_NORMAL = 0x0 + FADV_RANDOM = 0x1 + FADV_SEQUENTIAL = 0x2 + FADV_WILLNEED = 0x3 + FADV_DONTNEED = 0x4 + FADV_NOREUSE = 0x5 +) + +type RawSockaddrInet4 struct { + Family uint16 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]uint8 +} + +type RawSockaddrInet6 struct { + Family uint16 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Family uint16 + Path [108]int8 +} + +type RawSockaddrLinklayer struct { + Family uint16 + Protocol uint16 + Ifindex int32 + Hatype uint16 + Pkttype uint8 + Halen uint8 + Addr [8]uint8 +} + +type RawSockaddrNetlink struct { + Family uint16 + Pad uint16 + Pid uint32 + Groups uint32 +} + +type RawSockaddrHCI struct { + Family uint16 + Dev uint16 + Channel uint16 +} + +type RawSockaddr struct { + Family uint16 + Data [14]uint8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [96]uint8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint64 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPMreqn struct { + Multiaddr [4]byte /* in_addr */ + Address [4]byte /* in_addr */ + Ifindex int32 +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Pad_cgo_0 [4]byte + Iov *Iovec + Iovlen uint64 + Control *byte + Controllen uint64 + Flags int32 + Pad_cgo_1 [4]byte +} + +type Cmsghdr struct { + Len uint64 + Level int32 + Type int32 + X__cmsg_data [0]uint8 +} + +type Inet4Pktinfo struct { + Ifindex int32 + Spec_dst [4]byte /* in_addr */ + Addr [4]byte /* in_addr */ +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Data [8]uint32 +} + +type Ucred struct { + Pid int32 + Uid uint32 + Gid uint32 +} + +type TCPInfo struct { + State uint8 + Ca_state uint8 + Retransmits uint8 + Probes uint8 + Backoff uint8 + Options uint8 + Pad_cgo_0 [2]byte + Rto uint32 + Ato uint32 + Snd_mss uint32 + Rcv_mss uint32 + Unacked uint32 + Sacked uint32 + Lost uint32 + Retrans uint32 + Fackets uint32 + Last_data_sent uint32 + Last_ack_sent uint32 + Last_data_recv uint32 + Last_ack_recv uint32 + Pmtu uint32 + Rcv_ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Snd_ssthresh uint32 + Snd_cwnd uint32 + Advmss uint32 + Reordering uint32 + Rcv_rtt uint32 + Rcv_space uint32 + Total_retrans uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x70 + SizeofSockaddrUnix = 0x6e + SizeofSockaddrLinklayer = 0x14 + SizeofSockaddrNetlink = 0xc + SizeofSockaddrHCI = 0x6 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPMreqn = 0xc + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x38 + SizeofCmsghdr = 0x10 + SizeofInet4Pktinfo = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 + SizeofUcred = 0xc + SizeofTCPInfo = 0x68 +) + +const ( + IFA_UNSPEC = 0x0 + IFA_ADDRESS = 0x1 + IFA_LOCAL = 0x2 + IFA_LABEL = 0x3 + IFA_BROADCAST = 0x4 + IFA_ANYCAST = 0x5 + IFA_CACHEINFO = 0x6 + IFA_MULTICAST = 0x7 + IFLA_UNSPEC = 0x0 + IFLA_ADDRESS = 0x1 + IFLA_BROADCAST = 0x2 + IFLA_IFNAME = 0x3 + IFLA_MTU = 0x4 + IFLA_LINK = 0x5 + IFLA_QDISC = 0x6 + IFLA_STATS = 0x7 + IFLA_COST = 0x8 + IFLA_PRIORITY = 0x9 + IFLA_MASTER = 0xa + IFLA_WIRELESS = 0xb + IFLA_PROTINFO = 0xc + IFLA_TXQLEN = 0xd + IFLA_MAP = 0xe + IFLA_WEIGHT = 0xf + IFLA_OPERSTATE = 0x10 + IFLA_LINKMODE = 0x11 + IFLA_LINKINFO = 0x12 + IFLA_NET_NS_PID = 0x13 + IFLA_IFALIAS = 0x14 + IFLA_MAX = 0x23 + RT_SCOPE_UNIVERSE = 0x0 + RT_SCOPE_SITE = 0xc8 + RT_SCOPE_LINK = 0xfd + RT_SCOPE_HOST = 0xfe + RT_SCOPE_NOWHERE = 0xff + RT_TABLE_UNSPEC = 0x0 + RT_TABLE_COMPAT = 0xfc + RT_TABLE_DEFAULT = 0xfd + RT_TABLE_MAIN = 0xfe + RT_TABLE_LOCAL = 0xff + RT_TABLE_MAX = 0xffffffff + RTA_UNSPEC = 0x0 + RTA_DST = 0x1 + RTA_SRC = 0x2 + RTA_IIF = 0x3 + RTA_OIF = 0x4 + RTA_GATEWAY = 0x5 + RTA_PRIORITY = 0x6 + RTA_PREFSRC = 0x7 + RTA_METRICS = 0x8 + RTA_MULTIPATH = 0x9 + RTA_FLOW = 0xb + RTA_CACHEINFO = 0xc + RTA_TABLE = 0xf + RTN_UNSPEC = 0x0 + RTN_UNICAST = 0x1 + RTN_LOCAL = 0x2 + RTN_BROADCAST = 0x3 + RTN_ANYCAST = 0x4 + RTN_MULTICAST = 0x5 + RTN_BLACKHOLE = 0x6 + RTN_UNREACHABLE = 0x7 + RTN_PROHIBIT = 0x8 + RTN_THROW = 0x9 + RTN_NAT = 0xa + RTN_XRESOLVE = 0xb + RTNLGRP_NONE = 0x0 + RTNLGRP_LINK = 0x1 + RTNLGRP_NOTIFY = 0x2 + RTNLGRP_NEIGH = 0x3 + RTNLGRP_TC = 0x4 + RTNLGRP_IPV4_IFADDR = 0x5 + RTNLGRP_IPV4_MROUTE = 0x6 + RTNLGRP_IPV4_ROUTE = 0x7 + RTNLGRP_IPV4_RULE = 0x8 + RTNLGRP_IPV6_IFADDR = 0x9 + RTNLGRP_IPV6_MROUTE = 0xa + RTNLGRP_IPV6_ROUTE = 0xb + RTNLGRP_IPV6_IFINFO = 0xc + RTNLGRP_IPV6_PREFIX = 0x12 + RTNLGRP_IPV6_RULE = 0x13 + RTNLGRP_ND_USEROPT = 0x14 + SizeofNlMsghdr = 0x10 + SizeofNlMsgerr = 0x14 + SizeofRtGenmsg = 0x1 + SizeofNlAttr = 0x4 + SizeofRtAttr = 0x4 + SizeofIfInfomsg = 0x10 + SizeofIfAddrmsg = 0x8 + SizeofRtMsg = 0xc + SizeofRtNexthop = 0x8 +) + +type NlMsghdr struct { + Len uint32 + Type uint16 + Flags uint16 + Seq uint32 + Pid uint32 +} + +type NlMsgerr struct { + Error int32 + Msg NlMsghdr +} + +type RtGenmsg struct { + Family uint8 +} + +type NlAttr struct { + Len uint16 + Type uint16 +} + +type RtAttr struct { + Len uint16 + Type uint16 +} + +type IfInfomsg struct { + Family uint8 + X__ifi_pad uint8 + Type uint16 + Index int32 + Flags uint32 + Change uint32 +} + +type IfAddrmsg struct { + Family uint8 + Prefixlen uint8 + Flags uint8 + Scope uint8 + Index uint32 +} + +type RtMsg struct { + Family uint8 + Dst_len uint8 + Src_len uint8 + Tos uint8 + Table uint8 + Protocol uint8 + Scope uint8 + Type uint8 + Flags uint32 +} + +type RtNexthop struct { + Len uint16 + Flags uint8 + Hops uint8 + Ifindex int32 +} + +const ( + SizeofSockFilter = 0x8 + SizeofSockFprog = 0x10 +) + +type SockFilter struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type SockFprog struct { + Len uint16 + Pad_cgo_0 [6]byte + Filter *SockFilter +} + +type InotifyEvent struct { + Wd int32 + Mask uint32 + Cookie uint32 + Len uint32 + Name [0]uint8 +} + +const SizeofInotifyEvent = 0x10 + +type PtraceRegs struct { + Gpr [32]uint64 + Nip uint64 + Msr uint64 + Orig_gpr3 uint64 + Ctr uint64 + Link uint64 + Xer uint64 + Ccr uint64 + Softe uint64 + Trap uint64 + Dar uint64 + Dsisr uint64 + Result uint64 +} + +type FdSet struct { + Bits [16]int64 +} + +type Sysinfo_t struct { + Uptime int64 + Loads [3]uint64 + Totalram uint64 + Freeram uint64 + Sharedram uint64 + Bufferram uint64 + Totalswap uint64 + Freeswap uint64 + Procs uint16 + Pad uint16 + Pad_cgo_0 [4]byte + Totalhigh uint64 + Freehigh uint64 + Unit uint32 + X_f [0]uint8 + Pad_cgo_1 [4]byte +} + +type Utsname struct { + Sysname [65]uint8 + Nodename [65]uint8 + Release [65]uint8 + Version [65]uint8 + Machine [65]uint8 + Domainname [65]uint8 +} + +type Ustat_t struct { + Tfree int32 + Pad_cgo_0 [4]byte + Tinode uint64 + Fname [6]uint8 + Fpack [6]uint8 + Pad_cgo_1 [4]byte +} + +type EpollEvent struct { + Events uint32 + X_padFd int32 + Fd int32 + Pad int32 +} + +const ( + AT_FDCWD = -0x64 + AT_REMOVEDIR = 0x200 + AT_SYMLINK_FOLLOW = 0x400 + AT_SYMLINK_NOFOLLOW = 0x100 +) + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Cc [19]uint8 + Line uint8 + Ispeed uint32 + Ospeed uint32 +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_ppc64le.go b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_ppc64le.go new file mode 100644 index 0000000000..8e25c9fffc --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_ppc64le.go @@ -0,0 +1,614 @@ +// +build ppc64le,linux +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_linux.go + +package unix + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 + PathMax = 0x1000 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int64 +} + +type Timex struct { + Modes uint32 + Pad_cgo_0 [4]byte + Offset int64 + Freq int64 + Maxerror int64 + Esterror int64 + Status int32 + Pad_cgo_1 [4]byte + Constant int64 + Precision int64 + Tolerance int64 + Time Timeval + Tick int64 + Ppsfreq int64 + Jitter int64 + Shift int32 + Pad_cgo_2 [4]byte + Stabil int64 + Jitcnt int64 + Calcnt int64 + Errcnt int64 + Stbcnt int64 + Tai int32 + Pad_cgo_3 [44]byte +} + +type Time_t int64 + +type Tms struct { + Utime int64 + Stime int64 + Cutime int64 + Cstime int64 +} + +type Utimbuf struct { + Actime int64 + Modtime int64 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +type Stat_t struct { + Dev uint64 + Ino uint64 + Nlink uint64 + Mode uint32 + Uid uint32 + Gid uint32 + X__pad2 int32 + Rdev uint64 + Size int64 + Blksize int64 + Blocks int64 + Atim Timespec + Mtim Timespec + Ctim Timespec + X__glibc_reserved4 uint64 + X__glibc_reserved5 uint64 + X__glibc_reserved6 uint64 +} + +type Statfs_t struct { + Type int64 + Bsize int64 + Blocks uint64 + Bfree uint64 + Bavail uint64 + Files uint64 + Ffree uint64 + Fsid Fsid + Namelen int64 + Frsize int64 + Flags int64 + Spare [4]int64 +} + +type Dirent struct { + Ino uint64 + Off int64 + Reclen uint16 + Type uint8 + Name [256]uint8 + Pad_cgo_0 [5]byte +} + +type Fsid struct { + X__val [2]int32 +} + +type Flock_t struct { + Type int16 + Whence int16 + Pad_cgo_0 [4]byte + Start int64 + Len int64 + Pid int32 + Pad_cgo_1 [4]byte +} + +const ( + FADV_NORMAL = 0x0 + FADV_RANDOM = 0x1 + FADV_SEQUENTIAL = 0x2 + FADV_WILLNEED = 0x3 + FADV_DONTNEED = 0x4 + FADV_NOREUSE = 0x5 +) + +type RawSockaddrInet4 struct { + Family uint16 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]uint8 +} + +type RawSockaddrInet6 struct { + Family uint16 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Family uint16 + Path [108]int8 +} + +type RawSockaddrLinklayer struct { + Family uint16 + Protocol uint16 + Ifindex int32 + Hatype uint16 + Pkttype uint8 + Halen uint8 + Addr [8]uint8 +} + +type RawSockaddrNetlink struct { + Family uint16 + Pad uint16 + Pid uint32 + Groups uint32 +} + +type RawSockaddrHCI struct { + Family uint16 + Dev uint16 + Channel uint16 +} + +type RawSockaddr struct { + Family uint16 + Data [14]uint8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [96]uint8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint64 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPMreqn struct { + Multiaddr [4]byte /* in_addr */ + Address [4]byte /* in_addr */ + Ifindex int32 +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Pad_cgo_0 [4]byte + Iov *Iovec + Iovlen uint64 + Control *byte + Controllen uint64 + Flags int32 + Pad_cgo_1 [4]byte +} + +type Cmsghdr struct { + Len uint64 + Level int32 + Type int32 + X__cmsg_data [0]uint8 +} + +type Inet4Pktinfo struct { + Ifindex int32 + Spec_dst [4]byte /* in_addr */ + Addr [4]byte /* in_addr */ +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Data [8]uint32 +} + +type Ucred struct { + Pid int32 + Uid uint32 + Gid uint32 +} + +type TCPInfo struct { + State uint8 + Ca_state uint8 + Retransmits uint8 + Probes uint8 + Backoff uint8 + Options uint8 + Pad_cgo_0 [2]byte + Rto uint32 + Ato uint32 + Snd_mss uint32 + Rcv_mss uint32 + Unacked uint32 + Sacked uint32 + Lost uint32 + Retrans uint32 + Fackets uint32 + Last_data_sent uint32 + Last_ack_sent uint32 + Last_data_recv uint32 + Last_ack_recv uint32 + Pmtu uint32 + Rcv_ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Snd_ssthresh uint32 + Snd_cwnd uint32 + Advmss uint32 + Reordering uint32 + Rcv_rtt uint32 + Rcv_space uint32 + Total_retrans uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x70 + SizeofSockaddrUnix = 0x6e + SizeofSockaddrLinklayer = 0x14 + SizeofSockaddrNetlink = 0xc + SizeofSockaddrHCI = 0x6 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPMreqn = 0xc + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x38 + SizeofCmsghdr = 0x10 + SizeofInet4Pktinfo = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 + SizeofUcred = 0xc + SizeofTCPInfo = 0x68 +) + +const ( + IFA_UNSPEC = 0x0 + IFA_ADDRESS = 0x1 + IFA_LOCAL = 0x2 + IFA_LABEL = 0x3 + IFA_BROADCAST = 0x4 + IFA_ANYCAST = 0x5 + IFA_CACHEINFO = 0x6 + IFA_MULTICAST = 0x7 + IFLA_UNSPEC = 0x0 + IFLA_ADDRESS = 0x1 + IFLA_BROADCAST = 0x2 + IFLA_IFNAME = 0x3 + IFLA_MTU = 0x4 + IFLA_LINK = 0x5 + IFLA_QDISC = 0x6 + IFLA_STATS = 0x7 + IFLA_COST = 0x8 + IFLA_PRIORITY = 0x9 + IFLA_MASTER = 0xa + IFLA_WIRELESS = 0xb + IFLA_PROTINFO = 0xc + IFLA_TXQLEN = 0xd + IFLA_MAP = 0xe + IFLA_WEIGHT = 0xf + IFLA_OPERSTATE = 0x10 + IFLA_LINKMODE = 0x11 + IFLA_LINKINFO = 0x12 + IFLA_NET_NS_PID = 0x13 + IFLA_IFALIAS = 0x14 + IFLA_MAX = 0x22 + RT_SCOPE_UNIVERSE = 0x0 + RT_SCOPE_SITE = 0xc8 + RT_SCOPE_LINK = 0xfd + RT_SCOPE_HOST = 0xfe + RT_SCOPE_NOWHERE = 0xff + RT_TABLE_UNSPEC = 0x0 + RT_TABLE_COMPAT = 0xfc + RT_TABLE_DEFAULT = 0xfd + RT_TABLE_MAIN = 0xfe + RT_TABLE_LOCAL = 0xff + RT_TABLE_MAX = 0xffffffff + RTA_UNSPEC = 0x0 + RTA_DST = 0x1 + RTA_SRC = 0x2 + RTA_IIF = 0x3 + RTA_OIF = 0x4 + RTA_GATEWAY = 0x5 + RTA_PRIORITY = 0x6 + RTA_PREFSRC = 0x7 + RTA_METRICS = 0x8 + RTA_MULTIPATH = 0x9 + RTA_FLOW = 0xb + RTA_CACHEINFO = 0xc + RTA_TABLE = 0xf + RTN_UNSPEC = 0x0 + RTN_UNICAST = 0x1 + RTN_LOCAL = 0x2 + RTN_BROADCAST = 0x3 + RTN_ANYCAST = 0x4 + RTN_MULTICAST = 0x5 + RTN_BLACKHOLE = 0x6 + RTN_UNREACHABLE = 0x7 + RTN_PROHIBIT = 0x8 + RTN_THROW = 0x9 + RTN_NAT = 0xa + RTN_XRESOLVE = 0xb + RTNLGRP_NONE = 0x0 + RTNLGRP_LINK = 0x1 + RTNLGRP_NOTIFY = 0x2 + RTNLGRP_NEIGH = 0x3 + RTNLGRP_TC = 0x4 + RTNLGRP_IPV4_IFADDR = 0x5 + RTNLGRP_IPV4_MROUTE = 0x6 + RTNLGRP_IPV4_ROUTE = 0x7 + RTNLGRP_IPV4_RULE = 0x8 + RTNLGRP_IPV6_IFADDR = 0x9 + RTNLGRP_IPV6_MROUTE = 0xa + RTNLGRP_IPV6_ROUTE = 0xb + RTNLGRP_IPV6_IFINFO = 0xc + RTNLGRP_IPV6_PREFIX = 0x12 + RTNLGRP_IPV6_RULE = 0x13 + RTNLGRP_ND_USEROPT = 0x14 + SizeofNlMsghdr = 0x10 + SizeofNlMsgerr = 0x14 + SizeofRtGenmsg = 0x1 + SizeofNlAttr = 0x4 + SizeofRtAttr = 0x4 + SizeofIfInfomsg = 0x10 + SizeofIfAddrmsg = 0x8 + SizeofRtMsg = 0xc + SizeofRtNexthop = 0x8 +) + +type NlMsghdr struct { + Len uint32 + Type uint16 + Flags uint16 + Seq uint32 + Pid uint32 +} + +type NlMsgerr struct { + Error int32 + Msg NlMsghdr +} + +type RtGenmsg struct { + Family uint8 +} + +type NlAttr struct { + Len uint16 + Type uint16 +} + +type RtAttr struct { + Len uint16 + Type uint16 +} + +type IfInfomsg struct { + Family uint8 + X__ifi_pad uint8 + Type uint16 + Index int32 + Flags uint32 + Change uint32 +} + +type IfAddrmsg struct { + Family uint8 + Prefixlen uint8 + Flags uint8 + Scope uint8 + Index uint32 +} + +type RtMsg struct { + Family uint8 + Dst_len uint8 + Src_len uint8 + Tos uint8 + Table uint8 + Protocol uint8 + Scope uint8 + Type uint8 + Flags uint32 +} + +type RtNexthop struct { + Len uint16 + Flags uint8 + Hops uint8 + Ifindex int32 +} + +const ( + SizeofSockFilter = 0x8 + SizeofSockFprog = 0x10 +) + +type SockFilter struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type SockFprog struct { + Len uint16 + Pad_cgo_0 [6]byte + Filter *SockFilter +} + +type InotifyEvent struct { + Wd int32 + Mask uint32 + Cookie uint32 + Len uint32 + Name [0]uint8 +} + +const SizeofInotifyEvent = 0x10 + +type PtraceRegs struct { + Gpr [32]uint64 + Nip uint64 + Msr uint64 + Orig_gpr3 uint64 + Ctr uint64 + Link uint64 + Xer uint64 + Ccr uint64 + Softe uint64 + Trap uint64 + Dar uint64 + Dsisr uint64 + Result uint64 +} + +type FdSet struct { + Bits [16]int64 +} + +type Sysinfo_t struct { + Uptime int64 + Loads [3]uint64 + Totalram uint64 + Freeram uint64 + Sharedram uint64 + Bufferram uint64 + Totalswap uint64 + Freeswap uint64 + Procs uint16 + Pad uint16 + Pad_cgo_0 [4]byte + Totalhigh uint64 + Freehigh uint64 + Unit uint32 + X_f [0]uint8 + Pad_cgo_1 [4]byte +} + +type Utsname struct { + Sysname [65]uint8 + Nodename [65]uint8 + Release [65]uint8 + Version [65]uint8 + Machine [65]uint8 + Domainname [65]uint8 +} + +type Ustat_t struct { + Tfree int32 + Pad_cgo_0 [4]byte + Tinode uint64 + Fname [6]uint8 + Fpack [6]uint8 + Pad_cgo_1 [4]byte +} + +type EpollEvent struct { + Events uint32 + X_padFd int32 + Fd int32 + Pad int32 +} + +const ( + AT_FDCWD = -0x64 + AT_REMOVEDIR = 0x200 + AT_SYMLINK_FOLLOW = 0x400 + AT_SYMLINK_NOFOLLOW = 0x100 +) + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Cc [19]uint8 + Line uint8 + Ispeed uint32 + Ospeed uint32 +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_s390x.go b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_s390x.go new file mode 100644 index 0000000000..268e373624 --- /dev/null +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_s390x.go @@ -0,0 +1,629 @@ +// +build s390x,linux +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -fsigned-char types_linux.go + +package unix + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 + PathMax = 0x1000 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int64 +} + +type Timex struct { + Modes uint32 + _ [4]byte + Offset int64 + Freq int64 + Maxerror int64 + Esterror int64 + Status int32 + _ [4]byte + Constant int64 + Precision int64 + Tolerance int64 + Time Timeval + Tick int64 + Ppsfreq int64 + Jitter int64 + Shift int32 + _ [4]byte + Stabil int64 + Jitcnt int64 + Calcnt int64 + Errcnt int64 + Stbcnt int64 + Tai int32 + _ [44]byte +} + +type Time_t int64 + +type Tms struct { + Utime int64 + Stime int64 + Cutime int64 + Cstime int64 +} + +type Utimbuf struct { + Actime int64 + Modtime int64 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +type Stat_t struct { + Dev uint64 + Ino uint64 + Nlink uint64 + Mode uint32 + Uid uint32 + Gid uint32 + _ int32 + Rdev uint64 + Size int64 + Atim Timespec + Mtim Timespec + Ctim Timespec + Blksize int64 + Blocks int64 + _ [3]int64 +} + +type Statfs_t struct { + Type uint32 + Bsize uint32 + Blocks uint64 + Bfree uint64 + Bavail uint64 + Files uint64 + Ffree uint64 + Fsid Fsid + Namelen uint32 + Frsize uint32 + Flags uint32 + Spare [4]uint32 + _ [4]byte +} + +type Dirent struct { + Ino uint64 + Off int64 + Reclen uint16 + Type uint8 + Name [256]int8 + _ [5]byte +} + +type Fsid struct { + _ [2]int32 +} + +type Flock_t struct { + Type int16 + Whence int16 + _ [4]byte + Start int64 + Len int64 + Pid int32 + _ [4]byte +} + +const ( + FADV_NORMAL = 0x0 + FADV_RANDOM = 0x1 + FADV_SEQUENTIAL = 0x2 + FADV_WILLNEED = 0x3 + FADV_DONTNEED = 0x6 + FADV_NOREUSE = 0x7 +) + +type RawSockaddrInet4 struct { + Family uint16 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]uint8 +} + +type RawSockaddrInet6 struct { + Family uint16 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Family uint16 + Path [108]int8 +} + +type RawSockaddrLinklayer struct { + Family uint16 + Protocol uint16 + Ifindex int32 + Hatype uint16 + Pkttype uint8 + Halen uint8 + Addr [8]uint8 +} + +type RawSockaddrNetlink struct { + Family uint16 + Pad uint16 + Pid uint32 + Groups uint32 +} + +type RawSockaddrHCI struct { + Family uint16 + Dev uint16 + Channel uint16 +} + +type RawSockaddr struct { + Family uint16 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [96]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint64 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPMreqn struct { + Multiaddr [4]byte /* in_addr */ + Address [4]byte /* in_addr */ + Ifindex int32 +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + _ [4]byte + Iov *Iovec + Iovlen uint64 + Control *byte + Controllen uint64 + Flags int32 + _ [4]byte +} + +type Cmsghdr struct { + Len uint64 + Level int32 + Type int32 +} + +type Inet4Pktinfo struct { + Ifindex int32 + Spec_dst [4]byte /* in_addr */ + Addr [4]byte /* in_addr */ +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Data [8]uint32 +} + +type Ucred struct { + Pid int32 + Uid uint32 + Gid uint32 +} + +type TCPInfo struct { + State uint8 + Ca_state uint8 + Retransmits uint8 + Probes uint8 + Backoff uint8 + Options uint8 + _ [2]byte + Rto uint32 + Ato uint32 + Snd_mss uint32 + Rcv_mss uint32 + Unacked uint32 + Sacked uint32 + Lost uint32 + Retrans uint32 + Fackets uint32 + Last_data_sent uint32 + Last_ack_sent uint32 + Last_data_recv uint32 + Last_ack_recv uint32 + Pmtu uint32 + Rcv_ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Snd_ssthresh uint32 + Snd_cwnd uint32 + Advmss uint32 + Reordering uint32 + Rcv_rtt uint32 + Rcv_space uint32 + Total_retrans uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x70 + SizeofSockaddrUnix = 0x6e + SizeofSockaddrLinklayer = 0x14 + SizeofSockaddrNetlink = 0xc + SizeofSockaddrHCI = 0x6 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPMreqn = 0xc + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x38 + SizeofCmsghdr = 0x10 + SizeofInet4Pktinfo = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 + SizeofUcred = 0xc + SizeofTCPInfo = 0x68 +) + +const ( + IFA_UNSPEC = 0x0 + IFA_ADDRESS = 0x1 + IFA_LOCAL = 0x2 + IFA_LABEL = 0x3 + IFA_BROADCAST = 0x4 + IFA_ANYCAST = 0x5 + IFA_CACHEINFO = 0x6 + IFA_MULTICAST = 0x7 + IFLA_UNSPEC = 0x0 + IFLA_ADDRESS = 0x1 + IFLA_BROADCAST = 0x2 + IFLA_IFNAME = 0x3 + IFLA_MTU = 0x4 + IFLA_LINK = 0x5 + IFLA_QDISC = 0x6 + IFLA_STATS = 0x7 + IFLA_COST = 0x8 + IFLA_PRIORITY = 0x9 + IFLA_MASTER = 0xa + IFLA_WIRELESS = 0xb + IFLA_PROTINFO = 0xc + IFLA_TXQLEN = 0xd + IFLA_MAP = 0xe + IFLA_WEIGHT = 0xf + IFLA_OPERSTATE = 0x10 + IFLA_LINKMODE = 0x11 + IFLA_LINKINFO = 0x12 + IFLA_NET_NS_PID = 0x13 + IFLA_IFALIAS = 0x14 + IFLA_MAX = 0x27 + RT_SCOPE_UNIVERSE = 0x0 + RT_SCOPE_SITE = 0xc8 + RT_SCOPE_LINK = 0xfd + RT_SCOPE_HOST = 0xfe + RT_SCOPE_NOWHERE = 0xff + RT_TABLE_UNSPEC = 0x0 + RT_TABLE_COMPAT = 0xfc + RT_TABLE_DEFAULT = 0xfd + RT_TABLE_MAIN = 0xfe + RT_TABLE_LOCAL = 0xff + RT_TABLE_MAX = 0xffffffff + RTA_UNSPEC = 0x0 + RTA_DST = 0x1 + RTA_SRC = 0x2 + RTA_IIF = 0x3 + RTA_OIF = 0x4 + RTA_GATEWAY = 0x5 + RTA_PRIORITY = 0x6 + RTA_PREFSRC = 0x7 + RTA_METRICS = 0x8 + RTA_MULTIPATH = 0x9 + RTA_FLOW = 0xb + RTA_CACHEINFO = 0xc + RTA_TABLE = 0xf + RTN_UNSPEC = 0x0 + RTN_UNICAST = 0x1 + RTN_LOCAL = 0x2 + RTN_BROADCAST = 0x3 + RTN_ANYCAST = 0x4 + RTN_MULTICAST = 0x5 + RTN_BLACKHOLE = 0x6 + RTN_UNREACHABLE = 0x7 + RTN_PROHIBIT = 0x8 + RTN_THROW = 0x9 + RTN_NAT = 0xa + RTN_XRESOLVE = 0xb + RTNLGRP_NONE = 0x0 + RTNLGRP_LINK = 0x1 + RTNLGRP_NOTIFY = 0x2 + RTNLGRP_NEIGH = 0x3 + RTNLGRP_TC = 0x4 + RTNLGRP_IPV4_IFADDR = 0x5 + RTNLGRP_IPV4_MROUTE = 0x6 + RTNLGRP_IPV4_ROUTE = 0x7 + RTNLGRP_IPV4_RULE = 0x8 + RTNLGRP_IPV6_IFADDR = 0x9 + RTNLGRP_IPV6_MROUTE = 0xa + RTNLGRP_IPV6_ROUTE = 0xb + RTNLGRP_IPV6_IFINFO = 0xc + RTNLGRP_IPV6_PREFIX = 0x12 + RTNLGRP_IPV6_RULE = 0x13 + RTNLGRP_ND_USEROPT = 0x14 + SizeofNlMsghdr = 0x10 + SizeofNlMsgerr = 0x14 + SizeofRtGenmsg = 0x1 + SizeofNlAttr = 0x4 + SizeofRtAttr = 0x4 + SizeofIfInfomsg = 0x10 + SizeofIfAddrmsg = 0x8 + SizeofRtMsg = 0xc + SizeofRtNexthop = 0x8 +) + +type NlMsghdr struct { + Len uint32 + Type uint16 + Flags uint16 + Seq uint32 + Pid uint32 +} + +type NlMsgerr struct { + Error int32 + Msg NlMsghdr +} + +type RtGenmsg struct { + Family uint8 +} + +type NlAttr struct { + Len uint16 + Type uint16 +} + +type RtAttr struct { + Len uint16 + Type uint16 +} + +type IfInfomsg struct { + Family uint8 + _ uint8 + Type uint16 + Index int32 + Flags uint32 + Change uint32 +} + +type IfAddrmsg struct { + Family uint8 + Prefixlen uint8 + Flags uint8 + Scope uint8 + Index uint32 +} + +type RtMsg struct { + Family uint8 + Dst_len uint8 + Src_len uint8 + Tos uint8 + Table uint8 + Protocol uint8 + Scope uint8 + Type uint8 + Flags uint32 +} + +type RtNexthop struct { + Len uint16 + Flags uint8 + Hops uint8 + Ifindex int32 +} + +const ( + SizeofSockFilter = 0x8 + SizeofSockFprog = 0x10 +) + +type SockFilter struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type SockFprog struct { + Len uint16 + _ [6]byte + Filter *SockFilter +} + +type InotifyEvent struct { + Wd int32 + Mask uint32 + Cookie uint32 + Len uint32 +} + +const SizeofInotifyEvent = 0x10 + +type PtraceRegs struct { + Psw PtracePsw + Gprs [16]uint64 + Acrs [16]uint32 + Orig_gpr2 uint64 + Fp_regs PtraceFpregs + Per_info PtracePer + Ieee_instruction_pointer uint64 +} + +type PtracePsw struct { + Mask uint64 + Addr uint64 +} + +type PtraceFpregs struct { + Fpc uint32 + _ [4]byte + Fprs [16]float64 +} + +type PtracePer struct { + _ [0]uint64 + _ [24]byte + _ [8]byte + Starting_addr uint64 + Ending_addr uint64 + Perc_atmid uint16 + _ [6]byte + Address uint64 + Access_id uint8 + _ [7]byte +} + +type FdSet struct { + Bits [16]int64 +} + +type Sysinfo_t struct { + Uptime int64 + Loads [3]uint64 + Totalram uint64 + Freeram uint64 + Sharedram uint64 + Bufferram uint64 + Totalswap uint64 + Freeswap uint64 + Procs uint16 + Pad uint16 + _ [4]byte + Totalhigh uint64 + Freehigh uint64 + Unit uint32 + _ [0]int8 + _ [4]byte +} + +type Utsname struct { + Sysname [65]int8 + Nodename [65]int8 + Release [65]int8 + Version [65]int8 + Machine [65]int8 + Domainname [65]int8 +} + +type Ustat_t struct { + Tfree int32 + _ [4]byte + Tinode uint64 + Fname [6]int8 + Fpack [6]int8 + _ [4]byte +} + +type EpollEvent struct { + Events uint32 + _ int32 + Fd int32 + Pad int32 +} + +const ( + AT_FDCWD = -0x64 + AT_REMOVEDIR = 0x200 + AT_SYMLINK_FOLLOW = 0x400 + AT_SYMLINK_NOFOLLOW = 0x100 +) + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Line uint8 + Cc [19]uint8 + Ispeed uint32 + Ospeed uint32 +} diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_netbsd_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_netbsd_386.go index 345bf23b35..caf755fb86 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_netbsd_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_netbsd_386.go @@ -1,6 +1,8 @@ // Created by cgo -godefs - DO NOT EDIT // cgo -godefs types_netbsd.go +// +build 386,netbsd + package unix const ( diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_netbsd_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_netbsd_amd64.go index 5559f022ab..91b4a5305a 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_netbsd_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_netbsd_amd64.go @@ -1,6 +1,8 @@ // Created by cgo -godefs - DO NOT EDIT // cgo -godefs types_netbsd.go +// +build amd64,netbsd + package unix const ( diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_netbsd_arm.go b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_netbsd_arm.go index 5618909c77..c0758f9d3f 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_netbsd_arm.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_netbsd_arm.go @@ -1,6 +1,8 @@ // Created by cgo -godefs - DO NOT EDIT // cgo -godefs types_netbsd.go +// +build arm,netbsd + package unix const ( diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_openbsd_386.go b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_openbsd_386.go index be07f6e547..860a469796 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_openbsd_386.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_openbsd_386.go @@ -1,6 +1,8 @@ // Created by cgo -godefs - DO NOT EDIT // cgo -godefs types_openbsd.go +// +build 386,openbsd + package unix const ( diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_openbsd_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_openbsd_amd64.go index d553c2f084..23c52727f7 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_openbsd_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_openbsd_amd64.go @@ -1,6 +1,8 @@ // Created by cgo -godefs - DO NOT EDIT // cgo -godefs types_openbsd.go +// +build amd64,openbsd + package unix const ( diff --git a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_solaris_amd64.go b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_solaris_amd64.go index 9d8d0e5f41..b3b928a51e 100644 --- a/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_solaris_amd64.go +++ b/Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_solaris_amd64.go @@ -1,3 +1,4 @@ +// +build amd64,solaris // Created by cgo -godefs - DO NOT EDIT // cgo -godefs types_solaris.go @@ -9,6 +10,7 @@ const ( sizeofInt = 0x4 sizeofLong = 0x8 sizeofLongLong = 0x8 + PathMax = 0x400 ) type ( @@ -33,6 +35,18 @@ type Timeval32 struct { Usec int32 } +type Tms struct { + Utime int64 + Stime int64 + Cutime int64 + Cstime int64 +} + +type Utimbuf struct { + Actime int64 + Modtime int64 +} + type Rusage struct { Utime Timeval Stime Timeval @@ -228,6 +242,30 @@ type FdSet struct { Bits [1024]int64 } +type Utsname struct { + Sysname [257]int8 + Nodename [257]int8 + Release [257]int8 + Version [257]int8 + Machine [257]int8 +} + +type Ustat_t struct { + Tfree int64 + Tinode uint64 + Fname [6]int8 + Fpack [6]int8 + Pad_cgo_0 [4]byte +} + +const ( + AT_FDCWD = 0xffd19553 + AT_SYMLINK_NOFOLLOW = 0x1000 + AT_SYMLINK_FOLLOW = 0x2000 + AT_REMOVEDIR = 0x1 + AT_EACCESS = 0x4 +) + const ( SizeofIfMsghdr = 0x54 SizeofIfData = 0x44 @@ -355,6 +393,8 @@ type BpfHdr struct { Pad_cgo_0 [2]byte } +const _SC_PAGESIZE = 0xb + type Termios struct { Iflag uint32 Oflag uint32 @@ -363,3 +403,20 @@ type Termios struct { Cc [19]uint8 Pad_cgo_0 [1]byte } + +type Termio struct { + Iflag uint16 + Oflag uint16 + Cflag uint16 + Lflag uint16 + Line int8 + Cc [8]uint8 + Pad_cgo_0 [1]byte +} + +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} From bf93209ef1bf89a0bc49faad86c3b41351b351d0 Mon Sep 17 00:00:00 2001 From: Ed Rooth Date: Fri, 10 Jun 2016 15:16:30 -0700 Subject: [PATCH 0395/1304] Documentation: fix broken CoreOS install doc link --- Documentation/distributions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/distributions.md b/Documentation/distributions.md index 9b4ecd788e..e9afb6ba7a 100644 --- a/Documentation/distributions.md +++ b/Documentation/distributions.md @@ -5,7 +5,7 @@ rkt is an integral part of CoreOS, installed with the operating system. The [CoreOS releases page](https://coreos.com/releases/) lists the version of rkt available in each CoreOS release channel. -If the version of rkt included in CoreOS is too old, it's fairly trivial to fetch the desired version [via a systemd unit](Documentation/install-rkt-in-coreos.md) +If the version of rkt included in CoreOS is too old, it's fairly trivial to fetch the desired version [via a systemd unit](install-rkt-in-coreos.md) ## Fedora From 596d97201efc31386c9d0dc6d1f36db7359403ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Mon, 13 Jun 2016 12:30:07 +0200 Subject: [PATCH 0396/1304] functional tests: sleep on every app when testing exit code Sometimes, the first app (hello0) didn't have time to print its message before the pod exits. Sleep on every app so all of them have time to print it. --- tests/rkt_exit_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/rkt_exit_test.go b/tests/rkt_exit_test.go index 1370005bbd..3a77adae24 100644 --- a/tests/rkt_exit_test.go +++ b/tests/rkt_exit_test.go @@ -46,15 +46,15 @@ func TestExitCodeSimple(t *testing.T) { // exit codes. func TestExitCodeWithSeveralApps(t *testing.T) { image0File := patchTestACI("rkt-inspect-exit-0.aci", "--name=hello0", - "--exec=/inspect --print-msg=HelloWorld --exit-code=0") + "--exec=/inspect --print-msg=HelloWorld --exit-code=0 --sleep=1") defer os.Remove(image0File) image1File := patchTestACI("rkt-inspect-exit-1.aci", "--name=hello1", - "--exec=/inspect --print-msg=HelloWorld --exit-code=5") + "--exec=/inspect --print-msg=HelloWorld --exit-code=5 --sleep=1") defer os.Remove(image1File) image2File := patchTestACI("rkt-inspect-exit-2.aci", "--name=hello2", - "--exec=/inspect --print-msg=HelloWorld --exit-code=6 --sleep=1") + "--exec=/inspect --print-msg=HelloWorld --exit-code=6 --sleep=2") defer os.Remove(image2File) ctx := testutils.NewRktRunCtx() From f23ca9d8673762e3ddc9d5ec4605abd4893bab88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Mon, 13 Jun 2016 13:10:06 +0200 Subject: [PATCH 0397/1304] api_service: wait until a pod regs with machined If we return before we're registered with machined, we could return a wrong cgroup because the pod is not yet moved to its final cgroup. Wait until we're registered with machined for 500ms before returning pod's information. --- rkt/api_service.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/rkt/api_service.go b/rkt/api_service.go index d98afc152d..61d09c20ad 100644 --- a/rkt/api_service.go +++ b/rkt/api_service.go @@ -16,6 +16,7 @@ package main import ( "encoding/json" + "errors" "fmt" "io/ioutil" "net" @@ -36,6 +37,7 @@ import ( "github.com/coreos/rkt/pkg/set" "github.com/coreos/rkt/store" "github.com/coreos/rkt/version" + "github.com/godbus/dbus" "github.com/spf13/cobra" "golang.org/x/net/context" "google.golang.org/grpc" @@ -368,6 +370,11 @@ func getBasicPod(p *pod) (*v1alpha.Pod, *schema.PodManifest) { } if pod.State == v1alpha.PodState_POD_STATE_RUNNING { + if err := waitForMachinedRegistration(pod.Id); err != nil { + // If there's an error, it means we're not registered to machined + // in a reasonable time. Just output the cgroup we're in. + stderr.PrintE("checking for machined registration failed", err) + } // Get cgroup for the "name=systemd" controller. pid, err := p.getContainerPID1() if err != nil { @@ -390,6 +397,25 @@ func getBasicPod(p *pod) (*v1alpha.Pod, *schema.PodManifest) { return pod, manifest } +func waitForMachinedRegistration(uuid string) error { + conn, err := dbus.SystemBus() + if err != nil { + return err + } + machined := conn.Object("org.freedesktop.machine1", "/org/freedesktop/machine1") + machineName := "rkt-" + uuid + + var o dbus.ObjectPath + for i := 0; i < 10; i++ { + if err := machined.Call("org.freedesktop.machine1.Manager.GetMachine", 0, machineName).Store(&o); err == nil { + return nil + } + time.Sleep(time.Millisecond * 50) + } + + return errors.New("pod not found") +} + func (s *v1AlphaAPIServer) ListPods(ctx context.Context, request *v1alpha.ListPodsRequest) (*v1alpha.ListPodsResponse, error) { var pods []*v1alpha.Pod if err := walkPods(includeMostDirs, func(p *pod) { From bfc7a5208956480e6a8194b24c5c7f611215cfeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Fri, 10 Jun 2016 18:30:42 +0200 Subject: [PATCH 0398/1304] functional tests: start api service with "nobody" UID We now check if we're registered with machined over dbus before returning from the ListPods API call. It turns out dbus authentication doesn't succeed unless our UID is mapped to a user name, and UID 65534 might not be mapped to any user name. Instead, look for the "nobody" user in `/etc/passwd` and use that. If it's not found, fall back to running the API service as root in the functional tests. --- tests/rkt_api_service_test.go | 20 ++++++++++++++++---- tests/rkt_tests.go | 23 +++++++++++++++++++++++ 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/tests/rkt_api_service_test.go b/tests/rkt_api_service_test.go index 50de85f065..28ebdce503 100644 --- a/tests/rkt_api_service_test.go +++ b/tests/rkt_api_service_test.go @@ -21,8 +21,10 @@ import ( "encoding/json" "fmt" "os" + "os/user" "path/filepath" "reflect" + "strconv" "strings" "syscall" "testing" @@ -38,24 +40,34 @@ import ( ) func startAPIService(t *testing.T, ctx *testutils.RktRunCtx) *gexpect.ExpectSubprocess { - noGid := false + noUidGid := false gid, err := common.LookupGid(common.RktGroup) if err != nil { t.Logf("no %q group, will run api service with root, ONLY DO THIS FOR TESTING!", common.RktGroup) - noGid = true + noUidGid = true } else { if err := ctx.SetupDataDir(); err != nil { t.Fatalf("failed to setup data directory: %v", err) } } + u, err := user.Lookup("nobody") + if err != nil { + t.Logf(`no "nobody" user, will run api service with root, ONLY DO THIS FOR TESTING!`) + noUidGid = true + } + uid, err := strconv.Atoi(u.Uid) + if err != nil { + t.Fatalf(`failed to parse "nobody" UID: %v`, err) + } + t.Logf("Running rkt api service") apisvcCmd := fmt.Sprintf("%s api-service", ctx.Cmd()) - if noGid { + if noUidGid { return startRktAndCheckOutput(t, apisvcCmd, "API service running") } - return startRktAsGidAndCheckOutput(t, apisvcCmd, "API service running", gid) + return startRktAsUidGidAndCheckOutput(t, apisvcCmd, "API service running", false, uid, gid) } func stopAPIService(t *testing.T, svc *gexpect.ExpectSubprocess) { diff --git a/tests/rkt_tests.go b/tests/rkt_tests.go index afea7a96fc..0fea827cd3 100644 --- a/tests/rkt_tests.go +++ b/tests/rkt_tests.go @@ -369,6 +369,29 @@ func startRktAsGidAndCheckOutput(t *testing.T, rktCmd, expectedLine string, gid return child } +func startRktAsUidGidAndCheckOutput(t *testing.T, rktCmd, expectedLine string, expectError bool, uid, gid int) *gexpect.ExpectSubprocess { + child, err := gexpect.Command(rktCmd) + if err != nil { + t.Fatalf("cannot exec rkt: %v", err) + } + if gid != 0 { + child.Cmd.SysProcAttr = &syscall.SysProcAttr{} + child.Cmd.SysProcAttr.Credential = &syscall.Credential{Uid: uint32(uid), Gid: uint32(gid)} + } + + err = child.Start() + if err != nil { + t.Fatalf("cannot start rkt: %v", err) + } + + if expectedLine != "" { + if err := expectWithOutput(child, expectedLine); err != nil { + t.Fatalf("didn't receive expected output %q: %v", expectedLine, err) + } + } + return child +} + func runRktAndCheckRegexOutput(t *testing.T, rktCmd, match string) { child := spawnOrFail(t, rktCmd) defer child.Wait() From dd91f8f46ecd25b2bcaf050a5a4c31be76a1eb4c Mon Sep 17 00:00:00 2001 From: Josh Wood Date: Mon, 13 Jun 2016 16:25:34 -0700 Subject: [PATCH 0399/1304] Doc/subcmd: Fix options table in prepare and run Fix broken links to k8s/design/resources. Restore docker port name convention doc from https://github.com/coreos/rkt/commit/443073354c7d2bb40a3f69d520f4f45f69f2f31d --- Documentation/subcommands/prepare.md | 4 ++-- Documentation/subcommands/run.md | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Documentation/subcommands/prepare.md b/Documentation/subcommands/prepare.md index 0cbb1e1fcc..23ac4bf0e2 100644 --- a/Documentation/subcommands/prepare.md +++ b/Documentation/subcommands/prepare.md @@ -40,7 +40,7 @@ c9fad0e6-8236-4fc2-ad17-55d0a4c7d742 | `--no-overlay` | `false` | `true` or `false` | Disable the overlay filesystem. | | `--no-store` | `false` | `true` or `false` | Fetch images, ignoring the local store. See [image fetching behavior](../image-fetching-behavior.md) | | `--pod-manifest` | none | A path | The path to the pod manifest. If it's non-empty, then only `--net`, `--no-overlay` and `--interactive` will have effect. | -| `--port` | none | A port number (ex. `--port=NAME:HOSTPORT`) | Ports to expose on the host (requires [contained network](../networking.md#contained-mode)). | +| `--port` | none | A port name and number pair | Container port name to expose through host port number. Requires [contained network](../networking/overview.md#contained-mode). Syntax: `--port=NAME:HOSTPORT` The NAME is that given in the ACI. By convention, Docker containers' EXPOSEd ports are given a name formed from the port number, a hyphen, and the protocol, e.g., `80-tcp`, giving something like `--port=80-tcp:8080` | | `--private-users` | `false` | `true` or `false` | Run within user namespaces | | `--quiet` | `false` | `true` or `false` | Suppress superfluous output on stdout, print only the UUID on success | | `--set-env` | `` | An environment variable. Syntax `NAME=VALUE` | An environment variable to set for apps | @@ -57,4 +57,4 @@ c9fad0e6-8236-4fc2-ad17-55d0a4c7d742 ## Global options -See the table with [global options in general commands documentation](../commands.md#global-options). +See the table with [global options in the general commands documentation](../commands.md#global-options). diff --git a/Documentation/subcommands/run.md b/Documentation/subcommands/run.md index ee3c2f7cc5..16ad23eab9 100644 --- a/Documentation/subcommands/run.md +++ b/Documentation/subcommands/run.md @@ -44,7 +44,7 @@ This executable can be overridden by rkt using the `--exec` flag: ## Overriding Isolators Application images can include per-app isolators and some of them can be overridden by rkt. -The units come from [the Kubernetes resource model](http://kubernetes.io/v1.1/docs/design/resources.html). +The units come from [the Kubernetes resource model](https://github.com/kubernetes/kubernetes/blob/release-1.2/docs/design/resources.md). In the following example, the CPU isolator is defined to 750 milli-cores and the memory isolator limits the memory usage to 128MB. ``` @@ -342,7 +342,7 @@ For more details see the [hacking documentation](../hacking.md). | Flag | Default | Options | Description | | --- | --- | --- | --- | -| `--cpu` | none | CPU units (ex. `--cpu=500m`) | CPU limit for the preceding image in [Kubernetes resource model](http://kubernetes.io/v1.1/docs/design/resources.html) format. | +| `--cpu` | none | CPU units (ex. `--cpu=500m`) | CPU limit for the preceding image in [Kubernetes resource model](https://github.com/kubernetes/kubernetes/blob/release-1.2/docs/design/resources.md) format. | | `--dns` | none | IP Address | Name server to write in `/etc/resolv.conf`. It can be specified several times | | `--dns-opt` | none | DNS option | DNS option from resolv.conf(5) to write in `/etc/resolv.conf`. It can be specified several times. | | `--dns-search` | none | Domain name | DNS search domain to write in `/etc/resolv.conf`. It can be specified several times. | @@ -351,13 +351,13 @@ For more details see the [hacking documentation](../hacking.md). | `--inherit-env` | `false` | `true` or `false` | Inherit all environment variables not set by apps. | | `--interactive` | `false` | `true` or `false` | Run pod interactively. If true, only one image may be supplied. | | `--mds-register` | `false` | `true` or `false` | Register pod with metadata service. It needs network connectivity to the host (`--net` as `default`, `default-restricted`, or `host`). | -| `--memory` | none | Memory units (ex. `--memory=50M`) | Memory limit for the preceding image in [Kubernetes resource model](http://kubernetes.io/v1.1/docs/design/resources.html) format. | +| `--memory` | none | Memory units (ex. `--memory=50M`) | Memory limit for the preceding image in [Kubernetes resource model](https://github.com/kubernetes/kubernetes/blob/release-1.2/docs/design/resources.md) format. | | `--mount` | none | Mount syntax (ex. `--mount volume=NAME,target=PATH`) | Mount point binding a volume to a path within an app. See [Mounting Volumes without Mount Points](#mounting-volumes-without-mount-points). | | `--net` | `default` | A comma-separated list of networks. (ex. `--net[=n[:args], ...]`) | Configure the pod's networking. Optionally, pass a list of user-configured networks to load and set arguments to pass to each network, respectively. | | `--no-overlay` | `false` | `true` or `false` | Disable the overlay filesystem. | | `--no-store` | `false` | `true` or `false` | Fetch images, ignoring the local store. See [image fetching behavior](../image-fetching-behavior.md) | | `--pod-manifest` | none | A path | The path to the pod manifest. If it's non-empty, then only `--net`, `--no-overlay` and `--interactive` will have effect. | -| `--port` | none | A port number (ex. `--port=NAME:HOSTPORT`) | Ports to expose on the host (requires [contained network](../networking.md#contained-mode)). | +| `--port` | none | A port name and number pair | Container port name to expose through host port number. Requires [contained network](../networking/overview.md#contained-mode). Syntax: `--port=NAME:HOSTPORT` The NAME is that given in the ACI. By convention, Docker containers' EXPOSEd ports are given a name formed from the port number, a hyphen, and the protocol, e.g., `80-tcp`, giving something like `--port=80-tcp:8080` | | `--private-users` | `false` | `true` or `false` | Run within user namespaces. | | `--set-env` | none | An environment variable (ex. `--set-env=NAME=VALUE`) | An environment variable to set for apps. | | `--signature` | none | A file path | Local signature file to use in validating the preceding image | @@ -372,4 +372,4 @@ For more details see the [hacking documentation](../hacking.md). ## Global options -See the table with [global options in general commands documentation](../commands.md#global-options). +See the table with [global options in the general commands documentation](../commands.md#global-options). From 686d60c46be056b3dc51cd58745017e690ed933d Mon Sep 17 00:00:00 2001 From: Abhishek Chanda Date: Tue, 7 Jun 2016 13:03:20 -0700 Subject: [PATCH 0400/1304] functional tests: do not pretty print json in tests --- Documentation/subcommands/cat-manifest.md | 2 +- Documentation/subcommands/image.md | 2 +- tests/rkt_cat_manifest_test.go | 2 +- tests/rkt_config_test.go | 2 +- tests/rkt_image_cat_manifest_test.go | 2 +- tests/rkt_tests.go | 3 ++- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Documentation/subcommands/cat-manifest.md b/Documentation/subcommands/cat-manifest.md index d3f91e2afb..844d35acdb 100644 --- a/Documentation/subcommands/cat-manifest.md +++ b/Documentation/subcommands/cat-manifest.md @@ -3,7 +3,7 @@ For debugging or inspection you may want to extract the PodManifest to stdout. ``` -# rkt cat-manifest --pretty-print UUID +# rkt cat-manifest UUID { "acVersion":"0.7.0", "acKind":"PodManifest" diff --git a/Documentation/subcommands/image.md b/Documentation/subcommands/image.md index b89019020f..43907e1abc 100644 --- a/Documentation/subcommands/image.md +++ b/Documentation/subcommands/image.md @@ -5,7 +5,7 @@ For debugging or inspection you may want to extract an ACI manifest to stdout. ``` -# rkt image cat-manifest --pretty-print coreos.com/etcd +# rkt image cat-manifest coreos.com/etcd { "acVersion": "0.7.0", "acKind": "ImageManifest", diff --git a/tests/rkt_cat_manifest_test.go b/tests/rkt_cat_manifest_test.go index 0eb65c1de3..8f74c90a79 100644 --- a/tests/rkt_cat_manifest_test.go +++ b/tests/rkt_cat_manifest_test.go @@ -63,7 +63,7 @@ func TestCatManifest(t *testing.T) { } for i, tt := range tests { - runCmd := fmt.Sprintf("%s cat-manifest %s", ctx.Cmd(), tt.uuid) + runCmd := fmt.Sprintf("%s cat-manifest --pretty-print=false %s", ctx.Cmd(), tt.uuid) t.Logf("Running test #%d", i) runRktAndCheckRegexOutput(t, runCmd, tt.match) } diff --git a/tests/rkt_config_test.go b/tests/rkt_config_test.go index 00a85e91fa..ad8b028b60 100644 --- a/tests/rkt_config_test.go +++ b/tests/rkt_config_test.go @@ -452,7 +452,7 @@ func TestConfig(t *testing.T) { tt.configFunc(ctx) - rktCmd := ctx.Cmd() + " --debug --insecure-options=image config" + rktCmd := ctx.Cmd() + " --debug --insecure-options=image --pretty-print=false config" out, status := runRkt(t, rktCmd, nobodyUid, 0) if status != 0 { diff --git a/tests/rkt_image_cat_manifest_test.go b/tests/rkt_image_cat_manifest_test.go index 5ec32f02c9..3c05f0ed75 100644 --- a/tests/rkt_image_cat_manifest_test.go +++ b/tests/rkt_image_cat_manifest_test.go @@ -85,7 +85,7 @@ func TestImageCatManifest(t *testing.T) { } for i, tt := range tests { - runCmd := fmt.Sprintf("%s image cat-manifest %s", ctx.Cmd(), tt.image) + runCmd := fmt.Sprintf("%s image cat-manifest --pretty-print=false %s", ctx.Cmd(), tt.image) t.Logf("Running test #%d", i) runRktAndCheckOutput(t, runCmd, tt.expect, !tt.shouldFind) } diff --git a/tests/rkt_tests.go b/tests/rkt_tests.go index afea7a96fc..1c054f9680 100644 --- a/tests/rkt_tests.go +++ b/tests/rkt_tests.go @@ -627,7 +627,8 @@ func getImageInfo(t *testing.T, ctx *testutils.RktRunCtx, imageID string) *image imgInfo := parseImageInfoOutput(t, string(output)) // Get manifest - output, err = exec.Command("/bin/bash", "-c", fmt.Sprintf("%s image cat-manifest %s", ctx.Cmd(), imageID)).CombinedOutput() + output, err = exec.Command("/bin/bash", "-c", + fmt.Sprintf("%s image cat-manifest --pretty-print=false %s", ctx.Cmd(), imageID)).CombinedOutput() if err != nil { t.Fatalf("Unexpected error: %v", err) } From 0a129683a9f84ad6f4bbf616b40a031edcf4fbd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20J=2E=20=C5=81akis?= Date: Tue, 14 Jun 2016 12:00:49 +0200 Subject: [PATCH 0401/1304] KVM: Update LKVM patch to mount with mmap mode. It is minimal cache that is only used for read-write mmap. Nothing else is cached, like cache=none, but it allows to read logs from rkt+kvm. --- stage1/usr_from_kvm/lkvm/patches/do_synchronous_writes.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stage1/usr_from_kvm/lkvm/patches/do_synchronous_writes.patch b/stage1/usr_from_kvm/lkvm/patches/do_synchronous_writes.patch index 700caf7b6a..ebd8a0fa64 100644 --- a/stage1/usr_from_kvm/lkvm/patches/do_synchronous_writes.patch +++ b/stage1/usr_from_kvm/lkvm/patches/do_synchronous_writes.patch @@ -7,7 +7,7 @@ index edcaf3e..f2f2d73 100644 if (kvm->cfg.using_rootfs) { - strcat(real_cmdline, " rw rootflags=trans=virtio,version=9p2000.L,cache=loose rootfstype=9p"); -+ strcat(real_cmdline, " rw rootflags=trans=virtio,version=9p2000.L,cache=none rootfstype=9p"); ++ strcat(real_cmdline, " rw rootflags=trans=virtio,version=9p2000.L,cache=mmap rootfstype=9p"); if (kvm->cfg.custom_rootfs) { kvm_run_set_sandbox(kvm); From 83c5903fe00def7d6bccb8b11b7b84282f641792 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Tue, 14 Jun 2016 16:22:55 +0200 Subject: [PATCH 0402/1304] stage1_fly: write pid instead of ppid Currently the stage1 fly flavor writes a ppid file. This implies it will have a child pid eventually. For the fly flavor this assumption does not hold. fly may or may not spawn children hence a ppid doesn't make sense. This fixes it and writes a pid file instead. Fixes partially #2792 --- stage1_fly/run/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stage1_fly/run/main.go b/stage1_fly/run/main.go index 396ef39ebd..d569f0991a 100644 --- a/stage1_fly/run/main.go +++ b/stage1_fly/run/main.go @@ -334,7 +334,7 @@ func stage1() int { } } - if err = stage1common.WritePid(os.Getpid(), "ppid"); err != nil { + if err = stage1common.WritePid(os.Getpid(), "pid"); err != nil { log.Error(err) return 1 } From 23b73ad27efc38c075d83798b4ea946f2e633276 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Thu, 9 Jun 2016 17:21:24 +0200 Subject: [PATCH 0403/1304] run: add --cap-retain and --cap-remove This adds the isolators os/linux/capabilities-retain-set or os/linux/capabilities-remove-set respectively. Examples of usage: sudo rkt run docker://ubuntu --cap-retain=CAP_KILL,CAP_NET_ADMIN --exec sh -- -c 'capsh --print' sudo rkt run docker://ubuntu --cap-remove=CAP_MKNOD,CAP_SYS_CHROOT --exec sh -- -c 'capsh --print' It is not allowed to specify both --cap-retain and --cap-remove on the same image. Both flags will override any existing capability isolator from the ACI. The override also happens on a capability isolator of a different type. For example, if the image had os/linux/capabilities-retain-set, using --cap-remove will remove it even if --cap-remove refers to os/linux/capabilities-remove-set. --- common/apps/apps.go | 20 +++++++------- rkt/cli_apps.go | 64 +++++++++++++++++++++++++++++++++++++++++++++ rkt/run.go | 5 +++- stage0/run.go | 24 +++++++++++++++++ 4 files changed, 103 insertions(+), 10 deletions(-) diff --git a/common/apps/apps.go b/common/apps/apps.go index 865c3aaf52..76c7bc88f8 100644 --- a/common/apps/apps.go +++ b/common/apps/apps.go @@ -38,15 +38,17 @@ const ( ) type App struct { - Image string // the image reference as supplied by the user on the cli - ImType AppImageType // the type of the image reference (to be guessed, url, path or hash) - Args []string // any arguments the user supplied for this app - Asc string // signature file override for image verification (if fetching occurs) - Exec string // exec override for image - Mounts []schema.Mount // mounts for this app (superseding any mounts in rktApps.mounts of same MountPoint) - MemoryLimit *types.ResourceMemory // memory isolator override - CPULimit *types.ResourceCPU // cpu isolator override - User, Group string // user, group overrides + Image string // the image reference as supplied by the user on the cli + ImType AppImageType // the type of the image reference (to be guessed, url, path or hash) + Args []string // any arguments the user supplied for this app + Asc string // signature file override for image verification (if fetching occurs) + Exec string // exec override for image + Mounts []schema.Mount // mounts for this app (superseding any mounts in rktApps.mounts of same MountPoint) + MemoryLimit *types.ResourceMemory // memory isolator override + CPULimit *types.ResourceCPU // cpu isolator override + User, Group string // user, group overrides + CapsRetain *types.LinuxCapabilitiesRetainSet // os/linux/capabilities-retain-set overrides + CapsRemove *types.LinuxCapabilitiesRevokeSet // os/linux/capabilities-remove-set overrides // TODO(jonboulle): These images are partially-populated hashes, this should be clarified. ImageID types.Hash // resolved image identifier diff --git a/rkt/cli_apps.go b/rkt/cli_apps.go index 70f2132ae7..5e01daff0f 100644 --- a/rkt/cli_apps.go +++ b/rkt/cli_apps.go @@ -353,3 +353,67 @@ func (ag *appGroup) String() string { func (ag *appGroup) Type() string { return "appGroup" } + +// appCapsRetain is for --caps-retain flags in the form of: --caps-retain=CAP_KILL,CAP_NET_ADMIN +type appCapsRetain apps.Apps + +func (au *appCapsRetain) Set(s string) error { + app := (*apps.Apps)(au).Last() + if app == nil { + return fmt.Errorf("--caps-retain must follow an image") + } + capsRetain, err := types.NewLinuxCapabilitiesRetainSet(strings.Split(s, ",")...) + if err != nil { + return err + } + app.CapsRetain = capsRetain + return nil +} + +func (au *appCapsRetain) String() string { + app := (*apps.Apps)(au).Last() + if app == nil { + return "" + } + var vs []string + for _, v := range app.CapsRetain.Set() { + vs = append(vs, string(v)) + } + return strings.Join(vs, ",") +} + +func (au *appCapsRetain) Type() string { + return "appCapsRetain" +} + +// appCapsRemove is for --caps-remove flags in the form of: --caps-remove=CAP_MKNOD,CAP_SYS_CHROOT +type appCapsRemove apps.Apps + +func (au *appCapsRemove) Set(s string) error { + app := (*apps.Apps)(au).Last() + if app == nil { + return fmt.Errorf("--caps-retain must follow an image") + } + capsRemove, err := types.NewLinuxCapabilitiesRevokeSet(strings.Split(s, ",")...) + if err != nil { + return err + } + app.CapsRemove = capsRemove + return nil +} + +func (au *appCapsRemove) String() string { + app := (*apps.Apps)(au).Last() + if app == nil { + return "" + } + var vs []string + for _, v := range app.CapsRemove.Set() { + vs = append(vs, string(v)) + } + return strings.Join(vs, ",") +} + +func (au *appCapsRemove) Type() string { + return "appCapsRemove" +} diff --git a/rkt/run.go b/rkt/run.go index f0756d8bf4..0634b63005 100644 --- a/rkt/run.go +++ b/rkt/run.go @@ -101,6 +101,8 @@ func init() { cmdRun.Flags().Var((*appCPULimit)(&rktApps), "cpu", "cpu limit for the preceding image (example: '--cpu=500m')") cmdRun.Flags().Var((*appUser)(&rktApps), "user", "user override for the preceding image (example: '--user=user')") cmdRun.Flags().Var((*appGroup)(&rktApps), "group", "group override for the preceding image (example: '--group=group')") + cmdRun.Flags().Var((*appCapsRetain)(&rktApps), "cap-retain", "capability to retain (example: '--cap-retain=CAP_SYS_ADMIN')") + cmdRun.Flags().Var((*appCapsRemove)(&rktApps), "cap-remove", "capability to remove (example: '--cap-remove=CAP_MKNOD')") flagPorts = portList{} flagDNS = flagStringList{} @@ -150,7 +152,8 @@ func runRun(cmd *cobra.Command, args []string) (exit int) { if len(flagPodManifest) > 0 && (len(flagPorts) > 0 || flagInheritEnv || !flagExplicitEnv.IsEmpty() || rktApps.Count() > 0 || flagStoreOnly || flagNoStore || (*appsVolume)(&rktApps).String() != "" || (*appMount)(&rktApps).String() != "" || (*appExec)(&rktApps).String() != "" || - (*appUser)(&rktApps).String() != "" || (*appGroup)(&rktApps).String() != "") { + (*appUser)(&rktApps).String() != "" || (*appGroup)(&rktApps).String() != "" || + (*appCapsRetain)(&rktApps).String() != "" || (*appCapsRemove)(&rktApps).String() != "") { stderr.Print("conflicting flags set with --pod-manifest (see --help)") return 1 } diff --git a/stage0/run.go b/stage0/run.go index 110b5ea66e..f7b5aa1daa 100644 --- a/stage0/run.go +++ b/stage0/run.go @@ -248,6 +248,30 @@ func generatePodManifest(cfg PrepareConfig, dir string) ([]byte, error) { ra.App.Isolators = append(ra.App.Isolators, isolator) } + if app.CapsRetain != nil && app.CapsRemove != nil { + return fmt.Errorf("error: cannot use both --cap-retain and --cap-remove on the same image") + } + + // Delete existing caps isolators if the user wants to override + // them with either --cap-retain or --cap-remove + if app.CapsRetain != nil || app.CapsRemove != nil { + for i := len(ra.App.Isolators) - 1; i >= 0; i-- { + isolator := ra.App.Isolators[i] + if _, ok := isolator.Value().(types.LinuxCapabilitiesSet); ok { + ra.App.Isolators = append(ra.App.Isolators[:i], + ra.App.Isolators[i+1:]...) + } + } + } + + if capsRetain := app.CapsRetain; capsRetain != nil { + isolator := capsRetain.AsIsolator() + ra.App.Isolators = append(ra.App.Isolators, isolator) + } else if capsRemove := app.CapsRemove; capsRemove != nil { + isolator := capsRemove.AsIsolator() + ra.App.Isolators = append(ra.App.Isolators, isolator) + } + if user := app.User; user != "" { ra.App.User = user } From 52731d6a576577488a0e51ed4f64ae5dee8b41b1 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Fri, 10 Jun 2016 14:03:32 +0200 Subject: [PATCH 0404/1304] tests: new tests for --cap-retain and --cap-remove The existing test TestCapsSeveralApp was split in two tests: - TestCapsSeveralAppWithPatches: add the caps isolators in the ACI - TestCapsSeveralAppWithFlags: add the caps isolators on the command line TestCapsOverride is a new test that combine caps isolators defined in the ACI and on the command line. --- tests/rkt_caps_test.go | 600 ++++++++++++++++++++++++++--------------- 1 file changed, 376 insertions(+), 224 deletions(-) diff --git a/tests/rkt_caps_test.go b/tests/rkt_caps_test.go index b54057e0b5..1b73ee5eac 100644 --- a/tests/rkt_caps_test.go +++ b/tests/rkt_caps_test.go @@ -26,146 +26,382 @@ import ( "github.com/syndtr/gocapability/capability" ) -func TestCapsSeveralApp(t *testing.T) { +var appCapsTests = []struct { + // constants + testName string // name of the image + capRetainSet string // only use value if != "x" + capRemoveSet string // only use value if != "x" + expected string // caps bounding set as printed by gocapability + + // set during the test + imageFile string +}{ + // Testing without isolators + { + testName: "image-none", + capRetainSet: "x", + capRemoveSet: "x", + expected: strings.Join([]string{ + "chown", + "dac_override", + "fowner", + "fsetid", + "kill", + "setgid", + "setuid", + "setpcap", + "net_bind_service", + "net_raw", + "sys_chroot", + "mknod", + "audit_write", + "setfcap", + }, ", "), + }, + // Testing retain set + { + testName: "image-only-one-cap", + capRetainSet: "CAP_NET_ADMIN", + capRemoveSet: "x", + expected: "net_admin", + }, + { + testName: "image-only-one-cap-from-default", + capRetainSet: "CAP_CHOWN", + capRemoveSet: "x", + expected: "chown", + }, + { + testName: "image-some-caps", + capRetainSet: strings.Join([]string{ + "CAP_CHOWN", + "CAP_FOWNER", + "CAP_SYS_ADMIN", + "CAP_NET_ADMIN", + }, ","), + capRemoveSet: "x", + expected: strings.Join([]string{ + "chown", + "fowner", + "net_admin", + "sys_admin", + }, ", "), + }, + { + testName: "image-caps-from-nspawn-default", + capRetainSet: strings.Join([]string{ + "CAP_CHOWN", + "CAP_DAC_OVERRIDE", + "CAP_DAC_READ_SEARCH", + "CAP_FOWNER", + "CAP_FSETID", + "CAP_IPC_OWNER", + "CAP_KILL", + "CAP_LEASE", + "CAP_LINUX_IMMUTABLE", + "CAP_NET_BIND_SERVICE", + "CAP_NET_BROADCAST", + "CAP_NET_RAW", + "CAP_SETGID", + "CAP_SETFCAP", + "CAP_SETPCAP", + "CAP_SETUID", + "CAP_SYS_ADMIN", + "CAP_SYS_CHROOT", + "CAP_SYS_NICE", + "CAP_SYS_PTRACE", + "CAP_SYS_TTY_CONFIG", + "CAP_SYS_RESOURCE", + "CAP_SYS_BOOT", + "CAP_AUDIT_WRITE", + "CAP_AUDIT_CONTROL", + }, ","), + capRemoveSet: "x", + expected: strings.Join([]string{ + "chown", + "dac_override", + "dac_read_search", + "fowner", + "fsetid", + "kill", + "setgid", + "setuid", + "setpcap", + "linux_immutable", + "net_bind_service", + "net_broadcast", + "net_raw", + "ipc_owner", + "sys_chroot", + "sys_ptrace", + "sys_admin", + "sys_boot", + "sys_nice", + "sys_resource", + "sys_tty_config", + "lease", + "audit_write", + "audit_control", + "setfcap", + }, ", "), + }, + // Testing remove set + { + testName: "image-remove-one-from-default", + capRetainSet: "x", + capRemoveSet: "CAP_CHOWN", + expected: strings.Join([]string{ + "dac_override, fowner, fsetid, kill, setgid, setuid, setpcap, net_bind_service, net_raw, sys_chroot, mknod, audit_write, setfcap", + }, ", "), + }, + { + testName: "image-remove-one-already-removed", + capRetainSet: "x", + capRemoveSet: "CAP_SYS_ADMIN", + expected: strings.Join([]string{ + "chown", + "dac_override", + "fowner", + "fsetid", + "kill", + "setgid", + "setuid", + "setpcap", + "net_bind_service", + "net_raw", + "sys_chroot", + "mknod", + "audit_write", + "setfcap", + }, ", "), + }, + { + testName: "image-remove-two", + capRetainSet: "x", + capRemoveSet: "CAP_CHOWN,CAP_SYS_ADMIN", + expected: strings.Join([]string{ + "dac_override", + "fowner", + "fsetid", + "kill", + "setgid", + "setuid", + "setpcap", + "net_bind_service", + "net_raw", + "sys_chroot", + "mknod", + "audit_write", + "setfcap", + }, ", "), + }, + { + testName: "image-remove-all", + capRetainSet: "x", + capRemoveSet: strings.Join([]string{ + "CAP_AUDIT_WRITE", + "CAP_CHOWN", + "CAP_DAC_OVERRIDE", + "CAP_FSETID", + "CAP_FOWNER", + "CAP_KILL", + "CAP_MKNOD", + "CAP_NET_RAW", + "CAP_NET_BIND_SERVICE", + "CAP_SETUID", + "CAP_SETGID", + "CAP_SETPCAP", + "CAP_SETFCAP", + "CAP_SYS_CHROOT", + }, ","), + expected: "", + }, + { + testName: "image-remove-all-but-one", + capRetainSet: "x", + capRemoveSet: strings.Join([]string{ + "CAP_AUDIT_WRITE", + "CAP_CHOWN", + "CAP_DAC_OVERRIDE", + "CAP_FSETID", + "CAP_FOWNER", + "CAP_KILL", + "CAP_MKNOD", + "CAP_NET_RAW", + "CAP_NET_BIND_SERVICE", + "CAP_SETUID", + "CAP_SETGID", + "CAP_SETPCAP", + "CAP_SETFCAP", + }, ","), + expected: "sys_chroot", + }, + { + testName: "image-remove-all-plus-one", + capRetainSet: "x", + capRemoveSet: strings.Join([]string{ + "CAP_AUDIT_WRITE", + "CAP_CHOWN", + "CAP_DAC_OVERRIDE", + "CAP_FSETID", + "CAP_FOWNER", + "CAP_KILL", + "CAP_MKNOD", + "CAP_NET_RAW", + "CAP_NET_BIND_SERVICE", + "CAP_SETUID", + "CAP_SETGID", + "CAP_SETPCAP", + "CAP_SETFCAP", + "CAP_SYS_CHROOT", + "CAP_SYS_ADMIN", + }, ","), + expected: "", + }, + // Testing with an empty retain set or an empty remove set + // TODO(alban): "actool patch-manifest" cannot generate those images for now + //{ + // testName: "image-retain-set-empty", + // capRetainSet: "", + // capRemoveSet: "x", + // expected: "", + //}, + //{ + // testName: "image-remove-none", + // capRetainSet: "x", + // capRemoveSet: "", + // expected: "TODO(alban)", + //}, +} + +func capsSeveralAppsRunAndCheckOutput(t *testing.T, ctx *testutils.RktRunCtx, cmd string) { + // Ideally, the test would run the pod only one time, but all + // apps' output is mixed together without ordering guarantees, so + // it makes it impossible to call all the expectWithOutput() in + // the correct order. + for _, tt := range appCapsTests { + t.Logf("Checking caps for %q", tt.testName) + child := spawnOrFail(t, cmd) + + expected := fmt.Sprintf("Capability set: bounding: %s (%s)", + tt.expected, tt.testName) + if err := expectWithOutput(child, expected); err != nil { + t.Fatalf("Expected %q but not found: %v", expected, err) + } + + waitOrFail(t, child, 0) + + ctx.RunGC() + } +} + +func TestCapsSeveralAppWithPatches(t *testing.T) { + // All the following images are launched together in the same pod + + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + for i, tt := range appCapsTests { + patches := []string{ + fmt.Sprintf("--name=%s", tt.testName), + fmt.Sprintf("--exec=/inspect --print-caps-pid=0 --suffix-msg=%s", tt.testName), + } + if tt.capRetainSet != "x" { + patches = append(patches, "--capability="+tt.capRetainSet) + } + if tt.capRemoveSet != "x" { + patches = append(patches, "--revoke-capability="+tt.capRemoveSet) + } + imageFile := patchTestACI(tt.testName+".aci", patches...) + defer os.Remove(imageFile) + appCapsTests[i].imageFile = imageFile + t.Logf("Built image %q", imageFile) + } + + // Generate the rkt arguments to launch all the apps in the same pod + rktArgs := "" + for _, tt := range appCapsTests { + rktArgs += " " + tt.imageFile + } + cmd := fmt.Sprintf("%s --insecure-options=image run %s", ctx.Cmd(), rktArgs) + + capsSeveralAppsRunAndCheckOutput(t, ctx, cmd) +} + +func TestCapsSeveralAppWithFlags(t *testing.T) { // All the following images are launched together in the same pod - var appCapsTests = []struct { - // constants - testName string // name of the image - capRemainSet string // if != "x", value passed to actool patch-manifest --capability= - capRemoveSet string // if != "x", value passed to actool patch-manifest --revoke-capability= - expected string // caps bounding set as printed by gocapability - - // set during the test - imageFile string + + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + for i, tt := range appCapsTests { + imageFile := patchTestACI(tt.testName+".aci", fmt.Sprintf("--name=%s", tt.testName), + fmt.Sprintf("--exec=/inspect --print-caps-pid=0 --suffix-msg=%s", tt.testName)) + defer os.Remove(imageFile) + appCapsTests[i].imageFile = imageFile + t.Logf("Built image %q", imageFile) + } + + // Generate the rkt arguments to launch all the apps in the same pod + rktArgs := "" + for _, tt := range appCapsTests { + rktArgs += " " + tt.imageFile + if tt.capRetainSet != "x" { + rktArgs += " --cap-retain=" + tt.capRetainSet + } + if tt.capRemoveSet != "x" { + rktArgs += " --cap-remove=" + tt.capRemoveSet + } + } + cmd := fmt.Sprintf("%s --insecure-options=image run %s", ctx.Cmd(), rktArgs) + + capsSeveralAppsRunAndCheckOutput(t, ctx, cmd) +} + +// Tests that flags on the command line override the isolator in the ACI +func TestCapsOverride(t *testing.T) { + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + var appCapsOverride = []struct { + testName string // name of the image + capRetainSetImg string // only use value if != "x" + capRemoveSetImg string // only use value if != "x" + capRetainSetFlg string // only use value if != "x" + capRemoveSetFlg string // only use value if != "x" + expected string // caps bounding set as printed by gocapability }{ - // Testing without isolators - { - testName: "image-none", - capRemainSet: "x", - capRemoveSet: "x", - expected: strings.Join([]string{ - "chown", - "dac_override", - "fowner", - "fsetid", - "kill", - "setgid", - "setuid", - "setpcap", - "net_bind_service", - "net_raw", - "sys_chroot", - "mknod", - "audit_write", - "setfcap", - }, ", "), - }, - // Testing remain set - { - testName: "image-only-one-cap", - capRemainSet: "CAP_NET_ADMIN", - capRemoveSet: "x", - expected: "net_admin", - }, - { - testName: "image-only-one-cap-from-default", - capRemainSet: "CAP_CHOWN", - capRemoveSet: "x", - expected: "chown", - }, { - testName: "image-some-caps", - capRemainSet: strings.Join([]string{ - "CAP_CHOWN", - "CAP_FOWNER", - "CAP_SYS_ADMIN", - "CAP_NET_ADMIN", - }, ","), - capRemoveSet: "x", + testName: "retain-override-retain", + capRetainSetImg: "CAP_MKNOD", + capRemoveSetImg: "x", + capRetainSetFlg: "CAP_SYS_ADMIN", + capRemoveSetFlg: "x", expected: strings.Join([]string{ - "chown", - "fowner", - "net_admin", "sys_admin", }, ", "), }, { - testName: "image-caps-from-nspawn-default", - capRemainSet: strings.Join([]string{ - "CAP_CHOWN", - "CAP_DAC_OVERRIDE", - "CAP_DAC_READ_SEARCH", - "CAP_FOWNER", - "CAP_FSETID", - "CAP_IPC_OWNER", - "CAP_KILL", - "CAP_LEASE", - "CAP_LINUX_IMMUTABLE", - "CAP_NET_BIND_SERVICE", - "CAP_NET_BROADCAST", - "CAP_NET_RAW", - "CAP_SETGID", - "CAP_SETFCAP", - "CAP_SETPCAP", - "CAP_SETUID", - "CAP_SYS_ADMIN", - "CAP_SYS_CHROOT", - "CAP_SYS_NICE", - "CAP_SYS_PTRACE", - "CAP_SYS_TTY_CONFIG", - "CAP_SYS_RESOURCE", - "CAP_SYS_BOOT", - "CAP_AUDIT_WRITE", - "CAP_AUDIT_CONTROL", - }, ","), - capRemoveSet: "x", + testName: "retain-override-remove", + capRetainSetImg: "x", + capRemoveSetImg: "CAP_CHOWN", + capRetainSetFlg: "CAP_SYS_ADMIN", + capRemoveSetFlg: "x", expected: strings.Join([]string{ - "chown", - "dac_override", - "dac_read_search", - "fowner", - "fsetid", - "kill", - "setgid", - "setuid", - "setpcap", - "linux_immutable", - "net_bind_service", - "net_broadcast", - "net_raw", - "ipc_owner", - "sys_chroot", - "sys_ptrace", "sys_admin", - "sys_boot", - "sys_nice", - "sys_resource", - "sys_tty_config", - "lease", - "audit_write", - "audit_control", - "setfcap", }, ", "), }, - // Testing revoke set { - testName: "image-revoke-one-from-default", - capRemainSet: "x", - capRemoveSet: "CAP_CHOWN", - expected: strings.Join([]string{ - "dac_override, fowner, fsetid, kill, setgid, setuid, setpcap, net_bind_service, net_raw, sys_chroot, mknod, audit_write, setfcap", - }, ", "), - }, - { - testName: "image-revoke-one-already-revoked", - capRemainSet: "x", - capRemoveSet: "CAP_SYS_ADMIN", + testName: "remove-override-remove", + capRetainSetImg: "x", + capRemoveSetImg: "CAP_CHOWN", + capRetainSetFlg: "x", + capRemoveSetFlg: "CAP_KILL", expected: strings.Join([]string{ "chown", "dac_override", "fowner", "fsetid", - "kill", "setgid", "setuid", "setpcap", @@ -178,14 +414,16 @@ func TestCapsSeveralApp(t *testing.T) { }, ", "), }, { - testName: "image-revoke-two", - capRemainSet: "x", - capRemoveSet: "CAP_CHOWN,CAP_SYS_ADMIN", + testName: "remove-override-retain", + capRetainSetImg: "CAP_MKNOD", + capRemoveSetImg: "x", + capRetainSetFlg: "x", + capRemoveSetFlg: "CAP_KILL", expected: strings.Join([]string{ + "chown", "dac_override", "fowner", "fsetid", - "kill", "setgid", "setuid", "setpcap", @@ -197,117 +435,31 @@ func TestCapsSeveralApp(t *testing.T) { "setfcap", }, ", "), }, - { - testName: "image-revoke-all", - capRemainSet: "x", - capRemoveSet: strings.Join([]string{ - "CAP_AUDIT_WRITE", - "CAP_CHOWN", - "CAP_DAC_OVERRIDE", - "CAP_FSETID", - "CAP_FOWNER", - "CAP_KILL", - "CAP_MKNOD", - "CAP_NET_RAW", - "CAP_NET_BIND_SERVICE", - "CAP_SETUID", - "CAP_SETGID", - "CAP_SETPCAP", - "CAP_SETFCAP", - "CAP_SYS_CHROOT", - }, ","), - expected: "", - }, - { - testName: "image-revoke-all-but-one", - capRemainSet: "x", - capRemoveSet: strings.Join([]string{ - "CAP_AUDIT_WRITE", - "CAP_CHOWN", - "CAP_DAC_OVERRIDE", - "CAP_FSETID", - "CAP_FOWNER", - "CAP_KILL", - "CAP_MKNOD", - "CAP_NET_RAW", - "CAP_NET_BIND_SERVICE", - "CAP_SETUID", - "CAP_SETGID", - "CAP_SETPCAP", - "CAP_SETFCAP", - }, ","), - expected: "sys_chroot", - }, - { - testName: "image-revoke-all-plus-one", - capRemainSet: "x", - capRemoveSet: strings.Join([]string{ - "CAP_AUDIT_WRITE", - "CAP_CHOWN", - "CAP_DAC_OVERRIDE", - "CAP_FSETID", - "CAP_FOWNER", - "CAP_KILL", - "CAP_MKNOD", - "CAP_NET_RAW", - "CAP_NET_BIND_SERVICE", - "CAP_SETUID", - "CAP_SETGID", - "CAP_SETPCAP", - "CAP_SETFCAP", - "CAP_SYS_CHROOT", - "CAP_SYS_ADMIN", - }, ","), - expected: "", - }, - // Testing with an empty remain set or an empty remove set - // TODO(alban): "actool patch-manifest" cannot generate those images for now - //{ - // testName: "image-remain-set-empty", - // capRemainSet: "", - // capRemoveSet: "x", - // expected: "", - //}, - //{ - // testName: "image-revoke-none", - // capRemainSet: "x", - // capRemoveSet: "", - // expected: "TODO(alban)", - //}, } - ctx := testutils.NewRktRunCtx() - defer ctx.Cleanup() - - for i, tt := range appCapsTests { + for _, tt := range appCapsOverride { patches := []string{ fmt.Sprintf("--name=%s", tt.testName), fmt.Sprintf("--exec=/inspect --print-caps-pid=0 --suffix-msg=%s", tt.testName), } - if tt.capRemainSet != "x" { - patches = append(patches, "--capability="+tt.capRemainSet) + if tt.capRetainSetImg != "x" { + patches = append(patches, "--capability="+tt.capRetainSetImg) } - if tt.capRemoveSet != "x" { - patches = append(patches, "--revoke-capability="+tt.capRemoveSet) + if tt.capRemoveSetImg != "x" { + patches = append(patches, "--revoke-capability="+tt.capRemoveSetImg) } imageFile := patchTestACI(tt.testName+".aci", patches...) defer os.Remove(imageFile) - appCapsTests[i].imageFile = imageFile t.Logf("Built image %q", imageFile) - } - // Generate the rkt arguments to launch all the apps in the same pod - rktArgs := "" - for _, tt := range appCapsTests { - rktArgs += " " + tt.imageFile - } - cmd := fmt.Sprintf("%s --insecure-options=image run %s", ctx.Cmd(), rktArgs) + cmd := fmt.Sprintf("%s --insecure-options=image run %s", ctx.Cmd(), imageFile) + if tt.capRetainSetFlg != "x" { + cmd += " --cap-retain=" + tt.capRetainSetFlg + } + if tt.capRemoveSetFlg != "x" { + cmd += " --cap-remove=" + tt.capRemoveSetFlg + } - // Ideally, the test would run the pod only one time, but all - // apps' output is mixed together without ordering guarantees, so - // it makes it impossible to call all the expectWithOutput() in - // the correct order. - for _, tt := range appCapsTests { t.Logf("Checking caps for %q", tt.testName) child := spawnOrFail(t, cmd) From 9c6c37ec007e9c2b818002c504a200f587b122e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20=C5=BBy=C5=82owski?= Date: Mon, 13 Jun 2016 11:42:45 +0200 Subject: [PATCH 0405/1304] tests: enable all cases in capabilities test for rkt-kvm --- tests/rkt_caps_kvm_test.go | 6 +----- tests/rkt_caps_nspawn_test.go | 2 +- tests/rkt_caps_test.go | 5 ++--- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/tests/rkt_caps_kvm_test.go b/tests/rkt_caps_kvm_test.go index b30a108319..b72e5479bb 100644 --- a/tests/rkt_caps_kvm_test.go +++ b/tests/rkt_caps_kvm_test.go @@ -19,9 +19,5 @@ package main import "testing" func TestCaps(t *testing.T) { - // KVM is running VMs as stage1 pods, so root has access to all VM options. - // The case with access to PID 1 is skipped... - // KVM flavor runs systemd stage1 with full capabilities in stage1 (pid=1) - // so expect every capability enabled - NewCapsTest(true, []int{2}).Execute(t) + NewCapsTest(true).Execute(t) } diff --git a/tests/rkt_caps_nspawn_test.go b/tests/rkt_caps_nspawn_test.go index 5c3f2e048b..d23f8f4b09 100644 --- a/tests/rkt_caps_nspawn_test.go +++ b/tests/rkt_caps_nspawn_test.go @@ -19,5 +19,5 @@ package main import "testing" func TestCaps(t *testing.T) { - NewCapsTest(false, []int{1, 2}).Execute(t) + NewCapsTest(false).Execute(t) } diff --git a/tests/rkt_caps_test.go b/tests/rkt_caps_test.go index b54057e0b5..e9dda79b79 100644 --- a/tests/rkt_caps_test.go +++ b/tests/rkt_caps_test.go @@ -373,8 +373,7 @@ var capsTests = []struct { }, } -// CommonTestCaps creates a new capabilities test fixture for the given stages. -func NewCapsTest(hasStage1FullCaps bool, stages []int) testutils.Test { +func NewCapsTest(hasStage1FullCaps bool) testutils.Test { return testutils.TestFunc(func(t *testing.T) { ctx := testutils.NewRktRunCtx() defer ctx.Cleanup() @@ -392,7 +391,7 @@ func NewCapsTest(hasStage1FullCaps bool, stages []int) testutils.Test { defer os.Remove(stage2FileName) stageFileNames := []string{stage1FileName, stage2FileName} - for _, stage := range stages { + for _, stage := range []int{1, 2} { t.Logf("Running test #%v: %v [stage%v]", i, tt.testName, stage) cmd := fmt.Sprintf("%s --debug --insecure-options=image run --mds-register=false --set-env=CAPABILITY=%d %s", ctx.Cmd(), int(tt.capa), stageFileNames[stage-1]) From 8969389becbe2325c1338282f2f999f329963e89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 15 Jun 2016 16:05:08 +0200 Subject: [PATCH 0406/1304] functional tests: sleep before killing rkt on TestResumedFetch Our test server sends half of the file and then tells TestResumedFetch via a channel that it should kill rkt and start another rkt process to check if it resumes the download. However, it may happen that rkt doesn't have time to write everything to disk before it gets killed, in some cases it doesn't even have time to write anything and the test fails. To fix it, we sleep a bit before telling TestResumedFetch that it should kill rkt. --- tests/rkt_fetch_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/rkt_fetch_test.go b/tests/rkt_fetch_test.go index 3c3d56ae27..eefdedcf55 100644 --- a/tests/rkt_fetch_test.go +++ b/tests/rkt_fetch_test.go @@ -28,6 +28,7 @@ import ( "strings" "sync" "testing" + "time" "github.com/appc/spec/schema/types" "github.com/coreos/rkt/tests/testutils" @@ -395,6 +396,9 @@ func testInterruptingServerHandler(t *testing.T, imagePath string, kill, waitfor panic(err) } + // sleep a bit before signaling that rkt should be killed since it + // might not have had time to write everything to disk + time.Sleep(time.Second) kill <- struct{}{} <-waitforkill } From b2bb6322d15774ab603470b305c5de7e85e5a8da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Wed, 15 Jun 2016 16:19:25 +0200 Subject: [PATCH 0407/1304] functional tests: fix skipping tests on remote fetch failure If we call `t.Errorf` before skipping, our test will fail... --- tests/rkt_fetch_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/rkt_fetch_test.go b/tests/rkt_fetch_test.go index eefdedcf55..86c080b256 100644 --- a/tests/rkt_fetch_test.go +++ b/tests/rkt_fetch_test.go @@ -165,7 +165,7 @@ func testFetchDefault(t *testing.T, arg string, image string, imageArgs string, err := child.Wait() status := getExitStatus(err) if status != 0 { - t.Errorf("rkt terminated with unexpected status %d, expected %d\nOutput:\n%s", status, 0, child.Collect()) + t.Logf("rkt terminated with unexpected status %d, expected %d\nOutput:\n%s", status, 0, child.Collect()) t.Skip("remote fetching failed, probably a network failure. Skipping...") } @@ -212,7 +212,7 @@ func testFetchNoStore(t *testing.T, args string, image string, imageArgs string, err := child.Wait() status := getExitStatus(err) if status != 0 { - t.Errorf("rkt terminated with unexpected status %d, expected %d\nOutput:\n%s", status, 0, child.Collect()) + t.Logf("rkt terminated with unexpected status %d, expected %d\nOutput:\n%s", status, 0, child.Collect()) t.Skip("remote fetching failed, probably a network failure. Skipping...") } } From c3265e928ef798415b64adc0aa5f69a9a8e5f143 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Tue, 14 Jun 2016 16:25:28 +0200 Subject: [PATCH 0408/1304] rkt/api_service: return err for non-journaling pods Previously GetLogs assumed a journal directory is always present. This assumption doesn't hold for the fly flavor. This fixes it by returning an error in this case. Fixes partially #2792 --- api/v1alpha/client_example.go | 10 ++++++++-- rkt/api_service.go | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/api/v1alpha/client_example.go b/api/v1alpha/client_example.go index 6be7c32ac0..81d3d15c7d 100644 --- a/api/v1alpha/client_example.go +++ b/api/v1alpha/client_example.go @@ -41,15 +41,21 @@ func getLogsWithoutFollow(c v1alpha.PublicAPIClient, p *v1alpha.Pod) { SinceTime: time.Now().Add(-time.Second * 5).Unix(), Lines: 10, }) + if err != nil { fmt.Println(err) os.Exit(1) } logsRecvResp, err := logsResp.Recv() + + if err == io.EOF { + return + } + if err != nil { fmt.Println(err) - os.Exit(1) + return } for _, l := range logsRecvResp.Lines { @@ -81,7 +87,7 @@ func getLogsWithFollow(c v1alpha.PublicAPIClient, p *v1alpha.Pod) { if err != nil { fmt.Println(err) - os.Exit(1) + return } for _, l := range logsRecvResp.Lines { diff --git a/rkt/api_service.go b/rkt/api_service.go index d98afc152d..2f37305858 100644 --- a/rkt/api_service.go +++ b/rkt/api_service.go @@ -735,6 +735,11 @@ func (s *v1AlphaAPIServer) GetLogs(request *v1alpha.GetLogsRequest, server v1alp stage1Path = fmt.Sprintf("/overlay/%s/upper/", stage1TreeStoreID) } path := filepath.Join(getDataDir(), "/pods/run/", request.PodId, stage1Path, "/var/log/journal/") + + if _, err := os.Stat(path); os.IsNotExist(err) { + return fmt.Errorf("%s: logging unsupported", uuid.String()) + } + jconf := sdjournal.JournalReaderConfig{ Path: path, } From 6f9be548c580643ffeb0d36d97d026359a259556 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Wed, 1 Jun 2016 12:11:56 +0200 Subject: [PATCH 0409/1304] docs: add Jenkins CI Badge https://jenkins-rkt-public.prod.coreos.systems/ --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 12611baa68..83f8cfc1d4 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![godoc](https://godoc.org/github.com/coreos/rkt?status.svg)](http://godoc.org/github.com/coreos/rkt) [![Build Status (Travis)](https://travis-ci.org/coreos/rkt.svg?branch=master)](https://travis-ci.org/coreos/rkt) [![Build Status (SemaphoreCI)](https://semaphoreci.com/api/v1/projects/28468e19-4fd0-483e-9c29-6c8368661333/395211/badge.svg)](https://semaphoreci.com/coreos/rkt) +[![Build Status (Jenkins)](https://jenkins-rkt-public.prod.coreos.systems/job/rkt-matrix/badge/icon)](https://jenkins-rkt-public.prod.coreos.systems/job/rkt-matrix/) ![rkt Logo](logos/rkt-horizontal-color.png) From 579da705a27ccbba15f23e2876779ba668a0dd2e Mon Sep 17 00:00:00 2001 From: Euan Kemp Date: Tue, 24 May 2016 14:12:50 -0700 Subject: [PATCH 0410/1304] dist: Add rkt-api systemd unit This commit adds a sample service file for a rkt api-service listening on localhost. --- dist/init/systemd/rkt-api.service | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 dist/init/systemd/rkt-api.service diff --git a/dist/init/systemd/rkt-api.service b/dist/init/systemd/rkt-api.service new file mode 100644 index 0000000000..c4d8031b94 --- /dev/null +++ b/dist/init/systemd/rkt-api.service @@ -0,0 +1,10 @@ +[Unit] +Description=rkt api service +Documentation=http://github.com/coreos/rkt +After=network.target + +[Service] +ExecStart=/usr/bin/rkt api-service --listen="127.0.0.1:15441" + +[Install] +WantedBy=multi-user.target From e9afff0d70401f4e8acf69070cc7196b3ed15cce Mon Sep 17 00:00:00 2001 From: Euan Kemp Date: Mon, 13 Jun 2016 19:16:03 -0700 Subject: [PATCH 0411/1304] docs: Add a few words about rkt api-service unit --- Documentation/packaging.md | 3 ++- Documentation/subcommands/api-service.md | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Documentation/packaging.md b/Documentation/packaging.md index 8393bee81d..016a5cdde6 100644 --- a/Documentation/packaging.md +++ b/Documentation/packaging.md @@ -48,12 +48,13 @@ When the ownership and permissions of `/var/lib/rkt` are set up correctly, membe ### systemd units -A few [example systemd unit files for rkt helper services][rkt-units] are included in the rkt sources. These units demonstrate a systemd-managed, socket-activated rkt [metadata-service][rkt-metadata-svc], along with a convenient periodic [garbage collection][rkt-gc] service invoked at 12-hour intervals to purge dead pods. +A few [example systemd unit files for rkt helper services][rkt-units] are included in the rkt sources. These units demonstrate systemd-managed units to run the rkt [metadata-service][rkt-metadata-svc] with socket-activation, the rkt [api-service][api-service], and a periodic [garbage collection][rkt-gc] service invoked at 12-hour intervals to purge dead pods. [build-config]: build-configure.md [rkt-gc]: subcommands/gc.md [rkt-metadata-svc]: subcommands/metadata-service.md +[api-service]: subcommands/api-service.md [rkt-units]: https://github.com/coreos/rkt/tree/master/dist/init/systemd [build-deps]: dependencies.md#build-time-dependencies [run-deps]: dependencies.md#run-time-dependencies diff --git a/Documentation/subcommands/api-service.md b/Documentation/subcommands/api-service.md index e2795e4d51..160d27712c 100644 --- a/Documentation/subcommands/api-service.md +++ b/Documentation/subcommands/api-service.md @@ -13,6 +13,8 @@ The API service listens for gRPC requests on the address and port specified by t The default is to listen on the loopback interface on port number `15441`, equivalent to invoking `rkt api-service --listen=localhost:15441`. Specify the address `0.0.0.0` to listen on all interfaces. +Typically, the API service will be run via a unit file similar to the one included in the [dist directory](../dist/init/systemd/rkt-api.service). + ## Using the API service The interfaces are defined in the [protobuf here](../../api/v1alpha/api.proto). From c10a4564981918701b8f9aa5b334c21f263ffa1c Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Fri, 17 Jun 2016 21:01:15 +0200 Subject: [PATCH 0412/1304] tests: skip integration tests for dist/ changes --- tests/build-and-run-tests.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/build-and-run-tests.sh b/tests/build-and-run-tests.sh index 2b944ee44b..ddc02a315f 100755 --- a/tests/build-and-run-tests.sh +++ b/tests/build-and-run-tests.sh @@ -255,6 +255,7 @@ function main { DOC_CHANGE_PATTERN="\ -e ^Documentation/ \ + -e ^dist/ \ -e ^logos/ \ -e ^(MAINTAINERS|LICENSE|DCO)$ \ -e \.md$\ From 9b442efb30d8e54dbe043f066e39c8b2f573970c Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Mon, 20 Jun 2016 16:32:57 +0200 Subject: [PATCH 0413/1304] pkg/multicall: strip path from command before matching This commit strips base path from command name before trying multicall matching. It allows for file binaries to be properly run with entrypoint hijacking via multicall. --- pkg/multicall/multicall.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/multicall/multicall.go b/pkg/multicall/multicall.go index 1541c5ddc1..d16455f07c 100644 --- a/pkg/multicall/multicall.go +++ b/pkg/multicall/multicall.go @@ -22,6 +22,7 @@ import ( "fmt" "os" "os/exec" + "path" "syscall" ) @@ -62,7 +63,7 @@ func Add(name string, fn commandFn) Entrypoint { // exit with an exit status of 1, otherwise it will exit with a 0 exit // status. func MaybeExec() { - name := os.Args[0] + name := path.Base(os.Args[0]) if fn, ok := commands[name]; ok { if err := fn(); err != nil { fmt.Fprintln(os.Stderr, err) From 166b5603f24902711ceed01a146e06f9fbbaa671 Mon Sep 17 00:00:00 2001 From: Alessandro Puccetti Date: Sat, 20 Jun 2015 11:12:50 +0200 Subject: [PATCH 0414/1304] rkt/uuid: fix match when uuid is an empty string After the patch, if the uuid is an empty string then matchUUID(uuid string) returns `UUID cannot be empty` error message instead of all the pods. This is done to avoid `rkt rm` or `rkt enter` to delete or enter pods without intending to. Fixes https://github.com/coreos/rkt/issues/2806 --- rkt/uuid.go | 4 ++++ tests/rkt_rm_test.go | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/rkt/uuid.go b/rkt/uuid.go index 3969beeb60..0ca536b6cd 100644 --- a/rkt/uuid.go +++ b/rkt/uuid.go @@ -30,6 +30,10 @@ import ( // matchUUID attempts to match the uuid specified as uuid against all pods present. // An array of matches is returned, which may be empty when nothing matches. func matchUUID(uuid string) ([]string, error) { + if uuid == "" { + return nil, types.ErrNoEmptyUUID + } + ls, err := listPods(includePrepareDir | includePreparedDir | includeRunDir | includeExitedGarbageDir) if err != nil { return nil, err diff --git a/tests/rkt_rm_test.go b/tests/rkt_rm_test.go index c8c4b3a682..6ad66857f9 100644 --- a/tests/rkt_rm_test.go +++ b/tests/rkt_rm_test.go @@ -99,3 +99,14 @@ func TestRmInvalid(t *testing.T) { cmd = fmt.Sprintf("%s rm --uuid-file=%s", ctx.Cmd(), uuidFile) runRktAndCheckOutput(t, cmd, expected, true) } + +func TestRmEmptyUUID(t *testing.T) { + ctx := testutils.NewRktRunCtx() + defer ctx.Cleanup() + + emptyUUID := "\"\"" + expected := fmt.Sprintf("UUID cannot be empty") + + cmd := fmt.Sprintf("%s rm %s", ctx.Cmd(), emptyUUID) + runRktAndCheckOutput(t, cmd, expected, true) +} From f0bed3d8bd8ee55cd0b23f3e82aa7d3a80d7f843 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Thu, 16 Jun 2016 15:47:06 +0200 Subject: [PATCH 0415/1304] Documentation/vagrant: use rkt binary for getting started Currently to get started with rkt we recommend using "vagrant up". This tries to build rkt inside a virtual machine. This cleans up the install-vagrant.sh script to use a released version of rkt instead. It also removes scripts not being used any more. Fixes #2789 --- Documentation/distributions.md | 30 ++++++++ Documentation/getting-started-ubuntu.md | 97 ------------------------- Documentation/trying-out-rkt.md | 57 ++++++++++++++- Vagrantfile | 10 +-- scripts/install-acbuild.sh | 14 ---- scripts/install-common.sh | 12 --- scripts/install-go.sh | 37 ---------- scripts/install-rkt.sh | 65 ++++++++++++++++- scripts/install-vagrant.sh | 21 ------ 9 files changed, 152 insertions(+), 191 deletions(-) delete mode 100644 Documentation/getting-started-ubuntu.md delete mode 100755 scripts/install-acbuild.sh delete mode 100755 scripts/install-common.sh delete mode 100755 scripts/install-go.sh delete mode 100755 scripts/install-vagrant.sh diff --git a/Documentation/distributions.md b/Documentation/distributions.md index e9afb6ba7a..b40c41c75e 100644 --- a/Documentation/distributions.md +++ b/Documentation/distributions.md @@ -7,6 +7,36 @@ The [CoreOS releases page](https://coreos.com/releases/) lists the version of rk If the version of rkt included in CoreOS is too old, it's fairly trivial to fetch the desired version [via a systemd unit](install-rkt-in-coreos.md) +## Debian + +rkt currently is packaged in Debian sid (unstable) available at https://packages.debian.org/sid/utils/rkt: + +``` +sudo apt-get install rkt +``` + +Note that due to an outstanding bug (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=823322) one has to use the "coreos" stage1 image: + +``` +sudo rkt run --insecure-options=image --stage1-name=coreos.com/rkt/stage1-coreos:1.5.1 docker://nginx +``` + +If you prefer to install the newest version of rkt follow the instructions in the Ubuntu section below. + +## Ubuntu + +rkt is not packaged currently in Ubuntu. If you want the newest version of rkt the easiest method to install it is using the `install-rkt.sh` script: + +``` +sudo ./scripts/install-rkt.sh +``` + +The above script will install the "gnupg2", and "checkinstall" packages, download rkt, verify it, and finally invoke "checkinstall" to create a deb pakage and install rkt. To uninstall rkt, execute: + +``` +sudo apt-get remove rkt +``` + ## Fedora rkt is packaged in the development version of Fedora, [Rawhide](https://fedoraproject.org/wiki/Releases/Rawhide): diff --git a/Documentation/getting-started-ubuntu.md b/Documentation/getting-started-ubuntu.md deleted file mode 100644 index 83eb6208e9..0000000000 --- a/Documentation/getting-started-ubuntu.md +++ /dev/null @@ -1,97 +0,0 @@ -# Getting Started with rkt on Ubuntu Wily - -The following guide will show you how to build and run the sample [etcd ACI](https://github.com/coreos/etcd/releases/download/v2.0.9/etcd-v2.0.9-linux-amd64.aci) on the standard vagrantcloud.com [box for Ubuntu Wily](https://vagrantcloud.com/ubuntu/boxes/wily64). - -## Download and start an Ubuntu Wily box - -``` -vagrant init ubuntu/wily64 -vagrant up --provider virtualbox -``` - -## SSH into the VM and install rkt - -``` -vagrant ssh -sudo -s - -wget https://github.com/coreos/rkt/releases/download/v1.8.0/rkt-v1.8.0.tar.gz -tar xzvf rkt-v1.8.0.tar.gz -cd rkt-v1.8.0 -./rkt help -``` - -## Trust the CoreOS signing key - -This shows how to trust the CoreOS signing key using the [`rkt trust` command](https://github.com/coreos/rkt/blob/master/Documentation/commands.md#rkt-trust). - -``` -./rkt trust --prefix=coreos.com/etcd -Prefix: "coreos.com/etcd" -Key: "https://coreos.com/dist/pubkeys/aci-pubkeys.gpg" -GPG key fingerprint is: 8B86 DE38 890D DB72 9186 7B02 5210 BD88 8818 2190 - CoreOS ACI Builder - Are you sure you want to trust this key (yes/no)? - yes - Trusting "https://coreos.com/dist/pubkeys/aci-pubkeys.gpg" for prefix "coreos.com/etcd". - Added key for prefix "coreos.com/etcd" at "/etc/rkt/trustedkeys/prefix.d/coreos.com/etcd/8b86de38890ddb7291867b025210bd8888182190" -``` - -For more details on how signature verification works in rkt, see the [Signing and Verification Guide](https://github.com/coreos/rkt/blob/master/Documentation/signing-and-verification-guide.md). - -## Fetch the ACI - -The simplest way to retrieve the etcd ACI is to use image discovery: - -``` -./rkt fetch coreos.com/etcd:v2.0.9 -rkt: searching for app image coreos.com/etcd:v2.0.9 -rkt: fetching image from https://github.com/coreos/etcd/releases/download/v2.0.9/etcd-v2.0.9-linux-amd64.aci -Downloading signature from https://github.com/coreos/etcd/releases/download/v2.0.9/etcd-v2.0.9-linux-amd64.aci.asc -Downloading ACI: [================================ ] 2.71 MB/3.79 MB -rkt: signature verified: - CoreOS ACI Builder - sha512-91e98d7f1679a097c878203c9659f2a2 -``` - -For more on this and other ways to retrieve ACIs, check out the `rkt fetch` section of the [commands guide](https://github.com/coreos/rkt/blob/master/Documentation/commands.md#rkt-fetch). - -## Run the ACI - -Finally, let's run the application we just retrieved: - -``` -./rkt run coreos.com/etcd:v2.0.9 -rkt: searching for app image coreos.com/etcd:v2.0.9 -rkt: found image in local store, skipping fetching from https://github.com/coreos/etcd/releases/download/v2.0.9/etcd-v2.0.9-linux-amd64.aci -[ 489.734930] etcd[4]: 2015/08/03 08:57:23 etcd: no data-dir provided, using default data-dir ./default.etcd -[ 489.739297] etcd[4]: 2015/08/03 08:57:23 etcd: listening for peers on http://localhost:2380 -[ 489.740653] etcd[4]: 2015/08/03 08:57:23 etcd: listening for peers on http://localhost:7001 -[ 489.741405] etcd[4]: 2015/08/03 08:57:23 etcd: listening for client requests on http://localhost:2379 -[ 489.742178] etcd[4]: 2015/08/03 08:57:23 etcd: listening for client requests on http://localhost:4001 -[ 489.743394] etcd[4]: 2015/08/03 08:57:23 etcdserver: datadir is valid for the 2.0.1 format -[ 489.743977] etcd[4]: 2015/08/03 08:57:23 etcdserver: name = default -[ 489.744707] etcd[4]: 2015/08/03 08:57:23 etcdserver: data dir = default.etcd -[ 489.745374] etcd[4]: 2015/08/03 08:57:23 etcdserver: member dir = default.etcd/member -[ 489.746029] etcd[4]: 2015/08/03 08:57:23 etcdserver: heartbeat = 100ms -[ 489.746688] etcd[4]: 2015/08/03 08:57:23 etcdserver: election = 1000ms -[ 489.747238] etcd[4]: 2015/08/03 08:57:23 etcdserver: snapshot count = 10000 -[ 489.747586] etcd[4]: 2015/08/03 08:57:23 etcdserver: advertise client URLs = http://localhost:2379,http://localhost:4001 -[ 489.747838] etcd[4]: 2015/08/03 08:57:23 etcdserver: initial advertise peer URLs = http://localhost:2380,http://localhost:7001 -[ 489.748232] etcd[4]: 2015/08/03 08:57:23 etcdserver: initial cluster = default=http://localhost:2380,default=http://localhost:7001 -[ 489.750110] etcd[4]: 2015/08/03 08:57:23 etcdserver: start member ce2a822cea30bfca in cluster 7e27652122e8b2ae -[ 489.750588] etcd[4]: 2015/08/03 08:57:23 raft: ce2a822cea30bfca became follower at term 0 -[ 489.750839] etcd[4]: 2015/08/03 08:57:23 raft: newRaft ce2a822cea30bfca [peers: [], term: 0, commit: 0, applied: 0, lastindex: 0, lastterm: 0] -[ 489.751106] etcd[4]: 2015/08/03 08:57:23 raft: ce2a822cea30bfca became follower at term 1 -[ 489.751990] etcd[4]: 2015/08/03 08:57:23 etcdserver: added local member ce2a822cea30bfca [http://localhost:2380 http://localhost:7001] to cluster 7e27652122e8b2ae -[ 491.050049] etcd[4]: 2015/08/03 08:57:25 raft: ce2a822cea30bfca is starting a new election at term 1 -[ 491.051266] etcd[4]: 2015/08/03 08:57:25 raft: ce2a822cea30bfca became candidate at term 2 -[ 491.052159] etcd[4]: 2015/08/03 08:57:25 raft: ce2a822cea30bfca received vote from ce2a822cea30bfca at term 2 -[ 491.053349] etcd[4]: 2015/08/03 08:57:25 raft: ce2a822cea30bfca became leader at term 2 -[ 491.053727] etcd[4]: 2015/08/03 08:57:25 raft.node: ce2a822cea30bfca elected leader ce2a822cea30bfca at term 2 -[ 491.054883] etcd[4]: 2015/08/03 08:57:25 etcdserver: published {Name:default ClientURLs:[http://localhost:2379 http://localhost:4001]} to cluster 7e27652122e8b2ae -``` - -Congratulations! -You've run your first application with rkt. -For more on how to use rkt, check out the [commands guide](https://github.com/coreos/rkt/blob/master/Documentation/commands.md). diff --git a/Documentation/trying-out-rkt.md b/Documentation/trying-out-rkt.md index b8f2b7b2a0..620678485c 100644 --- a/Documentation/trying-out-rkt.md +++ b/Documentation/trying-out-rkt.md @@ -5,7 +5,7 @@ For a more in-depth guide of a full end-to-end workflow of building an applicati ## Using rkt on Linux -rkt consists of a single CLI tool, and is currently supported on amd64 Linux. A modern kernel is required but there should be no other system dependencies. We recommend booting up a fresh virtual machine to test out rkt. +rkt consists of a single CLI tool and can run on different platforms. The primary target platform currently is amd64 Linux. A modern kernel is required but there should be no other system dependencies. To download the rkt binary, simply grab the latest release directly from GitHub: @@ -16,6 +16,10 @@ cd rkt-v1.8.0 ./rkt help ``` +Like most applications, the easiest way to run rkt is to install it with your system's package manager, like apt on Debian or dnf on Fedora. If your distribution doesn't include a rkt package, or your operating system isn't Linux at all, running rkt in a Vagrant virtual machine can be nearly as simple. The instructions below start a virtual machine with rkt installed and ready to run. + +Refer to the [distributions guide](distributions.md) whether a package is available for your Linux distribution. + **SELinux Note**: rkt can use SELinux but the policy needs to be tailored to your distribution. We suggest that new users [disable SELinux](https://www.centos.org/docs/5/html/5.1/Deployment_Guide/sec-sel-enable-disable.html) to get started. If you can help package rkt for your distro [please help](https://github.com/coreos/rkt/issues?utf8=%E2%9C%93&q=is%3Aopen+is%3Aissue+label%3Aarea%2Fdistribution++label%3Adependency%2Fexternal)! ### Optional: Set up Privilege Separation @@ -65,7 +69,7 @@ If you want to run Vagrant on a Linux host machine, you may want to use libvirt ``` vagrant plugin install vagrant-libvirt vagrant plugin install vagrant-mutate -vagrant mutate ubuntu/vivid64 libvirt +vagrant mutate ubuntu/xenial64 libvirt vagrant up --provider=libvirt ``` @@ -76,6 +80,55 @@ vagrant ssh rkt --help ``` +Additional help can be consulted in the rkt man pages: + +``` +man rkt +``` + +The Vagrant setup also includes bash-completion to assist with rkt subcommands and options. + +To reach pods from your host determine the IP address of the Vagrant machine: + +``` +vagrant ssh -c 'ip address' +... +3: enp0s8: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 + link/ether 08:00:27:04:e4:5d brd ff:ff:ff:ff:ff:ff + inet 172.28.128.3/24 brd 172.28.128.255 scope global enp0s8 + valid_lft forever preferred_lft forever +... + +``` + +In the given example the Vagrant machine has the IP address `172.28.128.3`. The following command starts a nginx container using host networking and will be reachable from the host: + +``` +sudo rkt run --net=host --insecure-options=image docker://nginx +``` + +The nginx container is now accessible on the host under http://172.28.128.3. In order to use containers with the default contained network, a route to the 172.16.28.0/24 network has to be configured on the host: + +On Linux execute: +``` +sudo ip route add 172.16.28.0/24 via 172.28.128.3 +``` + +On OSX execute: +``` +sudo route -n add 172.16.28.0/24 172.28.128.3 +``` + +Now nginx can be started using the default network: +``` +$ sudo rkt run --insecure-options=image docker://nginx +$ rkt list +UUID APP IMAGE NAME STATE CREATED STARTED NETWORKS +0c3ab969 nginx registry-1.docker.io/library/nginx:latest running 2 minutes ago 2 minutes ago default:ip4=172.16.28.2 +``` + +The nginx container is now accessible on the host under http://172.16.28.2. + Success! The rest of the guide can now be followed normally. ## rkt basics diff --git a/Vagrantfile b/Vagrantfile index 4edf002652..09511431ff 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,12 +1,10 @@ Vagrant.configure('2') do |config| - # grab Ubuntu 15.10 official image - config.vm.box = "ubuntu/wily64" # Ubuntu 15.10 + config.vm.box = "ubuntu/xenial64" # Ubuntu 16.04 # fix issues with slow dns http://serverfault.com/a/595010 config.vm.provider :virtualbox do |vb, override| vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"] - # add more ram, the default isn't enough for the build vb.customize ["modifyvm", :id, "--memory", "1024"] end @@ -14,6 +12,8 @@ Vagrant.configure('2') do |config| libvirt.memory = 1024 end - config.vm.synced_folder ".", "/vagrant", type: "rsync" - config.vm.provision :shell, :privileged => true, :path => "scripts/install-vagrant.sh" + config.vm.network "private_network", type: "dhcp" + config.vm.provision :shell, :privileged => true, :path => "scripts/install-rkt.sh" + config.vm.provision :shell, :inline => "usermod -a -G rkt-admin ubuntu" + config.vm.provision :shell, :inline => "usermod -a -G rkt ubuntu" end diff --git a/scripts/install-acbuild.sh b/scripts/install-acbuild.sh deleted file mode 100755 index 03dab5d616..0000000000 --- a/scripts/install-acbuild.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -set -e - -if ! [ -e "$PWD/acbuild" ]; then - git clone https://github.com/appc/acbuild -fi - -pushd acbuild - -git pull -./build -cp -v bin/* /usr/local/bin - -popd diff --git a/scripts/install-common.sh b/scripts/install-common.sh deleted file mode 100755 index a94468e305..0000000000 --- a/scripts/install-common.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -set -e - -export DEBIAN_FRONTEND=noninteractive - -apt-get update -apt-get install -y --no-install-recommends ca-certificates gcc libc6-dev make automake wget git coreutils cpio squashfs-tools realpath autoconf file libacl1-dev libtspi-dev bc libsystemd-dev - -./scripts/install-go.sh -. /etc/profile - -./scripts/install-appc-spec.sh diff --git a/scripts/install-go.sh b/scripts/install-go.sh deleted file mode 100755 index 5f21b1841b..0000000000 --- a/scripts/install-go.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -set -e - -export DEBIAN_FRONTEND=noninteractive -VERSION=1.5.3 -OS=linux -ARCH=amd64 - -prefix=/usr/local - -which wget || apt-get install -y wget -# not essential but go get depends on it -which git || apt-get install -y git - -# grab go -if ! [ -e "$prefix/go" ]; then - if ! [ -e "go$VERSION.$OS-$ARCH.tar.gz" ]; then - wget -q https://storage.googleapis.com/golang/go$VERSION.$OS-$ARCH.tar.gz - fi - tar -C $prefix -xzf go$VERSION.$OS-$ARCH.tar.gz -fi - -# setup user environment variables -if ! [ -e "/etc/profile.d/01go.sh" ]; then - echo "export GOROOT=$prefix/go" | tee /etc/profile.d/01go.sh - - cat << 'EOF' | tee -a /etc/profile.d/go.sh - -export GOPATH=$HOME/.gopath - -[ -e $GOPATH ] || mkdir -p $GOPATH - -export PATH=$GOPATH/bin:$GOROOT/bin:$PATH -EOF - -fi diff --git a/scripts/install-rkt.sh b/scripts/install-rkt.sh index 7a3f623926..6ad891b082 100755 --- a/scripts/install-rkt.sh +++ b/scripts/install-rkt.sh @@ -1,6 +1,65 @@ #!/bin/bash - set -e +set -x + +cd $(mktemp -d) + +version="1.8.0" + +export DEBIAN_FRONTEND=noninteractive + +apt-get update +apt-get install -y --no-install-recommends \ + ca-certificates \ + gnupg2 \ + bash-completion \ + checkinstall + +curl -sSL https://coreos.com/dist/pubkeys/app-signing-pubkey.gpg | gpg2 --import - +key=$(gpg2 --with-colons --keyid-format LONG -k security@coreos.com | egrep ^pub | cut -d ':' -f5) + +wget --progress=bar:force https://github.com/coreos/rkt/releases/download/v"${version}"/rkt-v"${version}".tar.gz +wget --progress=bar:force https://github.com/coreos/rkt/releases/download/v"${version}"/rkt-v"${version}".tar.gz.asc +gpg2 --trusted-key "${key}" --verify-files *.asc + +tar xvzf rkt-v"${version}".tar.gz + +cat <install-pak +#!/bin/bash + +for flavor in fly coreos kvm; do + install -Dm644 rkt-v${version}/stage1-\${flavor}.aci /usr/lib/rkt/stage1-images/stage1-\${flavor}.aci +done + +install -Dm755 rkt-v${version}/rkt /usr/bin/rkt + +for f in rkt-v${version}/manpages/*; do + install -Dm644 "\${f}" "/usr/share/man/man1/\$(basename \$f)" +done + +install -Dm644 rkt-v${version}/bash_completion/rkt.bash /usr/share/bash-completion/completions/rkt +install -Dm644 rkt-v${version}/init/systemd/tmpfiles.d/rkt.conf /usr/lib/tmpfiles.d/rkt.conf + +for unit in rkt-gc.{timer,service} rkt-metadata.{socket,service}; do + install -Dm644 rkt-v${version}/init/systemd/\$unit /usr/lib/systemd/system/\$unit +done +EOF +chmod +x install-pak + +cat <preinstall-pak +#!/bin/sh + +groupadd --force --system rkt-admin +groupadd --force --system rkt +EOF +chmod +x preinstall-pak + +cp rkt-v"${version}"/scripts/setup-data-dir.sh postinstall-pak +chmod +x postinstall-pak + +cat <>postinstall-pak +systemctl daemon-reload +systemd-tmpfiles --create /usr/lib/tmpfiles.d/rkt.conf +EOF -BUILDDIR=${BUILDDIR:-$PWD/build-rkt*} -sudo cp -v $BUILDDIR/bin/* /usr/local/bin +checkinstall -y --pkgname=rkt --pkgversion="${version}" ./install-pak diff --git a/scripts/install-vagrant.sh b/scripts/install-vagrant.sh deleted file mode 100755 index 326be704cf..0000000000 --- a/scripts/install-vagrant.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -e - -cd /vagrant - -echo "Installing common dependencies" -./scripts/install-common.sh -. /etc/profile - -echo "Installing acbuild" -./scripts/install-acbuild.sh - -echo "Building rkt" -./scripts/build-rkt.sh > rkt-build.log 2>&1 - -echo "Installing rkt" -./scripts/install-rkt.sh - -groupadd rkt -./dist/scripts/setup-data-dir.sh -usermod -a -G rkt vagrant From ef86fb2f23297633399e93c337a38df44fc88b92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Thu, 16 Jun 2016 11:12:54 +0200 Subject: [PATCH 0416/1304] store: print more information on rm as non-root --- store/store.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/store/store.go b/store/store.go index ee226632a1..77faf17d97 100644 --- a/store/store.go +++ b/store/store.go @@ -548,7 +548,7 @@ func (s *Store) RemoveACI(key string) error { dirUid := int(fi.Sys().(*syscall.Stat_t).Uid) if uid != dirUid && uid != 0 { - return fmt.Errorf("permission denied, are you root or the owner of the image?") + return fmt.Errorf("permission denied on %s, directory owner id (%d) does not match current real id (%d). Are you root or the owner of the image?", path, dirUid, uid) } } From 9e7cd4620b0984ef597d5a571197c54b6f395e92 Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Tue, 21 Jun 2016 13:56:52 +0200 Subject: [PATCH 0417/1304] docs: fix relative link in api-service --- Documentation/subcommands/api-service.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/subcommands/api-service.md b/Documentation/subcommands/api-service.md index 160d27712c..ace2116a09 100644 --- a/Documentation/subcommands/api-service.md +++ b/Documentation/subcommands/api-service.md @@ -13,7 +13,7 @@ The API service listens for gRPC requests on the address and port specified by t The default is to listen on the loopback interface on port number `15441`, equivalent to invoking `rkt api-service --listen=localhost:15441`. Specify the address `0.0.0.0` to listen on all interfaces. -Typically, the API service will be run via a unit file similar to the one included in the [dist directory](../dist/init/systemd/rkt-api.service). +Typically, the API service will be run via a unit file similar to the one included in the [dist directory](../../dist/init/systemd/rkt-api.service). ## Using the API service From 30e5a121e9599976fbb40e0eeb8c7bad203f710b Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Tue, 21 Jun 2016 12:06:18 +0200 Subject: [PATCH 0418/1304] stage1: update coreos image to 1068.0.0 This introduces support for arm64 and aligns to the current base of beta channel. --- stage1/usr_from_coreos/coreos-common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stage1/usr_from_coreos/coreos-common.mk b/stage1/usr_from_coreos/coreos-common.mk index f864f56d6e..75abfb15cd 100644 --- a/stage1/usr_from_coreos/coreos-common.mk +++ b/stage1/usr_from_coreos/coreos-common.mk @@ -11,7 +11,7 @@ $(call setup-tmp-dir,CCN_TMPDIR) # systemd version in coreos image CCN_SYSTEMD_VERSION := v229 # coreos image version -CCN_IMG_RELEASE := 1032.0.0 +CCN_IMG_RELEASE := 1068.0.0 # coreos image URL CCN_IMG_URL := https://alpha.release.core-os.net/amd64-usr/$(CCN_IMG_RELEASE)/coreos_production_pxe_image.cpio.gz # path to downloaded pxe image From 344038ae27460e083f6dc404b0287c26be0a7654 Mon Sep 17 00:00:00 2001 From: Alessandro Puccetti Date: Sat, 20 Jun 2015 10:12:50 +0200 Subject: [PATCH 0419/1304] rkt/run: added --set-env-file switch and priorities for environments --set-env-file gets an environment variables file path in the format "VAR=VALUE\n...". This switch may be used multiple times on the command line to provide multiple environment files. When it used multiple times, it merges each environment file in a single environment and it returns an error if the same variable is set multiple times (either in different files or in the same file). This patch implements priorities among the various way to specify environment variables, from highest to least priority: 1. Command line (--set-env) 2. From files (--set-env-file) 3. Image Manifest 4. Inherit (--inherit-env) A variable in a group with an higher priority will override the value of a variable with the same name in groups with lower priority without producing any error. Variables with unique names will be always preserved. Fixes https://github.com/coreos/rkt/issues/647 --- Documentation/subcommands/prepare.md | 1 + Documentation/subcommands/run.md | 5 +- rkt/prepare.go | 5 +- rkt/run.go | 73 +++++++++++++++++++++++++++- stage0/run.go | 30 ++++++------ tests/env_file_test.conf | 1 + tests/rkt_env_test.go | 12 +++++ 7 files changed, 109 insertions(+), 18 deletions(-) create mode 100644 tests/env_file_test.conf diff --git a/Documentation/subcommands/prepare.md b/Documentation/subcommands/prepare.md index 23ac4bf0e2..419391314b 100644 --- a/Documentation/subcommands/prepare.md +++ b/Documentation/subcommands/prepare.md @@ -44,6 +44,7 @@ c9fad0e6-8236-4fc2-ad17-55d0a4c7d742 | `--private-users` | `false` | `true` or `false` | Run within user namespaces | | `--quiet` | `false` | `true` or `false` | Suppress superfluous output on stdout, print only the UUID on success | | `--set-env` | `` | An environment variable. Syntax `NAME=VALUE` | An environment variable to set for apps | +| `--set-env-file` | `` | Path of an environment variables file | Environment variables to set for apps | | `--signature` | `` | A file path | Local signature file to use in validating the preceding image | | `--stage1-url` | `` | A URL to a stage1 image. HTTP/HTTPS/File/Docker URLs are supported | Image to use as stage1 | | `--stage1-path` | `` | A path to a stage1 image. Absolute and relative paths are supported | Image to use as stage1 | diff --git a/Documentation/subcommands/run.md b/Documentation/subcommands/run.md index 16ad23eab9..dc4aa49b2a 100644 --- a/Documentation/subcommands/run.md +++ b/Documentation/subcommands/run.md @@ -80,11 +80,13 @@ To inherit all environment variables from the parent use the `--inherit-env` fla To explicitly set individual environment variables use the `--set-env` flag. +To explicitly set environment variables from a file use the `--set-env-file` flag. Variables are expected to be in the format `VAR_NAME=VALUE` separated by the new line character `\n`. Lines starting with `#` or `;` and empty ones will be ignored. The precedence is as follows with the last item replacing previous environment entries: - Parent environment - App image environment -- Explicitly set environment +- Explicitly set environment variables from file (`--set-env-file`) +- Explicitly set environment variables on command line (`--set-env`) ``` # export EXAMPLE_ENV=hello @@ -360,6 +362,7 @@ For more details see the [hacking documentation](../hacking.md). | `--port` | none | A port name and number pair | Container port name to expose through host port number. Requires [contained network](../networking/overview.md#contained-mode). Syntax: `--port=NAME:HOSTPORT` The NAME is that given in the ACI. By convention, Docker containers' EXPOSEd ports are given a name formed from the port number, a hyphen, and the protocol, e.g., `80-tcp`, giving something like `--port=80-tcp:8080` | | `--private-users` | `false` | `true` or `false` | Run within user namespaces. | | `--set-env` | none | An environment variable (ex. `--set-env=NAME=VALUE`) | An environment variable to set for apps. | +| `--set-env-file` | `` | Path of an environment variables file (ex. `--set-env-file=/path/to/env/file`) | Environment variables to set for apps | | `--signature` | none | A file path | Local signature file to use in validating the preceding image | | `--stage1-from-dir` | none | Image name (ex. `--stage1-name=coreos.com/rkt/stage1-coreos`) | A stage1 image file name to search for inside the default stage1 images directory. | | `--stage1-hash` | none | Image hash (ex. `--stage1-hash=sha512-dedce9f5ea50`) | A hash of a stage1 image. The image must exist in the store. | diff --git a/rkt/prepare.go b/rkt/prepare.go index 8bcb22f809..a71e673203 100644 --- a/rkt/prepare.go +++ b/rkt/prepare.go @@ -60,6 +60,7 @@ func init() { cmdPrepare.Flags().BoolVar(&flagNoOverlay, "no-overlay", false, "disable overlay filesystem") cmdPrepare.Flags().BoolVar(&flagPrivateUsers, "private-users", false, "run within user namespaces.") cmdPrepare.Flags().Var(&flagExplicitEnv, "set-env", "environment variable to set for apps in the form name=value") + cmdPrepare.Flags().Var(&flagEnvFromFile, "set-env-file", "the path to an environment variables file") cmdPrepare.Flags().BoolVar(&flagStoreOnly, "store-only", false, "use only available images in the store (do not discover or download from remote URLs)") cmdPrepare.Flags().BoolVar(&flagNoStore, "no-store", false, "fetch images ignoring the local store") cmdPrepare.Flags().StringVar(&flagPodManifest, "pod-manifest", "", "the path to the pod manifest. If it's non-empty, then only '--quiet' and '--no-overlay' will have effect") @@ -107,7 +108,8 @@ func runPrepare(cmd *cobra.Command, args []string) (exit int) { return 1 } - if len(flagPodManifest) > 0 && (len(flagPorts) > 0 || flagInheritEnv || !flagExplicitEnv.IsEmpty() || flagStoreOnly || flagNoStore || + if len(flagPodManifest) > 0 && (len(flagPorts) > 0 || flagStoreOnly || flagNoStore || + flagInheritEnv || !flagExplicitEnv.IsEmpty() || !flagEnvFromFile.IsEmpty() || (*appsVolume)(&rktApps).String() != "" || (*appMount)(&rktApps).String() != "" || (*appExec)(&rktApps).String() != "" || (*appUser)(&rktApps).String() != "" || (*appGroup)(&rktApps).String() != "") { stderr.Print("conflicting flags set with --pod-manifest (see --help)") @@ -181,6 +183,7 @@ func runPrepare(cmd *cobra.Command, args []string) (exit int) { pcfg.Ports = []types.ExposedPort(flagPorts) pcfg.InheritEnv = flagInheritEnv pcfg.ExplicitEnv = flagExplicitEnv.Strings() + pcfg.EnvFromFile = flagEnvFromFile.Strings() pcfg.Apps = &rktApps } diff --git a/rkt/run.go b/rkt/run.go index 0634b63005..56271a8be3 100644 --- a/rkt/run.go +++ b/rkt/run.go @@ -17,7 +17,9 @@ package main import ( + "bufio" "fmt" + "os" "strconv" "strings" @@ -57,6 +59,7 @@ image arguments with a lone "---" to resume argument parsing.`, flagPrivateUsers bool flagInheritEnv bool flagExplicitEnv envMap + flagEnvFromFile envFileMap flagInteractive bool flagDNS flagStringList flagDNSSearch flagStringList @@ -81,6 +84,7 @@ func init() { cmdRun.Flags().BoolVar(&flagNoOverlay, "no-overlay", false, "disable overlay filesystem") cmdRun.Flags().BoolVar(&flagPrivateUsers, "private-users", false, "run within user namespaces.") cmdRun.Flags().Var(&flagExplicitEnv, "set-env", "environment variable to set for apps in the form name=value") + cmdRun.Flags().Var(&flagEnvFromFile, "set-env-file", "path to an environment variables file") cmdRun.Flags().BoolVar(&flagInteractive, "interactive", false, "run pod interactively. If true, only one image may be supplied.") cmdRun.Flags().Var(&flagDNS, "dns", "name servers to write in /etc/resolv.conf") cmdRun.Flags().Var(&flagDNSSearch, "dns-search", "DNS search domains to write in /etc/resolv.conf") @@ -150,7 +154,8 @@ func runRun(cmd *cobra.Command, args []string) (exit int) { return 1 } - if len(flagPodManifest) > 0 && (len(flagPorts) > 0 || flagInheritEnv || !flagExplicitEnv.IsEmpty() || rktApps.Count() > 0 || flagStoreOnly || flagNoStore || + if len(flagPodManifest) > 0 && (len(flagPorts) > 0 || rktApps.Count() > 0 || flagStoreOnly || flagNoStore || + flagInheritEnv || !flagExplicitEnv.IsEmpty() || !flagEnvFromFile.IsEmpty() || (*appsVolume)(&rktApps).String() != "" || (*appMount)(&rktApps).String() != "" || (*appExec)(&rktApps).String() != "" || (*appUser)(&rktApps).String() != "" || (*appGroup)(&rktApps).String() != "" || (*appCapsRetain)(&rktApps).String() != "" || (*appCapsRemove)(&rktApps).String() != "") { @@ -249,6 +254,7 @@ func runRun(cmd *cobra.Command, args []string) (exit int) { pcfg.Ports = []types.ExposedPort(flagPorts) pcfg.InheritEnv = flagInheritEnv pcfg.ExplicitEnv = flagExplicitEnv.Strings() + pcfg.EnvFromFile = flagEnvFromFile.Strings() pcfg.Apps = &rktApps } @@ -409,3 +415,68 @@ func (e *envMap) Strings() []string { func (e *envMap) Type() string { return "envMap" } + +// envFileMap +type envFileMap struct { + mapping map[string]string +} + +func skipLine(s []string) bool { + // Empty line + if len(s) == 0 { + return true + } + // Line start with '#' and ';' + if string(s[0][0]) == "#" || string(s[0][0]) == ";" { + return true + } + return false +} + +func (e *envFileMap) Set(s string) error { + if e.mapping == nil { + e.mapping = make(map[string]string) + } + file, err := os.Open(s) + if err != nil { + return err + } + defer file.Close() + + scanner := bufio.NewScanner(file) + for scanner.Scan() { + // TODO parse '\' to skip new line character + pair := strings.SplitN(scanner.Text(), "=", 2) + if skipLine(pair) { + continue + } + if len(pair) != 2 { + return fmt.Errorf("environment variable must be specified as name=value (file %q)", file) + } + if _, exists := e.mapping[pair[0]]; exists { + return fmt.Errorf("environment variable %q already set (file %q)", pair[0], file) + } + e.mapping[pair[0]] = pair[1] + } + return nil +} + +func (e *envFileMap) IsEmpty() bool { + return len(e.mapping) == 0 +} + +func (e *envFileMap) String() string { + return strings.Join(e.Strings(), "\n") +} + +func (e *envFileMap) Strings() []string { + var env []string + for n, v := range e.mapping { + env = append(env, n+"="+v) + } + return env +} + +func (e *envFileMap) Type() string { + return "envFileMap" +} diff --git a/stage0/run.go b/stage0/run.go index f7b5aa1daa..2c0124c7a5 100644 --- a/stage0/run.go +++ b/stage0/run.go @@ -72,6 +72,7 @@ type PrepareConfig struct { Apps *apps.Apps // apps to prepare InheritEnv bool // inherit parent environment into apps ExplicitEnv []string // always set these environment variables for all the apps + EnvFromFile []string // environment variables loaded from files, set for all the apps Ports []types.ExposedPort // list of ports that rkt will expose on the host UseOverlay bool // prepare pod with overlay fs SkipTreeStoreCheck bool // skip checking the treestore before rendering @@ -125,20 +126,14 @@ func debug(format string, i ...interface{}) { } } -// MergeEnvs amends appEnv setting variables in setEnv before setting anything new from os.Environ if inheritEnv = true -// setEnv is expected to be in the os.Environ() key=value format -func MergeEnvs(appEnv *types.Environment, inheritEnv bool, setEnv []string) { - for _, ev := range setEnv { +// mergeEnvs merges environment variables from env into the current appEnv +// if override is set to true, then variables with the same name will be set to the value in env +// env is expected to be in the os.Environ() key=value format +func mergeEnvs(appEnv *types.Environment, env []string, override bool) { + for _, ev := range env { pair := strings.SplitN(ev, "=", 2) - appEnv.Set(pair[0], pair[1]) - } - - if inheritEnv { - for _, ev := range os.Environ() { - pair := strings.SplitN(ev, "=", 2) - if _, exists := appEnv.Get(pair[0]); !exists { - appEnv.Set(pair[0], pair[1]) - } + if _, exists := appEnv.Get(pair[0]); override || !exists { + appEnv.Set(pair[0], pair[1]) } } } @@ -280,9 +275,14 @@ func generatePodManifest(cfg PrepareConfig, dir string) ([]byte, error) { ra.App.Group = group } - if cfg.InheritEnv || len(cfg.ExplicitEnv) > 0 { - MergeEnvs(&ra.App.Environment, cfg.InheritEnv, cfg.ExplicitEnv) + // loading the environment from the lowest priority to highest + if cfg.InheritEnv { + // Inherit environment does not override app image environment + mergeEnvs(&ra.App.Environment, os.Environ(), false) } + + mergeEnvs(&ra.App.Environment, cfg.EnvFromFile, true) + mergeEnvs(&ra.App.Environment, cfg.ExplicitEnv, true) pm.Apps = append(pm.Apps, ra) return nil }); err != nil { diff --git a/tests/env_file_test.conf b/tests/env_file_test.conf new file mode 100644 index 0000000000..caae5bfdea --- /dev/null +++ b/tests/env_file_test.conf @@ -0,0 +1 @@ +VAR_OTHER=file diff --git a/tests/rkt_env_test.go b/tests/rkt_env_test.go index 8456d02204..a1f3ba1316 100644 --- a/tests/rkt_env_test.go +++ b/tests/rkt_env_test.go @@ -78,6 +78,18 @@ var envTests = []struct { `/bin/sh -c "export VAR_OTHER=host ; ^RKT_BIN^ --debug --insecure-options=image run --mds-register=false --interactive --inherit-env=true --set-env=VAR_OTHER=setenv ^SLEEP^"`, `/bin/sh -c "export VAR_OTHER=host ; ^RKT_BIN^ --debug enter $(^RKT_BIN^ list --full|grep running|awk '{print $1}') /inspect --print-env=VAR_OTHER"`, }, + { + `/bin/sh -c "^RKT_BIN^ --debug --insecure-options=image run --mds-register=false --set-env=VAR_OTHER=setenv --set-env-file=env_file_test.conf ^PRINT_VAR_OTHER^"`, + "VAR_OTHER=setenv", + `/bin/sh -c "^RKT_BIN^ --debug --insecure-options=image run --mds-register=false --interactive --set-env=VAR_OTHER=setenv --set-env-file=env_file_test.conf ^SLEEP^"`, + `/bin/sh -c "export VAR_OTHER=host ; ^RKT_BIN^ --debug enter $(^RKT_BIN^ list --full|grep running|awk '{print $1}') /inspect --print-env=VAR_OTHER"`, + }, + { + `/bin/sh -c "^RKT_BIN^ --debug --insecure-options=image run --mds-register=false --set-env-file=env_file_test.conf ^PRINT_VAR_OTHER^"`, + "VAR_OTHER=file", + `/bin/sh -c "^RKT_BIN^ --debug --insecure-options=image run --mds-register=false --interactive --set-env-file=env_file_test.conf ^SLEEP^"`, + `/bin/sh -c "^RKT_BIN^ --debug enter $(^RKT_BIN^ list --full|grep running|awk '{print $1}') /inspect --print-env=VAR_OTHER"`, + }, } func TestEnv(t *testing.T) { From 8cf28c4efd84f390095bd64dc1e272300ad24bcd Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Tue, 21 Jun 2016 17:22:20 +0200 Subject: [PATCH 0420/1304] Doc/subcmd: add missing flags https://github.com/coreos/rkt/pull/2771 previously added --cap-retain and --cap-remove in the "rkt run" command but they were not added in the documentation. This patch adds them. Also, the flags --user and --group were only partially documented. This patch also completes that. --- Documentation/subcommands/prepare.md | 4 ++-- Documentation/subcommands/run.md | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Documentation/subcommands/prepare.md b/Documentation/subcommands/prepare.md index 23ac4bf0e2..4e787350d9 100644 --- a/Documentation/subcommands/prepare.md +++ b/Documentation/subcommands/prepare.md @@ -35,6 +35,7 @@ c9fad0e6-8236-4fc2-ad17-55d0a4c7d742 | Flag | Default | Options | Description | | --- | --- | --- | --- | | `--exec` | none | Path to executable | Override the exec command for the preceding image. | +| `--group` | root | gid, groupname or file path | Group override for the preceding image (example: '--group=group') | | `--inherit-env` | `false` | `true` or `false` | Inherit all environment variables not set by apps. | | `--mount` | none | Mount syntax (ex. `--mount volume=NAME,target=PATH`) | Mount point binding a volume to a path within an app. See [Mounting Volumes without Mount Points](#mounting-volumes-without-mount-points). | | `--no-overlay` | `false` | `true` or `false` | Disable the overlay filesystem. | @@ -51,9 +52,8 @@ c9fad0e6-8236-4fc2-ad17-55d0a4c7d742 | `--stage1-hash` | `` | A hash of a stage1 image. The image must exist in the store | Image to use as stage1 | | `--stage1-from-dir` | `` | A stage1 image file inside the default stage1 images directory | Image to use as stage1 | | `--store-only` | `false` | `true` or `false` | Use only available images in the store (do not discover or download from remote URLs). See [image fetching behavior](../image-fetching-behavior.md) | +| `--user` | none | uid, username or file path | user override for the preceding image (example: '--user=user') | | `--volume` | `` | Volume syntax (`NAME,kind=KIND,source=PATH,readOnly=BOOL`). See [Mount Volumes into a Pod](run.md#mount-volumes-into-a-pod) | Volumes to make available in the pod | -| `--user` | none | username or UID | user override for the preceding image (example: '--user=user') | -| `--group` | none | group or GID | group override for the preceding image (example: '--group=group') | ## Global options diff --git a/Documentation/subcommands/run.md b/Documentation/subcommands/run.md index 16ad23eab9..1ed0aa7b13 100644 --- a/Documentation/subcommands/run.md +++ b/Documentation/subcommands/run.md @@ -342,11 +342,14 @@ For more details see the [hacking documentation](../hacking.md). | Flag | Default | Options | Description | | --- | --- | --- | --- | +| `--cap-remove` | none | capability to remove (example: '--cap-remove=CAP\_SYS\_CHROOT,CAP\_MKNOD') | Capabilities to remove from the process's capabilities bounding set, all others from the default set will be included | +| `--cap-retain` | none | capability to retain (example: '--cap-remove=CAP\_SYS\_ADMIN,CAP\_NET\_ADMIN') | Capabilities to retain in the process's capabilities bounding set, all others will be removed | | `--cpu` | none | CPU units (ex. `--cpu=500m`) | CPU limit for the preceding image in [Kubernetes resource model](https://github.com/kubernetes/kubernetes/blob/release-1.2/docs/design/resources.md) format. | | `--dns` | none | IP Address | Name server to write in `/etc/resolv.conf`. It can be specified several times | | `--dns-opt` | none | DNS option | DNS option from resolv.conf(5) to write in `/etc/resolv.conf`. It can be specified several times. | | `--dns-search` | none | Domain name | DNS search domain to write in `/etc/resolv.conf`. It can be specified several times. | | `--exec` | none | Path to executable | Override the exec command for the preceding image. | +| `--group` | root | gid, groupname or file path | Group override for the preceding image (example: '--group=group') | | `--hostname` | "rkt-$PODUUID" | A host name | Set pod's host name. | | `--inherit-env` | `false` | `true` or `false` | Inherit all environment variables not set by apps. | | `--interactive` | `false` | `true` or `false` | Run pod interactively. If true, only one image may be supplied. | @@ -367,6 +370,7 @@ For more details see the [hacking documentation](../hacking.md). | `--stage1-path` | none | Absolute or relative path | A path to a stage1 image. | | `--stage1-url` | none | URL with protocol | A URL to a stage1 image. HTTP/HTTPS/File/Docker URLs are supported. | | `--store-only` | `false` | `true` or `false` | Use only available images in the store (do not discover or download from remote URLs). See [image fetching behavior](../image-fetching-behavior.md). | +| `--user` | none | uid, username or file path | user override for the preceding image (example: '--user=user') | | `--uuid-file-save` | none | A file path | Write out the pod UUID to a file. | | `--volume` | none | Volume syntax (ex. `--volume NAME,kind=KIND,source=PATH,readOnly=BOOL`) | Volumes to make available in the pod. See [Mount Volumes into a Pod](#mount-volumes-into-a-pod). | From e040d3315c09008894f3db837c7890e20adbdbaa Mon Sep 17 00:00:00 2001 From: Derek Gonyeo Date: Mon, 20 Jun 2016 14:53:53 -0700 Subject: [PATCH 0421/1304] rkt/image: when using heuristics to determine app type, stat first At some point rkt will fall back to using heuristics to determine if the provided image name is referring to an ACI on disk or if it's an image name to perform discovery on / look in the store for. This commit modifies the function that determines this to begin by stat'ing the provided image name. If a file to that exact path exists on disk, that's probably what the user wished to run. --- rkt/image/common.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/rkt/image/common.go b/rkt/image/common.go index d0458f5a34..789f3cf663 100644 --- a/rkt/image/common.go +++ b/rkt/image/common.go @@ -160,7 +160,14 @@ func guessImageType(image string) apps.AppImageType { // Well, at this point is basically heuristics time. The image // parameter can be either a relative path or an image name. - // First, let's check if there is a colon in the image + // First, let's try to stat whatever file the URL would specify. If it + // exists, that's probably what the user wanted. + f, err := os.Stat(image) + if err == nil && f.Mode().IsRegular() { + return apps.AppImagePath + } + + // Second, let's check if there is a colon in the image // parameter. Colon often serves as a paths separator (like in // the PATH environment variable), so if it exists, then it is // highly unlikely that the image parameter is a path. Colon @@ -170,14 +177,14 @@ func guessImageType(image string) apps.AppImageType { return apps.AppImageName } - // Second, let's check if there is a dot followed by a slash + // Third, let's check if there is a dot followed by a slash // (./) - if so, it is likely that the image parameter is path // like ./aci-in-this-dir or ../aci-in-parent-dir if strings.Contains(image, "./") { return apps.AppImagePath } - // Third, let's check if the image parameter has an .aci + // Fourth, let's check if the image parameter has an .aci // extension. If so, likely a path like "stage1-coreos.aci". if filepath.Ext(image) == schema.ACIExtension { return apps.AppImagePath From 05da38501628b99396d28cdb7225c06746a1ac73 Mon Sep 17 00:00:00 2001 From: Derek Gonyeo Date: Tue, 21 Jun 2016 13:50:27 -0700 Subject: [PATCH 0422/1304] pkg/tar: overwrite tests was failing due to not using overwrite flag TestExtractTarOverwrite was failing due to attempting to test the tar package's ability to overwrite files during extraction, but called ExtractTar with the overwrite argument set to false. This went unnoticed since the test is skipped when not run as root, which is the case in our CI. --- pkg/tar/tar_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/tar/tar_test.go b/pkg/tar/tar_test.go index 0363ad86c6..db700b0027 100644 --- a/pkg/tar/tar_test.go +++ b/pkg/tar/tar_test.go @@ -427,7 +427,7 @@ func TestExtractTarOverwrite(t *testing.T) { if !sys.HasChrootCapability() { t.Skipf("chroot capability not available. Disabling test.") } - testExtractTarOverwrite(t, extractTarHelper) + testExtractTarOverwrite(t, extractTarOverwriteHelper) } func TestExtractTarOverwriteInsecure(t *testing.T) { testExtractTarOverwrite(t, extractTarInsecureHelper) @@ -787,6 +787,10 @@ func testExtractTarHardLink(t *testing.T, extractTar func(io.Reader, string) err } } +func extractTarOverwriteHelper(rdr io.Reader, target string) error { + return ExtractTar(rdr, target, true, user.NewBlankUidRange(), nil) +} + func extractTarHelper(rdr io.Reader, target string) error { return extractTarHelperPWL(rdr, target, nil) } From e53e047ee8a0b48b668c39357f81a823fc278e67 Mon Sep 17 00:00:00 2001 From: Rob Szumski Date: Wed, 22 Jun 2016 18:32:10 -0700 Subject: [PATCH 0423/1304] docs: fix list formatting --- Documentation/running-fly-stage1.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/running-fly-stage1.md b/Documentation/running-fly-stage1.md index b391e90754..bcdb9bb35d 100644 --- a/Documentation/running-fly-stage1.md +++ b/Documentation/running-fly-stage1.md @@ -77,6 +77,7 @@ If the image is not in the store, `--stage1-name` will perform discovery and fet By design, the *fly* stage1 does not provide the same isolaton and security features as the default stage1. Specifically, the following constraints are not available when using the *fly* stage1: + - network namespace isolation - CPU isolators - Memory isolators From eb0eb1f7079097e1b6e1a8c50441c3750dce9fc8 Mon Sep 17 00:00:00 2001 From: Alexander Kuleshov Date: Thu, 23 Jun 2016 01:15:41 +0600 Subject: [PATCH 0424/1304] common/cgroup: add mountFsRO() helper function There are some places in the common/cgroup/cgroup.go which contain the same code which collects flags to mount a filesystem in read-only mode and calls mount system call with the given flags and a filesystem source/target. This patch adds mountFsRO() helper function to prevent code duplication. Signed-off-by: Alexander Kuleshov --- common/cgroup/cgroup.go | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/common/cgroup/cgroup.go b/common/cgroup/cgroup.go index d30fc03c30..6211d4d528 100644 --- a/common/cgroup/cgroup.go +++ b/common/cgroup/cgroup.go @@ -349,17 +349,7 @@ func CreateCgroups(root string, enabledCgroups map[int][]string, mountContext st } // Bind-mount cgroup tmpfs filesystem read-only - flags = syscall.MS_BIND | - syscall.MS_REMOUNT | - syscall.MS_NOSUID | - syscall.MS_NOEXEC | - syscall.MS_NODEV | - syscall.MS_RDONLY - if err := syscall.Mount(cgroupTmpfs, cgroupTmpfs, "", flags, ""); err != nil { - return errwrap.Wrap(fmt.Errorf("error remounting RO %q", cgroupTmpfs), err) - } - - return nil + return mountFsRO(cgroupTmpfs) } // RemountCgroupsRO remounts the cgroup hierarchy under root read-only, leaving @@ -370,8 +360,6 @@ func RemountCgroupsRO(root string, enabledCgroups map[int][]string, subcgroup st cgroupTmpfs := filepath.Join(root, "/sys/fs/cgroup") sysPath := filepath.Join(root, "/sys") - var flags uintptr - // Mount RW knobs we need to make the enabled isolators work for _, c := range controllers { cPath := filepath.Join(cgroupTmpfs, c) @@ -403,26 +391,24 @@ func RemountCgroupsRO(root string, enabledCgroups map[int][]string, subcgroup st } // Re-mount controller read-only to prevent the container modifying host controllers - flags = syscall.MS_BIND | - syscall.MS_REMOUNT | - syscall.MS_NOSUID | - syscall.MS_NOEXEC | - syscall.MS_NODEV | - syscall.MS_RDONLY - if err := syscall.Mount(cPath, cPath, "", flags, ""); err != nil { - return errwrap.Wrap(fmt.Errorf("error remounting RO %q", cPath), err) + if err := mountFsRO(cPath); err != nil { + return err } } // Bind-mount sys filesystem read-only - flags = syscall.MS_BIND | + return mountFsRO(sysPath) +} + +func mountFsRO(mountPoint string) error { + var flags uintptr = syscall.MS_BIND | syscall.MS_REMOUNT | syscall.MS_NOSUID | syscall.MS_NOEXEC | syscall.MS_NODEV | syscall.MS_RDONLY - if err := syscall.Mount(sysPath, sysPath, "", flags, ""); err != nil { - return errwrap.Wrap(fmt.Errorf("error remounting RO %q", sysPath), err) + if err := syscall.Mount(mountPoint, mountPoint, "", flags, ""); err != nil { + return errwrap.Wrap(fmt.Errorf("error remounting RO %q", mountPoint), err) } return nil From 3a7d06ab45eb5a11794b2cf0a8bfed260221c998 Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Thu, 23 Jun 2016 12:56:58 +0000 Subject: [PATCH 0425/1304] docs: update docs or the v1.9.0 release --- CHANGELOG.md | 27 +++++++++++++++++++++++++++ ROADMAP.md | 10 ++-------- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e7ebf54dc..a4e669eeab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,30 @@ +## v1.9.0 + +This release focuses on bug fixes and developer tooling and UX improvements. + +#### New features and UX changes + +- rkt/run: added --set-env-file switch and priorities for environments ([#2816](https://github.com/coreos/rkt/pull/2816)). --set-env-file gets an environment variables file path in the format "VAR=VALUE\n...". +- run: add --cap-retain and --cap-remove ([#2771](https://github.com/coreos/rkt/pull/2771)). +- store: print more information on rm as non-root ([#2805](https://github.com/coreos/rkt/pull/2805)). +- Documentation/vagrant: use rkt binary for getting started ([#2808](https://github.com/coreos/rkt/pull/2808)). +- docs: New file in documentation - instruction for new developers in rkt ([#2639](https://github.com/coreos/rkt/pull/2639)). +- stage0/trust: change error message if prefix/root flag missing ([#2661](https://github.com/coreos/rkt/pull/2661)). + +#### Bug fixes + +- rkt/uuid: fix match when uuid is an empty string ([#2807](https://github.com/coreos/rkt/pull/2807)). +- rkt/api_service: fix fly pods ([#2799](https://github.com/coreos/rkt/pull/2799)). +- api/client_example: fix panic if pod has no apps ([#2766](https://github.com/coreos/rkt/pull/2766)). Fixes the concern expressed in https://github.com/coreos/rkt/pull/2763#discussion_r66409260 +- api_service: wait until a pod regs with machined ([#2788](https://github.com/coreos/rkt/pull/2788)). + +#### Other changes + +- stage1: update coreos image to 1068.0.0 ([#2821](https://github.com/coreos/rkt/pull/2821)). +- KVM: Update LKVM patch to mount with mmap mode ([#2795](https://github.com/coreos/rkt/pull/2795)). +- stage1: always write /etc/machine-id ([#2440](https://github.com/coreos/rkt/pull/2440)). Prepare rkt for systemd-v230 in stage1. +- stage1/prepare-app: always adjust /etc/hostname ([#2761](https://github.com/coreos/rkt/pull/2761)). + ## v1.8.0 This release focuses on stabilizing the API service, fixing multiple issues in the logging subsystem. diff --git a/ROADMAP.md b/ROADMAP.md index 73618c88ed..fe304ecde9 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -9,14 +9,6 @@ The version of the spec that rkt implements can be seen in the output of `rkt ve rkt's version 1.0 release marks the command line user interface and on-disk data structures as stable and reliable for external development. The (optional) API for pod inspection is not yet completely stabilized, but is quite usable. - -### rkt 1.9.0 (June) - -- full integration with Kubernetes (aka "rktnetes") -- app-level seccomp support [#1614](https://github.com/coreos/rkt/issues/1614) -- enhanced DNS configuration [#2044](https://github.com/coreos/rkt/issues/2044) -- IPv6 support [appc/cni#31](https://github.com/appc/cni/issues/31) - ### rkt 1.10.0 (July) - stable gRPC [API](https://github.com/coreos/rkt/tree/master/api/v1alpha) @@ -25,6 +17,8 @@ rkt's version 1.0 release marks the command line user interface and on-disk data ### rkt 1.11.0 (July) +- IPv6 support [appc/cni#31](https://github.com/appc/cni/issues/31) +- enhanced DNS configuration [#2044](https://github.com/coreos/rkt/issues/2044) - packaged for more distributions - CentOS [#1305](https://github.com/coreos/rkt/issues/1305) From d6874f787c60b3b4593e58030a2a20b55cc763e2 Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Thu, 23 Jun 2016 12:50:52 +0000 Subject: [PATCH 0426/1304] version: bump to v1.9.0 --- Documentation/running-fly-stage1.md | 4 ++-- Documentation/running-lkvm-stage1.md | 4 ++-- Documentation/subcommands/prepare.md | 2 +- Documentation/subcommands/version.md | 2 +- Documentation/trying-out-rkt.md | 6 +++--- configure.ac | 2 +- scripts/acbuild-rkt-builder.sh | 2 +- scripts/build-rir.sh | 2 +- scripts/install-rkt.sh | 2 +- tests/empty-image/manifest | 2 +- tests/image/manifest | 2 +- tests/rkt_exec_test.go | 2 +- tests/rkt_image_cat_manifest_test.go | 2 +- tests/rkt_image_export_test.go | 2 +- tests/rkt_image_render_test.go | 2 +- tests/rkt_os_arch_test.go | 2 +- 16 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Documentation/running-fly-stage1.md b/Documentation/running-fly-stage1.md index bcdb9bb35d..ee0e433e61 100644 --- a/Documentation/running-fly-stage1.md +++ b/Documentation/running-fly-stage1.md @@ -60,14 +60,14 @@ $ ./autogen.sh && ./configure --with-stage1-flavors=fly && make ``` For more details about configure parameters, see the [configure script parameters documentation](build-configure.md). -This will build the rkt binary and the stage1-fly.aci in `build-rkt-1.8.0+git/bin/`. +This will build the rkt binary and the stage1-fly.aci in `build-rkt-1.9.0+git/bin/`. ### Selecting stage1 at runtime Here is a quick example of how to use a container with the official fly stage1: ``` -# rkt run --stage1-name=coreos.com/rkt/stage1-fly:1.8.0 coreos.com/etcd:v2.2.5 +# rkt run --stage1-name=coreos.com/rkt/stage1-fly:1.9.0 coreos.com/etcd:v2.2.5 ``` If the image is not in the store, `--stage1-name` will perform discovery and fetch the image. diff --git a/Documentation/running-lkvm-stage1.md b/Documentation/running-lkvm-stage1.md index 666b5a6c76..e4b6eadfe1 100644 --- a/Documentation/running-lkvm-stage1.md +++ b/Documentation/running-lkvm-stage1.md @@ -13,7 +13,7 @@ $ ./autogen.sh && ./configure --with-stage1-flavors=kvm && make ``` For more details about configure parameters, see [configure script parameters documentation](build-configure.md). -This will build the rkt binary and the LKVM stage1-kvm.aci in `build-rkt-1.8.0+git/bin/`. +This will build the rkt binary and the LKVM stage1-kvm.aci in `build-rkt-1.9.0+git/bin/`. Provided you have hardware virtualization support and the [kernel KVM module](http://www.linux-kvm.org/page/Getting_the_kvm_kernel_modules) loaded (refer to your distribution for instructions), you can then run an image like you would normally do with rkt: @@ -84,7 +84,7 @@ If you want to run software that requires hypervisor isolation along with truste For example, to use the official lkvm stage1: ``` -# rkt run --stage1-name=coreos.com/rkt/stage1-kvm:1.8.0 coreos.com/etcd:v2.0.9 +# rkt run --stage1-name=coreos.com/rkt/stage1-kvm:1.9.0 coreos.com/etcd:v2.0.9 ... ``` diff --git a/Documentation/subcommands/prepare.md b/Documentation/subcommands/prepare.md index 967fd8d9af..9ca79ab45e 100644 --- a/Documentation/subcommands/prepare.md +++ b/Documentation/subcommands/prepare.md @@ -14,7 +14,7 @@ Therefore, the supported arguments are mostly the same as in `run` except runtim ``` # rkt prepare coreos.com/etcd:v2.0.10 rkt prepare coreos.com/etcd:v2.0.10 -rkt: using image from local store for image name coreos.com/rkt/stage1-coreos:1.8.0 +rkt: using image from local store for image name coreos.com/rkt/stage1-coreos:1.9.0 rkt: searching for app image coreos.com/etcd:v2.0.10 rkt: remote fetching from url https://github.com/coreos/etcd/releases/download/v2.0.10/etcd-v2.0.10-linux-amd64.aci prefix: "coreos.com/etcd" diff --git a/Documentation/subcommands/version.md b/Documentation/subcommands/version.md index b9ff8fe7a1..5a113ebf9a 100644 --- a/Documentation/subcommands/version.md +++ b/Documentation/subcommands/version.md @@ -6,7 +6,7 @@ This command prints the rkt version, the appc version rkt is built against, and ``` $ rkt version -rkt Version: 1.8.0 +rkt Version: 1.9.0 appc Version: 0.7.4 Go Version: go1.5.3 Go OS/Arch: linux/amd64 diff --git a/Documentation/trying-out-rkt.md b/Documentation/trying-out-rkt.md index 620678485c..054dfadadb 100644 --- a/Documentation/trying-out-rkt.md +++ b/Documentation/trying-out-rkt.md @@ -10,9 +10,9 @@ rkt consists of a single CLI tool and can run on different platforms. The primar To download the rkt binary, simply grab the latest release directly from GitHub: ``` -wget https://github.com/coreos/rkt/releases/download/v1.8.0/rkt-v1.8.0.tar.gz -tar xzvf rkt-v1.8.0.tar.gz -cd rkt-v1.8.0 +wget https://github.com/coreos/rkt/releases/download/v1.9.0/rkt-v1.9.0.tar.gz +tar xzvf rkt-v1.9.0.tar.gz +cd rkt-v1.9.0 ./rkt help ``` diff --git a/configure.ac b/configure.ac index 1cb0980034..5cb40a9924 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.63]) -AC_INIT([rkt], [1.8.0+git], [https://github.com/coreos/rkt/issues]) +AC_INIT([rkt], [1.9.0], [https://github.com/coreos/rkt/issues]) AC_DEFUN([RKT_CHECK_PROG], [AS_VAR_IF([$1], [], diff --git a/scripts/acbuild-rkt-builder.sh b/scripts/acbuild-rkt-builder.sh index 4bfe9763d6..9de21556ce 100755 --- a/scripts/acbuild-rkt-builder.sh +++ b/scripts/acbuild-rkt-builder.sh @@ -17,7 +17,7 @@ fi MODIFY=${MODIFY:-""} FLAGS=${FLAGS:-""} IMG_NAME="coreos.com/rkt/builder" -IMG_VERSION=${VERSION:-"v1.8.0+git"} +IMG_VERSION=${VERSION:-"v1.9.0"} ACI_FILE=rkt-builder.aci BUILDDIR=/opt/build-rkt SRC_DIR=/opt/rkt diff --git a/scripts/build-rir.sh b/scripts/build-rir.sh index c18a070acf..fb73cdbe30 100755 --- a/scripts/build-rir.sh +++ b/scripts/build-rir.sh @@ -4,7 +4,7 @@ set -xe SRC_DIR="${SRC_DIR:-$PWD}" BUILDDIR="${BUILDDIR:-$PWD/build-rir}" -RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.8.0+git}" +RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.9.0}" mkdir -p $BUILDDIR diff --git a/scripts/install-rkt.sh b/scripts/install-rkt.sh index 6ad891b082..301832e303 100755 --- a/scripts/install-rkt.sh +++ b/scripts/install-rkt.sh @@ -4,7 +4,7 @@ set -x cd $(mktemp -d) -version="1.8.0" +version="1.9.0" export DEBIAN_FRONTEND=noninteractive diff --git a/tests/empty-image/manifest b/tests/empty-image/manifest index b477c36f3f..17d71a3a9b 100644 --- a/tests/empty-image/manifest +++ b/tests/empty-image/manifest @@ -5,7 +5,7 @@ "labels": [ { "name": "version", - "value": "1.8.0" + "value": "1.9.0" }, { "name": "arch", diff --git a/tests/image/manifest b/tests/image/manifest index 590a406418..ee696ecb3d 100644 --- a/tests/image/manifest +++ b/tests/image/manifest @@ -5,7 +5,7 @@ "labels": [ { "name": "version", - "value": "1.8.0" + "value": "1.9.0" }, { "name": "arch", diff --git a/tests/rkt_exec_test.go b/tests/rkt_exec_test.go index 1565d7a79f..0fbc88ec92 100644 --- a/tests/rkt_exec_test.go +++ b/tests/rkt_exec_test.go @@ -26,7 +26,7 @@ import ( ) const ( - noappManifestStr = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"coreos.com/rkt-inspect","labels":[{"name":"version","value":"1.8.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}]}` + noappManifestStr = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"coreos.com/rkt-inspect","labels":[{"name":"version","value":"1.9.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}]}` ) func TestRunOverrideExec(t *testing.T) { diff --git a/tests/rkt_image_cat_manifest_test.go b/tests/rkt_image_cat_manifest_test.go index c72ba438fe..732e85c968 100644 --- a/tests/rkt_image_cat_manifest_test.go +++ b/tests/rkt_image_cat_manifest_test.go @@ -29,7 +29,7 @@ import ( const ( // The expected image manifest of the 'rkt-inspect-image-cat-manifest.aci'. - manifestTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.8.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.9.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageCatManifest tests 'rkt image cat-manifest', it will: diff --git a/tests/rkt_image_export_test.go b/tests/rkt_image_export_test.go index 5c1f006d08..1edd04f42c 100644 --- a/tests/rkt_image_export_test.go +++ b/tests/rkt_image_export_test.go @@ -28,7 +28,7 @@ import ( ) const ( - manifestExportTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.8.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestExportTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.9.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageExport tests 'rkt image export', it will import some existing diff --git a/tests/rkt_image_render_test.go b/tests/rkt_image_render_test.go index a2bbacb107..0f18001379 100644 --- a/tests/rkt_image_render_test.go +++ b/tests/rkt_image_render_test.go @@ -28,7 +28,7 @@ import ( ) const ( - manifestRenderTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.8.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"dependencies":[{"imageName":"coreos.com/rkt-inspect"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestRenderTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.9.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"dependencies":[{"imageName":"coreos.com/rkt-inspect"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageRender tests 'rkt image render', it will import some existing empty diff --git a/tests/rkt_os_arch_test.go b/tests/rkt_os_arch_test.go index c7236d717f..437c8850af 100644 --- a/tests/rkt_os_arch_test.go +++ b/tests/rkt_os_arch_test.go @@ -27,7 +27,7 @@ import ( ) const ( - manifestOSArchTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.8.0"}ARCH_OS],"app":{"exec":["/inspect", "--print-msg=HelloWorld"],"user":"0","group":"0","workingDirectory":"/"}}` + manifestOSArchTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.9.0"}ARCH_OS],"app":{"exec":["/inspect", "--print-msg=HelloWorld"],"user":"0","group":"0","workingDirectory":"/"}}` ) type osArchTest struct { From fbb131f6f94fafea59e73ff1f89a3f441c40259c Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Thu, 23 Jun 2016 12:50:52 +0000 Subject: [PATCH 0427/1304] version: bump to v1.9.0+git --- configure.ac | 2 +- scripts/acbuild-rkt-builder.sh | 2 +- scripts/build-rir.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 5cb40a9924..03a215da51 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.63]) -AC_INIT([rkt], [1.9.0], [https://github.com/coreos/rkt/issues]) +AC_INIT([rkt], [1.9.0+git], [https://github.com/coreos/rkt/issues]) AC_DEFUN([RKT_CHECK_PROG], [AS_VAR_IF([$1], [], diff --git a/scripts/acbuild-rkt-builder.sh b/scripts/acbuild-rkt-builder.sh index 9de21556ce..5dc1e0e5b8 100755 --- a/scripts/acbuild-rkt-builder.sh +++ b/scripts/acbuild-rkt-builder.sh @@ -17,7 +17,7 @@ fi MODIFY=${MODIFY:-""} FLAGS=${FLAGS:-""} IMG_NAME="coreos.com/rkt/builder" -IMG_VERSION=${VERSION:-"v1.9.0"} +IMG_VERSION=${VERSION:-"v1.9.0+git"} ACI_FILE=rkt-builder.aci BUILDDIR=/opt/build-rkt SRC_DIR=/opt/rkt diff --git a/scripts/build-rir.sh b/scripts/build-rir.sh index fb73cdbe30..5888a61836 100755 --- a/scripts/build-rir.sh +++ b/scripts/build-rir.sh @@ -4,7 +4,7 @@ set -xe SRC_DIR="${SRC_DIR:-$PWD}" BUILDDIR="${BUILDDIR:-$PWD/build-rir}" -RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.9.0}" +RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.9.0+git}" mkdir -p $BUILDDIR From e4c459ebc22912f09691ea4da9dea34f599473b8 Mon Sep 17 00:00:00 2001 From: Alexander Kuleshov Date: Thu, 23 Jun 2016 23:49:27 +0600 Subject: [PATCH 0428/1304] common: remove unused GetImageIDs() This patch removes apps.GetImageIds() method as it has no callers anymore. This helper was added to pass list of image ids to the state0, but now we pass list of apps in a pod instead. Last user of the GetImageIDs() was removed in the 227fe3c commit ( Move pod registration from stage1 to stage0. by @eyakubovich ) and it is not used anywhere anymore. So we can remove it. --- common/apps/apps.go | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/common/apps/apps.go b/common/apps/apps.go index 76c7bc88f8..b00efdb450 100644 --- a/common/apps/apps.go +++ b/common/apps/apps.go @@ -145,13 +145,3 @@ func (al *Apps) GetArgs() [][]string { } return aal } - -// GetImageIDs returns a list of the imageIDs in al, one per app. -// The order reflects the app order in al. -func (al *Apps) GetImageIDs() []types.Hash { - var hl []types.Hash - for _, a := range al.apps { - hl = append(hl, a.ImageID) - } - return hl -} From b678f216f68f1fd9fb6e3d697f60054d2ee4bd7c Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Thu, 23 Jun 2016 14:53:18 -0700 Subject: [PATCH 0429/1304] stage1/fly: use 0755 to create mountpaths This will allow any user to list the content directories. It does not have any effect on the permissions on the mounted files itself. --- stage1_fly/run/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stage1_fly/run/main.go b/stage1_fly/run/main.go index d569f0991a..77cf287ad6 100644 --- a/stage1_fly/run/main.go +++ b/stage1_fly/run/main.go @@ -299,13 +299,13 @@ func stage1() int { switch { case targetPathInfo == nil: absTargetPathParent, _ := filepath.Split(absTargetPath) - if err := os.MkdirAll(absTargetPathParent, 0700); err != nil { + if err := os.MkdirAll(absTargetPathParent, 0755); err != nil { log.PrintE(fmt.Sprintf("can't create directory %q", absTargetPath), err) return 1 } switch { case hostPathInfo == nil || hostPathInfo.IsDir(): - if err := os.Mkdir(absTargetPath, 0700); err != nil { + if err := os.Mkdir(absTargetPath, 0755); err != nil { log.PrintE(fmt.Sprintf("can't create directory %q", absTargetPath), err) return 1 } From 523abfa98cabbdfcbb745040da3c2ddb9911647c Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Thu, 23 Jun 2016 23:59:43 +0200 Subject: [PATCH 0430/1304] Godeps: update go-systemd go-systemd v10 fixes a panic-inducing bug due to returning incorrect Read() length values. --- Godeps/Godeps.json | 20 +++--- .../coreos/go-systemd/sdjournal/read.go | 72 +++++++++++++------ 2 files changed, 61 insertions(+), 31 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 141351f8d0..f0fc34c1db 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -356,28 +356,28 @@ }, { "ImportPath": "github.com/coreos/go-systemd/activation", - "Comment": "v9", - "Rev": "6dc8b843c670f2027cc26b164935635840a40526" + "Comment": "v10", + "Rev": "b32b8467dbea18858bfebf65c1a6a761090f2c31" }, { "ImportPath": "github.com/coreos/go-systemd/dbus", - "Comment": "v9", - "Rev": "6dc8b843c670f2027cc26b164935635840a40526" + "Comment": "v10", + "Rev": "b32b8467dbea18858bfebf65c1a6a761090f2c31" }, { "ImportPath": "github.com/coreos/go-systemd/sdjournal", - "Comment": "v9", - "Rev": "6dc8b843c670f2027cc26b164935635840a40526" + "Comment": "v10", + "Rev": "b32b8467dbea18858bfebf65c1a6a761090f2c31" }, { "ImportPath": "github.com/coreos/go-systemd/unit", - "Comment": "v9", - "Rev": "6dc8b843c670f2027cc26b164935635840a40526" + "Comment": "v10", + "Rev": "b32b8467dbea18858bfebf65c1a6a761090f2c31" }, { "ImportPath": "github.com/coreos/go-systemd/util", - "Comment": "v9", - "Rev": "6dc8b843c670f2027cc26b164935635840a40526" + "Comment": "v10", + "Rev": "b32b8467dbea18858bfebf65c1a6a761090f2c31" }, { "ImportPath": "github.com/coreos/go-tspi/tpmclient", diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/read.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/read.go index 73a0d51e96..71ee806a96 100644 --- a/Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/read.go +++ b/Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/read.go @@ -20,6 +20,7 @@ import ( "fmt" "io" "log" + "strings" "time" ) @@ -46,9 +47,10 @@ type JournalReaderConfig struct { } // JournalReader is an io.ReadCloser which provides a simple interface for iterating through the -// systemd journal. +// systemd journal. A JournalReader is not safe for concurrent use by multiple goroutines. type JournalReader struct { - journal *Journal + journal *Journal + msgReader *strings.Reader } // NewJournalReader creates a new JournalReader with configuration options that are similar to the @@ -101,35 +103,60 @@ func NewJournalReader(config JournalReaderConfig) (*JournalReader, error) { return r, nil } +// Read reads entries from the journal. Read follows the Reader interface so +// it must be able to read a specific amount of bytes. Journald on the other +// hand only allows us to read full entries of arbitrary size (without byte +// granularity). JournalReader is therefore internally buffering entries that +// don't fit in the read buffer. Callers should keep calling until 0 and/or an +// error is returned. func (r *JournalReader) Read(b []byte) (int, error) { var err error - var c int - // Advance the journal cursor - c, err = r.journal.Next() + if r.msgReader == nil { + var c int - // An unexpected error - if err != nil { - return 0, err - } + // Advance the journal cursor. It has to be called at least one time + // before reading + c, err = r.journal.Next() - // EOF detection - if c == 0 { - return 0, io.EOF - } + // An unexpected error + if err != nil { + return 0, err + } - // Build a message - var msg string - msg, err = r.buildMessage() + // EOF detection + if c == 0 { + return 0, io.EOF + } - if err != nil { - return 0, err + // Build a message + var msg string + msg, err = r.buildMessage() + + if err != nil { + return 0, err + } + r.msgReader = strings.NewReader(msg) } // Copy and return the message - copy(b, []byte(msg)) + var sz int + sz, err = r.msgReader.Read(b) + if err == io.EOF { + // The current entry has been fully read. Don't propagate this + // EOF, so the next entry can be read at the next Read() + // iteration. + r.msgReader = nil + return sz, nil + } + if err != nil { + return sz, err + } + if r.msgReader.Len() == 0 { + r.msgReader = nil + } - return len(msg), nil + return sz, nil } // Close closes the JournalReader's handle to the journal. @@ -139,6 +166,7 @@ func (r *JournalReader) Close() error { // Rewind attempts to rewind the JournalReader to the first entry. func (r *JournalReader) Rewind() error { + r.msgReader = nil return r.journal.SeekHead() } @@ -161,7 +189,9 @@ process: return ErrExpired default: if c > 0 { - writer.Write(msg[:c]) + if _, err = writer.Write(msg[:c]); err != nil { + break process + } continue process } } From 0f22bdf4a154d9e0123fc12366a0db5ef3fb08ea Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Fri, 24 Jun 2016 07:12:44 +0000 Subject: [PATCH 0431/1304] docs: update docs for the v1.9.1 release --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4e669eeab..13a60a4a19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## v1.9.1 + +This is a minor bug fix release. + +#### Bug fixes + +- Godeps: update go-systemd ([#2837](https://github.com/coreos/rkt/pull/2837)). go-systemd v10 fixes a panic-inducing bug due to returning incorrect +Read() length values. +- stage1/fly: use 0755 to create mountpaths ([#2836](https://github.com/coreos/rkt/pull/2836)). This will allow any user to list the content directories. It does not +have any effect on the permissions on the mounted files itself. + ## v1.9.0 This release focuses on bug fixes and developer tooling and UX improvements. From 886c62d84158b1164a91bef9b4ca68de4c4e0322 Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Fri, 24 Jun 2016 07:13:06 +0000 Subject: [PATCH 0432/1304] version: bump to v1.9.1 --- Documentation/running-fly-stage1.md | 4 ++-- Documentation/running-lkvm-stage1.md | 4 ++-- Documentation/subcommands/prepare.md | 2 +- Documentation/subcommands/version.md | 2 +- Documentation/trying-out-rkt.md | 6 +++--- configure.ac | 2 +- scripts/acbuild-rkt-builder.sh | 2 +- scripts/build-rir.sh | 2 +- scripts/install-rkt.sh | 2 +- tests/empty-image/manifest | 2 +- tests/image/manifest | 2 +- tests/rkt_exec_test.go | 2 +- tests/rkt_image_cat_manifest_test.go | 2 +- tests/rkt_image_export_test.go | 2 +- tests/rkt_image_render_test.go | 2 +- tests/rkt_os_arch_test.go | 2 +- 16 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Documentation/running-fly-stage1.md b/Documentation/running-fly-stage1.md index ee0e433e61..bfd9be5d52 100644 --- a/Documentation/running-fly-stage1.md +++ b/Documentation/running-fly-stage1.md @@ -60,14 +60,14 @@ $ ./autogen.sh && ./configure --with-stage1-flavors=fly && make ``` For more details about configure parameters, see the [configure script parameters documentation](build-configure.md). -This will build the rkt binary and the stage1-fly.aci in `build-rkt-1.9.0+git/bin/`. +This will build the rkt binary and the stage1-fly.aci in `build-rkt-1.9.1+git/bin/`. ### Selecting stage1 at runtime Here is a quick example of how to use a container with the official fly stage1: ``` -# rkt run --stage1-name=coreos.com/rkt/stage1-fly:1.9.0 coreos.com/etcd:v2.2.5 +# rkt run --stage1-name=coreos.com/rkt/stage1-fly:1.9.1 coreos.com/etcd:v2.2.5 ``` If the image is not in the store, `--stage1-name` will perform discovery and fetch the image. diff --git a/Documentation/running-lkvm-stage1.md b/Documentation/running-lkvm-stage1.md index e4b6eadfe1..fb3c3c541b 100644 --- a/Documentation/running-lkvm-stage1.md +++ b/Documentation/running-lkvm-stage1.md @@ -13,7 +13,7 @@ $ ./autogen.sh && ./configure --with-stage1-flavors=kvm && make ``` For more details about configure parameters, see [configure script parameters documentation](build-configure.md). -This will build the rkt binary and the LKVM stage1-kvm.aci in `build-rkt-1.9.0+git/bin/`. +This will build the rkt binary and the LKVM stage1-kvm.aci in `build-rkt-1.9.1+git/bin/`. Provided you have hardware virtualization support and the [kernel KVM module](http://www.linux-kvm.org/page/Getting_the_kvm_kernel_modules) loaded (refer to your distribution for instructions), you can then run an image like you would normally do with rkt: @@ -84,7 +84,7 @@ If you want to run software that requires hypervisor isolation along with truste For example, to use the official lkvm stage1: ``` -# rkt run --stage1-name=coreos.com/rkt/stage1-kvm:1.9.0 coreos.com/etcd:v2.0.9 +# rkt run --stage1-name=coreos.com/rkt/stage1-kvm:1.9.1 coreos.com/etcd:v2.0.9 ... ``` diff --git a/Documentation/subcommands/prepare.md b/Documentation/subcommands/prepare.md index 9ca79ab45e..223f10d215 100644 --- a/Documentation/subcommands/prepare.md +++ b/Documentation/subcommands/prepare.md @@ -14,7 +14,7 @@ Therefore, the supported arguments are mostly the same as in `run` except runtim ``` # rkt prepare coreos.com/etcd:v2.0.10 rkt prepare coreos.com/etcd:v2.0.10 -rkt: using image from local store for image name coreos.com/rkt/stage1-coreos:1.9.0 +rkt: using image from local store for image name coreos.com/rkt/stage1-coreos:1.9.1 rkt: searching for app image coreos.com/etcd:v2.0.10 rkt: remote fetching from url https://github.com/coreos/etcd/releases/download/v2.0.10/etcd-v2.0.10-linux-amd64.aci prefix: "coreos.com/etcd" diff --git a/Documentation/subcommands/version.md b/Documentation/subcommands/version.md index 5a113ebf9a..c920b975bd 100644 --- a/Documentation/subcommands/version.md +++ b/Documentation/subcommands/version.md @@ -6,7 +6,7 @@ This command prints the rkt version, the appc version rkt is built against, and ``` $ rkt version -rkt Version: 1.9.0 +rkt Version: 1.9.1 appc Version: 0.7.4 Go Version: go1.5.3 Go OS/Arch: linux/amd64 diff --git a/Documentation/trying-out-rkt.md b/Documentation/trying-out-rkt.md index 054dfadadb..d9f85ec241 100644 --- a/Documentation/trying-out-rkt.md +++ b/Documentation/trying-out-rkt.md @@ -10,9 +10,9 @@ rkt consists of a single CLI tool and can run on different platforms. The primar To download the rkt binary, simply grab the latest release directly from GitHub: ``` -wget https://github.com/coreos/rkt/releases/download/v1.9.0/rkt-v1.9.0.tar.gz -tar xzvf rkt-v1.9.0.tar.gz -cd rkt-v1.9.0 +wget https://github.com/coreos/rkt/releases/download/v1.9.1/rkt-v1.9.1.tar.gz +tar xzvf rkt-v1.9.1.tar.gz +cd rkt-v1.9.1 ./rkt help ``` diff --git a/configure.ac b/configure.ac index 03a215da51..49e51ffa16 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.63]) -AC_INIT([rkt], [1.9.0+git], [https://github.com/coreos/rkt/issues]) +AC_INIT([rkt], [1.9.1], [https://github.com/coreos/rkt/issues]) AC_DEFUN([RKT_CHECK_PROG], [AS_VAR_IF([$1], [], diff --git a/scripts/acbuild-rkt-builder.sh b/scripts/acbuild-rkt-builder.sh index 5dc1e0e5b8..11827941b0 100755 --- a/scripts/acbuild-rkt-builder.sh +++ b/scripts/acbuild-rkt-builder.sh @@ -17,7 +17,7 @@ fi MODIFY=${MODIFY:-""} FLAGS=${FLAGS:-""} IMG_NAME="coreos.com/rkt/builder" -IMG_VERSION=${VERSION:-"v1.9.0+git"} +IMG_VERSION=${VERSION:-"v1.9.1"} ACI_FILE=rkt-builder.aci BUILDDIR=/opt/build-rkt SRC_DIR=/opt/rkt diff --git a/scripts/build-rir.sh b/scripts/build-rir.sh index 5888a61836..bbe2abad6a 100755 --- a/scripts/build-rir.sh +++ b/scripts/build-rir.sh @@ -4,7 +4,7 @@ set -xe SRC_DIR="${SRC_DIR:-$PWD}" BUILDDIR="${BUILDDIR:-$PWD/build-rir}" -RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.9.0+git}" +RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.9.1}" mkdir -p $BUILDDIR diff --git a/scripts/install-rkt.sh b/scripts/install-rkt.sh index 301832e303..c2ff2aca68 100755 --- a/scripts/install-rkt.sh +++ b/scripts/install-rkt.sh @@ -4,7 +4,7 @@ set -x cd $(mktemp -d) -version="1.9.0" +version="1.9.1" export DEBIAN_FRONTEND=noninteractive diff --git a/tests/empty-image/manifest b/tests/empty-image/manifest index 17d71a3a9b..b0d661f23d 100644 --- a/tests/empty-image/manifest +++ b/tests/empty-image/manifest @@ -5,7 +5,7 @@ "labels": [ { "name": "version", - "value": "1.9.0" + "value": "1.9.1" }, { "name": "arch", diff --git a/tests/image/manifest b/tests/image/manifest index ee696ecb3d..049cfd66fe 100644 --- a/tests/image/manifest +++ b/tests/image/manifest @@ -5,7 +5,7 @@ "labels": [ { "name": "version", - "value": "1.9.0" + "value": "1.9.1" }, { "name": "arch", diff --git a/tests/rkt_exec_test.go b/tests/rkt_exec_test.go index 0fbc88ec92..17f8215cd8 100644 --- a/tests/rkt_exec_test.go +++ b/tests/rkt_exec_test.go @@ -26,7 +26,7 @@ import ( ) const ( - noappManifestStr = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"coreos.com/rkt-inspect","labels":[{"name":"version","value":"1.9.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}]}` + noappManifestStr = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"coreos.com/rkt-inspect","labels":[{"name":"version","value":"1.9.1"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}]}` ) func TestRunOverrideExec(t *testing.T) { diff --git a/tests/rkt_image_cat_manifest_test.go b/tests/rkt_image_cat_manifest_test.go index 732e85c968..fd7bcd5ff5 100644 --- a/tests/rkt_image_cat_manifest_test.go +++ b/tests/rkt_image_cat_manifest_test.go @@ -29,7 +29,7 @@ import ( const ( // The expected image manifest of the 'rkt-inspect-image-cat-manifest.aci'. - manifestTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.9.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.9.1"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageCatManifest tests 'rkt image cat-manifest', it will: diff --git a/tests/rkt_image_export_test.go b/tests/rkt_image_export_test.go index 1edd04f42c..1ffbebcf07 100644 --- a/tests/rkt_image_export_test.go +++ b/tests/rkt_image_export_test.go @@ -28,7 +28,7 @@ import ( ) const ( - manifestExportTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.9.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestExportTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.9.1"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageExport tests 'rkt image export', it will import some existing diff --git a/tests/rkt_image_render_test.go b/tests/rkt_image_render_test.go index 0f18001379..460925aed5 100644 --- a/tests/rkt_image_render_test.go +++ b/tests/rkt_image_render_test.go @@ -28,7 +28,7 @@ import ( ) const ( - manifestRenderTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.9.0"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"dependencies":[{"imageName":"coreos.com/rkt-inspect"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` + manifestRenderTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.9.1"},{"name":"arch","value":"amd64"},{"name":"os","value":"linux"}],"dependencies":[{"imageName":"coreos.com/rkt-inspect"}],"app":{"exec":["/inspect"],"user":"0","group":"0","workingDirectory":"/","environment":[{"name":"VAR_FROM_MANIFEST","value":"manifest"}]}}` ) // TestImageRender tests 'rkt image render', it will import some existing empty diff --git a/tests/rkt_os_arch_test.go b/tests/rkt_os_arch_test.go index 437c8850af..ff130222c0 100644 --- a/tests/rkt_os_arch_test.go +++ b/tests/rkt_os_arch_test.go @@ -27,7 +27,7 @@ import ( ) const ( - manifestOSArchTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.9.0"}ARCH_OS],"app":{"exec":["/inspect", "--print-msg=HelloWorld"],"user":"0","group":"0","workingDirectory":"/"}}` + manifestOSArchTemplate = `{"acKind":"ImageManifest","acVersion":"0.7.4","name":"IMG_NAME","labels":[{"name":"version","value":"1.9.1"}ARCH_OS],"app":{"exec":["/inspect", "--print-msg=HelloWorld"],"user":"0","group":"0","workingDirectory":"/"}}` ) type osArchTest struct { From 022d8772b8c9f3cca844845a7cf4b678cedaa845 Mon Sep 17 00:00:00 2001 From: Tamer Tas Date: Fri, 24 Jun 2016 07:13:06 +0000 Subject: [PATCH 0433/1304] version: bump to v1.9.1+git --- configure.ac | 2 +- scripts/acbuild-rkt-builder.sh | 2 +- scripts/build-rir.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 49e51ffa16..2a3dde581c 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.63]) -AC_INIT([rkt], [1.9.1], [https://github.com/coreos/rkt/issues]) +AC_INIT([rkt], [1.9.1+git], [https://github.com/coreos/rkt/issues]) AC_DEFUN([RKT_CHECK_PROG], [AS_VAR_IF([$1], [], diff --git a/scripts/acbuild-rkt-builder.sh b/scripts/acbuild-rkt-builder.sh index 11827941b0..01258ed61c 100755 --- a/scripts/acbuild-rkt-builder.sh +++ b/scripts/acbuild-rkt-builder.sh @@ -17,7 +17,7 @@ fi MODIFY=${MODIFY:-""} FLAGS=${FLAGS:-""} IMG_NAME="coreos.com/rkt/builder" -IMG_VERSION=${VERSION:-"v1.9.1"} +IMG_VERSION=${VERSION:-"v1.9.1+git"} ACI_FILE=rkt-builder.aci BUILDDIR=/opt/build-rkt SRC_DIR=/opt/rkt diff --git a/scripts/build-rir.sh b/scripts/build-rir.sh index bbe2abad6a..ad660ef659 100755 --- a/scripts/build-rir.sh +++ b/scripts/build-rir.sh @@ -4,7 +4,7 @@ set -xe SRC_DIR="${SRC_DIR:-$PWD}" BUILDDIR="${BUILDDIR:-$PWD/build-rir}" -RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.9.1}" +RKT_BUILDER_ACI="${RKT_BUILDER_ACI:-coreos.com/rkt/builder:v1.9.1+git}" mkdir -p $BUILDDIR From 2810a4c164fc61e3146e3b2fc608cc87f3c599a3 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Fri, 24 Jun 2016 14:24:54 +0200 Subject: [PATCH 0434/1304] tests: fix abuses of appc types.Isolator appc 0.8.5 perform stricter validation on types.Isolator instances, and some rkt tests would fail due to library misuses. This commit switches to proper unmarshaling to construct those instances. --- tests/rkt_run_pod_manifest_test.go | 60 +++++++++++++----------------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/tests/rkt_run_pod_manifest_test.go b/tests/rkt_run_pod_manifest_test.go index 7ff003ca63..321a2d60ab 100644 --- a/tests/rkt_run_pod_manifest_test.go +++ b/tests/rkt_run_pod_manifest_test.go @@ -17,7 +17,6 @@ package main import ( - "encoding/json" "fmt" "io/ioutil" "os" @@ -59,19 +58,12 @@ func verifyHostFile(t *testing.T, tmpdir, filename string, i int, expectedResult } } -func rawValue(value string) *json.RawMessage { - msg := json.RawMessage(value) - return &msg -} - -func rawRequestLimit(request, limit string) *json.RawMessage { - if request == "" { - return rawValue(fmt.Sprintf(`{"limit":%q}`, limit)) - } - if limit == "" { - return rawValue(fmt.Sprintf(`{"request":%q}`, request)) +func mustNewIsolator(body string) (i types.Isolator) { + err := i.UnmarshalJSON([]byte(body)) + if err != nil { + panic(err) } - return rawValue(fmt.Sprintf(`{"request":%q,"limit":%q}`, request, limit)) + return } type imagePatch struct { @@ -735,14 +727,14 @@ func TestPodManifest(t *testing.T) { User: "0", Group: "0", Isolators: []types.Isolator{ - { - Name: "resource/cpu", - ValueRaw: rawRequestLimit("100", "100"), - }, - { - Name: "os/linux/capabilities-retain-set", - ValueRaw: rawValue(`{"set":["CAP_SYS_PTRACE"]}`), - }, + mustNewIsolator(`{ + "name": "resource/cpu", + "value": { "request": "100", "limit": "100"} + }`), + mustNewIsolator(`{ + "name": "os/linux/capabilities-retain-set", + "value": { "set": ["CAP_SYS_PTRACE"] } + }`), }, }, }, @@ -766,15 +758,15 @@ func TestPodManifest(t *testing.T) { User: "0", Group: "0", Isolators: []types.Isolator{ - { - Name: "resource/memory", - // 4MB. - ValueRaw: rawRequestLimit("4194304", "4194304"), - }, - { - Name: "os/linux/capabilities-retain-set", - ValueRaw: rawValue(`{"set":["CAP_SYS_PTRACE"]}`), - }, + // 4MB. + mustNewIsolator(`{ + "name": "resource/memory", + "value": { "request": "4194304", "limit": "4194304"} + }`), + mustNewIsolator(`{ + "name": "os/linux/capabilities-retain-set", + "value": { "set": ["CAP_SYS_PTRACE"] } + }`), }, }, }, @@ -872,10 +864,10 @@ func TestPodManifest(t *testing.T) { {"CAPABILITY", strconv.Itoa(int(capability.CAP_NET_ADMIN))}, }, Isolators: []types.Isolator{ - { - Name: "os/linux/capabilities-retain-set", - ValueRaw: rawValue(fmt.Sprintf(`{"set":["CAP_NET_ADMIN"]}`)), - }, + mustNewIsolator(`{ + "name": "os/linux/capabilities-retain-set", + "value": { "set": ["CAP_NET_ADMIN"] } + }`), }, }, }, From b0a9822e545a4cd756e45ff01cbafb8d7aec3b4e Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Mon, 27 Jun 2016 11:21:48 -0700 Subject: [PATCH 0435/1304] build: Remove unused variable The makefile variable MAKETOOLSDIR is unused, so remove it. Signed-off-by: Geoff Levand --- makelib/variables.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/makelib/variables.mk b/makelib/variables.mk index 73f16298ae..1d53452728 100644 --- a/makelib/variables.mk +++ b/makelib/variables.mk @@ -4,7 +4,6 @@ REPO_PATH := $(ORG_PATH)/rkt override BUILDDIR := $(abspath $(BUILDDIR)) -MAKETOOLSDIR := $(MK_TOPLEVEL_SRCDIR)/tools STAMPSDIR := $(BUILDDIR)/stamps TOOLSDIR := $(BUILDDIR)/tools BINDIR := $(BUILDDIR)/bin From f854dc04e93aebe85d154955ff4a2648c934c3f5 Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Mon, 27 Jun 2016 11:21:48 -0700 Subject: [PATCH 0436/1304] build: Verbose go builds To aid in debugging go build problems, add go verbosity flags when the make variable V is set. Signed-off-by: Geoff Levand --- makelib/build_go_bin.mk | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/makelib/build_go_bin.mk b/makelib/build_go_bin.mk index a1d276d92d..4ae8b2a528 100644 --- a/makelib/build_go_bin.mk +++ b/makelib/build_go_bin.mk @@ -41,12 +41,16 @@ _BGB_PKG_NAME_ := $(REPO_PATH)/$(BGB_PKG_IN_REPO) $(call setup-dep-file,_BGB_GO_DEPMK,$(_BGB_PKG_NAME_)) $(call setup-dep-file,_BGB_KV_DEPMK,$(_BGB_PKG_NAME_)/kv) +VERBOSE_1 := -v +VERBOSE_2 := -v +VERBOSE_3 := -v -x + $(call forward-vars,$(BGB_BINARY), \ BGB_ADDITIONAL_GO_ENV GO_ENV GO BGB_GO_FLAGS _BGB_PKG_NAME_) $(BGB_BINARY): $(_BGB_PATH_) $(_BGB_RKT_SYMLINK_STAMP_) $(VQ) \ $(call vb,vt,GO,$(call vsg,$(_BGB_PKG_NAME_))) \ - $(BGB_ADDITIONAL_GO_ENV) $(GO_ENV) "$(GO)" build -o "$@" $(BGB_GO_FLAGS) "$(_BGB_PKG_NAME_)" + $(BGB_ADDITIONAL_GO_ENV) $(GO_ENV) "$(GO)" build $(VERBOSE_$(V)) -o "$@" $(BGB_GO_FLAGS) "$(_BGB_PKG_NAME_)" $(call generate-go-deps,$(_BGB_GO_DEPMK_STAMP_),$(BGB_BINARY),$(_BGB_GO_DEPMK),$(BGB_PKG_IN_REPO)) $(call generate-kv-deps,$(_BGB_KV_DEPMK_STAMP_),$(BGB_BINARY),$(_BGB_KV_DEPMK),BGB_GO_FLAGS) From 83bd7b851454f8302bbc6d341bec22e9cbd887eb Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Mon, 27 Jun 2016 11:21:49 -0700 Subject: [PATCH 0437/1304] build: Output makefile compiler variables To allow for cross compile builds, output CC and CXX to the makefile. Signed-off-by: Geoff Levand --- Makefile.in | 2 ++ configure.ac | 3 +++ 2 files changed, 5 insertions(+) diff --git a/Makefile.in b/Makefile.in index d668af0f64..d39fc6fe90 100644 --- a/Makefile.in +++ b/Makefile.in @@ -7,6 +7,8 @@ all: INSTALL = @INSTALL@ # binaries we need to build things +CC := @CC@ +CXX := @CXX@ GO := @GOBINARY@ GOFMT := @GOFMTBINARY@ GIT := @GIT@ diff --git a/configure.ac b/configure.ac index 2a3dde581c..df82f6df81 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,9 @@ AC_PREREQ([2.63]) AC_INIT([rkt], [1.9.1+git], [https://github.com/coreos/rkt/issues]) +AC_PROG_CC +AC_PROG_CXX + AC_DEFUN([RKT_CHECK_PROG], [AS_VAR_IF([$1], [], [AC_CHECK_PROG($@)],[:])]) From 25ee2968cf47666d2cfdd84429534820710c68fb Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Mon, 27 Jun 2016 11:21:49 -0700 Subject: [PATCH 0438/1304] build: Output makefile arch variables To allow the build system to target multiple architectures, add the new arch related makefile variables GOARCH, RKT_ACI_ARCH, and RKT_STAGE1_COREOS_BOARD. Signed-off-by: Geoff Levand --- Makefile.in | 5 +++++ configure.ac | 18 ++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Makefile.in b/Makefile.in index d39fc6fe90..01c6cd5efc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -23,6 +23,7 @@ RKT_TAGS := -tags "selinux @TPM_TAGS@" # stage1 build mode RKT_VERSION := @RKT_VERSION@ +RKT_ACI_ARCH := @RKT_ACI_ARCH@ RKT_STAGE1_VERSION_OVERRIDE := @RKT_STAGE1_FLAVORS_VERSION_OVERRIDE@ RKT_STAGE1_DEFAULT_NAME := @RKT_STAGE1_DEFAULT_NAME@ @@ -41,11 +42,15 @@ RKT_STAGE1_SYSTEMD_VER := @RKT_STAGE1_SYSTEMD_VER@ RKT_LOCAL_COREOS_PXE_IMAGE_PATH := @RKT_LOCAL_COREOS_PXE_IMAGE_PATH@ RKT_LOCAL_COREOS_PXE_IMAGE_SYSTEMD_VER := @RKT_LOCAL_COREOS_PXE_IMAGE_SYSTEMD_VER@ + +RKT_STAGE1_COREOS_BOARD := @RKT_STAGE1_COREOS_BOARD@ + # defines for enter RKT_DEFINES_FOR_ENTER := @RKT_DEFINES_FOR_ENTER@ RKT_RUN_FUNCTIONAL_TESTS := @RKT_RUN_FUNCTIONAL_TESTS@ +GOARCH := @GOARCH@ GOARCH_FOR_BUILD := @GOARCH_FOR_BUILD@ RKT_STAGE1_DEFAULT_NAME_LDFLAGS := @RKT_STAGE1_DEFAULT_NAME_LDFLAGS@ diff --git a/configure.ac b/configure.ac index df82f6df81..e8863160a8 100644 --- a/configure.ac +++ b/configure.ac @@ -41,6 +41,11 @@ AS_IF([test `expr match 'AC_PACKAGE_VERSION' '.*+git$'` -gt 0], AC_CANONICAL_HOST AC_CANONICAL_BUILD +AS_CASE([${host_cpu}], + [aarch64], [RKT_ACI_ARCH=aarch64; GOARCH=arm64;], + [x86_64], [RKT_ACI_ARCH=amd64; GOARCH=amd64;], + [AC_MSG_ERROR([*** unsupported host architecture specified: ${host_cpu}])]) + #### FLAGS ## STAGE1 - detailed setup @@ -119,6 +124,8 @@ AC_ARG_WITH([coreos-local-pxe-image-systemd-version], [RKT_LOCAL_COREOS_PXE_IMAGE_SYSTEMD_VER="${withval}"], [RKT_LOCAL_COREOS_PXE_IMAGE_SYSTEMD_VER=]) +RKT_STAGE1_COREOS_BOARD=${GOARCH}-usr; + ## Functional tests AC_ARG_ENABLE([functional-tests], @@ -653,6 +660,7 @@ RKT_FEATURES_LDFLAGS="-X 'main.rktFeatures=${RKT_FEATURES}'" #### SUBSTITUTIONS AC_SUBST(RKT_VERSION) +AC_SUBST(RKT_ACI_ARCH) AC_SUBST(RKT_STAGE1_FLAVORS_VERSION_OVERRIDE) AC_SUBST(RKT_STAGE1_DEFAULT_NAME) @@ -672,8 +680,11 @@ AC_SUBST(RKT_STAGE1_SYSTEMD_VER) AC_SUBST(RKT_LOCAL_COREOS_PXE_IMAGE_PATH) AC_SUBST(RKT_LOCAL_COREOS_PXE_IMAGE_SYSTEMD_VER) +AC_SUBST(RKT_STAGE1_COREOS_BOARD) + AC_SUBST(RKT_RUN_FUNCTIONAL_TESTS) +AC_SUBST(GOARCH) AC_SUBST(GOARCH_FOR_BUILD) AC_SUBST(RKT_STAGE1_DEFAULT_NAME_LDFLAGS) @@ -724,7 +735,8 @@ RKT_IF_HAS_FLAVOR([${RKT_STAGE1_FLAVORS}], [coreos,kvm], coreos/kvm flavor specific build parameters local CoreOS PXE image path: '${RKT_LOCAL_COREOS_PXE_IMAGE_PATH}' - local CoreOS PXE image systemd version: '${RKT_LOCAL_COREOS_PXE_IMAGE_SYSTEMD_VER}'])]) + local CoreOS PXE image systemd version: '${RKT_LOCAL_COREOS_PXE_IMAGE_SYSTEMD_VER}' + stage1 CoreOS board: '${RKT_STAGE1_COREOS_BOARD}'])]) RKT_IF_HAS_FLAVOR([${RKT_STAGE1_FLAVORS}], [src], [AC_MSG_RESULT([ @@ -738,4 +750,6 @@ AC_MSG_RESULT([ functional tests enabled: '${RKT_RUN_FUNCTIONAL_TESTS}' features: '${RKT_FEATURES}' - go version: '${GO_VERSION}']) + ACI arch: '${RKT_ACI_ARCH}' + go version: '${GO_VERSION}' + go arch: '${GOARCH}']) From 2656c561f50911f23189dc58b54b65404dd6d207 Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Mon, 27 Jun 2016 11:21:49 -0700 Subject: [PATCH 0439/1304] build: Make BGB_ADDITIONAL_GO_ENV override GO_ENV To allow GO_ENV to be the default environment, and for BGB_ADDITIONAL_GO_ENV to override that default when needed, switch the order of the two on the go invocation. Signed-off-by: Geoff Levand --- makelib/build_go_bin.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makelib/build_go_bin.mk b/makelib/build_go_bin.mk index 4ae8b2a528..8ceec59fcf 100644 --- a/makelib/build_go_bin.mk +++ b/makelib/build_go_bin.mk @@ -50,7 +50,7 @@ $(call forward-vars,$(BGB_BINARY), \ $(BGB_BINARY): $(_BGB_PATH_) $(_BGB_RKT_SYMLINK_STAMP_) $(VQ) \ $(call vb,vt,GO,$(call vsg,$(_BGB_PKG_NAME_))) \ - $(BGB_ADDITIONAL_GO_ENV) $(GO_ENV) "$(GO)" build $(VERBOSE_$(V)) -o "$@" $(BGB_GO_FLAGS) "$(_BGB_PKG_NAME_)" + $(GO_ENV) $(BGB_ADDITIONAL_GO_ENV) "$(GO)" build $(VERBOSE_$(V)) -o "$@" $(BGB_GO_FLAGS) "$(_BGB_PKG_NAME_)" $(call generate-go-deps,$(_BGB_GO_DEPMK_STAMP_),$(BGB_BINARY),$(_BGB_GO_DEPMK),$(BGB_PKG_IN_REPO)) $(call generate-kv-deps,$(_BGB_KV_DEPMK_STAMP_),$(BGB_BINARY),$(_BGB_KV_DEPMK),BGB_GO_FLAGS) From eff2aeb935585acadeaad5eb6e4865eee3660eda Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Mon, 27 Jun 2016 11:21:49 -0700 Subject: [PATCH 0440/1304] build: Setup GO_ENV for cross compile Signed-off-by: Geoff Levand --- makelib/variables.mk | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/makelib/variables.mk b/makelib/variables.mk index 1d53452728..27b4c79064 100644 --- a/makelib/variables.mk +++ b/makelib/variables.mk @@ -24,7 +24,13 @@ QUICKRMTOOL := $(TOOLSDIR)/quickrm GO_TEST_PACKAGES ?= ./... GO_TEST_FUNC_ARGS ?= -GO_ENV := $(strip GOPATH="$(GOPATH)" $(if $(strip $(GOROOT)),GOROOT=$(strip $(GOROOT)))) +GO_ENV := $(strip \ + GOARCH="$(GOARCH)" \ + CGO_ENABLED=1 \ + CC="$(CC)" \ + CXX="$(CXX)" \ + GOPATH="$(GOPATH)" \ + $(if $(strip $(GOROOT)),GOROOT="$(strip $(GOROOT))")) CREATE_DIRS += \ $(BUILDDIR) \ From 3aac0aecd6b31289f33a101a27b63c4bb00b4c13 Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Mon, 27 Jun 2016 11:21:49 -0700 Subject: [PATCH 0441/1304] actool: Move to TOOLSDIR The generated actool is a host tool, so move it to the TOOLSDIR. Signed-off-by: Geoff Levand --- makelib/variables.mk | 2 +- tools/actool.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/makelib/variables.mk b/makelib/variables.mk index 27b4c79064..43a1777e0d 100644 --- a/makelib/variables.mk +++ b/makelib/variables.mk @@ -14,7 +14,7 @@ FILELISTDIR := $(BUILDDIR)/filelists MAINTEMPDIR := $(BUILDDIR)/tmp CLEANDIR := $(BUILDDIR)/clean -ACTOOL := $(BINDIR)/actool +ACTOOL := $(TOOLSDIR)/actool DEPSGENTOOL := $(TOOLSDIR)/depsgen FILELISTGENTOOL := $(TOOLSDIR)/filelistgen CLEANGENTOOL := $(TOOLSDIR)/cleangen diff --git a/tools/actool.mk b/tools/actool.mk index 1e07c95f14..4d341b4d50 100644 --- a/tools/actool.mk +++ b/tools/actool.mk @@ -10,7 +10,7 @@ CLEAN_FILES += $(ACTOOL) $(call generate-stamp-rule,$(ACTOOL_STAMP)) -$(ACTOOL): $(MK_PATH) | $(BINDIR) +$(ACTOOL): $(MK_PATH) | $(TOOLSDIR) include makelib/build_go_bin.mk From 3cff20f1d6ce6ad9c52829e943bf46d0df225674 Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Mon, 27 Jun 2016 11:21:49 -0700 Subject: [PATCH 0442/1304] build: Add target directories Create new makfile variables TARGET_BINDIR and TARGET_TOOLSDIR to hold files for use within the target image. Files intended to be used on the host at build time will continue to be located in TOOLSDIR. Signed-off-by: Geoff Levand --- makelib/variables.mk | 8 ++++++-- rkt/rkt.mk | 4 ++-- stage1/makelib/aci_simple_go_bin.mk | 4 ++-- stage1/makelib/aci_simple_static_c_bin.mk | 4 ++-- stage1/net-plugins/net-plugins.mk | 4 ++-- stage1/stage1.mk | 4 ++-- stage1_fly/stage1_fly.mk | 4 ++-- tests/functional.mk | 2 +- 8 files changed, 19 insertions(+), 15 deletions(-) diff --git a/makelib/variables.mk b/makelib/variables.mk index 43a1777e0d..eabc804a02 100644 --- a/makelib/variables.mk +++ b/makelib/variables.mk @@ -6,7 +6,9 @@ override BUILDDIR := $(abspath $(BUILDDIR)) STAMPSDIR := $(BUILDDIR)/stamps TOOLSDIR := $(BUILDDIR)/tools -BINDIR := $(BUILDDIR)/bin +TARGETDIR := $(BUILDDIR)/target +TARGET_BINDIR := $(BUILDDIR)/target/bin +TARGET_TOOLSDIR := $(BUILDDIR)/target/tools GOPATH_TO_CREATE := $(BUILDDIR)/gopath GOPATH := $(GOPATH_TO_CREATE)/src/github.com/coreos/rkt/Godeps/_workspace:$(GOPATH_TO_CREATE) DEPSDIR := $(BUILDDIR)/deps @@ -36,7 +38,9 @@ CREATE_DIRS += \ $(BUILDDIR) \ $(STAMPSDIR) \ $(TOOLSDIR) \ - $(BINDIR) \ + $(TARGETDIR) \ + $(TARGET_BINDIR) \ + $(TARGET_TOOLSDIR) \ $(GOPATH_TO_CREATE) \ $(DEPSDIR) \ $(FILELISTDIR) \ diff --git a/rkt/rkt.mk b/rkt/rkt.mk index 48a26773f4..96c6e88eaa 100644 --- a/rkt/rkt.mk +++ b/rkt/rkt.mk @@ -2,7 +2,7 @@ LOCAL_NAME := $(patsubst %.mk,%,$(MK_FILENAME)) $(call setup-stamp-file,RKT_STAMP) -RKT_BINARY := $(BINDIR)/$(LOCAL_NAME) +RKT_BINARY := $(TARGET_BINDIR)/$(LOCAL_NAME) # variables for makelib/build_go_bin.mk BGB_STAMP := $(RKT_STAMP) @@ -25,7 +25,7 @@ TOPLEVEL_STAMPS += $(RKT_STAMP) $(call generate-stamp-rule,$(RKT_STAMP)) -$(BGB_BINARY): $(MK_PATH) | $(BINDIR) +$(BGB_BINARY): $(MK_PATH) | $(TARGET_BINDIR) include makelib/build_go_bin.mk diff --git a/stage1/makelib/aci_simple_go_bin.mk b/stage1/makelib/aci_simple_go_bin.mk index 88999931eb..7c44e01ea8 100644 --- a/stage1/makelib/aci_simple_go_bin.mk +++ b/stage1/makelib/aci_simple_go_bin.mk @@ -20,7 +20,7 @@ _ASGB_PATH_ := $(lastword $(MAKEFILE_LIST)) # Name of a binary, deduced upon filename of a parent Makefile. _ASGB_NAME_ := $(patsubst %.mk,%,$(MK_FILENAME)) # Path to built binary. Not the one in the ACI rootfs. -_ASGB_BINARY_ := $(TOOLSDIR)/$(_ASGB_NAME_) +_ASGB_BINARY_ := $(TARGET_TOOLSDIR)/$(_ASGB_NAME_) ifeq ($(ASGB_FLAVORS),) @@ -42,7 +42,7 @@ include makelib/build_go_bin.mk CLEAN_FILES += $(_ASGB_BINARY_) -$(_ASGB_BINARY_): $(_ASGB_PATH_) $(MK_PATH) | $(TOOLSDIR) +$(_ASGB_BINARY_): $(_ASGB_PATH_) $(MK_PATH) | $(TARGET_TOOLSDIR) # 2. diff --git a/stage1/makelib/aci_simple_static_c_bin.mk b/stage1/makelib/aci_simple_static_c_bin.mk index e98d5ad392..bf15731734 100644 --- a/stage1/makelib/aci_simple_static_c_bin.mk +++ b/stage1/makelib/aci_simple_static_c_bin.mk @@ -24,7 +24,7 @@ _ASSCB_PATH_ := $(lastword $(MAKEFILE_LIST)) # Name of a binary, deduced upon filename of a parent Makefile. _ASSCB_NAME_ := $(patsubst %.mk,%,$(MK_FILENAME)) # Path to built binary. Not the one in the ACI rootfs. -_ASSCB_BINARY_ := $(TOOLSDIR)/$(_ASSCB_NAME_) +_ASSCB_BINARY_ := $(TARGET_TOOLSDIR)/$(_ASSCB_NAME_) ifeq ($(ASSCB_FLAVORS),) @@ -44,7 +44,7 @@ CLEAN_FILES += $(_ASSCB_BINARY_) include makelib/build_static_c_bin.mk -$(_ASSCB_BINARY_): $(_ASSCB_PATH_) $(MK_PATH) | $(TOOLSDIR) +$(_ASSCB_BINARY_): $(_ASSCB_PATH_) $(MK_PATH) | $(TARGET_TOOLSDIR) # 2. diff --git a/stage1/net-plugins/net-plugins.mk b/stage1/net-plugins/net-plugins.mk index 78ef0848c0..edff85c2d4 100644 --- a/stage1/net-plugins/net-plugins.mk +++ b/stage1/net-plugins/net-plugins.mk @@ -30,7 +30,7 @@ define NPM_GENERATE_BUILD_PLUGIN_RULE # base name of a plugin NPM_BASE := $$(notdir $1) # path to the built plugin -NPM_PLUGIN := $$(TOOLSDIR)/$$(NPM_BASE) +NPM_PLUGIN := $$(TARGET_TOOLSDIR)/$$(NPM_BASE) # stamp used to build a plugin $$(call setup-stamp-file,NPM_STAMP,$$(NPM_BASE)) @@ -41,7 +41,7 @@ BGB_BINARY := $$(NPM_PLUGIN) BGB_PKG_IN_REPO := Godeps/_workspace/src/github.com/containernetworking/cni/plugins/$1 include makelib/build_go_bin.mk -$$(NPM_PLUGIN): | $$(TOOLSDIR) +$$(NPM_PLUGIN): $(TARGET_TOOLSDIR) $$(call generate-stamp-rule,$$(NPM_STAMP)) diff --git a/stage1/stage1.mk b/stage1/stage1.mk index f232013b6d..7bc82ad52a 100644 --- a/stage1/stage1.mk +++ b/stage1/stage1.mk @@ -66,7 +66,7 @@ $(foreach f,$(STAGE1_FLAVORS), \ $(eval STAGE1_SECONDARY_STAMPS_$f :=) \ $(eval STAGE1_ACIDIR_$f := $(BUILDDIR)/aci-for-$f-flavor) \ $(eval STAGE1_ACIROOTFSDIR_$f := $(STAGE1_ACIDIR_$f)/rootfs) \ - $(eval STAGE1_ACI_IMAGE_$f := $(BINDIR)/stage1-$f.aci) \ + $(eval STAGE1_ACI_IMAGE_$f := $(TARGET_BINDIR)/stage1-$f.aci) \ $(eval STAGE1_INSTALL_FILES_$f :=) \ $(eval STAGE1_INSTALL_SYMLINKS_$f :=) \ $(eval STAGE1_INSTALL_DIRS_$f :=) \ @@ -136,7 +136,7 @@ endif # above. $$(call forward-vars,$$(STAGE1_ACI_IMAGE_$1), \ ACTOOL STAGE1_ACIDIR_$1) -$$(STAGE1_ACI_IMAGE_$1): $$(ACTOOL_STAMP) | $$(BINDIR) +$$(STAGE1_ACI_IMAGE_$1): $$(ACTOOL_STAMP) | $$(TARGET_BINDIR) $(VQ) \ $(call vb,vt,ACTOOL,$$(call vsp,$$@)) \ "$$(ACTOOL)" build --overwrite --owner-root "$$(STAGE1_ACIDIR_$1)" "$$@" diff --git a/stage1_fly/stage1_fly.mk b/stage1_fly/stage1_fly.mk index 8513176f06..d9fe3149ea 100644 --- a/stage1_fly/stage1_fly.mk +++ b/stage1_fly/stage1_fly.mk @@ -1,9 +1,9 @@ FLY_ACIDIR := $(BUILDDIR)/aci-for-fly-flavor FLY_ACIROOTFSDIR := $(FLY_ACIDIR)/rootfs -FLY_TOOLSDIR := $(TOOLSDIR)/fly +FLY_TOOLSDIR := $(TARGET_TOOLSDIR)/fly FLY_STAMPS := FLY_SUBDIRS := run gc enter aci -FLY_STAGE1 := $(BINDIR)/stage1-fly.aci +FLY_STAGE1 := $(TARGET_BINDIR)/stage1-fly.aci $(call setup-stamp-file,FLY_STAMP,aci-build) diff --git a/tests/functional.mk b/tests/functional.mk index 2e8d383d89..7fb9ba7c4a 100644 --- a/tests/functional.mk +++ b/tests/functional.mk @@ -49,7 +49,7 @@ CREATE_DIRS += \ INSTALL_DIRS += \ $(FTST_IMAGE_ROOTFSDIR):0755 INSTALL_SYMLINKS += \ - $(foreach f,$(FTST_STAGE1_FLAVOR_FILENAMES),$(BINDIR)/$f:$(FTST_TMPDIR)/$f) + $(foreach f,$(FTST_STAGE1_FLAVOR_FILENAMES),$(TARGET_BINDIR)/$f:$(FTST_TMPDIR)/$f) CLEAN_FILES += \ $(FTST_IMAGE) \ $(FTST_ECHO_SERVER_BINARY) \ From de62f73737e219d23e54314eb07910a7751adbc2 Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Mon, 27 Jun 2016 11:21:49 -0700 Subject: [PATCH 0443/1304] stage1: Move manifest files to board directory To allow building rkt from multiple CoreOS board images move the manifest files to board specific directories. Signed-off-by: Geoff Levand --- .../{manifest.d => manifest-amd64-usr.d}/bash.manifest | 0 .../{manifest.d => manifest-amd64-usr.d}/journald.manifest | 0 .../{manifest.d => manifest-amd64-usr.d}/systemd.manifest | 0 stage1/usr_from_coreos/usr_from_coreos.mk | 2 +- stage1/usr_from_kvm/manifest-amd64-usr.d/bash.manifest | 1 + .../{manifest.d => manifest-amd64-usr.d}/ip.manifest | 0 stage1/usr_from_kvm/manifest-amd64-usr.d/journald.manifest | 1 + .../{manifest.d => manifest-amd64-usr.d}/sshd.manifest | 0 stage1/usr_from_kvm/manifest-amd64-usr.d/systemd.manifest | 1 + stage1/usr_from_kvm/manifest.d/bash.manifest | 1 - stage1/usr_from_kvm/manifest.d/journald.manifest | 1 - stage1/usr_from_kvm/manifest.d/systemd.manifest | 1 - stage1/usr_from_kvm/usr_from_kvm.mk | 2 +- 13 files changed, 5 insertions(+), 5 deletions(-) rename stage1/usr_from_coreos/{manifest.d => manifest-amd64-usr.d}/bash.manifest (100%) rename stage1/usr_from_coreos/{manifest.d => manifest-amd64-usr.d}/journald.manifest (100%) rename stage1/usr_from_coreos/{manifest.d => manifest-amd64-usr.d}/systemd.manifest (100%) create mode 120000 stage1/usr_from_kvm/manifest-amd64-usr.d/bash.manifest rename stage1/usr_from_kvm/{manifest.d => manifest-amd64-usr.d}/ip.manifest (100%) create mode 120000 stage1/usr_from_kvm/manifest-amd64-usr.d/journald.manifest rename stage1/usr_from_kvm/{manifest.d => manifest-amd64-usr.d}/sshd.manifest (100%) create mode 120000 stage1/usr_from_kvm/manifest-amd64-usr.d/systemd.manifest delete mode 120000 stage1/usr_from_kvm/manifest.d/bash.manifest delete mode 120000 stage1/usr_from_kvm/manifest.d/journald.manifest delete mode 120000 stage1/usr_from_kvm/manifest.d/systemd.manifest diff --git a/stage1/usr_from_coreos/manifest.d/bash.manifest b/stage1/usr_from_coreos/manifest-amd64-usr.d/bash.manifest similarity index 100% rename from stage1/usr_from_coreos/manifest.d/bash.manifest rename to stage1/usr_from_coreos/manifest-amd64-usr.d/bash.manifest diff --git a/stage1/usr_from_coreos/manifest.d/journald.manifest b/stage1/usr_from_coreos/manifest-amd64-usr.d/journald.manifest similarity index 100% rename from stage1/usr_from_coreos/manifest.d/journald.manifest rename to stage1/usr_from_coreos/manifest-amd64-usr.d/journald.manifest diff --git a/stage1/usr_from_coreos/manifest.d/systemd.manifest b/stage1/usr_from_coreos/manifest-amd64-usr.d/systemd.manifest similarity index 100% rename from stage1/usr_from_coreos/manifest.d/systemd.manifest rename to stage1/usr_from_coreos/manifest-amd64-usr.d/systemd.manifest diff --git a/stage1/usr_from_coreos/usr_from_coreos.mk b/stage1/usr_from_coreos/usr_from_coreos.mk index 0028982452..70ac3c8da9 100644 --- a/stage1/usr_from_coreos/usr_from_coreos.mk +++ b/stage1/usr_from_coreos/usr_from_coreos.mk @@ -10,7 +10,7 @@ S1_RF_USR_STAMPS += $(UFC_CBU_STAMP) # Input variables for building the ACI rootfs from CoreOS image # (build-usr.mk). -CBU_MANIFESTS_DIR := $(MK_SRCDIR)/manifest.d +CBU_MANIFESTS_DIR := $(MK_SRCDIR)/manifest-$(RKT_STAGE1_COREOS_BOARD).d CBU_TMPDIR := $(UFC_CBUDIR) CBU_DIFF := for-usr-from-coreos-mk CBU_STAMP := $(UFC_CBU_STAMP) diff --git a/stage1/usr_from_kvm/manifest-amd64-usr.d/bash.manifest b/stage1/usr_from_kvm/manifest-amd64-usr.d/bash.manifest new file mode 120000 index 0000000000..5eac6843c8 --- /dev/null +++ b/stage1/usr_from_kvm/manifest-amd64-usr.d/bash.manifest @@ -0,0 +1 @@ +../../usr_from_coreos/manifest-amd64-usr.d/bash.manifest \ No newline at end of file diff --git a/stage1/usr_from_kvm/manifest.d/ip.manifest b/stage1/usr_from_kvm/manifest-amd64-usr.d/ip.manifest similarity index 100% rename from stage1/usr_from_kvm/manifest.d/ip.manifest rename to stage1/usr_from_kvm/manifest-amd64-usr.d/ip.manifest diff --git a/stage1/usr_from_kvm/manifest-amd64-usr.d/journald.manifest b/stage1/usr_from_kvm/manifest-amd64-usr.d/journald.manifest new file mode 120000 index 0000000000..cdc5df962e --- /dev/null +++ b/stage1/usr_from_kvm/manifest-amd64-usr.d/journald.manifest @@ -0,0 +1 @@ +../../usr_from_coreos/manifest-amd64-usr.d/journald.manifest \ No newline at end of file diff --git a/stage1/usr_from_kvm/manifest.d/sshd.manifest b/stage1/usr_from_kvm/manifest-amd64-usr.d/sshd.manifest similarity index 100% rename from stage1/usr_from_kvm/manifest.d/sshd.manifest rename to stage1/usr_from_kvm/manifest-amd64-usr.d/sshd.manifest diff --git a/stage1/usr_from_kvm/manifest-amd64-usr.d/systemd.manifest b/stage1/usr_from_kvm/manifest-amd64-usr.d/systemd.manifest new file mode 120000 index 0000000000..d9346f64a8 --- /dev/null +++ b/stage1/usr_from_kvm/manifest-amd64-usr.d/systemd.manifest @@ -0,0 +1 @@ +../../usr_from_coreos/manifest-amd64-usr.d/systemd.manifest \ No newline at end of file diff --git a/stage1/usr_from_kvm/manifest.d/bash.manifest b/stage1/usr_from_kvm/manifest.d/bash.manifest deleted file mode 120000 index 1e70f758f7..0000000000 --- a/stage1/usr_from_kvm/manifest.d/bash.manifest +++ /dev/null @@ -1 +0,0 @@ -../../usr_from_coreos/manifest.d/bash.manifest \ No newline at end of file diff --git a/stage1/usr_from_kvm/manifest.d/journald.manifest b/stage1/usr_from_kvm/manifest.d/journald.manifest deleted file mode 120000 index 9190f6c01b..0000000000 --- a/stage1/usr_from_kvm/manifest.d/journald.manifest +++ /dev/null @@ -1 +0,0 @@ -../../usr_from_coreos/manifest.d/journald.manifest \ No newline at end of file diff --git a/stage1/usr_from_kvm/manifest.d/systemd.manifest b/stage1/usr_from_kvm/manifest.d/systemd.manifest deleted file mode 120000 index 8b479ff5c3..0000000000 --- a/stage1/usr_from_kvm/manifest.d/systemd.manifest +++ /dev/null @@ -1 +0,0 @@ -../../usr_from_coreos/manifest.d/systemd.manifest \ No newline at end of file diff --git a/stage1/usr_from_kvm/usr_from_kvm.mk b/stage1/usr_from_kvm/usr_from_kvm.mk index eceadc9e21..d74bb0bbb9 100644 --- a/stage1/usr_from_kvm/usr_from_kvm.mk +++ b/stage1/usr_from_kvm/usr_from_kvm.mk @@ -15,7 +15,7 @@ $(call inc-many,$(UFK_INCLUDES)) # Some input variables for building the ACI rootfs from CoreOS image # (build-usr.mk). -CBU_MANIFESTS_DIR := $(MK_SRCDIR)/manifest.d +CBU_MANIFESTS_DIR := $(MK_SRCDIR)/manifest-$(RKT_STAGE1_COREOS_BOARD).d CBU_TMPDIR := $(UFK_CBUDIR) CBU_DIFF := for-usr-from-kvm-mk CBU_STAMP := $(UFK_CBU_STAMP) From fcd6f8bacd83244fc4a28738cd8040325218be88 Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Mon, 27 Jun 2016 11:21:49 -0700 Subject: [PATCH 0444/1304] stage1: Get board specific image Signed-off-by: Geoff Levand --- stage1/usr_from_coreos/coreos-common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stage1/usr_from_coreos/coreos-common.mk b/stage1/usr_from_coreos/coreos-common.mk index 75abfb15cd..00491cea01 100644 --- a/stage1/usr_from_coreos/coreos-common.mk +++ b/stage1/usr_from_coreos/coreos-common.mk @@ -13,7 +13,7 @@ CCN_SYSTEMD_VERSION := v229 # coreos image version CCN_IMG_RELEASE := 1068.0.0 # coreos image URL -CCN_IMG_URL := https://alpha.release.core-os.net/amd64-usr/$(CCN_IMG_RELEASE)/coreos_production_pxe_image.cpio.gz +CCN_IMG_URL := https://alpha.release.core-os.net/$(RKT_STAGE1_COREOS_BOARD)/$(CCN_IMG_RELEASE)/coreos_production_pxe_image.cpio.gz # path to downloaded pxe image CCN_DOWNLOADED_PXE := $(CCN_TMPDIR)/pxe.img CLEAN_FILES += \ From 2ce24da0e558d645cfe162f166b82b6456bd6504 Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Mon, 27 Jun 2016 11:21:49 -0700 Subject: [PATCH 0445/1304] stage1: Set ACI manifest arch value Set the arch value of the ACI manifest based on the RKT_ACI_ARCH variable. Signed-off-by: Geoff Levand --- stage1/aci/aci-install.mk | 8 +++++--- stage1/aci/aci-manifest.in | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/stage1/aci/aci-install.mk b/stage1/aci/aci-install.mk index 54363b16e3..6e072c50f7 100644 --- a/stage1/aci/aci-install.mk +++ b/stage1/aci/aci-install.mk @@ -63,6 +63,7 @@ endif AMI_SED_NAME := $(call sed-replacement-escape,$(AMI_NAME)) AMI_SED_VERSION := $(call sed-replacement-escape,$(AMI_STAGE1_VERSION)) AMI_SED_ENTER := $(call sed-replacement-escape,$(STAGE1_ENTER_CMD_$(AMI_FLAVOR))) +AMI_SED_ARCH := $(call sed-replacement-escape,$(RKT_ACI_ARCH)) # main stamp ensures everything is done $(call setup-stamp-file,AMI_STAMP,$(AMI_FLAVOR)-main) @@ -86,7 +87,7 @@ $(call generate-stamp-rule,$(AMI_STAMP),$(AMI_INSTALLED_FILES) $(AMI_MANIFEST_KV # this rule generates a manifest $(call forward-vars,$(AMI_GEN_MANIFEST), \ - AMI_FLAVOR AMI_SED_NAME AMI_SED_VERSION AMI_SED_ENTER) + AMI_FLAVOR AMI_SED_NAME AMI_SED_VERSION AMI_SED_ENTER AMI_SED_ARCH) $(AMI_GEN_MANIFEST): $(AMI_SRC_MANIFEST) | $(AMI_TMPDIR) $(VQ) \ set -e; \ @@ -95,11 +96,12 @@ $(AMI_GEN_MANIFEST): $(AMI_SRC_MANIFEST) | $(AMI_TMPDIR) -e 's/@RKT_STAGE1_NAME@/$(AMI_SED_NAME)/g' \ -e 's/@RKT_STAGE1_VERSION@/$(AMI_SED_VERSION)/g' \ -e 's/@RKT_STAGE1_ENTER@/$(AMI_SED_ENTER)/g' \ + -e 's/@RKT_STAGE1_ARCH@/$(AMI_SED_ARCH)/g' \ "$<" >"$@.tmp"; \ $(call bash-cond-rename,$@.tmp,$@) -# invalidate generated manifest if name, version or enter cmd changes -$(call generate-kv-deps,$(AMI_MANIFEST_KV_DEPMK_STAMP),$(AMI_GEN_MANIFEST),$(AMI_MANIFEST_KV_DEPMK),AMI_SED_NAME AMI_SED_VERSION AMI_SED_ENTER) +# invalidate generated manifest if name, version, arch or enter cmd changes +$(call generate-kv-deps,$(AMI_MANIFEST_KV_DEPMK_STAMP),$(AMI_GEN_MANIFEST),$(AMI_MANIFEST_KV_DEPMK),AMI_SED_NAME AMI_SED_VERSION AMI_SED_ARCH AMI_SED_ENTER) # this removes the ACI rootfs dir $(call generate-rm-dir-rule,$(AMI_RMDIR_STAMP),$(AMI_ACIROOTFSDIR)) diff --git a/stage1/aci/aci-manifest.in b/stage1/aci/aci-manifest.in index b9e7b1a3dc..257fcb8900 100644 --- a/stage1/aci/aci-manifest.in +++ b/stage1/aci/aci-manifest.in @@ -9,7 +9,7 @@ }, { "name": "arch", - "value": "amd64" + "value": "@RKT_STAGE1_ARCH@" }, { "name": "os", From 42b35c2d75a0f812e126bbfb0c1884831b6c5aeb Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Mon, 27 Jun 2016 11:21:49 -0700 Subject: [PATCH 0446/1304] stage1_fly: Set ACI manifest arch value Set the arch value of the ACI manifest based on the RKT_ACI_ARCH variable. Signed-off-by: Geoff Levand --- stage1_fly/aci/aci-manifest.in | 2 +- stage1_fly/aci/aci.mk | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/stage1_fly/aci/aci-manifest.in b/stage1_fly/aci/aci-manifest.in index 54295d342e..598c409eb5 100644 --- a/stage1_fly/aci/aci-manifest.in +++ b/stage1_fly/aci/aci-manifest.in @@ -9,7 +9,7 @@ }, { "name": "arch", - "value": "amd64" + "value": "@RKT_STAGE1_ARCH@" }, { "name": "os", diff --git a/stage1_fly/aci/aci.mk b/stage1_fly/aci/aci.mk index eacf2d525d..f9c0d93e7e 100644 --- a/stage1_fly/aci/aci.mk +++ b/stage1_fly/aci/aci.mk @@ -12,6 +12,7 @@ FLY_ACI_MANIFEST := $(FLY_ACIDIR)/manifest # they can be safely used in the replacement part of sed's s/// # command. FLY_ACI_VERSION := $(call sed-replacement-escape,$(RKT_VERSION)) +FLY_ACI_ARCH := $(call sed-replacement-escape,$(RKT_ACI_ARCH)) # stamp and dep file for invalidating the generated manifest if name, # version or enter command changes for this flavor $(call setup-stamp-file,FLY_ACI_MANIFEST_KV_DEPMK_STAMP,$manifest-kv-dep) @@ -25,18 +26,19 @@ FLY_ACI_DIRS := \ # main stamp rule - makes sure manifest and deps files are generated $(call generate-stamp-rule,$(FLY_ACI_STAMP),$(FLY_ACI_MANIFEST) $(FLY_ACI_MANIFEST_KV_DEPMK_STAMP)) -# invalidate generated manifest if version changes -$(call generate-kv-deps,$(FLY_ACI_MANIFEST_KV_DEPMK_STAMP),$(FLY_ACI_GEN_MANIFEST),$(FLY_ACI_MANIFEST_KV_DEPMK),FLY_ACI_VERSION) +# invalidate generated manifest if version or arch changes +$(call generate-kv-deps,$(FLY_ACI_MANIFEST_KV_DEPMK_STAMP),$(FLY_ACI_GEN_MANIFEST),$(FLY_ACI_MANIFEST_KV_DEPMK),FLY_ACI_VERSION FLY_ACI_ARCH) # this rule generates a manifest $(call forward-vars,$(FLY_ACI_GEN_MANIFEST), \ - FLY_ACI_VERSION) + FLY_ACI_VERSION FLY_ACI_ARCH) $(FLY_ACI_GEN_MANIFEST): $(FLY_ACI_SRC_MANIFEST) | $(FLY_ACI_TMPDIR) $(FLY_ACI_DIRS) $(FLY_ACIROOTFSDIR)/flavor $(VQ) \ set -e; \ $(call vb,vt,MANIFEST,fly) \ sed \ -e 's/@RKT_STAGE1_VERSION@/$(FLY_ACI_VERSION)/g' \ + -e 's/@RKT_STAGE1_ARCH@/$(FLY_ACI_ARCH)/g' \ "$<" >"$@.tmp"; \ $(call bash-cond-rename,$@.tmp,$@) From 390af328ac4be322eddc1ccc01f8ccec8bc2ab7b Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Mon, 27 Jun 2016 11:21:49 -0700 Subject: [PATCH 0447/1304] stage1/init: Add arm64 interpBin The interpreter binary is arch specific, so split the interpBin definition off into the arch specific file init_linux_amd64.go, and add a new one, init_linux_arm64.go. Signed-off-by: Geoff Levand --- stage1/init/init.go | 2 -- stage1/init/init_linux_amd64.go | 22 ++++++++++++++++++++++ stage1/init/init_linux_arm64.go | 22 ++++++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 stage1/init/init_linux_amd64.go create mode 100644 stage1/init/init_linux_arm64.go diff --git a/stage1/init/init.go b/stage1/init/init.go index 7955e432da..cad2674615 100644 --- a/stage1/init/init.go +++ b/stage1/init/init.go @@ -56,8 +56,6 @@ import ( const ( // Path to systemd-nspawn binary within the stage1 rootfs nspawnBin = "/usr/bin/systemd-nspawn" - // Path to the interpreter within the stage1 rootfs - interpBin = "/usr/lib/ld-linux-x86-64.so.2" // Path to the localtime file/symlink in host localtimePath = "/etc/localtime" ) diff --git a/stage1/init/init_linux_amd64.go b/stage1/init/init_linux_amd64.go new file mode 100644 index 0000000000..fb673c2999 --- /dev/null +++ b/stage1/init/init_linux_amd64.go @@ -0,0 +1,22 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//+build amd64,linux + +package main + +const ( + // Path to the interpreter within the stage1 rootfs + interpBin = "/usr/lib/ld-linux-x86-64.so.2" +) diff --git a/stage1/init/init_linux_arm64.go b/stage1/init/init_linux_arm64.go new file mode 100644 index 0000000000..c7962260f8 --- /dev/null +++ b/stage1/init/init_linux_arm64.go @@ -0,0 +1,22 @@ +// Copyright 2016 The rkt Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//+build arm64,linux + +package main + +const ( + // Path to the interpreter within the stage1 rootfs + interpBin = "/usr/lib/ld-linux-aarch64.so.1" +) From 1b0d2f43120b1aeeb5569f4291cac07f3b6eca4a Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Mon, 27 Jun 2016 11:21:49 -0700 Subject: [PATCH 0448/1304] stage1: Add arm64-usr manifest files Signed-off-by: Geoff Levand --- .../manifest-arm64-usr.d/bash.manifest | 12 +++ .../manifest-arm64-usr.d/journald.manifest | 5 + .../manifest-arm64-usr.d/systemd.manifest | 95 +++++++++++++++++++ .../manifest-arm64-usr.d/bash.manifest | 1 + .../manifest-arm64-usr.d/ip.manifest | 8 ++ .../manifest-arm64-usr.d/journald.manifest | 1 + .../manifest-arm64-usr.d/sshd.manifest | 22 +++++ .../manifest-arm64-usr.d/systemd.manifest | 1 + 8 files changed, 145 insertions(+) create mode 100644 stage1/usr_from_coreos/manifest-arm64-usr.d/bash.manifest create mode 100644 stage1/usr_from_coreos/manifest-arm64-usr.d/journald.manifest create mode 100644 stage1/usr_from_coreos/manifest-arm64-usr.d/systemd.manifest create mode 120000 stage1/usr_from_kvm/manifest-arm64-usr.d/bash.manifest create mode 100644 stage1/usr_from_kvm/manifest-arm64-usr.d/ip.manifest create mode 120000 stage1/usr_from_kvm/manifest-arm64-usr.d/journald.manifest create mode 100644 stage1/usr_from_kvm/manifest-arm64-usr.d/sshd.manifest create mode 120000 stage1/usr_from_kvm/manifest-arm64-usr.d/systemd.manifest diff --git a/stage1/usr_from_coreos/manifest-arm64-usr.d/bash.manifest b/stage1/usr_from_coreos/manifest-arm64-usr.d/bash.manifest new file mode 100644 index 0000000000..cfba8f1f1a --- /dev/null +++ b/stage1/usr_from_coreos/manifest-arm64-usr.d/bash.manifest @@ -0,0 +1,12 @@ +bin/bash +lib64/libreadline.so.6.3 +lib64/libreadline.so.6 +lib64/libncurses.so.5.9 +lib64/libncurses.so.5 +lib64/libdl.so.2 +lib64/libdl-2.21.so +lib64/libc.so.6 +lib64/libc-2.21.so +lib64/ld-linux-aarch64.so.1 +lib64/ld-2.21.so +lib/ld-linux-aarch64.so.1 diff --git a/stage1/usr_from_coreos/manifest-arm64-usr.d/journald.manifest b/stage1/usr_from_coreos/manifest-arm64-usr.d/journald.manifest new file mode 100644 index 0000000000..04637a41c4 --- /dev/null +++ b/stage1/usr_from_coreos/manifest-arm64-usr.d/journald.manifest @@ -0,0 +1,5 @@ +lib/systemd/system/syslog.socket +lib/systemd/system/systemd-journald-audit.socket +lib/systemd/system/systemd-journald-dev-log.socket +lib/systemd/system/systemd-journald.service +lib/systemd/system/systemd-journald.socket diff --git a/stage1/usr_from_coreos/manifest-arm64-usr.d/systemd.manifest b/stage1/usr_from_coreos/manifest-arm64-usr.d/systemd.manifest new file mode 100644 index 0000000000..e1dc37bf3a --- /dev/null +++ b/stage1/usr_from_coreos/manifest-arm64-usr.d/systemd.manifest @@ -0,0 +1,95 @@ +bin/bash +bin/coredumpctl +bin/journalctl +bin/mount +bin/systemctl +bin/systemd-analyze +bin/systemd-ask-password +bin/systemd-cat +bin/systemd-cgls +bin/systemd-cgtop +bin/systemd-delta +bin/systemd-detect-virt +bin/systemd-inhibit +bin/systemd-machine-id-setup +bin/systemd-notify +bin/systemd-nspawn +bin/systemd-path +bin/systemd-run +bin/systemd-stdio-bridge +bin/systemd-sysusers +bin/systemd-tmpfiles +bin/systemd-tty-ask-password-agent +lib64/ld-2.21.so +lib64/ld-linux-aarch64.so.1 +lib64/libattr.so.1 +lib64/libattr.so.1.1.0 +lib64/libblkid.so.1 +lib64/libblkid.so.1.1.0 +lib64/libc-2.21.so +lib64/libcap.so.2 +lib64/libcap.so.2.24 +lib64/libc.so.6 +lib64/libdl-2.21.so +lib64/libdl.so +lib64/libdl.so.2 +lib64/libgcrypt.so.11 +lib64/libgcrypt.so.11.8.3 +lib64/libgpg-error.so.0 +lib64/libgpg-error.so.0.10.0 +lib64/libip4tc.so.0 +lib64/libip4tc.so.0.1.0 +lib64/libkmod.so.2 +lib64/libkmod.so.2.2.11 +lib64/liblzma.so.5.0.8 +lib64/liblzma.so.5 +lib64/libmount.so.1 +lib64/libmount.so.1.1.0 +lib64/libncurses.so.5 +lib64/libncurses.so.5.9 +lib64/libpam.so.0 +lib64/libpam.so.0.84.1 +lib64/libpthread-2.21.so +lib64/libpthread.so.0 +lib64/libreadline.so.6 +lib64/libreadline.so.6.3 +lib64/librt-2.21.so +lib64/librt.so.1 +lib64/libuuid.so.1 +lib64/libuuid.so.1.3.0 +lib64/libz.so.1 +lib64/libz.so.1.2.8 +lib/ld-linux-aarch64.so.1 +lib/systemd/systemd +lib/systemd/systemd-ac-power +lib/systemd/systemd-activate +lib/systemd/systemd-backlight +lib/systemd/systemd-binfmt +lib/systemd/systemd-bootchart +lib/systemd/systemd-bus-proxyd +lib/systemd/systemd-cgroups-agent +lib/systemd/systemd-coredump +lib/systemd/systemd-fsck +lib/systemd/systemd-hostnamed +lib/systemd/systemd-initctl +lib/systemd/systemd-journald +lib/systemd/systemd-localed +lib/systemd/systemd-logind +lib/systemd/systemd-machined +lib/systemd/systemd-modules-load +lib/systemd/systemd-networkd +lib/systemd/systemd-networkd-wait-online +lib/systemd/systemd-random-seed +lib/systemd/systemd-remount-fs +lib/systemd/systemd-reply-password +lib/systemd/systemd-rfkill +lib/systemd/systemd-shutdown +lib/systemd/systemd-sleep +lib/systemd/systemd-sysctl +lib/systemd/systemd-timedated +lib/systemd/systemd-udevd +lib/systemd/systemd-update-done +lib/systemd/systemd-update-utmp +lib/systemd/systemd-vconsole-setup +lib/systemd/system-sleep +lib/systemd/user-generators diff --git a/stage1/usr_from_kvm/manifest-arm64-usr.d/bash.manifest b/stage1/usr_from_kvm/manifest-arm64-usr.d/bash.manifest new file mode 120000 index 0000000000..c3b0ee0f4e --- /dev/null +++ b/stage1/usr_from_kvm/manifest-arm64-usr.d/bash.manifest @@ -0,0 +1 @@ +../../usr_from_coreos/manifest-arm64-usr.d/bash.manifest \ No newline at end of file diff --git a/stage1/usr_from_kvm/manifest-arm64-usr.d/ip.manifest b/stage1/usr_from_kvm/manifest-arm64-usr.d/ip.manifest new file mode 100644 index 0000000000..c983b94b65 --- /dev/null +++ b/stage1/usr_from_kvm/manifest-arm64-usr.d/ip.manifest @@ -0,0 +1,8 @@ +bin/ip +lib64/libdl.so.2 +lib64/libdl-2.21.so +lib64/libc.so.6 +lib64/libc-2.21.so +lib64/ld-linux-aarch64.so.1 +lib64/ld-2.21.so +lib/ld-linux-aarch64.so.1 diff --git a/stage1/usr_from_kvm/manifest-arm64-usr.d/journald.manifest b/stage1/usr_from_kvm/manifest-arm64-usr.d/journald.manifest new file mode 120000 index 0000000000..8306b4af1d --- /dev/null +++ b/stage1/usr_from_kvm/manifest-arm64-usr.d/journald.manifest @@ -0,0 +1 @@ +../../usr_from_coreos/manifest-arm64-usr.d/journald.manifest \ No newline at end of file diff --git a/stage1/usr_from_kvm/manifest-arm64-usr.d/sshd.manifest b/stage1/usr_from_kvm/manifest-arm64-usr.d/sshd.manifest new file mode 100644 index 0000000000..5591237179 --- /dev/null +++ b/stage1/usr_from_kvm/manifest-arm64-usr.d/sshd.manifest @@ -0,0 +1,22 @@ +bin/chmod +bin/chown +bin/ssh-keygen +lib64/ld-linux-aarch64.so.1 +lib64/libc-2.21.so +lib64/libcrypt-2.21.so +lib64/libcrypto.so.1.0.0 +lib64/libcrypt.so.1 +lib64/libc.so.6 +lib64/libdl-2.21.so +lib64/libdl.so.2 +lib64/libpam.so +lib64/libpam.so.0.84.1 +lib64/libresolv-2.21.so +lib64/libresolv.so.2 +lib64/libutil-2.21.so +lib64/libutil.so.1 +lib64/libz.so.1 +lib64/libz.so.1.2.8 +libcrypt-2.21.so +lib/ld-linux-aarch64.so.1 +sbin/sshd diff --git a/stage1/usr_from_kvm/manifest-arm64-usr.d/systemd.manifest b/stage1/usr_from_kvm/manifest-arm64-usr.d/systemd.manifest new file mode 120000 index 0000000000..4e10576577 --- /dev/null +++ b/stage1/usr_from_kvm/manifest-arm64-usr.d/systemd.manifest @@ -0,0 +1 @@ +../../usr_from_coreos/manifest-arm64-usr.d/systemd.manifest \ No newline at end of file From 687f8120474e07c879d30627aef936b497b88763 Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Mon, 27 Jun 2016 11:21:49 -0700 Subject: [PATCH 0449/1304] travis: Use apt packages addon Use the travis apt packages addon to simplify installing packages. Signed-off-by: Geoff Levand --- .travis.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index ad3e395521..6ce4bc67f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,12 +8,18 @@ go: - 1.5.3 - 1.6 +addons: + apt: + packages: + - cpio + - realpath + - squashfs-tools + - build-essential + - libacl1-dev + - libsystemd-journal-dev + install: - - sudo apt-get update -qq - - sudo apt-get install -y cpio realpath squashfs-tools - - sudo apt-get install -y build-essential - - sudo apt-get install -y libacl1-dev - - sudo apt-get install -y libsystemd-journal-dev + - script: - ./autogen.sh From 1642da3ef06b35c6fd2a54fb07c01d5b9ce65e17 Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Mon, 27 Jun 2016 11:21:49 -0700 Subject: [PATCH 0450/1304] travis: Add gimme.local Add a local gimme script that knows how to provide a go compiler with arm64 cgo support. This change can be reverted once travis PR #45 is merged. Signed-off-by: Geoff Levand --- gimme.local | 481 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 481 insertions(+) create mode 100755 gimme.local diff --git a/gimme.local b/gimme.local new file mode 100755 index 0000000000..9a2afe69d7 --- /dev/null +++ b/gimme.local @@ -0,0 +1,481 @@ +#!/bin/bash +# vim:noexpandtab:ts=2:sw=2: +# +#+ Usage: $(basename $0) [flags] [go-version] [version-prefix] +#+ - +#+ Version: ${GIMME_VERSION} +#+ - +#+ Install go! There are multiple types of installations available, with 'auto' being the default. +#+ If either 'auto' or 'binary' is specified as GIMME_TYPE, gimme will first check for an existing +#+ go installation. This behavior may be disabled by providing '-f/--force/force' as first positional +#+ argument. +#+ - +#+ Option flags: +#+ -h --help help - show this help text and exit +#+ -V --version version - show the version only and exit +#+ -f --force force - remove the existing go installation if present prior to install +#+ -l --list list - list installed go versions and exit +#+ - +#+ Influential env vars: +#+ - +#+ GIMME_GO_VERSION - version to install (*REQUIRED*, may be given as first positional arg) +#+ GIMME_VERSION_PREFIX - prefix for installed versions (default '${GIMME_VERSION_PREFIX}', +#+ may be given as second positional arg) +#+ GIMME_ARCH - arch to install (default '${GIMME_ARCH}') +#+ GIMME_BINARY_OSX - darwin-specific binary suffix (default '${GIMME_BINARY_OSX}') +#+ GIMME_ENV_PREFIX - prefix for env files (default '${GIMME_ENV_PREFIX}') +#+ GIMME_GO_GIT_REMOTE - git remote for git-based install (default '${GIMME_GO_GIT_REMOTE}') +#+ GIMME_OS - os to install (default '${GIMME_OS}') +#+ GIMME_TMP - temp directory (default '${GIMME_TMP}') +#+ GIMME_TYPE - install type to perform ('auto', 'binary', 'source', or 'git') +#+ (default '${GIMME_TYPE}') +#+ GIMME_DEBUG - enable tracing if non-empty +#+ GIMME_NO_ENV_ALIAS - disable creation of env 'alias' file when os and arch match host +#+ GIMME_SILENT_ENV - omit the 'go version' line from env file +#+ GIMME_CGO_ENABLED - enable build of cgo support +#+ GIMME_CC_FOR_TARGET - cross compiler for cgo support +#+ - +# +# The MIT License (MIT) +# +# Copyright (c) 2015 Dan Buch, Tianon Gravi +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +set -e +shopt -s nullglob +set -o pipefail + +[[ ${GIMME_DEBUG} ]] && set -x + +GIMME_VERSION=v0.2.3 + +# _do_curl "url" "file" +_do_curl() { + mkdir -p "$(dirname "${2}")" + + if command -v curl > /dev/null ; then + curl -sSLf "${1}" -o "${2}" 2>/dev/null + return + fi + + if command -v wget > /dev/null ; then + wget -q "${1}" -O "${2}" 2>/dev/null + return + fi + + echo >&2 'error: no curl or wget found' + exit 1 +} + +# _do_curls "file" "url" ["url"...] +_do_curls() { + f="${1}" + shift + [[ ! -s "${f}" ]] || return 0 + for url in "${@}" ; do + if _do_curl "${url}" "${f}" ; then + return + fi + done + rm -f "${f}" + return 1 +} + +# _binary "version" "file.tar.gz" "arch" +_binary() { + local version=${1} + local file=${2} + local arch=${3} + urls=( + "https://storage.googleapis.com/golang/go${version}.${GIMME_OS}-${arch}.tar.gz" + "https://go.googlecode.com/files/go${version}.${GIMME_OS}-${arch}.tar.gz" + "https://go.googlecode.com/files/go.${version}.${GIMME_OS}-${arch}.tar.gz" + ) + if [ "${GIMME_OS}" = 'darwin' -a "${GIMME_BINARY_OSX}" ] ; then + urls=( + "https://storage.googleapis.com/golang/go${version}.${GIMME_OS}-${arch}-${GIMME_BINARY_OSX}.tar.gz" + "${urls[@]}" + ) + fi + if [ "${arch}" = 'arm' ] ; then + # attempt "armv6l" vs just "arm" first (since that's what's officially published) + urls=( + "https://storage.googleapis.com/golang/go${version}.${GIMME_OS}-${arch}v6l.tar.gz" # go1.6beta2 & go1.6rc1 + "https://storage.googleapis.com/golang/go${version}.${GIMME_OS}-${arch}6.tar.gz" # go1.6beta1 + "${urls[@]}" + ) + fi + _do_curls "${file}" "${urls[@]}" +} + +# _source "version" "file.src.tar.gz" +_source() { + urls=( + "https://storage.googleapis.com/golang/go${1}.src.tar.gz" + "https://go.googlecode.com/files/go${1}.src.tar.gz" + "https://go.googlecode.com/files/go.${1}.src.tar.gz" + ) + _do_curls "${2}" "${urls[@]}" +} + +# _fetch "dir" +_fetch() { + mkdir -p "$(dirname "${1}")" + + if [[ -d "${1}/.git" ]] ; then + ( + cd "${1}" + git remote set-url origin "${GIMME_GO_GIT_REMOTE}" + git fetch -q --all && git fetch -q --tags + ) + return + fi + + git clone -q "${GIMME_GO_GIT_REMOTE}" "${1}" +} + +# _checkout "version" "dir" +_checkout() { + _fetch "${2}" + ( cd "${2}" && { + git reset -q --hard "origin/${1}" \ + || git reset -q --hard "origin/go${1}" \ + || { [ "${1}" = 'tip' ] && git reset -q --hard origin/master ; } \ + || git reset -q --hard "refs/tags/${1}" \ + || git reset -q --hard "refs/tags/go${1}" + } 2>/dev/null ) +} + +# _extract "file.tar.gz" "dir" +_extract() { + mkdir -p "${2}" + tar -xf "${1}" -C "${2}" --strip-components 1 +} + +# _setup_bootstrap +_setup_bootstrap() { + local versions=("1.6" "1.5" "1.4") + + # try existing + for v in "${versions[@]}" ; do + for candidate in "${GIMME_ENV_PREFIX}/go${v}"*".env" ; do + if [ -s "$candidate" ]; then + export GOROOT_BOOTSTRAP="$(source "${candidate}" 2>/dev/null && go env GOROOT)" + return 0 + fi + done + done + + # try binary + for v in "${versions[@]}" ; do + if [ -n "$(_try_binary ${v} "${GIMME_HOSTARCH}")" ]; then + export GOROOT_BOOTSTRAP="${GIMME_VERSION_PREFIX}/go${v}.${GIMME_OS}.${GIMME_HOSTARCH}" + return 0 + fi + done + + echo >&2 "Unable to setup go bootstrap from existing or binary"; + return 1; +} + +# _compile "dir" +_compile() { + ( + if grep -q GOROOT_BOOTSTRAP "${1}/src/make.bash" &> /dev/null; then + _setup_bootstrap || return 1 + fi + cd "${1}" + if [[ -d .git ]] ; then + git clean -dfx -q + fi + cd src + export GOOS="${GIMME_OS}" GOARCH="${GIMME_ARCH}" + export CGO_ENABLED="${GIMME_CGO_ENABLED}" + export CC_FOR_TARGET="${GIMME_CC_FOR_TARGET}" + + if [ "${GIMME_DEBUG}" = "2" ]; then + ./make.bash 1>&2 || return 1 + else + local make_log="${1}/make.${GOOS}.${GOARCH}.log" + ./make.bash &> $make_log || return 1 + fi + ) +} + +_can_compile() { + cat > "${GIMME_TMP}/test.go" <<'EOF' +package main +import "os" +func main() { + os.Exit(0) +} +EOF + "${1}/bin/go" run "${GIMME_TMP}/test.go" +} + +# _env "dir" +_env() { + [ -d "${1}/bin" -a -x "${1}/bin/go" ] || return 1 + + # if we try to run a Darwin binary on Linux, we need to fail so 'auto' can fallback to cross-compiling from source + # automatically + GOROOT="${1}" "${1}/bin/go" version &> /dev/null || return 1 + + # https://twitter.com/davecheney/status/431581286918934528 + # we have to GOROOT sometimes because we use official release binaries in unofficial locations :( + + echo + if [[ "$(GOROOT="${1}" "${1}/bin/go" env GOHOSTOS)" = "${GIMME_OS}" ]] ; then + echo 'unset GOOS' + else + echo 'export GOOS="'"${GIMME_OS}"'"' + fi + if [[ "$(GOROOT="${1}" "${1}/bin/go" env GOHOSTARCH)" = "${GIMME_ARCH}" ]] ; then + echo 'unset GOARCH' + else + echo 'export GOARCH="'"${GIMME_ARCH}"'"' + fi + if ! _can_compile "${1}" >/dev/null 2>&1 ; then + # if the compile test fails without GOROOT, then we probably need GOROOT + echo 'export GOROOT="'"${1}"'"' + else + echo 'unset GOROOT' + fi + echo 'export PATH="'"${1}/bin"':${PATH}"' + if [[ -z "${GIMME_SILENT_ENV}" ]] ; then + echo 'go version >&2' + fi + echo +} + +# _env_alias "dir" "env-file" +_env_alias() { + if [[ "${GIMME_NO_ENV_ALIAS}" ]] ; then + echo "${2}" + return + fi + + if [[ "$(GOROOT="${1}" "${1}/bin/go" env GOHOSTOS)" = "${GIMME_OS}" && \ + "$(GOROOT="${1}" "${1}/bin/go" env GOHOSTARCH)" = "${GIMME_ARCH}" ]] ; then + local dest="${GIMME_ENV_PREFIX}/go${GIMME_GO_VERSION}.env" + cp "${2}" "${dest}" + ln -sf "${dest}" "${GIMME_ENV_PREFIX}/latest.env" + echo "${dest}" + else + echo "${2}" + fi +} + +_try_existing() { + local existing_ver="${GIMME_VERSION_PREFIX}/go${GIMME_GO_VERSION}.${GIMME_OS}.${GIMME_ARCH}" + local existing_env="${GIMME_ENV_PREFIX}/go${GIMME_GO_VERSION}.${GIMME_OS}.${GIMME_ARCH}.env" + + if [[ -x "${existing_ver}/bin/go" && -s "${existing_env}" ]] ; then + cat "${existing_env}" + return + fi + + return 1 +} + +# _try_binary "version" "arch" +_try_binary() { + local version=${1} + local arch=${2} + local bin_tgz="${GIMME_TMP}/go${version}.${GIMME_OS}.${arch}.tar.gz" + local bin_dir="${GIMME_VERSION_PREFIX}/go${version}.${GIMME_OS}.${arch}" + local bin_env="${GIMME_ENV_PREFIX}/go${version}.${GIMME_OS}.${arch}.env" + + _binary "${version}" "${bin_tgz}" "${arch}" || return 1 + _extract "${bin_tgz}" "${bin_dir}" || return 1 + _env "${bin_dir}" | tee "${bin_env}" || return 1 + echo "export GIMME_ENV=\"$(_env_alias "${bin_dir}" "${bin_env}")\"" +} + +_try_source() { + local src_tgz="${GIMME_TMP}/go${GIMME_GO_VERSION}.src.tar.gz" + local src_dir="${GIMME_VERSION_PREFIX}/go${GIMME_GO_VERSION}.src" + local src_env="${GIMME_ENV_PREFIX}/go${GIMME_GO_VERSION}.${GIMME_OS}.${GIMME_ARCH}.env" + + _source "${GIMME_GO_VERSION}" "${src_tgz}" || return 1 + _extract "${src_tgz}" "${src_dir}" || return 1 + _compile "${src_dir}" || return 1 + _env "${src_dir}" | tee "${src_env}" || return 1 + echo "export GIMME_ENV=\"$(_env_alias "${src_dir}" "${src_env}")\"" +} + +_try_git() { + local git_dir="${GIMME_VERSION_PREFIX}/go" + local git_env="${GIMME_ENV_PREFIX}/go.git.${GIMME_OS}.${GIMME_ARCH}.env" + + _checkout "${GIMME_GO_VERSION}" "${git_dir}" || return 1 + _compile "${git_dir}" || return 1 + _env "${git_dir}" | tee "${git_env}" || return 1 + echo "export GIMME_ENV=\"$(_env_alias "${git_dir}" "${git_env}")\"" +} + +_wipe_version() { + local env_file="${GIMME_ENV_PREFIX}/go${1}.${GIMME_OS}.${GIMME_ARCH}.env" + + if [[ -s "${env_file}" ]] ; then + rm -rf "$(awk -F\" '/GOROOT/ { print $2 }' "${env_file}")" + rm -f "${env_file}" + fi +} + +_list_versions() { + if [ ! -d "${GIMME_VERSION_PREFIX}" ] ; then + return 0 + fi + + local current_version="$(go env GOROOT 2>/dev/null)" + current_version="${current_version##*/go}" + current_version="${current_version%%.${GIMME_OS}.*}" + + for d in "${GIMME_VERSION_PREFIX}/go"*".${GIMME_OS}."* ; do + local cleaned="${d##*/go}" + cleaned="${cleaned%%.${GIMME_OS}.*}" + echo -en "${cleaned}" + if [[ $cleaned = $current_version ]] ; then + echo -en >&2 ' <= current' + fi + echo + done +} + +_realpath() { + [ -d "$1" ] && echo "$(cd "$1" && pwd)" || echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")" +} + +_assert_version_given() { + if [[ -z "${GIMME_GO_VERSION}" ]] ; then + echo >&2 'error: no GIMME_GO_VERSION supplied' + echo >&2 " ex: GIMME_GO_VERSION=1.4.1 ${0} ${@}" + echo >&2 " ex: ${0} 1.4.1 ${@}" + exit 1 + fi +} + +: ${GIMME_OS:=$(uname -s | tr '[:upper:]' '[:lower:]')} +: ${GIMME_HOSTOS:=$(uname -s | tr '[:upper:]' '[:lower:]')} +: ${GIMME_ARCH:=$(uname -m)} +: ${GIMME_HOSTARCH:=$(uname -m)} +: ${GIMME_ENV_PREFIX:=${HOME}/.gimme/envs} +: ${GIMME_VERSION_PREFIX:=${HOME}/.gimme/versions} +: ${GIMME_TMP:=${TMPDIR:-/tmp}/gimme} +: ${GIMME_GO_GIT_REMOTE:=https://github.com/golang/go.git} +: ${GIMME_TYPE:=auto} # 'auto', 'binary', 'source', or 'git' +: ${GIMME_BINARY_OSX:=osx10.8} + +while [[ $# -gt 0 ]]; do + case "${1}" in + -h|--help|help|wat) + _old_ifs="$IFS" + IFS=';' + awk '/^#\+ / { + sub(/^#\+ /, "", $0) ; + sub(/-$/, "", $0) ; + print $0 + }' "$0" | while read line ; do + eval "echo \"$line\"" + done + IFS="$_old_ifs" + exit 0 + ;; + -V|--version|version) + echo "${GIMME_VERSION}" + exit 0 + ;; + -l|--list|list) + _list_versions + exit 0 + ;; + -f|--force|force) + force=1 + ;; + *) + break + ;; + esac + shift +done + +if [[ -n "${1}" ]] ; then + GIMME_GO_VERSION="${1}" +fi +if [[ -n "${2}" ]] ; then + GIMME_VERSION_PREFIX="${2}" +fi + +case "${GIMME_ARCH}" in + x86_64) GIMME_ARCH=amd64 ;; + x86) GIMME_ARCH=386 ;; + arm64) + if [[ "${GIMME_GO_VERSION}" < "1.5" ]]; then + echo >&2 "error: ${GIMME_ARCH} is not supported by this go version" + echo >&2 "try go1.5 or newer" + exit 1 + fi + if [[ "${GIMME_HOSTOS}" = "linux" && "${GIMME_HOSTARCH}" != "${GIMME_ARCH}" ]]; then + : ${GIMME_CC_FOR_TARGET:="aarch64-linux-gnu-gcc"} + fi + ;; + arm*) GIMME_ARCH=arm ;; +esac + +case "${GIMME_HOSTARCH}" in + x86_64) GIMME_HOSTARCH=amd64 ;; + x86) GIMME_HOSTARCH=386 ;; + arm64) ;; + arm*) GIMME_HOSTARCH=arm ;; +esac + +_assert_version_given "$@" + +[ ${force} ] && _wipe_version "${GIMME_GO_VERSION}" + +unset GOARCH +unset GOBIN +unset GOOS +unset GOPATH +unset GOROOT +unset CGO_ENABLED +unset CC_FOR_TARGET + +mkdir -p "${GIMME_VERSION_PREFIX}" "${GIMME_ENV_PREFIX}" + +GIMME_VERSION_PREFIX="$(_realpath "${GIMME_VERSION_PREFIX}")" +GIMME_ENV_PREFIX="$(_realpath "${GIMME_ENV_PREFIX}")" + +if ! case "${GIMME_TYPE}" in + binary) _try_existing || _try_binary "${GIMME_GO_VERSION}" "${GIMME_ARCH}" ;; + source) _try_source || _try_git ;; + git) _try_git ;; + auto) _try_existing || _try_binary "${GIMME_GO_VERSION}" "${GIMME_ARCH}" || _try_source || _try_git ;; + *) + echo >&2 "I don't know how to '${GIMME_TYPE}'." + echo >&2 " Try 'auto', 'binary', 'source', or 'git'." + exit 1 + ;; +esac ; then + echo >&2 "I don't have any idea what to do with '${GIMME_GO_VERSION}'." + echo >&2 " (using type '${GIMME_TYPE}')" + exit 1 +fi From 1b332d19334c9d662121399903dd9d6de5bbbfe0 Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Mon, 27 Jun 2016 11:21:49 -0700 Subject: [PATCH 0451/1304] travis: Add arm64 to build matrix Signed-off-by: Geoff Levand --- .travis.yml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6ce4bc67f0..ced0d50191 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,10 @@ go: - 1.5.3 - 1.6 +env: + - TARGET=amd64 + - TARGET=arm64 + addons: apt: packages: @@ -17,13 +21,22 @@ addons: - build-essential - libacl1-dev - libsystemd-journal-dev + - gcc-aarch64-linux-gnu + - libc6-dev-arm64-cross install: - script: - - ./autogen.sh # Build host and fly to ensure we build stage1 init. We don't build everything # to avoid downloading large images. - - ./configure --with-stage1-flavors=host,fly --enable-tpm=auto - - make unit-check + - if [ "${TARGET}" == "amd64" ]; then + ./autogen.sh; + ./configure --with-stage1-flavors=host,fly --enable-tpm=auto; + make unit-check; + elif [ "${TARGET}" == "arm64" ]; then + eval "$(GIMME_ARCH=${TARGET} GIMME_CGO_ENABLED=1 ./gimme.local ${TRAVIS_GO_VERSION})"; + ./autogen.sh; + ./configure --host=aarch64-linux-gnu --with-stage1-flavors=host,fly --enable-tpm=auto; + make V=2; + fi From d87acbb47bc83ba37d9a6aaf020be0b6cfa60530 Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Mon, 27 Jun 2016 11:21:49 -0700 Subject: [PATCH 0452/1304] release.md: Update for new target directories Signed-off-by: Geoff Levand --- Documentation/devel/release.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Documentation/devel/release.md b/Documentation/devel/release.md index 0d424082d3..f1b20631f8 100644 --- a/Documentation/devel/release.md +++ b/Documentation/devel/release.md @@ -54,9 +54,9 @@ After merging and going back to master branch, we check out the release version - `git clean -ffdx && sudo ./scripts/acbuild-rkt-builder.sh` - `rkt --insecure-options=image fetch ./rkt-builder.aci` - `export BUILDDIR=$PWD/release-build && mkdir -p $BUILDDIR && sudo BUILDDIR=$BUILDDIR ./scripts/build-rir.sh` - - Sanity check `release-build/bin/rkt version` - - Sanity check `ldd release-build/bin/rkt`: it can contain linux-vdso.so, libpthread.so, libc.so, libdl.so and ld-linux-x86-64.so but nothing else. - - Sanity check `ldd release-build/tools/init`: same as above. + - Sanity check `release-build/target/bin/rkt version` + - Sanity check `ldd release-build/target/bin/rkt`: it can contain linux-vdso.so, libpthread.so, libc.so, libdl.so and ld-linux-x86-64.so but nothing else. + - Sanity check `ldd release-build/target/tools/init`: same as above. - Grab the release key (see details below) and add a signed tag: `GIT_COMMITTER_NAME="CoreOS Application Signing Key" GIT_COMMITTER_EMAIL="security@coreos.com" git tag -u $RKTSUBKEYID'!' -s v1.2.0 -m "rkt v1.2.0"` - Push the tag to GitHub: `git push --tags` @@ -73,7 +73,7 @@ Now we switch to the GitHub web UI to conduct the release: export RKTVER="1.2.0" export NAME="rkt-v$RKTVER" mkdir $NAME -cp release-build/bin/rkt release-build/bin/stage1-{coreos,kvm,fly}.aci $NAME/ +cp release-build/target/bin/rkt release-build/target/bin/stage1-{coreos,kvm,fly}.aci $NAME/ cp -r dist/* $NAME/ sudo chown -R root:root $NAME/ tar czvf $NAME.tar.gz --numeric-owner $NAME/ @@ -82,9 +82,9 @@ tar czvf $NAME.tar.gz --numeric-owner $NAME/ - Attach each stage1 file individually so they can be fetched by the ACI discovery mechanism. The files must be named as follows: ``` -cp release-build/bin/stage1-coreos.aci stage1-coreos-$RKTVER-linux-amd64.aci -cp release-build/bin/stage1-kvm.aci stage1-kvm-$RKTVER-linux-amd64.aci -cp release-build/bin/stage1-fly.aci stage1-fly-$RKTVER-linux-amd64.aci +cp release-build/target/bin/stage1-coreos.aci stage1-coreos-$RKTVER-linux-amd64.aci +cp release-build/target/bin/stage1-kvm.aci stage1-kvm-$RKTVER-linux-amd64.aci +cp release-build/target/bin/stage1-fly.aci stage1-fly-$RKTVER-linux-amd64.aci ``` - Sign all release artifacts. From 1e31c7cbecb300b891988a5af711c587d2e1faf0 Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Mon, 27 Jun 2016 11:21:50 -0700 Subject: [PATCH 0453/1304] CHANGELOG: Updates for arm64 support Signed-off-by: Geoff Levand --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13a60a4a19..0cdb282588 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v1.10.0 + +#### Other changes + +- build directory layout change ([#2758](https://github.com/coreos/rkt/pull/2758)): The rkt binary and stage1 image files have been moved from the 'bin' sub-directory to the 'target/bin' sub-directory. + ## v1.9.1 This is a minor bug fix release. From bc18c26d2669860eab8d571b856b2ffec1f59b19 Mon Sep 17 00:00:00 2001 From: Thomas Hipp Date: Tue, 28 Jun 2016 11:43:11 +0200 Subject: [PATCH 0454/1304] Documentation: add openSUSE to distributions Closes #1308 Signed-off-by: Thomas Hipp --- Documentation/distributions.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Documentation/distributions.md b/Documentation/distributions.md index b40c41c75e..9faf390798 100644 --- a/Documentation/distributions.md +++ b/Documentation/distributions.md @@ -96,6 +96,23 @@ nix-env -iA rkt The source for the rkt.nix expression can be found on [GitHub](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/virtualization/rkt/default.nix) + +## openSUSE + +rkt is available in the [Virtualization:containers](https://build.opensuse.org/package/show/Virtualization:containers/rkt) project on openSUSE Build Service. +Before installing, the appropriate repository needs to be added (usually Tumbleweed or Leap): + +``` +sudo zypper ar -f obs://Virtualization:containers/openSUSE_Tumbleweed/ virtualization_containers +sudo zypper ar -f obs://Virtualization:containers/openSUSE_Leap_42.1/ virtualization_containers +``` + +Install rkt using zypper: + +``` +sudo zypper in rkt +``` + ## Void rkt is available in the [official binary packages](http://www.voidlinux.eu/packages/) for the Void Linux distribution. From 609559dda858cc00b69f133e9090ee3341e28e96 Mon Sep 17 00:00:00 2001 From: Alex Crawford Date: Tue, 28 Jun 2016 16:42:35 -0700 Subject: [PATCH 0455/1304] pkg/tar: ignore global extended headers --- pkg/tar/tar.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/tar/tar.go b/pkg/tar/tar.go index 0d8f27ad87..322fd95b20 100644 --- a/pkg/tar/tar.go +++ b/pkg/tar/tar.go @@ -194,6 +194,8 @@ func extractFile(tr *tar.Reader, target string, hdr *tar.Header, overwrite bool, if err := syscall.Mkfifo(p, uint32(fi.Mode())); err != nil { return err } + case typ == tar.TypeXGlobalHeader: + return nil // TODO(jonboulle): implement other modes default: return fmt.Errorf("unsupported type: %v", typ) From 12ecf682e2fe4238aa4590c140527017cfa2cfc6 Mon Sep 17 00:00:00 2001 From: Alex Crawford Date: Tue, 28 Jun 2016 16:49:20 -0700 Subject: [PATCH 0456/1304] pkg/tar: remove errwrap Since this package can be used outside of rkt, there is no need to obscure the return values by using errwrap. All of the internal consumers of these functions already wrap the output anyway, so this is actually redundant. For example, extractTarCommand() may return: error extracting tarball error extracting tarball no such file or directory This change removes the outermost wrap: error extracting tarball no such file or directory --- pkg/tar/tar.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/tar/tar.go b/pkg/tar/tar.go index 0d8f27ad87..cb95c8c8a2 100644 --- a/pkg/tar/tar.go +++ b/pkg/tar/tar.go @@ -28,7 +28,6 @@ import ( "github.com/appc/spec/pkg/device" "github.com/coreos/rkt/pkg/fileutil" "github.com/coreos/rkt/pkg/user" - "github.com/hashicorp/errwrap" ) const DEFAULT_DIR_MODE os.FileMode = 0755 @@ -94,13 +93,13 @@ Tar: } err = extractFile(tr, target, hdr, overwrite, editor) if err != nil { - return errwrap.Wrap(errors.New("error extracting tarball"), err) + return err } if hdr.Typeflag == tar.TypeDir { dirhdrs = append(dirhdrs, hdr) } default: - return errwrap.Wrap(errors.New("error extracting tarball"), err) + return err } } @@ -242,11 +241,11 @@ func extractFileFromTar(tr *tar.Reader, file string) ([]byte, error) { } buf, err := ioutil.ReadAll(tr) if err != nil { - return nil, errwrap.Wrap(errors.New("error extracting tarball"), err) + return nil, err } return buf, nil default: - return nil, errwrap.Wrap(errors.New("error extracting tarball"), err) + return nil, err } } } From c6b9bc5c83326312805c230e241c0664254c3f92 Mon Sep 17 00:00:00 2001 From: Alessandro Puccetti Date: Thu, 23 Jun 2016 18:10:26 +0200 Subject: [PATCH 0457/1304] stage1/enterexec: environment file with '\n' as separator (systemd style) This patch modifies enterexec to get environment files with variables separated by the new line character (like the systemd ones). This patch works also with environment files in the old format (separator '\0'). Fixes https://github.com/coreos/rkt/issues/2507 --- stage1/enterexec/enterexec.c | 38 ++++++++++++++++-------------------- stage1/init/common/path.go | 25 ++++++------------------ stage1/init/common/pod.go | 12 +++--------- 3 files changed, 26 insertions(+), 49 deletions(-) diff --git a/stage1/enterexec/enterexec.c b/stage1/enterexec/enterexec.c index 36079235a2..0d8c16361b 100644 --- a/stage1/enterexec/enterexec.c +++ b/stage1/enterexec/enterexec.c @@ -177,34 +177,30 @@ void initialize_keep_env(const char *keep_env_file, const char **keep_env) /* Try to set current env from keep_env and env file. */ static void set_env(const char *env_file) { - struct stat st; - char *map, *k, *v; - typeof(st.st_size) i; - - map_file(env_file, PROT_READ|PROT_WRITE, MAP_PRIVATE, &st, (void **)&map); - - if(!st.st_size) - return; - - map[st.st_size - 1] = '\0'; /* ensure the mapping is null-terminated */ - - for(i = 0; i < st.st_size;) { - k = &map[i]; - i += strlen(k) + 1; - exit_if((v = strchr(k, '=')) == NULL, - "Malformed environment entry: \"%s\"", k); - /* a private writable map is used permitting s/=/\0/ */ + FILE *f; + char *line = NULL; + size_t len = 0; + ssize_t read; + char *v; + + pexit_if((f = fopen(env_file, "r")) == NULL, + "Unable to fopen \"%s\"", env_file); + while ((read = getline(&line, &len, f)) != -1) { + pexit_if((v = strchr(line, '=')) == NULL, + "Malformed environment entry: \"%s\"", line); *v = '\0'; v++; - pexit_if(setenv(k, v, 1) == -1, - "Unable to set env variable: \"%s\"=\"%s\"", k, v); + pexit_if(setenv(line, v, 1) == -1, + "Unable to set env variable: \"%s\"=\"%s\"", line, v); } -} + free(line); + pexit_if(fclose(f) == EOF, + "Unable to fclose \"%s\"", env_file);} /* Read environment from env and keep_env files make it our own, keeping the env variables in * if they're present in the current environment. * The environment files must exist, may be empty, and are expected to be of the format: - * key=value\0key=value\0... + * key=value\nkey=value\n... */ static void load_env(const char *env_file, const char *keep_env_file, int entering) { diff --git a/stage1/init/common/path.go b/stage1/init/common/path.go index 51422e04c0..e2a9b733e3 100644 --- a/stage1/init/common/path.go +++ b/stage1/init/common/path.go @@ -43,28 +43,15 @@ func ServiceUnitPath(root string, appName types.ACName) string { return filepath.Join(common.Stage1RootfsPath(root), UnitsDir, ServiceUnitName(appName)) } -// RelEnvFilePathEnterexec returns the path to the environment file for the given -// app name relative to the pod's root to be parsed by enterexec. -func RelEnvFilePathEnterexec(appName types.ACName) string { +// RelEnvFilePath returns the path to the environment file for the given +// app name relative to the pod's root. +func RelEnvFilePath(appName types.ACName) string { return filepath.Join(envDir, appName.String()) } -// EnvFilePathEnterexec returns the path to the environment file for the given -// app name to be parsed by enterexec. -func EnvFilePathEnterexec(root string, appName types.ACName) string { - return filepath.Join(common.Stage1RootfsPath(root), RelEnvFilePathEnterexec(appName)) -} - -// RelEnvFilePathSystemd returns the path to the environment file for the given -// app name relative to the pod's root to be parsed by systemd. -func RelEnvFilePathSystemd(appName types.ACName) string { - return filepath.Join(envDir, appName.String()) + "-systemd" -} - -// EnvFilePathSystemd returns the path to the environment file for the given -// app name to be parsed by systemd. -func EnvFilePathSystemd(root string, appName types.ACName) string { - return EnvFilePathEnterexec(root, appName) + "-systemd" +// EnvFilePath returns the path to the environment file for the given app name. +func EnvFilePath(root string, appName types.ACName) string { + return filepath.Join(common.Stage1RootfsPath(root), RelEnvFilePath(appName)) } // ServiceWantPath returns the systemd default.target want symlink path for the diff --git a/stage1/init/common/pod.go b/stage1/init/common/pod.go index 13aba46a98..c847ae5620 100644 --- a/stage1/init/common/pod.go +++ b/stage1/init/common/pod.go @@ -388,23 +388,17 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b env.Set("AC_METADATA_URL", p.MetadataServiceURL) } - // TODO(iaguis): make enterexec use the same format as systemd - envFilePathSystemd := EnvFilePathSystemd(p.Root, appName) - envFilePathEnterexec := EnvFilePathEnterexec(p.Root, appName) + envFilePath := EnvFilePath(p.Root, appName) uidRange := user.NewBlankUidRange() if err := uidRange.Deserialize([]byte(privateUsers)); err != nil { return err } - if err := writeEnvFile(p, env, appName, uidRange, '\n', envFilePathSystemd); err != nil { + if err := writeEnvFile(p, env, appName, uidRange, '\n', envFilePath); err != nil { return errwrap.Wrap(errors.New("unable to write environment file for systemd"), err) } - if err := writeEnvFile(p, env, appName, uidRange, '\000', envFilePathEnterexec); err != nil { - return errwrap.Wrap(errors.New("unable to write environment file for enterexec"), err) - } - u, g, err := parseUserGroup(p, ra, uidRange) if err != nil { return err @@ -444,7 +438,7 @@ func appToSystemd(p *stage1commontypes.Pod, ra *schema.RuntimeApp, interactive b // as it might seem) makes sure the mount is slave+shared. unit.NewUnitOption("Service", "MountFlags", "shared"), unit.NewUnitOption("Service", "WorkingDirectory", workDir), - unit.NewUnitOption("Service", "EnvironmentFile", RelEnvFilePathSystemd(appName)), + unit.NewUnitOption("Service", "EnvironmentFile", RelEnvFilePath(appName)), unit.NewUnitOption("Service", "User", strconv.Itoa(u)), unit.NewUnitOption("Service", "Group", strconv.Itoa(g)), unit.NewUnitOption("Service", "SupplementaryGroups", strings.Join(supplementaryGroups, " ")), From 8b5deb1f0cb61f15aff8e5dc2c77451c20134e30 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Wed, 29 Jun 2016 10:38:26 +0200 Subject: [PATCH 0458/1304] glide: vendor dependencies --- glide.lock | 293 + vendor/github.com/StackExchange/wmi/LICENSE | 20 + vendor/github.com/StackExchange/wmi/wmi.go | 416 + vendor/github.com/appc/docker2aci/LICENSE | 202 + .../appc/docker2aci/lib/common/common.go | 62 + .../appc/docker2aci/lib/conversion_store.go | 126 + .../appc/docker2aci/lib/docker2aci.go | 417 + .../lib/internal/backend/file/file.go | 332 + .../internal/backend/repository/repository.go | 164 + .../backend/repository/repository1.go | 391 + .../backend/repository/repository2.go | 466 ++ .../lib/internal/docker/docker_functions.go | 161 + .../appc/docker2aci/lib/internal/internal.go | 591 ++ .../lib/internal/tarball/tarfile.go | 42 + .../docker2aci/lib/internal/tarball/walk.go | 43 + .../lib/internal/types/docker_types.go | 92 + .../docker2aci/lib/internal/types/types.go | 27 + .../appc/docker2aci/lib/internal/util/util.go | 83 + .../github.com/appc/docker2aci/lib/version.go | 20 + vendor/github.com/appc/docker2aci/main.go | 222 + .../github.com/appc/docker2aci/pkg/log/log.go | 46 + vendor/github.com/appc/goaci/LICENSE | 202 + .../github.com/appc/goaci/buildercommand.go | 50 + vendor/github.com/appc/goaci/command.go | 12 + vendor/github.com/appc/goaci/commands.go | 15 + vendor/github.com/appc/goaci/main.go | 59 + vendor/github.com/appc/goaci/mappers.go | 150 + .../github.com/appc/goaci/proj2aci/asset.go | 283 + .../github.com/appc/goaci/proj2aci/binary.go | 44 + .../github.com/appc/goaci/proj2aci/builder.go | 365 + .../github.com/appc/goaci/proj2aci/cmake.go | 234 + vendor/github.com/appc/goaci/proj2aci/go.go | 195 + vendor/github.com/appc/goaci/proj2aci/run.go | 65 + vendor/github.com/appc/goaci/proj2aci/util.go | 68 + vendor/github.com/appc/goaci/proj2aci/vcs.go | 118 + vendor/github.com/appc/spec/LICENSE | 202 + vendor/github.com/appc/spec/ace/doc.go | 19 + .../appc/spec/ace/image_manifest_main.json.in | 80 + .../spec/ace/image_manifest_sidekick.json.in | 24 + vendor/github.com/appc/spec/ace/os_default.go | 26 + vendor/github.com/appc/spec/ace/os_freebsd.go | 32 + vendor/github.com/appc/spec/ace/os_linux.go | 45 + vendor/github.com/appc/spec/ace/os_shared.go | 35 + vendor/github.com/appc/spec/ace/validator.go | 578 ++ vendor/github.com/appc/spec/aci/build.go | 110 + vendor/github.com/appc/spec/aci/doc.go | 16 + vendor/github.com/appc/spec/aci/file.go | 246 + vendor/github.com/appc/spec/aci/layout.go | 187 + vendor/github.com/appc/spec/aci/writer.go | 98 + vendor/github.com/appc/spec/actool/actool.go | 118 + vendor/github.com/appc/spec/actool/build.go | 145 + .../github.com/appc/spec/actool/discover.go | 106 + vendor/github.com/appc/spec/actool/doc.go | 17 + vendor/github.com/appc/spec/actool/help.go | 140 + .../github.com/appc/spec/actool/manifest.go | 525 ++ .../github.com/appc/spec/actool/validate.go | 177 + vendor/github.com/appc/spec/actool/version.go | 33 + .../appc/spec/discovery/discovery.go | 257 + vendor/github.com/appc/spec/discovery/doc.go | 17 + vendor/github.com/appc/spec/discovery/http.go | 122 + .../github.com/appc/spec/discovery/parse.go | 130 + .../appc/spec/pkg/acirenderer/acirenderer.go | 253 + .../appc/spec/pkg/acirenderer/resolve.go | 88 + .../appc/spec/pkg/device/device_linux.go | 33 + .../appc/spec/pkg/device/device_posix.go | 57 + .../github.com/appc/spec/pkg/tarheader/doc.go | 17 + .../appc/spec/pkg/tarheader/pop_darwin.go | 39 + .../appc/spec/pkg/tarheader/pop_linux.go | 39 + .../appc/spec/pkg/tarheader/pop_posix.go | 50 + .../appc/spec/pkg/tarheader/tarheader.go | 28 + .../appc/spec/schema/common/common.go | 40 + vendor/github.com/appc/spec/schema/doc.go | 25 + vendor/github.com/appc/spec/schema/image.go | 103 + vendor/github.com/appc/spec/schema/kind.go | 42 + .../appc/spec/schema/lastditch/doc.go | 28 + .../appc/spec/schema/lastditch/image.go | 45 + .../appc/spec/schema/lastditch/labels.go | 38 + .../appc/spec/schema/lastditch/pod.go | 57 + vendor/github.com/appc/spec/schema/pod.go | 168 + .../appc/spec/schema/types/acidentifier.go | 145 + .../appc/spec/schema/types/ackind.go | 67 + .../appc/spec/schema/types/acname.go | 145 + .../appc/spec/schema/types/annotations.go | 106 + .../github.com/appc/spec/schema/types/app.go | 90 + .../github.com/appc/spec/schema/types/date.go | 60 + .../appc/spec/schema/types/dependencies.go | 58 + .../github.com/appc/spec/schema/types/doc.go | 18 + .../appc/spec/schema/types/environment.go | 110 + .../appc/spec/schema/types/errors.go | 49 + .../appc/spec/schema/types/event_handler.go | 61 + .../github.com/appc/spec/schema/types/exec.go | 46 + .../github.com/appc/spec/schema/types/hash.go | 118 + .../appc/spec/schema/types/isolator.go | 129 + .../schema/types/isolator_linux_specific.go | 163 + .../spec/schema/types/isolator_resources.go | 236 + .../appc/spec/schema/types/labels.go | 134 + .../appc/spec/schema/types/mountpoint.go | 91 + .../github.com/appc/spec/schema/types/port.go | 139 + .../appc/spec/schema/types/semver.go | 91 + .../github.com/appc/spec/schema/types/url.go | 71 + .../github.com/appc/spec/schema/types/uuid.go | 92 + .../appc/spec/schema/types/volume.go | 236 + vendor/github.com/appc/spec/schema/version.go | 39 + vendor/github.com/aws/aws-sdk-go/LICENSE.txt | 202 + vendor/github.com/aws/aws-sdk-go/NOTICE.txt | 3 + .../aws/aws-sdk-go/aws/awserr/error.go | 124 + .../aws/aws-sdk-go/aws/awserr/types.go | 197 + .../aws/aws-sdk-go/aws/awsutil/copy.go | 100 + .../aws/aws-sdk-go/aws/awsutil/equal.go | 27 + .../aws/aws-sdk-go/aws/awsutil/path_value.go | 222 + .../aws/aws-sdk-go/aws/awsutil/prettify.go | 103 + .../aws-sdk-go/aws/awsutil/string_value.go | 89 + .../aws/client/metadata/client_info.go | 12 + .../github.com/aws/aws-sdk-go/aws/config.go | 311 + .../aws/aws-sdk-go/aws/convert_types.go | 357 + .../aws/credentials/chain_provider.go | 100 + .../aws-sdk-go/aws/credentials/credentials.go | 223 + .../aws/credentials/env_provider.go | 77 + .../shared_credentials_provider.go | 151 + .../aws/credentials/static_provider.go | 48 + .../github.com/aws/aws-sdk-go/aws/errors.go | 17 + .../github.com/aws/aws-sdk-go/aws/logger.go | 112 + .../aws/aws-sdk-go/aws/request/handlers.go | 187 + .../aws/aws-sdk-go/aws/request/request.go | 302 + .../aws/request/request_pagination.go | 104 + .../aws/aws-sdk-go/aws/request/retryer.go | 82 + vendor/github.com/aws/aws-sdk-go/aws/types.go | 88 + .../github.com/aws/aws-sdk-go/aws/version.go | 8 + .../aws-sdk-go/private/protocol/rest/build.go | 257 + .../private/protocol/rest/payload.go | 45 + .../private/protocol/rest/unmarshal.go | 193 + .../private/signer/v4/header_rules.go | 82 + .../aws/aws-sdk-go/private/signer/v4/v4.go | 438 ++ vendor/github.com/aws/aws-sdk-go/sdk.go | 7 + vendor/github.com/camlistore/go4/LICENSE | 202 + vendor/github.com/camlistore/go4/lock/lock.go | 186 + .../camlistore/go4/lock/lock_appengine.go | 32 + .../camlistore/go4/lock/lock_darwin_amd64.go | 67 + .../camlistore/go4/lock/lock_freebsd.go | 66 + .../camlistore/go4/lock/lock_linux_amd64.go | 67 + .../camlistore/go4/lock/lock_linux_arm.go | 68 + .../camlistore/go4/lock/lock_plan9.go | 41 + .../camlistore/go4/lock/lock_sigzero.go | 26 + .../containernetworking/cni/LICENSE | 202 + .../cni/pkg/invoke/args.go | 76 + .../cni/pkg/invoke/delegate.go | 53 + .../cni/pkg/invoke/exec.go | 75 + .../cni/pkg/invoke/find.go | 47 + .../containernetworking/cni/pkg/ip/cidr.go | 51 + .../cni/pkg/ip/ipforward.go | 31 + .../containernetworking/cni/pkg/ip/ipmasq.go | 66 + .../containernetworking/cni/pkg/ip/link.go | 153 + .../containernetworking/cni/pkg/ip/route.go | 47 + .../containernetworking/cni/pkg/ipam/ipam.go | 68 + .../containernetworking/cni/pkg/ns/ns.go | 315 + .../containernetworking/cni/pkg/skel/skel.go | 161 + .../cni/pkg/testutils/cmd.go | 77 + .../containernetworking/cni/pkg/types/args.go | 91 + .../cni/pkg/types/types.go | 191 + .../cni/pkg/utils/sysctl/sysctl_linux.go | 58 + .../cni/pkg/utils/utils.go | 41 + .../cni/plugins/ipam/dhcp/daemon.go | 157 + .../cni/plugins/ipam/dhcp/lease.go | 337 + .../cni/plugins/ipam/dhcp/main.go | 73 + .../cni/plugins/ipam/dhcp/options.go | 139 + .../cni/plugins/ipam/host-local/allocator.go | 165 + .../ipam/host-local/backend/disk/backend.go | 88 + .../ipam/host-local/backend/disk/lock.go | 50 + .../plugins/ipam/host-local/backend/store.go | 26 + .../cni/plugins/ipam/host-local/config.go | 70 + .../cni/plugins/ipam/host-local/main.go | 74 + .../cni/plugins/main/bridge/bridge.go | 319 + .../cni/plugins/main/ipvlan/ipvlan.go | 175 + .../cni/plugins/main/macvlan/macvlan.go | 193 + .../cni/plugins/main/ptp/ptp.go | 229 + .../cni/plugins/meta/flannel/flannel.go | 253 + .../cni/plugins/meta/tuning/tuning.go | 82 + vendor/github.com/coreos/gexpect/LICENCE | 7 + vendor/github.com/coreos/gexpect/gexpect.go | 449 ++ vendor/github.com/coreos/go-iptables/LICENSE | 191 + .../coreos/go-iptables/iptables/iptables.go | 295 + .../coreos/go-iptables/iptables/lock.go | 84 + vendor/github.com/coreos/go-semver/LICENSE | 202 + vendor/github.com/coreos/go-semver/example.go | 20 + .../coreos/go-semver/semver/semver.go | 257 + .../coreos/go-semver/semver/sort.go | 38 + vendor/github.com/coreos/go-systemd/LICENSE | 191 + .../coreos/go-systemd/activation/files.go | 52 + .../coreos/go-systemd/activation/listeners.go | 62 + .../go-systemd/activation/packetconns.go | 37 + .../github.com/coreos/go-systemd/dbus/dbus.go | 203 + .../coreos/go-systemd/dbus/methods.go | 484 ++ .../coreos/go-systemd/dbus/properties.go | 218 + .../github.com/coreos/go-systemd/dbus/set.go | 47 + .../coreos/go-systemd/dbus/subscription.go | 250 + .../go-systemd/dbus/subscription_set.go | 57 + .../coreos/go-systemd/sdjournal/journal.go | 971 +++ .../coreos/go-systemd/sdjournal/read.go | 252 + .../coreos/go-systemd/unit/deserialize.go | 276 + .../coreos/go-systemd/unit/escape.go | 116 + .../coreos/go-systemd/unit/option.go | 54 + .../coreos/go-systemd/unit/serialize.go | 75 + .../github.com/coreos/go-systemd/util/util.go | 227 + vendor/github.com/coreos/go-tspi/LICENSE | 202 + .../coreos/go-tspi/tpmclient/tpmclient.go | 310 + .../coreos/go-tspi/tspiconst/tspiconst.go | 538 ++ .../go-tspi/verification/verification.go | 654 ++ vendor/github.com/coreos/ioprogress/LICENSE | 21 + vendor/github.com/coreos/ioprogress/draw.go | 132 + vendor/github.com/coreos/ioprogress/reader.go | 107 + vendor/github.com/coreos/pkg/LICENSE | 202 + vendor/github.com/coreos/pkg/NOTICE | 5 + vendor/github.com/coreos/pkg/dlopen/dlopen.go | 82 + .../coreos/pkg/dlopen/dlopen_example.go | 56 + .../coreos/pkg/progressutil/iocopy.go | 189 + .../coreos/pkg/progressutil/progressbar.go | 256 + .../github.com/cpuguy83/go-md2man/LICENSE.md | 21 + .../github.com/cpuguy83/go-md2man/md2man.go | 44 + .../cpuguy83/go-md2man/md2man/md2man.go | 19 + .../cpuguy83/go-md2man/md2man/roff.go | 269 + vendor/github.com/cznic/b/LICENSE | 27 + vendor/github.com/cznic/b/btree.go | 929 +++ vendor/github.com/cznic/b/doc.go | 53 + vendor/github.com/cznic/bufs/LICENSE | 27 + vendor/github.com/cznic/bufs/bufs.go | 391 + vendor/github.com/cznic/exp/lldb/2pc.go | 324 + vendor/github.com/cznic/exp/lldb/2pc_docs.go | 44 + vendor/github.com/cznic/exp/lldb/LICENSE | 27 + vendor/github.com/cznic/exp/lldb/btree.go | 2297 ++++++ vendor/github.com/cznic/exp/lldb/errors.go | 170 + vendor/github.com/cznic/exp/lldb/falloc.go | 1981 +++++ vendor/github.com/cznic/exp/lldb/filer.go | 192 + vendor/github.com/cznic/exp/lldb/gb.go | 812 ++ vendor/github.com/cznic/exp/lldb/lldb.go | 155 + vendor/github.com/cznic/exp/lldb/memfiler.go | 344 + vendor/github.com/cznic/exp/lldb/osfiler.go | 130 + .../cznic/exp/lldb/simplefilefiler.go | 123 + vendor/github.com/cznic/exp/lldb/xact.go | 629 ++ vendor/github.com/cznic/fileutil/LICENSE | 27 + vendor/github.com/cznic/fileutil/fileutil.go | 223 + .../github.com/cznic/fileutil/fileutil_arm.go | 25 + .../cznic/fileutil/fileutil_darwin.go | 25 + .../cznic/fileutil/fileutil_freebsd.go | 25 + .../cznic/fileutil/fileutil_linux.go | 96 + .../cznic/fileutil/fileutil_openbsd.go | 25 + .../cznic/fileutil/fileutil_plan9.go | 25 + .../cznic/fileutil/fileutil_solaris.go | 27 + .../cznic/fileutil/fileutil_windows.go | 183 + vendor/github.com/cznic/fileutil/test_deps.go | 13 + vendor/github.com/cznic/mathutil/LICENSE | 27 + vendor/github.com/cznic/mathutil/bits.go | 207 + vendor/github.com/cznic/mathutil/envelope.go | 46 + vendor/github.com/cznic/mathutil/mathutil.go | 829 ++ vendor/github.com/cznic/mathutil/permute.go | 39 + vendor/github.com/cznic/mathutil/primes.go | 342 + vendor/github.com/cznic/mathutil/rat.go | 27 + vendor/github.com/cznic/mathutil/rnd.go | 383 + vendor/github.com/cznic/mathutil/tables.go | 6995 +++++++++++++++++ vendor/github.com/cznic/mathutil/test_deps.go | 11 + vendor/github.com/cznic/ql/LICENSE | 27 + vendor/github.com/cznic/ql/blob.go | 155 + vendor/github.com/cznic/ql/btree.go | 725 ++ vendor/github.com/cznic/ql/builtin.go | 991 +++ vendor/github.com/cznic/ql/coerce.go | 290 + vendor/github.com/cznic/ql/doc.go | 2606 ++++++ vendor/github.com/cznic/ql/driver.go | 523 ++ vendor/github.com/cznic/ql/driver/driver.go | 61 + vendor/github.com/cznic/ql/errors.go | 18 + vendor/github.com/cznic/ql/etc.go | 2805 +++++++ vendor/github.com/cznic/ql/expr.go | 4023 ++++++++++ vendor/github.com/cznic/ql/file.go | 1279 +++ vendor/github.com/cznic/ql/httpfs.go | 302 + vendor/github.com/cznic/ql/introspection.go | 625 ++ vendor/github.com/cznic/ql/mem.go | 1277 +++ vendor/github.com/cznic/ql/parser.go | 2637 +++++++ vendor/github.com/cznic/ql/plan.go | 2800 +++++++ vendor/github.com/cznic/ql/ql.go | 1729 ++++ vendor/github.com/cznic/ql/scanner.go | 4129 ++++++++++ vendor/github.com/cznic/ql/stmt.go | 1268 +++ vendor/github.com/cznic/ql/storage.go | 991 +++ vendor/github.com/cznic/sortutil/LICENSE | 27 + vendor/github.com/cznic/sortutil/sortutil.go | 227 + vendor/github.com/cznic/strutil/LICENSE | 27 + vendor/github.com/cznic/strutil/strutil.go | 428 + vendor/github.com/cznic/zappy/LICENSE | 27 + vendor/github.com/cznic/zappy/decode.go | 38 + vendor/github.com/cznic/zappy/decode_cgo.go | 121 + vendor/github.com/cznic/zappy/decode_nocgo.go | 89 + vendor/github.com/cznic/zappy/encode.go | 37 + vendor/github.com/cznic/zappy/encode_cgo.go | 140 + vendor/github.com/cznic/zappy/encode_nocgo.go | 92 + vendor/github.com/cznic/zappy/zappy.go | 241 + vendor/github.com/d2g/dhcp4/LICENSE | 27 + vendor/github.com/d2g/dhcp4/constants.go | 121 + vendor/github.com/d2g/dhcp4/helpers.go | 58 + vendor/github.com/d2g/dhcp4/option.go | 40 + vendor/github.com/d2g/dhcp4/packet.go | 149 + vendor/github.com/d2g/dhcp4client/LICENSE | 354 + vendor/github.com/d2g/dhcp4client/client.go | 366 + vendor/github.com/d2g/dhcp4client/inetsock.go | 75 + vendor/github.com/d2g/dhcp4client/init.go | 10 + .../d2g/dhcp4client/pktsock_linux.go | 147 + vendor/github.com/docker/distribution/LICENSE | 202 + .../github.com/docker/distribution/blobs.go | 233 + .../docker/distribution/digest/digest.go | 139 + .../docker/distribution/digest/digester.go | 155 + .../docker/distribution/digest/doc.go | 42 + .../docker/distribution/digest/set.go | 245 + .../docker/distribution/digest/verifiers.go | 44 + vendor/github.com/docker/distribution/doc.go | 7 + .../github.com/docker/distribution/errors.go | 111 + .../docker/distribution/manifests.go | 117 + .../distribution/reference/reference.go | 334 + .../docker/distribution/reference/regexp.go | 124 + .../docker/distribution/registry.go | 72 + vendor/github.com/docker/distribution/tags.go | 27 + vendor/github.com/dustin/go-humanize/LICENSE | 21 + vendor/github.com/dustin/go-humanize/big.go | 31 + .../github.com/dustin/go-humanize/bigbytes.go | 164 + vendor/github.com/dustin/go-humanize/bytes.go | 134 + vendor/github.com/dustin/go-humanize/comma.go | 101 + vendor/github.com/dustin/go-humanize/ftoa.go | 23 + .../github.com/dustin/go-humanize/humanize.go | 8 + .../github.com/dustin/go-humanize/number.go | 192 + .../github.com/dustin/go-humanize/ordinals.go | 25 + vendor/github.com/dustin/go-humanize/si.go | 110 + vendor/github.com/dustin/go-humanize/times.go | 91 + vendor/github.com/go-ini/ini/LICENSE | 191 + vendor/github.com/go-ini/ini/ini.go | 465 ++ vendor/github.com/go-ini/ini/key.go | 616 ++ vendor/github.com/go-ini/ini/parser.go | 312 + vendor/github.com/go-ini/ini/section.go | 177 + vendor/github.com/go-ini/ini/struct.go | 351 + vendor/github.com/go-ole/go-ole/com.go | 329 + vendor/github.com/go-ole/go-ole/com_func.go | 174 + vendor/github.com/go-ole/go-ole/connect.go | 192 + vendor/github.com/go-ole/go-ole/constants.go | 153 + vendor/github.com/go-ole/go-ole/error.go | 51 + vendor/github.com/go-ole/go-ole/error_func.go | 8 + .../github.com/go-ole/go-ole/error_windows.go | 24 + vendor/github.com/go-ole/go-ole/guid.go | 118 + .../go-ole/go-ole/iconnectionpoint.go | 20 + .../go-ole/go-ole/iconnectionpoint_func.go | 21 + .../go-ole/go-ole/iconnectionpoint_windows.go | 43 + .../go-ole/iconnectionpointcontainer.go | 17 + .../go-ole/iconnectionpointcontainer_func.go | 11 + .../iconnectionpointcontainer_windows.go | 25 + vendor/github.com/go-ole/go-ole/idispatch.go | 94 + .../go-ole/go-ole/idispatch_func.go | 19 + .../go-ole/go-ole/idispatch_windows.go | 193 + .../github.com/go-ole/go-ole/ienumvariant.go | 19 + .../go-ole/go-ole/ienumvariant_func.go | 19 + .../go-ole/go-ole/ienumvariant_windows.go | 63 + .../github.com/go-ole/go-ole/iinspectable.go | 18 + .../go-ole/go-ole/iinspectable_func.go | 15 + .../go-ole/go-ole/iinspectable_windows.go | 72 + .../go-ole/go-ole/iprovideclassinfo.go | 21 + .../go-ole/go-ole/iprovideclassinfo_func.go | 7 + .../go-ole/iprovideclassinfo_windows.go | 21 + vendor/github.com/go-ole/go-ole/itypeinfo.go | 34 + .../go-ole/go-ole/itypeinfo_func.go | 7 + .../go-ole/go-ole/itypeinfo_windows.go | 21 + vendor/github.com/go-ole/go-ole/iunknown.go | 57 + .../github.com/go-ole/go-ole/iunknown_func.go | 19 + .../go-ole/go-ole/iunknown_windows.go | 58 + vendor/github.com/go-ole/go-ole/ole.go | 147 + .../go-ole/go-ole/oleutil/connection.go | 100 + .../go-ole/go-ole/oleutil/connection_func.go | 10 + .../go-ole/oleutil/connection_windows.go | 57 + .../go-ole/go-ole/oleutil/go-get.go | 6 + .../go-ole/go-ole/oleutil/oleutil.go | 89 + vendor/github.com/go-ole/go-ole/safearray.go | 27 + .../go-ole/go-ole/safearray_func.go | 211 + .../go-ole/go-ole/safearray_windows.go | 337 + .../go-ole/go-ole/safearrayconversion.go | 140 + .../go-ole/go-ole/safearrayslices.go | 33 + vendor/github.com/go-ole/go-ole/utility.go | 101 + vendor/github.com/go-ole/go-ole/variables.go | 16 + vendor/github.com/go-ole/go-ole/variant.go | 105 + .../github.com/go-ole/go-ole/variant_386.go | 11 + .../github.com/go-ole/go-ole/variant_amd64.go | 12 + vendor/github.com/go-ole/go-ole/vt_string.go | 58 + vendor/github.com/go-ole/go-ole/winrt.go | 99 + vendor/github.com/go-ole/go-ole/winrt_doc.go | 36 + vendor/github.com/godbus/dbus/LICENSE | 25 + vendor/github.com/godbus/dbus/auth.go | 253 + .../github.com/godbus/dbus/auth_external.go | 26 + vendor/github.com/godbus/dbus/auth_sha1.go | 102 + vendor/github.com/godbus/dbus/call.go | 36 + vendor/github.com/godbus/dbus/conn.go | 625 ++ vendor/github.com/godbus/dbus/conn_darwin.go | 21 + vendor/github.com/godbus/dbus/conn_other.go | 27 + vendor/github.com/godbus/dbus/dbus.go | 258 + vendor/github.com/godbus/dbus/decoder.go | 228 + vendor/github.com/godbus/dbus/doc.go | 63 + vendor/github.com/godbus/dbus/encoder.go | 208 + vendor/github.com/godbus/dbus/export.go | 411 + vendor/github.com/godbus/dbus/homedir.go | 28 + .../github.com/godbus/dbus/homedir_dynamic.go | 15 + .../github.com/godbus/dbus/homedir_static.go | 45 + .../github.com/godbus/dbus/introspect/call.go | 27 + .../godbus/dbus/introspect/introspect.go | 86 + .../godbus/dbus/introspect/introspectable.go | 76 + vendor/github.com/godbus/dbus/message.go | 346 + vendor/github.com/godbus/dbus/object.go | 136 + vendor/github.com/godbus/dbus/sig.go | 257 + .../godbus/dbus/transport_darwin.go | 6 + .../godbus/dbus/transport_generic.go | 35 + .../github.com/godbus/dbus/transport_unix.go | 196 + .../dbus/transport_unixcred_dragonfly.go | 95 + .../godbus/dbus/transport_unixcred_linux.go | 25 + vendor/github.com/godbus/dbus/variant.go | 139 + .../github.com/godbus/dbus/variant_lexer.go | 284 + .../github.com/godbus/dbus/variant_parser.go | 817 ++ vendor/github.com/gogo/protobuf/LICENSE | 36 + .../github.com/gogo/protobuf/proto/clone.go | 228 + .../github.com/gogo/protobuf/proto/decode.go | 872 ++ .../gogo/protobuf/proto/decode_gogo.go | 175 + .../github.com/gogo/protobuf/proto/encode.go | 1325 ++++ .../gogo/protobuf/proto/encode_gogo.go | 354 + .../github.com/gogo/protobuf/proto/equal.go | 276 + .../gogo/protobuf/proto/extensions.go | 518 ++ .../gogo/protobuf/proto/extensions_gogo.go | 221 + vendor/github.com/gogo/protobuf/proto/lib.go | 894 +++ .../gogo/protobuf/proto/lib_gogo.go | 40 + .../gogo/protobuf/proto/message_set.go | 280 + .../gogo/protobuf/proto/pointer_reflect.go | 479 ++ .../gogo/protobuf/proto/pointer_unsafe.go | 266 + .../protobuf/proto/pointer_unsafe_gogo.go | 108 + .../gogo/protobuf/proto/properties.go | 923 +++ .../gogo/protobuf/proto/properties_gogo.go | 64 + .../gogo/protobuf/proto/skip_gogo.go | 117 + vendor/github.com/gogo/protobuf/proto/text.go | 793 ++ .../gogo/protobuf/proto/text_gogo.go | 55 + .../gogo/protobuf/proto/text_parser.go | 849 ++ vendor/github.com/golang/protobuf/LICENSE | 31 + .../github.com/golang/protobuf/proto/clone.go | 223 + .../golang/protobuf/proto/decode.go | 867 ++ .../golang/protobuf/proto/encode.go | 1325 ++++ .../github.com/golang/protobuf/proto/equal.go | 276 + .../golang/protobuf/proto/extensions.go | 399 + .../github.com/golang/protobuf/proto/lib.go | 893 +++ .../golang/protobuf/proto/message_set.go | 280 + .../golang/protobuf/proto/pointer_reflect.go | 479 ++ .../golang/protobuf/proto/pointer_unsafe.go | 266 + .../golang/protobuf/proto/properties.go | 842 ++ .../github.com/golang/protobuf/proto/text.go | 751 ++ .../golang/protobuf/proto/text_parser.go | 798 ++ .../protoc-gen-go/descriptor/descriptor.pb.go | 1812 +++++ .../golang/protobuf/protoc-gen-go/doc.go | 51 + .../protoc-gen-go/generator/generator.go | 2715 +++++++ .../protoc-gen-go/internal/grpc/grpc.go | 442 ++ .../protobuf/protoc-gen-go/link_grpc.go | 34 + .../golang/protobuf/protoc-gen-go/main.go | 98 + .../protoc-gen-go/plugin/plugin.pb.go | 222 + vendor/github.com/google/btree/LICENSE | 202 + vendor/github.com/google/btree/btree.go | 571 ++ vendor/github.com/google/btree/btree_mem.go | 76 + vendor/github.com/gorilla/context/LICENSE | 27 + vendor/github.com/gorilla/context/context.go | 143 + vendor/github.com/gorilla/context/doc.go | 82 + vendor/github.com/gorilla/mux/LICENSE | 27 + vendor/github.com/gorilla/mux/doc.go | 199 + vendor/github.com/gorilla/mux/mux.go | 353 + vendor/github.com/gorilla/mux/regexp.go | 276 + vendor/github.com/gorilla/mux/route.go | 524 ++ vendor/github.com/hashicorp/errwrap/LICENSE | 354 + .../github.com/hashicorp/errwrap/errwrap.go | 169 + .../hydrogen18/stoppableListener/LICENSE | 10 + .../hydrogen18/stoppableListener/listener.go | 62 + .../inconshreveable/mousetrap/LICENSE | 13 + .../inconshreveable/mousetrap/trap_others.go | 15 + .../inconshreveable/mousetrap/trap_windows.go | 98 + .../mousetrap/trap_windows_1.4.go | 46 + .../github.com/jmespath/go-jmespath/LICENSE | 13 + vendor/github.com/jmespath/go-jmespath/api.go | 49 + .../go-jmespath/astnodetype_string.go | 16 + .../jmespath/go-jmespath/functions.go | 842 ++ .../jmespath/go-jmespath/interpreter.go | 418 + .../github.com/jmespath/go-jmespath/lexer.go | 420 + .../github.com/jmespath/go-jmespath/parser.go | 603 ++ .../jmespath/go-jmespath/toktype_string.go | 16 + .../github.com/jmespath/go-jmespath/util.go | 185 + .../github.com/kballard/go-shellquote/LICENSE | 19 + .../github.com/kballard/go-shellquote/doc.go | 3 + .../kballard/go-shellquote/quote.go | 102 + .../kballard/go-shellquote/unquote.go | 144 + vendor/github.com/klauspost/compress/LICENSE | 27 + .../klauspost/compress/flate/copy.go | 32 + .../klauspost/compress/flate/crc32_amd64.go | 39 + .../klauspost/compress/flate/crc32_amd64.s | 218 + .../klauspost/compress/flate/crc32_noasm.go | 34 + .../klauspost/compress/flate/deflate.go | 1358 ++++ .../klauspost/compress/flate/fixedhuff.go | 78 + .../klauspost/compress/flate/gen.go | 265 + .../compress/flate/huffman_bit_writer.go | 717 ++ .../klauspost/compress/flate/huffman_code.go | 363 + .../klauspost/compress/flate/inflate.go | 846 ++ .../klauspost/compress/flate/reverse_bits.go | 48 + .../klauspost/compress/flate/snappy.go | 768 ++ .../klauspost/compress/flate/token.go | 105 + vendor/github.com/klauspost/cpuid/LICENSE | 22 + vendor/github.com/klauspost/cpuid/cpuid.go | 1022 +++ vendor/github.com/klauspost/cpuid/cpuid_386.s | 42 + .../github.com/klauspost/cpuid/cpuid_amd64.s | 42 + .../klauspost/cpuid/detect_intel.go | 17 + .../github.com/klauspost/cpuid/detect_ref.go | 23 + vendor/github.com/klauspost/cpuid/generate.go | 3 + .../github.com/klauspost/cpuid/private-gen.go | 476 ++ vendor/github.com/klauspost/crc32/LICENSE | 28 + vendor/github.com/klauspost/crc32/crc32.go | 186 + .../github.com/klauspost/crc32/crc32_amd64.go | 62 + .../github.com/klauspost/crc32/crc32_amd64.s | 237 + .../klauspost/crc32/crc32_amd64p32.go | 40 + .../klauspost/crc32/crc32_amd64p32.s | 67 + .../klauspost/crc32/crc32_generic.go | 29 + vendor/github.com/klauspost/pgzip/LICENSE | 22 + vendor/github.com/klauspost/pgzip/gunzip.go | 564 ++ vendor/github.com/klauspost/pgzip/gzip.go | 485 ++ vendor/github.com/kr/pty/License | 23 + vendor/github.com/kr/pty/doc.go | 16 + vendor/github.com/kr/pty/ioctl.go | 11 + vendor/github.com/kr/pty/ioctl_bsd.go | 39 + vendor/github.com/kr/pty/pty_darwin.go | 60 + vendor/github.com/kr/pty/pty_freebsd.go | 73 + vendor/github.com/kr/pty/pty_linux.go | 46 + vendor/github.com/kr/pty/pty_unsupported.go | 11 + vendor/github.com/kr/pty/run.go | 32 + vendor/github.com/kr/pty/types.go | 10 + vendor/github.com/kr/pty/types_freebsd.go | 15 + vendor/github.com/kr/pty/util.go | 35 + vendor/github.com/kr/pty/ztypes_386.go | 9 + vendor/github.com/kr/pty/ztypes_amd64.go | 9 + vendor/github.com/kr/pty/ztypes_arm.go | 9 + vendor/github.com/kr/pty/ztypes_arm64.go | 11 + .../github.com/kr/pty/ztypes_freebsd_386.go | 13 + .../github.com/kr/pty/ztypes_freebsd_amd64.go | 14 + .../github.com/kr/pty/ztypes_freebsd_arm.go | 13 + vendor/github.com/kr/pty/ztypes_ppc64.go | 11 + vendor/github.com/kr/pty/ztypes_ppc64le.go | 11 + vendor/github.com/kr/pty/ztypes_s390x.go | 11 + vendor/github.com/pborman/uuid/LICENSE | 27 + vendor/github.com/pborman/uuid/dce.go | 84 + vendor/github.com/pborman/uuid/doc.go | 8 + vendor/github.com/pborman/uuid/hash.go | 53 + vendor/github.com/pborman/uuid/json.go | 30 + vendor/github.com/pborman/uuid/node.go | 101 + vendor/github.com/pborman/uuid/sql.go | 40 + vendor/github.com/pborman/uuid/time.go | 132 + vendor/github.com/pborman/uuid/util.go | 43 + vendor/github.com/pborman/uuid/uuid.go | 163 + vendor/github.com/pborman/uuid/version1.go | 41 + vendor/github.com/pborman/uuid/version4.go | 25 + vendor/github.com/peterbourgon/diskv/LICENSE | 19 + .../peterbourgon/diskv/compression.go | 64 + vendor/github.com/peterbourgon/diskv/diskv.go | 578 ++ vendor/github.com/peterbourgon/diskv/index.go | 115 + .../russross/blackfriday/LICENSE.txt | 29 + .../github.com/russross/blackfriday/block.go | 1398 ++++ .../github.com/russross/blackfriday/html.go | 949 +++ .../github.com/russross/blackfriday/inline.go | 1133 +++ .../github.com/russross/blackfriday/latex.go | 332 + .../russross/blackfriday/markdown.go | 926 +++ .../russross/blackfriday/smartypants.go | 400 + vendor/github.com/shirou/gopsutil/LICENSE | 27 + vendor/github.com/shirou/gopsutil/cpu/cpu.go | 76 + .../shirou/gopsutil/cpu/cpu_darwin.go | 106 + .../shirou/gopsutil/cpu/cpu_darwin_cgo.go | 107 + .../shirou/gopsutil/cpu/cpu_darwin_nocgo.go | 14 + .../shirou/gopsutil/cpu/cpu_freebsd.go | 147 + .../shirou/gopsutil/cpu/cpu_linux.go | 244 + .../shirou/gopsutil/cpu/cpu_unix.go | 59 + .../shirou/gopsutil/cpu/cpu_windows.go | 105 + vendor/github.com/shirou/gopsutil/doc.go | 1 + .../github.com/shirou/gopsutil/host/host.go | 38 + .../shirou/gopsutil/host/host_darwin.go | 152 + .../shirou/gopsutil/host/host_darwin_amd64.go | 19 + .../shirou/gopsutil/host/host_freebsd.go | 196 + .../gopsutil/host/host_freebsd_amd64.go | 41 + .../shirou/gopsutil/host/host_linux.go | 431 + .../shirou/gopsutil/host/host_linux_386.go | 44 + .../shirou/gopsutil/host/host_linux_amd64.go | 42 + .../shirou/gopsutil/host/host_linux_arm.go | 42 + .../shirou/gopsutil/host/host_windows.go | 135 + .../shirou/gopsutil/host/types_darwin.go | 17 + .../shirou/gopsutil/host/types_freebsd.go | 43 + .../shirou/gopsutil/host/types_linux.go | 45 + .../shirou/gopsutil/internal/common/binary.go | 634 ++ .../shirou/gopsutil/internal/common/common.go | 279 + .../gopsutil/internal/common/common_darwin.go | 70 + .../internal/common/common_freebsd.go | 70 + .../gopsutil/internal/common/common_linux.go | 3 + .../gopsutil/internal/common/common_unix.go | 66 + .../internal/common/common_windows.go | 110 + .../github.com/shirou/gopsutil/load/load.go | 35 + .../shirou/gopsutil/load/load_darwin.go | 67 + .../shirou/gopsutil/load/load_freebsd.go | 65 + .../shirou/gopsutil/load/load_linux.go | 78 + .../shirou/gopsutil/load/load_windows.go | 19 + vendor/github.com/shirou/gopsutil/mem/mem.go | 64 + .../shirou/gopsutil/mem/mem_darwin.go | 69 + .../shirou/gopsutil/mem/mem_darwin_cgo.go | 53 + .../shirou/gopsutil/mem/mem_darwin_nocgo.go | 88 + .../shirou/gopsutil/mem/mem_freebsd.go | 134 + .../shirou/gopsutil/mem/mem_linux.go | 100 + .../shirou/gopsutil/mem/mem_windows.go | 50 + vendor/github.com/shirou/gopsutil/net/net.go | 243 + .../shirou/gopsutil/net/net_darwin.go | 114 + .../shirou/gopsutil/net/net_freebsd.go | 108 + .../shirou/gopsutil/net/net_linux.go | 620 ++ .../shirou/gopsutil/net/net_unix.go | 68 + .../shirou/gopsutil/net/net_windows.go | 116 + .../shirou/gopsutil/process/process.go | 166 + .../shirou/gopsutil/process/process_darwin.go | 451 ++ .../gopsutil/process/process_darwin_amd64.go | 234 + .../gopsutil/process/process_freebsd.go | 336 + .../gopsutil/process/process_freebsd_386.go | 141 + .../gopsutil/process/process_freebsd_amd64.go | 192 + .../shirou/gopsutil/process/process_linux.go | 733 ++ .../gopsutil/process/process_linux_386.go | 9 + .../gopsutil/process/process_linux_amd64.go | 9 + .../gopsutil/process/process_linux_arm.go | 9 + .../shirou/gopsutil/process/process_posix.go | 106 + .../gopsutil/process/process_windows.go | 357 + .../shirou/gopsutil/process/types_darwin.go | 160 + .../shirou/gopsutil/process/types_freebsd.go | 95 + vendor/github.com/shirou/w32/LICENSE | 23 + vendor/github.com/shirou/w32/advapi32.go | 299 + vendor/github.com/shirou/w32/comctl32.go | 109 + vendor/github.com/shirou/w32/comdlg32.go | 38 + vendor/github.com/shirou/w32/constants.go | 2661 +++++++ vendor/github.com/shirou/w32/dwmapi.go | 254 + vendor/github.com/shirou/w32/gdi32.go | 509 ++ vendor/github.com/shirou/w32/gdiplus.go | 175 + vendor/github.com/shirou/w32/idispatch.go | 43 + vendor/github.com/shirou/w32/istream.go | 31 + vendor/github.com/shirou/w32/iunknown.go | 27 + vendor/github.com/shirou/w32/kernel32.go | 314 + vendor/github.com/shirou/w32/ole32.go | 63 + vendor/github.com/shirou/w32/oleaut32.go | 48 + vendor/github.com/shirou/w32/opengl32.go | 72 + vendor/github.com/shirou/w32/psapi.go | 25 + vendor/github.com/shirou/w32/shell32.go | 153 + vendor/github.com/shirou/w32/typedef.go | 901 +++ vendor/github.com/shirou/w32/user32.go | 948 +++ vendor/github.com/shirou/w32/utils.go | 201 + vendor/github.com/shirou/w32/vars.go | 13 + .../shurcooL/sanitized_anchor_name/LICENSE | 19 + .../shurcooL/sanitized_anchor_name/main.go | 29 + vendor/github.com/spf13/cobra/LICENSE.txt | 174 + .../spf13/cobra/bash_completions.go | 602 ++ vendor/github.com/spf13/cobra/cobra.go | 171 + vendor/github.com/spf13/cobra/command.go | 1193 +++ .../github.com/spf13/cobra/command_notwin.go | 5 + vendor/github.com/spf13/cobra/command_win.go | 26 + vendor/github.com/spf13/cobra/doc/man_docs.go | 218 + vendor/github.com/spf13/cobra/doc/md_docs.go | 175 + vendor/github.com/spf13/cobra/doc/util.go | 38 + vendor/github.com/spf13/pflag/LICENSE | 28 + vendor/github.com/spf13/pflag/bool.go | 97 + vendor/github.com/spf13/pflag/count.go | 97 + vendor/github.com/spf13/pflag/duration.go | 86 + vendor/github.com/spf13/pflag/flag.go | 836 ++ vendor/github.com/spf13/pflag/float32.go | 91 + vendor/github.com/spf13/pflag/float64.go | 87 + vendor/github.com/spf13/pflag/golangflag.go | 97 + vendor/github.com/spf13/pflag/int.go | 87 + vendor/github.com/spf13/pflag/int32.go | 91 + vendor/github.com/spf13/pflag/int64.go | 87 + vendor/github.com/spf13/pflag/int8.go | 91 + vendor/github.com/spf13/pflag/int_slice.go | 128 + vendor/github.com/spf13/pflag/ip.go | 96 + vendor/github.com/spf13/pflag/ipmask.go | 122 + vendor/github.com/spf13/pflag/ipnet.go | 100 + vendor/github.com/spf13/pflag/string.go | 82 + vendor/github.com/spf13/pflag/string_slice.go | 111 + vendor/github.com/spf13/pflag/uint.go | 91 + vendor/github.com/spf13/pflag/uint16.go | 89 + vendor/github.com/spf13/pflag/uint32.go | 89 + vendor/github.com/spf13/pflag/uint64.go | 91 + vendor/github.com/spf13/pflag/uint8.go | 91 + vendor/github.com/syndtr/gocapability/LICENSE | 24 + .../gocapability/capability/capability.go | 72 + .../capability/capability_linux.go | 608 ++ .../capability/capability_noop.go | 19 + .../syndtr/gocapability/capability/enum.go | 345 + .../gocapability/capability/syscall_linux.go | 143 + vendor/github.com/vishvananda/netlink/LICENSE | 192 + vendor/github.com/vishvananda/netlink/addr.go | 43 + .../vishvananda/netlink/addr_linux.go | 128 + .../github.com/vishvananda/netlink/class.go | 110 + .../vishvananda/netlink/class_linux.go | 144 + .../github.com/vishvananda/netlink/filter.go | 55 + .../vishvananda/netlink/filter_linux.go | 191 + vendor/github.com/vishvananda/netlink/link.go | 223 + .../vishvananda/netlink/link_linux.go | 790 ++ .../github.com/vishvananda/netlink/neigh.go | 22 + .../vishvananda/netlink/neigh_linux.go | 189 + .../github.com/vishvananda/netlink/netlink.go | 39 + .../netlink/netlink_unspecified.go | 143 + .../vishvananda/netlink/nl/addr_linux.go | 47 + .../vishvananda/netlink/nl/link_linux.go | 104 + .../vishvananda/netlink/nl/nl_linux.go | 418 + .../vishvananda/netlink/nl/route_linux.go | 42 + .../vishvananda/netlink/nl/tc_linux.go | 425 + .../vishvananda/netlink/nl/xfrm_linux.go | 258 + .../netlink/nl/xfrm_policy_linux.go | 119 + .../netlink/nl/xfrm_state_linux.go | 221 + .../vishvananda/netlink/protinfo.go | 53 + .../vishvananda/netlink/protinfo_linux.go | 60 + .../github.com/vishvananda/netlink/qdisc.go | 167 + .../vishvananda/netlink/qdisc_linux.go | 316 + .../github.com/vishvananda/netlink/route.go | 41 + .../vishvananda/netlink/route_linux.go | 249 + vendor/github.com/vishvananda/netlink/xfrm.go | 64 + .../vishvananda/netlink/xfrm_policy.go | 59 + .../vishvananda/netlink/xfrm_policy_linux.go | 127 + .../vishvananda/netlink/xfrm_state.go | 53 + .../vishvananda/netlink/xfrm_state_linux.go | 181 + vendor/go4.org/LICENSE | 202 + vendor/go4.org/errorutil/highlight.go | 58 + vendor/golang.org/x/crypto/LICENSE | 27 + vendor/golang.org/x/crypto/PATENTS | 22 + vendor/golang.org/x/crypto/cast5/cast5.go | 526 ++ .../x/crypto/openpgp/armor/armor.go | 219 + .../x/crypto/openpgp/armor/encode.go | 160 + .../x/crypto/openpgp/canonical_text.go | 59 + .../x/crypto/openpgp/elgamal/elgamal.go | 122 + .../x/crypto/openpgp/errors/errors.go | 72 + vendor/golang.org/x/crypto/openpgp/keys.go | 624 ++ .../x/crypto/openpgp/packet/compressed.go | 123 + .../x/crypto/openpgp/packet/config.go | 88 + .../x/crypto/openpgp/packet/encrypted_key.go | 168 + .../x/crypto/openpgp/packet/literal.go | 89 + .../x/crypto/openpgp/packet/ocfb.go | 143 + .../openpgp/packet/one_pass_signature.go | 73 + .../x/crypto/openpgp/packet/opaque.go | 161 + .../x/crypto/openpgp/packet/packet.go | 538 ++ .../x/crypto/openpgp/packet/private_key.go | 310 + .../x/crypto/openpgp/packet/public_key.go | 687 ++ .../x/crypto/openpgp/packet/public_key_v3.go | 275 + .../x/crypto/openpgp/packet/reader.go | 62 + .../x/crypto/openpgp/packet/signature.go | 663 ++ .../x/crypto/openpgp/packet/signature_v3.go | 146 + .../openpgp/packet/symmetric_key_encrypted.go | 164 + .../openpgp/packet/symmetrically_encrypted.go | 290 + .../x/crypto/openpgp/packet/userattribute.go | 91 + .../x/crypto/openpgp/packet/userid.go | 160 + vendor/golang.org/x/crypto/openpgp/read.go | 423 + vendor/golang.org/x/crypto/openpgp/s2k/s2k.go | 273 + vendor/golang.org/x/crypto/openpgp/write.go | 374 + .../x/crypto/ssh/terminal/terminal.go | 892 +++ .../golang.org/x/crypto/ssh/terminal/util.go | 128 + .../x/crypto/ssh/terminal/util_bsd.go | 12 + .../x/crypto/ssh/terminal/util_linux.go | 11 + .../x/crypto/ssh/terminal/util_windows.go | 174 + vendor/golang.org/x/net/LICENSE | 27 + vendor/golang.org/x/net/PATENTS | 22 + vendor/golang.org/x/net/context/context.go | 447 ++ vendor/golang.org/x/net/html/atom/atom.go | 78 + vendor/golang.org/x/net/html/atom/gen.go | 648 ++ vendor/golang.org/x/net/html/atom/table.go | 713 ++ vendor/golang.org/x/net/html/const.go | 102 + vendor/golang.org/x/net/html/doc.go | 106 + vendor/golang.org/x/net/html/doctype.go | 156 + vendor/golang.org/x/net/html/entity.go | 2253 ++++++ vendor/golang.org/x/net/html/escape.go | 258 + vendor/golang.org/x/net/html/foreign.go | 226 + vendor/golang.org/x/net/html/node.go | 193 + vendor/golang.org/x/net/html/parse.go | 2094 +++++ vendor/golang.org/x/net/html/render.go | 271 + vendor/golang.org/x/net/html/token.go | 1219 +++ .../x/net/http2/client_conn_pool.go | 225 + .../x/net/http2/configure_transport.go | 89 + vendor/golang.org/x/net/http2/errors.go | 90 + vendor/golang.org/x/net/http2/fixed_buffer.go | 60 + vendor/golang.org/x/net/http2/flow.go | 50 + vendor/golang.org/x/net/http2/frame.go | 1269 +++ vendor/golang.org/x/net/http2/go15.go | 11 + vendor/golang.org/x/net/http2/gotrack.go | 170 + vendor/golang.org/x/net/http2/headermap.go | 78 + vendor/golang.org/x/net/http2/hpack/encode.go | 251 + vendor/golang.org/x/net/http2/hpack/hpack.go | 533 ++ .../golang.org/x/net/http2/hpack/huffman.go | 190 + vendor/golang.org/x/net/http2/hpack/tables.go | 352 + vendor/golang.org/x/net/http2/http2.go | 424 + vendor/golang.org/x/net/http2/not_go15.go | 11 + vendor/golang.org/x/net/http2/not_go16.go | 13 + vendor/golang.org/x/net/http2/pipe.go | 147 + vendor/golang.org/x/net/http2/server.go | 2260 ++++++ vendor/golang.org/x/net/http2/transport.go | 1713 ++++ vendor/golang.org/x/net/http2/write.go | 263 + vendor/golang.org/x/net/http2/writesched.go | 283 + .../x/net/internal/timeseries/timeseries.go | 525 ++ vendor/golang.org/x/net/trace/events.go | 524 ++ vendor/golang.org/x/net/trace/histogram.go | 356 + vendor/golang.org/x/net/trace/trace.go | 1059 +++ vendor/golang.org/x/sys/LICENSE | 27 + vendor/golang.org/x/sys/PATENTS | 22 + vendor/golang.org/x/sys/unix/asm.s | 10 + vendor/golang.org/x/sys/unix/asm_darwin_386.s | 29 + .../golang.org/x/sys/unix/asm_darwin_amd64.s | 29 + vendor/golang.org/x/sys/unix/asm_darwin_arm.s | 30 + .../golang.org/x/sys/unix/asm_darwin_arm64.s | 30 + .../x/sys/unix/asm_dragonfly_amd64.s | 29 + .../golang.org/x/sys/unix/asm_freebsd_386.s | 29 + .../golang.org/x/sys/unix/asm_freebsd_amd64.s | 29 + .../golang.org/x/sys/unix/asm_freebsd_arm.s | 29 + vendor/golang.org/x/sys/unix/asm_linux_386.s | 35 + .../golang.org/x/sys/unix/asm_linux_amd64.s | 29 + vendor/golang.org/x/sys/unix/asm_linux_arm.s | 29 + .../golang.org/x/sys/unix/asm_linux_arm64.s | 24 + .../golang.org/x/sys/unix/asm_linux_mips64x.s | 28 + .../golang.org/x/sys/unix/asm_linux_ppc64x.s | 28 + .../golang.org/x/sys/unix/asm_linux_s390x.s | 28 + vendor/golang.org/x/sys/unix/asm_netbsd_386.s | 29 + .../golang.org/x/sys/unix/asm_netbsd_amd64.s | 29 + vendor/golang.org/x/sys/unix/asm_netbsd_arm.s | 29 + .../golang.org/x/sys/unix/asm_openbsd_386.s | 29 + .../golang.org/x/sys/unix/asm_openbsd_amd64.s | 29 + .../golang.org/x/sys/unix/asm_solaris_amd64.s | 17 + .../golang.org/x/sys/unix/bluetooth_linux.go | 35 + vendor/golang.org/x/sys/unix/constants.go | 13 + vendor/golang.org/x/sys/unix/env_unix.go | 27 + vendor/golang.org/x/sys/unix/env_unset.go | 14 + vendor/golang.org/x/sys/unix/flock.go | 24 + .../x/sys/unix/flock_linux_32bit.go | 13 + vendor/golang.org/x/sys/unix/gccgo.go | 46 + vendor/golang.org/x/sys/unix/gccgo_c.c | 41 + .../x/sys/unix/gccgo_linux_amd64.go | 20 + vendor/golang.org/x/sys/unix/mkpost.go | 62 + vendor/golang.org/x/sys/unix/race.go | 30 + vendor/golang.org/x/sys/unix/race0.go | 25 + .../golang.org/x/sys/unix/sockcmsg_linux.go | 36 + vendor/golang.org/x/sys/unix/sockcmsg_unix.go | 103 + vendor/golang.org/x/sys/unix/str.go | 26 + vendor/golang.org/x/sys/unix/syscall.go | 76 + vendor/golang.org/x/sys/unix/syscall_bsd.go | 628 ++ .../golang.org/x/sys/unix/syscall_darwin.go | 509 ++ .../x/sys/unix/syscall_darwin_386.go | 77 + .../x/sys/unix/syscall_darwin_amd64.go | 79 + .../x/sys/unix/syscall_darwin_arm.go | 71 + .../x/sys/unix/syscall_darwin_arm64.go | 77 + .../x/sys/unix/syscall_dragonfly.go | 411 + .../x/sys/unix/syscall_dragonfly_amd64.go | 61 + .../golang.org/x/sys/unix/syscall_freebsd.go | 682 ++ .../x/sys/unix/syscall_freebsd_386.go | 61 + .../x/sys/unix/syscall_freebsd_amd64.go | 61 + .../x/sys/unix/syscall_freebsd_arm.go | 61 + vendor/golang.org/x/sys/unix/syscall_linux.go | 1108 +++ .../x/sys/unix/syscall_linux_386.go | 390 + .../x/sys/unix/syscall_linux_amd64.go | 148 + .../x/sys/unix/syscall_linux_arm.go | 254 + .../x/sys/unix/syscall_linux_arm64.go | 180 + .../x/sys/unix/syscall_linux_mips64x.go | 206 + .../x/sys/unix/syscall_linux_ppc64x.go | 126 + .../x/sys/unix/syscall_linux_s390x.go | 320 + .../golang.org/x/sys/unix/syscall_netbsd.go | 492 ++ .../x/sys/unix/syscall_netbsd_386.go | 42 + .../x/sys/unix/syscall_netbsd_amd64.go | 42 + .../x/sys/unix/syscall_netbsd_arm.go | 42 + .../golang.org/x/sys/unix/syscall_no_getwd.go | 11 + .../golang.org/x/sys/unix/syscall_openbsd.go | 303 + .../x/sys/unix/syscall_openbsd_386.go | 42 + .../x/sys/unix/syscall_openbsd_amd64.go | 42 + .../golang.org/x/sys/unix/syscall_solaris.go | 713 ++ .../x/sys/unix/syscall_solaris_amd64.go | 35 + vendor/golang.org/x/sys/unix/syscall_unix.go | 297 + vendor/golang.org/x/sys/unix/types_darwin.go | 250 + .../golang.org/x/sys/unix/types_dragonfly.go | 242 + vendor/golang.org/x/sys/unix/types_freebsd.go | 353 + vendor/golang.org/x/sys/unix/types_linux.go | 435 + vendor/golang.org/x/sys/unix/types_netbsd.go | 232 + vendor/golang.org/x/sys/unix/types_openbsd.go | 244 + vendor/golang.org/x/sys/unix/types_solaris.go | 260 + .../x/sys/unix/zerrors_darwin_386.go | 1576 ++++ .../x/sys/unix/zerrors_darwin_amd64.go | 1576 ++++ .../x/sys/unix/zerrors_darwin_arm.go | 1293 +++ .../x/sys/unix/zerrors_darwin_arm64.go | 1576 ++++ .../x/sys/unix/zerrors_dragonfly_amd64.go | 1530 ++++ .../x/sys/unix/zerrors_freebsd_386.go | 1743 ++++ .../x/sys/unix/zerrors_freebsd_amd64.go | 1748 ++++ .../x/sys/unix/zerrors_freebsd_arm.go | 1729 ++++ .../x/sys/unix/zerrors_linux_386.go | 1819 +++++ .../x/sys/unix/zerrors_linux_amd64.go | 1820 +++++ .../x/sys/unix/zerrors_linux_arm.go | 1743 ++++ .../x/sys/unix/zerrors_linux_arm64.go | 1897 +++++ .../x/sys/unix/zerrors_linux_mips64.go | 1917 +++++ .../x/sys/unix/zerrors_linux_mips64le.go | 1917 +++++ .../x/sys/unix/zerrors_linux_ppc64.go | 1970 +++++ .../x/sys/unix/zerrors_linux_ppc64le.go | 1969 +++++ .../x/sys/unix/zerrors_linux_s390x.go | 2027 +++++ .../x/sys/unix/zerrors_netbsd_386.go | 1712 ++++ .../x/sys/unix/zerrors_netbsd_amd64.go | 1702 ++++ .../x/sys/unix/zerrors_netbsd_arm.go | 1688 ++++ .../x/sys/unix/zerrors_openbsd_386.go | 1584 ++++ .../x/sys/unix/zerrors_openbsd_amd64.go | 1583 ++++ .../x/sys/unix/zerrors_solaris_amd64.go | 1436 ++++ .../x/sys/unix/zsyscall_darwin_386.go | 1427 ++++ .../x/sys/unix/zsyscall_darwin_amd64.go | 1443 ++++ .../x/sys/unix/zsyscall_darwin_arm.go | 1427 ++++ .../x/sys/unix/zsyscall_darwin_arm64.go | 1427 ++++ .../x/sys/unix/zsyscall_dragonfly_amd64.go | 1413 ++++ .../x/sys/unix/zsyscall_freebsd_386.go | 1665 ++++ .../x/sys/unix/zsyscall_freebsd_amd64.go | 1665 ++++ .../x/sys/unix/zsyscall_freebsd_arm.go | 1665 ++++ .../x/sys/unix/zsyscall_linux_386.go | 1638 ++++ .../x/sys/unix/zsyscall_linux_amd64.go | 1832 +++++ .../x/sys/unix/zsyscall_linux_arm.go | 1739 ++++ .../x/sys/unix/zsyscall_linux_arm64.go | 1723 ++++ .../x/sys/unix/zsyscall_linux_mips64.go | 1781 +++++ .../x/sys/unix/zsyscall_linux_mips64le.go | 1781 +++++ .../x/sys/unix/zsyscall_linux_ppc64.go | 1843 +++++ .../x/sys/unix/zsyscall_linux_ppc64le.go | 1843 +++++ .../x/sys/unix/zsyscall_linux_s390x.go | 1623 ++++ .../x/sys/unix/zsyscall_netbsd_386.go | 1327 ++++ .../x/sys/unix/zsyscall_netbsd_amd64.go | 1327 ++++ .../x/sys/unix/zsyscall_netbsd_arm.go | 1327 ++++ .../x/sys/unix/zsyscall_openbsd_386.go | 1387 ++++ .../x/sys/unix/zsyscall_openbsd_amd64.go | 1387 ++++ .../x/sys/unix/zsyscall_solaris_amd64.go | 1559 ++++ .../golang.org/x/sys/unix/zsysctl_openbsd.go | 270 + .../x/sys/unix/zsysnum_darwin_386.go | 398 + .../x/sys/unix/zsysnum_darwin_amd64.go | 398 + .../x/sys/unix/zsysnum_darwin_arm.go | 358 + .../x/sys/unix/zsysnum_darwin_arm64.go | 398 + .../x/sys/unix/zsysnum_dragonfly_amd64.go | 304 + .../x/sys/unix/zsysnum_freebsd_386.go | 351 + .../x/sys/unix/zsysnum_freebsd_amd64.go | 351 + .../x/sys/unix/zsysnum_freebsd_arm.go | 351 + .../x/sys/unix/zsysnum_linux_386.go | 355 + .../x/sys/unix/zsysnum_linux_amd64.go | 321 + .../x/sys/unix/zsysnum_linux_arm.go | 356 + .../x/sys/unix/zsysnum_linux_arm64.go | 272 + .../x/sys/unix/zsysnum_linux_mips64.go | 327 + .../x/sys/unix/zsysnum_linux_mips64le.go | 327 + .../x/sys/unix/zsysnum_linux_ppc64.go | 360 + .../x/sys/unix/zsysnum_linux_ppc64le.go | 353 + .../x/sys/unix/zsysnum_linux_s390x.go | 328 + .../x/sys/unix/zsysnum_netbsd_386.go | 273 + .../x/sys/unix/zsysnum_netbsd_amd64.go | 273 + .../x/sys/unix/zsysnum_netbsd_arm.go | 273 + .../x/sys/unix/zsysnum_openbsd_386.go | 207 + .../x/sys/unix/zsysnum_openbsd_amd64.go | 207 + .../x/sys/unix/zsysnum_solaris_amd64.go | 13 + .../x/sys/unix/ztypes_darwin_386.go | 447 ++ .../x/sys/unix/ztypes_darwin_amd64.go | 462 ++ .../x/sys/unix/ztypes_darwin_arm.go | 449 ++ .../x/sys/unix/ztypes_darwin_arm64.go | 457 ++ .../x/sys/unix/ztypes_dragonfly_amd64.go | 443 ++ .../x/sys/unix/ztypes_freebsd_386.go | 502 ++ .../x/sys/unix/ztypes_freebsd_amd64.go | 505 ++ .../x/sys/unix/ztypes_freebsd_arm.go | 497 ++ .../golang.org/x/sys/unix/ztypes_linux_386.go | 607 ++ .../x/sys/unix/ztypes_linux_amd64.go | 625 ++ .../golang.org/x/sys/unix/ztypes_linux_arm.go | 587 ++ .../x/sys/unix/ztypes_linux_arm64.go | 604 ++ .../x/sys/unix/ztypes_linux_mips64.go | 607 ++ .../x/sys/unix/ztypes_linux_mips64le.go | 607 ++ .../x/sys/unix/ztypes_linux_ppc64.go | 614 ++ .../x/sys/unix/ztypes_linux_ppc64le.go | 614 ++ .../x/sys/unix/ztypes_linux_s390x.go | 629 ++ .../x/sys/unix/ztypes_netbsd_386.go | 396 + .../x/sys/unix/ztypes_netbsd_amd64.go | 403 + .../x/sys/unix/ztypes_netbsd_arm.go | 401 + .../x/sys/unix/ztypes_openbsd_386.go | 441 ++ .../x/sys/unix/ztypes_openbsd_amd64.go | 448 ++ .../x/sys/unix/ztypes_solaris_amd64.go | 422 + vendor/golang.org/x/tools/LICENSE | 27 + vendor/golang.org/x/tools/PATENTS | 22 + vendor/golang.org/x/tools/go/vcs/discovery.go | 76 + vendor/golang.org/x/tools/go/vcs/env.go | 39 + vendor/golang.org/x/tools/go/vcs/http.go | 80 + vendor/golang.org/x/tools/go/vcs/vcs.go | 754 ++ vendor/google.golang.org/grpc/LICENSE | 28 + vendor/google.golang.org/grpc/PATENTS | 22 + vendor/google.golang.org/grpc/call.go | 190 + vendor/google.golang.org/grpc/clientconn.go | 590 ++ .../grpc/codes/code_string.go | 16 + vendor/google.golang.org/grpc/codes/codes.go | 159 + .../grpc/credentials/credentials.go | 226 + vendor/google.golang.org/grpc/doc.go | 6 + .../google.golang.org/grpc/grpclog/logger.go | 93 + .../grpc/internal/internal.go | 49 + .../grpc/metadata/metadata.go | 134 + .../google.golang.org/grpc/naming/naming.go | 73 + vendor/google.golang.org/grpc/peer/peer.go | 65 + vendor/google.golang.org/grpc/picker.go | 243 + vendor/google.golang.org/grpc/rpc_util.go | 444 ++ vendor/google.golang.org/grpc/server.go | 785 ++ vendor/google.golang.org/grpc/stream.go | 411 + vendor/google.golang.org/grpc/trace.go | 120 + .../grpc/transport/control.go | 260 + .../grpc/transport/handler_server.go | 377 + .../grpc/transport/http2_client.go | 875 +++ .../grpc/transport/http2_server.go | 707 ++ .../grpc/transport/http_util.go | 455 ++ .../grpc/transport/transport.go | 510 ++ vendor/gopkg.in/inf.v0/LICENSE | 28 + vendor/gopkg.in/inf.v0/dec.go | 615 ++ vendor/gopkg.in/inf.v0/rounder.go | 145 + vendor/k8s.io/kubernetes/LICENSE | 202 + .../pkg/api/resource/deep_copy_generated.go | 55 + .../pkg/api/resource/generated.pb.go | 371 + .../kubernetes/pkg/api/resource/quantity.go | 538 ++ .../pkg/api/resource/quantity_proto.go | 78 + .../kubernetes/pkg/api/resource/scale_int.go | 95 + .../kubernetes/pkg/api/resource/suffix.go | 136 + .../kubernetes/pkg/conversion/cloner.go | 237 + .../kubernetes/pkg/conversion/converter.go | 951 +++ .../pkg/conversion/deep_copy_generated.go | 185 + .../kubernetes/pkg/conversion/deep_equal.go | 36 + .../k8s.io/kubernetes/pkg/conversion/doc.go | 24 + .../kubernetes/pkg/conversion/helper.go | 39 + .../third_party/forked/reflect/LICENSE | 27 + .../third_party/forked/reflect/deep_equal.go | 388 + 1016 files changed, 311070 insertions(+) create mode 100644 glide.lock create mode 100644 vendor/github.com/StackExchange/wmi/LICENSE create mode 100644 vendor/github.com/StackExchange/wmi/wmi.go create mode 100644 vendor/github.com/appc/docker2aci/LICENSE create mode 100644 vendor/github.com/appc/docker2aci/lib/common/common.go create mode 100644 vendor/github.com/appc/docker2aci/lib/conversion_store.go create mode 100644 vendor/github.com/appc/docker2aci/lib/docker2aci.go create mode 100644 vendor/github.com/appc/docker2aci/lib/internal/backend/file/file.go create mode 100644 vendor/github.com/appc/docker2aci/lib/internal/backend/repository/repository.go create mode 100644 vendor/github.com/appc/docker2aci/lib/internal/backend/repository/repository1.go create mode 100644 vendor/github.com/appc/docker2aci/lib/internal/backend/repository/repository2.go create mode 100644 vendor/github.com/appc/docker2aci/lib/internal/docker/docker_functions.go create mode 100644 vendor/github.com/appc/docker2aci/lib/internal/internal.go create mode 100644 vendor/github.com/appc/docker2aci/lib/internal/tarball/tarfile.go create mode 100644 vendor/github.com/appc/docker2aci/lib/internal/tarball/walk.go create mode 100644 vendor/github.com/appc/docker2aci/lib/internal/types/docker_types.go create mode 100644 vendor/github.com/appc/docker2aci/lib/internal/types/types.go create mode 100644 vendor/github.com/appc/docker2aci/lib/internal/util/util.go create mode 100644 vendor/github.com/appc/docker2aci/lib/version.go create mode 100644 vendor/github.com/appc/docker2aci/main.go create mode 100644 vendor/github.com/appc/docker2aci/pkg/log/log.go create mode 100644 vendor/github.com/appc/goaci/LICENSE create mode 100644 vendor/github.com/appc/goaci/buildercommand.go create mode 100644 vendor/github.com/appc/goaci/command.go create mode 100644 vendor/github.com/appc/goaci/commands.go create mode 100644 vendor/github.com/appc/goaci/main.go create mode 100644 vendor/github.com/appc/goaci/mappers.go create mode 100644 vendor/github.com/appc/goaci/proj2aci/asset.go create mode 100644 vendor/github.com/appc/goaci/proj2aci/binary.go create mode 100644 vendor/github.com/appc/goaci/proj2aci/builder.go create mode 100644 vendor/github.com/appc/goaci/proj2aci/cmake.go create mode 100644 vendor/github.com/appc/goaci/proj2aci/go.go create mode 100644 vendor/github.com/appc/goaci/proj2aci/run.go create mode 100644 vendor/github.com/appc/goaci/proj2aci/util.go create mode 100644 vendor/github.com/appc/goaci/proj2aci/vcs.go create mode 100644 vendor/github.com/appc/spec/LICENSE create mode 100644 vendor/github.com/appc/spec/ace/doc.go create mode 100644 vendor/github.com/appc/spec/ace/image_manifest_main.json.in create mode 100644 vendor/github.com/appc/spec/ace/image_manifest_sidekick.json.in create mode 100644 vendor/github.com/appc/spec/ace/os_default.go create mode 100644 vendor/github.com/appc/spec/ace/os_freebsd.go create mode 100644 vendor/github.com/appc/spec/ace/os_linux.go create mode 100644 vendor/github.com/appc/spec/ace/os_shared.go create mode 100644 vendor/github.com/appc/spec/ace/validator.go create mode 100644 vendor/github.com/appc/spec/aci/build.go create mode 100644 vendor/github.com/appc/spec/aci/doc.go create mode 100644 vendor/github.com/appc/spec/aci/file.go create mode 100644 vendor/github.com/appc/spec/aci/layout.go create mode 100644 vendor/github.com/appc/spec/aci/writer.go create mode 100644 vendor/github.com/appc/spec/actool/actool.go create mode 100644 vendor/github.com/appc/spec/actool/build.go create mode 100644 vendor/github.com/appc/spec/actool/discover.go create mode 100644 vendor/github.com/appc/spec/actool/doc.go create mode 100644 vendor/github.com/appc/spec/actool/help.go create mode 100644 vendor/github.com/appc/spec/actool/manifest.go create mode 100644 vendor/github.com/appc/spec/actool/validate.go create mode 100644 vendor/github.com/appc/spec/actool/version.go create mode 100644 vendor/github.com/appc/spec/discovery/discovery.go create mode 100644 vendor/github.com/appc/spec/discovery/doc.go create mode 100644 vendor/github.com/appc/spec/discovery/http.go create mode 100644 vendor/github.com/appc/spec/discovery/parse.go create mode 100644 vendor/github.com/appc/spec/pkg/acirenderer/acirenderer.go create mode 100644 vendor/github.com/appc/spec/pkg/acirenderer/resolve.go create mode 100644 vendor/github.com/appc/spec/pkg/device/device_linux.go create mode 100644 vendor/github.com/appc/spec/pkg/device/device_posix.go create mode 100644 vendor/github.com/appc/spec/pkg/tarheader/doc.go create mode 100644 vendor/github.com/appc/spec/pkg/tarheader/pop_darwin.go create mode 100644 vendor/github.com/appc/spec/pkg/tarheader/pop_linux.go create mode 100644 vendor/github.com/appc/spec/pkg/tarheader/pop_posix.go create mode 100644 vendor/github.com/appc/spec/pkg/tarheader/tarheader.go create mode 100644 vendor/github.com/appc/spec/schema/common/common.go create mode 100644 vendor/github.com/appc/spec/schema/doc.go create mode 100644 vendor/github.com/appc/spec/schema/image.go create mode 100644 vendor/github.com/appc/spec/schema/kind.go create mode 100644 vendor/github.com/appc/spec/schema/lastditch/doc.go create mode 100644 vendor/github.com/appc/spec/schema/lastditch/image.go create mode 100644 vendor/github.com/appc/spec/schema/lastditch/labels.go create mode 100644 vendor/github.com/appc/spec/schema/lastditch/pod.go create mode 100644 vendor/github.com/appc/spec/schema/pod.go create mode 100644 vendor/github.com/appc/spec/schema/types/acidentifier.go create mode 100644 vendor/github.com/appc/spec/schema/types/ackind.go create mode 100644 vendor/github.com/appc/spec/schema/types/acname.go create mode 100644 vendor/github.com/appc/spec/schema/types/annotations.go create mode 100644 vendor/github.com/appc/spec/schema/types/app.go create mode 100644 vendor/github.com/appc/spec/schema/types/date.go create mode 100644 vendor/github.com/appc/spec/schema/types/dependencies.go create mode 100644 vendor/github.com/appc/spec/schema/types/doc.go create mode 100644 vendor/github.com/appc/spec/schema/types/environment.go create mode 100644 vendor/github.com/appc/spec/schema/types/errors.go create mode 100644 vendor/github.com/appc/spec/schema/types/event_handler.go create mode 100644 vendor/github.com/appc/spec/schema/types/exec.go create mode 100644 vendor/github.com/appc/spec/schema/types/hash.go create mode 100644 vendor/github.com/appc/spec/schema/types/isolator.go create mode 100644 vendor/github.com/appc/spec/schema/types/isolator_linux_specific.go create mode 100644 vendor/github.com/appc/spec/schema/types/isolator_resources.go create mode 100644 vendor/github.com/appc/spec/schema/types/labels.go create mode 100644 vendor/github.com/appc/spec/schema/types/mountpoint.go create mode 100644 vendor/github.com/appc/spec/schema/types/port.go create mode 100644 vendor/github.com/appc/spec/schema/types/semver.go create mode 100644 vendor/github.com/appc/spec/schema/types/url.go create mode 100644 vendor/github.com/appc/spec/schema/types/uuid.go create mode 100644 vendor/github.com/appc/spec/schema/types/volume.go create mode 100644 vendor/github.com/appc/spec/schema/version.go create mode 100644 vendor/github.com/aws/aws-sdk-go/LICENSE.txt create mode 100644 vendor/github.com/aws/aws-sdk-go/NOTICE.txt create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/awserr/error.go create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/awserr/types.go create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/awsutil/copy.go create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/awsutil/equal.go create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/awsutil/path_value.go create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/awsutil/prettify.go create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/awsutil/string_value.go create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/client/metadata/client_info.go create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/config.go create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/convert_types.go create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/credentials/chain_provider.go create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/credentials/credentials.go create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/credentials/env_provider.go create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/credentials/shared_credentials_provider.go create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/credentials/static_provider.go create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/errors.go create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/logger.go create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/request/handlers.go create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/request/request.go create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/request/request_pagination.go create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/request/retryer.go create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/types.go create mode 100644 vendor/github.com/aws/aws-sdk-go/aws/version.go create mode 100644 vendor/github.com/aws/aws-sdk-go/private/protocol/rest/build.go create mode 100644 vendor/github.com/aws/aws-sdk-go/private/protocol/rest/payload.go create mode 100644 vendor/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go create mode 100644 vendor/github.com/aws/aws-sdk-go/private/signer/v4/header_rules.go create mode 100644 vendor/github.com/aws/aws-sdk-go/private/signer/v4/v4.go create mode 100644 vendor/github.com/aws/aws-sdk-go/sdk.go create mode 100644 vendor/github.com/camlistore/go4/LICENSE create mode 100644 vendor/github.com/camlistore/go4/lock/lock.go create mode 100644 vendor/github.com/camlistore/go4/lock/lock_appengine.go create mode 100644 vendor/github.com/camlistore/go4/lock/lock_darwin_amd64.go create mode 100644 vendor/github.com/camlistore/go4/lock/lock_freebsd.go create mode 100644 vendor/github.com/camlistore/go4/lock/lock_linux_amd64.go create mode 100644 vendor/github.com/camlistore/go4/lock/lock_linux_arm.go create mode 100644 vendor/github.com/camlistore/go4/lock/lock_plan9.go create mode 100644 vendor/github.com/camlistore/go4/lock/lock_sigzero.go create mode 100644 vendor/github.com/containernetworking/cni/LICENSE create mode 100644 vendor/github.com/containernetworking/cni/pkg/invoke/args.go create mode 100644 vendor/github.com/containernetworking/cni/pkg/invoke/delegate.go create mode 100644 vendor/github.com/containernetworking/cni/pkg/invoke/exec.go create mode 100644 vendor/github.com/containernetworking/cni/pkg/invoke/find.go create mode 100644 vendor/github.com/containernetworking/cni/pkg/ip/cidr.go create mode 100644 vendor/github.com/containernetworking/cni/pkg/ip/ipforward.go create mode 100644 vendor/github.com/containernetworking/cni/pkg/ip/ipmasq.go create mode 100644 vendor/github.com/containernetworking/cni/pkg/ip/link.go create mode 100644 vendor/github.com/containernetworking/cni/pkg/ip/route.go create mode 100644 vendor/github.com/containernetworking/cni/pkg/ipam/ipam.go create mode 100644 vendor/github.com/containernetworking/cni/pkg/ns/ns.go create mode 100644 vendor/github.com/containernetworking/cni/pkg/skel/skel.go create mode 100644 vendor/github.com/containernetworking/cni/pkg/testutils/cmd.go create mode 100644 vendor/github.com/containernetworking/cni/pkg/types/args.go create mode 100644 vendor/github.com/containernetworking/cni/pkg/types/types.go create mode 100644 vendor/github.com/containernetworking/cni/pkg/utils/sysctl/sysctl_linux.go create mode 100644 vendor/github.com/containernetworking/cni/pkg/utils/utils.go create mode 100644 vendor/github.com/containernetworking/cni/plugins/ipam/dhcp/daemon.go create mode 100644 vendor/github.com/containernetworking/cni/plugins/ipam/dhcp/lease.go create mode 100644 vendor/github.com/containernetworking/cni/plugins/ipam/dhcp/main.go create mode 100644 vendor/github.com/containernetworking/cni/plugins/ipam/dhcp/options.go create mode 100644 vendor/github.com/containernetworking/cni/plugins/ipam/host-local/allocator.go create mode 100644 vendor/github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk/backend.go create mode 100644 vendor/github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk/lock.go create mode 100644 vendor/github.com/containernetworking/cni/plugins/ipam/host-local/backend/store.go create mode 100644 vendor/github.com/containernetworking/cni/plugins/ipam/host-local/config.go create mode 100644 vendor/github.com/containernetworking/cni/plugins/ipam/host-local/main.go create mode 100644 vendor/github.com/containernetworking/cni/plugins/main/bridge/bridge.go create mode 100644 vendor/github.com/containernetworking/cni/plugins/main/ipvlan/ipvlan.go create mode 100644 vendor/github.com/containernetworking/cni/plugins/main/macvlan/macvlan.go create mode 100644 vendor/github.com/containernetworking/cni/plugins/main/ptp/ptp.go create mode 100644 vendor/github.com/containernetworking/cni/plugins/meta/flannel/flannel.go create mode 100644 vendor/github.com/containernetworking/cni/plugins/meta/tuning/tuning.go create mode 100644 vendor/github.com/coreos/gexpect/LICENCE create mode 100644 vendor/github.com/coreos/gexpect/gexpect.go create mode 100644 vendor/github.com/coreos/go-iptables/LICENSE create mode 100644 vendor/github.com/coreos/go-iptables/iptables/iptables.go create mode 100644 vendor/github.com/coreos/go-iptables/iptables/lock.go create mode 100644 vendor/github.com/coreos/go-semver/LICENSE create mode 100644 vendor/github.com/coreos/go-semver/example.go create mode 100644 vendor/github.com/coreos/go-semver/semver/semver.go create mode 100644 vendor/github.com/coreos/go-semver/semver/sort.go create mode 100644 vendor/github.com/coreos/go-systemd/LICENSE create mode 100644 vendor/github.com/coreos/go-systemd/activation/files.go create mode 100644 vendor/github.com/coreos/go-systemd/activation/listeners.go create mode 100644 vendor/github.com/coreos/go-systemd/activation/packetconns.go create mode 100644 vendor/github.com/coreos/go-systemd/dbus/dbus.go create mode 100644 vendor/github.com/coreos/go-systemd/dbus/methods.go create mode 100644 vendor/github.com/coreos/go-systemd/dbus/properties.go create mode 100644 vendor/github.com/coreos/go-systemd/dbus/set.go create mode 100644 vendor/github.com/coreos/go-systemd/dbus/subscription.go create mode 100644 vendor/github.com/coreos/go-systemd/dbus/subscription_set.go create mode 100644 vendor/github.com/coreos/go-systemd/sdjournal/journal.go create mode 100644 vendor/github.com/coreos/go-systemd/sdjournal/read.go create mode 100644 vendor/github.com/coreos/go-systemd/unit/deserialize.go create mode 100644 vendor/github.com/coreos/go-systemd/unit/escape.go create mode 100644 vendor/github.com/coreos/go-systemd/unit/option.go create mode 100644 vendor/github.com/coreos/go-systemd/unit/serialize.go create mode 100644 vendor/github.com/coreos/go-systemd/util/util.go create mode 100644 vendor/github.com/coreos/go-tspi/LICENSE create mode 100644 vendor/github.com/coreos/go-tspi/tpmclient/tpmclient.go create mode 100644 vendor/github.com/coreos/go-tspi/tspiconst/tspiconst.go create mode 100644 vendor/github.com/coreos/go-tspi/verification/verification.go create mode 100644 vendor/github.com/coreos/ioprogress/LICENSE create mode 100644 vendor/github.com/coreos/ioprogress/draw.go create mode 100644 vendor/github.com/coreos/ioprogress/reader.go create mode 100644 vendor/github.com/coreos/pkg/LICENSE create mode 100644 vendor/github.com/coreos/pkg/NOTICE create mode 100644 vendor/github.com/coreos/pkg/dlopen/dlopen.go create mode 100644 vendor/github.com/coreos/pkg/dlopen/dlopen_example.go create mode 100644 vendor/github.com/coreos/pkg/progressutil/iocopy.go create mode 100644 vendor/github.com/coreos/pkg/progressutil/progressbar.go create mode 100644 vendor/github.com/cpuguy83/go-md2man/LICENSE.md create mode 100644 vendor/github.com/cpuguy83/go-md2man/md2man.go create mode 100644 vendor/github.com/cpuguy83/go-md2man/md2man/md2man.go create mode 100644 vendor/github.com/cpuguy83/go-md2man/md2man/roff.go create mode 100644 vendor/github.com/cznic/b/LICENSE create mode 100644 vendor/github.com/cznic/b/btree.go create mode 100644 vendor/github.com/cznic/b/doc.go create mode 100644 vendor/github.com/cznic/bufs/LICENSE create mode 100644 vendor/github.com/cznic/bufs/bufs.go create mode 100644 vendor/github.com/cznic/exp/lldb/2pc.go create mode 100644 vendor/github.com/cznic/exp/lldb/2pc_docs.go create mode 100644 vendor/github.com/cznic/exp/lldb/LICENSE create mode 100644 vendor/github.com/cznic/exp/lldb/btree.go create mode 100644 vendor/github.com/cznic/exp/lldb/errors.go create mode 100644 vendor/github.com/cznic/exp/lldb/falloc.go create mode 100644 vendor/github.com/cznic/exp/lldb/filer.go create mode 100644 vendor/github.com/cznic/exp/lldb/gb.go create mode 100644 vendor/github.com/cznic/exp/lldb/lldb.go create mode 100644 vendor/github.com/cznic/exp/lldb/memfiler.go create mode 100644 vendor/github.com/cznic/exp/lldb/osfiler.go create mode 100644 vendor/github.com/cznic/exp/lldb/simplefilefiler.go create mode 100644 vendor/github.com/cznic/exp/lldb/xact.go create mode 100644 vendor/github.com/cznic/fileutil/LICENSE create mode 100644 vendor/github.com/cznic/fileutil/fileutil.go create mode 100644 vendor/github.com/cznic/fileutil/fileutil_arm.go create mode 100644 vendor/github.com/cznic/fileutil/fileutil_darwin.go create mode 100644 vendor/github.com/cznic/fileutil/fileutil_freebsd.go create mode 100644 vendor/github.com/cznic/fileutil/fileutil_linux.go create mode 100644 vendor/github.com/cznic/fileutil/fileutil_openbsd.go create mode 100644 vendor/github.com/cznic/fileutil/fileutil_plan9.go create mode 100644 vendor/github.com/cznic/fileutil/fileutil_solaris.go create mode 100644 vendor/github.com/cznic/fileutil/fileutil_windows.go create mode 100644 vendor/github.com/cznic/fileutil/test_deps.go create mode 100644 vendor/github.com/cznic/mathutil/LICENSE create mode 100644 vendor/github.com/cznic/mathutil/bits.go create mode 100644 vendor/github.com/cznic/mathutil/envelope.go create mode 100644 vendor/github.com/cznic/mathutil/mathutil.go create mode 100644 vendor/github.com/cznic/mathutil/permute.go create mode 100644 vendor/github.com/cznic/mathutil/primes.go create mode 100644 vendor/github.com/cznic/mathutil/rat.go create mode 100644 vendor/github.com/cznic/mathutil/rnd.go create mode 100644 vendor/github.com/cznic/mathutil/tables.go create mode 100644 vendor/github.com/cznic/mathutil/test_deps.go create mode 100644 vendor/github.com/cznic/ql/LICENSE create mode 100644 vendor/github.com/cznic/ql/blob.go create mode 100644 vendor/github.com/cznic/ql/btree.go create mode 100644 vendor/github.com/cznic/ql/builtin.go create mode 100644 vendor/github.com/cznic/ql/coerce.go create mode 100644 vendor/github.com/cznic/ql/doc.go create mode 100644 vendor/github.com/cznic/ql/driver.go create mode 100644 vendor/github.com/cznic/ql/driver/driver.go create mode 100644 vendor/github.com/cznic/ql/errors.go create mode 100644 vendor/github.com/cznic/ql/etc.go create mode 100644 vendor/github.com/cznic/ql/expr.go create mode 100644 vendor/github.com/cznic/ql/file.go create mode 100644 vendor/github.com/cznic/ql/httpfs.go create mode 100644 vendor/github.com/cznic/ql/introspection.go create mode 100644 vendor/github.com/cznic/ql/mem.go create mode 100644 vendor/github.com/cznic/ql/parser.go create mode 100644 vendor/github.com/cznic/ql/plan.go create mode 100644 vendor/github.com/cznic/ql/ql.go create mode 100644 vendor/github.com/cznic/ql/scanner.go create mode 100644 vendor/github.com/cznic/ql/stmt.go create mode 100644 vendor/github.com/cznic/ql/storage.go create mode 100644 vendor/github.com/cznic/sortutil/LICENSE create mode 100644 vendor/github.com/cznic/sortutil/sortutil.go create mode 100644 vendor/github.com/cznic/strutil/LICENSE create mode 100644 vendor/github.com/cznic/strutil/strutil.go create mode 100644 vendor/github.com/cznic/zappy/LICENSE create mode 100644 vendor/github.com/cznic/zappy/decode.go create mode 100644 vendor/github.com/cznic/zappy/decode_cgo.go create mode 100644 vendor/github.com/cznic/zappy/decode_nocgo.go create mode 100644 vendor/github.com/cznic/zappy/encode.go create mode 100644 vendor/github.com/cznic/zappy/encode_cgo.go create mode 100644 vendor/github.com/cznic/zappy/encode_nocgo.go create mode 100644 vendor/github.com/cznic/zappy/zappy.go create mode 100644 vendor/github.com/d2g/dhcp4/LICENSE create mode 100644 vendor/github.com/d2g/dhcp4/constants.go create mode 100644 vendor/github.com/d2g/dhcp4/helpers.go create mode 100644 vendor/github.com/d2g/dhcp4/option.go create mode 100644 vendor/github.com/d2g/dhcp4/packet.go create mode 100644 vendor/github.com/d2g/dhcp4client/LICENSE create mode 100644 vendor/github.com/d2g/dhcp4client/client.go create mode 100644 vendor/github.com/d2g/dhcp4client/inetsock.go create mode 100644 vendor/github.com/d2g/dhcp4client/init.go create mode 100644 vendor/github.com/d2g/dhcp4client/pktsock_linux.go create mode 100644 vendor/github.com/docker/distribution/LICENSE create mode 100644 vendor/github.com/docker/distribution/blobs.go create mode 100644 vendor/github.com/docker/distribution/digest/digest.go create mode 100644 vendor/github.com/docker/distribution/digest/digester.go create mode 100644 vendor/github.com/docker/distribution/digest/doc.go create mode 100644 vendor/github.com/docker/distribution/digest/set.go create mode 100644 vendor/github.com/docker/distribution/digest/verifiers.go create mode 100644 vendor/github.com/docker/distribution/doc.go create mode 100644 vendor/github.com/docker/distribution/errors.go create mode 100644 vendor/github.com/docker/distribution/manifests.go create mode 100644 vendor/github.com/docker/distribution/reference/reference.go create mode 100644 vendor/github.com/docker/distribution/reference/regexp.go create mode 100644 vendor/github.com/docker/distribution/registry.go create mode 100644 vendor/github.com/docker/distribution/tags.go create mode 100644 vendor/github.com/dustin/go-humanize/LICENSE create mode 100644 vendor/github.com/dustin/go-humanize/big.go create mode 100644 vendor/github.com/dustin/go-humanize/bigbytes.go create mode 100644 vendor/github.com/dustin/go-humanize/bytes.go create mode 100644 vendor/github.com/dustin/go-humanize/comma.go create mode 100644 vendor/github.com/dustin/go-humanize/ftoa.go create mode 100644 vendor/github.com/dustin/go-humanize/humanize.go create mode 100644 vendor/github.com/dustin/go-humanize/number.go create mode 100644 vendor/github.com/dustin/go-humanize/ordinals.go create mode 100644 vendor/github.com/dustin/go-humanize/si.go create mode 100644 vendor/github.com/dustin/go-humanize/times.go create mode 100644 vendor/github.com/go-ini/ini/LICENSE create mode 100644 vendor/github.com/go-ini/ini/ini.go create mode 100644 vendor/github.com/go-ini/ini/key.go create mode 100644 vendor/github.com/go-ini/ini/parser.go create mode 100644 vendor/github.com/go-ini/ini/section.go create mode 100644 vendor/github.com/go-ini/ini/struct.go create mode 100644 vendor/github.com/go-ole/go-ole/com.go create mode 100644 vendor/github.com/go-ole/go-ole/com_func.go create mode 100644 vendor/github.com/go-ole/go-ole/connect.go create mode 100644 vendor/github.com/go-ole/go-ole/constants.go create mode 100644 vendor/github.com/go-ole/go-ole/error.go create mode 100644 vendor/github.com/go-ole/go-ole/error_func.go create mode 100644 vendor/github.com/go-ole/go-ole/error_windows.go create mode 100644 vendor/github.com/go-ole/go-ole/guid.go create mode 100644 vendor/github.com/go-ole/go-ole/iconnectionpoint.go create mode 100644 vendor/github.com/go-ole/go-ole/iconnectionpoint_func.go create mode 100644 vendor/github.com/go-ole/go-ole/iconnectionpoint_windows.go create mode 100644 vendor/github.com/go-ole/go-ole/iconnectionpointcontainer.go create mode 100644 vendor/github.com/go-ole/go-ole/iconnectionpointcontainer_func.go create mode 100644 vendor/github.com/go-ole/go-ole/iconnectionpointcontainer_windows.go create mode 100644 vendor/github.com/go-ole/go-ole/idispatch.go create mode 100644 vendor/github.com/go-ole/go-ole/idispatch_func.go create mode 100644 vendor/github.com/go-ole/go-ole/idispatch_windows.go create mode 100644 vendor/github.com/go-ole/go-ole/ienumvariant.go create mode 100644 vendor/github.com/go-ole/go-ole/ienumvariant_func.go create mode 100644 vendor/github.com/go-ole/go-ole/ienumvariant_windows.go create mode 100644 vendor/github.com/go-ole/go-ole/iinspectable.go create mode 100644 vendor/github.com/go-ole/go-ole/iinspectable_func.go create mode 100644 vendor/github.com/go-ole/go-ole/iinspectable_windows.go create mode 100644 vendor/github.com/go-ole/go-ole/iprovideclassinfo.go create mode 100644 vendor/github.com/go-ole/go-ole/iprovideclassinfo_func.go create mode 100644 vendor/github.com/go-ole/go-ole/iprovideclassinfo_windows.go create mode 100644 vendor/github.com/go-ole/go-ole/itypeinfo.go create mode 100644 vendor/github.com/go-ole/go-ole/itypeinfo_func.go create mode 100644 vendor/github.com/go-ole/go-ole/itypeinfo_windows.go create mode 100644 vendor/github.com/go-ole/go-ole/iunknown.go create mode 100644 vendor/github.com/go-ole/go-ole/iunknown_func.go create mode 100644 vendor/github.com/go-ole/go-ole/iunknown_windows.go create mode 100644 vendor/github.com/go-ole/go-ole/ole.go create mode 100644 vendor/github.com/go-ole/go-ole/oleutil/connection.go create mode 100644 vendor/github.com/go-ole/go-ole/oleutil/connection_func.go create mode 100644 vendor/github.com/go-ole/go-ole/oleutil/connection_windows.go create mode 100644 vendor/github.com/go-ole/go-ole/oleutil/go-get.go create mode 100644 vendor/github.com/go-ole/go-ole/oleutil/oleutil.go create mode 100644 vendor/github.com/go-ole/go-ole/safearray.go create mode 100644 vendor/github.com/go-ole/go-ole/safearray_func.go create mode 100644 vendor/github.com/go-ole/go-ole/safearray_windows.go create mode 100644 vendor/github.com/go-ole/go-ole/safearrayconversion.go create mode 100644 vendor/github.com/go-ole/go-ole/safearrayslices.go create mode 100644 vendor/github.com/go-ole/go-ole/utility.go create mode 100644 vendor/github.com/go-ole/go-ole/variables.go create mode 100644 vendor/github.com/go-ole/go-ole/variant.go create mode 100644 vendor/github.com/go-ole/go-ole/variant_386.go create mode 100644 vendor/github.com/go-ole/go-ole/variant_amd64.go create mode 100644 vendor/github.com/go-ole/go-ole/vt_string.go create mode 100644 vendor/github.com/go-ole/go-ole/winrt.go create mode 100644 vendor/github.com/go-ole/go-ole/winrt_doc.go create mode 100644 vendor/github.com/godbus/dbus/LICENSE create mode 100644 vendor/github.com/godbus/dbus/auth.go create mode 100644 vendor/github.com/godbus/dbus/auth_external.go create mode 100644 vendor/github.com/godbus/dbus/auth_sha1.go create mode 100644 vendor/github.com/godbus/dbus/call.go create mode 100644 vendor/github.com/godbus/dbus/conn.go create mode 100644 vendor/github.com/godbus/dbus/conn_darwin.go create mode 100644 vendor/github.com/godbus/dbus/conn_other.go create mode 100644 vendor/github.com/godbus/dbus/dbus.go create mode 100644 vendor/github.com/godbus/dbus/decoder.go create mode 100644 vendor/github.com/godbus/dbus/doc.go create mode 100644 vendor/github.com/godbus/dbus/encoder.go create mode 100644 vendor/github.com/godbus/dbus/export.go create mode 100644 vendor/github.com/godbus/dbus/homedir.go create mode 100644 vendor/github.com/godbus/dbus/homedir_dynamic.go create mode 100644 vendor/github.com/godbus/dbus/homedir_static.go create mode 100644 vendor/github.com/godbus/dbus/introspect/call.go create mode 100644 vendor/github.com/godbus/dbus/introspect/introspect.go create mode 100644 vendor/github.com/godbus/dbus/introspect/introspectable.go create mode 100644 vendor/github.com/godbus/dbus/message.go create mode 100644 vendor/github.com/godbus/dbus/object.go create mode 100644 vendor/github.com/godbus/dbus/sig.go create mode 100644 vendor/github.com/godbus/dbus/transport_darwin.go create mode 100644 vendor/github.com/godbus/dbus/transport_generic.go create mode 100644 vendor/github.com/godbus/dbus/transport_unix.go create mode 100644 vendor/github.com/godbus/dbus/transport_unixcred_dragonfly.go create mode 100644 vendor/github.com/godbus/dbus/transport_unixcred_linux.go create mode 100644 vendor/github.com/godbus/dbus/variant.go create mode 100644 vendor/github.com/godbus/dbus/variant_lexer.go create mode 100644 vendor/github.com/godbus/dbus/variant_parser.go create mode 100644 vendor/github.com/gogo/protobuf/LICENSE create mode 100644 vendor/github.com/gogo/protobuf/proto/clone.go create mode 100644 vendor/github.com/gogo/protobuf/proto/decode.go create mode 100644 vendor/github.com/gogo/protobuf/proto/decode_gogo.go create mode 100644 vendor/github.com/gogo/protobuf/proto/encode.go create mode 100644 vendor/github.com/gogo/protobuf/proto/encode_gogo.go create mode 100644 vendor/github.com/gogo/protobuf/proto/equal.go create mode 100644 vendor/github.com/gogo/protobuf/proto/extensions.go create mode 100644 vendor/github.com/gogo/protobuf/proto/extensions_gogo.go create mode 100644 vendor/github.com/gogo/protobuf/proto/lib.go create mode 100644 vendor/github.com/gogo/protobuf/proto/lib_gogo.go create mode 100644 vendor/github.com/gogo/protobuf/proto/message_set.go create mode 100644 vendor/github.com/gogo/protobuf/proto/pointer_reflect.go create mode 100644 vendor/github.com/gogo/protobuf/proto/pointer_unsafe.go create mode 100644 vendor/github.com/gogo/protobuf/proto/pointer_unsafe_gogo.go create mode 100644 vendor/github.com/gogo/protobuf/proto/properties.go create mode 100644 vendor/github.com/gogo/protobuf/proto/properties_gogo.go create mode 100644 vendor/github.com/gogo/protobuf/proto/skip_gogo.go create mode 100644 vendor/github.com/gogo/protobuf/proto/text.go create mode 100644 vendor/github.com/gogo/protobuf/proto/text_gogo.go create mode 100644 vendor/github.com/gogo/protobuf/proto/text_parser.go create mode 100644 vendor/github.com/golang/protobuf/LICENSE create mode 100644 vendor/github.com/golang/protobuf/proto/clone.go create mode 100644 vendor/github.com/golang/protobuf/proto/decode.go create mode 100644 vendor/github.com/golang/protobuf/proto/encode.go create mode 100644 vendor/github.com/golang/protobuf/proto/equal.go create mode 100644 vendor/github.com/golang/protobuf/proto/extensions.go create mode 100644 vendor/github.com/golang/protobuf/proto/lib.go create mode 100644 vendor/github.com/golang/protobuf/proto/message_set.go create mode 100644 vendor/github.com/golang/protobuf/proto/pointer_reflect.go create mode 100644 vendor/github.com/golang/protobuf/proto/pointer_unsafe.go create mode 100644 vendor/github.com/golang/protobuf/proto/properties.go create mode 100644 vendor/github.com/golang/protobuf/proto/text.go create mode 100644 vendor/github.com/golang/protobuf/proto/text_parser.go create mode 100644 vendor/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.pb.go create mode 100644 vendor/github.com/golang/protobuf/protoc-gen-go/doc.go create mode 100644 vendor/github.com/golang/protobuf/protoc-gen-go/generator/generator.go create mode 100644 vendor/github.com/golang/protobuf/protoc-gen-go/internal/grpc/grpc.go create mode 100644 vendor/github.com/golang/protobuf/protoc-gen-go/link_grpc.go create mode 100644 vendor/github.com/golang/protobuf/protoc-gen-go/main.go create mode 100644 vendor/github.com/golang/protobuf/protoc-gen-go/plugin/plugin.pb.go create mode 100644 vendor/github.com/google/btree/LICENSE create mode 100644 vendor/github.com/google/btree/btree.go create mode 100644 vendor/github.com/google/btree/btree_mem.go create mode 100644 vendor/github.com/gorilla/context/LICENSE create mode 100644 vendor/github.com/gorilla/context/context.go create mode 100644 vendor/github.com/gorilla/context/doc.go create mode 100644 vendor/github.com/gorilla/mux/LICENSE create mode 100644 vendor/github.com/gorilla/mux/doc.go create mode 100644 vendor/github.com/gorilla/mux/mux.go create mode 100644 vendor/github.com/gorilla/mux/regexp.go create mode 100644 vendor/github.com/gorilla/mux/route.go create mode 100644 vendor/github.com/hashicorp/errwrap/LICENSE create mode 100644 vendor/github.com/hashicorp/errwrap/errwrap.go create mode 100644 vendor/github.com/hydrogen18/stoppableListener/LICENSE create mode 100644 vendor/github.com/hydrogen18/stoppableListener/listener.go create mode 100644 vendor/github.com/inconshreveable/mousetrap/LICENSE create mode 100644 vendor/github.com/inconshreveable/mousetrap/trap_others.go create mode 100644 vendor/github.com/inconshreveable/mousetrap/trap_windows.go create mode 100644 vendor/github.com/inconshreveable/mousetrap/trap_windows_1.4.go create mode 100644 vendor/github.com/jmespath/go-jmespath/LICENSE create mode 100644 vendor/github.com/jmespath/go-jmespath/api.go create mode 100644 vendor/github.com/jmespath/go-jmespath/astnodetype_string.go create mode 100644 vendor/github.com/jmespath/go-jmespath/functions.go create mode 100644 vendor/github.com/jmespath/go-jmespath/interpreter.go create mode 100644 vendor/github.com/jmespath/go-jmespath/lexer.go create mode 100644 vendor/github.com/jmespath/go-jmespath/parser.go create mode 100644 vendor/github.com/jmespath/go-jmespath/toktype_string.go create mode 100644 vendor/github.com/jmespath/go-jmespath/util.go create mode 100644 vendor/github.com/kballard/go-shellquote/LICENSE create mode 100644 vendor/github.com/kballard/go-shellquote/doc.go create mode 100644 vendor/github.com/kballard/go-shellquote/quote.go create mode 100644 vendor/github.com/kballard/go-shellquote/unquote.go create mode 100644 vendor/github.com/klauspost/compress/LICENSE create mode 100644 vendor/github.com/klauspost/compress/flate/copy.go create mode 100644 vendor/github.com/klauspost/compress/flate/crc32_amd64.go create mode 100644 vendor/github.com/klauspost/compress/flate/crc32_amd64.s create mode 100644 vendor/github.com/klauspost/compress/flate/crc32_noasm.go create mode 100644 vendor/github.com/klauspost/compress/flate/deflate.go create mode 100644 vendor/github.com/klauspost/compress/flate/fixedhuff.go create mode 100644 vendor/github.com/klauspost/compress/flate/gen.go create mode 100644 vendor/github.com/klauspost/compress/flate/huffman_bit_writer.go create mode 100644 vendor/github.com/klauspost/compress/flate/huffman_code.go create mode 100644 vendor/github.com/klauspost/compress/flate/inflate.go create mode 100644 vendor/github.com/klauspost/compress/flate/reverse_bits.go create mode 100644 vendor/github.com/klauspost/compress/flate/snappy.go create mode 100644 vendor/github.com/klauspost/compress/flate/token.go create mode 100644 vendor/github.com/klauspost/cpuid/LICENSE create mode 100644 vendor/github.com/klauspost/cpuid/cpuid.go create mode 100644 vendor/github.com/klauspost/cpuid/cpuid_386.s create mode 100644 vendor/github.com/klauspost/cpuid/cpuid_amd64.s create mode 100644 vendor/github.com/klauspost/cpuid/detect_intel.go create mode 100644 vendor/github.com/klauspost/cpuid/detect_ref.go create mode 100644 vendor/github.com/klauspost/cpuid/generate.go create mode 100644 vendor/github.com/klauspost/cpuid/private-gen.go create mode 100644 vendor/github.com/klauspost/crc32/LICENSE create mode 100644 vendor/github.com/klauspost/crc32/crc32.go create mode 100644 vendor/github.com/klauspost/crc32/crc32_amd64.go create mode 100644 vendor/github.com/klauspost/crc32/crc32_amd64.s create mode 100644 vendor/github.com/klauspost/crc32/crc32_amd64p32.go create mode 100644 vendor/github.com/klauspost/crc32/crc32_amd64p32.s create mode 100644 vendor/github.com/klauspost/crc32/crc32_generic.go create mode 100644 vendor/github.com/klauspost/pgzip/LICENSE create mode 100644 vendor/github.com/klauspost/pgzip/gunzip.go create mode 100644 vendor/github.com/klauspost/pgzip/gzip.go create mode 100644 vendor/github.com/kr/pty/License create mode 100644 vendor/github.com/kr/pty/doc.go create mode 100644 vendor/github.com/kr/pty/ioctl.go create mode 100644 vendor/github.com/kr/pty/ioctl_bsd.go create mode 100644 vendor/github.com/kr/pty/pty_darwin.go create mode 100644 vendor/github.com/kr/pty/pty_freebsd.go create mode 100644 vendor/github.com/kr/pty/pty_linux.go create mode 100644 vendor/github.com/kr/pty/pty_unsupported.go create mode 100644 vendor/github.com/kr/pty/run.go create mode 100644 vendor/github.com/kr/pty/types.go create mode 100644 vendor/github.com/kr/pty/types_freebsd.go create mode 100644 vendor/github.com/kr/pty/util.go create mode 100644 vendor/github.com/kr/pty/ztypes_386.go create mode 100644 vendor/github.com/kr/pty/ztypes_amd64.go create mode 100644 vendor/github.com/kr/pty/ztypes_arm.go create mode 100644 vendor/github.com/kr/pty/ztypes_arm64.go create mode 100644 vendor/github.com/kr/pty/ztypes_freebsd_386.go create mode 100644 vendor/github.com/kr/pty/ztypes_freebsd_amd64.go create mode 100644 vendor/github.com/kr/pty/ztypes_freebsd_arm.go create mode 100644 vendor/github.com/kr/pty/ztypes_ppc64.go create mode 100644 vendor/github.com/kr/pty/ztypes_ppc64le.go create mode 100644 vendor/github.com/kr/pty/ztypes_s390x.go create mode 100644 vendor/github.com/pborman/uuid/LICENSE create mode 100755 vendor/github.com/pborman/uuid/dce.go create mode 100755 vendor/github.com/pborman/uuid/doc.go create mode 100644 vendor/github.com/pborman/uuid/hash.go create mode 100644 vendor/github.com/pborman/uuid/json.go create mode 100755 vendor/github.com/pborman/uuid/node.go create mode 100644 vendor/github.com/pborman/uuid/sql.go create mode 100755 vendor/github.com/pborman/uuid/time.go create mode 100644 vendor/github.com/pborman/uuid/util.go create mode 100755 vendor/github.com/pborman/uuid/uuid.go create mode 100644 vendor/github.com/pborman/uuid/version1.go create mode 100644 vendor/github.com/pborman/uuid/version4.go create mode 100644 vendor/github.com/peterbourgon/diskv/LICENSE create mode 100644 vendor/github.com/peterbourgon/diskv/compression.go create mode 100644 vendor/github.com/peterbourgon/diskv/diskv.go create mode 100644 vendor/github.com/peterbourgon/diskv/index.go create mode 100644 vendor/github.com/russross/blackfriday/LICENSE.txt create mode 100644 vendor/github.com/russross/blackfriday/block.go create mode 100644 vendor/github.com/russross/blackfriday/html.go create mode 100644 vendor/github.com/russross/blackfriday/inline.go create mode 100644 vendor/github.com/russross/blackfriday/latex.go create mode 100644 vendor/github.com/russross/blackfriday/markdown.go create mode 100644 vendor/github.com/russross/blackfriday/smartypants.go create mode 100644 vendor/github.com/shirou/gopsutil/LICENSE create mode 100644 vendor/github.com/shirou/gopsutil/cpu/cpu.go create mode 100644 vendor/github.com/shirou/gopsutil/cpu/cpu_darwin.go create mode 100644 vendor/github.com/shirou/gopsutil/cpu/cpu_darwin_cgo.go create mode 100644 vendor/github.com/shirou/gopsutil/cpu/cpu_darwin_nocgo.go create mode 100644 vendor/github.com/shirou/gopsutil/cpu/cpu_freebsd.go create mode 100644 vendor/github.com/shirou/gopsutil/cpu/cpu_linux.go create mode 100644 vendor/github.com/shirou/gopsutil/cpu/cpu_unix.go create mode 100644 vendor/github.com/shirou/gopsutil/cpu/cpu_windows.go create mode 100644 vendor/github.com/shirou/gopsutil/doc.go create mode 100644 vendor/github.com/shirou/gopsutil/host/host.go create mode 100644 vendor/github.com/shirou/gopsutil/host/host_darwin.go create mode 100644 vendor/github.com/shirou/gopsutil/host/host_darwin_amd64.go create mode 100644 vendor/github.com/shirou/gopsutil/host/host_freebsd.go create mode 100644 vendor/github.com/shirou/gopsutil/host/host_freebsd_amd64.go create mode 100644 vendor/github.com/shirou/gopsutil/host/host_linux.go create mode 100644 vendor/github.com/shirou/gopsutil/host/host_linux_386.go create mode 100644 vendor/github.com/shirou/gopsutil/host/host_linux_amd64.go create mode 100644 vendor/github.com/shirou/gopsutil/host/host_linux_arm.go create mode 100644 vendor/github.com/shirou/gopsutil/host/host_windows.go create mode 100644 vendor/github.com/shirou/gopsutil/host/types_darwin.go create mode 100644 vendor/github.com/shirou/gopsutil/host/types_freebsd.go create mode 100644 vendor/github.com/shirou/gopsutil/host/types_linux.go create mode 100644 vendor/github.com/shirou/gopsutil/internal/common/binary.go create mode 100644 vendor/github.com/shirou/gopsutil/internal/common/common.go create mode 100644 vendor/github.com/shirou/gopsutil/internal/common/common_darwin.go create mode 100644 vendor/github.com/shirou/gopsutil/internal/common/common_freebsd.go create mode 100644 vendor/github.com/shirou/gopsutil/internal/common/common_linux.go create mode 100644 vendor/github.com/shirou/gopsutil/internal/common/common_unix.go create mode 100644 vendor/github.com/shirou/gopsutil/internal/common/common_windows.go create mode 100644 vendor/github.com/shirou/gopsutil/load/load.go create mode 100644 vendor/github.com/shirou/gopsutil/load/load_darwin.go create mode 100644 vendor/github.com/shirou/gopsutil/load/load_freebsd.go create mode 100644 vendor/github.com/shirou/gopsutil/load/load_linux.go create mode 100644 vendor/github.com/shirou/gopsutil/load/load_windows.go create mode 100644 vendor/github.com/shirou/gopsutil/mem/mem.go create mode 100644 vendor/github.com/shirou/gopsutil/mem/mem_darwin.go create mode 100644 vendor/github.com/shirou/gopsutil/mem/mem_darwin_cgo.go create mode 100644 vendor/github.com/shirou/gopsutil/mem/mem_darwin_nocgo.go create mode 100644 vendor/github.com/shirou/gopsutil/mem/mem_freebsd.go create mode 100644 vendor/github.com/shirou/gopsutil/mem/mem_linux.go create mode 100644 vendor/github.com/shirou/gopsutil/mem/mem_windows.go create mode 100644 vendor/github.com/shirou/gopsutil/net/net.go create mode 100644 vendor/github.com/shirou/gopsutil/net/net_darwin.go create mode 100644 vendor/github.com/shirou/gopsutil/net/net_freebsd.go create mode 100644 vendor/github.com/shirou/gopsutil/net/net_linux.go create mode 100644 vendor/github.com/shirou/gopsutil/net/net_unix.go create mode 100644 vendor/github.com/shirou/gopsutil/net/net_windows.go create mode 100644 vendor/github.com/shirou/gopsutil/process/process.go create mode 100644 vendor/github.com/shirou/gopsutil/process/process_darwin.go create mode 100644 vendor/github.com/shirou/gopsutil/process/process_darwin_amd64.go create mode 100644 vendor/github.com/shirou/gopsutil/process/process_freebsd.go create mode 100644 vendor/github.com/shirou/gopsutil/process/process_freebsd_386.go create mode 100644 vendor/github.com/shirou/gopsutil/process/process_freebsd_amd64.go create mode 100644 vendor/github.com/shirou/gopsutil/process/process_linux.go create mode 100644 vendor/github.com/shirou/gopsutil/process/process_linux_386.go create mode 100644 vendor/github.com/shirou/gopsutil/process/process_linux_amd64.go create mode 100644 vendor/github.com/shirou/gopsutil/process/process_linux_arm.go create mode 100644 vendor/github.com/shirou/gopsutil/process/process_posix.go create mode 100644 vendor/github.com/shirou/gopsutil/process/process_windows.go create mode 100644 vendor/github.com/shirou/gopsutil/process/types_darwin.go create mode 100644 vendor/github.com/shirou/gopsutil/process/types_freebsd.go create mode 100644 vendor/github.com/shirou/w32/LICENSE create mode 100644 vendor/github.com/shirou/w32/advapi32.go create mode 100644 vendor/github.com/shirou/w32/comctl32.go create mode 100644 vendor/github.com/shirou/w32/comdlg32.go create mode 100644 vendor/github.com/shirou/w32/constants.go create mode 100644 vendor/github.com/shirou/w32/dwmapi.go create mode 100644 vendor/github.com/shirou/w32/gdi32.go create mode 100644 vendor/github.com/shirou/w32/gdiplus.go create mode 100644 vendor/github.com/shirou/w32/idispatch.go create mode 100644 vendor/github.com/shirou/w32/istream.go create mode 100644 vendor/github.com/shirou/w32/iunknown.go create mode 100644 vendor/github.com/shirou/w32/kernel32.go create mode 100644 vendor/github.com/shirou/w32/ole32.go create mode 100644 vendor/github.com/shirou/w32/oleaut32.go create mode 100644 vendor/github.com/shirou/w32/opengl32.go create mode 100644 vendor/github.com/shirou/w32/psapi.go create mode 100644 vendor/github.com/shirou/w32/shell32.go create mode 100644 vendor/github.com/shirou/w32/typedef.go create mode 100644 vendor/github.com/shirou/w32/user32.go create mode 100644 vendor/github.com/shirou/w32/utils.go create mode 100644 vendor/github.com/shirou/w32/vars.go create mode 100644 vendor/github.com/shurcooL/sanitized_anchor_name/LICENSE create mode 100644 vendor/github.com/shurcooL/sanitized_anchor_name/main.go create mode 100644 vendor/github.com/spf13/cobra/LICENSE.txt create mode 100644 vendor/github.com/spf13/cobra/bash_completions.go create mode 100644 vendor/github.com/spf13/cobra/cobra.go create mode 100644 vendor/github.com/spf13/cobra/command.go create mode 100644 vendor/github.com/spf13/cobra/command_notwin.go create mode 100644 vendor/github.com/spf13/cobra/command_win.go create mode 100644 vendor/github.com/spf13/cobra/doc/man_docs.go create mode 100644 vendor/github.com/spf13/cobra/doc/md_docs.go create mode 100644 vendor/github.com/spf13/cobra/doc/util.go create mode 100644 vendor/github.com/spf13/pflag/LICENSE create mode 100644 vendor/github.com/spf13/pflag/bool.go create mode 100644 vendor/github.com/spf13/pflag/count.go create mode 100644 vendor/github.com/spf13/pflag/duration.go create mode 100644 vendor/github.com/spf13/pflag/flag.go create mode 100644 vendor/github.com/spf13/pflag/float32.go create mode 100644 vendor/github.com/spf13/pflag/float64.go create mode 100644 vendor/github.com/spf13/pflag/golangflag.go create mode 100644 vendor/github.com/spf13/pflag/int.go create mode 100644 vendor/github.com/spf13/pflag/int32.go create mode 100644 vendor/github.com/spf13/pflag/int64.go create mode 100644 vendor/github.com/spf13/pflag/int8.go create mode 100644 vendor/github.com/spf13/pflag/int_slice.go create mode 100644 vendor/github.com/spf13/pflag/ip.go create mode 100644 vendor/github.com/spf13/pflag/ipmask.go create mode 100644 vendor/github.com/spf13/pflag/ipnet.go create mode 100644 vendor/github.com/spf13/pflag/string.go create mode 100644 vendor/github.com/spf13/pflag/string_slice.go create mode 100644 vendor/github.com/spf13/pflag/uint.go create mode 100644 vendor/github.com/spf13/pflag/uint16.go create mode 100644 vendor/github.com/spf13/pflag/uint32.go create mode 100644 vendor/github.com/spf13/pflag/uint64.go create mode 100644 vendor/github.com/spf13/pflag/uint8.go create mode 100644 vendor/github.com/syndtr/gocapability/LICENSE create mode 100644 vendor/github.com/syndtr/gocapability/capability/capability.go create mode 100644 vendor/github.com/syndtr/gocapability/capability/capability_linux.go create mode 100644 vendor/github.com/syndtr/gocapability/capability/capability_noop.go create mode 100644 vendor/github.com/syndtr/gocapability/capability/enum.go create mode 100644 vendor/github.com/syndtr/gocapability/capability/syscall_linux.go create mode 100644 vendor/github.com/vishvananda/netlink/LICENSE create mode 100644 vendor/github.com/vishvananda/netlink/addr.go create mode 100644 vendor/github.com/vishvananda/netlink/addr_linux.go create mode 100644 vendor/github.com/vishvananda/netlink/class.go create mode 100644 vendor/github.com/vishvananda/netlink/class_linux.go create mode 100644 vendor/github.com/vishvananda/netlink/filter.go create mode 100644 vendor/github.com/vishvananda/netlink/filter_linux.go create mode 100644 vendor/github.com/vishvananda/netlink/link.go create mode 100644 vendor/github.com/vishvananda/netlink/link_linux.go create mode 100644 vendor/github.com/vishvananda/netlink/neigh.go create mode 100644 vendor/github.com/vishvananda/netlink/neigh_linux.go create mode 100644 vendor/github.com/vishvananda/netlink/netlink.go create mode 100644 vendor/github.com/vishvananda/netlink/netlink_unspecified.go create mode 100644 vendor/github.com/vishvananda/netlink/nl/addr_linux.go create mode 100644 vendor/github.com/vishvananda/netlink/nl/link_linux.go create mode 100644 vendor/github.com/vishvananda/netlink/nl/nl_linux.go create mode 100644 vendor/github.com/vishvananda/netlink/nl/route_linux.go create mode 100644 vendor/github.com/vishvananda/netlink/nl/tc_linux.go create mode 100644 vendor/github.com/vishvananda/netlink/nl/xfrm_linux.go create mode 100644 vendor/github.com/vishvananda/netlink/nl/xfrm_policy_linux.go create mode 100644 vendor/github.com/vishvananda/netlink/nl/xfrm_state_linux.go create mode 100644 vendor/github.com/vishvananda/netlink/protinfo.go create mode 100644 vendor/github.com/vishvananda/netlink/protinfo_linux.go create mode 100644 vendor/github.com/vishvananda/netlink/qdisc.go create mode 100644 vendor/github.com/vishvananda/netlink/qdisc_linux.go create mode 100644 vendor/github.com/vishvananda/netlink/route.go create mode 100644 vendor/github.com/vishvananda/netlink/route_linux.go create mode 100644 vendor/github.com/vishvananda/netlink/xfrm.go create mode 100644 vendor/github.com/vishvananda/netlink/xfrm_policy.go create mode 100644 vendor/github.com/vishvananda/netlink/xfrm_policy_linux.go create mode 100644 vendor/github.com/vishvananda/netlink/xfrm_state.go create mode 100644 vendor/github.com/vishvananda/netlink/xfrm_state_linux.go create mode 100644 vendor/go4.org/LICENSE create mode 100644 vendor/go4.org/errorutil/highlight.go create mode 100644 vendor/golang.org/x/crypto/LICENSE create mode 100644 vendor/golang.org/x/crypto/PATENTS create mode 100644 vendor/golang.org/x/crypto/cast5/cast5.go create mode 100644 vendor/golang.org/x/crypto/openpgp/armor/armor.go create mode 100644 vendor/golang.org/x/crypto/openpgp/armor/encode.go create mode 100644 vendor/golang.org/x/crypto/openpgp/canonical_text.go create mode 100644 vendor/golang.org/x/crypto/openpgp/elgamal/elgamal.go create mode 100644 vendor/golang.org/x/crypto/openpgp/errors/errors.go create mode 100644 vendor/golang.org/x/crypto/openpgp/keys.go create mode 100644 vendor/golang.org/x/crypto/openpgp/packet/compressed.go create mode 100644 vendor/golang.org/x/crypto/openpgp/packet/config.go create mode 100644 vendor/golang.org/x/crypto/openpgp/packet/encrypted_key.go create mode 100644 vendor/golang.org/x/crypto/openpgp/packet/literal.go create mode 100644 vendor/golang.org/x/crypto/openpgp/packet/ocfb.go create mode 100644 vendor/golang.org/x/crypto/openpgp/packet/one_pass_signature.go create mode 100644 vendor/golang.org/x/crypto/openpgp/packet/opaque.go create mode 100644 vendor/golang.org/x/crypto/openpgp/packet/packet.go create mode 100644 vendor/golang.org/x/crypto/openpgp/packet/private_key.go create mode 100644 vendor/golang.org/x/crypto/openpgp/packet/public_key.go create mode 100644 vendor/golang.org/x/crypto/openpgp/packet/public_key_v3.go create mode 100644 vendor/golang.org/x/crypto/openpgp/packet/reader.go create mode 100644 vendor/golang.org/x/crypto/openpgp/packet/signature.go create mode 100644 vendor/golang.org/x/crypto/openpgp/packet/signature_v3.go create mode 100644 vendor/golang.org/x/crypto/openpgp/packet/symmetric_key_encrypted.go create mode 100644 vendor/golang.org/x/crypto/openpgp/packet/symmetrically_encrypted.go create mode 100644 vendor/golang.org/x/crypto/openpgp/packet/userattribute.go create mode 100644 vendor/golang.org/x/crypto/openpgp/packet/userid.go create mode 100644 vendor/golang.org/x/crypto/openpgp/read.go create mode 100644 vendor/golang.org/x/crypto/openpgp/s2k/s2k.go create mode 100644 vendor/golang.org/x/crypto/openpgp/write.go create mode 100644 vendor/golang.org/x/crypto/ssh/terminal/terminal.go create mode 100644 vendor/golang.org/x/crypto/ssh/terminal/util.go create mode 100644 vendor/golang.org/x/crypto/ssh/terminal/util_bsd.go create mode 100644 vendor/golang.org/x/crypto/ssh/terminal/util_linux.go create mode 100644 vendor/golang.org/x/crypto/ssh/terminal/util_windows.go create mode 100644 vendor/golang.org/x/net/LICENSE create mode 100644 vendor/golang.org/x/net/PATENTS create mode 100644 vendor/golang.org/x/net/context/context.go create mode 100644 vendor/golang.org/x/net/html/atom/atom.go create mode 100644 vendor/golang.org/x/net/html/atom/gen.go create mode 100644 vendor/golang.org/x/net/html/atom/table.go create mode 100644 vendor/golang.org/x/net/html/const.go create mode 100644 vendor/golang.org/x/net/html/doc.go create mode 100644 vendor/golang.org/x/net/html/doctype.go create mode 100644 vendor/golang.org/x/net/html/entity.go create mode 100644 vendor/golang.org/x/net/html/escape.go create mode 100644 vendor/golang.org/x/net/html/foreign.go create mode 100644 vendor/golang.org/x/net/html/node.go create mode 100644 vendor/golang.org/x/net/html/parse.go create mode 100644 vendor/golang.org/x/net/html/render.go create mode 100644 vendor/golang.org/x/net/html/token.go create mode 100644 vendor/golang.org/x/net/http2/client_conn_pool.go create mode 100644 vendor/golang.org/x/net/http2/configure_transport.go create mode 100644 vendor/golang.org/x/net/http2/errors.go create mode 100644 vendor/golang.org/x/net/http2/fixed_buffer.go create mode 100644 vendor/golang.org/x/net/http2/flow.go create mode 100644 vendor/golang.org/x/net/http2/frame.go create mode 100644 vendor/golang.org/x/net/http2/go15.go create mode 100644 vendor/golang.org/x/net/http2/gotrack.go create mode 100644 vendor/golang.org/x/net/http2/headermap.go create mode 100644 vendor/golang.org/x/net/http2/hpack/encode.go create mode 100644 vendor/golang.org/x/net/http2/hpack/hpack.go create mode 100644 vendor/golang.org/x/net/http2/hpack/huffman.go create mode 100644 vendor/golang.org/x/net/http2/hpack/tables.go create mode 100644 vendor/golang.org/x/net/http2/http2.go create mode 100644 vendor/golang.org/x/net/http2/not_go15.go create mode 100644 vendor/golang.org/x/net/http2/not_go16.go create mode 100644 vendor/golang.org/x/net/http2/pipe.go create mode 100644 vendor/golang.org/x/net/http2/server.go create mode 100644 vendor/golang.org/x/net/http2/transport.go create mode 100644 vendor/golang.org/x/net/http2/write.go create mode 100644 vendor/golang.org/x/net/http2/writesched.go create mode 100644 vendor/golang.org/x/net/internal/timeseries/timeseries.go create mode 100644 vendor/golang.org/x/net/trace/events.go create mode 100644 vendor/golang.org/x/net/trace/histogram.go create mode 100644 vendor/golang.org/x/net/trace/trace.go create mode 100644 vendor/golang.org/x/sys/LICENSE create mode 100644 vendor/golang.org/x/sys/PATENTS create mode 100644 vendor/golang.org/x/sys/unix/asm.s create mode 100644 vendor/golang.org/x/sys/unix/asm_darwin_386.s create mode 100644 vendor/golang.org/x/sys/unix/asm_darwin_amd64.s create mode 100644 vendor/golang.org/x/sys/unix/asm_darwin_arm.s create mode 100644 vendor/golang.org/x/sys/unix/asm_darwin_arm64.s create mode 100644 vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s create mode 100644 vendor/golang.org/x/sys/unix/asm_freebsd_386.s create mode 100644 vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s create mode 100644 vendor/golang.org/x/sys/unix/asm_freebsd_arm.s create mode 100644 vendor/golang.org/x/sys/unix/asm_linux_386.s create mode 100644 vendor/golang.org/x/sys/unix/asm_linux_amd64.s create mode 100644 vendor/golang.org/x/sys/unix/asm_linux_arm.s create mode 100644 vendor/golang.org/x/sys/unix/asm_linux_arm64.s create mode 100644 vendor/golang.org/x/sys/unix/asm_linux_mips64x.s create mode 100644 vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s create mode 100644 vendor/golang.org/x/sys/unix/asm_linux_s390x.s create mode 100644 vendor/golang.org/x/sys/unix/asm_netbsd_386.s create mode 100644 vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s create mode 100644 vendor/golang.org/x/sys/unix/asm_netbsd_arm.s create mode 100644 vendor/golang.org/x/sys/unix/asm_openbsd_386.s create mode 100644 vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s create mode 100644 vendor/golang.org/x/sys/unix/asm_solaris_amd64.s create mode 100644 vendor/golang.org/x/sys/unix/bluetooth_linux.go create mode 100644 vendor/golang.org/x/sys/unix/constants.go create mode 100644 vendor/golang.org/x/sys/unix/env_unix.go create mode 100644 vendor/golang.org/x/sys/unix/env_unset.go create mode 100644 vendor/golang.org/x/sys/unix/flock.go create mode 100644 vendor/golang.org/x/sys/unix/flock_linux_32bit.go create mode 100644 vendor/golang.org/x/sys/unix/gccgo.go create mode 100644 vendor/golang.org/x/sys/unix/gccgo_c.c create mode 100644 vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/mkpost.go create mode 100644 vendor/golang.org/x/sys/unix/race.go create mode 100644 vendor/golang.org/x/sys/unix/race0.go create mode 100644 vendor/golang.org/x/sys/unix/sockcmsg_linux.go create mode 100644 vendor/golang.org/x/sys/unix/sockcmsg_unix.go create mode 100644 vendor/golang.org/x/sys/unix/str.go create mode 100644 vendor/golang.org/x/sys/unix/syscall.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_bsd.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_darwin.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_darwin_386.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_darwin_arm.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_dragonfly.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_freebsd.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_freebsd_386.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_386.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_arm.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_arm64.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_linux_s390x.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_netbsd.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_netbsd_386.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_no_getwd.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_openbsd.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_openbsd_386.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_solaris.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_unix.go create mode 100644 vendor/golang.org/x/sys/unix/types_darwin.go create mode 100644 vendor/golang.org/x/sys/unix/types_dragonfly.go create mode 100644 vendor/golang.org/x/sys/unix/types_freebsd.go create mode 100644 vendor/golang.org/x/sys/unix/types_linux.go create mode 100644 vendor/golang.org/x/sys/unix/types_netbsd.go create mode 100644 vendor/golang.org/x/sys/unix/types_openbsd.go create mode 100644 vendor/golang.org/x/sys/unix/types_solaris.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_darwin_386.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_darwin_arm.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_freebsd_386.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_freebsd_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_freebsd_arm.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_linux_386.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_linux_arm.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_netbsd_386.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_netbsd_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_netbsd_arm.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_openbsd_386.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_solaris_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_linux_386.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/zsysctl_openbsd.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_darwin_386.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_darwin_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_darwin_arm.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_darwin_arm64.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_freebsd_386.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_linux_386.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_netbsd_386.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_openbsd_386.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_openbsd_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_solaris_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_darwin_386.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_linux_386.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_linux_arm.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go create mode 100644 vendor/golang.org/x/tools/LICENSE create mode 100644 vendor/golang.org/x/tools/PATENTS create mode 100644 vendor/golang.org/x/tools/go/vcs/discovery.go create mode 100644 vendor/golang.org/x/tools/go/vcs/env.go create mode 100644 vendor/golang.org/x/tools/go/vcs/http.go create mode 100644 vendor/golang.org/x/tools/go/vcs/vcs.go create mode 100644 vendor/google.golang.org/grpc/LICENSE create mode 100644 vendor/google.golang.org/grpc/PATENTS create mode 100644 vendor/google.golang.org/grpc/call.go create mode 100644 vendor/google.golang.org/grpc/clientconn.go create mode 100644 vendor/google.golang.org/grpc/codes/code_string.go create mode 100644 vendor/google.golang.org/grpc/codes/codes.go create mode 100644 vendor/google.golang.org/grpc/credentials/credentials.go create mode 100644 vendor/google.golang.org/grpc/doc.go create mode 100644 vendor/google.golang.org/grpc/grpclog/logger.go create mode 100644 vendor/google.golang.org/grpc/internal/internal.go create mode 100644 vendor/google.golang.org/grpc/metadata/metadata.go create mode 100644 vendor/google.golang.org/grpc/naming/naming.go create mode 100644 vendor/google.golang.org/grpc/peer/peer.go create mode 100644 vendor/google.golang.org/grpc/picker.go create mode 100644 vendor/google.golang.org/grpc/rpc_util.go create mode 100644 vendor/google.golang.org/grpc/server.go create mode 100644 vendor/google.golang.org/grpc/stream.go create mode 100644 vendor/google.golang.org/grpc/trace.go create mode 100644 vendor/google.golang.org/grpc/transport/control.go create mode 100644 vendor/google.golang.org/grpc/transport/handler_server.go create mode 100644 vendor/google.golang.org/grpc/transport/http2_client.go create mode 100644 vendor/google.golang.org/grpc/transport/http2_server.go create mode 100644 vendor/google.golang.org/grpc/transport/http_util.go create mode 100644 vendor/google.golang.org/grpc/transport/transport.go create mode 100644 vendor/gopkg.in/inf.v0/LICENSE create mode 100644 vendor/gopkg.in/inf.v0/dec.go create mode 100644 vendor/gopkg.in/inf.v0/rounder.go create mode 100644 vendor/k8s.io/kubernetes/LICENSE create mode 100644 vendor/k8s.io/kubernetes/pkg/api/resource/deep_copy_generated.go create mode 100644 vendor/k8s.io/kubernetes/pkg/api/resource/generated.pb.go create mode 100644 vendor/k8s.io/kubernetes/pkg/api/resource/quantity.go create mode 100644 vendor/k8s.io/kubernetes/pkg/api/resource/quantity_proto.go create mode 100644 vendor/k8s.io/kubernetes/pkg/api/resource/scale_int.go create mode 100644 vendor/k8s.io/kubernetes/pkg/api/resource/suffix.go create mode 100644 vendor/k8s.io/kubernetes/pkg/conversion/cloner.go create mode 100644 vendor/k8s.io/kubernetes/pkg/conversion/converter.go create mode 100644 vendor/k8s.io/kubernetes/pkg/conversion/deep_copy_generated.go create mode 100644 vendor/k8s.io/kubernetes/pkg/conversion/deep_equal.go create mode 100644 vendor/k8s.io/kubernetes/pkg/conversion/doc.go create mode 100644 vendor/k8s.io/kubernetes/pkg/conversion/helper.go create mode 100644 vendor/k8s.io/kubernetes/third_party/forked/reflect/LICENSE create mode 100644 vendor/k8s.io/kubernetes/third_party/forked/reflect/deep_equal.go diff --git a/glide.lock b/glide.lock new file mode 100644 index 0000000000..87fe3ed55f --- /dev/null +++ b/glide.lock @@ -0,0 +1,293 @@ +hash: 74fbc0c8510a051f4fa1a79b834e401dbea213c8e5e5749ec1c3a81d2256f091 +updated: 2016-06-29T10:38:03.891204025+02:00 +imports: +- name: github.com/appc/docker2aci + version: 355af275fa8d48b4ecdd361a5feaf173abff81e7 + subpackages: + - lib + - lib/common + - lib/internal + - lib/internal/backend/file + - lib/internal/backend/repository + - lib/internal/docker + - lib/internal/tarball + - lib/internal/types + - lib/internal/util + - pkg/log +- name: github.com/appc/goaci + version: ba7b591f930783c0ab75f5bbfd6ff65c7bd011bf + subpackages: + - proj2aci +- name: github.com/appc/spec + version: f82c741e743001237821b5e0bb9a8ebd324d3117 + subpackages: + - ace + - aci + - actool + - discovery + - pkg/acirenderer + - pkg/device + - pkg/tarheader + - schema + - schema/common + - schema/lastditch + - schema/types +- name: github.com/aws/aws-sdk-go + version: 13a12060f716145019378a10e2806c174356b857 + subpackages: + - aws + - aws/awserr + - aws/awsutil + - aws/client/metadata + - aws/credentials + - aws/request + - private/protocol/rest + - private/signer/v4 +- name: github.com/camlistore/go4 + version: 9ba773eba85ab9e258ff516630f7f6474bc4535b + subpackages: + - lock +- name: github.com/containernetworking/cni + version: 5c3c17164270150467498a32c71436c7cd5501be + subpackages: + - pkg/invoke + - pkg/ip + - pkg/ipam + - pkg/ipam + - pkg/ns + - pkg/skel + - pkg/testutils + - pkg/skel + - pkg/testutils + - pkg/types + - pkg/utils + - pkg/utils/sysctl + - plugins/ipam/dhcp + - plugins/ipam/host-local + - plugins/ipam/host-local/backend + - plugins/ipam/host-local/backend/disk + - plugins/main/bridge + - plugins/main/ipvlan + - plugins/main/macvlan + - plugins/main/ptp + - plugins/meta/flannel + - plugins/meta/tuning + - pkg/utils/sysctl + - plugins/ipam/dhcp + - plugins/ipam/host-local + - plugins/ipam/host-local/backend + - plugins/ipam/host-local/backend/disk + - plugins/main/bridge + - plugins/main/ipvlan + - plugins/main/macvlan + - plugins/main/ptp + - plugins/meta/flannel + - plugins/meta/tuning +- name: github.com/coreos/gexpect + version: ca42424d18c76d0d51a4cccd830d11878e9e5c17 +- name: github.com/coreos/go-iptables + version: fbb73372b87f6e89951c2b6b31470c2c9d5cfae3 + subpackages: + - iptables +- name: github.com/coreos/go-semver + version: 294930c1e79c64e7dbe360054274fdad492c8cf5 + subpackages: + - semver +- name: github.com/coreos/go-systemd + version: b32b8467dbea18858bfebf65c1a6a761090f2c31 + subpackages: + - activation + - dbus + - sdjournal + - unit + - util +- name: github.com/coreos/go-tspi + version: 03955c59fff97f9e38e7e32c68ac4db21a2aea2b + subpackages: + - tpmclient + - tspiconst + - verification +- name: github.com/coreos/ioprogress + version: e7fc03058804de5488baed8df5b89f3924b9ec9a +- name: github.com/coreos/pkg + version: 7f080b6c11ac2d2347c3cd7521e810207ea1a041 + subpackages: + - dlopen + - progressutil +- name: github.com/cpuguy83/go-md2man + version: 71acacd42f85e5e82f70a55327789582a5200a90 + subpackages: + - md2man +- name: github.com/cznic/b + version: e2e747ce049fb910cff6b1fd7ad8faf3900939d5 +- name: github.com/cznic/bufs + version: 3dcccbd7064a1689f9c093a988ea11ac00e21f51 +- name: github.com/cznic/exp + version: 36265f1914ea00990ff0b73f72350edf9b1850df + subpackages: + - lldb +- name: github.com/cznic/fileutil + version: 21ae57c9dce724a15e88bd9cd46d5668f3e880a5 +- name: github.com/cznic/mathutil + version: 250d0b9d3304c5ea0c4cfc7d9efc7ee528b81f3b +- name: github.com/cznic/ql + version: 77545ff365ff426dfab06c46d70fa77600cd55af + subpackages: + - driver +- name: github.com/cznic/sortutil + version: d4401851b4c370f979b842fa1e45e0b3b718b391 +- name: github.com/cznic/strutil + version: 97bc31f80ac4c9fa9c5dc5fea74c383858988ea2 +- name: github.com/cznic/zappy + version: 47331054e4f96186e3ff772877c0443909368a45 +- name: github.com/d2g/dhcp4 + version: f0e4d29ff0231dce36e250b2ed9ff08412584bca +- name: github.com/d2g/dhcp4client + version: bed07e1bc5b85f69c6f0fd73393aa35ec68ed892 +- name: github.com/docker/distribution + version: 099622876197e3b24d627a72053d1bcc8968076a + subpackages: + - digest + - reference +- name: github.com/dustin/go-humanize + version: c20a8bde38c8f5ba06f6600edf473705c96829d1 +- name: github.com/go-ini/ini + version: 12f418cc7edc5a618a51407b7ac1f1f512139df3 +- name: github.com/go-ole/go-ole + version: 572eabb84c424e76a0d39d31510dd7dfd62f70b2 + subpackages: + - oleutil +- name: github.com/godbus/dbus + version: a1b8ba5163b7f041b22761461eabd02b70d1f824 + subpackages: + - introspect +- name: github.com/gogo/protobuf + version: 4168943e65a2802828518e95310aeeed6d84c4e5 + subpackages: + - proto +- name: github.com/golang/protobuf + version: 2402d76f3d41f928c7902a765dfc872356dd3aad + subpackages: + - proto + - protoc-gen-go + - protoc-gen-go/descriptor + - protoc-gen-go/generator + - protoc-gen-go/internal/grpc + - protoc-gen-go/plugin +- name: github.com/google/btree + version: f06e229e679911bb31a04e07ac891115822e37c3 +- name: github.com/gorilla/context + version: 50c25fb3b2b3b3cc724e9b6ac75fb44b3bccd0da +- name: github.com/gorilla/mux + version: e444e69cbd2e2e3e0749a2f3c717cec491552bbf +- name: github.com/hashicorp/errwrap + version: 7554cd9344cec97297fa6649b055a8c98c2a1e55 +- name: github.com/hydrogen18/stoppableListener + version: 2eebd04b47ff393f4bc50b7fcacf8f048994c6fd +- name: github.com/inconshreveable/mousetrap + version: 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75 +- name: github.com/jmespath/go-jmespath + version: 0b12d6b521d83fc7f755e7cfc1b1fbdd35a01a74 +- name: github.com/kballard/go-shellquote + version: e5c918b80c17694cbc49aab32a759f9a40067f5d +- name: github.com/klauspost/compress + version: 006acde2c5d283d2f8b8aa03d8f0cd2891c680cf + subpackages: + - flate +- name: github.com/klauspost/cpuid + version: 09cded8978dc9e80714c4d85b0322337b0a1e5e0 +- name: github.com/klauspost/crc32 + version: 19b0b332c9e4516a6370a0456e6182c3b5036720 +- name: github.com/klauspost/pgzip + version: 95e8170c5d4da28db9c64dfc9ec3138ea4466fd4 +- name: github.com/kr/pty + version: f7ee69f31298ecbe5d2b349c711e2547a617d398 +- name: github.com/pborman/uuid + version: cccd189d45f7ac3368a0d127efb7f4d08ae0b655 +- name: github.com/peterbourgon/diskv + version: 937c5a91d7fb1477fa6d2bb71410b2ae7a0f2143 +- name: github.com/russross/blackfriday + version: 300106c228d52c8941d4b3de6054a6062a86dda3 +- name: github.com/shirou/gopsutil + version: e8f7a95747d711f34ddfe9dd9b825a84bd059dec + subpackages: + - cpu + - host + - internal/common + - load + - mem + - net + - process +- name: github.com/shirou/w32 + version: 3c9377fc6748f222729a8270fe2775d149a249ad +- name: github.com/shurcooL/sanitized_anchor_name + version: 10ef21a441db47d8b13ebcc5fd2310f636973c77 +- name: github.com/spf13/cobra + version: 4c05eb1145f16d0e6bb4a3e1b6d769f4713cb41f + subpackages: + - doc +- name: github.com/spf13/pflag + version: 08b1a584251b5b62f458943640fc8ebd4d50aaa5 +- name: github.com/StackExchange/wmi + version: f3e2bae1e0cb5aef83e319133eabfee30013a4a5 +- name: github.com/syndtr/gocapability + version: 8e4cdcb3c22b40d5e330ade0b68cb2e2a3cf6f98 + subpackages: + - capability +- name: github.com/vishvananda/netlink + version: ecf47fd5739b3d2c3daf7c89c4b9715a2605c21b + subpackages: + - nl +- name: go4.org + version: 03efcb870d84809319ea509714dd6d19a1498483 + subpackages: + - errorutil +- name: golang.org/x/crypto + version: a7ead6ddf06233883deca151dffaef2effbf498f + subpackages: + - cast5 + - openpgp + - openpgp/armor + - openpgp/elgamal + - openpgp/errors + - openpgp/packet + - openpgp/s2k + - ssh/terminal +- name: golang.org/x/net + version: d513e58596cd55e6f47cd1dcbff6b46035baeccb + subpackages: + - context + - html + - html/atom + - http2 + - http2/hpack + - internal/timeseries + - trace +- name: golang.org/x/sys + version: b44883b474ffefa37335017174e397412b633a4f + subpackages: + - unix +- name: golang.org/x/tools + version: 27e692e6ec36d8f48be794f32553e1400c70dbf2 + subpackages: + - go/vcs +- name: google.golang.org/grpc + version: 0f80f5b995e8332b1bdaac1bc37af0482c60147c + subpackages: + - codes + - credentials + - grpclog + - metadata + - naming + - peer + - transport + - internal +- name: gopkg.in/inf.v0 + version: 3887ee99ecf07df5b447e9b00d9c0b2adaa9f3e4 +- name: k8s.io/kubernetes + version: 9990f843cd62caa90445cf76b07d63ba7b5c86fd + subpackages: + - pkg/api/resource + - pkg/conversion + - third_party/forked/reflect +devImports: [] diff --git a/vendor/github.com/StackExchange/wmi/LICENSE b/vendor/github.com/StackExchange/wmi/LICENSE new file mode 100644 index 0000000000..ae80b67209 --- /dev/null +++ b/vendor/github.com/StackExchange/wmi/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2013 Stack Exchange + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/StackExchange/wmi/wmi.go b/vendor/github.com/StackExchange/wmi/wmi.go new file mode 100644 index 0000000000..b931ca57af --- /dev/null +++ b/vendor/github.com/StackExchange/wmi/wmi.go @@ -0,0 +1,416 @@ +// +build windows + +/* +Package wmi provides a WQL interface for WMI on Windows. + +Example code to print names of running processes: + + type Win32_Process struct { + Name string + } + + func main() { + var dst []Win32_Process + q := wmi.CreateQuery(&dst, "") + err := wmi.Query(q, &dst) + if err != nil { + log.Fatal(err) + } + for i, v := range dst { + println(i, v.Name) + } + } + +*/ +package wmi + +import ( + "bytes" + "errors" + "fmt" + "log" + "os" + "reflect" + "runtime" + "strconv" + "strings" + "sync" + "time" + + "github.com/go-ole/go-ole" + "github.com/go-ole/go-ole/oleutil" +) + +var l = log.New(os.Stdout, "", log.LstdFlags) + +var ( + ErrInvalidEntityType = errors.New("wmi: invalid entity type") + lock sync.Mutex +) + +// QueryNamespace invokes Query with the given namespace on the local machine. +func QueryNamespace(query string, dst interface{}, namespace string) error { + return Query(query, dst, nil, namespace) +} + +// Query runs the WQL query and appends the values to dst. +// +// dst must have type *[]S or *[]*S, for some struct type S. Fields selected in +// the query must have the same name in dst. Supported types are all signed and +// unsigned integers, time.Time, string, bool, or a pointer to one of those. +// Array types are not supported. +// +// By default, the local machine and default namespace are used. These can be +// changed using connectServerArgs. See +// http://msdn.microsoft.com/en-us/library/aa393720.aspx for details. +// +// Query is a wrapper around DefaultClient.Query. +func Query(query string, dst interface{}, connectServerArgs ...interface{}) error { + return DefaultClient.Query(query, dst, connectServerArgs...) +} + +// A Client is an WMI query client. +// +// Its zero value (DefaultClient) is a usable client. +type Client struct { + // NonePtrZero specifies if nil values for fields which aren't pointers + // should be returned as the field types zero value. + // + // Setting this to true allows stucts without pointer fields to be used + // without the risk failure should a nil value returned from WMI. + NonePtrZero bool + + // PtrNil specifies if nil values for pointer fields should be returned + // as nil. + // + // Setting this to true will set pointer fields to nil where WMI + // returned nil, otherwise the types zero value will be returned. + PtrNil bool + + // AllowMissingFields specifies that struct fields not present in the + // query result should not result in an error. + // + // Setting this to true allows custom queries to be used with full + // struct definitions instead of having to define multiple structs. + AllowMissingFields bool +} + +// DefaultClient is the default Client and is used by Query, QueryNamespace +var DefaultClient = &Client{} + +// Query runs the WQL query and appends the values to dst. +// +// dst must have type *[]S or *[]*S, for some struct type S. Fields selected in +// the query must have the same name in dst. Supported types are all signed and +// unsigned integers, time.Time, string, bool, or a pointer to one of those. +// Array types are not supported. +// +// By default, the local machine and default namespace are used. These can be +// changed using connectServerArgs. See +// http://msdn.microsoft.com/en-us/library/aa393720.aspx for details. +func (c *Client) Query(query string, dst interface{}, connectServerArgs ...interface{}) error { + dv := reflect.ValueOf(dst) + if dv.Kind() != reflect.Ptr || dv.IsNil() { + return ErrInvalidEntityType + } + dv = dv.Elem() + mat, elemType := checkMultiArg(dv) + if mat == multiArgTypeInvalid { + return ErrInvalidEntityType + } + + lock.Lock() + defer lock.Unlock() + runtime.LockOSThread() + defer runtime.UnlockOSThread() + + err := ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED) + if err != nil { + oleerr := err.(*ole.OleError) + // S_FALSE = 0x00000001 // CoInitializeEx was already called on this thread + if oleerr.Code() != ole.S_OK && oleerr.Code() != 0x00000001 { + return err + } + } else { + // Only invoke CoUninitialize if the thread was not initizlied before. + // This will allow other go packages based on go-ole play along + // with this library. + defer ole.CoUninitialize() + } + + unknown, err := oleutil.CreateObject("WbemScripting.SWbemLocator") + if err != nil { + return err + } + defer unknown.Release() + + wmi, err := unknown.QueryInterface(ole.IID_IDispatch) + if err != nil { + return err + } + defer wmi.Release() + + // service is a SWbemServices + serviceRaw, err := oleutil.CallMethod(wmi, "ConnectServer", connectServerArgs...) + if err != nil { + return err + } + service := serviceRaw.ToIDispatch() + defer serviceRaw.Clear() + + // result is a SWBemObjectSet + resultRaw, err := oleutil.CallMethod(service, "ExecQuery", query) + if err != nil { + return err + } + result := resultRaw.ToIDispatch() + defer resultRaw.Clear() + + count, err := oleInt64(result, "Count") + if err != nil { + return err + } + + // Initialize a slice with Count capacity + dv.Set(reflect.MakeSlice(dv.Type(), 0, int(count))) + + var errFieldMismatch error + for i := int64(0); i < count; i++ { + err := func() error { + // item is a SWbemObject, but really a Win32_Process + itemRaw, err := oleutil.CallMethod(result, "ItemIndex", i) + if err != nil { + return err + } + item := itemRaw.ToIDispatch() + defer itemRaw.Clear() + + ev := reflect.New(elemType) + if err = c.loadEntity(ev.Interface(), item); err != nil { + if _, ok := err.(*ErrFieldMismatch); ok { + // We continue loading entities even in the face of field mismatch errors. + // If we encounter any other error, that other error is returned. Otherwise, + // an ErrFieldMismatch is returned. + errFieldMismatch = err + } else { + return err + } + } + if mat != multiArgTypeStructPtr { + ev = ev.Elem() + } + dv.Set(reflect.Append(dv, ev)) + return nil + }() + if err != nil { + return err + } + } + return errFieldMismatch +} + +// ErrFieldMismatch is returned when a field is to be loaded into a different +// type than the one it was stored from, or when a field is missing or +// unexported in the destination struct. +// StructType is the type of the struct pointed to by the destination argument. +type ErrFieldMismatch struct { + StructType reflect.Type + FieldName string + Reason string +} + +func (e *ErrFieldMismatch) Error() string { + return fmt.Sprintf("wmi: cannot load field %q into a %q: %s", + e.FieldName, e.StructType, e.Reason) +} + +var timeType = reflect.TypeOf(time.Time{}) + +// loadEntity loads a SWbemObject into a struct pointer. +func (c *Client) loadEntity(dst interface{}, src *ole.IDispatch) (errFieldMismatch error) { + v := reflect.ValueOf(dst).Elem() + for i := 0; i < v.NumField(); i++ { + f := v.Field(i) + of := f + isPtr := f.Kind() == reflect.Ptr + if isPtr { + ptr := reflect.New(f.Type().Elem()) + f.Set(ptr) + f = f.Elem() + } + n := v.Type().Field(i).Name + if !f.CanSet() { + return &ErrFieldMismatch{ + StructType: of.Type(), + FieldName: n, + Reason: "CanSet() is false", + } + } + prop, err := oleutil.GetProperty(src, n) + if err != nil { + if !c.AllowMissingFields { + errFieldMismatch = &ErrFieldMismatch{ + StructType: of.Type(), + FieldName: n, + Reason: "no such struct field", + } + } + continue + } + defer prop.Clear() + + switch val := prop.Value().(type) { + case int8, int16, int32, int64, int: + v := reflect.ValueOf(val).Int() + switch f.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + f.SetInt(v) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + f.SetUint(uint64(v)) + default: + return &ErrFieldMismatch{ + StructType: of.Type(), + FieldName: n, + Reason: "not an integer class", + } + } + case uint8, uint16, uint32, uint64: + v := reflect.ValueOf(val).Uint() + switch f.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + f.SetInt(int64(v)) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + f.SetUint(v) + default: + return &ErrFieldMismatch{ + StructType: of.Type(), + FieldName: n, + Reason: "not an integer class", + } + } + case string: + switch f.Kind() { + case reflect.String: + f.SetString(val) + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + iv, err := strconv.ParseInt(val, 10, 64) + if err != nil { + return err + } + f.SetInt(iv) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + uv, err := strconv.ParseUint(val, 10, 64) + if err != nil { + return err + } + f.SetUint(uv) + case reflect.Struct: + switch f.Type() { + case timeType: + if len(val) == 25 { + mins, err := strconv.Atoi(val[22:]) + if err != nil { + return err + } + val = val[:22] + fmt.Sprintf("%02d%02d", mins/60, mins%60) + } + t, err := time.Parse("20060102150405.000000-0700", val) + if err != nil { + return err + } + f.Set(reflect.ValueOf(t)) + } + } + case bool: + switch f.Kind() { + case reflect.Bool: + f.SetBool(val) + default: + return &ErrFieldMismatch{ + StructType: of.Type(), + FieldName: n, + Reason: "not a bool", + } + } + default: + typeof := reflect.TypeOf(val) + if typeof == nil && (isPtr || c.NonePtrZero) { + if (isPtr && c.PtrNil) || (!isPtr && c.NonePtrZero) { + of.Set(reflect.Zero(of.Type())) + } + break + } + return &ErrFieldMismatch{ + StructType: of.Type(), + FieldName: n, + Reason: fmt.Sprintf("unsupported type (%T)", val), + } + } + } + return errFieldMismatch +} + +type multiArgType int + +const ( + multiArgTypeInvalid multiArgType = iota + multiArgTypeStruct + multiArgTypeStructPtr +) + +// checkMultiArg checks that v has type []S, []*S for some struct type S. +// +// It returns what category the slice's elements are, and the reflect.Type +// that represents S. +func checkMultiArg(v reflect.Value) (m multiArgType, elemType reflect.Type) { + if v.Kind() != reflect.Slice { + return multiArgTypeInvalid, nil + } + elemType = v.Type().Elem() + switch elemType.Kind() { + case reflect.Struct: + return multiArgTypeStruct, elemType + case reflect.Ptr: + elemType = elemType.Elem() + if elemType.Kind() == reflect.Struct { + return multiArgTypeStructPtr, elemType + } + } + return multiArgTypeInvalid, nil +} + +func oleInt64(item *ole.IDispatch, prop string) (int64, error) { + v, err := oleutil.GetProperty(item, prop) + if err != nil { + return 0, err + } + defer v.Clear() + + i := int64(v.Val) + return i, nil +} + +// CreateQuery returns a WQL query string that queries all columns of src. where +// is an optional string that is appended to the query, to be used with WHERE +// clauses. In such a case, the "WHERE" string should appear at the beginning. +func CreateQuery(src interface{}, where string) string { + var b bytes.Buffer + b.WriteString("SELECT ") + s := reflect.Indirect(reflect.ValueOf(src)) + t := s.Type() + if s.Kind() == reflect.Slice { + t = t.Elem() + } + if t.Kind() != reflect.Struct { + return "" + } + var fields []string + for i := 0; i < t.NumField(); i++ { + fields = append(fields, t.Field(i).Name) + } + b.WriteString(strings.Join(fields, ", ")) + b.WriteString(" FROM ") + b.WriteString(t.Name()) + b.WriteString(" " + where) + return b.String() +} diff --git a/vendor/github.com/appc/docker2aci/LICENSE b/vendor/github.com/appc/docker2aci/LICENSE new file mode 100644 index 0000000000..e06d208186 --- /dev/null +++ b/vendor/github.com/appc/docker2aci/LICENSE @@ -0,0 +1,202 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor 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, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/vendor/github.com/appc/docker2aci/lib/common/common.go b/vendor/github.com/appc/docker2aci/lib/common/common.go new file mode 100644 index 0000000000..5fd1d46050 --- /dev/null +++ b/vendor/github.com/appc/docker2aci/lib/common/common.go @@ -0,0 +1,62 @@ +// Copyright 2016 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package common provides misc types and variables. +package common + +import ( + "github.com/appc/docker2aci/lib/internal/docker" + "github.com/appc/docker2aci/lib/internal/types" +) + +type Compression int + +const ( + NoCompression = iota + GzipCompression +) + +type ParsedDockerURL types.ParsedDockerURL + +const ( + AppcDockerRegistryURL = "appc.io/docker/registryurl" + AppcDockerRepository = "appc.io/docker/repository" + AppcDockerTag = "appc.io/docker/tag" + AppcDockerImageID = "appc.io/docker/imageid" + AppcDockerParentImageID = "appc.io/docker/parentimageid" + AppcDockerEntrypoint = "appc.io/docker/entrypoint" + AppcDockerCmd = "appc.io/docker/cmd" +) + +type ErrSeveralImages struct { + Msg string + Images []string +} + +// InsecureConfig represents the different insecure options available +type InsecureConfig struct { + SkipVerify bool + AllowHTTP bool +} + +func (e *ErrSeveralImages) Error() string { + return e.Msg +} + +// ParseDockerURL takes a Docker URL and returns a ParsedDockerURL with its +// index URL, image name, and tag. +func ParseDockerURL(arg string) (*ParsedDockerURL, error) { + p, err := docker.ParseDockerURL(arg) + return (*ParsedDockerURL)(p), err +} diff --git a/vendor/github.com/appc/docker2aci/lib/conversion_store.go b/vendor/github.com/appc/docker2aci/lib/conversion_store.go new file mode 100644 index 0000000000..4944f1386a --- /dev/null +++ b/vendor/github.com/appc/docker2aci/lib/conversion_store.go @@ -0,0 +1,126 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package docker2aci + +import ( + "crypto/sha512" + "fmt" + "hash" + "io" + "io/ioutil" + "os" + + "github.com/appc/spec/aci" + "github.com/appc/spec/schema" + "github.com/appc/spec/schema/types" +) + +const ( + hashPrefix = "sha512-" +) + +type aciInfo struct { + path string + key string + ImageManifest *schema.ImageManifest +} + +// conversionStore is an simple implementation of the acirenderer.ACIRegistry +// interface. It stores the Docker layers converted to ACI so we can take +// advantage of acirenderer to generate a squashed ACI Image. +type conversionStore struct { + acis map[string]*aciInfo +} + +func newConversionStore() *conversionStore { + return &conversionStore{acis: make(map[string]*aciInfo)} +} + +func (ms *conversionStore) WriteACI(path string) (string, error) { + f, err := os.Open(path) + if err != nil { + return "", err + } + defer f.Close() + + cr, err := aci.NewCompressedReader(f) + if err != nil { + return "", err + } + defer cr.Close() + + h := sha512.New() + r := io.TeeReader(cr, h) + + // read the file so we can get the hash + if _, err := io.Copy(ioutil.Discard, r); err != nil { + return "", fmt.Errorf("error reading ACI: %v", err) + } + + im, err := aci.ManifestFromImage(f) + if err != nil { + return "", err + } + + key := ms.HashToKey(h) + ms.acis[key] = &aciInfo{path: path, key: key, ImageManifest: im} + return key, nil +} + +func (ms *conversionStore) GetImageManifest(key string) (*schema.ImageManifest, error) { + aci, ok := ms.acis[key] + if !ok { + return nil, fmt.Errorf("aci with key: %s not found", key) + } + return aci.ImageManifest, nil +} + +func (ms *conversionStore) GetACI(name types.ACIdentifier, labels types.Labels) (string, error) { + for _, aci := range ms.acis { + // we implement this function to comply with the interface so don't + // bother implementing a proper label check + if aci.ImageManifest.Name.String() == name.String() { + return aci.key, nil + } + } + return "", fmt.Errorf("aci not found") +} + +func (ms *conversionStore) ReadStream(key string) (io.ReadCloser, error) { + img, ok := ms.acis[key] + if !ok { + return nil, fmt.Errorf("stream for key: %s not found", key) + } + f, err := os.Open(img.path) + if err != nil { + return nil, fmt.Errorf("error opening aci: %s", img.path) + } + + tr, err := aci.NewCompressedReader(f) + if err != nil { + return nil, err + } + + return tr, nil +} + +func (ms *conversionStore) ResolveKey(key string) (string, error) { + return key, nil +} + +func (ms *conversionStore) HashToKey(h hash.Hash) string { + s := h.Sum(nil) + return fmt.Sprintf("%s%x", hashPrefix, s) +} diff --git a/vendor/github.com/appc/docker2aci/lib/docker2aci.go b/vendor/github.com/appc/docker2aci/lib/docker2aci.go new file mode 100644 index 0000000000..4cb0ecc9aa --- /dev/null +++ b/vendor/github.com/appc/docker2aci/lib/docker2aci.go @@ -0,0 +1,417 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package docker2aci implements a simple library for converting docker images to +// App Container Images (ACIs). +package docker2aci + +import ( + "archive/tar" + "fmt" + "io" + "io/ioutil" + "os" + "path/filepath" + "strings" + + "github.com/appc/docker2aci/lib/common" + "github.com/appc/docker2aci/lib/internal" + "github.com/appc/docker2aci/lib/internal/backend/file" + "github.com/appc/docker2aci/lib/internal/backend/repository" + "github.com/appc/docker2aci/lib/internal/docker" + "github.com/appc/docker2aci/lib/internal/tarball" + "github.com/appc/docker2aci/lib/internal/types" + "github.com/appc/docker2aci/lib/internal/util" + "github.com/appc/docker2aci/pkg/log" + "github.com/appc/spec/pkg/acirenderer" + "github.com/appc/spec/schema" + appctypes "github.com/appc/spec/schema/types" + gzip "github.com/klauspost/pgzip" +) + +// CommonConfig represents the shared configuration options for converting +// Docker images. +type CommonConfig struct { + Squash bool // squash the layers in one file + OutputDir string // where to put the resulting ACI + TmpDir string // directory to use for temporary files + Compression common.Compression // which compression to use for the resulting file(s) +} + +// RemoteConfig represents the remote repository specific configuration for +// converting Docker images. +type RemoteConfig struct { + CommonConfig + Username string // username to use if the image to convert needs authentication + Password string // password to use if the image to convert needs authentication + Insecure common.InsecureConfig // Insecure options +} + +// FileConfig represents the saved file specific configuration for converting +// Docker images. +type FileConfig struct { + CommonConfig + DockerURL string // select an image if there are several images/tags in the file, Syntax: "{docker registry URL}/{image name}:{tag}" +} + +// ConvertRemoteRepo generates ACI images from docker registry URLs. It takes +// as input a dockerURL of the form: +// +// {registry URL}/{repository}:{reference[tag|digest]} +// +// It then gets all the layers of the requested image and converts each of +// them to ACI. +// It returns the list of generated ACI paths. +func ConvertRemoteRepo(dockerURL string, config RemoteConfig) ([]string, error) { + repositoryBackend := repository.NewRepositoryBackend(config.Username, config.Password, config.Insecure) + return convertReal(repositoryBackend, dockerURL, config.Squash, config.OutputDir, config.TmpDir, config.Compression) +} + +// ConvertSavedFile generates ACI images from a file generated with "docker +// save". If there are several images/tags in the file, a particular image can +// be chosen via FileConfig.DockerURL. +// +// It returns the list of generated ACI paths. +func ConvertSavedFile(dockerSavedFile string, config FileConfig) ([]string, error) { + f, err := os.Open(dockerSavedFile) + if err != nil { + return nil, fmt.Errorf("error opening file: %v", err) + } + defer f.Close() + + fileBackend := file.NewFileBackend(f) + return convertReal(fileBackend, config.DockerURL, config.Squash, config.OutputDir, config.TmpDir, config.Compression) +} + +// GetIndexName returns the docker index server from a docker URL. +func GetIndexName(dockerURL string) string { + index, _ := docker.SplitReposName(dockerURL) + return index +} + +// GetDockercfgAuth reads a ~/.dockercfg file and returns the username and password +// of the given docker index server. +func GetDockercfgAuth(indexServer string) (string, string, error) { + return docker.GetAuthInfo(indexServer) +} + +func convertReal(backend internal.Docker2ACIBackend, dockerURL string, squash bool, outputDir string, tmpDir string, compression common.Compression) ([]string, error) { + log.Debug("Getting image info...") + ancestry, parsedDockerURL, err := backend.GetImageInfo(dockerURL) + if err != nil { + return nil, err + } + + layersOutputDir := outputDir + if squash { + layersOutputDir, err = ioutil.TempDir(tmpDir, "docker2aci-") + if err != nil { + return nil, fmt.Errorf("error creating dir: %v", err) + } + defer os.RemoveAll(layersOutputDir) + } + + conversionStore := newConversionStore() + + // only compress individual layers if we're not squashing + layerCompression := compression + if squash { + layerCompression = common.NoCompression + } + + aciLayerPaths, aciManifests, err := backend.BuildACI(ancestry, parsedDockerURL, layersOutputDir, tmpDir, layerCompression) + if err != nil { + return nil, err + } + + var images acirenderer.Images + for i, aciLayerPath := range aciLayerPaths { + key, err := conversionStore.WriteACI(aciLayerPath) + if err != nil { + return nil, fmt.Errorf("error inserting in the conversion store: %v", err) + } + + images = append(images, acirenderer.Image{Im: aciManifests[i], Key: key, Level: uint16(len(aciLayerPaths) - 1 - i)}) + } + + // acirenderer expects images in order from upper to base layer + images = util.ReverseImages(images) + if squash { + squashedImagePath, err := squashLayers(images, conversionStore, *parsedDockerURL, outputDir, compression) + if err != nil { + return nil, fmt.Errorf("error squashing image: %v", err) + } + aciLayerPaths = []string{squashedImagePath} + } + + return aciLayerPaths, nil +} + +// squashLayers receives a list of ACI layer file names ordered from base image +// to application image and squashes them into one ACI +func squashLayers(images []acirenderer.Image, aciRegistry acirenderer.ACIRegistry, parsedDockerURL types.ParsedDockerURL, outputDir string, compression common.Compression) (path string, err error) { + log.Debug("Squashing layers...") + log.Debug("Rendering ACI...") + renderedACI, err := acirenderer.GetRenderedACIFromList(images, aciRegistry) + if err != nil { + return "", fmt.Errorf("error rendering squashed image: %v", err) + } + manifests, err := getManifests(renderedACI, aciRegistry) + if err != nil { + return "", fmt.Errorf("error getting manifests: %v", err) + } + + squashedFilename := getSquashedFilename(parsedDockerURL) + squashedImagePath := filepath.Join(outputDir, squashedFilename) + + squashedTempFile, err := ioutil.TempFile(outputDir, "docker2aci-squashedFile-") + if err != nil { + return "", err + } + defer func() { + if err == nil { + err = squashedTempFile.Close() + } else { + // remove temp file on error + // we ignore its error to not mask the real error + os.Remove(squashedTempFile.Name()) + } + }() + + log.Debug("Writing squashed ACI...") + if err := writeSquashedImage(squashedTempFile, renderedACI, aciRegistry, manifests, compression); err != nil { + return "", fmt.Errorf("error writing squashed image: %v", err) + } + + log.Debug("Validating squashed ACI...") + if err := internal.ValidateACI(squashedTempFile.Name()); err != nil { + return "", fmt.Errorf("error validating image: %v", err) + } + + if err := os.Rename(squashedTempFile.Name(), squashedImagePath); err != nil { + return "", err + } + + log.Debug("ACI squashed!") + return squashedImagePath, nil +} + +func getSquashedFilename(parsedDockerURL types.ParsedDockerURL) string { + squashedFilename := strings.Replace(parsedDockerURL.ImageName, "/", "-", -1) + if parsedDockerURL.Tag != "" { + squashedFilename += "-" + parsedDockerURL.Tag + } + squashedFilename += ".aci" + + return squashedFilename +} + +func getManifests(renderedACI acirenderer.RenderedACI, aciRegistry acirenderer.ACIRegistry) ([]schema.ImageManifest, error) { + var manifests []schema.ImageManifest + + for _, aci := range renderedACI { + im, err := aciRegistry.GetImageManifest(aci.Key) + if err != nil { + return nil, err + } + manifests = append(manifests, *im) + } + + return manifests, nil +} + +func writeSquashedImage(outputFile *os.File, renderedACI acirenderer.RenderedACI, aciProvider acirenderer.ACIProvider, manifests []schema.ImageManifest, compression common.Compression) error { + var tarWriterTarget io.WriteCloser = outputFile + + switch compression { + case common.NoCompression: + case common.GzipCompression: + tarWriterTarget = gzip.NewWriter(outputFile) + defer tarWriterTarget.Close() + default: + return fmt.Errorf("unexpected compression enum value: %d", compression) + } + + outputWriter := tar.NewWriter(tarWriterTarget) + defer outputWriter.Close() + + finalManifest := mergeManifests(manifests) + + if err := internal.WriteManifest(outputWriter, finalManifest); err != nil { + return err + } + + if err := internal.WriteRootfsDir(outputWriter); err != nil { + return err + } + + type hardLinkEntry struct { + firstLinkCleanName string + firstLinkHeader tar.Header + keepOriginal bool + walked bool + } + // map aciFileKey -> cleanTarget -> hardLinkEntry + hardLinks := make(map[string]map[string]hardLinkEntry) + + // first pass: read all the entries and build the hardLinks map in memory + // but don't write on disk + for _, aciFile := range renderedACI { + rs, err := aciProvider.ReadStream(aciFile.Key) + if err != nil { + return err + } + defer rs.Close() + + hardLinks[aciFile.Key] = map[string]hardLinkEntry{} + + squashWalker := func(t *tarball.TarFile) error { + cleanName := filepath.Clean(t.Name()) + // the rootfs and the squashed manifest are added separately + if cleanName == "manifest" || cleanName == "rootfs" { + return nil + } + _, keep := aciFile.FileMap[cleanName] + if keep && t.Header.Typeflag == tar.TypeLink { + cleanTarget := filepath.Clean(t.Linkname()) + if _, ok := hardLinks[aciFile.Key][cleanTarget]; !ok { + _, keepOriginal := aciFile.FileMap[cleanTarget] + hardLinks[aciFile.Key][cleanTarget] = hardLinkEntry{cleanName, *t.Header, keepOriginal, false} + } + } + return nil + } + + tr := tar.NewReader(rs) + if err := tarball.Walk(*tr, squashWalker); err != nil { + return err + } + } + + // second pass: write on disk + for _, aciFile := range renderedACI { + rs, err := aciProvider.ReadStream(aciFile.Key) + if err != nil { + return err + } + defer rs.Close() + + squashWalker := func(t *tarball.TarFile) error { + cleanName := filepath.Clean(t.Name()) + // the rootfs and the squashed manifest are added separately + if cleanName == "manifest" || cleanName == "rootfs" { + return nil + } + _, keep := aciFile.FileMap[cleanName] + + if link, ok := hardLinks[aciFile.Key][cleanName]; ok { + if keep != link.keepOriginal { + return fmt.Errorf("logic error: should we keep file %q?", cleanName) + } + if keep { + if err := outputWriter.WriteHeader(t.Header); err != nil { + return fmt.Errorf("error writing header: %v", err) + } + if _, err := io.Copy(outputWriter, t.TarStream); err != nil { + return fmt.Errorf("error copying file into the tar out: %v", err) + } + } else { + // The current file does not remain but there is a hard link pointing to + // it. Write the current file but with the filename of the first hard link + // pointing to it. That first hard link will not be written later, see + // variable "alreadyWritten". + link.firstLinkHeader.Size = t.Header.Size + link.firstLinkHeader.Typeflag = t.Header.Typeflag + link.firstLinkHeader.Linkname = "" + + if err := outputWriter.WriteHeader(&link.firstLinkHeader); err != nil { + return fmt.Errorf("error writing header: %v", err) + } + if _, err := io.Copy(outputWriter, t.TarStream); err != nil { + return fmt.Errorf("error copying file into the tar out: %v", err) + } + } + } else if keep { + alreadyWritten := false + if t.Header.Typeflag == tar.TypeLink { + cleanTarget := filepath.Clean(t.Linkname()) + if link, ok := hardLinks[aciFile.Key][cleanTarget]; ok { + if !link.keepOriginal { + if link.walked { + t.Header.Linkname = link.firstLinkCleanName + } else { + alreadyWritten = true + } + } + link.walked = true + hardLinks[aciFile.Key][cleanTarget] = link + } + } + + if !alreadyWritten { + if err := outputWriter.WriteHeader(t.Header); err != nil { + return fmt.Errorf("error writing header: %v", err) + } + if _, err := io.Copy(outputWriter, t.TarStream); err != nil { + return fmt.Errorf("error copying file into the tar out: %v", err) + } + } + } + return nil + } + + tr := tar.NewReader(rs) + if err := tarball.Walk(*tr, squashWalker); err != nil { + return err + } + } + + return nil +} + +func mergeManifests(manifests []schema.ImageManifest) schema.ImageManifest { + // FIXME(iaguis) we take app layer's manifest as the final manifest for now + manifest := manifests[0] + + manifest.Dependencies = nil + + layerIndex := -1 + for i, l := range manifest.Labels { + if l.Name.String() == "layer" { + layerIndex = i + } + } + + if layerIndex != -1 { + manifest.Labels = append(manifest.Labels[:layerIndex], manifest.Labels[layerIndex+1:]...) + } + + nameWithoutLayerID := appctypes.MustACIdentifier(stripLayerID(manifest.Name.String())) + + manifest.Name = *nameWithoutLayerID + + // once the image is squashed, we don't need a pathWhitelist + manifest.PathWhitelist = nil + + return manifest +} + +// striplayerID strips the layer ID from an app name: +// +// myregistry.com/organization/app-name-85738f8f9a7f1b04b5329c590ebcb9e425925c6d0984089c43a022de4f19c281 +// myregistry.com/organization/app-name +func stripLayerID(layerName string) string { + n := strings.LastIndex(layerName, "-") + return layerName[:n] +} diff --git a/vendor/github.com/appc/docker2aci/lib/internal/backend/file/file.go b/vendor/github.com/appc/docker2aci/lib/internal/backend/file/file.go new file mode 100644 index 0000000000..a83402dfcd --- /dev/null +++ b/vendor/github.com/appc/docker2aci/lib/internal/backend/file/file.go @@ -0,0 +1,332 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package file is an implementation of Docker2ACIBackend for files saved via +// "docker save". +// +// Note: this package is an implementation detail and shouldn't be used outside +// of docker2aci. +package file + +import ( + "archive/tar" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "os" + "path" + "path/filepath" + + "github.com/appc/docker2aci/lib/common" + "github.com/appc/docker2aci/lib/internal" + "github.com/appc/docker2aci/lib/internal/docker" + "github.com/appc/docker2aci/lib/internal/tarball" + "github.com/appc/docker2aci/lib/internal/types" + "github.com/appc/docker2aci/pkg/log" + "github.com/appc/spec/schema" +) + +type FileBackend struct { + file *os.File +} + +func NewFileBackend(file *os.File) *FileBackend { + return &FileBackend{ + file: file, + } +} + +func (lb *FileBackend) GetImageInfo(dockerURL string) ([]string, *types.ParsedDockerURL, error) { + parsedDockerURL, err := docker.ParseDockerURL(dockerURL) + if err != nil { + // a missing Docker URL could mean that the file only contains one + // image, so we ignore the error here, we'll handle it in getImageID + } + + appImageID, parsedDockerURL, err := getImageID(lb.file, parsedDockerURL) + if err != nil { + return nil, nil, err + } + + ancestry, err := getAncestry(lb.file, appImageID) + if err != nil { + return nil, nil, fmt.Errorf("error getting ancestry: %v", err) + } + + return ancestry, parsedDockerURL, nil +} + +func (lb *FileBackend) BuildACI(layerIDs []string, dockerURL *types.ParsedDockerURL, outputDir string, tmpBaseDir string, compression common.Compression) ([]string, []*schema.ImageManifest, error) { + var aciLayerPaths []string + var aciManifests []*schema.ImageManifest + var curPwl []string + for i := len(layerIDs) - 1; i >= 0; i-- { + tmpDir, err := ioutil.TempDir(tmpBaseDir, "docker2aci-") + if err != nil { + return nil, nil, fmt.Errorf("error creating dir: %v", err) + } + defer os.RemoveAll(tmpDir) + + j, err := getJson(lb.file, layerIDs[i]) + if err != nil { + return nil, nil, fmt.Errorf("error getting image json: %v", err) + } + + layerData := types.DockerImageData{} + if err := json.Unmarshal(j, &layerData); err != nil { + return nil, nil, fmt.Errorf("error unmarshaling layer data: %v", err) + } + + tmpLayerPath := path.Join(tmpDir, layerIDs[i]) + tmpLayerPath += ".tar" + + layerFile, err := extractEmbeddedLayer(lb.file, layerIDs[i], tmpLayerPath) + if err != nil { + return nil, nil, fmt.Errorf("error getting layer from file: %v", err) + } + defer layerFile.Close() + + log.Debug("Generating layer ACI...") + aciPath, manifest, err := internal.GenerateACI(i, layerData, dockerURL, outputDir, layerFile, curPwl, compression) + if err != nil { + return nil, nil, fmt.Errorf("error generating ACI: %v", err) + } + + aciLayerPaths = append(aciLayerPaths, aciPath) + aciManifests = append(aciManifests, manifest) + curPwl = manifest.PathWhitelist + } + + return aciLayerPaths, aciManifests, nil +} + +func getImageID(file *os.File, dockerURL *types.ParsedDockerURL) (string, *types.ParsedDockerURL, error) { + type tags map[string]string + type apps map[string]tags + + _, err := file.Seek(0, 0) + if err != nil { + return "", nil, fmt.Errorf("error seeking file: %v", err) + } + + var imageID string + var appName string + reposWalker := func(t *tarball.TarFile) error { + if filepath.Clean(t.Name()) == "repositories" { + repob, err := ioutil.ReadAll(t.TarStream) + if err != nil { + return fmt.Errorf("error reading repositories file: %v", err) + } + + var repositories apps + if err := json.Unmarshal(repob, &repositories); err != nil { + return fmt.Errorf("error unmarshaling repositories file") + } + + if dockerURL == nil { + n := len(repositories) + switch { + case n == 1: + for key, _ := range repositories { + appName = key + } + case n > 1: + var appNames []string + for key, _ := range repositories { + appNames = append(appNames, key) + } + return &common.ErrSeveralImages{ + Msg: "several images found", + Images: appNames, + } + default: + return fmt.Errorf("no images found") + } + } else { + appName = dockerURL.ImageName + } + + tag := "latest" + if dockerURL != nil { + tag = dockerURL.Tag + } + + app, ok := repositories[appName] + if !ok { + return fmt.Errorf("app %q not found", appName) + } + + _, ok = app[tag] + if !ok { + if len(app) == 1 { + for key, _ := range app { + tag = key + } + } else { + return fmt.Errorf("tag %q not found", tag) + } + } + + if dockerURL == nil { + dockerURL = &types.ParsedDockerURL{ + IndexURL: "", + Tag: tag, + ImageName: appName, + } + } + + imageID = string(app[tag]) + } + + return nil + } + + tr := tar.NewReader(file) + if err := tarball.Walk(*tr, reposWalker); err != nil { + return "", nil, err + } + + if imageID == "" { + return "", nil, fmt.Errorf("repositories file not found") + } + + return imageID, dockerURL, nil +} + +func getJson(file *os.File, layerID string) ([]byte, error) { + jsonPath := path.Join(layerID, "json") + return getTarFileBytes(file, jsonPath) +} + +func getTarFileBytes(file *os.File, path string) ([]byte, error) { + _, err := file.Seek(0, 0) + if err != nil { + fmt.Errorf("error seeking file: %v", err) + } + + var fileBytes []byte + fileWalker := func(t *tarball.TarFile) error { + if filepath.Clean(t.Name()) == path { + fileBytes, err = ioutil.ReadAll(t.TarStream) + if err != nil { + return err + } + } + + return nil + } + + tr := tar.NewReader(file) + if err := tarball.Walk(*tr, fileWalker); err != nil { + return nil, err + } + + if fileBytes == nil { + return nil, fmt.Errorf("file %q not found", path) + } + + return fileBytes, nil +} + +func extractEmbeddedLayer(file *os.File, layerID string, outputPath string) (*os.File, error) { + log.Info("Extracting ", layerID[:12], "\n") + + _, err := file.Seek(0, 0) + if err != nil { + fmt.Errorf("error seeking file: %v", err) + } + + layerTarPath := path.Join(layerID, "layer.tar") + + var layerFile *os.File + fileWalker := func(t *tarball.TarFile) error { + if filepath.Clean(t.Name()) == layerTarPath { + layerFile, err = os.Create(outputPath) + if err != nil { + return fmt.Errorf("error creating layer: %v", err) + } + + _, err = io.Copy(layerFile, t.TarStream) + if err != nil { + return fmt.Errorf("error getting layer: %v", err) + } + } + + return nil + } + + tr := tar.NewReader(file) + if err := tarball.Walk(*tr, fileWalker); err != nil { + return nil, err + } + + if layerFile == nil { + return nil, fmt.Errorf("file %q not found", layerTarPath) + } + + return layerFile, nil +} + +func getAncestry(file *os.File, imgID string) ([]string, error) { + var ancestry []string + + curImgID := imgID + + var err error + for curImgID != "" { + ancestry = append(ancestry, curImgID) + curImgID, err = getParent(file, curImgID) + if err != nil { + return nil, err + } + } + + return ancestry, nil +} + +func getParent(file *os.File, imgID string) (string, error) { + var parent string + + _, err := file.Seek(0, 0) + if err != nil { + return "", fmt.Errorf("error seeking file: %v", err) + } + + jsonPath := filepath.Join(imgID, "json") + parentWalker := func(t *tarball.TarFile) error { + if filepath.Clean(t.Name()) == jsonPath { + jsonb, err := ioutil.ReadAll(t.TarStream) + if err != nil { + return fmt.Errorf("error reading layer json: %v", err) + } + + var dockerData types.DockerImageData + if err := json.Unmarshal(jsonb, &dockerData); err != nil { + return fmt.Errorf("error unmarshaling layer data: %v", err) + } + + parent = dockerData.Parent + } + + return nil + } + + tr := tar.NewReader(file) + if err := tarball.Walk(*tr, parentWalker); err != nil { + return "", err + } + + return parent, nil +} diff --git a/vendor/github.com/appc/docker2aci/lib/internal/backend/repository/repository.go b/vendor/github.com/appc/docker2aci/lib/internal/backend/repository/repository.go new file mode 100644 index 0000000000..57533857a1 --- /dev/null +++ b/vendor/github.com/appc/docker2aci/lib/internal/backend/repository/repository.go @@ -0,0 +1,164 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package repository is an implementation of Docker2ACIBackend for Docker +// remote registries. +// +// Note: this package is an implementation detail and shouldn't be used outside +// of docker2aci. +package repository + +import ( + "fmt" + "net/http" + "path" + + "github.com/appc/docker2aci/lib/common" + "github.com/appc/docker2aci/lib/internal/docker" + "github.com/appc/docker2aci/lib/internal/types" + "github.com/appc/docker2aci/lib/internal/util" + "github.com/appc/spec/schema" +) + +type registryVersion int + +const ( + registryV1 registryVersion = iota + registryV2 +) + +type RepositoryBackend struct { + repoData *RepoData + username string + password string + insecure common.InsecureConfig + hostsV2Support map[string]bool + hostsV2AuthTokens map[string]map[string]string + schema string + imageManifests map[types.ParsedDockerURL]v2Manifest +} + +func NewRepositoryBackend(username string, password string, insecure common.InsecureConfig) *RepositoryBackend { + return &RepositoryBackend{ + username: username, + password: password, + insecure: insecure, + hostsV2Support: make(map[string]bool), + hostsV2AuthTokens: make(map[string]map[string]string), + imageManifests: make(map[types.ParsedDockerURL]v2Manifest), + } +} + +func (rb *RepositoryBackend) GetImageInfo(url string) ([]string, *types.ParsedDockerURL, error) { + dockerURL, err := docker.ParseDockerURL(url) + if err != nil { + return nil, nil, err + } + + var supportsV2, ok bool + var URLSchema string + if supportsV2, ok = rb.hostsV2Support[dockerURL.IndexURL]; !ok { + var err error + URLSchema, supportsV2, err = rb.supportsRegistry(dockerURL.IndexURL, registryV2) + if err != nil { + return nil, nil, err + } + rb.schema = URLSchema + "://" + rb.hostsV2Support[dockerURL.IndexURL] = supportsV2 + } + + if supportsV2 { + return rb.getImageInfoV2(dockerURL) + } else { + URLSchema, supportsV1, err := rb.supportsRegistry(dockerURL.IndexURL, registryV1) + if err != nil { + return nil, nil, err + } + if !supportsV1 { + return nil, nil, fmt.Errorf("registry doesn't support API v2 nor v1") + } + rb.schema = URLSchema + "://" + return rb.getImageInfoV1(dockerURL) + } +} + +func (rb *RepositoryBackend) BuildACI(layerIDs []string, dockerURL *types.ParsedDockerURL, outputDir string, tmpBaseDir string, compression common.Compression) ([]string, []*schema.ImageManifest, error) { + if rb.hostsV2Support[dockerURL.IndexURL] { + return rb.buildACIV2(layerIDs, dockerURL, outputDir, tmpBaseDir, compression) + } else { + return rb.buildACIV1(layerIDs, dockerURL, outputDir, tmpBaseDir, compression) + } +} + +func checkRegistryStatus(statusCode int, hdr http.Header, version registryVersion) (bool, error) { + switch statusCode { + case http.StatusOK, http.StatusUnauthorized: + ok := true + if version == registryV2 { + // v2 API requires this check + ok = hdr.Get("Docker-Distribution-API-Version") == "registry/2.0" + } + return ok, nil + case http.StatusNotFound: + return false, nil + } + + return false, fmt.Errorf("unexpected http code: %d", statusCode) +} + +func (rb *RepositoryBackend) supportsRegistry(indexURL string, version registryVersion) (schema string, ok bool, err error) { + var URLPath string + switch version { + case registryV1: + // the v1 API defines this URL to check if the registry's status + URLPath = "v1/_ping" + case registryV2: + URLPath = "v2" + } + URLStr := path.Join(indexURL, URLPath) + + fetch := func(schema string) (res *http.Response, err error) { + url := schema + "://" + URLStr + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return nil, err + } + + rb.setBasicAuth(req) + + client := util.GetTLSClient(rb.insecure.SkipVerify) + res, err = client.Do(req) + return + } + + schema = "https" + res, err := fetch(schema) + if err == nil { + ok, err = checkRegistryStatus(res.StatusCode, res.Header, version) + defer res.Body.Close() + } + if err != nil || !ok { + if rb.insecure.AllowHTTP { + schema = "http" + res, err = fetch(schema) + if err == nil { + ok, err = checkRegistryStatus(res.StatusCode, res.Header, version) + defer res.Body.Close() + } + } + return schema, ok, err + } + + return schema, ok, err +} diff --git a/vendor/github.com/appc/docker2aci/lib/internal/backend/repository/repository1.go b/vendor/github.com/appc/docker2aci/lib/internal/backend/repository/repository1.go new file mode 100644 index 0000000000..bc54e47c7b --- /dev/null +++ b/vendor/github.com/appc/docker2aci/lib/internal/backend/repository/repository1.go @@ -0,0 +1,391 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package repository + +import ( + "encoding/json" + "fmt" + "io" + "io/ioutil" + "net/http" + "os" + "path" + "strconv" + "strings" + "time" + + "github.com/appc/docker2aci/lib/common" + "github.com/appc/docker2aci/lib/internal" + "github.com/appc/docker2aci/lib/internal/types" + "github.com/appc/docker2aci/lib/internal/util" + "github.com/appc/docker2aci/pkg/log" + "github.com/appc/spec/schema" + "github.com/coreos/ioprogress" +) + +type RepoData struct { + Tokens []string + Endpoints []string + Cookie []string +} + +func (rb *RepositoryBackend) getImageInfoV1(dockerURL *types.ParsedDockerURL) ([]string, *types.ParsedDockerURL, error) { + repoData, err := rb.getRepoDataV1(dockerURL.IndexURL, dockerURL.ImageName) + if err != nil { + return nil, nil, fmt.Errorf("error getting repository data: %v", err) + } + + // TODO(iaguis) check more endpoints + appImageID, err := rb.getImageIDFromTagV1(repoData.Endpoints[0], dockerURL.ImageName, dockerURL.Tag, repoData) + if err != nil { + return nil, nil, fmt.Errorf("error getting ImageID from tag %s: %v", dockerURL.Tag, err) + } + + ancestry, err := rb.getAncestryV1(appImageID, repoData.Endpoints[0], repoData) + if err != nil { + return nil, nil, err + } + + rb.repoData = repoData + + return ancestry, dockerURL, nil +} + +func (rb *RepositoryBackend) buildACIV1(layerIDs []string, dockerURL *types.ParsedDockerURL, outputDir string, tmpBaseDir string, compression common.Compression) ([]string, []*schema.ImageManifest, error) { + layerFiles := make([]*os.File, len(layerIDs)) + layerDatas := make([]types.DockerImageData, len(layerIDs)) + + tmpParentDir, err := ioutil.TempDir(tmpBaseDir, "docker2aci-") + if err != nil { + return nil, nil, err + } + defer os.RemoveAll(tmpParentDir) + + var doneChannels []chan error + for i, layerID := range layerIDs { + doneChan := make(chan error) + doneChannels = append(doneChannels, doneChan) + // https://github.com/golang/go/wiki/CommonMistakes + i := i // golang-- + layerID := layerID + go func() { + tmpDir, err := ioutil.TempDir(tmpParentDir, "") + if err != nil { + doneChan <- fmt.Errorf("error creating dir: %v", err) + return + } + + j, size, err := rb.getJsonV1(layerID, rb.repoData.Endpoints[0], rb.repoData) + if err != nil { + doneChan <- fmt.Errorf("error getting image json: %v", err) + return + } + + layerDatas[i] = types.DockerImageData{} + if err := json.Unmarshal(j, &layerDatas[i]); err != nil { + doneChan <- fmt.Errorf("error unmarshaling layer data: %v", err) + return + } + + layerFiles[i], err = rb.getLayerV1(layerID, rb.repoData.Endpoints[0], rb.repoData, size, tmpDir) + if err != nil { + doneChan <- fmt.Errorf("error getting the remote layer: %v", err) + return + } + doneChan <- nil + }() + } + for _, doneChan := range doneChannels { + err := <-doneChan + if err != nil { + return nil, nil, err + } + } + var aciLayerPaths []string + var aciManifests []*schema.ImageManifest + var curPwl []string + + for i := len(layerIDs) - 1; i >= 0; i-- { + log.Debug("Generating layer ACI...") + aciPath, manifest, err := internal.GenerateACI(i, layerDatas[i], dockerURL, outputDir, layerFiles[i], curPwl, compression) + if err != nil { + return nil, nil, fmt.Errorf("error generating ACI: %v", err) + } + aciLayerPaths = append(aciLayerPaths, aciPath) + aciManifests = append(aciManifests, manifest) + curPwl = manifest.PathWhitelist + + layerFiles[i].Close() + } + + return aciLayerPaths, aciManifests, nil +} + +func (rb *RepositoryBackend) getRepoDataV1(indexURL string, remote string) (*RepoData, error) { + client := util.GetTLSClient(rb.insecure.SkipVerify) + repositoryURL := rb.schema + path.Join(indexURL, "v1", "repositories", remote, "images") + + req, err := http.NewRequest("GET", repositoryURL, nil) + if err != nil { + return nil, err + } + + if rb.username != "" && rb.password != "" { + req.SetBasicAuth(rb.username, rb.password) + } + + req.Header.Set("X-Docker-Token", "true") + + res, err := client.Do(req) + if err != nil { + return nil, err + } + defer res.Body.Close() + + if res.StatusCode != 200 { + return nil, fmt.Errorf("HTTP code: %d, URL: %s", res.StatusCode, req.URL) + } + + var tokens []string + if res.Header.Get("X-Docker-Token") != "" { + tokens = res.Header["X-Docker-Token"] + } + + var cookies []string + if res.Header.Get("Set-Cookie") != "" { + cookies = res.Header["Set-Cookie"] + } + + var endpoints []string + if res.Header.Get("X-Docker-Endpoints") != "" { + endpoints = makeEndpointsListV1(res.Header["X-Docker-Endpoints"]) + } else { + // Assume same endpoint + endpoints = append(endpoints, indexURL) + } + + return &RepoData{ + Endpoints: endpoints, + Tokens: tokens, + Cookie: cookies, + }, nil +} + +func (rb *RepositoryBackend) getImageIDFromTagV1(registry string, appName string, tag string, repoData *RepoData) (string, error) { + client := util.GetTLSClient(rb.insecure.SkipVerify) + // we get all the tags instead of directly getting the imageID of the + // requested one (.../tags/TAG) because even though it's specified in the + // Docker API, some registries (e.g. Google Container Registry) don't + // implement it. + req, err := http.NewRequest("GET", rb.schema+path.Join(registry, "repositories", appName, "tags"), nil) + if err != nil { + return "", fmt.Errorf("failed to get Image ID: %s, URL: %s", err, req.URL) + } + + setAuthTokenV1(req, repoData.Tokens) + setCookieV1(req, repoData.Cookie) + res, err := client.Do(req) + if err != nil { + return "", fmt.Errorf("failed to get Image ID: %s, URL: %s", err, req.URL) + } + defer res.Body.Close() + + if res.StatusCode != 200 { + return "", fmt.Errorf("HTTP code: %d. URL: %s", res.StatusCode, req.URL) + } + + j, err := ioutil.ReadAll(res.Body) + + if err != nil { + return "", err + } + + var tags map[string]string + + if err := json.Unmarshal(j, &tags); err != nil { + return "", fmt.Errorf("error unmarshaling: %v", err) + } + + imageID, ok := tags[tag] + if !ok { + return "", fmt.Errorf("tag %s not found", tag) + } + + return imageID, nil +} + +func (rb *RepositoryBackend) getAncestryV1(imgID, registry string, repoData *RepoData) ([]string, error) { + client := util.GetTLSClient(rb.insecure.SkipVerify) + req, err := http.NewRequest("GET", rb.schema+path.Join(registry, "images", imgID, "ancestry"), nil) + if err != nil { + return nil, err + } + + setAuthTokenV1(req, repoData.Tokens) + setCookieV1(req, repoData.Cookie) + res, err := client.Do(req) + if err != nil { + return nil, err + } + defer res.Body.Close() + + if res.StatusCode != 200 { + return nil, fmt.Errorf("HTTP code: %d. URL: %s", res.StatusCode, req.URL) + } + + var ancestry []string + + j, err := ioutil.ReadAll(res.Body) + if err != nil { + return nil, fmt.Errorf("Failed to read downloaded json: %s (%s)", err, j) + } + + if err := json.Unmarshal(j, &ancestry); err != nil { + return nil, fmt.Errorf("error unmarshaling: %v", err) + } + + return ancestry, nil +} + +func (rb *RepositoryBackend) getJsonV1(imgID, registry string, repoData *RepoData) ([]byte, int64, error) { + client := util.GetTLSClient(rb.insecure.SkipVerify) + req, err := http.NewRequest("GET", rb.schema+path.Join(registry, "images", imgID, "json"), nil) + if err != nil { + return nil, -1, err + } + setAuthTokenV1(req, repoData.Tokens) + setCookieV1(req, repoData.Cookie) + res, err := client.Do(req) + if err != nil { + return nil, -1, err + } + defer res.Body.Close() + + if res.StatusCode != 200 { + return nil, -1, fmt.Errorf("HTTP code: %d, URL: %s", res.StatusCode, req.URL) + } + + imageSize := int64(-1) + + if hdr := res.Header.Get("X-Docker-Size"); hdr != "" { + imageSize, err = strconv.ParseInt(hdr, 10, 64) + if err != nil { + return nil, -1, err + } + } + + b, err := ioutil.ReadAll(res.Body) + if err != nil { + return nil, -1, fmt.Errorf("failed to read downloaded json: %v (%s)", err, b) + } + + return b, imageSize, nil +} + +func (rb *RepositoryBackend) getLayerV1(imgID, registry string, repoData *RepoData, imgSize int64, tmpDir string) (*os.File, error) { + client := util.GetTLSClient(rb.insecure.SkipVerify) + req, err := http.NewRequest("GET", rb.schema+path.Join(registry, "images", imgID, "layer"), nil) + if err != nil { + return nil, err + } + + setAuthTokenV1(req, repoData.Tokens) + setCookieV1(req, repoData.Cookie) + + res, err := client.Do(req) + if err != nil { + return nil, err + } + defer res.Body.Close() + + if res.StatusCode != 200 { + res.Body.Close() + return nil, fmt.Errorf("HTTP code: %d. URL: %s", res.StatusCode, req.URL) + } + + // if we didn't receive the size via X-Docker-Size when we retrieved the + // layer's json, try Content-Length + if imgSize == -1 { + if hdr := res.Header.Get("Content-Length"); hdr != "" { + imgSize, err = strconv.ParseInt(hdr, 10, 64) + if err != nil { + return nil, err + } + } + } + + prefix := "Downloading " + imgID[:12] + fmtBytesSize := 18 + barSize := int64(80 - len(prefix) - fmtBytesSize) + bar := ioprogress.DrawTextFormatBarForW(barSize, os.Stderr) + fmtfunc := func(progress, total int64) string { + return fmt.Sprintf( + "%s: %s %s", + prefix, + bar(progress, total), + ioprogress.DrawTextFormatBytes(progress, total), + ) + } + + progressReader := &ioprogress.Reader{ + Reader: res.Body, + Size: imgSize, + DrawFunc: ioprogress.DrawTerminalf(os.Stderr, fmtfunc), + DrawInterval: 500 * time.Millisecond, + } + + layerFile, err := ioutil.TempFile(tmpDir, "dockerlayer-") + if err != nil { + return nil, err + } + + _, err = io.Copy(layerFile, progressReader) + if err != nil { + return nil, err + } + + if err := layerFile.Sync(); err != nil { + return nil, err + } + + return layerFile, nil +} + +func setAuthTokenV1(req *http.Request, token []string) { + if req.Header.Get("Authorization") == "" { + req.Header.Set("Authorization", "Token "+strings.Join(token, ",")) + } +} + +func setCookieV1(req *http.Request, cookie []string) { + if req.Header.Get("Cookie") == "" { + req.Header.Set("Cookie", strings.Join(cookie, "")) + } +} + +func makeEndpointsListV1(headers []string) []string { + var endpoints []string + + for _, ep := range headers { + endpointsList := strings.Split(ep, ",") + for _, endpointEl := range endpointsList { + endpoints = append( + endpoints, + path.Join(strings.TrimSpace(endpointEl), "v1")) + } + } + + return endpoints +} diff --git a/vendor/github.com/appc/docker2aci/lib/internal/backend/repository/repository2.go b/vendor/github.com/appc/docker2aci/lib/internal/backend/repository/repository2.go new file mode 100644 index 0000000000..356d6f9bee --- /dev/null +++ b/vendor/github.com/appc/docker2aci/lib/internal/backend/repository/repository2.go @@ -0,0 +1,466 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package repository + +import ( + "encoding/json" + "errors" + "fmt" + "io" + "io/ioutil" + "net/http" + "os" + "path" + "regexp" + "strconv" + "strings" + "sync" + "time" + + "github.com/appc/docker2aci/lib/common" + "github.com/appc/docker2aci/lib/internal" + "github.com/appc/docker2aci/lib/internal/types" + "github.com/appc/docker2aci/lib/internal/util" + "github.com/appc/docker2aci/pkg/log" + "github.com/appc/spec/schema" + "github.com/coreos/pkg/progressutil" +) + +const ( + defaultIndexURL = "registry-1.docker.io" +) + +var validHex = regexp.MustCompile(`^([a-f0-9]{64})$`) + +type v2Manifest struct { + Name string `json:"name"` + Tag string `json:"tag"` + FSLayers []struct { + BlobSum string `json:"blobSum"` + } `json:"fsLayers"` + History []struct { + V1Compatibility string `json:"v1Compatibility"` + } `json:"history"` + Signature []byte `json:"signature"` +} + +func (rb *RepositoryBackend) getImageInfoV2(dockerURL *types.ParsedDockerURL) ([]string, *types.ParsedDockerURL, error) { + manifest, layers, err := rb.getManifestV2(dockerURL) + if err != nil { + return nil, nil, err + } + + rb.imageManifests[*dockerURL] = *manifest + + return layers, dockerURL, nil +} + +func (rb *RepositoryBackend) buildACIV2(layerIDs []string, dockerURL *types.ParsedDockerURL, outputDir string, tmpBaseDir string, compression common.Compression) ([]string, []*schema.ImageManifest, error) { + layerFiles := make([]*os.File, len(layerIDs)) + layerDatas := make([]types.DockerImageData, len(layerIDs)) + + tmpParentDir, err := ioutil.TempDir(tmpBaseDir, "docker2aci-") + if err != nil { + return nil, nil, err + } + defer os.RemoveAll(tmpParentDir) + + copier := progressutil.NewCopyProgressPrinter() + + var errChannels []chan error + closers := make([]io.ReadCloser, len(layerIDs)) + var wg sync.WaitGroup + for i, layerID := range layerIDs { + wg.Add(1) + errChan := make(chan error, 1) + errChannels = append(errChannels, errChan) + // https://github.com/golang/go/wiki/CommonMistakes + i := i // golang-- + layerID := layerID + go func() { + defer wg.Done() + + manifest := rb.imageManifests[*dockerURL] + + layerIndex, err := getLayerIndex(layerID, manifest) + if err != nil { + errChan <- err + return + } + + if len(manifest.History) <= layerIndex { + errChan <- fmt.Errorf("history not found for layer %s", layerID) + return + } + + layerDatas[i] = types.DockerImageData{} + if err := json.Unmarshal([]byte(manifest.History[layerIndex].V1Compatibility), &layerDatas[i]); err != nil { + errChan <- fmt.Errorf("error unmarshaling layer data: %v", err) + return + } + + tmpDir, err := ioutil.TempDir(tmpParentDir, "") + if err != nil { + errChan <- fmt.Errorf("error creating dir: %v", err) + return + } + + layerFiles[i], closers[i], err = rb.getLayerV2(layerID, dockerURL, tmpDir, copier) + if err != nil { + errChan <- fmt.Errorf("error getting the remote layer: %v", err) + return + } + errChan <- nil + }() + } + // Need to wait for all of the readers to be added to the copier (which happens during rb.getLayerV2) + wg.Wait() + err = copier.PrintAndWait(os.Stderr, 500*time.Millisecond, nil) + if err != nil { + return nil, nil, err + } + for _, closer := range closers { + if closer != nil { + closer.Close() + } + } + for _, errChan := range errChannels { + err := <-errChan + if err != nil { + return nil, nil, err + } + } + for _, layerFile := range layerFiles { + err := layerFile.Sync() + if err != nil { + return nil, nil, err + } + } + var aciLayerPaths []string + var aciManifests []*schema.ImageManifest + var curPwl []string + for i := len(layerIDs) - 1; i >= 0; i-- { + log.Debug("Generating layer ACI...") + aciPath, aciManifest, err := internal.GenerateACI(i, layerDatas[i], dockerURL, outputDir, layerFiles[i], curPwl, compression) + if err != nil { + return nil, nil, fmt.Errorf("error generating ACI: %v", err) + } + aciLayerPaths = append(aciLayerPaths, aciPath) + aciManifests = append(aciManifests, aciManifest) + curPwl = aciManifest.PathWhitelist + + layerFiles[i].Close() + } + + return aciLayerPaths, aciManifests, nil +} + +func (rb *RepositoryBackend) getManifestV2(dockerURL *types.ParsedDockerURL) (*v2Manifest, []string, error) { + url := rb.schema + path.Join(dockerURL.IndexURL, "v2", dockerURL.ImageName, "manifests", dockerURL.Tag) + + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + rb.setBasicAuth(req) + + res, err := rb.makeRequest(req, dockerURL.ImageName) + if err != nil { + return nil, nil, err + } + defer res.Body.Close() + + if res.StatusCode != http.StatusOK { + return nil, nil, fmt.Errorf("unexpected http code: %d, URL: %s", res.StatusCode, req.URL) + } + + manblob, err := ioutil.ReadAll(res.Body) + if err != nil { + return nil, nil, err + } + + manifest := &v2Manifest{} + + err = json.Unmarshal(manblob, manifest) + if err != nil { + return nil, nil, err + } + + if manifest.Name != dockerURL.ImageName { + return nil, nil, fmt.Errorf("name doesn't match what was requested, expected: %s, downloaded: %s", dockerURL.ImageName, manifest.Name) + } + + if manifest.Tag != dockerURL.Tag { + return nil, nil, fmt.Errorf("tag doesn't match what was requested, expected: %s, downloaded: %s", dockerURL.Tag, manifest.Tag) + } + + if err := fixManifestLayers(manifest); err != nil { + return nil, nil, err + } + + //TODO: verify signature here + + layers := make([]string, len(manifest.FSLayers)) + + for i, layer := range manifest.FSLayers { + layers[i] = layer.BlobSum + } + + return manifest, layers, nil +} + +func fixManifestLayers(manifest *v2Manifest) error { + type imageV1 struct { + ID string + Parent string + } + imgs := make([]*imageV1, len(manifest.FSLayers)) + for i := range manifest.FSLayers { + img := &imageV1{} + + if err := json.Unmarshal([]byte(manifest.History[i].V1Compatibility), img); err != nil { + return err + } + + imgs[i] = img + if err := validateV1ID(img.ID); err != nil { + return err + } + } + + if imgs[len(imgs)-1].Parent != "" { + return errors.New("Invalid parent ID in the base layer of the image.") + } + + // check general duplicates to error instead of a deadlock + idmap := make(map[string]struct{}) + + var lastID string + for _, img := range imgs { + // skip IDs that appear after each other, we handle those later + if _, exists := idmap[img.ID]; img.ID != lastID && exists { + return fmt.Errorf("ID %+v appears multiple times in manifest", img.ID) + } + lastID = img.ID + idmap[lastID] = struct{}{} + } + + // backwards loop so that we keep the remaining indexes after removing items + for i := len(imgs) - 2; i >= 0; i-- { + if imgs[i].ID == imgs[i+1].ID { // repeated ID. remove and continue + manifest.FSLayers = append(manifest.FSLayers[:i], manifest.FSLayers[i+1:]...) + manifest.History = append(manifest.History[:i], manifest.History[i+1:]...) + } else if imgs[i].Parent != imgs[i+1].ID { + return fmt.Errorf("Invalid parent ID. Expected %v, got %v.", imgs[i+1].ID, imgs[i].Parent) + } + } + + return nil +} + +func validateV1ID(id string) error { + if ok := validHex.MatchString(id); !ok { + return fmt.Errorf("image ID %q is invalid", id) + } + return nil +} + +func getLayerIndex(layerID string, manifest v2Manifest) (int, error) { + for i, layer := range manifest.FSLayers { + if layer.BlobSum == layerID { + return i, nil + } + } + return -1, fmt.Errorf("layer not found in manifest: %s", layerID) +} + +func (rb *RepositoryBackend) getLayerV2(layerID string, dockerURL *types.ParsedDockerURL, tmpDir string, copier *progressutil.CopyProgressPrinter) (*os.File, io.ReadCloser, error) { + url := rb.schema + path.Join(dockerURL.IndexURL, "v2", dockerURL.ImageName, "blobs", layerID) + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return nil, nil, err + } + + rb.setBasicAuth(req) + + res, err := rb.makeRequest(req, dockerURL.ImageName) + if err != nil { + return nil, nil, err + } + + if res.StatusCode == http.StatusTemporaryRedirect || res.StatusCode == http.StatusFound { + location := res.Header.Get("Location") + if location != "" { + req, err = http.NewRequest("GET", location, nil) + if err != nil { + return nil, nil, err + } + res, err = rb.makeRequest(req, dockerURL.ImageName) + if err != nil { + return nil, nil, err + } + defer res.Body.Close() + } + } + + if res.StatusCode != http.StatusOK { + return nil, nil, fmt.Errorf("HTTP code: %d. URL: %s", res.StatusCode, req.URL) + } + + var in io.Reader + in = res.Body + + var size int64 + + if hdr := res.Header.Get("Content-Length"); hdr != "" { + size, err = strconv.ParseInt(hdr, 10, 64) + if err != nil { + return nil, nil, err + } + } + + name := "Downloading " + layerID[:18] + + layerFile, err := ioutil.TempFile(tmpDir, "dockerlayer-") + if err != nil { + return nil, nil, err + } + + err = copier.AddCopy(in, name, size, layerFile) + if err != nil { + return nil, nil, err + } + + return layerFile, res.Body, nil +} + +func (rb *RepositoryBackend) makeRequest(req *http.Request, repo string) (*http.Response, error) { + setBearerHeader := false + hostAuthTokens, ok := rb.hostsV2AuthTokens[req.URL.Host] + if ok { + authToken, ok := hostAuthTokens[repo] + if ok { + req.Header.Set("Authorization", "Bearer "+authToken) + setBearerHeader = true + } + } + + client := util.GetTLSClient(rb.insecure.SkipVerify) + res, err := client.Do(req) + if err != nil { + return nil, err + } + + if res.StatusCode == http.StatusUnauthorized && setBearerHeader { + return res, err + } + + hdr := res.Header.Get("www-authenticate") + if res.StatusCode != http.StatusUnauthorized || hdr == "" { + return res, err + } + + tokens := strings.Split(hdr, ",") + if len(tokens) != 3 || + !strings.HasPrefix(strings.ToLower(tokens[0]), "bearer realm") { + return res, err + } + res.Body.Close() + + var realm, service, scope string + for _, token := range tokens { + if strings.HasPrefix(strings.ToLower(token), "bearer realm") { + realm = strings.Trim(token[len("bearer realm="):], "\"") + } + if strings.HasPrefix(token, "service") { + service = strings.Trim(token[len("service="):], "\"") + } + if strings.HasPrefix(token, "scope") { + scope = strings.Trim(token[len("scope="):], "\"") + } + } + + if realm == "" { + return nil, fmt.Errorf("missing realm in bearer auth challenge") + } + if service == "" { + return nil, fmt.Errorf("missing service in bearer auth challenge") + } + // The scope can be empty if we're not getting a token for a specific repo + if scope == "" && repo != "" { + // If the scope is empty and it shouldn't be, we can infer it based on the repo + scope = fmt.Sprintf("repository:%s:pull", repo) + } + + authReq, err := http.NewRequest("GET", realm, nil) + if err != nil { + return nil, err + } + + getParams := authReq.URL.Query() + getParams.Add("service", service) + if scope != "" { + getParams.Add("scope", scope) + } + authReq.URL.RawQuery = getParams.Encode() + + rb.setBasicAuth(authReq) + + res, err = client.Do(authReq) + if err != nil { + return nil, err + } + defer res.Body.Close() + + switch res.StatusCode { + case http.StatusUnauthorized: + return nil, fmt.Errorf("unable to retrieve auth token: 401 unauthorized") + case http.StatusOK: + break + default: + return nil, fmt.Errorf("unexpected http code: %d, URL: %s", res.StatusCode, authReq.URL) + } + + tokenBlob, err := ioutil.ReadAll(res.Body) + if err != nil { + return nil, err + } + + tokenStruct := struct { + Token string `json:"token"` + }{} + + err = json.Unmarshal(tokenBlob, &tokenStruct) + if err != nil { + return nil, err + } + + hostAuthTokens, ok = rb.hostsV2AuthTokens[req.URL.Host] + if !ok { + hostAuthTokens = make(map[string]string) + rb.hostsV2AuthTokens[req.URL.Host] = hostAuthTokens + } + + hostAuthTokens[repo] = tokenStruct.Token + + return rb.makeRequest(req, repo) +} + +func (rb *RepositoryBackend) setBasicAuth(req *http.Request) { + if rb.username != "" && rb.password != "" { + req.SetBasicAuth(rb.username, rb.password) + } +} diff --git a/vendor/github.com/appc/docker2aci/lib/internal/docker/docker_functions.go b/vendor/github.com/appc/docker2aci/lib/internal/docker/docker_functions.go new file mode 100644 index 0000000000..70bca8e476 --- /dev/null +++ b/vendor/github.com/appc/docker2aci/lib/internal/docker/docker_functions.go @@ -0,0 +1,161 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package docker + +import ( + "encoding/base64" + "encoding/json" + "fmt" + "io/ioutil" + "os" + "path" + "runtime" + "strings" + + "github.com/appc/docker2aci/lib/internal/types" + + "github.com/docker/distribution/reference" +) + +const ( + dockercfgFileName = "config.json" + dockercfgFileNameOld = ".dockercfg" + defaultIndexURL = "registry-1.docker.io" + defaultIndexURLAuth = "https://index.docker.io/v1/" + defaultTag = "latest" + defaultRepoPrefix = "library/" +) + +// SplitReposName breaks a repo name into an index name and remote name. +func SplitReposName(name string) (indexName, remoteName string) { + i := strings.IndexRune(name, '/') + if i == -1 || (!strings.ContainsAny(name[:i], ".:") && name[:i] != "localhost") { + indexName, remoteName = defaultIndexURL, name + } else { + indexName, remoteName = name[:i], name[i+1:] + } + if indexName == defaultIndexURL && !strings.ContainsRune(remoteName, '/') { + remoteName = defaultRepoPrefix + remoteName + } + return +} + +// Get a repos name and returns the right reposName + tag +// The tag can be confusing because of a port in a repository name. +// Ex: localhost.localdomain:5000/samalba/hipache:latest +func parseRepositoryTag(repos string) (string, string) { + n := strings.LastIndex(repos, ":") + if n < 0 { + return repos, "" + } + if tag := repos[n+1:]; !strings.Contains(tag, "/") { + return repos[:n], tag + } + return repos, "" +} + +func decodeDockerAuth(s string) (string, string, error) { + decoded, err := base64.StdEncoding.DecodeString(s) + if err != nil { + return "", "", err + } + parts := strings.SplitN(string(decoded), ":", 2) + if len(parts) != 2 { + return "", "", fmt.Errorf("invalid auth configuration file") + } + user := parts[0] + password := strings.Trim(parts[1], "\x00") + return user, password, nil +} + +func getHomeDir() string { + if runtime.GOOS == "windows" { + return os.Getenv("USERPROFILE") + } + return os.Getenv("HOME") +} + +// GetDockercfgAuth reads a ~/.dockercfg file and returns the username and password +// of the given docker index server. +func GetAuthInfo(indexServer string) (string, string, error) { + // official docker registry + if indexServer == defaultIndexURL { + indexServer = defaultIndexURLAuth + } + dockerCfgPath := path.Join(getHomeDir(), ".docker", dockercfgFileName) + if _, err := os.Stat(dockerCfgPath); err == nil { + j, err := ioutil.ReadFile(dockerCfgPath) + if err != nil { + return "", "", err + } + var dockerAuth types.DockerConfigFile + if err := json.Unmarshal(j, &dockerAuth); err != nil { + return "", "", err + } + // try the normal case + if c, ok := dockerAuth.AuthConfigs[indexServer]; ok { + return decodeDockerAuth(c.Auth) + } + } else if os.IsNotExist(err) { + oldDockerCfgPath := path.Join(getHomeDir(), dockercfgFileNameOld) + if _, err := os.Stat(oldDockerCfgPath); err != nil { + return "", "", nil //missing file is not an error + } + j, err := ioutil.ReadFile(oldDockerCfgPath) + if err != nil { + return "", "", err + } + var dockerAuthOld map[string]types.DockerAuthConfigOld + if err := json.Unmarshal(j, &dockerAuthOld); err != nil { + return "", "", err + } + if c, ok := dockerAuthOld[indexServer]; ok { + return decodeDockerAuth(c.Auth) + } + } else { + // if file is there but we can't stat it for any reason other + // than it doesn't exist then stop + return "", "", fmt.Errorf("%s - %v", dockerCfgPath, err) + } + return "", "", nil +} + +// ParseDockerURL takes a Docker URL and returns a ParsedDockerURL with its +// index URL, image name, and tag. +func ParseDockerURL(arg string) (*types.ParsedDockerURL, error) { + r, err := reference.ParseNamed(arg) + if err != nil { + return nil, err + } + + tag := defaultTag + var digest string + switch x := r.(type) { + case reference.Canonical: + digest = x.Digest().String() + case reference.NamedTagged: + tag = x.Tag() + } + + indexURL, remoteName := SplitReposName(r.Name()) + + p := &types.ParsedDockerURL{ + IndexURL: indexURL, + ImageName: remoteName, + Tag: tag, + Digest: digest, + } + return p, nil +} diff --git a/vendor/github.com/appc/docker2aci/lib/internal/internal.go b/vendor/github.com/appc/docker2aci/lib/internal/internal.go new file mode 100644 index 0000000000..29cd8c87e4 --- /dev/null +++ b/vendor/github.com/appc/docker2aci/lib/internal/internal.go @@ -0,0 +1,591 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package internal provides functions shared by different parts of docker2aci. +// +// Note: this package is an implementation detail and shouldn't be used outside +// of docker2aci. +package internal + +import ( + "archive/tar" + "encoding/json" + "fmt" + "io" + "os" + "path" + "path/filepath" + "sort" + "strconv" + "strings" + "time" + + "github.com/appc/docker2aci/lib/common" + "github.com/appc/docker2aci/lib/internal/tarball" + "github.com/appc/docker2aci/lib/internal/types" + "github.com/appc/docker2aci/lib/internal/util" + "github.com/appc/docker2aci/pkg/log" + "github.com/appc/spec/aci" + "github.com/appc/spec/schema" + appctypes "github.com/appc/spec/schema/types" + gzip "github.com/klauspost/pgzip" +) + +// Docker2ACIBackend is the interface that abstracts converting Docker layers +// to ACI from where they're stored (remote or file). +// +// GetImageInfo takes a Docker URL and returns a list of layers and the parsed +// Docker URL. +// +// BuildACI takes a Docker layer, converts it to ACI and returns its output +// path and its converted ImageManifest. +type Docker2ACIBackend interface { + GetImageInfo(dockerUrl string) ([]string, *types.ParsedDockerURL, error) + BuildACI(layerIDs []string, dockerURL *types.ParsedDockerURL, outputDir string, tmpBaseDir string, compression common.Compression) ([]string, []*schema.ImageManifest, error) +} + +// GenerateACI takes a Docker layer and generates an ACI from it. +func GenerateACI(layerNumber int, layerData types.DockerImageData, dockerURL *types.ParsedDockerURL, outputDir string, layerFile *os.File, curPwl []string, compression common.Compression) (string, *schema.ImageManifest, error) { + manifest, err := GenerateManifest(layerData, dockerURL) + if err != nil { + return "", nil, fmt.Errorf("error generating the manifest: %v", err) + } + + imageName := strings.Replace(dockerURL.ImageName, "/", "-", -1) + aciPath := imageName + "-" + layerData.ID + if dockerURL.Tag != "" { + aciPath += "-" + dockerURL.Tag + } + if layerData.OS != "" { + aciPath += "-" + layerData.OS + if layerData.Architecture != "" { + aciPath += "-" + layerData.Architecture + } + } + aciPath += "-" + strconv.Itoa(layerNumber) + aciPath += ".aci" + + aciPath = path.Join(outputDir, aciPath) + manifest, err = writeACI(layerFile, *manifest, curPwl, aciPath, compression) + if err != nil { + return "", nil, fmt.Errorf("error writing ACI: %v", err) + } + + if err := ValidateACI(aciPath); err != nil { + return "", nil, fmt.Errorf("invalid ACI generated: %v", err) + } + + return aciPath, manifest, nil +} + +// ValidateACI checks whether the ACI in aciPath is valid. +func ValidateACI(aciPath string) error { + aciFile, err := os.Open(aciPath) + if err != nil { + return err + } + defer aciFile.Close() + + tr, err := aci.NewCompressedTarReader(aciFile) + if err != nil { + return err + } + defer tr.Close() + + if err := aci.ValidateArchive(tr.Reader); err != nil { + return err + } + + return nil +} + +// GenerateManifest converts the docker manifest format to an appc +// ImageManifest. +func GenerateManifest(layerData types.DockerImageData, dockerURL *types.ParsedDockerURL) (*schema.ImageManifest, error) { + dockerConfig := layerData.Config + genManifest := &schema.ImageManifest{} + + appURL := "" + appURL = dockerURL.IndexURL + "/" + appURL += dockerURL.ImageName + "-" + layerData.ID + appURL, err := appctypes.SanitizeACIdentifier(appURL) + if err != nil { + return nil, err + } + name := appctypes.MustACIdentifier(appURL) + genManifest.Name = *name + + acVersion, err := appctypes.NewSemVer(schema.AppContainerVersion.String()) + if err != nil { + panic("invalid appc spec version") + } + genManifest.ACVersion = *acVersion + + genManifest.ACKind = appctypes.ACKind(schema.ImageManifestKind) + + var ( + labels appctypes.Labels + parentLabels appctypes.Labels + annotations appctypes.Annotations + ) + + layer := appctypes.MustACIdentifier("layer") + labels = append(labels, appctypes.Label{Name: *layer, Value: layerData.ID}) + + tag := dockerURL.Tag + version := appctypes.MustACIdentifier("version") + labels = append(labels, appctypes.Label{Name: *version, Value: tag}) + + if layerData.OS != "" { + os := appctypes.MustACIdentifier("os") + labels = append(labels, appctypes.Label{Name: *os, Value: layerData.OS}) + parentLabels = append(parentLabels, appctypes.Label{Name: *os, Value: layerData.OS}) + + if layerData.Architecture != "" { + arch := appctypes.MustACIdentifier("arch") + labels = append(labels, appctypes.Label{Name: *arch, Value: layerData.Architecture}) + parentLabels = append(parentLabels, appctypes.Label{Name: *arch, Value: layerData.Architecture}) + } + } + + if layerData.Author != "" { + authorsKey := appctypes.MustACIdentifier("authors") + annotations = append(annotations, appctypes.Annotation{Name: *authorsKey, Value: layerData.Author}) + } + epoch := time.Unix(0, 0) + if !layerData.Created.Equal(epoch) { + createdKey := appctypes.MustACIdentifier("created") + annotations = append(annotations, appctypes.Annotation{Name: *createdKey, Value: layerData.Created.Format(time.RFC3339)}) + } + if layerData.Comment != "" { + commentKey := appctypes.MustACIdentifier("docker-comment") + annotations = append(annotations, appctypes.Annotation{Name: *commentKey, Value: layerData.Comment}) + } + + if dockerURL.IndexURL != "" { + annotations = append(annotations, appctypes.Annotation{Name: *appctypes.MustACIdentifier(common.AppcDockerRegistryURL), Value: dockerURL.IndexURL}) + } + annotations = append(annotations, appctypes.Annotation{Name: *appctypes.MustACIdentifier(common.AppcDockerRepository), Value: dockerURL.ImageName}) + annotations = append(annotations, appctypes.Annotation{Name: *appctypes.MustACIdentifier(common.AppcDockerImageID), Value: layerData.ID}) + annotations = append(annotations, appctypes.Annotation{Name: *appctypes.MustACIdentifier(common.AppcDockerParentImageID), Value: layerData.Parent}) + + if dockerConfig != nil { + if len(dockerConfig.Entrypoint) > 0 { + entry, err := json.Marshal(dockerConfig.Entrypoint) + if err != nil { + return nil, err + } + annotations = append(annotations, appctypes.Annotation{Name: *appctypes.MustACIdentifier(common.AppcDockerEntrypoint), Value: string(entry)}) + } + if len(dockerConfig.Cmd) > 0 { + cmd, err := json.Marshal(dockerConfig.Cmd) + if err != nil { + return nil, err + } + annotations = append(annotations, appctypes.Annotation{Name: *appctypes.MustACIdentifier(common.AppcDockerCmd), Value: string(cmd)}) + } + + exec := getExecCommand(dockerConfig.Entrypoint, dockerConfig.Cmd) + if exec != nil { + user, group := parseDockerUser(dockerConfig.User) + var env appctypes.Environment + for _, v := range dockerConfig.Env { + parts := strings.SplitN(v, "=", 2) + env.Set(parts[0], parts[1]) + } + app := &appctypes.App{ + Exec: exec, + User: user, + Group: group, + Environment: env, + WorkingDirectory: dockerConfig.WorkingDir, + } + + app.MountPoints, err = convertVolumesToMPs(dockerConfig.Volumes) + if err != nil { + return nil, err + } + + app.Ports, err = convertPorts(dockerConfig.ExposedPorts, dockerConfig.PortSpecs) + if err != nil { + return nil, err + } + + genManifest.App = app + } + } + + if layerData.Parent != "" { + indexPrefix := "" + // omit docker hub index URL in app name + indexPrefix = dockerURL.IndexURL + "/" + parentImageNameString := indexPrefix + dockerURL.ImageName + "-" + layerData.Parent + parentImageNameString, err := appctypes.SanitizeACIdentifier(parentImageNameString) + if err != nil { + return nil, err + } + parentImageName := appctypes.MustACIdentifier(parentImageNameString) + + genManifest.Dependencies = append(genManifest.Dependencies, appctypes.Dependency{ImageName: *parentImageName, Labels: parentLabels}) + + annotations = append(annotations, appctypes.Annotation{Name: *appctypes.MustACIdentifier(common.AppcDockerTag), Value: dockerURL.Tag}) + } + + genManifest.Labels = labels + genManifest.Annotations = annotations + + return genManifest, nil +} + +type appcPortSorter []appctypes.Port + +func (s appcPortSorter) Len() int { + return len(s) +} + +func (s appcPortSorter) Swap(i, j int) { + s[i], s[j] = s[j], s[i] +} + +func (s appcPortSorter) Less(i, j int) bool { + return s[i].Name.String() < s[j].Name.String() +} + +func convertPorts(dockerExposedPorts map[string]struct{}, dockerPortSpecs []string) ([]appctypes.Port, error) { + ports := []appctypes.Port{} + + for ep := range dockerExposedPorts { + appcPort, err := parseDockerPort(ep) + if err != nil { + return nil, err + } + ports = append(ports, *appcPort) + } + + if dockerExposedPorts == nil && dockerPortSpecs != nil { + log.Debug("warning: docker image uses deprecated PortSpecs field") + for _, ep := range dockerPortSpecs { + appcPort, err := parseDockerPort(ep) + if err != nil { + return nil, err + } + ports = append(ports, *appcPort) + } + } + + sort.Sort(appcPortSorter(ports)) + + return ports, nil +} + +func parseDockerPort(dockerPort string) (*appctypes.Port, error) { + var portString string + proto := "tcp" + sp := strings.Split(dockerPort, "/") + if len(sp) < 2 { + portString = dockerPort + } else { + proto = sp[1] + portString = sp[0] + } + + port, err := strconv.ParseUint(portString, 10, 0) + if err != nil { + return nil, fmt.Errorf("error parsing port %q: %v", portString, err) + } + + sn, err := appctypes.SanitizeACName(dockerPort) + if err != nil { + return nil, err + } + + appcPort := &appctypes.Port{ + Name: *appctypes.MustACName(sn), + Protocol: proto, + Port: uint(port), + } + + return appcPort, nil +} + +type appcVolSorter []appctypes.MountPoint + +func (s appcVolSorter) Len() int { + return len(s) +} + +func (s appcVolSorter) Swap(i, j int) { + s[i], s[j] = s[j], s[i] +} + +func (s appcVolSorter) Less(i, j int) bool { + return s[i].Name.String() < s[j].Name.String() +} + +func convertVolumesToMPs(dockerVolumes map[string]struct{}) ([]appctypes.MountPoint, error) { + mps := []appctypes.MountPoint{} + dup := make(map[string]int) + + for p := range dockerVolumes { + n := filepath.Join("volume", p) + sn, err := appctypes.SanitizeACName(n) + if err != nil { + return nil, err + } + + // check for duplicate names + if i, ok := dup[sn]; ok { + dup[sn] = i + 1 + sn = fmt.Sprintf("%s-%d", sn, i) + } else { + dup[sn] = 1 + } + + mp := appctypes.MountPoint{ + Name: *appctypes.MustACName(sn), + Path: p, + } + + mps = append(mps, mp) + } + + sort.Sort(appcVolSorter(mps)) + + return mps, nil +} + +func writeACI(layer io.ReadSeeker, manifest schema.ImageManifest, curPwl []string, output string, compression common.Compression) (*schema.ImageManifest, error) { + aciFile, err := os.Create(output) + if err != nil { + return nil, fmt.Errorf("error creating ACI file: %v", err) + } + defer aciFile.Close() + + var w io.WriteCloser = aciFile + if compression == common.GzipCompression { + w = gzip.NewWriter(aciFile) + defer w.Close() + } + trw := tar.NewWriter(w) + defer trw.Close() + + if err := WriteRootfsDir(trw); err != nil { + return nil, fmt.Errorf("error writing rootfs entry: %v", err) + } + + fileMap := make(map[string]struct{}) + var whiteouts []string + convWalker := func(t *tarball.TarFile) error { + name := t.Name() + if name == "./" { + return nil + } + t.Header.Name = path.Join("rootfs", name) + absolutePath := strings.TrimPrefix(t.Header.Name, "rootfs") + + if filepath.Clean(absolutePath) == "/dev" && t.Header.Typeflag != tar.TypeDir { + return fmt.Errorf(`invalid layer: "/dev" is not a directory`) + } + + fileMap[absolutePath] = struct{}{} + if strings.Contains(t.Header.Name, "/.wh.") { + whiteouts = append(whiteouts, strings.Replace(absolutePath, ".wh.", "", 1)) + return nil + } + if t.Header.Typeflag == tar.TypeLink { + t.Header.Linkname = path.Join("rootfs", t.Linkname()) + } + + if err := trw.WriteHeader(t.Header); err != nil { + return err + } + if _, err := io.Copy(trw, t.TarStream); err != nil { + return err + } + + if !util.In(curPwl, absolutePath) { + curPwl = append(curPwl, absolutePath) + } + + return nil + } + tr, err := aci.NewCompressedTarReader(layer) + if err == nil { + defer tr.Close() + // write files in rootfs/ + if err := tarball.Walk(*tr.Reader, convWalker); err != nil { + return nil, err + } + } else { + // ignore errors: empty layers in tars generated by docker save are not + // valid tar files so we ignore errors trying to open them. Converted + // ACIs will have the manifest and an empty rootfs directory in any + // case. + } + newPwl := subtractWhiteouts(curPwl, whiteouts) + + newPwl, err = writeStdioSymlinks(trw, fileMap, newPwl) + if err != nil { + return nil, err + } + // Let's copy the newly generated PathWhitelist to avoid unintended + // side-effects + manifest.PathWhitelist = make([]string, len(newPwl)) + copy(manifest.PathWhitelist, newPwl) + + if err := WriteManifest(trw, manifest); err != nil { + return nil, fmt.Errorf("error writing manifest: %v", err) + } + + return &manifest, nil +} + +func getExecCommand(entrypoint []string, cmd []string) appctypes.Exec { + return append(entrypoint, cmd...) +} + +func parseDockerUser(dockerUser string) (string, string) { + // if the docker user is empty assume root user and group + if dockerUser == "" { + return "0", "0" + } + + dockerUserParts := strings.Split(dockerUser, ":") + + // when only the user is given, the docker spec says that the default and + // supplementary groups of the user in /etc/passwd should be applied. + // Assume root group for now in this case. + if len(dockerUserParts) < 2 { + return dockerUserParts[0], "0" + } + + return dockerUserParts[0], dockerUserParts[1] +} + +func subtractWhiteouts(pathWhitelist []string, whiteouts []string) []string { + matchPaths := []string{} + for _, path := range pathWhitelist { + // If one of the parent dirs of the current path matches the + // whiteout then also this path should be removed + curPath := path + for curPath != "/" { + for _, whiteout := range whiteouts { + if curPath == whiteout { + matchPaths = append(matchPaths, path) + } + } + curPath = filepath.Dir(curPath) + } + } + for _, matchPath := range matchPaths { + idx := util.IndexOf(pathWhitelist, matchPath) + if idx != -1 { + pathWhitelist = append(pathWhitelist[:idx], pathWhitelist[idx+1:]...) + } + } + + sort.Sort(sort.StringSlice(pathWhitelist)) + + return pathWhitelist +} + +// WriteManifest writes a schema.ImageManifest entry on a tar.Writer. +func WriteManifest(outputWriter *tar.Writer, manifest schema.ImageManifest) error { + b, err := json.Marshal(manifest) + if err != nil { + return err + } + + hdr := getGenericTarHeader() + hdr.Name = "manifest" + hdr.Mode = 0644 + hdr.Size = int64(len(b)) + hdr.Typeflag = tar.TypeReg + + if err := outputWriter.WriteHeader(hdr); err != nil { + return err + } + if _, err := outputWriter.Write(b); err != nil { + return err + } + + return nil +} + +// WriteRootfsDir writes a "rootfs" dir entry on a tar.Writer. +func WriteRootfsDir(tarWriter *tar.Writer) error { + hdr := getGenericTarHeader() + hdr.Name = "rootfs" + hdr.Mode = 0755 + hdr.Size = int64(0) + hdr.Typeflag = tar.TypeDir + + return tarWriter.WriteHeader(hdr) +} + +type symlink struct { + linkname string + target string +} + +// writeStdioSymlinks adds the /dev/stdin, /dev/stdout, /dev/stderr, and +// /dev/fd symlinks expected by Docker to the converted ACIs so apps can find +// them as expected +func writeStdioSymlinks(tarWriter *tar.Writer, fileMap map[string]struct{}, pwl []string) ([]string, error) { + stdioSymlinks := []symlink{ + {"/dev/stdin", "/proc/self/fd/0"}, + // Docker makes /dev/{stdout,stderr} point to /proc/self/fd/{1,2} but + // we point to /dev/console instead in order to support the case when + // stdout/stderr is a Unix socket (e.g. for the journal). + {"/dev/stdout", "/dev/console"}, + {"/dev/stderr", "/dev/console"}, + {"/dev/fd", "/proc/self/fd"}, + } + + for _, s := range stdioSymlinks { + name := s.linkname + target := s.target + if _, exists := fileMap[name]; exists { + continue + } + hdr := &tar.Header{ + Name: filepath.Join("rootfs", name), + Mode: 0777, + Typeflag: tar.TypeSymlink, + Linkname: target, + } + if err := tarWriter.WriteHeader(hdr); err != nil { + return nil, err + } + if !util.In(pwl, name) { + pwl = append(pwl, name) + } + } + + return pwl, nil +} + +func getGenericTarHeader() *tar.Header { + // FIXME(iaguis) Use docker image time instead of the Unix Epoch? + hdr := &tar.Header{ + Uid: 0, + Gid: 0, + ModTime: time.Unix(0, 0), + Uname: "0", + Gname: "0", + ChangeTime: time.Unix(0, 0), + } + + return hdr +} diff --git a/vendor/github.com/appc/docker2aci/lib/internal/tarball/tarfile.go b/vendor/github.com/appc/docker2aci/lib/internal/tarball/tarfile.go new file mode 100644 index 0000000000..c72d18d9d9 --- /dev/null +++ b/vendor/github.com/appc/docker2aci/lib/internal/tarball/tarfile.go @@ -0,0 +1,42 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package tarball provides functions to manipulate tar files. +// +// Note: this package is an implementation detail and shouldn't be used outside +// of docker2aci. +package tarball + +import ( + "archive/tar" + "io" +) + +// TarFile is a representation of a file in a tarball. It consists of two parts, +// the Header and the Stream. The Header is a regular tar header, the Stream +// is a byte stream that can be used to read the file's contents. +type TarFile struct { + Header *tar.Header + TarStream io.Reader +} + +// Name returns the name of the file as reported by the header. +func (t *TarFile) Name() string { + return t.Header.Name +} + +// Linkname returns the Linkname of the file as reported by the header. +func (t *TarFile) Linkname() string { + return t.Header.Linkname +} diff --git a/vendor/github.com/appc/docker2aci/lib/internal/tarball/walk.go b/vendor/github.com/appc/docker2aci/lib/internal/tarball/walk.go new file mode 100644 index 0000000000..c12d2e34fb --- /dev/null +++ b/vendor/github.com/appc/docker2aci/lib/internal/tarball/walk.go @@ -0,0 +1,43 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package tarball + +import ( + "archive/tar" + "fmt" + "io" +) + +// WalkFunc is a func for handling each file (header and byte stream) in a tarball +type WalkFunc func(t *TarFile) error + +// Walk walks through the files in the tarball represented by tarstream and +// passes each of them to the WalkFunc provided as an argument +func Walk(tarReader tar.Reader, walkFunc func(t *TarFile) error) error { + for { + hdr, err := tarReader.Next() + if err == io.EOF { + // end of tar archive + break + } + if err != nil { + return fmt.Errorf("Error reading tar entry: %v", err) + } + if err := walkFunc(&TarFile{Header: hdr, TarStream: &tarReader}); err != nil { + return err + } + } + return nil +} diff --git a/vendor/github.com/appc/docker2aci/lib/internal/types/docker_types.go b/vendor/github.com/appc/docker2aci/lib/internal/types/docker_types.go new file mode 100644 index 0000000000..7af1e17e7a --- /dev/null +++ b/vendor/github.com/appc/docker2aci/lib/internal/types/docker_types.go @@ -0,0 +1,92 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import "time" + +// DockerImageData stores the JSON structure of a Docker image. +// Taken and adapted from upstream Docker. +type DockerImageData struct { + ID string `json:"id"` + Parent string `json:"parent,omitempty"` + Comment string `json:"comment,omitempty"` + Created time.Time `json:"created"` + Container string `json:"container,omitempty"` + ContainerConfig DockerImageConfig `json:"container_config,omitempty"` + DockerVersion string `json:"docker_version,omitempty"` + Author string `json:"author,omitempty"` + Config *DockerImageConfig `json:"config,omitempty"` + Architecture string `json:"architecture,omitempty"` + OS string `json:"os,omitempty"` + Checksum string `json:"checksum"` +} + +// Note: the Config structure should hold only portable information about the container. +// Here, "portable" means "independent from the host we are running on". +// Non-portable information *should* appear in HostConfig. +// Taken and adapted from upstream Docker. +type DockerImageConfig struct { + Hostname string + Domainname string + User string + Memory int64 // Memory limit (in bytes) + MemorySwap int64 // Total memory usage (memory + swap); set `-1' to disable swap + CpuShares int64 // CPU shares (relative weight vs. other containers) + Cpuset string // Cpuset 0-2, 0,1 + AttachStdin bool + AttachStdout bool + AttachStderr bool + PortSpecs []string // Deprecated - Can be in the format of 8080/tcp + ExposedPorts map[string]struct{} + Tty bool // Attach standard streams to a tty, including stdin if it is not closed. + OpenStdin bool // Open stdin + StdinOnce bool // If true, close stdin after the 1 attached client disconnects. + Env []string + Cmd []string + Image string // Name of the image as it was passed by the operator (eg. could be symbolic) + Volumes map[string]struct{} + WorkingDir string + Entrypoint []string + NetworkDisabled bool + MacAddress string + OnBuild []string +} + +// DockerAuthConfigOld represents the deprecated ~/.dockercfg auth +// configuration. +// Taken from upstream Docker. +type DockerAuthConfigOld struct { + Username string `json:"username,omitempty"` + Password string `json:"password,omitempty"` + Auth string `json:"auth"` + Email string `json:"email"` + ServerAddress string `json:"serveraddress,omitempty"` +} + +// DockerAuthConfig represents a config.json auth entry. +// Taken from upstream Docker. +type DockerAuthConfig struct { + Username string `json:"username,omitempty"` + Password string `json:"password,omitempty"` + Auth string `json:"auth,omitempty"` + ServerAddress string `json:"serveraddress,omitempty"` + RegistryToken string `json:"registrytoken,omitempty"` +} + +// DockerConfigFile represents a config.json auth file. +// Taken from upstream docker. +type DockerConfigFile struct { + AuthConfigs map[string]DockerAuthConfig `json:"auths"` +} diff --git a/vendor/github.com/appc/docker2aci/lib/internal/types/types.go b/vendor/github.com/appc/docker2aci/lib/internal/types/types.go new file mode 100644 index 0000000000..cc4fc12ac8 --- /dev/null +++ b/vendor/github.com/appc/docker2aci/lib/internal/types/types.go @@ -0,0 +1,27 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package types defines Docker image, URL and configuration types. +// +// Note: this package is an implementation detail and shouldn't be used outside +// of docker2aci. +package types + +// ParsedDockerURL represents a parsed Docker URL. +type ParsedDockerURL struct { + IndexURL string + ImageName string + Tag string + Digest string +} diff --git a/vendor/github.com/appc/docker2aci/lib/internal/util/util.go b/vendor/github.com/appc/docker2aci/lib/internal/util/util.go new file mode 100644 index 0000000000..ebaafca62c --- /dev/null +++ b/vendor/github.com/appc/docker2aci/lib/internal/util/util.go @@ -0,0 +1,83 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package util defines convenience functions for handling slices and debugging. +// +// Note: this package is an implementation detail and shouldn't be used outside +// of docker2aci. +package util + +import ( + "crypto/tls" + "fmt" + "net/http" + + "github.com/appc/spec/pkg/acirenderer" +) + +// Quote takes a slice of strings and returns another slice with them quoted. +func Quote(l []string) []string { + var quoted []string + + for _, s := range l { + quoted = append(quoted, fmt.Sprintf("%q", s)) + } + + return quoted +} + +// ReverseImages takes an acirenderer.Images and reverses it. +func ReverseImages(s acirenderer.Images) acirenderer.Images { + var o acirenderer.Images + for i := len(s) - 1; i >= 0; i-- { + o = append(o, s[i]) + } + + return o +} + +// In checks whether el is in list. +func In(list []string, el string) bool { + return IndexOf(list, el) != -1 +} + +// IndexOf returns the index of el in list, or -1 if it's not found. +func IndexOf(list []string, el string) int { + for i, x := range list { + if el == x { + return i + } + } + return -1 +} + +// GetTLSClient gets an HTTP client that behaves like the default HTTP +// client, but optionally skips the TLS certificate verification. +func GetTLSClient(skipTLSCheck bool) *http.Client { + if !skipTLSCheck { + return http.DefaultClient + } + client := *http.DefaultClient + // Default transport is hidden behind the RoundTripper + // interface, so we can't easily make a copy of it. If this + // ever panics, we will have to adapt. + realTransport := http.DefaultTransport.(*http.Transport) + tr := *realTransport + if tr.TLSClientConfig == nil { + tr.TLSClientConfig = &tls.Config{} + } + tr.TLSClientConfig.InsecureSkipVerify = true + client.Transport = &tr + return &client +} diff --git a/vendor/github.com/appc/docker2aci/lib/version.go b/vendor/github.com/appc/docker2aci/lib/version.go new file mode 100644 index 0000000000..487c4bc50e --- /dev/null +++ b/vendor/github.com/appc/docker2aci/lib/version.go @@ -0,0 +1,20 @@ +// Copyright 2016 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package docker2aci + +import "github.com/appc/spec/schema" + +var Version = "0.11.1" +var AppcVersion = schema.AppContainerVersion diff --git a/vendor/github.com/appc/docker2aci/main.go b/vendor/github.com/appc/docker2aci/main.go new file mode 100644 index 0000000000..e52ca29769 --- /dev/null +++ b/vendor/github.com/appc/docker2aci/main.go @@ -0,0 +1,222 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "flag" + "fmt" + "net/url" + "os" + "strings" + + "github.com/appc/docker2aci/lib" + "github.com/appc/docker2aci/lib/common" + "github.com/appc/docker2aci/pkg/log" + + "github.com/appc/spec/aci" + "github.com/appc/spec/schema" +) + +var ( + flagNoSquash bool + flagImage string + flagDebug bool + flagInsecureSkipVerify bool + flagInsecureAllowHTTP bool + flagCompression string + flagVersion bool +) + +func init() { + flag.BoolVar(&flagNoSquash, "nosquash", false, "Don't squash layers and output every layer as ACI") + flag.StringVar(&flagImage, "image", "", "When converting a local file, it selects a particular image to convert. Format: IMAGE_NAME[:TAG]") + flag.BoolVar(&flagDebug, "debug", false, "Enables debug messages") + flag.BoolVar(&flagInsecureSkipVerify, "insecure-skip-verify", false, "Don't verify certificates when fetching images") + flag.BoolVar(&flagInsecureAllowHTTP, "insecure-allow-http", false, "Uses unencrypted connections when fetching images") + flag.StringVar(&flagCompression, "compression", "gzip", "Type of compression to use; allowed values: gzip, none") + flag.BoolVar(&flagVersion, "version", false, "Print version") +} + +func printVersion() { + fmt.Println("docker2aci version", docker2aci.Version) + fmt.Println("appc version", docker2aci.AppcVersion) +} + +func runDocker2ACI(arg string) error { + if flagDebug { + log.InitDebug() + } + squash := !flagNoSquash + + var aciLayerPaths []string + // try to convert a local file + u, err := url.Parse(arg) + if err != nil { + return fmt.Errorf("error parsing argument: %v", err) + } + + var compression common.Compression + + switch flagCompression { + case "none": + compression = common.NoCompression + case "gzip": + compression = common.GzipCompression + default: + return fmt.Errorf("unknown compression method: %s", flagCompression) + } + + cfg := docker2aci.CommonConfig{ + Squash: squash, + OutputDir: ".", + TmpDir: os.TempDir(), + Compression: compression, + } + if u.Scheme == "docker" { + if flagImage != "" { + return fmt.Errorf("flag --image works only with files.") + } + dockerURL := strings.TrimPrefix(arg, "docker://") + + indexServer := docker2aci.GetIndexName(dockerURL) + + var username, password string + username, password, err = docker2aci.GetDockercfgAuth(indexServer) + if err != nil { + return fmt.Errorf("error reading .dockercfg file: %v", err) + } + remoteConfig := docker2aci.RemoteConfig{ + CommonConfig: cfg, + Username: username, + Password: password, + Insecure: common.InsecureConfig{ + SkipVerify: flagInsecureSkipVerify, + AllowHTTP: flagInsecureAllowHTTP, + }, + } + + aciLayerPaths, err = docker2aci.ConvertRemoteRepo(dockerURL, remoteConfig) + } else { + fileConfig := docker2aci.FileConfig{ + CommonConfig: cfg, + DockerURL: flagImage, + } + aciLayerPaths, err = docker2aci.ConvertSavedFile(arg, fileConfig) + if serr, ok := err.(*common.ErrSeveralImages); ok { + err = fmt.Errorf("%s, use option --image with one of:\n\n%s", serr, strings.Join(serr.Images, "\n")) + } + } + if err != nil { + return fmt.Errorf("conversion error: %v", err) + } + + // we get last layer's manifest, this will include all the elements in the + // previous layers. If we're squashing, the last element of aciLayerPaths + // will be the squashed image. + manifest, err := getManifest(aciLayerPaths[len(aciLayerPaths)-1]) + if err != nil { + return err + } + + if err := printConvertedVolumes(*manifest); err != nil { + return err + } + if err := printConvertedPorts(*manifest); err != nil { + return err + } + + fmt.Printf("\nGenerated ACI(s):\n") + for _, aciFile := range aciLayerPaths { + fmt.Println(aciFile) + } + + return nil +} + +func printConvertedVolumes(manifest schema.ImageManifest) error { + if manifest.App != nil && manifest.App.MountPoints != nil { + mps := manifest.App.MountPoints + if len(mps) > 0 { + fmt.Printf("\nConverted volumes:\n") + for _, mp := range mps { + fmt.Printf("\tname: %q, path: %q, readOnly: %v\n", mp.Name, mp.Path, mp.ReadOnly) + } + } + } + + return nil +} + +func printConvertedPorts(manifest schema.ImageManifest) error { + if manifest.App != nil && manifest.App.Ports != nil { + ports := manifest.App.Ports + if len(ports) > 0 { + fmt.Printf("\nConverted ports:\n") + for _, port := range ports { + fmt.Printf("\tname: %q, protocol: %q, port: %v, count: %v, socketActivated: %v\n", + port.Name, port.Protocol, port.Port, port.Count, port.SocketActivated) + } + } + } + + return nil +} + +func getManifest(aciPath string) (*schema.ImageManifest, error) { + f, err := os.Open(aciPath) + if err != nil { + return nil, fmt.Errorf("error opening converted image: %v", err) + } + defer f.Close() + + manifest, err := aci.ManifestFromImage(f) + if err != nil { + return nil, fmt.Errorf("error reading manifest from converted image: %v", err) + } + + return manifest, nil +} + +func usage() { + fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0]) + fmt.Fprintf(os.Stderr, "docker2aci [--debug] [--nosquash] [--compression=(gzip|none)] IMAGE\n") + fmt.Fprintf(os.Stderr, " Where IMAGE is\n") + fmt.Fprintf(os.Stderr, " [--image=IMAGE_NAME[:TAG]] FILEPATH\n") + fmt.Fprintf(os.Stderr, " or\n") + fmt.Fprintf(os.Stderr, " docker://[REGISTRYURL/]IMAGE_NAME[:TAG]\n") + fmt.Fprintf(os.Stderr, "Flags:\n") + flag.PrintDefaults() +} + +func main() { + flag.Usage = usage + flag.Parse() + args := flag.Args() + + if flagVersion { + printVersion() + return + } + + if len(args) < 1 { + usage() + os.Exit(2) + } + + if err := runDocker2ACI(args[0]); err != nil { + fmt.Fprintf(os.Stderr, "Error: %v\n", err) + os.Exit(1) + } +} diff --git a/vendor/github.com/appc/docker2aci/pkg/log/log.go b/vendor/github.com/appc/docker2aci/pkg/log/log.go new file mode 100644 index 0000000000..2a02c47414 --- /dev/null +++ b/vendor/github.com/appc/docker2aci/pkg/log/log.go @@ -0,0 +1,46 @@ +// Copyright 2016 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package log + +import ( + "fmt" + "io" + "os" + "strings" +) + +var debugEnabled bool + +func printTo(w io.Writer, i ...interface{}) { + s := fmt.Sprint(i...) + fmt.Fprintln(w, strings.TrimSuffix(s, "\n")) +} + +// Info prints a message to stderr. +func Info(i ...interface{}) { + printTo(os.Stderr, i...) +} + +// Debug prints a message to stderr if debug is enabled. +func Debug(i ...interface{}) { + if debugEnabled { + printTo(os.Stderr, i...) + } +} + +// InitDebug enables debug output. +func InitDebug() { + debugEnabled = true +} diff --git a/vendor/github.com/appc/goaci/LICENSE b/vendor/github.com/appc/goaci/LICENSE new file mode 100644 index 0000000000..e06d208186 --- /dev/null +++ b/vendor/github.com/appc/goaci/LICENSE @@ -0,0 +1,202 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor 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, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/vendor/github.com/appc/goaci/buildercommand.go b/vendor/github.com/appc/goaci/buildercommand.go new file mode 100644 index 0000000000..586672775d --- /dev/null +++ b/vendor/github.com/appc/goaci/buildercommand.go @@ -0,0 +1,50 @@ +package main + +import ( + "flag" + "fmt" + + "github.com/appc/goaci/proj2aci" +) + +// parameterMapper is an interface which should handle command line +// parameter handling specific to a proj2aci.BuilderCustomizations +// implementation. +type parameterMapper interface { + Name() string + SetupParameters(parameters *flag.FlagSet) + GetBuilderCustomizations() proj2aci.BuilderCustomizations +} + +// builderCommand is an implementation of command interface which +// mainly maps command line parameters to proj2aci.Builder's +// configuration and runs the builder. +type builderCommand struct { + mapper parameterMapper +} + +func newBuilderCommand(mapper parameterMapper) command { + return &builderCommand{ + mapper: mapper, + } +} + +func (cmd *builderCommand) Name() string { + custom := cmd.mapper.GetBuilderCustomizations() + return custom.Name() +} + +func (cmd *builderCommand) Run(name string, args []string) error { + parameters := flag.NewFlagSet(name, flag.ExitOnError) + cmd.mapper.SetupParameters(parameters) + if err := parameters.Parse(args); err != nil { + return err + } + if len(parameters.Args()) != 1 { + return fmt.Errorf("Expected exactly one project to build, got %d", len(args)) + } + custom := cmd.mapper.GetBuilderCustomizations() + custom.GetCommonConfiguration().Project = parameters.Args()[0] + builder := proj2aci.NewBuilder(custom) + return builder.Run() +} diff --git a/vendor/github.com/appc/goaci/command.go b/vendor/github.com/appc/goaci/command.go new file mode 100644 index 0000000000..6e4e539cb1 --- /dev/null +++ b/vendor/github.com/appc/goaci/command.go @@ -0,0 +1,12 @@ +package main + +// command provides an interface for named actions for command line +// purposes. +type command interface { + // Name should return a name of a command usable at command + // line. + Name() string + // Run should parse given args and perform some action. name + // parameter is given for usage purposes. + Run(name string, args []string) error +} diff --git a/vendor/github.com/appc/goaci/commands.go b/vendor/github.com/appc/goaci/commands.go new file mode 100644 index 0000000000..831c4b08fc --- /dev/null +++ b/vendor/github.com/appc/goaci/commands.go @@ -0,0 +1,15 @@ +package main + +var ( + commandsMap map[string]command = make(map[string]command) +) + +func init() { + commands := []command{ + newBuilderCommand(newGoParameterMapper()), + newBuilderCommand(newCmakeParameterMapper()), + } + for _, c := range commands { + commandsMap[c.Name()] = c + } +} diff --git a/vendor/github.com/appc/goaci/main.go b/vendor/github.com/appc/goaci/main.go new file mode 100644 index 0000000000..24e04c5e33 --- /dev/null +++ b/vendor/github.com/appc/goaci/main.go @@ -0,0 +1,59 @@ +package main + +import ( + "fmt" + "os" + "sort" + + "github.com/appc/goaci/proj2aci" +) + +type CmdLineError struct { + what string +} + +func (err *CmdLineError) Error() string { + return fmt.Sprintf("Command line error: %s", err.what) +} + +func newCmdLineError(format string, args ...interface{}) error { + return &CmdLineError{ + what: fmt.Sprintf(format, args...), + } +} + +func main() { + if err := mainWithError(); err != nil { + proj2aci.Warn(err) + if _, ok := err.(*CmdLineError); ok { + printUsage() + } + os.Exit(1) + } +} + +func mainWithError() error { + proj2aci.InitDebug() + if len(os.Args) < 2 { + return newCmdLineError("No command specified") + } + if c, ok := commandsMap[os.Args[1]]; ok { + name := fmt.Sprintf("%s %s", os.Args[0], os.Args[1]) + return c.Run(name, os.Args[2:]) + } else { + return newCmdLineError("No such command: %q", os.Args[1]) + } +} + +func printUsage() { + fmt.Println("Available commands:") + commands := make([]string, 0, len(commandsMap)) + for c := range commandsMap { + commands = append(commands, c) + } + sort.Strings(commands) + for _, c := range commands { + fmt.Printf(" %s\n", c) + } + fmt.Printf("Type %s --help to get possible options for chosen command\n", os.Args[0]) +} diff --git a/vendor/github.com/appc/goaci/mappers.go b/vendor/github.com/appc/goaci/mappers.go new file mode 100644 index 0000000000..0b1f5c69ff --- /dev/null +++ b/vendor/github.com/appc/goaci/mappers.go @@ -0,0 +1,150 @@ +package main + +import ( + "flag" + "os/exec" + "sort" + "strings" + + "github.com/appc/goaci/proj2aci" +) + +// stringSliceWrapper is an implementation of flag.Value +// interface. It is basically a proxy that append strings to already +// existing strings slice. +type stringSliceWrapper struct { + vector *[]string +} + +func (wrapper *stringSliceWrapper) String() string { + if len(*wrapper.vector) > 0 { + return `["` + strings.Join(*wrapper.vector, `" "`) + `"]` + } + return "[]" +} + +func (wrapper *stringSliceWrapper) Set(str string) error { + *wrapper.vector = append(*wrapper.vector, str) + return nil +} + +// commonParameterMapper maps command line parameters to +// proj2aci.CommonConfiguration. +type commonParameterMapper struct { + custom proj2aci.BuilderCustomizations + config *proj2aci.CommonConfiguration + execWrapper stringSliceWrapper + assetWrapper stringSliceWrapper +} + +func (mapper *commonParameterMapper) setupCommonParameters(parameters *flag.FlagSet) { + // --exec + mapper.execWrapper.vector = &mapper.config.Exec + parameters.Var(&mapper.execWrapper, "exec", "Parameters passed to app, can be used multiple times") + + // --use-binary + parameters.StringVar(&mapper.config.UseBinary, "use-binary", "", "Which executable to put in ACI image") + + // --asset + mapper.assetWrapper.vector = &mapper.config.Assets + parameters.Var(&mapper.assetWrapper, "asset", "Additional assets, can be used multiple times; format: "+proj2aci.GetAssetString("", "")+"; available placeholders for use: "+mapper.getPlaceholders()) + + // --keep-tmp-dir + parameters.BoolVar(&mapper.config.KeepTmpDir, "keep-tmp-dir", false, "Do not delete temporary directory used for creating ACI") + + // --tmp-dir + parameters.StringVar(&mapper.config.TmpDir, "tmp-dir", "", "Use this directory for build a project and an ACI image") + + // --reuse-tmp-dir + parameters.StringVar(&mapper.config.ReuseTmpDir, "reuse-tmp-dir", "", "Use this already existing directory with built project to build an ACI image; ACI specific contents in this directory are removed before reuse") +} + +func (mapper *commonParameterMapper) getPlaceholders() string { + mapping := mapper.custom.GetPlaceholderMapping() + placeholders := make([]string, 0, len(mapping)) + for p := range mapping { + placeholders = append(placeholders, p) + } + sort.Strings(placeholders) + return strings.Join(placeholders, ", ") +} + +func (mapper *commonParameterMapper) Name() string { + return mapper.custom.Name() +} + +func (mapper *commonParameterMapper) GetBuilderCustomizations() proj2aci.BuilderCustomizations { + return mapper.custom +} + +// goParameterMapper maps command line parameters to +// proj2aci.GoConfiguration. +type goParameterMapper struct { + commonParameterMapper + + goCustom *proj2aci.GoCustomizations +} + +func newGoParameterMapper() parameterMapper { + custom := &proj2aci.GoCustomizations{} + return &goParameterMapper{ + commonParameterMapper: commonParameterMapper{ + custom: custom, + config: custom.GetCommonConfiguration(), + }, + goCustom: custom, + } +} + +func (mapper *goParameterMapper) SetupParameters(parameters *flag.FlagSet) { + // common params + mapper.setupCommonParameters(parameters) + + // --go-binary + goDefaultBinaryDesc := "Go binary to use" + gocmd, err := exec.LookPath("go") + if err != nil { + goDefaultBinaryDesc += " (default: none found in $PATH, so it must be provided)" + } else { + goDefaultBinaryDesc += " (default: whatever go in $PATH)" + } + parameters.StringVar(&mapper.goCustom.Configuration.GoBinary, "go-binary", gocmd, goDefaultBinaryDesc) + + // --go-path + parameters.StringVar(&mapper.goCustom.Configuration.GoPath, "go-path", "", "Custom GOPATH (default: a temporary directory)") +} + +// cmakeParameterMapper maps command line parameters to +// proj2aci.CmakeConfiguration. +type cmakeParameterMapper struct { + commonParameterMapper + + cmakeCustom *proj2aci.CmakeCustomizations + cmakeParamWrapper stringSliceWrapper +} + +func newCmakeParameterMapper() parameterMapper { + custom := &proj2aci.CmakeCustomizations{} + return &cmakeParameterMapper{ + commonParameterMapper: commonParameterMapper{ + custom: custom, + config: custom.GetCommonConfiguration(), + }, + cmakeCustom: custom, + } +} + +func (mapper *cmakeParameterMapper) SetupParameters(parameters *flag.FlagSet) { + // common params + mapper.setupCommonParameters(parameters) + + // --binary-dir + parameters.StringVar(&mapper.cmakeCustom.Configuration.BinDir, "binary-dir", "", "Look for binaries in this directory (relative to install path, eg passing /usr/local/mysql/bin would look for a binary in /install/usr/local/mysql/bin") + + // --reuse-src-dir + parameters.StringVar(&mapper.cmakeCustom.Configuration.ReuseSrcDir, "reuse-src-dir", "", "Instead of downloading a project, use this path with already downloaded sources") + + // --cmake-param + mapper.cmakeParamWrapper.vector = &mapper.cmakeCustom.Configuration.CmakeParams + parameters.Var(&mapper.cmakeParamWrapper, "cmake-param", "Parameters passed to cmake, can be used multiple times") +} diff --git a/vendor/github.com/appc/goaci/proj2aci/asset.go b/vendor/github.com/appc/goaci/proj2aci/asset.go new file mode 100644 index 0000000000..d90ee5fc8e --- /dev/null +++ b/vendor/github.com/appc/goaci/proj2aci/asset.go @@ -0,0 +1,283 @@ +package proj2aci + +import ( + "bytes" + "fmt" + "io" + "os" + "path/filepath" + "regexp" + "strings" +) + +// GetAssetString returns a properly formatted asset string. +func GetAssetString(aciAsset, localAsset string) string { + return getAssetString(aciAsset, localAsset) +} + +// PrepareAssets copies given assets to ACI rootfs directory. It also +// tries to copy required shared libraries if an asset is a +// dynamically linked executable or library. placeholderMapping maps +// placeholders (like "") to actual paths (usually +// something inside temporary directory). +func PrepareAssets(assets []string, rootfs string, placeholderMapping map[string]string) error { + newAssets := assets + processedAssets := make(map[string]struct{}) + for len(newAssets) > 0 { + assetsToProcess := newAssets + newAssets = nil + for _, asset := range assetsToProcess { + splitAsset := filepath.SplitList(asset) + if len(splitAsset) != 2 { + return fmt.Errorf("Malformed asset option: '%v' - expected two absolute paths separated with %v", asset, listSeparator()) + } + evalSrc, srcErr := evalPath(splitAsset[0]) + if srcErr != nil { + return fmt.Errorf("Could not evaluate symlinks in source asset %q: %v", evalSrc, srcErr) + } + evalDest, destErr := evalPath(splitAsset[1]) + asset = getAssetString(evalSrc, evalDest) + Debug("Processing asset:", asset) + if _, ok := processedAssets[asset]; ok { + Debug(" skipped") + continue + } + additionalAssets, err := processAsset(asset, rootfs, placeholderMapping) + if destErr != nil { + evalDest, destErr = evalPath(evalDest) + if destErr != nil { + return fmt.Errorf("Could not evaluate symlinks in destination asset %q, even after it was copied to: %v", evalDest, destErr) + } + asset = getAssetString(evalSrc, evalDest) + } + if err != nil { + return err + } + processedAssets[asset] = struct{}{} + newAssets = append(newAssets, additionalAssets...) + } + } + return nil +} + +func evalPath(path string) (string, error) { + symlinkDir := filepath.Dir(path) + symlinkBase := filepath.Base(path) + realSymlinkDir, err := filepath.EvalSymlinks(symlinkDir) + if err != nil { + return path, err + } + return filepath.Join(realSymlinkDir, symlinkBase), nil +} + +// processAsset validates an asset, replaces placeholders with real +// paths and does the copying. It may return additional assets to be +// processed when asset is an executable or a library. +func processAsset(asset, rootfs string, placeholderMapping map[string]string) ([]string, error) { + splitAsset := filepath.SplitList(asset) + if len(splitAsset) != 2 { + return nil, fmt.Errorf("Malformed asset option: '%v' - expected two absolute paths separated with %v", asset, listSeparator()) + } + ACIAsset := replacePlaceholders(splitAsset[0], placeholderMapping) + localAsset := replacePlaceholders(splitAsset[1], placeholderMapping) + if err := validateAsset(ACIAsset, localAsset); err != nil { + return nil, err + } + ACIAssetSubPath := filepath.Join(rootfs, filepath.Dir(ACIAsset)) + err := os.MkdirAll(ACIAssetSubPath, 0755) + if err != nil { + return nil, fmt.Errorf("Failed to create directory tree for asset '%v': %v", asset, err) + } + err = copyTree(localAsset, filepath.Join(rootfs, ACIAsset)) + if err != nil { + return nil, fmt.Errorf("Failed to copy assets for %q: %v", asset, err) + } + additionalAssets, err := getSoLibs(localAsset) + if err != nil { + return nil, fmt.Errorf("Failed to get dependent assets for %q: %v", localAsset, err) + } + // HACK! if we are copying libc then try to copy libnss_* libs + // (glibc name service switch libs used in networking) + if matched, err := filepath.Match("libc.*", filepath.Base(localAsset)); err == nil && matched { + toGlob := filepath.Join(filepath.Dir(localAsset), "libnss_*") + if matches, err := filepath.Glob(toGlob); err == nil && len(matches) > 0 { + matchesAsAssets := make([]string, 0, len(matches)) + for _, f := range matches { + matchesAsAssets = append(matchesAsAssets, getAssetString(f, f)) + } + additionalAssets = append(additionalAssets, matchesAsAssets...) + } + } + return additionalAssets, nil +} + +func replacePlaceholders(path string, placeholderMapping map[string]string) string { + Debug("Processing path: ", path) + newPath := path + for placeholder, replacement := range placeholderMapping { + newPath = strings.Replace(newPath, placeholder, replacement, -1) + } + Debug("Processed path: ", newPath) + return newPath +} + +func validateAsset(ACIAsset, localAsset string) error { + if !filepath.IsAbs(ACIAsset) { + return fmt.Errorf("Wrong ACI asset: '%v' - ACI asset has to be absolute path", ACIAsset) + } + if !filepath.IsAbs(localAsset) { + return fmt.Errorf("Wrong local asset: '%v' - local asset has to be absolute path", localAsset) + } + fi, err := os.Lstat(localAsset) + if err != nil { + return fmt.Errorf("Error stating %v: %v", localAsset, err) + } + mode := fi.Mode() + if mode.IsDir() || mode.IsRegular() || isSymlink(mode) { + return nil + } + return fmt.Errorf("Can't handle local asset %v - not a file, not a dir, not a symlink", fi.Name()) +} + +func copyTree(src, dest string) error { + return filepath.Walk(src, func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + rootLess := path[len(src):] + target := filepath.Join(dest, rootLess) + mode := info.Mode() + switch { + case mode.IsDir(): + err := os.Mkdir(target, mode.Perm()) + if err != nil { + return err + } + case mode.IsRegular(): + if err := copyRegularFile(path, target); err != nil { + return err + } + case isSymlink(mode): + if err := copySymlink(path, target); err != nil { + return err + } + default: + return fmt.Errorf("Unsupported node %q in assets, only regular files, directories and symlinks are supported.", path, mode.String()) + } + return nil + }) +} + +func copyRegularFile(src, dest string) error { + srcFile, err := os.Open(src) + if err != nil { + return err + } + defer srcFile.Close() + destFile, err := os.Create(dest) + if err != nil { + return err + } + defer destFile.Close() + if _, err := io.Copy(destFile, srcFile); err != nil { + return err + } + fi, err := srcFile.Stat() + if err != nil { + return err + } + if err := destFile.Chmod(fi.Mode().Perm()); err != nil { + return err + } + return nil +} + +func copySymlink(src, dest string) error { + symTarget, err := os.Readlink(src) + if err != nil { + return err + } + if err := os.Symlink(symTarget, dest); err != nil { + return err + } + return nil +} + +// getSoLibs tries to run ldd on given path and to process its output +// to get a list of shared libraries to copy. This list is returned as +// an array of assets. +// +// man ldd says that running ldd on untrusted executables is dangerous +// (it might run an executable to get the libraries), so possibly this +// should be replaced with objdump. Problem with objdump is that it +// just gives library names, while ldd gives absolute paths to those +// libraries - to use objdump we need to know the $libdir. +func getSoLibs(path string) ([]string, error) { + assets := []string{} + buf := new(bytes.Buffer) + args := []string{ + "ldd", + path, + } + if err := RunCmdFull("", args, nil, "", buf, nil); err != nil { + if _, ok := err.(CmdFailedError); !ok { + return nil, err + } + } else { + re := regexp.MustCompile(`(?m)^\t(?:\S+\s+=>\s+)?(\/\S+)\s+\([0-9a-fA-Fx]+\)$`) + for _, matches := range re.FindAllStringSubmatch(string(buf.Bytes()), -1) { + lib := matches[1] + if lib == "" { + continue + } + symlinkedAssets, err := getSymlinkedAssets(lib) + if err != nil { + return nil, err + } + assets = append(assets, symlinkedAssets...) + } + } + return assets, nil +} + +// getSymlinkedAssets returns an array of many assets if given path is +// a symlink - useful for getting shared libraries, which are often +// surrounded with a bunch of symlinks. +func getSymlinkedAssets(path string) ([]string, error) { + assets := []string{} + maxLevels := 100 + levels := maxLevels + for { + if levels < 1 { + return nil, fmt.Errorf("Too many levels of symlinks (>$d)", maxLevels) + } + fi, err := os.Lstat(path) + if err != nil { + return nil, err + } + asset := getAssetString(path, path) + assets = append(assets, asset) + if !isSymlink(fi.Mode()) { + break + } + symTarget, err := os.Readlink(path) + if err != nil { + return nil, err + } + if filepath.IsAbs(symTarget) { + path = symTarget + } else { + path = filepath.Join(filepath.Dir(path), symTarget) + } + levels-- + } + return assets, nil +} + +func getAssetString(aciAsset, localAsset string) string { + return fmt.Sprintf("%s%s%s", aciAsset, listSeparator(), localAsset) +} + +func isSymlink(mode os.FileMode) bool { + return mode&os.ModeSymlink == os.ModeSymlink +} diff --git a/vendor/github.com/appc/goaci/proj2aci/binary.go b/vendor/github.com/appc/goaci/proj2aci/binary.go new file mode 100644 index 0000000000..ee54f6c641 --- /dev/null +++ b/vendor/github.com/appc/goaci/proj2aci/binary.go @@ -0,0 +1,44 @@ +package proj2aci + +import ( + "fmt" + "io/ioutil" + "strings" +) + +// GetBinaryName checks if useBinary is in binDir and returns it. If +// useBinary is empty it returns a binary name if there is only one +// such in binDir. Otherwise it returns an error. +func GetBinaryName(binDir, useBinary string) (string, error) { + fi, err := ioutil.ReadDir(binDir) + if err != nil { + return "", err + } + + switch { + case len(fi) < 1: + return "", fmt.Errorf("No binaries found in %q", binDir) + case len(fi) == 1: + name := fi[0].Name() + if useBinary != "" && name != useBinary { + return "", fmt.Errorf("No such binary found in %q: %q. There is only %q", binDir, useBinary, name) + } + Debug("found binary: ", name) + return name, nil + case len(fi) > 1: + names := []string{} + for _, v := range fi { + names = append(names, v.Name()) + } + if useBinary == "" { + return "", fmt.Errorf("Found multiple binaries in %q, but no specific binary is preferred. Please specify which binary to pick up. Following binaries are available: %q", binDir, strings.Join(names, `", "`)) + } + for _, v := range names { + if v == useBinary { + return v, nil + } + } + return "", fmt.Errorf("No such binary found in %q: %q. There are following binaries available: %q", binDir, useBinary, strings.Join(names, `", "`)) + } + panic("Reaching this point shouldn't be possible.") +} diff --git a/vendor/github.com/appc/goaci/proj2aci/builder.go b/vendor/github.com/appc/goaci/proj2aci/builder.go new file mode 100644 index 0000000000..e512c572af --- /dev/null +++ b/vendor/github.com/appc/goaci/proj2aci/builder.go @@ -0,0 +1,365 @@ +package proj2aci + +import ( + "archive/tar" + "compress/gzip" + "fmt" + "io/ioutil" + "os" + "path/filepath" + "runtime" + + "github.com/appc/spec/aci" + "github.com/appc/spec/schema" + "github.com/appc/spec/schema/types" +) + +// CommonConfiguration keeps configuration items common for all the +// builders. Users of a Builder are supposed to create a +// BuilderCustomizations instance, get a CommonConfiguration instance +// via GetCommonConfiguration function and modify it before running +// Builder.Run(). +type CommonConfiguration struct { + Exec []string + UseBinary string + Assets []string + KeepTmpDir bool + TmpDir string + ReuseTmpDir string + Project string +} + +// CommonPaths keeps some paths common for all builders. Implementers +// of new BuilderCustomizations can read those after they are set up. +type CommonPaths struct { + TmpDir string + AciDir string + RootFS string +} + +// BuilderCustomizations is an interface for customizing a build +// process. The order of function roughly describe the build process. +type BuilderCustomizations interface { + Name() string + GetCommonConfiguration() *CommonConfiguration + ValidateConfiguration() error + GetCommonPaths() *CommonPaths + SetupPaths() error + GetDirectoriesToMake() []string + PrepareProject() error + GetPlaceholderMapping() map[string]string + GetAssets(aciBinDir string) ([]string, error) + GetImageName() (*types.ACIdentifier, error) + GetBinaryName() (string, error) + GetRepoPath() (string, error) + GetImageFileName() (string, error) +} + +type Builder struct { + manifest *schema.ImageManifest + aciBinDir string + custom BuilderCustomizations +} + +func NewBuilder(custom BuilderCustomizations) *Builder { + return &Builder{ + manifest: nil, + aciBinDir: "/", + custom: custom, + } +} + +func (cmd *Builder) Name() string { + return cmd.custom.Name() +} + +func (cmd *Builder) Run() error { + Info("Validating builder configuration") + if err := cmd.validateConfiguration(); err != nil { + return err + } + + Info("Setting up paths") + if err := cmd.setupPaths(); err != nil { + return err + } + + config := cmd.custom.GetCommonConfiguration() + paths := cmd.custom.GetCommonPaths() + if config.KeepTmpDir { + Info(fmt.Sprintf("Preserving temporary directory %q", paths.TmpDir)) + } else { + defer os.RemoveAll(paths.TmpDir) + } + + if config.ReuseTmpDir != "" { + Info("Reusing temporary directory") + Info("Deleting old ACI contents") + if err := os.RemoveAll(paths.AciDir); err != nil { + return err + } + + Info("Creating directories") + if err := cmd.makeDirectories(); err != nil { + return err + } + } else { + Info("Creating directories") + if err := cmd.makeDirectories(); err != nil { + return err + } + + Info("Preparing a project") + if err := cmd.prepareProject(); err != nil { + return err + } + } + + Info("Copying assets to ACI directory") + if err := cmd.copyAssets(); err != nil { + return err + } + + Info("Preparing manifest") + if err := cmd.prepareManifest(); err != nil { + return err + } + + Info("Writing ACI") + if name, err := cmd.writeACI(); err != nil { + return err + } else { + Info(fmt.Sprintf("Done, wrote %q", name)) + } + return nil +} + +func (cmd *Builder) validateConfiguration() error { + config := cmd.custom.GetCommonConfiguration() + if config == nil { + panic("common configuration is nil") + } + if config.Project == "" { + fmt.Errorf("Got no project to build") + } + + if config.TmpDir != "" && config.ReuseTmpDir != "" && config.TmpDir != config.ReuseTmpDir { + return fmt.Errorf("Specified both tmp dir to reuse and a tmp dir and they are different. ") + } + if !DirExists(config.ReuseTmpDir) { + return fmt.Errorf("Invalid tmp dir to reuse") + } + + return cmd.custom.ValidateConfiguration() +} + +func (cmd *Builder) setupPaths() error { + config := cmd.custom.GetCommonConfiguration() + paths := cmd.custom.GetCommonPaths() + tmpDir := "" + if config.TmpDir != "" { + tmpDir = config.TmpDir + } else if config.ReuseTmpDir != "" { + tmpDir = config.ReuseTmpDir + } else { + tmpName := fmt.Sprintf("proj2aci-%s-", cmd.custom.Name()) + aTmpDir, err := ioutil.TempDir("", tmpName) + if err != nil { + return fmt.Errorf("Failed to set up temporary directory: %v", err) + } + tmpDir = aTmpDir + } + paths.TmpDir = tmpDir + paths.AciDir = filepath.Join(paths.TmpDir, "aci") + paths.RootFS = filepath.Join(paths.AciDir, "rootfs") + return cmd.custom.SetupPaths() +} + +func (cmd *Builder) makeDirectories() error { + paths := cmd.custom.GetCommonPaths() + config := cmd.custom.GetCommonConfiguration() + + toMake := []string{} + if config.ReuseTmpDir == "" && config.TmpDir != "" { + tmpDirs, err := tmpDirList(paths.TmpDir) + if err != nil { + return err + } + toMake = append(toMake, tmpDirs...) + } + toMake = append(toMake, paths.AciDir, paths.RootFS) + if config.ReuseTmpDir == "" { + toMake = append(toMake, cmd.custom.GetDirectoriesToMake()...) + } + + for _, dir := range toMake { + Debug("mkdir ", dir) + if err := os.Mkdir(dir, 0755); err != nil { + return fmt.Errorf("Failed to make directory %q: %v", dir, err) + } + } + return nil +} + +func tmpDirList(path string) ([]string, error) { + list := []string{} + test := path + for { + if _, err := os.Stat(test); err != nil { + if !os.IsNotExist(err) { + return nil, err + } + // prepend + list = append([]string{test}, list...) + test = filepath.Dir(test) + } else { + break + } + } + return list, nil +} + +func (cmd *Builder) prepareProject() error { + return cmd.custom.PrepareProject() +} + +func (cmd *Builder) copyAssets() error { + paths := cmd.custom.GetCommonPaths() + config := cmd.custom.GetCommonConfiguration() + mapping := cmd.custom.GetPlaceholderMapping() + customAssets, err := cmd.custom.GetAssets(cmd.aciBinDir) + if err != nil { + return err + } + assets := append(config.Assets, customAssets...) + if err := PrepareAssets(assets, paths.RootFS, mapping); err != nil { + return err + } + return nil +} + +func (cmd *Builder) prepareManifest() error { + name, err := cmd.custom.GetImageName() + if err != nil { + return err + } + labels, err := cmd.getLabels() + if err != nil { + return err + } + app, err := cmd.getApp() + if err != nil { + return err + } + + cmd.manifest = schema.BlankImageManifest() + cmd.manifest.Name = *name + cmd.manifest.App = app + cmd.manifest.Labels = labels + return nil +} + +func (cmd *Builder) getApp() (*types.App, error) { + binaryName, err := cmd.custom.GetBinaryName() + if err != nil { + return nil, err + } + exec := []string{filepath.Join(cmd.aciBinDir, binaryName)} + config := cmd.custom.GetCommonConfiguration() + + return &types.App{ + Exec: append(exec, config.Exec...), + User: "0", + Group: "0", + }, nil +} + +func (cmd *Builder) getLabels() (types.Labels, error) { + arch, err := newLabel("arch", runtime.GOARCH) + if err != nil { + return nil, err + } + os, err := newLabel("os", runtime.GOOS) + if err != nil { + return nil, err + } + + labels := types.Labels{ + *arch, + *os, + } + + vcsLabel, err := cmd.getVCSLabel() + if err != nil { + return nil, err + } else if vcsLabel != nil { + labels = append(labels, *vcsLabel) + } + + return labels, nil +} + +func newLabel(name, value string) (*types.Label, error) { + acName, err := types.NewACIdentifier(name) + if err != nil { + return nil, err + } + return &types.Label{ + Name: *acName, + Value: value, + }, nil +} + +func (cmd *Builder) getVCSLabel() (*types.Label, error) { + repoPath, err := cmd.custom.GetRepoPath() + if err != nil { + return nil, err + } + if repoPath == "" { + return nil, nil + } + name, value, err := GetVCSInfo(repoPath) + if err != nil { + return nil, fmt.Errorf("Failed to get VCS info: %v", err) + } + acname, err := types.NewACIdentifier(name) + if err != nil { + return nil, fmt.Errorf("Invalid VCS label: %v", err) + } + return &types.Label{ + Name: *acname, + Value: value, + }, nil +} + +func (cmd *Builder) writeACI() (string, error) { + mode := os.O_CREATE | os.O_WRONLY | os.O_TRUNC + filename, err := cmd.custom.GetImageFileName() + if err != nil { + return "", err + } + of, err := os.OpenFile(filename, mode, 0644) + if err != nil { + return "", fmt.Errorf("Error opening output file: %v", err) + } + defer of.Close() + + gw := gzip.NewWriter(of) + defer gw.Close() + + tr := tar.NewWriter(gw) + defer tr.Close() + + // FIXME: the files in the tar archive are added with the + // wrong uid/gid. The uid/gid of the aci builder leaks in the + // tar archive. See: https://github.com/appc/goaci/issues/16 + iw := aci.NewImageWriter(*cmd.manifest, tr) + paths := cmd.custom.GetCommonPaths() + if err := filepath.Walk(paths.AciDir, aci.BuildWalker(paths.AciDir, iw, nil)); err != nil { + return "", err + } + if err := iw.Close(); err != nil { + return "", err + } + return of.Name(), nil +} diff --git a/vendor/github.com/appc/goaci/proj2aci/cmake.go b/vendor/github.com/appc/goaci/proj2aci/cmake.go new file mode 100644 index 0000000000..e8dea907d0 --- /dev/null +++ b/vendor/github.com/appc/goaci/proj2aci/cmake.go @@ -0,0 +1,234 @@ +package proj2aci + +import ( + "fmt" + "os" + "path/filepath" + "runtime" + "strings" + + "github.com/appc/spec/schema" + "github.com/appc/spec/schema/types" + + "golang.org/x/tools/go/vcs" +) + +type CmakeConfiguration struct { + CommonConfiguration + BinDir string + ReuseSrcDir string + CmakeParams []string +} + +type CmakePaths struct { + CommonPaths + src string + build string + install string + binDir string +} + +type CmakeCustomizations struct { + Configuration CmakeConfiguration + + paths CmakePaths + fullBinPath string +} + +func (custom *CmakeCustomizations) Name() string { + return "cmake" +} + +func (custom *CmakeCustomizations) GetCommonConfiguration() *CommonConfiguration { + return &custom.Configuration.CommonConfiguration +} + +func (custom *CmakeCustomizations) ValidateConfiguration() error { + if !DirExists(custom.Configuration.ReuseSrcDir) { + return fmt.Errorf("Invalid src dir to reuse") + } + return nil +} + +func (custom *CmakeCustomizations) GetCommonPaths() *CommonPaths { + return &custom.paths.CommonPaths +} + +func (custom *CmakeCustomizations) SetupPaths() error { + setupReusableDir(&custom.paths.src, custom.Configuration.ReuseSrcDir, filepath.Join(custom.paths.TmpDir, "src")) + custom.paths.build = filepath.Join(custom.paths.TmpDir, "build") + custom.paths.install = filepath.Join(custom.paths.TmpDir, "install") + return nil +} + +func setupReusableDir(path *string, reusePath, stockPath string) { + if path == nil { + panic("path in setupReusableDir cannot be nil") + } + if reusePath != "" { + *path = reusePath + } else { + *path = stockPath + } +} + +func (custom *CmakeCustomizations) GetDirectoriesToMake() []string { + dirs := []string{ + custom.paths.build, + custom.paths.install, + } + // not creating custom.paths.src, because go.vcs requires the + // src directory to be nonexistent + return dirs +} + +func (custom *CmakeCustomizations) PrepareProject() error { + if custom.Configuration.ReuseSrcDir == "" { + if err := custom.createRepo(); err != nil { + return err + } + } + + Info("Running cmake") + if err := custom.runCmake(); err != nil { + return err + } + + Info("Running make") + if err := custom.runMake(); err != nil { + return err + } + + Info("Running make install") + if err := custom.runMakeInstall(); err != nil { + return err + } + + return nil +} + +func (custom *CmakeCustomizations) createRepo() error { + Info(fmt.Sprintf("Downloading %s", custom.Configuration.Project)) + repo, err := vcs.RepoRootForImportPath(custom.Configuration.Project, false) + if err != nil { + return err + } + return repo.VCS.Create(custom.paths.src, repo.Repo) +} + +func (custom *CmakeCustomizations) runCmake() error { + args := []string{"cmake"} + args = append(args, custom.Configuration.CmakeParams...) + args = append(args, custom.paths.src) + return RunCmd(args, nil, custom.paths.build) +} + +func (custom *CmakeCustomizations) runMake() error { + args := []string{ + "make", + fmt.Sprintf("-j%d", runtime.NumCPU()), + } + return RunCmd(args, nil, custom.paths.build) +} + +func (custom *CmakeCustomizations) runMakeInstall() error { + args := []string{ + "make", + "install", + } + env := append(os.Environ(), "DESTDIR="+custom.paths.install) + return RunCmd(args, env, custom.paths.build) +} + +func (custom *CmakeCustomizations) GetPlaceholderMapping() map[string]string { + return map[string]string{ + "": custom.paths.src, + "": custom.paths.build, + "": custom.paths.install, + } +} + +func (custom *CmakeCustomizations) GetAssets(aciBinDir string) ([]string, error) { + binaryName, err := custom.GetBinaryName() + if err != nil { + return nil, err + } + rootBinary := filepath.Join(aciBinDir, binaryName) + return []string{GetAssetString(rootBinary, custom.fullBinPath)}, nil +} + +func (custom *CmakeCustomizations) getBinDir() (string, error) { + if custom.Configuration.BinDir != "" { + return filepath.Join(custom.paths.install, custom.Configuration.BinDir), nil + } + dirs := []string{ + "/usr/local/sbin", + "/usr/local/bin", + "/usr/sbin", + "/usr/bin", + "/sbin", + "/bin", + } + for _, dir := range dirs { + path := filepath.Join(custom.paths.install, dir) + _, err := os.Stat(path) + if err != nil { + if os.IsNotExist(err) { + continue + } + return "", err + } + return path, nil + } + return "", fmt.Errorf("Could not find any bin directory") +} + +func (custom *CmakeCustomizations) GetImageName() (*types.ACIdentifier, error) { + imageName := custom.Configuration.Project + if filepath.Base(imageName) == "..." { + imageName = filepath.Dir(imageName) + if custom.Configuration.UseBinary != "" { + imageName += "-" + custom.Configuration.UseBinary + } + } + return types.NewACIdentifier(strings.ToLower(imageName)) +} + +func (custom *CmakeCustomizations) GetBinaryName() (string, error) { + if err := custom.findFullBinPath(); err != nil { + return "", err + } + + return filepath.Base(custom.fullBinPath), nil +} + +func (custom *CmakeCustomizations) findFullBinPath() error { + if custom.fullBinPath != "" { + return nil + } + binDir, err := custom.getBinDir() + if err != nil { + return err + } + binary, err := GetBinaryName(binDir, custom.Configuration.UseBinary) + if err != nil { + return err + } + custom.fullBinPath = filepath.Join(binDir, binary) + return nil +} + +func (custom *CmakeCustomizations) GetRepoPath() (string, error) { + return custom.paths.src, nil +} + +func (custom *CmakeCustomizations) GetImageFileName() (string, error) { + base := filepath.Base(custom.Configuration.Project) + if base == "..." { + base = filepath.Base(filepath.Dir(custom.Configuration.Project)) + if custom.Configuration.UseBinary != "" { + base += "-" + custom.Configuration.UseBinary + } + } + return base + schema.ACIExtension, nil +} diff --git a/vendor/github.com/appc/goaci/proj2aci/go.go b/vendor/github.com/appc/goaci/proj2aci/go.go new file mode 100644 index 0000000000..2ebed255a4 --- /dev/null +++ b/vendor/github.com/appc/goaci/proj2aci/go.go @@ -0,0 +1,195 @@ +package proj2aci + +import ( + "fmt" + "os" + "os/exec" + "path/filepath" + "strings" + + "github.com/appc/spec/schema" + "github.com/appc/spec/schema/types" +) + +type GoConfiguration struct { + CommonConfiguration + GoBinary string + GoPath string +} + +type GoPaths struct { + CommonPaths + project string + realGo string + fakeGo string + goRoot string + goBin string +} + +type GoCustomizations struct { + Configuration GoConfiguration + + paths GoPaths + app string +} + +func (custom *GoCustomizations) Name() string { + return "go" +} + +func (custom *GoCustomizations) GetCommonConfiguration() *CommonConfiguration { + return &custom.Configuration.CommonConfiguration +} + +func (custom *GoCustomizations) GetCommonPaths() *CommonPaths { + return &custom.paths.CommonPaths +} + +func (custom *GoCustomizations) ValidateConfiguration() error { + if custom.Configuration.GoBinary == "" { + return fmt.Errorf("Go binary not found") + } + return nil +} + +func (custom *GoCustomizations) SetupPaths() error { + custom.paths.realGo, custom.paths.fakeGo = custom.getGoPath() + + if os.Getenv("GOPATH") != "" { + Warn("GOPATH env var is ignored, use --go-path=\"$GOPATH\" option instead") + } + custom.paths.goRoot = os.Getenv("GOROOT") + if custom.paths.goRoot != "" { + Warn("Overriding GOROOT env var to ", custom.paths.goRoot) + } + + projectName := getProjectName(custom.Configuration.Project) + // Project name is path-like string with slashes, but slash is + // not a file separator on every OS. + custom.paths.project = filepath.Join(custom.paths.realGo, "src", filepath.Join(strings.Split(projectName, "/")...)) + custom.paths.goBin = filepath.Join(custom.paths.fakeGo, "bin") + return nil +} + +// getGoPath returns go path and fake go path. The former is either in +// /tmp (which is a default) or some other path as specified by +// --go-path parameter. The latter is always in /tmp. +func (custom *GoCustomizations) getGoPath() (string, string) { + fakeGoPath := filepath.Join(custom.paths.TmpDir, "gopath") + if custom.Configuration.GoPath == "" { + return fakeGoPath, fakeGoPath + } + return custom.Configuration.GoPath, fakeGoPath +} + +func getProjectName(project string) string { + if filepath.Base(project) != "..." { + return project + } + return filepath.Dir(project) +} + +func (custom *GoCustomizations) GetDirectoriesToMake() []string { + return []string{ + custom.paths.fakeGo, + custom.paths.goBin, + } +} + +func (custom *GoCustomizations) PrepareProject() error { + Info("Running go get") + // Construct args for a go get that does a static build + args := []string{ + "go", + "get", + "-a", + custom.Configuration.Project, + } + + env := []string{ + "GOPATH=" + custom.paths.realGo, + "GOBIN=" + custom.paths.goBin, + "PATH=" + os.Getenv("PATH"), + } + if custom.paths.goRoot != "" { + env = append(env, "GOROOT="+custom.paths.goRoot) + } + + cmd := exec.Cmd{ + Env: env, + Path: custom.Configuration.GoBinary, + Args: args, + Stderr: os.Stderr, + Stdout: os.Stdout, + } + Debug("env: ", cmd.Env) + Debug("running command: ", strings.Join(cmd.Args, " ")) + if err := cmd.Run(); err != nil { + return err + } + return nil +} + +func (custom *GoCustomizations) GetPlaceholderMapping() map[string]string { + return map[string]string{ + "": custom.paths.project, + "": custom.paths.realGo, + } +} + +func (custom *GoCustomizations) GetAssets(aciBinDir string) ([]string, error) { + name, err := custom.GetBinaryName() + if err != nil { + return nil, err + } + aciAsset := filepath.Join(aciBinDir, name) + localAsset := filepath.Join(custom.paths.goBin, name) + + return []string{GetAssetString(aciAsset, localAsset)}, nil +} + +func (custom *GoCustomizations) GetImageName() (*types.ACIdentifier, error) { + imageName := custom.Configuration.Project + if filepath.Base(imageName) == "..." { + imageName = filepath.Dir(imageName) + if custom.Configuration.UseBinary != "" { + imageName += "-" + custom.Configuration.UseBinary + } + } + return types.NewACIdentifier(strings.ToLower(imageName)) +} + +func (custom *GoCustomizations) GetBinaryName() (string, error) { + if err := custom.findBinaryName(); err != nil { + return "", err + } + + return custom.app, nil +} + +func (custom *GoCustomizations) findBinaryName() error { + if custom.app != "" { + return nil + } + binaryName, err := GetBinaryName(custom.paths.goBin, custom.Configuration.UseBinary) + if err != nil { + return err + } + custom.app = binaryName + return nil +} + +func (custom *GoCustomizations) GetRepoPath() (string, error) { + return custom.paths.project, nil +} + +func (custom *GoCustomizations) GetImageFileName() (string, error) { + base := filepath.Base(custom.Configuration.Project) + if base == "..." { + base = filepath.Base(filepath.Dir(custom.Configuration.Project)) + if custom.Configuration.UseBinary != "" { + base += "-" + custom.Configuration.UseBinary + } + } + return base + schema.ACIExtension, nil +} diff --git a/vendor/github.com/appc/goaci/proj2aci/run.go b/vendor/github.com/appc/goaci/proj2aci/run.go new file mode 100644 index 0000000000..532990f30d --- /dev/null +++ b/vendor/github.com/appc/goaci/proj2aci/run.go @@ -0,0 +1,65 @@ +package proj2aci + +import ( + "fmt" + "io" + "os" + "os/exec" + "strings" +) + +type CmdFailedError struct { + Err error +} + +func (e CmdFailedError) Error() string { + return fmt.Sprintf("CmdFailedError: %s", e.Err.Error()) +} + +type CmdNotFoundError struct { + Err error +} + +func (e CmdNotFoundError) Error() string { + return fmt.Sprintf("CmdNotFoundError: %s", e.Err.Error()) +} + +// RunCmdFull runs given execProg. execProg should be an absolute path +// to a program or it can be an empty string. In the latter case first +// string in args is taken and searched for in $PATH. +// +// If execution fails then CmdFailedError is returned. This can be +// useful if we don't care if execution fails or not. CmdNotFoundError +// is returned if executable is not found. +func RunCmdFull(execProg string, args, env []string, cwd string, stdout, stderr io.Writer) error { + if len(args) < 1 { + return fmt.Errorf("No args to execute passed") + } + prog := execProg + if prog == "" { + pathProg, err := exec.LookPath(args[0]) + if err != nil { + return CmdNotFoundError{err} + } + prog = pathProg + } else if _, err := os.Stat(prog); err != nil { + return CmdNotFoundError{err} + } + cmd := exec.Cmd{ + Path: prog, + Args: args, + Env: env, + Dir: cwd, + Stdout: stdout, + Stderr: stderr, + } + Debug(`running command: "`, strings.Join(args, `" "`), `"`) + if err := cmd.Run(); err != nil { + return CmdFailedError{err} + } + return nil +} + +func RunCmd(args, env []string, cwd string) error { + return RunCmdFull("", args, env, cwd, os.Stdout, os.Stderr) +} diff --git a/vendor/github.com/appc/goaci/proj2aci/util.go b/vendor/github.com/appc/goaci/proj2aci/util.go new file mode 100644 index 0000000000..177c28c805 --- /dev/null +++ b/vendor/github.com/appc/goaci/proj2aci/util.go @@ -0,0 +1,68 @@ +package proj2aci + +import ( + "fmt" + "io" + "os" + "path/filepath" + "strings" + "unicode/utf8" +) + +var debugEnabled bool +var pathListSep string + +// DirExists checks if directory exists if given path is not empty. +// +// This function is rather specific as it is mostly used for checking +// overrides validity (like overriding temporary directory, where +// empty string means "do not override"). +func DirExists(path string) bool { + if path != "" { + fi, err := os.Stat(path) + if err != nil || !fi.IsDir() { + return false + } + } + return true +} + +func printTo(w io.Writer, i ...interface{}) { + s := fmt.Sprint(i...) + fmt.Fprintln(w, strings.TrimSuffix(s, "\n")) +} + +func Warn(i ...interface{}) { + printTo(os.Stderr, i...) +} + +func Info(i ...interface{}) { + printTo(os.Stdout, i...) +} + +func Debug(i ...interface{}) { + if debugEnabled { + printTo(os.Stdout, i...) + } +} + +func InitDebug() { + if os.Getenv("GOACI_DEBUG") != "" { + debugEnabled = true + } +} + +// listSeparator returns filepath.ListSeparator rune as a string. +func listSeparator() string { + if pathListSep == "" { + len := utf8.RuneLen(filepath.ListSeparator) + if len < 0 { + panic("filepath.ListSeparator is not valid utf8?!") + } + buf := make([]byte, len) + len = utf8.EncodeRune(buf, filepath.ListSeparator) + pathListSep = string(buf[:len]) + } + + return pathListSep +} diff --git a/vendor/github.com/appc/goaci/proj2aci/vcs.go b/vendor/github.com/appc/goaci/proj2aci/vcs.go new file mode 100644 index 0000000000..8a6d88b860 --- /dev/null +++ b/vendor/github.com/appc/goaci/proj2aci/vcs.go @@ -0,0 +1,118 @@ +package proj2aci + +import ( + "bytes" + "fmt" + "os" + "os/exec" + "path/filepath" + "strings" +) + +func repoDirExists(projPath, repoDir string) bool { + path := filepath.Join(projPath, repoDir) + info, err := os.Stat(path) + if err != nil { + return false + } + return info.IsDir() +} + +// getId gets first line of commands output which should hold some VCS +// specific id of current code checkout. +func getId(dir, cmd string, params []string) (string, error) { + args := []string{cmd} + args = append(args, params...) + buffer := new(bytes.Buffer) + cmdPath, err := exec.LookPath(cmd) + if err != nil { + return "", nil + } + process := &exec.Cmd{ + Path: cmdPath, + Args: args, + Env: []string{ + "PATH=" + os.Getenv("PATH"), + }, + Dir: dir, + Stdout: buffer, + } + if err := process.Run(); err != nil { + return "", err + } + output := string(buffer.Bytes()) + if newline := strings.Index(output, "\n"); newline < 0 { + return output, nil + } else { + return output[:newline], nil + } +} + +func getLabelAndId(label, path, cmd string, params []string) (string, string, error) { + if info, err := getId(path, cmd, params); err != nil { + return "", "", err + } else { + return label, info, nil + } +} + +type VCSInfo interface { + IsValid(path string) bool + GetLabelAndId(path string) (string, string, error) +} + +type GitInfo struct{} + +func (info GitInfo) IsValid(path string) bool { + return repoDirExists(path, ".git") +} + +func (info GitInfo) GetLabelAndId(path string) (string, string, error) { + return getLabelAndId("git", path, "git", []string{"rev-parse", "HEAD"}) +} + +type HgInfo struct{} + +func (info HgInfo) IsValid(path string) bool { + return repoDirExists(path, ".hg") +} + +func (info HgInfo) GetLabelAndId(path string) (string, string, error) { + return getLabelAndId("hg", path, "hg", []string{"id", "-i"}) +} + +type SvnInfo struct{} + +func (info SvnInfo) IsValid(path string) bool { + return repoDirExists(path, ".svn") +} + +func (info SvnInfo) GetLabelAndId(path string) (string, string, error) { + return getLabelAndId("svn", path, "svnversion", []string{}) +} + +type BzrInfo struct{} + +func (info BzrInfo) IsValid(path string) bool { + return repoDirExists(path, ".bzr") +} + +func (info BzrInfo) GetLabelAndId(path string) (string, string, error) { + return getLabelAndId("bzr", path, "bzr", []string{"revno"}) +} + +func GetVCSInfo(projPath string) (string, string, error) { + vcses := []VCSInfo{ + GitInfo{}, + HgInfo{}, + SvnInfo{}, + BzrInfo{}, + } + + for _, vcs := range vcses { + if vcs.IsValid(projPath) { + return vcs.GetLabelAndId(projPath) + } + } + return "", "", fmt.Errorf("Unknown code repository in %q", projPath) +} diff --git a/vendor/github.com/appc/spec/LICENSE b/vendor/github.com/appc/spec/LICENSE new file mode 100644 index 0000000000..e06d208186 --- /dev/null +++ b/vendor/github.com/appc/spec/LICENSE @@ -0,0 +1,202 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor 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, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/vendor/github.com/appc/spec/ace/doc.go b/vendor/github.com/appc/spec/ace/doc.go new file mode 100644 index 0000000000..476f2c9557 --- /dev/null +++ b/vendor/github.com/appc/spec/ace/doc.go @@ -0,0 +1,19 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package ace contains a tool intended to be run within an _Application +// Container Executor_ to validate that the ACE has set up the container +// environment correctly. This tool can be built into an ACI image ready for +// running on an executor by using the `build_aci` script. +package main diff --git a/vendor/github.com/appc/spec/ace/image_manifest_main.json.in b/vendor/github.com/appc/spec/ace/image_manifest_main.json.in new file mode 100644 index 0000000000..33157eeead --- /dev/null +++ b/vendor/github.com/appc/spec/ace/image_manifest_main.json.in @@ -0,0 +1,80 @@ +{ + "acVersion": "0.8.4", + "acKind": "ImageManifest", + "name": "coreos.com/ace-validator-main", + "labels": [ + { "name": "version", "value": "0.8.4" }, + { "name": "os", "value": "@GOOS@" }, + { "name": "arch", "value": "@GOARCH@" } + ], + "app": { + "exec": [ + "/ace-validator", "main" + ], + "eventHandlers": [ + { + "name": "pre-start", + "exec": [ + "/ace-validator", "prestart" + ] + }, + { + "name": "post-stop", + "exec": [ + "/ace-validator", "poststop" + ] + } + ], + "user": "0", + "group": "0", + "workingDirectory": "/opt/acvalidator", + "environment": [ + { + "name": "IN_ACE_VALIDATOR", + "value": "correct" + } + ], + "mountPoints": [ + { + "name": "database", + "path": "/db", + "readOnly": false + } + ], + "ports": [ + { + "name": "www", + "protocol": "tcp", + "port": 80 + } + ], + "isolators": [ + { + "name": "resource/memory", + "value": {"limit": "1G"} + } + ] + }, + "annotations": [ + { + "name": "created", + "value": "2014-10-27T19:32:27.67021798Z" + }, + { + "name": "authors", + "value": "Carly Container , Nat Network " + }, + { + "name": "homepage", + "value": "https://github.com/appc/spec" + }, + { + "name": "documentation", + "value": "https://github.com/appc/spec/blob/master/README.md" + }, + { + "name": "lorem", + "value": "ipsum" + } + ] +} diff --git a/vendor/github.com/appc/spec/ace/image_manifest_sidekick.json.in b/vendor/github.com/appc/spec/ace/image_manifest_sidekick.json.in new file mode 100644 index 0000000000..a69bbcf66b --- /dev/null +++ b/vendor/github.com/appc/spec/ace/image_manifest_sidekick.json.in @@ -0,0 +1,24 @@ +{ + "acVersion": "0.8.4", + "acKind": "ImageManifest", + "name": "coreos.com/ace-validator-sidekick", + "labels": [ + { "name": "version", "value": "0.8.4" }, + { "name": "os", "value": "@GOOS@" }, + { "name": "arch", "value": "@GOARCH@" } + ], + "app": { + "exec": [ + "/ace-validator", "sidekick" + ], + "user": "0", + "group": "0", + "mountPoints": [ + { + "name": "database", + "path": "/db", + "readOnly": false + } + ] + } +} diff --git a/vendor/github.com/appc/spec/ace/os_default.go b/vendor/github.com/appc/spec/ace/os_default.go new file mode 100644 index 0000000000..4810d4368f --- /dev/null +++ b/vendor/github.com/appc/spec/ace/os_default.go @@ -0,0 +1,26 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build !linux +// +build !freebsd + +package main + +import ( + "syscall" +) + +func isSameFilesystem(a, b *syscall.Statfs_t) bool { + return a.Fsid == b.Fsid +} diff --git a/vendor/github.com/appc/spec/ace/os_freebsd.go b/vendor/github.com/appc/spec/ace/os_freebsd.go new file mode 100644 index 0000000000..ec7ad0419f --- /dev/null +++ b/vendor/github.com/appc/spec/ace/os_freebsd.go @@ -0,0 +1,32 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build freebsd + +package main + +import ( + "syscall" +) + +func isSameFilesystem(a, b *syscall.Statfs_t) bool { + if a.Fsid != (syscall.Fsid{}) || b.Fsid != (syscall.Fsid{}) { + // If Fsid is not empty, we can just compare the IDs + return a.Fsid == b.Fsid + } + // Fsids are zero, this happens in jails, but we can compare the rest + return a.Fstypename == b.Fstypename && + a.Mntfromname == b.Mntfromname && + a.Mntonname == b.Mntonname +} diff --git a/vendor/github.com/appc/spec/ace/os_linux.go b/vendor/github.com/appc/spec/ace/os_linux.go new file mode 100644 index 0000000000..aedfc3ad59 --- /dev/null +++ b/vendor/github.com/appc/spec/ace/os_linux.go @@ -0,0 +1,45 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build linux + +package main + +import ( + "fmt" + "os" +) + +func checkMountImpl(d string, readonly bool) error { + mountinfoPath := fmt.Sprintf("/proc/self/mountinfo") + mi, err := os.Open(mountinfoPath) + if err != nil { + return err + } + defer mi.Close() + + isMounted, ro, err := parseMountinfo(mi, d) + if err != nil { + return err + } + if !isMounted { + return fmt.Errorf("%q is not a mount point", d) + } + + if ro == readonly { + return nil + } else { + return fmt.Errorf("%q mounted ro=%t, want %t", d, ro, readonly) + } +} diff --git a/vendor/github.com/appc/spec/ace/os_shared.go b/vendor/github.com/appc/spec/ace/os_shared.go new file mode 100644 index 0000000000..93964c3b12 --- /dev/null +++ b/vendor/github.com/appc/spec/ace/os_shared.go @@ -0,0 +1,35 @@ +// +build !linux + +package main + +import ( + "fmt" + "path/filepath" + "syscall" +) + +func checkMountStatfs(d string, readonly bool) error { + // or.... + // os.Stat(path).Sys().(*syscall.Stat_t).Dev + sfs1 := &syscall.Statfs_t{} + if err := syscall.Statfs(d, sfs1); err != nil { + return fmt.Errorf("error calling statfs on %q: %v", d, err) + } + sfs2 := &syscall.Statfs_t{} + if err := syscall.Statfs(filepath.Dir(d), sfs2); err != nil { + return fmt.Errorf("error calling statfs on %q: %v", d, err) + } + if isSameFilesystem(sfs1, sfs2) { + return fmt.Errorf("%q is not a mount point", d) + } + ro := sfs1.Flags&syscall.O_RDONLY == 1 + if ro != readonly { + return fmt.Errorf("%q mounted ro=%t, want %t", d, ro, readonly) + } + + return nil +} + +func checkMountImpl(d string, readonly bool) error { + return checkMountStatfs(d, readonly) +} diff --git a/vendor/github.com/appc/spec/ace/validator.go b/vendor/github.com/appc/spec/ace/validator.go new file mode 100644 index 0000000000..fdd27ac222 --- /dev/null +++ b/vendor/github.com/appc/spec/ace/validator.go @@ -0,0 +1,578 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +/* + +This validator tool is intended to be run within an App Container Executor +(ACE), and verifies that the ACE has been set up correctly. + +This verifies the _apps perspective_ of the execution environment. + +Changes to the validator need to be reflected in app_manifest.json, and vice-versa + +The App Container Execution spec defines the following expectations within the execution environment: + - Working Directory defaults to the root of the application image, overridden with "workingDirectory" + - PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + - USER, LOGNAME username of the user executing this app + - HOME home directory of the user + - SHELL login shell of the user + - AC_APP_NAME the entrypoint that this process was defined from + +In addition, we validate: + - The expected mount points are mounted + - metadata service reachable at http://169.254.169.255 + +TODO(jonboulle): + - should we validate Isolators? (e.g. MemoryLimit + malloc, or capabilities) + - should we validate ports? (e.g. that they are available to bind to within the network namespace of the pod) + +*/ + +import ( + "bufio" + "bytes" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "net/http" + "net/url" + "os" + "reflect" + "strings" + "time" + + "github.com/appc/spec/schema" + "github.com/appc/spec/schema/types" +) + +const ( + standardPath = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + appNameEnv = "AC_APP_NAME" + metadataPathBase = "/acMetadata/v1" + + // marker files to validate + prestartFile = "/prestart" + mainFile = "/main" + poststopFile = "/poststop" + + mainVolFile = "/db/main" + sidekickVolFile = "/db/sidekick" + + timeout = 5 * time.Second +) + +var ( + // Expected values must be kept in sync with app_manifest.json + workingDirectory = "/opt/acvalidator" + // "Environment" + env = map[string]string{ + "IN_ACE_VALIDATOR": "correct", + "HOME": "/root", + "USER": "root", + "LOGNAME": "root", + "SHELL": "/bin/sh", + } + // "MountPoints" + mps = map[string]types.MountPoint{ + "database": types.MountPoint{ + Path: "/db", + ReadOnly: false, + }, + } + // "Name" + an = "ace-validator-main" +) + +type results []error + +// main outputs diagnostic information to stderr and exits 1 if validation fails +func main() { + if len(os.Args) != 2 { + stderr("usage: %s [main|sidekick|preStart|postStop]", os.Args[0]) + os.Exit(64) + } + mode := os.Args[1] + var res results + switch strings.ToLower(mode) { + case "main": + res = validateMain() + case "sidekick": + res = validateSidekick() + case "prestart": + res = validatePrestart() + case "poststop": + res = validatePoststop() + default: + stderr("unrecognized mode: %s", mode) + os.Exit(64) + } + if len(res) == 0 { + fmt.Printf("%s OK\n", mode) + os.Exit(0) + } + fmt.Printf("%s FAIL\n", mode) + for _, err := range res { + fmt.Fprintln(os.Stderr, "==>", err) + } + os.Exit(1) +} + +func validateMain() (errs results) { + errs = append(errs, assertExists(prestartFile)...) + errs = append(errs, assertNotExistsAndCreate(mainFile)...) + errs = append(errs, assertNotExists(poststopFile)...) + errs = append(errs, ValidatePath(standardPath)...) + errs = append(errs, ValidateWorkingDirectory(workingDirectory)...) + errs = append(errs, ValidateEnvironment(env)...) + errs = append(errs, ValidateMountpoints(mps)...) + errs = append(errs, ValidateAppNameEnv(an)...) + errs = append(errs, ValidateMetadataSvc()...) + errs = append(errs, waitForFile(sidekickVolFile, timeout)...) + errs = append(errs, assertNotExistsAndCreate(mainVolFile)...) + return +} + +func validateSidekick() (errs results) { + errs = append(errs, assertNotExistsAndCreate(sidekickVolFile)...) + errs = append(errs, waitForFile(mainVolFile, timeout)...) + return +} + +func validatePrestart() (errs results) { + errs = append(errs, assertNotExistsAndCreate(prestartFile)...) + errs = append(errs, assertNotExists(mainFile)...) + errs = append(errs, assertNotExists(poststopFile)...) + return +} + +func validatePoststop() (errs results) { + errs = append(errs, assertExists(prestartFile)...) + errs = append(errs, assertExists(mainFile)...) + errs = append(errs, assertNotExistsAndCreate(poststopFile)...) + return +} + +// ValidatePath ensures that the PATH has been set up correctly within the +// environment in which this process is being run +func ValidatePath(wp string) results { + r := results{} + gp := os.Getenv("PATH") + if wp != gp { + r = append(r, fmt.Errorf("PATH not set appropriately (need %q, got %q)", wp, gp)) + } + return r +} + +// ValidateWorkingDirectory ensures that the process working directory is set +// to the desired path. +func ValidateWorkingDirectory(wwd string) (r results) { + gwd, err := os.Getwd() + if err != nil { + r = append(r, fmt.Errorf("error getting working directory: %v", err)) + return + } + if gwd != wwd { + r = append(r, fmt.Errorf("working directory not set appropriately (need %q, got %v)", wwd, gwd)) + } + return +} + +// ValidateEnvironment ensures that the given environment contains the +// necessary/expected environment variables. +func ValidateEnvironment(wenv map[string]string) (r results) { + for wkey, wval := range wenv { + gval := os.Getenv(wkey) + if gval != wval { + err := fmt.Errorf("environment variable %q not set appropriately (need %q, got %q)", wkey, wval, gval) + r = append(r, err) + } + } + return +} + +// ValidateAppNameEnv ensures that the environment variable specifying the +// entrypoint of this process is set correctly. +func ValidateAppNameEnv(want string) (r results) { + if got := os.Getenv(appNameEnv); got != want { + r = append(r, fmt.Errorf("%s not set appropriately (need %q, got %q)", appNameEnv, want, got)) + } + return +} + +// ValidateMountpoints ensures that the given mount points are present in the +// environment in which this process is running +func ValidateMountpoints(wmp map[string]types.MountPoint) results { + r := results{} + // TODO(jonboulle): verify actual source + for _, mp := range wmp { + if err := checkMount(mp.Path, mp.ReadOnly); err != nil { + r = append(r, err) + } + } + return r +} + +func metadataRequest(req *http.Request, expectedContentType string) ([]byte, error) { + cli := http.Client{ + Timeout: 100 * time.Millisecond, + } + + req.Header["Metadata-Flavor"] = []string{"AppContainer"} + + resp, err := cli.Do(req) + if err != nil { + return nil, err + } + + if resp.StatusCode != 200 { + return nil, fmt.Errorf("Get %s failed with %v", req.URL, resp.StatusCode) + } + + if respContentType := resp.Header.Get("Content-Type"); respContentType != expectedContentType { + return nil, fmt.Errorf("`%v` did not respond with expected Content-Type header. Expected %s, received %s", + req.URL, expectedContentType, respContentType) + } + + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil, fmt.Errorf("Get %s failed on body read: %v", req.URL, err) + } + + return body, nil +} + +func metadataGet(metadataURL, path string, expectedContentType string) ([]byte, error) { + uri := metadataURL + metadataPathBase + path + req, err := http.NewRequest("GET", uri, nil) + if err != nil { + panic(err) + } + + return metadataRequest(req, expectedContentType) +} + +func metadataPost(metadataURL, path string, body []byte, expectedContentType string) ([]byte, error) { + uri := metadataURL + metadataPathBase + path + req, err := http.NewRequest("POST", uri, bytes.NewBuffer(body)) + if err != nil { + panic(err) + } + req.Header.Set("Content-Type", "text/plain") + + return metadataRequest(req, expectedContentType) +} + +func metadataPostForm(metadataURL, path string, data url.Values, expectedContentType string) ([]byte, error) { + uri := metadataURL + metadataPathBase + path + req, err := http.NewRequest("POST", uri, strings.NewReader(data.Encode())) + if err != nil { + panic(err) + } + req.Header.Set("Content-Type", "application/x-www-form-urlencoded") + + return metadataRequest(req, expectedContentType) +} + +func validatePodAnnotations(metadataURL string, pm *schema.PodManifest) results { + r := results{} + + var actualAnnots types.Annotations + + annotJson, err := metadataGet(metadataURL, "/pod/annotations", "application/json") + if err != nil { + return append(r, err) + } + + err = json.Unmarshal(annotJson, &actualAnnots) + if err != nil { + return append(r, err) + } + + if !reflect.DeepEqual(actualAnnots, pm.Annotations) { + r = append(r, fmt.Errorf("pod annotations mismatch: %v vs %v", actualAnnots, pm.Annotations)) + } + + return r +} + +func validatePodMetadata(metadataURL string, pm *schema.PodManifest) results { + r := results{} + + uuid, err := metadataGet(metadataURL, "/pod/uuid", "text/plain; charset=us-ascii") + if err != nil { + return append(r, err) + } + + _, err = types.NewUUID(string(uuid)) + if err != nil { + return append(r, fmt.Errorf("malformed UUID returned (%v): %v", string(uuid), err)) + } + + return append(r, validatePodAnnotations(metadataURL, pm)...) +} + +func validateAppAnnotations(metadataURL string, pm *schema.PodManifest, app *schema.RuntimeApp, img *schema.ImageManifest) results { + r := results{} + + // build a map of expected annotations by merging app.Annotations + // with PodManifest overrides + expectedAnnots := app.Annotations + a := pm.Apps.Get(app.Name) + if a == nil { + panic("could not find app in manifest!") + } + for _, annot := range a.Annotations { + expectedAnnots.Set(annot.Name, annot.Value) + } + if len(expectedAnnots) == 0 { + expectedAnnots = nil + } + + var actualAnnots types.Annotations + + annotJson, err := metadataGet(metadataURL, "/apps/"+string(app.Name)+"/annotations", "application/json") + if err != nil { + return append(r, err) + } + + err = json.Unmarshal(annotJson, &actualAnnots) + if err != nil { + return append(r, err) + } + if len(actualAnnots) == 0 { + actualAnnots = nil + } + + if !reflect.DeepEqual(actualAnnots, expectedAnnots) { + err := fmt.Errorf("%v annotations mismatch: %v vs %v", app.Name, actualAnnots, expectedAnnots) + r = append(r, err) + } + + return r +} + +func validateAppMetadata(metadataURL string, pm *schema.PodManifest, app *schema.RuntimeApp) results { + r := results{} + + am, err := metadataGet(metadataURL, "/apps/"+app.Name.String()+"/image/manifest", "application/json") + if err != nil { + return append(r, err) + } + + img := &schema.ImageManifest{} + if err = json.Unmarshal(am, img); err != nil { + return append(r, fmt.Errorf("failed to JSON-decode %q manifest: %v", app.Name.String(), err)) + } + + id, err := metadataGet(metadataURL, "/apps/"+app.Name.String()+"/image/id", "text/plain; charset=us-ascii") + if err != nil { + r = append(r, err) + } + + if string(id) != app.Image.ID.String() { + err = fmt.Errorf("%q's image id mismatch: %v vs %v", app.Name.String(), id, app.Image.ID) + r = append(r, err) + } + + return append(r, validateAppAnnotations(metadataURL, pm, app, img)...) +} + +func validateSigning(metadataURL string, pm *schema.PodManifest) results { + r := results{} + + // Get our UUID + uuid, err := metadataGet(metadataURL, "/pod/uuid", "text/plain; charset=us-ascii") + if err != nil { + return append(r, err) + } + + plaintext := "Old MacDonald Had A Farm" + + // Sign + sig, err := metadataPostForm(metadataURL, "/pod/hmac/sign", url.Values{ + "content": []string{plaintext}, + }, "text/plain; charset=us-ascii") + if err != nil { + return append(r, err) + } + + // Verify + _, err = metadataPostForm(metadataURL, "/pod/hmac/verify", url.Values{ + "content": []string{plaintext}, + "uuid": []string{string(uuid)}, + "signature": []string{string(sig)}, + }, "text/plain; charset=us-ascii") + + if err != nil { + return append(r, err) + } + + return r +} + +func ValidateMetadataSvc() results { + r := results{} + + metadataURL := os.Getenv("AC_METADATA_URL") + if metadataURL == "" { + return append(r, fmt.Errorf("AC_METADATA_URL is not set")) + } + + pod, err := metadataGet(metadataURL, "/pod/manifest", "application/json") + if err != nil { + return append(r, err) + } + + pm := &schema.PodManifest{} + if err = json.Unmarshal(pod, pm); err != nil { + return append(r, fmt.Errorf("failed to JSON-decode pod manifest: %v", err)) + } + + r = append(r, validatePodMetadata(metadataURL, pm)...) + + for _, app := range pm.Apps { + app := app + r = append(r, validateAppMetadata(metadataURL, pm, &app)...) + } + + return append(r, validateSigning(metadataURL, pm)...) +} + +// checkMount checks that the given string is a mount point, and that it is +// mounted appropriately read-only or not according to the given bool +func checkMount(d string, readonly bool) error { + return checkMountImpl(d, readonly) +} + +// parseMountinfo parses a Reader representing a /proc/PID/mountinfo file and +// returns whether dir is mounted and if so, whether it is read-only or not +func parseMountinfo(mountinfo io.Reader, dir string) (isMounted bool, readOnly bool, err error) { + sc := bufio.NewScanner(mountinfo) + for sc.Scan() { + var ( + mountID int + parentID int + majorMinor string + root string + mountPoint string + mountOptions string + ) + + _, err := fmt.Sscanf(sc.Text(), "%d %d %s %s %s %s", + &mountID, &parentID, &majorMinor, &root, &mountPoint, &mountOptions) + if err != nil { + return false, false, err + } + + if mountPoint == dir { + isMounted = true + optionsParts := strings.Split(mountOptions, ",") + for _, o := range optionsParts { + switch o { + case "ro": + readOnly = true + case "rw": + readOnly = false + } + } + } + } + + return +} + +// assertNotExistsAndCreate asserts that a file at the given path does not +// exist, and then proceeds to create (touch) the file. It returns any errors +// encountered at either of these steps. +func assertNotExistsAndCreate(p string) []error { + var errs []error + errs = append(errs, assertNotExists(p)...) + if err := touchFile(p); err != nil { + errs = append(errs, fmt.Errorf("error touching file %q: %v", p, err)) + } + return errs +} + +// assertNotExists asserts that a file at the given path does not exist. A +// non-empty list of errors is returned if the file exists or any error is +// encountered while checking. +func assertNotExists(p string) []error { + var errs []error + e, err := fileExists(p) + if err != nil { + errs = append(errs, fmt.Errorf("error checking %q exists: %v", p, err)) + } + if e { + errs = append(errs, fmt.Errorf("file %q exists unexpectedly", p)) + } + return errs +} + +// assertExists asserts that a file exists at the given path. A non-empty +// list of errors is returned if the file does not exist or any error is +// encountered while checking. +func assertExists(p string) []error { + var errs []error + e, err := fileExists(p) + if err != nil { + errs = append(errs, fmt.Errorf("error checking %q exists: %v", p, err)) + } + if !e { + errs = append(errs, fmt.Errorf("file %q does not exist as expected", p)) + } + return errs +} + +// touchFile creates an empty file, returning any error encountered +func touchFile(p string) error { + _, err := os.Create(p) + return err +} + +// fileExists checks whether a file exists at the given path +func fileExists(p string) (bool, error) { + _, err := os.Stat(p) + if err == nil { + return true, nil + } + if os.IsNotExist(err) { + return false, nil + } + return false, err +} + +// waitForFile waits for the file at the given path to appear +func waitForFile(p string, to time.Duration) []error { + done := time.After(to) + for { + select { + case <-done: + return []error{ + fmt.Errorf("timed out waiting for %s", p), + } + case <-time.After(1): + if ok, _ := fileExists(p); ok { + return nil + } + } + } +} + +func stderr(format string, a ...interface{}) { + out := fmt.Sprintf(format, a...) + fmt.Fprintln(os.Stderr, strings.TrimSuffix(out, "\n")) +} diff --git a/vendor/github.com/appc/spec/aci/build.go b/vendor/github.com/appc/spec/aci/build.go new file mode 100644 index 0000000000..0d259a27f5 --- /dev/null +++ b/vendor/github.com/appc/spec/aci/build.go @@ -0,0 +1,110 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package aci + +import ( + "archive/tar" + "io" + "os" + "path/filepath" + + "github.com/appc/spec/pkg/tarheader" +) + +// TarHeaderWalkFunc is the type of the function which allows setting tar +// headers or filtering out tar entries when building an ACI. It will be +// applied to every entry in the tar file. +// +// If true is returned, the entry will be included in the final ACI; if false, +// the entry will not be included. +type TarHeaderWalkFunc func(hdr *tar.Header) bool + +// BuildWalker creates a filepath.WalkFunc that walks over the given root +// (which should represent an ACI layout on disk) and adds the files in the +// rootfs/ subdirectory to the given ArchiveWriter +func BuildWalker(root string, aw ArchiveWriter, cb TarHeaderWalkFunc) filepath.WalkFunc { + // cache of inode -> filepath, used to leverage hard links in the archive + inos := map[uint64]string{} + return func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + relpath, err := filepath.Rel(root, path) + if err != nil { + return err + } + if relpath == "." { + return nil + } + if relpath == ManifestFile { + // ignore; this will be written by the archive writer + // TODO(jonboulle): does this make sense? maybe just remove from archivewriter? + return nil + } + + link := "" + var r io.Reader + switch info.Mode() & os.ModeType { + case os.ModeSocket: + return nil + case os.ModeNamedPipe: + case os.ModeCharDevice: + case os.ModeDevice: + case os.ModeDir: + case os.ModeSymlink: + target, err := os.Readlink(path) + if err != nil { + return err + } + link = target + default: + file, err := os.Open(path) + if err != nil { + return err + } + defer file.Close() + r = file + } + + hdr, err := tar.FileInfoHeader(info, link) + if err != nil { + panic(err) + } + // Because os.FileInfo's Name method returns only the base + // name of the file it describes, it may be necessary to + // modify the Name field of the returned header to provide the + // full path name of the file. + hdr.Name = relpath + tarheader.Populate(hdr, info, inos) + // If the file is a hard link to a file we've already seen, we + // don't need the contents + if hdr.Typeflag == tar.TypeLink { + hdr.Size = 0 + r = nil + } + + if cb != nil { + if !cb(hdr) { + return nil + } + } + + if err := aw.AddFile(hdr, r); err != nil { + return err + } + + return nil + } +} diff --git a/vendor/github.com/appc/spec/aci/doc.go b/vendor/github.com/appc/spec/aci/doc.go new file mode 100644 index 0000000000..624d431aff --- /dev/null +++ b/vendor/github.com/appc/spec/aci/doc.go @@ -0,0 +1,16 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package aci contains various functions for working with App Container Images. +package aci diff --git a/vendor/github.com/appc/spec/aci/file.go b/vendor/github.com/appc/spec/aci/file.go new file mode 100644 index 0000000000..fe4e1b5bd9 --- /dev/null +++ b/vendor/github.com/appc/spec/aci/file.go @@ -0,0 +1,246 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package aci + +import ( + "archive/tar" + "bytes" + "compress/bzip2" + "compress/gzip" + "encoding/hex" + "errors" + "fmt" + "io" + "io/ioutil" + "log" + "net/http" + "os/exec" + "path/filepath" + + "github.com/appc/spec/schema" +) + +type FileType string + +const ( + TypeGzip = FileType("gz") + TypeBzip2 = FileType("bz2") + TypeXz = FileType("xz") + TypeTar = FileType("tar") + TypeText = FileType("text") + TypeUnknown = FileType("unknown") + + readLen = 512 // max bytes to sniff + + hexHdrGzip = "1f8b" + hexHdrBzip2 = "425a68" + hexHdrXz = "fd377a585a00" + hexSigTar = "7573746172" + + tarOffset = 257 + + textMime = "text/plain; charset=utf-8" +) + +var ( + hdrGzip []byte + hdrBzip2 []byte + hdrXz []byte + sigTar []byte + tarEnd int +) + +func mustDecodeHex(s string) []byte { + b, err := hex.DecodeString(s) + if err != nil { + panic(err) + } + return b +} + +func init() { + hdrGzip = mustDecodeHex(hexHdrGzip) + hdrBzip2 = mustDecodeHex(hexHdrBzip2) + hdrXz = mustDecodeHex(hexHdrXz) + sigTar = mustDecodeHex(hexSigTar) + tarEnd = tarOffset + len(sigTar) +} + +// DetectFileType attempts to detect the type of file that the given reader +// represents by comparing it against known file signatures (magic numbers) +func DetectFileType(r io.Reader) (FileType, error) { + var b bytes.Buffer + n, err := io.CopyN(&b, r, readLen) + if err != nil && err != io.EOF { + return TypeUnknown, err + } + bs := b.Bytes() + switch { + case bytes.HasPrefix(bs, hdrGzip): + return TypeGzip, nil + case bytes.HasPrefix(bs, hdrBzip2): + return TypeBzip2, nil + case bytes.HasPrefix(bs, hdrXz): + return TypeXz, nil + case n > int64(tarEnd) && bytes.Equal(bs[tarOffset:tarEnd], sigTar): + return TypeTar, nil + case http.DetectContentType(bs) == textMime: + return TypeText, nil + default: + return TypeUnknown, nil + } +} + +// XzReader is an io.ReadCloser which decompresses xz compressed data. +type XzReader struct { + io.ReadCloser + cmd *exec.Cmd + closech chan error +} + +// NewXzReader shells out to a command line xz executable (if +// available) to decompress the given io.Reader using the xz +// compression format and returns an *XzReader. +// It is the caller's responsibility to call Close on the XzReader when done. +func NewXzReader(r io.Reader) (*XzReader, error) { + rpipe, wpipe := io.Pipe() + ex, err := exec.LookPath("xz") + if err != nil { + log.Fatalf("couldn't find xz executable: %v", err) + } + cmd := exec.Command(ex, "--decompress", "--stdout") + + closech := make(chan error) + + cmd.Stdin = r + cmd.Stdout = wpipe + + go func() { + err := cmd.Run() + wpipe.CloseWithError(err) + closech <- err + }() + + return &XzReader{rpipe, cmd, closech}, nil +} + +func (r *XzReader) Close() error { + r.ReadCloser.Close() + r.cmd.Process.Kill() + return <-r.closech +} + +// ManifestFromImage extracts a new schema.ImageManifest from the given ACI image. +func ManifestFromImage(rs io.ReadSeeker) (*schema.ImageManifest, error) { + var im schema.ImageManifest + + tr, err := NewCompressedTarReader(rs) + if err != nil { + return nil, err + } + defer tr.Close() + + for { + hdr, err := tr.Next() + switch err { + case io.EOF: + return nil, errors.New("missing manifest") + case nil: + if filepath.Clean(hdr.Name) == ManifestFile { + data, err := ioutil.ReadAll(tr) + if err != nil { + return nil, err + } + if err := im.UnmarshalJSON(data); err != nil { + return nil, err + } + return &im, nil + } + default: + return nil, fmt.Errorf("error extracting tarball: %v", err) + } + } +} + +// TarReadCloser embeds a *tar.Reader and the related io.Closer +// It is the caller's responsibility to call Close on TarReadCloser when +// done. +type TarReadCloser struct { + *tar.Reader + io.Closer +} + +func (r *TarReadCloser) Close() error { + return r.Closer.Close() +} + +// NewCompressedTarReader creates a new TarReadCloser reading from the +// given ACI image. +// It is the caller's responsibility to call Close on the TarReadCloser +// when done. +func NewCompressedTarReader(rs io.ReadSeeker) (*TarReadCloser, error) { + cr, err := NewCompressedReader(rs) + if err != nil { + return nil, err + } + return &TarReadCloser{tar.NewReader(cr), cr}, nil +} + +// NewCompressedReader creates a new io.ReaderCloser from the given ACI image. +// It is the caller's responsibility to call Close on the Reader when done. +func NewCompressedReader(rs io.ReadSeeker) (io.ReadCloser, error) { + + var ( + dr io.ReadCloser + err error + ) + + _, err = rs.Seek(0, 0) + if err != nil { + return nil, err + } + + ftype, err := DetectFileType(rs) + if err != nil { + return nil, err + } + + _, err = rs.Seek(0, 0) + if err != nil { + return nil, err + } + + switch ftype { + case TypeGzip: + dr, err = gzip.NewReader(rs) + if err != nil { + return nil, err + } + case TypeBzip2: + dr = ioutil.NopCloser(bzip2.NewReader(rs)) + case TypeXz: + dr, err = NewXzReader(rs) + if err != nil { + return nil, err + } + case TypeTar: + dr = ioutil.NopCloser(rs) + case TypeUnknown: + return nil, errors.New("error: unknown image filetype") + default: + return nil, errors.New("no type returned from DetectFileType?") + } + return dr, nil +} diff --git a/vendor/github.com/appc/spec/aci/layout.go b/vendor/github.com/appc/spec/aci/layout.go new file mode 100644 index 0000000000..c2cce5635a --- /dev/null +++ b/vendor/github.com/appc/spec/aci/layout.go @@ -0,0 +1,187 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package aci + +/* + +Image Layout + +The on-disk layout of an app container is straightforward. +It includes a rootfs with all of the files that will exist in the root of the app and a manifest describing the image. +The layout MUST contain an image manifest. + +/manifest +/rootfs/ +/rootfs/usr/bin/mysql + +*/ + +import ( + "archive/tar" + "bytes" + "errors" + "fmt" + "io" + "io/ioutil" + "os" + "path/filepath" + "strings" + + "github.com/appc/spec/schema" + "github.com/appc/spec/schema/types" +) + +const ( + // Path to manifest file inside the layout + ManifestFile = "manifest" + // Path to rootfs directory inside the layout + RootfsDir = "rootfs" +) + +type ErrOldVersion struct { + version types.SemVer +} + +func (e ErrOldVersion) Error() string { + return fmt.Sprintf("ACVersion too old. Found major version %v, expected %v", e.version.Major, schema.AppContainerVersion.Major) +} + +var ( + ErrNoRootFS = errors.New("no rootfs found in layout") + ErrNoManifest = errors.New("no image manifest found in layout") +) + +// ValidateLayout takes a directory and validates that the layout of the directory +// matches that expected by the Application Container Image format. +// If any errors are encountered during the validation, it will abort and +// return the first one. +func ValidateLayout(dir string) error { + fi, err := os.Stat(dir) + if err != nil { + return fmt.Errorf("error accessing layout: %v", err) + } + if !fi.IsDir() { + return fmt.Errorf("given path %q is not a directory", dir) + } + var flist []string + var imOK, rfsOK bool + var im io.Reader + walkLayout := func(fpath string, fi os.FileInfo, err error) error { + rpath, err := filepath.Rel(dir, fpath) + if err != nil { + return err + } + switch rpath { + case ".": + case ManifestFile: + im, err = os.Open(fpath) + if err != nil { + return err + } + imOK = true + case RootfsDir: + if !fi.IsDir() { + return errors.New("rootfs is not a directory") + } + rfsOK = true + default: + flist = append(flist, rpath) + } + return nil + } + if err := filepath.Walk(dir, walkLayout); err != nil { + return err + } + return validate(imOK, im, rfsOK, flist) +} + +// ValidateArchive takes a *tar.Reader and validates that the layout of the +// filesystem the reader encapsulates matches that expected by the +// Application Container Image format. If any errors are encountered during +// the validation, it will abort and return the first one. +func ValidateArchive(tr *tar.Reader) error { + var fseen map[string]bool = make(map[string]bool) + var imOK, rfsOK bool + var im bytes.Buffer +Tar: + for { + hdr, err := tr.Next() + switch { + case err == nil: + case err == io.EOF: + break Tar + default: + return err + } + name := filepath.Clean(hdr.Name) + switch name { + case ".": + case ManifestFile: + _, err := io.Copy(&im, tr) + if err != nil { + return err + } + imOK = true + case RootfsDir: + if !hdr.FileInfo().IsDir() { + return fmt.Errorf("rootfs is not a directory") + } + rfsOK = true + default: + if _, seen := fseen[name]; seen { + return fmt.Errorf("duplicate file entry in archive: %s", name) + } + fseen[name] = true + } + } + var flist []string + for key := range fseen { + flist = append(flist, key) + } + return validate(imOK, &im, rfsOK, flist) +} + +func validate(imOK bool, im io.Reader, rfsOK bool, files []string) error { + defer func() { + if rc, ok := im.(io.Closer); ok { + rc.Close() + } + }() + if !imOK { + return ErrNoManifest + } + if !rfsOK { + return ErrNoRootFS + } + b, err := ioutil.ReadAll(im) + if err != nil { + return fmt.Errorf("error reading image manifest: %v", err) + } + var a schema.ImageManifest + if err := a.UnmarshalJSON(b); err != nil { + return fmt.Errorf("image manifest validation failed: %v", err) + } + if a.ACVersion.LessThanMajor(schema.AppContainerVersion) { + return ErrOldVersion{ + version: a.ACVersion, + } + } + for _, f := range files { + if !strings.HasPrefix(f, "rootfs") { + return fmt.Errorf("unrecognized file path in layout: %q", f) + } + } + return nil +} diff --git a/vendor/github.com/appc/spec/aci/writer.go b/vendor/github.com/appc/spec/aci/writer.go new file mode 100644 index 0000000000..070b09ba53 --- /dev/null +++ b/vendor/github.com/appc/spec/aci/writer.go @@ -0,0 +1,98 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package aci + +import ( + "archive/tar" + "bytes" + "encoding/json" + "io" + "time" + + "github.com/appc/spec/schema" +) + +// ArchiveWriter writes App Container Images. Users wanting to create an ACI or +// should create an ArchiveWriter and add files to it; the ACI will be written +// to the underlying tar.Writer +type ArchiveWriter interface { + AddFile(hdr *tar.Header, r io.Reader) error + Close() error +} + +type imageArchiveWriter struct { + *tar.Writer + am *schema.ImageManifest +} + +// NewImageWriter creates a new ArchiveWriter which will generate an App +// Container Image based on the given manifest and write it to the given +// tar.Writer +func NewImageWriter(am schema.ImageManifest, w *tar.Writer) ArchiveWriter { + aw := &imageArchiveWriter{ + w, + &am, + } + return aw +} + +func (aw *imageArchiveWriter) AddFile(hdr *tar.Header, r io.Reader) error { + err := aw.Writer.WriteHeader(hdr) + if err != nil { + return err + } + + if r != nil { + _, err := io.Copy(aw.Writer, r) + if err != nil { + return err + } + } + + return nil +} + +func (aw *imageArchiveWriter) addFileNow(path string, contents []byte) error { + buf := bytes.NewBuffer(contents) + now := time.Now() + hdr := tar.Header{ + Name: path, + Mode: 0644, + Uid: 0, + Gid: 0, + Size: int64(buf.Len()), + ModTime: now, + Typeflag: tar.TypeReg, + Uname: "root", + Gname: "root", + ChangeTime: now, + } + return aw.AddFile(&hdr, buf) +} + +func (aw *imageArchiveWriter) addManifest(name string, m json.Marshaler) error { + out, err := m.MarshalJSON() + if err != nil { + return err + } + return aw.addFileNow(name, out) +} + +func (aw *imageArchiveWriter) Close() error { + if err := aw.addManifest(ManifestFile, aw.am); err != nil { + return err + } + return aw.Writer.Close() +} diff --git a/vendor/github.com/appc/spec/actool/actool.go b/vendor/github.com/appc/spec/actool/actool.go new file mode 100644 index 0000000000..21c5f5fa90 --- /dev/null +++ b/vendor/github.com/appc/spec/actool/actool.go @@ -0,0 +1,118 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "flag" + "fmt" + "os" + "strings" + "text/tabwriter" +) + +const ( + cliName = "actool" + cliDescription = "actool, the application container tool" +) + +var ( + globalFlagset = flag.NewFlagSet(cliName, flag.ExitOnError) + out *tabwriter.Writer + commands []*Command + globalFlags = struct { + Dir string + Debug bool + Help bool + }{} + transportFlags = struct { + Insecure bool + }{} +) + +func init() { + globalFlagset.BoolVar(&globalFlags.Help, "help", false, "Print usage information and exit") + globalFlagset.BoolVar(&globalFlags.Debug, "debug", false, "Print verbose (debug) output") +} + +type Command struct { + Name string // Name of the Command and the string to use to invoke it + Summary string // One-sentence summary of what the Command does + Usage string // Usage options/arguments + Description string // Detailed description of command + Flags flag.FlagSet // Set of flags associated with this command + + Run func(args []string) int // Run a command with the given arguments, return exit status +} + +func init() { + out = new(tabwriter.Writer) + out.Init(os.Stdout, 0, 8, 1, '\t', 0) + commands = []*Command{ + cmdBuild, + cmdCatManifest, + cmdDiscover, + cmdHelp, + cmdPatchManifest, + cmdValidate, + cmdVersion, + } +} + +func main() { + // parse global arguments + globalFlagset.Parse(os.Args[1:]) + args := globalFlagset.Args() + if len(args) < 1 || globalFlags.Help { + args = []string{"help"} + } + + var cmd *Command + + // determine which Command should be run + for _, c := range commands { + if c.Name == args[0] { + cmd = c + if err := c.Flags.Parse(args[1:]); err != nil { + stderr("%v", err) + os.Exit(2) + } + break + } + } + + if cmd == nil { + stderr("%v: unknown subcommand: %q", cliName, args[0]) + stderr("Run '%v help' for usage.", cliName) + os.Exit(2) + } + os.Exit(cmd.Run(cmd.Flags.Args())) +} + +func getAllFlags() (flags []*flag.Flag) { + return getFlags(globalFlagset) +} + +func getFlags(flagset *flag.FlagSet) (flags []*flag.Flag) { + flags = make([]*flag.Flag, 0) + flagset.VisitAll(func(f *flag.Flag) { + flags = append(flags, f) + }) + return +} + +func stderr(format string, a ...interface{}) { + out := fmt.Sprintf(format, a...) + fmt.Fprintln(os.Stderr, strings.TrimSuffix(out, "\n")) +} diff --git a/vendor/github.com/appc/spec/actool/build.go b/vendor/github.com/appc/spec/actool/build.go new file mode 100644 index 0000000000..1c958eba45 --- /dev/null +++ b/vendor/github.com/appc/spec/actool/build.go @@ -0,0 +1,145 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "archive/tar" + "compress/gzip" + "io" + "io/ioutil" + "os" + "path/filepath" + + "github.com/appc/spec/aci" + "github.com/appc/spec/schema" +) + +var ( + buildNocompress bool + buildOverwrite bool + buildOwnerRoot bool + cmdBuild = &Command{ + Name: "build", + Description: `Build an ACI from a given directory. The directory should +contain an Image Layout. The Image Layout will be validated +before the ACI is created. The produced ACI will be +gzip-compressed by default.`, + Summary: "Build an ACI from an Image Layout (experimental)", + Usage: `[--overwrite] [--no-compression] [--owner-root] DIRECTORY OUTPUT_FILE`, + Run: runBuild, + } +) + +func init() { + cmdBuild.Flags.BoolVar(&buildOverwrite, "overwrite", false, "Overwrite target file if it already exists") + cmdBuild.Flags.BoolVar(&buildOwnerRoot, "owner-root", false, "Force ownership to root:root on all files") + cmdBuild.Flags.BoolVar(&buildNocompress, "no-compression", false, "Do not gzip-compress the produced ACI") +} + +func runBuild(args []string) (exit int) { + if len(args) != 2 { + stderr("build: Must provide directory and output file") + return 1 + } + + root := args[0] + tgt := args[1] + ext := filepath.Ext(tgt) + if ext != schema.ACIExtension { + stderr("build: Extension must be %s (given %s)", schema.ACIExtension, ext) + return 1 + } + + // TODO(jonboulle): stream the validation so we don't have to walk the rootfs twice + if err := aci.ValidateLayout(root); err != nil { + if e, ok := err.(aci.ErrOldVersion); ok { + stderr("build: Warning: %v. Please update your manifest.", e) + } else { + stderr("build: Layout failed validation: %v", err) + return 1 + } + } + + mode := os.O_CREATE | os.O_WRONLY + if buildOverwrite { + mode |= os.O_TRUNC + } else { + mode |= os.O_EXCL + } + fh, err := os.OpenFile(tgt, mode, 0644) + if err != nil { + if os.IsExist(err) { + stderr("build: Target file exists (try --overwrite)") + } else { + stderr("build: Unable to open target %s: %v", tgt, err) + } + return 1 + } + + var gw *gzip.Writer + var r io.WriteCloser = fh + if !buildNocompress { + gw = gzip.NewWriter(fh) + r = gw + } + tr := tar.NewWriter(r) + + defer func() { + tr.Close() + if !buildNocompress { + gw.Close() + } + fh.Close() + if exit != 0 && !buildOverwrite { + os.Remove(tgt) + } + }() + + mpath := filepath.Join(root, aci.ManifestFile) + b, err := ioutil.ReadFile(mpath) + if err != nil { + stderr("build: Unable to read Image Manifest: %v", err) + return 1 + } + var im schema.ImageManifest + if err := im.UnmarshalJSON(b); err != nil { + stderr("build: Unable to load Image Manifest: %v", err) + return 1 + } + iw := aci.NewImageWriter(im, tr) + + var walkerCb aci.TarHeaderWalkFunc + if buildOwnerRoot { + walkerCb = func(hdr *tar.Header) bool { + hdr.Uid, hdr.Gid = 0, 0 + hdr.Uname, hdr.Gname = "root", "root" + return true + } + } + + err = filepath.Walk(root, aci.BuildWalker(root, iw, walkerCb)) + if err != nil { + stderr("build: Error walking rootfs: %v", err) + return 1 + } + + err = iw.Close() + if err != nil { + stderr("build: Unable to close image %s: %v", tgt, err) + return 1 + } + + return +} diff --git a/vendor/github.com/appc/spec/actool/discover.go b/vendor/github.com/appc/spec/actool/discover.go new file mode 100644 index 0000000000..f91f526d7b --- /dev/null +++ b/vendor/github.com/appc/spec/actool/discover.go @@ -0,0 +1,106 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "encoding/json" + "fmt" + "runtime" + "strings" + + "github.com/appc/spec/discovery" +) + +var ( + outputJson bool + cmdDiscover = &Command{ + Name: "discover", + Description: "Discover the download URLs for an app", + Summary: "Discover the download URLs for one or more app container images", + Usage: "[--json] APP...", + Run: runDiscover, + } +) + +func init() { + cmdDiscover.Flags.BoolVar(&transportFlags.Insecure, "insecure", false, + "Don't check TLS certificates and allow insecure non-TLS downloads over http") + cmdDiscover.Flags.BoolVar(&outputJson, "json", false, + "Output result as JSON") +} + +func runDiscover(args []string) (exit int) { + if len(args) < 1 { + stderr("discover: at least one name required") + } + + for _, name := range args { + app, err := discovery.NewAppFromString(name) + if app.Labels["os"] == "" { + app.Labels["os"] = runtime.GOOS + } + if app.Labels["arch"] == "" { + app.Labels["arch"] = runtime.GOARCH + } + if err != nil { + stderr("%s: %s", name, err) + return 1 + } + insecure := discovery.InsecureNone + if transportFlags.Insecure { + insecure = discovery.InsecureTLS | discovery.InsecureHTTP + } + eps, attempts, err := discovery.DiscoverACIEndpoints(*app, nil, insecure) + if err != nil { + stderr("error fetching endpoints for %s: %s", name, err) + return 1 + } + for _, a := range attempts { + fmt.Printf("discover endpoints walk: prefix: %s error: %v\n", a.Prefix, a.Error) + } + publicKeys, attempts, err := discovery.DiscoverPublicKeys(*app, nil, insecure) + if err != nil { + stderr("error fetching public keys for %s: %s", name, err) + return 1 + } + for _, a := range attempts { + fmt.Printf("discover public keys walk: prefix: %s error: %v\n", a.Prefix, a.Error) + } + + type discoveryData struct { + ACIEndpoints []discovery.ACIEndpoint + PublicKeys []string + } + + if outputJson { + dd := discoveryData{ACIEndpoints: eps, PublicKeys: publicKeys} + jsonBytes, err := json.MarshalIndent(dd, "", " ") + if err != nil { + stderr("error generating JSON: %s", err) + return 1 + } + fmt.Println(string(jsonBytes)) + } else { + for _, aciEndpoint := range eps { + fmt.Printf("ACI: %s, ASC: %s\n", aciEndpoint.ACI, aciEndpoint.ASC) + } + if len(publicKeys) > 0 { + fmt.Println("PublicKeys: " + strings.Join(publicKeys, ",")) + } + } + } + + return +} diff --git a/vendor/github.com/appc/spec/actool/doc.go b/vendor/github.com/appc/spec/actool/doc.go new file mode 100644 index 0000000000..e0e446d203 --- /dev/null +++ b/vendor/github.com/appc/spec/actool/doc.go @@ -0,0 +1,17 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package main contains a tool for building and validating images and +// manifests that meet the App Container specifications. +package main diff --git a/vendor/github.com/appc/spec/actool/help.go b/vendor/github.com/appc/spec/actool/help.go new file mode 100644 index 0000000000..25fa5622cc --- /dev/null +++ b/vendor/github.com/appc/spec/actool/help.go @@ -0,0 +1,140 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "flag" + "fmt" + "strings" + "text/template" + + "github.com/appc/spec/schema" +) + +var ( + cmdHelp = &Command{ + Name: "help", + Summary: "Show a list of commands or help for one command", + Usage: "[COMMAND]", + Description: "Show a list of commands or detailed help for one command", + Run: runHelp, + } + + globalUsageTemplate *template.Template + commandUsageTemplate *template.Template + templFuncs = template.FuncMap{ + "descToLines": func(s string) []string { + // trim leading/trailing whitespace and split into slice of lines + return strings.Split(strings.Trim(s, "\n\t "), "\n") + }, + "printOption": func(name, defvalue, usage string) string { + prefix := "--" + if len(name) == 1 { + prefix = "-" + } + return fmt.Sprintf("\t%s%s=%s\t%s", prefix, name, defvalue, usage) + }, + } +) + +func init() { + globalUsageTemplate = template.Must(template.New("global_usage").Funcs(templFuncs).Parse(` +NAME: +{{printf "\t%s - %s" .Executable .Description}} + +USAGE: +{{printf "\t%s" .Executable}} [global options] [command options] [arguments...] + +VERSION: +{{printf "\t%s" .Version}} + +COMMANDS:{{range .Commands}} +{{printf "\t%s\t%s" .Name .Summary}}{{end}} + +GLOBAL OPTIONS:{{range .Flags}} +{{printOption .Name .DefValue .Usage}}{{end}} + +Run "{{.Executable}} help " for more details on a specific command. +`[1:])) + commandUsageTemplate = template.Must(template.New("command_usage").Funcs(templFuncs).Parse(` +NAME: +{{printf "\t%s - %s" .Cmd.Name .Cmd.Summary}} + +USAGE: +{{printf "\t%s %s %s" .Executable .Cmd.Name .Cmd.Usage}} + +DESCRIPTION: +{{range $line := descToLines .Cmd.Description}}{{printf "\t%s" $line}} +{{end}} +{{if .CmdFlags}}OPTIONS:{{range .CmdFlags}} +{{printOption .Name .DefValue .Usage}}{{end}} + +{{end}}For help on global options run "{{.Executable}} help" +`[1:])) +} + +func runHelp(args []string) (exit int) { + if len(args) < 1 { + printGlobalUsage() + return + } + + var cmd *Command + + for _, c := range commands { + if c.Name == args[0] { + cmd = c + break + } + } + + if cmd == nil { + stderr("Unrecognized command: %s", args[0]) + return 1 + } + + printCommandUsage(cmd) + return +} + +func printGlobalUsage() { + globalUsageTemplate.Execute(out, struct { + Executable string + Commands []*Command + Flags []*flag.Flag + Description string + Version string + }{ + cliName, + commands, + getAllFlags(), + cliDescription, + schema.AppContainerVersion.String(), + }) + out.Flush() +} + +func printCommandUsage(cmd *Command) { + commandUsageTemplate.Execute(out, struct { + Executable string + Cmd *Command + CmdFlags []*flag.Flag + }{ + cliName, + cmd, + getFlags(&cmd.Flags), + }) + out.Flush() +} diff --git a/vendor/github.com/appc/spec/actool/manifest.go b/vendor/github.com/appc/spec/actool/manifest.go new file mode 100644 index 0000000000..46662167dc --- /dev/null +++ b/vendor/github.com/appc/spec/actool/manifest.go @@ -0,0 +1,525 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "archive/tar" + "compress/gzip" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "net/url" + "os" + "path" + "path/filepath" + "strconv" + "strings" + + "github.com/appc/spec/aci" + "github.com/appc/spec/schema" + "github.com/appc/spec/schema/types" +) + +var ( + inputFile string + outputFile string + + patchNocompress bool + patchOverwrite bool + patchReplace bool + patchManifestFile string + patchName string + patchExec string + patchUser string + patchGroup string + patchSupplementaryGIDs string + patchCaps string + patchRevokeCaps string + patchMounts string + patchPorts string + patchIsolators string + + catPrettyPrint bool + + cmdPatchManifest = &Command{ + Name: "patch-manifest", + Description: `Copy an ACI and patch its manifest.`, + Summary: "Copy an ACI and patch its manifest (experimental)", + Usage: ` + [--manifest=MANIFEST_FILE] + [--name=example.com/app] + [--exec="/app --debug"] + [--user=uid] [--group=gid] + [--capability=CAP_SYS_ADMIN,CAP_NET_ADMIN] + [--revoke-capability=CAP_SYS_CHROOT,CAP_MKNOD] + [--mounts=work,path=/opt,readOnly=true[:work2,...]] + [--ports=query,protocol=tcp,port=8080[:query2,...]] + [--supplementary-groups=gid1,gid2,...] + [--isolators=resource/cpu,request=50m,limit=100m[:resource/memory,...]] + [--replace] + INPUT_ACI_FILE + [OUTPUT_ACI_FILE]`, + Run: runPatchManifest, + } + cmdCatManifest = &Command{ + Name: "cat-manifest", + Description: `Print the manifest from an ACI.`, + Summary: "Print the manifest from an ACI", + Usage: ` [--pretty-print] ACI_FILE`, + Run: runCatManifest, + } +) + +func init() { + cmdPatchManifest.Flags.BoolVar(&patchOverwrite, "overwrite", false, "Overwrite target file if it already exists") + cmdPatchManifest.Flags.BoolVar(&patchNocompress, "no-compression", false, "Do not gzip-compress the produced ACI") + cmdPatchManifest.Flags.BoolVar(&patchReplace, "replace", false, "Replace the input file") + + cmdPatchManifest.Flags.StringVar(&patchManifestFile, "manifest", "", "Replace image manifest with this file. Incompatible with other replace options.") + cmdPatchManifest.Flags.StringVar(&patchName, "name", "", "Replace name") + cmdPatchManifest.Flags.StringVar(&patchExec, "exec", "", "Replace the command line to launch the executable") + cmdPatchManifest.Flags.StringVar(&patchUser, "user", "", "Replace user") + cmdPatchManifest.Flags.StringVar(&patchGroup, "group", "", "Replace group") + cmdPatchManifest.Flags.StringVar(&patchSupplementaryGIDs, "supplementary-groups", "", "Replace supplementary groups, expects a comma-separated list.") + cmdPatchManifest.Flags.StringVar(&patchCaps, "capability", "", "Set the capability remain set") + cmdPatchManifest.Flags.StringVar(&patchRevokeCaps, "revoke-capability", "", "Set the capability remove set") + cmdPatchManifest.Flags.StringVar(&patchMounts, "mounts", "", "Replace mount points") + cmdPatchManifest.Flags.StringVar(&patchPorts, "ports", "", "Replace ports") + cmdPatchManifest.Flags.StringVar(&patchIsolators, "isolators", "", "Replace isolators") + + cmdCatManifest.Flags.BoolVar(&catPrettyPrint, "pretty-print", false, "Print with better style") +} + +func getIsolatorStr(name, value string) string { + return fmt.Sprintf(` + { + "name": "%s", + "value": { %s } + }`, name, value) +} + +func isolatorStrFromString(is string) (types.ACIdentifier, string, error) { + is = "name=" + is + v, err := url.ParseQuery(strings.Replace(is, ",", "&", -1)) + if err != nil { + return "", "", err + } + + var name string + var values []string + var acn *types.ACIdentifier + + for key, val := range v { + if len(val) > 1 { + return "", "", fmt.Errorf("label %s with multiple values %q", key, val) + } + + switch key { + case "name": + acn, err = types.NewACIdentifier(val[0]) + if err != nil { + return "", "", err + } + name = val[0] + default: + // (TODO)yifan: Not support the default boolean yet. + values = append(values, fmt.Sprintf(`"%s": "%s"`, key, val[0])) + } + } + return *acn, getIsolatorStr(name, strings.Join(values, ", ")), nil +} + +func patchManifest(im *schema.ImageManifest) error { + + if patchName != "" { + name, err := types.NewACIdentifier(patchName) + if err != nil { + return err + } + im.Name = *name + } + + var app *types.App = im.App + if patchExec != "" { + if app == nil { + // if the original manifest was missing an app and + // patchExec is set let's assume the user is trying to + // inject one... + im.App = &types.App{} + app = im.App + } + app.Exec = strings.Split(patchExec, " ") + } + + if patchUser != "" || + patchGroup != "" || + patchSupplementaryGIDs != "" || + patchCaps != "" || + patchRevokeCaps != "" || + patchMounts != "" || + patchPorts != "" || + patchIsolators != "" { + // ...but if we still don't have an app and the user is trying + // to patch one of its other parameters, it's an error + if app == nil { + return fmt.Errorf("no app in the supplied manifest and no exec command provided") + } + } + + if patchUser != "" { + app.User = patchUser + } + + if patchGroup != "" { + app.Group = patchGroup + } + + if patchSupplementaryGIDs != "" { + app.SupplementaryGIDs = []int{} + gids := strings.Split(patchSupplementaryGIDs, ",") + for _, g := range gids { + gid, err := strconv.Atoi(g) + if err != nil { + return fmt.Errorf("invalid supplementary group %q: %v", g, err) + } + app.SupplementaryGIDs = append(app.SupplementaryGIDs, gid) + } + } + + if patchCaps != "" { + isolator := app.Isolators.GetByName(types.LinuxCapabilitiesRetainSetName) + if isolator != nil { + return fmt.Errorf("isolator already exists (os/linux/capabilities-retain-set)") + } + + // Instantiate a Isolator with the content specified by the --capability + // parameter. + caps, err := types.NewLinuxCapabilitiesRetainSet(strings.Split(patchCaps, ",")...) + if err != nil { + return fmt.Errorf("cannot parse capability %q: %v", patchCaps, err) + } + app.Isolators = append(app.Isolators, caps.AsIsolator()) + } + if patchRevokeCaps != "" { + isolator := app.Isolators.GetByName(types.LinuxCapabilitiesRevokeSetName) + if isolator != nil { + return fmt.Errorf("isolator already exists (os/linux/capabilities-remove-set)") + } + + // Instantiate a Isolator with the content specified by the --revoke-capability + // parameter. + caps, err := types.NewLinuxCapabilitiesRevokeSet(strings.Split(patchRevokeCaps, ",")...) + if err != nil { + return fmt.Errorf("cannot parse capability %q: %v", patchRevokeCaps, err) + } + app.Isolators = append(app.Isolators, caps.AsIsolator()) + } + + if patchMounts != "" { + mounts := strings.Split(patchMounts, ":") + for _, m := range mounts { + mountPoint, err := types.MountPointFromString(m) + if err != nil { + return fmt.Errorf("cannot parse mount point %q: %v", m, err) + } + app.MountPoints = append(app.MountPoints, *mountPoint) + } + } + + if patchPorts != "" { + ports := strings.Split(patchPorts, ":") + for _, p := range ports { + port, err := types.PortFromString(p) + if err != nil { + return fmt.Errorf("cannot parse port %q: %v", p, err) + } + app.Ports = append(app.Ports, *port) + } + } + + if patchIsolators != "" { + isolators := strings.Split(patchIsolators, ":") + for _, is := range isolators { + name, isolatorStr, err := isolatorStrFromString(is) + if err != nil { + return fmt.Errorf("cannot parse isolator %q: %v", is, err) + } + + _, ok := types.ResourceIsolatorNames[name] + + if name == types.LinuxNoNewPrivilegesName { + ok = true + kv := strings.Split(is, ",") + if len(kv) != 2 { + return fmt.Errorf("isolator %s: invalid format", name) + } + + isolatorStr = fmt.Sprintf(`{ "name": "%s", "value": %s }`, name, kv[1]) + } + + if !ok { + return fmt.Errorf("isolator %s is not supported for patching", name) + } + + isolator := &types.Isolator{} + if err := isolator.UnmarshalJSON([]byte(isolatorStr)); err != nil { + return fmt.Errorf("cannot unmarshal isolator %v: %v", isolatorStr, err) + } + app.Isolators = append(app.Isolators, *isolator) + } + } + return nil +} + +// extractManifest iterates over the tar reader and locate the manifest. Once +// located, the manifest can be printed, replaced or patched. +func extractManifest(tr *tar.Reader, tw *tar.Writer, printManifest bool, newManifest []byte) error { +Tar: + for { + hdr, err := tr.Next() + switch err { + case io.EOF: + break Tar + case nil: + if filepath.Clean(hdr.Name) == aci.ManifestFile { + var new_bytes []byte + + bytes, err := ioutil.ReadAll(tr) + if err != nil { + return err + } + + if printManifest && !catPrettyPrint { + fmt.Println(string(bytes)) + } + + im := &schema.ImageManifest{} + err = im.UnmarshalJSON(bytes) + if err != nil { + return err + } + + if printManifest && catPrettyPrint { + output, err := json.MarshalIndent(im, "", " ") + if err != nil { + return err + } + fmt.Println(string(output)) + } + + if tw == nil { + return nil + } + + if len(newManifest) == 0 { + err = patchManifest(im) + if err != nil { + return err + } + + new_bytes, err = im.MarshalJSON() + if err != nil { + return err + } + } else { + new_bytes = newManifest + } + + hdr.Size = int64(len(new_bytes)) + err = tw.WriteHeader(hdr) + if err != nil { + return err + } + + _, err = tw.Write(new_bytes) + if err != nil { + return err + } + } else if tw != nil { + err := tw.WriteHeader(hdr) + if err != nil { + return err + } + _, err = io.Copy(tw, tr) + if err != nil { + return err + } + } + default: + return fmt.Errorf("error reading tarball: %v", err) + } + } + + return nil +} + +func runPatchManifest(args []string) (exit int) { + var fh *os.File + var err error + + if patchReplace && patchOverwrite { + stderr("patch-manifest: Cannot use both --replace and --overwrite") + return 1 + } + if !patchReplace && len(args) != 2 { + stderr("patch-manifest: Must provide input and output files (or use --replace)") + return 1 + } + if patchReplace && len(args) != 1 { + stderr("patch-manifest: Must provide one file") + return 1 + } + if patchManifestFile != "" && (patchName != "" || patchExec != "" || patchUser != "" || patchGroup != "" || patchCaps != "" || patchMounts != "") { + stderr("patch-manifest: --manifest is incompatible with other manifest editing options") + return 1 + } + + inputFile = args[0] + + // Prepare output writer + + if patchReplace { + fh, err = ioutil.TempFile(path.Dir(inputFile), ".actool-tmp."+path.Base(inputFile)+"-") + if err != nil { + stderr("patch-manifest: Cannot create temporary file: %v", err) + return 1 + } + } else { + outputFile = args[1] + + ext := filepath.Ext(outputFile) + if ext != schema.ACIExtension { + stderr("patch-manifest: Extension must be %s (given %s)", schema.ACIExtension, ext) + return 1 + } + + mode := os.O_CREATE | os.O_WRONLY + if patchOverwrite { + mode |= os.O_TRUNC + } else { + mode |= os.O_EXCL + } + + fh, err = os.OpenFile(outputFile, mode, 0644) + if err != nil { + if os.IsExist(err) { + stderr("patch-manifest: Output file exists (try --overwrite)") + } else { + stderr("patch-manifest: Unable to open output %s: %v", outputFile, err) + } + return 1 + } + } + + var gw *gzip.Writer + var w io.WriteCloser = fh + if !patchNocompress { + gw = gzip.NewWriter(fh) + w = gw + } + tw := tar.NewWriter(w) + + defer func() { + tw.Close() + if !patchNocompress { + gw.Close() + } + fh.Close() + if exit != 0 && !patchOverwrite { + os.Remove(fh.Name()) + } + }() + + // Prepare input reader + + input, err := os.Open(inputFile) + if err != nil { + stderr("patch-manifest: Cannot open %s: %v", inputFile, err) + return 1 + } + defer input.Close() + + tr, err := aci.NewCompressedTarReader(input) + if err != nil { + stderr("patch-manifest: Cannot extract %s: %v", inputFile, err) + return 1 + } + defer tr.Close() + + var newManifest []byte + + if patchManifestFile != "" { + mr, err := os.Open(patchManifestFile) + if err != nil { + stderr("patch-manifest: Cannot open %s: %v", patchManifestFile, err) + return 1 + } + defer input.Close() + + newManifest, err = ioutil.ReadAll(mr) + if err != nil { + stderr("patch-manifest: Cannot read %s: %v", patchManifestFile, err) + return 1 + } + } + + err = extractManifest(tr.Reader, tw, false, newManifest) + if err != nil { + stderr("patch-manifest: Unable to read %s: %v", inputFile, err) + return 1 + } + + if patchReplace { + err = os.Rename(fh.Name(), inputFile) + if err != nil { + stderr("patch-manifest: Cannot rename %q to %q: %v", fh.Name, inputFile, err) + return 1 + } + } + + return +} + +func runCatManifest(args []string) (exit int) { + if len(args) != 1 { + stderr("cat-manifest: Must provide one file") + return 1 + } + + inputFile = args[0] + + input, err := os.Open(inputFile) + if err != nil { + stderr("cat-manifest: Cannot open %s: %v", inputFile, err) + return 1 + } + defer input.Close() + + tr, err := aci.NewCompressedTarReader(input) + if err != nil { + stderr("cat-manifest: Cannot extract %s: %v", inputFile, err) + return 1 + } + defer tr.Close() + + err = extractManifest(tr.Reader, nil, true, nil) + if err != nil { + stderr("cat-manifest: Unable to read %s: %v", inputFile, err) + return 1 + } + + return +} diff --git a/vendor/github.com/appc/spec/actool/validate.go b/vendor/github.com/appc/spec/actool/validate.go new file mode 100644 index 0000000000..12a7f19ff9 --- /dev/null +++ b/vendor/github.com/appc/spec/actool/validate.go @@ -0,0 +1,177 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "fmt" + "io/ioutil" + "os" + "strings" + + "github.com/appc/spec/aci" + "github.com/appc/spec/schema" +) + +const ( + typeAppImage = "appimage" + typeImageLayout = "layout" + typeManifest = "manifest" +) + +var ( + valType string + cmdValidate = &Command{ + Name: "validate", + Description: "Validate one or more AppContainer files", + Summary: "Validate that one or more images or manifests meet the AppContainer specification", + Usage: "[--type=TYPE] FILE...", + Run: runValidate, + } + validateTypes = []string{ + typeAppImage, + typeImageLayout, + typeManifest, + } +) + +func init() { + cmdValidate.Flags.StringVar(&valType, "type", "", + fmt.Sprintf(`Type of file to validate. If unset, actool will try to detect the type. One of "%s"`, strings.Join(validateTypes, ","))) +} + +func runValidate(args []string) (exit int) { + if len(args) < 1 { + stderr("must pass one or more files") + return 1 + } + + for _, path := range args { + vt := valType + fi, err := os.Stat(path) + if err != nil { + stderr("unable to access %s: %v", path, err) + return 1 + } + var fh *os.File + if fi.IsDir() { + switch vt { + case typeImageLayout: + case "": + vt = typeImageLayout + case typeManifest, typeAppImage: + stderr("%s is a directory (wrong --type?)", path) + return 1 + default: + // should never happen + panic(fmt.Sprintf("unexpected type: %v", vt)) + } + } else { + fh, err = os.Open(path) + if err != nil { + stderr("%s: unable to open: %v", path, err) + return 1 + } + } + + if vt == "" { + vt, err = detectValType(fh) + if err != nil { + stderr("%s: error detecting file type: %v", path, err) + return 1 + } + } + switch vt { + case typeImageLayout: + err = aci.ValidateLayout(path) + if err != nil { + stderr("%s: invalid image layout: %v", path, err) + exit = 1 + } else if globalFlags.Debug { + stderr("%s: valid image layout", path) + } + case typeAppImage: + tr, err := aci.NewCompressedTarReader(fh) + if err != nil { + stderr("%s: error decompressing file: %v", path, err) + return 1 + } + err = aci.ValidateArchive(tr.Reader) + tr.Close() + fh.Close() + if err != nil { + if e, ok := err.(aci.ErrOldVersion); ok { + stderr("%s: warning: %v", path, e) + } else { + stderr("%s: error validating: %v", path, err) + exit = 1 + } + } else if globalFlags.Debug { + stderr("%s: valid app container image", path) + } + case typeManifest: + b, err := ioutil.ReadAll(fh) + fh.Close() + if err != nil { + stderr("%s: unable to read file %s", path, err) + return 1 + } + k := schema.Kind{} + if err := k.UnmarshalJSON(b); err != nil { + stderr("%s: error unmarshaling manifest: %v", path, err) + return 1 + } + switch k.ACKind { + case "ImageManifest": + m := schema.ImageManifest{} + err = m.UnmarshalJSON(b) + case "PodManifest": + m := schema.PodManifest{} + err = m.UnmarshalJSON(b) + default: + // Should not get here; schema.Kind unmarshal should fail + panic("bad ACKind") + } + if err != nil { + stderr("%s: invalid %s: %v", path, k.ACKind, err) + exit = 1 + } else if globalFlags.Debug { + stderr("%s: valid %s", path, k.ACKind) + } + default: + stderr("%s: unable to detect filetype (try --type)", path) + return 1 + } + } + + return +} + +func detectValType(file *os.File) (string, error) { + typ, err := aci.DetectFileType(file) + if err != nil { + return "", err + } + if _, err := file.Seek(0, 0); err != nil { + return "", err + } + switch typ { + case aci.TypeXz, aci.TypeGzip, aci.TypeBzip2, aci.TypeTar: + return typeAppImage, nil + case aci.TypeText: + return typeManifest, nil + default: + return "", nil + } +} diff --git a/vendor/github.com/appc/spec/actool/version.go b/vendor/github.com/appc/spec/actool/version.go new file mode 100644 index 0000000000..0191ad7b38 --- /dev/null +++ b/vendor/github.com/appc/spec/actool/version.go @@ -0,0 +1,33 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "fmt" + + "github.com/appc/spec/schema" +) + +var cmdVersion = &Command{ + Name: "version", + Description: "Print the version and exit", + Summary: "Print the version and exit", + Run: runVersion, +} + +func runVersion(args []string) (exit int) { + fmt.Printf("actool version %s\n", schema.AppContainerVersion.String()) + return +} diff --git a/vendor/github.com/appc/spec/discovery/discovery.go b/vendor/github.com/appc/spec/discovery/discovery.go new file mode 100644 index 0000000000..b2dc659541 --- /dev/null +++ b/vendor/github.com/appc/spec/discovery/discovery.go @@ -0,0 +1,257 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package discovery + +import ( + "errors" + "fmt" + "io" + "net/http" + "regexp" + "strings" + + "golang.org/x/net/html" + "golang.org/x/net/html/atom" +) + +type acMeta struct { + name string + prefix string + uri string +} + +type ACIEndpoint struct { + ACI string + ASC string +} + +// A struct containing both discovered endpoints and keys. Used to avoid +// function duplication (one for endpoints and one for keys, so to avoid two +// doDiscover, two DiscoverWalkFunc) +type discoveryData struct { + ACIEndpoints []ACIEndpoint + PublicKeys []string +} + +type ACIEndpoints []ACIEndpoint + +type PublicKeys []string + +const ( + defaultVersion = "latest" +) + +var ( + templateExpression = regexp.MustCompile(`{.*?}`) + errEnough = errors.New("enough discovery information found") +) + +func appendMeta(meta []acMeta, attrs []html.Attribute) []acMeta { + m := acMeta{} + + for _, a := range attrs { + if a.Namespace != "" { + continue + } + + switch a.Key { + case "name": + m.name = a.Val + + case "content": + parts := strings.SplitN(strings.TrimSpace(a.Val), " ", 2) + if len(parts) < 2 { + break + } + m.prefix = parts[0] + m.uri = strings.TrimSpace(parts[1]) + } + } + + // TODO(eyakubovich): should prefix be optional? + if !strings.HasPrefix(m.name, "ac-") || m.prefix == "" || m.uri == "" { + return meta + } + + return append(meta, m) +} + +func extractACMeta(r io.Reader) []acMeta { + var meta []acMeta + + z := html.NewTokenizer(r) + + for { + switch z.Next() { + case html.ErrorToken: + return meta + + case html.StartTagToken, html.SelfClosingTagToken: + tok := z.Token() + if tok.DataAtom == atom.Meta { + meta = appendMeta(meta, tok.Attr) + } + } + } +} + +func renderTemplate(tpl string, kvs ...string) (string, bool) { + for i := 0; i < len(kvs); i += 2 { + k := kvs[i] + v := kvs[i+1] + tpl = strings.Replace(tpl, k, v, -1) + } + return tpl, !templateExpression.MatchString(tpl) +} + +func createTemplateVars(app App) []string { + tplVars := []string{"{name}", app.Name.String()} + // If a label is called "name", it will be ignored as it appears after + // in the slice + for n, v := range app.Labels { + tplVars = append(tplVars, fmt.Sprintf("{%s}", n), v) + } + return tplVars +} + +func doDiscover(pre string, hostHeaders map[string]http.Header, app App, insecure InsecureOption) (*discoveryData, error) { + app = *app.Copy() + if app.Labels["version"] == "" { + app.Labels["version"] = defaultVersion + } + + _, body, err := httpsOrHTTP(pre, hostHeaders, insecure) + if err != nil { + return nil, err + } + defer body.Close() + + meta := extractACMeta(body) + + tplVars := createTemplateVars(app) + + dd := &discoveryData{} + + for _, m := range meta { + if !strings.HasPrefix(app.Name.String(), m.prefix) { + continue + } + + switch m.name { + case "ac-discovery": + // Ignore not handled variables as {ext} isn't already rendered. + uri, _ := renderTemplate(m.uri, tplVars...) + asc, ok := renderTemplate(uri, "{ext}", "aci.asc") + if !ok { + continue + } + aci, ok := renderTemplate(uri, "{ext}", "aci") + if !ok { + continue + } + dd.ACIEndpoints = append(dd.ACIEndpoints, ACIEndpoint{ACI: aci, ASC: asc}) + + case "ac-discovery-pubkeys": + dd.PublicKeys = append(dd.PublicKeys, m.uri) + } + } + + return dd, nil +} + +// DiscoverWalk will make HTTPS requests to find discovery meta tags and +// optionally will use HTTP if insecure is set. hostHeaders specifies the +// header to apply depending on the host (e.g. authentication). Based on the +// response of the discoverFn it will continue to recurse up the tree. +func DiscoverWalk(app App, hostHeaders map[string]http.Header, insecure InsecureOption, discoverFn DiscoverWalkFunc) (dd *discoveryData, err error) { + parts := strings.Split(string(app.Name), "/") + for i := range parts { + end := len(parts) - i + pre := strings.Join(parts[:end], "/") + + dd, err = doDiscover(pre, hostHeaders, app, insecure) + if derr := discoverFn(pre, dd, err); derr != nil { + return dd, derr + } + } + + return nil, fmt.Errorf("discovery failed") +} + +// DiscoverWalkFunc can stop a DiscoverWalk by returning non-nil error. +type DiscoverWalkFunc func(prefix string, dd *discoveryData, err error) error + +// FailedAttempt represents a failed discovery attempt. This is for debugging +// and user feedback. +type FailedAttempt struct { + Prefix string + Error error +} + +func walker(attempts *[]FailedAttempt, testFn DiscoverWalkFunc) DiscoverWalkFunc { + return func(pre string, dd *discoveryData, err error) error { + if err != nil { + *attempts = append(*attempts, FailedAttempt{pre, err}) + return nil + } + if err := testFn(pre, dd, err); err != nil { + return err + } + return nil + } +} + +// DiscoverACIEndpoints will make HTTPS requests to find the ac-discovery meta +// tags and optionally will use HTTP if insecure is set. hostHeaders +// specifies the header to apply depending on the host (e.g. authentication). +// It will not give up until it has exhausted the path or found an image +// discovery. +func DiscoverACIEndpoints(app App, hostHeaders map[string]http.Header, insecure InsecureOption) (ACIEndpoints, []FailedAttempt, error) { + testFn := func(pre string, dd *discoveryData, err error) error { + if len(dd.ACIEndpoints) != 0 { + return errEnough + } + return nil + } + + attempts := []FailedAttempt{} + dd, err := DiscoverWalk(app, hostHeaders, insecure, walker(&attempts, testFn)) + if err != nil && err != errEnough { + return nil, attempts, err + } + + return dd.ACIEndpoints, attempts, nil +} + +// DiscoverPublicKey will make HTTPS requests to find the ac-public-keys meta +// tags and optionally will use HTTP if insecure is set. hostHeaders +// specifies the header to apply depending on the host (e.g. authentication). +// It will not give up until it has exhausted the path or found an public key. +func DiscoverPublicKeys(app App, hostHeaders map[string]http.Header, insecure InsecureOption) (PublicKeys, []FailedAttempt, error) { + testFn := func(pre string, dd *discoveryData, err error) error { + if len(dd.PublicKeys) != 0 { + return errEnough + } + return nil + } + + attempts := []FailedAttempt{} + dd, err := DiscoverWalk(app, hostHeaders, insecure, walker(&attempts, testFn)) + if err != nil && err != errEnough { + return nil, attempts, err + } + + return dd.PublicKeys, attempts, nil +} diff --git a/vendor/github.com/appc/spec/discovery/doc.go b/vendor/github.com/appc/spec/discovery/doc.go new file mode 100644 index 0000000000..55bfc3a02a --- /dev/null +++ b/vendor/github.com/appc/spec/discovery/doc.go @@ -0,0 +1,17 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package discovery contains an experimental implementation of the Image +// Discovery section of the appc specification. +package discovery diff --git a/vendor/github.com/appc/spec/discovery/http.go b/vendor/github.com/appc/spec/discovery/http.go new file mode 100644 index 0000000000..430bcc61cf --- /dev/null +++ b/vendor/github.com/appc/spec/discovery/http.go @@ -0,0 +1,122 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package discovery + +import ( + "crypto/tls" + "fmt" + "io" + "net" + "net/http" + "net/url" + "time" +) + +type InsecureOption int + +const ( + defaultDialTimeout = 5 * time.Second +) + +const ( + InsecureNone InsecureOption = 0 + + InsecureTLS InsecureOption = 1 << iota + InsecureHTTP +) + +var ( + // Client is the default http.Client used for discovery requests. + Client *http.Client + ClientInsecureTLS *http.Client + + // httpDo is the internal object used by discovery to retrieve URLs; it is + // defined here so it can be overridden for testing + httpDo httpDoer + httpDoInsecureTLS httpDoer +) + +// httpDoer is an interface used to wrap http.Client for real requests and +// allow easy mocking in local tests. +type httpDoer interface { + Do(req *http.Request) (resp *http.Response, err error) +} + +func init() { + t := &http.Transport{ + Proxy: http.ProxyFromEnvironment, + Dial: func(n, a string) (net.Conn, error) { + return net.DialTimeout(n, a, defaultDialTimeout) + }, + } + Client = &http.Client{ + Transport: t, + } + httpDo = Client + + // copy for InsecureTLS + tInsecureTLS := *t + tInsecureTLS.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} + ClientInsecureTLS = &http.Client{ + Transport: &tInsecureTLS, + } + httpDoInsecureTLS = ClientInsecureTLS +} + +func httpsOrHTTP(name string, hostHeaders map[string]http.Header, insecure InsecureOption) (urlStr string, body io.ReadCloser, err error) { + fetch := func(scheme string) (urlStr string, res *http.Response, err error) { + u, err := url.Parse(scheme + "://" + name) + if err != nil { + return "", nil, err + } + u.RawQuery = "ac-discovery=1" + urlStr = u.String() + req, err := http.NewRequest("GET", urlStr, nil) + if err != nil { + return "", nil, err + } + if hostHeader, ok := hostHeaders[u.Host]; ok { + req.Header = hostHeader + } + if insecure&InsecureTLS != 0 { + res, err = httpDoInsecureTLS.Do(req) + return + } + res, err = httpDo.Do(req) + return + } + closeBody := func(res *http.Response) { + if res != nil { + res.Body.Close() + } + } + urlStr, res, err := fetch("https") + if err != nil || res.StatusCode != http.StatusOK { + if insecure&InsecureHTTP != 0 { + closeBody(res) + urlStr, res, err = fetch("http") + } + } + + if res != nil && res.StatusCode != http.StatusOK { + err = fmt.Errorf("expected a 200 OK got %d", res.StatusCode) + } + + if err != nil { + closeBody(res) + return "", nil, err + } + return urlStr, res.Body, nil +} diff --git a/vendor/github.com/appc/spec/discovery/parse.go b/vendor/github.com/appc/spec/discovery/parse.go new file mode 100644 index 0000000000..7b9d574a69 --- /dev/null +++ b/vendor/github.com/appc/spec/discovery/parse.go @@ -0,0 +1,130 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package discovery + +import ( + "fmt" + "net/url" + "strings" + + "github.com/appc/spec/schema/common" + "github.com/appc/spec/schema/types" +) + +type App struct { + Name types.ACIdentifier + Labels map[types.ACIdentifier]string +} + +func NewApp(name string, labels map[types.ACIdentifier]string) (*App, error) { + if labels == nil { + labels = make(map[types.ACIdentifier]string, 0) + } + acn, err := types.NewACIdentifier(name) + if err != nil { + return nil, err + } + return &App{ + Name: *acn, + Labels: labels, + }, nil +} + +// NewAppFromString takes a command line app parameter and returns a map of labels. +// +// Example app parameters: +// example.com/reduce-worker:1.0.0 +// example.com/reduce-worker,channel=alpha,label=value +// example.com/reduce-worker:1.0.0,label=value +// +// As can be seen in above examples - colon, comma and equal sign have +// special meaning. If any of them has to be a part of a label's value +// then consider writing your own string to App parser. +func NewAppFromString(app string) (*App, error) { + var ( + name string + labels map[types.ACIdentifier]string + ) + + preparedApp, err := prepareAppString(app) + if err != nil { + return nil, err + } + v, err := url.ParseQuery(preparedApp) + if err != nil { + return nil, err + } + labels = make(map[types.ACIdentifier]string, 0) + for key, val := range v { + if len(val) > 1 { + return nil, fmt.Errorf("label %s with multiple values %q", key, val) + } + if key == "name" { + name = val[0] + continue + } + labelName, err := types.NewACIdentifier(key) + if err != nil { + return nil, err + } + labels[*labelName] = val[0] + } + a, err := NewApp(name, labels) + if err != nil { + return nil, err + } + return a, nil +} + +func prepareAppString(app string) (string, error) { + if err := checkColon(app); err != nil { + return "", err + } + + app = "name=" + strings.Replace(app, ":", ",version=", 1) + return common.MakeQueryString(app) +} + +func checkColon(app string) error { + firstComma := strings.IndexRune(app, ',') + firstColon := strings.IndexRune(app, ':') + if firstColon > firstComma && firstComma > -1 { + return fmt.Errorf("malformed app string - colon may appear only right after the app name") + } + if strings.Count(app, ":") > 1 { + return fmt.Errorf("malformed app string - colon may appear at most once") + } + return nil +} + +func (a *App) Copy() *App { + ac := &App{ + Name: a.Name, + Labels: make(map[types.ACIdentifier]string, 0), + } + for k, v := range a.Labels { + ac.Labels[k] = v + } + return ac +} + +// String returns the URL-like image name +func (a *App) String() string { + img := a.Name.String() + for n, v := range a.Labels { + img += fmt.Sprintf(",%s=%s", n, v) + } + return img +} diff --git a/vendor/github.com/appc/spec/pkg/acirenderer/acirenderer.go b/vendor/github.com/appc/spec/pkg/acirenderer/acirenderer.go new file mode 100644 index 0000000000..25a097f056 --- /dev/null +++ b/vendor/github.com/appc/spec/pkg/acirenderer/acirenderer.go @@ -0,0 +1,253 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package acirenderer + +import ( + "archive/tar" + "crypto/sha512" + "fmt" + "hash" + "io" + "io/ioutil" + "path/filepath" + "strings" + + "github.com/appc/spec/schema" + "github.com/appc/spec/schema/types" +) + +// An ACIRegistry provides all functions of an ACIProvider plus functions to +// search for an aci and get its contents +type ACIRegistry interface { + ACIProvider + GetImageManifest(key string) (*schema.ImageManifest, error) + GetACI(name types.ACIdentifier, labels types.Labels) (string, error) +} + +// An ACIProvider provides functions to get an ACI contents, to convert an +// ACI hash to the key under which the ACI is known to the provider and to resolve an +// image ID to the key under which it's known to the provider. +type ACIProvider interface { + // Read the ACI contents stream given the key. Use ResolveKey to + // convert an image ID to the relative provider's key. + ReadStream(key string) (io.ReadCloser, error) + // Converts an image ID to the, if existent, key under which the + // ACI is known to the provider + ResolveKey(key string) (string, error) + // Converts a Hash to the provider's key + HashToKey(h hash.Hash) string +} + +// An Image contains the ImageManifest, the ACIProvider's key and its Level in +// the dependency tree. +type Image struct { + Im *schema.ImageManifest + Key string + Level uint16 +} + +// Images encapsulates an ordered slice of Image structs. It represents a flat +// dependency tree. +// The upper Image should be the first in the slice with a level of 0. +// For example if A is the upper image and has two deps (in order B and C). And C has one dep (D), +// the slice (reporting the app name and excluding im and Hash) should be: +// [{A, Level: 0}, {C, Level:1}, {D, Level: 2}, {B, Level: 1}] +type Images []Image + +// ACIFiles represents which files to extract for every ACI +type ACIFiles struct { + Key string + FileMap map[string]struct{} +} + +// RenderedACI is an (ordered) slice of ACIFiles +type RenderedACI []*ACIFiles + +// GetRenderedACIWithImageID, given an imageID, starts with the matching image +// available in the store, creates the dependencies list and returns the +// RenderedACI list. +func GetRenderedACIWithImageID(imageID types.Hash, ap ACIRegistry) (RenderedACI, error) { + imgs, err := CreateDepListFromImageID(imageID, ap) + if err != nil { + return nil, err + } + return GetRenderedACIFromList(imgs, ap) +} + +// GetRenderedACI, given an image app name and optional labels, starts with the +// best matching image available in the store, creates the dependencies list +// and returns the RenderedACI list. +func GetRenderedACI(name types.ACIdentifier, labels types.Labels, ap ACIRegistry) (RenderedACI, error) { + imgs, err := CreateDepListFromNameLabels(name, labels, ap) + if err != nil { + return nil, err + } + return GetRenderedACIFromList(imgs, ap) +} + +// GetRenderedACIFromList returns the RenderedACI list. All file outside rootfs +// are excluded (at the moment only "manifest"). +func GetRenderedACIFromList(imgs Images, ap ACIProvider) (RenderedACI, error) { + if len(imgs) == 0 { + return nil, fmt.Errorf("image list empty") + } + + allFiles := make(map[string]byte) + renderedACI := RenderedACI{} + + first := true + for i, img := range imgs { + pwlm := getUpperPWLM(imgs, i) + ra, err := getACIFiles(img, ap, allFiles, pwlm) + if err != nil { + return nil, err + } + // Use the manifest from the upper ACI + if first { + ra.FileMap["manifest"] = struct{}{} + first = false + } + renderedACI = append(renderedACI, ra) + } + + return renderedACI, nil +} + +// getUpperPWLM returns the pwl at the lower level for the branch where +// img[pos] lives. +func getUpperPWLM(imgs Images, pos int) map[string]struct{} { + var pwlm map[string]struct{} + curlevel := imgs[pos].Level + // Start from our position and go back ignoring the other leafs. + for i := pos; i >= 0; i-- { + img := imgs[i] + if img.Level < curlevel && len(img.Im.PathWhitelist) > 0 { + pwlm = pwlToMap(img.Im.PathWhitelist) + } + curlevel = img.Level + } + return pwlm +} + +// getACIFiles returns the ACIFiles struct for the given image. All files +// outside rootfs are excluded (at the moment only "manifest"). +func getACIFiles(img Image, ap ACIProvider, allFiles map[string]byte, pwlm map[string]struct{}) (*ACIFiles, error) { + rs, err := ap.ReadStream(img.Key) + if err != nil { + return nil, err + } + defer rs.Close() + + hash := sha512.New() + r := io.TeeReader(rs, hash) + + thispwlm := pwlToMap(img.Im.PathWhitelist) + ra := &ACIFiles{FileMap: make(map[string]struct{})} + if err = Walk(tar.NewReader(r), func(hdr *tar.Header) error { + name := hdr.Name + cleanName := filepath.Clean(name) + + // Add the rootfs directory. + if cleanName == "rootfs" && hdr.Typeflag == tar.TypeDir { + ra.FileMap[cleanName] = struct{}{} + allFiles[cleanName] = hdr.Typeflag + return nil + } + + // Ignore files outside /rootfs/ (at the moment only "manifest"). + if !strings.HasPrefix(cleanName, "rootfs/") { + return nil + } + + // Is the file in our PathWhiteList? + // If the file is a directory continue also if not in PathWhiteList + if hdr.Typeflag != tar.TypeDir { + if len(img.Im.PathWhitelist) > 0 { + if _, ok := thispwlm[cleanName]; !ok { + return nil + } + } + } + // Is the file in the lower level PathWhiteList of this img branch? + if pwlm != nil { + if _, ok := pwlm[cleanName]; !ok { + return nil + } + } + // Is the file already provided by a previous image? + if _, ok := allFiles[cleanName]; ok { + return nil + } + // Check that the parent dirs are also of type dir in the upper + // images + parentDir := filepath.Dir(cleanName) + for parentDir != "." && parentDir != "/" { + if ft, ok := allFiles[parentDir]; ok && ft != tar.TypeDir { + return nil + } + parentDir = filepath.Dir(parentDir) + } + ra.FileMap[cleanName] = struct{}{} + allFiles[cleanName] = hdr.Typeflag + return nil + }); err != nil { + return nil, err + } + + // Tar does not necessarily read the complete file, so ensure we read the entirety into the hash + if _, err := io.Copy(ioutil.Discard, r); err != nil { + return nil, fmt.Errorf("error reading ACI: %v", err) + } + + if g := ap.HashToKey(hash); g != img.Key { + return nil, fmt.Errorf("image hash does not match expected (%s != %s)", g, img.Key) + } + + ra.Key = img.Key + return ra, nil +} + +// pwlToMap converts a pathWhiteList slice to a map for faster search +// It will also prepend "rootfs/" to the provided paths and they will be +// relative to "/" so they can be easily compared with the tar.Header.Name +// If pwl length is 0, a nil map is returned +func pwlToMap(pwl []string) map[string]struct{} { + if len(pwl) == 0 { + return nil + } + m := make(map[string]struct{}, len(pwl)) + for _, name := range pwl { + relpath := filepath.Join("rootfs", name) + m[relpath] = struct{}{} + } + return m +} + +func Walk(tarReader *tar.Reader, walkFunc func(hdr *tar.Header) error) error { + for { + hdr, err := tarReader.Next() + if err == io.EOF { + // end of tar archive + break + } + if err != nil { + return fmt.Errorf("Error reading tar entry: %v", err) + } + if err := walkFunc(hdr); err != nil { + return err + } + } + return nil +} diff --git a/vendor/github.com/appc/spec/pkg/acirenderer/resolve.go b/vendor/github.com/appc/spec/pkg/acirenderer/resolve.go new file mode 100644 index 0000000000..248bcbf2af --- /dev/null +++ b/vendor/github.com/appc/spec/pkg/acirenderer/resolve.go @@ -0,0 +1,88 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package acirenderer + +import ( + "container/list" + + "github.com/appc/spec/schema/types" +) + +// CreateDepListFromImageID returns the flat dependency tree of the image with +// the provided imageID +func CreateDepListFromImageID(imageID types.Hash, ap ACIRegistry) (Images, error) { + key, err := ap.ResolveKey(imageID.String()) + if err != nil { + return nil, err + } + return createDepList(key, ap) +} + +// CreateDepListFromNameLabels returns the flat dependency tree of the image +// with the provided app name and optional labels. +func CreateDepListFromNameLabels(name types.ACIdentifier, labels types.Labels, ap ACIRegistry) (Images, error) { + key, err := ap.GetACI(name, labels) + if err != nil { + return nil, err + } + return createDepList(key, ap) +} + +// createDepList returns the flat dependency tree as a list of Image type +func createDepList(key string, ap ACIRegistry) (Images, error) { + imgsl := list.New() + im, err := ap.GetImageManifest(key) + if err != nil { + return nil, err + } + + img := Image{Im: im, Key: key, Level: 0} + imgsl.PushFront(img) + + // Create a flat dependency tree. Use a LinkedList to be able to + // insert elements in the list while working on it. + for el := imgsl.Front(); el != nil; el = el.Next() { + img := el.Value.(Image) + dependencies := img.Im.Dependencies + for _, d := range dependencies { + var depimg Image + var depKey string + if d.ImageID != nil && !d.ImageID.Empty() { + depKey, err = ap.ResolveKey(d.ImageID.String()) + if err != nil { + return nil, err + } + } else { + var err error + depKey, err = ap.GetACI(d.ImageName, d.Labels) + if err != nil { + return nil, err + } + } + im, err := ap.GetImageManifest(depKey) + if err != nil { + return nil, err + } + depimg = Image{Im: im, Key: depKey, Level: img.Level + 1} + imgsl.InsertAfter(depimg, el) + } + } + + imgs := Images{} + for el := imgsl.Front(); el != nil; el = el.Next() { + imgs = append(imgs, el.Value.(Image)) + } + return imgs, nil +} diff --git a/vendor/github.com/appc/spec/pkg/device/device_linux.go b/vendor/github.com/appc/spec/pkg/device/device_linux.go new file mode 100644 index 0000000000..4f895cd76e --- /dev/null +++ b/vendor/github.com/appc/spec/pkg/device/device_linux.go @@ -0,0 +1,33 @@ +// Copyright 2016 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build linux + +package device + +// with glibc/sysdeps/unix/sysv/linux/sys/sysmacros.h as reference + +func Major(rdev uint64) uint { + return uint((rdev>>8)&0xfff) | (uint(rdev>>32) & ^uint(0xfff)) +} + +func Minor(rdev uint64) uint { + return uint(rdev&0xff) | uint(uint32(rdev>>12) & ^uint32(0xff)) +} + +func Makedev(maj uint, min uint) uint64 { + return uint64(min&0xff) | (uint64(maj&0xfff) << 8) | + ((uint64(min) & ^uint64(0xff)) << 12) | + ((uint64(maj) & ^uint64(0xfff)) << 32) +} diff --git a/vendor/github.com/appc/spec/pkg/device/device_posix.go b/vendor/github.com/appc/spec/pkg/device/device_posix.go new file mode 100644 index 0000000000..c2e1b31697 --- /dev/null +++ b/vendor/github.com/appc/spec/pkg/device/device_posix.go @@ -0,0 +1,57 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build freebsd netbsd openbsd darwin + +package device + +/* +#define _BSD_SOURCE +#define _DEFAULT_SOURCE +#include + +unsigned int +my_major(dev_t dev) +{ + return major(dev); +} + +unsigned int +my_minor(dev_t dev) +{ + return minor(dev); +} + +dev_t +my_makedev(unsigned int maj, unsigned int min) +{ + return makedev(maj, min); +} +*/ +import "C" + +func Major(rdev uint64) uint { + major := C.my_major(C.dev_t(rdev)) + return uint(major) +} + +func Minor(rdev uint64) uint { + minor := C.my_minor(C.dev_t(rdev)) + return uint(minor) +} + +func Makedev(maj uint, min uint) uint64 { + dev := C.my_makedev(C.uint(maj), C.uint(min)) + return uint64(dev) +} diff --git a/vendor/github.com/appc/spec/pkg/tarheader/doc.go b/vendor/github.com/appc/spec/pkg/tarheader/doc.go new file mode 100644 index 0000000000..047a0c0fa4 --- /dev/null +++ b/vendor/github.com/appc/spec/pkg/tarheader/doc.go @@ -0,0 +1,17 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package tarheader contains a simple abstraction to accurately create +// tar.Headers on different operating systems. +package tarheader diff --git a/vendor/github.com/appc/spec/pkg/tarheader/pop_darwin.go b/vendor/github.com/appc/spec/pkg/tarheader/pop_darwin.go new file mode 100644 index 0000000000..8f68ee77c5 --- /dev/null +++ b/vendor/github.com/appc/spec/pkg/tarheader/pop_darwin.go @@ -0,0 +1,39 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//+build darwin + +package tarheader + +import ( + "archive/tar" + "os" + "syscall" + "time" +) + +func init() { + populateHeaderStat = append(populateHeaderStat, populateHeaderCtime) +} + +func populateHeaderCtime(h *tar.Header, fi os.FileInfo, _ map[uint64]string) { + st, ok := fi.Sys().(*syscall.Stat_t) + if !ok { + return + } + + sec, nsec := st.Ctimespec.Unix() + ctime := time.Unix(sec, nsec) + h.ChangeTime = ctime +} diff --git a/vendor/github.com/appc/spec/pkg/tarheader/pop_linux.go b/vendor/github.com/appc/spec/pkg/tarheader/pop_linux.go new file mode 100644 index 0000000000..2055024084 --- /dev/null +++ b/vendor/github.com/appc/spec/pkg/tarheader/pop_linux.go @@ -0,0 +1,39 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build linux + +package tarheader + +import ( + "archive/tar" + "os" + "syscall" + "time" +) + +func init() { + populateHeaderStat = append(populateHeaderStat, populateHeaderCtime) +} + +func populateHeaderCtime(h *tar.Header, fi os.FileInfo, _ map[uint64]string) { + st, ok := fi.Sys().(*syscall.Stat_t) + if !ok { + return + } + + sec, nsec := st.Ctim.Unix() + ctime := time.Unix(sec, nsec) + h.ChangeTime = ctime +} diff --git a/vendor/github.com/appc/spec/pkg/tarheader/pop_posix.go b/vendor/github.com/appc/spec/pkg/tarheader/pop_posix.go new file mode 100644 index 0000000000..0cc083fee6 --- /dev/null +++ b/vendor/github.com/appc/spec/pkg/tarheader/pop_posix.go @@ -0,0 +1,50 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build linux freebsd netbsd openbsd + +package tarheader + +import ( + "archive/tar" + "os" + "syscall" + + "github.com/appc/spec/pkg/device" +) + +func init() { + populateHeaderStat = append(populateHeaderStat, populateHeaderUnix) +} + +func populateHeaderUnix(h *tar.Header, fi os.FileInfo, seen map[uint64]string) { + st, ok := fi.Sys().(*syscall.Stat_t) + if !ok { + return + } + h.Uid = int(st.Uid) + h.Gid = int(st.Gid) + if st.Mode&syscall.S_IFMT == syscall.S_IFBLK || st.Mode&syscall.S_IFMT == syscall.S_IFCHR { + h.Devminor = int64(device.Minor(uint64(st.Rdev))) + h.Devmajor = int64(device.Major(uint64(st.Rdev))) + } + // If we have already seen this inode, generate a hardlink + p, ok := seen[uint64(st.Ino)] + if ok { + h.Linkname = p + h.Typeflag = tar.TypeLink + } else { + seen[uint64(st.Ino)] = h.Name + } +} diff --git a/vendor/github.com/appc/spec/pkg/tarheader/tarheader.go b/vendor/github.com/appc/spec/pkg/tarheader/tarheader.go new file mode 100644 index 0000000000..dc16c33d33 --- /dev/null +++ b/vendor/github.com/appc/spec/pkg/tarheader/tarheader.go @@ -0,0 +1,28 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package tarheader + +import ( + "archive/tar" + "os" +) + +var populateHeaderStat []func(h *tar.Header, fi os.FileInfo, seen map[uint64]string) + +func Populate(h *tar.Header, fi os.FileInfo, seen map[uint64]string) { + for _, pop := range populateHeaderStat { + pop(h, fi, seen) + } +} diff --git a/vendor/github.com/appc/spec/schema/common/common.go b/vendor/github.com/appc/spec/schema/common/common.go new file mode 100644 index 0000000000..ffc0f6f9b4 --- /dev/null +++ b/vendor/github.com/appc/spec/schema/common/common.go @@ -0,0 +1,40 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package common + +import ( + "fmt" + "net/url" + "strings" +) + +// MakeQueryString takes a comma-separated LABEL=VALUE string and returns an +// "&"-separated string with URL escaped values. +// +// Examples: +// version=1.0.0,label=v1+v2 -> version=1.0.0&label=v1%2Bv2 +// name=db,source=/tmp$1 -> name=db&source=%2Ftmp%241 +func MakeQueryString(app string) (string, error) { + parts := strings.Split(app, ",") + escapedParts := make([]string, len(parts)) + for i, s := range parts { + p := strings.SplitN(s, "=", 2) + if len(p) != 2 { + return "", fmt.Errorf("malformed string %q - has a label without a value: %s", app, p[0]) + } + escapedParts[i] = fmt.Sprintf("%s=%s", p[0], url.QueryEscape(p[1])) + } + return strings.Join(escapedParts, "&"), nil +} diff --git a/vendor/github.com/appc/spec/schema/doc.go b/vendor/github.com/appc/spec/schema/doc.go new file mode 100644 index 0000000000..ba381543f8 --- /dev/null +++ b/vendor/github.com/appc/spec/schema/doc.go @@ -0,0 +1,25 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package schema provides definitions for the JSON schema of the different +// manifests in the App Container Specification. The manifests are canonically +// represented in their respective structs: +// - `ImageManifest` +// - `PodManifest` +// +// Validation is performed through serialization: if a blob of JSON data will +// unmarshal to one of the *Manifests, it is considered a valid implementation +// of the standard. Similarly, if a constructed *Manifest struct marshals +// successfully to JSON, it must be valid. +package schema diff --git a/vendor/github.com/appc/spec/schema/image.go b/vendor/github.com/appc/spec/schema/image.go new file mode 100644 index 0000000000..fac4c794c3 --- /dev/null +++ b/vendor/github.com/appc/spec/schema/image.go @@ -0,0 +1,103 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package schema + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + + "github.com/appc/spec/schema/types" + + "go4.org/errorutil" +) + +const ( + ACIExtension = ".aci" + ImageManifestKind = types.ACKind("ImageManifest") +) + +type ImageManifest struct { + ACKind types.ACKind `json:"acKind"` + ACVersion types.SemVer `json:"acVersion"` + Name types.ACIdentifier `json:"name"` + Labels types.Labels `json:"labels,omitempty"` + App *types.App `json:"app,omitempty"` + Annotations types.Annotations `json:"annotations,omitempty"` + Dependencies types.Dependencies `json:"dependencies,omitempty"` + PathWhitelist []string `json:"pathWhitelist,omitempty"` +} + +// imageManifest is a model to facilitate extra validation during the +// unmarshalling of the ImageManifest +type imageManifest ImageManifest + +func BlankImageManifest() *ImageManifest { + return &ImageManifest{ACKind: ImageManifestKind, ACVersion: AppContainerVersion} +} + +func (im *ImageManifest) UnmarshalJSON(data []byte) error { + a := imageManifest(*im) + err := json.Unmarshal(data, &a) + if err != nil { + if serr, ok := err.(*json.SyntaxError); ok { + line, col, highlight := errorutil.HighlightBytePosition(bytes.NewReader(data), serr.Offset) + return fmt.Errorf("\nError at line %d, column %d\n%s%v", line, col, highlight, err) + } + return err + } + nim := ImageManifest(a) + if err := nim.assertValid(); err != nil { + return err + } + *im = nim + return nil +} + +func (im ImageManifest) MarshalJSON() ([]byte, error) { + if err := im.assertValid(); err != nil { + return nil, err + } + return json.Marshal(imageManifest(im)) +} + +var imKindError = types.InvalidACKindError(ImageManifestKind) + +// assertValid performs extra assertions on an ImageManifest to ensure that +// fields are set appropriately, etc. It is used exclusively when marshalling +// and unmarshalling an ImageManifest. Most field-specific validation is +// performed through the individual types being marshalled; assertValid() +// should only deal with higher-level validation. +func (im *ImageManifest) assertValid() error { + if im.ACKind != ImageManifestKind { + return imKindError + } + if im.ACVersion.Empty() { + return errors.New(`acVersion must be set`) + } + if im.Name.Empty() { + return errors.New(`name must be set`) + } + return nil +} + +func (im *ImageManifest) GetLabel(name string) (val string, ok bool) { + return im.Labels.Get(name) +} + +func (im *ImageManifest) GetAnnotation(name string) (val string, ok bool) { + return im.Annotations.Get(name) +} diff --git a/vendor/github.com/appc/spec/schema/kind.go b/vendor/github.com/appc/spec/schema/kind.go new file mode 100644 index 0000000000..5dc4f957ec --- /dev/null +++ b/vendor/github.com/appc/spec/schema/kind.go @@ -0,0 +1,42 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package schema + +import ( + "encoding/json" + + "github.com/appc/spec/schema/types" +) + +type Kind struct { + ACVersion types.SemVer `json:"acVersion"` + ACKind types.ACKind `json:"acKind"` +} + +type kind Kind + +func (k *Kind) UnmarshalJSON(data []byte) error { + nk := kind{} + err := json.Unmarshal(data, &nk) + if err != nil { + return err + } + *k = Kind(nk) + return nil +} + +func (k Kind) MarshalJSON() ([]byte, error) { + return json.Marshal(kind(k)) +} diff --git a/vendor/github.com/appc/spec/schema/lastditch/doc.go b/vendor/github.com/appc/spec/schema/lastditch/doc.go new file mode 100644 index 0000000000..9cc5734607 --- /dev/null +++ b/vendor/github.com/appc/spec/schema/lastditch/doc.go @@ -0,0 +1,28 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package lastditch provides fallback redefinitions of parts of +// schemas provided by schema package. +// +// Almost no validation of schemas is done (besides checking if data +// really is `JSON`-encoded and kind is either `ImageManifest` or +// `PodManifest`. This is to get as much data as possible from an +// invalid manifest. The main aim of the package is to be used for the +// better error reporting. The another aim might be to force some +// operation (like removing a pod), which would otherwise fail because +// of an invalid manifest. +// +// To avoid validation during deserialization, types provided by this +// package use plain strings. +package lastditch diff --git a/vendor/github.com/appc/spec/schema/lastditch/image.go b/vendor/github.com/appc/spec/schema/lastditch/image.go new file mode 100644 index 0000000000..dc5055a056 --- /dev/null +++ b/vendor/github.com/appc/spec/schema/lastditch/image.go @@ -0,0 +1,45 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package lastditch + +import ( + "encoding/json" + + "github.com/appc/spec/schema" + "github.com/appc/spec/schema/types" +) + +type ImageManifest struct { + ACVersion string `json:"acVersion"` + ACKind string `json:"acKind"` + Name string `json:"name"` + Labels Labels `json:"labels,omitempty"` +} + +// a type just to avoid a recursion during unmarshalling +type imageManifest ImageManifest + +func (im *ImageManifest) UnmarshalJSON(data []byte) error { + i := imageManifest(*im) + err := json.Unmarshal(data, &i) + if err != nil { + return err + } + if i.ACKind != string(schema.ImageManifestKind) { + return types.InvalidACKindError(schema.ImageManifestKind) + } + *im = ImageManifest(i) + return nil +} diff --git a/vendor/github.com/appc/spec/schema/lastditch/labels.go b/vendor/github.com/appc/spec/schema/lastditch/labels.go new file mode 100644 index 0000000000..5cf93a087c --- /dev/null +++ b/vendor/github.com/appc/spec/schema/lastditch/labels.go @@ -0,0 +1,38 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package lastditch + +import ( + "encoding/json" +) + +type Labels []Label + +// a type just to avoid a recursion during unmarshalling +type labels Labels + +type Label struct { + Name string `json:"name"` + Value string `json:"value"` +} + +func (l *Labels) UnmarshalJSON(data []byte) error { + var jl labels + if err := json.Unmarshal(data, &jl); err != nil { + return err + } + *l = Labels(jl) + return nil +} diff --git a/vendor/github.com/appc/spec/schema/lastditch/pod.go b/vendor/github.com/appc/spec/schema/lastditch/pod.go new file mode 100644 index 0000000000..2e9d8456bb --- /dev/null +++ b/vendor/github.com/appc/spec/schema/lastditch/pod.go @@ -0,0 +1,57 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package lastditch + +import ( + "encoding/json" + + "github.com/appc/spec/schema" + "github.com/appc/spec/schema/types" +) + +type PodManifest struct { + ACVersion string `json:"acVersion"` + ACKind string `json:"acKind"` + Apps AppList `json:"apps"` +} + +type AppList []RuntimeApp + +type RuntimeApp struct { + Name string `json:"name"` + Image RuntimeImage `json:"image"` +} + +type RuntimeImage struct { + Name string `json:"name"` + ID string `json:"id"` + Labels Labels `json:"labels,omitempty"` +} + +// a type just to avoid a recursion during unmarshalling +type podManifest PodManifest + +func (pm *PodManifest) UnmarshalJSON(data []byte) error { + p := podManifest(*pm) + err := json.Unmarshal(data, &p) + if err != nil { + return err + } + if p.ACKind != string(schema.PodManifestKind) { + return types.InvalidACKindError(schema.PodManifestKind) + } + *pm = PodManifest(p) + return nil +} diff --git a/vendor/github.com/appc/spec/schema/pod.go b/vendor/github.com/appc/spec/schema/pod.go new file mode 100644 index 0000000000..d4792ff3b4 --- /dev/null +++ b/vendor/github.com/appc/spec/schema/pod.go @@ -0,0 +1,168 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package schema + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + + "github.com/appc/spec/schema/types" + + "go4.org/errorutil" +) + +const PodManifestKind = types.ACKind("PodManifest") + +type PodManifest struct { + ACVersion types.SemVer `json:"acVersion"` + ACKind types.ACKind `json:"acKind"` + Apps AppList `json:"apps"` + Volumes []types.Volume `json:"volumes"` + Isolators []types.Isolator `json:"isolators"` + Annotations types.Annotations `json:"annotations"` + Ports []types.ExposedPort `json:"ports"` +} + +// podManifest is a model to facilitate extra validation during the +// unmarshalling of the PodManifest +type podManifest PodManifest + +func BlankPodManifest() *PodManifest { + return &PodManifest{ACKind: PodManifestKind, ACVersion: AppContainerVersion} +} + +func (pm *PodManifest) UnmarshalJSON(data []byte) error { + p := podManifest(*pm) + err := json.Unmarshal(data, &p) + if err != nil { + if serr, ok := err.(*json.SyntaxError); ok { + line, col, highlight := errorutil.HighlightBytePosition(bytes.NewReader(data), serr.Offset) + return fmt.Errorf("\nError at line %d, column %d\n%s%v", line, col, highlight, err) + } + return err + } + npm := PodManifest(p) + if err := npm.assertValid(); err != nil { + return err + } + *pm = npm + return nil +} + +func (pm PodManifest) MarshalJSON() ([]byte, error) { + if err := pm.assertValid(); err != nil { + return nil, err + } + return json.Marshal(podManifest(pm)) +} + +var pmKindError = types.InvalidACKindError(PodManifestKind) + +// assertValid performs extra assertions on an PodManifest to +// ensure that fields are set appropriately, etc. It is used exclusively when +// marshalling and unmarshalling an PodManifest. Most +// field-specific validation is performed through the individual types being +// marshalled; assertValid() should only deal with higher-level validation. +func (pm *PodManifest) assertValid() error { + if pm.ACKind != PodManifestKind { + return pmKindError + } + return nil +} + +type AppList []RuntimeApp + +type appList AppList + +func (al *AppList) UnmarshalJSON(data []byte) error { + a := appList{} + err := json.Unmarshal(data, &a) + if err != nil { + return err + } + nal := AppList(a) + if err := nal.assertValid(); err != nil { + return err + } + *al = nal + return nil +} + +func (al AppList) MarshalJSON() ([]byte, error) { + if err := al.assertValid(); err != nil { + return nil, err + } + return json.Marshal(appList(al)) +} + +func (al AppList) assertValid() error { + seen := map[types.ACName]bool{} + for _, a := range al { + if _, ok := seen[a.Name]; ok { + return fmt.Errorf(`duplicate apps of name %q`, a.Name) + } + seen[a.Name] = true + } + return nil +} + +// Get retrieves an app by the specified name from the AppList; if there is +// no such app, nil is returned. The returned *RuntimeApp MUST be considered +// read-only. +func (al AppList) Get(name types.ACName) *RuntimeApp { + for _, a := range al { + if name.Equals(a.Name) { + aa := a + return &aa + } + } + return nil +} + +// Mount describes the mapping between a volume and the path it is mounted +// inside of an app's filesystem. +type Mount struct { + Volume types.ACName `json:"volume"` + Path string `json:"path"` +} + +func (r Mount) assertValid() error { + if r.Volume.Empty() { + return errors.New("volume must be set") + } + if r.Path == "" { + return errors.New("path must be set") + } + return nil +} + +// RuntimeApp describes an application referenced in a PodManifest +type RuntimeApp struct { + Name types.ACName `json:"name"` + Image RuntimeImage `json:"image"` + App *types.App `json:"app,omitempty"` + ReadOnlyRootFS bool `json:"readOnlyRootFS,omitempty"` + Mounts []Mount `json:"mounts,omitempty"` + Annotations types.Annotations `json:"annotations,omitempty"` +} + +// RuntimeImage describes an image referenced in a RuntimeApp +type RuntimeImage struct { + Name *types.ACIdentifier `json:"name,omitempty"` + ID types.Hash `json:"id"` + Labels types.Labels `json:"labels,omitempty"` +} diff --git a/vendor/github.com/appc/spec/schema/types/acidentifier.go b/vendor/github.com/appc/spec/schema/types/acidentifier.go new file mode 100644 index 0000000000..904eda5cbc --- /dev/null +++ b/vendor/github.com/appc/spec/schema/types/acidentifier.go @@ -0,0 +1,145 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "encoding/json" + "errors" + "regexp" + "strings" +) + +var ( + // ValidACIdentifier is a regular expression that defines a valid ACIdentifier + ValidACIdentifier = regexp.MustCompile("^[a-z0-9]+([-._~/][a-z0-9]+)*$") + + invalidACIdentifierChars = regexp.MustCompile("[^a-z0-9-._~/]") + invalidACIdentifierEdges = regexp.MustCompile("(^[-._~/]+)|([-._~/]+$)") + + ErrEmptyACIdentifier = ACIdentifierError("ACIdentifier cannot be empty") + ErrInvalidEdgeInACIdentifier = ACIdentifierError("ACIdentifier must start and end with only lower case " + + "alphanumeric characters") + ErrInvalidCharInACIdentifier = ACIdentifierError("ACIdentifier must contain only lower case " + + `alphanumeric characters plus "-._~/"`) +) + +// ACIdentifier (an App-Container Identifier) is a format used by keys in image names +// and image labels of the App Container Standard. An ACIdentifier is restricted to numeric +// and lowercase URI unreserved characters defined in URI RFC[1]; all alphabetical characters +// must be lowercase only. Furthermore, the first and last character ("edges") must be +// alphanumeric, and an ACIdentifier cannot be empty. Programmatically, an ACIdentifier must +// conform to the regular expression ValidACIdentifier. +// +// [1] http://tools.ietf.org/html/rfc3986#section-2.3 +type ACIdentifier string + +func (n ACIdentifier) String() string { + return string(n) +} + +// Set sets the ACIdentifier to the given value, if it is valid; if not, +// an error is returned. +func (n *ACIdentifier) Set(s string) error { + nn, err := NewACIdentifier(s) + if err == nil { + *n = *nn + } + return err +} + +// Equals checks whether a given ACIdentifier is equal to this one. +func (n ACIdentifier) Equals(o ACIdentifier) bool { + return strings.ToLower(string(n)) == strings.ToLower(string(o)) +} + +// Empty returns a boolean indicating whether this ACIdentifier is empty. +func (n ACIdentifier) Empty() bool { + return n.String() == "" +} + +// NewACIdentifier generates a new ACIdentifier from a string. If the given string is +// not a valid ACIdentifier, nil and an error are returned. +func NewACIdentifier(s string) (*ACIdentifier, error) { + n := ACIdentifier(s) + if err := n.assertValid(); err != nil { + return nil, err + } + return &n, nil +} + +// MustACIdentifier generates a new ACIdentifier from a string, If the given string is +// not a valid ACIdentifier, it panics. +func MustACIdentifier(s string) *ACIdentifier { + n, err := NewACIdentifier(s) + if err != nil { + panic(err) + } + return n +} + +func (n ACIdentifier) assertValid() error { + s := string(n) + if len(s) == 0 { + return ErrEmptyACIdentifier + } + if invalidACIdentifierChars.MatchString(s) { + return ErrInvalidCharInACIdentifier + } + if invalidACIdentifierEdges.MatchString(s) { + return ErrInvalidEdgeInACIdentifier + } + return nil +} + +// UnmarshalJSON implements the json.Unmarshaler interface +func (n *ACIdentifier) UnmarshalJSON(data []byte) error { + var s string + if err := json.Unmarshal(data, &s); err != nil { + return err + } + nn, err := NewACIdentifier(s) + if err != nil { + return err + } + *n = *nn + return nil +} + +// MarshalJSON implements the json.Marshaler interface +func (n ACIdentifier) MarshalJSON() ([]byte, error) { + if err := n.assertValid(); err != nil { + return nil, err + } + return json.Marshal(n.String()) +} + +// SanitizeACIdentifier replaces every invalid ACIdentifier character in s with an underscore +// making it a legal ACIdentifier string. If the character is an upper case letter it +// replaces it with its lower case. It also removes illegal edge characters +// (hyphens, period, underscore, tilde and slash). +// +// This is a helper function and its algorithm is not part of the spec. It +// should not be called without the user explicitly asking for a suggestion. +func SanitizeACIdentifier(s string) (string, error) { + s = strings.ToLower(s) + s = invalidACIdentifierChars.ReplaceAllString(s, "_") + s = invalidACIdentifierEdges.ReplaceAllString(s, "") + + if s == "" { + return "", errors.New("must contain at least one valid character") + } + + return s, nil +} diff --git a/vendor/github.com/appc/spec/schema/types/ackind.go b/vendor/github.com/appc/spec/schema/types/ackind.go new file mode 100644 index 0000000000..1793ca8de8 --- /dev/null +++ b/vendor/github.com/appc/spec/schema/types/ackind.go @@ -0,0 +1,67 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "encoding/json" + "fmt" +) + +var ( + ErrNoACKind = ACKindError("ACKind must be set") +) + +// ACKind wraps a string to define a field which must be set with one of +// several ACKind values. If it is unset, or has an invalid value, the field +// will refuse to marshal/unmarshal. +type ACKind string + +func (a ACKind) String() string { + return string(a) +} + +func (a ACKind) assertValid() error { + s := a.String() + switch s { + case "ImageManifest", "PodManifest": + return nil + case "": + return ErrNoACKind + default: + msg := fmt.Sprintf("bad ACKind: %s", s) + return ACKindError(msg) + } +} + +func (a ACKind) MarshalJSON() ([]byte, error) { + if err := a.assertValid(); err != nil { + return nil, err + } + return json.Marshal(a.String()) +} + +func (a *ACKind) UnmarshalJSON(data []byte) error { + var s string + err := json.Unmarshal(data, &s) + if err != nil { + return err + } + na := ACKind(s) + if err := na.assertValid(); err != nil { + return err + } + *a = na + return nil +} diff --git a/vendor/github.com/appc/spec/schema/types/acname.go b/vendor/github.com/appc/spec/schema/types/acname.go new file mode 100644 index 0000000000..5ececffb7f --- /dev/null +++ b/vendor/github.com/appc/spec/schema/types/acname.go @@ -0,0 +1,145 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "encoding/json" + "errors" + "regexp" + "strings" +) + +var ( + // ValidACName is a regular expression that defines a valid ACName + ValidACName = regexp.MustCompile("^[a-z0-9]+([-][a-z0-9]+)*$") + + invalidACNameChars = regexp.MustCompile("[^a-z0-9-]") + invalidACNameEdges = regexp.MustCompile("(^[-]+)|([-]+$)") + + ErrEmptyACName = ACNameError("ACName cannot be empty") + ErrInvalidEdgeInACName = ACNameError("ACName must start and end with only lower case " + + "alphanumeric characters") + ErrInvalidCharInACName = ACNameError("ACName must contain only lower case " + + `alphanumeric characters plus "-"`) +) + +// ACName (an App-Container Name) is a format used by keys in different formats +// of the App Container Standard. An ACName is restricted to numeric and lowercase +// characters accepted by the DNS RFC[1] plus "-"; all alphabetical characters must +// be lowercase only. Furthermore, the first and last character ("edges") must be +// alphanumeric, and an ACName cannot be empty. Programmatically, an ACName must +// conform to the regular expression ValidACName. +// +// [1] http://tools.ietf.org/html/rfc1123#page-13 +type ACName string + +func (n ACName) String() string { + return string(n) +} + +// Set sets the ACName to the given value, if it is valid; if not, +// an error is returned. +func (n *ACName) Set(s string) error { + nn, err := NewACName(s) + if err == nil { + *n = *nn + } + return err +} + +// Equals checks whether a given ACName is equal to this one. +func (n ACName) Equals(o ACName) bool { + return strings.ToLower(string(n)) == strings.ToLower(string(o)) +} + +// Empty returns a boolean indicating whether this ACName is empty. +func (n ACName) Empty() bool { + return n.String() == "" +} + +// NewACName generates a new ACName from a string. If the given string is +// not a valid ACName, nil and an error are returned. +func NewACName(s string) (*ACName, error) { + n := ACName(s) + if err := n.assertValid(); err != nil { + return nil, err + } + return &n, nil +} + +// MustACName generates a new ACName from a string, If the given string is +// not a valid ACName, it panics. +func MustACName(s string) *ACName { + n, err := NewACName(s) + if err != nil { + panic(err) + } + return n +} + +func (n ACName) assertValid() error { + s := string(n) + if len(s) == 0 { + return ErrEmptyACName + } + if invalidACNameChars.MatchString(s) { + return ErrInvalidCharInACName + } + if invalidACNameEdges.MatchString(s) { + return ErrInvalidEdgeInACName + } + return nil +} + +// UnmarshalJSON implements the json.Unmarshaler interface +func (n *ACName) UnmarshalJSON(data []byte) error { + var s string + if err := json.Unmarshal(data, &s); err != nil { + return err + } + nn, err := NewACName(s) + if err != nil { + return err + } + *n = *nn + return nil +} + +// MarshalJSON implements the json.Marshaler interface +func (n ACName) MarshalJSON() ([]byte, error) { + if err := n.assertValid(); err != nil { + return nil, err + } + return json.Marshal(n.String()) +} + +// SanitizeACName replaces every invalid ACName character in s with a dash +// making it a legal ACName string. If the character is an upper case letter it +// replaces it with its lower case. It also removes illegal edge characters +// (hyphens). +// +// This is a helper function and its algorithm is not part of the spec. It +// should not be called without the user explicitly asking for a suggestion. +func SanitizeACName(s string) (string, error) { + s = strings.ToLower(s) + s = invalidACNameChars.ReplaceAllString(s, "-") + s = invalidACNameEdges.ReplaceAllString(s, "") + + if s == "" { + return "", errors.New("must contain at least one valid character") + } + + return s, nil +} diff --git a/vendor/github.com/appc/spec/schema/types/annotations.go b/vendor/github.com/appc/spec/schema/types/annotations.go new file mode 100644 index 0000000000..ce7743bf53 --- /dev/null +++ b/vendor/github.com/appc/spec/schema/types/annotations.go @@ -0,0 +1,106 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "encoding/json" + "fmt" +) + +type Annotations []Annotation + +type annotations Annotations + +type Annotation struct { + Name ACIdentifier `json:"name"` + Value string `json:"value"` +} + +func (a Annotations) assertValid() error { + seen := map[ACIdentifier]string{} + for _, anno := range a { + _, ok := seen[anno.Name] + if ok { + return fmt.Errorf(`duplicate annotations of name %q`, anno.Name) + } + seen[anno.Name] = anno.Value + } + if c, ok := seen["created"]; ok { + if _, err := NewDate(c); err != nil { + return err + } + } + if h, ok := seen["homepage"]; ok { + if _, err := NewURL(h); err != nil { + return err + } + } + if d, ok := seen["documentation"]; ok { + if _, err := NewURL(d); err != nil { + return err + } + } + + return nil +} + +func (a Annotations) MarshalJSON() ([]byte, error) { + if err := a.assertValid(); err != nil { + return nil, err + } + return json.Marshal(annotations(a)) +} + +func (a *Annotations) UnmarshalJSON(data []byte) error { + var ja annotations + if err := json.Unmarshal(data, &ja); err != nil { + return err + } + na := Annotations(ja) + if err := na.assertValid(); err != nil { + return err + } + *a = na + return nil +} + +// Retrieve the value of an annotation by the given name from Annotations, if +// it exists. +func (a Annotations) Get(name string) (val string, ok bool) { + for _, anno := range a { + if anno.Name.String() == name { + return anno.Value, true + } + } + return "", false +} + +// Set sets the value of an annotation by the given name, overwriting if one already exists. +func (a *Annotations) Set(name ACIdentifier, value string) { + for i, anno := range *a { + if anno.Name.Equals(name) { + (*a)[i] = Annotation{ + Name: name, + Value: value, + } + return + } + } + anno := Annotation{ + Name: name, + Value: value, + } + *a = append(*a, anno) +} diff --git a/vendor/github.com/appc/spec/schema/types/app.go b/vendor/github.com/appc/spec/schema/types/app.go new file mode 100644 index 0000000000..df13bf1c3a --- /dev/null +++ b/vendor/github.com/appc/spec/schema/types/app.go @@ -0,0 +1,90 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "encoding/json" + "errors" + "fmt" + "path" +) + +type App struct { + Exec Exec `json:"exec"` + EventHandlers []EventHandler `json:"eventHandlers,omitempty"` + User string `json:"user"` + Group string `json:"group"` + SupplementaryGIDs []int `json:"supplementaryGIDs,omitempty"` + WorkingDirectory string `json:"workingDirectory,omitempty"` + Environment Environment `json:"environment,omitempty"` + MountPoints []MountPoint `json:"mountPoints,omitempty"` + Ports []Port `json:"ports,omitempty"` + Isolators Isolators `json:"isolators,omitempty"` +} + +// app is a model to facilitate extra validation during the +// unmarshalling of the App +type app App + +func (a *App) UnmarshalJSON(data []byte) error { + ja := app(*a) + err := json.Unmarshal(data, &ja) + if err != nil { + return err + } + na := App(ja) + if err := na.assertValid(); err != nil { + return err + } + if na.Environment == nil { + na.Environment = make(Environment, 0) + } + *a = na + return nil +} + +func (a App) MarshalJSON() ([]byte, error) { + if err := a.assertValid(); err != nil { + return nil, err + } + return json.Marshal(app(a)) +} + +func (a *App) assertValid() error { + if err := a.Exec.assertValid(); err != nil { + return err + } + if a.User == "" { + return errors.New(`user is required`) + } + if a.Group == "" { + return errors.New(`group is required`) + } + if !path.IsAbs(a.WorkingDirectory) && a.WorkingDirectory != "" { + return errors.New("workingDirectory must be an absolute path") + } + eh := make(map[string]bool) + for _, e := range a.EventHandlers { + name := e.Name + if eh[name] { + return fmt.Errorf("Only one eventHandler of name %q allowed", name) + } + eh[name] = true + } + if err := a.Environment.assertValid(); err != nil { + return err + } + return nil +} diff --git a/vendor/github.com/appc/spec/schema/types/date.go b/vendor/github.com/appc/spec/schema/types/date.go new file mode 100644 index 0000000000..4458bf45d9 --- /dev/null +++ b/vendor/github.com/appc/spec/schema/types/date.go @@ -0,0 +1,60 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "encoding/json" + "fmt" + "time" +) + +// Date wraps time.Time to marshal/unmarshal to/from JSON strings in strict +// accordance with RFC3339 +// TODO(jonboulle): golang's implementation seems slightly buggy here; +// according to http://tools.ietf.org/html/rfc3339#section-5.6 , applications +// may choose to separate the date and time with a space instead of a T +// character (for example, `date --rfc-3339` on GNU coreutils) - but this is +// considered an error by go's parser. File a bug? +type Date time.Time + +func NewDate(s string) (*Date, error) { + t, err := time.Parse(time.RFC3339, s) + if err != nil { + return nil, fmt.Errorf("bad Date: %v", err) + } + d := Date(t) + return &d, nil +} + +func (d Date) String() string { + return time.Time(d).Format(time.RFC3339) +} + +func (d *Date) UnmarshalJSON(data []byte) error { + var s string + if err := json.Unmarshal(data, &s); err != nil { + return err + } + nd, err := NewDate(s) + if err != nil { + return err + } + *d = *nd + return nil +} + +func (d Date) MarshalJSON() ([]byte, error) { + return json.Marshal(d.String()) +} diff --git a/vendor/github.com/appc/spec/schema/types/dependencies.go b/vendor/github.com/appc/spec/schema/types/dependencies.go new file mode 100644 index 0000000000..fb399e4041 --- /dev/null +++ b/vendor/github.com/appc/spec/schema/types/dependencies.go @@ -0,0 +1,58 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "encoding/json" + "errors" +) + +type Dependencies []Dependency + +type Dependency struct { + ImageName ACIdentifier `json:"imageName"` + ImageID *Hash `json:"imageID,omitempty"` + Labels Labels `json:"labels,omitempty"` + Size uint `json:"size,omitempty"` +} + +type dependency Dependency + +func (d Dependency) assertValid() error { + if len(d.ImageName) < 1 { + return errors.New(`imageName cannot be empty`) + } + return nil +} + +func (d Dependency) MarshalJSON() ([]byte, error) { + if err := d.assertValid(); err != nil { + return nil, err + } + return json.Marshal(dependency(d)) +} + +func (d *Dependency) UnmarshalJSON(data []byte) error { + var jd dependency + if err := json.Unmarshal(data, &jd); err != nil { + return err + } + nd := Dependency(jd) + if err := nd.assertValid(); err != nil { + return err + } + *d = nd + return nil +} diff --git a/vendor/github.com/appc/spec/schema/types/doc.go b/vendor/github.com/appc/spec/schema/types/doc.go new file mode 100644 index 0000000000..9c540851b0 --- /dev/null +++ b/vendor/github.com/appc/spec/schema/types/doc.go @@ -0,0 +1,18 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package types contains structs representing the various types in the app +// container specification. It is used by the [schema manifest types](../) +// to enforce validation. +package types diff --git a/vendor/github.com/appc/spec/schema/types/environment.go b/vendor/github.com/appc/spec/schema/types/environment.go new file mode 100644 index 0000000000..f152a6b88d --- /dev/null +++ b/vendor/github.com/appc/spec/schema/types/environment.go @@ -0,0 +1,110 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "encoding/json" + "fmt" + "regexp" +) + +var ( + envPattern = regexp.MustCompile("^[A-Za-z_][A-Za-z_0-9]*$") +) + +type Environment []EnvironmentVariable + +type environment Environment + +type EnvironmentVariable struct { + Name string `json:"name"` + Value string `json:"value"` +} + +func (ev EnvironmentVariable) assertValid() error { + if len(ev.Name) == 0 { + return fmt.Errorf(`environment variable name must not be empty`) + } + if !envPattern.MatchString(ev.Name) { + return fmt.Errorf(`environment variable does not have valid identifier %q`, ev.Name) + } + return nil +} + +func (e Environment) assertValid() error { + seen := map[string]bool{} + for _, env := range e { + if err := env.assertValid(); err != nil { + return err + } + _, ok := seen[env.Name] + if ok { + return fmt.Errorf(`duplicate environment variable of name %q`, env.Name) + } + seen[env.Name] = true + } + + return nil +} + +func (e Environment) MarshalJSON() ([]byte, error) { + if err := e.assertValid(); err != nil { + return nil, err + } + return json.Marshal(environment(e)) +} + +func (e *Environment) UnmarshalJSON(data []byte) error { + var je environment + if err := json.Unmarshal(data, &je); err != nil { + return err + } + ne := Environment(je) + if err := ne.assertValid(); err != nil { + return err + } + *e = ne + return nil +} + +// Retrieve the value of an environment variable by the given name from +// Environment, if it exists. +func (e Environment) Get(name string) (value string, ok bool) { + for _, env := range e { + if env.Name == name { + return env.Value, true + } + } + return "", false +} + +// Set sets the value of an environment variable by the given name, +// overwriting if one already exists. +func (e *Environment) Set(name string, value string) { + for i, env := range *e { + if env.Name == name { + (*e)[i] = EnvironmentVariable{ + Name: name, + Value: value, + } + return + } + } + env := EnvironmentVariable{ + Name: name, + Value: value, + } + *e = append(*e, env) +} diff --git a/vendor/github.com/appc/spec/schema/types/errors.go b/vendor/github.com/appc/spec/schema/types/errors.go new file mode 100644 index 0000000000..bb46515944 --- /dev/null +++ b/vendor/github.com/appc/spec/schema/types/errors.go @@ -0,0 +1,49 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import "fmt" + +// An ACKindError is returned when the wrong ACKind is set in a manifest +type ACKindError string + +func (e ACKindError) Error() string { + return string(e) +} + +func InvalidACKindError(kind ACKind) ACKindError { + return ACKindError(fmt.Sprintf("missing or bad ACKind (must be %#v)", kind)) +} + +// An ACVersionError is returned when a bad ACVersion is set in a manifest +type ACVersionError string + +func (e ACVersionError) Error() string { + return string(e) +} + +// An ACIdentifierError is returned when a bad value is used for an ACIdentifier +type ACIdentifierError string + +func (e ACIdentifierError) Error() string { + return string(e) +} + +// An ACNameError is returned when a bad value is used for an ACName +type ACNameError string + +func (e ACNameError) Error() string { + return string(e) +} diff --git a/vendor/github.com/appc/spec/schema/types/event_handler.go b/vendor/github.com/appc/spec/schema/types/event_handler.go new file mode 100644 index 0000000000..f40c642be4 --- /dev/null +++ b/vendor/github.com/appc/spec/schema/types/event_handler.go @@ -0,0 +1,61 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "encoding/json" + "errors" + "fmt" +) + +type EventHandler struct { + Name string `json:"name"` + Exec Exec `json:"exec"` +} + +type eventHandler EventHandler + +func (e EventHandler) assertValid() error { + s := e.Name + switch s { + case "pre-start", "post-stop": + return nil + case "": + return errors.New(`eventHandler "name" cannot be empty`) + default: + return fmt.Errorf(`bad eventHandler "name": %q`, s) + } +} + +func (e EventHandler) MarshalJSON() ([]byte, error) { + if err := e.assertValid(); err != nil { + return nil, err + } + return json.Marshal(eventHandler(e)) +} + +func (e *EventHandler) UnmarshalJSON(data []byte) error { + var je eventHandler + err := json.Unmarshal(data, &je) + if err != nil { + return err + } + ne := EventHandler(je) + if err := ne.assertValid(); err != nil { + return err + } + *e = ne + return nil +} diff --git a/vendor/github.com/appc/spec/schema/types/exec.go b/vendor/github.com/appc/spec/schema/types/exec.go new file mode 100644 index 0000000000..fa8b156cfb --- /dev/null +++ b/vendor/github.com/appc/spec/schema/types/exec.go @@ -0,0 +1,46 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import "encoding/json" + +type Exec []string + +type exec Exec + +func (e Exec) assertValid() error { + return nil +} + +func (e Exec) MarshalJSON() ([]byte, error) { + if err := e.assertValid(); err != nil { + return nil, err + } + return json.Marshal(exec(e)) +} + +func (e *Exec) UnmarshalJSON(data []byte) error { + var je exec + err := json.Unmarshal(data, &je) + if err != nil { + return err + } + ne := Exec(je) + if err := ne.assertValid(); err != nil { + return err + } + *e = ne + return nil +} diff --git a/vendor/github.com/appc/spec/schema/types/hash.go b/vendor/github.com/appc/spec/schema/types/hash.go new file mode 100644 index 0000000000..1c060a47a0 --- /dev/null +++ b/vendor/github.com/appc/spec/schema/types/hash.go @@ -0,0 +1,118 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "crypto/sha512" + "encoding/json" + "errors" + "fmt" + "reflect" + "strings" +) + +const ( + maxHashSize = (sha512.Size / 2) + len("sha512-") +) + +// Hash encodes a hash specified in a string of the form: +// "-" +// for example +// "sha512-06c733b1838136838e6d2d3e8fa5aea4c7905e92[...]" +// Valid types are currently: +// * sha512 +type Hash struct { + typ string + Val string +} + +func NewHash(s string) (*Hash, error) { + elems := strings.Split(s, "-") + if len(elems) != 2 { + return nil, errors.New("badly formatted hash string") + } + nh := Hash{ + typ: elems[0], + Val: elems[1], + } + if err := nh.assertValid(); err != nil { + return nil, err + } + return &nh, nil +} + +func (h Hash) String() string { + return fmt.Sprintf("%s-%s", h.typ, h.Val) +} + +func (h *Hash) Set(s string) error { + nh, err := NewHash(s) + if err == nil { + *h = *nh + } + return err +} + +func (h Hash) Empty() bool { + return reflect.DeepEqual(h, Hash{}) +} + +func (h Hash) assertValid() error { + switch h.typ { + case "sha512": + case "": + return fmt.Errorf("unexpected empty hash type") + default: + return fmt.Errorf("unrecognized hash type: %v", h.typ) + } + if h.Val == "" { + return fmt.Errorf("unexpected empty hash value") + } + return nil +} + +func (h *Hash) UnmarshalJSON(data []byte) error { + var s string + if err := json.Unmarshal(data, &s); err != nil { + return err + } + nh, err := NewHash(s) + if err != nil { + return err + } + *h = *nh + return nil +} + +func (h Hash) MarshalJSON() ([]byte, error) { + if err := h.assertValid(); err != nil { + return nil, err + } + return json.Marshal(h.String()) +} + +func NewHashSHA512(b []byte) *Hash { + h := sha512.New() + h.Write(b) + nh, _ := NewHash(fmt.Sprintf("sha512-%x", h.Sum(nil))) + return nh +} + +func ShortHash(hash string) string { + if len(hash) > maxHashSize { + return hash[:maxHashSize] + } + return hash +} diff --git a/vendor/github.com/appc/spec/schema/types/isolator.go b/vendor/github.com/appc/spec/schema/types/isolator.go new file mode 100644 index 0000000000..ecdab0088b --- /dev/null +++ b/vendor/github.com/appc/spec/schema/types/isolator.go @@ -0,0 +1,129 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "encoding/json" +) + +var ( + isolatorMap map[ACIdentifier]IsolatorValueConstructor +) + +func init() { + isolatorMap = make(map[ACIdentifier]IsolatorValueConstructor) +} + +type IsolatorValueConstructor func() IsolatorValue + +func AddIsolatorValueConstructor(n ACIdentifier, i IsolatorValueConstructor) { + isolatorMap[n] = i +} + +func AddIsolatorName(n ACIdentifier, ns map[ACIdentifier]struct{}) { + ns[n] = struct{}{} +} + +// Isolators encapsulates a list of individual Isolators for the ImageManifest +// and PodManifest schemas. +type Isolators []Isolator + +// GetByName returns the last isolator in the list by the given name. +func (is *Isolators) GetByName(name ACIdentifier) *Isolator { + var i Isolator + for j := len(*is) - 1; j >= 0; j-- { + i = []Isolator(*is)[j] + if i.Name == name { + return &i + } + } + return nil +} + +// Unrecognized returns a set of isolators that are not recognized. +// An isolator is not recognized if it has not had an associated +// constructor registered with AddIsolatorValueConstructor. +func (is *Isolators) Unrecognized() Isolators { + u := Isolators{} + for _, i := range *is { + if i.value == nil { + u = append(u, i) + } + } + return u +} + +// IsolatorValue encapsulates the actual value of an Isolator which may be +// serialized as any arbitrary JSON blob. Specific Isolator types should +// implement this interface to facilitate unmarshalling and validation. +type IsolatorValue interface { + UnmarshalJSON(b []byte) error + AssertValid() error +} + +// Isolator is a model for unmarshalling isolator types from their JSON-encoded +// representation. +type Isolator struct { + // Name is the name of the Isolator type as defined in the specification. + Name ACIdentifier `json:"name"` + // ValueRaw captures the raw JSON value of an Isolator that was + // unmarshalled. This field is used for unmarshalling only. It MUST NOT + // be referenced by external users of the Isolator struct. It is + // exported only to satisfy Go's unfortunate requirement that fields + // must be capitalized to be unmarshalled successfully. + ValueRaw *json.RawMessage `json:"value"` + // value captures the "true" value of the isolator. + value IsolatorValue +} + +// isolator is a shadow type used for unmarshalling. +type isolator Isolator + +// Value returns the raw Value of this Isolator. Users should perform a type +// switch/assertion on this value to extract the underlying isolator type. +func (i *Isolator) Value() IsolatorValue { + return i.value +} + +// UnmarshalJSON populates this Isolator from a JSON-encoded representation. To +// unmarshal the Value of the Isolator, it will use the appropriate constructor +// as registered by AddIsolatorValueConstructor. +func (i *Isolator) UnmarshalJSON(b []byte) error { + var ii isolator + err := json.Unmarshal(b, &ii) + if err != nil { + return err + } + + var dst IsolatorValue + con, ok := isolatorMap[ii.Name] + if ok { + dst = con() + err = dst.UnmarshalJSON(*ii.ValueRaw) + if err != nil { + return err + } + err = dst.AssertValid() + if err != nil { + return err + } + } + + i.value = dst + i.ValueRaw = ii.ValueRaw + i.Name = ii.Name + + return nil +} diff --git a/vendor/github.com/appc/spec/schema/types/isolator_linux_specific.go b/vendor/github.com/appc/spec/schema/types/isolator_linux_specific.go new file mode 100644 index 0000000000..678e0bf1f4 --- /dev/null +++ b/vendor/github.com/appc/spec/schema/types/isolator_linux_specific.go @@ -0,0 +1,163 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "encoding/json" + "errors" +) + +const ( + LinuxCapabilitiesRetainSetName = "os/linux/capabilities-retain-set" + LinuxCapabilitiesRevokeSetName = "os/linux/capabilities-remove-set" + LinuxNoNewPrivilegesName = "os/linux/no-new-privileges" +) + +var LinuxIsolatorNames = make(map[ACIdentifier]struct{}) + +func init() { + for name, con := range map[ACIdentifier]IsolatorValueConstructor{ + LinuxCapabilitiesRevokeSetName: func() IsolatorValue { return &LinuxCapabilitiesRevokeSet{} }, + LinuxCapabilitiesRetainSetName: func() IsolatorValue { return &LinuxCapabilitiesRetainSet{} }, + LinuxNoNewPrivilegesName: func() IsolatorValue { v := LinuxNoNewPrivileges(false); return &v }, + } { + AddIsolatorName(name, LinuxIsolatorNames) + AddIsolatorValueConstructor(name, con) + } +} + +type LinuxNoNewPrivileges bool + +func (l LinuxNoNewPrivileges) AssertValid() error { + return nil +} + +func (l *LinuxNoNewPrivileges) UnmarshalJSON(b []byte) error { + var v bool + err := json.Unmarshal(b, &v) + if err != nil { + return err + } + + *l = LinuxNoNewPrivileges(v) + + return nil +} + +type LinuxCapabilitiesSet interface { + Set() []LinuxCapability + AssertValid() error +} + +type LinuxCapability string + +type linuxCapabilitiesSetValue struct { + Set []LinuxCapability `json:"set"` +} + +type linuxCapabilitiesSetBase struct { + val linuxCapabilitiesSetValue +} + +func (l linuxCapabilitiesSetBase) AssertValid() error { + if len(l.val.Set) == 0 { + return errors.New("set must be non-empty") + } + return nil +} + +func (l *linuxCapabilitiesSetBase) UnmarshalJSON(b []byte) error { + var v linuxCapabilitiesSetValue + err := json.Unmarshal(b, &v) + if err != nil { + return err + } + + l.val = v + + return err +} + +func (l linuxCapabilitiesSetBase) Set() []LinuxCapability { + return l.val.Set +} + +type LinuxCapabilitiesRetainSet struct { + linuxCapabilitiesSetBase +} + +func NewLinuxCapabilitiesRetainSet(caps ...string) (*LinuxCapabilitiesRetainSet, error) { + l := LinuxCapabilitiesRetainSet{ + linuxCapabilitiesSetBase{ + linuxCapabilitiesSetValue{ + make([]LinuxCapability, len(caps)), + }, + }, + } + for i, c := range caps { + l.linuxCapabilitiesSetBase.val.Set[i] = LinuxCapability(c) + } + if err := l.AssertValid(); err != nil { + return nil, err + } + return &l, nil +} + +func (l LinuxCapabilitiesRetainSet) AsIsolator() Isolator { + b, err := json.Marshal(l.linuxCapabilitiesSetBase.val) + if err != nil { + panic(err) + } + rm := json.RawMessage(b) + return Isolator{ + Name: LinuxCapabilitiesRetainSetName, + ValueRaw: &rm, + value: &l, + } +} + +type LinuxCapabilitiesRevokeSet struct { + linuxCapabilitiesSetBase +} + +func NewLinuxCapabilitiesRevokeSet(caps ...string) (*LinuxCapabilitiesRevokeSet, error) { + l := LinuxCapabilitiesRevokeSet{ + linuxCapabilitiesSetBase{ + linuxCapabilitiesSetValue{ + make([]LinuxCapability, len(caps)), + }, + }, + } + for i, c := range caps { + l.linuxCapabilitiesSetBase.val.Set[i] = LinuxCapability(c) + } + if err := l.AssertValid(); err != nil { + return nil, err + } + return &l, nil +} + +func (l LinuxCapabilitiesRevokeSet) AsIsolator() Isolator { + b, err := json.Marshal(l.linuxCapabilitiesSetBase.val) + if err != nil { + panic(err) + } + rm := json.RawMessage(b) + return Isolator{ + Name: LinuxCapabilitiesRevokeSetName, + ValueRaw: &rm, + value: &l, + } +} diff --git a/vendor/github.com/appc/spec/schema/types/isolator_resources.go b/vendor/github.com/appc/spec/schema/types/isolator_resources.go new file mode 100644 index 0000000000..2ac5130d1c --- /dev/null +++ b/vendor/github.com/appc/spec/schema/types/isolator_resources.go @@ -0,0 +1,236 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "encoding/json" + "errors" + "fmt" + + "k8s.io/kubernetes/pkg/api/resource" +) + +var ( + ErrDefaultTrue = errors.New("default must be false") + ErrDefaultRequired = errors.New("default must be true") + ErrRequestNonEmpty = errors.New("request not supported by this resource, must be empty") + + ResourceIsolatorNames = make(map[ACIdentifier]struct{}) +) + +const ( + ResourceBlockBandwidthName = "resource/block-bandwidth" + ResourceBlockIOPSName = "resource/block-iops" + ResourceCPUName = "resource/cpu" + ResourceMemoryName = "resource/memory" + ResourceNetworkBandwidthName = "resource/network-bandwidth" +) + +func init() { + for name, con := range map[ACIdentifier]IsolatorValueConstructor{ + ResourceBlockBandwidthName: func() IsolatorValue { return &ResourceBlockBandwidth{} }, + ResourceBlockIOPSName: func() IsolatorValue { return &ResourceBlockIOPS{} }, + ResourceCPUName: func() IsolatorValue { return &ResourceCPU{} }, + ResourceMemoryName: func() IsolatorValue { return &ResourceMemory{} }, + ResourceNetworkBandwidthName: func() IsolatorValue { return &ResourceNetworkBandwidth{} }, + } { + AddIsolatorName(name, ResourceIsolatorNames) + AddIsolatorValueConstructor(name, con) + } +} + +type Resource interface { + Limit() *resource.Quantity + Request() *resource.Quantity + Default() bool +} + +type ResourceBase struct { + val resourceValue +} + +type resourceValue struct { + Default bool `json:"default"` + Request *resource.Quantity `json:"request"` + Limit *resource.Quantity `json:"limit"` +} + +func (r ResourceBase) Limit() *resource.Quantity { + return r.val.Limit +} +func (r ResourceBase) Request() *resource.Quantity { + return r.val.Request +} +func (r ResourceBase) Default() bool { + return r.val.Default +} + +func (r *ResourceBase) UnmarshalJSON(b []byte) error { + return json.Unmarshal(b, &r.val) +} + +func (r ResourceBase) AssertValid() error { + return nil +} + +type ResourceBlockBandwidth struct { + ResourceBase +} + +func (r ResourceBlockBandwidth) AssertValid() error { + if r.Default() != true { + return ErrDefaultRequired + } + if r.Request() != nil { + return ErrRequestNonEmpty + } + return nil +} + +type ResourceBlockIOPS struct { + ResourceBase +} + +func (r ResourceBlockIOPS) AssertValid() error { + if r.Default() != true { + return ErrDefaultRequired + } + if r.Request() != nil { + return ErrRequestNonEmpty + } + return nil +} + +type ResourceCPU struct { + ResourceBase +} + +func (r ResourceCPU) String() string { + return fmt.Sprintf("ResourceCPU(request=%s, limit=%s)", r.Request(), r.Limit()) +} + +func (r ResourceCPU) AssertValid() error { + if r.Default() != false { + return ErrDefaultTrue + } + return nil +} + +func (r ResourceCPU) AsIsolator() Isolator { + isol := isolatorMap[ResourceCPUName]() + + b, err := json.Marshal(r.val) + if err != nil { + panic(err) + } + valRaw := json.RawMessage(b) + return Isolator{ + Name: ResourceCPUName, + ValueRaw: &valRaw, + value: isol, + } +} + +func NewResourceCPUIsolator(request, limit string) (*ResourceCPU, error) { + req, err := resource.ParseQuantity(request) + if err != nil { + return nil, fmt.Errorf("error parsing request: %v", err) + } + lim, err := resource.ParseQuantity(limit) + if err != nil { + return nil, fmt.Errorf("error parsing limit: %v", err) + } + res := &ResourceCPU{ + ResourceBase{ + resourceValue{ + Request: req, + Limit: lim, + }, + }, + } + if err := res.AssertValid(); err != nil { + // should never happen + return nil, err + } + return res, nil +} + +type ResourceMemory struct { + ResourceBase +} + +func (r ResourceMemory) String() string { + return fmt.Sprintf("ResourceMemory(request=%s, limit=%s)", r.Request(), r.Limit()) +} + +func (r ResourceMemory) AssertValid() error { + if r.Default() != false { + return ErrDefaultTrue + } + return nil +} + +func (r ResourceMemory) AsIsolator() Isolator { + isol := isolatorMap[ResourceMemoryName]() + + b, err := json.Marshal(r.val) + if err != nil { + panic(err) + } + valRaw := json.RawMessage(b) + return Isolator{ + Name: ResourceMemoryName, + ValueRaw: &valRaw, + value: isol, + } +} + +func NewResourceMemoryIsolator(request, limit string) (*ResourceMemory, error) { + req, err := resource.ParseQuantity(request) + if err != nil { + return nil, fmt.Errorf("error parsing request: %v", err) + } + lim, err := resource.ParseQuantity(limit) + if err != nil { + return nil, fmt.Errorf("error parsing limit: %v", err) + } + res := &ResourceMemory{ + ResourceBase{ + resourceValue{ + Request: req, + Limit: lim, + }, + }, + } + if err := res.AssertValid(); err != nil { + // should never happen + return nil, err + } + return res, nil +} + +type ResourceNetworkBandwidth struct { + ResourceBase +} + +func (r ResourceNetworkBandwidth) AssertValid() error { + if r.Default() != true { + return ErrDefaultRequired + } + if r.Request() != nil { + return ErrRequestNonEmpty + } + return nil +} diff --git a/vendor/github.com/appc/spec/schema/types/labels.go b/vendor/github.com/appc/spec/schema/types/labels.go new file mode 100644 index 0000000000..ebd2bb1a98 --- /dev/null +++ b/vendor/github.com/appc/spec/schema/types/labels.go @@ -0,0 +1,134 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "encoding/json" + "fmt" + "sort" +) + +var ValidOSArch = map[string][]string{ + "linux": {"amd64", "i386", "aarch64", "aarch64_be", "armv6l", "armv7l", "armv7b"}, + "freebsd": {"amd64", "i386", "arm"}, + "darwin": {"x86_64", "i386"}, +} + +type Labels []Label + +type labels Labels + +type Label struct { + Name ACIdentifier `json:"name"` + Value string `json:"value"` +} + +// IsValidOsArch checks if a OS-architecture combination is valid given a map +// of valid OS-architectures +func IsValidOSArch(labels map[ACIdentifier]string, validOSArch map[string][]string) error { + if os, ok := labels["os"]; ok { + if validArchs, ok := validOSArch[os]; !ok { + // Not a whitelisted OS. TODO: how to warn rather than fail? + validOses := make([]string, 0, len(validOSArch)) + for validOs := range validOSArch { + validOses = append(validOses, validOs) + } + sort.Strings(validOses) + return fmt.Errorf(`bad os %#v (must be one of: %v)`, os, validOses) + } else { + // Whitelisted OS. We check arch here, as arch makes sense only + // when os is defined. + if arch, ok := labels["arch"]; ok { + found := false + for _, validArch := range validArchs { + if arch == validArch { + found = true + break + } + } + if !found { + return fmt.Errorf(`bad arch %#v for %v (must be one of: %v)`, arch, os, validArchs) + } + } + } + } + return nil +} + +func (l Labels) assertValid() error { + seen := map[ACIdentifier]string{} + for _, lbl := range l { + if lbl.Name == "name" { + return fmt.Errorf(`invalid label name: "name"`) + } + _, ok := seen[lbl.Name] + if ok { + return fmt.Errorf(`duplicate labels of name %q`, lbl.Name) + } + seen[lbl.Name] = lbl.Value + } + return IsValidOSArch(seen, ValidOSArch) +} + +func (l Labels) MarshalJSON() ([]byte, error) { + if err := l.assertValid(); err != nil { + return nil, err + } + return json.Marshal(labels(l)) +} + +func (l *Labels) UnmarshalJSON(data []byte) error { + var jl labels + if err := json.Unmarshal(data, &jl); err != nil { + return err + } + nl := Labels(jl) + if err := nl.assertValid(); err != nil { + return err + } + *l = nl + return nil +} + +// Get retrieves the value of the label by the given name from Labels, if it exists +func (l Labels) Get(name string) (val string, ok bool) { + for _, lbl := range l { + if lbl.Name.String() == name { + return lbl.Value, true + } + } + return "", false +} + +// ToMap creates a map[ACIdentifier]string. +func (l Labels) ToMap() map[ACIdentifier]string { + labelsMap := make(map[ACIdentifier]string) + for _, lbl := range l { + labelsMap[lbl.Name] = lbl.Value + } + return labelsMap +} + +// LabelsFromMap creates Labels from a map[ACIdentifier]string +func LabelsFromMap(labelsMap map[ACIdentifier]string) (Labels, error) { + labels := Labels{} + for n, v := range labelsMap { + labels = append(labels, Label{Name: n, Value: v}) + } + if err := labels.assertValid(); err != nil { + return nil, err + } + return labels, nil +} diff --git a/vendor/github.com/appc/spec/schema/types/mountpoint.go b/vendor/github.com/appc/spec/schema/types/mountpoint.go new file mode 100644 index 0000000000..80eab94563 --- /dev/null +++ b/vendor/github.com/appc/spec/schema/types/mountpoint.go @@ -0,0 +1,91 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "errors" + "fmt" + "net/url" + "strconv" + + "github.com/appc/spec/schema/common" +) + +type MountPoint struct { + Name ACName `json:"name"` + Path string `json:"path"` + ReadOnly bool `json:"readOnly,omitempty"` +} + +func (mount MountPoint) assertValid() error { + if mount.Name.Empty() { + return errors.New("name must be set") + } + if len(mount.Path) == 0 { + return errors.New("path must be set") + } + return nil +} + +// MountPointFromString takes a command line mountpoint parameter and returns a mountpoint +// +// It is useful for actool patch-manifest --mounts +// +// Example mountpoint parameters: +// database,path=/tmp,readOnly=true +func MountPointFromString(mp string) (*MountPoint, error) { + var mount MountPoint + + mp = "name=" + mp + mpQuery, err := common.MakeQueryString(mp) + if err != nil { + return nil, err + } + + v, err := url.ParseQuery(mpQuery) + if err != nil { + return nil, err + } + for key, val := range v { + if len(val) > 1 { + return nil, fmt.Errorf("label %s with multiple values %q", key, val) + } + + switch key { + case "name": + acn, err := NewACName(val[0]) + if err != nil { + return nil, err + } + mount.Name = *acn + case "path": + mount.Path = val[0] + case "readOnly": + ro, err := strconv.ParseBool(val[0]) + if err != nil { + return nil, err + } + mount.ReadOnly = ro + default: + return nil, fmt.Errorf("unknown mountpoint parameter %q", key) + } + } + err = mount.assertValid() + if err != nil { + return nil, err + } + + return &mount, nil +} diff --git a/vendor/github.com/appc/spec/schema/types/port.go b/vendor/github.com/appc/spec/schema/types/port.go new file mode 100644 index 0000000000..78d6de4ce1 --- /dev/null +++ b/vendor/github.com/appc/spec/schema/types/port.go @@ -0,0 +1,139 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "encoding/json" + "errors" + "fmt" + "net/url" + "strconv" + + "github.com/appc/spec/schema/common" +) + +type Port struct { + Name ACName `json:"name"` + Protocol string `json:"protocol"` + Port uint `json:"port"` + Count uint `json:"count"` + SocketActivated bool `json:"socketActivated"` +} + +type ExposedPort struct { + Name ACName `json:"name"` + HostPort uint `json:"hostPort"` +} + +type port Port + +func (p *Port) UnmarshalJSON(data []byte) error { + var pp port + if err := json.Unmarshal(data, &pp); err != nil { + return err + } + np := Port(pp) + if err := np.assertValid(); err != nil { + return err + } + if np.Count == 0 { + np.Count = 1 + } + *p = np + return nil +} + +func (p Port) MarshalJSON() ([]byte, error) { + if err := p.assertValid(); err != nil { + return nil, err + } + return json.Marshal(port(p)) +} + +func (p Port) assertValid() error { + // Although there are no guarantees, most (if not all) + // transport protocols use 16 bit ports + if p.Port > 65535 || p.Port < 1 { + return errors.New("port must be in 1-65535 range") + } + if p.Port+p.Count > 65536 { + return errors.New("end of port range must be in 1-65535 range") + } + return nil +} + +// PortFromString takes a command line port parameter and returns a port +// +// It is useful for actool patch-manifest --ports +// +// Example port parameters: +// health-check,protocol=udp,port=8000 +// query,protocol=tcp,port=8080,count=1,socketActivated=true +func PortFromString(pt string) (*Port, error) { + var port Port + + pt = "name=" + pt + ptQuery, err := common.MakeQueryString(pt) + if err != nil { + return nil, err + } + + v, err := url.ParseQuery(ptQuery) + if err != nil { + return nil, err + } + for key, val := range v { + if len(val) > 1 { + return nil, fmt.Errorf("label %s with multiple values %q", key, val) + } + + switch key { + case "name": + acn, err := NewACName(val[0]) + if err != nil { + return nil, err + } + port.Name = *acn + case "protocol": + port.Protocol = val[0] + case "port": + p, err := strconv.ParseUint(val[0], 10, 16) + if err != nil { + return nil, err + } + port.Port = uint(p) + case "count": + cnt, err := strconv.ParseUint(val[0], 10, 16) + if err != nil { + return nil, err + } + port.Count = uint(cnt) + case "socketActivated": + sa, err := strconv.ParseBool(val[0]) + if err != nil { + return nil, err + } + port.SocketActivated = sa + default: + return nil, fmt.Errorf("unknown port parameter %q", key) + } + } + err = port.assertValid() + if err != nil { + return nil, err + } + + return &port, nil +} diff --git a/vendor/github.com/appc/spec/schema/types/semver.go b/vendor/github.com/appc/spec/schema/types/semver.go new file mode 100644 index 0000000000..0008181a5e --- /dev/null +++ b/vendor/github.com/appc/spec/schema/types/semver.go @@ -0,0 +1,91 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "encoding/json" + + "github.com/coreos/go-semver/semver" +) + +var ( + ErrNoZeroSemVer = ACVersionError("SemVer cannot be zero") + ErrBadSemVer = ACVersionError("SemVer is bad") +) + +// SemVer implements the Unmarshaler interface to define a field that must be +// a semantic version string +// TODO(jonboulle): extend upstream instead of wrapping? +type SemVer semver.Version + +// NewSemVer generates a new SemVer from a string. If the given string does +// not represent a valid SemVer, nil and an error are returned. +func NewSemVer(s string) (*SemVer, error) { + nsv, err := semver.NewVersion(s) + if err != nil { + return nil, ErrBadSemVer + } + v := SemVer(*nsv) + if v.Empty() { + return nil, ErrNoZeroSemVer + } + return &v, nil +} + +func (sv SemVer) LessThanMajor(versionB SemVer) bool { + majorA := semver.Version(sv).Major + majorB := semver.Version(versionB).Major + if majorA < majorB { + return true + } + return false +} + +func (sv SemVer) LessThanExact(versionB SemVer) bool { + vA := semver.Version(sv) + vB := semver.Version(versionB) + return vA.LessThan(vB) +} + +func (sv SemVer) String() string { + s := semver.Version(sv) + return s.String() +} + +func (sv SemVer) Empty() bool { + return semver.Version(sv) == semver.Version{} +} + +// UnmarshalJSON implements the json.Unmarshaler interface +func (sv *SemVer) UnmarshalJSON(data []byte) error { + var s string + if err := json.Unmarshal(data, &s); err != nil { + return err + } + v, err := NewSemVer(s) + if err != nil { + return err + } + *sv = *v + return nil +} + +// MarshalJSON implements the json.Marshaler interface +func (sv SemVer) MarshalJSON() ([]byte, error) { + if sv.Empty() { + return nil, ErrNoZeroSemVer + } + return json.Marshal(sv.String()) +} diff --git a/vendor/github.com/appc/spec/schema/types/url.go b/vendor/github.com/appc/spec/schema/types/url.go new file mode 100644 index 0000000000..d4f8f337da --- /dev/null +++ b/vendor/github.com/appc/spec/schema/types/url.go @@ -0,0 +1,71 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "encoding/json" + "fmt" + "net/url" +) + +// URL wraps url.URL to marshal/unmarshal to/from JSON strings and enforce +// that the scheme is HTTP/HTTPS only +type URL url.URL + +func NewURL(s string) (*URL, error) { + uu, err := url.Parse(s) + if err != nil { + return nil, fmt.Errorf("bad URL: %v", err) + } + nu := URL(*uu) + if err := nu.assertValidScheme(); err != nil { + return nil, err + } + return &nu, nil +} + +func (u URL) String() string { + uu := url.URL(u) + return uu.String() +} + +func (u URL) assertValidScheme() error { + switch u.Scheme { + case "http", "https": + return nil + default: + return fmt.Errorf("bad URL scheme, must be http/https") + } +} + +func (u *URL) UnmarshalJSON(data []byte) error { + var s string + if err := json.Unmarshal(data, &s); err != nil { + return err + } + nu, err := NewURL(s) + if err != nil { + return err + } + *u = *nu + return nil +} + +func (u URL) MarshalJSON() ([]byte, error) { + if err := u.assertValidScheme(); err != nil { + return nil, err + } + return json.Marshal(u.String()) +} diff --git a/vendor/github.com/appc/spec/schema/types/uuid.go b/vendor/github.com/appc/spec/schema/types/uuid.go new file mode 100644 index 0000000000..4925b7606d --- /dev/null +++ b/vendor/github.com/appc/spec/schema/types/uuid.go @@ -0,0 +1,92 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "encoding/hex" + "encoding/json" + "errors" + "fmt" + "reflect" + "strings" +) + +var ( + ErrNoEmptyUUID = errors.New("UUID cannot be empty") +) + +// UUID encodes an RFC4122-compliant UUID, marshaled to/from a string +// TODO(jonboulle): vendor a package for this? +// TODO(jonboulle): consider more flexibility in input string formats. +// Right now, we only accept: +// "6733C088-A507-4694-AABF-EDBE4FC5266F" +// "6733C088A5074694AABFEDBE4FC5266F" +type UUID [16]byte + +func (u UUID) String() string { + return fmt.Sprintf("%x-%x-%x-%x-%x", u[0:4], u[4:6], u[6:8], u[8:10], u[10:16]) +} + +func (u *UUID) Set(s string) error { + nu, err := NewUUID(s) + if err == nil { + *u = *nu + } + return err +} + +// NewUUID generates a new UUID from the given string. If the string does not +// represent a valid UUID, nil and an error are returned. +func NewUUID(s string) (*UUID, error) { + s = strings.Replace(s, "-", "", -1) + if len(s) != 32 { + return nil, errors.New("bad UUID length != 32") + } + dec, err := hex.DecodeString(s) + if err != nil { + return nil, err + } + var u UUID + for i, b := range dec { + u[i] = b + } + return &u, nil +} + +func (u UUID) Empty() bool { + return reflect.DeepEqual(u, UUID{}) +} + +func (u *UUID) UnmarshalJSON(data []byte) error { + var s string + if err := json.Unmarshal(data, &s); err != nil { + return err + } + uu, err := NewUUID(s) + if uu.Empty() { + return ErrNoEmptyUUID + } + if err == nil { + *u = *uu + } + return err +} + +func (u UUID) MarshalJSON() ([]byte, error) { + if u.Empty() { + return nil, ErrNoEmptyUUID + } + return json.Marshal(u.String()) +} diff --git a/vendor/github.com/appc/spec/schema/types/volume.go b/vendor/github.com/appc/spec/schema/types/volume.go new file mode 100644 index 0000000000..c5ae59180f --- /dev/null +++ b/vendor/github.com/appc/spec/schema/types/volume.go @@ -0,0 +1,236 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "encoding/json" + "errors" + "fmt" + "net/url" + "path/filepath" + "strconv" + "strings" + + "github.com/appc/spec/schema/common" +) + +const ( + emptyVolumeDefaultMode = "0755" + emptyVolumeDefaultUID = 0 + emptyVolumeDefaultGID = 0 +) + +// Volume encapsulates a volume which should be mounted into the filesystem +// of all apps in a PodManifest +type Volume struct { + Name ACName `json:"name"` + Kind string `json:"kind"` + + // currently used only by "host" + // TODO(jonboulle): factor out? + Source string `json:"source,omitempty"` + ReadOnly *bool `json:"readOnly,omitempty"` + + // currently used only by "empty" + Mode *string `json:"mode,omitempty"` + UID *int `json:"uid,omitempty"` + GID *int `json:"gid,omitempty"` +} + +type volume Volume + +func (v Volume) assertValid() error { + if v.Name.Empty() { + return errors.New("name must be set") + } + + switch v.Kind { + case "empty": + if v.Source != "" { + return errors.New("source for empty volume must be empty") + } + if v.Mode == nil { + return errors.New("mode for empty volume must be set") + } + if v.UID == nil { + return errors.New("uid for empty volume must be set") + } + if v.GID == nil { + return errors.New("gid for empty volume must be set") + } + return nil + case "host": + if v.Source == "" { + return errors.New("source for host volume cannot be empty") + } + if v.Mode != nil { + return errors.New("mode for host volume cannot be set") + } + if v.UID != nil { + return errors.New("uid for host volume cannot be set") + } + if v.GID != nil { + return errors.New("gid for host volume cannot be set") + } + if !filepath.IsAbs(v.Source) { + return errors.New("source for host volume must be absolute path") + } + return nil + default: + return errors.New(`unrecognized volume kind: should be one of "empty", "host"`) + } +} + +func (v *Volume) UnmarshalJSON(data []byte) error { + var vv volume + if err := json.Unmarshal(data, &vv); err != nil { + return err + } + nv := Volume(vv) + maybeSetDefaults(&nv) + if err := nv.assertValid(); err != nil { + return err + } + *v = nv + return nil +} + +func (v Volume) MarshalJSON() ([]byte, error) { + if err := v.assertValid(); err != nil { + return nil, err + } + return json.Marshal(volume(v)) +} + +func (v Volume) String() string { + s := []string{ + v.Name.String(), + ",kind=", + v.Kind, + } + if v.Source != "" { + s = append(s, ",source=") + s = append(s, v.Source) + } + if v.ReadOnly != nil { + s = append(s, ",readOnly=") + s = append(s, strconv.FormatBool(*v.ReadOnly)) + } + switch v.Kind { + case "empty": + if *v.Mode != emptyVolumeDefaultMode { + s = append(s, ",mode=") + s = append(s, *v.Mode) + } + if *v.UID != emptyVolumeDefaultUID { + s = append(s, ",uid=") + s = append(s, strconv.Itoa(*v.UID)) + } + if *v.GID != emptyVolumeDefaultGID { + s = append(s, ",gid=") + s = append(s, strconv.Itoa(*v.GID)) + } + } + return strings.Join(s, "") +} + +// VolumeFromString takes a command line volume parameter and returns a volume +// +// Example volume parameters: +// database,kind=host,source=/tmp,readOnly=true +func VolumeFromString(vp string) (*Volume, error) { + var vol Volume + + vp = "name=" + vp + vpQuery, err := common.MakeQueryString(vp) + if err != nil { + return nil, err + } + + v, err := url.ParseQuery(vpQuery) + if err != nil { + return nil, err + } + for key, val := range v { + val := val + if len(val) > 1 { + return nil, fmt.Errorf("label %s with multiple values %q", key, val) + } + + switch key { + case "name": + acn, err := NewACName(val[0]) + if err != nil { + return nil, err + } + vol.Name = *acn + case "kind": + vol.Kind = val[0] + case "source": + vol.Source = val[0] + case "readOnly": + ro, err := strconv.ParseBool(val[0]) + if err != nil { + return nil, err + } + vol.ReadOnly = &ro + case "mode": + vol.Mode = &val[0] + case "uid": + u, err := strconv.Atoi(val[0]) + if err != nil { + return nil, err + } + vol.UID = &u + case "gid": + g, err := strconv.Atoi(val[0]) + if err != nil { + return nil, err + } + vol.GID = &g + default: + return nil, fmt.Errorf("unknown volume parameter %q", key) + } + } + + maybeSetDefaults(&vol) + + err = vol.assertValid() + if err != nil { + return nil, err + } + + return &vol, nil +} + +// maybeSetDefaults sets the correct default values for certain fields on a +// Volume if they are not already been set. These fields are not +// pre-populated on all Volumes as the Volume type is polymorphic. +func maybeSetDefaults(vol *Volume) { + if vol.Kind == "empty" { + if vol.Mode == nil { + m := emptyVolumeDefaultMode + vol.Mode = &m + } + if vol.UID == nil { + u := emptyVolumeDefaultUID + vol.UID = &u + } + if vol.GID == nil { + g := emptyVolumeDefaultGID + vol.GID = &g + } + } +} diff --git a/vendor/github.com/appc/spec/schema/version.go b/vendor/github.com/appc/spec/schema/version.go new file mode 100644 index 0000000000..029ebfac35 --- /dev/null +++ b/vendor/github.com/appc/spec/schema/version.go @@ -0,0 +1,39 @@ +// Copyright 2015 The appc Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package schema + +import ( + "github.com/appc/spec/schema/types" +) + +const ( + // version represents the canonical version of the appc spec and tooling. + // For now, the schema and tooling is coupled with the spec itself, so + // this must be kept in sync with the VERSION file in the root of the repo. + version string = "0.8.4" +) + +var ( + // AppContainerVersion is the SemVer representation of version + AppContainerVersion types.SemVer +) + +func init() { + v, err := types.NewSemVer(version) + if err != nil { + panic(err) + } + AppContainerVersion = *v +} diff --git a/vendor/github.com/aws/aws-sdk-go/LICENSE.txt b/vendor/github.com/aws/aws-sdk-go/LICENSE.txt new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor 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, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/aws/aws-sdk-go/NOTICE.txt b/vendor/github.com/aws/aws-sdk-go/NOTICE.txt new file mode 100644 index 0000000000..5f14d1162e --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/NOTICE.txt @@ -0,0 +1,3 @@ +AWS SDK for Go +Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. +Copyright 2014-2015 Stripe, Inc. diff --git a/vendor/github.com/aws/aws-sdk-go/aws/awserr/error.go b/vendor/github.com/aws/aws-sdk-go/aws/awserr/error.go new file mode 100644 index 0000000000..cbc6bb1c0b --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/awserr/error.go @@ -0,0 +1,124 @@ +// Package awserr represents API error interface accessors for the SDK. +package awserr + +// An Error wraps lower level errors with code, message and an original error. +// The underlying concrete error type may also satisfy other interfaces which +// can be to used to obtain more specific information about the error. +// +// Calling Error() or String() will always include the full information about +// an error based on its underlying type. +// +// Example: +// +// output, err := s3manage.Upload(svc, input, opts) +// if err != nil { +// if awsErr, ok := err.(awserr.Error); ok { +// // Get error details +// log.Println("Error:", awsErr.Code(), awsErr.Message()) +// +// // Prints out full error message, including original error if there was one. +// log.Println("Error:", awsErr.Error()) +// +// // Get original error +// if origErr := awsErr.OrigErr(); origErr != nil { +// // operate on original error. +// } +// } else { +// fmt.Println(err.Error()) +// } +// } +// +type Error interface { + // Satisfy the generic error interface. + error + + // Returns the short phrase depicting the classification of the error. + Code() string + + // Returns the error details message. + Message() string + + // Returns the original error if one was set. Nil is returned if not set. + OrigErr() error +} + +// BatchError is a batch of errors which also wraps lower level errors with code, message, +// and original errors. Calling Error() will only return the error that is at the end +// of the list. +type BatchError interface { + // Satisfy the generic error interface. + error + + // Returns the short phrase depicting the classification of the error. + Code() string + + // Returns the error details message. + Message() string + + // Returns the original error if one was set. Nil is returned if not set. + OrigErrs() []error +} + +// New returns an Error object described by the code, message, and origErr. +// +// If origErr satisfies the Error interface it will not be wrapped within a new +// Error object and will instead be returned. +func New(code, message string, origErr error) Error { + return newBaseError(code, message, origErr) +} + +// NewBatchError returns an baseError with an expectation of an array of errors +func NewBatchError(code, message string, errs []error) BatchError { + return newBaseErrors(code, message, errs) +} + +// A RequestFailure is an interface to extract request failure information from +// an Error such as the request ID of the failed request returned by a service. +// RequestFailures may not always have a requestID value if the request failed +// prior to reaching the service such as a connection error. +// +// Example: +// +// output, err := s3manage.Upload(svc, input, opts) +// if err != nil { +// if reqerr, ok := err.(RequestFailure); ok { +// log.Println("Request failed", reqerr.Code(), reqerr.Message(), reqerr.RequestID()) +// } else { +// log.Println("Error:", err.Error()) +// } +// } +// +// Combined with awserr.Error: +// +// output, err := s3manage.Upload(svc, input, opts) +// if err != nil { +// if awsErr, ok := err.(awserr.Error); ok { +// // Generic AWS Error with Code, Message, and original error (if any) +// fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr()) +// +// if reqErr, ok := err.(awserr.RequestFailure); ok { +// // A service error occurred +// fmt.Println(reqErr.StatusCode(), reqErr.RequestID()) +// } +// } else { +// fmt.Println(err.Error()) +// } +// } +// +type RequestFailure interface { + Error + + // The status code of the HTTP response. + StatusCode() int + + // The request ID returned by the service for a request failure. This will + // be empty if no request ID is available such as the request failed due + // to a connection error. + RequestID() string +} + +// NewRequestFailure returns a new request error wrapper for the given Error +// provided. +func NewRequestFailure(err Error, statusCode int, reqID string) RequestFailure { + return newRequestError(err, statusCode, reqID) +} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/awserr/types.go b/vendor/github.com/aws/aws-sdk-go/aws/awserr/types.go new file mode 100644 index 0000000000..605f73c5d6 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/awserr/types.go @@ -0,0 +1,197 @@ +package awserr + +import "fmt" + +// SprintError returns a string of the formatted error code. +// +// Both extra and origErr are optional. If they are included their lines +// will be added, but if they are not included their lines will be ignored. +func SprintError(code, message, extra string, origErr error) string { + msg := fmt.Sprintf("%s: %s", code, message) + if extra != "" { + msg = fmt.Sprintf("%s\n\t%s", msg, extra) + } + if origErr != nil { + msg = fmt.Sprintf("%s\ncaused by: %s", msg, origErr.Error()) + } + return msg +} + +// A baseError wraps the code and message which defines an error. It also +// can be used to wrap an original error object. +// +// Should be used as the root for errors satisfying the awserr.Error. Also +// for any error which does not fit into a specific error wrapper type. +type baseError struct { + // Classification of error + code string + + // Detailed information about error + message string + + // Optional original error this error is based off of. Allows building + // chained errors. + errs []error +} + +// newBaseError returns an error object for the code, message, and err. +// +// code is a short no whitespace phrase depicting the classification of +// the error that is being created. +// +// message is the free flow string containing detailed information about the error. +// +// origErr is the error object which will be nested under the new error to be returned. +func newBaseError(code, message string, origErr error) *baseError { + b := &baseError{ + code: code, + message: message, + } + + if origErr != nil { + b.errs = append(b.errs, origErr) + } + + return b +} + +// newBaseErrors returns an error object for the code, message, and errors. +// +// code is a short no whitespace phrase depicting the classification of +// the error that is being created. +// +// message is the free flow string containing detailed information about the error. +// +// origErrs is the error objects which will be nested under the new errors to be returned. +func newBaseErrors(code, message string, origErrs []error) *baseError { + b := &baseError{ + code: code, + message: message, + errs: origErrs, + } + + return b +} + +// Error returns the string representation of the error. +// +// See ErrorWithExtra for formatting. +// +// Satisfies the error interface. +func (b baseError) Error() string { + size := len(b.errs) + if size > 0 { + return SprintError(b.code, b.message, "", errorList(b.errs)) + } + + return SprintError(b.code, b.message, "", nil) +} + +// String returns the string representation of the error. +// Alias for Error to satisfy the stringer interface. +func (b baseError) String() string { + return b.Error() +} + +// Code returns the short phrase depicting the classification of the error. +func (b baseError) Code() string { + return b.code +} + +// Message returns the error details message. +func (b baseError) Message() string { + return b.message +} + +// OrigErr returns the original error if one was set. Nil is returned if no error +// was set. This only returns the first element in the list. If the full list is +// needed, use BatchError +func (b baseError) OrigErr() error { + if size := len(b.errs); size > 0 { + return b.errs[0] + } + + return nil +} + +// OrigErrs returns the original errors if one was set. An empty slice is returned if +// no error was set:w +func (b baseError) OrigErrs() []error { + return b.errs +} + +// So that the Error interface type can be included as an anonymous field +// in the requestError struct and not conflict with the error.Error() method. +type awsError Error + +// A requestError wraps a request or service error. +// +// Composed of baseError for code, message, and original error. +type requestError struct { + awsError + statusCode int + requestID string +} + +// newRequestError returns a wrapped error with additional information for request +// status code, and service requestID. +// +// Should be used to wrap all request which involve service requests. Even if +// the request failed without a service response, but had an HTTP status code +// that may be meaningful. +// +// Also wraps original errors via the baseError. +func newRequestError(err Error, statusCode int, requestID string) *requestError { + return &requestError{ + awsError: err, + statusCode: statusCode, + requestID: requestID, + } +} + +// Error returns the string representation of the error. +// Satisfies the error interface. +func (r requestError) Error() string { + extra := fmt.Sprintf("status code: %d, request id: %s", + r.statusCode, r.requestID) + return SprintError(r.Code(), r.Message(), extra, r.OrigErr()) +} + +// String returns the string representation of the error. +// Alias for Error to satisfy the stringer interface. +func (r requestError) String() string { + return r.Error() +} + +// StatusCode returns the wrapped status code for the error +func (r requestError) StatusCode() int { + return r.statusCode +} + +// RequestID returns the wrapped requestID +func (r requestError) RequestID() string { + return r.requestID +} + +// An error list that satisfies the golang interface +type errorList []error + +// Error returns the string representation of the error. +// +// Satisfies the error interface. +func (e errorList) Error() string { + msg := "" + // How do we want to handle the array size being zero + if size := len(e); size > 0 { + for i := 0; i < size; i++ { + msg += fmt.Sprintf("%s", e[i].Error()) + // We check the next index to see if it is within the slice. + // If it is, then we append a newline. We do this, because unit tests + // could be broken with the additional '\n' + if i+1 < size { + msg += "\n" + } + } + } + return msg +} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/awsutil/copy.go b/vendor/github.com/aws/aws-sdk-go/aws/awsutil/copy.go new file mode 100644 index 0000000000..8429470b9d --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/awsutil/copy.go @@ -0,0 +1,100 @@ +package awsutil + +import ( + "io" + "reflect" +) + +// Copy deeply copies a src structure to dst. Useful for copying request and +// response structures. +// +// Can copy between structs of different type, but will only copy fields which +// are assignable, and exist in both structs. Fields which are not assignable, +// or do not exist in both structs are ignored. +func Copy(dst, src interface{}) { + dstval := reflect.ValueOf(dst) + if !dstval.IsValid() { + panic("Copy dst cannot be nil") + } + + rcopy(dstval, reflect.ValueOf(src), true) +} + +// CopyOf returns a copy of src while also allocating the memory for dst. +// src must be a pointer type or this operation will fail. +func CopyOf(src interface{}) (dst interface{}) { + dsti := reflect.New(reflect.TypeOf(src).Elem()) + dst = dsti.Interface() + rcopy(dsti, reflect.ValueOf(src), true) + return +} + +// rcopy performs a recursive copy of values from the source to destination. +// +// root is used to skip certain aspects of the copy which are not valid +// for the root node of a object. +func rcopy(dst, src reflect.Value, root bool) { + if !src.IsValid() { + return + } + + switch src.Kind() { + case reflect.Ptr: + if _, ok := src.Interface().(io.Reader); ok { + if dst.Kind() == reflect.Ptr && dst.Elem().CanSet() { + dst.Elem().Set(src) + } else if dst.CanSet() { + dst.Set(src) + } + } else { + e := src.Type().Elem() + if dst.CanSet() && !src.IsNil() { + dst.Set(reflect.New(e)) + } + if src.Elem().IsValid() { + // Keep the current root state since the depth hasn't changed + rcopy(dst.Elem(), src.Elem(), root) + } + } + case reflect.Struct: + t := dst.Type() + for i := 0; i < t.NumField(); i++ { + name := t.Field(i).Name + srcVal := src.FieldByName(name) + dstVal := dst.FieldByName(name) + if srcVal.IsValid() && dstVal.CanSet() { + rcopy(dstVal, srcVal, false) + } + } + case reflect.Slice: + if src.IsNil() { + break + } + + s := reflect.MakeSlice(src.Type(), src.Len(), src.Cap()) + dst.Set(s) + for i := 0; i < src.Len(); i++ { + rcopy(dst.Index(i), src.Index(i), false) + } + case reflect.Map: + if src.IsNil() { + break + } + + s := reflect.MakeMap(src.Type()) + dst.Set(s) + for _, k := range src.MapKeys() { + v := src.MapIndex(k) + v2 := reflect.New(v.Type()).Elem() + rcopy(v2, v, false) + dst.SetMapIndex(k, v2) + } + default: + // Assign the value if possible. If its not assignable, the value would + // need to be converted and the impact of that may be unexpected, or is + // not compatible with the dst type. + if src.Type().AssignableTo(dst.Type()) { + dst.Set(src) + } + } +} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/awsutil/equal.go b/vendor/github.com/aws/aws-sdk-go/aws/awsutil/equal.go new file mode 100644 index 0000000000..59fa4a558a --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/awsutil/equal.go @@ -0,0 +1,27 @@ +package awsutil + +import ( + "reflect" +) + +// DeepEqual returns if the two values are deeply equal like reflect.DeepEqual. +// In addition to this, this method will also dereference the input values if +// possible so the DeepEqual performed will not fail if one parameter is a +// pointer and the other is not. +// +// DeepEqual will not perform indirection of nested values of the input parameters. +func DeepEqual(a, b interface{}) bool { + ra := reflect.Indirect(reflect.ValueOf(a)) + rb := reflect.Indirect(reflect.ValueOf(b)) + + if raValid, rbValid := ra.IsValid(), rb.IsValid(); !raValid && !rbValid { + // If the elements are both nil, and of the same type the are equal + // If they are of different types they are not equal + return reflect.TypeOf(a) == reflect.TypeOf(b) + } else if raValid != rbValid { + // Both values must be valid to be equal + return false + } + + return reflect.DeepEqual(ra.Interface(), rb.Interface()) +} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/awsutil/path_value.go b/vendor/github.com/aws/aws-sdk-go/aws/awsutil/path_value.go new file mode 100644 index 0000000000..4d2a01e8c4 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/awsutil/path_value.go @@ -0,0 +1,222 @@ +package awsutil + +import ( + "reflect" + "regexp" + "strconv" + "strings" + + "github.com/jmespath/go-jmespath" +) + +var indexRe = regexp.MustCompile(`(.+)\[(-?\d+)?\]$`) + +// rValuesAtPath returns a slice of values found in value v. The values +// in v are explored recursively so all nested values are collected. +func rValuesAtPath(v interface{}, path string, createPath, caseSensitive, nilTerm bool) []reflect.Value { + pathparts := strings.Split(path, "||") + if len(pathparts) > 1 { + for _, pathpart := range pathparts { + vals := rValuesAtPath(v, pathpart, createPath, caseSensitive, nilTerm) + if len(vals) > 0 { + return vals + } + } + return nil + } + + values := []reflect.Value{reflect.Indirect(reflect.ValueOf(v))} + components := strings.Split(path, ".") + for len(values) > 0 && len(components) > 0 { + var index *int64 + var indexStar bool + c := strings.TrimSpace(components[0]) + if c == "" { // no actual component, illegal syntax + return nil + } else if caseSensitive && c != "*" && strings.ToLower(c[0:1]) == c[0:1] { + // TODO normalize case for user + return nil // don't support unexported fields + } + + // parse this component + if m := indexRe.FindStringSubmatch(c); m != nil { + c = m[1] + if m[2] == "" { + index = nil + indexStar = true + } else { + i, _ := strconv.ParseInt(m[2], 10, 32) + index = &i + indexStar = false + } + } + + nextvals := []reflect.Value{} + for _, value := range values { + // pull component name out of struct member + if value.Kind() != reflect.Struct { + continue + } + + if c == "*" { // pull all members + for i := 0; i < value.NumField(); i++ { + if f := reflect.Indirect(value.Field(i)); f.IsValid() { + nextvals = append(nextvals, f) + } + } + continue + } + + value = value.FieldByNameFunc(func(name string) bool { + if c == name { + return true + } else if !caseSensitive && strings.ToLower(name) == strings.ToLower(c) { + return true + } + return false + }) + + if nilTerm && value.Kind() == reflect.Ptr && len(components[1:]) == 0 { + if !value.IsNil() { + value.Set(reflect.Zero(value.Type())) + } + return []reflect.Value{value} + } + + if createPath && value.Kind() == reflect.Ptr && value.IsNil() { + // TODO if the value is the terminus it should not be created + // if the value to be set to its position is nil. + value.Set(reflect.New(value.Type().Elem())) + value = value.Elem() + } else { + value = reflect.Indirect(value) + } + + if value.Kind() == reflect.Slice || value.Kind() == reflect.Map { + if !createPath && value.IsNil() { + value = reflect.ValueOf(nil) + } + } + + if value.IsValid() { + nextvals = append(nextvals, value) + } + } + values = nextvals + + if indexStar || index != nil { + nextvals = []reflect.Value{} + for _, value := range values { + value := reflect.Indirect(value) + if value.Kind() != reflect.Slice { + continue + } + + if indexStar { // grab all indices + for i := 0; i < value.Len(); i++ { + idx := reflect.Indirect(value.Index(i)) + if idx.IsValid() { + nextvals = append(nextvals, idx) + } + } + continue + } + + // pull out index + i := int(*index) + if i >= value.Len() { // check out of bounds + if createPath { + // TODO resize slice + } else { + continue + } + } else if i < 0 { // support negative indexing + i = value.Len() + i + } + value = reflect.Indirect(value.Index(i)) + + if value.Kind() == reflect.Slice || value.Kind() == reflect.Map { + if !createPath && value.IsNil() { + value = reflect.ValueOf(nil) + } + } + + if value.IsValid() { + nextvals = append(nextvals, value) + } + } + values = nextvals + } + + components = components[1:] + } + return values +} + +// ValuesAtPath returns a list of values at the case insensitive lexical +// path inside of a structure. +func ValuesAtPath(i interface{}, path string) ([]interface{}, error) { + result, err := jmespath.Search(path, i) + if err != nil { + return nil, err + } + + v := reflect.ValueOf(result) + if !v.IsValid() || (v.Kind() == reflect.Ptr && v.IsNil()) { + return nil, nil + } + if s, ok := result.([]interface{}); ok { + return s, err + } + if v.Kind() == reflect.Map && v.Len() == 0 { + return nil, nil + } + if v.Kind() == reflect.Slice { + out := make([]interface{}, v.Len()) + for i := 0; i < v.Len(); i++ { + out[i] = v.Index(i).Interface() + } + return out, nil + } + + return []interface{}{result}, nil +} + +// SetValueAtPath sets a value at the case insensitive lexical path inside +// of a structure. +func SetValueAtPath(i interface{}, path string, v interface{}) { + if rvals := rValuesAtPath(i, path, true, false, v == nil); rvals != nil { + for _, rval := range rvals { + if rval.Kind() == reflect.Ptr && rval.IsNil() { + continue + } + setValue(rval, v) + } + } +} + +func setValue(dstVal reflect.Value, src interface{}) { + if dstVal.Kind() == reflect.Ptr { + dstVal = reflect.Indirect(dstVal) + } + srcVal := reflect.ValueOf(src) + + if !srcVal.IsValid() { // src is literal nil + if dstVal.CanAddr() { + // Convert to pointer so that pointer's value can be nil'ed + // dstVal = dstVal.Addr() + } + dstVal.Set(reflect.Zero(dstVal.Type())) + + } else if srcVal.Kind() == reflect.Ptr { + if srcVal.IsNil() { + srcVal = reflect.Zero(dstVal.Type()) + } else { + srcVal = reflect.ValueOf(src).Elem() + } + dstVal.Set(srcVal) + } else { + dstVal.Set(srcVal) + } + +} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/awsutil/prettify.go b/vendor/github.com/aws/aws-sdk-go/aws/awsutil/prettify.go new file mode 100644 index 0000000000..0de3eaa0f6 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/awsutil/prettify.go @@ -0,0 +1,103 @@ +package awsutil + +import ( + "bytes" + "fmt" + "io" + "reflect" + "strings" +) + +// Prettify returns the string representation of a value. +func Prettify(i interface{}) string { + var buf bytes.Buffer + prettify(reflect.ValueOf(i), 0, &buf) + return buf.String() +} + +// prettify will recursively walk value v to build a textual +// representation of the value. +func prettify(v reflect.Value, indent int, buf *bytes.Buffer) { + for v.Kind() == reflect.Ptr { + v = v.Elem() + } + + switch v.Kind() { + case reflect.Struct: + strtype := v.Type().String() + if strtype == "time.Time" { + fmt.Fprintf(buf, "%s", v.Interface()) + break + } else if strings.HasPrefix(strtype, "io.") { + buf.WriteString("") + break + } + + buf.WriteString("{\n") + + names := []string{} + for i := 0; i < v.Type().NumField(); i++ { + name := v.Type().Field(i).Name + f := v.Field(i) + if name[0:1] == strings.ToLower(name[0:1]) { + continue // ignore unexported fields + } + if (f.Kind() == reflect.Ptr || f.Kind() == reflect.Slice || f.Kind() == reflect.Map) && f.IsNil() { + continue // ignore unset fields + } + names = append(names, name) + } + + for i, n := range names { + val := v.FieldByName(n) + buf.WriteString(strings.Repeat(" ", indent+2)) + buf.WriteString(n + ": ") + prettify(val, indent+2, buf) + + if i < len(names)-1 { + buf.WriteString(",\n") + } + } + + buf.WriteString("\n" + strings.Repeat(" ", indent) + "}") + case reflect.Slice: + nl, id, id2 := "", "", "" + if v.Len() > 3 { + nl, id, id2 = "\n", strings.Repeat(" ", indent), strings.Repeat(" ", indent+2) + } + buf.WriteString("[" + nl) + for i := 0; i < v.Len(); i++ { + buf.WriteString(id2) + prettify(v.Index(i), indent+2, buf) + + if i < v.Len()-1 { + buf.WriteString("," + nl) + } + } + + buf.WriteString(nl + id + "]") + case reflect.Map: + buf.WriteString("{\n") + + for i, k := range v.MapKeys() { + buf.WriteString(strings.Repeat(" ", indent+2)) + buf.WriteString(k.String() + ": ") + prettify(v.MapIndex(k), indent+2, buf) + + if i < v.Len()-1 { + buf.WriteString(",\n") + } + } + + buf.WriteString("\n" + strings.Repeat(" ", indent) + "}") + default: + format := "%v" + switch v.Interface().(type) { + case string: + format = "%q" + case io.ReadSeeker, io.Reader: + format = "buffer(%p)" + } + fmt.Fprintf(buf, format, v.Interface()) + } +} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/awsutil/string_value.go b/vendor/github.com/aws/aws-sdk-go/aws/awsutil/string_value.go new file mode 100644 index 0000000000..b6432f1a11 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/awsutil/string_value.go @@ -0,0 +1,89 @@ +package awsutil + +import ( + "bytes" + "fmt" + "reflect" + "strings" +) + +// StringValue returns the string representation of a value. +func StringValue(i interface{}) string { + var buf bytes.Buffer + stringValue(reflect.ValueOf(i), 0, &buf) + return buf.String() +} + +func stringValue(v reflect.Value, indent int, buf *bytes.Buffer) { + for v.Kind() == reflect.Ptr { + v = v.Elem() + } + + switch v.Kind() { + case reflect.Struct: + buf.WriteString("{\n") + + names := []string{} + for i := 0; i < v.Type().NumField(); i++ { + name := v.Type().Field(i).Name + f := v.Field(i) + if name[0:1] == strings.ToLower(name[0:1]) { + continue // ignore unexported fields + } + if (f.Kind() == reflect.Ptr || f.Kind() == reflect.Slice) && f.IsNil() { + continue // ignore unset fields + } + names = append(names, name) + } + + for i, n := range names { + val := v.FieldByName(n) + buf.WriteString(strings.Repeat(" ", indent+2)) + buf.WriteString(n + ": ") + stringValue(val, indent+2, buf) + + if i < len(names)-1 { + buf.WriteString(",\n") + } + } + + buf.WriteString("\n" + strings.Repeat(" ", indent) + "}") + case reflect.Slice: + nl, id, id2 := "", "", "" + if v.Len() > 3 { + nl, id, id2 = "\n", strings.Repeat(" ", indent), strings.Repeat(" ", indent+2) + } + buf.WriteString("[" + nl) + for i := 0; i < v.Len(); i++ { + buf.WriteString(id2) + stringValue(v.Index(i), indent+2, buf) + + if i < v.Len()-1 { + buf.WriteString("," + nl) + } + } + + buf.WriteString(nl + id + "]") + case reflect.Map: + buf.WriteString("{\n") + + for i, k := range v.MapKeys() { + buf.WriteString(strings.Repeat(" ", indent+2)) + buf.WriteString(k.String() + ": ") + stringValue(v.MapIndex(k), indent+2, buf) + + if i < v.Len()-1 { + buf.WriteString(",\n") + } + } + + buf.WriteString("\n" + strings.Repeat(" ", indent) + "}") + default: + format := "%v" + switch v.Interface().(type) { + case string: + format = "%q" + } + fmt.Fprintf(buf, format, v.Interface()) + } +} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/client/metadata/client_info.go b/vendor/github.com/aws/aws-sdk-go/aws/client/metadata/client_info.go new file mode 100644 index 0000000000..4778056ddf --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/client/metadata/client_info.go @@ -0,0 +1,12 @@ +package metadata + +// ClientInfo wraps immutable data from the client.Client structure. +type ClientInfo struct { + ServiceName string + APIVersion string + Endpoint string + SigningName string + SigningRegion string + JSONVersion string + TargetPrefix string +} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/config.go b/vendor/github.com/aws/aws-sdk-go/aws/config.go new file mode 100644 index 0000000000..9e83e9260a --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/config.go @@ -0,0 +1,311 @@ +package aws + +import ( + "net/http" + "time" + + "github.com/aws/aws-sdk-go/aws/credentials" +) + +// UseServiceDefaultRetries instructs the config to use the service's own default +// number of retries. This will be the default action if Config.MaxRetries +// is nil also. +const UseServiceDefaultRetries = -1 + +// RequestRetryer is an alias for a type that implements the request.Retryer interface. +type RequestRetryer interface{} + +// A Config provides service configuration for service clients. By default, +// all clients will use the {defaults.DefaultConfig} structure. +type Config struct { + // Enables verbose error printing of all credential chain errors. + // Should be used when wanting to see all errors while attempting to retreive + // credentials. + CredentialsChainVerboseErrors *bool + + // The credentials object to use when signing requests. Defaults to + // a chain of credential providers to search for credentials in environment + // variables, shared credential file, and EC2 Instance Roles. + Credentials *credentials.Credentials + + // An optional endpoint URL (hostname only or fully qualified URI) + // that overrides the default generated endpoint for a client. Set this + // to `""` to use the default generated endpoint. + // + // @note You must still provide a `Region` value when specifying an + // endpoint for a client. + Endpoint *string + + // The region to send requests to. This parameter is required and must + // be configured globally or on a per-client basis unless otherwise + // noted. A full list of regions is found in the "Regions and Endpoints" + // document. + // + // @see http://docs.aws.amazon.com/general/latest/gr/rande.html + // AWS Regions and Endpoints + Region *string + + // Set this to `true` to disable SSL when sending requests. Defaults + // to `false`. + DisableSSL *bool + + // The HTTP client to use when sending requests. Defaults to + // `http.DefaultClient`. + HTTPClient *http.Client + + // An integer value representing the logging level. The default log level + // is zero (LogOff), which represents no logging. To enable logging set + // to a LogLevel Value. + LogLevel *LogLevelType + + // The logger writer interface to write logging messages to. Defaults to + // standard out. + Logger Logger + + // The maximum number of times that a request will be retried for failures. + // Defaults to -1, which defers the max retry setting to the service specific + // configuration. + MaxRetries *int + + // Retryer guides how HTTP requests should be retried in case of recoverable failures. + // + // When nil or the value does not implement the request.Retryer interface, + // the request.DefaultRetryer will be used. + // + // When both Retryer and MaxRetries are non-nil, the former is used and + // the latter ignored. + // + // To set the Retryer field in a type-safe manner and with chaining, use + // the request.WithRetryer helper function: + // + // cfg := request.WithRetryer(aws.NewConfig(), myRetryer) + // + Retryer RequestRetryer + + // Disables semantic parameter validation, which validates input for missing + // required fields and/or other semantic request input errors. + DisableParamValidation *bool + + // Disables the computation of request and response checksums, e.g., + // CRC32 checksums in Amazon DynamoDB. + DisableComputeChecksums *bool + + // Set this to `true` to force the request to use path-style addressing, + // i.e., `http://s3.amazonaws.com/BUCKET/KEY`. By default, the S3 client will + // use virtual hosted bucket addressing when possible + // (`http://BUCKET.s3.amazonaws.com/KEY`). + // + // @note This configuration option is specific to the Amazon S3 service. + // @see http://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html + // Amazon S3: Virtual Hosting of Buckets + S3ForcePathStyle *bool + + // Set this to `true` to disable the EC2Metadata client from overriding the + // default http.Client's Timeout. This is helpful if you do not want the EC2Metadata + // client to create a new http.Client. This options is only meaningful if you're not + // already using a custom HTTP client with the SDK. Enabled by default. + // + // Must be set and provided to the session.New() in order to disable the EC2Metadata + // overriding the timeout for default credentials chain. + // + // Example: + // sess := session.New(aws.NewConfig().WithEC2MetadataDiableTimeoutOverride(true)) + // svc := s3.New(sess) + // + EC2MetadataDisableTimeoutOverride *bool + + SleepDelay func(time.Duration) +} + +// NewConfig returns a new Config pointer that can be chained with builder methods to +// set multiple configuration values inline without using pointers. +// +// svc := s3.New(aws.NewConfig().WithRegion("us-west-2").WithMaxRetries(10)) +// +func NewConfig() *Config { + return &Config{} +} + +// WithCredentialsChainVerboseErrors sets a config verbose errors boolean and returning +// a Config pointer. +func (c *Config) WithCredentialsChainVerboseErrors(verboseErrs bool) *Config { + c.CredentialsChainVerboseErrors = &verboseErrs + return c +} + +// WithCredentials sets a config Credentials value returning a Config pointer +// for chaining. +func (c *Config) WithCredentials(creds *credentials.Credentials) *Config { + c.Credentials = creds + return c +} + +// WithEndpoint sets a config Endpoint value returning a Config pointer for +// chaining. +func (c *Config) WithEndpoint(endpoint string) *Config { + c.Endpoint = &endpoint + return c +} + +// WithRegion sets a config Region value returning a Config pointer for +// chaining. +func (c *Config) WithRegion(region string) *Config { + c.Region = ®ion + return c +} + +// WithDisableSSL sets a config DisableSSL value returning a Config pointer +// for chaining. +func (c *Config) WithDisableSSL(disable bool) *Config { + c.DisableSSL = &disable + return c +} + +// WithHTTPClient sets a config HTTPClient value returning a Config pointer +// for chaining. +func (c *Config) WithHTTPClient(client *http.Client) *Config { + c.HTTPClient = client + return c +} + +// WithMaxRetries sets a config MaxRetries value returning a Config pointer +// for chaining. +func (c *Config) WithMaxRetries(max int) *Config { + c.MaxRetries = &max + return c +} + +// WithDisableParamValidation sets a config DisableParamValidation value +// returning a Config pointer for chaining. +func (c *Config) WithDisableParamValidation(disable bool) *Config { + c.DisableParamValidation = &disable + return c +} + +// WithDisableComputeChecksums sets a config DisableComputeChecksums value +// returning a Config pointer for chaining. +func (c *Config) WithDisableComputeChecksums(disable bool) *Config { + c.DisableComputeChecksums = &disable + return c +} + +// WithLogLevel sets a config LogLevel value returning a Config pointer for +// chaining. +func (c *Config) WithLogLevel(level LogLevelType) *Config { + c.LogLevel = &level + return c +} + +// WithLogger sets a config Logger value returning a Config pointer for +// chaining. +func (c *Config) WithLogger(logger Logger) *Config { + c.Logger = logger + return c +} + +// WithS3ForcePathStyle sets a config S3ForcePathStyle value returning a Config +// pointer for chaining. +func (c *Config) WithS3ForcePathStyle(force bool) *Config { + c.S3ForcePathStyle = &force + return c +} + +// WithEC2MetadataDisableTimeoutOverride sets a config EC2MetadataDisableTimeoutOverride value +// returning a Config pointer for chaining. +func (c *Config) WithEC2MetadataDisableTimeoutOverride(enable bool) *Config { + c.EC2MetadataDisableTimeoutOverride = &enable + return c +} + +// WithSleepDelay overrides the function used to sleep while waiting for the +// next retry. Defaults to time.Sleep. +func (c *Config) WithSleepDelay(fn func(time.Duration)) *Config { + c.SleepDelay = fn + return c +} + +// MergeIn merges the passed in configs into the existing config object. +func (c *Config) MergeIn(cfgs ...*Config) { + for _, other := range cfgs { + mergeInConfig(c, other) + } +} + +func mergeInConfig(dst *Config, other *Config) { + if other == nil { + return + } + + if other.CredentialsChainVerboseErrors != nil { + dst.CredentialsChainVerboseErrors = other.CredentialsChainVerboseErrors + } + + if other.Credentials != nil { + dst.Credentials = other.Credentials + } + + if other.Endpoint != nil { + dst.Endpoint = other.Endpoint + } + + if other.Region != nil { + dst.Region = other.Region + } + + if other.DisableSSL != nil { + dst.DisableSSL = other.DisableSSL + } + + if other.HTTPClient != nil { + dst.HTTPClient = other.HTTPClient + } + + if other.LogLevel != nil { + dst.LogLevel = other.LogLevel + } + + if other.Logger != nil { + dst.Logger = other.Logger + } + + if other.MaxRetries != nil { + dst.MaxRetries = other.MaxRetries + } + + if other.Retryer != nil { + dst.Retryer = other.Retryer + } + + if other.DisableParamValidation != nil { + dst.DisableParamValidation = other.DisableParamValidation + } + + if other.DisableComputeChecksums != nil { + dst.DisableComputeChecksums = other.DisableComputeChecksums + } + + if other.S3ForcePathStyle != nil { + dst.S3ForcePathStyle = other.S3ForcePathStyle + } + + if other.EC2MetadataDisableTimeoutOverride != nil { + dst.EC2MetadataDisableTimeoutOverride = other.EC2MetadataDisableTimeoutOverride + } + + if other.SleepDelay != nil { + dst.SleepDelay = other.SleepDelay + } +} + +// Copy will return a shallow copy of the Config object. If any additional +// configurations are provided they will be merged into the new config returned. +func (c *Config) Copy(cfgs ...*Config) *Config { + dst := &Config{} + dst.MergeIn(c) + + for _, cfg := range cfgs { + dst.MergeIn(cfg) + } + + return dst +} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/convert_types.go b/vendor/github.com/aws/aws-sdk-go/aws/convert_types.go new file mode 100644 index 0000000000..d6a7b08dff --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/convert_types.go @@ -0,0 +1,357 @@ +package aws + +import "time" + +// String returns a pointer to of the string value passed in. +func String(v string) *string { + return &v +} + +// StringValue returns the value of the string pointer passed in or +// "" if the pointer is nil. +func StringValue(v *string) string { + if v != nil { + return *v + } + return "" +} + +// StringSlice converts a slice of string values into a slice of +// string pointers +func StringSlice(src []string) []*string { + dst := make([]*string, len(src)) + for i := 0; i < len(src); i++ { + dst[i] = &(src[i]) + } + return dst +} + +// StringValueSlice converts a slice of string pointers into a slice of +// string values +func StringValueSlice(src []*string) []string { + dst := make([]string, len(src)) + for i := 0; i < len(src); i++ { + if src[i] != nil { + dst[i] = *(src[i]) + } + } + return dst +} + +// StringMap converts a string map of string values into a string +// map of string pointers +func StringMap(src map[string]string) map[string]*string { + dst := make(map[string]*string) + for k, val := range src { + v := val + dst[k] = &v + } + return dst +} + +// StringValueMap converts a string map of string pointers into a string +// map of string values +func StringValueMap(src map[string]*string) map[string]string { + dst := make(map[string]string) + for k, val := range src { + if val != nil { + dst[k] = *val + } + } + return dst +} + +// Bool returns a pointer to of the bool value passed in. +func Bool(v bool) *bool { + return &v +} + +// BoolValue returns the value of the bool pointer passed in or +// false if the pointer is nil. +func BoolValue(v *bool) bool { + if v != nil { + return *v + } + return false +} + +// BoolSlice converts a slice of bool values into a slice of +// bool pointers +func BoolSlice(src []bool) []*bool { + dst := make([]*bool, len(src)) + for i := 0; i < len(src); i++ { + dst[i] = &(src[i]) + } + return dst +} + +// BoolValueSlice converts a slice of bool pointers into a slice of +// bool values +func BoolValueSlice(src []*bool) []bool { + dst := make([]bool, len(src)) + for i := 0; i < len(src); i++ { + if src[i] != nil { + dst[i] = *(src[i]) + } + } + return dst +} + +// BoolMap converts a string map of bool values into a string +// map of bool pointers +func BoolMap(src map[string]bool) map[string]*bool { + dst := make(map[string]*bool) + for k, val := range src { + v := val + dst[k] = &v + } + return dst +} + +// BoolValueMap converts a string map of bool pointers into a string +// map of bool values +func BoolValueMap(src map[string]*bool) map[string]bool { + dst := make(map[string]bool) + for k, val := range src { + if val != nil { + dst[k] = *val + } + } + return dst +} + +// Int returns a pointer to of the int value passed in. +func Int(v int) *int { + return &v +} + +// IntValue returns the value of the int pointer passed in or +// 0 if the pointer is nil. +func IntValue(v *int) int { + if v != nil { + return *v + } + return 0 +} + +// IntSlice converts a slice of int values into a slice of +// int pointers +func IntSlice(src []int) []*int { + dst := make([]*int, len(src)) + for i := 0; i < len(src); i++ { + dst[i] = &(src[i]) + } + return dst +} + +// IntValueSlice converts a slice of int pointers into a slice of +// int values +func IntValueSlice(src []*int) []int { + dst := make([]int, len(src)) + for i := 0; i < len(src); i++ { + if src[i] != nil { + dst[i] = *(src[i]) + } + } + return dst +} + +// IntMap converts a string map of int values into a string +// map of int pointers +func IntMap(src map[string]int) map[string]*int { + dst := make(map[string]*int) + for k, val := range src { + v := val + dst[k] = &v + } + return dst +} + +// IntValueMap converts a string map of int pointers into a string +// map of int values +func IntValueMap(src map[string]*int) map[string]int { + dst := make(map[string]int) + for k, val := range src { + if val != nil { + dst[k] = *val + } + } + return dst +} + +// Int64 returns a pointer to of the int64 value passed in. +func Int64(v int64) *int64 { + return &v +} + +// Int64Value returns the value of the int64 pointer passed in or +// 0 if the pointer is nil. +func Int64Value(v *int64) int64 { + if v != nil { + return *v + } + return 0 +} + +// Int64Slice converts a slice of int64 values into a slice of +// int64 pointers +func Int64Slice(src []int64) []*int64 { + dst := make([]*int64, len(src)) + for i := 0; i < len(src); i++ { + dst[i] = &(src[i]) + } + return dst +} + +// Int64ValueSlice converts a slice of int64 pointers into a slice of +// int64 values +func Int64ValueSlice(src []*int64) []int64 { + dst := make([]int64, len(src)) + for i := 0; i < len(src); i++ { + if src[i] != nil { + dst[i] = *(src[i]) + } + } + return dst +} + +// Int64Map converts a string map of int64 values into a string +// map of int64 pointers +func Int64Map(src map[string]int64) map[string]*int64 { + dst := make(map[string]*int64) + for k, val := range src { + v := val + dst[k] = &v + } + return dst +} + +// Int64ValueMap converts a string map of int64 pointers into a string +// map of int64 values +func Int64ValueMap(src map[string]*int64) map[string]int64 { + dst := make(map[string]int64) + for k, val := range src { + if val != nil { + dst[k] = *val + } + } + return dst +} + +// Float64 returns a pointer to of the float64 value passed in. +func Float64(v float64) *float64 { + return &v +} + +// Float64Value returns the value of the float64 pointer passed in or +// 0 if the pointer is nil. +func Float64Value(v *float64) float64 { + if v != nil { + return *v + } + return 0 +} + +// Float64Slice converts a slice of float64 values into a slice of +// float64 pointers +func Float64Slice(src []float64) []*float64 { + dst := make([]*float64, len(src)) + for i := 0; i < len(src); i++ { + dst[i] = &(src[i]) + } + return dst +} + +// Float64ValueSlice converts a slice of float64 pointers into a slice of +// float64 values +func Float64ValueSlice(src []*float64) []float64 { + dst := make([]float64, len(src)) + for i := 0; i < len(src); i++ { + if src[i] != nil { + dst[i] = *(src[i]) + } + } + return dst +} + +// Float64Map converts a string map of float64 values into a string +// map of float64 pointers +func Float64Map(src map[string]float64) map[string]*float64 { + dst := make(map[string]*float64) + for k, val := range src { + v := val + dst[k] = &v + } + return dst +} + +// Float64ValueMap converts a string map of float64 pointers into a string +// map of float64 values +func Float64ValueMap(src map[string]*float64) map[string]float64 { + dst := make(map[string]float64) + for k, val := range src { + if val != nil { + dst[k] = *val + } + } + return dst +} + +// Time returns a pointer to of the time.Time value passed in. +func Time(v time.Time) *time.Time { + return &v +} + +// TimeValue returns the value of the time.Time pointer passed in or +// time.Time{} if the pointer is nil. +func TimeValue(v *time.Time) time.Time { + if v != nil { + return *v + } + return time.Time{} +} + +// TimeSlice converts a slice of time.Time values into a slice of +// time.Time pointers +func TimeSlice(src []time.Time) []*time.Time { + dst := make([]*time.Time, len(src)) + for i := 0; i < len(src); i++ { + dst[i] = &(src[i]) + } + return dst +} + +// TimeValueSlice converts a slice of time.Time pointers into a slice of +// time.Time values +func TimeValueSlice(src []*time.Time) []time.Time { + dst := make([]time.Time, len(src)) + for i := 0; i < len(src); i++ { + if src[i] != nil { + dst[i] = *(src[i]) + } + } + return dst +} + +// TimeMap converts a string map of time.Time values into a string +// map of time.Time pointers +func TimeMap(src map[string]time.Time) map[string]*time.Time { + dst := make(map[string]*time.Time) + for k, val := range src { + v := val + dst[k] = &v + } + return dst +} + +// TimeValueMap converts a string map of time.Time pointers into a string +// map of time.Time values +func TimeValueMap(src map[string]*time.Time) map[string]time.Time { + dst := make(map[string]time.Time) + for k, val := range src { + if val != nil { + dst[k] = *val + } + } + return dst +} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/credentials/chain_provider.go b/vendor/github.com/aws/aws-sdk-go/aws/credentials/chain_provider.go new file mode 100644 index 0000000000..857311f64c --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/credentials/chain_provider.go @@ -0,0 +1,100 @@ +package credentials + +import ( + "github.com/aws/aws-sdk-go/aws/awserr" +) + +var ( + // ErrNoValidProvidersFoundInChain Is returned when there are no valid + // providers in the ChainProvider. + // + // This has been deprecated. For verbose error messaging set + // aws.Config.CredentialsChainVerboseErrors to true + // + // @readonly + ErrNoValidProvidersFoundInChain = awserr.New("NoCredentialProviders", + `no valid providers in chain. Deprecated. + For verbose messaging see aws.Config.CredentialsChainVerboseErrors`, + nil) +) + +// A ChainProvider will search for a provider which returns credentials +// and cache that provider until Retrieve is called again. +// +// The ChainProvider provides a way of chaining multiple providers together +// which will pick the first available using priority order of the Providers +// in the list. +// +// If none of the Providers retrieve valid credentials Value, ChainProvider's +// Retrieve() will return the error ErrNoValidProvidersFoundInChain. +// +// If a Provider is found which returns valid credentials Value ChainProvider +// will cache that Provider for all calls to IsExpired(), until Retrieve is +// called again. +// +// Example of ChainProvider to be used with an EnvProvider and EC2RoleProvider. +// In this example EnvProvider will first check if any credentials are available +// vai the environment variables. If there are none ChainProvider will check +// the next Provider in the list, EC2RoleProvider in this case. If EC2RoleProvider +// does not return any credentials ChainProvider will return the error +// ErrNoValidProvidersFoundInChain +// +// creds := NewChainCredentials( +// []Provider{ +// &EnvProvider{}, +// &EC2RoleProvider{ +// Client: ec2metadata.New(sess), +// }, +// }) +// +// // Usage of ChainCredentials with aws.Config +// svc := ec2.New(&aws.Config{Credentials: creds}) +// +type ChainProvider struct { + Providers []Provider + curr Provider + VerboseErrors bool +} + +// NewChainCredentials returns a pointer to a new Credentials object +// wrapping a chain of providers. +func NewChainCredentials(providers []Provider) *Credentials { + return NewCredentials(&ChainProvider{ + Providers: append([]Provider{}, providers...), + }) +} + +// Retrieve returns the credentials value or error if no provider returned +// without error. +// +// If a provider is found it will be cached and any calls to IsExpired() +// will return the expired state of the cached provider. +func (c *ChainProvider) Retrieve() (Value, error) { + var errs []error + for _, p := range c.Providers { + creds, err := p.Retrieve() + if err == nil { + c.curr = p + return creds, nil + } + errs = append(errs, err) + } + c.curr = nil + + var err error + err = ErrNoValidProvidersFoundInChain + if c.VerboseErrors { + err = awserr.NewBatchError("NoCredentialProviders", "no valid providers in chain", errs) + } + return Value{}, err +} + +// IsExpired will returned the expired state of the currently cached provider +// if there is one. If there is no current provider, true will be returned. +func (c *ChainProvider) IsExpired() bool { + if c.curr != nil { + return c.curr.IsExpired() + } + + return true +} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/credentials/credentials.go b/vendor/github.com/aws/aws-sdk-go/aws/credentials/credentials.go new file mode 100644 index 0000000000..7b8ebf5f9d --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/credentials/credentials.go @@ -0,0 +1,223 @@ +// Package credentials provides credential retrieval and management +// +// The Credentials is the primary method of getting access to and managing +// credentials Values. Using dependency injection retrieval of the credential +// values is handled by a object which satisfies the Provider interface. +// +// By default the Credentials.Get() will cache the successful result of a +// Provider's Retrieve() until Provider.IsExpired() returns true. At which +// point Credentials will call Provider's Retrieve() to get new credential Value. +// +// The Provider is responsible for determining when credentials Value have expired. +// It is also important to note that Credentials will always call Retrieve the +// first time Credentials.Get() is called. +// +// Example of using the environment variable credentials. +// +// creds := NewEnvCredentials() +// +// // Retrieve the credentials value +// credValue, err := creds.Get() +// if err != nil { +// // handle error +// } +// +// Example of forcing credentials to expire and be refreshed on the next Get(). +// This may be helpful to proactively expire credentials and refresh them sooner +// than they would naturally expire on their own. +// +// creds := NewCredentials(&EC2RoleProvider{}) +// creds.Expire() +// credsValue, err := creds.Get() +// // New credentials will be retrieved instead of from cache. +// +// +// Custom Provider +// +// Each Provider built into this package also provides a helper method to generate +// a Credentials pointer setup with the provider. To use a custom Provider just +// create a type which satisfies the Provider interface and pass it to the +// NewCredentials method. +// +// type MyProvider struct{} +// func (m *MyProvider) Retrieve() (Value, error) {...} +// func (m *MyProvider) IsExpired() bool {...} +// +// creds := NewCredentials(&MyProvider{}) +// credValue, err := creds.Get() +// +package credentials + +import ( + "sync" + "time" +) + +// AnonymousCredentials is an empty Credential object that can be used as +// dummy placeholder credentials for requests that do not need signed. +// +// This Credentials can be used to configure a service to not sign requests +// when making service API calls. For example, when accessing public +// s3 buckets. +// +// svc := s3.New(&aws.Config{Credentials: AnonymousCredentials}) +// // Access public S3 buckets. +// +// @readonly +var AnonymousCredentials = NewStaticCredentials("", "", "") + +// A Value is the AWS credentials value for individual credential fields. +type Value struct { + // AWS Access key ID + AccessKeyID string + + // AWS Secret Access Key + SecretAccessKey string + + // AWS Session Token + SessionToken string + + // Provider used to get credentials + ProviderName string +} + +// A Provider is the interface for any component which will provide credentials +// Value. A provider is required to manage its own Expired state, and what to +// be expired means. +// +// The Provider should not need to implement its own mutexes, because +// that will be managed by Credentials. +type Provider interface { + // Refresh returns nil if it successfully retrieved the value. + // Error is returned if the value were not obtainable, or empty. + Retrieve() (Value, error) + + // IsExpired returns if the credentials are no longer valid, and need + // to be retrieved. + IsExpired() bool +} + +// A Expiry provides shared expiration logic to be used by credentials +// providers to implement expiry functionality. +// +// The best method to use this struct is as an anonymous field within the +// provider's struct. +// +// Example: +// type EC2RoleProvider struct { +// Expiry +// ... +// } +type Expiry struct { + // The date/time when to expire on + expiration time.Time + + // If set will be used by IsExpired to determine the current time. + // Defaults to time.Now if CurrentTime is not set. Available for testing + // to be able to mock out the current time. + CurrentTime func() time.Time +} + +// SetExpiration sets the expiration IsExpired will check when called. +// +// If window is greater than 0 the expiration time will be reduced by the +// window value. +// +// Using a window is helpful to trigger credentials to expire sooner than +// the expiration time given to ensure no requests are made with expired +// tokens. +func (e *Expiry) SetExpiration(expiration time.Time, window time.Duration) { + e.expiration = expiration + if window > 0 { + e.expiration = e.expiration.Add(-window) + } +} + +// IsExpired returns if the credentials are expired. +func (e *Expiry) IsExpired() bool { + if e.CurrentTime == nil { + e.CurrentTime = time.Now + } + return e.expiration.Before(e.CurrentTime()) +} + +// A Credentials provides synchronous safe retrieval of AWS credentials Value. +// Credentials will cache the credentials value until they expire. Once the value +// expires the next Get will attempt to retrieve valid credentials. +// +// Credentials is safe to use across multiple goroutines and will manage the +// synchronous state so the Providers do not need to implement their own +// synchronization. +// +// The first Credentials.Get() will always call Provider.Retrieve() to get the +// first instance of the credentials Value. All calls to Get() after that +// will return the cached credentials Value until IsExpired() returns true. +type Credentials struct { + creds Value + forceRefresh bool + m sync.Mutex + + provider Provider +} + +// NewCredentials returns a pointer to a new Credentials with the provider set. +func NewCredentials(provider Provider) *Credentials { + return &Credentials{ + provider: provider, + forceRefresh: true, + } +} + +// Get returns the credentials value, or error if the credentials Value failed +// to be retrieved. +// +// Will return the cached credentials Value if it has not expired. If the +// credentials Value has expired the Provider's Retrieve() will be called +// to refresh the credentials. +// +// If Credentials.Expire() was called the credentials Value will be force +// expired, and the next call to Get() will cause them to be refreshed. +func (c *Credentials) Get() (Value, error) { + c.m.Lock() + defer c.m.Unlock() + + if c.isExpired() { + creds, err := c.provider.Retrieve() + if err != nil { + return Value{}, err + } + c.creds = creds + c.forceRefresh = false + } + + return c.creds, nil +} + +// Expire expires the credentials and forces them to be retrieved on the +// next call to Get(). +// +// This will override the Provider's expired state, and force Credentials +// to call the Provider's Retrieve(). +func (c *Credentials) Expire() { + c.m.Lock() + defer c.m.Unlock() + + c.forceRefresh = true +} + +// IsExpired returns if the credentials are no longer valid, and need +// to be retrieved. +// +// If the Credentials were forced to be expired with Expire() this will +// reflect that override. +func (c *Credentials) IsExpired() bool { + c.m.Lock() + defer c.m.Unlock() + + return c.isExpired() +} + +// isExpired helper method wrapping the definition of expired credentials. +func (c *Credentials) isExpired() bool { + return c.forceRefresh || c.provider.IsExpired() +} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/credentials/env_provider.go b/vendor/github.com/aws/aws-sdk-go/aws/credentials/env_provider.go new file mode 100644 index 0000000000..96655bc46a --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/credentials/env_provider.go @@ -0,0 +1,77 @@ +package credentials + +import ( + "os" + + "github.com/aws/aws-sdk-go/aws/awserr" +) + +// EnvProviderName provides a name of Env provider +const EnvProviderName = "EnvProvider" + +var ( + // ErrAccessKeyIDNotFound is returned when the AWS Access Key ID can't be + // found in the process's environment. + // + // @readonly + ErrAccessKeyIDNotFound = awserr.New("EnvAccessKeyNotFound", "AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY not found in environment", nil) + + // ErrSecretAccessKeyNotFound is returned when the AWS Secret Access Key + // can't be found in the process's environment. + // + // @readonly + ErrSecretAccessKeyNotFound = awserr.New("EnvSecretNotFound", "AWS_SECRET_ACCESS_KEY or AWS_SECRET_KEY not found in environment", nil) +) + +// A EnvProvider retrieves credentials from the environment variables of the +// running process. Environment credentials never expire. +// +// Environment variables used: +// +// * Access Key ID: AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY +// * Secret Access Key: AWS_SECRET_ACCESS_KEY or AWS_SECRET_KEY +type EnvProvider struct { + retrieved bool +} + +// NewEnvCredentials returns a pointer to a new Credentials object +// wrapping the environment variable provider. +func NewEnvCredentials() *Credentials { + return NewCredentials(&EnvProvider{}) +} + +// Retrieve retrieves the keys from the environment. +func (e *EnvProvider) Retrieve() (Value, error) { + e.retrieved = false + + id := os.Getenv("AWS_ACCESS_KEY_ID") + if id == "" { + id = os.Getenv("AWS_ACCESS_KEY") + } + + secret := os.Getenv("AWS_SECRET_ACCESS_KEY") + if secret == "" { + secret = os.Getenv("AWS_SECRET_KEY") + } + + if id == "" { + return Value{ProviderName: EnvProviderName}, ErrAccessKeyIDNotFound + } + + if secret == "" { + return Value{ProviderName: EnvProviderName}, ErrSecretAccessKeyNotFound + } + + e.retrieved = true + return Value{ + AccessKeyID: id, + SecretAccessKey: secret, + SessionToken: os.Getenv("AWS_SESSION_TOKEN"), + ProviderName: EnvProviderName, + }, nil +} + +// IsExpired returns if the credentials have been retrieved. +func (e *EnvProvider) IsExpired() bool { + return !e.retrieved +} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/credentials/shared_credentials_provider.go b/vendor/github.com/aws/aws-sdk-go/aws/credentials/shared_credentials_provider.go new file mode 100644 index 0000000000..7fb7cbf0db --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/credentials/shared_credentials_provider.go @@ -0,0 +1,151 @@ +package credentials + +import ( + "fmt" + "os" + "path/filepath" + + "github.com/go-ini/ini" + + "github.com/aws/aws-sdk-go/aws/awserr" +) + +// SharedCredsProviderName provides a name of SharedCreds provider +const SharedCredsProviderName = "SharedCredentialsProvider" + +var ( + // ErrSharedCredentialsHomeNotFound is emitted when the user directory cannot be found. + // + // @readonly + ErrSharedCredentialsHomeNotFound = awserr.New("UserHomeNotFound", "user home directory not found.", nil) +) + +// A SharedCredentialsProvider retrieves credentials from the current user's home +// directory, and keeps track if those credentials are expired. +// +// Profile ini file example: $HOME/.aws/credentials +type SharedCredentialsProvider struct { + // Path to the shared credentials file. + // + // If empty will look for "AWS_SHARED_CREDENTIALS_FILE" env variable. If the + // env value is empty will default to current user's home directory. + // Linux/OSX: "$HOME/.aws/credentials" + // Windows: "%USERPROFILE%\.aws\credentials" + Filename string + + // AWS Profile to extract credentials from the shared credentials file. If empty + // will default to environment variable "AWS_PROFILE" or "default" if + // environment variable is also not set. + Profile string + + // retrieved states if the credentials have been successfully retrieved. + retrieved bool +} + +// NewSharedCredentials returns a pointer to a new Credentials object +// wrapping the Profile file provider. +func NewSharedCredentials(filename, profile string) *Credentials { + return NewCredentials(&SharedCredentialsProvider{ + Filename: filename, + Profile: profile, + }) +} + +// Retrieve reads and extracts the shared credentials from the current +// users home directory. +func (p *SharedCredentialsProvider) Retrieve() (Value, error) { + p.retrieved = false + + filename, err := p.filename() + if err != nil { + return Value{ProviderName: SharedCredsProviderName}, err + } + + creds, err := loadProfile(filename, p.profile()) + if err != nil { + return Value{ProviderName: SharedCredsProviderName}, err + } + + p.retrieved = true + return creds, nil +} + +// IsExpired returns if the shared credentials have expired. +func (p *SharedCredentialsProvider) IsExpired() bool { + return !p.retrieved +} + +// loadProfiles loads from the file pointed to by shared credentials filename for profile. +// The credentials retrieved from the profile will be returned or error. Error will be +// returned if it fails to read from the file, or the data is invalid. +func loadProfile(filename, profile string) (Value, error) { + config, err := ini.Load(filename) + if err != nil { + return Value{ProviderName: SharedCredsProviderName}, awserr.New("SharedCredsLoad", "failed to load shared credentials file", err) + } + iniProfile, err := config.GetSection(profile) + if err != nil { + return Value{ProviderName: SharedCredsProviderName}, awserr.New("SharedCredsLoad", "failed to get profile", err) + } + + id, err := iniProfile.GetKey("aws_access_key_id") + if err != nil { + return Value{ProviderName: SharedCredsProviderName}, awserr.New("SharedCredsAccessKey", + fmt.Sprintf("shared credentials %s in %s did not contain aws_access_key_id", profile, filename), + err) + } + + secret, err := iniProfile.GetKey("aws_secret_access_key") + if err != nil { + return Value{ProviderName: SharedCredsProviderName}, awserr.New("SharedCredsSecret", + fmt.Sprintf("shared credentials %s in %s did not contain aws_secret_access_key", profile, filename), + nil) + } + + // Default to empty string if not found + token := iniProfile.Key("aws_session_token") + + return Value{ + AccessKeyID: id.String(), + SecretAccessKey: secret.String(), + SessionToken: token.String(), + ProviderName: SharedCredsProviderName, + }, nil +} + +// filename returns the filename to use to read AWS shared credentials. +// +// Will return an error if the user's home directory path cannot be found. +func (p *SharedCredentialsProvider) filename() (string, error) { + if p.Filename == "" { + if p.Filename = os.Getenv("AWS_SHARED_CREDENTIALS_FILE"); p.Filename != "" { + return p.Filename, nil + } + + homeDir := os.Getenv("HOME") // *nix + if homeDir == "" { // Windows + homeDir = os.Getenv("USERPROFILE") + } + if homeDir == "" { + return "", ErrSharedCredentialsHomeNotFound + } + + p.Filename = filepath.Join(homeDir, ".aws", "credentials") + } + + return p.Filename, nil +} + +// profile returns the AWS shared credentials profile. If empty will read +// environment variable "AWS_PROFILE". If that is not set profile will +// return "default". +func (p *SharedCredentialsProvider) profile() string { + if p.Profile == "" { + p.Profile = os.Getenv("AWS_PROFILE") + } + if p.Profile == "" { + p.Profile = "default" + } + + return p.Profile +} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/credentials/static_provider.go b/vendor/github.com/aws/aws-sdk-go/aws/credentials/static_provider.go new file mode 100644 index 0000000000..71189e733d --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/credentials/static_provider.go @@ -0,0 +1,48 @@ +package credentials + +import ( + "github.com/aws/aws-sdk-go/aws/awserr" +) + +// StaticProviderName provides a name of Static provider +const StaticProviderName = "StaticProvider" + +var ( + // ErrStaticCredentialsEmpty is emitted when static credentials are empty. + // + // @readonly + ErrStaticCredentialsEmpty = awserr.New("EmptyStaticCreds", "static credentials are empty", nil) +) + +// A StaticProvider is a set of credentials which are set pragmatically, +// and will never expire. +type StaticProvider struct { + Value +} + +// NewStaticCredentials returns a pointer to a new Credentials object +// wrapping a static credentials value provider. +func NewStaticCredentials(id, secret, token string) *Credentials { + return NewCredentials(&StaticProvider{Value: Value{ + AccessKeyID: id, + SecretAccessKey: secret, + SessionToken: token, + }}) +} + +// Retrieve returns the credentials or error if the credentials are invalid. +func (s *StaticProvider) Retrieve() (Value, error) { + if s.AccessKeyID == "" || s.SecretAccessKey == "" { + return Value{ProviderName: StaticProviderName}, ErrStaticCredentialsEmpty + } + + s.Value.ProviderName = StaticProviderName + return s.Value, nil +} + +// IsExpired returns if the credentials are expired. +// +// For StaticProvider, the credentials never expired. +func (s *StaticProvider) IsExpired() bool { + return false +} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/errors.go b/vendor/github.com/aws/aws-sdk-go/aws/errors.go new file mode 100644 index 0000000000..5766361686 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/errors.go @@ -0,0 +1,17 @@ +package aws + +import "github.com/aws/aws-sdk-go/aws/awserr" + +var ( + // ErrMissingRegion is an error that is returned if region configuration is + // not found. + // + // @readonly + ErrMissingRegion = awserr.New("MissingRegion", "could not find region configuration", nil) + + // ErrMissingEndpoint is an error that is returned if an endpoint cannot be + // resolved for a service. + // + // @readonly + ErrMissingEndpoint = awserr.New("MissingEndpoint", "'Endpoint' configuration is required for this service", nil) +) diff --git a/vendor/github.com/aws/aws-sdk-go/aws/logger.go b/vendor/github.com/aws/aws-sdk-go/aws/logger.go new file mode 100644 index 0000000000..db87188e20 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/logger.go @@ -0,0 +1,112 @@ +package aws + +import ( + "log" + "os" +) + +// A LogLevelType defines the level logging should be performed at. Used to instruct +// the SDK which statements should be logged. +type LogLevelType uint + +// LogLevel returns the pointer to a LogLevel. Should be used to workaround +// not being able to take the address of a non-composite literal. +func LogLevel(l LogLevelType) *LogLevelType { + return &l +} + +// Value returns the LogLevel value or the default value LogOff if the LogLevel +// is nil. Safe to use on nil value LogLevelTypes. +func (l *LogLevelType) Value() LogLevelType { + if l != nil { + return *l + } + return LogOff +} + +// Matches returns true if the v LogLevel is enabled by this LogLevel. Should be +// used with logging sub levels. Is safe to use on nil value LogLevelTypes. If +// LogLevel is nill, will default to LogOff comparison. +func (l *LogLevelType) Matches(v LogLevelType) bool { + c := l.Value() + return c&v == v +} + +// AtLeast returns true if this LogLevel is at least high enough to satisfies v. +// Is safe to use on nil value LogLevelTypes. If LogLevel is nill, will default +// to LogOff comparison. +func (l *LogLevelType) AtLeast(v LogLevelType) bool { + c := l.Value() + return c >= v +} + +const ( + // LogOff states that no logging should be performed by the SDK. This is the + // default state of the SDK, and should be use to disable all logging. + LogOff LogLevelType = iota * 0x1000 + + // LogDebug state that debug output should be logged by the SDK. This should + // be used to inspect request made and responses received. + LogDebug +) + +// Debug Logging Sub Levels +const ( + // LogDebugWithSigning states that the SDK should log request signing and + // presigning events. This should be used to log the signing details of + // requests for debugging. Will also enable LogDebug. + LogDebugWithSigning LogLevelType = LogDebug | (1 << iota) + + // LogDebugWithHTTPBody states the SDK should log HTTP request and response + // HTTP bodys in addition to the headers and path. This should be used to + // see the body content of requests and responses made while using the SDK + // Will also enable LogDebug. + LogDebugWithHTTPBody + + // LogDebugWithRequestRetries states the SDK should log when service requests will + // be retried. This should be used to log when you want to log when service + // requests are being retried. Will also enable LogDebug. + LogDebugWithRequestRetries + + // LogDebugWithRequestErrors states the SDK should log when service requests fail + // to build, send, validate, or unmarshal. + LogDebugWithRequestErrors +) + +// A Logger is a minimalistic interface for the SDK to log messages to. Should +// be used to provide custom logging writers for the SDK to use. +type Logger interface { + Log(...interface{}) +} + +// A LoggerFunc is a convenience type to convert a function taking a variadic +// list of arguments and wrap it so the Logger interface can be used. +// +// Example: +// s3.New(sess, &aws.Config{Logger: aws.LoggerFunc(func(args ...interface{}) { +// fmt.Fprintln(os.Stdout, args...) +// })}) +type LoggerFunc func(...interface{}) + +// Log calls the wrapped function with the arguments provided +func (f LoggerFunc) Log(args ...interface{}) { + f(args...) +} + +// NewDefaultLogger returns a Logger which will write log messages to stdout, and +// use same formatting runes as the stdlib log.Logger +func NewDefaultLogger() Logger { + return &defaultLogger{ + logger: log.New(os.Stdout, "", log.LstdFlags), + } +} + +// A defaultLogger provides a minimalistic logger satisfying the Logger interface. +type defaultLogger struct { + logger *log.Logger +} + +// Log logs the parameters to the stdlib logger. See log.Println. +func (l defaultLogger) Log(args ...interface{}) { + l.logger.Println(args...) +} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/request/handlers.go b/vendor/github.com/aws/aws-sdk-go/aws/request/handlers.go new file mode 100644 index 0000000000..5279c19c09 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/request/handlers.go @@ -0,0 +1,187 @@ +package request + +import ( + "fmt" + "strings" +) + +// A Handlers provides a collection of request handlers for various +// stages of handling requests. +type Handlers struct { + Validate HandlerList + Build HandlerList + Sign HandlerList + Send HandlerList + ValidateResponse HandlerList + Unmarshal HandlerList + UnmarshalMeta HandlerList + UnmarshalError HandlerList + Retry HandlerList + AfterRetry HandlerList +} + +// Copy returns of this handler's lists. +func (h *Handlers) Copy() Handlers { + return Handlers{ + Validate: h.Validate.copy(), + Build: h.Build.copy(), + Sign: h.Sign.copy(), + Send: h.Send.copy(), + ValidateResponse: h.ValidateResponse.copy(), + Unmarshal: h.Unmarshal.copy(), + UnmarshalError: h.UnmarshalError.copy(), + UnmarshalMeta: h.UnmarshalMeta.copy(), + Retry: h.Retry.copy(), + AfterRetry: h.AfterRetry.copy(), + } +} + +// Clear removes callback functions for all handlers +func (h *Handlers) Clear() { + h.Validate.Clear() + h.Build.Clear() + h.Send.Clear() + h.Sign.Clear() + h.Unmarshal.Clear() + h.UnmarshalMeta.Clear() + h.UnmarshalError.Clear() + h.ValidateResponse.Clear() + h.Retry.Clear() + h.AfterRetry.Clear() +} + +// A HandlerListRunItem represents an entry in the HandlerList which +// is being run. +type HandlerListRunItem struct { + Index int + Handler NamedHandler + Request *Request +} + +// A HandlerList manages zero or more handlers in a list. +type HandlerList struct { + list []NamedHandler + + // Called after each request handler in the list is called. If set + // and the func returns true the HandlerList will continue to iterate + // over the request handlers. If false is returned the HandlerList + // will stop iterating. + // + // Should be used if extra logic to be performed between each handler + // in the list. This can be used to terminate a list's iteration + // based on a condition such as error like, HandlerListStopOnError. + // Or for logging like HandlerListLogItem. + AfterEachFn func(item HandlerListRunItem) bool +} + +// A NamedHandler is a struct that contains a name and function callback. +type NamedHandler struct { + Name string + Fn func(*Request) +} + +// copy creates a copy of the handler list. +func (l *HandlerList) copy() HandlerList { + n := HandlerList{ + AfterEachFn: l.AfterEachFn, + } + n.list = append([]NamedHandler{}, l.list...) + return n +} + +// Clear clears the handler list. +func (l *HandlerList) Clear() { + l.list = []NamedHandler{} +} + +// Len returns the number of handlers in the list. +func (l *HandlerList) Len() int { + return len(l.list) +} + +// PushBack pushes handler f to the back of the handler list. +func (l *HandlerList) PushBack(f func(*Request)) { + l.list = append(l.list, NamedHandler{"__anonymous", f}) +} + +// PushFront pushes handler f to the front of the handler list. +func (l *HandlerList) PushFront(f func(*Request)) { + l.list = append([]NamedHandler{{"__anonymous", f}}, l.list...) +} + +// PushBackNamed pushes named handler f to the back of the handler list. +func (l *HandlerList) PushBackNamed(n NamedHandler) { + l.list = append(l.list, n) +} + +// PushFrontNamed pushes named handler f to the front of the handler list. +func (l *HandlerList) PushFrontNamed(n NamedHandler) { + l.list = append([]NamedHandler{n}, l.list...) +} + +// Remove removes a NamedHandler n +func (l *HandlerList) Remove(n NamedHandler) { + newlist := []NamedHandler{} + for _, m := range l.list { + if m.Name != n.Name { + newlist = append(newlist, m) + } + } + l.list = newlist +} + +// Run executes all handlers in the list with a given request object. +func (l *HandlerList) Run(r *Request) { + for i, h := range l.list { + h.Fn(r) + item := HandlerListRunItem{ + Index: i, Handler: h, Request: r, + } + if l.AfterEachFn != nil && !l.AfterEachFn(item) { + return + } + } +} + +// HandlerListLogItem logs the request handler and the state of the +// request's Error value. Always returns true to continue iterating +// request handlers in a HandlerList. +func HandlerListLogItem(item HandlerListRunItem) bool { + if item.Request.Config.Logger == nil { + return true + } + item.Request.Config.Logger.Log("DEBUG: RequestHandler", + item.Index, item.Handler.Name, item.Request.Error) + + return true +} + +// HandlerListStopOnError returns false to stop the HandlerList iterating +// over request handlers if Request.Error is not nil. True otherwise +// to continue iterating. +func HandlerListStopOnError(item HandlerListRunItem) bool { + return item.Request.Error == nil +} + +// MakeAddToUserAgentHandler will add the name/version pair to the User-Agent request +// header. If the extra parameters are provided they will be added as metadata to the +// name/version pair resulting in the following format. +// "name/version (extra0; extra1; ...)" +// The user agent part will be concatenated with this current request's user agent string. +func MakeAddToUserAgentHandler(name, version string, extra ...string) func(*Request) { + ua := fmt.Sprintf("%s/%s", name, version) + if len(extra) > 0 { + ua += fmt.Sprintf(" (%s)", strings.Join(extra, "; ")) + } + return func(r *Request) { + AddToUserAgent(r, ua) + } +} + +// MakeAddToUserAgentFreeFormHandler adds the input to the User-Agent request header. +// The input string will be concatenated with the current request's user agent string. +func MakeAddToUserAgentFreeFormHandler(s string) func(*Request) { + return func(r *Request) { + AddToUserAgent(r, s) + } +} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/request/request.go b/vendor/github.com/aws/aws-sdk-go/aws/request/request.go new file mode 100644 index 0000000000..85eead3d51 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/request/request.go @@ -0,0 +1,302 @@ +package request + +import ( + "bytes" + "fmt" + "io" + "io/ioutil" + "net/http" + "net/url" + "reflect" + "strings" + "time" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/client/metadata" +) + +// A Request is the service request to be made. +type Request struct { + Config aws.Config + ClientInfo metadata.ClientInfo + Handlers Handlers + + Retryer + Time time.Time + ExpireTime time.Duration + Operation *Operation + HTTPRequest *http.Request + HTTPResponse *http.Response + Body io.ReadSeeker + BodyStart int64 // offset from beginning of Body that the request body starts + Params interface{} + Error error + Data interface{} + RequestID string + RetryCount int + Retryable *bool + RetryDelay time.Duration + NotHoist bool + SignedHeaderVals http.Header + + built bool +} + +// An Operation is the service API operation to be made. +type Operation struct { + Name string + HTTPMethod string + HTTPPath string + *Paginator +} + +// Paginator keeps track of pagination configuration for an API operation. +type Paginator struct { + InputTokens []string + OutputTokens []string + LimitToken string + TruncationToken string +} + +// New returns a new Request pointer for the service API +// operation and parameters. +// +// Params is any value of input parameters to be the request payload. +// Data is pointer value to an object which the request's response +// payload will be deserialized to. +func New(cfg aws.Config, clientInfo metadata.ClientInfo, handlers Handlers, + retryer Retryer, operation *Operation, params interface{}, data interface{}) *Request { + + method := operation.HTTPMethod + if method == "" { + method = "POST" + } + p := operation.HTTPPath + if p == "" { + p = "/" + } + + httpReq, _ := http.NewRequest(method, "", nil) + httpReq.URL, _ = url.Parse(clientInfo.Endpoint + p) + + r := &Request{ + Config: cfg, + ClientInfo: clientInfo, + Handlers: handlers.Copy(), + + Retryer: retryer, + Time: time.Now(), + ExpireTime: 0, + Operation: operation, + HTTPRequest: httpReq, + Body: nil, + Params: params, + Error: nil, + Data: data, + } + r.SetBufferBody([]byte{}) + + return r +} + +// WillRetry returns if the request's can be retried. +func (r *Request) WillRetry() bool { + return r.Error != nil && aws.BoolValue(r.Retryable) && r.RetryCount < r.MaxRetries() +} + +// ParamsFilled returns if the request's parameters have been populated +// and the parameters are valid. False is returned if no parameters are +// provided or invalid. +func (r *Request) ParamsFilled() bool { + return r.Params != nil && reflect.ValueOf(r.Params).Elem().IsValid() +} + +// DataFilled returns true if the request's data for response deserialization +// target has been set and is a valid. False is returned if data is not +// set, or is invalid. +func (r *Request) DataFilled() bool { + return r.Data != nil && reflect.ValueOf(r.Data).Elem().IsValid() +} + +// SetBufferBody will set the request's body bytes that will be sent to +// the service API. +func (r *Request) SetBufferBody(buf []byte) { + r.SetReaderBody(bytes.NewReader(buf)) +} + +// SetStringBody sets the body of the request to be backed by a string. +func (r *Request) SetStringBody(s string) { + r.SetReaderBody(strings.NewReader(s)) +} + +// SetReaderBody will set the request's body reader. +func (r *Request) SetReaderBody(reader io.ReadSeeker) { + r.HTTPRequest.Body = ioutil.NopCloser(reader) + r.Body = reader +} + +// Presign returns the request's signed URL. Error will be returned +// if the signing fails. +func (r *Request) Presign(expireTime time.Duration) (string, error) { + r.ExpireTime = expireTime + r.NotHoist = false + r.Sign() + if r.Error != nil { + return "", r.Error + } + return r.HTTPRequest.URL.String(), nil +} + +// PresignRequest behaves just like presign, but hoists all headers and signs them. +// Also returns the signed hash back to the user +func (r *Request) PresignRequest(expireTime time.Duration) (string, http.Header, error) { + r.ExpireTime = expireTime + r.NotHoist = true + r.Sign() + if r.Error != nil { + return "", nil, r.Error + } + return r.HTTPRequest.URL.String(), r.SignedHeaderVals, nil +} + +func debugLogReqError(r *Request, stage string, retrying bool, err error) { + if !r.Config.LogLevel.Matches(aws.LogDebugWithRequestErrors) { + return + } + + retryStr := "not retrying" + if retrying { + retryStr = "will retry" + } + + r.Config.Logger.Log(fmt.Sprintf("DEBUG: %s %s/%s failed, %s, error %v", + stage, r.ClientInfo.ServiceName, r.Operation.Name, retryStr, err)) +} + +// Build will build the request's object so it can be signed and sent +// to the service. Build will also validate all the request's parameters. +// Anny additional build Handlers set on this request will be run +// in the order they were set. +// +// The request will only be built once. Multiple calls to build will have +// no effect. +// +// If any Validate or Build errors occur the build will stop and the error +// which occurred will be returned. +func (r *Request) Build() error { + if !r.built { + r.Error = nil + r.Handlers.Validate.Run(r) + if r.Error != nil { + debugLogReqError(r, "Validate Request", false, r.Error) + return r.Error + } + r.Handlers.Build.Run(r) + if r.Error != nil { + debugLogReqError(r, "Build Request", false, r.Error) + return r.Error + } + r.built = true + } + + return r.Error +} + +// Sign will sign the request retuning error if errors are encountered. +// +// Send will build the request prior to signing. All Sign Handlers will +// be executed in the order they were set. +func (r *Request) Sign() error { + r.Build() + if r.Error != nil { + debugLogReqError(r, "Build Request", false, r.Error) + return r.Error + } + + r.Handlers.Sign.Run(r) + return r.Error +} + +// Send will send the request returning error if errors are encountered. +// +// Send will sign the request prior to sending. All Send Handlers will +// be executed in the order they were set. +func (r *Request) Send() error { + for { + r.Sign() + if r.Error != nil { + return r.Error + } + + if aws.BoolValue(r.Retryable) { + if r.Config.LogLevel.Matches(aws.LogDebugWithRequestRetries) { + r.Config.Logger.Log(fmt.Sprintf("DEBUG: Retrying Request %s/%s, attempt %d", + r.ClientInfo.ServiceName, r.Operation.Name, r.RetryCount)) + } + + // Closing response body. Since we are setting a new request to send off, this + // response will get squashed and leaked. + r.HTTPResponse.Body.Close() + + // Re-seek the body back to the original point in for a retry so that + // send will send the body's contents again in the upcoming request. + r.Body.Seek(r.BodyStart, 0) + r.HTTPRequest.Body = ioutil.NopCloser(r.Body) + } + r.Retryable = nil + + r.Handlers.Send.Run(r) + if r.Error != nil { + err := r.Error + r.Handlers.Retry.Run(r) + r.Handlers.AfterRetry.Run(r) + if r.Error != nil { + debugLogReqError(r, "Send Request", false, r.Error) + return r.Error + } + debugLogReqError(r, "Send Request", true, err) + continue + } + + r.Handlers.UnmarshalMeta.Run(r) + r.Handlers.ValidateResponse.Run(r) + if r.Error != nil { + err := r.Error + r.Handlers.UnmarshalError.Run(r) + r.Handlers.Retry.Run(r) + r.Handlers.AfterRetry.Run(r) + if r.Error != nil { + debugLogReqError(r, "Validate Response", false, r.Error) + return r.Error + } + debugLogReqError(r, "Validate Response", true, err) + continue + } + + r.Handlers.Unmarshal.Run(r) + if r.Error != nil { + err := r.Error + r.Handlers.Retry.Run(r) + r.Handlers.AfterRetry.Run(r) + if r.Error != nil { + debugLogReqError(r, "Unmarshal Response", false, r.Error) + return r.Error + } + debugLogReqError(r, "Unmarshal Response", true, err) + continue + } + + break + } + + return nil +} + +// AddToUserAgent adds the string to the end of the request's current user agent. +func AddToUserAgent(r *Request, s string) { + curUA := r.HTTPRequest.Header.Get("User-Agent") + if len(curUA) > 0 { + s = curUA + " " + s + } + r.HTTPRequest.Header.Set("User-Agent", s) +} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/request/request_pagination.go b/vendor/github.com/aws/aws-sdk-go/aws/request/request_pagination.go new file mode 100644 index 0000000000..2939ec473f --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/request/request_pagination.go @@ -0,0 +1,104 @@ +package request + +import ( + "reflect" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awsutil" +) + +//type Paginater interface { +// HasNextPage() bool +// NextPage() *Request +// EachPage(fn func(data interface{}, isLastPage bool) (shouldContinue bool)) error +//} + +// HasNextPage returns true if this request has more pages of data available. +func (r *Request) HasNextPage() bool { + return len(r.nextPageTokens()) > 0 +} + +// nextPageTokens returns the tokens to use when asking for the next page of +// data. +func (r *Request) nextPageTokens() []interface{} { + if r.Operation.Paginator == nil { + return nil + } + + if r.Operation.TruncationToken != "" { + tr, _ := awsutil.ValuesAtPath(r.Data, r.Operation.TruncationToken) + if len(tr) == 0 { + return nil + } + + switch v := tr[0].(type) { + case *bool: + if !aws.BoolValue(v) { + return nil + } + case bool: + if v == false { + return nil + } + } + } + + tokens := []interface{}{} + tokenAdded := false + for _, outToken := range r.Operation.OutputTokens { + v, _ := awsutil.ValuesAtPath(r.Data, outToken) + if len(v) > 0 { + tokens = append(tokens, v[0]) + tokenAdded = true + } else { + tokens = append(tokens, nil) + } + } + if !tokenAdded { + return nil + } + + return tokens +} + +// NextPage returns a new Request that can be executed to return the next +// page of result data. Call .Send() on this request to execute it. +func (r *Request) NextPage() *Request { + tokens := r.nextPageTokens() + if len(tokens) == 0 { + return nil + } + + data := reflect.New(reflect.TypeOf(r.Data).Elem()).Interface() + nr := New(r.Config, r.ClientInfo, r.Handlers, r.Retryer, r.Operation, awsutil.CopyOf(r.Params), data) + for i, intok := range nr.Operation.InputTokens { + awsutil.SetValueAtPath(nr.Params, intok, tokens[i]) + } + return nr +} + +// EachPage iterates over each page of a paginated request object. The fn +// parameter should be a function with the following sample signature: +// +// func(page *T, lastPage bool) bool { +// return true // return false to stop iterating +// } +// +// Where "T" is the structure type matching the output structure of the given +// operation. For example, a request object generated by +// DynamoDB.ListTablesRequest() would expect to see dynamodb.ListTablesOutput +// as the structure "T". The lastPage value represents whether the page is +// the last page of data or not. The return value of this function should +// return true to keep iterating or false to stop. +func (r *Request) EachPage(fn func(data interface{}, isLastPage bool) (shouldContinue bool)) error { + for page := r; page != nil; page = page.NextPage() { + if err := page.Send(); err != nil { + return err + } + if getNextPage := fn(page.Data, !page.HasNextPage()); !getNextPage { + return page.Error + } + } + + return nil +} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/request/retryer.go b/vendor/github.com/aws/aws-sdk-go/aws/request/retryer.go new file mode 100644 index 0000000000..ab6fff5ac8 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/request/retryer.go @@ -0,0 +1,82 @@ +package request + +import ( + "time" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awserr" +) + +// Retryer is an interface to control retry logic for a given service. +// The default implementation used by most services is the service.DefaultRetryer +// structure, which contains basic retry logic using exponential backoff. +type Retryer interface { + RetryRules(*Request) time.Duration + ShouldRetry(*Request) bool + MaxRetries() int +} + +// WithRetryer sets a config Retryer value to the given Config returning it +// for chaining. +func WithRetryer(cfg *aws.Config, retryer Retryer) *aws.Config { + cfg.Retryer = retryer + return cfg +} + +// retryableCodes is a collection of service response codes which are retry-able +// without any further action. +var retryableCodes = map[string]struct{}{ + "RequestError": {}, + "RequestTimeout": {}, + "ProvisionedThroughputExceededException": {}, + "Throttling": {}, + "ThrottlingException": {}, + "RequestLimitExceeded": {}, + "RequestThrottled": {}, + "LimitExceededException": {}, // Deleting 10+ DynamoDb tables at once + "TooManyRequestsException": {}, // Lambda functions +} + +// credsExpiredCodes is a collection of error codes which signify the credentials +// need to be refreshed. Expired tokens require refreshing of credentials, and +// resigning before the request can be retried. +var credsExpiredCodes = map[string]struct{}{ + "ExpiredToken": {}, + "ExpiredTokenException": {}, + "RequestExpired": {}, // EC2 Only +} + +func isCodeRetryable(code string) bool { + if _, ok := retryableCodes[code]; ok { + return true + } + + return isCodeExpiredCreds(code) +} + +func isCodeExpiredCreds(code string) bool { + _, ok := credsExpiredCodes[code] + return ok +} + +// IsErrorRetryable returns whether the error is retryable, based on its Code. +// Returns false if the request has no Error set. +func (r *Request) IsErrorRetryable() bool { + if r.Error != nil { + if err, ok := r.Error.(awserr.Error); ok { + return isCodeRetryable(err.Code()) + } + } + return false +} + +// IsErrorExpired returns whether the error code is a credential expiry error. +// Returns false if the request has no Error set. +func (r *Request) IsErrorExpired() bool { + if r.Error != nil { + if err, ok := r.Error.(awserr.Error); ok { + return isCodeExpiredCreds(err.Code()) + } + } + return false +} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/types.go b/vendor/github.com/aws/aws-sdk-go/aws/types.go new file mode 100644 index 0000000000..0f067c57f4 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/types.go @@ -0,0 +1,88 @@ +package aws + +import ( + "io" + "sync" +) + +// ReadSeekCloser wraps a io.Reader returning a ReaderSeekerCloser +func ReadSeekCloser(r io.Reader) ReaderSeekerCloser { + return ReaderSeekerCloser{r} +} + +// ReaderSeekerCloser represents a reader that can also delegate io.Seeker and +// io.Closer interfaces to the underlying object if they are available. +type ReaderSeekerCloser struct { + r io.Reader +} + +// Read reads from the reader up to size of p. The number of bytes read, and +// error if it occurred will be returned. +// +// If the reader is not an io.Reader zero bytes read, and nil error will be returned. +// +// Performs the same functionality as io.Reader Read +func (r ReaderSeekerCloser) Read(p []byte) (int, error) { + switch t := r.r.(type) { + case io.Reader: + return t.Read(p) + } + return 0, nil +} + +// Seek sets the offset for the next Read to offset, interpreted according to +// whence: 0 means relative to the origin of the file, 1 means relative to the +// current offset, and 2 means relative to the end. Seek returns the new offset +// and an error, if any. +// +// If the ReaderSeekerCloser is not an io.Seeker nothing will be done. +func (r ReaderSeekerCloser) Seek(offset int64, whence int) (int64, error) { + switch t := r.r.(type) { + case io.Seeker: + return t.Seek(offset, whence) + } + return int64(0), nil +} + +// Close closes the ReaderSeekerCloser. +// +// If the ReaderSeekerCloser is not an io.Closer nothing will be done. +func (r ReaderSeekerCloser) Close() error { + switch t := r.r.(type) { + case io.Closer: + return t.Close() + } + return nil +} + +// A WriteAtBuffer provides a in memory buffer supporting the io.WriterAt interface +// Can be used with the s3manager.Downloader to download content to a buffer +// in memory. Safe to use concurrently. +type WriteAtBuffer struct { + buf []byte + m sync.Mutex +} + +// WriteAt writes a slice of bytes to a buffer starting at the position provided +// The number of bytes written will be returned, or error. Can overwrite previous +// written slices if the write ats overlap. +func (b *WriteAtBuffer) WriteAt(p []byte, pos int64) (n int, err error) { + b.m.Lock() + defer b.m.Unlock() + + expLen := pos + int64(len(p)) + if int64(len(b.buf)) < expLen { + newBuf := make([]byte, expLen) + copy(newBuf, b.buf) + b.buf = newBuf + } + copy(b.buf[pos:], p) + return len(p), nil +} + +// Bytes returns a slice of bytes written to the buffer. +func (b *WriteAtBuffer) Bytes() []byte { + b.m.Lock() + defer b.m.Unlock() + return b.buf[:len(b.buf):len(b.buf)] +} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/version.go b/vendor/github.com/aws/aws-sdk-go/aws/version.go new file mode 100644 index 0000000000..669da2d695 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/aws/version.go @@ -0,0 +1,8 @@ +// Package aws provides core functionality for making requests to AWS services. +package aws + +// SDKName is the name of this AWS SDK +const SDKName = "aws-sdk-go" + +// SDKVersion is the version of this SDK +const SDKVersion = "1.1.7" diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/build.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/build.go new file mode 100644 index 0000000000..5469edb60b --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/build.go @@ -0,0 +1,257 @@ +// Package rest provides RESTful serialization of AWS requests and responses. +package rest + +import ( + "bytes" + "encoding/base64" + "fmt" + "io" + "net/http" + "net/url" + "path" + "reflect" + "strconv" + "strings" + "time" + + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/request" +) + +// RFC822 returns an RFC822 formatted timestamp for AWS protocols +const RFC822 = "Mon, 2 Jan 2006 15:04:05 GMT" + +// Whether the byte value can be sent without escaping in AWS URLs +var noEscape [256]bool + +var errValueNotSet = fmt.Errorf("value not set") + +func init() { + for i := 0; i < len(noEscape); i++ { + // AWS expects every character except these to be escaped + noEscape[i] = (i >= 'A' && i <= 'Z') || + (i >= 'a' && i <= 'z') || + (i >= '0' && i <= '9') || + i == '-' || + i == '.' || + i == '_' || + i == '~' + } +} + +// BuildHandler is a named request handler for building rest protocol requests +var BuildHandler = request.NamedHandler{Name: "awssdk.rest.Build", Fn: Build} + +// Build builds the REST component of a service request. +func Build(r *request.Request) { + if r.ParamsFilled() { + v := reflect.ValueOf(r.Params).Elem() + buildLocationElements(r, v) + buildBody(r, v) + } +} + +func buildLocationElements(r *request.Request, v reflect.Value) { + query := r.HTTPRequest.URL.Query() + + for i := 0; i < v.NumField(); i++ { + m := v.Field(i) + if n := v.Type().Field(i).Name; n[0:1] == strings.ToLower(n[0:1]) { + continue + } + + if m.IsValid() { + field := v.Type().Field(i) + name := field.Tag.Get("locationName") + if name == "" { + name = field.Name + } + if m.Kind() == reflect.Ptr { + m = m.Elem() + } + if !m.IsValid() { + continue + } + + var err error + switch field.Tag.Get("location") { + case "headers": // header maps + err = buildHeaderMap(&r.HTTPRequest.Header, m, field.Tag.Get("locationName")) + case "header": + err = buildHeader(&r.HTTPRequest.Header, m, name) + case "uri": + err = buildURI(r.HTTPRequest.URL, m, name) + case "querystring": + err = buildQueryString(query, m, name) + } + r.Error = err + } + if r.Error != nil { + return + } + } + + r.HTTPRequest.URL.RawQuery = query.Encode() + updatePath(r.HTTPRequest.URL, r.HTTPRequest.URL.Path) +} + +func buildBody(r *request.Request, v reflect.Value) { + if field, ok := v.Type().FieldByName("_"); ok { + if payloadName := field.Tag.Get("payload"); payloadName != "" { + pfield, _ := v.Type().FieldByName(payloadName) + if ptag := pfield.Tag.Get("type"); ptag != "" && ptag != "structure" { + payload := reflect.Indirect(v.FieldByName(payloadName)) + if payload.IsValid() && payload.Interface() != nil { + switch reader := payload.Interface().(type) { + case io.ReadSeeker: + r.SetReaderBody(reader) + case []byte: + r.SetBufferBody(reader) + case string: + r.SetStringBody(reader) + default: + r.Error = awserr.New("SerializationError", + "failed to encode REST request", + fmt.Errorf("unknown payload type %s", payload.Type())) + } + } + } + } + } +} + +func buildHeader(header *http.Header, v reflect.Value, name string) error { + str, err := convertType(v) + if err == errValueNotSet { + return nil + } else if err != nil { + return awserr.New("SerializationError", "failed to encode REST request", err) + } + + header.Add(name, str) + + return nil +} + +func buildHeaderMap(header *http.Header, v reflect.Value, prefix string) error { + for _, key := range v.MapKeys() { + str, err := convertType(v.MapIndex(key)) + if err == errValueNotSet { + continue + } else if err != nil { + return awserr.New("SerializationError", "failed to encode REST request", err) + + } + + header.Add(prefix+key.String(), str) + } + return nil +} + +func buildURI(u *url.URL, v reflect.Value, name string) error { + value, err := convertType(v) + if err == errValueNotSet { + return nil + } else if err != nil { + return awserr.New("SerializationError", "failed to encode REST request", err) + } + + uri := u.Path + uri = strings.Replace(uri, "{"+name+"}", EscapePath(value, true), -1) + uri = strings.Replace(uri, "{"+name+"+}", EscapePath(value, false), -1) + u.Path = uri + + return nil +} + +func buildQueryString(query url.Values, v reflect.Value, name string) error { + switch value := v.Interface().(type) { + case []*string: + for _, item := range value { + query.Add(name, *item) + } + case map[string]*string: + for key, item := range value { + query.Add(key, *item) + } + case map[string][]*string: + for key, items := range value { + for _, item := range items { + query.Add(key, *item) + } + } + default: + str, err := convertType(v) + if err == errValueNotSet { + return nil + } else if err != nil { + return awserr.New("SerializationError", "failed to encode REST request", err) + } + query.Set(name, str) + } + + return nil +} + +func updatePath(url *url.URL, urlPath string) { + scheme, query := url.Scheme, url.RawQuery + + hasSlash := strings.HasSuffix(urlPath, "/") + + // clean up path + urlPath = path.Clean(urlPath) + if hasSlash && !strings.HasSuffix(urlPath, "/") { + urlPath += "/" + } + + // get formatted URL minus scheme so we can build this into Opaque + url.Scheme, url.Path, url.RawQuery = "", "", "" + s := url.String() + url.Scheme = scheme + url.RawQuery = query + + // build opaque URI + url.Opaque = s + urlPath +} + +// EscapePath escapes part of a URL path in Amazon style +func EscapePath(path string, encodeSep bool) string { + var buf bytes.Buffer + for i := 0; i < len(path); i++ { + c := path[i] + if noEscape[c] || (c == '/' && !encodeSep) { + buf.WriteByte(c) + } else { + buf.WriteByte('%') + buf.WriteString(strings.ToUpper(strconv.FormatUint(uint64(c), 16))) + } + } + return buf.String() +} + +func convertType(v reflect.Value) (string, error) { + v = reflect.Indirect(v) + if !v.IsValid() { + return "", errValueNotSet + } + + var str string + switch value := v.Interface().(type) { + case string: + str = value + case []byte: + str = base64.StdEncoding.EncodeToString(value) + case bool: + str = strconv.FormatBool(value) + case int64: + str = strconv.FormatInt(value, 10) + case float64: + str = strconv.FormatFloat(value, 'f', -1, 64) + case time.Time: + str = value.UTC().Format(RFC822) + default: + err := fmt.Errorf("Unsupported value for param %v (%s)", v.Interface(), v.Type()) + return "", err + } + return str, nil +} diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/payload.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/payload.go new file mode 100644 index 0000000000..4366de2e1e --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/payload.go @@ -0,0 +1,45 @@ +package rest + +import "reflect" + +// PayloadMember returns the payload field member of i if there is one, or nil. +func PayloadMember(i interface{}) interface{} { + if i == nil { + return nil + } + + v := reflect.ValueOf(i).Elem() + if !v.IsValid() { + return nil + } + if field, ok := v.Type().FieldByName("_"); ok { + if payloadName := field.Tag.Get("payload"); payloadName != "" { + field, _ := v.Type().FieldByName(payloadName) + if field.Tag.Get("type") != "structure" { + return nil + } + + payload := v.FieldByName(payloadName) + if payload.IsValid() || (payload.Kind() == reflect.Ptr && !payload.IsNil()) { + return payload.Interface() + } + } + } + return nil +} + +// PayloadType returns the type of a payload field member of i if there is one, or "". +func PayloadType(i interface{}) string { + v := reflect.Indirect(reflect.ValueOf(i)) + if !v.IsValid() { + return "" + } + if field, ok := v.Type().FieldByName("_"); ok { + if payloadName := field.Tag.Get("payload"); payloadName != "" { + if member, ok := v.Type().FieldByName(payloadName); ok { + return member.Tag.Get("type") + } + } + } + return "" +} diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go new file mode 100644 index 0000000000..ba46f5bc9f --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go @@ -0,0 +1,193 @@ +package rest + +import ( + "encoding/base64" + "fmt" + "io/ioutil" + "net/http" + "reflect" + "strconv" + "strings" + "time" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/request" +) + +// UnmarshalHandler is a named request handler for unmarshaling rest protocol requests +var UnmarshalHandler = request.NamedHandler{Name: "awssdk.rest.Unmarshal", Fn: Unmarshal} + +// UnmarshalMetaHandler is a named request handler for unmarshaling rest protocol request metadata +var UnmarshalMetaHandler = request.NamedHandler{Name: "awssdk.rest.UnmarshalMeta", Fn: UnmarshalMeta} + +// Unmarshal unmarshals the REST component of a response in a REST service. +func Unmarshal(r *request.Request) { + if r.DataFilled() { + v := reflect.Indirect(reflect.ValueOf(r.Data)) + unmarshalBody(r, v) + } +} + +// UnmarshalMeta unmarshals the REST metadata of a response in a REST service +func UnmarshalMeta(r *request.Request) { + r.RequestID = r.HTTPResponse.Header.Get("X-Amzn-Requestid") + if r.RequestID == "" { + // Alternative version of request id in the header + r.RequestID = r.HTTPResponse.Header.Get("X-Amz-Request-Id") + } + if r.DataFilled() { + v := reflect.Indirect(reflect.ValueOf(r.Data)) + unmarshalLocationElements(r, v) + } +} + +func unmarshalBody(r *request.Request, v reflect.Value) { + if field, ok := v.Type().FieldByName("_"); ok { + if payloadName := field.Tag.Get("payload"); payloadName != "" { + pfield, _ := v.Type().FieldByName(payloadName) + if ptag := pfield.Tag.Get("type"); ptag != "" && ptag != "structure" { + payload := v.FieldByName(payloadName) + if payload.IsValid() { + switch payload.Interface().(type) { + case []byte: + b, err := ioutil.ReadAll(r.HTTPResponse.Body) + if err != nil { + r.Error = awserr.New("SerializationError", "failed to decode REST response", err) + } else { + payload.Set(reflect.ValueOf(b)) + } + case *string: + b, err := ioutil.ReadAll(r.HTTPResponse.Body) + if err != nil { + r.Error = awserr.New("SerializationError", "failed to decode REST response", err) + } else { + str := string(b) + payload.Set(reflect.ValueOf(&str)) + } + default: + switch payload.Type().String() { + case "io.ReadSeeker": + payload.Set(reflect.ValueOf(aws.ReadSeekCloser(r.HTTPResponse.Body))) + case "aws.ReadSeekCloser", "io.ReadCloser": + payload.Set(reflect.ValueOf(r.HTTPResponse.Body)) + default: + r.Error = awserr.New("SerializationError", + "failed to decode REST response", + fmt.Errorf("unknown payload type %s", payload.Type())) + } + } + } + } + } + } +} + +func unmarshalLocationElements(r *request.Request, v reflect.Value) { + for i := 0; i < v.NumField(); i++ { + m, field := v.Field(i), v.Type().Field(i) + if n := field.Name; n[0:1] == strings.ToLower(n[0:1]) { + continue + } + + if m.IsValid() { + name := field.Tag.Get("locationName") + if name == "" { + name = field.Name + } + + switch field.Tag.Get("location") { + case "statusCode": + unmarshalStatusCode(m, r.HTTPResponse.StatusCode) + case "header": + err := unmarshalHeader(m, r.HTTPResponse.Header.Get(name)) + if err != nil { + r.Error = awserr.New("SerializationError", "failed to decode REST response", err) + break + } + case "headers": + prefix := field.Tag.Get("locationName") + err := unmarshalHeaderMap(m, r.HTTPResponse.Header, prefix) + if err != nil { + r.Error = awserr.New("SerializationError", "failed to decode REST response", err) + break + } + } + } + if r.Error != nil { + return + } + } +} + +func unmarshalStatusCode(v reflect.Value, statusCode int) { + if !v.IsValid() { + return + } + + switch v.Interface().(type) { + case *int64: + s := int64(statusCode) + v.Set(reflect.ValueOf(&s)) + } +} + +func unmarshalHeaderMap(r reflect.Value, headers http.Header, prefix string) error { + switch r.Interface().(type) { + case map[string]*string: // we only support string map value types + out := map[string]*string{} + for k, v := range headers { + k = http.CanonicalHeaderKey(k) + if strings.HasPrefix(strings.ToLower(k), strings.ToLower(prefix)) { + out[k[len(prefix):]] = &v[0] + } + } + r.Set(reflect.ValueOf(out)) + } + return nil +} + +func unmarshalHeader(v reflect.Value, header string) error { + if !v.IsValid() || (header == "" && v.Elem().Kind() != reflect.String) { + return nil + } + + switch v.Interface().(type) { + case *string: + v.Set(reflect.ValueOf(&header)) + case []byte: + b, err := base64.StdEncoding.DecodeString(header) + if err != nil { + return err + } + v.Set(reflect.ValueOf(&b)) + case *bool: + b, err := strconv.ParseBool(header) + if err != nil { + return err + } + v.Set(reflect.ValueOf(&b)) + case *int64: + i, err := strconv.ParseInt(header, 10, 64) + if err != nil { + return err + } + v.Set(reflect.ValueOf(&i)) + case *float64: + f, err := strconv.ParseFloat(header, 64) + if err != nil { + return err + } + v.Set(reflect.ValueOf(&f)) + case *time.Time: + t, err := time.Parse(RFC822, header) + if err != nil { + return err + } + v.Set(reflect.ValueOf(&t)) + default: + err := fmt.Errorf("Unsupported value for param %v (%s)", v.Interface(), v.Type()) + return err + } + return nil +} diff --git a/vendor/github.com/aws/aws-sdk-go/private/signer/v4/header_rules.go b/vendor/github.com/aws/aws-sdk-go/private/signer/v4/header_rules.go new file mode 100644 index 0000000000..244c86da05 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/private/signer/v4/header_rules.go @@ -0,0 +1,82 @@ +package v4 + +import ( + "net/http" + "strings" +) + +// validator houses a set of rule needed for validation of a +// string value +type rules []rule + +// rule interface allows for more flexible rules and just simply +// checks whether or not a value adheres to that rule +type rule interface { + IsValid(value string) bool +} + +// IsValid will iterate through all rules and see if any rules +// apply to the value and supports nested rules +func (r rules) IsValid(value string) bool { + for _, rule := range r { + if rule.IsValid(value) { + return true + } + } + return false +} + +// mapRule generic rule for maps +type mapRule map[string]struct{} + +// IsValid for the map rule satisfies whether it exists in the map +func (m mapRule) IsValid(value string) bool { + _, ok := m[value] + return ok +} + +// whitelist is a generic rule for whitelisting +type whitelist struct { + rule +} + +// IsValid for whitelist checks if the value is within the whitelist +func (w whitelist) IsValid(value string) bool { + return w.rule.IsValid(value) +} + +// blacklist is a generic rule for blacklisting +type blacklist struct { + rule +} + +// IsValid for whitelist checks if the value is within the whitelist +func (b blacklist) IsValid(value string) bool { + return !b.rule.IsValid(value) +} + +type patterns []string + +// IsValid for patterns checks each pattern and returns if a match has +// been found +func (p patterns) IsValid(value string) bool { + for _, pattern := range p { + if strings.HasPrefix(http.CanonicalHeaderKey(value), pattern) { + return true + } + } + return false +} + +// inclusiveRules rules allow for rules to depend on one another +type inclusiveRules []rule + +// IsValid will return true if all rules are true +func (r inclusiveRules) IsValid(value string) bool { + for _, rule := range r { + if !rule.IsValid(value) { + return false + } + } + return true +} diff --git a/vendor/github.com/aws/aws-sdk-go/private/signer/v4/v4.go b/vendor/github.com/aws/aws-sdk-go/private/signer/v4/v4.go new file mode 100644 index 0000000000..14b0c66161 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/private/signer/v4/v4.go @@ -0,0 +1,438 @@ +// Package v4 implements signing for AWS V4 signer +package v4 + +import ( + "crypto/hmac" + "crypto/sha256" + "encoding/hex" + "fmt" + "io" + "net/http" + "net/url" + "sort" + "strconv" + "strings" + "time" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/credentials" + "github.com/aws/aws-sdk-go/aws/request" + "github.com/aws/aws-sdk-go/private/protocol/rest" +) + +const ( + authHeaderPrefix = "AWS4-HMAC-SHA256" + timeFormat = "20060102T150405Z" + shortTimeFormat = "20060102" +) + +var ignoredHeaders = rules{ + blacklist{ + mapRule{ + "Content-Length": struct{}{}, + "User-Agent": struct{}{}, + }, + }, +} + +// requiredSignedHeaders is a whitelist for build canonical headers. +var requiredSignedHeaders = rules{ + whitelist{ + mapRule{ + "Cache-Control": struct{}{}, + "Content-Disposition": struct{}{}, + "Content-Encoding": struct{}{}, + "Content-Language": struct{}{}, + "Content-Md5": struct{}{}, + "Content-Type": struct{}{}, + "Expires": struct{}{}, + "If-Match": struct{}{}, + "If-Modified-Since": struct{}{}, + "If-None-Match": struct{}{}, + "If-Unmodified-Since": struct{}{}, + "Range": struct{}{}, + "X-Amz-Acl": struct{}{}, + "X-Amz-Copy-Source": struct{}{}, + "X-Amz-Copy-Source-If-Match": struct{}{}, + "X-Amz-Copy-Source-If-Modified-Since": struct{}{}, + "X-Amz-Copy-Source-If-None-Match": struct{}{}, + "X-Amz-Copy-Source-If-Unmodified-Since": struct{}{}, + "X-Amz-Copy-Source-Range": struct{}{}, + "X-Amz-Copy-Source-Server-Side-Encryption-Customer-Algorithm": struct{}{}, + "X-Amz-Copy-Source-Server-Side-Encryption-Customer-Key": struct{}{}, + "X-Amz-Copy-Source-Server-Side-Encryption-Customer-Key-Md5": struct{}{}, + "X-Amz-Grant-Full-control": struct{}{}, + "X-Amz-Grant-Read": struct{}{}, + "X-Amz-Grant-Read-Acp": struct{}{}, + "X-Amz-Grant-Write": struct{}{}, + "X-Amz-Grant-Write-Acp": struct{}{}, + "X-Amz-Metadata-Directive": struct{}{}, + "X-Amz-Mfa": struct{}{}, + "X-Amz-Request-Payer": struct{}{}, + "X-Amz-Server-Side-Encryption": struct{}{}, + "X-Amz-Server-Side-Encryption-Aws-Kms-Key-Id": struct{}{}, + "X-Amz-Server-Side-Encryption-Customer-Algorithm": struct{}{}, + "X-Amz-Server-Side-Encryption-Customer-Key": struct{}{}, + "X-Amz-Server-Side-Encryption-Customer-Key-Md5": struct{}{}, + "X-Amz-Storage-Class": struct{}{}, + "X-Amz-Website-Redirect-Location": struct{}{}, + }, + }, + patterns{"X-Amz-Meta-"}, +} + +// allowedHoisting is a whitelist for build query headers. The boolean value +// represents whether or not it is a pattern. +var allowedQueryHoisting = inclusiveRules{ + blacklist{requiredSignedHeaders}, + patterns{"X-Amz-"}, +} + +type signer struct { + Request *http.Request + Time time.Time + ExpireTime time.Duration + ServiceName string + Region string + CredValues credentials.Value + Credentials *credentials.Credentials + Query url.Values + Body io.ReadSeeker + Debug aws.LogLevelType + Logger aws.Logger + + isPresign bool + formattedTime string + formattedShortTime string + + signedHeaders string + canonicalHeaders string + canonicalString string + credentialString string + stringToSign string + signature string + authorization string + notHoist bool + signedHeaderVals http.Header +} + +// Sign requests with signature version 4. +// +// Will sign the requests with the service config's Credentials object +// Signing is skipped if the credentials is the credentials.AnonymousCredentials +// object. +func Sign(req *request.Request) { + // If the request does not need to be signed ignore the signing of the + // request if the AnonymousCredentials object is used. + if req.Config.Credentials == credentials.AnonymousCredentials { + return + } + + region := req.ClientInfo.SigningRegion + if region == "" { + region = aws.StringValue(req.Config.Region) + } + + name := req.ClientInfo.SigningName + if name == "" { + name = req.ClientInfo.ServiceName + } + + s := signer{ + Request: req.HTTPRequest, + Time: req.Time, + ExpireTime: req.ExpireTime, + Query: req.HTTPRequest.URL.Query(), + Body: req.Body, + ServiceName: name, + Region: region, + Credentials: req.Config.Credentials, + Debug: req.Config.LogLevel.Value(), + Logger: req.Config.Logger, + notHoist: req.NotHoist, + } + + req.Error = s.sign() + req.SignedHeaderVals = s.signedHeaderVals +} + +func (v4 *signer) sign() error { + if v4.ExpireTime != 0 { + v4.isPresign = true + } + + if v4.isRequestSigned() { + if !v4.Credentials.IsExpired() { + // If the request is already signed, and the credentials have not + // expired yet ignore the signing request. + return nil + } + + // The credentials have expired for this request. The current signing + // is invalid, and needs to be request because the request will fail. + if v4.isPresign { + v4.removePresign() + // Update the request's query string to ensure the values stays in + // sync in the case retrieving the new credentials fails. + v4.Request.URL.RawQuery = v4.Query.Encode() + } + } + + var err error + v4.CredValues, err = v4.Credentials.Get() + if err != nil { + return err + } + + if v4.isPresign { + v4.Query.Set("X-Amz-Algorithm", authHeaderPrefix) + if v4.CredValues.SessionToken != "" { + v4.Query.Set("X-Amz-Security-Token", v4.CredValues.SessionToken) + } else { + v4.Query.Del("X-Amz-Security-Token") + } + } else if v4.CredValues.SessionToken != "" { + v4.Request.Header.Set("X-Amz-Security-Token", v4.CredValues.SessionToken) + } + + v4.build() + + if v4.Debug.Matches(aws.LogDebugWithSigning) { + v4.logSigningInfo() + } + + return nil +} + +const logSignInfoMsg = `DEBUG: Request Signiture: +---[ CANONICAL STRING ]----------------------------- +%s +---[ STRING TO SIGN ]-------------------------------- +%s%s +-----------------------------------------------------` +const logSignedURLMsg = ` +---[ SIGNED URL ]------------------------------------ +%s` + +func (v4 *signer) logSigningInfo() { + signedURLMsg := "" + if v4.isPresign { + signedURLMsg = fmt.Sprintf(logSignedURLMsg, v4.Request.URL.String()) + } + msg := fmt.Sprintf(logSignInfoMsg, v4.canonicalString, v4.stringToSign, signedURLMsg) + v4.Logger.Log(msg) +} + +func (v4 *signer) build() { + + v4.buildTime() // no depends + v4.buildCredentialString() // no depends + + unsignedHeaders := v4.Request.Header + if v4.isPresign { + if !v4.notHoist { + urlValues := url.Values{} + urlValues, unsignedHeaders = buildQuery(allowedQueryHoisting, unsignedHeaders) // no depends + for k := range urlValues { + v4.Query[k] = urlValues[k] + } + } + } + + v4.buildCanonicalHeaders(ignoredHeaders, unsignedHeaders) + v4.buildCanonicalString() // depends on canon headers / signed headers + v4.buildStringToSign() // depends on canon string + v4.buildSignature() // depends on string to sign + + if v4.isPresign { + v4.Request.URL.RawQuery += "&X-Amz-Signature=" + v4.signature + } else { + parts := []string{ + authHeaderPrefix + " Credential=" + v4.CredValues.AccessKeyID + "/" + v4.credentialString, + "SignedHeaders=" + v4.signedHeaders, + "Signature=" + v4.signature, + } + v4.Request.Header.Set("Authorization", strings.Join(parts, ", ")) + } +} + +func (v4 *signer) buildTime() { + v4.formattedTime = v4.Time.UTC().Format(timeFormat) + v4.formattedShortTime = v4.Time.UTC().Format(shortTimeFormat) + + if v4.isPresign { + duration := int64(v4.ExpireTime / time.Second) + v4.Query.Set("X-Amz-Date", v4.formattedTime) + v4.Query.Set("X-Amz-Expires", strconv.FormatInt(duration, 10)) + } else { + v4.Request.Header.Set("X-Amz-Date", v4.formattedTime) + } +} + +func (v4 *signer) buildCredentialString() { + v4.credentialString = strings.Join([]string{ + v4.formattedShortTime, + v4.Region, + v4.ServiceName, + "aws4_request", + }, "/") + + if v4.isPresign { + v4.Query.Set("X-Amz-Credential", v4.CredValues.AccessKeyID+"/"+v4.credentialString) + } +} + +func buildQuery(r rule, header http.Header) (url.Values, http.Header) { + query := url.Values{} + unsignedHeaders := http.Header{} + for k, h := range header { + if r.IsValid(k) { + query[k] = h + } else { + unsignedHeaders[k] = h + } + } + + return query, unsignedHeaders +} +func (v4 *signer) buildCanonicalHeaders(r rule, header http.Header) { + var headers []string + headers = append(headers, "host") + for k, v := range header { + canonicalKey := http.CanonicalHeaderKey(k) + if !r.IsValid(canonicalKey) { + continue // ignored header + } + + lowerCaseKey := strings.ToLower(k) + headers = append(headers, lowerCaseKey) + + if v4.signedHeaderVals == nil { + v4.signedHeaderVals = make(http.Header) + } + v4.signedHeaderVals[lowerCaseKey] = v + } + sort.Strings(headers) + + v4.signedHeaders = strings.Join(headers, ";") + + if v4.isPresign { + v4.Query.Set("X-Amz-SignedHeaders", v4.signedHeaders) + } + + headerValues := make([]string, len(headers)) + for i, k := range headers { + if k == "host" { + headerValues[i] = "host:" + v4.Request.URL.Host + } else { + headerValues[i] = k + ":" + + strings.Join(v4.Request.Header[http.CanonicalHeaderKey(k)], ",") + } + } + + v4.canonicalHeaders = strings.Join(headerValues, "\n") +} + +func (v4 *signer) buildCanonicalString() { + v4.Request.URL.RawQuery = strings.Replace(v4.Query.Encode(), "+", "%20", -1) + uri := v4.Request.URL.Opaque + if uri != "" { + uri = "/" + strings.Join(strings.Split(uri, "/")[3:], "/") + } else { + uri = v4.Request.URL.Path + } + if uri == "" { + uri = "/" + } + + if v4.ServiceName != "s3" { + uri = rest.EscapePath(uri, false) + } + + v4.canonicalString = strings.Join([]string{ + v4.Request.Method, + uri, + v4.Request.URL.RawQuery, + v4.canonicalHeaders + "\n", + v4.signedHeaders, + v4.bodyDigest(), + }, "\n") +} + +func (v4 *signer) buildStringToSign() { + v4.stringToSign = strings.Join([]string{ + authHeaderPrefix, + v4.formattedTime, + v4.credentialString, + hex.EncodeToString(makeSha256([]byte(v4.canonicalString))), + }, "\n") +} + +func (v4 *signer) buildSignature() { + secret := v4.CredValues.SecretAccessKey + date := makeHmac([]byte("AWS4"+secret), []byte(v4.formattedShortTime)) + region := makeHmac(date, []byte(v4.Region)) + service := makeHmac(region, []byte(v4.ServiceName)) + credentials := makeHmac(service, []byte("aws4_request")) + signature := makeHmac(credentials, []byte(v4.stringToSign)) + v4.signature = hex.EncodeToString(signature) +} + +func (v4 *signer) bodyDigest() string { + hash := v4.Request.Header.Get("X-Amz-Content-Sha256") + if hash == "" { + if v4.isPresign && v4.ServiceName == "s3" { + hash = "UNSIGNED-PAYLOAD" + } else if v4.Body == nil { + hash = hex.EncodeToString(makeSha256([]byte{})) + } else { + hash = hex.EncodeToString(makeSha256Reader(v4.Body)) + } + v4.Request.Header.Add("X-Amz-Content-Sha256", hash) + } + return hash +} + +// isRequestSigned returns if the request is currently signed or presigned +func (v4 *signer) isRequestSigned() bool { + if v4.isPresign && v4.Query.Get("X-Amz-Signature") != "" { + return true + } + if v4.Request.Header.Get("Authorization") != "" { + return true + } + + return false +} + +// unsign removes signing flags for both signed and presigned requests. +func (v4 *signer) removePresign() { + v4.Query.Del("X-Amz-Algorithm") + v4.Query.Del("X-Amz-Signature") + v4.Query.Del("X-Amz-Security-Token") + v4.Query.Del("X-Amz-Date") + v4.Query.Del("X-Amz-Expires") + v4.Query.Del("X-Amz-Credential") + v4.Query.Del("X-Amz-SignedHeaders") +} + +func makeHmac(key []byte, data []byte) []byte { + hash := hmac.New(sha256.New, key) + hash.Write(data) + return hash.Sum(nil) +} + +func makeSha256(data []byte) []byte { + hash := sha256.New() + hash.Write(data) + return hash.Sum(nil) +} + +func makeSha256Reader(reader io.ReadSeeker) []byte { + hash := sha256.New() + start, _ := reader.Seek(0, 1) + defer reader.Seek(start, 0) + + io.Copy(hash, reader) + return hash.Sum(nil) +} diff --git a/vendor/github.com/aws/aws-sdk-go/sdk.go b/vendor/github.com/aws/aws-sdk-go/sdk.go new file mode 100644 index 0000000000..afa465a225 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/sdk.go @@ -0,0 +1,7 @@ +// Package sdk is the official AWS SDK for the Go programming language. +// +// See our Developer Guide for information for on getting started and using +// the SDK. +// +// https://github.com/aws/aws-sdk-go/wiki +package sdk diff --git a/vendor/github.com/camlistore/go4/LICENSE b/vendor/github.com/camlistore/go4/LICENSE new file mode 100644 index 0000000000..8f71f43fee --- /dev/null +++ b/vendor/github.com/camlistore/go4/LICENSE @@ -0,0 +1,202 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor 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, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/vendor/github.com/camlistore/go4/lock/lock.go b/vendor/github.com/camlistore/go4/lock/lock.go new file mode 100644 index 0000000000..a9fb802de6 --- /dev/null +++ b/vendor/github.com/camlistore/go4/lock/lock.go @@ -0,0 +1,186 @@ +/* +Copyright 2013 The Go Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package lock is a file locking library. +package lock + +import ( + "encoding/json" + "fmt" + "io" + "os" + "path/filepath" + "sync" +) + +// Lock locks the given file, creating the file if necessary. If the +// file already exists, it must have zero size or an error is returned. +// The lock is an exclusive lock (a write lock), but locked files +// should neither be read from nor written to. Such files should have +// zero size and only exist to co-ordinate ownership across processes. +// +// A nil Closer is returned if an error occurred. Otherwise, close that +// Closer to release the lock. +// +// On Linux, FreeBSD and OSX, a lock has the same semantics as fcntl(2)'s +// advisory locks. In particular, closing any other file descriptor for the +// same file will release the lock prematurely. +// +// Attempting to lock a file that is already locked by the current process +// has undefined behavior. +// +// On other operating systems, lock will fallback to using the presence and +// content of a file named name + '.lock' to implement locking behavior. +func Lock(name string) (io.Closer, error) { + abs, err := filepath.Abs(name) + if err != nil { + return nil, err + } + lockmu.Lock() + defer lockmu.Unlock() + if locked[abs] { + return nil, fmt.Errorf("file %q already locked", abs) + } + + c, err := lockFn(abs) + if err != nil { + return nil, fmt.Errorf("cannot acquire lock: %v", err) + } + locked[abs] = true + return c, nil +} + +var lockFn = lockPortable + +// lockPortable is a portable version not using fcntl. Doesn't handle crashes as gracefully, +// since it can leave stale lock files. +func lockPortable(name string) (io.Closer, error) { + fi, err := os.Stat(name) + if err == nil && fi.Size() > 0 { + st := portableLockStatus(name) + switch st { + case statusLocked: + return nil, fmt.Errorf("file %q already locked", name) + case statusStale: + os.Remove(name) + case statusInvalid: + return nil, fmt.Errorf("can't Lock file %q: has invalid contents", name) + } + } + f, err := os.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_EXCL, 0666) + if err != nil { + return nil, fmt.Errorf("failed to create lock file %s %v", name, err) + } + if err := json.NewEncoder(f).Encode(&pidLockMeta{OwnerPID: os.Getpid()}); err != nil { + return nil, fmt.Errorf("cannot write owner pid: %v", err) + } + return &unlocker{ + f: f, + abs: name, + portable: true, + }, nil +} + +type lockStatus int + +const ( + statusInvalid lockStatus = iota + statusLocked + statusUnlocked + statusStale +) + +type pidLockMeta struct { + OwnerPID int +} + +func portableLockStatus(path string) lockStatus { + f, err := os.Open(path) + if err != nil { + return statusUnlocked + } + defer f.Close() + var meta pidLockMeta + if json.NewDecoder(f).Decode(&meta) != nil { + return statusInvalid + } + if meta.OwnerPID == 0 { + return statusInvalid + } + p, err := os.FindProcess(meta.OwnerPID) + if err != nil { + // e.g. on Windows + return statusStale + } + // On unix, os.FindProcess always is true, so we have to send + // it a signal to see if it's alive. + if signalZero != nil { + if p.Signal(signalZero) != nil { + return statusStale + } + } + return statusLocked +} + +var signalZero os.Signal // nil or set by lock_sigzero.go + +var ( + lockmu sync.Mutex + locked = map[string]bool{} // abs path -> true +) + +type unlocker struct { + portable bool + f *os.File + abs string + // once guards the close method call. + once sync.Once + // err holds the error returned by Close. + err error +} + +func (u *unlocker) Close() error { + u.once.Do(u.close) + return u.err +} + +func (u *unlocker) close() { + lockmu.Lock() + defer lockmu.Unlock() + delete(locked, u.abs) + + if u.portable { + // In the portable lock implementation, it's + // important to close before removing because + // Windows won't allow us to remove an open + // file. + if err := u.f.Close(); err != nil { + u.err = err + } + if err := os.Remove(u.abs); err != nil { + // Note that if both Close and Remove fail, + // we care more about the latter than the former + // so we'll return that error. + u.err = err + } + return + } + // In other implementatioons, it's nice for us to clean up. + // If we do do this, though, it needs to be before the + // u.f.Close below. + os.Remove(u.abs) + u.err = u.f.Close() +} diff --git a/vendor/github.com/camlistore/go4/lock/lock_appengine.go b/vendor/github.com/camlistore/go4/lock/lock_appengine.go new file mode 100644 index 0000000000..ab4cad6ab6 --- /dev/null +++ b/vendor/github.com/camlistore/go4/lock/lock_appengine.go @@ -0,0 +1,32 @@ +// +build appengine + +/* +Copyright 2013 The Go Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package lock + +import ( + "errors" + "io" +) + +func init() { + lockFn = lockAppEngine +} + +func lockAppEngine(name string) (io.Closer, error) { + return nil, errors.New("Lock not available on App Engine") +} diff --git a/vendor/github.com/camlistore/go4/lock/lock_darwin_amd64.go b/vendor/github.com/camlistore/go4/lock/lock_darwin_amd64.go new file mode 100644 index 0000000000..35f5787bae --- /dev/null +++ b/vendor/github.com/camlistore/go4/lock/lock_darwin_amd64.go @@ -0,0 +1,67 @@ +// +build darwin,amd64 +// +build !appengine + +/* +Copyright 2013 The Go Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package lock + +import ( + "fmt" + "io" + "os" + "syscall" + "unsafe" +) + +func init() { + lockFn = lockFcntl +} + +func lockFcntl(name string) (io.Closer, error) { + fi, err := os.Stat(name) + if err == nil && fi.Size() > 0 { + return nil, fmt.Errorf("can't Lock file %q: has non-zero size", name) + } + + f, err := os.Create(name) + if err != nil { + return nil, fmt.Errorf("Lock Create of %s failed: %v", name, err) + } + + // This type matches C's "struct flock" defined in /usr/include/sys/fcntl.h. + // TODO: move this into the standard syscall package. + k := struct { + Start uint64 // sizeof(off_t): 8 + Len uint64 // sizeof(off_t): 8 + Pid uint32 // sizeof(pid_t): 4 + Type uint16 // sizeof(short): 2 + Whence uint16 // sizeof(short): 2 + }{ + Type: syscall.F_WRLCK, + Whence: uint16(os.SEEK_SET), + Start: 0, + Len: 0, // 0 means to lock the entire file. + Pid: uint32(os.Getpid()), + } + + _, _, errno := syscall.Syscall(syscall.SYS_FCNTL, f.Fd(), uintptr(syscall.F_SETLK), uintptr(unsafe.Pointer(&k))) + if errno != 0 { + f.Close() + return nil, errno + } + return &unlocker{f: f, abs: name}, nil +} diff --git a/vendor/github.com/camlistore/go4/lock/lock_freebsd.go b/vendor/github.com/camlistore/go4/lock/lock_freebsd.go new file mode 100644 index 0000000000..ee2767a0a6 --- /dev/null +++ b/vendor/github.com/camlistore/go4/lock/lock_freebsd.go @@ -0,0 +1,66 @@ +/* +Copyright 2013 The Go Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package lock + +import ( + "fmt" + "io" + "os" + "syscall" + "unsafe" +) + +func init() { + lockFn = lockFcntl +} + +func lockFcntl(name string) (io.Closer, error) { + fi, err := os.Stat(name) + if err == nil && fi.Size() > 0 { + return nil, fmt.Errorf("can't Lock file %q: has non-zero size", name) + } + + f, err := os.Create(name) + if err != nil { + return nil, err + } + + // This type matches C's "struct flock" defined in /usr/include/fcntl.h. + // TODO: move this into the standard syscall package. + k := struct { + Start int64 /* off_t starting offset */ + Len int64 /* off_t len = 0 means until end of file */ + Pid int32 /* pid_t lock owner */ + Type int16 /* short lock type: read/write, etc. */ + Whence int16 /* short type of l_start */ + Sysid int32 /* int remote system id or zero for local */ + }{ + Start: 0, + Len: 0, // 0 means to lock the entire file. + Pid: int32(os.Getpid()), + Type: syscall.F_WRLCK, + Whence: int16(os.SEEK_SET), + Sysid: 0, + } + + _, _, errno := syscall.Syscall(syscall.SYS_FCNTL, f.Fd(), uintptr(syscall.F_SETLK), uintptr(unsafe.Pointer(&k))) + if errno != 0 { + f.Close() + return nil, errno + } + return &unlocker{f: f, abs: name}, nil +} diff --git a/vendor/github.com/camlistore/go4/lock/lock_linux_amd64.go b/vendor/github.com/camlistore/go4/lock/lock_linux_amd64.go new file mode 100644 index 0000000000..08b3aae921 --- /dev/null +++ b/vendor/github.com/camlistore/go4/lock/lock_linux_amd64.go @@ -0,0 +1,67 @@ +// +build linux,amd64 +// +build !appengine + +/* +Copyright 2013 The Go Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package lock + +import ( + "fmt" + "io" + "os" + "syscall" + "unsafe" +) + +func init() { + lockFn = lockFcntl +} + +func lockFcntl(name string) (io.Closer, error) { + fi, err := os.Stat(name) + if err == nil && fi.Size() > 0 { + return nil, fmt.Errorf("can't Lock file %q: has non-zero size", name) + } + + f, err := os.Create(name) + if err != nil { + return nil, err + } + + // This type matches C's "struct flock" defined in /usr/include/bits/fcntl.h. + // TODO: move this into the standard syscall package. + k := struct { + Type uint32 + Whence uint32 + Start uint64 + Len uint64 + Pid uint32 + }{ + Type: syscall.F_WRLCK, + Whence: uint32(os.SEEK_SET), + Start: 0, + Len: 0, // 0 means to lock the entire file. + Pid: uint32(os.Getpid()), + } + + _, _, errno := syscall.Syscall(syscall.SYS_FCNTL, f.Fd(), uintptr(syscall.F_SETLK), uintptr(unsafe.Pointer(&k))) + if errno != 0 { + f.Close() + return nil, errno + } + return &unlocker{f: f, abs: name}, nil +} diff --git a/vendor/github.com/camlistore/go4/lock/lock_linux_arm.go b/vendor/github.com/camlistore/go4/lock/lock_linux_arm.go new file mode 100644 index 0000000000..ebf87bd3e7 --- /dev/null +++ b/vendor/github.com/camlistore/go4/lock/lock_linux_arm.go @@ -0,0 +1,68 @@ +// +build linux,arm +// +build !appengine + +/* +Copyright 2013 The Go Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package lock + +import ( + "fmt" + "io" + "os" + "syscall" + "unsafe" +) + +func init() { + lockFn = lockFcntl +} + +func lockFcntl(name string) (io.Closer, error) { + fi, err := os.Stat(name) + if err == nil && fi.Size() > 0 { + return nil, fmt.Errorf("can't Lock file %q: has non-zero size", name) + } + + f, err := os.Create(name) + if err != nil { + return nil, err + } + + // This type matches C's "struct flock" defined in /usr/include/bits/fcntl.h. + // TODO: move this into the standard syscall package. + k := struct { + Type uint16 + Whence uint16 + Start uint32 + Len uint32 + Pid uint32 + }{ + Type: syscall.F_WRLCK, + Whence: uint16(os.SEEK_SET), + Start: 0, + Len: 0, // 0 means to lock the entire file. + Pid: uint32(os.Getpid()), + } + + const F_SETLK = 6 // actual value. syscall package is wrong: golang.org/issue/7059 + _, _, errno := syscall.Syscall(syscall.SYS_FCNTL, f.Fd(), uintptr(F_SETLK), uintptr(unsafe.Pointer(&k))) + if errno != 0 { + f.Close() + return nil, errno + } + return &unlocker{f: f, abs: name}, nil +} diff --git a/vendor/github.com/camlistore/go4/lock/lock_plan9.go b/vendor/github.com/camlistore/go4/lock/lock_plan9.go new file mode 100644 index 0000000000..d841c27d70 --- /dev/null +++ b/vendor/github.com/camlistore/go4/lock/lock_plan9.go @@ -0,0 +1,41 @@ +/* +Copyright 2013 The Go Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package lock + +import ( + "fmt" + "io" + "os" +) + +func init() { + lockFn = lockPlan9 +} + +func lockPlan9(name string) (io.Closer, error) { + fi, err := os.Stat(name) + if err == nil && fi.Size() > 0 { + return nil, fmt.Errorf("can't Lock file %q: has non-zero size", name) + } + + f, err := os.OpenFile(name, os.O_RDWR|os.O_CREATE, os.ModeExclusive|0644) + if err != nil { + return nil, fmt.Errorf("Lock Create of %s failed: %v", name, err) + } + + return &unlocker{f: f, abs: name}, nil +} diff --git a/vendor/github.com/camlistore/go4/lock/lock_sigzero.go b/vendor/github.com/camlistore/go4/lock/lock_sigzero.go new file mode 100644 index 0000000000..fd3ba2db19 --- /dev/null +++ b/vendor/github.com/camlistore/go4/lock/lock_sigzero.go @@ -0,0 +1,26 @@ +// +build !appengine +// +build linux darwin freebsd openbsd netbsd dragonfly + +/* +Copyright 2013 The Go Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package lock + +import "syscall" + +func init() { + signalZero = syscall.Signal(0) +} diff --git a/vendor/github.com/containernetworking/cni/LICENSE b/vendor/github.com/containernetworking/cni/LICENSE new file mode 100644 index 0000000000..8f71f43fee --- /dev/null +++ b/vendor/github.com/containernetworking/cni/LICENSE @@ -0,0 +1,202 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor 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, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/vendor/github.com/containernetworking/cni/pkg/invoke/args.go b/vendor/github.com/containernetworking/cni/pkg/invoke/args.go new file mode 100644 index 0000000000..be28ba621f --- /dev/null +++ b/vendor/github.com/containernetworking/cni/pkg/invoke/args.go @@ -0,0 +1,76 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package invoke + +import ( + "os" + "strings" +) + +type CNIArgs interface { + // For use with os/exec; i.e., return nil to inherit the + // environment from this process + AsEnv() []string +} + +type inherited struct{} + +var inheritArgsFromEnv inherited + +func (_ *inherited) AsEnv() []string { + return nil +} + +func ArgsFromEnv() CNIArgs { + return &inheritArgsFromEnv +} + +type Args struct { + Command string + ContainerID string + NetNS string + PluginArgs [][2]string + PluginArgsStr string + IfName string + Path string +} + +func (args *Args) AsEnv() []string { + env := os.Environ() + pluginArgsStr := args.PluginArgsStr + if pluginArgsStr == "" { + pluginArgsStr = stringify(args.PluginArgs) + } + + env = append(env, + "CNI_COMMAND="+args.Command, + "CNI_CONTAINERID="+args.ContainerID, + "CNI_NETNS="+args.NetNS, + "CNI_ARGS="+pluginArgsStr, + "CNI_IFNAME="+args.IfName, + "CNI_PATH="+args.Path) + return env +} + +// taken from rkt/networking/net_plugin.go +func stringify(pluginArgs [][2]string) string { + entries := make([]string, len(pluginArgs)) + + for i, kv := range pluginArgs { + entries[i] = strings.Join(kv[:], "=") + } + + return strings.Join(entries, ";") +} diff --git a/vendor/github.com/containernetworking/cni/pkg/invoke/delegate.go b/vendor/github.com/containernetworking/cni/pkg/invoke/delegate.go new file mode 100644 index 0000000000..ddf1d17274 --- /dev/null +++ b/vendor/github.com/containernetworking/cni/pkg/invoke/delegate.go @@ -0,0 +1,53 @@ +// Copyright 2016 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package invoke + +import ( + "fmt" + "os" + "strings" + + "github.com/containernetworking/cni/pkg/types" +) + +func DelegateAdd(delegatePlugin string, netconf []byte) (*types.Result, error) { + if os.Getenv("CNI_COMMAND") != "ADD" { + return nil, fmt.Errorf("CNI_COMMAND is not ADD") + } + + paths := strings.Split(os.Getenv("CNI_PATH"), ":") + + pluginPath, err := FindInPath(delegatePlugin, paths) + if err != nil { + return nil, err + } + + return ExecPluginWithResult(pluginPath, netconf, ArgsFromEnv()) +} + +func DelegateDel(delegatePlugin string, netconf []byte) error { + if os.Getenv("CNI_COMMAND") != "DEL" { + return fmt.Errorf("CNI_COMMAND is not DEL") + } + + paths := strings.Split(os.Getenv("CNI_PATH"), ":") + + pluginPath, err := FindInPath(delegatePlugin, paths) + if err != nil { + return err + } + + return ExecPluginWithoutResult(pluginPath, netconf, ArgsFromEnv()) +} diff --git a/vendor/github.com/containernetworking/cni/pkg/invoke/exec.go b/vendor/github.com/containernetworking/cni/pkg/invoke/exec.go new file mode 100644 index 0000000000..a85eede66a --- /dev/null +++ b/vendor/github.com/containernetworking/cni/pkg/invoke/exec.go @@ -0,0 +1,75 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package invoke + +import ( + "bytes" + "encoding/json" + "fmt" + "os" + "os/exec" + + "github.com/containernetworking/cni/pkg/types" +) + +func pluginErr(err error, output []byte) error { + if _, ok := err.(*exec.ExitError); ok { + emsg := types.Error{} + if perr := json.Unmarshal(output, &emsg); perr != nil { + return fmt.Errorf("netplugin failed but error parsing its diagnostic message %q: %v", string(output), perr) + } + details := "" + if emsg.Details != "" { + details = fmt.Sprintf("; %v", emsg.Details) + } + return fmt.Errorf("%v%v", emsg.Msg, details) + } + + return err +} + +func ExecPluginWithResult(pluginPath string, netconf []byte, args CNIArgs) (*types.Result, error) { + stdoutBytes, err := execPlugin(pluginPath, netconf, args) + if err != nil { + return nil, err + } + + res := &types.Result{} + err = json.Unmarshal(stdoutBytes, res) + return res, err +} + +func ExecPluginWithoutResult(pluginPath string, netconf []byte, args CNIArgs) error { + _, err := execPlugin(pluginPath, netconf, args) + return err +} + +func execPlugin(pluginPath string, netconf []byte, args CNIArgs) ([]byte, error) { + stdout := &bytes.Buffer{} + + c := exec.Cmd{ + Env: args.AsEnv(), + Path: pluginPath, + Args: []string{pluginPath}, + Stdin: bytes.NewBuffer(netconf), + Stdout: stdout, + Stderr: os.Stderr, + } + if err := c.Run(); err != nil { + return nil, pluginErr(err, stdout.Bytes()) + } + + return stdout.Bytes(), nil +} diff --git a/vendor/github.com/containernetworking/cni/pkg/invoke/find.go b/vendor/github.com/containernetworking/cni/pkg/invoke/find.go new file mode 100644 index 0000000000..3b03790711 --- /dev/null +++ b/vendor/github.com/containernetworking/cni/pkg/invoke/find.go @@ -0,0 +1,47 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package invoke + +import ( + "fmt" + "os" + "path/filepath" +) + +// FindInPath returns the full path of the plugin by searching in the provided path +func FindInPath(plugin string, paths []string) (string, error) { + if plugin == "" { + return "", fmt.Errorf("no plugin name provided") + } + + if len(paths) == 0 { + return "", fmt.Errorf("no paths provided") + } + + var fullpath string + for _, path := range paths { + full := filepath.Join(path, plugin) + if fi, err := os.Stat(full); err == nil && fi.Mode().IsRegular() { + fullpath = full + break + } + } + + if fullpath == "" { + return "", fmt.Errorf("failed to find plugin %q in path %s", plugin, paths) + } + + return fullpath, nil +} diff --git a/vendor/github.com/containernetworking/cni/pkg/ip/cidr.go b/vendor/github.com/containernetworking/cni/pkg/ip/cidr.go new file mode 100644 index 0000000000..dae2c4d0e4 --- /dev/null +++ b/vendor/github.com/containernetworking/cni/pkg/ip/cidr.go @@ -0,0 +1,51 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ip + +import ( + "math/big" + "net" +) + +// NextIP returns IP incremented by 1 +func NextIP(ip net.IP) net.IP { + i := ipToInt(ip) + return intToIP(i.Add(i, big.NewInt(1))) +} + +// PrevIP returns IP decremented by 1 +func PrevIP(ip net.IP) net.IP { + i := ipToInt(ip) + return intToIP(i.Sub(i, big.NewInt(1))) +} + +func ipToInt(ip net.IP) *big.Int { + if v := ip.To4(); v != nil { + return big.NewInt(0).SetBytes(v) + } + return big.NewInt(0).SetBytes(ip.To16()) +} + +func intToIP(i *big.Int) net.IP { + return net.IP(i.Bytes()) +} + +// Network masks off the host portion of the IP +func Network(ipn *net.IPNet) *net.IPNet { + return &net.IPNet{ + IP: ipn.IP.Mask(ipn.Mask), + Mask: ipn.Mask, + } +} diff --git a/vendor/github.com/containernetworking/cni/pkg/ip/ipforward.go b/vendor/github.com/containernetworking/cni/pkg/ip/ipforward.go new file mode 100644 index 0000000000..77ee74632a --- /dev/null +++ b/vendor/github.com/containernetworking/cni/pkg/ip/ipforward.go @@ -0,0 +1,31 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ip + +import ( + "io/ioutil" +) + +func EnableIP4Forward() error { + return echo1("/proc/sys/net/ipv4/ip_forward") +} + +func EnableIP6Forward() error { + return echo1("/proc/sys/net/ipv6/conf/all/forwarding") +} + +func echo1(f string) error { + return ioutil.WriteFile(f, []byte("1"), 0644) +} diff --git a/vendor/github.com/containernetworking/cni/pkg/ip/ipmasq.go b/vendor/github.com/containernetworking/cni/pkg/ip/ipmasq.go new file mode 100644 index 0000000000..8ee279717a --- /dev/null +++ b/vendor/github.com/containernetworking/cni/pkg/ip/ipmasq.go @@ -0,0 +1,66 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ip + +import ( + "fmt" + "net" + + "github.com/coreos/go-iptables/iptables" +) + +// SetupIPMasq installs iptables rules to masquerade traffic +// coming from ipn and going outside of it +func SetupIPMasq(ipn *net.IPNet, chain string, comment string) error { + ipt, err := iptables.New() + if err != nil { + return fmt.Errorf("failed to locate iptables: %v", err) + } + + if err = ipt.NewChain("nat", chain); err != nil { + if err.(*iptables.Error).ExitStatus() != 1 { + // TODO(eyakubovich): assumes exit status 1 implies chain exists + return err + } + } + + if err = ipt.AppendUnique("nat", chain, "-d", ipn.String(), "-j", "ACCEPT", "-m", "comment", "--comment", comment); err != nil { + return err + } + + if err = ipt.AppendUnique("nat", chain, "!", "-d", "224.0.0.0/4", "-j", "MASQUERADE", "-m", "comment", "--comment", comment); err != nil { + return err + } + + return ipt.AppendUnique("nat", "POSTROUTING", "-s", ipn.String(), "-j", chain, "-m", "comment", "--comment", comment) +} + +// TeardownIPMasq undoes the effects of SetupIPMasq +func TeardownIPMasq(ipn *net.IPNet, chain string, comment string) error { + ipt, err := iptables.New() + if err != nil { + return fmt.Errorf("failed to locate iptables: %v", err) + } + + if err = ipt.Delete("nat", "POSTROUTING", "-s", ipn.String(), "-j", chain, "-m", "comment", "--comment", comment); err != nil { + return err + } + + if err = ipt.ClearChain("nat", chain); err != nil { + return err + } + + return ipt.DeleteChain("nat", chain) +} diff --git a/vendor/github.com/containernetworking/cni/pkg/ip/link.go b/vendor/github.com/containernetworking/cni/pkg/ip/link.go new file mode 100644 index 0000000000..1b78567201 --- /dev/null +++ b/vendor/github.com/containernetworking/cni/pkg/ip/link.go @@ -0,0 +1,153 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ip + +import ( + "crypto/rand" + "fmt" + "net" + "os" + + "github.com/containernetworking/cni/pkg/ns" + "github.com/vishvananda/netlink" +) + +func makeVethPair(name, peer string, mtu int) (netlink.Link, error) { + veth := &netlink.Veth{ + LinkAttrs: netlink.LinkAttrs{ + Name: name, + Flags: net.FlagUp, + MTU: mtu, + }, + PeerName: peer, + } + if err := netlink.LinkAdd(veth); err != nil { + return nil, err + } + + return veth, nil +} + +func makeVeth(name string, mtu int) (peerName string, veth netlink.Link, err error) { + for i := 0; i < 10; i++ { + peerName, err = RandomVethName() + if err != nil { + return + } + + veth, err = makeVethPair(name, peerName, mtu) + switch { + case err == nil: + return + + case os.IsExist(err): + continue + + default: + err = fmt.Errorf("failed to make veth pair: %v", err) + return + } + } + + // should really never be hit + err = fmt.Errorf("failed to find a unique veth name") + return +} + +// RandomVethName returns string "veth" with random prefix (hashed from entropy) +func RandomVethName() (string, error) { + entropy := make([]byte, 4) + _, err := rand.Reader.Read(entropy) + if err != nil { + return "", fmt.Errorf("failed to generate random veth name: %v", err) + } + + // NetworkManager (recent versions) will ignore veth devices that start with "veth" + return fmt.Sprintf("veth%x", entropy), nil +} + +// SetupVeth sets up a virtual ethernet link. +// Should be in container netns, and will switch back to hostNS to set the host +// veth end up. +func SetupVeth(contVethName string, mtu int, hostNS ns.NetNS) (hostVeth, contVeth netlink.Link, err error) { + var hostVethName string + hostVethName, contVeth, err = makeVeth(contVethName, mtu) + if err != nil { + return + } + + if err = netlink.LinkSetUp(contVeth); err != nil { + err = fmt.Errorf("failed to set %q up: %v", contVethName, err) + return + } + + hostVeth, err = netlink.LinkByName(hostVethName) + if err != nil { + err = fmt.Errorf("failed to lookup %q: %v", hostVethName, err) + return + } + + if err = netlink.LinkSetNsFd(hostVeth, int(hostNS.Fd())); err != nil { + err = fmt.Errorf("failed to move veth to host netns: %v", err) + return + } + + err = hostNS.Do(func(_ ns.NetNS) error { + hostVeth, err := netlink.LinkByName(hostVethName) + if err != nil { + return fmt.Errorf("failed to lookup %q in %q: %v", hostVethName, hostNS.Path(), err) + } + + if err = netlink.LinkSetUp(hostVeth); err != nil { + return fmt.Errorf("failed to set %q up: %v", hostVethName, err) + } + return nil + }) + return +} + +// DelLinkByName removes an interface link. +func DelLinkByName(ifName string) error { + iface, err := netlink.LinkByName(ifName) + if err != nil { + return fmt.Errorf("failed to lookup %q: %v", ifName, err) + } + + if err = netlink.LinkDel(iface); err != nil { + return fmt.Errorf("failed to delete %q: %v", ifName, err) + } + + return nil +} + +// DelLinkByNameAddr remove an interface returns its IP address +// of the specified family +func DelLinkByNameAddr(ifName string, family int) (*net.IPNet, error) { + iface, err := netlink.LinkByName(ifName) + if err != nil { + return nil, fmt.Errorf("failed to lookup %q: %v", ifName, err) + } + + addrs, err := netlink.AddrList(iface, family) + if err != nil || len(addrs) == 0 { + return nil, fmt.Errorf("failed to get IP addresses for %q: %v", ifName, err) + } + + if err = netlink.LinkDel(iface); err != nil { + return nil, fmt.Errorf("failed to delete %q: %v", ifName, err) + } + + return addrs[0].IPNet, nil +} diff --git a/vendor/github.com/containernetworking/cni/pkg/ip/route.go b/vendor/github.com/containernetworking/cni/pkg/ip/route.go new file mode 100644 index 0000000000..6c8658b2a2 --- /dev/null +++ b/vendor/github.com/containernetworking/cni/pkg/ip/route.go @@ -0,0 +1,47 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ip + +import ( + "net" + + "github.com/vishvananda/netlink" +) + +// AddDefaultRoute sets the default route on the given gateway. +func AddDefaultRoute(gw net.IP, dev netlink.Link) error { + _, defNet, _ := net.ParseCIDR("0.0.0.0/0") + return AddRoute(defNet, gw, dev) +} + +// AddRoute adds a universally-scoped route to a device. +func AddRoute(ipn *net.IPNet, gw net.IP, dev netlink.Link) error { + return netlink.RouteAdd(&netlink.Route{ + LinkIndex: dev.Attrs().Index, + Scope: netlink.SCOPE_UNIVERSE, + Dst: ipn, + Gw: gw, + }) +} + +// AddHostRoute adds a host-scoped route to a device. +func AddHostRoute(ipn *net.IPNet, gw net.IP, dev netlink.Link) error { + return netlink.RouteAdd(&netlink.Route{ + LinkIndex: dev.Attrs().Index, + Scope: netlink.SCOPE_HOST, + Dst: ipn, + Gw: gw, + }) +} diff --git a/vendor/github.com/containernetworking/cni/pkg/ipam/ipam.go b/vendor/github.com/containernetworking/cni/pkg/ipam/ipam.go new file mode 100644 index 0000000000..d9fbff74c7 --- /dev/null +++ b/vendor/github.com/containernetworking/cni/pkg/ipam/ipam.go @@ -0,0 +1,68 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ipam + +import ( + "fmt" + "os" + + "github.com/containernetworking/cni/pkg/invoke" + "github.com/containernetworking/cni/pkg/ip" + "github.com/containernetworking/cni/pkg/types" + + "github.com/vishvananda/netlink" +) + +func ExecAdd(plugin string, netconf []byte) (*types.Result, error) { + return invoke.DelegateAdd(plugin, netconf) +} + +func ExecDel(plugin string, netconf []byte) error { + return invoke.DelegateDel(plugin, netconf) +} + +// ConfigureIface takes the result of IPAM plugin and +// applies to the ifName interface +func ConfigureIface(ifName string, res *types.Result) error { + link, err := netlink.LinkByName(ifName) + if err != nil { + return fmt.Errorf("failed to lookup %q: %v", ifName, err) + } + + if err := netlink.LinkSetUp(link); err != nil { + return fmt.Errorf("failed to set %q UP: %v", ifName, err) + } + + // TODO(eyakubovich): IPv6 + addr := &netlink.Addr{IPNet: &res.IP4.IP, Label: ""} + if err = netlink.AddrAdd(link, addr); err != nil { + return fmt.Errorf("failed to add IP addr to %q: %v", ifName, err) + } + + for _, r := range res.IP4.Routes { + gw := r.GW + if gw == nil { + gw = res.IP4.Gateway + } + if err = ip.AddRoute(&r.Dst, gw, link); err != nil { + // we skip over duplicate routes as we assume the first one wins + if !os.IsExist(err) { + return fmt.Errorf("failed to add route '%v via %v dev %v': %v", r.Dst, gw, ifName, err) + } + } + } + + return nil +} diff --git a/vendor/github.com/containernetworking/cni/pkg/ns/ns.go b/vendor/github.com/containernetworking/cni/pkg/ns/ns.go new file mode 100644 index 0000000000..e29f712ce1 --- /dev/null +++ b/vendor/github.com/containernetworking/cni/pkg/ns/ns.go @@ -0,0 +1,315 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ns + +import ( + "crypto/rand" + "fmt" + "os" + "path" + "runtime" + "strings" + "sync" + "syscall" + + "golang.org/x/sys/unix" +) + +type NetNS interface { + // Executes the passed closure in this object's network namespace, + // attemtping to restore the original namespace before returning. + // However, since each OS thread can have a different network namespace, + // and Go's thread scheduling is highly variable, callers cannot + // guarantee any specific namespace is set unless operations that + // require that namespace are wrapped with Do(). Also, no code called + // from Do() should call runtime.UnlockOSThread(), or the risk + // of executing code in an incorrect namespace will be greater. See + // https://github.com/golang/go/wiki/LockOSThread for further details. + Do(toRun func(NetNS) error) error + + // Sets the current network namespace to this object's network namespace. + // Note that since Go's thread scheduling is highly variable, callers + // cannot guarantee the requested namespace will be the current namespace + // after this function is called; to ensure this wrap operations that + // require the namespace with Do() instead. + Set() error + + // Returns the filesystem path representing this object's network namespace + Path() string + + // Returns a file descriptor representing this object's network namespace + Fd() uintptr + + // Cleans up this instance of the network namespace; if this instance + // is the last user the namespace will be destroyed + Close() error +} + +type netNS struct { + file *os.File + mounted bool + closed bool +} + +func getCurrentThreadNetNSPath() string { + // /proc/self/ns/net returns the namespace of the main thread, not + // of whatever thread this goroutine is running on. Make sure we + // use the thread's net namespace since the thread is switching around + return fmt.Sprintf("/proc/%d/task/%d/ns/net", os.Getpid(), unix.Gettid()) +} + +// Returns an object representing the current OS thread's network namespace +func GetCurrentNS() (NetNS, error) { + return GetNS(getCurrentThreadNetNSPath()) +} + +const ( + // https://github.com/torvalds/linux/blob/master/include/uapi/linux/magic.h + NSFS_MAGIC = 0x6e736673 + PROCFS_MAGIC = 0x9fa0 +) + +type NSPathNotExistErr struct{ msg string } + +func (e NSPathNotExistErr) Error() string { return e.msg } + +type NSPathNotNSErr struct{ msg string } + +func (e NSPathNotNSErr) Error() string { return e.msg } + +func IsNSorErr(nspath string) error { + stat := syscall.Statfs_t{} + if err := syscall.Statfs(nspath, &stat); err != nil { + if os.IsNotExist(err) { + err = NSPathNotExistErr{msg: fmt.Sprintf("failed to Statfs %q: %v", nspath, err)} + } else { + err = fmt.Errorf("failed to Statfs %q: %v", nspath, err) + } + return err + } + + switch stat.Type { + case PROCFS_MAGIC: + // Kernel < 3.19 + + validPathContent := "ns/" + validName := strings.Contains(nspath, validPathContent) + if !validName { + return NSPathNotNSErr{msg: fmt.Sprintf("path %q doesn't contain %q", nspath, validPathContent)} + } + + return nil + case NSFS_MAGIC: + // Kernel >= 3.19 + + return nil + default: + return NSPathNotNSErr{msg: fmt.Sprintf("unknown FS magic on %q: %x", nspath, stat.Type)} + } +} + +// Returns an object representing the namespace referred to by @path +func GetNS(nspath string) (NetNS, error) { + err := IsNSorErr(nspath) + if err != nil { + return nil, err + } + + fd, err := os.Open(nspath) + if err != nil { + return nil, err + } + + return &netNS{file: fd}, nil +} + +// Creates a new persistent network namespace and returns an object +// representing that namespace, without switching to it +func NewNS() (NetNS, error) { + const nsRunDir = "/var/run/netns" + + b := make([]byte, 16) + _, err := rand.Reader.Read(b) + if err != nil { + return nil, fmt.Errorf("failed to generate random netns name: %v", err) + } + + err = os.MkdirAll(nsRunDir, 0755) + if err != nil { + return nil, err + } + + // create an empty file at the mount point + nsName := fmt.Sprintf("cni-%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:]) + nsPath := path.Join(nsRunDir, nsName) + mountPointFd, err := os.Create(nsPath) + if err != nil { + return nil, err + } + mountPointFd.Close() + + // Ensure the mount point is cleaned up on errors; if the namespace + // was successfully mounted this will have no effect because the file + // is in-use + defer os.RemoveAll(nsPath) + + var wg sync.WaitGroup + wg.Add(1) + + // do namespace work in a dedicated goroutine, so that we can safely + // Lock/Unlock OSThread without upsetting the lock/unlock state of + // the caller of this function + var fd *os.File + go (func() { + defer wg.Done() + runtime.LockOSThread() + + var origNS NetNS + origNS, err = GetNS(getCurrentThreadNetNSPath()) + if err != nil { + return + } + defer origNS.Close() + + // create a new netns on the current thread + err = unix.Unshare(unix.CLONE_NEWNET) + if err != nil { + return + } + defer origNS.Set() + + // bind mount the new netns from the current thread onto the mount point + err = unix.Mount(getCurrentThreadNetNSPath(), nsPath, "none", unix.MS_BIND, "") + if err != nil { + return + } + + fd, err = os.Open(nsPath) + if err != nil { + return + } + })() + wg.Wait() + + if err != nil { + unix.Unmount(nsPath, unix.MNT_DETACH) + return nil, fmt.Errorf("failed to create namespace: %v", err) + } + + return &netNS{file: fd, mounted: true}, nil +} + +func (ns *netNS) Path() string { + return ns.file.Name() +} + +func (ns *netNS) Fd() uintptr { + return ns.file.Fd() +} + +func (ns *netNS) errorIfClosed() error { + if ns.closed { + return fmt.Errorf("%q has already been closed", ns.file.Name()) + } + return nil +} + +func (ns *netNS) Close() error { + if err := ns.errorIfClosed(); err != nil { + return err + } + + if err := ns.file.Close(); err != nil { + return fmt.Errorf("Failed to close %q: %v", ns.file.Name(), err) + } + ns.closed = true + + if ns.mounted { + if err := unix.Unmount(ns.file.Name(), unix.MNT_DETACH); err != nil { + return fmt.Errorf("Failed to unmount namespace %s: %v", ns.file.Name(), err) + } + if err := os.RemoveAll(ns.file.Name()); err != nil { + return fmt.Errorf("Failed to clean up namespace %s: %v", ns.file.Name(), err) + } + ns.mounted = false + } + + return nil +} + +func (ns *netNS) Do(toRun func(NetNS) error) error { + if err := ns.errorIfClosed(); err != nil { + return err + } + + containedCall := func(hostNS NetNS) error { + threadNS, err := GetNS(getCurrentThreadNetNSPath()) + if err != nil { + return fmt.Errorf("failed to open current netns: %v", err) + } + defer threadNS.Close() + + // switch to target namespace + if err = ns.Set(); err != nil { + return fmt.Errorf("error switching to ns %v: %v", ns.file.Name(), err) + } + defer threadNS.Set() // switch back + + return toRun(hostNS) + } + + // save a handle to current network namespace + hostNS, err := GetNS(getCurrentThreadNetNSPath()) + if err != nil { + return fmt.Errorf("Failed to open current namespace: %v", err) + } + defer hostNS.Close() + + var wg sync.WaitGroup + wg.Add(1) + + var innerError error + go func() { + defer wg.Done() + runtime.LockOSThread() + innerError = containedCall(hostNS) + }() + wg.Wait() + + return innerError +} + +func (ns *netNS) Set() error { + if err := ns.errorIfClosed(); err != nil { + return err + } + + if _, _, err := unix.Syscall(unix.SYS_SETNS, ns.Fd(), uintptr(unix.CLONE_NEWNET), 0); err != 0 { + return fmt.Errorf("Error switching to ns %v: %v", ns.file.Name(), err) + } + + return nil +} + +// WithNetNSPath executes the passed closure under the given network +// namespace, restoring the original namespace afterwards. +func WithNetNSPath(nspath string, toRun func(NetNS) error) error { + ns, err := GetNS(nspath) + if err != nil { + return err + } + defer ns.Close() + return ns.Do(toRun) +} diff --git a/vendor/github.com/containernetworking/cni/pkg/skel/skel.go b/vendor/github.com/containernetworking/cni/pkg/skel/skel.go new file mode 100644 index 0000000000..9cf03917b4 --- /dev/null +++ b/vendor/github.com/containernetworking/cni/pkg/skel/skel.go @@ -0,0 +1,161 @@ +// Copyright 2014 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package skel provides skeleton code for a CNI plugin. +// In particular, it implements argument parsing and validation. +package skel + +import ( + "fmt" + "io/ioutil" + "log" + "os" + + "github.com/containernetworking/cni/pkg/types" +) + +// CmdArgs captures all the arguments passed in to the plugin +// via both env vars and stdin +type CmdArgs struct { + ContainerID string + Netns string + IfName string + Args string + Path string + StdinData []byte +} + +type reqForCmdEntry map[string]bool + +// PluginMain is the "main" for a plugin. It accepts +// two callback functions for add and del commands. +func PluginMain(cmdAdd, cmdDel func(_ *CmdArgs) error) { + var cmd, contID, netns, ifName, args, path string + + vars := []struct { + name string + val *string + reqForCmd reqForCmdEntry + }{ + { + "CNI_COMMAND", + &cmd, + reqForCmdEntry{ + "ADD": true, + "DEL": true, + }, + }, + { + "CNI_CONTAINERID", + &contID, + reqForCmdEntry{ + "ADD": false, + "DEL": false, + }, + }, + { + "CNI_NETNS", + &netns, + reqForCmdEntry{ + "ADD": true, + "DEL": false, + }, + }, + { + "CNI_IFNAME", + &ifName, + reqForCmdEntry{ + "ADD": true, + "DEL": true, + }, + }, + { + "CNI_ARGS", + &args, + reqForCmdEntry{ + "ADD": false, + "DEL": false, + }, + }, + { + "CNI_PATH", + &path, + reqForCmdEntry{ + "ADD": true, + "DEL": true, + }, + }, + } + + argsMissing := false + for _, v := range vars { + *v.val = os.Getenv(v.name) + if v.reqForCmd[cmd] && *v.val == "" { + log.Printf("%v env variable missing", v.name) + argsMissing = true + } + } + + if argsMissing { + dieMsg("required env variables missing") + } + + stdinData, err := ioutil.ReadAll(os.Stdin) + if err != nil { + dieMsg("error reading from stdin: %v", err) + } + + cmdArgs := &CmdArgs{ + ContainerID: contID, + Netns: netns, + IfName: ifName, + Args: args, + Path: path, + StdinData: stdinData, + } + + switch cmd { + case "ADD": + err = cmdAdd(cmdArgs) + + case "DEL": + err = cmdDel(cmdArgs) + + default: + dieMsg("unknown CNI_COMMAND: %v", cmd) + } + + if err != nil { + if e, ok := err.(*types.Error); ok { + // don't wrap Error in Error + dieErr(e) + } + dieMsg(err.Error()) + } +} + +func dieMsg(f string, args ...interface{}) { + e := &types.Error{ + Code: 100, + Msg: fmt.Sprintf(f, args...), + } + dieErr(e) +} + +func dieErr(e *types.Error) { + if err := e.Print(); err != nil { + log.Print("Error writing error JSON to stdout: ", err) + } + os.Exit(1) +} diff --git a/vendor/github.com/containernetworking/cni/pkg/testutils/cmd.go b/vendor/github.com/containernetworking/cni/pkg/testutils/cmd.go new file mode 100644 index 0000000000..201b935f40 --- /dev/null +++ b/vendor/github.com/containernetworking/cni/pkg/testutils/cmd.go @@ -0,0 +1,77 @@ +// Copyright 2016 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package testutils + +import ( + "encoding/json" + "io/ioutil" + "os" + + "github.com/containernetworking/cni/pkg/types" +) + +func envCleanup() { + os.Unsetenv("CNI_COMMAND") + os.Unsetenv("CNI_PATH") + os.Unsetenv("CNI_NETNS") + os.Unsetenv("CNI_IFNAME") +} + +func CmdAddWithResult(cniNetns, cniIfname string, f func() error) (*types.Result, error) { + os.Setenv("CNI_COMMAND", "ADD") + os.Setenv("CNI_PATH", os.Getenv("PATH")) + os.Setenv("CNI_NETNS", cniNetns) + os.Setenv("CNI_IFNAME", cniIfname) + defer envCleanup() + + // Redirect stdout to capture plugin result + oldStdout := os.Stdout + r, w, err := os.Pipe() + if err != nil { + return nil, err + } + + os.Stdout = w + err = f() + w.Close() + if err != nil { + return nil, err + } + + // parse the result + out, err := ioutil.ReadAll(r) + os.Stdout = oldStdout + if err != nil { + return nil, err + } + + result := types.Result{} + err = json.Unmarshal(out, &result) + if err != nil { + return nil, err + } + + return &result, nil +} + +func CmdDelWithResult(cniNetns, cniIfname string, f func() error) error { + os.Setenv("CNI_COMMAND", "DEL") + os.Setenv("CNI_PATH", os.Getenv("PATH")) + os.Setenv("CNI_NETNS", cniNetns) + os.Setenv("CNI_IFNAME", cniIfname) + defer envCleanup() + + return f() +} diff --git a/vendor/github.com/containernetworking/cni/pkg/types/args.go b/vendor/github.com/containernetworking/cni/pkg/types/args.go new file mode 100644 index 0000000000..3b667b0f20 --- /dev/null +++ b/vendor/github.com/containernetworking/cni/pkg/types/args.go @@ -0,0 +1,91 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "encoding" + "fmt" + "reflect" + "strings" +) + +// UnmarshallableBool typedef for builtin bool +// because builtin type's methods can't be declared +type UnmarshallableBool bool + +// UnmarshalText implements the encoding.TextUnmarshaler interface. +// Returns boolean true if the string is "1" or "[Tt]rue" +// Returns boolean false if the string is "0" or "[Ff]alse" +func (b *UnmarshallableBool) UnmarshalText(data []byte) error { + s := strings.ToLower(string(data)) + switch s { + case "1", "true": + *b = true + case "0", "false": + *b = false + default: + return fmt.Errorf("Boolean unmarshal error: invalid input %s", s) + } + return nil +} + +// CommonArgs contains the IgnoreUnknown argument +// and must be embedded by all Arg structs +type CommonArgs struct { + IgnoreUnknown UnmarshallableBool `json:"ignoreunknown,omitempty"` +} + +// GetKeyField is a helper function to receive Values +// Values that represent a pointer to a struct +func GetKeyField(keyString string, v reflect.Value) reflect.Value { + return v.Elem().FieldByName(keyString) +} + +// LoadArgs parses args from a string in the form "K=V;K2=V2;..." +func LoadArgs(args string, container interface{}) error { + if args == "" { + return nil + } + + containerValue := reflect.ValueOf(container) + + pairs := strings.Split(args, ";") + unknownArgs := []string{} + for _, pair := range pairs { + kv := strings.Split(pair, "=") + if len(kv) != 2 { + return fmt.Errorf("ARGS: invalid pair %q", pair) + } + keyString := kv[0] + valueString := kv[1] + keyField := GetKeyField(keyString, containerValue) + if !keyField.IsValid() { + unknownArgs = append(unknownArgs, pair) + continue + } + + u := keyField.Addr().Interface().(encoding.TextUnmarshaler) + err := u.UnmarshalText([]byte(valueString)) + if err != nil { + return fmt.Errorf("ARGS: error parsing value of pair %q: %v)", pair, err) + } + } + + isIgnoreUnknown := GetKeyField("IgnoreUnknown", containerValue).Bool() + if len(unknownArgs) > 0 && !isIgnoreUnknown { + return fmt.Errorf("ARGS: unknown args %q", unknownArgs) + } + return nil +} diff --git a/vendor/github.com/containernetworking/cni/pkg/types/types.go b/vendor/github.com/containernetworking/cni/pkg/types/types.go new file mode 100644 index 0000000000..6948dcb1fb --- /dev/null +++ b/vendor/github.com/containernetworking/cni/pkg/types/types.go @@ -0,0 +1,191 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "encoding/json" + "fmt" + "net" + "os" +) + +// like net.IPNet but adds JSON marshalling and unmarshalling +type IPNet net.IPNet + +// ParseCIDR takes a string like "10.2.3.1/24" and +// return IPNet with "10.2.3.1" and /24 mask +func ParseCIDR(s string) (*net.IPNet, error) { + ip, ipn, err := net.ParseCIDR(s) + if err != nil { + return nil, err + } + + ipn.IP = ip + return ipn, nil +} + +func (n IPNet) MarshalJSON() ([]byte, error) { + return json.Marshal((*net.IPNet)(&n).String()) +} + +func (n *IPNet) UnmarshalJSON(data []byte) error { + var s string + if err := json.Unmarshal(data, &s); err != nil { + return err + } + + tmp, err := ParseCIDR(s) + if err != nil { + return err + } + + *n = IPNet(*tmp) + return nil +} + +// NetConf describes a network. +type NetConf struct { + Name string `json:"name,omitempty"` + Type string `json:"type,omitempty"` + IPAM struct { + Type string `json:"type,omitempty"` + } `json:"ipam,omitempty"` + DNS DNS `json:"dns"` +} + +// Result is what gets returned from the plugin (via stdout) to the caller +type Result struct { + IP4 *IPConfig `json:"ip4,omitempty"` + IP6 *IPConfig `json:"ip6,omitempty"` + DNS DNS `json:"dns,omitempty"` +} + +func (r *Result) Print() error { + return prettyPrint(r) +} + +// String returns a formatted string in the form of "[IP4: $1,][ IP6: $2,] DNS: $3" where +// $1 represents the receiver's IPv4, $2 represents the receiver's IPv6 and $3 the +// receiver's DNS. If $1 or $2 are nil, they won't be present in the returned string. +func (r *Result) String() string { + var str string + if r.IP4 != nil { + str = fmt.Sprintf("IP4:%+v, ", *r.IP4) + } + if r.IP6 != nil { + str += fmt.Sprintf("IP6:%+v, ", *r.IP6) + } + return fmt.Sprintf("%sDNS:%+v", str, r.DNS) +} + +// IPConfig contains values necessary to configure an interface +type IPConfig struct { + IP net.IPNet + Gateway net.IP + Routes []Route +} + +// DNS contains values interesting for DNS resolvers +type DNS struct { + Nameservers []string `json:"nameservers,omitempty"` + Domain string `json:"domain,omitempty"` + Search []string `json:"search,omitempty"` + Options []string `json:"options,omitempty"` +} + +type Route struct { + Dst net.IPNet + GW net.IP +} + +type Error struct { + Code uint `json:"code"` + Msg string `json:"msg"` + Details string `json:"details,omitempty"` +} + +func (e *Error) Error() string { + return e.Msg +} + +func (e *Error) Print() error { + return prettyPrint(e) +} + +// net.IPNet is not JSON (un)marshallable so this duality is needed +// for our custom IPNet type + +// JSON (un)marshallable types +type ipConfig struct { + IP IPNet `json:"ip"` + Gateway net.IP `json:"gateway,omitempty"` + Routes []Route `json:"routes,omitempty"` +} + +type route struct { + Dst IPNet `json:"dst"` + GW net.IP `json:"gw,omitempty"` +} + +func (c *IPConfig) MarshalJSON() ([]byte, error) { + ipc := ipConfig{ + IP: IPNet(c.IP), + Gateway: c.Gateway, + Routes: c.Routes, + } + + return json.Marshal(ipc) +} + +func (c *IPConfig) UnmarshalJSON(data []byte) error { + ipc := ipConfig{} + if err := json.Unmarshal(data, &ipc); err != nil { + return err + } + + c.IP = net.IPNet(ipc.IP) + c.Gateway = ipc.Gateway + c.Routes = ipc.Routes + return nil +} + +func (r *Route) UnmarshalJSON(data []byte) error { + rt := route{} + if err := json.Unmarshal(data, &rt); err != nil { + return err + } + + r.Dst = net.IPNet(rt.Dst) + r.GW = rt.GW + return nil +} + +func (r *Route) MarshalJSON() ([]byte, error) { + rt := route{ + Dst: IPNet(r.Dst), + GW: r.GW, + } + + return json.Marshal(rt) +} + +func prettyPrint(obj interface{}) error { + data, err := json.MarshalIndent(obj, "", " ") + if err != nil { + return err + } + _, err = os.Stdout.Write(data) + return err +} diff --git a/vendor/github.com/containernetworking/cni/pkg/utils/sysctl/sysctl_linux.go b/vendor/github.com/containernetworking/cni/pkg/utils/sysctl/sysctl_linux.go new file mode 100644 index 0000000000..c0fba38290 --- /dev/null +++ b/vendor/github.com/containernetworking/cni/pkg/utils/sysctl/sysctl_linux.go @@ -0,0 +1,58 @@ +// Copyright 2016 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// build +linux + +package sysctl + +import ( + "fmt" + "io/ioutil" + "path/filepath" + "strings" +) + +// Sysctl provides a method to set/get values from /proc/sys - in linux systems +// new interface to set/get values of variables formerly handled by sysctl syscall +// If optional `params` have only one string value - this function will +// set this value into coresponding sysctl variable +func Sysctl(name string, params ...string) (string, error) { + if len(params) > 1 { + return "", fmt.Errorf("unexcepted additional parameters") + } else if len(params) == 1 { + return setSysctl(name, params[0]) + } + return getSysctl(name) +} + +func getSysctl(name string) (string, error) { + fullName := filepath.Join("/proc/sys", strings.Replace(name, ".", "/", -1)) + fullName = filepath.Clean(fullName) + data, err := ioutil.ReadFile(fullName) + if err != nil { + return "", err + } + + return string(data[:len(data)-1]), nil +} + +func setSysctl(name, value string) (string, error) { + fullName := filepath.Join("/proc/sys", strings.Replace(name, ".", "/", -1)) + fullName = filepath.Clean(fullName) + if err := ioutil.WriteFile(fullName, []byte(value), 0644); err != nil { + return "", err + } + + return getSysctl(name) +} diff --git a/vendor/github.com/containernetworking/cni/pkg/utils/utils.go b/vendor/github.com/containernetworking/cni/pkg/utils/utils.go new file mode 100644 index 0000000000..33a2aa7960 --- /dev/null +++ b/vendor/github.com/containernetworking/cni/pkg/utils/utils.go @@ -0,0 +1,41 @@ +// Copyright 2016 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package utils + +import ( + "crypto/sha512" + "fmt" +) + +const ( + maxChainLength = 28 + chainPrefix = "CNI-" + prefixLength = len(chainPrefix) +) + +// Generates a chain name to be used with iptables. +// Ensures that the generated chain name is exactly +// maxChainLength chars in length +func FormatChainName(name string, id string) string { + chainBytes := sha512.Sum512([]byte(name + id)) + chain := fmt.Sprintf("%s%x", chainPrefix, chainBytes) + return chain[:maxChainLength] +} + +// FormatComment returns a comment used for easier +// rule identification within iptables. +func FormatComment(name string, id string) string { + return fmt.Sprintf("name: %q id: %q", name, id) +} diff --git a/vendor/github.com/containernetworking/cni/plugins/ipam/dhcp/daemon.go b/vendor/github.com/containernetworking/cni/plugins/ipam/dhcp/daemon.go new file mode 100644 index 0000000000..2386f9a9f4 --- /dev/null +++ b/vendor/github.com/containernetworking/cni/plugins/ipam/dhcp/daemon.go @@ -0,0 +1,157 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "encoding/json" + "errors" + "fmt" + "log" + "net" + "net/http" + "net/rpc" + "os" + "path/filepath" + "runtime" + "sync" + + "github.com/containernetworking/cni/pkg/skel" + "github.com/containernetworking/cni/pkg/types" + "github.com/coreos/go-systemd/activation" +) + +const listenFdsStart = 3 +const resendCount = 3 + +var errNoMoreTries = errors.New("no more tries") + +type DHCP struct { + mux sync.Mutex + leases map[string]*DHCPLease +} + +func newDHCP() *DHCP { + return &DHCP{ + leases: make(map[string]*DHCPLease), + } +} + +// Allocate acquires an IP from a DHCP server for a specified container. +// The acquired lease will be maintained until Release() is called. +func (d *DHCP) Allocate(args *skel.CmdArgs, result *types.Result) error { + conf := types.NetConf{} + if err := json.Unmarshal(args.StdinData, &conf); err != nil { + return fmt.Errorf("error parsing netconf: %v", err) + } + + clientID := args.ContainerID + "/" + conf.Name + l, err := AcquireLease(clientID, args.Netns, args.IfName) + if err != nil { + return err + } + + ipn, err := l.IPNet() + if err != nil { + l.Stop() + return err + } + + d.setLease(args.ContainerID, conf.Name, l) + + result.IP4 = &types.IPConfig{ + IP: *ipn, + Gateway: l.Gateway(), + Routes: l.Routes(), + } + + return nil +} + +// Release stops maintenance of the lease acquired in Allocate() +// and sends a release msg to the DHCP server. +func (d *DHCP) Release(args *skel.CmdArgs, reply *struct{}) error { + conf := types.NetConf{} + if err := json.Unmarshal(args.StdinData, &conf); err != nil { + return fmt.Errorf("error parsing netconf: %v", err) + } + + if l := d.getLease(args.ContainerID, conf.Name); l != nil { + l.Stop() + return nil + } + + return fmt.Errorf("lease not found: %v/%v", args.ContainerID, conf.Name) +} + +func (d *DHCP) getLease(contID, netName string) *DHCPLease { + d.mux.Lock() + defer d.mux.Unlock() + + // TODO(eyakubovich): hash it to avoid collisions + l, ok := d.leases[contID+netName] + if !ok { + return nil + } + return l +} + +func (d *DHCP) setLease(contID, netName string, l *DHCPLease) { + d.mux.Lock() + defer d.mux.Unlock() + + // TODO(eyakubovich): hash it to avoid collisions + d.leases[contID+netName] = l +} + +func getListener() (net.Listener, error) { + l, err := activation.Listeners(true) + if err != nil { + return nil, err + } + + switch { + case len(l) == 0: + if err := os.MkdirAll(filepath.Dir(socketPath), 0700); err != nil { + return nil, err + } + return net.Listen("unix", socketPath) + + case len(l) == 1: + if l[0] == nil { + return nil, fmt.Errorf("LISTEN_FDS=1 but no FD found") + } + return l[0], nil + + default: + return nil, fmt.Errorf("Too many (%v) FDs passed through socket activation", len(l)) + } +} + +func runDaemon() { + // since other goroutines (on separate threads) will change namespaces, + // ensure the RPC server does not get scheduled onto those + runtime.LockOSThread() + + l, err := getListener() + if err != nil { + log.Printf("Error getting listener: %v", err) + return + } + + dhcp := newDHCP() + rpc.Register(dhcp) + rpc.HandleHTTP() + http.Serve(l, nil) +} diff --git a/vendor/github.com/containernetworking/cni/plugins/ipam/dhcp/lease.go b/vendor/github.com/containernetworking/cni/plugins/ipam/dhcp/lease.go new file mode 100644 index 0000000000..eb2b403130 --- /dev/null +++ b/vendor/github.com/containernetworking/cni/plugins/ipam/dhcp/lease.go @@ -0,0 +1,337 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "fmt" + "log" + "math/rand" + "net" + "sync" + "time" + + "github.com/d2g/dhcp4" + "github.com/d2g/dhcp4client" + "github.com/vishvananda/netlink" + + "github.com/containernetworking/cni/pkg/ns" + "github.com/containernetworking/cni/pkg/types" +) + +// RFC 2131 suggests using exponential backoff, starting with 4sec +// and randomized to +/- 1sec +const resendDelay0 = 4 * time.Second +const resendDelayMax = 32 * time.Second + +const ( + leaseStateBound = iota + leaseStateRenewing + leaseStateRebinding +) + +// This implementation uses 1 OS thread per lease. This is because +// all the network operations have to be done in network namespace +// of the interface. This can be improved by switching to the proper +// namespace for network ops and using fewer threads. However, this +// needs to be done carefully as dhcp4client ops are blocking. + +type DHCPLease struct { + clientID string + ack *dhcp4.Packet + opts dhcp4.Options + link netlink.Link + renewalTime time.Time + rebindingTime time.Time + expireTime time.Time + stop chan struct{} + wg sync.WaitGroup +} + +// AcquireLease gets an DHCP lease and then maintains it in the background +// by periodically renewing it. The acquired lease can be released by +// calling DHCPLease.Stop() +func AcquireLease(clientID, netns, ifName string) (*DHCPLease, error) { + errCh := make(chan error, 1) + l := &DHCPLease{ + clientID: clientID, + stop: make(chan struct{}), + } + + log.Printf("%v: acquiring lease", clientID) + + l.wg.Add(1) + go func() { + errCh <- ns.WithNetNSPath(netns, func(_ ns.NetNS) error { + defer l.wg.Done() + + link, err := netlink.LinkByName(ifName) + if err != nil { + return fmt.Errorf("error looking up %q: %v", ifName, err) + } + + l.link = link + + if err = l.acquire(); err != nil { + return err + } + + log.Printf("%v: lease acquired, expiration is %v", l.clientID, l.expireTime) + + errCh <- nil + + l.maintain() + return nil + }) + }() + + if err := <-errCh; err != nil { + return nil, err + } + + return l, nil +} + +// Stop terminates the background task that maintains the lease +// and issues a DHCP Release +func (l *DHCPLease) Stop() { + close(l.stop) + l.wg.Wait() +} + +func (l *DHCPLease) acquire() error { + c, err := newDHCPClient(l.link) + if err != nil { + return err + } + defer c.Close() + + if (l.link.Attrs().Flags & net.FlagUp) != net.FlagUp { + log.Printf("Link %q down. Attempting to set up", l.link.Attrs().Name) + if err = netlink.LinkSetUp(l.link); err != nil { + return err + } + } + + pkt, err := backoffRetry(func() (*dhcp4.Packet, error) { + ok, ack, err := c.Request() + switch { + case err != nil: + return nil, err + case !ok: + return nil, fmt.Errorf("DHCP server NACK'd own offer") + default: + return &ack, nil + } + }) + if err != nil { + return err + } + + return l.commit(pkt) +} + +func (l *DHCPLease) commit(ack *dhcp4.Packet) error { + opts := ack.ParseOptions() + + leaseTime, err := parseLeaseTime(opts) + if err != nil { + return err + } + + rebindingTime, err := parseRebindingTime(opts) + if err != nil || rebindingTime > leaseTime { + // Per RFC 2131 Section 4.4.5, it should default to 85% of lease time + rebindingTime = leaseTime * 85 / 100 + } + + renewalTime, err := parseRenewalTime(opts) + if err != nil || renewalTime > rebindingTime { + // Per RFC 2131 Section 4.4.5, it should default to 50% of lease time + renewalTime = leaseTime / 2 + } + + now := time.Now() + l.expireTime = now.Add(leaseTime) + l.renewalTime = now.Add(renewalTime) + l.rebindingTime = now.Add(rebindingTime) + l.ack = ack + l.opts = opts + + return nil +} + +func (l *DHCPLease) maintain() { + state := leaseStateBound + + for { + var sleepDur time.Duration + + switch state { + case leaseStateBound: + sleepDur = l.renewalTime.Sub(time.Now()) + if sleepDur <= 0 { + log.Printf("%v: renewing lease", l.clientID) + state = leaseStateRenewing + continue + } + + case leaseStateRenewing: + if err := l.renew(); err != nil { + log.Printf("%v: %v", l.clientID, err) + + if time.Now().After(l.rebindingTime) { + log.Printf("%v: renawal time expired, rebinding", l.clientID) + state = leaseStateRebinding + } + } else { + log.Printf("%v: lease renewed, expiration is %v", l.clientID, l.expireTime) + state = leaseStateBound + } + + case leaseStateRebinding: + if err := l.acquire(); err != nil { + log.Printf("%v: %v", l.clientID, err) + + if time.Now().After(l.expireTime) { + log.Printf("%v: lease expired, bringing interface DOWN", l.clientID) + l.downIface() + return + } + } else { + log.Printf("%v: lease rebound, expiration is %v", l.clientID, l.expireTime) + state = leaseStateBound + } + } + + select { + case <-time.After(sleepDur): + + case <-l.stop: + if err := l.release(); err != nil { + log.Printf("%v: failed to release DHCP lease: %v", l.clientID, err) + } + return + } + } +} + +func (l *DHCPLease) downIface() { + if err := netlink.LinkSetDown(l.link); err != nil { + log.Printf("%v: failed to bring %v interface DOWN: %v", l.clientID, l.link.Attrs().Name, err) + } +} + +func (l *DHCPLease) renew() error { + c, err := newDHCPClient(l.link) + if err != nil { + return err + } + defer c.Close() + + pkt, err := backoffRetry(func() (*dhcp4.Packet, error) { + ok, ack, err := c.Renew(*l.ack) + switch { + case err != nil: + return nil, err + case !ok: + return nil, fmt.Errorf("DHCP server did not renew lease") + default: + return &ack, nil + } + }) + if err != nil { + return err + } + + l.commit(pkt) + return nil +} + +func (l *DHCPLease) release() error { + log.Printf("%v: releasing lease", l.clientID) + + c, err := newDHCPClient(l.link) + if err != nil { + return err + } + defer c.Close() + + if err = c.Release(*l.ack); err != nil { + return fmt.Errorf("failed to send DHCPRELEASE") + } + + return nil +} + +func (l *DHCPLease) IPNet() (*net.IPNet, error) { + mask := parseSubnetMask(l.opts) + if mask == nil { + return nil, fmt.Errorf("DHCP option Subnet Mask not found in DHCPACK") + } + + return &net.IPNet{ + IP: l.ack.YIAddr(), + Mask: mask, + }, nil +} + +func (l *DHCPLease) Gateway() net.IP { + return parseRouter(l.opts) +} + +func (l *DHCPLease) Routes() []types.Route { + routes := parseRoutes(l.opts) + return append(routes, parseCIDRRoutes(l.opts)...) +} + +// jitter returns a random value within [-span, span) range +func jitter(span time.Duration) time.Duration { + return time.Duration(float64(span) * (2.0*rand.Float64() - 1.0)) +} + +func backoffRetry(f func() (*dhcp4.Packet, error)) (*dhcp4.Packet, error) { + var baseDelay time.Duration = resendDelay0 + + for i := 0; i < resendCount; i++ { + pkt, err := f() + if err == nil { + return pkt, nil + } + + log.Print(err) + + time.Sleep(baseDelay + jitter(time.Second)) + + if baseDelay < resendDelayMax { + baseDelay *= 2 + } + } + + return nil, errNoMoreTries +} + +func newDHCPClient(link netlink.Link) (*dhcp4client.Client, error) { + pktsock, err := dhcp4client.NewPacketSock(link.Attrs().Index) + if err != nil { + return nil, err + } + + return dhcp4client.New( + dhcp4client.HardwareAddr(link.Attrs().HardwareAddr), + dhcp4client.Timeout(5*time.Second), + dhcp4client.Broadcast(false), + dhcp4client.Connection(pktsock), + ) +} diff --git a/vendor/github.com/containernetworking/cni/plugins/ipam/dhcp/main.go b/vendor/github.com/containernetworking/cni/plugins/ipam/dhcp/main.go new file mode 100644 index 0000000000..b537831506 --- /dev/null +++ b/vendor/github.com/containernetworking/cni/plugins/ipam/dhcp/main.go @@ -0,0 +1,73 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "fmt" + "net/rpc" + "os" + "path/filepath" + + "github.com/containernetworking/cni/pkg/skel" + "github.com/containernetworking/cni/pkg/types" +) + +const socketPath = "/run/cni/dhcp.sock" + +func main() { + if len(os.Args) > 1 && os.Args[1] == "daemon" { + runDaemon() + } else { + skel.PluginMain(cmdAdd, cmdDel) + } +} + +func cmdAdd(args *skel.CmdArgs) error { + result := types.Result{} + if err := rpcCall("DHCP.Allocate", args, &result); err != nil { + return err + } + return result.Print() +} + +func cmdDel(args *skel.CmdArgs) error { + result := struct{}{} + if err := rpcCall("DHCP.Release", args, &result); err != nil { + return fmt.Errorf("error dialing DHCP daemon: %v", err) + } + return nil +} + +func rpcCall(method string, args *skel.CmdArgs, result interface{}) error { + client, err := rpc.DialHTTP("unix", socketPath) + if err != nil { + return fmt.Errorf("error dialing DHCP daemon: %v", err) + } + + // The daemon may be running under a different working dir + // so make sure the netns path is absolute. + netns, err := filepath.Abs(args.Netns) + if err != nil { + return fmt.Errorf("failed to make %q an absolute path: %v", args.Netns, err) + } + args.Netns = netns + + err = client.Call(method, args, result) + if err != nil { + return fmt.Errorf("error calling %v: %v", method, err) + } + + return nil +} diff --git a/vendor/github.com/containernetworking/cni/plugins/ipam/dhcp/options.go b/vendor/github.com/containernetworking/cni/plugins/ipam/dhcp/options.go new file mode 100644 index 0000000000..b11ec21d55 --- /dev/null +++ b/vendor/github.com/containernetworking/cni/plugins/ipam/dhcp/options.go @@ -0,0 +1,139 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "encoding/binary" + "fmt" + "net" + "time" + + "github.com/containernetworking/cni/pkg/types" + "github.com/d2g/dhcp4" +) + +func parseRouter(opts dhcp4.Options) net.IP { + if opts, ok := opts[dhcp4.OptionRouter]; ok { + if len(opts) == 4 { + return net.IP(opts) + } + } + return nil +} + +func classfulSubnet(sn net.IP) net.IPNet { + return net.IPNet{ + IP: sn, + Mask: sn.DefaultMask(), + } +} + +func parseRoutes(opts dhcp4.Options) []types.Route { + // StaticRoutes format: pairs of: + // Dest = 4 bytes; Classful IP subnet + // Router = 4 bytes; IP address of router + + routes := []types.Route{} + if opt, ok := opts[dhcp4.OptionStaticRoute]; ok { + for len(opt) >= 8 { + sn := opt[0:4] + r := opt[4:8] + rt := types.Route{ + Dst: classfulSubnet(sn), + GW: r, + } + routes = append(routes, rt) + opt = opt[8:] + } + } + + return routes +} + +func parseCIDRRoutes(opts dhcp4.Options) []types.Route { + // See RFC4332 for format (http://tools.ietf.org/html/rfc3442) + + routes := []types.Route{} + if opt, ok := opts[dhcp4.OptionClasslessRouteFormat]; ok { + for len(opt) >= 5 { + width := int(opt[0]) + if width > 32 { + // error: can't have more than /32 + return nil + } + // network bits are compacted to avoid zeros + octets := 0 + if width > 0 { + octets = (width-1)/8 + 1 + } + + if len(opt) < 1+octets+4 { + // error: too short + return nil + } + + sn := make([]byte, 4) + copy(sn, opt[1:octets+1]) + + gw := net.IP(opt[octets+1 : octets+5]) + + rt := types.Route{ + Dst: net.IPNet{ + IP: net.IP(sn), + Mask: net.CIDRMask(width, 32), + }, + GW: gw, + } + routes = append(routes, rt) + + opt = opt[octets+5 : len(opt)] + } + } + return routes +} + +func parseSubnetMask(opts dhcp4.Options) net.IPMask { + mask, ok := opts[dhcp4.OptionSubnetMask] + if !ok { + return nil + } + + return net.IPMask(mask) +} + +func parseDuration(opts dhcp4.Options, code dhcp4.OptionCode, optName string) (time.Duration, error) { + val, ok := opts[code] + if !ok { + return 0, fmt.Errorf("option %v not found", optName) + } + if len(val) != 4 { + return 0, fmt.Errorf("option %v is not 4 bytes", optName) + } + + secs := binary.BigEndian.Uint32(val) + return time.Duration(secs) * time.Second, nil +} + +func parseLeaseTime(opts dhcp4.Options) (time.Duration, error) { + return parseDuration(opts, dhcp4.OptionIPAddressLeaseTime, "LeaseTime") +} + +func parseRenewalTime(opts dhcp4.Options) (time.Duration, error) { + return parseDuration(opts, dhcp4.OptionRenewalTimeValue, "RenewalTime") +} + +func parseRebindingTime(opts dhcp4.Options) (time.Duration, error) { + return parseDuration(opts, dhcp4.OptionRebindingTimeValue, "RebindingTime") +} diff --git a/vendor/github.com/containernetworking/cni/plugins/ipam/host-local/allocator.go b/vendor/github.com/containernetworking/cni/plugins/ipam/host-local/allocator.go new file mode 100644 index 0000000000..55a3ae6fa4 --- /dev/null +++ b/vendor/github.com/containernetworking/cni/plugins/ipam/host-local/allocator.go @@ -0,0 +1,165 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "fmt" + "net" + + "github.com/containernetworking/cni/pkg/ip" + "github.com/containernetworking/cni/pkg/types" + "github.com/containernetworking/cni/plugins/ipam/host-local/backend" +) + +type IPAllocator struct { + start net.IP + end net.IP + conf *IPAMConfig + store backend.Store +} + +func NewIPAllocator(conf *IPAMConfig, store backend.Store) (*IPAllocator, error) { + var ( + start net.IP + end net.IP + err error + ) + start, end, err = networkRange((*net.IPNet)(&conf.Subnet)) + if err != nil { + return nil, err + } + + // skip the .0 address + start = ip.NextIP(start) + + if conf.RangeStart != nil { + if err := validateRangeIP(conf.RangeStart, (*net.IPNet)(&conf.Subnet)); err != nil { + return nil, err + } + start = conf.RangeStart + } + if conf.RangeEnd != nil { + if err := validateRangeIP(conf.RangeEnd, (*net.IPNet)(&conf.Subnet)); err != nil { + return nil, err + } + // RangeEnd is inclusive + end = ip.NextIP(conf.RangeEnd) + } + + return &IPAllocator{start, end, conf, store}, nil +} + +func validateRangeIP(ip net.IP, ipnet *net.IPNet) error { + if !ipnet.Contains(ip) { + return fmt.Errorf("%s not in network: %s", ip, ipnet) + } + return nil +} + +// Returns newly allocated IP along with its config +func (a *IPAllocator) Get(id string) (*types.IPConfig, error) { + a.store.Lock() + defer a.store.Unlock() + + gw := a.conf.Gateway + if gw == nil { + gw = ip.NextIP(a.conf.Subnet.IP) + } + + var requestedIP net.IP + if a.conf.Args != nil { + requestedIP = a.conf.Args.IP + } + + if requestedIP != nil { + if gw != nil && gw.Equal(a.conf.Args.IP) { + return nil, fmt.Errorf("requested IP must differ gateway IP") + } + + subnet := net.IPNet{ + IP: a.conf.Subnet.IP, + Mask: a.conf.Subnet.Mask, + } + err := validateRangeIP(requestedIP, &subnet) + if err != nil { + return nil, err + } + + reserved, err := a.store.Reserve(id, requestedIP) + if err != nil { + return nil, err + } + + if reserved { + return &types.IPConfig{ + IP: net.IPNet{IP: requestedIP, Mask: a.conf.Subnet.Mask}, + Gateway: gw, + Routes: a.conf.Routes, + }, nil + } + return nil, fmt.Errorf("requested IP address %q is not available in network: %s", requestedIP, a.conf.Name) + } + + for cur := a.start; !cur.Equal(a.end); cur = ip.NextIP(cur) { + // don't allocate gateway IP + if gw != nil && cur.Equal(gw) { + continue + } + + reserved, err := a.store.Reserve(id, cur) + if err != nil { + return nil, err + } + if reserved { + return &types.IPConfig{ + IP: net.IPNet{IP: cur, Mask: a.conf.Subnet.Mask}, + Gateway: gw, + Routes: a.conf.Routes, + }, nil + } + } + return nil, fmt.Errorf("no IP addresses available in network: %s", a.conf.Name) +} + +// Releases all IPs allocated for the container with given ID +func (a *IPAllocator) Release(id string) error { + a.store.Lock() + defer a.store.Unlock() + + return a.store.ReleaseByID(id) +} + +func networkRange(ipnet *net.IPNet) (net.IP, net.IP, error) { + if ipnet.IP == nil { + return nil, nil, fmt.Errorf("missing field %q in IPAM configuration", "subnet") + } + ip := ipnet.IP.To4() + if ip == nil { + ip = ipnet.IP.To16() + if ip == nil { + return nil, nil, fmt.Errorf("IP not v4 nor v6") + } + } + + if len(ip) != len(ipnet.Mask) { + return nil, nil, fmt.Errorf("IPNet IP and Mask version mismatch") + } + + var end net.IP + for i := 0; i < len(ip); i++ { + end = append(end, ip[i]|^ipnet.Mask[i]) + } + return ipnet.IP, end, nil +} diff --git a/vendor/github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk/backend.go b/vendor/github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk/backend.go new file mode 100644 index 0000000000..88dc5e92bc --- /dev/null +++ b/vendor/github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk/backend.go @@ -0,0 +1,88 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package disk + +import ( + "io/ioutil" + "net" + "os" + "path/filepath" +) + +var defaultDataDir = "/var/lib/cni/networks" + +type Store struct { + FileLock + dataDir string +} + +func New(network string) (*Store, error) { + dir := filepath.Join(defaultDataDir, network) + if err := os.MkdirAll(dir, 0644); err != nil { + return nil, err + } + + lk, err := NewFileLock(dir) + if err != nil { + return nil, err + } + return &Store{*lk, dir}, nil +} + +func (s *Store) Reserve(id string, ip net.IP) (bool, error) { + fname := filepath.Join(s.dataDir, ip.String()) + f, err := os.OpenFile(fname, os.O_RDWR|os.O_EXCL|os.O_CREATE, 0644) + if os.IsExist(err) { + return false, nil + } + if err != nil { + return false, err + } + if _, err := f.WriteString(id); err != nil { + f.Close() + os.Remove(f.Name()) + return false, err + } + if err := f.Close(); err != nil { + os.Remove(f.Name()) + return false, err + } + return true, nil +} + +func (s *Store) Release(ip net.IP) error { + return os.Remove(filepath.Join(s.dataDir, ip.String())) +} + +// N.B. This function eats errors to be tolerant and +// release as much as possible +func (s *Store) ReleaseByID(id string) error { + err := filepath.Walk(s.dataDir, func(path string, info os.FileInfo, err error) error { + if err != nil || info.IsDir() { + return nil + } + data, err := ioutil.ReadFile(path) + if err != nil { + return nil + } + if string(data) == id { + if err := os.Remove(path); err != nil { + return nil + } + } + return nil + }) + return err +} diff --git a/vendor/github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk/lock.go b/vendor/github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk/lock.go new file mode 100644 index 0000000000..7241482515 --- /dev/null +++ b/vendor/github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk/lock.go @@ -0,0 +1,50 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package disk + +import ( + "os" + "syscall" +) + +// FileLock wraps os.File to be used as a lock using flock +type FileLock struct { + f *os.File +} + +// NewFileLock opens file/dir at path and returns unlocked FileLock object +func NewFileLock(path string) (*FileLock, error) { + f, err := os.Open(path) + if err != nil { + return nil, err + } + + return &FileLock{f}, nil +} + +// Close closes underlying file +func (l *FileLock) Close() error { + return l.f.Close() +} + +// Lock acquires an exclusive lock +func (l *FileLock) Lock() error { + return syscall.Flock(int(l.f.Fd()), syscall.LOCK_EX) +} + +// Unlock releases the lock +func (l *FileLock) Unlock() error { + return syscall.Flock(int(l.f.Fd()), syscall.LOCK_UN) +} diff --git a/vendor/github.com/containernetworking/cni/plugins/ipam/host-local/backend/store.go b/vendor/github.com/containernetworking/cni/plugins/ipam/host-local/backend/store.go new file mode 100644 index 0000000000..45a89b109c --- /dev/null +++ b/vendor/github.com/containernetworking/cni/plugins/ipam/host-local/backend/store.go @@ -0,0 +1,26 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package backend + +import "net" + +type Store interface { + Lock() error + Unlock() error + Close() error + Reserve(id string, ip net.IP) (bool, error) + Release(ip net.IP) error + ReleaseByID(id string) error +} diff --git a/vendor/github.com/containernetworking/cni/plugins/ipam/host-local/config.go b/vendor/github.com/containernetworking/cni/plugins/ipam/host-local/config.go new file mode 100644 index 0000000000..a0e493cd84 --- /dev/null +++ b/vendor/github.com/containernetworking/cni/plugins/ipam/host-local/config.go @@ -0,0 +1,70 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "encoding/json" + "fmt" + "net" + + "github.com/containernetworking/cni/pkg/types" +) + +// IPAMConfig represents the IP related network configuration. +type IPAMConfig struct { + Name string + Type string `json:"type"` + RangeStart net.IP `json:"rangeStart"` + RangeEnd net.IP `json:"rangeEnd"` + Subnet types.IPNet `json:"subnet"` + Gateway net.IP `json:"gateway"` + Routes []types.Route `json:"routes"` + Args *IPAMArgs `json:"-"` +} + +type IPAMArgs struct { + types.CommonArgs + IP net.IP `json:"ip,omitempty"` +} + +type Net struct { + Name string `json:"name"` + IPAM *IPAMConfig `json:"ipam"` +} + +// NewIPAMConfig creates a NetworkConfig from the given network name. +func LoadIPAMConfig(bytes []byte, args string) (*IPAMConfig, error) { + n := Net{} + if err := json.Unmarshal(bytes, &n); err != nil { + return nil, err + } + + if args != "" { + n.IPAM.Args = &IPAMArgs{} + err := types.LoadArgs(args, n.IPAM.Args) + if err != nil { + return nil, err + } + } + + if n.IPAM == nil { + return nil, fmt.Errorf("%q missing 'ipam' key") + } + + // Copy net name into IPAM so not to drag Net struct around + n.IPAM.Name = n.Name + + return n.IPAM, nil +} diff --git a/vendor/github.com/containernetworking/cni/plugins/ipam/host-local/main.go b/vendor/github.com/containernetworking/cni/plugins/ipam/host-local/main.go new file mode 100644 index 0000000000..d2f3c305a5 --- /dev/null +++ b/vendor/github.com/containernetworking/cni/plugins/ipam/host-local/main.go @@ -0,0 +1,74 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk" + + "github.com/containernetworking/cni/pkg/skel" + "github.com/containernetworking/cni/pkg/types" +) + +func main() { + skel.PluginMain(cmdAdd, cmdDel) +} + +func cmdAdd(args *skel.CmdArgs) error { + ipamConf, err := LoadIPAMConfig(args.StdinData, args.Args) + if err != nil { + return err + } + + store, err := disk.New(ipamConf.Name) + if err != nil { + return err + } + defer store.Close() + + allocator, err := NewIPAllocator(ipamConf, store) + if err != nil { + return err + } + + ipConf, err := allocator.Get(args.ContainerID) + if err != nil { + return err + } + + r := &types.Result{ + IP4: ipConf, + } + return r.Print() +} + +func cmdDel(args *skel.CmdArgs) error { + ipamConf, err := LoadIPAMConfig(args.StdinData, args.Args) + if err != nil { + return err + } + + store, err := disk.New(ipamConf.Name) + if err != nil { + return err + } + defer store.Close() + + allocator, err := NewIPAllocator(ipamConf, store) + if err != nil { + return err + } + + return allocator.Release(args.ContainerID) +} diff --git a/vendor/github.com/containernetworking/cni/plugins/main/bridge/bridge.go b/vendor/github.com/containernetworking/cni/plugins/main/bridge/bridge.go new file mode 100644 index 0000000000..d4fc89c3aa --- /dev/null +++ b/vendor/github.com/containernetworking/cni/plugins/main/bridge/bridge.go @@ -0,0 +1,319 @@ +// Copyright 2014 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "encoding/json" + "errors" + "fmt" + "net" + "runtime" + "syscall" + + "github.com/containernetworking/cni/pkg/ip" + "github.com/containernetworking/cni/pkg/ipam" + "github.com/containernetworking/cni/pkg/ns" + "github.com/containernetworking/cni/pkg/skel" + "github.com/containernetworking/cni/pkg/types" + "github.com/containernetworking/cni/pkg/utils" + "github.com/vishvananda/netlink" +) + +const defaultBrName = "cni0" + +type NetConf struct { + types.NetConf + BrName string `json:"bridge"` + IsGW bool `json:"isGateway"` + IsDefaultGW bool `json:"isDefaultGateway"` + IPMasq bool `json:"ipMasq"` + MTU int `json:"mtu"` + HairpinMode bool `json:"hairpinMode"` +} + +func init() { + // this ensures that main runs only on main thread (thread group leader). + // since namespace ops (unshare, setns) are done for a single thread, we + // must ensure that the goroutine does not jump from OS thread to thread + runtime.LockOSThread() +} + +func loadNetConf(bytes []byte) (*NetConf, error) { + n := &NetConf{ + BrName: defaultBrName, + } + if err := json.Unmarshal(bytes, n); err != nil { + return nil, fmt.Errorf("failed to load netconf: %v", err) + } + return n, nil +} + +func ensureBridgeAddr(br *netlink.Bridge, ipn *net.IPNet) error { + addrs, err := netlink.AddrList(br, syscall.AF_INET) + if err != nil && err != syscall.ENOENT { + return fmt.Errorf("could not get list of IP addresses: %v", err) + } + + // if there're no addresses on the bridge, it's ok -- we'll add one + if len(addrs) > 0 { + ipnStr := ipn.String() + for _, a := range addrs { + // string comp is actually easiest for doing IPNet comps + if a.IPNet.String() == ipnStr { + return nil + } + } + return fmt.Errorf("%q already has an IP address different from %v", br.Name, ipn.String()) + } + + addr := &netlink.Addr{IPNet: ipn, Label: ""} + if err := netlink.AddrAdd(br, addr); err != nil { + return fmt.Errorf("could not add IP address to %q: %v", br.Name, err) + } + return nil +} + +func bridgeByName(name string) (*netlink.Bridge, error) { + l, err := netlink.LinkByName(name) + if err != nil { + return nil, fmt.Errorf("could not lookup %q: %v", name, err) + } + br, ok := l.(*netlink.Bridge) + if !ok { + return nil, fmt.Errorf("%q already exists but is not a bridge", name) + } + return br, nil +} + +func ensureBridge(brName string, mtu int) (*netlink.Bridge, error) { + br := &netlink.Bridge{ + LinkAttrs: netlink.LinkAttrs{ + Name: brName, + MTU: mtu, + // Let kernel use default txqueuelen; leaving it unset + // means 0, and a zero-length TX queue messes up FIFO + // traffic shapers which use TX queue length as the + // default packet limit + TxQLen: -1, + }, + } + + if err := netlink.LinkAdd(br); err != nil { + if err != syscall.EEXIST { + return nil, fmt.Errorf("could not add %q: %v", brName, err) + } + + // it's ok if the device already exists as long as config is similar + br, err = bridgeByName(brName) + if err != nil { + return nil, err + } + } + + if err := netlink.LinkSetUp(br); err != nil { + return nil, err + } + + return br, nil +} + +func setupVeth(netns ns.NetNS, br *netlink.Bridge, ifName string, mtu int, hairpinMode bool) error { + var hostVethName string + + err := netns.Do(func(hostNS ns.NetNS) error { + // create the veth pair in the container and move host end into host netns + hostVeth, _, err := ip.SetupVeth(ifName, mtu, hostNS) + if err != nil { + return err + } + + hostVethName = hostVeth.Attrs().Name + return nil + }) + if err != nil { + return err + } + + // need to lookup hostVeth again as its index has changed during ns move + hostVeth, err := netlink.LinkByName(hostVethName) + if err != nil { + return fmt.Errorf("failed to lookup %q: %v", hostVethName, err) + } + + // connect host veth end to the bridge + if err = netlink.LinkSetMaster(hostVeth, br); err != nil { + return fmt.Errorf("failed to connect %q to bridge %v: %v", hostVethName, br.Attrs().Name, err) + } + + // set hairpin mode + if err = netlink.LinkSetHairpin(hostVeth, hairpinMode); err != nil { + return fmt.Errorf("failed to setup hairpin mode for %v: %v", hostVethName, err) + } + + return nil +} + +func calcGatewayIP(ipn *net.IPNet) net.IP { + nid := ipn.IP.Mask(ipn.Mask) + return ip.NextIP(nid) +} + +func setupBridge(n *NetConf) (*netlink.Bridge, error) { + // create bridge if necessary + br, err := ensureBridge(n.BrName, n.MTU) + if err != nil { + return nil, fmt.Errorf("failed to create bridge %q: %v", n.BrName, err) + } + + return br, nil +} + +func cmdAdd(args *skel.CmdArgs) error { + n, err := loadNetConf(args.StdinData) + if err != nil { + return err + } + + if n.IsDefaultGW { + n.IsGW = true + } + + br, err := setupBridge(n) + if err != nil { + return err + } + + netns, err := ns.GetNS(args.Netns) + if err != nil { + return fmt.Errorf("failed to open netns %q: %v", args.Netns, err) + } + defer netns.Close() + + if err = setupVeth(netns, br, args.IfName, n.MTU, n.HairpinMode); err != nil { + return err + } + + // run the IPAM plugin and get back the config to apply + result, err := ipam.ExecAdd(n.IPAM.Type, args.StdinData) + if err != nil { + return err + } + + // TODO: make this optional when IPv6 is supported + if result.IP4 == nil { + return errors.New("IPAM plugin returned missing IPv4 config") + } + + if result.IP4.Gateway == nil && n.IsGW { + result.IP4.Gateway = calcGatewayIP(&result.IP4.IP) + } + + if err := netns.Do(func(_ ns.NetNS) error { + // set the default gateway if requested + if n.IsDefaultGW { + _, defaultNet, err := net.ParseCIDR("0.0.0.0/0") + if err != nil { + return err + } + + for _, route := range result.IP4.Routes { + if defaultNet.String() == route.Dst.String() { + if route.GW != nil && !route.GW.Equal(result.IP4.Gateway) { + return fmt.Errorf( + "isDefaultGateway ineffective because IPAM sets default route via %q", + route.GW, + ) + } + } + } + + result.IP4.Routes = append( + result.IP4.Routes, + types.Route{Dst: *defaultNet, GW: result.IP4.Gateway}, + ) + + // TODO: IPV6 + } + + return ipam.ConfigureIface(args.IfName, result) + }); err != nil { + return err + } + + if n.IsGW { + gwn := &net.IPNet{ + IP: result.IP4.Gateway, + Mask: result.IP4.IP.Mask, + } + + if err = ensureBridgeAddr(br, gwn); err != nil { + return err + } + + if err := ip.EnableIP4Forward(); err != nil { + return fmt.Errorf("failed to enable forwarding: %v", err) + } + } + + if n.IPMasq { + chain := utils.FormatChainName(n.Name, args.ContainerID) + comment := utils.FormatComment(n.Name, args.ContainerID) + if err = ip.SetupIPMasq(ip.Network(&result.IP4.IP), chain, comment); err != nil { + return err + } + } + + result.DNS = n.DNS + return result.Print() +} + +func cmdDel(args *skel.CmdArgs) error { + n, err := loadNetConf(args.StdinData) + if err != nil { + return err + } + + if err := ipam.ExecDel(n.IPAM.Type, args.StdinData); err != nil { + return err + } + + if args.Netns == "" { + return nil + } + + var ipn *net.IPNet + err = ns.WithNetNSPath(args.Netns, func(_ ns.NetNS) error { + var err error + ipn, err = ip.DelLinkByNameAddr(args.IfName, netlink.FAMILY_V4) + return err + }) + if err != nil { + return err + } + + if n.IPMasq { + chain := utils.FormatChainName(n.Name, args.ContainerID) + comment := utils.FormatComment(n.Name, args.ContainerID) + if err = ip.TeardownIPMasq(ipn, chain, comment); err != nil { + return err + } + } + + return nil +} + +func main() { + skel.PluginMain(cmdAdd, cmdDel) +} diff --git a/vendor/github.com/containernetworking/cni/plugins/main/ipvlan/ipvlan.go b/vendor/github.com/containernetworking/cni/plugins/main/ipvlan/ipvlan.go new file mode 100644 index 0000000000..d7cfc39f4e --- /dev/null +++ b/vendor/github.com/containernetworking/cni/plugins/main/ipvlan/ipvlan.go @@ -0,0 +1,175 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "encoding/json" + "errors" + "fmt" + "runtime" + + "github.com/containernetworking/cni/pkg/ip" + "github.com/containernetworking/cni/pkg/ipam" + "github.com/containernetworking/cni/pkg/ns" + "github.com/containernetworking/cni/pkg/skel" + "github.com/containernetworking/cni/pkg/types" + "github.com/vishvananda/netlink" +) + +type NetConf struct { + types.NetConf + Master string `json:"master"` + Mode string `json:"mode"` + MTU int `json:"mtu"` +} + +func init() { + // this ensures that main runs only on main thread (thread group leader). + // since namespace ops (unshare, setns) are done for a single thread, we + // must ensure that the goroutine does not jump from OS thread to thread + runtime.LockOSThread() +} + +func loadConf(bytes []byte) (*NetConf, error) { + n := &NetConf{} + if err := json.Unmarshal(bytes, n); err != nil { + return nil, fmt.Errorf("failed to load netconf: %v", err) + } + if n.Master == "" { + return nil, fmt.Errorf(`"master" field is required. It specifies the host interface name to virtualize`) + } + return n, nil +} + +func modeFromString(s string) (netlink.IPVlanMode, error) { + switch s { + case "", "l2": + return netlink.IPVLAN_MODE_L2, nil + case "l3": + return netlink.IPVLAN_MODE_L3, nil + default: + return 0, fmt.Errorf("unknown ipvlan mode: %q", s) + } +} + +func createIpvlan(conf *NetConf, ifName string, netns ns.NetNS) error { + mode, err := modeFromString(conf.Mode) + if err != nil { + return err + } + + m, err := netlink.LinkByName(conf.Master) + if err != nil { + return fmt.Errorf("failed to lookup master %q: %v", conf.Master, err) + } + + // due to kernel bug we have to create with tmpname or it might + // collide with the name on the host and error out + tmpName, err := ip.RandomVethName() + if err != nil { + return err + } + + mv := &netlink.IPVlan{ + LinkAttrs: netlink.LinkAttrs{ + MTU: conf.MTU, + Name: tmpName, + ParentIndex: m.Attrs().Index, + Namespace: netlink.NsFd(int(netns.Fd())), + }, + Mode: mode, + } + + if err := netlink.LinkAdd(mv); err != nil { + return fmt.Errorf("failed to create ipvlan: %v", err) + } + + return netns.Do(func(_ ns.NetNS) error { + err := renameLink(tmpName, ifName) + if err != nil { + return fmt.Errorf("failed to rename ipvlan to %q: %v", ifName, err) + } + return nil + }) +} + +func cmdAdd(args *skel.CmdArgs) error { + n, err := loadConf(args.StdinData) + if err != nil { + return err + } + + netns, err := ns.GetNS(args.Netns) + if err != nil { + return fmt.Errorf("failed to open netns %q: %v", args.Netns, err) + } + defer netns.Close() + + if err = createIpvlan(n, args.IfName, netns); err != nil { + return err + } + + // run the IPAM plugin and get back the config to apply + result, err := ipam.ExecAdd(n.IPAM.Type, args.StdinData) + if err != nil { + return err + } + if result.IP4 == nil { + return errors.New("IPAM plugin returned missing IPv4 config") + } + + err = netns.Do(func(_ ns.NetNS) error { + return ipam.ConfigureIface(args.IfName, result) + }) + if err != nil { + return err + } + + result.DNS = n.DNS + return result.Print() +} + +func cmdDel(args *skel.CmdArgs) error { + n, err := loadConf(args.StdinData) + if err != nil { + return err + } + + err = ipam.ExecDel(n.IPAM.Type, args.StdinData) + if err != nil { + return err + } + + if args.Netns == "" { + return nil + } + + return ns.WithNetNSPath(args.Netns, func(_ ns.NetNS) error { + return ip.DelLinkByName(args.IfName) + }) +} + +func renameLink(curName, newName string) error { + link, err := netlink.LinkByName(curName) + if err != nil { + return err + } + + return netlink.LinkSetName(link, newName) +} + +func main() { + skel.PluginMain(cmdAdd, cmdDel) +} diff --git a/vendor/github.com/containernetworking/cni/plugins/main/macvlan/macvlan.go b/vendor/github.com/containernetworking/cni/plugins/main/macvlan/macvlan.go new file mode 100644 index 0000000000..7739d7b8eb --- /dev/null +++ b/vendor/github.com/containernetworking/cni/plugins/main/macvlan/macvlan.go @@ -0,0 +1,193 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "encoding/json" + "errors" + "fmt" + "runtime" + + "github.com/containernetworking/cni/pkg/ip" + "github.com/containernetworking/cni/pkg/ipam" + "github.com/containernetworking/cni/pkg/ns" + "github.com/containernetworking/cni/pkg/skel" + "github.com/containernetworking/cni/pkg/types" + "github.com/containernetworking/cni/pkg/utils/sysctl" + "github.com/vishvananda/netlink" +) + +const ( + IPv4InterfaceArpProxySysctlTemplate = "net.ipv4.conf.%s.proxy_arp" +) + +type NetConf struct { + types.NetConf + Master string `json:"master"` + Mode string `json:"mode"` + MTU int `json:"mtu"` +} + +func init() { + // this ensures that main runs only on main thread (thread group leader). + // since namespace ops (unshare, setns) are done for a single thread, we + // must ensure that the goroutine does not jump from OS thread to thread + runtime.LockOSThread() +} + +func loadConf(bytes []byte) (*NetConf, error) { + n := &NetConf{} + if err := json.Unmarshal(bytes, n); err != nil { + return nil, fmt.Errorf("failed to load netconf: %v", err) + } + if n.Master == "" { + return nil, fmt.Errorf(`"master" field is required. It specifies the host interface name to virtualize`) + } + return n, nil +} + +func modeFromString(s string) (netlink.MacvlanMode, error) { + switch s { + case "", "bridge": + return netlink.MACVLAN_MODE_BRIDGE, nil + case "private": + return netlink.MACVLAN_MODE_PRIVATE, nil + case "vepa": + return netlink.MACVLAN_MODE_VEPA, nil + case "passthru": + return netlink.MACVLAN_MODE_PASSTHRU, nil + default: + return 0, fmt.Errorf("unknown macvlan mode: %q", s) + } +} + +func createMacvlan(conf *NetConf, ifName string, netns ns.NetNS) error { + mode, err := modeFromString(conf.Mode) + if err != nil { + return err + } + + m, err := netlink.LinkByName(conf.Master) + if err != nil { + return fmt.Errorf("failed to lookup master %q: %v", conf.Master, err) + } + + // due to kernel bug we have to create with tmpName or it might + // collide with the name on the host and error out + tmpName, err := ip.RandomVethName() + if err != nil { + return err + } + + mv := &netlink.Macvlan{ + LinkAttrs: netlink.LinkAttrs{ + MTU: conf.MTU, + Name: tmpName, + ParentIndex: m.Attrs().Index, + Namespace: netlink.NsFd(int(netns.Fd())), + }, + Mode: mode, + } + + if err := netlink.LinkAdd(mv); err != nil { + return fmt.Errorf("failed to create macvlan: %v", err) + } + + return netns.Do(func(_ ns.NetNS) error { + // TODO: duplicate following lines for ipv6 support, when it will be added in other places + ipv4SysctlValueName := fmt.Sprintf(IPv4InterfaceArpProxySysctlTemplate, tmpName) + if _, err := sysctl.Sysctl(ipv4SysctlValueName, "1"); err != nil { + // remove the newly added link and ignore errors, because we already are in a failed state + _ = netlink.LinkDel(mv) + return fmt.Errorf("failed to set proxy_arp on newly added interface %q: %v", tmpName, err) + } + + err := renameLink(tmpName, ifName) + if err != nil { + _ = netlink.LinkDel(mv) + return fmt.Errorf("failed to rename macvlan to %q: %v", ifName, err) + } + return nil + }) +} + +func cmdAdd(args *skel.CmdArgs) error { + n, err := loadConf(args.StdinData) + if err != nil { + return err + } + + netns, err := ns.GetNS(args.Netns) + if err != nil { + return fmt.Errorf("failed to open netns %q: %v", netns, err) + } + defer netns.Close() + + if err = createMacvlan(n, args.IfName, netns); err != nil { + return err + } + + // run the IPAM plugin and get back the config to apply + result, err := ipam.ExecAdd(n.IPAM.Type, args.StdinData) + if err != nil { + return err + } + if result.IP4 == nil { + return errors.New("IPAM plugin returned missing IPv4 config") + } + + err = netns.Do(func(_ ns.NetNS) error { + return ipam.ConfigureIface(args.IfName, result) + }) + if err != nil { + return err + } + + result.DNS = n.DNS + return result.Print() +} + +func cmdDel(args *skel.CmdArgs) error { + n, err := loadConf(args.StdinData) + if err != nil { + return err + } + + err = ipam.ExecDel(n.IPAM.Type, args.StdinData) + if err != nil { + return err + } + + if args.Netns == "" { + return nil + } + + return ns.WithNetNSPath(args.Netns, func(_ ns.NetNS) error { + return ip.DelLinkByName(args.IfName) + }) +} + +func renameLink(curName, newName string) error { + link, err := netlink.LinkByName(curName) + if err != nil { + return err + } + + return netlink.LinkSetName(link, newName) +} + +func main() { + skel.PluginMain(cmdAdd, cmdDel) +} diff --git a/vendor/github.com/containernetworking/cni/plugins/main/ptp/ptp.go b/vendor/github.com/containernetworking/cni/plugins/main/ptp/ptp.go new file mode 100644 index 0000000000..aa695e39e2 --- /dev/null +++ b/vendor/github.com/containernetworking/cni/plugins/main/ptp/ptp.go @@ -0,0 +1,229 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "encoding/json" + "errors" + "fmt" + "net" + "os" + "runtime" + + "github.com/vishvananda/netlink" + + "github.com/containernetworking/cni/pkg/ip" + "github.com/containernetworking/cni/pkg/ipam" + "github.com/containernetworking/cni/pkg/ns" + "github.com/containernetworking/cni/pkg/skel" + "github.com/containernetworking/cni/pkg/types" + "github.com/containernetworking/cni/pkg/utils" +) + +func init() { + // this ensures that main runs only on main thread (thread group leader). + // since namespace ops (unshare, setns) are done for a single thread, we + // must ensure that the goroutine does not jump from OS thread to thread + runtime.LockOSThread() +} + +type NetConf struct { + types.NetConf + IPMasq bool `json:"ipMasq"` + MTU int `json:"mtu"` +} + +func setupContainerVeth(netns, ifName string, mtu int, pr *types.Result) (string, error) { + // The IPAM result will be something like IP=192.168.3.5/24, GW=192.168.3.1. + // What we want is really a point-to-point link but veth does not support IFF_POINTOPONT. + // Next best thing would be to let it ARP but set interface to 192.168.3.5/32 and + // add a route like "192.168.3.0/24 via 192.168.3.1 dev $ifName". + // Unfortunately that won't work as the GW will be outside the interface's subnet. + + // Our solution is to configure the interface with 192.168.3.5/24, then delete the + // "192.168.3.0/24 dev $ifName" route that was automatically added. Then we add + // "192.168.3.1/32 dev $ifName" and "192.168.3.0/24 via 192.168.3.1 dev $ifName". + // In other words we force all traffic to ARP via the gateway except for GW itself. + + var hostVethName string + err := ns.WithNetNSPath(netns, func(hostNS ns.NetNS) error { + hostVeth, _, err := ip.SetupVeth(ifName, mtu, hostNS) + if err != nil { + return err + } + + if err = ipam.ConfigureIface(ifName, pr); err != nil { + return err + } + + contVeth, err := netlink.LinkByName(ifName) + if err != nil { + return fmt.Errorf("failed to look up %q: %v", ifName, err) + } + + // Delete the route that was automatically added + route := netlink.Route{ + LinkIndex: contVeth.Attrs().Index, + Dst: &net.IPNet{ + IP: pr.IP4.IP.IP.Mask(pr.IP4.IP.Mask), + Mask: pr.IP4.IP.Mask, + }, + Scope: netlink.SCOPE_NOWHERE, + } + + if err := netlink.RouteDel(&route); err != nil { + return fmt.Errorf("failed to delete route %v: %v", route, err) + } + + for _, r := range []netlink.Route{ + netlink.Route{ + LinkIndex: contVeth.Attrs().Index, + Dst: &net.IPNet{ + IP: pr.IP4.Gateway, + Mask: net.CIDRMask(32, 32), + }, + Scope: netlink.SCOPE_LINK, + Src: pr.IP4.IP.IP, + }, + netlink.Route{ + LinkIndex: contVeth.Attrs().Index, + Dst: &net.IPNet{ + IP: pr.IP4.IP.IP.Mask(pr.IP4.IP.Mask), + Mask: pr.IP4.IP.Mask, + }, + Scope: netlink.SCOPE_UNIVERSE, + Gw: pr.IP4.Gateway, + Src: pr.IP4.IP.IP, + }, + } { + if err := netlink.RouteAdd(&r); err != nil { + return fmt.Errorf("failed to add route %v: %v", r, err) + } + } + + hostVethName = hostVeth.Attrs().Name + + return nil + }) + return hostVethName, err +} + +func setupHostVeth(vethName string, ipConf *types.IPConfig) error { + // hostVeth moved namespaces and may have a new ifindex + veth, err := netlink.LinkByName(vethName) + if err != nil { + return fmt.Errorf("failed to lookup %q: %v", vethName, err) + } + + // TODO(eyakubovich): IPv6 + ipn := &net.IPNet{ + IP: ipConf.Gateway, + Mask: net.CIDRMask(32, 32), + } + addr := &netlink.Addr{IPNet: ipn, Label: ""} + if err = netlink.AddrAdd(veth, addr); err != nil { + return fmt.Errorf("failed to add IP addr (%#v) to veth: %v", ipn, err) + } + + ipn = &net.IPNet{ + IP: ipConf.IP.IP, + Mask: net.CIDRMask(32, 32), + } + // dst happens to be the same as IP/net of host veth + if err = ip.AddHostRoute(ipn, nil, veth); err != nil && !os.IsExist(err) { + return fmt.Errorf("failed to add route on host: %v", err) + } + + return nil +} + +func cmdAdd(args *skel.CmdArgs) error { + conf := NetConf{} + if err := json.Unmarshal(args.StdinData, &conf); err != nil { + return fmt.Errorf("failed to load netconf: %v", err) + } + + if err := ip.EnableIP4Forward(); err != nil { + return fmt.Errorf("failed to enable forwarding: %v", err) + } + + // run the IPAM plugin and get back the config to apply + result, err := ipam.ExecAdd(conf.IPAM.Type, args.StdinData) + if err != nil { + return err + } + if result.IP4 == nil { + return errors.New("IPAM plugin returned missing IPv4 config") + } + + hostVethName, err := setupContainerVeth(args.Netns, args.IfName, conf.MTU, result) + if err != nil { + return err + } + + if err = setupHostVeth(hostVethName, result.IP4); err != nil { + return err + } + + if conf.IPMasq { + chain := utils.FormatChainName(conf.Name, args.ContainerID) + comment := utils.FormatComment(conf.Name, args.ContainerID) + if err = ip.SetupIPMasq(&result.IP4.IP, chain, comment); err != nil { + return err + } + } + + result.DNS = conf.DNS + return result.Print() +} + +func cmdDel(args *skel.CmdArgs) error { + conf := NetConf{} + if err := json.Unmarshal(args.StdinData, &conf); err != nil { + return fmt.Errorf("failed to load netconf: %v", err) + } + + if err := ipam.ExecDel(conf.IPAM.Type, args.StdinData); err != nil { + return err + } + + if args.Netns == "" { + return nil + } + + var ipn *net.IPNet + err := ns.WithNetNSPath(args.Netns, func(_ ns.NetNS) error { + var err error + ipn, err = ip.DelLinkByNameAddr(args.IfName, netlink.FAMILY_V4) + return err + }) + if err != nil { + return err + } + + if conf.IPMasq { + chain := utils.FormatChainName(conf.Name, args.ContainerID) + comment := utils.FormatComment(conf.Name, args.ContainerID) + if err = ip.TeardownIPMasq(ipn, chain, comment); err != nil { + return err + } + } + + return nil +} + +func main() { + skel.PluginMain(cmdAdd, cmdDel) +} diff --git a/vendor/github.com/containernetworking/cni/plugins/meta/flannel/flannel.go b/vendor/github.com/containernetworking/cni/plugins/meta/flannel/flannel.go new file mode 100644 index 0000000000..096fe6d677 --- /dev/null +++ b/vendor/github.com/containernetworking/cni/plugins/meta/flannel/flannel.go @@ -0,0 +1,253 @@ +// Copyright 2015 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This is a "meta-plugin". It reads in its own netconf, combines it with +// the data from flannel generated subnet file and then invokes a plugin +// like bridge or ipvlan to do the real work. + +package main + +import ( + "bufio" + "encoding/json" + "fmt" + "io/ioutil" + "net" + "os" + "path/filepath" + "strconv" + "strings" + + "github.com/containernetworking/cni/pkg/invoke" + "github.com/containernetworking/cni/pkg/skel" + "github.com/containernetworking/cni/pkg/types" +) + +const ( + defaultSubnetFile = "/run/flannel/subnet.env" + stateDir = "/var/lib/cni/flannel" +) + +type NetConf struct { + types.NetConf + SubnetFile string `json:"subnetFile"` + Delegate map[string]interface{} `json:"delegate"` +} + +type subnetEnv struct { + nw *net.IPNet + sn *net.IPNet + mtu *uint + ipmasq *bool +} + +func (se *subnetEnv) missing() string { + m := []string{} + + if se.nw == nil { + m = append(m, "FLANNEL_NETWORK") + } + if se.sn == nil { + m = append(m, "FLANNEL_SUBNET") + } + if se.mtu == nil { + m = append(m, "FLANNEL_MTU") + } + if se.ipmasq == nil { + m = append(m, "FLANNEL_IPMASQ") + } + return strings.Join(m, ", ") +} + +func loadFlannelNetConf(bytes []byte) (*NetConf, error) { + n := &NetConf{ + SubnetFile: defaultSubnetFile, + } + if err := json.Unmarshal(bytes, n); err != nil { + return nil, fmt.Errorf("failed to load netconf: %v", err) + } + return n, nil +} + +func loadFlannelSubnetEnv(fn string) (*subnetEnv, error) { + f, err := os.Open(fn) + if err != nil { + return nil, err + } + defer f.Close() + + se := &subnetEnv{} + + s := bufio.NewScanner(f) + for s.Scan() { + parts := strings.SplitN(s.Text(), "=", 2) + switch parts[0] { + case "FLANNEL_NETWORK": + _, se.nw, err = net.ParseCIDR(parts[1]) + if err != nil { + return nil, err + } + + case "FLANNEL_SUBNET": + _, se.sn, err = net.ParseCIDR(parts[1]) + if err != nil { + return nil, err + } + + case "FLANNEL_MTU": + mtu, err := strconv.ParseUint(parts[1], 10, 32) + if err != nil { + return nil, err + } + se.mtu = new(uint) + *se.mtu = uint(mtu) + + case "FLANNEL_IPMASQ": + ipmasq := parts[1] == "true" + se.ipmasq = &ipmasq + } + } + if err := s.Err(); err != nil { + return nil, err + } + + if m := se.missing(); m != "" { + return nil, fmt.Errorf("%v is missing %v", fn, m) + } + + return se, nil +} + +func saveScratchNetConf(containerID string, netconf []byte) error { + if err := os.MkdirAll(stateDir, 0700); err != nil { + return err + } + path := filepath.Join(stateDir, containerID) + return ioutil.WriteFile(path, netconf, 0600) +} + +func consumeScratchNetConf(containerID string) ([]byte, error) { + path := filepath.Join(stateDir, containerID) + defer os.Remove(path) + + return ioutil.ReadFile(path) +} + +func delegateAdd(cid string, netconf map[string]interface{}) error { + netconfBytes, err := json.Marshal(netconf) + if err != nil { + return fmt.Errorf("error serializing delegate netconf: %v", err) + } + + // save the rendered netconf for cmdDel + if err = saveScratchNetConf(cid, netconfBytes); err != nil { + return err + } + + result, err := invoke.DelegateAdd(netconf["type"].(string), netconfBytes) + if err != nil { + return err + } + + return result.Print() +} + +func hasKey(m map[string]interface{}, k string) bool { + _, ok := m[k] + return ok +} + +func isString(i interface{}) bool { + _, ok := i.(string) + return ok +} + +func cmdAdd(args *skel.CmdArgs) error { + n, err := loadFlannelNetConf(args.StdinData) + if err != nil { + return err + } + + fenv, err := loadFlannelSubnetEnv(n.SubnetFile) + if err != nil { + return err + } + + if n.Delegate == nil { + n.Delegate = make(map[string]interface{}) + } else { + if hasKey(n.Delegate, "type") && !isString(n.Delegate["type"]) { + return fmt.Errorf("'delegate' dictionary, if present, must have (string) 'type' field") + } + if hasKey(n.Delegate, "name") { + return fmt.Errorf("'delegate' dictionary must not have 'name' field, it'll be set by flannel") + } + if hasKey(n.Delegate, "ipam") { + return fmt.Errorf("'delegate' dictionary must not have 'ipam' field, it'll be set by flannel") + } + } + + n.Delegate["name"] = n.Name + + if !hasKey(n.Delegate, "type") { + n.Delegate["type"] = "bridge" + } + + if !hasKey(n.Delegate, "ipMasq") { + // if flannel is not doing ipmasq, we should + ipmasq := !*fenv.ipmasq + n.Delegate["ipMasq"] = ipmasq + } + + if !hasKey(n.Delegate, "mtu") { + mtu := fenv.mtu + n.Delegate["mtu"] = mtu + } + + if n.Delegate["type"].(string) == "bridge" { + if !hasKey(n.Delegate, "isGateway") { + n.Delegate["isGateway"] = true + } + } + + n.Delegate["ipam"] = map[string]interface{}{ + "type": "host-local", + "subnet": fenv.sn.String(), + "routes": []types.Route{ + types.Route{ + Dst: *fenv.nw, + }, + }, + } + + return delegateAdd(args.ContainerID, n.Delegate) +} + +func cmdDel(args *skel.CmdArgs) error { + netconfBytes, err := consumeScratchNetConf(args.ContainerID) + if err != nil { + return err + } + + n := &types.NetConf{} + if err = json.Unmarshal(netconfBytes, n); err != nil { + return fmt.Errorf("failed to parse netconf: %v", err) + } + + return invoke.DelegateDel(n.Type, netconfBytes) +} + +func main() { + skel.PluginMain(cmdAdd, cmdDel) +} diff --git a/vendor/github.com/containernetworking/cni/plugins/meta/tuning/tuning.go b/vendor/github.com/containernetworking/cni/plugins/meta/tuning/tuning.go new file mode 100644 index 0000000000..75ba852c00 --- /dev/null +++ b/vendor/github.com/containernetworking/cni/plugins/meta/tuning/tuning.go @@ -0,0 +1,82 @@ +// Copyright 2016 CNI authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This is a "meta-plugin". It reads in its own netconf, it does not create +// any network interface but just changes the network sysctl. + +package main + +import ( + "encoding/json" + "fmt" + "io/ioutil" + "path/filepath" + "strings" + + "github.com/containernetworking/cni/pkg/ns" + "github.com/containernetworking/cni/pkg/skel" + "github.com/containernetworking/cni/pkg/types" +) + +// TuningConf represents the network tuning configuration. +type TuningConf struct { + types.NetConf + SysCtl map[string]string `json:"sysctl"` +} + +func cmdAdd(args *skel.CmdArgs) error { + tuningConf := TuningConf{} + if err := json.Unmarshal(args.StdinData, &tuningConf); err != nil { + return fmt.Errorf("failed to load netconf: %v", err) + } + + // The directory /proc/sys/net is per network namespace. Enter in the + // network namespace before writing on it. + + err := ns.WithNetNSPath(args.Netns, func(_ ns.NetNS) error { + for key, value := range tuningConf.SysCtl { + fileName := filepath.Join("/proc/sys", strings.Replace(key, ".", "/", -1)) + fileName = filepath.Clean(fileName) + + // Refuse to modify sysctl parameters that don't belong + // to the network subsystem. + if !strings.HasPrefix(fileName, "/proc/sys/net/") { + return fmt.Errorf("invalid net sysctl key: %q", key) + } + content := []byte(value) + err := ioutil.WriteFile(fileName, content, 0644) + if err != nil { + return err + } + } + return nil + }) + if err != nil { + return err + } + + result := types.Result{} + return result.Print() +} + +func cmdDel(args *skel.CmdArgs) error { + // TODO: the settings are not reverted to the previous values. Reverting the + // settings is not useful when the whole container goes away but it could be + // useful in scenarios where plugins are added and removed at runtime. + return nil +} + +func main() { + skel.PluginMain(cmdAdd, cmdDel) +} diff --git a/vendor/github.com/coreos/gexpect/LICENCE b/vendor/github.com/coreos/gexpect/LICENCE new file mode 100644 index 0000000000..50adb0f19c --- /dev/null +++ b/vendor/github.com/coreos/gexpect/LICENCE @@ -0,0 +1,7 @@ +Copyright (C) 2014 Thomas Rooney + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/vendor/github.com/coreos/gexpect/gexpect.go b/vendor/github.com/coreos/gexpect/gexpect.go new file mode 100644 index 0000000000..4ea620ef6e --- /dev/null +++ b/vendor/github.com/coreos/gexpect/gexpect.go @@ -0,0 +1,449 @@ +// +build !windows + +package gexpect + +import ( + "bytes" + "errors" + "fmt" + "io" + "os" + "os/exec" + "regexp" + "time" + "unicode/utf8" + + shell "github.com/kballard/go-shellquote" + "github.com/kr/pty" +) + +var ( + ErrEmptySearch = errors.New("empty search string") +) + +type ExpectSubprocess struct { + Cmd *exec.Cmd + buf *buffer + outputBuffer []byte +} + +type buffer struct { + f *os.File + b bytes.Buffer + collect bool + + collection bytes.Buffer +} + +func (buf *buffer) StartCollecting() { + buf.collect = true +} + +func (buf *buffer) StopCollecting() (result string) { + result = string(buf.collection.Bytes()) + buf.collect = false + buf.collection.Reset() + return result +} + +func (buf *buffer) Read(chunk []byte) (int, error) { + nread := 0 + if buf.b.Len() > 0 { + n, err := buf.b.Read(chunk) + if err != nil { + return n, err + } + if n == len(chunk) { + return n, nil + } + nread = n + } + fn, err := buf.f.Read(chunk[nread:]) + return fn + nread, err +} + +func (buf *buffer) ReadRune() (r rune, size int, err error) { + l := buf.b.Len() + + chunk := make([]byte, utf8.UTFMax) + if l > 0 { + n, err := buf.b.Read(chunk) + if err != nil { + return 0, 0, err + } + if utf8.FullRune(chunk[:n]) { + r, rL := utf8.DecodeRune(chunk) + if n > rL { + buf.PutBack(chunk[rL:n]) + } + if buf.collect { + buf.collection.WriteRune(r) + } + return r, rL, nil + } + } + // else add bytes from the file, then try that + for l < utf8.UTFMax { + fn, err := buf.f.Read(chunk[l : l+1]) + if err != nil { + return 0, 0, err + } + l = l + fn + + if utf8.FullRune(chunk[:l]) { + r, rL := utf8.DecodeRune(chunk) + if buf.collect { + buf.collection.WriteRune(r) + } + return r, rL, nil + } + } + return 0, 0, errors.New("File is not a valid UTF=8 encoding") +} + +func (buf *buffer) PutBack(chunk []byte) { + if len(chunk) == 0 { + return + } + if buf.b.Len() == 0 { + buf.b.Write(chunk) + return + } + d := make([]byte, 0, len(chunk)+buf.b.Len()) + d = append(d, chunk...) + d = append(d, buf.b.Bytes()...) + buf.b.Reset() + buf.b.Write(d) +} + +func SpawnAtDirectory(command string, directory string) (*ExpectSubprocess, error) { + expect, err := _spawn(command) + if err != nil { + return nil, err + } + expect.Cmd.Dir = directory + return _start(expect) +} + +func Command(command string) (*ExpectSubprocess, error) { + expect, err := _spawn(command) + if err != nil { + return nil, err + } + return expect, nil +} + +func (expect *ExpectSubprocess) Start() error { + _, err := _start(expect) + return err +} + +func Spawn(command string) (*ExpectSubprocess, error) { + expect, err := _spawn(command) + if err != nil { + return nil, err + } + return _start(expect) +} + +func (expect *ExpectSubprocess) Close() error { + if err := expect.Cmd.Process.Kill(); err != nil { + return err + } + if err := expect.buf.f.Close(); err != nil { + return err + } + return nil +} + +func (expect *ExpectSubprocess) AsyncInteractChannels() (send chan string, receive chan string) { + receive = make(chan string) + send = make(chan string) + + go func() { + for { + str, err := expect.ReadLine() + if err != nil { + close(receive) + return + } + receive <- str + } + }() + + go func() { + for { + select { + case sendCommand, exists := <-send: + { + if !exists { + return + } + err := expect.Send(sendCommand) + if err != nil { + receive <- "gexpect Error: " + err.Error() + return + } + } + } + } + }() + + return +} + +func (expect *ExpectSubprocess) ExpectRegex(regex string) (bool, error) { + return regexp.MatchReader(regex, expect.buf) +} + +func (expect *ExpectSubprocess) expectRegexFind(regex string, output bool) ([]string, string, error) { + re, err := regexp.Compile(regex) + if err != nil { + return nil, "", err + } + expect.buf.StartCollecting() + pairs := re.FindReaderSubmatchIndex(expect.buf) + stringIndexedInto := expect.buf.StopCollecting() + l := len(pairs) + numPairs := l / 2 + result := make([]string, numPairs) + for i := 0; i < numPairs; i += 1 { + result[i] = stringIndexedInto[pairs[i*2]:pairs[i*2+1]] + } + // convert indexes to strings + + if len(result) == 0 { + err = fmt.Errorf("ExpectRegex didn't find regex '%v'.", regex) + } else { + // The number in pairs[1] is an index of a first + // character outside the whole match + putBackIdx := pairs[1] + if len(stringIndexedInto) > putBackIdx { + stringToPutBack := stringIndexedInto[putBackIdx:] + stringIndexedInto = stringIndexedInto[:putBackIdx] + expect.buf.PutBack([]byte(stringToPutBack)) + } + } + return result, stringIndexedInto, err +} + +func (expect *ExpectSubprocess) expectTimeoutRegexFind(regex string, timeout time.Duration) (result []string, out string, err error) { + t := make(chan bool) + go func() { + result, out, err = expect.ExpectRegexFindWithOutput(regex) + t <- false + }() + go func() { + time.Sleep(timeout) + err = fmt.Errorf("ExpectRegex timed out after %v finding '%v'.\nOutput:\n%s", timeout, regex, expect.Collect()) + t <- true + }() + <-t + return result, out, err +} + +func (expect *ExpectSubprocess) ExpectRegexFind(regex string) ([]string, error) { + result, _, err := expect.expectRegexFind(regex, false) + return result, err +} + +func (expect *ExpectSubprocess) ExpectTimeoutRegexFind(regex string, timeout time.Duration) ([]string, error) { + result, _, err := expect.expectTimeoutRegexFind(regex, timeout) + return result, err +} + +func (expect *ExpectSubprocess) ExpectRegexFindWithOutput(regex string) ([]string, string, error) { + return expect.expectRegexFind(regex, true) +} + +func (expect *ExpectSubprocess) ExpectTimeoutRegexFindWithOutput(regex string, timeout time.Duration) ([]string, string, error) { + return expect.expectTimeoutRegexFind(regex, timeout) +} + +func buildKMPTable(searchString string) []int { + pos := 2 + cnd := 0 + length := len(searchString) + + var table []int + if length < 2 { + length = 2 + } + + table = make([]int, length) + table[0] = -1 + table[1] = 0 + + for pos < len(searchString) { + if searchString[pos-1] == searchString[cnd] { + cnd += 1 + table[pos] = cnd + pos += 1 + } else if cnd > 0 { + cnd = table[cnd] + } else { + table[pos] = 0 + pos += 1 + } + } + return table +} + +func (expect *ExpectSubprocess) ExpectTimeout(searchString string, timeout time.Duration) (e error) { + result := make(chan error) + go func() { + result <- expect.Expect(searchString) + }() + select { + case e = <-result: + case <-time.After(timeout): + e = fmt.Errorf("Expect timed out after %v waiting for '%v'.\nOutput:\n%s", timeout, searchString, expect.Collect()) + } + return e +} + +func (expect *ExpectSubprocess) Expect(searchString string) (e error) { + target := len(searchString) + if target < 1 { + return ErrEmptySearch + } + chunk := make([]byte, target*2) + if expect.outputBuffer != nil { + expect.outputBuffer = expect.outputBuffer[0:] + } + m := 0 + i := 0 + // Build KMP Table + table := buildKMPTable(searchString) + + for { + n, err := expect.buf.Read(chunk) + if err != nil { + return err + } + if expect.outputBuffer != nil { + expect.outputBuffer = append(expect.outputBuffer, chunk[:n]...) + } + offset := m + i + for m+i-offset < n { + if searchString[i] == chunk[m+i-offset] { + i += 1 + if i == target { + unreadIndex := m + i - offset + if len(chunk) > unreadIndex { + expect.buf.PutBack(chunk[unreadIndex:n]) + } + return nil + } + } else { + m += i - table[i] + if table[i] > -1 { + i = table[i] + } else { + i = 0 + } + } + } + } +} + +func (expect *ExpectSubprocess) Send(command string) error { + _, err := io.WriteString(expect.buf.f, command) + return err +} + +func (expect *ExpectSubprocess) Capture() { + if expect.outputBuffer == nil { + expect.outputBuffer = make([]byte, 0) + } +} + +func (expect *ExpectSubprocess) Collect() []byte { + collectOutput := make([]byte, len(expect.outputBuffer)) + copy(collectOutput, expect.outputBuffer) + expect.outputBuffer = nil + return collectOutput +} + +func (expect *ExpectSubprocess) SendLine(command string) error { + _, err := io.WriteString(expect.buf.f, command+"\r\n") + return err +} + +func (expect *ExpectSubprocess) Interact() { + defer expect.Cmd.Wait() + io.Copy(os.Stdout, &expect.buf.b) + go io.Copy(os.Stdout, expect.buf.f) + go io.Copy(expect.buf.f, os.Stdin) +} + +func (expect *ExpectSubprocess) ReadUntil(delim byte) ([]byte, error) { + join := make([]byte, 0, 512) + chunk := make([]byte, 255) + + for { + n, err := expect.buf.Read(chunk) + + for i := 0; i < n; i++ { + if chunk[i] == delim { + if len(chunk) > i+1 { + expect.buf.PutBack(chunk[i+1:n]) + } + return join, nil + } else { + join = append(join, chunk[i]) + } + } + + if err != nil { + return join, err + } + } +} + +func (expect *ExpectSubprocess) Wait() error { + return expect.Cmd.Wait() +} + +func (expect *ExpectSubprocess) ReadLine() (string, error) { + str, err := expect.ReadUntil('\n') + return string(str), err +} + +func _start(expect *ExpectSubprocess) (*ExpectSubprocess, error) { + f, err := pty.Start(expect.Cmd) + if err != nil { + return nil, err + } + expect.buf.f = f + + return expect, nil +} + +func _spawn(command string) (*ExpectSubprocess, error) { + wrapper := new(ExpectSubprocess) + + wrapper.outputBuffer = nil + + splitArgs, err := shell.Split(command) + if err != nil { + return nil, err + } + numArguments := len(splitArgs) - 1 + if numArguments < 0 { + return nil, errors.New("gexpect: No command given to spawn") + } + path, err := exec.LookPath(splitArgs[0]) + if err != nil { + return nil, err + } + + if numArguments >= 1 { + wrapper.Cmd = exec.Command(path, splitArgs[1:]...) + } else { + wrapper.Cmd = exec.Command(path) + } + wrapper.buf = new(buffer) + + return wrapper, nil +} diff --git a/vendor/github.com/coreos/go-iptables/LICENSE b/vendor/github.com/coreos/go-iptables/LICENSE new file mode 100644 index 0000000000..37ec93a14f --- /dev/null +++ b/vendor/github.com/coreos/go-iptables/LICENSE @@ -0,0 +1,191 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, "control" means (i) the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising +permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +"Object" form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +"submitted" means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor 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, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of +this License; and +You must cause any modified files to carry prominent notices stating that You +changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets "[]" replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same "printed page" as the copyright notice for easier identification within +third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/coreos/go-iptables/iptables/iptables.go b/vendor/github.com/coreos/go-iptables/iptables/iptables.go new file mode 100644 index 0000000000..4b2f2f2f4b --- /dev/null +++ b/vendor/github.com/coreos/go-iptables/iptables/iptables.go @@ -0,0 +1,295 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package iptables + +import ( + "bytes" + "fmt" + "io" + "os/exec" + "regexp" + "strconv" + "strings" + "syscall" +) + +// Adds the output of stderr to exec.ExitError +type Error struct { + exec.ExitError + msg string +} + +func (e *Error) ExitStatus() int { + return e.Sys().(syscall.WaitStatus).ExitStatus() +} + +func (e *Error) Error() string { + return fmt.Sprintf("exit status %v: %v", e.ExitStatus(), e.msg) +} + +type IPTables struct { + path string + hasCheck bool + hasWait bool +} + +func New() (*IPTables, error) { + path, err := exec.LookPath("iptables") + if err != nil { + return nil, err + } + checkPresent, waitPresent, err := getIptablesCommandSupport() + if err != nil { + return nil, fmt.Errorf("error checking iptables version: %v", err) + } + ipt := IPTables{ + path: path, + hasCheck: checkPresent, + hasWait: waitPresent, + } + return &ipt, nil +} + +// Exists checks if given rulespec in specified table/chain exists +func (ipt *IPTables) Exists(table, chain string, rulespec ...string) (bool, error) { + if !ipt.hasCheck { + return ipt.existsForOldIptables(table, chain, rulespec) + + } + cmd := append([]string{"-t", table, "-C", chain}, rulespec...) + err := ipt.run(cmd...) + eerr, eok := err.(*Error) + switch { + case err == nil: + return true, nil + case eok && eerr.ExitStatus() == 1: + return false, nil + default: + return false, err + } +} + +// Insert inserts rulespec to specified table/chain (in specified pos) +func (ipt *IPTables) Insert(table, chain string, pos int, rulespec ...string) error { + cmd := append([]string{"-t", table, "-I", chain, strconv.Itoa(pos)}, rulespec...) + return ipt.run(cmd...) +} + +// Append appends rulespec to specified table/chain +func (ipt *IPTables) Append(table, chain string, rulespec ...string) error { + cmd := append([]string{"-t", table, "-A", chain}, rulespec...) + return ipt.run(cmd...) +} + +// AppendUnique acts like Append except that it won't add a duplicate +func (ipt *IPTables) AppendUnique(table, chain string, rulespec ...string) error { + exists, err := ipt.Exists(table, chain, rulespec...) + if err != nil { + return err + } + + if !exists { + return ipt.Append(table, chain, rulespec...) + } + + return nil +} + +// Delete removes rulespec in specified table/chain +func (ipt *IPTables) Delete(table, chain string, rulespec ...string) error { + cmd := append([]string{"-t", table, "-D", chain}, rulespec...) + return ipt.run(cmd...) +} + +// List rules in specified table/chain +func (ipt *IPTables) List(table, chain string) ([]string, error) { + args := []string{"-t", table, "-S", chain} + var stdout bytes.Buffer + if err := ipt.runWithOutput(args, &stdout); err != nil { + return nil, err + } + + rules := strings.Split(stdout.String(), "\n") + if len(rules) > 0 && rules[len(rules)-1] == "" { + rules = rules[:len(rules)-1] + } + + return rules, nil +} + +func (ipt *IPTables) NewChain(table, chain string) error { + return ipt.run("-t", table, "-N", chain) +} + +// ClearChain flushed (deletes all rules) in the specified table/chain. +// If the chain does not exist, a new one will be created +func (ipt *IPTables) ClearChain(table, chain string) error { + err := ipt.NewChain(table, chain) + + eerr, eok := err.(*Error) + switch { + case err == nil: + return nil + case eok && eerr.ExitStatus() == 1: + // chain already exists. Flush (clear) it. + return ipt.run("-t", table, "-F", chain) + default: + return err + } +} + +// RenameChain renames the old chain to the new one. +func (ipt *IPTables) RenameChain(table, oldChain, newChain string) error { + return ipt.run("-t", table, "-E", oldChain, newChain) +} + +// DeleteChain deletes the chain in the specified table. +// The chain must be empty +func (ipt *IPTables) DeleteChain(table, chain string) error { + return ipt.run("-t", table, "-X", chain) +} + +// run runs an iptables command with the given arguments, ignoring +// any stdout output +func (ipt *IPTables) run(args ...string) error { + return ipt.runWithOutput(args, nil) +} + +// runWithOutput runs an iptables command with the given arguments, +// writing any stdout output to the given writer +func (ipt *IPTables) runWithOutput(args []string, stdout io.Writer) error { + args = append([]string{ipt.path}, args...) + if ipt.hasWait { + args = append(args, "--wait") + } else { + fmu, err := newXtablesFileLock() + if err != nil { + return err + } + ul, err := fmu.tryLock() + if err != nil { + return err + } + defer ul.Unlock() + } + + var stderr bytes.Buffer + cmd := exec.Cmd{ + Path: ipt.path, + Args: args, + Stdout: stdout, + Stderr: &stderr, + } + + if err := cmd.Run(); err != nil { + return &Error{*(err.(*exec.ExitError)), stderr.String()} + } + + return nil +} + +// Checks if iptables has the "-C" and "--wait" flag +func getIptablesCommandSupport() (bool, bool, error) { + vstring, err := getIptablesVersionString() + if err != nil { + return false, false, err + } + + v1, v2, v3, err := extractIptablesVersion(vstring) + if err != nil { + return false, false, err + } + + return iptablesHasCheckCommand(v1, v2, v3), iptablesHasWaitCommand(v1, v2, v3), nil +} + +// getIptablesVersion returns the first three components of the iptables version. +// e.g. "iptables v1.3.66" would return (1, 3, 66, nil) +func extractIptablesVersion(str string) (int, int, int, error) { + versionMatcher := regexp.MustCompile("v([0-9]+)\\.([0-9]+)\\.([0-9]+)") + result := versionMatcher.FindStringSubmatch(str) + if result == nil { + return 0, 0, 0, fmt.Errorf("no iptables version found in string: %s", str) + } + + v1, err := strconv.Atoi(result[1]) + if err != nil { + return 0, 0, 0, err + } + + v2, err := strconv.Atoi(result[2]) + if err != nil { + return 0, 0, 0, err + } + + v3, err := strconv.Atoi(result[3]) + if err != nil { + return 0, 0, 0, err + } + + return v1, v2, v3, nil +} + +// Runs "iptables --version" to get the version string +func getIptablesVersionString() (string, error) { + cmd := exec.Command("iptables", "--version") + var out bytes.Buffer + cmd.Stdout = &out + err := cmd.Run() + if err != nil { + return "", err + } + return out.String(), nil +} + +// Checks if an iptables version is after 1.4.11, when --check was added +func iptablesHasCheckCommand(v1 int, v2 int, v3 int) bool { + if v1 > 1 { + return true + } + if v1 == 1 && v2 > 4 { + return true + } + if v1 == 1 && v2 == 4 && v3 >= 11 { + return true + } + return false +} + +// Checks if an iptables version is after 1.4.20, when --wait was added +func iptablesHasWaitCommand(v1 int, v2 int, v3 int) bool { + if v1 > 1 { + return true + } + if v1 == 1 && v2 > 4 { + return true + } + if v1 == 1 && v2 == 4 && v3 >= 20 { + return true + } + return false +} + +// Checks if a rule specification exists for a table +func (ipt *IPTables) existsForOldIptables(table, chain string, rulespec []string) (bool, error) { + rs := strings.Join(append([]string{"-A", chain}, rulespec...), " ") + args := []string{"-t", table, "-S"} + var stdout bytes.Buffer + err := ipt.runWithOutput(args, &stdout) + if err != nil { + return false, err + } + return strings.Contains(stdout.String(), rs), nil +} diff --git a/vendor/github.com/coreos/go-iptables/iptables/lock.go b/vendor/github.com/coreos/go-iptables/iptables/lock.go new file mode 100644 index 0000000000..a88e92b4e4 --- /dev/null +++ b/vendor/github.com/coreos/go-iptables/iptables/lock.go @@ -0,0 +1,84 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package iptables + +import ( + "os" + "sync" + "syscall" +) + +const ( + // In earlier versions of iptables, the xtables lock was implemented + // via a Unix socket, but now flock is used via this lockfile: + // http://git.netfilter.org/iptables/commit/?id=aa562a660d1555b13cffbac1e744033e91f82707 + // Note the LSB-conforming "/run" directory does not exist on old + // distributions, so assume "/var" is symlinked + xtablesLockFilePath = "/var/run/xtables.lock" + + defaultFilePerm = 0600 +) + +type Unlocker interface { + Unlock() error +} + +type nopUnlocker struct{} + +func (_ nopUnlocker) Unlock() error { return nil } + +type fileLock struct { + // mu is used to protect against concurrent invocations from within this process + mu sync.Mutex + fd int +} + +// tryLock takes an exclusive lock on the xtables lock file without blocking. +// This is best-effort only: if the exclusive lock would block (i.e. because +// another process already holds it), no error is returned. Otherwise, any +// error encountered during the locking operation is returned. +// The returned Unlocker should be used to release the lock when the caller is +// done invoking iptables commands. +func (l *fileLock) tryLock() (Unlocker, error) { + l.mu.Lock() + err := syscall.Flock(l.fd, syscall.LOCK_EX|syscall.LOCK_NB) + switch err { + case syscall.EWOULDBLOCK: + l.mu.Unlock() + return nopUnlocker{}, nil + case nil: + return l, nil + default: + l.mu.Unlock() + return nil, err + } +} + +// Unlock closes the underlying file, which implicitly unlocks it as well. It +// also unlocks the associated mutex. +func (l *fileLock) Unlock() error { + defer l.mu.Unlock() + return syscall.Close(l.fd) +} + +// newXtablesFileLock opens a new lock on the xtables lockfile without +// acquiring the lock +func newXtablesFileLock() (*fileLock, error) { + fd, err := syscall.Open(xtablesLockFilePath, os.O_CREATE, defaultFilePerm) + if err != nil { + return nil, err + } + return &fileLock{fd: fd}, nil +} diff --git a/vendor/github.com/coreos/go-semver/LICENSE b/vendor/github.com/coreos/go-semver/LICENSE new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/vendor/github.com/coreos/go-semver/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor 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, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/coreos/go-semver/example.go b/vendor/github.com/coreos/go-semver/example.go new file mode 100644 index 0000000000..fd2ee5af27 --- /dev/null +++ b/vendor/github.com/coreos/go-semver/example.go @@ -0,0 +1,20 @@ +package main + +import ( + "fmt" + "github.com/coreos/go-semver/semver" + "os" +) + +func main() { + vA, err := semver.NewVersion(os.Args[1]) + if err != nil { + fmt.Println(err.Error()) + } + vB, err := semver.NewVersion(os.Args[2]) + if err != nil { + fmt.Println(err.Error()) + } + + fmt.Printf("%s < %s == %t\n", vA, vB, vA.LessThan(*vB)) +} diff --git a/vendor/github.com/coreos/go-semver/semver/semver.go b/vendor/github.com/coreos/go-semver/semver/semver.go new file mode 100644 index 0000000000..000a020586 --- /dev/null +++ b/vendor/github.com/coreos/go-semver/semver/semver.go @@ -0,0 +1,257 @@ +// Copyright 2013-2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Semantic Versions http://semver.org +package semver + +import ( + "bytes" + "errors" + "fmt" + "strconv" + "strings" +) + +type Version struct { + Major int64 + Minor int64 + Patch int64 + PreRelease PreRelease + Metadata string +} + +type PreRelease string + +func splitOff(input *string, delim string) (val string) { + parts := strings.SplitN(*input, delim, 2) + + if len(parts) == 2 { + *input = parts[0] + val = parts[1] + } + + return val +} + +func NewVersion(version string) (*Version, error) { + v := Version{} + + v.Metadata = splitOff(&version, "+") + v.PreRelease = PreRelease(splitOff(&version, "-")) + + dotParts := strings.SplitN(version, ".", 3) + + if len(dotParts) != 3 { + return nil, errors.New(fmt.Sprintf("%s is not in dotted-tri format", version)) + } + + parsed := make([]int64, 3, 3) + + for i, v := range dotParts[:3] { + val, err := strconv.ParseInt(v, 10, 64) + parsed[i] = val + if err != nil { + return nil, err + } + } + + v.Major = parsed[0] + v.Minor = parsed[1] + v.Patch = parsed[2] + + return &v, nil +} + +func Must(v *Version, err error) *Version { + if err != nil { + panic(err) + } + return v +} + +func (v Version) String() string { + var buffer bytes.Buffer + + fmt.Fprintf(&buffer, "%d.%d.%d", v.Major, v.Minor, v.Patch) + + if v.PreRelease != "" { + fmt.Fprintf(&buffer, "-%s", v.PreRelease) + } + + if v.Metadata != "" { + fmt.Fprintf(&buffer, "+%s", v.Metadata) + } + + return buffer.String() +} + +func (v *Version) UnmarshalYAML(unmarshal func(interface{}) error) error { + var data string + if err := unmarshal(&data); err != nil { + return err + } + vv, err := NewVersion(data) + if err != nil { + return err + } + *v = *vv + return nil +} + +func (v Version) MarshalJSON() ([]byte, error) { + return []byte(`"` + v.String() + `"`), nil +} + +func (v *Version) UnmarshalJSON(data []byte) error { + l := len(data) + if l == 0 || string(data) == `""` { + return nil + } + if l < 2 || data[0] != '"' || data[l-1] != '"' { + return errors.New("invalid semver string") + } + vv, err := NewVersion(string(data[1 : l-1])) + if err != nil { + return err + } + *v = *vv + return nil +} + +func (v Version) LessThan(versionB Version) bool { + versionA := v + cmp := recursiveCompare(versionA.Slice(), versionB.Slice()) + + if cmp == 0 { + cmp = preReleaseCompare(versionA, versionB) + } + + if cmp == -1 { + return true + } + + return false +} + +/* Slice converts the comparable parts of the semver into a slice of strings */ +func (v Version) Slice() []int64 { + return []int64{v.Major, v.Minor, v.Patch} +} + +func (p PreRelease) Slice() []string { + preRelease := string(p) + return strings.Split(preRelease, ".") +} + +func preReleaseCompare(versionA Version, versionB Version) int { + a := versionA.PreRelease + b := versionB.PreRelease + + /* Handle the case where if two versions are otherwise equal it is the + * one without a PreRelease that is greater */ + if len(a) == 0 && (len(b) > 0) { + return 1 + } else if len(b) == 0 && (len(a) > 0) { + return -1 + } + + // If there is a prelease, check and compare each part. + return recursivePreReleaseCompare(a.Slice(), b.Slice()) +} + +func recursiveCompare(versionA []int64, versionB []int64) int { + if len(versionA) == 0 { + return 0 + } + + a := versionA[0] + b := versionB[0] + + if a > b { + return 1 + } else if a < b { + return -1 + } + + return recursiveCompare(versionA[1:], versionB[1:]) +} + +func recursivePreReleaseCompare(versionA []string, versionB []string) int { + // Handle slice length disparity. + if len(versionA) == 0 { + // Nothing to compare too, so we return 0 + return 0 + } else if len(versionB) == 0 { + // We're longer than versionB so return 1. + return 1 + } + + a := versionA[0] + b := versionB[0] + + aInt := false + bInt := false + + aI, err := strconv.Atoi(versionA[0]) + if err == nil { + aInt = true + } + + bI, err := strconv.Atoi(versionB[0]) + if err == nil { + bInt = true + } + + // Handle Integer Comparison + if aInt && bInt { + if aI > bI { + return 1 + } else if aI < bI { + return -1 + } + } + + // Handle String Comparison + if a > b { + return 1 + } else if a < b { + return -1 + } + + return recursivePreReleaseCompare(versionA[1:], versionB[1:]) +} + +// BumpMajor increments the Major field by 1 and resets all other fields to their default values +func (v *Version) BumpMajor() { + v.Major += 1 + v.Minor = 0 + v.Patch = 0 + v.PreRelease = PreRelease("") + v.Metadata = "" +} + +// BumpMinor increments the Minor field by 1 and resets all other fields to their default values +func (v *Version) BumpMinor() { + v.Minor += 1 + v.Patch = 0 + v.PreRelease = PreRelease("") + v.Metadata = "" +} + +// BumpPatch increments the Patch field by 1 and resets all other fields to their default values +func (v *Version) BumpPatch() { + v.Patch += 1 + v.PreRelease = PreRelease("") + v.Metadata = "" +} diff --git a/vendor/github.com/coreos/go-semver/semver/sort.go b/vendor/github.com/coreos/go-semver/semver/sort.go new file mode 100644 index 0000000000..e256b41a5d --- /dev/null +++ b/vendor/github.com/coreos/go-semver/semver/sort.go @@ -0,0 +1,38 @@ +// Copyright 2013-2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package semver + +import ( + "sort" +) + +type Versions []*Version + +func (s Versions) Len() int { + return len(s) +} + +func (s Versions) Swap(i, j int) { + s[i], s[j] = s[j], s[i] +} + +func (s Versions) Less(i, j int) bool { + return s[i].LessThan(*s[j]) +} + +// Sort sorts the given slice of Version +func Sort(versions []*Version) { + sort.Sort(Versions(versions)) +} diff --git a/vendor/github.com/coreos/go-systemd/LICENSE b/vendor/github.com/coreos/go-systemd/LICENSE new file mode 100644 index 0000000000..37ec93a14f --- /dev/null +++ b/vendor/github.com/coreos/go-systemd/LICENSE @@ -0,0 +1,191 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, "control" means (i) the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising +permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +"Object" form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +"submitted" means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor 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, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of +this License; and +You must cause any modified files to carry prominent notices stating that You +changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets "[]" replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same "printed page" as the copyright notice for easier identification within +third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/coreos/go-systemd/activation/files.go b/vendor/github.com/coreos/go-systemd/activation/files.go new file mode 100644 index 0000000000..c8e85fcd58 --- /dev/null +++ b/vendor/github.com/coreos/go-systemd/activation/files.go @@ -0,0 +1,52 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package activation implements primitives for systemd socket activation. +package activation + +import ( + "os" + "strconv" + "syscall" +) + +// based on: https://gist.github.com/alberts/4640792 +const ( + listenFdsStart = 3 +) + +func Files(unsetEnv bool) []*os.File { + if unsetEnv { + defer os.Unsetenv("LISTEN_PID") + defer os.Unsetenv("LISTEN_FDS") + } + + pid, err := strconv.Atoi(os.Getenv("LISTEN_PID")) + if err != nil || pid != os.Getpid() { + return nil + } + + nfds, err := strconv.Atoi(os.Getenv("LISTEN_FDS")) + if err != nil || nfds == 0 { + return nil + } + + files := make([]*os.File, 0, nfds) + for fd := listenFdsStart; fd < listenFdsStart+nfds; fd++ { + syscall.CloseOnExec(fd) + files = append(files, os.NewFile(uintptr(fd), "LISTEN_FD_"+strconv.Itoa(fd))) + } + + return files +} diff --git a/vendor/github.com/coreos/go-systemd/activation/listeners.go b/vendor/github.com/coreos/go-systemd/activation/listeners.go new file mode 100644 index 0000000000..df27c29e9e --- /dev/null +++ b/vendor/github.com/coreos/go-systemd/activation/listeners.go @@ -0,0 +1,62 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package activation + +import ( + "crypto/tls" + "net" +) + +// Listeners returns a slice containing a net.Listener for each matching socket type +// passed to this process. +// +// The order of the file descriptors is preserved in the returned slice. +// Nil values are used to fill any gaps. For example if systemd were to return file descriptors +// corresponding with "udp, tcp, tcp", then the slice would contain {nil, net.Listener, net.Listener} +func Listeners(unsetEnv bool) ([]net.Listener, error) { + files := Files(unsetEnv) + listeners := make([]net.Listener, len(files)) + + for i, f := range files { + if pc, err := net.FileListener(f); err == nil { + listeners[i] = pc + } + } + return listeners, nil +} + +// TLSListeners returns a slice containing a net.listener for each matching TCP socket type +// passed to this process. +// It uses default Listeners func and forces TCP sockets handlers to use TLS based on tlsConfig. +func TLSListeners(unsetEnv bool, tlsConfig *tls.Config) ([]net.Listener, error) { + listeners, err := Listeners(unsetEnv) + + if listeners == nil || err != nil { + return nil, err + } + + if tlsConfig != nil && err == nil { + tlsConfig.NextProtos = []string{"http/1.1"} + + for i, l := range listeners { + // Activate TLS only for TCP sockets + if l.Addr().Network() == "tcp" { + listeners[i] = tls.NewListener(l, tlsConfig) + } + } + } + + return listeners, err +} diff --git a/vendor/github.com/coreos/go-systemd/activation/packetconns.go b/vendor/github.com/coreos/go-systemd/activation/packetconns.go new file mode 100644 index 0000000000..48b2ca029d --- /dev/null +++ b/vendor/github.com/coreos/go-systemd/activation/packetconns.go @@ -0,0 +1,37 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package activation + +import ( + "net" +) + +// PacketConns returns a slice containing a net.PacketConn for each matching socket type +// passed to this process. +// +// The order of the file descriptors is preserved in the returned slice. +// Nil values are used to fill any gaps. For example if systemd were to return file descriptors +// corresponding with "udp, tcp, udp", then the slice would contain {net.PacketConn, nil, net.PacketConn} +func PacketConns(unsetEnv bool) ([]net.PacketConn, error) { + files := Files(unsetEnv) + conns := make([]net.PacketConn, len(files)) + + for i, f := range files { + if pc, err := net.FilePacketConn(f); err == nil { + conns[i] = pc + } + } + return conns, nil +} diff --git a/vendor/github.com/coreos/go-systemd/dbus/dbus.go b/vendor/github.com/coreos/go-systemd/dbus/dbus.go new file mode 100644 index 0000000000..1699b90332 --- /dev/null +++ b/vendor/github.com/coreos/go-systemd/dbus/dbus.go @@ -0,0 +1,203 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Integration with the systemd D-Bus API. See http://www.freedesktop.org/wiki/Software/systemd/dbus/ +package dbus + +import ( + "fmt" + "os" + "strconv" + "strings" + "sync" + + "github.com/godbus/dbus" +) + +const ( + alpha = `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ` + num = `0123456789` + alphanum = alpha + num + signalBuffer = 100 +) + +// needsEscape checks whether a byte in a potential dbus ObjectPath needs to be escaped +func needsEscape(i int, b byte) bool { + // Escape everything that is not a-z-A-Z-0-9 + // Also escape 0-9 if it's the first character + return strings.IndexByte(alphanum, b) == -1 || + (i == 0 && strings.IndexByte(num, b) != -1) +} + +// PathBusEscape sanitizes a constituent string of a dbus ObjectPath using the +// rules that systemd uses for serializing special characters. +func PathBusEscape(path string) string { + // Special case the empty string + if len(path) == 0 { + return "_" + } + n := []byte{} + for i := 0; i < len(path); i++ { + c := path[i] + if needsEscape(i, c) { + e := fmt.Sprintf("_%x", c) + n = append(n, []byte(e)...) + } else { + n = append(n, c) + } + } + return string(n) +} + +// Conn is a connection to systemd's dbus endpoint. +type Conn struct { + // sysconn/sysobj are only used to call dbus methods + sysconn *dbus.Conn + sysobj dbus.BusObject + + // sigconn/sigobj are only used to receive dbus signals + sigconn *dbus.Conn + sigobj dbus.BusObject + + jobListener struct { + jobs map[dbus.ObjectPath]chan<- string + sync.Mutex + } + subscriber struct { + updateCh chan<- *SubStateUpdate + errCh chan<- error + sync.Mutex + ignore map[dbus.ObjectPath]int64 + cleanIgnore int64 + } +} + +// New establishes a connection to the system bus and authenticates. +// Callers should call Close() when done with the connection. +func New() (*Conn, error) { + return NewConnection(func() (*dbus.Conn, error) { + return dbusAuthHelloConnection(dbus.SystemBusPrivate) + }) +} + +// NewUserConnection establishes a connection to the session bus and +// authenticates. This can be used to connect to systemd user instances. +// Callers should call Close() when done with the connection. +func NewUserConnection() (*Conn, error) { + return NewConnection(func() (*dbus.Conn, error) { + return dbusAuthHelloConnection(dbus.SessionBusPrivate) + }) +} + +// NewSystemdConnection establishes a private, direct connection to systemd. +// This can be used for communicating with systemd without a dbus daemon. +// Callers should call Close() when done with the connection. +func NewSystemdConnection() (*Conn, error) { + return NewConnection(func() (*dbus.Conn, error) { + // We skip Hello when talking directly to systemd. + return dbusAuthConnection(func() (*dbus.Conn, error) { + return dbus.Dial("unix:path=/run/systemd/private") + }) + }) +} + +// Close closes an established connection +func (c *Conn) Close() { + c.sysconn.Close() + c.sigconn.Close() +} + +// NewConnection establishes a connection to a bus using a caller-supplied function. +// This allows connecting to remote buses through a user-supplied mechanism. +// The supplied function may be called multiple times, and should return independent connections. +// The returned connection must be fully initialised: the org.freedesktop.DBus.Hello call must have succeeded, +// and any authentication should be handled by the function. +func NewConnection(dialBus func() (*dbus.Conn, error)) (*Conn, error) { + sysconn, err := dialBus() + if err != nil { + return nil, err + } + + sigconn, err := dialBus() + if err != nil { + sysconn.Close() + return nil, err + } + + c := &Conn{ + sysconn: sysconn, + sysobj: systemdObject(sysconn), + sigconn: sigconn, + sigobj: systemdObject(sigconn), + } + + c.subscriber.ignore = make(map[dbus.ObjectPath]int64) + c.jobListener.jobs = make(map[dbus.ObjectPath]chan<- string) + + // Setup the listeners on jobs so that we can get completions + c.sigconn.BusObject().Call("org.freedesktop.DBus.AddMatch", 0, + "type='signal', interface='org.freedesktop.systemd1.Manager', member='JobRemoved'") + + c.dispatch() + return c, nil +} + +// GetManagerProperty returns the value of a property on the org.freedesktop.systemd1.Manager +// interface. The value is returned in its string representation, as defined at +// https://developer.gnome.org/glib/unstable/gvariant-text.html +func (c *Conn) GetManagerProperty(prop string) (string, error) { + variant, err := c.sysobj.GetProperty("org.freedesktop.systemd1.Manager." + prop) + if err != nil { + return "", err + } + return variant.String(), nil +} + +func dbusAuthConnection(createBus func() (*dbus.Conn, error)) (*dbus.Conn, error) { + conn, err := createBus() + if err != nil { + return nil, err + } + + // Only use EXTERNAL method, and hardcode the uid (not username) + // to avoid a username lookup (which requires a dynamically linked + // libc) + methods := []dbus.Auth{dbus.AuthExternal(strconv.Itoa(os.Getuid()))} + + err = conn.Auth(methods) + if err != nil { + conn.Close() + return nil, err + } + + return conn, nil +} + +func dbusAuthHelloConnection(createBus func() (*dbus.Conn, error)) (*dbus.Conn, error) { + conn, err := dbusAuthConnection(createBus) + if err != nil { + return nil, err + } + + if err = conn.Hello(); err != nil { + conn.Close() + return nil, err + } + + return conn, nil +} + +func systemdObject(conn *dbus.Conn) dbus.BusObject { + return conn.Object("org.freedesktop.systemd1", dbus.ObjectPath("/org/freedesktop/systemd1")) +} diff --git a/vendor/github.com/coreos/go-systemd/dbus/methods.go b/vendor/github.com/coreos/go-systemd/dbus/methods.go new file mode 100644 index 0000000000..8f32fe8a7d --- /dev/null +++ b/vendor/github.com/coreos/go-systemd/dbus/methods.go @@ -0,0 +1,484 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package dbus + +import ( + "errors" + "path" + "strconv" + + "github.com/godbus/dbus" +) + +func (c *Conn) jobComplete(signal *dbus.Signal) { + var id uint32 + var job dbus.ObjectPath + var unit string + var result string + dbus.Store(signal.Body, &id, &job, &unit, &result) + c.jobListener.Lock() + out, ok := c.jobListener.jobs[job] + if ok { + out <- result + delete(c.jobListener.jobs, job) + } + c.jobListener.Unlock() +} + +func (c *Conn) startJob(ch chan<- string, job string, args ...interface{}) (int, error) { + if ch != nil { + c.jobListener.Lock() + defer c.jobListener.Unlock() + } + + var p dbus.ObjectPath + err := c.sysobj.Call(job, 0, args...).Store(&p) + if err != nil { + return 0, err + } + + if ch != nil { + c.jobListener.jobs[p] = ch + } + + // ignore error since 0 is fine if conversion fails + jobID, _ := strconv.Atoi(path.Base(string(p))) + + return jobID, nil +} + +// StartUnit enqueues a start job and depending jobs, if any (unless otherwise +// specified by the mode string). +// +// Takes the unit to activate, plus a mode string. The mode needs to be one of +// replace, fail, isolate, ignore-dependencies, ignore-requirements. If +// "replace" the call will start the unit and its dependencies, possibly +// replacing already queued jobs that conflict with this. If "fail" the call +// will start the unit and its dependencies, but will fail if this would change +// an already queued job. If "isolate" the call will start the unit in question +// and terminate all units that aren't dependencies of it. If +// "ignore-dependencies" it will start a unit but ignore all its dependencies. +// If "ignore-requirements" it will start a unit but only ignore the +// requirement dependencies. It is not recommended to make use of the latter +// two options. +// +// If the provided channel is non-nil, a result string will be sent to it upon +// job completion: one of done, canceled, timeout, failed, dependency, skipped. +// done indicates successful execution of a job. canceled indicates that a job +// has been canceled before it finished execution. timeout indicates that the +// job timeout was reached. failed indicates that the job failed. dependency +// indicates that a job this job has been depending on failed and the job hence +// has been removed too. skipped indicates that a job was skipped because it +// didn't apply to the units current state. +// +// If no error occurs, the ID of the underlying systemd job will be returned. There +// does exist the possibility for no error to be returned, but for the returned job +// ID to be 0. In this case, the actual underlying ID is not 0 and this datapoint +// should not be considered authoritative. +// +// If an error does occur, it will be returned to the user alongside a job ID of 0. +func (c *Conn) StartUnit(name string, mode string, ch chan<- string) (int, error) { + return c.startJob(ch, "org.freedesktop.systemd1.Manager.StartUnit", name, mode) +} + +// StopUnit is similar to StartUnit but stops the specified unit rather +// than starting it. +func (c *Conn) StopUnit(name string, mode string, ch chan<- string) (int, error) { + return c.startJob(ch, "org.freedesktop.systemd1.Manager.StopUnit", name, mode) +} + +// ReloadUnit reloads a unit. Reloading is done only if the unit is already running and fails otherwise. +func (c *Conn) ReloadUnit(name string, mode string, ch chan<- string) (int, error) { + return c.startJob(ch, "org.freedesktop.systemd1.Manager.ReloadUnit", name, mode) +} + +// RestartUnit restarts a service. If a service is restarted that isn't +// running it will be started. +func (c *Conn) RestartUnit(name string, mode string, ch chan<- string) (int, error) { + return c.startJob(ch, "org.freedesktop.systemd1.Manager.RestartUnit", name, mode) +} + +// TryRestartUnit is like RestartUnit, except that a service that isn't running +// is not affected by the restart. +func (c *Conn) TryRestartUnit(name string, mode string, ch chan<- string) (int, error) { + return c.startJob(ch, "org.freedesktop.systemd1.Manager.TryRestartUnit", name, mode) +} + +// ReloadOrRestart attempts a reload if the unit supports it and use a restart +// otherwise. +func (c *Conn) ReloadOrRestartUnit(name string, mode string, ch chan<- string) (int, error) { + return c.startJob(ch, "org.freedesktop.systemd1.Manager.ReloadOrRestartUnit", name, mode) +} + +// ReloadOrTryRestart attempts a reload if the unit supports it and use a "Try" +// flavored restart otherwise. +func (c *Conn) ReloadOrTryRestartUnit(name string, mode string, ch chan<- string) (int, error) { + return c.startJob(ch, "org.freedesktop.systemd1.Manager.ReloadOrTryRestartUnit", name, mode) +} + +// StartTransientUnit() may be used to create and start a transient unit, which +// will be released as soon as it is not running or referenced anymore or the +// system is rebooted. name is the unit name including suffix, and must be +// unique. mode is the same as in StartUnit(), properties contains properties +// of the unit. +func (c *Conn) StartTransientUnit(name string, mode string, properties []Property, ch chan<- string) (int, error) { + return c.startJob(ch, "org.freedesktop.systemd1.Manager.StartTransientUnit", name, mode, properties, make([]PropertyCollection, 0)) +} + +// KillUnit takes the unit name and a UNIX signal number to send. All of the unit's +// processes are killed. +func (c *Conn) KillUnit(name string, signal int32) { + c.sysobj.Call("org.freedesktop.systemd1.Manager.KillUnit", 0, name, "all", signal).Store() +} + +// ResetFailedUnit resets the "failed" state of a specific unit. +func (c *Conn) ResetFailedUnit(name string) error { + return c.sysobj.Call("org.freedesktop.systemd1.Manager.ResetFailedUnit", 0, name).Store() +} + +// getProperties takes the unit name and returns all of its dbus object properties, for the given dbus interface +func (c *Conn) getProperties(unit string, dbusInterface string) (map[string]interface{}, error) { + var err error + var props map[string]dbus.Variant + + path := unitPath(unit) + if !path.IsValid() { + return nil, errors.New("invalid unit name: " + unit) + } + + obj := c.sysconn.Object("org.freedesktop.systemd1", path) + err = obj.Call("org.freedesktop.DBus.Properties.GetAll", 0, dbusInterface).Store(&props) + if err != nil { + return nil, err + } + + out := make(map[string]interface{}, len(props)) + for k, v := range props { + out[k] = v.Value() + } + + return out, nil +} + +// GetUnitProperties takes the unit name and returns all of its dbus object properties. +func (c *Conn) GetUnitProperties(unit string) (map[string]interface{}, error) { + return c.getProperties(unit, "org.freedesktop.systemd1.Unit") +} + +func (c *Conn) getProperty(unit string, dbusInterface string, propertyName string) (*Property, error) { + var err error + var prop dbus.Variant + + path := unitPath(unit) + if !path.IsValid() { + return nil, errors.New("invalid unit name: " + unit) + } + + obj := c.sysconn.Object("org.freedesktop.systemd1", path) + err = obj.Call("org.freedesktop.DBus.Properties.Get", 0, dbusInterface, propertyName).Store(&prop) + if err != nil { + return nil, err + } + + return &Property{Name: propertyName, Value: prop}, nil +} + +func (c *Conn) GetUnitProperty(unit string, propertyName string) (*Property, error) { + return c.getProperty(unit, "org.freedesktop.systemd1.Unit", propertyName) +} + +// GetServiceProperty returns property for given service name and property name +func (c *Conn) GetServiceProperty(service string, propertyName string) (*Property, error) { + return c.getProperty(service, "org.freedesktop.systemd1.Service", propertyName) +} + +// GetUnitTypeProperties returns the extra properties for a unit, specific to the unit type. +// Valid values for unitType: Service, Socket, Target, Device, Mount, Automount, Snapshot, Timer, Swap, Path, Slice, Scope +// return "dbus.Error: Unknown interface" if the unitType is not the correct type of the unit +func (c *Conn) GetUnitTypeProperties(unit string, unitType string) (map[string]interface{}, error) { + return c.getProperties(unit, "org.freedesktop.systemd1."+unitType) +} + +// SetUnitProperties() may be used to modify certain unit properties at runtime. +// Not all properties may be changed at runtime, but many resource management +// settings (primarily those in systemd.cgroup(5)) may. The changes are applied +// instantly, and stored on disk for future boots, unless runtime is true, in which +// case the settings only apply until the next reboot. name is the name of the unit +// to modify. properties are the settings to set, encoded as an array of property +// name and value pairs. +func (c *Conn) SetUnitProperties(name string, runtime bool, properties ...Property) error { + return c.sysobj.Call("org.freedesktop.systemd1.Manager.SetUnitProperties", 0, name, runtime, properties).Store() +} + +func (c *Conn) GetUnitTypeProperty(unit string, unitType string, propertyName string) (*Property, error) { + return c.getProperty(unit, "org.freedesktop.systemd1."+unitType, propertyName) +} + +type UnitStatus struct { + Name string // The primary unit name as string + Description string // The human readable description string + LoadState string // The load state (i.e. whether the unit file has been loaded successfully) + ActiveState string // The active state (i.e. whether the unit is currently started or not) + SubState string // The sub state (a more fine-grained version of the active state that is specific to the unit type, which the active state is not) + Followed string // A unit that is being followed in its state by this unit, if there is any, otherwise the empty string. + Path dbus.ObjectPath // The unit object path + JobId uint32 // If there is a job queued for the job unit the numeric job id, 0 otherwise + JobType string // The job type as string + JobPath dbus.ObjectPath // The job object path +} + +type storeFunc func(retvalues ...interface{}) error + +func (c *Conn) listUnitsInternal(f storeFunc) ([]UnitStatus, error) { + result := make([][]interface{}, 0) + err := f(&result) + if err != nil { + return nil, err + } + + resultInterface := make([]interface{}, len(result)) + for i := range result { + resultInterface[i] = result[i] + } + + status := make([]UnitStatus, len(result)) + statusInterface := make([]interface{}, len(status)) + for i := range status { + statusInterface[i] = &status[i] + } + + err = dbus.Store(resultInterface, statusInterface...) + if err != nil { + return nil, err + } + + return status, nil +} + +// ListUnits returns an array with all currently loaded units. Note that +// units may be known by multiple names at the same time, and hence there might +// be more unit names loaded than actual units behind them. +func (c *Conn) ListUnits() ([]UnitStatus, error) { + return c.listUnitsInternal(c.sysobj.Call("org.freedesktop.systemd1.Manager.ListUnits", 0).Store) +} + +// ListUnitsFiltered returns an array with units filtered by state. +// It takes a list of units' statuses to filter. +func (c *Conn) ListUnitsFiltered(states []string) ([]UnitStatus, error) { + return c.listUnitsInternal(c.sysobj.Call("org.freedesktop.systemd1.Manager.ListUnitsFiltered", 0, states).Store) +} + +// ListUnitsByPatterns returns an array with units. +// It takes a list of units' statuses and names to filter. +// Note that units may be known by multiple names at the same time, +// and hence there might be more unit names loaded than actual units behind them. +func (c *Conn) ListUnitsByPatterns(states []string, patterns []string) ([]UnitStatus, error) { + return c.listUnitsInternal(c.sysobj.Call("org.freedesktop.systemd1.Manager.ListUnitsByPatterns", 0, states, patterns).Store) +} + +// ListUnitsByNames returns an array with units. It takes a list of units' +// names and returns an UnitStatus array. Comparing to ListUnitsByPatterns +// method, this method returns statuses even for inactive or non-existing +// units. Input array should contain exact unit names, but not patterns. +func (c *Conn) ListUnitsByNames(units []string) ([]UnitStatus, error) { + return c.listUnitsInternal(c.sysobj.Call("org.freedesktop.systemd1.Manager.ListUnitsByNames", 0, units).Store) +} + +type UnitFile struct { + Path string + Type string +} + +func (c *Conn) listUnitFilesInternal(f storeFunc) ([]UnitFile, error) { + result := make([][]interface{}, 0) + err := f(&result) + if err != nil { + return nil, err + } + + resultInterface := make([]interface{}, len(result)) + for i := range result { + resultInterface[i] = result[i] + } + + files := make([]UnitFile, len(result)) + fileInterface := make([]interface{}, len(files)) + for i := range files { + fileInterface[i] = &files[i] + } + + err = dbus.Store(resultInterface, fileInterface...) + if err != nil { + return nil, err + } + + return files, nil +} + +// ListUnitFiles returns an array of all available units on disk. +func (c *Conn) ListUnitFiles() ([]UnitFile, error) { + return c.listUnitFilesInternal(c.sysobj.Call("org.freedesktop.systemd1.Manager.ListUnitFiles", 0).Store) +} + +// ListUnitFilesByPatterns returns an array of all available units on disk matched the patterns. +func (c *Conn) ListUnitFilesByPatterns(states []string, patterns []string) ([]UnitFile, error) { + return c.listUnitFilesInternal(c.sysobj.Call("org.freedesktop.systemd1.Manager.ListUnitFilesByPatterns", 0, states, patterns).Store) +} + +type LinkUnitFileChange EnableUnitFileChange + +// LinkUnitFiles() links unit files (that are located outside of the +// usual unit search paths) into the unit search path. +// +// It takes a list of absolute paths to unit files to link and two +// booleans. The first boolean controls whether the unit shall be +// enabled for runtime only (true, /run), or persistently (false, +// /etc). +// The second controls whether symlinks pointing to other units shall +// be replaced if necessary. +// +// This call returns a list of the changes made. The list consists of +// structures with three strings: the type of the change (one of symlink +// or unlink), the file name of the symlink and the destination of the +// symlink. +func (c *Conn) LinkUnitFiles(files []string, runtime bool, force bool) ([]LinkUnitFileChange, error) { + result := make([][]interface{}, 0) + err := c.sysobj.Call("org.freedesktop.systemd1.Manager.LinkUnitFiles", 0, files, runtime, force).Store(&result) + if err != nil { + return nil, err + } + + resultInterface := make([]interface{}, len(result)) + for i := range result { + resultInterface[i] = result[i] + } + + changes := make([]LinkUnitFileChange, len(result)) + changesInterface := make([]interface{}, len(changes)) + for i := range changes { + changesInterface[i] = &changes[i] + } + + err = dbus.Store(resultInterface, changesInterface...) + if err != nil { + return nil, err + } + + return changes, nil +} + +// EnableUnitFiles() may be used to enable one or more units in the system (by +// creating symlinks to them in /etc or /run). +// +// It takes a list of unit files to enable (either just file names or full +// absolute paths if the unit files are residing outside the usual unit +// search paths), and two booleans: the first controls whether the unit shall +// be enabled for runtime only (true, /run), or persistently (false, /etc). +// The second one controls whether symlinks pointing to other units shall +// be replaced if necessary. +// +// This call returns one boolean and an array with the changes made. The +// boolean signals whether the unit files contained any enablement +// information (i.e. an [Install]) section. The changes list consists of +// structures with three strings: the type of the change (one of symlink +// or unlink), the file name of the symlink and the destination of the +// symlink. +func (c *Conn) EnableUnitFiles(files []string, runtime bool, force bool) (bool, []EnableUnitFileChange, error) { + var carries_install_info bool + + result := make([][]interface{}, 0) + err := c.sysobj.Call("org.freedesktop.systemd1.Manager.EnableUnitFiles", 0, files, runtime, force).Store(&carries_install_info, &result) + if err != nil { + return false, nil, err + } + + resultInterface := make([]interface{}, len(result)) + for i := range result { + resultInterface[i] = result[i] + } + + changes := make([]EnableUnitFileChange, len(result)) + changesInterface := make([]interface{}, len(changes)) + for i := range changes { + changesInterface[i] = &changes[i] + } + + err = dbus.Store(resultInterface, changesInterface...) + if err != nil { + return false, nil, err + } + + return carries_install_info, changes, nil +} + +type EnableUnitFileChange struct { + Type string // Type of the change (one of symlink or unlink) + Filename string // File name of the symlink + Destination string // Destination of the symlink +} + +// DisableUnitFiles() may be used to disable one or more units in the system (by +// removing symlinks to them from /etc or /run). +// +// It takes a list of unit files to disable (either just file names or full +// absolute paths if the unit files are residing outside the usual unit +// search paths), and one boolean: whether the unit was enabled for runtime +// only (true, /run), or persistently (false, /etc). +// +// This call returns an array with the changes made. The changes list +// consists of structures with three strings: the type of the change (one of +// symlink or unlink), the file name of the symlink and the destination of the +// symlink. +func (c *Conn) DisableUnitFiles(files []string, runtime bool) ([]DisableUnitFileChange, error) { + result := make([][]interface{}, 0) + err := c.sysobj.Call("org.freedesktop.systemd1.Manager.DisableUnitFiles", 0, files, runtime).Store(&result) + if err != nil { + return nil, err + } + + resultInterface := make([]interface{}, len(result)) + for i := range result { + resultInterface[i] = result[i] + } + + changes := make([]DisableUnitFileChange, len(result)) + changesInterface := make([]interface{}, len(changes)) + for i := range changes { + changesInterface[i] = &changes[i] + } + + err = dbus.Store(resultInterface, changesInterface...) + if err != nil { + return nil, err + } + + return changes, nil +} + +type DisableUnitFileChange struct { + Type string // Type of the change (one of symlink or unlink) + Filename string // File name of the symlink + Destination string // Destination of the symlink +} + +// Reload instructs systemd to scan for and reload unit files. This is +// equivalent to a 'systemctl daemon-reload'. +func (c *Conn) Reload() error { + return c.sysobj.Call("org.freedesktop.systemd1.Manager.Reload", 0).Store() +} + +func unitPath(name string) dbus.ObjectPath { + return dbus.ObjectPath("/org/freedesktop/systemd1/unit/" + PathBusEscape(name)) +} diff --git a/vendor/github.com/coreos/go-systemd/dbus/properties.go b/vendor/github.com/coreos/go-systemd/dbus/properties.go new file mode 100644 index 0000000000..7520011564 --- /dev/null +++ b/vendor/github.com/coreos/go-systemd/dbus/properties.go @@ -0,0 +1,218 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package dbus + +import ( + "github.com/godbus/dbus" +) + +// From the systemd docs: +// +// The properties array of StartTransientUnit() may take many of the settings +// that may also be configured in unit files. Not all parameters are currently +// accepted though, but we plan to cover more properties with future release. +// Currently you may set the Description, Slice and all dependency types of +// units, as well as RemainAfterExit, ExecStart for service units, +// TimeoutStopUSec and PIDs for scope units, and CPUAccounting, CPUShares, +// BlockIOAccounting, BlockIOWeight, BlockIOReadBandwidth, +// BlockIOWriteBandwidth, BlockIODeviceWeight, MemoryAccounting, MemoryLimit, +// DevicePolicy, DeviceAllow for services/scopes/slices. These fields map +// directly to their counterparts in unit files and as normal D-Bus object +// properties. The exception here is the PIDs field of scope units which is +// used for construction of the scope only and specifies the initial PIDs to +// add to the scope object. + +type Property struct { + Name string + Value dbus.Variant +} + +type PropertyCollection struct { + Name string + Properties []Property +} + +type execStart struct { + Path string // the binary path to execute + Args []string // an array with all arguments to pass to the executed command, starting with argument 0 + UncleanIsFailure bool // a boolean whether it should be considered a failure if the process exits uncleanly +} + +// PropExecStart sets the ExecStart service property. The first argument is a +// slice with the binary path to execute followed by the arguments to pass to +// the executed command. See +// http://www.freedesktop.org/software/systemd/man/systemd.service.html#ExecStart= +func PropExecStart(command []string, uncleanIsFailure bool) Property { + execStarts := []execStart{ + execStart{ + Path: command[0], + Args: command, + UncleanIsFailure: uncleanIsFailure, + }, + } + + return Property{ + Name: "ExecStart", + Value: dbus.MakeVariant(execStarts), + } +} + +// PropRemainAfterExit sets the RemainAfterExit service property. See +// http://www.freedesktop.org/software/systemd/man/systemd.service.html#RemainAfterExit= +func PropRemainAfterExit(b bool) Property { + return Property{ + Name: "RemainAfterExit", + Value: dbus.MakeVariant(b), + } +} + +// PropDescription sets the Description unit property. See +// http://www.freedesktop.org/software/systemd/man/systemd.unit#Description= +func PropDescription(desc string) Property { + return Property{ + Name: "Description", + Value: dbus.MakeVariant(desc), + } +} + +func propDependency(name string, units []string) Property { + return Property{ + Name: name, + Value: dbus.MakeVariant(units), + } +} + +// PropRequires sets the Requires unit property. See +// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Requires= +func PropRequires(units ...string) Property { + return propDependency("Requires", units) +} + +// PropRequiresOverridable sets the RequiresOverridable unit property. See +// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#RequiresOverridable= +func PropRequiresOverridable(units ...string) Property { + return propDependency("RequiresOverridable", units) +} + +// PropRequisite sets the Requisite unit property. See +// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Requisite= +func PropRequisite(units ...string) Property { + return propDependency("Requisite", units) +} + +// PropRequisiteOverridable sets the RequisiteOverridable unit property. See +// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#RequisiteOverridable= +func PropRequisiteOverridable(units ...string) Property { + return propDependency("RequisiteOverridable", units) +} + +// PropWants sets the Wants unit property. See +// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Wants= +func PropWants(units ...string) Property { + return propDependency("Wants", units) +} + +// PropBindsTo sets the BindsTo unit property. See +// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#BindsTo= +func PropBindsTo(units ...string) Property { + return propDependency("BindsTo", units) +} + +// PropRequiredBy sets the RequiredBy unit property. See +// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#RequiredBy= +func PropRequiredBy(units ...string) Property { + return propDependency("RequiredBy", units) +} + +// PropRequiredByOverridable sets the RequiredByOverridable unit property. See +// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#RequiredByOverridable= +func PropRequiredByOverridable(units ...string) Property { + return propDependency("RequiredByOverridable", units) +} + +// PropWantedBy sets the WantedBy unit property. See +// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#WantedBy= +func PropWantedBy(units ...string) Property { + return propDependency("WantedBy", units) +} + +// PropBoundBy sets the BoundBy unit property. See +// http://www.freedesktop.org/software/systemd/main/systemd.unit.html#BoundBy= +func PropBoundBy(units ...string) Property { + return propDependency("BoundBy", units) +} + +// PropConflicts sets the Conflicts unit property. See +// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Conflicts= +func PropConflicts(units ...string) Property { + return propDependency("Conflicts", units) +} + +// PropConflictedBy sets the ConflictedBy unit property. See +// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#ConflictedBy= +func PropConflictedBy(units ...string) Property { + return propDependency("ConflictedBy", units) +} + +// PropBefore sets the Before unit property. See +// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Before= +func PropBefore(units ...string) Property { + return propDependency("Before", units) +} + +// PropAfter sets the After unit property. See +// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#After= +func PropAfter(units ...string) Property { + return propDependency("After", units) +} + +// PropOnFailure sets the OnFailure unit property. See +// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#OnFailure= +func PropOnFailure(units ...string) Property { + return propDependency("OnFailure", units) +} + +// PropTriggers sets the Triggers unit property. See +// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Triggers= +func PropTriggers(units ...string) Property { + return propDependency("Triggers", units) +} + +// PropTriggeredBy sets the TriggeredBy unit property. See +// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#TriggeredBy= +func PropTriggeredBy(units ...string) Property { + return propDependency("TriggeredBy", units) +} + +// PropPropagatesReloadTo sets the PropagatesReloadTo unit property. See +// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#PropagatesReloadTo= +func PropPropagatesReloadTo(units ...string) Property { + return propDependency("PropagatesReloadTo", units) +} + +// PropRequiresMountsFor sets the RequiresMountsFor unit property. See +// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#RequiresMountsFor= +func PropRequiresMountsFor(units ...string) Property { + return propDependency("RequiresMountsFor", units) +} + +// PropSlice sets the Slice unit property. See +// http://www.freedesktop.org/software/systemd/man/systemd.resource-control.html#Slice= +func PropSlice(slice string) Property { + return Property{ + Name: "Slice", + Value: dbus.MakeVariant(slice), + } +} diff --git a/vendor/github.com/coreos/go-systemd/dbus/set.go b/vendor/github.com/coreos/go-systemd/dbus/set.go new file mode 100644 index 0000000000..f92e6fbed1 --- /dev/null +++ b/vendor/github.com/coreos/go-systemd/dbus/set.go @@ -0,0 +1,47 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package dbus + +type set struct { + data map[string]bool +} + +func (s *set) Add(value string) { + s.data[value] = true +} + +func (s *set) Remove(value string) { + delete(s.data, value) +} + +func (s *set) Contains(value string) (exists bool) { + _, exists = s.data[value] + return +} + +func (s *set) Length() int { + return len(s.data) +} + +func (s *set) Values() (values []string) { + for val, _ := range s.data { + values = append(values, val) + } + return +} + +func newSet() *set { + return &set{make(map[string]bool)} +} diff --git a/vendor/github.com/coreos/go-systemd/dbus/subscription.go b/vendor/github.com/coreos/go-systemd/dbus/subscription.go new file mode 100644 index 0000000000..996451445c --- /dev/null +++ b/vendor/github.com/coreos/go-systemd/dbus/subscription.go @@ -0,0 +1,250 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package dbus + +import ( + "errors" + "time" + + "github.com/godbus/dbus" +) + +const ( + cleanIgnoreInterval = int64(10 * time.Second) + ignoreInterval = int64(30 * time.Millisecond) +) + +// Subscribe sets up this connection to subscribe to all systemd dbus events. +// This is required before calling SubscribeUnits. When the connection closes +// systemd will automatically stop sending signals so there is no need to +// explicitly call Unsubscribe(). +func (c *Conn) Subscribe() error { + c.sigconn.BusObject().Call("org.freedesktop.DBus.AddMatch", 0, + "type='signal',interface='org.freedesktop.systemd1.Manager',member='UnitNew'") + c.sigconn.BusObject().Call("org.freedesktop.DBus.AddMatch", 0, + "type='signal',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged'") + + err := c.sigobj.Call("org.freedesktop.systemd1.Manager.Subscribe", 0).Store() + if err != nil { + return err + } + + return nil +} + +// Unsubscribe this connection from systemd dbus events. +func (c *Conn) Unsubscribe() error { + err := c.sigobj.Call("org.freedesktop.systemd1.Manager.Unsubscribe", 0).Store() + if err != nil { + return err + } + + return nil +} + +func (c *Conn) dispatch() { + ch := make(chan *dbus.Signal, signalBuffer) + + c.sigconn.Signal(ch) + + go func() { + for { + signal, ok := <-ch + if !ok { + return + } + + if signal.Name == "org.freedesktop.systemd1.Manager.JobRemoved" { + c.jobComplete(signal) + } + + if c.subscriber.updateCh == nil { + continue + } + + var unitPath dbus.ObjectPath + switch signal.Name { + case "org.freedesktop.systemd1.Manager.JobRemoved": + unitName := signal.Body[2].(string) + c.sysobj.Call("org.freedesktop.systemd1.Manager.GetUnit", 0, unitName).Store(&unitPath) + case "org.freedesktop.systemd1.Manager.UnitNew": + unitPath = signal.Body[1].(dbus.ObjectPath) + case "org.freedesktop.DBus.Properties.PropertiesChanged": + if signal.Body[0].(string) == "org.freedesktop.systemd1.Unit" { + unitPath = signal.Path + } + } + + if unitPath == dbus.ObjectPath("") { + continue + } + + c.sendSubStateUpdate(unitPath) + } + }() +} + +// Returns two unbuffered channels which will receive all changed units every +// interval. Deleted units are sent as nil. +func (c *Conn) SubscribeUnits(interval time.Duration) (<-chan map[string]*UnitStatus, <-chan error) { + return c.SubscribeUnitsCustom(interval, 0, func(u1, u2 *UnitStatus) bool { return *u1 != *u2 }, nil) +} + +// SubscribeUnitsCustom is like SubscribeUnits but lets you specify the buffer +// size of the channels, the comparison function for detecting changes and a filter +// function for cutting down on the noise that your channel receives. +func (c *Conn) SubscribeUnitsCustom(interval time.Duration, buffer int, isChanged func(*UnitStatus, *UnitStatus) bool, filterUnit func(string) bool) (<-chan map[string]*UnitStatus, <-chan error) { + old := make(map[string]*UnitStatus) + statusChan := make(chan map[string]*UnitStatus, buffer) + errChan := make(chan error, buffer) + + go func() { + for { + timerChan := time.After(interval) + + units, err := c.ListUnits() + if err == nil { + cur := make(map[string]*UnitStatus) + for i := range units { + if filterUnit != nil && filterUnit(units[i].Name) { + continue + } + cur[units[i].Name] = &units[i] + } + + // add all new or changed units + changed := make(map[string]*UnitStatus) + for n, u := range cur { + if oldU, ok := old[n]; !ok || isChanged(oldU, u) { + changed[n] = u + } + delete(old, n) + } + + // add all deleted units + for oldN := range old { + changed[oldN] = nil + } + + old = cur + + if len(changed) != 0 { + statusChan <- changed + } + } else { + errChan <- err + } + + <-timerChan + } + }() + + return statusChan, errChan +} + +type SubStateUpdate struct { + UnitName string + SubState string +} + +// SetSubStateSubscriber writes to updateCh when any unit's substate changes. +// Although this writes to updateCh on every state change, the reported state +// may be more recent than the change that generated it (due to an unavoidable +// race in the systemd dbus interface). That is, this method provides a good +// way to keep a current view of all units' states, but is not guaranteed to +// show every state transition they go through. Furthermore, state changes +// will only be written to the channel with non-blocking writes. If updateCh +// is full, it attempts to write an error to errCh; if errCh is full, the error +// passes silently. +func (c *Conn) SetSubStateSubscriber(updateCh chan<- *SubStateUpdate, errCh chan<- error) { + c.subscriber.Lock() + defer c.subscriber.Unlock() + c.subscriber.updateCh = updateCh + c.subscriber.errCh = errCh +} + +func (c *Conn) sendSubStateUpdate(path dbus.ObjectPath) { + c.subscriber.Lock() + defer c.subscriber.Unlock() + + if c.shouldIgnore(path) { + return + } + + info, err := c.GetUnitProperties(string(path)) + if err != nil { + select { + case c.subscriber.errCh <- err: + default: + } + } + + name := info["Id"].(string) + substate := info["SubState"].(string) + + update := &SubStateUpdate{name, substate} + select { + case c.subscriber.updateCh <- update: + default: + select { + case c.subscriber.errCh <- errors.New("update channel full!"): + default: + } + } + + c.updateIgnore(path, info) +} + +// The ignore functions work around a wart in the systemd dbus interface. +// Requesting the properties of an unloaded unit will cause systemd to send a +// pair of UnitNew/UnitRemoved signals. Because we need to get a unit's +// properties on UnitNew (as that's the only indication of a new unit coming up +// for the first time), we would enter an infinite loop if we did not attempt +// to detect and ignore these spurious signals. The signal themselves are +// indistinguishable from relevant ones, so we (somewhat hackishly) ignore an +// unloaded unit's signals for a short time after requesting its properties. +// This means that we will miss e.g. a transient unit being restarted +// *immediately* upon failure and also a transient unit being started +// immediately after requesting its status (with systemctl status, for example, +// because this causes a UnitNew signal to be sent which then causes us to fetch +// the properties). + +func (c *Conn) shouldIgnore(path dbus.ObjectPath) bool { + t, ok := c.subscriber.ignore[path] + return ok && t >= time.Now().UnixNano() +} + +func (c *Conn) updateIgnore(path dbus.ObjectPath, info map[string]interface{}) { + c.cleanIgnore() + + // unit is unloaded - it will trigger bad systemd dbus behavior + if info["LoadState"].(string) == "not-found" { + c.subscriber.ignore[path] = time.Now().UnixNano() + ignoreInterval + } +} + +// without this, ignore would grow unboundedly over time +func (c *Conn) cleanIgnore() { + now := time.Now().UnixNano() + if c.subscriber.cleanIgnore < now { + c.subscriber.cleanIgnore = now + cleanIgnoreInterval + + for p, t := range c.subscriber.ignore { + if t < now { + delete(c.subscriber.ignore, p) + } + } + } +} diff --git a/vendor/github.com/coreos/go-systemd/dbus/subscription_set.go b/vendor/github.com/coreos/go-systemd/dbus/subscription_set.go new file mode 100644 index 0000000000..5b408d5847 --- /dev/null +++ b/vendor/github.com/coreos/go-systemd/dbus/subscription_set.go @@ -0,0 +1,57 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package dbus + +import ( + "time" +) + +// SubscriptionSet returns a subscription set which is like conn.Subscribe but +// can filter to only return events for a set of units. +type SubscriptionSet struct { + *set + conn *Conn +} + +func (s *SubscriptionSet) filter(unit string) bool { + return !s.Contains(unit) +} + +// Subscribe starts listening for dbus events for all of the units in the set. +// Returns channels identical to conn.SubscribeUnits. +func (s *SubscriptionSet) Subscribe() (<-chan map[string]*UnitStatus, <-chan error) { + // TODO: Make fully evented by using systemd 209 with properties changed values + return s.conn.SubscribeUnitsCustom(time.Second, 0, + mismatchUnitStatus, + func(unit string) bool { return s.filter(unit) }, + ) +} + +// NewSubscriptionSet returns a new subscription set. +func (conn *Conn) NewSubscriptionSet() *SubscriptionSet { + return &SubscriptionSet{newSet(), conn} +} + +// mismatchUnitStatus returns true if the provided UnitStatus objects +// are not equivalent. false is returned if the objects are equivalent. +// Only the Name, Description and state-related fields are used in +// the comparison. +func mismatchUnitStatus(u1, u2 *UnitStatus) bool { + return u1.Name != u2.Name || + u1.Description != u2.Description || + u1.LoadState != u2.LoadState || + u1.ActiveState != u2.ActiveState || + u1.SubState != u2.SubState +} diff --git a/vendor/github.com/coreos/go-systemd/sdjournal/journal.go b/vendor/github.com/coreos/go-systemd/sdjournal/journal.go new file mode 100644 index 0000000000..4fd29c66f1 --- /dev/null +++ b/vendor/github.com/coreos/go-systemd/sdjournal/journal.go @@ -0,0 +1,971 @@ +// Copyright 2015 RedHat, Inc. +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package sdjournal provides a low-level Go interface to the +// systemd journal wrapped around the sd-journal C API. +// +// All public read methods map closely to the sd-journal API functions. See the +// sd-journal.h documentation[1] for information about each function. +// +// To write to the journal, see the pure-Go "journal" package +// +// [1] http://www.freedesktop.org/software/systemd/man/sd-journal.html +package sdjournal + +// #include +// #include +// #include +// #include +// +// int +// my_sd_journal_open(void *f, sd_journal **ret, int flags) +// { +// int (*sd_journal_open)(sd_journal **, int); +// +// sd_journal_open = f; +// return sd_journal_open(ret, flags); +// } +// +// int +// my_sd_journal_open_directory(void *f, sd_journal **ret, const char *path, int flags) +// { +// int (*sd_journal_open_directory)(sd_journal **, const char *, int); +// +// sd_journal_open_directory = f; +// return sd_journal_open_directory(ret, path, flags); +// } +// +// void +// my_sd_journal_close(void *f, sd_journal *j) +// { +// int (*sd_journal_close)(sd_journal *); +// +// sd_journal_close = f; +// sd_journal_close(j); +// } +// +// int +// my_sd_journal_get_usage(void *f, sd_journal *j, uint64_t *bytes) +// { +// int (*sd_journal_get_usage)(sd_journal *, uint64_t *); +// +// sd_journal_get_usage = f; +// return sd_journal_get_usage(j, bytes); +// } +// +// int +// my_sd_journal_add_match(void *f, sd_journal *j, const void *data, size_t size) +// { +// int (*sd_journal_add_match)(sd_journal *, const void *, size_t); +// +// sd_journal_add_match = f; +// return sd_journal_add_match(j, data, size); +// } +// +// int +// my_sd_journal_add_disjunction(void *f, sd_journal *j) +// { +// int (*sd_journal_add_disjunction)(sd_journal *); +// +// sd_journal_add_disjunction = f; +// return sd_journal_add_disjunction(j); +// } +// +// int +// my_sd_journal_add_conjunction(void *f, sd_journal *j) +// { +// int (*sd_journal_add_conjunction)(sd_journal *); +// +// sd_journal_add_conjunction = f; +// return sd_journal_add_conjunction(j); +// } +// +// void +// my_sd_journal_flush_matches(void *f, sd_journal *j) +// { +// int (*sd_journal_flush_matches)(sd_journal *); +// +// sd_journal_flush_matches = f; +// sd_journal_flush_matches(j); +// } +// +// int +// my_sd_journal_next(void *f, sd_journal *j) +// { +// int (*sd_journal_next)(sd_journal *); +// +// sd_journal_next = f; +// return sd_journal_next(j); +// } +// +// int +// my_sd_journal_next_skip(void *f, sd_journal *j, uint64_t skip) +// { +// int (*sd_journal_next_skip)(sd_journal *, uint64_t); +// +// sd_journal_next_skip = f; +// return sd_journal_next_skip(j, skip); +// } +// +// int +// my_sd_journal_previous(void *f, sd_journal *j) +// { +// int (*sd_journal_previous)(sd_journal *); +// +// sd_journal_previous = f; +// return sd_journal_previous(j); +// } +// +// int +// my_sd_journal_previous_skip(void *f, sd_journal *j, uint64_t skip) +// { +// int (*sd_journal_previous_skip)(sd_journal *, uint64_t); +// +// sd_journal_previous_skip = f; +// return sd_journal_previous_skip(j, skip); +// } +// +// int +// my_sd_journal_get_data(void *f, sd_journal *j, const char *field, const void **data, size_t *length) +// { +// int (*sd_journal_get_data)(sd_journal *, const char *, const void **, size_t *); +// +// sd_journal_get_data = f; +// return sd_journal_get_data(j, field, data, length); +// } +// +// int +// my_sd_journal_set_data_threshold(void *f, sd_journal *j, size_t sz) +// { +// int (*sd_journal_set_data_threshold)(sd_journal *, size_t); +// +// sd_journal_set_data_threshold = f; +// return sd_journal_set_data_threshold(j, sz); +// } +// +// int +// my_sd_journal_get_cursor(void *f, sd_journal *j, char **cursor) +// { +// int (*sd_journal_get_cursor)(sd_journal *, char **); +// +// sd_journal_get_cursor = f; +// return sd_journal_get_cursor(j, cursor); +// } +// +// int +// my_sd_journal_test_cursor(void *f, sd_journal *j, const char *cursor) +// { +// int (*sd_journal_test_cursor)(sd_journal *, const char *); +// +// sd_journal_test_cursor = f; +// return sd_journal_test_cursor(j, cursor); +// } +// +// int +// my_sd_journal_get_realtime_usec(void *f, sd_journal *j, uint64_t *usec) +// { +// int (*sd_journal_get_realtime_usec)(sd_journal *, uint64_t *); +// +// sd_journal_get_realtime_usec = f; +// return sd_journal_get_realtime_usec(j, usec); +// } +// +// int +// my_sd_journal_get_monotonic_usec(void *f, sd_journal *j, uint64_t *usec, sd_id128_t *boot_id) +// { +// int (*sd_journal_get_monotonic_usec)(sd_journal *, uint64_t *, sd_id128_t *); +// +// sd_journal_get_monotonic_usec = f; +// return sd_journal_get_monotonic_usec(j, usec, boot_id); +// } +// +// int +// my_sd_journal_seek_head(void *f, sd_journal *j) +// { +// int (*sd_journal_seek_head)(sd_journal *); +// +// sd_journal_seek_head = f; +// return sd_journal_seek_head(j); +// } +// +// int +// my_sd_journal_seek_tail(void *f, sd_journal *j) +// { +// int (*sd_journal_seek_tail)(sd_journal *); +// +// sd_journal_seek_tail = f; +// return sd_journal_seek_tail(j); +// } +// +// +// int +// my_sd_journal_seek_cursor(void *f, sd_journal *j, const char *cursor) +// { +// int (*sd_journal_seek_cursor)(sd_journal *, const char *); +// +// sd_journal_seek_cursor = f; +// return sd_journal_seek_cursor(j, cursor); +// } +// +// int +// my_sd_journal_seek_realtime_usec(void *f, sd_journal *j, uint64_t usec) +// { +// int (*sd_journal_seek_realtime_usec)(sd_journal *, uint64_t); +// +// sd_journal_seek_realtime_usec = f; +// return sd_journal_seek_realtime_usec(j, usec); +// } +// +// int +// my_sd_journal_wait(void *f, sd_journal *j, uint64_t timeout_usec) +// { +// int (*sd_journal_wait)(sd_journal *, uint64_t); +// +// sd_journal_wait = f; +// return sd_journal_wait(j, timeout_usec); +// } +// +// void +// my_sd_journal_restart_data(void *f, sd_journal *j) +// { +// void (*sd_journal_restart_data)(sd_journal *); +// +// sd_journal_restart_data = f; +// sd_journal_restart_data(j); +// } +// +// int +// my_sd_journal_enumerate_data(void *f, sd_journal *j, const void **data, size_t *length) +// { +// int (*sd_journal_enumerate_data)(sd_journal *, const void **, size_t *); +// +// sd_journal_enumerate_data = f; +// return sd_journal_enumerate_data(j, data, length); +// } +// +import "C" +import ( + "fmt" + "path/filepath" + "strings" + "sync" + "syscall" + "time" + "unsafe" + + "github.com/coreos/pkg/dlopen" +) + +var libsystemdFunctions = map[string]unsafe.Pointer{} + +// Journal entry field strings which correspond to: +// http://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html +const ( + // User Journal Fields + SD_JOURNAL_FIELD_MESSAGE = "MESSAGE" + SD_JOURNAL_FIELD_MESSAGE_ID = "MESSAGE_ID" + SD_JOURNAL_FIELD_PRIORITY = "PRIORITY" + SD_JOURNAL_FIELD_CODE_FILE = "CODE_FILE" + SD_JOURNAL_FIELD_CODE_LINE = "CODE_LINE" + SD_JOURNAL_FIELD_CODE_FUNC = "CODE_FUNC" + SD_JOURNAL_FIELD_ERRNO = "ERRNO" + SD_JOURNAL_FIELD_SYSLOG_FACILITY = "SYSLOG_FACILITY" + SD_JOURNAL_FIELD_SYSLOG_IDENTIFIER = "SYSLOG_IDENTIFIER" + SD_JOURNAL_FIELD_SYSLOG_PID = "SYSLOG_PID" + + // Trusted Journal Fields + SD_JOURNAL_FIELD_PID = "_PID" + SD_JOURNAL_FIELD_UID = "_UID" + SD_JOURNAL_FIELD_GID = "_GID" + SD_JOURNAL_FIELD_COMM = "_COMM" + SD_JOURNAL_FIELD_EXE = "_EXE" + SD_JOURNAL_FIELD_CMDLINE = "_CMDLINE" + SD_JOURNAL_FIELD_CAP_EFFECTIVE = "_CAP_EFFECTIVE" + SD_JOURNAL_FIELD_AUDIT_SESSION = "_AUDIT_SESSION" + SD_JOURNAL_FIELD_AUDIT_LOGINUID = "_AUDIT_LOGINUID" + SD_JOURNAL_FIELD_SYSTEMD_CGROUP = "_SYSTEMD_CGROUP" + SD_JOURNAL_FIELD_SYSTEMD_SESSION = "_SYSTEMD_SESSION" + SD_JOURNAL_FIELD_SYSTEMD_UNIT = "_SYSTEMD_UNIT" + SD_JOURNAL_FIELD_SYSTEMD_USER_UNIT = "_SYSTEMD_USER_UNIT" + SD_JOURNAL_FIELD_SYSTEMD_OWNER_UID = "_SYSTEMD_OWNER_UID" + SD_JOURNAL_FIELD_SYSTEMD_SLICE = "_SYSTEMD_SLICE" + SD_JOURNAL_FIELD_SELINUX_CONTEXT = "_SELINUX_CONTEXT" + SD_JOURNAL_FIELD_SOURCE_REALTIME_TIMESTAMP = "_SOURCE_REALTIME_TIMESTAMP" + SD_JOURNAL_FIELD_BOOT_ID = "_BOOT_ID" + SD_JOURNAL_FIELD_MACHINE_ID = "_MACHINE_ID" + SD_JOURNAL_FIELD_HOSTNAME = "_HOSTNAME" + SD_JOURNAL_FIELD_TRANSPORT = "_TRANSPORT" + + // Address Fields + SD_JOURNAL_FIELD_CURSOR = "__CURSOR" + SD_JOURNAL_FIELD_REALTIME_TIMESTAMP = "__REALTIME_TIMESTAMP" + SD_JOURNAL_FIELD_MONOTONIC_TIMESTAMP = "__MONOTONIC_TIMESTAMP" +) + +// Journal event constants +const ( + SD_JOURNAL_NOP = int(C.SD_JOURNAL_NOP) + SD_JOURNAL_APPEND = int(C.SD_JOURNAL_APPEND) + SD_JOURNAL_INVALIDATE = int(C.SD_JOURNAL_INVALIDATE) +) + +const ( + // IndefiniteWait is a sentinel value that can be passed to + // sdjournal.Wait() to signal an indefinite wait for new journal + // events. It is implemented as the maximum value for a time.Duration: + // https://github.com/golang/go/blob/e4dcf5c8c22d98ac9eac7b9b226596229624cb1d/src/time/time.go#L434 + IndefiniteWait time.Duration = 1<<63 - 1 +) + +var libsystemdNames = []string{ + // systemd < 209 + "libsystemd-journal.so.0", + "libsystemd-journal.so", + + // systemd >= 209 merged libsystemd-journal into libsystemd proper + "libsystemd.so.0", + "libsystemd.so", +} + +// Journal is a Go wrapper of an sd_journal structure. +type Journal struct { + cjournal *C.sd_journal + mu sync.Mutex + lib *dlopen.LibHandle +} + +// JournalEntry represents all fields of a journal entry plus address fields. +type JournalEntry struct { + Fields map[string]string + Cursor string + RealtimeTimestamp uint64 + MonotonicTimestamp uint64 +} + +// Match is a convenience wrapper to describe filters supplied to AddMatch. +type Match struct { + Field string + Value string +} + +// String returns a string representation of a Match suitable for use with AddMatch. +func (m *Match) String() string { + return m.Field + "=" + m.Value +} + +func (j *Journal) getFunction(name string) (unsafe.Pointer, error) { + j.mu.Lock() + defer j.mu.Unlock() + f, ok := libsystemdFunctions[name] + if !ok { + var err error + f, err = j.lib.GetSymbolPointer(name) + if err != nil { + return nil, err + } + + libsystemdFunctions[name] = f + } + + return f, nil +} + +// NewJournal returns a new Journal instance pointing to the local journal +func NewJournal() (j *Journal, err error) { + h, err := dlopen.GetHandle(libsystemdNames) + if err != nil { + return nil, err + } + defer func() { + if err == nil { + return + } + err2 := h.Close() + if err2 != nil { + err = fmt.Errorf(`%q and "error closing handle: %v"`, err, err2) + } + }() + + j = &Journal{lib: h} + + sd_journal_open, err := j.getFunction("sd_journal_open") + if err != nil { + return nil, err + } + + r := C.my_sd_journal_open(sd_journal_open, &j.cjournal, C.SD_JOURNAL_LOCAL_ONLY) + + if r < 0 { + return nil, fmt.Errorf("failed to open journal: %d", syscall.Errno(-r)) + } + + return j, nil +} + +// NewJournalFromDir returns a new Journal instance pointing to a journal residing +// in a given directory. The supplied path may be relative or absolute; if +// relative, it will be converted to an absolute path before being opened. +func NewJournalFromDir(path string) (j *Journal, err error) { + h, err := dlopen.GetHandle(libsystemdNames) + if err != nil { + return nil, err + } + defer func() { + if err == nil { + return + } + err2 := h.Close() + if err2 != nil { + err = fmt.Errorf(`%q and "error closing handle: %v"`, err, err2) + } + }() + + path, err = filepath.Abs(path) + if err != nil { + return nil, err + } + + j = &Journal{lib: h} + + sd_journal_open_directory, err := j.getFunction("sd_journal_open_directory") + if err != nil { + return nil, err + } + + p := C.CString(path) + defer C.free(unsafe.Pointer(p)) + + r := C.my_sd_journal_open_directory(sd_journal_open_directory, &j.cjournal, p, 0) + if r < 0 { + return nil, fmt.Errorf("failed to open journal in directory %q: %d", path, syscall.Errno(-r)) + } + + return j, nil +} + +// Close closes a journal opened with NewJournal. +func (j *Journal) Close() error { + sd_journal_close, err := j.getFunction("sd_journal_close") + if err != nil { + return err + } + + j.mu.Lock() + C.my_sd_journal_close(sd_journal_close, j.cjournal) + j.mu.Unlock() + + // we don't close the handle to reuse the symbol cache between Journal + // instances. It will go away when the process exits. + return nil +} + +// AddMatch adds a match by which to filter the entries of the journal. +func (j *Journal) AddMatch(match string) error { + sd_journal_add_match, err := j.getFunction("sd_journal_add_match") + if err != nil { + return err + } + + m := C.CString(match) + defer C.free(unsafe.Pointer(m)) + + j.mu.Lock() + r := C.my_sd_journal_add_match(sd_journal_add_match, j.cjournal, unsafe.Pointer(m), C.size_t(len(match))) + j.mu.Unlock() + + if r < 0 { + return fmt.Errorf("failed to add match: %d", syscall.Errno(-r)) + } + + return nil +} + +// AddDisjunction inserts a logical OR in the match list. +func (j *Journal) AddDisjunction() error { + sd_journal_add_disjunction, err := j.getFunction("sd_journal_add_disjunction") + if err != nil { + return err + } + + j.mu.Lock() + r := C.my_sd_journal_add_disjunction(sd_journal_add_disjunction, j.cjournal) + j.mu.Unlock() + + if r < 0 { + return fmt.Errorf("failed to add a disjunction in the match list: %d", syscall.Errno(-r)) + } + + return nil +} + +// AddConjunction inserts a logical AND in the match list. +func (j *Journal) AddConjunction() error { + sd_journal_add_conjunction, err := j.getFunction("sd_journal_add_conjunction") + if err != nil { + return err + } + + j.mu.Lock() + r := C.my_sd_journal_add_conjunction(sd_journal_add_conjunction, j.cjournal) + j.mu.Unlock() + + if r < 0 { + return fmt.Errorf("failed to add a conjunction in the match list: %d", syscall.Errno(-r)) + } + + return nil +} + +// FlushMatches flushes all matches, disjunctions and conjunctions. +func (j *Journal) FlushMatches() { + sd_journal_flush_matches, err := j.getFunction("sd_journal_flush_matches") + if err != nil { + return + } + + j.mu.Lock() + C.my_sd_journal_flush_matches(sd_journal_flush_matches, j.cjournal) + j.mu.Unlock() +} + +// Next advances the read pointer into the journal by one entry. +func (j *Journal) Next() (int, error) { + sd_journal_next, err := j.getFunction("sd_journal_next") + if err != nil { + return -1, err + } + + j.mu.Lock() + r := C.my_sd_journal_next(sd_journal_next, j.cjournal) + j.mu.Unlock() + + if r < 0 { + return int(r), fmt.Errorf("failed to iterate journal: %d", syscall.Errno(-r)) + } + + return int(r), nil +} + +// NextSkip advances the read pointer by multiple entries at once, +// as specified by the skip parameter. +func (j *Journal) NextSkip(skip uint64) (uint64, error) { + sd_journal_next_skip, err := j.getFunction("sd_journal_next_skip") + if err != nil { + return 0, err + } + + j.mu.Lock() + r := C.my_sd_journal_next_skip(sd_journal_next_skip, j.cjournal, C.uint64_t(skip)) + j.mu.Unlock() + + if r < 0 { + return uint64(r), fmt.Errorf("failed to iterate journal: %d", syscall.Errno(-r)) + } + + return uint64(r), nil +} + +// Previous sets the read pointer into the journal back by one entry. +func (j *Journal) Previous() (uint64, error) { + sd_journal_previous, err := j.getFunction("sd_journal_previous") + if err != nil { + return 0, err + } + + j.mu.Lock() + r := C.my_sd_journal_previous(sd_journal_previous, j.cjournal) + j.mu.Unlock() + + if r < 0 { + return uint64(r), fmt.Errorf("failed to iterate journal: %d", syscall.Errno(-r)) + } + + return uint64(r), nil +} + +// PreviousSkip sets back the read pointer by multiple entries at once, +// as specified by the skip parameter. +func (j *Journal) PreviousSkip(skip uint64) (uint64, error) { + sd_journal_previous_skip, err := j.getFunction("sd_journal_previous_skip") + if err != nil { + return 0, err + } + + j.mu.Lock() + r := C.my_sd_journal_previous_skip(sd_journal_previous_skip, j.cjournal, C.uint64_t(skip)) + j.mu.Unlock() + + if r < 0 { + return uint64(r), fmt.Errorf("failed to iterate journal: %d", syscall.Errno(-r)) + } + + return uint64(r), nil +} + +// GetData gets the data object associated with a specific field from the +// current journal entry. +func (j *Journal) GetData(field string) (string, error) { + sd_journal_get_data, err := j.getFunction("sd_journal_get_data") + if err != nil { + return "", err + } + + f := C.CString(field) + defer C.free(unsafe.Pointer(f)) + + var d unsafe.Pointer + var l C.size_t + + j.mu.Lock() + r := C.my_sd_journal_get_data(sd_journal_get_data, j.cjournal, f, &d, &l) + j.mu.Unlock() + + if r < 0 { + return "", fmt.Errorf("failed to read message: %d", syscall.Errno(-r)) + } + + msg := C.GoStringN((*C.char)(d), C.int(l)) + + return msg, nil +} + +// GetDataValue gets the data object associated with a specific field from the +// current journal entry, returning only the value of the object. +func (j *Journal) GetDataValue(field string) (string, error) { + val, err := j.GetData(field) + if err != nil { + return "", err + } + return strings.SplitN(val, "=", 2)[1], nil +} + +// GetEntry returns a full representation of a journal entry with +// all key-value pairs of data as well as address fields (cursor, realtime +// timestamp and monotonic timestamp) +func (j *Journal) GetEntry() (*JournalEntry, error) { + sd_journal_get_realtime_usec, err := j.getFunction("sd_journal_get_realtime_usec") + if err != nil { + return nil, err + } + + sd_journal_get_monotonic_usec, err := j.getFunction("sd_journal_get_monotonic_usec") + if err != nil { + return nil, err + } + + sd_journal_get_cursor, err := j.getFunction("sd_journal_get_cursor") + if err != nil { + return nil, err + } + + sd_journal_restart_data, err := j.getFunction("sd_journal_restart_data") + if err != nil { + return nil, err + } + + sd_journal_enumerate_data, err := j.getFunction("sd_journal_enumerate_data") + if err != nil { + return nil, err + } + + j.mu.Lock() + defer j.mu.Unlock() + + var r C.int + entry := &JournalEntry{Fields: make(map[string]string)} + + var realtimeUsec C.uint64_t + r = C.my_sd_journal_get_realtime_usec(sd_journal_get_realtime_usec, j.cjournal, &realtimeUsec) + if r < 0 { + return nil, fmt.Errorf("failed to get realtime timestamp: %d", syscall.Errno(-r)) + } + + entry.RealtimeTimestamp = uint64(realtimeUsec) + + var monotonicUsec C.uint64_t + var boot_id C.sd_id128_t + + r = C.my_sd_journal_get_monotonic_usec(sd_journal_get_monotonic_usec, j.cjournal, &monotonicUsec, &boot_id) + if r < 0 { + return nil, fmt.Errorf("failed to get monotonic timestamp: %d", syscall.Errno(-r)) + } + + entry.MonotonicTimestamp = uint64(monotonicUsec) + + var c *C.char + r = C.my_sd_journal_get_cursor(sd_journal_get_cursor, j.cjournal, &c) + if r < 0 { + return nil, fmt.Errorf("failed to get cursor: %d", syscall.Errno(-r)) + } + + entry.Cursor = C.GoString(c) + + // Implements the JOURNAL_FOREACH_DATA_RETVAL macro from journal-internal.h + var d unsafe.Pointer + var l C.size_t + C.my_sd_journal_restart_data(sd_journal_restart_data, j.cjournal) + for { + r = C.my_sd_journal_enumerate_data(sd_journal_enumerate_data, j.cjournal, &d, &l) + if r == 0 { + break + } + + if r < 0 { + return nil, fmt.Errorf("failed to read message field: %d", syscall.Errno(-r)) + } + + msg := C.GoStringN((*C.char)(d), C.int(l)) + kv := strings.SplitN(msg, "=", 2) + if len(kv) < 2 { + return nil, fmt.Errorf("failed to parse field") + } + + entry.Fields[kv[0]] = kv[1] + } + + return entry, nil +} + +// SetDataThresold sets the data field size threshold for data returned by +// GetData. To retrieve the complete data fields this threshold should be +// turned off by setting it to 0, so that the library always returns the +// complete data objects. +func (j *Journal) SetDataThreshold(threshold uint64) error { + sd_journal_set_data_threshold, err := j.getFunction("sd_journal_set_data_threshold") + if err != nil { + return err + } + + j.mu.Lock() + r := C.my_sd_journal_set_data_threshold(sd_journal_set_data_threshold, j.cjournal, C.size_t(threshold)) + j.mu.Unlock() + + if r < 0 { + return fmt.Errorf("failed to set data threshold: %d", syscall.Errno(-r)) + } + + return nil +} + +// GetRealtimeUsec gets the realtime (wallclock) timestamp of the current +// journal entry. +func (j *Journal) GetRealtimeUsec() (uint64, error) { + var usec C.uint64_t + + sd_journal_get_realtime_usec, err := j.getFunction("sd_journal_get_realtime_usec") + if err != nil { + return 0, err + } + + j.mu.Lock() + r := C.my_sd_journal_get_realtime_usec(sd_journal_get_realtime_usec, j.cjournal, &usec) + j.mu.Unlock() + + if r < 0 { + return 0, fmt.Errorf("failed to get realtime timestamp: %d", syscall.Errno(-r)) + } + + return uint64(usec), nil +} + +// GetMonotonicUsec gets the monotonic timestamp of the current journal entry. +func (j *Journal) GetMonotonicUsec() (uint64, error) { + var usec C.uint64_t + var boot_id C.sd_id128_t + + sd_journal_get_monotonic_usec, err := j.getFunction("sd_journal_get_monotonic_usec") + if err != nil { + return 0, err + } + + j.mu.Lock() + r := C.my_sd_journal_get_monotonic_usec(sd_journal_get_monotonic_usec, j.cjournal, &usec, &boot_id) + j.mu.Unlock() + + if r < 0 { + return 0, fmt.Errorf("failed to get monotonic timestamp: %d", syscall.Errno(-r)) + } + + return uint64(usec), nil +} + +// GetCursor gets the cursor of the current journal entry. +func (j *Journal) GetCursor() (string, error) { + var d *C.char + + sd_journal_get_cursor, err := j.getFunction("sd_journal_get_cursor") + if err != nil { + return "", err + } + + j.mu.Lock() + r := C.my_sd_journal_get_cursor(sd_journal_get_cursor, j.cjournal, &d) + j.mu.Unlock() + + if r < 0 { + return "", fmt.Errorf("failed to get cursor: %d", syscall.Errno(-r)) + } + + cursor := C.GoString(d) + + return cursor, nil +} + +// TestCursor checks whether the current position in the journal matches the +// specified cursor +func (j *Journal) TestCursor(cursor string) error { + sd_journal_test_cursor, err := j.getFunction("sd_journal_test_cursor") + if err != nil { + return err + } + + c := C.CString(cursor) + defer C.free(unsafe.Pointer(c)) + + j.mu.Lock() + r := C.my_sd_journal_test_cursor(sd_journal_test_cursor, j.cjournal, c) + j.mu.Unlock() + + if r < 0 { + return fmt.Errorf("failed to test to cursor %q: %d", cursor, syscall.Errno(-r)) + } + + return nil +} + +// SeekHead seeks to the beginning of the journal, i.e. the oldest available +// entry. +func (j *Journal) SeekHead() error { + sd_journal_seek_head, err := j.getFunction("sd_journal_seek_head") + if err != nil { + return err + } + + j.mu.Lock() + r := C.my_sd_journal_seek_head(sd_journal_seek_head, j.cjournal) + j.mu.Unlock() + + if r < 0 { + return fmt.Errorf("failed to seek to head of journal: %d", syscall.Errno(-r)) + } + + return nil +} + +// SeekTail may be used to seek to the end of the journal, i.e. the most recent +// available entry. +func (j *Journal) SeekTail() error { + sd_journal_seek_tail, err := j.getFunction("sd_journal_seek_tail") + if err != nil { + return err + } + + j.mu.Lock() + r := C.my_sd_journal_seek_tail(sd_journal_seek_tail, j.cjournal) + j.mu.Unlock() + + if r < 0 { + return fmt.Errorf("failed to seek to tail of journal: %d", syscall.Errno(-r)) + } + + return nil +} + +// SeekRealtimeUsec seeks to the entry with the specified realtime (wallclock) +// timestamp, i.e. CLOCK_REALTIME. +func (j *Journal) SeekRealtimeUsec(usec uint64) error { + sd_journal_seek_realtime_usec, err := j.getFunction("sd_journal_seek_realtime_usec") + if err != nil { + return err + } + + j.mu.Lock() + r := C.my_sd_journal_seek_realtime_usec(sd_journal_seek_realtime_usec, j.cjournal, C.uint64_t(usec)) + j.mu.Unlock() + + if r < 0 { + return fmt.Errorf("failed to seek to %d: %d", usec, syscall.Errno(-r)) + } + + return nil +} + +// SeekCursor seeks to a concrete journal cursor. +func (j *Journal) SeekCursor(cursor string) error { + sd_journal_seek_cursor, err := j.getFunction("sd_journal_seek_cursor") + if err != nil { + return err + } + + c := C.CString(cursor) + defer C.free(unsafe.Pointer(c)) + + j.mu.Lock() + r := C.my_sd_journal_seek_cursor(sd_journal_seek_cursor, j.cjournal, c) + j.mu.Unlock() + + if r < 0 { + return fmt.Errorf("failed to seek to cursor %q: %d", cursor, syscall.Errno(-r)) + } + + return nil +} + +// Wait will synchronously wait until the journal gets changed. The maximum time +// this call sleeps may be controlled with the timeout parameter. If +// sdjournal.IndefiniteWait is passed as the timeout parameter, Wait will +// wait indefinitely for a journal change. +func (j *Journal) Wait(timeout time.Duration) int { + var to uint64 + + sd_journal_wait, err := j.getFunction("sd_journal_wait") + if err != nil { + return -1 + } + + if timeout == IndefiniteWait { + // sd_journal_wait(3) calls for a (uint64_t) -1 to be passed to signify + // indefinite wait, but using a -1 overflows our C.uint64_t, so we use an + // equivalent hex value. + to = 0xffffffffffffffff + } else { + to = uint64(time.Now().Add(timeout).Unix() / 1000) + } + j.mu.Lock() + r := C.my_sd_journal_wait(sd_journal_wait, j.cjournal, C.uint64_t(to)) + j.mu.Unlock() + + return int(r) +} + +// GetUsage returns the journal disk space usage, in bytes. +func (j *Journal) GetUsage() (uint64, error) { + var out C.uint64_t + + sd_journal_get_usage, err := j.getFunction("sd_journal_get_usage") + if err != nil { + return 0, err + } + + j.mu.Lock() + r := C.my_sd_journal_get_usage(sd_journal_get_usage, j.cjournal, &out) + j.mu.Unlock() + + if r < 0 { + return 0, fmt.Errorf("failed to get journal disk space usage: %d", syscall.Errno(-r)) + } + + return uint64(out), nil +} diff --git a/vendor/github.com/coreos/go-systemd/sdjournal/read.go b/vendor/github.com/coreos/go-systemd/sdjournal/read.go new file mode 100644 index 0000000000..71ee806a96 --- /dev/null +++ b/vendor/github.com/coreos/go-systemd/sdjournal/read.go @@ -0,0 +1,252 @@ +// Copyright 2015 RedHat, Inc. +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package sdjournal + +import ( + "errors" + "fmt" + "io" + "log" + "strings" + "time" +) + +var ( + ErrExpired = errors.New("Timeout expired") +) + +// JournalReaderConfig represents options to drive the behavior of a JournalReader. +type JournalReaderConfig struct { + // The Since, NumFromTail and Cursor options are mutually exclusive and + // determine where the reading begins within the journal. The order in which + // options are written is exactly the order of precedence. + Since time.Duration // start relative to a Duration from now + NumFromTail uint64 // start relative to the tail + Cursor string // start relative to the cursor + + // Show only journal entries whose fields match the supplied values. If + // the array is empty, entries will not be filtered. + Matches []Match + + // If not empty, the journal instance will point to a journal residing + // in this directory. The supplied path may be relative or absolute. + Path string +} + +// JournalReader is an io.ReadCloser which provides a simple interface for iterating through the +// systemd journal. A JournalReader is not safe for concurrent use by multiple goroutines. +type JournalReader struct { + journal *Journal + msgReader *strings.Reader +} + +// NewJournalReader creates a new JournalReader with configuration options that are similar to the +// systemd journalctl tool's iteration and filtering features. +func NewJournalReader(config JournalReaderConfig) (*JournalReader, error) { + r := &JournalReader{} + + // Open the journal + var err error + if config.Path != "" { + r.journal, err = NewJournalFromDir(config.Path) + } else { + r.journal, err = NewJournal() + } + if err != nil { + return nil, err + } + + // Add any supplied matches + for _, m := range config.Matches { + r.journal.AddMatch(m.String()) + } + + // Set the start position based on options + if config.Since != 0 { + // Start based on a relative time + start := time.Now().Add(config.Since) + if err := r.journal.SeekRealtimeUsec(uint64(start.UnixNano() / 1000)); err != nil { + return nil, err + } + } else if config.NumFromTail != 0 { + // Start based on a number of lines before the tail + if err := r.journal.SeekTail(); err != nil { + return nil, err + } + + // Move the read pointer into position near the tail. Go one further than + // the option so that the initial cursor advancement positions us at the + // correct starting point. + if _, err := r.journal.PreviousSkip(config.NumFromTail + 1); err != nil { + return nil, err + } + } else if config.Cursor != "" { + // Start based on a custom cursor + if err := r.journal.SeekCursor(config.Cursor); err != nil { + return nil, err + } + } + + return r, nil +} + +// Read reads entries from the journal. Read follows the Reader interface so +// it must be able to read a specific amount of bytes. Journald on the other +// hand only allows us to read full entries of arbitrary size (without byte +// granularity). JournalReader is therefore internally buffering entries that +// don't fit in the read buffer. Callers should keep calling until 0 and/or an +// error is returned. +func (r *JournalReader) Read(b []byte) (int, error) { + var err error + + if r.msgReader == nil { + var c int + + // Advance the journal cursor. It has to be called at least one time + // before reading + c, err = r.journal.Next() + + // An unexpected error + if err != nil { + return 0, err + } + + // EOF detection + if c == 0 { + return 0, io.EOF + } + + // Build a message + var msg string + msg, err = r.buildMessage() + + if err != nil { + return 0, err + } + r.msgReader = strings.NewReader(msg) + } + + // Copy and return the message + var sz int + sz, err = r.msgReader.Read(b) + if err == io.EOF { + // The current entry has been fully read. Don't propagate this + // EOF, so the next entry can be read at the next Read() + // iteration. + r.msgReader = nil + return sz, nil + } + if err != nil { + return sz, err + } + if r.msgReader.Len() == 0 { + r.msgReader = nil + } + + return sz, nil +} + +// Close closes the JournalReader's handle to the journal. +func (r *JournalReader) Close() error { + return r.journal.Close() +} + +// Rewind attempts to rewind the JournalReader to the first entry. +func (r *JournalReader) Rewind() error { + r.msgReader = nil + return r.journal.SeekHead() +} + +// Follow synchronously follows the JournalReader, writing each new journal entry to writer. The +// follow will continue until a single time.Time is received on the until channel. +func (r *JournalReader) Follow(until <-chan time.Time, writer io.Writer) (err error) { + + // Process journal entries and events. Entries are flushed until the tail or + // timeout is reached, and then we wait for new events or the timeout. + var msg = make([]byte, 64*1<<(10)) +process: + for { + c, err := r.Read(msg) + if err != nil && err != io.EOF { + break process + } + + select { + case <-until: + return ErrExpired + default: + if c > 0 { + if _, err = writer.Write(msg[:c]); err != nil { + break process + } + continue process + } + } + + // We're at the tail, so wait for new events or time out. + // Holds journal events to process. Tightly bounded for now unless there's a + // reason to unblock the journal watch routine more quickly. + events := make(chan int, 1) + pollDone := make(chan bool, 1) + go func() { + for { + select { + case <-pollDone: + return + default: + events <- r.journal.Wait(time.Duration(1) * time.Second) + } + } + }() + + select { + case <-until: + pollDone <- true + return ErrExpired + case e := <-events: + pollDone <- true + switch e { + case SD_JOURNAL_NOP, SD_JOURNAL_APPEND, SD_JOURNAL_INVALIDATE: + // TODO: need to account for any of these? + default: + log.Printf("Received unknown event: %d\n", e) + } + continue process + } + } + + return +} + +// buildMessage returns a string representing the current journal entry in a simple format which +// includes the entry timestamp and MESSAGE field. +func (r *JournalReader) buildMessage() (string, error) { + var msg string + var usec uint64 + var err error + + if msg, err = r.journal.GetData("MESSAGE"); err != nil { + return "", err + } + + if usec, err = r.journal.GetRealtimeUsec(); err != nil { + return "", err + } + + timestamp := time.Unix(0, int64(usec)*int64(time.Microsecond)) + + return fmt.Sprintf("%s %s\n", timestamp, msg), nil +} diff --git a/vendor/github.com/coreos/go-systemd/unit/deserialize.go b/vendor/github.com/coreos/go-systemd/unit/deserialize.go new file mode 100644 index 0000000000..8a88162f98 --- /dev/null +++ b/vendor/github.com/coreos/go-systemd/unit/deserialize.go @@ -0,0 +1,276 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package unit + +import ( + "bufio" + "bytes" + "errors" + "fmt" + "io" + "strings" + "unicode" +) + +const ( + // SYSTEMD_LINE_MAX mimics the maximum line length that systemd can use. + // On typical systemd platforms (i.e. modern Linux), this will most + // commonly be 2048, so let's use that as a sanity check. + // Technically, we should probably pull this at runtime: + // SYSTEMD_LINE_MAX = int(C.sysconf(C.__SC_LINE_MAX)) + // but this would introduce an (unfortunate) dependency on cgo + SYSTEMD_LINE_MAX = 2048 + + // characters that systemd considers indicate a newline + SYSTEMD_NEWLINE = "\r\n" +) + +var ( + ErrLineTooLong = fmt.Errorf("line too long (max %d bytes)", SYSTEMD_LINE_MAX) +) + +// Deserialize parses a systemd unit file into a list of UnitOption objects. +func Deserialize(f io.Reader) (opts []*UnitOption, err error) { + lexer, optchan, errchan := newLexer(f) + go lexer.lex() + + for opt := range optchan { + opts = append(opts, &(*opt)) + } + + err = <-errchan + return opts, err +} + +func newLexer(f io.Reader) (*lexer, <-chan *UnitOption, <-chan error) { + optchan := make(chan *UnitOption) + errchan := make(chan error, 1) + buf := bufio.NewReader(f) + + return &lexer{buf, optchan, errchan, ""}, optchan, errchan +} + +type lexer struct { + buf *bufio.Reader + optchan chan *UnitOption + errchan chan error + section string +} + +func (l *lexer) lex() { + var err error + defer func() { + close(l.optchan) + close(l.errchan) + }() + next := l.lexNextSection + for next != nil { + if l.buf.Buffered() >= SYSTEMD_LINE_MAX { + // systemd truncates lines longer than LINE_MAX + // https://bugs.freedesktop.org/show_bug.cgi?id=85308 + // Rather than allowing this to pass silently, let's + // explicitly gate people from encountering this + line, err := l.buf.Peek(SYSTEMD_LINE_MAX) + if err != nil { + l.errchan <- err + return + } + if bytes.IndexAny(line, SYSTEMD_NEWLINE) == -1 { + l.errchan <- ErrLineTooLong + return + } + } + + next, err = next() + if err != nil { + l.errchan <- err + return + } + } +} + +type lexStep func() (lexStep, error) + +func (l *lexer) lexSectionName() (lexStep, error) { + sec, err := l.buf.ReadBytes(']') + if err != nil { + return nil, errors.New("unable to find end of section") + } + + return l.lexSectionSuffixFunc(string(sec[:len(sec)-1])), nil +} + +func (l *lexer) lexSectionSuffixFunc(section string) lexStep { + return func() (lexStep, error) { + garbage, _, err := l.toEOL() + if err != nil { + return nil, err + } + + garbage = bytes.TrimSpace(garbage) + if len(garbage) > 0 { + return nil, fmt.Errorf("found garbage after section name %s: %v", l.section, garbage) + } + + return l.lexNextSectionOrOptionFunc(section), nil + } +} + +func (l *lexer) ignoreLineFunc(next lexStep) lexStep { + return func() (lexStep, error) { + for { + line, _, err := l.toEOL() + if err != nil { + return nil, err + } + + line = bytes.TrimSuffix(line, []byte{' '}) + + // lack of continuation means this line has been exhausted + if !bytes.HasSuffix(line, []byte{'\\'}) { + break + } + } + + // reached end of buffer, safe to exit + return next, nil + } +} + +func (l *lexer) lexNextSection() (lexStep, error) { + r, _, err := l.buf.ReadRune() + if err != nil { + if err == io.EOF { + err = nil + } + return nil, err + } + + if r == '[' { + return l.lexSectionName, nil + } else if isComment(r) { + return l.ignoreLineFunc(l.lexNextSection), nil + } + + return l.lexNextSection, nil +} + +func (l *lexer) lexNextSectionOrOptionFunc(section string) lexStep { + return func() (lexStep, error) { + r, _, err := l.buf.ReadRune() + if err != nil { + if err == io.EOF { + err = nil + } + return nil, err + } + + if unicode.IsSpace(r) { + return l.lexNextSectionOrOptionFunc(section), nil + } else if r == '[' { + return l.lexSectionName, nil + } else if isComment(r) { + return l.ignoreLineFunc(l.lexNextSectionOrOptionFunc(section)), nil + } + + l.buf.UnreadRune() + return l.lexOptionNameFunc(section), nil + } +} + +func (l *lexer) lexOptionNameFunc(section string) lexStep { + return func() (lexStep, error) { + var partial bytes.Buffer + for { + r, _, err := l.buf.ReadRune() + if err != nil { + return nil, err + } + + if r == '\n' || r == '\r' { + return nil, errors.New("unexpected newline encountered while parsing option name") + } + + if r == '=' { + break + } + + partial.WriteRune(r) + } + + name := strings.TrimSpace(partial.String()) + return l.lexOptionValueFunc(section, name, bytes.Buffer{}), nil + } +} + +func (l *lexer) lexOptionValueFunc(section, name string, partial bytes.Buffer) lexStep { + return func() (lexStep, error) { + for { + line, eof, err := l.toEOL() + if err != nil { + return nil, err + } + + if len(bytes.TrimSpace(line)) == 0 { + break + } + + partial.Write(line) + + // lack of continuation means this value has been exhausted + idx := bytes.LastIndex(line, []byte{'\\'}) + if idx == -1 || idx != (len(line)-1) { + break + } + + if !eof { + partial.WriteRune('\n') + } + + return l.lexOptionValueFunc(section, name, partial), nil + } + + val := partial.String() + if strings.HasSuffix(val, "\n") { + // A newline was added to the end, so the file didn't end with a backslash. + // => Keep the newline + val = strings.TrimSpace(val) + "\n" + } else { + val = strings.TrimSpace(val) + } + l.optchan <- &UnitOption{Section: section, Name: name, Value: val} + + return l.lexNextSectionOrOptionFunc(section), nil + } +} + +// toEOL reads until the end-of-line or end-of-file. +// Returns (data, EOFfound, error) +func (l *lexer) toEOL() ([]byte, bool, error) { + line, err := l.buf.ReadBytes('\n') + // ignore EOF here since it's roughly equivalent to EOL + if err != nil && err != io.EOF { + return nil, false, err + } + + line = bytes.TrimSuffix(line, []byte{'\r'}) + line = bytes.TrimSuffix(line, []byte{'\n'}) + + return line, err == io.EOF, nil +} + +func isComment(r rune) bool { + return r == '#' || r == ';' +} diff --git a/vendor/github.com/coreos/go-systemd/unit/escape.go b/vendor/github.com/coreos/go-systemd/unit/escape.go new file mode 100644 index 0000000000..63b11726db --- /dev/null +++ b/vendor/github.com/coreos/go-systemd/unit/escape.go @@ -0,0 +1,116 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Implements systemd-escape [--unescape] [--path] + +package unit + +import ( + "fmt" + "strconv" + "strings" +) + +const ( + allowed = `:_.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789` +) + +// If isPath is true: +// We remove redundant '/'s, the leading '/', and trailing '/'. +// If the result is empty, a '/' is inserted. +// +// We always: +// Replace the following characters with `\x%x`: +// Leading `.` +// `-`, `\`, and anything not in this set: `:-_.\[0-9a-zA-Z]` +// Replace '/' with '-'. +func escape(unescaped string, isPath bool) string { + e := []byte{} + inSlashes := false + start := true + for i := 0; i < len(unescaped); i++ { + c := unescaped[i] + if isPath { + if c == '/' { + inSlashes = true + continue + } else if inSlashes { + inSlashes = false + if !start { + e = append(e, '-') + } + } + } + + if c == '/' { + e = append(e, '-') + } else if start && c == '.' || strings.IndexByte(allowed, c) == -1 { + e = append(e, []byte(fmt.Sprintf(`\x%x`, c))...) + } else { + e = append(e, c) + } + start = false + } + if isPath && len(e) == 0 { + e = append(e, '-') + } + return string(e) +} + +// If isPath is true: +// We always return a string beginning with '/'. +// +// We always: +// Replace '-' with '/'. +// Replace `\x%x` with the value represented in hex. +func unescape(escaped string, isPath bool) string { + u := []byte{} + for i := 0; i < len(escaped); i++ { + c := escaped[i] + if c == '-' { + c = '/' + } else if c == '\\' && len(escaped)-i >= 4 && escaped[i+1] == 'x' { + n, err := strconv.ParseInt(escaped[i+2:i+4], 16, 8) + if err == nil { + c = byte(n) + i += 3 + } + } + u = append(u, c) + } + if isPath && (len(u) == 0 || u[0] != '/') { + u = append([]byte("/"), u...) + } + return string(u) +} + +// UnitNameEscape escapes a string as `systemd-escape` would +func UnitNameEscape(unescaped string) string { + return escape(unescaped, false) +} + +// UnitNameUnescape unescapes a string as `systemd-escape --unescape` would +func UnitNameUnescape(escaped string) string { + return unescape(escaped, false) +} + +// UnitNamePathEscape escapes a string as `systemd-escape --path` would +func UnitNamePathEscape(unescaped string) string { + return escape(unescaped, true) +} + +// UnitNamePathUnescape unescapes a string as `systemd-escape --path --unescape` would +func UnitNamePathUnescape(escaped string) string { + return unescape(escaped, true) +} diff --git a/vendor/github.com/coreos/go-systemd/unit/option.go b/vendor/github.com/coreos/go-systemd/unit/option.go new file mode 100644 index 0000000000..e5d21e19d9 --- /dev/null +++ b/vendor/github.com/coreos/go-systemd/unit/option.go @@ -0,0 +1,54 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package unit + +import ( + "fmt" +) + +type UnitOption struct { + Section string + Name string + Value string +} + +func NewUnitOption(section, name, value string) *UnitOption { + return &UnitOption{Section: section, Name: name, Value: value} +} + +func (uo *UnitOption) String() string { + return fmt.Sprintf("{Section: %q, Name: %q, Value: %q}", uo.Section, uo.Name, uo.Value) +} + +func (uo *UnitOption) Match(other *UnitOption) bool { + return uo.Section == other.Section && + uo.Name == other.Name && + uo.Value == other.Value +} + +func AllMatch(u1 []*UnitOption, u2 []*UnitOption) bool { + length := len(u1) + if length != len(u2) { + return false + } + + for i := 0; i < length; i++ { + if !u1[i].Match(u2[i]) { + return false + } + } + + return true +} diff --git a/vendor/github.com/coreos/go-systemd/unit/serialize.go b/vendor/github.com/coreos/go-systemd/unit/serialize.go new file mode 100644 index 0000000000..e07799cad6 --- /dev/null +++ b/vendor/github.com/coreos/go-systemd/unit/serialize.go @@ -0,0 +1,75 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package unit + +import ( + "bytes" + "io" +) + +// Serialize encodes all of the given UnitOption objects into a +// unit file. When serialized the options are sorted in their +// supplied order but grouped by section. +func Serialize(opts []*UnitOption) io.Reader { + var buf bytes.Buffer + + if len(opts) == 0 { + return &buf + } + + // Index of sections -> ordered options + idx := map[string][]*UnitOption{} + // Separately preserve order in which sections were seen + sections := []string{} + for _, opt := range opts { + sec := opt.Section + if _, ok := idx[sec]; !ok { + sections = append(sections, sec) + } + idx[sec] = append(idx[sec], opt) + } + + for i, sect := range sections { + writeSectionHeader(&buf, sect) + writeNewline(&buf) + + opts := idx[sect] + for _, opt := range opts { + writeOption(&buf, opt) + writeNewline(&buf) + } + if i < len(sections)-1 { + writeNewline(&buf) + } + } + + return &buf +} + +func writeNewline(buf *bytes.Buffer) { + buf.WriteRune('\n') +} + +func writeSectionHeader(buf *bytes.Buffer, section string) { + buf.WriteRune('[') + buf.WriteString(section) + buf.WriteRune(']') +} + +func writeOption(buf *bytes.Buffer, opt *UnitOption) { + buf.WriteString(opt.Name) + buf.WriteRune('=') + buf.WriteString(opt.Value) +} diff --git a/vendor/github.com/coreos/go-systemd/util/util.go b/vendor/github.com/coreos/go-systemd/util/util.go new file mode 100644 index 0000000000..e4ed8b2639 --- /dev/null +++ b/vendor/github.com/coreos/go-systemd/util/util.go @@ -0,0 +1,227 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package util contains utility functions related to systemd that applications +// can use to check things like whether systemd is running. Note that some of +// these functions attempt to manually load systemd libraries at runtime rather +// than linking against them. +package util + +// #include +// #include +// #include +// +// int +// my_sd_pid_get_owner_uid(void *f, pid_t pid, uid_t *uid) +// { +// int (*sd_pid_get_owner_uid)(pid_t, uid_t *); +// +// sd_pid_get_owner_uid = (int (*)(pid_t, uid_t *))f; +// return sd_pid_get_owner_uid(pid, uid); +// } +// +// int +// my_sd_pid_get_unit(void *f, pid_t pid, char **unit) +// { +// int (*sd_pid_get_unit)(pid_t, char **); +// +// sd_pid_get_unit = (int (*)(pid_t, char **))f; +// return sd_pid_get_unit(pid, unit); +// } +// +// int +// my_sd_pid_get_slice(void *f, pid_t pid, char **slice) +// { +// int (*sd_pid_get_slice)(pid_t, char **); +// +// sd_pid_get_slice = (int (*)(pid_t, char **))f; +// return sd_pid_get_slice(pid, slice); +// } +// +// int +// am_session_leader() +// { +// return (getsid(0) == getpid()); +// } +import "C" +import ( + "fmt" + "io/ioutil" + "os" + "strings" + "syscall" + "unsafe" + + "github.com/coreos/pkg/dlopen" +) + +var libsystemdNames = []string{ + // systemd < 209 + "libsystemd-login.so.0", + "libsystemd-login.so", + + // systemd >= 209 merged libsystemd-login into libsystemd proper + "libsystemd.so.0", + "libsystemd.so", +} + +// GetRunningSlice attempts to retrieve the name of the systemd slice in which +// the current process is running. +// This function is a wrapper around the libsystemd C library; if it cannot be +// opened, an error is returned. +func GetRunningSlice() (slice string, err error) { + var h *dlopen.LibHandle + h, err = dlopen.GetHandle(libsystemdNames) + if err != nil { + return + } + defer func() { + if err1 := h.Close(); err1 != nil { + err = err1 + } + }() + + sd_pid_get_slice, err := h.GetSymbolPointer("sd_pid_get_slice") + if err != nil { + return + } + + var s string + sl := C.CString(s) + defer C.free(unsafe.Pointer(sl)) + + ret := C.my_sd_pid_get_slice(sd_pid_get_slice, 0, &sl) + if ret < 0 { + err = fmt.Errorf("error calling sd_pid_get_slice: %v", syscall.Errno(-ret)) + return + } + + return C.GoString(sl), nil +} + +// RunningFromSystemService tries to detect whether the current process has +// been invoked from a system service. The condition for this is whether the +// process is _not_ a user process. User processes are those running in session +// scopes or under per-user `systemd --user` instances. +// +// To avoid false positives on systems without `pam_systemd` (which is +// responsible for creating user sessions), this function also uses a heuristic +// to detect whether it's being invoked from a session leader process. This is +// the case if the current process is executed directly from a service file +// (e.g. with `ExecStart=/this/cmd`). Note that this heuristic will fail if the +// command is instead launched in a subshell or similar so that it is not +// session leader (e.g. `ExecStart=/bin/bash -c "/this/cmd"`) +// +// This function is a wrapper around the libsystemd C library; if this is +// unable to successfully open a handle to the library for any reason (e.g. it +// cannot be found), an errr will be returned +func RunningFromSystemService() (ret bool, err error) { + var h *dlopen.LibHandle + h, err = dlopen.GetHandle(libsystemdNames) + if err != nil { + return + } + defer func() { + if err1 := h.Close(); err1 != nil { + err = err1 + } + }() + + sd_pid_get_owner_uid, err := h.GetSymbolPointer("sd_pid_get_owner_uid") + if err != nil { + return + } + + var uid C.uid_t + errno := C.my_sd_pid_get_owner_uid(sd_pid_get_owner_uid, 0, &uid) + serrno := syscall.Errno(-errno) + // when we're running from a unit file, sd_pid_get_owner_uid returns + // ENOENT (systemd <220) or ENXIO (systemd >=220) + switch { + case errno >= 0: + ret = false + case serrno == syscall.ENOENT, serrno == syscall.ENXIO: + // Since the implementation of sessions in systemd relies on + // the `pam_systemd` module, using the sd_pid_get_owner_uid + // heuristic alone can result in false positives if that module + // (or PAM itself) is not present or properly configured on the + // system. As such, we also check if we're the session leader, + // which should be the case if we're invoked from a unit file, + // but not if e.g. we're invoked from the command line from a + // user's login session + ret = C.am_session_leader() == 1 + default: + err = fmt.Errorf("error calling sd_pid_get_owner_uid: %v", syscall.Errno(-errno)) + } + return +} + +// CurrentUnitName attempts to retrieve the name of the systemd system unit +// from which the calling process has been invoked. It wraps the systemd +// `sd_pid_get_unit` call, with the same caveat: for processes not part of a +// systemd system unit, this function will return an error. +func CurrentUnitName() (unit string, err error) { + var h *dlopen.LibHandle + h, err = dlopen.GetHandle(libsystemdNames) + if err != nil { + return + } + defer func() { + if err1 := h.Close(); err1 != nil { + err = err1 + } + }() + + sd_pid_get_unit, err := h.GetSymbolPointer("sd_pid_get_unit") + if err != nil { + return + } + + var s string + u := C.CString(s) + defer C.free(unsafe.Pointer(u)) + + ret := C.my_sd_pid_get_unit(sd_pid_get_unit, 0, &u) + if ret < 0 { + err = fmt.Errorf("error calling sd_pid_get_unit: %v", syscall.Errno(-ret)) + return + } + + unit = C.GoString(u) + return +} + +// IsRunningSystemd checks whether the host was booted with systemd as its init +// system. This functions similarly to systemd's `sd_booted(3)`: internally, it +// checks whether /run/systemd/system/ exists and is a directory. +// http://www.freedesktop.org/software/systemd/man/sd_booted.html +func IsRunningSystemd() bool { + fi, err := os.Lstat("/run/systemd/system") + if err != nil { + return false + } + return fi.IsDir() +} + +// GetMachineID returns a host's 128-bit machine ID as a string. This functions +// similarly to systemd's `sd_id128_get_machine`: internally, it simply reads +// the contents of /etc/machine-id +// http://www.freedesktop.org/software/systemd/man/sd_id128_get_machine.html +func GetMachineID() (string, error) { + machineID, err := ioutil.ReadFile("/etc/machine-id") + if err != nil { + return "", fmt.Errorf("failed to read /etc/machine-id: %v", err) + } + return strings.TrimSpace(string(machineID)), nil +} diff --git a/vendor/github.com/coreos/go-tspi/LICENSE b/vendor/github.com/coreos/go-tspi/LICENSE new file mode 100644 index 0000000000..e06d208186 --- /dev/null +++ b/vendor/github.com/coreos/go-tspi/LICENSE @@ -0,0 +1,202 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor 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, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/vendor/github.com/coreos/go-tspi/tpmclient/tpmclient.go b/vendor/github.com/coreos/go-tspi/tpmclient/tpmclient.go new file mode 100644 index 0000000000..fb5279b2a1 --- /dev/null +++ b/vendor/github.com/coreos/go-tspi/tpmclient/tpmclient.go @@ -0,0 +1,310 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package tpmclient + +import ( + "bytes" + "crypto/rand" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "net/http" + "time" + + "github.com/coreos/go-tspi/tspiconst" + "github.com/coreos/go-tspi/verification" +) + +// TPMClient represents a connection to a system running a daemon providing +// access to TPM functionality +type TPMClient struct { + host string + timeout time.Duration +} + +const ( + GetEKCertURL = "/v1/getEkcert" + ExtendURL = "/v1/extend" + QuoteURL = "/v1/quote" + GenerateAikURL = "/v1/generateAik" + GenerateKeyURL = "/v1/generateKey" + AikChallengeURL = "/v1/aikChallenge" +) + +func (client *TPMClient) get(endpoint string) (*http.Response, error) { + url := fmt.Sprintf("http://%s%s", client.host, endpoint) + httpClient := &http.Client{ + Timeout: client.timeout, + } + resp, err := httpClient.Get(url) + return resp, err +} + +func (client *TPMClient) post(endpoint string, data io.Reader) (*http.Response, error) { + url := fmt.Sprintf("http://%s%s", client.host, endpoint) + httpClient := &http.Client{ + Timeout: client.timeout, + } + resp, err := httpClient.Post(url, "application/json", data) + return resp, err +} + +type EkcertResponse struct { + EKCert []byte +} + +// GetEKCert obtains the Endorsement Key certificate from the client TPM. This +// is an X509 certificate containing the public half of the Endorsement Key +// and a signature chain chaining back to a vendor-issued signing certificate. +func (client *TPMClient) GetEKCert() (ekcert []byte, err error) { + var ekcertData EkcertResponse + + ekresp, err := client.get(GetEKCertURL) + if err != nil { + return nil, fmt.Errorf("Can't obtain ekcert: %s", err) + } + defer ekresp.Body.Close() + body, err := ioutil.ReadAll(ekresp.Body) + if err != nil { + return nil, fmt.Errorf("Can't read ekcert response: %s", err) + } + + err = json.Unmarshal(body, &ekcertData) + if err != nil { + return nil, fmt.Errorf("Can't parse ekcert response: %s", err) + } + + return ekcertData.EKCert, nil +} + +type AikResponse struct { + AIKBlob []byte + AIKPub []byte +} + +// GenerateAIK requests that the TPM generate a new Attestation Identity Key. +// It returns an unencrypted copy of the public half of the AIK, along with +// a TSPI key blob encrypted by the TPM. +func (client *TPMClient) GenerateAIK() (aikpub []byte, aikblob []byte, err error) { + var aikData AikResponse + + aikresp, err := client.post(GenerateAikURL, nil) + if err != nil { + return nil, nil, fmt.Errorf("Can't generate AIK: %s", err) + } + defer aikresp.Body.Close() + body, err := ioutil.ReadAll(aikresp.Body) + if err != nil { + return nil, nil, fmt.Errorf("Can't read AIK response: %s", err) + } + + err = json.Unmarshal(body, &aikData) + if err != nil { + return nil, nil, fmt.Errorf("Can't parse AIK response: %s (%s)", err, body) + } + + aikpub = aikData.AIKPub + aikblob = aikData.AIKBlob + + return aikpub, aikblob, nil +} + +type KeyData struct { + KeyFlags int +} + +type KeyResponse struct { + KeyBlob []byte + KeyPub []byte +} + +// GenerateKey requests that the TPM generate a new keypair +func (client *TPMClient) GenerateKey(flags int) (keypub []byte, keyblob []byte, err error) { + var keyData KeyData + var keyResponse KeyResponse + + keyData.KeyFlags = flags + request, err := json.Marshal(keyData) + if err != nil { + return nil, nil, fmt.Errorf("Can't construct request JSON: %s", err) + } + + keyresp, err := client.post(GenerateKeyURL, bytes.NewBuffer(request)) + if err != nil { + return nil, nil, fmt.Errorf("Can't generate key: %s", err) + } + defer keyresp.Body.Close() + body, err := ioutil.ReadAll(keyresp.Body) + if err != nil { + return nil, nil, fmt.Errorf("Can't read key response: %s", err) + } + + err = json.Unmarshal(body, &keyResponse) + if err != nil { + return nil, nil, fmt.Errorf("Can't parse key response: %s (%s)", err, body) + } + + keypub = keyResponse.KeyPub + keyblob = keyResponse.KeyBlob + + return keypub, keyblob, nil +} + +type ChallengeData struct { + AIK []byte + Asymenc []byte + Symenc []byte +} + +type ChallengeResponse struct { + Response []byte +} + +// ValidateAIK challenges the TPM to validate an AIK by using the provided +// key blob to decrypt a secret encrypted with the public half of the +// AIK. This will only be possible if the TPM is able to decrypt the +// encrypted key blob. The AIK is used to decrypt asymenc, which then +// provides the AES key used to encrypt symenc. Decrypting symenc provides +// the original secret, which is then returned. +func (client *TPMClient) ValidateAIK(aikblob []byte, asymenc []byte, symenc []byte) (secret []byte, err error) { + var challenge ChallengeData + var response ChallengeResponse + + challenge.AIK = aikblob + challenge.Asymenc = asymenc + challenge.Symenc = symenc + + request, err := json.Marshal(challenge) + if err != nil { + return nil, fmt.Errorf("Can't construct challenge JSON: %s", err) + } + chalresp, err := client.post(AikChallengeURL, bytes.NewBuffer(request)) + if err != nil { + return nil, fmt.Errorf("Can't perform AIK challenge: %s", err) + } + defer chalresp.Body.Close() + body, err := ioutil.ReadAll(chalresp.Body) + if err != nil { + return nil, fmt.Errorf("Can't read AIK challenge response: %s", err) + } + + err = json.Unmarshal(body, &response) + if err != nil { + return nil, fmt.Errorf("Can't parse AIK challenge response: %s", err) + } + return response.Response, nil +} + +type ExtendInput struct { + Pcr int + Eventtype int + Data []byte + Event string +} + +// Extend extends a TPM PCR with the provided data. If event is nil, data must +// be pre-hashed with SHA1 and will be used to extend the PCR directly. If +// event is not nil, data and event will be hashed to generate the extension +// value. Event will then be stored in the TPM event log. +func (client *TPMClient) Extend(pcr int, eventtype int, data []byte, event string) error { + var extendData ExtendInput + + extendData.Pcr = pcr + extendData.Eventtype = eventtype + extendData.Data = data + extendData.Event = event + + request, err := json.Marshal(extendData) + if err != nil { + return fmt.Errorf("Can't construct extension JSON: %s", err) + } + chalresp, err := client.post(ExtendURL, bytes.NewBuffer(request)) + if err != nil { + return fmt.Errorf("Can't perform PCR extension: %s", err) + } + defer chalresp.Body.Close() + + return nil +} + +type QuoteData struct { + AIK []byte + PCRs []int + Nonce []byte +} + +type QuoteResponse struct { + Data []byte + Validation []byte + PCRValues [][]byte + Events []tspiconst.Log +} + +// GetQuote obtains a PCR quote from the TPM. It takes the aikpub Tspi Key, the +// encrypted AIK blob and a list of PCRs as arguments. The response will +// contain an array of PCR values, an array of log entries and any error. +func (client *TPMClient) GetQuote(aikpub []byte, aikblob []byte, pcrs []int) (pcrvals [][]byte, log []tspiconst.Log, err error) { + var quoteRequest QuoteData + var response QuoteResponse + + nonce := make([]byte, 20) + _, err = rand.Read(nonce) + if err != nil { + return nil, nil, fmt.Errorf("Unable to generate nonce: %s", err) + } + + quoteRequest.AIK = aikblob + quoteRequest.PCRs = pcrs + quoteRequest.Nonce = nonce + + request, err := json.Marshal(quoteRequest) + if err != nil { + return nil, nil, fmt.Errorf("Can't construct quote request JSON: %s", err) + } + chalresp, err := client.post(QuoteURL, bytes.NewBuffer(request)) + if err != nil { + return nil, nil, fmt.Errorf("Can't perform obtain quote: %s", err) + } + defer chalresp.Body.Close() + body, err := ioutil.ReadAll(chalresp.Body) + if err != nil { + return nil, nil, fmt.Errorf("Can't read quote response: %s", err) + } + + err = json.Unmarshal(body, &response) + if err != nil { + return nil, nil, fmt.Errorf("Can't parse quote response: %s", err) + } + + aikmod := aikpub[28:] + + err = verification.QuoteVerify(response.Data, response.Validation, aikmod, response.PCRValues, nonce) + + if err != nil { + return nil, nil, fmt.Errorf("Can't verify quote: %s", err) + } + + return response.PCRValues, response.Events, nil +} + +// New returns a TPMClient structure configured to connect to the provided +// host with the provided timeout. +func New(host string, timeout time.Duration) *TPMClient { + return &TPMClient{ + host: host, + timeout: timeout, + } +} diff --git a/vendor/github.com/coreos/go-tspi/tspiconst/tspiconst.go b/vendor/github.com/coreos/go-tspi/tspiconst/tspiconst.go new file mode 100644 index 0000000000..f2446db76b --- /dev/null +++ b/vendor/github.com/coreos/go-tspi/tspiconst/tspiconst.go @@ -0,0 +1,538 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package tspiconst + +const ( + TSS_OBJECT_TYPE_POLICY = 0x01 + TSS_OBJECT_TYPE_RSAKEY = 0x02 + TSS_OBJECT_TYPE_ENCDATA = 0x03 + TSS_OBJECT_TYPE_PCRS = 0x04 + TSS_OBJECT_TYPE_HASH = 0x05 + TSS_OBJECT_TYPE_DELFAMILY = 0x06 + TSS_OBJECT_TYPE_NV = 0x07 + TSS_OBJECT_TYPE_MIGDATA = 0x08 + TSS_OBJECT_TYPE_DAA_CERTIFICATE = 0x09 + TSS_OBJECT_TYPE_DAA_ISSUER_KEY = 0x0a + TSS_OBJECT_TYPE_DAA_ARA_KEY = 0x0b + TSS_KEY_NO_AUTHORIZATION = 0x00000000 + TSS_KEY_AUTHORIZATION = 0x00000001 + TSS_KEY_AUTHORIZATION_PRIV_USE_ONLY = 0x00000002 + TSS_KEY_NON_VOLATILE = 0x00000000 + TSS_KEY_VOLATILE = 0x00000004 + TSS_KEY_NOT_MIGRATABLE = 0x00000000 + TSS_KEY_MIGRATABLE = 0x00000008 + TSS_KEY_TYPE_DEFAULT = 0x00000000 + TSS_KEY_TYPE_SIGNING = 0x00000010 + TSS_KEY_TYPE_STORAGE = 0x00000020 + TSS_KEY_TYPE_IDENTITY = 0x00000030 + TSS_KEY_TYPE_AUTHCHANGE = 0x00000040 + TSS_KEY_TYPE_BIND = 0x00000050 + TSS_KEY_TYPE_LEGACY = 0x00000060 + TSS_KEY_TYPE_MIGRATE = 0x00000070 + TSS_KEY_TYPE_BITMASK = 0x000000F0 + TSS_KEY_SIZE_DEFAULT = 0x00000000 + TSS_KEY_SIZE_512 = 0x00000100 + TSS_KEY_SIZE_1024 = 0x00000200 + TSS_KEY_SIZE_2048 = 0x00000300 + TSS_KEY_SIZE_4096 = 0x00000400 + TSS_KEY_SIZE_8192 = 0x00000500 + TSS_KEY_SIZE_16384 = 0x00000600 + TSS_KEY_SIZE_BITMASK = 0x00000F00 + TSS_KEY_NOT_CERTIFIED_MIGRATABLE = 0x00000000 + TSS_KEY_CERTIFIED_MIGRATABLE = 0x00001000 + TSS_KEY_STRUCT_DEFAULT = 0x00000000 + TSS_KEY_STRUCT_KEY = 0x00004000 + TSS_KEY_STRUCT_KEY12 = 0x00008000 + TSS_KEY_STRUCT_BITMASK = 0x0001C000 + TSS_KEY_EMPTY_KEY = 0x00000000 + TSS_KEY_TSP_SRK = 0x04000000 + TSS_KEY_TEMPLATE_BITMASK = 0xFC000000 + TSS_ENCDATA_SEAL = 0x00000001 + TSS_ENCDATA_BIND = 0x00000002 + TSS_ENCDATA_LEGACY = 0x00000003 + TSS_HASH_DEFAULT = 0x00000000 + TSS_HASH_SHA1 = 0x00000001 + TSS_HASH_OTHER = 0xFFFFFFFF + TSS_POLICY_USAGE = 0x00000001 + TSS_POLICY_MIGRATION = 0x00000002 + TSS_POLICY_OPERATOR = 0x00000003 + TSS_PCRS_STRUCT_DEFAULT = 0x00000000 + TSS_PCRS_STRUCT_INFO = 0x00000001 + TSS_PCRS_STRUCT_INFO_LONG = 0x00000002 + TSS_PCRS_STRUCT_INFO_SHORT = 0x00000003 + TSS_TSPATTRIB_CONTEXT_SILENT_MODE = 0x00000001 + TSS_TSPATTRIB_CONTEXT_MACHINE_NAME = 0x00000002 + TSS_TSPATTRIB_CONTEXT_VERSION_MODE = 0x00000003 + TSS_TSPATTRIB_CONTEXT_TRANSPORT = 0x00000004 + TSS_TSPATTRIB_CONTEXT_CONNECTION_VERSION = 0x00000005 + TSS_TSPATTRIB_SECRET_HASH_MODE = 0x00000006 + TSS_TSPATTRIB_CONTEXTTRANS_CONTROL = 0x00000008 + TSS_TSPATTRIB_CONTEXTTRANS_MODE = 0x00000010 + TSS_TSPATTRIB_CONTEXT_NOT_SILENT = 0x00000000 + TSS_TSPATTRIB_CONTEXT_SILENT = 0x00000001 + TSS_TSPATTRIB_CONTEXT_VERSION_AUTO = 0x00000001 + TSS_TSPATTRIB_CONTEXT_VERSION_V1_1 = 0x00000002 + TSS_TSPATTRIB_CONTEXT_VERSION_V1_2 = 0x00000003 + TSS_TSPATTRIB_DISABLE_TRANSPORT = 0x00000016 + TSS_TSPATTRIB_ENABLE_TRANSPORT = 0x00000032 + TSS_TSPATTRIB_TRANSPORT_NO_DEFAULT_ENCRYPTION = 0x00000000 + TSS_TSPATTRIB_TRANSPORT_DEFAULT_ENCRYPTION = 0x00000001 + TSS_TSPATTRIB_TRANSPORT_AUTHENTIC_CHANNEL = 0x00000002 + TSS_TSPATTRIB_TRANSPORT_EXCLUSIVE = 0x00000004 + TSS_TSPATTRIB_TRANSPORT_STATIC_AUTH = 0x00000008 + TSS_CONNECTION_VERSION_1_1 = 0x00000001 + TSS_CONNECTION_VERSION_1_2 = 0x00000002 + TSS_TSPATTRIB_SECRET_HASH_MODE_POPUP = 0x00000001 + TSS_TSPATTRIB_HASH_MODE_NOT_NULL = 0x00000000 + TSS_TSPATTRIB_HASH_MODE_NULL = 0x00000001 + TSS_TSPATTRIB_TPM_CALLBACK_COLLATEIDENTITY = 0x00000001 + TSS_TSPATTRIB_TPM_CALLBACK_ACTIVATEIDENTITY = 0x00000002 + TSS_TSPATTRIB_TPM_ORDINAL_AUDIT_STATUS = 0x00000003 + TSS_TSPATTRIB_TPM_CREDENTIAL = 0x00001000 + TPM_CAP_PROP_TPM_CLEAR_ORDINAL_AUDIT = 0x00000000 + TPM_CAP_PROP_TPM_SET_ORDINAL_AUDIT = 0x00000001 + TSS_TPMATTRIB_EKCERT = 0x00000001 + TSS_TPMATTRIB_TPM_CC = 0x00000002 + TSS_TPMATTRIB_PLATFORMCERT = 0x00000003 + TSS_TPMATTRIB_PLATFORM_CC = 0x00000004 + TSS_TSPATTRIB_POLICY_CALLBACK_HMAC = 0x00000080 + TSS_TSPATTRIB_POLICY_CALLBACK_XOR_ENC = 0x00000100 + TSS_TSPATTRIB_POLICY_CALLBACK_TAKEOWNERSHIP = 0x00000180 + TSS_TSPATTRIB_POLICY_CALLBACK_CHANGEAUTHASYM = 0x00000200 + TSS_TSPATTRIB_POLICY_SECRET_LIFETIME = 0x00000280 + TSS_TSPATTRIB_POLICY_POPUPSTRING = 0x00000300 + TSS_TSPATTRIB_POLICY_CALLBACK_SEALX_MASK = 0x00000380 + TSS_TSPATTRIB_POLICY_DELEGATION_INFO = 0x00000001 + TSS_TSPATTRIB_POLICY_DELEGATION_PCR = 0x00000002 + TSS_SECRET_LIFETIME_ALWAYS = 0x00000001 + TSS_SECRET_LIFETIME_COUNTER = 0x00000002 + TSS_SECRET_LIFETIME_TIMER = 0x00000003 + TSS_TSPATTRIB_POLSECRET_LIFETIME_ALWAYS = TSS_SECRET_LIFETIME_ALWAYS + TSS_TSPATTRIB_POLSECRET_LIFETIME_COUNTER = TSS_SECRET_LIFETIME_COUNTER + TSS_TSPATTRIB_POLSECRET_LIFETIME_TIMER = TSS_SECRET_LIFETIME_TIMER + TSS_TSPATTRIB_POLICYSECRET_LIFETIME_ALWAYS = TSS_SECRET_LIFETIME_ALWAYS + TSS_TSPATTRIB_POLICYSECRET_LIFETIME_COUNTER = TSS_SECRET_LIFETIME_COUNTER + TSS_TSPATTRIB_POLICYSECRET_LIFETIME_TIMER = TSS_SECRET_LIFETIME_TIMER + TSS_TSPATTRIB_POLDEL_TYPE = 0x00000001 + TSS_TSPATTRIB_POLDEL_INDEX = 0x00000002 + TSS_TSPATTRIB_POLDEL_PER1 = 0x00000003 + TSS_TSPATTRIB_POLDEL_PER2 = 0x00000004 + TSS_TSPATTRIB_POLDEL_LABEL = 0x00000005 + TSS_TSPATTRIB_POLDEL_FAMILYID = 0x00000006 + TSS_TSPATTRIB_POLDEL_VERCOUNT = 0x00000007 + TSS_TSPATTRIB_POLDEL_OWNERBLOB = 0x00000008 + TSS_TSPATTRIB_POLDEL_KEYBLOB = 0x00000009 + TSS_TSPATTRIB_POLDELPCR_LOCALITY = 0x00000001 + TSS_TSPATTRIB_POLDELPCR_DIGESTATRELEASE = 0x00000002 + TSS_TSPATTRIB_POLDELPCR_SELECTION = 0x00000003 + TSS_DELEGATIONTYPE_NONE = 0x00000001 + TSS_DELEGATIONTYPE_OWNER = 0x00000002 + TSS_DELEGATIONTYPE_KEY = 0x00000003 + TSS_SECRET_MODE_NONE = 0x00000800 + TSS_SECRET_MODE_SHA1 = 0x00001000 + TSS_SECRET_MODE_PLAIN = 0x00001800 + TSS_SECRET_MODE_POPUP = 0x00002000 + TSS_SECRET_MODE_CALLBACK = 0x00002800 + TSS_TSPATTRIB_ENCDATA_BLOB = 0x00000008 + TSS_TSPATTRIB_ENCDATA_PCR = 0x00000010 + TSS_TSPATTRIB_ENCDATA_PCR_LONG = 0x00000018 + TSS_TSPATTRIB_ENCDATA_SEAL = 0x00000020 + TSS_TSPATTRIB_ENCDATABLOB_BLOB = 0x00000001 + TSS_TSPATTRIB_ENCDATAPCR_DIGEST_ATCREATION = 0x00000002 + TSS_TSPATTRIB_ENCDATAPCR_DIGEST_ATRELEASE = 0x00000003 + TSS_TSPATTRIB_ENCDATAPCR_SELECTION = 0x00000004 + TSS_TSPATTRIB_ENCDATAPCR_DIGEST_RELEASE = TSS_TSPATTRIB_ENCDATAPCR_DIGEST_ATRELEASE + TSS_TSPATTRIB_ENCDATAPCRLONG_LOCALITY_ATCREATION = 0x00000005 + TSS_TSPATTRIB_ENCDATAPCRLONG_LOCALITY_ATRELEASE = 0x00000006 + TSS_TSPATTRIB_ENCDATAPCRLONG_CREATION_SELECTION = 0x00000007 + TSS_TSPATTRIB_ENCDATAPCRLONG_RELEASE_SELECTION = 0x00000008 + TSS_TSPATTRIB_ENCDATAPCRLONG_DIGEST_ATCREATION = 0x00000009 + TSS_TSPATTRIB_ENCDATAPCRLONG_DIGEST_ATRELEASE = 0x0000000A + TSS_TSPATTRIB_ENCDATASEAL_PROTECT_MODE = 0x00000001 + TSS_TSPATTRIB_ENCDATASEAL_NOPROTECT = 0x00000000 + TSS_TSPATTRIB_ENCDATASEAL_PROTECT = 0x00000001 + TSS_TSPATTRIB_ENCDATASEAL_NO_PROTECT = TSS_TSPATTRIB_ENCDATASEAL_NOPROTECT + TSS_TSPATTRIB_NV_INDEX = 0x00000001 + TSS_TSPATTRIB_NV_PERMISSIONS = 0x00000002 + TSS_TSPATTRIB_NV_STATE = 0x00000003 + TSS_TSPATTRIB_NV_DATASIZE = 0x00000004 + TSS_TSPATTRIB_NV_PCR = 0x00000005 + TSS_TSPATTRIB_NVSTATE_READSTCLEAR = 0x00100000 + TSS_TSPATTRIB_NVSTATE_WRITESTCLEAR = 0x00200000 + TSS_TSPATTRIB_NVSTATE_WRITEDEFINE = 0x00300000 + TSS_TSPATTRIB_NVPCR_READPCRSELECTION = 0x01000000 + TSS_TSPATTRIB_NVPCR_READDIGESTATRELEASE = 0x02000000 + TSS_TSPATTRIB_NVPCR_READLOCALITYATRELEASE = 0x03000000 + TSS_TSPATTRIB_NVPCR_WRITEPCRSELECTION = 0x04000000 + TSS_TSPATTRIB_NVPCR_WRITEDIGESTATRELEASE = 0x05000000 + TSS_TSPATTRIB_NVPCR_WRITELOCALITYATRELEASE = 0x06000000 + TSS_NV_TPM = 0x80000000 + TSS_NV_PLATFORM = 0x40000000 + TSS_NV_USER = 0x20000000 + TSS_NV_DEFINED = 0x10000000 + TSS_NV_MASK_TPM = 0x80000000 + TSS_NV_MASK_PLATFORM = 0x40000000 + TSS_NV_MASK_USER = 0x20000000 + TSS_NV_MASK_DEFINED = 0x10000000 + TSS_NV_MASK_RESERVED = 0x0f000000 + TSS_NV_MASK_PURVIEW = 0x00ff0000 + TSS_NV_MASK_INDEX = 0x0000ffff + TSS_NV_INDEX_SESSIONS = 0x00011101 + TSS_MIGATTRIB_MIGRATIONBLOB = 0x00000010 + TSS_MIGATTRIB_MIGRATIONTICKET = 0x00000020 + TSS_MIGATTRIB_AUTHORITY_DATA = 0x00000030 + TSS_MIGATTRIB_MIG_AUTH_DATA = 0x00000040 + TSS_MIGATTRIB_TICKET_DATA = 0x00000050 + TSS_MIGATTRIB_PAYLOAD_TYPE = 0x00000060 + TSS_MIGATTRIB_MIGRATION_XOR_BLOB = 0x00000101 + TSS_MIGATTRIB_MIGRATION_REWRAPPED_BLOB = 0x00000102 + TSS_MIGATTRIB_MIG_MSALIST_PUBKEY_BLOB = 0x00000103 + TSS_MIGATTRIB_MIG_AUTHORITY_PUBKEY_BLOB = 0x00000104 + TSS_MIGATTRIB_MIG_DESTINATION_PUBKEY_BLOB = 0x00000105 + TSS_MIGATTRIB_MIG_SOURCE_PUBKEY_BLOB = 0x00000106 + TSS_MIGATTRIB_MIG_REWRAPPED_BLOB = TSS_MIGATTRIB_MIGRATION_REWRAPPED_BLOB + TSS_MIGATTRIB_MIG_XOR_BLOB = TSS_MIGATTRIB_MIGRATION_XOR_BLOB + TSS_MIGATTRIB_AUTHORITY_DIGEST = 0x00000301 + TSS_MIGATTRIB_AUTHORITY_APPROVAL_HMAC = 0x00000302 + TSS_MIGATTRIB_AUTHORITY_MSALIST = 0x00000303 + TSS_MIGATTRIB_MIG_AUTH_AUTHORITY_DIGEST = 0x00000401 + TSS_MIGATTRIB_MIG_AUTH_DESTINATION_DIGEST = 0x00000402 + TSS_MIGATTRIB_MIG_AUTH_SOURCE_DIGEST = 0x00000403 + TSS_MIGATTRIB_TICKET_SIG_DIGEST = 0x00000501 + TSS_MIGATTRIB_TICKET_SIG_VALUE = 0x00000502 + TSS_MIGATTRIB_TICKET_SIG_TICKET = 0x00000503 + TSS_MIGATTRIB_TICKET_RESTRICT_TICKET = 0x00000504 + TSS_MIGATTRIB_PT_MIGRATE_RESTRICTED = 0x00000601 + TSS_MIGATTRIB_PT_MIGRATE_EXTERNAL = 0x00000602 + TSS_TSPATTRIB_HASH_IDENTIFIER = 0x00001000 + TSS_TSPATTRIB_ALG_IDENTIFIER = 0x00002000 + TSS_TSPATTRIB_PCRS_INFO = 0x00000001 + TSS_TSPATTRIB_PCRSINFO_PCRSTRUCT = 0x00000001 + TSS_TSPATTRIB_DELFAMILY_STATE = 0x00000001 + TSS_TSPATTRIB_DELFAMILY_INFO = 0x00000002 + TSS_TSPATTRIB_DELFAMILYSTATE_LOCKED = 0x00000001 + TSS_TSPATTRIB_DELFAMILYSTATE_ENABLED = 0x00000002 + TSS_TSPATTRIB_DELFAMILYINFO_LABEL = 0x00000003 + TSS_TSPATTRIB_DELFAMILYINFO_VERCOUNT = 0x00000004 + TSS_TSPATTRIB_DELFAMILYINFO_FAMILYID = 0x00000005 + TSS_DELEGATE_INCREMENTVERIFICATIONCOUNT = 1 + TSS_DELEGATE_CACHEOWNERDELEGATION_OVERWRITEEXISTING = 1 + TSS_TSPATTRIB_DAACRED_COMMIT = 0x00000001 + TSS_TSPATTRIB_DAACRED_ATTRIB_GAMMAS = 0x00000002 + TSS_TSPATTRIB_DAACRED_CREDENTIAL_BLOB = 0x00000003 + TSS_TSPATTRIB_DAACRED_CALLBACK_SIGN = 0x00000004 + TSS_TSPATTRIB_DAACRED_CALLBACK_VERIFYSIGNATURE = 0x00000005 + TSS_TSPATTRIB_DAACOMMIT_NUMBER = 0x00000001 + TSS_TSPATTRIB_DAACOMMIT_SELECTION = 0x00000002 + TSS_TSPATTRIB_DAACOMMIT_COMMITMENTS = 0x00000003 + TSS_TSPATTRIB_DAAATTRIBGAMMAS_BLOB = 0xffffffff + TSS_TSPATTRIB_DAAISSUERKEY_BLOB = 0x00000001 + TSS_TSPATTRIB_DAAISSUERKEY_PUBKEY = 0x00000002 + TSS_TSPATTRIB_DAAISSUERKEYBLOB_PUBLIC_KEY = 0x00000001 + TSS_TSPATTRIB_DAAISSUERKEYBLOB_SECRET_KEY = 0x00000002 + TSS_TSPATTRIB_DAAISSUERKEYBLOB_KEYBLOB = 0x00000003 + TSS_TSPATTRIB_DAAISSUERKEYBLOB_PROOF = 0x00000004 + TSS_TSPATTRIB_DAAISSUERKEYPUBKEY_NUM_ATTRIBS = 0x00000001 + TSS_TSPATTRIB_DAAISSUERKEYPUBKEY_NUM_PLATFORM_ATTRIBS = 0x00000002 + TSS_TSPATTRIB_DAAISSUERKEYPUBKEY_NUM_ISSUER_ATTRIBS = 0x00000003 + TSS_TSPATTRIB_DAAARAKEY_BLOB = 0x00000001 + TSS_TSPATTRIB_DAAARAKEYBLOB_PUBLIC_KEY = 0x00000001 + TSS_TSPATTRIB_DAAARAKEYBLOB_SECRET_KEY = 0x00000002 + TSS_TSPATTRIB_DAAARAKEYBLOB_KEYBLOB = 0x00000003 + TSS_FLAG_DAA_PSEUDONYM_PLAIN = 0x00000000 + TSS_FLAG_DAA_PSEUDONYM_ENCRYPTED = 0x00000001 + TSS_TSPATTRIB_KEY_BLOB = 0x00000040 + TSS_TSPATTRIB_KEY_INFO = 0x00000080 + TSS_TSPATTRIB_KEY_UUID = 0x000000C0 + TSS_TSPATTRIB_KEY_PCR = 0x00000100 + TSS_TSPATTRIB_RSAKEY_INFO = 0x00000140 + TSS_TSPATTRIB_KEY_REGISTER = 0x00000180 + TSS_TSPATTRIB_KEY_PCR_LONG = 0x000001c0 + TSS_TSPATTRIB_KEY_CONTROLBIT = 0x00000200 + TSS_TSPATTRIB_KEY_CMKINFO = 0x00000400 + TSS_TSPATTRIB_KEYBLOB_BLOB = 0x00000008 + TSS_TSPATTRIB_KEYBLOB_PUBLIC_KEY = 0x00000010 + TSS_TSPATTRIB_KEYBLOB_PRIVATE_KEY = 0x00000028 + TSS_TSPATTRIB_KEYINFO_SIZE = 0x00000080 + TSS_TSPATTRIB_KEYINFO_USAGE = 0x00000100 + TSS_TSPATTRIB_KEYINFO_KEYFLAGS = 0x00000180 + TSS_TSPATTRIB_KEYINFO_AUTHUSAGE = 0x00000200 + TSS_TSPATTRIB_KEYINFO_ALGORITHM = 0x00000280 + TSS_TSPATTRIB_KEYINFO_SIGSCHEME = 0x00000300 + TSS_TSPATTRIB_KEYINFO_ENCSCHEME = 0x00000380 + TSS_TSPATTRIB_KEYINFO_MIGRATABLE = 0x00000400 + TSS_TSPATTRIB_KEYINFO_REDIRECTED = 0x00000480 + TSS_TSPATTRIB_KEYINFO_VOLATILE = 0x00000500 + TSS_TSPATTRIB_KEYINFO_AUTHDATAUSAGE = 0x00000580 + TSS_TSPATTRIB_KEYINFO_VERSION = 0x00000600 + TSS_TSPATTRIB_KEYINFO_CMK = 0x00000680 + TSS_TSPATTRIB_KEYINFO_KEYSTRUCT = 0x00000700 + TSS_TSPATTRIB_KEYCONTROL_OWNEREVICT = 0x00000780 + TSS_TSPATTRIB_KEYINFO_RSA_EXPONENT = 0x00001000 + TSS_TSPATTRIB_KEYINFO_RSA_MODULUS = 0x00002000 + TSS_TSPATTRIB_KEYINFO_RSA_KEYSIZE = 0x00003000 + TSS_TSPATTRIB_KEYINFO_RSA_PRIMES = 0x00004000 + TSS_TSPATTRIB_KEYPCR_DIGEST_ATCREATION = 0x00008000 + TSS_TSPATTRIB_KEYPCR_DIGEST_ATRELEASE = 0x00010000 + TSS_TSPATTRIB_KEYPCR_SELECTION = 0x00018000 + TSS_TSPATTRIB_KEYREGISTER_USER = 0x02000000 + TSS_TSPATTRIB_KEYREGISTER_SYSTEM = 0x04000000 + TSS_TSPATTRIB_KEYREGISTER_NO = 0x06000000 + TSS_TSPATTRIB_KEYPCRLONG_LOCALITY_ATCREATION = 0x00040000 + TSS_TSPATTRIB_KEYPCRLONG_LOCALITY_ATRELEASE = 0x00080000 + TSS_TSPATTRIB_KEYPCRLONG_CREATION_SELECTION = 0x000C0000 + TSS_TSPATTRIB_KEYPCRLONG_RELEASE_SELECTION = 0x00100000 + TSS_TSPATTRIB_KEYPCRLONG_DIGEST_ATCREATION = 0x00140000 + TSS_TSPATTRIB_KEYPCRLONG_DIGEST_ATRELEASE = 0x00180000 + TSS_TSPATTRIB_KEYINFO_CMK_MA_APPROVAL = 0x00000010 + TSS_TSPATTRIB_KEYINFO_CMK_MA_DIGEST = 0x00000020 + TSS_KEY_SIZEVAL_512BIT = 0x0200 + TSS_KEY_SIZEVAL_1024BIT = 0x0400 + TSS_KEY_SIZEVAL_2048BIT = 0x0800 + TSS_KEY_SIZEVAL_4096BIT = 0x1000 + TSS_KEY_SIZEVAL_8192BIT = 0x2000 + TSS_KEY_SIZEVAL_16384BIT = 0x4000 + TSS_KEYUSAGE_BIND = 0x00 + TSS_KEYUSAGE_IDENTITY = 0x01 + TSS_KEYUSAGE_LEGACY = 0x02 + TSS_KEYUSAGE_SIGN = 0x03 + TSS_KEYUSAGE_STORAGE = 0x04 + TSS_KEYUSAGE_AUTHCHANGE = 0x05 + TSS_KEYUSAGE_MIGRATE = 0x06 + TSS_KEYFLAG_REDIRECTION = 0x00000001 + TSS_KEYFLAG_MIGRATABLE = 0x00000002 + TSS_KEYFLAG_VOLATILEKEY = 0x00000004 + TSS_KEYFLAG_CERTIFIED_MIGRATABLE = 0x00000008 + TSS_ALG_RSA = 0x20 + TSS_ALG_DES = 0x21 + TSS_ALG_3DES = 0x22 + TSS_ALG_SHA = 0x23 + TSS_ALG_HMAC = 0x24 + TSS_ALG_AES128 = 0x25 + TSS_ALG_AES192 = 0x26 + TSS_ALG_AES256 = 0x27 + TSS_ALG_XOR = 0x28 + TSS_ALG_MGF1 = 0x29 + TSS_ALG_AES = TSS_ALG_AES128 + TSS_ALG_DEFAULT = 0xfe + TSS_ALG_DEFAULT_SIZE = 0xff + TSS_SS_NONE = 0x10 + TSS_SS_RSASSAPKCS1V15_SHA1 = 0x11 + TSS_SS_RSASSAPKCS1V15_DER = 0x12 + TSS_SS_RSASSAPKCS1V15_INFO = 0x13 + TSS_ES_NONE = 0x10 + TSS_ES_RSAESPKCSV15 = 0x11 + TSS_ES_RSAESOAEP_SHA1_MGF1 = 0x12 + TSS_ES_SYM_CNT = 0x13 + TSS_ES_SYM_OFB = 0x14 + TSS_ES_SYM_CBC_PKCS5PAD = 0x15 + TSS_PS_TYPE_USER = 1 + TSS_PS_TYPE_SYSTEM = 2 + TSS_MS_MIGRATE = 0x20 + TSS_MS_REWRAP = 0x21 + TSS_MS_MAINT = 0x22 + TSS_MS_RESTRICT_MIGRATE = 0x23 + TSS_MS_RESTRICT_APPROVE_DOUBLE = 0x24 + TSS_MS_RESTRICT_MIGRATE_EXTERNAL = 0x25 + TSS_KEYAUTH_AUTH_NEVER = 0x10 + TSS_KEYAUTH_AUTH_ALWAYS = 0x11 + TSS_KEYAUTH_AUTH_PRIV_USE_ONLY = 0x12 + TSS_TPMSTATUS_DISABLEOWNERCLEAR = 0x00000001 + TSS_TPMSTATUS_DISABLEFORCECLEAR = 0x00000002 + TSS_TPMSTATUS_DISABLED = 0x00000003 + TSS_TPMSTATUS_DEACTIVATED = 0x00000004 + TSS_TPMSTATUS_OWNERSETDISABLE = 0x00000005 + TSS_TPMSTATUS_SETOWNERINSTALL = 0x00000006 + TSS_TPMSTATUS_DISABLEPUBEKREAD = 0x00000007 + TSS_TPMSTATUS_ALLOWMAINTENANCE = 0x00000008 + TSS_TPMSTATUS_PHYSPRES_LIFETIMELOCK = 0x00000009 + TSS_TPMSTATUS_PHYSPRES_HWENABLE = 0x0000000A + TSS_TPMSTATUS_PHYSPRES_CMDENABLE = 0x0000000B + TSS_TPMSTATUS_PHYSPRES_LOCK = 0x0000000C + TSS_TPMSTATUS_PHYSPRESENCE = 0x0000000D + TSS_TPMSTATUS_PHYSICALDISABLE = 0x0000000E + TSS_TPMSTATUS_CEKP_USED = 0x0000000F + TSS_TPMSTATUS_PHYSICALSETDEACTIVATED = 0x00000010 + TSS_TPMSTATUS_SETTEMPDEACTIVATED = 0x00000011 + TSS_TPMSTATUS_POSTINITIALISE = 0x00000012 + TSS_TPMSTATUS_TPMPOST = 0x00000013 + TSS_TPMSTATUS_TPMPOSTLOCK = 0x00000014 + TSS_TPMSTATUS_DISABLEPUBSRKREAD = 0x00000016 + TSS_TPMSTATUS_MAINTENANCEUSED = 0x00000017 + TSS_TPMSTATUS_OPERATORINSTALLED = 0x00000018 + TSS_TPMSTATUS_OPERATOR_INSTALLED = TSS_TPMSTATUS_OPERATORINSTALLED + TSS_TPMSTATUS_FIPS = 0x00000019 + TSS_TPMSTATUS_ENABLEREVOKEEK = 0x0000001A + TSS_TPMSTATUS_ENABLE_REVOKEEK = TSS_TPMSTATUS_ENABLEREVOKEEK + TSS_TPMSTATUS_NV_LOCK = 0x0000001B + TSS_TPMSTATUS_TPM_ESTABLISHED = 0x0000001C + TSS_TPMSTATUS_RESETLOCK = 0x0000001D + TSS_TPMSTATUS_DISABLE_FULL_DA_LOGIC_INFO = 0x0000001D + TSS_TPMCAP_ORD = 0x10 + TSS_TPMCAP_ALG = 0x11 + TSS_TPMCAP_FLAG = 0x12 + TSS_TPMCAP_PROPERTY = 0x13 + TSS_TPMCAP_VERSION = 0x14 + TSS_TPMCAP_VERSION_VAL = 0x15 + TSS_TPMCAP_NV_LIST = 0x16 + TSS_TPMCAP_NV_INDEX = 0x17 + TSS_TPMCAP_MFR = 0x18 + TSS_TPMCAP_SYM_MODE = 0x19 + TSS_TPMCAP_HANDLE = 0x1a + TSS_TPMCAP_TRANS_ES = 0x1b + TSS_TPMCAP_AUTH_ENCRYPT = 0x1c + TSS_TPMCAP_SET_PERM_FLAGS = 0x1d + TSS_TPMCAP_SET_VENDOR = 0x1e + TSS_TPMCAP_DA_LOGIC = 0x1f + TSS_TPMCAP_PROP_PCR = 0x10 + TSS_TPMCAP_PROP_DIR = 0x11 + TSS_TPMCAP_PROP_MANUFACTURER = 0x12 + TSS_TPMCAP_PROP_SLOTS = 0x13 + TSS_TPMCAP_PROP_KEYS = TSS_TPMCAP_PROP_SLOTS + TSS_TPMCAP_PROP_FAMILYROWS = 0x14 + TSS_TPMCAP_PROP_DELEGATEROWS = 0x15 + TSS_TPMCAP_PROP_OWNER = 0x16 + TSS_TPMCAP_PROP_MAXKEYS = 0x18 + TSS_TPMCAP_PROP_AUTHSESSIONS = 0x19 + TSS_TPMCAP_PROP_MAXAUTHSESSIONS = 0x1a + TSS_TPMCAP_PROP_TRANSESSIONS = 0x1b + TSS_TPMCAP_PROP_MAXTRANSESSIONS = 0x1c + TSS_TPMCAP_PROP_SESSIONS = 0x1d + TSS_TPMCAP_PROP_MAXSESSIONS = 0x1e + TSS_TPMCAP_PROP_CONTEXTS = 0x1f + TSS_TPMCAP_PROP_MAXCONTEXTS = 0x20 + TSS_TPMCAP_PROP_DAASESSIONS = 0x21 + TSS_TPMCAP_PROP_MAXDAASESSIONS = 0x22 + TSS_TPMCAP_PROP_DAA_INTERRUPT = 0x23 + TSS_TPMCAP_PROP_COUNTERS = 0x24 + TSS_TPMCAP_PROP_MAXCOUNTERS = 0x25 + TSS_TPMCAP_PROP_ACTIVECOUNTER = 0x26 + TSS_TPMCAP_PROP_MIN_COUNTER = 0x27 + TSS_TPMCAP_PROP_TISTIMEOUTS = 0x28 + TSS_TPMCAP_PROP_STARTUPEFFECTS = 0x29 + TSS_TPMCAP_PROP_MAXCONTEXTCOUNTDIST = 0x2a + TSS_TPMCAP_PROP_CMKRESTRICTION = 0x2b + TSS_TPMCAP_PROP_DURATION = 0x2c + TSS_TPMCAP_PROP_MAXNVAVAILABLE = 0x2d + TSS_TPMCAP_PROP_INPUTBUFFERSIZE = 0x2e + TSS_TPMCAP_PROP_REVISION = 0x2f + TSS_TPMCAP_PROP_LOCALITIES_AVAIL = 0x32 + TSS_RT_KEY = 0x00000010 + TSS_RT_AUTH = 0x00000020 + TSS_RT_TRANS = 0x00000030 + TSS_RT_COUNTER = 0x00000040 + TSS_TCSCAP_ALG = 0x00000001 + TSS_TCSCAP_VERSION = 0x00000002 + TSS_TCSCAP_CACHING = 0x00000003 + TSS_TCSCAP_PERSSTORAGE = 0x00000004 + TSS_TCSCAP_MANUFACTURER = 0x00000005 + TSS_TCSCAP_PLATFORM_CLASS = 0x00000006 + TSS_TCSCAP_TRANSPORT = 0x00000007 + TSS_TCSCAP_PLATFORM_INFO = 0x00000008 + TSS_TCSCAP_PROP_KEYCACHE = 0x00000100 + TSS_TCSCAP_PROP_AUTHCACHE = 0x00000101 + TSS_TCSCAP_PROP_MANUFACTURER_STR = 0x00000102 + TSS_TCSCAP_PROP_MANUFACTURER_ID = 0x00000103 + TSS_TCSCAP_PLATFORM_VERSION = 0x00001100 + TSS_TCSCAP_PLATFORM_TYPE = 0x00001101 + TSS_TCSCAP_TRANS_EXCLUSIVE = 0x00002100 + TSS_TCSCAP_PROP_HOST_PLATFORM = 0x00003001 + TSS_TCSCAP_PROP_ALL_PLATFORMS = 0x00003002 + TSS_TSPCAP_ALG = 0x00000010 + TSS_TSPCAP_VERSION = 0x00000011 + TSS_TSPCAP_PERSSTORAGE = 0x00000012 + TSS_TSPCAP_MANUFACTURER = 0x00000013 + TSS_TSPCAP_RETURNVALUE_INFO = 0x00000015 + TSS_TSPCAP_PLATFORM_INFO = 0x00000016 + TSS_TSPCAP_PROP_MANUFACTURER_STR = 0x00000102 + TSS_TSPCAP_PROP_MANUFACTURER_ID = 0x00000103 + TSS_TSPCAP_PLATFORM_TYPE = 0x00000201 + TSS_TSPCAP_PLATFORM_VERSION = 0x00000202 + TSS_TSPCAP_PROP_RETURNVALUE_INFO = 0x00000201 + TSS_EV_CODE_CERT = 0x00000001 + TSS_EV_CODE_NOCERT = 0x00000002 + TSS_EV_XML_CONFIG = 0x00000003 + TSS_EV_NO_ACTION = 0x00000004 + TSS_EV_SEPARATOR = 0x00000005 + TSS_EV_ACTION = 0x00000006 + TSS_EV_PLATFORM_SPECIFIC = 0x00000007 + TSS_TSPCAP_RANDOMLIMIT = 0x00001000 + TSS_PCRS_DIRECTION_CREATION = 1 + TSS_PCRS_DIRECTION_RELEASE = 2 + TSS_BLOB_STRUCT_VERSION = 0x01 + TSS_BLOB_TYPE_KEY = 0x01 + TSS_BLOB_TYPE_PUBKEY = 0x02 + TSS_BLOB_TYPE_MIGKEY = 0x03 + TSS_BLOB_TYPE_SEALEDDATA = 0x04 + TSS_BLOB_TYPE_BOUNDDATA = 0x05 + TSS_BLOB_TYPE_MIGTICKET = 0x06 + TSS_BLOB_TYPE_PRIVATEKEY = 0x07 + TSS_BLOB_TYPE_PRIVATEKEY_MOD1 = 0x08 + TSS_BLOB_TYPE_RANDOM_XOR = 0x09 + TSS_BLOB_TYPE_CERTIFY_INFO = 0x0A + TSS_BLOB_TYPE_KEY_1_2 = 0x0B + TSS_BLOB_TYPE_CERTIFY_INFO_2 = 0x0C + TSS_BLOB_TYPE_CMK_MIG_KEY = 0x0D + TSS_BLOB_TYPE_CMK_BYTE_STREAM = 0x0E + TSS_CMK_DELEGATE_SIGNING = 1 << 31 + TSS_CMK_DELEGATE_STORAGE = 1 << 30 + TSS_CMK_DELEGATE_BIND = 1 << 29 + TSS_CMK_DELEGATE_LEGACY = 1 << 28 + TSS_CMK_DELEGATE_MIGRATE = 1 << 27 + TSS_DAA_LENGTH_N = 256 + TSS_DAA_LENGTH_F = 13 + TSS_DAA_LENGTH_E = 46 + TSS_DAA_LENGTH_E_PRIME = 15 + TSS_DAA_LENGTH_V = 317 + TSS_DAA_LENGTH_SAFETY = 10 + TSS_DAA_LENGTH_HASH = 20 + TSS_DAA_LENGTH_S = 128 + TSS_DAA_LENGTH_GAMMA = 204 + TSS_DAA_LENGTH_RHO = 26 + TSS_DAA_LENGTH_MFG1_GAMMA = 214 + TSS_DAA_LENGTH_MGF1_AR = 25 + TPM_ALG_RSA = 0x00000001 + TPM_ALG_DES = 0x00000002 + TPM_ALG_3DES = 0x00000003 + TPM_ALG_SHA = 0x00000004 + TPM_ALG_HMAC = 0x00000005 + TPM_ALG_AES = 0x00000006 + TPM_ALG_AES128 = TPM_ALG_AES + TPM_ALG_MGF1 = 0x00000007 + TPM_ALG_AES192 = 0x00000008 + TPM_ALG_AES256 = 0x00000009 + TPM_ALG_XOR = 0x0000000A + TPM_SS_NONE = 0x0001 + TPM_SS_RSASSAPKCS1v15_SHA1 = 0x0002 + TPM_SS_RSASSAPKCS1v15_DER = 0x0003 + TPM_SS_RSASSAPKCS1v15_INFO = 0x0004 + TPM_ES_NONE = 0x0001 + TPM_ES_RSAESPKCSv15 = 0x0002 + TPM_ES_RSAESOAEP_SHA1_MGF1 = 0x0003 + TPM_ES_SYM_CNT = 0x0004 + TPM_ES_SYM_CTR = TPM_ES_SYM_CNT + TPM_ES_SYM_OFB = 0x0005 + TPM_ES_SYM_CBC_PKCS5PAD = 0x00FF +) + +// Log represents an entry from the TSS event log. Pcr is the register that +// was extended by the event. Eventtype is the type of the event. PcrValue +// is the value that was hashed into the TPM. Event is the raw event data. +type Log struct { + Pcr int32 + Eventtype int32 + PcrValue [20]byte + Event []byte +} diff --git a/vendor/github.com/coreos/go-tspi/verification/verification.go b/vendor/github.com/coreos/go-tspi/verification/verification.go new file mode 100644 index 0000000000..15e06e2103 --- /dev/null +++ b/vendor/github.com/coreos/go-tspi/verification/verification.go @@ -0,0 +1,654 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package verification + +import ( + "bytes" + "crypto" + "crypto/aes" + "crypto/cipher" + "crypto/rand" + "crypto/rsa" + "crypto/sha1" + "crypto/x509" + "encoding/binary" + "encoding/pem" + "errors" + "fmt" + "math/big" + + "github.com/coreos/go-tspi/tspiconst" +) + +func pad(plaintext []byte, bsize int) ([]byte, error) { + if bsize >= 256 { + return nil, errors.New("bsize must be < 256") + } + pad := bsize - (len(plaintext) % bsize) + if pad == 0 { + pad = bsize + } + for i := 0; i < pad; i++ { + plaintext = append(plaintext, byte(pad)) + } + return plaintext, nil +} + +// GenerateChallenge takes a copy of the EK certificate, the public half of +// the AIK to be challenged and a secret. It then symmetrically encrypts the +// secret with a randomly generated AES key and Asymmetrically encrypts the +// AES key with the public half of the EK. These can then be provided to the +// TPM in order to ensure that the AIK is under the control of the TPM. It +// returns the asymmetrically and symmetrically encrypted data, along with +// any error. +func GenerateChallenge(ekcert []byte, aikpub []byte, secret []byte) (asymenc []byte, symenc []byte, err error) { + aeskey := make([]byte, 16) + iv := make([]byte, 16) + + _, err = rand.Read(aeskey) + if err != nil { + return nil, nil, err + } + + _, err = rand.Read(iv) + if err != nil { + return nil, nil, err + } + + /* + * The EK certificate has an OID for rsaesOaep which will break + * parsing. Replace it with rsaEncryption instead. + */ + ekcert = bytes.Replace(ekcert, []byte{0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x07}, []byte{0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01}, 1) + cert, err := x509.ParseCertificate(ekcert) + pubkey := cert.PublicKey.(*rsa.PublicKey) + + asymplain := []byte{0x00, 0x00, 0x00, 0x06, 0x00, 0xff, 0x00, 0x10} + asymplain = append(asymplain, aeskey...) + hash := sha1.Sum(aikpub) + asymplain = append(asymplain, hash[:]...) + + label := []byte{'T', 'C', 'P', 'A'} + asymenc, err = rsa.EncryptOAEP(sha1.New(), rand.Reader, pubkey, asymplain, label) + block, err := aes.NewCipher(aeskey) + if err != nil { + return nil, nil, err + } + cbc := cipher.NewCBCEncrypter(block, iv) + secret, err = pad(secret, len(iv)) + if err != nil { + return nil, nil, err + } + symenc = make([]byte, len(secret)) + cbc.CryptBlocks(symenc, secret) + + symheader := new(bytes.Buffer) + err = binary.Write(symheader, binary.BigEndian, (uint32)(len(symenc)+len(iv))) + if err != nil { + return nil, nil, err + } + err = binary.Write(symheader, binary.BigEndian, (uint32)(tspiconst.TPM_ALG_AES)) + if err != nil { + return nil, nil, err + } + err = binary.Write(symheader, binary.BigEndian, (uint16)(tspiconst.TPM_ES_SYM_CBC_PKCS5PAD)) + if err != nil { + return nil, nil, err + } + err = binary.Write(symheader, binary.BigEndian, (uint16)(tspiconst.TPM_SS_NONE)) + if err != nil { + return nil, nil, err + } + err = binary.Write(symheader, binary.BigEndian, (uint32)(12)) + if err != nil { + return nil, nil, err + } + err = binary.Write(symheader, binary.BigEndian, (uint32)(128)) + if err != nil { + return nil, nil, err + } + err = binary.Write(symheader, binary.BigEndian, (uint32)(len(iv))) + if err != nil { + return nil, nil, err + } + err = binary.Write(symheader, binary.BigEndian, (uint32)(0)) + if err != nil { + return nil, nil, err + } + header := make([]byte, 28) + err = binary.Read(symheader, binary.BigEndian, &header) + header = append(header, iv...) + header = append(header, symenc...) + symenc = header + + return asymenc, symenc, nil +} + +// VerifyEKCert verifies that the provided EK certificate is signed by a +// trusted manufacturer. +func VerifyEKCert(ekcert []byte) error { + trustedCerts := map[string]string{ + "STM1": `-----BEGIN CERTIFICATE----- +MIIDzDCCArSgAwIBAgIEAAAAATANBgkqhkiG9w0BAQsFADBKMQswCQYDVQQGEwJD +SDEeMBwGA1UEChMVU1RNaWNyb2VsZWN0cm9uaWNzIE5WMRswGQYDVQQDExJTVE0g +VFBNIEVLIFJvb3QgQ0EwHhcNMDkwNzI4MDAwMDAwWhcNMjkxMjMxMDAwMDAwWjBV +MQswCQYDVQQGEwJDSDEeMBwGA1UEChMVU1RNaWNyb2VsZWN0cm9uaWNzIE5WMSYw +JAYDVQQDEx1TVE0gVFBNIEVLIEludGVybWVkaWF0ZSBDQSAwMTCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAJQYnWO8iw955vWqakWNr3YyazQnNzqV97+l +Qa+wUKMVY+lsyhAyOyXO31j4+clvsj6+JhNEwQtcnpkSc+TX60eZvLhgZPUgRVuK +B9w4GUVyg/db593QUmP8K41Is8E+l32CQdcVh9go0toqf/oS/za1TDFHEHLlB4dC +joKkfr3/hkGA9XJaoUopO2ELt4Otop12aw1BknoiTh1+YbzrZtAlIwK2TX99GW3S +IjaCi+fLoXyK2Fmx8vKnr9JfNL888xK9BQfhZzKmbKm/eLD1e1CFRs1B3z2gd3ax +pW5j1OIkSBMOIUeip5+7xvYo2gor5mxatB+rzSvrWup9AwIcymMCAwEAAaOBrjCB +qzAdBgNVHQ4EFgQU88kVdKbnc/8TvwxrrXp7Zc8ceCAwHwYDVR0jBBgwFoAUb+bF +bAe3bIsKgZKDXMtBHva00ScwRQYDVR0gAQH/BDswOTA3BgRVHSAAMC8wLQYIKwYB +BQUHAgEWIWh0dHA6Ly93d3cuc3QuY29tL1RQTS9yZXBvc2l0b3J5LzAOBgNVHQ8B +Af8EBAMCAAQwEgYDVR0TAQH/BAgwBgEB/wIBADANBgkqhkiG9w0BAQsFAAOCAQEA +uZqViou3aZDGvaAn29gghOkj04SkEWViZR3dU3DGrA+5ZX+zr6kZduus3Hf0bVHT +I318PZGTml1wm6faDRomE8bI5xADWhPiCQ1Gf7cFPiqaPkq7mgdC6SGlQtRAfoP8 +ISUJlih0UtsqBWGql4lpk5G6YmvAezguWmMR0/O5Cx5w8YKfXkwAhegGmMGIoJFO +oSzJrS7jK2GnGCuRG65OQVC5HiQY2fFF0JePLWG/D56djNxMbPNGTHF3+yBWg0DU +0xJKYKGFdjFcw0Wi0m2j49Pv3JD1f78c2Z3I/65pkklZGu4awnKQcHeGIbdYF0hQ +LtDSBV4DR9q5GVxSR9JPgQ== +-----END CERTIFICATE-----`, + "STM2": `-----BEGIN CERTIFICATE----- +MIIDzDCCArSgAwIBAgIEAAAAAzANBgkqhkiG9w0BAQsFADBKMQswCQYDVQQGEwJD +SDEeMBwGA1UEChMVU1RNaWNyb2VsZWN0cm9uaWNzIE5WMRswGQYDVQQDExJTVE0g +VFBNIEVLIFJvb3QgQ0EwHhcNMTEwMTIxMDAwMDAwWhcNMjkxMjMxMDAwMDAwWjBV +MQswCQYDVQQGEwJDSDEeMBwGA1UEChMVU1RNaWNyb2VsZWN0cm9uaWNzIE5WMSYw +JAYDVQQDEx1TVE0gVFBNIEVLIEludGVybWVkaWF0ZSBDQSAwMjCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAJO3ihn/uHgV3HrlPZpv8+1+xg9ccLf3pVXJ +oT5n8PHHixN6ZRBmf/Ng85/ODZzxnotC64WD8GHMLyQ0Cna3MJF+MGJZ5R5JkuJR +B4CtgTPwcTVZIsCuup0aDWnPzYqHwvfaiD2FD0aaxCnTKIjWU9OztTD2I61xW2LK +EY4Vde+W3C7WZgS5TpqkbhJzy2NJj6oSMDKklfI3X8jVf7bngMcCR3X3NcIo349I +Dt1r1GfwB+oWrhogZVnMFJKAoSYP8aQrLDVl7SQOAgTXz2IDD6bo1jga/8Kb72dD +h8D2qrkqWh7Hwdas3jqqbb9uiq6O2dJJY86FjffjXPo3jGlFjTsCAwEAAaOBrjCB +qzAdBgNVHQ4EFgQUVx+Aa0fM55v6NZR87Yi40QBa4J4wHwYDVR0jBBgwFoAUb+bF +bAe3bIsKgZKDXMtBHvaO0ScwRQYDVR0gAQH/BDswOTA3BgRVHSAAMC8wLQYIKwYB +BQUHAgEWIWh0dHA6Ly93d3cuc3QuY29tL1RQTS9yZXBvc2l0b3J5LzAOBgNVHQ8B +Af8EBAMCAAQwEgYDVR0TAQH/BAgwBgEB/wIBATANBgkqhkiG9w0BAQsFAAOCAQEA +4gllWq44PFWcv0JgMPOtyXDQx30YB5vBpjS0in7f/Y/r+1Dd8q3EZwNOwYApe+Lp +/ldNqCXw4XzmO8ZCVWOdQdVOqHZuSOhe++Jn0S7M4z2/1PQ6EbRczGfw3dlX63Ec +cEnrn6YMcgPC63Q+ID53vbTS3gpeX/SGpngtVwnzpuJ5rBajqSQUo5jBTBtuGQpO +Ko6Eu7U6Ouz7BVgOSn0mLbfSRb77PjOLZ3+97gSiMmV0iofS7ufemYqA8sF7ZFv/ +lM2eOe/eeS56Jw+IPsnEU0Tf8Tn9hnEig1KP8VByRTWAJgiEOgX2nTs5iJbyZeIZ +RUjDHQQ5onqhgjpfRsC95g== +-----END CERTIFICATE-----`, + "NTC1": `-----BEGIN CERTIFICATE----- +MIIDSjCCAjKgAwIBAgIGAK3jXfbVMA0GCSqGSIb3DQEBBQUAMFIxUDAcBgNVBAMT +FU5UQyBUUE0gRUsgUm9vdCBDQSAwMTAlBgNVBAoTHk51dm90b24gVGVjaG5vbG9n +eSBDb3Jwb3JhdGlvbjAJBgNVBAYTAlRXMB4XDTEyMDcxMTE2MjkzMFoXDTMyMDcx +MTE2MjkzMFowUjFQMBwGA1UEAxMVTlRDIFRQTSBFSyBSb290IENBIDAxMCUGA1UE +ChMeTnV2b3RvbiBUZWNobm9sb2d5IENvcnBvcmF0aW9uMAkGA1UEBhMCVFcwggEi +MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDoNqxhtD4yUtXhqKQGGZemoKJy +uj1RnWvmNgzItLeejNU8B6fOnpMQyoS4K72tMhhFRK2jV9RYzyJMSjEwyX0ASTO1 +2yMti2UJQS60d36eGwk8WLgrFnnITlemshi01h9t1MOmay3TO1LLH/3/VDKJ+jbd +cbfIO2bBquN8r3/ojYUaNSPj6pK1mmsMoJXF4dGRSEwb/4ozBIw5dugm1MEq4Zj3 +GZ0YPg5wyLRugQbt7DkUOX4FGuK5p/C0u5zX8u33EGTrDrRz3ye3zO+aAY1xXF/m +qwEqgxX5M8f0/DXTTO/CfeIksuPeOzujFtXfi5Cy64eeIZ0nAUG3jbtnGjoFAgMB +AAGjJjAkMA4GA1UdDwEB/wQEAwICBDASBgNVHRMBAf8ECDAGAQH/AgEAMA0GCSqG +SIb3DQEBBQUAA4IBAQBBQznOPJAsD4Yvyt/hXtVJSgBX/+rRfoaqbdt3UMbUPJYi +pUoTUgaTx02DVRwommO+hLx7CS++1F2zorWC8qQyvNbg7iffQbbjWitt8NPE6kCr +q0Y5g7M/LkQDd5N3cFfC15uFJOtlj+A2DGzir8dlXU/0qNq9dBFbi+y+Y3rAT+wK +fktmN82UT861wTUzDvnXO+v7H5DYXjUU8kejPW6q+GgsccIbVTOdHNNWbMrcD9yf +oS91nMZ/+/n7IfFWXNN82qERsrvOFCDsbIzUOR30N0IP++oqGfwAbKFfCOCFUz6j +jpXUdJlh22tp12UMsreibmi5bsWYBgybwSbRgvzE +-----END CERTIFICATE-----`, + "NTC2": `-----BEGIN CERTIFICATE----- +MIIDSjCCAjKgAwIBAgIGAPadBmPZMA0GCSqGSIb3DQEBBQUAMFIxUDAcBgNVBAMT +FU5UQyBUUE0gRUsgUm9vdCBDQSAwMjAlBgNVBAoTHk51dm90b24gVGVjaG5vbG9n +eSBDb3Jwb3JhdGlvbjAJBgNVBAYTAlRXMB4XDTEyMDcxMTE2MzMyNFoXDTMyMDcx +MTE2MzMyNFowUjFQMBwGA1UEAxMVTlRDIFRQTSBFSyBSb290IENBIDAyMCUGA1UE +ChMeTnV2b3RvbiBUZWNobm9sb2d5IENvcnBvcmF0aW9uMAkGA1UEBhMCVFcwggEi +MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDSagWxaANT1YA2YUSN7sq7yzOT +1ymbIM+WijhE5AGcLwLFoJ9fmaQrYL6fAW2EW/Q3yu97Q9Ysr8yYZ2XCCfxfseEr +Vs80an8Nk6LkTDz8+0Hm0Cct0klvNUAZEIvWpmgHZMvGijXyOcp4z494d8B28Ynb +I7x0JMXZZQQKQi+WfuHtntF+2osYScweocipPrGeONLKU9sngWZ2vnnvw1SBneTa +irxq0Q0SD6Bx9jtxvdf87euk8JzfPhX8jp8GEeAjmLwGR+tnOQrDmczGNmp7YYNN +R+Q7NZVoYWHw5jaoZnNxbouWUXZZxFqDsB/ndCKWtsIzRYPuWcqrFcmUN4SVAgMB +AAGjJjAkMA4GA1UdDwEB/wQEAwICBDASBgNVHRMBAf8ECDAGAQH/AgEAMA0GCSqG +SIb3DQEBBQUAA4IBAQAIkdDSErzPLPYrVthw4lKjW4tRYelUicMPEHKjQeVUAAS5 +y9XTzB4DWISDAFsgtQjqHJj0xCG+vpY0Rmn2FCO/0YpP+YBQkdbJOsiyXCdFy9e4 +gGjQ24gw1B+rr84+pkI51y952NYBdoQDeb7diPe+24U94f//DYt/JQ8cJua4alr3 +2Pohhh5TxCXXfU2EHt67KyqBSxCSy9m4OkCOGLHL2X5nQIdXVj178mw6DSAwyhwR +n3uJo5MvUEoQTFZJKGSXfab619mIgzEr+YHsIQToqf44VfDMDdM+MFiXQ3a5fLii +hEKQ9DhBPtpHAbhFA4jhCiG9HA8FdEplJ+M4uxNz +-----END CERTIFICATE-----`, + "IFX1": `-----BEGIN CERTIFICATE----- +MIIEnzCCA4egAwIBAgIEMV64bDANBgkqhkiG9w0BAQUFADBtMQswCQYDVQQGEwJE +RTEQMA4GA1UECBMHQmF2YXJpYTEhMB8GA1UEChMYSW5maW5lb24gVGVjaG5vbG9n +aWVzIEFHMQwwCgYDVQQLEwNBSU0xGzAZBgNVBAMTEklGWCBUUE0gRUsgUm9vdCBD +QTAeFw0wNTEwMjAxMzQ3NDNaFw0yNTEwMjAxMzQ3NDNaMHcxCzAJBgNVBAYTAkRF +MQ8wDQYDVQQIEwZTYXhvbnkxITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2ll +cyBBRzEMMAoGA1UECxMDQUlNMSYwJAYDVQQDEx1JRlggVFBNIEVLIEludGVybWVk +aWF0ZSBDQSAwMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALftPhYN +t4rE+JnU/XOPICbOBLvfo6iA7nuq7zf4DzsAWBdsZEdFJQfaK331ihG3IpQnlQ2i +YtDim289265f0J4OkPFpKeFU27CsfozVaNUm6UR/uzwA8ncxFc3iZLRMRNLru/Al +VG053ULVDQMVx2iwwbBSAYO9pGiGbk1iMmuZaSErMdb9v0KRUyZM7yABiyDlM3cz +UQX5vLWV0uWqxdGoHwNva5u3ynP9UxPTZWHZOHE6+14rMzpobs6Ww2RR8BgF96rh +4rRAZEl8BXhwiQq4STvUXkfvdpWH4lzsGcDDtrB6Nt3KvVNvsKz+b07Dk+Xzt+EH +NTf3Byk2HlvX+scCAwEAAaOCATswggE3MB0GA1UdDgQWBBQ4k8292HPEIzMV4bE7 +qWoNI8wQxzAOBgNVHQ8BAf8EBAMCAgQwEgYDVR0TAQH/BAgwBgEB/wIBADBYBgNV +HSABAf8ETjBMMEoGC2CGSAGG+EUBBy8BMDswOQYIKwYBBQUHAgEWLWh0dHA6Ly93 +d3cudmVyaXNpZ24uY29tL3JlcG9zaXRvcnkvaW5kZXguaHRtbDCBlwYDVR0jBIGP +MIGMgBRW65FEhWPWcrOu1EWWC/eUDlRCpqFxpG8wbTELMAkGA1UEBhMCREUxEDAO +BgNVBAgTB0JhdmFyaWExITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2llcyBB +RzEMMAoGA1UECxMDQUlNMRswGQYDVQQDExJJRlggVFBNIEVLIFJvb3QgQ0GCAQMw +DQYJKoZIhvcNAQEFBQADggEBABJ1+Ap3rNlxZ0FW0aIgdzktbNHlvXWNxFdYIBbM +OKjmbOos0Y4O60eKPu259XmMItCUmtbzF3oKYXq6ybARUT2Lm+JsseMF5VgikSlU +BJALqpKVjwAds81OtmnIQe2LSu4xcTSavpsL4f52cUAu/maMhtSgN9mq5roYptq9 +DnSSDZrX4uYiMPl//rBaNDBflhJ727j8xo9CCohF3yQUoQm7coUgbRMzyO64yMIO +3fhb+Vuc7sNwrMOz3VJN14C3JMoGgXy0c57IP/kD5zGRvljKEvrRC2I147+fPeLS +DueRMS6lblvRKiZgmGAg7YaKOkOaEmVDMQ+fTo2Po7hI5wc= +-----END CERTIFICATE-----`, + "IFX2": `-----BEGIN CERTIFICATE----- +MIIEnzCCA4egAwIBAgIEaItIgTANBgkqhkiG9w0BAQUFADBtMQswCQYDVQQGEwJE +RTEQMA4GA1UECBMHQmF2YXJpYTEhMB8GA1UEChMYSW5maW5lb24gVGVjaG5vbG9n +aWVzIEFHMQwwCgYDVQQLEwNBSU0xGzAZBgNVBAMTEklGWCBUUE0gRUsgUm9vdCBD +QTAeFw0wNjEyMjExMDM0MDBaFw0yNjEyMjExMDM0MDBaMHcxCzAJBgNVBAYTAkRF +MQ8wDQYDVQQIEwZTYXhvbnkxITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2ll +cyBBRzEMMAoGA1UECxMDQUlNMSYwJAYDVQQDEx1JRlggVFBNIEVLIEludGVybWVk +aWF0ZSBDQSAwMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK6KnP5R +8ppq9TtPu3mAs3AFxdWhzK5ks+BixGR6mpzyXG64Bjl4xzBXeBIVtlBZXYvIAJ5s +eCTEEsnZc9eKNJeFLdmXQ/siRrTeonyxoS4aL1mVEQebLUz2gN9J6j1ewly+OvGk +jEYouGCzA+fARzLeRIrhuhBI0kUChbH7VM8FngJsbT4xKB3EJ6Wttma25VSimkAr +SPS6dzUDRS1OFCWtAtHJW6YjBnA4wgR8WfpXsnjeNpwEEB+JciWu1VAueLNI+Kis +RiferCfsgWRvHkR6RQf04h+FlhnYHJnf1ktqcEi1oYAjLsbYOAwqyoU1Pev9cS28 +EA6FTJcxjuHhH9ECAwEAAaOCATswggE3MB0GA1UdDgQWBBRDMlr1UAQGVIkwzamm +fceAZ7l4ATAOBgNVHQ8BAf8EBAMCAgQwEgYDVR0TAQH/BAgwBgEB/wIBADBYBgNV +HSABAf8ETjBMMEoGC2CGSAGG+EUBBy8BMDswOQYIKwYBBQUHAgEWLWh0dHA6Ly93 +d3cudmVyaXNpZ24uY29tL3JlcG9zaXRvcnkvaW5kZXguaHRtbDCBlwYDVR0jBIGP +MIGMgBRW65FEhWPWcrOu1EWWC/eUDlRCpqFxpG8wbTELMAkGA1UEBhMCREUxEDAO +BgNVBAgTB0JhdmFyaWExITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2llcyBB +RzEMMAoGA1UECxMDQUlNMRswGQYDVQQDExJJRlggVFBNIEVLIFJvb3QgQ0GCAQMw +DQYJKoZIhvcNAQEFBQADggEBAIZAaYGzf9AYv6DqoUNx6wdpayhCeX75/IHuFQ/d +gLzat9Vd6qNKdAByskpOjpE0KRauEzD/BhTtkEJDazPSmVP1QxAPjqGaD+JjqhS/ +Q6aY+1PSDi2zRIDA66V2yFJDcUBTtShbdTg144YSkVSY5UCKhQrsdg8yAbs7saAB +LHzVebTXffjmkTk5GZk26d/AZQRjfssta1N/TWhWTfuZtwYvjZmgDPeCfr6AOPLr +pVJz+ntzUKGpQ+5mwDJXMZ0qeiFIgXUlU0D+lfuajc/x9rgix9cM+o7amgDlRi1T +55Uu2vzUQ9jLUaISFaTTMag+quBDhx8BDVu+igLp5hvBtxQ= +-----END CERTIFICATE-----`, + "IFX3": `-----BEGIN CERTIFICATE----- +MIIEnzCCA4egAwIBAgIEH7fYljANBgkqhkiG9w0BAQUFADBtMQswCQYDVQQGEwJE +RTEQMA4GA1UECBMHQmF2YXJpYTEhMB8GA1UEChMYSW5maW5lb24gVGVjaG5vbG9n +aWVzIEFHMQwwCgYDVQQLEwNBSU0xGzAZBgNVBAMTEklGWCBUUE0gRUsgUm9vdCBD +QTAeFw0wNzA0MTMxNjQ0MjRaFw0yNzA0MTMxNjQ0MjRaMHcxCzAJBgNVBAYTAkRF +MQ8wDQYDVQQIEwZTYXhvbnkxITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2ll +cyBBRzEMMAoGA1UECxMDQUlNMSYwJAYDVQQDEx1JRlggVFBNIEVLIEludGVybWVk +aWF0ZSBDQSAwMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJWdPAuH +z/p1tIwB1QXlPD/PjedZ4uBZdwPH5tI3Uve0TzbR/mO5clx/loWn7nZ5cHkH1nhB +R67JEFY0a9GithPfITh0XRxPcisLBE/SoqZ90KHFaS+N6SwOpdCP0GlUg1OesKCF +79Z6fXrkTZsVpPqdawdZK+oUsDO9z9U6xqV7bwsS75Y+QiHsm6UTgAkSNQnuFMP3 +NqQyDi/BaWaYRGQ6K8pM7Y7e1h21z/+5X7LncZXU8hgpYpu2zQPg96IkYboVUKL4 +00snaPcOvfagsBUGlBltNfz7geaSuWTCdwEiwlkCYZqCtbkAj5FiStajrzP72BfT +2fshIv+5eF7Qp5ECAwEAAaOCATswggE3MB0GA1UdDgQWBBTGyypNtylL6RFyT1BB +MQtMQvibsjAOBgNVHQ8BAf8EBAMCAgQwEgYDVR0TAQH/BAgwBgEB/wIBADBYBgNV +HSABAf8ETjBMMEoGC2CGSAGG+EUBBy8BMDswOQYIKwYBBQUHAgEWLWh0dHA6Ly93 +d3cudmVyaXNpZ24uY29tL3JlcG9zaXRvcnkvaW5kZXguaHRtbDCBlwYDVR0jBIGP +MIGMgBRW65FEhWPWcrOu1EWWC/eUDlRCpqFxpG8wbTELMAkGA1UEBhMCREUxEDAO +BgNVBAgTB0JhdmFyaWExITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2llcyBB +RzEMMAoGA1UECxMDQUlNMRswGQYDVQQDExJJRlggVFBNIEVLIFJvb3QgQ0GCAQMw +DQYJKoZIhvcNAQEFBQADggEBAGN1bkh4J90DGcOPP2BlwE6ejJ0iDKf1zF+7CLu5 +WS5K4dvuzsWUoQ5eplUt1LrIlorLr46mLokZD0RTG8t49Rcw4AvxMgWk7oYk69q2 +0MGwXwgZ5OQypHaPwslmddLcX+RyEvjrdGpQx3E/87ZrQP8OKnmqI3pBlB8QwCGL +SV9AERaGDpzIHoObLlUjgHuD6aFekPfeIu1xbN25oZCWmqFVIhkKxWE1Xu+qqHIA +dnCFhoIWH3ie9OsJh/iDRaANYYGyplIibDx1FJA8fqiBiBBKUlPoJvbqmZs4meMd +OoeOuCvQ7op28UtaoV6H6BSYmN5dOgW7r1lX2Re0nd84NGE= +-----END CERTIFICATE-----`, + "IFX4": `-----BEGIN CERTIFICATE----- +MIIEnzCCA4egAwIBAgIEDhD4wDANBgkqhkiG9w0BAQUFADBtMQswCQYDVQQGEwJE +RTEQMA4GA1UECBMHQmF2YXJpYTEhMB8GA1UEChMYSW5maW5lb24gVGVjaG5vbG9n +aWVzIEFHMQwwCgYDVQQLEwNBSU0xGzAZBgNVBAMTEklGWCBUUE0gRUsgUm9vdCBD +QTAeFw0wNzEyMDMxMzA3NTVaFw0yNzEyMDMxMzA3NTVaMHcxCzAJBgNVBAYTAkRF +MQ8wDQYDVQQIEwZTYXhvbnkxITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2ll +cyBBRzEMMAoGA1UECxMDQUlNMSYwJAYDVQQDEx1JRlggVFBNIEVLIEludGVybWVk +aWF0ZSBDQSAwNDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAN3UBmDk +jJzzJ+WCgrq4tILtE9KJPMGHwvCsbJOlo7eHiEb8JQzGK1prkPQ3dowFRXPnqONP +WUa36/J3R32xgvuZHqAdliZCt8IUb9qYhDenuXo1SSqJ8LWp30QIJ0vnkaQ2TCkO +bveZZR3hK2OZKRTkFaV/iy2RH+Qs4JAe3diD8mlIu2gXAXnKJSkrzW6gbMzrlTOi +RCuGcatpy7Hfmodbz/0Trbuwtc3dyJZ3Ko1z9bz2Oirjh93RrmYjbtL0HhkAjMOR +83GLrzwUddSqmxtXXX8j5i+/gmE3AO71swOIESdGugxaKUzJ1jTqWKMZcx0E6BFI +lDIfKk0fJlSxHfECAwEAAaOCATswggE3MB0GA1UdDgQWBBSIs8E/YQXRBCKfWsDr +SZVkrNRzvTAOBgNVHQ8BAf8EBAMCAgQwEgYDVR0TAQH/BAgwBgEB/wIBADBYBgNV +HSABAf8ETjBMMEoGC2CGSAGG+EUBBy8BMDswOQYIKwYBBQUHAgEWLWh0dHA6Ly93 +d3cudmVyaXNpZ24uY29tL3JlcG9zaXRvcnkvaW5kZXguaHRtbDCBlwYDVR0jBIGP +MIGMgBRW65FEhWPWcrOu1EWWC/eUDlRCpqFxpG8wbTELMAkGA1UEBhMCREUxEDAO +BgNVBAgTB0JhdmFyaWExITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2llcyBB +RzEMMAoGA1UECxMDQUlNMRswGQYDVQQDExJJRlggVFBNIEVLIFJvb3QgQ0GCAQMw +DQYJKoZIhvcNAQEFBQADggEBAFtqClQNBLOzcGZUpsBqlz3frzM45iiBpxosG1Re +IgoAgtIBEtl609TG51tmpm294KqpfKZVO+xNzovm8k/heGb0jmYf+q1ggrk2qT4v +Qy2jgE0jbP/P8WWq8NHC13uMcBUGPaka7yofEDDwz7TcduQyJVfG2pd1vflnzP0+ +iiJpfCk3CAQQnb+B7zsOp7jHNwpvHP+FhNwZaikaa0OdR/ML9da1sOOW3oJSTEjW +SMLuhaZHtcVgitvtOVvCI/aq47rNJku3xQ7c/s8FHnFzQQ+Q4TExbP20SrqQIlL/ +9sFAb7/nKYNauusakiF3pfvMrJOJigNfJyIcWaGfyyQtVVI= +-----END CERTIFICATE-----`, + "IFX5": `-----BEGIN CERTIFICATE----- +MIIEnzCCA4egAwIBAgIEVuRoqzANBgkqhkiG9w0BAQUFADBtMQswCQYDVQQGEwJE +RTEQMA4GA1UECBMHQmF2YXJpYTEhMB8GA1UEChMYSW5maW5lb24gVGVjaG5vbG9n +aWVzIEFHMQwwCgYDVQQLEwNBSU0xGzAZBgNVBAMTEklGWCBUUE0gRUsgUm9vdCBD +QTAeFw0wOTEyMTExMDM4NDJaFw0yOTEyMTExMDM4NDJaMHcxCzAJBgNVBAYTAkRF +MQ8wDQYDVQQIEwZTYXhvbnkxITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2ll +cyBBRzEMMAoGA1UECxMDQUlNMSYwJAYDVQQDEx1JRlggVFBNIEVLIEludGVybWVk +aWF0ZSBDQSAwNTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL79zMCO +bjkg7gCWEuyGO49CisF/QrGoz9adW1FBuSW8U9IOlvWXNsvoasC1mhrsfkRRojuU +mWifxxxcVfOI9v1SbRfJ+i6lG21IcVe6ywLJdDliT+3vzvrb/2hU/XjCCMDWb/Pw +aZslV5iL4QEiKxvRIiWMYHW0MkkL7mzRBDVN/Vz3ZiL5Lpq7awiKuX9OXpS2a1wf +qSGAlm2TxjU884q9Ky85JJugn0Q/C3dc8aaFPKLHlRs6rIvN1l0LwB1b5EWPzTPJ +d9EhRPFJOAbJS66nSgX06Fl7eWB71ow6w/25otLQCbpy6OrF8wBVMtPMHqFb1c32 +PaaNzpCBnIU7vaMCAwEAAaOCATswggE3MB0GA1UdDgQWBBS7z3zBhCExZtq1vlOo +cBTd00jYzDAOBgNVHQ8BAf8EBAMCAgQwEgYDVR0TAQH/BAgwBgEB/wIBADBYBgNV +HSABAf8ETjBMMEoGC2CGSAGG+EUBBy8BMDswOQYIKwYBBQUHAgEWLWh0dHA6Ly93 +d3cudmVyaXNpZ24uY29tL3JlcG9zaXRvcnkvaW5kZXguaHRtbDCBlwYDVR0jBIGP +MIGMgBRW65FEhWPWcrOu1EWWC/eUDlRCpqFxpG8wbTELMAkGA1UEBhMCREUxEDAO +BgNVBAgTB0JhdmFyaWExITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2llcyBB +RzEMMAoGA1UECxMDQUlNMRswGQYDVQQDExJJRlggVFBNIEVLIFJvb3QgQ0GCAQMw +DQYJKoZIhvcNAQEFBQADggEBAHomNJtmFNtRJI2+s6ZwdzCTHXXIcR/T+N/lfPbE +hIUG4Kg+3uQMP7zBi22m3I3Kk9SXsjLqV5mnsQUGMGlF7jw5W5Q+d6NSJz4taw9D +2DsiUxE/i5vrjWiUaWxv2Eckd4MUexe5Qz8YSh4FPqLB8FZnAlgx2kfdzRIUjkMq +EgFK8ZRSUjXdczvsud68YPVMIZTxK0L8POGJ6RYiDrjTelprfZ4pKKZ79XwxwAIo +pG6emUEf+doRT0KoHoCHr9vvWCWKhojqlQ6jflPZcEsNBMbq5KHVN77vOU58OKx1 +56v3EaqrZenVFt8+n6h2NzhOmg2quQXIr0V9jEg8GAMehDs= +-----END CERTIFICATE-----`, + "IFX8": `-----BEGIN CERTIFICATE----- +MIIEnzCCA4egAwIBAgIEfGoY6jANBgkqhkiG9w0BAQUFADBtMQswCQYDVQQGEwJE +RTEQMA4GA1UECBMHQmF2YXJpYTEhMB8GA1UEChMYSW5maW5lb24gVGVjaG5vbG9n +aWVzIEFHMQwwCgYDVQQLEwNBSU0xGzAZBgNVBAMTEklGWCBUUE0gRUsgUm9vdCBD +QTAeFw0xMjA3MTcwOTI0NTJaFw0zMDEwMTgyMzU5NTlaMHcxCzAJBgNVBAYTAkRF +MQ8wDQYDVQQIEwZTYXhvbnkxITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2ll +cyBBRzEMMAoGA1UECxMDQUlNMSYwJAYDVQQDEx1JRlggVFBNIEVLIEludGVybWVk +aWF0ZSBDQSAwODCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOJaIJu6 +r/betrMgWJ/JZ5j8ytoAA9RWq0cw7+W0e5L2kDLJMM288wYT+iEbfwx6sWSLAl7q +okXYDtTB9MFNhQ5ZWFLslFXbYigtXJxwANcSdPISTF1Czn6LLi1fu1EHddwCXFC8 +xaX0iGgQ9pZklvAy2ijK9BPHquWisisEiWZNRT9dCVylzOR3+p2YOC3ZrRmg7Bj+ +DkC7dltTTO6dPR+LNOFe01pJlpZdF4YHcu4EC10gRu0quZz1LtDZWFKezK7rg5Rj +LSAJbKOsGXjl6hQXMtADEX9Vlz1vItD21OYCNRsu6VdipiL0bl0aAio4BV3GMyjk +0gHnQwCk9k/YPU8CAwEAAaOCATswggE3MB0GA1UdDgQWBBRMS01kiQjkW/5aENNj +h6aIrsHPeDAOBgNVHQ8BAf8EBAMCAgQwEgYDVR0TAQH/BAgwBgEB/wIBADBYBgNV +HSABAf8ETjBMMEoGC2CGSAGG+EUBBy8BMDswOQYIKwYBBQUHAgEWLWh0dHA6Ly93 +d3cudmVyaXNpZ24uY29tL3JlcG9zaXRvcnkvaW5kZXguaHRtbDCBlwYDVR0jBIGP +MIGMgBRW65FEhWPWcrOu1EWWC/eUDlRCpqFxpG8wbTELMAkGA1UEBhMCREUxEDAO +BgNVBAgTB0JhdmFyaWExITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2llcyBB +RzEMMAoGA1UECxMDQUlNMRswGQYDVQQDExJJRlggVFBNIEVLIFJvb3QgQ0GCAQMw +DQYJKoZIhvcNAQEFBQADggEBALMiDyQ9WKH/eTI84Mk8KYk+TXXEwf+fhgeCvxOQ +G0FTSmOpJaNIzxWXr/gDbY3dO0ODjWRKYvhimZUuV+ckMA+wZX2C6o8g5njpWIOH +pSAa+W35ijArh0Zt3MASJ46avd+fnQGTdzT0hK46gx6n2KixLvaZsR3JtuwUFYlQ +wzmz/UsbBNEoPiR8p5E0Zf5GEGiTqkmBVYyS6XA34axpMMRHy0wI7AGs0gVihwUM +rr0iWOu+GAcrm11lcYzqJvuEkfenAF62ufA2Ktv+Ut2xiRC0jUIp73CeplAJsqBr +camV3pJn3qYPI5c1njMRYnoRFWQbrOR5ADWDQLFQPYRrJmg= +-----END CERTIFICATE-----`, + "IFX15": `-----BEGIN CERTIFICATE----- +MIIEnzCCA4egAwIBAgIER3V5aDANBgkqhkiG9w0BAQUFADBtMQswCQYDVQQGEwJE +RTEQMA4GA1UECBMHQmF2YXJpYTEhMB8GA1UEChMYSW5maW5lb24gVGVjaG5vbG9n +aWVzIEFHMQwwCgYDVQQLEwNBSU0xGzAZBgNVBAMTEklGWCBUUE0gRUsgUm9vdCBD +QTAeFw0xMjExMTQxNDQzMzRaFw0zMDEwMTgyMzU5NTlaMHcxCzAJBgNVBAYTAkRF +MQ8wDQYDVQQIEwZTYXhvbnkxITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2ll +cyBBRzEMMAoGA1UECxMDQUlNMSYwJAYDVQQDEx1JRlggVFBNIEVLIEludGVybWVk +aWF0ZSBDQSAxNTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKS6pgcg +OQWSozVbMkdf9jZkpGdT4U735zs0skfpjoKK2CgpLMO/+oGKbObm/DQPRQO/oxvq +jJNBKz55QBgKd+MoQ6t+2J8mcQ91Nfwqnm1C4r+c4zezJ1Utk/KIYNqpFDAzefBA +/lK8IxQ6kmzxcIFE4skaFsSgkearSZGG6sA9A51yxwvs8yUrQF51ICEUM7wDb4cM +53utaFdm6p6m9UZGSmmrdTiemOkuuwtl8IUQXfuk9lFyQsACBTM95Hrts0IzI6hX +QeTwSL4JqyEnKP9vbtT4eXzWNycqSYBf0+Uo/HHZo9WuVDUaA4I9zcmD0qCvSOT0 +NAj4ifJ7SPGInU0CAwEAAaOCATswggE3MB0GA1UdDgQWBBR4pAnEV95pJvbfQsYR +TrflaptW5zAOBgNVHQ8BAf8EBAMCAgQwEgYDVR0TAQH/BAgwBgEB/wIBADBYBgNV +HSABAf8ETjBMMEoGC2CGSAGG+EUBBy8BMDswOQYIKwYBBQUHAgEWLWh0dHA6Ly93 +d3cudmVyaXNpZ24uY29tL3JlcG9zaXRvcnkvaW5kZXguaHRtbDCBlwYDVR0jBIGP +MIGMgBRW65FEhWPWcrOu1EWWC/eUDlRCpqFxpG8wbTELMAkGA1UEBhMCREUxEDAO +BgNVBAgTB0JhdmFyaWExITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2llcyBB +RzEMMAoGA1UECxMDQUlNMRswGQYDVQQDExJJRlggVFBNIEVLIFJvb3QgQ0GCAQMw +DQYJKoZIhvcNAQEFBQADggEBAAnZDdJZs5QgAXnl0Jo5sCqktZcwcK+V1+uhsqrT +Z7OJ9Ze1YJ9XB14KxRfmck7Erl5HVc6PtUcLnR0tuJKKKqm7dTe4sQEFYd5usjrW +KSG6y7BOH7AdonocILY9OIxuNwxMAqhK8LIjkkRCeOWSvCqLnaLtrP52C0fBkTTM +SWX7YnsutXEpwhro3Qsnm9hL9s3s/WoIuNKUcLFH/qWKztpxXnF0zip73gcZbwEy +1GPQQpYnxFJ2R2ab2RHlO+3Uf3FDxn+eRLXNl95ZZ6GE4OIIpKEg2urIiig0HmGA +ijO6JfJxT30H9QNsx78sjYs7pOfMw6DfiqJ8Fx82GcCUOyM= +-----END CERTIFICATE-----`, + } + + trustedKeys := map[string]string{ + "ATM1": `-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5a+4yXtubUnGJPz7ZVjW +spGhe5Tr9BhrWQ9QOfDoVlkmi+tg2Gqc9qA9R39WhiiEmKuQ3+4XIvO+XFFrVCv+ +8YuEnBIIu46FEX1LBG7LnUJbkgAV0pzHMWOghLhDIGcGg/6kO9fH+7KcwfwNah+Z +Lkfbfis3cm09RlOG8RSq8LyK8Zc07QH2M7L/8PFnRRQ5MnAgW7vuk8h/M62TTy+y +DVuWl/jnh3vrKgVMoOyL/iM3EdFHIV+r/lJOI/HRAlkieCRGiJ1kJI4tQpUXiL+t +K2iB1yAxnqcSQzWWxlNuu6sAUV2tI+qMVM2o6eT1f/MM7+b4nmyuBrdOIO5dvTek +7wIDAQAB +-----END PUBLIC KEY-----`, + "ATM10": `-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1HEeCn82r8Vrg64howvt +s/2Yj5yuXhEv7FwUaISo7rYFnAbstyMVGNsL24reRW7aiyj65iHEojx1Car3Jlu8 +hYfTqiagFmEK/qe8erEatwg5jFQ0GdK3a9Tw7nhYZjjpe98sRjL/DQlI5NiKClPF +4ZNqI418MGmzmPN/QNxRnKJAr5LTE8FZCMShm5V9ege72oLj4VfPuz29fQLBZWJA +2+NUy6gCpcUShejGfm9DTGBk0m3wruqyXuzKzJ4U0Xo5nTqp7ZV/JLbSWnTJxs72 +hZ4D1nbi0paPQgcK5FYbIwQ1WuEpN5QMfilsAZFbokQnQa+jX2Rzleoa0mURVEnG +TQIDAQAB +-----END PUBLIC KEY-----`, + "ATM11": `-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqrS1Ei1VvLxVYWNv/s35 +aYmHa5MOnvQybgW/i1XuINZuPQqYNw02wrWRA5eft2ts+FkJDvbz6edtqH30Cjx+ +pmE9OvotY7O7rboruz2W2PpcQ0/inLUixNiq/A8giKRWJaTNsiF6VLNEWEe5sf3r +e6+C/ZQUfwupM56bU0JrIMxEgp8SCFguQsNwcq2txtr1ujgX4PN6DOet6BcrTpsY +vxKhQPbL/Tfl/kMqYVzqqyrBGgkg8+2FRxO6bVSJCwryrA37ZwkgJl3k/qibTFzw +JVfJnGaT57L/TUVJRwADtVN+oJFcQamR7N6VIuohx7fp7U8t8nrKhZpIwK405hLE +1wIDAQAB +-----END PUBLIC KEY-----`, + "ATM12": `-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1R4fVBbUI7tsaRuS0VvH +TiouZ7L/HAokHIsozeLKamistnoCNKMyz40pwGenK8l0XnvJveoAlT+3tbKmmeo7 +iR1QP28shN8ggnObHZpBN2cPiySh0A8uYIEXY3sJMrNZ/h2MMbjYD2nUyreVpuj+ +mytSbvmB1eqcj9p4JBY1aqwXBrm0DqxZXJsVNBkjJ7c9kFy3ze8yccTFKx/wXe7v +PHgoWKA7RLtM2i/ppJdQgT/IubOrhZTyWPpvLQDpNf0p/SDmByw3/RzinPFlxUmA +eBzvTDwM7jEsZIUQGDZIBhifK45VLLrQiDTTOL8eVw9D8H0zn8AJu7cF9w9oYQj6 +fQIDAQAB +-----END PUBLIC KEY-----`, + "ATM13": `-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwSvUzUQRjD3KyZMJu5CZ +sHVLqAN0mBT86nivjCV+RhHsR0uSU110NKjb2IHXM3fYaJlgvZRTAQJ3c8jPc0bV +tC0+521QKKt86OLi0+nrNT2QzLtrJgx6eRoYiu9se2F0u/zB+PHQ0R8qVOI1xw0W +FVK2w2+mRT3WN4Udp0Rn6LKPRXCq59JPfuD7hNBVmwp9uzj2TLp8ljMRSbChRjek +u9H4G+b2qa4wf2g9R5/Eqq5cMwYsD4357cuhlfqWQxD61J93ro2Hf5+30JrZF2yo +/TX5ocdQqnvLeape1KZGTDrikNXD9eIhR53yT4aBAK/RB8scsbwjn5tnoIBO0GAE +wwIDAQAB +-----END PUBLIC KEY-----`, + "ATM2": `-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6e/oMMyv7NPlNKo9A7ls +wJDkE14LZGSsKiRyzyJe2qHCoBwsZEq3QV2w4ducngcOysRaczDd8Cku9Z332dbi +9Tq6RZapk/eL7mcBF/XBNu7Wft3PDRTzs8gpM3xFHo59+OAjeax3TE8yR6Phiipp +42uI9f184vQsgwzEWNz6kMUP5mwe3Hm9y8RlTzrpJAtVtW9w7LmoSeOHHgzsEGG9 +q5F2PkY6X0Ft9eDQaIOlTofkSHzvG2VLv8MJINMjnXrPnvF8dqG38lzAIvDfJKKx +E5MjY2aoFc1dfISQDv4sYx02b6jwfDl8pFCrwCzH7cWmIE0hD2BV2LpurURTi+kk +MQIDAQAB +-----END PUBLIC KEY-----`, + "ATM3": `-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmFAUATJ/8xIeuFW0aKNZ +cwCtDLDOQoGIez+sg64EmJ+rEKNHfPQj7ee3UxiARWoLvmrMwMZFHXVuHb6Q6QUB +H2OmUZfhcBXm94ZbXrFQyDxosR3lU+JZu5JK0X76kZAQtiBI2/UkJMt0xRUm1P7p +InKnqk9HYw2HpwrCYZII78R2N8bfGJAXOpz1oOpI7jVHewtJY/gun1jgXuOwNW+1 +ouDaUrB/8t9m0lvsoeqduq0Nhvl4AL6kxVFp4sSX3gFuSORcbFP4hu7UMJy6g59d +bsgpulbltd2+HDqxEa4VPOe3IlC4iUso091vq+V49ThYOZ0TXFjk1dNdcTFuK2O8 +kQIDAQAB +-----END PUBLIC KEY-----`, + "ATM4": `-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxtl1salu/2SXeqCGMtac +0GMCqx6Qeh4KtrviPfGVdObksuyGRPPuaW25/oYNGLlf2x/kDlknB2eZFMiW8otK +XV+xO50uFcxoTHXZ1wnMD8x6CgM0z0j3DQ5d0eu5sRRDd7GHYEpuvMj0x8pgkZk+ +C+Ux2hWlj8xEiEDH8q5wyP5AX92GkpoUAL0e4vUV7/cCEBcsLOs8Oq6rKzmig82k +sDiL/Tn/8TtsSmUAwT/FzM/gi79x0D1hHtXyLOFPDIrOy3d3cz5QMOSSLDHGjmoa +DBF0+rcBRJCCU2iBtfIMBevJO1IBUmj/EgerHWWaf5pNNJAL62eAeeaWKm5OaX6b +VQIDAQAB +-----END PUBLIC KEY-----`, + "ATM5": `-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqg1FjhOQ/GsqgUL+WSBc +fYr3hkxxl1EBaCIqiolc1R5TmZabaHoCUIJmhwXfFGhFvhZrI0AcEqIYANLgY0ri +vn4h6vV+rrwtxM1X7X8hmT+AdvxL2p9lOCp7XNpQ2Rw+o/2JhuBSUv+opW7K6wPu +mwUpy4gL+dAozZyBjan5Co9sP5Yh3kdG3+ezRsfxf3CnS76NhjHglK9AWUdM1c6m +FGqTP+fU9ySTpoabrnDUzIcedu5OsMZa5L1LeLKHrqrbM3b995aU9RPrIQoO3x+B +Sau9Ab0d614zpD0TeWwjBT7Y5rIg14bIx7DiA+4kGRE5fHZtpdSWpgJmlkcObSSd +vQIDAQAB +-----END PUBLIC KEY-----`, + "ATM6": `-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw9s9ykpgzH1Birz8JVmH +c/jXNSaFsDQYM9hcS3513P7arS+r/musmUqfdybY/GQ8+YqAA6IZq+xlGZ7WUEmx +vo/Hlnm/FQj3epZGD3ruApm+8dLV4Hvs4RjZCS8cfpkRZygh+nRdrZ3aAwZRjQbh +vl8mAJOQ2Rp9ANaZMzYjre7adkuqIFDa83nKgn4XkMIft+MthOvcMYmZtSL64gvA +NZ7PiryB2cMhS+0yAMGK/Oqm0ELIRk8wqAR/l3txRVxoQEqA9fBk2bvGNiWva92c +hxCLpEX9+CcZWvUeH6Up5a2EDxw8BgxE0L6sqjINWn2uN0x7jlKysg+XEyo7qUpM +RQIDAQAB +-----END PUBLIC KEY-----`, + "ATM7": `-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlYRfDD3bMJB7w6Fl+Kez +oIaEkzz+2VCeF8v3ohsNnSKCgcx8uk7Seyp50bEtLB6vOzwgcM5WjFItKyYLZaHt +P43q3iHsvISjAGNcYGcQ3NrM4ia6pc2geVraupldPTdQFOQjwd+0P/Q2/RMbWY6g ++sbjIDtItEc1vhf6bI3TinT+bGxxXdR9B6qWgLNc/H31wsBNN2nPv1K4wE8MWfAV +7hcK2NoIc1zGEY+IiWPtXSu48zmvS2lxKWWYuiHBwCt5ns/U7M8XSjkaj7SbhD02 +yKwiMavu7SMAceSWWMBuhjgm9/zfMAPKO9weQixVCeuXspByefsekPuk5ohbWOS/ +bwIDAQAB +-----END PUBLIC KEY-----`, + "ATM8": `-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAylXag4JmzoqaTK8eCcSj +DSOGRcrX8IK/fBawgEWKAgPy/yu+8FGXXK10XDeI1fmlAefDr7349Cn+v9/y+Mff +XIduKCqR5ZP9M1+fBk7k5l4x2SeC9NfIMG+c0yJ6m1kEmsSN04nlKk8foo54L7DY ++Kkjfh6EPxyzxsMDqqTrMifBThF2kqo5KUBDdBjIkOUH1dbLWGjEgUpKocCu2M41 +U7jmjToatkA+d3V+PyQRF4/lJkTYiv6Jy1Zl1qpEkLvR0qKrzoHkOij7zBpQ/46B +2BW1pARjU7AIp3NtfS5THL59mpXxpuyj6y2h0wxNVRkPZpnVA0ZWHgz9J4TcIgAN +PwIDAQAB +-----END PUBLIC KEY-----`, + "ATM9": `-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxa0XBIlBj9t5bYB81Cea +mlV3I3rTathgyUn2VL7/wng2vK5x7BB3a1wjXt5k/uwR/M5tfIDOSjug/SdDfTWk +ZRe82Ij/oYJOytcrFzEzouIZVA7t/uKdXzRwz7dZ6LPnNVkp8GiWUDCDpTNNmnvi +eZcjqofajDcc0EC720NT+NqmkAJd0qYMs+i4TA2om2C2Lxpkq+YdJp2pJOCCQquC +wmLXB8OxrddjX4QW5mHzigx4fanC/GJcXuRQPXqLruHZlWmUqU7Sl6yZEluItHbB +ri4BxD3Q7eXH0sM3rZGUCLr3lMPXjGsfpogZT4zLr075QIxtwe5OUpnslU61c34X +BwIDAQAB +-----END PUBLIC KEY-----`, + } + + cert, err := x509.ParseCertificate(ekcert) + if err != nil { + return fmt.Errorf("Unable to parse EKCert: %s", err) + } + + for vendor, certificate := range trustedCerts { + block, _ := pem.Decode([]byte(certificate)) + testcert, err := x509.ParseCertificate(block.Bytes) + if err != nil { + return fmt.Errorf("Unable to parse %s: %s", vendor, err) + } + err = testcert.CheckSignature(cert.SignatureAlgorithm, cert.RawTBSCertificate, cert.Signature) + if err == nil { + return nil + } + } + + for vendor, key := range trustedKeys { + block, _ := pem.Decode([]byte(key)) + pubkey, err := x509.ParsePKIXPublicKey(block.Bytes) + if err != nil { + return fmt.Errorf("Unable to parse %s: %s", vendor, err) + } + hashdata := sha1.Sum(cert.RawTBSCertificate[:]) + err = rsa.VerifyPKCS1v15(pubkey.(*rsa.PublicKey), crypto.SHA1, hashdata[:], cert.Signature) + if err == nil { + return nil + } + } + + return fmt.Errorf("No matching certificate found") +} + +// QuoteVerify verifies that a quote was genuinely provided by the TPM. It +// takes the quote data, quote validation blob, public half of the AIK, +// current PCR values and the nonce used in the original quote request. It +// then verifies that the validation block is a valid signature for the +// quote data, that the secrets are the same (in order to avoid replay +// attacks), and that the PCR values are the same. It returns an error if +// any stage of the validation fails. +func QuoteVerify(data []byte, validation []byte, aikpub []byte, pcrvalues [][]byte, secret []byte) error { + n := big.NewInt(0) + n.SetBytes(aikpub) + e := 65537 + + pKey := rsa.PublicKey{N: n, E: int(e)} + + dataHash := sha1.Sum(data[:]) + + err := rsa.VerifyPKCS1v15(&pKey, crypto.SHA1, dataHash[:], validation) + if err != nil { + return err + } + + pcrHash := data[8:28] + nonceHash := data[28:48] + + secretHash := sha1.Sum(secret[:]) + + if bytes.Equal(secretHash[:], nonceHash) == false { + return fmt.Errorf("Secret doesn't match") + } + + pcrComposite := []byte{0x00, 0x02, 0xff, 0xff, 0x00, 0x00, 0x01, 0x40} + for i := 0; i < 16; i++ { + pcrComposite = append(pcrComposite, pcrvalues[i]...) + } + pcrCompositeHash := sha1.Sum(pcrComposite[:]) + + if bytes.Equal(pcrCompositeHash[:], pcrHash) == false { + return fmt.Errorf("PCR values don't match") + } + + return nil +} + +// KeyVerify verifies that a key certification request was genuinely +// provided by the TPM. It takes the certification data, certification +// validation blob, the public half of the AIK, the public half of the key +// to be certified and the nonce used in the original quote request. It then +// verifies that the validation block is a valid signature for the +// certification data, that the certification data matches the certified key +// and that the secrets are the same (in order to avoid replay attacks). It +// returns an error if any stage of the validation fails. +func KeyVerify(data []byte, validation []byte, aikpub []byte, keypub []byte, secret []byte) error { + n := big.NewInt(0) + n.SetBytes(aikpub) + e := 65537 + + pKey := rsa.PublicKey{N: n, E: int(e)} + + dataHash := sha1.Sum(data[:]) + + err := rsa.VerifyPKCS1v15(&pKey, crypto.SHA1, dataHash[:], validation) + if err != nil { + return err + } + + keyHash := data[43:63] + nonceHash := data[63:83] + + secretHash := sha1.Sum(secret[:]) + + if bytes.Equal(secretHash[:], nonceHash) == false { + return fmt.Errorf("Secret doesn't match") + } + + certHash := sha1.Sum(keypub[:]) + + if bytes.Equal(certHash[:], keyHash) == false { + return fmt.Errorf("Key doesn't match") + } + + return nil +} diff --git a/vendor/github.com/coreos/ioprogress/LICENSE b/vendor/github.com/coreos/ioprogress/LICENSE new file mode 100644 index 0000000000..2298515904 --- /dev/null +++ b/vendor/github.com/coreos/ioprogress/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Mitchell Hashimoto + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/github.com/coreos/ioprogress/draw.go b/vendor/github.com/coreos/ioprogress/draw.go new file mode 100644 index 0000000000..b659be5b67 --- /dev/null +++ b/vendor/github.com/coreos/ioprogress/draw.go @@ -0,0 +1,132 @@ +package ioprogress + +import ( + "fmt" + "io" + "os" + "strings" + + "golang.org/x/crypto/ssh/terminal" +) + +// DrawFunc is the callback type for drawing progress. +type DrawFunc func(int64, int64) error + +// DrawTextFormatFunc is a callback used by DrawFuncs that draw text in +// order to format the text into some more human friendly format. +type DrawTextFormatFunc func(int64, int64) string + +var defaultDrawFunc DrawFunc + +func init() { + defaultDrawFunc = DrawTerminal(os.Stdout) +} + +// isTerminal returns True when w is going to a tty, and false otherwise. +func isTerminal(w io.Writer) bool { + if f, ok := w.(*os.File); ok { + return terminal.IsTerminal(int(f.Fd())) + } + return false +} + +// DrawTerminal returns a DrawFunc that draws a progress bar to an io.Writer +// that is assumed to be a terminal (and therefore respects carriage returns). +func DrawTerminal(w io.Writer) DrawFunc { + return DrawTerminalf(w, func(progress, total int64) string { + return fmt.Sprintf("%d/%d", progress, total) + }) +} + +// DrawTerminalf returns a DrawFunc that draws a progress bar to an io.Writer +// that is formatted with the given formatting function. +func DrawTerminalf(w io.Writer, f DrawTextFormatFunc) DrawFunc { + var maxLength int + + return func(progress, total int64) error { + if progress == -1 && total == -1 { + _, err := fmt.Fprintf(w, "\n") + return err + } + + // Make sure we pad it to the max length we've ever drawn so that + // we don't have trailing characters. + line := f(progress, total) + if len(line) < maxLength { + line = fmt.Sprintf( + "%s%s", + line, + strings.Repeat(" ", maxLength-len(line))) + } + maxLength = len(line) + + terminate := "\r" + if !isTerminal(w) { + terminate = "\n" + } + _, err := fmt.Fprint(w, line+terminate) + return err + } +} + +var byteUnits = []string{"B", "KB", "MB", "GB", "TB", "PB"} + +// DrawTextFormatBytes is a DrawTextFormatFunc that formats the progress +// and total into human-friendly byte formats. +func DrawTextFormatBytes(progress, total int64) string { + return fmt.Sprintf("%s/%s", ByteUnitStr(progress), ByteUnitStr(total)) +} + +// DrawTextFormatBar returns a DrawTextFormatFunc that draws a progress +// bar with the given width (in characters). This can be used in conjunction +// with another DrawTextFormatFunc to create a progress bar with bytes, for +// example: +// +// bar := DrawTextFormatBar(20) +// func(progress, total int64) string { +// return fmt.Sprintf( +// "%s %s", +// bar(progress, total), +// DrawTextFormatBytes(progress, total)) +// } +// +func DrawTextFormatBar(width int64) DrawTextFormatFunc { + return DrawTextFormatBarForW(width, nil) +} + +// DrawTextFormatBarForW returns a DrawTextFormatFunc as described in the docs +// for DrawTextFormatBar, however if the io.Writer passed in is not a tty then +// the returned function will always return "". +func DrawTextFormatBarForW(width int64, w io.Writer) DrawTextFormatFunc { + if w != nil && !isTerminal(w) { + return func(progress, total int64) string { + return "" + } + } + + width -= 2 + + return func(progress, total int64) string { + current := int64((float64(progress) / float64(total)) * float64(width)) + return fmt.Sprintf( + "[%s%s]", + strings.Repeat("=", int(current)), + strings.Repeat(" ", int(width-current))) + } +} + +// ByteUnitStr pretty prints a number of bytes. +func ByteUnitStr(n int64) string { + var unit string + size := float64(n) + for i := 1; i < len(byteUnits); i++ { + if size < 1000 { + unit = byteUnits[i-1] + break + } + + size = size / 1000 + } + + return fmt.Sprintf("%.3g %s", size, unit) +} diff --git a/vendor/github.com/coreos/ioprogress/reader.go b/vendor/github.com/coreos/ioprogress/reader.go new file mode 100644 index 0000000000..7d52731e2d --- /dev/null +++ b/vendor/github.com/coreos/ioprogress/reader.go @@ -0,0 +1,107 @@ +package ioprogress + +import ( + "io" + "time" +) + +// Reader is an implementation of io.Reader that draws the progress of +// reading some data. +type Reader struct { + // Reader is the underlying reader to read from + Reader io.Reader + + // Size is the total size of the data coming out of the reader. + Size int64 + + // DrawFunc is the callback to invoke to draw the progress bar. By + // default, this will be DrawTerminal(os.Stdout). + // + // DrawInterval is the minimum time to wait between reads to update the + // progress bar. + DrawFunc DrawFunc + DrawInterval time.Duration + + progress int64 + lastDraw time.Time +} + +// Read reads from the underlying reader and invokes the DrawFunc if +// appropriate. The DrawFunc is executed when there is data that is +// read (progress is made) and at least DrawInterval time has passed. +func (r *Reader) Read(p []byte) (int, error) { + // If we haven't drawn before, initialize the progress bar + if r.lastDraw.IsZero() { + r.initProgress() + } + + // Read from the underlying source + n, err := r.Reader.Read(p) + + // Always increment the progress even if there was an error + r.progress += int64(n) + + // If we don't have any errors, then draw the progress. If we are + // at the end of the data, then finish the progress. + if err == nil { + // Only draw if we read data or we've never read data before (to + // initialize the progress bar). + if n > 0 { + r.drawProgress() + } + } + if err == io.EOF { + r.finishProgress() + } + + return n, err +} + +func (r *Reader) drawProgress() { + // If we've drawn before, then make sure that the draw interval + // has passed before we draw again. + interval := r.DrawInterval + if interval == 0 { + interval = time.Second + } + if !r.lastDraw.IsZero() { + nextDraw := r.lastDraw.Add(interval) + if time.Now().Before(nextDraw) { + return + } + } + + // Draw + f := r.drawFunc() + f(r.progress, r.Size) + + // Record this draw so that we don't draw again really quickly + r.lastDraw = time.Now() +} + +func (r *Reader) finishProgress() { + f := r.drawFunc() + f(r.progress, r.Size) + + // Print a newline + f(-1, -1) + + // Reset lastDraw so we don't finish again + var zeroDraw time.Time + r.lastDraw = zeroDraw +} + +func (r *Reader) initProgress() { + var zeroDraw time.Time + r.lastDraw = zeroDraw + r.drawProgress() + r.lastDraw = zeroDraw +} + +func (r *Reader) drawFunc() DrawFunc { + if r.DrawFunc == nil { + return defaultDrawFunc + } + + return r.DrawFunc +} diff --git a/vendor/github.com/coreos/pkg/LICENSE b/vendor/github.com/coreos/pkg/LICENSE new file mode 100644 index 0000000000..e06d208186 --- /dev/null +++ b/vendor/github.com/coreos/pkg/LICENSE @@ -0,0 +1,202 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor 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, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/vendor/github.com/coreos/pkg/NOTICE b/vendor/github.com/coreos/pkg/NOTICE new file mode 100644 index 0000000000..b39ddfa5cb --- /dev/null +++ b/vendor/github.com/coreos/pkg/NOTICE @@ -0,0 +1,5 @@ +CoreOS Project +Copyright 2014 CoreOS, Inc + +This product includes software developed at CoreOS, Inc. +(http://www.coreos.com/). diff --git a/vendor/github.com/coreos/pkg/dlopen/dlopen.go b/vendor/github.com/coreos/pkg/dlopen/dlopen.go new file mode 100644 index 0000000000..23774f612e --- /dev/null +++ b/vendor/github.com/coreos/pkg/dlopen/dlopen.go @@ -0,0 +1,82 @@ +// Copyright 2016 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package dlopen provides some convenience functions to dlopen a library and +// get its symbols. +package dlopen + +// #cgo LDFLAGS: -ldl +// #include +// #include +import "C" +import ( + "errors" + "fmt" + "unsafe" +) + +var ErrSoNotFound = errors.New("unable to open a handle to the library") + +// LibHandle represents an open handle to a library (.so) +type LibHandle struct { + Handle unsafe.Pointer + Libname string +} + +// GetHandle tries to get a handle to a library (.so), attempting to access it +// by the names specified in libs and returning the first that is successfully +// opened. Callers are responsible for closing the handler. If no library can +// be successfully opened, an error is returned. +func GetHandle(libs []string) (*LibHandle, error) { + for _, name := range libs { + libname := C.CString(name) + defer C.free(unsafe.Pointer(libname)) + handle := C.dlopen(libname, C.RTLD_LAZY) + if handle != nil { + h := &LibHandle{ + Handle: handle, + Libname: name, + } + return h, nil + } + } + return nil, ErrSoNotFound +} + +// GetSymbolPointer takes a symbol name and returns a pointer to the symbol. +func (l *LibHandle) GetSymbolPointer(symbol string) (unsafe.Pointer, error) { + sym := C.CString(symbol) + defer C.free(unsafe.Pointer(sym)) + + C.dlerror() + p := C.dlsym(l.Handle, sym) + e := C.dlerror() + if e != nil { + return nil, fmt.Errorf("error resolving symbol %q: %v", symbol, errors.New(C.GoString(e))) + } + + return p, nil +} + +// Close closes a LibHandle. +func (l *LibHandle) Close() error { + C.dlerror() + C.dlclose(l.Handle) + e := C.dlerror() + if e != nil { + return fmt.Errorf("error closing %v: %v", l.Libname, errors.New(C.GoString(e))) + } + + return nil +} diff --git a/vendor/github.com/coreos/pkg/dlopen/dlopen_example.go b/vendor/github.com/coreos/pkg/dlopen/dlopen_example.go new file mode 100644 index 0000000000..48a660104f --- /dev/null +++ b/vendor/github.com/coreos/pkg/dlopen/dlopen_example.go @@ -0,0 +1,56 @@ +// Copyright 2015 CoreOS, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +build linux + +package dlopen + +// #include +// #include +// +// int +// my_strlen(void *f, const char *s) +// { +// size_t (*strlen)(const char *); +// +// strlen = (size_t (*)(const char *))f; +// return strlen(s); +// } +import "C" + +import ( + "fmt" + "unsafe" +) + +func strlen(libs []string, s string) (int, error) { + h, err := GetHandle(libs) + if err != nil { + return -1, fmt.Errorf(`couldn't get a handle to the library: %v`, err) + } + defer h.Close() + + f := "strlen" + cs := C.CString(s) + defer C.free(unsafe.Pointer(cs)) + + strlen, err := h.GetSymbolPointer(f) + if err != nil { + return -1, fmt.Errorf(`couldn't get symbol %q: %v`, f, err) + } + + len := C.my_strlen(strlen, cs) + + return int(len), nil +} diff --git a/vendor/github.com/coreos/pkg/progressutil/iocopy.go b/vendor/github.com/coreos/pkg/progressutil/iocopy.go new file mode 100644 index 0000000000..04cd0dfa30 --- /dev/null +++ b/vendor/github.com/coreos/pkg/progressutil/iocopy.go @@ -0,0 +1,189 @@ +// Copyright 2016 CoreOS Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package progressutil + +import ( + "errors" + "fmt" + "io" + "sync" + "time" +) + +var ( + ErrAlreadyStarted = errors.New("cannot add copies after PrintAndWait has been called") +) + +type copyReader struct { + reader io.Reader + current int64 + total int64 + pb *ProgressBar +} + +func (cr *copyReader) Read(p []byte) (int, error) { + n, err := cr.reader.Read(p) + cr.current += int64(n) + err1 := cr.updateProgressBar() + if err == nil { + err = err1 + } + return n, err +} + +func (cr *copyReader) updateProgressBar() error { + cr.pb.SetPrintAfter(cr.formattedProgress()) + + progress := float64(cr.current) / float64(cr.total) + if progress > 1 { + progress = 1 + } + return cr.pb.SetCurrentProgress(progress) +} + +// NewCopyProgressPrinter returns a new CopyProgressPrinter +func NewCopyProgressPrinter() *CopyProgressPrinter { + return &CopyProgressPrinter{results: make(chan error), cancel: make(chan struct{})} +} + +// CopyProgressPrinter will perform an arbitrary number of io.Copy calls, while +// continually printing the progress of each copy. +type CopyProgressPrinter struct { + results chan error + cancel chan struct{} + + // `lock` mutex protects all fields below it in CopyProgressPrinter struct + lock sync.Mutex + readers []*copyReader + started bool + pbp *ProgressBarPrinter +} + +// AddCopy adds a copy for this CopyProgressPrinter to perform. An io.Copy call +// will be made to copy bytes from reader to dest, and name and size will be +// used to label the progress bar and display how much progress has been made. +// If size is 0, the total size of the reader is assumed to be unknown. +// AddCopy can only be called before PrintAndWait; otherwise, ErrAlreadyStarted +// will be returned. +func (cpp *CopyProgressPrinter) AddCopy(reader io.Reader, name string, size int64, dest io.Writer) error { + cpp.lock.Lock() + defer cpp.lock.Unlock() + + if cpp.started { + return ErrAlreadyStarted + } + if cpp.pbp == nil { + cpp.pbp = &ProgressBarPrinter{} + cpp.pbp.PadToBeEven = true + } + + cr := ©Reader{ + reader: reader, + current: 0, + total: size, + pb: cpp.pbp.AddProgressBar(), + } + cr.pb.SetPrintBefore(name) + cr.pb.SetPrintAfter(cr.formattedProgress()) + + cpp.readers = append(cpp.readers, cr) + + go func() { + _, err := io.Copy(dest, cr) + select { + case <-cpp.cancel: + return + case cpp.results <- err: + return + } + }() + return nil +} + +// PrintAndWait will print the progress for each copy operation added with +// AddCopy to printTo every printInterval. This will continue until every added +// copy is finished, or until cancel is written to. +// PrintAndWait may only be called once; any subsequent calls will immediately +// return ErrAlreadyStarted. After PrintAndWait has been called, no more +// copies may be added to the CopyProgressPrinter. +func (cpp *CopyProgressPrinter) PrintAndWait(printTo io.Writer, printInterval time.Duration, cancel chan struct{}) error { + cpp.lock.Lock() + if cpp.started { + cpp.lock.Unlock() + return ErrAlreadyStarted + } + cpp.started = true + cpp.lock.Unlock() + + n := len(cpp.readers) + if n == 0 { + // Nothing to do. + return nil + } + + defer close(cpp.cancel) + t := time.NewTicker(printInterval) + allDone := false + for i := 0; i < n; { + select { + case <-cancel: + return nil + case <-t.C: + _, err := cpp.pbp.Print(printTo) + if err != nil { + return err + } + case err := <-cpp.results: + i++ + // Once completion is signaled, further on this just drains + // (unlikely) errors from the channel. + if err == nil && !allDone { + allDone, err = cpp.pbp.Print(printTo) + } + if err != nil { + return err + } + } + } + return nil +} + +func (cr *copyReader) formattedProgress() string { + var totalStr string + if cr.total == 0 { + totalStr = "?" + } else { + totalStr = ByteUnitStr(cr.total) + } + return fmt.Sprintf("%s / %s", ByteUnitStr(cr.current), totalStr) +} + +var byteUnits = []string{"B", "KB", "MB", "GB", "TB", "PB"} + +// ByteUnitStr pretty prints a number of bytes. +func ByteUnitStr(n int64) string { + var unit string + size := float64(n) + for i := 1; i < len(byteUnits); i++ { + if size < 1000 { + unit = byteUnits[i-1] + break + } + + size = size / 1000 + } + + return fmt.Sprintf("%.3g %s", size, unit) +} diff --git a/vendor/github.com/coreos/pkg/progressutil/progressbar.go b/vendor/github.com/coreos/pkg/progressutil/progressbar.go new file mode 100644 index 0000000000..224c124acd --- /dev/null +++ b/vendor/github.com/coreos/pkg/progressutil/progressbar.go @@ -0,0 +1,256 @@ +// Copyright 2016 CoreOS Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package progressutil + +import ( + "fmt" + "io" + "os" + "strings" + "sync" + + "golang.org/x/crypto/ssh/terminal" +) + +var ( + // ErrorProgressOutOfBounds is returned if the progress is set to a value + // not between 0 and 1. + ErrorProgressOutOfBounds = fmt.Errorf("progress is out of bounds (0 to 1)") + + // ErrorNoBarsAdded is returned when no progress bars have been added to a + // ProgressBarPrinter before PrintAndWait is called. + ErrorNoBarsAdded = fmt.Errorf("AddProgressBar hasn't been called yet") +) + +// ProgressBar represents one progress bar in a ProgressBarPrinter. Should not +// be created directly, use the AddProgressBar on a ProgressBarPrinter to +// create these. +type ProgressBar struct { + lock sync.Mutex + + currentProgress float64 + printBefore string + printAfter string + done bool +} + +func (pb *ProgressBar) clone() *ProgressBar { + pb.lock.Lock() + pbClone := &ProgressBar{ + currentProgress: pb.currentProgress, + printBefore: pb.printBefore, + printAfter: pb.printAfter, + done: pb.done, + } + pb.lock.Unlock() + return pbClone +} + +func (pb *ProgressBar) GetCurrentProgress() float64 { + pb.lock.Lock() + val := pb.currentProgress + pb.lock.Unlock() + return val +} + +// SetCurrentProgress sets the progress of this ProgressBar. The progress must +// be between 0 and 1 inclusive. +func (pb *ProgressBar) SetCurrentProgress(progress float64) error { + if progress < 0 || progress > 1 { + return ErrorProgressOutOfBounds + } + pb.lock.Lock() + pb.currentProgress = progress + pb.lock.Unlock() + return nil +} + +// GetDone returns whether or not this progress bar is done +func (pb *ProgressBar) GetDone() bool { + pb.lock.Lock() + val := pb.done + pb.lock.Unlock() + return val +} + +// SetDone sets whether or not this progress bar is done +func (pb *ProgressBar) SetDone(val bool) { + pb.lock.Lock() + pb.done = val + pb.lock.Unlock() +} + +// GetPrintBefore gets the text printed on the line before the progress bar. +func (pb *ProgressBar) GetPrintBefore() string { + pb.lock.Lock() + val := pb.printBefore + pb.lock.Unlock() + return val +} + +// SetPrintBefore sets the text printed on the line before the progress bar. +func (pb *ProgressBar) SetPrintBefore(before string) { + pb.lock.Lock() + pb.printBefore = before + pb.lock.Unlock() +} + +// GetPrintAfter gets the text printed on the line after the progress bar. +func (pb *ProgressBar) GetPrintAfter() string { + pb.lock.Lock() + val := pb.printAfter + pb.lock.Unlock() + return val +} + +// SetPrintAfter sets the text printed on the line after the progress bar. +func (pb *ProgressBar) SetPrintAfter(after string) { + pb.lock.Lock() + pb.printAfter = after + pb.lock.Unlock() +} + +// ProgressBarPrinter will print out the progress of some number of +// ProgressBars. +type ProgressBarPrinter struct { + lock sync.Mutex + + // DisplayWidth can be set to influence how large the progress bars are. + // The bars will be scaled to attempt to produce lines of this number of + // characters, but lines of different lengths may still be printed. When + // this value is 0 (aka unset), 80 character columns are assumed. + DisplayWidth int + // PadToBeEven, when set to true, will make Print pad the printBefore text + // with trailing spaces and the printAfter text with leading spaces to make + // the progress bars the same length. + PadToBeEven bool + numLinesInLastPrint int + progressBars []*ProgressBar + maxBefore int + maxAfter int +} + +// AddProgressBar will create a new ProgressBar, register it with this +// ProgressBarPrinter, and return it. This must be called at least once before +// PrintAndWait is called. +func (pbp *ProgressBarPrinter) AddProgressBar() *ProgressBar { + pb := &ProgressBar{} + pbp.lock.Lock() + pbp.progressBars = append(pbp.progressBars, pb) + pbp.lock.Unlock() + return pb +} + +// Print will print out progress information for each ProgressBar that has been +// added to this ProgressBarPrinter. The progress will be written to printTo, +// and if printTo is a terminal it will draw progress bars. AddProgressBar +// must be called at least once before Print is called. If printing to a +// terminal, all draws after the first one will move the cursor up to draw over +// the previously printed bars. +func (pbp *ProgressBarPrinter) Print(printTo io.Writer) (bool, error) { + pbp.lock.Lock() + var bars []*ProgressBar + for _, bar := range pbp.progressBars { + bars = append(bars, bar.clone()) + } + numColumns := pbp.DisplayWidth + pbp.lock.Unlock() + + if len(bars) == 0 { + return false, ErrorNoBarsAdded + } + + if numColumns == 0 { + numColumns = 80 + } + + if isTerminal(printTo) { + moveCursorUp(printTo, pbp.numLinesInLastPrint) + } + + for _, bar := range bars { + beforeSize := len(bar.GetPrintBefore()) + afterSize := len(bar.GetPrintAfter()) + if beforeSize > pbp.maxBefore { + pbp.maxBefore = beforeSize + } + if afterSize > pbp.maxAfter { + pbp.maxAfter = afterSize + } + } + + allDone := true + for _, bar := range bars { + if isTerminal(printTo) { + bar.printToTerminal(printTo, numColumns, pbp.PadToBeEven, pbp.maxBefore, pbp.maxAfter) + } else { + bar.printToNonTerminal(printTo) + } + allDone = allDone && bar.GetCurrentProgress() == 1 + } + + pbp.numLinesInLastPrint = len(bars) + + return allDone, nil +} + +// moveCursorUp moves the cursor up numLines in the terminal +func moveCursorUp(printTo io.Writer, numLines int) { + if numLines > 0 { + fmt.Fprintf(printTo, "\033[%dA", numLines) + } +} + +func (pb *ProgressBar) printToTerminal(printTo io.Writer, numColumns int, padding bool, maxBefore, maxAfter int) { + before := pb.GetPrintBefore() + after := pb.GetPrintAfter() + + if padding { + before = before + strings.Repeat(" ", maxBefore-len(before)) + after = strings.Repeat(" ", maxAfter-len(after)) + after + } + + progressBarSize := numColumns - (len(fmt.Sprintf("%s [] %s", before, after))) + progressBar := "" + if progressBarSize > 0 { + currentProgress := int(pb.GetCurrentProgress() * float64(progressBarSize)) + progressBar = fmt.Sprintf("[%s%s] ", + strings.Repeat("=", currentProgress), + strings.Repeat(" ", progressBarSize-currentProgress)) + } else { + // If we can't fit the progress bar, better to not pad the before/after. + before = pb.GetPrintBefore() + after = pb.GetPrintAfter() + } + + fmt.Fprintf(printTo, "%s %s%s\n", before, progressBar, after) +} + +func (pb *ProgressBar) printToNonTerminal(printTo io.Writer) { + if !pb.GetDone() { + fmt.Fprintf(printTo, "%s %s\n", pb.printBefore, pb.printAfter) + if pb.GetCurrentProgress() == 1 { + pb.SetDone(true) + } + } +} + +// isTerminal returns True when w is going to a tty, and false otherwise. +func isTerminal(w io.Writer) bool { + if f, ok := w.(*os.File); ok { + return terminal.IsTerminal(int(f.Fd())) + } + return false +} diff --git a/vendor/github.com/cpuguy83/go-md2man/LICENSE.md b/vendor/github.com/cpuguy83/go-md2man/LICENSE.md new file mode 100644 index 0000000000..1cade6cef6 --- /dev/null +++ b/vendor/github.com/cpuguy83/go-md2man/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Brian Goff + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/github.com/cpuguy83/go-md2man/md2man.go b/vendor/github.com/cpuguy83/go-md2man/md2man.go new file mode 100644 index 0000000000..1dc70f47a7 --- /dev/null +++ b/vendor/github.com/cpuguy83/go-md2man/md2man.go @@ -0,0 +1,44 @@ +package main + +import ( + "flag" + "fmt" + "io/ioutil" + "os" + + "github.com/cpuguy83/go-md2man/md2man" +) + +var inFilePath = flag.String("in", "", "Path to file to be processed") +var outFilePath = flag.String("out", "", "Path to output processed file") + +func main() { + flag.Parse() + + inFile, err := os.Open(*inFilePath) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + defer inFile.Close() + + doc, err := ioutil.ReadAll(inFile) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + out := md2man.Render(doc) + + outFile, err := os.Create(*outFilePath) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + defer outFile.Close() + _, err = outFile.Write(out) + if err != nil { + fmt.Println(err) + os.Exit(1) + } +} diff --git a/vendor/github.com/cpuguy83/go-md2man/md2man/md2man.go b/vendor/github.com/cpuguy83/go-md2man/md2man/md2man.go new file mode 100644 index 0000000000..8f44fa1550 --- /dev/null +++ b/vendor/github.com/cpuguy83/go-md2man/md2man/md2man.go @@ -0,0 +1,19 @@ +package md2man + +import ( + "github.com/russross/blackfriday" +) + +func Render(doc []byte) []byte { + renderer := RoffRenderer(0) + extensions := 0 + extensions |= blackfriday.EXTENSION_NO_INTRA_EMPHASIS + extensions |= blackfriday.EXTENSION_TABLES + extensions |= blackfriday.EXTENSION_FENCED_CODE + extensions |= blackfriday.EXTENSION_AUTOLINK + extensions |= blackfriday.EXTENSION_SPACE_HEADERS + extensions |= blackfriday.EXTENSION_FOOTNOTES + extensions |= blackfriday.EXTENSION_TITLEBLOCK + + return blackfriday.Markdown(doc, renderer, extensions) +} diff --git a/vendor/github.com/cpuguy83/go-md2man/md2man/roff.go b/vendor/github.com/cpuguy83/go-md2man/md2man/roff.go new file mode 100644 index 0000000000..4478786b7b --- /dev/null +++ b/vendor/github.com/cpuguy83/go-md2man/md2man/roff.go @@ -0,0 +1,269 @@ +package md2man + +import ( + "bytes" + "fmt" + "html" + "strings" + + "github.com/russross/blackfriday" +) + +type roffRenderer struct{} + +func RoffRenderer(flags int) blackfriday.Renderer { + return &roffRenderer{} +} + +func (r *roffRenderer) GetFlags() int { + return 0 +} + +func (r *roffRenderer) TitleBlock(out *bytes.Buffer, text []byte) { + out.WriteString(".TH ") + + splitText := bytes.Split(text, []byte("\n")) + for i, line := range splitText { + line = bytes.TrimPrefix(line, []byte("% ")) + if i == 0 { + line = bytes.Replace(line, []byte("("), []byte("\" \""), 1) + line = bytes.Replace(line, []byte(")"), []byte("\" \""), 1) + } + line = append([]byte("\""), line...) + line = append(line, []byte("\" ")...) + out.Write(line) + } + + out.WriteString(" \"\"\n") +} + +func (r *roffRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string) { + out.WriteString("\n.PP\n.RS\n\n.nf\n") + escapeSpecialChars(out, text) + out.WriteString("\n.fi\n.RE\n") +} + +func (r *roffRenderer) BlockQuote(out *bytes.Buffer, text []byte) { + out.WriteString("\n.PP\n.RS\n") + out.Write(text) + out.WriteString("\n.RE\n") +} + +func (r *roffRenderer) BlockHtml(out *bytes.Buffer, text []byte) { + out.Write(text) +} + +func (r *roffRenderer) Header(out *bytes.Buffer, text func() bool, level int, id string) { + marker := out.Len() + + switch { + case marker == 0: + // This is the doc header + out.WriteString(".TH ") + case level == 1: + out.WriteString("\n\n.SH ") + case level == 2: + out.WriteString("\n.SH ") + default: + out.WriteString("\n.SS ") + } + + if !text() { + out.Truncate(marker) + return + } +} + +func (r *roffRenderer) HRule(out *bytes.Buffer) { + out.WriteString("\n.ti 0\n\\l'\\n(.lu'\n") +} + +func (r *roffRenderer) List(out *bytes.Buffer, text func() bool, flags int) { + marker := out.Len() + out.WriteString(".IP ") + if flags&blackfriday.LIST_TYPE_ORDERED != 0 { + out.WriteString("\\(bu 2") + } else { + out.WriteString("\\n+[step" + string(flags) + "]") + } + out.WriteString("\n") + if !text() { + out.Truncate(marker) + return + } + +} + +func (r *roffRenderer) ListItem(out *bytes.Buffer, text []byte, flags int) { + out.WriteString("\n\\item ") + out.Write(text) +} + +func (r *roffRenderer) Paragraph(out *bytes.Buffer, text func() bool) { + marker := out.Len() + out.WriteString("\n.PP\n") + if !text() { + out.Truncate(marker) + return + } + if marker != 0 { + out.WriteString("\n") + } +} + +// TODO: This might now work +func (r *roffRenderer) Table(out *bytes.Buffer, header []byte, body []byte, columnData []int) { + out.WriteString(".TS\nallbox;\n") + + out.Write(header) + out.Write(body) + out.WriteString("\n.TE\n") +} + +func (r *roffRenderer) TableRow(out *bytes.Buffer, text []byte) { + if out.Len() > 0 { + out.WriteString("\n") + } + out.Write(text) + out.WriteString("\n") +} + +func (r *roffRenderer) TableHeaderCell(out *bytes.Buffer, text []byte, align int) { + if out.Len() > 0 { + out.WriteString(" ") + } + out.Write(text) + out.WriteString(" ") +} + +// TODO: This is probably broken +func (r *roffRenderer) TableCell(out *bytes.Buffer, text []byte, align int) { + if out.Len() > 0 { + out.WriteString("\t") + } + out.Write(text) + out.WriteString("\t") +} + +func (r *roffRenderer) Footnotes(out *bytes.Buffer, text func() bool) { + +} + +func (r *roffRenderer) FootnoteItem(out *bytes.Buffer, name, text []byte, flags int) { + +} + +func (r *roffRenderer) AutoLink(out *bytes.Buffer, link []byte, kind int) { + out.WriteString("\n\\[la]") + out.Write(link) + out.WriteString("\\[ra]") +} + +func (r *roffRenderer) CodeSpan(out *bytes.Buffer, text []byte) { + out.WriteString("\\fB\\fC") + escapeSpecialChars(out, text) + out.WriteString("\\fR") +} + +func (r *roffRenderer) DoubleEmphasis(out *bytes.Buffer, text []byte) { + out.WriteString("\\fB") + out.Write(text) + out.WriteString("\\fP") +} + +func (r *roffRenderer) Emphasis(out *bytes.Buffer, text []byte) { + out.WriteString("\\fI") + out.Write(text) + out.WriteString("\\fP") +} + +func (r *roffRenderer) Image(out *bytes.Buffer, link []byte, title []byte, alt []byte) { +} + +func (r *roffRenderer) LineBreak(out *bytes.Buffer) { + out.WriteString("\n.br\n") +} + +func (r *roffRenderer) Link(out *bytes.Buffer, link []byte, title []byte, content []byte) { + r.AutoLink(out, link, 0) +} + +func (r *roffRenderer) RawHtmlTag(out *bytes.Buffer, tag []byte) { + out.Write(tag) +} + +func (r *roffRenderer) TripleEmphasis(out *bytes.Buffer, text []byte) { + out.WriteString("\\s+2") + out.Write(text) + out.WriteString("\\s-2") +} + +func (r *roffRenderer) StrikeThrough(out *bytes.Buffer, text []byte) { +} + +func (r *roffRenderer) FootnoteRef(out *bytes.Buffer, ref []byte, id int) { + +} + +func (r *roffRenderer) Entity(out *bytes.Buffer, entity []byte) { + out.WriteString(html.UnescapeString(string(entity))) +} + +func processFooterText(text []byte) []byte { + text = bytes.TrimPrefix(text, []byte("% ")) + newText := []byte{} + textArr := strings.Split(string(text), ") ") + + for i, w := range textArr { + if i == 0 { + w = strings.Replace(w, "(", "\" \"", 1) + w = fmt.Sprintf("\"%s\"", w) + } else { + w = fmt.Sprintf(" \"%s\"", w) + } + newText = append(newText, []byte(w)...) + } + newText = append(newText, []byte(" \"\"")...) + + return newText +} + +func (r *roffRenderer) NormalText(out *bytes.Buffer, text []byte) { + escapeSpecialChars(out, text) +} + +func (r *roffRenderer) DocumentHeader(out *bytes.Buffer) { +} + +func (r *roffRenderer) DocumentFooter(out *bytes.Buffer) { +} + +func needsBackslash(c byte) bool { + for _, r := range []byte("-_&\\~") { + if c == r { + return true + } + } + return false +} + +func escapeSpecialChars(out *bytes.Buffer, text []byte) { + for i := 0; i < len(text); i++ { + // directly copy normal characters + org := i + + for i < len(text) && !needsBackslash(text[i]) { + i++ + } + if i > org { + out.Write(text[org:i]) + } + + // escape a character + if i >= len(text) { + break + } + out.WriteByte('\\') + out.WriteByte(text[i]) + } +} diff --git a/vendor/github.com/cznic/b/LICENSE b/vendor/github.com/cznic/b/LICENSE new file mode 100644 index 0000000000..54c6e90872 --- /dev/null +++ b/vendor/github.com/cznic/b/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2014 The b 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 names of the authors nor the names of the +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. diff --git a/vendor/github.com/cznic/b/btree.go b/vendor/github.com/cznic/b/btree.go new file mode 100644 index 0000000000..18cbeb8b05 --- /dev/null +++ b/vendor/github.com/cznic/b/btree.go @@ -0,0 +1,929 @@ +// Copyright 2014 The b 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 b + +import ( + "fmt" + "io" + "sync" +) + +const ( + kx = 32 //TODO benchmark tune this number if using custom key/value type(s). + kd = 32 //TODO benchmark tune this number if using custom key/value type(s). +) + +func init() { + if kd < 1 { + panic(fmt.Errorf("kd %d: out of range", kd)) + } + + if kx < 2 { + panic(fmt.Errorf("kx %d: out of range", kx)) + } +} + +var ( + btDPool = sync.Pool{New: func() interface{} { return &d{} }} + btEPool = btEpool{sync.Pool{New: func() interface{} { return &Enumerator{} }}} + btTPool = btTpool{sync.Pool{New: func() interface{} { return &Tree{} }}} + btXPool = sync.Pool{New: func() interface{} { return &x{} }} +) + +type btTpool struct{ sync.Pool } + +func (p *btTpool) get(cmp Cmp) *Tree { + x := p.Get().(*Tree) + x.cmp = cmp + return x +} + +type btEpool struct{ sync.Pool } + +func (p *btEpool) get(err error, hit bool, i int, k interface{} /*K*/, q *d, t *Tree, ver int64) *Enumerator { + x := p.Get().(*Enumerator) + x.err, x.hit, x.i, x.k, x.q, x.t, x.ver = err, hit, i, k, q, t, ver + return x +} + +type ( + // Cmp compares a and b. Return value is: + // + // < 0 if a < b + // 0 if a == b + // > 0 if a > b + // + Cmp func(a, b interface{} /*K*/) int + + d struct { // data page + c int + d [2*kd + 1]de + n *d + p *d + } + + de struct { // d element + k interface{} /*K*/ + v interface{} /*V*/ + } + + // Enumerator captures the state of enumerating a tree. It is returned + // from the Seek* methods. The enumerator is aware of any mutations + // made to the tree in the process of enumerating it and automatically + // resumes the enumeration at the proper key, if possible. + // + // However, once an Enumerator returns io.EOF to signal "no more + // items", it does no more attempt to "resync" on tree mutation(s). In + // other words, io.EOF from an Enumaretor is "sticky" (idempotent). + Enumerator struct { + err error + hit bool + i int + k interface{} /*K*/ + q *d + t *Tree + ver int64 + } + + // Tree is a B+tree. + Tree struct { + c int + cmp Cmp + first *d + last *d + r interface{} + ver int64 + } + + xe struct { // x element + ch interface{} + k interface{} /*K*/ + } + + x struct { // index page + c int + x [2*kx + 2]xe + } +) + +var ( // R/O zero values + zd d + zde de + ze Enumerator + zk interface{} /*K*/ + zt Tree + zx x + zxe xe +) + +func clr(q interface{}) { + switch x := q.(type) { + case *x: + for i := 0; i <= x.c; i++ { // Ch0 Sep0 ... Chn-1 Sepn-1 Chn + clr(x.x[i].ch) + } + *x = zx + btXPool.Put(x) + case *d: + *x = zd + btDPool.Put(x) + } +} + +// -------------------------------------------------------------------------- x + +func newX(ch0 interface{}) *x { + r := btXPool.Get().(*x) + r.x[0].ch = ch0 + return r +} + +func (q *x) extract(i int) { + q.c-- + if i < q.c { + copy(q.x[i:], q.x[i+1:q.c+1]) + q.x[q.c].ch = q.x[q.c+1].ch + q.x[q.c].k = zk // GC + q.x[q.c+1] = zxe // GC + } +} + +func (q *x) insert(i int, k interface{} /*K*/, ch interface{}) *x { + c := q.c + if i < c { + q.x[c+1].ch = q.x[c].ch + copy(q.x[i+2:], q.x[i+1:c]) + q.x[i+1].k = q.x[i].k + } + c++ + q.c = c + q.x[i].k = k + q.x[i+1].ch = ch + return q +} + +func (q *x) siblings(i int) (l, r *d) { + if i >= 0 { + if i > 0 { + l = q.x[i-1].ch.(*d) + } + if i < q.c { + r = q.x[i+1].ch.(*d) + } + } + return +} + +// -------------------------------------------------------------------------- d + +func (l *d) mvL(r *d, c int) { + copy(l.d[l.c:], r.d[:c]) + copy(r.d[:], r.d[c:r.c]) + l.c += c + r.c -= c +} + +func (l *d) mvR(r *d, c int) { + copy(r.d[c:], r.d[:r.c]) + copy(r.d[:c], l.d[l.c-c:]) + r.c += c + l.c -= c +} + +// ----------------------------------------------------------------------- Tree + +// TreeNew returns a newly created, empty Tree. The compare function is used +// for key collation. +func TreeNew(cmp Cmp) *Tree { + return btTPool.get(cmp) +} + +// Clear removes all K/V pairs from the tree. +func (t *Tree) Clear() { + if t.r == nil { + return + } + + clr(t.r) + t.c, t.first, t.last, t.r = 0, nil, nil, nil + t.ver++ +} + +// Close performs Clear and recycles t to a pool for possible later reuse. No +// references to t should exist or such references must not be used afterwards. +func (t *Tree) Close() { + t.Clear() + *t = zt + btTPool.Put(t) +} + +func (t *Tree) cat(p *x, q, r *d, pi int) { + t.ver++ + q.mvL(r, r.c) + if r.n != nil { + r.n.p = q + } else { + t.last = q + } + q.n = r.n + *r = zd + btDPool.Put(r) + if p.c > 1 { + p.extract(pi) + p.x[pi].ch = q + return + } + + switch x := t.r.(type) { + case *x: + *x = zx + btXPool.Put(x) + case *d: + *x = zd + btDPool.Put(x) + } + t.r = q +} + +func (t *Tree) catX(p, q, r *x, pi int) { + t.ver++ + q.x[q.c].k = p.x[pi].k + copy(q.x[q.c+1:], r.x[:r.c]) + q.c += r.c + 1 + q.x[q.c].ch = r.x[r.c].ch + *r = zx + btXPool.Put(r) + if p.c > 1 { + p.c-- + pc := p.c + if pi < pc { + p.x[pi].k = p.x[pi+1].k + copy(p.x[pi+1:], p.x[pi+2:pc+1]) + p.x[pc].ch = p.x[pc+1].ch + p.x[pc].k = zk // GC + p.x[pc+1].ch = nil // GC + } + return + } + + switch x := t.r.(type) { + case *x: + *x = zx + btXPool.Put(x) + case *d: + *x = zd + btDPool.Put(x) + } + t.r = q +} + +// Delete removes the k's KV pair, if it exists, in which case Delete returns +// true. +func (t *Tree) Delete(k interface{} /*K*/) (ok bool) { + pi := -1 + var p *x + q := t.r + if q == nil { + return false + } + + for { + var i int + i, ok = t.find(q, k) + if ok { + switch x := q.(type) { + case *x: + if x.c < kx && q != t.r { + x, i = t.underflowX(p, x, pi, i) + } + pi = i + 1 + p = x + q = x.x[pi].ch + ok = false + continue + case *d: + t.extract(x, i) + if x.c >= kd { + return true + } + + if q != t.r { + t.underflow(p, x, pi) + } else if t.c == 0 { + t.Clear() + } + return true + } + } + + switch x := q.(type) { + case *x: + if x.c < kx && q != t.r { + x, i = t.underflowX(p, x, pi, i) + } + pi = i + p = x + q = x.x[i].ch + case *d: + return false + } + } +} + +func (t *Tree) extract(q *d, i int) { // (r interface{} /*V*/) { + t.ver++ + //r = q.d[i].v // prepared for Extract + q.c-- + if i < q.c { + copy(q.d[i:], q.d[i+1:q.c+1]) + } + q.d[q.c] = zde // GC + t.c-- + return +} + +func (t *Tree) find(q interface{}, k interface{} /*K*/) (i int, ok bool) { + var mk interface{} /*K*/ + l := 0 + switch x := q.(type) { + case *x: + h := x.c - 1 + for l <= h { + m := (l + h) >> 1 + mk = x.x[m].k + switch cmp := t.cmp(k, mk); { + case cmp > 0: + l = m + 1 + case cmp == 0: + return m, true + default: + h = m - 1 + } + } + case *d: + h := x.c - 1 + for l <= h { + m := (l + h) >> 1 + mk = x.d[m].k + switch cmp := t.cmp(k, mk); { + case cmp > 0: + l = m + 1 + case cmp == 0: + return m, true + default: + h = m - 1 + } + } + } + return l, false +} + +// First returns the first item of the tree in the key collating order, or +// (zero-value, zero-value) if the tree is empty. +func (t *Tree) First() (k interface{} /*K*/, v interface{} /*V*/) { + if q := t.first; q != nil { + q := &q.d[0] + k, v = q.k, q.v + } + return +} + +// Get returns the value associated with k and true if it exists. Otherwise Get +// returns (zero-value, false). +func (t *Tree) Get(k interface{} /*K*/) (v interface{} /*V*/, ok bool) { + q := t.r + if q == nil { + return + } + + for { + var i int + if i, ok = t.find(q, k); ok { + switch x := q.(type) { + case *x: + q = x.x[i+1].ch + continue + case *d: + return x.d[i].v, true + } + } + switch x := q.(type) { + case *x: + q = x.x[i].ch + default: + return + } + } +} + +func (t *Tree) insert(q *d, i int, k interface{} /*K*/, v interface{} /*V*/) *d { + t.ver++ + c := q.c + if i < c { + copy(q.d[i+1:], q.d[i:c]) + } + c++ + q.c = c + q.d[i].k, q.d[i].v = k, v + t.c++ + return q +} + +// Last returns the last item of the tree in the key collating order, or +// (zero-value, zero-value) if the tree is empty. +func (t *Tree) Last() (k interface{} /*K*/, v interface{} /*V*/) { + if q := t.last; q != nil { + q := &q.d[q.c-1] + k, v = q.k, q.v + } + return +} + +// Len returns the number of items in the tree. +func (t *Tree) Len() int { + return t.c +} + +func (t *Tree) overflow(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{} /*V*/) { + t.ver++ + l, r := p.siblings(pi) + + if l != nil && l.c < 2*kd { + l.mvL(q, 1) + t.insert(q, i-1, k, v) + p.x[pi-1].k = q.d[0].k + return + } + + if r != nil && r.c < 2*kd { + if i < 2*kd { + q.mvR(r, 1) + t.insert(q, i, k, v) + p.x[pi].k = r.d[0].k + return + } + + t.insert(r, 0, k, v) + p.x[pi].k = k + return + } + + t.split(p, q, pi, i, k, v) +} + +// Seek returns an Enumerator positioned on a an item such that k >= item's +// key. ok reports if k == item.key The Enumerator's position is possibly +// after the last item in the tree. +func (t *Tree) Seek(k interface{} /*K*/) (e *Enumerator, ok bool) { + q := t.r + if q == nil { + e = btEPool.get(nil, false, 0, k, nil, t, t.ver) + return + } + + for { + var i int + if i, ok = t.find(q, k); ok { + switch x := q.(type) { + case *x: + q = x.x[i+1].ch + continue + case *d: + return btEPool.get(nil, ok, i, k, x, t, t.ver), true + } + } + + switch x := q.(type) { + case *x: + q = x.x[i].ch + case *d: + return btEPool.get(nil, ok, i, k, x, t, t.ver), false + } + } +} + +// SeekFirst returns an enumerator positioned on the first KV pair in the tree, +// if any. For an empty tree, err == io.EOF is returned and e will be nil. +func (t *Tree) SeekFirst() (e *Enumerator, err error) { + q := t.first + if q == nil { + return nil, io.EOF + } + + return btEPool.get(nil, true, 0, q.d[0].k, q, t, t.ver), nil +} + +// SeekLast returns an enumerator positioned on the last KV pair in the tree, +// if any. For an empty tree, err == io.EOF is returned and e will be nil. +func (t *Tree) SeekLast() (e *Enumerator, err error) { + q := t.last + if q == nil { + return nil, io.EOF + } + + return btEPool.get(nil, true, q.c-1, q.d[q.c-1].k, q, t, t.ver), nil +} + +// Set sets the value associated with k. +func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) { + //dbg("--- PRE Set(%v, %v)\n%s", k, v, t.dump()) + //defer func() { + // dbg("--- POST\n%s\n====\n", t.dump()) + //}() + + pi := -1 + var p *x + q := t.r + if q == nil { + z := t.insert(btDPool.Get().(*d), 0, k, v) + t.r, t.first, t.last = z, z, z + return + } + + for { + i, ok := t.find(q, k) + if ok { + switch x := q.(type) { + case *x: + if x.c > 2*kx { + x, i = t.splitX(p, x, pi, i) + } + pi = i + 1 + p = x + q = x.x[i+1].ch + continue + case *d: + x.d[i].v = v + } + return + } + + switch x := q.(type) { + case *x: + if x.c > 2*kx { + x, i = t.splitX(p, x, pi, i) + } + pi = i + p = x + q = x.x[i].ch + case *d: + switch { + case x.c < 2*kd: + t.insert(x, i, k, v) + default: + t.overflow(p, x, pi, i, k, v) + } + return + } + } +} + +// Put combines Get and Set in a more efficient way where the tree is walked +// only once. The upd(ater) receives (old-value, true) if a KV pair for k +// exists or (zero-value, false) otherwise. It can then return a (new-value, +// true) to create or overwrite the existing value in the KV pair, or +// (whatever, false) if it decides not to create or not to update the value of +// the KV pair. +// +// tree.Set(k, v) call conceptually equals calling +// +// tree.Put(k, func(interface{} /*K*/, bool){ return v, true }) +// +// modulo the differing return values. +func (t *Tree) Put(k interface{} /*K*/, upd func(oldV interface{} /*V*/, exists bool) (newV interface{} /*V*/, write bool)) (oldV interface{} /*V*/, written bool) { + pi := -1 + var p *x + q := t.r + var newV interface{} /*V*/ + if q == nil { + // new KV pair in empty tree + newV, written = upd(newV, false) + if !written { + return + } + + z := t.insert(btDPool.Get().(*d), 0, k, newV) + t.r, t.first, t.last = z, z, z + return + } + + for { + i, ok := t.find(q, k) + if ok { + switch x := q.(type) { + case *x: + if x.c > 2*kx { + x, i = t.splitX(p, x, pi, i) + } + pi = i + 1 + p = x + q = x.x[i+1].ch + continue + case *d: + oldV = x.d[i].v + newV, written = upd(oldV, true) + if !written { + return + } + + x.d[i].v = newV + } + return + } + + switch x := q.(type) { + case *x: + if x.c > 2*kx { + x, i = t.splitX(p, x, pi, i) + } + pi = i + p = x + q = x.x[i].ch + case *d: // new KV pair + newV, written = upd(newV, false) + if !written { + return + } + + switch { + case x.c < 2*kd: + t.insert(x, i, k, newV) + default: + t.overflow(p, x, pi, i, k, newV) + } + return + } + } +} + +func (t *Tree) split(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{} /*V*/) { + t.ver++ + r := btDPool.Get().(*d) + if q.n != nil { + r.n = q.n + r.n.p = r + } else { + t.last = r + } + q.n = r + r.p = q + + copy(r.d[:], q.d[kd:2*kd]) + for i := range q.d[kd:] { + q.d[kd+i] = zde + } + q.c = kd + r.c = kd + var done bool + if i > kd { + done = true + t.insert(r, i-kd, k, v) + } + if pi >= 0 { + p.insert(pi, r.d[0].k, r) + } else { + t.r = newX(q).insert(0, r.d[0].k, r) + } + if done { + return + } + + t.insert(q, i, k, v) +} + +func (t *Tree) splitX(p *x, q *x, pi int, i int) (*x, int) { + t.ver++ + r := btXPool.Get().(*x) + copy(r.x[:], q.x[kx+1:]) + q.c = kx + r.c = kx + if pi >= 0 { + p.insert(pi, q.x[kx].k, r) + q.x[kx].k = zk + for i := range q.x[kx+1:] { + q.x[kx+i+1] = zxe + } + + switch { + case i < kx: + return q, i + case i == kx: + return p, pi + default: // i > kx + return r, i - kx - 1 + } + } + + nr := newX(q).insert(0, q.x[kx].k, r) + t.r = nr + q.x[kx].k = zk + for i := range q.x[kx+1:] { + q.x[kx+i+1] = zxe + } + + switch { + case i < kx: + return q, i + case i == kx: + return nr, 0 + default: // i > kx + return r, i - kx - 1 + } +} + +func (t *Tree) underflow(p *x, q *d, pi int) { + t.ver++ + l, r := p.siblings(pi) + + if l != nil && l.c+q.c >= 2*kd { + l.mvR(q, 1) + p.x[pi-1].k = q.d[0].k + return + } + + if r != nil && q.c+r.c >= 2*kd { + q.mvL(r, 1) + p.x[pi].k = r.d[0].k + r.d[r.c] = zde // GC + return + } + + if l != nil { + t.cat(p, l, q, pi-1) + return + } + + t.cat(p, q, r, pi) +} + +func (t *Tree) underflowX(p *x, q *x, pi int, i int) (*x, int) { + t.ver++ + var l, r *x + + if pi >= 0 { + if pi > 0 { + l = p.x[pi-1].ch.(*x) + } + if pi < p.c { + r = p.x[pi+1].ch.(*x) + } + } + + if l != nil && l.c > kx { + q.x[q.c+1].ch = q.x[q.c].ch + copy(q.x[1:], q.x[:q.c]) + q.x[0].ch = l.x[l.c].ch + q.x[0].k = p.x[pi-1].k + q.c++ + i++ + l.c-- + p.x[pi-1].k = l.x[l.c].k + return q, i + } + + if r != nil && r.c > kx { + q.x[q.c].k = p.x[pi].k + q.c++ + q.x[q.c].ch = r.x[0].ch + p.x[pi].k = r.x[0].k + copy(r.x[:], r.x[1:r.c]) + r.c-- + rc := r.c + r.x[rc].ch = r.x[rc+1].ch + r.x[rc].k = zk + r.x[rc+1].ch = nil + return q, i + } + + if l != nil { + i += l.c + 1 + t.catX(p, l, q, pi-1) + q = l + return q, i + } + + t.catX(p, q, r, pi) + return q, i +} + +// ----------------------------------------------------------------- Enumerator + +// Close recycles e to a pool for possible later reuse. No references to e +// should exist or such references must not be used afterwards. +func (e *Enumerator) Close() { + *e = ze + btEPool.Put(e) +} + +// Next returns the currently enumerated item, if it exists and moves to the +// next item in the key collation order. If there is no item to return, err == +// io.EOF is returned. +func (e *Enumerator) Next() (k interface{} /*K*/, v interface{} /*V*/, err error) { + if err = e.err; err != nil { + return + } + + if e.ver != e.t.ver { + f, hit := e.t.Seek(e.k) + if !e.hit && hit { + if err = f.next(); err != nil { + return + } + } + + *e = *f + f.Close() + } + if e.q == nil { + e.err, err = io.EOF, io.EOF + return + } + + if e.i >= e.q.c { + if err = e.next(); err != nil { + return + } + } + + i := e.q.d[e.i] + k, v = i.k, i.v + e.k, e.hit = k, false + e.next() + return +} + +func (e *Enumerator) next() error { + if e.q == nil { + e.err = io.EOF + return io.EOF + } + + switch { + case e.i < e.q.c-1: + e.i++ + default: + if e.q, e.i = e.q.n, 0; e.q == nil { + e.err = io.EOF + } + } + return e.err +} + +// Prev returns the currently enumerated item, if it exists and moves to the +// previous item in the key collation order. If there is no item to return, err +// == io.EOF is returned. +func (e *Enumerator) Prev() (k interface{} /*K*/, v interface{} /*V*/, err error) { + if err = e.err; err != nil { + return + } + + if e.ver != e.t.ver { + f, hit := e.t.Seek(e.k) + if !e.hit && hit { + if err = f.prev(); err != nil { + return + } + } + + *e = *f + f.Close() + } + if e.q == nil { + e.err, err = io.EOF, io.EOF + return + } + + if e.i >= e.q.c { + if err = e.next(); err != nil { + return + } + } + + i := e.q.d[e.i] + k, v = i.k, i.v + e.k, e.hit = k, false + e.prev() + return +} + +func (e *Enumerator) prev() error { + if e.q == nil { + e.err = io.EOF + return io.EOF + } + + switch { + case e.i > 0: + e.i-- + default: + if e.q = e.q.p; e.q == nil { + e.err = io.EOF + break + } + + e.i = e.q.c - 1 + } + return e.err +} diff --git a/vendor/github.com/cznic/b/doc.go b/vendor/github.com/cznic/b/doc.go new file mode 100644 index 0000000000..ddcf73704f --- /dev/null +++ b/vendor/github.com/cznic/b/doc.go @@ -0,0 +1,53 @@ +// Copyright 2014 The b 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 b implements the B+tree flavor of a BTree. +// +// Changelog +// +// 2014-06-26: Lower GC presure by recycling things. +// +// 2014-04-18: Added new method Put. +// +// Generic types +// +// Keys and their associated values are interface{} typed, similar to all of +// the containers in the standard library. +// +// Semiautomatic production of a type specific variant of this package is +// supported via +// +// $ make generic +// +// This command will write to stdout a version of the btree.go file where every +// key type occurrence is replaced by the word 'KEY' and every value type +// occurrence is replaced by the word 'VALUE'. Then you have to replace these +// tokens with your desired type(s), using any technique you're comfortable +// with. +// +// This is how, for example, 'example/int.go' was created: +// +// $ mkdir example +// $ make generic | sed -e 's/KEY/int/g' -e 's/VALUE/int/g' > example/int.go +// +// No other changes to int.go are necessary, it compiles just fine. +// +// Running the benchmarks for 1000 keys on a machine with Intel i5-4670 CPU @ +// 3.4GHz, Go release 1.4.2. +// +// $ go test -bench 1e3 example/all_test.go example/int.go +// PASS +// BenchmarkSetSeq1e3 10000 151620 ns/op +// BenchmarkGetSeq1e3 10000 115354 ns/op +// BenchmarkSetRnd1e3 5000 255865 ns/op +// BenchmarkGetRnd1e3 10000 140466 ns/op +// BenchmarkDelSeq1e3 10000 143860 ns/op +// BenchmarkDelRnd1e3 10000 188228 ns/op +// BenchmarkSeekSeq1e3 10000 156448 ns/op +// BenchmarkSeekRnd1e3 10000 190587 ns/op +// BenchmarkNext1e3 200000 9407 ns/op +// BenchmarkPrev1e3 200000 9306 ns/op +// ok command-line-arguments 26.369s +// $ +package b diff --git a/vendor/github.com/cznic/bufs/LICENSE b/vendor/github.com/cznic/bufs/LICENSE new file mode 100644 index 0000000000..7d80fe28eb --- /dev/null +++ b/vendor/github.com/cznic/bufs/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2014 The bufs 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 names of the authors nor the names of the +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. diff --git a/vendor/github.com/cznic/bufs/bufs.go b/vendor/github.com/cznic/bufs/bufs.go new file mode 100644 index 0000000000..f4e0eee2a6 --- /dev/null +++ b/vendor/github.com/cznic/bufs/bufs.go @@ -0,0 +1,391 @@ +// Copyright 2014 The bufs 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 bufs implements a simple buffer cache. +// +// The intended use scheme is like: +// +// type Foo struct { +// buffers bufs.Buffers +// ... +// } +// +// // Bar can call Qux, but not the other way around (in this example). +// const maxFooDepth = 2 +// +// func NewFoo() *Foo { +// return &Foo{buffers: bufs.New(maxFooDepth), ...} +// } +// +// func (f *Foo) Bar(n int) { +// buf := f.buffers.Alloc(n) // needed locally for computation and/or I/O +// defer f.buffers.Free() +// ... +// f.Qux(whatever) +// } +// +// func (f *Foo) Qux(n int) { +// buf := f.buffers.Alloc(n) // needed locally for computation and/or I/O +// defer f.buffers.Free() +// ... +// } +// +// The whole idea behind 'bufs' is that when calling e.g. Foo.Bar N times, then +// normally, without using 'bufs', there will be 2*N (in this example) []byte +// buffers allocated. While using 'bufs', only 2 buffers (in this example) +// will ever be created. For large N it can be a substantial difference. +// +// It's not a good idea to use Buffers to cache too big buffers. The cost of +// having a cached buffer is that the buffer is naturally not eligible for +// garbage collection. Of course, that holds only while the Foo instance is +// reachable, in the above example. +// +// The buffer count limit is intentionally "hard" (read panicking), although +// configurable in New(). The rationale is to prevent recursive calls, using +// Alloc, to cause excessive, "static" memory consumption. Tune the limit +// carefully or do not use Buffers from within [mutually] recursive functions +// where the nesting depth is not realistically bounded to some rather small +// number. +// +// Buffers cannot guarantee improvements to you program performance. There may +// be a gain in case where they fit well. Firm grasp on what your code is +// actually doing, when and in what order is essential to proper use of +// Buffers. It's _highly_ recommended to first do profiling and memory +// profiling before even thinking about using 'bufs'. The real world example, +// and cause for this package, was a first correct, yet no optimizations done +// version of a program; producing few MB of useful data while allocating 20+GB +// of memory. Of course the garbage collector properly kicked in, yet the +// memory abuse caused ~80+% of run time to be spent memory management. The +// program _was_ expected to be slow in its still development phase, but the +// bottleneck was guessed to be in I/O. Actually the hard disk was waiting for +// the billions bytes being allocated and zeroed. Garbage collect on low +// memory, rinse and repeat. +// +// In the provided tests, TestFoo and TestFooBufs do the same simulated work, +// except the later uses Buffers while the former does not. Suggested test runs +// which show the differences: +// +// $ go test -bench . -benchmem +// +// or +// +// $ go test -c +// $ ./bufs.test -test.v -test.run Foo -test.memprofile mem.out -test.memprofilerate 1 +// $ go tool pprof bufs.test mem.out --alloc_space --nodefraction 0.0001 --edgefraction 0 -web +// $ # Note: Foo vs FooBufs allocated memory is in hundreds of MBs vs 8 kB. +// +// or +// +// $ make demo # same as all of the above +// +// +// NOTE: Alloc/Free calls must be properly nested in the same way as in for +// example BeginTransaction/EndTransaction pairs. If your code can panic then +// the pairing should be enforced by deferred calls. +// +// NOTE: Buffers objects do not allocate any space until requested by Alloc, +// the mechanism works on demand only. +// +// FAQ: Why the 'bufs' package name? +// +// Package name 'bufs' was intentionally chosen instead of the perhaps more +// conventional 'buf'. There are already too many 'buf' named things in the +// code out there and that'll be a source of a lot of trouble. It's a bit +// similar situation as in the case of package "strings" (not "string"). +package bufs + +import ( + "errors" + "sort" + "sync" +) + +// Buffers type represents a buffer ([]byte) cache. +// +// NOTE: Do not modify Buffers directly, use only its methods. Do not create +// additional values (copies) of Buffers, that'll break its functionality. Use +// a pointer instead to refer to a single instance from different +// places/scopes. +type Buffers [][]byte + +// New returns a newly created instance of Buffers with a maximum capacity of n +// buffers. +// +// NOTE: 'bufs.New(n)' is the same as 'make(bufs.Buffers, n)'. +func New(n int) Buffers { + return make(Buffers, n) +} + +// Alloc will return a buffer such that len(r) == n. It will firstly try to +// find an existing and unused buffer of big enough size. Only when there is no +// such, then one of the buffer slots is reallocated to a bigger size. +// +// It's okay to use append with buffers returned by Alloc. But it can cause +// allocation in that case and will again be producing load for the garbage +// collector. The best use of Alloc is for I/O buffers where the needed size of +// the buffer is figured out at some point of the code path in a 'final size' +// sense. Another real world example are compression/decompression buffers. +// +// NOTE: The buffer returned by Alloc _is not_ zeroed. That's okay for e.g. +// passing a buffer to io.Reader. If you need a zeroed buffer use Calloc. +// +// NOTE: Buffers returned from Alloc _must not_ be exposed/returned to your +// clients. Those buffers are intended to be used strictly internally, within +// the methods of some "object". +// +// NOTE: Alloc will panic if there are no buffers (buffer slots) left. +func (p *Buffers) Alloc(n int) (r []byte) { + b := *p + if len(b) == 0 { + panic(errors.New("Buffers.Alloc: out of buffers")) + } + + biggest, best, biggestI, bestI := -1, -1, -1, -1 + for i, v := range b { + //ln := len(v) + // The above was correct, buts it's just confusing. It worked + // because not the buffers, but slices of them are returned in + // the 'if best >= n' code path. + ln := cap(v) + + if ln >= biggest { + biggest, biggestI = ln, i + } + + if ln >= n && (bestI < 0 || best > ln) { + best, bestI = ln, i + if ln == n { + break + } + } + } + + last := len(b) - 1 + if best >= n { + r = b[bestI] + b[last], b[bestI] = b[bestI], b[last] + *p = b[:last] + return r[:n] + } + + r = make([]byte, n, overCommit(n)) + b[biggestI] = r + b[last], b[biggestI] = b[biggestI], b[last] + *p = b[:last] + return +} + +// Calloc will acquire a buffer using Alloc and then clears it to zeros. The +// zeroing goes up to n, not cap(r). +func (p *Buffers) Calloc(n int) (r []byte) { + r = p.Alloc(n) + for i := range r { + r[i] = 0 + } + return +} + +// Free makes the lastly allocated by Alloc buffer free (available) again for +// Alloc. +// +// NOTE: Improper Free invocations, like in the sequence {New, Alloc, Free, +// Free}, will panic. +func (p *Buffers) Free() { + b := *p + b = b[:len(b)+1] + *p = b +} + +// Stats reports memory consumed by Buffers, without accounting for some +// (smallish) additional overhead. +func (p *Buffers) Stats() (bytes int) { + b := *p + b = b[:cap(b)] + for _, v := range b { + bytes += cap(v) + } + return +} + +// Cache caches buffers ([]byte). A zero value of Cache is ready for use. +// +// NOTE: Do not modify a Cache directly, use only its methods. Do not create +// additional values (copies) of a Cache, that'll break its functionality. Use +// a pointer instead to refer to a single instance from different +// places/scopes. +type Cache [][]byte + +// Get returns a buffer ([]byte) of length n. If no such buffer is cached then +// a biggest cached buffer is resized to have length n and returned. If there +// are no cached items at all, Get returns a newly allocated buffer. +// +// In other words the cache policy is: +// +// - If the cache is empty, the buffer must be newly created and returned. +// Cache remains empty. +// +// - If a buffer of sufficient size is found in the cache, remove it from the +// cache and return it. +// +// - Otherwise the cache is non empty, but no cached buffer is big enough. +// Enlarge the biggest cached buffer, remove it from the cache and return it. +// This provide cached buffers size adjustment based on demand. +// +// In short, if the cache is not empty, Get guarantees to make it always one +// item less. This rules prevent uncontrolled cache grow in some scenarios. +// The older policy was not preventing that. Another advantage is better cached +// buffers sizes "auto tuning", although not in every possible use case. +// +// NOTE: The buffer returned by Get _is not guaranteed_ to be zeroed. That's +// okay for e.g. passing a buffer to io.Reader. If you need a zeroed buffer +// use Cget. +func (c *Cache) Get(n int) []byte { + r, _ := c.get(n) + return r +} + +func (c *Cache) get(n int) (r []byte, isZeroed bool) { + s := *c + lens := len(s) + if lens == 0 { + r, isZeroed = make([]byte, n, overCommit(n)), true + return + } + + i := sort.Search(lens, func(x int) bool { return len(s[x]) >= n }) + if i == lens { + i-- + s[i] = make([]byte, n, overCommit(n)) + } + r = s[i][:n] + copy(s[i:], s[i+1:]) + s[lens-1] = nil + s = s[:lens-1] + *c = s + return r, false +} + +// Cget will acquire a buffer using Get and then clears it to zeros. The +// zeroing goes up to n, not cap(r). +func (c *Cache) Cget(n int) (r []byte) { + r, ok := c.get(n) + if ok { + return + } + + for i := range r { + r[i] = 0 + } + return +} + +// Put caches b for possible later reuse (via Get). No other references to b's +// backing array may exist. Otherwise a big mess is sooner or later inevitable. +func (c *Cache) Put(b []byte) { + b = b[:cap(b)] + lenb := len(b) + if lenb == 0 { + return + } + + s := *c + lens := len(s) + i := sort.Search(lens, func(x int) bool { return len(s[x]) >= lenb }) + s = append(s, nil) + copy(s[i+1:], s[i:]) + s[i] = b + *c = s + return +} + +// Stats reports memory consumed by a Cache, without accounting for some +// (smallish) additional overhead. 'n' is the number of cached buffers, bytes +// is their combined capacity. +func (c Cache) Stats() (n, bytes int) { + n = len(c) + for _, v := range c { + bytes += cap(v) + } + return +} + +// CCache is a Cache which is safe for concurrent use by multiple goroutines. +type CCache struct { + c Cache + mu sync.Mutex +} + +// Get returns a buffer ([]byte) of length n. If no such buffer is cached then +// a biggest cached buffer is resized to have length n and returned. If there +// are no cached items at all, Get returns a newly allocated buffer. +// +// In other words the cache policy is: +// +// - If the cache is empty, the buffer must be newly created and returned. +// Cache remains empty. +// +// - If a buffer of sufficient size is found in the cache, remove it from the +// cache and return it. +// +// - Otherwise the cache is non empty, but no cached buffer is big enough. +// Enlarge the biggest cached buffer, remove it from the cache and return it. +// This provide cached buffers size adjustment based on demand. +// +// In short, if the cache is not empty, Get guarantees to make it always one +// item less. This rules prevent uncontrolled cache grow in some scenarios. +// The older policy was not preventing that. Another advantage is better cached +// buffers sizes "auto tuning", although not in every possible use case. +// +// NOTE: The buffer returned by Get _is not guaranteed_ to be zeroed. That's +// okay for e.g. passing a buffer to io.Reader. If you need a zeroed buffer +// use Cget. +func (c *CCache) Get(n int) []byte { + c.mu.Lock() + r, _ := c.c.get(n) + c.mu.Unlock() + return r +} + +// Cget will acquire a buffer using Get and then clears it to zeros. The +// zeroing goes up to n, not cap(r). +func (c *CCache) Cget(n int) (r []byte) { + c.mu.Lock() + r = c.c.Cget(n) + c.mu.Unlock() + return +} + +// Put caches b for possible later reuse (via Get). No other references to b's +// backing array may exist. Otherwise a big mess is sooner or later inevitable. +func (c *CCache) Put(b []byte) { + c.mu.Lock() + c.c.Put(b) + c.mu.Unlock() +} + +// Stats reports memory consumed by a Cache, without accounting for some +// (smallish) additional overhead. 'n' is the number of cached buffers, bytes +// is their combined capacity. +func (c *CCache) Stats() (n, bytes int) { + c.mu.Lock() + n, bytes = c.c.Stats() + c.mu.Unlock() + return +} + +// GCache is a ready to use global instance of a CCache. +var GCache CCache + +func overCommit(n int) int { + switch { + case n < 8: + return 8 + case n < 1e5: + return 2 * n + case n < 1e6: + return 3 * n / 2 + default: + return n + } +} diff --git a/vendor/github.com/cznic/exp/lldb/2pc.go b/vendor/github.com/cznic/exp/lldb/2pc.go new file mode 100644 index 0000000000..887604def2 --- /dev/null +++ b/vendor/github.com/cznic/exp/lldb/2pc.go @@ -0,0 +1,324 @@ +// Copyright 2014 The lldb Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Two Phase Commit & Structural ACID + +package lldb + +import ( + "bufio" + "encoding/binary" + "fmt" + "io" + "os" + + "github.com/cznic/fileutil" + "github.com/cznic/mathutil" +) + +var _ Filer = &ACIDFiler0{} // Ensure ACIDFiler0 is a Filer + +type acidWrite struct { + b []byte + off int64 +} + +type acidWriter0 ACIDFiler0 + +func (a *acidWriter0) WriteAt(b []byte, off int64) (n int, err error) { + f := (*ACIDFiler0)(a) + if f.bwal == nil { // new epoch + f.data = f.data[:0] + f.bwal = bufio.NewWriter(f.wal) + if err = a.writePacket([]interface{}{wpt00Header, walTypeACIDFiler0, ""}); err != nil { + return + } + } + + if err = a.writePacket([]interface{}{wpt00WriteData, b, off}); err != nil { + return + } + + f.data = append(f.data, acidWrite{b, off}) + return len(b), nil +} + +func (a *acidWriter0) writePacket(items []interface{}) (err error) { + f := (*ACIDFiler0)(a) + b, err := EncodeScalars(items...) + if err != nil { + return + } + + var b4 [4]byte + binary.BigEndian.PutUint32(b4[:], uint32(len(b))) + if _, err = f.bwal.Write(b4[:]); err != nil { + return + } + + if _, err = f.bwal.Write(b); err != nil { + return + } + + if m := (4 + len(b)) % 16; m != 0 { + var pad [15]byte + _, err = f.bwal.Write(pad[:16-m]) + } + return +} + +// WAL Packet Tags +const ( + wpt00Header = iota + wpt00WriteData + wpt00Checkpoint +) + +const ( + walTypeACIDFiler0 = iota +) + +// ACIDFiler0 is a very simple, synchronous implementation of 2PC. It uses a +// single write ahead log file to provide the structural atomicity +// (BeginUpdate/EndUpdate/Rollback) and durability (DB can be recovered from +// WAL if a crash occurred). +// +// ACIDFiler0 is a Filer. +// +// NOTE: Durable synchronous 2PC involves three fsyncs in this implementation +// (WAL, DB, zero truncated WAL). Where possible, it's recommended to collect +// transactions for, say one second before performing the two phase commit as +// the typical performance for rotational hard disks is about few tens of +// fsyncs per second atmost. For an example of such collective transaction +// approach please see the colecting FSM STT in Dbm's documentation[1]. +// +// [1]: http://godoc.org/github.com/cznic/exp/dbm +type ACIDFiler0 struct { + *RollbackFiler + wal *os.File + bwal *bufio.Writer + data []acidWrite + testHook bool // keeps WAL untruncated (once) + peakWal int64 // tracks WAL maximum used size + peakBitFilerPages int // track maximum transaction memory +} + +// NewACIDFiler0 returns a newly created ACIDFiler0 with WAL in wal. +// +// If the WAL is zero sized then a previous clean shutdown of db is taken for +// granted and no recovery procedure is taken. +// +// If the WAL is of non zero size then it is checked for having a +// commited/fully finished transaction not yet been reflected in db. If such +// transaction exists it's committed to db. If the recovery process finishes +// successfully, the WAL is truncated to zero size and fsync'ed prior to return +// from NewACIDFiler0. +func NewACIDFiler(db Filer, wal *os.File) (r *ACIDFiler0, err error) { + fi, err := wal.Stat() + if err != nil { + return + } + + r = &ACIDFiler0{wal: wal} + + if fi.Size() != 0 { + if err = r.recoverDb(db); err != nil { + return + } + } + + acidWriter := (*acidWriter0)(r) + + if r.RollbackFiler, err = NewRollbackFiler( + db, + func(sz int64) (err error) { + // Checkpoint + if err = acidWriter.writePacket([]interface{}{wpt00Checkpoint, sz}); err != nil { + return + } + + if err = r.bwal.Flush(); err != nil { + return + } + + r.bwal = nil + + if err = r.wal.Sync(); err != nil { + return + } + + wfi, err := r.wal.Stat() + switch err != nil { + case true: + // unexpected, but ignored + case false: + r.peakWal = mathutil.MaxInt64(wfi.Size(), r.peakWal) + } + + // Phase 1 commit complete + + for _, v := range r.data { + if _, err := db.WriteAt(v.b, v.off); err != nil { + return err + } + } + + if err = db.Truncate(sz); err != nil { + return + } + + if err = db.Sync(); err != nil { + return + } + + // Phase 2 commit complete + + if !r.testHook { + if err = r.wal.Truncate(0); err != nil { + return + } + + if _, err = r.wal.Seek(0, 0); err != nil { + return + } + } + + r.testHook = false + return r.wal.Sync() + + }, + acidWriter, + ); err != nil { + return + } + + return r, nil +} + +// PeakWALSize reports the maximum size WAL has ever used. +func (a ACIDFiler0) PeakWALSize() int64 { + return a.peakWal +} + +func (a *ACIDFiler0) readPacket(f *bufio.Reader) (items []interface{}, err error) { + var b4 [4]byte + n, err := io.ReadAtLeast(f, b4[:], 4) + if n != 4 { + return + } + + ln := int(binary.BigEndian.Uint32(b4[:])) + m := (4 + ln) % 16 + padd := (16 - m) % 16 + b := make([]byte, ln+padd) + if n, err = io.ReadAtLeast(f, b, len(b)); n != len(b) { + return + } + + return DecodeScalars(b[:ln]) +} + +func (a *ACIDFiler0) recoverDb(db Filer) (err error) { + fi, err := a.wal.Stat() + if err != nil { + return &ErrILSEQ{Type: ErrInvalidWAL, Name: a.wal.Name(), More: err} + } + + if sz := fi.Size(); sz%16 != 0 { + return &ErrILSEQ{Type: ErrFileSize, Name: a.wal.Name(), Arg: sz} + } + + f := bufio.NewReader(a.wal) + items, err := a.readPacket(f) + if err != nil { + return + } + + if len(items) != 3 || items[0] != int64(wpt00Header) || items[1] != int64(walTypeACIDFiler0) { + return &ErrILSEQ{Type: ErrInvalidWAL, Name: a.wal.Name(), More: fmt.Sprintf("invalid packet items %#v", items)} + } + + tr := NewBTree(nil) + + for { + items, err = a.readPacket(f) + if err != nil { + return + } + + if len(items) < 2 { + return &ErrILSEQ{Type: ErrInvalidWAL, Name: a.wal.Name(), More: fmt.Sprintf("too few packet items %#v", items)} + } + + switch items[0] { + case int64(wpt00WriteData): + if len(items) != 3 { + return &ErrILSEQ{Type: ErrInvalidWAL, Name: a.wal.Name(), More: fmt.Sprintf("invalid data packet items %#v", items)} + } + + b, off := items[1].([]byte), items[2].(int64) + var key [8]byte + binary.BigEndian.PutUint64(key[:], uint64(off)) + if err = tr.Set(key[:], b); err != nil { + return + } + case int64(wpt00Checkpoint): + var b1 [1]byte + if n, err := f.Read(b1[:]); n != 0 || err == nil { + return &ErrILSEQ{Type: ErrInvalidWAL, Name: a.wal.Name(), More: fmt.Sprintf("checkpoint n %d, err %v", n, err)} + } + + if len(items) != 2 { + return &ErrILSEQ{Type: ErrInvalidWAL, Name: a.wal.Name(), More: fmt.Sprintf("checkpoint packet invalid items %#v", items)} + } + + sz := items[1].(int64) + enum, err := tr.seekFirst() + if err != nil { + return err + } + + for { + k, v, err := enum.current() + if err != nil { + if fileutil.IsEOF(err) { + break + } + + return err + } + + if _, err = db.WriteAt(v, int64(binary.BigEndian.Uint64(k))); err != nil { + return err + } + + if err = enum.next(); err != nil { + if fileutil.IsEOF(err) { + break + } + + return err + } + } + + if err = db.Truncate(sz); err != nil { + return err + } + + if err = db.Sync(); err != nil { + return err + } + + // Recovery complete + + if err = a.wal.Truncate(0); err != nil { + return err + } + + return a.wal.Sync() + default: + return &ErrILSEQ{Type: ErrInvalidWAL, Name: a.wal.Name(), More: fmt.Sprintf("packet tag %v", items[0])} + } + } +} diff --git a/vendor/github.com/cznic/exp/lldb/2pc_docs.go b/vendor/github.com/cznic/exp/lldb/2pc_docs.go new file mode 100644 index 0000000000..02c993b8ba --- /dev/null +++ b/vendor/github.com/cznic/exp/lldb/2pc_docs.go @@ -0,0 +1,44 @@ +// Copyright 2014 The lldb Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +/* + +Anatomy of a WAL file + +WAL file + A sequence of packets + +WAL packet, parts in slice notation + [0:4], 4 bytes: N uint32 // network byte order + [4:4+N], N bytes: payload []byte // gb encoded scalars + +Packets, including the 4 byte 'size' prefix, MUST BE padded to size == 0 (mod +16). The values of the padding bytes MUST BE zero. + +Encoded scalars first item is a packet type number (packet tag). The meaning of +any other item(s) of the payload depends on the packet tag. + +Packet definitions + + {wpt00Header int, typ int, s string} + typ: Must be zero (ACIDFiler0 file). + s: Any comment string, empty string is okay. + + This packet must be present only once - as the first packet of + a WAL file. + + {wpt00WriteData int, b []byte, off int64} + Write data (WriteAt(b, off)). + + {wpt00Checkpoint int, sz int64} + Checkpoint (Truncate(sz)). + + This packet must be present only once - as the last packet of + a WAL file. + +*/ + +package lldb + +//TODO optimize bitfiler/wal/2pc data above final size diff --git a/vendor/github.com/cznic/exp/lldb/LICENSE b/vendor/github.com/cznic/exp/lldb/LICENSE new file mode 100644 index 0000000000..27e4447a49 --- /dev/null +++ b/vendor/github.com/cznic/exp/lldb/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2014 The lldb 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 names of the authors nor the names of the +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. diff --git a/vendor/github.com/cznic/exp/lldb/btree.go b/vendor/github.com/cznic/exp/lldb/btree.go new file mode 100644 index 0000000000..57b0f39c62 --- /dev/null +++ b/vendor/github.com/cznic/exp/lldb/btree.go @@ -0,0 +1,2297 @@ +// Copyright 2014 The lldb 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 lldb + +import ( + "bytes" + "errors" + "fmt" + "io" + "sort" + "strings" + + "github.com/cznic/bufs" + "github.com/cznic/fileutil" + "github.com/cznic/sortutil" +) + +const ( + kData = 256 // [1, 512] + kIndex = 256 // [2, 2048] + kKV = 19 // Size of the key/value field in btreeDataPage + kSz = kKV - 1 - 7 // Content prefix size + kH = kKV - 7 // Content field offset for handle + tagBTreeDataPage = 1 + tagBTreeIndexPage = 0 +) + +// BTree is a B+tree[1][2], i.e. a variant which speeds up +// enumeration/iteration of the BTree. According to its origin it can be +// volatile (backed only by memory) or non-volatile (backed by a non-volatile +// Allocator). +// +// The specific implementation of BTrees in this package are B+trees with +// delayed split/concatenation (discussed in e.g. [3]). +// +// Note: No BTree methods returns io.EOF for physical Filer reads/writes. The +// io.EOF is returned only by bTreeEnumerator methods to indicate "no more K-V +// pair". +// +// [1]: http://en.wikipedia.org/wiki/B+tree +// [2]: http://zgking.com:8080/home/donghui/publications/books/dshandbook_BTree.pdf +// [3]: http://people.cs.aau.dk/~simas/aalg06/UbiquitBtree.pdf +type BTree struct { + store btreeStore + root btree + collate func(a, b []byte) int + serial uint64 +} + +// NewBTree returns a new, memory-only BTree. +func NewBTree(collate func(a, b []byte) int) *BTree { + store := newMemBTreeStore() + root, err := newBTree(store) + if err != nil { // should not happen + panic(err.Error()) + } + + return &BTree{store, root, collate, 0} +} + +// IsMem reports if t is a memory only BTree. +func (t *BTree) IsMem() (r bool) { + _, r = t.store.(*memBTreeStore) + return +} + +// Clear empties the tree. +func (t *BTree) Clear() (err error) { + if t == nil { + err = errors.New("BTree method invoked on nil receiver") + return + } + + t.serial++ + return t.root.clear(t.store) +} + +// Delete deletes key and its associated value from the tree. +func (t *BTree) Delete(key []byte) (err error) { + if t == nil { + err = errors.New("BTree method invoked on nil receiver") + return + } + + t.serial++ + _, err = t.root.extract(t.store, nil, t.collate, key) + return +} + +// DeleteAny deletes one key and its associated value from the tree. If the +// tree is empty on return then empty is true. +func (t *BTree) DeleteAny() (empty bool, err error) { + if t == nil { + err = errors.New("BTree method invoked on nil receiver") + return + } + + t.serial++ + return t.root.deleteAny(t.store) +} + +func elem(v interface{}) string { + switch x := v.(type) { + default: + panic("internal error") + case nil: + return "nil" + case bool: + if x { + return "true" + } + + return "false" + case int64: + return fmt.Sprint(x) + case uint64: + return fmt.Sprint(x) + case float64: + s := fmt.Sprintf("%g", x) + if !strings.Contains(s, ".") { + s += "." + } + return s + case complex128: + s := fmt.Sprint(x) + return s[1 : len(s)-1] + case []byte: + return fmt.Sprintf("[]byte{% 02x}", x) + case string: + return fmt.Sprintf("%q", x) + } +} + +// Dump outputs a human readable dump of t to w. It is usable iff t keys and +// values are encoded scalars (see EncodeScalars). Intended use is only for +// examples or debugging. Some type information is lost in the rendering, for +// example a float value '17.' and an integer value '17' may both output as +// '17'. +func (t *BTree) Dump(w io.Writer) (err error) { + enum, err := t.seekFirst() + if err != nil { + return + } + + for { + bkey, bval, err := enum.current() + if err != nil { + return err + } + + key, err := DecodeScalars(bkey) + if err != nil { + return err + } + + val, err := DecodeScalars(bval) + if err != nil { + return err + } + + kk := []string{} + if key == nil { + kk = []string{"null"} + } + for _, v := range key { + kk = append(kk, elem(v)) + } + vv := []string{} + if val == nil { + vv = []string{"null"} + } + for _, v := range val { + vv = append(vv, elem(v)) + } + skey := strings.Join(kk, ", ") + sval := strings.Join(vv, ", ") + if len(vv) > 1 { + sval = fmt.Sprintf("[]interface{%s}", sval) + } + if _, err = fmt.Fprintf(w, "%s → %s\n", skey, sval); err != nil { + return err + } + + err = enum.next() + if err != nil { + if fileutil.IsEOF(err) { + err = nil + break + } + + return err + } + } + return +} + +// Extract is a combination of Get and Delete. If the key exists in the tree, +// it is returned (like Get) and also deleted from a tree in a more efficient +// way which doesn't walk it twice. The returned slice may be a sub-slice of +// buf if buf was large enough to hold the entire content. Otherwise, a newly +// allocated slice will be returned. It is valid to pass a nil buf. +func (t *BTree) Extract(buf, key []byte) (value []byte, err error) { + if t == nil { + err = errors.New("BTree method invoked on nil receiver") + return + } + + t.serial++ + return t.root.extract(t.store, buf, t.collate, key) +} + +// First returns the first KV pair of the tree, if it exists. Otherwise key == nil +// and value == nil. +func (t *BTree) First() (key, value []byte, err error) { + if t == nil { + err = errors.New("BTree method invoked on nil receiver") + return + } + + var p btreeDataPage + if _, p, err = t.root.first(t.store); err != nil || p == nil { + return + } + + if key, err = p.key(t.store, 0); err != nil { + return + } + + value, err = p.value(t.store, 0) + return +} + +// Get returns the value associated with key, or nil if no such value exists. +// The returned slice may be a sub-slice of buf if buf was large enough to hold +// the entire content. Otherwise, a newly allocated slice will be returned. +// It is valid to pass a nil buf. +// +// Get is safe for concurrent access by multiple goroutines iff no other +// goroutine mutates the tree. +func (t *BTree) Get(buf, key []byte) (value []byte, err error) { + if t == nil { + err = errors.New("BTree method invoked on nil receiver") + return + } + + buffer := bufs.GCache.Get(maxBuf) + defer bufs.GCache.Put(buffer) + if buffer, err = t.root.get(t.store, buffer, t.collate, key); buffer == nil || err != nil { + return + } + + value = need(len(buffer), buf) + copy(value, buffer) + return +} + +// Handle reports t's handle. +func (t *BTree) Handle() int64 { + return int64(t.root) +} + +// Last returns the last KV pair of the tree, if it exists. Otherwise key == nil +// and value == nil. +func (t *BTree) Last() (key, value []byte, err error) { + if t == nil { + err = errors.New("BTree method invoked on nil receiver") + return + } + + var p btreeDataPage + if _, p, err = t.root.last(t.store); err != nil || p == nil { + return + } + + index := p.len() - 1 + if key, err = p.key(t.store, index); err != nil { + return + } + + value, err = p.value(t.store, index) + return +} + +// Put combines Get and Set in a more efficient way where the tree is walked +// only once. The upd(ater) receives the current (key, old-value), if that +// exists or (key, nil) otherwise. It can then return a (new-value, true, nil) +// to create or overwrite the existing value in the KV pair, or (whatever, +// false, nil) if it decides not to create or not to update the value of the KV +// pair. +// +// tree.Set(k, v) +// +// conceptually equals +// +// tree.Put(k, func(k, v []byte){ return v, true }([]byte, bool)) +// +// modulo the differing return values. +// +// The returned slice may be a sub-slice of buf if buf was large enough to hold +// the entire content. Otherwise, a newly allocated slice will be returned. +// It is valid to pass a nil buf. +func (t *BTree) Put(buf, key []byte, upd func(key, old []byte) (new []byte, write bool, err error)) (old []byte, written bool, err error) { + if t == nil { + err = errors.New("BTree method invoked on nil receiver") + return + } + + t.serial++ + return t.root.put2(buf, t.store, t.collate, key, upd) +} + +// Seek returns an Enumerator with "position" or an error of any. Normally the +// position is on a KV pair such that key >= KV.key. Then hit is key == KV.key. +// The position is possibly "after" the last KV pair, but that is not an error. +// +// Seek is safe for concurrent access by multiple goroutines iff no other +// goroutine mutates the tree. +func (t *BTree) Seek(key []byte) (enum *BTreeEnumerator, hit bool, err error) { + enum0, hit, err := t.seek(key) + if err != nil { + return + } + + enum = &BTreeEnumerator{ + enum: enum0, + firstHit: hit, + key: append([]byte(nil), key...), + } + return +} + +func (t *BTree) seek(key []byte) (enum *bTreeEnumerator, hit bool, err error) { + if t == nil { + err = errors.New("BTree method invoked on nil receiver") + return + } + + r := &bTreeEnumerator{t: t, collate: t.collate, serial: t.serial} + if r.p, r.index, hit, err = t.root.seek(t.store, r.collate, key); err != nil { + return + } + + enum = r + return +} + +// IndexSeek returns an Enumerator with "position" or an error of any. Normally +// the position is on a KV pair such that key >= KV.key. Then hit is key == +// KV.key. The position is possibly "after" the last KV pair, but that is not +// an error. The collate function originally passed to CreateBTree is used for +// enumerating the tree but a custom collate function c is used for IndexSeek. +// +// IndexSeek is safe for concurrent access by multiple goroutines iff no other +// goroutine mutates the tree. +func (t *BTree) IndexSeek(key []byte, c func(a, b []byte) int) (enum *BTreeEnumerator, hit bool, err error) { //TODO +test + enum0, hit, err := t.indexSeek(key, c) + if err != nil { + return + } + + enum = &BTreeEnumerator{ + enum: enum0, + firstHit: hit, + key: append([]byte(nil), key...), + } + return +} + +func (t *BTree) indexSeek(key []byte, c func(a, b []byte) int) (enum *bTreeEnumerator, hit bool, err error) { + if t == nil { + err = errors.New("BTree method invoked on nil receiver") + return + } + + r := &bTreeEnumerator{t: t, collate: t.collate, serial: t.serial} + if r.p, r.index, hit, err = t.root.seek(t.store, c, key); err != nil { + return + } + + enum = r + return +} + +// seekFirst returns an enumerator positioned on the first KV pair in the tree, +// if any. For an empty tree, err == io.EOF is returend. +// +// SeekFirst is safe for concurrent access by multiple goroutines iff no other +// goroutine mutates the tree. +func (t *BTree) SeekFirst() (enum *BTreeEnumerator, err error) { + enum0, err := t.seekFirst() + if err != nil { + return + } + + var key []byte + if key, _, err = enum0.current(); err != nil { + return + } + + enum = &BTreeEnumerator{ + enum: enum0, + firstHit: true, + key: append([]byte(nil), key...), + } + return +} + +func (t *BTree) seekFirst() (enum *bTreeEnumerator, err error) { + if t == nil { + err = errors.New("BTree method invoked on nil receiver") + return + } + + var p btreeDataPage + if _, p, err = t.root.first(t.store); err == nil && p == nil { + err = io.EOF + } + if err != nil { + return + } + + return &bTreeEnumerator{t: t, collate: t.collate, p: p, index: 0, serial: t.serial}, nil +} + +// seekLast returns an enumerator positioned on the last KV pair in the tree, +// if any. For an empty tree, err == io.EOF is returend. +// +// SeekLast is safe for concurrent access by multiple goroutines iff no other +// goroutine mutates the tree. +func (t *BTree) SeekLast() (enum *BTreeEnumerator, err error) { + enum0, err := t.seekLast() + if err != nil { + return + } + + var key []byte + if key, _, err = enum0.current(); err != nil { + return + } + + enum = &BTreeEnumerator{ + enum: enum0, + firstHit: true, + key: append([]byte(nil), key...), + } + return +} + +func (t *BTree) seekLast() (enum *bTreeEnumerator, err error) { + if t == nil { + err = errors.New("BTree method invoked on nil receiver") + return + } + + var p btreeDataPage + if _, p, err = t.root.last(t.store); err == nil && p == nil { + err = io.EOF + } + if err != nil { + return + } + + return &bTreeEnumerator{t: t, collate: t.collate, p: p, index: p.len() - 1, serial: t.serial}, nil +} + +// Set sets the value associated with key. Any previous value, if existed, is +// overwritten by the new one. +func (t *BTree) Set(key, value []byte) (err error) { + if t == nil { + err = errors.New("BTree method invoked on nil receiver") + return + } + + t.serial++ + dst := bufs.GCache.Get(maxBuf) + _, err = t.root.put(dst, t.store, t.collate, key, value, true) + bufs.GCache.Put(dst) + return +} + +// bTreeEnumerator is a closure of a BTree and a position. It is returned from +// BTree.seek. +// +// NOTE: bTreeEnumerator cannot be used after its BTree was mutated after the +// bTreeEnumerator was acquired from any of the seek, seekFirst, seekLast +// methods. +type bTreeEnumerator struct { + t *BTree + collate func(a, b []byte) int + p btreeDataPage + index int + serial uint64 +} + +// Current returns the KV pair the enumerator is currently positioned on. If +// the position is before the first KV pair in the tree or after the last KV +// pair in the tree then err == io.EOF is returned. +// +// If the enumerator has been invalidated by updating the tree, ErrINVAL is +// returned. +func (e *bTreeEnumerator) current() (key, value []byte, err error) { + if e == nil { + err = errors.New("bTreeEnumerator method invoked on nil receiver") + return + } + + if e.serial != e.t.serial { + err = &ErrINVAL{Src: "bTreeEnumerator invalidated by updating the tree"} + return + } + + if e.p == nil || e.index == e.p.len() { + return nil, nil, io.EOF + } + + if key, err = e.p.key(e.t.store, e.index); err != nil { + return + } + + value, err = e.p.value(e.t.store, e.index) + return +} + +// Next attempts to position the enumerator onto the next KV pair wrt the +// current position. If there is no "next" KV pair, io.EOF is returned. +// +// If the enumerator has been invalidated by updating the tree, ErrINVAL is +// returned. +func (e *bTreeEnumerator) next() (err error) { + if e == nil { + err = errors.New("bTreeEnumerator method invoked on nil receiver") + return + } + + if e.serial != e.t.serial { + err = &ErrINVAL{Src: "bTreeEnumerator invalidated by updating the tree"} + return + } + + if e.p == nil { + return io.EOF + } + + switch { + case e.index < e.p.len()-1: + e.index++ + default: + ph := e.p.next() + if ph == 0 { + err = io.EOF + break + } + + if e.p, err = e.t.store.Get(e.p, ph); err != nil { + e.p = nil + return + } + e.index = 0 + } + return +} + +// Prev attempts to position the enumerator onto the previous KV pair wrt the +// current position. If there is no "previous" KV pair, io.EOF is returned. +// +// If the enumerator has been invalidated by updating the tree, ErrINVAL is +// returned. +func (e *bTreeEnumerator) prev() (err error) { + if e == nil { + err = errors.New("bTreeEnumerator method invoked on nil receiver") + return + } + + if e.serial != e.t.serial { + err = &ErrINVAL{Src: "bTreeEnumerator invalidated by updating the tree"} + return + } + + if e.p == nil { + return io.EOF + } + + switch { + case e.index > 0: + e.index-- + default: + ph := e.p.prev() + if ph == 0 { + err = io.EOF + break + } + + if e.p, err = e.t.store.Get(e.p, ph); err != nil { + e.p = nil + return + } + e.index = e.p.len() - 1 + } + return +} + +// BTreeEnumerator captures the state of enumerating a tree. It is returned +// from the Seek* methods. The enumerator is aware of any mutations made to +// the tree in the process of enumerating it and automatically resumes the +// enumeration. +type BTreeEnumerator struct { + enum *bTreeEnumerator + err error + key []byte + firstHit bool +} + +// Next returns the currently enumerated KV pair, if it exists and moves to the +// next KV in the key collation order. If there is no KV pair to return, err == +// io.EOF is returned. +// +// Next is safe for concurrent access by multiple goroutines iff no other +// goroutine mutates the tree. +func (e *BTreeEnumerator) Next() (key, value []byte, err error) { + if err = e.err; err != nil { + return + } + + canRetry := true +retry: + if key, value, err = e.enum.current(); err != nil { + if _, ok := err.(*ErrINVAL); !ok || !canRetry { + e.err = err + return + } + + canRetry = false + var hit bool + if e.enum, hit, err = e.enum.t.seek(e.key); err != nil { + e.err = err + return + } + + if !e.firstHit && hit { + err = e.enum.next() + if err != nil { + e.err = err + return + } + } + + goto retry + } + + e.firstHit = false + e.key = append([]byte(nil), key...) + e.err = e.enum.next() + return +} + +// Prev returns the currently enumerated KV pair, if it exists and moves to the +// previous KV in the key collation order. If there is no KV pair to return, +// err == io.EOF is returned. +// +// Prev is safe for concurrent access by multiple goroutines iff no other +// goroutine mutates the tree. +func (e *BTreeEnumerator) Prev() (key, value []byte, err error) { + if err = e.err; err != nil { + return + } + + canRetry := true +retry: + if key, value, err = e.enum.current(); err != nil { + if _, ok := err.(*ErrINVAL); !ok || !canRetry { + e.err = err + return + } + + canRetry = false + var hit bool + if e.enum, hit, err = e.enum.t.seek(e.key); err != nil { + e.err = err + return + } + + if !e.firstHit && hit { + err = e.enum.prev() + if err != nil { + e.err = err + return + } + } + + goto retry + } + + e.firstHit = false + e.key = append([]byte(nil), key...) + e.err = e.enum.prev() + return +} + +// CreateBTree creates a new BTree in store. It returns the tree, its (freshly +// assigned) handle (for OpenBTree or RemoveBTree) or an error, if any. +func CreateBTree(store *Allocator, collate func(a, b []byte) int) (bt *BTree, handle int64, err error) { + r := &BTree{store: store, collate: collate} + if r.root, err = newBTree(store); err != nil { + return + } + + return r, int64(r.root), nil +} + +// OpenBTree opens a store's BTree using handle. It returns the tree or an +// error, if any. The same tree may be opened more than once, but operations on +// the separate instances should not ever overlap or void the other instances. +// However, the intended API usage is to open the same tree handle only once +// (handled by some upper layer "dispatcher"). +func OpenBTree(store *Allocator, collate func(a, b []byte) int, handle int64) (bt *BTree, err error) { + r := &BTree{store: store, root: btree(handle), collate: collate} + b := bufs.GCache.Get(7) + defer bufs.GCache.Put(b) + if b, err = store.Get(b, handle); err != nil { + return + } + + if len(b) != 7 { + return nil, &ErrILSEQ{Off: h2off(handle), More: "btree.go:671"} + } + + return r, nil +} + +// RemoveBTree removes tree, represented by handle from store. Empty trees are +// cheap, each uses only few bytes of the store. If there's a chance that a +// tree will eventually get reused (non empty again), it's recommended to +// not/never remove it. One advantage of such approach is a stable handle of +// such tree. +func RemoveBTree(store *Allocator, handle int64) (err error) { + tree, err := OpenBTree(store, nil, handle) + if err != nil { + return + } + + if err = tree.Clear(); err != nil { + return + } + + return store.Free(handle) +} + +type btreeStore interface { + Alloc(b []byte) (handle int64, err error) + Free(handle int64) (err error) + Get(dst []byte, handle int64) (b []byte, err error) + Realloc(handle int64, b []byte) (err error) +} + +// Read only zero bytes +var zeros [2 * kKV]byte + +func init() { + if kData < 1 || kData > 512 { + panic(fmt.Errorf("kData %d: out of limits", kData)) + } + + if kIndex < 2 || kIndex > 2048 { + panic(fmt.Errorf("kIndex %d: out of limits", kIndex)) + } + + if kKV < 8 || kKV > 23 { + panic(fmt.Errorf("kKV %d: out of limits", kKV)) + } + + if n := len(zeros); n < 15 { + panic(fmt.Errorf("not enough zeros: %d", n)) + } +} + +type memBTreeStore struct { + h int64 + m map[int64][]byte +} + +func newMemBTreeStore() *memBTreeStore { + return &memBTreeStore{h: 0, m: map[int64][]byte{}} +} + +func (s *memBTreeStore) String() string { + var a sortutil.Int64Slice + for k := range s.m { + a = append(a, k) + } + sort.Sort(a) + var sa []string + for _, k := range a { + sa = append(sa, fmt.Sprintf("%#x:|% x|", k, s.m[k])) + } + return strings.Join(sa, "\n") +} + +func (s *memBTreeStore) Alloc(b []byte) (handle int64, err error) { + s.h++ + handle = s.h + s.m[handle] = bpack(b) + return +} + +func (s *memBTreeStore) Free(handle int64) (err error) { + if _, ok := s.m[handle]; !ok { + return &ErrILSEQ{Type: ErrOther, Off: h2off(handle), More: "btree.go:754"} + } + + delete(s.m, handle) + return +} + +func (s *memBTreeStore) Get(dst []byte, handle int64) (b []byte, err error) { + r, ok := s.m[handle] + if !ok { + return nil, &ErrILSEQ{Type: ErrOther, Off: h2off(handle), More: "btree.go:764"} + } + + b = need(len(r), dst) + copy(b, r) + return +} + +func (s *memBTreeStore) Realloc(handle int64, b []byte) (err error) { + if _, ok := s.m[handle]; !ok { + return &ErrILSEQ{Type: ErrOther, Off: h2off(handle), More: "btree.go:774"} + } + + s.m[handle] = bpack(b) + return +} + +/* + +0...0 (1 bytes): +Flag + + 0 + +---+ + | 0 | + +---+ + +0 indicates an index page + +1...count*14-1 +"array" of items, 14 bytes each. Count of items in kIndex-1..2*kIndex+2 + + Count = (len(raw) - 8) / 14 + + 0..6 7..13 + +-------+----------+ + | Child | DataPage | + +-------+----------+ + + Child == handle of a child index page + DataPage == handle of a data page + +Offsets into the raw []byte: +Child[X] == 1+14*X +DataPage[X] == 8+14*X + +*/ +type btreeIndexPage []byte + +func newBTreeIndexPage(leftmostChild int64) (p btreeIndexPage) { + p = bufs.GCache.Get(1 + (kIndex+1)*2*7)[:8] + p[0] = tagBTreeIndexPage + h2b(p[1:], leftmostChild) + return +} + +func (p btreeIndexPage) len() int { + return (len(p) - 8) / 14 +} + +func (p btreeIndexPage) child(index int) int64 { + return b2h(p[1+14*index:]) +} + +func (p btreeIndexPage) setChild(index int, dp int64) { + h2b(p[1+14*index:], dp) +} + +func (p btreeIndexPage) dataPage(index int) int64 { + return b2h(p[8+14*index:]) +} + +func (p btreeIndexPage) setDataPage(index int, dp int64) { + h2b(p[8+14*index:], dp) +} + +func (q btreeIndexPage) insert(index int) btreeIndexPage { + switch len0 := q.len(); { + case index < len0: + has := len(q) + need := has + 14 + switch { + case cap(q) >= need: + q = q[:need] + default: + q = append(q, zeros[:14]...) + } + copy(q[8+14*(index+1):8+14*(index+1)+2*(len0-index)*7], q[8+14*index:]) + case index == len0: + has := len(q) + need := has + 14 + switch { + case cap(q) >= need: + q = q[:need] + default: + q = append(q, zeros[:14]...) + } + } + return q +} + +func (p btreeIndexPage) insert3(index int, dataPage, child int64) btreeIndexPage { + p = p.insert(index) + p.setDataPage(index, dataPage) + p.setChild(index+1, child) + return p +} + +func (p btreeIndexPage) cmp(a btreeStore, c func(a, b []byte) int, keyA []byte, keyBIndex int) (int, error) { + b := bufs.GCache.Get(maxBuf) + defer bufs.GCache.Put(b) + dp, err := a.Get(b, p.dataPage(keyBIndex)) + if err != nil { + return 0, err + } + + return btreeDataPage(dp).cmp(a, c, keyA, 0) +} + +func (q btreeIndexPage) setLen(n int) btreeIndexPage { + q = q[:cap(q)] + need := 8 + 14*n + if need < len(q) { + return q[:need] + } + return append(q, make([]byte, need-len(q))...) +} + +func (p btreeIndexPage) split(a btreeStore, root btree, ph *int64, parent int64, parentIndex int, index *int) (btreeIndexPage, error) { + right := newBTreeIndexPage(0) + canRecycle := true + defer func() { + if canRecycle { + bufs.GCache.Put(right) + } + }() + right = right.setLen(kIndex) + copy(right[1:1+(2*kIndex+1)*7], p[1+14*(kIndex+1):]) + p = p.setLen(kIndex) + if err := a.Realloc(*ph, p); err != nil { + return nil, err + } + + rh, err := a.Alloc(right) + if err != nil { + return nil, err + } + + if parentIndex >= 0 { + var pp btreeIndexPage = bufs.GCache.Get(maxBuf) + defer bufs.GCache.Put(pp) + if pp, err = a.Get(pp, parent); err != nil { + return nil, err + } + pp = pp.insert3(parentIndex, p.dataPage(kIndex), rh) + if err = a.Realloc(parent, pp); err != nil { + return nil, err + } + + } else { + nr := newBTreeIndexPage(*ph) + defer bufs.GCache.Put(nr) + nr = nr.insert3(0, p.dataPage(kIndex), rh) + nrh, err := a.Alloc(nr) + if err != nil { + return nil, err + } + + if err = a.Realloc(int64(root), h2b(make([]byte, 7), nrh)); err != nil { + return nil, err + } + } + if *index > kIndex { + p = right + canRecycle = false + *ph = rh + *index -= kIndex + 1 + } + return p, nil +} + +// p is dirty on return +func (p btreeIndexPage) extract(index int) btreeIndexPage { + n := p.len() - 1 + if index < n { + sz := (n-index)*14 + 7 + copy(p[1+14*index:1+14*index+sz], p[1+14*(index+1):]) + } + return p.setLen(n) +} + +// must persist all changes made +func (p btreeIndexPage) underflow(a btreeStore, root, iroot, parent int64, ph *int64, parentIndex int, index *int) (btreeIndexPage, error) { + lh, rh, err := checkSiblings(a, parent, parentIndex) + if err != nil { + return nil, err + } + + var left btreeIndexPage = bufs.GCache.Get(maxBuf) + defer bufs.GCache.Put(left) + + if lh != 0 { + if left, err = a.Get(left, lh); err != nil { + return nil, err + } + + if lc := btreeIndexPage(left).len(); lc > kIndex { + var pp = bufs.GCache.Get(maxBuf) + defer bufs.GCache.Put(pp) + if pp, err = a.Get(pp, parent); err != nil { + return nil, err + } + + pc := p.len() + p = p.setLen(pc + 1) + di, si, sz := 1+1*14, 1+0*14, (2*pc+1)*7 + copy(p[di:di+sz], p[si:]) + p.setChild(0, btreeIndexPage(left).child(lc)) + p.setDataPage(0, btreeIndexPage(pp).dataPage(parentIndex-1)) + *index++ + btreeIndexPage(pp).setDataPage(parentIndex-1, btreeIndexPage(left).dataPage(lc-1)) + left = left.setLen(lc - 1) + if err = a.Realloc(parent, pp); err != nil { + return nil, err + } + + if err = a.Realloc(*ph, p); err != nil { + return nil, err + } + + return p, a.Realloc(lh, left) + } + } + + if rh != 0 { + right := bufs.GCache.Get(maxBuf) + defer bufs.GCache.Put(right) + if right, err = a.Get(right, rh); err != nil { + return nil, err + } + + if rc := btreeIndexPage(right).len(); rc > kIndex { + pp := bufs.GCache.Get(maxBuf) + defer bufs.GCache.Put(pp) + if pp, err = a.Get(pp, parent); err != nil { + return nil, err + } + + pc := p.len() + p = p.setLen(pc + 1) + p.setDataPage(pc, btreeIndexPage(pp).dataPage(parentIndex)) + pc++ + p.setChild(pc, btreeIndexPage(right).child(0)) + btreeIndexPage(pp).setDataPage(parentIndex, btreeIndexPage(right).dataPage(0)) + di, si, sz := 1+0*14, 1+1*14, (2*rc+1)*7 + copy(right[di:di+sz], right[si:]) + right = btreeIndexPage(right).setLen(rc - 1) + if err = a.Realloc(parent, pp); err != nil { + return nil, err + } + + if err = a.Realloc(*ph, p); err != nil { + return nil, err + } + + return p, a.Realloc(rh, right) + } + } + + if lh != 0 { + *index += left.len() + 1 + if left, err = left.concat(a, root, iroot, parent, lh, *ph, parentIndex-1); err != nil { + return p, err + } + + p, *ph = left, lh + return p, nil + } + + return p.concat(a, root, iroot, parent, *ph, rh, parentIndex) +} + +// must persist all changes made +func (p btreeIndexPage) concat(a btreeStore, root, iroot, parent, ph, rh int64, parentIndex int) (btreeIndexPage, error) { + pp := bufs.GCache.Get(maxBuf) + defer bufs.GCache.Put(pp) + pp, err := a.Get(pp, parent) + if err != nil { + return nil, err + } + + right := bufs.GCache.Get(maxBuf) + defer bufs.GCache.Put(right) + if right, err = a.Get(right, rh); err != nil { + return nil, err + } + + pc := p.len() + rc := btreeIndexPage(right).len() + p = p.setLen(pc + rc + 1) + p.setDataPage(pc, btreeIndexPage(pp).dataPage(parentIndex)) + di, si, sz := 1+14*(pc+1), 1+0*14, (2*rc+1)*7 + copy(p[di:di+sz], right[si:]) + if err := a.Realloc(ph, p); err != nil { + return nil, err + } + + if err := a.Free(rh); err != nil { + return nil, err + } + + if pc := btreeIndexPage(pp).len(); pc > 1 { + if parentIndex < pc-1 { + di, si, sz := 8+parentIndex*14, 8+(parentIndex+1)*14, 2*(pc-1-parentIndex)*7 + copy(pp[di:si+sz], pp[si:]) + } + pp = btreeIndexPage(pp).setLen(pc - 1) + return p, a.Realloc(parent, pp) + } + + if err := a.Free(iroot); err != nil { + return nil, err + } + + b7 := bufs.GCache.Get(7) + defer bufs.GCache.Put(b7) + return p, a.Realloc(root, h2b(b7[:7], ph)) +} + +/* + +0...0 (1 bytes): +Flag + + 0 + +---+ + | 1 | + +---+ + +1 indicates a data page + +1...14 (14 bytes) + + 1..7 8..14 + +------+------+ + | Prev | Next | + +------+------+ + + Prev, Next == Handles of the data pages doubly linked list + + Count = (len(raw) - 15) / (2*kKV) + +15...count*2*kKV-1 +"array" of items, 2*kKV bytes each. Count of items in kData-1..2*kData + +Item + 0..kKV-1 kKV..2*kKV-1 + +----------+--------------+ + | Key | Value | + +----------+--------------+ + +Key/Value encoding + +Length 0...kKV-1 + + 0 1...N N+1...kKV-1 + +---+---------+-------------+ + | N | Data | Padding | + +---+---------+-------------+ + + N == content length + Data == Key or Value content + Padding == MUST be zero bytes + +Length >= kKV + + 0 1...kkV-8 kKV-7...kkV-1 + +------+-----------+--------------+ + | 0xFF | Data | H | + +------+-----------+--------------+ + + Data == Key or Value content, first kKV-7 bytes + H == Handle to THE REST of the content, w/o the first bytes in Data. + +Offsets into the raw []byte: +Key[X] == 15+2*kKV*X +Value[X] == 15+kKV+2*kKV*X +*/ +type btreeDataPage []byte + +func newBTreeDataPage() (p btreeDataPage) { + p = bufs.GCache.Cget(1 + 2*7 + (kData+1)*2*kKV)[:1+2*7] + p[0] = tagBTreeDataPage + return +} + +func newBTreeDataPageAlloc(a btreeStore) (p btreeDataPage, h int64, err error) { + p = newBTreeDataPage() + h, err = a.Alloc(p) + return +} + +func (p btreeDataPage) len() int { + return (len(p) - 15) / (2 * kKV) +} + +func (q btreeDataPage) setLen(n int) btreeDataPage { + q = q[:cap(q)] + need := 15 + 2*kKV*n + if need < len(q) { + return q[:need] + } + return append(q, make([]byte, need-len(q))...) +} + +func (p btreeDataPage) prev() int64 { + return b2h(p[1:]) +} + +func (p btreeDataPage) next() int64 { + return b2h(p[8:]) +} + +func (p btreeDataPage) setPrev(h int64) { + h2b(p[1:], h) +} + +func (p btreeDataPage) setNext(h int64) { + h2b(p[8:], h) +} + +func (q btreeDataPage) insert(index int) btreeDataPage { + switch len0 := q.len(); { + case index < len0: + has := len(q) + need := has + 2*kKV + switch { + case cap(q) >= need: + q = q[:need] + default: + q = append(q, zeros[:2*kKV]...) + } + q.copy(q, index+1, index, len0-index) + return q + case index == len0: + has := len(q) + need := has + 2*kKV + switch { + case cap(q) >= need: + return q[:need] + default: + return append(q, zeros[:2*kKV]...) + } + } + panic("internal error") +} + +func (p btreeDataPage) contentField(off int) (b []byte, h int64) { + p = p[off:] + switch n := int(p[0]); { + case n >= kKV: // content has a handle + b = append([]byte(nil), p[1:1+kSz]...) + h = b2h(p[kH:]) + default: // content is embedded + b, h = append([]byte(nil), p[1:1+n]...), 0 + } + return +} + +func (p btreeDataPage) content(a btreeStore, off int) (b []byte, err error) { + b, h := p.contentField(off) + if h == 0 { + return + } + + // content has a handle + b2, err := a.Get(nil, h) //TODO buffers: Later, not a public API + if err != nil { + return nil, err + } + + return append(b, b2...), nil +} + +func (p btreeDataPage) setContent(a btreeStore, off int, b []byte) (err error) { + p = p[off:] + switch { + case p[0] >= kKV: // existing content has a handle + switch n := len(b); { + case n < kKV: + p[0] = byte(n) + if err = a.Free(b2h(p[kH:])); err != nil { + return + } + copy(p[1:], b) + default: + // reuse handle + copy(p[1:1+kSz], b) + return a.Realloc(b2h(p[kH:]), b[kSz:]) + } + default: // existing content is embedded + switch n := len(b); { + case n < kKV: + p[0] = byte(n) + copy(p[1:], b) + default: + p[0] = 0xff + copy(p[1:1+kSz], b) + h, err := a.Alloc(b[kSz:]) + if err != nil { + return err + } + + h2b(p[kH:], h) + } + } + return +} + +func (p btreeDataPage) keyField(index int) (b []byte, h int64) { + return p.contentField(15 + 2*kKV*index) +} + +func (p btreeDataPage) key(a btreeStore, index int) (b []byte, err error) { + return p.content(a, 15+2*kKV*index) +} + +func (p btreeDataPage) valueField(index int) (b []byte, h int64) { + return p.contentField(15 + kKV + 2*kKV*index) +} + +func (p btreeDataPage) value(a btreeStore, index int) (b []byte, err error) { + return p.content(a, 15+kKV+2*kKV*index) +} + +func (p btreeDataPage) valueCopy(a btreeStore, index int) (b []byte, err error) { + if b, err = p.content(a, 15+kKV+2*kKV*index); err != nil { + return + } + + return append([]byte(nil), b...), nil +} + +func (p btreeDataPage) setKey(a btreeStore, index int, key []byte) (err error) { + return p.setContent(a, 15+2*kKV*index, key) +} + +func (p btreeDataPage) setValue(a btreeStore, index int, value []byte) (err error) { + return p.setContent(a, 15+kKV+2*kKV*index, value) +} + +func (p btreeDataPage) cmp(a btreeStore, c func(a, b []byte) int, keyA []byte, keyBIndex int) (y int, err error) { + var keyB []byte + if keyB, err = p.content(a, 15+2*kKV*keyBIndex); err != nil { + return + } + + return c(keyA, keyB), nil +} + +func (p btreeDataPage) copy(src btreeDataPage, di, si, n int) { + do, so := 15+2*kKV*di, 15+2*kKV*si + copy(p[do:do+2*kKV*n], src[so:]) +} + +// {p,left} dirty on exit +func (p btreeDataPage) moveLeft(left btreeDataPage, n int) (btreeDataPage, btreeDataPage) { + nl, np := left.len(), p.len() + left = left.setLen(nl + n) + left.copy(p, nl, 0, n) + p.copy(p, 0, n, np-n) + return p.setLen(np - n), left +} + +func (p btreeDataPage) moveRight(right btreeDataPage, n int) (btreeDataPage, btreeDataPage) { + nr, np := right.len(), p.len() + right = right.setLen(nr + n) + right.copy(right, n, 0, nr) + right.copy(p, 0, np-n, n) + return p.setLen(np - n), right +} + +func (p btreeDataPage) insertItem(a btreeStore, index int, key, value []byte) (btreeDataPage, error) { + p = p.insert(index) + di, sz := 15+2*kKV*index, 2*kKV + copy(p[di:di+sz], zeros[:sz]) + if err := p.setKey(a, index, key); err != nil { + return nil, err + } + return p, p.setValue(a, index, value) +} + +func (p btreeDataPage) split(a btreeStore, root, ph, parent int64, parentIndex, index int, key, value []byte) (btreeDataPage, error) { + right, rh, err := newBTreeDataPageAlloc(a) + // fails defer bufs.GCache.Put(right) + if err != nil { + return nil, err + } + + if next := p.next(); next != 0 { + right.setNext(p.next()) + nxh := right.next() + nx := bufs.GCache.Get(maxBuf) + defer bufs.GCache.Put(nx) + if nx, err = a.Get(nx, nxh); err != nil { + return nil, err + } + + btreeDataPage(nx).setPrev(rh) + if err = a.Realloc(nxh, nx); err != nil { + return nil, err + } + } + + p.setNext(rh) + right.setPrev(ph) + right = right.setLen(kData) + right.copy(p, 0, kData, kData) + p = p.setLen(kData) + + if parentIndex >= 0 { + var pp btreeIndexPage = bufs.GCache.Get(maxBuf) + defer bufs.GCache.Put(pp) + if pp, err = a.Get(pp, parent); err != nil { + return nil, err + } + + pp = pp.insert3(parentIndex, rh, rh) + if err = a.Realloc(parent, pp); err != nil { + return nil, err + } + + } else { + nr := newBTreeIndexPage(ph) + defer bufs.GCache.Put(nr) + nr = nr.insert3(0, rh, rh) + nrh, err := a.Alloc(nr) + if err != nil { + return nil, err + } + + if err = a.Realloc(root, h2b(make([]byte, 7), nrh)); err != nil { + return nil, err + } + + } + if index > kData { + if right, err = right.insertItem(a, index-kData, key, value); err != nil { + return nil, err + } + } else { + if p, err = p.insertItem(a, index, key, value); err != nil { + return nil, err + } + } + if err = a.Realloc(ph, p); err != nil { + return nil, err + } + + return p, a.Realloc(rh, right) +} + +func (p btreeDataPage) overflow(a btreeStore, root, ph, parent int64, parentIndex, index int, key, value []byte) (btreeDataPage, error) { + leftH, rightH, err := checkSiblings(a, parent, parentIndex) + if err != nil { + return nil, err + } + + if leftH != 0 { + left := btreeDataPage(bufs.GCache.Get(maxBuf)) + defer bufs.GCache.Put(left) + if left, err = a.Get(left, leftH); err != nil { + return nil, err + } + + if left.len() < 2*kData { + + p, left = p.moveLeft(left, 1) + if err = a.Realloc(leftH, left); err != nil { + return nil, err + } + + if p, err = p.insertItem(a, index-1, key, value); err != nil { + return nil, err + } + + return p, a.Realloc(ph, p) + } + } + + if rightH != 0 { + right := btreeDataPage(bufs.GCache.Get(maxBuf)) + defer bufs.GCache.Put(right) + if right, err = a.Get(right, rightH); err != nil { + return nil, err + } + + if right.len() < 2*kData { + if index < 2*kData { + p, right = p.moveRight(right, 1) + if err = a.Realloc(rightH, right); err != nil { + return nil, err + } + + if p, err = p.insertItem(a, index, key, value); err != nil { + return nil, err + } + + return p, a.Realloc(ph, p) + } else { + if right, err = right.insertItem(a, 0, key, value); err != nil { + return nil, err + } + + return p, a.Realloc(rightH, right) + } + } + } + return p.split(a, root, ph, parent, parentIndex, index, key, value) +} + +func (p btreeDataPage) swap(a btreeStore, di int, value []byte, canOverwrite bool) (oldValue []byte, err error) { + if oldValue, err = p.value(a, di); err != nil { + return + } + + if !canOverwrite { + return + } + + oldValue = append([]byte(nil), oldValue...) + err = p.setValue(a, di, value) + return +} + +type btreePage []byte + +func (p btreePage) isIndex() bool { + return p[0] == tagBTreeIndexPage +} + +func (p btreePage) len() int { + if p.isIndex() { + return btreeIndexPage(p).len() + } + + return btreeDataPage(p).len() +} + +func (p btreePage) find(a btreeStore, c func(a, b []byte) int, key []byte) (index int, ok bool, err error) { + l := 0 + h := p.len() - 1 + isIndex := p.isIndex() + if c == nil { + c = bytes.Compare + } + for l <= h { + index = (l + h) >> 1 + var cmp int + if isIndex { + if cmp, err = btreeIndexPage(p).cmp(a, c, key, index); err != nil { + return + } + } else { + if cmp, err = btreeDataPage(p).cmp(a, c, key, index); err != nil { + return + } + } + switch ok = cmp == 0; { + case cmp > 0: + l = index + 1 + case ok: + return + default: + h = index - 1 + } + } + return l, false, nil +} + +// p is dirty after extract! +func (p btreeDataPage) extract(a btreeStore, index int) (btreeDataPage, []byte, error) { + value, err := p.valueCopy(a, index) + if err != nil { + return nil, nil, err + } + + if _, h := p.keyField(index); h != 0 { + if err = a.Free(h); err != nil { + return nil, nil, err + } + } + + if _, h := p.valueField(index); h != 0 { + if err = a.Free(h); err != nil { + return nil, nil, err + } + } + + n := p.len() - 1 + if index < n { + p.copy(p, index, index+1, n-index) + } + return p.setLen(n), value, nil +} + +func checkSiblings(a btreeStore, parent int64, parentIndex int) (left, right int64, err error) { + if parentIndex >= 0 { + var p btreeIndexPage = bufs.GCache.Get(maxBuf) + defer bufs.GCache.Put(p) + if p, err = a.Get(p, parent); err != nil { + return + } + + if parentIndex > 0 { + left = p.child(parentIndex - 1) + } + if parentIndex < p.len() { + right = p.child(parentIndex + 1) + } + } + return +} + +// underflow must persist all changes made. +func (p btreeDataPage) underflow(a btreeStore, root, iroot, parent, ph int64, parentIndex int) (err error) { + lh, rh, err := checkSiblings(a, parent, parentIndex) + if err != nil { + return err + } + + if lh != 0 { + left := bufs.GCache.Get(maxBuf) + defer bufs.GCache.Put(left) + if left, err = a.Get(left, lh); err != nil { + return err + } + + if btreeDataPage(left).len()+p.len() >= 2*kData { + left, p = btreeDataPage(left).moveRight(p, 1) + if err = a.Realloc(lh, left); err != nil { + return err + } + + return a.Realloc(ph, p) + } + } + + if rh != 0 { + right := bufs.GCache.Get(maxBuf) + defer bufs.GCache.Put(right) + if right, err = a.Get(right, rh); err != nil { + return err + } + + if p.len()+btreeDataPage(right).len() > 2*kData { + right, p = btreeDataPage(right).moveLeft(p, 1) + if err = a.Realloc(rh, right); err != nil { + return err + } + + return a.Realloc(ph, p) + } + } + + if lh != 0 { + left := bufs.GCache.Get(maxBuf) + defer bufs.GCache.Put(left) + if left, err = a.Get(left, lh); err != nil { + return err + } + + if err = a.Realloc(ph, p); err != nil { + return err + } + + return btreeDataPage(left).concat(a, root, iroot, parent, lh, ph, parentIndex-1) + } + + return p.concat(a, root, iroot, parent, ph, rh, parentIndex) +} + +// concat must persist all changes made. +func (p btreeDataPage) concat(a btreeStore, root, iroot, parent, ph, rh int64, parentIndex int) (err error) { + right := bufs.GCache.Get(maxBuf) + defer bufs.GCache.Put(right) + if right, err = a.Get(right, rh); err != nil { + return err + } + + right, p = btreeDataPage(right).moveLeft(p, btreeDataPage(right).len()) + nxh := btreeDataPage(right).next() + if nxh != 0 { + nx := bufs.GCache.Get(maxBuf) + defer bufs.GCache.Put(nx) + if nx, err = a.Get(nx, nxh); err != nil { + return err + } + + btreeDataPage(nx).setPrev(ph) + if err = a.Realloc(nxh, nx); err != nil { + return err + } + } + p.setNext(nxh) + if err = a.Free(rh); err != nil { + return err + } + + pp := bufs.GCache.Get(maxBuf) + defer bufs.GCache.Put(pp) + if pp, err = a.Get(pp, parent); err != nil { + return err + } + + if btreeIndexPage(pp).len() > 1 { + pp = btreeIndexPage(pp).extract(parentIndex) + btreeIndexPage(pp).setChild(parentIndex, ph) + if err = a.Realloc(parent, pp); err != nil { + return err + } + + return a.Realloc(ph, p) + } + + if err = a.Free(iroot); err != nil { + return err + } + + if err = a.Realloc(ph, p); err != nil { + return err + } + + var b7 [7]byte + return a.Realloc(root, h2b(b7[:], ph)) +} + +// external "root" is stable and contains the real root. +type btree int64 + +func newBTree(a btreeStore) (btree, error) { + r, err := a.Alloc(zeros[:7]) + return btree(r), err +} + +func (root btree) String(a btreeStore) string { + r := bufs.GCache.Get(16) + defer bufs.GCache.Put(r) + r, err := a.Get(r, int64(root)) + if err != nil { + panic(err) + } + + iroot := b2h(r) + m := map[int64]bool{int64(root): true} + + s := []string{fmt.Sprintf("tree %#x -> %#x\n====", root, iroot)} + if iroot == 0 { + return s[0] + } + + var f func(int64, string) + f = func(h int64, ind string) { + if m[h] { + return + } + + m[h] = true + var b btreePage = bufs.GCache.Get(maxBuf) + defer bufs.GCache.Put(b) + var err error + if b, err = a.Get(b, h); err != nil { + panic(err) + } + + s = append(s, fmt.Sprintf("%s@%#x", ind, h)) + switch b.isIndex() { + case true: + da := []int64{} + b := btreeIndexPage(b) + for i := 0; i < b.len(); i++ { + c, d := b.child(i), b.dataPage(i) + s = append(s, fmt.Sprintf("%schild[%d] %#x dataPage[%d] %#x", ind, i, c, i, d)) + da = append(da, c) + da = append(da, d) + } + i := b.len() + c := b.child(i) + s = append(s, fmt.Sprintf("%schild[%d] %#x", ind, i, c)) + for _, c := range da { + f(c, ind+" ") + } + f(c, ind+" ") + case false: + b := btreeDataPage(b) + s = append(s, fmt.Sprintf("%sprev %#x next %#x", ind, b.prev(), b.next())) + for i := 0; i < b.len(); i++ { + k, err := b.key(a, i) + if err != nil { + panic(err) + } + + v, err := b.value(a, i) + if err != nil { + panic(err) + } + + s = append(s, fmt.Sprintf("%sK[%d]|% x| V[%d]|% x|", ind, i, k, i, v)) + } + } + } + + f(int64(iroot), "") + return strings.Join(s, "\n") +} + +func (root btree) put(dst []byte, a btreeStore, c func(a, b []byte) int, key, value []byte, canOverwrite bool) (prev []byte, err error) { + prev, _, err = root.put2(dst, a, c, key, func(key, old []byte) (new []byte, write bool, err error) { + new, write = value, true + return + }) + return +} + +func (root btree) put2(dst []byte, a btreeStore, c func(a, b []byte) int, key []byte, upd func(key, old []byte) (new []byte, write bool, err error)) (old []byte, written bool, err error) { + var r, value []byte + if r, err = a.Get(dst, int64(root)); err != nil { + return + } + + iroot := b2h(r) + var h int64 + if iroot == 0 { + p := newBTreeDataPage() + defer bufs.GCache.Put(p) + if value, written, err = upd(key, nil); err != nil || !written { + return + } + + if p, err = p.insertItem(a, 0, key, value); err != nil { + return + } + + h, err = a.Alloc(p) + if err != nil { + return nil, true, err + } + + err = a.Realloc(int64(root), h2b(r, h)[:7]) + return + } + + parentIndex := -1 + var parent int64 + ph := iroot + + p := bufs.GCache.Get(maxBuf) + defer bufs.GCache.Put(p) + + for { + if p, err = a.Get(p[:cap(p)], ph); err != nil { + return + } + + var index int + var ok bool + + if index, ok, err = btreePage(p).find(a, c, key); err != nil { + return + } + + switch { + case ok: // Key found + if btreePage(p).isIndex() { + ph = btreeIndexPage(p).dataPage(index) + if p, err = a.Get(p, ph); err != nil { + return + } + + if old, err = btreeDataPage(p).valueCopy(a, 0); err != nil { + return + } + + if value, written, err = upd(key, old); err != nil || !written { + return + } + + if _, err = btreeDataPage(p).swap(a, 0, value, true); err != nil { + return + } + + err = a.Realloc(ph, p) + return + } + + if old, err = btreeDataPage(p).valueCopy(a, index); err != nil { + return + } + + if value, written, err = upd(key, old); err != nil || !written { + return + } + + if _, err = btreeDataPage(p).swap(a, index, value, true); err != nil { + return + } + + err = a.Realloc(ph, p) + return + case btreePage(p).isIndex(): + if btreePage(p).len() > 2*kIndex { + if p, err = btreeIndexPage(p).split(a, root, &ph, parent, parentIndex, &index); err != nil { + return + } + } + parentIndex = index + parent = ph + ph = btreeIndexPage(p).child(index) + default: + if value, written, err = upd(key, nil); err != nil || !written { + return + } + + if btreePage(p).len() < 2*kData { // page is not full + if p, err = btreeDataPage(p).insertItem(a, index, key, value); err != nil { + return + } + + err = a.Realloc(ph, p) + return + } + + // page is full + p, err = btreeDataPage(p).overflow(a, int64(root), ph, parent, parentIndex, index, key, value) + return + } + } +} + +//TODO actually use 'dst' to return 'value' +func (root btree) get(a btreeStore, dst []byte, c func(a, b []byte) int, key []byte) (b []byte, err error) { + var r []byte + if r, err = a.Get(dst, int64(root)); err != nil { + return + } + + iroot := b2h(r) + if iroot == 0 { + return + } + + ph := iroot + + for { + var p btreePage + if p, err = a.Get(p, ph); err != nil { + return + } + + var index int + var ok bool + if index, ok, err = p.find(a, c, key); err != nil { + return + } + + switch { + case ok: + if p.isIndex() { + dh := btreeIndexPage(p).dataPage(index) + dp, err := a.Get(dst, dh) + if err != nil { + return nil, err + } + + return btreeDataPage(dp).value(a, 0) + } + + return btreeDataPage(p).value(a, index) + case p.isIndex(): + ph = btreeIndexPage(p).child(index) + default: + return + } + } +} + +//TODO actually use 'dst' to return 'value' +func (root btree) extract(a btreeStore, dst []byte, c func(a, b []byte) int, key []byte) (value []byte, err error) { + var r []byte + if r, err = a.Get(dst, int64(root)); err != nil { + return + } + + iroot := b2h(r) + if iroot == 0 { + return + } + + ph := iroot + parentIndex := -1 + var parent int64 + + p := bufs.GCache.Get(maxBuf) + defer bufs.GCache.Put(p) + + for { + if p, err = a.Get(p[:cap(p)], ph); err != nil { + return + } + + var index int + var ok bool + if index, ok, err = btreePage(p).find(a, c, key); err != nil { + return + } + + if ok { + if btreePage(p).isIndex() { + dph := btreeIndexPage(p).dataPage(index) + dp, err := a.Get(dst, dph) + if err != nil { + return nil, err + } + + if btreeDataPage(dp).len() > kData { + if dp, value, err = btreeDataPage(dp).extract(a, 0); err != nil { + return nil, err + } + + return value, a.Realloc(dph, dp) + } + + if btreeIndexPage(p).len() < kIndex && ph != iroot { + var err error + if p, err = btreeIndexPage(p).underflow(a, int64(root), iroot, parent, &ph, parentIndex, &index); err != nil { + return nil, err + } + } + parentIndex = index + 1 + parent = ph + ph = btreeIndexPage(p).child(parentIndex) + continue + } + + p, value, err = btreeDataPage(p).extract(a, index) + if btreePage(p).len() >= kData { + err = a.Realloc(ph, p) + return + } + + if ph != iroot { + err = btreeDataPage(p).underflow(a, int64(root), iroot, parent, ph, parentIndex) + return + } + + if btreePage(p).len() == 0 { + if err = a.Free(ph); err != nil { + return + } + + err = a.Realloc(int64(root), zeros[:7]) + return + } + err = a.Realloc(ph, p) + return + } + + if !btreePage(p).isIndex() { + return + } + + if btreePage(p).len() < kIndex && ph != iroot { + if p, err = btreeIndexPage(p).underflow(a, int64(root), iroot, parent, &ph, parentIndex, &index); err != nil { + return nil, err + } + } + parentIndex = index + parent = ph + ph = btreeIndexPage(p).child(index) + } +} + +func (root btree) deleteAny(a btreeStore) (bool, error) { + r := bufs.GCache.Get(7) + defer bufs.GCache.Put(r) + var err error + if r, err = a.Get(r, int64(root)); err != nil { + return false, err + } + + iroot := b2h(r) + if iroot == 0 { + return true, nil + } + + ph := iroot + parentIndex := -1 + var parent int64 + p := bufs.GCache.Get(maxBuf) + defer bufs.GCache.Put(p) + + for { + if p, err = a.Get(p, ph); err != nil { + return false, err + } + + index := btreePage(p).len() / 2 + if btreePage(p).isIndex() { + dph := btreeIndexPage(p).dataPage(index) + dp := bufs.GCache.Get(maxBuf) + defer bufs.GCache.Put(dp) + if dp, err = a.Get(dp, dph); err != nil { + return false, err + } + + if btreeDataPage(dp).len() > kData { + if dp, _, err = btreeDataPage(dp).extract(a, 0); err != nil { + return false, err + } + + return false, a.Realloc(dph, dp) + } + + if btreeIndexPage(p).len() < kIndex && ph != iroot { + if p, err = btreeIndexPage(p).underflow(a, int64(root), iroot, parent, &ph, parentIndex, &index); err != nil { + return false, err + } + } + parentIndex = index + 1 + parent = ph + ph = btreeIndexPage(p).child(parentIndex) + continue + } + + p, _, err = btreeDataPage(p).extract(a, index) + if btreePage(p).len() >= kData { + err = a.Realloc(ph, p) + return false, err + } + + if ph != iroot { + err = btreeDataPage(p).underflow(a, int64(root), iroot, parent, ph, parentIndex) + return false, err + } + + if btreePage(p).len() == 0 { + if err = a.Free(ph); err != nil { + return true, err + } + + return true, a.Realloc(int64(root), zeros[:7]) + } + + return false, a.Realloc(ph, p) + } +} + +func (root btree) first(a btreeStore) (ph int64, p btreeDataPage, err error) { + r := bufs.GCache.Get(7) + defer bufs.GCache.Put(r) + if r, err = a.Get(r, int64(root)); err != nil { + return + } + + for ph = b2h(r); ph != 0; ph = btreeIndexPage(p).child(0) { + if p, err = a.Get(p, ph); err != nil { + return + } + + if !btreePage(p).isIndex() { + break + } + } + + return +} + +func (root btree) last(a btreeStore) (ph int64, p btreeDataPage, err error) { + r := bufs.GCache.Get(7) + defer bufs.GCache.Put(r) + if r, err = a.Get(r, int64(root)); err != nil { + return + } + + for ph = b2h(r); ph != 0; ph = btreeIndexPage(p).child(btreeIndexPage(p).len()) { + if p, err = a.Get(p, ph); err != nil { + return + } + + if !btreePage(p).isIndex() { + break + } + } + + return +} + +// key >= p[index].key +func (root btree) seek(a btreeStore, c func(a, b []byte) int, key []byte) (p btreeDataPage, index int, equal bool, err error) { + r := bufs.GCache.Get(7) + defer bufs.GCache.Put(r) + if r, err = a.Get(r, int64(root)); err != nil { + return + } + + for ph := b2h(r); ph != 0; ph = btreeIndexPage(p).child(index) { + if p, err = a.Get(p, ph); err != nil { + break + } + + if index, equal, err = btreePage(p).find(a, c, key); err != nil { + break + } + + if equal { + if !btreePage(p).isIndex() { + break + } + + p, err = a.Get(p, btreeIndexPage(p).dataPage(index)) + index = 0 + break + } + + if !btreePage(p).isIndex() { + break + } + } + return +} + +func (root btree) clear(a btreeStore) (err error) { + r := bufs.GCache.Get(7) + defer bufs.GCache.Put(r) + if r, err = a.Get(r, int64(root)); err != nil { + return + } + + iroot := b2h(r) + if iroot == 0 { + return + } + + if err = root.clear2(a, iroot); err != nil { + return + } + + var b [7]byte + return a.Realloc(int64(root), b[:]) +} + +func (root btree) clear2(a btreeStore, ph int64) (err error) { + var p = bufs.GCache.Get(maxBuf) + defer bufs.GCache.Put(p) + if p, err = a.Get(p, ph); err != nil { + return + } + + switch btreePage(p).isIndex() { + case true: + ip := btreeIndexPage(p) + for i := 0; i <= ip.len(); i++ { + root.clear2(a, ip.child(i)) + + } + case false: + dp := btreeDataPage(p) + for i := 0; i < dp.len(); i++ { + if err = dp.setKey(a, i, nil); err != nil { + return + } + + if err = dp.setValue(a, i, nil); err != nil { + return + } + } + } + return a.Free(ph) +} diff --git a/vendor/github.com/cznic/exp/lldb/errors.go b/vendor/github.com/cznic/exp/lldb/errors.go new file mode 100644 index 0000000000..7dffe7f10c --- /dev/null +++ b/vendor/github.com/cznic/exp/lldb/errors.go @@ -0,0 +1,170 @@ +// Copyright 2014 The lldb Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Some errors returned by this package. +// +// Note that this package can return more errors than declared here, for +// example io.EOF from Filer.ReadAt(). + +package lldb + +import ( + "fmt" +) + +// ErrDecodeScalars is possibly returned from DecodeScalars +type ErrDecodeScalars struct { + B []byte // Data being decoded + I int // offending offset +} + +// Error implements the built in error type. +func (e *ErrDecodeScalars) Error() string { + return fmt.Sprintf("DecodeScalars: corrupted data @ %d/%d", e.I, len(e.B)) +} + +// ErrINVAL reports invalid values passed as parameters, for example negative +// offsets where only non-negative ones are allowed or read from the DB. +type ErrINVAL struct { + Src string + Val interface{} +} + +// Error implements the built in error type. +func (e *ErrINVAL) Error() string { + return fmt.Sprintf("%s: %+v", e.Src, e.Val) +} + +// ErrPERM is for example reported when a Filer is closed while BeginUpdate(s) +// are not balanced with EndUpdate(s)/Rollback(s) or when EndUpdate or Rollback +// is invoked which is not paired with a BeginUpdate. +type ErrPERM struct { + Src string +} + +// Error implements the built in error type. +func (e *ErrPERM) Error() string { + return fmt.Sprintf("%s: Operation not permitted", string(e.Src)) +} + +// ErrTag represents an ErrILSEQ kind. +type ErrType int + +// ErrILSEQ types +const ( + ErrOther ErrType = iota + + ErrAdjacentFree // Adjacent free blocks (.Off and .Arg) + ErrDecompress // Used compressed block: corrupted compression + ErrExpFreeTag // Expected a free block tag, got .Arg + ErrExpUsedTag // Expected a used block tag, got .Arg + ErrFLT // Free block is invalid or referenced multiple times + ErrFLTLoad // FLT truncated to .Off, need size >= .Arg + ErrFLTSize // Free block size (.Arg) doesn't belong to its list min size: .Arg2 + ErrFileSize // File .Name size (.Arg) != 0 (mod 16) + ErrFreeChaining // Free block, .prev.next doesn't point back to this block + ErrFreeTailBlock // Last block is free + ErrHead // Head of a free block list has non zero Prev (.Arg) + ErrInvalidRelocTarget // Reloc doesn't target (.Arg) a short or long used block + ErrInvalidWAL // Corrupted write ahead log. .Name: file name, .More: more + ErrLongFreeBlkTooLong // Long free block spans beyond EOF, size .Arg + ErrLongFreeBlkTooShort // Long free block must have at least 2 atoms, got only .Arg + ErrLongFreeNextBeyondEOF // Long free block .Next (.Arg) spans beyond EOF + ErrLongFreePrevBeyondEOF // Long free block .Prev (.Arg) spans beyond EOF + ErrLongFreeTailTag // Expected a long free block tail tag, got .Arg + ErrLostFreeBlock // Free block is not in any FLT list + ErrNullReloc // Used reloc block with nil target + ErrRelocBeyondEOF // Used reloc points (.Arg) beyond EOF + ErrShortFreeTailTag // Expected a short free block tail tag, got .Arg + ErrSmall // Request for a free block (.Arg) returned a too small one (.Arg2) at .Off + ErrTailTag // Block at .Off has invalid tail CC (compression code) tag, got .Arg + ErrUnexpReloc // Unexpected reloc block referred to from reloc block .Arg + ErrVerifyPadding // Used block has nonzero padding + ErrVerifyTailSize // Long free block size .Arg but tail size .Arg2 + ErrVerifyUsedSpan // Used block size (.Arg) spans beyond EOF +) + +// ErrILSEQ reports a corrupted file format. Details in fields according to Type. +type ErrILSEQ struct { + Type ErrType + Off int64 + Arg int64 + Arg2 int64 + Arg3 int64 + Name string + More interface{} +} + +// Error implements the built in error type. +func (e *ErrILSEQ) Error() string { + switch e.Type { + case ErrAdjacentFree: + return fmt.Sprintf("Adjacent free blocks at offset %#x and %#x", e.Off, e.Arg) + case ErrDecompress: + return fmt.Sprintf("Compressed block at offset %#x: Corrupted compressed content", e.Off) + case ErrExpFreeTag: + return fmt.Sprintf("Block at offset %#x: Expected a free block tag, got %#2x", e.Off, e.Arg) + case ErrExpUsedTag: + return fmt.Sprintf("Block at ofset %#x: Expected a used block tag, got %#2x", e.Off, e.Arg) + case ErrFLT: + return fmt.Sprintf("Free block at offset %#x is invalid or referenced multiple times", e.Off) + case ErrFLTLoad: + return fmt.Sprintf("FLT truncated to size %d, expected at least %d", e.Off, e.Arg) + case ErrFLTSize: + return fmt.Sprintf("Free block at offset %#x has size (%#x) should be at least (%#x)", e.Off, e.Arg, e.Arg2) + case ErrFileSize: + return fmt.Sprintf("File %q size (%#x) != 0 (mod 16)", e.Name, e.Arg) + case ErrFreeChaining: + return fmt.Sprintf("Free block at offset %#x: .prev.next doesn point back here.", e.Off) + case ErrFreeTailBlock: + return fmt.Sprintf("Free block at offset %#x: Cannot be last file block", e.Off) + case ErrHead: + return fmt.Sprintf("Block at offset %#x: Head of free block list has non zero .prev %#x", e.Off, e.Arg) + case ErrInvalidRelocTarget: + return fmt.Sprintf("Used reloc block at offset %#x: Target (%#x) is not a short or long used block", e.Off, e.Arg) + case ErrInvalidWAL: + return fmt.Sprintf("Corrupted write ahead log file: %q %v", e.Name, e.More) + case ErrLongFreeBlkTooLong: + return fmt.Sprintf("Long free block at offset %#x: Size (%#x) beyond EOF", e.Off, e.Arg) + case ErrLongFreeBlkTooShort: + return fmt.Sprintf("Long free block at offset %#x: Size (%#x) too small", e.Off, e.Arg) + case ErrLongFreeNextBeyondEOF: + return fmt.Sprintf("Long free block at offset %#x: Next (%#x) points beyond EOF", e.Off, e.Arg) + case ErrLongFreePrevBeyondEOF: + return fmt.Sprintf("Long free block at offset %#x: Prev (%#x) points beyond EOF", e.Off, e.Arg) + case ErrLongFreeTailTag: + return fmt.Sprintf("Block at offset %#x: Expected long free tail tag, got %#2x", e.Off, e.Arg) + case ErrLostFreeBlock: + return fmt.Sprintf("Free block at offset %#x: not in any FLT list", e.Off) + case ErrNullReloc: + return fmt.Sprintf("Used reloc block at offset %#x: Nil target", e.Off) + case ErrRelocBeyondEOF: + return fmt.Sprintf("Used reloc block at offset %#x: Link (%#x) points beyond EOF", e.Off, e.Arg) + case ErrShortFreeTailTag: + return fmt.Sprintf("Block at offset %#x: Expected short free tail tag, got %#2x", e.Off, e.Arg) + case ErrSmall: + return fmt.Sprintf("Request for of free block of size %d returned a too small (%d) one at offset %#x", e.Arg, e.Arg2, e.Off) + case ErrTailTag: + return fmt.Sprintf("Block at offset %#x: Invalid tail CC tag, got %#2x", e.Off, e.Arg) + case ErrUnexpReloc: + return fmt.Sprintf("Block at offset %#x: Unexpected reloc block. Referred to from reloc block at offset %#x", e.Off, e.Arg) + case ErrVerifyPadding: + return fmt.Sprintf("Used block at offset %#x: Nonzero padding", e.Off) + case ErrVerifyTailSize: + return fmt.Sprintf("Long free block at offset %#x: Size %#x, but tail size %#x", e.Off, e.Arg, e.Arg2) + case ErrVerifyUsedSpan: + return fmt.Sprintf("Used block at offset %#x: Size %#x spans beyond EOF", e.Off, e.Arg) + } + + more := "" + if e.More != nil { + more = fmt.Sprintf(", %v", e.More) + } + off := "" + if e.Off != 0 { + off = fmt.Sprintf(", off: %#x", e.Off) + } + + return fmt.Sprintf("Error%s%s", off, more) +} diff --git a/vendor/github.com/cznic/exp/lldb/falloc.go b/vendor/github.com/cznic/exp/lldb/falloc.go new file mode 100644 index 0000000000..2969036e24 --- /dev/null +++ b/vendor/github.com/cznic/exp/lldb/falloc.go @@ -0,0 +1,1981 @@ +// Copyright 2014 The lldb Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// The storage space management. + +package lldb + +import ( + "bytes" + "errors" + "fmt" + "io" + "sort" + "strings" + "sync" + + "github.com/cznic/bufs" + "github.com/cznic/mathutil" + "github.com/cznic/zappy" +) + +const ( + maxBuf = maxRq + 20 // bufs,Buffers.Alloc +) + +// Options are passed to the NewAllocator to amend some configuration. The +// compatibility promise is the same as of struct types in the Go standard +// library - introducing changes can be made only by adding new exported +// fields, which is backward compatible as long as client code uses field names +// to assign values of imported struct types literals. +// +// NOTE: No options are currently defined. +type Options struct{} + +// AllocStats record statistics about a Filer. It can be optionally filled by +// Allocator.Verify, if successful. +type AllocStats struct { + Handles int64 // total valid handles in use + Compression int64 // number of compressed blocks + TotalAtoms int64 // total number of atoms == AllocAtoms + FreeAtoms + AllocBytes int64 // bytes allocated (after decompression, if/where used) + AllocAtoms int64 // atoms allocated/used, including relocation atoms + Relocations int64 // number of relocated used blocks + FreeAtoms int64 // atoms unused + AllocMap map[int64]int64 // allocated block size in atoms -> count of such blocks + FreeMap map[int64]int64 // free block size in atoms -> count of such blocks +} + +/* + +Allocator implements "raw" storage space management (allocation and +deallocation) for a low level of a DB engine. The storage is an abstraction +provided by a Filer. + +The terms MUST or MUST NOT, if/where used in the documentation of Allocator, +written in all caps as seen here, are a requirement for any possible +alternative implementations aiming for compatibility with this one. + +Filer file + +A Filer file, or simply 'file', is a linear, contiguous sequence of blocks. +Blocks may be either free (currently unused) or allocated (currently used). +Some blocks may eventually become virtual in a sense as they may not be +realized in the storage (sparse files). + +Free Lists Table + +File starts with a FLT. This table records heads of 14 doubly linked free +lists. The zero based index (I) vs minimal size of free blocks in that list, +except the last one which registers free blocks of size 4112+ atoms: + + MinSize == 2^I + + For example 0 -> 1, 1 -> 2, ... 12 -> 4096. + +Each entry in the FLT is 8 bytes in netwtork order, MSB MUST be zero, ie. the +slot value is effectively only 7 bytes. The value is the handle of the head of +the respective doubly linked free list. The FLT size is 14*8 == 112(0x70) +bytes. If the free blocks list for any particular size is empty, the respective +FLT slot is zero. Sizes of free blocks in one list MUST NOT overlap with sizes +of free lists in other list. For example, even though a free block of size 2 +technically is of minimal size >= 1, it MUST NOT be put to the list for slot 0 +(minimal size 1), but in slot 1( minimal size 2). + + slot 0: sizes [1, 2) + slot 1: sizes [2, 4) + slot 2: sizes [4, 8) + ... + slot 11: sizes [2048, 4096) + slot 12: sizes [4096, 4112) + slot 13: sizes [4112, inf) + +The last FLT slot collects all free blocks bigger than its minimal size. That +still respects the 'no overlap' invariant. + +File blocks + +A block is a linear, contiguous sequence of atoms. The first and last atoms of +a block provide information about, for example, whether the block is free or +used, what is the size of the block, etc. Details are discussed elsewhere. The +first block of a file starts immediately after FLT, ie. at file offset +112(0x70). + +Block atoms + +An atom is a fixed size piece of a block (and thus of a file too); it is 16 +bytes long. A consequence is that for a valid file: + + filesize == 0 (mod 16) + +The first atom of the first block is considered to be atom #1. + +Block handles + +A handle is an integer referring to a block. The reference is the number of the +atom the block starts with. Put in other way: + + handle == offset/16 - 6 + offset == 16 * (handle + 6) + +`offset` is the offset of the first byte of the block, measured in bytes +- as in fseek(3). Handle has type `int64`, but only the lower 7 bytes may be +nonzero while referring to a block, both in code as well as when persisted in +the the file's internal bookkeeping structures - see 'Block types' bellow. So a +handle is effectively only `uint56`. This also means that the maximum usable +size of a file is 2^56 atoms. That is 2^60 bytes == 1 exabyte (10^18 bytes). + +Nil handles + +A handle with numeric value of '0' refers to no block. + +Zero padding + +A padding is used to round-up a block size to be a whole number of atoms. Any +padding, if present, MUST be all zero bytes. Note that the size of padding is +in [0, 15]. + +Content wiping + +When a block is deallocated, its data content is not wiped as the added +overhead may be substantial while not necessarily needed. Client code should +however overwrite the content of any block having sensitive data with eg. zeros +(good compression) - before deallocating the block. + +Block tags + +Every block is tagged in its first byte (a head tag) and last byte (tail tag). +Block types are: + + 1. Short content used block (head tags 0x00-0xFB) + 2. Long content used block (head tag 0xFC) + 3. Relocated used block (head tag 0xFD) + 4. Short, single atom, free block (head tag 0xFE) + 5. Long free block (head tag 0xFF) + +Note: Relocated used block, 3. above (head tag 0xFD) MUST NOT refer to blocks +other then 1. or 2. above (head tags 0x00-0xFC). + +Content blocks + +Used blocks (head tags 0x00-0xFC) tail tag distinguish used/unused block and if +content is compressed or not. + +Content compression + +The tail flag of an used block is one of + + CC == 0 // Content is not compressed. + CC == 1 // Content is in zappy compression format. + +If compression of written content is enabled, there are two cases: If +compressed size < original size then the compressed content should be written +if it will save at least one atom of the block. If compressed size >= original +size then the compressed content should not be used. + +It's recommended to use compression. For example the BTrees implementation +assumes compression is used. Using compression may cause a slowdown in some +cases while it may as well cause a speedup. + +Short content block + +Short content block carries content of length between N == 0(0x00) and N == +251(0xFB) bytes. + + |<-first atom start ... last atom end->| + +---++-- ... --+-- ... --++------+ + | 0 || 1... | 0x*...0x*E || 0x*F | + +---++-- ... --+-- ... --++------+ + | N || content | padding || CC | + +---++-- ... --+-- ... --++------+ + + A == (N+1)/16 + 1 // The number of atoms in the block [1, 16] + padding == 15 - (N+1)%16 // Length of the zero padding + +Long content block + +Long content block carries content of length between N == 252(0xFC) and N == +65787(0x100FB) bytes. + + |<-first atom start ... last atom end->| + +------++------+-- ... --+-- ... --++------+ + | 0 || 1..2 | 3... | 0x*...0x*E || 0x*F | + +------++------+-- ... --+-- ... --++------+ + | 0xFC || M | content | padding || CC | + +------++------+-- ... --+-- ... --++------+ + + A == (N+3)/16 + 1 // The number of atoms in the block [16, 4112] + M == N % 0x10000 // Stored as 2 bytes in network byte order + padding == 15 - (N+3)%16 // Length of the zero padding + +Relocated used block + +Relocated block allows to permanently assign a handle to some content and +resize the content anytime afterwards without having to update all the possible +existing references; the handle can be constant while the content size may be +dynamic. When relocating a block, any space left by the original block content, +above this single atom block, MUST be reclaimed. + +Relocations MUST point only to a used short or long block == blocks with tags +0x00...0xFC. + + +------++------+---------++----+ + | 0 || 1..7 | 8...14 || 15 | + +------++------+---------++----+ + | 0xFD || H | padding || 0 | + +------++------+---------++----+ + +H is the handle of the relocated block in network byte order. + +Free blocks + +Free blocks are the result of space deallocation. Free blocks are organized in +one or more doubly linked lists, abstracted by the FLT interface. Free blocks +MUST be "registered" by putting them in such list. Allocator MUST reuse a big +enough free block, if such exists, before growing the file size. When a free +block is created by deallocation or reallocation it MUST be joined with any +adjacently existing free blocks before "registering". If the resulting free +block is now a last block of a file, the free block MUST be discarded and the +file size MUST be truncated accordingly instead. Put differently, there MUST +NOT ever be a free block at the file end. + +A single free atom + +Is an unused block of size 1 atom. + + +------++------+--------++------+ + | 0 || 1..7 | 8...14 || 15 | + +------++------+--------++------+ + | 0xFE || P | N || 0xFE | + +------++------+--------++------+ + +P and N, stored in network byte order, are the previous and next free block +handles in the doubly linked list to which this free block belongs. + +A long unused block + +Is an unused block of size > 1 atom. + + +------++------+-------+---------+- ... -+----------++------+ + | 0 || 1..7 | 8..14 | 15...21 | | Z-7..Z-1 || Z | + +------++------+-------+---------+- ... -+----------++------+ + | 0xFF || S | P | N | Leak | S || 0xFF | + +------++------+-------+---------+- ... -+----------++------+ + + Z == 16 * S - 1 + +S is the size of this unused block in atoms. P and N are the previous and next +free block handles in the doubly linked list to which this free block belongs. +Leak contains any data the block had before deallocating this block. See also +the subtitle 'Content wiping' above. S, P and N are stored in network byte +order. Large free blocks may trigger a consideration of file hole punching of +the Leak field - for some value of 'large'. + +Note: Allocator methods vs CRUD[1]: + + Alloc [C]reate + Get [R]ead + Realloc [U]pdate + Free [D]elete + +Note: No Allocator method returns io.EOF. + + [1]: http://en.wikipedia.org/wiki/Create,_read,_update_and_delete + +*/ +type Allocator struct { + f Filer + flt flt + Compress bool // enables content compression + cache cache + m map[int64]*node + lru lst + expHit int64 + expMiss int64 + cacheSz int + hit uint16 + miss uint16 + mu sync.Mutex +} + +// NewAllocator returns a new Allocator. To open an existing file, pass its +// Filer. To create a "new" file, pass a Filer which file is of zero size. +func NewAllocator(f Filer, opts *Options) (a *Allocator, err error) { + if opts == nil { // Enforce *Options is always passed + return nil, errors.New("NewAllocator: nil opts passed") + } + + a = &Allocator{ + f: f, + cacheSz: 10, + } + + a.cinit() + switch x := f.(type) { + case *RollbackFiler: + x.afterRollback = func() error { + a.cinit() + return a.flt.load(a.f, 0) + } + case *ACIDFiler0: + x.RollbackFiler.afterRollback = func() error { + a.cinit() + return a.flt.load(a.f, 0) + } + } + + sz, err := f.Size() + if err != nil { + return + } + + a.flt.init() + if sz == 0 { + var b [fltSz]byte + if err = a.f.BeginUpdate(); err != nil { + return + } + + if _, err = f.WriteAt(b[:], 0); err != nil { + a.f.Rollback() + return + } + + return a, a.f.EndUpdate() + } + + return a, a.flt.load(f, 0) +} + +// CacheStats reports cache statistics. +// +//TODO return a struct perhaps. +func (a *Allocator) CacheStats() (buffersUsed, buffersTotal int, bytesUsed, bytesTotal, hits, misses int64) { + buffersUsed = len(a.m) + buffersTotal = buffersUsed + len(a.cache) + bytesUsed = a.lru.size() + bytesTotal = bytesUsed + a.cache.size() + hits = a.expHit + misses = a.expMiss + return +} + +func (a *Allocator) cinit() { + for h, n := range a.m { + a.cache.put(a.lru.remove(n)) + delete(a.m, h) + } + if a.m == nil { + a.m = map[int64]*node{} + } +} + +func (a *Allocator) cadd(b []byte, h int64) { + if len(a.m) < a.cacheSz { + n := a.cache.get(len(b)) + n.h = h + copy(n.b, b) + a.m[h] = a.lru.pushFront(n) + return + } + + // cache full + delete(a.m, a.cache.put(a.lru.removeBack()).h) + n := a.cache.get(len(b)) + n.h = h + copy(n.b, b) + a.m[h] = a.lru.pushFront(n) + return +} + +func (a *Allocator) cfree(h int64) { + n, ok := a.m[h] + if !ok { // must have been evicted + return + } + + a.cache.put(a.lru.remove(n)) + delete(a.m, h) +} + +// Alloc allocates storage space for b and returns the handle of the new block +// with content set to b or an error, if any. The returned handle is valid only +// while the block is used - until the block is deallocated. No two valid +// handles share the same value within the same Filer, but any value of a +// handle not referring to any used block may become valid any time as a result +// of Alloc. +// +// Invoking Alloc on an empty Allocator is guaranteed to return handle with +// value 1. The intended use of content of handle 1 is a root "directory" of +// other data held by an Allocator. +// +// Passing handles not obtained initially from Alloc or not anymore valid to +// any other Allocator methods can result in an irreparably corrupted database. +func (a *Allocator) Alloc(b []byte) (handle int64, err error) { + buf := bufs.GCache.Get(zappy.MaxEncodedLen(len(b))) + defer bufs.GCache.Put(buf) + buf, _, cc, err := a.makeUsedBlock(buf, b) + if err != nil { + return + } + + if handle, err = a.alloc(buf, cc); err == nil { + a.cadd(b, handle) + } + return +} + +func (a *Allocator) alloc(b []byte, cc byte) (h int64, err error) { + rqAtoms := n2atoms(len(b)) + if h = a.flt.find(rqAtoms); h == 0 { // must grow + var sz int64 + if sz, err = a.f.Size(); err != nil { + return + } + + h = off2h(sz) + err = a.writeUsedBlock(h, cc, b) + return + } + + // Handle is the first item of a free blocks list. + tag, s, prev, next, err := a.nfo(h) + if err != nil { + return + } + + if tag != tagFreeShort && tag != tagFreeLong { + err = &ErrILSEQ{Type: ErrExpFreeTag, Off: h2off(h), Arg: int64(tag)} + return + } + + if prev != 0 { + err = &ErrILSEQ{Type: ErrHead, Off: h2off(h), Arg: prev} + return + } + + if s < int64(rqAtoms) { + err = &ErrILSEQ{Type: ErrSmall, Arg: int64(rqAtoms), Arg2: s, Off: h2off(h)} + return + } + + if err = a.unlink(h, s, prev, next); err != nil { + return + } + + if s > int64(rqAtoms) { + freeH := h + int64(rqAtoms) + freeAtoms := s - int64(rqAtoms) + if err = a.link(freeH, freeAtoms); err != nil { + return + } + } + return h, a.writeUsedBlock(h, cc, b) +} + +// Free deallocates the block referred to by handle or returns an error, if +// any. +// +// After Free succeeds, handle is invalid and must not be used. +// +// Handle must have been obtained initially from Alloc and must be still valid, +// otherwise a database may get irreparably corrupted. +func (a *Allocator) Free(handle int64) (err error) { + if handle <= 0 || handle > maxHandle { + return &ErrINVAL{"Allocator.Free: handle out of limits", handle} + } + + a.cfree(handle) + return a.free(handle, 0, true) +} + +func (a *Allocator) free(h, from int64, acceptRelocs bool) (err error) { + tag, atoms, _, n, err := a.nfo(h) + if err != nil { + return + } + + switch tag { + default: + // nop + case tagUsedLong: + // nop + case tagUsedRelocated: + if !acceptRelocs { + return &ErrILSEQ{Type: ErrUnexpReloc, Off: h2off(h), Arg: h2off(from)} + } + + if err = a.free(n, h, false); err != nil { + return + } + case tagFreeShort, tagFreeLong: + return &ErrINVAL{"Allocator.Free: attempt to free a free block at off", h2off(h)} + } + + return a.free2(h, atoms) +} + +func (a *Allocator) free2(h, atoms int64) (err error) { + sz, err := a.f.Size() + if err != nil { + return + } + + ltag, latoms, lp, ln, err := a.leftNfo(h) + if err != nil { + return + } + + if ltag != tagFreeShort && ltag != tagFreeLong { + latoms = 0 + } + + var rtag byte + var ratoms, rp, rn int64 + + isTail := h2off(h)+atoms*16 == sz + if !isTail { + if rtag, ratoms, rp, rn, err = a.nfo(h + atoms); err != nil { + return + } + } + + if rtag != tagFreeShort && rtag != tagFreeLong { + ratoms = 0 + } + + switch { + case latoms == 0 && ratoms == 0: + // -> isolated <- + if isTail { // cut tail + return a.f.Truncate(h2off(h)) + } + + return a.link(h, atoms) + case latoms == 0 && ratoms != 0: + // right join -> + if err = a.unlink(h+atoms, ratoms, rp, rn); err != nil { + return + } + + return a.link(h, atoms+ratoms) + case latoms != 0 && ratoms == 0: + // <- left join + if err = a.unlink(h-latoms, latoms, lp, ln); err != nil { + return + } + + if isTail { + return a.f.Truncate(h2off(h - latoms)) + } + + return a.link(h-latoms, latoms+atoms) + } + + // case latoms != 0 && ratoms != 0: + // <- middle join -> + lh, rh := h-latoms, h+atoms + if err = a.unlink(lh, latoms, lp, ln); err != nil { + return + } + + // Prev unlink may have invalidated rp or rn + if _, _, rp, rn, err = a.nfo(rh); err != nil { + return + } + + if err = a.unlink(rh, ratoms, rp, rn); err != nil { + return + } + + return a.link(h-latoms, latoms+atoms+ratoms) +} + +// Add a free block h to the appropriate free list +func (a *Allocator) link(h, atoms int64) (err error) { + if err = a.makeFree(h, atoms, 0, a.flt.head(atoms)); err != nil { + return + } + + return a.flt.setHead(h, atoms, a.f) +} + +// Remove free block h from the free list +func (a *Allocator) unlink(h, atoms, p, n int64) (err error) { + switch { + case p == 0 && n == 0: + // single item list, must be head + return a.flt.setHead(0, atoms, a.f) + case p == 0 && n != 0: + // head of list (has next item[s]) + if err = a.prev(n, 0); err != nil { + return + } + + // new head + return a.flt.setHead(n, atoms, a.f) + case p != 0 && n == 0: + // last item in list + return a.next(p, 0) + } + // case p != 0 && n != 0: + // intermediate item in a list + if err = a.next(p, n); err != nil { + return + } + + return a.prev(n, p) +} + +//TODO remove ? +// Return len(slice) == n, reuse src if possible. +func need(n int, src []byte) []byte { + if cap(src) < n { + bufs.GCache.Put(src) + return bufs.GCache.Get(n) + } + + return src[:n] +} + +// Get returns the data content of a block referred to by handle or an error if +// any. The returned slice may be a sub-slice of buf if buf was large enough +// to hold the entire content. Otherwise, a newly allocated slice will be +// returned. It is valid to pass a nil buf. +// +// If the content was stored using compression then it is transparently +// returned decompressed. +// +// Handle must have been obtained initially from Alloc and must be still valid, +// otherwise invalid data may be returned without detecting the error. +// +// Get is safe for concurrent access by multiple goroutines iff no other +// goroutine mutates the DB. +func (a *Allocator) Get(buf []byte, handle int64) (b []byte, err error) { + buf = buf[:cap(buf)] + a.mu.Lock() // X1+ + if n, ok := a.m[handle]; ok { + a.lru.moveToFront(n) + b = need(len(n.b), buf) + copy(b, n.b) + a.expHit++ + a.hit++ + a.mu.Unlock() // X1- + return + } + + a.expMiss++ + a.miss++ + if a.miss > 10 && len(a.m) < 500 { + if 100*a.hit/a.miss < 95 { + a.cacheSz++ + } + a.hit, a.miss = 0, 0 + } + a.mu.Unlock() // X1- + + defer func(h int64) { + if err == nil { + a.mu.Lock() // X2+ + a.cadd(b, h) + a.mu.Unlock() // X2- + } + }(handle) + + first := bufs.GCache.Get(16) + defer bufs.GCache.Put(first) + relocated := false + relocSrc := handle +reloc: + if handle <= 0 || handle > maxHandle { + return nil, &ErrINVAL{"Allocator.Get: handle out of limits", handle} + } + + off := h2off(handle) + if err = a.read(first, off); err != nil { + return + } + + switch tag := first[0]; tag { + default: + dlen := int(tag) + atoms := n2atoms(dlen) + switch atoms { + case 1: + switch tag := first[15]; tag { + default: + return nil, &ErrILSEQ{Type: ErrTailTag, Off: off, Arg: int64(tag)} + case tagNotCompressed: + b = need(dlen, buf) + copy(b, first[1:]) + return + case tagCompressed: + return zappy.Decode(buf, first[1:dlen+1]) + } + default: + cc := bufs.GCache.Get(1) + defer bufs.GCache.Put(cc) + dlen := int(tag) + atoms := n2atoms(dlen) + tailOff := off + 16*int64(atoms) - 1 + if err = a.read(cc, tailOff); err != nil { + return + } + + switch tag := cc[0]; tag { + default: + return nil, &ErrILSEQ{Type: ErrTailTag, Off: off, Arg: int64(tag)} + case tagNotCompressed: + b = need(dlen, buf) + off += 1 + if err = a.read(b, off); err != nil { + b = buf[:0] + } + return + case tagCompressed: + zbuf := bufs.GCache.Get(dlen) + defer bufs.GCache.Put(zbuf) + off += 1 + if err = a.read(zbuf, off); err != nil { + return buf[:0], err + } + + return zappy.Decode(buf, zbuf) + } + } + case 0: + return buf[:0], nil + case tagUsedLong: + cc := bufs.GCache.Get(1) + defer bufs.GCache.Put(cc) + dlen := m2n(int(first[1])<<8 | int(first[2])) + atoms := n2atoms(dlen) + tailOff := off + 16*int64(atoms) - 1 + if err = a.read(cc, tailOff); err != nil { + return + } + + switch tag := cc[0]; tag { + default: + return nil, &ErrILSEQ{Type: ErrTailTag, Off: off, Arg: int64(tag)} + case tagNotCompressed: + b = need(dlen, buf) + off += 3 + if err = a.read(b, off); err != nil { + b = buf[:0] + } + return + case tagCompressed: + zbuf := bufs.GCache.Get(dlen) + defer bufs.GCache.Put(zbuf) + off += 3 + if err = a.read(zbuf, off); err != nil { + return buf[:0], err + } + + return zappy.Decode(buf, zbuf) + } + case tagFreeShort, tagFreeLong: + return nil, &ErrILSEQ{Type: ErrExpUsedTag, Off: off, Arg: int64(tag)} + case tagUsedRelocated: + if relocated { + return nil, &ErrILSEQ{Type: ErrUnexpReloc, Off: off, Arg: relocSrc} + } + + handle = b2h(first[1:]) + relocated = true + goto reloc + } +} + +var reallocTestHook bool + +// Realloc sets the content of a block referred to by handle or returns an +// error, if any. +// +// Handle must have been obtained initially from Alloc and must be still valid, +// otherwise a database may get irreparably corrupted. +func (a *Allocator) Realloc(handle int64, b []byte) (err error) { + if handle <= 0 || handle > maxHandle { + return &ErrINVAL{"Realloc: handle out of limits", handle} + } + + a.cfree(handle) + if err = a.realloc(handle, b); err != nil { + return + } + + if reallocTestHook { + if err = cacheAudit(a.m, &a.lru); err != nil { + return + } + } + + a.cadd(b, handle) + return +} + +func (a *Allocator) realloc(handle int64, b []byte) (err error) { + var dlen, needAtoms0 int + + b8 := bufs.GCache.Get(8) + defer bufs.GCache.Put(b8) + dst := bufs.GCache.Get(zappy.MaxEncodedLen(len(b))) + defer bufs.GCache.Put(dst) + b, needAtoms0, cc, err := a.makeUsedBlock(dst, b) + if err != nil { + return + } + + needAtoms := int64(needAtoms0) + off := h2off(handle) + if err = a.read(b8[:], off); err != nil { + return + } + + switch tag := b8[0]; tag { + default: + dlen = int(b8[0]) + case tagUsedLong: + dlen = m2n(int(b8[1])<<8 | int(b8[2])) + case tagUsedRelocated: + if err = a.free(b2h(b8[1:]), handle, false); err != nil { + return err + } + + dlen = 0 + case tagFreeShort, tagFreeLong: + return &ErrINVAL{"Allocator.Realloc: invalid handle", handle} + } + + atoms := int64(n2atoms(dlen)) +retry: + switch { + case needAtoms < atoms: + // in place shrink + if err = a.writeUsedBlock(handle, cc, b); err != nil { + return + } + + fh, fa := handle+needAtoms, atoms-needAtoms + sz, err := a.f.Size() + if err != nil { + return err + } + + if h2off(fh)+16*fa == sz { + return a.f.Truncate(h2off(fh)) + } + + return a.free2(fh, fa) + case needAtoms == atoms: + // in place replace + return a.writeUsedBlock(handle, cc, b) + } + + // case needAtoms > atoms: + // in place extend or relocate + var sz int64 + if sz, err = a.f.Size(); err != nil { + return + } + + off = h2off(handle) + switch { + case off+atoms*16 == sz: + // relocating tail block - shortcut + return a.writeUsedBlock(handle, cc, b) + default: + if off+atoms*16 < sz { + // handle is not a tail block, check right neighbour + rh := handle + atoms + rtag, ratoms, p, n, e := a.nfo(rh) + if e != nil { + return e + } + + if rtag == tagFreeShort || rtag == tagFreeLong { + // Right neighbour is a free block + if needAtoms <= atoms+ratoms { + // can expand in place + if err = a.unlink(rh, ratoms, p, n); err != nil { + return + } + + atoms += ratoms + goto retry + + } + } + } + } + + if atoms > 1 { + if err = a.realloc(handle, nil); err != nil { + return + } + } + + var newH int64 + if newH, err = a.alloc(b, cc); err != nil { + return err + } + + rb := bufs.GCache.Cget(16) + defer bufs.GCache.Put(rb) + rb[0] = tagUsedRelocated + h2b(rb[1:], newH) + if err = a.writeAt(rb[:], h2off(handle)); err != nil { + return + } + + return a.writeUsedBlock(newH, cc, b) +} + +func (a *Allocator) writeAt(b []byte, off int64) (err error) { + var n int + if n, err = a.f.WriteAt(b, off); err != nil { + return + } + + if n != len(b) { + err = io.ErrShortWrite + } + return +} + +func (a *Allocator) write(off int64, b ...[]byte) (err error) { + rq := 0 + for _, part := range b { + rq += len(part) + } + buf := bufs.GCache.Get(rq) + defer bufs.GCache.Put(buf) + buf = buf[:0] + for _, part := range b { + buf = append(buf, part...) + } + return a.writeAt(buf, off) +} + +func (a *Allocator) read(b []byte, off int64) (err error) { + var rn int + if rn, err = a.f.ReadAt(b, off); rn != len(b) { + return &ErrILSEQ{Type: ErrOther, Off: off, More: err} + } + + return nil +} + +// nfo returns h's tag. If it's a free block then return also (s)ize (in +// atoms), (p)rev and (n)ext. If it's a used block then only (s)ize is returned +// (again in atoms). If it's a used relocate block then (n)ext is set to the +// relocation target handle. +func (a *Allocator) nfo(h int64) (tag byte, s, p, n int64, err error) { + off := h2off(h) + rq := int64(22) + sz, err := a.f.Size() + if err != nil { + return + } + + if off+rq >= sz { + if rq = sz - off; rq < 15 { + err = io.ErrUnexpectedEOF + return + } + } + + buf := bufs.GCache.Get(22) + defer bufs.GCache.Put(buf) + if err = a.read(buf[:rq], off); err != nil { + return + } + + switch tag = buf[0]; tag { + default: + s = int64(n2atoms(int(tag))) + case tagUsedLong: + s = int64(n2atoms(m2n(int(buf[1])<<8 | int(buf[2])))) + case tagFreeLong: + if rq < 22 { + err = io.ErrUnexpectedEOF + return + } + + s, p, n = b2h(buf[1:]), b2h(buf[8:]), b2h(buf[15:]) + case tagUsedRelocated: + s, n = 1, b2h(buf[1:]) + case tagFreeShort: + s, p, n = 1, b2h(buf[1:]), b2h(buf[8:]) + } + return +} + +// leftNfo returns nfo for h's left neighbor if h > 1 and the left neighbor is +// a free block. Otherwise all zero values are returned instead. +func (a *Allocator) leftNfo(h int64) (tag byte, s, p, n int64, err error) { + if !(h > 1) { + return + } + + buf := bufs.GCache.Get(8) + defer bufs.GCache.Put(buf) + off := h2off(h) + if err = a.read(buf[:], off-8); err != nil { + return + } + + switch tag := buf[7]; tag { + case tagFreeShort: + return a.nfo(h - 1) + case tagFreeLong: + return a.nfo(h - b2h(buf[:])) + } + return +} + +// Set h.prev = p +func (a *Allocator) prev(h, p int64) (err error) { + b := bufs.GCache.Get(7) + defer bufs.GCache.Put(b) + off := h2off(h) + if err = a.read(b[:1], off); err != nil { + return + } + + switch tag := b[0]; tag { + default: + return &ErrILSEQ{Type: ErrExpFreeTag, Off: off, Arg: int64(tag)} + case tagFreeShort: + off += 1 + case tagFreeLong: + off += 8 + } + return a.writeAt(h2b(b[:7], p), off) +} + +// Set h.next = n +func (a *Allocator) next(h, n int64) (err error) { + b := bufs.GCache.Get(7) + defer bufs.GCache.Put(b) + off := h2off(h) + if err = a.read(b[:1], off); err != nil { + return + } + + switch tag := b[0]; tag { + default: + return &ErrILSEQ{Type: ErrExpFreeTag, Off: off, Arg: int64(tag)} + case tagFreeShort: + off += 8 + case tagFreeLong: + off += 15 + } + return a.writeAt(h2b(b[:7], n), off) +} + +// Make the filer image @h a free block. +func (a *Allocator) makeFree(h, atoms, prev, next int64) (err error) { + buf := bufs.GCache.Get(22) + defer bufs.GCache.Put(buf) + switch { + case atoms == 1: + buf[0], buf[15] = tagFreeShort, tagFreeShort + h2b(buf[1:], prev) + h2b(buf[8:], next) + if err = a.write(h2off(h), buf[:16]); err != nil { + return + } + default: + + buf[0] = tagFreeLong + h2b(buf[1:], atoms) + h2b(buf[8:], prev) + h2b(buf[15:], next) + if err = a.write(h2off(h), buf[:22]); err != nil { + return + } + + h2b(buf[:], atoms) + buf[7] = tagFreeLong + if err = a.write(h2off(h+atoms)-8, buf[:8]); err != nil { + return + } + } + if prev != 0 { + if err = a.next(prev, h); err != nil { + return + } + } + + if next != 0 { + err = a.prev(next, h) + } + return +} + +func (a *Allocator) makeUsedBlock(dst []byte, b []byte) (w []byte, rqAtoms int, cc byte, err error) { + cc = tagNotCompressed + w = b + + var n int + if n = len(b); n > maxRq { + return nil, 0, 0, &ErrINVAL{"Allocator.makeUsedBlock: content size out of limits", n} + } + + rqAtoms = n2atoms(n) + if a.Compress && n > 14 { // attempt compression + if dst, err = zappy.Encode(dst, b); err != nil { + return + } + + n2 := len(dst) + if rqAtoms2 := n2atoms(n2); rqAtoms2 < rqAtoms { // compression saved at least a single atom + w, n, rqAtoms, cc = dst, n2, rqAtoms2, tagCompressed + } + } + return +} + +func (a *Allocator) writeUsedBlock(h int64, cc byte, b []byte) (err error) { + n := len(b) + rq := n2atoms(n) << 4 + buf := bufs.GCache.Get(rq) + defer bufs.GCache.Put(buf) + switch n <= maxShort { + case true: + buf[0] = byte(n) + copy(buf[1:], b) + case false: + m := n2m(n) + buf[0], buf[1], buf[2] = tagUsedLong, byte(m>>8), byte(m) + copy(buf[3:], b) + } + if p := n2padding(n); p != 0 { + copy(buf[rq-1-p:], zeros[:]) + } + buf[rq-1] = cc + return a.writeAt(buf, h2off(h)) +} + +func (a *Allocator) verifyUnused(h, totalAtoms int64, tag byte, log func(error) bool, fast bool) (atoms, prev, next int64, err error) { + switch tag { + default: + panic("internal error") + case tagFreeShort: + var b [16]byte + off := h2off(h) + if err = a.read(b[:], off); err != nil { + return + } + + if b[15] != tagFreeShort { + err = &ErrILSEQ{Type: ErrShortFreeTailTag, Off: off, Arg: int64(b[15])} + log(err) + return + } + + atoms, prev, next = 1, b2h(b[1:]), b2h(b[8:]) + case tagFreeLong: + var b [22]byte + off := h2off(h) + if err = a.read(b[:], off); err != nil { + return + } + + atoms, prev, next = b2h(b[1:]), b2h(b[8:]), b2h(b[15:]) + if fast { + return + } + + if atoms < 2 { + err = &ErrILSEQ{Type: ErrLongFreeBlkTooShort, Off: off, Arg: int64(atoms)} + break + } + + if h+atoms-1 > totalAtoms { + err = &ErrILSEQ{Type: ErrLongFreeBlkTooLong, Off: off, Arg: atoms} + break + } + + if prev > totalAtoms { + err = &ErrILSEQ{Type: ErrLongFreePrevBeyondEOF, Off: off, Arg: next} + break + } + + if next > totalAtoms { + err = &ErrILSEQ{Type: ErrLongFreeNextBeyondEOF, Off: off, Arg: next} + break + } + + toff := h2off(h+atoms) - 8 + if err = a.read(b[:8], toff); err != nil { + return + } + + if b[7] != tag { + err = &ErrILSEQ{Type: ErrLongFreeTailTag, Off: off, Arg: int64(b[7])} + break + } + + if s2 := b2h(b[:]); s2 != atoms { + err = &ErrILSEQ{Type: ErrVerifyTailSize, Off: off, Arg: atoms, Arg2: s2} + break + } + + } + if err != nil { + log(err) + } + return +} + +func (a *Allocator) verifyUsed(h, totalAtoms int64, tag byte, buf, ubuf []byte, log func(error) bool, fast bool) (compressed bool, dlen int, atoms, link int64, err error) { + var ( + padding int + doff int64 + padZeros [15]byte + tailBuf [16]byte + ) + + switch tag { + default: // Short used + dlen = int(tag) + atoms = int64((dlen+1)/16) + 1 + padding = 15 - (dlen+1)%16 + doff = h2off(h) + 1 + case tagUsedLong: + off := h2off(h) + 1 + var b2 [2]byte + if err = a.read(b2[:], off); err != nil { + return + } + + dlen = m2n(int(b2[0])<<8 | int(b2[1])) + atoms = int64((dlen+3)/16) + 1 + padding = 15 - (dlen+3)%16 + doff = h2off(h) + 3 + case tagUsedRelocated: + dlen = 7 + atoms = 1 + padding = 7 + doff = h2off(h) + 1 + case tagFreeShort, tagFreeLong: + panic("internal error") + } + + if fast { + if tag == tagUsedRelocated { + dlen = 0 + if err = a.read(buf[:7], doff); err != nil { + return + } + + link = b2h(buf) + } + + return false, dlen, atoms, link, nil + } + + if ok := h+atoms-1 <= totalAtoms; !ok { // invalid last block + err = &ErrILSEQ{Type: ErrVerifyUsedSpan, Off: h2off(h), Arg: atoms} + log(err) + return + } + + tailsz := 1 + padding + off := h2off(h) + 16*atoms - int64(tailsz) + if err = a.read(tailBuf[:tailsz], off); err != nil { + return false, 0, 0, 0, err + } + + if ok := bytes.Equal(padZeros[:padding], tailBuf[:padding]); !ok { + err = &ErrILSEQ{Type: ErrVerifyPadding, Off: h2off(h)} + log(err) + return + } + + var cc byte + switch cc = tailBuf[padding]; cc { + default: + err = &ErrILSEQ{Type: ErrTailTag, Off: h2off(h)} + log(err) + return + case tagCompressed: + compressed = true + if tag == tagUsedRelocated { + err = &ErrILSEQ{Type: ErrTailTag, Off: h2off(h)} + log(err) + return + } + + fallthrough + case tagNotCompressed: + if err = a.read(buf[:dlen], doff); err != nil { + return false, 0, 0, 0, err + } + } + + if cc == tagCompressed { + if ubuf, err = zappy.Decode(ubuf, buf[:dlen]); err != nil || len(ubuf) > maxRq { + err = &ErrILSEQ{Type: ErrDecompress, Off: h2off(h)} + log(err) + return + } + + dlen = len(ubuf) + } + + if tag == tagUsedRelocated { + link = b2h(buf) + if link == 0 { + err = &ErrILSEQ{Type: ErrNullReloc, Off: h2off(h)} + log(err) + return + } + + if link > totalAtoms { // invalid last block + err = &ErrILSEQ{Type: ErrRelocBeyondEOF, Off: h2off(h), Arg: link} + log(err) + return + } + } + + return +} + +var nolog = func(error) bool { return false } + +// Verify attempts to find any structural errors in a Filer wrt the +// organization of it as defined by Allocator. 'bitmap' is a scratch pad for +// necessary bookkeeping and will grow to at most to Allocator's +// Filer.Size()/128 (0,78%). Any problems found are reported to 'log' except +// non verify related errors like disk read fails etc. If 'log' returns false +// or the error doesn't allow to (reliably) continue, the verification process +// is stopped and an error is returned from the Verify function. Passing a nil +// log works like providing a log function always returning false. Any +// non-structural errors, like for instance Filer read errors, are NOT reported +// to 'log', but returned as the Verify's return value, because Verify cannot +// proceed in such cases. Verify returns nil only if it fully completed +// verifying Allocator's Filer without detecting any error. +// +// It is recommended to limit the number reported problems by returning false +// from 'log' after reaching some limit. Huge and corrupted DB can produce an +// overwhelming error report dataset. +// +// The verifying process will scan the whole DB at least 3 times (a trade +// between processing space and time consumed). It doesn't read the content of +// free blocks above the head/tail info bytes. If the 3rd phase detects lost +// free space, then a 4th scan (a faster one) is performed to precisely report +// all of them. +// +// If the DB/Filer to be verified is reasonably small, respective if its +// size/128 can comfortably fit within process's free memory, then it is +// recommended to consider using a MemFiler for the bit map. +// +// Statistics are returned via 'stats' if non nil. The statistics are valid +// only if Verify succeeded, ie. it didn't reported anything to log and it +// returned a nil error. +func (a *Allocator) Verify(bitmap Filer, log func(error) bool, stats *AllocStats) (err error) { + if log == nil { + log = nolog + } + + n, err := bitmap.Size() + if err != nil { + return + } + + if n != 0 { + return &ErrINVAL{"Allocator.Verify: bit map initial size non zero (%d)", n} + } + + var bits int64 + bitMask := [8]byte{1, 2, 4, 8, 16, 32, 64, 128} + byteBuf := []byte{0} + + //DONE + // +performance, this implementation is hopefully correct but _very_ + // naive, probably good as a prototype only. Use maybe a MemFiler + // "cache" etc. + // ---- + // Turns out the OS caching is as effective as it can probably get. + bit := func(on bool, h int64) (wasOn bool, err error) { + m := bitMask[h&7] + off := h >> 3 + var v byte + sz, err := bitmap.Size() + if err != nil { + return + } + + if off < sz { + if n, err := bitmap.ReadAt(byteBuf, off); n != 1 { + return false, &ErrILSEQ{Type: ErrOther, Off: off, More: fmt.Errorf("Allocator.Verify - reading bitmap: %s", err)} + } + + v = byteBuf[0] + } + switch wasOn = v&m != 0; on { + case true: + if !wasOn { + v |= m + bits++ + } + case false: + if wasOn { + v ^= m + bits-- + } + } + byteBuf[0] = v + if n, err := bitmap.WriteAt(byteBuf, off); n != 1 || err != nil { + return false, &ErrILSEQ{Type: ErrOther, Off: off, More: fmt.Errorf("Allocator.Verify - writing bitmap: %s", err)} + } + + return + } + + // Phase 1 - sequentially scan a.f to reliably determine block + // boundaries. Set a bit for every block start. + var ( + buf, ubuf [maxRq]byte + prevH, h, atoms int64 + wasOn bool + tag byte + st = AllocStats{ + AllocMap: map[int64]int64{}, + FreeMap: map[int64]int64{}, + } + dlen int + ) + + fsz, err := a.f.Size() + if err != nil { + return + } + + ok := fsz%16 == 0 + totalAtoms := (fsz - fltSz) / atomLen + if !ok { + err = &ErrILSEQ{Type: ErrFileSize, Name: a.f.Name(), Arg: fsz} + log(err) + return + } + + st.TotalAtoms = totalAtoms + prevTag := -1 + lastH := int64(-1) + + for h = 1; h <= totalAtoms; h += atoms { + prevH = h // For checking last block == used + + off := h2off(h) + if err = a.read(buf[:1], off); err != nil { + return + } + + switch tag = buf[0]; tag { + default: // Short used + fallthrough + case tagUsedLong, tagUsedRelocated: + var compressed bool + if compressed, dlen, atoms, _, err = a.verifyUsed(h, totalAtoms, tag, buf[:], ubuf[:], log, false); err != nil { + return + } + + if compressed { + st.Compression++ + } + st.AllocAtoms += atoms + switch { + case tag == tagUsedRelocated: + st.AllocMap[1]++ + st.Relocations++ + default: + st.AllocMap[atoms]++ + st.AllocBytes += int64(dlen) + st.Handles++ + } + case tagFreeShort, tagFreeLong: + if prevTag == tagFreeShort || prevTag == tagFreeLong { + err = &ErrILSEQ{Type: ErrAdjacentFree, Off: h2off(lastH), Arg: off} + log(err) + return + } + + if atoms, _, _, err = a.verifyUnused(h, totalAtoms, tag, log, false); err != nil { + return + } + + st.FreeMap[atoms]++ + st.FreeAtoms += atoms + } + + if wasOn, err = bit(true, h); err != nil { + return + } + + if wasOn { + panic("internal error") + } + + prevTag = int(tag) + lastH = h + } + + if totalAtoms != 0 && (tag == tagFreeShort || tag == tagFreeLong) { + err = &ErrILSEQ{Type: ErrFreeTailBlock, Off: h2off(prevH)} + log(err) + return + } + + // Phase 2 - check used blocks, turn off the map bit for every used + // block. + for h = 1; h <= totalAtoms; h += atoms { + off := h2off(h) + if err = a.read(buf[:1], off); err != nil { + return + } + + var link int64 + switch tag = buf[0]; tag { + default: // Short used + fallthrough + case tagUsedLong, tagUsedRelocated: + if _, _, atoms, link, err = a.verifyUsed(h, totalAtoms, tag, buf[:], ubuf[:], log, true); err != nil { + return + } + case tagFreeShort, tagFreeLong: + if atoms, _, _, err = a.verifyUnused(h, totalAtoms, tag, log, true); err != nil { + return + } + } + + turnoff := true + switch tag { + case tagUsedRelocated: + if err = a.read(buf[:1], h2off(link)); err != nil { + return + } + + switch linkedTag := buf[0]; linkedTag { + case tagFreeShort, tagFreeLong, tagUsedRelocated: + err = &ErrILSEQ{Type: ErrInvalidRelocTarget, Off: off, Arg: link} + log(err) + return + } + + case tagFreeShort, tagFreeLong: + turnoff = false + } + + if !turnoff { + continue + } + + if wasOn, err = bit(false, h); err != nil { + return + } + + if !wasOn { + panic("internal error") + } + + } + + // Phase 3 - using the flt check heads link to proper free blocks. For + // every free block, walk the list, verify the {next, prev} links and + // turn the respective map bit off. After processing all free lists, + // the map bits count should be zero. Otherwise there are "lost" free + // blocks. + + var prev, next, fprev, fnext int64 + rep := a.flt + + for _, list := range rep { + prev, next = 0, list.head + for ; next != 0; prev, next = next, fnext { + if wasOn, err = bit(false, next); err != nil { + return + } + + if !wasOn { + err = &ErrILSEQ{Type: ErrFLT, Off: h2off(next), Arg: h} + log(err) + return + } + + off := h2off(next) + if err = a.read(buf[:1], off); err != nil { + return + } + + switch tag = buf[0]; tag { + default: + panic("internal error") + case tagFreeShort, tagFreeLong: + if atoms, fprev, fnext, err = a.verifyUnused(next, totalAtoms, tag, log, true); err != nil { + return + } + + if min := list.minSize; atoms < min { + err = &ErrILSEQ{Type: ErrFLTSize, Off: h2off(next), Arg: atoms, Arg2: min} + log(err) + return + } + + if fprev != prev { + err = &ErrILSEQ{Type: ErrFreeChaining, Off: h2off(next)} + log(err) + return + } + } + } + + } + + if bits == 0 { // Verify succeeded + if stats != nil { + *stats = st + } + return + } + + // Phase 4 - if after phase 3 there are lost free blocks, report all of + // them to 'log' + for i := range ubuf { // setup zeros for compares + ubuf[i] = 0 + } + + var off, lh int64 + rem, err := bitmap.Size() + if err != nil { + return err + } + + for rem != 0 { + rq := int(mathutil.MinInt64(64*1024, rem)) + var n int + if n, err = bitmap.ReadAt(buf[:rq], off); n != rq { + return &ErrILSEQ{Type: ErrOther, Off: off, More: fmt.Errorf("bitmap ReadAt(size %d, off %#x): %s", rq, off, err)} + } + + if !bytes.Equal(buf[:rq], ubuf[:rq]) { + for d, v := range buf[:rq] { + if v != 0 { + for i, m := range bitMask { + if v&m != 0 { + lh = 8*(off+int64(d)) + int64(i) + err = &ErrILSEQ{Type: ErrLostFreeBlock, Off: h2off(lh)} + log(err) + return + } + } + } + } + } + + off += int64(rq) + rem -= int64(rq) + } + + return +} + +type fltSlot struct { + head int64 + minSize int64 +} + +func (f fltSlot) String() string { + return fmt.Sprintf("head %#x, minSize %#x\n", f.head, f.minSize) +} + +type flt [14]fltSlot + +func (f *flt) init() { + sz := 1 + for i := range *f { + f[i].minSize, f[i].head = int64(sz), 0 + sz <<= 1 + } + f[13].minSize = 4112 +} + +func (f *flt) load(fi Filer, off int64) (err error) { + b := bufs.GCache.Get(fltSz) + defer bufs.GCache.Put(b) + if _, err = fi.ReadAt(b[:], off); err != nil { + return + } + + for i := range *f { + off := 8*i + 1 + f[i].head = b2h(b[off:]) + } + return +} + +func (f *flt) find(rq int) (h int64) { + switch { + case rq < 1: + panic(rq) + case rq >= maxFLTRq: + h, f[13].head = f[13].head, 0 + return + default: + g := f[mathutil.Log2Uint16(uint16(rq)):] + for i := range g { + p := &g[i] + if rq <= int(p.minSize) { + if h = p.head; h != 0 { + p.head = 0 + return + } + } + } + return + } +} + +func (f *flt) head(atoms int64) (h int64) { + switch { + case atoms < 1: + panic(atoms) + case atoms >= maxFLTRq: + return f[13].head + default: + lg := mathutil.Log2Uint16(uint16(atoms)) + g := f[lg:] + for i := range g { + if atoms < g[i+1].minSize { + return g[i].head + } + } + panic("internal error") + } +} + +func (f *flt) setHead(h, atoms int64, fi Filer) (err error) { + switch { + case atoms < 1: + panic(atoms) + case atoms >= maxFLTRq: + b := bufs.GCache.Get(7) + defer bufs.GCache.Put(b) + if _, err = fi.WriteAt(h2b(b[:], h), 8*13+1); err != nil { + return + } + + f[13].head = h + return + default: + lg := mathutil.Log2Uint16(uint16(atoms)) + g := f[lg:] + for i := range f { + if atoms < g[i+1].minSize { + b := bufs.GCache.Get(7) + defer bufs.GCache.Put(b) + if _, err = fi.WriteAt(h2b(b[:], h), 8*int64(i+lg)+1); err != nil { + return + } + + g[i].head = h + return + } + } + panic("internal error") + } +} + +func (f *flt) String() string { + a := []string{} + for i, v := range *f { + a = append(a, fmt.Sprintf("[%2d] %s", i, v)) + } + return strings.Join(a, "") +} + +type node struct { + b []byte + h int64 + prev, next *node +} + +type cache []*node + +func (c *cache) get(n int) *node { + r, _ := c.get2(n) + return r +} + +func (c *cache) get2(n int) (r *node, isZeroed bool) { + s := *c + lens := len(s) + if lens == 0 { + return &node{b: make([]byte, n, mathutil.Min(2*n, maxBuf))}, true + } + + i := sort.Search(lens, func(x int) bool { return len(s[x].b) >= n }) + if i == lens { + i-- + s[i].b, isZeroed = make([]byte, n, mathutil.Min(2*n, maxBuf)), true + } + + r = s[i] + r.b = r.b[:n] + copy(s[i:], s[i+1:]) + s = s[:lens-1] + *c = s + return +} + +func (c *cache) cget(n int) (r *node) { + r, ok := c.get2(n) + if ok { + return + } + + for i := range r.b { + r.b[i] = 0 + } + return +} + +func (c *cache) size() (sz int64) { + for _, n := range *c { + sz += int64(cap(n.b)) + } + return +} + +func (c *cache) put(n *node) *node { + s := *c + n.b = n.b[:cap(n.b)] + lenb := len(n.b) + lens := len(s) + i := sort.Search(lens, func(x int) bool { return len(s[x].b) >= lenb }) + s = append(s, nil) + copy(s[i+1:], s[i:]) + s[i] = n + *c = s + return n +} + +type lst struct { + front, back *node +} + +func (l *lst) pushFront(n *node) *node { + if l.front == nil { + l.front, l.back, n.prev, n.next = n, n, nil, nil + return n + } + + n.prev, n.next, l.front.prev, l.front = nil, l.front, n, n + return n +} + +func (l *lst) remove(n *node) *node { + if n.prev == nil { + l.front = n.next + } else { + n.prev.next = n.next + } + if n.next == nil { + l.back = n.prev + } else { + n.next.prev = n.prev + } + n.prev, n.next = nil, nil + return n +} + +func (l *lst) removeBack() *node { + return l.remove(l.back) +} + +func (l *lst) moveToFront(n *node) *node { + return l.pushFront(l.remove(n)) +} + +func (l *lst) size() (sz int64) { + for n := l.front; n != nil; n = n.next { + sz += int64(cap(n.b)) + } + return +} + +func cacheAudit(m map[int64]*node, l *lst) (err error) { + cnt := 0 + for h, n := range m { + if g, e := n.h, h; g != e { + return fmt.Errorf("cacheAudit: invalid node handle %d != %d", g, e) + } + + if cnt, err = l.audit(n, true); err != nil { + return + } + } + + if g, e := cnt, len(m); g != e { + return fmt.Errorf("cacheAudit: invalid cache size %d != %d", g, e) + } + + return +} + +func (l *lst) audit(n *node, onList bool) (cnt int, err error) { + if !onList && (n.prev != nil || n.next != nil) { + return -1, fmt.Errorf("lst.audit: free node with non nil linkage") + } + + if l.front == nil && l.back != nil || l.back == nil && l.front != nil { + return -1, fmt.Errorf("lst.audit: one of .front/.back is nil while the other is non nil") + } + + if l.front == l.back && l.front != nil { + x := l.front + if x.prev != nil || x.next != nil { + return -1, fmt.Errorf("lst.audit: single node has non nil linkage") + } + + if onList && x != n { + return -1, fmt.Errorf("lst.audit: single node is alien") + } + } + + seen := false + var prev *node + x := l.front + for x != nil { + cnt++ + if x.prev != prev { + return -1, fmt.Errorf("lst.audit: broken .prev linkage") + } + + if x == n { + seen = true + } + + prev = x + x = x.next + } + + if prev != l.back { + return -1, fmt.Errorf("lst.audit: broken .back linkage") + } + + if onList && !seen { + return -1, fmt.Errorf("lst.audit: node missing in list") + } + + if !onList && seen { + return -1, fmt.Errorf("lst.audit: node should not be on the list") + } + + return +} diff --git a/vendor/github.com/cznic/exp/lldb/filer.go b/vendor/github.com/cznic/exp/lldb/filer.go new file mode 100644 index 0000000000..38b389387a --- /dev/null +++ b/vendor/github.com/cznic/exp/lldb/filer.go @@ -0,0 +1,192 @@ +// Copyright 2014 The lldb Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// An abstraction of file like (persistent) storage with optional (abstracted) +// support for structural integrity. + +package lldb + +import ( + "fmt" + + "github.com/cznic/mathutil" +) + +func doubleTrouble(first, second error) error { + return fmt.Errorf("%q. Additionally, while attempting to recover (rollback): %q", first, second) +} + +// A Filer is a []byte-like model of a file or similar entity. It may +// optionally implement support for structural transaction safety. In contrast +// to a file stream, a Filer is not sequentially accessible. ReadAt and WriteAt +// are always "addressed" by an offset and are assumed to perform atomically. +// A Filer is not safe for concurrent access, it's designed for consumption by +// the other objects in package, which should use a Filer from one goroutine +// only or via a mutex. BeginUpdate, EndUpdate and Rollback must be either all +// implemented by a Filer for structural integrity - or they should be all +// no-ops; where/if that requirement is relaxed. +// +// If a Filer wraps another Filer implementation, it usually invokes the same +// methods on the "inner" one, after some possible argument translations etc. +// If a Filer implements the structural transactions handling methods +// (BeginUpdate, EndUpdate and Rollback) as no-ops _and_ wraps another Filer: +// it then still MUST invoke those methods on the inner Filer. This is +// important for the case where a RollbackFiler exists somewhere down the +// chain. It's also important for an Allocator - to know when it must +// invalidate its FLT cache. +type Filer interface { + // BeginUpdate increments the "nesting" counter (initially zero). Every + // call to BeginUpdate must be eventually "balanced" by exactly one of + // EndUpdate or Rollback. Calls to BeginUpdate may nest. + BeginUpdate() error + + // Analogous to os.File.Close(). + Close() error + + // EndUpdate decrements the "nesting" counter. If it's zero after that + // then assume the "storage" has reached structural integrity (after a + // batch of partial updates). If a Filer implements some support for + // that (write ahead log, journal, etc.) then the appropriate actions + // are to be taken for nesting == 0. Invocation of an unbalanced + // EndUpdate is an error. + EndUpdate() error + + // Analogous to os.File.Name(). + Name() string + + // PunchHole deallocates space inside a "file" in the byte range + // starting at off and continuing for size bytes. The actual hole + // created by PunchHole may be smaller than requested. The Filer size + // (as reported by `Size()` does not change when hole punching, even + // when punching the end of a file off. In contrast to the Linux + // implementation of FALLOC_FL_PUNCH_HOLE in `fallocate`(2); a Filer is + // free not only to ignore `PunchHole()` (implement it as a nop), but + // additionally no guarantees about the content of the hole, when + // eventually read back, are required, i.e. any data, not only zeros, + // can be read from the "hole", including just anything what was left + // there - with all of the possible security problems. + PunchHole(off, size int64) error + + // As os.File.ReadAt. Note: `off` is an absolute "file pointer" + // address and cannot be negative even when a Filer is a InnerFiler. + ReadAt(b []byte, off int64) (n int, err error) + + // Rollback cancels and undoes the innermost pending update level. + // Rollback decrements the "nesting" counter. If a Filer implements + // some support for keeping structural integrity (write ahead log, + // journal, etc.) then the appropriate actions are to be taken. + // Invocation of an unbalanced Rollback is an error. + Rollback() error + + // Analogous to os.File.FileInfo().Size(). + Size() (int64, error) + + // Analogous to os.Sync(). + Sync() (err error) + + // Analogous to os.File.Truncate(). + Truncate(size int64) error + + // Analogous to os.File.WriteAt(). Note: `off` is an absolute "file + // pointer" address and cannot be negative even when a Filer is a + // InnerFiler. + WriteAt(b []byte, off int64) (n int, err error) +} + +var _ Filer = &InnerFiler{} // Ensure InnerFiler is a Filer. + +// A InnerFiler is a Filer with added addressing/size translation. +type InnerFiler struct { + outer Filer + off int64 +} + +// NewInnerFiler returns a new InnerFiler wrapped by `outer` in a way which +// adds `off` to every access. +// +// For example, considering: +// +// inner := NewInnerFiler(outer, 10) +// +// then +// +// inner.WriteAt([]byte{42}, 4) +// +// translates to +// +// outer.WriteAt([]byte{42}, 14) +// +// But an attempt to emulate +// +// outer.WriteAt([]byte{17}, 9) +// +// by +// +// inner.WriteAt([]byte{17}, -1) +// +// will fail as the `off` parameter can never be < 0. Also note that +// +// inner.Size() == outer.Size() - off, +// +// i.e. `inner` pretends no `outer` exists. Finally, after e.g. +// +// inner.Truncate(7) +// outer.Size() == 17 +// +// will be true. +func NewInnerFiler(outer Filer, off int64) *InnerFiler { return &InnerFiler{outer, off} } + +// BeginUpdate implements Filer. +func (f *InnerFiler) BeginUpdate() error { return f.outer.BeginUpdate() } + +// Close implements Filer. +func (f *InnerFiler) Close() (err error) { return f.outer.Close() } + +// EndUpdate implements Filer. +func (f *InnerFiler) EndUpdate() error { return f.outer.EndUpdate() } + +// Name implements Filer. +func (f *InnerFiler) Name() string { return f.outer.Name() } + +// PunchHole implements Filer. `off`, `size` must be >= 0. +func (f *InnerFiler) PunchHole(off, size int64) error { return f.outer.PunchHole(f.off+off, size) } + +// ReadAt implements Filer. `off` must be >= 0. +func (f *InnerFiler) ReadAt(b []byte, off int64) (n int, err error) { + if off < 0 { + return 0, &ErrINVAL{f.outer.Name() + ":ReadAt invalid off", off} + } + + return f.outer.ReadAt(b, f.off+off) +} + +// Rollback implements Filer. +func (f *InnerFiler) Rollback() error { return f.outer.Rollback() } + +// Size implements Filer. +func (f *InnerFiler) Size() (int64, error) { + sz, err := f.outer.Size() + if err != nil { + return 0, err + } + + return mathutil.MaxInt64(sz-f.off, 0), nil +} + +// Sync() implements Filer. +func (f *InnerFiler) Sync() (err error) { + return f.outer.Sync() +} + +// Truncate implements Filer. +func (f *InnerFiler) Truncate(size int64) error { return f.outer.Truncate(size + f.off) } + +// WriteAt implements Filer. `off` must be >= 0. +func (f *InnerFiler) WriteAt(b []byte, off int64) (n int, err error) { + if off < 0 { + return 0, &ErrINVAL{f.outer.Name() + ":WriteAt invalid off", off} + } + + return f.outer.WriteAt(b, f.off+off) +} diff --git a/vendor/github.com/cznic/exp/lldb/gb.go b/vendor/github.com/cznic/exp/lldb/gb.go new file mode 100644 index 0000000000..e9090a5473 --- /dev/null +++ b/vendor/github.com/cznic/exp/lldb/gb.go @@ -0,0 +1,812 @@ +// Copyright 2014 The lldb Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Utilities to encode/decode and collate Go predeclared scalar types (and the +// typeless nil and []byte). The encoding format is a variation of the one +// used by the "encoding/gob" package. + +package lldb + +import ( + "bytes" + "fmt" + "math" + + "github.com/cznic/mathutil" +) + +const ( + gbNull = iota // 0x00 + gbFalse // 0x01 + gbTrue // 0x02 + gbFloat0 // 0x03 + gbFloat1 // 0x04 + gbFloat2 // 0x05 + gbFloat3 // 0x06 + gbFloat4 // 0x07 + gbFloat5 // 0x08 + gbFloat6 // 0x09 + gbFloat7 // 0x0a + gbFloat8 // 0x0b + gbComplex0 // 0x0c + gbComplex1 // 0x0d + gbComplex2 // 0x0e + gbComplex3 // 0x0f + gbComplex4 // 0x10 + gbComplex5 // 0x11 + gbComplex6 // 0x12 + gbComplex7 // 0x13 + gbComplex8 // 0x14 + gbBytes00 // 0x15 + gbBytes01 // 0x16 + gbBytes02 // 0x17 + gbBytes03 // 0x18 + gbBytes04 // 0x19 + gbBytes05 // 0x1a + gbBytes06 // 0x1b + gbBytes07 // 0x1c + gbBytes08 // 0x1d + gbBytes09 // 0x1e + gbBytes10 // 0x1f + gbBytes11 // 0x20 + gbBytes12 // 0x21 + gbBytes13 // 0x22 + gbBytes14 // 0x23 + gbBytes15 // 0x24 + gbBytes16 // 0x25 + gbBytes17 // Ox26 + gbBytes1 // 0x27 + gbBytes2 // 0x28: Offset by one to allow 64kB sized []byte. + gbString00 // 0x29 + gbString01 // 0x2a + gbString02 // 0x2b + gbString03 // 0x2c + gbString04 // 0x2d + gbString05 // 0x2e + gbString06 // 0x2f + gbString07 // 0x30 + gbString08 // 0x31 + gbString09 // 0x32 + gbString10 // 0x33 + gbString11 // 0x34 + gbString12 // 0x35 + gbString13 // 0x36 + gbString14 // 0x37 + gbString15 // 0x38 + gbString16 // 0x39 + gbString17 // 0x3a + gbString1 // 0x3b + gbString2 // 0x3c + gbUintP1 // 0x3d + gbUintP2 // 0x3e + gbUintP3 // 0x3f + gbUintP4 // 0x40 + gbUintP5 // 0x41 + gbUintP6 // 0x42 + gbUintP7 // 0x43 + gbUintP8 // 0x44 + gbIntM8 // 0x45 + gbIntM7 // 0x46 + gbIntM6 // 0x47 + gbIntM5 // 0x48 + gbIntM4 // 0x49 + gbIntM3 // 0x4a + gbIntM2 // 0x4b + gbIntM1 // 0x4c + gbIntP1 // 0x4d + gbIntP2 // 0x4e + gbIntP3 // 0x4f + gbIntP4 // 0x50 + gbIntP5 // 0x51 + gbIntP6 // 0x52 + gbIntP7 // 0x53 + gbIntP8 // 0x54 + gbInt0 // 0x55 + + gbIntMax = 255 - gbInt0 // 0xff == 170 +) + +// EncodeScalars encodes a vector of predeclared scalar type values to a +// []byte, making it suitable to store it as a "record" in a DB or to use it as +// a key of a BTree. +func EncodeScalars(scalars ...interface{}) (b []byte, err error) { + for _, scalar := range scalars { + switch x := scalar.(type) { + default: + return nil, &ErrINVAL{"EncodeScalars: unsupported type", fmt.Sprintf("%T in `%#v`", x, scalars)} + + case nil: + b = append(b, gbNull) + + case bool: + switch x { + case false: + b = append(b, gbFalse) + case true: + b = append(b, gbTrue) + } + + case float32: + encFloat(float64(x), &b) + case float64: + encFloat(x, &b) + + case complex64: + encComplex(complex128(x), &b) + case complex128: + encComplex(x, &b) + + case string: + n := len(x) + if n <= 17 { + b = append(b, byte(gbString00+n)) + b = append(b, []byte(x)...) + break + } + + if n > 65535 { + return nil, fmt.Errorf("EncodeScalars: cannot encode string of length %d (limit 65536)", n) + } + + pref := byte(gbString1) + if n > 255 { + pref++ + } + b = append(b, pref) + encUint0(uint64(n), &b) + b = append(b, []byte(x)...) + + case int8: + encInt(int64(x), &b) + case int16: + encInt(int64(x), &b) + case int32: + encInt(int64(x), &b) + case int64: + encInt(x, &b) + case int: + encInt(int64(x), &b) + + case uint8: + encUint(uint64(x), &b) + case uint16: + encUint(uint64(x), &b) + case uint32: + encUint(uint64(x), &b) + case uint64: + encUint(x, &b) + case uint: + encUint(uint64(x), &b) + case []byte: + n := len(x) + if n <= 17 { + b = append(b, byte(gbBytes00+n)) + b = append(b, []byte(x)...) + break + } + + if n > 655356 { + return nil, fmt.Errorf("EncodeScalars: cannot encode []byte of length %d (limit 65536)", n) + } + + pref := byte(gbBytes1) + if n > 255 { + pref++ + } + b = append(b, pref) + if n <= 255 { + b = append(b, byte(n)) + } else { + n-- + b = append(b, byte(n>>8), byte(n)) + } + b = append(b, x...) + } + } + return +} + +func encComplex(f complex128, b *[]byte) { + encFloatPrefix(gbComplex0, real(f), b) + encFloatPrefix(gbComplex0, imag(f), b) +} + +func encFloatPrefix(prefix byte, f float64, b *[]byte) { + u := math.Float64bits(f) + var n uint64 + for i := 0; i < 8; i++ { + n <<= 8 + n |= u & 0xFF + u >>= 8 + } + bits := mathutil.BitLenUint64(n) + if bits == 0 { + *b = append(*b, prefix) + return + } + + // 0 1 2 3 4 5 6 7 8 9 + // . 1 1 1 1 1 1 1 1 2 + encUintPrefix(prefix+1+byte((bits-1)>>3), n, b) +} + +func encFloat(f float64, b *[]byte) { + encFloatPrefix(gbFloat0, f, b) +} + +func encUint0(n uint64, b *[]byte) { + switch { + case n <= 0xff: + *b = append(*b, byte(n)) + case n <= 0xffff: + *b = append(*b, byte(n>>8), byte(n)) + case n <= 0xffffff: + *b = append(*b, byte(n>>16), byte(n>>8), byte(n)) + case n <= 0xffffffff: + *b = append(*b, byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) + case n <= 0xffffffffff: + *b = append(*b, byte(n>>32), byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) + case n <= 0xffffffffffff: + *b = append(*b, byte(n>>40), byte(n>>32), byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) + case n <= 0xffffffffffffff: + *b = append(*b, byte(n>>48), byte(n>>40), byte(n>>32), byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) + case n <= math.MaxUint64: + *b = append(*b, byte(n>>56), byte(n>>48), byte(n>>40), byte(n>>32), byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) + } +} + +func encUintPrefix(prefix byte, n uint64, b *[]byte) { + *b = append(*b, prefix) + encUint0(n, b) +} + +func encUint(n uint64, b *[]byte) { + bits := mathutil.Max(1, mathutil.BitLenUint64(n)) + encUintPrefix(gbUintP1+byte((bits-1)>>3), n, b) +} + +func encInt(n int64, b *[]byte) { + switch { + case n < -0x100000000000000: + *b = append(*b, byte(gbIntM8), byte(n>>56), byte(n>>48), byte(n>>40), byte(n>>32), byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) + case n < -0x1000000000000: + *b = append(*b, byte(gbIntM7), byte(n>>48), byte(n>>40), byte(n>>32), byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) + case n < -0x10000000000: + *b = append(*b, byte(gbIntM6), byte(n>>40), byte(n>>32), byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) + case n < -0x100000000: + *b = append(*b, byte(gbIntM5), byte(n>>32), byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) + case n < -0x1000000: + *b = append(*b, byte(gbIntM4), byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) + case n < -0x10000: + *b = append(*b, byte(gbIntM3), byte(n>>16), byte(n>>8), byte(n)) + case n < -0x100: + *b = append(*b, byte(gbIntM2), byte(n>>8), byte(n)) + case n < 0: + *b = append(*b, byte(gbIntM1), byte(n)) + case n <= gbIntMax: + *b = append(*b, byte(gbInt0+n)) + case n <= 0xff: + *b = append(*b, gbIntP1, byte(n)) + case n <= 0xffff: + *b = append(*b, gbIntP2, byte(n>>8), byte(n)) + case n <= 0xffffff: + *b = append(*b, gbIntP3, byte(n>>16), byte(n>>8), byte(n)) + case n <= 0xffffffff: + *b = append(*b, gbIntP4, byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) + case n <= 0xffffffffff: + *b = append(*b, gbIntP5, byte(n>>32), byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) + case n <= 0xffffffffffff: + *b = append(*b, gbIntP6, byte(n>>40), byte(n>>32), byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) + case n <= 0xffffffffffffff: + *b = append(*b, gbIntP7, byte(n>>48), byte(n>>40), byte(n>>32), byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) + case n <= 0x7fffffffffffffff: + *b = append(*b, gbIntP8, byte(n>>56), byte(n>>48), byte(n>>40), byte(n>>32), byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) + } +} + +func decodeFloat(b []byte) float64 { + var u uint64 + for i, v := range b { + u |= uint64(v) << uint((i+8-len(b))*8) + } + return math.Float64frombits(u) +} + +// DecodeScalars decodes a []byte produced by EncodeScalars. +func DecodeScalars(b []byte) (scalars []interface{}, err error) { + b0 := b + for len(b) != 0 { + switch tag := b[0]; tag { + //default: + //return nil, fmt.Errorf("tag %d(%#x) not supported", b[0], b[0]) + case gbNull: + scalars = append(scalars, nil) + b = b[1:] + case gbFalse: + scalars = append(scalars, false) + b = b[1:] + case gbTrue: + scalars = append(scalars, true) + b = b[1:] + case gbFloat0: + scalars = append(scalars, 0.0) + b = b[1:] + case gbFloat1, gbFloat2, gbFloat3, gbFloat4, gbFloat5, gbFloat6, gbFloat7, gbFloat8: + n := 1 + int(tag) - gbFloat0 + if len(b) < n-1 { + goto corrupted + } + + scalars = append(scalars, decodeFloat(b[1:n])) + b = b[n:] + case gbComplex0, gbComplex1, gbComplex2, gbComplex3, gbComplex4, gbComplex5, gbComplex6, gbComplex7, gbComplex8: + n := 1 + int(tag) - gbComplex0 + if len(b) < n-1 { + goto corrupted + } + + re := decodeFloat(b[1:n]) + b = b[n:] + + if len(b) == 0 { + goto corrupted + } + + tag = b[0] + if tag < gbComplex0 || tag > gbComplex8 { + goto corrupted + } + + n = 1 + int(tag) - gbComplex0 + if len(b) < n-1 { + goto corrupted + } + + scalars = append(scalars, complex(re, decodeFloat(b[1:n]))) + b = b[n:] + case gbBytes00, gbBytes01, gbBytes02, gbBytes03, gbBytes04, + gbBytes05, gbBytes06, gbBytes07, gbBytes08, gbBytes09, + gbBytes10, gbBytes11, gbBytes12, gbBytes13, gbBytes14, + gbBytes15, gbBytes16, gbBytes17: + n := int(tag - gbBytes00) + if len(b) < n+1 { + goto corrupted + } + + scalars = append(scalars, append([]byte(nil), b[1:n+1]...)) + b = b[n+1:] + case gbBytes1: + if len(b) < 2 { + goto corrupted + } + + n := int(b[1]) + b = b[2:] + if len(b) < n { + goto corrupted + } + + scalars = append(scalars, append([]byte(nil), b[:n]...)) + b = b[n:] + case gbBytes2: + if len(b) < 3 { + goto corrupted + } + + n := int(b[1])<<8 | int(b[2]) + 1 + b = b[3:] + if len(b) < n { + goto corrupted + } + + scalars = append(scalars, append([]byte(nil), b[:n]...)) + b = b[n:] + case gbString00, gbString01, gbString02, gbString03, gbString04, + gbString05, gbString06, gbString07, gbString08, gbString09, + gbString10, gbString11, gbString12, gbString13, gbString14, + gbString15, gbString16, gbString17: + n := int(tag - gbString00) + if len(b) < n+1 { + goto corrupted + } + + scalars = append(scalars, string(b[1:n+1])) + b = b[n+1:] + case gbString1: + if len(b) < 2 { + goto corrupted + } + + n := int(b[1]) + b = b[2:] + if len(b) < n { + goto corrupted + } + + scalars = append(scalars, string(b[:n])) + b = b[n:] + case gbString2: + if len(b) < 3 { + goto corrupted + } + + n := int(b[1])<<8 | int(b[2]) + b = b[3:] + if len(b) < n { + goto corrupted + } + + scalars = append(scalars, string(b[:n])) + b = b[n:] + case gbUintP1, gbUintP2, gbUintP3, gbUintP4, gbUintP5, gbUintP6, gbUintP7, gbUintP8: + b = b[1:] + n := 1 + int(tag) - gbUintP1 + if len(b) < n { + goto corrupted + } + + var u uint64 + for _, v := range b[:n] { + u = u<<8 | uint64(v) + } + scalars = append(scalars, u) + b = b[n:] + case gbIntM8, gbIntM7, gbIntM6, gbIntM5, gbIntM4, gbIntM3, gbIntM2, gbIntM1: + b = b[1:] + n := 8 - (int(tag) - gbIntM8) + if len(b) < n { + goto corrupted + } + u := uint64(math.MaxUint64) + for _, v := range b[:n] { + u = u<<8 | uint64(v) + } + scalars = append(scalars, int64(u)) + b = b[n:] + case gbIntP1, gbIntP2, gbIntP3, gbIntP4, gbIntP5, gbIntP6, gbIntP7, gbIntP8: + b = b[1:] + n := 1 + int(tag) - gbIntP1 + if len(b) < n { + goto corrupted + } + + i := int64(0) + for _, v := range b[:n] { + i = i<<8 | int64(v) + } + scalars = append(scalars, i) + b = b[n:] + default: + scalars = append(scalars, int64(b[0])-gbInt0) + b = b[1:] + } + } + return append([]interface{}(nil), scalars...), nil + +corrupted: + return nil, &ErrDecodeScalars{append([]byte(nil), b0...), len(b0) - len(b)} +} + +func collateComplex(x, y complex128) int { + switch rx, ry := real(x), real(y); { + case rx < ry: + return -1 + case rx == ry: + switch ix, iy := imag(x), imag(y); { + case ix < iy: + return -1 + case ix == iy: + return 0 + case ix > iy: + return 1 + } + } + //case rx > ry: + return 1 +} + +func collateFloat(x, y float64) int { + switch { + case x < y: + return -1 + case x == y: + return 0 + } + //case x > y: + return 1 +} + +func collateInt(x, y int64) int { + switch { + case x < y: + return -1 + case x == y: + return 0 + } + //case x > y: + return 1 +} + +func collateUint(x, y uint64) int { + switch { + case x < y: + return -1 + case x == y: + return 0 + } + //case x > y: + return 1 +} + +func collateIntUint(x int64, y uint64) int { + if y > math.MaxInt64 { + return -1 + } + + return collateInt(x, int64(y)) +} + +func collateUintInt(x uint64, y int64) int { + return -collateIntUint(y, x) +} + +func collateType(i interface{}) (r interface{}, err error) { + switch x := i.(type) { + default: + return nil, fmt.Errorf("invalid collate type %T", x) + case nil: + return i, nil + case bool: + return i, nil + case int8: + return int64(x), nil + case int16: + return int64(x), nil + case int32: + return int64(x), nil + case int64: + return i, nil + case int: + return int64(x), nil + case uint8: + return uint64(x), nil + case uint16: + return uint64(x), nil + case uint32: + return uint64(x), nil + case uint64: + return i, nil + case uint: + return uint64(x), nil + case float32: + return float64(x), nil + case float64: + return i, nil + case complex64: + return complex128(x), nil + case complex128: + return i, nil + case []byte: + return i, nil + case string: + return i, nil + } +} + +// Collate collates two arrays of Go predeclared scalar types (and the typeless +// nil or []byte). If any other type appears in x or y, Collate will return a +// non nil error. String items are collated using strCollate or lexically +// byte-wise (as when using Go comparison operators) when strCollate is nil. +// []byte items are collated using bytes.Compare. +// +// Collate returns: +// +// -1 if x < y +// 0 if x == y +// +1 if x > y +// +// The same value as defined above must be returned from strCollate. +// +// The "outer" ordering is: nil, bool, number, []byte, string. IOW, nil is +// "smaller" than anything else except other nil, numbers collate before +// []byte, []byte collate before strings, etc. +// +// Integers and real numbers collate as expected in math. However, complex +// numbers are not ordered in Go. Here the ordering is defined: Complex numbers +// are in comparison considered first only by their real part. Iff the result +// is equality then the imaginary part is used to determine the ordering. In +// this "second order" comparing, integers and real numbers are considered as +// complex numbers with a zero imaginary part. +func Collate(x, y []interface{}, strCollate func(string, string) int) (r int, err error) { + nx, ny := len(x), len(y) + + switch { + case nx == 0 && ny != 0: + return -1, nil + case nx == 0 && ny == 0: + return 0, nil + case nx != 0 && ny == 0: + return 1, nil + } + + r = 1 + if nx > ny { + x, y, r = y, x, -r + } + + var c int + for i, xi0 := range x { + yi0 := y[i] + xi, err := collateType(xi0) + if err != nil { + return 0, err + } + + yi, err := collateType(yi0) + if err != nil { + return 0, err + } + + switch x := xi.(type) { + default: + panic(fmt.Errorf("internal error: %T", x)) + + case nil: + switch yi.(type) { + case nil: + // nop + default: + return -r, nil + } + + case bool: + switch y := yi.(type) { + case nil: + return r, nil + case bool: + switch { + case !x && y: + return -r, nil + case x == y: + // nop + case x && !y: + return r, nil + } + default: + return -r, nil + } + + case int64: + switch y := yi.(type) { + case nil, bool: + return r, nil + case int64: + c = collateInt(x, y) + case uint64: + c = collateIntUint(x, y) + case float64: + c = collateFloat(float64(x), y) + case complex128: + c = collateComplex(complex(float64(x), 0), y) + case []byte: + return -r, nil + case string: + return -r, nil + } + + if c != 0 { + return c * r, nil + } + + case uint64: + switch y := yi.(type) { + case nil, bool: + return r, nil + case int64: + c = collateUintInt(x, y) + case uint64: + c = collateUint(x, y) + case float64: + c = collateFloat(float64(x), y) + case complex128: + c = collateComplex(complex(float64(x), 0), y) + case []byte: + return -r, nil + case string: + return -r, nil + } + + if c != 0 { + return c * r, nil + } + + case float64: + switch y := yi.(type) { + case nil, bool: + return r, nil + case int64: + c = collateFloat(x, float64(y)) + case uint64: + c = collateFloat(x, float64(y)) + case float64: + c = collateFloat(x, y) + case complex128: + c = collateComplex(complex(x, 0), y) + case []byte: + return -r, nil + case string: + return -r, nil + } + + if c != 0 { + return c * r, nil + } + + case complex128: + switch y := yi.(type) { + case nil, bool: + return r, nil + case int64: + c = collateComplex(x, complex(float64(y), 0)) + case uint64: + c = collateComplex(x, complex(float64(y), 0)) + case float64: + c = collateComplex(x, complex(y, 0)) + case complex128: + c = collateComplex(x, y) + case []byte: + return -r, nil + case string: + return -r, nil + } + + if c != 0 { + return c * r, nil + } + + case []byte: + switch y := yi.(type) { + case nil, bool, int64, uint64, float64, complex128: + return r, nil + case []byte: + c = bytes.Compare(x, y) + case string: + return -r, nil + } + + if c != 0 { + return c * r, nil + } + + case string: + switch y := yi.(type) { + case nil, bool, int64, uint64, float64, complex128: + return r, nil + case []byte: + return r, nil + case string: + switch { + case strCollate != nil: + c = strCollate(x, y) + case x < y: + return -r, nil + case x == y: + c = 0 + case x > y: + return r, nil + } + } + + if c != 0 { + return c * r, nil + } + } + } + + if nx == ny { + return 0, nil + } + + return -r, nil +} diff --git a/vendor/github.com/cznic/exp/lldb/lldb.go b/vendor/github.com/cznic/exp/lldb/lldb.go new file mode 100644 index 0000000000..8f77ec8add --- /dev/null +++ b/vendor/github.com/cznic/exp/lldb/lldb.go @@ -0,0 +1,155 @@ +// Copyright 2014 The lldb 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 lldb (WIP) implements a low level database engine. The database +// model used could be considered a specific implementation of some small(est) +// intersection of models listed in [1]. As a settled term is lacking, it'll be +// called here a 'Virtual memory model' (VMM). +// +// Experimental release notes +// +// This is an experimental release. Don't open a DB from two applications or +// two instances of an application - it will get corrupted (no file locking is +// implemented and this task is delegated to lldb's clients). +// +// WARNING: THE LLDB API IS SUBJECT TO CHANGE. +// +// Filers +// +// A Filer is an abstraction of storage. A Filer may be a part of some process' +// virtual address space, an OS file, a networked, remote file etc. Persistence +// of the storage is optional, opaque to VMM and it is specific to a concrete +// Filer implementation. +// +// Space management +// +// Mechanism to allocate, reallocate (resize), deallocate (and later reclaim +// the unused) contiguous parts of a Filer, called blocks. Blocks are +// identified and referred to by a handle, an int64. +// +// BTrees +// +// In addition to the VMM like services, lldb provides volatile and +// non-volatile BTrees. Keys and values of a BTree are limited in size to 64kB +// each (a bit more actually). Support for larger keys/values, if desired, can +// be built atop a BTree to certain limits. +// +// Handles vs pointers +// +// A handle is the abstracted storage counterpart of a memory address. There +// is one fundamental difference, though. Resizing a block never results in a +// change to the handle which refers to the resized block, so a handle is more +// akin to an unique numeric id/key. Yet it shares one property of pointers - +// handles can be associated again with blocks after the original handle block +// was deallocated. In other words, a handle uniqueness domain is the state of +// the database and is not something comparable to e.g. an ever growing +// numbering sequence. +// +// Also, as with memory pointers, dangling handles can be created and blocks +// overwritten when such handles are used. Using a zero handle to refer to a +// block will not panic; however, the resulting error is effectively the same +// exceptional situation as dereferencing a nil pointer. +// +// Blocks +// +// Allocated/used blocks, are limited in size to only a little bit more than +// 64kB. Bigger semantic entities/structures must be built in lldb's client +// code. The content of a block has no semantics attached, it's only a fully +// opaque `[]byte`. +// +// Scalars +// +// Use of "scalars" applies to EncodeScalars, DecodeScalars and Collate. Those +// first two "to bytes" and "from bytes" functions are suggested for handling +// multi-valued Allocator content items and/or keys/values of BTrees (using +// Collate for keys). Types called "scalar" are: +// +// nil (the typeless one) +// bool +// all integral types: [u]int8, [u]int16, [u]int32, [u]int, [u]int64 +// all floating point types: float32, float64 +// all complex types: complex64, complex128 +// []byte (64kB max) +// string (64kb max) +// +// Specific implementations +// +// Included are concrete implementations of some of the VMM interfaces included +// to ease serving simple client code or for testing and possibly as an +// example. More details in the documentation of such implementations. +// +// [1]: http://en.wikipedia.org/wiki/Database_model +package lldb + +const ( + fltSz = 0x70 // size of the FLT + maxShort = 251 + maxRq = 65787 + maxFLTRq = 4112 + maxHandle = 1<<56 - 1 + atomLen = 16 + tagUsedLong = 0xfc + tagUsedRelocated = 0xfd + tagFreeShort = 0xfe + tagFreeLong = 0xff + tagNotCompressed = 0 + tagCompressed = 1 +) + +// Content size n -> blocksize in atoms. +func n2atoms(n int) int { + if n > maxShort { + n += 2 + } + return (n+1)/16 + 1 +} + +// Content size n -> number of padding zeros. +func n2padding(n int) int { + if n > maxShort { + n += 2 + } + return 15 - (n+1)&15 +} + +// Handle <-> offset +func h2off(h int64) int64 { return (h + 6) * 16 } +func off2h(off int64) int64 { return off/16 - 6 } + +// Get a 7B int64 from b +func b2h(b []byte) (h int64) { + for _, v := range b[:7] { + h = h<<8 | int64(v) + } + return +} + +// Put a 7B int64 into b +func h2b(b []byte, h int64) []byte { + for i := range b[:7] { + b[i], h = byte(h>>48), h<<8 + } + return b +} + +// Content length N (must be in [252, 65787]) to long used block M field. +func n2m(n int) (m int) { + return n % 0x10000 +} + +// Long used block M (must be in [0, 65535]) field to content length N. +func m2n(m int) (n int) { + if m <= maxShort { + m += 0x10000 + } + return m +} + +func bpack(a []byte) []byte { + if cap(a) > len(a) { + return append([]byte(nil), a...) + } + + return a +} diff --git a/vendor/github.com/cznic/exp/lldb/memfiler.go b/vendor/github.com/cznic/exp/lldb/memfiler.go new file mode 100644 index 0000000000..417e92f3aa --- /dev/null +++ b/vendor/github.com/cznic/exp/lldb/memfiler.go @@ -0,0 +1,344 @@ +// Copyright 2014 The lldb Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// A memory-only implementation of Filer. + +/* + +pgBits: 8 +BenchmarkMemFilerWrSeq 100000 19430 ns/op 1646.93 MB/s +BenchmarkMemFilerRdSeq 100000 17390 ns/op 1840.13 MB/s +BenchmarkMemFilerWrRand 1000000 1903 ns/op 133.94 MB/s +BenchmarkMemFilerRdRand 1000000 1153 ns/op 221.16 MB/s + +pgBits: 9 +BenchmarkMemFilerWrSeq 100000 16195 ns/op 1975.80 MB/s +BenchmarkMemFilerRdSeq 200000 13011 ns/op 2459.39 MB/s +BenchmarkMemFilerWrRand 1000000 2248 ns/op 227.28 MB/s +BenchmarkMemFilerRdRand 1000000 1177 ns/op 433.94 MB/s + +pgBits: 10 +BenchmarkMemFilerWrSeq 100000 16169 ns/op 1979.04 MB/s +BenchmarkMemFilerRdSeq 200000 12673 ns/op 2524.91 MB/s +BenchmarkMemFilerWrRand 1000000 5550 ns/op 184.30 MB/s +BenchmarkMemFilerRdRand 1000000 1699 ns/op 601.79 MB/s + +pgBits: 11 +BenchmarkMemFilerWrSeq 100000 13449 ns/op 2379.31 MB/s +BenchmarkMemFilerRdSeq 200000 12058 ns/op 2653.80 MB/s +BenchmarkMemFilerWrRand 500000 4335 ns/op 471.47 MB/s +BenchmarkMemFilerRdRand 1000000 2843 ns/op 719.47 MB/s + +pgBits: 12 +BenchmarkMemFilerWrSeq 200000 11976 ns/op 2672.00 MB/s +BenchmarkMemFilerRdSeq 200000 12255 ns/op 2611.06 MB/s +BenchmarkMemFilerWrRand 200000 8058 ns/op 507.14 MB/s +BenchmarkMemFilerRdRand 500000 4365 ns/op 936.15 MB/s + +pgBits: 13 +BenchmarkMemFilerWrSeq 200000 10852 ns/op 2948.69 MB/s +BenchmarkMemFilerRdSeq 200000 11561 ns/op 2767.77 MB/s +BenchmarkMemFilerWrRand 200000 9748 ns/op 840.15 MB/s +BenchmarkMemFilerRdRand 500000 7236 ns/op 1131.59 MB/s + +pgBits: 14 +BenchmarkMemFilerWrSeq 200000 10328 ns/op 3098.12 MB/s +BenchmarkMemFilerRdSeq 200000 11292 ns/op 2833.66 MB/s +BenchmarkMemFilerWrRand 100000 16768 ns/op 978.75 MB/s +BenchmarkMemFilerRdRand 200000 13033 ns/op 1258.43 MB/s + +pgBits: 15 +BenchmarkMemFilerWrSeq 200000 10309 ns/op 3103.93 MB/s +BenchmarkMemFilerRdSeq 200000 11126 ns/op 2876.12 MB/s +BenchmarkMemFilerWrRand 50000 31985 ns/op 1021.74 MB/s +BenchmarkMemFilerRdRand 100000 25217 ns/op 1297.65 MB/s + +pgBits: 16 +BenchmarkMemFilerWrSeq 200000 10324 ns/op 3099.45 MB/s +BenchmarkMemFilerRdSeq 200000 11201 ns/op 2856.80 MB/s +BenchmarkMemFilerWrRand 20000 55226 ns/op 1184.76 MB/s +BenchmarkMemFilerRdRand 50000 48316 ns/op 1355.16 MB/s + +pgBits: 17 +BenchmarkMemFilerWrSeq 200000 10377 ns/op 3083.53 MB/s +BenchmarkMemFilerRdSeq 200000 11018 ns/op 2904.18 MB/s +BenchmarkMemFilerWrRand 10000 143425 ns/op 913.12 MB/s +BenchmarkMemFilerRdRand 20000 95267 ns/op 1376.99 MB/s + +pgBits: 18 +BenchmarkMemFilerWrSeq 200000 10312 ns/op 3102.96 MB/s +BenchmarkMemFilerRdSeq 200000 11069 ns/op 2890.84 MB/s +BenchmarkMemFilerWrRand 5000 280910 ns/op 934.14 MB/s +BenchmarkMemFilerRdRand 10000 188500 ns/op 1388.17 MB/s + +*/ + +package lldb + +import ( + "bytes" + "fmt" + "io" + + "github.com/cznic/fileutil" + "github.com/cznic/mathutil" +) + +const ( + pgBits = 16 + pgSize = 1 << pgBits + pgMask = pgSize - 1 +) + +var _ Filer = &MemFiler{} // Ensure MemFiler is a Filer. + +type memFilerMap map[int64]*[pgSize]byte + +// MemFiler is a memory backed Filer. It implements BeginUpdate, EndUpdate and +// Rollback as no-ops. MemFiler is not automatically persistent, but it has +// ReadFrom and WriteTo methods. +type MemFiler struct { + m memFilerMap + nest int + size int64 +} + +// NewMemFiler returns a new MemFiler. +func NewMemFiler() *MemFiler { + return &MemFiler{m: memFilerMap{}} +} + +// BeginUpdate implements Filer. +func (f *MemFiler) BeginUpdate() error { + f.nest++ + return nil +} + +// Close implements Filer. +func (f *MemFiler) Close() (err error) { + if f.nest != 0 { + return &ErrPERM{(f.Name() + ":Close")} + } + + return +} + +// EndUpdate implements Filer. +func (f *MemFiler) EndUpdate() (err error) { + if f.nest == 0 { + return &ErrPERM{(f.Name() + ": EndUpdate")} + } + + f.nest-- + return +} + +// Name implements Filer. +func (f *MemFiler) Name() string { + return fmt.Sprintf("%p.memfiler", f) +} + +// PunchHole implements Filer. +func (f *MemFiler) PunchHole(off, size int64) (err error) { + if off < 0 { + return &ErrINVAL{f.Name() + ": PunchHole off", off} + } + + if size < 0 || off+size > f.size { + return &ErrINVAL{f.Name() + ": PunchHole size", size} + } + + first := off >> pgBits + if off&pgMask != 0 { + first++ + } + off += size - 1 + last := off >> pgBits + if off&pgMask != 0 { + last-- + } + if limit := f.size >> pgBits; last > limit { + last = limit + } + for pg := first; pg <= last; pg++ { + delete(f.m, pg) + } + return +} + +var zeroPage [pgSize]byte + +// ReadAt implements Filer. +func (f *MemFiler) ReadAt(b []byte, off int64) (n int, err error) { + avail := f.size - off + pgI := off >> pgBits + pgO := int(off & pgMask) + rem := len(b) + if int64(rem) >= avail { + rem = int(avail) + err = io.EOF + } + for rem != 0 && avail > 0 { + pg := f.m[pgI] + if pg == nil { + pg = &zeroPage + } + nc := copy(b[:mathutil.Min(rem, pgSize)], pg[pgO:]) + pgI++ + pgO = 0 + rem -= nc + n += nc + b = b[nc:] + } + return +} + +// ReadFrom is a helper to populate MemFiler's content from r. 'n' reports the +// number of bytes read from 'r'. +func (f *MemFiler) ReadFrom(r io.Reader) (n int64, err error) { + if err = f.Truncate(0); err != nil { + return + } + + var ( + b [pgSize]byte + rn int + off int64 + ) + + var rerr error + for rerr == nil { + if rn, rerr = r.Read(b[:]); rn != 0 { + f.WriteAt(b[:rn], off) + off += int64(rn) + n += int64(rn) + } + } + if !fileutil.IsEOF(rerr) { + err = rerr + } + return +} + +// Rollback implements Filer. +func (f *MemFiler) Rollback() (err error) { return } + +// Size implements Filer. +func (f *MemFiler) Size() (int64, error) { + return f.size, nil +} + +// Sync implements Filer. +func (f *MemFiler) Sync() error { + return nil +} + +// Truncate implements Filer. +func (f *MemFiler) Truncate(size int64) (err error) { + switch { + case size < 0: + return &ErrINVAL{"Truncate size", size} + case size == 0: + f.m = memFilerMap{} + f.size = 0 + return + } + + first := size >> pgBits + if size&pgMask != 0 { + first++ + } + last := f.size >> pgBits + if f.size&pgMask != 0 { + last++ + } + for ; first < last; first++ { + delete(f.m, first) + } + + f.size = size + return +} + +// WriteAt implements Filer. +func (f *MemFiler) WriteAt(b []byte, off int64) (n int, err error) { + pgI := off >> pgBits + pgO := int(off & pgMask) + n = len(b) + rem := n + var nc int + for rem != 0 { + if pgO == 0 && rem >= pgSize && bytes.Equal(b[:pgSize], zeroPage[:]) { + delete(f.m, pgI) + nc = pgSize + } else { + pg := f.m[pgI] + if pg == nil { + pg = new([pgSize]byte) + f.m[pgI] = pg + } + nc = copy((*pg)[pgO:], b) + } + pgI++ + pgO = 0 + rem -= nc + b = b[nc:] + } + f.size = mathutil.MaxInt64(f.size, off+int64(n)) + return +} + +// WriteTo is a helper to copy/persist MemFiler's content to w. If w is also +// an io.WriterAt then WriteTo may attempt to _not_ write any big, for some +// value of big, runs of zeros, i.e. it will attempt to punch holes, where +// possible, in `w` if that happens to be a freshly created or to zero length +// truncated OS file. 'n' reports the number of bytes written to 'w'. +func (f *MemFiler) WriteTo(w io.Writer) (n int64, err error) { + var ( + b [pgSize]byte + wn, rn int + off int64 + rerr error + ) + + if wa, ok := w.(io.WriterAt); ok { + lastPgI := f.size >> pgBits + for pgI := int64(0); pgI <= lastPgI; pgI++ { + sz := pgSize + if pgI == lastPgI { + sz = int(f.size & pgMask) + } + pg := f.m[pgI] + if pg != nil { + wn, err = wa.WriteAt(pg[:sz], off) + if err != nil { + return + } + + n += int64(wn) + off += int64(sz) + if wn != sz { + return n, io.ErrShortWrite + } + } + } + return + } + + var werr error + for rerr == nil { + if rn, rerr = f.ReadAt(b[:], off); rn != 0 { + off += int64(rn) + if wn, werr = w.Write(b[:rn]); werr != nil { + return n, werr + } + + n += int64(wn) + } + } + if !fileutil.IsEOF(rerr) { + err = rerr + } + return +} diff --git a/vendor/github.com/cznic/exp/lldb/osfiler.go b/vendor/github.com/cznic/exp/lldb/osfiler.go new file mode 100644 index 0000000000..d6e189a18f --- /dev/null +++ b/vendor/github.com/cznic/exp/lldb/osfiler.go @@ -0,0 +1,130 @@ +// Copyright 2014 The lldb 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 lldb + +import ( + "io" + "os" + + "github.com/cznic/mathutil" +) + +var _ Filer = (*OSFiler)(nil) + +// OSFile is an os.File like minimal set of methods allowing to construct a +// Filer. +type OSFile interface { + Name() string + Stat() (fi os.FileInfo, err error) + Sync() (err error) + Truncate(size int64) (err error) + io.Closer + io.Reader + io.ReaderAt + io.Seeker + io.Writer + io.WriterAt +} + +// OSFiler is like a SimpleFileFiler but based on an OSFile. +type OSFiler struct { + f OSFile + nest int + size int64 // not set if < 0 +} + +// NewOSFiler returns a Filer from an OSFile. This Filer is like the +// SimpleFileFiler, it does not implement the transaction related methods. +func NewOSFiler(f OSFile) (r *OSFiler) { + return &OSFiler{ + f: f, + size: -1, + } +} + +// BeginUpdate implements Filer. +func (f *OSFiler) BeginUpdate() (err error) { + f.nest++ + return nil +} + +// Close implements Filer. +func (f *OSFiler) Close() (err error) { + if f.nest != 0 { + return &ErrPERM{(f.Name() + ":Close")} + } + + return f.f.Close() +} + +// EndUpdate implements Filer. +func (f *OSFiler) EndUpdate() (err error) { + if f.nest == 0 { + return &ErrPERM{(f.Name() + ":EndUpdate")} + } + + f.nest-- + return +} + +// Name implements Filer. +func (f *OSFiler) Name() string { + return f.f.Name() +} + +// PunchHole implements Filer. +func (f *OSFiler) PunchHole(off, size int64) (err error) { + return +} + +// ReadAt implements Filer. +func (f *OSFiler) ReadAt(b []byte, off int64) (n int, err error) { + return f.f.ReadAt(b, off) +} + +// Rollback implements Filer. +func (f *OSFiler) Rollback() (err error) { return } + +// Size implements Filer. +func (f *OSFiler) Size() (n int64, err error) { + if f.size < 0 { // boot + fi, err := f.f.Stat() + if err != nil { + return 0, err + } + + f.size = fi.Size() + } + return f.size, nil +} + +// Sync implements Filer. +func (f *OSFiler) Sync() (err error) { + return f.f.Sync() +} + +// Truncate implements Filer. +func (f *OSFiler) Truncate(size int64) (err error) { + if size < 0 { + return &ErrINVAL{"Truncate size", size} + } + + f.size = size + return f.f.Truncate(size) +} + +// WriteAt implements Filer. +func (f *OSFiler) WriteAt(b []byte, off int64) (n int, err error) { + if f.size < 0 { // boot + fi, err := os.Stat(f.f.Name()) + if err != nil { + return 0, err + } + + f.size = fi.Size() + } + f.size = mathutil.MaxInt64(f.size, int64(len(b))+off) + return f.f.WriteAt(b, off) +} diff --git a/vendor/github.com/cznic/exp/lldb/simplefilefiler.go b/vendor/github.com/cznic/exp/lldb/simplefilefiler.go new file mode 100644 index 0000000000..de32e64916 --- /dev/null +++ b/vendor/github.com/cznic/exp/lldb/simplefilefiler.go @@ -0,0 +1,123 @@ +// Copyright 2014 The lldb Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// A basic os.File backed Filer. + +package lldb + +import ( + "os" + + "github.com/cznic/fileutil" + "github.com/cznic/mathutil" +) + +var _ Filer = &SimpleFileFiler{} // Ensure SimpleFileFiler is a Filer. + +// SimpleFileFiler is an os.File backed Filer intended for use where structural +// consistency can be reached by other means (SimpleFileFiler is for example +// wrapped in eg. an RollbackFiler or ACIDFiler0) or where persistence is not +// required (temporary/working data sets). +// +// SimpleFileFiler is the most simple os.File backed Filer implementation as it +// does not really implement BeginUpdate and EndUpdate/Rollback in any way +// which would protect the structural integrity of data. If misused e.g. as a +// real database storage w/o other measures, it can easily cause data loss +// when, for example, a power outage occurs or the updating process terminates +// abruptly. +type SimpleFileFiler struct { + file *os.File + nest int + size int64 // not set if < 0 +} + +// NewSimpleFileFiler returns a new SimpleFileFiler. +func NewSimpleFileFiler(f *os.File) *SimpleFileFiler { + return &SimpleFileFiler{file: f, size: -1} +} + +// BeginUpdate implements Filer. +func (f *SimpleFileFiler) BeginUpdate() error { + f.nest++ + return nil +} + +// Close implements Filer. +func (f *SimpleFileFiler) Close() (err error) { + if f.nest != 0 { + return &ErrPERM{(f.Name() + ":Close")} + } + + return f.file.Close() +} + +// EndUpdate implements Filer. +func (f *SimpleFileFiler) EndUpdate() (err error) { + if f.nest == 0 { + return &ErrPERM{(f.Name() + ":EndUpdate")} + } + + f.nest-- + return +} + +// Name implements Filer. +func (f *SimpleFileFiler) Name() string { + return f.file.Name() +} + +// PunchHole implements Filer. +func (f *SimpleFileFiler) PunchHole(off, size int64) (err error) { + return fileutil.PunchHole(f.file, off, size) +} + +// ReadAt implements Filer. +func (f *SimpleFileFiler) ReadAt(b []byte, off int64) (n int, err error) { + return f.file.ReadAt(b, off) +} + +// Rollback implements Filer. +func (f *SimpleFileFiler) Rollback() (err error) { return } + +// Size implements Filer. +func (f *SimpleFileFiler) Size() (int64, error) { + if f.size < 0 { // boot + fi, err := os.Stat(f.file.Name()) + if err != nil { + return 0, err + } + + f.size = fi.Size() + } + return f.size, nil +} + +// Sync implements Filer. +func (f *SimpleFileFiler) Sync() error { + return f.file.Sync() +} + +// Truncate implements Filer. +func (f *SimpleFileFiler) Truncate(size int64) (err error) { + if size < 0 { + return &ErrINVAL{"Truncate size", size} + } + + f.size = size + return f.file.Truncate(size) +} + +// WriteAt implements Filer. +func (f *SimpleFileFiler) WriteAt(b []byte, off int64) (n int, err error) { + if f.size < 0 { // boot + fi, err := os.Stat(f.file.Name()) + if err != nil { + return 0, err + } + + f.size = fi.Size() + } + f.size = mathutil.MaxInt64(f.size, int64(len(b))+off) + return f.file.WriteAt(b, off) +} diff --git a/vendor/github.com/cznic/exp/lldb/xact.go b/vendor/github.com/cznic/exp/lldb/xact.go new file mode 100644 index 0000000000..f9ad1cbfb7 --- /dev/null +++ b/vendor/github.com/cznic/exp/lldb/xact.go @@ -0,0 +1,629 @@ +// Copyright 2014 The lldb Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Structural transactions. + +package lldb + +//DONE+ TransactionalMemoryFiler +// ---- +// Use NewRollbackFiler(myMemFiler, ...) + +/* + +bfBits: 3 +BenchmarkRollbackFiler 20000000 102 ns/op 9.73 MB/s + +bfBits: 4 +BenchmarkRollbackFiler 50000000 55.7 ns/op 17.95 MB/s + +bfBits: 5 +BenchmarkRollbackFiler 100000000 32.2 ns/op 31.06 MB/s + +bfBits: 6 +BenchmarkRollbackFiler 100000000 20.6 ns/op 48.46 MB/s + +bfBits: 7 +BenchmarkRollbackFiler 100000000 15.1 ns/op 66.12 MB/s + +bfBits: 8 +BenchmarkRollbackFiler 100000000 10.5 ns/op 95.66 MB/s + +bfBits: 9 +BenchmarkRollbackFiler 200000000 8.02 ns/op 124.74 MB/s + +bfBits: 10 +BenchmarkRollbackFiler 200000000 9.25 ns/op 108.09 MB/s + +bfBits: 11 +BenchmarkRollbackFiler 100000000 11.7 ns/op 85.47 MB/s + +bfBits: 12 +BenchmarkRollbackFiler 100000000 17.2 ns/op 57.99 MB/s + +bfBits: 13 +BenchmarkRollbackFiler 100000000 32.7 ns/op 30.58 MB/s + +bfBits: 14 +BenchmarkRollbackFiler 50000000 39.6 ns/op 25.27 MB/s + +*/ + +import ( + "fmt" + "io" + "sync" + + "github.com/cznic/fileutil" + "github.com/cznic/mathutil" +) + +var ( + _ Filer = &bitFiler{} // Ensure bitFiler is a Filer. + _ Filer = &RollbackFiler{} // ditto +) + +const ( + bfBits = 9 + bfSize = 1 << bfBits + bfMask = bfSize - 1 +) + +var ( + bitmask = [8]byte{1, 2, 4, 8, 16, 32, 64, 128} + bitZeroPage bitPage + allDirtyFlags [bfSize >> 3]byte +) + +func init() { + for i := range allDirtyFlags { + allDirtyFlags[i] = 0xff + } +} + +type ( + bitPage struct { + prev, next *bitPage + data [bfSize]byte + flags [bfSize >> 3]byte + dirty bool + } + + bitFilerMap map[int64]*bitPage + + bitFiler struct { + parent Filer + m bitFilerMap + size int64 + } +) + +func newBitFiler(parent Filer) (f *bitFiler, err error) { + sz, err := parent.Size() + if err != nil { + return + } + + return &bitFiler{parent: parent, m: bitFilerMap{}, size: sz}, nil +} + +func (f *bitFiler) BeginUpdate() error { panic("internal error") } +func (f *bitFiler) EndUpdate() error { panic("internal error") } +func (f *bitFiler) Rollback() error { panic("internal error") } +func (f *bitFiler) Sync() error { panic("internal error") } + +func (f *bitFiler) Close() (err error) { return } +func (f *bitFiler) Name() string { return fmt.Sprintf("%p.bitfiler", f) } +func (f *bitFiler) Size() (int64, error) { return f.size, nil } + +func (f *bitFiler) PunchHole(off, size int64) (err error) { + first := off >> bfBits + if off&bfMask != 0 { + first++ + } + off += size - 1 + last := off >> bfBits + if off&bfMask != 0 { + last-- + } + if limit := f.size >> bfBits; last > limit { + last = limit + } + for pgI := first; pgI <= last; pgI++ { + pg := &bitPage{} + pg.flags = allDirtyFlags + f.m[pgI] = pg + } + return +} + +func (f *bitFiler) ReadAt(b []byte, off int64) (n int, err error) { + avail := f.size - off + pgI := off >> bfBits + pgO := int(off & bfMask) + rem := len(b) + if int64(rem) >= avail { + rem = int(avail) + err = io.EOF + } + for rem != 0 && avail > 0 { + pg := f.m[pgI] + if pg == nil { + pg = &bitPage{} + if f.parent != nil { + _, err = f.parent.ReadAt(pg.data[:], off&^bfMask) + if err != nil && !fileutil.IsEOF(err) { + return + } + + err = nil + } + f.m[pgI] = pg + } + nc := copy(b[:mathutil.Min(rem, bfSize)], pg.data[pgO:]) + pgI++ + pgO = 0 + rem -= nc + n += nc + b = b[nc:] + off += int64(nc) + } + return +} + +func (f *bitFiler) Truncate(size int64) (err error) { + switch { + case size < 0: + return &ErrINVAL{"Truncate size", size} + case size == 0: + f.m = bitFilerMap{} + f.size = 0 + return + } + + first := size >> bfBits + if size&bfMask != 0 { + first++ + } + last := f.size >> bfBits + if f.size&bfMask != 0 { + last++ + } + for ; first < last; first++ { + delete(f.m, first) + } + + f.size = size + return +} + +func (f *bitFiler) WriteAt(b []byte, off int64) (n int, err error) { + off0 := off + pgI := off >> bfBits + pgO := int(off & bfMask) + n = len(b) + rem := n + var nc int + for rem != 0 { + pg := f.m[pgI] + if pg == nil { + pg = &bitPage{} + if f.parent != nil { + _, err = f.parent.ReadAt(pg.data[:], off&^bfMask) + if err != nil && !fileutil.IsEOF(err) { + return + } + + err = nil + } + f.m[pgI] = pg + } + nc = copy(pg.data[pgO:], b) + pgI++ + pg.dirty = true + for i := pgO; i < pgO+nc; i++ { + pg.flags[i>>3] |= bitmask[i&7] + } + pgO = 0 + rem -= nc + b = b[nc:] + off += int64(nc) + } + f.size = mathutil.MaxInt64(f.size, off0+int64(n)) + return +} + +func (f *bitFiler) link() { + for pgI, pg := range f.m { + nx, ok := f.m[pgI+1] + if !ok || !nx.dirty { + continue + } + + nx.prev, pg.next = pg, nx + } +} + +func (f *bitFiler) dumpDirty(w io.WriterAt) (nwr int, err error) { + f.link() + for pgI, pg := range f.m { + if !pg.dirty { + continue + } + + for pg.prev != nil && pg.prev.dirty { + pg = pg.prev + pgI-- + } + + for pg != nil && pg.dirty { + last := false + var off int64 + first := -1 + for i := 0; i < bfSize; i++ { + flag := pg.flags[i>>3]&bitmask[i&7] != 0 + switch { + case flag && !last: // Leading edge detected + off = pgI<= 0 { + i := bfSize + n, err := w.WriteAt(pg.data[first:i], off) + if n != i-first { + return 0, err + } + + nwr++ + } + + pg.dirty = false + pg = pg.next + pgI++ + } + } + return +} + +// RollbackFiler is a Filer implementing structural transaction handling. +// Structural transactions should be small and short lived because all non +// committed data are held in memory until committed or discarded by a +// Rollback. +// +// While using RollbackFiler, every intended update of the wrapped Filler, by +// WriteAt, Truncate or PunchHole, _must_ be made within a transaction. +// Attempts to do it outside of a transaction will return ErrPERM. OTOH, +// invoking ReadAt outside of a transaction is not a problem. +// +// No nested transactions: All updates within a transaction are held in memory. +// On a matching EndUpdate the updates held in memory are actually written to +// the wrapped Filer. +// +// Nested transactions: Correct data will be seen from RollbackFiler when any +// level of a nested transaction is rollbacked. The actual writing to the +// wrapped Filer happens only when the outer most transaction nesting level is +// closed. +// +// Invoking Rollback is an alternative to EndUpdate. It discards all changes +// made at the current transaction level and returns the "state" (possibly not +// yet persisted) of the Filer to what it was before the corresponding +// BeginUpdate. +// +// During an open transaction, all reads (using ReadAt) are "dirty" reads, +// seeing the uncommitted changes made to the Filer's data. +// +// Lldb databases should be based upon a RollbackFiler. +// +// With a wrapped MemFiler one gets transactional memory. With, for example a +// wrapped disk based SimpleFileFiler it protects against at least some HW +// errors - if Rollback is properly invoked on such failures and/or if there's +// some WAL or 2PC or whatever other safe mechanism based recovery procedure +// used by the client. +// +// The "real" writes to the wrapped Filer (or WAL instead) go through the +// writerAt supplied to NewRollbackFiler. +// +// List of functions/methods which are recommended to be wrapped in a +// BeginUpdate/EndUpdate structural transaction: +// +// Allocator.Alloc +// Allocator.Free +// Allocator.Realloc +// +// CreateBTree +// RemoveBTree +// BTree.Clear +// BTree.Delete +// BTree.DeleteAny +// BTree.Clear +// BTree.Extract +// BTree.Get (it can mutate the DB) +// BTree.Put +// BTree.Set +// +// NOTE: RollbackFiler is a generic solution intended to wrap Filers provided +// by this package which do not implement any of the transactional methods. +// RollbackFiler thus _does not_ invoke any of the transactional methods of its +// wrapped Filer. +// +// RollbackFiler is safe for concurrent use by multiple goroutines. +type RollbackFiler struct { + mu sync.RWMutex + inCallback bool + inCallbackMu sync.RWMutex + bitFiler *bitFiler + checkpoint func(int64) error + closed bool + f Filer + parent Filer + tlevel int // transaction nesting level, 0 == not in transaction + writerAt io.WriterAt + + // afterRollback, if not nil, is called after performing Rollback + // without errros. + afterRollback func() error +} + +// NewRollbackFiler returns a RollbackFiler wrapping f. +// +// The checkpoint parameter +// +// The checkpoint function is called after closing (by EndUpdate) the upper +// most level open transaction if all calls of writerAt were successful and the +// DB (or eg. a WAL) is thus now in a consistent state (virtually, in the ideal +// world with no write caches, no HW failures, no process crashes, ...). +// +// NOTE: In, for example, a 2PC it is necessary to reflect also the sz +// parameter as the new file size (as in the parameter to Truncate). All +// changes were successfully written already by writerAt before invoking +// checkpoint. +// +// The writerAt parameter +// +// The writerAt interface is used to commit the updates of the wrapped Filer. +// If any invocation of writerAt fails then a non nil error will be returned +// from EndUpdate and checkpoint will _not_ ne called. Neither is necessary to +// call Rollback. The rule of thumb: The [structural] transaction [level] is +// closed by invoking exactly once one of EndUpdate _or_ Rollback. +// +// It is presumed that writerAt uses WAL or 2PC or whatever other safe +// mechanism to physically commit the updates. +// +// Updates performed by invocations of writerAt are byte-precise, but not +// necessarily maximum possible length precise. IOW, for example an update +// crossing page boundaries may be performed by more than one writerAt +// invocation. No offset sorting is performed. This may change if it proves +// to be a problem. Such change would be considered backward compatible. +// +// NOTE: Using RollbackFiler, but failing to ever invoke a matching "closing" +// EndUpdate after an "opening" BeginUpdate means neither writerAt or +// checkpoint will ever get called - with all the possible data loss +// consequences. +func NewRollbackFiler(f Filer, checkpoint func(sz int64) error, writerAt io.WriterAt) (r *RollbackFiler, err error) { + if f == nil || checkpoint == nil || writerAt == nil { + return nil, &ErrINVAL{Src: "lldb.NewRollbackFiler, nil argument"} + } + + return &RollbackFiler{ + checkpoint: checkpoint, + f: f, + writerAt: writerAt, + }, nil +} + +// Implements Filer. +func (r *RollbackFiler) BeginUpdate() (err error) { + r.mu.Lock() + defer r.mu.Unlock() + + parent := r.f + if r.tlevel != 0 { + parent = r.bitFiler + } + r.bitFiler, err = newBitFiler(parent) + if err != nil { + return + } + + r.tlevel++ + return +} + +// Implements Filer. +// +// Close will return an error if not invoked at nesting level 0. However, to +// allow emergency closing from eg. a signal handler; if Close is invoked +// within an open transaction(s), it rollbacks any non committed open +// transactions and performs the Close operation. +// +// IOW: Regardless of the transaction nesting level the Close is always +// performed but any uncommitted transaction data are lost. +func (r *RollbackFiler) Close() (err error) { + r.mu.Lock() + defer r.mu.Unlock() + + if r.closed { + return &ErrPERM{r.f.Name() + ": Already closed"} + } + + r.closed = true + if err = r.f.Close(); err != nil { + return + } + + if r.tlevel != 0 { + err = &ErrPERM{r.f.Name() + ": Close inside an open transaction"} + } + + return +} + +// Implements Filer. +func (r *RollbackFiler) EndUpdate() (err error) { + r.mu.Lock() + defer r.mu.Unlock() + + if r.tlevel == 0 { + return &ErrPERM{r.f.Name() + " : EndUpdate outside of a transaction"} + } + + sz, err := r.size() // Cannot call .Size() -> deadlock + if err != nil { + return + } + + r.tlevel-- + bf := r.bitFiler + parent := bf.parent + w := r.writerAt + if r.tlevel != 0 { + w = parent + } + nwr, err := bf.dumpDirty(w) + if err != nil { + return + } + + switch { + case r.tlevel == 0: + r.bitFiler = nil + if nwr == 0 { + return + } + + return r.checkpoint(sz) + default: + r.bitFiler = parent.(*bitFiler) + sz, _ := bf.Size() // bitFiler.Size() never returns err != nil + return parent.Truncate(sz) + } +} + +// Implements Filer. +func (r *RollbackFiler) Name() string { + r.mu.RLock() + defer r.mu.RUnlock() + + return r.f.Name() +} + +// Implements Filer. +func (r *RollbackFiler) PunchHole(off, size int64) error { + r.mu.Lock() + defer r.mu.Unlock() + + if r.tlevel == 0 { + return &ErrPERM{r.f.Name() + ": PunchHole outside of a transaction"} + } + + if off < 0 { + return &ErrINVAL{r.f.Name() + ": PunchHole off", off} + } + + if size < 0 || off+size > r.bitFiler.size { + return &ErrINVAL{r.f.Name() + ": PunchHole size", size} + } + + return r.bitFiler.PunchHole(off, size) +} + +// Implements Filer. +func (r *RollbackFiler) ReadAt(b []byte, off int64) (n int, err error) { + r.inCallbackMu.RLock() + defer r.inCallbackMu.RUnlock() + if !r.inCallback { + r.mu.RLock() + defer r.mu.RUnlock() + } + if r.tlevel == 0 { + return r.f.ReadAt(b, off) + } + + return r.bitFiler.ReadAt(b, off) +} + +// Implements Filer. +func (r *RollbackFiler) Rollback() (err error) { + r.mu.Lock() + defer r.mu.Unlock() + + if r.tlevel == 0 { + return &ErrPERM{r.f.Name() + ": Rollback outside of a transaction"} + } + + if r.tlevel > 1 { + r.bitFiler = r.bitFiler.parent.(*bitFiler) + } + r.tlevel-- + if f := r.afterRollback; f != nil { + r.inCallbackMu.Lock() + r.inCallback = true + r.inCallbackMu.Unlock() + defer func() { + r.inCallbackMu.Lock() + r.inCallback = false + r.inCallbackMu.Unlock() + }() + return f() + } + return +} + +func (r *RollbackFiler) size() (sz int64, err error) { + if r.tlevel == 0 { + return r.f.Size() + } + + return r.bitFiler.Size() +} + +// Implements Filer. +func (r *RollbackFiler) Size() (sz int64, err error) { + r.mu.Lock() + defer r.mu.Unlock() + + return r.size() +} + +// Implements Filer. +func (r *RollbackFiler) Sync() error { + r.mu.Lock() + defer r.mu.Unlock() + + return r.f.Sync() +} + +// Implements Filer. +func (r *RollbackFiler) Truncate(size int64) error { + r.mu.Lock() + defer r.mu.Unlock() + + if r.tlevel == 0 { + return &ErrPERM{r.f.Name() + ": Truncate outside of a transaction"} + } + + return r.bitFiler.Truncate(size) +} + +// Implements Filer. +func (r *RollbackFiler) WriteAt(b []byte, off int64) (n int, err error) { + r.mu.Lock() + defer r.mu.Unlock() + + if r.tlevel == 0 { + return 0, &ErrPERM{r.f.Name() + ": WriteAt outside of a transaction"} + } + + return r.bitFiler.WriteAt(b, off) +} diff --git a/vendor/github.com/cznic/fileutil/LICENSE b/vendor/github.com/cznic/fileutil/LICENSE new file mode 100644 index 0000000000..50bbdd2410 --- /dev/null +++ b/vendor/github.com/cznic/fileutil/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2014 The fileutil 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 names of the authors nor the names of the +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. diff --git a/vendor/github.com/cznic/fileutil/fileutil.go b/vendor/github.com/cznic/fileutil/fileutil.go new file mode 100644 index 0000000000..2f0f7ab155 --- /dev/null +++ b/vendor/github.com/cznic/fileutil/fileutil.go @@ -0,0 +1,223 @@ +// Copyright (c) 2014 The fileutil 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 fileutil collects some file utility functions. +package fileutil + +import ( + "fmt" + "io" + "os" + "path/filepath" + "runtime" + "strconv" + "sync" + "time" +) + +// GoMFile is a concurrent access safe version of MFile. +type GoMFile struct { + mfile *MFile + mutex sync.Mutex +} + +// NewGoMFile return a newly created GoMFile. +func NewGoMFile(fname string, flag int, perm os.FileMode, delta_ns int64) (m *GoMFile, err error) { + m = &GoMFile{} + if m.mfile, err = NewMFile(fname, flag, perm, delta_ns); err != nil { + m = nil + } + return +} + +func (m *GoMFile) File() (file *os.File, err error) { + m.mutex.Lock() + defer m.mutex.Unlock() + return m.mfile.File() +} + +func (m *GoMFile) SetChanged() { + m.mutex.Lock() + defer m.mutex.Unlock() + m.mfile.SetChanged() +} + +func (m *GoMFile) SetHandler(h MFileHandler) { + m.mutex.Lock() + defer m.mutex.Unlock() + m.mfile.SetHandler(h) +} + +// MFileHandler resolves modifications of File. +// Possible File context is expected to be a part of the handler's closure. +type MFileHandler func(*os.File) error + +// MFile represents an os.File with a guard/handler on change/modification. +// Example use case is an app with a configuration file which can be modified at any time +// and have to be reloaded in such event prior to performing something configurable by that +// file. The checks are made only on access to the MFile file by +// File() and a time threshold/hysteresis value can be chosen on creating a new MFile. +type MFile struct { + file *os.File + handler MFileHandler + t0 int64 + delta int64 + ctime int64 +} + +// NewMFile returns a newly created MFile or Error if any. +// The fname, flag and perm parameters have the same meaning as in os.Open. +// For meaning of the delta_ns parameter please see the (m *MFile) File() docs. +func NewMFile(fname string, flag int, perm os.FileMode, delta_ns int64) (m *MFile, err error) { + m = &MFile{} + m.t0 = time.Now().UnixNano() + if m.file, err = os.OpenFile(fname, flag, perm); err != nil { + return + } + + var fi os.FileInfo + if fi, err = m.file.Stat(); err != nil { + return + } + + m.ctime = fi.ModTime().UnixNano() + m.delta = delta_ns + runtime.SetFinalizer(m, func(m *MFile) { + m.file.Close() + }) + return +} + +// SetChanged forces next File() to unconditionally handle modification of the wrapped os.File. +func (m *MFile) SetChanged() { + m.ctime = -1 +} + +// SetHandler sets a function to be invoked when modification of MFile is to be processed. +func (m *MFile) SetHandler(h MFileHandler) { + m.handler = h +} + +// File returns an os.File from MFile. If time elapsed between the last invocation of this function +// and now is at least delta_ns ns (a parameter of NewMFile) then the file is checked for +// change/modification. For delta_ns == 0 the modification is checked w/o getting os.Time(). +// If a change is detected a handler is invoked on the MFile file. +// Any of these steps can produce an Error. If that happens the function returns nil, Error. +func (m *MFile) File() (file *os.File, err error) { + var now int64 + + mustCheck := m.delta == 0 + if !mustCheck { + now = time.Now().UnixNano() + mustCheck = now-m.t0 > m.delta + } + + if mustCheck { // check interval reached + var fi os.FileInfo + if fi, err = m.file.Stat(); err != nil { + return + } + + if fi.ModTime().UnixNano() != m.ctime { // modification detected + if m.handler == nil { + return nil, fmt.Errorf("no handler set for modified file %q", m.file.Name()) + } + if err = m.handler(m.file); err != nil { + return + } + + m.ctime = fi.ModTime().UnixNano() + } + m.t0 = now + } + + return m.file, nil +} + +// Read reads buf from r. It will either fill the full buf or fail. +// It wraps the functionality of an io.Reader which may return less bytes than requested, +// but may block if not all data are ready for the io.Reader. +func Read(r io.Reader, buf []byte) (err error) { + have := 0 + remain := len(buf) + got := 0 + for remain > 0 { + if got, err = r.Read(buf[have:]); err != nil { + return + } + + remain -= got + have += got + } + return +} + +// "os" and/or "syscall" extensions + +// FadviseAdvice is used by Fadvise. +type FadviseAdvice int + +// FAdviseAdvice values. +const ( + // $ grep FADV /usr/include/bits/fcntl.h + POSIX_FADV_NORMAL FadviseAdvice = iota // No further special treatment. + POSIX_FADV_RANDOM // Expect random page references. + POSIX_FADV_SEQUENTIAL // Expect sequential page references. + POSIX_FADV_WILLNEED // Will need these pages. + POSIX_FADV_DONTNEED // Don't need these pages. + POSIX_FADV_NOREUSE // Data will be accessed once. +) + +// TempFile creates a new temporary file in the directory dir with a name +// ending with suffix, basename starting with prefix, opens the file for +// reading and writing, and returns the resulting *os.File. If dir is the +// empty string, TempFile uses the default directory for temporary files (see +// os.TempDir). Multiple programs calling TempFile simultaneously will not +// choose the same file. The caller can use f.Name() to find the pathname of +// the file. It is the caller's responsibility to remove the file when no +// longer needed. +// +// NOTE: This function differs from ioutil.TempFile. +func TempFile(dir, prefix, suffix string) (f *os.File, err error) { + if dir == "" { + dir = os.TempDir() + } + + nconflict := 0 + for i := 0; i < 10000; i++ { + name := filepath.Join(dir, prefix+nextInfix()+suffix) + f, err = os.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600) + if os.IsExist(err) { + if nconflict++; nconflict > 10 { + rand = reseed() + } + continue + } + break + } + return +} + +// Random number state. +// We generate random temporary file names so that there's a good +// chance the file doesn't exist yet - keeps the number of tries in +// TempFile to a minimum. +var rand uint32 +var randmu sync.Mutex + +func reseed() uint32 { + return uint32(time.Now().UnixNano() + int64(os.Getpid())) +} + +func nextInfix() string { + randmu.Lock() + r := rand + if r == 0 { + r = reseed() + } + r = r*1664525 + 1013904223 // constants from Numerical Recipes + rand = r + randmu.Unlock() + return strconv.Itoa(int(1e9 + r%1e9))[1:] +} diff --git a/vendor/github.com/cznic/fileutil/fileutil_arm.go b/vendor/github.com/cznic/fileutil/fileutil_arm.go new file mode 100644 index 0000000000..9410d1bb26 --- /dev/null +++ b/vendor/github.com/cznic/fileutil/fileutil_arm.go @@ -0,0 +1,25 @@ +// Copyright (c) 2014 The fileutil 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 fileutil + +import ( + "io" + "os" +) + +// PunchHole deallocates space inside a file in the byte range starting at +// offset and continuing for len bytes. Not supported on ARM. +func PunchHole(f *os.File, off, len int64) error { + return nil +} + +// Fadvise predeclares an access pattern for file data. See also 'man 2 +// posix_fadvise'. Not supported on ARM. +func Fadvise(f *os.File, off, len int64, advice FadviseAdvice) error { + return nil +} + +// IsEOF reports whether err is an EOF condition. +func IsEOF(err error) bool { return err == io.EOF } diff --git a/vendor/github.com/cznic/fileutil/fileutil_darwin.go b/vendor/github.com/cznic/fileutil/fileutil_darwin.go new file mode 100644 index 0000000000..a19723fc78 --- /dev/null +++ b/vendor/github.com/cznic/fileutil/fileutil_darwin.go @@ -0,0 +1,25 @@ +// Copyright (c) 2014 The fileutil 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 fileutil + +import ( + "io" + "os" +) + +// PunchHole deallocates space inside a file in the byte range starting at +// offset and continuing for len bytes. Not supported on OSX. +func PunchHole(f *os.File, off, len int64) error { + return nil +} + +// Fadvise predeclares an access pattern for file data. See also 'man 2 +// posix_fadvise'. Not supported on OSX. +func Fadvise(f *os.File, off, len int64, advice FadviseAdvice) error { + return nil +} + +// IsEOF reports whether err is an EOF condition. +func IsEOF(err error) bool { return err == io.EOF } diff --git a/vendor/github.com/cznic/fileutil/fileutil_freebsd.go b/vendor/github.com/cznic/fileutil/fileutil_freebsd.go new file mode 100644 index 0000000000..0865093e2b --- /dev/null +++ b/vendor/github.com/cznic/fileutil/fileutil_freebsd.go @@ -0,0 +1,25 @@ +// Copyright (c) 2014 The fileutil 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 fileutil + +import ( + "io" + "os" +) + +// PunchHole deallocates space inside a file in the byte range starting at +// offset and continuing for len bytes. Unimplemented on FreeBSD. +func PunchHole(f *os.File, off, len int64) error { + return nil +} + +// Fadvise predeclares an access pattern for file data. See also 'man 2 +// posix_fadvise'. Unimplemented on FreeBSD. +func Fadvise(f *os.File, off, len int64, advice FadviseAdvice) error { + return nil +} + +// IsEOF reports whether err is an EOF condition. +func IsEOF(err error) bool { return err == io.EOF } diff --git a/vendor/github.com/cznic/fileutil/fileutil_linux.go b/vendor/github.com/cznic/fileutil/fileutil_linux.go new file mode 100644 index 0000000000..8babfc5533 --- /dev/null +++ b/vendor/github.com/cznic/fileutil/fileutil_linux.go @@ -0,0 +1,96 @@ +// Copyright (c) 2014 The fileutil 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 !arm + +package fileutil + +import ( + "bytes" + "io" + "io/ioutil" + "os" + "strconv" + "syscall" +) + +func n(s []byte) byte { + for i, c := range s { + if c < '0' || c > '9' { + s = s[:i] + break + } + } + v, _ := strconv.Atoi(string(s)) + return byte(v) +} + +func init() { + b, err := ioutil.ReadFile("/proc/sys/kernel/osrelease") + if err != nil { + panic(err) + } + + tokens := bytes.Split(b, []byte(".")) + if len(tokens) > 3 { + tokens = tokens[:3] + } + switch len(tokens) { + case 3: + // Supported since kernel 2.6.38 + if bytes.Compare([]byte{n(tokens[0]), n(tokens[1]), n(tokens[2])}, []byte{2, 6, 38}) < 0 { + puncher = func(*os.File, int64, int64) error { return nil } + } + case 2: + if bytes.Compare([]byte{n(tokens[0]), n(tokens[1])}, []byte{2, 7}) < 0 { + puncher = func(*os.File, int64, int64) error { return nil } + } + default: + puncher = func(*os.File, int64, int64) error { return nil } + } +} + +var puncher = func(f *os.File, off, len int64) error { + const ( + /* + /usr/include/linux$ grep FL_ falloc.h + */ + _FALLOC_FL_KEEP_SIZE = 0x01 // default is extend size + _FALLOC_FL_PUNCH_HOLE = 0x02 // de-allocates range + ) + + _, _, errno := syscall.Syscall6( + syscall.SYS_FALLOCATE, + uintptr(f.Fd()), + uintptr(_FALLOC_FL_KEEP_SIZE|_FALLOC_FL_PUNCH_HOLE), + uintptr(off), + uintptr(len), + 0, 0) + if errno != 0 { + return os.NewSyscallError("SYS_FALLOCATE", errno) + } + return nil +} + +// PunchHole deallocates space inside a file in the byte range starting at +// offset and continuing for len bytes. No-op for kernels < 2.6.38 (or < 2.7). +func PunchHole(f *os.File, off, len int64) error { + return puncher(f, off, len) +} + +// Fadvise predeclares an access pattern for file data. See also 'man 2 +// posix_fadvise'. +func Fadvise(f *os.File, off, len int64, advice FadviseAdvice) error { + _, _, errno := syscall.Syscall6( + syscall.SYS_FADVISE64, + uintptr(f.Fd()), + uintptr(off), + uintptr(len), + uintptr(advice), + 0, 0) + return os.NewSyscallError("SYS_FADVISE64", errno) +} + +// IsEOF reports whether err is an EOF condition. +func IsEOF(err error) bool { return err == io.EOF } diff --git a/vendor/github.com/cznic/fileutil/fileutil_openbsd.go b/vendor/github.com/cznic/fileutil/fileutil_openbsd.go new file mode 100644 index 0000000000..428171bdfe --- /dev/null +++ b/vendor/github.com/cznic/fileutil/fileutil_openbsd.go @@ -0,0 +1,25 @@ +// Copyright (c) 2014 The fileutil 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 fileutil + +import ( + "io" + "os" +) + +// PunchHole deallocates space inside a file in the byte range starting at +// offset and continuing for len bytes. Similar to FreeBSD, this is +// unimplemented. +func PunchHole(f *os.File, off, len int64) error { + return nil +} + +// Unimplemented on OpenBSD. +func Fadvise(f *os.File, off, len int64, advice FadviseAdvice) error { + return nil +} + +// IsEOF reports whether err is an EOF condition. +func IsEOF(err error) bool { return err == io.EOF } diff --git a/vendor/github.com/cznic/fileutil/fileutil_plan9.go b/vendor/github.com/cznic/fileutil/fileutil_plan9.go new file mode 100644 index 0000000000..a2db64e2d3 --- /dev/null +++ b/vendor/github.com/cznic/fileutil/fileutil_plan9.go @@ -0,0 +1,25 @@ +// Copyright (c) 2014 The fileutil 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 fileutil + +import ( + "io" + "os" +) + +// PunchHole deallocates space inside a file in the byte range starting at +// offset and continuing for len bytes. Unimplemented on Plan 9. +func PunchHole(f *os.File, off, len int64) error { + return nil +} + +// Fadvise predeclares an access pattern for file data. See also 'man 2 +// posix_fadvise'. Unimplemented on Plan 9. +func Fadvise(f *os.File, off, len int64, advice FadviseAdvice) error { + return nil +} + +// IsEOF reports whether err is an EOF condition. +func IsEOF(err error) bool { return err == io.EOF } diff --git a/vendor/github.com/cznic/fileutil/fileutil_solaris.go b/vendor/github.com/cznic/fileutil/fileutil_solaris.go new file mode 100644 index 0000000000..61dfcde38f --- /dev/null +++ b/vendor/github.com/cznic/fileutil/fileutil_solaris.go @@ -0,0 +1,27 @@ +// Copyright (c) 2013 jnml. 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.3 + +package fileutil + +import ( + "io" + "os" +) + +// PunchHole deallocates space inside a file in the byte range starting at +// offset and continuing for len bytes. Not supported on Solaris. +func PunchHole(f *os.File, off, len int64) error { + return nil +} + +// Fadvise predeclares an access pattern for file data. See also 'man 2 +// posix_fadvise'. Not supported on Solaris. +func Fadvise(f *os.File, off, len int64, advice FadviseAdvice) error { + return nil +} + +// IsEOF reports whether err is an EOF condition. +func IsEOF(err error) bool { return err == io.EOF } diff --git a/vendor/github.com/cznic/fileutil/fileutil_windows.go b/vendor/github.com/cznic/fileutil/fileutil_windows.go new file mode 100644 index 0000000000..3a81f2fc87 --- /dev/null +++ b/vendor/github.com/cznic/fileutil/fileutil_windows.go @@ -0,0 +1,183 @@ +// Copyright (c) 2014 The fileutil 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 fileutil + +import ( + "io" + "os" + "sync" + "syscall" + "unsafe" +) + +// PunchHole deallocates space inside a file in the byte range starting at +// offset and continuing for len bytes. Not supported on Windows. +func PunchHole(f *os.File, off, len int64) error { + return puncher(f, off, len) +} + +// Fadvise predeclares an access pattern for file data. See also 'man 2 +// posix_fadvise'. Not supported on Windows. +func Fadvise(f *os.File, off, len int64, advice FadviseAdvice) error { + return nil +} + +// IsEOF reports whether err is an EOF condition. +func IsEOF(err error) bool { + if err == io.EOF { + return true + } + + // http://social.technet.microsoft.com/Forums/windowsserver/en-US/1a16311b-c625-46cf-830b-6a26af488435/how-to-solve-error-38-0x26-errorhandleeof-using-fsctlgetretrievalpointers + x, ok := err.(*os.PathError) + return ok && x.Op == "read" && x.Err.(syscall.Errno) == 0x26 +} + +var ( + modkernel32 = syscall.NewLazyDLL("kernel32.dll") + + procDeviceIOControl = modkernel32.NewProc("DeviceIoControl") + + sparseFilesMu sync.Mutex + sparseFiles map[uintptr]struct{} +) + +func init() { + // sparseFiles is an fd set for already "sparsed" files - according to + // msdn.microsoft.com/en-us/library/windows/desktop/aa364225(v=vs.85).aspx + // the file handles are unique per process. + sparseFiles = make(map[uintptr]struct{}) +} + +// puncHoleWindows punches a hole into the given file starting at offset, +// measuring "size" bytes +// (http://msdn.microsoft.com/en-us/library/windows/desktop/aa364597%28v=vs.85%29.aspx) +func puncher(file *os.File, offset, size int64) error { + if err := ensureFileSparse(file); err != nil { + return err + } + + // http://msdn.microsoft.com/en-us/library/windows/desktop/aa364411%28v=vs.85%29.aspx + // typedef struct _FILE_ZERO_DATA_INFORMATION { + // LARGE_INTEGER FileOffset; + // LARGE_INTEGER BeyondFinalZero; + //} FILE_ZERO_DATA_INFORMATION, *PFILE_ZERO_DATA_INFORMATION; + type fileZeroDataInformation struct { + FileOffset, BeyondFinalZero int64 + } + + lpInBuffer := fileZeroDataInformation{ + FileOffset: offset, + BeyondFinalZero: offset + size} + return deviceIOControl(false, file.Fd(), uintptr(unsafe.Pointer(&lpInBuffer)), 16) +} + +// // http://msdn.microsoft.com/en-us/library/windows/desktop/cc948908%28v=vs.85%29.aspx +// type fileSetSparseBuffer struct { +// SetSparse bool +// } + +func ensureFileSparse(file *os.File) (err error) { + fd := file.Fd() + sparseFilesMu.Lock() + if _, ok := sparseFiles[fd]; ok { + sparseFilesMu.Unlock() + return nil + } + + if err = deviceIOControl(true, fd, 0, 0); err == nil { + sparseFiles[fd] = struct{}{} + } + sparseFilesMu.Unlock() + return err +} + +func deviceIOControl(setSparse bool, fd, inBuf, inBufLen uintptr) (err error) { + const ( + //http://source.winehq.org/source/include/winnt.h#L4605 + file_read_data = 1 + file_write_data = 2 + + // METHOD_BUFFERED 0 + method_buffered = 0 + // FILE_ANY_ACCESS 0 + file_any_access = 0 + // FILE_DEVICE_FILE_SYSTEM 0x00000009 + file_device_file_system = 0x00000009 + // FILE_SPECIAL_ACCESS (FILE_ANY_ACCESS) + file_special_access = file_any_access + file_read_access = file_read_data + file_write_access = file_write_data + + // http://source.winehq.org/source/include/winioctl.h + // #define CTL_CODE ( DeviceType, + // Function, + // Method, + // Access ) + // ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) + + // FSCTL_SET_COMPRESSION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 16, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA) + fsctl_set_compression = (file_device_file_system << 16) | ((file_read_access | file_write_access) << 14) | (16 << 2) | method_buffered + // FSCTL_SET_SPARSE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 49, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) + fsctl_set_sparse = (file_device_file_system << 16) | (file_special_access << 14) | (49 << 2) | method_buffered + // FSCTL_SET_ZERO_DATA CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 50, METHOD_BUFFERED, FILE_WRITE_DATA) + fsctl_set_zero_data = (file_device_file_system << 16) | (file_write_data << 14) | (50 << 2) | method_buffered + ) + retPtr := uintptr(unsafe.Pointer(&(make([]byte, 8)[0]))) + var r1 uintptr + var e1 syscall.Errno + if setSparse { + // BOOL + // WINAPI + // DeviceIoControl( (HANDLE) hDevice, // handle to a file + // FSCTL_SET_SPARSE, // dwIoControlCode + // (PFILE_SET_SPARSE_BUFFER) lpInBuffer, // input buffer + // (DWORD) nInBufferSize, // size of input buffer + // NULL, // lpOutBuffer + // 0, // nOutBufferSize + // (LPDWORD) lpBytesReturned, // number of bytes returned + // (LPOVERLAPPED) lpOverlapped ); // OVERLAPPED structure + r1, _, e1 = syscall.Syscall9(procDeviceIOControl.Addr(), 8, + fd, + uintptr(fsctl_set_sparse), + // If the lpInBuffer parameter is NULL, the operation will behave the same as if the SetSparse member of the FILE_SET_SPARSE_BUFFER structure were TRUE. In other words, the operation sets the file to a sparse file. + 0, // uintptr(unsafe.Pointer(&lpInBuffer)), + 0, // 1, + 0, + 0, + retPtr, + 0, + 0) + } else { + // BOOL + // WINAPI + // DeviceIoControl( (HANDLE) hDevice, // handle to a file + // FSCTL_SET_ZERO_DATA, // dwIoControlCode + // (LPVOID) lpInBuffer, // input buffer + // (DWORD) nInBufferSize, // size of input buffer + // NULL, // lpOutBuffer + // 0, // nOutBufferSize + // (LPDWORD) lpBytesReturned, // number of bytes returned + // (LPOVERLAPPED) lpOverlapped ); // OVERLAPPED structure + r1, _, e1 = syscall.Syscall9(procDeviceIOControl.Addr(), 8, + fd, + uintptr(fsctl_set_zero_data), + inBuf, + inBufLen, + 0, + 0, + retPtr, + 0, + 0) + } + if r1 == 0 { + if e1 != 0 { + err = error(e1) + } else { + err = syscall.EINVAL + } + } + return err +} diff --git a/vendor/github.com/cznic/fileutil/test_deps.go b/vendor/github.com/cznic/fileutil/test_deps.go new file mode 100644 index 0000000000..eec608ab3a --- /dev/null +++ b/vendor/github.com/cznic/fileutil/test_deps.go @@ -0,0 +1,13 @@ +// Copyright (c) 2014 The fileutil Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// blame: jnml, labs.nic.cz + +package fileutil + +// Pull test dependencies too. +// Enables easy 'go test X' after 'go get X' +import ( +// nothing yet +) diff --git a/vendor/github.com/cznic/mathutil/LICENSE b/vendor/github.com/cznic/mathutil/LICENSE new file mode 100644 index 0000000000..128a1b64a4 --- /dev/null +++ b/vendor/github.com/cznic/mathutil/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2014 The mathutil 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 names of the authors nor the names of the +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. diff --git a/vendor/github.com/cznic/mathutil/bits.go b/vendor/github.com/cznic/mathutil/bits.go new file mode 100644 index 0000000000..6eaa4e3054 --- /dev/null +++ b/vendor/github.com/cznic/mathutil/bits.go @@ -0,0 +1,207 @@ +// Copyright (c) 2014 The mathutil 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 mathutil + +import ( + "math/big" +) + +// BitLenByte returns the bit width of the non zero part of n. +func BitLenByte(n byte) int { + return log2[n] + 1 +} + +// BitLenUint16 returns the bit width of the non zero part of n. +func BitLenUint16(n uint16) int { + if b := n >> 8; b != 0 { + return log2[b] + 8 + 1 + } + + return log2[n] + 1 +} + +// BitLenUint32 returns the bit width of the non zero part of n. +func BitLenUint32(n uint32) int { + if b := n >> 24; b != 0 { + return log2[b] + 24 + 1 + } + + if b := n >> 16; b != 0 { + return log2[b] + 16 + 1 + } + + if b := n >> 8; b != 0 { + return log2[b] + 8 + 1 + } + + return log2[n] + 1 +} + +// BitLen returns the bit width of the non zero part of n. +func BitLen(n int) int { // Should handle correctly [future] 64 bit Go ints + if IntBits == 64 { + return BitLenUint64(uint64(n)) + } + + if b := byte(n >> 24); b != 0 { + return log2[b] + 24 + 1 + } + + if b := byte(n >> 16); b != 0 { + return log2[b] + 16 + 1 + } + + if b := byte(n >> 8); b != 0 { + return log2[b] + 8 + 1 + } + + return log2[byte(n)] + 1 +} + +// BitLenUint returns the bit width of the non zero part of n. +func BitLenUint(n uint) int { // Should handle correctly [future] 64 bit Go uints + if IntBits == 64 { + return BitLenUint64(uint64(n)) + } + + if b := n >> 24; b != 0 { + return log2[b] + 24 + 1 + } + + if b := n >> 16; b != 0 { + return log2[b] + 16 + 1 + } + + if b := n >> 8; b != 0 { + return log2[b] + 8 + 1 + } + + return log2[n] + 1 +} + +// BitLenUint64 returns the bit width of the non zero part of n. +func BitLenUint64(n uint64) int { + if b := n >> 56; b != 0 { + return log2[b] + 56 + 1 + } + + if b := n >> 48; b != 0 { + return log2[b] + 48 + 1 + } + + if b := n >> 40; b != 0 { + return log2[b] + 40 + 1 + } + + if b := n >> 32; b != 0 { + return log2[b] + 32 + 1 + } + + if b := n >> 24; b != 0 { + return log2[b] + 24 + 1 + } + + if b := n >> 16; b != 0 { + return log2[b] + 16 + 1 + } + + if b := n >> 8; b != 0 { + return log2[b] + 8 + 1 + } + + return log2[n] + 1 +} + +// BitLenUintptr returns the bit width of the non zero part of n. +func BitLenUintptr(n uintptr) int { + if b := n >> 56; b != 0 { + return log2[b] + 56 + 1 + } + + if b := n >> 48; b != 0 { + return log2[b] + 48 + 1 + } + + if b := n >> 40; b != 0 { + return log2[b] + 40 + 1 + } + + if b := n >> 32; b != 0 { + return log2[b] + 32 + 1 + } + + if b := n >> 24; b != 0 { + return log2[b] + 24 + 1 + } + + if b := n >> 16; b != 0 { + return log2[b] + 16 + 1 + } + + if b := n >> 8; b != 0 { + return log2[b] + 8 + 1 + } + + return log2[n] + 1 +} + +// PopCountByte returns population count of n (number of bits set in n). +func PopCountByte(n byte) int { + return int(popcnt[byte(n)]) +} + +// PopCountUint16 returns population count of n (number of bits set in n). +func PopCountUint16(n uint16) int { + return int(popcnt[byte(n>>8)]) + int(popcnt[byte(n)]) +} + +// PopCountUint32 returns population count of n (number of bits set in n). +func PopCountUint32(n uint32) int { + return int(popcnt[byte(n>>24)]) + int(popcnt[byte(n>>16)]) + + int(popcnt[byte(n>>8)]) + int(popcnt[byte(n)]) +} + +// PopCount returns population count of n (number of bits set in n). +func PopCount(n int) int { // Should handle correctly [future] 64 bit Go ints + if IntBits == 64 { + return PopCountUint64(uint64(n)) + } + + return PopCountUint32(uint32(n)) +} + +// PopCountUint returns population count of n (number of bits set in n). +func PopCountUint(n uint) int { // Should handle correctly [future] 64 bit Go uints + if IntBits == 64 { + return PopCountUint64(uint64(n)) + } + + return PopCountUint32(uint32(n)) +} + +// PopCountUintptr returns population count of n (number of bits set in n). +func PopCountUintptr(n uintptr) int { + if UintPtrBits == 64 { + return PopCountUint64(uint64(n)) + } + + return PopCountUint32(uint32(n)) +} + +// PopCountUint64 returns population count of n (number of bits set in n). +func PopCountUint64(n uint64) int { + return int(popcnt[byte(n>>56)]) + int(popcnt[byte(n>>48)]) + + int(popcnt[byte(n>>40)]) + int(popcnt[byte(n>>32)]) + + int(popcnt[byte(n>>24)]) + int(popcnt[byte(n>>16)]) + + int(popcnt[byte(n>>8)]) + int(popcnt[byte(n)]) +} + +// PopCountBigInt returns population count of |n| (number of bits set in |n|). +func PopCountBigInt(n *big.Int) (r int) { + for _, v := range n.Bits() { + r += PopCountUintptr(uintptr(v)) + } + return +} diff --git a/vendor/github.com/cznic/mathutil/envelope.go b/vendor/github.com/cznic/mathutil/envelope.go new file mode 100644 index 0000000000..ff8e6012a6 --- /dev/null +++ b/vendor/github.com/cznic/mathutil/envelope.go @@ -0,0 +1,46 @@ +// Copyright (c) 2014 The mathutil 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 mathutil + +import ( + "math" +) + +// Approximation type determines approximation methods used by e.g. Envelope. +type Approximation int + +// Specific approximation method tags +const ( + _ Approximation = iota + Linear // As named + Sinusoidal // Smooth for all derivations +) + +// Envelope is an utility for defining simple curves using a small (usually) +// set of data points. Envelope returns a value defined by x, points and +// approximation. The value of x must be in [0,1) otherwise the result is +// undefined or the function may panic. Points are interpreted as dividing the +// [0,1) interval in len(points)-1 sections, so len(points) must be > 1 or the +// function may panic. According to the left and right points closing/adjacent +// to the section the resulting value is interpolated using the chosen +// approximation method. Unsupported values of approximation are silently +// interpreted as 'Linear'. +func Envelope(x float64, points []float64, approximation Approximation) float64 { + step := 1 / float64(len(points)-1) + fslot := math.Floor(x / step) + mod := x - fslot*step + slot := int(fslot) + l, r := points[slot], points[slot+1] + rmod := mod / step + switch approximation { + case Sinusoidal: + k := (math.Sin(math.Pi*(rmod-0.5)) + 1) / 2 + return l + (r-l)*k + case Linear: + fallthrough + default: + return l + (r-l)*rmod + } +} diff --git a/vendor/github.com/cznic/mathutil/mathutil.go b/vendor/github.com/cznic/mathutil/mathutil.go new file mode 100644 index 0000000000..e8f3f5622c --- /dev/null +++ b/vendor/github.com/cznic/mathutil/mathutil.go @@ -0,0 +1,829 @@ +// Copyright (c) 2014 The mathutil 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 mathutil provides utilities supplementing the standard 'math' and +// 'math/rand' packages. +// +// Compatibility issues +// +// 2013-12-13: The following functions have been REMOVED +// +// func Uint64ToBigInt(n uint64) *big.Int +// func Uint64FromBigInt(n *big.Int) (uint64, bool) +// +// 2013-05-13: The following functions are now DEPRECATED +// +// func Uint64ToBigInt(n uint64) *big.Int +// func Uint64FromBigInt(n *big.Int) (uint64, bool) +// +// These functions will be REMOVED with Go release 1.1+1. +// +// 2013-01-21: The following functions have been REMOVED +// +// func MaxInt() int +// func MinInt() int +// func MaxUint() uint +// func UintPtrBits() int +// +// They are now replaced by untyped constants +// +// MaxInt +// MinInt +// MaxUint +// UintPtrBits +// +// Additionally one more untyped constant was added +// +// IntBits +// +// This change breaks any existing code depending on the above removed +// functions. They should have not been published in the first place, that was +// unfortunate. Instead, defining such architecture and/or implementation +// specific integer limits and bit widths as untyped constants improves +// performance and allows for static dead code elimination if it depends on +// these values. Thanks to minux for pointing it out in the mail list +// (https://groups.google.com/d/msg/golang-nuts/tlPpLW6aJw8/NT3mpToH-a4J). +// +// 2012-12-12: The following functions will be DEPRECATED with Go release +// 1.0.3+1 and REMOVED with Go release 1.0.3+2, b/c of +// http://code.google.com/p/go/source/detail?r=954a79ee3ea8 +// +// func Uint64ToBigInt(n uint64) *big.Int +// func Uint64FromBigInt(n *big.Int) (uint64, bool) +package mathutil + +import ( + "math" + "math/big" +) + +// Architecture and/or implementation specific integer limits and bit widths. +const ( + MaxInt = 1<<(IntBits-1) - 1 + MinInt = -MaxInt - 1 + MaxUint = 1<>32&1 + ^uint(0)>>16&1 + ^uint(0)>>8&1 + 3) + UintPtrBits = 1 << (^uintptr(0)>>32&1 + ^uintptr(0)>>16&1 + ^uintptr(0)>>8&1 + 3) +) + +var ( + _1 = big.NewInt(1) + _2 = big.NewInt(2) +) + +// GCDByte returns the greatest common divisor of a and b. Based on: +// http://en.wikipedia.org/wiki/Euclidean_algorithm#Implementations +func GCDByte(a, b byte) byte { + for b != 0 { + a, b = b, a%b + } + return a +} + +// GCDUint16 returns the greatest common divisor of a and b. +func GCDUint16(a, b uint16) uint16 { + for b != 0 { + a, b = b, a%b + } + return a +} + +// GCD returns the greatest common divisor of a and b. +func GCDUint32(a, b uint32) uint32 { + for b != 0 { + a, b = b, a%b + } + return a +} + +// GCD64 returns the greatest common divisor of a and b. +func GCDUint64(a, b uint64) uint64 { + for b != 0 { + a, b = b, a%b + } + return a +} + +// ISqrt returns floor(sqrt(n)). Typical run time is few hundreds of ns. +func ISqrt(n uint32) (x uint32) { + if n == 0 { + return + } + + if n >= math.MaxUint16*math.MaxUint16 { + return math.MaxUint16 + } + + var px, nx uint32 + for x = n; ; px, x = x, nx { + nx = (x + n/x) / 2 + if nx == x || nx == px { + break + } + } + return +} + +// SqrtUint64 returns floor(sqrt(n)). Typical run time is about 0.5 µs. +func SqrtUint64(n uint64) (x uint64) { + if n == 0 { + return + } + + if n >= math.MaxUint32*math.MaxUint32 { + return math.MaxUint32 + } + + var px, nx uint64 + for x = n; ; px, x = x, nx { + nx = (x + n/x) / 2 + if nx == x || nx == px { + break + } + } + return +} + +// SqrtBig returns floor(sqrt(n)). It panics on n < 0. +func SqrtBig(n *big.Int) (x *big.Int) { + switch n.Sign() { + case -1: + panic(-1) + case 0: + return big.NewInt(0) + } + + var px, nx big.Int + x = big.NewInt(0) + x.SetBit(x, n.BitLen()/2+1, 1) + for { + nx.Rsh(nx.Add(x, nx.Div(n, x)), 1) + if nx.Cmp(x) == 0 || nx.Cmp(&px) == 0 { + break + } + px.Set(x) + x.Set(&nx) + } + return +} + +// Log2Byte returns log base 2 of n. It's the same as index of the highest +// bit set in n. For n == 0 -1 is returned. +func Log2Byte(n byte) int { + return log2[n] +} + +// Log2Uint16 returns log base 2 of n. It's the same as index of the highest +// bit set in n. For n == 0 -1 is returned. +func Log2Uint16(n uint16) int { + if b := n >> 8; b != 0 { + return log2[b] + 8 + } + + return log2[n] +} + +// Log2Uint32 returns log base 2 of n. It's the same as index of the highest +// bit set in n. For n == 0 -1 is returned. +func Log2Uint32(n uint32) int { + if b := n >> 24; b != 0 { + return log2[b] + 24 + } + + if b := n >> 16; b != 0 { + return log2[b] + 16 + } + + if b := n >> 8; b != 0 { + return log2[b] + 8 + } + + return log2[n] +} + +// Log2Uint64 returns log base 2 of n. It's the same as index of the highest +// bit set in n. For n == 0 -1 is returned. +func Log2Uint64(n uint64) int { + if b := n >> 56; b != 0 { + return log2[b] + 56 + } + + if b := n >> 48; b != 0 { + return log2[b] + 48 + } + + if b := n >> 40; b != 0 { + return log2[b] + 40 + } + + if b := n >> 32; b != 0 { + return log2[b] + 32 + } + + if b := n >> 24; b != 0 { + return log2[b] + 24 + } + + if b := n >> 16; b != 0 { + return log2[b] + 16 + } + + if b := n >> 8; b != 0 { + return log2[b] + 8 + } + + return log2[n] +} + +// ModPowByte computes (b^e)%m. It panics for m == 0 || b == e == 0. +// +// See also: http://en.wikipedia.org/wiki/Modular_exponentiation#Right-to-left_binary_method +func ModPowByte(b, e, m byte) byte { + if b == 0 && e == 0 { + panic(0) + } + + if m == 1 { + return 0 + } + + r := uint16(1) + for b, m := uint16(b), uint16(m); e > 0; b, e = b*b%m, e>>1 { + if e&1 == 1 { + r = r * b % m + } + } + return byte(r) +} + +// ModPowByte computes (b^e)%m. It panics for m == 0 || b == e == 0. +func ModPowUint16(b, e, m uint16) uint16 { + if b == 0 && e == 0 { + panic(0) + } + + if m == 1 { + return 0 + } + + r := uint32(1) + for b, m := uint32(b), uint32(m); e > 0; b, e = b*b%m, e>>1 { + if e&1 == 1 { + r = r * b % m + } + } + return uint16(r) +} + +// ModPowUint32 computes (b^e)%m. It panics for m == 0 || b == e == 0. +func ModPowUint32(b, e, m uint32) uint32 { + if b == 0 && e == 0 { + panic(0) + } + + if m == 1 { + return 0 + } + + r := uint64(1) + for b, m := uint64(b), uint64(m); e > 0; b, e = b*b%m, e>>1 { + if e&1 == 1 { + r = r * b % m + } + } + return uint32(r) +} + +// ModPowUint64 computes (b^e)%m. It panics for m == 0 || b == e == 0. +func ModPowUint64(b, e, m uint64) (r uint64) { + if b == 0 && e == 0 { + panic(0) + } + + if m == 1 { + return 0 + } + + return modPowBigInt(big.NewInt(0).SetUint64(b), big.NewInt(0).SetUint64(e), big.NewInt(0).SetUint64(m)).Uint64() +} + +func modPowBigInt(b, e, m *big.Int) (r *big.Int) { + r = big.NewInt(1) + for i, n := 0, e.BitLen(); i < n; i++ { + if e.Bit(i) != 0 { + r.Mod(r.Mul(r, b), m) + } + b.Mod(b.Mul(b, b), m) + } + return +} + +// ModPowBigInt computes (b^e)%m. Returns nil for e < 0. It panics for m == 0 || b == e == 0. +func ModPowBigInt(b, e, m *big.Int) (r *big.Int) { + if b.Sign() == 0 && e.Sign() == 0 { + panic(0) + } + + if m.Cmp(_1) == 0 { + return big.NewInt(0) + } + + if e.Sign() < 0 { + return + } + + return modPowBigInt(big.NewInt(0).Set(b), big.NewInt(0).Set(e), m) +} + +var uint64ToBigIntDelta big.Int + +func init() { + uint64ToBigIntDelta.SetBit(&uint64ToBigIntDelta, 63, 1) +} + +var uintptrBits int + +func init() { + x := uint64(math.MaxUint64) + uintptrBits = BitLenUintptr(uintptr(x)) +} + +// UintptrBits returns the bit width of an uintptr at the executing machine. +func UintptrBits() int { + return uintptrBits +} + +// AddUint128_64 returns the uint128 sum of uint64 a and b. +func AddUint128_64(a, b uint64) (hi uint64, lo uint64) { + lo = a + b + if lo < a { + hi = 1 + } + return +} + +// MulUint128_64 returns the uint128 bit product of uint64 a and b. +func MulUint128_64(a, b uint64) (hi, lo uint64) { + /* + 2^(2 W) ahi bhi + 2^W alo bhi + 2^W ahi blo + alo blo + + FEDCBA98 76543210 FEDCBA98 76543210 + ---- alo*blo ---- + ---- alo*bhi ---- + ---- ahi*blo ---- + ---- ahi*bhi ---- + */ + const w = 32 + const m = 1<>w, b>>w, a&m, b&m + lo = alo * blo + mid1 := alo * bhi + mid2 := ahi * blo + c1, lo := AddUint128_64(lo, mid1<>w+mid2>>w+uint64(c1+c2)) + return +} + +// PowerizeBigInt returns (e, p) such that e is the smallest number for which p +// == b^e is greater or equal n. For n < 0 or b < 2 (0, nil) is returned. +// +// NOTE: Run time for large values of n (above about 2^1e6 ~= 1e300000) can be +// significant and/or unacceptabe. For any smaller values of n the function +// typically performs in sub second time. For "small" values of n (cca bellow +// 2^1e3 ~= 1e300) the same can be easily below 10 µs. +// +// A special (and trivial) case of b == 2 is handled separately and performs +// much faster. +func PowerizeBigInt(b, n *big.Int) (e uint32, p *big.Int) { + switch { + case b.Cmp(_2) < 0 || n.Sign() < 0: + return + case n.Sign() == 0 || n.Cmp(_1) == 0: + return 0, big.NewInt(1) + case b.Cmp(_2) == 0: + p = big.NewInt(0) + e = uint32(n.BitLen() - 1) + p.SetBit(p, int(e), 1) + if p.Cmp(n) < 0 { + p.Mul(p, _2) + e++ + } + return + } + + bw := b.BitLen() + nw := n.BitLen() + p = big.NewInt(1) + var bb, r big.Int + for { + switch p.Cmp(n) { + case -1: + x := uint32((nw - p.BitLen()) / bw) + if x == 0 { + x = 1 + } + e += x + switch x { + case 1: + p.Mul(p, b) + default: + r.Set(_1) + bb.Set(b) + e := x + for { + if e&1 != 0 { + r.Mul(&r, &bb) + } + if e >>= 1; e == 0 { + break + } + + bb.Mul(&bb, &bb) + } + p.Mul(p, &r) + } + case 0, 1: + return + } + } +} + +// PowerizeUint32BigInt returns (e, p) such that e is the smallest number for +// which p == b^e is greater or equal n. For n < 0 or b < 2 (0, nil) is +// returned. +// +// More info: see PowerizeBigInt. +func PowerizeUint32BigInt(b uint32, n *big.Int) (e uint32, p *big.Int) { + switch { + case b < 2 || n.Sign() < 0: + return + case n.Sign() == 0 || n.Cmp(_1) == 0: + return 0, big.NewInt(1) + case b == 2: + p = big.NewInt(0) + e = uint32(n.BitLen() - 1) + p.SetBit(p, int(e), 1) + if p.Cmp(n) < 0 { + p.Mul(p, _2) + e++ + } + return + } + + var bb big.Int + bb.SetInt64(int64(b)) + return PowerizeBigInt(&bb, n) +} + +/* +ProbablyPrimeUint32 returns true if n is prime or n is a pseudoprime to base a. +It implements the Miller-Rabin primality test for one specific value of 'a' and +k == 1. + +Wrt pseudocode shown at +http://en.wikipedia.org/wiki/Miller-Rabin_primality_test#Algorithm_and_running_time + + Input: n > 3, an odd integer to be tested for primality; + Input: k, a parameter that determines the accuracy of the test + Output: composite if n is composite, otherwise probably prime + write n − 1 as 2^s·d with d odd by factoring powers of 2 from n − 1 + LOOP: repeat k times: + pick a random integer a in the range [2, n − 2] + x ← a^d mod n + if x = 1 or x = n − 1 then do next LOOP + for r = 1 .. s − 1 + x ← x^2 mod n + if x = 1 then return composite + if x = n − 1 then do next LOOP + return composite + return probably prime + +... this function behaves like passing 1 for 'k' and additionaly a +fixed/non-random 'a'. Otherwise it's the same algorithm. + +See also: http://mathworld.wolfram.com/Rabin-MillerStrongPseudoprimeTest.html +*/ +func ProbablyPrimeUint32(n, a uint32) bool { + d, s := n-1, 0 + for ; d&1 == 0; d, s = d>>1, s+1 { + } + x := uint64(ModPowUint32(a, d, n)) + if x == 1 || uint32(x) == n-1 { + return true + } + + for ; s > 1; s-- { + if x = x * x % uint64(n); x == 1 { + return false + } + + if uint32(x) == n-1 { + return true + } + } + return false +} + +// ProbablyPrimeUint64_32 returns true if n is prime or n is a pseudoprime to +// base a. It implements the Miller-Rabin primality test for one specific value +// of 'a' and k == 1. See also ProbablyPrimeUint32. +func ProbablyPrimeUint64_32(n uint64, a uint32) bool { + d, s := n-1, 0 + for ; d&1 == 0; d, s = d>>1, s+1 { + } + x := ModPowUint64(uint64(a), d, n) + if x == 1 || x == n-1 { + return true + } + + bx, bn := big.NewInt(0).SetUint64(x), big.NewInt(0).SetUint64(n) + for ; s > 1; s-- { + if x = bx.Mod(bx.Mul(bx, bx), bn).Uint64(); x == 1 { + return false + } + + if x == n-1 { + return true + } + } + return false +} + +// ProbablyPrimeBigInt_32 returns true if n is prime or n is a pseudoprime to +// base a. It implements the Miller-Rabin primality test for one specific value +// of 'a' and k == 1. See also ProbablyPrimeUint32. +func ProbablyPrimeBigInt_32(n *big.Int, a uint32) bool { + var d big.Int + d.Set(n) + d.Sub(&d, _1) // d <- n-1 + s := 0 + for ; d.Bit(s) == 0; s++ { + } + nMinus1 := big.NewInt(0).Set(&d) + d.Rsh(&d, uint(s)) + + x := ModPowBigInt(big.NewInt(int64(a)), &d, n) + if x.Cmp(_1) == 0 || x.Cmp(nMinus1) == 0 { + return true + } + + for ; s > 1; s-- { + if x = x.Mod(x.Mul(x, x), n); x.Cmp(_1) == 0 { + return false + } + + if x.Cmp(nMinus1) == 0 { + return true + } + } + return false +} + +// ProbablyPrimeBigInt returns true if n is prime or n is a pseudoprime to base +// a. It implements the Miller-Rabin primality test for one specific value of +// 'a' and k == 1. See also ProbablyPrimeUint32. +func ProbablyPrimeBigInt(n, a *big.Int) bool { + var d big.Int + d.Set(n) + d.Sub(&d, _1) // d <- n-1 + s := 0 + for ; d.Bit(s) == 0; s++ { + } + nMinus1 := big.NewInt(0).Set(&d) + d.Rsh(&d, uint(s)) + + x := ModPowBigInt(a, &d, n) + if x.Cmp(_1) == 0 || x.Cmp(nMinus1) == 0 { + return true + } + + for ; s > 1; s-- { + if x = x.Mod(x.Mul(x, x), n); x.Cmp(_1) == 0 { + return false + } + + if x.Cmp(nMinus1) == 0 { + return true + } + } + return false +} + +// Max returns the larger of a and b. +func Max(a, b int) int { + if a > b { + return a + } + + return b +} + +// Min returns the smaller of a and b. +func Min(a, b int) int { + if a < b { + return a + } + + return b +} + +// UMax returns the larger of a and b. +func UMax(a, b uint) uint { + if a > b { + return a + } + + return b +} + +// UMin returns the smaller of a and b. +func UMin(a, b uint) uint { + if a < b { + return a + } + + return b +} + +// MaxByte returns the larger of a and b. +func MaxByte(a, b byte) byte { + if a > b { + return a + } + + return b +} + +// MinByte returns the smaller of a and b. +func MinByte(a, b byte) byte { + if a < b { + return a + } + + return b +} + +// MaxInt8 returns the larger of a and b. +func MaxInt8(a, b int8) int8 { + if a > b { + return a + } + + return b +} + +// MinInt8 returns the smaller of a and b. +func MinInt8(a, b int8) int8 { + if a < b { + return a + } + + return b +} + +// MaxUint16 returns the larger of a and b. +func MaxUint16(a, b uint16) uint16 { + if a > b { + return a + } + + return b +} + +// MinUint16 returns the smaller of a and b. +func MinUint16(a, b uint16) uint16 { + if a < b { + return a + } + + return b +} + +// MaxInt16 returns the larger of a and b. +func MaxInt16(a, b int16) int16 { + if a > b { + return a + } + + return b +} + +// MinInt16 returns the smaller of a and b. +func MinInt16(a, b int16) int16 { + if a < b { + return a + } + + return b +} + +// MaxUint32 returns the larger of a and b. +func MaxUint32(a, b uint32) uint32 { + if a > b { + return a + } + + return b +} + +// MinUint32 returns the smaller of a and b. +func MinUint32(a, b uint32) uint32 { + if a < b { + return a + } + + return b +} + +// MaxInt32 returns the larger of a and b. +func MaxInt32(a, b int32) int32 { + if a > b { + return a + } + + return b +} + +// MinInt32 returns the smaller of a and b. +func MinInt32(a, b int32) int32 { + if a < b { + return a + } + + return b +} + +// MaxUint64 returns the larger of a and b. +func MaxUint64(a, b uint64) uint64 { + if a > b { + return a + } + + return b +} + +// MinUint64 returns the smaller of a and b. +func MinUint64(a, b uint64) uint64 { + if a < b { + return a + } + + return b +} + +// MaxInt64 returns the larger of a and b. +func MaxInt64(a, b int64) int64 { + if a > b { + return a + } + + return b +} + +// MinInt64 returns the smaller of a and b. +func MinInt64(a, b int64) int64 { + if a < b { + return a + } + + return b +} + +// ToBase produces n in base b. For example +// +// ToBase(2047, 22) -> [1, 5, 4] +// +// 1 * 22^0 1 +// 5 * 22^1 110 +// 4 * 22^2 1936 +// ---- +// 2047 +// +// ToBase panics for bases < 2. +func ToBase(n *big.Int, b int) []int { + var nn big.Int + nn.Set(n) + if b < 2 { + panic("invalid base") + } + + k := 1 + switch nn.Sign() { + case -1: + nn.Neg(&nn) + k = -1 + case 0: + return []int{0} + } + + bb := big.NewInt(int64(b)) + var r []int + rem := big.NewInt(0) + for nn.Sign() != 0 { + nn.QuoRem(&nn, bb, rem) + r = append(r, k*int(rem.Int64())) + } + return r +} diff --git a/vendor/github.com/cznic/mathutil/permute.go b/vendor/github.com/cznic/mathutil/permute.go new file mode 100644 index 0000000000..bf828b694f --- /dev/null +++ b/vendor/github.com/cznic/mathutil/permute.go @@ -0,0 +1,39 @@ +// Copyright (c) 2014 The mathutil 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 mathutil + +import ( + "sort" +) + +// Generate the first permutation of data. +func PermutationFirst(data sort.Interface) { + sort.Sort(data) +} + +// Generate the next permutation of data if possible and return true. +// Return false if there is no more permutation left. +// Based on the algorithm described here: +// http://en.wikipedia.org/wiki/Permutation#Generation_in_lexicographic_order +func PermutationNext(data sort.Interface) bool { + var k, l int + for k = data.Len() - 2; ; k-- { // 1. + if k < 0 { + return false + } + + if data.Less(k, k+1) { + break + } + } + for l = data.Len() - 1; !data.Less(k, l); l-- { // 2. + } + data.Swap(k, l) // 3. + for i, j := k+1, data.Len()-1; i < j; i++ { // 4. + data.Swap(i, j) + j-- + } + return true +} diff --git a/vendor/github.com/cznic/mathutil/primes.go b/vendor/github.com/cznic/mathutil/primes.go new file mode 100644 index 0000000000..2c82eb033e --- /dev/null +++ b/vendor/github.com/cznic/mathutil/primes.go @@ -0,0 +1,342 @@ +// Copyright (c) 2014 The mathutil 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 mathutil + +import ( + "math" +) + +// IsPrimeUint16 returns true if n is prime. Typical run time is few ns. +func IsPrimeUint16(n uint16) bool { + return n > 0 && primes16[n-1] == 1 +} + +// NextPrimeUint16 returns first prime > n and true if successful or an +// undefined value and false if there is no next prime in the uint16 limits. +// Typical run time is few ns. +func NextPrimeUint16(n uint16) (p uint16, ok bool) { + return n + uint16(primes16[n]), n < 65521 +} + +// IsPrime returns true if n is prime. Typical run time is about 100 ns. +// +//TODO rename to IsPrimeUint32 +func IsPrime(n uint32) bool { + switch { + case n&1 == 0: + return n == 2 + case n%3 == 0: + return n == 3 + case n%5 == 0: + return n == 5 + case n%7 == 0: + return n == 7 + case n%11 == 0: + return n == 11 + case n%13 == 0: + return n == 13 + case n%17 == 0: + return n == 17 + case n%19 == 0: + return n == 19 + case n%23 == 0: + return n == 23 + case n%29 == 0: + return n == 29 + case n%31 == 0: + return n == 31 + case n%37 == 0: + return n == 37 + case n%41 == 0: + return n == 41 + case n%43 == 0: + return n == 43 + case n%47 == 0: + return n == 47 + case n%53 == 0: + return n == 53 // Benchmarked optimum + case n < 65536: + // use table data + return IsPrimeUint16(uint16(n)) + default: + mod := ModPowUint32(2, (n+1)/2, n) + if mod != 2 && mod != n-2 { + return false + } + blk := &lohi[n>>24] + lo, hi := blk.lo, blk.hi + for lo <= hi { + index := (lo + hi) >> 1 + liar := liars[index] + switch { + case n > liar: + lo = index + 1 + case n < liar: + hi = index - 1 + default: + return false + } + } + return true + } +} + +// IsPrimeUint64 returns true if n is prime. Typical run time is few tens of µs. +// +// SPRP bases: http://miller-rabin.appspot.com +func IsPrimeUint64(n uint64) bool { + switch { + case n%2 == 0: + return n == 2 + case n%3 == 0: + return n == 3 + case n%5 == 0: + return n == 5 + case n%7 == 0: + return n == 7 + case n%11 == 0: + return n == 11 + case n%13 == 0: + return n == 13 + case n%17 == 0: + return n == 17 + case n%19 == 0: + return n == 19 + case n%23 == 0: + return n == 23 + case n%29 == 0: + return n == 29 + case n%31 == 0: + return n == 31 + case n%37 == 0: + return n == 37 + case n%41 == 0: + return n == 41 + case n%43 == 0: + return n == 43 + case n%47 == 0: + return n == 47 + case n%53 == 0: + return n == 53 + case n%59 == 0: + return n == 59 + case n%61 == 0: + return n == 61 + case n%67 == 0: + return n == 67 + case n%71 == 0: + return n == 71 + case n%73 == 0: + return n == 73 + case n%79 == 0: + return n == 79 + case n%83 == 0: + return n == 83 + case n%89 == 0: + return n == 89 // Benchmarked optimum + case n <= math.MaxUint16: + return IsPrimeUint16(uint16(n)) + case n <= math.MaxUint32: + return ProbablyPrimeUint32(uint32(n), 11000544) && + ProbablyPrimeUint32(uint32(n), 31481107) + case n < 105936894253: + return ProbablyPrimeUint64_32(n, 2) && + ProbablyPrimeUint64_32(n, 1005905886) && + ProbablyPrimeUint64_32(n, 1340600841) + case n < 31858317218647: + return ProbablyPrimeUint64_32(n, 2) && + ProbablyPrimeUint64_32(n, 642735) && + ProbablyPrimeUint64_32(n, 553174392) && + ProbablyPrimeUint64_32(n, 3046413974) + case n < 3071837692357849: + return ProbablyPrimeUint64_32(n, 2) && + ProbablyPrimeUint64_32(n, 75088) && + ProbablyPrimeUint64_32(n, 642735) && + ProbablyPrimeUint64_32(n, 203659041) && + ProbablyPrimeUint64_32(n, 3613982119) + default: + return ProbablyPrimeUint64_32(n, 2) && + ProbablyPrimeUint64_32(n, 325) && + ProbablyPrimeUint64_32(n, 9375) && + ProbablyPrimeUint64_32(n, 28178) && + ProbablyPrimeUint64_32(n, 450775) && + ProbablyPrimeUint64_32(n, 9780504) && + ProbablyPrimeUint64_32(n, 1795265022) + } +} + +// NextPrime returns first prime > n and true if successful or an undefined value and false if there +// is no next prime in the uint32 limits. Typical run time is about 2 µs. +// +//TODO rename to NextPrimeUint32 +func NextPrime(n uint32) (p uint32, ok bool) { + switch { + case n < 65521: + p16, _ := NextPrimeUint16(uint16(n)) + return uint32(p16), true + case n >= math.MaxUint32-4: + return + } + + n++ + var d0, d uint32 + switch mod := n % 6; mod { + case 0: + d0, d = 1, 4 + case 1: + d = 4 + case 2, 3, 4: + d0, d = 5-mod, 2 + case 5: + d = 2 + } + + p = n + d0 + if p < n { // overflow + return + } + + for { + if IsPrime(p) { + return p, true + } + + p0 := p + p += d + if p < p0 { // overflow + break + } + + d ^= 6 + } + return +} + +// NextPrimeUint64 returns first prime > n and true if successful or an undefined value and false if there +// is no next prime in the uint64 limits. Typical run time is in hundreds of µs. +func NextPrimeUint64(n uint64) (p uint64, ok bool) { + switch { + case n < 65521: + p16, _ := NextPrimeUint16(uint16(n)) + return uint64(p16), true + case n >= 18446744073709551557: // last uint64 prime + return + } + + n++ + var d0, d uint64 + switch mod := n % 6; mod { + case 0: + d0, d = 1, 4 + case 1: + d = 4 + case 2, 3, 4: + d0, d = 5-mod, 2 + case 5: + d = 2 + } + + p = n + d0 + if p < n { // overflow + return + } + + for { + if ok = IsPrimeUint64(p); ok { + break + } + + p0 := p + p += d + if p < p0 { // overflow + break + } + + d ^= 6 + } + return +} + +// FactorTerm is one term of an integer factorization. +type FactorTerm struct { + Prime uint32 // The divisor + Power uint32 // Term == Prime^Power +} + +// FactorTerms represent a factorization of an integer +type FactorTerms []FactorTerm + +// FactorInt returns prime factorization of n > 1 or nil otherwise. +// Resulting factors are ordered by Prime. Typical run time is few µs. +func FactorInt(n uint32) (f FactorTerms) { + switch { + case n < 2: + return + case IsPrime(n): + return []FactorTerm{{n, 1}} + } + + f, w := make([]FactorTerm, 9), 0 + prime16 := uint16(0) + for { + var ok bool + if prime16, ok = NextPrimeUint16(prime16); !ok { + break + } + + prime := uint32(prime16) + if prime*prime > n { + break + } + + power := uint32(0) + for n%prime == 0 { + n /= prime + power++ + } + if power != 0 { + f[w] = FactorTerm{prime, power} + w++ + } + if n == 1 { + break + } + } + if n != 1 { + f[w] = FactorTerm{n, 1} + w++ + } + return f[:w] +} + +// PrimorialProductsUint32 returns a slice of numbers in [lo, hi] which are a +// product of max 'max' primorials. The slice is not sorted. +// +// See also: http://en.wikipedia.org/wiki/Primorial +func PrimorialProductsUint32(lo, hi, max uint32) (r []uint32) { + lo64, hi64 := int64(lo), int64(hi) + if max > 31 { // N/A + max = 31 + } + + var f func(int64, int64, uint32) + f = func(n, p int64, emax uint32) { + e := uint32(1) + for n <= hi64 && e <= emax { + n *= p + if n >= lo64 && n <= hi64 { + r = append(r, uint32(n)) + } + if n < hi64 { + p, _ := NextPrime(uint32(p)) + f(n, int64(p), e) + } + e++ + } + } + + f(1, 2, max) + return +} diff --git a/vendor/github.com/cznic/mathutil/rat.go b/vendor/github.com/cznic/mathutil/rat.go new file mode 100644 index 0000000000..91b1c6fb1e --- /dev/null +++ b/vendor/github.com/cznic/mathutil/rat.go @@ -0,0 +1,27 @@ +// Copyright (c) 2014 The mathutil 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 mathutil + +// QCmpUint32 compares a/b and c/d and returns: +// +// -1 if a/b < c/d +// 0 if a/b == c/d +// +1 if a/b > c/d +// +func QCmpUint32(a, b, c, d uint32) int { + switch x, y := uint64(a)*uint64(d), uint64(b)*uint64(c); { + case x < y: + return -1 + case x == y: + return 0 + default: // x > y + return 1 + } +} + +// QScaleUint32 returns a such that a/b >= c/d. +func QScaleUint32(b, c, d uint32) (a uint64) { + return 1 + (uint64(b)*uint64(c))/uint64(d) +} diff --git a/vendor/github.com/cznic/mathutil/rnd.go b/vendor/github.com/cznic/mathutil/rnd.go new file mode 100644 index 0000000000..9132dc0d55 --- /dev/null +++ b/vendor/github.com/cznic/mathutil/rnd.go @@ -0,0 +1,383 @@ +// Copyright (c) 2014 The mathutil 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 mathutil + +import ( + "fmt" + "math" + "math/big" +) + +// FC32 is a full cycle PRNG covering the 32 bit signed integer range. +// In contrast to full cycle generators shown at e.g. http://en.wikipedia.org/wiki/Full_cycle, +// this code doesn't produce values at constant delta (mod cycle length). +// The 32 bit limit is per this implementation, the algorithm used has no intrinsic limit on the cycle size. +// Properties include: +// - Adjustable limits on creation (hi, lo). +// - Positionable/randomly accessible (Pos, Seek). +// - Repeatable (deterministic). +// - Can run forward or backward (Next, Prev). +// - For a billion numbers cycle the Next/Prev PRN can be produced in cca 100-150ns. +// That's like 5-10 times slower compared to PRNs generated using the (non FC) rand package. +type FC32 struct { + cycle int64 // On average: 3 * delta / 2, (HQ: 2 * delta) + delta int64 // hi - lo + factors [][]int64 // This trades some space for hopefully a bit of speed (multiple adding vs multiplying). + lo int + mods []int // pos % set + pos int64 // Within cycle. + primes []int64 // Ordered. ∏ primes == cycle. + set []int64 // Reordered primes (magnitude order bases) according to seed. +} + +// NewFC32 returns a newly created FC32 adjusted for the closed interval [lo, hi] or an Error if any. +// If hq == true then trade some generation time for improved (pseudo)randomness. +func NewFC32(lo, hi int, hq bool) (r *FC32, err error) { + if lo > hi { + return nil, fmt.Errorf("invalid range %d > %d", lo, hi) + } + + if uint64(hi)-uint64(lo) > math.MaxUint32 { + return nil, fmt.Errorf("range out of int32 limits %d, %d", lo, hi) + } + + delta := int64(hi) - int64(lo) + // Find the primorial covering whole delta + n, set, p := int64(1), []int64{}, uint32(2) + if hq { + p++ + } + for { + set = append(set, int64(p)) + n *= int64(p) + if n > delta { + break + } + p, _ = NextPrime(p) + } + + // Adjust the set so n ∊ [delta, 2 * delta] (HQ: [delta, 3 * delta]) + // while keeping the cardinality of the set (correlates with the statistic "randomness quality") + // at max, i.e. discard atmost one member. + i := -1 // no candidate prime + if n > 2*(delta+1) { + for j, p := range set { + q := n / p + if q < delta+1 { + break + } + + i = j // mark the highest candidate prime set index + } + } + if i >= 0 { // shrink the inner cycle + n = n / set[i] + set = delete(set, i) + } + r = &FC32{ + cycle: n, + delta: delta, + factors: make([][]int64, len(set)), + lo: lo, + mods: make([]int, len(set)), + primes: set, + } + r.Seed(1) // the default seed should be always non zero + return +} + +// Cycle reports the length of the inner FCPRNG cycle. +// Cycle is atmost the double (HQ: triple) of the generator period (hi - lo + 1). +func (r *FC32) Cycle() int64 { + return r.cycle +} + +// Next returns the first PRN after Pos. +func (r *FC32) Next() int { + return r.step(1) +} + +// Pos reports the current position within the inner cycle. +func (r *FC32) Pos() int64 { + return r.pos +} + +// Prev return the first PRN before Pos. +func (r *FC32) Prev() int { + return r.step(-1) +} + +// Seed uses the provided seed value to initialize the generator to a deterministic state. +// A zero seed produces a "canonical" generator with worse randomness than for most non zero seeds. +// Still, the FC property holds for any seed value. +func (r *FC32) Seed(seed int64) { + u := uint64(seed) + r.set = mix(r.primes, &u) + n := int64(1) + for i, p := range r.set { + k := make([]int64, p) + v := int64(0) + for j := range k { + k[j] = v + v += n + } + n *= p + r.factors[i] = mix(k, &u) + } +} + +// Seek sets Pos to |pos| % Cycle. +func (r *FC32) Seek(pos int64) { //vet:ignore + if pos < 0 { + pos = -pos + } + pos %= r.cycle + r.pos = pos + for i, p := range r.set { + r.mods[i] = int(pos % p) + } +} + +func (r *FC32) step(dir int) int { + for { // avg loops per step: 3/2 (HQ: 2) + y := int64(0) + pos := r.pos + pos += int64(dir) + switch { + case pos < 0: + pos = r.cycle - 1 + case pos >= r.cycle: + pos = 0 + } + r.pos = pos + for i, mod := range r.mods { + mod += dir + p := int(r.set[i]) + switch { + case mod < 0: + mod = p - 1 + case mod >= p: + mod = 0 + } + r.mods[i] = mod + y += r.factors[i][mod] + } + if y <= r.delta { + return int(y) + r.lo + } + } +} + +func delete(set []int64, i int) (y []int64) { + for j, v := range set { + if j != i { + y = append(y, v) + } + } + return +} + +func mix(set []int64, seed *uint64) (y []int64) { + for len(set) != 0 { + *seed = rol(*seed) + i := int(*seed % uint64(len(set))) + y = append(y, set[i]) + set = delete(set, i) + } + return +} + +func rol(u uint64) (y uint64) { + y = u << 1 + if int64(u) < 0 { + y |= 1 + } + return +} + +// FCBig is a full cycle PRNG covering ranges outside of the int32 limits. +// For more info see the FC32 docs. +// Next/Prev PRN on a 1e15 cycle can be produced in about 2 µsec. +type FCBig struct { + cycle *big.Int // On average: 3 * delta / 2, (HQ: 2 * delta) + delta *big.Int // hi - lo + factors [][]*big.Int // This trades some space for hopefully a bit of speed (multiple adding vs multiplying). + lo *big.Int + mods []int // pos % set + pos *big.Int // Within cycle. + primes []int64 // Ordered. ∏ primes == cycle. + set []int64 // Reordered primes (magnitude order bases) according to seed. +} + +// NewFCBig returns a newly created FCBig adjusted for the closed interval [lo, hi] or an Error if any. +// If hq == true then trade some generation time for improved (pseudo)randomness. +func NewFCBig(lo, hi *big.Int, hq bool) (r *FCBig, err error) { + if lo.Cmp(hi) > 0 { + return nil, fmt.Errorf("invalid range %d > %d", lo, hi) + } + + delta := big.NewInt(0) + delta.Add(delta, hi).Sub(delta, lo) + + // Find the primorial covering whole delta + n, set, pp, p := big.NewInt(1), []int64{}, big.NewInt(0), uint32(2) + if hq { + p++ + } + for { + set = append(set, int64(p)) + pp.SetInt64(int64(p)) + n.Mul(n, pp) + if n.Cmp(delta) > 0 { + break + } + p, _ = NextPrime(p) + } + + // Adjust the set so n ∊ [delta, 2 * delta] (HQ: [delta, 3 * delta]) + // while keeping the cardinality of the set (correlates with the statistic "randomness quality") + // at max, i.e. discard atmost one member. + dd1 := big.NewInt(1) + dd1.Add(dd1, delta) + dd2 := big.NewInt(0) + dd2.Lsh(dd1, 1) + i := -1 // no candidate prime + if n.Cmp(dd2) > 0 { + q := big.NewInt(0) + for j, p := range set { + pp.SetInt64(p) + q.Set(n) + q.Div(q, pp) + if q.Cmp(dd1) < 0 { + break + } + + i = j // mark the highest candidate prime set index + } + } + if i >= 0 { // shrink the inner cycle + pp.SetInt64(set[i]) + n.Div(n, pp) + set = delete(set, i) + } + r = &FCBig{ + cycle: n, + delta: delta, + factors: make([][]*big.Int, len(set)), + lo: lo, + mods: make([]int, len(set)), + pos: big.NewInt(0), + primes: set, + } + r.Seed(1) // the default seed should be always non zero + return +} + +// Cycle reports the length of the inner FCPRNG cycle. +// Cycle is atmost the double (HQ: triple) of the generator period (hi - lo + 1). +func (r *FCBig) Cycle() *big.Int { + return r.cycle +} + +// Next returns the first PRN after Pos. +func (r *FCBig) Next() *big.Int { + return r.step(1) +} + +// Pos reports the current position within the inner cycle. +func (r *FCBig) Pos() *big.Int { + return r.pos +} + +// Prev return the first PRN before Pos. +func (r *FCBig) Prev() *big.Int { + return r.step(-1) +} + +// Seed uses the provided seed value to initialize the generator to a deterministic state. +// A zero seed produces a "canonical" generator with worse randomness than for most non zero seeds. +// Still, the FC property holds for any seed value. +func (r *FCBig) Seed(seed int64) { + u := uint64(seed) + r.set = mix(r.primes, &u) + n := big.NewInt(1) + v := big.NewInt(0) + pp := big.NewInt(0) + for i, p := range r.set { + k := make([]*big.Int, p) + v.SetInt64(0) + for j := range k { + k[j] = big.NewInt(0) + k[j].Set(v) + v.Add(v, n) + } + pp.SetInt64(p) + n.Mul(n, pp) + r.factors[i] = mixBig(k, &u) + } +} + +// Seek sets Pos to |pos| % Cycle. +func (r *FCBig) Seek(pos *big.Int) { + r.pos.Set(pos) + r.pos.Abs(r.pos) + r.pos.Mod(r.pos, r.cycle) + mod := big.NewInt(0) + pp := big.NewInt(0) + for i, p := range r.set { + pp.SetInt64(p) + r.mods[i] = int(mod.Mod(r.pos, pp).Int64()) + } +} + +func (r *FCBig) step(dir int) (y *big.Int) { + y = big.NewInt(0) + d := big.NewInt(int64(dir)) + for { // avg loops per step: 3/2 (HQ: 2) + r.pos.Add(r.pos, d) + switch { + case r.pos.Sign() < 0: + r.pos.Add(r.pos, r.cycle) + case r.pos.Cmp(r.cycle) >= 0: + r.pos.SetInt64(0) + } + for i, mod := range r.mods { + mod += dir + p := int(r.set[i]) + switch { + case mod < 0: + mod = p - 1 + case mod >= p: + mod = 0 + } + r.mods[i] = mod + y.Add(y, r.factors[i][mod]) + } + if y.Cmp(r.delta) <= 0 { + y.Add(y, r.lo) + return + } + y.SetInt64(0) + } +} + +func deleteBig(set []*big.Int, i int) (y []*big.Int) { + for j, v := range set { + if j != i { + y = append(y, v) + } + } + return +} + +func mixBig(set []*big.Int, seed *uint64) (y []*big.Int) { + for len(set) != 0 { + *seed = rol(*seed) + i := int(*seed % uint64(len(set))) + y = append(y, set[i]) + set = deleteBig(set, i) + } + return +} diff --git a/vendor/github.com/cznic/mathutil/tables.go b/vendor/github.com/cznic/mathutil/tables.go new file mode 100644 index 0000000000..f32952c007 --- /dev/null +++ b/vendor/github.com/cznic/mathutil/tables.go @@ -0,0 +1,6995 @@ +// Copyright (c) 2014 The mathutil Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// "Static" data + +package mathutil + +var ( + // Set bits count in a byte + popcnt = [256]byte{ + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, // 0 + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, // 1 + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, // 2 + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, // 3 + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, // 4 + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, // 5 + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, // 6 + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, // 7 + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, // 8 + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, // 9 + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, // 10 + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, // 11 + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, // 12 + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, // 13 + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, // 14 + 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8, // 15 + } + + // Highest set bit index in a byte + log2 = [256]int{ + -1, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, // 0 + + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, // 1 + + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, // 2 + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, // 3 + + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, // 4 + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, // 5 + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, // 6 + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, // 7 + + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 8 + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 9 + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 10 + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 11 + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 12 + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 13 + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 14 + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 15 + } + + // "Predivisors": 2-53 + liars = [3660]uint32{ + 31621, 42799, 49141, 49981, 65077, 65281, 80581, 83333, 88357, 90751, + 104653, 130561, 164737, 188057, 194221, 196093, 215749, 219781, 220729, 253241, + 256999, 271951, 280601, 282133, 357761, 390937, 458989, 486737, 489997, 514447, + 580337, 587861, 611701, 647089, 653333, 657901, 665281, 665333, 688213, 710533, + 721801, 722261, 738541, 741751, 742813, 745889, 769757, 818201, 838861, 873181, + 877099, 916327, 976873, 983401, 1016801, 1018921, 1053761, 1064053, 1073021, 1082401, + 1109461, 1132657, 1145257, 1168513, 1194649, 1207361, 1251949, 1252697, 1302451, 1325843, + 1357441, 1373653, 1397419, 1441091, 1493857, 1507963, 1509709, 1530787, 1584133, 1678541, + 1690501, 1730977, 1735841, 1811573, 1876393, 1969417, 1987021, 2004403, 2081713, 2163001, + 2181961, 2205967, 2261953, 2264369, 2269093, 2284453, 2304167, 2387797, 2487941, 2510569, + 2670361, 2746477, 2748023, 2757241, 2811271, 2909197, 2944261, 2976487, 3048841, 3090091, + 3116107, 3125281, 3225601, 3363121, 3375041, 3400013, 3413533, 3429037, 3539101, 3542533, + 3567481, 3568661, 3605429, 3656449, 3763801, 3828001, 3898129, 3911197, 3985921, 4072729, + 4181921, 4188889, 4209661, 4360621, 4469471, 4480477, 4513841, 4835209, 4863127, 4869313, + 4877641, 4922413, 5016191, 5044033, 5095177, 5173169, 5173601, 5176153, 5256091, 5271841, + 5284333, 5351537, 5489641, 5590621, 5672041, 5919187, 6027193, 6118141, 6140161, 6159301, + 6189121, 6226193, 6233977, 6236257, 6278533, 6334351, 6368689, 6386993, 6631549, 6658669, + 6779137, 6787327, 6836233, 6952037, 6955541, 6998881, 7017193, 7232321, 7306261, 7306561, + 7429117, 7462001, 7674967, 7725901, 7759937, 7820201, 7883731, 8036033, 8095447, 8239477, + 8384513, 8534233, 8725753, 8727391, 8902741, 9006401, 9056501, 9073513, 9131401, 9345541, + 9371251, 9439201, 9480461, 9533701, 9564169, 9567673, 9588151, 9591661, 9729301, 9774181, + 9863461, 10024561, 10084177, 10323769, 10331141, 10386241, 10425511, 10610063, 10700761, 10712857, + 10763653, 10974881, 11081459, 11115037, 11335501, 11541307, 11585293, 11592397, 11777599, 12032021, + 12096613, 12263131, 12322133, 12327121, 12599233, 12854437, 13057787, 13338371, 13446253, 13500313, + 13635289, 13694761, 13747361, 13773061, 14026897, 14154337, 14179537, 14324473, 14469841, 14671801, + 14676481, 14709241, 14794081, 14796289, 14865121, 15101893, 15139199, 15162941, 15188557, 15220951, + 15247621, 15479777, 15525241, 15603391, 15621409, 15700301, 15802681, 15976747, 15978007, 16070429, + 16132321, 16149169, 16153633, 16324001, 16349477, 16360381, 16705021, 16773121, 16822081, 16843009, + 16853077, 16879501, 16973393, 17098369, 17116837, 17134043, 17208601, 17236801, 17327773, 17375249, + 17405537, 17585969, 17870561, 18067501, 18073817, 18366937, 18443701, 18454921, 18535177, 18653353, + 18740971, 19328653, 19384289, 19404139, 19471033, 19607561, 20261251, 20417311, 20647621, 20968501, + 21042001, 21303343, 21306157, 21359521, 21397381, 21400481, 21623659, 21654533, 22075579, 22087477, + 22369621, 22591301, 22669501, 22711873, 22849481, 22953673, 23247901, 23382529, 23464033, 23577497, + 23634181, 23734901, 23828017, 23872213, 23963869, 24214051, 24356377, 25080101, 25150501, 25276421, + 25326001, 25457833, 25629913, 25696133, 25768261, 25909453, 26280073, 26377921, 26821601, 26840269, + 26877421, 26886817, 27108397, 27118601, 27219697, 27271151, 27279409, 27331921, 27380831, 27392041, + 27409541, 27491237, 27509653, 27664033, 27798461, 27808463, 28325881, 28527049, 28572961, 29111881, + 29214541, 29581501, 30022129, 30090817, 30185569, 30219757, 30295141, 30338593, 30388753, 30418957, + 30576151, 30662497, 30740417, 30881551, 30894307, 31040833, 31166803, 31436123, 31735621, 31759121, + 32091781, 32095057, 32168117, 32285041, 32497921, 32676481, 33146717, 33298337, 33600533, 33627301, + 33704101, 33872593, 34003061, 34043101, 34124641, 34540801, 34856167, 34944001, 35576599, 35703361, + 35820937, 35851037, 36291193, 36307981, 36861901, 36919681, 36974341, 37109467, 37376509, 37439201, + 37964809, 37988497, 38010307, 38046817, 38118763, 38210323, 39465091, 39512773, 39655153, 39684157, + 40165093, 40238797, 40315441, 40361197, 40629601, 40782589, 40827473, 40987201, 41121433, 41568101, + 41604109, 41642681, 41662297, 41840809, 42009217, 42485119, 42623017, 42984589, 43224397, 43363601, + 43661257, 44070841, 44314129, 44465221, 44482901, 45100177, 45175201, 45219329, 45414433, 45819541, + 45879941, 46094401, 46325029, 46386589, 46469809, 46517857, 46679761, 46860001, 47220367, 47903701, + 47918581, 48064021, 48191653, 48269761, 48316969, 48400753, 48448661, 48551161, 48563089, 49075417, + 49303801, 49411801, 49459801, 50155733, 50201089, 50443201, 50523661, 51030601, 51129781, 51302353, + 51500521, 52072021, 52119289, 52204237, 53283169, 53399449, 53656021, 53675623, 53695721, 53711113, + 54029741, 54449431, 55109401, 55176097, 55318957, 55729957, 56052361, 56420033, 56479897, 56810137, + 57762433, 58003213, 58422409, 58449847, 58509977, 58679941, 58755877, 59631211, 59840537, 59913157, + 59953741, 60155201, 60352921, 60547831, 60566431, 60581401, 60696661, 60738257, 60957361, 61201009, + 61219789, 61377109, 61832377, 62756641, 63001801, 63002501, 63065281, 63167743, 63318169, 63328469, + 63346999, 63388033, 64148717, 64605041, 64735897, 65144501, 65254393, 65301013, 65350801, 65359477, + 66096253, 67194401, 67642513, 67928221, 68102641, 68154001, 68165761, 68512867, 68621701, 68839597, + 69030901, 69128641, 69176647, 69228967, 69231061, 69485281, 69612061, 69885649, 70149631, 70463489, + 70593931, 70728121, 71079661, 71734417, 72498253, 72543547, 73562833, 73645001, 74411131, 74927161, + 75140137, 75565873, 76725091, 76745101, 77533123, 77648941, 77812153, 77817979, 78939089, 79398901, + 79411201, 79417801, 79464533, 79786523, 80142761, 80146909, 80375707, 80556337, 80687881, 80891009, + 81433591, 81954133, 82273201, 82506439, 82870517, 82929001, 83083001, 83103329, 83204801, 84164033, + 84350561, 84421081, 84487457, 84998503, 85328717, 85519337, 85823401, 86027329, 86438857, 86530621, + 86999837, 87499651, 87694261, 88256449, 88368853, 88661861, 89308771, 89784581, 90270613, 90278161, + 90341197, 90665789, 90698401, 91433281, 91659283, 92438581, 92625121, 93431521, 93541537, 93571633, + 93643201, 93677761, 93926197, 94316401, 94502701, 95451361, 95452781, 96135601, 96618397, 96791881, + 96888641, 96895441, 96904081, 96925921, 97255801, 97496449, 97796953, 97863529, 97924217, 99036001, + 99115297, 99486889, 99789673, 99898801, 100463443, 100618933, 100943201, 101152133, 101218921, 101270251, + 101276579, 101649241, 102004421, 102678031, 102690677, 102690901, 103301633, 104078857, 104524421, 104988673, + 105305443, 105919633, 106485121, 106622353, 106743073, 107360641, 107543333, 108596953, 109231229, 109437751, + 109541461, 109879837, 110135821, 110139499, 110312773, 110413333, 110717861, 111370141, 111654401, 112032001, + 112402981, 112828801, 113589601, 113605201, 113730481, 113892589, 114305441, 114329881, 114701341, 114842677, + 114910489, 115039081, 115174681, 115497901, 115804501, 115873801, 116090081, 116321617, 116617289, 116682721, + 116696161, 116998669, 117987841, 118466401, 118901521, 119092801, 119204809, 119261113, 119327041, 119558011, + 119743537, 119940853, 120296677, 120517021, 120838609, 121062001, 121374241, 121472359, 121609489, 122166307, + 122396737, 122941981, 123481777, 123671671, 123877081, 123987793, 124145473, 124630273, 124818601, 125284141, + 125686241, 125848577, 126132553, 127050067, 128079409, 128124151, 128396921, 128468957, 128665319, 128987429, + 129205781, 129256273, 129357061, 129461617, 129524669, 130556329, 130693393, 130944133, 131023201, 131567929, + 131938561, 132332201, 132338881, 132440521, 132575071, 133216381, 133302781, 133467517, 133800661, 134696801, + 134767153, 134868029, 135263269, 135296053, 135308881, 135945853, 135969401, 136043641, 136661201, 136722433, + 137415821, 137763037, 138030721, 138403981, 138828821, 139295701, 139487041, 140197051, 142525333, 142922413, + 143106133, 143168581, 145348529, 146156617, 146272901, 146659801, 146843929, 146884393, 147028001, 147287141, + 148109473, 148171769, 148910653, 149389633, 150379693, 150960239, 150988753, 151533377, 151589881, 152716537, + 152922001, 152991841, 153369061, 153589801, 153754873, 153928133, 154287451, 154513633, 154944533, 155203361, + 156114061, 156532799, 157069189, 157368661, 157405249, 157725829, 158068153, 158192317, 158397247, 158496911, + 158544401, 158895281, 160348189, 160378861, 160491329, 160587841, 160672201, 160730389, 161184013, 161216021, + 161289649, 161304001, 161423377, 162026869, 162067441, 162690481, 162771337, 162776041, 163442551, 163954561, + 164111281, 165061909, 165224321, 165938653, 166082309, 166339057, 166406561, 166827943, 167579497, 167582377, + 167692141, 167881121, 168566501, 169655641, 170640961, 170782921, 170856533, 171454321, 172116181, 172436713, + 172947529, 173401621, 174479729, 176030977, 176597821, 176609441, 176977921, 177167233, 177254533, 177693521, + 177927641, 177951973, 178837201, 178956971, 179083601, 179285137, 179820257, 180115489, 180497633, 180703451, + 181285001, 181285537, 181542601, 181647497, 182383111, 183677341, 184411567, 185653333, 186183469, 186393481, + 186983521, 187050529, 187667969, 187761241, 188516329, 188985961, 189714193, 189738361, 189941761, 190212181, + 190382161, 190913297, 191233813, 191648161, 191981609, 192346153, 192857761, 193330237, 193638337, 193949641, + 194556451, 196035001, 196049701, 196231393, 198982759, 199674721, 200143351, 200753281, 201261061, 202130197, + 202156813, 202538857, 203505697, 204280501, 204582457, 204766381, 205057561, 206304961, 206453509, 206504033, + 206529737, 207008569, 207030541, 207132481, 207477001, 207618781, 208051201, 208969223, 209246701, 209404369, + 209990881, 210592873, 210842113, 213035761, 214038533, 214110541, 214852609, 214858717, 215436241, 216821881, + 217123069, 217875571, 218603617, 218642029, 218947121, 219621781, 220531501, 220883521, 221368153, 221415781, + 221884001, 222010721, 222630193, 223449463, 223625851, 223782263, 224074369, 224136013, 224769241, 224957893, + 225853633, 226359547, 226450297, 227132641, 227444101, 227475481, 228652201, 228842209, 228988033, 229589413, + 230357761, 231383461, 231405701, 231927781, 232114433, 232460821, 232771501, 233110081, 234869009, 235426913, + 235928071, 237791143, 238001653, 238833421, 240068041, 240371713, 240694513, 240785047, 241505377, 242067841, + 242650717, 242860069, 243583201, 243955141, 244883981, 245006623, 245950561, 246099317, 246282511, 246434761, + 246658441, 247318957, 247321301, 247416101, 249582481, 250436033, 250958401, 250988173, 251528401, 251663837, + 251855893, 252853921, 253610281, 253893397, 255416897, 256831433, 257590661, 258020473, 258043229, 258234401, + 258944401, 259763093, 259765747, 260156101, 260518801, 260736341, 260963389, 261186001, 261703417, 262979501, + 263428181, 264269449, 264384469, 265020001, 265584133, 265735969, 265836161, 266790481, 266925601, 270525737, + 271272569, 271763467, 271826629, 271950829, 273361789, 273480637, 274701913, 274810241, 274919401, 275283401, + 275619961, 276018913, 276131137, 276542401, 276638321, 277787141, 278943061, 279377281, 280885153, 282253141, + 282471853, 282769771, 283900961, 284166877, 284301751, 284736091, 284834299, 285820501, 286316801, 287160301, + 287449091, 287715121, 288099001, 288117721, 288735277, 290643601, 290706781, 290953921, 291088513, 291461633, + 292153681, 292290181, 292433321, 292902481, 293346637, 293847721, 293938261, 295419097, 295743017, 297624961, + 297798961, 298212601, 299367877, 299736181, 301413001, 302635351, 304080001, 307629401, 307694323, 307972801, + 308483209, 309666361, 310474249, 310978027, 311177213, 311411629, 311655829, 311671361, 312408113, 312614021, + 314184487, 315034513, 315351521, 317137969, 317365933, 317641171, 317796119, 319053281, 319374577, 319440769, + 319726177, 320326003, 321324589, 321850849, 322469701, 322941881, 324477697, 325028089, 325352101, 325546873, + 326266051, 326405713, 326469137, 326628721, 326694301, 326695141, 327073601, 327093409, 327398009, 328302901, + 329153653, 329769721, 330198331, 330759617, 331658081, 331934989, 337135501, 337420679, 337665901, 337783981, + 338125537, 338458807, 338914369, 339195097, 339492169, 339794641, 341958121, 341994131, 343017529, 343052833, + 344201441, 344255551, 344776301, 346080391, 348989101, 349752913, 350031973, 350244577, 351058753, 351177769, + 352802803, 352932337, 353815801, 353932801, 354062809, 356604421, 356836819, 357348601, 357872971, 358416577, + 359394751, 359727073, 360145633, 360375181, 360787771, 361307521, 361312337, 362569201, 363170837, 363430637, + 364550761, 365077373, 365231401, 366487201, 366532321, 366652201, 367559501, 367632301, 368016949, 368476501, + 369667561, 371011801, 371611153, 372167101, 373012777, 373533617, 373669453, 373906513, 374346361, 374988661, + 376957153, 377192353, 377334497, 377458849, 377806687, 377869031, 378792649, 379732501, 380137633, 382304161, + 384100001, 385175113, 385319089, 387072661, 388695301, 390609941, 390612221, 391014937, 392679737, 393611653, + 394723177, 396864469, 399156661, 399302581, 399647221, 400385701, 400557109, 401100881, 403095967, 403293313, + 405739681, 405782623, 407737201, 407889161, 409302001, 409458241, 410613809, 410680357, 411618241, 411851389, + 412836689, 413138881, 413429801, 413778817, 414216461, 414368641, 415200361, 415204501, 415476343, 416964241, + 417767201, 417779909, 418044563, 418226581, 418616161, 418617281, 418667401, 419184481, 420607441, 421942951, + 422429041, 422928101, 423384001, 423465001, 424175761, 424411501, 424431541, 425967301, 426174101, 426219649, + 426770437, 426783811, 427294141, 428180191, 428758201, 429135841, 429509837, 430046857, 430381921, 430646401, + 430733701, 432227449, 434042801, 435016187, 435358657, 435993301, 436465501, 437247841, 437462101, 437597101, + 437866087, 439309261, 441354497, 441650591, 441758461, 442050577, 442181291, 442543553, 444660421, 445429693, + 446414621, 446619617, 449501761, 450807481, 450866021, 450872573, 452990401, 453366029, 453967739, 454745773, + 455198563, 457274161, 457320533, 459785089, 460251733, 460585861, 461151121, 461272267, 461329601, 462587329, + 462639409, 462701513, 464012033, 464955857, 465505633, 466290949, 466758181, 467100937, 468410113, 468950021, + 470120257, 470268137, 470644021, 471535373, 471664513, 472814413, 473581057, 474892741, 474970501, 474983881, + 475723849, 478614067, 479962009, 480668347, 481153501, 481239361, 482488393, 482824669, 482921297, 483006889, + 483029821, 483945601, 484200289, 486063001, 486902929, 487896601, 488104681, 488169289, 488585521, 488656981, + 489994201, 490950461, 491738801, 493108481, 494288677, 495909871, 496109729, 496560349, 497148599, 497285713, + 498662561, 498706651, 498905189, 500747293, 501172241, 501472333, 502686713, 504870241, 505473263, 505532773, + 505798213, 506349421, 507142567, 507323521, 508606771, 509302873, 509551201, 510925609, 511098521, 511215521, + 511611673, 512330281, 514738981, 516045197, 516259657, 516764063, 517662001, 518216201, 518548801, 521501473, + 522390109, 522758233, 523756711, 526067821, 526359289, 526686889, 528013333, 528043753, 528220117, 530630701, + 531095029, 531681281, 532126801, 532758241, 532800133, 533429881, 534782293, 535252867, 535428577, 535517581, + 536003333, 536114197, 536342419, 536870911, 540207097, 540621181, 540654409, 540680141, 542497201, 542536457, + 544861633, 545550433, 545622401, 546102481, 546117301, 546322201, 548080513, 548989561, 549308761, 550132741, + 550230409, 550635373, 550853137, 551313001, 552573793, 553027201, 554487121, 554599051, 554964001, 555321007, + 555465601, 556001377, 556069849, 556095433, 556114609, 557165209, 558235109, 558900821, 558977761, 561448487, + 562367821, 563298061, 563947141, 564298489, 564689381, 565664761, 565707061, 567358513, 567596401, 568902001, + 568967221, 569332177, 569495809, 570941881, 572123521, 572228929, 572430769, 572567353, 572936869, 573817861, + 573862021, 574998841, 575326033, 576724219, 577210181, 577352641, 577613261, 579606301, 579956653, 581618143, + 582389641, 582799951, 585261637, 586706821, 587343541, 588049001, 591242653, 591822001, 592467451, 592468777, + 593682169, 593728489, 595405201, 595590841, 597537361, 597717121, 599135767, 599945293, 600893921, 601606487, + 602379181, 604584221, 605454917, 605961049, 606872449, 607148653, 607750681, 608421637, 608917753, 609361567, + 609813781, 611097401, 611374453, 611770513, 611812321, 611817421, 612006253, 613849601, 614742241, 615361183, + 615760133, 615895897, 616280897, 617087701, 619239457, 619365121, 619480601, 620169409, 620544961, 620755537, + 621769669, 622137601, 623735953, 624303241, 624732421, 625060801, 625482001, 626717471, 627886657, 628868467, + 629134081, 630496621, 630622753, 630811513, 631767943, 631974613, 633289807, 635155291, 635291077, 635319361, + 636287653, 636337073, 636936697, 638502913, 638837761, 639305921, 639807781, 640650931, 640977373, 643036321, + 643316461, 643552909, 644004817, 644453633, 644457551, 644731357, 644900257, 645556481, 648056449, 648328801, + 651011329, 651064681, 651151801, 651514753, 652469641, 653235841, 653260633, 655264369, 657732349, 659526601, + 659846021, 660095641, 660754117, 661122881, 661207177, 662134201, 663760681, 665462081, 668498321, 670976641, + 670987021, 671716921, 672103001, 672108193, 673778827, 675260477, 676359391, 678481693, 680983817, 681019921, + 681124207, 681303241, 682528687, 683316001, 683362681, 684350833, 686059921, 687741401, 689537441, 690035713, + 690562601, 691131349, 692535637, 693456521, 694116893, 696042901, 696321949, 696998251, 697821857, 698192041, + 698819711, 702683101, 705303457, 705351583, 706728377, 707691601, 709409993, 710382401, 710617861, 710721001, + 714490481, 717096641, 717653129, 717831211, 720767521, 722955773, 724160251, 724969087, 725508241, 731276521, + 732805681, 734166217, 736668013, 739444021, 739576801, 740988151, 741182401, 741214237, 742017181, 742550401, + 744500641, 745493761, 745745461, 746331041, 747406801, 748638001, 749172821, 749640161, 750632137, 751226401, + 751705597, 752186593, 753233717, 753574537, 753594001, 754020361, 754874257, 756205633, 756271909, 756980137, + 758581651, 758687581, 758901701, 759252367, 759266621, 759638881, 762699649, 763907741, 764033999, 764240611, + 765378241, 766303693, 766823797, 770201221, 770909107, 770937931, 771043201, 771337891, 772495777, 773131927, + 773807401, 775368901, 775896181, 776443769, 777218989, 781471001, 782823281, 784450393, 784777393, 784783477, + 784966297, 787085857, 787209277, 788046901, 788931361, 789082001, 790453049, 791118043, 792144161, 792145729, + 794201333, 794399041, 794937601, 795064909, 796072003, 796200901, 796560703, 797418997, 797834017, 799162561, + 799630753, 799898833, 799916101, 801093011, 801227269, 801866647, 804978721, 805505957, 805771501, 807115753, + 807218413, 808214161, 809790881, 810023881, 810455101, 811110301, 811478533, 811607777, 811730923, 815430533, + 815796413, 816024161, 816215401, 816549121, 817832329, 818401321, 819466201, 819743233, 822018961, 822531841, + 824389441, 826004467, 829512001, 830664451, 831933901, 832048447, 832127489, 832169857, 833610751, 837766217, + 839268139, 839280691, 839908217, 840749761, 841217653, 841660961, 842785841, 842824981, 842960981, 843161887, + 844545271, 845376533, 846961321, 848090377, 848755969, 849548671, 852432769, 854094781, 854868257, 855734401, + 857100421, 857902861, 858687103, 859096477, 860334301, 862082677, 862678081, 863196181, 863609113, 863984881, + 865242841, 867022747, 867110501, 867638201, 868088341, 868111597, 868691401, 870985223, 871157233, 871195561, + 871908481, 876850801, 877542481, 878492941, 878940833, 879995689, 880870513, 880922657, 883276549, 884304037, + 884952001, 886180429, 887795221, 888868441, 892740853, 893692819, 894264337, 896901461, 897087361, 897283213, + 899019353, 900736411, 901848301, 902566501, 903108821, 903390643, 905040953, 907378669, 907670501, 907711561, + 908005249, 910202509, 910867481, 911484421, 914348737, 914906539, 920375821, 920696653, 921858631, 922845241, + 923437213, 926756881, 927106561, 927877001, 929159941, 930530701, 932148253, 933729421, 935794081, 936421141, + 937675393, 938376181, 939947009, 940123801, 941056273, 941734657, 943271569, 944832533, 946034057, 946787377, + 947878081, 949317217, 949697233, 952893881, 954924013, 957600541, 957631249, 958131157, 958735681, 960269377, + 960946321, 962442001, 962489557, 962523169, 964412837, 965501857, 967266451, 967287751, 967790401, 968283247, + 968413217, 968751241, 969528337, 970586713, 971975071, 974113601, 974471243, 974774401, 975576281, 976396961, + 977483449, 979363153, 980056507, 980725201, 981484561, 983456377, 984133441, 984252001, 985052881, 985075681, + 987842101, 994133479, 995586373, 995650921, 997836841, 998489017, 998590601, 998596741, 998724481, 999828727, + 1002261781, 1003062061, 1005402133, 1005833971, 1006800829, 1008777001, 1008839999, 1009025263, 1009140161, 1011319501, + 1011333061, 1011570457, 1011909271, 1012438391, 1013833153, 1015339441, 1015626151, 1017748057, 1020515761, 1021281301, + 1022336611, 1024041853, 1024123501, 1024605121, 1025035129, 1026738161, 1027744453, 1028494429, 1034252929, 1034958601, + 1040234231, 1049584313, 1050102901, 1050535501, 1054999441, 1055009117, 1056121453, 1057426651, 1063212481, 1065508321, + 1065602281, 1066972301, 1069388497, 1070639389, 1070941987, 1071512749, 1071643249, 1072898711, 1073159281, 1073288581, + 1073484823, 1075100041, 1077133397, 1078467589, 1081798061, 1082472553, 1084241341, 1084444481, 1090858081, 1093150081, + 1093352833, 1093526353, 1094042321, 1097416321, 1098743563, 1100624857, 1101623381, 1101673501, 1102573501, 1102750013, + 1104194521, 1105038871, 1106529761, 1106580817, 1106595493, 1107138961, 1108135381, 1109304913, 1110582947, 1111205873, + 1111939201, 1112671603, 1114277221, 1116379301, 1117202557, 1117785881, 1117828001, 1117890019, 1119412321, 1120076281, + 1120981021, 1121176981, 1123406047, 1123625501, 1123727617, 1124396521, 1125038377, 1127040769, 1130933429, 1134367777, + 1138289041, 1138607233, 1139137057, 1140573601, 1142466151, 1147434289, 1148578201, 1150229761, 1151670001, 1153164097, + 1153440289, 1154343961, 1154691409, 1154987209, 1155939709, 1156761911, 1156993373, 1157839381, 1159421509, 1160844821, + 1163098249, 1163227759, 1164218641, 1165717129, 1166475601, 1166598217, 1168221121, 1168256953, 1168492417, 1173229201, + 1173545533, 1174300093, 1180970407, 1181566219, 1183338241, 1184554801, 1186325981, 1187235193, 1191153937, 1191216133, + 1192314817, 1192412033, 1192903531, 1193229577, 1193557093, 1195524181, 1196852273, 1198650961, 1198880261, 1200456577, + 1200778753, 1202142061, 1204205449, 1205606533, 1205772499, 1209998077, 1210393801, 1210562701, 1210653541, 1213619761, + 1217181061, 1217823517, 1217924159, 1219816261, 1219858921, 1220114377, 1221127013, 1222861271, 1223531677, 1223941657, + 1225128829, 1226230297, 1226855293, 1227220801, 1229491063, 1229751667, 1230446653, 1231362793, 1232445677, 1234125721, + 1234646533, 1235188597, 1235864033, 1236313501, 1236442421, 1238825569, 1242171349, 1242858317, 1249166881, 1249785941, + 1250656621, 1252236421, 1254277909, 1255665613, 1257102001, 1258903981, 1260332137, 1263293281, 1264145401, 1265477791, + 1266003461, 1266273793, 1266425101, 1267345081, 1269295201, 1269835201, 1270193401, 1270489621, 1270667353, 1272558739, + 1272866167, 1282447477, 1282568741, 1285636801, 1286298133, 1286298263, 1296613501, 1297443913, 1299072721, 1299784141, + 1299963601, 1301509249, 1301926081, 1302745481, 1306836001, 1307004641, 1307520469, 1307823661, 1308758533, 1308998741, + 1309723213, 1309983901, 1310329567, 1311255661, 1311616153, 1312332001, 1312573123, 1313396221, 1315858381, 1316169541, + 1318126321, 1318717531, 1319978701, 1319992181, 1320793813, 1321058213, 1323668917, 1325172421, 1325329297, 1328256247, + 1329174601, 1329431689, 1331973329, 1341010577, 1341926401, 1343575381, 1344597577, 1344975721, 1345514101, 1345523401, + 1347387361, 1348964401, 1350685001, 1351126261, 1352453257, 1353051517, 1356241321, 1356328121, 1357459183, 1362463807, + 1362515701, 1362742561, 1365662917, 1366587661, 1366608377, 1368769681, 1371908137, 1372681861, 1375322101, 1376799577, + 1378646179, 1379464633, 1382453333, 1383283129, 1385656829, 1386705433, 1388972353, 1389353941, 1389975149, 1391890033, + 1393851553, 1394640941, 1394746081, 1394942473, 1397357851, 1398883201, 1400859847, 1401840833, 1404008369, 1404253369, + 1406826241, 1406851249, 1409372779, 1413803197, 1414154827, 1414529533, 1415969101, 1417986901, 1421475031, 1424503849, + 1425860101, 1426319563, 1426534201, 1427771089, 1428966001, 1432354901, 1435091377, 1438648993, 1440231941, 1440922891, + 1441139641, 1441678411, 1442945689, 1443388481, 1443742273, 1446298309, 1446434677, 1446818651, 1448921633, 1451635201, + 1454282449, 1454445413, 1456527461, 1457378449, 1461307717, 1463065501, 1463178817, 1463992661, 1464568381, 1465908193, + 1465945417, 1468540477, 1468824787, 1469059481, 1469960377, 1470080501, 1470650851, 1471628401, 1472221921, 1473580001, + 1477289941, 1481626513, 1482274513, 1482876673, 1483873861, 1483918801, 1485061471, 1486564301, 1493114149, 1495190699, + 1497221281, 1497965713, 1499971457, 1499989177, 1500142001, 1501165097, 1502171117, 1502403121, 1503240559, 1503705601, + 1504139521, 1504832033, 1507746241, 1509156013, 1510870241, 1511558533, 1515175087, 1515785041, 1517039371, 1518014689, + 1518290707, 1520190341, 1521221473, 1522302121, 1526732803, 1529648231, 1529819971, 1530495289, 1532419099, 1532569681, + 1532755369, 1533343261, 1534063081, 1535020133, 1536112001, 1536251047, 1536883357, 1537433899, 1537641691, 1538012449, + 1539583921, 1539804001, 1540454761, 1540550413, 1541047813, 1541849761, 1541955409, 1544145121, 1545019813, 1545177581, + 1546106773, 1546340401, 1546508057, 1547140841, 1547543161, 1547712601, 1550924873, 1554270481, 1557118081, 1560312001, + 1560620041, 1561800833, 1565893201, 1566594551, 1567830241, 1568916311, 1574362441, 1574601601, 1577983489, 1578009401, + 1580449201, 1581576641, 1581714481, 1582783777, 1583230241, 1583658649, 1586436193, 1587650401, 1590394313, 1593706201, + 1595647351, 1595887921, 1598197201, 1602517949, 1603765021, 1603810561, 1603994701, 1609916491, 1609935913, 1612121473, + 1614508267, 1617795181, 1617921667, 1619447741, 1620646177, 1627103521, 1627898401, 1628692201, 1630062253, 1630307617, + 1631314609, 1632286673, 1632513601, 1633044241, 1636185601, 1637434657, 1637436457, 1637930893, 1638294661, 1639351981, + 1639846391, 1641971701, 1642814653, 1644637051, 1645413001, 1647225529, 1648076041, 1649430889, 1650265549, 1650682153, + 1654940509, 1655660761, 1656229921, 1656280033, 1656917377, 1659009601, 1661202113, 1668037621, 1668926629, 1669893661, + 1671603667, 1671714241, 1672125131, 1674091141, 1674658133, 1675978193, 1678274581, 1679130641, 1680901381, 1683174533, + 1685433413, 1686001861, 1687248001, 1691745821, 1692605041, 1694128129, 1695158921, 1696893101, 1698707377, 1699279441, + 1700250049, 1709909293, 1710753001, 1712392321, 1714322377, 1716160321, 1716714793, 1716774481, 1718013133, 1718088301, + 1719197621, 1721061497, 1721986313, 1722007169, 1722685777, 1725675451, 1726372441, 1731048937, 1731995497, 1732924001, + 1734059291, 1734285601, 1735071913, 1736481601, 1738687469, 1740214841, 1742288881, 1742815621, 1743166441, 1744605097, + 1746692641, 1746721681, 1749124829, 1750412161, 1754818561, 1757148121, 1760014561, 1766984389, 1767234613, 1769091241, + 1769267761, 1770236893, 1771303801, 1772267281, 1773582977, 1776439261, 1776820033, 1779649381, 1779892577, 1784306273, + 1784638309, 1785843547, 1786005521, 1787934881, 1790023861, 1791426787, 1792442737, 1792588813, 1794814103, 1801558201, + 1801774081, 1802510669, 1803768091, 1804906517, 1805947313, 1809888967, 1816408273, 1817067169, 1819829749, 1820306953, + 1821514633, 1828682101, 1828887061, 1831258601, 1835114401, 1837156049, 1837599769, 1839568981, 1841034961, 1841099261, + 1841479501, 1844028961, 1846171781, 1847811673, 1849964117, 1850233897, 1850598961, 1852496761, 1853926777, 1854084649, + 1854940231, 1856689453, 1857221281, 1858098497, 1858197961, 1860373241, 1861026133, 1861880689, 1862880401, 1866409861, + 1867906721, 1868682241, 1871987041, 1872937057, 1873177693, 1874634721, 1874849929, 1878691753, 1879111697, 1879623157, + 1879775501, 1883509633, 1883785681, 1885915841, 1894909141, 1894955311, 1897700113, 1899081757, 1899525601, 1900687381, + 1903447841, 1904658913, 1905958891, 1908088001, 1909566073, 1910134309, 1911197947, 1912950241, 1914303841, 1915391521, + 1916987593, 1917397637, 1920301951, 1921309633, 1922092567, 1922687293, 1923224689, 1923311317, 1923845801, 1924201501, + 1925042737, 1928903971, 1929862849, 1930403333, 1930447501, 1930534453, 1930915169, 1934350351, 1938264241, 1940048881, + 1943951041, 1944125633, 1945042181, 1950987193, 1952513369, 1952968753, 1957705177, 1959659857, 1960708261, 1963149553, + 1965007601, 1968002149, 1970065681, 1974474049, 1977257441, 1982123893, 1982826961, 1988071801, 1988713189, 1988835713, + 1988965861, 1989192277, 1991063449, 1995784961, 1995830761, 1996231189, 1996339649, 1997844157, 1998780001, 1999053601, + 1999111801, 1999743661, 2004299641, 2007646961, 2013554869, 2013834961, 2016481477, 2017021333, 2017509601, 2019564769, + 2021392369, 2021884343, 2027675701, 2028279793, 2028631361, 2028812399, 2029830409, 2030600833, 2036224321, 2043173273, + 2049293401, 2050617713, 2052149221, 2054711381, 2055634561, 2057267941, 2057835781, 2058072041, 2059739221, 2062612033, + 2068867841, 2070739441, 2072624761, 2076192007, 2081039297, 2081551753, 2082146617, 2083034113, 2083997441, 2085453649, + 2085882661, 2086645009, 2093300401, 2095627153, 2096046457, 2097317377, 2100292841, 2101470541, 2101744837, 2104994449, + 2106147457, 2107148761, 2114643217, 2115769633, 2115986557, 2116483027, 2116541221, 2117031263, 2117555641, 2118621097, + 2120096161, 2123601751, 2124078653, 2124691213, 2127197489, 2128104001, 2129304997, 2130134533, 2131004737, 2131811501, + 2140699681, 2140771609, 2141340833, 2144961253, 2147418113, 2147429509, 2152627801, 2154446641, 2155416251, 2156151313, + 2164282177, 2168431201, 2170282969, 2172155819, 2173499329, 2173540951, 2173579801, 2175126601, 2175406201, 2175646177, + 2177374321, 2177645557, 2178082901, 2178939221, 2180221201, 2182281601, 2182802689, 2185362233, 2187717761, 2193980881, + 2199617701, 2200115713, 2201924341, 2202101761, 2202205897, 2203649197, 2203856497, 2206095589, 2210578759, 2213431729, + 2216960929, 2217879901, 2219072017, 2224252801, 2229468697, 2231332357, 2233031701, 2240507821, 2241880033, 2241982009, + 2244932281, 2245519981, 2246762899, 2248354153, 2251732033, 2254314241, 2254757077, 2256197761, 2256748777, 2256751837, + 2262861901, 2269307587, 2274584089, 2283289681, 2284416181, 2289251669, 2289624793, 2290316377, 2290910257, 2291205461, + 2292068143, 2295209281, 2296995121, 2299190401, 2300628601, 2300795353, 2301745249, 2304120001, 2308966661, 2309241601, + 2309405617, 2311558021, 2311575001, 2315137261, 2320527613, 2323147201, 2324867399, 2329584217, 2330569541, 2331181621, + 2335341601, 2338157597, 2338728001, 2340460487, 2345907961, 2347597981, 2352371251, 2354453561, 2355230749, 2355320101, + 2355622721, 2355649921, 2355735089, 2358534361, 2360261989, 2370771181, 2370928337, 2371350101, 2372976563, 2374232977, + 2375415841, 2377166401, 2378309041, 2381782597, 2382678101, 2383164577, 2385574201, 2389072321, 2389544977, 2393708761, + 2394311233, 2398393661, 2404912501, 2411128441, 2412172153, 2412675721, 2413973071, 2422296241, 2423401681, 2425249601, + 2428648967, 2428870753, 2428986913, 2429407961, 2430697513, 2431136401, 2431144801, 2432761633, 2432860273, 2433791593, + 2434964321, 2434974433, 2435091221, 2436691321, 2437907779, 2438778413, 2442050353, 2442454561, 2443708961, 2444950561, + 2448039497, 2448374689, 2453473049, 2454285751, 2456536681, 2457846161, 2463713281, 2471205361, 2473120961, 2473189441, + 2473823353, 2474308069, 2474676949, 2476283239, 2477814193, 2478643907, 2480147521, 2480343553, 2482435981, 2482682131, + 2484408301, 2486017249, 2488420801, 2488591117, 2492480233, 2494660033, 2494984321, 2495834329, 2499327041, 2501012599, + 2501771329, 2502525637, 2504008609, 2506529257, 2506733189, 2507121037, 2508178843, 2513230891, 2516684801, 2519297089, + 2525070241, 2526566041, 2528291341, 2529410281, 2529827821, 2529854713, 2530351561, 2532630787, 2533465661, 2533797017, + 2535516173, 2537105761, 2539406281, 2539736257, 2540469901, 2541660367, 2542479481, 2544590161, 2545934077, 2548051801, + 2550139253, 2550780277, 2551365769, 2552418761, 2553272929, 2555391481, 2561945401, 2564536201, 2565186137, 2570087521, + 2571180247, 2575060949, 2575737361, 2577345541, 2582092189, 2582246701, 2582952769, 2583322381, 2584460701, 2588054401, + 2588582089, 2590663681, 2593065721, 2595276353, 2597289241, 2597294701, 2598933481, 2600611861, 2602343521, 2602378721, + 2604465013, 2604803701, 2611122229, 2611461529, 2613382201, 2614688801, 2616180821, 2617563031, 2621080741, 2621977627, + 2622993661, 2624549929, 2625903601, 2626783921, 2627284987, 2630643401, 2632605049, 2634284801, 2634804481, 2634820813, + 2638067881, 2639099233, 2642159809, 2642582251, 2646751249, 2646790033, 2648662777, 2649907201, 2650820329, 2651507713, + 2654716321, 2656494271, 2658630913, 2658696301, 2659265701, 2668095181, 2668469431, 2670972949, 2672605657, 2672651521, + 2676053333, 2677147201, 2677821121, 2678785621, 2681041843, 2682823681, 2683742491, 2684284441, 2687655169, 2688124001, + 2689427281, 2690408533, 2690867401, 2693739751, 2695115473, 2700818017, 2700891839, 2701878941, 2704957909, 2706863833, + 2707661501, 2716157989, 2716275007, 2717428033, 2719319513, 2721666817, 2721721939, 2723859001, 2725357249, 2733156029, + 2736316301, 2738184697, 2740336561, 2744329909, 2746021741, 2753333227, 2753538001, 2759392633, 2765323397, 2766006253, + 2767672189, 2769080161, 2769602333, 2774295577, 2777887297, 2778304273, 2779477741, 2781117721, 2781226477, 2786028337, + 2787998641, 2789218909, 2800352011, 2805762961, 2809635901, 2812672981, 2814748201, 2823570433, 2824256377, 2824804693, + 2824854913, 2828205397, 2832384133, 2832743713, 2837697773, 2837917633, 2840634109, 2840871041, 2841190381, 2847894377, + 2848466281, 2848722131, 2855046421, 2855071801, 2855512909, 2862066481, 2865483601, 2866005139, 2866527841, 2870377309, + 2871536561, 2872527733, 2872948321, 2874382853, 2877769501, 2881429741, 2882370481, 2885594497, 2887955533, 2890316801, + 2890414873, 2892426029, 2894667781, 2895004927, 2899294889, 2903776129, 2915953633, 2916247819, 2918295451, 2920691161, + 2923042141, 2924158001, 2929062533, 2929106753, 2930831641, 2931708097, 2932327549, 2936227603, 2936958181, 2941174897, + 2941343633, 2944555681, 2944677961, 2945208001, 2945549881, 2951136343, 2956724317, 2957320351, 2965700233, 2967053953, + 2968206601, 2974506841, 2975377429, 2976930001, 2978766341, 2980689601, 2986025677, 2987414977, 2990152901, 2993462713, + 2993495041, 2994098281, 2994415201, 2998202353, 2998919873, 3000688381, 3001561441, 3002647829, 3004443679, 3009628301, + 3011421841, 3014101261, 3015502181, 3016957381, 3017444761, 3018147217, 3018576689, 3019916461, 3025350343, 3026575553, + 3028586471, 3030393901, 3033332641, 3034402681, 3034817209, 3035375047, 3036079729, 3037295801, 3037781251, 3038880473, + 3039681457, 3041984353, 3042630533, 3048159841, 3050190163, 3056100623, 3056160929, 3057886591, 3058670677, 3059397793, + 3063685633, 3065998717, 3076505209, 3077122133, 3079496551, 3082054697, 3082068013, 3083053387, 3083537689, 3083884651, + 3088408429, 3089013313, 3091019777, 3094763851, 3099670657, 3103800701, 3112974481, 3114125071, 3115667521, 3120445697, + 3122287981, 3129914881, 3133899409, 3135040133, 3143282221, 3145410761, 3150972917, 3156599161, 3156643141, 3157579861, + 3163106953, 3166504273, 3167442721, 3170262409, 3172658653, 3175204531, 3175255717, 3178375201, 3181356263, 3181391641, + 3182606857, 3182655361, 3182891401, 3185472001, 3187035113, 3187421077, 3187939921, 3196397821, 3196431829, 3197565001, + 3197632441, 3197911001, 3197911741, 3199164901, 3205663921, 3207297773, 3208902491, 3212465437, 3215031751, 3217412881, + 3219808411, 3221580281, 3222693421, 3224143441, 3225081473, 3227082823, 3227209057, 3229131137, 3233558021, 3237992101, + 3242533897, 3248236309, 3250348417, 3250700737, 3252148621, 3257334541, 3258647809, 3258892801, 3261114601, 3263097641, + 3263568901, 3263626957, 3264820001, 3265122451, 3267417677, 3268506541, 3268841941, 3270933121, 3271999249, 3272030401, + 3272702497, 3274264033, 3275671969, 3276075709, 3277047649, 3278640289, 3280067129, 3282974857, 3287174129, 3288757249, + 3295362727, 3296403601, 3299246833, 3302322241, 3304307341, 3305829073, 3306686659, 3306957593, 3310858777, 3312489577, + 3312536569, 3313196881, 3315139717, 3320669437, 3323308501, 3323590463, 3323829169, 3328354801, 3332800021, 3334350781, + 3340214413, 3342005633, 3344191241, 3346172189, 3347908801, 3349218881, 3350993969, 3352091557, 3355382857, 3355953001, + 3357417181, 3359737921, 3360511981, 3369139201, 3371024521, 3371452921, 3371693063, 3372667121, 3373086601, 3381052177, + 3381901921, 3385842877, 3386603221, 3387014401, 3387487351, 3389030261, 3395091311, 3399205591, 3399890413, 3402234749, + 3407609221, 3407772817, 3407952169, 3408135121, 3409339393, 3411250081, 3411574801, 3411829693, 3412575097, 3415379701, + 3415832137, 3417522841, 3420143941, 3421845001, 3423222757, 3423580481, 3427050673, 3428133103, 3429457921, 3429982081, + 3430804297, 3432695921, 3432997537, 3433458073, 3434575327, 3435973837, 3440195713, 3443704261, 3449768513, 3450717901, + 3453900913, 3458257741, 3461861761, 3463907761, 3464236901, 3466158361, 3470716657, 3474335437, 3480174001, 3482161261, + 3485747521, 3489958697, 3491763493, 3492178873, 3492883081, 3493262761, 3497607433, 3504132113, 3512030497, 3512291021, + 3512369857, 3513604657, 3516565057, 3519318721, 3524086333, 3525088961, 3529119361, 3529864391, 3532687201, 3533662129, + 3533856913, 3538213381, 3542303047, 3543203333, 3548378341, 3549286001, 3549988261, 3552158521, 3553567057, 3557646401, + 3562963973, 3563340457, 3566428301, 3574891757, 3582711841, 3583249921, 3583604161, 3584800801, 3586833253, 3587553971, + 3589937261, 3590409439, 3593276353, 3594110081, 3596491907, 3596815169, 3598772761, 3602006101, 3605151241, 3611571121, + 3612298321, 3612825221, 3614770573, 3616574081, 3620631169, 3628526287, 3630596257, 3631828481, 3632452741, 3635993089, + 3649116277, 3649965281, 3650158849, 3651572609, 3656355841, 3658730893, 3662387977, 3662503093, 3663084541, 3668926801, + 3669587533, 3672754633, 3677180797, 3679657997, 3682471321, 3685647701, 3685775741, 3692307161, 3695628133, 3697278427, + 3700801861, 3705582073, 3705623281, 3708123301, 3708905341, 3709626961, 3712887289, 3713287801, 3713448769, 3718226401, + 3721486081, 3723410161, 3723699373, 3725016749, 3727828501, 3729097633, 3733761739, 3736293461, 3745192001, 3746101189, + 3749383681, 3751554581, 3751782737, 3754680403, 3756668401, 3759781369, 3760622689, 3760896133, 3762110881, 3767640601, + 3773061337, 3774337201, 3784123501, 3787491457, 3798040471, 3798626833, 3799111681, 3800084401, 3805699501, 3807112123, + 3807308269, 3807749821, 3809018947, 3813919453, 3817561777, 3817706621, 3821233121, 3827035237, 3832807681, 3833208961, + 3842941741, 3846174151, 3846532801, 3847106803, 3850058689, 3852800033, 3863326897, 3865604023, 3867183937, 3874471147, + 3874523017, 3875096893, 3875965417, 3886515361, 3886643801, 3887423437, 3887635753, 3891892421, 3891919417, 3894053311, + 3896079281, 3897241129, 3897869201, 3898906129, 3900327241, 3903711841, 3905533721, 3905876501, 3907577521, 3907752241, + 3912174421, 3914880337, 3914923211, 3915467341, 3915604421, 3915921241, 3918227437, 3922321561, 3926912669, 3929293061, + 3934940833, 3935864017, 3936123601, 3945165841, 3947233201, 3947383201, 3953408801, 3953949421, 3955572001, 3958597301, + 3958930441, 3959578801, 3960728641, 3962037061, 3966350203, 3967343161, 3971095301, 3973556837, 3979485931, 3982017601, + 3987528793, 3987960913, 3991124341, 3992697997, 3997536427, 4005660961, 4007365741, 4011996871, 4015548769, 4017684529, + 4018283501, 4020144133, 4026822577, 4027012021, 4027518961, 4028465873, 4028771849, 4031223841, 4034969401, 4034993269, + 4035498409, 4036395581, 4042538497, 4044601751, 4044884689, 4048493983, 4053267217, 4054039841, 4057195309, 4058433931, + 4059776533, 4060942381, 4061009971, 4064633821, 4067039461, 4067887501, 4068671881, 4071644893, 4075241633, 4075721921, + 4076009857, 4079665633, 4079682361, 4083376067, 4085074909, 4088147617, 4088838913, 4092929149, 4098258707, 4099180801, + 4100934241, 4103745689, 4105691393, 4108970251, 4109461709, 4109711581, 4110320663, 4113013141, 4115891893, 4117058221, + 4117447441, 4121286907, 4127050621, 4129914673, 4133928761, 4135847101, 4136916001, 4137262541, 4138838401, 4139015987, + 4150174393, 4155375349, 4157008813, 4162880401, 4166032873, 4183664101, 4185636781, 4186561633, 4187360341, 4191864013, + 4192060699, 4195843037, 4196323561, 4204344601, 4206006229, 4206295433, 4212105409, 4215885697, 4218900001, 4220122321, + 4232966251, 4234224601, 4237212061, 4243744201, 4244022301, 4244663651, 4247990917, 4250920459, 4251904273, 4255695013, + 4257003353, 4261352869, 4271267333, 4275011401, 4277526901, 4278305651, 4282867213, 4285148981, 4293088801, 4294901761, + } + + primes16 = [65536]byte{ + 2, 1, 1, 2, 1, 2, 1, 4, 3, 2, // 0-9 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 10-19 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 20-29 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 30-39 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 40-49 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 50-59 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 60-69 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 70-79 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 80-89 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 90-99 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 100-109 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 110-119 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 120-129 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 130-139 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 140-149 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 150-159 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 160-169 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 170-179 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 180-189 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 190-199 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 200-209 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 210-219 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 220-229 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 230-239 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 240-249 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 250-259 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 260-269 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 270-279 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 280-289 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 290-299 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 300-309 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 310-319 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 320-329 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 330-339 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 340-349 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 350-359 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 360-369 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 370-379 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 380-389 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 390-399 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 400-409 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 410-419 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 420-429 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 430-439 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 440-449 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 450-459 + 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 460-469 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 470-479 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 480-489 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 490-499 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 500-509 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 510-519 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 520-529 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 530-539 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 540-549 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 550-559 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 560-569 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 570-579 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 580-589 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 590-599 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 600-609 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 610-619 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 620-629 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 630-639 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 640-649 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 650-659 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 660-669 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 670-679 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 680-689 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 690-699 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 700-709 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 710-719 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 720-729 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 730-739 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 740-749 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 750-759 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 760-769 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 770-779 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 780-789 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 790-799 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 800-809 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 810-819 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 820-829 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 830-839 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 840-849 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 850-859 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 860-869 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 870-879 + 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 880-889 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 890-899 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 900-909 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 910-919 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 920-929 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 930-939 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 940-949 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 950-959 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 960-969 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 970-979 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 980-989 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 990-999 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 1000-1009 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 1010-1019 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1020-1029 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 1030-1039 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 1040-1049 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1050-1059 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 1060-1069 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 1070-1079 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 1080-1089 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 1090-1099 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 1100-1109 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 1110-1119 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 1120-1129 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 1130-1139 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1140-1149 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 1150-1159 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 1160-1169 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1170-1179 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 1180-1189 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 1190-1199 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 1200-1209 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 1210-1219 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 1220-1229 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 1230-1239 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 1240-1249 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 1250-1259 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 1260-1269 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 1270-1279 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 1280-1289 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 1290-1299 + 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 1300-1309 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 1310-1319 + 1, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 1320-1329 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 1330-1339 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 1340-1349 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1350-1359 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 1360-1369 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 1370-1379 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 1380-1389 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 1390-1399 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 1400-1409 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 1410-1419 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 1420-1429 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 1430-1439 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 1440-1449 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 1450-1459 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1460-1469 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1470-1479 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 1480-1489 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 1490-1499 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1500-1509 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 1510-1519 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 1520-1529 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 1530-1539 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 1540-1549 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 1550-1559 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 1560-1569 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 1570-1579 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 1580-1589 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 1590-1599 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 1600-1609 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 1610-1619 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 1620-1629 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 1630-1639 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 1640-1649 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 1650-1659 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 24, // 1660-1669 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 1670-1679 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 1680-1689 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 1690-1699 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 1700-1709 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1710-1719 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 1720-1729 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 1730-1739 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 1740-1749 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 1750-1759 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 1760-1769 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 1770-1779 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 1780-1789 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1790-1799 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1800-1809 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 1810-1819 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 1820-1829 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 1830-1839 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 1840-1849 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1850-1859 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 1860-1869 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 1870-1879 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 1880-1889 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1890-1899 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 1900-1909 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 1910-1919 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1920-1929 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 1930-1939 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 1940-1949 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 1950-1959 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 1960-1969 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 1970-1979 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 1980-1989 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 1990-1999 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 2000-2009 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 2010-2019 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 2020-2029 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 2030-2039 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 2040-2049 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 2050-2059 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 2060-2069 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 2070-2079 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 2080-2089 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 2090-2099 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 2100-2109 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 2110-2119 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 2120-2129 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 2130-2139 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 2140-2149 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 2150-2159 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 2160-2169 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 2170-2179 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 2180-2189 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 2190-2199 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 2200-2209 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 2210-2219 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 2220-2229 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 2230-2239 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 2240-2249 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 2250-2259 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 2260-2269 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 2270-2279 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 2280-2289 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 2290-2299 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 2300-2309 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 2310-2319 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 2320-2329 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 2330-2339 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 2340-2349 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 2350-2359 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 2360-2369 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 2370-2379 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 2380-2389 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 2390-2399 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 2400-2409 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 2410-2419 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 2420-2429 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 2430-2439 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 2440-2449 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 2450-2459 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 2460-2469 + 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 2470-2479 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 2480-2489 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 2490-2499 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 2500-2509 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 2510-2519 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 2520-2529 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 2530-2539 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 2540-2549 + 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 2550-2559 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 2560-2569 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 2570-2579 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 2580-2589 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 2590-2599 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 2600-2609 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 2610-2619 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 2620-2629 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 2630-2639 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 2640-2649 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 2650-2659 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 2660-2669 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 2670-2679 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 2680-2689 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 2690-2699 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 2700-2709 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 2710-2719 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 2720-2729 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 2730-2739 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 2740-2749 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 2750-2759 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 2760-2769 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 2770-2779 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 2780-2789 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 2790-2799 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 2800-2809 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 2810-2819 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 2820-2829 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 2830-2839 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 2840-2849 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 2850-2859 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 2860-2869 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 2870-2879 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 2880-2889 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 2890-2899 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 2900-2909 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 2910-2919 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 2920-2929 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 2930-2939 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 2940-2949 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 2950-2959 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 2960-2969 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 2970-2979 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 2980-2989 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 2990-2999 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3000-3009 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 3010-3019 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 3020-3029 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 3030-3039 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 3040-3049 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3050-3059 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 3060-3069 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 3070-3079 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 20, // 3080-3089 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 3090-3099 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 3100-3109 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 3110-3119 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 3120-3129 + 7, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 3130-3139 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 3140-3149 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 3150-3159 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 3160-3169 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3170-3179 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 3180-3189 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 3190-3199 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 3200-3209 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 3210-3219 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 3220-3229 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 3230-3239 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3240-3249 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 3250-3259 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3260-3269 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 3270-3279 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 3280-3289 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 3290-3299 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 3300-3309 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 3310-3319 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 3320-3329 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 3330-3339 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 3340-3349 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 3350-3359 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3360-3369 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 3370-3379 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 3380-3389 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 3390-3399 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 3400-3409 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 3410-3419 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 3420-3429 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 3430-3439 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 3440-3449 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 3450-3459 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 22, // 3460-3469 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 3470-3479 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3480-3489 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 3490-3499 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3500-3509 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 3510-3519 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 3520-3529 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 3530-3539 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 3540-3549 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 3550-3559 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3560-3569 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3570-3579 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 3580-3589 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 3590-3599 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 3600-3609 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 3610-3619 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 3620-3629 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 3630-3639 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 3640-3649 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 3650-3659 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3660-3669 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 3670-3679 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3680-3689 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 3690-3699 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 3700-3709 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 3710-3719 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 3720-3729 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 3730-3739 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 3740-3749 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3750-3759 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 3760-3769 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 3770-3779 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 3780-3789 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 3790-3799 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 3800-3809 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3810-3819 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 3820-3829 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 3830-3839 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 3840-3849 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 3850-3859 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 3860-3869 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 3870-3879 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 3880-3889 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 3890-3899 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 3900-3909 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 3910-3919 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 3920-3929 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 3930-3939 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 3940-3949 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 3950-3959 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 3960-3969 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 3970-3979 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 3980-3989 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3990-3999 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 4000-4009 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 4010-4019 + 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 4020-4029 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 4030-4039 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 4040-4049 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 4050-4059 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 4060-4069 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 4070-4079 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4080-4089 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 4090-4099 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4100-4109 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 4110-4119 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 4120-4129 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 4130-4139 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 4140-4149 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 18, // 4150-4159 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 4160-4169 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 4170-4179 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 4180-4189 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4190-4199 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4200-4209 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 4210-4219 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 4220-4229 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4230-4239 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 4240-4249 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 4250-4259 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4260-4269 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 4270-4279 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 4280-4289 + 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 4290-4299 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 4300-4309 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 4310-4319 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 4320-4329 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 4330-4339 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 4340-4349 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 4350-4359 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 4360-4369 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 4370-4379 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4380-4389 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 4390-4399 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 4400-4409 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4410-4419 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 4420-4429 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4430-4439 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 4440-4449 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 4450-4459 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 4460-4469 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4470-4479 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 4480-4489 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 4490-4499 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 4500-4509 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 4510-4519 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 4520-4529 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 4530-4539 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 4540-4549 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4550-4559 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 4560-4569 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 4570-4579 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 4580-4589 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 4590-4599 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 4600-4609 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4610-4619 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 4620-4629 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 4630-4639 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 4640-4649 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 4650-4659 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 4660-4669 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 4670-4679 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4680-4689 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 4690-4699 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 4700-4709 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4710-4719 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 4720-4729 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 4730-4739 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4740-4749 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 4750-4759 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 4760-4769 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 4770-4779 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 4780-4789 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 4790-4799 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 4800-4809 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 4810-4819 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4820-4829 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 4830-4839 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 4840-4849 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4850-4859 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4860-4869 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 4870-4879 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 4880-4889 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 4890-4899 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 4900-4909 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 4910-4919 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4920-4929 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 4930-4939 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 4940-4949 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 4950-4959 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 4960-4969 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 4970-4979 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 4980-4989 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 4990-4999 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 5000-5009 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5010-5019 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 5020-5029 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 5030-5039 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5040-5049 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 5050-5059 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 5060-5069 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5070-5079 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 5080-5089 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 5090-5099 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 5100-5109 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 28, // 5110-5119 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 5120-5129 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 5130-5139 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 5140-5149 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 5150-5159 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5160-5169 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 5170-5179 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 5180-5189 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 5190-5199 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 5200-5209 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 5210-5219 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5220-5229 + 1, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 5230-5239 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 5240-5249 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5250-5259 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 5260-5269 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 5270-5279 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 5280-5289 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 5290-5299 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 5300-5309 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 5310-5319 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 5320-5329 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 5330-5339 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5340-5349 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 5350-5359 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 5360-5369 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5370-5379 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 5380-5389 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 5390-5399 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 5400-5409 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 5410-5419 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5420-5429 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5430-5439 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 5440-5449 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 5450-5459 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5460-5469 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 5470-5479 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 5480-5489 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5490-5499 + 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 5500-5509 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 5510-5519 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5520-5529 + 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 5530-5539 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 5540-5549 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 5550-5559 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 5560-5569 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 5570-5579 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5580-5589 + 1, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 5590-5599 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 5600-5609 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 5610-5619 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 5620-5629 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 5630-5639 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5640-5649 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 5650-5659 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 5660-5669 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 5670-5679 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 5680-5689 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 5690-5699 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5700-5709 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 5710-5719 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 5720-5729 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5730-5739 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 30, // 5740-5749 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 5750-5759 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 5760-5769 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 5770-5779 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 5780-5789 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5790-5799 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 5800-5809 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 5810-5819 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 5820-5829 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 5830-5839 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 5840-5849 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5850-5859 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 5860-5869 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 5870-5879 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 5880-5889 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 5890-5899 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 5900-5909 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 5910-5919 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 5920-5929 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 5930-5939 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 5940-5949 + 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 5950-5959 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 5960-5969 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5970-5979 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 5980-5989 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 5990-5999 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 6000-6009 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 6010-6019 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 6020-6029 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 6030-6039 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 6040-6049 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 6050-6059 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 6060-6069 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 6070-6079 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 6080-6089 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6090-6099 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 6100-6109 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 6110-6119 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6120-6129 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 6130-6139 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 6140-6149 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 6150-6159 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 6160-6169 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 6170-6179 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 6180-6189 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 6190-6199 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 6200-6209 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 6210-6219 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 6220-6229 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 6230-6239 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 6240-6249 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 6250-6259 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 6260-6269 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 6270-6279 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 6280-6289 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 6290-6299 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6300-6309 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 6310-6319 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 6320-6329 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 6330-6339 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 6340-6349 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 6350-6359 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 6360-6369 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 6370-6379 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 6380-6389 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 6390-6399 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 6400-6409 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6410-6419 + 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 6420-6429 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 6430-6439 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 6440-6449 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 6450-6459 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 6460-6469 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 6470-6479 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6480-6489 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 6490-6499 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 6500-6509 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6510-6519 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 6520-6529 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 6530-6539 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 6540-6549 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 6550-6559 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 6560-6569 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 6570-6579 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 6580-6589 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 6590-6599 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 6600-6609 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 6610-6619 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 6620-6629 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 6630-6639 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 6640-6649 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 6650-6659 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 6660-6669 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 6670-6679 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 6680-6689 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6690-6699 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 6700-6709 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 6710-6719 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 6720-6729 + 3, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 6730-6739 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 6740-6749 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6750-6759 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 6760-6769 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 6770-6779 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6780-6789 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 6790-6799 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 6800-6809 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 6810-6819 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 6820-6829 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 6830-6839 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 6840-6849 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 6850-6859 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 6860-6869 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 6870-6879 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 6880-6889 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 6890-6899 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 6900-6909 + 1, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 6910-6919 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 6920-6929 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 6930-6939 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 6940-6949 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 6950-6959 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 6960-6969 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 6970-6979 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 6980-6989 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 6990-6999 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7000-7009 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 7010-7019 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 7020-7029 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 7030-7039 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 7040-7049 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 7050-7059 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 7060-7069 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 7070-7079 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 7080-7089 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7090-7099 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 7100-7109 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7110-7119 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 7120-7129 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 7130-7139 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7140-7149 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 7150-7159 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 7160-7169 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 7170-7179 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 7180-7189 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 7190-7199 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 7200-7209 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 7210-7219 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 7220-7229 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 7230-7239 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 7240-7249 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 7250-7259 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 7260-7269 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7270-7279 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 7280-7289 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 7290-7299 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 7300-7309 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7310-7319 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7320-7329 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 7330-7339 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 7340-7349 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 7350-7359 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 7360-7369 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 7370-7379 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7380-7389 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 7390-7399 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7400-7409 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 7410-7419 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7420-7429 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 7430-7439 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7440-7449 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 7450-7459 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 7460-7469 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 7470-7479 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 7480-7489 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 7490-7499 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 7500-7509 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 7510-7519 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 7520-7529 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 7530-7539 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 7540-7549 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 7550-7559 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7560-7569 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 7570-7579 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 7580-7589 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7590-7599 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 7600-7609 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7610-7619 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 7620-7629 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 7630-7639 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 20, // 7640-7649 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 7650-7659 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 7660-7669 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 7670-7679 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 7680-7689 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 7690-7699 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 7700-7709 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 7710-7719 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 7720-7729 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7730-7739 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7740-7749 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 30, // 7750-7759 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 7760-7769 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 7770-7779 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 7780-7789 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 7790-7799 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 7800-7809 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 7810-7819 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 7820-7829 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7830-7839 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7840-7849 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 7850-7859 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 7860-7869 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 7870-7879 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 7880-7889 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7890-7899 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 7900-7909 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 7910-7919 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 7920-7929 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 7930-7939 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 7940-7949 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7950-7959 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 7960-7969 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 7970-7979 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7980-7989 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 7990-7999 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 8000-8009 + 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 8010-8019 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 8020-8029 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 8030-8039 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8040-8049 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 8050-8059 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 8060-8069 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8070-8079 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 8080-8089 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 8090-8099 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8100-8109 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 8110-8119 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 8120-8129 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 8130-8139 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 8140-8149 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8150-8159 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 8160-8169 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 8170-8179 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8180-8189 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 8190-8199 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 8200-8209 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 8210-8219 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8220-8229 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 8230-8239 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 8240-8249 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8250-8259 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 8260-8269 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 8270-8279 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 8280-8289 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 8290-8299 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8300-8309 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 8310-8319 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 8320-8329 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 8330-8339 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8340-8349 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 8350-8359 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 8360-8369 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 8370-8379 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 30, // 8380-8389 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 8390-8399 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 8400-8409 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 8410-8419 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 8420-8429 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8430-8439 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 8440-8449 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8450-8459 + 1, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 8460-8469 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 8470-8479 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 8480-8489 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8490-8499 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8500-8509 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 8510-8519 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 8520-8529 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 8530-8539 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 8540-8549 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8550-8559 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 8560-8569 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 8570-8579 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 8580-8589 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 8590-8599 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 8600-8609 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8610-8619 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 8620-8629 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8630-8639 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 8640-8649 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8650-8659 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 8660-8669 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 8670-8679 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 8680-8689 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 8690-8699 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 8700-8709 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 8710-8719 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8720-8729 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 8730-8739 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 8740-8749 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 8750-8759 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 8760-8769 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 8770-8779 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 8780-8789 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8790-8799 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 8800-8809 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 8810-8819 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8820-8829 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 8830-8839 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 8840-8849 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8850-8859 + 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 8860-8869 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 8870-8879 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 8880-8889 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 8890-8899 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 8900-8909 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8910-8919 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 8920-8929 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 8930-8939 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8940-8949 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8950-8959 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 8960-8969 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 8970-8979 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 8980-8989 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 8990-8999 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 9000-9009 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 9010-9019 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 9020-9029 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9030-9039 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 9040-9049 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 9050-9059 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 9060-9069 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 9070-9079 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9080-9089 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9090-9099 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 9100-9109 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 9110-9119 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 9120-9129 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 9130-9139 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9140-9149 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 9150-9159 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9160-9169 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 9170-9179 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 9180-9189 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 9190-9199 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 9200-9209 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9210-9219 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 9220-9229 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 9230-9239 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 9240-9249 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 9250-9259 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 9260-9269 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 9270-9279 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 9280-9289 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 9290-9299 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9300-9309 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 9310-9319 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 9320-9329 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 9330-9339 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 9340-9349 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 9350-9359 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9360-9369 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 9370-9379 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9380-9389 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 9390-9399 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 9400-9409 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 9410-9419 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9420-9429 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 22, // 9430-9439 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 9440-9449 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9450-9459 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 9460-9469 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 9470-9479 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9480-9489 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 9490-9499 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9500-9509 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9510-9519 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9520-9529 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 9530-9539 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 9540-9549 + 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 9550-9559 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 9560-9569 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 9570-9579 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 9580-9589 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9590-9599 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9600-9609 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 9610-9619 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 9620-9629 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9630-9639 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 9640-9649 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9650-9659 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 9660-9669 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 9670-9679 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 9680-9689 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 9690-9699 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 9700-9709 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 9710-9719 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9720-9729 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 9730-9739 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 9740-9749 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 9750-9759 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 9760-9769 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9770-9779 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 9780-9789 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9790-9799 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 9800-9809 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 9810-9819 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 9820-9829 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 9830-9839 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9840-9849 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 9850-9859 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9860-9869 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9870-9879 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 9880-9889 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9890-9899 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 9900-9909 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9910-9919 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 9920-9929 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9930-9939 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 9940-9949 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 9950-9959 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 9960-9969 + 3, 2, 1, 34, 33, 32, 31, 30, 29, 28, // 9970-9979 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 9980-9989 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 9990-9999 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 28, // 10000-10009 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 10010-10019 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 10020-10029 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 10030-10039 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 10040-10049 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10050-10059 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 10060-10069 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 10070-10079 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10080-10089 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 10090-10099 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 10100-10109 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 10110-10119 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10120-10129 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 10130-10139 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10140-10149 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 10150-10159 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 10160-10169 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 10170-10179 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10180-10189 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 10190-10199 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10200-10209 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10210-10219 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 10220-10229 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10230-10239 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 10240-10249 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 10250-10259 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 10260-10269 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 10270-10279 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 10280-10289 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10290-10299 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 10300-10309 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 10310-10319 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10320-10329 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 10330-10339 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 10340-10349 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 10350-10359 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 10360-10369 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 10370-10379 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10380-10389 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 28, // 10390-10399 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 10400-10409 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 10410-10419 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 10420-10429 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 10430-10439 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10440-10449 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 10450-10459 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 10460-10469 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 10470-10479 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 10480-10489 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 10490-10499 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10500-10509 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 10510-10519 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 10520-10529 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 10530-10539 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 10540-10549 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 10550-10559 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 10560-10569 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 10570-10579 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 10580-10589 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 10590-10599 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 10600-10609 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 10610-10619 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 10620-10629 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 10630-10639 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10640-10649 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 10650-10659 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 10660-10669 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 10670-10679 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 10680-10689 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 10690-10699 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 10700-10709 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10710-10719 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 10720-10729 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 10730-10739 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10740-10749 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 10750-10759 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10760-10769 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10770-10779 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 10780-10789 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 32, // 10790-10799 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 10800-10809 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 10810-10819 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10820-10829 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 10830-10839 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 10840-10849 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 10850-10859 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 10860-10869 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10870-10879 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 10880-10889 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10890-10899 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 28, // 10900-10909 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 10910-10919 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 10920-10929 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 10930-10939 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 10940-10949 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 10950-10959 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10960-10969 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 10970-10979 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 10980-10989 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 10990-10999 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 11000-11009 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11010-11019 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 11020-11029 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11030-11039 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 11040-11049 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 11050-11059 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 11060-11069 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11070-11079 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 11080-11089 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 11090-11099 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11100-11109 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 11110-11119 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 11120-11129 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 11130-11139 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 11140-11149 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 11150-11159 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 11160-11169 + 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 11170-11179 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11180-11189 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 11190-11199 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11200-11209 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 11210-11219 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 11220-11229 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 11230-11239 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 11240-11249 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 11250-11259 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11260-11269 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 11270-11279 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 11280-11289 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 11290-11299 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 11300-11309 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 11310-11319 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 11320-11329 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 11330-11339 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 11340-11349 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 11350-11359 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 11360-11369 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11370-11379 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 11380-11389 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 11390-11399 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 11400-11409 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11410-11419 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 11420-11429 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 11430-11439 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 11440-11449 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11450-11459 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 11460-11469 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11470-11479 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 11480-11489 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 11490-11499 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 11500-11509 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 11510-11519 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 11520-11529 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 11530-11539 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 11540-11549 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 11550-11559 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 11560-11569 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 11570-11579 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 11580-11589 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 11590-11599 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11600-11609 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 11610-11619 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11620-11629 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 11630-11639 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11640-11649 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 11650-11659 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11660-11669 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 11670-11679 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 11680-11689 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 11690-11699 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11700-11709 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 11710-11719 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 11720-11729 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11730-11739 + 3, 2, 1, 34, 33, 32, 31, 30, 29, 28, // 11740-11749 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 11750-11759 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11760-11769 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 11770-11779 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 11780-11789 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 11790-11799 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 11800-11809 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 11810-11819 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 11820-11829 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 24, // 11830-11839 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 11840-11849 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11850-11859 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 11860-11869 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11870-11879 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 11880-11889 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 11890-11899 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 11900-11909 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11910-11919 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 11920-11929 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 11930-11939 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11940-11949 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 11950-11959 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 11960-11969 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 11970-11979 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 11980-11989 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11990-11999 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 12000-12009 + 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 12010-12019 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 12020-12029 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 12030-12039 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 12040-12049 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 12050-12059 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12060-12069 + 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 12070-12079 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 12080-12089 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 12090-12099 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 12100-12109 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 24, // 12110-12119 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 12120-12129 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 12130-12139 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 12140-12149 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 12150-12159 + 1, 2, 1, 34, 33, 32, 31, 30, 29, 28, // 12160-12169 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 12170-12179 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 12180-12189 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 12190-12199 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 12200-12209 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 12210-12219 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 12220-12229 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 12230-12239 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12240-12249 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 12250-12259 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 12260-12269 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 12270-12279 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 12280-12289 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12290-12299 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 12300-12309 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 12310-12319 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 12320-12329 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 12330-12339 + 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 12340-12349 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 12350-12359 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 12360-12369 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 12370-12379 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12380-12389 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12390-12399 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 12400-12409 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 12410-12419 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 12420-12429 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 12430-12439 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12440-12449 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 12450-12459 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 12460-12469 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 12470-12479 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 12480-12489 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 12490-12499 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 12500-12509 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 12510-12519 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 12520-12529 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 12530-12539 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 12540-12549 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 12550-12559 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 12560-12569 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 12570-12579 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 12580-12589 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12590-12599 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12600-12609 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 12610-12619 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 12620-12629 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 12630-12639 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 12640-12649 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 12650-12659 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12660-12669 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 12670-12679 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 12680-12689 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 12690-12699 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 12700-12709 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 12710-12719 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 12720-12729 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 12730-12739 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 12740-12749 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 12750-12759 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 12760-12769 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12770-12779 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12780-12789 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 12790-12799 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 12800-12809 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12810-12819 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 12820-12829 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12830-12839 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 12840-12849 + 3, 2, 1, 36, 35, 34, 33, 32, 31, 30, // 12850-12859 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 12860-12869 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 12870-12879 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 12880-12889 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 12890-12899 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 12900-12909 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 12910-12919 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 12920-12929 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12930-12939 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 12940-12949 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 12950-12959 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 12960-12969 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 12970-12979 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 12980-12989 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12990-12999 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 24, // 13000-13009 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 13010-13019 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 13020-13029 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 13030-13039 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 13040-13049 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 13050-13059 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 13060-13069 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 13070-13079 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 13080-13089 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 13090-13099 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 13100-13109 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13110-13119 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 13120-13129 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 13130-13139 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 13140-13149 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 13150-13159 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 13160-13169 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 13170-13179 + 3, 2, 1, 4, 3, 2, 1, 30, 29, 28, // 13180-13189 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 13190-13199 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 13200-13209 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 13210-13219 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 13220-13229 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13230-13239 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 13240-13249 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 13250-13259 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 13260-13269 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 13270-13279 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13280-13289 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 13290-13299 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 13300-13309 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 13310-13319 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 13320-13329 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 28, // 13330-13339 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 13340-13349 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 13350-13359 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 13360-13369 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13370-13379 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 13380-13389 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 13390-13399 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13400-13409 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 13410-13419 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 13420-13429 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13430-13439 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13440-13449 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 13450-13459 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 13460-13469 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 13470-13479 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 13480-13489 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 13490-13499 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 13500-13509 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 13510-13519 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 13520-13529 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 13530-13539 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 13540-13549 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 13550-13559 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 13560-13569 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 13570-13579 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13580-13589 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 13590-13599 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 13600-13609 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 13610-13619 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 13620-13629 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 13630-13639 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 13640-13649 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 13650-13659 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 13660-13669 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 13670-13679 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 13680-13689 + 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 13690-13699 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 13700-13709 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13710-13719 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 13720-13729 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 13730-13739 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13740-13749 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 13750-13759 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 13760-13769 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13770-13779 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 13780-13789 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 13790-13799 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 13800-13809 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 13810-13819 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 13820-13829 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13830-13839 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 13840-13849 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 13850-13859 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 13860-13869 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 13870-13879 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 13880-13889 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13890-13899 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 13900-13909 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 13910-13919 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13920-13929 + 1, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 13930-13939 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 13940-13949 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 13950-13959 + 3, 2, 1, 4, 3, 2, 1, 30, 29, 28, // 13960-13969 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 13970-13979 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 13980-13989 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 13990-13999 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 14000-14009 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 14010-14019 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 14020-14029 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 14030-14039 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14040-14049 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 14050-14059 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14060-14069 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14070-14079 + 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 14080-14089 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 14090-14099 + 7, 6, 5, 4, 3, 2, 1, 36, 35, 34, // 14100-14109 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 14110-14119 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 14120-14129 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14130-14139 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 14140-14149 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 14150-14159 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14160-14169 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 14170-14179 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 14180-14189 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 14190-14199 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 14200-14209 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14210-14219 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 14220-14229 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14230-14239 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 14240-14249 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 14250-14259 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 14260-14269 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14270-14279 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14280-14289 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 14290-14299 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 14300-14309 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14310-14319 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 14320-14329 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14330-14339 + 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 14340-14349 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 14350-14359 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 14360-14369 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 14370-14379 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 14380-14389 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14390-14399 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 14400-14409 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 14410-14419 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 14420-14429 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 14430-14439 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 14440-14449 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14450-14459 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 14460-14469 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 14470-14479 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 14480-14489 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14490-14499 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 14500-14509 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 14510-14519 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14520-14529 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 14530-14539 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 14540-14549 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 14550-14559 + 1, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 14560-14569 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 14570-14579 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14580-14589 + 1, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 14590-14599 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 14600-14609 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14610-14619 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 14620-14629 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 14630-14639 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14640-14649 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 14650-14659 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 14660-14669 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14670-14679 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 14680-14689 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 14690-14699 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14700-14709 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 14710-14719 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 14720-14729 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 14730-14739 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 14740-14749 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 14750-14759 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 14760-14769 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 14770-14779 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 14780-14789 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 14790-14799 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14800-14809 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 14810-14819 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 14820-14829 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14830-14839 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 14840-14849 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 14850-14859 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 14860-14869 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 14870-14879 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 14880-14889 + 1, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 14890-14899 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 14900-14909 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14910-14919 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 14920-14929 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 14930-14939 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 14940-14949 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 14950-14959 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 14960-14969 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14970-14979 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 14980-14989 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 14990-14999 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 15000-15009 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 15010-15019 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15020-15029 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 15030-15039 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 15040-15049 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 15050-15059 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 15060-15069 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 15070-15079 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 15080-15089 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15090-15099 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 15100-15109 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15110-15119 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15120-15129 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 15130-15139 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 15140-15149 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15150-15159 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 15160-15169 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 15170-15179 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 15180-15189 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 15190-15199 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 15200-15209 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 15210-15219 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 15220-15229 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 15230-15239 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 15240-15249 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 15250-15259 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 15260-15269 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 15270-15279 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 15280-15289 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 15290-15299 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 15300-15309 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 15310-15319 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 15320-15329 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 15330-15339 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 15340-15349 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 15350-15359 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 15360-15369 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 15370-15379 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 15380-15389 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15390-15399 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 15400-15409 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 15410-15419 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 15420-15429 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 15430-15439 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 15440-15449 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15450-15459 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 15460-15469 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 15470-15479 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 15480-15489 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 15490-15499 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15500-15509 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 15510-15519 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 15520-15529 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15530-15539 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15540-15549 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 15550-15559 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 15560-15569 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15570-15579 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 15580-15589 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15590-15599 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 15600-15609 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 15610-15619 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 15620-15629 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15630-15639 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 15640-15649 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15650-15659 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 15660-15669 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 15670-15679 + 3, 2, 1, 44, 43, 42, 41, 40, 39, 38, // 15680-15689 + 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 15690-15699 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 15700-15709 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 15710-15719 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 15720-15729 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 15730-15739 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 15740-15749 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15750-15759 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 15760-15769 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 15770-15779 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 15780-15789 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 15790-15799 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 15800-15809 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 15810-15819 + 3, 2, 1, 36, 35, 34, 33, 32, 31, 30, // 15820-15829 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 15830-15839 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 15840-15849 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 15850-15859 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 15860-15869 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 15870-15879 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 15880-15889 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15890-15899 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 15900-15909 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 15910-15919 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 15920-15929 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 15930-15939 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 15940-15949 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 15950-15959 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15960-15969 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 15970-15979 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15980-15989 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15990-15999 + 1, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 16000-16009 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 16010-16019 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 16020-16029 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 16030-16039 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 16040-16049 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 16050-16059 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 16060-16069 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 16070-16079 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 16080-16089 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16090-16099 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 16100-16109 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 16110-16119 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 16120-16129 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 16130-16139 + 1, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 16140-16149 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 16150-16159 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 16160-16169 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 16170-16179 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 16180-16189 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 16190-16199 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 16200-16209 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16210-16219 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 16220-16229 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 16230-16239 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 16240-16249 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 16250-16259 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16260-16269 + 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 16270-16279 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 16280-16289 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16290-16299 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 16300-16309 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 16310-16319 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 16320-16329 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 16330-16339 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 16340-16349 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16350-16359 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 16360-16369 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16370-16379 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 16380-16389 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 16390-16399 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16400-16409 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 16410-16419 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16420-16429 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 16430-16439 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 16440-16449 + 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 16450-16459 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 16460-16469 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 16470-16479 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16480-16489 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 16490-16499 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 16500-16509 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 16510-16519 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 16520-16529 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 16530-16539 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16540-16549 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 16550-16559 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16560-16569 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 16570-16579 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 16580-16589 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 16590-16599 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 16600-16609 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 16610-16619 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16620-16629 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 16630-16639 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 16640-16649 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 16650-16659 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 16660-16669 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 16670-16679 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16680-16689 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 16690-16699 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 16700-16709 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 16710-16719 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 16720-16729 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16730-16739 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 16740-16749 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 16750-16759 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 16760-16769 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 16770-16779 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 16780-16789 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 16790-16799 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16800-16809 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 16810-16819 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 16820-16829 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 16830-16839 + 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 16840-16849 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 16850-16859 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16860-16869 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 16870-16879 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 16880-16889 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16890-16899 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 16900-16909 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16910-16919 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 16920-16929 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16930-16939 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 16940-16949 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 16950-16959 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 16960-16969 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 16970-16979 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16980-16989 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 16990-16999 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17000-17009 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17010-17019 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 17020-17029 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 17030-17039 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 17040-17049 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 17050-17059 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17060-17069 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 17070-17079 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 17080-17089 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 17090-17099 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 17100-17109 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 17110-17119 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 17120-17129 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 17130-17139 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 17140-17149 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 17150-17159 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 17160-17169 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 17170-17179 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 17180-17189 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 17190-17199 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 22, // 17200-17209 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 17210-17219 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17220-17229 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 17230-17239 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17240-17249 + 7, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 17250-17259 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 17260-17269 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 17270-17279 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17280-17289 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 17290-17299 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17300-17309 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 17310-17319 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 17320-17329 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 17330-17339 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17340-17349 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 17350-17359 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17360-17369 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 17370-17379 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 17380-17389 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 17390-17399 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17400-17409 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 17410-17419 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17420-17429 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 17430-17439 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 17440-17449 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17450-17459 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 17460-17469 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 17470-17479 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 17480-17489 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 17490-17499 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 17500-17509 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 17510-17519 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 17520-17529 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 17530-17539 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17540-17549 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 17550-17559 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 17560-17569 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 17570-17579 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17580-17589 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 17590-17599 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 17600-17609 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 17610-17619 + 3, 2, 1, 4, 3, 2, 1, 30, 29, 28, // 17620-17629 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 17630-17639 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17640-17649 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 17650-17659 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 17660-17669 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17670-17679 + 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 17680-17689 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17690-17699 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 17700-17709 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 17710-17719 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 17720-17729 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 17730-17739 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 17740-17749 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17750-17759 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 17760-17769 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 17770-17779 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 17780-17789 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17790-17799 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 17800-17809 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17810-17819 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 17820-17829 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 17830-17839 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17840-17849 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 17850-17859 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 17860-17869 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17870-17879 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17880-17889 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 17890-17899 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 17900-17909 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17910-17919 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 17920-17929 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 17930-17939 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17940-17949 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 17950-17959 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17960-17969 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 17970-17979 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 24, // 17980-17989 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 17990-17999 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18000-18009 + 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 18010-18019 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 18020-18029 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18030-18039 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 18040-18049 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 18050-18059 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 18060-18069 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 18070-18079 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 18080-18089 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 18090-18099 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 18100-18109 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 18110-18119 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 18120-18129 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 18130-18139 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 20, // 18140-18149 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 18150-18159 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 18160-18169 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18170-18179 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18180-18189 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 18190-18199 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18200-18209 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 18210-18219 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 18220-18229 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 18230-18239 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18240-18249 + 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 18250-18259 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 18260-18269 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 18270-18279 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 18280-18289 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18290-18299 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 18300-18309 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 18310-18319 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 18320-18329 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18330-18339 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18340-18349 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 18350-18359 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 18360-18369 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 18370-18379 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 18380-18389 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 18390-18399 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18400-18409 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 18410-18419 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 18420-18429 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 18430-18439 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 18440-18449 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 18450-18459 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 18460-18469 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18470-18479 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18480-18489 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 18490-18499 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 18500-18509 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 18510-18519 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 18520-18529 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 18530-18539 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18540-18549 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 18550-18559 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 18560-18569 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18570-18579 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 18580-18589 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 18590-18599 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 18600-18609 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 18610-18619 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 18620-18629 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 18630-18639 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 18640-18649 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18650-18659 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18660-18669 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 18670-18679 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18680-18689 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18690-18699 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18700-18709 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 18710-18719 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18720-18729 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18730-18739 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 18740-18749 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 18750-18759 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18760-18769 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 18770-18779 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 18780-18789 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 18790-18799 + 3, 2, 1, 36, 35, 34, 33, 32, 31, 30, // 18800-18809 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 18810-18819 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 18820-18829 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 18830-18839 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 18840-18849 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 18850-18859 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 18860-18869 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 18870-18879 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 18880-18889 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 18890-18899 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18900-18909 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 28, // 18910-18919 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 18920-18929 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 18930-18939 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 18940-18949 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 18950-18959 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18960-18969 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 18970-18979 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 18980-18989 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18990-18999 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 19000-19009 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 19010-19019 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19020-19029 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 19030-19039 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19040-19049 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 19050-19059 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 19060-19069 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 19070-19079 + 1, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 19080-19089 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 19090-19099 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 19100-19109 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19110-19119 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 19120-19129 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 19130-19139 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 19140-19149 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 19150-19159 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 19160-19169 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19170-19179 + 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 19180-19189 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 19190-19199 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 19200-19209 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 19210-19219 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19220-19229 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 19230-19239 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 19240-19249 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 19250-19259 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 19260-19269 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 19270-19279 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 19280-19289 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19290-19299 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 19300-19309 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 19310-19319 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 19320-19329 + 3, 2, 1, 40, 39, 38, 37, 36, 35, 34, // 19330-19339 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 19340-19349 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 19350-19359 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 19360-19369 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 19370-19379 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 19380-19389 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 19390-19399 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 19400-19409 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 19410-19419 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 19420-19429 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 19430-19439 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 19440-19449 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 19450-19459 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 19460-19469 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 19470-19479 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 19480-19489 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19490-19499 + 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 19500-19509 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 19510-19519 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19520-19529 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19530-19539 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 19540-19549 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 19550-19559 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19560-19569 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 19570-19579 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 19580-19589 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 19590-19599 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 52, // 19600-19609 + 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, // 19610-19619 + 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 19620-19629 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 19630-19639 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 19640-19649 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19650-19659 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 19660-19669 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19670-19679 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 19680-19689 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 19690-19699 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 19700-19709 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 19710-19719 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 19720-19729 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 19730-19739 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19740-19749 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 19750-19759 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 19760-19769 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 19770-19779 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 19780-19789 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 19790-19799 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 19800-19809 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 19810-19819 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 19820-19829 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19830-19839 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 19840-19849 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 19850-19859 + 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 19860-19869 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 19870-19879 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 19880-19889 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 19890-19899 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 19900-19909 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 19910-19919 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 19920-19929 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 19930-19939 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 19940-19949 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19950-19959 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 19960-19969 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 19970-19979 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19980-19989 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 19990-19999 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20000-20009 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20010-20019 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 20020-20029 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 20030-20039 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 20040-20049 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20050-20059 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 20060-20069 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 20070-20079 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 20080-20089 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20090-20099 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 20100-20109 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 20110-20119 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 20120-20129 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20130-20139 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 20140-20149 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20150-20159 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20160-20169 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 20170-20179 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 20180-20189 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20190-20199 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 20200-20209 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 20210-20219 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20220-20229 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 20230-20239 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 20240-20249 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20250-20259 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 20260-20269 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 20270-20279 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 20280-20289 + 7, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 20290-20299 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 20300-20309 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20310-20319 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 20320-20329 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 20330-20339 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 20340-20349 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 20350-20359 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 20360-20369 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 20370-20379 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 20380-20389 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 20390-20399 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 20400-20409 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 20410-20419 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20420-20429 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20430-20439 + 1, 2, 1, 34, 33, 32, 31, 30, 29, 28, // 20440-20449 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 20450-20459 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 20460-20469 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 20470-20479 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 20480-20489 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 20490-20499 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 20500-20509 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20510-20519 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20520-20529 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 20530-20539 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 20540-20549 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20550-20559 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 20560-20569 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 20570-20579 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20580-20589 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 20590-20599 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20600-20609 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 20610-20619 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 20620-20629 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 20630-20639 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 20640-20649 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20650-20659 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 20660-20669 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20670-20679 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20680-20689 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 20690-20699 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 20700-20709 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 20710-20719 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20720-20729 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20730-20739 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 20740-20749 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 20750-20759 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20760-20769 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 20770-20779 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 20780-20789 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 20790-20799 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 40, // 20800-20809 + 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 20810-20819 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 20820-20829 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 20830-20839 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 20840-20849 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 20850-20859 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20860-20869 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 20870-20879 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 20880-20889 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 20890-20899 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 20900-20909 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20910-20919 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 20920-20929 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 20930-20939 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 20940-20949 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 20950-20959 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 20960-20969 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20970-20979 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 20980-20989 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20990-20999 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21000-21009 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 21010-21019 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 21020-21029 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 21030-21039 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 21040-21049 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 21050-21059 + 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 21060-21069 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 21070-21079 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 21080-21089 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21090-21099 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 21100-21109 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21110-21119 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 21120-21129 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 21130-21139 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 21140-21149 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 21150-21159 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 21160-21169 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 21170-21179 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 21180-21189 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 21190-21199 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21200-21209 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21210-21219 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 21220-21229 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 21230-21239 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 21240-21249 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 21250-21259 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 21260-21269 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 21270-21279 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 21280-21289 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 21290-21299 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 21300-21309 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 21310-21319 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 21320-21329 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21330-21339 + 1, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 21340-21349 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 21350-21359 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 21360-21369 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 21370-21379 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 21380-21389 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 21390-21399 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 21400-21409 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 21410-21419 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 21420-21429 + 3, 2, 1, 34, 33, 32, 31, 30, 29, 28, // 21430-21439 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 21440-21449 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 21450-21459 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 21460-21469 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21470-21479 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 21480-21489 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 21490-21499 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 21500-21509 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 21510-21519 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 28, // 21520-21529 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 21530-21539 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 21540-21549 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 21550-21559 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 21560-21569 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 21570-21579 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 21580-21589 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 21590-21599 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21600-21609 + 1, 2, 1, 4, 3, 2, 1, 30, 29, 28, // 21610-21619 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 21620-21629 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 21630-21639 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 21640-21649 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21650-21659 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 21660-21669 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 21670-21679 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 21680-21689 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21690-21699 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 21700-21709 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 21710-21719 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 21720-21729 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 21730-21739 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21740-21749 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 21750-21759 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 21760-21769 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 21770-21779 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 21780-21789 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 21790-21799 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 21800-21809 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 21810-21819 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 21820-21829 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 21830-21839 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21840-21849 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 21850-21859 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 21860-21869 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21870-21879 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 21880-21889 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 21890-21899 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21900-21909 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 21910-21919 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 21920-21929 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 21930-21939 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 21940-21949 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21950-21959 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 21960-21969 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 21970-21979 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21980-21989 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 21990-21999 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 22000-22009 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 22010-22019 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 22020-22029 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 22030-22039 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22040-22049 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 22050-22059 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 22060-22069 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 22070-22079 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22080-22089 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 22090-22099 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 22100-22109 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 22110-22119 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 22120-22129 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 22130-22139 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 22140-22149 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 22150-22159 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22160-22169 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 22170-22179 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 22180-22189 + 3, 2, 1, 36, 35, 34, 33, 32, 31, 30, // 22190-22199 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 22200-22209 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 22210-22219 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 22220-22229 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 22230-22239 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 22240-22249 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 22250-22259 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22260-22269 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 22270-22279 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 22280-22289 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 22290-22299 + 3, 2, 1, 4, 3, 2, 1, 36, 35, 34, // 22300-22309 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 22310-22319 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 22320-22329 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 22330-22339 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 22340-22349 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 22350-22359 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 22360-22369 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22370-22379 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22380-22389 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 22390-22399 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 22400-22409 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 22410-22419 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 22420-22429 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 22430-22439 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 22440-22449 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 22450-22459 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 22460-22469 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22470-22479 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 22480-22489 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22490-22499 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22500-22509 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 22510-22519 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22520-22529 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22530-22539 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 22540-22549 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 22550-22559 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 22560-22569 + 1, 2, 1, 40, 39, 38, 37, 36, 35, 34, // 22570-22579 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 22580-22589 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 22590-22599 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 22600-22609 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 22610-22619 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 22620-22629 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 22630-22639 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 22640-22649 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 22650-22659 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 22660-22669 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 22670-22679 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22680-22689 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 22690-22699 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 22700-22709 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 22710-22719 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 22720-22729 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 22730-22739 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22740-22749 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 22750-22759 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 22760-22769 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 22770-22779 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 22780-22789 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 22790-22799 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 22800-22809 + 1, 6, 5, 4, 3, 2, 1, 36, 35, 34, // 22810-22819 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 22820-22829 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 22830-22839 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 22840-22849 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 22850-22859 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22860-22869 + 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 22870-22879 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 22880-22889 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22890-22899 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 22900-22909 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22910-22919 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 22920-22929 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 22930-22939 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 22940-22949 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22950-22959 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 22960-22969 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 22970-22979 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 22980-22989 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 22990-22999 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 23000-23009 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 23010-23019 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 23020-23029 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 23030-23039 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 23040-23049 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 23050-23059 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 23060-23069 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23070-23079 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 23080-23089 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 23090-23099 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 23100-23109 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 23110-23119 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23120-23129 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 23130-23139 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 23140-23149 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 23150-23159 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 23160-23169 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 23170-23179 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 23180-23189 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 23190-23199 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 23200-23209 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 23210-23219 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 23220-23229 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 23230-23239 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23240-23249 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 23250-23259 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 23260-23269 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 23270-23279 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23280-23289 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 23290-23299 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23300-23309 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23310-23319 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 23320-23329 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 23330-23339 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 23340-23349 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 23350-23359 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 23360-23369 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 23370-23379 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 23380-23389 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 23390-23399 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 23400-23409 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 23410-23419 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23420-23429 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 23430-23439 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 23440-23449 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 23450-23459 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 23460-23469 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 23470-23479 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 23480-23489 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 23490-23499 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 23500-23509 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 23510-23519 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23520-23529 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 23530-23539 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 23540-23549 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 23550-23559 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 23560-23569 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23570-23579 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 23580-23589 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 23590-23599 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 23600-23609 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 23610-23619 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 23620-23629 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 23630-23639 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 23640-23649 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 23650-23659 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 23660-23669 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 23670-23679 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 30, // 23680-23689 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 23690-23699 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 23700-23709 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 23710-23719 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 23720-23729 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23730-23739 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 23740-23749 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 23750-23759 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 23760-23769 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 23770-23779 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 23780-23789 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23790-23799 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 23800-23809 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 23810-23819 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 23820-23829 + 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 23830-23839 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 23840-23849 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 23850-23859 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 23860-23869 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 23870-23879 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 23880-23889 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 23890-23899 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 23900-23909 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 23910-23919 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 28, // 23920-23929 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 23930-23939 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 23940-23949 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 23950-23959 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23960-23969 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 23970-23979 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 23980-23989 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 23990-23999 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 24000-24009 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 24010-24019 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 24020-24029 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24030-24039 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 24040-24049 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24050-24059 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24060-24069 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 24070-24079 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 24080-24089 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 24090-24099 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 24100-24109 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 24110-24119 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24120-24129 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 24130-24139 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24140-24149 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 24150-24159 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 24160-24169 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 24170-24179 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 24180-24189 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 24190-24199 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 24200-24209 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24210-24219 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 24220-24229 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 24230-24239 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 24240-24249 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 24250-24259 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 24260-24269 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24270-24279 + 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 24280-24289 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 24290-24299 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 24300-24309 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 24310-24319 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 24320-24329 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 24330-24339 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 24340-24349 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 24350-24359 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24360-24369 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 24370-24379 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24380-24389 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 24390-24399 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 24400-24409 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 24410-24419 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 24420-24429 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 24430-24439 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 24440-24449 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 24450-24459 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 24460-24469 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 24470-24479 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 24480-24489 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 24490-24499 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 24500-24509 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 24510-24519 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 24520-24529 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 24530-24539 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 24540-24549 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 24550-24559 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24560-24569 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 24570-24579 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24580-24589 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 24590-24599 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24600-24609 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24610-24619 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 24620-24629 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 24630-24639 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 24640-24649 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 24650-24659 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24660-24669 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 24670-24679 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 24680-24689 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 24690-24699 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 24700-24709 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 24710-24719 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24720-24729 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 24730-24739 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 24740-24749 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24750-24759 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 24760-24769 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24770-24779 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24780-24789 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 24790-24799 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 24800-24809 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24810-24819 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 24820-24829 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24830-24839 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 24840-24849 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 24850-24859 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 24860-24869 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 24870-24879 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 24880-24889 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 24890-24899 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 24900-24909 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 24910-24919 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 24920-24929 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24930-24939 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 24940-24949 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 24950-24959 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 24960-24969 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 24970-24979 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 24980-24989 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 24990-24999 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25000-25009 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 25010-25019 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25020-25029 + 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 25030-25039 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 25040-25049 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 25050-25059 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25060-25069 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 25070-25079 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 25080-25089 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 25090-25099 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25100-25109 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 25110-25119 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 25120-25129 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 25130-25139 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 25140-25149 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 25150-25159 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 25160-25169 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25170-25179 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 30, // 25180-25189 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 25190-25199 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 25200-25209 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 25210-25219 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 25220-25229 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 25230-25239 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 25240-25249 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 25250-25259 + 1, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 25260-25269 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 25270-25279 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 25280-25289 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25290-25299 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 25300-25309 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25310-25319 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 25320-25329 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 25330-25339 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 25340-25349 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 25350-25359 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 25360-25369 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 25370-25379 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25380-25389 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 25390-25399 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 25400-25409 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25410-25419 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 25420-25429 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 25430-25439 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 25440-25449 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 25450-25459 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 25460-25469 + 1, 52, 51, 50, 49, 48, 47, 46, 45, 44, // 25470-25479 + 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 25480-25489 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 25490-25499 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 25500-25509 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25510-25519 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 25520-25529 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 25530-25539 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 25540-25549 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25550-25559 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 25560-25569 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 25570-25579 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 25580-25589 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25590-25599 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 25600-25609 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25610-25619 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25620-25629 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 25630-25639 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 25640-25649 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 25650-25659 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 25660-25669 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 25670-25679 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25680-25689 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 25690-25699 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 25700-25709 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 25710-25719 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25720-25729 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 25730-25739 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 25740-25749 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 25750-25759 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 25760-25769 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 25770-25779 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25780-25789 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 25790-25799 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 25800-25809 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 25810-25819 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 25820-25829 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25830-25839 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 25840-25849 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 25850-25859 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 25860-25869 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 25870-25879 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 25880-25889 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25890-25899 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 25900-25909 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 25910-25919 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25920-25929 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 25930-25939 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 25940-25949 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 25950-25959 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 25960-25969 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25970-25979 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 25980-25989 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 25990-25999 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 26000-26009 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 26010-26019 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 26020-26029 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26030-26039 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26040-26049 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 26050-26059 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 26060-26069 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26070-26079 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 26080-26089 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 26090-26099 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 26100-26109 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 26110-26119 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 26120-26129 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26130-26139 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26140-26149 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 26150-26159 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26160-26169 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 26170-26179 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 26180-26189 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26190-26199 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 26200-26209 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 26210-26219 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 26220-26229 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 26230-26239 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 26240-26249 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26250-26259 + 1, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 26260-26269 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 26270-26279 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26280-26289 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 26290-26299 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 26300-26309 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 26310-26319 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 26320-26329 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 26330-26339 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 26340-26349 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 26350-26359 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26360-26369 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 26370-26379 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 26380-26389 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 26390-26399 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 26400-26409 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 26410-26419 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 26420-26429 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 26430-26439 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 26440-26449 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 26450-26459 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 26460-26469 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 26470-26479 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 26480-26489 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 26490-26499 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26500-26509 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 26510-26519 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 26520-26529 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 26530-26539 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 26540-26549 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 26550-26559 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26560-26569 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 26570-26579 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26580-26589 + 1, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 26590-26599 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 26600-26609 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 26610-26619 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 26620-26629 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 26630-26639 + 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 26640-26649 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 26650-26659 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 26660-26669 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26670-26679 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 26680-26689 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 26690-26699 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26700-26709 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 26710-26719 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 26720-26729 + 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 26730-26739 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 26740-26749 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 26750-26759 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 26760-26769 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 26770-26779 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 26780-26789 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26790-26799 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26800-26809 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 26810-26819 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26820-26829 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 26830-26839 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 26840-26849 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26850-26859 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 26860-26869 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 26870-26879 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26880-26889 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 26890-26899 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 26900-26909 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26910-26919 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 26920-26929 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 26930-26939 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 26940-26949 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 26950-26959 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 26960-26969 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26970-26979 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 26980-26989 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 26990-26999 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27000-27009 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 27010-27019 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27020-27029 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27030-27039 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 27040-27049 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 27050-27059 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 27060-27069 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 27070-27079 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27080-27089 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27090-27099 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 18, // 27100-27109 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 27110-27119 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 27120-27129 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27130-27139 + 3, 2, 1, 36, 35, 34, 33, 32, 31, 30, // 27140-27149 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 27150-27159 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 27160-27169 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 27170-27179 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27180-27189 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 27190-27199 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27200-27209 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 27210-27219 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 27220-27229 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 27230-27239 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27240-27249 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 27250-27259 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27260-27269 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 27270-27279 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 27280-27289 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 27290-27299 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 27300-27309 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 27310-27319 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 27320-27329 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 27330-27339 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 27340-27349 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27350-27359 + 1, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 27360-27369 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 27370-27379 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 27380-27389 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 27390-27399 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 27400-27409 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 27410-27419 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 27420-27429 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 27430-27439 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 27440-27449 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 27450-27459 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 27460-27469 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 27470-27479 + 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 27480-27489 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 27490-27499 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 27500-27509 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 27510-27519 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 27520-27529 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 27530-27539 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27540-27549 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 27550-27559 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 27560-27569 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27570-27579 + 1, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 27580-27589 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 27590-27599 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27600-27609 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 27610-27619 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27620-27629 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 27630-27639 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 27640-27649 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 27650-27659 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27660-27669 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 27670-27679 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 27680-27689 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 27690-27699 + 1, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 27700-27709 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 27710-27719 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27720-27729 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 27730-27739 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 27740-27749 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27750-27759 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 27760-27769 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 27770-27779 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27780-27789 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 27790-27799 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 27800-27809 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 27810-27819 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 27820-27829 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 27830-27839 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 27840-27849 + 1, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 27850-27859 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 27860-27869 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27870-27879 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 27880-27889 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 27890-27899 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 27900-27909 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 27910-27919 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 27920-27929 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27930-27939 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 27940-27949 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 27950-27959 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 27960-27969 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27970-27979 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 27980-27989 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 27990-27999 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 28000-28009 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 28010-28019 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 28020-28029 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 28030-28039 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28040-28049 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 28050-28059 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 28060-28069 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28070-28079 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 28080-28089 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 28090-28099 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 28100-28109 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 28110-28119 + 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 28120-28129 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 28130-28139 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28140-28149 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 28150-28159 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 28160-28169 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28170-28179 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 28180-28189 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28190-28199 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28200-28209 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 28210-28219 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 48, // 28220-28229 + 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, // 28230-28239 + 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 28240-28249 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 28250-28259 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 28260-28269 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 28270-28279 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 28280-28289 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 28290-28299 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 28300-28309 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 28310-28319 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 28320-28329 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 28330-28339 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 28340-28349 + 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 28350-28359 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 28360-28369 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 28370-28379 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 28380-28389 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 28390-28399 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 28400-28409 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 28410-28419 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 28420-28429 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 28430-28439 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 28440-28449 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 28450-28459 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 28460-28469 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 28470-28479 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 28480-28489 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 28490-28499 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 28500-28509 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 28510-28519 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 28520-28529 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 28530-28539 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 28540-28549 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 28550-28559 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28560-28569 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 28570-28579 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28580-28589 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 28590-28599 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 28600-28609 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 28610-28619 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 28620-28629 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 28630-28639 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 28640-28649 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 28650-28659 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 28660-28669 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 28670-28679 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 28680-28689 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 28690-28699 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 28700-28709 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 28710-28719 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 28720-28729 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 28730-28739 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28740-28749 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 28750-28759 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28760-28769 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 28770-28779 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 28780-28789 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 28790-28799 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 28800-28809 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 28810-28819 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 28820-28829 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 28830-28839 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 28840-28849 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 28850-28859 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 28860-28869 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 28870-28879 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 28880-28889 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28890-28899 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 28900-28909 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28910-28919 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 28920-28929 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 28930-28939 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 28940-28949 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28950-28959 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 28960-28969 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 28970-28979 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 28980-28989 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 28990-28999 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 29000-29009 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 29010-29019 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 29020-29029 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 29030-29039 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 29040-29049 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 29050-29059 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 29060-29069 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 29070-29079 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 29080-29089 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29090-29099 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 29100-29109 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29110-29119 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 29120-29129 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 29130-29139 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 29140-29149 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 29150-29159 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 29160-29169 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 29170-29179 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29180-29189 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29190-29199 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 29200-29209 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29210-29219 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29220-29229 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29230-29239 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 29240-29249 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 29250-29259 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 29260-29269 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 29270-29279 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 29280-29289 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 29290-29299 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 29300-29309 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 29310-29319 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 29320-29329 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 29330-29339 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 29340-29349 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29350-29359 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 29360-29369 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29370-29379 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 29380-29389 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 29390-29399 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29400-29409 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29410-29419 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 29420-29429 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 29430-29439 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 29440-29449 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 29450-29459 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29460-29469 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 29470-29479 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 29480-29489 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29490-29499 + 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 29500-29509 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 29510-29519 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 29520-29529 + 1, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 29530-29539 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 29540-29549 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 29550-29559 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 29560-29569 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 29570-29579 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 29580-29589 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 29590-29599 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29600-29609 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 29610-29619 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 29620-29629 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 29630-29639 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 29640-29649 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29650-29659 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 29660-29669 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29670-29679 + 3, 2, 1, 34, 33, 32, 31, 30, 29, 28, // 29680-29689 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 29690-29699 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 29700-29709 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 29710-29719 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 29720-29729 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29730-29739 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29740-29749 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 29750-29759 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 29760-29769 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 29770-29779 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 29780-29789 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29790-29799 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 29800-29809 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 29810-29819 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29820-29829 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 29830-29839 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29840-29849 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29850-29859 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 29860-29869 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 29870-29879 + 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 29880-29889 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 29890-29899 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 29900-29909 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 29910-29919 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 29920-29929 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 29930-29939 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 29940-29949 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 29950-29959 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 29960-29969 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29970-29979 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 29980-29989 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 29990-29999 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30000-30009 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 30010-30019 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 30020-30029 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 30030-30039 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 30040-30049 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 30050-30059 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30060-30069 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 30070-30079 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 30080-30089 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 30090-30099 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 30100-30109 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 30110-30119 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30120-30129 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 22, // 30130-30139 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 30140-30149 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30150-30159 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 30160-30169 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30170-30179 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 30180-30189 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 30190-30199 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 30200-30209 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30210-30219 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 30220-30229 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30230-30239 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30240-30249 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 30250-30259 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 30260-30269 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 30270-30279 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30280-30289 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 30290-30299 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 30300-30309 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 30310-30319 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 30320-30329 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30330-30339 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 30340-30349 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 30350-30359 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 30360-30369 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 30370-30379 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 30380-30389 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30390-30399 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 30400-30409 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 30410-30419 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 30420-30429 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 30430-30439 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 30440-30449 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 30450-30459 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 30460-30469 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 30470-30479 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30480-30489 + 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 30490-30499 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 30500-30509 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 30510-30519 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 30520-30529 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 30530-30539 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30540-30549 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 18, // 30550-30559 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 30560-30569 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 30570-30579 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30580-30589 + 3, 2, 1, 38, 37, 36, 35, 34, 33, 32, // 30590-30599 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 30600-30609 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 30610-30619 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30620-30629 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 30630-30639 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 30640-30649 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30650-30659 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30660-30669 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 30670-30679 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 30680-30689 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 30690-30699 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 30700-30709 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 30710-30719 + 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 30720-30729 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 30730-30739 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 30740-30749 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 30750-30759 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 30760-30769 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 30770-30779 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 30780-30789 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30790-30799 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 30800-30809 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 30810-30819 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 30820-30829 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 30830-30839 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30840-30849 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 30850-30859 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 30860-30869 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30870-30879 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30880-30889 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 30890-30899 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30900-30909 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 30910-30919 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30920-30929 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 30930-30939 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 30940-30949 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 30950-30959 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30960-30969 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 30970-30979 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 30980-30989 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 30990-30999 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 31000-31009 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 31010-31019 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 31020-31029 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 31030-31039 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31040-31049 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 31050-31059 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 31060-31069 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 31070-31079 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31080-31089 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 31090-31099 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 31100-31109 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31110-31119 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 31120-31129 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 31130-31139 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 31140-31149 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 31150-31159 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31160-31169 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 31170-31179 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 31180-31189 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 31190-31199 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 31200-31209 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 31210-31219 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 31220-31229 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 31230-31239 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 31240-31249 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 31250-31259 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 31260-31269 + 1, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 31270-31279 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 31280-31289 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31290-31299 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 31300-31309 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 31310-31319 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 31320-31329 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 31330-31339 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31340-31349 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 31350-31359 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 31360-31369 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 31370-31379 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 31380-31389 + 1, 2, 1, 4, 3, 2, 1, 72, 71, 70, // 31390-31399 + 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, // 31400-31409 + 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, // 31410-31419 + 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, // 31420-31429 + 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 31430-31439 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 31440-31449 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 31450-31459 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 31460-31469 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 31470-31479 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 31480-31489 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 31490-31499 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31500-31509 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 31510-31519 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31520-31529 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31530-31539 + 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 31540-31549 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31550-31559 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 31560-31569 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 31570-31579 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 31580-31589 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31590-31599 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 31600-31609 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31610-31619 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 31620-31629 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 31630-31639 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 31640-31649 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 31650-31659 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 31660-31669 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31670-31679 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 31680-31689 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 31690-31699 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 31700-31709 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31710-31719 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 31720-31729 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31730-31739 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31740-31749 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 31750-31759 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 31760-31769 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 31770-31779 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 31780-31789 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 31790-31799 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31800-31809 + 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 31810-31819 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 31820-31829 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31830-31839 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 31840-31849 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 31850-31859 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 31860-31869 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 31870-31879 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 31880-31889 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31890-31899 + 7, 6, 5, 4, 3, 2, 1, 50, 49, 48, // 31900-31909 + 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, // 31910-31919 + 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 31920-31929 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 31930-31939 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31940-31949 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 31950-31959 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 31960-31969 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 31970-31979 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31980-31989 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 31990-31999 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 32000-32009 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 32010-32019 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 32020-32029 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 32030-32039 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32040-32049 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 32050-32059 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 32060-32069 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 32070-32079 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 32080-32089 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 32090-32099 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 32100-32109 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 32110-32119 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 32120-32129 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32130-32139 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 32140-32149 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 32150-32159 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 32160-32169 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 32170-32179 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 32180-32189 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 32190-32199 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 32200-32209 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 32210-32219 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 32220-32229 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 32230-32239 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32240-32249 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 32250-32259 + 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 32260-32269 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 32270-32279 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 32280-32289 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 32290-32299 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 32300-32309 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32310-32319 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 32320-32329 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32330-32339 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 32340-32349 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 32350-32359 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 32360-32369 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 32370-32379 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 32380-32389 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32390-32399 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32400-32409 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 32410-32419 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 32420-32429 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32430-32439 + 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 32440-32449 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 32450-32459 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 32460-32469 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 32470-32479 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32480-32489 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 32490-32499 + 3, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 32500-32509 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 32510-32519 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32520-32529 + 1, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 32530-32539 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 32540-32549 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32550-32559 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 32560-32569 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 32570-32579 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 32580-32589 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 32590-32599 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 32600-32609 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32610-32619 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 32620-32629 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 32630-32639 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 32640-32649 + 3, 2, 1, 34, 33, 32, 31, 30, 29, 28, // 32650-32659 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 32660-32669 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 32670-32679 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 32680-32689 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 32690-32699 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 32700-32709 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 30, // 32710-32719 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 32720-32729 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 32730-32739 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 32740-32749 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 32750-32759 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32760-32769 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 32770-32779 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 32780-32789 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 32790-32799 + 1, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 32800-32809 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 32810-32819 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32820-32829 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 32830-32839 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 32840-32849 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 32850-32859 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 32860-32869 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 32870-32879 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 32880-32889 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 32890-32899 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 32900-32909 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 32910-32919 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 32920-32929 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 32930-32939 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 32940-32949 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 32950-32959 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 32960-32969 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 32970-32979 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 32980-32989 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 32990-32999 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 33000-33009 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 33010-33019 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 33020-33029 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 33030-33039 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 33040-33049 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 33050-33059 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33060-33069 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 33070-33079 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 33080-33089 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 33090-33099 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 33100-33109 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 30, // 33110-33119 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 33120-33129 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 33130-33139 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 33140-33149 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33150-33159 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 33160-33169 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 33170-33179 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33180-33189 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 33190-33199 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 33200-33209 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 33210-33219 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 33220-33229 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 33230-33239 + 7, 6, 5, 4, 3, 2, 1, 40, 39, 38, // 33240-33249 + 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 33250-33259 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 33260-33269 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 33270-33279 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 33280-33289 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33290-33299 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33300-33309 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 33310-33319 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 33320-33329 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 33330-33339 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 33340-33349 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 33350-33359 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 33360-33369 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 33370-33379 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33380-33389 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 33390-33399 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 33400-33409 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 33410-33419 + 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 33420-33429 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 33430-33439 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 33440-33449 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 33450-33459 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 33460-33469 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 33470-33479 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 33480-33489 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 33490-33499 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 33500-33509 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33510-33519 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 33520-33529 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 33530-33539 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 33540-33549 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 33550-33559 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 33560-33569 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 33570-33579 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 33580-33589 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 33590-33599 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 33600-33609 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 33610-33619 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 33620-33629 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 33630-33639 + 1, 6, 5, 4, 3, 2, 1, 32, 31, 30, // 33640-33649 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 33650-33659 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 33660-33669 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 33670-33679 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 33680-33689 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 33690-33699 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 33700-33709 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 33710-33719 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 33720-33729 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 33730-33739 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 33740-33749 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 33750-33759 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 33760-33769 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 33770-33779 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33780-33789 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 33790-33799 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 33800-33809 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 33810-33819 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 33820-33829 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 33830-33839 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33840-33849 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 33850-33859 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 33860-33869 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 33870-33879 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 33880-33889 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 33890-33899 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33900-33909 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 33910-33919 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 33920-33929 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 33930-33939 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 33940-33949 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33950-33959 + 1, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 33960-33969 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 33970-33979 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 33980-33989 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 33990-33999 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 34000-34009 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 34010-34019 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34020-34029 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 34030-34039 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 34040-34049 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 34050-34059 + 1, 62, 61, 60, 59, 58, 57, 56, 55, 54, // 34060-34069 + 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, // 34070-34079 + 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 34080-34089 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 34090-34099 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 34100-34109 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 34110-34119 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 34120-34129 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34130-34139 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 34140-34149 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 34150-34159 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34160-34169 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 34170-34179 + 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 34180-34189 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 34190-34199 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34200-34209 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 34210-34219 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34220-34229 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 34230-34239 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 34240-34249 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 34250-34259 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 34260-34269 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 34270-34279 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 34280-34289 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 34290-34299 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 34300-34309 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 34310-34319 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 34320-34329 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 34330-34339 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34340-34349 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34350-34359 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 34360-34369 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34370-34379 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 34380-34389 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 34390-34399 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 34400-34409 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34410-34419 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 34420-34429 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 34430-34439 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 34440-34449 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 34450-34459 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 34460-34469 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 34470-34479 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 34480-34489 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 34490-34499 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34500-34509 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 34510-34519 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 34520-34529 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 34530-34539 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 34, // 34540-34549 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 34550-34559 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 34560-34569 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 34570-34579 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 34580-34589 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 34590-34599 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 34600-34609 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 34610-34619 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34620-34629 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 34630-34639 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 34640-34649 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 34650-34659 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 34660-34669 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 34670-34679 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 34680-34689 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 34690-34699 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 34700-34709 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34710-34719 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 34720-34729 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 34730-34739 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 34740-34749 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 34750-34759 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 34760-34769 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34770-34779 + 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 34780-34789 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 34790-34799 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 34800-34809 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 34810-34819 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 34820-34829 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34830-34839 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 22, // 34840-34849 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 34850-34859 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34860-34869 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 34870-34879 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 34880-34889 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 34890-34899 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 34900-34909 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 20, // 34910-34919 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 34920-34929 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 34930-34939 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 34940-34949 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34950-34959 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 34960-34969 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34970-34979 + 1, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 34980-34989 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 34990-34999 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 35000-35009 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 35010-35019 + 3, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 35020-35029 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 35030-35039 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35040-35049 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 35050-35059 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 35060-35069 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35070-35079 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 35080-35089 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 35090-35099 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 35100-35109 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 35110-35119 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 35120-35129 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35130-35139 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 35140-35149 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 35150-35159 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35160-35169 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 35170-35179 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 35180-35189 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35190-35199 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 35200-35209 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35210-35219 + 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 35220-35229 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 35230-35239 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35240-35249 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 35250-35259 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 35260-35269 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 35270-35279 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35280-35289 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 35290-35299 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35300-35309 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 35310-35319 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 35320-35329 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 35330-35339 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 35340-35349 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 35350-35359 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 35360-35369 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35370-35379 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 35380-35389 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 35390-35399 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 35400-35409 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 35410-35419 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 35420-35429 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 35430-35439 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 35440-35449 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35450-35459 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 35460-35469 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 35470-35479 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35480-35489 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 35490-35499 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 35500-35509 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35510-35519 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 35520-35529 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 35530-35539 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 35540-35549 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 35550-35559 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 35560-35569 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 35570-35579 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35580-35589 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 35590-35599 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 35600-35609 + 7, 6, 5, 4, 3, 2, 1, 54, 53, 52, // 35610-35619 + 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, // 35620-35629 + 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 35630-35639 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 35640-35649 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 35650-35659 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35660-35669 + 1, 6, 5, 4, 3, 2, 1, 52, 51, 50, // 35670-35679 + 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, // 35680-35689 + 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 35690-35699 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 35700-35709 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 35710-35719 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 35720-35729 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 35730-35739 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 35740-35749 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 35750-35759 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35760-35769 + 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 35770-35779 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 35780-35789 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 35790-35799 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 35800-35809 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 35810-35819 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35820-35829 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 35830-35839 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35840-35849 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 35850-35859 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 35860-35869 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 35870-35879 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 35880-35889 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 35890-35899 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35900-35909 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 35910-35919 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 35920-35929 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 35930-35939 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35940-35949 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 35950-35959 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 35960-35969 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 35970-35979 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 35980-35989 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 35990-35999 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 36000-36009 + 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 36010-36019 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 36020-36029 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 36030-36039 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 36040-36049 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36050-36059 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 36060-36069 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 36070-36079 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 36080-36089 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 36090-36099 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 36100-36109 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 36110-36119 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36120-36129 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 36130-36139 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36140-36149 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36150-36159 + 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 36160-36169 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 36170-36179 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 36180-36189 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 36190-36199 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 36200-36209 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 36210-36219 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 36220-36229 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36230-36239 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36240-36249 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36250-36259 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 36260-36269 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 36270-36279 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36280-36289 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 36290-36299 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 36300-36309 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 36310-36319 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 36320-36329 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36330-36339 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 36340-36349 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 36350-36359 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36360-36369 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 36370-36379 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 44, // 36380-36389 + 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 36390-36399 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 36400-36409 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 36410-36419 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36420-36429 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 36430-36439 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36440-36449 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 36450-36459 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 36460-36469 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 36470-36479 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36480-36489 + 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 36490-36499 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 36500-36509 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36510-36519 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 36520-36529 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36530-36539 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36540-36549 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 36550-36559 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 36560-36569 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36570-36579 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 36580-36589 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 36590-36599 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 36600-36609 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 36610-36619 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 36620-36629 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 36630-36639 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 36640-36649 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 36650-36659 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36660-36669 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 36670-36679 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 36680-36689 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 36690-36699 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 36700-36709 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 36710-36719 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 36720-36729 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 36730-36739 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 36740-36749 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36750-36759 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 36760-36769 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 36770-36779 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 36780-36789 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 36790-36799 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 36800-36809 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36810-36819 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36820-36829 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 36830-36839 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 36840-36849 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 36850-36859 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36860-36869 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 36870-36879 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 36880-36889 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 36890-36899 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36900-36909 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 36910-36919 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 36920-36929 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36930-36939 + 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 36940-36949 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 36950-36959 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36960-36969 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 36970-36979 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 36980-36989 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 36990-36999 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 37000-37009 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 37010-37019 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 37020-37029 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 37030-37039 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 37040-37049 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 37050-37059 + 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 37060-37069 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37070-37079 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 37080-37089 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 37090-37099 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37100-37109 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 37110-37119 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 37120-37129 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 37130-37139 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 37140-37149 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 37150-37159 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37160-37169 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37170-37179 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 37180-37189 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 37190-37199 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37200-37209 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 37210-37219 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 37220-37229 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 37230-37239 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 37240-37249 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 37250-37259 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 37260-37269 + 3, 2, 1, 4, 3, 2, 1, 30, 29, 28, // 37270-37279 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 37280-37289 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37290-37299 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 37300-37309 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 37310-37319 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37320-37329 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 37330-37339 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37340-37349 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 37350-37359 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 37360-37369 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 37370-37379 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37380-37389 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 37390-37399 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 37400-37409 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 37410-37419 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 37420-37429 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37430-37439 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 37440-37449 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 37450-37459 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 37460-37469 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 37470-37479 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 37480-37489 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 37490-37499 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 37500-37509 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 37510-37519 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 37520-37529 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 37530-37539 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 37540-37549 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37550-37559 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 37560-37569 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 37570-37579 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 37580-37589 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37590-37599 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 37600-37609 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 37610-37619 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 37620-37629 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 37630-37639 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 37640-37649 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 37650-37659 + 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 37660-37669 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 37670-37679 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37680-37689 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 37690-37699 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37700-37709 + 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 37710-37719 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 37720-37729 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37730-37739 + 7, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 37740-37749 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 37750-37759 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 37760-37769 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37770-37779 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 37780-37789 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 37790-37799 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37800-37809 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 37810-37819 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37820-37829 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37830-37839 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 37840-37849 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 37850-37859 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37860-37869 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 37870-37879 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 37880-37889 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 37890-37899 + 7, 6, 5, 4, 3, 2, 1, 44, 43, 42, // 37900-37909 + 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 37910-37919 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 37920-37929 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 37930-37939 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37940-37949 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 37950-37959 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 37960-37969 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37970-37979 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 37980-37989 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 37990-37999 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38000-38009 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 38010-38019 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 38020-38029 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 38030-38039 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 38040-38049 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 38050-38059 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 38060-38069 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38070-38079 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 38080-38089 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 38090-38099 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38100-38109 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 30, // 38110-38119 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 38120-38129 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 38130-38139 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 38140-38149 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 38150-38159 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 38160-38169 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 38170-38179 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 38180-38189 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 38190-38199 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 38200-38209 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 38210-38219 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38220-38229 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 38230-38239 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 38240-38249 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38250-38259 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38260-38269 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 38270-38279 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 38280-38289 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 38290-38299 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 38300-38309 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 38310-38319 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 38320-38329 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 38330-38339 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38340-38349 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 38350-38359 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38360-38369 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 38370-38379 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38380-38389 + 3, 2, 1, 38, 37, 36, 35, 34, 33, 32, // 38390-38399 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 38400-38409 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 38410-38419 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38420-38429 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 38430-38439 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 38440-38449 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 38450-38459 + 1, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 38460-38469 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 38470-38479 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 38480-38489 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38490-38499 + 1, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 38500-38509 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 38510-38519 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 38520-38529 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38530-38539 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 38540-38549 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 38550-38559 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 24, // 38560-38569 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 38570-38579 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38580-38589 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 38590-38599 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 38600-38609 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 38610-38619 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 38620-38629 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 38630-38639 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38640-38649 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 38650-38659 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 38660-38669 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 38670-38679 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38680-38689 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 38690-38699 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 38700-38709 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 38710-38719 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 38720-38729 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 38730-38739 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 38740-38749 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 38750-38759 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 38760-38769 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38770-38779 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 38780-38789 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38790-38799 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 38800-38809 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38810-38819 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38820-38829 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 38830-38839 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38840-38849 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38850-38859 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 38860-38869 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 38870-38879 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38880-38889 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38890-38899 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 38900-38909 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 38910-38919 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 38920-38929 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 38930-38939 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38940-38949 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 38950-38959 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38960-38969 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 38970-38979 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38980-38989 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 38990-38999 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 39000-39009 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 39010-39019 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 39020-39029 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39030-39039 + 1, 2, 1, 4, 3, 2, 1, 32, 31, 30, // 39040-39049 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 39050-39059 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 39060-39069 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 39070-39079 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 39080-39089 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 39090-39099 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 39100-39109 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 39110-39119 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 39120-39129 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 39130-39139 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 39140-39149 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 39150-39159 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 39160-39169 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39170-39179 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39180-39189 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 39190-39199 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 39200-39209 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 39210-39219 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 39220-39229 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 39230-39239 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39240-39249 + 1, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 39250-39259 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 39260-39269 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 39270-39279 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 39280-39289 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 39290-39299 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 39300-39309 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 39310-39319 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 39320-39329 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39330-39339 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 39340-39349 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 39350-39359 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 39360-39369 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 39370-39379 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 39380-39389 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 39390-39399 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 39400-39409 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 39410-39419 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 39420-39429 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 39430-39439 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 39440-39449 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39450-39459 + 1, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 39460-39469 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 39470-39479 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 39480-39489 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 39490-39499 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 39500-39509 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39510-39519 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 39520-39529 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39530-39539 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39540-39549 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 39550-39559 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 39560-39569 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39570-39579 + 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 39580-39589 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 39590-39599 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 39600-39609 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 39610-39619 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 39620-39629 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 39630-39639 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 39640-39649 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 39650-39659 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 39660-39669 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 39670-39679 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 39680-39689 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 39690-39699 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 39700-39709 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 39710-39719 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 39720-39729 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 39730-39739 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 39740-39749 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39750-39759 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 39760-39769 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 39770-39779 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39780-39789 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 39790-39799 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 39800-39809 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39810-39819 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 39820-39829 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 39830-39839 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 39840-39849 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 39850-39859 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 39860-39869 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 39870-39879 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 39880-39889 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39890-39899 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 39900-39909 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 39910-39919 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 39920-39929 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 39930-39939 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 39940-39949 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 39950-39959 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39960-39969 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 39970-39979 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 20, // 39980-39989 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 39990-39999 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 40000-40009 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 40010-40019 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40020-40029 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 24, // 40030-40039 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 40040-40049 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40050-40059 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 40060-40069 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 40070-40079 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 40080-40089 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 40090-40099 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40100-40109 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40110-40119 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 22, // 40120-40129 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 40130-40139 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40140-40149 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 40150-40159 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 40160-40169 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 40170-40179 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 40180-40189 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 40190-40199 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40200-40209 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 40210-40219 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40220-40229 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 40230-40239 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40240-40249 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 40250-40259 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 40260-40269 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 40270-40279 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 54, // 40280-40289 + 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, // 40290-40299 + 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 40300-40309 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 40310-40319 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 40320-40329 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40330-40339 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 40340-40349 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 40350-40359 + 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 40360-40369 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 40370-40379 + 7, 6, 5, 4, 3, 2, 1, 36, 35, 34, // 40380-40389 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 40390-40399 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 40400-40409 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40410-40419 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 40420-40429 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 40430-40439 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 40440-40449 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 40450-40459 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40460-40469 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40470-40479 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 40480-40489 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 40490-40499 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 40500-40509 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 40510-40519 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 40520-40529 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40530-40539 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 40540-40549 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 40550-40559 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 40560-40569 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 40570-40579 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 40580-40589 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 40590-40599 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 40600-40609 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 40610-40619 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 40620-40629 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 54, // 40630-40639 + 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, // 40640-40649 + 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 40650-40659 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 40660-40669 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 40670-40679 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40680-40689 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 40690-40699 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 40700-40709 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 40710-40719 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 40720-40729 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 40730-40739 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40740-40749 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 40750-40759 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 40760-40769 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 40770-40779 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 40780-40789 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40790-40799 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40800-40809 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 40810-40819 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 40820-40829 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40830-40839 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 40840-40849 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 40850-40859 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 40860-40869 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 40870-40879 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 40880-40889 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 40890-40899 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 40900-40909 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 40910-40919 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 40920-40929 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 40930-40939 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 40940-40949 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40950-40959 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40960-40969 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 40970-40979 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40980-40989 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 40990-40999 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41000-41009 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 41010-41019 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 41020-41029 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 41030-41039 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 41040-41049 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 41050-41059 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 41060-41069 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 41070-41079 + 1, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 41080-41089 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 41090-41099 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 41100-41109 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 41110-41119 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41120-41129 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41130-41139 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 41140-41149 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41150-41159 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 41160-41169 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 41170-41179 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 41180-41189 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41190-41199 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 41200-41209 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 41210-41219 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 41220-41229 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 41230-41239 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 41240-41249 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 41250-41259 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 41260-41269 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41270-41279 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 41280-41289 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 34, // 41290-41299 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 41300-41309 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 41310-41319 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 41320-41329 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 41330-41339 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41340-41349 + 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 41350-41359 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 41360-41369 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41370-41379 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 41380-41389 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 41390-41399 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41400-41409 + 1, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 41410-41419 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 41420-41429 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 41430-41439 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 41440-41449 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 41450-41459 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 41460-41469 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 41470-41479 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41480-41489 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 41490-41499 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 41500-41509 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 41510-41519 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 41520-41529 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 41530-41539 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 30, // 41540-41549 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 41550-41559 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 41560-41569 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 41570-41579 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 41580-41589 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 41590-41599 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 41600-41609 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 41610-41619 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 41620-41629 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41630-41639 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 41640-41649 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 41650-41659 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 41660-41669 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41670-41679 + 1, 6, 5, 4, 3, 2, 1, 32, 31, 30, // 41680-41689 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 41690-41699 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 41700-41709 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 41710-41719 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 41720-41729 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 41730-41739 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 41740-41749 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 41750-41759 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41760-41769 + 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 41770-41779 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 41780-41789 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41790-41799 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 41800-41809 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 41810-41819 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 41820-41829 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 41830-41839 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 41840-41849 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 41850-41859 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 41860-41869 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 41870-41879 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 41880-41889 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 41890-41899 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 41900-41909 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 41910-41919 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 41920-41929 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41930-41939 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 41940-41949 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 41950-41959 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 41960-41969 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41970-41979 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 41980-41989 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 41990-41999 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42000-42009 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 42010-42019 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 42020-42029 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42030-42039 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 42040-42049 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42050-42059 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42060-42069 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 42070-42079 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 42080-42089 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42090-42099 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 42100-42109 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 42110-42119 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42120-42129 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 42130-42139 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 42140-42149 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 42150-42159 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 42160-42169 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 42170-42179 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 42180-42189 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 42190-42199 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 42200-42209 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42210-42219 + 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 42220-42229 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 42230-42239 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 42240-42249 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 42250-42259 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 42260-42269 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42270-42279 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 42280-42289 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 42290-42299 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 42300-42309 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42310-42319 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 42320-42329 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 42330-42339 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 42340-42349 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 42350-42359 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42360-42369 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 42370-42379 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42380-42389 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 42390-42399 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 24, // 42400-42409 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 42410-42419 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42420-42429 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 42430-42439 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 42440-42449 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 42450-42459 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 42460-42469 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 42470-42479 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 42480-42489 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 42490-42499 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 42500-42509 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 42510-42519 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42520-42529 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 42530-42539 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 42540-42549 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 42550-42559 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 42560-42569 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 42570-42579 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 42580-42589 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 42590-42599 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42600-42609 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 42610-42619 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 42620-42629 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42630-42639 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 42640-42649 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 42650-42659 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 42660-42669 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 42670-42679 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 42680-42689 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 42690-42699 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 42700-42709 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 42710-42719 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 42720-42729 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 42730-42739 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 42740-42749 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 42750-42759 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 42760-42769 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 42770-42779 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 42780-42789 + 3, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 42790-42799 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 42800-42809 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42810-42819 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 42820-42829 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 42830-42839 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42840-42849 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 42850-42859 + 3, 2, 1, 36, 35, 34, 33, 32, 31, 30, // 42860-42869 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 42870-42879 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 42880-42889 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 42890-42899 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 42900-42909 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42910-42919 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 42920-42929 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 42930-42939 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 42940-42949 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 42950-42959 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 42960-42969 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 42970-42979 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 42980-42989 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42990-42999 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 43000-43009 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 43010-43019 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 43020-43029 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 43030-43039 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 43040-43049 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43050-43059 + 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 43060-43069 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 43070-43079 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43080-43089 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 43090-43099 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 43100-43109 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 43110-43119 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43120-43129 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 43130-43139 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43140-43149 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 43150-43159 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 43160-43169 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 43170-43179 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 43180-43189 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43190-43199 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 43200-43209 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43210-43219 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 43220-43229 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 43230-43239 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 43240-43249 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43250-43259 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43260-43269 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43270-43279 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 43280-43289 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 43290-43299 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43300-43309 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 43310-43319 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43320-43329 + 1, 60, 59, 58, 57, 56, 55, 54, 53, 52, // 43330-43339 + 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, // 43340-43349 + 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 43350-43359 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 43360-43369 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 43370-43379 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43380-43389 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 43390-43399 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 43400-43409 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 43410-43419 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 43420-43429 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43430-43439 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43440-43449 + 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 43450-43459 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 43460-43469 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43470-43479 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 43480-43489 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 43490-43499 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 43500-43509 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 43510-43519 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 43520-43529 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43530-43539 + 1, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 43540-43549 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 43550-43559 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43560-43569 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 43570-43579 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43580-43589 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 43590-43599 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 43600-43609 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 43610-43619 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 43620-43629 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 43630-43639 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 43640-43649 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43650-43659 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 43660-43669 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 43670-43679 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43680-43689 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 43690-43699 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43700-43709 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 43710-43719 + 1, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 43720-43729 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 43730-43739 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43740-43749 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 43750-43759 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 43760-43769 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 43770-43779 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 43780-43789 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 43790-43799 + 1, 52, 51, 50, 49, 48, 47, 46, 45, 44, // 43800-43809 + 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 43810-43819 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 43820-43829 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 43830-43839 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43840-43849 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 43850-43859 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 43860-43869 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 43870-43879 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 43880-43889 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 43890-43899 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43900-43909 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 43910-43919 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43920-43929 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 43930-43939 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 43940-43949 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43950-43959 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 43960-43969 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 43970-43979 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 43980-43989 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 43990-43999 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 44000-44009 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 44010-44019 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 44020-44029 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44030-44039 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 44040-44049 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 44050-44059 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44060-44069 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 44070-44079 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 44080-44089 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44090-44099 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44100-44109 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 44110-44119 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 44120-44129 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 44130-44139 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 44140-44149 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 44150-44159 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44160-44169 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 44170-44179 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 44180-44189 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44190-44199 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 44200-44209 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44210-44219 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 44220-44229 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 44230-44239 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 44240-44249 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 44250-44259 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 44260-44269 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 44270-44279 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 44280-44289 + 3, 2, 1, 58, 57, 56, 55, 54, 53, 52, // 44290-44299 + 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, // 44300-44309 + 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 44310-44319 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 44320-44329 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 44330-44339 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44340-44349 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 44350-44359 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44360-44369 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44370-44379 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 28, // 44380-44389 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 44390-44399 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 44400-44409 + 7, 6, 5, 4, 3, 2, 1, 32, 31, 30, // 44410-44419 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 44420-44429 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 44430-44439 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 44440-44449 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 44450-44459 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 44460-44469 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 44470-44479 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 44480-44489 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 44490-44499 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 44500-44509 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 44510-44519 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44520-44529 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 44530-44539 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 44540-44549 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 44550-44559 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 44560-44569 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 44570-44579 + 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 44580-44589 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 44590-44599 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 44600-44609 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 44610-44619 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 44620-44629 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 44630-44639 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 44640-44649 + 1, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 44650-44659 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 44660-44669 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 44670-44679 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 44680-44689 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 44690-44699 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44700-44709 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 44710-44719 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 44720-44729 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44730-44739 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 44740-44749 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 44750-44759 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44760-44769 + 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 44770-44779 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 44780-44789 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 44790-44799 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 44800-44809 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 44810-44819 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 44820-44829 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 44830-44839 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 44840-44849 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 44850-44859 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 44860-44869 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 44870-44879 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 44880-44889 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 44890-44899 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 44900-44909 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 44910-44919 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 44920-44929 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 44930-44939 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 44940-44949 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 44950-44959 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 44960-44969 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 44970-44979 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 44980-44989 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 44990-44999 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 45000-45009 + 3, 2, 1, 40, 39, 38, 37, 36, 35, 34, // 45010-45019 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 45020-45029 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 45030-45039 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 45040-45049 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 45050-45059 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 45060-45069 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 45070-45079 + 3, 2, 1, 36, 35, 34, 33, 32, 31, 30, // 45080-45089 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 45090-45099 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 45100-45109 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 45110-45119 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 45120-45129 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 45130-45139 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 45140-45149 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45150-45159 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 45160-45169 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 45170-45179 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45180-45189 + 1, 6, 5, 4, 3, 2, 1, 36, 35, 34, // 45190-45199 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 45200-45209 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 45210-45219 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 45220-45229 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 45230-45239 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 45240-45249 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 45250-45259 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 45260-45269 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45270-45279 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 45280-45289 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 45290-45299 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 45300-45309 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 45310-45319 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 45320-45329 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 45330-45339 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 45340-45349 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45350-45359 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 45360-45369 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 45370-45379 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 45380-45389 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 45390-45399 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 45400-45409 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 45410-45419 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 45420-45429 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 42, // 45430-45439 + 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 45440-45449 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 45450-45459 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 45460-45469 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45470-45479 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45480-45489 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 45490-45499 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 45500-45509 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 45510-45519 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 45520-45529 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 45530-45539 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 45540-45549 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 45550-45559 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 45560-45569 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 45570-45579 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 45580-45589 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 45590-45599 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 45600-45609 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 45610-45619 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45620-45629 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45630-45639 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 45640-45649 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 45650-45659 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 45660-45669 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 45670-45679 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45680-45689 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 45690-45699 + 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 45700-45709 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 45710-45719 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 45720-45729 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 45730-45739 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45740-45749 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 45750-45759 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 45760-45769 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 38, // 45770-45779 + 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 45780-45789 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 45790-45799 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 45800-45809 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 45810-45819 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 45820-45829 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 45830-45839 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 45840-45849 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 45850-45859 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 45860-45869 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 45870-45879 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 45880-45889 + 3, 2, 1, 50, 49, 48, 47, 46, 45, 44, // 45890-45899 + 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 45900-45909 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 45910-45919 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 45920-45929 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 45930-45939 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 45940-45949 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 45950-45959 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45960-45969 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 45970-45979 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 32, // 45980-45989 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 45990-45999 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 46000-46009 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46010-46019 + 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 46020-46029 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 46030-46039 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 46040-46049 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46050-46059 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46060-46069 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 46070-46079 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46080-46089 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 46090-46099 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 46100-46109 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 46110-46119 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46120-46129 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 46130-46139 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 46140-46149 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 46150-46159 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46160-46169 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46170-46179 + 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 46180-46189 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 46190-46199 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 46200-46209 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 46210-46219 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 46220-46229 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 46230-46239 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 46240-46249 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46250-46259 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46260-46269 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 46270-46279 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 46280-46289 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46290-46299 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 46300-46309 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 46310-46319 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 46320-46329 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 46330-46339 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 46340-46349 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 46350-46359 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 46360-46369 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46370-46379 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 46380-46389 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 46390-46399 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46400-46409 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 46410-46419 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 46420-46429 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 46430-46439 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 46440-46449 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 46450-46459 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46460-46469 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 46470-46479 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 46480-46489 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 46490-46499 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 46500-46509 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46510-46519 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 46520-46529 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 46530-46539 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 46540-46549 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 46550-46559 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 46560-46569 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 46570-46579 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 46580-46589 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46590-46599 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 46600-46609 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 46610-46619 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46620-46629 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 46630-46639 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 46640-46649 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46650-46659 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 46660-46669 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 46670-46679 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 46680-46689 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46690-46699 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 46700-46709 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46710-46719 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 46720-46729 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 46730-46739 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 46740-46749 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 46750-46759 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 46760-46769 + 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 46770-46779 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 46780-46789 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 46790-46799 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 46800-46809 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 46810-46819 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 46820-46829 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 46830-46839 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46840-46849 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 46850-46859 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 46860-46869 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 46870-46879 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 46880-46889 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46890-46899 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 46900-46909 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 46910-46919 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46920-46929 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 46930-46939 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 46940-46949 + 7, 6, 5, 4, 3, 2, 1, 36, 35, 34, // 46950-46959 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 46960-46969 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 46970-46979 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46980-46989 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 46990-46999 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 47000-47009 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 47010-47019 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 47020-47029 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47030-47039 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47040-47049 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 28, // 47050-47059 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 47060-47069 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 47070-47079 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 47080-47089 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 47090-47099 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47100-47109 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 47110-47119 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 47120-47129 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 47130-47139 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 47140-47149 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47150-47159 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 47160-47169 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 47170-47179 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 47180-47189 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 47190-47199 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 47200-47209 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47210-47219 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 47220-47229 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 47230-47239 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47240-47249 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 47250-47259 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 47260-47269 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 47270-47279 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 47280-47289 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 47290-47299 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 47300-47309 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 47310-47319 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 47320-47329 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 47330-47339 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47340-47349 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 47350-47359 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 47360-47369 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47370-47379 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 47380-47389 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 47390-47399 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 47400-47409 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 47410-47419 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47420-47429 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47430-47439 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 47440-47449 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 32, // 47450-47459 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 47460-47469 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 47470-47479 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47480-47489 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 47490-47499 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 47500-47509 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 47510-47519 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 47520-47529 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 47530-47539 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 47540-47549 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 47550-47559 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 47560-47569 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47570-47579 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47580-47589 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 47590-47599 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 47600-47609 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 47610-47619 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 47620-47629 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 47630-47639 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 47640-47649 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 22, // 47650-47659 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 47660-47669 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47670-47679 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 47680-47689 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 47690-47699 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47700-47709 + 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 47710-47719 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 47720-47729 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 47730-47739 + 1, 2, 1, 34, 33, 32, 31, 30, 29, 28, // 47740-47749 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 47750-47759 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 47760-47769 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 47770-47779 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47780-47789 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 47790-47799 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 47800-47809 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 47810-47819 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 47820-47829 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 47830-47839 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 47840-47849 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 47850-47859 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 47860-47869 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47870-47879 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 47880-47889 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 47890-47899 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 47900-47909 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 47910-47919 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 47920-47929 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 47930-47939 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 47940-47949 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 47950-47959 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 47960-47969 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 47970-47979 + 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 47980-47989 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 47990-47999 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 48000-48009 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 48010-48019 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 20, // 48020-48029 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 48030-48039 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 48040-48049 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 48050-48059 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48060-48069 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 48070-48079 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48080-48089 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 48090-48099 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 48100-48109 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 48110-48119 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48120-48129 + 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 48130-48139 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 48140-48149 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 48150-48159 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 48160-48169 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 48170-48179 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 48180-48189 + 3, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 48190-48199 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 48200-48209 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48210-48219 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 48220-48229 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 48230-48239 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 48240-48249 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 48250-48259 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48260-48269 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48270-48279 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 48280-48289 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 48290-48299 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48300-48309 + 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 48310-48319 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 48320-48329 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 48330-48339 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48340-48349 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 48350-48359 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48360-48369 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48370-48379 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 48380-48389 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 48390-48399 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 48400-48409 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 48410-48419 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 48420-48429 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 48430-48439 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 48440-48449 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48450-48459 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 48460-48469 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 48470-48479 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 48480-48489 + 1, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 48490-48499 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 48500-48509 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48510-48519 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 48520-48529 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 48530-48539 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 48540-48549 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48550-48559 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 48560-48569 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 48570-48579 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 48580-48589 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 48590-48599 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48600-48609 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 48610-48619 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 48620-48629 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 48630-48639 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 48640-48649 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48650-48659 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48660-48669 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 52, // 48670-48679 + 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, // 48680-48689 + 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 48690-48699 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 48700-48709 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 48710-48719 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48720-48729 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 48730-48739 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48740-48749 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 48750-48759 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 48760-48769 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 48770-48779 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 48780-48789 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 48790-48799 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 48800-48809 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 48810-48819 + 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 48820-48829 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 48830-48839 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 48840-48849 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 48850-48859 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 48860-48869 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48870-48879 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 48880-48889 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 48890-48899 + 7, 6, 5, 4, 3, 2, 1, 40, 39, 38, // 48900-48909 + 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 48910-48919 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 48920-48929 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 48930-48939 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 48940-48949 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 48950-48959 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48960-48969 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 48970-48979 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 48980-48989 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48990-48999 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 49000-49009 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 49010-49019 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49020-49029 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 49030-49039 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 49040-49049 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 49050-49059 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 49060-49069 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49070-49079 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 49080-49089 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49090-49099 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 49100-49109 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 49110-49119 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 49120-49129 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 49130-49139 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 49140-49149 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 49150-49159 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 49160-49169 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 49170-49179 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49180-49189 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 49190-49199 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 49200-49209 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49210-49219 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 49220-49229 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 49230-49239 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49240-49249 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 49250-49259 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 49260-49269 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 49270-49279 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 49280-49289 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 49290-49299 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 49300-49309 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 49310-49319 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49320-49329 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 24, // 49330-49339 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 49340-49349 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49350-49359 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 22, // 49360-49369 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 49370-49379 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49380-49389 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 49390-49399 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 49400-49409 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 49410-49419 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 49420-49429 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 49430-49439 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49440-49449 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 49450-49459 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 49460-49469 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 49470-49479 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 49480-49489 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 49490-49499 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 49500-49509 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49510-49519 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 49520-49529 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 49530-49539 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 49540-49549 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 38, // 49550-49559 + 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 49560-49569 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 49570-49579 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 49580-49589 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 49590-49599 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 49600-49609 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 49610-49619 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 49620-49629 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 24, // 49630-49639 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 49640-49649 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49650-49659 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 49660-49669 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49670-49679 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 49680-49689 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 49690-49699 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49700-49709 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 49710-49719 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 49720-49729 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 49730-49739 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 49740-49749 + 7, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 49750-49759 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 49760-49769 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49770-49779 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 49780-49789 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49790-49799 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 49800-49809 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49810-49819 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 49820-49829 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49830-49839 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 49840-49849 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 49850-49859 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49860-49869 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 49870-49879 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49880-49889 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 49890-49899 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 49900-49909 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 49910-49919 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 49920-49929 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 49930-49939 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 49940-49949 + 7, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 49950-49959 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 49960-49969 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 49970-49979 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49980-49989 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 49990-49999 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 50000-50009 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50010-50019 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 50020-50029 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 50030-50039 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 50040-50049 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 50050-50059 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 50060-50069 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 50070-50079 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 50080-50089 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 50090-50099 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50100-50109 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 50110-50119 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 50120-50129 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 50130-50139 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 50140-50149 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 50150-50159 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 50160-50169 + 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 50170-50179 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 50180-50189 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 50190-50199 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 50200-50209 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50210-50219 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 50220-50229 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 50230-50239 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 50240-50249 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50250-50259 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 50260-50269 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 50270-50279 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 50280-50289 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 50290-50299 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50300-50309 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50310-50319 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 50320-50329 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 50330-50339 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 50340-50349 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 50350-50359 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 50360-50369 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 50370-50379 + 3, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 50380-50389 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 50390-50399 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50400-50409 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 50410-50419 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 50420-50429 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50430-50439 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 50440-50449 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 50450-50459 + 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 50460-50469 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 50470-50479 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 50480-50489 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 50490-50499 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 50500-50509 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 50510-50519 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 50520-50529 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 50530-50539 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 50540-50549 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 50550-50559 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 50560-50569 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50570-50579 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 50580-50589 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 28, // 50590-50599 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 50600-50609 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 50610-50619 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 50620-50629 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 50630-50639 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 50640-50649 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 50650-50659 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50660-50669 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 50670-50679 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 50680-50689 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 50690-50699 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 50700-50709 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 50710-50719 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 50720-50729 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50730-50739 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 50740-50749 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 50750-50759 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 50760-50769 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 50770-50779 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 32, // 50780-50789 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 50790-50799 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 50800-50809 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50810-50819 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 50820-50829 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 50830-50839 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 50840-50849 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 50850-50859 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 50860-50869 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 50870-50879 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50880-50889 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 50890-50899 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 50900-50909 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 50910-50919 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 50920-50929 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 50930-50939 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50940-50949 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 50950-50959 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 50960-50969 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 50970-50979 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 50980-50989 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 50990-50999 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 51000-51009 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 51010-51019 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51020-51029 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51030-51039 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 51040-51049 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 51050-51059 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51060-51069 + 1, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 51070-51079 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 51080-51089 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 51090-51099 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 51100-51109 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 51110-51119 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51120-51129 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 51130-51139 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51140-51149 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 51150-51159 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 51160-51169 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 51170-51179 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51180-51189 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 51190-51199 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 51200-51209 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 51210-51219 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 51220-51229 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 51230-51239 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 51240-51249 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 51250-51259 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 51260-51269 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51270-51279 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 51280-51289 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 51290-51299 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 51300-51309 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 51310-51319 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 51320-51329 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51330-51339 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 51340-51349 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51350-51359 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 51360-51369 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51370-51379 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 51380-51389 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 51390-51399 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 51400-51409 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 51410-51419 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 51420-51429 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 51430-51439 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 51440-51449 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51450-51459 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51460-51469 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 51470-51479 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 51480-51489 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51490-51499 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 51500-51509 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 51510-51519 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 51520-51529 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 51530-51539 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51540-51549 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51550-51559 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 51560-51569 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 51570-51579 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51580-51589 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 51590-51599 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 51600-51609 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 51610-51619 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51620-51629 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 51630-51639 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 51640-51649 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 51650-51659 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51660-51669 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 51670-51679 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 51680-51689 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 51690-51699 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51700-51709 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 51710-51719 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 51720-51729 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 51730-51739 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 51740-51749 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 51750-51759 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 51760-51769 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 51770-51779 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 51780-51789 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 51790-51799 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 51800-51809 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 51810-51819 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 51820-51829 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 51830-51839 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51840-51849 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 51850-51859 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 51860-51869 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 51870-51879 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51880-51889 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 51890-51899 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 51900-51909 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 51910-51919 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 51920-51929 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51930-51939 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 51940-51949 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 51950-51959 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51960-51969 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 51970-51979 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51980-51989 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 51990-51999 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 52000-52009 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52010-52019 + 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 52020-52029 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 52030-52039 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52040-52049 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 52050-52059 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 52060-52069 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52070-52079 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 52080-52089 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 52090-52099 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 52100-52109 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52110-52119 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 52120-52129 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 52130-52139 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 52140-52149 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 52150-52159 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 52160-52169 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 52170-52179 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 52180-52189 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52190-52199 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 52200-52209 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 52210-52219 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 52220-52229 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 52230-52239 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 52240-52249 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 52250-52259 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 52260-52269 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 52270-52279 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 52280-52289 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52290-52299 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 52300-52309 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 52310-52319 + 1, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 52320-52329 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 52330-52339 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 52340-52349 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52350-52359 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 52360-52369 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 52370-52379 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 52380-52389 + 1, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 52390-52399 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 52400-52409 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 52410-52419 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 52420-52429 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 52430-52439 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 52440-52449 + 3, 2, 1, 4, 3, 2, 1, 32, 31, 30, // 52450-52459 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 52460-52469 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 52470-52479 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 52480-52489 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52490-52499 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52500-52509 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 52510-52519 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 52520-52529 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52530-52539 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 52540-52549 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 52550-52559 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 52560-52569 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 52570-52579 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 52580-52589 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 52590-52599 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 52600-52609 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 52610-52619 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 52620-52629 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 28, // 52630-52639 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 52640-52649 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 52650-52659 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 52660-52669 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 52670-52679 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52680-52689 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 52690-52699 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 52700-52709 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52710-52719 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 52720-52729 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 52730-52739 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 52740-52749 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 52750-52759 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 52760-52769 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 52770-52779 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 52780-52789 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 52790-52799 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 52800-52809 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 52810-52819 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 52820-52829 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 52830-52839 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 52840-52849 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 52850-52859 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 52860-52869 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 52870-52879 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 52880-52889 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52890-52899 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 52900-52909 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 52910-52919 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 52920-52929 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 52930-52939 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52940-52949 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 52950-52959 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 52960-52969 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 52970-52979 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 52980-52989 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 52990-52999 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 53000-53009 + 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 53010-53019 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 53020-53029 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53030-53039 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 53040-53049 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 53050-53059 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 53060-53069 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 53070-53079 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 53080-53089 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 53090-53099 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53100-53109 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 53110-53119 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 53120-53129 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53130-53139 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 53140-53149 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53150-53159 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53160-53169 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 53170-53179 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 53180-53189 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 53190-53199 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 53200-53209 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 53210-53219 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53220-53229 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 28, // 53230-53239 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 53240-53249 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53250-53259 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 53260-53269 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 53270-53279 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 53280-53289 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 53290-53299 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 53300-53309 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53310-53319 + 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 53320-53329 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 53330-53339 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53340-53349 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 53350-53359 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53360-53369 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 53370-53379 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 53380-53389 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53390-53399 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 53400-53409 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 53410-53419 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53420-53429 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 53430-53439 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53440-53449 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 53450-53459 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 53460-53469 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 53470-53479 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 53480-53489 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53490-53499 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 53500-53509 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53510-53519 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 53520-53529 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 53530-53539 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 53540-53549 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 53550-53559 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 53560-53569 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 53570-53579 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53580-53589 + 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 53590-53599 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 53600-53609 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 53610-53619 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 53620-53629 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 53630-53639 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53640-53649 + 3, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 53650-53659 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 53660-53669 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53670-53679 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53680-53689 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 53690-53699 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53700-53709 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 53710-53719 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53720-53729 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 53730-53739 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 53740-53749 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 53750-53759 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53760-53769 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 53770-53779 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 53780-53789 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 53790-53799 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53800-53809 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 53810-53819 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53820-53829 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 53830-53839 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 53840-53849 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 53850-53859 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 53860-53869 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53870-53879 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 53880-53889 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 53890-53899 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53900-53909 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 53910-53919 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 53920-53929 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 53930-53939 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53940-53949 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 28, // 53950-53959 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 53960-53969 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53970-53979 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 53980-53989 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 53990-53999 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54000-54009 + 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 54010-54019 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54020-54029 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 54030-54039 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 54040-54049 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 54050-54059 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 54060-54069 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 54070-54079 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 54080-54089 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54090-54099 + 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 54100-54109 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54110-54119 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 54120-54129 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 54130-54139 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54140-54149 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 54150-54159 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 54160-54169 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54170-54179 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 54180-54189 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 54190-54199 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54200-54209 + 7, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 54210-54219 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 54220-54229 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 54230-54239 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54240-54249 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 54250-54259 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 54260-54269 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 54270-54279 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 54280-54289 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 54290-54299 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54300-54309 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 54310-54319 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 54320-54329 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54330-54339 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 54340-54349 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54350-54359 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 54360-54369 + 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 54370-54379 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 54380-54389 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54390-54399 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 54400-54409 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 54410-54419 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54420-54429 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 54430-54439 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 20, // 54440-54449 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 54450-54459 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 54460-54469 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 54470-54479 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 54480-54489 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 54490-54499 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 54500-54509 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 54510-54519 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 54520-54529 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 54530-54539 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 54540-54549 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 54550-54559 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 54560-54569 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 54570-54579 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 54580-54589 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54590-54599 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54600-54609 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 54610-54619 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 54620-54629 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54630-54639 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 54640-54649 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54650-54659 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 54660-54669 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 30, // 54670-54679 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 54680-54689 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 54690-54699 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 54700-54709 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 54710-54719 + 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 54720-54729 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 54730-54739 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54740-54749 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54750-54759 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 54760-54769 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 54770-54779 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 54780-54789 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 54790-54799 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 54800-54809 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 54810-54819 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 54820-54829 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 54830-54839 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54840-54849 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 54850-54859 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 54860-54869 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 54870-54879 + 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 54880-54889 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54890-54899 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 54900-54909 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 54910-54919 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 54920-54929 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54930-54939 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 54940-54949 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 54950-54959 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 54960-54969 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 54970-54979 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 54980-54989 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54990-54999 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 55000-55009 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55010-55019 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 55020-55029 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 55030-55039 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 55040-55049 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 55050-55059 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55060-55069 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 24, // 55070-55079 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 55080-55089 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55090-55099 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 55100-55109 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 55110-55119 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 55120-55129 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 55130-55139 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 55140-55149 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55150-55159 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 55160-55169 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 55170-55179 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 55180-55189 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55190-55199 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 55200-55209 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 55210-55219 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 55220-55229 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55230-55239 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 55240-55249 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 32, // 55250-55259 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 55260-55269 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 55270-55279 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55280-55289 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 55290-55299 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55300-55309 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 55310-55319 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55320-55329 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 55330-55339 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 55340-55349 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 55350-55359 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55360-55369 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 55370-55379 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 55380-55389 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 55390-55399 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55400-55409 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 55410-55419 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 55420-55429 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 55430-55439 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 55440-55449 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 55450-55459 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 55460-55469 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 55470-55479 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 55480-55489 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55490-55499 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55500-55509 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 55510-55519 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 55520-55529 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55530-55539 + 1, 6, 5, 4, 3, 2, 1, 32, 31, 30, // 55540-55549 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 55550-55559 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 55560-55569 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 55570-55579 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 55580-55589 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55590-55599 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 55600-55609 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 55610-55619 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55620-55629 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 55630-55639 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 55640-55649 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55650-55659 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 55660-55669 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 55670-55679 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55680-55689 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 55690-55699 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55700-55709 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 55710-55719 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55720-55729 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 55730-55739 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 55740-55749 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55750-55759 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 55760-55769 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 55770-55779 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 55780-55789 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 55790-55799 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 55800-55809 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 55810-55819 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 55820-55829 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 55830-55839 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 55840-55849 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 55850-55859 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55860-55869 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 55870-55879 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 55880-55889 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 55890-55899 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 55900-55909 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55910-55919 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 55920-55929 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 55930-55939 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 55940-55949 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 55950-55959 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 55960-55969 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 55970-55979 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 55980-55989 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 55990-55999 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 30, // 56000-56009 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 56010-56019 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 56020-56029 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 56030-56039 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 56040-56049 + 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 56050-56059 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 56060-56069 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56070-56079 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 56080-56089 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 56090-56099 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 56100-56109 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 56110-56119 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 56120-56129 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 56130-56139 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 56140-56149 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 56150-56159 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 56160-56169 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 56170-56179 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 56180-56189 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 56190-56199 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 28, // 56200-56209 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 56210-56219 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 56220-56229 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 56230-56239 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 56240-56249 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 56250-56259 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 30, // 56260-56269 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 56270-56279 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 56280-56289 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 56290-56299 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56300-56309 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 56310-56319 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 56320-56329 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 56330-56339 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 56340-56349 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 56350-56359 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 56360-56369 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 56370-56379 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 56380-56389 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 56390-56399 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 56400-56409 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 56410-56419 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56420-56429 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 56430-56439 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 56440-56449 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 56450-56459 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 56460-56469 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 56470-56479 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 56480-56489 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56490-56499 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 56500-56509 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 56510-56519 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 56520-56529 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 56530-56539 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 56540-56549 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 56550-56559 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 56560-56569 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 56570-56579 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56580-56589 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 56590-56599 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56600-56609 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 56610-56619 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 56620-56629 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 56630-56639 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 56640-56649 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 56650-56659 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 56660-56669 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56670-56679 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 56680-56689 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56690-56699 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56700-56709 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 56710-56719 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56720-56729 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 56730-56739 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 56740-56749 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 56750-56759 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 56760-56769 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 56770-56779 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 56780-56789 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 56790-56799 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 56800-56809 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 56810-56819 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 56820-56829 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 56830-56839 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 56840-56849 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 56850-56859 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 56860-56869 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 56870-56879 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56880-56889 + 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 56890-56899 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 56900-56909 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56910-56919 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 56920-56929 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56930-56939 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56940-56949 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 56950-56959 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 56960-56969 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 56970-56979 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 56980-56989 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 38, // 56990-56999 + 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 57000-57009 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 57010-57019 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57020-57029 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 57030-57039 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 57040-57049 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 57050-57059 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 57060-57069 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 57070-57079 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 57080-57089 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 57090-57099 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 57100-57109 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 57110-57119 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57120-57129 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 57130-57139 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 57140-57149 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 57150-57159 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 57160-57169 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 57170-57179 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57180-57189 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 57190-57199 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 57200-57209 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57210-57219 + 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 57220-57229 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57230-57239 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57240-57249 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 57250-57259 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 57260-57269 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 57270-57279 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 57280-57289 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57290-57299 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 57300-57309 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 57310-57319 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 57320-57329 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57330-57339 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 57340-57349 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57350-57359 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 57360-57369 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 57370-57379 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 57380-57389 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 57390-57399 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 57400-57409 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 57410-57419 + 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 57420-57429 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 57430-57439 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57440-57449 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 57450-57459 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 57460-57469 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57470-57479 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 57480-57489 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 57490-57499 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 57500-57509 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57510-57519 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 28, // 57520-57529 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 57530-57539 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57540-57549 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 57550-57559 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57560-57569 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57570-57579 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 57580-57589 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 57590-57599 + 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 57600-57609 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 57610-57619 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57620-57629 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 57630-57639 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 57640-57649 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 57650-57659 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 57660-57669 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 57670-57679 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 57680-57689 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 57690-57699 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 57700-57709 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 57710-57719 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 57720-57729 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 57730-57739 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57740-57749 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 57750-57759 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 57760-57769 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 57770-57779 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 57780-57789 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 57790-57799 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 20, // 57800-57809 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 57810-57819 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 57820-57829 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 57830-57839 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 57840-57849 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 57850-57859 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 57860-57869 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57870-57879 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 57880-57889 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 57890-57899 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57900-57909 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 57910-57919 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 57920-57929 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 57930-57939 + 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 57940-57949 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 57950-57959 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 57960-57969 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 57970-57979 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57980-57989 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 57990-57999 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 58000-58009 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 58010-58019 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 58020-58029 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 58030-58039 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 58040-58049 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 58050-58059 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 58060-58069 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 58070-58079 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 58080-58089 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 58090-58099 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 58100-58109 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 58110-58119 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 58120-58129 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58130-58139 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 58140-58149 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 58150-58159 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 58160-58169 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 58170-58179 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 58180-58189 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 58190-58199 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 58200-58209 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 58210-58219 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 58220-58229 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 58230-58239 + 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 58240-58249 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 58250-58259 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58260-58269 + 1, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 58270-58279 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 58280-58289 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 58290-58299 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 58300-58309 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 58310-58319 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58320-58329 + 7, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 58330-58339 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 58340-58349 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 58350-58359 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 58360-58369 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 58370-58379 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58380-58389 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 58390-58399 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 58400-58409 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 58410-58419 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 58420-58429 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 58430-58439 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58440-58449 + 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 58450-58459 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58460-58469 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 58470-58479 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 58480-58489 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 58490-58499 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58500-58509 + 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 58510-58519 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58520-58529 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 58530-58539 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 58540-58549 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58550-58559 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 58560-58569 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 58570-58579 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 58580-58589 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58590-58599 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 58600-58609 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 58610-58619 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58620-58629 + 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 58630-58639 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58640-58649 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 58650-58659 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 58660-58669 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 58670-58679 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 58680-58689 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 58690-58699 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58700-58709 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58710-58719 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 58720-58729 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 58730-58739 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58740-58749 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 58750-58759 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 58760-58769 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58770-58779 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 42, // 58780-58789 + 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 58790-58799 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 58800-58809 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 58810-58819 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58820-58829 + 1, 58, 57, 56, 55, 54, 53, 52, 51, 50, // 58830-58839 + 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, // 58840-58849 + 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 58850-58859 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 58860-58869 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 58870-58879 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 58880-58889 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 58890-58899 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 58900-58909 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 58910-58919 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58920-58929 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 58930-58939 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 58940-58949 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 58950-58959 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 58960-58969 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 58970-58979 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58980-58989 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 58990-58999 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 59000-59009 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59010-59019 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 59020-59029 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 59030-59039 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59040-59049 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 59050-59059 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 59060-59069 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 59070-59079 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 59080-59089 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 59090-59099 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 59100-59109 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 59110-59119 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 59120-59129 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59130-59139 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 59140-59149 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 59150-59159 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 59160-59169 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59170-59179 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 59180-59189 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 59190-59199 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 59200-59209 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 59210-59219 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59220-59229 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 59230-59239 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 59240-59249 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59250-59259 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 59260-59269 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 59270-59279 + 1, 52, 51, 50, 49, 48, 47, 46, 45, 44, // 59280-59289 + 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 59290-59299 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 59300-59309 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 59310-59319 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59320-59329 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 59330-59339 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59340-59349 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 59350-59359 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 59360-59369 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 59370-59379 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 59380-59389 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 59390-59399 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 59400-59409 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 59410-59419 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 59420-59429 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59430-59439 + 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 59440-59449 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 59450-59459 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 59460-59469 + 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 59470-59479 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 59480-59489 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 59490-59499 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 59500-59509 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 59510-59519 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 59520-59529 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 59530-59539 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 59540-59549 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 59550-59559 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 59560-59569 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59570-59579 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 59580-59589 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 59590-59599 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59600-59609 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 59610-59619 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 59620-59629 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 59630-59639 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59640-59649 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 59650-59659 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 59660-59669 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 59670-59679 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59680-59689 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 59690-59699 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 59700-59709 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59710-59719 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 59720-59729 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59730-59739 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 59740-59749 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 59750-59759 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59760-59769 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 59770-59779 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59780-59789 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 59790-59799 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 59800-59809 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 59810-59819 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59820-59829 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 59830-59839 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 59840-59849 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59850-59859 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 59860-59869 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 59870-59879 + 7, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 59880-59889 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 59890-59899 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 59900-59909 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59910-59919 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 59920-59929 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 59930-59939 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59940-59949 + 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 59950-59959 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59960-59969 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59970-59979 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 59980-59989 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 59990-59999 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 60000-60009 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 60010-60019 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 60020-60029 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 60030-60039 + 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 60040-60049 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 60050-60059 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 60060-60069 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 60070-60079 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 60080-60089 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60090-60099 + 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 60100-60109 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 60110-60119 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 60120-60129 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 60130-60139 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 60140-60149 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60150-60159 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 40, // 60160-60169 + 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 60170-60179 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 60180-60189 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 60190-60199 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 60200-60209 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 60210-60219 + 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 60220-60229 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 60230-60239 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60240-60249 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 60250-60259 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60260-60269 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 60270-60279 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 60280-60289 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 60290-60299 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 60300-60309 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 60310-60319 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60320-60329 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 60330-60339 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 60340-60349 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 60350-60359 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 60360-60369 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 60370-60379 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 60380-60389 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 60390-60399 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 60400-60409 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 60410-60419 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 60420-60429 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 60430-60439 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 60440-60449 + 7, 6, 5, 4, 3, 2, 1, 36, 35, 34, // 60450-60459 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 60460-60469 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 60470-60479 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 60480-60489 + 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 60490-60499 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 60500-60509 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60510-60519 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 60520-60529 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 50, // 60530-60539 + 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, // 60540-60549 + 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 60550-60559 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 60560-60569 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 60570-60579 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 60580-60589 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60590-60599 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 60600-60609 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 60610-60619 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 60620-60629 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 60630-60639 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 60640-60649 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 60650-60659 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 60660-60669 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 60670-60679 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 60680-60689 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 60690-60699 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 60700-60709 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 60710-60719 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 60720-60729 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 60730-60739 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 60740-60749 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 60750-60759 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 60760-60769 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 60770-60779 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 60780-60789 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 60790-60799 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60800-60809 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60810-60819 + 1, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 60820-60829 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 60830-60839 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 60840-60849 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 60850-60859 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 60860-60869 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 60870-60879 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 60880-60889 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 60890-60899 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 60900-60909 + 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 60910-60919 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 60920-60929 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 60930-60939 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 60940-60949 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 60950-60959 + 1, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 60960-60969 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 60970-60979 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 60980-60989 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60990-60999 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 61000-61009 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 61010-61019 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 61020-61029 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61030-61039 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 61040-61049 + 1, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 61050-61059 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 61060-61069 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 61070-61079 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61080-61089 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 61090-61099 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 61100-61109 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61110-61119 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 61120-61129 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61130-61139 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61140-61149 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 61150-61159 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 42, // 61160-61169 + 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 61170-61179 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 61180-61189 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 61190-61199 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61200-61209 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61210-61219 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 61220-61229 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 61230-61239 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61240-61249 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 61250-61259 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 61260-61269 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61270-61279 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 61280-61289 + 1, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 61290-61299 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 61300-61309 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 61310-61319 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61320-61329 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 61330-61339 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 61340-61349 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 61350-61359 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 61360-61369 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 61370-61379 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 61380-61389 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61390-61399 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 61400-61409 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 61410-61419 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 61420-61429 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61430-61439 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 61440-61449 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61450-61459 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 61460-61469 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61470-61479 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 61480-61489 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 61490-61499 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 61500-61509 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 61510-61519 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 61520-61529 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61530-61539 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 61540-61549 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 61550-61559 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 61560-61569 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61570-61579 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 61580-61589 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61590-61599 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 61600-61609 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 61610-61619 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 61620-61629 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 61630-61639 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 61640-61649 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 61650-61659 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 61660-61669 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 61670-61679 + 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 61680-61689 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61690-61699 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 61700-61709 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 61710-61719 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 61720-61729 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 61730-61739 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61740-61749 + 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 61750-61759 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 61760-61769 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61770-61779 + 1, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 61780-61789 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 61790-61799 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61800-61809 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 61810-61819 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 61820-61829 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 61830-61839 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 61840-61849 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61850-61859 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61860-61869 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 61870-61879 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 61880-61889 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 61890-61899 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 61900-61909 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 61910-61919 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 61920-61929 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 61930-61939 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 61940-61949 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61950-61959 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 61960-61969 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 61970-61979 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 61980-61989 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61990-61999 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 62000-62009 + 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 62010-62019 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 62020-62029 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 62030-62039 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 62040-62049 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 62050-62059 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62060-62069 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62070-62079 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 62080-62089 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 62090-62099 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 62100-62109 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 62110-62119 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 62120-62129 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 62130-62139 + 1, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 62140-62149 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 62150-62159 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62160-62169 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 62170-62179 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 62180-62189 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62190-62199 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 62200-62209 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 62210-62219 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62220-62229 + 3, 2, 1, 40, 39, 38, 37, 36, 35, 34, // 62230-62239 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 62240-62249 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 62250-62259 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62260-62269 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 62270-62279 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 62280-62289 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 62290-62299 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 62300-62309 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62310-62319 + 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 62320-62329 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 62330-62339 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 62340-62349 + 1, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 62350-62359 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 62360-62369 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62370-62379 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 62380-62389 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62390-62399 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 62400-62409 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 62410-62419 + 3, 2, 1, 36, 35, 34, 33, 32, 31, 30, // 62420-62429 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 62430-62439 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 62440-62449 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 62450-62459 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 62460-62469 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 62470-62479 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 62480-62489 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 62490-62499 + 1, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 62500-62509 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 62510-62519 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62520-62529 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 62530-62539 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 62540-62549 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62550-62559 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 62560-62569 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62570-62579 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62580-62589 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 62590-62599 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 62600-62609 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 62610-62619 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 62620-62629 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 62630-62639 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62640-62649 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 24, // 62650-62659 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 62660-62669 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62670-62679 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 62680-62689 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62690-62699 + 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 62700-62709 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62710-62719 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 62720-62729 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62730-62739 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 62740-62749 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 62750-62759 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62760-62769 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 62770-62779 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62780-62789 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62790-62799 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 62800-62809 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 62810-62819 + 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 62820-62829 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 62830-62839 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62840-62849 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62850-62859 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 62860-62869 + 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 62870-62879 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 62880-62889 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 62890-62899 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 62900-62909 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62910-62919 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 62920-62929 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 62930-62939 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 62940-62949 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 62950-62959 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 62960-62969 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62970-62979 + 1, 2, 1, 4, 3, 2, 1, 2, 1, 40, // 62980-62989 + 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 62990-62999 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 63000-63009 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63010-63019 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 63020-63029 + 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 63030-63039 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63040-63049 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 63050-63059 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 63060-63069 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 63070-63079 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 63080-63089 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 63090-63099 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 63100-63109 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 63110-63119 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 63120-63129 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63130-63139 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 63140-63149 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 63150-63159 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63160-63169 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 63170-63179 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 63180-63189 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 63190-63199 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 63200-63209 + 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 63210-63219 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 63220-63229 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 63230-63239 + 1, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 63240-63249 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 63250-63259 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 63260-63269 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 63270-63279 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63280-63289 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 63290-63299 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 63300-63309 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 63310-63319 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 63320-63329 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 63330-63339 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 63340-63349 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 63350-63359 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 63360-63369 + 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 63370-63379 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 63380-63389 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 63390-63399 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 63400-63409 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 63410-63419 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63420-63429 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 63430-63439 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 63440-63449 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 63450-63459 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 63460-63469 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 63470-63479 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 63480-63489 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 63490-63499 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 63500-63509 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 63510-63519 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 63520-63529 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 63530-63539 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63540-63549 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 63550-63559 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 63560-63569 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 63570-63579 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 63580-63589 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 63590-63599 + 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 63600-63609 + 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 63610-63619 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 63620-63629 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 63630-63639 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 63640-63649 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 63650-63659 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 63660-63669 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63670-63679 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 63680-63689 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 63690-63699 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 63700-63709 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 63710-63719 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 63720-63729 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 63730-63739 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 63740-63749 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 63750-63759 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 63760-63769 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 63770-63779 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 63780-63789 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 63790-63799 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 63800-63809 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 63810-63819 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 63820-63829 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 63830-63839 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 63840-63849 + 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 63850-63859 + 3, 2, 1, 38, 37, 36, 35, 34, 33, 32, // 63860-63869 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 63870-63879 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 63880-63889 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 63890-63899 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 63900-63909 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 63910-63919 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 63920-63929 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63930-63939 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 28, // 63940-63949 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 63950-63959 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 63960-63969 + 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 63970-63979 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 63980-63989 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 63990-63999 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 64000-64009 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 64010-64019 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64020-64029 + 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 64030-64039 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 64040-64049 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64050-64059 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 64060-64069 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64070-64079 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64080-64089 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 64090-64099 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 64100-64109 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64110-64119 + 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 64120-64129 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 64130-64139 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64140-64149 + 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 64150-64159 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64160-64169 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 64170-64179 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 28, // 64180-64189 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 64190-64199 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 64200-64209 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 64210-64219 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 64220-64229 + 1, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 64230-64239 + 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 64240-64249 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 64250-64259 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64260-64269 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 64270-64279 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 64280-64289 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64290-64299 + 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 64300-64309 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 64310-64319 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 64320-64329 + 3, 2, 1, 40, 39, 38, 37, 36, 35, 34, // 64330-64339 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 64340-64349 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 64350-64359 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64360-64369 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 64370-64379 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 64380-64389 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 64390-64399 + 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 64400-64409 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 64410-64419 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64420-64429 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 64430-64439 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64440-64449 + 1, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 64450-64459 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 64460-64469 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64470-64479 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 64480-64489 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 64490-64499 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64500-64509 + 3, 2, 1, 40, 39, 38, 37, 36, 35, 34, // 64510-64519 + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 64520-64529 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 64530-64539 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64540-64549 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 64550-64559 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 64560-64569 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 64570-64579 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64580-64589 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64590-64599 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 64600-64609 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 64610-64619 + 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 64620-64629 + 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 64630-64639 + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 64640-64649 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64650-64659 + 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 64660-64669 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 64670-64679 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64680-64689 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 64690-64699 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 64700-64709 + 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 64710-64719 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 64720-64729 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 64730-64739 + 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 64740-64749 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64750-64759 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 64760-64769 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64770-64779 + 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 64780-64789 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 64790-64799 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64800-64809 + 1, 6, 5, 4, 3, 2, 1, 32, 31, 30, // 64810-64819 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 64820-64829 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 64830-64839 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 64840-64849 + 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 64850-64859 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64860-64869 + 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 64870-64879 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64880-64889 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64890-64899 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 64900-64909 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 64910-64919 + 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 64920-64929 + 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 64930-64939 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64940-64949 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 64950-64959 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 28, // 64960-64969 + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 64970-64979 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 64980-64989 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 64990-64999 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 65000-65009 + 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 65010-65019 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 65020-65029 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 65030-65039 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 65040-65049 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 65050-65059 + 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 65060-65069 + 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 65070-65079 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 65080-65089 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 65090-65099 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 65100-65109 + 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 65110-65119 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 65120-65129 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 65130-65139 + 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 65140-65149 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 65150-65159 + 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 65160-65169 + 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 65170-65179 + 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 65180-65189 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 65190-65199 + 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 65200-65209 + 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 65210-65219 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 65220-65229 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 65230-65239 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 65240-65249 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 65250-65259 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 65260-65269 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 65270-65279 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 65280-65289 + 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 65290-65299 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 65300-65309 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 65310-65319 + 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 65320-65329 + 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 65330-65339 + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 65340-65349 + 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 65350-65359 + 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 65360-65369 + 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 65370-65379 + 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 65380-65389 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 65390-65399 + 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 65400-65409 + 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 65410-65419 + 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 65420-65429 + 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 65430-65439 + 7, 6, 5, 4, 3, 2, 1, 2, 1, 30, // 65440-65449 + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 65450-65459 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 65460-65469 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 65470-65479 + 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 65480-65489 + 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 65490-65499 + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 65500-65509 + 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 65510-65519 + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 65520-65529 + 0, 0, 0, 0, 0, 0, + } + + lohi [256]struct{ lo, hi int } +) + +func init() { + for i, v := range liars { + blk := v >> 24 + x := &lohi[blk] + if x.lo == 0 || i < x.lo { + x.lo = i + } + if i > x.hi { + x.hi = i + } + } +} diff --git a/vendor/github.com/cznic/mathutil/test_deps.go b/vendor/github.com/cznic/mathutil/test_deps.go new file mode 100644 index 0000000000..40054dcad2 --- /dev/null +++ b/vendor/github.com/cznic/mathutil/test_deps.go @@ -0,0 +1,11 @@ +// Copyright (c) 2014 The mathutil 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 mathutil + +// Pull test dependencies too. +// Enables easy 'go test X' after 'go get X' +import ( +// nothing yet +) diff --git a/vendor/github.com/cznic/ql/LICENSE b/vendor/github.com/cznic/ql/LICENSE new file mode 100644 index 0000000000..0d10c02b92 --- /dev/null +++ b/vendor/github.com/cznic/ql/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2014 The ql 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 names of the authors nor the names of the +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. diff --git a/vendor/github.com/cznic/ql/blob.go b/vendor/github.com/cznic/ql/blob.go new file mode 100644 index 0000000000..2005b52c7e --- /dev/null +++ b/vendor/github.com/cznic/ql/blob.go @@ -0,0 +1,155 @@ +// Copyright 2014 The ql 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 ql + +import ( + "bytes" + "encoding/gob" + "math/big" + "sync" + "time" +) + +const shortBlob = 256 // bytes + +var ( + gobInitDuration = time.Duration(278) + gobInitInt = big.NewInt(42) + gobInitRat = big.NewRat(355, 113) + gobInitTime time.Time +) + +func init() { + var err error + if gobInitTime, err = time.ParseInLocation( + "Jan 2, 2006 at 3:04pm (MST)", + "Jul 9, 2012 at 5:02am (CEST)", + time.FixedZone("XYZ", 1234), + ); err != nil { + panic(err) + } + newGobCoder() +} + +type gobCoder struct { + buf bytes.Buffer + dec *gob.Decoder + enc *gob.Encoder + mu sync.Mutex +} + +func newGobCoder() (g *gobCoder) { + g = &gobCoder{} + g.enc = gob.NewEncoder(&g.buf) + if err := g.enc.Encode(gobInitInt); err != nil { + panic(err) + } + + if err := g.enc.Encode(gobInitRat); err != nil { + panic(err) + } + + if err := g.enc.Encode(gobInitTime); err != nil { + panic(err) + } + + if err := g.enc.Encode(gobInitDuration); err != nil { + panic(err) + } + + g.dec = gob.NewDecoder(&g.buf) + i := big.NewInt(0) + if err := g.dec.Decode(i); err != nil { + panic(err) + } + + r := big.NewRat(3, 5) + if err := g.dec.Decode(r); err != nil { + panic(err) + } + + t := time.Now() + if err := g.dec.Decode(&t); err != nil { + panic(err) + } + + var d time.Duration + if err := g.dec.Decode(&d); err != nil { + panic(err) + } + + return +} + +func isBlobType(v interface{}) (bool, Type) { + switch v.(type) { + case []byte: + return true, Blob + case *big.Int: + return true, BigInt + case *big.Rat: + return true, BigRat + case time.Time: + return true, Time + case time.Duration: + return true, Duration + default: + return false, -1 + } +} + +func (g *gobCoder) encode(v interface{}) (b []byte, err error) { + g.mu.Lock() + defer g.mu.Unlock() + + g.buf.Reset() + switch x := v.(type) { + case []byte: + return x, nil + case *big.Int: + err = g.enc.Encode(x) + case *big.Rat: + err = g.enc.Encode(x) + case time.Time: + err = g.enc.Encode(x) + case time.Duration: + err = g.enc.Encode(int64(x)) + default: + panic("internal error 002") + } + b = g.buf.Bytes() + return +} + +func (g *gobCoder) decode(b []byte, typ int) (v interface{}, err error) { + g.mu.Lock() + defer g.mu.Unlock() + + g.buf.Reset() + g.buf.Write(b) + switch typ { + case qBlob: + return b, nil + case qBigInt: + x := big.NewInt(0) + err = g.dec.Decode(&x) + v = x + case qBigRat: + x := big.NewRat(1, 1) + err = g.dec.Decode(&x) + v = x + case qTime: + var x time.Time + err = g.dec.Decode(&x) + v = x + case qDuration: + var x int64 + err = g.dec.Decode(&x) + v = time.Duration(x) + default: + panic("internal error 003") + } + return +} diff --git a/vendor/github.com/cznic/ql/btree.go b/vendor/github.com/cznic/ql/btree.go new file mode 100644 index 0000000000..2b588b70d8 --- /dev/null +++ b/vendor/github.com/cznic/ql/btree.go @@ -0,0 +1,725 @@ +// Copyright 2014 The ql 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 ql + +import ( + "io" +) + +const ( + kx = 128 //DONE benchmark tune this number if using custom key/value type(s). + kd = 64 //DONE benchmark tune this number if using custom key/value type(s). +) + +type ( + // cmp compares a and b. Return value is: + // + // < 0 if a < b + // 0 if a == b + // > 0 if a > b + // + cmp func(a, b []interface{}) int + + d struct { // data page + c int + d [2*kd + 1]de + n *d + p *d + } + + de struct { // d element + k []interface{} + v []interface{} + } + + enumerator struct { + err error + hit bool + i int + k []interface{} + q *d + t *tree + ver int64 + } + + // tree is a B+tree. + tree struct { + c int + cmp cmp + first *d + last *d + r interface{} + ver int64 + } + + xe struct { // x element + ch interface{} + sep *d + } + + x struct { // index page + c int + x [2*kx + 2]xe + } +) + +var ( // R/O zero values + zd d + zde de + zx x + zxe xe +) + +func clr(q interface{}) { + switch z := q.(type) { + case *x: + for i := 0; i <= z.c; i++ { // Ch0 Sep0 ... Chn-1 Sepn-1 Chn + clr(z.x[i].ch) + } + *z = zx // GC + case *d: + *z = zd // GC + } +} + +// -------------------------------------------------------------------------- x + +func newX(ch0 interface{}) *x { + r := &x{} + r.x[0].ch = ch0 + return r +} + +func (q *x) extract(i int) { + q.c-- + if i < q.c { + copy(q.x[i:], q.x[i+1:q.c+1]) + q.x[q.c].ch = q.x[q.c+1].ch + q.x[q.c].sep = nil // GC + q.x[q.c+1] = zxe // GC + } +} + +func (q *x) insert(i int, d *d, ch interface{}) *x { + c := q.c + if i < c { + q.x[c+1].ch = q.x[c].ch + copy(q.x[i+2:], q.x[i+1:c]) + q.x[i+1].sep = q.x[i].sep + } + c++ + q.c = c + q.x[i].sep = d + q.x[i+1].ch = ch + return q +} + +func (q *x) siblings(i int) (l, r *d) { + if i >= 0 { + if i > 0 { + l = q.x[i-1].ch.(*d) + } + if i < q.c { + r = q.x[i+1].ch.(*d) + } + } + return +} + +// -------------------------------------------------------------------------- d + +func (l *d) mvL(r *d, c int) { + copy(l.d[l.c:], r.d[:c]) + copy(r.d[:], r.d[c:r.c]) + l.c += c + r.c -= c +} + +func (l *d) mvR(r *d, c int) { + copy(r.d[c:], r.d[:r.c]) + copy(r.d[:c], l.d[l.c-c:]) + r.c += c + l.c -= c +} + +// ----------------------------------------------------------------------- tree + +// treeNew returns a newly created, empty tree. The compare function is used +// for key collation. +func treeNew(cmp cmp) *tree { + return &tree{cmp: cmp} +} + +// Clear removes all K/V pairs from the tree. +func (t *tree) Clear() { + if t.r == nil { + return + } + + clr(t.r) + t.c, t.first, t.last, t.r = 0, nil, nil, nil + t.ver++ +} + +func (t *tree) cat(p *x, q, r *d, pi int) { + t.ver++ + q.mvL(r, r.c) + if r.n != nil { + r.n.p = q + } else { + t.last = q + } + q.n = r.n + if p.c > 1 { + p.extract(pi) + p.x[pi].ch = q + } else { + t.r = q + } +} + +func (t *tree) catX(p, q, r *x, pi int) { + t.ver++ + q.x[q.c].sep = p.x[pi].sep + copy(q.x[q.c+1:], r.x[:r.c]) + q.c += r.c + 1 + q.x[q.c].ch = r.x[r.c].ch + if p.c > 1 { + p.c-- + pc := p.c + if pi < pc { + p.x[pi].sep = p.x[pi+1].sep + copy(p.x[pi+1:], p.x[pi+2:pc+1]) + p.x[pc].ch = p.x[pc+1].ch + p.x[pc].sep = nil // GC + p.x[pc+1].ch = nil // GC + } + return + } + + t.r = q +} + +//Delete removes the k's KV pair, if it exists, in which case Delete returns +//true. +func (t *tree) Delete(k []interface{}) (ok bool) { + pi := -1 + var p *x + q := t.r + if q == nil { + return + } + + for { + var i int + i, ok = t.find(q, k) + if ok { + switch z := q.(type) { + case *x: + dp := z.x[i].sep + switch { + case dp.c > kd: + t.extract(dp, 0) + default: + if z.c < kx && q != t.r { + t.underflowX(p, &z, pi, &i) + } + pi = i + 1 + p = z + q = z.x[pi].ch + ok = false + continue + } + case *d: + t.extract(z, i) + if z.c >= kd { + return + } + + if q != t.r { + t.underflow(p, z, pi) + } else if t.c == 0 { + t.Clear() + } + } + return + } + + switch z := q.(type) { + case *x: + if z.c < kx && q != t.r { + t.underflowX(p, &z, pi, &i) + } + pi = i + p = z + q = z.x[i].ch + case *d: + return + } + } +} + +func (t *tree) extract(q *d, i int) { // (r []interface{}) { + t.ver++ + //r = q.d[i].v // prepared for Extract + q.c-- + if i < q.c { + copy(q.d[i:], q.d[i+1:q.c+1]) + } + q.d[q.c] = zde // GC + t.c-- + return +} + +func (t *tree) find(q interface{}, k []interface{}) (i int, ok bool) { + var mk []interface{} + l := 0 + switch z := q.(type) { + case *x: + h := z.c - 1 + for l <= h { + m := (l + h) >> 1 + mk = z.x[m].sep.d[0].k + switch cmp := t.cmp(k, mk); { + case cmp > 0: + l = m + 1 + case cmp == 0: + return m, true + default: + h = m - 1 + } + } + case *d: + h := z.c - 1 + for l <= h { + m := (l + h) >> 1 + mk = z.d[m].k + switch cmp := t.cmp(k, mk); { + case cmp > 0: + l = m + 1 + case cmp == 0: + return m, true + default: + h = m - 1 + } + } + } + return l, false +} + +// First returns the first item of the tree in the key collating order, or +// (nil, nil) if the tree is empty. +func (t *tree) First() (k []interface{}, v []interface{}) { + if q := t.first; q != nil { + q := &q.d[0] + k, v = q.k, q.v + } + return +} + +// Get returns the value associated with k and true if it exists. Otherwise Get +// returns (nil, false). +func (t *tree) Get(k []interface{}) (v []interface{}, ok bool) { + q := t.r + if q == nil { + return + } + + for { + var i int + if i, ok = t.find(q, k); ok { + switch z := q.(type) { + case *x: + return z.x[i].sep.d[0].v, true + case *d: + return z.d[i].v, true + } + } + switch z := q.(type) { + case *x: + q = z.x[i].ch + default: + return + } + } +} + +func (t *tree) insert(q *d, i int, k []interface{}, v []interface{}) *d { + t.ver++ + c := q.c + if i < c { + copy(q.d[i+1:], q.d[i:c]) + } + c++ + q.c = c + q.d[i].k, q.d[i].v = k, v + t.c++ + return q +} + +// Last returns the last item of the tree in the key collating order, or (nil, +// nil) if the tree is empty. +func (t *tree) Last() (k []interface{}, v []interface{}) { + if q := t.last; q != nil { + q := &q.d[q.c-1] + k, v = q.k, q.v + } + return +} + +// Len returns the number of items in the tree. +func (t *tree) Len() int { + return t.c +} + +func (t *tree) overflow(p *x, q *d, pi, i int, k []interface{}, v []interface{}) { + t.ver++ + l, r := p.siblings(pi) + + if l != nil && l.c < 2*kd && i > 0 { + l.mvL(q, 1) + t.insert(q, i-1, k, v) + return + } + + if r != nil && r.c < 2*kd { + if i < 2*kd { + q.mvR(r, 1) + t.insert(q, i, k, v) + } else { + t.insert(r, 0, k, v) + } + return + } + + t.split(p, q, pi, i, k, v) +} + +// Seek returns an enumerator positioned on a an item such that k >= item's +// key. ok reports if k == item.key The enumerator's position is possibly +// after the last item in the tree. +func (t *tree) Seek(k []interface{}) (e *enumerator, ok bool) { + q := t.r + if q == nil { + e = &enumerator{nil, false, 0, k, nil, t, t.ver} + return + } + + for { + var i int + if i, ok = t.find(q, k); ok { + switch z := q.(type) { + case *x: + e = &enumerator{nil, ok, 0, k, z.x[i].sep, t, t.ver} + return + case *d: + e = &enumerator{nil, ok, i, k, z, t, t.ver} + return + } + } + switch z := q.(type) { + case *x: + q = z.x[i].ch + case *d: + e = &enumerator{nil, ok, i, k, z, t, t.ver} + return + } + } +} + +// SeekFirst returns an enumerator positioned on the first KV pair in the tree, +// if any. For an empty tree, err == io.EOF is returned and e will be nil. +func (t *tree) SeekFirst() (e *enumerator, err error) { + q := t.first + if q == nil { + return nil, io.EOF + } + + return &enumerator{nil, true, 0, q.d[0].k, q, t, t.ver}, nil +} + +// SeekLast returns an enumerator positioned on the last KV pair in the tree, +// if any. For an empty tree, err == io.EOF is returned and e will be nil. +func (t *tree) SeekLast() (e *enumerator, err error) { + q := t.last + if q == nil { + return nil, io.EOF + } + + return &enumerator{nil, true, q.c - 1, q.d[q.c-1].k, q, t, t.ver}, nil +} + +// Set sets the value associated with k. +func (t *tree) Set(k []interface{}, v []interface{}) { + pi := -1 + var p *x + q := t.r + if q != nil { + for { + i, ok := t.find(q, k) + if ok { + switch z := q.(type) { + case *x: + z.x[i].sep.d[0].v = v + case *d: + z.d[i].v = v + } + return + } + + switch z := q.(type) { + case *x: + if z.c > 2*kx { + t.splitX(p, &z, pi, &i) + } + pi = i + p = z + q = z.x[i].ch + case *d: + switch { + case z.c < 2*kd: + t.insert(z, i, k, v) + default: + t.overflow(p, z, pi, i, k, v) + } + return + } + } + } + + z := t.insert(&d{}, 0, k, v) + t.r, t.first, t.last = z, z, z + return +} + +func (t *tree) split(p *x, q *d, pi, i int, k []interface{}, v []interface{}) { + t.ver++ + r := &d{} + if q.n != nil { + r.n = q.n + r.n.p = r + } else { + t.last = r + } + q.n = r + r.p = q + + copy(r.d[:], q.d[kd:2*kd]) + for i := range q.d[kd:] { + q.d[kd+i] = zde + } + q.c = kd + r.c = kd + if pi >= 0 { + p.insert(pi, r, r) + } else { + t.r = newX(q).insert(0, r, r) + } + if i > kd { + t.insert(r, i-kd, k, v) + return + } + + t.insert(q, i, k, v) +} + +func (t *tree) splitX(p *x, pp **x, pi int, i *int) { + t.ver++ + q := *pp + r := &x{} + copy(r.x[:], q.x[kx+1:]) + q.c = kx + r.c = kx + if pi >= 0 { + p.insert(pi, q.x[kx].sep, r) + } else { + t.r = newX(q).insert(0, q.x[kx].sep, r) + } + q.x[kx].sep = nil + for i := range q.x[kx+1:] { + q.x[kx+i+1] = zxe + } + if *i > kx { + *pp = r + *i -= kx + 1 + } +} + +func (t *tree) underflow(p *x, q *d, pi int) { + t.ver++ + l, r := p.siblings(pi) + + if l != nil && l.c+q.c >= 2*kd { + l.mvR(q, 1) + } else if r != nil && q.c+r.c >= 2*kd { + q.mvL(r, 1) + r.d[r.c] = zde // GC + } else if l != nil { + t.cat(p, l, q, pi-1) + } else { + t.cat(p, q, r, pi) + } +} + +func (t *tree) underflowX(p *x, pp **x, pi int, i *int) { + t.ver++ + var l, r *x + q := *pp + + if pi >= 0 { + if pi > 0 { + l = p.x[pi-1].ch.(*x) + } + if pi < p.c { + r = p.x[pi+1].ch.(*x) + } + } + + if l != nil && l.c > kx { + q.x[q.c+1].ch = q.x[q.c].ch + copy(q.x[1:], q.x[:q.c]) + q.x[0].ch = l.x[l.c].ch + q.x[0].sep = p.x[pi-1].sep + q.c++ + *i++ + l.c-- + p.x[pi-1].sep = l.x[l.c].sep + return + } + + if r != nil && r.c > kx { + q.x[q.c].sep = p.x[pi].sep + q.c++ + q.x[q.c].ch = r.x[0].ch + p.x[pi].sep = r.x[0].sep + copy(r.x[:], r.x[1:r.c]) + r.c-- + rc := r.c + r.x[rc].ch = r.x[rc+1].ch + r.x[rc].sep = nil + r.x[rc+1].ch = nil + return + } + + if l != nil { + *i += l.c + 1 + t.catX(p, l, q, pi-1) + *pp = l + return + } + + t.catX(p, q, r, pi) +} + +// ----------------------------------------------------------------- enumerator + +// Next returns the currently enumerated item, if it exists and moves to the +// next item in the key collation order. If there is no item to return, err == +// io.EOF is returned. +func (e *enumerator) Next() (k []interface{}, v []interface{}, err error) { + if err = e.err; err != nil { + return + } + + if e.ver != e.t.ver { + f, hit := e.t.Seek(e.k) + if !e.hit && hit { + if err = f.next(); err != nil { + return + } + } + + *e = *f + } + if e.q == nil { + e.err, err = io.EOF, io.EOF + return + } + + if e.i >= e.q.c { + if err = e.next(); err != nil { + return + } + } + + i := e.q.d[e.i] + k, v = i.k, i.v + e.k, e.hit = k, false + e.next() + return +} + +func (e *enumerator) next() error { + if e.q == nil { + e.err = io.EOF + return io.EOF + } + + switch { + case e.i < e.q.c-1: + e.i++ + default: + if e.q, e.i = e.q.n, 0; e.q == nil { + e.err = io.EOF + } + } + return e.err +} + +// Prev returns the currently enumerated item, if it exists and moves to the +// previous item in the key collation order. If there is no item to return, err +// == io.EOF is returned. +func (e *enumerator) Prev() (k []interface{}, v []interface{}, err error) { + if err = e.err; err != nil { + return + } + + if e.ver != e.t.ver { + f, hit := e.t.Seek(e.k) + if !e.hit && hit { + if err = f.prev(); err != nil { + return + } + } + + *e = *f + } + if e.q == nil { + e.err, err = io.EOF, io.EOF + return + } + + if e.i >= e.q.c { + if err = e.next(); err != nil { + return + } + } + + i := e.q.d[e.i] + k, v = i.k, i.v + e.k, e.hit = k, false + e.prev() + return +} + +func (e *enumerator) prev() error { + if e.q == nil { + e.err = io.EOF + return io.EOF + } + + switch { + case e.i > 0: + e.i-- + default: + if e.q = e.q.p; e.q == nil { + e.err = io.EOF + break + } + + e.i = e.q.c - 1 + } + return e.err +} diff --git a/vendor/github.com/cznic/ql/builtin.go b/vendor/github.com/cznic/ql/builtin.go new file mode 100644 index 0000000000..1c4bc1c1af --- /dev/null +++ b/vendor/github.com/cznic/ql/builtin.go @@ -0,0 +1,991 @@ +// Copyright 2014 The ql 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 ql + +import ( + "fmt" + "math/rand" + "reflect" + "strconv" + "strings" + "time" +) + +//TODO agg bigint, bigrat, time, duration + +var builtin = map[string]struct { + f func([]interface{}, map[interface{}]interface{}) (interface{}, error) + minArgs int + maxArgs int + isStatic bool + isAggregate bool +}{ + "__testBlob": {builtinTestBlob, 1, 1, true, false}, + "__testString": {builtinTestString, 1, 1, true, false}, + "avg": {builtinAvg, 1, 1, false, true}, + "complex": {builtinComplex, 2, 2, true, false}, + "contains": {builtinContains, 2, 2, true, false}, + "count": {builtinCount, 0, 1, false, true}, + "date": {builtinDate, 8, 8, true, false}, + "day": {builtinDay, 1, 1, true, false}, + "formatTime": {builtinFormatTime, 2, 2, true, false}, + "formatFloat": {builtinFormatFloat, 1, 4, true, false}, + "formatInt": {builtinFormatInt, 1, 2, true, false}, + "hasPrefix": {builtinHasPrefix, 2, 2, true, false}, + "hasSuffix": {builtinHasSuffix, 2, 2, true, false}, + "hour": {builtinHour, 1, 1, true, false}, + "hours": {builtinHours, 1, 1, true, false}, + "id": {builtinID, 0, 1, false, false}, + "imag": {builtinImag, 1, 1, true, false}, + "len": {builtinLen, 1, 1, true, false}, + "max": {builtinMax, 1, 1, false, true}, + "min": {builtinMin, 1, 1, false, true}, + "minute": {builtinMinute, 1, 1, true, false}, + "minutes": {builtinMinutes, 1, 1, true, false}, + "month": {builtinMonth, 1, 1, true, false}, + "nanosecond": {builtinNanosecond, 1, 1, true, false}, + "nanoseconds": {builtinNanoseconds, 1, 1, true, false}, + "now": {builtinNow, 0, 0, false, false}, + "parseTime": {builtinParseTime, 2, 2, true, false}, + "real": {builtinReal, 1, 1, true, false}, + "second": {builtinSecond, 1, 1, true, false}, + "seconds": {builtinSeconds, 1, 1, true, false}, + "since": {builtinSince, 1, 1, false, false}, + "sum": {builtinSum, 1, 1, false, true}, + "timeIn": {builtinTimeIn, 2, 2, true, false}, + "weekday": {builtinWeekday, 1, 1, true, false}, + "year": {builtinYear, 1, 1, true, false}, + "yearDay": {builtinYearday, 1, 1, true, false}, +} + +func badNArgs(min int, s string, arg []interface{}) error { + a := []string{} + for _, v := range arg { + a = append(a, fmt.Sprintf("%v", v)) + } + switch len(arg) < min { + case true: + return fmt.Errorf("missing argument to %s(%s)", s, strings.Join(a, ", ")) + default: //case false: + return fmt.Errorf("too many arguments to %s(%s)", s, strings.Join(a, ", ")) + } +} + +func invArg(arg interface{}, s string) error { + return fmt.Errorf("invalid argument %v (type %T) for %s", arg, arg, s) +} + +func builtinTestBlob(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + n, err := intExpr(arg[0]) + if err != nil { + return nil, err + } + + rng := rand.New(rand.NewSource(n)) + b := make([]byte, n) + for i := range b { + b[i] = byte(rng.Int()) + } + return b, nil +} + +func builtinTestString(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + n, err := intExpr(arg[0]) + if err != nil { + return nil, err + } + + rng := rand.New(rand.NewSource(n)) + b := make([]byte, n) + for i := range b { + b[i] = byte(rng.Int()) + } + return string(b), nil +} + +func builtinAvg(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + type avg struct { + sum interface{} + n uint64 + } + + if _, ok := ctx["$agg0"]; ok { + return + } + + fn := ctx["$fn"] + if _, ok := ctx["$agg"]; ok { + data, ok := ctx[fn].(avg) + if !ok { + return + } + + switch x := data.sum.(type) { + case complex64: + return complex64(complex128(x) / complex(float64(data.n), 0)), nil + case complex128: + return complex64(complex128(x) / complex(float64(data.n), 0)), nil + case float32: + return float32(float64(x) / float64(data.n)), nil + case float64: + return float64(x) / float64(data.n), nil + case int8: + return int8(int64(x) / int64(data.n)), nil + case int16: + return int16(int64(x) / int64(data.n)), nil + case int32: + return int32(int64(x) / int64(data.n)), nil + case int64: + return int64(int64(x) / int64(data.n)), nil + case uint8: + return uint8(uint64(x) / data.n), nil + case uint16: + return uint16(uint64(x) / data.n), nil + case uint32: + return uint32(uint64(x) / data.n), nil + case uint64: + return uint64(uint64(x) / data.n), nil + } + + } + + data, _ := ctx[fn].(avg) + y := arg[0] + if y == nil { + return + } + + switch x := data.sum.(type) { + case nil: + switch y := y.(type) { + case float32, float64, int8, int16, int32, int64, uint8, uint16, uint32, uint64: + data = avg{y, 0} + default: + return nil, fmt.Errorf("avg: cannot accept %v (value if type %T)", y, y) + } + case complex64: + data.sum = x + y.(complex64) + case complex128: + data.sum = x + y.(complex128) + case float32: + data.sum = x + y.(float32) + case float64: + data.sum = x + y.(float64) + case int8: + data.sum = x + y.(int8) + case int16: + data.sum = x + y.(int16) + case int32: + data.sum = x + y.(int32) + case int64: + data.sum = x + y.(int64) + case uint8: + data.sum = x + y.(uint8) + case uint16: + data.sum = x + y.(uint16) + case uint32: + data.sum = x + y.(uint32) + case uint64: + data.sum = x + y.(uint64) + } + data.n++ + ctx[fn] = data + return +} + +func builtinComplex(arg []interface{}, _ map[interface{}]interface{}) (v interface{}, err error) { + re, im := arg[0], arg[1] + if re == nil || im == nil { + return nil, nil + } + + re, im = coerce(re, im) + if reflect.TypeOf(re) != reflect.TypeOf(im) { + return nil, fmt.Errorf("complex(%T(%#v), %T(%#v)): invalid types", re, re, im, im) + } + + switch re := re.(type) { + case idealFloat: + return idealComplex(complex(float64(re), float64(im.(idealFloat)))), nil + case idealInt: + return idealComplex(complex(float64(re), float64(im.(idealInt)))), nil + case idealRune: + return idealComplex(complex(float64(re), float64(im.(idealRune)))), nil + case idealUint: + return idealComplex(complex(float64(re), float64(im.(idealUint)))), nil + case float32: + return complex(float32(re), im.(float32)), nil + case float64: + return complex(float64(re), im.(float64)), nil + case int8: + return complex(float64(re), float64(im.(int8))), nil + case int16: + return complex(float64(re), float64(im.(int16))), nil + case int32: + return complex(float64(re), float64(im.(int32))), nil + case int64: + return complex(float64(re), float64(im.(int64))), nil + case uint8: + return complex(float64(re), float64(im.(uint8))), nil + case uint16: + return complex(float64(re), float64(im.(uint16))), nil + case uint32: + return complex(float64(re), float64(im.(uint32))), nil + case uint64: + return complex(float64(re), float64(im.(uint64))), nil + default: + return nil, invArg(re, "complex") + } +} + +func builtinContains(arg []interface{}, _ map[interface{}]interface{}) (v interface{}, err error) { + switch s := arg[0].(type) { + case nil: + return nil, nil + case string: + switch chars := arg[1].(type) { + case nil: + return nil, nil + case string: + return strings.Contains(s, chars), nil + default: + return nil, invArg(chars, "string") + } + default: + return nil, invArg(s, "string") + } +} + +func builtinCount(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + if _, ok := ctx["$agg0"]; ok { + return int64(0), nil + } + + fn := ctx["$fn"] + if _, ok := ctx["$agg"]; ok { + return ctx[fn].(int64), nil + } + + n, _ := ctx[fn].(int64) + switch len(arg) { + case 0: + n++ + case 1: + if arg[0] != nil { + n++ + } + default: + panic("internal error 067") + } + ctx[fn] = n + return +} + +func builtinDate(arg []interface{}, _ map[interface{}]interface{}) (v interface{}, err error) { + for i, v := range arg { + switch i { + case 7: + switch x := v.(type) { + case string: + default: + return nil, invArg(x, "date") + } + default: + switch x := v.(type) { + case int64: + case idealInt: + arg[i] = int64(x) + default: + return nil, invArg(x, "date") + } + } + } + + sloc := arg[7].(string) + loc := time.Local + switch sloc { + case "local": + default: + loc, err = time.LoadLocation(sloc) + if err != nil { + return + } + } + + return time.Date( + int(arg[0].(int64)), + time.Month(arg[1].(int64)), + int(arg[2].(int64)), + int(arg[3].(int64)), + int(arg[4].(int64)), + int(arg[5].(int64)), + int(arg[6].(int64)), + loc, + ), nil +} + +func builtinLen(arg []interface{}, _ map[interface{}]interface{}) (v interface{}, err error) { + switch x := arg[0].(type) { + case nil: + return nil, nil + case string: + return int64(len(x)), nil + default: + return nil, invArg(x, "len") + } +} + +func builtinDay(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + switch x := arg[0].(type) { + case nil: + return nil, nil + case time.Time: + return int64(x.Day()), nil + default: + return nil, invArg(x, "day") + } +} + +func builtinFormatTime(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + switch x := arg[0].(type) { + case nil: + return nil, nil + case time.Time: + switch y := arg[1].(type) { + case nil: + return nil, nil + case string: + return x.Format(y), nil + default: + return nil, invArg(y, "formatTime") + } + default: + return nil, invArg(x, "formatTime") + } +} + +func builtinFormatFloat(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + var val float64 + var fmt byte = 'g' + + prec := -1 + bitSize := 64 + + switch x := arg[0].(type) { + case nil: + return nil, nil + case float32: + val = float64(x) + bitSize = 32 + case float64: + val = x + default: + return nil, invArg(x, "formatFloat") + } + + switch len(arg) { + case 4: + arg3 := coerce1(arg[3], int64(0)) + switch y := arg3.(type) { + case nil: + return nil, nil + case int64: + bitSize = int(y) + default: + return nil, invArg(y, "formatFloat") + } + fallthrough + case 3: + arg2 := coerce1(arg[2], int64(0)) + switch y := arg2.(type) { + case nil: + return nil, nil + case int64: + prec = int(y) + default: + return nil, invArg(y, "formatFloat") + } + fallthrough + case 2: + arg1 := coerce1(arg[1], byte(0)) + switch y := arg1.(type) { + case nil: + return nil, nil + case byte: + fmt = y + default: + return nil, invArg(y, "formatFloat") + } + } + + return strconv.FormatFloat(val, fmt, prec, bitSize), nil +} + +func builtinFormatInt(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + var intVal int64 + var uintVal uint64 + + uintType := false + base := 10 + + switch x := arg[0].(type) { + case nil: + return nil, nil + case int8: + intVal = int64(x) + case int16: + intVal = int64(x) + case int32: + intVal = int64(x) + case int64: + intVal = x + case uint8: + uintType = true + uintVal = uint64(x) + case uint16: + uintType = true + uintVal = uint64(x) + case uint32: + uintType = true + uintVal = uint64(x) + case uint64: + uintType = true + uintVal = x + default: + return nil, invArg(x, "formatInt") + } + + switch len(arg) { + case 2: + arg1 := coerce1(arg[1], int64(0)) + switch y := arg1.(type) { + case nil: + return nil, nil + case int64: + base = int(y) + default: + return nil, invArg(y, "formatInt") + } + } + + if uintType { + return strconv.FormatUint(uintVal, base), nil + } + + return strconv.FormatInt(intVal, base), nil +} + +func builtinHasPrefix(arg []interface{}, _ map[interface{}]interface{}) (v interface{}, err error) { + switch s := arg[0].(type) { + case nil: + return nil, nil + case string: + switch prefix := arg[1].(type) { + case nil: + return nil, nil + case string: + return strings.HasPrefix(s, prefix), nil + default: + return nil, invArg(prefix, "string") + } + default: + return nil, invArg(s, "string") + } +} + +func builtinHasSuffix(arg []interface{}, _ map[interface{}]interface{}) (v interface{}, err error) { + switch s := arg[0].(type) { + case nil: + return nil, nil + case string: + switch suffix := arg[1].(type) { + case nil: + return nil, nil + case string: + return strings.HasSuffix(s, suffix), nil + default: + return nil, invArg(suffix, "string") + } + default: + return nil, invArg(s, "string") + } +} + +func builtinHour(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + switch x := arg[0].(type) { + case nil: + return nil, nil + case time.Time: + return int64(x.Hour()), nil + default: + return nil, invArg(x, "hour") + } +} + +func builtinHours(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + switch x := arg[0].(type) { + case nil: + return nil, nil + case time.Duration: + return x.Hours(), nil + default: + return nil, invArg(x, "hours") + } +} + +func builtinID(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + switch x := ctx["$id"].(type) { + case map[string]interface{}: + if len(arg) == 0 { + return nil, nil + } + + tab := arg[0].(*ident) + id, ok := x[tab.s] + if !ok { + return nil, fmt.Errorf("value not available: id(%s)", tab) + } + + if _, ok := id.(int64); ok { + return id, nil + } + + return nil, fmt.Errorf("value not available: id(%s)", tab) + case int64: + return x, nil + default: + return nil, nil + } +} + +func builtinImag(arg []interface{}, _ map[interface{}]interface{}) (v interface{}, err error) { + switch x := arg[0].(type) { + case nil: + return nil, nil + case idealComplex: + return imag(x), nil + case complex64: + return imag(x), nil + case complex128: + return imag(x), nil + default: + return nil, invArg(x, "imag") + } +} + +func builtinMax(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + if _, ok := ctx["$agg0"]; ok { + return + } + + fn := ctx["$fn"] + if _, ok := ctx["$agg"]; ok { + if v, ok = ctx[fn]; ok { + return + } + + return nil, nil + } + + max := ctx[fn] + y := arg[0] + if y == nil { + return + } + switch x := max.(type) { + case nil: + switch y := y.(type) { + case float32, float64, string, int8, int16, int32, int64, uint8, uint16, uint32, uint64, time.Time: + max = y + default: + return nil, fmt.Errorf("max: cannot accept %v (value if type %T)", y, y) + } + case float32: + if y := y.(float32); y > x { + max = y + } + case float64: + if y := y.(float64); y > x { + max = y + } + case string: + if y := y.(string); y > x { + max = y + } + case int8: + if y := y.(int8); y > x { + max = y + } + case int16: + if y := y.(int16); y > x { + max = y + } + case int32: + if y := y.(int32); y > x { + max = y + } + case int64: + if y := y.(int64); y > x { + max = y + } + case uint8: + if y := y.(uint8); y > x { + max = y + } + case uint16: + if y := y.(uint16); y > x { + max = y + } + case uint32: + if y := y.(uint32); y > x { + max = y + } + case uint64: + if y := y.(uint64); y > x { + max = y + } + case time.Time: + if y := y.(time.Time); y.After(x) { + max = y + } + } + ctx[fn] = max + return +} + +func builtinMin(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + if _, ok := ctx["$agg0"]; ok { + return + } + + fn := ctx["$fn"] + if _, ok := ctx["$agg"]; ok { + if v, ok = ctx[fn]; ok { + return + } + + return nil, nil + } + + min := ctx[fn] + y := arg[0] + if y == nil { + return + } + switch x := min.(type) { + case nil: + switch y := y.(type) { + case float32, float64, string, int8, int16, int32, int64, uint8, uint16, uint32, uint64, time.Time: + min = y + default: + return nil, fmt.Errorf("min: cannot accept %v (value if type %T)", y, y) + } + case float32: + if y := y.(float32); y < x { + min = y + } + case float64: + if y := y.(float64); y < x { + min = y + } + case string: + if y := y.(string); y < x { + min = y + } + case int8: + if y := y.(int8); y < x { + min = y + } + case int16: + if y := y.(int16); y < x { + min = y + } + case int32: + if y := y.(int32); y < x { + min = y + } + case int64: + if y := y.(int64); y < x { + min = y + } + case uint8: + if y := y.(uint8); y < x { + min = y + } + case uint16: + if y := y.(uint16); y < x { + min = y + } + case uint32: + if y := y.(uint32); y < x { + min = y + } + case uint64: + if y := y.(uint64); y < x { + min = y + } + case time.Time: + if y := y.(time.Time); y.Before(x) { + min = y + } + } + ctx[fn] = min + return +} + +func builtinMinute(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + switch x := arg[0].(type) { + case nil: + return nil, nil + case time.Time: + return int64(x.Minute()), nil + default: + return nil, invArg(x, "minute") + } +} + +func builtinMinutes(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + switch x := arg[0].(type) { + case nil: + return nil, nil + case time.Duration: + return x.Minutes(), nil + default: + return nil, invArg(x, "minutes") + } +} + +func builtinMonth(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + switch x := arg[0].(type) { + case nil: + return nil, nil + case time.Time: + return int64(x.Month()), nil + default: + return nil, invArg(x, "month") + } +} + +func builtinNanosecond(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + switch x := arg[0].(type) { + case nil: + return nil, nil + case time.Time: + return int64(x.Nanosecond()), nil + default: + return nil, invArg(x, "nanosecond") + } +} + +func builtinNanoseconds(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + switch x := arg[0].(type) { + case nil: + return nil, nil + case time.Duration: + return x.Nanoseconds(), nil + default: + return nil, invArg(x, "nanoseconds") + } +} + +func builtinNow(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + return time.Now(), nil +} + +func builtinParseTime(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + var a [2]string + for i, v := range arg { + switch x := v.(type) { + case nil: + return nil, nil + case string: + a[i] = x + default: + return nil, invArg(x, "parseTime") + } + } + + t, err := time.Parse(a[0], a[1]) + if err != nil { + return nil, err + } + + ls := t.Location().String() + if ls == "UTC" { + return t, nil + } + + l, err := time.LoadLocation(ls) + if err != nil { + return t, nil + } + + return time.ParseInLocation(a[0], a[1], l) +} + +func builtinReal(arg []interface{}, _ map[interface{}]interface{}) (v interface{}, err error) { + switch x := arg[0].(type) { + case nil: + return nil, nil + case idealComplex: + return real(x), nil + case complex64: + return real(x), nil + case complex128: + return real(x), nil + default: + return nil, invArg(x, "real") + } +} + +func builtinSecond(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + switch x := arg[0].(type) { + case nil: + return nil, nil + case time.Time: + return int64(x.Second()), nil + default: + return nil, invArg(x, "second") + } +} + +func builtinSeconds(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + switch x := arg[0].(type) { + case nil: + return nil, nil + case time.Duration: + return x.Seconds(), nil + default: + return nil, invArg(x, "seconds") + } +} + +func builtinSince(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + switch x := arg[0].(type) { + case nil: + return nil, nil + case time.Time: + return time.Since(x), nil + default: + return nil, invArg(x, "since") + } +} + +func builtinSum(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + if _, ok := ctx["$agg0"]; ok { + return + } + + fn := ctx["$fn"] + if _, ok := ctx["$agg"]; ok { + if v, ok = ctx[fn]; ok { + return + } + + return nil, nil + } + + sum := ctx[fn] + y := arg[0] + if y == nil { + return + } + switch x := sum.(type) { + case nil: + switch y := y.(type) { + case complex64, complex128, float32, float64, int8, int16, int32, int64, uint8, uint16, uint32, uint64: + sum = y + default: + return nil, fmt.Errorf("sum: cannot accept %v (value if type %T)", y, y) + } + case complex64: + sum = x + y.(complex64) + case complex128: + sum = x + y.(complex128) + case float32: + sum = x + y.(float32) + case float64: + sum = x + y.(float64) + case int8: + sum = x + y.(int8) + case int16: + sum = x + y.(int16) + case int32: + sum = x + y.(int32) + case int64: + sum = x + y.(int64) + case uint8: + sum = x + y.(uint8) + case uint16: + sum = x + y.(uint16) + case uint32: + sum = x + y.(uint32) + case uint64: + sum = x + y.(uint64) + } + ctx[fn] = sum + return +} + +func builtinTimeIn(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + switch x := arg[0].(type) { + case nil: + return nil, nil + case time.Time: + switch y := arg[1].(type) { + case nil: + return nil, nil + case string: + loc := time.Local + switch y { + case "local": + default: + loc, err = time.LoadLocation(y) + if err != nil { + return + } + } + + return x.In(loc), nil + default: + return nil, invArg(x, "timeIn") + } + default: + return nil, invArg(x, "timeIn") + } +} + +func builtinWeekday(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + switch x := arg[0].(type) { + case nil: + return nil, nil + case time.Time: + return int64(x.Weekday()), nil + default: + return nil, invArg(x, "weekday") + } +} + +func builtinYear(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + switch x := arg[0].(type) { + case nil: + return nil, nil + case time.Time: + return int64(x.Year()), nil + default: + return nil, invArg(x, "year") + } +} + +func builtinYearday(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { + switch x := arg[0].(type) { + case nil: + return nil, nil + case time.Time: + return int64(x.YearDay()), nil + default: + return nil, invArg(x, "yearDay") + } +} diff --git a/vendor/github.com/cznic/ql/coerce.go b/vendor/github.com/cznic/ql/coerce.go new file mode 100644 index 0000000000..bd384f93e6 --- /dev/null +++ b/vendor/github.com/cznic/ql/coerce.go @@ -0,0 +1,290 @@ +// Copyright 2013 The ql Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// CAUTION: This file was generated automatically by +// +// $ go run helper/helper.go -o coerce.go +// +// DO NOT EDIT! + +package ql + +import ( + "math" + "math/big" + "reflect" + "time" +) + +func coerce(a, b interface{}) (x, y interface{}) { + if reflect.TypeOf(a) == reflect.TypeOf(b) { + return a, b + } + + switch a.(type) { + case idealComplex, idealFloat, idealInt, idealRune, idealUint: + switch b.(type) { + case idealComplex, idealFloat, idealInt, idealRune, idealUint: + x, y = coerce1(a, b), b + if reflect.TypeOf(x) == reflect.TypeOf(y) { + return + } + + return a, coerce1(b, a) + default: + return coerce1(a, b), b + } + default: + switch b.(type) { + case idealComplex, idealFloat, idealInt, idealRune, idealUint: + return a, coerce1(b, a) + default: + return a, b + } + } +} + +func coerce1(inVal, otherVal interface{}) (coercedInVal interface{}) { + coercedInVal = inVal + if otherVal == nil { + return + } + + switch x := inVal.(type) { + case nil: + return + case idealComplex: + switch otherVal.(type) { + //case idealComplex: + //case idealFloat: + //case idealInt: + //case idealRune: + //case idealUint: + //case bool: + case complex64: + return complex64(x) + case complex128: + return complex128(x) + //case float32: + //case float64: + //case int8: + //case int16: + //case int32: + //case int64: + //case string: + //case uint8: + //case uint16: + //case uint32: + //case uint64: + //case *big.Int: + //case *big.Rat: + //case time.Time: + //case time.Duration: + } + case idealFloat: + switch otherVal.(type) { + case idealComplex: + return idealComplex(complex(float64(x), 0)) + case idealFloat: + return idealFloat(float64(x)) + //case idealInt: + //case idealRune: + //case idealUint: + //case bool: + case complex64: + return complex64(complex(float32(x), 0)) + case complex128: + return complex128(complex(float64(x), 0)) + case float32: + return float32(float64(x)) + case float64: + return float64(float64(x)) + //case int8: + //case int16: + //case int32: + //case int64: + //case string: + //case uint8: + //case uint16: + //case uint32: + //case uint64: + //case *big.Int: + case *big.Rat: + return big.NewRat(1, 1).SetFloat64(float64(x)) + //case time.Time: + //case time.Duration: + } + case idealInt: + switch otherVal.(type) { + case idealComplex: + return idealComplex(complex(float64(x), 0)) + case idealFloat: + return idealFloat(int64(x)) + case idealInt: + return idealInt(int64(x)) + //case idealRune: + case idealUint: + if x >= 0 { + return idealUint(int64(x)) + } + //case bool: + case complex64: + return complex64(complex(float32(x), 0)) + case complex128: + return complex128(complex(float64(x), 0)) + case float32: + return float32(int64(x)) + case float64: + return float64(int64(x)) + case int8: + if x >= math.MinInt8 && x <= math.MaxInt8 { + return int8(int64(x)) + } + case int16: + if x >= math.MinInt16 && x <= math.MaxInt16 { + return int16(int64(x)) + } + case int32: + if x >= math.MinInt32 && x <= math.MaxInt32 { + return int32(int64(x)) + } + case int64: + return int64(int64(x)) + //case string: + case uint8: + if x >= 0 && x <= math.MaxUint8 { + return uint8(int64(x)) + } + case uint16: + if x >= 0 && x <= math.MaxUint16 { + return uint16(int64(x)) + } + case uint32: + if x >= 0 && x <= math.MaxUint32 { + return uint32(int64(x)) + } + case uint64: + if x >= 0 { + return uint64(int64(x)) + } + case *big.Int: + return big.NewInt(int64(x)) + case *big.Rat: + return big.NewRat(1, 1).SetInt64(int64(x)) + //case time.Time: + case time.Duration: + return time.Duration(int64(x)) + } + case idealRune: + switch otherVal.(type) { + case idealComplex: + return idealComplex(complex(float64(x), 0)) + case idealFloat: + return idealFloat(int64(x)) + case idealInt: + return idealInt(int64(x)) + case idealRune: + return idealRune(int64(x)) + case idealUint: + return idealUint(int64(x)) + //case bool: + case complex64: + return complex64(complex(float32(x), 0)) + case complex128: + return complex128(complex(float64(x), 0)) + case float32: + return float32(int64(x)) + case float64: + return float64(int64(x)) + case int8: + return int8(int64(x)) + case int16: + return int16(int64(x)) + case int32: + return int32(int64(x)) + case int64: + return int64(int64(x)) + //case string: + case uint8: + return uint8(int64(x)) + case uint16: + return uint16(int64(x)) + case uint32: + return uint32(int64(x)) + case uint64: + return uint64(int64(x)) + case *big.Int: + return big.NewInt(int64(x)) + case *big.Rat: + return big.NewRat(1, 1).SetInt64(int64(x)) + //case time.Time: + case time.Duration: + return time.Duration(int64(x)) + } + case idealUint: + switch otherVal.(type) { + case idealComplex: + return idealComplex(complex(float64(x), 0)) + case idealFloat: + return idealFloat(uint64(x)) + case idealInt: + if x <= math.MaxInt64 { + return idealInt(int64(x)) + } + //case idealRune: + case idealUint: + return idealUint(uint64(x)) + //case bool: + case complex64: + return complex64(complex(float32(x), 0)) + case complex128: + return complex128(complex(float64(x), 0)) + case float32: + return float32(uint64(x)) + case float64: + return float64(uint64(x)) + case int8: + if x <= math.MaxInt8 { + return int8(int64(x)) + } + case int16: + if x <= math.MaxInt16 { + return int16(int64(x)) + } + case int32: + if x <= math.MaxInt32 { + return int32(int64(x)) + } + case int64: + if x <= math.MaxInt64 { + return int64(int64(x)) + } + //case string: + case uint8: + if x >= 0 && x <= math.MaxUint8 { + return uint8(int64(x)) + } + case uint16: + if x >= 0 && x <= math.MaxUint16 { + return uint16(int64(x)) + } + case uint32: + if x >= 0 && x <= math.MaxUint32 { + return uint32(int64(x)) + } + case uint64: + return uint64(uint64(x)) + case *big.Int: + return big.NewInt(0).SetUint64(uint64(x)) + case *big.Rat: + return big.NewRat(1, 1).SetInt(big.NewInt(0).SetUint64(uint64(x))) + //case time.Time: + case time.Duration: + if x <= math.MaxInt64 { + return time.Duration(int64(x)) + } + } + } + return +} diff --git a/vendor/github.com/cznic/ql/doc.go b/vendor/github.com/cznic/ql/doc.go new file mode 100644 index 0000000000..7a8baf10eb --- /dev/null +++ b/vendor/github.com/cznic/ql/doc.go @@ -0,0 +1,2606 @@ +// Copyright 2014 The ql Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//MAYBE set operations +//MAYBE +=, -=, ... + +//TODO verify there's a graceful failure for a 2G+ blob on a 32 bit machine. + +// Package ql implements a pure Go embedded SQL database engine. +// +// QL is a member of the SQL family of languages. It is less complex and less +// powerful than SQL (whichever specification SQL is considered to be). +// +// Change list +// +// 2015-06-15: To improve compatibility with other SQL implementations, the +// count built-in aggregate function now accepts * as its argument. +// +// 2015-05-29: The execution planner was rewritten from scratch. It should use +// indices in all places where they were used before plus in some additional +// situations. It is possible to investigate the plan using the newly added +// EXPLAIN statement. The QL tool is handy for such analysis. If the planner +// would have used an index, but no such exists, the plan includes hints in +// form of copy/paste ready CREATE INDEX statements. +// +// The planner is still quite simple and a lot of work on it is yet ahead. You +// can help this process by filling an issue with a schema and query which +// fails to use an index or indices when it should, in your opinion. Bonus +// points for including output of `ql 'explain '`. +// +// 2015-05-09: The grammar of the CREATE INDEX statement now accepts an +// expression list instead of a single expression, which was further limited to +// just a column name or the built-in id(). As a side effect, composite +// indices are now functional. However, the values in the expression-list style +// index are not yet used by other statements or the statement/query planner. +// The composite index is useful while having UNIQUE clause to check for +// semantically duplicate rows before they get added to the table or when such +// a row is mutated using the UPDATE statement and the expression-list style +// index tuple of the row is thus recomputed. +// +// 2015-05-02: The Schema field of table __Table now correctly reflects any +// column constraints and/or defaults. Also, the (*DB).Info method now has that +// information provided in new ColumInfo fields NotNull, Constraint and +// Default. +// +// 2015-04-20: Added support for {LEFT,RIGHT,FULL} [OUTER] JOIN. +// +// 2015-04-18: Column definitions can now have constraints and defaults. +// Details are discussed in the "Constraints and defaults" chapter below the +// CREATE TABLE statement documentation. +// +// 2015-03-06: New built-in functions formatFloat and formatInt. Thanks +// urandom! (https://github.com/urandom) +// +// 2015-02-16: IN predicate now accepts a SELECT statement. See the updated +// "Predicates" section. +// +// 2015-01-17: Logical operators || and && have now alternative spellings: OR +// and AND (case insensitive). AND was a keyword before, but OR is a new one. +// This can possibly break existing queries. For the record, it's a good idea +// to not use any name appearing in, for example, [7] in your queries as the +// list of QL's keywords may expand for gaining better compatibility with +// existing SQL "standards". +// +// 2015-01-12: ACID guarantees were tightened at the cost of performance in +// some cases. The write collecting window mechanism, a formerly used +// implementation detail, was removed. Inserting rows one by one in a +// transaction is now slow. I mean very slow. Try to avoid inserting single +// rows in a transaction. Instead, whenever possible, perform batch updates of +// tens to, say thousands of rows in a single transaction. See also: +// http://www.sqlite.org/faq.html#q19, the discussed synchronization principles +// involved are the same as for QL, modulo minor details. +// +// Note: A side effect is that closing a DB before exiting an application, both +// for the Go API and through database/sql driver, is no more required, +// strictly speaking. Beware that exiting an application while there is an open +// (uncommitted) transaction in progress means losing the transaction data. +// However, the DB will not become corrupted because of not closing it. Nor +// that was the case before, but formerly failing to close a DB could have +// resulted in losing the data of the last transaction. +// +// 2014-09-21: id() now optionally accepts a single argument - a table name. +// +// 2014-09-01: Added the DB.Flush() method and the LIKE pattern matching +// predicate. +// +// 2014-08-08: The built in functions max and min now accept also time values. +// Thanks opennota! (https://github.com/opennota) +// +// 2014-06-05: RecordSet interface extended by new methods FirstRow and Rows. +// +// 2014-06-02: Indices on id() are now used by SELECT statements. +// +// 2014-05-07: Introduction of Marshal, Schema, Unmarshal. +// +// 2014-04-15: +// +// Added optional IF NOT EXISTS clause to CREATE INDEX and optional IF EXISTS +// clause to DROP INDEX. +// +// 2014-04-12: +// +// The column Unique in the virtual table __Index was renamed to IsUnique +// because the old name is a keyword. Unfortunately, this is a breaking change, +// sorry. +// +// 2014-04-11: Introduction of LIMIT, OFFSET. +// +// 2014-04-10: Introduction of query rewriting. +// +// 2014-04-07: Introduction of indices. +// +// Building non CGO QL +// +// QL imports zappy[8], a block-based compressor, which speeds up its +// performance by using a C version of the compression/decompression +// algorithms. If a CGO-free (pure Go) version of QL, or an app using QL, is +// required, please include 'purego' in the -tags option of go +// {build,get,install}. For example: +// +// $ go get -tags purego github.com/cznic/ql +// +// If zappy was installed before installing QL, it might be necessary to +// rebuild zappy first (or rebuild QL with all its dependencies using the -a +// option): +// +// $ touch "$GOPATH"/src/github.com/cznic/zappy/*.go +// $ go install -tags purego github.com/cznic/zappy +// $ go install github.com/cznic/ql +// +// Notation +// +// The syntax is specified using Extended Backus-Naur Form (EBNF) +// +// Production = production_name "=" [ Expression ] "." . +// Expression = Alternative { "|" Alternative } . +// Alternative = Term { Term } . +// Term = production_name | token [ "…" token ] | Group | Option | Repetition . +// Group = "(" Expression ")" . +// Option = "[" Expression "]" . +// Repetition = "{" Expression "}" . +// Productions are expressions constructed from terms and the following operators, in increasing precedence +// +// | alternation +// () grouping +// [] option (0 or 1 times) +// {} repetition (0 to n times) +// +// Lower-case production names are used to identify lexical tokens. +// Non-terminals are in CamelCase. Lexical tokens are enclosed in double quotes +// "" or back quotes ``. +// +// The form a … b represents the set of characters from a through b as +// alternatives. The horizontal ellipsis … is also used elsewhere in the spec +// to informally denote various enumerations or code snippets that are not +// further specified. +// +// QL source code representation +// +// QL source code is Unicode text encoded in UTF-8. The text is not +// canonicalized, so a single accented code point is distinct from the same +// character constructed from combining an accent and a letter; those are +// treated as two code points. For simplicity, this document will use the +// unqualified term character to refer to a Unicode code point in the source +// text. +// +// Each code point is distinct; for instance, upper and lower case letters are +// different characters. +// +// Implementation restriction: For compatibility with other tools, the parser +// may disallow the NUL character (U+0000) in the statement. +// +// Implementation restriction: A byte order mark is disallowed anywhere in QL +// statements. +// +// Characters +// +// The following terms are used to denote specific character classes +// +// newline = . // the Unicode code point U+000A +// unicode_char = . // an arbitrary Unicode code point except newline +// ascii_letter = "a" … "z" | "A" … "Z" . +// +// Letters and digits +// +// The underscore character _ (U+005F) is considered a letter. +// +// letter = ascii_letter | "_" . +// decimal_digit = "0" … "9" . +// octal_digit = "0" … "7" . +// hex_digit = "0" … "9" | "A" … "F" | "a" … "f" . +// +// Lexical elements +// +// Lexical elements are comments, tokens, identifiers, keywords, operators and +// delimiters, integer, floating-point, imaginary, rune and string literals and +// QL parameters. +// +// Comments +// +// There are three forms of comments +// +// Line comments start with the character sequence // or -- and stop at the end +// of the line. A line comment acts like a space. +// +// General comments start with the character sequence /* and continue through +// the character sequence */. A general comment acts like a space. +// +// Comments do not nest. +// +// Tokens +// +// Tokens form the vocabulary of QL. There are four classes: identifiers, +// keywords, operators and delimiters, and literals. White space, formed from +// spaces (U+0020), horizontal tabs (U+0009), carriage returns (U+000D), and +// newlines (U+000A), is ignored except as it separates tokens that would +// otherwise combine into a single token. +// +// Semicolons +// +// The formal grammar uses semicolons ";" as separators of QL statements. A +// single QL statement or the last QL statement in a list of statements can +// have an optional semicolon terminator. (Actually a separator from the +// following empty statement.) +// +// Identifiers +// +// Identifiers name entities such as tables or record set columns. An +// identifier is a sequence of one or more letters and digits. The first +// character in an identifier must be a letter. +// +// identifier = letter { letter | decimal_digit } . +// +// For example +// +// price +// _tmp42 +// Sales +// +// No identifiers are predeclared, however note that no keyword can be used as +// an identifier. Identifiers starting with two underscores are used for meta +// data virtual tables names. For forward compatibility, users should generally +// avoid using any identifiers starting with two underscores. For example +// +// __Column +// __Column2 +// __Index +// __Table +// +// Keywords +// +// The following keywords are reserved and may not be used as identifiers. +// +// ADD COLUMN false int32 ORDER uint16 +// ALTER complex128 float int64 OUTER uint32 +// AND complex64 float32 int8 RIGHT uint64 +// AS CREATE float64 INTO SELECT uint8 +// ASC DEFAULT FROM JOIN SET UNIQUE +// BETWEEN DELETE GROUP LEFT string UPDATE +// bigint DESC IF LIMIT TABLE VALUES +// bigrat DISTINCT IN LIKE time WHERE +// blob DROP INDEX NOT true +// bool duration INSERT NULL OR +// BY EXISTS int OFFSET TRUNCATE +// byte EXPLAIN int16 ON uint +// +// Keywords are not case sensitive. +// +// Operators and Delimiters +// +// The following character sequences represent operators, delimiters, and other +// special tokens +// +// + & && == != ( ) +// - | || < <= [ ] +// * ^ > >= , ; +// / << = . +// % >> ! +// &^ +// +// Operators consisting of more than one character are referred to by names in +// the rest of the documentation +// +// andand = "&&" . +// andnot = "&^" . +// lsh = "<<" . +// le = "<=" . +// eq = "==" . +// ge = ">=" . +// neq = "!=" . +// oror = "||" . +// rsh = ">>" . +// +// Integer literals +// +// An integer literal is a sequence of digits representing an integer constant. +// An optional prefix sets a non-decimal base: 0 for octal, 0x or 0X for +// hexadecimal. In hexadecimal literals, letters a-f and A-F represent values +// 10 through 15. +// +// int_lit = decimal_lit | octal_lit | hex_lit . +// decimal_lit = ( "1" … "9" ) { decimal_digit } . +// octal_lit = "0" { octal_digit } . +// hex_lit = "0" ( "x" | "X" ) hex_digit { hex_digit } . +// +// For example +// +// 42 +// 0600 +// 0xBadFace +// 1701411834604692 +// +// Floating-point literals +// +// A floating-point literal is a decimal representation of a floating-point +// constant. It has an integer part, a decimal point, a fractional part, and an +// exponent part. The integer and fractional part comprise decimal digits; the +// exponent part is an e or E followed by an optionally signed decimal +// exponent. One of the integer part or the fractional part may be elided; one +// of the decimal point or the exponent may be elided. +// +// float_lit = decimals "." [ decimals ] [ exponent ] | +// decimals exponent | +// "." decimals [ exponent ] . +// decimals = decimal_digit { decimal_digit } . +// exponent = ( "e" | "E" ) [ "+" | "-" ] decimals . +// +// For example +// +// 0. +// 72.40 +// 072.40 // == 72.40 +// 2.71828 +// 1.e+0 +// 6.67428e-11 +// 1E6 +// .25 +// .12345E+5 +// +// Imaginary literals +// +// An imaginary literal is a decimal representation of the imaginary part of a +// complex constant. It consists of a floating-point literal or decimal integer +// followed by the lower-case letter i. +// +// imaginary_lit = (decimals | float_lit) "i" . +// +// For example +// +// 0i +// 011i // == 11i +// 0.i +// 2.71828i +// 1.e+0i +// 6.67428e-11i +// 1E6i +// .25i +// .12345E+5i +// +// Rune literals +// +// A rune literal represents a rune constant, an integer value identifying a +// Unicode code point. A rune literal is expressed as one or more characters +// enclosed in single quotes. Within the quotes, any character may appear +// except single quote and newline. A single quoted character represents the +// Unicode value of the character itself, while multi-character sequences +// beginning with a backslash encode values in various formats. +// +// The simplest form represents the single character within the quotes; since +// QL statements are Unicode characters encoded in UTF-8, multiple +// UTF-8-encoded bytes may represent a single integer value. For instance, the +// literal 'a' holds a single byte representing a literal a, Unicode U+0061, +// value 0x61, while 'ä' holds two bytes (0xc3 0xa4) representing a literal +// a-dieresis, U+00E4, value 0xe4. +// +// Several backslash escapes allow arbitrary values to be encoded as ASCII +// text. There are four ways to represent the integer value as a numeric +// constant: \x followed by exactly two hexadecimal digits; \u followed by +// exactly four hexadecimal digits; \U followed by exactly eight hexadecimal +// digits, and a plain backslash \ followed by exactly three octal digits. In +// each case the value of the literal is the value represented by the digits in +// the corresponding base. +// +// Although these representations all result in an integer, they have different +// valid ranges. Octal escapes must represent a value between 0 and 255 +// inclusive. Hexadecimal escapes satisfy this condition by construction. The +// escapes \u and \U represent Unicode code points so within them some values +// are illegal, in particular those above 0x10FFFF and surrogate halves. +// +// After a backslash, certain single-character escapes represent special +// values +// +// \a U+0007 alert or bell +// \b U+0008 backspace +// \f U+000C form feed +// \n U+000A line feed or newline +// \r U+000D carriage return +// \t U+0009 horizontal tab +// \v U+000b vertical tab +// \\ U+005c backslash +// \' U+0027 single quote (valid escape only within rune literals) +// \" U+0022 double quote (valid escape only within string literals) +// +// All other sequences starting with a backslash are illegal inside rune +// literals. +// +// rune_lit = "'" ( unicode_value | byte_value ) "'" . +// unicode_value = unicode_char | little_u_value | big_u_value | escaped_char . +// byte_value = octal_byte_value | hex_byte_value . +// octal_byte_value = `\` octal_digit octal_digit octal_digit . +// hex_byte_value = `\` "x" hex_digit hex_digit . +// little_u_value = `\` "u" hex_digit hex_digit hex_digit hex_digit . +// big_u_value = `\` "U" hex_digit hex_digit hex_digit hex_digit +// hex_digit hex_digit hex_digit hex_digit . +// escaped_char = `\` ( "a" | "b" | "f" | "n" | "r" | "t" | "v" | `\` | "'" | `"` ) . +// +// For example +// +// 'a' +// 'ä' +// '本' +// '\t' +// '\000' +// '\007' +// '\377' +// '\x07' +// '\xff' +// '\u12e4' +// '\U00101234' +// 'aa' // illegal: too many characters +// '\xa' // illegal: too few hexadecimal digits +// '\0' // illegal: too few octal digits +// '\uDFFF' // illegal: surrogate half +// '\U00110000' // illegal: invalid Unicode code point +// +// String literals +// +// A string literal represents a string constant obtained from concatenating a +// sequence of characters. There are two forms: raw string literals and +// interpreted string literals. +// +// Raw string literals are character sequences between back quotes ``. Within +// the quotes, any character is legal except back quote. The value of a raw +// string literal is the string composed of the uninterpreted (implicitly +// UTF-8-encoded) characters between the quotes; in particular, backslashes +// have no special meaning and the string may contain newlines. Carriage +// returns inside raw string literals are discarded from the raw string value. +// +// Interpreted string literals are character sequences between double quotes +// "". The text between the quotes, which may not contain newlines, forms the +// value of the literal, with backslash escapes interpreted as they are in rune +// literals (except that \' is illegal and \" is legal), with the same +// restrictions. The three-digit octal (\nnn) and two-digit hexadecimal (\xnn) +// escapes represent individual bytes of the resulting string; all other +// escapes represent the (possibly multi-byte) UTF-8 encoding of individual +// characters. Thus inside a string literal \377 and \xFF represent a single +// byte of value 0xFF=255, while ÿ, \u00FF, \U000000FF and \xc3\xbf represent +// the two bytes 0xc3 0xbf of the UTF-8 encoding of character U+00FF. +// +// string_lit = raw_string_lit | interpreted_string_lit . +// raw_string_lit = "`" { unicode_char | newline } "`" . +// interpreted_string_lit = `"` { unicode_value | byte_value } `"` . +// +// For example +// +// `abc` // same as "abc" +// `\n +// \n` // same as "\\n\n\\n" +// "\n" +// "" +// "Hello, world!\n" +// "日本語" +// "\u65e5本\U00008a9e" +// "\xff\u00FF" +// "\uD800" // illegal: surrogate half +// "\U00110000" // illegal: invalid Unicode code point +// +// These examples all represent the same string +// +// "日本語" // UTF-8 input text +// `日本語` // UTF-8 input text as a raw literal +// "\u65e5\u672c\u8a9e" // the explicit Unicode code points +// "\U000065e5\U0000672c\U00008a9e" // the explicit Unicode code points +// "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e" // the explicit UTF-8 bytes +// +// If the statement source represents a character as two code points, such as a +// combining form involving an accent and a letter, the result will be an error +// if placed in a rune literal (it is not a single code point), and will appear +// as two code points if placed in a string literal. +// +// QL parameters +// +// Literals are assigned their values from the respective text representation +// at "compile" (parse) time. QL parameters provide the same functionality as +// literals, but their value is assigned at execution time from an expression +// list passed to DB.Run or DB.Execute. Using '?' or '$' is completely +// equivalent. +// +// ql_parameter = ( "?" | "$" ) "1" … "9" { "0" … "9" } . +// +// For example +// +// SELECT DepartmentID +// FROM department +// WHERE DepartmentID == ?1 +// ORDER BY DepartmentName; +// +// SELECT employee.LastName +// FROM department, employee +// WHERE department.DepartmentID == $1 && employee.LastName > $2 +// ORDER BY DepartmentID; +// +// Constants +// +// Keywords 'false' and 'true' (not case sensitive) represent the two possible +// constant values of type bool (also not case sensitive). +// +// Keyword 'NULL' (not case sensitive) represents an untyped constant which is +// assignable to any type. NULL is distinct from any other value of any type. +// +// Types +// +// A type determines the set of values and operations specific to values of +// that type. A type is specified by a type name. +// +// Type = "bigint" // http://golang.org/pkg/math/big/#Int +// | "bigrat" // http://golang.org/pkg/math/big/#Rat +// | "blob" // []byte +// | "bool" +// | "byte" // alias for uint8 +// | "complex128" +// | "complex64" +// | "duration" // http://golang.org/pkg/time/#Duration +// | "float" // alias for float64 +// | "float32" +// | "float64" +// | "int" // alias for int64 +// | "int16" +// | "int32" +// | "int64" +// | "int8" +// | "rune" // alias for int32 +// | "string" +// | "time" // http://golang.org/pkg/time/#Time +// | "uint" // alias for uint64 +// | "uint16" +// | "uint32" +// | "uint64" +// | "uint8" . +// +// Named instances of the boolean, numeric, and string types are keywords. The +// names are not case sensitive. +// +// Note: The blob type is exchanged between the back end and the API as []byte. +// On 32 bit platforms this limits the size which the implementation can handle +// to 2G. +// +// Boolean types +// +// A boolean type represents the set of Boolean truth values denoted by the +// predeclared constants true and false. The predeclared boolean type is bool. +// +// Duration type +// +// A duration type represents the elapsed time between two instants as an int64 +// nanosecond count. The representation limits the largest representable +// duration to approximately 290 years. +// +// Numeric types +// +// A numeric type represents sets of integer or floating-point values. The +// predeclared architecture-independent numeric types are +// +// uint8 the set of all unsigned 8-bit integers (0 to 255) +// uint16 the set of all unsigned 16-bit integers (0 to 65535) +// uint32 the set of all unsigned 32-bit integers (0 to 4294967295) +// uint64 the set of all unsigned 64-bit integers (0 to 18446744073709551615) +// +// int8 the set of all signed 8-bit integers (-128 to 127) +// int16 the set of all signed 16-bit integers (-32768 to 32767) +// int32 the set of all signed 32-bit integers (-2147483648 to 2147483647) +// int64 the set of all signed 64-bit integers (-9223372036854775808 to 9223372036854775807) +// duration the set of all signed 64-bit integers (-9223372036854775808 to 9223372036854775807) +// bigint the set of all integers +// +// bigrat the set of all rational numbers +// +// float32 the set of all IEEE-754 32-bit floating-point numbers +// float64 the set of all IEEE-754 64-bit floating-point numbers +// +// complex64 the set of all complex numbers with float32 real and imaginary parts +// complex128 the set of all complex numbers with float64 real and imaginary parts +// +// byte alias for uint8 +// float alias for float64 +// int alias for int64 +// rune alias for int32 +// uint alias for uint64 +// +// The value of an n-bit integer is n bits wide and represented using two's +// complement arithmetic. +// +// Conversions are required when different numeric types are mixed in an +// expression or assignment. +// +// String types +// +// A string type represents the set of string values. A string value is a +// (possibly empty) sequence of bytes. The case insensitive keyword for the +// string type is 'string'. +// +// The length of a string (its size in bytes) can be discovered using the +// built-in function len. +// +// Time types +// +// A time type represents an instant in time with nanosecond precision. Each +// time has associated with it a location, consulted when computing the +// presentation form of the time. +// +// Predeclared functions +// +// The following functions are implicitly declared +// +// avg complex contains count date +// day formatTime formatFloat formatInt +// hasPrefix hasSuffix hour hours id +// imag len max min minute +// minutes month nanosecond nanoseconds now +// parseTime real second seconds since +// sum timeIn weekday year yearDay +// +// Expressions +// +// An expression specifies the computation of a value by applying operators and +// functions to operands. +// +// Operands +// +// Operands denote the elementary values in an expression. An operand may be a +// literal, a (possibly qualified) identifier denoting a constant or a function +// or a table/record set column, or a parenthesized expression. +// +// Operand = Literal | QualifiedIdent | "(" Expression ")" . +// Literal = "FALSE" | "NULL" | "TRUE" +// | float_lit | imaginary_lit | int_lit | rune_lit | string_lit +// | ql_parameter . +// +// Qualified identifiers +// +// A qualified identifier is an identifier qualified with a table/record set +// name prefix. +// +// QualifiedIdent = identifier [ "." identifier ] . +// +// For example +// +// invoice.Num // might denote column 'Num' from table 'invoice' +// +// Primary expressions +// +// Primary expression are the operands for unary and binary expressions. +// +// PrimaryExpression = Operand +// | Conversion +// | PrimaryExpression Index +// | PrimaryExpression Slice +// | PrimaryExpression Call . +// +// Call = "(" [ "*" | ExpressionList ] ")" . // * only in count(*). +// Index = "[" Expression "]" . +// Slice = "[" [ Expression ] ":" [ Expression ] "]" . +// +// For example +// +// x +// 2 +// (s + ".txt") +// f(3.1415, true) +// s[i : j + 1] +// +// Index expressions +// +// A primary expression of the form +// +// s[x] +// +// denotes the element of a string indexed by x. Its type is byte. The value x +// is called the index. The following rules apply +// +// - The index x must be of integer type except bigint or duration; it is in +// range if 0 <= x < len(s), otherwise it is out of range. +// +// - A constant index must be non-negative and representable by a value of type +// int. +// +// - A constant index must be in range if the string a is a literal. +// +// - If x is out of range at run time, a run-time error occurs. +// +// - s[x] is the byte at index x and the type of s[x] is byte. +// +// If s is NULL or x is NULL then the result is NULL. +// +// Otherwise s[x] is illegal. +// +// Slices +// +// For a string, the primary expression +// +// s[low : high] +// +// constructs a substring. The indices low and high select which elements +// appear in the result. The result has indices starting at 0 and length equal +// to high - low. +// +// For convenience, any of the indices may be omitted. A missing low index +// defaults to zero; a missing high index defaults to the length of the sliced +// operand +// +// s[2:] // same s[2 : len(s)] +// s[:3] // same as s[0 : 3] +// s[:] // same as s[0 : len(s)] +// +// The indices low and high are in range if 0 <= low <= high <= len(a), +// otherwise they are out of range. A constant index must be non-negative and +// representable by a value of type int. If both indices are constant, they +// must satisfy low <= high. If the indices are out of range at run time, a +// run-time error occurs. +// +// Integer values of type bigint or duration cannot be used as indices. +// +// If s is NULL the result is NULL. If low or high is not omitted and is NULL +// then the result is NULL. +// +// Calls +// +// Given an identifier f denoting a predeclared function, +// +// f(a1, a2, … an) +// +// calls f with arguments a1, a2, … an. Arguments are evaluated before the +// function is called. The type of the expression is the result type of f. +// +// complex(x, y) +// len(name) +// +// In a function call, the function value and arguments are evaluated in the +// usual order. After they are evaluated, the parameters of the call are passed +// by value to the function and the called function begins execution. The +// return value of the function is passed by value when the function returns. +// +// Calling an undefined function causes a compile-time error. +// +// Operators +// +// Operators combine operands into expressions. +// +// Expression = Term { ( oror | "OR" ) Term } . +// +// ExpressionList = Expression { "," Expression } [ "," ]. +// Factor = PrimaryFactor { ( ge | ">" | le | "<" | neq | eq | "LIKE" ) PrimaryFactor } [ Predicate ] . +// PrimaryFactor = PrimaryTerm { ( "^" | "|" | "-" | "+" ) PrimaryTerm } . +// PrimaryTerm = UnaryExpr { ( andnot | "&" | lsh | rsh | "%" | "/" | "*" ) UnaryExpr } . +// Term = Factor { ( andand | "AND" ) Factor } . +// UnaryExpr = [ "^" | "!" | "-" | "+" ] PrimaryExpression . +// +// Comparisons are discussed elsewhere. For other binary operators, the operand +// types must be identical unless the operation involves shifts or untyped +// constants. For operations involving constants only, see the section on +// constant expressions. +// +// Except for shift operations, if one operand is an untyped constant and the +// other operand is not, the constant is converted to the type of the other +// operand. +// +// The right operand in a shift expression must have unsigned integer type or +// be an untyped constant that can be converted to unsigned integer type. If +// the left operand of a non-constant shift expression is an untyped constant, +// the type of the constant is what it would be if the shift expression were +// replaced by its left operand alone. +// +// Pattern matching +// +// Expressions of the form +// +// expr1 LIKE expr2 +// +// yeild a boolean value true if expr2, a regular expression, matches expr1 +// (see also [6]). Both expression must be of type string. If any one of the +// expressions is NULL the result is NULL. +// +// Predicates +// +// Predicates are special form expressions having a boolean result type. +// +// Expressions of the form +// +// expr IN ( expr1, expr2, expr3, ... ) // case A +// +// expr NOT IN ( expr1, expr2, expr3, ... ) // case B +// +// are equivalent, including NULL handling, to +// +// expr == expr1 || expr == expr2 || expr == expr3 || ... // case A +// +// expr != expr1 && expr != expr2 && expr != expr3 && ... // case B +// +// The types of involved expressions must be comparable as defined in +// "Comparison operators". +// +// Another form of the IN predicate creates the expression list from a result +// of a SelectStmt. +// +// DELETE FROM t WHERE id() IN (SELECT id_t FROM u WHERE inactive_days > 365) +// +// The SelectStmt must select only one column. The produced expression list is +// resource limited by the memory available to the process. NULL values +// produced by the SelectStmt are ignored, but if all records of the SelectStmt +// are NULL the predicate yields NULL. The select statement is evaluated only +// once. If the type of expr is not the same as the type of the field returned +// by the SelectStmt then the set operation yields false. The type of the +// column returned by the SelectStmt must be one of the simple (non blob-like) +// types: +// +// bool +// byte // alias uint8 +// complex128 +// complex64 +// float // alias float64 +// float32 +// float64 +// int // alias int64 +// int16 +// int32 +// int64 +// int8 +// rune // alias int32 +// string +// uint // alias uint64 +// uint16 +// uint32 +// uint64 +// uint8 +// +// Expressions of the form +// +// expr BETWEEN low AND high // case A +// +// expr NOT BETWEEN low AND high // case B +// +// are equivalent, including NULL handling, to +// +// expr >= low && expr <= high // case A +// +// expr < low || expr > high // case B +// +// The types of involved expressions must be ordered as defined in "Comparison +// operators". +// +// Predicate = ( +// [ "NOT" ] ( +// "IN" "(" ExpressionList ")" +// | "IN" "(" SelectStmt [ ";" ] ")" +// | "BETWEEN" PrimaryFactor "AND" PrimaryFactor +// ) +// | "IS" [ "NOT" ] "NULL" +// ). +// +// Expressions of the form +// +// expr IS NULL // case A +// +// expr IS NOT NULL // case B +// +// yeild a boolean value true if expr does not have a specific type (case A) or +// if expr has a specific type (case B). In other cases the result is a boolean +// value false. +// +// Operator precedence +// +// Unary operators have the highest precedence. +// +// There are five precedence levels for binary operators. Multiplication +// operators bind strongest, followed by addition operators, comparison +// operators, && (logical AND), and finally || (logical OR) +// +// Precedence Operator +// 5 * / % << >> & &^ +// 4 + - | ^ +// 3 == != < <= > >= +// 2 && +// 1 || +// +// Binary operators of the same precedence associate from left to right. For +// instance, x / y * z is the same as (x / y) * z. +// +// +x +// 23 + 3*x[i] +// x <= f() +// ^a >> b +// f() || g() +// x == y+1 && z > 0 +// +// Note that the operator precedence is reflected explicitly by the grammar. +// +// Arithmetic operators +// +// Arithmetic operators apply to numeric values and yield a result of the same +// type as the first operand. The four standard arithmetic operators (+, -, *, +// /) apply to integer, rational, floating-point, and complex types; + also +// applies to strings; +,- also applies to times. All other arithmetic +// operators apply to integers only. +// +// + sum integers, rationals, floats, complex values, strings +// - difference integers, rationals, floats, complex values, times +// * product integers, rationals, floats, complex values +// / quotient integers, rationals, floats, complex values +// % remainder integers +// +// & bitwise AND integers +// | bitwise OR integers +// ^ bitwise XOR integers +// &^ bit clear (AND NOT) integers +// +// << left shift integer << unsigned integer +// >> right shift integer >> unsigned integer +// +// Strings can be concatenated using the + operator +// +// "hi" + string(c) + " and good bye" +// +// String addition creates a new string by concatenating the operands. +// +// A value of type duration can be added to or subtracted from a value of type time. +// +// now() + duration("1h") // time after 1 hour from now +// duration("1h") + now() // time after 1 hour from now +// now() - duration("1h") // time before 1 hour from now +// duration("1h") - now() // illegal, negative times do not exist +// +// Times can subtracted from each other producing a value of type duration. +// +// now() - t0 // elapsed time since t0 +// now() + now() // illegal, operator + not defined for times +// +// For two integer values x and y, the integer quotient q = x / y and remainder +// r = x % y satisfy the following relationships +// +// x = q*y + r and |r| < |y| +// +// with x / y truncated towards zero ("truncated division"). +// +// x y x / y x % y +// 5 3 1 2 +// -5 3 -1 -2 +// 5 -3 -1 2 +// -5 -3 1 -2 +// +// As an exception to this rule, if the dividend x is the most negative value +// for the int type of x, the quotient q = x / -1 is equal to x (and r = 0). +// +// x, q +// int8 -128 +// int16 -32768 +// int32 -2147483648 +// int64 -9223372036854775808 +// +// If the divisor is a constant expression, it must not be zero. If the divisor +// is zero at run time, a run-time error occurs. If the dividend is +// non-negative and the divisor is a constant power of 2, the division may be +// replaced by a right shift, and computing the remainder may be replaced by a +// bitwise AND operation +// +// x x / 4 x % 4 x >> 2 x & 3 +// 11 2 3 2 3 +// -11 -2 -3 -3 1 +// +// The shift operators shift the left operand by the shift count specified by +// the right operand. They implement arithmetic shifts if the left operand is a +// signed integer and logical shifts if it is an unsigned integer. There is no +// upper limit on the shift count. Shifts behave as if the left operand is +// shifted n times by 1 for a shift count of n. As a result, x << 1 is the same +// as x*2 and x >> 1 is the same as x/2 but truncated towards negative +// infinity. +// +// For integer operands, the unary operators +, -, and ^ are defined as follows +// +// +x is 0 + x +// -x negation is 0 - x +// ^x bitwise complement is m ^ x with m = "all bits set to 1" for unsigned x +// and m = -1 for signed x +// +// For floating-point and complex numbers, +x is the same as x, while -x is the +// negation of x. The result of a floating-point or complex division by zero is +// not specified beyond the IEEE-754 standard; whether a run-time error occurs +// is implementation-specific. +// +// Whenever any operand of any arithmetic operation, unary or binary, is NULL, +// as well as in the case of the string concatenating operation, the result is +// NULL. +// +// 42*NULL // the result is NULL +// NULL/x // the result is NULL +// "foo"+NULL // the result is NULL +// +// Integer overflow +// +// For unsigned integer values, the operations +, -, *, and << are computed +// modulo 2n, where n is the bit width of the unsigned integer's type. Loosely +// speaking, these unsigned integer operations discard high bits upon overflow, +// and expressions may rely on ``wrap around''. +// +// For signed integers with a finite bit width, the operations +, -, *, and << +// may legally overflow and the resulting value exists and is deterministically +// defined by the signed integer representation, the operation, and its +// operands. No exception is raised as a result of overflow. An evaluator may +// not optimize an expression under the assumption that overflow does not +// occur. For instance, it may not assume that x < x + 1 is always true. +// +// Integers of type bigint and rationals do not overflow but their handling is +// limited by the memory resources available to the program. +// +// Comparison operators +// +// Comparison operators compare two operands and yield a boolean value. +// +// == equal +// != not equal +// < less +// <= less or equal +// > greater +// >= greater or equal +// +// In any comparison, the first operand must be of same type as is the second +// operand, or vice versa. +// +// The equality operators == and != apply to operands that are comparable. The +// ordering operators <, <=, >, and >= apply to operands that are ordered. +// These terms and the result of the comparisons are defined as follows +// +// - Boolean values are comparable. Two boolean values are equal if they are +// either both true or both false. +// +// - Complex values are comparable. Two complex values u and v are equal if +// both real(u) == real(v) and imag(u) == imag(v). +// +// - Integer values are comparable and ordered, in the usual way. Note that +// durations are integers. +// +// - Floating point values are comparable and ordered, as defined by the +// IEEE-754 standard. +// +// - Rational values are comparable and ordered, in the usual way. +// +// - String values are comparable and ordered, lexically byte-wise. +// +// - Time values are comparable and ordered. +// +// Whenever any operand of any comparison operation is NULL, the result is +// NULL. +// +// Note that slices are always of type string. +// +// Logical operators +// +// Logical operators apply to boolean values and yield a boolean result. The +// right operand is evaluated conditionally. +// +// && conditional AND p && q is "if p then q else false" +// || conditional OR p || q is "if p then true else q" +// ! NOT !p is "not p" +// +// The truth tables for logical operations with NULL values +// +// +-------+-------+---------+---------+ +// | p | q | p || q | p && q | +// +-------+-------+---------+---------+ +// | true | true | *true | true | +// | true | false | *true | false | +// | true | NULL | *true | NULL | +// | false | true | true | *false | +// | false | false | false | *false | +// | false | NULL | NULL | *false | +// | NULL | true | true | NULL | +// | NULL | false | NULL | false | +// | NULL | NULL | NULL | NULL | +// +-------+-------+---------+---------+ +// * indicates q is not evaluated. +// +// +-------+-------+ +// | p | !p | +// +-------+-------+ +// | true | false | +// | false | true | +// | NULL | NULL | +// +-------+-------+ +// +// Conversions +// +// Conversions are expressions of the form T(x) where T is a type and x is an +// expression that can be converted to type T. +// +// Conversion = Type "(" Expression ")" . +// +// A constant value x can be converted to type T in any of these cases: +// +// - x is representable by a value of type T. +// +// - x is a floating-point constant, T is a floating-point type, and x is +// representable by a value of type T after rounding using IEEE 754 +// round-to-even rules. The constant T(x) is the rounded value. +// +// - x is an integer constant and T is a string type. The same rule as for +// non-constant x applies in this case. +// +// Converting a constant yields a typed constant as result. +// +// float32(2.718281828) // 2.718281828 of type float32 +// complex128(1) // 1.0 + 0.0i of type complex128 +// float32(0.49999999) // 0.5 of type float32 +// string('x') // "x" of type string +// string(0x266c) // "♬" of type string +// "foo" + "bar" // "foobar" +// int(1.2) // illegal: 1.2 cannot be represented as an int +// string(65.0) // illegal: 65.0 is not an integer constant +// +// A non-constant value x can be converted to type T in any of these cases: +// +// - x has type T. +// +// - x's type and T are both integer or floating point types. +// +// - x's type and T are both complex types. +// +// - x is an integer, except bigint or duration, and T is a string type. +// +// Specific rules apply to (non-constant) conversions between numeric types or +// to and from a string type. These conversions may change the representation +// of x and incur a run-time cost. All other conversions only change the type +// but not the representation of x. +// +// A conversion of NULL to any type yields NULL. +// +// Conversions between numeric types +// +// For the conversion of non-constant numeric values, the following rules +// apply +// +// 1. When converting between integer types, if the value is a signed integer, +// it is sign extended to implicit infinite precision; otherwise it is zero +// extended. It is then truncated to fit in the result type's size. For +// example, if v == uint16(0x10F0), then uint32(int8(v)) == 0xFFFFFFF0. The +// conversion always yields a valid value; there is no indication of overflow. +// +// 2. When converting a floating-point number to an integer, the fraction is +// discarded (truncation towards zero). +// +// 3. When converting an integer or floating-point number to a floating-point +// type, or a complex number to another complex type, the result value is +// rounded to the precision specified by the destination type. For instance, +// the value of a variable x of type float32 may be stored using additional +// precision beyond that of an IEEE-754 32-bit number, but float32(x) +// represents the result of rounding x's value to 32-bit precision. Similarly, +// x + 0.1 may use more than 32 bits of precision, but float32(x + 0.1) does +// not. +// +// In all non-constant conversions involving floating-point or complex values, +// if the result type cannot represent the value the conversion succeeds but +// the result value is implementation-dependent. +// +// Conversions to and from a string type +// +// 1. Converting a signed or unsigned integer value to a string type yields a +// string containing the UTF-8 representation of the integer. Values outside +// the range of valid Unicode code points are converted to "\uFFFD". +// +// string('a') // "a" +// string(-1) // "\ufffd" == "\xef\xbf\xbd" +// string(0xf8) // "\u00f8" == "ø" == "\xc3\xb8" +// string(0x65e5) // "\u65e5" == "日" == "\xe6\x97\xa5" +// +// 2. Converting a blob to a string type yields a string whose successive bytes +// are the elements of the blob. +// +// string(b /* []byte{'h', 'e', 'l', 'l', '\xc3', '\xb8'} */) // "hellø" +// string(b /* []byte{} */) // "" +// string(b /* []byte(nil) */) // "" +// +// 3. Converting a value of a string type to a blob yields a blob whose +// successive elements are the bytes of the string. +// +// blob("hellø") // []byte{'h', 'e', 'l', 'l', '\xc3', '\xb8'} +// blob("") // []byte{} +// +// 4. Converting a value of a bigint type to a string yields a string +// containing the decimal decimal representation of the integer. +// +// string(M9) // "2305843009213693951" +// +// 5. Converting a value of a string type to a bigint yields a bigint value +// containing the integer represented by the string value. A prefix of “0x” or +// “0X” selects base 16; the “0” prefix selects base 8, and a “0b” or “0B” +// prefix selects base 2. Otherwise the value is interpreted in base 10. An +// error occurs if the string value is not in any valid format. +// +// bigint("2305843009213693951") // M9 +// bigint("0x1ffffffffffffffffffffff") // M10 == 2^89-1 +// +// 6. Converting a value of a rational type to a string yields a string +// containing the decimal decimal representation of the rational in the form +// "a/b" (even if b == 1). +// +// string(bigrat(355)/bigrat(113)) // "355/113" +// +// 7. Converting a value of a string type to a bigrat yields a bigrat value +// containing the rational represented by the string value. The string can be +// given as a fraction "a/b" or as a floating-point number optionally followed +// by an exponent. An error occurs if the string value is not in any valid +// format. +// +// bigrat("1.2e-34") +// bigrat("355/113") +// +// 8. Converting a value of a duration type to a string returns a string +// representing the duration in the form "72h3m0.5s". Leading zero units are +// omitted. As a special case, durations less than one second format using a +// smaller unit (milli-, micro-, or nanoseconds) to ensure that the leading +// digit is non-zero. The zero duration formats as 0, with no unit. +// +// string(elapsed) // "1h", for example +// +// 9. Converting a string value to a duration yields a duration represented by +// the string. A duration string is a possibly signed sequence of decimal +// numbers, each with optional fraction and a unit suffix, such as "300ms", +// "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", +// "m", "h". +// +// duration("1m") // http://golang.org/pkg/time/#Minute +// +// 10. Converting a time value to a string returns the time formatted using the +// format string +// +// "2006-01-02 15:04:05.999999999 -0700 MST" +// +// Order of evaluation +// +// When evaluating the operands of an expression or of function calls, +// operations are evaluated in lexical left-to-right order. +// +// For example, in the evaluation of +// +// g(h(), i()+x[j()], c) +// +// the function calls and evaluation of c happen in the order h(), i(), j(), c. +// +// Floating-point operations within a single expression are evaluated according +// to the associativity of the operators. Explicit parentheses affect the +// evaluation by overriding the default associativity. In the expression x + (y +// + z) the addition y + z is performed before adding x. +// +// Statements +// +// Statements control execution. +// +// Statement = EmptyStmt | AlterTableStmt | BeginTransactionStmt | CommitStmt +// | CreateIndexStmt | CreateTableStmt | DeleteFromStmt | DropIndexStmt +// | DropTableStmt | InsertIntoStmt | RollbackStmt | SelectStmt +// | TruncateTableStmt | UpdateStmt | ExplainStmt. +// +// StatementList = Statement { ";" Statement } . +// +// Empty statements +// +// The empty statement does nothing. +// +// EmptyStmt = . +// +// ALTER TABLE +// +// Alter table statements modify existing tables. With the ADD clause it adds +// a new column to the table. The column must not exist. With the DROP clause +// it removes an existing column from a table. The column must exist and it +// must be not the only (last) column of the table. IOW, there cannot be a +// table with no columns. +// +// AlterTableStmt = "ALTER" "TABLE" TableName ( "ADD" ColumnDef | "DROP" "COLUMN" ColumnName ) . +// +// For example +// +// BEGIN TRANSACTION; +// ALTER TABLE Stock ADD Qty int; +// ALTER TABLE Income DROP COLUMN Taxes; +// COMMIT; +// +// When adding a column to a table with existing data, the constraint clause of +// the ColumnDef cannot be used. Adding a constrained column to an empty table +// is fine. +// +// BEGIN TRANSACTION +// +// Begin transactions statements introduce a new transaction level. Every +// transaction level must be eventually balanced by exactly one of COMMIT or +// ROLLBACK statements. Note that when a transaction is roll-backed because of +// a statement failure then no explicit balancing of the respective BEGIN +// TRANSACTION is statement is required nor permitted. +// +// Failure to properly balance any opened transaction level may cause dead +// locks and/or lose of data updated in the uppermost opened but never properly +// closed transaction level. +// +// BeginTransactionStmt = "BEGIN" "TRANSACTION" . +// +// For example +// +// BEGIN TRANSACTION; +// INSERT INTO foo VALUES (42, 3.14); +// INSERT INTO foo VALUES (-1, 2.78); +// COMMIT; +// +// Mandatory transactions +// +// A database cannot be updated (mutated) outside of a transaction. Statements +// requiring a transaction +// +// ALTER TABLE +// COMMIT +// CREATE INDEX +// CREATE TABLE +// DELETE FROM +// DROP INDEX +// DROP TABLE +// INSERT INTO +// ROLLBACK +// TRUNCATE TABLE +// UPDATE +// +// A database is effectively read only outside of a transaction. Statements not +// requiring a transaction +// +// BEGIN TRANSACTION +// SELECT FROM +// +// COMMIT +// +// The commit statement closes the innermost transaction nesting level. If +// that's the outermost level then the updates to the DB made by the +// transaction are atomically made persistent. +// +// CommitStmt = "COMMIT" . +// +// For example +// +// BEGIN TRANSACTION; +// INSERT INTO AccountA (Amount) VALUES ($1); +// INSERT INTO AccountB (Amount) VALUES (-$1); +// COMMIT; +// +// CREATE INDEX +// +// Create index statements create new indices. Index is a named projection of +// ordered values of a table column to the respective records. As a special +// case the id() of the record can be indexed. Index name must not be the same +// as any of the existing tables and it also cannot be the same as of any +// column name of the table the index is on. +// +// CreateIndexStmt = "CREATE" [ "UNIQUE" ] "INDEX" [ "IF" "NOT" "EXISTS" ] +// IndexName "ON" TableName "(" ExpressionList ")" . +// +// For example +// +// BEGIN TRANSACTION; +// CREATE TABLE Orders (CustomerID int, Date time); +// CREATE INDEX OrdersID ON Orders (id()); +// CREATE INDEX OrdersDate ON Orders (Date); +// CREATE TABLE Items (OrderID int, ProductID int, Qty int); +// CREATE INDEX ItemsOrderID ON Items (OrderID); +// COMMIT; +// +// Now certain SELECT statements may use the indices to speed up joins and/or +// to speed up record set filtering when the WHERE clause is used; or the +// indices might be used to improve the performance when the ORDER BY clause is +// present. +// +// The UNIQUE modifier requires the indexed values tuple to be index-wise +// unique or have all values NULL. +// +// The optional IF NOT EXISTS clause makes the statement a no operation if the +// index already exists. +// +// Simple index +// +// A simple index consists of only one expression which must be either a column +// name or the built-in id(). +// +// Expression list index +// +// A more complex and more general index is one that consists of more than one +// expression or its single expression does not qualify as a simple index. In +// this case the type of all expressions in the list must be one of the non +// blob-like types. +// +// Note: Blob-like types are blob, bigint, bigrat, time and duration. +// +// CREATE TABLE +// +// Create table statements create new tables. A column definition declares the +// column name and type. Table names and column names are case sensitive. +// Neither a table or an index of the same name may exist in the DB. +// +// CreateTableStmt = "CREATE" "TABLE" [ "IF" "NOT" "EXISTS" ] TableName +// "(" ColumnDef { "," ColumnDef } [ "," ] ")" . +// +// ColumnDef = ColumnName Type [ "NOT" "NULL" | Expression ] [ "DEFAULT" Expression ] . +// ColumnName = identifier . +// TableName = identifier . +// +// For example +// +// BEGIN TRANSACTION; +// CREATE TABLE department ( +// DepartmentID int, +// DepartmentName string, +// ); +// CREATE TABLE employee ( +// LastName string, +// DepartmentID int, +// ); +// COMMIT; +// +// The optional IF NOT EXISTS clause makes the statement a no operation if the +// table already exists. +// +// The optional constraint clause has two forms. The first one is found in many +// SQL dialects. +// +// BEGIN TRANSACTION; +// CREATE TABLE department ( +// DepartmentID int, +// DepartmentName string NOT NULL, +// ); +// COMMIT; +// +// This form prevents the data in column DepartmentName to be NULL. +// +// The second form allows an arbitrary boolean expression to be used to +// validate the column. If the value of the expression is true then the +// validation succeeded. If the value of the expression is false or NULL then +// the validation fails. If the value of the expression is not of type bool an +// error occurs. +// +// BEGIN TRANSACTION; +// CREATE TABLE department ( +// DepartmentID int, +// DepartmentName string DepartmentName IN ("HQ", "R/D", "Lab", "HR"), +// ); +// COMMIT; +// +// BEGIN TRANSACTION; +// CREATE TABLE t ( +// TimeStamp time TimeStamp < now() && since(TimeStamp) < duration("10s"), +// Event string Event != "" && Event like "[0-9]+:[ \t]+.*", +// ); +// COMMIT; +// +// The optional DEFAULT clause is an expression which, if present, is +// substituted instead of a NULL value when the colum is assigned a value. +// +// BEGIN TRANSACTION; +// CREATE TABLE department ( +// DepartmentID int, +// DepartmentName string DepartmentName IN ("HQ", "R/D", "Lab", "HR") DEFAULT "HQ", +// ); +// COMMIT; +// +// Note that the constraint and/or default expressions may refer to other +// columns by name: +// +// BEGIN TRANSACTION; +// CREATE TABLE t ( +// a int, +// b int b > a && b < c DEFAULT (a+c)/2, +// c int, +// ); +// COMMIT; +// +// +// Constraints and defaults +// +// When a table row is inserted by the INSERT INTO statement or when a table +// row is updated by the UPDATE statement, the order of operations is as +// follows: +// +// 1. The new values of the affected columns are set and the values of all the +// row columns become the named values which can be referred to in default +// expressions evaluated in step 2. +// +// 2. If any row column value is NULL and the DEFAULT clause is present in the +// column's definition, the default expression is evaluated and its value is +// set as the respective column value. +// +// 3. The values, potentially updated, of row columns become the named values +// which can be referred to in constraint expressions evaluated during step 4. +// +// 4. All row columns which definition has the constraint clause present will +// have that constraint checked. If any constraint violation is detected, the +// overall operation fails and no changes to the table are made. +// +// DELETE FROM +// +// Delete from statements remove rows from a table, which must exist. +// +// DeleteFromStmt = "DELETE" "FROM" TableName [ WhereClause ] . +// +// For example +// +// BEGIN TRANSACTION; +// DELETE FROM DepartmentID +// WHERE DepartmentName == "Ponies"; +// COMMIT; +// +// If the WHERE clause is not present then all rows are removed and the +// statement is equivalent to the TRUNCATE TABLE statement. +// +// DROP INDEX +// +// Drop index statements remove indices from the DB. The index must exist. +// +// DropIndexStmt = "DROP" "INDEX" [ "IF" "EXISTS" ] IndexName . +// IndexName = identifier . +// +// For example +// +// BEGIN TRANSACTION; +// DROP INDEX ItemsOrderID; +// COMMIT; +// +// The optional IF EXISTS clause makes the statement a no operation if the +// index does not exist. +// +// DROP TABLE +// +// Drop table statements remove tables from the DB. The table must exist. +// +// DropTableStmt = "DROP" "TABLE" [ "IF" "EXISTS" ] TableName . +// +// For example +// +// BEGIN TRANSACTION; +// DROP TABLE Inventory; +// COMMIT; +// +// The optional IF EXISTS clause makes the statement a no operation if the +// table does not exist. +// +// INSERT INTO +// +// Insert into statements insert new rows into tables. New rows come from +// literal data, if using the VALUES clause, or are a result of select +// statement. In the later case the select statement is fully evaluated before +// the insertion of any rows is performed, allowing to insert values calculated +// from the same table rows are to be inserted into. If the ColumnNameList part +// is omitted then the number of values inserted in the row must be the same as +// are columns in the table. If the ColumnNameList part is present then the +// number of values per row must be same as the same number of column names. +// All other columns of the record are set to NULL. The type of the value +// assigned to a column must be the same as is the column's type or the value +// must be NULL. +// +// InsertIntoStmt = "INSERT" "INTO" TableName [ "(" ColumnNameList ")" ] ( Values | SelectStmt ) . +// +// ColumnNameList = ColumnName { "," ColumnName } [ "," ] . +// Values = "VALUES" "(" ExpressionList ")" { "," "(" ExpressionList ")" } [ "," ] . +// +// For example +// +// BEGIN TRANSACTION; +// INSERT INTO department (DepartmentID) VALUES (42); +// +// INSERT INTO department ( +// DepartmentName, +// DepartmentID, +// ) +// VALUES ( +// "R&D", +// 42, +// ); +// +// INSERT INTO department VALUES +// (42, "R&D"), +// (17, "Sales"), +// ; +// COMMIT; +// +// BEGIN TRANSACTION; +// INSERT INTO department (DepartmentName, DepartmentID) +// SELECT DepartmentName+"/headquarters", DepartmentID+1000 +// FROM department; +// COMMIT; +// +// If any of the columns of the table were defined using the optional +// constraints clause or the optional defaults clause then those are processed +// on a per row basis. The details are discussed in the "Constraints and +// defaults" chapter below the CREATE TABLE statement documentation. +// +// Explain statement +// +// Explain statement produces a recordset consisting of lines of text which +// describe the execution plan of a statement, if any. +// +// ExplainStmt = "EXPLAIN" Statement . +// +// For example, the QL tool treats the explain statement specially and outputs +// the joined lines: +// +// $ ql 'create table t(i int); create table u(j int)' +// $ ql 'explain select * from t, u where t.i > 42 && u.j < 314' +// ┌Compute Cartesian product of +// │ ┌Iterate all rows of table "t" +// │ └Output field names ["i"] +// │ ┌Iterate all rows of table "u" +// │ └Output field names ["j"] +// └Output field names ["t.i" "u.j"] +// ┌Filter on t.i > 42 && u.j < 314 +// │Possibly useful indices +// │CREATE INDEX xt_i ON t(i); +// │CREATE INDEX xu_j ON u(j); +// └Output field names ["t.i" "u.j"] +// $ ql 'CREATE INDEX xt_i ON t(i); CREATE INDEX xu_j ON u(j);' +// $ ql 'explain select * from t, u where t.i > 42 && u.j < 314' +// ┌Compute Cartesian product of +// │ ┌Iterate all rows of table "t" using index "xt_i" where i > 42 +// │ └Output field names ["i"] +// │ ┌Iterate all rows of table "u" using index "xu_j" where j < 314 +// │ └Output field names ["j"] +// └Output field names ["t.i" "u.j"] +// $ ql 'explain select * from t where i > 12 and i between 10 and 20 and i < 42' +// ┌Iterate all rows of table "t" using index "xt_i" where i > 12 && i <= 20 +// └Output field names ["i"] +// $ +// +// The explanation may aid in uderstanding how a statement/query would be +// executed and if indices are used as expected - or which indices may possibly +// improve the statement performance. The create index statements above were +// directly copy/pasted in the terminal from the suggestions provided by the +// filter recordset pipeline part returned by the explain statement. +// +// If the statement has nothing special in its plan, the result is the original +// statement. +// +// $ ql 'explain delete from t where 42 < i' +// DELETE FROM t WHERE i > 42; +// $ +// +// To get an explanation of the select statement of the IN predicate, use the EXPLAIN +// statement with that particular select statement. +// +// $ ql 'explain select * from t where i in (select j from u where j > 0)' +// ┌Iterate all rows of table "t" +// └Output field names ["i"] +// ┌Filter on i IN (SELECT j FROM u WHERE j > 0;) +// └Output field names ["i"] +// $ ql 'explain select j from u where j > 0' +// ┌Iterate all rows of table "u" using index "xu_j" where j > 0 +// └Output field names ["j"] +// $ +// +// ROLLBACK +// +// The rollback statement closes the innermost transaction nesting level +// discarding any updates to the DB made by it. If that's the outermost level +// then the effects on the DB are as if the transaction never happened. +// +// RollbackStmt = "ROLLBACK" . +// +// For example +// +// // First statement list +// BEGIN TRANSACTION +// SELECT * INTO tmp FROM foo; +// INSERT INTO tmp SELECT * from bar; +// SELECT * from tmp; +// +// The (temporary) record set from the last statement is returned and can be +// processed by the client. +// +// // Second statement list +// ROLLBACK; +// +// In this case the rollback is the same as 'DROP TABLE tmp;' but it can be a +// more complex operation. +// +// SELECT FROM +// +// Select from statements produce recordsets. The optional DISTINCT modifier +// ensures all rows in the result recordset are unique. Either all of the +// resulting fields are returned ('*') or only those named in FieldList. +// +// RecordSetList is a list of table names or parenthesized select statements, +// optionally (re)named using the AS clause. +// +// The result can be filtered using a WhereClause and orderd by the OrderBy +// clause. +// +// SelectStmt = "SELECT" [ "DISTINCT" ] ( "*" | FieldList ) "FROM" RecordSetList +// [ JoinClause ] [ WhereClause ] [ GroupByClause ] [ OrderBy ] [ Limit ] [ Offset ]. +// +// JoinClause = ( "LEFT" | "RIGHT" | "FULL" ) [ "OUTER" ] "JOIN" RecordSet "ON" Expression . +// +// RecordSet = ( TableName | "(" SelectStmt [ ";" ] ")" ) [ "AS" identifier ] . +// RecordSetList = RecordSet { "," RecordSet } [ "," ] . +// +// For example +// +// SELECT * FROM Stock; +// +// SELECT DepartmentID +// FROM department +// WHERE DepartmentID == 42 +// ORDER BY DepartmentName; +// +// SELECT employee.LastName +// FROM department, employee +// WHERE department.DepartmentID == employee.DepartmentID +// ORDER BY DepartmentID; +// +// If Recordset is a nested, parenthesized SelectStmt then it must be given a +// name using the AS clause if its field are to be accessible in expressions. +// +// SELECT a.b, c.d +// FROM +// x AS a, +// ( +// SELECT * FROM y; +// ) AS c +// WHERE a.e > c.e; +// +// Fields naming rules +// +// A field is an named expression. Identifiers, not used as a type in +// conversion or a function name in the Call clause, denote names of (other) +// fields, values of which should be used in the expression. +// +// Field = Expression [ "AS" identifier ] . +// +// The expression can be named using the AS clause. If the AS clause is not +// present and the expression consists solely of a field name, then that field +// name is used as the name of the resulting field. Otherwise the field is +// unnamed. +// +// For example +// +// SELECT 314, 42 as AUQLUE, DepartmentID, DepartmentID+1000, LastName as Name from employee; +// // Fields are []string{"", "AUQLUE", "DepartmentID", "", "Name"} +// +// The SELECT statement can optionally enumerate the desired/resulting fields +// in a list. +// +// FieldList = Field { "," Field } [ "," ] . +// +// No two identical field names can appear in the list. +// +// SELECT DepartmentID, LastName, DepartmentID from employee; +// // duplicate field name "DepartmentID" +// +// SELECT DepartmentID, LastName, DepartmentID as ID2 from employee; +// // works +// +// When more than one record set is used in the FROM clause record set list, +// the result record set field names are rewritten to be qualified using +// the record set names. +// +// SELECT * FROM employee, department; +// // Fields are []string{"employee.LastName", "employee.DepartmentID", "department.DepartmentID", "department.DepartmentName" +// +// If a particular record set doesn't have a name, its respective fields became +// unnamed. +// +// SELECT * FROM employee as e, ( SELECT * FROM department); +// // Fields are []string{"e.LastName", "e.DepartmentID", "", "" +// +// SELECT * FROM employee AS e, ( SELECT * FROM department) AS d; +// // Fields are []string{"e.LastName", "e.DepartmentID", "d.DepartmentID", "d.DepartmentName" +// +// Outer joins +// +// The optional JOIN clause, for example +// +// SELECT * +// FROM a +// LEFT OUTER JOIN b ON expr; +// +// is mostly equal to +// +// SELECT * +// FROM a, b +// WHERE expr; +// +// except that the rows from a which, when they appear in the cross join, never +// made expr to evaluate to true, are combined with a virtual row from b, +// containing all nulls, and added to the result set. For the RIGHT JOIN +// variant the discussed rules are used for rows from b not satisfying expr == +// true and the virtual, all-null row "comes" from a. The FULL JOIN adds the +// respective rows which would be otherwise provided by the separate executions +// of the LEFT JOIN and RIGHT JOIN variants. For more thorough OUTER JOIN +// discussion please see the Wikipedia article at [10]. +// +// Recordset ordering +// +// Resultins rows of a SELECT statement can be optionally ordered by the ORDER +// BY clause. Collating proceeds by considering the expressions in the +// expression list left to right until a collating order is determined. Any +// possibly remaining expressions are not evaluated. +// +// OrderBy = "ORDER" "BY" ExpressionList [ "ASC" | "DESC" ] . +// +// All of the expression values must yield an ordered type or NULL. Ordered +// types are defined in "Comparison operators". Collating of elements having a +// NULL value is different compared to what the comparison operators yield in +// expression evaluation (NULL result instead of a boolean value). +// +// Below, T denotes a non NULL value of any QL type. +// +// NULL < T +// +// NULL collates before any non NULL value (is considered smaller than T). +// +// NULL == NULL +// +// Two NULLs have no collating order (are considered equal). +// +// Recordset filtering +// +// The WHERE clause restricts records considered by some statements, like +// SELECT FROM, DELETE FROM, or UPDATE. +// +// expression value consider the record +// ---------------- ------------------- +// true yes +// false or NULL no +// +// It is an error if the expression evaluates to a non null value of non bool +// type. +// +// WhereClause = "WHERE" Expression . +// +// Recordset grouping +// +// The GROUP BY clause is used to project rows having common values into a +// smaller set of rows. +// +// For example +// +// SELECT Country, sum(Qty) FROM Sales GROUP BY Country; +// +// SELECT Country, Product FROM Sales GROUP BY Country, Product; +// +// SELECT DISTINCT Country, Product FROM Sales; +// +// Using the GROUP BY without any aggregate functions in the selected fields is +// in certain cases equal to using the DISTINCT modifier. The last two examples +// above produce the same resultsets. +// +// GroupByClause = "GROUP BY" ColumnNameList . +// +// Skipping records +// +// The optional OFFSET clause allows to ignore first N records. For example +// +// SELECT * FROM t OFFSET 10; +// +// The above will produce only rows 11, 12, ... of the record set, if they +// exist. The value of the expression must a non negative integer, but not +// bigint or duration. +// +// Offset = "OFFSET" Expression . +// +// Limiting the result set size +// +// The optional LIMIT clause allows to ignore all but first N records. For +// example +// +// SELECT * FROM t LIMIT 10; +// +// The above will return at most the first 10 records of the record set. The +// value of the expression must a non negative integer, but not bigint or +// duration. +// +// Limit = "Limit" Expression . +// +// The LIMIT and OFFSET clauses can be combined. For example +// +// SELECT * FROM t LIMIT 5 OFFSET 3; +// +// Considering table t has, say 10 records, the above will produce only records +// 4 - 8. +// +// #1: Ignore 1/3 +// #2: Ignore 2/3 +// #3: Ignore 3/3 +// #4: Return 1/5 +// #5: Return 2/5 +// #6: Return 3/5 +// #7: Return 4/5 +// #8: Return 5/5 +// +// After returning record #8, no more result rows/records are computed. +// +// Select statement evaluation order +// +// 1. The FROM clause is evaluated, producing a Cartesian product of its source +// record sets (tables or nested SELECT statements). +// +// 2. If present, the JOIN cluase is evaluated on the result set of the +// previous evaluation and the recordset specified by the JOIN clause. (... +// JOIN Recordset ON ...) +// +// 3. If present, the WHERE clause is evaluated on the result set of the +// previous evaluation. +// +// 4. If present, the GROUP BY clause is evaluated on the result set of the +// previous evaluation(s). +// +// 5. The SELECT field expressions are evaluated on the result set of the +// previous evaluation(s). +// +// 6. If present, the DISTINCT modifier is evaluated on the result set of the +// previous evaluation(s). +// +// 7. If present, the ORDER BY clause is evaluated on the result set of the +// previous evaluation(s). +// +// 8. If present, the OFFSET clause is evaluated on the result set of the +// previous evaluation(s). The offset expression is evaluated once for the +// first record produced by the previous evaluations. +// +// 9. If present, the LIMIT clause is evaluated on the result set of the +// previous evaluation(s). The limit expression is evaluated once for the first +// record produced by the previous evaluations. +// +// +// TRUNCATE TABLE +// +// Truncate table statements remove all records from a table. The table must +// exist. +// +// TruncateTableStmt = "TRUNCATE" "TABLE" TableName . +// +// For example +// +// BEGIN TRANSACTION +// TRUNCATE TABLE department; +// COMMIT; +// +// UPDATE +// +// Update statements change values of fields in rows of a table. +// +// UpdateStmt = "UPDATE" TableName [ "SET" ] AssignmentList [ WhereClause ] . +// +// AssignmentList = Assignment { "," Assignment } [ "," ] . +// Assignment = ColumnName "=" Expression . +// +// For example +// +// BEGIN TRANSACTION +// UPDATE department +// DepartmentName = DepartmentName + " dpt.", +// DepartmentID = 1000+DepartmentID, +// WHERE DepartmentID < 1000; +// COMMIT; +// +// Note: The SET clause is optional. +// +// If any of the columns of the table were defined using the optional +// constraints clause or the optional defaults clause then those are processed +// on a per row basis. The details are discussed in the "Constraints and +// defaults" chapter below the CREATE TABLE statement documentation. +// +// System Tables +// +// To allow to query for DB meta data, there exist specially named tables, some +// of them being virtual. +// +// Note: Virtual system tables may have fake table-wise unique but meaningless +// and unstable record IDs. Do not apply the built-in id() to any system table. +// +// Tables Table +// +// The table __Table lists all tables in the DB. The schema is +// +// CREATE TABLE __Table (Name string, Schema string); +// +// The Schema column returns the statement to (re)create table Name. This table +// is virtual. +// +// Columns Table +// +// The table __Colum lists all columns of all tables in the DB. The schema is +// +// CREATE TABLE __Column (TableName string, Ordinal int, Name string, Type string); +// +// The Ordinal column defines the 1-based index of the column in the record. +// This table is virtual. +// +// Columns2 Table +// +// The table __Colum2 lists all columns of all tables in the DB which have the +// constraint NOT NULL or which have a constraint expression defined or which +// have a default expression defined. The schema is +// +// CREATE TABLE __Column2 (TableName string, Name string, NotNull bool, ConstraintExpr string, DefaultExpr string) +// +// It's possible to obtain a consolidated recordset for all properties of all +// DB columns using +// +// SELECT +// __Column.TableName, __Column.Ordinal, __Column.Name, __Column.Type, +// __Column2.NotNull, __Column2.ConstraintExpr, __Column2.DefaultExpr, +// FROM __Column +// LEFT JOIN __Column2 +// ON __Column.TableName == __Column2.TableName && __Column.Name == __Column2.Name +// ORDER BY __Column.TableName, __Column.Ordinal; +// +// The Name column is the column name in TableName. +// +// Indices table +// +// The table __Index lists all indices in the DB. The schema is +// +// CREATE TABLE __Index (TableName string, ColumnName string, Name string, IsUnique bool); +// +// The IsUnique columns reflects if the index was created using the optional +// UNIQUE clause. This table is virtual. +// +// Built-in functions +// +// Built-in functions are predeclared. +// +// Average +// +// The built-in aggregate function avg returns the average of values of an +// expression. Avg ignores NULL values, but returns NULL if all values of a +// column are NULL or if avg is applied to an empty record set. +// +// func avg(e numeric) typeof(e) +// +// The column values must be of a numeric type. +// +// SELECT salesperson, avg(sales) FROM salesforce GROUP BY salesperson; +// +// Contains +// +// The built-in function contains returns true if substr is within s. +// +// func contains(s, substr string) bool +// +// If any argument to contains is NULL the result is NULL. +// +// Count +// +// The built-in aggregate function count returns how many times an expression +// has a non NULL values or the number of rows in a record set. Note: count() +// returns 0 for an empty record set. +// +// func count() int // The number of rows in a record set. +// func count(*) int // Equivalent to count(). +// func count(e expression) int // The number of cases where the expression value is not NULL. +// +// For example +// +// SELECT count() FROM department; // # of rows +// +// SELECT count(*) FROM department; // # of rows +// +// SELECT count(DepartmentID) FROM department; // # of records with non NULL field DepartmentID +// +// SELECT count()-count(DepartmentID) FROM department; // # of records with NULL field DepartmentID +// +// SELECT count(foo+bar*3) AS y FROM t; // # of cases where 'foo+bar*3' is non NULL +// +// Date +// +// Date returns the time corresponding to +// +// yyyy-mm-dd hh:mm:ss + nsec nanoseconds +// +// in the appropriate zone for that time in the given location. +// +// The month, day, hour, min, sec, and nsec values may be outside their usual +// ranges and will be normalized during the conversion. For example, October 32 +// converts to November 1. +// +// A daylight savings time transition skips or repeats times. For example, in +// the United States, March 13, 2011 2:15am never occurred, while November 6, +// 2011 1:15am occurred twice. In such cases, the choice of time zone, and +// therefore the time, is not well-defined. Date returns a time that is correct +// in one of the two zones involved in the transition, but it does not +// guarantee which. +// +// func date(year, month, day, hour, min, sec, nsec int, loc string) time +// +// A location maps time instants to the zone in use at that time. Typically, +// the location represents the collection of time offsets in use in a +// geographical area, such as "CEST" and "CET" for central Europe. "local" +// represents the system's local time zone. "UTC" represents Universal +// Coordinated Time (UTC). +// +// The month specifies a month of the year (January = 1, ...). +// +// If any argument to date is NULL the result is NULL. +// +// Day +// +// The built-in function day returns the day of the month specified by t. +// +// func day(t time) int +// +// If the argument to day is NULL the result is NULL. +// +// Format time +// +// The built-in function formatTime returns a textual representation of the +// time value formatted according to layout, which defines the format by +// showing how the reference time, +// +// Mon Jan 2 15:04:05 -0700 MST 2006 +// +// would be displayed if it were the value; it serves as an example of the +// desired output. The same display rules will then be applied to the time +// value. +// +// func formatTime(t time, layout string) string +// +// If any argument to formatTime is NULL the result is NULL. +// +// NOTE: The string value of the time zone, like "CET" or "ACDT", is dependent +// on the time zone of the machine the function is run on. For example, if the +// t value is in "CET", but the machine is in "ACDT", instead of "CET" the +// result is "+0100". This is the same what Go (time.Time).String() returns and +// in fact formatTime directly calls t.String(). +// +// formatTime(date(2006, 1, 2, 15, 4, 5, 999999999, "CET")) +// +// returns +// +// 2006-01-02 15:04:05.999999999 +0100 CET +// +// on a machine in the CET time zone, but may return +// +// 2006-01-02 15:04:05.999999999 +0100 +0100 +// +// on a machine in the ACDT zone. The time value is in both cases the same so +// its ordering and comparing is correct. Only the display value can differ. +// +// Format numbers +// +// The built-in functions formatFloat and formatInt format numbers +// to strings using go's number format functions in the `strconv` package. For +// all three functions, only the first argument is mandatory. The default values +// of the rest are shown in the examples. If the first argument is NULL, the +// result is NULL. +// +// formatFloat(43.2[, 'g', -1, 64]) string +// +// returns +// +// "43.2" +// +// formatInt(-42[, 10]) string +// +// returns +// +// "-42" +// +// formatInt(uint32(42)[, 10]) string +// +// returns +// +// "42" +// +// Unlike the `strconv` equivalent, the formatInt function handles all integer +// types, both signed and unsigned. +// +// HasPrefix +// +// The built-in function hasPrefix tests whether the string s begins with prefix. +// +// func hasPrefix(s, prefix string) bool +// +// If any argument to hasPrefix is NULL the result is NULL. +// +// HasSuffix +// +// The built-in function hasSuffix tests whether the string s ends with suffix. +// +// func hasSuffix(s, suffix string) bool +// +// If any argument to hasSuffix is NULL the result is NULL. +// +// Hour +// +// The built-in function hour returns the hour within the day specified by t, +// in the range [0, 23]. +// +// func hour(t time) int +// +// If the argument to hour is NULL the result is NULL. +// +// Hours +// +// The built-in function hours returns the duration as a floating point number +// of hours. +// +// func hours(d duration) float +// +// If the argument to hours is NULL the result is NULL. +// +// Record id +// +// The built-in function id takes zero or one arguments. If no argument is +// provided, id() returns a table-unique automatically assigned numeric +// identifier of type int. Ids of deleted records are not reused unless the DB +// becomes completely empty (has no tables). +// +// func id() int +// +// For example +// +// SELECT id(), LastName +// FROM employee; +// +// If id() without arguments is called for a row which is not a table record +// then the result value is NULL. +// +// For example +// +// SELECT id(), e.LastName, e.DepartmentID, d.DepartmentID +// FROM +// employee AS e, +// department AS d, +// WHERE e.DepartmentID == d.DepartmentID; +// // Will always return NULL in first field. +// +// SELECT e.ID, e.LastName, e.DepartmentID, d.DepartmentID +// FROM +// (SELECT id() AS ID, LastName, DepartmentID FROM employee) AS e, +// department as d, +// WHERE e.DepartmentID == d.DepartmentID; +// // Will work. +// +// If id() has one argument it must be a table name of a table in a cross join. +// +// For example +// +// SELECT * +// FROM foo, bar +// WHERE bar.fooID == id(foo) +// ORDER BY id(foo); +// +// Length +// +// The built-in function len takes a string argument and returns the lentgh of +// the string in bytes. +// +// func len(s string) int +// +// The expression len(s) is constant if s is a string constant. +// +// If the argument to len is NULL the result is NULL. +// +// Maximum +// +// The built-in aggregate function max returns the largest value of an +// expression in a record set. Max ignores NULL values, but returns NULL if +// all values of a column are NULL or if max is applied to an empty record set. +// +// func max(e expression) typeof(e) // The largest value of the expression. +// +// The expression values must be of an ordered type. +// +// For example +// +// SELECT department, max(sales) FROM t GROUP BY department; +// +// Minimum +// +// The built-in aggregate function min returns the smallest value of an +// expression in a record set. Min ignores NULL values, but returns NULL if +// all values of a column are NULL or if min is applied to an empty record set. +// +// func min(e expression) typeof(e) // The smallest value of the expression. +// +// For example +// +// SELECT a, min(b) FROM t GROUP BY a; +// +// The column values must be of an ordered type. +// +// Minute +// +// The built-in function minute returns the minute offset within the hour +// specified by t, in the range [0, 59]. +// +// func minute(t time) int +// +// If the argument to minute is NULL the result is NULL. +// +// Minutes +// +// The built-in function minutes returns the duration as a floating point +// number of minutes. +// +// func minutes(d duration) float +// +// If the argument to minutes is NULL the result is NULL. +// +// Month +// +// The built-in function month returns the month of the year specified by t +// (January = 1, ...). +// +// func month(t time) int +// +// If the argument to month is NULL the result is NULL. +// +// Nanosecond +// +// The built-in function nanosecond returns the nanosecond offset within the +// second specified by t, in the range [0, 999999999]. +// +// func nanosecond(t time) int +// +// If the argument to nanosecond is NULL the result is NULL. +// +// Nanoseconds +// +// The built-in function nanoseconds returns the duration as an integer +// nanosecond count. +// +// func nanoseconds(d duration) float +// +// If the argument to nanoseconds is NULL the result is NULL. +// +// Now +// +// The built-in function now returns the current local time. +// +// func now() time +// +// Parse time +// +// The built-in function parseTime parses a formatted string and returns the +// time value it represents. The layout defines the format by showing how the +// reference time, +// +// Mon Jan 2 15:04:05 -0700 MST 2006 +// +// would be interpreted if it were the value; it serves as an example of the +// input format. The same interpretation will then be made to the input string. +// +// Elements omitted from the value are assumed to be zero or, when zero is +// impossible, one, so parsing "3:04pm" returns the time corresponding to Jan +// 1, year 0, 15:04:00 UTC (note that because the year is 0, this time is +// before the zero Time). Years must be in the range 0000..9999. The day of the +// week is checked for syntax but it is otherwise ignored. +// +// In the absence of a time zone indicator, parseTime returns a time in UTC. +// +// When parsing a time with a zone offset like -0700, if the offset corresponds +// to a time zone used by the current location, then parseTime uses that +// location and zone in the returned time. Otherwise it records the time as +// being in a fabricated location with time fixed at the given zone offset. +// +// When parsing a time with a zone abbreviation like MST, if the zone +// abbreviation has a defined offset in the current location, then that offset +// is used. The zone abbreviation "UTC" is recognized as UTC regardless of +// location. If the zone abbreviation is unknown, Parse records the time as +// being in a fabricated location with the given zone abbreviation and a zero +// offset. This choice means that such a time can be parses and reformatted +// with the same layout losslessly, but the exact instant used in the +// representation will differ by the actual zone offset. To avoid such +// problems, prefer time layouts that use a numeric zone offset. +// +// func parseTime(layout, value string) time +// +// If any argument to parseTime is NULL the result is NULL. +// +// Second +// +// The built-in function second returns the second offset within the minute +// specified by t, in the range [0, 59]. +// +// func second(t time) int +// +// If the argument to second is NULL the result is NULL. +// +// Seconds +// +// The built-in function seconds returns the duration as a floating point +// number of seconds. +// +// func seconds(d duration) float +// +// If the argument to seconds is NULL the result is NULL. +// +// Since +// +// The built-in function since returns the time elapsed since t. It is +// shorthand for now()-t. +// +// func since(t time) duration +// +// If the argument to since is NULL the result is NULL. +// +// Sum +// +// The built-in aggregate function sum returns the sum of values of an +// expression for all rows of a record set. Sum ignores NULL values, but +// returns NULL if all values of a column are NULL or if sum is applied to an +// empty record set. +// +// func sum(e expression) typeof(e) // The sum of the values of the expression. +// +// The column values must be of a numeric type. +// +// SELECT salesperson, sum(sales) FROM salesforce GROUP BY salesperson; +// +// Time in a specific zone +// +// The built-in function timeIn returns t with the location information set to +// loc. For discussion of the loc argument please see date(). +// +// func timeIn(t time, loc string) time +// +// If any argument to timeIn is NULL the result is NULL. +// +// Weekday +// +// The built-in function weekday returns the day of the week specified by t. +// Sunday == 0, Monday == 1, ... +// +// func weekday(t time) int +// +// If the argument to weekday is NULL the result is NULL. +// +// Year +// +// The built-in function year returns the year in which t occurs. +// +// func year(t time) int +// +// If the argument to year is NULL the result is NULL. +// +// Year day +// +// The built-in function yearDay returns the day of the year specified by t, in +// the range [1,365] for non-leap years, and [1,366] in leap years. +// +// func yearDay(t time) int +// +// If the argument to yearDay is NULL the result is NULL. +// +// Manipulating complex numbers +// +// Three functions assemble and disassemble complex numbers. The built-in +// function complex constructs a complex value from a floating-point real and +// imaginary part, while real and imag extract the real and imaginary parts of +// a complex value. +// +// complex(realPart, imaginaryPart floatT) complexT +// real(complexT) floatT +// imag(complexT) floatT +// +// The type of the arguments and return value correspond. For complex, the two +// arguments must be of the same floating-point type and the return type is the +// complex type with the corresponding floating-point constituents: complex64 +// for float32, complex128 for float64. The real and imag functions together +// form the inverse, so for a complex value z, z == complex(real(z), imag(z)). +// +// If the operands of these functions are all constants, the return value is a +// constant. +// +// complex(2, -2) // complex128 +// complex(1.0, -1.4) // complex128 +// float32(math.Cos(math.Pi/2)) // float32 +// complex(5, float32(-x)) // complex64 +// imag(b) // float64 +// real(complex(5, float32(-x))) // float32 +// +// If any argument to any of complex, real, imag functions is NULL the result +// is NULL. +// +// Size guarantees +// +// For the numeric types, the following sizes are guaranteed +// +// type size in bytes +// +// byte, uint8, int8 1 +// uint16, int16 2 +// uint32, int32, float32 4 +// uint, uint64, int, int64, float64, complex64 8 +// complex128 16 +// +// License +// +// Portions of this specification page are modifications based on work[2] +// created and shared by Google[3] and used according to terms described in the +// Creative Commons 3.0 Attribution License[4]. +// +// This specification is licensed under the Creative Commons Attribution 3.0 +// License, and code is licensed under a BSD license[5]. +// +// References +// +// Links from the above documentation +// +// [1]: http://golang.org/ref/spec#Notation +// [2]: http://golang.org/ref/spec +// [3]: http://code.google.com/policies.html +// [4]: http://creativecommons.org/licenses/by/3.0/ +// [5]: http://golang.org/LICENSE +// [6]: http://golang.org/pkg/regexp/#Regexp.MatchString +// [7]: http://developer.mimer.com/validator/sql-reserved-words.tml +// [8]: http://godoc.org/github.com/cznic/zappy +// [9]: http://www.w3schools.com/sql/sql_default.asp +// [10]: http://en.wikipedia.org/wiki/Join_(SQL)#Outer_join +// +// Implementation details +// +// This section is not part of the specification. +// +// Indices +// +// WARNING: The implementation of indices is new and it surely needs more time +// to become mature. +// +// Indices are used currently used only by the WHERE clause. The following +// expression patterns of 'WHERE expression' are recognized and trigger index +// use. +// +// - WHERE c // For bool typed indexed column c +// - WHERE !c // For bool typed indexed column c +// - WHERE c relOp constExpr // For indexed column c +// - WHERE c relOp parameter // For indexed column c +// - WHERE parameter relOp c // For indexed column c +// - WHERE constExpr relOp c // For indexed column c +// +// The relOp is one of the relation operators <, <=, ==, >=, >. For the +// equality operator both operands must be of comparable types. For all other +// operators both operands must be of ordered types. The constant expression is +// a compile time constant expression. Some constant folding is still a TODO. +// Parameter is a QL parameter ($1 etc.). +// +// Query rewriting +// +// Consider tables t and u, both with an indexed field f. The WHERE expression +// doesn't comply with the above simple detected cases. +// +// SELECT * FROM t, u WHERE t.f < x && u.f < y; +// +// However, such query is now automatically rewritten to +// +// SELECT * FROM +// (SELECT * FROM t WHERE f < x), +// (SELECT * FROM u WHERE f < y); +// +// which will use both of the indices. The impact of using the indices can be +// substantial (cf. BenchmarkCrossJoin*) if the resulting rows have low +// "selectivity", ie. only few rows from both tables are selected by the +// respective WHERE filtering. +// +// Note: Existing QL DBs can be used and indices can be added to them. However, +// once any indices are present in the DB, the old QL versions cannot work with +// such DB anymore. +// +// Benchmarks +// +// Running a benchmark with -v (-test.v) outputs information about the scale +// used to report records/s and a brief description of the benchmark. For +// example +// +// $ go test -run NONE -bench 'SelectMem.*1e[23]' -v +// PASS +// BenchmarkSelectMem1kBx1e2 50000 67680 ns/op 1477537.05 MB/s +// --- BENCH: BenchmarkSelectMem1kBx1e2 +// all_test.go:310: +// ============================================================= +// NOTE: All benchmarks report records/s as 1000000 bytes/s. +// ============================================================= +// all_test.go:321: Having a table of 100 records, each of size 1kB, measure the performance of +// SELECT * FROM t; +// +// BenchmarkSelectMem1kBx1e3 5000 634819 ns/op 1575251.01 MB/s +// --- BENCH: BenchmarkSelectMem1kBx1e3 +// all_test.go:321: Having a table of 1000 records, each of size 1kB, measure the performance of +// SELECT * FROM t; +// +// ok github.com/cznic/ql 7.496s +// $ +// +// Running the full suite of benchmarks takes a lot of time. Use the -timeout +// flag to avoid them being killed after the default time limit (10 minutes). +package ql diff --git a/vendor/github.com/cznic/ql/driver.go b/vendor/github.com/cznic/ql/driver.go new file mode 100644 index 0000000000..b660e4cb65 --- /dev/null +++ b/vendor/github.com/cznic/ql/driver.go @@ -0,0 +1,523 @@ +// Copyright 2014 The ql Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// database/sql/driver + +package ql + +import ( + "bytes" + "database/sql" + "database/sql/driver" + "errors" + "fmt" + "io" + "math/big" + "os" + "path/filepath" + "strings" + "sync" + "time" +) + +var ( + _ driver.Conn = (*driverConn)(nil) + _ driver.Driver = (*sqlDriver)(nil) + _ driver.Execer = (*driverConn)(nil) + _ driver.Queryer = (*driverConn)(nil) + _ driver.Result = (*driverResult)(nil) + _ driver.Rows = (*driverRows)(nil) + _ driver.Stmt = (*driverStmt)(nil) + _ driver.Tx = (*driverConn)(nil) + + txBegin = MustCompile("BEGIN TRANSACTION;") + txCommit = MustCompile("COMMIT;") + txRollback = MustCompile("ROLLBACK;") + + errNoResult = errors.New("query statement does not produce a result set (no top level SELECT)") +) + +type errList []error + +func (e *errList) append(err error) { + if err != nil { + *e = append(*e, err) + } +} + +func (e errList) error() error { + if len(e) == 0 { + return nil + } + + return e +} + +func (e errList) Error() string { + a := make([]string, len(e)) + for i, v := range e { + a[i] = v.Error() + } + return strings.Join(a, "\n") +} + +func params(args []driver.Value) []interface{} { + r := make([]interface{}, len(args)) + for i, v := range args { + r[i] = interface{}(v) + } + return r +} + +var ( + fileDriver = &sqlDriver{dbs: map[string]*driverDB{}} + fileDriverOnce sync.Once + memDriver = &sqlDriver{isMem: true, dbs: map[string]*driverDB{}} + memDriverOnce sync.Once +) + +// RegisterDriver registers a QL database/sql/driver[0] named "ql". The name +// parameter of +// +// sql.Open("ql", name) +// +// is interpreted as a path name to a named DB file which will be created if +// not present. The underlying QL database data are persisted on db.Close(). +// RegisterDriver can be safely called multiple times, it'll register the +// driver only once. +// +// The name argument can be optionally prefixed by "file://". In that case the +// prefix is stripped before interpreting it as a file name. +// +// The name argument can be optionally prefixed by "memory://". In that case +// the prefix is stripped before interpreting it as a name of a memory-only, +// volatile DB. +// +// [0]: http://golang.org/pkg/database/sql/driver/ +func RegisterDriver() { + fileDriverOnce.Do(func() { sql.Register("ql", fileDriver) }) +} + +// RegisterMemDriver registers a QL memory database/sql/driver[0] named +// "ql-mem". The name parameter of +// +// sql.Open("ql-mem", name) +// +// is interpreted as an unique memory DB name which will be created if not +// present. The underlying QL memory database data are not persisted on +// db.Close(). RegisterMemDriver can be safely called multiple times, it'll +// register the driver only once. +// +// [0]: http://golang.org/pkg/database/sql/driver/ +func RegisterMemDriver() { + memDriverOnce.Do(func() { sql.Register("ql-mem", memDriver) }) +} + +type driverDB struct { + db *DB + name string + refcount int +} + +func newDriverDB(db *DB, name string) *driverDB { + return &driverDB{db: db, name: name, refcount: 1} +} + +// sqlDriver implements the interface required by database/sql/driver. +type sqlDriver struct { + dbs map[string]*driverDB + isMem bool + mu sync.Mutex +} + +func (d *sqlDriver) lock() func() { + d.mu.Lock() + return d.mu.Unlock +} + +// Open returns a new connection to the database. The name is a string in a +// driver-specific format. +// +// Open may return a cached connection (one previously closed), but doing so is +// unnecessary; the sql package maintains a pool of idle connections for +// efficient re-use. +// +// The returned connection is only used by one goroutine at a time. +func (d *sqlDriver) Open(name string) (driver.Conn, error) { + if d != fileDriver && d != memDriver { + return nil, fmt.Errorf("open: unexpected/unsupported instance of driver.Driver: %p", d) + } + + switch { + case d == fileDriver && strings.HasPrefix(name, "file://"): + name = name[len("file://"):] + case d == fileDriver && strings.HasPrefix(name, "memory://"): + d = memDriver + name = name[len("memory://"):] + } + name = filepath.Clean(name) + if name == "" || name == "." || name == string(os.PathSeparator) { + return nil, fmt.Errorf("invalid DB name %q", name) + } + + defer d.lock()() + db := d.dbs[name] + if db == nil { + var err error + var db0 *DB + switch d.isMem { + case true: + db0, err = OpenMem() + default: + db0, err = OpenFile(name, &Options{CanCreate: true}) + } + if err != nil { + return nil, err + } + + db = newDriverDB(db0, name) + d.dbs[name] = db + return newDriverConn(d, db), nil + } + + db.refcount++ + return newDriverConn(d, db), nil +} + +// driverConn is a connection to a database. It is not used concurrently by +// multiple goroutines. +// +// Conn is assumed to be stateful. +type driverConn struct { + ctx *TCtx + db *driverDB + driver *sqlDriver + stop map[*driverStmt]struct{} + tnl int +} + +func newDriverConn(d *sqlDriver, ddb *driverDB) driver.Conn { + r := &driverConn{ + db: ddb, + driver: d, + stop: map[*driverStmt]struct{}{}, + } + return r +} + +// Prepare returns a prepared statement, bound to this connection. +func (c *driverConn) Prepare(query string) (driver.Stmt, error) { + list, err := Compile(query) + if err != nil { + return nil, err + } + + s := &driverStmt{conn: c, stmt: list} + c.stop[s] = struct{}{} + return s, nil +} + +// Close invalidates and potentially stops any current prepared statements and +// transactions, marking this connection as no longer in use. +// +// Because the sql package maintains a free pool of connections and only calls +// Close when there's a surplus of idle connections, it shouldn't be necessary +// for drivers to do their own connection caching. +func (c *driverConn) Close() error { + var err errList + for s := range c.stop { + err.append(s.Close()) + } + defer c.driver.lock()() + dbs, name := c.driver.dbs, c.db.name + v := dbs[name] + v.refcount-- + if v.refcount == 0 { + err.append(c.db.db.Close()) + delete(dbs, name) + } + return err.error() +} + +// Begin starts and returns a new transaction. +func (c *driverConn) Begin() (driver.Tx, error) { + if c.ctx == nil { + c.ctx = NewRWCtx() + } + + if _, _, err := c.db.db.Execute(c.ctx, txBegin); err != nil { + return nil, err + } + + c.tnl++ + return c, nil +} + +func (c *driverConn) Commit() error { + if c.tnl == 0 || c.ctx == nil { + return errCommitNotInTransaction + } + + if _, _, err := c.db.db.Execute(c.ctx, txCommit); err != nil { + return err + } + + c.tnl-- + if c.tnl == 0 { + c.ctx = nil + } + return nil +} + +func (c *driverConn) Rollback() error { + if c.tnl == 0 || c.ctx == nil { + return errRollbackNotInTransaction + } + + if _, _, err := c.db.db.Execute(c.ctx, txRollback); err != nil { + return err + } + + c.tnl-- + if c.tnl == 0 { + c.ctx = nil + } + return nil +} + +// Execer is an optional interface that may be implemented by a Conn. +// +// If a Conn does not implement Execer, the sql package's DB.Exec will first +// prepare a query, execute the statement, and then close the statement. +// +// Exec may return driver.ErrSkip. +func (c *driverConn) Exec(query string, args []driver.Value) (driver.Result, error) { + list, err := Compile(query) + if err != nil { + return nil, err + } + + return driverExec(c.db, c.ctx, list, args) +} + +func driverExec(db *driverDB, ctx *TCtx, list List, args []driver.Value) (driver.Result, error) { + if _, _, err := db.db.Execute(ctx, list, params(args)...); err != nil { + return nil, err + } + + if len(list.l) == 1 { + switch list.l[0].(type) { + case *createTableStmt, *dropTableStmt, *alterTableAddStmt, + *alterTableDropColumnStmt, *truncateTableStmt: + return driver.ResultNoRows, nil + } + } + + r := &driverResult{} + if ctx != nil { + r.lastInsertID, r.rowsAffected = ctx.LastInsertID, ctx.RowsAffected + } + return r, nil +} + +// Queryer is an optional interface that may be implemented by a Conn. +// +// If a Conn does not implement Queryer, the sql package's DB.Query will first +// prepare a query, execute the statement, and then close the statement. +// +// Query may return driver.ErrSkip. +func (c *driverConn) Query(query string, args []driver.Value) (driver.Rows, error) { + list, err := Compile(query) + if err != nil { + return nil, err + } + + return driverQuery(c.db, c.ctx, list, args) +} + +func driverQuery(db *driverDB, ctx *TCtx, list List, args []driver.Value) (driver.Rows, error) { + rss, _, err := db.db.Execute(ctx, list, params(args)...) + if err != nil { + return nil, err + } + + switch n := len(rss); n { + case 0: + return nil, errNoResult + case 1: + return newdriverRows(rss[len(rss)-1]), nil + default: + return nil, fmt.Errorf("query produced %d result sets, expected only one", n) + } +} + +// driverResult is the result of a query execution. +type driverResult struct { + lastInsertID int64 + rowsAffected int64 +} + +// LastInsertId returns the database's auto-generated ID after, for example, an +// INSERT into a table with primary key. +func (r *driverResult) LastInsertId() (int64, error) { // -golint + return r.lastInsertID, nil +} + +// RowsAffected returns the number of rows affected by the query. +func (r *driverResult) RowsAffected() (int64, error) { + return r.rowsAffected, nil +} + +// driverRows is an iterator over an executed query's results. +type driverRows struct { + rs Recordset + done chan int + rows chan interface{} +} + +func newdriverRows(rs Recordset) *driverRows { + r := &driverRows{ + rs: rs, + done: make(chan int), + rows: make(chan interface{}, 500), + } + go func() { + err := io.EOF + if e := r.rs.Do(false, func(data []interface{}) (bool, error) { + select { + case r.rows <- data: + return true, nil + case <-r.done: + return false, nil + } + }); e != nil { + err = e + } + + select { + case r.rows <- err: + case <-r.done: + } + }() + return r +} + +// Columns returns the names of the columns. The number of columns of the +// result is inferred from the length of the slice. If a particular column +// name isn't known, an empty string should be returned for that entry. +func (r *driverRows) Columns() []string { + f, _ := r.rs.Fields() + return f +} + +// Close closes the rows iterator. +func (r *driverRows) Close() error { + close(r.done) + return nil +} + +// Next is called to populate the next row of data into the provided slice. The +// provided slice will be the same size as the Columns() are wide. +// +// The dest slice may be populated only with a driver Value type, but excluding +// string. All string values must be converted to []byte. +// +// Next should return io.EOF when there are no more rows. +func (r *driverRows) Next(dest []driver.Value) error { + select { + case rx := <-r.rows: + switch x := rx.(type) { + case error: + return x + case []interface{}: + if g, e := len(x), len(dest); g != e { + return fmt.Errorf("field count mismatch: got %d, need %d", g, e) + } + + for i, xi := range x { + switch v := xi.(type) { + case nil, int64, float64, bool, []byte, time.Time: + dest[i] = v + case complex64, complex128, *big.Int, *big.Rat: + var buf bytes.Buffer + fmt.Fprintf(&buf, "%v", v) + dest[i] = buf.Bytes() + case int8: + dest[i] = int64(v) + case int16: + dest[i] = int64(v) + case int32: + dest[i] = int64(v) + case int: + dest[i] = int64(v) + case uint8: + dest[i] = int64(v) + case uint16: + dest[i] = int64(v) + case uint32: + dest[i] = int64(v) + case uint64: + dest[i] = int64(v) + case uint: + dest[i] = int64(v) + case time.Duration: + dest[i] = int64(v) + case string: + dest[i] = []byte(v) + default: + return fmt.Errorf("internal error 004") + } + } + return nil + default: + return fmt.Errorf("internal error 005") + } + case <-r.done: + return io.EOF + } +} + +// driverStmt is a prepared statement. It is bound to a driverConn and not used +// by multiple goroutines concurrently. +type driverStmt struct { + conn *driverConn + stmt List +} + +// Close closes the statement. +// +// As of Go 1.1, a Stmt will not be closed if it's in use by any queries. +func (s *driverStmt) Close() error { + delete(s.conn.stop, s) + return nil +} + +// NumInput returns the number of placeholder parameters. +// +// If NumInput returns >= 0, the sql package will sanity check argument counts +// from callers and return errors to the caller before the statement's Exec or +// Query methods are called. +// +// NumInput may also return -1, if the driver doesn't know its number of +// placeholders. In that case, the sql package will not sanity check Exec or +// Query argument counts. +func (s *driverStmt) NumInput() int { + if x := s.stmt; len(x.l) == 1 { + return x.params + } + + return -1 +} + +// Exec executes a query that doesn't return rows, such as an INSERT or UPDATE. +func (s *driverStmt) Exec(args []driver.Value) (driver.Result, error) { + c := s.conn + return driverExec(c.db, c.ctx, s.stmt, args) +} + +// Exec executes a query that may return rows, such as a SELECT. +func (s *driverStmt) Query(args []driver.Value) (driver.Rows, error) { + c := s.conn + return driverQuery(c.db, c.ctx, s.stmt, args) +} diff --git a/vendor/github.com/cznic/ql/driver/driver.go b/vendor/github.com/cznic/ql/driver/driver.go new file mode 100644 index 0000000000..557c70d828 --- /dev/null +++ b/vendor/github.com/cznic/ql/driver/driver.go @@ -0,0 +1,61 @@ +// Copyright 2014 The ql 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 driver registers a QL sql/driver named "ql" and a memory driver named "ql-mem". + +See also [0], [1] and [3]. + +Usage + +A skeleton program using ql/driver. + + package main + + import ( + "database/sql" + + _ "github.com/cznic/ql/driver" + ) + + func main() { + ... + // Disk file DB + db, err := sql.Open("ql", "ql.db") // [2] + // alternatively + db, err := sql.Open("ql", "file://ql.db") + + // and/or + + // RAM DB + mdb, err := sql.Open("ql-mem", "mem.db") + // alternatively + mdb, err := sql.Open("ql", "memory://mem.db") + if err != nil { + log.Fatal(err) + } + + // Use db/mdb here + ... + } + +This package exports nothing. + +Links + +Referenced from above: + + [0]: http://godoc.org/github.com/cznic/ql + [1]: http://golang.org/pkg/database/sql/ + [2]: http://golang.org/pkg/database/sql/#Open + [3]: http://golang.org/pkg/database/sql/driver +*/ +package driver + +import "github.com/cznic/ql" + +func init() { + ql.RegisterDriver() + ql.RegisterMemDriver() +} diff --git a/vendor/github.com/cznic/ql/errors.go b/vendor/github.com/cznic/ql/errors.go new file mode 100644 index 0000000000..305414f4a9 --- /dev/null +++ b/vendor/github.com/cznic/ql/errors.go @@ -0,0 +1,18 @@ +// Copyright 2014 The ql 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 ql + +import ( + "errors" +) + +var ( + errBeginTransNoCtx = errors.New("BEGIN TRANSACTION: Must use R/W context, have nil") + errCommitNotInTransaction = errors.New("COMMIT: Not in transaction") + errDivByZero = errors.New("division by zero") + errIncompatibleDBFormat = errors.New("incompatible DB format") + errNoDataForHandle = errors.New("read: no data for handle") + errRollbackNotInTransaction = errors.New("ROLLBACK: Not in transaction") +) diff --git a/vendor/github.com/cznic/ql/etc.go b/vendor/github.com/cznic/ql/etc.go new file mode 100644 index 0000000000..c2e1524af0 --- /dev/null +++ b/vendor/github.com/cznic/ql/etc.go @@ -0,0 +1,2805 @@ +// Copyright 2014 The ql 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 ql + +import ( + "bytes" + "fmt" + "io" + "math" + "math/big" + "strings" + "time" +) + +// QL types. +const ( + qBool = 0x62 // 'b' + qComplex64 = 0x63 // 'c' + qComplex128 = 0x64 // 'd' + qFloat32 = 0x66 // 'f' + qFloat64 = 0x67 // 'g', alias float + qInt8 = 0x69 // 'i' + qInt16 = 0x6a // 'j' + qInt32 = 0x6b // 'k' + qInt64 = 0x6c // 'l', alias int + qString = 0x73 // 's' + qUint8 = 0x75 // 'u', alias byte + qUint16 = 0x76 // 'v' + qUint32 = 0x77 // 'w' + qUint64 = 0x78 // 'x', alias uint + + qBigInt = 0x49 // 'I' + qBigRat = 0x52 // 'R' + qBlob = 0x42 // 'B' + qDuration = 0x44 // 'D' + qTime = 0x54 // 'T' +) + +var ( + type2Str = map[int]string{ + qBigInt: "bigint", + qBigRat: "bigrat", + qBlob: "blob", + qBool: "bool", + qComplex128: "complex128", + qComplex64: "complex64", + qDuration: "duration", + qFloat32: "float32", + qFloat64: "float64", + qInt16: "int16", + qInt32: "int32", + qInt64: "int64", + qInt8: "int8", + qString: "string", + qTime: "time", + qUint16: "uint16", + qUint32: "uint32", + qUint64: "uint64", + qUint8: "uint8", + } +) + +func typeStr(typ int) (r string) { + return type2Str[typ] +} + +func noEOF(err error) error { + if err == io.EOF { + err = nil + } + return err +} + +func runErr(err error) error { return fmt.Errorf("run time error: %s", err) } + +func invXOp(s, x interface{}) error { + return fmt.Errorf("invalid operation: %v[%v] (index of type %T)", s, x, x) +} + +func invSOp(s interface{}) error { + return fmt.Errorf("cannot slice %s (type %T)", s, s) +} + +func invNegX(x interface{}) error { + return fmt.Errorf("invalid string index %v (index must be non-negative)", x) +} + +func invNegLO(x interface{}) error { + return fmt.Errorf("invalid LIMIT or OFFSET value %v (must be non-negative)", x) +} + +func invSliceNegX(x interface{}) error { + return fmt.Errorf("invalid slice index %v (index must be non-negative)", x) +} + +func invBoundX(s string, x uint64) error { + return fmt.Errorf("invalid string index %d (out of bounds for %d-byte string)", x, len(s)) +} + +func invSliceBoundX(s string, x uint64) error { + return fmt.Errorf("invalid slice index %d (out of bounds for %d-byte string)", x, len(s)) +} + +func intExpr(x interface{}) (i int64, err error) { + switch x := x.(type) { + case idealInt: + if x < 0 { + return 0, invNegLO(x) + } + + return int64(x), nil + case idealRune: + if x < 0 { + return 0, invNegLO(x) + } + + return int64(x), nil + case idealUint: + if x < 0 { + return 0, invNegLO(x) + } + + return int64(x), nil + case int8: + if x < 0 { + return 0, invNegLO(x) + } + + return int64(x), nil + case int16: + if x < 0 { + return 0, invNegLO(x) + } + + return int64(x), nil + case int32: + if x < 0 { + return 0, invNegLO(x) + } + + return int64(x), nil + case int64: + if x < 0 { + return 0, invNegLO(x) + } + + return int64(x), nil + case uint8: + return int64(x), nil + case uint16: + return int64(x), nil + case uint32: + return int64(x), nil + case uint64: + return int64(x), nil + default: + return 0, fmt.Errorf("non-integer expression: %v (value of type %T)", x, x) + } +} + +func limOffExpr(x interface{}) (i uint64, err error) { + switch x := x.(type) { + case idealInt: + if x < 0 { + return 0, invNegLO(x) + } + + return uint64(x), nil + case idealRune: + if x < 0 { + return 0, invNegLO(x) + } + + return uint64(x), nil + case idealUint: + if x < 0 { + return 0, invNegLO(x) + } + + return uint64(x), nil + case int8: + if x < 0 { + return 0, invNegLO(x) + } + + return uint64(x), nil + case int16: + if x < 0 { + return 0, invNegLO(x) + } + + return uint64(x), nil + case int32: + if x < 0 { + return 0, invNegLO(x) + } + + return uint64(x), nil + case int64: + if x < 0 { + return 0, invNegLO(x) + } + + return uint64(x), nil + case uint8: + return uint64(x), nil + case uint16: + return uint64(x), nil + case uint32: + return uint64(x), nil + case uint64: + return uint64(x), nil + default: + return 0, fmt.Errorf("non-integer used in LIMIT or OFFSET: %v (value of type %T)", x, x) + } +} + +func indexExpr(s *string, x interface{}) (i uint64, err error) { + switch x := x.(type) { + case idealFloat: + if x < 0 { + return 0, invNegX(x) + } + + if s != nil && int(x) >= len(*s) { + return 0, invBoundX(*s, uint64(x)) + } + + return uint64(x), nil + case idealInt: + if x < 0 { + return 0, invNegX(x) + } + + if s != nil && int64(x) >= int64(len(*s)) { + return 0, invBoundX(*s, uint64(x)) + } + + return uint64(x), nil + case idealRune: + if x < 0 { + return 0, invNegX(x) + } + + if s != nil && int32(x) >= int32(len(*s)) { + return 0, invBoundX(*s, uint64(x)) + } + + return uint64(x), nil + case idealUint: + if x < 0 { + return 0, invNegX(x) + } + + if s != nil && uint64(x) >= uint64(len(*s)) { + return 0, invBoundX(*s, uint64(x)) + } + + return uint64(x), nil + case int8: + if x < 0 { + return 0, invNegX(x) + } + + if s != nil && int(x) >= len(*s) { + return 0, invBoundX(*s, uint64(x)) + } + + return uint64(x), nil + case int16: + if x < 0 { + return 0, invNegX(x) + } + + if s != nil && int(x) >= len(*s) { + return 0, invBoundX(*s, uint64(x)) + } + + return uint64(x), nil + case int32: + if x < 0 { + return 0, invNegX(x) + } + + if s != nil && int(x) >= len(*s) { + return 0, invBoundX(*s, uint64(x)) + } + + return uint64(x), nil + case int64: + if x < 0 { + return 0, invNegX(x) + } + + if s != nil && x >= int64(len(*s)) { + return 0, invBoundX(*s, uint64(x)) + } + + return uint64(x), nil + case uint8: + if s != nil && int(x) >= len(*s) { + return 0, invBoundX(*s, uint64(x)) + } + + return uint64(x), nil + case uint16: + if s != nil && int(x) >= len(*s) { + return 0, invBoundX(*s, uint64(x)) + } + + return uint64(x), nil + case uint32: + if s != nil && x >= uint32(len(*s)) { + return 0, invBoundX(*s, uint64(x)) + } + + return uint64(x), nil + case uint64: + if s != nil && x >= uint64(len(*s)) { + return 0, invBoundX(*s, uint64(x)) + } + + return uint64(x), nil + default: + return 0, fmt.Errorf("non-integer string index %v (value of type %T)", x, x) + } +} + +func sliceExpr(s *string, x interface{}, mod int) (i uint64, err error) { + switch x := x.(type) { + case idealFloat: + if x < 0 { + return 0, invSliceNegX(x) + } + + if s != nil && int(x) >= len(*s)+mod { + return 0, invSliceBoundX(*s, uint64(x)) + } + + return uint64(x), nil + case idealInt: + if x < 0 { + return 0, invSliceNegX(x) + } + + if s != nil && int64(x) >= int64(len(*s)+mod) { + return 0, invSliceBoundX(*s, uint64(x)) + } + + return uint64(x), nil + case idealRune: + if x < 0 { + return 0, invSliceNegX(x) + } + + if s != nil && int32(x) >= int32(len(*s)+mod) { + return 0, invSliceBoundX(*s, uint64(x)) + } + + return uint64(x), nil + case idealUint: + if x < 0 { + return 0, invSliceNegX(x) + } + + if s != nil && uint64(x) >= uint64(len(*s)+mod) { + return 0, invSliceBoundX(*s, uint64(x)) + } + + return uint64(x), nil + case int8: + if x < 0 { + return 0, invSliceNegX(x) + } + + if s != nil && int(x) >= len(*s)+mod { + return 0, invSliceBoundX(*s, uint64(x)) + } + + return uint64(x), nil + case int16: + if x < 0 { + return 0, invSliceNegX(x) + } + + if s != nil && int(x) >= len(*s)+mod { + return 0, invSliceBoundX(*s, uint64(x)) + } + + return uint64(x), nil + case int32: + if x < 0 { + return 0, invSliceNegX(x) + } + + if s != nil && int(x) >= len(*s)+mod { + return 0, invSliceBoundX(*s, uint64(x)) + } + + return uint64(x), nil + case int64: + if x < 0 { + return 0, invSliceNegX(x) + } + + if s != nil && x >= int64(len(*s)+mod) { + return 0, invSliceBoundX(*s, uint64(x)) + } + + return uint64(x), nil + case uint8: + if s != nil && int(x) >= len(*s)+mod { + return 0, invSliceBoundX(*s, uint64(x)) + } + + return uint64(x), nil + case uint16: + if s != nil && int(x) >= len(*s)+mod { + return 0, invSliceBoundX(*s, uint64(x)) + } + + return uint64(x), nil + case uint32: + if s != nil && x >= uint32(len(*s)+mod) { + return 0, invSliceBoundX(*s, uint64(x)) + } + + return uint64(x), nil + case uint64: + if s != nil && x >= uint64(len(*s)+mod) { + return 0, invSliceBoundX(*s, uint64(x)) + } + + return uint64(x), nil + default: + return 0, fmt.Errorf("invalid slice index %s (type %T)", x, x) + } +} + +type iop int + +func (o iop) String() string { + switch i := int(o); i { + case andand: + return "&&" + case andnot: + return "&^" + case lsh: + return "<<" + case le: + return "<=" + case eq: + return "==" + case ge: + return ">=" + case neq: + return "!=" + case oror: + return "||" + case rsh: + return ">>" + default: + return string(i) + } +} + +func ideal(v interface{}) interface{} { + switch x := v.(type) { + case idealComplex: + return complex128(x) + case idealFloat: + return float64(x) + case idealInt: + return int64(x) + case idealRune: + return int64(x) + case idealUint: + return uint64(x) + default: + return v + } +} + +func eval(v expression, execCtx *execCtx, ctx map[interface{}]interface{}) (y interface{}) { + y, err := expand1(v.eval(execCtx, ctx)) + if err != nil { + panic(err) // panic ok here + } + return +} + +func eval2(a, b expression, execCtx *execCtx, ctx map[interface{}]interface{}) (x, y interface{}) { + return eval(a, execCtx, ctx), eval(b, execCtx, ctx) +} + +func invOp2(x, y interface{}, o int) (interface{}, error) { + return nil, fmt.Errorf("invalid operation: %v %v %v (mismatched types %T and %T)", x, iop(o), y, ideal(x), ideal(y)) +} + +func undOp(x interface{}, o int) (interface{}, error) { + return nil, fmt.Errorf("invalid operation: %v%v (operator %v not defined on %T)", iop(o), x, iop(o), x) +} + +func undOp2(x, y interface{}, o int) (interface{}, error) { + return nil, fmt.Errorf("invalid operation: %v %v %v (operator %v not defined on %T)", x, iop(o), y, iop(o), x) +} + +func invConv(val interface{}, typ int) (interface{}, error) { + return nil, fmt.Errorf("cannot convert %v (type %T) to type %s", val, val, typeStr(typ)) +} + +func truncConv(val interface{}) (interface{}, error) { + return nil, fmt.Errorf("constant %v truncated to integer", val) +} + +func convert(val interface{}, typ int) (v interface{}, err error) { //NTYPE + if val == nil { + return nil, nil + } + + switch typ { + case qBool: + switch x := val.(type) { + //case nil: + //case idealComplex: + //case idealFloat: + //case idealInt: + //case idealRune: + //case idealUint: + case bool: + return bool(x), nil + //case complex64: + //case complex128: + //case float32: + //case float64: + //case int8: + //case int16: + //case int32: + //case int64: + //case string: + //case uint8: + //case uint16: + //case uint32: + //case uint64: + default: + return invConv(val, typ) + } + case qComplex64: + switch x := val.(type) { + //case nil: + case idealComplex: + return complex64(x), nil + case idealFloat: + return complex(float32(x), 0), nil + case idealInt: + return complex(float32(x), 0), nil + case idealRune: + return complex(float32(x), 0), nil + case idealUint: + return complex(float32(x), 0), nil + //case bool: + case complex64: + return complex64(x), nil + case complex128: + return complex64(x), nil + //case float32: + //case float64: + //case int8: + //case int16: + //case int32: + //case int64: + //case string: + //case uint8: + //case uint16: + //case uint32: + //case uint64: + default: + return invConv(val, typ) + } + case qComplex128: + switch x := val.(type) { + //case nil: + case idealComplex: + return complex128(x), nil + case idealFloat: + return complex(float64(x), 0), nil + case idealInt: + return complex(float64(x), 0), nil + case idealRune: + return complex(float64(x), 0), nil + case idealUint: + return complex(float64(x), 0), nil + //case bool: + case complex64: + return complex128(x), nil + case complex128: + return complex128(x), nil + //case float32: + //case float64: + //case int8: + //case int16: + //case int32: + //case int64: + //case string: + //case uint8: + //case uint16: + //case uint32: + //case uint64: + default: + return invConv(val, typ) + } + case qFloat32: + switch x := val.(type) { + //case nil: + //case idealComplex: + case idealFloat: + return float32(x), nil + case idealInt: + return float32(x), nil + case idealRune: + return float32(x), nil + case idealUint: + return float32(x), nil + //case bool: + //case complex64: + //case complex128: + case float32: + return float32(x), nil + case float64: + return float32(x), nil + case int8: + return float32(x), nil + case int16: + return float32(x), nil + case int32: + return float32(x), nil + case int64: + return float32(x), nil + //case string: + case uint8: + return float32(x), nil + case uint16: + return float32(x), nil + case uint32: + return float32(x), nil + case uint64: + return float32(x), nil + case *big.Int: + v, _ := big.NewRat(1, 1).SetInt(x).Float64() + return float32(v), nil + case *big.Rat: + v, _ := x.Float64() + return float32(v), nil + case time.Duration: + return float32(x), nil + default: + return invConv(val, typ) + } + case qFloat64: + switch x := val.(type) { + //case nil: + //case idealComplex: + case idealFloat: + return float64(x), nil + case idealInt: + return float64(x), nil + case idealRune: + return float64(x), nil + case idealUint: + return float64(x), nil + //case bool: + //case complex64: + //case complex128: + case float32: + return float64(x), nil + case float64: + return float64(x), nil + case int8: + return float64(x), nil + case int16: + return float64(x), nil + case int32: + return float64(x), nil + case int64: + return float64(x), nil + //case string: + case uint8: + return float64(x), nil + case uint16: + return float64(x), nil + case uint32: + return float64(x), nil + case uint64: + return float64(x), nil + case *big.Int: + v, _ := big.NewRat(1, 1).SetInt(x).Float64() + return v, nil + case *big.Rat: + v, _ := x.Float64() + return v, nil + case time.Duration: + return float64(x), nil + default: + return invConv(val, typ) + } + case qInt8: + switch x := val.(type) { + //case nil: + //case idealComplex: + case idealFloat: + if _, frac := math.Modf(float64(x)); frac != 0 { + return truncConv(x) + } + + return int8(x), nil + case idealInt: + return int8(x), nil + case idealRune: + return int8(x), nil + case idealUint: + return int8(x), nil + //case bool: + //case complex64: + //case complex128: + case float32: + return int8(x), nil + case float64: + return int8(x), nil + case int8: + return int8(x), nil + case int16: + return int8(x), nil + case int32: + return int8(x), nil + case int64: + return int8(x), nil + //case string: + case uint8: + return int8(x), nil + case uint16: + return int8(x), nil + case uint32: + return int8(x), nil + case uint64: + return int8(x), nil + case *big.Int: + return int8(x.Int64()), nil + case time.Duration: + return int8(x), nil + default: + return invConv(val, typ) + } + case qInt16: + switch x := val.(type) { + //case nil: + //case idealComplex: + case idealFloat: + if _, frac := math.Modf(float64(x)); frac != 0 { + return truncConv(x) + } + + return int16(x), nil + case idealInt: + return int16(x), nil + case idealRune: + return int16(x), nil + case idealUint: + return int16(x), nil + //case bool: + //case complex64: + //case complex128: + case float32: + return int16(x), nil + case float64: + return int16(x), nil + case int8: + return int16(x), nil + case int16: + return int16(x), nil + case int32: + return int16(x), nil + case int64: + return int16(x), nil + //case string: + case uint8: + return int16(x), nil + case uint16: + return int16(x), nil + case uint32: + return int16(x), nil + case uint64: + return int16(x), nil + case *big.Int: + return int16(x.Int64()), nil + case time.Duration: + return int16(x), nil + default: + return invConv(val, typ) + } + case qInt32: + switch x := val.(type) { + //case nil: + //case idealComplex: + case idealFloat: + if _, frac := math.Modf(float64(x)); frac != 0 { + return truncConv(x) + } + + return int32(x), nil + case idealInt: + return int32(x), nil + case idealRune: + return int32(x), nil + case idealUint: + return int32(x), nil + //case bool: + //case complex64: + //case complex128: + case float32: + return int32(x), nil + case float64: + return int32(x), nil + case int8: + return int32(x), nil + case int16: + return int32(x), nil + case int32: + return int32(x), nil + case int64: + return int32(x), nil + //case string: + case uint8: + return int32(x), nil + case uint16: + return int32(x), nil + case uint32: + return int32(x), nil + case uint64: + return int32(x), nil + case *big.Int: + return int32(x.Int64()), nil + case time.Duration: + return int32(x), nil + default: + return invConv(val, typ) + } + case qInt64: + switch x := val.(type) { + //case nil: + //case idealComplex: + case idealFloat: + if _, frac := math.Modf(float64(x)); frac != 0 { + return truncConv(x) + } + + return int64(x), nil + case idealInt: + return int64(x), nil + case idealRune: + return int64(x), nil + case idealUint: + return int64(x), nil + //case bool: + //case complex64: + //case complex128: + case float32: + return int64(x), nil + case float64: + return int64(x), nil + case int8: + return int64(x), nil + case int16: + return int64(x), nil + case int32: + return int64(x), nil + case int64: + return int64(x), nil + //case string: + case uint8: + return int64(x), nil + case uint16: + return int64(x), nil + case uint32: + return int64(x), nil + case uint64: + return int64(x), nil + case *big.Int: + return x.Int64(), nil + case time.Duration: + return int64(x), nil + default: + return invConv(val, typ) + } + case qString: + switch x := val.(type) { + //case nil: + //case idealComplex: + //case idealFloat: + case idealInt: + return string(x), nil + case idealRune: + return string(x), nil + case idealUint: + return string(x), nil + //case bool: + //case complex64: + //case complex128: + //case float32: + //case float64: + case int8: + return string(x), nil + case int16: + return string(x), nil + case int32: + return string(x), nil + case int64: + return string(x), nil + case string: + return string(x), nil + case uint8: + return string(x), nil + case uint16: + return string(x), nil + case uint32: + return string(x), nil + case uint64: + return string(x), nil + case []byte: + return string(x), nil + case *big.Int: + return x.String(), nil + case time.Time: + return x.String(), nil + case time.Duration: + return x.String(), nil + default: + return invConv(val, typ) + } + case qUint8: + switch x := val.(type) { + //case nil: + //case idealComplex: + case idealFloat: + if _, frac := math.Modf(float64(x)); frac != 0 { + return truncConv(x) + } + + return uint8(x), nil + case idealInt: + return uint8(x), nil + case idealRune: + return uint8(x), nil + case idealUint: + return uint8(x), nil + //case bool: + //case complex64: + //case complex128: + case float32: + return uint8(x), nil + case float64: + return uint8(x), nil + case int8: + return uint8(x), nil + case int16: + return uint8(x), nil + case int32: + return uint8(x), nil + case int64: + return uint8(x), nil + //case string: + case uint8: + return uint8(x), nil + case uint16: + return uint8(x), nil + case uint32: + return uint8(x), nil + case uint64: + return uint8(x), nil + case *big.Int: + return uint8(x.Int64()), nil + case time.Duration: + return uint8(x), nil + default: + return invConv(val, typ) + } + case qUint16: + switch x := val.(type) { + //case nil: + //case idealComplex: + case idealFloat: + if _, frac := math.Modf(float64(x)); frac != 0 { + return truncConv(x) + } + + return uint16(x), nil + case idealInt: + return uint16(x), nil + case idealRune: + return uint16(x), nil + case idealUint: + return uint16(x), nil + //case bool: + //case complex64: + //case complex128: + case float32: + return uint16(x), nil + case float64: + return uint16(x), nil + case int8: + return uint16(x), nil + case int16: + return uint16(x), nil + case int32: + return uint16(x), nil + case int64: + return uint16(x), nil + //case string: + case uint8: + return uint16(x), nil + case uint16: + return uint16(x), nil + case uint32: + return uint16(x), nil + case uint64: + return uint16(x), nil + case *big.Int: + return uint16(x.Int64()), nil + case time.Duration: + return uint16(x), nil + default: + return invConv(val, typ) + } + case qUint32: + switch x := val.(type) { + //case nil: + //case idealComplex: + case idealFloat: + if _, frac := math.Modf(float64(x)); frac != 0 { + return truncConv(x) + } + + return uint32(x), nil + case idealInt: + return uint32(x), nil + case idealRune: + return uint32(x), nil + case idealUint: + return uint32(x), nil + //case bool: + //case complex64: + //case complex128: + case float32: + return uint32(x), nil + case float64: + return uint32(x), nil + case int8: + return uint32(x), nil + case int16: + return uint32(x), nil + case int32: + return uint32(x), nil + case int64: + return uint32(x), nil + //case string: + case uint8: + return uint32(x), nil + case uint16: + return uint32(x), nil + case uint32: + return uint32(x), nil + case uint64: + return uint32(x), nil + case *big.Int: + return uint32(x.Int64()), nil + case time.Duration: + return uint32(x), nil + default: + return invConv(val, typ) + } + case qUint64: + switch x := val.(type) { + //case nil: + //case idealComplex: + case idealFloat: + if _, frac := math.Modf(float64(x)); frac != 0 { + return truncConv(x) + } + + return uint64(x), nil + case idealInt: + return uint64(x), nil + case idealRune: + return uint64(x), nil + case idealUint: + return uint64(x), nil + //case bool: + //case complex64: + //case complex128: + case float32: + return uint64(x), nil + case float64: + return uint64(x), nil + case int8: + return uint64(x), nil + case int16: + return uint64(x), nil + case int32: + return uint64(x), nil + case int64: + return uint64(x), nil + //case string: + case uint8: + return uint64(x), nil + case uint16: + return uint64(x), nil + case uint32: + return uint64(x), nil + case uint64: + return uint64(x), nil + case *big.Int: + return x.Uint64(), nil + case time.Duration: + return uint64(x), nil + default: + return invConv(val, typ) + } + case qBlob: + switch x := val.(type) { + case string: + return []byte(x), nil + case []byte: + return x, nil + default: + return invConv(val, typ) + } + case qBigInt: + switch x := val.(type) { + // case blob + // case bool + //case idealComplex: + case idealFloat: + if _, frac := math.Modf(float64(x)); frac != 0 { + return truncConv(x) + } + + rr := big.NewRat(1, 1).SetFloat64(float64(x)) + ii := big.NewInt(0).Set(rr.Num()) + ii.Quo(ii, rr.Denom()) + return ii, nil + case idealInt: + return big.NewInt(0).SetInt64(int64(x)), nil + case idealRune: + return big.NewInt(0).SetInt64(int64(x)), nil + case idealUint: + return big.NewInt(0).SetUint64(uint64(x)), nil + //case complex64 + //case complex128 + case float32: + rr := big.NewRat(1, 1).SetFloat64(float64(x)) + ii := big.NewInt(0).Set(rr.Num()) + ii.Quo(ii, rr.Denom()) + return ii, nil + case float64: + rr := big.NewRat(1, 1).SetFloat64(float64(x)) + ii := big.NewInt(0).Set(rr.Num()) + ii.Quo(ii, rr.Denom()) + return ii, nil + case int8: + return big.NewInt(0).SetInt64(int64(x)), nil + case int16: + return big.NewInt(0).SetInt64(int64(x)), nil + case int32: + return big.NewInt(0).SetInt64(int64(x)), nil + case int64: + return big.NewInt(0).SetInt64(x), nil + case string: + y := big.NewInt(0) + if _, ok := y.SetString(x, 0); !ok { + return invConv(val, typ) + } + + return y, nil + case uint8: + return big.NewInt(0).SetUint64(uint64(x)), nil + case uint16: + return big.NewInt(0).SetUint64(uint64(x)), nil + case uint32: + return big.NewInt(0).SetUint64(uint64(x)), nil + case uint64: + return big.NewInt(0).SetUint64(x), nil + case *big.Int: + return x, nil + case *big.Rat: + ii := big.NewInt(0).Set(x.Num()) + ii.Div(ii, x.Denom()) + return ii, nil + default: + return invConv(val, typ) + } + case qBigRat: + switch x := val.(type) { + // case blob + // case bool + //case idealComplex: + case idealFloat: + return big.NewRat(1, 1).SetFloat64(float64(x)), nil + case idealInt: + return big.NewRat(1, 1).SetInt64(int64(x)), nil + case idealRune: + return big.NewRat(1, 1).SetInt64(int64(x)), nil + case idealUint: + return big.NewRat(1, 1).SetInt(big.NewInt(0).SetUint64(uint64(x))), nil + //case complex64 + //case complex128 + case float32: + return big.NewRat(1, 1).SetFloat64(float64(x)), nil + case float64: + return big.NewRat(1, 1).SetFloat64(x), nil + case int8: + return big.NewRat(1, 1).SetInt64(int64(x)), nil + case int16: + return big.NewRat(1, 1).SetInt64(int64(x)), nil + case int32: + return big.NewRat(1, 1).SetInt64(int64(x)), nil + case int64: + return big.NewRat(1, 1).SetInt64(x), nil + case string: + y := big.NewRat(1, 1) + if _, ok := y.SetString(x); !ok { + return invConv(val, typ) + } + + return y, nil + case uint8: + return big.NewRat(1, 1).SetInt64(int64(x)), nil + case uint16: + return big.NewRat(1, 1).SetInt64(int64(x)), nil + case uint32: + return big.NewRat(1, 1).SetInt64(int64(x)), nil + case uint64: + return big.NewRat(1, 1).SetInt(big.NewInt(0).SetUint64(x)), nil + case *big.Int: + return big.NewRat(1, 1).SetInt(x), nil + case *big.Rat: + return x, nil + default: + return invConv(val, typ) + } + case qDuration: + switch x := val.(type) { + // case blob + // case bool + //case idealComplex: + case idealFloat: + return time.Duration(x), nil + case idealInt: + return time.Duration(x), nil + case idealRune: + return time.Duration(x), nil + case idealUint: + return time.Duration(x), nil + //case complex64 + //case complex128 + case float32: + return time.Duration(x), nil + case float64: + return time.Duration(x), nil + case int8: + return time.Duration(x), nil + case int16: + return time.Duration(x), nil + case int32: + return time.Duration(x), nil + case int64: + return time.Duration(x), nil + case string: + return time.ParseDuration(x) + case uint8: + return time.Duration(x), nil + case uint16: + return time.Duration(x), nil + case uint32: + return time.Duration(x), nil + case uint64: + return time.Duration(x), nil + case *big.Int: + return time.Duration(x.Int64()), nil + case *big.Rat: + f, _ := x.Float64() + return time.Duration(f), nil + case time.Duration: + return x, nil + default: + return invConv(val, typ) + } + case qTime: + switch x := val.(type) { + // case blob + // case bool + //case idealComplex: + //case idealFloat: + //case idealInt: + //case idealRune: + //case idealUint: + //case complex64 + //case complex128 + //case float32: + //case float64: + //case int8: + //case int16: + //case int32: + //case int64: + //case string: + //case uint8: + //case uint16: + //case uint32: + //case uint64: + //case *big.Int: + //case *big.Rat: + //case time.Duration: + case time.Time: + return x, nil + default: + return invConv(val, typ) + } + default: + panic("internal error 006") + } +} + +func invShiftRHS(lhs, rhs interface{}) (interface{}, error) { + return nil, fmt.Errorf("invalid operation: %v << %v (shift count type %T, must be unsigned integer)", lhs, rhs, rhs) +} + +func invTruncInt(v interface{}) error { + return fmt.Errorf("constant %v truncated to integer", v) +} + +func overflow(v interface{}, typ int) error { + return fmt.Errorf("constant %v overflows %s", v, typeStr(typ)) +} + +func typeCheck1(val interface{}, c *col) (interface{}, error) { + rec := []interface{}{val} + c = c.clone() + c.index = 0 + if err := typeCheck(rec, []*col{c}); err != nil { + return nil, err + } + + return rec[0], nil +} + +func typeCheck(rec []interface{}, cols []*col) (err error) { + for _, c := range cols { + i := c.index + if v := rec[i]; !c.typeCheck(v) { + switch v.(type) { + case idealComplex: + y := complex128(v.(idealComplex)) + switch c.typ { + case qBool: + case qComplex64: + rec[i] = complex64(y) + continue + case qComplex128: + rec[i] = complex128(y) + continue + case qFloat32, qFloat64, qInt8, qInt16, qInt32, qInt64, qUint8, qUint16, qUint32, qUint64: + return fmt.Errorf("constant %v truncated to real", y) + } + case idealFloat: + y := float64(v.(idealFloat)) + switch c.typ { + case qBool: + case qComplex64: + rec[i] = complex(float32(y), 0) + continue + case qComplex128: + rec[i] = complex(float64(y), 0) + continue + case qFloat32: + rec[i] = float32(y) + continue + case qFloat64: + rec[i] = float64(y) + continue + case qInt8: + if math.Floor(y) != y { + return invTruncInt(y) + } + + if y < math.MinInt8 || y > math.MaxInt8 { + return overflow(y, c.typ) + } + + rec[i] = int8(y) + continue + case qInt16: + if math.Floor(y) != y { + return invTruncInt(y) + } + + if y < math.MinInt16 || y > math.MaxInt16 { + return overflow(y, c.typ) + } + + rec[i] = int16(y) + continue + case qInt32: + if math.Floor(y) != y { + return invTruncInt(y) + } + + if y < math.MinInt32 || y > math.MaxInt32 { + return overflow(y, c.typ) + } + + rec[i] = int32(y) + continue + case qInt64: + if math.Floor(y) != y { + return invTruncInt(y) + } + + if y < math.MinInt64 || y > math.MaxInt64 { + return overflow(y, c.typ) + } + + rec[i] = int64(y) + continue + case qString: + case qUint8: + if math.Floor(y) != y { + return invTruncInt(y) + } + + if y < 0 || y > math.MaxUint8 { + return overflow(y, c.typ) + } + + rec[i] = uint8(y) + continue + case qUint16: + if math.Floor(y) != y { + return invTruncInt(y) + } + + if y < 0 || y > math.MaxUint16 { + return overflow(y, c.typ) + } + + rec[i] = uint16(y) + continue + case qUint32: + if math.Floor(y) != y { + return invTruncInt(y) + } + + if y < 0 || y > math.MaxUint32 { + return overflow(y, c.typ) + } + + rec[i] = uint32(y) + continue + case qUint64: + if math.Floor(y) != y { + return invTruncInt(y) + } + + if y < 0 || y > math.MaxUint64 { + return overflow(y, c.typ) + } + + rec[i] = uint64(y) + continue + case qBigInt: + if math.Floor(y) != y { + return invTruncInt(y) + } + + rr := big.NewRat(1, 1).SetFloat64(y) + ii := big.NewInt(0) + ii.Set(rr.Num()) + ii.Quo(ii, rr.Denom()) + rec[i] = ii + continue + case qBigRat: + rec[i] = big.NewRat(1, 1).SetFloat64(y) + continue + } + case idealInt: + y := int64(v.(idealInt)) + switch c.typ { + case qBool: + case qComplex64: + rec[i] = complex(float32(y), 0) + continue + case qComplex128: + rec[i] = complex(float64(y), 0) + continue + case qFloat32: + rec[i] = float32(y) + continue + case qFloat64: + rec[i] = float64(y) + continue + case qInt8: + if y < math.MinInt8 || y > math.MaxInt8 { + return overflow(y, c.typ) + } + + rec[i] = int8(y) + continue + case qInt16: + if y < math.MinInt16 || y > math.MaxInt16 { + return overflow(y, c.typ) + } + + rec[i] = int16(y) + continue + case qInt32: + if y < math.MinInt32 || y > math.MaxInt32 { + return overflow(y, c.typ) + } + + rec[i] = int32(y) + continue + case qInt64: + if y < math.MinInt64 || y > math.MaxInt64 { + return overflow(y, c.typ) + } + + rec[i] = int64(y) + continue + case qString: + case qUint8: + if y < 0 || y > math.MaxUint8 { + return overflow(y, c.typ) + } + + rec[i] = uint8(y) + continue + case qUint16: + if y < 0 || y > math.MaxUint16 { + return overflow(y, c.typ) + } + + rec[i] = uint16(y) + continue + case qUint32: + if y < 0 || y > math.MaxUint32 { + return overflow(y, c.typ) + } + + rec[i] = uint32(y) + continue + case qUint64: + if y < 0 { + return overflow(y, c.typ) + } + + rec[i] = uint64(y) + continue + case qBigInt: + rec[i] = big.NewInt(y) + continue + case qBigRat: + rec[i] = big.NewRat(1, 1).SetInt64(y) + continue + } + case idealRune: + y := int64(v.(idealRune)) + switch c.typ { + case qBool: + case qComplex64: + rec[i] = complex(float32(y), 0) + continue + case qComplex128: + rec[i] = complex(float64(y), 0) + continue + case qFloat32: + rec[i] = float32(y) + continue + case qFloat64: + rec[i] = float64(y) + continue + case qInt8: + if y < math.MinInt8 || y > math.MaxInt8 { + return overflow(y, c.typ) + } + + rec[i] = int8(y) + continue + case qInt16: + if y < math.MinInt16 || y > math.MaxInt16 { + return overflow(y, c.typ) + } + + rec[i] = int16(y) + continue + case qInt32: + if y < math.MinInt32 || y > math.MaxInt32 { + return overflow(y, c.typ) + } + + rec[i] = int32(y) + continue + case qInt64: + if y < math.MinInt64 || y > math.MaxInt64 { + return overflow(y, c.typ) + } + + rec[i] = int64(y) + continue + case qString: + case qUint8: + if y < 0 || y > math.MaxUint8 { + return overflow(y, c.typ) + } + + rec[i] = uint8(y) + continue + case qUint16: + if y < 0 || y > math.MaxUint16 { + return overflow(y, c.typ) + } + + rec[i] = uint16(y) + continue + case qUint32: + if y < 0 { + return overflow(y, c.typ) + } + + rec[i] = uint32(y) + continue + case qUint64: + if y < 0 { + return overflow(y, c.typ) + } + + rec[i] = uint64(y) + continue + case qBigInt: + rec[i] = big.NewInt(y) + continue + case qBigRat: + rec[i] = big.NewRat(1, 1).SetInt64(y) + continue + } + case idealUint: + y := uint64(v.(idealUint)) + switch c.typ { + case qBool: + case qComplex64: + rec[i] = complex(float32(y), 0) + continue + case qComplex128: + rec[i] = complex(float64(y), 0) + continue + case qFloat32: + rec[i] = float32(y) + continue + case qFloat64: + rec[i] = float64(y) + continue + case qInt8: + if y > math.MaxInt8 { + return overflow(y, c.typ) + } + + rec[i] = int8(y) + continue + case qInt16: + if y > math.MaxInt16 { + return overflow(y, c.typ) + } + + rec[i] = int16(y) + continue + case qInt32: + if y > math.MaxInt32 { + return overflow(y, c.typ) + } + + rec[i] = int32(y) + continue + case qInt64: + if y > math.MaxInt64 { + return overflow(y, c.typ) + } + + rec[i] = int64(y) + continue + case qString: + rec[i] = string(y) + continue + case qUint8: + if y > math.MaxUint8 { + return overflow(y, c.typ) + } + + rec[i] = uint8(y) + continue + case qUint16: + if y > math.MaxUint16 { + return overflow(y, c.typ) + } + + rec[i] = uint16(y) + continue + case qUint32: + if y > math.MaxUint32 { + return overflow(y, c.typ) + } + + rec[i] = uint32(y) + continue + case qUint64: + rec[i] = uint64(y) + continue + case qBigInt: + rec[i] = big.NewInt(0).SetUint64(y) + continue + case qBigRat: + ii := big.NewInt(0).SetUint64(y) + rec[i] = big.NewRat(1, 1).SetInt(ii) + continue + } + } + return fmt.Errorf("cannot use %v (type %T) in assignment to, or comparison with, column %s (type %s)", v, ideal(v), c.name, typeStr(c.typ)) + } + } + return +} + +//TODO collate1 should return errors instead of panicing +func collate1(a, b interface{}) int { + switch x := a.(type) { + case nil: + if b != nil { + return -1 + } + + return 0 + case bool: + switch y := b.(type) { + case nil: + return 1 + case bool: + if !x && y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + default: + // Make bool collate before anything except nil and + // other bool for index seeking first non NULL value. + return -1 + } + case idealComplex: + switch y := b.(type) { + case nil: + return 1 + case idealComplex: + if x == y { + return 0 + } + + if real(x) < real(y) { + return -1 + } + + if real(x) > real(y) { + return 1 + } + + if imag(x) < imag(y) { + return -1 + } + + return 1 + case complex64: + { + x, y := complex64(x), complex64(y) + if x == y { + return 0 + } + + if real(x) < real(y) { + return -1 + } + + if real(x) > real(y) { + return 1 + } + + if imag(x) < imag(y) { + return -1 + } + + return 1 + } + case complex128: + { + x := complex128(x) + if x == y { + return 0 + } + + if real(x) < real(y) { + return -1 + } + + if real(x) > real(y) { + return 1 + } + + if imag(x) < imag(y) { + return -1 + } + + return 1 + } + default: + panic("internal error 012") + } + case idealUint: + switch y := b.(type) { + case nil: + return 1 + case idealUint: + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + case uint8: + { + x, y := uint64(x), uint64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + case uint16: + { + x, y := uint64(x), uint64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + case uint32: + { + x, y := uint64(x), uint64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + case uint64: + { + x, y := uint64(x), uint64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + case uint: + { + x, y := uint64(x), uint64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + default: + panic("internal error 013") + } + case idealRune: + switch y := b.(type) { + case nil: + return 1 + case idealRune: + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + case int8: + { + x, y := int64(x), int64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + case int16: + { + x, y := int64(x), int64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + case int32: + { + x, y := int64(x), int64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + case int64: + { + x, y := int64(x), int64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + case int: + { + x, y := int64(x), int64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + default: + panic("internal error 014") + } + case idealInt: + switch y := b.(type) { + case nil: + return 1 + case idealInt: + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + case int8: + { + x, y := int64(x), int64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + case int16: + { + x, y := int64(x), int64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + case int32: + { + x, y := int64(x), int64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + case int64: + { + x, y := int64(x), int64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + case int: + { + x, y := int64(x), int64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + default: + panic("internal error 015") + } + case idealFloat: + switch y := b.(type) { + case nil: + return 1 + case idealFloat: + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + case float32: + { + x, y := float64(x), float64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + case float64: + { + x, y := float64(x), float64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + default: + panic("internal error 016") + } + case complex64: + switch y := b.(type) { + case nil: + return 1 + case complex64: + if x == y { + return 0 + } + + if real(x) < real(y) { + return -1 + } + + if real(x) > real(y) { + return 1 + } + + if imag(x) < imag(y) { + return -1 + } + + return 1 + case idealComplex: + { + x, y := complex64(x), complex64(y) + if x == y { + return 0 + } + + if real(x) < real(y) { + return -1 + } + + if real(x) > real(y) { + return 1 + } + + if imag(x) < imag(y) { + return -1 + } + + return 1 + } + default: + panic("internal error 017") + } + case complex128: + switch y := b.(type) { + case nil: + return 1 + case complex128: + if x == y { + return 0 + } + + if real(x) < real(y) { + return -1 + } + + if real(x) > real(y) { + return 1 + } + + if imag(x) < imag(y) { + return -1 + } + + return 1 + case idealComplex: + { + x, y := complex128(x), complex128(y) + if x == y { + return 0 + } + + if real(x) < real(y) { + return -1 + } + + if real(x) > real(y) { + return 1 + } + + if imag(x) < imag(y) { + return -1 + } + + return 1 + } + default: + panic("internal error 018") + } + case float32: + switch y := b.(type) { + case nil: + return 1 + case float32: + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + case idealFloat: + { + x, y := float32(x), float32(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + default: + panic("internal error 019") + } + case float64: + switch y := b.(type) { + case nil: + return 1 + case float64: + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + case idealFloat: + { + x, y := float64(x), float64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + default: + panic("internal error 020") + } + case int8: + switch y := b.(type) { + case nil: + return 1 + case int8: + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + case idealInt: + { + x, y := int64(x), int64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + default: + panic("internal error 021") + } + case int16: + switch y := b.(type) { + case nil: + return 1 + case int16: + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + case idealInt: + { + x, y := int64(x), int64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + default: + panic("internal error 022") + } + case int32: + switch y := b.(type) { + case nil: + return 1 + case int32: + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + case idealInt: + { + x, y := int64(x), int64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + default: + panic("internal error 023") + } + case int64: + switch y := b.(type) { + case nil: + return 1 + case int64: + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + case idealInt: + { + x, y := int64(x), int64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + default: + panic("internal error 024") + } + case uint8: + switch y := b.(type) { + case nil: + return 1 + case uint8: + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + case idealInt: + { + x, y := uint64(x), uint64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + case idealUint: + { + x, y := uint64(x), uint64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + default: + panic("internal error 025") + } + case uint16: + switch y := b.(type) { + case nil: + return 1 + case uint16: + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + case idealInt: + { + x, y := uint64(x), uint64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + case idealUint: + { + x, y := uint64(x), uint64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + default: + panic("internal error 026") + } + case uint32: + switch y := b.(type) { + case nil: + return 1 + case uint32: + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + case idealInt: + { + x, y := uint64(x), uint64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + case idealUint: + { + x, y := uint64(x), uint64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + default: + panic("internal error 027") + } + case uint64: + switch y := b.(type) { + case nil: + return 1 + case uint64: + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + case idealInt: + { + x, y := uint64(x), uint64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + case idealUint: + { + x, y := uint64(x), uint64(y) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + } + default: + panic("internal error 028") + } + case string: + switch y := b.(type) { + case nil: + return 1 + case string: + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + default: + panic("internal error 029") + } + case []byte: + switch y := b.(type) { + case nil: + return 1 + case []byte: + return bytes.Compare(x, y) + default: + panic("internal error 030") + } + case *big.Int: + switch y := b.(type) { + case nil: + return 1 + case *big.Int: + return x.Cmp(y) + case idealInt: + { + y := big.NewInt(int64(y)) + return x.Cmp(y) + } + case idealUint: + { + u := big.NewInt(0) + u.SetUint64(uint64(y)) + return x.Cmp(u) + } + default: + panic("internal error 031") + } + case *big.Rat: + switch y := b.(type) { + case nil: + return 1 + case *big.Rat: + return x.Cmp(y) + case idealInt: + { + y := big.NewRat(int64(y), 1) + return x.Cmp(y) + } + case idealUint: + { + u := big.NewInt(0) + u.SetUint64(uint64(y)) + var y big.Rat + y.SetInt(u) + return x.Cmp(&y) + } + default: + panic("internal error 032") + } + case time.Time: + switch y := b.(type) { + case nil: + return 1 + case time.Time: + if x.Before(y) { + return -1 + } + + if x.Equal(y) { + return 0 + } + + return 1 + default: + panic("internal error 033") + } + case time.Duration: + switch y := b.(type) { + case nil: + return 1 + case time.Duration: + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + default: + panic("internal error 034") + } + case chunk: + switch y := b.(type) { + case nil: + return 1 + case chunk: + a, err := x.expand() + if err != nil { + panic(err) + } + + b, err := y.expand() + if err != nil { + panic(err) + } + + return collate1(a, b) + default: + panic("internal error 035") + } + default: + //dbg("%T(%v) %T(%v)", a, a, b, b) + panic("internal error 036") + } +} + +//TODO collate should return errors from collate1 +func collate(x, y []interface{}) (r int) { + //defer func() { dbg("%v %v -> %v", x, y, r) }() + nx, ny := len(x), len(y) + + switch { + case nx == 0 && ny != 0: + return -1 + case nx == 0 && ny == 0: + return 0 + case nx != 0 && ny == 0: + return 1 + } + + r = 1 + if nx > ny { + x, y, r = y, x, -r + } + + for i, xi := range x { + if c := collate1(xi, y[i]); c != 0 { + return c * r + } + } + + if nx == ny { + return 0 + } + + return -r +} + +var collators = map[bool]func(a, b []interface{}) int{false: collateDesc, true: collate} + +func collateDesc(a, b []interface{}) int { + return -collate(a, b) +} + +func isOrderedType(v interface{}) (y interface{}, r bool, err error) { + //dbg("====") + //dbg("%T(%v)", v, v) + //defer func() { dbg("%T(%v)", y, y) }() + switch x := v.(type) { + case idealFloat, idealInt, idealRune, idealUint, + float32, float64, + int8, int16, int32, int64, + uint8, uint16, uint32, uint64, + string: + return v, true, nil + case *big.Int, *big.Rat, time.Time, time.Duration: + return x, true, nil + case chunk: + if y, err = x.expand(); err != nil { + return + } + + return isOrderedType(y) + } + + return v, false, nil +} + +var isSystemName = map[string]bool{ + "__Column": true, + "__Column2": true, + "__Index": true, + "__Index2": true, + "__Index2_Column": true, + "__Index2_Expr": true, + "__Table": true, +} + +func qualifier(s string) string { + if pos := strings.IndexByte(s, '.'); pos >= 0 { + s = s[:pos] + } + return s +} + +func mustQualifier(s string) string { + q := qualifier(s) + if q == s { + panic("internal error 068") + } + + return q +} + +func selector(s string) string { + if pos := strings.IndexByte(s, '.'); pos >= 0 { + s = s[pos+1:] + } + return s +} + +func mustSelector(s string) string { + q := selector(s) + if q == s { + panic("internal error 053") + } + + return q +} + +func qnames(l []string) []string { + r := make([]string, len(l)) + for i, v := range l { + r[i] = fmt.Sprintf("%q", v) + } + return r +} diff --git a/vendor/github.com/cznic/ql/expr.go b/vendor/github.com/cznic/ql/expr.go new file mode 100644 index 0000000000..3e6954fbe6 --- /dev/null +++ b/vendor/github.com/cznic/ql/expr.go @@ -0,0 +1,4023 @@ +// Copyright 2014 The ql Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found pIn the LICENSE file. + +package ql + +import ( + "fmt" + "math/big" + "regexp" + "strings" + "time" +) + +var ( + _ expression = (*binaryOperation)(nil) + _ expression = (*call)(nil) + _ expression = (*conversion)(nil) + _ expression = (*ident)(nil) + _ expression = (*indexOp)(nil) + _ expression = (*isNull)(nil) + _ expression = (*pIn)(nil) + _ expression = (*pLike)(nil) + _ expression = (*parameter)(nil) + _ expression = (*pexpr)(nil) + _ expression = (*slice)(nil) + _ expression = (*unaryOperation)(nil) + _ expression = value{} +) + +type expression interface { + clone(arg []interface{}, unqualify ...string) (expression, error) + eval(execCtx *execCtx, ctx map[interface{}]interface{}) (v interface{}, err error) + isStatic() bool + String() string +} + +func cloneExpressionList(arg []interface{}, list []expression, unqualify ...string) ([]expression, error) { + r := make([]expression, len(list)) + var err error + for i, v := range list { + if r[i], err = v.clone(arg, unqualify...); err != nil { + return nil, err + } + } + return r, nil +} + +func isConstValue(v interface{}) interface{} { + switch x := v.(type) { + case value: + return x.val + case + idealComplex, + idealFloat, + idealInt, + idealRune, + idealUint: + return v + default: + return nil + } +} + +func isColumnExpression(v expression) (bool, string) { + x, ok := v.(*ident) + if ok { + return true, x.s + } + + c, ok := v.(*call) + if !ok || c.f != "id" || len(c.arg) != 0 { + return false, "" + } + + return true, "id()" +} + +func mentionedColumns0(e expression, q, nq bool, m map[string]struct{}) { + switch x := e.(type) { + case parameter, + value: + // nop + case *binaryOperation: + mentionedColumns0(x.l, q, nq, m) + mentionedColumns0(x.r, q, nq, m) + case *call: + if x.f != "id" { + for _, e := range x.arg { + mentionedColumns0(e, q, nq, m) + } + } + case *conversion: + mentionedColumns0(x.val, q, nq, m) + case *ident: + if q && x.isQualified() { + m[x.s] = struct{}{} + } + if nq && !x.isQualified() { + m[x.s] = struct{}{} + } + case *indexOp: + mentionedColumns0(x.expr, q, nq, m) + mentionedColumns0(x.x, q, nq, m) + case *isNull: + mentionedColumns0(x.expr, q, nq, m) + case *pexpr: + mentionedColumns0(x.expr, q, nq, m) + case *pIn: + mentionedColumns0(x.expr, q, nq, m) + for _, e := range x.list { + mentionedColumns0(e, q, nq, m) + } + case *pLike: + mentionedColumns0(x.expr, q, nq, m) + mentionedColumns0(x.pattern, q, nq, m) + case *slice: + mentionedColumns0(x.expr, q, nq, m) + if y := x.lo; y != nil { + mentionedColumns0(*y, q, nq, m) + } + if y := x.hi; y != nil { + mentionedColumns0(*y, q, nq, m) + } + case *unaryOperation: + mentionedColumns0(x.v, q, nq, m) + default: + panic("internal error 052") + } +} + +func mentionedColumns(e expression) map[string]struct{} { + m := map[string]struct{}{} + mentionedColumns0(e, false, true, m) + return m +} + +func mentionedQColumns(e expression) map[string]struct{} { + m := map[string]struct{}{} + mentionedColumns0(e, true, false, m) + return m +} + +func staticExpr(e expression) (expression, error) { + if e.isStatic() { + v, err := e.eval(nil, nil) + if err != nil { + return nil, err + } + + if v == nil { + return value{nil}, nil + } + + return value{v}, nil + } + + return e, nil +} + +type ( + idealComplex complex128 + idealFloat float64 + idealInt int64 + idealRune int32 + idealUint uint64 +) + +type exprTab struct { + expr expression + table string +} + +type pexpr struct { + expr expression +} + +func (p *pexpr) clone(arg []interface{}, unqualify ...string) (expression, error) { + expr, err := p.expr.clone(arg, unqualify...) + if err != nil { + return nil, err + } + + return &pexpr{expr: expr}, nil +} + +func (p *pexpr) isStatic() bool { return p.expr.isStatic() } + +func (p *pexpr) String() string { + return fmt.Sprintf("(%s)", p.expr) +} + +func (p *pexpr) eval(execCtx *execCtx, ctx map[interface{}]interface{}) (v interface{}, err error) { + return p.expr.eval(execCtx, ctx) +} + +//DONE newBetween +//LATER like newBetween, check all others have and use new* + +func newBetween(expr, lo, hi interface{}, not bool) (expression, error) { + e, err := staticExpr(expr.(expression)) + if err != nil { + return nil, err + } + + l, err := staticExpr(lo.(expression)) + if err != nil { + return nil, err + } + + h, err := staticExpr(hi.(expression)) + if err != nil { + return nil, err + } + + var a, b expression + op := andand + switch { + case not: // e < l || e > h + op = oror + if a, err = newBinaryOperation('<', e, l); err != nil { + return nil, err + } + + if b, err = newBinaryOperation('>', e, h); err != nil { + return nil, err + } + default: // e >= l && e <= h + if a, err = newBinaryOperation(ge, e, l); err != nil { + return nil, err + } + + if b, err = newBinaryOperation(le, e, h); err != nil { + return nil, err + } + } + + if a, err = staticExpr(a); err != nil { + return nil, err + } + + if b, err = staticExpr(b); err != nil { + return nil, err + } + + ret, err := newBinaryOperation(op, a, b) + if err != nil { + return nil, err + } + + return staticExpr(ret) +} + +type pLike struct { + expr expression + pattern expression + re *regexp.Regexp + sexpr *string +} + +func (p *pLike) clone(arg []interface{}, unqualify ...string) (expression, error) { + expr, err := p.expr.clone(arg, unqualify...) + if err != nil { + return nil, err + } + + pattern, err := p.pattern.clone(arg, unqualify...) + if err != nil { + return nil, err + } + + return &pLike{ + expr: expr, + pattern: pattern, + re: p.re, + sexpr: p.sexpr, + }, nil +} + +func (p *pLike) isStatic() bool { return p.expr.isStatic() && p.pattern.isStatic() } +func (p *pLike) String() string { return fmt.Sprintf("%s LIKE %s", p.expr, p.pattern) } + +func (p *pLike) eval(execCtx *execCtx, ctx map[interface{}]interface{}) (v interface{}, err error) { + var sexpr string + var ok bool + switch { + case p.sexpr != nil: + sexpr = *p.sexpr + default: + expr, err := expand1(p.expr.eval(execCtx, ctx)) + if err != nil { + return nil, err + } + + if expr == nil { + return nil, nil + } + + sexpr, ok = expr.(string) + if !ok { + return nil, fmt.Errorf("non-string expression in LIKE: %v (value of type %T)", expr, expr) + } + + if p.expr.isStatic() { + p.sexpr = new(string) + *p.sexpr = sexpr + } + } + + re := p.re + if re == nil { + pattern, err := expand1(p.pattern.eval(execCtx, ctx)) + if err != nil { + return nil, err + } + + if pattern == nil { + return nil, nil + } + + spattern, ok := pattern.(string) + if !ok { + return nil, fmt.Errorf("non-string pattern in LIKE: %v (value of type %T)", pattern, pattern) + } + + if re, err = regexp.Compile(spattern); err != nil { + return nil, err + } + + if p.pattern.isStatic() { + p.re = re + } + } + + return re.MatchString(sexpr), nil +} + +type binaryOperation struct { + op int + l, r expression +} + +func newBinaryOperation0(op int, x, y interface{}) (v expression, err error) { + if op == eq { + if l, ok := x.(value); ok { + if b, ok := l.val.(bool); ok { + if b { // true == y: y + return y.(expression), nil + } + + // false == y: !y + return newUnaryOperation('!', y) + } + } + + if r, ok := y.(value); ok { + if b, ok := r.val.(bool); ok { + if b { // x == true: x + return x.(expression), nil + } + + // x == false: !x + return newUnaryOperation('!', x) + } + } + } + + if op == neq { + if l, ok := x.(value); ok { + if b, ok := l.val.(bool); ok { + if b { // true != y: !y + return newUnaryOperation('!', y) + } + + // false != y: y + return y.(expression), nil + } + } + + if r, ok := y.(value); ok { + if b, ok := r.val.(bool); ok { + if b { // x != true: !x + return newUnaryOperation('!', x) + } + + // x != false: x + return x.(expression), nil + } + } + } + + b := binaryOperation{op, x.(expression), y.(expression)} + var lv interface{} + if e := b.l; e.isStatic() { + if lv, err = e.eval(nil, nil); err != nil { + return nil, err + } + + b.l = value{lv} + } + + if e := b.r; e.isStatic() { + v, err := e.eval(nil, nil) + if err != nil { + return nil, err + } + + if v == nil { + return value{nil}, nil + } + + if op == '/' || op == '%' { + rb := binaryOperation{eq, e, value{idealInt(0)}} + val, err := rb.eval(nil, nil) + if err != nil { + return nil, err + } + + if val.(bool) { + return nil, errDivByZero + } + } + + if b.l.isStatic() && lv == nil { + return value{nil}, nil + } + + b.r = value{v} + } + + if !b.isStatic() { + return &b, nil + } + + val, err := b.eval(nil, nil) + return value{val}, err +} + +func newBinaryOperation(op int, x, y interface{}) (v expression, err error) { + expr, err := newBinaryOperation0(op, x, y) + if err != nil { + return nil, err + } + + b, ok := expr.(*binaryOperation) + if !ok { + return expr, nil + } + + if _, ok := b.l.(*ident); ok { + return expr, nil + } + + if c, ok := b.l.(*call); ok && c.f == "id" { + return expr, nil + } + + var r expression + if r, ok = b.r.(*ident); !ok { + r1, ok := b.r.(*call) + if !ok || r1.f != "id" || len(r1.arg) != 0 { + return expr, nil + } + + r = r1 + } + + // Normalize expr relOp indent: ident invRelOp expr + switch b.op { + case '<': + return &binaryOperation{'>', r, b.l}, nil + case le: + return &binaryOperation{ge, r, b.l}, nil + case '>': + return &binaryOperation{'<', r, b.l}, nil + case ge: + return &binaryOperation{le, r, b.l}, nil + case eq, neq: + return &binaryOperation{b.op, r, b.l}, nil + default: + return expr, nil + } +} + +func (o *binaryOperation) isIdentRelOpVal() (bool, string, interface{}, error) { + sid := "" + id, ok := o.l.(*ident) + if !ok { + f, ok := o.l.(*call) + if !ok || f.f != "id" || len(f.arg) != 0 { + return false, "", nil, nil + } + + sid = "id()" + } else { + if id.isQualified() { + return false, "", nil, nil + } + + sid = id.s + } + + if v, ok := o.r.(value); ok { + switch o.op { + case '<', + le, + '>', + ge, + eq, + neq: + return true, sid, v.val, nil + default: + return false, "", nil, nil + } + } + + return false, "", nil, nil +} + +func (o *binaryOperation) clone(arg []interface{}, unqualify ...string) (expression, error) { + l, err := o.l.clone(arg, unqualify...) + if err != nil { + return nil, err + } + + r, err := o.r.clone(arg, unqualify...) + if err != nil { + return nil, err + } + + return newBinaryOperation(o.op, l, r) +} + +func (o *binaryOperation) isStatic() bool { return o.l.isStatic() && o.r.isStatic() } + +func (o *binaryOperation) String() string { + return fmt.Sprintf("%s %s %s", o.l, iop(o.op), o.r) +} + +func (o *binaryOperation) eval(execCtx *execCtx, ctx map[interface{}]interface{}) (r interface{}, err error) { + defer func() { + if e := recover(); e != nil { + switch x := e.(type) { + case error: + r, err = nil, x + default: + r, err = nil, fmt.Errorf("%v", x) + } + } + }() + + switch op := o.op; op { + case andand: + a, err := expand1(o.l.eval(execCtx, ctx)) + if err != nil { + return nil, err + } + + switch x := a.(type) { + case nil: + b, err := expand1(o.r.eval(execCtx, ctx)) + if err != nil { + return nil, err + } + + switch y := b.(type) { + case nil: + return nil, nil + case bool: + if !y { + return false, nil + } + + return nil, nil + default: + return invOp2(x, y, op) + } + case bool: + if !x { + return false, nil + } + + b, err := expand1(o.r.eval(execCtx, ctx)) + if err != nil { + return nil, err + } + + switch y := b.(type) { + case nil: + return nil, nil + case bool: + return y, nil + default: + return invOp2(x, y, op) + } + default: + return undOp(x, op) + } + case oror: + a, err := expand1(o.l.eval(execCtx, ctx)) + if err != nil { + return nil, err + } + + switch x := a.(type) { + case nil: + b, err := expand1(o.r.eval(execCtx, ctx)) + if err != nil { + return nil, err + } + + switch y := b.(type) { + case nil: + return nil, nil + case bool: + if y { + return y, nil + } + + return nil, nil + default: + return invOp2(x, y, op) + } + case bool: + if x { + return x, nil + } + + b, err := expand1(o.r.eval(execCtx, ctx)) + if err != nil { + return nil, err + } + + switch y := b.(type) { + case nil: + return nil, nil + case bool: + return y, nil + default: + return invOp2(x, y, op) + } + default: + return undOp(x, op) + } + case '>': + a, b := o.get2(execCtx, ctx) + if a == nil || b == nil { + return + } + switch x := a.(type) { + //case nil: + case idealComplex: + return undOp2(a, b, op) + case idealFloat: + switch y := b.(type) { + case idealFloat: + return x > y, nil + default: + return invOp2(x, y, op) + } + case idealInt: + switch y := b.(type) { + case idealInt: + return x > y, nil + default: + return invOp2(x, y, op) + } + case idealRune: + switch y := b.(type) { + case idealRune: + return x > y, nil + default: + return invOp2(x, y, op) + } + case idealUint: + switch y := b.(type) { + case idealUint: + return x > y, nil + default: + return invOp2(x, y, op) + } + case bool: + return undOp2(a, b, op) + case complex64: + return undOp2(a, b, op) + case complex128: + return undOp2(a, b, op) + case float32: + switch y := b.(type) { + case float32: + return x > y, nil + default: + return invOp2(x, y, op) + } + case float64: + switch y := b.(type) { + case float64: + return x > y, nil + default: + return invOp2(x, y, op) + } + case int8: + switch y := b.(type) { + case int8: + return x > y, nil + default: + return invOp2(x, y, op) + } + case int16: + switch y := b.(type) { + case int16: + return x > y, nil + default: + return invOp2(x, y, op) + } + case int32: + switch y := b.(type) { + case int32: + return x > y, nil + default: + return invOp2(x, y, op) + } + case int64: + switch y := b.(type) { + case int64: + return x > y, nil + default: + return invOp2(x, y, op) + } + case string: + switch y := b.(type) { + case string: + return x > y, nil + default: + return invOp2(x, y, op) + } + case uint8: + switch y := b.(type) { + case uint8: + return x > y, nil + default: + return invOp2(x, y, op) + } + case uint16: + switch y := b.(type) { + case uint16: + return x > y, nil + default: + return invOp2(x, y, op) + } + case uint32: + switch y := b.(type) { + case uint32: + return x > y, nil + default: + return invOp2(x, y, op) + } + case uint64: + switch y := b.(type) { + case uint64: + return x > y, nil + default: + return invOp2(x, y, op) + } + case *big.Int: + switch y := b.(type) { + case *big.Int: + return x.Cmp(y) > 0, nil + default: + return invOp2(x, y, op) + } + case *big.Rat: + switch y := b.(type) { + case *big.Rat: + return x.Cmp(y) > 0, nil + default: + return invOp2(x, y, op) + } + case time.Duration: + switch y := b.(type) { + case time.Duration: + return x > y, nil + default: + return invOp2(x, y, op) + } + case time.Time: + switch y := b.(type) { + case time.Time: + return x.After(y), nil + default: + return invOp2(x, y, op) + } + default: + return invOp2(a, b, op) + } + case '<': + a, b := o.get2(execCtx, ctx) + if a == nil || b == nil { + return + } + switch x := a.(type) { + //case nil: + case idealComplex: + return undOp2(a, b, op) + case idealFloat: + switch y := b.(type) { + case idealFloat: + return x < y, nil + default: + return invOp2(x, y, op) + } + case idealInt: + switch y := b.(type) { + case idealInt: + return x < y, nil + default: + return invOp2(x, y, op) + } + case idealRune: + switch y := b.(type) { + case idealRune: + return x < y, nil + default: + return invOp2(x, y, op) + } + case idealUint: + switch y := b.(type) { + case idealUint: + return x < y, nil + default: + return invOp2(x, y, op) + } + case bool: + return undOp2(a, b, op) + case complex64: + return undOp2(a, b, op) + case complex128: + return undOp2(a, b, op) + case float32: + switch y := b.(type) { + case float32: + return x < y, nil + default: + return invOp2(x, y, op) + } + case float64: + switch y := b.(type) { + case float64: + return x < y, nil + default: + return invOp2(x, y, op) + } + case int8: + switch y := b.(type) { + case int8: + return x < y, nil + default: + return invOp2(x, y, op) + } + case int16: + switch y := b.(type) { + case int16: + return x < y, nil + default: + return invOp2(x, y, op) + } + case int32: + switch y := b.(type) { + case int32: + return x < y, nil + default: + return invOp2(x, y, op) + } + case int64: + switch y := b.(type) { + case int64: + return x < y, nil + default: + return invOp2(x, y, op) + } + case string: + switch y := b.(type) { + case string: + return x < y, nil + default: + return invOp2(x, y, op) + } + case uint8: + switch y := b.(type) { + case uint8: + return x < y, nil + default: + return invOp2(x, y, op) + } + case uint16: + switch y := b.(type) { + case uint16: + return x < y, nil + default: + return invOp2(x, y, op) + } + case uint32: + switch y := b.(type) { + case uint32: + return x < y, nil + default: + return invOp2(x, y, op) + } + case uint64: + switch y := b.(type) { + case uint64: + return x < y, nil + default: + return invOp2(x, y, op) + } + case *big.Int: + switch y := b.(type) { + case *big.Int: + return x.Cmp(y) < 0, nil + default: + return invOp2(x, y, op) + } + case *big.Rat: + switch y := b.(type) { + case *big.Rat: + return x.Cmp(y) < 0, nil + default: + return invOp2(x, y, op) + } + case time.Duration: + switch y := b.(type) { + case time.Duration: + return x < y, nil + default: + return invOp2(x, y, op) + } + case time.Time: + switch y := b.(type) { + case time.Time: + return x.Before(y), nil + default: + return invOp2(x, y, op) + } + default: + return invOp2(a, b, op) + } + case le: + a, b := o.get2(execCtx, ctx) + if a == nil || b == nil { + return + } + switch x := a.(type) { + //case nil: + case idealComplex: + return undOp2(a, b, op) + case idealFloat: + switch y := b.(type) { + case idealFloat: + return x <= y, nil + default: + return invOp2(x, y, op) + } + case idealInt: + switch y := b.(type) { + case idealInt: + return x <= y, nil + default: + return invOp2(x, y, op) + } + case idealRune: + switch y := b.(type) { + case idealRune: + return x <= y, nil + default: + return invOp2(x, y, op) + } + case idealUint: + switch y := b.(type) { + case idealUint: + return x <= y, nil + default: + return invOp2(x, y, op) + } + case bool: + return undOp2(a, b, op) + case complex64: + return undOp2(a, b, op) + case complex128: + return undOp2(a, b, op) + case float32: + switch y := b.(type) { + case float32: + return x <= y, nil + default: + return invOp2(x, y, op) + } + case float64: + switch y := b.(type) { + case float64: + return x <= y, nil + default: + return invOp2(x, y, op) + } + case int8: + switch y := b.(type) { + case int8: + return x <= y, nil + default: + return invOp2(x, y, op) + } + case int16: + switch y := b.(type) { + case int16: + return x <= y, nil + default: + return invOp2(x, y, op) + } + case int32: + switch y := b.(type) { + case int32: + return x <= y, nil + default: + return invOp2(x, y, op) + } + case int64: + switch y := b.(type) { + case int64: + return x <= y, nil + default: + return invOp2(x, y, op) + } + case string: + switch y := b.(type) { + case string: + return x <= y, nil + default: + return invOp2(x, y, op) + } + case uint8: + switch y := b.(type) { + case uint8: + return x <= y, nil + default: + return invOp2(x, y, op) + } + case uint16: + switch y := b.(type) { + case uint16: + return x <= y, nil + default: + return invOp2(x, y, op) + } + case uint32: + switch y := b.(type) { + case uint32: + return x <= y, nil + default: + return invOp2(x, y, op) + } + case uint64: + switch y := b.(type) { + case uint64: + return x <= y, nil + default: + return invOp2(x, y, op) + } + case *big.Int: + switch y := b.(type) { + case *big.Int: + return x.Cmp(y) <= 0, nil + default: + return invOp2(x, y, op) + } + case *big.Rat: + switch y := b.(type) { + case *big.Rat: + return x.Cmp(y) <= 0, nil + default: + return invOp2(x, y, op) + } + case time.Duration: + switch y := b.(type) { + case time.Duration: + return x <= y, nil + default: + return invOp2(x, y, op) + } + case time.Time: + switch y := b.(type) { + case time.Time: + return x.Before(y) || x.Equal(y), nil + default: + return invOp2(x, y, op) + } + default: + return invOp2(a, b, op) + } + case ge: + a, b := o.get2(execCtx, ctx) + if a == nil || b == nil { + return + } + switch x := a.(type) { + //case nil: + case idealComplex: + return undOp2(a, b, op) + case idealFloat: + switch y := b.(type) { + case idealFloat: + return x >= y, nil + default: + return invOp2(x, y, op) + } + case idealInt: + switch y := b.(type) { + case idealInt: + return x >= y, nil + default: + return invOp2(x, y, op) + } + case idealRune: + switch y := b.(type) { + case idealRune: + return x >= y, nil + default: + return invOp2(x, y, op) + } + case idealUint: + switch y := b.(type) { + case idealUint: + return x >= y, nil + default: + return invOp2(x, y, op) + } + case bool: + return undOp2(a, b, op) + case complex64: + return undOp2(a, b, op) + case complex128: + return undOp2(a, b, op) + case float32: + switch y := b.(type) { + case float32: + return x >= y, nil + default: + return invOp2(x, y, op) + } + case float64: + switch y := b.(type) { + case float64: + return x >= y, nil + default: + return invOp2(x, y, op) + } + case int8: + switch y := b.(type) { + case int8: + return x >= y, nil + default: + return invOp2(x, y, op) + } + case int16: + switch y := b.(type) { + case int16: + return x >= y, nil + default: + return invOp2(x, y, op) + } + case int32: + switch y := b.(type) { + case int32: + return x >= y, nil + default: + return invOp2(x, y, op) + } + case int64: + switch y := b.(type) { + case int64: + return x >= y, nil + default: + return invOp2(x, y, op) + } + case string: + switch y := b.(type) { + case string: + return x >= y, nil + default: + return invOp2(x, y, op) + } + case uint8: + switch y := b.(type) { + case uint8: + return x >= y, nil + default: + return invOp2(x, y, op) + } + case uint16: + switch y := b.(type) { + case uint16: + return x >= y, nil + default: + return invOp2(x, y, op) + } + case uint32: + switch y := b.(type) { + case uint32: + return x >= y, nil + default: + return invOp2(x, y, op) + } + case uint64: + switch y := b.(type) { + case uint64: + return x >= y, nil + default: + return invOp2(x, y, op) + } + case *big.Int: + switch y := b.(type) { + case *big.Int: + return x.Cmp(y) >= 0, nil + default: + return invOp2(x, y, op) + } + case *big.Rat: + switch y := b.(type) { + case *big.Rat: + return x.Cmp(y) >= 0, nil + default: + return invOp2(x, y, op) + } + case time.Duration: + switch y := b.(type) { + case time.Duration: + return x >= y, nil + default: + return invOp2(x, y, op) + } + case time.Time: + switch y := b.(type) { + case time.Time: + return x.After(y) || x.Equal(y), nil + default: + return invOp2(x, y, op) + } + default: + return invOp2(a, b, op) + } + case neq: + a, b := o.get2(execCtx, ctx) + if a == nil || b == nil { + return + } + switch x := a.(type) { + //case nil: + case idealComplex: + switch y := b.(type) { + case idealComplex: + return x != y, nil + default: + return invOp2(x, y, op) + } + case idealFloat: + switch y := b.(type) { + case idealFloat: + return x != y, nil + default: + return invOp2(x, y, op) + } + case idealInt: + switch y := b.(type) { + case idealInt: + return x != y, nil + default: + return invOp2(x, y, op) + } + case idealRune: + switch y := b.(type) { + case idealRune: + return x != y, nil + default: + return invOp2(x, y, op) + } + case idealUint: + switch y := b.(type) { + case idealUint: + return x != y, nil + default: + return invOp2(x, y, op) + } + case bool: + switch y := b.(type) { + case bool: + return x != y, nil + default: + return invOp2(x, y, op) + } + case complex64: + switch y := b.(type) { + case complex64: + return x != y, nil + default: + return invOp2(x, y, op) + } + case complex128: + switch y := b.(type) { + case complex128: + return x != y, nil + default: + return invOp2(x, y, op) + } + case float32: + switch y := b.(type) { + case float32: + return x != y, nil + default: + return invOp2(x, y, op) + } + case float64: + switch y := b.(type) { + case float64: + return x != y, nil + default: + return invOp2(x, y, op) + } + case int8: + switch y := b.(type) { + case int8: + return x != y, nil + default: + return invOp2(x, y, op) + } + case int16: + switch y := b.(type) { + case int16: + return x != y, nil + default: + return invOp2(x, y, op) + } + case int32: + switch y := b.(type) { + case int32: + return x != y, nil + default: + return invOp2(x, y, op) + } + case int64: + switch y := b.(type) { + case int64: + return x != y, nil + default: + return invOp2(x, y, op) + } + case string: + switch y := b.(type) { + case string: + return x != y, nil + default: + return invOp2(x, y, op) + } + case uint8: + switch y := b.(type) { + case uint8: + return x != y, nil + default: + return invOp2(x, y, op) + } + case uint16: + switch y := b.(type) { + case uint16: + return x != y, nil + default: + return invOp2(x, y, op) + } + case uint32: + switch y := b.(type) { + case uint32: + return x != y, nil + default: + return invOp2(x, y, op) + } + case uint64: + switch y := b.(type) { + case uint64: + return x != y, nil + default: + return invOp2(x, y, op) + } + case *big.Int: + switch y := b.(type) { + case *big.Int: + return x.Cmp(y) != 0, nil + default: + return invOp2(x, y, op) + } + case *big.Rat: + switch y := b.(type) { + case *big.Rat: + return x.Cmp(y) != 0, nil + default: + return invOp2(x, y, op) + } + case time.Duration: + switch y := b.(type) { + case time.Duration: + return x != y, nil + default: + return invOp2(x, y, op) + } + case time.Time: + switch y := b.(type) { + case time.Time: + return !x.Equal(y), nil + default: + return invOp2(x, y, op) + } + default: + return invOp2(a, b, op) + } + case eq: + a, b := o.get2(execCtx, ctx) + if a == nil || b == nil { + return + } + switch x := a.(type) { + //case nil: + case idealComplex: + switch y := b.(type) { + case idealComplex: + return x == y, nil + default: + return invOp2(x, y, op) + } + case idealFloat: + switch y := b.(type) { + case idealFloat: + return x == y, nil + default: + return invOp2(x, y, op) + } + case idealInt: + switch y := b.(type) { + case idealInt: + return x == y, nil + default: + return invOp2(x, y, op) + } + case idealRune: + switch y := b.(type) { + case idealRune: + return x == y, nil + default: + return invOp2(x, y, op) + } + case idealUint: + switch y := b.(type) { + case idealUint: + return x == y, nil + default: + return invOp2(x, y, op) + } + case bool: + switch y := b.(type) { + case bool: + return x == y, nil + default: + return invOp2(x, y, op) + } + case complex64: + switch y := b.(type) { + case complex64: + return x == y, nil + default: + return invOp2(x, y, op) + } + case complex128: + switch y := b.(type) { + case complex128: + return x == y, nil + default: + return invOp2(x, y, op) + } + case float32: + switch y := b.(type) { + case float32: + return x == y, nil + default: + return invOp2(x, y, op) + } + case float64: + switch y := b.(type) { + case float64: + return x == y, nil + default: + return invOp2(x, y, op) + } + case int8: + switch y := b.(type) { + case int8: + return x == y, nil + default: + return invOp2(x, y, op) + } + case int16: + switch y := b.(type) { + case int16: + return x == y, nil + default: + return invOp2(x, y, op) + } + case int32: + switch y := b.(type) { + case int32: + return x == y, nil + default: + return invOp2(x, y, op) + } + case int64: + switch y := b.(type) { + case int64: + return x == y, nil + default: + return invOp2(x, y, op) + } + case string: + switch y := b.(type) { + case string: + return x == y, nil + default: + return invOp2(x, y, op) + } + case uint8: + switch y := b.(type) { + case uint8: + return x == y, nil + default: + return invOp2(x, y, op) + } + case uint16: + switch y := b.(type) { + case uint16: + return x == y, nil + default: + return invOp2(x, y, op) + } + case uint32: + switch y := b.(type) { + case uint32: + return x == y, nil + default: + return invOp2(x, y, op) + } + case uint64: + switch y := b.(type) { + case uint64: + return x == y, nil + default: + return invOp2(x, y, op) + } + case *big.Int: + switch y := b.(type) { + case *big.Int: + return x.Cmp(y) == 0, nil + default: + return invOp2(x, y, op) + } + case *big.Rat: + switch y := b.(type) { + case *big.Rat: + return x.Cmp(y) == 0, nil + default: + return invOp2(x, y, op) + } + case time.Duration: + switch y := b.(type) { + case time.Duration: + return x == y, nil + default: + return invOp2(x, y, op) + } + case time.Time: + switch y := b.(type) { + case time.Time: + return x.Equal(y), nil + default: + return invOp2(x, y, op) + } + default: + return invOp2(a, b, op) + } + case '+': + a, b := o.get2(execCtx, ctx) + if a == nil || b == nil { + return + } + switch x := a.(type) { + //case nil: + case idealComplex: + switch y := b.(type) { + case idealComplex: + return idealComplex(complex64(x) + complex64(y)), nil + default: + return invOp2(x, y, op) + } + case idealFloat: + switch y := b.(type) { + case idealFloat: + return idealFloat(float64(x) + float64(y)), nil + default: + return invOp2(x, y, op) + } + case idealInt: + switch y := b.(type) { + case idealInt: + return idealInt(int64(x) + int64(y)), nil + default: + return invOp2(x, y, op) + } + case idealRune: + switch y := b.(type) { + case idealRune: + return idealRune(int64(x) + int64(y)), nil + default: + return invOp2(x, y, op) + } + case idealUint: + switch y := b.(type) { + case idealUint: + return idealUint(uint64(x) + uint64(y)), nil + default: + return invOp2(x, y, op) + } + case bool: + return undOp2(a, b, op) + case complex64: + switch y := b.(type) { + case complex64: + return x + y, nil + default: + return invOp2(x, y, op) + } + case complex128: + switch y := b.(type) { + case complex128: + return x + y, nil + default: + return invOp2(x, y, op) + } + case float32: + switch y := b.(type) { + case float32: + return x + y, nil + default: + return invOp2(x, y, op) + } + case float64: + switch y := b.(type) { + case float64: + return x + y, nil + default: + return invOp2(x, y, op) + } + case int8: + switch y := b.(type) { + case int8: + return x + y, nil + default: + return invOp2(x, y, op) + } + case int16: + switch y := b.(type) { + case int16: + return x + y, nil + default: + return invOp2(x, y, op) + } + case int32: + switch y := b.(type) { + case int32: + return x + y, nil + default: + return invOp2(x, y, op) + } + case int64: + switch y := b.(type) { + case int64: + return x + y, nil + default: + return invOp2(x, y, op) + } + case string: + switch y := b.(type) { + case string: + return x + y, nil + default: + return invOp2(x, y, op) + } + case uint8: + switch y := b.(type) { + case uint8: + return x + y, nil + default: + return invOp2(x, y, op) + } + case uint16: + switch y := b.(type) { + case uint16: + return x + y, nil + default: + return invOp2(x, y, op) + } + case uint32: + switch y := b.(type) { + case uint32: + return x + y, nil + default: + return invOp2(x, y, op) + } + case uint64: + switch y := b.(type) { + case uint64: + return x + y, nil + default: + return invOp2(x, y, op) + } + case *big.Int: + switch y := b.(type) { + case *big.Int: + var z big.Int + return z.Add(x, y), nil + default: + return invOp2(x, y, op) + } + case *big.Rat: + switch y := b.(type) { + case *big.Rat: + var z big.Rat + return z.Add(x, y), nil + default: + return invOp2(x, y, op) + } + case time.Duration: + switch y := b.(type) { + case time.Duration: + return x + y, nil + case time.Time: + return y.Add(x), nil + default: + return invOp2(x, y, op) + } + case time.Time: + switch y := b.(type) { + case time.Duration: + return x.Add(y), nil + default: + return invOp2(x, y, op) + } + default: + return invOp2(a, b, op) + } + case '-': + a, b := o.get2(execCtx, ctx) + if a == nil || b == nil { + return + } + switch x := a.(type) { + //case nil: + case idealComplex: + switch y := b.(type) { + case idealComplex: + return idealComplex(complex64(x) - complex64(y)), nil + default: + return invOp2(x, y, op) + } + case idealFloat: + switch y := b.(type) { + case idealFloat: + return idealFloat(float64(x) - float64(y)), nil + default: + return invOp2(x, y, op) + } + case idealInt: + switch y := b.(type) { + case idealInt: + return idealInt(int64(x) - int64(y)), nil + default: + return invOp2(x, y, op) + } + case idealRune: + switch y := b.(type) { + case idealRune: + return idealRune(int64(x) - int64(y)), nil + default: + return invOp2(x, y, op) + } + case idealUint: + switch y := b.(type) { + case idealUint: + return idealUint(uint64(x) - uint64(y)), nil + default: + return invOp2(x, y, op) + } + case bool: + return undOp2(a, b, op) + case complex64: + switch y := b.(type) { + case complex64: + return x - y, nil + default: + return invOp2(x, y, op) + } + case complex128: + switch y := b.(type) { + case complex128: + return x - y, nil + default: + return invOp2(x, y, op) + } + case float32: + switch y := b.(type) { + case float32: + return x - y, nil + default: + return invOp2(x, y, op) + } + case float64: + switch y := b.(type) { + case float64: + return x - y, nil + default: + return invOp2(x, y, op) + } + case int8: + switch y := b.(type) { + case int8: + return x - y, nil + default: + return invOp2(x, y, op) + } + case int16: + switch y := b.(type) { + case int16: + return x - y, nil + default: + return invOp2(x, y, op) + } + case int32: + switch y := b.(type) { + case int32: + return x - y, nil + default: + return invOp2(x, y, op) + } + case int64: + switch y := b.(type) { + case int64: + return x - y, nil + default: + return invOp2(x, y, op) + } + case string: + return undOp2(a, b, op) + case uint8: + switch y := b.(type) { + case uint8: + return x - y, nil + default: + return invOp2(x, y, op) + } + case uint16: + switch y := b.(type) { + case uint16: + return x - y, nil + default: + return invOp2(x, y, op) + } + case uint32: + switch y := b.(type) { + case uint32: + return x - y, nil + default: + return invOp2(x, y, op) + } + case uint64: + switch y := b.(type) { + case uint64: + return x - y, nil + default: + return invOp2(x, y, op) + } + case *big.Int: + switch y := b.(type) { + case *big.Int: + var z big.Int + return z.Sub(x, y), nil + default: + return invOp2(x, y, op) + } + case *big.Rat: + switch y := b.(type) { + case *big.Rat: + var z big.Rat + return z.Sub(x, y), nil + default: + return invOp2(x, y, op) + } + case time.Duration: + switch y := b.(type) { + case time.Duration: + return x - y, nil + default: + return invOp2(x, y, op) + } + case time.Time: + switch y := b.(type) { + case time.Duration: + return x.Add(-y), nil + case time.Time: + return x.Sub(y), nil + default: + return invOp2(x, y, op) + } + default: + return invOp2(a, b, op) + } + case rsh: + a, b := eval2(o.l, o.r, execCtx, ctx) + if a == nil || b == nil { + return + } + + var cnt uint64 + switch y := b.(type) { + //case nil: + case idealComplex: + return invShiftRHS(a, b) + case idealFloat: + return invShiftRHS(a, b) + case idealInt: + cnt = uint64(y) + case idealRune: + cnt = uint64(y) + case idealUint: + cnt = uint64(y) + case bool: + return invShiftRHS(a, b) + case complex64: + return invShiftRHS(a, b) + case complex128: + return invShiftRHS(a, b) + case float32: + return invShiftRHS(a, b) + case float64: + return invShiftRHS(a, b) + case int8: + return invShiftRHS(a, b) + case int16: + return invShiftRHS(a, b) + case int32: + return invShiftRHS(a, b) + case int64: + return invShiftRHS(a, b) + case string: + return invShiftRHS(a, b) + case uint8: + cnt = uint64(y) + case uint16: + cnt = uint64(y) + case uint32: + cnt = uint64(y) + case uint64: + cnt = uint64(y) + default: + return invOp2(a, b, op) + } + + switch x := a.(type) { + //case nil: + case idealComplex: + return undOp2(a, b, op) + case idealFloat: + return undOp2(a, b, op) + case idealInt: + return idealInt(int64(x) >> cnt), nil + case idealRune: + return idealRune(int64(x) >> cnt), nil + case idealUint: + return idealUint(uint64(x) >> cnt), nil + case bool: + return undOp2(a, b, op) + case complex64: + return undOp2(a, b, op) + case complex128: + return undOp2(a, b, op) + case float32: + return undOp2(a, b, op) + case float64: + return undOp2(a, b, op) + case int8: + return x >> cnt, nil + case int16: + return x >> cnt, nil + case int32: + return x >> cnt, nil + case int64: + return x >> cnt, nil + case string: + return undOp2(a, b, op) + case uint8: + return x >> cnt, nil + case uint16: + return x >> cnt, nil + case uint32: + return x >> cnt, nil + case uint64: + return x >> cnt, nil + case *big.Int: + var z big.Int + return z.Rsh(x, uint(cnt)), nil + case time.Duration: + return x >> cnt, nil + default: + return invOp2(a, b, op) + } + case lsh: + a, b := eval2(o.l, o.r, execCtx, ctx) + if a == nil || b == nil { + return + } + + var cnt uint64 + switch y := b.(type) { + //case nil: + case idealComplex: + return invShiftRHS(a, b) + case idealFloat: + return invShiftRHS(a, b) + case idealInt: + cnt = uint64(y) + case idealRune: + cnt = uint64(y) + case idealUint: + cnt = uint64(y) + case bool: + return invShiftRHS(a, b) + case complex64: + return invShiftRHS(a, b) + case complex128: + return invShiftRHS(a, b) + case float32: + return invShiftRHS(a, b) + case float64: + return invShiftRHS(a, b) + case int8: + return invShiftRHS(a, b) + case int16: + return invShiftRHS(a, b) + case int32: + return invShiftRHS(a, b) + case int64: + return invShiftRHS(a, b) + case string: + return invShiftRHS(a, b) + case uint8: + cnt = uint64(y) + case uint16: + cnt = uint64(y) + case uint32: + cnt = uint64(y) + case uint64: + cnt = uint64(y) + default: + return invOp2(a, b, op) + } + + switch x := a.(type) { + //case nil: + case idealComplex: + return undOp2(a, b, op) + case idealFloat: + return undOp2(a, b, op) + case idealInt: + return idealInt(int64(x) << cnt), nil + case idealRune: + return idealRune(int64(x) << cnt), nil + case idealUint: + return idealUint(uint64(x) << cnt), nil + case bool: + return undOp2(a, b, op) + case complex64: + return undOp2(a, b, op) + case complex128: + return undOp2(a, b, op) + case float32: + return undOp2(a, b, op) + case float64: + return undOp2(a, b, op) + case int8: + return x << cnt, nil + case int16: + return x << cnt, nil + case int32: + return x << cnt, nil + case int64: + return x << cnt, nil + case string: + return undOp2(a, b, op) + case uint8: + return x << cnt, nil + case uint16: + return x << cnt, nil + case uint32: + return x << cnt, nil + case uint64: + return x << cnt, nil + case *big.Int: + var z big.Int + return z.Lsh(x, uint(cnt)), nil + case time.Duration: + return x << cnt, nil + default: + return invOp2(a, b, op) + } + case '&': + a, b := o.get2(execCtx, ctx) + if a == nil || b == nil { + return + } + switch x := a.(type) { + //case nil: + case idealComplex: + return undOp2(a, b, op) + case idealFloat: + return undOp2(a, b, op) + case idealInt: + switch y := b.(type) { + case idealInt: + return idealInt(int64(x) & int64(y)), nil + default: + return invOp2(x, y, op) + } + case idealRune: + switch y := b.(type) { + case idealRune: + return idealRune(int64(x) & int64(y)), nil + default: + return invOp2(x, y, op) + } + case idealUint: + switch y := b.(type) { + case idealUint: + return idealUint(uint64(x) & uint64(y)), nil + default: + return invOp2(x, y, op) + } + case bool: + return undOp2(a, b, op) + case complex64: + return undOp2(a, b, op) + case complex128: + return undOp2(a, b, op) + case float32: + return undOp2(a, b, op) + case float64: + return undOp2(a, b, op) + case int8: + switch y := b.(type) { + case int8: + return x & y, nil + default: + return invOp2(x, y, op) + } + case int16: + switch y := b.(type) { + case int16: + return x & y, nil + default: + return invOp2(x, y, op) + } + case int32: + switch y := b.(type) { + case int32: + return x & y, nil + default: + return invOp2(x, y, op) + } + case int64: + switch y := b.(type) { + case int64: + return x & y, nil + default: + return invOp2(x, y, op) + } + case string: + return undOp2(a, b, op) + case uint8: + switch y := b.(type) { + case uint8: + return x & y, nil + default: + return invOp2(x, y, op) + } + case uint16: + switch y := b.(type) { + case uint16: + return x & y, nil + default: + return invOp2(x, y, op) + } + case uint32: + switch y := b.(type) { + case uint32: + return x & y, nil + default: + return invOp2(x, y, op) + } + case uint64: + switch y := b.(type) { + case uint64: + return x & y, nil + default: + return invOp2(x, y, op) + } + case *big.Int: + switch y := b.(type) { + case *big.Int: + var z big.Int + return z.And(x, y), nil + default: + return invOp2(x, y, op) + } + case time.Duration: + switch y := b.(type) { + case time.Duration: + return x & y, nil + default: + return invOp2(x, y, op) + } + default: + return invOp2(a, b, op) + } + case '|': + a, b := o.get2(execCtx, ctx) + if a == nil || b == nil { + return + } + switch x := a.(type) { + //case nil: + case idealComplex: + return undOp2(a, b, op) + case idealFloat: + return undOp2(a, b, op) + case idealInt: + switch y := b.(type) { + case idealInt: + return idealInt(int64(x) | int64(y)), nil + default: + return invOp2(x, y, op) + } + case idealRune: + switch y := b.(type) { + case idealRune: + return idealRune(int64(x) | int64(y)), nil + default: + return invOp2(x, y, op) + } + case idealUint: + switch y := b.(type) { + case idealUint: + return idealUint(uint64(x) | uint64(y)), nil + default: + return invOp2(x, y, op) + } + case bool: + return undOp2(a, b, op) + case complex64: + return undOp2(a, b, op) + case complex128: + return undOp2(a, b, op) + case float32: + return undOp2(a, b, op) + case float64: + return undOp2(a, b, op) + case int8: + switch y := b.(type) { + case int8: + return x | y, nil + default: + return invOp2(x, y, op) + } + case int16: + switch y := b.(type) { + case int16: + return x | y, nil + default: + return invOp2(x, y, op) + } + case int32: + switch y := b.(type) { + case int32: + return x | y, nil + default: + return invOp2(x, y, op) + } + case int64: + switch y := b.(type) { + case int64: + return x | y, nil + default: + return invOp2(x, y, op) + } + case string: + return undOp2(a, b, op) + case uint8: + switch y := b.(type) { + case uint8: + return x | y, nil + default: + return invOp2(x, y, op) + } + case uint16: + switch y := b.(type) { + case uint16: + return x | y, nil + default: + return invOp2(x, y, op) + } + case uint32: + switch y := b.(type) { + case uint32: + return x | y, nil + default: + return invOp2(x, y, op) + } + case uint64: + switch y := b.(type) { + case uint64: + return x | y, nil + default: + return invOp2(x, y, op) + } + case *big.Int: + switch y := b.(type) { + case *big.Int: + var z big.Int + return z.Or(x, y), nil + default: + return invOp2(x, y, op) + } + case time.Duration: + switch y := b.(type) { + case time.Duration: + return x | y, nil + default: + return invOp2(x, y, op) + } + default: + return invOp2(a, b, op) + } + case andnot: + a, b := o.get2(execCtx, ctx) + if a == nil || b == nil { + return + } + switch x := a.(type) { + //case nil: + case idealComplex: + return undOp2(a, b, op) + case idealFloat: + return undOp2(a, b, op) + case idealInt: + switch y := b.(type) { + case idealInt: + return idealInt(int64(x) &^ int64(y)), nil + default: + return invOp2(x, y, op) + } + case idealRune: + switch y := b.(type) { + case idealRune: + return idealRune(int64(x) &^ int64(y)), nil + default: + return invOp2(x, y, op) + } + case idealUint: + switch y := b.(type) { + case idealUint: + return idealUint(uint64(x) &^ uint64(y)), nil + default: + return invOp2(x, y, op) + } + case bool: + return undOp2(a, b, op) + case complex64: + return undOp2(a, b, op) + case complex128: + return undOp2(a, b, op) + case float32: + return undOp2(a, b, op) + case float64: + return undOp2(a, b, op) + case int8: + switch y := b.(type) { + case int8: + return x &^ y, nil + default: + return invOp2(x, y, op) + } + case int16: + switch y := b.(type) { + case int16: + return x &^ y, nil + default: + return invOp2(x, y, op) + } + case int32: + switch y := b.(type) { + case int32: + return x &^ y, nil + default: + return invOp2(x, y, op) + } + case int64: + switch y := b.(type) { + case int64: + return x &^ y, nil + default: + return invOp2(x, y, op) + } + case string: + return undOp2(a, b, op) + case uint8: + switch y := b.(type) { + case uint8: + return x &^ y, nil + default: + return invOp2(x, y, op) + } + case uint16: + switch y := b.(type) { + case uint16: + return x &^ y, nil + default: + return invOp2(x, y, op) + } + case uint32: + switch y := b.(type) { + case uint32: + return x &^ y, nil + default: + return invOp2(x, y, op) + } + case uint64: + switch y := b.(type) { + case uint64: + return x &^ y, nil + default: + return invOp2(x, y, op) + } + case *big.Int: + switch y := b.(type) { + case *big.Int: + var z big.Int + return z.AndNot(x, y), nil + default: + return invOp2(x, y, op) + } + case time.Duration: + switch y := b.(type) { + case time.Duration: + return x &^ y, nil + default: + return invOp2(x, y, op) + } + default: + return invOp2(a, b, op) + } + case '^': + a, b := o.get2(execCtx, ctx) + if a == nil || b == nil { + return + } + switch x := a.(type) { + //case nil: + case idealComplex: + return undOp2(a, b, op) + case idealFloat: + return undOp2(a, b, op) + case idealInt: + switch y := b.(type) { + case idealInt: + return idealInt(int64(x) ^ int64(y)), nil + default: + return invOp2(x, y, op) + } + case idealRune: + switch y := b.(type) { + case idealRune: + return idealRune(int64(x) ^ int64(y)), nil + default: + return invOp2(x, y, op) + } + case idealUint: + switch y := b.(type) { + case idealUint: + return idealUint(uint64(x) ^ uint64(y)), nil + default: + return invOp2(x, y, op) + } + case bool: + return undOp2(a, b, op) + case complex64: + return undOp2(a, b, op) + case complex128: + return undOp2(a, b, op) + case float32: + return undOp2(a, b, op) + case float64: + return undOp2(a, b, op) + case int8: + switch y := b.(type) { + case int8: + return x ^ y, nil + default: + return invOp2(x, y, op) + } + case int16: + switch y := b.(type) { + case int16: + return x ^ y, nil + default: + return invOp2(x, y, op) + } + case int32: + switch y := b.(type) { + case int32: + return x ^ y, nil + default: + return invOp2(x, y, op) + } + case int64: + switch y := b.(type) { + case int64: + return x ^ y, nil + default: + return invOp2(x, y, op) + } + case string: + return undOp2(a, b, op) + case uint8: + switch y := b.(type) { + case uint8: + return x ^ y, nil + default: + return invOp2(x, y, op) + } + case uint16: + switch y := b.(type) { + case uint16: + return x ^ y, nil + default: + return invOp2(x, y, op) + } + case uint32: + switch y := b.(type) { + case uint32: + return x ^ y, nil + default: + return invOp2(x, y, op) + } + case uint64: + switch y := b.(type) { + case uint64: + return x ^ y, nil + default: + return invOp2(x, y, op) + } + case *big.Int: + switch y := b.(type) { + case *big.Int: + var z big.Int + return z.Xor(x, y), nil + default: + return invOp2(x, y, op) + } + case time.Duration: + switch y := b.(type) { + case time.Duration: + return x ^ y, nil + default: + return invOp2(x, y, op) + } + default: + return invOp2(a, b, op) + } + case '%': + a, b := o.get2(execCtx, ctx) + if a == nil || b == nil { + return + } + switch x := a.(type) { + //case nil: + case idealComplex: + return undOp2(a, b, op) + case idealFloat: + return undOp2(a, b, op) + case idealInt: + switch y := b.(type) { + case idealInt: + return idealInt(int64(x) % int64(y)), nil + default: + return invOp2(x, y, op) + } + case idealRune: + switch y := b.(type) { + case idealRune: + return idealRune(int64(x) % int64(y)), nil + default: + return invOp2(x, y, op) + } + case idealUint: + switch y := b.(type) { + case idealUint: + return idealUint(uint64(x) % uint64(y)), nil + default: + return invOp2(x, y, op) + } + case bool: + return undOp2(a, b, op) + case complex64: + return undOp2(a, b, op) + case complex128: + return undOp2(a, b, op) + case float32: + return undOp2(a, b, op) + case float64: + return undOp2(a, b, op) + case int8: + switch y := b.(type) { + case int8: + return x % y, nil + default: + return invOp2(x, y, op) + } + case int16: + switch y := b.(type) { + case int16: + return x % y, nil + default: + return invOp2(x, y, op) + } + case int32: + switch y := b.(type) { + case int32: + return x % y, nil + default: + return invOp2(x, y, op) + } + case int64: + switch y := b.(type) { + case int64: + return x % y, nil + default: + return invOp2(x, y, op) + } + case string: + return undOp2(a, b, op) + case uint8: + switch y := b.(type) { + case uint8: + return x % y, nil + default: + return invOp2(x, y, op) + } + case uint16: + switch y := b.(type) { + case uint16: + return x % y, nil + default: + return invOp2(x, y, op) + } + case uint32: + switch y := b.(type) { + case uint32: + return x % y, nil + default: + return invOp2(x, y, op) + } + case uint64: + switch y := b.(type) { + case uint64: + return x % y, nil + default: + return invOp2(x, y, op) + } + case *big.Int: + switch y := b.(type) { + case *big.Int: + if y.Sign() == 0 { + return nil, errDivByZero + } + + var z big.Int + return z.Mod(x, y), nil + default: + return invOp2(x, y, op) + } + case time.Duration: + switch y := b.(type) { + case time.Duration: + return x % y, nil + default: + return invOp2(x, y, op) + } + default: + return invOp2(a, b, op) + } + case '/': + a, b := o.get2(execCtx, ctx) + if a == nil || b == nil { + return + } + switch x := a.(type) { + //case nil: + case idealComplex: + switch y := b.(type) { + case idealComplex: + return idealComplex(complex64(x) / complex64(y)), nil + default: + return invOp2(x, y, op) + } + case idealFloat: + switch y := b.(type) { + case idealFloat: + return idealFloat(float64(x) / float64(y)), nil + default: + return invOp2(x, y, op) + } + case idealInt: + switch y := b.(type) { + case idealInt: + return idealInt(int64(x) / int64(y)), nil + default: + return invOp2(x, y, op) + } + case idealRune: + switch y := b.(type) { + case idealRune: + return idealRune(int64(x) / int64(y)), nil + default: + return invOp2(x, y, op) + } + case idealUint: + switch y := b.(type) { + case idealUint: + return idealUint(uint64(x) / uint64(y)), nil + default: + return invOp2(x, y, op) + } + case bool: + return undOp2(a, b, op) + case complex64: + switch y := b.(type) { + case complex64: + return x / y, nil + default: + return invOp2(x, y, op) + } + case complex128: + switch y := b.(type) { + case complex128: + return x / y, nil + default: + return invOp2(x, y, op) + } + case float32: + switch y := b.(type) { + case float32: + return x / y, nil + default: + return invOp2(x, y, op) + } + case float64: + switch y := b.(type) { + case float64: + return x / y, nil + default: + return invOp2(x, y, op) + } + case int8: + switch y := b.(type) { + case int8: + return x / y, nil + default: + return invOp2(x, y, op) + } + case int16: + switch y := b.(type) { + case int16: + return x / y, nil + default: + return invOp2(x, y, op) + } + case int32: + switch y := b.(type) { + case int32: + return x / y, nil + default: + return invOp2(x, y, op) + } + case int64: + switch y := b.(type) { + case int64: + return x / y, nil + default: + return invOp2(x, y, op) + } + case string: + return undOp2(a, b, op) + case uint8: + switch y := b.(type) { + case uint8: + return x / y, nil + default: + return invOp2(x, y, op) + } + case uint16: + switch y := b.(type) { + case uint16: + return x / y, nil + default: + return invOp2(x, y, op) + } + case uint32: + switch y := b.(type) { + case uint32: + return x / y, nil + default: + return invOp2(x, y, op) + } + case uint64: + switch y := b.(type) { + case uint64: + return x / y, nil + default: + return invOp2(x, y, op) + } + case *big.Int: + switch y := b.(type) { + case *big.Int: + if y.Sign() == 0 { + return nil, errDivByZero + } + + var z big.Int + return z.Quo(x, y), nil + default: + return invOp2(x, y, op) + } + case *big.Rat: + switch y := b.(type) { + case *big.Rat: + if y.Sign() == 0 { + return nil, errDivByZero + } + + var z big.Rat + return z.Quo(x, y), nil + default: + return invOp2(x, y, op) + } + case time.Duration: + switch y := b.(type) { + case time.Duration: + return x / y, nil + default: + return invOp2(x, y, op) + } + default: + return invOp2(a, b, op) + } + case '*': + a, b := o.get2(execCtx, ctx) + if a == nil || b == nil { + return + } + switch x := a.(type) { + //case nil: + case idealComplex: + switch y := b.(type) { + case idealComplex: + return idealComplex(complex64(x) * complex64(y)), nil + default: + return invOp2(x, y, op) + } + case idealFloat: + switch y := b.(type) { + case idealFloat: + return idealFloat(float64(x) * float64(y)), nil + default: + return invOp2(x, y, op) + } + case idealInt: + switch y := b.(type) { + case idealInt: + return idealInt(int64(x) * int64(y)), nil + default: + return invOp2(x, y, op) + } + case idealRune: + switch y := b.(type) { + case idealRune: + return idealRune(int64(x) * int64(y)), nil + default: + return invOp2(x, y, op) + } + case idealUint: + switch y := b.(type) { + case idealUint: + return idealUint(uint64(x) * uint64(y)), nil + default: + return invOp2(x, y, op) + } + case bool: + return undOp2(a, b, op) + case complex64: + switch y := b.(type) { + case complex64: + return x * y, nil + default: + return invOp2(x, y, op) + } + case complex128: + switch y := b.(type) { + case complex128: + return x * y, nil + default: + return invOp2(x, y, op) + } + case float32: + switch y := b.(type) { + case float32: + return x * y, nil + default: + return invOp2(x, y, op) + } + case float64: + switch y := b.(type) { + case float64: + return x * y, nil + default: + return invOp2(x, y, op) + } + case int8: + switch y := b.(type) { + case int8: + return x * y, nil + default: + return invOp2(x, y, op) + } + case int16: + switch y := b.(type) { + case int16: + return x * y, nil + default: + return invOp2(x, y, op) + } + case int32: + switch y := b.(type) { + case int32: + return x * y, nil + default: + return invOp2(x, y, op) + } + case int64: + switch y := b.(type) { + case int64: + return x * y, nil + default: + return invOp2(x, y, op) + } + case string: + return undOp2(a, b, op) + case uint8: + switch y := b.(type) { + case uint8: + return x * y, nil + default: + return invOp2(x, y, op) + } + case uint16: + switch y := b.(type) { + case uint16: + return x * y, nil + default: + return invOp2(x, y, op) + } + case uint32: + switch y := b.(type) { + case uint32: + return x * y, nil + default: + return invOp2(x, y, op) + } + case uint64: + switch y := b.(type) { + case uint64: + return x * y, nil + default: + return invOp2(x, y, op) + } + case *big.Int: + switch y := b.(type) { + case *big.Int: + var z big.Int + return z.Mul(x, y), nil + default: + return invOp2(x, y, op) + } + case *big.Rat: + switch y := b.(type) { + case *big.Rat: + var z big.Rat + return z.Mul(x, y), nil + default: + return invOp2(x, y, op) + } + case time.Duration: + switch y := b.(type) { + case time.Duration: + return x * y, nil + default: + return invOp2(x, y, op) + } + default: + return invOp2(a, b, op) + } + default: + panic("internal error 037") + } +} + +func (o *binaryOperation) get2(execCtx *execCtx, ctx map[interface{}]interface{}) (x, y interface{}) { + x, y = eval2(o.l, o.r, execCtx, ctx) + //dbg("get2 pIn - ", x, y) + //defer func() {dbg("get2 coerced ", x, y)}() + return coerce(x, y) +} + +type ident struct { + s string +} + +func (i *ident) clone(arg []interface{}, unqualify ...string) (expression, error) { + x := strings.IndexByte(i.s, '.') + if x < 0 { + return &ident{s: i.s}, nil + } + + q := i.s[:x] + for _, v := range unqualify { + if q == v { + return &ident{i.s[x+1:]}, nil + } + } + return &ident{s: i.s}, nil +} + +func (i *ident) isQualified() bool { return strings.Contains(i.s, ".") } + +func (i *ident) isStatic() bool { return false } + +func (i *ident) String() string { return i.s } + +func (i *ident) eval(execCtx *execCtx, ctx map[interface{}]interface{}) (v interface{}, err error) { + if _, ok := ctx["$agg0"]; ok { + return int64(0), nil + } + + //defer func() { dbg("ident %q -> %v %v", i.s, v, err) }() + v, ok := ctx[i.s] + if !ok { + err = fmt.Errorf("unknown field %s", i.s) + } + return +} + +type pInEval struct { + m map[interface{}]struct{} // IN (SELECT...) results + sample interface{} +} + +type pIn struct { + expr expression + list []expression + not bool + sel *selectStmt +} + +func (n *pIn) clone(arg []interface{}, unqualify ...string) (expression, error) { + expr, err := n.expr.clone(arg, unqualify...) + if err != nil { + return nil, err + } + + list, err := cloneExpressionList(arg, n.list) + if err != nil { + return nil, err + } + + return &pIn{ + expr: expr, + list: list, + not: n.not, + sel: n.sel, + }, nil +} + +func (n *pIn) isStatic() bool { + if !n.expr.isStatic() || n.sel != nil { + return false + } + + for _, v := range n.list { + if !v.isStatic() { + return false + } + } + return true +} + +//LATER newIn + +func (n *pIn) String() string { + if n.sel == nil { + a := []string{} + for _, v := range n.list { + a = append(a, v.String()) + } + if n.not { + return fmt.Sprintf("%s NOT IN (%s)", n.expr, strings.Join(a, ",")) + } + + return fmt.Sprintf("%s IN (%s)", n.expr, strings.Join(a, ",")) + } + + if n.not { + return fmt.Sprintf("%s NOT IN (%s)", n.expr, n.sel) + } + + return fmt.Sprintf("%s IN (%s)", n.expr, n.sel) +} + +func (n *pIn) eval(execCtx *execCtx, ctx map[interface{}]interface{}) (v interface{}, err error) { + lhs, err := expand1(n.expr.eval(execCtx, ctx)) + if err != nil { + return nil, err + } + + if lhs == nil { + return nil, nil //TODO Add test for NULL LHS. + } + + if n.sel == nil { + for _, v := range n.list { + b, err := newBinaryOperation(eq, value{lhs}, v) + if err != nil { + return nil, err + } + + eval, err := b.eval(execCtx, ctx) + if err != nil { + return nil, err + } + + if x, ok := eval.(bool); ok && x { + return !n.not, nil + } + } + return n.not, nil + } + + var ev *pInEval + ev0 := ctx[n] + if ev0 == nil { // SELECT not yet evaluated. + r, err := n.sel.plan(execCtx) + if err != nil { + return nil, err + } + + if g, e := len(r.fieldNames()), 1; g != e { + return false, fmt.Errorf("IN (%s): mismatched field count, have %d, need %d", n.sel, g, e) + } + + ev = &pInEval{m: map[interface{}]struct{}{}} + ctx[n] = ev + m := ev.m + typechecked := false + if err := r.do(execCtx, func(id interface{}, data []interface{}) (more bool, err error) { + if typechecked { + if data[0] == nil { + return true, nil + } + + m[data[0]] = struct{}{} + } + + if data[0] == nil { + return true, nil + } + + ev.sample = data[0] + switch ev.sample.(type) { + case bool, byte, complex128, complex64, float32, + float64, int16, int32, int64, int8, + string, uint16, uint32, uint64: + typechecked = true + m[ev.sample] = struct{}{} + return true, nil + default: + return false, fmt.Errorf("IN (%s): invalid field type: %T", n.sel, data[0]) + } + + }); err != nil { + return nil, err + } + } else { + ev = ev0.(*pInEval) + } + + if ev.sample == nil { + return nil, nil + } + + _, ok := ev.m[coerce1(lhs, ev.sample)] + return ok != n.not, nil +} + +type value struct { + val interface{} +} + +func (l value) clone(arg []interface{}, unqualify ...string) (expression, error) { + return value{val: l.val}, nil +} + +func (l value) isStatic() bool { return true } + +func (l value) String() string { + switch x := l.val.(type) { + case nil: + return "NULL" + case idealComplex: + s := fmt.Sprint(x) + return s[1 : len(s)-1] + case complex64: + s := fmt.Sprint(x) + return s[1 : len(s)-1] + case complex128: + s := fmt.Sprint(x) + return s[1 : len(s)-1] + case string: + return fmt.Sprintf("%q", x) + case time.Duration: + return fmt.Sprintf("duration(%q)", l.val) + case time.Time: + return fmt.Sprintf("time(%q)", l.val) + case *big.Rat: + return fmt.Sprintf("bigrat(%q)", l.val) + case *big.Int: + return fmt.Sprintf(`bigint("%v")`, l.val) + default: + return fmt.Sprintf("%v", l.val) + } +} + +func (l value) eval(execCtx *execCtx, ctx map[interface{}]interface{}) (interface{}, error) { + return l.val, nil +} + +type conversion struct { + typ int + val expression +} + +func (c *conversion) clone(arg []interface{}, unqualify ...string) (expression, error) { + val, err := c.val.clone(arg, unqualify...) + if err != nil { + return nil, err + } + + return &conversion{typ: c.typ, val: val}, nil +} + +func (c *conversion) isStatic() bool { + return c.val.isStatic() +} + +//LATER newConversion or fake unary op + +func (c *conversion) String() string { + return fmt.Sprintf("%s(%s)", typeStr(c.typ), c.val) +} + +func (c *conversion) eval(execCtx *execCtx, ctx map[interface{}]interface{}) (v interface{}, err error) { + val, err := expand1(c.val.eval(execCtx, ctx)) + if err != nil { + return + } + + return convert(val, c.typ) +} + +type unaryOperation struct { + op int + v expression +} + +func newUnaryOperation(op int, x interface{}) (v expression, err error) { + l, ok := x.(expression) + if !ok { + panic("internal error 038") + } + + for { + pe, ok := l.(*pexpr) + if ok { + l = pe.expr + continue + } + + break + } + + if l.isStatic() { + val, err := l.eval(nil, nil) + if err != nil { + return nil, err + } + + l = value{val} + } + + if op == '!' { + b, ok := l.(*binaryOperation) + if ok { + switch b.op { + case eq: + b.op = neq + return b, nil + case neq: + b.op = eq + return b, nil + case '>': + b.op = le + return b, nil + case ge: + b.op = '<' + return b, nil + case '<': + b.op = ge + return b, nil + case le: + b.op = '>' + return b, nil + } + } + + u, ok := l.(*unaryOperation) + if ok && u.op == '!' { // !!x: x + return u.v, nil + } + } + + return &unaryOperation{op, l}, nil +} + +func (u *unaryOperation) clone(arg []interface{}, unqualify ...string) (expression, error) { + v, err := u.v.clone(arg, unqualify...) + if err != nil { + return nil, err + } + + return &unaryOperation{op: u.op, v: v}, nil +} + +func (u *unaryOperation) isStatic() bool { return u.v.isStatic() } + +func (u *unaryOperation) String() string { + switch u.v.(type) { + case *binaryOperation: + return fmt.Sprintf("%s(%s)", iop(u.op), u.v) + default: + return fmt.Sprintf("%s%s", iop(u.op), u.v) + } +} + +// !ident +func (u *unaryOperation) isNotQIdent() (bool, string, expression) { + if u.op != '!' { + return false, "", nil + } + + id, ok := u.v.(*ident) + if ok && id.isQualified() { + return true, mustQualifier(id.s), &unaryOperation{'!', &ident{mustSelector(id.s)}} + } + + return false, "", nil +} + +func (u *unaryOperation) eval(execCtx *execCtx, ctx map[interface{}]interface{}) (r interface{}, err error) { + defer func() { + if e := recover(); e != nil { + switch x := e.(type) { + case error: + r, err = nil, x + default: + r, err = nil, fmt.Errorf("%v", x) + } + } + }() + + switch op := u.op; op { + case '!': + a := eval(u.v, execCtx, ctx) + if a == nil { + return + } + + switch x := a.(type) { + case bool: + return !x, nil + default: + return undOp(a, op) + } + case '^': + a := eval(u.v, execCtx, ctx) + if a == nil { + return + } + + switch x := a.(type) { + //case nil: + case idealComplex: + return undOp(a, op) + case idealFloat: + return undOp(a, op) + case idealInt: + return ^x, nil + case idealRune: + return ^x, nil + case idealUint: + return ^x, nil + case bool: + return undOp(a, op) + case complex64: + return undOp(a, op) + case complex128: + return undOp(a, op) + case float32: + return undOp(a, op) + case float64: + return undOp(a, op) + case int8: + return ^x, nil + case int16: + return ^x, nil + case int32: + return ^x, nil + case int64: + return ^x, nil + case string: + return undOp(a, op) + case uint8: + return ^x, nil + case uint16: + return ^x, nil + case uint32: + return ^x, nil + case uint64: + return ^x, nil + case *big.Int: + var z big.Int + return z.Not(x), nil + case time.Duration: + return ^x, nil + default: + return undOp(a, op) + } + case '+': + a := eval(u.v, execCtx, ctx) + if a == nil { + return + } + + switch x := a.(type) { + //case nil: + case idealComplex: + return +x, nil + case idealFloat: + return +x, nil + case idealInt: + return +x, nil + case idealRune: + return +x, nil + case idealUint: + return +x, nil + case bool: + return undOp(a, op) + case complex64: + return +x, nil + case complex128: + return +x, nil + case float32: + return +x, nil + case float64: + return +x, nil + case int8: + return +x, nil + case int16: + return +x, nil + case int32: + return +x, nil + case int64: + return +x, nil + case string: + return undOp(a, op) + case uint8: + return +x, nil + case uint16: + return +x, nil + case uint32: + return +x, nil + case uint64: + return +x, nil + case *big.Int: + var z big.Int + return z.Set(x), nil + case *big.Rat: + var z big.Rat + return z.Set(x), nil + case time.Duration: + return x, nil + default: + return undOp(a, op) + } + case '-': + a := eval(u.v, execCtx, ctx) + if a == nil { + return + } + + switch x := a.(type) { + //case nil: + case idealComplex: + return -x, nil + case idealFloat: + return -x, nil + case idealInt: + return -x, nil + case idealRune: + return -x, nil + case idealUint: + return -x, nil + case bool: + return undOp(a, op) + case complex64: + return -x, nil + case complex128: + return -x, nil + case float32: + return -x, nil + case float64: + return -x, nil + case int8: + return -x, nil + case int16: + return -x, nil + case int32: + return -x, nil + case int64: + return -x, nil + case string: + return undOp(a, op) + case uint8: + return -x, nil + case uint16: + return -x, nil + case uint32: + return -x, nil + case uint64: + return -x, nil + case *big.Int: + var z big.Int + return z.Neg(x), nil + case *big.Rat: + var z big.Rat + return z.Neg(x), nil + case time.Duration: + return -x, nil + default: + return undOp(a, op) + } + default: + panic("internal error 039") + } +} + +type call struct { + f string + arg []expression +} + +func newCall(f string, arg []expression) (v expression, isAgg bool, err error) { + x := builtin[f] + if x.f == nil { + return nil, false, fmt.Errorf("undefined: %s", f) + } + + isAgg = x.isAggregate + if g, min, max := len(arg), x.minArgs, x.maxArgs; g < min || g > max { + a := []interface{}{} + for _, v := range arg { + a = append(a, v) + } + return nil, false, badNArgs(min, f, a) + } + + c := call{f: f} + for _, val := range arg { + if !val.isStatic() { + c.arg = append(c.arg, val) + continue + } + + eval, err := val.eval(nil, nil) + if err != nil { + return nil, isAgg, err + } + + c.arg = append(c.arg, value{eval}) + } + + return &c, isAgg, nil +} + +func (c *call) clone(arg []interface{}, unqualify ...string) (expression, error) { + list, err := cloneExpressionList(arg, c.arg) + if err != nil { + return nil, err + } + + return &call{f: c.f, arg: list}, nil +} + +func (c *call) isStatic() bool { + v := builtin[c.f] + if v.f == nil || !v.isStatic { + return false + } + + for _, v := range c.arg { + if !v.isStatic() { + return false + } + } + return true +} + +func (c *call) String() string { + a := []string{} + for _, v := range c.arg { + a = append(a, v.String()) + } + return fmt.Sprintf("%s(%s)", c.f, strings.Join(a, ", ")) +} + +func (c *call) eval(execCtx *execCtx, ctx map[interface{}]interface{}) (v interface{}, err error) { + f, ok := builtin[c.f] + if !ok { + return nil, fmt.Errorf("unknown function %s", c.f) + } + + isID := c.f == "id" + a := make([]interface{}, len(c.arg)) + for i, arg := range c.arg { + if v, err = expand1(arg.eval(execCtx, ctx)); err != nil { + if !isID { + return nil, err + } + + if _, ok := arg.(*ident); !ok { + return nil, err + } + + a[i] = arg + continue + } + + a[i] = v + } + + if ctx != nil { + ctx["$fn"] = c + } + return f.f(a, ctx) +} + +type parameter struct { + n int +} + +func (p parameter) clone(arg []interface{}, unqualify ...string) (expression, error) { + i := p.n - 1 + if i < len(arg) { + return value{val: arg[i]}, nil + } + + return nil, fmt.Errorf("missing %s", p) +} + +func (parameter) isStatic() bool { return false } + +func (p parameter) String() string { return fmt.Sprintf("$%d", p.n) } + +func (p parameter) eval(execCtx *execCtx, ctx map[interface{}]interface{}) (v interface{}, err error) { + i := p.n - 1 + if i < len(execCtx.arg) { + return execCtx.arg[i], nil + } + + return nil, fmt.Errorf("missing %s", p) +} + +//MAYBE make it an unary operation +type isNull struct { + expr expression + not bool +} + +//LATER newIsNull + +func (is *isNull) clone(arg []interface{}, unqualify ...string) (expression, error) { + expr, err := is.expr.clone(arg, unqualify...) + if err != nil { + return nil, err + } + + return &isNull{expr: expr, not: is.not}, nil +} + +func (is *isNull) isStatic() bool { return is.expr.isStatic() } + +func (is *isNull) String() string { + if is.not { + return fmt.Sprintf("%s IS NOT NULL", is.expr) + } + + return fmt.Sprintf("%s IS NULL", is.expr) +} + +func (is *isNull) eval(execCtx *execCtx, ctx map[interface{}]interface{}) (v interface{}, err error) { + val, err := is.expr.eval(execCtx, ctx) + if err != nil { + return + } + + return val == nil != is.not, nil +} + +type indexOp struct { + expr, x expression +} + +func newIndex(sv, xv expression) (v expression, err error) { + s, fs, i := "", false, uint64(0) + x := indexOp{sv, xv} + if x.expr.isStatic() { + v, err := x.expr.eval(nil, nil) + if err != nil { + return nil, err + } + + if v == nil { + return value{nil}, nil + } + + if s, fs = v.(string); !fs { + return nil, invXOp(sv, xv) + } + + x.expr = value{s} + } + + if x.x.isStatic() { + v, err := x.x.eval(nil, nil) + if err != nil { + return nil, err + } + + if v == nil { + return value{nil}, nil + } + + var p *string + if fs { + p = &s + } + if i, err = indexExpr(p, v); err != nil { + return nil, err + } + + x.x = value{i} + } + + return &x, nil +} + +func (x *indexOp) clone(arg []interface{}, unqualify ...string) (expression, error) { + expr, err := x.expr.clone(arg, unqualify...) + if err != nil { + return nil, err + } + + x2, err := x.x.clone(arg, unqualify...) + if err != nil { + return nil, err + } + + return &indexOp{expr: expr, x: x2}, nil +} + +func (x *indexOp) isStatic() bool { + return x.expr.isStatic() && x.x.isStatic() +} + +func (x *indexOp) String() string { return fmt.Sprintf("%s[%s]", x.expr, x.x) } + +func (x *indexOp) eval(execCtx *execCtx, ctx map[interface{}]interface{}) (v interface{}, err error) { + s0, err := x.expr.eval(execCtx, ctx) + if err != nil { + return nil, runErr(err) + } + + s, ok := s0.(string) + if !ok { + return nil, runErr(invXOp(s0, x.x)) + } + + i0, err := x.x.eval(execCtx, ctx) + if err != nil { + return nil, runErr(err) + } + + if i0 == nil { + return nil, nil + } + + i, err := indexExpr(&s, i0) + if err != nil { + return nil, runErr(err) + } + + return s[i], nil +} + +type slice struct { + expr expression + lo, hi *expression +} + +func newSlice(e expression, lo, hi *expression) (v expression, err error) { + y := slice{e, lo, hi} + var val interface{} + if e := y.expr; e.isStatic() { + if val, err = e.eval(nil, nil); err != nil { + return nil, err + } + + if val == nil { + return value{nil}, nil + } + + y.expr = value{val} + } + + if p := y.lo; p != nil { + if e := expr(*p); e.isStatic() { + if val, err = e.eval(nil, nil); err != nil { + return nil, err + } + + if val == nil { + return value{nil}, nil + } + + v := expression(value{val}) + y.lo = &v + } + } + + if p := y.hi; p != nil { + if e := expr(*p); e.isStatic() { + if val, err = e.eval(nil, nil); err != nil { + return nil, err + } + + if val == nil { + return value{nil}, nil + } + + v := expression(value{val}) + y.hi = &v + } + } + return &y, nil +} + +func (s *slice) clone(arg []interface{}, unqualify ...string) (expression, error) { + expr, err := s.expr.clone(arg, unqualify...) + if err != nil { + return nil, err + } + + r := &slice{expr: expr, lo: s.lo, hi: s.hi} + if s.lo != nil { + e, err := (*s.lo).clone(arg, unqualify...) + if err != nil { + return nil, err + } + + r.lo = &e + } + if s.hi != nil { + e, err := (*s.hi).clone(arg, unqualify...) + if err != nil { + return nil, err + } + + r.hi = &e + } + return r, nil +} + +func (s *slice) eval(execCtx *execCtx, ctx map[interface{}]interface{}) (v interface{}, err error) { + s0, err := s.expr.eval(execCtx, ctx) + if err != nil { + return + } + + if s0 == nil { + return + } + + ss, ok := s0.(string) + if !ok { + return nil, runErr(invSOp(s0)) + } + + var iLo, iHi uint64 + if s.lo != nil { + i, err := (*s.lo).eval(execCtx, ctx) + if err != nil { + return nil, err + } + + if i == nil { + return nil, err + } + + if iLo, err = sliceExpr(&ss, i, 0); err != nil { + return nil, err + } + } + + iHi = uint64(len(ss)) + if s.hi != nil { + i, err := (*s.hi).eval(execCtx, ctx) + if err != nil { + return nil, err + } + + if i == nil { + return nil, err + } + + if iHi, err = sliceExpr(&ss, i, 1); err != nil { + return nil, err + } + } + + return ss[iLo:iHi], nil +} + +func (s *slice) isStatic() bool { + if !s.expr.isStatic() { + return false + } + + if p := s.lo; p != nil && !(*p).isStatic() { + return false + } + + if p := s.hi; p != nil && !(*p).isStatic() { + return false + } + + return false +} + +func (s *slice) String() string { + switch { + case s.lo == nil && s.hi == nil: + return fmt.Sprintf("%v[:]", s.expr) + case s.lo == nil && s.hi != nil: + return fmt.Sprintf("%v[:%v]", s.expr, *s.hi) + case s.lo != nil && s.hi == nil: + return fmt.Sprintf("%v[%v:]", s.expr, *s.lo) + default: //case s.lo != nil && s.hi != nil: + return fmt.Sprintf("%v[%v:%v]", s.expr, *s.lo, *s.hi) + } +} diff --git a/vendor/github.com/cznic/ql/file.go b/vendor/github.com/cznic/ql/file.go new file mode 100644 index 0000000000..c7fb7c95ed --- /dev/null +++ b/vendor/github.com/cznic/ql/file.go @@ -0,0 +1,1279 @@ +// Copyright 2014 The ql Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Well known handles +// 1: root +// 2: id + +package ql + +import ( + "crypto/sha1" + "fmt" + "io" + "io/ioutil" + "math/big" + "os" + "path/filepath" + "sync" + "time" + + "github.com/camlistore/go4/lock" + "github.com/cznic/exp/lldb" + "github.com/cznic/mathutil" +) + +const ( + magic = "\x60\xdbql" +) + +var ( + _ btreeIndex = (*fileIndex)(nil) + _ btreeIterator = (*fileBTreeIterator)(nil) + _ indexIterator = (*fileIndexIterator)(nil) + _ storage = (*file)(nil) + _ temp = (*fileTemp)(nil) +) + +type chunk struct { // expanded to blob types lazily + f *file + b []byte +} + +func (c chunk) expand() (v interface{}, err error) { + return c.f.loadChunks(c.b) +} + +func expand1(data interface{}, e error) (v interface{}, err error) { + if e != nil { + return nil, e + } + + c, ok := data.(chunk) + if !ok { + return data, nil + } + + return c.expand() +} + +func expand(data []interface{}) (err error) { + for i, v := range data { + if data[i], err = expand1(v, nil); err != nil { + return + } + } + return +} + +// OpenFile returns a DB backed by a named file. The back end limits the size +// of a record to about 64 kB. +func OpenFile(name string, opt *Options) (db *DB, err error) { + var f lldb.OSFile + if f = opt.OSFile; f == nil { + f, err = os.OpenFile(name, os.O_RDWR, 0666) + if err != nil { + if !os.IsNotExist(err) { + return nil, err + } + + if !opt.CanCreate { + return nil, err + } + + f, err = os.OpenFile(name, os.O_CREATE|os.O_EXCL|os.O_RDWR, 0666) + if err != nil { + return nil, err + } + } + } + + fi, err := newFileFromOSFile(f) // always ACID + if err != nil { + return + } + + if fi.tempFile = opt.TempFile; fi.tempFile == nil { + fi.tempFile = func(dir, prefix string) (f lldb.OSFile, err error) { + f0, err := ioutil.TempFile(dir, prefix) + return f0, err + } + } + + return newDB(fi) +} + +// Options amend the behavior of OpenFile. +// +// CanCreate +// +// The CanCreate option enables OpenFile to create the DB file if it does not +// exists. +// +// OSFile +// +// OSFile allows to pass an os.File like back end providing, for example, +// encrypted storage. If this field is nil then OpenFile uses the file named by +// the 'name' parameter instead. +// +// TempFile +// +// TempFile provides a temporary file used for evaluating the GROUP BY, ORDER +// BY, ... clauses. The hook is intended to be used by encrypted DB back ends +// to avoid leaks of unecrypted data to such temp files by providing temp files +// which are encrypted as well. Note that *os.File satisfies the lldb.OSFile +// interface. +// +// If TempFile is nil it defaults to ioutil.TempFile. +type Options struct { + CanCreate bool + OSFile lldb.OSFile + TempFile func(dir, prefix string) (f lldb.OSFile, err error) +} + +type fileBTreeIterator struct { + en *lldb.BTreeEnumerator + t *fileTemp +} + +func (it *fileBTreeIterator) Next() (k, v []interface{}, err error) { + bk, bv, err := it.en.Next() + if err != nil { + return + } + + if k, err = lldb.DecodeScalars(bk); err != nil { + return + } + + for i, val := range k { + b, ok := val.([]byte) + if !ok { + continue + } + + c := chunk{it.t.file, b} + if k[i], err = c.expand(); err != nil { + return nil, nil, err + } + } + + if err = enforce(k, it.t.colsK); err != nil { + return + } + + if v, err = lldb.DecodeScalars(bv); err != nil { + return + } + + for i, val := range v { + b, ok := val.([]byte) + if !ok { + continue + } + + c := chunk{it.t.file, b} + if v[i], err = c.expand(); err != nil { + return nil, nil, err + } + } + + err = enforce(v, it.t.colsV) + return +} + +func enforce(val []interface{}, cols []*col) (err error) { + for i, v := range val { + if val[i], err = convert(v, cols[i].typ); err != nil { + return + } + } + return +} + +//NTYPE +func infer(from []interface{}, to *[]*col) { + if len(*to) == 0 { + *to = make([]*col, len(from)) + for i := range *to { + (*to)[i] = &col{} + } + } + for i, c := range *to { + if f := from[i]; f != nil { + switch x := f.(type) { + //case nil: + case idealComplex: + c.typ = qComplex128 + from[i] = complex128(x) + case idealFloat: + c.typ = qFloat64 + from[i] = float64(x) + case idealInt: + c.typ = qInt64 + from[i] = int64(x) + case idealRune: + c.typ = qInt32 + from[i] = int32(x) + case idealUint: + c.typ = qUint64 + from[i] = uint64(x) + case bool: + c.typ = qBool + case complex128: + c.typ = qComplex128 + case complex64: + c.typ = qComplex64 + case float64: + c.typ = qFloat64 + case float32: + c.typ = qFloat32 + case int8: + c.typ = qInt8 + case int16: + c.typ = qInt16 + case int32: + c.typ = qInt32 + case int64: + c.typ = qInt64 + case string: + c.typ = qString + case uint8: + c.typ = qUint8 + case uint16: + c.typ = qUint16 + case uint32: + c.typ = qUint32 + case uint64: + c.typ = qUint64 + case []byte: + c.typ = qBlob + case *big.Int: + c.typ = qBigInt + case *big.Rat: + c.typ = qBigRat + case time.Time: + c.typ = qTime + case time.Duration: + c.typ = qDuration + case chunk: + vals, err := lldb.DecodeScalars([]byte(x.b)) + if err != nil { + panic(err) + } + + if len(vals) == 0 { + panic("internal error 040") + } + + i, ok := vals[0].(int64) + if !ok { + panic("internal error 041") + } + + c.typ = int(i) + case map[string]interface{}: // map of ids of a cross join + default: + panic("internal error 042") + } + } + } +} + +type fileTemp struct { + *file + colsK []*col + colsV []*col + t *lldb.BTree +} + +func (t *fileTemp) BeginTransaction() error { + return nil +} + +func (t *fileTemp) Get(k []interface{}) (v []interface{}, err error) { + if err = expand(k); err != nil { + return + } + + if err = t.flatten(k); err != nil { + return nil, err + } + + bk, err := lldb.EncodeScalars(k...) + if err != nil { + return + } + + bv, err := t.t.Get(nil, bk) + if err != nil { + return + } + + return lldb.DecodeScalars(bv) +} + +func (t *fileTemp) Drop() (err error) { + if t.f0 == nil { + return + } + + fn := t.f0.Name() + if err = t.f0.Close(); err != nil { + return + } + + if fn == "" { + return + } + + return os.Remove(fn) +} + +func (t *fileTemp) SeekFirst() (it btreeIterator, err error) { + en, err := t.t.SeekFirst() + if err != nil { + return + } + + return &fileBTreeIterator{t: t, en: en}, nil +} + +func (t *fileTemp) Set(k, v []interface{}) (err error) { + if err = expand(k); err != nil { + return + } + + if err = expand(v); err != nil { + return + } + + infer(k, &t.colsK) + infer(v, &t.colsV) + + if err = t.flatten(k); err != nil { + return + } + + bk, err := lldb.EncodeScalars(k...) + if err != nil { + return + } + + if err = t.flatten(v); err != nil { + return + } + + bv, err := lldb.EncodeScalars(v...) + if err != nil { + return + } + + return t.t.Set(bk, bv) +} + +type file struct { + a *lldb.Allocator + codec *gobCoder + f lldb.Filer + f0 lldb.OSFile + id int64 + lck io.Closer + mu sync.Mutex + name string + tempFile func(dir, prefix string) (f lldb.OSFile, err error) + wal *os.File +} + +func newFileFromOSFile(f lldb.OSFile) (fi *file, err error) { + nm := lockName(f.Name()) + lck, err := lock.Lock(nm) + if err != nil { + if lck != nil { + lck.Close() + } + return nil, err + } + + close := true + defer func() { + if close && lck != nil { + lck.Close() + } + }() + + var w *os.File + closew := false + wn := walName(f.Name()) + w, err = os.OpenFile(wn, os.O_CREATE|os.O_EXCL|os.O_RDWR, 0666) + closew = true + defer func() { + if closew { + nm := w.Name() + w.Close() + os.Remove(nm) + w = nil + } + }() + + if err != nil { + if !os.IsExist(err) { + return nil, err + } + + closew = false + w, err = os.OpenFile(wn, os.O_RDWR, 0666) + if err != nil { + return nil, err + } + + closew = true + st, err := w.Stat() + if err != nil { + return nil, err + } + + if st.Size() != 0 { + return nil, fmt.Errorf("(file-001) non empty WAL file %s exists", wn) + } + } + + info, err := f.Stat() + if err != nil { + return nil, err + } + + switch sz := info.Size(); { + case sz == 0: + b := make([]byte, 16) + copy(b, []byte(magic)) + if _, err := f.Write(b); err != nil { + return nil, err + } + + filer := lldb.Filer(lldb.NewOSFiler(f)) + filer = lldb.NewInnerFiler(filer, 16) + if filer, err = lldb.NewACIDFiler(filer, w); err != nil { + return nil, err + } + + a, err := lldb.NewAllocator(filer, &lldb.Options{}) + if err != nil { + return nil, err + } + + a.Compress = true + s := &file{ + a: a, + codec: newGobCoder(), + f0: f, + f: filer, + lck: lck, + name: f.Name(), + wal: w, + } + if err = s.BeginTransaction(); err != nil { + return nil, err + } + + h, err := s.Create() + if err != nil { + return nil, err + } + + if h != 1 { // root + panic("internal error 043") + } + + if h, err = s.a.Alloc(make([]byte, 8)); err != nil { + return nil, err + } + + if h != 2 { // id + panic("internal error 044") + } + + close, closew = false, false + return s, s.Commit() + default: + b := make([]byte, 16) + if _, err := f.Read(b); err != nil { + return nil, err + } + + if string(b[:len(magic)]) != magic { + return nil, fmt.Errorf("(file-002) unknown file format") + } + + filer := lldb.Filer(lldb.NewOSFiler(f)) + filer = lldb.NewInnerFiler(filer, 16) + if filer, err = lldb.NewACIDFiler(filer, w); err != nil { + return nil, err + } + + a, err := lldb.NewAllocator(filer, &lldb.Options{}) + if err != nil { + return nil, err + } + + bid, err := a.Get(nil, 2) // id + if err != nil { + return nil, err + } + + if len(bid) != 8 { + return nil, fmt.Errorf("(file-003) corrupted DB: id |% x|", bid) + } + + id := int64(0) + for _, v := range bid { + id = (id << 8) | int64(v) + } + + a.Compress = true + s := &file{ + a: a, + codec: newGobCoder(), + f0: f, + f: filer, + id: id, + lck: lck, + name: f.Name(), + wal: w, + } + + close, closew = false, false + return s, nil + } +} + +func (s *file) OpenIndex(unique bool, handle int64) (btreeIndex, error) { + t, err := lldb.OpenBTree(s.a, s.collate, handle) + if err != nil { + return nil, err + } + + return &fileIndex{s, handle, t, unique}, nil +} + +func (s *file) CreateIndex(unique bool) ( /* handle */ int64, btreeIndex, error) { + t, h, err := lldb.CreateBTree(s.a, s.collate) + if err != nil { + return -1, nil, err + } + + return h, &fileIndex{s, h, t, unique}, nil +} + +func (s *file) Acid() bool { return s.wal != nil } + +func errSet(p *error, errs ...error) (err error) { + err = *p + for _, e := range errs { + if err != nil { + return + } + *p, err = e, e + } + return +} + +func (s *file) lock() func() { + s.mu.Lock() + return s.mu.Unlock +} + +func (s *file) Close() (err error) { + defer s.lock()() + + es := s.f0.Sync() + ef := s.f0.Close() + var ew error + if s.wal != nil { + ew = s.wal.Close() + } + el := s.lck.Close() + return errSet(&err, es, ef, ew, el) +} + +func (s *file) Name() string { return s.name } + +func (s *file) Verify() (allocs int64, err error) { + defer s.lock()() + var stat lldb.AllocStats + if err = s.a.Verify(lldb.NewMemFiler(), nil, &stat); err != nil { + return + } + + allocs = stat.AllocAtoms + return +} + +func (s *file) expandBytes(d []interface{}) (err error) { + for i, v := range d { + b, ok := v.([]byte) + if !ok { + continue + } + + d[i], err = s.loadChunks(b) + if err != nil { + return + } + } + return +} + +func (s *file) collate(a, b []byte) int { //TODO w/ error return + da, err := lldb.DecodeScalars(a) + if err != nil { + panic(err) + } + + if err = s.expandBytes(da); err != nil { + panic(err) + } + + db, err := lldb.DecodeScalars(b) + if err != nil { + panic(err) + } + + if err = s.expandBytes(db); err != nil { + panic(err) + } + + //dbg("da: %v, db: %v", da, db) + return collate(da, db) +} + +func (s *file) CreateTemp(asc bool) (bt temp, err error) { + f, err := s.tempFile("", "ql-tmp-") + if err != nil { + return nil, err + } + + fn := f.Name() + filer := lldb.NewOSFiler(f) + a, err := lldb.NewAllocator(filer, &lldb.Options{}) + if err != nil { + f.Close() + os.Remove(fn) + return nil, err + } + + k := 1 + if !asc { + k = -1 + } + + t, _, err := lldb.CreateBTree(a, func(a, b []byte) int { //TODO w/ error return + return k * s.collate(a, b) + }) + if err != nil { + f.Close() + if fn != "" { + os.Remove(fn) + } + return nil, err + } + + x := &fileTemp{file: &file{ + a: a, + codec: newGobCoder(), + f0: f, + }, + t: t} + return x, nil +} + +func (s *file) BeginTransaction() (err error) { + defer s.lock()() + return s.f.BeginUpdate() +} + +func (s *file) Rollback() (err error) { + defer s.lock()() + return s.f.Rollback() +} + +func (s *file) Commit() (err error) { + defer s.lock()() + return s.f.EndUpdate() +} + +func (s *file) Create(data ...interface{}) (h int64, err error) { + if err = expand(data); err != nil { + return + } + + if err = s.flatten(data); err != nil { + return + } + + b, err := lldb.EncodeScalars(data...) + if err != nil { + return + } + + defer s.lock()() + return s.a.Alloc(b) +} + +func (s *file) Delete(h int64, blobCols ...*col) (err error) { + switch len(blobCols) { + case 0: + defer s.lock()() + return s.a.Free(h) + default: + return s.free(h, blobCols) + } +} + +func (s *file) ResetID() (err error) { + s.id = 0 + return +} + +func (s *file) ID() (int64, error) { + defer s.lock()() + + s.id++ + b := make([]byte, 8) + id := s.id + for i := 7; i >= 0; i-- { + b[i] = byte(id) + id >>= 8 + } + + return s.id, s.a.Realloc(2, b) +} + +func (s *file) free(h int64, blobCols []*col) (err error) { + b, err := s.a.Get(nil, h) //LATER +bufs + if err != nil { + return + } + + rec, err := lldb.DecodeScalars(b) + if err != nil { + return + } + + for _, col := range blobCols { + if col.index >= len(rec) { + return fmt.Errorf("(file-004) file.free: corrupted DB (record len)") + } + if col.index+2 >= len(rec) { + continue + } + + switch x := rec[col.index+2].(type) { + case nil: + // nop + case []byte: + if err = s.freeChunks(x); err != nil { + return + } + } + } + defer s.lock()() + return s.a.Free(h) +} + +func (s *file) Read(dst []interface{}, h int64, cols ...*col) (data []interface{}, err error) { //NTYPE + b, err := s.a.Get(nil, h) //LATER +bufs + if err != nil { + return + } + + rec, err := lldb.DecodeScalars(b) + if err != nil { + return + } + + for _, col := range cols { + i := col.index + 2 + if i >= len(rec) || rec[i] == nil { + continue + } + + switch col.typ { + case 0: + case qBool: + case qComplex64: + rec[i] = complex64(rec[i].(complex128)) + case qComplex128: + case qFloat32: + rec[i] = float32(rec[i].(float64)) + case qFloat64: + case qInt8: + rec[i] = int8(rec[i].(int64)) + case qInt16: + rec[i] = int16(rec[i].(int64)) + case qInt32: + rec[i] = int32(rec[i].(int64)) + case qInt64: + case qString: + case qUint8: + rec[i] = uint8(rec[i].(uint64)) + case qUint16: + rec[i] = uint16(rec[i].(uint64)) + case qUint32: + rec[i] = uint32(rec[i].(uint64)) + case qUint64: + case qBlob, qBigInt, qBigRat, qTime, qDuration: + switch x := rec[i].(type) { + case []byte: + rec[i] = chunk{f: s, b: x} + default: + return nil, fmt.Errorf("(file-006) corrupted DB: non nil chunk type is not []byte") + } + default: + panic("internal error 045") + } + } + + if cols != nil { + for n, dn := len(cols)+2, len(rec); dn < n; dn++ { + rec = append(rec, nil) + } + } + + return rec, nil +} + +func (s *file) freeChunks(enc []byte) (err error) { + items, err := lldb.DecodeScalars(enc) + if err != nil { + return + } + + var ok bool + var next int64 + switch len(items) { + case 2: + return + case 3: + if next, ok = items[1].(int64); !ok || next == 0 { + return fmt.Errorf("(file-007) corrupted DB: first chunk link") + } + default: + return fmt.Errorf("(file-008) corrupted DB: first chunk") + } + + for next != 0 { + b, err := s.a.Get(nil, next) + if err != nil { + return err + } + + if items, err = lldb.DecodeScalars(b); err != nil { + return err + } + + var h int64 + switch len(items) { + case 1: + // nop + case 2: + if h, ok = items[0].(int64); !ok { + return fmt.Errorf("(file-009) corrupted DB: chunk link") + } + + default: + return fmt.Errorf("(file-010) corrupted DB: chunk items %d (%v)", len(items), items) + } + + s.mu.Lock() + if err = s.a.Free(next); err != nil { + s.mu.Unlock() + return err + } + + s.mu.Unlock() + next = h + } + return +} + +func (s *file) loadChunks(enc []byte) (v interface{}, err error) { + items, err := lldb.DecodeScalars(enc) + if err != nil { + return + } + + var ok bool + var next int64 + switch len(items) { + case 2: + // nop + case 3: + if next, ok = items[1].(int64); !ok || next == 0 { + return nil, fmt.Errorf("(file-011) corrupted DB: first chunk link") + } + default: + //fmt.Printf("%d: %#v\n", len(items), items) + return nil, fmt.Errorf("(file-012) corrupted DB: first chunk") + } + + typ, ok := items[0].(int64) + if !ok { + return nil, fmt.Errorf("(file-013) corrupted DB: first chunk tag") + } + + buf, ok := items[len(items)-1].([]byte) + if !ok { + return nil, fmt.Errorf("(file-014) corrupted DB: first chunk data") + } + + for next != 0 { + b, err := s.a.Get(nil, next) + if err != nil { + return nil, err + } + + if items, err = lldb.DecodeScalars(b); err != nil { + return nil, err + } + + switch len(items) { + case 1: + next = 0 + case 2: + if next, ok = items[0].(int64); !ok { + return nil, fmt.Errorf("(file-015) corrupted DB: chunk link") + } + + items = items[1:] + default: + return nil, fmt.Errorf("(file-016) corrupted DB: chunk items %d (%v)", len(items), items) + } + + if b, ok = items[0].([]byte); !ok { + return nil, fmt.Errorf("(file-017) corrupted DB: chunk data") + } + + buf = append(buf, b...) + } + return s.codec.decode(buf, int(typ)) +} + +func (s *file) Update(h int64, data ...interface{}) (err error) { + b, err := lldb.EncodeScalars(data...) + if err != nil { + return + } + + defer s.lock()() + return s.a.Realloc(h, b) +} + +func (s *file) UpdateRow(h int64, blobCols []*col, data ...interface{}) (err error) { + if len(blobCols) == 0 { + return s.Update(h, data...) + } + + if err = expand(data); err != nil { + return + } + + data0, err := s.Read(nil, h, blobCols...) + if err != nil { + return + } + + for _, c := range blobCols { + if c.index+2 >= len(data0) { + continue + } + + if x := data0[c.index+2]; x != nil { + if err = s.freeChunks(x.(chunk).b); err != nil { + return + } + } + } + + if err = s.flatten(data); err != nil { + return + } + + return s.Update(h, data...) +} + +// []interface{}{qltype, ...}->[]interface{}{lldb scalar type, ...} +// + long blobs are (pre)written to a chain of chunks. +func (s *file) flatten(data []interface{}) (err error) { + for i, v := range data { + tag := 0 + var b []byte + switch x := v.(type) { + case []byte: + tag = qBlob + b = x + case *big.Int: + tag = qBigInt + b, err = s.codec.encode(x) + case *big.Rat: + tag = qBigRat + b, err = s.codec.encode(x) + case time.Time: + tag = qTime + b, err = s.codec.encode(x) + case time.Duration: + tag = qDuration + b, err = s.codec.encode(x) + default: + continue + } + if err != nil { + return + } + + const chunk = 1 << 16 + chunks := 0 + var next int64 + var buf []byte + for rem := len(b); rem > shortBlob; { + n := mathutil.Min(rem, chunk) + part := b[rem-n:] + b = b[:rem-n] + rem -= n + switch next { + case 0: // last chunk + buf, err = lldb.EncodeScalars([]interface{}{part}...) + default: // middle chunk + buf, err = lldb.EncodeScalars([]interface{}{next, part}...) + } + if err != nil { + return + } + + s.mu.Lock() + h, err := s.a.Alloc(buf) + s.mu.Unlock() + if err != nil { + return err + } + + next = h + chunks++ + } + + switch next { + case 0: // single chunk + buf, err = lldb.EncodeScalars([]interface{}{tag, b}...) + default: // multi chunks + buf, err = lldb.EncodeScalars([]interface{}{tag, next, b}...) + } + if err != nil { + return + } + + data[i] = buf + } + return +} + +func lockName(dbname string) string { + base := filepath.Base(filepath.Clean(dbname)) + "lockfile" + h := sha1.New() + io.WriteString(h, base) + return filepath.Join(filepath.Dir(dbname), fmt.Sprintf(".%x", h.Sum(nil))) +} + +func walName(dbname string) (r string) { + base := filepath.Base(filepath.Clean(dbname)) + h := sha1.New() + io.WriteString(h, base) + return filepath.Join(filepath.Dir(dbname), fmt.Sprintf(".%x", h.Sum(nil))) +} + +type fileIndex struct { + f *file + h int64 + t *lldb.BTree + unique bool +} + +func (x *fileIndex) Clear() error { + return x.t.Clear() +} + +var gbZeroInt64 []byte + +func init() { + var err error + if gbZeroInt64, err = lldb.EncodeScalars(int64(0)); err != nil { + panic(err) + } +} + +func isIndexNull(data []interface{}) bool { + for _, v := range data { + if v != nil { + return false + } + } + return true +} + +// The []byte version of the key in the BTree shares chunks, if any, with +// the value stored in the record. +func (x *fileIndex) Create(indexedValues []interface{}, h int64) error { + for i, indexedValue := range indexedValues { + chunk, ok := indexedValue.(chunk) + if ok { + indexedValues[i] = chunk.b + } + } + + t := x.t + switch { + case !x.unique: + k, err := lldb.EncodeScalars(append(indexedValues, h)...) + if err != nil { + return err + } + + return t.Set(k, gbZeroInt64) + case isIndexNull(indexedValues): // unique, NULL + k, err := lldb.EncodeScalars(nil, h) + if err != nil { + return err + } + + return t.Set(k, gbZeroInt64) + default: // unique, non NULL + k, err := lldb.EncodeScalars(append(indexedValues, int64(0))...) + if err != nil { + return err + } + + v, err := lldb.EncodeScalars(h) + if err != nil { + return err + } + + _, _, err = t.Put(nil, k, func(key, old []byte) (new []byte, write bool, err error) { + if old == nil { + return v, true, nil + } + + return nil, false, fmt.Errorf("(file-018) cannot insert into unique index: duplicate value(s): %v", indexedValues) + }) + return err + } +} + +func (x *fileIndex) Delete(indexedValues []interface{}, h int64) error { + for i, indexedValue := range indexedValues { + chunk, ok := indexedValue.(chunk) + if ok { + indexedValues[i] = chunk.b + } + } + + t := x.t + var k []byte + var err error + switch { + case !x.unique: + k, err = lldb.EncodeScalars(append(indexedValues, h)...) + case isIndexNull(indexedValues): // unique, NULL + k, err = lldb.EncodeScalars(nil, h) + default: // unique, non NULL + k, err = lldb.EncodeScalars(append(indexedValues, int64(0))...) + } + if err != nil { + return err + } + + return t.Delete(k) +} + +func (x *fileIndex) Drop() error { + if err := x.Clear(); err != nil { + return err + } + + return x.f.a.Free(x.h) +} + +func (x *fileIndex) Seek(indexedValues []interface{}) (indexIterator, bool, error) { //TODO(indices) blobs: +test + k, err := lldb.EncodeScalars(append(indexedValues, 0)...) + if err != nil { + return nil, false, err + } + + en, hit, err := x.t.Seek(k) + if err != nil { + return nil, false, err + } + + return &fileIndexIterator{x.f, en, x.unique}, hit, nil +} + +func (x *fileIndex) SeekFirst() (iter indexIterator, err error) { + en, err := x.t.SeekFirst() + return &fileIndexIterator{x.f, en, x.unique}, err +} + +func (x *fileIndex) SeekLast() (iter indexIterator, err error) { + en, err := x.t.SeekLast() + return &fileIndexIterator{x.f, en, x.unique}, err +} + +type fileIndexIterator struct { + f *file + en *lldb.BTreeEnumerator + unique bool +} + +func (i *fileIndexIterator) nextPrev(f func() ([]byte, []byte, error)) ([]interface{}, int64, error) { //TODO(indices) blobs: +test + bk, bv, err := f() + if err != nil { + return nil, -1, err + } + + dk, err := lldb.DecodeScalars(bk) + if err != nil { + return nil, -1, err + } + + b, ok := dk[0].([]byte) + if ok { + dk[0] = chunk{i.f, b} + if expand(dk[:1]); err != nil { + return nil, -1, err + } + } + + var k indexKey + k.value = dk[:len(dk)-1] + switch i.unique { + case true: + if isIndexNull(k.value) { + return nil, dk[len(dk)-1].(int64), nil + } + + dv, err := lldb.DecodeScalars(bv) + if err != nil { + return nil, -1, err + } + + return k.value, dv[0].(int64), nil + default: + return k.value, dk[len(dk)-1].(int64), nil + } +} + +func (i *fileIndexIterator) Next() ([]interface{}, int64, error) { //TODO(indices) blobs: +test + return i.nextPrev(i.en.Next) +} + +func (i *fileIndexIterator) Prev() ([]interface{}, int64, error) { //TODO(indices) blobs: +test + return i.nextPrev(i.en.Prev) +} diff --git a/vendor/github.com/cznic/ql/httpfs.go b/vendor/github.com/cznic/ql/httpfs.go new file mode 100644 index 0000000000..89c6f89c52 --- /dev/null +++ b/vendor/github.com/cznic/ql/httpfs.go @@ -0,0 +1,302 @@ +// Copyright (c) 2014 ql 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 ql + +import ( + "fmt" + "io" + "net/http" + "os" + "path" + "path/filepath" + "strings" + "time" + + "github.com/cznic/mathutil" +) + +var ( + _ http.FileSystem = (*HTTPFS)(nil) + _ http.File = (*HTTPFile)(nil) + _ os.FileInfo = (*HTTPFile)(nil) + _ os.FileInfo = (*dirEntry)(nil) +) + +type dirEntry string + +func (d dirEntry) Name() string { return string(d) } +func (d dirEntry) Size() int64 { return -1 } +func (d dirEntry) Mode() os.FileMode { return os.ModeDir } +func (d dirEntry) ModTime() time.Time { return time.Time{} } +func (d dirEntry) IsDir() bool { return true } +func (d dirEntry) Sys() interface{} { return interface{}(nil) } + +// A HTTPFile is returned by the HTTPFS's Open method and can be served by the +// http.FileServer implementation. +type HTTPFile struct { + closed bool + content []byte + dirEntries []os.FileInfo + isFile bool + name string + off int + sz int +} + +// Close implements http.File. +func (f *HTTPFile) Close() error { + if f.closed { + return os.ErrInvalid + } + + f.closed = true + return nil +} + +// IsDir implements os.FileInfo +func (f *HTTPFile) IsDir() bool { return !f.isFile } + +// Mode implements os.FileInfo +func (f *HTTPFile) Mode() os.FileMode { + switch f.isFile { + case false: + return os.FileMode(0444) + default: + return os.ModeDir + } +} + +// ModTime implements os.FileInfo +func (f *HTTPFile) ModTime() time.Time { + return time.Time{} +} + +// Name implements os.FileInfo +func (f *HTTPFile) Name() string { return path.Base(f.name) } + +// Size implements os.FileInfo +func (f *HTTPFile) Size() int64 { + switch f.isFile { + case false: + return -1 + default: + return int64(len(f.content)) + } +} + +// Stat implements http.File. +func (f *HTTPFile) Stat() (os.FileInfo, error) { return f, nil } + +// Sys implements os.FileInfo +func (f *HTTPFile) Sys() interface{} { return interface{}(nil) } + +// Readdir implements http.File. +func (f *HTTPFile) Readdir(count int) ([]os.FileInfo, error) { + if f.isFile { + return nil, fmt.Errorf("not a directory: %s", f.name) + } + + if count <= 0 { + r := f.dirEntries + f.dirEntries = f.dirEntries[:0] + return r, nil + } + + rq := mathutil.Min(count, len(f.dirEntries)) + r := f.dirEntries[:rq] + f.dirEntries = f.dirEntries[rq:] + if len(r) != 0 { + return r, nil + } + + return nil, io.EOF +} + +// Read implements http.File. +func (f *HTTPFile) Read(b []byte) (int, error) { + if f.closed { + return 0, os.ErrInvalid + } + + n := copy(b, f.content[f.off:]) + f.off += n + if n != 0 { + return n, nil + } + + return 0, io.EOF +} + +// Seek implements http.File. +func (f *HTTPFile) Seek(offset int64, whence int) (int64, error) { + if f.closed { + return 0, os.ErrInvalid + } + + if offset < 0 { + return int64(f.off), fmt.Errorf("cannot seek before start of file") + } + + switch whence { + case 0: + noff := int64(f.off) + offset + if noff > mathutil.MaxInt { + return int64(f.off), fmt.Errorf("seek target overflows int: %d", noff) + } + + f.off = mathutil.Min(int(offset), len(f.content)) + if f.off == int(offset) { + return offset, nil + } + + return int64(f.off), io.EOF + case 1: + noff := int64(f.off) + offset + if noff > mathutil.MaxInt { + return int64(f.off), fmt.Errorf("seek target overflows int: %d", noff) + } + + off := mathutil.Min(f.off+int(offset), len(f.content)) + if off == f.off+int(offset) { + f.off = off + return int64(off), nil + } + + f.off = off + return int64(off), io.EOF + case 2: + noff := int64(f.off) - offset + if noff < 0 { + return int64(f.off), fmt.Errorf("cannot seek before start of file") + } + + f.off = len(f.content) - int(offset) + return int64(f.off), nil + default: + return int64(f.off), fmt.Errorf("seek: invalid whence %d", whence) + } +} + +// HTTPFS implements a http.FileSystem backed by data in a DB. +type HTTPFS struct { + db *DB + dir, get List +} + +// NewHTTPFS returns a http.FileSystem backed by a result record set of query. +// The record set provides two mandatory fields: path and content (the field +// names are case sensitive). Type of name must be string and type of content +// must be blob (ie. []byte). Field 'path' value is the "file" pathname, which +// must be rooted; and field 'content' value is its "data". +func (db *DB) NewHTTPFS(query string) (*HTTPFS, error) { + if _, err := Compile(query); err != nil { + return nil, err + } + + dir, err := Compile(fmt.Sprintf("SELECT path FROM (%s) WHERE hasPrefix(path, $1)", query)) + if err != nil { + return nil, err + } + + get, err := Compile(fmt.Sprintf("SELECT content FROM (%s) WHERE path == $1", query)) + if err != nil { + return nil, err + } + + return &HTTPFS{db: db, dir: dir, get: get}, nil +} + +// Open implements http.FileSystem. The name parameter represents a file path. +// The elements in a file path are separated by slash ('/', U+002F) characters, +// regardless of host operating system convention. +func (f *HTTPFS) Open(name string) (http.File, error) { + if filepath.Separator != '/' && strings.IndexRune(name, filepath.Separator) >= 0 || + strings.Contains(name, "\x00") { + return nil, fmt.Errorf("invalid character in file path: %q", name) + } + + name = path.Clean("/" + name) + rs, _, err := f.db.Execute(nil, f.get, name) + if err != nil { + return nil, err + } + + n := 0 + var fdata []byte + if err = rs[0].Do(false, func(data []interface{}) (more bool, err error) { + switch n { + case 0: + var ok bool + fdata, ok = data[0].([]byte) + if !ok { + return false, fmt.Errorf("open: expected blob, got %T", data[0]) + } + n++ + return true, nil + default: + return false, fmt.Errorf("open: more than one result was returned for %s", name) + } + }); err != nil { + return nil, err + } + + if n == 1 { // file found + return &HTTPFile{name: name, isFile: true, content: fdata}, nil + } + + dirName := name + if dirName[len(dirName)-1] != filepath.Separator { + dirName += string(filepath.Separator) + } + // Open("/a/b"): {/a/b/c.x,/a/b/d.x,/a/e.x,/a/b/f/g.x} -> {c.x,d.x,f} + rs, _, err = f.db.Execute(nil, f.dir, dirName) + if err != nil { + return nil, err + } + + n = 0 + r := &HTTPFile{name: dirName} + m := map[string]bool{} + x := len(dirName) + if err = rs[0].Do(false, func(data []interface{}) (more bool, err error) { + n++ + switch name := data[0].(type) { + case string: + if filepath.Separator != '/' && strings.IndexRune(name, filepath.Separator) >= 0 || + strings.Contains(name, "\x00") { + return false, fmt.Errorf("invalid character in file path: %q", name) + } + + name = path.Clean("/" + name) + rest := name[x:] + parts := strings.Split(rest, "/") + if len(parts) == 0 { + return true, nil + } + + nm := parts[0] + switch len(parts) { + case 1: // file + r.dirEntries = append(r.dirEntries, &HTTPFile{isFile: true, name: nm}) + default: // directory + if !m[nm] { + r.dirEntries = append(r.dirEntries, dirEntry(nm)) + } + m[nm] = true + } + return true, nil + default: + return false, fmt.Errorf("expected string path, got %T(%v)", name, name) + } + }); err != nil { + return nil, err + } + + if n != 0 { + return r, nil + } + + return nil, os.ErrNotExist +} diff --git a/vendor/github.com/cznic/ql/introspection.go b/vendor/github.com/cznic/ql/introspection.go new file mode 100644 index 0000000000..61ac9a928d --- /dev/null +++ b/vendor/github.com/cznic/ql/introspection.go @@ -0,0 +1,625 @@ +// Copyright 2014 The ql 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 ql + +import ( + "bytes" + "fmt" + "go/ast" + "reflect" + "strings" + "sync" +) + +var ( + schemaCache = map[reflect.Type]*StructInfo{} + schemaMu sync.RWMutex +) + +// StructInfo describes a struct type. An instance of StructInfo obtained from +// StructSchema is shared and must not be mutated. That includes the values +// pointed to by the elements of Fields and Indices. +type StructInfo struct { + Fields []*StructField // Fields describe the considered fields of a struct type. + HasID bool // Whether the struct has a considered field named ID of type int64. + Indices []*StructIndex // Indices describe indices defined by the index or uindex ql tags. + IsPtr bool // Whether the StructInfo was derived from a pointer to a struct. +} + +// StructIndex describes an index defined by the ql tag index or uindex. +type StructIndex struct { + ColumnName string // Name of the column the index is on. + Name string // Name of the index. + Unique bool // Whether the index is unique. +} + +// StructField describes a considered field of a struct type. +type StructField struct { + Index int // Index is the index of the field for reflect.Value.Field. + IsID bool // Whether the field corresponds to record id(). + IsPtr bool // Whether the field is a pointer type. + MarshalType reflect.Type // The reflect.Type a field must be converted to when marshaling or nil when it is assignable directly. (Field->value) + Name string // Field name or value of the name tag (like in `ql:"name foo"`). + ReflectType reflect.Type // The reflect.Type of the field. + Tags map[string]string // QL tags of this field. (`ql:"a, b c, d"` -> {"a": "", "b": "c", "d": ""}) + Type Type // QL type of the field. + UnmarshalType reflect.Type // The reflect.Type a value must be converted to when unmarshaling or nil when it is assignable directly. (Field<-value) + ZeroPtr reflect.Value // The reflect.Zero value of the field if it's a pointer type. +} + +func (s *StructField) check(v interface{}) error { + t := reflect.TypeOf(v) + if !s.ReflectType.AssignableTo(t) { + if !s.ReflectType.ConvertibleTo(t) { + return fmt.Errorf("type %s (%v) cannot be converted to %T", s.ReflectType.Name(), s.ReflectType.Kind(), t.Name()) + } + + s.MarshalType = t + } + + if !t.AssignableTo(s.ReflectType) { + if !t.ConvertibleTo(s.ReflectType) { + return fmt.Errorf("type %s (%v) cannot be converted to %T", t.Name(), t.Kind(), s.ReflectType.Name()) + } + + s.UnmarshalType = s.ReflectType + } + return nil +} + +func parseTag(s string) map[string]string { + m := map[string]string{} + for _, v := range strings.Split(s, ",") { + v = strings.TrimSpace(v) + switch n := strings.IndexRune(v, ' '); { + case n < 0: + m[v] = "" + default: + m[v[:n]] = v[n+1:] + } + } + return m +} + +// StructSchema returns StructInfo for v which must be a struct instance or a +// pointer to a struct. The info is computed only once for every type. +// Subsequent calls to StructSchema for the same type return a cached +// StructInfo. +// +// Note: The returned StructSchema is shared and must be not mutated, including +// any other data structures it may point to. +func StructSchema(v interface{}) (*StructInfo, error) { + if v == nil { + return nil, fmt.Errorf("cannot derive schema for %T(%v)", v, v) + } + + typ := reflect.TypeOf(v) + schemaMu.RLock() + if r, ok := schemaCache[typ]; ok { + schemaMu.RUnlock() + return r, nil + } + + schemaMu.RUnlock() + var schemaPtr bool + t := typ + if t.Kind() == reflect.Ptr { + t = t.Elem() + schemaPtr = true + } + if k := t.Kind(); k != reflect.Struct { + return nil, fmt.Errorf("cannot derive schema for type %T (%v)", v, k) + } + + r := &StructInfo{IsPtr: schemaPtr} + for i := 0; i < t.NumField(); i++ { + f := t.Field(i) + fn := f.Name + if !ast.IsExported(fn) { + continue + } + + tags := parseTag(f.Tag.Get("ql")) + if _, ok := tags["-"]; ok { + continue + } + + if s := tags["name"]; s != "" { + fn = s + } + + if fn == "ID" && f.Type.Kind() == reflect.Int64 { + r.HasID = true + } + var ix, unique bool + var xn string + xfn := fn + if s := tags["index"]; s != "" { + if _, ok := tags["uindex"]; ok { + return nil, fmt.Errorf("both index and uindex in QL struct tag") + } + + ix, xn = true, s + } else if s := tags["uindex"]; s != "" { + if _, ok := tags["index"]; ok { + return nil, fmt.Errorf("both index and uindex in QL struct tag") + } + + ix, unique, xn = true, true, s + } + if ix { + if fn == "ID" && r.HasID { + xfn = "id()" + } + r.Indices = append(r.Indices, &StructIndex{Name: xn, ColumnName: xfn, Unique: unique}) + } + + sf := &StructField{Index: i, Name: fn, Tags: tags, Type: Type(-1), ReflectType: f.Type} + fk := sf.ReflectType.Kind() + if fk == reflect.Ptr { + sf.IsPtr = true + sf.ZeroPtr = reflect.Zero(sf.ReflectType) + sf.ReflectType = sf.ReflectType.Elem() + fk = sf.ReflectType.Kind() + } + + switch fk { + case reflect.Bool: + sf.Type = Bool + if err := sf.check(false); err != nil { + return nil, err + } + case reflect.Int, reflect.Uint: + return nil, fmt.Errorf("only integers of fixed size can be used to derive a schema: %v", fk) + case reflect.Int8: + sf.Type = Int8 + if err := sf.check(int8(0)); err != nil { + return nil, err + } + case reflect.Int16: + if err := sf.check(int16(0)); err != nil { + return nil, err + } + sf.Type = Int16 + case reflect.Int32: + if err := sf.check(int32(0)); err != nil { + return nil, err + } + sf.Type = Int32 + case reflect.Int64: + if sf.ReflectType.Name() == "Duration" && sf.ReflectType.PkgPath() == "time" { + sf.Type = Duration + break + } + + sf.Type = Int64 + if err := sf.check(int64(0)); err != nil { + return nil, err + } + case reflect.Uint8: + sf.Type = Uint8 + if err := sf.check(uint8(0)); err != nil { + return nil, err + } + case reflect.Uint16: + sf.Type = Uint16 + if err := sf.check(uint16(0)); err != nil { + return nil, err + } + case reflect.Uint32: + sf.Type = Uint32 + if err := sf.check(uint32(0)); err != nil { + return nil, err + } + case reflect.Uint64: + sf.Type = Uint64 + if err := sf.check(uint64(0)); err != nil { + return nil, err + } + case reflect.Float32: + sf.Type = Float32 + if err := sf.check(float32(0)); err != nil { + return nil, err + } + case reflect.Float64: + sf.Type = Float64 + if err := sf.check(float64(0)); err != nil { + return nil, err + } + case reflect.Complex64: + sf.Type = Complex64 + if err := sf.check(complex64(0)); err != nil { + return nil, err + } + case reflect.Complex128: + sf.Type = Complex128 + if err := sf.check(complex128(0)); err != nil { + return nil, err + } + case reflect.Slice: + sf.Type = Blob + if err := sf.check([]byte(nil)); err != nil { + return nil, err + } + case reflect.Struct: + switch sf.ReflectType.PkgPath() { + case "math/big": + switch sf.ReflectType.Name() { + case "Int": + sf.Type = BigInt + case "Rat": + sf.Type = BigRat + } + case "time": + switch sf.ReflectType.Name() { + case "Time": + sf.Type = Time + } + } + case reflect.String: + sf.Type = String + if err := sf.check(""); err != nil { + return nil, err + } + } + + if sf.Type < 0 { + return nil, fmt.Errorf("cannot derive schema for type %s (%v)", sf.ReflectType.Name(), fk) + } + + sf.IsID = fn == "ID" && r.HasID + r.Fields = append(r.Fields, sf) + } + + schemaMu.Lock() + schemaCache[typ] = r + if t != typ { + r2 := *r + r2.IsPtr = false + schemaCache[t] = &r2 + } + schemaMu.Unlock() + return r, nil +} + +// MustStructSchema is like StructSchema but panics on error. It simplifies +// safe initialization of global variables holding StructInfo. +// +// MustStructSchema is safe for concurrent use by multiple goroutines. +func MustStructSchema(v interface{}) *StructInfo { + s, err := StructSchema(v) + if err != nil { + panic(err) + } + + return s +} + +// SchemaOptions amend the result of Schema. +type SchemaOptions struct { + // Don't wrap the CREATE statement(s) in a transaction. + NoTransaction bool + + // Don't insert the IF NOT EXISTS clause in the CREATE statement(s). + NoIfNotExists bool + + // Do not strip the "pkg." part from type name "pkg.Type", produce + // "pkg_Type" table name instead. Applies only when no name is passed + // to Schema(). + KeepPrefix bool +} + +var zeroSchemaOptions SchemaOptions + +// Schema returns a CREATE TABLE/INDEX statement(s) for a table derived from a +// struct or an error, if any. The table is named using the name parameter. If +// name is an empty string then the type name of the struct is used while non +// conforming characters are replaced by underscores. Value v can be also a +// pointer to a struct. +// +// Every considered struct field type must be one of the QL types or a type +// convertible to string, bool, int*, uint*, float* or complex* type or pointer +// to such type. Integers with a width dependent on the architecture can not be +// used. Only exported fields are considered. If an exported field QL tag +// contains "-" (`ql:"-"`) then such field is not considered. A field with name +// ID, having type int64, corresponds to id() - and is thus not a part of the +// CREATE statement. A field QL tag containing "index name" or "uindex name" +// triggers additionally creating an index or unique index on the respective +// field. Fields can be renamed using a QL tag "name newName". Fields are +// considered in the order of appearance. A QL tag is a struct tag part +// prefixed by "ql:". Tags can be combined, for example: +// +// type T struct { +// Foo string `ql:"index xFoo, name Bar"` +// } +// +// If opts.NoTransaction == true then the statement(s) are not wrapped in a +// transaction. If opt.NoIfNotExists == true then the CREATE statement(s) omits +// the IF NOT EXISTS clause. Passing nil opts is equal to passing +// &SchemaOptions{} +// +// Schema is safe for concurrent use by multiple goroutines. +func Schema(v interface{}, name string, opt *SchemaOptions) (List, error) { + if opt == nil { + opt = &zeroSchemaOptions + } + s, err := StructSchema(v) + if err != nil { + return List{}, err + } + + var buf bytes.Buffer + if !opt.NoTransaction { + buf.WriteString("BEGIN TRANSACTION; ") + } + buf.WriteString("CREATE TABLE ") + if !opt.NoIfNotExists { + buf.WriteString("IF NOT EXISTS ") + } + if name == "" { + name = fmt.Sprintf("%T", v) + if !opt.KeepPrefix { + a := strings.Split(name, ".") + if l := len(a); l > 1 { + name = a[l-1] + } + } + nm := []rune{} + for _, v := range name { + switch { + case v >= '0' && v <= '9' || v == '_' || v >= 'a' && v <= 'z' || v >= 'A' && v <= 'Z': + // ok + default: + v = '_' + } + nm = append(nm, v) + } + name = string(nm) + } + buf.WriteString(name + " (") + for _, v := range s.Fields { + if v.IsID { + continue + } + + buf.WriteString(fmt.Sprintf("%s %s, ", v.Name, v.Type)) + } + buf.WriteString("); ") + for _, v := range s.Indices { + buf.WriteString("CREATE ") + if v.Unique { + buf.WriteString("UNIQUE ") + } + buf.WriteString("INDEX ") + if !opt.NoIfNotExists { + buf.WriteString("IF NOT EXISTS ") + } + buf.WriteString(fmt.Sprintf("%s ON %s (%s); ", v.Name, name, v.ColumnName)) + } + if !opt.NoTransaction { + buf.WriteString("COMMIT; ") + } + l, err := Compile(buf.String()) + if err != nil { + return List{}, fmt.Errorf("%s: %v", buf.String(), err) + } + + return l, nil +} + +// MustSchema is like Schema but panics on error. It simplifies safe +// initialization of global variables holding compiled schemas. +// +// MustSchema is safe for concurrent use by multiple goroutines. +func MustSchema(v interface{}, name string, opt *SchemaOptions) List { + l, err := Schema(v, name, opt) + if err != nil { + panic(err) + } + + return l +} + +// Marshal converts, in the order of appearance, fields of a struct instance v +// to []interface{} or an error, if any. Value v can be also a pointer to a +// struct. +// +// Every considered struct field type must be one of the QL types or a type +// convertible to string, bool, int*, uint*, float* or complex* type or pointer +// to such type. Integers with a width dependent on the architecture can not be +// used. Only exported fields are considered. If an exported field QL tag +// contains "-" then such field is not considered. A QL tag is a struct tag +// part prefixed by "ql:". Field with name ID, having type int64, corresponds +// to id() - and is thus not part of the result. +// +// Marshal is safe for concurrent use by multiple goroutines. +func Marshal(v interface{}) ([]interface{}, error) { + s, err := StructSchema(v) + if err != nil { + return nil, err + } + + val := reflect.ValueOf(v) + if s.IsPtr { + val = val.Elem() + } + n := len(s.Fields) + if s.HasID { + n-- + } + r := make([]interface{}, n) + j := 0 + for _, v := range s.Fields { + if v.IsID { + continue + } + + f := val.Field(v.Index) + if v.IsPtr { + if f.IsNil() { + r[j] = nil + j++ + continue + } + + f = f.Elem() + } + if m := v.MarshalType; m != nil { + f = f.Convert(m) + } + r[j] = f.Interface() + j++ + } + return r, nil +} + +// MustMarshal is like Marshal but panics on error. It simplifies marshaling of +// "safe" types, like eg. those which were already verified by Schema or +// MustSchema. When the underlying Marshal returns an error, MustMarshal +// panics. +// +// MustMarshal is safe for concurrent use by multiple goroutines. +func MustMarshal(v interface{}) []interface{} { + r, err := Marshal(v) + if err != nil { + panic(err) + } + + return r +} + +// Unmarshal stores data from []interface{} in the struct value pointed to by +// v. +// +// Every considered struct field type must be one of the QL types or a type +// convertible to string, bool, int*, uint*, float* or complex* type or pointer +// to such type. Integers with a width dependent on the architecture can not be +// used. Only exported fields are considered. If an exported field QL tag +// contains "-" then such field is not considered. A QL tag is a struct tag +// part prefixed by "ql:". Fields are considered in the order of appearance. +// Types of values in data must be compatible with the corresponding considered +// field of v. +// +// If the struct has no ID field then the number of values in data must be equal +// to the number of considered fields of v. +// +// type T struct { +// A bool +// B string +// } +// +// Assuming the schema is +// +// CREATE TABLE T (A bool, B string); +// +// Data might be a result of queries like +// +// SELECT * FROM T; +// SELECT A, B FROM T; +// +// If the struct has a considered ID field then the number of values in data +// must be equal to the number of considered fields in v - or one less. In the +// later case the ID field is not set. +// +// type U struct { +// ID int64 +// A bool +// B string +// } +// +// Assuming the schema is +// +// CREATE TABLE T (A bool, B string); +// +// Data might be a result of queries like +// +// SELECT * FROM T; // ID not set +// SELECT A, B FROM T; // ID not set +// SELECT id(), A, B FROM T; // ID is set +// +// To unmarshal a value from data into a pointer field of v, Unmarshal first +// handles the case of the value being nil. In that case, Unmarshal sets the +// pointer to nil. Otherwise, Unmarshal unmarshals the data value into value +// pointed at by the pointer. If the pointer is nil, Unmarshal allocates a new +// value for it to point to. +// +// Unmarshal is safe for concurrent use by multiple goroutines. +func Unmarshal(v interface{}, data []interface{}) (err error) { + defer func() { + if r := recover(); r != nil { + var ok bool + if err, ok = r.(error); !ok { + err = fmt.Errorf("%v", r) + } + err = fmt.Errorf("unmarshal: %v", err) + } + }() + + s, err := StructSchema(v) + if err != nil { + return err + } + + if !s.IsPtr { + return fmt.Errorf("unmarshal: need a pointer to a struct") + } + + id := false + nv, nf := len(data), len(s.Fields) + switch s.HasID { + case true: + switch { + case nv == nf: + id = true + case nv == nf-1: + // ok + default: + return fmt.Errorf("unmarshal: got %d values, need %d or %d", nv, nf-1, nf) + } + default: + switch { + case nv == nf: + // ok + default: + return fmt.Errorf("unmarshal: got %d values, need %d", nv, nf) + } + } + + j := 0 + vVal := reflect.ValueOf(v) + if s.IsPtr { + vVal = vVal.Elem() + } + for _, sf := range s.Fields { + if sf.IsID && !id { + continue + } + + d := data[j] + val := reflect.ValueOf(d) + j++ + + fVal := vVal.Field(sf.Index) + if u := sf.UnmarshalType; u != nil { + val = val.Convert(u) + } + if !sf.IsPtr { + fVal.Set(val) + continue + } + + if d == nil { + fVal.Set(sf.ZeroPtr) + continue + } + + if fVal.IsNil() { + fVal.Set(reflect.New(sf.ReflectType)) + } + + fVal.Elem().Set(val) + } + return nil +} diff --git a/vendor/github.com/cznic/ql/mem.go b/vendor/github.com/cznic/ql/mem.go new file mode 100644 index 0000000000..bd2a2dd269 --- /dev/null +++ b/vendor/github.com/cznic/ql/mem.go @@ -0,0 +1,1277 @@ +// Copyright (c) 2014 ql Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Plain memory storage back end. + +package ql + +import ( + "bytes" + "fmt" + "io" + "math/big" + "time" +) + +var ( + _ btreeIndex = (*memIndex)(nil) + _ btreeIterator = (*memBTreeIterator)(nil) + _ indexIterator = (*xenumerator2)(nil) + _ storage = (*mem)(nil) + _ temp = (*memTemp)(nil) +) + +type memIndex struct { + m *mem + t *xtree + unique bool +} + +func newMemIndex(m *mem, unique bool) *memIndex { + r := &memIndex{t: xtreeNew(), unique: unique, m: m} + //dbg("newMemIndex %p, %p", r, m) + return r +} + +func (x *memIndex) Clear() error { + //dbg("memIndex(%p, %p).Clear", x, x.m) + x.m.newUndo(undoClearX, 0, []interface{}{x, x.t}) + x.t = xtreeNew() + return nil +} + +func (x *memIndex) Create(indexedValues []interface{}, h int64) error { + //dbg("memIndex(%p, %p).Create %v, %v", x, x.m, indexedValues, h) + t := x.t + switch { + case !x.unique: + k := indexKey{indexedValues, h} + x.m.newUndo(undoCreateX, 0, []interface{}{x, k}) //TODO why is old value, if any, not saved? + t.Set(k, 0) + case isIndexNull(indexedValues): // unique, NULL + k := indexKey{nil, h} + x.m.newUndo(undoCreateX, 0, []interface{}{x, k}) //TODO why is old value, if any, not saved? + t.Set(k, 0) + default: // unique, non NULL + k := indexKey{indexedValues, 0} + if _, ok := t.Get(k); ok { //LATER need .Put + return fmt.Errorf("cannot insert into unique index: duplicate value(s): %v", indexedValues) + } + + x.m.newUndo(undoCreateX, 0, []interface{}{x, k}) //TODO why is old value, if any, not saved? + t.Set(k, int(h)) + } + return nil +} + +func (x *memIndex) Delete(indexedValues []interface{}, h int64) error { + //dbg("memIndex(%p, %p).Delete %v, %v", x, x.m, indexedValues, h) + t := x.t + var k indexKey + var v interface{} + var ok, okv bool + switch { + case !x.unique: + k = indexKey{indexedValues, h} + v, okv = t.Get(k) + ok = t.delete(k) + case isIndexNull(indexedValues): // unique, NULL + k = indexKey{nil, h} + v, okv = t.Get(k) + ok = t.delete(k) + default: // unique, non NULL + k = indexKey{indexedValues, 0} + v, okv = t.Get(k) + ok = t.delete(k) + } + if ok { + if okv { + x.m.newUndo(undoDeleteX, int64(v.(int)), []interface{}{x, k}) + } + return nil + } + + return fmt.Errorf("internal error 047") +} + +func (x *memIndex) Drop() error { + x.m.newUndo(undoDropX, 0, []interface{}{x, *x}) + *x = memIndex{} + return nil +} + +func (x *memIndex) Seek(indexedValues []interface{}) (indexIterator, bool, error) { + it, hit := x.t.Seek(indexKey{indexedValues, 0}) + return &xenumerator2{*it, x.unique}, hit, nil +} + +func (x *memIndex) SeekFirst() (iter indexIterator, err error) { + it, err := x.t.SeekFirst() + if err != nil { + return nil, err + } + + return &xenumerator2{*it, x.unique}, nil +} + +func (x *memIndex) SeekLast() (iter indexIterator, err error) { + it, err := x.t.SeekLast() + if err != nil { + return nil, err + } + + return &xenumerator2{*it, x.unique}, nil +} + +type xenumerator2 struct { + it xenumerator + unique bool +} + +func (it *xenumerator2) Next() ([]interface{}, int64, error) { + k, h, err := it.it.Next() + if err != nil { + return nil, -1, err + } + + switch it.unique { + case true: + if k.value == nil { + return nil, k.h, nil + } + + return k.value, h, nil + default: + return k.value, k.h, nil + } +} + +func (it *xenumerator2) Prev() ([]interface{}, int64, error) { + k, h, err := it.it.Prev() + if err != nil { + return nil, -1, err + } + + switch it.unique { + case true: + if k.value == nil { + return nil, k.h, nil + } + + return k.value, h, nil + default: + return k.value, k.h, nil + } +} + +type memBTreeIterator enumerator + +func (it *memBTreeIterator) Next() (k, v []interface{}, err error) { + return (*enumerator)(it).Next() +} + +type memTemp struct { + tree *tree + store *mem +} + +func (t *memTemp) BeginTransaction() (err error) { + return nil +} + +func (t *memTemp) Get(k []interface{}) (v []interface{}, err error) { + v, _ = t.tree.Get(k) + return +} + +func (t *memTemp) Create(data ...interface{}) (h int64, err error) { + s := t.store + switch n := len(s.recycler); { + case n != 0: + h = int64(s.recycler[n-1]) + s.recycler = s.recycler[:n-1] + s.data[h] = s.clone(data...) + default: + h = int64(len(s.data)) + s.data = append(s.data, s.clone(data...)) + } + return +} + +func (t *memTemp) Read(dst []interface{}, h int64, cols ...*col) (data []interface{}, err error) { + return t.store.Read(dst, h, cols...) +} + +func (*memTemp) Drop() (err error) { return } + +func (t *memTemp) Set(k, v []interface{}) (err error) { + t.tree.Set(append([]interface{}(nil), k...), t.store.clone(v...)) + return +} + +func (t *memTemp) SeekFirst() (e btreeIterator, err error) { + en, err := t.tree.SeekFirst() + if err != nil { + return + } + + return (*memBTreeIterator)(en), nil +} + +const ( + undoCreateNewHandle = iota + undoCreateRecycledHandle + undoUpdate + undoDelete + undoClearX // {0: *memIndex, 1: *xtree} + undoCreateX // {0: *memIndex, 1: indexKey} + undoDeleteX // {0: *memIndex, 1: indexKey} + undoDropX // {0: *memIndex, 1: memIndex} +) + +type undo struct { + tag int + h int64 + data []interface{} +} + +type undos struct { + list []undo + parent *undos +} + +type mem struct { + data [][]interface{} + id int64 + recycler []int + tnl int + rollback *undos +} + +func newMemStorage() (s *mem, err error) { + s = &mem{data: [][]interface{}{nil}} + if err = s.BeginTransaction(); err != nil { + return nil, err + } + + h, err := s.Create() + if h != 1 { + panic("internal error 048") + } + + if err = s.Commit(); err != nil { + return nil, err + } + + return +} + +func (s *mem) OpenIndex(unique bool, handle int64) (btreeIndex, error) { // Never called on the memory backend. + panic("internal error 049") +} + +func (s *mem) newUndo(tag int, h int64, data []interface{}) { + s.rollback.list = append(s.rollback.list, undo{tag, h, data}) +} + +func (s *mem) Acid() bool { return false } + +func (s *mem) Close() (err error) { + if s.tnl != 0 { + return fmt.Errorf("cannot close DB while open transaction exist") + } + *s = mem{} + return +} + +func (s *mem) CreateIndex(unique bool) ( /* handle */ int64, btreeIndex, error) { + return -1, newMemIndex(s, unique), nil // handle of memIndex should never be used +} + +func (s *mem) Name() string { return fmt.Sprintf("/proc/self/mem/%p", s) } // fake, non existing name + +// OpenMem returns a new, empty DB backed by the process' memory. The back end +// has no limits on field/record/table/DB size other than memory available to +// the process. +func OpenMem() (db *DB, err error) { + s, err := newMemStorage() + if err != nil { + return + } + + if db, err = newDB(s); err != nil { + return nil, err + } + + db.isMem = true + return db, nil +} + +func (s *mem) Verify() (allocs int64, err error) { + for _, v := range s.recycler { + if s.data[v] != nil { + return 0, fmt.Errorf("corrupted: non nil free handle %d", s.data[v]) + } + } + + for _, v := range s.data { + if v != nil { + allocs++ + } + } + + if allocs != int64(len(s.data))-1-int64(len(s.recycler)) { + return 0, fmt.Errorf("corrupted: len(data) %d, len(recycler) %d, allocs %d", len(s.data), len(s.recycler), allocs) + } + + return +} + +func (s *mem) String() string { + var b bytes.Buffer + for i, v := range s.data { + b.WriteString(fmt.Sprintf("s.data[%d] %#v\n", i, v)) + } + for i, v := range s.recycler { + b.WriteString(fmt.Sprintf("s.recycler[%d] %v\n", i, v)) + } + return b.String() +} + +func (s *mem) CreateTemp(asc bool) (_ temp, err error) { + st, err := newMemStorage() + if err != nil { + return + } + + return &memTemp{ + tree: treeNew(collators[asc]), + store: st, + }, nil +} + +func (s *mem) ResetID() (err error) { + s.id = 0 + return +} + +func (s *mem) ID() (id int64, err error) { + s.id++ + return s.id, nil +} + +func (s *mem) clone(data ...interface{}) []interface{} { + r := make([]interface{}, len(data)) + for i, v := range data { + switch x := v.(type) { + case nil: + // nop + case idealComplex: + r[i] = complex128(x) + case idealFloat: + r[i] = float64(x) + case idealInt: + r[i] = int64(x) + case idealRune: + r[i] = int32(x) + case idealUint: + r[i] = uint64(x) + case bool: + r[i] = x + case complex64: + r[i] = x + case complex128: + r[i] = x + case float32: + r[i] = x + case float64: + r[i] = x + case int: + r[i] = int64(x) + case int8: + r[i] = x + case int16: + r[i] = x + case int32: + r[i] = x + case int64: + r[i] = x + case string: + r[i] = x + case uint: + r[i] = uint64(x) + case uint8: + r[i] = x + case uint16: + r[i] = x + case uint32: + r[i] = x + case uint64: + r[i] = x + case []byte: + r[i] = append([]byte(nil), x...) + case *big.Int: + r[i] = big.NewInt(0).Set(x) + case *big.Rat: + r[i] = big.NewRat(1, 2).Set(x) + case time.Time: + t := x + r[i] = t + case time.Duration: + r[i] = x + case map[string]interface{}: // map of ids of a cross join + r[i] = x + default: + panic("internal error 050") + } + } + return r +} + +func (s *mem) Create(data ...interface{}) (h int64, err error) { + switch n := len(s.recycler); { + case n != 0: + h = int64(s.recycler[n-1]) + s.recycler = s.recycler[:n-1] + s.data[h] = s.clone(data...) + r := s.rollback + r.list = append(r.list, undo{ + tag: undoCreateRecycledHandle, + h: h, + }) + default: + h = int64(len(s.data)) + s.data = append(s.data, s.clone(data...)) + r := s.rollback + r.list = append(r.list, undo{ + tag: undoCreateNewHandle, + h: h, + }) + } + return +} + +func (s *mem) Read(dst []interface{}, h int64, cols ...*col) (data []interface{}, err error) { + if i := int(h); i != 0 && i < len(s.data) { + d := s.clone(s.data[h]...) + if cols == nil { + return d, nil + } + + for n, dn := len(cols)+2, len(d); dn < n; dn++ { + d = append(d, nil) + } + return d, nil + } + + return nil, errNoDataForHandle +} + +func (s *mem) UpdateRow(h int64, _ []*col, data ...interface{}) (err error) { + return s.Update(h, data...) +} + +func (s *mem) Update(h int64, data ...interface{}) (err error) { + r := s.rollback + r.list = append(r.list, undo{ + tag: undoUpdate, + h: h, + data: s.data[h], + }) + s.data[h] = s.clone(data...) + return +} + +func (s *mem) Delete(h int64, _ ...*col) (err error) { + r := s.rollback + r.list = append(r.list, undo{ + tag: undoDelete, + h: h, + data: s.data[h], + }) + s.recycler = append(s.recycler, int(h)) + s.data[h] = nil + return +} + +func (s *mem) BeginTransaction() (err error) { + s.rollback = &undos{parent: s.rollback} + s.tnl++ + return nil +} + +func (s *mem) Rollback() (err error) { + if s.tnl == 0 { + return errRollbackNotInTransaction + } + + list := s.rollback.list + for i := len(list) - 1; i >= 0; i-- { + undo := list[i] + switch h, data := int(undo.h), undo.data; undo.tag { + case undoCreateNewHandle: + d := s.data + s.data = d[:len(d)-1] + case undoCreateRecycledHandle: + s.data[h] = nil + r := s.recycler + s.recycler = append(r, h) + case undoUpdate: + s.data[h] = data + case undoDelete: + s.data[h] = data + s.recycler = s.recycler[:len(s.recycler)-1] + case undoClearX: + x, t := data[0].(*memIndex), data[1].(*xtree) + x.t = t + case undoCreateX: + x, k := data[0].(*memIndex), data[1].(indexKey) + x.t.delete(k) + case undoDeleteX: + x, k := data[0].(*memIndex), data[1].(indexKey) + x.t.Set(k, h) + case undoDropX: + x, v := data[0].(*memIndex), data[1].(memIndex) + *x = v + default: + panic("internal error 051") + } + } + + s.tnl-- + s.rollback = s.rollback.parent + return nil +} + +func (s *mem) Commit() (err error) { + if s.tnl == 0 { + return errCommitNotInTransaction + } + + s.tnl-- + s.rollback = s.rollback.parent + return nil +} + +// Transaction index B+Tree +//LATER make it just a wrapper of the implementation in btree.go. + +type ( + xd struct { // data page + c int + xd [2*kd + 1]xde + n *xd + p *xd + } + + xde struct { // xd element + k indexKey + v int + } + + // xenumerator captures the state of enumerating a tree. It is returned + // from the Seek* methods. The enumerator is aware of any mutations + // made to the tree in the process of enumerating it and automatically + // resumes the enumeration at the proper key, if possible. + // + // However, once an xenumerator returns io.EOF to signal "no more + // items", it does no more attempt to "resync" on tree mutation(s). In + // other words, io.EOF from an Enumaretor is "sticky" (idempotent). + xenumerator struct { + err error + hit bool + i int + k indexKey + q *xd + t *xtree + ver int64 + } + + // xtree is a B+tree. + xtree struct { + c int + first *xd + last *xd + r interface{} + ver int64 + } + + xxe struct { // xx element + ch interface{} + sep *xd + } + + xx struct { // index page + c int + xx [2*kx + 2]xxe + } +) + +func (a *indexKey) cmp(b *indexKey) int { + r := collate(a.value, b.value) + if r != 0 { + return r + } + + return int(a.h) - int(b.h) +} + +var ( // R/O zero values + zxd xd + zxde xde + zxx xx + zxxe xxe +) + +func xclr(q interface{}) { + switch xx := q.(type) { + case *xx: + for i := 0; i <= xx.c; i++ { // Ch0 Sep0 ... Chn-1 Sepn-1 Chn + xclr(xx.xx[i].ch) + } + *xx = zxx // GC + case *xd: + *xx = zxd // GC + } +} + +// -------------------------------------------------------------------------- xx + +func xnewX(ch0 interface{}) *xx { + r := &xx{} + r.xx[0].ch = ch0 + return r +} + +func (q *xx) extract(i int) { + q.c-- + if i < q.c { + copy(q.xx[i:], q.xx[i+1:q.c+1]) + q.xx[q.c].ch = q.xx[q.c+1].ch + q.xx[q.c].sep = nil // GC + q.xx[q.c+1] = zxxe // GC + } +} + +func (q *xx) insert(i int, xd *xd, ch interface{}) *xx { + c := q.c + if i < c { + q.xx[c+1].ch = q.xx[c].ch + copy(q.xx[i+2:], q.xx[i+1:c]) + q.xx[i+1].sep = q.xx[i].sep + } + c++ + q.c = c + q.xx[i].sep = xd + q.xx[i+1].ch = ch + return q +} + +func (q *xx) siblings(i int) (l, r *xd) { + if i >= 0 { + if i > 0 { + l = q.xx[i-1].ch.(*xd) + } + if i < q.c { + r = q.xx[i+1].ch.(*xd) + } + } + return +} + +// -------------------------------------------------------------------------- xd + +func (l *xd) mvL(r *xd, c int) { + copy(l.xd[l.c:], r.xd[:c]) + copy(r.xd[:], r.xd[c:r.c]) + l.c += c + r.c -= c +} + +func (l *xd) mvR(r *xd, c int) { + copy(r.xd[c:], r.xd[:r.c]) + copy(r.xd[:c], l.xd[l.c-c:]) + r.c += c + l.c -= c +} + +// ----------------------------------------------------------------------- xtree + +// xtreeNew returns a newly created, empty xtree. The compare function is used +// for key collation. +func xtreeNew() *xtree { + return &xtree{} +} + +// Clear removes all K/V pairs from the tree. +func (t *xtree) Clear() { + if t.r == nil { + return + } + + xclr(t.r) + t.c, t.first, t.last, t.r = 0, nil, nil, nil + t.ver++ +} + +func (t *xtree) cat(p *xx, q, r *xd, pi int) { + t.ver++ + q.mvL(r, r.c) + if r.n != nil { + r.n.p = q + } else { + t.last = q + } + q.n = r.n + if p.c > 1 { + p.extract(pi) + p.xx[pi].ch = q + } else { + t.r = q + } +} + +func (t *xtree) catX(p, q, r *xx, pi int) { + t.ver++ + q.xx[q.c].sep = p.xx[pi].sep + copy(q.xx[q.c+1:], r.xx[:r.c]) + q.c += r.c + 1 + q.xx[q.c].ch = r.xx[r.c].ch + if p.c > 1 { + p.c-- + pc := p.c + if pi < pc { + p.xx[pi].sep = p.xx[pi+1].sep + copy(p.xx[pi+1:], p.xx[pi+2:pc+1]) + p.xx[pc].ch = p.xx[pc+1].ch + p.xx[pc].sep = nil // GC + p.xx[pc+1].ch = nil // GC + } + return + } + + t.r = q +} + +//Delete removes the k's KV pair, if it exists, in which case Delete returns +//true. +func (t *xtree) delete(k indexKey) (ok bool) { + pi := -1 + var p *xx + q := t.r + if q == nil { + return + } + + for { + var i int + i, ok = t.find(q, k) + if ok { + switch xx := q.(type) { + case *xx: + dp := xx.xx[i].sep + switch { + case dp.c > kd: + t.extract(dp, 0) + default: + if xx.c < kx && q != t.r { + t.underflowX(p, &xx, pi, &i) + } + pi = i + 1 + p = xx + q = xx.xx[pi].ch + ok = false + continue + } + case *xd: + t.extract(xx, i) + if xx.c >= kd { + return + } + + if q != t.r { + t.underflow(p, xx, pi) + } else if t.c == 0 { + t.Clear() + } + } + return + } + + switch xx := q.(type) { + case *xx: + if xx.c < kx && q != t.r { + t.underflowX(p, &xx, pi, &i) + } + pi = i + p = xx + q = xx.xx[i].ch + case *xd: + return + } + } +} + +func (t *xtree) extract(q *xd, i int) { // (r int64) { + t.ver++ + //r = q.xd[i].v // prepared for Extract + q.c-- + if i < q.c { + copy(q.xd[i:], q.xd[i+1:q.c+1]) + } + q.xd[q.c] = zxde // GC + t.c-- + return +} + +func (t *xtree) find(q interface{}, k indexKey) (i int, ok bool) { + var mk indexKey + l := 0 + switch xx := q.(type) { + case *xx: + h := xx.c - 1 + for l <= h { + m := (l + h) >> 1 + mk = xx.xx[m].sep.xd[0].k + switch cmp := k.cmp(&mk); { + case cmp > 0: + l = m + 1 + case cmp == 0: + return m, true + default: + h = m - 1 + } + } + case *xd: + h := xx.c - 1 + for l <= h { + m := (l + h) >> 1 + mk = xx.xd[m].k + switch cmp := k.cmp(&mk); { + case cmp > 0: + l = m + 1 + case cmp == 0: + return m, true + default: + h = m - 1 + } + } + } + return l, false +} + +// First returns the first item of the tree in the key collating order, or +// (nil, nil) if the tree is empty. +func (t *xtree) First() (k indexKey, v int) { + if q := t.first; q != nil { + q := &q.xd[0] + k, v = q.k, q.v + } + return +} + +// Get returns the value associated with k and true if it exists. Otherwise Get +// returns (nil, false). +func (t *xtree) Get(k indexKey) (v int, ok bool) { + q := t.r + if q == nil { + return + } + + for { + var i int + if i, ok = t.find(q, k); ok { + switch xx := q.(type) { + case *xx: + return xx.xx[i].sep.xd[0].v, true + case *xd: + return xx.xd[i].v, true + } + } + switch xx := q.(type) { + case *xx: + q = xx.xx[i].ch + default: + return + } + } +} + +func (t *xtree) insert(q *xd, i int, k indexKey, v int) *xd { + t.ver++ + c := q.c + if i < c { + copy(q.xd[i+1:], q.xd[i:c]) + } + c++ + q.c = c + q.xd[i].k, q.xd[i].v = k, v + t.c++ + return q +} + +// Last returns the last item of the tree in the key collating order, or (nil, +// nil) if the tree is empty. +func (t *xtree) Last() (k indexKey, v int) { + if q := t.last; q != nil { + q := &q.xd[q.c-1] + k, v = q.k, q.v + } + return +} + +// Len returns the number of items in the tree. +func (t *xtree) Len() int { + return t.c +} + +func (t *xtree) overflow(p *xx, q *xd, pi, i int, k indexKey, v int) { + t.ver++ + l, r := p.siblings(pi) + + if l != nil && l.c < 2*kd { + l.mvL(q, 1) + t.insert(q, i-1, k, v) + return + } + + if r != nil && r.c < 2*kd { + if i < 2*kd { + q.mvR(r, 1) + t.insert(q, i, k, v) + } else { + t.insert(r, 0, k, v) + } + return + } + + t.split(p, q, pi, i, k, v) +} + +// Seek returns an xenumerator positioned on a an item such that k >= item's +// key. ok reports if k == item.key The xenumerator's position is possibly +// after the last item in the tree. +func (t *xtree) Seek(k indexKey) (e *xenumerator, ok bool) { + q := t.r + if q == nil { + e = &xenumerator{nil, false, 0, k, nil, t, t.ver} + return + } + + for { + var i int + if i, ok = t.find(q, k); ok { + switch xx := q.(type) { + case *xx: + e = &xenumerator{nil, ok, 0, k, xx.xx[i].sep, t, t.ver} + return + case *xd: + e = &xenumerator{nil, ok, i, k, xx, t, t.ver} + return + } + } + switch xx := q.(type) { + case *xx: + q = xx.xx[i].ch + case *xd: + e = &xenumerator{nil, ok, i, k, xx, t, t.ver} + return + } + } +} + +// SeekFirst returns an enumerator positioned on the first KV pair in the tree, +// if any. For an empty tree, err == io.EOF is returned and e will be nil. +func (t *xtree) SeekFirst() (e *xenumerator, err error) { + q := t.first + if q == nil { + return nil, io.EOF + } + + return &xenumerator{nil, true, 0, q.xd[0].k, q, t, t.ver}, nil +} + +// SeekLast returns an enumerator positioned on the last KV pair in the tree, +// if any. For an empty tree, err == io.EOF is returned and e will be nil. +func (t *xtree) SeekLast() (e *xenumerator, err error) { + q := t.last + if q == nil { + return nil, io.EOF + } + + return &xenumerator{nil, true, q.c - 1, q.xd[q.c-1].k, q, t, t.ver}, nil +} + +// Set sets the value associated with k. +func (t *xtree) Set(k indexKey, v int) { + pi := -1 + var p *xx + q := t.r + if q != nil { + for { + i, ok := t.find(q, k) + if ok { + switch xx := q.(type) { + case *xx: + xx.xx[i].sep.xd[0].v = v + case *xd: + xx.xd[i].v = v + } + return + } + + switch xx := q.(type) { + case *xx: + if xx.c > 2*kx { + t.splitX(p, &xx, pi, &i) + } + pi = i + p = xx + q = xx.xx[i].ch + case *xd: + switch { + case xx.c < 2*kd: + t.insert(xx, i, k, v) + default: + t.overflow(p, xx, pi, i, k, v) + } + return + } + } + } + + z := t.insert(&xd{}, 0, k, v) + t.r, t.first, t.last = z, z, z + return +} + +func (t *xtree) split(p *xx, q *xd, pi, i int, k indexKey, v int) { + t.ver++ + r := &xd{} + if q.n != nil { + r.n = q.n + r.n.p = r + } else { + t.last = r + } + q.n = r + r.p = q + + copy(r.xd[:], q.xd[kd:2*kd]) + for i := range q.xd[kd:] { + q.xd[kd+i] = zxde + } + q.c = kd + r.c = kd + if pi >= 0 { + p.insert(pi, r, r) + } else { + t.r = xnewX(q).insert(0, r, r) + } + if i > kd { + t.insert(r, i-kd, k, v) + return + } + + t.insert(q, i, k, v) +} + +func (t *xtree) splitX(p *xx, pp **xx, pi int, i *int) { + t.ver++ + q := *pp + r := &xx{} + copy(r.xx[:], q.xx[kx+1:]) + q.c = kx + r.c = kx + if pi >= 0 { + p.insert(pi, q.xx[kx].sep, r) + } else { + t.r = xnewX(q).insert(0, q.xx[kx].sep, r) + } + q.xx[kx].sep = nil + for i := range q.xx[kx+1:] { + q.xx[kx+i+1] = zxxe + } + if *i > kx { + *pp = r + *i -= kx + 1 + } +} + +func (t *xtree) underflow(p *xx, q *xd, pi int) { + t.ver++ + l, r := p.siblings(pi) + + if l != nil && l.c+q.c >= 2*kd { + l.mvR(q, 1) + } else if r != nil && q.c+r.c >= 2*kd { + q.mvL(r, 1) + r.xd[r.c] = zxde // GC + } else if l != nil { + t.cat(p, l, q, pi-1) + } else { + t.cat(p, q, r, pi) + } +} + +func (t *xtree) underflowX(p *xx, pp **xx, pi int, i *int) { + t.ver++ + var l, r *xx + q := *pp + + if pi >= 0 { + if pi > 0 { + l = p.xx[pi-1].ch.(*xx) + } + if pi < p.c { + r = p.xx[pi+1].ch.(*xx) + } + } + + if l != nil && l.c > kx { + q.xx[q.c+1].ch = q.xx[q.c].ch + copy(q.xx[1:], q.xx[:q.c]) + q.xx[0].ch = l.xx[l.c].ch + q.xx[0].sep = p.xx[pi-1].sep + q.c++ + *i++ + l.c-- + p.xx[pi-1].sep = l.xx[l.c].sep + return + } + + if r != nil && r.c > kx { + q.xx[q.c].sep = p.xx[pi].sep + q.c++ + q.xx[q.c].ch = r.xx[0].ch + p.xx[pi].sep = r.xx[0].sep + copy(r.xx[:], r.xx[1:r.c]) + r.c-- + rc := r.c + r.xx[rc].ch = r.xx[rc+1].ch + r.xx[rc].sep = nil + r.xx[rc+1].ch = nil + return + } + + if l != nil { + *i += l.c + 1 + t.catX(p, l, q, pi-1) + *pp = l + return + } + + t.catX(p, q, r, pi) +} + +// ----------------------------------------------------------------- xenumerator + +// Next returns the currently enumerated item, if it exists and moves to the +// next item in the key collation order. If there is no item to return, err == +// io.EOF is returned. +func (e *xenumerator) Next() (k indexKey, v int64, err error) { + if err = e.err; err != nil { + return + } + + if e.ver != e.t.ver { + f, hit := e.t.Seek(e.k) + if !e.hit && hit { + if err = f.next(); err != nil { + return + } + } + + *e = *f + } + if e.q == nil { + e.err, err = io.EOF, io.EOF + return + } + + if e.i >= e.q.c { + if err = e.next(); err != nil { + return + } + } + + i := e.q.xd[e.i] + k, v = i.k, int64(i.v) + e.k, e.hit = k, false + e.next() + return +} + +func (e *xenumerator) next() error { + if e.q == nil { + e.err = io.EOF + return io.EOF + } + + switch { + case e.i < e.q.c-1: + e.i++ + default: + if e.q, e.i = e.q.n, 0; e.q == nil { + e.err = io.EOF + } + } + return e.err +} + +// Prev returns the currently enumerated item, if it exists and moves to the +// previous item in the key collation order. If there is no item to return, err +// == io.EOF is returned. +func (e *xenumerator) Prev() (k indexKey, v int64, err error) { + if err = e.err; err != nil { + return + } + + if e.ver != e.t.ver { + f, hit := e.t.Seek(e.k) + if !e.hit && hit { + if err = f.prev(); err != nil { + return + } + } + + *e = *f + } + if e.q == nil { + e.err, err = io.EOF, io.EOF + return + } + + if e.i >= e.q.c { + if err = e.next(); err != nil { + return + } + } + + i := e.q.xd[e.i] + k, v = i.k, int64(i.v) + e.k, e.hit = k, false + e.prev() + return +} + +func (e *xenumerator) prev() error { + if e.q == nil { + e.err = io.EOF + return io.EOF + } + + switch { + case e.i > 0: + e.i-- + default: + if e.q = e.q.p; e.q == nil { + e.err = io.EOF + break + } + + e.i = e.q.c - 1 + } + return e.err +} diff --git a/vendor/github.com/cznic/ql/parser.go b/vendor/github.com/cznic/ql/parser.go new file mode 100644 index 0000000000..1fb6e04a54 --- /dev/null +++ b/vendor/github.com/cznic/ql/parser.go @@ -0,0 +1,2637 @@ +// CAUTION: Generated file - DO NOT EDIT. + +// Copyright (c) 2014 The ql Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Inital yacc source generated by ebnf2y[1] +// at 2013-10-04 23:10:47.861401015 +0200 CEST +// +// $ ebnf2y -o ql.y -oe ql.ebnf -start StatementList -pkg ql -p _ +// +// [1]: http://github.com/cznic/ebnf2y + +package ql + +import __yyfmt__ "fmt" + +import ( + "fmt" + + "github.com/cznic/mathutil" +) + +type yySymType struct { + yys int + line int + col int + item interface{} + list []interface{} +} + +type yyXError struct { + state, xsym int +} + +const ( + yyDefault = 57437 + yyEOFCode = 57344 + add = 57352 + alter = 57353 + and = 57354 + andand = 57355 + andnot = 57356 + as = 57357 + asc = 57358 + begin = 57359 + between = 57360 + bigIntType = 57361 + bigRatType = 57362 + blobType = 57363 + boolType = 57364 + by = 57365 + byteType = 57366 + column = 57367 + commit = 57368 + complex128Type = 57369 + complex64Type = 57370 + create = 57371 + defaultKwd = 57372 + deleteKwd = 57373 + desc = 57374 + distinct = 57375 + drop = 57376 + durationType = 57377 + eq = 57378 + yyErrCode = 57345 + exists = 57379 + explain = 57380 + falseKwd = 57381 + float32Type = 57383 + float64Type = 57384 + floatLit = 57346 + floatType = 57382 + from = 57385 + full = 57386 + ge = 57387 + group = 57388 + identifier = 57347 + ifKwd = 57389 + imaginaryLit = 57348 + in = 57390 + index = 57391 + insert = 57392 + int16Type = 57394 + int32Type = 57395 + int64Type = 57396 + int8Type = 57397 + intLit = 57349 + intType = 57393 + into = 57398 + is = 57399 + join = 57400 + le = 57401 + left = 57402 + like = 57403 + limit = 57404 + lsh = 57405 + neq = 57406 + not = 57407 + null = 57408 + offset = 57409 + on = 57410 + or = 57411 + order = 57412 + oror = 57413 + outer = 57414 + parseExpression = 57436 + qlParam = 57350 + right = 57415 + rollback = 57416 + rsh = 57417 + runeType = 57418 + selectKwd = 57419 + set = 57420 + stringLit = 57351 + stringType = 57421 + tableKwd = 57422 + timeType = 57423 + transaction = 57424 + trueKwd = 57425 + truncate = 57426 + uint16Type = 57428 + uint32Type = 57429 + uint64Type = 57430 + uint8Type = 57431 + uintType = 57427 + unique = 57432 + update = 57433 + values = 57434 + where = 57435 + + yyMaxDepth = 200 + yyTabOfs = -216 +) + +var ( + yyXLAT = map[int]int{ + 59: 0, // ';' (192x) + 57344: 1, // $end (191x) + 41: 2, // ')' (164x) + 43: 3, // '+' (133x) + 45: 4, // '-' (133x) + 94: 5, // '^' (133x) + 44: 6, // ',' (130x) + 40: 7, // '(' (125x) + 57347: 8, // identifier (116x) + 57409: 9, // offset (103x) + 57404: 10, // limit (101x) + 57372: 11, // defaultKwd (94x) + 57412: 12, // order (90x) + 57435: 13, // where (87x) + 57408: 14, // null (84x) + 57361: 15, // bigIntType (83x) + 57362: 16, // bigRatType (83x) + 57363: 17, // blobType (83x) + 57364: 18, // boolType (83x) + 57366: 19, // byteType (83x) + 57369: 20, // complex128Type (83x) + 57370: 21, // complex64Type (83x) + 57377: 22, // durationType (83x) + 57383: 23, // float32Type (83x) + 57384: 24, // float64Type (83x) + 57382: 25, // floatType (83x) + 57394: 26, // int16Type (83x) + 57395: 27, // int32Type (83x) + 57396: 28, // int64Type (83x) + 57397: 29, // int8Type (83x) + 57393: 30, // intType (83x) + 57418: 31, // runeType (83x) + 57421: 32, // stringType (83x) + 57423: 33, // timeType (83x) + 57428: 34, // uint16Type (83x) + 57429: 35, // uint32Type (83x) + 57430: 36, // uint64Type (83x) + 57431: 37, // uint8Type (83x) + 57427: 38, // uintType (83x) + 57381: 39, // falseKwd (81x) + 57346: 40, // floatLit (81x) + 57388: 41, // group (81x) + 57348: 42, // imaginaryLit (81x) + 57349: 43, // intLit (81x) + 57407: 44, // not (81x) + 57411: 45, // or (81x) + 57413: 46, // oror (81x) + 57350: 47, // qlParam (81x) + 57351: 48, // stringLit (81x) + 57425: 49, // trueKwd (81x) + 33: 50, // '!' (77x) + 57385: 51, // from (75x) + 57358: 52, // asc (71x) + 57374: 53, // desc (71x) + 93: 54, // ']' (70x) + 57357: 55, // as (69x) + 58: 56, // ':' (67x) + 57354: 57, // and (67x) + 57355: 58, // andand (65x) + 124: 59, // '|' (56x) + 57360: 60, // between (54x) + 57390: 61, // in (54x) + 60: 62, // '<' (53x) + 62: 63, // '>' (53x) + 57378: 64, // eq (53x) + 57387: 65, // ge (53x) + 57399: 66, // is (53x) + 57401: 67, // le (53x) + 57403: 68, // like (53x) + 57406: 69, // neq (53x) + 57513: 70, // Type (52x) + 57453: 71, // Conversion (51x) + 57483: 72, // Literal (51x) + 57484: 73, // Operand (51x) + 57488: 74, // PrimaryExpression (51x) + 57491: 75, // QualifiedIdent (51x) + 42: 76, // '*' (48x) + 57514: 77, // UnaryExpr (47x) + 37: 78, // '%' (44x) + 38: 79, // '&' (44x) + 47: 80, // '/' (44x) + 57356: 81, // andnot (44x) + 57405: 82, // lsh (44x) + 57417: 83, // rsh (44x) + 57490: 84, // PrimaryTerm (40x) + 57489: 85, // PrimaryFactor (36x) + 91: 86, // '[' (31x) + 57470: 87, // Factor (25x) + 57471: 88, // Factor1 (25x) + 57511: 89, // Term (24x) + 57467: 90, // Expression (23x) + 57519: 91, // logOr (16x) + 57446: 92, // ColumnName (10x) + 57386: 93, // full (10x) + 57402: 94, // left (10x) + 57415: 95, // right (10x) + 57419: 96, // selectKwd (10x) + 57510: 97, // TableName (9x) + 57449: 98, // CommaOpt (7x) + 57468: 99, // ExpressionList (7x) + 57410: 100, // on (7x) + 57497: 101, // SelectStmt (7x) + 57400: 102, // join (6x) + 57443: 103, // Call (5x) + 57376: 104, // drop (5x) + 57476: 105, // Index (5x) + 57506: 106, // Slice (5x) + 57445: 107, // ColumnDef (4x) + 57379: 108, // exists (4x) + 57389: 109, // ifKwd (4x) + 57391: 110, // index (4x) + 57414: 111, // outer (4x) + 57422: 112, // tableKwd (4x) + 57434: 113, // values (4x) + 57353: 114, // alter (3x) + 57438: 115, // AlterTableStmt (3x) + 57359: 116, // begin (3x) + 57442: 117, // BeginTransactionStmt (3x) + 57368: 118, // commit (3x) + 57450: 119, // CommitStmt (3x) + 57371: 120, // create (3x) + 57455: 121, // CreateIndexStmt (3x) + 57457: 122, // CreateTableStmt (3x) + 57461: 123, // DeleteFromStmt (3x) + 57373: 124, // deleteKwd (3x) + 57463: 125, // DropIndexStmt (3x) + 57464: 126, // DropTableStmt (3x) + 57465: 127, // EmptyStmt (3x) + 57380: 128, // explain (3x) + 57466: 129, // ExplainStmt (3x) + 57392: 130, // insert (3x) + 57477: 131, // InsertIntoStmt (3x) + 57492: 132, // RecordSet (3x) + 57493: 133, // RecordSet1 (3x) + 57416: 134, // rollback (3x) + 57496: 135, // RollbackStmt (3x) + 57520: 136, // semiOpt (3x) + 57508: 137, // Statement (3x) + 57426: 138, // truncate (3x) + 57512: 139, // TruncateTableStmt (3x) + 57433: 140, // update (3x) + 57515: 141, // UpdateStmt (3x) + 57517: 142, // WhereClause (3x) + 61: 143, // '=' (2x) + 57352: 144, // add (2x) + 57439: 145, // Assignment (2x) + 57365: 146, // by (2x) + 57447: 147, // ColumnNameList (2x) + 57458: 148, // CreateTableStmt1 (2x) + 57472: 149, // Field (2x) + 57518: 150, // logAnd (2x) + 57420: 151, // set (2x) + 46: 152, // '.' (1x) + 57440: 153, // AssignmentList (1x) + 57441: 154, // AssignmentList1 (1x) + 57444: 155, // Call1 (1x) + 57367: 156, // column (1x) + 57448: 157, // ColumnNameList1 (1x) + 57451: 158, // Constraint (1x) + 57452: 159, // ConstraintOpt (1x) + 57454: 160, // CreateIndexIfNotExists (1x) + 57456: 161, // CreateIndexStmtUnique (1x) + 57459: 162, // Default (1x) + 57460: 163, // DefaultOpt (1x) + 57375: 164, // distinct (1x) + 57462: 165, // DropIndexIfExists (1x) + 57469: 166, // ExpressionList1 (1x) + 57473: 167, // Field1 (1x) + 57474: 168, // FieldList (1x) + 57475: 169, // GroupByClause (1x) + 57478: 170, // InsertIntoStmt1 (1x) + 57479: 171, // InsertIntoStmt2 (1x) + 57398: 172, // into (1x) + 57480: 173, // JoinClause (1x) + 57481: 174, // JoinClauseOpt (1x) + 57482: 175, // JoinType (1x) + 57485: 176, // OrderBy (1x) + 57486: 177, // OrderBy1 (1x) + 57487: 178, // OuterOpt (1x) + 57436: 179, // parseExpression (1x) + 57494: 180, // RecordSet2 (1x) + 57495: 181, // RecordSetList (1x) + 57498: 182, // SelectStmtDistinct (1x) + 57499: 183, // SelectStmtFieldList (1x) + 57500: 184, // SelectStmtGroup (1x) + 57501: 185, // SelectStmtLimit (1x) + 57502: 186, // SelectStmtOffset (1x) + 57503: 187, // SelectStmtOrder (1x) + 57504: 188, // SelectStmtWhere (1x) + 57505: 189, // SetOpt (1x) + 57507: 190, // Start (1x) + 57509: 191, // StatementList (1x) + 57424: 192, // transaction (1x) + 57432: 193, // unique (1x) + 57516: 194, // UpdateStmt1 (1x) + 57437: 195, // $default (0x) + 57345: 196, // error (0x) + } + + yySymNames = []string{ + "';'", + "$end", + "')'", + "'+'", + "'-'", + "'^'", + "','", + "'('", + "identifier", + "offset", + "limit", + "defaultKwd", + "order", + "where", + "null", + "bigIntType", + "bigRatType", + "blobType", + "boolType", + "byteType", + "complex128Type", + "complex64Type", + "durationType", + "float32Type", + "float64Type", + "floatType", + "int16Type", + "int32Type", + "int64Type", + "int8Type", + "intType", + "runeType", + "stringType", + "timeType", + "uint16Type", + "uint32Type", + "uint64Type", + "uint8Type", + "uintType", + "falseKwd", + "floatLit", + "group", + "imaginaryLit", + "intLit", + "not", + "or", + "oror", + "qlParam", + "stringLit", + "trueKwd", + "'!'", + "from", + "asc", + "desc", + "']'", + "as", + "':'", + "and", + "andand", + "'|'", + "between", + "in", + "'<'", + "'>'", + "eq", + "ge", + "is", + "le", + "like", + "neq", + "Type", + "Conversion", + "Literal", + "Operand", + "PrimaryExpression", + "QualifiedIdent", + "'*'", + "UnaryExpr", + "'%'", + "'&'", + "'/'", + "andnot", + "lsh", + "rsh", + "PrimaryTerm", + "PrimaryFactor", + "'['", + "Factor", + "Factor1", + "Term", + "Expression", + "logOr", + "ColumnName", + "full", + "left", + "right", + "selectKwd", + "TableName", + "CommaOpt", + "ExpressionList", + "on", + "SelectStmt", + "join", + "Call", + "drop", + "Index", + "Slice", + "ColumnDef", + "exists", + "ifKwd", + "index", + "outer", + "tableKwd", + "values", + "alter", + "AlterTableStmt", + "begin", + "BeginTransactionStmt", + "commit", + "CommitStmt", + "create", + "CreateIndexStmt", + "CreateTableStmt", + "DeleteFromStmt", + "deleteKwd", + "DropIndexStmt", + "DropTableStmt", + "EmptyStmt", + "explain", + "ExplainStmt", + "insert", + "InsertIntoStmt", + "RecordSet", + "RecordSet1", + "rollback", + "RollbackStmt", + "semiOpt", + "Statement", + "truncate", + "TruncateTableStmt", + "update", + "UpdateStmt", + "WhereClause", + "'='", + "add", + "Assignment", + "by", + "ColumnNameList", + "CreateTableStmt1", + "Field", + "logAnd", + "set", + "'.'", + "AssignmentList", + "AssignmentList1", + "Call1", + "column", + "ColumnNameList1", + "Constraint", + "ConstraintOpt", + "CreateIndexIfNotExists", + "CreateIndexStmtUnique", + "Default", + "DefaultOpt", + "distinct", + "DropIndexIfExists", + "ExpressionList1", + "Field1", + "FieldList", + "GroupByClause", + "InsertIntoStmt1", + "InsertIntoStmt2", + "into", + "JoinClause", + "JoinClauseOpt", + "JoinType", + "OrderBy", + "OrderBy1", + "OuterOpt", + "parseExpression", + "RecordSet2", + "RecordSetList", + "SelectStmtDistinct", + "SelectStmtFieldList", + "SelectStmtGroup", + "SelectStmtLimit", + "SelectStmtOffset", + "SelectStmtOrder", + "SelectStmtWhere", + "SetOpt", + "Start", + "StatementList", + "transaction", + "unique", + "UpdateStmt1", + "$default", + "error", + } + + yyReductions = map[int]struct{ xsym, components int }{ + 0: {0, 1}, + 1: {190, 1}, + 2: {190, 2}, + 3: {115, 5}, + 4: {115, 6}, + 5: {145, 3}, + 6: {153, 3}, + 7: {154, 0}, + 8: {154, 3}, + 9: {117, 2}, + 10: {103, 3}, + 11: {103, 3}, + 12: {155, 0}, + 13: {155, 1}, + 14: {107, 4}, + 15: {92, 1}, + 16: {147, 3}, + 17: {157, 0}, + 18: {157, 3}, + 19: {119, 1}, + 20: {158, 2}, + 21: {158, 1}, + 22: {159, 0}, + 23: {159, 1}, + 24: {71, 4}, + 25: {121, 10}, + 26: {160, 0}, + 27: {160, 3}, + 28: {161, 0}, + 29: {161, 1}, + 30: {122, 8}, + 31: {122, 11}, + 32: {148, 0}, + 33: {148, 3}, + 34: {162, 2}, + 35: {163, 0}, + 36: {163, 1}, + 37: {123, 3}, + 38: {123, 4}, + 39: {125, 4}, + 40: {165, 0}, + 41: {165, 2}, + 42: {126, 3}, + 43: {126, 5}, + 44: {127, 0}, + 45: {129, 2}, + 46: {90, 1}, + 47: {90, 3}, + 48: {91, 1}, + 49: {91, 1}, + 50: {99, 3}, + 51: {166, 0}, + 52: {166, 3}, + 53: {87, 1}, + 54: {87, 5}, + 55: {87, 6}, + 56: {87, 6}, + 57: {87, 7}, + 58: {87, 5}, + 59: {87, 6}, + 60: {87, 3}, + 61: {87, 4}, + 62: {88, 1}, + 63: {88, 3}, + 64: {88, 3}, + 65: {88, 3}, + 66: {88, 3}, + 67: {88, 3}, + 68: {88, 3}, + 69: {88, 3}, + 70: {149, 2}, + 71: {167, 0}, + 72: {167, 2}, + 73: {168, 1}, + 74: {168, 3}, + 75: {169, 3}, + 76: {105, 3}, + 77: {131, 10}, + 78: {131, 5}, + 79: {170, 0}, + 80: {170, 3}, + 81: {171, 0}, + 82: {171, 5}, + 83: {72, 1}, + 84: {72, 1}, + 85: {72, 1}, + 86: {72, 1}, + 87: {72, 1}, + 88: {72, 1}, + 89: {72, 1}, + 90: {73, 1}, + 91: {73, 1}, + 92: {73, 1}, + 93: {73, 3}, + 94: {176, 4}, + 95: {177, 0}, + 96: {177, 1}, + 97: {177, 1}, + 98: {74, 1}, + 99: {74, 1}, + 100: {74, 2}, + 101: {74, 2}, + 102: {74, 2}, + 103: {85, 1}, + 104: {85, 3}, + 105: {85, 3}, + 106: {85, 3}, + 107: {85, 3}, + 108: {84, 1}, + 109: {84, 3}, + 110: {84, 3}, + 111: {84, 3}, + 112: {84, 3}, + 113: {84, 3}, + 114: {84, 3}, + 115: {84, 3}, + 116: {75, 1}, + 117: {75, 3}, + 118: {132, 2}, + 119: {133, 1}, + 120: {133, 4}, + 121: {136, 0}, + 122: {136, 1}, + 123: {180, 0}, + 124: {180, 2}, + 125: {181, 1}, + 126: {181, 3}, + 127: {135, 1}, + 128: {175, 1}, + 129: {175, 1}, + 130: {175, 1}, + 131: {178, 0}, + 132: {178, 1}, + 133: {173, 6}, + 134: {174, 0}, + 135: {174, 1}, + 136: {101, 12}, + 137: {185, 0}, + 138: {185, 2}, + 139: {186, 0}, + 140: {186, 2}, + 141: {182, 0}, + 142: {182, 1}, + 143: {183, 1}, + 144: {183, 1}, + 145: {183, 2}, + 146: {188, 0}, + 147: {188, 1}, + 148: {184, 0}, + 149: {184, 1}, + 150: {187, 0}, + 151: {187, 1}, + 152: {106, 3}, + 153: {106, 4}, + 154: {106, 4}, + 155: {106, 5}, + 156: {137, 1}, + 157: {137, 1}, + 158: {137, 1}, + 159: {137, 1}, + 160: {137, 1}, + 161: {137, 1}, + 162: {137, 1}, + 163: {137, 1}, + 164: {137, 1}, + 165: {137, 1}, + 166: {137, 1}, + 167: {137, 1}, + 168: {137, 1}, + 169: {137, 1}, + 170: {137, 1}, + 171: {191, 1}, + 172: {191, 3}, + 173: {97, 1}, + 174: {89, 1}, + 175: {89, 3}, + 176: {150, 1}, + 177: {150, 1}, + 178: {139, 3}, + 179: {70, 1}, + 180: {70, 1}, + 181: {70, 1}, + 182: {70, 1}, + 183: {70, 1}, + 184: {70, 1}, + 185: {70, 1}, + 186: {70, 1}, + 187: {70, 1}, + 188: {70, 1}, + 189: {70, 1}, + 190: {70, 1}, + 191: {70, 1}, + 192: {70, 1}, + 193: {70, 1}, + 194: {70, 1}, + 195: {70, 1}, + 196: {70, 1}, + 197: {70, 1}, + 198: {70, 1}, + 199: {70, 1}, + 200: {70, 1}, + 201: {70, 1}, + 202: {70, 1}, + 203: {141, 5}, + 204: {194, 0}, + 205: {194, 1}, + 206: {77, 1}, + 207: {77, 2}, + 208: {77, 2}, + 209: {77, 2}, + 210: {77, 2}, + 211: {142, 2}, + 212: {189, 0}, + 213: {189, 1}, + 214: {98, 0}, + 215: {98, 1}, + } + + yyXErrors = map[yyXError]string{ + yyXError{1, -1}: "expected $end", + yyXError{43, -1}: "expected '('", + yyXError{157, -1}: "expected '('", + yyXError{181, -1}: "expected '('", + yyXError{281, -1}: "expected '('", + yyXError{309, -1}: "expected '('", + yyXError{313, -1}: "expected '('", + yyXError{344, -1}: "expected '('", + yyXError{118, -1}: "expected ')'", + yyXError{119, -1}: "expected ')'", + yyXError{120, -1}: "expected ')'", + yyXError{187, -1}: "expected ')'", + yyXError{189, -1}: "expected ')'", + yyXError{190, -1}: "expected ')'", + yyXError{194, -1}: "expected ')'", + yyXError{196, -1}: "expected ')'", + yyXError{265, -1}: "expected ')'", + yyXError{279, -1}: "expected ')'", + yyXError{284, -1}: "expected ')'", + yyXError{290, -1}: "expected ')'", + yyXError{318, -1}: "expected ')'", + yyXError{335, -1}: "expected ')'", + yyXError{346, -1}: "expected ')'", + yyXError{36, -1}: "expected '='", + yyXError{233, -1}: "expected BY", + yyXError{236, -1}: "expected BY", + yyXError{352, -1}: "expected COLUMN", + yyXError{7, -1}: "expected CREATE INDEX optional UNIQUE clause or one of [INDEX, TABLE, UNIQUE]", + yyXError{337, -1}: "expected CREATE INDEX statement optional IF NOT EXISTS cluse or one of [IF, identifier]", + yyXError{316, -1}: "expected CREATE TABLE statement colum definition list or optional comma or one of [')', ',']", + yyXError{333, -1}: "expected CREATE TABLE statement colum definition list or optional comma or one of [')', ',']", + yyXError{293, -1}: "expected DROP INDEX statement optional IF EXISTS clause or one of [IF, identifier]", + yyXError{296, -1}: "expected EXISTS", + yyXError{300, -1}: "expected EXISTS", + yyXError{311, -1}: "expected EXISTS", + yyXError{340, -1}: "expected EXISTS", + yyXError{8, -1}: "expected FROM", + yyXError{215, -1}: "expected FROM", + yyXError{216, -1}: "expected FROM", + yyXError{306, -1}: "expected INDEX", + yyXError{307, -1}: "expected INDEX", + yyXError{276, -1}: "expected INSERT INTO statement optional column list clause or SELECT statement or one of ['(', SELECT, VALUES]", + yyXError{285, -1}: "expected INSERT INTO statement optional values list or optional comma or one of [$end, ',', ';']", + yyXError{11, -1}: "expected INTO", + yyXError{257, -1}: "expected JOIN", + yyXError{258, -1}: "expected JOIN", + yyXError{310, -1}: "expected NOT", + yyXError{339, -1}: "expected NOT", + yyXError{176, -1}: "expected NULL", + yyXError{324, -1}: "expected NULL", + yyXError{260, -1}: "expected ON", + yyXError{342, -1}: "expected ON", + yyXError{246, -1}: "expected ORDER BY clause optional collation specification or one of [$end, ')', ';', ASC, DESC, LIMIT, OFFSET]", + yyXError{217, -1}: "expected RecordSetList or one of ['(', identifier]", + yyXError{13, -1}: "expected SELECT statement field list or SELECT statement optional DISTINCT clause or one of ['!', '(', '*', '+', '-', '^', DISTINCT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{210, -1}: "expected SELECT statement field list or one of ['!', '(', '*', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{224, -1}: "expected SELECT statement optional GROUP BY clause or SELECT statement optional JOIN clause or SELECT statement optional LIMIT clause or SELECT statement optional OFFSET clause or SELECT statement optional ORDER BY clause or SELECT statement optional WHERE clause or one of [$end, ')', ';', FULL, GROUP, LEFT, LIMIT, OFFSET, ORDER, RIGHT, WHERE]", + yyXError{222, -1}: "expected SELECT statement optional GROUP BY clause or SELECT statement optional JOIN clause or SELECT statement optional LIMIT clause or SELECT statement optional OFFSET clause or SELECT statement optional ORDER BY clause or SELECT statement optional WHERE clause or optional comma or one of [$end, ')', ',', ';', FULL, GROUP, LEFT, LIMIT, OFFSET, ORDER, RIGHT, WHERE]", + yyXError{230, -1}: "expected SELECT statement optional GROUP BY clause or SELECT statement optional LIMIT clause or SELECT statement optional OFFSET clause or SELECT statement optional ORDER BY clause or SELECT statement optional WHERE clause or one of [$end, ')', ';', GROUP, LIMIT, OFFSET, ORDER, WHERE]", + yyXError{231, -1}: "expected SELECT statement optional GROUP BY clause or SELECT statement optional LIMIT clause or SELECT statement optional OFFSET clause or SELECT statement optional ORDER BY clause or one of [$end, ')', ';', GROUP, LIMIT, OFFSET, ORDER]", + yyXError{234, -1}: "expected SELECT statement optional LIMIT clause or SELECT statement optional OFFSET clause or SELECT statement optional ORDER BY clause or one of [$end, ')', ';', LIMIT, OFFSET, ORDER]", + yyXError{237, -1}: "expected SELECT statement optional LIMIT clause or SELECT statement optional OFFSET clause or one of [$end, ')', ';', LIMIT, OFFSET]", + yyXError{239, -1}: "expected SELECT statement optional OFFSET clause or one of [$end, ')', ';', OFFSET]", + yyXError{220, -1}: "expected SELECT statement or SELECT", + yyXError{186, -1}: "expected SELECT statement or expression list or one of ['!', '(', '+', '-', '^', NULL, QL parameter, SELECT, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{193, -1}: "expected SELECT statement or expression list or one of ['!', '(', '+', '-', '^', NULL, QL parameter, SELECT, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{277, -1}: "expected SELECT statement or one of [SELECT, VALUES]", + yyXError{33, -1}: "expected SetOpt or assignment list or one of [SET, identifier]", + yyXError{0, -1}: "expected Start or one of [$end, ';', ALTER, BEGIN, COMMIT, CREATE, DELETE, DROP, EXPLAIN, INSERT, ROLLBACK, SELECT, TRUNCATE, UPDATE, parse expression prefix]", + yyXError{4, -1}: "expected TABLE", + yyXError{30, -1}: "expected TABLE", + yyXError{5, -1}: "expected TRANSACTION", + yyXError{39, -1}: "expected UPDATE statement optional WHERE clause or one of [$end, ';', WHERE]", + yyXError{304, -1}: "expected WHERE clause or one of [$end, ';', WHERE]", + yyXError{37, -1}: "expected assignment list optional trailing comma or optional comma or one of [$end, ',', ';', WHERE]", + yyXError{34, -1}: "expected assignment list or identifier", + yyXError{204, -1}: "expected assignment or one of [$end, ';', WHERE, identifier]", + yyXError{250, -1}: "expected column name list or identifier", + yyXError{278, -1}: "expected column name list or identifier", + yyXError{251, -1}: "expected column name list with optional trailing comma or optional comma or one of [$end, ')', ',', ';', LIMIT, OFFSET, ORDER]", + yyXError{353, -1}: "expected column name or identifier", + yyXError{255, -1}: "expected column name or one of [$end, ')', ';', LIMIT, OFFSET, ORDER, identifier]", + yyXError{109, -1}: "expected expression factor or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{121, -1}: "expected expression list expression or logical or operator or optional comma or one of [$end, ')', ',', ';', ASC, DESC, LIMIT, OFFSET, OR, ||]", + yyXError{245, -1}: "expected expression list or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{283, -1}: "expected expression list or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{289, -1}: "expected expression list or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{345, -1}: "expected expression list or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{124, -1}: "expected expression or one of [$end, '!', '(', ')', '+', '-', ';', '^', ASC, DESC, LIMIT, NULL, OFFSET, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{96, -1}: "expected expression or one of ['!', '(', '+', '-', ':', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{101, -1}: "expected expression or one of ['!', '(', '+', '-', ']', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{114, -1}: "expected expression or one of ['!', '(', '+', '-', ']', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{3, -1}: "expected expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{42, -1}: "expected expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{58, -1}: "expected expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{199, -1}: "expected expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{206, -1}: "expected expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{240, -1}: "expected expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{243, -1}: "expected expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{261, -1}: "expected expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{329, -1}: "expected expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{104, -1}: "expected expression term or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{212, -1}: "expected field expression optional AS clause or logical or operator or one of [',', AS, FROM, OR, ||]", + yyXError{270, -1}: "expected field expression or one of ['!', '(', '+', '-', '^', FROM, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{95, -1}: "expected function call optional argument list or one of ['!', '(', ')', '*', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{61, -1}: "expected function call or string index or string slice or one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{94, -1}: "expected function call or string index or string slice or one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{128, -1}: "expected function call or string index or string slice or one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{129, -1}: "expected function call or string index or string slice or one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{130, -1}: "expected function call or string index or string slice or one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{35, -1}: "expected identifier", + yyXError{131, -1}: "expected identifier", + yyXError{268, -1}: "expected identifier", + yyXError{273, -1}: "expected identifier", + yyXError{299, -1}: "expected identifier", + yyXError{301, -1}: "expected identifier", + yyXError{338, -1}: "expected identifier", + yyXError{341, -1}: "expected identifier", + yyXError{343, -1}: "expected identifier", + yyXError{44, -1}: "expected logical and operator or one of [$end, &&, ')', ',', ':', ';', ']', AND, AS, ASC, DEFAULT, DESC, FROM, GROUP, LIMIT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{108, -1}: "expected logical and operator or one of [$end, &&, ')', ',', ':', ';', ']', AND, AS, ASC, DEFAULT, DESC, FROM, GROUP, LIMIT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{125, -1}: "expected logical or operator or one of [$end, ')', ',', ';', ASC, DESC, LIMIT, OFFSET, OR, ||]", + yyXError{325, -1}: "expected logical or operator or one of [$end, ')', ',', ';', DEFAULT, OR, ||]", + yyXError{331, -1}: "expected logical or operator or one of [$end, ')', ',', ';', OR, ||]", + yyXError{262, -1}: "expected logical or operator or one of [$end, ')', ';', GROUP, LIMIT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{45, -1}: "expected logical or operator or one of [$end, ')', ';', GROUP, LIMIT, OFFSET, OR, ORDER, ||]", + yyXError{241, -1}: "expected logical or operator or one of [$end, ')', ';', OFFSET, OR, ||]", + yyXError{244, -1}: "expected logical or operator or one of [$end, ')', ';', OR, ||]", + yyXError{207, -1}: "expected logical or operator or one of [$end, ',', ';', OR, WHERE, ||]", + yyXError{356, -1}: "expected logical or operator or one of [$end, OR, ||]", + yyXError{147, -1}: "expected logical or operator or one of [')', OR, ||]", + yyXError{200, -1}: "expected logical or operator or one of [')', OR, ||]", + yyXError{100, -1}: "expected logical or operator or one of [':', ']', OR, ||]", + yyXError{102, -1}: "expected logical or operator or one of [']', OR, ||]", + yyXError{115, -1}: "expected logical or operator or one of [']', OR, ||]", + yyXError{64, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{48, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{49, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{50, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{51, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{52, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{53, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{54, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{55, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{56, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{57, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{59, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{60, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{97, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{98, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{99, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{103, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{107, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{113, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{116, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{117, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{126, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{127, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{132, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{148, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{201, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{62, -1}: "expected one of [!=, $end, &&, &^, '%', '&', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{63, -1}: "expected one of [!=, $end, &&, &^, '%', '&', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{140, -1}: "expected one of [!=, $end, &&, &^, '%', '&', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{141, -1}: "expected one of [!=, $end, &&, &^, '%', '&', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{142, -1}: "expected one of [!=, $end, &&, &^, '%', '&', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{143, -1}: "expected one of [!=, $end, &&, &^, '%', '&', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{144, -1}: "expected one of [!=, $end, &&, &^, '%', '&', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{145, -1}: "expected one of [!=, $end, &&, &^, '%', '&', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{146, -1}: "expected one of [!=, $end, &&, &^, '%', '&', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{153, -1}: "expected one of [!=, $end, &&, &^, '%', '&', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{154, -1}: "expected one of [!=, $end, &&, &^, '%', '&', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{155, -1}: "expected one of [!=, $end, &&, &^, '%', '&', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{156, -1}: "expected one of [!=, $end, &&, &^, '%', '&', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{47, -1}: "expected one of [!=, $end, &&, ')', '+', ',', '-', ':', ';', '<', '>', ']', '^', '|', <=, ==, >=, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{168, -1}: "expected one of [!=, $end, &&, ')', '+', ',', '-', ':', ';', '<', '>', ']', '^', '|', <=, ==, >=, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{169, -1}: "expected one of [!=, $end, &&, ')', '+', ',', '-', ':', ';', '<', '>', ']', '^', '|', <=, ==, >=, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{170, -1}: "expected one of [!=, $end, &&, ')', '+', ',', '-', ':', ';', '<', '>', ']', '^', '|', <=, ==, >=, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{171, -1}: "expected one of [!=, $end, &&, ')', '+', ',', '-', ':', ';', '<', '>', ']', '^', '|', <=, ==, >=, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{172, -1}: "expected one of [!=, $end, &&, ')', '+', ',', '-', ':', ';', '<', '>', ']', '^', '|', <=, ==, >=, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{173, -1}: "expected one of [!=, $end, &&, ')', '+', ',', '-', ':', ';', '<', '>', ']', '^', '|', <=, ==, >=, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{174, -1}: "expected one of [!=, $end, &&, ')', '+', ',', '-', ':', ';', '<', '>', ']', '^', '|', <=, ==, >=, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{46, -1}: "expected one of [!=, $end, &&, ')', ',', ':', ';', '<', '>', ']', <=, ==, >=, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{180, -1}: "expected one of [$end, &&, ')', '+', ',', '-', ':', ';', ']', '^', '|', AND, AS, ASC, DEFAULT, DESC, FROM, GROUP, LIMIT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{185, -1}: "expected one of [$end, &&, ')', '+', ',', '-', ':', ';', ']', '^', '|', AND, AS, ASC, DEFAULT, DESC, FROM, GROUP, LIMIT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{65, -1}: "expected one of [$end, &&, ')', ',', ':', ';', ']', AND, AS, ASC, DEFAULT, DESC, FROM, GROUP, LIMIT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{112, -1}: "expected one of [$end, &&, ')', ',', ':', ';', ']', AND, AS, ASC, DEFAULT, DESC, FROM, GROUP, LIMIT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{175, -1}: "expected one of [$end, &&, ')', ',', ':', ';', ']', AND, AS, ASC, DEFAULT, DESC, FROM, GROUP, LIMIT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{177, -1}: "expected one of [$end, &&, ')', ',', ':', ';', ']', AND, AS, ASC, DEFAULT, DESC, FROM, GROUP, LIMIT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{191, -1}: "expected one of [$end, &&, ')', ',', ':', ';', ']', AND, AS, ASC, DEFAULT, DESC, FROM, GROUP, LIMIT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{192, -1}: "expected one of [$end, &&, ')', ',', ':', ';', ']', AND, AS, ASC, DEFAULT, DESC, FROM, GROUP, LIMIT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{197, -1}: "expected one of [$end, &&, ')', ',', ':', ';', ']', AND, AS, ASC, DEFAULT, DESC, FROM, GROUP, LIMIT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{198, -1}: "expected one of [$end, &&, ')', ',', ':', ';', ']', AND, AS, ASC, DEFAULT, DESC, FROM, GROUP, LIMIT, OFFSET, OR, ORDER, WHERE, ||]", + yyXError{66, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{67, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{68, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{69, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{70, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{71, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{72, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{73, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{74, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{75, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{76, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{77, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{78, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{79, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{80, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{81, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{82, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{83, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{84, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{85, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{86, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{87, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{88, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{89, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{32, -1}: "expected one of [$end, '(', ';', ADD, DROP, SELECT, SET, VALUES, WHERE, identifier]", + yyXError{288, -1}: "expected one of [$end, '(', ';']", + yyXError{38, -1}: "expected one of [$end, ')', ',', ';', '=', LIMIT, OFFSET, ORDER, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, float, float32, float64, int, int16, int32, int64, int8, rune, string, time, uint, uint16, uint32, uint64, uint8]", + yyXError{219, -1}: "expected one of [$end, ')', ',', ';', AS, FULL, GROUP, LEFT, LIMIT, OFFSET, ON, ORDER, RIGHT, WHERE]", + yyXError{266, -1}: "expected one of [$end, ')', ',', ';', AS, FULL, GROUP, LEFT, LIMIT, OFFSET, ON, ORDER, RIGHT, WHERE]", + yyXError{326, -1}: "expected one of [$end, ')', ',', ';', DEFAULT]", + yyXError{327, -1}: "expected one of [$end, ')', ',', ';', DEFAULT]", + yyXError{267, -1}: "expected one of [$end, ')', ',', ';', FULL, GROUP, LEFT, LIMIT, OFFSET, ON, ORDER, RIGHT, WHERE]", + yyXError{269, -1}: "expected one of [$end, ')', ',', ';', FULL, GROUP, LEFT, LIMIT, OFFSET, ON, ORDER, RIGHT, WHERE]", + yyXError{221, -1}: "expected one of [$end, ')', ',', ';', FULL, GROUP, LEFT, LIMIT, OFFSET, ORDER, RIGHT, WHERE]", + yyXError{263, -1}: "expected one of [$end, ')', ',', ';', FULL, GROUP, LEFT, LIMIT, OFFSET, ORDER, RIGHT, WHERE]", + yyXError{256, -1}: "expected one of [$end, ')', ',', ';', LIMIT, OFFSET, ORDER]", + yyXError{328, -1}: "expected one of [$end, ')', ',', ';']", + yyXError{330, -1}: "expected one of [$end, ')', ',', ';']", + yyXError{123, -1}: "expected one of [$end, ')', ';', ASC, DESC, LIMIT, OFFSET]", + yyXError{229, -1}: "expected one of [$end, ')', ';', GROUP, LIMIT, OFFSET, ORDER, WHERE]", + yyXError{232, -1}: "expected one of [$end, ')', ';', GROUP, LIMIT, OFFSET, ORDER]", + yyXError{235, -1}: "expected one of [$end, ')', ';', LIMIT, OFFSET, ORDER]", + yyXError{252, -1}: "expected one of [$end, ')', ';', LIMIT, OFFSET, ORDER]", + yyXError{254, -1}: "expected one of [$end, ')', ';', LIMIT, OFFSET, ORDER]", + yyXError{238, -1}: "expected one of [$end, ')', ';', LIMIT, OFFSET]", + yyXError{247, -1}: "expected one of [$end, ')', ';', LIMIT, OFFSET]", + yyXError{248, -1}: "expected one of [$end, ')', ';', LIMIT, OFFSET]", + yyXError{249, -1}: "expected one of [$end, ')', ';', LIMIT, OFFSET]", + yyXError{242, -1}: "expected one of [$end, ')', ';']", + yyXError{205, -1}: "expected one of [$end, ',', ';', WHERE]", + yyXError{291, -1}: "expected one of [$end, ',', ';']", + yyXError{203, -1}: "expected one of [$end, ';', WHERE]", + yyXError{2, -1}: "expected one of [$end, ';']", + yyXError{6, -1}: "expected one of [$end, ';']", + yyXError{12, -1}: "expected one of [$end, ';']", + yyXError{14, -1}: "expected one of [$end, ';']", + yyXError{15, -1}: "expected one of [$end, ';']", + yyXError{16, -1}: "expected one of [$end, ';']", + yyXError{17, -1}: "expected one of [$end, ';']", + yyXError{18, -1}: "expected one of [$end, ';']", + yyXError{19, -1}: "expected one of [$end, ';']", + yyXError{20, -1}: "expected one of [$end, ';']", + yyXError{21, -1}: "expected one of [$end, ';']", + yyXError{22, -1}: "expected one of [$end, ';']", + yyXError{23, -1}: "expected one of [$end, ';']", + yyXError{24, -1}: "expected one of [$end, ';']", + yyXError{25, -1}: "expected one of [$end, ';']", + yyXError{26, -1}: "expected one of [$end, ';']", + yyXError{27, -1}: "expected one of [$end, ';']", + yyXError{28, -1}: "expected one of [$end, ';']", + yyXError{29, -1}: "expected one of [$end, ';']", + yyXError{40, -1}: "expected one of [$end, ';']", + yyXError{41, -1}: "expected one of [$end, ';']", + yyXError{209, -1}: "expected one of [$end, ';']", + yyXError{282, -1}: "expected one of [$end, ';']", + yyXError{287, -1}: "expected one of [$end, ';']", + yyXError{292, -1}: "expected one of [$end, ';']", + yyXError{295, -1}: "expected one of [$end, ';']", + yyXError{298, -1}: "expected one of [$end, ';']", + yyXError{302, -1}: "expected one of [$end, ';']", + yyXError{305, -1}: "expected one of [$end, ';']", + yyXError{321, -1}: "expected one of [$end, ';']", + yyXError{336, -1}: "expected one of [$end, ';']", + yyXError{347, -1}: "expected one of [$end, ';']", + yyXError{348, -1}: "expected one of [$end, ';']", + yyXError{354, -1}: "expected one of [$end, ';']", + yyXError{355, -1}: "expected one of [$end, ';']", + yyXError{358, -1}: "expected one of [$end, ';']", + yyXError{211, -1}: "expected one of ['!', '(', '*', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{105, -1}: "expected one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{106, -1}: "expected one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{110, -1}: "expected one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{111, -1}: "expected one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{320, -1}: "expected one of [')', ',']", + yyXError{178, -1}: "expected one of ['+', '-', '^', '|', AND]", + yyXError{183, -1}: "expected one of ['+', '-', '^', '|', AND]", + yyXError{213, -1}: "expected one of [',', FROM]", + yyXError{214, -1}: "expected one of [',', FROM]", + yyXError{271, -1}: "expected one of [',', FROM]", + yyXError{272, -1}: "expected one of [',', FROM]", + yyXError{274, -1}: "expected one of [',', FROM]", + yyXError{350, -1}: "expected one of [ADD, DROP]", + yyXError{158, -1}: "expected one of [BETWEEN, IN]", + yyXError{9, -1}: "expected one of [INDEX, TABLE]", + yyXError{225, -1}: "expected one of [JOIN, OUTER]", + yyXError{226, -1}: "expected one of [JOIN, OUTER]", + yyXError{227, -1}: "expected one of [JOIN, OUTER]", + yyXError{160, -1}: "expected one of [NOT, NULL]", + yyXError{280, -1}: "expected one of [SELECT, VALUES]", + yyXError{323, -1}: "expected optional DEFAULT clause or one of [$end, ')', ',', ';', DEFAULT]", + yyXError{322, -1}: "expected optional DEFAULT clause or optional column value constraint or one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{228, -1}: "expected optional OUTER clause or one of [JOIN, OUTER]", + yyXError{122, -1}: "expected optional comma or one of [$end, ')', ',', ';', ASC, DESC, LIMIT, OFFSET]", + yyXError{253, -1}: "expected optional comma or one of [$end, ')', ',', ';', LIMIT, OFFSET, ORDER]", + yyXError{202, -1}: "expected optional comma or one of [$end, ',', ';', WHERE]", + yyXError{286, -1}: "expected optional comma or one of [$end, ',', ';']", + yyXError{317, -1}: "expected optional comma or one of [')', ',']", + yyXError{334, -1}: "expected optional comma or one of [')', ',']", + yyXError{159, -1}: "expected primary expression factor or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{161, -1}: "expected primary expression factor or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{162, -1}: "expected primary expression factor or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{163, -1}: "expected primary expression factor or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{164, -1}: "expected primary expression factor or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{165, -1}: "expected primary expression factor or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{166, -1}: "expected primary expression factor or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{167, -1}: "expected primary expression factor or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{179, -1}: "expected primary expression factor or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{182, -1}: "expected primary expression factor or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{184, -1}: "expected primary expression factor or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{90, -1}: "expected primary expression or one of ['(', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{91, -1}: "expected primary expression or one of ['(', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{92, -1}: "expected primary expression or one of ['(', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{93, -1}: "expected primary expression or one of ['(', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{149, -1}: "expected primary expression term or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{150, -1}: "expected primary expression term or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{151, -1}: "expected primary expression term or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{152, -1}: "expected primary expression term or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{218, -1}: "expected record set optional AS clause or one of [$end, ')', ',', ';', AS, FULL, GROUP, LEFT, LIMIT, OFFSET, ON, ORDER, RIGHT, WHERE]", + yyXError{223, -1}: "expected record set or one of [$end, '(', ')', ';', FULL, GROUP, LEFT, LIMIT, OFFSET, ORDER, RIGHT, WHERE, identifier]", + yyXError{259, -1}: "expected record set or one of ['(', identifier]", + yyXError{188, -1}: "expected semiOpt or one of [')', ';']", + yyXError{195, -1}: "expected semiOpt or one of [')', ';']", + yyXError{264, -1}: "expected semiOpt or one of [')', ';']", + yyXError{10, -1}: "expected statement or one of [$end, ';', ALTER, BEGIN, COMMIT, CREATE, DELETE, DROP, EXPLAIN, INSERT, ROLLBACK, SELECT, TRUNCATE, UPDATE]", + yyXError{357, -1}: "expected statement or one of [$end, ';', ALTER, BEGIN, COMMIT, CREATE, DELETE, DROP, EXPLAIN, INSERT, ROLLBACK, SELECT, TRUNCATE, UPDATE]", + yyXError{314, -1}: "expected table column definition or identifier", + yyXError{332, -1}: "expected table column definition or identifier", + yyXError{351, -1}: "expected table column definition or identifier", + yyXError{319, -1}: "expected table column definition or one of [')', identifier]", + yyXError{31, -1}: "expected table name or identifier", + yyXError{208, -1}: "expected table name or identifier", + yyXError{275, -1}: "expected table name or identifier", + yyXError{297, -1}: "expected table name or identifier", + yyXError{303, -1}: "expected table name or identifier", + yyXError{312, -1}: "expected table name or identifier", + yyXError{349, -1}: "expected table name or identifier", + yyXError{294, -1}: "expected table name or one of [IF, identifier]", + yyXError{308, -1}: "expected table name or one of [IF, identifier]", + yyXError{315, -1}: "expected type or one of [bigint, bigrat, blob, bool, byte, complex128, complex64, duration, float, float32, float64, int, int16, int32, int64, int8, rune, string, time, uint, uint16, uint32, uint64, uint8]", + yyXError{133, -1}: "expected unary expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{134, -1}: "expected unary expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{135, -1}: "expected unary expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{136, -1}: "expected unary expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{137, -1}: "expected unary expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{138, -1}: "expected unary expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + yyXError{139, -1}: "expected unary expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", + } + + yyParseTab = [359][]uint16{ + // 0 + {172, 172, 96: 229, 101: 242, 104: 225, 114: 220, 231, 221, 232, 222, 233, 223, 234, 235, 236, 224, 237, 238, 230, 226, 239, 227, 240, 134: 228, 241, 137: 245, 246, 243, 247, 244, 179: 219, 190: 217, 218}, + {1: 216}, + {573, 215}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 572}, + {112: 565}, + // 5 + {192: 564}, + {197, 197}, + {110: 188, 112: 524, 161: 522, 193: 523}, + {51: 519}, + {110: 509, 112: 510}, + // 10 + {172, 172, 96: 229, 101: 242, 104: 225, 114: 220, 231, 221, 232, 222, 233, 223, 234, 235, 236, 224, 237, 238, 230, 226, 239, 227, 240, 134: 228, 241, 137: 508, 246, 243, 247, 244}, + {172: 491}, + {89, 89}, + {3: 75, 75, 75, 7: 75, 75, 14: 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 42: 75, 75, 47: 75, 75, 75, 75, 76: 75, 164: 427, 182: 426}, + {60, 60}, + // 15 + {59, 59}, + {58, 58}, + {57, 57}, + {56, 56}, + {55, 55}, + // 20 + {54, 54}, + {53, 53}, + {52, 52}, + {51, 51}, + {50, 50}, + // 25 + {49, 49}, + {48, 48}, + {47, 47}, + {46, 46}, + {45, 45}, + // 30 + {112: 424}, + {8: 248, 97: 249}, + {43, 43, 7: 43, 43, 13: 43, 96: 43, 104: 43, 113: 43, 144: 43, 151: 43}, + {8: 4, 151: 251, 189: 250}, + {8: 254, 92: 252, 145: 253, 153: 255}, + // 35 + {8: 3}, + {143: 422}, + {209, 209, 6: 209, 13: 209, 154: 418}, + {201, 201, 201, 6: 201, 9: 201, 201, 12: 201, 15: 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 143: 201}, + {12, 12, 13: 258, 142: 257, 194: 256}, + // 40 + {13, 13}, + {11, 11}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 261}, + {7: 415}, + {170, 170, 170, 6: 170, 9: 170, 170, 170, 170, 170, 41: 170, 45: 170, 170, 51: 170, 170, 170, 170, 170, 170, 327, 326, 150: 325}, + // 45 + {5, 5, 5, 9: 5, 5, 12: 5, 41: 5, 45: 322, 321, 91: 320}, + {163, 163, 163, 6: 163, 9: 163, 163, 163, 163, 163, 41: 163, 44: 374, 163, 163, 51: 163, 163, 163, 163, 163, 163, 163, 163, 60: 375, 373, 380, 378, 382, 377, 376, 379, 383, 381}, + {154, 154, 154, 368, 367, 365, 154, 9: 154, 154, 154, 154, 154, 41: 154, 44: 154, 154, 154, 51: 154, 154, 154, 154, 154, 154, 154, 154, 366, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154}, + {133, 133, 133, 133, 133, 133, 133, 133, 9: 133, 133, 133, 133, 133, 41: 133, 44: 133, 133, 133, 51: 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 76: 133, 78: 133, 133, 133, 133, 133, 133, 86: 133}, + {132, 132, 132, 132, 132, 132, 132, 132, 9: 132, 132, 132, 132, 132, 41: 132, 44: 132, 132, 132, 51: 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 76: 132, 78: 132, 132, 132, 132, 132, 132, 86: 132}, + // 50 + {131, 131, 131, 131, 131, 131, 131, 131, 9: 131, 131, 131, 131, 131, 41: 131, 44: 131, 131, 131, 51: 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 76: 131, 78: 131, 131, 131, 131, 131, 131, 86: 131}, + {130, 130, 130, 130, 130, 130, 130, 130, 9: 130, 130, 130, 130, 130, 41: 130, 44: 130, 130, 130, 51: 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 76: 130, 78: 130, 130, 130, 130, 130, 130, 86: 130}, + {129, 129, 129, 129, 129, 129, 129, 129, 9: 129, 129, 129, 129, 129, 41: 129, 44: 129, 129, 129, 51: 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 76: 129, 78: 129, 129, 129, 129, 129, 129, 86: 129}, + {128, 128, 128, 128, 128, 128, 128, 128, 9: 128, 128, 128, 128, 128, 41: 128, 44: 128, 128, 128, 51: 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 76: 128, 78: 128, 128, 128, 128, 128, 128, 86: 128}, + {127, 127, 127, 127, 127, 127, 127, 127, 9: 127, 127, 127, 127, 127, 41: 127, 44: 127, 127, 127, 51: 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 76: 127, 78: 127, 127, 127, 127, 127, 127, 86: 127}, + // 55 + {126, 126, 126, 126, 126, 126, 126, 126, 9: 126, 126, 126, 126, 126, 41: 126, 44: 126, 126, 126, 51: 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 76: 126, 78: 126, 126, 126, 126, 126, 126, 86: 126}, + {125, 125, 125, 125, 125, 125, 125, 125, 9: 125, 125, 125, 125, 125, 41: 125, 44: 125, 125, 125, 51: 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 76: 125, 78: 125, 125, 125, 125, 125, 125, 86: 125}, + {124, 124, 124, 124, 124, 124, 124, 124, 9: 124, 124, 124, 124, 124, 41: 124, 44: 124, 124, 124, 51: 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 76: 124, 78: 124, 124, 124, 124, 124, 124, 86: 124}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 363}, + {118, 118, 118, 118, 118, 118, 118, 118, 9: 118, 118, 118, 118, 118, 41: 118, 44: 118, 118, 118, 51: 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 76: 118, 78: 118, 118, 118, 118, 118, 118, 86: 118}, + // 60 + {117, 117, 117, 117, 117, 117, 117, 117, 9: 117, 117, 117, 117, 117, 41: 117, 44: 117, 117, 117, 51: 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 76: 117, 78: 117, 117, 117, 117, 117, 117, 86: 117}, + {10, 10, 10, 10, 10, 10, 10, 311, 9: 10, 10, 10, 10, 10, 41: 10, 44: 10, 10, 10, 51: 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 76: 10, 78: 10, 10, 10, 10, 10, 10, 86: 312, 103: 315, 105: 313, 314}, + {113, 113, 113, 113, 113, 113, 113, 9: 113, 113, 113, 113, 113, 41: 113, 44: 113, 113, 113, 51: 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 76: 355, 78: 353, 350, 354, 349, 351, 352}, + {108, 108, 108, 108, 108, 108, 108, 9: 108, 108, 108, 108, 108, 41: 108, 44: 108, 108, 108, 51: 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 76: 108, 78: 108, 108, 108, 108, 108, 108}, + {100, 100, 100, 100, 100, 100, 100, 100, 9: 100, 100, 100, 100, 100, 41: 100, 44: 100, 100, 100, 51: 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 76: 100, 78: 100, 100, 100, 100, 100, 100, 86: 100, 152: 347}, + // 65 + {42, 42, 42, 6: 42, 9: 42, 42, 42, 42, 42, 41: 42, 45: 42, 42, 51: 42, 42, 42, 42, 42, 42, 42, 42}, + {37, 37, 37, 37, 37, 37, 37, 37, 37, 11: 37, 14: 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 42: 37, 37, 37, 47: 37, 37, 37, 37}, + {36, 36, 36, 36, 36, 36, 36, 36, 36, 11: 36, 14: 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 42: 36, 36, 36, 47: 36, 36, 36, 36}, + {35, 35, 35, 35, 35, 35, 35, 35, 35, 11: 35, 14: 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 42: 35, 35, 35, 47: 35, 35, 35, 35}, + {34, 34, 34, 34, 34, 34, 34, 34, 34, 11: 34, 14: 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 42: 34, 34, 34, 47: 34, 34, 34, 34}, + // 70 + {33, 33, 33, 33, 33, 33, 33, 33, 33, 11: 33, 14: 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 42: 33, 33, 33, 47: 33, 33, 33, 33}, + {32, 32, 32, 32, 32, 32, 32, 32, 32, 11: 32, 14: 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 42: 32, 32, 32, 47: 32, 32, 32, 32}, + {31, 31, 31, 31, 31, 31, 31, 31, 31, 11: 31, 14: 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 42: 31, 31, 31, 47: 31, 31, 31, 31}, + {30, 30, 30, 30, 30, 30, 30, 30, 30, 11: 30, 14: 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 42: 30, 30, 30, 47: 30, 30, 30, 30}, + {29, 29, 29, 29, 29, 29, 29, 29, 29, 11: 29, 14: 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 42: 29, 29, 29, 47: 29, 29, 29, 29}, + // 75 + {28, 28, 28, 28, 28, 28, 28, 28, 28, 11: 28, 14: 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 42: 28, 28, 28, 47: 28, 28, 28, 28}, + {27, 27, 27, 27, 27, 27, 27, 27, 27, 11: 27, 14: 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 42: 27, 27, 27, 47: 27, 27, 27, 27}, + {26, 26, 26, 26, 26, 26, 26, 26, 26, 11: 26, 14: 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 42: 26, 26, 26, 47: 26, 26, 26, 26}, + {25, 25, 25, 25, 25, 25, 25, 25, 25, 11: 25, 14: 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 42: 25, 25, 25, 47: 25, 25, 25, 25}, + {24, 24, 24, 24, 24, 24, 24, 24, 24, 11: 24, 14: 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 42: 24, 24, 24, 47: 24, 24, 24, 24}, + // 80 + {23, 23, 23, 23, 23, 23, 23, 23, 23, 11: 23, 14: 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 42: 23, 23, 23, 47: 23, 23, 23, 23}, + {22, 22, 22, 22, 22, 22, 22, 22, 22, 11: 22, 14: 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 42: 22, 22, 22, 47: 22, 22, 22, 22}, + {21, 21, 21, 21, 21, 21, 21, 21, 21, 11: 21, 14: 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 42: 21, 21, 21, 47: 21, 21, 21, 21}, + {20, 20, 20, 20, 20, 20, 20, 20, 20, 11: 20, 14: 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 42: 20, 20, 20, 47: 20, 20, 20, 20}, + {19, 19, 19, 19, 19, 19, 19, 19, 19, 11: 19, 14: 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 42: 19, 19, 19, 47: 19, 19, 19, 19}, + // 85 + {18, 18, 18, 18, 18, 18, 18, 18, 18, 11: 18, 14: 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 42: 18, 18, 18, 47: 18, 18, 18, 18}, + {17, 17, 17, 17, 17, 17, 17, 17, 17, 11: 17, 14: 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 42: 17, 17, 17, 47: 17, 17, 17, 17}, + {16, 16, 16, 16, 16, 16, 16, 16, 16, 11: 16, 14: 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 42: 16, 16, 16, 47: 16, 16, 16, 16}, + {15, 15, 15, 15, 15, 15, 15, 15, 15, 11: 15, 14: 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 42: 15, 15, 15, 47: 15, 15, 15, 15}, + {14, 14, 14, 14, 14, 14, 14, 14, 14, 11: 14, 14: 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 42: 14, 14, 14, 47: 14, 14, 14, 14}, + // 90 + {7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 70: 259, 276, 271, 275, 346, 273}, + {7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 70: 259, 276, 271, 275, 345, 273}, + {7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 70: 259, 276, 271, 275, 344, 273}, + {7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 70: 259, 276, 271, 275, 310, 273}, + {6, 6, 6, 6, 6, 6, 6, 311, 9: 6, 6, 6, 6, 6, 41: 6, 44: 6, 6, 6, 51: 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 76: 6, 78: 6, 6, 6, 6, 6, 6, 86: 312, 103: 315, 105: 313, 314}, + // 95 + {2: 204, 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 335, 279, 84: 278, 263, 87: 281, 262, 260, 337, 99: 336, 155: 334}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 56: 317, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 316}, + {116, 116, 116, 116, 116, 116, 116, 116, 9: 116, 116, 116, 116, 116, 41: 116, 44: 116, 116, 116, 51: 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 76: 116, 78: 116, 116, 116, 116, 116, 116, 86: 116}, + {115, 115, 115, 115, 115, 115, 115, 115, 9: 115, 115, 115, 115, 115, 41: 115, 44: 115, 115, 115, 51: 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 76: 115, 78: 115, 115, 115, 115, 115, 115, 86: 115}, + {114, 114, 114, 114, 114, 114, 114, 114, 9: 114, 114, 114, 114, 114, 41: 114, 44: 114, 114, 114, 51: 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 76: 114, 78: 114, 114, 114, 114, 114, 114, 86: 114}, + // 100 + {45: 322, 321, 54: 329, 56: 330, 91: 320}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 54: 319, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 318}, + {45: 322, 321, 54: 323, 91: 320}, + {64, 64, 64, 64, 64, 64, 64, 64, 9: 64, 64, 64, 64, 64, 41: 64, 44: 64, 64, 64, 51: 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 76: 64, 78: 64, 64, 64, 64, 64, 64, 86: 64}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 324}, + // 105 + {3: 168, 168, 168, 7: 168, 168, 14: 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 42: 168, 168, 47: 168, 168, 168, 168}, + {3: 167, 167, 167, 7: 167, 167, 14: 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 42: 167, 167, 47: 167, 167, 167, 167}, + {63, 63, 63, 63, 63, 63, 63, 63, 9: 63, 63, 63, 63, 63, 41: 63, 44: 63, 63, 63, 51: 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 76: 63, 78: 63, 63, 63, 63, 63, 63, 86: 63}, + {169, 169, 169, 6: 169, 9: 169, 169, 169, 169, 169, 41: 169, 45: 169, 169, 51: 169, 169, 169, 169, 169, 169, 327, 326, 150: 325}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 328, 262}, + // 110 + {3: 40, 40, 40, 7: 40, 40, 14: 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 42: 40, 40, 47: 40, 40, 40, 40}, + {3: 39, 39, 39, 7: 39, 39, 14: 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 42: 39, 39, 47: 39, 39, 39, 39}, + {41, 41, 41, 6: 41, 9: 41, 41, 41, 41, 41, 41: 41, 45: 41, 41, 51: 41, 41, 41, 41, 41, 41, 41, 41}, + {140, 140, 140, 140, 140, 140, 140, 140, 9: 140, 140, 140, 140, 140, 41: 140, 44: 140, 140, 140, 51: 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 76: 140, 78: 140, 140, 140, 140, 140, 140, 86: 140}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 54: 332, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 331}, + // 115 + {45: 322, 321, 54: 333, 91: 320}, + {62, 62, 62, 62, 62, 62, 62, 62, 9: 62, 62, 62, 62, 62, 41: 62, 44: 62, 62, 62, 51: 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 76: 62, 78: 62, 62, 62, 62, 62, 62, 86: 62}, + {61, 61, 61, 61, 61, 61, 61, 61, 9: 61, 61, 61, 61, 61, 41: 61, 44: 61, 61, 61, 51: 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 76: 61, 78: 61, 61, 61, 61, 61, 61, 86: 61}, + {2: 343}, + {2: 342}, + // 120 + {2: 203}, + {165, 165, 165, 6: 165, 9: 165, 165, 45: 322, 321, 52: 165, 165, 91: 320, 166: 338}, + {2, 2, 2, 6: 340, 9: 2, 2, 52: 2, 2, 98: 339}, + {166, 166, 166, 9: 166, 166, 52: 166, 166}, + {1, 1, 1, 309, 308, 306, 7: 274, 280, 1, 1, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 52: 1, 1, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 341}, + // 125 + {164, 164, 164, 6: 164, 9: 164, 164, 45: 322, 321, 52: 164, 164, 91: 320}, + {205, 205, 205, 205, 205, 205, 205, 205, 9: 205, 205, 205, 205, 205, 41: 205, 44: 205, 205, 205, 51: 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 76: 205, 78: 205, 205, 205, 205, 205, 205, 86: 205}, + {206, 206, 206, 206, 206, 206, 206, 206, 9: 206, 206, 206, 206, 206, 41: 206, 44: 206, 206, 206, 51: 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 76: 206, 78: 206, 206, 206, 206, 206, 206, 86: 206}, + {7, 7, 7, 7, 7, 7, 7, 311, 9: 7, 7, 7, 7, 7, 41: 7, 44: 7, 7, 7, 51: 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 76: 7, 78: 7, 7, 7, 7, 7, 7, 86: 312, 103: 315, 105: 313, 314}, + {8, 8, 8, 8, 8, 8, 8, 311, 9: 8, 8, 8, 8, 8, 41: 8, 44: 8, 8, 8, 51: 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 76: 8, 78: 8, 8, 8, 8, 8, 8, 86: 312, 103: 315, 105: 313, 314}, + // 130 + {9, 9, 9, 9, 9, 9, 9, 311, 9: 9, 9, 9, 9, 9, 41: 9, 44: 9, 9, 9, 51: 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 76: 9, 78: 9, 9, 9, 9, 9, 9, 86: 312, 103: 315, 105: 313, 314}, + {8: 348}, + {99, 99, 99, 99, 99, 99, 99, 99, 9: 99, 99, 99, 99, 99, 41: 99, 44: 99, 99, 99, 51: 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 76: 99, 78: 99, 99, 99, 99, 99, 99, 86: 99}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 362}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 361}, + // 135 + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 360}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 359}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 358}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 357}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 356}, + // 140 + {101, 101, 101, 101, 101, 101, 101, 9: 101, 101, 101, 101, 101, 41: 101, 44: 101, 101, 101, 51: 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 76: 101, 78: 101, 101, 101, 101, 101, 101}, + {102, 102, 102, 102, 102, 102, 102, 9: 102, 102, 102, 102, 102, 41: 102, 44: 102, 102, 102, 51: 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 76: 102, 78: 102, 102, 102, 102, 102, 102}, + {103, 103, 103, 103, 103, 103, 103, 9: 103, 103, 103, 103, 103, 41: 103, 44: 103, 103, 103, 51: 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 76: 103, 78: 103, 103, 103, 103, 103, 103}, + {104, 104, 104, 104, 104, 104, 104, 9: 104, 104, 104, 104, 104, 41: 104, 44: 104, 104, 104, 51: 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 76: 104, 78: 104, 104, 104, 104, 104, 104}, + {105, 105, 105, 105, 105, 105, 105, 9: 105, 105, 105, 105, 105, 41: 105, 44: 105, 105, 105, 51: 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 76: 105, 78: 105, 105, 105, 105, 105, 105}, + // 145 + {106, 106, 106, 106, 106, 106, 106, 9: 106, 106, 106, 106, 106, 41: 106, 44: 106, 106, 106, 51: 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 76: 106, 78: 106, 106, 106, 106, 106, 106}, + {107, 107, 107, 107, 107, 107, 107, 9: 107, 107, 107, 107, 107, 41: 107, 44: 107, 107, 107, 51: 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 76: 107, 78: 107, 107, 107, 107, 107, 107}, + {2: 364, 45: 322, 321, 91: 320}, + {123, 123, 123, 123, 123, 123, 123, 123, 9: 123, 123, 123, 123, 123, 41: 123, 44: 123, 123, 123, 51: 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 76: 123, 78: 123, 123, 123, 123, 123, 123, 86: 123}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 372}, + // 150 + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 371}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 370}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 369}, + {109, 109, 109, 109, 109, 109, 109, 9: 109, 109, 109, 109, 109, 41: 109, 44: 109, 109, 109, 51: 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 76: 355, 78: 353, 350, 354, 349, 351, 352}, + {110, 110, 110, 110, 110, 110, 110, 9: 110, 110, 110, 110, 110, 41: 110, 44: 110, 110, 110, 51: 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 76: 355, 78: 353, 350, 354, 349, 351, 352}, + // 155 + {111, 111, 111, 111, 111, 111, 111, 9: 111, 111, 111, 111, 111, 41: 111, 44: 111, 111, 111, 51: 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 76: 355, 78: 353, 350, 354, 349, 351, 352}, + {112, 112, 112, 112, 112, 112, 112, 9: 112, 112, 112, 112, 112, 41: 112, 44: 112, 112, 112, 51: 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 76: 355, 78: 353, 350, 354, 349, 351, 352}, + {7: 409}, + {60: 398, 397}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 394}, + // 160 + {14: 391, 44: 392}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 390}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 389}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 388}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 387}, + // 165 + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 386}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 385}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 384}, + {147, 147, 147, 368, 367, 365, 147, 9: 147, 147, 147, 147, 147, 41: 147, 44: 147, 147, 147, 51: 147, 147, 147, 147, 147, 147, 147, 147, 366, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147}, + {148, 148, 148, 368, 367, 365, 148, 9: 148, 148, 148, 148, 148, 41: 148, 44: 148, 148, 148, 51: 148, 148, 148, 148, 148, 148, 148, 148, 366, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148}, + // 170 + {149, 149, 149, 368, 367, 365, 149, 9: 149, 149, 149, 149, 149, 41: 149, 44: 149, 149, 149, 51: 149, 149, 149, 149, 149, 149, 149, 149, 366, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149}, + {150, 150, 150, 368, 367, 365, 150, 9: 150, 150, 150, 150, 150, 41: 150, 44: 150, 150, 150, 51: 150, 150, 150, 150, 150, 150, 150, 150, 366, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150}, + {151, 151, 151, 368, 367, 365, 151, 9: 151, 151, 151, 151, 151, 41: 151, 44: 151, 151, 151, 51: 151, 151, 151, 151, 151, 151, 151, 151, 366, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151}, + {152, 152, 152, 368, 367, 365, 152, 9: 152, 152, 152, 152, 152, 41: 152, 44: 152, 152, 152, 51: 152, 152, 152, 152, 152, 152, 152, 152, 366, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152}, + {153, 153, 153, 368, 367, 365, 153, 9: 153, 153, 153, 153, 153, 41: 153, 44: 153, 153, 153, 51: 153, 153, 153, 153, 153, 153, 153, 153, 366, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153}, + // 175 + {156, 156, 156, 6: 156, 9: 156, 156, 156, 156, 156, 41: 156, 45: 156, 156, 51: 156, 156, 156, 156, 156, 156, 156, 156}, + {14: 393}, + {155, 155, 155, 6: 155, 9: 155, 155, 155, 155, 155, 41: 155, 45: 155, 155, 51: 155, 155, 155, 155, 155, 155, 155, 155}, + {3: 368, 367, 365, 57: 395, 59: 366}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 396}, + // 180 + {158, 158, 158, 368, 367, 365, 158, 9: 158, 158, 158, 158, 158, 41: 158, 45: 158, 158, 51: 158, 158, 158, 158, 158, 158, 158, 158, 366}, + {7: 402}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 399}, + {3: 368, 367, 365, 57: 400, 59: 366}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 401}, + // 185 + {157, 157, 157, 368, 367, 365, 157, 9: 157, 157, 157, 157, 157, 41: 157, 45: 157, 157, 51: 157, 157, 157, 157, 157, 157, 157, 157, 366}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 337, 96: 229, 99: 403, 101: 404}, + {2: 408}, + {406, 2: 95, 136: 405}, + {2: 407}, + // 190 + {2: 94}, + {159, 159, 159, 6: 159, 9: 159, 159, 159, 159, 159, 41: 159, 45: 159, 159, 51: 159, 159, 159, 159, 159, 159, 159, 159}, + {161, 161, 161, 6: 161, 9: 161, 161, 161, 161, 161, 41: 161, 45: 161, 161, 51: 161, 161, 161, 161, 161, 161, 161, 161}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 337, 96: 229, 99: 410, 101: 411}, + {2: 414}, + // 195 + {406, 2: 95, 136: 412}, + {2: 413}, + {160, 160, 160, 6: 160, 9: 160, 160, 160, 160, 160, 41: 160, 45: 160, 160, 51: 160, 160, 160, 160, 160, 160, 160, 160}, + {162, 162, 162, 6: 162, 9: 162, 162, 162, 162, 162, 41: 162, 45: 162, 162, 51: 162, 162, 162, 162, 162, 162, 162, 162}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 416}, + // 200 + {2: 417, 45: 322, 321, 91: 320}, + {192, 192, 192, 192, 192, 192, 192, 192, 9: 192, 192, 192, 192, 192, 41: 192, 44: 192, 192, 192, 51: 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 76: 192, 78: 192, 192, 192, 192, 192, 192, 86: 192}, + {2, 2, 6: 420, 13: 2, 98: 419}, + {210, 210, 13: 210}, + {1, 1, 8: 254, 13: 1, 92: 252, 145: 421}, + // 205 + {208, 208, 6: 208, 13: 208}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 423}, + {211, 211, 6: 211, 13: 211, 45: 322, 321, 91: 320}, + {8: 248, 97: 425}, + {38, 38}, + // 210 + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 432, 279, 84: 278, 263, 87: 281, 262, 260, 428, 149: 429, 168: 430, 183: 431}, + {3: 74, 74, 74, 7: 74, 74, 14: 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 42: 74, 74, 47: 74, 74, 74, 74, 76: 74}, + {6: 145, 45: 322, 321, 51: 145, 55: 489, 91: 320, 167: 488}, + {6: 143, 51: 143}, + {6: 486, 51: 72}, + // 215 + {51: 433}, + {51: 73}, + {7: 436, 435, 132: 437, 434, 181: 438}, + {93, 93, 93, 6: 93, 9: 93, 93, 12: 93, 93, 41: 93, 55: 484, 93: 93, 93, 93, 100: 93, 180: 483}, + {97, 97, 97, 6: 97, 9: 97, 97, 12: 97, 97, 41: 97, 55: 97, 93: 97, 97, 97, 100: 97}, + // 220 + {96: 229, 101: 480}, + {91, 91, 91, 6: 91, 9: 91, 91, 12: 91, 91, 41: 91, 93: 91, 91, 91}, + {2, 2, 2, 6: 439, 9: 2, 2, 12: 2, 2, 41: 2, 93: 2, 2, 2, 98: 440}, + {1, 1, 1, 7: 436, 435, 1, 1, 12: 1, 1, 41: 1, 93: 1, 1, 1, 132: 479, 434}, + {82, 82, 82, 9: 82, 82, 12: 82, 82, 41: 82, 93: 443, 441, 442, 173: 445, 446, 444}, + // 225 + {102: 88, 111: 88}, + {102: 87, 111: 87}, + {102: 86, 111: 86}, + {102: 85, 111: 473, 178: 474}, + {81, 81, 81, 9: 81, 81, 12: 81, 81, 41: 81}, + // 230 + {70, 70, 70, 9: 70, 70, 12: 70, 258, 41: 70, 142: 448, 188: 447}, + {68, 68, 68, 9: 68, 68, 12: 68, 41: 449, 169: 451, 184: 450}, + {69, 69, 69, 9: 69, 69, 12: 69, 41: 69}, + {146: 466}, + {66, 66, 66, 9: 66, 66, 12: 452, 176: 454, 187: 453}, + // 235 + {67, 67, 67, 9: 67, 67, 12: 67}, + {146: 461}, + {79, 79, 79, 9: 79, 456, 185: 455}, + {65, 65, 65, 9: 65, 65}, + {77, 77, 77, 9: 459, 186: 458}, + // 240 + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 457}, + {78, 78, 78, 9: 78, 45: 322, 321, 91: 320}, + {80, 80, 80}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 460}, + {76, 76, 76, 45: 322, 321, 91: 320}, + // 245 + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 337, 99: 462}, + {121, 121, 121, 9: 121, 121, 52: 464, 465, 177: 463}, + {122, 122, 122, 9: 122, 122}, + {120, 120, 120, 9: 120, 120}, + {119, 119, 119, 9: 119, 119}, + // 250 + {8: 254, 92: 467, 147: 468}, + {199, 199, 199, 6: 199, 9: 199, 199, 12: 199, 157: 469}, + {141, 141, 141, 9: 141, 141, 12: 141}, + {2, 2, 2, 6: 471, 9: 2, 2, 12: 2, 98: 470}, + {200, 200, 200, 9: 200, 200, 12: 200}, + // 255 + {1, 1, 1, 8: 254, 1, 1, 12: 1, 92: 472}, + {198, 198, 198, 6: 198, 9: 198, 198, 12: 198}, + {102: 84}, + {102: 475}, + {7: 436, 435, 132: 476, 434}, + // 260 + {100: 477}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 478}, + {83, 83, 83, 9: 83, 83, 12: 83, 83, 41: 83, 45: 322, 321, 91: 320}, + {90, 90, 90, 6: 90, 9: 90, 90, 12: 90, 90, 41: 90, 93: 90, 90, 90}, + {406, 2: 95, 136: 481}, + // 265 + {2: 482}, + {96, 96, 96, 6: 96, 9: 96, 96, 12: 96, 96, 41: 96, 55: 96, 93: 96, 96, 96, 100: 96}, + {98, 98, 98, 6: 98, 9: 98, 98, 12: 98, 98, 41: 98, 93: 98, 98, 98, 100: 98}, + {8: 485}, + {92, 92, 92, 6: 92, 9: 92, 92, 12: 92, 92, 41: 92, 93: 92, 92, 92, 100: 92}, + // 270 + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 71, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 428, 149: 487}, + {6: 142, 51: 142}, + {6: 146, 51: 146}, + {8: 490}, + {6: 144, 51: 144}, + // 275 + {8: 248, 97: 492}, + {7: 494, 96: 137, 113: 137, 170: 493}, + {96: 229, 101: 498, 113: 497}, + {8: 254, 92: 467, 147: 495}, + {2: 496}, + // 280 + {96: 136, 113: 136}, + {7: 499}, + {138, 138}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 337, 99: 500}, + {2: 501}, + // 285 + {135, 135, 6: 135, 171: 502}, + {2, 2, 6: 504, 98: 503}, + {139, 139}, + {1, 1, 7: 505}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 337, 99: 506}, + // 290 + {2: 507}, + {134, 134, 6: 134}, + {171, 171}, + {8: 176, 109: 516, 165: 515}, + {8: 248, 97: 511, 109: 512}, + // 295 + {174, 174}, + {108: 513}, + {8: 248, 97: 514}, + {173, 173}, + {8: 518}, + // 300 + {108: 517}, + {8: 175}, + {177, 177}, + {8: 248, 97: 520}, + {179, 179, 13: 258, 142: 521}, + // 305 + {178, 178}, + {110: 553}, + {110: 187}, + {8: 248, 97: 525, 109: 526}, + {7: 548}, + // 310 + {44: 527}, + {108: 528}, + {8: 248, 97: 529}, + {7: 530}, + {8: 254, 92: 531, 107: 532}, + // 315 + {15: 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 70: 538}, + {2: 184, 6: 184, 148: 533}, + {2: 2, 6: 535, 98: 534}, + {2: 537}, + {2: 1, 8: 254, 92: 531, 107: 536}, + // 320 + {2: 183, 6: 183}, + {185, 185}, + {194, 194, 194, 309, 308, 306, 194, 274, 280, 11: 194, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 540, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 541, 158: 542, 539}, + {181, 181, 181, 6: 181, 11: 545, 162: 546, 544}, + {14: 543}, + // 325 + {195, 195, 195, 6: 195, 11: 195, 45: 322, 321, 91: 320}, + {193, 193, 193, 6: 193, 11: 193}, + {196, 196, 196, 6: 196, 11: 196}, + {202, 202, 202, 6: 202}, + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 547}, + // 330 + {180, 180, 180, 6: 180}, + {182, 182, 182, 6: 182, 45: 322, 321, 91: 320}, + {8: 254, 92: 531, 107: 549}, + {2: 184, 6: 184, 148: 550}, + {2: 2, 6: 535, 98: 551}, + // 335 + {2: 552}, + {186, 186}, + {8: 190, 109: 555, 160: 554}, + {8: 558}, + {44: 556}, + // 340 + {108: 557}, + {8: 189}, + {100: 559}, + {8: 560}, + {7: 561}, + // 345 + {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 337, 99: 562}, + {2: 563}, + {191, 191}, + {207, 207}, + {8: 248, 97: 566}, + // 350 + {104: 568, 144: 567}, + {8: 254, 92: 531, 107: 571}, + {156: 569}, + {8: 254, 92: 570}, + {212, 212}, + // 355 + {213, 213}, + {1: 214, 45: 322, 321, 91: 320}, + {172, 172, 96: 229, 101: 242, 104: 225, 114: 220, 231, 221, 232, 222, 233, 223, 234, 235, 236, 224, 237, 238, 230, 226, 239, 227, 240, 134: 228, 241, 137: 574, 246, 243, 247, 244}, + {44, 44}, + } +) + +var yyDebug = 0 + +type yyLexer interface { + Lex(lval *yySymType) int + Error(s string) +} + +type yyLexerEx interface { + yyLexer + Reduced(rule, state int, lval *yySymType) bool +} + +func yySymName(c int) (s string) { + x, ok := yyXLAT[c] + if ok { + return yySymNames[x] + } + + return __yyfmt__.Sprintf("%d", c) +} + +func yylex1(yylex yyLexer, lval *yySymType) (n int) { + n = yylex.Lex(lval) + if n <= 0 { + n = yyEOFCode + } + if yyDebug >= 3 { + __yyfmt__.Printf("\nlex %s(%#x %d), lval: %+v\n", yySymName(n), n, n, lval) + } + return n +} + +func yyParse(yylex yyLexer) int { + const yyError = 196 + + yyEx, _ := yylex.(yyLexerEx) + var yyn int + var yylval yySymType + var yyVAL yySymType + yyS := make([]yySymType, 200) + + Nerrs := 0 /* number of errors */ + Errflag := 0 /* error recovery flag */ + yyerrok := func() { + if yyDebug >= 2 { + __yyfmt__.Printf("yyerrok()\n") + } + Errflag = 0 + } + _ = yyerrok + yystate := 0 + yychar := -1 + var yyxchar int + var yyshift int + yyp := -1 + goto yystack + +ret0: + return 0 + +ret1: + return 1 + +yystack: + /* put a state and value onto the stack */ + yyp++ + if yyp >= len(yyS) { + nyys := make([]yySymType, len(yyS)*2) + copy(nyys, yyS) + yyS = nyys + } + yyS[yyp] = yyVAL + yyS[yyp].yys = yystate + +yynewstate: + if yychar < 0 { + yychar = yylex1(yylex, &yylval) + var ok bool + if yyxchar, ok = yyXLAT[yychar]; !ok { + yyxchar = len(yySymNames) // > tab width + } + } + if yyDebug >= 4 { + var a []int + for _, v := range yyS[:yyp+1] { + a = append(a, v.yys) + } + __yyfmt__.Printf("state stack %v\n", a) + } + row := yyParseTab[yystate] + yyn = 0 + if yyxchar < len(row) { + if yyn = int(row[yyxchar]); yyn != 0 { + yyn += yyTabOfs + } + } + switch { + case yyn > 0: // shift + yychar = -1 + yyVAL = yylval + yystate = yyn + yyshift = yyn + if yyDebug >= 2 { + __yyfmt__.Printf("shift, and goto state %d\n", yystate) + } + if Errflag > 0 { + Errflag-- + } + goto yystack + case yyn < 0: // reduce + case yystate == 1: // accept + if yyDebug >= 2 { + __yyfmt__.Println("accept") + } + goto ret0 + } + + if yyn == 0 { + /* error ... attempt to resume parsing */ + switch Errflag { + case 0: /* brand new error */ + if yyDebug >= 1 { + __yyfmt__.Printf("no action for %s in state %d\n", yySymName(yychar), yystate) + } + msg, ok := yyXErrors[yyXError{yystate, yyxchar}] + if !ok { + msg, ok = yyXErrors[yyXError{yystate, -1}] + } + if !ok && yyshift != 0 { + msg, ok = yyXErrors[yyXError{yyshift, yyxchar}] + } + if !ok { + msg, ok = yyXErrors[yyXError{yyshift, -1}] + } + if !ok || msg == "" { + msg = "syntax error" + } + yylex.Error(msg) + Nerrs++ + fallthrough + + case 1, 2: /* incompletely recovered error ... try again */ + Errflag = 3 + + /* find a state where "error" is a legal shift action */ + for yyp >= 0 { + row := yyParseTab[yyS[yyp].yys] + if yyError < len(row) { + yyn = int(row[yyError]) + yyTabOfs + if yyn > 0 { // hit + if yyDebug >= 2 { + __yyfmt__.Printf("error recovery found error shift in state %d\n", yyS[yyp].yys) + } + yystate = yyn /* simulate a shift of "error" */ + goto yystack + } + } + + /* the current p has no shift on "error", pop stack */ + if yyDebug >= 2 { + __yyfmt__.Printf("error recovery pops state %d\n", yyS[yyp].yys) + } + yyp-- + } + /* there is no state on the stack with an error shift ... abort */ + if yyDebug >= 2 { + __yyfmt__.Printf("error recovery failed\n") + } + goto ret1 + + case 3: /* no shift yet; clobber input char */ + if yyDebug >= 2 { + __yyfmt__.Printf("error recovery discards %s\n", yySymName(yychar)) + } + if yychar == yyEOFCode { + goto ret1 + } + + yychar = -1 + goto yynewstate /* try again in the same state */ + } + } + + r := -yyn + x0 := yyReductions[r] + x, n := x0.xsym, x0.components + yypt := yyp + _ = yypt // guard against "declared and not used" + + yyp -= n + if yyp+1 >= len(yyS) { + nyys := make([]yySymType, len(yyS)*2) + copy(nyys, yyS) + yyS = nyys + } + yyVAL = yyS[yyp+1] + + /* consult goto table to find next state */ + exState := yystate + yystate = int(yyParseTab[yyS[yyp].yys][x]) + yyTabOfs + /* reduction by production r */ + if yyDebug >= 2 { + __yyfmt__.Printf("reduce using rule %v (%s), and goto state %d\n", r, yySymNames[x], yystate) + } + + switch r { + case 2: + { + yylex.(*lexer).expr = expr(yyS[yypt-0].item) + } + case 3: + { + yyVAL.item = &alterTableAddStmt{tableName: yyS[yypt-2].item.(string), c: yyS[yypt-0].item.(*col)} + } + case 4: + { + yyVAL.item = &alterTableDropColumnStmt{tableName: yyS[yypt-3].item.(string), colName: yyS[yypt-0].item.(string)} + } + case 5: + { + yyVAL.item = assignment{colName: yyS[yypt-2].item.(string), expr: expr(yyS[yypt-0].item)} + } + case 6: + { + yyVAL.item = append([]assignment{yyS[yypt-2].item.(assignment)}, yyS[yypt-1].item.([]assignment)...) + } + case 7: + { + yyVAL.item = []assignment{} + } + case 8: + { + yyVAL.item = append(yyS[yypt-2].item.([]assignment), yyS[yypt-0].item.(assignment)) + } + case 9: + { + yyVAL.item = beginTransactionStmt{} + } + case 10: + { + yyVAL.item = yyS[yypt-1].item + } + case 11: + { + yyVAL.item = '*' + } + case 12: + { + yyVAL.item = []expression{} + } + case 14: + { + x := &col{name: yyS[yypt-3].item.(string), typ: yyS[yypt-2].item.(int), constraint: yyS[yypt-1].item.(*constraint)} + if yyS[yypt-0].item != nil { + x.dflt = expr(yyS[yypt-0].item) + } + yyVAL.item = x + } + case 16: + { + yyVAL.item = append([]string{yyS[yypt-2].item.(string)}, yyS[yypt-1].item.([]string)...) + } + case 17: + { + yyVAL.item = []string{} + } + case 18: + { + yyVAL.item = append(yyS[yypt-2].item.([]string), yyS[yypt-0].item.(string)) + } + case 19: + { + yyVAL.item = commitStmt{} + } + case 20: + { + yyVAL.item = &constraint{} + } + case 21: + { + yyVAL.item = &constraint{expr(yyS[yypt-0].item)} + } + case 22: + { + yyVAL.item = (*constraint)(nil) + } + case 24: + { + yyVAL.item = &conversion{typ: yyS[yypt-3].item.(int), val: expr(yyS[yypt-1].item)} + } + case 25: + { + indexName, tableName, exprList := yyS[yypt-5].item.(string), yyS[yypt-3].item.(string), yyS[yypt-1].item.([]expression) + simpleIndex := len(exprList) == 1 + var columnName string + if simpleIndex { + expr := exprList[0] + switch x := expr.(type) { + case *ident: + columnName = x.s + case *call: + if x.f == "id" && len(x.arg) == 0 { + columnName = "id()" + break + } + + simpleIndex = false + default: + simpleIndex = false + } + } + + if !simpleIndex { + columnName = "" + } + yyVAL.item = &createIndexStmt{unique: yyS[yypt-8].item.(bool), ifNotExists: yyS[yypt-6].item.(bool), indexName: indexName, tableName: tableName, colName: columnName, exprList: exprList} + + if indexName == tableName || indexName == columnName { + yylex.(*lexer).err("index name collision: %s", indexName) + return 1 + } + + if yylex.(*lexer).root { + break + } + + if isSystemName[indexName] || isSystemName[tableName] { + yylex.(*lexer).err("name is used for system tables: %s", indexName) + return 1 + } + } + case 26: + { + yyVAL.item = false + } + case 27: + { + yyVAL.item = true + } + case 28: + { + yyVAL.item = false + } + case 29: + { + yyVAL.item = true + } + case 30: + { + nm := yyS[yypt-5].item.(string) + yyVAL.item = &createTableStmt{tableName: nm, cols: append([]*col{yyS[yypt-3].item.(*col)}, yyS[yypt-2].item.([]*col)...)} + + if yylex.(*lexer).root { + break + } + + if isSystemName[nm] { + yylex.(*lexer).err("name is used for system tables: %s", nm) + return 1 + } + } + case 31: + { + nm := yyS[yypt-5].item.(string) + yyVAL.item = &createTableStmt{ifNotExists: true, tableName: nm, cols: append([]*col{yyS[yypt-3].item.(*col)}, yyS[yypt-2].item.([]*col)...)} + + if yylex.(*lexer).root { + break + } + + if isSystemName[nm] { + yylex.(*lexer).err("name is used for system tables: %s", nm) + return 1 + } + } + case 32: + { + yyVAL.item = []*col{} + } + case 33: + { + yyVAL.item = append(yyS[yypt-2].item.([]*col), yyS[yypt-0].item.(*col)) + } + case 34: + { + yyVAL.item = yyS[yypt-0].item + } + case 35: + { + yyVAL.item = nil + } + case 37: + { + yyVAL.item = &truncateTableStmt{yyS[yypt-0].item.(string)} + + if yylex.(*lexer).root { + break + } + + if isSystemName[yyS[yypt-0].item.(string)] { + yylex.(*lexer).err("name is used for system tables: %s", yyS[yypt-0].item.(string)) + return 1 + } + } + case 38: + { + yyVAL.item = &deleteStmt{tableName: yyS[yypt-1].item.(string), where: yyS[yypt-0].item.(*whereRset).expr} + + if yylex.(*lexer).root { + break + } + + if isSystemName[yyS[yypt-1].item.(string)] { + yylex.(*lexer).err("name is used for system tables: %s", yyS[yypt-1].item.(string)) + return 1 + } + } + case 39: + { + yyVAL.item = &dropIndexStmt{ifExists: yyS[yypt-1].item.(bool), indexName: yyS[yypt-0].item.(string)} + } + case 40: + { + yyVAL.item = false + } + case 41: + { + yyVAL.item = true + } + case 42: + { + nm := yyS[yypt-0].item.(string) + yyVAL.item = &dropTableStmt{tableName: nm} + + if yylex.(*lexer).root { + break + } + + if isSystemName[nm] { + yylex.(*lexer).err("name is used for system tables: %s", nm) + return 1 + } + } + case 43: + { + nm := yyS[yypt-0].item.(string) + yyVAL.item = &dropTableStmt{ifExists: true, tableName: nm} + + if yylex.(*lexer).root { + break + } + + if isSystemName[nm] { + yylex.(*lexer).err("name is used for system tables: %s", nm) + return 1 + } + } + case 44: + { + yyVAL.item = nil + } + case 45: + { + yyVAL.item = &explainStmt{yyS[yypt-0].item.(stmt)} + } + case 47: + { + var err error + if yyVAL.item, err = newBinaryOperation(oror, yyS[yypt-2].item, yyS[yypt-0].item); err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 50: + { + yyVAL.item = append([]expression{expr(yyS[yypt-2].item)}, yyS[yypt-1].item.([]expression)...) + } + case 51: + { + yyVAL.item = []expression(nil) + } + case 52: + { + yyVAL.item = append(yyS[yypt-2].item.([]expression), expr(yyS[yypt-0].item)) + } + case 54: + { + yyVAL.item = &pIn{expr: yyS[yypt-4].item.(expression), list: yyS[yypt-1].item.([]expression)} + } + case 55: + { + yyVAL.item = &pIn{expr: yyS[yypt-5].item.(expression), not: true, list: yyS[yypt-1].item.([]expression)} + } + case 56: + { + yyVAL.item = &pIn{expr: yyS[yypt-5].item.(expression), sel: yyS[yypt-2].item.(*selectStmt)} + } + case 57: + { + yyVAL.item = &pIn{expr: yyS[yypt-6].item.(expression), not: true, sel: yyS[yypt-2].item.(*selectStmt)} + } + case 58: + { + var err error + if yyVAL.item, err = newBetween(yyS[yypt-4].item, yyS[yypt-2].item, yyS[yypt-0].item, false); err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 59: + { + var err error + if yyVAL.item, err = newBetween(yyS[yypt-5].item, yyS[yypt-2].item, yyS[yypt-0].item, true); err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 60: + { + yyVAL.item = &isNull{expr: yyS[yypt-2].item.(expression)} + } + case 61: + { + yyVAL.item = &isNull{expr: yyS[yypt-3].item.(expression), not: true} + } + case 63: + { + var err error + if yyVAL.item, err = newBinaryOperation(ge, yyS[yypt-2].item, yyS[yypt-0].item); err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 64: + { + var err error + if yyVAL.item, err = newBinaryOperation('>', yyS[yypt-2].item, yyS[yypt-0].item); err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 65: + { + var err error + if yyVAL.item, err = newBinaryOperation(le, yyS[yypt-2].item, yyS[yypt-0].item); err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 66: + { + var err error + if yyVAL.item, err = newBinaryOperation('<', yyS[yypt-2].item, yyS[yypt-0].item); err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 67: + { + var err error + if yyVAL.item, err = newBinaryOperation(neq, yyS[yypt-2].item, yyS[yypt-0].item); err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 68: + { + var err error + if yyVAL.item, err = newBinaryOperation(eq, yyS[yypt-2].item, yyS[yypt-0].item); err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 69: + { + yyVAL.item = &pLike{expr: yyS[yypt-2].item.(expression), pattern: yyS[yypt-0].item.(expression)} + } + case 70: + { + expr, name := expr(yyS[yypt-1].item), yyS[yypt-0].item.(string) + if name == "" { + s, ok := expr.(*ident) + if ok { + name = s.s + } + } + yyVAL.item = &fld{expr: expr, name: name} + } + case 71: + { + yyVAL.item = "" + } + case 72: + { + yyVAL.item = yyS[yypt-0].item + } + case 73: + { + yyVAL.item = []*fld{yyS[yypt-0].item.(*fld)} + } + case 74: + { + l, f := yyS[yypt-2].item.([]*fld), yyS[yypt-0].item.(*fld) + if f.name != "" { + if f := findFld(l, f.name); f != nil { + yylex.(*lexer).err("duplicate field name %q", f.name) + return 1 + } + } + + yyVAL.item = append(yyS[yypt-2].item.([]*fld), yyS[yypt-0].item.(*fld)) + } + case 75: + { + yyVAL.item = &groupByRset{colNames: yyS[yypt-0].item.([]string)} + } + case 76: + { + yyVAL.item = yyS[yypt-1].item + } + case 77: + { + yyVAL.item = &insertIntoStmt{tableName: yyS[yypt-7].item.(string), colNames: yyS[yypt-6].item.([]string), lists: append([][]expression{yyS[yypt-3].item.([]expression)}, yyS[yypt-1].item.([][]expression)...)} + + if yylex.(*lexer).root { + break + } + + if isSystemName[yyS[yypt-7].item.(string)] { + yylex.(*lexer).err("name is used for system tables: %s", yyS[yypt-7].item.(string)) + return 1 + } + } + case 78: + { + yyVAL.item = &insertIntoStmt{tableName: yyS[yypt-2].item.(string), colNames: yyS[yypt-1].item.([]string), sel: yyS[yypt-0].item.(*selectStmt)} + } + case 79: + { + yyVAL.item = []string{} + } + case 80: + { + yyVAL.item = yyS[yypt-1].item + } + case 81: + { + yyVAL.item = [][]expression{} + } + case 82: + { + yyVAL.item = append(yyS[yypt-4].item.([][]expression), yyS[yypt-1].item.([]expression)) + } + case 90: + { + yyVAL.item = value{yyS[yypt-0].item} + } + case 91: + { + n := yyS[yypt-0].item.(int) + yyVAL.item = parameter{n} + l := yylex.(*lexer) + l.params = mathutil.Max(l.params, n) + if n == 0 { + l.err("parameter number must be non zero") + return 1 + } + } + case 92: + { + yyVAL.item = &ident{yyS[yypt-0].item.(string)} + } + case 93: + { + yyVAL.item = &pexpr{expr: expr(yyS[yypt-1].item)} + } + case 94: + { + yyVAL.item = &orderByRset{by: yyS[yypt-1].item.([]expression), asc: yyS[yypt-0].item.(bool)} + } + case 95: + { + yyVAL.item = true // ASC by default + } + case 96: + { + yyVAL.item = true + } + case 97: + { + yyVAL.item = false + } + case 100: + { + var err error + if yyVAL.item, err = newIndex(yyS[yypt-1].item.(expression), expr(yyS[yypt-0].item)); err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 101: + { + var err error + s := yyS[yypt-0].item.([2]*expression) + if yyVAL.item, err = newSlice(yyS[yypt-1].item.(expression), s[0], s[1]); err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 102: + { + x := yylex.(*lexer) + f, ok := yyS[yypt-1].item.(*ident) + if !ok { + x.err("expected identifier or qualified identifier") + return 1 + } + + if r, ok := yyS[yypt-0].item.(rune); ok { + if f.isQualified() || f.s != "count" || r != '*' { + x.err(fmt.Sprintf("invalid expression %s(%c)", f, r)) + return 1 + } + + yyS[yypt-0].item = []expression(nil) + } + + var err error + var agg bool + if yyVAL.item, agg, err = newCall(f.s, yyS[yypt-0].item.([]expression)); err != nil { + x.err("%v", err) + return 1 + } + if n := len(x.agg); n > 0 { + x.agg[n-1] = x.agg[n-1] || agg + } + } + case 104: + { + var err error + if yyVAL.item, err = newBinaryOperation('^', yyS[yypt-2].item, yyS[yypt-0].item); err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 105: + { + var err error + if yyVAL.item, err = newBinaryOperation('|', yyS[yypt-2].item, yyS[yypt-0].item); err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 106: + { + var err error + if yyVAL.item, err = newBinaryOperation('-', yyS[yypt-2].item, yyS[yypt-0].item); err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 107: + { + var err error + yyVAL.item, err = newBinaryOperation('+', yyS[yypt-2].item, yyS[yypt-0].item) + if err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 109: + { + var err error + yyVAL.item, err = newBinaryOperation(andnot, yyS[yypt-2].item, yyS[yypt-0].item) + if err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 110: + { + var err error + yyVAL.item, err = newBinaryOperation('&', yyS[yypt-2].item, yyS[yypt-0].item) + if err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 111: + { + var err error + yyVAL.item, err = newBinaryOperation(lsh, yyS[yypt-2].item, yyS[yypt-0].item) + if err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 112: + { + var err error + yyVAL.item, err = newBinaryOperation(rsh, yyS[yypt-2].item, yyS[yypt-0].item) + if err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 113: + { + var err error + yyVAL.item, err = newBinaryOperation('%', yyS[yypt-2].item, yyS[yypt-0].item) + if err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 114: + { + var err error + yyVAL.item, err = newBinaryOperation('/', yyS[yypt-2].item, yyS[yypt-0].item) + if err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 115: + { + var err error + yyVAL.item, err = newBinaryOperation('*', yyS[yypt-2].item, yyS[yypt-0].item) + if err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 117: + { + yyVAL.item = fmt.Sprintf("%s.%s", yyS[yypt-2].item.(string), yyS[yypt-0].item.(string)) + } + case 118: + { + yyVAL.item = []interface{}{yyS[yypt-1].item, yyS[yypt-0].item} + } + case 120: + { + yyVAL.item = yyS[yypt-2].item + } + case 123: + { + yyVAL.item = "" + } + case 124: + { + yyVAL.item = yyS[yypt-0].item + } + case 125: + { + yyVAL.list = []interface{}{yyS[yypt-0].item} + } + case 126: + { + yyVAL.list = append(yyS[yypt-2].list, yyS[yypt-0].item) + } + case 127: + { + yyVAL.item = rollbackStmt{} + } + case 128: + { + yyVAL.item = leftJoin + } + case 129: + { + yyVAL.item = rightJoin + } + case 130: + { + yyVAL.item = fullJoin + } + case 131: + { + yyVAL.item = nil + } + case 133: + { + yyVAL.item = []interface{}{yyS[yypt-5].item, yyS[yypt-2].item, yyS[yypt-0].item} + } + case 134: + { + yyVAL.item = nil + } + case 136: + { + x := yylex.(*lexer) + n := len(x.agg) + join := &joinRset{sources: yyS[yypt-7].list} + if o := yyS[yypt-5].item; o != nil { + o := o.([]interface{}) + join.typ = o[0].(int) + join.sources = append(join.sources, o[1].([]interface{})) + join.on = o[2].(expression) + } + yyVAL.item = &selectStmt{ + distinct: yyS[yypt-10].item.(bool), + flds: yyS[yypt-9].item.([]*fld), + from: join, + hasAggregates: x.agg[n-1], + where: yyS[yypt-4].item.(*whereRset), + group: yyS[yypt-3].item.(*groupByRset), + order: yyS[yypt-2].item.(*orderByRset), + limit: yyS[yypt-1].item.(*limitRset), + offset: yyS[yypt-0].item.(*offsetRset), + } + x.agg = x.agg[:n-1] + } + case 137: + { + yyVAL.item = (*limitRset)(nil) + } + case 138: + { + yyVAL.item = &limitRset{expr: expr(yyS[yypt-0].item)} + } + case 139: + { + yyVAL.item = (*offsetRset)(nil) + } + case 140: + { + yyVAL.item = &offsetRset{expr: expr(yyS[yypt-0].item)} + } + case 141: + { + yyVAL.item = false + } + case 142: + { + yyVAL.item = true + } + case 143: + { + yyVAL.item = []*fld{} + } + case 144: + { + yyVAL.item = yyS[yypt-0].item + } + case 145: + { + yyVAL.item = yyS[yypt-1].item + } + case 146: + { + yyVAL.item = (*whereRset)(nil) + } + case 148: + { + yyVAL.item = (*groupByRset)(nil) + } + case 150: + { + yyVAL.item = (*orderByRset)(nil) + } + case 152: + { + yyVAL.item = [2]*expression{nil, nil} + } + case 153: + { + hi := expr(yyS[yypt-1].item) + yyVAL.item = [2]*expression{nil, &hi} + } + case 154: + { + lo := expr(yyS[yypt-2].item) + yyVAL.item = [2]*expression{&lo, nil} + } + case 155: + { + lo := expr(yyS[yypt-3].item) + hi := expr(yyS[yypt-1].item) + yyVAL.item = [2]*expression{&lo, &hi} + } + case 171: + { + if yyS[yypt-0].item != nil { + yylex.(*lexer).list = []stmt{yyS[yypt-0].item.(stmt)} + } + } + case 172: + { + if yyS[yypt-0].item != nil { + yylex.(*lexer).list = append(yylex.(*lexer).list, yyS[yypt-0].item.(stmt)) + } + } + case 175: + { + var err error + if yyVAL.item, err = newBinaryOperation(andand, yyS[yypt-2].item, yyS[yypt-0].item); err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 178: + { + yyVAL.item = &truncateTableStmt{tableName: yyS[yypt-0].item.(string)} + } + case 203: + { + var expr expression + if w := yyS[yypt-0].item; w != nil { + expr = w.(*whereRset).expr + } + yyVAL.item = &updateStmt{tableName: yyS[yypt-3].item.(string), list: yyS[yypt-1].item.([]assignment), where: expr} + + if yylex.(*lexer).root { + break + } + + if isSystemName[yyS[yypt-3].item.(string)] { + yylex.(*lexer).err("name is used for system tables: %s", yyS[yypt-3].item.(string)) + return 1 + } + } + case 204: + { + yyVAL.item = nil + } + case 207: + { + var err error + yyVAL.item, err = newUnaryOperation('^', yyS[yypt-0].item) + if err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 208: + { + var err error + yyVAL.item, err = newUnaryOperation('!', yyS[yypt-0].item) + if err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 209: + { + var err error + yyVAL.item, err = newUnaryOperation('-', yyS[yypt-0].item) + if err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 210: + { + var err error + yyVAL.item, err = newUnaryOperation('+', yyS[yypt-0].item) + if err != nil { + yylex.(*lexer).err("%v", err) + return 1 + } + } + case 211: + { + yyVAL.item = &whereRset{expr: expr(yyS[yypt-0].item)} + } + + } + + if yyEx != nil && yyEx.Reduced(r, exState, &yyVAL) { + return -1 + } + goto yystack /* stack new state and value */ +} + +func expr(v interface{}) expression { + e := v.(expression) + for { + x, ok := e.(*pexpr) + if !ok { + return e + } + e = x.expr + } +} diff --git a/vendor/github.com/cznic/ql/plan.go b/vendor/github.com/cznic/ql/plan.go new file mode 100644 index 0000000000..be52b72c6a --- /dev/null +++ b/vendor/github.com/cznic/ql/plan.go @@ -0,0 +1,2800 @@ +// Copyright 2015 The ql 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 ql + +import ( + "bytes" + "fmt" + "strings" + + "github.com/cznic/b" + "github.com/cznic/strutil" +) + +const ( + _ = iota + indexEq // [L] + indexFalse // [false] + indexGe // [L, ...) + indexGt // (L, ...) + indexIsNotNull // (NULL, ...) + indexIsNull // [NULL] + indexIntervalCC // [L, H] + indexIntervalCO // [L, H) + indexIntervalOC // (L, H] + indexIntervalOO // (L, H) + indexLe // (..., H] + indexLt // (..., H) + indexNe // (L) + indexTrue // [true] +) + +// Note: All plans must have a pointer receiver. Enables planA == planB operation. +var ( + _ plan = (*crossJoinDefaultPlan)(nil) + _ plan = (*distinctDefaultPlan)(nil) + _ plan = (*explainDefaultPlan)(nil) + _ plan = (*filterDefaultPlan)(nil) + _ plan = (*fullJoinDefaultPlan)(nil) + _ plan = (*groupByDefaultPlan)(nil) + _ plan = (*indexPlan)(nil) + _ plan = (*leftJoinDefaultPlan)(nil) + _ plan = (*limitDefaultPlan)(nil) + _ plan = (*nullPlan)(nil) + _ plan = (*offsetDefaultPlan)(nil) + _ plan = (*orderByDefaultPlan)(nil) + _ plan = (*rightJoinDefaultPlan)(nil) + _ plan = (*selectFieldsDefaultPlan)(nil) + _ plan = (*selectFieldsGroupPlan)(nil) + _ plan = (*selectIndexDefaultPlan)(nil) + _ plan = (*sysColumnDefaultPlan)(nil) + _ plan = (*sysIndexDefaultPlan)(nil) + _ plan = (*sysTableDefaultPlan)(nil) + _ plan = (*tableDefaultPlan)(nil) + _ plan = (*tableNilPlan)(nil) +) + +type plan interface { + do(ctx *execCtx, f func(id interface{}, data []interface{}) (more bool, err error)) error + explain(w strutil.Formatter) + fieldNames() []string + filter(expr expression) (p plan, indicesSought []string, err error) + hasID() bool +} + +func isTableOrIndex(p plan) bool { + switch p.(type) { + case + *indexPlan, + *sysColumnDefaultPlan, + *sysIndexDefaultPlan, + *sysTableDefaultPlan, + *tableDefaultPlan: + return true + default: + return false + } +} + +// Invariants +// - All interval plans produce rows in ascending index value collating order. +// - L <= H +type indexPlan struct { + src *table + cname string + xname string + x btreeIndex + kind int // See interval* consts. + lval interface{} // L, H: Ordered and comparable (lldb perspective). + hval interface{} +} + +func (r *indexPlan) doGe(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { + // nil, nil, ..., L-1, L-1, L, L, L+1, L+1, ... + // --- --- --- --- --- + + +++ +++ +++ + t := r.src + it, _, err := r.x.Seek([]interface{}{r.lval}) + if err != nil { + return noEOF(err) + } + + for { + _, h, err := it.Next() + if err != nil { + return noEOF(err) + } + + id, data, err := t.row(ctx, h) + if err != nil { + return err + } + + if more, err := f(id, data); err != nil || !more { + return err + } + } +} + +func (r *indexPlan) doGt(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { + // nil, nil, ..., L-1, L-1, L, L, L+1, L+1, ... + // --- --- --- --- --- - - +++ +++ +++ + t := r.src + it, _, err := r.x.Seek([]interface{}{r.lval}) + if err != nil { + return noEOF(err) + } + + var ok bool + for { + k, h, err := it.Next() + if err != nil { + return noEOF(err) + } + + if !ok { + val, err := expand1(k[0], nil) + if err != nil { + return err + } + + if collate1(val, r.lval) == 0 { + continue + } + + ok = true + } + + id, data, err := t.row(ctx, h) + if err != nil { + return err + } + + if more, err := f(id, data); err != nil || !more { + return err + } + } +} + +func (r *indexPlan) doInterval00(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { + // nil, nil, ..., L-1, L-1, L, L, L+1, L+1, ..., H-1, H-1, H, H, H+1, H+1, ... + // --- --- --- --- --- - - +++ +++ +++ +++ +++ - - --- --- --- + t := r.src + it, _, err := r.x.Seek([]interface{}{r.lval}) + if err != nil { + return noEOF(err) + } + + var ok bool + for { + k, h, err := it.Next() + if err != nil { + return noEOF(err) + } + + if !ok { + val, err := expand1(k[0], nil) + if err != nil { + return err + } + + if collate1(val, r.lval) == 0 { + continue + } + + ok = true + } + + val, err := expand1(k[0], nil) + if err != nil { + return err + } + + if collate1(val, r.hval) == 0 { + return nil + } + + id, data, err := t.row(ctx, h) + if err != nil { + return err + } + + if more, err := f(id, data); err != nil || !more { + return err + } + } +} + +func (r *indexPlan) doIntervalOC(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { + // nil, nil, ..., L-1, L-1, L, L, L+1, L+1, ..., H-1, H-1, H, H, H+1, H+1, ... + // --- --- --- --- --- - - +++ +++ +++ +++ +++ + + --- --- --- + t := r.src + it, _, err := r.x.Seek([]interface{}{r.lval}) + if err != nil { + return noEOF(err) + } + + var ok bool + for { + k, h, err := it.Next() + if err != nil { + return noEOF(err) + } + + if !ok { + val, err := expand1(k[0], nil) + if err != nil { + return err + } + + if collate1(val, r.lval) == 0 { + continue + } + + ok = true + } + + val, err := expand1(k[0], nil) + if err != nil { + return err + } + + if collate1(val, r.hval) > 0 { + return nil + } + + id, data, err := t.row(ctx, h) + if err != nil { + return err + } + + if more, err := f(id, data); err != nil || !more { + return err + } + } +} + +func (r *indexPlan) doIntervalCC(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { + // nil, nil, ..., L-1, L-1, L, L, L+1, L+1, ..., H-1, H-1, H, H, H+1, H+1, ... + // --- --- --- --- --- + + +++ +++ +++ +++ +++ + + --- --- --- + t := r.src + it, _, err := r.x.Seek([]interface{}{r.lval}) + if err != nil { + return noEOF(err) + } + + for { + k, h, err := it.Next() + if err != nil { + return noEOF(err) + } + + val, err := expand1(k[0], nil) + if err != nil { + return err + } + + if collate1(val, r.hval) > 0 { + return nil + } + + id, data, err := t.row(ctx, h) + if err != nil { + return err + } + + if more, err := f(id, data); err != nil || !more { + return err + } + } +} + +func (r *indexPlan) doIntervalCO(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { + // nil, nil, ..., L-1, L-1, L, L, L+1, L+1, ..., H-1, H-1, H, H, H+1, H+1, ... + // --- --- --- --- --- + + +++ +++ +++ +++ +++ - - --- --- --- + t := r.src + it, _, err := r.x.Seek([]interface{}{r.lval}) + if err != nil { + return noEOF(err) + } + + for { + k, h, err := it.Next() + if err != nil { + return noEOF(err) + } + + val, err := expand1(k[0], nil) + if err != nil { + return err + } + + if collate1(val, r.hval) >= 0 { + return nil + } + + id, data, err := t.row(ctx, h) + if err != nil { + return err + } + + if more, err := f(id, data); err != nil || !more { + return err + } + } +} + +func (r *indexPlan) doLe(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { + // nil, nil, ..., H-1, H-1, H, H, H+1, H+1, ... + // --- --- +++ +++ +++ + + --- --- + t := r.src + it, err := r.x.SeekFirst() + if err != nil { + return noEOF(err) + } + + for { + k, h, err := it.Next() + if err != nil { + return noEOF(err) + } + + if k == nil || k[0] == nil { + continue + } + + val, err := expand1(k[0], nil) + if err != nil { + return err + } + + if collate1(val, r.hval) > 0 { + return nil + } + + id, data, err := t.row(ctx, h) + if err != nil { + return err + } + + if more, err := f(id, data); err != nil || !more { + return err + } + } +} + +func (r *indexPlan) doLt(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { + // nil, nil, ..., H-1, H-1, H, H, H+1, H+1, ... + // --- --- +++ +++ +++ - - --- --- + t := r.src + it, err := r.x.SeekFirst() + if err != nil { + return noEOF(err) + } + + for { + k, h, err := it.Next() + if err != nil { + return noEOF(err) + } + + if k == nil || k[0] == nil { + continue + } + + val, err := expand1(k[0], nil) + if err != nil { + return err + } + + if collate1(val, r.hval) >= 0 { + return nil + } + + id, data, err := t.row(ctx, h) + if err != nil { + return err + } + + if more, err := f(id, data); err != nil || !more { + return err + } + } +} + +func (r *indexPlan) doEq(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { + // nil, nil, ..., L-1, L-1, L, L, L+1, L+1, ... + // --- --- --- --- --- + + --- --- --- + t := r.src + it, _, err := r.x.Seek([]interface{}{r.lval}) + if err != nil { + return noEOF(err) + } + + for { + k, h, err := it.Next() + if err != nil { + return noEOF(err) + } + + val, err := expand1(k[0], nil) + if err != nil { + return err + } + + if collate1(val, r.lval) != 0 { + return nil + } + + id, data, err := t.row(ctx, h) + if err != nil { + return err + } + + if more, err := f(id, data); err != nil || !more { + return err + } + } +} + +func (r *indexPlan) doNe(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { + // nil, nil, ..., L-1, L-1, L, L, L+1, L+1, ... + // --- --- +++ +++ +++ - - +++ +++ +++ + t := r.src + it, err := r.x.SeekFirst() + if err != nil { + return noEOF(err) + } + + for { + k, h, err := it.Next() + if err != nil { + return noEOF(err) + } + + if k == nil || k[0] == nil { + continue + } + + val, err := expand1(k[0], nil) + if err != nil { + return err + } + + if collate1(val, r.hval) == 0 { + continue + } + + id, data, err := t.row(ctx, h) + if err != nil { + return err + } + + if more, err := f(id, data); err != nil || !more { + return err + } + } +} + +func (r *indexPlan) doIsNull(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { + // nil, nil, ... + // +++ +++ --- + t := r.src + it, err := r.x.SeekFirst() + if err != nil { + return noEOF(err) + } + + for { + k, h, err := it.Next() + if err != nil { + return noEOF(err) + } + + if k != nil && k[0] != nil { + return nil + } + + id, data, err := t.row(ctx, h) + if err != nil { + return err + } + + if more, err := f(id, data); err != nil || !more { + return err + } + } +} + +func (r *indexPlan) doIsNotNull(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { + // nil, nil, ... + // --- --- +++ + t := r.src + it, _, err := r.x.Seek([]interface{}{false}) // lldb collates false right after NULL. + if err != nil { + return noEOF(err) + } + + for { + _, h, err := it.Next() + if err != nil { + return noEOF(err) + } + + id, data, err := t.row(ctx, h) + if err != nil { + return err + } + + if more, err := f(id, data); err != nil || !more { + return err + } + } +} + +func (r *indexPlan) doFalse(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { + t := r.src + it, _, err := r.x.Seek([]interface{}{false}) + if err != nil { + return noEOF(err) + } + + for { + k, h, err := it.Next() + if err != nil { + return noEOF(err) + } + + b, ok := k[0].(bool) + if !ok || b { + return nil + } + + id, data, err := t.row(ctx, h) + if err != nil { + return err + } + + if more, err := f(id, data); err != nil || !more { + return err + } + } +} + +func (r *indexPlan) doTrue(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { + t := r.src + it, _, err := r.x.Seek([]interface{}{true}) + if err != nil { + return noEOF(err) + } + + for { + k, h, err := it.Next() + if err != nil { + return noEOF(err) + } + + if _, ok := k[0].(bool); !ok { + return nil + } + + id, data, err := t.row(ctx, h) + if err != nil { + return err + } + + if more, err := f(id, data); err != nil || !more { + return err + } + } +} + +func (r *indexPlan) do(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { + switch r.kind { + case indexEq: + return r.doEq(ctx, f) + case indexGe: + return r.doGe(ctx, f) + case indexGt: + return r.doGt(ctx, f) + case indexLe: + return r.doLe(ctx, f) + case indexLt: + return r.doLt(ctx, f) + case indexNe: + return r.doNe(ctx, f) + case indexIsNull: + return r.doIsNull(ctx, f) + case indexIsNotNull: + return r.doIsNotNull(ctx, f) + case indexFalse: + return r.doFalse(ctx, f) + case indexTrue: + return r.doTrue(ctx, f) + case indexIntervalOO: + return r.doInterval00(ctx, f) + case indexIntervalCC: + return r.doIntervalCC(ctx, f) + case indexIntervalOC: + return r.doIntervalOC(ctx, f) + case indexIntervalCO: + return r.doIntervalCO(ctx, f) + default: + //dbg("", r.kind) + panic("internal error 072") + } +} + +func (r *indexPlan) explain(w strutil.Formatter) { + s := "" + if r.kind == indexFalse { + s = "!" + } + w.Format("┌Iterate all rows of table %q using index %q where %s%s", r.src.name, r.xname, s, r.cname) + switch r.kind { + case indexEq: + w.Format(" == %v", value{r.lval}) + case indexGe: + w.Format(" >= %v", value{r.lval}) + case indexGt: + w.Format(" > %v", value{r.lval}) + case indexLe: + w.Format(" <= %v", value{r.hval}) + case indexLt: + w.Format(" < %v", value{r.hval}) + case indexNe: + w.Format(" != %v", value{r.lval}) + case indexIsNull: + w.Format(" IS NULL") + case indexIsNotNull: + w.Format(" IS NOT NULL") + case indexFalse, indexTrue: + // nop + case indexIntervalOO: + w.Format(" > %v && %s < %v", value{r.lval}, r.cname, value{r.hval}) + case indexIntervalCC: + w.Format(" >= %v && %s <= %v", value{r.lval}, r.cname, value{r.hval}) + case indexIntervalCO: + w.Format(" >= %v && %s < %v", value{r.lval}, r.cname, value{r.hval}) + case indexIntervalOC: + w.Format(" > %v && %s <= %v", value{r.lval}, r.cname, value{r.hval}) + default: + //dbg("", r.kind) + panic("internal error 073") + } + w.Format("\n└Output field names %v\n", qnames(r.fieldNames())) +} + +func (r *indexPlan) fieldNames() []string { return r.src.fieldNames() } + +func (r *indexPlan) filterEq(binOp2 int, val interface{}) (plan, []string, error) { + switch binOp2 { + case eq: + if collate1(r.lval, val) == 0 { + return r, nil, nil + } + + return &nullPlan{r.fieldNames()}, nil, nil + case ge: + if collate1(r.lval, val) >= 0 { + return r, nil, nil + } + + return &nullPlan{r.fieldNames()}, nil, nil + case '>': + if collate1(r.lval, val) > 0 { + return r, nil, nil + } + + return &nullPlan{r.fieldNames()}, nil, nil + case le: + if collate1(r.lval, val) <= 0 { + return r, nil, nil + } + + return &nullPlan{r.fieldNames()}, nil, nil + case '<': + if collate1(r.lval, val) < 0 { + return r, nil, nil + } + + return &nullPlan{r.fieldNames()}, nil, nil + case neq: + if collate1(r.lval, val) != 0 { + return r, nil, nil + } + + return &nullPlan{r.fieldNames()}, nil, nil + } + return nil, nil, nil +} + +func (r *indexPlan) filterGe(binOp2 int, val interface{}) (plan, []string, error) { + switch binOp2 { + case eq: + if collate1(r.lval, val) <= 0 { + r.lval = val + r.kind = indexEq + return r, nil, nil + } + + return &nullPlan{r.fieldNames()}, nil, nil + case ge: + if collate1(r.lval, val) < 0 { + r.lval = val + } + return r, nil, nil + case '>': + if collate1(r.lval, val) <= 0 { + r.lval = val + r.kind = indexGt + } + return r, nil, nil + case le: + switch c := collate1(r.lval, val); { + case c < 0: + r.hval = val + r.kind = indexIntervalCC + return r, nil, nil + case c == 0: + r.kind = indexEq + return r, nil, nil + default: // c > 0 + return &nullPlan{r.fieldNames()}, nil, nil + } + case '<': + if collate1(r.lval, val) < 0 { + r.hval = val + r.kind = indexIntervalCO + return r, nil, nil + } + + return &nullPlan{r.fieldNames()}, nil, nil + case neq: + switch c := collate1(r.lval, val); { + case c < 0: + //MAYBE ORed intervals + case c == 0: + r.kind = indexGt + return r, nil, nil + default: // c > 0 + return r, nil, nil + } + } + return nil, nil, nil +} + +func (r *indexPlan) filterGt(binOp2 int, val interface{}) (plan, []string, error) { + switch binOp2 { + case eq: + if collate1(r.lval, val) < 0 { + r.lval = val + r.kind = indexEq + return r, nil, nil + } + + return &nullPlan{r.fieldNames()}, nil, nil + case ge: + if collate1(r.lval, val) < 0 { + r.lval = val + r.kind = indexGe + } + return r, nil, nil + case '>': + if collate1(r.lval, val) < 0 { + r.lval = val + } + return r, nil, nil + case le: + if collate1(r.lval, val) < 0 { + r.hval = val + r.kind = indexIntervalOC + return r, nil, nil + } + + return &nullPlan{r.fieldNames()}, nil, nil + case '<': + if collate1(r.lval, val) < 0 { + r.hval = val + r.kind = indexIntervalOO + return r, nil, nil + } + + return &nullPlan{r.fieldNames()}, nil, nil + case neq: + if collate1(r.lval, val) >= 0 { + return r, nil, nil + } + } + return nil, nil, nil +} + +func (r *indexPlan) filterLe(binOp2 int, val interface{}) (plan, []string, error) { + switch binOp2 { + case eq: + if collate1(r.hval, val) >= 0 { + r.lval = val + r.kind = indexEq + return r, nil, nil + } + + return &nullPlan{r.fieldNames()}, nil, nil + case ge: + switch c := collate1(r.hval, val); { + case c < 0: + return &nullPlan{r.fieldNames()}, nil, nil + case c == 0: + r.lval = val + r.kind = indexEq + return r, nil, nil + default: // c > 0 + r.lval = val + r.kind = indexIntervalCC + return r, nil, nil + } + case '>': + if collate1(r.hval, val) > 0 { + r.lval = val + r.kind = indexIntervalOC + return r, nil, nil + } + + return &nullPlan{r.fieldNames()}, nil, nil + case le: + if collate1(r.hval, val) > 0 { + r.hval = val + } + return r, nil, nil + case '<': + if collate1(r.hval, val) >= 0 { + r.hval = val + r.kind = indexLt + } + return r, nil, nil + case neq: + switch c := collate1(r.hval, val); { + case c < 0: + return r, nil, nil + case c == 0: + r.kind = indexLt + return r, nil, nil + default: // c > 0 + //bop + } + } + return nil, nil, nil +} + +func (r *indexPlan) filterLt(binOp2 int, val interface{}) (plan, []string, error) { + switch binOp2 { + case eq: + if collate1(r.hval, val) > 0 { + r.lval = val + r.kind = indexEq + return r, nil, nil + } + + return &nullPlan{r.fieldNames()}, nil, nil + case ge: + if collate1(r.hval, val) > 0 { + r.lval = val + r.kind = indexIntervalCO + return r, nil, nil + } + + return &nullPlan{r.fieldNames()}, nil, nil + case '>': + if collate1(r.hval, val) > 0 { + r.lval = val + r.kind = indexIntervalOO + return r, nil, nil + } + + return &nullPlan{r.fieldNames()}, nil, nil + case le: + if collate1(r.hval, val) > 0 { + r.hval = val + r.kind = indexLe + } + return r, nil, nil + case '<': + if collate1(r.hval, val) > 0 { + r.hval = val + } + return r, nil, nil + case neq: + if collate1(r.hval, val) > 0 { + return nil, nil, nil + } + + return r, nil, nil + } + return nil, nil, nil +} + +func (r *indexPlan) filterCC(binOp2 int, val interface{}) (plan, []string, error) { + switch binOp2 { + case eq: + if collate1(val, r.lval) < 0 || collate1(val, r.hval) > 0 { + return &nullPlan{r.fieldNames()}, nil, nil + } + + r.lval = val + r.kind = indexEq + return r, nil, nil + case ge: + if collate1(val, r.lval) <= 0 { + return r, nil, nil + } + + switch c := collate1(val, r.hval); { + case c < 0: + r.lval = val + return r, nil, nil + case c == 0: + r.lval = val + r.kind = indexEq + return r, nil, nil + default: + return &nullPlan{r.fieldNames()}, nil, nil + } + case '>': + switch c := collate1(val, r.lval); { + case c < 0: + return r, nil, nil + case c == 0: + r.kind = indexIntervalOC + return r, nil, nil + default: + if collate1(val, r.hval) < 0 { + r.lval = val + r.kind = indexIntervalOC + return r, nil, nil + } + + return &nullPlan{r.fieldNames()}, nil, nil + } + case le: + switch c := collate1(val, r.lval); { + case c < 0: + return &nullPlan{r.fieldNames()}, nil, nil + case c == 0: + r.kind = indexEq + return r, nil, nil + default: + if collate1(val, r.hval) < 0 { + r.hval = val + } + return r, nil, nil + } + case '<': + if collate1(val, r.lval) <= 0 { + return &nullPlan{r.fieldNames()}, nil, nil + } + + if collate1(val, r.hval) <= 0 { + r.hval = val + r.kind = indexIntervalCO + } + return r, nil, nil + case neq: + switch c := collate1(val, r.lval); { + case c < 0: + return r, nil, nil + case c == 0: + r.kind = indexIntervalOC + return r, nil, nil + default: + switch c := collate1(val, r.hval); { + case c == 0: + r.kind = indexIntervalCO + return r, nil, nil + case c > 0: + return r, nil, nil + default: + return nil, nil, nil + } + } + } + return nil, nil, nil +} + +func (r *indexPlan) filterOC(binOp2 int, val interface{}) (plan, []string, error) { + switch binOp2 { + case eq: + if collate1(val, r.lval) <= 0 || collate1(val, r.hval) > 0 { + return &nullPlan{r.fieldNames()}, nil, nil + } + + r.lval = val + r.kind = indexEq + return r, nil, nil + case ge: + if collate1(val, r.lval) <= 0 { + return r, nil, nil + } + + switch c := collate1(val, r.hval); { + case c < 0: + r.lval = val + r.kind = indexIntervalCC + return r, nil, nil + case c == 0: + r.lval = val + r.kind = indexEq + return r, nil, nil + default: + return &nullPlan{r.fieldNames()}, nil, nil + } + case '>': + if collate1(val, r.lval) <= 0 { + return r, nil, nil + } + + if collate1(val, r.hval) < 0 { + r.lval = val + return r, nil, nil + } + + return &nullPlan{r.fieldNames()}, nil, nil + case le: + if collate1(val, r.lval) <= 0 { + return &nullPlan{r.fieldNames()}, nil, nil + } + + if collate1(val, r.hval) < 0 { + r.hval = val + } + return r, nil, nil + case '<': + if collate1(val, r.lval) <= 0 { + return &nullPlan{r.fieldNames()}, nil, nil + } + + switch c := collate1(val, r.hval); { + case c < 0: + r.hval = val + r.kind = indexIntervalOO + case c == 0: + r.kind = indexIntervalOO + } + return r, nil, nil + case neq: + if collate1(val, r.lval) <= 0 { + return r, nil, nil + } + + switch c := collate1(val, r.hval); { + case c < 0: + return nil, nil, nil + case c == 0: + r.kind = indexIntervalOO + return r, nil, nil + default: + return r, nil, nil + } + } + return nil, nil, nil +} + +func (r *indexPlan) filterOO(binOp2 int, val interface{}) (plan, []string, error) { + switch binOp2 { + case eq: + if collate1(val, r.lval) <= 0 || collate1(val, r.hval) >= 0 { + return &nullPlan{r.fieldNames()}, nil, nil + } + + r.lval = val + r.kind = indexEq + return r, nil, nil + case ge: + if collate1(val, r.lval) <= 0 { + return r, nil, nil + } + + if collate1(val, r.hval) < 0 { + r.lval = val + r.kind = indexIntervalCO + return r, nil, nil + } + + return &nullPlan{r.fieldNames()}, nil, nil + case '>': + if collate1(val, r.lval) <= 0 { + return r, nil, nil + } + + if collate1(val, r.hval) < 0 { + r.lval = val + return r, nil, nil + } + + return &nullPlan{r.fieldNames()}, nil, nil + case le: + if collate1(val, r.lval) <= 0 { + return &nullPlan{r.fieldNames()}, nil, nil + } + + if collate1(val, r.hval) < 0 { + r.hval = val + r.kind = indexIntervalOC + } + return r, nil, nil + case '<': + if collate1(val, r.lval) <= 0 { + return &nullPlan{r.fieldNames()}, nil, nil + } + + if collate1(val, r.hval) < 0 { + r.hval = val + } + return r, nil, nil + case neq: + if collate1(val, r.lval) <= 0 || collate1(val, r.hval) >= 0 { + return r, nil, nil + } + + return nil, nil, nil + } + return nil, nil, nil +} + +func (r *indexPlan) filterCO(binOp2 int, val interface{}) (plan, []string, error) { + switch binOp2 { + case eq: + if collate1(val, r.lval) < 0 || collate1(val, r.hval) >= 0 { + return &nullPlan{r.fieldNames()}, nil, nil + } + + r.lval = val + r.kind = indexEq + return r, nil, nil + case ge: + if collate1(val, r.lval) <= 0 { + return r, nil, nil + } + + if collate1(val, r.hval) < 0 { + r.lval = val + return r, nil, nil + } + + return &nullPlan{r.fieldNames()}, nil, nil + case '>': + switch c := collate1(val, r.lval); { + case c < 0: + return r, nil, nil + case c == 0: + r.kind = indexIntervalOO + return r, nil, nil + default: + if collate1(val, r.hval) < 0 { + r.lval = val + r.kind = indexIntervalOO + return r, nil, nil + } + + return &nullPlan{r.fieldNames()}, nil, nil + } + case le: + switch c := collate1(val, r.lval); { + case c < 0: + return &nullPlan{r.fieldNames()}, nil, nil + case c == 0: + r.kind = indexEq + return r, nil, nil + default: + if collate1(val, r.hval) < 0 { + r.hval = val + r.kind = indexIntervalCC + } + return r, nil, nil + } + case '<': + if collate1(val, r.lval) <= 0 { + return &nullPlan{r.fieldNames()}, nil, nil + } + + if collate1(val, r.hval) < 0 { + r.hval = val + } + return r, nil, nil + case neq: + switch c := collate1(val, r.lval); { + case c < 0: + return r, nil, nil + case c == 0: + r.kind = indexIntervalOO + return r, nil, nil + default: + if collate1(val, r.hval) < 0 { + return nil, nil, nil + } + + return r, nil, nil + } + } + return nil, nil, nil +} + +func (r *indexPlan) filterNe(binOp2 int, val interface{}) (plan, []string, error) { + switch binOp2 { + case eq: + if collate1(val, r.lval) != 0 { + r.lval = val + r.kind = indexEq + return r, nil, nil + } + + return &nullPlan{r.fieldNames()}, nil, nil + case ge: + switch c := collate1(val, r.lval); { + case c < 0: + return nil, nil, nil //TODO + case c == 0: + r.kind = indexGt + return r, nil, nil + default: + r.lval = val + r.kind = indexGe + return r, nil, nil + } + case '>': + if collate1(val, r.lval) < 0 { + return nil, nil, nil //TODO + } + + r.lval = val + r.kind = indexGt + return r, nil, nil + case le: + switch c := collate1(val, r.lval); { + case c < 0: + r.hval = val + r.kind = indexLe + return r, nil, nil + case c == 0: + r.kind = indexLt + return r, nil, nil + default: + return nil, nil, nil //TODO + } + case '<': + if collate1(val, r.lval) <= 0 { + r.hval = val + r.kind = indexLt + return r, nil, nil + } + + return nil, nil, nil //TODO + case neq: + if collate1(val, r.lval) == 0 { + return r, nil, nil + } + + return nil, nil, nil + } + return nil, nil, nil +} + +func (r *indexPlan) filter(expr expression) (plan, []string, error) { + switch x := expr.(type) { + case *binaryOperation: + ok, cname, val, err := x.isIdentRelOpVal() + if err != nil { + return nil, nil, err + } + + if !ok || r.cname != cname { + break + } + + if val, err = typeCheck1(val, findCol(r.src.cols, cname)); err != nil { + return nil, nil, err + } + + switch r.kind { + case indexEq: // [L] + return r.filterEq(x.op, val) + case indexGe: // [L, ...) + return r.filterGe(x.op, val) + case indexGt: // (L, ...) + return r.filterGt(x.op, val) + case indexIntervalCC: // [L, H] + return r.filterCC(x.op, val) + case indexIntervalCO: // [L, H) + return r.filterCO(x.op, val) + case indexIntervalOC: // (L, H] + return r.filterOC(x.op, val) + case indexIntervalOO: // (L, H) + return r.filterOO(x.op, val) + case indexLe: // (..., H] + return r.filterLe(x.op, val) + case indexLt: // (..., H) + return r.filterLt(x.op, val) + case indexNe: // (L) + return r.filterNe(x.op, val) + } + case *ident: + cname := x.s + if r.cname != cname { + break + } + + switch r.kind { + case indexFalse: // [false] + return &nullPlan{r.fieldNames()}, nil, nil + case indexTrue: // [true] + return r, nil, nil + } + case *unaryOperation: + if x.op != '!' { + break + } + + operand, ok := x.v.(*ident) + if !ok { + break + } + + cname := operand.s + if r.cname != cname { + break + } + + switch r.kind { + case indexFalse: // [false] + return r, nil, nil + case indexTrue: // [true] + return &nullPlan{r.fieldNames()}, nil, nil + } + } + + return nil, nil, nil +} + +func (r *indexPlan) hasID() bool { return true } + +type explainDefaultPlan struct { + s stmt +} + +func (r *explainDefaultPlan) hasID() bool { return false } + +func (r *explainDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (more bool, err error)) error { + var buf bytes.Buffer + switch x := r.s.(type) { + default: + w := strutil.IndentFormatter(&buf, "│ ") + x.explain(ctx, w) + } + + a := bytes.Split(buf.Bytes(), []byte{'\n'}) + for _, v := range a[:len(a)-1] { + if more, err := f(nil, []interface{}{string(v)}); !more || err != nil { + return err + } + } + return nil +} + +func (r *explainDefaultPlan) explain(w strutil.Formatter) { + return +} + +func (r *explainDefaultPlan) fieldNames() []string { + return []string{""} +} + +func (r *explainDefaultPlan) filter(expr expression) (plan, []string, error) { + return nil, nil, nil +} + +type filterDefaultPlan struct { + plan + expr expression + is []string +} + +func (r *filterDefaultPlan) hasID() bool { return r.plan.hasID() } + +func (r *filterDefaultPlan) explain(w strutil.Formatter) { + r.plan.explain(w) + w.Format("┌Filter on %v\n", r.expr) + if len(r.is) != 0 { + w.Format("│Possibly useful indices\n") + m := map[string]bool{} + for _, v := range r.is { + if !m[v] { + m[v] = true + n := "" + for _, r := range v { + if r >= '0' && r <= '9' || r >= 'a' && r <= 'z' || r >= 'A' && r <= 'Z' || r == '_' { + n += string(r) + continue + } + + n += "_" + } + for strings.Contains(n, "__") { + n = strings.Replace(n, "__", "_", -1) + } + for strings.HasSuffix(n, "_") { + n = n[:len(n)-1] + } + w.Format("│CREATE INDEX x%s ON %s;\n", n, v) + } + } + } + w.Format("└Output field names %v\n", qnames(r.plan.fieldNames())) +} + +func (r *filterDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (bool, error)) (err error) { + m := map[interface{}]interface{}{} + fields := r.plan.fieldNames() + return r.plan.do(ctx, func(rid interface{}, data []interface{}) (bool, error) { + for i, v := range fields { + m[v] = data[i] + } + m["$id"] = rid + val, err := r.expr.eval(ctx, m) + if err != nil { + return false, err + } + + if val == nil { + return true, nil + } + + x, ok := val.(bool) + if !ok { + return false, fmt.Errorf("invalid boolean expression %s (value of type %T)", val, val) + } + + if !x { + return true, nil + } + + return f(rid, data) + }) +} + +type crossJoinDefaultPlan struct { + rsets []plan + names []string + fields []string +} + +func (r *crossJoinDefaultPlan) hasID() bool { return false } + +func (r *crossJoinDefaultPlan) explain(w strutil.Formatter) { + w.Format("┌Compute Cartesian product of%i\n") + for i, v := range r.rsets { + sel := !isTableOrIndex(v) + if sel { + w.Format("┌Iterate all rows of virtual table %q%i\n", r.names[i]) + } + v.explain(w) + if sel { + w.Format("%u└Output field names %v\n", qnames(v.fieldNames())) + } + } + w.Format("%u└Output field names %v\n", qnames(r.fields)) +} + +func (r *crossJoinDefaultPlan) filter(expr expression) (plan, []string, error) { + var is []string + for i, v := range r.names { + e2, err := expr.clone(nil, v) + if err != nil { + return nil, nil, err + } + + p2, is2, err := r.rsets[i].filter(e2) + is = append(is, is2...) + if err != nil { + return nil, nil, err + } + + if p2 != nil { + r.rsets[i] = p2 + return r, is, nil + } + } + return nil, is, nil +} + +func (r *crossJoinDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (bool, error)) error { + if len(r.rsets) == 1 { + return r.rsets[0].do(ctx, f) + } + + ids := map[string]interface{}{} + var g func([]interface{}, []plan, int) error + g = func(prefix []interface{}, rsets []plan, x int) (err error) { + return rsets[0].do(ctx, func(id interface{}, in []interface{}) (bool, error) { + ids[r.names[x]] = id + if len(rsets) > 1 { + return true, g(append(prefix, in...), rsets[1:], x+1) + } + + return f(ids, append(prefix, in...)) + }) + } + return g(nil, r.rsets, 0) +} + +func (r *crossJoinDefaultPlan) fieldNames() []string { return r.fields } + +type distinctDefaultPlan struct { + src plan + fields []string +} + +func (r *distinctDefaultPlan) hasID() bool { return false } + +func (r *distinctDefaultPlan) explain(w strutil.Formatter) { + r.src.explain(w) + w.Format("┌Compute distinct rows\n└Output field names %v\n", r.fields) +} + +func (r *distinctDefaultPlan) filter(expr expression) (plan, []string, error) { + return nil, nil, nil +} + +func (r *distinctDefaultPlan) fieldNames() []string { return r.fields } + +func (r *distinctDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (bool, error)) (err error) { + t, err := ctx.db.store.CreateTemp(true) + if err != nil { + return + } + + defer func() { + if derr := t.Drop(); derr != nil && err == nil { + err = derr + } + }() + + if err = r.src.do(ctx, func(id interface{}, in []interface{}) (bool, error) { + if err = t.Set(in, nil); err != nil { + return false, err + } + + return true, nil + }); err != nil { + return + } + + var data []interface{} + more := true + it, err := t.SeekFirst() + for more && err == nil { + data, _, err = it.Next() + if err != nil { + break + } + + more, err = f(nil, data) + } + return noEOF(err) +} + +type groupByDefaultPlan struct { + colNames []string + src plan + fields []string +} + +func (r *groupByDefaultPlan) hasID() bool { return false } + +func (r *groupByDefaultPlan) explain(w strutil.Formatter) { + r.src.explain(w) + switch { + case len(r.colNames) == 0: //TODO this case should not exist for this plan, should become tableDefaultPlan + w.Format("┌Group by distinct rows") + default: + w.Format("┌Group by") + for _, v := range r.colNames { + w.Format(" %s,", v) + } + } + w.Format("\n└Output field names %v\n", qnames(r.fields)) +} + +func (r *groupByDefaultPlan) filter(expr expression) (plan, []string, error) { + return nil, nil, nil +} + +func (r *groupByDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (bool, error)) (err error) { + t, err := ctx.db.store.CreateTemp(true) + if err != nil { + return + } + + defer func() { + if derr := t.Drop(); derr != nil && err == nil { + err = derr + } + }() + + var gcols []*col + var cols []*col + m := map[string]int{} + for i, v := range r.src.fieldNames() { + m[v] = i + } + for _, c := range r.colNames { + i, ok := m[c] + if !ok { + return fmt.Errorf("unknown field %s", c) + } + + gcols = append(gcols, &col{name: c, index: i}) + } + k := make([]interface{}, len(r.colNames)) //TODO optimize when len(r.cols) == 0, should become tableDefaultPlan + if err = r.src.do(ctx, func(rid interface{}, in []interface{}) (more bool, err error) { + infer(in, &cols) + for i, c := range gcols { + k[i] = in[c.index] + } + h0, err := t.Get(k) + if err != nil { + return false, err + } + + var h int64 + if len(h0) != 0 { + h, _ = h0[0].(int64) + } + nh, err := t.Create(append([]interface{}{h, nil}, in...)...) + if err != nil { + return false, err + } + + for i, c := range gcols { + k[i] = in[c.index] + } + err = t.Set(k, []interface{}{nh}) + if err != nil { + return false, err + } + + return true, nil + }); err != nil { + return + } + + for i, v := range r.src.fieldNames()[:len(cols)] { + cols[i].name = v + cols[i].index = i + } + if more, err := f(nil, []interface{}{t, cols}); !more || err != nil { + return err + } + + it, err := t.SeekFirst() + more := true + var data []interface{} + for more && err == nil { + if _, data, err = it.Next(); err != nil { + break + } + + more, err = f(nil, data) + } + return noEOF(err) +} + +func (r *groupByDefaultPlan) fieldNames() []string { return r.fields } + +type selectIndexDefaultPlan struct { + nm string + x interface{} +} + +func (r *selectIndexDefaultPlan) hasID() bool { return false } + +func (r *selectIndexDefaultPlan) explain(w strutil.Formatter) { + w.Format("┌Iterate all values of index %q\n└Output field names N/A\n", r.nm) +} + +func (r *selectIndexDefaultPlan) filter(expr expression) (plan, []string, error) { + return nil, nil, nil +} + +func (r *selectIndexDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (bool, error)) (err error) { + var x btreeIndex + switch ix := r.x.(type) { + case *indexedCol: + x = ix.x + case *index2: + x = ix.x + default: + panic("internal error 007") + } + + en, err := x.SeekFirst() + if err != nil { + return noEOF(err) + } + + var id int64 + for { + k, _, err := en.Next() + if err != nil { + return noEOF(err) + } + + id++ + if more, err := f(id, k); !more || err != nil { + return err + } + } +} + +func (r *selectIndexDefaultPlan) fieldNames() []string { + return []string{r.nm} +} + +type limitDefaultPlan struct { + expr expression + src plan + fields []string +} + +func (r *limitDefaultPlan) hasID() bool { return r.src.hasID() } + +func (r *limitDefaultPlan) explain(w strutil.Formatter) { + r.src.explain(w) + w.Format("┌Pass first %v records\n└Output field names %v\n", r.expr, r.fields) +} + +func (r *limitDefaultPlan) filter(expr expression) (plan, []string, error) { + return nil, nil, nil +} + +func (r *limitDefaultPlan) fieldNames() []string { return r.fields } + +func (r *limitDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (more bool, err error)) (err error) { + m := map[interface{}]interface{}{} + var eval bool + var lim uint64 + return r.src.do(ctx, func(rid interface{}, in []interface{}) (more bool, err error) { + if !eval { + for i, fld := range r.fields { + if fld != "" { + m[fld] = in[i] + } + } + m["$id"] = rid + val, err := r.expr.eval(ctx, m) + if err != nil { + return false, err + } + + if val == nil { + return true, nil + } + + if lim, err = limOffExpr(val); err != nil { + return false, err + } + + eval = true + } + switch lim { + case 0: + return false, nil + default: + lim-- + return f(rid, in) + } + }) +} + +type offsetDefaultPlan struct { + expr expression + src plan + fields []string +} + +func (r *offsetDefaultPlan) hasID() bool { return r.src.hasID() } + +func (r *offsetDefaultPlan) explain(w strutil.Formatter) { + r.src.explain(w) + w.Format("┌Skip first %v records\n└Output field names %v\n", r.expr, qnames(r.fields)) +} + +func (r *offsetDefaultPlan) filter(expr expression) (plan, []string, error) { + return nil, nil, nil +} + +func (r *offsetDefaultPlan) fieldNames() []string { return r.fields } + +func (r *offsetDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (bool, error)) error { + m := map[interface{}]interface{}{} + var eval bool + var off uint64 + return r.src.do(ctx, func(rid interface{}, in []interface{}) (bool, error) { + if !eval { + for i, fld := range r.fields { + if fld != "" { + m[fld] = in[i] + } + } + m["$id"] = rid + val, err := r.expr.eval(ctx, m) + if err != nil { + return false, err + } + + if val == nil { + return true, nil + } + + if off, err = limOffExpr(val); err != nil { + return false, err + } + + eval = true + } + if off > 0 { + off-- + return true, nil + } + + return f(rid, in) + }) +} + +type orderByDefaultPlan struct { + asc bool + by []expression + src plan + fields []string +} + +func (r *orderByDefaultPlan) hasID() bool { return r.src.hasID() } + +func (r *orderByDefaultPlan) explain(w strutil.Formatter) { + r.src.explain(w) + w.Format("┌Order%s by", map[bool]string{false: " descending"}[r.asc]) + for _, v := range r.by { + w.Format(" %s,", v) + } + w.Format("\n└Output field names %v\n", qnames(r.fields)) +} + +func (r *orderByDefaultPlan) filter(expr expression) (plan, []string, error) { + return nil, nil, nil +} + +func (r *orderByDefaultPlan) fieldNames() []string { return r.fields } + +func (r *orderByDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (bool, error)) (err error) { + t, err := ctx.db.store.CreateTemp(r.asc) + if err != nil { + return + } + + defer func() { + if derr := t.Drop(); derr != nil && err == nil { + err = derr + } + }() + + m := map[interface{}]interface{}{} + flds := r.fields + k := make([]interface{}, len(r.by)+1) + id := int64(-1) + if err = r.src.do(ctx, func(rid interface{}, in []interface{}) (bool, error) { + id++ + for i, fld := range flds { + if fld != "" { + m[fld] = in[i] + } + } + m["$id"] = rid + for i, expr := range r.by { + val, err := expr.eval(ctx, m) + if err != nil { + return false, err + } + + if val != nil { + val, ordered, err := isOrderedType(val) + if err != nil { + return false, err + } + + if !ordered { + return false, fmt.Errorf("cannot order by %v (type %T)", val, val) + + } + } + + k[i] = val + } + k[len(r.by)] = id + if err = t.Set(k, in); err != nil { + return false, err + } + + return true, nil + }); err != nil { + return + } + + it, err := t.SeekFirst() + if err != nil { + return noEOF(err) + } + + var data []interface{} + more := true + for more && err == nil { + if _, data, err = it.Next(); err != nil { + break + } + + more, err = f(nil, data) + } + return noEOF(err) +} + +type selectFieldsDefaultPlan struct { + flds []*fld + src plan + fields []string +} + +func (r *selectFieldsDefaultPlan) hasID() bool { return r.src.hasID() } + +func (r *selectFieldsDefaultPlan) explain(w strutil.Formatter) { + //TODO check for non existing fields + r.src.explain(w) + w.Format("┌Evaluate") + for _, v := range r.flds { + w.Format(" %s as %s,", v.expr, fmt.Sprintf("%q", v.name)) + } + w.Format("\n└Output field names %v\n", qnames(r.fields)) +} + +func (r *selectFieldsDefaultPlan) filter(expr expression) (plan, []string, error) { + return nil, nil, nil +} + +func (r *selectFieldsDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (bool, error)) error { + fields := r.src.fieldNames() + m := map[interface{}]interface{}{} + return r.src.do(ctx, func(rid interface{}, in []interface{}) (bool, error) { + for i, nm := range fields { + if nm != "" { + m[nm] = in[i] + } + } + m["$id"] = rid + out := make([]interface{}, len(r.flds)) + for i, fld := range r.flds { + var err error + if out[i], err = fld.expr.eval(ctx, m); err != nil { + return false, err + } + } + return f(rid, out) + }) +} + +func (r *selectFieldsDefaultPlan) fieldNames() []string { return r.fields } + +type selectFieldsGroupPlan struct { + flds []*fld + src *groupByDefaultPlan + fields []string +} + +func (r *selectFieldsGroupPlan) hasID() bool { return false } + +func (r *selectFieldsGroupPlan) explain(w strutil.Formatter) { + //TODO check for non existing fields + r.src.explain(w) + w.Format("┌Evaluate") + for _, v := range r.flds { + w.Format(" %s as %s,", v.expr, fmt.Sprintf("%q", v.name)) + } + w.Format("\n└Output field names %v\n", qnames(r.fields)) +} + +func (r *selectFieldsGroupPlan) fieldNames() []string { return r.fields } + +func (r *selectFieldsGroupPlan) filter(expr expression) (plan, []string, error) { + return nil, nil, nil +} + +func (r *selectFieldsGroupPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (bool, error)) error { + var t temp + var cols []*col + var err error + out := make([]interface{}, len(r.flds)) + ok := false + rows := false + if err = r.src.do(ctx, func(rid interface{}, in []interface{}) (bool, error) { + if ok { + h := in[0].(int64) + m := map[interface{}]interface{}{} + for h != 0 { + in, err = t.Read(nil, h, cols...) + if err != nil { + return false, err + } + + rec := in[2:] + for i, c := range cols { + if nm := c.name; nm != "" { + m[nm] = rec[i] + } + } + m["$id"] = rid + for _, fld := range r.flds { + if _, err = fld.expr.eval(ctx, m); err != nil { + return false, err + } + } + + h = in[0].(int64) + } + m["$agg"] = true + for i, fld := range r.flds { + if out[i], err = fld.expr.eval(ctx, m); err != nil { + return false, err + } + } + rows = true + return f(nil, out) + } + + ok = true + t = in[0].(temp) + cols = in[1].([]*col) + if len(r.flds) == 0 { // SELECT * + r.flds = make([]*fld, len(cols)) + for i, v := range cols { + r.flds[i] = &fld{expr: &ident{v.name}, name: v.name} + } + out = make([]interface{}, len(r.flds)) + } + return true, nil + }); err != nil { + return err + } + + if rows { + return nil + } + + m := map[interface{}]interface{}{"$agg0": true} // aggregate empty record set + for i, fld := range r.flds { + if out[i], err = fld.expr.eval(ctx, m); err != nil { + return err + } + } + _, err = f(nil, out) + + return err +} + +type sysColumnDefaultPlan struct{} + +func (r *sysColumnDefaultPlan) hasID() bool { return false } + +func (r *sysColumnDefaultPlan) explain(w strutil.Formatter) { + w.Format("┌Iterate all rows of table \"__Column\"\n└Output field names %v\n", qnames(r.fieldNames())) +} + +func (r *sysColumnDefaultPlan) filter(expr expression) (plan, []string, error) { + return nil, nil, nil +} + +func (r *sysColumnDefaultPlan) fieldNames() []string { + return []string{"TableName", "Ordinal", "Name", "Type"} +} + +func (r *sysColumnDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (bool, error)) error { + rec := make([]interface{}, 4) + di, err := ctx.db.info() + if err != nil { + return err + } + + var id int64 + for _, ti := range di.Tables { + rec[0] = ti.Name + var ix int64 + for _, ci := range ti.Columns { + ix++ + rec[1] = ix + rec[2] = ci.Name + rec[3] = ci.Type.String() + id++ + if more, err := f(id, rec); !more || err != nil { + return err + } + } + } + return nil +} + +type sysIndexDefaultPlan struct{} + +func (r *sysIndexDefaultPlan) hasID() bool { return false } + +func (r *sysIndexDefaultPlan) explain(w strutil.Formatter) { + w.Format("┌Iterate all rows of table \"__Index\"\n└Output field names %v\n", qnames(r.fieldNames())) +} + +func (r *sysIndexDefaultPlan) filter(expr expression) (plan, []string, error) { + return nil, nil, nil +} + +func (r *sysIndexDefaultPlan) fieldNames() []string { + return []string{"TableName", "ColumnName", "Name", "IsUnique"} +} + +func (r *sysIndexDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (bool, error)) error { + rec := make([]interface{}, 4) + di, err := ctx.db.info() + if err != nil { + return err + } + + var id int64 + for _, xi := range di.Indices { + rec[0] = xi.Table + rec[1] = xi.Column + rec[2] = xi.Name + rec[3] = xi.Unique + id++ + if more, err := f(id, rec); !more || err != nil { + return err + } + } + return nil +} + +type sysTableDefaultPlan struct{} + +func (r *sysTableDefaultPlan) hasID() bool { return false } + +func (r *sysTableDefaultPlan) explain(w strutil.Formatter) { + w.Format("┌Iterate all rows of table \"__Table\"\n└Output field names %v\n", qnames(r.fieldNames())) +} + +func (r *sysTableDefaultPlan) filter(expr expression) (plan, []string, error) { + return nil, nil, nil +} + +func (r *sysTableDefaultPlan) fieldNames() []string { return []string{"Name", "Schema"} } + +func (r *sysTableDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (bool, error)) error { + rec := make([]interface{}, 2) + di, err := ctx.db.info() + if err != nil { + return err + } + + var id int64 + for _, ti := range di.Tables { + rec[0] = ti.Name + a := []string{} + for _, ci := range ti.Columns { + s := "" + if ci.NotNull { + s += " NOT NULL" + } + if c := ci.Constraint; c != "" { + s += " " + c + } + if d := ci.Default; d != "" { + s += " DEFAULT " + d + } + a = append(a, fmt.Sprintf("%s %s%s", ci.Name, ci.Type, s)) + } + rec[1] = fmt.Sprintf("CREATE TABLE %s (%s);", ti.Name, strings.Join(a, ", ")) + id++ + if more, err := f(id, rec); !more || err != nil { + return err + } + } + return nil +} + +type tableNilPlan struct { + t *table +} + +func (r *tableNilPlan) hasID() bool { return true } + +func (r *tableNilPlan) explain(w strutil.Formatter) { + w.Format("┌Iterate all rows of table %q\n└Output field names %v\n", r.t.name, qnames(r.fieldNames())) +} + +func (r *tableNilPlan) fieldNames() []string { return []string{} } + +func (r *tableNilPlan) filter(expr expression) (plan, []string, error) { + return nil, nil, nil +} + +func (r *tableNilPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (bool, error)) (err error) { + t := r.t + h := t.head + cols := t.cols + for h > 0 { + rec, err := t.store.Read(nil, h, cols...) // 0:next, 1:id, 2...: data + if err != nil { + return err + } + + if m, err := f(rec[1], nil); !m || err != nil { + return err + } + + h = rec[0].(int64) // next + } + return nil +} + +type tableDefaultPlan struct { + t *table + fields []string +} + +func (r *tableDefaultPlan) hasID() bool { return true } + +func (r *tableDefaultPlan) explain(w strutil.Formatter) { + w.Format("┌Iterate all rows of table %q\n└Output field names %v\n", r.t.name, qnames(r.fields)) +} + +func (r *tableDefaultPlan) filterBinOp(x *binaryOperation) (plan, []string, error) { + ok, cn, rval, err := x.isIdentRelOpVal() + if err != nil { + return nil, nil, err + } + + if !ok { + return nil, nil, nil + } + + t := r.t + c, ix := t.findIndexByColName(cn) + if ix == nil { // Column cn has no index. + return nil, []string{fmt.Sprintf("%s(%s)", t.name, cn)}, nil + } + + if rval, err = typeCheck1(rval, c); err != nil { + return nil, nil, err + } + + switch x.op { + case eq: + return &indexPlan{t, cn, ix.name, ix.x, indexEq, rval, rval}, nil, nil + case '<': + return &indexPlan{t, cn, ix.name, ix.x, indexLt, nil, rval}, nil, nil + case le: + return &indexPlan{t, cn, ix.name, ix.x, indexLe, nil, rval}, nil, nil + case ge: + return &indexPlan{t, cn, ix.name, ix.x, indexGe, rval, nil}, nil, nil + case '>': + return &indexPlan{t, cn, ix.name, ix.x, indexGt, rval, nil}, nil, nil + case neq: + return &indexPlan{t, cn, ix.name, ix.x, indexNe, rval, rval}, nil, nil + default: + panic("internal error 069") + } +} + +func (r *tableDefaultPlan) filterIdent(x *ident, trueValue bool) (plan, []string, error) { + cn := x.s + t := r.t + for _, v := range t.cols { + if v.name != cn { + continue + } + + if v.typ != qBool { + return nil, nil, nil + } + + xi := v.index + 1 // 0: id() + if xi >= len(t.indices) { + return nil, nil, nil + } + + ix := t.indices[xi] + if ix == nil { // Column cn has no index. + return nil, []string{fmt.Sprintf("%s(%s)", t.name, cn)}, nil + } + + kind := indexFalse + if trueValue { + kind = indexTrue + } + return &indexPlan{t, cn, ix.name, ix.x, kind, nil, nil}, nil, nil + } + return nil, nil, nil +} + +func (r *tableDefaultPlan) filterIsNull(x *isNull) (plan, []string, error) { + ok, cn := isColumnExpression(x.expr) + if !ok { + return nil, nil, nil + } + + t := r.t + _, ix := t.findIndexByColName(cn) + if ix == nil { // Column cn has no index. + return nil, []string{fmt.Sprintf("%s(%s)", t.name, cn)}, nil + } + + switch { + case x.not: + return &indexPlan{t, cn, ix.name, ix.x, indexIsNotNull, nil, nil}, nil, nil + default: + return &indexPlan{t, cn, ix.name, ix.x, indexIsNull, nil, nil}, nil, nil + } +} + +func (r *tableDefaultPlan) filter(expr expression) (plan, []string, error) { + cols := mentionedColumns(expr) + for _, v := range r.fields { + delete(cols, v) + } + for k := range cols { + return nil, nil, fmt.Errorf("unknown field %s", k) + } + + var is []string + + //TODO var sexpr string + //TODO for _, ix := range t.indices2 { + //TODO if len(ix.exprList) != 1 { + //TODO continue + //TODO } + + //TODO if sexpr == "" { + //TODO sexpr = expr.String() + //TODO } + //TODO if ix.sources[0] != sexpr { + //TODO continue + //TODO } + + //TODO } + + switch x := expr.(type) { + case *binaryOperation: + return r.filterBinOp(x) + case *ident: + return r.filterIdent(x, true) + case *isNull: + return r.filterIsNull(x) + case *unaryOperation: + if x.op != '!' { + break + } + + if operand, ok := x.v.(*ident); ok { + return r.filterIdent(operand, false) + } + default: + //dbg("", expr) + return nil, is, nil //TODO + } + + return nil, is, nil +} + +func (r *tableDefaultPlan) do(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) (err error) { + t := r.t + cols := t.cols + h := t.head + for h > 0 { + rec, err := t.row0(ctx, h) + if err != nil { + return err + } + + h = rec[0].(int64) + id := rec[1].(int64) + for i, c := range cols { + rec[i] = rec[c.index+2] + } + if m, err := f(id, rec[:len(cols)]); !m || err != nil { + return err + } + } + return nil +} + +func (r *tableDefaultPlan) fieldNames() []string { return r.fields } + +type nullPlan struct { + fields []string +} + +func (r *nullPlan) hasID() bool { return false } + +func (r *nullPlan) fieldNames() []string { return r.fields } + +func (r *nullPlan) explain(w strutil.Formatter) { + w.Format("┌Iterate no rows\n└Output field names %v\n", qnames(r.fields)) +} + +func (r *nullPlan) do(*execCtx, func(interface{}, []interface{}) (bool, error)) error { + return nil +} + +func (r *nullPlan) filter(expr expression) (plan, []string, error) { + return r, nil, nil +} + +type leftJoinDefaultPlan struct { + on expression + rsets []plan + names []string + right int + fields []string +} + +func (r *leftJoinDefaultPlan) hasID() bool { return false } + +func (r *leftJoinDefaultPlan) explain(w strutil.Formatter) { + w.Format("┌Compute Cartesian product of%i\n") + for i, v := range r.rsets { + sel := !isTableOrIndex(v) + if sel { + w.Format("┌Iterate all rows of virtual table %q%i\n", r.names[i]) + } + v.explain(w) + if sel { + w.Format("%u└Output field names %v\n", qnames(v.fieldNames())) + } + } + w.Format("Extend the product with all NULL rows of %q when no match for %v%u\n", r.names[len(r.names)-1], r.on) + w.Format("└Output field names %v\n", qnames(r.fields)) +} + +func (r *leftJoinDefaultPlan) filter(expr expression) (plan, []string, error) { + var is []string + for i, v := range r.names { + e2, err := expr.clone(nil, v) + if err != nil { + return nil, nil, err + } + + p2, is2, err := r.rsets[i].filter(e2) + is = append(is, is2...) + if err != nil { + return nil, nil, err + } + + if p2 != nil { + r.rsets[i] = p2 + return r, is, nil + } + } + return nil, is, nil +} + +type rightJoinDefaultPlan struct { + leftJoinDefaultPlan +} + +func (r *rightJoinDefaultPlan) hasID() bool { return false } + +func (r *rightJoinDefaultPlan) explain(w strutil.Formatter) { + w.Format("┌Compute Cartesian product of%i\n") + for i, v := range r.rsets { + sel := !isTableOrIndex(v) + if sel { + w.Format("┌Iterate all rows of virtual table %q%i\n", r.names[i]) + } + v.explain(w) + if sel { + w.Format("%u└Output field names %v\n", qnames(v.fieldNames())) + } + } + w.Format("Extend the product with all NULL rows of all but %q when no match for %v%u\n", r.names[len(r.names)-1], r.on) + w.Format("└Output field names %v\n", qnames(r.fields)) +} + +func (r *rightJoinDefaultPlan) filter(expr expression) (plan, []string, error) { + var is []string + for i, v := range r.names { + e2, err := expr.clone(nil, v) + if err != nil { + return nil, nil, err + } + + p2, is2, err := r.rsets[i].filter(e2) + is = append(is, is2...) + if err != nil { + return nil, nil, err + } + + if p2 != nil { + r.rsets[i] = p2 + return r, is, nil + } + } + return nil, is, nil +} + +type fullJoinDefaultPlan struct { + leftJoinDefaultPlan +} + +func (r *fullJoinDefaultPlan) hasID() bool { return false } + +func (r *fullJoinDefaultPlan) explain(w strutil.Formatter) { + w.Format("┌Compute Cartesian product of%i\n") + for i, v := range r.rsets { + sel := !isTableOrIndex(v) + if sel { + w.Format("┌Iterate all rows of virtual table %q%i\n", r.names[i]) + } + v.explain(w) + if sel { + w.Format("%u└Output field names %v\n", qnames(v.fieldNames())) + } + } + w.Format("Extend the product with all NULL rows of %q when no match for %v\n", r.names[len(r.names)-1], r.on) + w.Format("Extend the product with all NULL rows of all but %q when no match for %v%u\n", r.names[len(r.names)-1], r.on) + w.Format("└Output field names %v\n", qnames(r.fields)) +} + +func (r *fullJoinDefaultPlan) filter(expr expression) (plan, []string, error) { + var is []string + for i, v := range r.names { + e2, err := expr.clone(nil, v) + if err != nil { + return nil, nil, err + } + + p2, is2, err := r.rsets[i].filter(e2) + is = append(is, is2...) + if err != nil { + return nil, nil, err + } + + if p2 != nil { + r.rsets[i] = p2 + return r, is, nil + } + } + return nil, is, nil +} + +func (r *leftJoinDefaultPlan) fieldNames() []string { return r.fields } + +func (r *leftJoinDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (more bool, err error)) error { + m := map[interface{}]interface{}{} + ids := map[string]interface{}{} + var g func([]interface{}, []plan, int) error + var match bool + g = func(prefix []interface{}, rsets []plan, x int) (err error) { + return rsets[0].do(ctx, func(id interface{}, in []interface{}) (bool, error) { + ids[r.names[x]] = id + row := append(prefix, in...) + if len(rsets) > 1 { + if len(rsets) == 2 { + match = false + } + if err = g(row, rsets[1:], x+1); err != nil { + return false, err + } + + if len(rsets) != 2 || match { + return true, nil + } + + ids[r.names[x+1]] = nil + return f(ids, append(row, make([]interface{}, r.right)...)) + } + + for i, fld := range r.fields { + if fld != "" { + m[fld] = row[i] + } + } + + val, err := r.on.eval(ctx, m) + if err != nil { + return false, err + } + + if val == nil { + return true, nil + } + + x, ok := val.(bool) + if !ok { + return false, fmt.Errorf("invalid ON expression %s (value of type %T)", val, val) + } + + if !x { + return true, nil + } + + match = true + return f(ids, row) + }) + } + return g(nil, r.rsets, 0) +} + +func (r *rightJoinDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (more bool, err error)) error { + right := r.right + left := len(r.fields) - right + n := len(r.rsets) + m := map[interface{}]interface{}{} + ids := map[string]interface{}{} + var g func([]interface{}, []plan, int) error + var match bool + nf := len(r.fields) + fields := append(append([]string(nil), r.fields[nf-right:]...), r.fields[:nf-right]...) + g = func(prefix []interface{}, rsets []plan, x int) (err error) { + return rsets[0].do(ctx, func(id interface{}, in []interface{}) (bool, error) { + ids[r.names[x]] = id + row := append(prefix, in...) + if len(rsets) > 1 { + if len(rsets) == n { + match = false + } + if err = g(row, rsets[1:], x+1); err != nil { + return false, err + } + + if len(rsets) != n || match { + return true, nil + } + + for i := 0; i < n-1; i++ { + ids[r.names[i]] = nil + } + + // rigth, left -> left, right + return f(ids, append(make([]interface{}, left), row[:right]...)) + } + + for i, fld := range fields { + if fld != "" { + m[fld] = row[i] + } + } + + val, err := r.on.eval(ctx, m) + if err != nil { + return false, err + } + + if val == nil { + return true, nil + } + + x, ok := val.(bool) + if !ok { + return false, fmt.Errorf("invalid ON expression %s (value of type %T)", val, val) + } + + if !x { + return true, nil + } + + match = true + // rigth, left -> left, right + return f(ids, append(append([]interface{}(nil), row[right:]...), row[:right]...)) + }) + } + return g(nil, append([]plan{r.rsets[n-1]}, r.rsets[:n-1]...), 0) +} + +func (r *fullJoinDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (more bool, err error)) error { + b3 := b.TreeNew(func(a, b interface{}) int { + x := a.(int64) + y := b.(int64) + if x < y { + return -1 + } + + if x == y { + return 0 + } + + return 1 + }) + m := map[interface{}]interface{}{} + ids := map[string]interface{}{} + var g func([]interface{}, []plan, int) error + var match bool + var rid int64 + firstR := true + g = func(prefix []interface{}, rsets []plan, x int) (err error) { + return rsets[0].do(ctx, func(id interface{}, in []interface{}) (bool, error) { + ids[r.names[x]] = id + row := append(prefix, in...) + if len(rsets) > 1 { + if len(rsets) == 2 { + match = false + rid = 0 + } + if err = g(row, rsets[1:], x+1); err != nil { + return false, err + } + + if len(rsets) == 2 { + firstR = false + } + if len(rsets) != 2 || match { + return true, nil + } + + ids[r.names[x+1]] = nil + return f(ids, append(row, make([]interface{}, r.right)...)) + } + + rid++ + if firstR { + b3.Set(rid, in) + } + for i, fld := range r.fields { + if fld != "" { + m[fld] = row[i] + } + } + + val, err := r.on.eval(ctx, m) + if err != nil { + return false, err + } + + if val == nil { + return true, nil + } + + x, ok := val.(bool) + if !ok { + return false, fmt.Errorf("invalid ON expression %s (value of type %T)", val, val) + } + + if !x { + return true, nil + } + + match = true + b3.Delete(rid) + return f(ids, row) + }) + } + if err := g(nil, r.rsets, 0); err != nil { + return err + } + + it, err := b3.SeekFirst() + if err != nil { + return noEOF(err) + } + + pref := make([]interface{}, len(r.fields)-r.right) + for { + _, v, err := it.Next() + if err != nil { + return noEOF(err) + } + + more, err := f(nil, append(pref, v.([]interface{})...)) + if err != nil || !more { + return err + } + } +} diff --git a/vendor/github.com/cznic/ql/ql.go b/vendor/github.com/cznic/ql/ql.go new file mode 100644 index 0000000000..82c3c5fa58 --- /dev/null +++ b/vendor/github.com/cznic/ql/ql.go @@ -0,0 +1,1729 @@ +// Copyright 2014 The ql Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//LATER profile mem +//LATER profile cpu +//LATER coverage + +package ql + +import ( + "bytes" + "errors" + "fmt" + "math/big" + "strconv" + "strings" + "sync" + "time" + + "github.com/cznic/strutil" +) + +const ( + crossJoin = iota + leftJoin + rightJoin + fullJoin +) + +// NOTE: all rset implementations must be safe for concurrent use by multiple +// goroutines. If the do method requires any execution domain local data, they +// must be held out of the implementing instance. +var ( + _ rset = (*distinctRset)(nil) + _ rset = (*groupByRset)(nil) + _ rset = (*joinRset)(nil) + _ rset = (*limitRset)(nil) + _ rset = (*offsetRset)(nil) + _ rset = (*orderByRset)(nil) + _ rset = (*selectRset)(nil) + _ rset = (*selectStmt)(nil) + _ rset = (*tableRset)(nil) + _ rset = (*whereRset)(nil) + + isTesting bool // enables test hook: select from an index +) + +type rset interface { + plan(ctx *execCtx) (plan, error) +} + +type recordset struct { + ctx *execCtx + plan + tx *TCtx +} + +func (r recordset) fieldNames() []interface{} { + f := r.plan.fieldNames() + a := make([]interface{}, len(f)) + for i, v := range f { + a[i] = v + } + return a +} + +// Do implements Recordset. +func (r recordset) Do(names bool, f func(data []interface{}) (bool, error)) error { + if names { + if more, err := f(r.fieldNames()); err != nil || !more { + return err + } + } + return r.ctx.db.do(r, f) +} + +// Fields implements Recordset. +func (r recordset) Fields() (names []string, err error) { + return r.plan.fieldNames(), nil +} + +// FirstRow implements Recordset. +func (r recordset) FirstRow() (row []interface{}, err error) { + rows, err := r.Rows(1, 0) + if err != nil { + return nil, err + } + + if len(rows) != 0 { + return rows[0], nil + } + + return nil, nil +} + +// Rows implements Recordset. +func (r recordset) Rows(limit, offset int) ([][]interface{}, error) { + var rows [][]interface{} + if err := r.Do(false, func(row []interface{}) (bool, error) { + if offset > 0 { + offset-- + return true, nil + } + + switch { + case limit < 0: + rows = append(rows, row) + return true, nil + case limit == 0: + return false, nil + default: // limit > 0 + rows = append(rows, row) + limit-- + return limit > 0, nil + } + }); err != nil { + return nil, err + } + + return rows, nil +} + +// List represents a group of compiled statements. +type List struct { + l []stmt + params int +} + +// String implements fmt.Stringer +func (l List) String() string { + var b bytes.Buffer + f := strutil.IndentFormatter(&b, "\t") + for _, s := range l.l { + switch s.(type) { + case beginTransactionStmt: + f.Format("%s\n%i", s) + case commitStmt, rollbackStmt: + f.Format("%u%s\n", s) + default: + f.Format("%s\n", s) + } + } + return b.String() +} + +// IsExplainStmt reports whether l is a single EXPLAIN statment or a single EXPLAIN +// statment enclosed in a transaction. +func (l List) IsExplainStmt() bool { + switch len(l.l) { + case 1: + _, ok := l.l[0].(*explainStmt) + return ok + case 3: + if _, ok := l.l[0].(beginTransactionStmt); !ok { + return false + } + if _, ok := l.l[1].(*explainStmt); !ok { + return false + } + _, ok := l.l[2].(commitStmt) + return ok + default: + return false + } +} + +type groupByRset struct { + colNames []string + src plan +} + +func (r *groupByRset) plan(ctx *execCtx) (plan, error) { + fields := r.src.fieldNames() + for _, v := range r.colNames { + found := false + for _, v2 := range fields { + if v == v2 { + found = true + break + } + } + if !found { + return nil, fmt.Errorf("unknown field %s", v) + } + } + return &groupByDefaultPlan{colNames: r.colNames, src: r.src, fields: fields}, nil +} + +// TCtx represents transaction context. It enables to execute multiple +// statement lists in the same context. The same context guarantees the state +// of the DB cannot change in between the separated executions. +// +// LastInsertID +// +// LastInsertID is updated by INSERT INTO statements. The value considers +// performed ROLLBACK statements, if any, even though roll backed IDs are not +// reused. QL clients should treat the field as read only. +// +// RowsAffected +// +// RowsAffected is updated by INSERT INTO, DELETE FROM and UPDATE statements. +// The value does not (yet) consider any ROLLBACK statements involved. QL +// clients should treat the field as read only. +type TCtx struct { + LastInsertID int64 + RowsAffected int64 +} + +// NewRWCtx returns a new read/write transaction context. NewRWCtx is safe for +// concurrent use by multiple goroutines, every one of them will get a new, +// unique conext. +func NewRWCtx() *TCtx { return &TCtx{} } + +// Recordset is a result of a select statment. It can call a user function for +// every row (record) in the set using the Do method. +// +// Recordsets can be safely reused. Evaluation of the rows is performed lazily. +// Every invocation of Do will see the current, potentially actualized data. +// +// Do +// +// Do will call f for every row (record) in the Recordset. +// +// If f returns more == false or err != nil then f will not be called for any +// remaining rows in the set and the err value is returned from Do. +// +// If names == true then f is firstly called with a virtual row +// consisting of field (column) names of the RecordSet. +// +// Do is executed in a read only context and performs a RLock of the +// database. +// +// Do is safe for concurrent use by multiple goroutines. +// +// Fields +// +// Fields return a slice of field names of the recordset. The result is computed +// without actually computing the recordset rows. +// +// FirstRow +// +// FirstRow will return the first row of the RecordSet or an error, if any. If +// the Recordset has no rows the result is (nil, nil). +// +// Rows +// +// Rows will return rows in Recordset or an error, if any. The semantics of +// limit and offset are the same as of the LIMIT and OFFSET clauses of the +// SELECT statement. To get all rows pass limit < 0. If there are no rows to +// return the result is (nil, nil). +type Recordset interface { + Do(names bool, f func(data []interface{}) (more bool, err error)) error + Fields() (names []string, err error) + FirstRow() (row []interface{}, err error) + Rows(limit, offset int) (rows [][]interface{}, err error) +} + +type assignment struct { + colName string + expr expression +} + +func (a *assignment) String() string { + return fmt.Sprintf("%s=%s", a.colName, a.expr) +} + +type distinctRset struct { + src plan +} + +func (r *distinctRset) plan(ctx *execCtx) (plan, error) { + return &distinctDefaultPlan{src: r.src, fields: r.src.fieldNames()}, nil +} + +type orderByRset struct { + asc bool + by []expression + src plan +} + +func (r *orderByRset) String() string { + a := make([]string, len(r.by)) + for i, v := range r.by { + a[i] = v.String() + } + s := strings.Join(a, ", ") + if !r.asc { + s += " DESC" + } + return s +} + +func (r *orderByRset) plan(ctx *execCtx) (plan, error) { + if _, ok := r.src.(*nullPlan); ok { + return r.src, nil + } + + var by []expression + fields := r.src.fieldNames() + for _, e := range r.by { + cols := mentionedColumns(e) + for k := range cols { + found := false + for _, v := range fields { + if k == v { + found = true + break + } + } + if !found { + return nil, fmt.Errorf("unknown field %s", k) + } + } + if len(cols) == 0 { + v, err := e.eval(ctx, nil) + if err != nil { + by = append(by, e) + continue + } + + if isConstValue(v) != nil { + continue + } + } + + by = append(by, e) + } + return &orderByDefaultPlan{asc: r.asc, by: by, src: r.src, fields: fields}, nil +} + +type whereRset struct { + expr expression + src plan +} + +func (r *whereRset) planBinOp(x *binaryOperation) (plan, error) { + p := r.src + ok, cn := isColumnExpression(x.l) + if ok && cn == "id()" { + if v := isConstValue(x.r); v != nil { + v, err := typeCheck1(v, idCol) + if err != nil { + return nil, err + } + + rv := v.(int64) + switch { + case p.hasID(): + switch x.op { + case '<': + if rv <= 1 { + return &nullPlan{p.fieldNames()}, nil + } + case '>': + if rv <= 0 { + return p, nil + } + case ge: + if rv >= 1 { + return p, nil + } + case neq: + if rv <= 0 { + return p, nil + } + case eq: + if rv <= 0 { + return &nullPlan{p.fieldNames()}, nil + } + case le: + if rv <= 0 { + return &nullPlan{p.fieldNames()}, nil + } + } + } + } + } + + var err error + var p2 plan + var is []string + switch x.op { + case eq, ge, '>', le, '<', neq: + if p2, is, err = p.filter(x); err != nil { + return nil, err + } + + if p2 != nil { + return p2, nil + } + case andand: + var in []expression + var f func(expression) + f = func(e expression) { + b, ok := e.(*binaryOperation) + if !ok || b.op != andand { + in = append(in, e) + return + } + + f(b.l) + f(b.r) + } + f(x) + out := []expression{} + p := r.src + isNewPlan := false + for _, e := range in { + p2, is2, err := p.filter(e) + if err != nil { + return nil, err + } + + if p2 == nil { + is = append(is, is2...) + out = append(out, e) + continue + } + + p = p2 + isNewPlan = true + } + + if !isNewPlan { + break + } + + if len(out) == 0 { + return p, nil + } + + for len(out) > 1 { + n := len(out) + e, err := newBinaryOperation(andand, out[n-2], out[n-1]) + if err != nil { + return nil, err + } + + out = out[:n-1] + out[n-2] = e + } + + return &filterDefaultPlan{p, out[0], is}, nil + } + + return &filterDefaultPlan{p, x, is}, nil +} + +func (r *whereRset) planIdent(x *ident) (plan, error) { + p := r.src + p2, is, err := p.filter(x) + if err != nil { + return nil, err + } + + if p2 != nil { + return p2, nil + } + + return &filterDefaultPlan{p, x, is}, nil +} + +func (r *whereRset) planIsNull(x *isNull) (plan, error) { + p := r.src + ok, cn := isColumnExpression(x.expr) + if !ok { + return &filterDefaultPlan{p, x, nil}, nil + } + + if cn == "id()" { + switch { + case p.hasID(): + switch { + case x.not: // IS NOT NULL + return p, nil + default: // IS NULL + return &nullPlan{p.fieldNames()}, nil + } + default: + switch { + case x.not: // IS NOT NULL + return &nullPlan{p.fieldNames()}, nil + default: // IS NULL + return p, nil + } + } + } + + p2, is, err := p.filter(x) + if err != nil { + return nil, err + } + + if p2 != nil { + return p2, nil + } + + return &filterDefaultPlan{p, x, is}, nil +} + +func (r *whereRset) planUnaryOp(x *unaryOperation) (plan, error) { + p := r.src + p2, is, err := p.filter(x) + if err != nil { + return nil, err + } + + if p2 != nil { + return p2, nil + } + + return &filterDefaultPlan{p, x, is}, nil +} + +func (r *whereRset) plan(ctx *execCtx) (plan, error) { + expr, err := r.expr.clone(ctx.arg) + if err != nil { + return nil, err + } + + switch r.src.(type) { + case *leftJoinDefaultPlan, *rightJoinDefaultPlan, *fullJoinDefaultPlan: + return &filterDefaultPlan{r.src, expr, nil}, nil + } + + switch x := expr.(type) { + case *binaryOperation: + return r.planBinOp(x) + case *ident: + return r.planIdent(x) + case *isNull: + return r.planIsNull(x) + case *pIn: + //TODO optimize + //TODO show plan + case *pLike: + //TODO optimize + case *unaryOperation: + return r.planUnaryOp(x) + } + + return &filterDefaultPlan{r.src, expr, nil}, nil +} + +type offsetRset struct { + expr expression + src plan +} + +func (r *offsetRset) plan(ctx *execCtx) (plan, error) { + return &offsetDefaultPlan{expr: r.expr, src: r.src, fields: r.src.fieldNames()}, nil +} + +type limitRset struct { + expr expression + src plan +} + +func (r *limitRset) plan(ctx *execCtx) (plan, error) { + return &limitDefaultPlan{expr: r.expr, src: r.src, fields: r.src.fieldNames()}, nil +} + +type selectRset struct { + flds []*fld + src plan +} + +func (r *selectRset) plan(ctx *execCtx) (plan, error) { + var flds2 []*fld + if len(r.flds) != 0 { + m := map[string]struct{}{} + for _, v := range r.flds { + mentionedColumns0(v.expr, true, true, m) + } + for _, v := range r.src.fieldNames() { + delete(m, v) + } + for k := range m { + return nil, fmt.Errorf("unknown field %s", k) + } + + flds2 = append(flds2, r.flds...) + } + + if x, ok := r.src.(*groupByDefaultPlan); ok { + if len(r.flds) == 0 { + fields := x.fieldNames() + flds := make([]*fld, len(fields)) + for i, v := range fields { + flds[i] = &fld{&ident{v}, v} + } + return &selectFieldsGroupPlan{flds: flds, src: x, fields: fields}, nil + } + + p := &selectFieldsGroupPlan{flds: flds2, src: x} + for _, v := range r.flds { + p.fields = append(p.fields, v.name) + } + return p, nil + } + + if len(r.flds) == 0 { + return r.src, nil + } + + f0 := r.src.fieldNames() + if len(f0) == len(flds2) { + match := true + for i, v := range flds2 { + if x, ok := v.expr.(*ident); ok && x.s == f0[i] && v.name == f0[i] { + continue + } + + match = false + break + } + + if match { + return r.src, nil + } + } + + src := r.src + if x, ok := src.(*tableDefaultPlan); ok { + isconst := true + for _, v := range flds2 { + if isConstValue(v.expr) == nil { + isconst = false + break + } + } + if isconst { // #250 + src = &tableNilPlan{x.t} + } + } + + p := &selectFieldsDefaultPlan{flds: flds2, src: src} + for _, v := range r.flds { + p.fields = append(p.fields, v.name) + } + return p, nil +} + +type tableRset string + +func (r tableRset) plan(ctx *execCtx) (plan, error) { + switch r { + case "__Table": + return &sysTableDefaultPlan{}, nil + case "__Column": + return &sysColumnDefaultPlan{}, nil + case "__Index": + return &sysIndexDefaultPlan{}, nil + } + + t, ok := ctx.db.root.tables[string(r)] + if !ok && isTesting { + if _, x0 := ctx.db.root.findIndexByName(string(r)); x0 != nil { + return &selectIndexDefaultPlan{nm: string(r), x: x0}, nil + } + } + + if !ok { + return nil, fmt.Errorf("table %s does not exist", r) + } + + rs := &tableDefaultPlan{t: t} + for _, col := range t.cols { + rs.fields = append(rs.fields, col.name) + } + return rs, nil +} + +func findFldIndex(fields []*fld, name string) int { + for i, f := range fields { + if f.name == name { + return i + } + } + + return -1 +} + +func findFld(fields []*fld, name string) (f *fld) { + for _, f = range fields { + if f.name == name { + return + } + } + + return nil +} + +type col struct { + index int + name string + typ int + constraint *constraint + dflt expression +} + +var idCol = &col{name: "id()", typ: qInt64} + +func findCol(cols []*col, name string) (c *col) { + for _, c = range cols { + if c.name == name { + return + } + } + + return nil +} + +func (f *col) clone() *col { + var r col + r = *f + r.constraint = f.constraint.clone() + if f.dflt != nil { + r.dflt, _ = r.dflt.clone(nil) + } + return &r +} + +func (f *col) typeCheck(x interface{}) (ok bool) { //NTYPE + switch x.(type) { + case nil: + return true + case bool: + return f.typ == qBool + case complex64: + return f.typ == qComplex64 + case complex128: + return f.typ == qComplex128 + case float32: + return f.typ == qFloat32 + case float64: + return f.typ == qFloat64 + case int8: + return f.typ == qInt8 + case int16: + return f.typ == qInt16 + case int32: + return f.typ == qInt32 + case int64: + return f.typ == qInt64 + case string: + return f.typ == qString + case uint8: + return f.typ == qUint8 + case uint16: + return f.typ == qUint16 + case uint32: + return f.typ == qUint32 + case uint64: + return f.typ == qUint64 + case []byte: + return f.typ == qBlob + case *big.Int: + return f.typ == qBigInt + case *big.Rat: + return f.typ == qBigRat + case time.Time: + return f.typ == qTime + case time.Duration: + return f.typ == qDuration + case chunk: + return true // was checked earlier + } + return +} + +func cols2meta(f []*col) (s string) { + a := []string{} + for _, f := range f { + a = append(a, string(f.typ)+f.name) + } + return strings.Join(a, "|") +} + +// DB represent the database capable of executing QL statements. +type DB struct { + cc *TCtx // Current transaction context + isMem bool + mu sync.Mutex + root *root + rw bool // DB FSM + rwmu sync.RWMutex + store storage + tnl int // Transaction nesting level + exprCache map[string]expression + exprCacheMu sync.Mutex + hasIndex2 int // 0: nope, 1: in progress, 2: yes. +} + +var selIndex2Expr = MustCompile("select Expr from __Index2_Expr where Index2_ID == $1") + +func newDB(store storage) (db *DB, err error) { + db0 := &DB{ + exprCache: map[string]expression{}, + store: store, + } + if db0.root, err = newRoot(store); err != nil { + return + } + + ctx := &execCtx{db: db0} + for _, t := range db0.root.tables { + if err := t.constraintsAndDefaults(ctx); err != nil { + return nil, err + } + } + + if !db0.hasAllIndex2() { + return db0, nil + } + + db0.hasIndex2 = 2 + rss, _, err := db0.Run(nil, "select id(), TableName, IndexName, IsUnique, Root from __Index2 where !IsSimple") + if err != nil { + return nil, err + } + + rows, err := rss[0].Rows(-1, 0) + if err != nil { + return nil, err + } + + for _, row := range rows { + defer func() { + if e := recover(); e != nil { + err = fmt.Errorf("error loading DB indices: %v", e) + } + }() + + id := row[0].(int64) + tn := row[1].(string) + xn := row[2].(string) + unique := row[3].(bool) + xroot := row[4].(int64) + + t := db0.root.tables[tn] + if t == nil { + return nil, fmt.Errorf("DB index refers to nonexistent table: %s", tn) + } + + x, err := store.OpenIndex(unique, xroot) + if err != nil { + return nil, err + } + + if v := t.indices2[xn]; v != nil { + return nil, fmt.Errorf("duplicate DB index: %s", xn) + } + + ix := &index2{ + unique: unique, + x: x, + xroot: xroot, + } + + rss, _, err := db0.Execute(nil, selIndex2Expr, id) + if err != nil { + return nil, err + } + + rows, err := rss[0].Rows(-1, 0) + if err != nil { + return nil, err + } + + if len(rows) == 0 { + return nil, fmt.Errorf("index has no expression: %s", xn) + } + + var sources []string + var list []expression + for _, row := range rows { + src, ok := row[0].(string) + if !ok { + return nil, fmt.Errorf("index %s: expression of type %T", xn, row[0]) + } + + expr, err := db0.str2expr(src) + if err != nil { + return nil, fmt.Errorf("index %s: expression error: %v", xn, err) + } + + sources = append(sources, src) + list = append(list, expr) + } + + ix.sources = sources + ix.exprList = list + if t.indices2 == nil { + t.indices2 = map[string]*index2{} + } + t.indices2[xn] = ix + } + return db0, nil +} + +func (db *DB) deleteIndex2ByIndexName(nm string) error { + for _, s := range deleteIndex2ByIndexName.l { + if _, err := s.exec(&execCtx{db: db, arg: []interface{}{nm}}); err != nil { + return err + } + } + return nil +} + +func (db *DB) deleteIndex2ByTableName(nm string) error { + for _, s := range deleteIndex2ByTableName.l { + if _, err := s.exec(&execCtx{db: db, arg: []interface{}{nm}}); err != nil { + return err + } + } + return nil +} + +func (db *DB) createIndex2() error { + if db.hasIndex2 != 0 { + return nil + } + + db.hasIndex2 = 1 + ctx := execCtx{db: db} + for _, s := range createIndex2.l { + if _, err := s.exec(&ctx); err != nil { + db.hasIndex2 = 0 + return err + } + } + + for t := db.root.thead; t != nil; t = t.tnext { + for i, index := range t.indices { + if index == nil { + continue + } + + expr := "id()" + if i != 0 { + expr = t.cols[i-1].name + } + + if err := db.insertIndex2(t.name, index.name, []string{expr}, index.unique, true, index.xroot); err != nil { + db.hasIndex2 = 0 + return err + } + } + } + + db.hasIndex2 = 2 + return nil +} + +func (db *DB) insertIndex2(tableName, indexName string, expr []string, unique, isSimple bool, h int64) error { + ctx := execCtx{db: db} + ctx.arg = []interface{}{ + tableName, + indexName, + unique, + isSimple, + h, + } + if _, err := insertIndex2.l[0].exec(&ctx); err != nil { + return err + } + + id := db.root.lastInsertID + for _, e := range expr { + ctx.arg = []interface{}{id, e} + if _, err := insertIndex2Expr.l[0].exec(&ctx); err != nil { + return err + } + } + return nil +} + +func (db *DB) hasAllIndex2() bool { + t := db.root.tables + if _, ok := t["__Index2"]; !ok { + return false + } + + _, ok := t["__Index2_Expr"] + return ok +} + +func (db *DB) str2expr(expr string) (expression, error) { + db.exprCacheMu.Lock() + e := db.exprCache[expr] + db.exprCacheMu.Unlock() + if e != nil { + return e, nil + } + + e, err := compileExpr(expr) + if err != nil { + return nil, err + } + + db.exprCacheMu.Lock() + for k := range db.exprCache { + if len(db.exprCache) < 1000 { + break + } + + delete(db.exprCache, k) + } + db.exprCache[expr] = e + db.exprCacheMu.Unlock() + return e, nil +} + +// Name returns the name of the DB. +func (db *DB) Name() string { return db.store.Name() } + +// Run compiles and executes a statement list. It returns, if applicable, a +// RecordSet slice and/or an index and error. +// +// For more details please see DB.Execute +// +// Run is safe for concurrent use by multiple goroutines. +func (db *DB) Run(ctx *TCtx, ql string, arg ...interface{}) (rs []Recordset, index int, err error) { + l, err := Compile(ql) + if err != nil { + return nil, -1, err + } + + return db.Execute(ctx, l, arg...) +} + +func (db *DB) run(ctx *TCtx, ql string, arg ...interface{}) (rs []Recordset, index int, err error) { + l, err := compile(ql) + if err != nil { + return nil, -1, err + } + + return db.Execute(ctx, l, arg...) +} + +// Compile parses the ql statements from src and returns a compiled list for +// DB.Execute or an error if any. +// +// Compile is safe for concurrent use by multiple goroutines. +func Compile(src string) (List, error) { + l := newLexer(src) + if yyParse(l) != 0 { + return List{}, l.errs[0] + } + + return List{l.list, l.params}, nil +} + +func compileExpr(src string) (expression, error) { + l := newLexer(src) + l.inj = parseExpression + if yyParse(l) != 0 { + return nil, l.errs[0] + } + + return l.expr, nil +} + +func compile(src string) (List, error) { + l := newLexer(src) + l.root = true + if yyParse(l) != 0 { + return List{}, l.errs[0] + } + + return List{l.list, l.params}, nil +} + +// MustCompile is like Compile but panics if the ql statements in src cannot be +// compiled. It simplifies safe initialization of global variables holding +// compiled statement lists for DB.Execute. +// +// MustCompile is safe for concurrent use by multiple goroutines. +func MustCompile(src string) List { + list, err := Compile(src) + if err != nil { + panic("ql: Compile(" + strconv.Quote(src) + "): " + err.Error()) // panic ok here + } + + return list +} + +func mustCompile(src string) List { + list, err := compile(src) + if err != nil { + panic("ql: compile(" + strconv.Quote(src) + "): " + err.Error()) // panic ok here + } + + return list +} + +// Execute executes statements in a list while substituting QL paramaters from +// arg. +// +// The resulting []Recordset corresponds to the SELECT FROM statements in the +// list. +// +// If err != nil then index is the zero based index of the failed QL statement. +// Empty statements do not count. +// +// The FSM STT describing the relations between DB states, statements and the +// ctx parameter. +// +// +-----------+---------------------+------------------+------------------+------------------+ +// |\ Event | | | | | +// | \-------\ | BEGIN | | | Other | +// | State \| TRANSACTION | COMMIT | ROLLBACK | statement | +// +-----------+---------------------+------------------+------------------+------------------+ +// | RD | if PC == nil | return error | return error | DB.RLock | +// | | return error | | | Execute(1) | +// | CC == nil | | | | DB.RUnlock | +// | TNL == 0 | DB.Lock | | | | +// | | CC = PC | | | | +// | | TNL++ | | | | +// | | DB.BeginTransaction | | | | +// | | State = WR | | | | +// +-----------+---------------------+------------------+------------------+------------------+ +// | WR | if PC == nil | if PC != CC | if PC != CC | if PC == nil | +// | | return error | return error | return error | DB.Rlock | +// | CC != nil | | | | Execute(1) | +// | TNL != 0 | if PC != CC | DB.Commit | DB.Rollback | RUnlock | +// | | DB.Lock | TNL-- | TNL-- | else if PC != CC | +// | | CC = PC | if TNL == 0 | if TNL == 0 | return error | +// | | | CC = nil | CC = nil | else | +// | | TNL++ | State = RD | State = RD | Execute(2) | +// | | DB.BeginTransaction | DB.Unlock | DB.Unlock | | +// +-----------+---------------------+------------------+------------------+------------------+ +// CC: Curent transaction context +// PC: Passed transaction context +// TNL: Transaction nesting level +// +// Lock, Unlock, RLock, RUnlock semantics above are the same as in +// sync.RWMutex. +// +// (1): Statement list is executed outside of a transaction. Attempts to update +// the DB will fail, the execution context is read-only. Other statements with +// read only context will execute concurrently. If any statement fails, the +// execution of the statement list is aborted. +// +// Note that the RLock/RUnlock surrounds every single "other" statement when it +// is executed outside of a transaction. If read consistency is required by a +// list of more than one statement then an explicit BEGIN TRANSACTION / COMMIT +// or ROLLBACK wrapper must be provided. Otherwise the state of the DB may +// change in between executing any two out-of-transaction statements. +// +// (2): Statement list is executed inside an isolated transaction. Execution of +// statements can update the DB, the execution context is read-write. If any +// statement fails, the execution of the statement list is aborted and the DB +// is automatically rolled back to the TNL which was active before the start of +// execution of the statement list. +// +// Execute is safe for concurrent use by multiple goroutines, but one must +// consider the blocking issues as discussed above. +// +// ACID +// +// Atomicity: Transactions are atomic. Transactions can be nested. Commit or +// rollbacks work on the current transaction level. Transactions are made +// persistent only on the top level commit. Reads made from within an open +// transaction are dirty reads. +// +// Consistency: Transactions bring the DB from one structurally consistent +// state to other structurally consistent state. +// +// Isolation: Transactions are isolated. Isolation is implemented by +// serialization. +// +// Durability: Transactions are durable. A two phase commit protocol and a +// write ahead log is used. Database is recovered after a crash from the write +// ahead log automatically on open. +func (db *DB) Execute(ctx *TCtx, l List, arg ...interface{}) (rs []Recordset, index int, err error) { + // Sanitize args + for i, v := range arg { + switch x := v.(type) { + case nil, bool, complex64, complex128, float32, float64, string, + int8, int16, int32, int64, int, + uint8, uint16, uint32, uint64, uint, + *big.Int, *big.Rat, []byte, time.Duration, time.Time: + case big.Int: + arg[i] = &x + case big.Rat: + arg[i] = &x + default: + return nil, 0, fmt.Errorf("cannot use arg[%d] (type %T):unsupported type", i, v) + } + } + + tnl0 := -1 + if ctx != nil { + ctx.LastInsertID, ctx.RowsAffected = 0, 0 + } + + list := l.l + for _, s := range list { + r, tnla, tnl, err := db.run1(ctx, s, arg...) + if tnl0 < 0 { + tnl0 = tnla + } + if err != nil { + for tnl > tnl0 { + var e2 error + if _, _, tnl, e2 = db.run1(ctx, rollbackStmt{}); e2 != nil { + err = e2 + } + } + return rs, index, err + } + + if r != nil { + if x, ok := r.(recordset); ok { + x.tx = ctx + r = x + } + rs = append(rs, r) + } + } + return +} + +func (db *DB) run1(pc *TCtx, s stmt, arg ...interface{}) (rs Recordset, tnla, tnlb int, err error) { + db.mu.Lock() + tnla = db.tnl + tnlb = db.tnl + switch db.rw { + case false: + switch s.(type) { + case beginTransactionStmt: + defer db.mu.Unlock() + if pc == nil { + return nil, tnla, tnlb, errors.New("BEGIN TRANSACTION: cannot start a transaction in nil TransactionCtx") + } + + if err = db.store.BeginTransaction(); err != nil { + return + } + + db.beginTransaction() + db.rwmu.Lock() + db.cc = pc + db.tnl++ + tnlb = db.tnl + db.rw = true + return + case commitStmt: + defer db.mu.Unlock() + return nil, tnla, tnlb, errCommitNotInTransaction + case rollbackStmt: + defer db.mu.Unlock() + return nil, tnla, tnlb, errRollbackNotInTransaction + default: + if s.isUpdating() { + db.mu.Unlock() + return nil, tnla, tnlb, fmt.Errorf("attempt to update the DB outside of a transaction") + } + + db.rwmu.RLock() // can safely grab before Unlock + db.mu.Unlock() + defer db.rwmu.RUnlock() + rs, err = s.exec(&execCtx{db, arg}) // R/O tctx + return rs, tnla, tnlb, err + } + default: // case true: + switch s.(type) { + case beginTransactionStmt: + defer db.mu.Unlock() + + if pc == nil { + return nil, tnla, tnlb, errBeginTransNoCtx + } + + if pc != db.cc { + for db.rw == true { + db.mu.Unlock() // Transaction isolation + db.mu.Lock() + } + + db.rw = true + db.rwmu.Lock() + } + + if err = db.store.BeginTransaction(); err != nil { + return + } + + db.beginTransaction() + db.cc = pc + db.tnl++ + tnlb = db.tnl + return + case commitStmt: + defer db.mu.Unlock() + if pc != db.cc { + return nil, tnla, tnlb, fmt.Errorf("invalid passed transaction context") + } + + db.commit() + err = db.store.Commit() + db.tnl-- + tnlb = db.tnl + if db.tnl != 0 { + return + } + + db.cc = nil + db.rw = false + db.rwmu.Unlock() + return + case rollbackStmt: + defer db.mu.Unlock() + defer func() { pc.LastInsertID = db.root.lastInsertID }() + if pc != db.cc { + return nil, tnla, tnlb, fmt.Errorf("invalid passed transaction context") + } + + db.rollback() + err = db.store.Rollback() + db.tnl-- + tnlb = db.tnl + if db.tnl != 0 { + return + } + + db.cc = nil + db.rw = false + db.rwmu.Unlock() + return + default: + if pc == nil { + if s.isUpdating() { + db.mu.Unlock() + return nil, tnla, tnlb, fmt.Errorf("attempt to update the DB outside of a transaction") + } + + db.mu.Unlock() // must Unlock before RLock + db.rwmu.RLock() + defer db.rwmu.RUnlock() + rs, err = s.exec(&execCtx{db, arg}) + return rs, tnla, tnlb, err + } + + defer db.mu.Unlock() + defer func() { pc.LastInsertID = db.root.lastInsertID }() + if pc != db.cc { + return nil, tnla, tnlb, fmt.Errorf("invalid passed transaction context") + } + + rs, err = s.exec(&execCtx{db, arg}) + return rs, tnla, tnlb, err + } + } +} + +// Flush ends the transaction collecting window, if applicable. IOW, if the DB +// is dirty, it schedules a 2PC (WAL + DB file) commit on the next outer most +// DB.Commit or performs it synchronously if there's currently no open +// transaction. +// +// The collecting window is an implementation detail and future versions of +// Flush may become a no operation while keeping the operation semantics. +func (db *DB) Flush() (err error) { + return nil +} + +// Close will close the DB. Successful Close is idempotent. +func (db *DB) Close() error { + db.mu.Lock() + defer db.mu.Unlock() + if db.store == nil { + return nil + } + + if db.tnl != 0 { + return fmt.Errorf("cannot close DB while open transaction exist") + } + + err := db.store.Close() + db.root, db.store = nil, nil + return err +} + +func (db *DB) do(r recordset, f func(data []interface{}) (bool, error)) (err error) { + db.mu.Lock() + switch db.rw { + case false: + db.rwmu.RLock() // can safely grab before Unlock + db.mu.Unlock() + defer db.rwmu.RUnlock() + default: // case true: + if r.tx == nil { + db.mu.Unlock() // must Unlock before RLock + db.rwmu.RLock() + defer db.rwmu.RUnlock() + break + } + + defer db.mu.Unlock() + if r.tx != db.cc { + return fmt.Errorf("invalid passed transaction context") + } + } + + return r.do(r.ctx, func(id interface{}, data []interface{}) (bool, error) { + if err = expand(data); err != nil { + return false, err + } + + return f(data) + }) +} + +func (db *DB) beginTransaction() { //TODO Rewrite, must use much smaller undo info! + root := *db.root + root.parent = db.root + root.tables = make(map[string]*table, len(db.root.tables)) + var tprev *table + for t := db.root.thead; t != nil; t = t.tnext { + t2 := t.clone() + root.tables[t2.name] = t2 + t2.tprev = tprev + switch { + case tprev == nil: + root.thead = t2 + default: + tprev.tnext = t2 + } + tprev = t2 + } + db.root = &root +} + +func (db *DB) rollback() { + db.root = db.root.parent +} + +func (db *DB) commit() { + db.root.parent = db.root.parent.parent +} + +// Type represents a QL type (bigint, int, string, ...) +type Type int + +// Values of ColumnInfo.Type. +const ( + BigInt Type = qBigInt + BigRat = qBigRat + Blob = qBlob + Bool = qBool + Complex128 = qComplex128 + Complex64 = qComplex64 + Duration = qDuration + Float32 = qFloat32 + Float64 = qFloat64 + Int16 = qInt16 + Int32 = qInt32 + Int64 = qInt64 + Int8 = qInt8 + String = qString + Time = qTime + Uint16 = qUint16 + Uint32 = qUint32 + Uint64 = qUint64 + Uint8 = qUint8 +) + +// String implements fmt.Stringer. +func (t Type) String() string { + return typeStr(int(t)) +} + +// ColumnInfo provides meta data describing a table column. +type ColumnInfo struct { + Name string // Column name. + Type Type // Column type (BigInt, BigRat, ...). + NotNull bool // Column cannot be NULL. + Constraint string // Constraint expression, if any. + Default string // Default expression, if any. +} + +// TableInfo provides meta data describing a DB table. +type TableInfo struct { + // Table name. + Name string + + // Table schema. Columns are listed in the order in which they appear + // in the schema. + Columns []ColumnInfo +} + +// IndexInfo provides meta data describing a DB index. It corresponds to the +// statement +// +// CREATE INDEX Name ON Table (Column); +type IndexInfo struct { + Name string // Index name + Table string // Table name. + Column string // Column name. + Unique bool // Wheter the index is unique. + ExpressionList []string // Index expression list. +} + +// DbInfo provides meta data describing a DB. +type DbInfo struct { + Name string // DB name. + Tables []TableInfo // Tables in the DB. + Indices []IndexInfo // Indices in the DB. +} + +func (db *DB) info() (r *DbInfo, err error) { + _, hasColumn2 := db.root.tables["__Column2"] + r = &DbInfo{Name: db.Name()} + for nm, t := range db.root.tables { + ti := TableInfo{Name: nm} + m := map[string]*ColumnInfo{} + if hasColumn2 { + rs, err := selectColumn2.l[0].exec(&execCtx{db: db, arg: []interface{}{nm}}) + if err != nil { + return nil, err + } + + if err := rs.(recordset).do( + &execCtx{db: db, arg: []interface{}{nm}}, + func(id interface{}, data []interface{}) (bool, error) { + ci := &ColumnInfo{NotNull: data[1].(bool), Constraint: data[2].(string), Default: data[3].(string)} + m[data[0].(string)] = ci + return true, nil + }, + ); err != nil { + return nil, err + } + } + for _, c := range t.cols { + ci := ColumnInfo{Name: c.name, Type: Type(c.typ)} + if c2 := m[c.name]; c2 != nil { + ci.NotNull = c2.NotNull + ci.Constraint = c2.Constraint + ci.Default = c2.Default + } + ti.Columns = append(ti.Columns, ci) + } + r.Tables = append(r.Tables, ti) + for i, x := range t.indices { + if x == nil { + continue + } + + var cn string + switch { + case i == 0: + cn = "id()" + default: + cn = t.cols0[i-1].name + } + r.Indices = append(r.Indices, IndexInfo{x.name, nm, cn, x.unique, []string{cn}}) + } + var a []string + for k := range t.indices2 { + a = append(a, k) + } + for _, k := range a { + x := t.indices2[k] + a = a[:0] + for _, e := range x.exprList { + a = append(a, e.String()) + } + r.Indices = append(r.Indices, IndexInfo{k, nm, "", x.unique, a}) + } + } + return +} + +// Info provides meta data describing a DB or an error if any. It locks the DB +// to obtain the result. +func (db *DB) Info() (r *DbInfo, err error) { + db.mu.Lock() + defer db.mu.Unlock() + return db.info() +} + +type constraint struct { + expr expression // If expr == nil: constraint is 'NOT NULL' +} + +func (c *constraint) clone() *constraint { + if c == nil { + return nil + } + + var e expression + if c.expr != nil { + e, _ = c.expr.clone(nil) + } + return &constraint{e} +} + +type joinRset struct { + sources []interface{} + typ int + on expression +} + +func (r *joinRset) String() string { + a := make([]string, len(r.sources)) + for i, pair0 := range r.sources { + pair := pair0.([]interface{}) + altName := pair[1].(string) + switch x := pair[0].(type) { + case string: // table name + switch { + case altName == "": + a[i] = x + default: + a[i] = fmt.Sprintf("%s AS %s", x, altName) + } + case *selectStmt: + switch { + case altName == "": + a[i] = fmt.Sprintf("(%s)", x) + default: + a[i] = fmt.Sprintf("(%s) AS %s", x, altName) + } + default: + panic("internal error 054") + } + } + n := len(a) + a2 := a[:n-1] + j := a[n-1] + var s string + switch r.typ { + case crossJoin: + return strings.Join(a, ", ") + case leftJoin: + s = strings.Join(a2, ",") + " LEFT" + case rightJoin: + s = strings.Join(a2, ",") + " RIGHT" + case fullJoin: + s = strings.Join(a2, ",") + " FULL" + } + s += " OUTER JOIN " + j + " ON " + r.on.String() + return s +} + +func (r *joinRset) plan(ctx *execCtx) (plan, error) { + rsets := make([]plan, len(r.sources)) + names := make([]string, len(r.sources)) + var err error + m := map[string]bool{} + var fields []string + for i, v := range r.sources { + pair := v.([]interface{}) + src := pair[0] + nm := pair[1].(string) + if s, ok := src.(string); ok { + src = tableRset(s) + if nm == "" { + nm = s + } + } + if m[nm] { + return nil, fmt.Errorf("%s: duplicate name %s", r.String(), nm) + } + + if nm != "" { + m[nm] = true + } + names[i] = nm + var q plan + switch x := src.(type) { + case rset: + if q, err = x.plan(ctx); err != nil { + return nil, err + } + case plan: + q = x + default: + panic("internal error 008") + } + + switch { + case len(r.sources) == 1: + fields = q.fieldNames() + default: + for _, f := range q.fieldNames() { + if strings.Contains(f, ".") { + return nil, fmt.Errorf("cannot join on recordset with already qualified field names (use the AS clause): %s", f) + } + + if f != "" && nm != "" { + f = fmt.Sprintf("%s.%s", nm, f) + } + if nm == "" { + f = "" + } + fields = append(fields, f) + } + } + rsets[i] = q + } + + if len(rsets) == 1 { + return rsets[0], nil + } + + right := len(rsets[len(rsets)-1].fieldNames()) + switch r.typ { + case crossJoin: + return &crossJoinDefaultPlan{rsets: rsets, names: names, fields: fields}, nil + case leftJoin: + return &leftJoinDefaultPlan{rsets: rsets, names: names, fields: fields, on: r.on, right: right}, nil + case rightJoin: + return &rightJoinDefaultPlan{leftJoinDefaultPlan{rsets: rsets, names: names, fields: fields, on: r.on, right: right}}, nil + case fullJoin: + return &fullJoinDefaultPlan{leftJoinDefaultPlan{rsets: rsets, names: names, fields: fields, on: r.on, right: right}}, nil + default: + panic("internal error 010") + } +} + +type fld struct { + expr expression + name string +} diff --git a/vendor/github.com/cznic/ql/scanner.go b/vendor/github.com/cznic/ql/scanner.go new file mode 100644 index 0000000000..aafa3cf8fa --- /dev/null +++ b/vendor/github.com/cznic/ql/scanner.go @@ -0,0 +1,4129 @@ +// CAUTION: Generated file - DO NOT EDIT. + +/* +Copyright (c) 2014 The ql 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 ql + +import ( + "fmt" + "math" + "strconv" + "unicode" +) + +type lexer struct { + agg []bool + c int + col int + errs []error + expr expression + i int + inj int + lcol int + line int + list []stmt + ncol int + nline int + params int + sc int + src string + val []byte + root bool +} + +func newLexer(src string) (l *lexer) { + l = &lexer{ + src: src, + nline: 1, + ncol: 0, + } + l.next() + return +} + +func (l *lexer) next() int { + if l.c != 0 { + l.val = append(l.val, byte(l.c)) + } + l.c = 0 + if l.i < len(l.src) { + l.c = int(l.src[l.i]) + l.i++ + } + switch l.c { + case '\n': + l.lcol = l.ncol + l.nline++ + l.ncol = 0 + default: + l.ncol++ + } + return l.c +} + +func (l *lexer) err0(ln, c int, s string, arg ...interface{}) { + err := fmt.Errorf(fmt.Sprintf("%d:%d ", ln, c)+s, arg...) + l.errs = append(l.errs, err) +} + +func (l *lexer) err(s string, arg ...interface{}) { + l.err0(l.line, l.col, s, arg...) +} + +func (l *lexer) Error(s string) { + l.err(s) +} + +func (l *lexer) Lex(lval *yySymType) (r int) { + //defer func() { dbg("Lex -> %d(%#x)", r, r) }() + defer func() { + lval.line, lval.col = l.line, l.col + }() + const ( + INITIAL = iota + S1 + S2 + ) + + if n := l.inj; n != 0 { + l.inj = 0 + return n + } + + c0, c := 0, l.c + +yystate0: + + l.val = l.val[:0] + c0, l.line, l.col = l.c, l.nline, l.ncol + + switch yyt := l.sc; yyt { + default: + panic(fmt.Errorf(`invalid start condition %d`, yyt)) + case 0: // start condition: INITIAL + goto yystart1 + case 1: // start condition: S1 + goto yystart319 + case 2: // start condition: S2 + goto yystart324 + } + + goto yystate0 // silence unused label error + goto yystate1 // silence unused label error +yystate1: + c = l.next() +yystart1: + switch { + default: + goto yystate3 // c >= '\x01' && c <= '\b' || c == '\v' || c == '\f' || c >= '\x0e' && c <= '\x1f' || c == '#' || c == '%%' || c >= '(' && c <= ',' || c == ':' || c == ';' || c == '@' || c >= '[' && c <= '^' || c == '{' || c >= '}' && c <= 'ÿ' + case c == '!': + goto yystate6 + case c == '"': + goto yystate8 + case c == '$' || c == '?': + goto yystate9 + case c == '&': + goto yystate11 + case c == '-': + goto yystate19 + case c == '.': + goto yystate21 + case c == '/': + goto yystate27 + case c == '0': + goto yystate32 + case c == '<': + goto yystate40 + case c == '=': + goto yystate43 + case c == '>': + goto yystate45 + case c == 'A' || c == 'a': + goto yystate48 + case c == 'B' || c == 'b': + goto yystate60 + case c == 'C' || c == 'c': + goto yystate87 + case c == 'D' || c == 'd': + goto yystate111 + case c == 'E' || c == 'e': + goto yystate141 + case c == 'F' || c == 'f': + goto yystate152 + case c == 'G' || c == 'g': + goto yystate171 + case c == 'H' || c == 'K' || c == 'M' || c == 'P' || c == 'Q' || c >= 'X' && c <= 'Z' || c == '_' || c == 'h' || c == 'k' || c == 'm' || c == 'p' || c == 'q' || c >= 'x' && c <= 'z': + goto yystate176 + case c == 'I' || c == 'i': + goto yystate177 + case c == 'J' || c == 'j': + goto yystate197 + case c == 'L' || c == 'l': + goto yystate201 + case c == 'N' || c == 'n': + goto yystate211 + case c == 'O' || c == 'o': + goto yystate217 + case c == 'R' || c == 'r': + goto yystate232 + case c == 'S' || c == 's': + goto yystate247 + case c == 'T' || c == 't': + goto yystate259 + case c == 'U' || c == 'u': + goto yystate284 + case c == 'V' || c == 'v': + goto yystate305 + case c == 'W' || c == 'w': + goto yystate311 + case c == '\'': + goto yystate14 + case c == '\n': + goto yystate5 + case c == '\t' || c == '\r' || c == ' ': + goto yystate4 + case c == '\x00': + goto yystate2 + case c == '`': + goto yystate316 + case c == '|': + goto yystate317 + case c >= '1' && c <= '9': + goto yystate38 + } + +yystate2: + c = l.next() + goto yyrule1 + +yystate3: + c = l.next() + goto yyrule101 + +yystate4: + c = l.next() + switch { + default: + goto yyrule2 + case c == '\t' || c == '\n' || c == '\r' || c == ' ': + goto yystate5 + } + +yystate5: + c = l.next() + switch { + default: + goto yyrule2 + case c == '\t' || c == '\n' || c == '\r' || c == ' ': + goto yystate5 + } + +yystate6: + c = l.next() + switch { + default: + goto yyrule101 + case c == '=': + goto yystate7 + } + +yystate7: + c = l.next() + goto yyrule21 + +yystate8: + c = l.next() + goto yyrule10 + +yystate9: + c = l.next() + switch { + default: + goto yyrule101 + case c >= '0' && c <= '9': + goto yystate10 + } + +yystate10: + c = l.next() + switch { + default: + goto yyrule100 + case c >= '0' && c <= '9': + goto yystate10 + } + +yystate11: + c = l.next() + switch { + default: + goto yyrule101 + case c == '&': + goto yystate12 + case c == '^': + goto yystate13 + } + +yystate12: + c = l.next() + goto yyrule15 + +yystate13: + c = l.next() + goto yyrule16 + +yystate14: + c = l.next() + switch { + default: + goto yyrule101 + case c == '\'': + goto yystate16 + case c == '\\': + goto yystate17 + case c >= '\x01' && c <= '&' || c >= '(' && c <= '[' || c >= ']' && c <= 'ÿ': + goto yystate15 + } + +yystate15: + c = l.next() + switch { + default: + goto yyabort + case c == '\'': + goto yystate16 + case c == '\\': + goto yystate17 + case c >= '\x01' && c <= '&' || c >= '(' && c <= '[' || c >= ']' && c <= 'ÿ': + goto yystate15 + } + +yystate16: + c = l.next() + goto yyrule12 + +yystate17: + c = l.next() + switch { + default: + goto yyabort + case c == '\'': + goto yystate18 + case c == '\\': + goto yystate17 + case c >= '\x01' && c <= '&' || c >= '(' && c <= '[' || c >= ']' && c <= 'ÿ': + goto yystate15 + } + +yystate18: + c = l.next() + switch { + default: + goto yyrule12 + case c == '\'': + goto yystate16 + case c == '\\': + goto yystate17 + case c >= '\x01' && c <= '&' || c >= '(' && c <= '[' || c >= ']' && c <= 'ÿ': + goto yystate15 + } + +yystate19: + c = l.next() + switch { + default: + goto yyrule101 + case c == '-': + goto yystate20 + } + +yystate20: + c = l.next() + switch { + default: + goto yyrule3 + case c >= '\x01' && c <= '\t' || c >= '\v' && c <= 'ÿ': + goto yystate20 + } + +yystate21: + c = l.next() + switch { + default: + goto yyrule101 + case c >= '0' && c <= '9': + goto yystate22 + } + +yystate22: + c = l.next() + switch { + default: + goto yyrule9 + case c == 'E' || c == 'e': + goto yystate23 + case c == 'i': + goto yystate26 + case c >= '0' && c <= '9': + goto yystate22 + } + +yystate23: + c = l.next() + switch { + default: + goto yyabort + case c == '+' || c == '-': + goto yystate24 + case c >= '0' && c <= '9': + goto yystate25 + } + +yystate24: + c = l.next() + switch { + default: + goto yyabort + case c >= '0' && c <= '9': + goto yystate25 + } + +yystate25: + c = l.next() + switch { + default: + goto yyrule9 + case c == 'i': + goto yystate26 + case c >= '0' && c <= '9': + goto yystate25 + } + +yystate26: + c = l.next() + goto yyrule7 + +yystate27: + c = l.next() + switch { + default: + goto yyrule101 + case c == '*': + goto yystate28 + case c == '/': + goto yystate31 + } + +yystate28: + c = l.next() + switch { + default: + goto yyabort + case c == '*': + goto yystate29 + case c >= '\x01' && c <= ')' || c >= '+' && c <= 'ÿ': + goto yystate28 + } + +yystate29: + c = l.next() + switch { + default: + goto yyabort + case c == '*': + goto yystate29 + case c == '/': + goto yystate30 + case c >= '\x01' && c <= ')' || c >= '+' && c <= '.' || c >= '0' && c <= 'ÿ': + goto yystate28 + } + +yystate30: + c = l.next() + goto yyrule5 + +yystate31: + c = l.next() + switch { + default: + goto yyrule4 + case c >= '\x01' && c <= '\t' || c >= '\v' && c <= 'ÿ': + goto yystate31 + } + +yystate32: + c = l.next() + switch { + default: + goto yyrule8 + case c == '.': + goto yystate22 + case c == '8' || c == '9': + goto yystate34 + case c == 'E' || c == 'e': + goto yystate23 + case c == 'X' || c == 'x': + goto yystate36 + case c == 'i': + goto yystate35 + case c >= '0' && c <= '7': + goto yystate33 + } + +yystate33: + c = l.next() + switch { + default: + goto yyrule8 + case c == '.': + goto yystate22 + case c == '8' || c == '9': + goto yystate34 + case c == 'E' || c == 'e': + goto yystate23 + case c == 'i': + goto yystate35 + case c >= '0' && c <= '7': + goto yystate33 + } + +yystate34: + c = l.next() + switch { + default: + goto yyabort + case c == '.': + goto yystate22 + case c == 'E' || c == 'e': + goto yystate23 + case c == 'i': + goto yystate35 + case c >= '0' && c <= '9': + goto yystate34 + } + +yystate35: + c = l.next() + goto yyrule6 + +yystate36: + c = l.next() + switch { + default: + goto yyabort + case c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f': + goto yystate37 + } + +yystate37: + c = l.next() + switch { + default: + goto yyrule8 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f': + goto yystate37 + } + +yystate38: + c = l.next() + switch { + default: + goto yyrule8 + case c == '.': + goto yystate22 + case c == 'E' || c == 'e': + goto yystate23 + case c == 'i': + goto yystate35 + case c >= '0' && c <= '9': + goto yystate39 + } + +yystate39: + c = l.next() + switch { + default: + goto yyrule8 + case c == '.': + goto yystate22 + case c == 'E' || c == 'e': + goto yystate23 + case c == 'i': + goto yystate35 + case c >= '0' && c <= '9': + goto yystate39 + } + +yystate40: + c = l.next() + switch { + default: + goto yyrule101 + case c == '<': + goto yystate41 + case c == '=': + goto yystate42 + } + +yystate41: + c = l.next() + goto yyrule17 + +yystate42: + c = l.next() + goto yyrule18 + +yystate43: + c = l.next() + switch { + default: + goto yyrule101 + case c == '=': + goto yystate44 + } + +yystate44: + c = l.next() + goto yyrule19 + +yystate45: + c = l.next() + switch { + default: + goto yyrule101 + case c == '=': + goto yystate46 + case c == '>': + goto yystate47 + } + +yystate46: + c = l.next() + goto yyrule20 + +yystate47: + c = l.next() + goto yyrule23 + +yystate48: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'D' || c == 'd': + goto yystate50 + case c == 'L' || c == 'l': + goto yystate52 + case c == 'N' || c == 'n': + goto yystate56 + case c == 'S' || c == 's': + goto yystate58 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'C' || c >= 'E' && c <= 'K' || c == 'M' || c >= 'O' && c <= 'R' || c >= 'T' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'c' || c >= 'e' && c <= 'k' || c == 'm' || c >= 'o' && c <= 'r' || c >= 't' && c <= 'z': + goto yystate49 + } + +yystate49: + c = l.next() + switch { + default: + goto yyrule99 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate50: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'D' || c == 'd': + goto yystate51 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'C' || c >= 'E' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'c' || c >= 'e' && c <= 'z': + goto yystate49 + } + +yystate51: + c = l.next() + switch { + default: + goto yyrule24 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate52: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'T' || c == 't': + goto yystate53 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate53: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate54 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': + goto yystate49 + } + +yystate54: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'R' || c == 'r': + goto yystate55 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'q' || c >= 's' && c <= 'z': + goto yystate49 + } + +yystate55: + c = l.next() + switch { + default: + goto yyrule25 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate56: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'D' || c == 'd': + goto yystate57 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'C' || c >= 'E' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'c' || c >= 'e' && c <= 'z': + goto yystate49 + } + +yystate57: + c = l.next() + switch { + default: + goto yyrule26 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate58: + c = l.next() + switch { + default: + goto yyrule28 + case c == 'C' || c == 'c': + goto yystate59 + case c >= '0' && c <= '9' || c == 'A' || c == 'B' || c >= 'D' && c <= 'Z' || c == '_' || c == 'a' || c == 'b' || c >= 'd' && c <= 'z': + goto yystate49 + } + +yystate59: + c = l.next() + switch { + default: + goto yyrule27 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate60: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate61 + case c == 'I' || c == 'i': + goto yystate70 + case c == 'L' || c == 'l': + goto yystate78 + case c == 'O' || c == 'o': + goto yystate81 + case c == 'Y' || c == 'y': + goto yystate84 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'H' || c == 'J' || c == 'K' || c == 'M' || c == 'N' || c >= 'P' && c <= 'X' || c == 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'h' || c == 'j' || c == 'k' || c == 'm' || c == 'n' || c >= 'p' && c <= 'x' || c == 'z': + goto yystate49 + } + +yystate61: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'G' || c == 'g': + goto yystate62 + case c == 'T' || c == 't': + goto yystate65 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'H' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'f' || c >= 'h' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate62: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'I' || c == 'i': + goto yystate63 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z': + goto yystate49 + } + +yystate63: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'N' || c == 'n': + goto yystate64 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z': + goto yystate49 + } + +yystate64: + c = l.next() + switch { + default: + goto yyrule29 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate65: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'W' || c == 'w': + goto yystate66 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'V' || c >= 'X' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'v' || c >= 'x' && c <= 'z': + goto yystate49 + } + +yystate66: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate67 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': + goto yystate49 + } + +yystate67: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate68 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': + goto yystate49 + } + +yystate68: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'N' || c == 'n': + goto yystate69 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z': + goto yystate49 + } + +yystate69: + c = l.next() + switch { + default: + goto yyrule30 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate70: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'G' || c == 'g': + goto yystate71 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'H' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'f' || c >= 'h' && c <= 'z': + goto yystate49 + } + +yystate71: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'I' || c == 'i': + goto yystate72 + case c == 'R' || c == 'r': + goto yystate75 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'q' || c >= 's' && c <= 'z': + goto yystate49 + } + +yystate72: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'N' || c == 'n': + goto yystate73 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z': + goto yystate49 + } + +yystate73: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'T' || c == 't': + goto yystate74 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate74: + c = l.next() + switch { + default: + goto yyrule75 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate75: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'A' || c == 'a': + goto yystate76 + case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z': + goto yystate49 + } + +yystate76: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'T' || c == 't': + goto yystate77 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate77: + c = l.next() + switch { + default: + goto yyrule76 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate78: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'O' || c == 'o': + goto yystate79 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z': + goto yystate49 + } + +yystate79: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'B' || c == 'b': + goto yystate80 + case c >= '0' && c <= '9' || c == 'A' || c >= 'C' && c <= 'Z' || c == '_' || c == 'a' || c >= 'c' && c <= 'z': + goto yystate49 + } + +yystate80: + c = l.next() + switch { + default: + goto yyrule77 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate81: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'O' || c == 'o': + goto yystate82 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z': + goto yystate49 + } + +yystate82: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'L' || c == 'l': + goto yystate83 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z': + goto yystate49 + } + +yystate83: + c = l.next() + switch { + default: + goto yyrule78 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate84: + c = l.next() + switch { + default: + goto yyrule31 + case c == 'T' || c == 't': + goto yystate85 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate85: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate86 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': + goto yystate49 + } + +yystate86: + c = l.next() + switch { + default: + goto yyrule79 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate87: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'O' || c == 'o': + goto yystate88 + case c == 'R' || c == 'r': + goto yystate106 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c == 'P' || c == 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c == 'p' || c == 'q' || c >= 's' && c <= 'z': + goto yystate49 + } + +yystate88: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'L' || c == 'l': + goto yystate89 + case c == 'M' || c == 'm': + goto yystate93 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'N' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'n' && c <= 'z': + goto yystate49 + } + +yystate89: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'U' || c == 'u': + goto yystate90 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'a' && c <= 't' || c >= 'v' && c <= 'z': + goto yystate49 + } + +yystate90: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'M' || c == 'm': + goto yystate91 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'L' || c >= 'N' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'l' || c >= 'n' && c <= 'z': + goto yystate49 + } + +yystate91: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'N' || c == 'n': + goto yystate92 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z': + goto yystate49 + } + +yystate92: + c = l.next() + switch { + default: + goto yyrule32 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate93: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'M' || c == 'm': + goto yystate94 + case c == 'P' || c == 'p': + goto yystate97 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'L' || c == 'N' || c == 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'l' || c == 'n' || c == 'o' || c >= 'q' && c <= 'z': + goto yystate49 + } + +yystate94: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'I' || c == 'i': + goto yystate95 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z': + goto yystate49 + } + +yystate95: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'T' || c == 't': + goto yystate96 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate96: + c = l.next() + switch { + default: + goto yyrule33 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate97: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'L' || c == 'l': + goto yystate98 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z': + goto yystate49 + } + +yystate98: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate99 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': + goto yystate49 + } + +yystate99: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'X' || c == 'x': + goto yystate100 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'W' || c == 'Y' || c == 'Z' || c == '_' || c >= 'a' && c <= 'w' || c == 'y' || c == 'z': + goto yystate49 + } + +yystate100: + c = l.next() + switch { + default: + goto yyrule99 + case c == '0' || c >= '2' && c <= '5' || c >= '7' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + case c == '1': + goto yystate101 + case c == '6': + goto yystate104 + } + +yystate101: + c = l.next() + switch { + default: + goto yyrule99 + case c == '0' || c == '1' || c >= '3' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + case c == '2': + goto yystate102 + } + +yystate102: + c = l.next() + switch { + default: + goto yyrule99 + case c == '8': + goto yystate103 + case c >= '0' && c <= '7' || c == '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate103: + c = l.next() + switch { + default: + goto yyrule80 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate104: + c = l.next() + switch { + default: + goto yyrule99 + case c == '4': + goto yystate105 + case c >= '0' && c <= '3' || c >= '5' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate105: + c = l.next() + switch { + default: + goto yyrule81 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate106: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate107 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': + goto yystate49 + } + +yystate107: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'A' || c == 'a': + goto yystate108 + case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z': + goto yystate49 + } + +yystate108: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'T' || c == 't': + goto yystate109 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate109: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate110 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': + goto yystate49 + } + +yystate110: + c = l.next() + switch { + default: + goto yyrule34 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate111: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate112 + case c == 'I' || c == 'i': + goto yystate124 + case c == 'R' || c == 'r': + goto yystate131 + case c == 'U' || c == 'u': + goto yystate134 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'H' || c >= 'J' && c <= 'Q' || c == 'S' || c == 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'h' || c >= 'j' && c <= 'q' || c == 's' || c == 't' || c >= 'v' && c <= 'z': + goto yystate49 + } + +yystate112: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'F' || c == 'f': + goto yystate113 + case c == 'L' || c == 'l': + goto yystate118 + case c == 'S' || c == 's': + goto yystate122 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'E' || c >= 'G' && c <= 'K' || c >= 'M' && c <= 'R' || c >= 'T' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'e' || c >= 'g' && c <= 'k' || c >= 'm' && c <= 'r' || c >= 't' && c <= 'z': + goto yystate49 + } + +yystate113: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'A' || c == 'a': + goto yystate114 + case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z': + goto yystate49 + } + +yystate114: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'U' || c == 'u': + goto yystate115 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'a' && c <= 't' || c >= 'v' && c <= 'z': + goto yystate49 + } + +yystate115: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'L' || c == 'l': + goto yystate116 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z': + goto yystate49 + } + +yystate116: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'T' || c == 't': + goto yystate117 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate117: + c = l.next() + switch { + default: + goto yyrule35 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate118: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate119 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': + goto yystate49 + } + +yystate119: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'T' || c == 't': + goto yystate120 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate120: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate121 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': + goto yystate49 + } + +yystate121: + c = l.next() + switch { + default: + goto yyrule36 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate122: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'C' || c == 'c': + goto yystate123 + case c >= '0' && c <= '9' || c == 'A' || c == 'B' || c >= 'D' && c <= 'Z' || c == '_' || c == 'a' || c == 'b' || c >= 'd' && c <= 'z': + goto yystate49 + } + +yystate123: + c = l.next() + switch { + default: + goto yyrule37 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate124: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'S' || c == 's': + goto yystate125 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'R' || c >= 'T' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'r' || c >= 't' && c <= 'z': + goto yystate49 + } + +yystate125: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'T' || c == 't': + goto yystate126 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate126: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'I' || c == 'i': + goto yystate127 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z': + goto yystate49 + } + +yystate127: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'N' || c == 'n': + goto yystate128 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z': + goto yystate49 + } + +yystate128: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'C' || c == 'c': + goto yystate129 + case c >= '0' && c <= '9' || c == 'A' || c == 'B' || c >= 'D' && c <= 'Z' || c == '_' || c == 'a' || c == 'b' || c >= 'd' && c <= 'z': + goto yystate49 + } + +yystate129: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'T' || c == 't': + goto yystate130 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate130: + c = l.next() + switch { + default: + goto yyrule38 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate131: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'O' || c == 'o': + goto yystate132 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z': + goto yystate49 + } + +yystate132: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'P' || c == 'p': + goto yystate133 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'o' || c >= 'q' && c <= 'z': + goto yystate49 + } + +yystate133: + c = l.next() + switch { + default: + goto yyrule39 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate134: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'R' || c == 'r': + goto yystate135 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'q' || c >= 's' && c <= 'z': + goto yystate49 + } + +yystate135: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'A' || c == 'a': + goto yystate136 + case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z': + goto yystate49 + } + +yystate136: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'T' || c == 't': + goto yystate137 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate137: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'I' || c == 'i': + goto yystate138 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z': + goto yystate49 + } + +yystate138: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'O' || c == 'o': + goto yystate139 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z': + goto yystate49 + } + +yystate139: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'N' || c == 'n': + goto yystate140 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z': + goto yystate49 + } + +yystate140: + c = l.next() + switch { + default: + goto yyrule82 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate141: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'X' || c == 'x': + goto yystate142 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'W' || c == 'Y' || c == 'Z' || c == '_' || c >= 'a' && c <= 'w' || c == 'y' || c == 'z': + goto yystate49 + } + +yystate142: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'I' || c == 'i': + goto yystate143 + case c == 'P' || c == 'p': + goto yystate147 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'o' || c >= 'q' && c <= 'z': + goto yystate49 + } + +yystate143: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'S' || c == 's': + goto yystate144 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'R' || c >= 'T' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'r' || c >= 't' && c <= 'z': + goto yystate49 + } + +yystate144: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'T' || c == 't': + goto yystate145 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate145: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'S' || c == 's': + goto yystate146 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'R' || c >= 'T' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'r' || c >= 't' && c <= 'z': + goto yystate49 + } + +yystate146: + c = l.next() + switch { + default: + goto yyrule40 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate147: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'L' || c == 'l': + goto yystate148 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z': + goto yystate49 + } + +yystate148: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'A' || c == 'a': + goto yystate149 + case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z': + goto yystate49 + } + +yystate149: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'I' || c == 'i': + goto yystate150 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z': + goto yystate49 + } + +yystate150: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'N' || c == 'n': + goto yystate151 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z': + goto yystate49 + } + +yystate151: + c = l.next() + switch { + default: + goto yyrule41 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate152: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'A' || c == 'a': + goto yystate153 + case c == 'L' || c == 'l': + goto yystate157 + case c == 'R' || c == 'r': + goto yystate165 + case c == 'U' || c == 'u': + goto yystate168 + case c >= '0' && c <= '9' || c >= 'B' && c <= 'K' || c >= 'M' && c <= 'Q' || c == 'S' || c == 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'k' || c >= 'm' && c <= 'q' || c == 's' || c == 't' || c >= 'v' && c <= 'z': + goto yystate49 + } + +yystate153: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'L' || c == 'l': + goto yystate154 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z': + goto yystate49 + } + +yystate154: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'S' || c == 's': + goto yystate155 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'R' || c >= 'T' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'r' || c >= 't' && c <= 'z': + goto yystate49 + } + +yystate155: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate156 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': + goto yystate49 + } + +yystate156: + c = l.next() + switch { + default: + goto yyrule73 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate157: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'O' || c == 'o': + goto yystate158 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z': + goto yystate49 + } + +yystate158: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'A' || c == 'a': + goto yystate159 + case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z': + goto yystate49 + } + +yystate159: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'T' || c == 't': + goto yystate160 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate160: + c = l.next() + switch { + default: + goto yyrule83 + case c == '3': + goto yystate161 + case c == '6': + goto yystate163 + case c >= '0' && c <= '2' || c == '4' || c == '5' || c >= '7' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate161: + c = l.next() + switch { + default: + goto yyrule99 + case c == '0' || c == '1' || c >= '3' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + case c == '2': + goto yystate162 + } + +yystate162: + c = l.next() + switch { + default: + goto yyrule84 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate163: + c = l.next() + switch { + default: + goto yyrule99 + case c == '4': + goto yystate164 + case c >= '0' && c <= '3' || c >= '5' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate164: + c = l.next() + switch { + default: + goto yyrule85 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate165: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'O' || c == 'o': + goto yystate166 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z': + goto yystate49 + } + +yystate166: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'M' || c == 'm': + goto yystate167 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'L' || c >= 'N' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'l' || c >= 'n' && c <= 'z': + goto yystate49 + } + +yystate167: + c = l.next() + switch { + default: + goto yyrule42 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate168: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'L' || c == 'l': + goto yystate169 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z': + goto yystate49 + } + +yystate169: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'L' || c == 'l': + goto yystate170 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z': + goto yystate49 + } + +yystate170: + c = l.next() + switch { + default: + goto yyrule43 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate171: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'R' || c == 'r': + goto yystate172 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'q' || c >= 's' && c <= 'z': + goto yystate49 + } + +yystate172: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'O' || c == 'o': + goto yystate173 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z': + goto yystate49 + } + +yystate173: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'U' || c == 'u': + goto yystate174 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'a' && c <= 't' || c >= 'v' && c <= 'z': + goto yystate49 + } + +yystate174: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'P' || c == 'p': + goto yystate175 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'o' || c >= 'q' && c <= 'z': + goto yystate49 + } + +yystate175: + c = l.next() + switch { + default: + goto yyrule44 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate176: + c = l.next() + switch { + default: + goto yyrule99 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate177: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'F' || c == 'f': + goto yystate178 + case c == 'N' || c == 'n': + goto yystate179 + case c == 'S' || c == 's': + goto yystate196 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'E' || c >= 'G' && c <= 'M' || c >= 'O' && c <= 'R' || c >= 'T' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'e' || c >= 'g' && c <= 'm' || c >= 'o' && c <= 'r' || c >= 't' && c <= 'z': + goto yystate49 + } + +yystate178: + c = l.next() + switch { + default: + goto yyrule45 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate179: + c = l.next() + switch { + default: + goto yyrule49 + case c == 'D' || c == 'd': + goto yystate180 + case c == 'S' || c == 's': + goto yystate183 + case c == 'T' || c == 't': + goto yystate187 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'C' || c >= 'E' && c <= 'R' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'c' || c >= 'e' && c <= 'r' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate180: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate181 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': + goto yystate49 + } + +yystate181: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'X' || c == 'x': + goto yystate182 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'W' || c == 'Y' || c == 'Z' || c == '_' || c >= 'a' && c <= 'w' || c == 'y' || c == 'z': + goto yystate49 + } + +yystate182: + c = l.next() + switch { + default: + goto yyrule46 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate183: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate184 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': + goto yystate49 + } + +yystate184: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'R' || c == 'r': + goto yystate185 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'q' || c >= 's' && c <= 'z': + goto yystate49 + } + +yystate185: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'T' || c == 't': + goto yystate186 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate186: + c = l.next() + switch { + default: + goto yyrule47 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate187: + c = l.next() + switch { + default: + goto yyrule86 + case c == '0' || c == '2' || c == '4' || c == '5' || c == '7' || c == '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z': + goto yystate49 + case c == '1': + goto yystate188 + case c == '3': + goto yystate190 + case c == '6': + goto yystate192 + case c == '8': + goto yystate194 + case c == 'O' || c == 'o': + goto yystate195 + } + +yystate188: + c = l.next() + switch { + default: + goto yyrule99 + case c == '6': + goto yystate189 + case c >= '0' && c <= '5' || c >= '7' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate189: + c = l.next() + switch { + default: + goto yyrule87 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate190: + c = l.next() + switch { + default: + goto yyrule99 + case c == '0' || c == '1' || c >= '3' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + case c == '2': + goto yystate191 + } + +yystate191: + c = l.next() + switch { + default: + goto yyrule88 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate192: + c = l.next() + switch { + default: + goto yyrule99 + case c == '4': + goto yystate193 + case c >= '0' && c <= '3' || c >= '5' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate193: + c = l.next() + switch { + default: + goto yyrule89 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate194: + c = l.next() + switch { + default: + goto yyrule90 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate195: + c = l.next() + switch { + default: + goto yyrule48 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate196: + c = l.next() + switch { + default: + goto yyrule50 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate197: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'O' || c == 'o': + goto yystate198 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z': + goto yystate49 + } + +yystate198: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'I' || c == 'i': + goto yystate199 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z': + goto yystate49 + } + +yystate199: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'N' || c == 'n': + goto yystate200 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z': + goto yystate49 + } + +yystate200: + c = l.next() + switch { + default: + goto yyrule51 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate201: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate202 + case c == 'I' || c == 'i': + goto yystate205 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'h' || c >= 'j' && c <= 'z': + goto yystate49 + } + +yystate202: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'F' || c == 'f': + goto yystate203 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'E' || c >= 'G' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'e' || c >= 'g' && c <= 'z': + goto yystate49 + } + +yystate203: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'T' || c == 't': + goto yystate204 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate204: + c = l.next() + switch { + default: + goto yyrule52 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate205: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'K' || c == 'k': + goto yystate206 + case c == 'M' || c == 'm': + goto yystate208 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'J' || c == 'L' || c >= 'N' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'j' || c == 'l' || c >= 'n' && c <= 'z': + goto yystate49 + } + +yystate206: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate207 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': + goto yystate49 + } + +yystate207: + c = l.next() + switch { + default: + goto yyrule53 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate208: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'I' || c == 'i': + goto yystate209 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z': + goto yystate49 + } + +yystate209: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'T' || c == 't': + goto yystate210 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate210: + c = l.next() + switch { + default: + goto yyrule54 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate211: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'O' || c == 'o': + goto yystate212 + case c == 'U' || c == 'u': + goto yystate214 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 't' || c >= 'v' && c <= 'z': + goto yystate49 + } + +yystate212: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'T' || c == 't': + goto yystate213 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate213: + c = l.next() + switch { + default: + goto yyrule55 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate214: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'L' || c == 'l': + goto yystate215 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z': + goto yystate49 + } + +yystate215: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'L' || c == 'l': + goto yystate216 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z': + goto yystate49 + } + +yystate216: + c = l.next() + switch { + default: + goto yyrule72 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate217: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'F' || c == 'f': + goto yystate218 + case c == 'N' || c == 'n': + goto yystate223 + case c == 'R' || c == 'r': + goto yystate224 + case c == 'U' || c == 'u': + goto yystate228 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'E' || c >= 'G' && c <= 'M' || c >= 'O' && c <= 'Q' || c == 'S' || c == 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'e' || c >= 'g' && c <= 'm' || c >= 'o' && c <= 'q' || c == 's' || c == 't' || c >= 'v' && c <= 'z': + goto yystate49 + } + +yystate218: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'F' || c == 'f': + goto yystate219 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'E' || c >= 'G' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'e' || c >= 'g' && c <= 'z': + goto yystate49 + } + +yystate219: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'S' || c == 's': + goto yystate220 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'R' || c >= 'T' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'r' || c >= 't' && c <= 'z': + goto yystate49 + } + +yystate220: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate221 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': + goto yystate49 + } + +yystate221: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'T' || c == 't': + goto yystate222 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate222: + c = l.next() + switch { + default: + goto yyrule56 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate223: + c = l.next() + switch { + default: + goto yyrule57 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate224: + c = l.next() + switch { + default: + goto yyrule59 + case c == 'D' || c == 'd': + goto yystate225 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'C' || c >= 'E' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'c' || c >= 'e' && c <= 'z': + goto yystate49 + } + +yystate225: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate226 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': + goto yystate49 + } + +yystate226: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'R' || c == 'r': + goto yystate227 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'q' || c >= 's' && c <= 'z': + goto yystate49 + } + +yystate227: + c = l.next() + switch { + default: + goto yyrule58 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate228: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'T' || c == 't': + goto yystate229 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate229: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate230 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': + goto yystate49 + } + +yystate230: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'R' || c == 'r': + goto yystate231 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'q' || c >= 's' && c <= 'z': + goto yystate49 + } + +yystate231: + c = l.next() + switch { + default: + goto yyrule60 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate232: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'I' || c == 'i': + goto yystate233 + case c == 'O' || c == 'o': + goto yystate237 + case c == 'U' || c == 'u': + goto yystate244 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'N' || c >= 'P' && c <= 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'n' || c >= 'p' && c <= 't' || c >= 'v' && c <= 'z': + goto yystate49 + } + +yystate233: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'G' || c == 'g': + goto yystate234 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'H' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'f' || c >= 'h' && c <= 'z': + goto yystate49 + } + +yystate234: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'H' || c == 'h': + goto yystate235 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'G' || c >= 'I' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'g' || c >= 'i' && c <= 'z': + goto yystate49 + } + +yystate235: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'T' || c == 't': + goto yystate236 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate236: + c = l.next() + switch { + default: + goto yyrule61 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate237: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'L' || c == 'l': + goto yystate238 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z': + goto yystate49 + } + +yystate238: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'L' || c == 'l': + goto yystate239 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z': + goto yystate49 + } + +yystate239: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'B' || c == 'b': + goto yystate240 + case c >= '0' && c <= '9' || c == 'A' || c >= 'C' && c <= 'Z' || c == '_' || c == 'a' || c >= 'c' && c <= 'z': + goto yystate49 + } + +yystate240: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'A' || c == 'a': + goto yystate241 + case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z': + goto yystate49 + } + +yystate241: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'C' || c == 'c': + goto yystate242 + case c >= '0' && c <= '9' || c == 'A' || c == 'B' || c >= 'D' && c <= 'Z' || c == '_' || c == 'a' || c == 'b' || c >= 'd' && c <= 'z': + goto yystate49 + } + +yystate242: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'K' || c == 'k': + goto yystate243 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'J' || c >= 'L' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'j' || c >= 'l' && c <= 'z': + goto yystate49 + } + +yystate243: + c = l.next() + switch { + default: + goto yyrule62 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate244: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'N' || c == 'n': + goto yystate245 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z': + goto yystate49 + } + +yystate245: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate246 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': + goto yystate49 + } + +yystate246: + c = l.next() + switch { + default: + goto yyrule91 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate247: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate248 + case c == 'T' || c == 't': + goto yystate254 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate248: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'L' || c == 'l': + goto yystate249 + case c == 'T' || c == 't': + goto yystate253 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate249: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate250 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': + goto yystate49 + } + +yystate250: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'C' || c == 'c': + goto yystate251 + case c >= '0' && c <= '9' || c == 'A' || c == 'B' || c >= 'D' && c <= 'Z' || c == '_' || c == 'a' || c == 'b' || c >= 'd' && c <= 'z': + goto yystate49 + } + +yystate251: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'T' || c == 't': + goto yystate252 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate252: + c = l.next() + switch { + default: + goto yyrule63 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate253: + c = l.next() + switch { + default: + goto yyrule64 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate254: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'R' || c == 'r': + goto yystate255 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'q' || c >= 's' && c <= 'z': + goto yystate49 + } + +yystate255: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'I' || c == 'i': + goto yystate256 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z': + goto yystate49 + } + +yystate256: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'N' || c == 'n': + goto yystate257 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z': + goto yystate49 + } + +yystate257: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'G' || c == 'g': + goto yystate258 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'H' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'f' || c >= 'h' && c <= 'z': + goto yystate49 + } + +yystate258: + c = l.next() + switch { + default: + goto yyrule92 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate259: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'A' || c == 'a': + goto yystate260 + case c == 'I' || c == 'i': + goto yystate264 + case c == 'R' || c == 'r': + goto yystate267 + case c >= '0' && c <= '9' || c >= 'B' && c <= 'H' || c >= 'J' && c <= 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'h' || c >= 'j' && c <= 'q' || c >= 's' && c <= 'z': + goto yystate49 + } + +yystate260: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'B' || c == 'b': + goto yystate261 + case c >= '0' && c <= '9' || c == 'A' || c >= 'C' && c <= 'Z' || c == '_' || c == 'a' || c >= 'c' && c <= 'z': + goto yystate49 + } + +yystate261: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'L' || c == 'l': + goto yystate262 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z': + goto yystate49 + } + +yystate262: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate263 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': + goto yystate49 + } + +yystate263: + c = l.next() + switch { + default: + goto yyrule65 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate264: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'M' || c == 'm': + goto yystate265 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'L' || c >= 'N' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'l' || c >= 'n' && c <= 'z': + goto yystate49 + } + +yystate265: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate266 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': + goto yystate49 + } + +yystate266: + c = l.next() + switch { + default: + goto yyrule93 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate267: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'A' || c == 'a': + goto yystate268 + case c == 'U' || c == 'u': + goto yystate277 + case c >= '0' && c <= '9' || c >= 'B' && c <= 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'b' && c <= 't' || c >= 'v' && c <= 'z': + goto yystate49 + } + +yystate268: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'N' || c == 'n': + goto yystate269 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z': + goto yystate49 + } + +yystate269: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'S' || c == 's': + goto yystate270 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'R' || c >= 'T' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'r' || c >= 't' && c <= 'z': + goto yystate49 + } + +yystate270: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'A' || c == 'a': + goto yystate271 + case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z': + goto yystate49 + } + +yystate271: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'C' || c == 'c': + goto yystate272 + case c >= '0' && c <= '9' || c == 'A' || c == 'B' || c >= 'D' && c <= 'Z' || c == '_' || c == 'a' || c == 'b' || c >= 'd' && c <= 'z': + goto yystate49 + } + +yystate272: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'T' || c == 't': + goto yystate273 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate273: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'I' || c == 'i': + goto yystate274 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z': + goto yystate49 + } + +yystate274: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'O' || c == 'o': + goto yystate275 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z': + goto yystate49 + } + +yystate275: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'N' || c == 'n': + goto yystate276 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z': + goto yystate49 + } + +yystate276: + c = l.next() + switch { + default: + goto yyrule66 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate277: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate278 + case c == 'N' || c == 'n': + goto yystate279 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'm' || c >= 'o' && c <= 'z': + goto yystate49 + } + +yystate278: + c = l.next() + switch { + default: + goto yyrule74 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate279: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'C' || c == 'c': + goto yystate280 + case c >= '0' && c <= '9' || c == 'A' || c == 'B' || c >= 'D' && c <= 'Z' || c == '_' || c == 'a' || c == 'b' || c >= 'd' && c <= 'z': + goto yystate49 + } + +yystate280: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'A' || c == 'a': + goto yystate281 + case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z': + goto yystate49 + } + +yystate281: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'T' || c == 't': + goto yystate282 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate282: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate283 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': + goto yystate49 + } + +yystate283: + c = l.next() + switch { + default: + goto yyrule67 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate284: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'I' || c == 'i': + goto yystate285 + case c == 'N' || c == 'n': + goto yystate295 + case c == 'P' || c == 'p': + goto yystate300 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'M' || c == 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'm' || c == 'o' || c >= 'q' && c <= 'z': + goto yystate49 + } + +yystate285: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'N' || c == 'n': + goto yystate286 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z': + goto yystate49 + } + +yystate286: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'T' || c == 't': + goto yystate287 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate287: + c = l.next() + switch { + default: + goto yyrule94 + case c == '0' || c == '2' || c == '4' || c == '5' || c == '7' || c == '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + case c == '1': + goto yystate288 + case c == '3': + goto yystate290 + case c == '6': + goto yystate292 + case c == '8': + goto yystate294 + } + +yystate288: + c = l.next() + switch { + default: + goto yyrule99 + case c == '6': + goto yystate289 + case c >= '0' && c <= '5' || c >= '7' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate289: + c = l.next() + switch { + default: + goto yyrule95 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate290: + c = l.next() + switch { + default: + goto yyrule99 + case c == '0' || c == '1' || c >= '3' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + case c == '2': + goto yystate291 + } + +yystate291: + c = l.next() + switch { + default: + goto yyrule96 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate292: + c = l.next() + switch { + default: + goto yyrule99 + case c == '4': + goto yystate293 + case c >= '0' && c <= '3' || c >= '5' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate293: + c = l.next() + switch { + default: + goto yyrule97 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate294: + c = l.next() + switch { + default: + goto yyrule98 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate295: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'I' || c == 'i': + goto yystate296 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z': + goto yystate49 + } + +yystate296: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'Q' || c == 'q': + goto yystate297 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'P' || c >= 'R' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'p' || c >= 'r' && c <= 'z': + goto yystate49 + } + +yystate297: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'U' || c == 'u': + goto yystate298 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'a' && c <= 't' || c >= 'v' && c <= 'z': + goto yystate49 + } + +yystate298: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate299 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': + goto yystate49 + } + +yystate299: + c = l.next() + switch { + default: + goto yyrule69 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate300: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'D' || c == 'd': + goto yystate301 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'C' || c >= 'E' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'c' || c >= 'e' && c <= 'z': + goto yystate49 + } + +yystate301: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'A' || c == 'a': + goto yystate302 + case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z': + goto yystate49 + } + +yystate302: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'T' || c == 't': + goto yystate303 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': + goto yystate49 + } + +yystate303: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate304 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': + goto yystate49 + } + +yystate304: + c = l.next() + switch { + default: + goto yyrule68 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate305: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'A' || c == 'a': + goto yystate306 + case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z': + goto yystate49 + } + +yystate306: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'L' || c == 'l': + goto yystate307 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z': + goto yystate49 + } + +yystate307: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'U' || c == 'u': + goto yystate308 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'a' && c <= 't' || c >= 'v' && c <= 'z': + goto yystate49 + } + +yystate308: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate309 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': + goto yystate49 + } + +yystate309: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'S' || c == 's': + goto yystate310 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'R' || c >= 'T' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'r' || c >= 't' && c <= 'z': + goto yystate49 + } + +yystate310: + c = l.next() + switch { + default: + goto yyrule70 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate311: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'H' || c == 'h': + goto yystate312 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'G' || c >= 'I' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'g' || c >= 'i' && c <= 'z': + goto yystate49 + } + +yystate312: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate313 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': + goto yystate49 + } + +yystate313: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'R' || c == 'r': + goto yystate314 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'q' || c >= 's' && c <= 'z': + goto yystate49 + } + +yystate314: + c = l.next() + switch { + default: + goto yyrule99 + case c == 'E' || c == 'e': + goto yystate315 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': + goto yystate49 + } + +yystate315: + c = l.next() + switch { + default: + goto yyrule71 + case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': + goto yystate49 + } + +yystate316: + c = l.next() + goto yyrule11 + +yystate317: + c = l.next() + switch { + default: + goto yyrule101 + case c == '|': + goto yystate318 + } + +yystate318: + c = l.next() + goto yyrule22 + + goto yystate319 // silence unused label error +yystate319: + c = l.next() +yystart319: + switch { + default: + goto yystate320 // c >= '\x01' && c <= '!' || c >= '#' && c <= '[' || c >= ']' && c <= 'ÿ' + case c == '"': + goto yystate321 + case c == '\\': + goto yystate322 + case c == '\x00': + goto yystate2 + } + +yystate320: + c = l.next() + switch { + default: + goto yyabort + case c == '"': + goto yystate321 + case c == '\\': + goto yystate322 + case c >= '\x01' && c <= '!' || c >= '#' && c <= '[' || c >= ']' && c <= 'ÿ': + goto yystate320 + } + +yystate321: + c = l.next() + goto yyrule13 + +yystate322: + c = l.next() + switch { + default: + goto yyabort + case c == '"': + goto yystate323 + case c == '\\': + goto yystate322 + case c >= '\x01' && c <= '!' || c >= '#' && c <= '[' || c >= ']' && c <= 'ÿ': + goto yystate320 + } + +yystate323: + c = l.next() + switch { + default: + goto yyrule13 + case c == '"': + goto yystate321 + case c == '\\': + goto yystate322 + case c >= '\x01' && c <= '!' || c >= '#' && c <= '[' || c >= ']' && c <= 'ÿ': + goto yystate320 + } + + goto yystate324 // silence unused label error +yystate324: + c = l.next() +yystart324: + switch { + default: + goto yystate325 // c >= '\x01' && c <= '_' || c >= 'a' && c <= 'ÿ' + case c == '\x00': + goto yystate2 + case c == '`': + goto yystate326 + } + +yystate325: + c = l.next() + switch { + default: + goto yyabort + case c == '`': + goto yystate326 + case c >= '\x01' && c <= '_' || c >= 'a' && c <= 'ÿ': + goto yystate325 + } + +yystate326: + c = l.next() + goto yyrule14 + +yyrule1: // \0 + { + return 0 + } +yyrule2: // [ \t\n\r]+ + + goto yystate0 +yyrule3: // --.* + + goto yystate0 +yyrule4: // \/\/.* + + goto yystate0 +yyrule5: // \/\*([^*]|\*+[^*/])*\*+\/ + + goto yystate0 +yyrule6: // {imaginary_ilit} + { + return l.int(lval, true) + } +yyrule7: // {imaginary_lit} + { + return l.float(lval, true) + } +yyrule8: // {int_lit} + { + return l.int(lval, false) + } +yyrule9: // {float_lit} + { + return l.float(lval, false) + } +yyrule10: // \" + { + l.sc = S1 + goto yystate0 + } +yyrule11: // ` + { + l.sc = S2 + goto yystate0 + } +yyrule12: // '(\\.|[^'])*' + { + if ret := l.str(lval, ""); ret != stringLit { + return ret + } + lval.item = idealRune(lval.item.(string)[0]) + return intLit + } +yyrule13: // (\\.|[^\"])*\" + { + return l.str(lval, "\"") + } +yyrule14: // ([^`]|\n)*` + { + return l.str(lval, "`") + } +yyrule15: // "&&" + { + return andand + } +yyrule16: // "&^" + { + return andnot + } +yyrule17: // "<<" + { + return lsh + } +yyrule18: // "<=" + { + return le + } +yyrule19: // "==" + { + return eq + } +yyrule20: // ">=" + { + return ge + } +yyrule21: // "!=" + { + return neq + } +yyrule22: // "||" + { + return oror + } +yyrule23: // ">>" + { + return rsh + } +yyrule24: // {add} + { + return add + } +yyrule25: // {alter} + { + return alter + } +yyrule26: // {and} + { + return and + } +yyrule27: // {asc} + { + return asc + } +yyrule28: // {as} + { + return as + } +yyrule29: // {begin} + { + return begin + } +yyrule30: // {between} + { + return between + } +yyrule31: // {by} + { + return by + } +yyrule32: // {column} + { + return column + } +yyrule33: // {commit} + { + return commit + } +yyrule34: // {create} + { + return create + } +yyrule35: // {default} + { + return defaultKwd + } +yyrule36: // {delete} + { + return deleteKwd + } +yyrule37: // {desc} + { + return desc + } +yyrule38: // {distinct} + { + return distinct + } +yyrule39: // {drop} + { + return drop + } +yyrule40: // {exists} + { + return exists + } +yyrule41: // {explain} + { + return explain + } +yyrule42: // {from} + { + return from + } +yyrule43: // {full} + { + return full + } +yyrule44: // {group} + { + return group + } +yyrule45: // {if} + { + return ifKwd + } +yyrule46: // {index} + { + return index + } +yyrule47: // {insert} + { + return insert + } +yyrule48: // {into} + { + return into + } +yyrule49: // {in} + { + return in + } +yyrule50: // {is} + { + return is + } +yyrule51: // {join} + { + return join + } +yyrule52: // {left} + { + return left + } +yyrule53: // {like} + { + return like + } +yyrule54: // {limit} + { + return limit + } +yyrule55: // {not} + { + return not + } +yyrule56: // {offset} + { + return offset + } +yyrule57: // {on} + { + return on + } +yyrule58: // {order} + { + return order + } +yyrule59: // {or} + { + return or + } +yyrule60: // {outer} + { + return outer + } +yyrule61: // {right} + { + return right + } +yyrule62: // {rollback} + { + return rollback + } +yyrule63: // {select} + { + l.agg = append(l.agg, false) + return selectKwd + } +yyrule64: // {set} + { + return set + } +yyrule65: // {table} + { + return tableKwd + } +yyrule66: // {transaction} + { + return transaction + } +yyrule67: // {truncate} + { + return truncate + } +yyrule68: // {update} + { + return update + } +yyrule69: // {unique} + { + return unique + } +yyrule70: // {values} + { + return values + } +yyrule71: // {where} + { + return where + } +yyrule72: // {null} + { + lval.item = nil + return null + } +yyrule73: // {false} + { + lval.item = false + return falseKwd + } +yyrule74: // {true} + { + lval.item = true + return trueKwd + } +yyrule75: // {bigint} + { + lval.item = qBigInt + return bigIntType + } +yyrule76: // {bigrat} + { + lval.item = qBigRat + return bigRatType + } +yyrule77: // {blob} + { + lval.item = qBlob + return blobType + } +yyrule78: // {bool} + { + lval.item = qBool + return boolType + } +yyrule79: // {byte} + { + lval.item = qUint8 + return byteType + } +yyrule80: // {complex}128 + { + lval.item = qComplex128 + return complex128Type + } +yyrule81: // {complex}64 + { + lval.item = qComplex64 + return complex64Type + } +yyrule82: // {duration} + { + lval.item = qDuration + return durationType + } +yyrule83: // {float} + { + lval.item = qFloat64 + return floatType + } +yyrule84: // {float}32 + { + lval.item = qFloat32 + return float32Type + } +yyrule85: // {float}64 + { + lval.item = qFloat64 + return float64Type + } +yyrule86: // {int} + { + lval.item = qInt64 + return intType + } +yyrule87: // {int}16 + { + lval.item = qInt16 + return int16Type + } +yyrule88: // {int}32 + { + lval.item = qInt32 + return int32Type + } +yyrule89: // {int}64 + { + lval.item = qInt64 + return int64Type + } +yyrule90: // {int}8 + { + lval.item = qInt8 + return int8Type + } +yyrule91: // {rune} + { + lval.item = qInt32 + return runeType + } +yyrule92: // {string} + { + lval.item = qString + return stringType + } +yyrule93: // {time} + { + lval.item = qTime + return timeType + } +yyrule94: // {uint} + { + lval.item = qUint64 + return uintType + } +yyrule95: // {uint}16 + { + lval.item = qUint16 + return uint16Type + } +yyrule96: // {uint}32 + { + lval.item = qUint32 + return uint32Type + } +yyrule97: // {uint}64 + { + lval.item = qUint64 + return uint64Type + } +yyrule98: // {uint}8 + { + lval.item = qUint8 + return uint8Type + } +yyrule99: // {ident} + { + lval.item = string(l.val) + return identifier + } +yyrule100: // ($|\?){D} + { + lval.item, _ = strconv.Atoi(string(l.val[1:])) + return qlParam + } +yyrule101: // . + { + return c0 + } + panic("unreachable") + + goto yyabort // silence unused label error + +yyabort: // no lexem recognized + return int(unicode.ReplacementChar) +} + +func (l *lexer) npos() (line, col int) { + if line, col = l.nline, l.ncol; col == 0 { + line-- + col = l.lcol + 1 + } + return +} + +func (l *lexer) str(lval *yySymType, pref string) int { + l.sc = 0 + s := pref + string(l.val) + s, err := strconv.Unquote(s) + if err != nil { + l.err("string literal: %v", err) + return int(unicode.ReplacementChar) + } + + lval.item = s + return stringLit +} + +func (l *lexer) int(lval *yySymType, im bool) int { + if im { + l.val = l.val[:len(l.val)-1] + } + n, err := strconv.ParseUint(string(l.val), 0, 64) + if err != nil { + l.err("integer literal: %v", err) + return int(unicode.ReplacementChar) + } + + if im { + lval.item = idealComplex(complex(0, float64(n))) + return imaginaryLit + } + + switch { + case n < math.MaxInt64: + lval.item = idealInt(n) + default: + lval.item = idealUint(n) + } + return intLit +} + +func (l *lexer) float(lval *yySymType, im bool) int { + if im { + l.val = l.val[:len(l.val)-1] + } + n, err := strconv.ParseFloat(string(l.val), 64) + if err != nil { + l.err("float literal: %v", err) + return int(unicode.ReplacementChar) + } + + if im { + lval.item = idealComplex(complex(0, n)) + return imaginaryLit + } + + lval.item = idealFloat(n) + return floatLit +} diff --git a/vendor/github.com/cznic/ql/stmt.go b/vendor/github.com/cznic/ql/stmt.go new file mode 100644 index 0000000000..8de367d4c9 --- /dev/null +++ b/vendor/github.com/cznic/ql/stmt.go @@ -0,0 +1,1268 @@ +// Copyright (c) 2014 ql 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 ql + +import ( + "bytes" + "fmt" + "strings" + "sync" + + "github.com/cznic/strutil" +) + +// NOTE: all stmt implementations must be safe for concurrent use by multiple +// goroutines. If the exec method requires any execution domain local data, +// they must be held out of the implementing instance. +var ( + _ stmt = (*alterTableAddStmt)(nil) + _ stmt = (*alterTableDropColumnStmt)(nil) + _ stmt = (*createIndexStmt)(nil) + _ stmt = (*createTableStmt)(nil) + _ stmt = (*deleteStmt)(nil) //TODO optimizer plan + _ stmt = (*dropIndexStmt)(nil) + _ stmt = (*dropTableStmt)(nil) + _ stmt = (*explainStmt)(nil) + _ stmt = (*insertIntoStmt)(nil) + _ stmt = (*selectStmt)(nil) + _ stmt = (*truncateTableStmt)(nil) + _ stmt = (*updateStmt)(nil) //TODO optimizer plan + _ stmt = beginTransactionStmt{} + _ stmt = commitStmt{} + _ stmt = rollbackStmt{} +) + +var ( + createColumn2 = mustCompile(` + create table if not exists __Column2 ( + TableName string, + Name string, + NotNull bool, + ConstraintExpr string, + DefaultExpr string, + ); + create index if not exists __Column2TableName on __Column2(TableName); + `) + + insertColumn2 = mustCompile(`insert into __Column2 values($1, $2, $3, $4, $5)`) + + selectColumn2 = MustCompile(` + select Name, NotNull, ConstraintExpr, DefaultExpr + from __Column2 + where TableName == $1 + `) + + deleteColumn2 = mustCompile(` + delete from __Column2 + where TableName == $1 && Name == $2 + `) + + createIndex2 = mustCompile(` + // Index register 2. + create table if not exists __Index2( + TableName string, + IndexName string, + IsUnique bool, + IsSimple bool, // Just a column name or id(). + Root int64, // BTree handle + ); + + // Expressions for given index. Compared in order of id(__Index2_Expr). + create table if not exists __Index2_Expr( + Index2_ID int, + Expr string, + ); + + create index if not exists __xIndex2_TableName on __Index2(TableName); + create unique index if not exists __xIndex2_IndexName on __Index2(IndexName); + create index if not exists __xIndex2_ID on __Index2(id()); + create index if not exists __xIndex2_Expr_Index2_ID on __Index2_Expr(Index2_ID); +`) + + insertIndex2 = mustCompile("insert into __Index2 values($1, $2, $3, $4, $5)") + insertIndex2Expr = mustCompile("insert into __Index2_Expr values($1, $2)") + + deleteIndex2ByIndexName = mustCompile(` + delete from __Index2_Expr + where Index2_ID in ( + select id() from __Index2 where IndexName == $1; + ); + + delete from __Index2 + where IndexName == $1; +`) + deleteIndex2ByTableName = mustCompile(` + delete from __Index2_Expr + where Index2_ID in ( + select id() from __Index2 where TableName == $1; + ); + + delete from __Index2 + where TableName == $1; +`) +) + +type stmt interface { + // never invoked for + // - beginTransactionStmt + // - commitStmt + // - rollbackStmt + exec(ctx *execCtx) (Recordset, error) + + explain(ctx *execCtx, w strutil.Formatter) + + // return value ignored for + // - beginTransactionStmt + // - commitStmt + // - rollbackStmt + isUpdating() bool + String() string +} + +type execCtx struct { //LATER +shared temp + db *DB + arg []interface{} +} + +type explainStmt struct { + s stmt +} + +func (s *explainStmt) explain(ctx *execCtx, w strutil.Formatter) { + for { + x, ok := s.s.(*explainStmt) + if !ok { + s.s.explain(ctx, w) + return + } + + s = x + } +} + +func (s *explainStmt) String() string { + return "EXPLAIN " + s.s.String() +} + +func (*explainStmt) isUpdating() bool { return false } + +func (s *explainStmt) exec(ctx *execCtx) (_ Recordset, err error) { + return recordset{ctx, &explainDefaultPlan{s.s}, ctx.db.cc}, nil +} + +type updateStmt struct { + tableName string + list []assignment + where expression +} + +func (s *updateStmt) explain(ctx *execCtx, w strutil.Formatter) { + w.Format("%s\n", s) +} + +func (s *updateStmt) String() string { + u := fmt.Sprintf("UPDATE %s", s.tableName) + a := make([]string, len(s.list)) + for i, v := range s.list { + a[i] = v.String() + } + w := "" + if s.where != nil { + w = fmt.Sprintf(" WHERE %s", s.where) + } + return fmt.Sprintf("%s %s%s;", u, strings.Join(a, ", "), w) +} + +func (s *updateStmt) exec(ctx *execCtx) (_ Recordset, err error) { + t, ok := ctx.db.root.tables[s.tableName] + if !ok { + return nil, fmt.Errorf("UPDATE: table %s does not exist", s.tableName) + } + + tcols := make([]*col, len(s.list)) + for i, asgn := range s.list { + col := findCol(t.cols, asgn.colName) + if col == nil { + return nil, fmt.Errorf("UPDATE: unknown column %s", asgn.colName) + } + tcols[i] = col + } + + m := map[interface{}]interface{}{} + var nh int64 + expr := s.where + blobCols := t.blobCols() + cc := ctx.db.cc + var old []interface{} + var touched []bool + if t.hasIndices() { + old = make([]interface{}, len(t.cols0)) + touched = make([]bool, len(t.cols0)) + } + for h := t.head; h != 0; h = nh { + // Read can return lazily expanded chunks + data, err := t.store.Read(nil, h, t.cols...) + if err != nil { + return nil, err + } + + nh = data[0].(int64) + for _, col := range t.cols { + m[col.name] = data[2+col.index] + } + id := data[1].(int64) + m["$id"] = id + if expr != nil { + val, err := s.where.eval(ctx, m) + if err != nil { + return nil, err + } + + if val == nil { + continue + } + + x, ok := val.(bool) + if !ok { + return nil, fmt.Errorf("invalid WHERE expression %s (value of type %T)", val, val) + } + + if !x { + continue + } + } + + // hit + for _, ix := range t.indices2 { + vlist, err := ix.eval(ctx, t.cols, id, data[2:]) + if err != nil { + return nil, err + } + + if err := ix.x.Delete(vlist, h); err != nil { + return nil, err + } + } + for i, asgn := range s.list { + val, err := asgn.expr.eval(ctx, m) + if err != nil { + return nil, err + } + + colIndex := tcols[i].index + if t.hasIndices() { + old[colIndex] = data[2+colIndex] + touched[colIndex] = true + } + data[2+colIndex] = val + } + if err = typeCheck(data[2:], t.cols); err != nil { + return nil, err + } + + if err = t.checkConstraintsAndDefaults(ctx, data[2:], m); err != nil { + return nil, err + } + + for i, v := range t.indices { + if i == 0 { // id() N/A + continue + } + + if v == nil || !touched[i-1] { + continue + } + + if err = v.x.Delete([]interface{}{old[i-1]}, h); err != nil { + return nil, err + } + } + + if err = t.store.UpdateRow(h, blobCols, data...); err != nil { //LATER detect which blobs are actually affected + return nil, err + } + + for i, v := range t.indices { + if i == 0 { // id() N/A + continue + } + + if v == nil || !touched[i-1] { + continue + } + + if err = v.x.Create([]interface{}{data[2+i-1]}, h); err != nil { + return nil, err + } + } + for _, ix := range t.indices2 { + vlist, err := ix.eval(ctx, t.cols, id, data[2:]) + if err != nil { + return nil, err + } + + if err := ix.x.Create(vlist, h); err != nil { + return nil, err + } + } + + cc.RowsAffected++ + } + return +} + +func (s *updateStmt) isUpdating() bool { return true } + +type deleteStmt struct { + tableName string + where expression +} + +func (s *deleteStmt) explain(ctx *execCtx, w strutil.Formatter) { + w.Format("%s\n", s) +} + +func (s *deleteStmt) String() string { + switch { + case s.where == nil: + return fmt.Sprintf("DELETE FROM %s;", s.tableName) + default: + return fmt.Sprintf("DELETE FROM %s WHERE %s;", s.tableName, s.where) + } +} + +func (s *deleteStmt) exec(ctx *execCtx) (_ Recordset, err error) { + t, ok := ctx.db.root.tables[s.tableName] + if !ok { + return nil, fmt.Errorf("DELETE FROM: table %s does not exist", s.tableName) + } + + m := map[interface{}]interface{}{} + var ph, h, nh int64 + var data []interface{} + blobCols := t.blobCols() + cc := ctx.db.cc + for h = t.head; h != 0; ph, h = h, nh { + for i, v := range data { + c, ok := v.(chunk) + if !ok { + continue + } + + data[i] = c.b + } + // Read can return lazily expanded chunks + data, err = t.store.Read(nil, h, t.cols...) + if err != nil { + return nil, err + } + + nh = data[0].(int64) + for _, col := range t.cols { + m[col.name] = data[2+col.index] + } + id := data[1].(int64) + m["$id"] = id + val, err := s.where.eval(ctx, m) + if err != nil { + return nil, err + } + + if val == nil { + continue + } + + x, ok := val.(bool) + if !ok { + return nil, fmt.Errorf("invalid WHERE expression %s (value of type %T)", val, val) + } + + if !x { + continue + } + + // hit + for i, v := range t.indices { + if v == nil { + continue + } + + // overflow chunks left in place + if err = v.x.Delete([]interface{}{data[i+1]}, h); err != nil { + return nil, err + } + } + for _, ix := range t.indices2 { + vlist, err := ix.eval(ctx, t.cols, id, data[2:]) + if err != nil { + return nil, err + } + + if err := ix.x.Delete(vlist, h); err != nil { + return nil, err + } + } + + // overflow chunks freed here + if err = t.store.Delete(h, blobCols...); err != nil { + return nil, err + } + + cc.RowsAffected++ + switch { + case ph == 0 && nh == 0: // "only" + fallthrough + case ph == 0 && nh != 0: // "first" + if err = t.store.Update(t.hhead, nh); err != nil { + return nil, err + } + + t.head, h = nh, 0 + case ph != 0 && nh == 0: // "last" + fallthrough + case ph != 0 && nh != 0: // "inner" + pdata, err := t.store.Read(nil, ph, t.cols...) + if err != nil { + return nil, err + } + + for i, v := range pdata { + if x, ok := v.(chunk); ok { + pdata[i] = x.b + } + } + pdata[0] = nh + if err = t.store.Update(ph, pdata...); err != nil { + return nil, err + } + + h = ph + } + } + + return +} + +func (s *deleteStmt) isUpdating() bool { return true } + +type truncateTableStmt struct { + tableName string +} + +func (s *truncateTableStmt) explain(ctx *execCtx, w strutil.Formatter) { + w.Format("%s\n", s) +} + +func (s *truncateTableStmt) String() string { return fmt.Sprintf("TRUNCATE TABLE %s;", s.tableName) } + +func (s *truncateTableStmt) exec(ctx *execCtx) (Recordset, error) { + t, ok := ctx.db.root.tables[s.tableName] + if !ok { + return nil, fmt.Errorf("TRUNCATE TABLE: table %s does not exist", s.tableName) + } + + return nil, t.truncate() +} + +func (s *truncateTableStmt) isUpdating() bool { return true } + +type dropIndexStmt struct { + ifExists bool + indexName string +} + +func (s *dropIndexStmt) explain(ctx *execCtx, w strutil.Formatter) { + w.Format("%s\n", s) +} + +func (s *dropIndexStmt) String() string { return fmt.Sprintf("DROP INDEX %s;", s.indexName) } + +func (s *dropIndexStmt) exec(ctx *execCtx) (Recordset, error) { + t, x := ctx.db.root.findIndexByName(s.indexName) + if x == nil { + if s.ifExists { + return nil, nil + } + + return nil, fmt.Errorf("DROP INDEX: index %s does not exist", s.indexName) + } + + if ctx.db.hasAllIndex2() { + if err := ctx.db.deleteIndex2ByIndexName(s.indexName); err != nil { + return nil, err + } + } + + switch ix := x.(type) { + case *indexedCol: + for i, v := range t.indices { + if v == nil || v.name != s.indexName { + continue + } + + return nil, t.dropIndex(i) + } + case *index2: + delete(t.indices2, s.indexName) + return nil, ix.x.Drop() + } + + panic("internal error 058") +} + +func (s *dropIndexStmt) isUpdating() bool { return true } + +type dropTableStmt struct { + ifExists bool + tableName string +} + +func (s *dropTableStmt) explain(ctx *execCtx, w strutil.Formatter) { + w.Format("%s\n", s) +} + +func (s *dropTableStmt) String() string { return fmt.Sprintf("DROP TABLE %s;", s.tableName) } + +func (s *dropTableStmt) exec(ctx *execCtx) (Recordset, error) { + t, ok := ctx.db.root.tables[s.tableName] + if !ok { + if s.ifExists { + return nil, nil + } + + return nil, fmt.Errorf("DROP TABLE: table %s does not exist", s.tableName) + } + + if ctx.db.hasAllIndex2() { + if err := ctx.db.deleteIndex2ByTableName(s.tableName); err != nil { + return nil, err + } + } + + return nil, ctx.db.root.dropTable(t) +} + +func (s *dropTableStmt) isUpdating() bool { return true } + +type alterTableDropColumnStmt struct { + tableName, colName string +} + +func (s *alterTableDropColumnStmt) explain(ctx *execCtx, w strutil.Formatter) { + w.Format("%s\n", s) +} + +func (s *alterTableDropColumnStmt) String() string { + return fmt.Sprintf("ALTER TABLE %s DROP COLUMN %s;", s.tableName, s.colName) +} + +func (s *alterTableDropColumnStmt) exec(ctx *execCtx) (Recordset, error) { + t, ok := ctx.db.root.tables[s.tableName] + if !ok { + return nil, fmt.Errorf("ALTER TABLE: table %s does not exist", s.tableName) + } + + cols := t.cols + for _, c := range cols { + if c.name == s.colName { + if len(cols) == 1 { + return nil, fmt.Errorf("ALTER TABLE %s DROP COLUMN: cannot drop the only column: %s", s.tableName, s.colName) + } + + if _, ok := ctx.db.root.tables["__Column2"]; ok { + if _, err := deleteColumn2.l[0].exec(&execCtx{db: ctx.db, arg: []interface{}{s.tableName, c.name}}); err != nil { + return nil, err + } + } + + c.name = "" + t.cols0[c.index].name = "" + if t.hasIndices() { + if len(t.indices) != 0 { + if v := t.indices[c.index+1]; v != nil { + if err := t.dropIndex(c.index + 1); err != nil { + return nil, err + } + + if ctx.db.hasAllIndex2() { + if err := ctx.db.deleteIndex2ByIndexName(v.name); err != nil { + return nil, err + } + } + } + } + + for nm, ix := range t.indices2 { + for _, e := range ix.exprList { + m := mentionedColumns(e) + if _, ok := m[s.colName]; ok { + if err := ctx.db.deleteIndex2ByIndexName(nm); err != nil { + return nil, err + } + + if err := ix.x.Drop(); err != nil { + return nil, err + } + + delete(t.indices2, nm) + break + } + } + } + } + if err := t.constraintsAndDefaults(ctx); err != nil { + return nil, err + } + + return nil, t.updated() + } + } + + return nil, fmt.Errorf("ALTER TABLE %s DROP COLUMN: column %s does not exist", s.tableName, s.colName) +} + +func (s *alterTableDropColumnStmt) isUpdating() bool { return true } + +type alterTableAddStmt struct { + tableName string + c *col +} + +func (s *alterTableAddStmt) explain(ctx *execCtx, w strutil.Formatter) { + w.Format("%s\n", s) +} + +func (s *alterTableAddStmt) String() string { + r := fmt.Sprintf("ALTER TABLE %s ADD %s %s", s.tableName, s.c.name, typeStr(s.c.typ)) + c := s.c + if x := c.constraint; x != nil { //TODO add (*col).String() + switch e := x.expr; { + case e != nil: + r += " " + e.String() + default: + r += " NOT NULL" + } + } + if x := c.dflt; x != nil { + r += " DEFAULT " + x.String() + } + return r + ";" +} + +func (s *alterTableAddStmt) exec(ctx *execCtx) (Recordset, error) { + t, ok := ctx.db.root.tables[s.tableName] + if !ok { + return nil, fmt.Errorf("ALTER TABLE: table %s does not exist", s.tableName) + } + + hasRecords := t.head != 0 + c := s.c + if c.constraint != nil && hasRecords { + return nil, fmt.Errorf("ALTER TABLE %s ADD %s: cannot add constrained column to table with existing data", s.tableName, c.name) + } + + cols := t.cols + for _, c := range cols { + nm := c.name + if nm == s.c.name { + return nil, fmt.Errorf("ALTER TABLE %s ADD: column %s exists", s.tableName, nm) + } + } + + if len(t.indices) != 0 { + t.indices = append(t.indices, nil) + t.xroots = append(t.xroots, 0) + if err := t.store.Update(t.hxroots, t.xroots...); err != nil { + return nil, err + } + } + + if c.constraint != nil || c.dflt != nil { + for _, s := range createColumn2.l { + _, err := s.exec(&execCtx{db: ctx.db}) + if err != nil { + return nil, err + } + } + notNull := c.constraint != nil && c.constraint.expr == nil + var co, d string + if c.constraint != nil && c.constraint.expr != nil { + co = c.constraint.expr.String() + } + if e := c.dflt; e != nil { + d = e.String() + } + if _, err := insertColumn2.l[0].exec(&execCtx{db: ctx.db, arg: []interface{}{s.tableName, c.name, notNull, co, d}}); err != nil { + return nil, err + } + } + + t.cols0 = append(t.cols0, s.c) + if err := t.constraintsAndDefaults(ctx); err != nil { + return nil, err + } + + return nil, t.updated() +} + +func (s *alterTableAddStmt) isUpdating() bool { return true } + +type selectStmt struct { + distinct bool + flds []*fld + from *joinRset + group *groupByRset + hasAggregates bool + limit *limitRset + mu sync.Mutex + offset *offsetRset + order *orderByRset + where *whereRset +} + +func (s *selectStmt) explain(ctx *execCtx, w strutil.Formatter) { + p, err := s.plan(ctx) + if err != nil { + w.Format("ERROR: %v\n", err) + return + } + + p.explain(w) +} + +func (s *selectStmt) String() string { + var b bytes.Buffer + b.WriteString("SELECT") + if s.distinct { + b.WriteString(" DISTINCT") + } + switch { + case len(s.flds) == 0: + b.WriteString(" *") + default: + a := make([]string, len(s.flds)) + for i, v := range s.flds { + s := v.expr.String() + if v.name != "" && v.name != s { + s += " AS " + v.name + } + a[i] = s + } + b.WriteString(" " + strings.Join(a, ", ")) + } + b.WriteString(" FROM ") + b.WriteString(s.from.String()) + if s.where != nil { + b.WriteString(" WHERE ") + b.WriteString(s.where.expr.String()) + } + if s.group != nil { + b.WriteString(" GROUP BY ") + b.WriteString(strings.Join(s.group.colNames, ", ")) + } + if s.order != nil { + b.WriteString(" ORDER BY ") + b.WriteString(s.order.String()) + } + if s.limit != nil { + b.WriteString(" LIMIT ") + b.WriteString(s.limit.expr.String()) + } + if s.offset != nil { + b.WriteString(" OFFSET ") + b.WriteString(s.offset.expr.String()) + } + b.WriteRune(';') + return b.String() +} + +func (s *selectStmt) plan(ctx *execCtx) (plan, error) { //LATER overlapping goroutines/pipelines + r, err := s.from.plan(ctx) + if err != nil { + return nil, err + } + + if w := s.where; w != nil { + if r, err = (&whereRset{expr: w.expr, src: r}).plan(ctx); err != nil { + return nil, err + } + } + switch { + case !s.hasAggregates && s.group == nil: // nop + case !s.hasAggregates && s.group != nil: + if r, err = (&groupByRset{colNames: s.group.colNames, src: r}).plan(ctx); err != nil { + return nil, err + } + case s.hasAggregates && s.group == nil: + if r, err = (&groupByRset{src: r}).plan(ctx); err != nil { + return nil, err + } + case s.hasAggregates && s.group != nil: + if r, err = (&groupByRset{colNames: s.group.colNames, src: r}).plan(ctx); err != nil { + return nil, err + } + } + if r, err = (&selectRset{flds: s.flds, src: r}).plan(ctx); err != nil { + return nil, err + } + + if s.distinct { + if r, err = (&distinctRset{src: r}).plan(ctx); err != nil { + return nil, err + } + } + if s := s.order; s != nil { + if r, err = (&orderByRset{asc: s.asc, by: s.by, src: r}).plan(ctx); err != nil { + return nil, err + } + } + if s := s.offset; s != nil { + if r, err = (&offsetRset{s.expr, r}).plan(ctx); err != nil { + return nil, err + } + } + if s := s.limit; s != nil { + if r, err = (&limitRset{s.expr, r}).plan(ctx); err != nil { + return nil, err + } + } + return r, nil +} + +func (s *selectStmt) exec(ctx *execCtx) (rs Recordset, err error) { + r, err := s.plan(ctx) + if err != nil { + return nil, err + } + + return recordset{ctx, r, nil}, nil +} + +func (s *selectStmt) isUpdating() bool { return false } + +type insertIntoStmt struct { + colNames []string + lists [][]expression + sel *selectStmt + tableName string +} + +func (s *insertIntoStmt) explain(ctx *execCtx, w strutil.Formatter) { + w.Format("%s\n", s) +} + +func (s *insertIntoStmt) String() string { + cn := "" + if len(s.colNames) != 0 { + cn = fmt.Sprintf(" (%s)", strings.Join(s.colNames, ", ")) + } + switch { + case s.sel != nil: + return fmt.Sprintf("INSERT INTO %s%s %s;", s.tableName, cn, s.sel) + default: + a := make([]string, len(s.lists)) + for i, v := range s.lists { + b := make([]string, len(v)) + for i, v := range v { + b[i] = v.String() + } + a[i] = fmt.Sprintf("(%s)", strings.Join(b, ", ")) + } + return fmt.Sprintf("INSERT INTO %s%s VALUES %s;", s.tableName, cn, strings.Join(a, ", ")) + } +} + +func (s *insertIntoStmt) execSelect(t *table, cols []*col, ctx *execCtx) (_ Recordset, err error) { + //TODO missing rs column number eq check + r, err := s.sel.plan(ctx) + if err != nil { + return nil, err + } + + h := t.head + data0 := make([]interface{}, len(t.cols0)+2) + cc := ctx.db.cc + m := map[interface{}]interface{}{} + if err = r.do(ctx, func(_ interface{}, data []interface{}) (more bool, err error) { + for i, d := range data { + data0[cols[i].index+2] = d + } + if err = typeCheck(data0[2:], cols); err != nil { + return + } + + if err = t.checkConstraintsAndDefaults(ctx, data0[2:], m); err != nil { + return false, err + } + + id, err := t.store.ID() + if err != nil { + return false, err + } + + data0[0] = h + data0[1] = id + + // Any overflow chunks are written here. + if h, err = t.store.Create(data0...); err != nil { + return false, err + } + + for i, v := range t.indices { + if v == nil { + continue + } + + // Any overflow chunks are shared with the BTree key + if err = v.x.Create([]interface{}{data0[i+1]}, h); err != nil { + return false, err + } + } + for _, ix := range t.indices2 { + vlist, err := ix.eval(ctx, t.cols, id, data0[2:]) + if err != nil { + return false, err + } + + if err := ix.x.Create(vlist, h); err != nil { + return false, err + } + } + + cc.RowsAffected++ + ctx.db.root.lastInsertID = id + return true, nil + }); err != nil { + return nil, err + } + + t.head = h + return nil, t.store.Update(t.hhead, h) +} + +func (s *insertIntoStmt) exec(ctx *execCtx) (_ Recordset, err error) { + root := ctx.db.root + t, ok := root.tables[s.tableName] + if !ok { + return nil, fmt.Errorf("INSERT INTO %s: table does not exist", s.tableName) + } + + var cols []*col + switch len(s.colNames) { + case 0: + cols = t.cols + default: + for _, colName := range s.colNames { + if col := findCol(t.cols, colName); col != nil { + cols = append(cols, col) + continue + } + + return nil, fmt.Errorf("INSERT INTO %s: unknown column %s", s.tableName, colName) + } + } + + if s.sel != nil { + return s.execSelect(t, cols, ctx) + } + + for _, list := range s.lists { + if g, e := len(list), len(cols); g != e { + return nil, fmt.Errorf("INSERT INTO %s: expected %d value(s), have %d", s.tableName, e, g) + } + } + + cc := ctx.db.cc + r := make([]interface{}, len(t.cols0)) + m := map[interface{}]interface{}{} + for _, list := range s.lists { + for i, expr := range list { + val, err := expr.eval(ctx, m) + if err != nil { + return nil, err + } + + r[cols[i].index] = val + } + if err = typeCheck(r, cols); err != nil { + return nil, err + } + + if err = t.checkConstraintsAndDefaults(ctx, r, m); err != nil { + return nil, err + } + + id, err := t.addRecord(ctx, r) + if err != nil { + return nil, err + } + + cc.RowsAffected++ + root.lastInsertID = id + } + return nil, nil +} + +func (s *insertIntoStmt) isUpdating() bool { return true } + +type beginTransactionStmt struct{} + +func (s beginTransactionStmt) explain(ctx *execCtx, w strutil.Formatter) { + w.Format("%s\n", s) +} + +func (beginTransactionStmt) String() string { return "BEGIN TRANSACTION;" } +func (beginTransactionStmt) exec(*execCtx) (Recordset, error) { + panic("internal error 059") +} +func (beginTransactionStmt) isUpdating() bool { + panic("internal error 060") +} + +type commitStmt struct{} + +func (s commitStmt) explain(ctx *execCtx, w strutil.Formatter) { + w.Format("%s\n", s) +} + +func (commitStmt) String() string { return "COMMIT;" } +func (commitStmt) exec(*execCtx) (Recordset, error) { + panic("internal error 061") +} +func (commitStmt) isUpdating() bool { + panic("internal error 062") +} + +type rollbackStmt struct{} + +func (s rollbackStmt) explain(ctx *execCtx, w strutil.Formatter) { + w.Format("%s\n", s) +} + +func (rollbackStmt) String() string { return "ROLLBACK;" } +func (rollbackStmt) exec(*execCtx) (Recordset, error) { + panic("internal error 063") +} +func (rollbackStmt) isUpdating() bool { + panic("internal error 064") +} + +type createIndexStmt struct { + colName string // alt. "id()" for simple index on id() + ifNotExists bool + indexName string + tableName string + unique bool + exprList []expression +} + +func (s *createIndexStmt) explain(ctx *execCtx, w strutil.Formatter) { + w.Format("%s\n", s) +} + +func (s *createIndexStmt) isSimpleIndex() bool { return s.colName != "" } + +func (s *createIndexStmt) String() string { + u := "" + if s.unique { + u = "UNIQUE " + } + e := "" + if s.ifNotExists { + e = "IF NOT EXISTS " + } + expr := s.colName + if !s.isSimpleIndex() { + var a []string + for _, v := range s.exprList { + a = append(a, v.String()) + } + expr = strings.Join(a, ", ") + } + return fmt.Sprintf("CREATE %sINDEX %s%s ON %s (%s);", u, e, s.indexName, s.tableName, expr) +} + +func (s *createIndexStmt) exec(ctx *execCtx) (Recordset, error) { + root := ctx.db.root + if t, i := root.findIndexByName(s.indexName); i != nil { + if s.ifNotExists { + return nil, nil + } + + return nil, fmt.Errorf("CREATE INDEX: table %s already has an index named %s", t.name, s.indexName) + } + + if root.tables[s.indexName] != nil { + return nil, fmt.Errorf("CREATE INDEX: index name collision with existing table: %s", s.indexName) + } + + t, ok := root.tables[s.tableName] + if !ok { + return nil, fmt.Errorf("CREATE INDEX: table does not exist %s", s.tableName) + } + + if findCol(t.cols, s.indexName) != nil { + return nil, fmt.Errorf("CREATE INDEX: index name collision with existing column: %s", s.indexName) + } + + var h int64 + var err error + switch { + case s.isSimpleIndex(): + colIndex := -1 + if s.colName != "id()" { + c := findCol(t.cols, s.colName) + if c == nil { + return nil, fmt.Errorf("CREATE INDEX: column does not exist: %s", s.colName) + } + + colIndex = c.index + } + + if h, err = t.addIndex(s.unique, s.indexName, colIndex); err != nil { + return nil, fmt.Errorf("CREATE INDEX: %v", err) + } + + if err = t.updated(); err != nil { + return nil, err + } + default: + for _, e := range s.exprList { + m := mentionedColumns(e) + for colName := range m { + c := findCol(t.cols, colName) + if c == nil { + return nil, fmt.Errorf("CREATE INDEX: column does not exist: %s", colName) + } + } + } + if h, err = t.addIndex2(ctx, s.unique, s.indexName, s.exprList); err != nil { + return nil, fmt.Errorf("CREATE INDEX: %v", err) + } + } + + switch ctx.db.hasIndex2 { + case 0: + if err := ctx.db.createIndex2(); err != nil { + return nil, err + } + + if s.isSimpleIndex() { + return nil, nil + } + case 1: + return nil, nil + case 2: + if s.isSimpleIndex() { + return nil, ctx.db.insertIndex2(s.tableName, s.indexName, []string{s.colName}, s.unique, true, h) + } + default: + panic("internal error 011") + } + + exprList := make([]string, 0, len(s.exprList)) + for _, e := range s.exprList { + exprList = append(exprList, e.String()) + } + return nil, ctx.db.insertIndex2(s.tableName, s.indexName, exprList, s.unique, false, h) +} + +func (s *createIndexStmt) isUpdating() bool { return true } + +type createTableStmt struct { + ifNotExists bool + tableName string + cols []*col +} + +func (s *createTableStmt) explain(ctx *execCtx, w strutil.Formatter) { + w.Format("%s\n", s) +} + +func (s *createTableStmt) String() string { + a := make([]string, len(s.cols)) + for i, v := range s.cols { + var c, d string + if x := v.constraint; x != nil { + switch e := x.expr; { + case e != nil: + c = " " + e.String() + default: + c = " NOT NULL" + } + } + if x := v.dflt; x != nil { + d = " DEFAULT " + x.String() + } + a[i] = fmt.Sprintf("%s %s%s%s", v.name, typeStr(v.typ), c, d) + } + e := "" + if s.ifNotExists { + e = "IF NOT EXISTS " + } + return fmt.Sprintf("CREATE TABLE %s%s (%s);", e, s.tableName, strings.Join(a, ", ")) +} + +func (s *createTableStmt) exec(ctx *execCtx) (_ Recordset, err error) { + var cols []*col + for _, v := range s.cols { + cols = append(cols, v.clone()) + } + root := ctx.db.root + if _, ok := root.tables[s.tableName]; ok { + if s.ifNotExists { + return nil, nil + } + + return nil, fmt.Errorf("CREATE TABLE: table exists %s", s.tableName) + } + + if t, x := root.findIndexByName(s.tableName); x != nil { + return nil, fmt.Errorf("CREATE TABLE: table %s has index %s", t.name, s.tableName) + } + + m := map[string]bool{} + mustCreateColumn2 := true + for i, c := range cols { + nm := c.name + if m[nm] { + return nil, fmt.Errorf("CREATE TABLE: duplicate column %s", nm) + } + + m[nm] = true + c.index = i + if c.constraint != nil || c.dflt != nil { + if mustCreateColumn2 { + for _, stmt := range createColumn2.l { + _, err := stmt.exec(&execCtx{db: ctx.db}) + if err != nil { + return nil, err + } + } + } + + mustCreateColumn2 = false + notNull := c.constraint != nil && c.constraint.expr == nil + var co, d string + if c.constraint != nil && c.constraint.expr != nil { + co = c.constraint.expr.String() + } + if e := c.dflt; e != nil { + d = e.String() + } + if _, err := insertColumn2.l[0].exec(&execCtx{db: ctx.db, arg: []interface{}{s.tableName, c.name, notNull, co, d}}); err != nil { + return nil, err + } + } + } + t, err := root.createTable(s.tableName, cols) + if err != nil { + return nil, err + } + + return nil, t.constraintsAndDefaults(ctx) +} + +func (s *createTableStmt) isUpdating() bool { return true } diff --git a/vendor/github.com/cznic/ql/storage.go b/vendor/github.com/cznic/ql/storage.go new file mode 100644 index 0000000000..fa7a4bf0c6 --- /dev/null +++ b/vendor/github.com/cznic/ql/storage.go @@ -0,0 +1,991 @@ +// Copyright (c) 2014 ql 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 ql + +import ( + "fmt" + "strings" +) + +type storage interface { + Acid() bool + BeginTransaction() error + Close() error + Commit() error + Create(data ...interface{}) (h int64, err error) + CreateIndex(unique bool) (handle int64, x btreeIndex, err error) + CreateTemp(asc bool) (bt temp, err error) + Delete(h int64, blobCols ...*col) error //LATER split the nil blobCols case + ID() (id int64, err error) + Name() string + OpenIndex(unique bool, handle int64) (btreeIndex, error) // Never called on the memory backend. + Read(dst []interface{}, h int64, cols ...*col) (data []interface{}, err error) + ResetID() (err error) + Rollback() error + Update(h int64, data ...interface{}) error + UpdateRow(h int64, blobCols []*col, data ...interface{}) error + Verify() (allocs int64, err error) +} + +type btreeIterator interface { + Next() (k, v []interface{}, err error) +} + +type temp interface { + BeginTransaction() error + Create(data ...interface{}) (h int64, err error) + Drop() (err error) + Get(k []interface{}) (v []interface{}, err error) + Read(dst []interface{}, h int64, cols ...*col) (data []interface{}, err error) + SeekFirst() (e btreeIterator, err error) + Set(k, v []interface{}) (err error) +} + +type indexIterator interface { + Next() (k []interface{}, h int64, err error) + Prev() (k []interface{}, h int64, err error) +} + +type btreeIndex interface { + Clear() error // supports truncate table statement + Create(indexedValues []interface{}, h int64) error // supports insert into statement + Delete(indexedValues []interface{}, h int64) error // supports delete from statement + Drop() error // supports drop table, drop index statements + Seek(indexedValues []interface{}) (iter indexIterator, hit bool, err error) // supports where clause + SeekFirst() (iter indexIterator, err error) // supports aggregate min / ascending order by + SeekLast() (iter indexIterator, err error) // supports aggregate max / descending order by +} + +type indexedCol struct { // Column name or id() index. + name string + unique bool + x btreeIndex + xroot int64 +} + +type index2 struct { // Expression list index. + unique bool + x btreeIndex + xroot int64 + sources []string + exprList []expression +} + +func (x *index2) eval(ctx *execCtx, cols []*col, id int64, r []interface{}) ([]interface{}, error) { + f, isFile := ctx.db.store.(*file) + vlist := make([]interface{}, len(x.exprList)) + m := map[interface{}]interface{}{"$id": id} + for _, col := range cols { + ci := col.index + v := interface{}(nil) + if ci < len(r) { + v = r[ci] + } + if b, ok := v.([]byte); ok && isFile { + var err error + if v, err = expand1(chunk{f: f, b: b}, nil); err != nil { + return nil, err + } + } + m[col.name] = v + } + for i, e := range x.exprList { + v, err := e.eval(ctx, m) + if err != nil { + return nil, err + } + + if ok, typ := isBlobType(v); ok { + return nil, fmt.Errorf("value of a complex index cannot be of blob-like type: %v", typ) + } + + vlist[i] = v + } + return vlist, nil +} + +type indexKey struct { + value []interface{} + h int64 +} + +// storage fields +// 0: next int64 +// 1: scols string +// 2: hhead int64 +// 3: name string +// 4: indices string - optional +// 5: hxroots int64 - optional +type table struct { + cols []*col // logical + cols0 []*col // physical + h int64 // + head int64 // head of the single linked record list + hhead int64 // handle of the head of the single linked record list + hxroots int64 + indices []*indexedCol + indices2 map[string]*index2 + name string + next int64 // single linked table list + store storage + tnext *table + tprev *table + xroots []interface{} + constraints []*constraint + defaults []expression +} + +func (t *table) hasIndices() bool { return len(t.indices) != 0 || len(t.indices2) != 0 } +func (t *table) hasIndices2() bool { return len(t.indices2) != 0 } + +func (t *table) constraintsAndDefaults(ctx *execCtx) error { + if isSystemName[t.name] { + return nil + } + + _, ok := ctx.db.root.tables["__Column2"] + if !ok { + return nil + } + + cols := t.cols + constraints := make([]*constraint, len(cols)) + defaults := make([]expression, len(cols)) + arg := []interface{}{t.name} + rs, err := selectColumn2.l[0].exec(&execCtx{db: ctx.db, arg: arg}) + if err != nil { + return err + } + + var rows [][]interface{} + ok = false + if err := rs.(recordset).do( + &execCtx{db: ctx.db, arg: arg}, + func(id interface{}, data []interface{}) (more bool, err error) { + rows = append(rows, data) + return true, nil + }, + ); err != nil { + return err + } + + for _, row := range rows { + nm := row[0].(string) + nonNull := row[1].(bool) + cexpr := row[2].(string) + dexpr := row[3].(string) + for i, c := range cols { + if c.name == nm { + var co *constraint + if nonNull || cexpr != "" { + co = &constraint{} + constraints[i] = co + if cexpr != "" { + if co.expr, err = ctx.db.str2expr(cexpr); err != nil { + return fmt.Errorf("constraint %q: %v", cexpr, err) + } + } + + t.constraints = constraints + } + if dexpr != "" { + if defaults[i], err = ctx.db.str2expr(dexpr); err != nil { + return fmt.Errorf("constraint %q: %v", dexpr, err) + } + + t.defaults = defaults + } + } + } + } + return nil +} + +func (t *table) checkConstraintsAndDefaults(ctx *execCtx, row []interface{}, m map[interface{}]interface{}) error { + cols := t.cols + + if len(t.defaults) != 0 { + // 1. + for _, c := range cols { + m[c.name] = row[c.index] + } + + // 2. + for i, c := range cols { + val := row[c.index] + expr := t.defaults[i] + if val != nil || expr == nil { + continue + } + + dval, err := expr.eval(ctx, m) + if err != nil { + return err + } + + row[c.index] = dval + if err = typeCheck(row, []*col{c}); err != nil { + return err + } + } + } + + if len(t.constraints) != 0 { + // 3. + for _, c := range cols { + m[c.name] = row[c.index] + } + + // 4. + for i, c := range cols { + constraint := t.constraints[i] + if constraint == nil { + continue + } + + val := row[c.index] + expr := constraint.expr + if expr == nil { // Constraint: NOT NULL + if val == nil { + return fmt.Errorf("column %s: constraint violation: NOT NULL", c.name) + } + + continue + } + + // Constraint is an expression + cval, err := expr.eval(ctx, m) + if err != nil { + return err + } + + if cval == nil { + return fmt.Errorf("column %s: constraint violation: %s", c.name, expr) + } + + bval, ok := cval.(bool) + if !ok { + return fmt.Errorf("column %s: non bool constraint expression: %s", c.name, expr) + } + + if !bval { + return fmt.Errorf("column %s: constraint violation: %s", c.name, expr) + } + } + } + + return nil +} + +func (t *table) clone() *table { + r := &table{} + *r = *t + r.constraints = append([]*constraint(nil), t.constraints...) + r.defaults = append([]expression(nil), t.defaults...) + r.indices2 = nil + if n := len(t.indices2); n != 0 { + r.indices2 = make(map[string]*index2, n) + for k, v := range t.indices2 { + r.indices2[k] = v + } + } + r.cols = make([]*col, len(t.cols)) + for i, v := range t.cols { + c := &col{} + *c = *v + r.cols[i] = c + } + r.cols0 = make([]*col, len(t.cols0)) + for i, v := range t.cols0 { + c := &col{} + *c = *v + r.cols0[i] = c + } + r.indices = make([]*indexedCol, len(t.indices)) + for i, v := range t.indices { + if v != nil { + c := &indexedCol{} + *c = *v + r.indices[i] = c + } + } + r.xroots = make([]interface{}, len(t.xroots)) + copy(r.xroots, t.xroots) + r.tnext, r.tprev = nil, nil + return r +} + +func (t *table) findIndexByColName(name string) (*col, *indexedCol) { + for i, v := range t.indices { + if v == nil { + continue + } + + if i == 0 { + if name == "id()" { + return idCol, v + } + + continue + } + + if c := t.cols[i-1]; c.name == name { + return c, v + } + } + + return nil, nil +} + +func (t *table) findIndexByName(name string) interface{} { + for _, v := range t.indices { + if v != nil && v.name == name { + return v + } + } + for k, v := range t.indices2 { + if k == name { + return v + } + } + return nil +} + +func (t *table) load() (err error) { + data, err := t.store.Read(nil, t.h) + if err != nil { + return + } + + var hasIndices bool + switch n := len(data); n { + case 4: + case 6: + hasIndices = true + default: + return fmt.Errorf("corrupted DB: table data len %d", n) + } + + var ok bool + if t.next, ok = data[0].(int64); !ok { + return fmt.Errorf("corrupted DB: table data[0] of type %T", data[0]) + } + + scols, ok := data[1].(string) + if !ok { + return fmt.Errorf("corrupted DB: table data[1] of type %T", data[1]) + } + + if t.hhead, ok = data[2].(int64); !ok { + return fmt.Errorf("corrupted DB: table data[2] of type %T", data[2]) + } + + if t.name, ok = data[3].(string); !ok { + return fmt.Errorf("corrupted DB: table data[3] of type %T", data[3]) + } + + var head []interface{} + if head, err = t.store.Read(nil, t.hhead); err != nil { + return err + } + + if len(head) != 1 { + return fmt.Errorf("corrupted DB: table head data len %d", len(head)) + } + + if t.head, ok = head[0].(int64); !ok { + return fmt.Errorf("corrupted DB: table head data[0] of type %T", head[0]) + } + + a := strings.Split(scols, "|") + t.cols0 = make([]*col, len(a)) + for i, v := range a { + if len(v) < 1 { + return fmt.Errorf("corrupted DB: field info %q", v) + } + + col := &col{name: v[1:], typ: int(v[0]), index: i} + t.cols0[i] = col + if col.name != "" { + t.cols = append(t.cols, col) + } + } + + if !hasIndices { + return + } + + if t.hxroots, ok = data[5].(int64); !ok { + return fmt.Errorf("corrupted DB: table data[5] of type %T", data[5]) + } + + xroots, err := t.store.Read(nil, t.hxroots) + if err != nil { + return err + } + + if g, e := len(xroots), len(t.cols0)+1; g != e { + return fmt.Errorf("corrupted DB: got %d index roots, expected %d", g, e) + } + + indices, ok := data[4].(string) + if !ok { + return fmt.Errorf("corrupted DB: table data[4] of type %T", data[4]) + } + + a = strings.Split(indices, "|") + if g, e := len(a), len(t.cols0)+1; g != e { + return fmt.Errorf("corrupted DB: got %d index definitions, expected %d", g, e) + } + + t.indices = make([]*indexedCol, len(a)) + for i, v := range a { + if v == "" { + continue + } + + if len(v) < 2 { + return fmt.Errorf("corrupted DB: invalid index definition %q", v) + } + + nm := v[1:] + h, ok := xroots[i].(int64) + if !ok { + return fmt.Errorf("corrupted DB: table index root of type %T", xroots[i]) + } + + if h == 0 { + return fmt.Errorf("corrupted DB: missing root for index %s", nm) + } + + unique := v[0] == 'u' + x, err := t.store.OpenIndex(unique, h) + if err != nil { + return err + } + + t.indices[i] = &indexedCol{nm, unique, x, h} + } + t.xroots = xroots + + return +} + +func newTable(store storage, name string, next int64, cols []*col, tprev, tnext *table) (t *table, err error) { + hhead, err := store.Create(int64(0)) + if err != nil { + return + } + + scols := cols2meta(cols) + h, err := store.Create(next, scols, hhead, name) + if err != nil { + return + } + + t = &table{ + cols0: cols, + h: h, + hhead: hhead, + name: name, + next: next, + store: store, + tnext: tnext, + tprev: tprev, + } + return t.updateCols(), nil +} + +func (t *table) blobCols() (r []*col) { + for _, c := range t.cols0 { + switch c.typ { + case qBlob, qBigInt, qBigRat, qTime, qDuration: + r = append(r, c) + } + } + return +} + +func (t *table) truncate() (err error) { + h := t.head + var rec []interface{} + blobCols := t.blobCols() + for h != 0 { + rec, err := t.store.Read(rec, h) + if err != nil { + return err + } + nh := rec[0].(int64) + + if err = t.store.Delete(h, blobCols...); err != nil { //LATER remove double read for len(blobCols) != 0 + return err + } + + h = nh + } + if err = t.store.Update(t.hhead, 0); err != nil { + return + } + + for _, v := range t.indices { + if v == nil { + continue + } + + if err := v.x.Clear(); err != nil { + return err + } + } + for _, ix := range t.indices2 { + if err := ix.x.Clear(); err != nil { + return err + } + } + t.head = 0 + return t.updated() +} + +func (t *table) addIndex0(unique bool, indexName string, colIndex int) (int64, btreeIndex, error) { + switch len(t.indices) { + case 0: + indices := make([]*indexedCol, len(t.cols0)+1) + h, x, err := t.store.CreateIndex(unique) + if err != nil { + return -1, nil, err + } + + indices[colIndex+1] = &indexedCol{indexName, unique, x, h} + xroots := make([]interface{}, len(indices)) + xroots[colIndex+1] = h + hx, err := t.store.Create(xroots...) + if err != nil { + return -1, nil, err + } + + t.hxroots, t.xroots, t.indices = hx, xroots, indices + return h, x, t.updated() + default: + ex := t.indices[colIndex+1] + if ex != nil && ex.name != "" { + colName := "id()" + if colIndex >= 0 { + colName = t.cols0[colIndex].name + } + return -1, nil, fmt.Errorf("column %s already has an index: %s", colName, ex.name) + } + + h, x, err := t.store.CreateIndex(unique) + if err != nil { + return -1, nil, err + } + + t.xroots[colIndex+1] = h + if err := t.store.Update(t.hxroots, t.xroots...); err != nil { + return -1, nil, err + } + + t.indices[colIndex+1] = &indexedCol{indexName, unique, x, h} + return h, x, t.updated() + } +} + +func (t *table) addIndex(unique bool, indexName string, colIndex int) (int64, error) { + hx, x, err := t.addIndex0(unique, indexName, colIndex) + if err != nil { + return -1, err + } + + // Must fill the new index. + ncols := len(t.cols0) + h, store := t.head, t.store + for h != 0 { + rec, err := store.Read(nil, h, t.cols...) + if err != nil { + return -1, err + } + + if n := ncols + 2 - len(rec); n > 0 { + rec = append(rec, make([]interface{}, n)...) + } + + if err = x.Create([]interface{}{rec[colIndex+2]}, h); err != nil { + return -1, err + } + + h = rec[0].(int64) + } + return hx, nil +} + +func (t *table) addIndex2(execCtx *execCtx, unique bool, indexName string, exprList []expression) (int64, error) { + if _, ok := t.indices2[indexName]; ok { + panic("internal error 009") + } + + hx, x, err := t.store.CreateIndex(unique) + if err != nil { + return -1, err + } + var a []string + for _, v := range exprList { + a = append(a, v.String()) + } + x2 := &index2{unique, x, hx, a, exprList} + if t.indices2 == nil { + t.indices2 = map[string]*index2{} + } + t.indices2[indexName] = x2 + + // Must fill the new index. + m := map[interface{}]interface{}{} + h, store := t.head, t.store + for h != 0 { + rec, err := store.Read(nil, h, t.cols...) + if err != nil { + return -1, err + } + + for _, col := range t.cols { + ci := col.index + v := interface{}(nil) + if ci < len(rec) { + v = rec[ci+2] + } + m[col.name] = v + } + + id := rec[1].(int64) + vlist, err := x2.eval(execCtx, t.cols, id, rec[2:]) + if err != nil { + return -1, err + } + + if err := x2.x.Create(vlist, h); err != nil { + return -1, err + } + + h = rec[0].(int64) + } + return hx, nil +} + +func (t *table) dropIndex(xIndex int) error { + t.xroots[xIndex] = 0 + if err := t.indices[xIndex].x.Drop(); err != nil { + return err + } + + t.indices[xIndex] = nil + return t.updated() +} + +func (t *table) updated() (err error) { + switch { + case len(t.indices) != 0: + a := []string{} + for _, v := range t.indices { + if v == nil { + a = append(a, "") + continue + } + + s := "n" + if v.unique { + s = "u" + } + a = append(a, s+v.name) + } + return t.store.Update(t.h, t.next, cols2meta(t.updateCols().cols0), t.hhead, t.name, strings.Join(a, "|"), t.hxroots) + default: + return t.store.Update(t.h, t.next, cols2meta(t.updateCols().cols0), t.hhead, t.name) + } +} + +// storage fields +// 0: next record handle int64 +// 1: record id int64 +// 2...: data row +func (t *table) addRecord(execCtx *execCtx, r []interface{}) (id int64, err error) { + if id, err = t.store.ID(); err != nil { + return + } + + r = append([]interface{}{t.head, id}, r...) + h, err := t.store.Create(r...) + if err != nil { + return + } + + for i, v := range t.indices { + if v == nil { + continue + } + + if err = v.x.Create([]interface{}{r[i+1]}, h); err != nil { + return + } + } + + for _, ix := range t.indices2 { + vlist, err := ix.eval(execCtx, t.cols, id, r[2:]) + if err != nil { + return -1, err + } + + if err := ix.x.Create(vlist, h); err != nil { + return -1, err + } + } + + if err = t.store.Update(t.hhead, h); err != nil { + return + } + + t.head = h + return +} + +func (t *table) flds() (r []*fld) { + r = make([]*fld, len(t.cols)) + for i, v := range t.cols { + r[i] = &fld{expr: &ident{v.name}, name: v.name} + } + return +} + +func (t *table) fieldNames() []string { + r := make([]string, len(t.cols)) + for i, v := range t.cols { + r[i] = v.name + } + return r +} + +func (t *table) updateCols() *table { + t.cols = t.cols[:0] + for i, c := range t.cols0 { + if c.name != "" { + c.index = i + t.cols = append(t.cols, c) + } + } + return t +} + +func (t *table) row0(ctx *execCtx, h int64) ([]interface{}, error) { + rec, err := ctx.db.store.Read(nil, h, t.cols...) + if err != nil { + return nil, err + } + + if d := len(t.cols) - (len(rec) - 2); d > 0 { + rec = append(rec, make([]interface{}, d)...) + } + + return rec, nil +} + +func (t *table) row(ctx *execCtx, h int64) (int64, []interface{}, error) { + rec, err := t.row0(ctx, h) + if err != nil { + return -1, nil, err + } + + return rec[1].(int64), rec[2:], nil +} + +// storage fields +// 0: handle of first table in DB int64 +type root struct { + head int64 // Single linked table list + lastInsertID int64 + parent *root + rowsAffected int64 //LATER implement + store storage + tables map[string]*table + thead *table +} + +func newRoot(store storage) (r *root, err error) { + data, err := store.Read(nil, 1) + if err != nil { + return + } + + switch len(data) { + case 0: // new empty DB, create empty table list + if err = store.BeginTransaction(); err != nil { + return + } + + if err = store.Update(1, int64(0)); err != nil { + store.Rollback() + return + } + + if err = store.Commit(); err != nil { + return + } + + return &root{ + store: store, + tables: map[string]*table{}, + }, nil + case 1: // existing DB, load tables + if len(data) != 1 { + return nil, fmt.Errorf("corrupted DB: root is an %d-scalar", len(data)) + } + + p, ok := data[0].(int64) + if !ok { + return nil, fmt.Errorf("corrupted DB: root head has type %T", data[0]) + } + + r := &root{ + head: p, + store: store, + tables: map[string]*table{}, + } + + var tprev *table + for p != 0 { + t := &table{ + h: p, + store: store, + tprev: tprev, + } + + if r.thead == nil { + r.thead = t + } + if tprev != nil { + tprev.tnext = t + } + tprev = t + + if err = t.load(); err != nil { + return nil, err + } + + if r.tables[t.name] != nil { // duplicate + return nil, fmt.Errorf("corrupted DB: duplicate table metadata for table %s", t.name) + } + + r.tables[t.name] = t + p = t.next + } + return r, nil + default: + return nil, errIncompatibleDBFormat + } +} + +func (r *root) findIndexByName(name string) (*table, interface{}) { + for _, t := range r.tables { + if i := t.findIndexByName(name); i != nil { + return t, i + } + } + + return nil, nil +} + +func (r *root) updated() (err error) { + return r.store.Update(1, r.head) +} + +func (r *root) createTable(name string, cols []*col) (t *table, err error) { + if _, ok := r.tables[name]; ok { + panic("internal error 065") + } + + if t, err = newTable(r.store, name, r.head, cols, nil, r.thead); err != nil { + return nil, err + } + + if err = r.store.Update(1, t.h); err != nil { + return nil, err + } + + if p := r.thead; p != nil { + p.tprev = t + } + r.tables[name], r.head, r.thead = t, t.h, t + return +} + +func (r *root) dropTable(t *table) (err error) { + defer func() { + if err != nil { + return + } + + delete(r.tables, t.name) + }() + + if err = t.truncate(); err != nil { + return + } + + if err = t.store.Delete(t.hhead); err != nil { + return + } + + if err = t.store.Delete(t.h); err != nil { + return + } + + for _, v := range t.indices { + if v != nil && v.x != nil { + if err = v.x.Drop(); err != nil { + return + } + } + } + for _, v := range t.indices2 { + if err = v.x.Drop(); err != nil { + return + } + } + + if h := t.hxroots; h != 0 { + if err = t.store.Delete(h); err != nil { + return + } + } + + switch { + case t.tprev == nil && t.tnext == nil: + r.head = 0 + r.thead = nil + err = r.updated() + return errSet(&err, r.store.ResetID()) + case t.tprev == nil && t.tnext != nil: + next := t.tnext + next.tprev = nil + r.head = next.h + r.thead = next + if err = r.updated(); err != nil { + return + } + + return next.updated() + case t.tprev != nil && t.tnext == nil: // last in list + prev := t.tprev + prev.next = 0 + prev.tnext = nil + return prev.updated() + default: //case t.tprev != nil && t.tnext != nil: + prev, next := t.tprev, t.tnext + prev.next = next.h + prev.tnext = next + next.tprev = prev + if err = prev.updated(); err != nil { + return + } + + return next.updated() + } +} diff --git a/vendor/github.com/cznic/sortutil/LICENSE b/vendor/github.com/cznic/sortutil/LICENSE new file mode 100644 index 0000000000..67983e0e61 --- /dev/null +++ b/vendor/github.com/cznic/sortutil/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2014 The sortutil 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 names of the authors nor the names of the +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. diff --git a/vendor/github.com/cznic/sortutil/sortutil.go b/vendor/github.com/cznic/sortutil/sortutil.go new file mode 100644 index 0000000000..c0ced542d3 --- /dev/null +++ b/vendor/github.com/cznic/sortutil/sortutil.go @@ -0,0 +1,227 @@ +// Copyright 2014 The sortutil 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 sortutil provides utilities supplementing the standard 'sort' package. +package sortutil + +import "sort" + +// ByteSlice attaches the methods of sort.Interface to []byte, sorting in increasing order. +type ByteSlice []byte + +func (s ByteSlice) Len() int { return len(s) } +func (s ByteSlice) Less(i, j int) bool { return s[i] < s[j] } +func (s ByteSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } + +// Sort is a convenience method. +func (s ByteSlice) Sort() { + sort.Sort(s) +} + +// SearchBytes searches for x in a sorted slice of bytes and returns the index +// as specified by sort.Search. The slice must be sorted in ascending order. +func SearchBytes(a []byte, x byte) int { + return sort.Search(len(a), func(i int) bool { return a[i] >= x }) +} + +// Float32Slice attaches the methods of sort.Interface to []float32, sorting in increasing order. +type Float32Slice []float32 + +func (s Float32Slice) Len() int { return len(s) } +func (s Float32Slice) Less(i, j int) bool { return s[i] < s[j] } +func (s Float32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } + +// Sort is a convenience method. +func (s Float32Slice) Sort() { + sort.Sort(s) +} + +// SearchFloat32s searches for x in a sorted slice of float32 and returns the index +// as specified by sort.Search. The slice must be sorted in ascending order. +func SearchFloat32s(a []float32, x float32) int { + return sort.Search(len(a), func(i int) bool { return a[i] >= x }) +} + +// Int8Slice attaches the methods of sort.Interface to []int8, sorting in increasing order. +type Int8Slice []int8 + +func (s Int8Slice) Len() int { return len(s) } +func (s Int8Slice) Less(i, j int) bool { return s[i] < s[j] } +func (s Int8Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } + +// Sort is a convenience method. +func (s Int8Slice) Sort() { + sort.Sort(s) +} + +// SearchInt8s searches for x in a sorted slice of int8 and returns the index +// as specified by sort.Search. The slice must be sorted in ascending order. +func SearchInt8s(a []int8, x int8) int { + return sort.Search(len(a), func(i int) bool { return a[i] >= x }) +} + +// Int16Slice attaches the methods of sort.Interface to []int16, sorting in increasing order. +type Int16Slice []int16 + +func (s Int16Slice) Len() int { return len(s) } +func (s Int16Slice) Less(i, j int) bool { return s[i] < s[j] } +func (s Int16Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } + +// Sort is a convenience method. +func (s Int16Slice) Sort() { + sort.Sort(s) +} + +// SearchInt16s searches for x in a sorted slice of int16 and returns the index +// as specified by sort.Search. The slice must be sorted in ascending order. +func SearchInt16s(a []int16, x int16) int { + return sort.Search(len(a), func(i int) bool { return a[i] >= x }) +} + +// Int32Slice attaches the methods of sort.Interface to []int32, sorting in increasing order. +type Int32Slice []int32 + +func (s Int32Slice) Len() int { return len(s) } +func (s Int32Slice) Less(i, j int) bool { return s[i] < s[j] } +func (s Int32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } + +// Sort is a convenience method. +func (s Int32Slice) Sort() { + sort.Sort(s) +} + +// SearchInt32s searches for x in a sorted slice of int32 and returns the index +// as specified by sort.Search. The slice must be sorted in ascending order. +func SearchInt32s(a []int32, x int32) int { + return sort.Search(len(a), func(i int) bool { return a[i] >= x }) +} + +// Int64Slice attaches the methods of sort.Interface to []int64, sorting in increasing order. +type Int64Slice []int64 + +func (s Int64Slice) Len() int { return len(s) } +func (s Int64Slice) Less(i, j int) bool { return s[i] < s[j] } +func (s Int64Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } + +// Sort is a convenience method. +func (s Int64Slice) Sort() { + sort.Sort(s) +} + +// SearchInt64s searches for x in a sorted slice of int64 and returns the index +// as specified by sort.Search. The slice must be sorted in ascending order. +func SearchInt64s(a []int64, x int64) int { + return sort.Search(len(a), func(i int) bool { return a[i] >= x }) +} + +// UintSlice attaches the methods of sort.Interface to []uint, sorting in increasing order. +type UintSlice []uint + +func (s UintSlice) Len() int { return len(s) } +func (s UintSlice) Less(i, j int) bool { return s[i] < s[j] } +func (s UintSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } + +// Sort is a convenience method. +func (s UintSlice) Sort() { + sort.Sort(s) +} + +// SearchUints searches for x in a sorted slice of uints and returns the index +// as specified by sort.Search. The slice must be sorted in ascending order. +func SearchUints(a []uint, x uint) int { + return sort.Search(len(a), func(i int) bool { return a[i] >= x }) +} + +// Uint16Slice attaches the methods of sort.Interface to []uint16, sorting in increasing order. +type Uint16Slice []uint16 + +func (s Uint16Slice) Len() int { return len(s) } +func (s Uint16Slice) Less(i, j int) bool { return s[i] < s[j] } +func (s Uint16Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } + +// Sort is a convenience method. +func (s Uint16Slice) Sort() { + sort.Sort(s) +} + +// SearchUint16s searches for x in a sorted slice of uint16 and returns the index +// as specified by sort.Search. The slice must be sorted in ascending order. +func SearchUint16s(a []uint16, x uint16) int { + return sort.Search(len(a), func(i int) bool { return a[i] >= x }) +} + +// Uint32Slice attaches the methods of sort.Interface to []uint32, sorting in increasing order. +type Uint32Slice []uint32 + +func (s Uint32Slice) Len() int { return len(s) } +func (s Uint32Slice) Less(i, j int) bool { return s[i] < s[j] } +func (s Uint32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } + +// Sort is a convenience method. +func (s Uint32Slice) Sort() { + sort.Sort(s) +} + +// SearchUint32s searches for x in a sorted slice of uint32 and returns the index +// as specified by sort.Search. The slice must be sorted in ascending order. +func SearchUint32s(a []uint32, x uint32) int { + return sort.Search(len(a), func(i int) bool { return a[i] >= x }) +} + +// Uint64Slice attaches the methods of sort.Interface to []uint64, sorting in increasing order. +type Uint64Slice []uint64 + +func (s Uint64Slice) Len() int { return len(s) } +func (s Uint64Slice) Less(i, j int) bool { return s[i] < s[j] } +func (s Uint64Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } + +// Sort is a convenience method. +func (s Uint64Slice) Sort() { + sort.Sort(s) +} + +// SearchUint64s searches for x in a sorted slice of uint64 and returns the index +// as specified by sort.Search. The slice must be sorted in ascending order. +func SearchUint64s(a []uint64, x uint64) int { + return sort.Search(len(a), func(i int) bool { return a[i] >= x }) +} + +// RuneSlice attaches the methods of sort.Interface to []rune, sorting in increasing order. +type RuneSlice []rune + +func (s RuneSlice) Len() int { return len(s) } +func (s RuneSlice) Less(i, j int) bool { return s[i] < s[j] } +func (s RuneSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } + +// Sort is a convenience method. +func (s RuneSlice) Sort() { + sort.Sort(s) +} + +// SearchRunes searches for x in a sorted slice of uint64 and returns the index +// as specified by sort.Search. The slice must be sorted in ascending order. +func SearchRunes(a []rune, x rune) int { + return sort.Search(len(a), func(i int) bool { return a[i] >= x }) +} + +// Dedupe returns n, the number of distinct elements in data. The resulting +// elements are sorted in elements [0, n) or data[:n] for a slice. +func Dedupe(data sort.Interface) (n int) { + if n = data.Len(); n < 2 { + return n + } + + sort.Sort(data) + a, b := 0, 1 + for b < n { + if data.Less(a, b) { + a++ + if a != b { + data.Swap(a, b) + } + } + b++ + } + return a + 1 +} diff --git a/vendor/github.com/cznic/strutil/LICENSE b/vendor/github.com/cznic/strutil/LICENSE new file mode 100644 index 0000000000..2fdd92cf71 --- /dev/null +++ b/vendor/github.com/cznic/strutil/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2014 The strutil 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 names of the authors nor the names of the +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. diff --git a/vendor/github.com/cznic/strutil/strutil.go b/vendor/github.com/cznic/strutil/strutil.go new file mode 100644 index 0000000000..ba83489df7 --- /dev/null +++ b/vendor/github.com/cznic/strutil/strutil.go @@ -0,0 +1,428 @@ +// Copyright (c) 2014 The sortutil 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 strutil collects utils supplemental to the standard strings package. +package strutil + +import ( + "bytes" + "encoding/base32" + "encoding/base64" + "fmt" + "io" + "strings" + "sync" +) + +// Base32ExtDecode decodes base32 extended (RFC 4648) text to binary data. +func Base32ExtDecode(text []byte) (data []byte, err error) { + n := base32.HexEncoding.DecodedLen(len(text)) + data = make([]byte, n) + decoder := base32.NewDecoder(base32.HexEncoding, bytes.NewBuffer(text)) + if n, err = decoder.Read(data); err != nil { + n = 0 + } + data = data[:n] + return +} + +// Base32ExtEncode encodes binary data to base32 extended (RFC 4648) encoded text. +func Base32ExtEncode(data []byte) (text []byte) { + n := base32.HexEncoding.EncodedLen(len(data)) + buf := bytes.NewBuffer(make([]byte, 0, n)) + encoder := base32.NewEncoder(base32.HexEncoding, buf) + encoder.Write(data) + encoder.Close() + if buf.Len() != n { + panic("internal error") + } + return buf.Bytes() +} + +// Base64Decode decodes base64 text to binary data. +func Base64Decode(text []byte) (data []byte, err error) { + n := base64.StdEncoding.DecodedLen(len(text)) + data = make([]byte, n) + decoder := base64.NewDecoder(base64.StdEncoding, bytes.NewBuffer(text)) + if n, err = decoder.Read(data); err != nil { + n = 0 + } + data = data[:n] + return +} + +// Base64Encode encodes binary data to base64 encoded text. +func Base64Encode(data []byte) (text []byte) { + n := base64.StdEncoding.EncodedLen(len(data)) + buf := bytes.NewBuffer(make([]byte, 0, n)) + encoder := base64.NewEncoder(base64.StdEncoding, buf) + encoder.Write(data) + encoder.Close() + if buf.Len() != n { + panic("internal error") + } + return buf.Bytes() +} + +// Formatter is an io.Writer extended by a fmt.Printf like function Format +type Formatter interface { + io.Writer + Format(format string, args ...interface{}) (n int, errno error) +} + +type indentFormatter struct { + io.Writer + indent []byte + indentLevel int + state int +} + +const ( + st0 = iota + stBOL + stPERC + stBOL_PERC +) + +// IndentFormatter returns a new Formatter which interprets %i and %u in the +// Format() format string as indent and undent commands. The commands can +// nest. The Formatter writes to io.Writer 'w' and inserts one 'indent' +// string per current indent level value. +// Behaviour of commands reaching negative indent levels is undefined. +// IndentFormatter(os.Stdout, "\t").Format("abc%d%%e%i\nx\ny\n%uz\n", 3) +// output: +// abc3%e +// x +// y +// z +// The Go quoted string literal form of the above is: +// "abc%%e\n\tx\n\tx\nz\n" +// The commands can be scattered between separate invocations of Format(), +// i.e. the formatter keeps track of the indent level and knows if it is +// positioned on start of a line and should emit indentation(s). +// The same output as above can be produced by e.g.: +// f := IndentFormatter(os.Stdout, " ") +// f.Format("abc%d%%e%i\nx\n", 3) +// f.Format("y\n%uz\n") +func IndentFormatter(w io.Writer, indent string) Formatter { + return &indentFormatter{w, []byte(indent), 0, stBOL} +} + +func (f *indentFormatter) format(flat bool, format string, args ...interface{}) (n int, errno error) { + buf := []byte{} + for i := 0; i < len(format); i++ { + c := format[i] + switch f.state { + case st0: + switch c { + case '\n': + cc := c + if flat && f.indentLevel != 0 { + cc = ' ' + } + buf = append(buf, cc) + f.state = stBOL + case '%': + f.state = stPERC + default: + buf = append(buf, c) + } + case stBOL: + switch c { + case '\n': + cc := c + if flat && f.indentLevel != 0 { + cc = ' ' + } + buf = append(buf, cc) + case '%': + f.state = stBOL_PERC + default: + if !flat { + for i := 0; i < f.indentLevel; i++ { + buf = append(buf, f.indent...) + } + } + buf = append(buf, c) + f.state = st0 + } + case stBOL_PERC: + switch c { + case 'i': + f.indentLevel++ + f.state = stBOL + case 'u': + f.indentLevel-- + f.state = stBOL + default: + if !flat { + for i := 0; i < f.indentLevel; i++ { + buf = append(buf, f.indent...) + } + } + buf = append(buf, '%', c) + f.state = st0 + } + case stPERC: + switch c { + case 'i': + f.indentLevel++ + f.state = st0 + case 'u': + f.indentLevel-- + f.state = st0 + default: + buf = append(buf, '%', c) + f.state = st0 + } + default: + panic("unexpected state") + } + } + switch f.state { + case stPERC, stBOL_PERC: + buf = append(buf, '%') + } + return f.Write([]byte(fmt.Sprintf(string(buf), args...))) +} + +func (f *indentFormatter) Format(format string, args ...interface{}) (n int, errno error) { + return f.format(false, format, args...) +} + +type flatFormatter indentFormatter + +// FlatFormatter returns a newly created Formatter with the same functionality as the one returned +// by IndentFormatter except it allows a newline in the 'format' string argument of Format +// to pass through iff indent level is currently zero. +// +// If indent level is non-zero then such new lines are changed to a space character. +// There is no indent string, the %i and %u format verbs are used solely to determine the indent level. +// +// The FlatFormatter is intended for flattening of normally nested structure textual representation to +// a one top level structure per line form. +// FlatFormatter(os.Stdout, " ").Format("abc%d%%e%i\nx\ny\n%uz\n", 3) +// output in the form of a Go quoted string literal: +// "abc3%%e x y z\n" +func FlatFormatter(w io.Writer) Formatter { + return (*flatFormatter)(IndentFormatter(w, "").(*indentFormatter)) +} + +func (f *flatFormatter) Format(format string, args ...interface{}) (n int, errno error) { + return (*indentFormatter)(f).format(true, format, args...) +} + +// Pool handles aligning of strings having equal values to the same string instance. +// Intended use is to conserve some memory e.g. where a large number of identically valued strings +// with non identical backing arrays may exists in several semantically distinct instances of some structs. +// Pool is *not* concurrent access safe. It doesn't handle common prefix/suffix aligning, +// e.g. having s1 == "abc" and s2 == "bc", s2 is not automatically aligned as s1[1:]. +type Pool struct { + pool map[string]string +} + +// NewPool returns a newly created Pool. +func NewPool() *Pool { + return &Pool{map[string]string{}} +} + +// Align returns a string with the same value as its argument. It guarantees that +// all aligned strings share a single instance in memory. +func (p *Pool) Align(s string) string { + if a, ok := p.pool[s]; ok { + return a + } + + s = StrPack(s) + p.pool[s] = s + return s +} + +// Count returns the number of items in the pool. +func (p *Pool) Count() int { + return len(p.pool) +} + +// GoPool is a concurrent access safe version of Pool. +type GoPool struct { + pool map[string]string + rwm *sync.RWMutex +} + +// NewGoPool returns a newly created GoPool. +func NewGoPool() (p *GoPool) { + return &GoPool{map[string]string{}, &sync.RWMutex{}} +} + +// Align returns a string with the same value as its argument. It guarantees that +// all aligned strings share a single instance in memory. +func (p *GoPool) Align(s string) (y string) { + if s != "" { + p.rwm.RLock() // R++ + if a, ok := p.pool[s]; ok { // found + p.rwm.RUnlock() // R-- + return a + } + + p.rwm.RUnlock() // R-- + // not found but with a race condition, retry within a write lock + p.rwm.Lock() // W++ + defer p.rwm.Unlock() // W-- + if a, ok := p.pool[s]; ok { // done in a race + return a + } + + // we won + s = StrPack(s) + p.pool[s] = s + return s + } + + return +} + +// Count returns the number of items in the pool. +func (p *GoPool) Count() int { + return len(p.pool) +} + +// Dict is a string <-> id bijection. Dict is *not* concurrent access safe for assigning new ids +// to strings not yet contained in the bijection. +// Id for an empty string is guaranteed to be 0, +// thus Id for any non empty string is guaranteed to be non zero. +type Dict struct { + si map[string]int + is []string +} + +// NewDict returns a newly created Dict. +func NewDict() (d *Dict) { + d = &Dict{map[string]int{}, []string{}} + d.Id("") + return +} + +// Count returns the number of items in the dict. +func (d *Dict) Count() int { + return len(d.is) +} + +// Id maps string s to its numeric identificator. +func (d *Dict) Id(s string) (y int) { + if y, ok := d.si[s]; ok { + return y + } + + s = StrPack(s) + y = len(d.is) + d.si[s] = y + d.is = append(d.is, s) + return +} + +// S maps an id to its string value and ok == true. Id values not contained in the bijection +// return "", false. +func (d *Dict) S(id int) (s string, ok bool) { + if id >= len(d.is) { + return "", false + } + return d.is[id], true +} + +// GoDict is a concurrent access safe version of Dict. +type GoDict struct { + si map[string]int + is []string + rwm *sync.RWMutex +} + +// NewGoDict returns a newly created GoDict. +func NewGoDict() (d *GoDict) { + d = &GoDict{map[string]int{}, []string{}, &sync.RWMutex{}} + d.Id("") + return +} + +// Count returns the number of items in the dict. +func (d *GoDict) Count() int { + return len(d.is) +} + +// Id maps string s to its numeric identificator. The implementation honors getting +// an existing id at the cost of assigning a new one. +func (d *GoDict) Id(s string) (y int) { + d.rwm.RLock() // R++ + if y, ok := d.si[s]; ok { // found + d.rwm.RUnlock() // R-- + return y + } + + d.rwm.RUnlock() // R-- + + // not found but with a race condition + d.rwm.Lock() // W++ recheck with write lock + defer d.rwm.Unlock() // W-- + if y, ok := d.si[s]; ok { // some other goroutine won already + return y + } + + // a race free not found state => insert the string + s = StrPack(s) + y = len(d.is) + d.si[s] = y + d.is = append(d.is, s) + return +} + +// S maps an id to its string value and ok == true. Id values not contained in the bijection +// return "", false. +func (d *GoDict) S(id int) (s string, ok bool) { + d.rwm.RLock() // R++ + defer d.rwm.RUnlock() // R-- + if id >= len(d.is) { + return "", false + } + return d.is[id], true +} + +// StrPack returns a new instance of s which is tightly packed in memory. +// It is intended for avoiding the situation where having a live reference +// to a string slice over an unreferenced biger underlying string keeps the biger one +// in memory anyway - it can't be GCed. +func StrPack(s string) string { + return string([]byte(s)) +} + +// JoinFields returns strings in flds joined by sep. Flds may contain arbitrary +// bytes, including the sep as they are safely escaped. JoinFields panics if +// sep is the backslash character or if len(sep) != 1. +func JoinFields(flds []string, sep string) string { + if len(sep) != 1 || sep == "\\" { + panic("invalid separator") + } + + a := make([]string, len(flds)) + for i, v := range flds { + v = strings.Replace(v, "\\", "\\0", -1) + a[i] = strings.Replace(v, sep, "\\1", -1) + } + return strings.Join(a, sep) +} + +// SplitFields splits s, which must be produced by JoinFields using the same +// sep, into flds. SplitFields panics if sep is the backslash character or if +// len(sep) != 1. +func SplitFields(s, sep string) (flds []string) { + if len(sep) != 1 || sep == "\\" { + panic("invalid separator") + } + + a := strings.Split(s, sep) + r := make([]string, len(a)) + for i, v := range a { + v = strings.Replace(v, "\\1", sep, -1) + r[i] = strings.Replace(v, "\\0", "\\", -1) + } + return r +} diff --git a/vendor/github.com/cznic/zappy/LICENSE b/vendor/github.com/cznic/zappy/LICENSE new file mode 100644 index 0000000000..bc67059c52 --- /dev/null +++ b/vendor/github.com/cznic/zappy/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2014 The zappy 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 names of the authors nor the names of the +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. diff --git a/vendor/github.com/cznic/zappy/decode.go b/vendor/github.com/cznic/zappy/decode.go new file mode 100644 index 0000000000..867c8deea5 --- /dev/null +++ b/vendor/github.com/cznic/zappy/decode.go @@ -0,0 +1,38 @@ +// Copyright 2014 The zappy Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Copyright 2011 The Snappy-Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the SNAPPY-GO-LICENSE file. + +package zappy + +import ( + "encoding/binary" + "errors" +) + +// ErrCorrupt reports that the input is invalid. +var ErrCorrupt = errors.New("zappy: corrupt input") + +// DecodedLen returns the length of the decoded block. +func DecodedLen(src []byte) (int, error) { + v, _, err := decodedLen(src) + return v, err +} + +// decodedLen returns the length of the decoded block and the number of bytes +// that the length header occupied. +func decodedLen(src []byte) (blockLen, headerLen int, err error) { + v, n := binary.Uvarint(src) + if n == 0 { + return 0, 0, ErrCorrupt + } + + if uint64(int(v)) != v { + return 0, 0, errors.New("zappy: decoded block is too large") + } + + return int(v), n, nil +} diff --git a/vendor/github.com/cznic/zappy/decode_cgo.go b/vendor/github.com/cznic/zappy/decode_cgo.go new file mode 100644 index 0000000000..993c99242b --- /dev/null +++ b/vendor/github.com/cznic/zappy/decode_cgo.go @@ -0,0 +1,121 @@ +// Copyright 2014 The zappy Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Copyright 2011 The Snappy-Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the SNAPPY-GO-LICENSE file. + +// +build cgo,!purego + +package zappy + +/* + +#include +#include + +// supports only uint32 encoded values +int uvarint(unsigned int* n, uint8_t* src, int len) { + int r = 0; + unsigned int v = 0; + unsigned int s = 0; + while ((len-- != 0) && (++r <= 5)) { + uint8_t b = *src++; + v = v | ((b&0x7f)<>1; + if ((u&1) != 0) + x = ~x; + *n = x; + return i; +} + +int decode(int s, int len_src, uint8_t* src, int len_dst, uint8_t* dst) { + int d = 0; + int length; + while (s < len_src) { + int n, i = varint(&n, src+s, len_src-s); + if (i <= 0) { + return -1; + } + + s += i; + if (n >= 0) { + length = n+1; + if ((length > len_dst-d) || (length > len_src-s)) + return -1; + + memcpy(dst+d, src+s, length); + d += length; + s += length; + continue; + } + + + length = -n; + int offset; + i = uvarint((unsigned int*)(&offset), src+s, len_src-s); + if (i <= 0) + return -1; + + s += i; + if (s > len_src) + return -1; + + int end = d+length; + if ((offset > d) || (end > len_dst)) + return -1; + + for( ; d < end; d++) + *(dst+d) = *(dst+d-offset); + } + return d; +} + +*/ +import "C" + +func puregoDecode() bool { return false } + +// Decode returns the decoded form of src. The returned slice may be a sub- +// slice of buf if buf was large enough to hold the entire decoded block. +// Otherwise, a newly allocated slice will be returned. +// It is valid to pass a nil buf. +func Decode(buf, src []byte) ([]byte, error) { + dLen, s, err := decodedLen(src) + if err != nil { + return nil, err + } + + if dLen == 0 { + if len(src) == 1 { + return nil, nil + } + + return nil, ErrCorrupt + } + + if len(buf) < dLen { + buf = make([]byte, dLen) + } + + d := int(C.decode(C.int(s), C.int(len(src)), (*C.uint8_t)(&src[0]), C.int(len(buf)), (*C.uint8_t)(&buf[0]))) + if d != dLen { + return nil, ErrCorrupt + } + + return buf[:d], nil +} diff --git a/vendor/github.com/cznic/zappy/decode_nocgo.go b/vendor/github.com/cznic/zappy/decode_nocgo.go new file mode 100644 index 0000000000..75b782f8fa --- /dev/null +++ b/vendor/github.com/cznic/zappy/decode_nocgo.go @@ -0,0 +1,89 @@ +// Copyright 2014 The zappy Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Copyright 2011 The Snappy-Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the SNAPPY-GO-LICENSE file. + +// +build !cgo purego + +package zappy + +import ( + "encoding/binary" +) + +func puregoDecode() bool { return true } + +// Decode returns the decoded form of src. The returned slice may be a sub- +// slice of buf if buf was large enough to hold the entire decoded block. +// Otherwise, a newly allocated slice will be returned. +// It is valid to pass a nil buf. +func Decode(buf, src []byte) ([]byte, error) { + dLen, s, err := decodedLen(src) + if err != nil { + return nil, err + } + + if dLen == 0 { + if len(src) == 1 { + return nil, nil + } + + return nil, ErrCorrupt + } + + if len(buf) < dLen { + buf = make([]byte, dLen) + } + + var d, offset, length int + for s < len(src) { + n, i := binary.Varint(src[s:]) + if i <= 0 { + return nil, ErrCorrupt + } + + s += i + if n >= 0 { + length = int(n + 1) + if length > len(buf)-d || length > len(src)-s { + return nil, ErrCorrupt + } + + copy(buf[d:], src[s:s+length]) + d += length + s += length + continue + } + + length = int(-n) + off64, i := binary.Uvarint(src[s:]) + if i <= 0 { + return nil, ErrCorrupt + } + + offset = int(off64) + s += i + if s > len(src) { + return nil, ErrCorrupt + } + + end := d + length + if offset > d || end > len(buf) { + return nil, ErrCorrupt + } + + for s, v := range buf[d-offset : end-offset] { + buf[d+s] = v + } + d = end + + } + if d != dLen { + return nil, ErrCorrupt + } + + return buf[:d], nil +} diff --git a/vendor/github.com/cznic/zappy/encode.go b/vendor/github.com/cznic/zappy/encode.go new file mode 100644 index 0000000000..27ceba03b8 --- /dev/null +++ b/vendor/github.com/cznic/zappy/encode.go @@ -0,0 +1,37 @@ +// Copyright 2014 The zappy Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Copyright 2011 The Snappy-Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the SNAPPY-GO-LICENSE file. + +package zappy + +import ( + "encoding/binary" +) + +// We limit how far copy back-references can go, the same as the snappy C++ +// code. +const maxOffset = 1 << 20 + +// emitCopy writes a copy chunk and returns the number of bytes written. +func emitCopy(dst []byte, offset, length int) (n int) { + n = binary.PutVarint(dst, int64(-length)) + n += binary.PutUvarint(dst[n:], uint64(offset)) + return +} + +// emitLiteral writes a literal chunk and returns the number of bytes written. +func emitLiteral(dst, lit []byte) (n int) { + n = binary.PutVarint(dst, int64(len(lit)-1)) + n += copy(dst[n:], lit) + return +} + +// MaxEncodedLen returns the maximum length of a zappy block, given its +// uncompressed length. +func MaxEncodedLen(srcLen int) int { + return 10 + srcLen +} diff --git a/vendor/github.com/cznic/zappy/encode_cgo.go b/vendor/github.com/cznic/zappy/encode_cgo.go new file mode 100644 index 0000000000..6c343f58eb --- /dev/null +++ b/vendor/github.com/cznic/zappy/encode_cgo.go @@ -0,0 +1,140 @@ +// Copyright 2014 The zappy Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Copyright 2011 The Snappy-Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the SNAPPY-GO-LICENSE file. + +// +build cgo,!purego + +package zappy + +/* + +#include +#include + +#define MAXOFFSET 1<<20 + +int putUvarint(uint8_t* buf, unsigned int x) { + int i = 1; + for (; x >= 0x80; i++) { + *buf++ = x|0x80; + x >>= 7; + } + *buf = x; + return i; +} + +int putVarint(uint8_t* buf, int x) { + unsigned int ux = x << 1; + if (x < 0) + ux = ~ux; + return putUvarint(buf, ux); +} + +int emitLiteral(uint8_t* dst, uint8_t* lit, int len_lit) { + int n = putVarint(dst, len_lit-1); + memcpy(dst+n, lit, len_lit); + return n+len_lit; +} + +int emitCopy(uint8_t* dst, int off, int len) { + int n = putVarint(dst, -len); + return n+putUvarint(dst+n, (unsigned int)off); +} + +int encode(int d, uint8_t* dst, uint8_t* src, int len_src) { + int table[1<<12]; + int s = 0; + int t = 0; + int lit = 0; + int lim = 0; + memset(table, 0, sizeof(table)); + for (lim = len_src-3; s < lim; ) { + // Update the hash table. + uint32_t b0 = src[s]; + uint32_t b1 = src[s+1]; + uint32_t b2 = src[s+2]; + uint32_t b3 = src[s+3]; + uint32_t h = b0 | (b1<<8) | (b2<<16) | (b3<<24); + uint32_t i; +more: + i = (h*0x1e35a7bd)>>20; + t = table[i]; + table[i] = s; + // If t is invalid or src[s:s+4] differs from src[t:t+4], accumulate a literal byte. + if ((t == 0) || (s-t >= MAXOFFSET) || (b0 != src[t]) || (b1 != src[t+1]) || (b2 != src[t+2]) || (b3 != src[t+3])) { + s++; + if (s >= lim) + break; + + b0 = b1; + b1 = b2; + b2 = b3; + b3 = src[s+3]; + h = (h>>8) | ((b3)<<24); + goto more; + } + + // Otherwise, we have a match. First, emit any pending literal bytes. + if (lit != s) { + d += emitLiteral(dst+d, src+lit, s-lit); + } + // Extend the match to be as long as possible. + int s0 = s; + s += 4; + t += 4; + while ((s < len_src) && (src[s] == src[t])) { + s++; + t++; + } + d += emitCopy(dst+d, s-t, s-s0); + lit = s; + } + // Emit any final pending literal bytes and return. + if (lit != len_src) { + d += emitLiteral(dst+d, src+lit, len_src-lit); + } + return d; +} + +*/ +import "C" + +import ( + "encoding/binary" + "fmt" + "math" +) + +func puregoEncode() bool { return false } + +// Encode returns the encoded form of src. The returned slice may be a sub- +// slice of buf if buf was large enough to hold the entire encoded block. +// Otherwise, a newly allocated slice will be returned. +// It is valid to pass a nil buf. +func Encode(buf, src []byte) ([]byte, error) { + if n := MaxEncodedLen(len(src)); len(buf) < n { + buf = make([]byte, n) + } + + if len(src) > math.MaxInt32 { + return nil, fmt.Errorf("zappy.Encode: too long data: %d bytes", len(src)) + } + + // The block starts with the varint-encoded length of the decompressed bytes. + d := binary.PutUvarint(buf, uint64(len(src))) + + // Return early if src is short. + if len(src) <= 4 { + if len(src) != 0 { + d += emitLiteral(buf[d:], src) + } + return buf[:d], nil + } + + d = int(C.encode(C.int(d), (*C.uint8_t)(&buf[0]), (*C.uint8_t)(&src[0]), C.int(len(src)))) + return buf[:d], nil +} diff --git a/vendor/github.com/cznic/zappy/encode_nocgo.go b/vendor/github.com/cznic/zappy/encode_nocgo.go new file mode 100644 index 0000000000..1d1df44395 --- /dev/null +++ b/vendor/github.com/cznic/zappy/encode_nocgo.go @@ -0,0 +1,92 @@ +// Copyright 2014 The zappy Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Copyright 2011 The Snappy-Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the SNAPPY-GO-LICENSE file. + +// +build !cgo purego + +package zappy + +import ( + "encoding/binary" + "fmt" + "math" +) + +func puregoEncode() bool { return true } + +// Encode returns the encoded form of src. The returned slice may be a sub- +// slice of buf if buf was large enough to hold the entire encoded block. +// Otherwise, a newly allocated slice will be returned. +// It is valid to pass a nil buf. +func Encode(buf, src []byte) ([]byte, error) { + if n := MaxEncodedLen(len(src)); len(buf) < n { + buf = make([]byte, n) + } + + if len(src) > math.MaxInt32 { + return nil, fmt.Errorf("zappy.Encode: too long data: %d bytes", len(src)) + } + + // The block starts with the varint-encoded length of the decompressed bytes. + d := binary.PutUvarint(buf, uint64(len(src))) + + // Return early if src is short. + if len(src) <= 4 { + if len(src) != 0 { + d += emitLiteral(buf[d:], src) + } + return buf[:d], nil + } + + // Iterate over the source bytes. + var ( + table [1 << 12]int // Hash table + s int // The iterator position. + t int // The last position with the same hash as s. + lit int // The start position of any pending literal bytes. + ) + for lim := len(src) - 3; s < lim; { + // Update the hash table. + b0, b1, b2, b3 := src[s], src[s+1], src[s+2], src[s+3] + h := uint32(b0) | uint32(b1)<<8 | uint32(b2)<<16 | uint32(b3)<<24 + more: + p := &table[(h*0x1e35a7bd)>>20] + t, *p = *p, s + // If t is invalid or src[s:s+4] differs from src[t:t+4], accumulate a literal byte. + if t == 0 || s-t >= maxOffset || b0 != src[t] || b1 != src[t+1] || b2 != src[t+2] || b3 != src[t+3] { + s++ + if s >= lim { + break + } + + b0, b1, b2, b3 = b1, b2, b3, src[s+3] + h = h>>8 | uint32(b3)<<24 + goto more + } + + // Otherwise, we have a match. First, emit any pending literal bytes. + if lit != s { + d += emitLiteral(buf[d:], src[lit:s]) + } + // Extend the match to be as long as possible. + s0 := s + s, t = s+4, t+4 + for s < len(src) && src[s] == src[t] { + s++ + t++ + } + // Emit the copied bytes. + d += emitCopy(buf[d:], s-t, s-s0) + lit = s + } + + // Emit any final pending literal bytes and return. + if lit != len(src) { + d += emitLiteral(buf[d:], src[lit:]) + } + return buf[:d], nil +} diff --git a/vendor/github.com/cznic/zappy/zappy.go b/vendor/github.com/cznic/zappy/zappy.go new file mode 100644 index 0000000000..760df34a15 --- /dev/null +++ b/vendor/github.com/cznic/zappy/zappy.go @@ -0,0 +1,241 @@ +// Copyright 2014 The zappy Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Copyright 2011 The Snappy-Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the SNAPPY-GO-LICENSE file. + +/* +Package zappy implements the zappy block-based compression format. It aims for +a combination of good speed and reasonable compression. + +Zappy is a format incompatible, API compatible fork of snappy-go[1]. The C++ +snappy implementation is at [2]. + +Reasons for the fork + +The snappy compression is pretty good. Yet it has one problem built into its +format definition[3] - the maximum length of a copy "instruction" is 64 bytes. +For some specific usage patterns with long runs of repeated data, it turns out +the compression is suboptimal. For example a 1:1000 "sparseness" 64kB bit index +with only few set bits is compressed to about 3kB (about 1000 of 64B copy, 3 +byte "instructions"). + +Format description + +Zappy uses much less complicated format than snappy. Each encoded block begins +with the uvarint-encoded[4] length of the decoded data, followed by a sequence +of chunks. Chunks begin and end on byte boundaries. The chunk starts with a +varint encoded number N: + + N >= 0: N+1 literal bytes follow. + + N < 0: copy -N bytes, starting at offset M (in the following uvarint). + +Performance issues + +Compression rate is roughly the same as of snappy for the reference data set: + + testdata/html: snappy 23320, zappy 22943, 0.984, orig 102400 + testdata/urls.10K: snappy 334437, zappy 355163, 1.062, orig 702087 + testdata/house.jpg: snappy 126711, zappy 126694, 1.000, orig 126958 + testdata/mapreduce-osdi-1.pdf: snappy 77227, zappy 77646, 1.005, orig 94330 + testdata/html_x_4: snappy 92350, zappy 22956, 0.249, orig 409600 + testdata/cp.html: snappy 11938, zappy 12961, 1.086, orig 24603 + testdata/fields.c: snappy 4825, zappy 5395, 1.118, orig 11150 + testdata/grammar.lsp: snappy 1814, zappy 1933, 1.066, orig 3721 + testdata/kennedy.xls: snappy 423518, zappy 440597, 1.040, orig 1029744 + testdata/alice29.txt: snappy 89550, zappy 104016, 1.162, orig 152089 + testdata/asyoulik.txt: snappy 79583, zappy 91345, 1.148, orig 125179 + testdata/lcet10.txt: snappy 238761, zappy 275488, 1.154, orig 426754 + testdata/plrabn12.txt: snappy 324567, zappy 376885, 1.161, orig 481861 + testdata/ptt5: snappy 96350, zappy 91465, 0.949, orig 513216 + testdata/sum: snappy 18927, zappy 20015, 1.057, orig 38240 + testdata/xargs.1: snappy 2532, zappy 2793, 1.103, orig 4227 + testdata/geo.protodata: snappy 23362, zappy 20759, 0.889, orig 118588 + testdata/kppkn.gtb: snappy 73962, zappy 87200, 1.179, orig 184320 + TOTAL: snappy 2043734, zappy 2136254, 1.045, orig 4549067 + +Zappy has better RLE handling (1/1000+1 non zero bytes in each index): + + Sparse bit index 16 B: snappy 9, zappy 9, 1.000 + Sparse bit index 32 B: snappy 10, zappy 10, 1.000 + Sparse bit index 64 B: snappy 11, zappy 10, 0.909 + Sparse bit index 128 B: snappy 16, zappy 14, 0.875 + Sparse bit index 256 B: snappy 22, zappy 14, 0.636 + Sparse bit index 512 B: snappy 36, zappy 16, 0.444 + Sparse bit index 1024 B: snappy 57, zappy 18, 0.316 + Sparse bit index 2048 B: snappy 111, zappy 32, 0.288 + Sparse bit index 4096 B: snappy 210, zappy 31, 0.148 + Sparse bit index 8192 B: snappy 419, zappy 75, 0.179 + Sparse bit index 16384 B: snappy 821, zappy 138, 0.168 + Sparse bit index 32768 B: snappy 1627, zappy 232, 0.143 + Sparse bit index 65536 B: snappy 3243, zappy 451, 0.139 + +When compiled with CGO_ENABLED=1, zappy is now faster than snappy-go. +Old=snappy-go, new=zappy: + + benchmark old MB/s new MB/s speedup + BenchmarkWordsDecode1e3 148.98 189.04 1.27x + BenchmarkWordsDecode1e4 150.29 182.51 1.21x + BenchmarkWordsDecode1e5 145.79 182.95 1.25x + BenchmarkWordsDecode1e6 167.43 187.69 1.12x + BenchmarkWordsEncode1e3 47.11 145.69 3.09x + BenchmarkWordsEncode1e4 81.47 136.50 1.68x + BenchmarkWordsEncode1e5 78.86 127.93 1.62x + BenchmarkWordsEncode1e6 96.81 142.95 1.48x + Benchmark_UFlat0 316.87 463.19 1.46x + Benchmark_UFlat1 231.56 350.32 1.51x + Benchmark_UFlat2 3656.68 8258.39 2.26x + Benchmark_UFlat3 892.56 1270.09 1.42x + Benchmark_UFlat4 315.84 959.08 3.04x + Benchmark_UFlat5 211.70 301.55 1.42x + Benchmark_UFlat6 211.59 258.29 1.22x + Benchmark_UFlat7 209.80 272.21 1.30x + Benchmark_UFlat8 254.59 301.70 1.19x + Benchmark_UFlat9 163.39 192.66 1.18x + Benchmark_UFlat10 155.46 189.70 1.22x + Benchmark_UFlat11 170.11 198.95 1.17x + Benchmark_UFlat12 148.32 178.78 1.21x + Benchmark_UFlat13 359.25 579.99 1.61x + Benchmark_UFlat14 197.27 291.33 1.48x + Benchmark_UFlat15 185.75 248.07 1.34x + Benchmark_UFlat16 362.74 582.66 1.61x + Benchmark_UFlat17 222.95 240.01 1.08x + Benchmark_ZFlat0 188.66 311.89 1.65x + Benchmark_ZFlat1 101.46 201.34 1.98x + Benchmark_ZFlat2 93.62 244.50 2.61x + Benchmark_ZFlat3 102.79 243.34 2.37x + Benchmark_ZFlat4 191.64 625.32 3.26x + Benchmark_ZFlat5 103.09 169.39 1.64x + Benchmark_ZFlat6 110.35 182.57 1.65x + Benchmark_ZFlat7 89.56 190.53 2.13x + Benchmark_ZFlat8 154.05 235.68 1.53x + Benchmark_ZFlat9 87.58 133.51 1.52x + Benchmark_ZFlat10 82.08 127.51 1.55x + Benchmark_ZFlat11 91.36 138.91 1.52x + Benchmark_ZFlat12 79.24 123.02 1.55x + Benchmark_ZFlat13 217.04 374.26 1.72x + Benchmark_ZFlat14 100.33 168.03 1.67x + Benchmark_ZFlat15 80.79 160.46 1.99x + Benchmark_ZFlat16 213.32 375.79 1.76x + Benchmark_ZFlat17 135.37 197.13 1.46x + +The package builds with CGO_ENABLED=0 as well, but the performance is worse. + + + $ CGO_ENABLED=0 go test -test.run=NONE -test.bench=. > old.benchcmp + $ CGO_ENABLED=1 go test -test.run=NONE -test.bench=. > new.benchcmp + $ benchcmp old.benchcmp new.benchcmp + benchmark old ns/op new ns/op delta + BenchmarkWordsDecode1e3 9735 5288 -45.68% + BenchmarkWordsDecode1e4 100229 55369 -44.76% + BenchmarkWordsDecode1e5 1037611 546420 -47.34% + BenchmarkWordsDecode1e6 9559352 5335307 -44.19% + BenchmarkWordsEncode1e3 16206 6629 -59.10% + BenchmarkWordsEncode1e4 140283 73161 -47.85% + BenchmarkWordsEncode1e5 1476657 781756 -47.06% + BenchmarkWordsEncode1e6 12702229 6997656 -44.91% + Benchmark_UFlat0 397307 221198 -44.33% + Benchmark_UFlat1 3890483 2008341 -48.38% + Benchmark_UFlat2 35810 15398 -57.00% + Benchmark_UFlat3 140850 74194 -47.32% + Benchmark_UFlat4 814575 426783 -47.61% + Benchmark_UFlat5 156995 81473 -48.10% + Benchmark_UFlat6 77645 43161 -44.41% + Benchmark_UFlat7 25415 13579 -46.57% + Benchmark_UFlat8 6372440 3412916 -46.44% + Benchmark_UFlat9 1453679 789956 -45.66% + Benchmark_UFlat10 1243146 660747 -46.85% + Benchmark_UFlat11 3903493 2146334 -45.02% + Benchmark_UFlat12 5106250 2696144 -47.20% + Benchmark_UFlat13 1641394 884969 -46.08% + Benchmark_UFlat14 262206 131174 -49.97% + Benchmark_UFlat15 32325 17047 -47.26% + Benchmark_UFlat16 366991 204877 -44.17% + Benchmark_UFlat17 1343988 770907 -42.64% + Benchmark_ZFlat0 579954 329812 -43.13% + Benchmark_ZFlat1 6564692 3504867 -46.61% + Benchmark_ZFlat2 902029 513700 -43.05% + Benchmark_ZFlat3 678722 384312 -43.38% + Benchmark_ZFlat4 1197389 654361 -45.35% + Benchmark_ZFlat5 262677 144939 -44.82% + Benchmark_ZFlat6 111249 60876 -45.28% + Benchmark_ZFlat7 39024 19420 -50.24% + Benchmark_ZFlat8 8046106 4387928 -45.47% + Benchmark_ZFlat9 2043167 1143139 -44.05% + Benchmark_ZFlat10 1781604 980528 -44.96% + Benchmark_ZFlat11 5478647 3078585 -43.81% + Benchmark_ZFlat12 7245995 3929863 -45.77% + Benchmark_ZFlat13 2432529 1371606 -43.61% + Benchmark_ZFlat14 420315 227494 -45.88% + Benchmark_ZFlat15 52378 26564 -49.28% + Benchmark_ZFlat16 567047 316196 -44.24% + Benchmark_ZFlat17 1630820 937310 -42.53% + + benchmark old MB/s new MB/s speedup + BenchmarkWordsDecode1e3 102.71 189.08 1.84x + BenchmarkWordsDecode1e4 99.77 180.60 1.81x + BenchmarkWordsDecode1e5 96.38 183.01 1.90x + BenchmarkWordsDecode1e6 104.61 187.43 1.79x + BenchmarkWordsEncode1e3 61.70 150.85 2.44x + BenchmarkWordsEncode1e4 71.28 136.68 1.92x + BenchmarkWordsEncode1e5 67.72 127.92 1.89x + BenchmarkWordsEncode1e6 78.73 142.90 1.82x + Benchmark_UFlat0 257.73 462.93 1.80x + Benchmark_UFlat1 180.46 349.59 1.94x + Benchmark_UFlat2 3545.30 8244.61 2.33x + Benchmark_UFlat3 669.72 1271.39 1.90x + Benchmark_UFlat4 502.84 959.74 1.91x + Benchmark_UFlat5 156.71 301.98 1.93x + Benchmark_UFlat6 143.60 258.33 1.80x + Benchmark_UFlat7 146.41 274.01 1.87x + Benchmark_UFlat8 161.59 301.72 1.87x + Benchmark_UFlat9 104.62 192.53 1.84x + Benchmark_UFlat10 100.70 189.45 1.88x + Benchmark_UFlat11 109.33 198.83 1.82x + Benchmark_UFlat12 94.37 178.72 1.89x + Benchmark_UFlat13 312.67 579.93 1.85x + Benchmark_UFlat14 145.84 291.52 2.00x + Benchmark_UFlat15 130.77 247.95 1.90x + Benchmark_UFlat16 323.14 578.82 1.79x + Benchmark_UFlat17 137.14 239.09 1.74x + Benchmark_ZFlat0 176.57 310.48 1.76x + Benchmark_ZFlat1 106.95 200.32 1.87x + Benchmark_ZFlat2 140.75 247.14 1.76x + Benchmark_ZFlat3 138.98 245.45 1.77x + Benchmark_ZFlat4 342.08 625.95 1.83x + Benchmark_ZFlat5 93.66 169.75 1.81x + Benchmark_ZFlat6 100.23 183.16 1.83x + Benchmark_ZFlat7 95.35 191.60 2.01x + Benchmark_ZFlat8 127.98 234.68 1.83x + Benchmark_ZFlat9 74.44 133.04 1.79x + Benchmark_ZFlat10 70.26 127.66 1.82x + Benchmark_ZFlat11 77.89 138.62 1.78x + Benchmark_ZFlat12 66.50 122.62 1.84x + Benchmark_ZFlat13 210.98 374.17 1.77x + Benchmark_ZFlat14 90.98 168.09 1.85x + Benchmark_ZFlat15 80.70 159.12 1.97x + Benchmark_ZFlat16 209.13 375.04 1.79x + Benchmark_ZFlat17 113.02 196.65 1.74x + $ + +Build tags + +If a constraint 'purego' appears in the build constraints [5] then a pure Go +version is built regardless of the $CGO_ENABLED value. + + $ touch zappy.go ; go install -tags purego github.com/cznic/zappy # for example + +Information sources + +... referenced from the above documentation. + + [1]: http://code.google.com/p/snappy-go/ + [2]: http://code.google.com/p/snappy/ + [3]: http://code.google.com/p/snappy/source/browse/trunk/format_description.txt + [4]: http://golang.org/pkg/encoding/binary/ + [5]: http://golang.org/pkg/go/build/#hdr-Build_Constraints +*/ +package zappy diff --git a/vendor/github.com/d2g/dhcp4/LICENSE b/vendor/github.com/d2g/dhcp4/LICENSE new file mode 100644 index 0000000000..f7d058a358 --- /dev/null +++ b/vendor/github.com/d2g/dhcp4/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2013 Skagerrak Software Limited. 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 Skagerrak Software Limited 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. \ No newline at end of file diff --git a/vendor/github.com/d2g/dhcp4/constants.go b/vendor/github.com/d2g/dhcp4/constants.go new file mode 100644 index 0000000000..183a778371 --- /dev/null +++ b/vendor/github.com/d2g/dhcp4/constants.go @@ -0,0 +1,121 @@ +package dhcp4 + +// OpCodes +const ( + BootRequest OpCode = 1 // From Client + BootReply OpCode = 2 // From Server +) + +// DHCP Message Type 53 +const ( + Discover MessageType = 1 // Broadcast Packet From Client - Can I have an IP? + Offer MessageType = 2 // Broadcast From Server - Here's an IP + Request MessageType = 3 // Broadcast From Client - I'll take that IP (Also start for renewals) + Decline MessageType = 4 // Broadcast From Client - Sorry I can't use that IP + ACK MessageType = 5 // From Server, Yes you can have that IP + NAK MessageType = 6 // From Server, No you cannot have that IP + Release MessageType = 7 // From Client, I don't need that IP anymore + Inform MessageType = 8 // From Client, I have this IP and there's nothing you can do about it +) + +// DHCP Options +const ( + End OptionCode = 255 + Pad OptionCode = 0 + OptionSubnetMask OptionCode = 1 + OptionTimeOffset OptionCode = 2 + OptionRouter OptionCode = 3 + OptionTimeServer OptionCode = 4 + OptionNameServer OptionCode = 5 + OptionDomainNameServer OptionCode = 6 + OptionLogServer OptionCode = 7 + OptionCookieServer OptionCode = 8 + OptionLPRServer OptionCode = 9 + OptionImpressServer OptionCode = 10 + OptionResourceLocationServer OptionCode = 11 + OptionHostName OptionCode = 12 + OptionBootFileSize OptionCode = 13 + OptionMeritDumpFile OptionCode = 14 + OptionDomainName OptionCode = 15 + OptionSwapServer OptionCode = 16 + OptionRootPath OptionCode = 17 + OptionExtensionsPath OptionCode = 18 + + // IP Layer Parameters per Host + OptionIPForwardingEnableDisable OptionCode = 19 + OptionNonLocalSourceRoutingEnableDisable OptionCode = 20 + OptionPolicyFilter OptionCode = 21 + OptionMaximumDatagramReassemblySize OptionCode = 22 + OptionDefaultIPTimeToLive OptionCode = 23 + OptionPathMTUAgingTimeout OptionCode = 24 + OptionPathMTUPlateauTable OptionCode = 25 + + // IP Layer Parameters per Interface + OptionInterfaceMTU OptionCode = 26 + OptionAllSubnetsAreLocal OptionCode = 27 + OptionBroadcastAddress OptionCode = 28 + OptionPerformMaskDiscovery OptionCode = 29 + OptionMaskSupplier OptionCode = 30 + OptionPerformRouterDiscovery OptionCode = 31 + OptionRouterSolicitationAddress OptionCode = 32 + OptionStaticRoute OptionCode = 33 + + // Link Layer Parameters per Interface + OptionTrailerEncapsulation OptionCode = 34 + OptionARPCacheTimeout OptionCode = 35 + OptionEthernetEncapsulation OptionCode = 36 + + // TCP Parameters + OptionTCPDefaultTTL OptionCode = 37 + OptionTCPKeepaliveInterval OptionCode = 38 + OptionTCPKeepaliveGarbage OptionCode = 39 + + // Application and Service Parameters + OptionNetworkInformationServiceDomain OptionCode = 40 + OptionNetworkInformationServers OptionCode = 41 + OptionNetworkTimeProtocolServers OptionCode = 42 + OptionVendorSpecificInformation OptionCode = 43 + OptionNetBIOSOverTCPIPNameServer OptionCode = 44 + OptionNetBIOSOverTCPIPDatagramDistributionServer OptionCode = 45 + OptionNetBIOSOverTCPIPNodeType OptionCode = 46 + OptionNetBIOSOverTCPIPScope OptionCode = 47 + OptionXWindowSystemFontServer OptionCode = 48 + OptionXWindowSystemDisplayManager OptionCode = 49 + OptionNetworkInformationServicePlusDomain OptionCode = 64 + OptionNetworkInformationServicePlusServers OptionCode = 65 + OptionMobileIPHomeAgent OptionCode = 68 + OptionSimpleMailTransportProtocol OptionCode = 69 + OptionPostOfficeProtocolServer OptionCode = 70 + OptionNetworkNewsTransportProtocol OptionCode = 71 + OptionDefaultWorldWideWebServer OptionCode = 72 + OptionDefaultFingerServer OptionCode = 73 + OptionDefaultInternetRelayChatServer OptionCode = 74 + OptionStreetTalkServer OptionCode = 75 + OptionStreetTalkDirectoryAssistance OptionCode = 76 + + // DHCP Extensions + OptionRequestedIPAddress OptionCode = 50 + OptionIPAddressLeaseTime OptionCode = 51 + OptionOverload OptionCode = 52 + OptionDHCPMessageType OptionCode = 53 + OptionServerIdentifier OptionCode = 54 + OptionParameterRequestList OptionCode = 55 + OptionMessage OptionCode = 56 + OptionMaximumDHCPMessageSize OptionCode = 57 + OptionRenewalTimeValue OptionCode = 58 + OptionRebindingTimeValue OptionCode = 59 + OptionVendorClassIdentifier OptionCode = 60 + OptionClientIdentifier OptionCode = 61 + + OptionTFTPServerName OptionCode = 66 + OptionBootFileName OptionCode = 67 + + OptionUserClass OptionCode = 77 + + OptionClientArchitecture OptionCode = 93 + + OptionTZPOSIXString OptionCode = 100 + OptionTZDatabaseString OptionCode = 101 + + OptionClasslessRouteFormat OptionCode = 121 +) diff --git a/vendor/github.com/d2g/dhcp4/helpers.go b/vendor/github.com/d2g/dhcp4/helpers.go new file mode 100644 index 0000000000..4b1463869f --- /dev/null +++ b/vendor/github.com/d2g/dhcp4/helpers.go @@ -0,0 +1,58 @@ +package dhcp4 + +import ( + "encoding/binary" + "net" + "time" +) + +// IPRange returns how many ips in the ip range from start to stop (inclusive) +func IPRange(start, stop net.IP) int { + //return int(Uint([]byte(stop))-Uint([]byte(start))) + 1 + return int(binary.BigEndian.Uint32(stop.To4())) - int(binary.BigEndian.Uint32(start.To4())) + 1 +} + +// IPAdd returns a copy of start + add. +// IPAdd(net.IP{192,168,1,1},30) returns net.IP{192.168.1.31} +func IPAdd(start net.IP, add int) net.IP { // IPv4 only + start = start.To4() + //v := Uvarint([]byte(start)) + result := make(net.IP, 4) + binary.BigEndian.PutUint32(result, binary.BigEndian.Uint32(start)+uint32(add)) + //PutUint([]byte(result), v+uint64(add)) + return result +} + +// IPLess returns where IP a is less than IP b. +func IPLess(a, b net.IP) bool { + b = b.To4() + for i, ai := range a.To4() { + if ai != b[i] { + return ai < b[i] + } + } + return false +} + +// IPInRange returns true if ip is between (inclusive) start and stop. +func IPInRange(start, stop, ip net.IP) bool { + return !(IPLess(ip, start) || IPLess(stop, ip)) +} + +// OptionsLeaseTime - converts a time.Duration to a 4 byte slice, compatible +// with OptionIPAddressLeaseTime. +func OptionsLeaseTime(d time.Duration) []byte { + leaseBytes := make([]byte, 4) + binary.BigEndian.PutUint32(leaseBytes, uint32(d/time.Second)) + //PutUvarint(leaseBytes, uint64(d/time.Second)) + return leaseBytes +} + +// JoinIPs returns a byte slice of IP addresses, one immediately after the other +// This may be useful for creating multiple IP options such as OptionRouter. +func JoinIPs(ips []net.IP) (b []byte) { + for _, v := range ips { + b = append(b, v.To4()...) + } + return +} diff --git a/vendor/github.com/d2g/dhcp4/option.go b/vendor/github.com/d2g/dhcp4/option.go new file mode 100644 index 0000000000..f3239e1980 --- /dev/null +++ b/vendor/github.com/d2g/dhcp4/option.go @@ -0,0 +1,40 @@ +package dhcp4 + +type OptionCode byte + +type Option struct { + Code OptionCode + Value []byte +} + +// Map of DHCP options +type Options map[OptionCode][]byte + +// SelectOrderOrAll has same functionality as SelectOrder, except if the order +// param is nil, whereby all options are added (in arbitary order). +func (o Options) SelectOrderOrAll(order []byte) []Option { + if order == nil { + opts := make([]Option, 0, len(o)) + for i, v := range o { + opts = append(opts, Option{Code: i, Value: v}) + } + return opts + } + return o.SelectOrder(order) +} + +// SelectOrder returns a slice of options ordered and selected by a byte array +// usually defined by OptionParameterRequestList. This result is expected to be +// used in ReplyPacket()'s []Option parameter. +func (o Options) SelectOrder(order []byte) []Option { + opts := make([]Option, 0, len(order)) + for _, v := range order { + if data, ok := o[OptionCode(v)]; ok { + opts = append(opts, Option{Code: OptionCode(v), Value: data}) + } + } + return opts +} + +type OpCode byte +type MessageType byte // Option 53 diff --git a/vendor/github.com/d2g/dhcp4/packet.go b/vendor/github.com/d2g/dhcp4/packet.go new file mode 100644 index 0000000000..5e547c86fa --- /dev/null +++ b/vendor/github.com/d2g/dhcp4/packet.go @@ -0,0 +1,149 @@ +package dhcp4 + +import ( + "net" + "time" +) + +// A DHCP packet +type Packet []byte + +func (p Packet) OpCode() OpCode { return OpCode(p[0]) } +func (p Packet) HType() byte { return p[1] } +func (p Packet) HLen() byte { return p[2] } +func (p Packet) Hops() byte { return p[3] } +func (p Packet) XId() []byte { return p[4:8] } +func (p Packet) Secs() []byte { return p[8:10] } // Never Used? +func (p Packet) Flags() []byte { return p[10:12] } +func (p Packet) CIAddr() net.IP { return net.IP(p[12:16]) } +func (p Packet) YIAddr() net.IP { return net.IP(p[16:20]) } +func (p Packet) SIAddr() net.IP { return net.IP(p[20:24]) } +func (p Packet) GIAddr() net.IP { return net.IP(p[24:28]) } +func (p Packet) CHAddr() net.HardwareAddr { + hLen := p.HLen() + if hLen > 16 { // Prevent chaddr exceeding p boundary + hLen = 16 + } + return net.HardwareAddr(p[28 : 28+hLen]) // max endPos 44 +} + +// 192 bytes of zeros BOOTP legacy +func (p Packet) Cookie() []byte { return p[236:240] } +func (p Packet) Options() []byte { + if len(p) > 240 { + return p[240:] + } + return nil +} + +func (p Packet) Broadcast() bool { return p.Flags()[0] > 127 } + +func (p Packet) SetBroadcast(broadcast bool) { + if p.Broadcast() != broadcast { + p.Flags()[0] ^= 128 + } +} + +func (p Packet) SetOpCode(c OpCode) { p[0] = byte(c) } +func (p Packet) SetCHAddr(a net.HardwareAddr) { + copy(p[28:44], a) + p[2] = byte(len(a)) +} +func (p Packet) SetHType(hType byte) { p[1] = hType } +func (p Packet) SetCookie(cookie []byte) { copy(p.Cookie(), cookie) } +func (p Packet) SetHops(hops byte) { p[3] = hops } +func (p Packet) SetXId(xId []byte) { copy(p.XId(), xId) } +func (p Packet) SetSecs(secs []byte) { copy(p.Secs(), secs) } +func (p Packet) SetFlags(flags []byte) { copy(p.Flags(), flags) } +func (p Packet) SetCIAddr(ip net.IP) { copy(p.CIAddr(), ip.To4()) } +func (p Packet) SetYIAddr(ip net.IP) { copy(p.YIAddr(), ip.To4()) } +func (p Packet) SetSIAddr(ip net.IP) { copy(p.SIAddr(), ip.To4()) } +func (p Packet) SetGIAddr(ip net.IP) { copy(p.GIAddr(), ip.To4()) } + +// Parses the packet's options into an Options map +func (p Packet) ParseOptions() Options { + opts := p.Options() + options := make(Options, 10) + for len(opts) >= 2 && OptionCode(opts[0]) != End { + if OptionCode(opts[0]) == Pad { + opts = opts[1:] + continue + } + size := int(opts[1]) + if len(opts) < 2+size { + break + } + options[OptionCode(opts[0])] = opts[2 : 2+size] + opts = opts[2+size:] + } + return options +} + +func NewPacket(opCode OpCode) Packet { + p := make(Packet, 241) + p.SetOpCode(opCode) + p.SetHType(1) // Ethernet + p.SetCookie([]byte{99, 130, 83, 99}) + p[240] = byte(End) + return p +} + +// Appends a DHCP option to the end of a packet +func (p *Packet) AddOption(o OptionCode, value []byte) { + *p = append((*p)[:len(*p)-1], []byte{byte(o), byte(len(value))}...) // Strip off End, Add OptionCode and Length + *p = append(*p, value...) // Add Option Value + *p = append(*p, byte(End)) // Add on new End +} + +// Removes all options from packet. +func (p *Packet) StripOptions() { + *p = append((*p)[:240], byte(End)) +} + +// Creates a request packet that a Client would send to a server. +func RequestPacket(mt MessageType, chAddr net.HardwareAddr, cIAddr net.IP, xId []byte, broadcast bool, options []Option) Packet { + p := NewPacket(BootRequest) + p.SetCHAddr(chAddr) + p.SetXId(xId) + if cIAddr != nil { + p.SetCIAddr(cIAddr) + } + p.SetBroadcast(broadcast) + p.AddOption(OptionDHCPMessageType, []byte{byte(mt)}) + for _, o := range options { + p.AddOption(o.Code, o.Value) + } + p.PadToMinSize() + return p +} + +// ReplyPacket creates a reply packet that a Server would send to a client. +// It uses the req Packet param to copy across common/necessary fields to +// associate the reply the request. +func ReplyPacket(req Packet, mt MessageType, serverId, yIAddr net.IP, leaseDuration time.Duration, options []Option) Packet { + p := NewPacket(BootReply) + p.SetXId(req.XId()) + p.SetFlags(req.Flags()) + p.SetYIAddr(yIAddr) + p.SetGIAddr(req.GIAddr()) + p.SetCHAddr(req.CHAddr()) + p.SetSecs(req.Secs()) + p.AddOption(OptionDHCPMessageType, []byte{byte(mt)}) + p.AddOption(OptionServerIdentifier, []byte(serverId)) + p.AddOption(OptionIPAddressLeaseTime, OptionsLeaseTime(leaseDuration)) + for _, o := range options { + p.AddOption(o.Code, o.Value) + } + p.PadToMinSize() + return p +} + +// PadToMinSize pads a packet so that when sent over UDP, the entire packet, +// is 300 bytes (BOOTP min), to be compatible with really old devices. +var padder [272]byte + +func (p *Packet) PadToMinSize() { + if n := len(*p); n < 272 { + *p = append(*p, padder[:272-n]...) + } +} diff --git a/vendor/github.com/d2g/dhcp4client/LICENSE b/vendor/github.com/d2g/dhcp4client/LICENSE new file mode 100644 index 0000000000..c33dcc7c92 --- /dev/null +++ b/vendor/github.com/d2g/dhcp4client/LICENSE @@ -0,0 +1,354 @@ +Mozilla Public License, version 2.0 + +1. Definitions + +1.1. “Contributor” + + means each individual or legal entity that creates, contributes to the + creation of, or owns Covered Software. + +1.2. “Contributor Version” + + means the combination of the Contributions of others (if any) used by a + Contributor and that particular Contributor’s Contribution. + +1.3. “Contribution” + + means Covered Software of a particular Contributor. + +1.4. “Covered Software” + + means Source Code Form to which the initial Contributor has attached the + notice in Exhibit A, the Executable Form of such Source Code Form, and + Modifications of such Source Code Form, in each case including portions + thereof. + +1.5. “Incompatible With Secondary Licenses” + means + + a. that the initial Contributor has attached the notice described in + Exhibit B to the Covered Software; or + + b. that the Covered Software was made available under the terms of version + 1.1 or earlier of the License, but not also under the terms of a + Secondary License. + +1.6. “Executable Form” + + means any form of the work other than Source Code Form. + +1.7. “Larger Work” + + means a work that combines Covered Software with other material, in a separate + file or files, that is not Covered Software. + +1.8. “License” + + means this document. + +1.9. “Licensable” + + means having the right to grant, to the maximum extent possible, whether at the + time of the initial grant or subsequently, any and all of the rights conveyed by + this License. + +1.10. “Modifications” + + means any of the following: + + a. any file in Source Code Form that results from an addition to, deletion + from, or modification of the contents of Covered Software; or + + b. any new file in Source Code Form that contains any Covered Software. + +1.11. “Patent Claims” of a Contributor + + means any patent claim(s), including without limitation, method, process, + and apparatus claims, in any patent Licensable by such Contributor that + would be infringed, but for the grant of the License, by the making, + using, selling, offering for sale, having made, import, or transfer of + either its Contributions or its Contributor Version. + +1.12. “Secondary License” + + means either the GNU General Public License, Version 2.0, the GNU Lesser + General Public License, Version 2.1, the GNU Affero General Public + License, Version 3.0, or any later versions of those licenses. + +1.13. “Source Code Form” + + means the form of the work preferred for making modifications. + +1.14. “You” (or “Your”) + + means an individual or a legal entity exercising rights under this + License. For legal entities, “You” includes any entity that controls, is + controlled by, or is under common control with You. For purposes of this + definition, “control” means (a) the power, direct or indirect, to cause + the direction or management of such entity, whether by contract or + otherwise, or (b) ownership of more than fifty percent (50%) of the + outstanding shares or beneficial ownership of such entity. + + +2. License Grants and Conditions + +2.1. Grants + + Each Contributor hereby grants You a world-wide, royalty-free, + non-exclusive license: + + a. under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or as + part of a Larger Work; and + + b. under Patent Claims of such Contributor to make, use, sell, offer for + sale, have made, import, and otherwise transfer either its Contributions + or its Contributor Version. + +2.2. Effective Date + + The licenses granted in Section 2.1 with respect to any Contribution become + effective for each Contribution on the date the Contributor first distributes + such Contribution. + +2.3. Limitations on Grant Scope + + The licenses granted in this Section 2 are the only rights granted under this + License. No additional rights or licenses will be implied from the distribution + or licensing of Covered Software under this License. Notwithstanding Section + 2.1(b) above, no patent license is granted by a Contributor: + + a. for any code that a Contributor has removed from Covered Software; or + + b. for infringements caused by: (i) Your and any other third party’s + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + + c. under Patent Claims infringed by Covered Software in the absence of its + Contributions. + + This License does not grant any rights in the trademarks, service marks, or + logos of any Contributor (except as may be necessary to comply with the + notice requirements in Section 3.4). + +2.4. Subsequent Licenses + + No Contributor makes additional grants as a result of Your choice to + distribute the Covered Software under a subsequent version of this License + (see Section 10.2) or under the terms of a Secondary License (if permitted + under the terms of Section 3.3). + +2.5. Representation + + Each Contributor represents that the Contributor believes its Contributions + are its original creation(s) or it has sufficient rights to grant the + rights to its Contributions conveyed by this License. + +2.6. Fair Use + + This License is not intended to limit any rights You have under applicable + copyright doctrines of fair use, fair dealing, or other equivalents. + +2.7. Conditions + + Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in + Section 2.1. + + +3. Responsibilities + +3.1. Distribution of Source Form + + All distribution of Covered Software in Source Code Form, including any + Modifications that You create or to which You contribute, must be under the + terms of this License. You must inform recipients that the Source Code Form + of the Covered Software is governed by the terms of this License, and how + they can obtain a copy of this License. You may not attempt to alter or + restrict the recipients’ rights in the Source Code Form. + +3.2. Distribution of Executable Form + + If You distribute Covered Software in Executable Form then: + + a. such Covered Software must also be made available in Source Code Form, + as described in Section 3.1, and You must inform recipients of the + Executable Form how they can obtain a copy of such Source Code Form by + reasonable means in a timely manner, at a charge no more than the cost + of distribution to the recipient; and + + b. You may distribute such Executable Form under the terms of this License, + or sublicense it under different terms, provided that the license for + the Executable Form does not attempt to limit or alter the recipients’ + rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + + You may create and distribute a Larger Work under terms of Your choice, + provided that You also comply with the requirements of this License for the + Covered Software. If the Larger Work is a combination of Covered Software + with a work governed by one or more Secondary Licenses, and the Covered + Software is not Incompatible With Secondary Licenses, this License permits + You to additionally distribute such Covered Software under the terms of + such Secondary License(s), so that the recipient of the Larger Work may, at + their option, further distribute the Covered Software under the terms of + either this License or such Secondary License(s). + +3.4. Notices + + You may not remove or alter the substance of any license notices (including + copyright notices, patent notices, disclaimers of warranty, or limitations + of liability) contained within the Source Code Form of the Covered + Software, except that You may alter any license notices to the extent + required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + + You may choose to offer, and to charge a fee for, warranty, support, + indemnity or liability obligations to one or more recipients of Covered + Software. However, You may do so only on Your own behalf, and not on behalf + of any Contributor. You must make it absolutely clear that any such + warranty, support, indemnity, or liability obligation is offered by You + alone, and You hereby agree to indemnify every Contributor for any + liability incurred by such Contributor as a result of warranty, support, + indemnity or liability terms You offer. You may include additional + disclaimers of warranty and limitations of liability specific to any + jurisdiction. + +4. Inability to Comply Due to Statute or Regulation + + If it is impossible for You to comply with any of the terms of this License + with respect to some or all of the Covered Software due to statute, judicial + order, or regulation then You must: (a) comply with the terms of this License + to the maximum extent possible; and (b) describe the limitations and the code + they affect. Such description must be placed in a text file included with all + distributions of the Covered Software under this License. Except to the + extent prohibited by statute or regulation, such description must be + sufficiently detailed for a recipient of ordinary skill to be able to + understand it. + +5. Termination + +5.1. The rights granted under this License will terminate automatically if You + fail to comply with any of its terms. However, if You become compliant, + then the rights granted under this License from a particular Contributor + are reinstated (a) provisionally, unless and until such Contributor + explicitly and finally terminates Your grants, and (b) on an ongoing basis, + if such Contributor fails to notify You of the non-compliance by some + reasonable means prior to 60 days after You have come back into compliance. + Moreover, Your grants from a particular Contributor are reinstated on an + ongoing basis if such Contributor notifies You of the non-compliance by + some reasonable means, this is the first time You have received notice of + non-compliance with this License from such Contributor, and You become + compliant prior to 30 days after Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent + infringement claim (excluding declaratory judgment actions, counter-claims, + and cross-claims) alleging that a Contributor Version directly or + indirectly infringes any patent, then the rights granted to You by any and + all Contributors for the Covered Software under Section 2.1 of this License + shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user + license agreements (excluding distributors and resellers) which have been + validly granted by You or Your distributors under this License prior to + termination shall survive termination. + +6. Disclaimer of Warranty + + Covered Software is provided under this License on an “as is” basis, without + warranty of any kind, either expressed, implied, or statutory, including, + without limitation, warranties that the Covered Software is free of defects, + merchantable, fit for a particular purpose or non-infringing. The entire + risk as to the quality and performance of the Covered Software is with You. + Should any Covered Software prove defective in any respect, You (not any + Contributor) assume the cost of any necessary servicing, repair, or + correction. This disclaimer of warranty constitutes an essential part of this + License. No use of any Covered Software is authorized under this License + except under this disclaimer. + +7. Limitation of Liability + + Under no circumstances and under no legal theory, whether tort (including + negligence), contract, or otherwise, shall any Contributor, or anyone who + distributes Covered Software as permitted above, be liable to You for any + direct, indirect, special, incidental, or consequential damages of any + character including, without limitation, damages for lost profits, loss of + goodwill, work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses, even if such party shall have been + informed of the possibility of such damages. This limitation of liability + shall not apply to liability for death or personal injury resulting from such + party’s negligence to the extent applicable law prohibits such limitation. + Some jurisdictions do not allow the exclusion or limitation of incidental or + consequential damages, so this exclusion and limitation may not apply to You. + +8. Litigation + + Any litigation relating to this License may be brought only in the courts of + a jurisdiction where the defendant maintains its principal place of business + and such litigation shall be governed by laws of that jurisdiction, without + reference to its conflict-of-law provisions. Nothing in this Section shall + prevent a party’s ability to bring cross-claims or counter-claims. + +9. Miscellaneous + + This License represents the complete agreement concerning the subject matter + hereof. If any provision of this License is held to be unenforceable, such + provision shall be reformed only to the extent necessary to make it + enforceable. Any law or regulation which provides that the language of a + contract shall be construed against the drafter shall not be used to construe + this License against a Contributor. + + +10. Versions of the License + +10.1. New Versions + + Mozilla Foundation is the license steward. Except as provided in Section + 10.3, no one other than the license steward has the right to modify or + publish new versions of this License. Each version will be given a + distinguishing version number. + +10.2. Effect of New Versions + + You may distribute the Covered Software under the terms of the version of + the License under which You originally received the Covered Software, or + under the terms of any subsequent version published by the license + steward. + +10.3. Modified Versions + + If you create software not governed by this License, and you want to + create a new license for such software, you may create and use a modified + version of this License if you rename the license and remove any + references to the name of the license steward (except to note that such + modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses + If You choose to distribute Source Code Form that is Incompatible With + Secondary Licenses under the terms of this version of the License, the + notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice + + This Source Code Form is subject to the + terms of the Mozilla Public License, v. + 2.0. If a copy of the MPL was not + distributed with this file, You can + obtain one at + http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular file, then +You may include the notice in a location (such as a LICENSE file in a relevant +directory) where a recipient would be likely to look for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - “Incompatible With Secondary Licenses” Notice + + This Source Code Form is “Incompatible + With Secondary Licenses”, as defined by + the Mozilla Public License, v. 2.0. + diff --git a/vendor/github.com/d2g/dhcp4client/client.go b/vendor/github.com/d2g/dhcp4client/client.go new file mode 100644 index 0000000000..ab852c650e --- /dev/null +++ b/vendor/github.com/d2g/dhcp4client/client.go @@ -0,0 +1,366 @@ +package dhcp4client + +import ( + "bytes" + "crypto/rand" + "net" + "time" + + "github.com/d2g/dhcp4" +) + +const ( + MaxDHCPLen = 576 +) + +type Client struct { + hardwareAddr net.HardwareAddr //The HardwareAddr to send in the request. + ignoreServers []net.IP //List of Servers to Ignore requests from. + timeout time.Duration //Time before we timeout. + broadcast bool //Set the Bcast flag in BOOTP Flags + connection connection //The Connection Method to use +} + +/* + * Abstracts the type of underlying socket used + */ +type connection interface { + Close() error + Write(packet []byte) error + ReadFrom() ([]byte, net.IP, error) + SetReadTimeout(t time.Duration) error +} + +func New(options ...func(*Client) error) (*Client, error) { + c := Client{ + timeout: time.Second * 10, + broadcast: true, + } + + err := c.SetOption(options...) + if err != nil { + return nil, err + } + + //if connection hasn't been set as an option create the default. + if c.connection == nil { + conn, err := NewInetSock() + if err != nil { + return nil, err + } + c.connection = conn + } + + return &c, nil +} + +func (c *Client) SetOption(options ...func(*Client) error) error { + for _, opt := range options { + if err := opt(c); err != nil { + return err + } + } + return nil +} + +func Timeout(t time.Duration) func(*Client) error { + return func(c *Client) error { + c.timeout = t + return nil + } +} + +func IgnoreServers(s []net.IP) func(*Client) error { + return func(c *Client) error { + c.ignoreServers = s + return nil + } +} + +func HardwareAddr(h net.HardwareAddr) func(*Client) error { + return func(c *Client) error { + c.hardwareAddr = h + return nil + } +} + +func Broadcast(b bool) func(*Client) error { + return func(c *Client) error { + c.broadcast = b + return nil + } +} + +func Connection(conn connection) func(*Client) error { + return func(c *Client) error { + c.connection = conn + return nil + } +} + +/* + * Close Connections + */ +func (c *Client) Close() error { + if c.connection != nil { + return c.connection.Close() + } + return nil +} + +/* + * Send the Discovery Packet to the Broadcast Channel + */ +func (c *Client) SendDiscoverPacket() (dhcp4.Packet, error) { + discoveryPacket := c.DiscoverPacket() + discoveryPacket.PadToMinSize() + + return discoveryPacket, c.SendPacket(discoveryPacket) +} + +/* + * Retreive Offer... + * Wait for the offer for a specific Discovery Packet. + */ +func (c *Client) GetOffer(discoverPacket *dhcp4.Packet) (dhcp4.Packet, error) { + for { + c.connection.SetReadTimeout(c.timeout) + readBuffer, source, err := c.connection.ReadFrom() + if err != nil { + return dhcp4.Packet{}, err + } + + offerPacket := dhcp4.Packet(readBuffer) + offerPacketOptions := offerPacket.ParseOptions() + + // Ignore Servers in my Ignore list + for _, ignoreServer := range c.ignoreServers { + if source.Equal(ignoreServer) { + continue + } + + if offerPacket.SIAddr().Equal(ignoreServer) { + continue + } + } + + if len(offerPacketOptions[dhcp4.OptionDHCPMessageType]) < 1 || dhcp4.MessageType(offerPacketOptions[dhcp4.OptionDHCPMessageType][0]) != dhcp4.Offer || !bytes.Equal(discoverPacket.XId(), offerPacket.XId()) { + continue + } + + return offerPacket, nil + } + +} + +/* + * Send Request Based On the offer Received. + */ +func (c *Client) SendRequest(offerPacket *dhcp4.Packet) (dhcp4.Packet, error) { + requestPacket := c.RequestPacket(offerPacket) + requestPacket.PadToMinSize() + + return requestPacket, c.SendPacket(requestPacket) +} + +/* + * Retreive Acknowledgement + * Wait for the offer for a specific Request Packet. + */ +func (c *Client) GetAcknowledgement(requestPacket *dhcp4.Packet) (dhcp4.Packet, error) { + for { + c.connection.SetReadTimeout(c.timeout) + readBuffer, source, err := c.connection.ReadFrom() + if err != nil { + return dhcp4.Packet{}, err + } + + acknowledgementPacket := dhcp4.Packet(readBuffer) + acknowledgementPacketOptions := acknowledgementPacket.ParseOptions() + + // Ignore Servers in my Ignore list + for _, ignoreServer := range c.ignoreServers { + if source.Equal(ignoreServer) { + continue + } + + if acknowledgementPacket.SIAddr().Equal(ignoreServer) { + continue + } + } + + if !bytes.Equal(requestPacket.XId(), acknowledgementPacket.XId()) || len(acknowledgementPacketOptions[dhcp4.OptionDHCPMessageType]) < 1 || (dhcp4.MessageType(acknowledgementPacketOptions[dhcp4.OptionDHCPMessageType][0]) != dhcp4.ACK && dhcp4.MessageType(acknowledgementPacketOptions[dhcp4.OptionDHCPMessageType][0]) != dhcp4.NAK) { + continue + } + + return acknowledgementPacket, nil + } +} + +/* + * Send a DHCP Packet. + */ +func (c *Client) SendPacket(packet dhcp4.Packet) error { + return c.connection.Write(packet) +} + +/* + * Create Discover Packet + */ +func (c *Client) DiscoverPacket() dhcp4.Packet { + messageid := make([]byte, 4) + if _, err := rand.Read(messageid); err != nil { + panic(err) + } + + packet := dhcp4.NewPacket(dhcp4.BootRequest) + packet.SetCHAddr(c.hardwareAddr) + packet.SetXId(messageid) + packet.SetBroadcast(c.broadcast) + + packet.AddOption(dhcp4.OptionDHCPMessageType, []byte{byte(dhcp4.Discover)}) + //packet.PadToMinSize() + return packet +} + +/* + * Create Request Packet + */ +func (c *Client) RequestPacket(offerPacket *dhcp4.Packet) dhcp4.Packet { + offerOptions := offerPacket.ParseOptions() + + packet := dhcp4.NewPacket(dhcp4.BootRequest) + packet.SetCHAddr(c.hardwareAddr) + + packet.SetXId(offerPacket.XId()) + packet.SetCIAddr(offerPacket.CIAddr()) + packet.SetSIAddr(offerPacket.SIAddr()) + + packet.SetBroadcast(c.broadcast) + packet.AddOption(dhcp4.OptionDHCPMessageType, []byte{byte(dhcp4.Request)}) + packet.AddOption(dhcp4.OptionRequestedIPAddress, (offerPacket.YIAddr()).To4()) + packet.AddOption(dhcp4.OptionServerIdentifier, offerOptions[dhcp4.OptionServerIdentifier]) + + //packet.PadToMinSize() + return packet +} + +/* + * Create Request Packet For a Renew + */ +func (c *Client) RenewalRequestPacket(acknowledgement *dhcp4.Packet) dhcp4.Packet { + messageid := make([]byte, 4) + if _, err := rand.Read(messageid); err != nil { + panic(err) + } + + acknowledgementOptions := acknowledgement.ParseOptions() + + packet := dhcp4.NewPacket(dhcp4.BootRequest) + packet.SetCHAddr(acknowledgement.CHAddr()) + + packet.SetXId(messageid) + packet.SetCIAddr(acknowledgement.YIAddr()) + packet.SetSIAddr(acknowledgement.SIAddr()) + + packet.SetBroadcast(c.broadcast) + packet.AddOption(dhcp4.OptionDHCPMessageType, []byte{byte(dhcp4.Request)}) + packet.AddOption(dhcp4.OptionRequestedIPAddress, (acknowledgement.YIAddr()).To4()) + packet.AddOption(dhcp4.OptionServerIdentifier, acknowledgementOptions[dhcp4.OptionServerIdentifier]) + + //packet.PadToMinSize() + return packet +} + +/* + * Create Release Packet For a Release + */ +func (c *Client) ReleasePacket(acknowledgement *dhcp4.Packet) dhcp4.Packet { + messageid := make([]byte, 4) + if _, err := rand.Read(messageid); err != nil { + panic(err) + } + + acknowledgementOptions := acknowledgement.ParseOptions() + + packet := dhcp4.NewPacket(dhcp4.BootRequest) + packet.SetCHAddr(acknowledgement.CHAddr()) + + packet.SetXId(messageid) + packet.SetCIAddr(acknowledgement.YIAddr()) + + packet.AddOption(dhcp4.OptionDHCPMessageType, []byte{byte(dhcp4.Release)}) + packet.AddOption(dhcp4.OptionServerIdentifier, acknowledgementOptions[dhcp4.OptionServerIdentifier]) + + //packet.PadToMinSize() + return packet +} + +/* + * Lets do a Full DHCP Request. + */ +func (c *Client) Request() (bool, dhcp4.Packet, error) { + discoveryPacket, err := c.SendDiscoverPacket() + if err != nil { + return false, discoveryPacket, err + } + + offerPacket, err := c.GetOffer(&discoveryPacket) + if err != nil { + return false, offerPacket, err + } + + requestPacket, err := c.SendRequest(&offerPacket) + if err != nil { + return false, requestPacket, err + } + + acknowledgement, err := c.GetAcknowledgement(&requestPacket) + if err != nil { + return false, acknowledgement, err + } + + acknowledgementOptions := acknowledgement.ParseOptions() + if dhcp4.MessageType(acknowledgementOptions[dhcp4.OptionDHCPMessageType][0]) != dhcp4.ACK { + return false, acknowledgement, nil + } + + return true, acknowledgement, nil +} + +/* + * Renew a lease backed on the Acknowledgement Packet. + * Returns Sucessfull, The AcknoledgementPacket, Any Errors + */ +func (c *Client) Renew(acknowledgement dhcp4.Packet) (bool, dhcp4.Packet, error) { + renewRequest := c.RenewalRequestPacket(&acknowledgement) + renewRequest.PadToMinSize() + + err := c.SendPacket(renewRequest) + if err != nil { + return false, renewRequest, err + } + + newAcknowledgement, err := c.GetAcknowledgement(&renewRequest) + if err != nil { + return false, newAcknowledgement, err + } + + newAcknowledgementOptions := newAcknowledgement.ParseOptions() + if dhcp4.MessageType(newAcknowledgementOptions[dhcp4.OptionDHCPMessageType][0]) != dhcp4.ACK { + return false, newAcknowledgement, nil + } + + return true, newAcknowledgement, nil +} + +/* + * Release a lease backed on the Acknowledgement Packet. + * Returns Any Errors + */ +func (c *Client) Release(acknowledgement dhcp4.Packet) error { + release := c.ReleasePacket(&acknowledgement) + release.PadToMinSize() + + return c.SendPacket(release) +} diff --git a/vendor/github.com/d2g/dhcp4client/inetsock.go b/vendor/github.com/d2g/dhcp4client/inetsock.go new file mode 100644 index 0000000000..293f186538 --- /dev/null +++ b/vendor/github.com/d2g/dhcp4client/inetsock.go @@ -0,0 +1,75 @@ +package dhcp4client + +import ( + "net" + "time" +) + +type inetSock struct { + *net.UDPConn + + laddr net.UDPAddr + raddr net.UDPAddr +} + +func NewInetSock(options ...func(*inetSock) error) (*inetSock, error) { + c := &inetSock{ + laddr: net.UDPAddr{IP: net.IPv4(0, 0, 0, 0), Port: 68}, + raddr: net.UDPAddr{IP: net.IPv4bcast, Port: 67}, + } + + err := c.setOption(options...) + if err != nil { + return nil, err + } + + conn, err := net.ListenUDP("udp4", &c.laddr) + if err != nil { + return nil, err + } + + c.UDPConn = conn + return c, err +} + +func (c *inetSock) setOption(options ...func(*inetSock) error) error { + for _, opt := range options { + if err := opt(c); err != nil { + return err + } + } + return nil +} + +func SetLocalAddr(l net.UDPAddr) func(*inetSock) error { + return func(c *inetSock) error { + c.laddr = l + return nil + } +} + +func SetRemoteAddr(r net.UDPAddr) func(*inetSock) error { + return func(c *inetSock) error { + c.raddr = r + return nil + } +} + +func (c *inetSock) Write(packet []byte) error { + _, err := c.WriteToUDP(packet, &c.raddr) + return err +} + +func (c *inetSock) ReadFrom() ([]byte, net.IP, error) { + readBuffer := make([]byte, MaxDHCPLen) + n, source, err := c.ReadFromUDP(readBuffer) + if source != nil { + return readBuffer[:n], source.IP, err + } else { + return readBuffer[:n], net.IP{}, err + } +} + +func (c *inetSock) SetReadTimeout(t time.Duration) error { + return c.SetReadDeadline(time.Now().Add(t)) +} diff --git a/vendor/github.com/d2g/dhcp4client/init.go b/vendor/github.com/d2g/dhcp4client/init.go new file mode 100644 index 0000000000..67ae8a3a13 --- /dev/null +++ b/vendor/github.com/d2g/dhcp4client/init.go @@ -0,0 +1,10 @@ +package dhcp4client + +import ( + "math/rand" + "time" +) + +func init() { + rand.Seed(time.Now().Unix()) +} diff --git a/vendor/github.com/d2g/dhcp4client/pktsock_linux.go b/vendor/github.com/d2g/dhcp4client/pktsock_linux.go new file mode 100644 index 0000000000..a21c265fb4 --- /dev/null +++ b/vendor/github.com/d2g/dhcp4client/pktsock_linux.go @@ -0,0 +1,147 @@ +package dhcp4client + +import ( + "crypto/rand" + "encoding/binary" + "net" + "time" + + "golang.org/x/sys/unix" +) + +const ( + minIPHdrLen = 20 + maxIPHdrLen = 60 + udpHdrLen = 8 + ip4Ver = 0x40 + ttl = 16 + srcPort = 68 + dstPort = 67 +) + +var ( + bcastMAC = []byte{255, 255, 255, 255, 255, 255} +) + +// abstracts AF_PACKET +type packetSock struct { + fd int + ifindex int +} + +func NewPacketSock(ifindex int) (*packetSock, error) { + fd, err := unix.Socket(unix.AF_PACKET, unix.SOCK_DGRAM, int(swap16(unix.ETH_P_IP))) + if err != nil { + return nil, err + } + + addr := unix.SockaddrLinklayer{ + Ifindex: ifindex, + Protocol: swap16(unix.ETH_P_IP), + } + + if err = unix.Bind(fd, &addr); err != nil { + return nil, err + } + + return &packetSock{ + fd: fd, + ifindex: ifindex, + }, nil +} + +func (pc *packetSock) Close() error { + return unix.Close(pc.fd) +} + +func (pc *packetSock) Write(packet []byte) error { + lladdr := unix.SockaddrLinklayer{ + Ifindex: pc.ifindex, + Protocol: swap16(unix.ETH_P_IP), + Halen: uint8(len(bcastMAC)), + } + copy(lladdr.Addr[:], bcastMAC) + + pkt := make([]byte, minIPHdrLen+udpHdrLen+len(packet)) + + fillIPHdr(pkt[0:minIPHdrLen], udpHdrLen+uint16(len(packet))) + fillUDPHdr(pkt[minIPHdrLen:minIPHdrLen+udpHdrLen], uint16(len(packet))) + + // payload + copy(pkt[minIPHdrLen+udpHdrLen:len(pkt)], packet) + + return unix.Sendto(pc.fd, pkt, 0, &lladdr) +} + +func (pc *packetSock) ReadFrom() ([]byte, net.IP, error) { + pkt := make([]byte, maxIPHdrLen+udpHdrLen+MaxDHCPLen) + n, _, err := unix.Recvfrom(pc.fd, pkt, 0) + if err != nil { + return nil, nil, err + } + + // IP hdr len + ihl := int(pkt[0]&0x0F) * 4 + // Source IP address + src := net.IP(pkt[12:16]) + + return pkt[ihl+udpHdrLen : n], src, nil +} + +func (pc *packetSock) SetReadTimeout(t time.Duration) error { + + tv := unix.NsecToTimeval(t.Nanoseconds()) + return unix.SetsockoptTimeval(pc.fd, unix.SOL_SOCKET, unix.SO_RCVTIMEO, &tv) +} + +// compute's 1's complement checksum +func chksum(p []byte, csum []byte) { + cklen := len(p) + s := uint32(0) + for i := 0; i < (cklen - 1); i += 2 { + s += uint32(p[i+1])<<8 | uint32(p[i]) + } + if cklen&1 == 1 { + s += uint32(p[cklen-1]) + } + s = (s >> 16) + (s & 0xffff) + s = s + (s >> 16) + s = ^s + + csum[0] = uint8(s & 0xff) + csum[1] = uint8(s >> 8) +} + +func fillIPHdr(hdr []byte, payloadLen uint16) { + // version + IHL + hdr[0] = ip4Ver | (minIPHdrLen / 4) + // total length + binary.BigEndian.PutUint16(hdr[2:4], uint16(len(hdr))+payloadLen) + // identification + if _, err := rand.Read(hdr[4:5]); err != nil { + panic(err) + } + // TTL + hdr[8] = 16 + // Protocol + hdr[9] = unix.IPPROTO_UDP + // dst IP + copy(hdr[16:20], net.IPv4bcast.To4()) + // compute IP hdr checksum + chksum(hdr[0:len(hdr)], hdr[10:12]) +} + +func fillUDPHdr(hdr []byte, payloadLen uint16) { + // src port + binary.BigEndian.PutUint16(hdr[0:2], srcPort) + // dest port + binary.BigEndian.PutUint16(hdr[2:4], dstPort) + // length + binary.BigEndian.PutUint16(hdr[4:6], udpHdrLen+payloadLen) +} + +func swap16(x uint16) uint16 { + var b [2]byte + binary.BigEndian.PutUint16(b[:], x) + return binary.LittleEndian.Uint16(b[:]) +} diff --git a/vendor/github.com/docker/distribution/LICENSE b/vendor/github.com/docker/distribution/LICENSE new file mode 100644 index 0000000000..e06d208186 --- /dev/null +++ b/vendor/github.com/docker/distribution/LICENSE @@ -0,0 +1,202 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor 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, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/vendor/github.com/docker/distribution/blobs.go b/vendor/github.com/docker/distribution/blobs.go new file mode 100644 index 0000000000..ce43ea2ef6 --- /dev/null +++ b/vendor/github.com/docker/distribution/blobs.go @@ -0,0 +1,233 @@ +package distribution + +import ( + "errors" + "fmt" + "io" + "net/http" + "time" + + "github.com/docker/distribution/context" + "github.com/docker/distribution/digest" + "github.com/docker/distribution/reference" +) + +var ( + // ErrBlobExists returned when blob already exists + ErrBlobExists = errors.New("blob exists") + + // ErrBlobDigestUnsupported when blob digest is an unsupported version. + ErrBlobDigestUnsupported = errors.New("unsupported blob digest") + + // ErrBlobUnknown when blob is not found. + ErrBlobUnknown = errors.New("unknown blob") + + // ErrBlobUploadUnknown returned when upload is not found. + ErrBlobUploadUnknown = errors.New("blob upload unknown") + + // ErrBlobInvalidLength returned when the blob has an expected length on + // commit, meaning mismatched with the descriptor or an invalid value. + ErrBlobInvalidLength = errors.New("blob invalid length") +) + +// ErrBlobInvalidDigest returned when digest check fails. +type ErrBlobInvalidDigest struct { + Digest digest.Digest + Reason error +} + +func (err ErrBlobInvalidDigest) Error() string { + return fmt.Sprintf("invalid digest for referenced layer: %v, %v", + err.Digest, err.Reason) +} + +// ErrBlobMounted returned when a blob is mounted from another repository +// instead of initiating an upload session. +type ErrBlobMounted struct { + From reference.Canonical + Descriptor Descriptor +} + +func (err ErrBlobMounted) Error() string { + return fmt.Sprintf("blob mounted from: %v to: %v", + err.From, err.Descriptor) +} + +// Descriptor describes targeted content. Used in conjunction with a blob +// store, a descriptor can be used to fetch, store and target any kind of +// blob. The struct also describes the wire protocol format. Fields should +// only be added but never changed. +type Descriptor struct { + // MediaType describe the type of the content. All text based formats are + // encoded as utf-8. + MediaType string `json:"mediaType,omitempty"` + + // Size in bytes of content. + Size int64 `json:"size,omitempty"` + + // Digest uniquely identifies the content. A byte stream can be verified + // against against this digest. + Digest digest.Digest `json:"digest,omitempty"` + + // NOTE: Before adding a field here, please ensure that all + // other options have been exhausted. Much of the type relationships + // depend on the simplicity of this type. +} + +// Descriptor returns the descriptor, to make it satisfy the Describable +// interface. Note that implementations of Describable are generally objects +// which can be described, not simply descriptors; this exception is in place +// to make it more convenient to pass actual descriptors to functions that +// expect Describable objects. +func (d Descriptor) Descriptor() Descriptor { + return d +} + +// BlobStatter makes blob descriptors available by digest. The service may +// provide a descriptor of a different digest if the provided digest is not +// canonical. +type BlobStatter interface { + // Stat provides metadata about a blob identified by the digest. If the + // blob is unknown to the describer, ErrBlobUnknown will be returned. + Stat(ctx context.Context, dgst digest.Digest) (Descriptor, error) +} + +// BlobDeleter enables deleting blobs from storage. +type BlobDeleter interface { + Delete(ctx context.Context, dgst digest.Digest) error +} + +// BlobDescriptorService manages metadata about a blob by digest. Most +// implementations will not expose such an interface explicitly. Such mappings +// should be maintained by interacting with the BlobIngester. Hence, this is +// left off of BlobService and BlobStore. +type BlobDescriptorService interface { + BlobStatter + + // SetDescriptor assigns the descriptor to the digest. The provided digest and + // the digest in the descriptor must map to identical content but they may + // differ on their algorithm. The descriptor must have the canonical + // digest of the content and the digest algorithm must match the + // annotators canonical algorithm. + // + // Such a facility can be used to map blobs between digest domains, with + // the restriction that the algorithm of the descriptor must match the + // canonical algorithm (ie sha256) of the annotator. + SetDescriptor(ctx context.Context, dgst digest.Digest, desc Descriptor) error + + // Clear enables descriptors to be unlinked + Clear(ctx context.Context, dgst digest.Digest) error +} + +// ReadSeekCloser is the primary reader type for blob data, combining +// io.ReadSeeker with io.Closer. +type ReadSeekCloser interface { + io.ReadSeeker + io.Closer +} + +// BlobProvider describes operations for getting blob data. +type BlobProvider interface { + // Get returns the entire blob identified by digest along with the descriptor. + Get(ctx context.Context, dgst digest.Digest) ([]byte, error) + + // Open provides a ReadSeekCloser to the blob identified by the provided + // descriptor. If the blob is not known to the service, an error will be + // returned. + Open(ctx context.Context, dgst digest.Digest) (ReadSeekCloser, error) +} + +// BlobServer can serve blobs via http. +type BlobServer interface { + // ServeBlob attempts to serve the blob, identifed by dgst, via http. The + // service may decide to redirect the client elsewhere or serve the data + // directly. + // + // This handler only issues successful responses, such as 2xx or 3xx, + // meaning it serves data or issues a redirect. If the blob is not + // available, an error will be returned and the caller may still issue a + // response. + // + // The implementation may serve the same blob from a different digest + // domain. The appropriate headers will be set for the blob, unless they + // have already been set by the caller. + ServeBlob(ctx context.Context, w http.ResponseWriter, r *http.Request, dgst digest.Digest) error +} + +// BlobIngester ingests blob data. +type BlobIngester interface { + // Put inserts the content p into the blob service, returning a descriptor + // or an error. + Put(ctx context.Context, mediaType string, p []byte) (Descriptor, error) + + // Create allocates a new blob writer to add a blob to this service. The + // returned handle can be written to and later resumed using an opaque + // identifier. With this approach, one can Close and Resume a BlobWriter + // multiple times until the BlobWriter is committed or cancelled. + Create(ctx context.Context, options ...BlobCreateOption) (BlobWriter, error) + + // Resume attempts to resume a write to a blob, identified by an id. + Resume(ctx context.Context, id string) (BlobWriter, error) +} + +// BlobCreateOption is a general extensible function argument for blob creation +// methods. A BlobIngester may choose to honor any or none of the given +// BlobCreateOptions, which can be specific to the implementation of the +// BlobIngester receiving them. +// TODO (brianbland): unify this with ManifestServiceOption in the future +type BlobCreateOption interface { + Apply(interface{}) error +} + +// BlobWriter provides a handle for inserting data into a blob store. +// Instances should be obtained from BlobWriteService.Writer and +// BlobWriteService.Resume. If supported by the store, a writer can be +// recovered with the id. +type BlobWriter interface { + io.WriteSeeker + io.ReaderFrom + io.Closer + + // ID returns the identifier for this writer. The ID can be used with the + // Blob service to later resume the write. + ID() string + + // StartedAt returns the time this blob write was started. + StartedAt() time.Time + + // Commit completes the blob writer process. The content is verified + // against the provided provisional descriptor, which may result in an + // error. Depending on the implementation, written data may be validated + // against the provisional descriptor fields. If MediaType is not present, + // the implementation may reject the commit or assign "application/octet- + // stream" to the blob. The returned descriptor may have a different + // digest depending on the blob store, referred to as the canonical + // descriptor. + Commit(ctx context.Context, provisional Descriptor) (canonical Descriptor, err error) + + // Cancel ends the blob write without storing any data and frees any + // associated resources. Any data written thus far will be lost. Cancel + // implementations should allow multiple calls even after a commit that + // result in a no-op. This allows use of Cancel in a defer statement, + // increasing the assurance that it is correctly called. + Cancel(ctx context.Context) error + + // Get a reader to the blob being written by this BlobWriter + Reader() (io.ReadCloser, error) +} + +// BlobService combines the operations to access, read and write blobs. This +// can be used to describe remote blob services. +type BlobService interface { + BlobStatter + BlobProvider + BlobIngester +} + +// BlobStore represent the entire suite of blob related operations. Such an +// implementation can access, read, write, delete and serve blobs. +type BlobStore interface { + BlobService + BlobServer + BlobDeleter +} diff --git a/vendor/github.com/docker/distribution/digest/digest.go b/vendor/github.com/docker/distribution/digest/digest.go new file mode 100644 index 0000000000..31d821bba7 --- /dev/null +++ b/vendor/github.com/docker/distribution/digest/digest.go @@ -0,0 +1,139 @@ +package digest + +import ( + "fmt" + "hash" + "io" + "regexp" + "strings" +) + +const ( + // DigestSha256EmptyTar is the canonical sha256 digest of empty data + DigestSha256EmptyTar = "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" +) + +// Digest allows simple protection of hex formatted digest strings, prefixed +// by their algorithm. Strings of type Digest have some guarantee of being in +// the correct format and it provides quick access to the components of a +// digest string. +// +// The following is an example of the contents of Digest types: +// +// sha256:7173b809ca12ec5dee4506cd86be934c4596dd234ee82c0662eac04a8c2c71dc +// +// This allows to abstract the digest behind this type and work only in those +// terms. +type Digest string + +// NewDigest returns a Digest from alg and a hash.Hash object. +func NewDigest(alg Algorithm, h hash.Hash) Digest { + return NewDigestFromBytes(alg, h.Sum(nil)) +} + +// NewDigestFromBytes returns a new digest from the byte contents of p. +// Typically, this can come from hash.Hash.Sum(...) or xxx.SumXXX(...) +// functions. This is also useful for rebuilding digests from binary +// serializations. +func NewDigestFromBytes(alg Algorithm, p []byte) Digest { + return Digest(fmt.Sprintf("%s:%x", alg, p)) +} + +// NewDigestFromHex returns a Digest from alg and a the hex encoded digest. +func NewDigestFromHex(alg, hex string) Digest { + return Digest(fmt.Sprintf("%s:%s", alg, hex)) +} + +// DigestRegexp matches valid digest types. +var DigestRegexp = regexp.MustCompile(`[a-zA-Z0-9-_+.]+:[a-fA-F0-9]+`) + +// DigestRegexpAnchored matches valid digest types, anchored to the start and end of the match. +var DigestRegexpAnchored = regexp.MustCompile(`^` + DigestRegexp.String() + `$`) + +var ( + // ErrDigestInvalidFormat returned when digest format invalid. + ErrDigestInvalidFormat = fmt.Errorf("invalid checksum digest format") + + // ErrDigestInvalidLength returned when digest has invalid length. + ErrDigestInvalidLength = fmt.Errorf("invalid checksum digest length") + + // ErrDigestUnsupported returned when the digest algorithm is unsupported. + ErrDigestUnsupported = fmt.Errorf("unsupported digest algorithm") +) + +// ParseDigest parses s and returns the validated digest object. An error will +// be returned if the format is invalid. +func ParseDigest(s string) (Digest, error) { + d := Digest(s) + + return d, d.Validate() +} + +// FromReader returns the most valid digest for the underlying content using +// the canonical digest algorithm. +func FromReader(rd io.Reader) (Digest, error) { + return Canonical.FromReader(rd) +} + +// FromBytes digests the input and returns a Digest. +func FromBytes(p []byte) Digest { + return Canonical.FromBytes(p) +} + +// Validate checks that the contents of d is a valid digest, returning an +// error if not. +func (d Digest) Validate() error { + s := string(d) + + if !DigestRegexpAnchored.MatchString(s) { + return ErrDigestInvalidFormat + } + + i := strings.Index(s, ":") + if i < 0 { + return ErrDigestInvalidFormat + } + + // case: "sha256:" with no hex. + if i+1 == len(s) { + return ErrDigestInvalidFormat + } + + switch algorithm := Algorithm(s[:i]); algorithm { + case SHA256, SHA384, SHA512: + if algorithm.Size()*2 != len(s[i+1:]) { + return ErrDigestInvalidLength + } + break + default: + return ErrDigestUnsupported + } + + return nil +} + +// Algorithm returns the algorithm portion of the digest. This will panic if +// the underlying digest is not in a valid format. +func (d Digest) Algorithm() Algorithm { + return Algorithm(d[:d.sepIndex()]) +} + +// Hex returns the hex digest portion of the digest. This will panic if the +// underlying digest is not in a valid format. +func (d Digest) Hex() string { + return string(d[d.sepIndex()+1:]) +} + +func (d Digest) String() string { + return string(d) +} + +func (d Digest) sepIndex() int { + i := strings.Index(string(d), ":") + + if i < 0 { + panic("could not find ':' in digest: " + d) + } + + return i +} diff --git a/vendor/github.com/docker/distribution/digest/digester.go b/vendor/github.com/docker/distribution/digest/digester.go new file mode 100644 index 0000000000..f3105a45b6 --- /dev/null +++ b/vendor/github.com/docker/distribution/digest/digester.go @@ -0,0 +1,155 @@ +package digest + +import ( + "crypto" + "fmt" + "hash" + "io" +) + +// Algorithm identifies and implementation of a digester by an identifier. +// Note the that this defines both the hash algorithm used and the string +// encoding. +type Algorithm string + +// supported digest types +const ( + SHA256 Algorithm = "sha256" // sha256 with hex encoding + SHA384 Algorithm = "sha384" // sha384 with hex encoding + SHA512 Algorithm = "sha512" // sha512 with hex encoding + + // Canonical is the primary digest algorithm used with the distribution + // project. Other digests may be used but this one is the primary storage + // digest. + Canonical = SHA256 +) + +var ( + // TODO(stevvooe): Follow the pattern of the standard crypto package for + // registration of digests. Effectively, we are a registerable set and + // common symbol access. + + // algorithms maps values to hash.Hash implementations. Other algorithms + // may be available but they cannot be calculated by the digest package. + algorithms = map[Algorithm]crypto.Hash{ + SHA256: crypto.SHA256, + SHA384: crypto.SHA384, + SHA512: crypto.SHA512, + } +) + +// Available returns true if the digest type is available for use. If this +// returns false, New and Hash will return nil. +func (a Algorithm) Available() bool { + h, ok := algorithms[a] + if !ok { + return false + } + + // check availability of the hash, as well + return h.Available() +} + +func (a Algorithm) String() string { + return string(a) +} + +// Size returns number of bytes returned by the hash. +func (a Algorithm) Size() int { + h, ok := algorithms[a] + if !ok { + return 0 + } + return h.Size() +} + +// Set implemented to allow use of Algorithm as a command line flag. +func (a *Algorithm) Set(value string) error { + if value == "" { + *a = Canonical + } else { + // just do a type conversion, support is queried with Available. + *a = Algorithm(value) + } + + return nil +} + +// New returns a new digester for the specified algorithm. If the algorithm +// does not have a digester implementation, nil will be returned. This can be +// checked by calling Available before calling New. +func (a Algorithm) New() Digester { + return &digester{ + alg: a, + hash: a.Hash(), + } +} + +// Hash returns a new hash as used by the algorithm. If not available, the +// method will panic. Check Algorithm.Available() before calling. +func (a Algorithm) Hash() hash.Hash { + if !a.Available() { + // NOTE(stevvooe): A missing hash is usually a programming error that + // must be resolved at compile time. We don't import in the digest + // package to allow users to choose their hash implementation (such as + // when using stevvooe/resumable or a hardware accelerated package). + // + // Applications that may want to resolve the hash at runtime should + // call Algorithm.Available before call Algorithm.Hash(). + panic(fmt.Sprintf("%v not available (make sure it is imported)", a)) + } + + return algorithms[a].New() +} + +// FromReader returns the digest of the reader using the algorithm. +func (a Algorithm) FromReader(rd io.Reader) (Digest, error) { + digester := a.New() + + if _, err := io.Copy(digester.Hash(), rd); err != nil { + return "", err + } + + return digester.Digest(), nil +} + +// FromBytes digests the input and returns a Digest. +func (a Algorithm) FromBytes(p []byte) Digest { + digester := a.New() + + if _, err := digester.Hash().Write(p); err != nil { + // Writes to a Hash should never fail. None of the existing + // hash implementations in the stdlib or hashes vendored + // here can return errors from Write. Having a panic in this + // condition instead of having FromBytes return an error value + // avoids unnecessary error handling paths in all callers. + panic("write to hash function returned error: " + err.Error()) + } + + return digester.Digest() +} + +// TODO(stevvooe): Allow resolution of verifiers using the digest type and +// this registration system. + +// Digester calculates the digest of written data. Writes should go directly +// to the return value of Hash, while calling Digest will return the current +// value of the digest. +type Digester interface { + Hash() hash.Hash // provides direct access to underlying hash instance. + Digest() Digest +} + +// digester provides a simple digester definition that embeds a hasher. +type digester struct { + alg Algorithm + hash hash.Hash +} + +func (d *digester) Hash() hash.Hash { + return d.hash +} + +func (d *digester) Digest() Digest { + return NewDigest(d.alg, d.hash) +} diff --git a/vendor/github.com/docker/distribution/digest/doc.go b/vendor/github.com/docker/distribution/digest/doc.go new file mode 100644 index 0000000000..f64b0db32b --- /dev/null +++ b/vendor/github.com/docker/distribution/digest/doc.go @@ -0,0 +1,42 @@ +// Package digest provides a generalized type to opaquely represent message +// digests and their operations within the registry. The Digest type is +// designed to serve as a flexible identifier in a content-addressable system. +// More importantly, it provides tools and wrappers to work with +// hash.Hash-based digests with little effort. +// +// Basics +// +// The format of a digest is simply a string with two parts, dubbed the +// "algorithm" and the "digest", separated by a colon: +// +// : +// +// An example of a sha256 digest representation follows: +// +// sha256:7173b809ca12ec5dee4506cd86be934c4596dd234ee82c0662eac04a8c2c71dc +// +// In this case, the string "sha256" is the algorithm and the hex bytes are +// the "digest". +// +// Because the Digest type is simply a string, once a valid Digest is +// obtained, comparisons are cheap, quick and simple to express with the +// standard equality operator. +// +// Verification +// +// The main benefit of using the Digest type is simple verification against a +// given digest. The Verifier interface, modeled after the stdlib hash.Hash +// interface, provides a common write sink for digest verification. After +// writing is complete, calling the Verifier.Verified method will indicate +// whether or not the stream of bytes matches the target digest. +// +// Missing Features +// +// In addition to the above, we intend to add the following features to this +// package: +// +// 1. A Digester type that supports write sink digest calculation. +// +// 2. Suspend and resume of ongoing digest calculations to support efficient digest verification in the registry. +// +package digest diff --git a/vendor/github.com/docker/distribution/digest/set.go b/vendor/github.com/docker/distribution/digest/set.go new file mode 100644 index 0000000000..3fac41b40f --- /dev/null +++ b/vendor/github.com/docker/distribution/digest/set.go @@ -0,0 +1,245 @@ +package digest + +import ( + "errors" + "sort" + "strings" + "sync" +) + +var ( + // ErrDigestNotFound is used when a matching digest + // could not be found in a set. + ErrDigestNotFound = errors.New("digest not found") + + // ErrDigestAmbiguous is used when multiple digests + // are found in a set. None of the matching digests + // should be considered valid matches. + ErrDigestAmbiguous = errors.New("ambiguous digest string") +) + +// Set is used to hold a unique set of digests which +// may be easily referenced by easily referenced by a string +// representation of the digest as well as short representation. +// The uniqueness of the short representation is based on other +// digests in the set. If digests are ommited from this set, +// collisions in a larger set may not be detected, therefore it +// is important to always do short representation lookups on +// the complete set of digests. To mitigate collisions, an +// appropriately long short code should be used. +type Set struct { + mutex sync.RWMutex + entries digestEntries +} + +// NewSet creates an empty set of digests +// which may have digests added. +func NewSet() *Set { + return &Set{ + entries: digestEntries{}, + } +} + +// checkShortMatch checks whether two digests match as either whole +// values or short values. This function does not test equality, +// rather whether the second value could match against the first +// value. +func checkShortMatch(alg Algorithm, hex, shortAlg, shortHex string) bool { + if len(hex) == len(shortHex) { + if hex != shortHex { + return false + } + if len(shortAlg) > 0 && string(alg) != shortAlg { + return false + } + } else if !strings.HasPrefix(hex, shortHex) { + return false + } else if len(shortAlg) > 0 && string(alg) != shortAlg { + return false + } + return true +} + +// Lookup looks for a digest matching the given string representation. +// If no digests could be found ErrDigestNotFound will be returned +// with an empty digest value. If multiple matches are found +// ErrDigestAmbiguous will be returned with an empty digest value. +func (dst *Set) Lookup(d string) (Digest, error) { + dst.mutex.RLock() + defer dst.mutex.RUnlock() + if len(dst.entries) == 0 { + return "", ErrDigestNotFound + } + var ( + searchFunc func(int) bool + alg Algorithm + hex string + ) + dgst, err := ParseDigest(d) + if err == ErrDigestInvalidFormat { + hex = d + searchFunc = func(i int) bool { + return dst.entries[i].val >= d + } + } else { + hex = dgst.Hex() + alg = dgst.Algorithm() + searchFunc = func(i int) bool { + if dst.entries[i].val == hex { + return dst.entries[i].alg >= alg + } + return dst.entries[i].val >= hex + } + } + idx := sort.Search(len(dst.entries), searchFunc) + if idx == len(dst.entries) || !checkShortMatch(dst.entries[idx].alg, dst.entries[idx].val, string(alg), hex) { + return "", ErrDigestNotFound + } + if dst.entries[idx].alg == alg && dst.entries[idx].val == hex { + return dst.entries[idx].digest, nil + } + if idx+1 < len(dst.entries) && checkShortMatch(dst.entries[idx+1].alg, dst.entries[idx+1].val, string(alg), hex) { + return "", ErrDigestAmbiguous + } + + return dst.entries[idx].digest, nil +} + +// Add adds the given digest to the set. An error will be returned +// if the given digest is invalid. If the digest already exists in the +// set, this operation will be a no-op. +func (dst *Set) Add(d Digest) error { + if err := d.Validate(); err != nil { + return err + } + dst.mutex.Lock() + defer dst.mutex.Unlock() + entry := &digestEntry{alg: d.Algorithm(), val: d.Hex(), digest: d} + searchFunc := func(i int) bool { + if dst.entries[i].val == entry.val { + return dst.entries[i].alg >= entry.alg + } + return dst.entries[i].val >= entry.val + } + idx := sort.Search(len(dst.entries), searchFunc) + if idx == len(dst.entries) { + dst.entries = append(dst.entries, entry) + return nil + } else if dst.entries[idx].digest == d { + return nil + } + + entries := append(dst.entries, nil) + copy(entries[idx+1:], entries[idx:len(entries)-1]) + entries[idx] = entry + dst.entries = entries + return nil +} + +// Remove removes the given digest from the set. An err will be +// returned if the given digest is invalid. If the digest does +// not exist in the set, this operation will be a no-op. +func (dst *Set) Remove(d Digest) error { + if err := d.Validate(); err != nil { + return err + } + dst.mutex.Lock() + defer dst.mutex.Unlock() + entry := &digestEntry{alg: d.Algorithm(), val: d.Hex(), digest: d} + searchFunc := func(i int) bool { + if dst.entries[i].val == entry.val { + return dst.entries[i].alg >= entry.alg + } + return dst.entries[i].val >= entry.val + } + idx := sort.Search(len(dst.entries), searchFunc) + // Not found if idx is after or value at idx is not digest + if idx == len(dst.entries) || dst.entries[idx].digest != d { + return nil + } + + entries := dst.entries + copy(entries[idx:], entries[idx+1:]) + entries = entries[:len(entries)-1] + dst.entries = entries + + return nil +} + +// All returns all the digests in the set +func (dst *Set) All() []Digest { + dst.mutex.RLock() + defer dst.mutex.RUnlock() + retValues := make([]Digest, len(dst.entries)) + for i := range dst.entries { + retValues[i] = dst.entries[i].digest + } + + return retValues +} + +// ShortCodeTable returns a map of Digest to unique short codes. The +// length represents the minimum value, the maximum length may be the +// entire value of digest if uniqueness cannot be achieved without the +// full value. This function will attempt to make short codes as short +// as possible to be unique. +func ShortCodeTable(dst *Set, length int) map[Digest]string { + dst.mutex.RLock() + defer dst.mutex.RUnlock() + m := make(map[Digest]string, len(dst.entries)) + l := length + resetIdx := 0 + for i := 0; i < len(dst.entries); i++ { + var short string + extended := true + for extended { + extended = false + if len(dst.entries[i].val) <= l { + short = dst.entries[i].digest.String() + } else { + short = dst.entries[i].val[:l] + for j := i + 1; j < len(dst.entries); j++ { + if checkShortMatch(dst.entries[j].alg, dst.entries[j].val, "", short) { + if j > resetIdx { + resetIdx = j + } + extended = true + } else { + break + } + } + if extended { + l++ + } + } + } + m[dst.entries[i].digest] = short + if i >= resetIdx { + l = length + } + } + return m +} + +type digestEntry struct { + alg Algorithm + val string + digest Digest +} + +type digestEntries []*digestEntry + +func (d digestEntries) Len() int { + return len(d) +} + +func (d digestEntries) Less(i, j int) bool { + if d[i].val != d[j].val { + return d[i].val < d[j].val + } + return d[i].alg < d[j].alg +} + +func (d digestEntries) Swap(i, j int) { + d[i], d[j] = d[j], d[i] +} diff --git a/vendor/github.com/docker/distribution/digest/verifiers.go b/vendor/github.com/docker/distribution/digest/verifiers.go new file mode 100644 index 0000000000..9af3be1341 --- /dev/null +++ b/vendor/github.com/docker/distribution/digest/verifiers.go @@ -0,0 +1,44 @@ +package digest + +import ( + "hash" + "io" +) + +// Verifier presents a general verification interface to be used with message +// digests and other byte stream verifications. Users instantiate a Verifier +// from one of the various methods, write the data under test to it then check +// the result with the Verified method. +type Verifier interface { + io.Writer + + // Verified will return true if the content written to Verifier matches + // the digest. + Verified() bool +} + +// NewDigestVerifier returns a verifier that compares the written bytes +// against a passed in digest. +func NewDigestVerifier(d Digest) (Verifier, error) { + if err := d.Validate(); err != nil { + return nil, err + } + + return hashVerifier{ + hash: d.Algorithm().Hash(), + digest: d, + }, nil +} + +type hashVerifier struct { + digest Digest + hash hash.Hash +} + +func (hv hashVerifier) Write(p []byte) (n int, err error) { + return hv.hash.Write(p) +} + +func (hv hashVerifier) Verified() bool { + return hv.digest == NewDigest(hv.digest.Algorithm(), hv.hash) +} diff --git a/vendor/github.com/docker/distribution/doc.go b/vendor/github.com/docker/distribution/doc.go new file mode 100644 index 0000000000..bdd8cb708e --- /dev/null +++ b/vendor/github.com/docker/distribution/doc.go @@ -0,0 +1,7 @@ +// Package distribution will define the interfaces for the components of +// docker distribution. The goal is to allow users to reliably package, ship +// and store content related to docker images. +// +// This is currently a work in progress. More details are available in the +// README.md. +package distribution diff --git a/vendor/github.com/docker/distribution/errors.go b/vendor/github.com/docker/distribution/errors.go new file mode 100644 index 0000000000..77bd096ec8 --- /dev/null +++ b/vendor/github.com/docker/distribution/errors.go @@ -0,0 +1,111 @@ +package distribution + +import ( + "errors" + "fmt" + "strings" + + "github.com/docker/distribution/digest" +) + +// ErrManifestNotModified is returned when a conditional manifest GetByTag +// returns nil due to the client indicating it has the latest version +var ErrManifestNotModified = errors.New("manifest not modified") + +// ErrUnsupported is returned when an unimplemented or unsupported action is +// performed +var ErrUnsupported = errors.New("operation unsupported") + +// ErrTagUnknown is returned if the given tag is not known by the tag service +type ErrTagUnknown struct { + Tag string +} + +func (err ErrTagUnknown) Error() string { + return fmt.Sprintf("unknown tag=%s", err.Tag) +} + +// ErrRepositoryUnknown is returned if the named repository is not known by +// the registry. +type ErrRepositoryUnknown struct { + Name string +} + +func (err ErrRepositoryUnknown) Error() string { + return fmt.Sprintf("unknown repository name=%s", err.Name) +} + +// ErrRepositoryNameInvalid should be used to denote an invalid repository +// name. Reason may set, indicating the cause of invalidity. +type ErrRepositoryNameInvalid struct { + Name string + Reason error +} + +func (err ErrRepositoryNameInvalid) Error() string { + return fmt.Sprintf("repository name %q invalid: %v", err.Name, err.Reason) +} + +// ErrManifestUnknown is returned if the manifest is not known by the +// registry. +type ErrManifestUnknown struct { + Name string + Tag string +} + +func (err ErrManifestUnknown) Error() string { + return fmt.Sprintf("unknown manifest name=%s tag=%s", err.Name, err.Tag) +} + +// ErrManifestUnknownRevision is returned when a manifest cannot be found by +// revision within a repository. +type ErrManifestUnknownRevision struct { + Name string + Revision digest.Digest +} + +func (err ErrManifestUnknownRevision) Error() string { + return fmt.Sprintf("unknown manifest name=%s revision=%s", err.Name, err.Revision) +} + +// ErrManifestUnverified is returned when the registry is unable to verify +// the manifest. +type ErrManifestUnverified struct{} + +func (ErrManifestUnverified) Error() string { + return fmt.Sprintf("unverified manifest") +} + +// ErrManifestVerification provides a type to collect errors encountered +// during manifest verification. Currently, it accepts errors of all types, +// but it may be narrowed to those involving manifest verification. +type ErrManifestVerification []error + +func (errs ErrManifestVerification) Error() string { + var parts []string + for _, err := range errs { + parts = append(parts, err.Error()) + } + + return fmt.Sprintf("errors verifying manifest: %v", strings.Join(parts, ",")) +} + +// ErrManifestBlobUnknown returned when a referenced blob cannot be found. +type ErrManifestBlobUnknown struct { + Digest digest.Digest +} + +func (err ErrManifestBlobUnknown) Error() string { + return fmt.Sprintf("unknown blob %v on manifest", err.Digest) +} + +// ErrManifestNameInvalid should be used to denote an invalid manifest +// name. Reason may set, indicating the cause of invalidity. +type ErrManifestNameInvalid struct { + Name string + Reason error +} + +func (err ErrManifestNameInvalid) Error() string { + return fmt.Sprintf("manifest name %q invalid: %v", err.Name, err.Reason) +} diff --git a/vendor/github.com/docker/distribution/manifests.go b/vendor/github.com/docker/distribution/manifests.go new file mode 100644 index 0000000000..1acb0500d7 --- /dev/null +++ b/vendor/github.com/docker/distribution/manifests.go @@ -0,0 +1,117 @@ +package distribution + +import ( + "fmt" + "mime" + + "github.com/docker/distribution/context" + "github.com/docker/distribution/digest" +) + +// Manifest represents a registry object specifying a set of +// references and an optional target +type Manifest interface { + // References returns a list of objects which make up this manifest. + // The references are strictly ordered from base to head. A reference + // is anything which can be represented by a distribution.Descriptor + References() []Descriptor + + // Payload provides the serialized format of the manifest, in addition to + // the mediatype. + Payload() (mediatype string, payload []byte, err error) +} + +// ManifestBuilder creates a manifest allowing one to include dependencies. +// Instances can be obtained from a version-specific manifest package. Manifest +// specific data is passed into the function which creates the builder. +type ManifestBuilder interface { + // Build creates the manifest from his builder. + Build(ctx context.Context) (Manifest, error) + + // References returns a list of objects which have been added to this + // builder. The dependencies are returned in the order they were added, + // which should be from base to head. + References() []Descriptor + + // AppendReference includes the given object in the manifest after any + // existing dependencies. If the add fails, such as when adding an + // unsupported dependency, an error may be returned. + AppendReference(dependency Describable) error +} + +// ManifestService describes operations on image manifests. +type ManifestService interface { + // Exists returns true if the manifest exists. + Exists(ctx context.Context, dgst digest.Digest) (bool, error) + + // Get retrieves the manifest specified by the given digest + Get(ctx context.Context, dgst digest.Digest, options ...ManifestServiceOption) (Manifest, error) + + // Put creates or updates the given manifest returning the manifest digest + Put(ctx context.Context, manifest Manifest, options ...ManifestServiceOption) (digest.Digest, error) + + // Delete removes the manifest specified by the given digest. Deleting + // a manifest that doesn't exist will return ErrManifestNotFound + Delete(ctx context.Context, dgst digest.Digest) error + + // Enumerate fills 'manifests' with the manifests in this service up + // to the size of 'manifests' and returns 'n' for the number of entries + // which were filled. 'last' contains an offset in the manifest set + // and can be used to resume iteration. + //Enumerate(ctx context.Context, manifests []Manifest, last Manifest) (n int, err error) +} + +// Describable is an interface for descriptors +type Describable interface { + Descriptor() Descriptor +} + +// ManifestMediaTypes returns the supported media types for manifests. +func ManifestMediaTypes() (mediaTypes []string) { + for t := range mappings { + if t != "" { + mediaTypes = append(mediaTypes, t) + } + } + return +} + +// UnmarshalFunc implements manifest unmarshalling a given MediaType +type UnmarshalFunc func([]byte) (Manifest, Descriptor, error) + +var mappings = make(map[string]UnmarshalFunc, 0) + +// UnmarshalManifest looks up manifest unmarshall functions based on +// MediaType +func UnmarshalManifest(ctHeader string, p []byte) (Manifest, Descriptor, error) { + // Need to look up by the actual media type, not the raw contents of + // the header. Strip semicolons and anything following them. + var mediatype string + if ctHeader != "" { + var err error + mediatype, _, err = mime.ParseMediaType(ctHeader) + if err != nil { + return nil, Descriptor{}, err + } + } + + unmarshalFunc, ok := mappings[mediatype] + if !ok { + unmarshalFunc, ok = mappings[""] + if !ok { + return nil, Descriptor{}, fmt.Errorf("unsupported manifest mediatype and no default available: %s", mediatype) + } + } + + return unmarshalFunc(p) +} + +// RegisterManifestSchema registers an UnmarshalFunc for a given schema type. This +// should be called from specific +func RegisterManifestSchema(mediatype string, u UnmarshalFunc) error { + if _, ok := mappings[mediatype]; ok { + return fmt.Errorf("manifest mediatype registration would overwrite existing: %s", mediatype) + } + mappings[mediatype] = u + return nil +} diff --git a/vendor/github.com/docker/distribution/reference/reference.go b/vendor/github.com/docker/distribution/reference/reference.go new file mode 100644 index 0000000000..c188472a40 --- /dev/null +++ b/vendor/github.com/docker/distribution/reference/reference.go @@ -0,0 +1,334 @@ +// Package reference provides a general type to represent any way of referencing images within the registry. +// Its main purpose is to abstract tags and digests (content-addressable hash). +// +// Grammar +// +// reference := repository [ ":" tag ] [ "@" digest ] +// name := [hostname '/'] component ['/' component]* +// hostname := hostcomponent ['.' hostcomponent]* [':' port-number] +// hostcomponent := /([a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])/ +// port-number := /[0-9]+/ +// component := alpha-numeric [separator alpha-numeric]* +// alpha-numeric := /[a-z0-9]+/ +// separator := /[_.]|__|[-]*/ +// +// tag := /[\w][\w.-]{0,127}/ +// +// digest := digest-algorithm ":" digest-hex +// digest-algorithm := digest-algorithm-component [ digest-algorithm-separator digest-algorithm-component ] +// digest-algorithm-separator := /[+.-_]/ +// digest-algorithm-component := /[A-Za-z][A-Za-z0-9]*/ +// digest-hex := /[0-9a-fA-F]{32,}/ ; At least 128 bit digest value +package reference + +import ( + "errors" + "fmt" + + "github.com/docker/distribution/digest" +) + +const ( + // NameTotalLengthMax is the maximum total number of characters in a repository name. + NameTotalLengthMax = 255 +) + +var ( + // ErrReferenceInvalidFormat represents an error while trying to parse a string as a reference. + ErrReferenceInvalidFormat = errors.New("invalid reference format") + + // ErrTagInvalidFormat represents an error while trying to parse a string as a tag. + ErrTagInvalidFormat = errors.New("invalid tag format") + + // ErrDigestInvalidFormat represents an error while trying to parse a string as a tag. + ErrDigestInvalidFormat = errors.New("invalid digest format") + + // ErrNameEmpty is returned for empty, invalid repository names. + ErrNameEmpty = errors.New("repository name must have at least one component") + + // ErrNameTooLong is returned when a repository name is longer than NameTotalLengthMax. + ErrNameTooLong = fmt.Errorf("repository name must not be more than %v characters", NameTotalLengthMax) +) + +// Reference is an opaque object reference identifier that may include +// modifiers such as a hostname, name, tag, and digest. +type Reference interface { + // String returns the full reference + String() string +} + +// Field provides a wrapper type for resolving correct reference types when +// working with encoding. +type Field struct { + reference Reference +} + +// AsField wraps a reference in a Field for encoding. +func AsField(reference Reference) Field { + return Field{reference} +} + +// Reference unwraps the reference type from the field to +// return the Reference object. This object should be +// of the appropriate type to further check for different +// reference types. +func (f Field) Reference() Reference { + return f.reference +} + +// MarshalText serializes the field to byte text which +// is the string of the reference. +func (f Field) MarshalText() (p []byte, err error) { + return []byte(f.reference.String()), nil +} + +// UnmarshalText parses text bytes by invoking the +// reference parser to ensure the appropriately +// typed reference object is wrapped by field. +func (f *Field) UnmarshalText(p []byte) error { + r, err := Parse(string(p)) + if err != nil { + return err + } + + f.reference = r + return nil +} + +// Named is an object with a full name +type Named interface { + Reference + Name() string +} + +// Tagged is an object which has a tag +type Tagged interface { + Reference + Tag() string +} + +// NamedTagged is an object including a name and tag. +type NamedTagged interface { + Named + Tag() string +} + +// Digested is an object which has a digest +// in which it can be referenced by +type Digested interface { + Reference + Digest() digest.Digest +} + +// Canonical reference is an object with a fully unique +// name including a name with hostname and digest +type Canonical interface { + Named + Digest() digest.Digest +} + +// SplitHostname splits a named reference into a +// hostname and name string. If no valid hostname is +// found, the hostname is empty and the full value +// is returned as name +func SplitHostname(named Named) (string, string) { + name := named.Name() + match := anchoredNameRegexp.FindStringSubmatch(name) + if match == nil || len(match) != 3 { + return "", name + } + return match[1], match[2] +} + +// Parse parses s and returns a syntactically valid Reference. +// If an error was encountered it is returned, along with a nil Reference. +// NOTE: Parse will not handle short digests. +func Parse(s string) (Reference, error) { + matches := ReferenceRegexp.FindStringSubmatch(s) + if matches == nil { + if s == "" { + return nil, ErrNameEmpty + } + // TODO(dmcgowan): Provide more specific and helpful error + return nil, ErrReferenceInvalidFormat + } + + if len(matches[1]) > NameTotalLengthMax { + return nil, ErrNameTooLong + } + + ref := reference{ + name: matches[1], + tag: matches[2], + } + if matches[3] != "" { + var err error + ref.digest, err = digest.ParseDigest(matches[3]) + if err != nil { + return nil, err + } + } + + r := getBestReferenceType(ref) + if r == nil { + return nil, ErrNameEmpty + } + + return r, nil +} + +// ParseNamed parses s and returns a syntactically valid reference implementing +// the Named interface. The reference must have a name, otherwise an error is +// returned. +// If an error was encountered it is returned, along with a nil Reference. +// NOTE: ParseNamed will not handle short digests. +func ParseNamed(s string) (Named, error) { + ref, err := Parse(s) + if err != nil { + return nil, err + } + named, isNamed := ref.(Named) + if !isNamed { + return nil, fmt.Errorf("reference %s has no name", ref.String()) + } + return named, nil +} + +// WithName returns a named object representing the given string. If the input +// is invalid ErrReferenceInvalidFormat will be returned. +func WithName(name string) (Named, error) { + if len(name) > NameTotalLengthMax { + return nil, ErrNameTooLong + } + if !anchoredNameRegexp.MatchString(name) { + return nil, ErrReferenceInvalidFormat + } + return repository(name), nil +} + +// WithTag combines the name from "name" and the tag from "tag" to form a +// reference incorporating both the name and the tag. +func WithTag(name Named, tag string) (NamedTagged, error) { + if !anchoredTagRegexp.MatchString(tag) { + return nil, ErrTagInvalidFormat + } + return taggedReference{ + name: name.Name(), + tag: tag, + }, nil +} + +// WithDigest combines the name from "name" and the digest from "digest" to form +// a reference incorporating both the name and the digest. +func WithDigest(name Named, digest digest.Digest) (Canonical, error) { + if !anchoredDigestRegexp.MatchString(digest.String()) { + return nil, ErrDigestInvalidFormat + } + return canonicalReference{ + name: name.Name(), + digest: digest, + }, nil +} + +func getBestReferenceType(ref reference) Reference { + if ref.name == "" { + // Allow digest only references + if ref.digest != "" { + return digestReference(ref.digest) + } + return nil + } + if ref.tag == "" { + if ref.digest != "" { + return canonicalReference{ + name: ref.name, + digest: ref.digest, + } + } + return repository(ref.name) + } + if ref.digest == "" { + return taggedReference{ + name: ref.name, + tag: ref.tag, + } + } + + return ref +} + +type reference struct { + name string + tag string + digest digest.Digest +} + +func (r reference) String() string { + return r.name + ":" + r.tag + "@" + r.digest.String() +} + +func (r reference) Name() string { + return r.name +} + +func (r reference) Tag() string { + return r.tag +} + +func (r reference) Digest() digest.Digest { + return r.digest +} + +type repository string + +func (r repository) String() string { + return string(r) +} + +func (r repository) Name() string { + return string(r) +} + +type digestReference digest.Digest + +func (d digestReference) String() string { + return d.String() +} + +func (d digestReference) Digest() digest.Digest { + return digest.Digest(d) +} + +type taggedReference struct { + name string + tag string +} + +func (t taggedReference) String() string { + return t.name + ":" + t.tag +} + +func (t taggedReference) Name() string { + return t.name +} + +func (t taggedReference) Tag() string { + return t.tag +} + +type canonicalReference struct { + name string + digest digest.Digest +} + +func (c canonicalReference) String() string { + return c.name + "@" + c.digest.String() +} + +func (c canonicalReference) Name() string { + return c.name +} + +func (c canonicalReference) Digest() digest.Digest { + return c.digest +} diff --git a/vendor/github.com/docker/distribution/reference/regexp.go b/vendor/github.com/docker/distribution/reference/regexp.go new file mode 100644 index 0000000000..a4ffe5b642 --- /dev/null +++ b/vendor/github.com/docker/distribution/reference/regexp.go @@ -0,0 +1,124 @@ +package reference + +import "regexp" + +var ( + // alphaNumericRegexp defines the alpha numeric atom, typically a + // component of names. This only allows lower case characters and digits. + alphaNumericRegexp = match(`[a-z0-9]+`) + + // separatorRegexp defines the separators allowed to be embedded in name + // components. This allow one period, one or two underscore and multiple + // dashes. + separatorRegexp = match(`(?:[._]|__|[-]*)`) + + // nameComponentRegexp restricts registry path component names to start + // with at least one letter or number, with following parts able to be + // separated by one period, one or two underscore and multiple dashes. + nameComponentRegexp = expression( + alphaNumericRegexp, + optional(repeated(separatorRegexp, alphaNumericRegexp))) + + // hostnameComponentRegexp restricts the registry hostname component of a + // repository name to start with a component as defined by hostnameRegexp + // and followed by an optional port. + hostnameComponentRegexp = match(`(?:[a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])`) + + // hostnameRegexp defines the structure of potential hostname components + // that may be part of image names. This is purposely a subset of what is + // allowed by DNS to ensure backwards compatibility with Docker image + // names. + hostnameRegexp = expression( + hostnameComponentRegexp, + optional(repeated(literal(`.`), hostnameComponentRegexp)), + optional(literal(`:`), match(`[0-9]+`))) + + // TagRegexp matches valid tag names. From docker/docker:graph/tags.go. + TagRegexp = match(`[\w][\w.-]{0,127}`) + + // anchoredTagRegexp matches valid tag names, anchored at the start and + // end of the matched string. + anchoredTagRegexp = anchored(TagRegexp) + + // DigestRegexp matches valid digests. + DigestRegexp = match(`[A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*[:][[:xdigit:]]{32,}`) + + // anchoredDigestRegexp matches valid digests, anchored at the start and + // end of the matched string. + anchoredDigestRegexp = anchored(DigestRegexp) + + // NameRegexp is the format for the name component of references. The + // regexp has capturing groups for the hostname and name part omitting + // the seperating forward slash from either. + NameRegexp = expression( + optional(hostnameRegexp, literal(`/`)), + nameComponentRegexp, + optional(repeated(literal(`/`), nameComponentRegexp))) + + // anchoredNameRegexp is used to parse a name value, capturing the + // hostname and trailing components. + anchoredNameRegexp = anchored( + optional(capture(hostnameRegexp), literal(`/`)), + capture(nameComponentRegexp, + optional(repeated(literal(`/`), nameComponentRegexp)))) + + // ReferenceRegexp is the full supported format of a reference. The regexp + // is anchored and has capturing groups for name, tag, and digest + // components. + ReferenceRegexp = anchored(capture(NameRegexp), + optional(literal(":"), capture(TagRegexp)), + optional(literal("@"), capture(DigestRegexp))) +) + +// match compiles the string to a regular expression. +var match = regexp.MustCompile + +// literal compiles s into a literal regular expression, escaping any regexp +// reserved characters. +func literal(s string) *regexp.Regexp { + re := match(regexp.QuoteMeta(s)) + + if _, complete := re.LiteralPrefix(); !complete { + panic("must be a literal") + } + + return re +} + +// expression defines a full expression, where each regular expression must +// follow the previous. +func expression(res ...*regexp.Regexp) *regexp.Regexp { + var s string + for _, re := range res { + s += re.String() + } + + return match(s) +} + +// optional wraps the expression in a non-capturing group and makes the +// production optional. +func optional(res ...*regexp.Regexp) *regexp.Regexp { + return match(group(expression(res...)).String() + `?`) +} + +// repeated wraps the regexp in a non-capturing group to get one or more +// matches. +func repeated(res ...*regexp.Regexp) *regexp.Regexp { + return match(group(expression(res...)).String() + `+`) +} + +// group wraps the regexp in a non-capturing group. +func group(res ...*regexp.Regexp) *regexp.Regexp { + return match(`(?:` + expression(res...).String() + `)`) +} + +// capture wraps the expression in a capturing group. +func capture(res ...*regexp.Regexp) *regexp.Regexp { + return match(`(` + expression(res...).String() + `)`) +} + +// anchored anchors the regular expression by adding start and end delimiters. +func anchored(res ...*regexp.Regexp) *regexp.Regexp { + return match(`^` + expression(res...).String() + `$`) +} diff --git a/vendor/github.com/docker/distribution/registry.go b/vendor/github.com/docker/distribution/registry.go new file mode 100644 index 0000000000..dcb35c3744 --- /dev/null +++ b/vendor/github.com/docker/distribution/registry.go @@ -0,0 +1,72 @@ +package distribution + +import ( + "github.com/docker/distribution/context" + "github.com/docker/distribution/reference" +) + +// Scope defines the set of items that match a namespace. +type Scope interface { + // Contains returns true if the name belongs to the namespace. + Contains(name string) bool +} + +type fullScope struct{} + +func (f fullScope) Contains(string) bool { + return true +} + +// GlobalScope represents the full namespace scope which contains +// all other scopes. +var GlobalScope = Scope(fullScope{}) + +// Namespace represents a collection of repositories, addressable by name. +// Generally, a namespace is backed by a set of one or more services, +// providing facilities such as registry access, trust, and indexing. +type Namespace interface { + // Scope describes the names that can be used with this Namespace. The + // global namespace will have a scope that matches all names. The scope + // effectively provides an identity for the namespace. + Scope() Scope + + // Repository should return a reference to the named repository. The + // registry may or may not have the repository but should always return a + // reference. + Repository(ctx context.Context, name reference.Named) (Repository, error) + + // Repositories fills 'repos' with a lexigraphically sorted catalog of repositories + // up to the size of 'repos' and returns the value 'n' for the number of entries + // which were filled. 'last' contains an offset in the catalog, and 'err' will be + // set to io.EOF if there are no more entries to obtain. + Repositories(ctx context.Context, repos []string, last string) (n int, err error) +} + +// ManifestServiceOption is a function argument for Manifest Service methods +type ManifestServiceOption interface { + Apply(ManifestService) error +} + +// Repository is a named collection of manifests and layers. +type Repository interface { + // Name returns the name of the repository. + Name() reference.Named + + // Manifests returns a reference to this repository's manifest service. + // with the supplied options applied. + Manifests(ctx context.Context, options ...ManifestServiceOption) (ManifestService, error) + + // Blobs returns a reference to this repository's blob service. + Blobs(ctx context.Context) BlobStore + + // TODO(stevvooe): The above BlobStore return can probably be relaxed to + // be a BlobService for use with clients. This will allow such + // implementations to avoid implementing ServeBlob. + + // Tags returns a reference to this repositories tag service + Tags(ctx context.Context) TagService +} + +// TODO(stevvooe): Must add close methods to all these. May want to change the +// way instances are created to better reflect internal dependency +// relationships. diff --git a/vendor/github.com/docker/distribution/tags.go b/vendor/github.com/docker/distribution/tags.go new file mode 100644 index 0000000000..5030565963 --- /dev/null +++ b/vendor/github.com/docker/distribution/tags.go @@ -0,0 +1,27 @@ +package distribution + +import ( + "github.com/docker/distribution/context" +) + +// TagService provides access to information about tagged objects. +type TagService interface { + // Get retrieves the descriptor identified by the tag. Some + // implementations may differentiate between "trusted" tags and + // "untrusted" tags. If a tag is "untrusted", the mapping will be returned + // as an ErrTagUntrusted error, with the target descriptor. + Get(ctx context.Context, tag string) (Descriptor, error) + + // Tag associates the tag with the provided descriptor, updating the + // current association, if needed. + Tag(ctx context.Context, tag string, desc Descriptor) error + + // Untag removes the given tag association + Untag(ctx context.Context, tag string) error + + // All returns the set of tags managed by this tag service + All(ctx context.Context) ([]string, error) + + // Lookup returns the set of tags referencing the given digest. + Lookup(ctx context.Context, digest Descriptor) ([]string, error) +} diff --git a/vendor/github.com/dustin/go-humanize/LICENSE b/vendor/github.com/dustin/go-humanize/LICENSE new file mode 100644 index 0000000000..8d9a94a906 --- /dev/null +++ b/vendor/github.com/dustin/go-humanize/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) 2005-2008 Dustin Sallings + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + diff --git a/vendor/github.com/dustin/go-humanize/big.go b/vendor/github.com/dustin/go-humanize/big.go new file mode 100644 index 0000000000..f49dc337dc --- /dev/null +++ b/vendor/github.com/dustin/go-humanize/big.go @@ -0,0 +1,31 @@ +package humanize + +import ( + "math/big" +) + +// order of magnitude (to a max order) +func oomm(n, b *big.Int, maxmag int) (float64, int) { + mag := 0 + m := &big.Int{} + for n.Cmp(b) >= 0 { + n.DivMod(n, b, m) + mag++ + if mag == maxmag && maxmag >= 0 { + break + } + } + return float64(n.Int64()) + (float64(m.Int64()) / float64(b.Int64())), mag +} + +// total order of magnitude +// (same as above, but with no upper limit) +func oom(n, b *big.Int) (float64, int) { + mag := 0 + m := &big.Int{} + for n.Cmp(b) >= 0 { + n.DivMod(n, b, m) + mag++ + } + return float64(n.Int64()) + (float64(m.Int64()) / float64(b.Int64())), mag +} diff --git a/vendor/github.com/dustin/go-humanize/bigbytes.go b/vendor/github.com/dustin/go-humanize/bigbytes.go new file mode 100644 index 0000000000..e4a814a904 --- /dev/null +++ b/vendor/github.com/dustin/go-humanize/bigbytes.go @@ -0,0 +1,164 @@ +package humanize + +import ( + "fmt" + "math/big" + "strings" + "unicode" +) + +var ( + bigIECExp = big.NewInt(1024) + + // BigByte is one byte in bit.Ints + BigByte = big.NewInt(1) + // BigKiByte is 1,024 bytes in bit.Ints + BigKiByte = (&big.Int{}).Mul(BigByte, bigIECExp) + // BigMiByte is 1,024 k bytes in bit.Ints + BigMiByte = (&big.Int{}).Mul(BigKiByte, bigIECExp) + // BigGiByte is 1,024 m bytes in bit.Ints + BigGiByte = (&big.Int{}).Mul(BigMiByte, bigIECExp) + // BigTiByte is 1,024 g bytes in bit.Ints + BigTiByte = (&big.Int{}).Mul(BigGiByte, bigIECExp) + // BigPiByte is 1,024 t bytes in bit.Ints + BigPiByte = (&big.Int{}).Mul(BigTiByte, bigIECExp) + // BigEiByte is 1,024 p bytes in bit.Ints + BigEiByte = (&big.Int{}).Mul(BigPiByte, bigIECExp) + // BigZiByte is 1,024 e bytes in bit.Ints + BigZiByte = (&big.Int{}).Mul(BigEiByte, bigIECExp) + // BigYiByte is 1,024 z bytes in bit.Ints + BigYiByte = (&big.Int{}).Mul(BigZiByte, bigIECExp) +) + +var ( + bigSIExp = big.NewInt(1000) + + // BigSIByte is one SI byte in big.Ints + BigSIByte = big.NewInt(1) + // BigKByte is 1,000 SI bytes in big.Ints + BigKByte = (&big.Int{}).Mul(BigSIByte, bigSIExp) + // BigMByte is 1,000 SI k bytes in big.Ints + BigMByte = (&big.Int{}).Mul(BigKByte, bigSIExp) + // BigGByte is 1,000 SI m bytes in big.Ints + BigGByte = (&big.Int{}).Mul(BigMByte, bigSIExp) + // BigTByte is 1,000 SI g bytes in big.Ints + BigTByte = (&big.Int{}).Mul(BigGByte, bigSIExp) + // BigPByte is 1,000 SI t bytes in big.Ints + BigPByte = (&big.Int{}).Mul(BigTByte, bigSIExp) + // BigEByte is 1,000 SI p bytes in big.Ints + BigEByte = (&big.Int{}).Mul(BigPByte, bigSIExp) + // BigZByte is 1,000 SI e bytes in big.Ints + BigZByte = (&big.Int{}).Mul(BigEByte, bigSIExp) + // BigYByte is 1,000 SI z bytes in big.Ints + BigYByte = (&big.Int{}).Mul(BigZByte, bigSIExp) +) + +var bigBytesSizeTable = map[string]*big.Int{ + "b": BigByte, + "kib": BigKiByte, + "kb": BigKByte, + "mib": BigMiByte, + "mb": BigMByte, + "gib": BigGiByte, + "gb": BigGByte, + "tib": BigTiByte, + "tb": BigTByte, + "pib": BigPiByte, + "pb": BigPByte, + "eib": BigEiByte, + "eb": BigEByte, + "zib": BigZiByte, + "zb": BigZByte, + "yib": BigYiByte, + "yb": BigYByte, + // Without suffix + "": BigByte, + "ki": BigKiByte, + "k": BigKByte, + "mi": BigMiByte, + "m": BigMByte, + "gi": BigGiByte, + "g": BigGByte, + "ti": BigTiByte, + "t": BigTByte, + "pi": BigPiByte, + "p": BigPByte, + "ei": BigEiByte, + "e": BigEByte, + "z": BigZByte, + "zi": BigZiByte, + "y": BigYByte, + "yi": BigYiByte, +} + +var ten = big.NewInt(10) + +func humanateBigBytes(s, base *big.Int, sizes []string) string { + if s.Cmp(ten) < 0 { + return fmt.Sprintf("%dB", s) + } + c := (&big.Int{}).Set(s) + val, mag := oomm(c, base, len(sizes)-1) + suffix := sizes[mag] + f := "%.0f%s" + if val < 10 { + f = "%.1f%s" + } + + return fmt.Sprintf(f, val, suffix) + +} + +// BigBytes produces a human readable representation of an SI size. +// +// See also: ParseBigBytes. +// +// BigBytes(82854982) -> 83MB +func BigBytes(s *big.Int) string { + sizes := []string{"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"} + return humanateBigBytes(s, bigSIExp, sizes) +} + +// BigIBytes produces a human readable representation of an IEC size. +// +// See also: ParseBigBytes. +// +// BigIBytes(82854982) -> 79MiB +func BigIBytes(s *big.Int) string { + sizes := []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"} + return humanateBigBytes(s, bigIECExp, sizes) +} + +// ParseBigBytes parses a string representation of bytes into the number +// of bytes it represents. +// +// See also: BigBytes, BigIBytes. +// +// ParseBigBytes("42MB") -> 42000000, nil +// ParseBigBytes("42mib") -> 44040192, nil +func ParseBigBytes(s string) (*big.Int, error) { + lastDigit := 0 + for _, r := range s { + if !(unicode.IsDigit(r) || r == '.') { + break + } + lastDigit++ + } + + val := &big.Rat{} + _, err := fmt.Sscanf(s[:lastDigit], "%f", val) + if err != nil { + return nil, err + } + + extra := strings.ToLower(strings.TrimSpace(s[lastDigit:])) + if m, ok := bigBytesSizeTable[extra]; ok { + mv := (&big.Rat{}).SetInt(m) + val.Mul(val, mv) + rv := &big.Int{} + rv.Div(val.Num(), val.Denom()) + return rv, nil + } + + return nil, fmt.Errorf("unhandled size name: %v", extra) +} diff --git a/vendor/github.com/dustin/go-humanize/bytes.go b/vendor/github.com/dustin/go-humanize/bytes.go new file mode 100644 index 0000000000..b7a77b5296 --- /dev/null +++ b/vendor/github.com/dustin/go-humanize/bytes.go @@ -0,0 +1,134 @@ +package humanize + +import ( + "fmt" + "math" + "strconv" + "strings" + "unicode" +) + +// IEC Sizes. +// kibis of bits +const ( + Byte = 1 << (iota * 10) + KiByte + MiByte + GiByte + TiByte + PiByte + EiByte +) + +// SI Sizes. +const ( + IByte = 1 + KByte = IByte * 1000 + MByte = KByte * 1000 + GByte = MByte * 1000 + TByte = GByte * 1000 + PByte = TByte * 1000 + EByte = PByte * 1000 +) + +var bytesSizeTable = map[string]uint64{ + "b": Byte, + "kib": KiByte, + "kb": KByte, + "mib": MiByte, + "mb": MByte, + "gib": GiByte, + "gb": GByte, + "tib": TiByte, + "tb": TByte, + "pib": PiByte, + "pb": PByte, + "eib": EiByte, + "eb": EByte, + // Without suffix + "": Byte, + "ki": KiByte, + "k": KByte, + "mi": MiByte, + "m": MByte, + "gi": GiByte, + "g": GByte, + "ti": TiByte, + "t": TByte, + "pi": PiByte, + "p": PByte, + "ei": EiByte, + "e": EByte, +} + +func logn(n, b float64) float64 { + return math.Log(n) / math.Log(b) +} + +func humanateBytes(s uint64, base float64, sizes []string) string { + if s < 10 { + return fmt.Sprintf("%dB", s) + } + e := math.Floor(logn(float64(s), base)) + suffix := sizes[int(e)] + val := math.Floor(float64(s)/math.Pow(base, e)*10+0.5) / 10 + f := "%.0f%s" + if val < 10 { + f = "%.1f%s" + } + + return fmt.Sprintf(f, val, suffix) +} + +// Bytes produces a human readable representation of an SI size. +// +// See also: ParseBytes. +// +// Bytes(82854982) -> 83MB +func Bytes(s uint64) string { + sizes := []string{"B", "kB", "MB", "GB", "TB", "PB", "EB"} + return humanateBytes(s, 1000, sizes) +} + +// IBytes produces a human readable representation of an IEC size. +// +// See also: ParseBytes. +// +// IBytes(82854982) -> 79MiB +func IBytes(s uint64) string { + sizes := []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"} + return humanateBytes(s, 1024, sizes) +} + +// ParseBytes parses a string representation of bytes into the number +// of bytes it represents. +// +// See Also: Bytes, IBytes. +// +// ParseBytes("42MB") -> 42000000, nil +// ParseBytes("42mib") -> 44040192, nil +func ParseBytes(s string) (uint64, error) { + lastDigit := 0 + for _, r := range s { + if !(unicode.IsDigit(r) || r == '.') { + break + } + lastDigit++ + } + + f, err := strconv.ParseFloat(s[:lastDigit], 64) + if err != nil { + return 0, err + } + + extra := strings.ToLower(strings.TrimSpace(s[lastDigit:])) + if m, ok := bytesSizeTable[extra]; ok { + f *= float64(m) + if f >= math.MaxUint64 { + return 0, fmt.Errorf("too large: %v", s) + } + return uint64(f), nil + } + + return 0, fmt.Errorf("unhandled size name: %v", extra) +} diff --git a/vendor/github.com/dustin/go-humanize/comma.go b/vendor/github.com/dustin/go-humanize/comma.go new file mode 100644 index 0000000000..b65ea6fa78 --- /dev/null +++ b/vendor/github.com/dustin/go-humanize/comma.go @@ -0,0 +1,101 @@ +package humanize + +import ( + "bytes" + "math/big" + "strconv" + "strings" +) + +// Comma produces a string form of the given number in base 10 with +// commas after every three orders of magnitude. +// +// e.g. Comma(834142) -> 834,142 +func Comma(v int64) string { + sign := "" + if v < 0 { + sign = "-" + v = 0 - v + } + + parts := []string{"", "", "", "", "", "", ""} + j := len(parts) - 1 + + for v > 999 { + parts[j] = strconv.FormatInt(v%1000, 10) + switch len(parts[j]) { + case 2: + parts[j] = "0" + parts[j] + case 1: + parts[j] = "00" + parts[j] + } + v = v / 1000 + j-- + } + parts[j] = strconv.Itoa(int(v)) + return sign + strings.Join(parts[j:], ",") +} + +// Commaf produces a string form of the given number in base 10 with +// commas after every three orders of magnitude. +// +// e.g. Comma(834142.32) -> 834,142.32 +func Commaf(v float64) string { + buf := &bytes.Buffer{} + if v < 0 { + buf.Write([]byte{'-'}) + v = 0 - v + } + + comma := []byte{','} + + parts := strings.Split(strconv.FormatFloat(v, 'f', -1, 64), ".") + pos := 0 + if len(parts[0])%3 != 0 { + pos += len(parts[0]) % 3 + buf.WriteString(parts[0][:pos]) + buf.Write(comma) + } + for ; pos < len(parts[0]); pos += 3 { + buf.WriteString(parts[0][pos : pos+3]) + buf.Write(comma) + } + buf.Truncate(buf.Len() - 1) + + if len(parts) > 1 { + buf.Write([]byte{'.'}) + buf.WriteString(parts[1]) + } + return buf.String() +} + +// BigComma produces a string form of the given big.Int in base 10 +// with commas after every three orders of magnitude. +func BigComma(b *big.Int) string { + sign := "" + if b.Sign() < 0 { + sign = "-" + b.Abs(b) + } + + athousand := big.NewInt(1000) + c := (&big.Int{}).Set(b) + _, m := oom(c, athousand) + parts := make([]string, m+1) + j := len(parts) - 1 + + mod := &big.Int{} + for b.Cmp(athousand) >= 0 { + b.DivMod(b, athousand, mod) + parts[j] = strconv.FormatInt(mod.Int64(), 10) + switch len(parts[j]) { + case 2: + parts[j] = "0" + parts[j] + case 1: + parts[j] = "00" + parts[j] + } + j-- + } + parts[j] = strconv.Itoa(int(b.Int64())) + return sign + strings.Join(parts[j:], ",") +} diff --git a/vendor/github.com/dustin/go-humanize/ftoa.go b/vendor/github.com/dustin/go-humanize/ftoa.go new file mode 100644 index 0000000000..c76190b106 --- /dev/null +++ b/vendor/github.com/dustin/go-humanize/ftoa.go @@ -0,0 +1,23 @@ +package humanize + +import "strconv" + +func stripTrailingZeros(s string) string { + offset := len(s) - 1 + for offset > 0 { + if s[offset] == '.' { + offset-- + break + } + if s[offset] != '0' { + break + } + offset-- + } + return s[:offset+1] +} + +// Ftoa converts a float to a string with no trailing zeros. +func Ftoa(num float64) string { + return stripTrailingZeros(strconv.FormatFloat(num, 'f', 6, 64)) +} diff --git a/vendor/github.com/dustin/go-humanize/humanize.go b/vendor/github.com/dustin/go-humanize/humanize.go new file mode 100644 index 0000000000..a69540a06b --- /dev/null +++ b/vendor/github.com/dustin/go-humanize/humanize.go @@ -0,0 +1,8 @@ +/* +Package humanize converts boring ugly numbers to human-friendly strings and back. + +Durations can be turned into strings such as "3 days ago", numbers +representing sizes like 82854982 into useful strings like, "83MB" or +"79MiB" (whichever you prefer). +*/ +package humanize diff --git a/vendor/github.com/dustin/go-humanize/number.go b/vendor/github.com/dustin/go-humanize/number.go new file mode 100644 index 0000000000..32141348c8 --- /dev/null +++ b/vendor/github.com/dustin/go-humanize/number.go @@ -0,0 +1,192 @@ +package humanize + +/* +Slightly adapted from the source to fit go-humanize. + +Author: https://github.com/gorhill +Source: https://gist.github.com/gorhill/5285193 + +*/ + +import ( + "math" + "strconv" +) + +var ( + renderFloatPrecisionMultipliers = [...]float64{ + 1, + 10, + 100, + 1000, + 10000, + 100000, + 1000000, + 10000000, + 100000000, + 1000000000, + } + + renderFloatPrecisionRounders = [...]float64{ + 0.5, + 0.05, + 0.005, + 0.0005, + 0.00005, + 0.000005, + 0.0000005, + 0.00000005, + 0.000000005, + 0.0000000005, + } +) + +// FormatFloat produces a formatted number as string based on the following user-specified criteria: +// * thousands separator +// * decimal separator +// * decimal precision +// +// Usage: s := RenderFloat(format, n) +// The format parameter tells how to render the number n. +// +// See examples: http://play.golang.org/p/LXc1Ddm1lJ +// +// Examples of format strings, given n = 12345.6789: +// "#,###.##" => "12,345.67" +// "#,###." => "12,345" +// "#,###" => "12345,678" +// "#\u202F###,##" => "12 345,68" +// "#.###,###### => 12.345,678900 +// "" (aka default format) => 12,345.67 +// +// The highest precision allowed is 9 digits after the decimal symbol. +// There is also a version for integer number, FormatInteger(), +// which is convenient for calls within template. +func FormatFloat(format string, n float64) string { + // Special cases: + // NaN = "NaN" + // +Inf = "+Infinity" + // -Inf = "-Infinity" + if math.IsNaN(n) { + return "NaN" + } + if n > math.MaxFloat64 { + return "Infinity" + } + if n < -math.MaxFloat64 { + return "-Infinity" + } + + // default format + precision := 2 + decimalStr := "." + thousandStr := "," + positiveStr := "" + negativeStr := "-" + + if len(format) > 0 { + format := []rune(format) + + // If there is an explicit format directive, + // then default values are these: + precision = 9 + thousandStr = "" + + // collect indices of meaningful formatting directives + formatIndx := []int{} + for i, char := range format { + if char != '#' && char != '0' { + formatIndx = append(formatIndx, i) + } + } + + if len(formatIndx) > 0 { + // Directive at index 0: + // Must be a '+' + // Raise an error if not the case + // index: 0123456789 + // +0.000,000 + // +000,000.0 + // +0000.00 + // +0000 + if formatIndx[0] == 0 { + if format[formatIndx[0]] != '+' { + panic("RenderFloat(): invalid positive sign directive") + } + positiveStr = "+" + formatIndx = formatIndx[1:] + } + + // Two directives: + // First is thousands separator + // Raise an error if not followed by 3-digit + // 0123456789 + // 0.000,000 + // 000,000.00 + if len(formatIndx) == 2 { + if (formatIndx[1] - formatIndx[0]) != 4 { + panic("RenderFloat(): thousands separator directive must be followed by 3 digit-specifiers") + } + thousandStr = string(format[formatIndx[0]]) + formatIndx = formatIndx[1:] + } + + // One directive: + // Directive is decimal separator + // The number of digit-specifier following the separator indicates wanted precision + // 0123456789 + // 0.00 + // 000,0000 + if len(formatIndx) == 1 { + decimalStr = string(format[formatIndx[0]]) + precision = len(format) - formatIndx[0] - 1 + } + } + } + + // generate sign part + var signStr string + if n >= 0.000000001 { + signStr = positiveStr + } else if n <= -0.000000001 { + signStr = negativeStr + n = -n + } else { + signStr = "" + n = 0.0 + } + + // split number into integer and fractional parts + intf, fracf := math.Modf(n + renderFloatPrecisionRounders[precision]) + + // generate integer part string + intStr := strconv.Itoa(int(intf)) + + // add thousand separator if required + if len(thousandStr) > 0 { + for i := len(intStr); i > 3; { + i -= 3 + intStr = intStr[:i] + thousandStr + intStr[i:] + } + } + + // no fractional part, we can leave now + if precision == 0 { + return signStr + intStr + } + + // generate fractional part + fracStr := strconv.Itoa(int(fracf * renderFloatPrecisionMultipliers[precision])) + // may need padding + if len(fracStr) < precision { + fracStr = "000000000000000"[:precision-len(fracStr)] + fracStr + } + + return signStr + intStr + decimalStr + fracStr +} + +// FormatInteger produces a formatted number as string. +// See FormatFloat. +func FormatInteger(format string, n int) string { + return FormatFloat(format, float64(n)) +} diff --git a/vendor/github.com/dustin/go-humanize/ordinals.go b/vendor/github.com/dustin/go-humanize/ordinals.go new file mode 100644 index 0000000000..43d88a8619 --- /dev/null +++ b/vendor/github.com/dustin/go-humanize/ordinals.go @@ -0,0 +1,25 @@ +package humanize + +import "strconv" + +// Ordinal gives you the input number in a rank/ordinal format. +// +// Ordinal(3) -> 3rd +func Ordinal(x int) string { + suffix := "th" + switch x % 10 { + case 1: + if x%100 != 11 { + suffix = "st" + } + case 2: + if x%100 != 12 { + suffix = "nd" + } + case 3: + if x%100 != 13 { + suffix = "rd" + } + } + return strconv.Itoa(x) + suffix +} diff --git a/vendor/github.com/dustin/go-humanize/si.go b/vendor/github.com/dustin/go-humanize/si.go new file mode 100644 index 0000000000..dee8b765a0 --- /dev/null +++ b/vendor/github.com/dustin/go-humanize/si.go @@ -0,0 +1,110 @@ +package humanize + +import ( + "errors" + "math" + "regexp" + "strconv" +) + +var siPrefixTable = map[float64]string{ + -24: "y", // yocto + -21: "z", // zepto + -18: "a", // atto + -15: "f", // femto + -12: "p", // pico + -9: "n", // nano + -6: "µ", // micro + -3: "m", // milli + 0: "", + 3: "k", // kilo + 6: "M", // mega + 9: "G", // giga + 12: "T", // tera + 15: "P", // peta + 18: "E", // exa + 21: "Z", // zetta + 24: "Y", // yotta +} + +var revSIPrefixTable = revfmap(siPrefixTable) + +// revfmap reverses the map and precomputes the power multiplier +func revfmap(in map[float64]string) map[string]float64 { + rv := map[string]float64{} + for k, v := range in { + rv[v] = math.Pow(10, k) + } + return rv +} + +var riParseRegex *regexp.Regexp + +func init() { + ri := `^([0-9.]+)([` + for _, v := range siPrefixTable { + ri += v + } + ri += `]?)(.*)` + + riParseRegex = regexp.MustCompile(ri) +} + +// ComputeSI finds the most appropriate SI prefix for the given number +// and returns the prefix along with the value adjusted to be within +// that prefix. +// +// See also: SI, ParseSI. +// +// e.g. ComputeSI(2.2345e-12) -> (2.2345, "p") +func ComputeSI(input float64) (float64, string) { + if input == 0 { + return 0, "" + } + exponent := math.Floor(logn(input, 10)) + exponent = math.Floor(exponent/3) * 3 + + value := input / math.Pow(10, exponent) + + // Handle special case where value is exactly 1000.0 + // Should return 1M instead of 1000k + if value == 1000.0 { + exponent += 3 + value = input / math.Pow(10, exponent) + } + + prefix := siPrefixTable[exponent] + return value, prefix +} + +// SI returns a string with default formatting. +// +// SI uses Ftoa to format float value, removing trailing zeros. +// +// See also: ComputeSI, ParseSI. +// +// e.g. SI(1000000, B) -> 1MB +// e.g. SI(2.2345e-12, "F") -> 2.2345pF +func SI(input float64, unit string) string { + value, prefix := ComputeSI(input) + return Ftoa(value) + prefix + unit +} + +var errInvalid = errors.New("invalid input") + +// ParseSI parses an SI string back into the number and unit. +// +// See also: SI, ComputeSI. +// +// e.g. ParseSI(2.2345pF) -> (2.2345e-12, "F", nil) +func ParseSI(input string) (float64, string, error) { + found := riParseRegex.FindStringSubmatch(input) + if len(found) != 4 { + return 0, "", errInvalid + } + mag := revSIPrefixTable[found[2]] + unit := found[3] + + base, err := strconv.ParseFloat(found[1], 64) + return base * mag, unit, err +} diff --git a/vendor/github.com/dustin/go-humanize/times.go b/vendor/github.com/dustin/go-humanize/times.go new file mode 100644 index 0000000000..592ebe1d62 --- /dev/null +++ b/vendor/github.com/dustin/go-humanize/times.go @@ -0,0 +1,91 @@ +package humanize + +import ( + "fmt" + "math" + "sort" + "time" +) + +// Seconds-based time units +const ( + Minute = 60 + Hour = 60 * Minute + Day = 24 * Hour + Week = 7 * Day + Month = 30 * Day + Year = 12 * Month + LongTime = 37 * Year +) + +// Time formats a time into a relative string. +// +// Time(someT) -> "3 weeks ago" +func Time(then time.Time) string { + return RelTime(then, time.Now(), "ago", "from now") +} + +var magnitudes = []struct { + d int64 + format string + divby int64 +}{ + {1, "now", 1}, + {2, "1 second %s", 1}, + {Minute, "%d seconds %s", 1}, + {2 * Minute, "1 minute %s", 1}, + {Hour, "%d minutes %s", Minute}, + {2 * Hour, "1 hour %s", 1}, + {Day, "%d hours %s", Hour}, + {2 * Day, "1 day %s", 1}, + {Week, "%d days %s", Day}, + {2 * Week, "1 week %s", 1}, + {Month, "%d weeks %s", Week}, + {2 * Month, "1 month %s", 1}, + {Year, "%d months %s", Month}, + {18 * Month, "1 year %s", 1}, + {2 * Year, "2 years %s", 1}, + {LongTime, "%d years %s", Year}, + {math.MaxInt64, "a long while %s", 1}, +} + +// RelTime formats a time into a relative string. +// +// It takes two times and two labels. In addition to the generic time +// delta string (e.g. 5 minutes), the labels are used applied so that +// the label corresponding to the smaller time is applied. +// +// RelTime(timeInPast, timeInFuture, "earlier", "later") -> "3 weeks earlier" +func RelTime(a, b time.Time, albl, blbl string) string { + lbl := albl + diff := b.Unix() - a.Unix() + + after := a.After(b) + if after { + lbl = blbl + diff = a.Unix() - b.Unix() + } + + n := sort.Search(len(magnitudes), func(i int) bool { + return magnitudes[i].d > diff + }) + + mag := magnitudes[n] + args := []interface{}{} + escaped := false + for _, ch := range mag.format { + if escaped { + switch ch { + case '%': + case 's': + args = append(args, lbl) + case 'd': + args = append(args, diff/mag.divby) + } + escaped = false + } else { + escaped = ch == '%' + } + } + return fmt.Sprintf(mag.format, args...) +} diff --git a/vendor/github.com/go-ini/ini/LICENSE b/vendor/github.com/go-ini/ini/LICENSE new file mode 100644 index 0000000000..37ec93a14f --- /dev/null +++ b/vendor/github.com/go-ini/ini/LICENSE @@ -0,0 +1,191 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, "control" means (i) the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising +permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +"Object" form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +"submitted" means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor 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, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of +this License; and +You must cause any modified files to carry prominent notices stating that You +changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets "[]" replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same "printed page" as the copyright notice for easier identification within +third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/go-ini/ini/ini.go b/vendor/github.com/go-ini/ini/ini.go new file mode 100644 index 0000000000..f186148aad --- /dev/null +++ b/vendor/github.com/go-ini/ini/ini.go @@ -0,0 +1,465 @@ +// Copyright 2014 Unknwon +// +// Licensed under the Apache License, Version 2.0 (the "License"): you may +// not use this file except in compliance with the License. You may obtain +// a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations +// under the License. + +// Package ini provides INI file read and write functionality in Go. +package ini + +import ( + "bytes" + "errors" + "fmt" + "io" + "os" + "regexp" + "runtime" + "strconv" + "strings" + "sync" + "time" +) + +const ( + // Name for default section. You can use this constant or the string literal. + // In most of cases, an empty string is all you need to access the section. + DEFAULT_SECTION = "DEFAULT" + + // Maximum allowed depth when recursively substituing variable names. + _DEPTH_VALUES = 99 + _VERSION = "1.11.0" +) + +// Version returns current package version literal. +func Version() string { + return _VERSION +} + +var ( + // Delimiter to determine or compose a new line. + // This variable will be changed to "\r\n" automatically on Windows + // at package init time. + LineBreak = "\n" + + // Variable regexp pattern: %(variable)s + varPattern = regexp.MustCompile(`%\(([^\)]+)\)s`) + + // Indicate whether to align "=" sign with spaces to produce pretty output + // or reduce all possible spaces for compact format. + PrettyFormat = true + + // Explicitly write DEFAULT section header + DefaultHeader = false +) + +func init() { + if runtime.GOOS == "windows" { + LineBreak = "\r\n" + } +} + +func inSlice(str string, s []string) bool { + for _, v := range s { + if str == v { + return true + } + } + return false +} + +// dataSource is an interface that returns object which can be read and closed. +type dataSource interface { + ReadCloser() (io.ReadCloser, error) +} + +// sourceFile represents an object that contains content on the local file system. +type sourceFile struct { + name string +} + +func (s sourceFile) ReadCloser() (_ io.ReadCloser, err error) { + return os.Open(s.name) +} + +type bytesReadCloser struct { + reader io.Reader +} + +func (rc *bytesReadCloser) Read(p []byte) (n int, err error) { + return rc.reader.Read(p) +} + +func (rc *bytesReadCloser) Close() error { + return nil +} + +// sourceData represents an object that contains content in memory. +type sourceData struct { + data []byte +} + +func (s *sourceData) ReadCloser() (io.ReadCloser, error) { + return &bytesReadCloser{bytes.NewReader(s.data)}, nil +} + +// File represents a combination of a or more INI file(s) in memory. +type File struct { + // Should make things safe, but sometimes doesn't matter. + BlockMode bool + // Make sure data is safe in multiple goroutines. + lock sync.RWMutex + + // Allow combination of multiple data sources. + dataSources []dataSource + // Actual data is stored here. + sections map[string]*Section + + // To keep data in order. + sectionList []string + + // Whether the parser should ignore nonexistent files or return error. + looseMode bool + + NameMapper +} + +// newFile initializes File object with given data sources. +func newFile(dataSources []dataSource, looseMode bool) *File { + return &File{ + BlockMode: true, + dataSources: dataSources, + sections: make(map[string]*Section), + sectionList: make([]string, 0, 10), + looseMode: looseMode, + } +} + +func parseDataSource(source interface{}) (dataSource, error) { + switch s := source.(type) { + case string: + return sourceFile{s}, nil + case []byte: + return &sourceData{s}, nil + default: + return nil, fmt.Errorf("error parsing data source: unknown type '%s'", s) + } +} + +func loadSources(looseMode bool, source interface{}, others ...interface{}) (_ *File, err error) { + sources := make([]dataSource, len(others)+1) + sources[0], err = parseDataSource(source) + if err != nil { + return nil, err + } + for i := range others { + sources[i+1], err = parseDataSource(others[i]) + if err != nil { + return nil, err + } + } + f := newFile(sources, looseMode) + if err = f.Reload(); err != nil { + return nil, err + } + return f, nil +} + +// Load loads and parses from INI data sources. +// Arguments can be mixed of file name with string type, or raw data in []byte. +// It will return error if list contains nonexistent files. +func Load(source interface{}, others ...interface{}) (*File, error) { + return loadSources(false, source, others...) +} + +// LooseLoad has exactly same functionality as Load function +// except it ignores nonexistent files instead of returning error. +func LooseLoad(source interface{}, others ...interface{}) (*File, error) { + return loadSources(true, source, others...) +} + +// Empty returns an empty file object. +func Empty() *File { + // Ignore error here, we sure our data is good. + f, _ := Load([]byte("")) + return f +} + +// NewSection creates a new section. +func (f *File) NewSection(name string) (*Section, error) { + if len(name) == 0 { + return nil, errors.New("error creating new section: empty section name") + } + + if f.BlockMode { + f.lock.Lock() + defer f.lock.Unlock() + } + + if inSlice(name, f.sectionList) { + return f.sections[name], nil + } + + f.sectionList = append(f.sectionList, name) + f.sections[name] = newSection(f, name) + return f.sections[name], nil +} + +// NewSections creates a list of sections. +func (f *File) NewSections(names ...string) (err error) { + for _, name := range names { + if _, err = f.NewSection(name); err != nil { + return err + } + } + return nil +} + +// GetSection returns section by given name. +func (f *File) GetSection(name string) (*Section, error) { + if len(name) == 0 { + name = DEFAULT_SECTION + } + + if f.BlockMode { + f.lock.RLock() + defer f.lock.RUnlock() + } + + sec := f.sections[name] + if sec == nil { + return nil, fmt.Errorf("section '%s' does not exist", name) + } + return sec, nil +} + +// Section assumes named section exists and returns a zero-value when not. +func (f *File) Section(name string) *Section { + sec, err := f.GetSection(name) + if err != nil { + // Note: It's OK here because the only possible error is empty section name, + // but if it's empty, this piece of code won't be executed. + sec, _ = f.NewSection(name) + return sec + } + return sec +} + +// Section returns list of Section. +func (f *File) Sections() []*Section { + sections := make([]*Section, len(f.sectionList)) + for i := range f.sectionList { + sections[i] = f.Section(f.sectionList[i]) + } + return sections +} + +// SectionStrings returns list of section names. +func (f *File) SectionStrings() []string { + list := make([]string, len(f.sectionList)) + copy(list, f.sectionList) + return list +} + +// DeleteSection deletes a section. +func (f *File) DeleteSection(name string) { + if f.BlockMode { + f.lock.Lock() + defer f.lock.Unlock() + } + + if len(name) == 0 { + name = DEFAULT_SECTION + } + + for i, s := range f.sectionList { + if s == name { + f.sectionList = append(f.sectionList[:i], f.sectionList[i+1:]...) + delete(f.sections, name) + return + } + } +} + +func (f *File) reload(s dataSource) error { + r, err := s.ReadCloser() + if err != nil { + return err + } + defer r.Close() + + return f.parse(r) +} + +// Reload reloads and parses all data sources. +func (f *File) Reload() (err error) { + for _, s := range f.dataSources { + if err = f.reload(s); err != nil { + // In loose mode, we create an empty default section for nonexistent files. + if os.IsNotExist(err) && f.looseMode { + f.parse(bytes.NewBuffer(nil)) + continue + } + return err + } + } + return nil +} + +// Append appends one or more data sources and reloads automatically. +func (f *File) Append(source interface{}, others ...interface{}) error { + ds, err := parseDataSource(source) + if err != nil { + return err + } + f.dataSources = append(f.dataSources, ds) + for _, s := range others { + ds, err = parseDataSource(s) + if err != nil { + return err + } + f.dataSources = append(f.dataSources, ds) + } + return f.Reload() +} + +// WriteToIndent writes content into io.Writer with given indention. +// If PrettyFormat has been set to be true, +// it will align "=" sign with spaces under each section. +func (f *File) WriteToIndent(w io.Writer, indent string) (n int64, err error) { + equalSign := "=" + if PrettyFormat { + equalSign = " = " + } + + // Use buffer to make sure target is safe until finish encoding. + buf := bytes.NewBuffer(nil) + for i, sname := range f.sectionList { + sec := f.Section(sname) + if len(sec.Comment) > 0 { + if sec.Comment[0] != '#' && sec.Comment[0] != ';' { + sec.Comment = "; " + sec.Comment + } + if _, err = buf.WriteString(sec.Comment + LineBreak); err != nil { + return 0, err + } + } + + if i > 0 || DefaultHeader { + if _, err = buf.WriteString("[" + sname + "]" + LineBreak); err != nil { + return 0, err + } + } else { + // Write nothing if default section is empty + if len(sec.keyList) == 0 { + continue + } + } + + // Count and generate alignment length and buffer spaces + alignLength := 0 + if PrettyFormat { + for i := 0; i < len(sec.keyList); i++ { + if len(sec.keyList[i]) > alignLength { + alignLength = len(sec.keyList[i]) + } + } + } + alignSpaces := bytes.Repeat([]byte(" "), alignLength) + + for _, kname := range sec.keyList { + key := sec.Key(kname) + if len(key.Comment) > 0 { + if len(indent) > 0 && sname != DEFAULT_SECTION { + buf.WriteString(indent) + } + if key.Comment[0] != '#' && key.Comment[0] != ';' { + key.Comment = "; " + key.Comment + } + if _, err = buf.WriteString(key.Comment + LineBreak); err != nil { + return 0, err + } + } + + if len(indent) > 0 && sname != DEFAULT_SECTION { + buf.WriteString(indent) + } + + switch { + case key.isAutoIncr: + kname = "-" + case strings.ContainsAny(kname, "\"=:"): + kname = "`" + kname + "`" + case strings.Contains(kname, "`"): + kname = `"""` + kname + `"""` + } + if _, err = buf.WriteString(kname); err != nil { + return 0, err + } + + // Write out alignment spaces before "=" sign + if PrettyFormat { + buf.Write(alignSpaces[:alignLength-len(kname)]) + } + + val := key.value + // In case key value contains "\n", "`", "\"", "#" or ";" + if strings.ContainsAny(val, "\n`") { + val = `"""` + val + `"""` + } else if strings.ContainsAny(val, "#;") { + val = "`" + val + "`" + } + if _, err = buf.WriteString(equalSign + val + LineBreak); err != nil { + return 0, err + } + } + + // Put a line between sections + if _, err = buf.WriteString(LineBreak); err != nil { + return 0, err + } + } + + return buf.WriteTo(w) +} + +// WriteTo writes file content into io.Writer. +func (f *File) WriteTo(w io.Writer) (int64, error) { + return f.WriteToIndent(w, "") +} + +// SaveToIndent writes content to file system with given value indention. +func (f *File) SaveToIndent(filename, indent string) error { + // Note: Because we are truncating with os.Create, + // so it's safer to save to a temporary file location and rename afte done. + tmpPath := filename + "." + strconv.Itoa(time.Now().Nanosecond()) + ".tmp" + defer os.Remove(tmpPath) + + fw, err := os.Create(tmpPath) + if err != nil { + return err + } + + if _, err = f.WriteToIndent(fw, indent); err != nil { + fw.Close() + return err + } + fw.Close() + + // Remove old file and rename the new one. + os.Remove(filename) + return os.Rename(tmpPath, filename) +} + +// SaveTo writes content to file system. +func (f *File) SaveTo(filename string) error { + return f.SaveToIndent(filename, "") +} diff --git a/vendor/github.com/go-ini/ini/key.go b/vendor/github.com/go-ini/ini/key.go new file mode 100644 index 0000000000..7cbccd38e6 --- /dev/null +++ b/vendor/github.com/go-ini/ini/key.go @@ -0,0 +1,616 @@ +// Copyright 2014 Unknwon +// +// Licensed under the Apache License, Version 2.0 (the "License"): you may +// not use this file except in compliance with the License. You may obtain +// a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations +// under the License. + +package ini + +import ( + "fmt" + "strconv" + "strings" + "time" +) + +// Key represents a key under a section. +type Key struct { + s *Section + Comment string + name string + value string + isAutoIncr bool +} + +// Name returns name of key. +func (k *Key) Name() string { + return k.name +} + +// Value returns raw value of key for performance purpose. +func (k *Key) Value() string { + return k.value +} + +// String returns string representation of value. +func (k *Key) String() string { + val := k.value + if strings.Index(val, "%") == -1 { + return val + } + + for i := 0; i < _DEPTH_VALUES; i++ { + vr := varPattern.FindString(val) + if len(vr) == 0 { + break + } + + // Take off leading '%(' and trailing ')s'. + noption := strings.TrimLeft(vr, "%(") + noption = strings.TrimRight(noption, ")s") + + // Search in the same section. + nk, err := k.s.GetKey(noption) + if err != nil { + // Search again in default section. + nk, _ = k.s.f.Section("").GetKey(noption) + } + + // Substitute by new value and take off leading '%(' and trailing ')s'. + val = strings.Replace(val, vr, nk.value, -1) + } + return val +} + +// Validate accepts a validate function which can +// return modifed result as key value. +func (k *Key) Validate(fn func(string) string) string { + return fn(k.String()) +} + +// parseBool returns the boolean value represented by the string. +// +// It accepts 1, t, T, TRUE, true, True, YES, yes, Yes, y, ON, on, On, +// 0, f, F, FALSE, false, False, NO, no, No, n, OFF, off, Off. +// Any other value returns an error. +func parseBool(str string) (value bool, err error) { + switch str { + case "1", "t", "T", "true", "TRUE", "True", "YES", "yes", "Yes", "y", "ON", "on", "On": + return true, nil + case "0", "f", "F", "false", "FALSE", "False", "NO", "no", "No", "n", "OFF", "off", "Off": + return false, nil + } + return false, fmt.Errorf("parsing \"%s\": invalid syntax", str) +} + +// Bool returns bool type value. +func (k *Key) Bool() (bool, error) { + return parseBool(k.String()) +} + +// Float64 returns float64 type value. +func (k *Key) Float64() (float64, error) { + return strconv.ParseFloat(k.String(), 64) +} + +// Int returns int type value. +func (k *Key) Int() (int, error) { + return strconv.Atoi(k.String()) +} + +// Int64 returns int64 type value. +func (k *Key) Int64() (int64, error) { + return strconv.ParseInt(k.String(), 10, 64) +} + +// Uint returns uint type valued. +func (k *Key) Uint() (uint, error) { + u, e := strconv.ParseUint(k.String(), 10, 64) + return uint(u), e +} + +// Uint64 returns uint64 type value. +func (k *Key) Uint64() (uint64, error) { + return strconv.ParseUint(k.String(), 10, 64) +} + +// Duration returns time.Duration type value. +func (k *Key) Duration() (time.Duration, error) { + return time.ParseDuration(k.String()) +} + +// TimeFormat parses with given format and returns time.Time type value. +func (k *Key) TimeFormat(format string) (time.Time, error) { + return time.Parse(format, k.String()) +} + +// Time parses with RFC3339 format and returns time.Time type value. +func (k *Key) Time() (time.Time, error) { + return k.TimeFormat(time.RFC3339) +} + +// MustString returns default value if key value is empty. +func (k *Key) MustString(defaultVal string) string { + val := k.String() + if len(val) == 0 { + return defaultVal + } + return val +} + +// MustBool always returns value without error, +// it returns false if error occurs. +func (k *Key) MustBool(defaultVal ...bool) bool { + val, err := k.Bool() + if len(defaultVal) > 0 && err != nil { + return defaultVal[0] + } + return val +} + +// MustFloat64 always returns value without error, +// it returns 0.0 if error occurs. +func (k *Key) MustFloat64(defaultVal ...float64) float64 { + val, err := k.Float64() + if len(defaultVal) > 0 && err != nil { + return defaultVal[0] + } + return val +} + +// MustInt always returns value without error, +// it returns 0 if error occurs. +func (k *Key) MustInt(defaultVal ...int) int { + val, err := k.Int() + if len(defaultVal) > 0 && err != nil { + return defaultVal[0] + } + return val +} + +// MustInt64 always returns value without error, +// it returns 0 if error occurs. +func (k *Key) MustInt64(defaultVal ...int64) int64 { + val, err := k.Int64() + if len(defaultVal) > 0 && err != nil { + return defaultVal[0] + } + return val +} + +// MustUint always returns value without error, +// it returns 0 if error occurs. +func (k *Key) MustUint(defaultVal ...uint) uint { + val, err := k.Uint() + if len(defaultVal) > 0 && err != nil { + return defaultVal[0] + } + return val +} + +// MustUint64 always returns value without error, +// it returns 0 if error occurs. +func (k *Key) MustUint64(defaultVal ...uint64) uint64 { + val, err := k.Uint64() + if len(defaultVal) > 0 && err != nil { + return defaultVal[0] + } + return val +} + +// MustDuration always returns value without error, +// it returns zero value if error occurs. +func (k *Key) MustDuration(defaultVal ...time.Duration) time.Duration { + val, err := k.Duration() + if len(defaultVal) > 0 && err != nil { + return defaultVal[0] + } + return val +} + +// MustTimeFormat always parses with given format and returns value without error, +// it returns zero value if error occurs. +func (k *Key) MustTimeFormat(format string, defaultVal ...time.Time) time.Time { + val, err := k.TimeFormat(format) + if len(defaultVal) > 0 && err != nil { + return defaultVal[0] + } + return val +} + +// MustTime always parses with RFC3339 format and returns value without error, +// it returns zero value if error occurs. +func (k *Key) MustTime(defaultVal ...time.Time) time.Time { + return k.MustTimeFormat(time.RFC3339, defaultVal...) +} + +// In always returns value without error, +// it returns default value if error occurs or doesn't fit into candidates. +func (k *Key) In(defaultVal string, candidates []string) string { + val := k.String() + for _, cand := range candidates { + if val == cand { + return val + } + } + return defaultVal +} + +// InFloat64 always returns value without error, +// it returns default value if error occurs or doesn't fit into candidates. +func (k *Key) InFloat64(defaultVal float64, candidates []float64) float64 { + val := k.MustFloat64() + for _, cand := range candidates { + if val == cand { + return val + } + } + return defaultVal +} + +// InInt always returns value without error, +// it returns default value if error occurs or doesn't fit into candidates. +func (k *Key) InInt(defaultVal int, candidates []int) int { + val := k.MustInt() + for _, cand := range candidates { + if val == cand { + return val + } + } + return defaultVal +} + +// InInt64 always returns value without error, +// it returns default value if error occurs or doesn't fit into candidates. +func (k *Key) InInt64(defaultVal int64, candidates []int64) int64 { + val := k.MustInt64() + for _, cand := range candidates { + if val == cand { + return val + } + } + return defaultVal +} + +// InUint always returns value without error, +// it returns default value if error occurs or doesn't fit into candidates. +func (k *Key) InUint(defaultVal uint, candidates []uint) uint { + val := k.MustUint() + for _, cand := range candidates { + if val == cand { + return val + } + } + return defaultVal +} + +// InUint64 always returns value without error, +// it returns default value if error occurs or doesn't fit into candidates. +func (k *Key) InUint64(defaultVal uint64, candidates []uint64) uint64 { + val := k.MustUint64() + for _, cand := range candidates { + if val == cand { + return val + } + } + return defaultVal +} + +// InTimeFormat always parses with given format and returns value without error, +// it returns default value if error occurs or doesn't fit into candidates. +func (k *Key) InTimeFormat(format string, defaultVal time.Time, candidates []time.Time) time.Time { + val := k.MustTimeFormat(format) + for _, cand := range candidates { + if val == cand { + return val + } + } + return defaultVal +} + +// InTime always parses with RFC3339 format and returns value without error, +// it returns default value if error occurs or doesn't fit into candidates. +func (k *Key) InTime(defaultVal time.Time, candidates []time.Time) time.Time { + return k.InTimeFormat(time.RFC3339, defaultVal, candidates) +} + +// RangeFloat64 checks if value is in given range inclusively, +// and returns default value if it's not. +func (k *Key) RangeFloat64(defaultVal, min, max float64) float64 { + val := k.MustFloat64() + if val < min || val > max { + return defaultVal + } + return val +} + +// RangeInt checks if value is in given range inclusively, +// and returns default value if it's not. +func (k *Key) RangeInt(defaultVal, min, max int) int { + val := k.MustInt() + if val < min || val > max { + return defaultVal + } + return val +} + +// RangeInt64 checks if value is in given range inclusively, +// and returns default value if it's not. +func (k *Key) RangeInt64(defaultVal, min, max int64) int64 { + val := k.MustInt64() + if val < min || val > max { + return defaultVal + } + return val +} + +// RangeTimeFormat checks if value with given format is in given range inclusively, +// and returns default value if it's not. +func (k *Key) RangeTimeFormat(format string, defaultVal, min, max time.Time) time.Time { + val := k.MustTimeFormat(format) + if val.Unix() < min.Unix() || val.Unix() > max.Unix() { + return defaultVal + } + return val +} + +// RangeTime checks if value with RFC3339 format is in given range inclusively, +// and returns default value if it's not. +func (k *Key) RangeTime(defaultVal, min, max time.Time) time.Time { + return k.RangeTimeFormat(time.RFC3339, defaultVal, min, max) +} + +// Strings returns list of string divided by given delimiter. +func (k *Key) Strings(delim string) []string { + str := k.String() + if len(str) == 0 { + return []string{} + } + + vals := strings.Split(str, delim) + for i := range vals { + vals[i] = strings.TrimSpace(vals[i]) + } + return vals +} + +// Float64s returns list of float64 divided by given delimiter. Any invalid input will be treated as zero value. +func (k *Key) Float64s(delim string) []float64 { + vals, _ := k.getFloat64s(delim, true, false) + return vals +} + +// Ints returns list of int divided by given delimiter. Any invalid input will be treated as zero value. +func (k *Key) Ints(delim string) []int { + vals, _ := k.getInts(delim, true, false) + return vals +} + +// Int64s returns list of int64 divided by given delimiter. Any invalid input will be treated as zero value. +func (k *Key) Int64s(delim string) []int64 { + vals, _ := k.getInt64s(delim, true, false) + return vals +} + +// Uints returns list of uint divided by given delimiter. Any invalid input will be treated as zero value. +func (k *Key) Uints(delim string) []uint { + vals, _ := k.getUints(delim, true, false) + return vals +} + +// Uint64s returns list of uint64 divided by given delimiter. Any invalid input will be treated as zero value. +func (k *Key) Uint64s(delim string) []uint64 { + vals, _ := k.getUint64s(delim, true, false) + return vals +} + +// TimesFormat parses with given format and returns list of time.Time divided by given delimiter. +// Any invalid input will be treated as zero value (0001-01-01 00:00:00 +0000 UTC). +func (k *Key) TimesFormat(format, delim string) []time.Time { + vals, _ := k.getTimesFormat(format, delim, true, false) + return vals +} + +// Times parses with RFC3339 format and returns list of time.Time divided by given delimiter. +// Any invalid input will be treated as zero value (0001-01-01 00:00:00 +0000 UTC). +func (k *Key) Times(delim string) []time.Time { + return k.TimesFormat(time.RFC3339, delim) +} + +// ValidFloat64s returns list of float64 divided by given delimiter. If some value is not float, then +// it will not be included to result list. +func (k *Key) ValidFloat64s(delim string) []float64 { + vals, _ := k.getFloat64s(delim, false, false) + return vals +} + +// ValidInts returns list of int divided by given delimiter. If some value is not integer, then it will +// not be included to result list. +func (k *Key) ValidInts(delim string) []int { + vals, _ := k.getInts(delim, false, false) + return vals +} + +// ValidInt64s returns list of int64 divided by given delimiter. If some value is not 64-bit integer, +// then it will not be included to result list. +func (k *Key) ValidInt64s(delim string) []int64 { + vals, _ := k.getInt64s(delim, false, false) + return vals +} + +// ValidUints returns list of uint divided by given delimiter. If some value is not unsigned integer, +// then it will not be included to result list. +func (k *Key) ValidUints(delim string) []uint { + vals, _ := k.getUints(delim, false, false) + return vals +} + +// ValidUint64s returns list of uint64 divided by given delimiter. If some value is not 64-bit unsigned +// integer, then it will not be included to result list. +func (k *Key) ValidUint64s(delim string) []uint64 { + vals, _ := k.getUint64s(delim, false, false) + return vals +} + +// ValidTimesFormat parses with given format and returns list of time.Time divided by given delimiter. +func (k *Key) ValidTimesFormat(format, delim string) []time.Time { + vals, _ := k.getTimesFormat(format, delim, false, false) + return vals +} + +// ValidTimes parses with RFC3339 format and returns list of time.Time divided by given delimiter. +func (k *Key) ValidTimes(delim string) []time.Time { + return k.ValidTimesFormat(time.RFC3339, delim) +} + +// StrictFloat64s returns list of float64 divided by given delimiter or error on first invalid input. +func (k *Key) StrictFloat64s(delim string) ([]float64, error) { + return k.getFloat64s(delim, false, true) +} + +// StrictInts returns list of int divided by given delimiter or error on first invalid input. +func (k *Key) StrictInts(delim string) ([]int, error) { + return k.getInts(delim, false, true) +} + +// StrictInt64s returns list of int64 divided by given delimiter or error on first invalid input. +func (k *Key) StrictInt64s(delim string) ([]int64, error) { + return k.getInt64s(delim, false, true) +} + +// StrictUints returns list of uint divided by given delimiter or error on first invalid input. +func (k *Key) StrictUints(delim string) ([]uint, error) { + return k.getUints(delim, false, true) +} + +// StrictUint64s returns list of uint64 divided by given delimiter or error on first invalid input. +func (k *Key) StrictUint64s(delim string) ([]uint64, error) { + return k.getUint64s(delim, false, true) +} + +// StrictTimesFormat parses with given format and returns list of time.Time divided by given delimiter +// or error on first invalid input. +func (k *Key) StrictTimesFormat(format, delim string) ([]time.Time, error) { + return k.getTimesFormat(format, delim, false, true) +} + +// StrictTimes parses with RFC3339 format and returns list of time.Time divided by given delimiter +// or error on first invalid input. +func (k *Key) StrictTimes(delim string) ([]time.Time, error) { + return k.StrictTimesFormat(time.RFC3339, delim) +} + +// getFloat64s returns list of float64 divided by given delimiter. +func (k *Key) getFloat64s(delim string, addInvalid, returnOnInvalid bool) ([]float64, error) { + strs := k.Strings(delim) + vals := make([]float64, 0, len(strs)) + for _, str := range strs { + val, err := strconv.ParseFloat(str, 64) + if err != nil && returnOnInvalid { + return nil, err + } + if err == nil || addInvalid { + vals = append(vals, val) + } + } + return vals, nil +} + +// getInts returns list of int divided by given delimiter. +func (k *Key) getInts(delim string, addInvalid, returnOnInvalid bool) ([]int, error) { + strs := k.Strings(delim) + vals := make([]int, 0, len(strs)) + for _, str := range strs { + val, err := strconv.Atoi(str) + if err != nil && returnOnInvalid { + return nil, err + } + if err == nil || addInvalid { + vals = append(vals, val) + } + } + return vals, nil +} + +// getInt64s returns list of int64 divided by given delimiter. +func (k *Key) getInt64s(delim string, addInvalid, returnOnInvalid bool) ([]int64, error) { + strs := k.Strings(delim) + vals := make([]int64, 0, len(strs)) + for _, str := range strs { + val, err := strconv.ParseInt(str, 10, 64) + if err != nil && returnOnInvalid { + return nil, err + } + if err == nil || addInvalid { + vals = append(vals, val) + } + } + return vals, nil +} + +// getUints returns list of uint divided by given delimiter. +func (k *Key) getUints(delim string, addInvalid, returnOnInvalid bool) ([]uint, error) { + strs := k.Strings(delim) + vals := make([]uint, 0, len(strs)) + for _, str := range strs { + val, err := strconv.ParseUint(str, 10, 0) + if err != nil && returnOnInvalid { + return nil, err + } + if err == nil || addInvalid { + vals = append(vals, uint(val)) + } + } + return vals, nil +} + +// getUint64s returns list of uint64 divided by given delimiter. +func (k *Key) getUint64s(delim string, addInvalid, returnOnInvalid bool) ([]uint64, error) { + strs := k.Strings(delim) + vals := make([]uint64, 0, len(strs)) + for _, str := range strs { + val, err := strconv.ParseUint(str, 10, 64) + if err != nil && returnOnInvalid { + return nil, err + } + if err == nil || addInvalid { + vals = append(vals, val) + } + } + return vals, nil +} + +// getTimesFormat parses with given format and returns list of time.Time divided by given delimiter. +func (k *Key) getTimesFormat(format, delim string, addInvalid, returnOnInvalid bool) ([]time.Time, error) { + strs := k.Strings(delim) + vals := make([]time.Time, 0, len(strs)) + for _, str := range strs { + val, err := time.Parse(format, str) + if err != nil && returnOnInvalid { + return nil, err + } + if err == nil || addInvalid { + vals = append(vals, val) + } + } + return vals, nil +} + +// SetValue changes key value. +func (k *Key) SetValue(v string) { + if k.s.f.BlockMode { + k.s.f.lock.Lock() + defer k.s.f.lock.Unlock() + } + + k.value = v + k.s.keysHash[k.name] = v +} diff --git a/vendor/github.com/go-ini/ini/parser.go b/vendor/github.com/go-ini/ini/parser.go new file mode 100644 index 0000000000..1c1bf91f0e --- /dev/null +++ b/vendor/github.com/go-ini/ini/parser.go @@ -0,0 +1,312 @@ +// Copyright 2015 Unknwon +// +// Licensed under the Apache License, Version 2.0 (the "License"): you may +// not use this file except in compliance with the License. You may obtain +// a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations +// under the License. + +package ini + +import ( + "bufio" + "bytes" + "fmt" + "io" + "strconv" + "strings" + "unicode" +) + +type tokenType int + +const ( + _TOKEN_INVALID tokenType = iota + _TOKEN_COMMENT + _TOKEN_SECTION + _TOKEN_KEY +) + +type parser struct { + buf *bufio.Reader + isEOF bool + count int + comment *bytes.Buffer +} + +func newParser(r io.Reader) *parser { + return &parser{ + buf: bufio.NewReader(r), + count: 1, + comment: &bytes.Buffer{}, + } +} + +// BOM handles header of BOM-UTF8 format. +// http://en.wikipedia.org/wiki/Byte_order_mark#Representations_of_byte_order_marks_by_encoding +func (p *parser) BOM() error { + mask, err := p.buf.Peek(3) + if err != nil && err != io.EOF { + return err + } else if len(mask) < 3 { + return nil + } else if mask[0] == 239 && mask[1] == 187 && mask[2] == 191 { + p.buf.Read(mask) + } + return nil +} + +func (p *parser) readUntil(delim byte) ([]byte, error) { + data, err := p.buf.ReadBytes(delim) + if err != nil { + if err == io.EOF { + p.isEOF = true + } else { + return nil, err + } + } + return data, nil +} + +func cleanComment(in []byte) ([]byte, bool) { + i := bytes.IndexAny(in, "#;") + if i == -1 { + return nil, false + } + return in[i:], true +} + +func readKeyName(in []byte) (string, int, error) { + line := string(in) + + // Check if key name surrounded by quotes. + var keyQuote string + if line[0] == '"' { + if len(line) > 6 && string(line[0:3]) == `"""` { + keyQuote = `"""` + } else { + keyQuote = `"` + } + } else if line[0] == '`' { + keyQuote = "`" + } + + // Get out key name + endIdx := -1 + if len(keyQuote) > 0 { + startIdx := len(keyQuote) + // FIXME: fail case -> """"""name"""=value + pos := strings.Index(line[startIdx:], keyQuote) + if pos == -1 { + return "", -1, fmt.Errorf("missing closing key quote: %s", line) + } + pos += startIdx + + // Find key-value delimiter + i := strings.IndexAny(line[pos+startIdx:], "=:") + if i < 0 { + return "", -1, fmt.Errorf("key-value delimiter not found: %s", line) + } + endIdx = pos + i + return strings.TrimSpace(line[startIdx:pos]), endIdx + startIdx + 1, nil + } + + endIdx = strings.IndexAny(line, "=:") + if endIdx < 0 { + return "", -1, fmt.Errorf("key-value delimiter not found: %s", line) + } + return strings.TrimSpace(line[0:endIdx]), endIdx + 1, nil +} + +func (p *parser) readMultilines(line, val, valQuote string) (string, error) { + for { + data, err := p.readUntil('\n') + if err != nil { + return "", err + } + next := string(data) + + pos := strings.LastIndex(next, valQuote) + if pos > -1 { + val += next[:pos] + + comment, has := cleanComment([]byte(next[pos:])) + if has { + p.comment.Write(bytes.TrimSpace(comment)) + } + break + } + val += next + if p.isEOF { + return "", fmt.Errorf("missing closing key quote from '%s' to '%s'", line, next) + } + } + return val, nil +} + +func (p *parser) readContinuationLines(val string) (string, error) { + for { + data, err := p.readUntil('\n') + if err != nil { + return "", err + } + next := strings.TrimSpace(string(data)) + + if len(next) == 0 { + break + } + val += next + if val[len(val)-1] != '\\' { + break + } + val = val[:len(val)-1] + } + return val, nil +} + +// hasSurroundedQuote check if and only if the first and last characters +// are quotes \" or \'. +// It returns false if any other parts also contain same kind of quotes. +func hasSurroundedQuote(in string, quote byte) bool { + return len(in) > 2 && in[0] == quote && in[len(in)-1] == quote && + strings.IndexByte(in[1:], quote) == len(in)-2 +} + +func (p *parser) readValue(in []byte) (string, error) { + line := strings.TrimLeftFunc(string(in), unicode.IsSpace) + if len(line) == 0 { + return "", nil + } + + var valQuote string + if len(line) > 3 && string(line[0:3]) == `"""` { + valQuote = `"""` + } else if line[0] == '`' { + valQuote = "`" + } + + if len(valQuote) > 0 { + startIdx := len(valQuote) + pos := strings.LastIndex(line[startIdx:], valQuote) + // Check for multi-line value + if pos == -1 { + return p.readMultilines(line, line[startIdx:], valQuote) + } + + return line[startIdx : pos+startIdx], nil + } + + // Won't be able to reach here if value only contains whitespace. + line = strings.TrimSpace(line) + + // Check continuation lines + if line[len(line)-1] == '\\' { + return p.readContinuationLines(line[:len(line)-1]) + } + + i := strings.IndexAny(line, "#;") + if i > -1 { + p.comment.WriteString(line[i:]) + line = strings.TrimSpace(line[:i]) + } + + // Trim single quotes + if hasSurroundedQuote(line, '\'') || + hasSurroundedQuote(line, '"') { + line = line[1 : len(line)-1] + } + return line, nil +} + +// parse parses data through an io.Reader. +func (f *File) parse(reader io.Reader) (err error) { + p := newParser(reader) + if err = p.BOM(); err != nil { + return fmt.Errorf("BOM: %v", err) + } + + // Ignore error because default section name is never empty string. + section, _ := f.NewSection(DEFAULT_SECTION) + + var line []byte + for !p.isEOF { + line, err = p.readUntil('\n') + if err != nil { + return err + } + + line = bytes.TrimLeftFunc(line, unicode.IsSpace) + if len(line) == 0 { + continue + } + + // Comments + if line[0] == '#' || line[0] == ';' { + // Note: we do not care ending line break, + // it is needed for adding second line, + // so just clean it once at the end when set to value. + p.comment.Write(line) + continue + } + + // Section + if line[0] == '[' { + // Read to the next ']' (TODO: support quoted strings) + closeIdx := bytes.IndexByte(line, ']') + if closeIdx == -1 { + return fmt.Errorf("unclosed section: %s", line) + } + + section, err = f.NewSection(string(line[1:closeIdx])) + if err != nil { + return err + } + + comment, has := cleanComment(line[closeIdx+1:]) + if has { + p.comment.Write(comment) + } + + section.Comment = strings.TrimSpace(p.comment.String()) + + // Reset aotu-counter and comments + p.comment.Reset() + p.count = 1 + continue + } + + kname, offset, err := readKeyName(line) + if err != nil { + return err + } + + // Auto increment. + isAutoIncr := false + if kname == "-" { + isAutoIncr = true + kname = "#" + strconv.Itoa(p.count) + p.count++ + } + + key, err := section.NewKey(kname, "") + if err != nil { + return err + } + key.isAutoIncr = isAutoIncr + + value, err := p.readValue(line[offset:]) + if err != nil { + return err + } + key.SetValue(value) + key.Comment = strings.TrimSpace(p.comment.String()) + p.comment.Reset() + } + return nil +} diff --git a/vendor/github.com/go-ini/ini/section.go b/vendor/github.com/go-ini/ini/section.go new file mode 100644 index 0000000000..ed8cbdb54a --- /dev/null +++ b/vendor/github.com/go-ini/ini/section.go @@ -0,0 +1,177 @@ +// Copyright 2014 Unknwon +// +// Licensed under the Apache License, Version 2.0 (the "License"): you may +// not use this file except in compliance with the License. You may obtain +// a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations +// under the License. + +package ini + +import ( + "errors" + "fmt" + "strings" +) + +// Section represents a config section. +type Section struct { + f *File + Comment string + name string + keys map[string]*Key + keyList []string + keysHash map[string]string +} + +func newSection(f *File, name string) *Section { + return &Section{f, "", name, make(map[string]*Key), make([]string, 0, 10), make(map[string]string)} +} + +// Name returns name of Section. +func (s *Section) Name() string { + return s.name +} + +// NewKey creates a new key to given section. +func (s *Section) NewKey(name, val string) (*Key, error) { + if len(name) == 0 { + return nil, errors.New("error creating new key: empty key name") + } + + if s.f.BlockMode { + s.f.lock.Lock() + defer s.f.lock.Unlock() + } + + if inSlice(name, s.keyList) { + s.keys[name].value = val + return s.keys[name], nil + } + + s.keyList = append(s.keyList, name) + s.keys[name] = &Key{s, "", name, val, false} + s.keysHash[name] = val + return s.keys[name], nil +} + +// GetKey returns key in section by given name. +func (s *Section) GetKey(name string) (*Key, error) { + // FIXME: change to section level lock? + if s.f.BlockMode { + s.f.lock.RLock() + } + key := s.keys[name] + if s.f.BlockMode { + s.f.lock.RUnlock() + } + + if key == nil { + // Check if it is a child-section. + sname := s.name + for { + if i := strings.LastIndex(sname, "."); i > -1 { + sname = sname[:i] + sec, err := s.f.GetSection(sname) + if err != nil { + continue + } + return sec.GetKey(name) + } else { + break + } + } + return nil, fmt.Errorf("error when getting key of section '%s': key '%s' not exists", s.name, name) + } + return key, nil +} + +// HasKey returns true if section contains a key with given name. +func (s *Section) HasKey(name string) bool { + key, _ := s.GetKey(name) + return key != nil +} + +// Haskey is a backwards-compatible name for HasKey. +func (s *Section) Haskey(name string) bool { + return s.HasKey(name) +} + +// HasValue returns true if section contains given raw value. +func (s *Section) HasValue(value string) bool { + if s.f.BlockMode { + s.f.lock.RLock() + defer s.f.lock.RUnlock() + } + + for _, k := range s.keys { + if value == k.value { + return true + } + } + return false +} + +// Key assumes named Key exists in section and returns a zero-value when not. +func (s *Section) Key(name string) *Key { + key, err := s.GetKey(name) + if err != nil { + // It's OK here because the only possible error is empty key name, + // but if it's empty, this piece of code won't be executed. + key, _ = s.NewKey(name, "") + return key + } + return key +} + +// Keys returns list of keys of section. +func (s *Section) Keys() []*Key { + keys := make([]*Key, len(s.keyList)) + for i := range s.keyList { + keys[i] = s.Key(s.keyList[i]) + } + return keys +} + +// KeyStrings returns list of key names of section. +func (s *Section) KeyStrings() []string { + list := make([]string, len(s.keyList)) + copy(list, s.keyList) + return list +} + +// KeysHash returns keys hash consisting of names and values. +func (s *Section) KeysHash() map[string]string { + if s.f.BlockMode { + s.f.lock.RLock() + defer s.f.lock.RUnlock() + } + + hash := map[string]string{} + for key, value := range s.keysHash { + hash[key] = value + } + return hash +} + +// DeleteKey deletes a key from section. +func (s *Section) DeleteKey(name string) { + if s.f.BlockMode { + s.f.lock.Lock() + defer s.f.lock.Unlock() + } + + for i, k := range s.keyList { + if k == name { + s.keyList = append(s.keyList[:i], s.keyList[i+1:]...) + delete(s.keys, name) + return + } + } +} diff --git a/vendor/github.com/go-ini/ini/struct.go b/vendor/github.com/go-ini/ini/struct.go new file mode 100644 index 0000000000..3fb92c3962 --- /dev/null +++ b/vendor/github.com/go-ini/ini/struct.go @@ -0,0 +1,351 @@ +// Copyright 2014 Unknwon +// +// Licensed under the Apache License, Version 2.0 (the "License"): you may +// not use this file except in compliance with the License. You may obtain +// a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations +// under the License. + +package ini + +import ( + "bytes" + "errors" + "fmt" + "reflect" + "time" + "unicode" +) + +// NameMapper represents a ini tag name mapper. +type NameMapper func(string) string + +// Built-in name getters. +var ( + // AllCapsUnderscore converts to format ALL_CAPS_UNDERSCORE. + AllCapsUnderscore NameMapper = func(raw string) string { + newstr := make([]rune, 0, len(raw)) + for i, chr := range raw { + if isUpper := 'A' <= chr && chr <= 'Z'; isUpper { + if i > 0 { + newstr = append(newstr, '_') + } + } + newstr = append(newstr, unicode.ToUpper(chr)) + } + return string(newstr) + } + // TitleUnderscore converts to format title_underscore. + TitleUnderscore NameMapper = func(raw string) string { + newstr := make([]rune, 0, len(raw)) + for i, chr := range raw { + if isUpper := 'A' <= chr && chr <= 'Z'; isUpper { + if i > 0 { + newstr = append(newstr, '_') + } + chr -= ('A' - 'a') + } + newstr = append(newstr, chr) + } + return string(newstr) + } +) + +func (s *Section) parseFieldName(raw, actual string) string { + if len(actual) > 0 { + return actual + } + if s.f.NameMapper != nil { + return s.f.NameMapper(raw) + } + return raw +} + +func parseDelim(actual string) string { + if len(actual) > 0 { + return actual + } + return "," +} + +var reflectTime = reflect.TypeOf(time.Now()).Kind() + +// setWithProperType sets proper value to field based on its type, +// but it does not return error for failing parsing, +// because we want to use default value that is already assigned to strcut. +func setWithProperType(t reflect.Type, key *Key, field reflect.Value, delim string) error { + switch t.Kind() { + case reflect.String: + if len(key.String()) == 0 { + return nil + } + field.SetString(key.String()) + case reflect.Bool: + boolVal, err := key.Bool() + if err != nil { + return nil + } + field.SetBool(boolVal) + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + durationVal, err := key.Duration() + // Skip zero value + if err == nil && int(durationVal) > 0 { + field.Set(reflect.ValueOf(durationVal)) + return nil + } + + intVal, err := key.Int64() + if err != nil || intVal == 0 { + return nil + } + field.SetInt(intVal) + // byte is an alias for uint8, so supporting uint8 breaks support for byte + case reflect.Uint, reflect.Uint16, reflect.Uint32, reflect.Uint64: + durationVal, err := key.Duration() + if err == nil { + field.Set(reflect.ValueOf(durationVal)) + return nil + } + + uintVal, err := key.Uint64() + if err != nil { + return nil + } + field.SetUint(uintVal) + + case reflect.Float64: + floatVal, err := key.Float64() + if err != nil { + return nil + } + field.SetFloat(floatVal) + case reflectTime: + timeVal, err := key.Time() + if err != nil { + return nil + } + field.Set(reflect.ValueOf(timeVal)) + case reflect.Slice: + vals := key.Strings(delim) + numVals := len(vals) + if numVals == 0 { + return nil + } + + sliceOf := field.Type().Elem().Kind() + + var times []time.Time + if sliceOf == reflectTime { + times = key.Times(delim) + } + + slice := reflect.MakeSlice(field.Type(), numVals, numVals) + for i := 0; i < numVals; i++ { + switch sliceOf { + case reflectTime: + slice.Index(i).Set(reflect.ValueOf(times[i])) + default: + slice.Index(i).Set(reflect.ValueOf(vals[i])) + } + } + field.Set(slice) + default: + return fmt.Errorf("unsupported type '%s'", t) + } + return nil +} + +func (s *Section) mapTo(val reflect.Value) error { + if val.Kind() == reflect.Ptr { + val = val.Elem() + } + typ := val.Type() + + for i := 0; i < typ.NumField(); i++ { + field := val.Field(i) + tpField := typ.Field(i) + + tag := tpField.Tag.Get("ini") + if tag == "-" { + continue + } + + fieldName := s.parseFieldName(tpField.Name, tag) + if len(fieldName) == 0 || !field.CanSet() { + continue + } + + isAnonymous := tpField.Type.Kind() == reflect.Ptr && tpField.Anonymous + isStruct := tpField.Type.Kind() == reflect.Struct + if isAnonymous { + field.Set(reflect.New(tpField.Type.Elem())) + } + + if isAnonymous || isStruct { + if sec, err := s.f.GetSection(fieldName); err == nil { + if err = sec.mapTo(field); err != nil { + return fmt.Errorf("error mapping field(%s): %v", fieldName, err) + } + continue + } + } + + if key, err := s.GetKey(fieldName); err == nil { + if err = setWithProperType(tpField.Type, key, field, parseDelim(tpField.Tag.Get("delim"))); err != nil { + return fmt.Errorf("error mapping field(%s): %v", fieldName, err) + } + } + } + return nil +} + +// MapTo maps section to given struct. +func (s *Section) MapTo(v interface{}) error { + typ := reflect.TypeOf(v) + val := reflect.ValueOf(v) + if typ.Kind() == reflect.Ptr { + typ = typ.Elem() + val = val.Elem() + } else { + return errors.New("cannot map to non-pointer struct") + } + + return s.mapTo(val) +} + +// MapTo maps file to given struct. +func (f *File) MapTo(v interface{}) error { + return f.Section("").MapTo(v) +} + +// MapTo maps data sources to given struct with name mapper. +func MapToWithMapper(v interface{}, mapper NameMapper, source interface{}, others ...interface{}) error { + cfg, err := Load(source, others...) + if err != nil { + return err + } + cfg.NameMapper = mapper + return cfg.MapTo(v) +} + +// MapTo maps data sources to given struct. +func MapTo(v, source interface{}, others ...interface{}) error { + return MapToWithMapper(v, nil, source, others...) +} + +// reflectWithProperType does the opposite thing with setWithProperType. +func reflectWithProperType(t reflect.Type, key *Key, field reflect.Value, delim string) error { + switch t.Kind() { + case reflect.String: + key.SetValue(field.String()) + case reflect.Bool, + reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, + reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, + reflect.Float64, + reflectTime: + key.SetValue(fmt.Sprint(field)) + case reflect.Slice: + vals := field.Slice(0, field.Len()) + if field.Len() == 0 { + return nil + } + + var buf bytes.Buffer + isTime := fmt.Sprint(field.Type()) == "[]time.Time" + for i := 0; i < field.Len(); i++ { + if isTime { + buf.WriteString(vals.Index(i).Interface().(time.Time).Format(time.RFC3339)) + } else { + buf.WriteString(fmt.Sprint(vals.Index(i))) + } + buf.WriteString(delim) + } + key.SetValue(buf.String()[:buf.Len()-1]) + default: + return fmt.Errorf("unsupported type '%s'", t) + } + return nil +} + +func (s *Section) reflectFrom(val reflect.Value) error { + if val.Kind() == reflect.Ptr { + val = val.Elem() + } + typ := val.Type() + + for i := 0; i < typ.NumField(); i++ { + field := val.Field(i) + tpField := typ.Field(i) + + tag := tpField.Tag.Get("ini") + if tag == "-" { + continue + } + + fieldName := s.parseFieldName(tpField.Name, tag) + if len(fieldName) == 0 || !field.CanSet() { + continue + } + + if (tpField.Type.Kind() == reflect.Ptr && tpField.Anonymous) || + (tpField.Type.Kind() == reflect.Struct) { + // Note: The only error here is section doesn't exist. + sec, err := s.f.GetSection(fieldName) + if err != nil { + // Note: fieldName can never be empty here, ignore error. + sec, _ = s.f.NewSection(fieldName) + } + if err = sec.reflectFrom(field); err != nil { + return fmt.Errorf("error reflecting field(%s): %v", fieldName, err) + } + continue + } + + // Note: Same reason as secion. + key, err := s.GetKey(fieldName) + if err != nil { + key, _ = s.NewKey(fieldName, "") + } + if err = reflectWithProperType(tpField.Type, key, field, parseDelim(tpField.Tag.Get("delim"))); err != nil { + return fmt.Errorf("error reflecting field(%s): %v", fieldName, err) + } + + } + return nil +} + +// ReflectFrom reflects secion from given struct. +func (s *Section) ReflectFrom(v interface{}) error { + typ := reflect.TypeOf(v) + val := reflect.ValueOf(v) + if typ.Kind() == reflect.Ptr { + typ = typ.Elem() + val = val.Elem() + } else { + return errors.New("cannot reflect from non-pointer struct") + } + + return s.reflectFrom(val) +} + +// ReflectFrom reflects file from given struct. +func (f *File) ReflectFrom(v interface{}) error { + return f.Section("").ReflectFrom(v) +} + +// ReflectFrom reflects data sources from given struct with name mapper. +func ReflectFromWithMapper(cfg *File, v interface{}, mapper NameMapper) error { + cfg.NameMapper = mapper + return cfg.ReflectFrom(v) +} + +// ReflectFrom reflects data sources from given struct. +func ReflectFrom(cfg *File, v interface{}) error { + return ReflectFromWithMapper(cfg, v, nil) +} diff --git a/vendor/github.com/go-ole/go-ole/com.go b/vendor/github.com/go-ole/go-ole/com.go new file mode 100644 index 0000000000..f224fa069a --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/com.go @@ -0,0 +1,329 @@ +// +build windows + +package ole + +import ( + "errors" + "syscall" + "time" + "unicode/utf16" + "unsafe" +) + +var ( + procCoInitialize, _ = modole32.FindProc("CoInitialize") + procCoInitializeEx, _ = modole32.FindProc("CoInitializeEx") + procCoUninitialize, _ = modole32.FindProc("CoUninitialize") + procCoCreateInstance, _ = modole32.FindProc("CoCreateInstance") + procCoTaskMemFree, _ = modole32.FindProc("CoTaskMemFree") + procCLSIDFromProgID, _ = modole32.FindProc("CLSIDFromProgID") + procCLSIDFromString, _ = modole32.FindProc("CLSIDFromString") + procStringFromCLSID, _ = modole32.FindProc("StringFromCLSID") + procStringFromIID, _ = modole32.FindProc("StringFromIID") + procIIDFromString, _ = modole32.FindProc("IIDFromString") + procGetUserDefaultLCID, _ = modkernel32.FindProc("GetUserDefaultLCID") + procCopyMemory, _ = modkernel32.FindProc("RtlMoveMemory") + procVariantInit, _ = modoleaut32.FindProc("VariantInit") + procVariantClear, _ = modoleaut32.FindProc("VariantClear") + procVariantTimeToSystemTime, _ = modoleaut32.FindProc("VariantTimeToSystemTime") + procSysAllocString, _ = modoleaut32.FindProc("SysAllocString") + procSysAllocStringLen, _ = modoleaut32.FindProc("SysAllocStringLen") + procSysFreeString, _ = modoleaut32.FindProc("SysFreeString") + procSysStringLen, _ = modoleaut32.FindProc("SysStringLen") + procCreateDispTypeInfo, _ = modoleaut32.FindProc("CreateDispTypeInfo") + procCreateStdDispatch, _ = modoleaut32.FindProc("CreateStdDispatch") + procGetActiveObject, _ = modoleaut32.FindProc("GetActiveObject") + + procGetMessageW, _ = moduser32.FindProc("GetMessageW") + procDispatchMessageW, _ = moduser32.FindProc("DispatchMessageW") +) + +// coInitialize initializes COM library on current thread. +// +// MSDN documentation suggests that this function should not be called. Call +// CoInitializeEx() instead. The reason has to do with threading and this +// function is only for single-threaded apartments. +// +// That said, most users of the library have gotten away with just this +// function. If you are experiencing threading issues, then use +// CoInitializeEx(). +func coInitialize() (err error) { + // http://msdn.microsoft.com/en-us/library/windows/desktop/ms678543(v=vs.85).aspx + // Suggests that no value should be passed to CoInitialized. + // Could just be Call() since the parameter is optional. <-- Needs testing to be sure. + hr, _, _ := procCoInitialize.Call(uintptr(0)) + if hr != 0 { + err = NewError(hr) + } + return +} + +// coInitializeEx initializes COM library with concurrency model. +func coInitializeEx(coinit uint32) (err error) { + // http://msdn.microsoft.com/en-us/library/windows/desktop/ms695279(v=vs.85).aspx + // Suggests that the first parameter is not only optional but should always be NULL. + hr, _, _ := procCoInitializeEx.Call(uintptr(0), uintptr(coinit)) + if hr != 0 { + err = NewError(hr) + } + return +} + +// CoInitialize initializes COM library on current thread. +// +// MSDN documentation suggests that this function should not be called. Call +// CoInitializeEx() instead. The reason has to do with threading and this +// function is only for single-threaded apartments. +// +// That said, most users of the library have gotten away with just this +// function. If you are experiencing threading issues, then use +// CoInitializeEx(). +func CoInitialize(p uintptr) (err error) { + // p is ignored and won't be used. + // Avoid any variable not used errors. + p = uintptr(0) + return coInitialize() +} + +// CoInitializeEx initializes COM library with concurrency model. +func CoInitializeEx(p uintptr, coinit uint32) (err error) { + // Avoid any variable not used errors. + p = uintptr(0) + return coInitializeEx(coinit) +} + +// CoUninitialize uninitializes COM Library. +func CoUninitialize() { + procCoUninitialize.Call() +} + +// CoTaskMemFree frees memory pointer. +func CoTaskMemFree(memptr uintptr) { + procCoTaskMemFree.Call(memptr) +} + +// CLSIDFromProgID retrieves Class Identifier with the given Program Identifier. +// +// The Programmatic Identifier must be registered, because it will be looked up +// in the Windows Registry. The registry entry has the following keys: CLSID, +// Insertable, Protocol and Shell +// (https://msdn.microsoft.com/en-us/library/dd542719(v=vs.85).aspx). +// +// programID identifies the class id with less precision and is not guaranteed +// to be unique. These are usually found in the registry under +// HKEY_LOCAL_MACHINE\SOFTWARE\Classes, usually with the format of +// "Program.Component.Version" with version being optional. +// +// CLSIDFromProgID in Windows API. +func CLSIDFromProgID(progId string) (clsid *GUID, err error) { + var guid GUID + lpszProgID := uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(progId))) + hr, _, _ := procCLSIDFromProgID.Call(lpszProgID, uintptr(unsafe.Pointer(&guid))) + if hr != 0 { + err = NewError(hr) + } + clsid = &guid + return +} + +// CLSIDFromString retrieves Class ID from string representation. +// +// This is technically the string version of the GUID and will convert the +// string to object. +// +// CLSIDFromString in Windows API. +func CLSIDFromString(str string) (clsid *GUID, err error) { + var guid GUID + lpsz := uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(str))) + hr, _, _ := procCLSIDFromString.Call(lpsz, uintptr(unsafe.Pointer(&guid))) + if hr != 0 { + err = NewError(hr) + } + clsid = &guid + return +} + +// StringFromCLSID returns GUID formated string from GUID object. +func StringFromCLSID(clsid *GUID) (str string, err error) { + var p *uint16 + hr, _, _ := procStringFromCLSID.Call(uintptr(unsafe.Pointer(clsid)), uintptr(unsafe.Pointer(&p))) + if hr != 0 { + err = NewError(hr) + } + str = LpOleStrToString(p) + return +} + +// IIDFromString returns GUID from program ID. +func IIDFromString(progId string) (clsid *GUID, err error) { + var guid GUID + lpsz := uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(progId))) + hr, _, _ := procIIDFromString.Call(lpsz, uintptr(unsafe.Pointer(&guid))) + if hr != 0 { + err = NewError(hr) + } + clsid = &guid + return +} + +// StringFromIID returns GUID formatted string from GUID object. +func StringFromIID(iid *GUID) (str string, err error) { + var p *uint16 + hr, _, _ := procStringFromIID.Call(uintptr(unsafe.Pointer(iid)), uintptr(unsafe.Pointer(&p))) + if hr != 0 { + err = NewError(hr) + } + str = LpOleStrToString(p) + return +} + +// CreateInstance of single uninitialized object with GUID. +func CreateInstance(clsid *GUID, iid *GUID) (unk *IUnknown, err error) { + if iid == nil { + iid = IID_IUnknown + } + hr, _, _ := procCoCreateInstance.Call( + uintptr(unsafe.Pointer(clsid)), + 0, + CLSCTX_SERVER, + uintptr(unsafe.Pointer(iid)), + uintptr(unsafe.Pointer(&unk))) + if hr != 0 { + err = NewError(hr) + } + return +} + +// GetActiveObject retrieves pointer to active object. +func GetActiveObject(clsid *GUID, iid *GUID) (unk *IUnknown, err error) { + if iid == nil { + iid = IID_IUnknown + } + hr, _, _ := procGetActiveObject.Call( + uintptr(unsafe.Pointer(clsid)), + uintptr(unsafe.Pointer(iid)), + uintptr(unsafe.Pointer(&unk))) + if hr != 0 { + err = NewError(hr) + } + return +} + +// VariantInit initializes variant. +func VariantInit(v *VARIANT) (err error) { + hr, _, _ := procVariantInit.Call(uintptr(unsafe.Pointer(v))) + if hr != 0 { + err = NewError(hr) + } + return +} + +// VariantClear clears value in Variant settings to VT_EMPTY. +func VariantClear(v *VARIANT) (err error) { + hr, _, _ := procVariantClear.Call(uintptr(unsafe.Pointer(v))) + if hr != 0 { + err = NewError(hr) + } + return +} + +// SysAllocString allocates memory for string and copies string into memory. +func SysAllocString(v string) (ss *int16) { + pss, _, _ := procSysAllocString.Call(uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(v)))) + ss = (*int16)(unsafe.Pointer(pss)) + return +} + +// SysAllocStringLen copies up to length of given string returning pointer. +func SysAllocStringLen(v string) (ss *int16) { + utf16 := utf16.Encode([]rune(v + "\x00")) + ptr := &utf16[0] + + pss, _, _ := procSysAllocStringLen.Call(uintptr(unsafe.Pointer(ptr)), uintptr(len(utf16)-1)) + ss = (*int16)(unsafe.Pointer(pss)) + return +} + +// SysFreeString frees string system memory. This must be called with SysAllocString. +func SysFreeString(v *int16) (err error) { + hr, _, _ := procSysFreeString.Call(uintptr(unsafe.Pointer(v))) + if hr != 0 { + err = NewError(hr) + } + return +} + +// SysStringLen is the length of the system allocated string. +func SysStringLen(v *int16) uint32 { + l, _, _ := procSysStringLen.Call(uintptr(unsafe.Pointer(v))) + return uint32(l) +} + +// CreateStdDispatch provides default IDispatch implementation for IUnknown. +// +// This handles default IDispatch implementation for objects. It haves a few +// limitations with only supporting one language. It will also only return +// default exception codes. +func CreateStdDispatch(unk *IUnknown, v uintptr, ptinfo *IUnknown) (disp *IDispatch, err error) { + hr, _, _ := procCreateStdDispatch.Call( + uintptr(unsafe.Pointer(unk)), + v, + uintptr(unsafe.Pointer(ptinfo)), + uintptr(unsafe.Pointer(&disp))) + if hr != 0 { + err = NewError(hr) + } + return +} + +// CreateDispTypeInfo provides default ITypeInfo implementation for IDispatch. +// +// This will not handle the full implementation of the interface. +func CreateDispTypeInfo(idata *INTERFACEDATA) (pptinfo *IUnknown, err error) { + hr, _, _ := procCreateDispTypeInfo.Call( + uintptr(unsafe.Pointer(idata)), + uintptr(GetUserDefaultLCID()), + uintptr(unsafe.Pointer(&pptinfo))) + if hr != 0 { + err = NewError(hr) + } + return +} + +// copyMemory moves location of a block of memory. +func copyMemory(dest unsafe.Pointer, src unsafe.Pointer, length uint32) { + procCopyMemory.Call(uintptr(dest), uintptr(src), uintptr(length)) +} + +// GetUserDefaultLCID retrieves current user default locale. +func GetUserDefaultLCID() (lcid uint32) { + ret, _, _ := procGetUserDefaultLCID.Call() + lcid = uint32(ret) + return +} + +// GetMessage in message queue from runtime. +// +// This function appears to block. PeekMessage does not block. +func GetMessage(msg *Msg, hwnd uint32, MsgFilterMin uint32, MsgFilterMax uint32) (ret int32, err error) { + r0, _, err := procGetMessageW.Call(uintptr(unsafe.Pointer(msg)), uintptr(hwnd), uintptr(MsgFilterMin), uintptr(MsgFilterMax)) + ret = int32(r0) + return +} + +// DispatchMessage to window procedure. +func DispatchMessage(msg *Msg) (ret int32) { + r0, _, _ := procDispatchMessageW.Call(uintptr(unsafe.Pointer(msg))) + ret = int32(r0) + return +} + +// GetVariantDate converts COM Variant Time value to Go time.Time. +func GetVariantDate(value float64) (time.Time, error) { + var st syscall.Systemtime + r, _, _ := procVariantTimeToSystemTime.Call(uintptr(unsafe.Pointer(&value)), uintptr(unsafe.Pointer(&st))) + if r != 0 { + return time.Date(int(st.Year), time.Month(st.Month), int(st.Day), int(st.Hour), int(st.Minute), int(st.Second), int(st.Milliseconds/1000), nil), nil + } + return time.Now(), errors.New("Could not convert to time, passing current time.") +} diff --git a/vendor/github.com/go-ole/go-ole/com_func.go b/vendor/github.com/go-ole/go-ole/com_func.go new file mode 100644 index 0000000000..425aad3233 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/com_func.go @@ -0,0 +1,174 @@ +// +build !windows + +package ole + +import ( + "time" + "unsafe" +) + +// coInitialize initializes COM library on current thread. +// +// MSDN documentation suggests that this function should not be called. Call +// CoInitializeEx() instead. The reason has to do with threading and this +// function is only for single-threaded apartments. +// +// That said, most users of the library have gotten away with just this +// function. If you are experiencing threading issues, then use +// CoInitializeEx(). +func coInitialize() error { + return NewError(E_NOTIMPL) +} + +// coInitializeEx initializes COM library with concurrency model. +func coInitializeEx(coinit uint32) error { + return NewError(E_NOTIMPL) +} + +// CoInitialize initializes COM library on current thread. +// +// MSDN documentation suggests that this function should not be called. Call +// CoInitializeEx() instead. The reason has to do with threading and this +// function is only for single-threaded apartments. +// +// That said, most users of the library have gotten away with just this +// function. If you are experiencing threading issues, then use +// CoInitializeEx(). +func CoInitialize(p uintptr) error { + return NewError(E_NOTIMPL) +} + +// CoInitializeEx initializes COM library with concurrency model. +func CoInitializeEx(p uintptr, coinit uint32) error { + return NewError(E_NOTIMPL) +} + +// CoUninitialize uninitializes COM Library. +func CoUninitialize() {} + +// CoTaskMemFree frees memory pointer. +func CoTaskMemFree(memptr uintptr) {} + +// CLSIDFromProgID retrieves Class Identifier with the given Program Identifier. +// +// The Programmatic Identifier must be registered, because it will be looked up +// in the Windows Registry. The registry entry has the following keys: CLSID, +// Insertable, Protocol and Shell +// (https://msdn.microsoft.com/en-us/library/dd542719(v=vs.85).aspx). +// +// programID identifies the class id with less precision and is not guaranteed +// to be unique. These are usually found in the registry under +// HKEY_LOCAL_MACHINE\SOFTWARE\Classes, usually with the format of +// "Program.Component.Version" with version being optional. +// +// CLSIDFromProgID in Windows API. +func CLSIDFromProgID(progId string) (*GUID, error) { + return nil, NewError(E_NOTIMPL) +} + +// CLSIDFromString retrieves Class ID from string representation. +// +// This is technically the string version of the GUID and will convert the +// string to object. +// +// CLSIDFromString in Windows API. +func CLSIDFromString(str string) (*GUID, error) { + return nil, NewError(E_NOTIMPL) +} + +// StringFromCLSID returns GUID formated string from GUID object. +func StringFromCLSID(clsid *GUID) (string, error) { + return "", NewError(E_NOTIMPL) +} + +// IIDFromString returns GUID from program ID. +func IIDFromString(progId string) (*GUID, error) { + return nil, NewError(E_NOTIMPL) +} + +// StringFromIID returns GUID formatted string from GUID object. +func StringFromIID(iid *GUID) (string, error) { + return "", NewError(E_NOTIMPL) +} + +// CreateInstance of single uninitialized object with GUID. +func CreateInstance(clsid *GUID, iid *GUID) (*IUnknown, error) { + return nil, NewError(E_NOTIMPL) +} + +// GetActiveObject retrieves pointer to active object. +func GetActiveObject(clsid *GUID, iid *GUID) (*IUnknown, error) { + return nil, NewError(E_NOTIMPL) +} + +// VariantInit initializes variant. +func VariantInit(v *VARIANT) error { + return NewError(E_NOTIMPL) +} + +// VariantClear clears value in Variant settings to VT_EMPTY. +func VariantClear(v *VARIANT) error { + return NewError(E_NOTIMPL) +} + +// SysAllocString allocates memory for string and copies string into memory. +func SysAllocString(v string) *int16 { + u := int16(0) + return &u +} + +// SysAllocStringLen copies up to length of given string returning pointer. +func SysAllocStringLen(v string) *int16 { + u := int16(0) + return &u +} + +// SysFreeString frees string system memory. This must be called with SysAllocString. +func SysFreeString(v *int16) error { + return NewError(E_NOTIMPL) +} + +// SysStringLen is the length of the system allocated string. +func SysStringLen(v *int16) uint32 { + return uint32(0) +} + +// CreateStdDispatch provides default IDispatch implementation for IUnknown. +// +// This handles default IDispatch implementation for objects. It haves a few +// limitations with only supporting one language. It will also only return +// default exception codes. +func CreateStdDispatch(unk *IUnknown, v uintptr, ptinfo *IUnknown) (*IDispatch, error) { + return nil, NewError(E_NOTIMPL) +} + +// CreateDispTypeInfo provides default ITypeInfo implementation for IDispatch. +// +// This will not handle the full implementation of the interface. +func CreateDispTypeInfo(idata *INTERFACEDATA) (*IUnknown, error) { + return nil, NewError(E_NOTIMPL) +} + +// copyMemory moves location of a block of memory. +func copyMemory(dest unsafe.Pointer, src unsafe.Pointer, length uint32) {} + +// GetUserDefaultLCID retrieves current user default locale. +func GetUserDefaultLCID() uint32 { + return uint32(0) +} + +// GetMessage in message queue from runtime. +// +// This function appears to block. PeekMessage does not block. +func GetMessage(msg *Msg, hwnd uint32, MsgFilterMin uint32, MsgFilterMax uint32) (int32, error) { + return int32(0), NewError(E_NOTIMPL) +} + +// DispatchMessage to window procedure. +func DispatchMessage(msg *Msg) int32 { + return int32(0) +} + +func GetVariantDate(value float64) (time.Time, error) { + return time.Now(), NewError(E_NOTIMPL) +} diff --git a/vendor/github.com/go-ole/go-ole/connect.go b/vendor/github.com/go-ole/go-ole/connect.go new file mode 100644 index 0000000000..b2ac2ec67a --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/connect.go @@ -0,0 +1,192 @@ +package ole + +// Connection contains IUnknown for fluent interface interaction. +// +// Deprecated. Use oleutil package instead. +type Connection struct { + Object *IUnknown // Access COM +} + +// Initialize COM. +func (*Connection) Initialize() (err error) { + return coInitialize() +} + +// Uninitialize COM. +func (*Connection) Uninitialize() { + CoUninitialize() +} + +// Create IUnknown object based first on ProgId and then from String. +func (c *Connection) Create(progId string) (err error) { + var clsid *GUID + clsid, err = CLSIDFromProgID(progId) + if err != nil { + clsid, err = CLSIDFromString(progId) + if err != nil { + return + } + } + + unknown, err := CreateInstance(clsid, IID_IUnknown) + if err != nil { + return + } + c.Object = unknown + + return +} + +// Release IUnknown object. +func (c *Connection) Release() { + c.Object.Release() +} + +// Load COM object from list of programIDs or strings. +func (c *Connection) Load(names ...string) (errors []error) { + var tempErrors []error = make([]error, len(names)) + var numErrors int = 0 + for _, name := range names { + err := c.Create(name) + if err != nil { + tempErrors = append(tempErrors, err) + numErrors += 1 + continue + } + break + } + + copy(errors, tempErrors[0:numErrors]) + return +} + +// Dispatch returns Dispatch object. +func (c *Connection) Dispatch() (object *Dispatch, err error) { + dispatch, err := c.Object.QueryInterface(IID_IDispatch) + if err != nil { + return + } + object = &Dispatch{dispatch} + return +} + +// Dispatch stores IDispatch object. +type Dispatch struct { + Object *IDispatch // Dispatch object. +} + +// Call method on IDispatch with parameters. +func (d *Dispatch) Call(method string, params ...interface{}) (result *VARIANT, err error) { + id, err := d.GetId(method) + if err != nil { + return + } + + result, err = d.Invoke(id, DISPATCH_METHOD, params) + return +} + +// MustCall method on IDispatch with parameters. +func (d *Dispatch) MustCall(method string, params ...interface{}) (result *VARIANT) { + id, err := d.GetId(method) + if err != nil { + panic(err) + } + + result, err = d.Invoke(id, DISPATCH_METHOD, params) + if err != nil { + panic(err) + } + + return +} + +// Get property on IDispatch with parameters. +func (d *Dispatch) Get(name string, params ...interface{}) (result *VARIANT, err error) { + id, err := d.GetId(name) + if err != nil { + return + } + result, err = d.Invoke(id, DISPATCH_PROPERTYGET, params) + return +} + +// MustGet property on IDispatch with parameters. +func (d *Dispatch) MustGet(name string, params ...interface{}) (result *VARIANT) { + id, err := d.GetId(name) + if err != nil { + panic(err) + } + + result, err = d.Invoke(id, DISPATCH_PROPERTYGET, params) + if err != nil { + panic(err) + } + return +} + +// Set property on IDispatch with parameters. +func (d *Dispatch) Set(name string, params ...interface{}) (result *VARIANT, err error) { + id, err := d.GetId(name) + if err != nil { + return + } + result, err = d.Invoke(id, DISPATCH_PROPERTYPUT, params) + return +} + +// MustSet property on IDispatch with parameters. +func (d *Dispatch) MustSet(name string, params ...interface{}) (result *VARIANT) { + id, err := d.GetId(name) + if err != nil { + panic(err) + } + + result, err = d.Invoke(id, DISPATCH_PROPERTYPUT, params) + if err != nil { + panic(err) + } + return +} + +// GetId retrieves ID of name on IDispatch. +func (d *Dispatch) GetId(name string) (id int32, err error) { + var dispid []int32 + dispid, err = d.Object.GetIDsOfName([]string{name}) + if err != nil { + return + } + id = dispid[0] + return +} + +// GetIds retrieves all IDs of names on IDispatch. +func (d *Dispatch) GetIds(names ...string) (dispid []int32, err error) { + dispid, err = d.Object.GetIDsOfName(names) + return +} + +// Invoke IDispatch on DisplayID of dispatch type with parameters. +// +// There have been problems where if send cascading params..., it would error +// out because the parameters would be empty. +func (d *Dispatch) Invoke(id int32, dispatch int16, params []interface{}) (result *VARIANT, err error) { + if len(params) < 1 { + result, err = d.Object.Invoke(id, dispatch) + } else { + result, err = d.Object.Invoke(id, dispatch, params...) + } + return +} + +// Release IDispatch object. +func (d *Dispatch) Release() { + d.Object.Release() +} + +// Connect initializes COM and attempts to load IUnknown based on given names. +func Connect(names ...string) (connection *Connection) { + connection.Initialize() + connection.Load(names...) + return +} diff --git a/vendor/github.com/go-ole/go-ole/constants.go b/vendor/github.com/go-ole/go-ole/constants.go new file mode 100644 index 0000000000..fd0c6d74b0 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/constants.go @@ -0,0 +1,153 @@ +package ole + +const ( + CLSCTX_INPROC_SERVER = 1 + CLSCTX_INPROC_HANDLER = 2 + CLSCTX_LOCAL_SERVER = 4 + CLSCTX_INPROC_SERVER16 = 8 + CLSCTX_REMOTE_SERVER = 16 + CLSCTX_ALL = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER + CLSCTX_INPROC = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER + CLSCTX_SERVER = CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER +) + +const ( + COINIT_APARTMENTTHREADED = 0x2 + COINIT_MULTITHREADED = 0x0 + COINIT_DISABLE_OLE1DDE = 0x4 + COINIT_SPEED_OVER_MEMORY = 0x8 +) + +const ( + DISPATCH_METHOD = 1 + DISPATCH_PROPERTYGET = 2 + DISPATCH_PROPERTYPUT = 4 + DISPATCH_PROPERTYPUTREF = 8 +) + +const ( + S_OK = 0x00000000 + E_UNEXPECTED = 0x8000FFFF + E_NOTIMPL = 0x80004001 + E_OUTOFMEMORY = 0x8007000E + E_INVALIDARG = 0x80070057 + E_NOINTERFACE = 0x80004002 + E_POINTER = 0x80004003 + E_HANDLE = 0x80070006 + E_ABORT = 0x80004004 + E_FAIL = 0x80004005 + E_ACCESSDENIED = 0x80070005 + E_PENDING = 0x8000000A + + CO_E_CLASSSTRING = 0x800401F3 +) + +const ( + CC_FASTCALL = iota + CC_CDECL + CC_MSCPASCAL + CC_PASCAL = CC_MSCPASCAL + CC_MACPASCAL + CC_STDCALL + CC_FPFASTCALL + CC_SYSCALL + CC_MPWCDECL + CC_MPWPASCAL + CC_MAX = CC_MPWPASCAL +) + +type VT uint16 + +const ( + VT_EMPTY VT = 0x0 + VT_NULL VT = 0x1 + VT_I2 VT = 0x2 + VT_I4 VT = 0x3 + VT_R4 VT = 0x4 + VT_R8 VT = 0x5 + VT_CY VT = 0x6 + VT_DATE VT = 0x7 + VT_BSTR VT = 0x8 + VT_DISPATCH VT = 0x9 + VT_ERROR VT = 0xa + VT_BOOL VT = 0xb + VT_VARIANT VT = 0xc + VT_UNKNOWN VT = 0xd + VT_DECIMAL VT = 0xe + VT_I1 VT = 0x10 + VT_UI1 VT = 0x11 + VT_UI2 VT = 0x12 + VT_UI4 VT = 0x13 + VT_I8 VT = 0x14 + VT_UI8 VT = 0x15 + VT_INT VT = 0x16 + VT_UINT VT = 0x17 + VT_VOID VT = 0x18 + VT_HRESULT VT = 0x19 + VT_PTR VT = 0x1a + VT_SAFEARRAY VT = 0x1b + VT_CARRAY VT = 0x1c + VT_USERDEFINED VT = 0x1d + VT_LPSTR VT = 0x1e + VT_LPWSTR VT = 0x1f + VT_RECORD VT = 0x24 + VT_INT_PTR VT = 0x25 + VT_UINT_PTR VT = 0x26 + VT_FILETIME VT = 0x40 + VT_BLOB VT = 0x41 + VT_STREAM VT = 0x42 + VT_STORAGE VT = 0x43 + VT_STREAMED_OBJECT VT = 0x44 + VT_STORED_OBJECT VT = 0x45 + VT_BLOB_OBJECT VT = 0x46 + VT_CF VT = 0x47 + VT_CLSID VT = 0x48 + VT_BSTR_BLOB VT = 0xfff + VT_VECTOR VT = 0x1000 + VT_ARRAY VT = 0x2000 + VT_BYREF VT = 0x4000 + VT_RESERVED VT = 0x8000 + VT_ILLEGAL VT = 0xffff + VT_ILLEGALMASKED VT = 0xfff + VT_TYPEMASK VT = 0xfff +) + +const ( + DISPID_UNKNOWN = -1 + DISPID_VALUE = 0 + DISPID_PROPERTYPUT = -3 + DISPID_NEWENUM = -4 + DISPID_EVALUATE = -5 + DISPID_CONSTRUCTOR = -6 + DISPID_DESTRUCTOR = -7 + DISPID_COLLECT = -8 +) + +const ( + TKIND_ENUM = 1 + TKIND_RECORD = 2 + TKIND_MODULE = 3 + TKIND_INTERFACE = 4 + TKIND_DISPATCH = 5 + TKIND_COCLASS = 6 + TKIND_ALIAS = 7 + TKIND_UNION = 8 + TKIND_MAX = 9 +) + +// Safe Array Feature Flags + +const ( + FADF_AUTO = 0x0001 + FADF_STATIC = 0x0002 + FADF_EMBEDDED = 0x0004 + FADF_FIXEDSIZE = 0x0010 + FADF_RECORD = 0x0020 + FADF_HAVEIID = 0x0040 + FADF_HAVEVARTYPE = 0x0080 + FADF_BSTR = 0x0100 + FADF_UNKNOWN = 0x0200 + FADF_DISPATCH = 0x0400 + FADF_VARIANT = 0x0800 + FADF_RESERVED = 0xF008 +) diff --git a/vendor/github.com/go-ole/go-ole/error.go b/vendor/github.com/go-ole/go-ole/error.go new file mode 100644 index 0000000000..096b456d3a --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/error.go @@ -0,0 +1,51 @@ +package ole + +// OleError stores COM errors. +type OleError struct { + hr uintptr + description string + subError error +} + +// NewError creates new error with HResult. +func NewError(hr uintptr) *OleError { + return &OleError{hr: hr} +} + +// NewErrorWithDescription creates new COM error with HResult and description. +func NewErrorWithDescription(hr uintptr, description string) *OleError { + return &OleError{hr: hr, description: description} +} + +// NewErrorWithSubError creates new COM error with parent error. +func NewErrorWithSubError(hr uintptr, description string, err error) *OleError { + return &OleError{hr: hr, description: description, subError: err} +} + +// Code is the HResult. +func (v *OleError) Code() uintptr { + return uintptr(v.hr) +} + +// String description, either manually set or format message with error code. +func (v *OleError) String() string { + if v.description != "" { + return errstr(int(v.hr)) + " (" + v.description + ")" + } + return errstr(int(v.hr)) +} + +// Error implements error interface. +func (v *OleError) Error() string { + return v.String() +} + +// Description retrieves error summary, if there is one. +func (v *OleError) Description() string { + return v.description +} + +// SubError returns parent error, if there is one. +func (v *OleError) SubError() error { + return v.subError +} diff --git a/vendor/github.com/go-ole/go-ole/error_func.go b/vendor/github.com/go-ole/go-ole/error_func.go new file mode 100644 index 0000000000..8a2ffaa272 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/error_func.go @@ -0,0 +1,8 @@ +// +build !windows + +package ole + +// errstr converts error code to string. +func errstr(errno int) string { + return "" +} diff --git a/vendor/github.com/go-ole/go-ole/error_windows.go b/vendor/github.com/go-ole/go-ole/error_windows.go new file mode 100644 index 0000000000..d0e8e68595 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/error_windows.go @@ -0,0 +1,24 @@ +// +build windows + +package ole + +import ( + "fmt" + "syscall" + "unicode/utf16" +) + +// errstr converts error code to string. +func errstr(errno int) string { + // ask windows for the remaining errors + var flags uint32 = syscall.FORMAT_MESSAGE_FROM_SYSTEM | syscall.FORMAT_MESSAGE_ARGUMENT_ARRAY | syscall.FORMAT_MESSAGE_IGNORE_INSERTS + b := make([]uint16, 300) + n, err := syscall.FormatMessage(flags, 0, uint32(errno), 0, b, nil) + if err != nil { + return fmt.Sprintf("error %d (FormatMessage failed with: %v)", errno, err) + } + // trim terminating \r and \n + for ; n > 0 && (b[n-1] == '\n' || b[n-1] == '\r'); n-- { + } + return string(utf16.Decode(b[:n])) +} diff --git a/vendor/github.com/go-ole/go-ole/guid.go b/vendor/github.com/go-ole/go-ole/guid.go new file mode 100644 index 0000000000..609ef0bfe3 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/guid.go @@ -0,0 +1,118 @@ +package ole + +var ( + // IID_NULL is null Interface ID, used when no other Interface ID is known. + IID_NULL = &GUID{0x00000000, 0x0000, 0x0000, [8]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}} + + // IID_IUnknown is for IUnknown interfaces. + IID_IUnknown = &GUID{0x00000000, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} + + // IID_IDispatch is for IDispatch interfaces. + IID_IDispatch = &GUID{0x00020400, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} + + // IID_IEnumVariant is for IEnumVariant interfaces + IID_IEnumVariant = &GUID{0x00020404, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} + + // IID_IConnectionPointContainer is for IConnectionPointContainer interfaces. + IID_IConnectionPointContainer = &GUID{0xB196B284, 0xBAB4, 0x101A, [8]byte{0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07}} + + // IID_IConnectionPoint is for IConnectionPoint interfaces. + IID_IConnectionPoint = &GUID{0xB196B286, 0xBAB4, 0x101A, [8]byte{0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07}} + + // IID_IInspectable is for IInspectable interfaces. + IID_IInspectable = &GUID{0xaf86e2e0, 0xb12d, 0x4c6a, [8]byte{0x9c, 0x5a, 0xd7, 0xaa, 0x65, 0x10, 0x1e, 0x90}} + + // IID_IProvideClassInfo is for IProvideClassInfo interfaces. + IID_IProvideClassInfo = &GUID{0xb196b283, 0xbab4, 0x101a, [8]byte{0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07}} +) + +// These are for testing and not part of any library. +var ( + // IID_ICOMTestString is for ICOMTestString interfaces. + // + // {E0133EB4-C36F-469A-9D3D-C66B84BE19ED} + IID_ICOMTestString = &GUID{0xe0133eb4, 0xc36f, 0x469a, [8]byte{0x9d, 0x3d, 0xc6, 0x6b, 0x84, 0xbe, 0x19, 0xed}} + + // IID_ICOMTestInt8 is for ICOMTestInt8 interfaces. + // + // {BEB06610-EB84-4155-AF58-E2BFF53608B4} + IID_ICOMTestInt8 = &GUID{0xbeb06610, 0xeb84, 0x4155, [8]byte{0xaf, 0x58, 0xe2, 0xbf, 0xf5, 0x36, 0x80, 0xb4}} + + // IID_ICOMTestInt16 is for ICOMTestInt16 interfaces. + // + // {DAA3F9FA-761E-4976-A860-8364CE55F6FC} + IID_ICOMTestInt16 = &GUID{0xdaa3f9fa, 0x761e, 0x4976, [8]byte{0xa8, 0x60, 0x83, 0x64, 0xce, 0x55, 0xf6, 0xfc}} + + // IID_ICOMTestInt32 is for ICOMTestInt32 interfaces. + // + // {E3DEDEE7-38A2-4540-91D1-2EEF1D8891B0} + IID_ICOMTestInt32 = &GUID{0xe3dedee7, 0x38a2, 0x4540, [8]byte{0x91, 0xd1, 0x2e, 0xef, 0x1d, 0x88, 0x91, 0xb0}} + + // IID_ICOMTestInt64 is for ICOMTestInt64 interfaces. + // + // {8D437CBC-B3ED-485C-BC32-C336432A1623} + IID_ICOMTestInt64 = &GUID{0x8d437cbc, 0xb3ed, 0x485c, [8]byte{0xbc, 0x32, 0xc3, 0x36, 0x43, 0x2a, 0x16, 0x23}} + + // IID_ICOMTestFloat is for ICOMTestFloat interfaces. + // + // {BF1ED004-EA02-456A-AA55-2AC8AC6B054C} + IID_ICOMTestFloat = &GUID{0xbf1ed004, 0xea02, 0x456a, [8]byte{0xaa, 0x55, 0x2a, 0xc8, 0xac, 0x6b, 0x5, 0x4c}} + + // IID_ICOMTestDouble is for ICOMTestDouble interfaces. + // + // {BF908A81-8687-4E93-999F-D86FAB284BA0} + IID_ICOMTestDouble = &GUID{0xbf908a81, 0x8687, 0x4e93, [8]byte{0x99, 0x9f, 0xd8, 0x6f, 0xab, 0x28, 0x4b, 0xa0}} + + // IID_ICOMTestBoolean is for ICOMTestBoolean interfaces. + // + // {D530E7A6-4EE8-40D1-8931-3D63B8605001} + IID_ICOMTestBoolean = &GUID{0xd530e7a6, 0x4ee8, 0x40d1, [8]byte{0x89, 0x31, 0x3d, 0x63, 0xb8, 0x60, 0x50, 0x10}} + + // IID_ICOMEchoTestObject is for ICOMEchoTestObject interfaces. + // + // {6485B1EF-D780-4834-A4FE-1EBB51746CA3} + IID_ICOMEchoTestObject = &GUID{0x6485b1ef, 0xd780, 0x4834, [8]byte{0xa4, 0xfe, 0x1e, 0xbb, 0x51, 0x74, 0x6c, 0xa3}} + + // IID_ICOMTestTypes is for ICOMTestTypes interfaces. + // + // {CCA8D7AE-91C0-4277-A8B3-FF4EDF28D3C0} + IID_ICOMTestTypes = &GUID{0xcca8d7ae, 0x91c0, 0x4277, [8]byte{0xa8, 0xb3, 0xff, 0x4e, 0xdf, 0x28, 0xd3, 0xc0}} + + // CLSID_COMEchoTestObject is for COMEchoTestObject class. + // + // {3C24506A-AE9E-4D50-9157-EF317281F1B0} + CLSID_COMEchoTestObject = &GUID{0x3c24506a, 0xae9e, 0x4d50, [8]byte{0x91, 0x57, 0xef, 0x31, 0x72, 0x81, 0xf1, 0xb0}} + + // CLSID_COMTestScalarClass is for COMTestScalarClass class. + // + // {865B85C5-0334-4AC6-9EF6-AACEC8FC5E86} + CLSID_COMTestScalarClass = &GUID{0x865b85c5, 0x0334, 0x4ac6, [8]byte{0x9e, 0xf6, 0xaa, 0xce, 0xc8, 0xfc, 0x5e, 0x86}} +) + +// GUID is Windows API specific GUID type. +// +// This exists to match Windows GUID type for direct passing for COM. +// Format is in xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx. +type GUID struct { + Data1 uint32 + Data2 uint16 + Data3 uint16 + Data4 [8]byte +} + +// IsEqualGUID compares two GUID. +// +// Not constant time comparison. +func IsEqualGUID(guid1 *GUID, guid2 *GUID) bool { + return guid1.Data1 == guid2.Data1 && + guid1.Data2 == guid2.Data2 && + guid1.Data3 == guid2.Data3 && + guid1.Data4[0] == guid2.Data4[0] && + guid1.Data4[1] == guid2.Data4[1] && + guid1.Data4[2] == guid2.Data4[2] && + guid1.Data4[3] == guid2.Data4[3] && + guid1.Data4[4] == guid2.Data4[4] && + guid1.Data4[5] == guid2.Data4[5] && + guid1.Data4[6] == guid2.Data4[6] && + guid1.Data4[7] == guid2.Data4[7] +} diff --git a/vendor/github.com/go-ole/go-ole/iconnectionpoint.go b/vendor/github.com/go-ole/go-ole/iconnectionpoint.go new file mode 100644 index 0000000000..9e6c49f41f --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/iconnectionpoint.go @@ -0,0 +1,20 @@ +package ole + +import "unsafe" + +type IConnectionPoint struct { + IUnknown +} + +type IConnectionPointVtbl struct { + IUnknownVtbl + GetConnectionInterface uintptr + GetConnectionPointContainer uintptr + Advise uintptr + Unadvise uintptr + EnumConnections uintptr +} + +func (v *IConnectionPoint) VTable() *IConnectionPointVtbl { + return (*IConnectionPointVtbl)(unsafe.Pointer(v.RawVTable)) +} diff --git a/vendor/github.com/go-ole/go-ole/iconnectionpoint_func.go b/vendor/github.com/go-ole/go-ole/iconnectionpoint_func.go new file mode 100644 index 0000000000..5414dc3cd3 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/iconnectionpoint_func.go @@ -0,0 +1,21 @@ +// +build !windows + +package ole + +import "unsafe" + +func (v *IConnectionPoint) GetConnectionInterface(piid **GUID) int32 { + return int32(0) +} + +func (v *IConnectionPoint) Advise(unknown *IUnknown) (uint32, error) { + return uint32(0), NewError(E_NOTIMPL) +} + +func (v *IConnectionPoint) Unadvise(cookie uint32) error { + return NewError(E_NOTIMPL) +} + +func (v *IConnectionPoint) EnumConnections(p *unsafe.Pointer) (err error) { + return NewError(E_NOTIMPL) +} diff --git a/vendor/github.com/go-ole/go-ole/iconnectionpoint_windows.go b/vendor/github.com/go-ole/go-ole/iconnectionpoint_windows.go new file mode 100644 index 0000000000..32bc183248 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/iconnectionpoint_windows.go @@ -0,0 +1,43 @@ +// +build windows + +package ole + +import ( + "syscall" + "unsafe" +) + +func (v *IConnectionPoint) GetConnectionInterface(piid **GUID) int32 { + // XXX: This doesn't look like it does what it's supposed to + return release((*IUnknown)(unsafe.Pointer(v))) +} + +func (v *IConnectionPoint) Advise(unknown *IUnknown) (cookie uint32, err error) { + hr, _, _ := syscall.Syscall( + v.VTable().Advise, + 3, + uintptr(unsafe.Pointer(v)), + uintptr(unsafe.Pointer(unknown)), + uintptr(unsafe.Pointer(&cookie))) + if hr != 0 { + err = NewError(hr) + } + return +} + +func (v *IConnectionPoint) Unadvise(cookie uint32) (err error) { + hr, _, _ := syscall.Syscall( + v.VTable().Unadvise, + 2, + uintptr(unsafe.Pointer(v)), + uintptr(cookie), + 0) + if hr != 0 { + err = NewError(hr) + } + return +} + +func (v *IConnectionPoint) EnumConnections(p *unsafe.Pointer) error { + return NewError(E_NOTIMPL) +} diff --git a/vendor/github.com/go-ole/go-ole/iconnectionpointcontainer.go b/vendor/github.com/go-ole/go-ole/iconnectionpointcontainer.go new file mode 100644 index 0000000000..165860d199 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/iconnectionpointcontainer.go @@ -0,0 +1,17 @@ +package ole + +import "unsafe" + +type IConnectionPointContainer struct { + IUnknown +} + +type IConnectionPointContainerVtbl struct { + IUnknownVtbl + EnumConnectionPoints uintptr + FindConnectionPoint uintptr +} + +func (v *IConnectionPointContainer) VTable() *IConnectionPointContainerVtbl { + return (*IConnectionPointContainerVtbl)(unsafe.Pointer(v.RawVTable)) +} diff --git a/vendor/github.com/go-ole/go-ole/iconnectionpointcontainer_func.go b/vendor/github.com/go-ole/go-ole/iconnectionpointcontainer_func.go new file mode 100644 index 0000000000..5dfa42aaeb --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/iconnectionpointcontainer_func.go @@ -0,0 +1,11 @@ +// +build !windows + +package ole + +func (v *IConnectionPointContainer) EnumConnectionPoints(points interface{}) error { + return NewError(E_NOTIMPL) +} + +func (v *IConnectionPointContainer) FindConnectionPoint(iid *GUID, point **IConnectionPoint) error { + return NewError(E_NOTIMPL) +} diff --git a/vendor/github.com/go-ole/go-ole/iconnectionpointcontainer_windows.go b/vendor/github.com/go-ole/go-ole/iconnectionpointcontainer_windows.go new file mode 100644 index 0000000000..ad30d79efc --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/iconnectionpointcontainer_windows.go @@ -0,0 +1,25 @@ +// +build windows + +package ole + +import ( + "syscall" + "unsafe" +) + +func (v *IConnectionPointContainer) EnumConnectionPoints(points interface{}) error { + return NewError(E_NOTIMPL) +} + +func (v *IConnectionPointContainer) FindConnectionPoint(iid *GUID, point **IConnectionPoint) (err error) { + hr, _, _ := syscall.Syscall( + v.VTable().FindConnectionPoint, + 3, + uintptr(unsafe.Pointer(v)), + uintptr(unsafe.Pointer(iid)), + uintptr(unsafe.Pointer(point))) + if hr != 0 { + err = NewError(hr) + } + return +} diff --git a/vendor/github.com/go-ole/go-ole/idispatch.go b/vendor/github.com/go-ole/go-ole/idispatch.go new file mode 100644 index 0000000000..d4af124092 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/idispatch.go @@ -0,0 +1,94 @@ +package ole + +import "unsafe" + +type IDispatch struct { + IUnknown +} + +type IDispatchVtbl struct { + IUnknownVtbl + GetTypeInfoCount uintptr + GetTypeInfo uintptr + GetIDsOfNames uintptr + Invoke uintptr +} + +func (v *IDispatch) VTable() *IDispatchVtbl { + return (*IDispatchVtbl)(unsafe.Pointer(v.RawVTable)) +} + +func (v *IDispatch) GetIDsOfName(names []string) (dispid []int32, err error) { + dispid, err = getIDsOfName(v, names) + return +} + +func (v *IDispatch) Invoke(dispid int32, dispatch int16, params ...interface{}) (result *VARIANT, err error) { + result, err = invoke(v, dispid, dispatch, params...) + return +} + +func (v *IDispatch) GetTypeInfoCount() (c uint32, err error) { + c, err = getTypeInfoCount(v) + return +} + +func (v *IDispatch) GetTypeInfo() (tinfo *ITypeInfo, err error) { + tinfo, err = getTypeInfo(v) + return +} + +// GetSingleIDOfName is a helper that returns single display ID for IDispatch name. +// +// This replaces the common pattern of attempting to get a single name from the list of available +// IDs. It gives the first ID, if it is available. +func (v *IDispatch) GetSingleIDOfName(name string) (displayID int32, err error) { + var displayIDs []int32 + displayIDs, err = v.GetIDsOfName([]string{name}) + if err != nil { + return + } + displayID = displayIDs[0] + return +} + +// InvokeWithOptionalArgs accepts arguments as an array, works like Invoke. +// +// Accepts name and will attempt to retrieve Display ID to pass to Invoke. +// +// Passing params as an array is a workaround that could be fixed in later versions of Go that +// prevent passing empty params. During testing it was discovered that this is an acceptable way of +// getting around not being able to pass params normally. +func (v *IDispatch) InvokeWithOptionalArgs(name string, dispatch int16, params []interface{}) (result *VARIANT, err error) { + displayID, err := v.GetSingleIDOfName(name) + if err != nil { + return + } + + if len(params) < 1 { + result, err = v.Invoke(displayID, dispatch) + } else { + result, err = v.Invoke(displayID, dispatch, params...) + } + + return +} + +// CallMethod invokes named function with arguments on object. +func (v *IDispatch) CallMethod(name string, params ...interface{}) (*VARIANT, error) { + return v.InvokeWithOptionalArgs(name, DISPATCH_METHOD, params) +} + +// GetProperty retrieves the property with the name with the ability to pass arguments. +// +// Most of the time you will not need to pass arguments as most objects do not allow for this +// feature. Or at least, should not allow for this feature. Some servers don't follow best practices +// and this is provided for those edge cases. +func (v *IDispatch) GetProperty(name string, params ...interface{}) (*VARIANT, error) { + return v.InvokeWithOptionalArgs(name, DISPATCH_PROPERTYGET, params) +} + +// PutProperty attempts to mutate a property in the object. +func (v *IDispatch) PutProperty(name string, params ...interface{}) (*VARIANT, error) { + return v.InvokeWithOptionalArgs(name, DISPATCH_PROPERTYPUT, params) +} diff --git a/vendor/github.com/go-ole/go-ole/idispatch_func.go b/vendor/github.com/go-ole/go-ole/idispatch_func.go new file mode 100644 index 0000000000..b8fbbe319f --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/idispatch_func.go @@ -0,0 +1,19 @@ +// +build !windows + +package ole + +func getIDsOfName(disp *IDispatch, names []string) ([]int32, error) { + return []int32{}, NewError(E_NOTIMPL) +} + +func getTypeInfoCount(disp *IDispatch) (uint32, error) { + return uint32(0), NewError(E_NOTIMPL) +} + +func getTypeInfo(disp *IDispatch) (*ITypeInfo, error) { + return nil, NewError(E_NOTIMPL) +} + +func invoke(disp *IDispatch, dispid int32, dispatch int16, params ...interface{}) (*VARIANT, error) { + return nil, NewError(E_NOTIMPL) +} diff --git a/vendor/github.com/go-ole/go-ole/idispatch_windows.go b/vendor/github.com/go-ole/go-ole/idispatch_windows.go new file mode 100644 index 0000000000..bb73690382 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/idispatch_windows.go @@ -0,0 +1,193 @@ +// +build windows + +package ole + +import ( + "syscall" + "time" + "unsafe" +) + +func getIDsOfName(disp *IDispatch, names []string) (dispid []int32, err error) { + wnames := make([]*uint16, len(names)) + for i := 0; i < len(names); i++ { + wnames[i] = syscall.StringToUTF16Ptr(names[i]) + } + dispid = make([]int32, len(names)) + namelen := uint32(len(names)) + hr, _, _ := syscall.Syscall6( + disp.VTable().GetIDsOfNames, + 6, + uintptr(unsafe.Pointer(disp)), + uintptr(unsafe.Pointer(IID_NULL)), + uintptr(unsafe.Pointer(&wnames[0])), + uintptr(namelen), + uintptr(GetUserDefaultLCID()), + uintptr(unsafe.Pointer(&dispid[0]))) + if hr != 0 { + err = NewError(hr) + } + return +} + +func getTypeInfoCount(disp *IDispatch) (c uint32, err error) { + hr, _, _ := syscall.Syscall( + disp.VTable().GetTypeInfoCount, + 2, + uintptr(unsafe.Pointer(disp)), + uintptr(unsafe.Pointer(&c)), + 0) + if hr != 0 { + err = NewError(hr) + } + return +} + +func getTypeInfo(disp *IDispatch) (tinfo *ITypeInfo, err error) { + hr, _, _ := syscall.Syscall( + disp.VTable().GetTypeInfo, + 3, + uintptr(unsafe.Pointer(disp)), + uintptr(GetUserDefaultLCID()), + uintptr(unsafe.Pointer(&tinfo))) + if hr != 0 { + err = NewError(hr) + } + return +} + +func invoke(disp *IDispatch, dispid int32, dispatch int16, params ...interface{}) (result *VARIANT, err error) { + var dispparams DISPPARAMS + + if dispatch&DISPATCH_PROPERTYPUT != 0 { + dispnames := [1]int32{DISPID_PROPERTYPUT} + dispparams.rgdispidNamedArgs = uintptr(unsafe.Pointer(&dispnames[0])) + dispparams.cNamedArgs = 1 + } + var vargs []VARIANT + if len(params) > 0 { + vargs = make([]VARIANT, len(params)) + for i, v := range params { + //n := len(params)-i-1 + n := len(params) - i - 1 + VariantInit(&vargs[n]) + switch vv := v.(type) { + case bool: + if vv { + vargs[n] = NewVariant(VT_BOOL, 0xffff) + } else { + vargs[n] = NewVariant(VT_BOOL, 0) + } + case *bool: + vargs[n] = NewVariant(VT_BOOL|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*bool))))) + case uint8: + vargs[n] = NewVariant(VT_I1, int64(v.(uint8))) + case *uint8: + vargs[n] = NewVariant(VT_I1|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*uint8))))) + case int8: + vargs[n] = NewVariant(VT_I1, int64(v.(int8))) + case *int8: + vargs[n] = NewVariant(VT_I1|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*uint8))))) + case int16: + vargs[n] = NewVariant(VT_I2, int64(v.(int16))) + case *int16: + vargs[n] = NewVariant(VT_I2|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*int16))))) + case uint16: + vargs[n] = NewVariant(VT_UI2, int64(v.(uint16))) + case *uint16: + vargs[n] = NewVariant(VT_UI2|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*uint16))))) + case int32: + vargs[n] = NewVariant(VT_I4, int64(v.(int32))) + case *int32: + vargs[n] = NewVariant(VT_I4|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*int32))))) + case uint32: + vargs[n] = NewVariant(VT_UI4, int64(v.(uint32))) + case *uint32: + vargs[n] = NewVariant(VT_UI4|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*uint32))))) + case int64: + vargs[n] = NewVariant(VT_I8, int64(v.(int64))) + case *int64: + vargs[n] = NewVariant(VT_I8|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*int64))))) + case uint64: + vargs[n] = NewVariant(VT_UI8, int64(uintptr(v.(uint64)))) + case *uint64: + vargs[n] = NewVariant(VT_UI8|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*uint64))))) + case int: + vargs[n] = NewVariant(VT_I4, int64(v.(int))) + case *int: + vargs[n] = NewVariant(VT_I4|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*int))))) + case uint: + vargs[n] = NewVariant(VT_UI4, int64(v.(uint))) + case *uint: + vargs[n] = NewVariant(VT_UI4|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*uint))))) + case float32: + vargs[n] = NewVariant(VT_R4, *(*int64)(unsafe.Pointer(&vv))) + case *float32: + vargs[n] = NewVariant(VT_R4|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*float32))))) + case float64: + vargs[n] = NewVariant(VT_R8, *(*int64)(unsafe.Pointer(&vv))) + case *float64: + vargs[n] = NewVariant(VT_R8|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*float64))))) + case string: + vargs[n] = NewVariant(VT_BSTR, int64(uintptr(unsafe.Pointer(SysAllocStringLen(v.(string)))))) + case *string: + vargs[n] = NewVariant(VT_BSTR|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*string))))) + case time.Time: + s := vv.Format("2006-01-02 15:04:05") + vargs[n] = NewVariant(VT_BSTR, int64(uintptr(unsafe.Pointer(SysAllocStringLen(s))))) + case *time.Time: + s := vv.Format("2006-01-02 15:04:05") + vargs[n] = NewVariant(VT_BSTR|VT_BYREF, int64(uintptr(unsafe.Pointer(&s)))) + case *IDispatch: + vargs[n] = NewVariant(VT_DISPATCH, int64(uintptr(unsafe.Pointer(v.(*IDispatch))))) + case **IDispatch: + vargs[n] = NewVariant(VT_DISPATCH|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(**IDispatch))))) + case nil: + vargs[n] = NewVariant(VT_NULL, 0) + case *VARIANT: + vargs[n] = NewVariant(VT_VARIANT|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*VARIANT))))) + case []byte: + safeByteArray := safeArrayFromByteSlice(v.([]byte)) + vargs[n] = NewVariant(VT_ARRAY|VT_UI1, int64(uintptr(unsafe.Pointer(safeByteArray)))) + defer VariantClear(&vargs[n]) + case []string: + safeByteArray := safeArrayFromStringSlice(v.([]string)) + vargs[n] = NewVariant(VT_ARRAY|VT_BSTR, int64(uintptr(unsafe.Pointer(safeByteArray)))) + defer VariantClear(&vargs[n]) + default: + panic("unknown type") + } + } + dispparams.rgvarg = uintptr(unsafe.Pointer(&vargs[0])) + dispparams.cArgs = uint32(len(params)) + } + + result = new(VARIANT) + var excepInfo EXCEPINFO + VariantInit(result) + hr, _, _ := syscall.Syscall9( + disp.VTable().Invoke, + 9, + uintptr(unsafe.Pointer(disp)), + uintptr(dispid), + uintptr(unsafe.Pointer(IID_NULL)), + uintptr(GetUserDefaultLCID()), + uintptr(dispatch), + uintptr(unsafe.Pointer(&dispparams)), + uintptr(unsafe.Pointer(result)), + uintptr(unsafe.Pointer(&excepInfo)), + 0) + if hr != 0 { + err = NewErrorWithSubError(hr, BstrToString(excepInfo.bstrDescription), excepInfo) + } + for i, varg := range vargs { + n := len(params) - i - 1 + if varg.VT == VT_BSTR && varg.Val != 0 { + SysFreeString(((*int16)(unsafe.Pointer(uintptr(varg.Val))))) + } + if varg.VT == (VT_BSTR|VT_BYREF) && varg.Val != 0 { + *(params[n].(*string)) = LpOleStrToString(*(**uint16)(unsafe.Pointer(uintptr(varg.Val)))) + } + } + return +} diff --git a/vendor/github.com/go-ole/go-ole/ienumvariant.go b/vendor/github.com/go-ole/go-ole/ienumvariant.go new file mode 100644 index 0000000000..2433897544 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/ienumvariant.go @@ -0,0 +1,19 @@ +package ole + +import "unsafe" + +type IEnumVARIANT struct { + IUnknown +} + +type IEnumVARIANTVtbl struct { + IUnknownVtbl + Next uintptr + Skip uintptr + Reset uintptr + Clone uintptr +} + +func (v *IEnumVARIANT) VTable() *IEnumVARIANTVtbl { + return (*IEnumVARIANTVtbl)(unsafe.Pointer(v.RawVTable)) +} diff --git a/vendor/github.com/go-ole/go-ole/ienumvariant_func.go b/vendor/github.com/go-ole/go-ole/ienumvariant_func.go new file mode 100644 index 0000000000..c14848199c --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/ienumvariant_func.go @@ -0,0 +1,19 @@ +// +build !windows + +package ole + +func (enum *IEnumVARIANT) Clone() (*IEnumVARIANT, error) { + return nil, NewError(E_NOTIMPL) +} + +func (enum *IEnumVARIANT) Reset() error { + return NewError(E_NOTIMPL) +} + +func (enum *IEnumVARIANT) Skip(celt uint) error { + return NewError(E_NOTIMPL) +} + +func (enum *IEnumVARIANT) Next(celt uint) (VARIANT, uint, error) { + return NewVariant(VT_NULL, int64(0)), 0, NewError(E_NOTIMPL) +} diff --git a/vendor/github.com/go-ole/go-ole/ienumvariant_windows.go b/vendor/github.com/go-ole/go-ole/ienumvariant_windows.go new file mode 100644 index 0000000000..4781f3b8b0 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/ienumvariant_windows.go @@ -0,0 +1,63 @@ +// +build windows + +package ole + +import ( + "syscall" + "unsafe" +) + +func (enum *IEnumVARIANT) Clone() (cloned *IEnumVARIANT, err error) { + hr, _, _ := syscall.Syscall( + enum.VTable().Clone, + 2, + uintptr(unsafe.Pointer(enum)), + uintptr(unsafe.Pointer(&cloned)), + 0) + if hr != 0 { + err = NewError(hr) + } + return +} + +func (enum *IEnumVARIANT) Reset() (err error) { + hr, _, _ := syscall.Syscall( + enum.VTable().Reset, + 1, + uintptr(unsafe.Pointer(enum)), + 0, + 0) + if hr != 0 { + err = NewError(hr) + } + return +} + +func (enum *IEnumVARIANT) Skip(celt uint) (err error) { + hr, _, _ := syscall.Syscall( + enum.VTable().Skip, + 2, + uintptr(unsafe.Pointer(enum)), + uintptr(celt), + 0) + if hr != 0 { + err = NewError(hr) + } + return +} + +func (enum *IEnumVARIANT) Next(celt uint) (array VARIANT, length uint, err error) { + hr, _, _ := syscall.Syscall6( + enum.VTable().Next, + 4, + uintptr(unsafe.Pointer(enum)), + uintptr(celt), + uintptr(unsafe.Pointer(&array)), + uintptr(unsafe.Pointer(&length)), + 0, + 0) + if hr != 0 { + err = NewError(hr) + } + return +} diff --git a/vendor/github.com/go-ole/go-ole/iinspectable.go b/vendor/github.com/go-ole/go-ole/iinspectable.go new file mode 100644 index 0000000000..f4a19e253a --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/iinspectable.go @@ -0,0 +1,18 @@ +package ole + +import "unsafe" + +type IInspectable struct { + IUnknown +} + +type IInspectableVtbl struct { + IUnknownVtbl + GetIIds uintptr + GetRuntimeClassName uintptr + GetTrustLevel uintptr +} + +func (v *IInspectable) VTable() *IInspectableVtbl { + return (*IInspectableVtbl)(unsafe.Pointer(v.RawVTable)) +} diff --git a/vendor/github.com/go-ole/go-ole/iinspectable_func.go b/vendor/github.com/go-ole/go-ole/iinspectable_func.go new file mode 100644 index 0000000000..348829bf06 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/iinspectable_func.go @@ -0,0 +1,15 @@ +// +build !windows + +package ole + +func (v *IInspectable) GetIids() ([]*GUID, error) { + return []*GUID{}, NewError(E_NOTIMPL) +} + +func (v *IInspectable) GetRuntimeClassName() (string, error) { + return "", NewError(E_NOTIMPL) +} + +func (v *IInspectable) GetTrustLevel() (uint32, error) { + return uint32(0), NewError(E_NOTIMPL) +} diff --git a/vendor/github.com/go-ole/go-ole/iinspectable_windows.go b/vendor/github.com/go-ole/go-ole/iinspectable_windows.go new file mode 100644 index 0000000000..4519a4aa44 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/iinspectable_windows.go @@ -0,0 +1,72 @@ +// +build windows + +package ole + +import ( + "bytes" + "encoding/binary" + "reflect" + "syscall" + "unsafe" +) + +func (v *IInspectable) GetIids() (iids []*GUID, err error) { + var count uint32 + var array uintptr + hr, _, _ := syscall.Syscall( + v.VTable().GetIIds, + 3, + uintptr(unsafe.Pointer(v)), + uintptr(unsafe.Pointer(&count)), + uintptr(unsafe.Pointer(&array))) + if hr != 0 { + err = NewError(hr) + return + } + defer CoTaskMemFree(array) + + iids = make([]*GUID, count) + byteCount := count * uint32(unsafe.Sizeof(GUID{})) + slicehdr := reflect.SliceHeader{Data: array, Len: int(byteCount), Cap: int(byteCount)} + byteSlice := *(*[]byte)(unsafe.Pointer(&slicehdr)) + reader := bytes.NewReader(byteSlice) + for i := range iids { + guid := GUID{} + err = binary.Read(reader, binary.LittleEndian, &guid) + if err != nil { + return + } + iids[i] = &guid + } + return +} + +func (v *IInspectable) GetRuntimeClassName() (s string, err error) { + var hstring HString + hr, _, _ := syscall.Syscall( + v.VTable().GetRuntimeClassName, + 2, + uintptr(unsafe.Pointer(v)), + uintptr(unsafe.Pointer(&hstring)), + 0) + if hr != 0 { + err = NewError(hr) + return + } + s = hstring.String() + DeleteHString(hstring) + return +} + +func (v *IInspectable) GetTrustLevel() (level uint32, err error) { + hr, _, _ := syscall.Syscall( + v.VTable().GetTrustLevel, + 2, + uintptr(unsafe.Pointer(v)), + uintptr(unsafe.Pointer(&level)), + 0) + if hr != 0 { + err = NewError(hr) + } + return +} diff --git a/vendor/github.com/go-ole/go-ole/iprovideclassinfo.go b/vendor/github.com/go-ole/go-ole/iprovideclassinfo.go new file mode 100644 index 0000000000..25f3a6f24a --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/iprovideclassinfo.go @@ -0,0 +1,21 @@ +package ole + +import "unsafe" + +type IProvideClassInfo struct { + IUnknown +} + +type IProvideClassInfoVtbl struct { + IUnknownVtbl + GetClassInfo uintptr +} + +func (v *IProvideClassInfo) VTable() *IProvideClassInfoVtbl { + return (*IProvideClassInfoVtbl)(unsafe.Pointer(v.RawVTable)) +} + +func (v *IProvideClassInfo) GetClassInfo() (cinfo *ITypeInfo, err error) { + cinfo, err = getClassInfo(v) + return +} diff --git a/vendor/github.com/go-ole/go-ole/iprovideclassinfo_func.go b/vendor/github.com/go-ole/go-ole/iprovideclassinfo_func.go new file mode 100644 index 0000000000..7e3cb63ea7 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/iprovideclassinfo_func.go @@ -0,0 +1,7 @@ +// +build !windows + +package ole + +func getClassInfo(disp *IProvideClassInfo) (tinfo *ITypeInfo, err error) { + return nil, NewError(E_NOTIMPL) +} diff --git a/vendor/github.com/go-ole/go-ole/iprovideclassinfo_windows.go b/vendor/github.com/go-ole/go-ole/iprovideclassinfo_windows.go new file mode 100644 index 0000000000..2ad0163949 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/iprovideclassinfo_windows.go @@ -0,0 +1,21 @@ +// +build windows + +package ole + +import ( + "syscall" + "unsafe" +) + +func getClassInfo(disp *IProvideClassInfo) (tinfo *ITypeInfo, err error) { + hr, _, _ := syscall.Syscall( + disp.VTable().GetClassInfo, + 2, + uintptr(unsafe.Pointer(disp)), + uintptr(unsafe.Pointer(&tinfo)), + 0) + if hr != 0 { + err = NewError(hr) + } + return +} diff --git a/vendor/github.com/go-ole/go-ole/itypeinfo.go b/vendor/github.com/go-ole/go-ole/itypeinfo.go new file mode 100644 index 0000000000..dd3c5e21bb --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/itypeinfo.go @@ -0,0 +1,34 @@ +package ole + +import "unsafe" + +type ITypeInfo struct { + IUnknown +} + +type ITypeInfoVtbl struct { + IUnknownVtbl + GetTypeAttr uintptr + GetTypeComp uintptr + GetFuncDesc uintptr + GetVarDesc uintptr + GetNames uintptr + GetRefTypeOfImplType uintptr + GetImplTypeFlags uintptr + GetIDsOfNames uintptr + Invoke uintptr + GetDocumentation uintptr + GetDllEntry uintptr + GetRefTypeInfo uintptr + AddressOfMember uintptr + CreateInstance uintptr + GetMops uintptr + GetContainingTypeLib uintptr + ReleaseTypeAttr uintptr + ReleaseFuncDesc uintptr + ReleaseVarDesc uintptr +} + +func (v *ITypeInfo) VTable() *ITypeInfoVtbl { + return (*ITypeInfoVtbl)(unsafe.Pointer(v.RawVTable)) +} diff --git a/vendor/github.com/go-ole/go-ole/itypeinfo_func.go b/vendor/github.com/go-ole/go-ole/itypeinfo_func.go new file mode 100644 index 0000000000..8364a659ba --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/itypeinfo_func.go @@ -0,0 +1,7 @@ +// +build !windows + +package ole + +func (v *ITypeInfo) GetTypeAttr() (*TYPEATTR, error) { + return nil, NewError(E_NOTIMPL) +} diff --git a/vendor/github.com/go-ole/go-ole/itypeinfo_windows.go b/vendor/github.com/go-ole/go-ole/itypeinfo_windows.go new file mode 100644 index 0000000000..54782b3da5 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/itypeinfo_windows.go @@ -0,0 +1,21 @@ +// +build windows + +package ole + +import ( + "syscall" + "unsafe" +) + +func (v *ITypeInfo) GetTypeAttr() (tattr *TYPEATTR, err error) { + hr, _, _ := syscall.Syscall( + uintptr(v.VTable().GetTypeAttr), + 2, + uintptr(unsafe.Pointer(v)), + uintptr(unsafe.Pointer(&tattr)), + 0) + if hr != 0 { + err = NewError(hr) + } + return +} diff --git a/vendor/github.com/go-ole/go-ole/iunknown.go b/vendor/github.com/go-ole/go-ole/iunknown.go new file mode 100644 index 0000000000..108f28ea61 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/iunknown.go @@ -0,0 +1,57 @@ +package ole + +import "unsafe" + +type IUnknown struct { + RawVTable *interface{} +} + +type IUnknownVtbl struct { + QueryInterface uintptr + AddRef uintptr + Release uintptr +} + +type UnknownLike interface { + QueryInterface(iid *GUID) (disp *IDispatch, err error) + AddRef() int32 + Release() int32 +} + +func (v *IUnknown) VTable() *IUnknownVtbl { + return (*IUnknownVtbl)(unsafe.Pointer(v.RawVTable)) +} + +func (v *IUnknown) PutQueryInterface(interfaceID *GUID, obj interface{}) error { + return reflectQueryInterface(v, v.VTable().QueryInterface, interfaceID, obj) +} + +func (v *IUnknown) IDispatch(interfaceID *GUID) (dispatch *IDispatch, err error) { + err = v.PutQueryInterface(interfaceID, &dispatch) + return +} + +func (v *IUnknown) IEnumVARIANT(interfaceID *GUID) (enum *IEnumVARIANT, err error) { + err = v.PutQueryInterface(interfaceID, &enum) + return +} + +func (v *IUnknown) QueryInterface(iid *GUID) (*IDispatch, error) { + return queryInterface(v, iid) +} + +func (v *IUnknown) MustQueryInterface(iid *GUID) (disp *IDispatch) { + unk, err := queryInterface(v, iid) + if err != nil { + panic(err) + } + return unk +} + +func (v *IUnknown) AddRef() int32 { + return addRef(v) +} + +func (v *IUnknown) Release() int32 { + return release(v) +} diff --git a/vendor/github.com/go-ole/go-ole/iunknown_func.go b/vendor/github.com/go-ole/go-ole/iunknown_func.go new file mode 100644 index 0000000000..d0a62cfd73 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/iunknown_func.go @@ -0,0 +1,19 @@ +// +build !windows + +package ole + +func reflectQueryInterface(self interface{}, method uintptr, interfaceID *GUID, obj interface{}) (err error) { + return NewError(E_NOTIMPL) +} + +func queryInterface(unk *IUnknown, iid *GUID) (disp *IDispatch, err error) { + return nil, NewError(E_NOTIMPL) +} + +func addRef(unk *IUnknown) int32 { + return 0 +} + +func release(unk *IUnknown) int32 { + return 0 +} diff --git a/vendor/github.com/go-ole/go-ole/iunknown_windows.go b/vendor/github.com/go-ole/go-ole/iunknown_windows.go new file mode 100644 index 0000000000..ede5bb8c17 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/iunknown_windows.go @@ -0,0 +1,58 @@ +// +build windows + +package ole + +import ( + "reflect" + "syscall" + "unsafe" +) + +func reflectQueryInterface(self interface{}, method uintptr, interfaceID *GUID, obj interface{}) (err error) { + selfValue := reflect.ValueOf(self).Elem() + objValue := reflect.ValueOf(obj).Elem() + + hr, _, _ := syscall.Syscall( + method, + 3, + selfValue.UnsafeAddr(), + uintptr(unsafe.Pointer(interfaceID)), + objValue.Addr().Pointer()) + if hr != 0 { + err = NewError(hr) + } + return +} + +func queryInterface(unk *IUnknown, iid *GUID) (disp *IDispatch, err error) { + hr, _, _ := syscall.Syscall( + unk.VTable().QueryInterface, + 3, + uintptr(unsafe.Pointer(unk)), + uintptr(unsafe.Pointer(iid)), + uintptr(unsafe.Pointer(&disp))) + if hr != 0 { + err = NewError(hr) + } + return +} + +func addRef(unk *IUnknown) int32 { + ret, _, _ := syscall.Syscall( + unk.VTable().AddRef, + 1, + uintptr(unsafe.Pointer(unk)), + 0, + 0) + return int32(ret) +} + +func release(unk *IUnknown) int32 { + ret, _, _ := syscall.Syscall( + unk.VTable().Release, + 1, + uintptr(unsafe.Pointer(unk)), + 0, + 0) + return int32(ret) +} diff --git a/vendor/github.com/go-ole/go-ole/ole.go b/vendor/github.com/go-ole/go-ole/ole.go new file mode 100644 index 0000000000..b92b4ea189 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/ole.go @@ -0,0 +1,147 @@ +package ole + +import ( + "fmt" + "strings" +) + +// DISPPARAMS are the arguments that passed to methods or property. +type DISPPARAMS struct { + rgvarg uintptr + rgdispidNamedArgs uintptr + cArgs uint32 + cNamedArgs uint32 +} + +// EXCEPINFO defines exception info. +type EXCEPINFO struct { + wCode uint16 + wReserved uint16 + bstrSource *uint16 + bstrDescription *uint16 + bstrHelpFile *uint16 + dwHelpContext uint32 + pvReserved uintptr + pfnDeferredFillIn uintptr + scode uint32 +} + +// String convert EXCEPINFO to string. +func (e EXCEPINFO) String() string { + var src, desc, hlp string + if e.bstrSource == nil { + src = "" + } else { + src = BstrToString(e.bstrSource) + } + + if e.bstrDescription == nil { + desc = "" + } else { + desc = BstrToString(e.bstrDescription) + } + + if e.bstrHelpFile == nil { + hlp = "" + } else { + hlp = BstrToString(e.bstrHelpFile) + } + + return fmt.Sprintf( + "wCode: %#x, bstrSource: %v, bstrDescription: %v, bstrHelpFile: %v, dwHelpContext: %#x, scode: %#x", + e.wCode, src, desc, hlp, e.dwHelpContext, e.scode, + ) +} + +// Error implements error interface and returns error string. +func (e EXCEPINFO) Error() string { + if e.bstrDescription != nil { + return strings.TrimSpace(BstrToString(e.bstrDescription)) + } + + src := "Unknown" + if e.bstrSource != nil { + src = BstrToString(e.bstrSource) + } + + code := e.scode + if e.wCode != 0 { + code = uint32(e.wCode) + } + + return fmt.Sprintf("%v: %#x", src, code) +} + +// PARAMDATA defines parameter data type. +type PARAMDATA struct { + Name *int16 + Vt uint16 +} + +// METHODDATA defines method info. +type METHODDATA struct { + Name *uint16 + Data *PARAMDATA + Dispid int32 + Meth uint32 + CC int32 + CArgs uint32 + Flags uint16 + VtReturn uint32 +} + +// INTERFACEDATA defines interface info. +type INTERFACEDATA struct { + MethodData *METHODDATA + CMembers uint32 +} + +// Point is 2D vector type. +type Point struct { + X int32 + Y int32 +} + +// Msg is message between processes. +type Msg struct { + Hwnd uint32 + Message uint32 + Wparam int32 + Lparam int32 + Time uint32 + Pt Point +} + +// TYPEDESC defines data type. +type TYPEDESC struct { + Hreftype uint32 + VT uint16 +} + +// IDLDESC defines IDL info. +type IDLDESC struct { + DwReserved uint32 + WIDLFlags uint16 +} + +// TYPEATTR defines type info. +type TYPEATTR struct { + Guid GUID + Lcid uint32 + dwReserved uint32 + MemidConstructor int32 + MemidDestructor int32 + LpstrSchema *uint16 + CbSizeInstance uint32 + Typekind int32 + CFuncs uint16 + CVars uint16 + CImplTypes uint16 + CbSizeVft uint16 + CbAlignment uint16 + WTypeFlags uint16 + WMajorVerNum uint16 + WMinorVerNum uint16 + TdescAlias TYPEDESC + IdldescType IDLDESC +} diff --git a/vendor/github.com/go-ole/go-ole/oleutil/connection.go b/vendor/github.com/go-ole/go-ole/oleutil/connection.go new file mode 100644 index 0000000000..60df73cda0 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/oleutil/connection.go @@ -0,0 +1,100 @@ +// +build windows + +package oleutil + +import ( + "reflect" + "unsafe" + + ole "github.com/go-ole/go-ole" +) + +type stdDispatch struct { + lpVtbl *stdDispatchVtbl + ref int32 + iid *ole.GUID + iface interface{} + funcMap map[string]int32 +} + +type stdDispatchVtbl struct { + pQueryInterface uintptr + pAddRef uintptr + pRelease uintptr + pGetTypeInfoCount uintptr + pGetTypeInfo uintptr + pGetIDsOfNames uintptr + pInvoke uintptr +} + +func dispQueryInterface(this *ole.IUnknown, iid *ole.GUID, punk **ole.IUnknown) uint32 { + pthis := (*stdDispatch)(unsafe.Pointer(this)) + *punk = nil + if ole.IsEqualGUID(iid, ole.IID_IUnknown) || + ole.IsEqualGUID(iid, ole.IID_IDispatch) { + dispAddRef(this) + *punk = this + return ole.S_OK + } + if ole.IsEqualGUID(iid, pthis.iid) { + dispAddRef(this) + *punk = this + return ole.S_OK + } + return ole.E_NOINTERFACE +} + +func dispAddRef(this *ole.IUnknown) int32 { + pthis := (*stdDispatch)(unsafe.Pointer(this)) + pthis.ref++ + return pthis.ref +} + +func dispRelease(this *ole.IUnknown) int32 { + pthis := (*stdDispatch)(unsafe.Pointer(this)) + pthis.ref-- + return pthis.ref +} + +func dispGetIDsOfNames(this *ole.IUnknown, iid *ole.GUID, wnames []*uint16, namelen int, lcid int, pdisp []int32) uintptr { + pthis := (*stdDispatch)(unsafe.Pointer(this)) + names := make([]string, len(wnames)) + for i := 0; i < len(names); i++ { + names[i] = ole.LpOleStrToString(wnames[i]) + } + for n := 0; n < namelen; n++ { + if id, ok := pthis.funcMap[names[n]]; ok { + pdisp[n] = id + } + } + return ole.S_OK +} + +func dispGetTypeInfoCount(pcount *int) uintptr { + if pcount != nil { + *pcount = 0 + } + return ole.S_OK +} + +func dispGetTypeInfo(ptypeif *uintptr) uintptr { + return ole.E_NOTIMPL +} + +func dispInvoke(this *ole.IDispatch, dispid int32, riid *ole.GUID, lcid int, flags int16, dispparams *ole.DISPPARAMS, result *ole.VARIANT, pexcepinfo *ole.EXCEPINFO, nerr *uint) uintptr { + pthis := (*stdDispatch)(unsafe.Pointer(this)) + found := "" + for name, id := range pthis.funcMap { + if id == dispid { + found = name + } + } + if found != "" { + rv := reflect.ValueOf(pthis.iface).Elem() + rm := rv.MethodByName(found) + rr := rm.Call([]reflect.Value{}) + println(len(rr)) + return ole.S_OK + } + return ole.E_NOTIMPL +} diff --git a/vendor/github.com/go-ole/go-ole/oleutil/connection_func.go b/vendor/github.com/go-ole/go-ole/oleutil/connection_func.go new file mode 100644 index 0000000000..8818fb8275 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/oleutil/connection_func.go @@ -0,0 +1,10 @@ +// +build !windows + +package oleutil + +import ole "github.com/go-ole/go-ole" + +// ConnectObject creates a connection point between two services for communication. +func ConnectObject(disp *ole.IDispatch, iid *ole.GUID, idisp interface{}) (uint32, error) { + return 0, ole.NewError(ole.E_NOTIMPL) +} diff --git a/vendor/github.com/go-ole/go-ole/oleutil/connection_windows.go b/vendor/github.com/go-ole/go-ole/oleutil/connection_windows.go new file mode 100644 index 0000000000..6b5c059993 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/oleutil/connection_windows.go @@ -0,0 +1,57 @@ +// +build windows + +package oleutil + +import ( + "reflect" + "syscall" + "unsafe" + + ole "github.com/go-ole/go-ole" +) + +// ConnectObject creates a connection point between two services for communication. +func ConnectObject(disp *ole.IDispatch, iid *ole.GUID, idisp interface{}) (cookie uint32, err error) { + unknown, err := disp.QueryInterface(ole.IID_IConnectionPointContainer) + if err != nil { + return + } + + container := (*ole.IConnectionPointContainer)(unsafe.Pointer(unknown)) + var point *ole.IConnectionPoint + err = container.FindConnectionPoint(iid, &point) + if err != nil { + return + } + if edisp, ok := idisp.(*ole.IUnknown); ok { + cookie, err = point.Advise(edisp) + container.Release() + if err != nil { + return + } + } + rv := reflect.ValueOf(disp).Elem() + if rv.Type().Kind() == reflect.Struct { + dest := &stdDispatch{} + dest.lpVtbl = &stdDispatchVtbl{} + dest.lpVtbl.pQueryInterface = syscall.NewCallback(dispQueryInterface) + dest.lpVtbl.pAddRef = syscall.NewCallback(dispAddRef) + dest.lpVtbl.pRelease = syscall.NewCallback(dispRelease) + dest.lpVtbl.pGetTypeInfoCount = syscall.NewCallback(dispGetTypeInfoCount) + dest.lpVtbl.pGetTypeInfo = syscall.NewCallback(dispGetTypeInfo) + dest.lpVtbl.pGetIDsOfNames = syscall.NewCallback(dispGetIDsOfNames) + dest.lpVtbl.pInvoke = syscall.NewCallback(dispInvoke) + dest.iface = disp + dest.iid = iid + cookie, err = point.Advise((*ole.IUnknown)(unsafe.Pointer(dest))) + container.Release() + if err != nil { + point.Release() + return + } + } + + container.Release() + + return 0, ole.NewError(ole.E_INVALIDARG) +} diff --git a/vendor/github.com/go-ole/go-ole/oleutil/go-get.go b/vendor/github.com/go-ole/go-ole/oleutil/go-get.go new file mode 100644 index 0000000000..58347628f2 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/oleutil/go-get.go @@ -0,0 +1,6 @@ +// This file is here so go get succeeds as without it errors with: +// no buildable Go source files in ... +// +// +build !windows + +package oleutil diff --git a/vendor/github.com/go-ole/go-ole/oleutil/oleutil.go b/vendor/github.com/go-ole/go-ole/oleutil/oleutil.go new file mode 100644 index 0000000000..55e072a636 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/oleutil/oleutil.go @@ -0,0 +1,89 @@ +package oleutil + +import ole "github.com/go-ole/go-ole" + +// ClassIDFrom retrieves class ID whether given is program ID or application string. +func ClassIDFrom(programID string) (classID *ole.GUID, err error) { + return ole.ClassIDFrom(programID) +} + +// CreateObject creates object from programID based on interface type. +// +// Only supports IUnknown. +// +// Program ID can be either program ID or application string. +func CreateObject(programID string) (unknown *ole.IUnknown, err error) { + classID, err := ole.ClassIDFrom(programID) + if err != nil { + return + } + + unknown, err = ole.CreateInstance(classID, ole.IID_IUnknown) + if err != nil { + return + } + + return +} + +// GetActiveObject retrieves active object for program ID and interface ID based +// on interface type. +// +// Only supports IUnknown. +// +// Program ID can be either program ID or application string. +func GetActiveObject(programID string) (unknown *ole.IUnknown, err error) { + classID, err := ole.ClassIDFrom(programID) + if err != nil { + return + } + + unknown, err = ole.GetActiveObject(classID, ole.IID_IUnknown) + if err != nil { + return + } + + return +} + +// CallMethod calls method on IDispatch with parameters. +func CallMethod(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT, err error) { + return disp.InvokeWithOptionalArgs(name, ole.DISPATCH_METHOD, params) +} + +// MustCallMethod calls method on IDispatch with parameters or panics. +func MustCallMethod(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT) { + r, err := CallMethod(disp, name, params...) + if err != nil { + panic(err.Error()) + } + return r +} + +// GetProperty retrieves property from IDispatch. +func GetProperty(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT, err error) { + return disp.InvokeWithOptionalArgs(name, ole.DISPATCH_PROPERTYGET, params) +} + +// MustGetProperty retrieves property from IDispatch or panics. +func MustGetProperty(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT) { + r, err := GetProperty(disp, name, params...) + if err != nil { + panic(err.Error()) + } + return r +} + +// PutProperty mutates property. +func PutProperty(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT, err error) { + return disp.InvokeWithOptionalArgs(name, ole.DISPATCH_PROPERTYPUT, params) +} + +// MustPutProperty mutates property or panics. +func MustPutProperty(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT) { + r, err := PutProperty(disp, name, params...) + if err != nil { + panic(err.Error()) + } + return r +} diff --git a/vendor/github.com/go-ole/go-ole/safearray.go b/vendor/github.com/go-ole/go-ole/safearray.go new file mode 100644 index 0000000000..a5201b56c3 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/safearray.go @@ -0,0 +1,27 @@ +// Package is meant to retrieve and process safe array data returned from COM. + +package ole + +// SafeArrayBound defines the SafeArray boundaries. +type SafeArrayBound struct { + Elements uint32 + LowerBound int32 +} + +// SafeArray is how COM handles arrays. +type SafeArray struct { + Dimensions uint16 + FeaturesFlag uint16 + ElementsSize uint32 + LocksAmount uint32 + Data uint32 + Bounds [16]byte +} + +// SAFEARRAY is obsolete, exists for backwards compatibility. +// Use SafeArray +type SAFEARRAY SafeArray + +// SAFEARRAYBOUND is obsolete, exists for backwards compatibility. +// Use SafeArrayBound +type SAFEARRAYBOUND SafeArrayBound diff --git a/vendor/github.com/go-ole/go-ole/safearray_func.go b/vendor/github.com/go-ole/go-ole/safearray_func.go new file mode 100644 index 0000000000..8ff0baa41d --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/safearray_func.go @@ -0,0 +1,211 @@ +// +build !windows + +package ole + +import ( + "unsafe" +) + +// safeArrayAccessData returns raw array pointer. +// +// AKA: SafeArrayAccessData in Windows API. +func safeArrayAccessData(safearray *SafeArray) (uintptr, error) { + return uintptr(0), NewError(E_NOTIMPL) +} + +// safeArrayUnaccessData releases raw array. +// +// AKA: SafeArrayUnaccessData in Windows API. +func safeArrayUnaccessData(safearray *SafeArray) error { + return NewError(E_NOTIMPL) +} + +// safeArrayAllocData allocates SafeArray. +// +// AKA: SafeArrayAllocData in Windows API. +func safeArrayAllocData(safearray *SafeArray) error { + return NewError(E_NOTIMPL) +} + +// safeArrayAllocDescriptor allocates SafeArray. +// +// AKA: SafeArrayAllocDescriptor in Windows API. +func safeArrayAllocDescriptor(dimensions uint32) (*SafeArray, error) { + return nil, NewError(E_NOTIMPL) +} + +// safeArrayAllocDescriptorEx allocates SafeArray. +// +// AKA: SafeArrayAllocDescriptorEx in Windows API. +func safeArrayAllocDescriptorEx(variantType VT, dimensions uint32) (*SafeArray, error) { + return nil, NewError(E_NOTIMPL) +} + +// safeArrayCopy returns copy of SafeArray. +// +// AKA: SafeArrayCopy in Windows API. +func safeArrayCopy(original *SafeArray) (*SafeArray, error) { + return nil, NewError(E_NOTIMPL) +} + +// safeArrayCopyData duplicates SafeArray into another SafeArray object. +// +// AKA: SafeArrayCopyData in Windows API. +func safeArrayCopyData(original *SafeArray, duplicate *SafeArray) error { + return NewError(E_NOTIMPL) +} + +// safeArrayCreate creates SafeArray. +// +// AKA: SafeArrayCreate in Windows API. +func safeArrayCreate(variantType VT, dimensions uint32, bounds *SafeArrayBound) (*SafeArray, error) { + return nil, NewError(E_NOTIMPL) +} + +// safeArrayCreateEx creates SafeArray. +// +// AKA: SafeArrayCreateEx in Windows API. +func safeArrayCreateEx(variantType VT, dimensions uint32, bounds *SafeArrayBound, extra uintptr) (*SafeArray, error) { + return nil, NewError(E_NOTIMPL) +} + +// safeArrayCreateVector creates SafeArray. +// +// AKA: SafeArrayCreateVector in Windows API. +func safeArrayCreateVector(variantType VT, lowerBound int32, length uint32) (*SafeArray, error) { + return nil, NewError(E_NOTIMPL) +} + +// safeArrayCreateVectorEx creates SafeArray. +// +// AKA: SafeArrayCreateVectorEx in Windows API. +func safeArrayCreateVectorEx(variantType VT, lowerBound int32, length uint32, extra uintptr) (*SafeArray, error) { + return nil, NewError(E_NOTIMPL) +} + +// safeArrayDestroy destroys SafeArray object. +// +// AKA: SafeArrayDestroy in Windows API. +func safeArrayDestroy(safearray *SafeArray) error { + return NewError(E_NOTIMPL) +} + +// safeArrayDestroyData destroys SafeArray object. +// +// AKA: SafeArrayDestroyData in Windows API. +func safeArrayDestroyData(safearray *SafeArray) error { + return NewError(E_NOTIMPL) +} + +// safeArrayDestroyDescriptor destroys SafeArray object. +// +// AKA: SafeArrayDestroyDescriptor in Windows API. +func safeArrayDestroyDescriptor(safearray *SafeArray) error { + return NewError(E_NOTIMPL) +} + +// safeArrayGetDim is the amount of dimensions in the SafeArray. +// +// SafeArrays may have multiple dimensions. Meaning, it could be +// multidimensional array. +// +// AKA: SafeArrayGetDim in Windows API. +func safeArrayGetDim(safearray *SafeArray) (*uint32, error) { + u := uint32(0) + return &u, NewError(E_NOTIMPL) +} + +// safeArrayGetElementSize is the element size in bytes. +// +// AKA: SafeArrayGetElemsize in Windows API. +func safeArrayGetElementSize(safearray *SafeArray) (*uint32, error) { + u := uint32(0) + return &u, NewError(E_NOTIMPL) +} + +// safeArrayGetElement retrieves element at given index. +func safeArrayGetElement(safearray *SafeArray, index int64, pv unsafe.Pointer) error { + return NewError(E_NOTIMPL) +} + +// safeArrayGetElement retrieves element at given index and converts to string. +func safeArrayGetElementString(safearray *SafeArray, index int64) (string, error) { + return "", NewError(E_NOTIMPL) +} + +// safeArrayGetIID is the InterfaceID of the elements in the SafeArray. +// +// AKA: SafeArrayGetIID in Windows API. +func safeArrayGetIID(safearray *SafeArray) (*GUID, error) { + return nil, NewError(E_NOTIMPL) +} + +// safeArrayGetLBound returns lower bounds of SafeArray. +// +// SafeArrays may have multiple dimensions. Meaning, it could be +// multidimensional array. +// +// AKA: SafeArrayGetLBound in Windows API. +func safeArrayGetLBound(safearray *SafeArray, dimension uint32) (int64, error) { + return int64(0), NewError(E_NOTIMPL) +} + +// safeArrayGetUBound returns upper bounds of SafeArray. +// +// SafeArrays may have multiple dimensions. Meaning, it could be +// multidimensional array. +// +// AKA: SafeArrayGetUBound in Windows API. +func safeArrayGetUBound(safearray *SafeArray, dimension uint32) (int64, error) { + return int64(0), NewError(E_NOTIMPL) +} + +// safeArrayGetVartype returns data type of SafeArray. +// +// AKA: SafeArrayGetVartype in Windows API. +func safeArrayGetVartype(safearray *SafeArray) (uint16, error) { + return uint16(0), NewError(E_NOTIMPL) +} + +// safeArrayLock locks SafeArray for reading to modify SafeArray. +// +// This must be called during some calls to ensure that another process does not +// read or write to the SafeArray during editing. +// +// AKA: SafeArrayLock in Windows API. +func safeArrayLock(safearray *SafeArray) error { + return NewError(E_NOTIMPL) +} + +// safeArrayUnlock unlocks SafeArray for reading. +// +// AKA: SafeArrayUnlock in Windows API. +func safeArrayUnlock(safearray *SafeArray) error { + return NewError(E_NOTIMPL) +} + +// safeArrayPutElement stores the data element at the specified location in the +// array. +// +// AKA: SafeArrayPutElement in Windows API. +func safeArrayPutElement(safearray *SafeArray, index int64, element uintptr) error { + return NewError(E_NOTIMPL) +} + +// safeArrayGetRecordInfo accesses IRecordInfo info for custom types. +// +// AKA: SafeArrayGetRecordInfo in Windows API. +// +// XXX: Must implement IRecordInfo interface for this to return. +func safeArrayGetRecordInfo(safearray *SafeArray) (interface{}, error) { + return nil, NewError(E_NOTIMPL) +} + +// safeArraySetRecordInfo mutates IRecordInfo info for custom types. +// +// AKA: SafeArraySetRecordInfo in Windows API. +// +// XXX: Must implement IRecordInfo interface for this to return. +func safeArraySetRecordInfo(safearray *SafeArray, recordInfo interface{}) error { + return NewError(E_NOTIMPL) +} diff --git a/vendor/github.com/go-ole/go-ole/safearray_windows.go b/vendor/github.com/go-ole/go-ole/safearray_windows.go new file mode 100644 index 0000000000..b27936e24e --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/safearray_windows.go @@ -0,0 +1,337 @@ +// +build windows + +package ole + +import ( + "unsafe" +) + +var ( + procSafeArrayAccessData, _ = modoleaut32.FindProc("SafeArrayAccessData") + procSafeArrayAllocData, _ = modoleaut32.FindProc("SafeArrayAllocData") + procSafeArrayAllocDescriptor, _ = modoleaut32.FindProc("SafeArrayAllocDescriptor") + procSafeArrayAllocDescriptorEx, _ = modoleaut32.FindProc("SafeArrayAllocDescriptorEx") + procSafeArrayCopy, _ = modoleaut32.FindProc("SafeArrayCopy") + procSafeArrayCopyData, _ = modoleaut32.FindProc("SafeArrayCopyData") + procSafeArrayCreate, _ = modoleaut32.FindProc("SafeArrayCreate") + procSafeArrayCreateEx, _ = modoleaut32.FindProc("SafeArrayCreateEx") + procSafeArrayCreateVector, _ = modoleaut32.FindProc("SafeArrayCreateVector") + procSafeArrayCreateVectorEx, _ = modoleaut32.FindProc("SafeArrayCreateVectorEx") + procSafeArrayDestroy, _ = modoleaut32.FindProc("SafeArrayDestroy") + procSafeArrayDestroyData, _ = modoleaut32.FindProc("SafeArrayDestroyData") + procSafeArrayDestroyDescriptor, _ = modoleaut32.FindProc("SafeArrayDestroyDescriptor") + procSafeArrayGetDim, _ = modoleaut32.FindProc("SafeArrayGetDim") + procSafeArrayGetElement, _ = modoleaut32.FindProc("SafeArrayGetElement") + procSafeArrayGetElemsize, _ = modoleaut32.FindProc("SafeArrayGetElemsize") + procSafeArrayGetIID, _ = modoleaut32.FindProc("SafeArrayGetIID") + procSafeArrayGetLBound, _ = modoleaut32.FindProc("SafeArrayGetLBound") + procSafeArrayGetUBound, _ = modoleaut32.FindProc("SafeArrayGetUBound") + procSafeArrayGetVartype, _ = modoleaut32.FindProc("SafeArrayGetVartype") + procSafeArrayLock, _ = modoleaut32.FindProc("SafeArrayLock") + procSafeArrayPtrOfIndex, _ = modoleaut32.FindProc("SafeArrayPtrOfIndex") + procSafeArrayUnaccessData, _ = modoleaut32.FindProc("SafeArrayUnaccessData") + procSafeArrayUnlock, _ = modoleaut32.FindProc("SafeArrayUnlock") + procSafeArrayPutElement, _ = modoleaut32.FindProc("SafeArrayPutElement") + //procSafeArrayRedim, _ = modoleaut32.FindProc("SafeArrayRedim") // TODO + //procSafeArraySetIID, _ = modoleaut32.FindProc("SafeArraySetIID") // TODO + procSafeArrayGetRecordInfo, _ = modoleaut32.FindProc("SafeArrayGetRecordInfo") + procSafeArraySetRecordInfo, _ = modoleaut32.FindProc("SafeArraySetRecordInfo") +) + +// safeArrayAccessData returns raw array pointer. +// +// AKA: SafeArrayAccessData in Windows API. +// Todo: Test +func safeArrayAccessData(safearray *SafeArray) (element uintptr, err error) { + err = convertHresultToError( + procSafeArrayAccessData.Call( + uintptr(unsafe.Pointer(safearray)), + uintptr(unsafe.Pointer(&element)))) + return +} + +// safeArrayUnaccessData releases raw array. +// +// AKA: SafeArrayUnaccessData in Windows API. +func safeArrayUnaccessData(safearray *SafeArray) (err error) { + err = convertHresultToError(procSafeArrayUnaccessData.Call(uintptr(unsafe.Pointer(safearray)))) + return +} + +// safeArrayAllocData allocates SafeArray. +// +// AKA: SafeArrayAllocData in Windows API. +func safeArrayAllocData(safearray *SafeArray) (err error) { + err = convertHresultToError(procSafeArrayAllocData.Call(uintptr(unsafe.Pointer(safearray)))) + return +} + +// safeArrayAllocDescriptor allocates SafeArray. +// +// AKA: SafeArrayAllocDescriptor in Windows API. +func safeArrayAllocDescriptor(dimensions uint32) (safearray *SafeArray, err error) { + err = convertHresultToError( + procSafeArrayAllocDescriptor.Call(uintptr(dimensions), uintptr(unsafe.Pointer(&safearray)))) + return +} + +// safeArrayAllocDescriptorEx allocates SafeArray. +// +// AKA: SafeArrayAllocDescriptorEx in Windows API. +func safeArrayAllocDescriptorEx(variantType VT, dimensions uint32) (safearray *SafeArray, err error) { + err = convertHresultToError( + procSafeArrayAllocDescriptorEx.Call( + uintptr(variantType), + uintptr(dimensions), + uintptr(unsafe.Pointer(&safearray)))) + return +} + +// safeArrayCopy returns copy of SafeArray. +// +// AKA: SafeArrayCopy in Windows API. +func safeArrayCopy(original *SafeArray) (safearray *SafeArray, err error) { + err = convertHresultToError( + procSafeArrayCopy.Call( + uintptr(unsafe.Pointer(original)), + uintptr(unsafe.Pointer(&safearray)))) + return +} + +// safeArrayCopyData duplicates SafeArray into another SafeArray object. +// +// AKA: SafeArrayCopyData in Windows API. +func safeArrayCopyData(original *SafeArray, duplicate *SafeArray) (err error) { + err = convertHresultToError( + procSafeArrayCopyData.Call( + uintptr(unsafe.Pointer(original)), + uintptr(unsafe.Pointer(duplicate)))) + return +} + +// safeArrayCreate creates SafeArray. +// +// AKA: SafeArrayCreate in Windows API. +func safeArrayCreate(variantType VT, dimensions uint32, bounds *SafeArrayBound) (safearray *SafeArray, err error) { + sa, _, err := procSafeArrayCreate.Call( + uintptr(variantType), + uintptr(dimensions), + uintptr(unsafe.Pointer(bounds))) + safearray = (*SafeArray)(unsafe.Pointer(&sa)) + return +} + +// safeArrayCreateEx creates SafeArray. +// +// AKA: SafeArrayCreateEx in Windows API. +func safeArrayCreateEx(variantType VT, dimensions uint32, bounds *SafeArrayBound, extra uintptr) (safearray *SafeArray, err error) { + sa, _, err := procSafeArrayCreateEx.Call( + uintptr(variantType), + uintptr(dimensions), + uintptr(unsafe.Pointer(bounds)), + extra) + safearray = (*SafeArray)(unsafe.Pointer(sa)) + return +} + +// safeArrayCreateVector creates SafeArray. +// +// AKA: SafeArrayCreateVector in Windows API. +func safeArrayCreateVector(variantType VT, lowerBound int32, length uint32) (safearray *SafeArray, err error) { + sa, _, err := procSafeArrayCreateVector.Call( + uintptr(variantType), + uintptr(lowerBound), + uintptr(length)) + safearray = (*SafeArray)(unsafe.Pointer(sa)) + return +} + +// safeArrayCreateVectorEx creates SafeArray. +// +// AKA: SafeArrayCreateVectorEx in Windows API. +func safeArrayCreateVectorEx(variantType VT, lowerBound int32, length uint32, extra uintptr) (safearray *SafeArray, err error) { + sa, _, err := procSafeArrayCreateVectorEx.Call( + uintptr(variantType), + uintptr(lowerBound), + uintptr(length), + extra) + safearray = (*SafeArray)(unsafe.Pointer(sa)) + return +} + +// safeArrayDestroy destroys SafeArray object. +// +// AKA: SafeArrayDestroy in Windows API. +func safeArrayDestroy(safearray *SafeArray) (err error) { + err = convertHresultToError(procSafeArrayDestroy.Call(uintptr(unsafe.Pointer(safearray)))) + return +} + +// safeArrayDestroyData destroys SafeArray object. +// +// AKA: SafeArrayDestroyData in Windows API. +func safeArrayDestroyData(safearray *SafeArray) (err error) { + err = convertHresultToError(procSafeArrayDestroyData.Call(uintptr(unsafe.Pointer(safearray)))) + return +} + +// safeArrayDestroyDescriptor destroys SafeArray object. +// +// AKA: SafeArrayDestroyDescriptor in Windows API. +func safeArrayDestroyDescriptor(safearray *SafeArray) (err error) { + err = convertHresultToError(procSafeArrayDestroyDescriptor.Call(uintptr(unsafe.Pointer(safearray)))) + return +} + +// safeArrayGetDim is the amount of dimensions in the SafeArray. +// +// SafeArrays may have multiple dimensions. Meaning, it could be +// multidimensional array. +// +// AKA: SafeArrayGetDim in Windows API. +func safeArrayGetDim(safearray *SafeArray) (dimensions *uint32, err error) { + l, _, err := procSafeArrayGetDim.Call(uintptr(unsafe.Pointer(safearray))) + dimensions = (*uint32)(unsafe.Pointer(l)) + return +} + +// safeArrayGetElementSize is the element size in bytes. +// +// AKA: SafeArrayGetElemsize in Windows API. +func safeArrayGetElementSize(safearray *SafeArray) (length *uint32, err error) { + l, _, err := procSafeArrayGetElemsize.Call(uintptr(unsafe.Pointer(safearray))) + length = (*uint32)(unsafe.Pointer(l)) + return +} + +// safeArrayGetElement retrieves element at given index. +func safeArrayGetElement(safearray *SafeArray, index int64, pv unsafe.Pointer) error { + return convertHresultToError( + procSafeArrayGetElement.Call( + uintptr(unsafe.Pointer(safearray)), + uintptr(unsafe.Pointer(&index)), + uintptr(pv))) +} + +// safeArrayGetElementString retrieves element at given index and converts to string. +func safeArrayGetElementString(safearray *SafeArray, index int64) (str string, err error) { + var element *int16 + err = convertHresultToError( + procSafeArrayGetElement.Call( + uintptr(unsafe.Pointer(safearray)), + uintptr(unsafe.Pointer(&index)), + uintptr(unsafe.Pointer(&element)))) + str = BstrToString(*(**uint16)(unsafe.Pointer(&element))) + SysFreeString(element) + return +} + +// safeArrayGetIID is the InterfaceID of the elements in the SafeArray. +// +// AKA: SafeArrayGetIID in Windows API. +func safeArrayGetIID(safearray *SafeArray) (guid *GUID, err error) { + err = convertHresultToError( + procSafeArrayGetIID.Call( + uintptr(unsafe.Pointer(safearray)), + uintptr(unsafe.Pointer(&guid)))) + return +} + +// safeArrayGetLBound returns lower bounds of SafeArray. +// +// SafeArrays may have multiple dimensions. Meaning, it could be +// multidimensional array. +// +// AKA: SafeArrayGetLBound in Windows API. +func safeArrayGetLBound(safearray *SafeArray, dimension uint32) (lowerBound int64, err error) { + err = convertHresultToError( + procSafeArrayGetLBound.Call( + uintptr(unsafe.Pointer(safearray)), + uintptr(dimension), + uintptr(unsafe.Pointer(&lowerBound)))) + return +} + +// safeArrayGetUBound returns upper bounds of SafeArray. +// +// SafeArrays may have multiple dimensions. Meaning, it could be +// multidimensional array. +// +// AKA: SafeArrayGetUBound in Windows API. +func safeArrayGetUBound(safearray *SafeArray, dimension uint32) (upperBound int64, err error) { + err = convertHresultToError( + procSafeArrayGetUBound.Call( + uintptr(unsafe.Pointer(safearray)), + uintptr(dimension), + uintptr(unsafe.Pointer(&upperBound)))) + return +} + +// safeArrayGetVartype returns data type of SafeArray. +// +// AKA: SafeArrayGetVartype in Windows API. +func safeArrayGetVartype(safearray *SafeArray) (varType uint16, err error) { + err = convertHresultToError( + procSafeArrayGetVartype.Call( + uintptr(unsafe.Pointer(safearray)), + uintptr(unsafe.Pointer(&varType)))) + return +} + +// safeArrayLock locks SafeArray for reading to modify SafeArray. +// +// This must be called during some calls to ensure that another process does not +// read or write to the SafeArray during editing. +// +// AKA: SafeArrayLock in Windows API. +func safeArrayLock(safearray *SafeArray) (err error) { + err = convertHresultToError(procSafeArrayLock.Call(uintptr(unsafe.Pointer(safearray)))) + return +} + +// safeArrayUnlock unlocks SafeArray for reading. +// +// AKA: SafeArrayUnlock in Windows API. +func safeArrayUnlock(safearray *SafeArray) (err error) { + err = convertHresultToError(procSafeArrayUnlock.Call(uintptr(unsafe.Pointer(safearray)))) + return +} + +// safeArrayPutElement stores the data element at the specified location in the +// array. +// +// AKA: SafeArrayPutElement in Windows API. +func safeArrayPutElement(safearray *SafeArray, index int64, element uintptr) (err error) { + err = convertHresultToError( + procSafeArrayPutElement.Call( + uintptr(unsafe.Pointer(safearray)), + uintptr(unsafe.Pointer(&index)), + uintptr(unsafe.Pointer(element)))) + return +} + +// safeArrayGetRecordInfo accesses IRecordInfo info for custom types. +// +// AKA: SafeArrayGetRecordInfo in Windows API. +// +// XXX: Must implement IRecordInfo interface for this to return. +func safeArrayGetRecordInfo(safearray *SafeArray) (recordInfo interface{}, err error) { + err = convertHresultToError( + procSafeArrayGetRecordInfo.Call( + uintptr(unsafe.Pointer(safearray)), + uintptr(unsafe.Pointer(&recordInfo)))) + return +} + +// safeArraySetRecordInfo mutates IRecordInfo info for custom types. +// +// AKA: SafeArraySetRecordInfo in Windows API. +// +// XXX: Must implement IRecordInfo interface for this to return. +func safeArraySetRecordInfo(safearray *SafeArray, recordInfo interface{}) (err error) { + err = convertHresultToError( + procSafeArraySetRecordInfo.Call( + uintptr(unsafe.Pointer(safearray)), + uintptr(unsafe.Pointer(&recordInfo)))) + return +} diff --git a/vendor/github.com/go-ole/go-ole/safearrayconversion.go b/vendor/github.com/go-ole/go-ole/safearrayconversion.go new file mode 100644 index 0000000000..ffeb2b97b0 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/safearrayconversion.go @@ -0,0 +1,140 @@ +// Helper for converting SafeArray to array of objects. + +package ole + +import ( + "unsafe" +) + +type SafeArrayConversion struct { + Array *SafeArray +} + +func (sac *SafeArrayConversion) ToStringArray() (strings []string) { + totalElements, _ := sac.TotalElements(0) + strings = make([]string, totalElements) + + for i := int64(0); i < totalElements; i++ { + strings[int32(i)], _ = safeArrayGetElementString(sac.Array, i) + } + + return +} + +func (sac *SafeArrayConversion) ToByteArray() (bytes []byte) { + totalElements, _ := sac.TotalElements(0) + bytes = make([]byte, totalElements) + + for i := int64(0); i < totalElements; i++ { + safeArrayGetElement(sac.Array, i, unsafe.Pointer(&bytes[int32(i)])) + } + + return +} + +func (sac *SafeArrayConversion) ToValueArray() (values []interface{}) { + totalElements, _ := sac.TotalElements(0) + values = make([]interface{}, totalElements) + vt, _ := safeArrayGetVartype(sac.Array) + + for i := 0; i < int(totalElements); i++ { + switch VT(vt) { + case VT_BOOL: + var v bool + safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) + values[i] = v + case VT_I1: + var v int8 + safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) + values[i] = v + case VT_I2: + var v int16 + safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) + values[i] = v + case VT_I4: + var v int32 + safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) + values[i] = v + case VT_I8: + var v int64 + safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) + values[i] = v + case VT_UI1: + var v uint8 + safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) + values[i] = v + case VT_UI2: + var v uint16 + safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) + values[i] = v + case VT_UI4: + var v uint32 + safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) + values[i] = v + case VT_UI8: + var v uint64 + safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) + values[i] = v + case VT_R4: + var v float32 + safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) + values[i] = v + case VT_R8: + var v float64 + safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) + values[i] = v + case VT_BSTR: + var v string + safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) + values[i] = v + case VT_VARIANT: + var v VARIANT + safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) + values[i] = v.Value() + default: + // TODO + } + } + + return +} + +func (sac *SafeArrayConversion) GetType() (varType uint16, err error) { + return safeArrayGetVartype(sac.Array) +} + +func (sac *SafeArrayConversion) GetDimensions() (dimensions *uint32, err error) { + return safeArrayGetDim(sac.Array) +} + +func (sac *SafeArrayConversion) GetSize() (length *uint32, err error) { + return safeArrayGetElementSize(sac.Array) +} + +func (sac *SafeArrayConversion) TotalElements(index uint32) (totalElements int64, err error) { + if index < 1 { + index = 1 + } + + // Get array bounds + var LowerBounds int64 + var UpperBounds int64 + + LowerBounds, err = safeArrayGetLBound(sac.Array, index) + if err != nil { + return + } + + UpperBounds, err = safeArrayGetUBound(sac.Array, index) + if err != nil { + return + } + + totalElements = UpperBounds - LowerBounds + 1 + return +} + +// Release Safe Array memory +func (sac *SafeArrayConversion) Release() { + safeArrayDestroy(sac.Array) +} diff --git a/vendor/github.com/go-ole/go-ole/safearrayslices.go b/vendor/github.com/go-ole/go-ole/safearrayslices.go new file mode 100644 index 0000000000..a9fa885f1d --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/safearrayslices.go @@ -0,0 +1,33 @@ +// +build windows + +package ole + +import ( + "unsafe" +) + +func safeArrayFromByteSlice(slice []byte) *SafeArray { + array, _ := safeArrayCreateVector(VT_UI1, 0, uint32(len(slice))) + + if array == nil { + panic("Could not convert []byte to SAFEARRAY") + } + + for i, v := range slice { + safeArrayPutElement(array, int64(i), uintptr(unsafe.Pointer(&v))) + } + return array +} + +func safeArrayFromStringSlice(slice []string) *SafeArray { + array, _ := safeArrayCreateVector(VT_BSTR, 0, uint32(len(slice))) + + if array == nil { + panic("Could not convert []string to SAFEARRAY") + } + // SysAllocStringLen(s) + for i, v := range slice { + safeArrayPutElement(array, int64(i), uintptr(unsafe.Pointer(SysAllocStringLen(v)))) + } + return array +} diff --git a/vendor/github.com/go-ole/go-ole/utility.go b/vendor/github.com/go-ole/go-ole/utility.go new file mode 100644 index 0000000000..99ee82dc34 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/utility.go @@ -0,0 +1,101 @@ +package ole + +import ( + "unicode/utf16" + "unsafe" +) + +// ClassIDFrom retrieves class ID whether given is program ID or application string. +// +// Helper that provides check against both Class ID from Program ID and Class ID from string. It is +// faster, if you know which you are using, to use the individual functions, but this will check +// against available functions for you. +func ClassIDFrom(programID string) (classID *GUID, err error) { + classID, err = CLSIDFromProgID(programID) + if err != nil { + classID, err = CLSIDFromString(programID) + if err != nil { + return + } + } + return +} + +// BytePtrToString converts byte pointer to a Go string. +func BytePtrToString(p *byte) string { + a := (*[10000]uint8)(unsafe.Pointer(p)) + i := 0 + for a[i] != 0 { + i++ + } + return string(a[:i]) +} + +// UTF16PtrToString is alias for LpOleStrToString. +// +// Kept for compatibility reasons. +func UTF16PtrToString(p *uint16) string { + return LpOleStrToString(p) +} + +// LpOleStrToString converts COM Unicode to Go string. +func LpOleStrToString(p *uint16) string { + if p == nil { + return "" + } + + length := lpOleStrLen(p) + a := make([]uint16, length) + + ptr := unsafe.Pointer(p) + + for i := 0; i < int(length); i++ { + a[i] = *(*uint16)(ptr) + ptr = unsafe.Pointer(uintptr(ptr) + 2) + } + + return string(utf16.Decode(a)) +} + +// BstrToString converts COM binary string to Go string. +func BstrToString(p *uint16) string { + if p == nil { + return "" + } + length := SysStringLen((*int16)(unsafe.Pointer(p))) + a := make([]uint16, length) + + ptr := unsafe.Pointer(p) + + for i := 0; i < int(length); i++ { + a[i] = *(*uint16)(ptr) + ptr = unsafe.Pointer(uintptr(ptr) + 2) + } + return string(utf16.Decode(a)) +} + +// lpOleStrLen returns the length of Unicode string. +func lpOleStrLen(p *uint16) (length int64) { + if p == nil { + return 0 + } + + ptr := unsafe.Pointer(p) + + for i := 0; ; i++ { + if 0 == *(*uint16)(ptr) { + length = int64(i) + break + } + ptr = unsafe.Pointer(uintptr(ptr) + 2) + } + return +} + +// convertHresultToError converts syscall to error, if call is unsuccessful. +func convertHresultToError(hr uintptr, r2 uintptr, ignore error) (err error) { + if hr != 0 { + err = NewError(hr) + } + return +} diff --git a/vendor/github.com/go-ole/go-ole/variables.go b/vendor/github.com/go-ole/go-ole/variables.go new file mode 100644 index 0000000000..ebe00f1cfc --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/variables.go @@ -0,0 +1,16 @@ +// +build windows + +package ole + +import ( + "syscall" +) + +var ( + modcombase = syscall.NewLazyDLL("combase.dll") + modkernel32, _ = syscall.LoadDLL("kernel32.dll") + modole32, _ = syscall.LoadDLL("ole32.dll") + modoleaut32, _ = syscall.LoadDLL("oleaut32.dll") + modmsvcrt, _ = syscall.LoadDLL("msvcrt.dll") + moduser32, _ = syscall.LoadDLL("user32.dll") +) diff --git a/vendor/github.com/go-ole/go-ole/variant.go b/vendor/github.com/go-ole/go-ole/variant.go new file mode 100644 index 0000000000..36969725eb --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/variant.go @@ -0,0 +1,105 @@ +package ole + +import "unsafe" + +// NewVariant returns new variant based on type and value. +func NewVariant(vt VT, val int64) VARIANT { + return VARIANT{VT: vt, Val: val} +} + +// ToIUnknown converts Variant to Unknown object. +func (v *VARIANT) ToIUnknown() *IUnknown { + if v.VT != VT_UNKNOWN { + return nil + } + return (*IUnknown)(unsafe.Pointer(uintptr(v.Val))) +} + +// ToIDispatch converts variant to dispatch object. +func (v *VARIANT) ToIDispatch() *IDispatch { + if v.VT != VT_DISPATCH { + return nil + } + return (*IDispatch)(unsafe.Pointer(uintptr(v.Val))) +} + +// ToArray converts variant to SafeArray helper. +func (v *VARIANT) ToArray() *SafeArrayConversion { + if v.VT != VT_SAFEARRAY { + if v.VT&VT_ARRAY == 0 { + return nil + } + } + var safeArray *SafeArray = (*SafeArray)(unsafe.Pointer(uintptr(v.Val))) + return &SafeArrayConversion{safeArray} +} + +// ToString converts variant to Go string. +func (v *VARIANT) ToString() string { + if v.VT != VT_BSTR { + return "" + } + return BstrToString(*(**uint16)(unsafe.Pointer(&v.Val))) +} + +// Clear the memory of variant object. +func (v *VARIANT) Clear() error { + return VariantClear(v) +} + +// Value returns variant value based on its type. +// +// Currently supported types: 2- and 4-byte integers, strings, bools. +// Note that 64-bit integers, datetimes, and other types are stored as strings +// and will be returned as strings. +// +// Needs to be further converted, because this returns an interface{}. +func (v *VARIANT) Value() interface{} { + switch v.VT { + case VT_I1: + return int8(v.Val) + case VT_UI1: + return uint8(v.Val) + case VT_I2: + return int16(v.Val) + case VT_UI2: + return uint16(v.Val) + case VT_I4: + return int32(v.Val) + case VT_UI4: + return uint32(v.Val) + case VT_I8: + return int64(v.Val) + case VT_UI8: + return uint64(v.Val) + case VT_INT: + return int(v.Val) + case VT_UINT: + return uint(v.Val) + case VT_INT_PTR: + return uintptr(v.Val) // TODO + case VT_UINT_PTR: + return uintptr(v.Val) + case VT_R4: + return *(*float32)(unsafe.Pointer(&v.Val)) + case VT_R8: + return *(*float64)(unsafe.Pointer(&v.Val)) + case VT_BSTR: + return v.ToString() + case VT_DATE: + // VT_DATE type will either return float64 or time.Time. + d := float64(v.Val) + date, err := GetVariantDate(d) + if err != nil { + return d + } + return date + case VT_UNKNOWN: + return v.ToIUnknown() + case VT_DISPATCH: + return v.ToIDispatch() + case VT_BOOL: + return v.Val != 0 + } + return nil +} diff --git a/vendor/github.com/go-ole/go-ole/variant_386.go b/vendor/github.com/go-ole/go-ole/variant_386.go new file mode 100644 index 0000000000..e73736bf39 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/variant_386.go @@ -0,0 +1,11 @@ +// +build 386 + +package ole + +type VARIANT struct { + VT VT // 2 + wReserved1 uint16 // 4 + wReserved2 uint16 // 6 + wReserved3 uint16 // 8 + Val int64 // 16 +} diff --git a/vendor/github.com/go-ole/go-ole/variant_amd64.go b/vendor/github.com/go-ole/go-ole/variant_amd64.go new file mode 100644 index 0000000000..dccdde1323 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/variant_amd64.go @@ -0,0 +1,12 @@ +// +build amd64 + +package ole + +type VARIANT struct { + VT VT // 2 + wReserved1 uint16 // 4 + wReserved2 uint16 // 6 + wReserved3 uint16 // 8 + Val int64 // 16 + _ [8]byte // 24 +} diff --git a/vendor/github.com/go-ole/go-ole/vt_string.go b/vendor/github.com/go-ole/go-ole/vt_string.go new file mode 100644 index 0000000000..729b4a04dd --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/vt_string.go @@ -0,0 +1,58 @@ +// generated by stringer -output vt_string.go -type VT; DO NOT EDIT + +package ole + +import "fmt" + +const ( + _VT_name_0 = "VT_EMPTYVT_NULLVT_I2VT_I4VT_R4VT_R8VT_CYVT_DATEVT_BSTRVT_DISPATCHVT_ERRORVT_BOOLVT_VARIANTVT_UNKNOWNVT_DECIMAL" + _VT_name_1 = "VT_I1VT_UI1VT_UI2VT_UI4VT_I8VT_UI8VT_INTVT_UINTVT_VOIDVT_HRESULTVT_PTRVT_SAFEARRAYVT_CARRAYVT_USERDEFINEDVT_LPSTRVT_LPWSTR" + _VT_name_2 = "VT_RECORDVT_INT_PTRVT_UINT_PTR" + _VT_name_3 = "VT_FILETIMEVT_BLOBVT_STREAMVT_STORAGEVT_STREAMED_OBJECTVT_STORED_OBJECTVT_BLOB_OBJECTVT_CFVT_CLSID" + _VT_name_4 = "VT_BSTR_BLOBVT_VECTOR" + _VT_name_5 = "VT_ARRAY" + _VT_name_6 = "VT_BYREF" + _VT_name_7 = "VT_RESERVED" + _VT_name_8 = "VT_ILLEGAL" +) + +var ( + _VT_index_0 = [...]uint8{0, 8, 15, 20, 25, 30, 35, 40, 47, 54, 65, 73, 80, 90, 100, 110} + _VT_index_1 = [...]uint8{0, 5, 11, 17, 23, 28, 34, 40, 47, 54, 64, 70, 82, 91, 105, 113, 122} + _VT_index_2 = [...]uint8{0, 9, 19, 30} + _VT_index_3 = [...]uint8{0, 11, 18, 27, 37, 55, 71, 85, 90, 98} + _VT_index_4 = [...]uint8{0, 12, 21} + _VT_index_5 = [...]uint8{0, 8} + _VT_index_6 = [...]uint8{0, 8} + _VT_index_7 = [...]uint8{0, 11} + _VT_index_8 = [...]uint8{0, 10} +) + +func (i VT) String() string { + switch { + case 0 <= i && i <= 14: + return _VT_name_0[_VT_index_0[i]:_VT_index_0[i+1]] + case 16 <= i && i <= 31: + i -= 16 + return _VT_name_1[_VT_index_1[i]:_VT_index_1[i+1]] + case 36 <= i && i <= 38: + i -= 36 + return _VT_name_2[_VT_index_2[i]:_VT_index_2[i+1]] + case 64 <= i && i <= 72: + i -= 64 + return _VT_name_3[_VT_index_3[i]:_VT_index_3[i+1]] + case 4095 <= i && i <= 4096: + i -= 4095 + return _VT_name_4[_VT_index_4[i]:_VT_index_4[i+1]] + case i == 8192: + return _VT_name_5 + case i == 16384: + return _VT_name_6 + case i == 32768: + return _VT_name_7 + case i == 65535: + return _VT_name_8 + default: + return fmt.Sprintf("VT(%d)", i) + } +} diff --git a/vendor/github.com/go-ole/go-ole/winrt.go b/vendor/github.com/go-ole/go-ole/winrt.go new file mode 100644 index 0000000000..4e9eca7324 --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/winrt.go @@ -0,0 +1,99 @@ +// +build windows + +package ole + +import ( + "reflect" + "syscall" + "unicode/utf8" + "unsafe" +) + +var ( + procRoInitialize = modcombase.NewProc("RoInitialize") + procRoActivateInstance = modcombase.NewProc("RoActivateInstance") + procRoGetActivationFactory = modcombase.NewProc("RoGetActivationFactory") + procWindowsCreateString = modcombase.NewProc("WindowsCreateString") + procWindowsDeleteString = modcombase.NewProc("WindowsDeleteString") + procWindowsGetStringRawBuffer = modcombase.NewProc("WindowsGetStringRawBuffer") +) + +func RoInitialize(thread_type uint32) (err error) { + hr, _, _ := procRoInitialize.Call(uintptr(thread_type)) + if hr != 0 { + err = NewError(hr) + } + return +} + +func RoActivateInstance(clsid string) (ins *IInspectable, err error) { + hClsid, err := NewHString(clsid) + if err != nil { + return nil, err + } + defer DeleteHString(hClsid) + + hr, _, _ := procRoActivateInstance.Call( + uintptr(unsafe.Pointer(hClsid)), + uintptr(unsafe.Pointer(&ins))) + if hr != 0 { + err = NewError(hr) + } + return +} + +func RoGetActivationFactory(clsid string, iid *GUID) (ins *IInspectable, err error) { + hClsid, err := NewHString(clsid) + if err != nil { + return nil, err + } + defer DeleteHString(hClsid) + + hr, _, _ := procRoGetActivationFactory.Call( + uintptr(unsafe.Pointer(hClsid)), + uintptr(unsafe.Pointer(iid)), + uintptr(unsafe.Pointer(&ins))) + if hr != 0 { + err = NewError(hr) + } + return +} + +// HString is handle string for pointers. +type HString uintptr + +// NewHString returns a new HString for Go string. +func NewHString(s string) (hstring HString, err error) { + u16 := syscall.StringToUTF16Ptr(s) + len := uint32(utf8.RuneCountInString(s)) + hr, _, _ := procWindowsCreateString.Call( + uintptr(unsafe.Pointer(u16)), + uintptr(len), + uintptr(unsafe.Pointer(&hstring))) + if hr != 0 { + err = NewError(hr) + } + return +} + +// DeleteHString deletes HString. +func DeleteHString(hstring HString) (err error) { + hr, _, _ := procWindowsDeleteString.Call(uintptr(hstring)) + if hr != 0 { + err = NewError(hr) + } + return +} + +// String returns Go string value of HString. +func (h HString) String() string { + var u16buf uintptr + var u16len uint32 + u16buf, _, _ = procWindowsGetStringRawBuffer.Call( + uintptr(h), + uintptr(unsafe.Pointer(&u16len))) + + u16hdr := reflect.SliceHeader{Data: u16buf, Len: int(u16len), Cap: int(u16len)} + u16 := *(*[]uint16)(unsafe.Pointer(&u16hdr)) + return syscall.UTF16ToString(u16) +} diff --git a/vendor/github.com/go-ole/go-ole/winrt_doc.go b/vendor/github.com/go-ole/go-ole/winrt_doc.go new file mode 100644 index 0000000000..52e6d74c9a --- /dev/null +++ b/vendor/github.com/go-ole/go-ole/winrt_doc.go @@ -0,0 +1,36 @@ +// +build !windows + +package ole + +// RoInitialize +func RoInitialize(thread_type uint32) (err error) { + return NewError(E_NOTIMPL) +} + +// RoActivateInstance +func RoActivateInstance(clsid string) (ins *IInspectable, err error) { + return nil, NewError(E_NOTIMPL) +} + +// RoGetActivationFactory +func RoGetActivationFactory(clsid string, iid *GUID) (ins *IInspectable, err error) { + return nil, NewError(E_NOTIMPL) +} + +// HString is handle string for pointers. +type HString uintptr + +// NewHString returns a new HString for Go string. +func NewHString(s string) (hstring HString, err error) { + return HString(uintptr(0)), NewError(E_NOTIMPL) +} + +// DeleteHString deletes HString. +func DeleteHString(hstring HString) (err error) { + return NewError(E_NOTIMPL) +} + +// String returns Go string value of HString. +func (h HString) String() string { + return "" +} diff --git a/vendor/github.com/godbus/dbus/LICENSE b/vendor/github.com/godbus/dbus/LICENSE new file mode 100644 index 0000000000..670d88fcaa --- /dev/null +++ b/vendor/github.com/godbus/dbus/LICENSE @@ -0,0 +1,25 @@ +Copyright (c) 2013, Georg Reinke (), Google +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. + +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. diff --git a/vendor/github.com/godbus/dbus/auth.go b/vendor/github.com/godbus/dbus/auth.go new file mode 100644 index 0000000000..98017b693e --- /dev/null +++ b/vendor/github.com/godbus/dbus/auth.go @@ -0,0 +1,253 @@ +package dbus + +import ( + "bufio" + "bytes" + "errors" + "io" + "os" + "strconv" +) + +// AuthStatus represents the Status of an authentication mechanism. +type AuthStatus byte + +const ( + // AuthOk signals that authentication is finished; the next command + // from the server should be an OK. + AuthOk AuthStatus = iota + + // AuthContinue signals that additional data is needed; the next command + // from the server should be a DATA. + AuthContinue + + // AuthError signals an error; the server sent invalid data or some + // other unexpected thing happened and the current authentication + // process should be aborted. + AuthError +) + +type authState byte + +const ( + waitingForData authState = iota + waitingForOk + waitingForReject +) + +// Auth defines the behaviour of an authentication mechanism. +type Auth interface { + // Return the name of the mechnism, the argument to the first AUTH command + // and the next status. + FirstData() (name, resp []byte, status AuthStatus) + + // Process the given DATA command, and return the argument to the DATA + // command and the next status. If len(resp) == 0, no DATA command is sent. + HandleData(data []byte) (resp []byte, status AuthStatus) +} + +// Auth authenticates the connection, trying the given list of authentication +// mechanisms (in that order). If nil is passed, the EXTERNAL and +// DBUS_COOKIE_SHA1 mechanisms are tried for the current user. For private +// connections, this method must be called before sending any messages to the +// bus. Auth must not be called on shared connections. +func (conn *Conn) Auth(methods []Auth) error { + if methods == nil { + uid := strconv.Itoa(os.Getuid()) + methods = []Auth{AuthExternal(uid), AuthCookieSha1(uid, getHomeDir())} + } + in := bufio.NewReader(conn.transport) + err := conn.transport.SendNullByte() + if err != nil { + return err + } + err = authWriteLine(conn.transport, []byte("AUTH")) + if err != nil { + return err + } + s, err := authReadLine(in) + if err != nil { + return err + } + if len(s) < 2 || !bytes.Equal(s[0], []byte("REJECTED")) { + return errors.New("dbus: authentication protocol error") + } + s = s[1:] + for _, v := range s { + for _, m := range methods { + if name, data, status := m.FirstData(); bytes.Equal(v, name) { + var ok bool + err = authWriteLine(conn.transport, []byte("AUTH"), []byte(v), data) + if err != nil { + return err + } + switch status { + case AuthOk: + err, ok = conn.tryAuth(m, waitingForOk, in) + case AuthContinue: + err, ok = conn.tryAuth(m, waitingForData, in) + default: + panic("dbus: invalid authentication status") + } + if err != nil { + return err + } + if ok { + if conn.transport.SupportsUnixFDs() { + err = authWriteLine(conn, []byte("NEGOTIATE_UNIX_FD")) + if err != nil { + return err + } + line, err := authReadLine(in) + if err != nil { + return err + } + switch { + case bytes.Equal(line[0], []byte("AGREE_UNIX_FD")): + conn.EnableUnixFDs() + conn.unixFD = true + case bytes.Equal(line[0], []byte("ERROR")): + default: + return errors.New("dbus: authentication protocol error") + } + } + err = authWriteLine(conn.transport, []byte("BEGIN")) + if err != nil { + return err + } + go conn.inWorker() + go conn.outWorker() + return nil + } + } + } + } + return errors.New("dbus: authentication failed") +} + +// tryAuth tries to authenticate with m as the mechanism, using state as the +// initial authState and in for reading input. It returns (nil, true) on +// success, (nil, false) on a REJECTED and (someErr, false) if some other +// error occured. +func (conn *Conn) tryAuth(m Auth, state authState, in *bufio.Reader) (error, bool) { + for { + s, err := authReadLine(in) + if err != nil { + return err, false + } + switch { + case state == waitingForData && string(s[0]) == "DATA": + if len(s) != 2 { + err = authWriteLine(conn.transport, []byte("ERROR")) + if err != nil { + return err, false + } + continue + } + data, status := m.HandleData(s[1]) + switch status { + case AuthOk, AuthContinue: + if len(data) != 0 { + err = authWriteLine(conn.transport, []byte("DATA"), data) + if err != nil { + return err, false + } + } + if status == AuthOk { + state = waitingForOk + } + case AuthError: + err = authWriteLine(conn.transport, []byte("ERROR")) + if err != nil { + return err, false + } + } + case state == waitingForData && string(s[0]) == "REJECTED": + return nil, false + case state == waitingForData && string(s[0]) == "ERROR": + err = authWriteLine(conn.transport, []byte("CANCEL")) + if err != nil { + return err, false + } + state = waitingForReject + case state == waitingForData && string(s[0]) == "OK": + if len(s) != 2 { + err = authWriteLine(conn.transport, []byte("CANCEL")) + if err != nil { + return err, false + } + state = waitingForReject + } + conn.uuid = string(s[1]) + return nil, true + case state == waitingForData: + err = authWriteLine(conn.transport, []byte("ERROR")) + if err != nil { + return err, false + } + case state == waitingForOk && string(s[0]) == "OK": + if len(s) != 2 { + err = authWriteLine(conn.transport, []byte("CANCEL")) + if err != nil { + return err, false + } + state = waitingForReject + } + conn.uuid = string(s[1]) + return nil, true + case state == waitingForOk && string(s[0]) == "REJECTED": + return nil, false + case state == waitingForOk && (string(s[0]) == "DATA" || + string(s[0]) == "ERROR"): + + err = authWriteLine(conn.transport, []byte("CANCEL")) + if err != nil { + return err, false + } + state = waitingForReject + case state == waitingForOk: + err = authWriteLine(conn.transport, []byte("ERROR")) + if err != nil { + return err, false + } + case state == waitingForReject && string(s[0]) == "REJECTED": + return nil, false + case state == waitingForReject: + return errors.New("dbus: authentication protocol error"), false + default: + panic("dbus: invalid auth state") + } + } +} + +// authReadLine reads a line and separates it into its fields. +func authReadLine(in *bufio.Reader) ([][]byte, error) { + data, err := in.ReadBytes('\n') + if err != nil { + return nil, err + } + data = bytes.TrimSuffix(data, []byte("\r\n")) + return bytes.Split(data, []byte{' '}), nil +} + +// authWriteLine writes the given line in the authentication protocol format +// (elements of data separated by a " " and terminated by "\r\n"). +func authWriteLine(out io.Writer, data ...[]byte) error { + buf := make([]byte, 0) + for i, v := range data { + buf = append(buf, v...) + if i != len(data)-1 { + buf = append(buf, ' ') + } + } + buf = append(buf, '\r') + buf = append(buf, '\n') + n, err := out.Write(buf) + if err != nil { + return err + } + if n != len(buf) { + return io.ErrUnexpectedEOF + } + return nil +} diff --git a/vendor/github.com/godbus/dbus/auth_external.go b/vendor/github.com/godbus/dbus/auth_external.go new file mode 100644 index 0000000000..7e376d3ef6 --- /dev/null +++ b/vendor/github.com/godbus/dbus/auth_external.go @@ -0,0 +1,26 @@ +package dbus + +import ( + "encoding/hex" +) + +// AuthExternal returns an Auth that authenticates as the given user with the +// EXTERNAL mechanism. +func AuthExternal(user string) Auth { + return authExternal{user} +} + +// AuthExternal implements the EXTERNAL authentication mechanism. +type authExternal struct { + user string +} + +func (a authExternal) FirstData() ([]byte, []byte, AuthStatus) { + b := make([]byte, 2*len(a.user)) + hex.Encode(b, []byte(a.user)) + return []byte("EXTERNAL"), b, AuthOk +} + +func (a authExternal) HandleData(b []byte) ([]byte, AuthStatus) { + return nil, AuthError +} diff --git a/vendor/github.com/godbus/dbus/auth_sha1.go b/vendor/github.com/godbus/dbus/auth_sha1.go new file mode 100644 index 0000000000..df15b46119 --- /dev/null +++ b/vendor/github.com/godbus/dbus/auth_sha1.go @@ -0,0 +1,102 @@ +package dbus + +import ( + "bufio" + "bytes" + "crypto/rand" + "crypto/sha1" + "encoding/hex" + "os" +) + +// AuthCookieSha1 returns an Auth that authenticates as the given user with the +// DBUS_COOKIE_SHA1 mechanism. The home parameter should specify the home +// directory of the user. +func AuthCookieSha1(user, home string) Auth { + return authCookieSha1{user, home} +} + +type authCookieSha1 struct { + user, home string +} + +func (a authCookieSha1) FirstData() ([]byte, []byte, AuthStatus) { + b := make([]byte, 2*len(a.user)) + hex.Encode(b, []byte(a.user)) + return []byte("DBUS_COOKIE_SHA1"), b, AuthContinue +} + +func (a authCookieSha1) HandleData(data []byte) ([]byte, AuthStatus) { + challenge := make([]byte, len(data)/2) + _, err := hex.Decode(challenge, data) + if err != nil { + return nil, AuthError + } + b := bytes.Split(challenge, []byte{' '}) + if len(b) != 3 { + return nil, AuthError + } + context := b[0] + id := b[1] + svchallenge := b[2] + cookie := a.getCookie(context, id) + if cookie == nil { + return nil, AuthError + } + clchallenge := a.generateChallenge() + if clchallenge == nil { + return nil, AuthError + } + hash := sha1.New() + hash.Write(bytes.Join([][]byte{svchallenge, clchallenge, cookie}, []byte{':'})) + hexhash := make([]byte, 2*hash.Size()) + hex.Encode(hexhash, hash.Sum(nil)) + data = append(clchallenge, ' ') + data = append(data, hexhash...) + resp := make([]byte, 2*len(data)) + hex.Encode(resp, data) + return resp, AuthOk +} + +// getCookie searches for the cookie identified by id in context and returns +// the cookie content or nil. (Since HandleData can't return a specific error, +// but only whether an error occured, this function also doesn't bother to +// return an error.) +func (a authCookieSha1) getCookie(context, id []byte) []byte { + file, err := os.Open(a.home + "/.dbus-keyrings/" + string(context)) + if err != nil { + return nil + } + defer file.Close() + rd := bufio.NewReader(file) + for { + line, err := rd.ReadBytes('\n') + if err != nil { + return nil + } + line = line[:len(line)-1] + b := bytes.Split(line, []byte{' '}) + if len(b) != 3 { + return nil + } + if bytes.Equal(b[0], id) { + return b[2] + } + } +} + +// generateChallenge returns a random, hex-encoded challenge, or nil on error +// (see above). +func (a authCookieSha1) generateChallenge() []byte { + b := make([]byte, 16) + n, err := rand.Read(b) + if err != nil { + return nil + } + if n != 16 { + return nil + } + enc := make([]byte, 32) + hex.Encode(enc, b) + return enc +} diff --git a/vendor/github.com/godbus/dbus/call.go b/vendor/github.com/godbus/dbus/call.go new file mode 100644 index 0000000000..ba6e73f607 --- /dev/null +++ b/vendor/github.com/godbus/dbus/call.go @@ -0,0 +1,36 @@ +package dbus + +import ( + "errors" +) + +// Call represents a pending or completed method call. +type Call struct { + Destination string + Path ObjectPath + Method string + Args []interface{} + + // Strobes when the call is complete. + Done chan *Call + + // After completion, the error status. If this is non-nil, it may be an + // error message from the peer (with Error as its type) or some other error. + Err error + + // Holds the response once the call is done. + Body []interface{} +} + +var errSignature = errors.New("dbus: mismatched signature") + +// Store stores the body of the reply into the provided pointers. It returns +// an error if the signatures of the body and retvalues don't match, or if +// the error status is not nil. +func (c *Call) Store(retvalues ...interface{}) error { + if c.Err != nil { + return c.Err + } + + return Store(c.Body, retvalues...) +} diff --git a/vendor/github.com/godbus/dbus/conn.go b/vendor/github.com/godbus/dbus/conn.go new file mode 100644 index 0000000000..a4f5394010 --- /dev/null +++ b/vendor/github.com/godbus/dbus/conn.go @@ -0,0 +1,625 @@ +package dbus + +import ( + "errors" + "io" + "os" + "reflect" + "strings" + "sync" +) + +const defaultSystemBusAddress = "unix:path=/var/run/dbus/system_bus_socket" + +var ( + systemBus *Conn + systemBusLck sync.Mutex + sessionBus *Conn + sessionBusLck sync.Mutex +) + +// ErrClosed is the error returned by calls on a closed connection. +var ErrClosed = errors.New("dbus: connection closed by user") + +// Conn represents a connection to a message bus (usually, the system or +// session bus). +// +// Connections are either shared or private. Shared connections +// are shared between calls to the functions that return them. As a result, +// the methods Close, Auth and Hello must not be called on them. +// +// Multiple goroutines may invoke methods on a connection simultaneously. +type Conn struct { + transport + + busObj BusObject + unixFD bool + uuid string + + names []string + namesLck sync.RWMutex + + serialLck sync.Mutex + nextSerial uint32 + serialUsed map[uint32]bool + + calls map[uint32]*Call + callsLck sync.RWMutex + + handlers map[ObjectPath]map[string]exportWithMapping + handlersLck sync.RWMutex + + out chan *Message + closed bool + outLck sync.RWMutex + + signals []chan<- *Signal + signalsLck sync.Mutex + + eavesdropped chan<- *Message + eavesdroppedLck sync.Mutex +} + +// SessionBus returns a shared connection to the session bus, connecting to it +// if not already done. +func SessionBus() (conn *Conn, err error) { + sessionBusLck.Lock() + defer sessionBusLck.Unlock() + if sessionBus != nil { + return sessionBus, nil + } + defer func() { + if conn != nil { + sessionBus = conn + } + }() + conn, err = SessionBusPrivate() + if err != nil { + return + } + if err = conn.Auth(nil); err != nil { + conn.Close() + conn = nil + return + } + if err = conn.Hello(); err != nil { + conn.Close() + conn = nil + } + return +} + +// SessionBusPrivate returns a new private connection to the session bus. +func SessionBusPrivate() (*Conn, error) { + address := os.Getenv("DBUS_SESSION_BUS_ADDRESS") + if address != "" && address != "autolaunch:" { + return Dial(address) + } + + return sessionBusPlatform() +} + +// SystemBus returns a shared connection to the system bus, connecting to it if +// not already done. +func SystemBus() (conn *Conn, err error) { + systemBusLck.Lock() + defer systemBusLck.Unlock() + if systemBus != nil { + return systemBus, nil + } + defer func() { + if conn != nil { + systemBus = conn + } + }() + conn, err = SystemBusPrivate() + if err != nil { + return + } + if err = conn.Auth(nil); err != nil { + conn.Close() + conn = nil + return + } + if err = conn.Hello(); err != nil { + conn.Close() + conn = nil + } + return +} + +// SystemBusPrivate returns a new private connection to the system bus. +func SystemBusPrivate() (*Conn, error) { + address := os.Getenv("DBUS_SYSTEM_BUS_ADDRESS") + if address != "" { + return Dial(address) + } + return Dial(defaultSystemBusAddress) +} + +// Dial establishes a new private connection to the message bus specified by address. +func Dial(address string) (*Conn, error) { + tr, err := getTransport(address) + if err != nil { + return nil, err + } + return newConn(tr) +} + +// NewConn creates a new private *Conn from an already established connection. +func NewConn(conn io.ReadWriteCloser) (*Conn, error) { + return newConn(genericTransport{conn}) +} + +// newConn creates a new *Conn from a transport. +func newConn(tr transport) (*Conn, error) { + conn := new(Conn) + conn.transport = tr + conn.calls = make(map[uint32]*Call) + conn.out = make(chan *Message, 10) + conn.handlers = make(map[ObjectPath]map[string]exportWithMapping) + conn.nextSerial = 1 + conn.serialUsed = map[uint32]bool{0: true} + conn.busObj = conn.Object("org.freedesktop.DBus", "/org/freedesktop/DBus") + return conn, nil +} + +// BusObject returns the object owned by the bus daemon which handles +// administrative requests. +func (conn *Conn) BusObject() BusObject { + return conn.busObj +} + +// Close closes the connection. Any blocked operations will return with errors +// and the channels passed to Eavesdrop and Signal are closed. This method must +// not be called on shared connections. +func (conn *Conn) Close() error { + conn.outLck.Lock() + if conn.closed { + // inWorker calls Close on read error, the read error may + // be caused by another caller calling Close to shutdown the + // dbus connection, a double-close scenario we prevent here. + conn.outLck.Unlock() + return nil + } + close(conn.out) + conn.closed = true + conn.outLck.Unlock() + conn.signalsLck.Lock() + for _, ch := range conn.signals { + close(ch) + } + conn.signalsLck.Unlock() + conn.eavesdroppedLck.Lock() + if conn.eavesdropped != nil { + close(conn.eavesdropped) + } + conn.eavesdroppedLck.Unlock() + return conn.transport.Close() +} + +// Eavesdrop causes conn to send all incoming messages to the given channel +// without further processing. Method replies, errors and signals will not be +// sent to the appropiate channels and method calls will not be handled. If nil +// is passed, the normal behaviour is restored. +// +// The caller has to make sure that ch is sufficiently buffered; +// if a message arrives when a write to ch is not possible, the message is +// discarded. +func (conn *Conn) Eavesdrop(ch chan<- *Message) { + conn.eavesdroppedLck.Lock() + conn.eavesdropped = ch + conn.eavesdroppedLck.Unlock() +} + +// getSerial returns an unused serial. +func (conn *Conn) getSerial() uint32 { + conn.serialLck.Lock() + defer conn.serialLck.Unlock() + n := conn.nextSerial + for conn.serialUsed[n] { + n++ + } + conn.serialUsed[n] = true + conn.nextSerial = n + 1 + return n +} + +// Hello sends the initial org.freedesktop.DBus.Hello call. This method must be +// called after authentication, but before sending any other messages to the +// bus. Hello must not be called for shared connections. +func (conn *Conn) Hello() error { + var s string + err := conn.busObj.Call("org.freedesktop.DBus.Hello", 0).Store(&s) + if err != nil { + return err + } + conn.namesLck.Lock() + conn.names = make([]string, 1) + conn.names[0] = s + conn.namesLck.Unlock() + return nil +} + +// inWorker runs in an own goroutine, reading incoming messages from the +// transport and dispatching them appropiately. +func (conn *Conn) inWorker() { + for { + msg, err := conn.ReadMessage() + if err == nil { + conn.eavesdroppedLck.Lock() + if conn.eavesdropped != nil { + select { + case conn.eavesdropped <- msg: + default: + } + conn.eavesdroppedLck.Unlock() + continue + } + conn.eavesdroppedLck.Unlock() + dest, _ := msg.Headers[FieldDestination].value.(string) + found := false + if dest == "" { + found = true + } else { + conn.namesLck.RLock() + if len(conn.names) == 0 { + found = true + } + for _, v := range conn.names { + if dest == v { + found = true + break + } + } + conn.namesLck.RUnlock() + } + if !found { + // Eavesdropped a message, but no channel for it is registered. + // Ignore it. + continue + } + switch msg.Type { + case TypeMethodReply, TypeError: + serial := msg.Headers[FieldReplySerial].value.(uint32) + conn.callsLck.Lock() + if c, ok := conn.calls[serial]; ok { + if msg.Type == TypeError { + name, _ := msg.Headers[FieldErrorName].value.(string) + c.Err = Error{name, msg.Body} + } else { + c.Body = msg.Body + } + c.Done <- c + conn.serialLck.Lock() + delete(conn.serialUsed, serial) + conn.serialLck.Unlock() + delete(conn.calls, serial) + } + conn.callsLck.Unlock() + case TypeSignal: + iface := msg.Headers[FieldInterface].value.(string) + member := msg.Headers[FieldMember].value.(string) + // as per http://dbus.freedesktop.org/doc/dbus-specification.html , + // sender is optional for signals. + sender, _ := msg.Headers[FieldSender].value.(string) + if iface == "org.freedesktop.DBus" && sender == "org.freedesktop.DBus" { + if member == "NameLost" { + // If we lost the name on the bus, remove it from our + // tracking list. + name, ok := msg.Body[0].(string) + if !ok { + panic("Unable to read the lost name") + } + conn.namesLck.Lock() + for i, v := range conn.names { + if v == name { + conn.names = append(conn.names[:i], + conn.names[i+1:]...) + } + } + conn.namesLck.Unlock() + } else if member == "NameAcquired" { + // If we acquired the name on the bus, add it to our + // tracking list. + name, ok := msg.Body[0].(string) + if !ok { + panic("Unable to read the acquired name") + } + conn.namesLck.Lock() + conn.names = append(conn.names, name) + conn.namesLck.Unlock() + } + } + signal := &Signal{ + Sender: sender, + Path: msg.Headers[FieldPath].value.(ObjectPath), + Name: iface + "." + member, + Body: msg.Body, + } + conn.signalsLck.Lock() + for _, ch := range conn.signals { + ch <- signal + } + conn.signalsLck.Unlock() + case TypeMethodCall: + go conn.handleCall(msg) + } + } else if _, ok := err.(InvalidMessageError); !ok { + // Some read error occured (usually EOF); we can't really do + // anything but to shut down all stuff and returns errors to all + // pending replies. + conn.Close() + conn.callsLck.RLock() + for _, v := range conn.calls { + v.Err = err + v.Done <- v + } + conn.callsLck.RUnlock() + return + } + // invalid messages are ignored + } +} + +// Names returns the list of all names that are currently owned by this +// connection. The slice is always at least one element long, the first element +// being the unique name of the connection. +func (conn *Conn) Names() []string { + conn.namesLck.RLock() + // copy the slice so it can't be modified + s := make([]string, len(conn.names)) + copy(s, conn.names) + conn.namesLck.RUnlock() + return s +} + +// Object returns the object identified by the given destination name and path. +func (conn *Conn) Object(dest string, path ObjectPath) BusObject { + return &Object{conn, dest, path} +} + +// outWorker runs in an own goroutine, encoding and sending messages that are +// sent to conn.out. +func (conn *Conn) outWorker() { + for msg := range conn.out { + err := conn.SendMessage(msg) + conn.callsLck.RLock() + if err != nil { + if c := conn.calls[msg.serial]; c != nil { + c.Err = err + c.Done <- c + } + conn.serialLck.Lock() + delete(conn.serialUsed, msg.serial) + conn.serialLck.Unlock() + } else if msg.Type != TypeMethodCall { + conn.serialLck.Lock() + delete(conn.serialUsed, msg.serial) + conn.serialLck.Unlock() + } + conn.callsLck.RUnlock() + } +} + +// Send sends the given message to the message bus. You usually don't need to +// use this; use the higher-level equivalents (Call / Go, Emit and Export) +// instead. If msg is a method call and NoReplyExpected is not set, a non-nil +// call is returned and the same value is sent to ch (which must be buffered) +// once the call is complete. Otherwise, ch is ignored and a Call structure is +// returned of which only the Err member is valid. +func (conn *Conn) Send(msg *Message, ch chan *Call) *Call { + var call *Call + + msg.serial = conn.getSerial() + if msg.Type == TypeMethodCall && msg.Flags&FlagNoReplyExpected == 0 { + if ch == nil { + ch = make(chan *Call, 5) + } else if cap(ch) == 0 { + panic("dbus: unbuffered channel passed to (*Conn).Send") + } + call = new(Call) + call.Destination, _ = msg.Headers[FieldDestination].value.(string) + call.Path, _ = msg.Headers[FieldPath].value.(ObjectPath) + iface, _ := msg.Headers[FieldInterface].value.(string) + member, _ := msg.Headers[FieldMember].value.(string) + call.Method = iface + "." + member + call.Args = msg.Body + call.Done = ch + conn.callsLck.Lock() + conn.calls[msg.serial] = call + conn.callsLck.Unlock() + conn.outLck.RLock() + if conn.closed { + call.Err = ErrClosed + call.Done <- call + } else { + conn.out <- msg + } + conn.outLck.RUnlock() + } else { + conn.outLck.RLock() + if conn.closed { + call = &Call{Err: ErrClosed} + } else { + conn.out <- msg + call = &Call{Err: nil} + } + conn.outLck.RUnlock() + } + return call +} + +// sendError creates an error message corresponding to the parameters and sends +// it to conn.out. +func (conn *Conn) sendError(e Error, dest string, serial uint32) { + msg := new(Message) + msg.Type = TypeError + msg.serial = conn.getSerial() + msg.Headers = make(map[HeaderField]Variant) + if dest != "" { + msg.Headers[FieldDestination] = MakeVariant(dest) + } + msg.Headers[FieldErrorName] = MakeVariant(e.Name) + msg.Headers[FieldReplySerial] = MakeVariant(serial) + msg.Body = e.Body + if len(e.Body) > 0 { + msg.Headers[FieldSignature] = MakeVariant(SignatureOf(e.Body...)) + } + conn.outLck.RLock() + if !conn.closed { + conn.out <- msg + } + conn.outLck.RUnlock() +} + +// sendReply creates a method reply message corresponding to the parameters and +// sends it to conn.out. +func (conn *Conn) sendReply(dest string, serial uint32, values ...interface{}) { + msg := new(Message) + msg.Type = TypeMethodReply + msg.serial = conn.getSerial() + msg.Headers = make(map[HeaderField]Variant) + if dest != "" { + msg.Headers[FieldDestination] = MakeVariant(dest) + } + msg.Headers[FieldReplySerial] = MakeVariant(serial) + msg.Body = values + if len(values) > 0 { + msg.Headers[FieldSignature] = MakeVariant(SignatureOf(values...)) + } + conn.outLck.RLock() + if !conn.closed { + conn.out <- msg + } + conn.outLck.RUnlock() +} + +// Signal registers the given channel to be passed all received signal messages. +// The caller has to make sure that ch is sufficiently buffered; if a message +// arrives when a write to c is not possible, it is discarded. +// +// Multiple of these channels can be registered at the same time. Passing a +// channel that already is registered will remove it from the list of the +// registered channels. +// +// These channels are "overwritten" by Eavesdrop; i.e., if there currently is a +// channel for eavesdropped messages, this channel receives all signals, and +// none of the channels passed to Signal will receive any signals. +func (conn *Conn) Signal(ch chan<- *Signal) { + conn.signalsLck.Lock() + conn.signals = append(conn.signals, ch) + conn.signalsLck.Unlock() +} + +// SupportsUnixFDs returns whether the underlying transport supports passing of +// unix file descriptors. If this is false, method calls containing unix file +// descriptors will return an error and emitted signals containing them will +// not be sent. +func (conn *Conn) SupportsUnixFDs() bool { + return conn.unixFD +} + +// Error represents a D-Bus message of type Error. +type Error struct { + Name string + Body []interface{} +} + +func NewError(name string, body []interface{}) *Error { + return &Error{name, body} +} + +func (e Error) Error() string { + if len(e.Body) >= 1 { + s, ok := e.Body[0].(string) + if ok { + return s + } + } + return e.Name +} + +// Signal represents a D-Bus message of type Signal. The name member is given in +// "interface.member" notation, e.g. org.freedesktop.D-Bus.NameLost. +type Signal struct { + Sender string + Path ObjectPath + Name string + Body []interface{} +} + +// transport is a D-Bus transport. +type transport interface { + // Read and Write raw data (for example, for the authentication protocol). + io.ReadWriteCloser + + // Send the initial null byte used for the EXTERNAL mechanism. + SendNullByte() error + + // Returns whether this transport supports passing Unix FDs. + SupportsUnixFDs() bool + + // Signal the transport that Unix FD passing is enabled for this connection. + EnableUnixFDs() + + // Read / send a message, handling things like Unix FDs. + ReadMessage() (*Message, error) + SendMessage(*Message) error +} + +var ( + transports = make(map[string]func(string) (transport, error)) +) + +func getTransport(address string) (transport, error) { + var err error + var t transport + + addresses := strings.Split(address, ";") + for _, v := range addresses { + i := strings.IndexRune(v, ':') + if i == -1 { + err = errors.New("dbus: invalid bus address (no transport)") + continue + } + f := transports[v[:i]] + if f == nil { + err = errors.New("dbus: invalid bus address (invalid or unsupported transport)") + continue + } + t, err = f(v[i+1:]) + if err == nil { + return t, nil + } + } + return nil, err +} + +// dereferenceAll returns a slice that, assuming that vs is a slice of pointers +// of arbitrary types, containes the values that are obtained from dereferencing +// all elements in vs. +func dereferenceAll(vs []interface{}) []interface{} { + for i := range vs { + v := reflect.ValueOf(vs[i]) + v = v.Elem() + vs[i] = v.Interface() + } + return vs +} + +// getKey gets a key from a the list of keys. Returns "" on error / not found... +func getKey(s, key string) string { + i := strings.Index(s, key) + if i == -1 { + return "" + } + if i+len(key)+1 >= len(s) || s[i+len(key)] != '=' { + return "" + } + j := strings.Index(s, ",") + if j == -1 { + j = len(s) + } + return s[i+len(key)+1 : j] +} diff --git a/vendor/github.com/godbus/dbus/conn_darwin.go b/vendor/github.com/godbus/dbus/conn_darwin.go new file mode 100644 index 0000000000..b67bb1b81d --- /dev/null +++ b/vendor/github.com/godbus/dbus/conn_darwin.go @@ -0,0 +1,21 @@ +package dbus + +import ( + "errors" + "os/exec" +) + +func sessionBusPlatform() (*Conn, error) { + cmd := exec.Command("launchctl", "getenv", "DBUS_LAUNCHD_SESSION_BUS_SOCKET") + b, err := cmd.CombinedOutput() + + if err != nil { + return nil, err + } + + if len(b) == 0 { + return nil, errors.New("dbus: couldn't determine address of session bus") + } + + return Dial("unix:path=" + string(b[:len(b)-1])) +} diff --git a/vendor/github.com/godbus/dbus/conn_other.go b/vendor/github.com/godbus/dbus/conn_other.go new file mode 100644 index 0000000000..f74b8758d4 --- /dev/null +++ b/vendor/github.com/godbus/dbus/conn_other.go @@ -0,0 +1,27 @@ +// +build !darwin + +package dbus + +import ( + "bytes" + "errors" + "os/exec" +) + +func sessionBusPlatform() (*Conn, error) { + cmd := exec.Command("dbus-launch") + b, err := cmd.CombinedOutput() + + if err != nil { + return nil, err + } + + i := bytes.IndexByte(b, '=') + j := bytes.IndexByte(b, '\n') + + if i == -1 || j == -1 { + return nil, errors.New("dbus: couldn't determine address of session bus") + } + + return Dial(string(b[i+1 : j])) +} diff --git a/vendor/github.com/godbus/dbus/dbus.go b/vendor/github.com/godbus/dbus/dbus.go new file mode 100644 index 0000000000..2ce68735cd --- /dev/null +++ b/vendor/github.com/godbus/dbus/dbus.go @@ -0,0 +1,258 @@ +package dbus + +import ( + "errors" + "reflect" + "strings" +) + +var ( + byteType = reflect.TypeOf(byte(0)) + boolType = reflect.TypeOf(false) + uint8Type = reflect.TypeOf(uint8(0)) + int16Type = reflect.TypeOf(int16(0)) + uint16Type = reflect.TypeOf(uint16(0)) + int32Type = reflect.TypeOf(int32(0)) + uint32Type = reflect.TypeOf(uint32(0)) + int64Type = reflect.TypeOf(int64(0)) + uint64Type = reflect.TypeOf(uint64(0)) + float64Type = reflect.TypeOf(float64(0)) + stringType = reflect.TypeOf("") + signatureType = reflect.TypeOf(Signature{""}) + objectPathType = reflect.TypeOf(ObjectPath("")) + variantType = reflect.TypeOf(Variant{Signature{""}, nil}) + interfacesType = reflect.TypeOf([]interface{}{}) + unixFDType = reflect.TypeOf(UnixFD(0)) + unixFDIndexType = reflect.TypeOf(UnixFDIndex(0)) +) + +// An InvalidTypeError signals that a value which cannot be represented in the +// D-Bus wire format was passed to a function. +type InvalidTypeError struct { + Type reflect.Type +} + +func (e InvalidTypeError) Error() string { + return "dbus: invalid type " + e.Type.String() +} + +// Store copies the values contained in src to dest, which must be a slice of +// pointers. It converts slices of interfaces from src to corresponding structs +// in dest. An error is returned if the lengths of src and dest or the types of +// their elements don't match. +func Store(src []interface{}, dest ...interface{}) error { + if len(src) != len(dest) { + return errors.New("dbus.Store: length mismatch") + } + + for i := range src { + if err := store(src[i], dest[i]); err != nil { + return err + } + } + return nil +} + +func store(src, dest interface{}) error { + if reflect.TypeOf(dest).Elem() == reflect.TypeOf(src) { + reflect.ValueOf(dest).Elem().Set(reflect.ValueOf(src)) + return nil + } else if hasStruct(dest) { + rv := reflect.ValueOf(dest).Elem() + switch rv.Kind() { + case reflect.Struct: + vs, ok := src.([]interface{}) + if !ok { + return errors.New("dbus.Store: type mismatch") + } + t := rv.Type() + ndest := make([]interface{}, 0, rv.NumField()) + for i := 0; i < rv.NumField(); i++ { + field := t.Field(i) + if field.PkgPath == "" && field.Tag.Get("dbus") != "-" { + ndest = append(ndest, rv.Field(i).Addr().Interface()) + } + } + if len(vs) != len(ndest) { + return errors.New("dbus.Store: type mismatch") + } + err := Store(vs, ndest...) + if err != nil { + return errors.New("dbus.Store: type mismatch") + } + case reflect.Slice: + sv := reflect.ValueOf(src) + if sv.Kind() != reflect.Slice { + return errors.New("dbus.Store: type mismatch") + } + rv.Set(reflect.MakeSlice(rv.Type(), sv.Len(), sv.Len())) + for i := 0; i < sv.Len(); i++ { + if err := store(sv.Index(i).Interface(), rv.Index(i).Addr().Interface()); err != nil { + return err + } + } + case reflect.Map: + sv := reflect.ValueOf(src) + if sv.Kind() != reflect.Map { + return errors.New("dbus.Store: type mismatch") + } + keys := sv.MapKeys() + rv.Set(reflect.MakeMap(sv.Type())) + for _, key := range keys { + v := reflect.New(sv.Type().Elem()) + if err := store(v, sv.MapIndex(key).Interface()); err != nil { + return err + } + rv.SetMapIndex(key, v.Elem()) + } + default: + return errors.New("dbus.Store: type mismatch") + } + return nil + } else { + return errors.New("dbus.Store: type mismatch") + } +} + +func hasStruct(v interface{}) bool { + t := reflect.TypeOf(v) + for { + switch t.Kind() { + case reflect.Struct: + return true + case reflect.Slice, reflect.Ptr, reflect.Map: + t = t.Elem() + default: + return false + } + } +} + +// An ObjectPath is an object path as defined by the D-Bus spec. +type ObjectPath string + +// IsValid returns whether the object path is valid. +func (o ObjectPath) IsValid() bool { + s := string(o) + if len(s) == 0 { + return false + } + if s[0] != '/' { + return false + } + if s[len(s)-1] == '/' && len(s) != 1 { + return false + } + // probably not used, but technically possible + if s == "/" { + return true + } + split := strings.Split(s[1:], "/") + for _, v := range split { + if len(v) == 0 { + return false + } + for _, c := range v { + if !isMemberChar(c) { + return false + } + } + } + return true +} + +// A UnixFD is a Unix file descriptor sent over the wire. See the package-level +// documentation for more information about Unix file descriptor passsing. +type UnixFD int32 + +// A UnixFDIndex is the representation of a Unix file descriptor in a message. +type UnixFDIndex uint32 + +// alignment returns the alignment of values of type t. +func alignment(t reflect.Type) int { + switch t { + case variantType: + return 1 + case objectPathType: + return 4 + case signatureType: + return 1 + case interfacesType: // sometimes used for structs + return 8 + } + switch t.Kind() { + case reflect.Uint8: + return 1 + case reflect.Uint16, reflect.Int16: + return 2 + case reflect.Uint32, reflect.Int32, reflect.String, reflect.Array, reflect.Slice, reflect.Map: + return 4 + case reflect.Uint64, reflect.Int64, reflect.Float64, reflect.Struct: + return 8 + case reflect.Ptr: + return alignment(t.Elem()) + } + return 1 +} + +// isKeyType returns whether t is a valid type for a D-Bus dict. +func isKeyType(t reflect.Type) bool { + switch t.Kind() { + case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, + reflect.Int16, reflect.Int32, reflect.Int64, reflect.Float64, + reflect.String: + + return true + } + return false +} + +// isValidInterface returns whether s is a valid name for an interface. +func isValidInterface(s string) bool { + if len(s) == 0 || len(s) > 255 || s[0] == '.' { + return false + } + elem := strings.Split(s, ".") + if len(elem) < 2 { + return false + } + for _, v := range elem { + if len(v) == 0 { + return false + } + if v[0] >= '0' && v[0] <= '9' { + return false + } + for _, c := range v { + if !isMemberChar(c) { + return false + } + } + } + return true +} + +// isValidMember returns whether s is a valid name for a member. +func isValidMember(s string) bool { + if len(s) == 0 || len(s) > 255 { + return false + } + i := strings.Index(s, ".") + if i != -1 { + return false + } + if s[0] >= '0' && s[0] <= '9' { + return false + } + for _, c := range s { + if !isMemberChar(c) { + return false + } + } + return true +} + +func isMemberChar(c rune) bool { + return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || + (c >= 'a' && c <= 'z') || c == '_' +} diff --git a/vendor/github.com/godbus/dbus/decoder.go b/vendor/github.com/godbus/dbus/decoder.go new file mode 100644 index 0000000000..ef50dcab98 --- /dev/null +++ b/vendor/github.com/godbus/dbus/decoder.go @@ -0,0 +1,228 @@ +package dbus + +import ( + "encoding/binary" + "io" + "reflect" +) + +type decoder struct { + in io.Reader + order binary.ByteOrder + pos int +} + +// newDecoder returns a new decoder that reads values from in. The input is +// expected to be in the given byte order. +func newDecoder(in io.Reader, order binary.ByteOrder) *decoder { + dec := new(decoder) + dec.in = in + dec.order = order + return dec +} + +// align aligns the input to the given boundary and panics on error. +func (dec *decoder) align(n int) { + if dec.pos%n != 0 { + newpos := (dec.pos + n - 1) & ^(n - 1) + empty := make([]byte, newpos-dec.pos) + if _, err := io.ReadFull(dec.in, empty); err != nil { + panic(err) + } + dec.pos = newpos + } +} + +// Calls binary.Read(dec.in, dec.order, v) and panics on read errors. +func (dec *decoder) binread(v interface{}) { + if err := binary.Read(dec.in, dec.order, v); err != nil { + panic(err) + } +} + +func (dec *decoder) Decode(sig Signature) (vs []interface{}, err error) { + defer func() { + var ok bool + v := recover() + if err, ok = v.(error); ok { + if err == io.EOF || err == io.ErrUnexpectedEOF { + err = FormatError("unexpected EOF") + } + } + }() + vs = make([]interface{}, 0) + s := sig.str + for s != "" { + err, rem := validSingle(s, 0) + if err != nil { + return nil, err + } + v := dec.decode(s[:len(s)-len(rem)], 0) + vs = append(vs, v) + s = rem + } + return vs, nil +} + +func (dec *decoder) decode(s string, depth int) interface{} { + dec.align(alignment(typeFor(s))) + switch s[0] { + case 'y': + var b [1]byte + if _, err := dec.in.Read(b[:]); err != nil { + panic(err) + } + dec.pos++ + return b[0] + case 'b': + i := dec.decode("u", depth).(uint32) + switch { + case i == 0: + return false + case i == 1: + return true + default: + panic(FormatError("invalid value for boolean")) + } + case 'n': + var i int16 + dec.binread(&i) + dec.pos += 2 + return i + case 'i': + var i int32 + dec.binread(&i) + dec.pos += 4 + return i + case 'x': + var i int64 + dec.binread(&i) + dec.pos += 8 + return i + case 'q': + var i uint16 + dec.binread(&i) + dec.pos += 2 + return i + case 'u': + var i uint32 + dec.binread(&i) + dec.pos += 4 + return i + case 't': + var i uint64 + dec.binread(&i) + dec.pos += 8 + return i + case 'd': + var f float64 + dec.binread(&f) + dec.pos += 8 + return f + case 's': + length := dec.decode("u", depth).(uint32) + b := make([]byte, int(length)+1) + if _, err := io.ReadFull(dec.in, b); err != nil { + panic(err) + } + dec.pos += int(length) + 1 + return string(b[:len(b)-1]) + case 'o': + return ObjectPath(dec.decode("s", depth).(string)) + case 'g': + length := dec.decode("y", depth).(byte) + b := make([]byte, int(length)+1) + if _, err := io.ReadFull(dec.in, b); err != nil { + panic(err) + } + dec.pos += int(length) + 1 + sig, err := ParseSignature(string(b[:len(b)-1])) + if err != nil { + panic(err) + } + return sig + case 'v': + if depth >= 64 { + panic(FormatError("input exceeds container depth limit")) + } + var variant Variant + sig := dec.decode("g", depth).(Signature) + if len(sig.str) == 0 { + panic(FormatError("variant signature is empty")) + } + err, rem := validSingle(sig.str, 0) + if err != nil { + panic(err) + } + if rem != "" { + panic(FormatError("variant signature has multiple types")) + } + variant.sig = sig + variant.value = dec.decode(sig.str, depth+1) + return variant + case 'h': + return UnixFDIndex(dec.decode("u", depth).(uint32)) + case 'a': + if len(s) > 1 && s[1] == '{' { + ksig := s[2:3] + vsig := s[3 : len(s)-1] + v := reflect.MakeMap(reflect.MapOf(typeFor(ksig), typeFor(vsig))) + if depth >= 63 { + panic(FormatError("input exceeds container depth limit")) + } + length := dec.decode("u", depth).(uint32) + // Even for empty maps, the correct padding must be included + dec.align(8) + spos := dec.pos + for dec.pos < spos+int(length) { + dec.align(8) + if !isKeyType(v.Type().Key()) { + panic(InvalidTypeError{v.Type()}) + } + kv := dec.decode(ksig, depth+2) + vv := dec.decode(vsig, depth+2) + v.SetMapIndex(reflect.ValueOf(kv), reflect.ValueOf(vv)) + } + return v.Interface() + } + if depth >= 64 { + panic(FormatError("input exceeds container depth limit")) + } + length := dec.decode("u", depth).(uint32) + v := reflect.MakeSlice(reflect.SliceOf(typeFor(s[1:])), 0, int(length)) + // Even for empty arrays, the correct padding must be included + dec.align(alignment(typeFor(s[1:]))) + spos := dec.pos + for dec.pos < spos+int(length) { + ev := dec.decode(s[1:], depth+1) + v = reflect.Append(v, reflect.ValueOf(ev)) + } + return v.Interface() + case '(': + if depth >= 64 { + panic(FormatError("input exceeds container depth limit")) + } + dec.align(8) + v := make([]interface{}, 0) + s = s[1 : len(s)-1] + for s != "" { + err, rem := validSingle(s, 0) + if err != nil { + panic(err) + } + ev := dec.decode(s[:len(s)-len(rem)], depth+1) + v = append(v, ev) + s = rem + } + return v + default: + panic(SignatureError{Sig: s}) + } +} + +// A FormatError is an error in the wire format. +type FormatError string + +func (e FormatError) Error() string { + return "dbus: wire format error: " + string(e) +} diff --git a/vendor/github.com/godbus/dbus/doc.go b/vendor/github.com/godbus/dbus/doc.go new file mode 100644 index 0000000000..deff554a38 --- /dev/null +++ b/vendor/github.com/godbus/dbus/doc.go @@ -0,0 +1,63 @@ +/* +Package dbus implements bindings to the D-Bus message bus system. + +To use the message bus API, you first need to connect to a bus (usually the +session or system bus). The acquired connection then can be used to call methods +on remote objects and emit or receive signals. Using the Export method, you can +arrange D-Bus methods calls to be directly translated to method calls on a Go +value. + +Conversion Rules + +For outgoing messages, Go types are automatically converted to the +corresponding D-Bus types. The following types are directly encoded as their +respective D-Bus equivalents: + + Go type | D-Bus type + ------------+----------- + byte | BYTE + bool | BOOLEAN + int16 | INT16 + uint16 | UINT16 + int32 | INT32 + uint32 | UINT32 + int64 | INT64 + uint64 | UINT64 + float64 | DOUBLE + string | STRING + ObjectPath | OBJECT_PATH + Signature | SIGNATURE + Variant | VARIANT + UnixFDIndex | UNIX_FD + +Slices and arrays encode as ARRAYs of their element type. + +Maps encode as DICTs, provided that their key type can be used as a key for +a DICT. + +Structs other than Variant and Signature encode as a STRUCT containing their +exported fields. Fields whose tags contain `dbus:"-"` and unexported fields will +be skipped. + +Pointers encode as the value they're pointed to. + +Trying to encode any other type or a slice, map or struct containing an +unsupported type will result in an InvalidTypeError. + +For incoming messages, the inverse of these rules are used, with the exception +of STRUCTs. Incoming STRUCTS are represented as a slice of empty interfaces +containing the struct fields in the correct order. The Store function can be +used to convert such values to Go structs. + +Unix FD passing + +Handling Unix file descriptors deserves special mention. To use them, you should +first check that they are supported on a connection by calling SupportsUnixFDs. +If it returns true, all method of Connection will translate messages containing +UnixFD's to messages that are accompanied by the given file descriptors with the +UnixFD values being substituted by the correct indices. Similarily, the indices +of incoming messages are automatically resolved. It shouldn't be necessary to use +UnixFDIndex. + +*/ +package dbus diff --git a/vendor/github.com/godbus/dbus/encoder.go b/vendor/github.com/godbus/dbus/encoder.go new file mode 100644 index 0000000000..9f0a9e89ea --- /dev/null +++ b/vendor/github.com/godbus/dbus/encoder.go @@ -0,0 +1,208 @@ +package dbus + +import ( + "bytes" + "encoding/binary" + "io" + "reflect" +) + +// An encoder encodes values to the D-Bus wire format. +type encoder struct { + out io.Writer + order binary.ByteOrder + pos int +} + +// NewEncoder returns a new encoder that writes to out in the given byte order. +func newEncoder(out io.Writer, order binary.ByteOrder) *encoder { + return newEncoderAtOffset(out, 0, order) +} + +// newEncoderAtOffset returns a new encoder that writes to out in the given +// byte order. Specify the offset to initialize pos for proper alignment +// computation. +func newEncoderAtOffset(out io.Writer, offset int, order binary.ByteOrder) *encoder { + enc := new(encoder) + enc.out = out + enc.order = order + enc.pos = offset + return enc +} + +// Aligns the next output to be on a multiple of n. Panics on write errors. +func (enc *encoder) align(n int) { + pad := enc.padding(0, n) + if pad > 0 { + empty := make([]byte, pad) + if _, err := enc.out.Write(empty); err != nil { + panic(err) + } + enc.pos += pad + } +} + +// pad returns the number of bytes of padding, based on current position and additional offset. +// and alignment. +func (enc *encoder) padding(offset, algn int) int { + abs := enc.pos + offset + if abs%algn != 0 { + newabs := (abs + algn - 1) & ^(algn - 1) + return newabs - abs + } + return 0 +} + +// Calls binary.Write(enc.out, enc.order, v) and panics on write errors. +func (enc *encoder) binwrite(v interface{}) { + if err := binary.Write(enc.out, enc.order, v); err != nil { + panic(err) + } +} + +// Encode encodes the given values to the underyling reader. All written values +// are aligned properly as required by the D-Bus spec. +func (enc *encoder) Encode(vs ...interface{}) (err error) { + defer func() { + err, _ = recover().(error) + }() + for _, v := range vs { + enc.encode(reflect.ValueOf(v), 0) + } + return nil +} + +// encode encodes the given value to the writer and panics on error. depth holds +// the depth of the container nesting. +func (enc *encoder) encode(v reflect.Value, depth int) { + enc.align(alignment(v.Type())) + switch v.Kind() { + case reflect.Uint8: + var b [1]byte + b[0] = byte(v.Uint()) + if _, err := enc.out.Write(b[:]); err != nil { + panic(err) + } + enc.pos++ + case reflect.Bool: + if v.Bool() { + enc.encode(reflect.ValueOf(uint32(1)), depth) + } else { + enc.encode(reflect.ValueOf(uint32(0)), depth) + } + case reflect.Int16: + enc.binwrite(int16(v.Int())) + enc.pos += 2 + case reflect.Uint16: + enc.binwrite(uint16(v.Uint())) + enc.pos += 2 + case reflect.Int32: + enc.binwrite(int32(v.Int())) + enc.pos += 4 + case reflect.Uint32: + enc.binwrite(uint32(v.Uint())) + enc.pos += 4 + case reflect.Int64: + enc.binwrite(v.Int()) + enc.pos += 8 + case reflect.Uint64: + enc.binwrite(v.Uint()) + enc.pos += 8 + case reflect.Float64: + enc.binwrite(v.Float()) + enc.pos += 8 + case reflect.String: + enc.encode(reflect.ValueOf(uint32(len(v.String()))), depth) + b := make([]byte, v.Len()+1) + copy(b, v.String()) + b[len(b)-1] = 0 + n, err := enc.out.Write(b) + if err != nil { + panic(err) + } + enc.pos += n + case reflect.Ptr: + enc.encode(v.Elem(), depth) + case reflect.Slice, reflect.Array: + if depth >= 64 { + panic(FormatError("input exceeds container depth limit")) + } + // Lookahead offset: 4 bytes for uint32 length (with alignment), + // plus alignment for elements. + n := enc.padding(0, 4) + 4 + offset := enc.pos + n + enc.padding(n, alignment(v.Type().Elem())) + + var buf bytes.Buffer + bufenc := newEncoderAtOffset(&buf, offset, enc.order) + + for i := 0; i < v.Len(); i++ { + bufenc.encode(v.Index(i), depth+1) + } + enc.encode(reflect.ValueOf(uint32(buf.Len())), depth) + length := buf.Len() + enc.align(alignment(v.Type().Elem())) + if _, err := buf.WriteTo(enc.out); err != nil { + panic(err) + } + enc.pos += length + case reflect.Struct: + if depth >= 64 && v.Type() != signatureType { + panic(FormatError("input exceeds container depth limit")) + } + switch t := v.Type(); t { + case signatureType: + str := v.Field(0) + enc.encode(reflect.ValueOf(byte(str.Len())), depth+1) + b := make([]byte, str.Len()+1) + copy(b, str.String()) + b[len(b)-1] = 0 + n, err := enc.out.Write(b) + if err != nil { + panic(err) + } + enc.pos += n + case variantType: + variant := v.Interface().(Variant) + enc.encode(reflect.ValueOf(variant.sig), depth+1) + enc.encode(reflect.ValueOf(variant.value), depth+1) + default: + for i := 0; i < v.Type().NumField(); i++ { + field := t.Field(i) + if field.PkgPath == "" && field.Tag.Get("dbus") != "-" { + enc.encode(v.Field(i), depth+1) + } + } + } + case reflect.Map: + // Maps are arrays of structures, so they actually increase the depth by + // 2. + if depth >= 63 { + panic(FormatError("input exceeds container depth limit")) + } + if !isKeyType(v.Type().Key()) { + panic(InvalidTypeError{v.Type()}) + } + keys := v.MapKeys() + // Lookahead offset: 4 bytes for uint32 length (with alignment), + // plus 8-byte alignment + n := enc.padding(0, 4) + 4 + offset := enc.pos + n + enc.padding(n, 8) + + var buf bytes.Buffer + bufenc := newEncoderAtOffset(&buf, offset, enc.order) + for _, k := range keys { + bufenc.align(8) + bufenc.encode(k, depth+2) + bufenc.encode(v.MapIndex(k), depth+2) + } + enc.encode(reflect.ValueOf(uint32(buf.Len())), depth) + length := buf.Len() + enc.align(8) + if _, err := buf.WriteTo(enc.out); err != nil { + panic(err) + } + enc.pos += length + default: + panic(InvalidTypeError{v.Type()}) + } +} diff --git a/vendor/github.com/godbus/dbus/export.go b/vendor/github.com/godbus/dbus/export.go new file mode 100644 index 0000000000..c6440a7416 --- /dev/null +++ b/vendor/github.com/godbus/dbus/export.go @@ -0,0 +1,411 @@ +package dbus + +import ( + "errors" + "fmt" + "reflect" + "strings" +) + +var ( + errmsgInvalidArg = Error{ + "org.freedesktop.DBus.Error.InvalidArgs", + []interface{}{"Invalid type / number of args"}, + } + errmsgNoObject = Error{ + "org.freedesktop.DBus.Error.NoSuchObject", + []interface{}{"No such object"}, + } + errmsgUnknownMethod = Error{ + "org.freedesktop.DBus.Error.UnknownMethod", + []interface{}{"Unknown / invalid method"}, + } +) + +// exportWithMapping represents an exported struct along with a method name +// mapping to allow for exporting lower-case methods, etc. +type exportWithMapping struct { + export interface{} + + // Method name mapping; key -> struct method, value -> dbus method. + mapping map[string]string + + // Whether or not this export is for the entire subtree + includeSubtree bool +} + +// Sender is a type which can be used in exported methods to receive the message +// sender. +type Sender string + +func exportedMethod(export exportWithMapping, name string) reflect.Value { + if export.export == nil { + return reflect.Value{} + } + + // If a mapping was included in the export, check the map to see if we + // should be looking for a different method in the export. + if export.mapping != nil { + for key, value := range export.mapping { + if value == name { + name = key + break + } + + // Catch the case where a method is aliased but the client is calling + // the original, e.g. the "Foo" method was exported mapped to + // "foo," and dbus client called the original "Foo." + if key == name { + return reflect.Value{} + } + } + } + + value := reflect.ValueOf(export.export) + m := value.MethodByName(name) + + // Catch the case of attempting to call an unexported method + method, ok := value.Type().MethodByName(name) + + if !m.IsValid() || !ok || method.PkgPath != "" { + return reflect.Value{} + } + t := m.Type() + if t.NumOut() == 0 || + t.Out(t.NumOut()-1) != reflect.TypeOf(&errmsgInvalidArg) { + + return reflect.Value{} + } + return m +} + +// searchHandlers will look through all registered handlers looking for one +// to handle the given path. If a verbatim one isn't found, it will check for +// a subtree registration for the path as well. +func (conn *Conn) searchHandlers(path ObjectPath) (map[string]exportWithMapping, bool) { + conn.handlersLck.RLock() + defer conn.handlersLck.RUnlock() + + handlers, ok := conn.handlers[path] + if ok { + return handlers, ok + } + + // If handlers weren't found for this exact path, look for a matching subtree + // registration + handlers = make(map[string]exportWithMapping) + path = path[:strings.LastIndex(string(path), "/")] + for len(path) > 0 { + var subtreeHandlers map[string]exportWithMapping + subtreeHandlers, ok = conn.handlers[path] + if ok { + for iface, handler := range subtreeHandlers { + // Only include this handler if it registered for the subtree + if handler.includeSubtree { + handlers[iface] = handler + } + } + + break + } + + path = path[:strings.LastIndex(string(path), "/")] + } + + return handlers, ok +} + +// handleCall handles the given method call (i.e. looks if it's one of the +// pre-implemented ones and searches for a corresponding handler if not). +func (conn *Conn) handleCall(msg *Message) { + name := msg.Headers[FieldMember].value.(string) + path := msg.Headers[FieldPath].value.(ObjectPath) + ifaceName, hasIface := msg.Headers[FieldInterface].value.(string) + sender, hasSender := msg.Headers[FieldSender].value.(string) + serial := msg.serial + if ifaceName == "org.freedesktop.DBus.Peer" { + switch name { + case "Ping": + conn.sendReply(sender, serial) + case "GetMachineId": + conn.sendReply(sender, serial, conn.uuid) + default: + conn.sendError(errmsgUnknownMethod, sender, serial) + } + return + } + if len(name) == 0 { + conn.sendError(errmsgUnknownMethod, sender, serial) + } + + // Find the exported handler (if any) for this path + handlers, ok := conn.searchHandlers(path) + if !ok { + conn.sendError(errmsgNoObject, sender, serial) + return + } + + var m reflect.Value + if hasIface { + iface := handlers[ifaceName] + m = exportedMethod(iface, name) + } else { + for _, v := range handlers { + m = exportedMethod(v, name) + if m.IsValid() { + break + } + } + } + + if !m.IsValid() { + conn.sendError(errmsgUnknownMethod, sender, serial) + return + } + + t := m.Type() + vs := msg.Body + pointers := make([]interface{}, t.NumIn()) + decode := make([]interface{}, 0, len(vs)) + for i := 0; i < t.NumIn(); i++ { + tp := t.In(i) + val := reflect.New(tp) + pointers[i] = val.Interface() + if tp == reflect.TypeOf((*Sender)(nil)).Elem() { + val.Elem().SetString(sender) + } else if tp == reflect.TypeOf((*Message)(nil)).Elem() { + val.Elem().Set(reflect.ValueOf(*msg)) + } else { + decode = append(decode, pointers[i]) + } + } + + if len(decode) != len(vs) { + conn.sendError(errmsgInvalidArg, sender, serial) + return + } + + if err := Store(vs, decode...); err != nil { + conn.sendError(errmsgInvalidArg, sender, serial) + return + } + + // Extract parameters + params := make([]reflect.Value, len(pointers)) + for i := 0; i < len(pointers); i++ { + params[i] = reflect.ValueOf(pointers[i]).Elem() + } + + // Call method + ret := m.Call(params) + if em := ret[t.NumOut()-1].Interface().(*Error); em != nil { + conn.sendError(*em, sender, serial) + return + } + + if msg.Flags&FlagNoReplyExpected == 0 { + reply := new(Message) + reply.Type = TypeMethodReply + reply.serial = conn.getSerial() + reply.Headers = make(map[HeaderField]Variant) + if hasSender { + reply.Headers[FieldDestination] = msg.Headers[FieldSender] + } + reply.Headers[FieldReplySerial] = MakeVariant(msg.serial) + reply.Body = make([]interface{}, len(ret)-1) + for i := 0; i < len(ret)-1; i++ { + reply.Body[i] = ret[i].Interface() + } + if len(ret) != 1 { + reply.Headers[FieldSignature] = MakeVariant(SignatureOf(reply.Body...)) + } + conn.outLck.RLock() + if !conn.closed { + conn.out <- reply + } + conn.outLck.RUnlock() + } +} + +// Emit emits the given signal on the message bus. The name parameter must be +// formatted as "interface.member", e.g., "org.freedesktop.DBus.NameLost". +func (conn *Conn) Emit(path ObjectPath, name string, values ...interface{}) error { + if !path.IsValid() { + return errors.New("dbus: invalid object path") + } + i := strings.LastIndex(name, ".") + if i == -1 { + return errors.New("dbus: invalid method name") + } + iface := name[:i] + member := name[i+1:] + if !isValidMember(member) { + return errors.New("dbus: invalid method name") + } + if !isValidInterface(iface) { + return errors.New("dbus: invalid interface name") + } + msg := new(Message) + msg.Type = TypeSignal + msg.serial = conn.getSerial() + msg.Headers = make(map[HeaderField]Variant) + msg.Headers[FieldInterface] = MakeVariant(iface) + msg.Headers[FieldMember] = MakeVariant(member) + msg.Headers[FieldPath] = MakeVariant(path) + msg.Body = values + if len(values) > 0 { + msg.Headers[FieldSignature] = MakeVariant(SignatureOf(values...)) + } + conn.outLck.RLock() + defer conn.outLck.RUnlock() + if conn.closed { + return ErrClosed + } + conn.out <- msg + return nil +} + +// Export registers the given value to be exported as an object on the +// message bus. +// +// If a method call on the given path and interface is received, an exported +// method with the same name is called with v as the receiver if the +// parameters match and the last return value is of type *Error. If this +// *Error is not nil, it is sent back to the caller as an error. +// Otherwise, a method reply is sent with the other return values as its body. +// +// Any parameters with the special type Sender are set to the sender of the +// dbus message when the method is called. Parameters of this type do not +// contribute to the dbus signature of the method (i.e. the method is exposed +// as if the parameters of type Sender were not there). +// +// Similarly, any parameters with the type Message are set to the raw message +// received on the bus. Again, parameters of this type do not contribute to the +// dbus signature of the method. +// +// Every method call is executed in a new goroutine, so the method may be called +// in multiple goroutines at once. +// +// Method calls on the interface org.freedesktop.DBus.Peer will be automatically +// handled for every object. +// +// Passing nil as the first parameter will cause conn to cease handling calls on +// the given combination of path and interface. +// +// Export returns an error if path is not a valid path name. +func (conn *Conn) Export(v interface{}, path ObjectPath, iface string) error { + return conn.ExportWithMap(v, nil, path, iface) +} + +// ExportWithMap works exactly like Export but provides the ability to remap +// method names (e.g. export a lower-case method). +// +// The keys in the map are the real method names (exported on the struct), and +// the values are the method names to be exported on DBus. +func (conn *Conn) ExportWithMap(v interface{}, mapping map[string]string, path ObjectPath, iface string) error { + return conn.exportWithMap(v, mapping, path, iface, false) +} + +// ExportSubtree works exactly like Export but registers the given value for +// an entire subtree rather under the root path provided. +// +// In order to make this useful, one parameter in each of the value's exported +// methods should be a Message, in which case it will contain the raw message +// (allowing one to get access to the path that caused the method to be called). +// +// Note that more specific export paths take precedence over less specific. For +// example, a method call using the ObjectPath /foo/bar/baz will call a method +// exported on /foo/bar before a method exported on /foo. +func (conn *Conn) ExportSubtree(v interface{}, path ObjectPath, iface string) error { + return conn.ExportSubtreeWithMap(v, nil, path, iface) +} + +// ExportSubtreeWithMap works exactly like ExportSubtree but provides the +// ability to remap method names (e.g. export a lower-case method). +// +// The keys in the map are the real method names (exported on the struct), and +// the values are the method names to be exported on DBus. +func (conn *Conn) ExportSubtreeWithMap(v interface{}, mapping map[string]string, path ObjectPath, iface string) error { + return conn.exportWithMap(v, mapping, path, iface, true) +} + +// exportWithMap is the worker function for all exports/registrations. +func (conn *Conn) exportWithMap(v interface{}, mapping map[string]string, path ObjectPath, iface string, includeSubtree bool) error { + if !path.IsValid() { + return fmt.Errorf(`dbus: Invalid path name: "%s"`, path) + } + + conn.handlersLck.Lock() + defer conn.handlersLck.Unlock() + + // Remove a previous export if the interface is nil + if v == nil { + if _, ok := conn.handlers[path]; ok { + delete(conn.handlers[path], iface) + if len(conn.handlers[path]) == 0 { + delete(conn.handlers, path) + } + } + + return nil + } + + // If this is the first handler for this path, make a new map to hold all + // handlers for this path. + if _, ok := conn.handlers[path]; !ok { + conn.handlers[path] = make(map[string]exportWithMapping) + } + + // Finally, save this handler + conn.handlers[path][iface] = exportWithMapping{export: v, mapping: mapping, includeSubtree: includeSubtree} + + return nil +} + +// ReleaseName calls org.freedesktop.DBus.ReleaseName and awaits a response. +func (conn *Conn) ReleaseName(name string) (ReleaseNameReply, error) { + var r uint32 + err := conn.busObj.Call("org.freedesktop.DBus.ReleaseName", 0, name).Store(&r) + if err != nil { + return 0, err + } + return ReleaseNameReply(r), nil +} + +// RequestName calls org.freedesktop.DBus.RequestName and awaits a response. +func (conn *Conn) RequestName(name string, flags RequestNameFlags) (RequestNameReply, error) { + var r uint32 + err := conn.busObj.Call("org.freedesktop.DBus.RequestName", 0, name, flags).Store(&r) + if err != nil { + return 0, err + } + return RequestNameReply(r), nil +} + +// ReleaseNameReply is the reply to a ReleaseName call. +type ReleaseNameReply uint32 + +const ( + ReleaseNameReplyReleased ReleaseNameReply = 1 + iota + ReleaseNameReplyNonExistent + ReleaseNameReplyNotOwner +) + +// RequestNameFlags represents the possible flags for a RequestName call. +type RequestNameFlags uint32 + +const ( + NameFlagAllowReplacement RequestNameFlags = 1 << iota + NameFlagReplaceExisting + NameFlagDoNotQueue +) + +// RequestNameReply is the reply to a RequestName call. +type RequestNameReply uint32 + +const ( + RequestNameReplyPrimaryOwner RequestNameReply = 1 + iota + RequestNameReplyInQueue + RequestNameReplyExists + RequestNameReplyAlreadyOwner +) diff --git a/vendor/github.com/godbus/dbus/homedir.go b/vendor/github.com/godbus/dbus/homedir.go new file mode 100644 index 0000000000..0b745f9313 --- /dev/null +++ b/vendor/github.com/godbus/dbus/homedir.go @@ -0,0 +1,28 @@ +package dbus + +import ( + "os" + "sync" +) + +var ( + homeDir string + homeDirLock sync.Mutex +) + +func getHomeDir() string { + homeDirLock.Lock() + defer homeDirLock.Unlock() + + if homeDir != "" { + return homeDir + } + + homeDir = os.Getenv("HOME") + if homeDir != "" { + return homeDir + } + + homeDir = lookupHomeDir() + return homeDir +} diff --git a/vendor/github.com/godbus/dbus/homedir_dynamic.go b/vendor/github.com/godbus/dbus/homedir_dynamic.go new file mode 100644 index 0000000000..2732081e73 --- /dev/null +++ b/vendor/github.com/godbus/dbus/homedir_dynamic.go @@ -0,0 +1,15 @@ +// +build !static_build + +package dbus + +import ( + "os/user" +) + +func lookupHomeDir() string { + u, err := user.Current() + if err != nil { + return "/" + } + return u.HomeDir +} diff --git a/vendor/github.com/godbus/dbus/homedir_static.go b/vendor/github.com/godbus/dbus/homedir_static.go new file mode 100644 index 0000000000..b9d9cb5525 --- /dev/null +++ b/vendor/github.com/godbus/dbus/homedir_static.go @@ -0,0 +1,45 @@ +// +build static_build + +package dbus + +import ( + "bufio" + "os" + "strconv" + "strings" +) + +func lookupHomeDir() string { + myUid := os.Getuid() + + f, err := os.Open("/etc/passwd") + if err != nil { + return "/" + } + defer f.Close() + + s := bufio.NewScanner(f) + + for s.Scan() { + if err := s.Err(); err != nil { + break + } + + line := strings.TrimSpace(s.Text()) + if line == "" { + continue + } + + parts := strings.Split(line, ":") + + if len(parts) >= 6 { + uid, err := strconv.Atoi(parts[2]) + if err == nil && uid == myUid { + return parts[5] + } + } + } + + // Default to / if we can't get a better value + return "/" +} diff --git a/vendor/github.com/godbus/dbus/introspect/call.go b/vendor/github.com/godbus/dbus/introspect/call.go new file mode 100644 index 0000000000..790a23ec24 --- /dev/null +++ b/vendor/github.com/godbus/dbus/introspect/call.go @@ -0,0 +1,27 @@ +package introspect + +import ( + "encoding/xml" + "github.com/godbus/dbus" + "strings" +) + +// Call calls org.freedesktop.Introspectable.Introspect on a remote object +// and returns the introspection data. +func Call(o dbus.BusObject) (*Node, error) { + var xmldata string + var node Node + + err := o.Call("org.freedesktop.DBus.Introspectable.Introspect", 0).Store(&xmldata) + if err != nil { + return nil, err + } + err = xml.NewDecoder(strings.NewReader(xmldata)).Decode(&node) + if err != nil { + return nil, err + } + if node.Name == "" { + node.Name = string(o.Path()) + } + return &node, nil +} diff --git a/vendor/github.com/godbus/dbus/introspect/introspect.go b/vendor/github.com/godbus/dbus/introspect/introspect.go new file mode 100644 index 0000000000..b06c3f1cf2 --- /dev/null +++ b/vendor/github.com/godbus/dbus/introspect/introspect.go @@ -0,0 +1,86 @@ +// Package introspect provides some utilities for dealing with the DBus +// introspection format. +package introspect + +import "encoding/xml" + +// The introspection data for the org.freedesktop.DBus.Introspectable interface. +var IntrospectData = Interface{ + Name: "org.freedesktop.DBus.Introspectable", + Methods: []Method{ + { + Name: "Introspect", + Args: []Arg{ + {"out", "s", "out"}, + }, + }, + }, +} + +// XML document type declaration of the introspection format version 1.0 +const IntrospectDeclarationString = ` + +` + +// The introspection data for the org.freedesktop.DBus.Introspectable interface, +// as a string. +const IntrospectDataString = ` + + + + + +` + +// Node is the root element of an introspection. +type Node struct { + XMLName xml.Name `xml:"node"` + Name string `xml:"name,attr,omitempty"` + Interfaces []Interface `xml:"interface"` + Children []Node `xml:"node,omitempty"` +} + +// Interface describes a DBus interface that is available on the message bus. +type Interface struct { + Name string `xml:"name,attr"` + Methods []Method `xml:"method"` + Signals []Signal `xml:"signal"` + Properties []Property `xml:"property"` + Annotations []Annotation `xml:"annotation"` +} + +// Method describes a Method on an Interface as retured by an introspection. +type Method struct { + Name string `xml:"name,attr"` + Args []Arg `xml:"arg"` + Annotations []Annotation `xml:"annotation"` +} + +// Signal describes a Signal emitted on an Interface. +type Signal struct { + Name string `xml:"name,attr"` + Args []Arg `xml:"arg"` + Annotations []Annotation `xml:"annotation"` +} + +// Property describes a property of an Interface. +type Property struct { + Name string `xml:"name,attr"` + Type string `xml:"type,attr"` + Access string `xml:"access,attr"` + Annotations []Annotation `xml:"annotation"` +} + +// Arg represents an argument of a method or a signal. +type Arg struct { + Name string `xml:"name,attr,omitempty"` + Type string `xml:"type,attr"` + Direction string `xml:"direction,attr,omitempty"` +} + +// Annotation is an annotation in the introspection format. +type Annotation struct { + Name string `xml:"name,attr"` + Value string `xml:"value,attr"` +} diff --git a/vendor/github.com/godbus/dbus/introspect/introspectable.go b/vendor/github.com/godbus/dbus/introspect/introspectable.go new file mode 100644 index 0000000000..2f16690b99 --- /dev/null +++ b/vendor/github.com/godbus/dbus/introspect/introspectable.go @@ -0,0 +1,76 @@ +package introspect + +import ( + "encoding/xml" + "github.com/godbus/dbus" + "reflect" + "strings" +) + +// Introspectable implements org.freedesktop.Introspectable. +// +// You can create it by converting the XML-formatted introspection data from a +// string to an Introspectable or call NewIntrospectable with a Node. Then, +// export it as org.freedesktop.Introspectable on you object. +type Introspectable string + +// NewIntrospectable returns an Introspectable that returns the introspection +// data that corresponds to the given Node. If n.Interfaces doesn't contain the +// data for org.freedesktop.DBus.Introspectable, it is added automatically. +func NewIntrospectable(n *Node) Introspectable { + found := false + for _, v := range n.Interfaces { + if v.Name == "org.freedesktop.DBus.Introspectable" { + found = true + break + } + } + if !found { + n.Interfaces = append(n.Interfaces, IntrospectData) + } + b, err := xml.Marshal(n) + if err != nil { + panic(err) + } + return Introspectable(strings.TrimSpace(IntrospectDeclarationString) + string(b)) +} + +// Introspect implements org.freedesktop.Introspectable.Introspect. +func (i Introspectable) Introspect() (string, *dbus.Error) { + return string(i), nil +} + +// Methods returns the description of the methods of v. This can be used to +// create a Node which can be passed to NewIntrospectable. +func Methods(v interface{}) []Method { + t := reflect.TypeOf(v) + ms := make([]Method, 0, t.NumMethod()) + for i := 0; i < t.NumMethod(); i++ { + if t.Method(i).PkgPath != "" { + continue + } + mt := t.Method(i).Type + if mt.NumOut() == 0 || + mt.Out(mt.NumOut()-1) != reflect.TypeOf(&dbus.Error{}) { + + continue + } + var m Method + m.Name = t.Method(i).Name + m.Args = make([]Arg, 0, mt.NumIn()+mt.NumOut()-2) + for j := 1; j < mt.NumIn(); j++ { + if mt.In(j) != reflect.TypeOf((*dbus.Sender)(nil)).Elem() && + mt.In(j) != reflect.TypeOf((*dbus.Message)(nil)).Elem() { + arg := Arg{"", dbus.SignatureOfType(mt.In(j)).String(), "in"} + m.Args = append(m.Args, arg) + } + } + for j := 0; j < mt.NumOut()-1; j++ { + arg := Arg{"", dbus.SignatureOfType(mt.Out(j)).String(), "out"} + m.Args = append(m.Args, arg) + } + m.Annotations = make([]Annotation, 0) + ms = append(ms, m) + } + return ms +} diff --git a/vendor/github.com/godbus/dbus/message.go b/vendor/github.com/godbus/dbus/message.go new file mode 100644 index 0000000000..075d6e38ba --- /dev/null +++ b/vendor/github.com/godbus/dbus/message.go @@ -0,0 +1,346 @@ +package dbus + +import ( + "bytes" + "encoding/binary" + "errors" + "io" + "reflect" + "strconv" +) + +const protoVersion byte = 1 + +// Flags represents the possible flags of a D-Bus message. +type Flags byte + +const ( + // FlagNoReplyExpected signals that the message is not expected to generate + // a reply. If this flag is set on outgoing messages, any possible reply + // will be discarded. + FlagNoReplyExpected Flags = 1 << iota + // FlagNoAutoStart signals that the message bus should not automatically + // start an application when handling this message. + FlagNoAutoStart +) + +// Type represents the possible types of a D-Bus message. +type Type byte + +const ( + TypeMethodCall Type = 1 + iota + TypeMethodReply + TypeError + TypeSignal + typeMax +) + +func (t Type) String() string { + switch t { + case TypeMethodCall: + return "method call" + case TypeMethodReply: + return "reply" + case TypeError: + return "error" + case TypeSignal: + return "signal" + } + return "invalid" +} + +// HeaderField represents the possible byte codes for the headers +// of a D-Bus message. +type HeaderField byte + +const ( + FieldPath HeaderField = 1 + iota + FieldInterface + FieldMember + FieldErrorName + FieldReplySerial + FieldDestination + FieldSender + FieldSignature + FieldUnixFDs + fieldMax +) + +// An InvalidMessageError describes the reason why a D-Bus message is regarded as +// invalid. +type InvalidMessageError string + +func (e InvalidMessageError) Error() string { + return "dbus: invalid message: " + string(e) +} + +// fieldType are the types of the various header fields. +var fieldTypes = [fieldMax]reflect.Type{ + FieldPath: objectPathType, + FieldInterface: stringType, + FieldMember: stringType, + FieldErrorName: stringType, + FieldReplySerial: uint32Type, + FieldDestination: stringType, + FieldSender: stringType, + FieldSignature: signatureType, + FieldUnixFDs: uint32Type, +} + +// requiredFields lists the header fields that are required by the different +// message types. +var requiredFields = [typeMax][]HeaderField{ + TypeMethodCall: {FieldPath, FieldMember}, + TypeMethodReply: {FieldReplySerial}, + TypeError: {FieldErrorName, FieldReplySerial}, + TypeSignal: {FieldPath, FieldInterface, FieldMember}, +} + +// Message represents a single D-Bus message. +type Message struct { + Type + Flags + Headers map[HeaderField]Variant + Body []interface{} + + serial uint32 +} + +type header struct { + Field byte + Variant +} + +// DecodeMessage tries to decode a single message in the D-Bus wire format +// from the given reader. The byte order is figured out from the first byte. +// The possibly returned error can be an error of the underlying reader, an +// InvalidMessageError or a FormatError. +func DecodeMessage(rd io.Reader) (msg *Message, err error) { + var order binary.ByteOrder + var hlength, length uint32 + var typ, flags, proto byte + var headers []header + + b := make([]byte, 1) + _, err = rd.Read(b) + if err != nil { + return + } + switch b[0] { + case 'l': + order = binary.LittleEndian + case 'B': + order = binary.BigEndian + default: + return nil, InvalidMessageError("invalid byte order") + } + + dec := newDecoder(rd, order) + dec.pos = 1 + + msg = new(Message) + vs, err := dec.Decode(Signature{"yyyuu"}) + if err != nil { + return nil, err + } + if err = Store(vs, &typ, &flags, &proto, &length, &msg.serial); err != nil { + return nil, err + } + msg.Type = Type(typ) + msg.Flags = Flags(flags) + + // get the header length separately because we need it later + b = make([]byte, 4) + _, err = io.ReadFull(rd, b) + if err != nil { + return nil, err + } + binary.Read(bytes.NewBuffer(b), order, &hlength) + if hlength+length+16 > 1<<27 { + return nil, InvalidMessageError("message is too long") + } + dec = newDecoder(io.MultiReader(bytes.NewBuffer(b), rd), order) + dec.pos = 12 + vs, err = dec.Decode(Signature{"a(yv)"}) + if err != nil { + return nil, err + } + if err = Store(vs, &headers); err != nil { + return nil, err + } + + msg.Headers = make(map[HeaderField]Variant) + for _, v := range headers { + msg.Headers[HeaderField(v.Field)] = v.Variant + } + + dec.align(8) + body := make([]byte, int(length)) + if length != 0 { + _, err := io.ReadFull(rd, body) + if err != nil { + return nil, err + } + } + + if err = msg.IsValid(); err != nil { + return nil, err + } + sig, _ := msg.Headers[FieldSignature].value.(Signature) + if sig.str != "" { + buf := bytes.NewBuffer(body) + dec = newDecoder(buf, order) + vs, err := dec.Decode(sig) + if err != nil { + return nil, err + } + msg.Body = vs + } + + return +} + +// EncodeTo encodes and sends a message to the given writer. The byte order must +// be either binary.LittleEndian or binary.BigEndian. If the message is not +// valid or an error occurs when writing, an error is returned. +func (msg *Message) EncodeTo(out io.Writer, order binary.ByteOrder) error { + if err := msg.IsValid(); err != nil { + return err + } + var vs [7]interface{} + switch order { + case binary.LittleEndian: + vs[0] = byte('l') + case binary.BigEndian: + vs[0] = byte('B') + default: + return errors.New("dbus: invalid byte order") + } + body := new(bytes.Buffer) + enc := newEncoder(body, order) + if len(msg.Body) != 0 { + enc.Encode(msg.Body...) + } + vs[1] = msg.Type + vs[2] = msg.Flags + vs[3] = protoVersion + vs[4] = uint32(len(body.Bytes())) + vs[5] = msg.serial + headers := make([]header, 0, len(msg.Headers)) + for k, v := range msg.Headers { + headers = append(headers, header{byte(k), v}) + } + vs[6] = headers + var buf bytes.Buffer + enc = newEncoder(&buf, order) + enc.Encode(vs[:]...) + enc.align(8) + body.WriteTo(&buf) + if buf.Len() > 1<<27 { + return InvalidMessageError("message is too long") + } + if _, err := buf.WriteTo(out); err != nil { + return err + } + return nil +} + +// IsValid checks whether msg is a valid message and returns an +// InvalidMessageError if it is not. +func (msg *Message) IsValid() error { + if msg.Flags & ^(FlagNoAutoStart|FlagNoReplyExpected) != 0 { + return InvalidMessageError("invalid flags") + } + if msg.Type == 0 || msg.Type >= typeMax { + return InvalidMessageError("invalid message type") + } + for k, v := range msg.Headers { + if k == 0 || k >= fieldMax { + return InvalidMessageError("invalid header") + } + if reflect.TypeOf(v.value) != fieldTypes[k] { + return InvalidMessageError("invalid type of header field") + } + } + for _, v := range requiredFields[msg.Type] { + if _, ok := msg.Headers[v]; !ok { + return InvalidMessageError("missing required header") + } + } + if path, ok := msg.Headers[FieldPath]; ok { + if !path.value.(ObjectPath).IsValid() { + return InvalidMessageError("invalid path name") + } + } + if iface, ok := msg.Headers[FieldInterface]; ok { + if !isValidInterface(iface.value.(string)) { + return InvalidMessageError("invalid interface name") + } + } + if member, ok := msg.Headers[FieldMember]; ok { + if !isValidMember(member.value.(string)) { + return InvalidMessageError("invalid member name") + } + } + if errname, ok := msg.Headers[FieldErrorName]; ok { + if !isValidInterface(errname.value.(string)) { + return InvalidMessageError("invalid error name") + } + } + if len(msg.Body) != 0 { + if _, ok := msg.Headers[FieldSignature]; !ok { + return InvalidMessageError("missing signature") + } + } + return nil +} + +// Serial returns the message's serial number. The returned value is only valid +// for messages received by eavesdropping. +func (msg *Message) Serial() uint32 { + return msg.serial +} + +// String returns a string representation of a message similar to the format of +// dbus-monitor. +func (msg *Message) String() string { + if err := msg.IsValid(); err != nil { + return "" + } + s := msg.Type.String() + if v, ok := msg.Headers[FieldSender]; ok { + s += " from " + v.value.(string) + } + if v, ok := msg.Headers[FieldDestination]; ok { + s += " to " + v.value.(string) + } + s += " serial " + strconv.FormatUint(uint64(msg.serial), 10) + if v, ok := msg.Headers[FieldReplySerial]; ok { + s += " reply_serial " + strconv.FormatUint(uint64(v.value.(uint32)), 10) + } + if v, ok := msg.Headers[FieldUnixFDs]; ok { + s += " unixfds " + strconv.FormatUint(uint64(v.value.(uint32)), 10) + } + if v, ok := msg.Headers[FieldPath]; ok { + s += " path " + string(v.value.(ObjectPath)) + } + if v, ok := msg.Headers[FieldInterface]; ok { + s += " interface " + v.value.(string) + } + if v, ok := msg.Headers[FieldErrorName]; ok { + s += " error " + v.value.(string) + } + if v, ok := msg.Headers[FieldMember]; ok { + s += " member " + v.value.(string) + } + if len(msg.Body) != 0 { + s += "\n" + } + for i, v := range msg.Body { + s += " " + MakeVariant(v).String() + if i != len(msg.Body)-1 { + s += "\n" + } + } + return s +} diff --git a/vendor/github.com/godbus/dbus/object.go b/vendor/github.com/godbus/dbus/object.go new file mode 100644 index 0000000000..9573b7095a --- /dev/null +++ b/vendor/github.com/godbus/dbus/object.go @@ -0,0 +1,136 @@ +package dbus + +import ( + "errors" + "strings" +) + +// BusObject is the interface of a remote object on which methods can be +// invoked. +type BusObject interface { + Call(method string, flags Flags, args ...interface{}) *Call + Go(method string, flags Flags, ch chan *Call, args ...interface{}) *Call + GetProperty(p string) (Variant, error) + Destination() string + Path() ObjectPath +} + +// Object represents a remote object on which methods can be invoked. +type Object struct { + conn *Conn + dest string + path ObjectPath +} + +// Call calls a method with (*Object).Go and waits for its reply. +func (o *Object) Call(method string, flags Flags, args ...interface{}) *Call { + return <-o.Go(method, flags, make(chan *Call, 1), args...).Done +} + +// AddMatchSignal subscribes BusObject to signals from specified interface and +// method (member). +func (o *Object) AddMatchSignal(iface, member string) *Call { + return o.Call( + "org.freedesktop.DBus.AddMatch", + 0, + "type='signal',interface='"+iface+"',member='"+member+"'", + ) +} + +// Go calls a method with the given arguments asynchronously. It returns a +// Call structure representing this method call. The passed channel will +// return the same value once the call is done. If ch is nil, a new channel +// will be allocated. Otherwise, ch has to be buffered or Go will panic. +// +// If the flags include FlagNoReplyExpected, ch is ignored and a Call structure +// is returned of which only the Err member is valid. +// +// If the method parameter contains a dot ('.'), the part before the last dot +// specifies the interface on which the method is called. +func (o *Object) Go(method string, flags Flags, ch chan *Call, args ...interface{}) *Call { + iface := "" + i := strings.LastIndex(method, ".") + if i != -1 { + iface = method[:i] + } + method = method[i+1:] + msg := new(Message) + msg.Type = TypeMethodCall + msg.serial = o.conn.getSerial() + msg.Flags = flags & (FlagNoAutoStart | FlagNoReplyExpected) + msg.Headers = make(map[HeaderField]Variant) + msg.Headers[FieldPath] = MakeVariant(o.path) + msg.Headers[FieldDestination] = MakeVariant(o.dest) + msg.Headers[FieldMember] = MakeVariant(method) + if iface != "" { + msg.Headers[FieldInterface] = MakeVariant(iface) + } + msg.Body = args + if len(args) > 0 { + msg.Headers[FieldSignature] = MakeVariant(SignatureOf(args...)) + } + if msg.Flags&FlagNoReplyExpected == 0 { + if ch == nil { + ch = make(chan *Call, 10) + } else if cap(ch) == 0 { + panic("dbus: unbuffered channel passed to (*Object).Go") + } + call := &Call{ + Destination: o.dest, + Path: o.path, + Method: method, + Args: args, + Done: ch, + } + o.conn.callsLck.Lock() + o.conn.calls[msg.serial] = call + o.conn.callsLck.Unlock() + o.conn.outLck.RLock() + if o.conn.closed { + call.Err = ErrClosed + call.Done <- call + } else { + o.conn.out <- msg + } + o.conn.outLck.RUnlock() + return call + } + o.conn.outLck.RLock() + defer o.conn.outLck.RUnlock() + if o.conn.closed { + return &Call{Err: ErrClosed} + } + o.conn.out <- msg + return &Call{Err: nil} +} + +// GetProperty calls org.freedesktop.DBus.Properties.GetProperty on the given +// object. The property name must be given in interface.member notation. +func (o *Object) GetProperty(p string) (Variant, error) { + idx := strings.LastIndex(p, ".") + if idx == -1 || idx+1 == len(p) { + return Variant{}, errors.New("dbus: invalid property " + p) + } + + iface := p[:idx] + prop := p[idx+1:] + + result := Variant{} + err := o.Call("org.freedesktop.DBus.Properties.Get", 0, iface, prop).Store(&result) + + if err != nil { + return Variant{}, err + } + + return result, nil +} + +// Destination returns the destination that calls on o are sent to. +func (o *Object) Destination() string { + return o.dest +} + +// Path returns the path that calls on o are sent to. +func (o *Object) Path() ObjectPath { + return o.path +} diff --git a/vendor/github.com/godbus/dbus/sig.go b/vendor/github.com/godbus/dbus/sig.go new file mode 100644 index 0000000000..f45b53ce1b --- /dev/null +++ b/vendor/github.com/godbus/dbus/sig.go @@ -0,0 +1,257 @@ +package dbus + +import ( + "fmt" + "reflect" + "strings" +) + +var sigToType = map[byte]reflect.Type{ + 'y': byteType, + 'b': boolType, + 'n': int16Type, + 'q': uint16Type, + 'i': int32Type, + 'u': uint32Type, + 'x': int64Type, + 't': uint64Type, + 'd': float64Type, + 's': stringType, + 'g': signatureType, + 'o': objectPathType, + 'v': variantType, + 'h': unixFDIndexType, +} + +// Signature represents a correct type signature as specified by the D-Bus +// specification. The zero value represents the empty signature, "". +type Signature struct { + str string +} + +// SignatureOf returns the concatenation of all the signatures of the given +// values. It panics if one of them is not representable in D-Bus. +func SignatureOf(vs ...interface{}) Signature { + var s string + for _, v := range vs { + s += getSignature(reflect.TypeOf(v)) + } + return Signature{s} +} + +// SignatureOfType returns the signature of the given type. It panics if the +// type is not representable in D-Bus. +func SignatureOfType(t reflect.Type) Signature { + return Signature{getSignature(t)} +} + +// getSignature returns the signature of the given type and panics on unknown types. +func getSignature(t reflect.Type) string { + // handle simple types first + switch t.Kind() { + case reflect.Uint8: + return "y" + case reflect.Bool: + return "b" + case reflect.Int16: + return "n" + case reflect.Uint16: + return "q" + case reflect.Int32: + if t == unixFDType { + return "h" + } + return "i" + case reflect.Uint32: + if t == unixFDIndexType { + return "h" + } + return "u" + case reflect.Int64: + return "x" + case reflect.Uint64: + return "t" + case reflect.Float64: + return "d" + case reflect.Ptr: + return getSignature(t.Elem()) + case reflect.String: + if t == objectPathType { + return "o" + } + return "s" + case reflect.Struct: + if t == variantType { + return "v" + } else if t == signatureType { + return "g" + } + var s string + for i := 0; i < t.NumField(); i++ { + field := t.Field(i) + if field.PkgPath == "" && field.Tag.Get("dbus") != "-" { + s += getSignature(t.Field(i).Type) + } + } + return "(" + s + ")" + case reflect.Array, reflect.Slice: + return "a" + getSignature(t.Elem()) + case reflect.Map: + if !isKeyType(t.Key()) { + panic(InvalidTypeError{t}) + } + return "a{" + getSignature(t.Key()) + getSignature(t.Elem()) + "}" + } + panic(InvalidTypeError{t}) +} + +// ParseSignature returns the signature represented by this string, or a +// SignatureError if the string is not a valid signature. +func ParseSignature(s string) (sig Signature, err error) { + if len(s) == 0 { + return + } + if len(s) > 255 { + return Signature{""}, SignatureError{s, "too long"} + } + sig.str = s + for err == nil && len(s) != 0 { + err, s = validSingle(s, 0) + } + if err != nil { + sig = Signature{""} + } + + return +} + +// ParseSignatureMust behaves like ParseSignature, except that it panics if s +// is not valid. +func ParseSignatureMust(s string) Signature { + sig, err := ParseSignature(s) + if err != nil { + panic(err) + } + return sig +} + +// Empty retruns whether the signature is the empty signature. +func (s Signature) Empty() bool { + return s.str == "" +} + +// Single returns whether the signature represents a single, complete type. +func (s Signature) Single() bool { + err, r := validSingle(s.str, 0) + return err != nil && r == "" +} + +// String returns the signature's string representation. +func (s Signature) String() string { + return s.str +} + +// A SignatureError indicates that a signature passed to a function or received +// on a connection is not a valid signature. +type SignatureError struct { + Sig string + Reason string +} + +func (e SignatureError) Error() string { + return fmt.Sprintf("dbus: invalid signature: %q (%s)", e.Sig, e.Reason) +} + +// Try to read a single type from this string. If it was successfull, err is nil +// and rem is the remaining unparsed part. Otherwise, err is a non-nil +// SignatureError and rem is "". depth is the current recursion depth which may +// not be greater than 64 and should be given as 0 on the first call. +func validSingle(s string, depth int) (err error, rem string) { + if s == "" { + return SignatureError{Sig: s, Reason: "empty signature"}, "" + } + if depth > 64 { + return SignatureError{Sig: s, Reason: "container nesting too deep"}, "" + } + switch s[0] { + case 'y', 'b', 'n', 'q', 'i', 'u', 'x', 't', 'd', 's', 'g', 'o', 'v', 'h': + return nil, s[1:] + case 'a': + if len(s) > 1 && s[1] == '{' { + i := findMatching(s[1:], '{', '}') + if i == -1 { + return SignatureError{Sig: s, Reason: "unmatched '{'"}, "" + } + i++ + rem = s[i+1:] + s = s[2:i] + if err, _ = validSingle(s[:1], depth+1); err != nil { + return err, "" + } + err, nr := validSingle(s[1:], depth+1) + if err != nil { + return err, "" + } + if nr != "" { + return SignatureError{Sig: s, Reason: "too many types in dict"}, "" + } + return nil, rem + } + return validSingle(s[1:], depth+1) + case '(': + i := findMatching(s, '(', ')') + if i == -1 { + return SignatureError{Sig: s, Reason: "unmatched ')'"}, "" + } + rem = s[i+1:] + s = s[1:i] + for err == nil && s != "" { + err, s = validSingle(s, depth+1) + } + if err != nil { + rem = "" + } + return + } + return SignatureError{Sig: s, Reason: "invalid type character"}, "" +} + +func findMatching(s string, left, right rune) int { + n := 0 + for i, v := range s { + if v == left { + n++ + } else if v == right { + n-- + } + if n == 0 { + return i + } + } + return -1 +} + +// typeFor returns the type of the given signature. It ignores any left over +// characters and panics if s doesn't start with a valid type signature. +func typeFor(s string) (t reflect.Type) { + err, _ := validSingle(s, 0) + if err != nil { + panic(err) + } + + if t, ok := sigToType[s[0]]; ok { + return t + } + switch s[0] { + case 'a': + if s[1] == '{' { + i := strings.LastIndex(s, "}") + t = reflect.MapOf(sigToType[s[2]], typeFor(s[3:i])) + } else { + t = reflect.SliceOf(typeFor(s[1:])) + } + case '(': + t = interfacesType + } + return +} diff --git a/vendor/github.com/godbus/dbus/transport_darwin.go b/vendor/github.com/godbus/dbus/transport_darwin.go new file mode 100644 index 0000000000..1bba0d6bf7 --- /dev/null +++ b/vendor/github.com/godbus/dbus/transport_darwin.go @@ -0,0 +1,6 @@ +package dbus + +func (t *unixTransport) SendNullByte() error { + _, err := t.Write([]byte{0}) + return err +} diff --git a/vendor/github.com/godbus/dbus/transport_generic.go b/vendor/github.com/godbus/dbus/transport_generic.go new file mode 100644 index 0000000000..46f8f49d69 --- /dev/null +++ b/vendor/github.com/godbus/dbus/transport_generic.go @@ -0,0 +1,35 @@ +package dbus + +import ( + "encoding/binary" + "errors" + "io" +) + +type genericTransport struct { + io.ReadWriteCloser +} + +func (t genericTransport) SendNullByte() error { + _, err := t.Write([]byte{0}) + return err +} + +func (t genericTransport) SupportsUnixFDs() bool { + return false +} + +func (t genericTransport) EnableUnixFDs() {} + +func (t genericTransport) ReadMessage() (*Message, error) { + return DecodeMessage(t) +} + +func (t genericTransport) SendMessage(msg *Message) error { + for _, v := range msg.Body { + if _, ok := v.(UnixFD); ok { + return errors.New("dbus: unix fd passing not enabled") + } + } + return msg.EncodeTo(t, binary.LittleEndian) +} diff --git a/vendor/github.com/godbus/dbus/transport_unix.go b/vendor/github.com/godbus/dbus/transport_unix.go new file mode 100644 index 0000000000..3fafeabb15 --- /dev/null +++ b/vendor/github.com/godbus/dbus/transport_unix.go @@ -0,0 +1,196 @@ +//+build !windows + +package dbus + +import ( + "bytes" + "encoding/binary" + "errors" + "io" + "net" + "syscall" +) + +type oobReader struct { + conn *net.UnixConn + oob []byte + buf [4096]byte +} + +func (o *oobReader) Read(b []byte) (n int, err error) { + n, oobn, flags, _, err := o.conn.ReadMsgUnix(b, o.buf[:]) + if err != nil { + return n, err + } + if flags&syscall.MSG_CTRUNC != 0 { + return n, errors.New("dbus: control data truncated (too many fds received)") + } + o.oob = append(o.oob, o.buf[:oobn]...) + return n, nil +} + +type unixTransport struct { + *net.UnixConn + hasUnixFDs bool +} + +func newUnixTransport(keys string) (transport, error) { + var err error + + t := new(unixTransport) + abstract := getKey(keys, "abstract") + path := getKey(keys, "path") + switch { + case abstract == "" && path == "": + return nil, errors.New("dbus: invalid address (neither path nor abstract set)") + case abstract != "" && path == "": + t.UnixConn, err = net.DialUnix("unix", nil, &net.UnixAddr{Name: "@" + abstract, Net: "unix"}) + if err != nil { + return nil, err + } + return t, nil + case abstract == "" && path != "": + t.UnixConn, err = net.DialUnix("unix", nil, &net.UnixAddr{Name: path, Net: "unix"}) + if err != nil { + return nil, err + } + return t, nil + default: + return nil, errors.New("dbus: invalid address (both path and abstract set)") + } +} + +func init() { + transports["unix"] = newUnixTransport +} + +func (t *unixTransport) EnableUnixFDs() { + t.hasUnixFDs = true +} + +func (t *unixTransport) ReadMessage() (*Message, error) { + var ( + blen, hlen uint32 + csheader [16]byte + headers []header + order binary.ByteOrder + unixfds uint32 + ) + // To be sure that all bytes of out-of-band data are read, we use a special + // reader that uses ReadUnix on the underlying connection instead of Read + // and gathers the out-of-band data in a buffer. + rd := &oobReader{conn: t.UnixConn} + // read the first 16 bytes (the part of the header that has a constant size), + // from which we can figure out the length of the rest of the message + if _, err := io.ReadFull(rd, csheader[:]); err != nil { + return nil, err + } + switch csheader[0] { + case 'l': + order = binary.LittleEndian + case 'B': + order = binary.BigEndian + default: + return nil, InvalidMessageError("invalid byte order") + } + // csheader[4:8] -> length of message body, csheader[12:16] -> length of + // header fields (without alignment) + binary.Read(bytes.NewBuffer(csheader[4:8]), order, &blen) + binary.Read(bytes.NewBuffer(csheader[12:]), order, &hlen) + if hlen%8 != 0 { + hlen += 8 - (hlen % 8) + } + + // decode headers and look for unix fds + headerdata := make([]byte, hlen+4) + copy(headerdata, csheader[12:]) + if _, err := io.ReadFull(t, headerdata[4:]); err != nil { + return nil, err + } + dec := newDecoder(bytes.NewBuffer(headerdata), order) + dec.pos = 12 + vs, err := dec.Decode(Signature{"a(yv)"}) + if err != nil { + return nil, err + } + Store(vs, &headers) + for _, v := range headers { + if v.Field == byte(FieldUnixFDs) { + unixfds, _ = v.Variant.value.(uint32) + } + } + all := make([]byte, 16+hlen+blen) + copy(all, csheader[:]) + copy(all[16:], headerdata[4:]) + if _, err := io.ReadFull(rd, all[16+hlen:]); err != nil { + return nil, err + } + if unixfds != 0 { + if !t.hasUnixFDs { + return nil, errors.New("dbus: got unix fds on unsupported transport") + } + // read the fds from the OOB data + scms, err := syscall.ParseSocketControlMessage(rd.oob) + if err != nil { + return nil, err + } + if len(scms) != 1 { + return nil, errors.New("dbus: received more than one socket control message") + } + fds, err := syscall.ParseUnixRights(&scms[0]) + if err != nil { + return nil, err + } + msg, err := DecodeMessage(bytes.NewBuffer(all)) + if err != nil { + return nil, err + } + // substitute the values in the message body (which are indices for the + // array receiver via OOB) with the actual values + for i, v := range msg.Body { + if j, ok := v.(UnixFDIndex); ok { + if uint32(j) >= unixfds { + return nil, InvalidMessageError("invalid index for unix fd") + } + msg.Body[i] = UnixFD(fds[j]) + } + } + return msg, nil + } + return DecodeMessage(bytes.NewBuffer(all)) +} + +func (t *unixTransport) SendMessage(msg *Message) error { + fds := make([]int, 0) + for i, v := range msg.Body { + if fd, ok := v.(UnixFD); ok { + msg.Body[i] = UnixFDIndex(len(fds)) + fds = append(fds, int(fd)) + } + } + if len(fds) != 0 { + if !t.hasUnixFDs { + return errors.New("dbus: unix fd passing not enabled") + } + msg.Headers[FieldUnixFDs] = MakeVariant(uint32(len(fds))) + oob := syscall.UnixRights(fds...) + buf := new(bytes.Buffer) + msg.EncodeTo(buf, binary.LittleEndian) + n, oobn, err := t.UnixConn.WriteMsgUnix(buf.Bytes(), oob, nil) + if err != nil { + return err + } + if n != buf.Len() || oobn != len(oob) { + return io.ErrShortWrite + } + } else { + if err := msg.EncodeTo(t, binary.LittleEndian); err != nil { + return nil + } + } + return nil +} + +func (t *unixTransport) SupportsUnixFDs() bool { + return true +} diff --git a/vendor/github.com/godbus/dbus/transport_unixcred_dragonfly.go b/vendor/github.com/godbus/dbus/transport_unixcred_dragonfly.go new file mode 100644 index 0000000000..a8cd39395f --- /dev/null +++ b/vendor/github.com/godbus/dbus/transport_unixcred_dragonfly.go @@ -0,0 +1,95 @@ +// The UnixCredentials system call is currently only implemented on Linux +// http://golang.org/src/pkg/syscall/sockcmsg_linux.go +// https://golang.org/s/go1.4-syscall +// http://code.google.com/p/go/source/browse/unix/sockcmsg_linux.go?repo=sys + +// Local implementation of the UnixCredentials system call for DragonFly BSD + +package dbus + +/* +#include +*/ +import "C" + +import ( + "io" + "os" + "syscall" + "unsafe" +) + +// http://golang.org/src/pkg/syscall/ztypes_linux_amd64.go +// http://golang.org/src/pkg/syscall/ztypes_dragonfly_amd64.go +type Ucred struct { + Pid int32 + Uid uint32 + Gid uint32 +} + +// http://golang.org/src/pkg/syscall/types_linux.go +// http://golang.org/src/pkg/syscall/types_dragonfly.go +// https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/sys/sys/ucred.h +const ( + SizeofUcred = C.sizeof_struct_ucred +) + +// http://golang.org/src/pkg/syscall/sockcmsg_unix.go +func cmsgAlignOf(salen int) int { + // From http://golang.org/src/pkg/syscall/sockcmsg_unix.go + //salign := sizeofPtr + // NOTE: It seems like 64-bit Darwin and DragonFly BSD kernels + // still require 32-bit aligned access to network subsystem. + //if darwin64Bit || dragonfly64Bit { + // salign = 4 + //} + salign := 4 + return (salen + salign - 1) & ^(salign - 1) +} + +// http://golang.org/src/pkg/syscall/sockcmsg_unix.go +func cmsgData(h *syscall.Cmsghdr) unsafe.Pointer { + return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(cmsgAlignOf(syscall.SizeofCmsghdr))) +} + +// http://golang.org/src/pkg/syscall/sockcmsg_linux.go +// 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, syscall.CmsgSpace(SizeofUcred)) + h := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) + h.Level = syscall.SOL_SOCKET + h.Type = syscall.SCM_CREDS + h.SetLen(syscall.CmsgLen(SizeofUcred)) + *((*Ucred)(cmsgData(h))) = *ucred + return b +} + +// http://golang.org/src/pkg/syscall/sockcmsg_linux.go +// 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 *syscall.SocketControlMessage) (*Ucred, error) { + if m.Header.Level != syscall.SOL_SOCKET { + return nil, syscall.EINVAL + } + if m.Header.Type != syscall.SCM_CREDS { + return nil, syscall.EINVAL + } + ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0])) + return &ucred, nil +} + +func (t *unixTransport) SendNullByte() error { + ucred := &Ucred{Pid: int32(os.Getpid()), Uid: uint32(os.Getuid()), Gid: uint32(os.Getgid())} + b := UnixCredentials(ucred) + _, oobn, err := t.UnixConn.WriteMsgUnix([]byte{0}, b, nil) + if err != nil { + return err + } + if oobn != len(b) { + return io.ErrShortWrite + } + return nil +} diff --git a/vendor/github.com/godbus/dbus/transport_unixcred_linux.go b/vendor/github.com/godbus/dbus/transport_unixcred_linux.go new file mode 100644 index 0000000000..d9dfdf6982 --- /dev/null +++ b/vendor/github.com/godbus/dbus/transport_unixcred_linux.go @@ -0,0 +1,25 @@ +// The UnixCredentials system call is currently only implemented on Linux +// http://golang.org/src/pkg/syscall/sockcmsg_linux.go +// https://golang.org/s/go1.4-syscall +// http://code.google.com/p/go/source/browse/unix/sockcmsg_linux.go?repo=sys + +package dbus + +import ( + "io" + "os" + "syscall" +) + +func (t *unixTransport) SendNullByte() error { + ucred := &syscall.Ucred{Pid: int32(os.Getpid()), Uid: uint32(os.Getuid()), Gid: uint32(os.Getgid())} + b := syscall.UnixCredentials(ucred) + _, oobn, err := t.UnixConn.WriteMsgUnix([]byte{0}, b, nil) + if err != nil { + return err + } + if oobn != len(b) { + return io.ErrShortWrite + } + return nil +} diff --git a/vendor/github.com/godbus/dbus/variant.go b/vendor/github.com/godbus/dbus/variant.go new file mode 100644 index 0000000000..b7b13ae90d --- /dev/null +++ b/vendor/github.com/godbus/dbus/variant.go @@ -0,0 +1,139 @@ +package dbus + +import ( + "bytes" + "fmt" + "reflect" + "sort" + "strconv" +) + +// Variant represents the D-Bus variant type. +type Variant struct { + sig Signature + value interface{} +} + +// MakeVariant converts the given value to a Variant. It panics if v cannot be +// represented as a D-Bus type. +func MakeVariant(v interface{}) Variant { + return Variant{SignatureOf(v), v} +} + +// ParseVariant parses the given string as a variant as described at +// https://developer.gnome.org/glib/unstable/gvariant-text.html. If sig is not +// empty, it is taken to be the expected signature for the variant. +func ParseVariant(s string, sig Signature) (Variant, error) { + tokens := varLex(s) + p := &varParser{tokens: tokens} + n, err := varMakeNode(p) + if err != nil { + return Variant{}, err + } + if sig.str == "" { + sig, err = varInfer(n) + if err != nil { + return Variant{}, err + } + } + v, err := n.Value(sig) + if err != nil { + return Variant{}, err + } + return MakeVariant(v), nil +} + +// format returns a formatted version of v and whether this string can be parsed +// unambigously. +func (v Variant) format() (string, bool) { + switch v.sig.str[0] { + case 'b', 'i': + return fmt.Sprint(v.value), true + case 'n', 'q', 'u', 'x', 't', 'd', 'h': + return fmt.Sprint(v.value), false + case 's': + return strconv.Quote(v.value.(string)), true + case 'o': + return strconv.Quote(string(v.value.(ObjectPath))), false + case 'g': + return strconv.Quote(v.value.(Signature).str), false + case 'v': + s, unamb := v.value.(Variant).format() + if !unamb { + return "<@" + v.value.(Variant).sig.str + " " + s + ">", true + } + return "<" + s + ">", true + case 'y': + return fmt.Sprintf("%#x", v.value.(byte)), false + } + rv := reflect.ValueOf(v.value) + switch rv.Kind() { + case reflect.Slice: + if rv.Len() == 0 { + return "[]", false + } + unamb := true + buf := bytes.NewBuffer([]byte("[")) + for i := 0; i < rv.Len(); i++ { + // TODO: slooow + s, b := MakeVariant(rv.Index(i).Interface()).format() + unamb = unamb && b + buf.WriteString(s) + if i != rv.Len()-1 { + buf.WriteString(", ") + } + } + buf.WriteByte(']') + return buf.String(), unamb + case reflect.Map: + if rv.Len() == 0 { + return "{}", false + } + unamb := true + var buf bytes.Buffer + kvs := make([]string, rv.Len()) + for i, k := range rv.MapKeys() { + s, b := MakeVariant(k.Interface()).format() + unamb = unamb && b + buf.Reset() + buf.WriteString(s) + buf.WriteString(": ") + s, b = MakeVariant(rv.MapIndex(k).Interface()).format() + unamb = unamb && b + buf.WriteString(s) + kvs[i] = buf.String() + } + buf.Reset() + buf.WriteByte('{') + sort.Strings(kvs) + for i, kv := range kvs { + if i > 0 { + buf.WriteString(", ") + } + buf.WriteString(kv) + } + buf.WriteByte('}') + return buf.String(), unamb + } + return `"INVALID"`, true +} + +// Signature returns the D-Bus signature of the underlying value of v. +func (v Variant) Signature() Signature { + return v.sig +} + +// String returns the string representation of the underlying value of v as +// described at https://developer.gnome.org/glib/unstable/gvariant-text.html. +func (v Variant) String() string { + s, unamb := v.format() + if !unamb { + return "@" + v.sig.str + " " + s + } + return s +} + +// Value returns the underlying value of v. +func (v Variant) Value() interface{} { + return v.value +} diff --git a/vendor/github.com/godbus/dbus/variant_lexer.go b/vendor/github.com/godbus/dbus/variant_lexer.go new file mode 100644 index 0000000000..332007d6f1 --- /dev/null +++ b/vendor/github.com/godbus/dbus/variant_lexer.go @@ -0,0 +1,284 @@ +package dbus + +import ( + "fmt" + "strings" + "unicode" + "unicode/utf8" +) + +// Heavily inspired by the lexer from text/template. + +type varToken struct { + typ varTokenType + val string +} + +type varTokenType byte + +const ( + tokEOF varTokenType = iota + tokError + tokNumber + tokString + tokBool + tokArrayStart + tokArrayEnd + tokDictStart + tokDictEnd + tokVariantStart + tokVariantEnd + tokComma + tokColon + tokType + tokByteString +) + +type varLexer struct { + input string + start int + pos int + width int + tokens []varToken +} + +type lexState func(*varLexer) lexState + +func varLex(s string) []varToken { + l := &varLexer{input: s} + l.run() + return l.tokens +} + +func (l *varLexer) accept(valid string) bool { + if strings.IndexRune(valid, l.next()) >= 0 { + return true + } + l.backup() + return false +} + +func (l *varLexer) backup() { + l.pos -= l.width +} + +func (l *varLexer) emit(t varTokenType) { + l.tokens = append(l.tokens, varToken{t, l.input[l.start:l.pos]}) + l.start = l.pos +} + +func (l *varLexer) errorf(format string, v ...interface{}) lexState { + l.tokens = append(l.tokens, varToken{ + tokError, + fmt.Sprintf(format, v...), + }) + return nil +} + +func (l *varLexer) ignore() { + l.start = l.pos +} + +func (l *varLexer) next() rune { + var r rune + + if l.pos >= len(l.input) { + l.width = 0 + return -1 + } + r, l.width = utf8.DecodeRuneInString(l.input[l.pos:]) + l.pos += l.width + return r +} + +func (l *varLexer) run() { + for state := varLexNormal; state != nil; { + state = state(l) + } +} + +func (l *varLexer) peek() rune { + r := l.next() + l.backup() + return r +} + +func varLexNormal(l *varLexer) lexState { + for { + r := l.next() + switch { + case r == -1: + l.emit(tokEOF) + return nil + case r == '[': + l.emit(tokArrayStart) + case r == ']': + l.emit(tokArrayEnd) + case r == '{': + l.emit(tokDictStart) + case r == '}': + l.emit(tokDictEnd) + case r == '<': + l.emit(tokVariantStart) + case r == '>': + l.emit(tokVariantEnd) + case r == ':': + l.emit(tokColon) + case r == ',': + l.emit(tokComma) + case r == '\'' || r == '"': + l.backup() + return varLexString + case r == '@': + l.backup() + return varLexType + case unicode.IsSpace(r): + l.ignore() + case unicode.IsNumber(r) || r == '+' || r == '-': + l.backup() + return varLexNumber + case r == 'b': + pos := l.start + if n := l.peek(); n == '"' || n == '\'' { + return varLexByteString + } + // not a byte string; try to parse it as a type or bool below + l.pos = pos + 1 + l.width = 1 + fallthrough + default: + // either a bool or a type. Try bools first. + l.backup() + if l.pos+4 <= len(l.input) { + if l.input[l.pos:l.pos+4] == "true" { + l.pos += 4 + l.emit(tokBool) + continue + } + } + if l.pos+5 <= len(l.input) { + if l.input[l.pos:l.pos+5] == "false" { + l.pos += 5 + l.emit(tokBool) + continue + } + } + // must be a type. + return varLexType + } + } +} + +var varTypeMap = map[string]string{ + "boolean": "b", + "byte": "y", + "int16": "n", + "uint16": "q", + "int32": "i", + "uint32": "u", + "int64": "x", + "uint64": "t", + "double": "f", + "string": "s", + "objectpath": "o", + "signature": "g", +} + +func varLexByteString(l *varLexer) lexState { + q := l.next() +Loop: + for { + switch l.next() { + case '\\': + if r := l.next(); r != -1 { + break + } + fallthrough + case -1: + return l.errorf("unterminated bytestring") + case q: + break Loop + } + } + l.emit(tokByteString) + return varLexNormal +} + +func varLexNumber(l *varLexer) lexState { + l.accept("+-") + digits := "0123456789" + if l.accept("0") { + if l.accept("x") { + digits = "0123456789abcdefABCDEF" + } else { + digits = "01234567" + } + } + for strings.IndexRune(digits, l.next()) >= 0 { + } + l.backup() + if l.accept(".") { + for strings.IndexRune(digits, l.next()) >= 0 { + } + l.backup() + } + if l.accept("eE") { + l.accept("+-") + for strings.IndexRune("0123456789", l.next()) >= 0 { + } + l.backup() + } + if r := l.peek(); unicode.IsLetter(r) { + l.next() + return l.errorf("bad number syntax: %q", l.input[l.start:l.pos]) + } + l.emit(tokNumber) + return varLexNormal +} + +func varLexString(l *varLexer) lexState { + q := l.next() +Loop: + for { + switch l.next() { + case '\\': + if r := l.next(); r != -1 { + break + } + fallthrough + case -1: + return l.errorf("unterminated string") + case q: + break Loop + } + } + l.emit(tokString) + return varLexNormal +} + +func varLexType(l *varLexer) lexState { + at := l.accept("@") + for { + r := l.next() + if r == -1 { + break + } + if unicode.IsSpace(r) { + l.backup() + break + } + } + if at { + if _, err := ParseSignature(l.input[l.start+1 : l.pos]); err != nil { + return l.errorf("%s", err) + } + } else { + if _, ok := varTypeMap[l.input[l.start:l.pos]]; ok { + l.emit(tokType) + return varLexNormal + } + return l.errorf("unrecognized type %q", l.input[l.start:l.pos]) + } + l.emit(tokType) + return varLexNormal +} diff --git a/vendor/github.com/godbus/dbus/variant_parser.go b/vendor/github.com/godbus/dbus/variant_parser.go new file mode 100644 index 0000000000..d20f5da6dd --- /dev/null +++ b/vendor/github.com/godbus/dbus/variant_parser.go @@ -0,0 +1,817 @@ +package dbus + +import ( + "bytes" + "errors" + "fmt" + "io" + "reflect" + "strconv" + "strings" + "unicode/utf8" +) + +type varParser struct { + tokens []varToken + i int +} + +func (p *varParser) backup() { + p.i-- +} + +func (p *varParser) next() varToken { + if p.i < len(p.tokens) { + t := p.tokens[p.i] + p.i++ + return t + } + return varToken{typ: tokEOF} +} + +type varNode interface { + Infer() (Signature, error) + String() string + Sigs() sigSet + Value(Signature) (interface{}, error) +} + +func varMakeNode(p *varParser) (varNode, error) { + var sig Signature + + for { + t := p.next() + switch t.typ { + case tokEOF: + return nil, io.ErrUnexpectedEOF + case tokError: + return nil, errors.New(t.val) + case tokNumber: + return varMakeNumNode(t, sig) + case tokString: + return varMakeStringNode(t, sig) + case tokBool: + if sig.str != "" && sig.str != "b" { + return nil, varTypeError{t.val, sig} + } + b, err := strconv.ParseBool(t.val) + if err != nil { + return nil, err + } + return boolNode(b), nil + case tokArrayStart: + return varMakeArrayNode(p, sig) + case tokVariantStart: + return varMakeVariantNode(p, sig) + case tokDictStart: + return varMakeDictNode(p, sig) + case tokType: + if sig.str != "" { + return nil, errors.New("unexpected type annotation") + } + if t.val[0] == '@' { + sig.str = t.val[1:] + } else { + sig.str = varTypeMap[t.val] + } + case tokByteString: + if sig.str != "" && sig.str != "ay" { + return nil, varTypeError{t.val, sig} + } + b, err := varParseByteString(t.val) + if err != nil { + return nil, err + } + return byteStringNode(b), nil + default: + return nil, fmt.Errorf("unexpected %q", t.val) + } + } +} + +type varTypeError struct { + val string + sig Signature +} + +func (e varTypeError) Error() string { + return fmt.Sprintf("dbus: can't parse %q as type %q", e.val, e.sig.str) +} + +type sigSet map[Signature]bool + +func (s sigSet) Empty() bool { + return len(s) == 0 +} + +func (s sigSet) Intersect(s2 sigSet) sigSet { + r := make(sigSet) + for k := range s { + if s2[k] { + r[k] = true + } + } + return r +} + +func (s sigSet) Single() (Signature, bool) { + if len(s) == 1 { + for k := range s { + return k, true + } + } + return Signature{}, false +} + +func (s sigSet) ToArray() sigSet { + r := make(sigSet, len(s)) + for k := range s { + r[Signature{"a" + k.str}] = true + } + return r +} + +type numNode struct { + sig Signature + str string + val interface{} +} + +var numSigSet = sigSet{ + Signature{"y"}: true, + Signature{"n"}: true, + Signature{"q"}: true, + Signature{"i"}: true, + Signature{"u"}: true, + Signature{"x"}: true, + Signature{"t"}: true, + Signature{"d"}: true, +} + +func (n numNode) Infer() (Signature, error) { + if strings.ContainsAny(n.str, ".e") { + return Signature{"d"}, nil + } + return Signature{"i"}, nil +} + +func (n numNode) String() string { + return n.str +} + +func (n numNode) Sigs() sigSet { + if n.sig.str != "" { + return sigSet{n.sig: true} + } + if strings.ContainsAny(n.str, ".e") { + return sigSet{Signature{"d"}: true} + } + return numSigSet +} + +func (n numNode) Value(sig Signature) (interface{}, error) { + if n.sig.str != "" && n.sig != sig { + return nil, varTypeError{n.str, sig} + } + if n.val != nil { + return n.val, nil + } + return varNumAs(n.str, sig) +} + +func varMakeNumNode(tok varToken, sig Signature) (varNode, error) { + if sig.str == "" { + return numNode{str: tok.val}, nil + } + num, err := varNumAs(tok.val, sig) + if err != nil { + return nil, err + } + return numNode{sig: sig, val: num}, nil +} + +func varNumAs(s string, sig Signature) (interface{}, error) { + isUnsigned := false + size := 32 + switch sig.str { + case "n": + size = 16 + case "i": + case "x": + size = 64 + case "y": + size = 8 + isUnsigned = true + case "q": + size = 16 + isUnsigned = true + case "u": + isUnsigned = true + case "t": + size = 64 + isUnsigned = true + case "d": + d, err := strconv.ParseFloat(s, 64) + if err != nil { + return nil, err + } + return d, nil + default: + return nil, varTypeError{s, sig} + } + base := 10 + if strings.HasPrefix(s, "0x") { + base = 16 + s = s[2:] + } + if strings.HasPrefix(s, "0") && len(s) != 1 { + base = 8 + s = s[1:] + } + if isUnsigned { + i, err := strconv.ParseUint(s, base, size) + if err != nil { + return nil, err + } + var v interface{} = i + switch sig.str { + case "y": + v = byte(i) + case "q": + v = uint16(i) + case "u": + v = uint32(i) + } + return v, nil + } + i, err := strconv.ParseInt(s, base, size) + if err != nil { + return nil, err + } + var v interface{} = i + switch sig.str { + case "n": + v = int16(i) + case "i": + v = int32(i) + } + return v, nil +} + +type stringNode struct { + sig Signature + str string // parsed + val interface{} // has correct type +} + +var stringSigSet = sigSet{ + Signature{"s"}: true, + Signature{"g"}: true, + Signature{"o"}: true, +} + +func (n stringNode) Infer() (Signature, error) { + return Signature{"s"}, nil +} + +func (n stringNode) String() string { + return n.str +} + +func (n stringNode) Sigs() sigSet { + if n.sig.str != "" { + return sigSet{n.sig: true} + } + return stringSigSet +} + +func (n stringNode) Value(sig Signature) (interface{}, error) { + if n.sig.str != "" && n.sig != sig { + return nil, varTypeError{n.str, sig} + } + if n.val != nil { + return n.val, nil + } + switch { + case sig.str == "g": + return Signature{n.str}, nil + case sig.str == "o": + return ObjectPath(n.str), nil + case sig.str == "s": + return n.str, nil + default: + return nil, varTypeError{n.str, sig} + } +} + +func varMakeStringNode(tok varToken, sig Signature) (varNode, error) { + if sig.str != "" && sig.str != "s" && sig.str != "g" && sig.str != "o" { + return nil, fmt.Errorf("invalid type %q for string", sig.str) + } + s, err := varParseString(tok.val) + if err != nil { + return nil, err + } + n := stringNode{str: s} + if sig.str == "" { + return stringNode{str: s}, nil + } + n.sig = sig + switch sig.str { + case "o": + n.val = ObjectPath(s) + case "g": + n.val = Signature{s} + case "s": + n.val = s + } + return n, nil +} + +func varParseString(s string) (string, error) { + // quotes are guaranteed to be there + s = s[1 : len(s)-1] + buf := new(bytes.Buffer) + for len(s) != 0 { + r, size := utf8.DecodeRuneInString(s) + if r == utf8.RuneError && size == 1 { + return "", errors.New("invalid UTF-8") + } + s = s[size:] + if r != '\\' { + buf.WriteRune(r) + continue + } + r, size = utf8.DecodeRuneInString(s) + if r == utf8.RuneError && size == 1 { + return "", errors.New("invalid UTF-8") + } + s = s[size:] + switch r { + case 'a': + buf.WriteRune(0x7) + case 'b': + buf.WriteRune(0x8) + case 'f': + buf.WriteRune(0xc) + case 'n': + buf.WriteRune('\n') + case 'r': + buf.WriteRune('\r') + case 't': + buf.WriteRune('\t') + case '\n': + case 'u': + if len(s) < 4 { + return "", errors.New("short unicode escape") + } + r, err := strconv.ParseUint(s[:4], 16, 32) + if err != nil { + return "", err + } + buf.WriteRune(rune(r)) + s = s[4:] + case 'U': + if len(s) < 8 { + return "", errors.New("short unicode escape") + } + r, err := strconv.ParseUint(s[:8], 16, 32) + if err != nil { + return "", err + } + buf.WriteRune(rune(r)) + s = s[8:] + default: + buf.WriteRune(r) + } + } + return buf.String(), nil +} + +var boolSigSet = sigSet{Signature{"b"}: true} + +type boolNode bool + +func (boolNode) Infer() (Signature, error) { + return Signature{"b"}, nil +} + +func (b boolNode) String() string { + if b { + return "true" + } + return "false" +} + +func (boolNode) Sigs() sigSet { + return boolSigSet +} + +func (b boolNode) Value(sig Signature) (interface{}, error) { + if sig.str != "b" { + return nil, varTypeError{b.String(), sig} + } + return bool(b), nil +} + +type arrayNode struct { + set sigSet + children []varNode + val interface{} +} + +func (n arrayNode) Infer() (Signature, error) { + for _, v := range n.children { + csig, err := varInfer(v) + if err != nil { + continue + } + return Signature{"a" + csig.str}, nil + } + return Signature{}, fmt.Errorf("can't infer type for %q", n.String()) +} + +func (n arrayNode) String() string { + s := "[" + for i, v := range n.children { + s += v.String() + if i != len(n.children)-1 { + s += ", " + } + } + return s + "]" +} + +func (n arrayNode) Sigs() sigSet { + return n.set +} + +func (n arrayNode) Value(sig Signature) (interface{}, error) { + if n.set.Empty() { + // no type information whatsoever, so this must be an empty slice + return reflect.MakeSlice(typeFor(sig.str), 0, 0).Interface(), nil + } + if !n.set[sig] { + return nil, varTypeError{n.String(), sig} + } + s := reflect.MakeSlice(typeFor(sig.str), len(n.children), len(n.children)) + for i, v := range n.children { + rv, err := v.Value(Signature{sig.str[1:]}) + if err != nil { + return nil, err + } + s.Index(i).Set(reflect.ValueOf(rv)) + } + return s.Interface(), nil +} + +func varMakeArrayNode(p *varParser, sig Signature) (varNode, error) { + var n arrayNode + if sig.str != "" { + n.set = sigSet{sig: true} + } + if t := p.next(); t.typ == tokArrayEnd { + return n, nil + } else { + p.backup() + } +Loop: + for { + t := p.next() + switch t.typ { + case tokEOF: + return nil, io.ErrUnexpectedEOF + case tokError: + return nil, errors.New(t.val) + } + p.backup() + cn, err := varMakeNode(p) + if err != nil { + return nil, err + } + if cset := cn.Sigs(); !cset.Empty() { + if n.set.Empty() { + n.set = cset.ToArray() + } else { + nset := cset.ToArray().Intersect(n.set) + if nset.Empty() { + return nil, fmt.Errorf("can't parse %q with given type information", cn.String()) + } + n.set = nset + } + } + n.children = append(n.children, cn) + switch t := p.next(); t.typ { + case tokEOF: + return nil, io.ErrUnexpectedEOF + case tokError: + return nil, errors.New(t.val) + case tokArrayEnd: + break Loop + case tokComma: + continue + default: + return nil, fmt.Errorf("unexpected %q", t.val) + } + } + return n, nil +} + +type variantNode struct { + n varNode +} + +var variantSet = sigSet{ + Signature{"v"}: true, +} + +func (variantNode) Infer() (Signature, error) { + return Signature{"v"}, nil +} + +func (n variantNode) String() string { + return "<" + n.n.String() + ">" +} + +func (variantNode) Sigs() sigSet { + return variantSet +} + +func (n variantNode) Value(sig Signature) (interface{}, error) { + if sig.str != "v" { + return nil, varTypeError{n.String(), sig} + } + sig, err := varInfer(n.n) + if err != nil { + return nil, err + } + v, err := n.n.Value(sig) + if err != nil { + return nil, err + } + return MakeVariant(v), nil +} + +func varMakeVariantNode(p *varParser, sig Signature) (varNode, error) { + n, err := varMakeNode(p) + if err != nil { + return nil, err + } + if t := p.next(); t.typ != tokVariantEnd { + return nil, fmt.Errorf("unexpected %q", t.val) + } + vn := variantNode{n} + if sig.str != "" && sig.str != "v" { + return nil, varTypeError{vn.String(), sig} + } + return variantNode{n}, nil +} + +type dictEntry struct { + key, val varNode +} + +type dictNode struct { + kset, vset sigSet + children []dictEntry + val interface{} +} + +func (n dictNode) Infer() (Signature, error) { + for _, v := range n.children { + ksig, err := varInfer(v.key) + if err != nil { + continue + } + vsig, err := varInfer(v.val) + if err != nil { + continue + } + return Signature{"a{" + ksig.str + vsig.str + "}"}, nil + } + return Signature{}, fmt.Errorf("can't infer type for %q", n.String()) +} + +func (n dictNode) String() string { + s := "{" + for i, v := range n.children { + s += v.key.String() + ": " + v.val.String() + if i != len(n.children)-1 { + s += ", " + } + } + return s + "}" +} + +func (n dictNode) Sigs() sigSet { + r := sigSet{} + for k := range n.kset { + for v := range n.vset { + sig := "a{" + k.str + v.str + "}" + r[Signature{sig}] = true + } + } + return r +} + +func (n dictNode) Value(sig Signature) (interface{}, error) { + set := n.Sigs() + if set.Empty() { + // no type information -> empty dict + return reflect.MakeMap(typeFor(sig.str)).Interface(), nil + } + if !set[sig] { + return nil, varTypeError{n.String(), sig} + } + m := reflect.MakeMap(typeFor(sig.str)) + ksig := Signature{sig.str[2:3]} + vsig := Signature{sig.str[3 : len(sig.str)-1]} + for _, v := range n.children { + kv, err := v.key.Value(ksig) + if err != nil { + return nil, err + } + vv, err := v.val.Value(vsig) + if err != nil { + return nil, err + } + m.SetMapIndex(reflect.ValueOf(kv), reflect.ValueOf(vv)) + } + return m.Interface(), nil +} + +func varMakeDictNode(p *varParser, sig Signature) (varNode, error) { + var n dictNode + + if sig.str != "" { + if len(sig.str) < 5 { + return nil, fmt.Errorf("invalid signature %q for dict type", sig) + } + ksig := Signature{string(sig.str[2])} + vsig := Signature{sig.str[3 : len(sig.str)-1]} + n.kset = sigSet{ksig: true} + n.vset = sigSet{vsig: true} + } + if t := p.next(); t.typ == tokDictEnd { + return n, nil + } else { + p.backup() + } +Loop: + for { + t := p.next() + switch t.typ { + case tokEOF: + return nil, io.ErrUnexpectedEOF + case tokError: + return nil, errors.New(t.val) + } + p.backup() + kn, err := varMakeNode(p) + if err != nil { + return nil, err + } + if kset := kn.Sigs(); !kset.Empty() { + if n.kset.Empty() { + n.kset = kset + } else { + n.kset = kset.Intersect(n.kset) + if n.kset.Empty() { + return nil, fmt.Errorf("can't parse %q with given type information", kn.String()) + } + } + } + t = p.next() + switch t.typ { + case tokEOF: + return nil, io.ErrUnexpectedEOF + case tokError: + return nil, errors.New(t.val) + case tokColon: + default: + return nil, fmt.Errorf("unexpected %q", t.val) + } + t = p.next() + switch t.typ { + case tokEOF: + return nil, io.ErrUnexpectedEOF + case tokError: + return nil, errors.New(t.val) + } + p.backup() + vn, err := varMakeNode(p) + if err != nil { + return nil, err + } + if vset := vn.Sigs(); !vset.Empty() { + if n.vset.Empty() { + n.vset = vset + } else { + n.vset = n.vset.Intersect(vset) + if n.vset.Empty() { + return nil, fmt.Errorf("can't parse %q with given type information", vn.String()) + } + } + } + n.children = append(n.children, dictEntry{kn, vn}) + t = p.next() + switch t.typ { + case tokEOF: + return nil, io.ErrUnexpectedEOF + case tokError: + return nil, errors.New(t.val) + case tokDictEnd: + break Loop + case tokComma: + continue + default: + return nil, fmt.Errorf("unexpected %q", t.val) + } + } + return n, nil +} + +type byteStringNode []byte + +var byteStringSet = sigSet{ + Signature{"ay"}: true, +} + +func (byteStringNode) Infer() (Signature, error) { + return Signature{"ay"}, nil +} + +func (b byteStringNode) String() string { + return string(b) +} + +func (b byteStringNode) Sigs() sigSet { + return byteStringSet +} + +func (b byteStringNode) Value(sig Signature) (interface{}, error) { + if sig.str != "ay" { + return nil, varTypeError{b.String(), sig} + } + return []byte(b), nil +} + +func varParseByteString(s string) ([]byte, error) { + // quotes and b at start are guaranteed to be there + b := make([]byte, 0, 1) + s = s[2 : len(s)-1] + for len(s) != 0 { + c := s[0] + s = s[1:] + if c != '\\' { + b = append(b, c) + continue + } + c = s[0] + s = s[1:] + switch c { + case 'a': + b = append(b, 0x7) + case 'b': + b = append(b, 0x8) + case 'f': + b = append(b, 0xc) + case 'n': + b = append(b, '\n') + case 'r': + b = append(b, '\r') + case 't': + b = append(b, '\t') + case 'x': + if len(s) < 2 { + return nil, errors.New("short escape") + } + n, err := strconv.ParseUint(s[:2], 16, 8) + if err != nil { + return nil, err + } + b = append(b, byte(n)) + s = s[2:] + case '0': + if len(s) < 3 { + return nil, errors.New("short escape") + } + n, err := strconv.ParseUint(s[:3], 8, 8) + if err != nil { + return nil, err + } + b = append(b, byte(n)) + s = s[3:] + default: + b = append(b, c) + } + } + return append(b, 0), nil +} + +func varInfer(n varNode) (Signature, error) { + if sig, ok := n.Sigs().Single(); ok { + return sig, nil + } + return n.Infer() +} diff --git a/vendor/github.com/gogo/protobuf/LICENSE b/vendor/github.com/gogo/protobuf/LICENSE new file mode 100644 index 0000000000..335e38e19b --- /dev/null +++ b/vendor/github.com/gogo/protobuf/LICENSE @@ -0,0 +1,36 @@ +Extensions for Protocol Buffers to create more go like structures. + +Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. +http://github.com/gogo/protobuf/gogoproto + +Go support for Protocol Buffers - Google's data interchange format + +Copyright 2010 The Go Authors. All rights reserved. +https://github.com/golang/protobuf + +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. + diff --git a/vendor/github.com/gogo/protobuf/proto/clone.go b/vendor/github.com/gogo/protobuf/proto/clone.go new file mode 100644 index 0000000000..79edb86119 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/clone.go @@ -0,0 +1,228 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2011 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +// Protocol buffer deep copy and merge. +// TODO: RawMessage. + +package proto + +import ( + "log" + "reflect" + "strings" +) + +// Clone returns a deep copy of a protocol buffer. +func Clone(pb Message) Message { + in := reflect.ValueOf(pb) + if in.IsNil() { + return pb + } + + out := reflect.New(in.Type().Elem()) + // out is empty so a merge is a deep copy. + mergeStruct(out.Elem(), in.Elem()) + return out.Interface().(Message) +} + +// Merge merges src into dst. +// Required and optional fields that are set in src will be set to that value in dst. +// Elements of repeated fields will be appended. +// Merge panics if src and dst are not the same type, or if dst is nil. +func Merge(dst, src Message) { + in := reflect.ValueOf(src) + out := reflect.ValueOf(dst) + if out.IsNil() { + panic("proto: nil destination") + } + if in.Type() != out.Type() { + // Explicit test prior to mergeStruct so that mistyped nils will fail + panic("proto: type mismatch") + } + if in.IsNil() { + // Merging nil into non-nil is a quiet no-op + return + } + mergeStruct(out.Elem(), in.Elem()) +} + +func mergeStruct(out, in reflect.Value) { + sprop := GetProperties(in.Type()) + for i := 0; i < in.NumField(); i++ { + f := in.Type().Field(i) + if strings.HasPrefix(f.Name, "XXX_") { + continue + } + mergeAny(out.Field(i), in.Field(i), false, sprop.Prop[i]) + } + + if emIn, ok := in.Addr().Interface().(extensionsMap); ok { + emOut := out.Addr().Interface().(extensionsMap) + mergeExtension(emOut.ExtensionMap(), emIn.ExtensionMap()) + } else if emIn, ok := in.Addr().Interface().(extensionsBytes); ok { + emOut := out.Addr().Interface().(extensionsBytes) + bIn := emIn.GetExtensions() + bOut := emOut.GetExtensions() + *bOut = append(*bOut, *bIn...) + } + + uf := in.FieldByName("XXX_unrecognized") + if !uf.IsValid() { + return + } + uin := uf.Bytes() + if len(uin) > 0 { + out.FieldByName("XXX_unrecognized").SetBytes(append([]byte(nil), uin...)) + } +} + +// mergeAny performs a merge between two values of the same type. +// viaPtr indicates whether the values were indirected through a pointer (implying proto2). +// prop is set if this is a struct field (it may be nil). +func mergeAny(out, in reflect.Value, viaPtr bool, prop *Properties) { + if in.Type() == protoMessageType { + if !in.IsNil() { + if out.IsNil() { + out.Set(reflect.ValueOf(Clone(in.Interface().(Message)))) + } else { + Merge(out.Interface().(Message), in.Interface().(Message)) + } + } + return + } + switch in.Kind() { + case reflect.Bool, reflect.Float32, reflect.Float64, reflect.Int32, reflect.Int64, + reflect.String, reflect.Uint32, reflect.Uint64: + if !viaPtr && isProto3Zero(in) { + return + } + out.Set(in) + case reflect.Interface: + // Probably a oneof field; copy non-nil values. + if in.IsNil() { + return + } + // Allocate destination if it is not set, or set to a different type. + // Otherwise we will merge as normal. + if out.IsNil() || out.Elem().Type() != in.Elem().Type() { + out.Set(reflect.New(in.Elem().Elem().Type())) // interface -> *T -> T -> new(T) + } + mergeAny(out.Elem(), in.Elem(), false, nil) + case reflect.Map: + if in.Len() == 0 { + return + } + if out.IsNil() { + out.Set(reflect.MakeMap(in.Type())) + } + // For maps with value types of *T or []byte we need to deep copy each value. + elemKind := in.Type().Elem().Kind() + for _, key := range in.MapKeys() { + var val reflect.Value + switch elemKind { + case reflect.Ptr: + val = reflect.New(in.Type().Elem().Elem()) + mergeAny(val, in.MapIndex(key), false, nil) + case reflect.Slice: + val = in.MapIndex(key) + val = reflect.ValueOf(append([]byte{}, val.Bytes()...)) + default: + val = in.MapIndex(key) + } + out.SetMapIndex(key, val) + } + case reflect.Ptr: + if in.IsNil() { + return + } + if out.IsNil() { + out.Set(reflect.New(in.Elem().Type())) + } + mergeAny(out.Elem(), in.Elem(), true, nil) + case reflect.Slice: + if in.IsNil() { + return + } + if in.Type().Elem().Kind() == reflect.Uint8 { + // []byte is a scalar bytes field, not a repeated field. + + // Edge case: if this is in a proto3 message, a zero length + // bytes field is considered the zero value, and should not + // be merged. + if prop != nil && prop.proto3 && in.Len() == 0 { + return + } + + // Make a deep copy. + // Append to []byte{} instead of []byte(nil) so that we never end up + // with a nil result. + out.SetBytes(append([]byte{}, in.Bytes()...)) + return + } + n := in.Len() + if out.IsNil() { + out.Set(reflect.MakeSlice(in.Type(), 0, n)) + } + switch in.Type().Elem().Kind() { + case reflect.Bool, reflect.Float32, reflect.Float64, reflect.Int32, reflect.Int64, + reflect.String, reflect.Uint32, reflect.Uint64: + out.Set(reflect.AppendSlice(out, in)) + default: + for i := 0; i < n; i++ { + x := reflect.Indirect(reflect.New(in.Type().Elem())) + mergeAny(x, in.Index(i), false, nil) + out.Set(reflect.Append(out, x)) + } + } + case reflect.Struct: + mergeStruct(out, in) + default: + // unknown type, so not a protocol buffer + log.Printf("proto: don't know how to copy %v", in) + } +} + +func mergeExtension(out, in map[int32]Extension) { + for extNum, eIn := range in { + eOut := Extension{desc: eIn.desc} + if eIn.value != nil { + v := reflect.New(reflect.TypeOf(eIn.value)).Elem() + mergeAny(v, reflect.ValueOf(eIn.value), false, nil) + eOut.value = v.Interface() + } + if eIn.enc != nil { + eOut.enc = make([]byte, len(eIn.enc)) + copy(eOut.enc, eIn.enc) + } + + out[extNum] = eOut + } +} diff --git a/vendor/github.com/gogo/protobuf/proto/decode.go b/vendor/github.com/gogo/protobuf/proto/decode.go new file mode 100644 index 0000000000..cb5b213f9b --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/decode.go @@ -0,0 +1,872 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +package proto + +/* + * Routines for decoding protocol buffer data to construct in-memory representations. + */ + +import ( + "errors" + "fmt" + "io" + "os" + "reflect" +) + +// errOverflow is returned when an integer is too large to be represented. +var errOverflow = errors.New("proto: integer overflow") + +// ErrInternalBadWireType is returned by generated code when an incorrect +// wire type is encountered. It does not get returned to user code. +var ErrInternalBadWireType = errors.New("proto: internal error: bad wiretype for oneof") + +// The fundamental decoders that interpret bytes on the wire. +// Those that take integer types all return uint64 and are +// therefore of type valueDecoder. + +// DecodeVarint reads a varint-encoded integer from the slice. +// It returns the integer and the number of bytes consumed, or +// zero if there is not enough. +// This is the format for the +// int32, int64, uint32, uint64, bool, and enum +// protocol buffer types. +func DecodeVarint(buf []byte) (x uint64, n int) { + // x, n already 0 + for shift := uint(0); shift < 64; shift += 7 { + if n >= len(buf) { + return 0, 0 + } + b := uint64(buf[n]) + n++ + x |= (b & 0x7F) << shift + if (b & 0x80) == 0 { + return x, n + } + } + + // The number is too large to represent in a 64-bit value. + return 0, 0 +} + +// DecodeVarint reads a varint-encoded integer from the Buffer. +// This is the format for the +// int32, int64, uint32, uint64, bool, and enum +// protocol buffer types. +func (p *Buffer) DecodeVarint() (x uint64, err error) { + // x, err already 0 + + i := p.index + l := len(p.buf) + + for shift := uint(0); shift < 64; shift += 7 { + if i >= l { + err = io.ErrUnexpectedEOF + return + } + b := p.buf[i] + i++ + x |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + p.index = i + return + } + } + + // The number is too large to represent in a 64-bit value. + err = errOverflow + return +} + +// DecodeFixed64 reads a 64-bit integer from the Buffer. +// This is the format for the +// fixed64, sfixed64, and double protocol buffer types. +func (p *Buffer) DecodeFixed64() (x uint64, err error) { + // x, err already 0 + i := p.index + 8 + if i < 0 || i > len(p.buf) { + err = io.ErrUnexpectedEOF + return + } + p.index = i + + x = uint64(p.buf[i-8]) + x |= uint64(p.buf[i-7]) << 8 + x |= uint64(p.buf[i-6]) << 16 + x |= uint64(p.buf[i-5]) << 24 + x |= uint64(p.buf[i-4]) << 32 + x |= uint64(p.buf[i-3]) << 40 + x |= uint64(p.buf[i-2]) << 48 + x |= uint64(p.buf[i-1]) << 56 + return +} + +// DecodeFixed32 reads a 32-bit integer from the Buffer. +// This is the format for the +// fixed32, sfixed32, and float protocol buffer types. +func (p *Buffer) DecodeFixed32() (x uint64, err error) { + // x, err already 0 + i := p.index + 4 + if i < 0 || i > len(p.buf) { + err = io.ErrUnexpectedEOF + return + } + p.index = i + + x = uint64(p.buf[i-4]) + x |= uint64(p.buf[i-3]) << 8 + x |= uint64(p.buf[i-2]) << 16 + x |= uint64(p.buf[i-1]) << 24 + return +} + +// DecodeZigzag64 reads a zigzag-encoded 64-bit integer +// from the Buffer. +// This is the format used for the sint64 protocol buffer type. +func (p *Buffer) DecodeZigzag64() (x uint64, err error) { + x, err = p.DecodeVarint() + if err != nil { + return + } + x = (x >> 1) ^ uint64((int64(x&1)<<63)>>63) + return +} + +// DecodeZigzag32 reads a zigzag-encoded 32-bit integer +// from the Buffer. +// This is the format used for the sint32 protocol buffer type. +func (p *Buffer) DecodeZigzag32() (x uint64, err error) { + x, err = p.DecodeVarint() + if err != nil { + return + } + x = uint64((uint32(x) >> 1) ^ uint32((int32(x&1)<<31)>>31)) + return +} + +// These are not ValueDecoders: they produce an array of bytes or a string. +// bytes, embedded messages + +// DecodeRawBytes reads a count-delimited byte buffer from the Buffer. +// This is the format used for the bytes protocol buffer +// type and for embedded messages. +func (p *Buffer) DecodeRawBytes(alloc bool) (buf []byte, err error) { + n, err := p.DecodeVarint() + if err != nil { + return nil, err + } + + nb := int(n) + if nb < 0 { + return nil, fmt.Errorf("proto: bad byte length %d", nb) + } + end := p.index + nb + if end < p.index || end > len(p.buf) { + return nil, io.ErrUnexpectedEOF + } + + if !alloc { + // todo: check if can get more uses of alloc=false + buf = p.buf[p.index:end] + p.index += nb + return + } + + buf = make([]byte, nb) + copy(buf, p.buf[p.index:]) + p.index += nb + return +} + +// DecodeStringBytes reads an encoded string from the Buffer. +// This is the format used for the proto2 string type. +func (p *Buffer) DecodeStringBytes() (s string, err error) { + buf, err := p.DecodeRawBytes(false) + if err != nil { + return + } + return string(buf), nil +} + +// Skip the next item in the buffer. Its wire type is decoded and presented as an argument. +// If the protocol buffer has extensions, and the field matches, add it as an extension. +// Otherwise, if the XXX_unrecognized field exists, append the skipped data there. +func (o *Buffer) skipAndSave(t reflect.Type, tag, wire int, base structPointer, unrecField field) error { + oi := o.index + + err := o.skip(t, tag, wire) + if err != nil { + return err + } + + if !unrecField.IsValid() { + return nil + } + + ptr := structPointer_Bytes(base, unrecField) + + // Add the skipped field to struct field + obuf := o.buf + + o.buf = *ptr + o.EncodeVarint(uint64(tag<<3 | wire)) + *ptr = append(o.buf, obuf[oi:o.index]...) + + o.buf = obuf + + return nil +} + +// Skip the next item in the buffer. Its wire type is decoded and presented as an argument. +func (o *Buffer) skip(t reflect.Type, tag, wire int) error { + + var u uint64 + var err error + + switch wire { + case WireVarint: + _, err = o.DecodeVarint() + case WireFixed64: + _, err = o.DecodeFixed64() + case WireBytes: + _, err = o.DecodeRawBytes(false) + case WireFixed32: + _, err = o.DecodeFixed32() + case WireStartGroup: + for { + u, err = o.DecodeVarint() + if err != nil { + break + } + fwire := int(u & 0x7) + if fwire == WireEndGroup { + break + } + ftag := int(u >> 3) + err = o.skip(t, ftag, fwire) + if err != nil { + break + } + } + default: + err = fmt.Errorf("proto: can't skip unknown wire type %d for %s", wire, t) + } + return err +} + +// Unmarshaler is the interface representing objects that can +// unmarshal themselves. The method should reset the receiver before +// decoding starts. The argument points to data that may be +// overwritten, so implementations should not keep references to the +// buffer. +type Unmarshaler interface { + Unmarshal([]byte) error +} + +// Unmarshal parses the protocol buffer representation in buf and places the +// decoded result in pb. If the struct underlying pb does not match +// the data in buf, the results can be unpredictable. +// +// Unmarshal resets pb before starting to unmarshal, so any +// existing data in pb is always removed. Use UnmarshalMerge +// to preserve and append to existing data. +func Unmarshal(buf []byte, pb Message) error { + pb.Reset() + return UnmarshalMerge(buf, pb) +} + +// UnmarshalMerge parses the protocol buffer representation in buf and +// writes the decoded result to pb. If the struct underlying pb does not match +// the data in buf, the results can be unpredictable. +// +// UnmarshalMerge merges into existing data in pb. +// Most code should use Unmarshal instead. +func UnmarshalMerge(buf []byte, pb Message) error { + // If the object can unmarshal itself, let it. + if u, ok := pb.(Unmarshaler); ok { + return u.Unmarshal(buf) + } + return NewBuffer(buf).Unmarshal(pb) +} + +// DecodeMessage reads a count-delimited message from the Buffer. +func (p *Buffer) DecodeMessage(pb Message) error { + enc, err := p.DecodeRawBytes(false) + if err != nil { + return err + } + return NewBuffer(enc).Unmarshal(pb) +} + +// DecodeGroup reads a tag-delimited group from the Buffer. +func (p *Buffer) DecodeGroup(pb Message) error { + typ, base, err := getbase(pb) + if err != nil { + return err + } + return p.unmarshalType(typ.Elem(), GetProperties(typ.Elem()), true, base) +} + +// Unmarshal parses the protocol buffer representation in the +// Buffer and places the decoded result in pb. If the struct +// underlying pb does not match the data in the buffer, the results can be +// unpredictable. +func (p *Buffer) Unmarshal(pb Message) error { + // If the object can unmarshal itself, let it. + if u, ok := pb.(Unmarshaler); ok { + err := u.Unmarshal(p.buf[p.index:]) + p.index = len(p.buf) + return err + } + + typ, base, err := getbase(pb) + if err != nil { + return err + } + + err = p.unmarshalType(typ.Elem(), GetProperties(typ.Elem()), false, base) + + if collectStats { + stats.Decode++ + } + + return err +} + +// unmarshalType does the work of unmarshaling a structure. +func (o *Buffer) unmarshalType(st reflect.Type, prop *StructProperties, is_group bool, base structPointer) error { + var state errorState + required, reqFields := prop.reqCount, uint64(0) + + var err error + for err == nil && o.index < len(o.buf) { + oi := o.index + var u uint64 + u, err = o.DecodeVarint() + if err != nil { + break + } + wire := int(u & 0x7) + if wire == WireEndGroup { + if is_group { + return nil // input is satisfied + } + return fmt.Errorf("proto: %s: wiretype end group for non-group", st) + } + tag := int(u >> 3) + if tag <= 0 { + return fmt.Errorf("proto: %s: illegal tag %d (wire type %d)", st, tag, wire) + } + fieldnum, ok := prop.decoderTags.get(tag) + if !ok { + // Maybe it's an extension? + if prop.extendable { + if e := structPointer_Interface(base, st).(extendableProto); isExtensionField(e, int32(tag)) { + if err = o.skip(st, tag, wire); err == nil { + if ee, eok := e.(extensionsMap); eok { + ext := ee.ExtensionMap()[int32(tag)] // may be missing + ext.enc = append(ext.enc, o.buf[oi:o.index]...) + ee.ExtensionMap()[int32(tag)] = ext + } else if ee, eok := e.(extensionsBytes); eok { + ext := ee.GetExtensions() + *ext = append(*ext, o.buf[oi:o.index]...) + } + } + continue + } + } + // Maybe it's a oneof? + if prop.oneofUnmarshaler != nil { + m := structPointer_Interface(base, st).(Message) + // First return value indicates whether tag is a oneof field. + ok, err = prop.oneofUnmarshaler(m, tag, wire, o) + if err == ErrInternalBadWireType { + // Map the error to something more descriptive. + // Do the formatting here to save generated code space. + err = fmt.Errorf("bad wiretype for oneof field in %T", m) + } + if ok { + continue + } + } + err = o.skipAndSave(st, tag, wire, base, prop.unrecField) + continue + } + p := prop.Prop[fieldnum] + + if p.dec == nil { + fmt.Fprintf(os.Stderr, "proto: no protobuf decoder for %s.%s\n", st, st.Field(fieldnum).Name) + continue + } + dec := p.dec + if wire != WireStartGroup && wire != p.WireType { + if wire == WireBytes && p.packedDec != nil { + // a packable field + dec = p.packedDec + } else { + err = fmt.Errorf("proto: bad wiretype for field %s.%s: got wiretype %d, want %d", st, st.Field(fieldnum).Name, wire, p.WireType) + continue + } + } + decErr := dec(o, p, base) + if decErr != nil && !state.shouldContinue(decErr, p) { + err = decErr + } + if err == nil && p.Required { + // Successfully decoded a required field. + if tag <= 64 { + // use bitmap for fields 1-64 to catch field reuse. + var mask uint64 = 1 << uint64(tag-1) + if reqFields&mask == 0 { + // new required field + reqFields |= mask + required-- + } + } else { + // This is imprecise. It can be fooled by a required field + // with a tag > 64 that is encoded twice; that's very rare. + // A fully correct implementation would require allocating + // a data structure, which we would like to avoid. + required-- + } + } + } + if err == nil { + if is_group { + return io.ErrUnexpectedEOF + } + if state.err != nil { + return state.err + } + if required > 0 { + // Not enough information to determine the exact field. If we use extra + // CPU, we could determine the field only if the missing required field + // has a tag <= 64 and we check reqFields. + return &RequiredNotSetError{"{Unknown}"} + } + } + return err +} + +// Individual type decoders +// For each, +// u is the decoded value, +// v is a pointer to the field (pointer) in the struct + +// Sizes of the pools to allocate inside the Buffer. +// The goal is modest amortization and allocation +// on at least 16-byte boundaries. +const ( + boolPoolSize = 16 + uint32PoolSize = 8 + uint64PoolSize = 4 +) + +// Decode a bool. +func (o *Buffer) dec_bool(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + if len(o.bools) == 0 { + o.bools = make([]bool, boolPoolSize) + } + o.bools[0] = u != 0 + *structPointer_Bool(base, p.field) = &o.bools[0] + o.bools = o.bools[1:] + return nil +} + +func (o *Buffer) dec_proto3_bool(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + *structPointer_BoolVal(base, p.field) = u != 0 + return nil +} + +// Decode an int32. +func (o *Buffer) dec_int32(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + word32_Set(structPointer_Word32(base, p.field), o, uint32(u)) + return nil +} + +func (o *Buffer) dec_proto3_int32(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + word32Val_Set(structPointer_Word32Val(base, p.field), uint32(u)) + return nil +} + +// Decode an int64. +func (o *Buffer) dec_int64(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + word64_Set(structPointer_Word64(base, p.field), o, u) + return nil +} + +func (o *Buffer) dec_proto3_int64(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + word64Val_Set(structPointer_Word64Val(base, p.field), o, u) + return nil +} + +// Decode a string. +func (o *Buffer) dec_string(p *Properties, base structPointer) error { + s, err := o.DecodeStringBytes() + if err != nil { + return err + } + *structPointer_String(base, p.field) = &s + return nil +} + +func (o *Buffer) dec_proto3_string(p *Properties, base structPointer) error { + s, err := o.DecodeStringBytes() + if err != nil { + return err + } + *structPointer_StringVal(base, p.field) = s + return nil +} + +// Decode a slice of bytes ([]byte). +func (o *Buffer) dec_slice_byte(p *Properties, base structPointer) error { + b, err := o.DecodeRawBytes(true) + if err != nil { + return err + } + *structPointer_Bytes(base, p.field) = b + return nil +} + +// Decode a slice of bools ([]bool). +func (o *Buffer) dec_slice_bool(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + v := structPointer_BoolSlice(base, p.field) + *v = append(*v, u != 0) + return nil +} + +// Decode a slice of bools ([]bool) in packed format. +func (o *Buffer) dec_slice_packed_bool(p *Properties, base structPointer) error { + v := structPointer_BoolSlice(base, p.field) + + nn, err := o.DecodeVarint() + if err != nil { + return err + } + nb := int(nn) // number of bytes of encoded bools + fin := o.index + nb + if fin < o.index { + return errOverflow + } + + y := *v + for o.index < fin { + u, err := p.valDec(o) + if err != nil { + return err + } + y = append(y, u != 0) + } + + *v = y + return nil +} + +// Decode a slice of int32s ([]int32). +func (o *Buffer) dec_slice_int32(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + structPointer_Word32Slice(base, p.field).Append(uint32(u)) + return nil +} + +// Decode a slice of int32s ([]int32) in packed format. +func (o *Buffer) dec_slice_packed_int32(p *Properties, base structPointer) error { + v := structPointer_Word32Slice(base, p.field) + + nn, err := o.DecodeVarint() + if err != nil { + return err + } + nb := int(nn) // number of bytes of encoded int32s + + fin := o.index + nb + if fin < o.index { + return errOverflow + } + for o.index < fin { + u, err := p.valDec(o) + if err != nil { + return err + } + v.Append(uint32(u)) + } + return nil +} + +// Decode a slice of int64s ([]int64). +func (o *Buffer) dec_slice_int64(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + + structPointer_Word64Slice(base, p.field).Append(u) + return nil +} + +// Decode a slice of int64s ([]int64) in packed format. +func (o *Buffer) dec_slice_packed_int64(p *Properties, base structPointer) error { + v := structPointer_Word64Slice(base, p.field) + + nn, err := o.DecodeVarint() + if err != nil { + return err + } + nb := int(nn) // number of bytes of encoded int64s + + fin := o.index + nb + if fin < o.index { + return errOverflow + } + for o.index < fin { + u, err := p.valDec(o) + if err != nil { + return err + } + v.Append(u) + } + return nil +} + +// Decode a slice of strings ([]string). +func (o *Buffer) dec_slice_string(p *Properties, base structPointer) error { + s, err := o.DecodeStringBytes() + if err != nil { + return err + } + v := structPointer_StringSlice(base, p.field) + *v = append(*v, s) + return nil +} + +// Decode a slice of slice of bytes ([][]byte). +func (o *Buffer) dec_slice_slice_byte(p *Properties, base structPointer) error { + b, err := o.DecodeRawBytes(true) + if err != nil { + return err + } + v := structPointer_BytesSlice(base, p.field) + *v = append(*v, b) + return nil +} + +// Decode a map field. +func (o *Buffer) dec_new_map(p *Properties, base structPointer) error { + raw, err := o.DecodeRawBytes(false) + if err != nil { + return err + } + oi := o.index // index at the end of this map entry + o.index -= len(raw) // move buffer back to start of map entry + + mptr := structPointer_NewAt(base, p.field, p.mtype) // *map[K]V + if mptr.Elem().IsNil() { + mptr.Elem().Set(reflect.MakeMap(mptr.Type().Elem())) + } + v := mptr.Elem() // map[K]V + + // Prepare addressable doubly-indirect placeholders for the key and value types. + // See enc_new_map for why. + keyptr := reflect.New(reflect.PtrTo(p.mtype.Key())).Elem() // addressable *K + keybase := toStructPointer(keyptr.Addr()) // **K + + var valbase structPointer + var valptr reflect.Value + switch p.mtype.Elem().Kind() { + case reflect.Slice: + // []byte + var dummy []byte + valptr = reflect.ValueOf(&dummy) // *[]byte + valbase = toStructPointer(valptr) // *[]byte + case reflect.Ptr: + // message; valptr is **Msg; need to allocate the intermediate pointer + valptr = reflect.New(reflect.PtrTo(p.mtype.Elem())).Elem() // addressable *V + valptr.Set(reflect.New(valptr.Type().Elem())) + valbase = toStructPointer(valptr) + default: + // everything else + valptr = reflect.New(reflect.PtrTo(p.mtype.Elem())).Elem() // addressable *V + valbase = toStructPointer(valptr.Addr()) // **V + } + + // Decode. + // This parses a restricted wire format, namely the encoding of a message + // with two fields. See enc_new_map for the format. + for o.index < oi { + // tagcode for key and value properties are always a single byte + // because they have tags 1 and 2. + tagcode := o.buf[o.index] + o.index++ + switch tagcode { + case p.mkeyprop.tagcode[0]: + if err := p.mkeyprop.dec(o, p.mkeyprop, keybase); err != nil { + return err + } + case p.mvalprop.tagcode[0]: + if err := p.mvalprop.dec(o, p.mvalprop, valbase); err != nil { + return err + } + default: + // TODO: Should we silently skip this instead? + return fmt.Errorf("proto: bad map data tag %d", raw[0]) + } + } + keyelem, valelem := keyptr.Elem(), valptr.Elem() + if !keyelem.IsValid() || !valelem.IsValid() { + // We did not decode the key or the value in the map entry. + // Either way, it's an invalid map entry. + return fmt.Errorf("proto: bad map data: missing key/val") + } + + v.SetMapIndex(keyelem, valelem) + return nil +} + +// Decode a group. +func (o *Buffer) dec_struct_group(p *Properties, base structPointer) error { + bas := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(bas) { + // allocate new nested message + bas = toStructPointer(reflect.New(p.stype)) + structPointer_SetStructPointer(base, p.field, bas) + } + return o.unmarshalType(p.stype, p.sprop, true, bas) +} + +// Decode an embedded message. +func (o *Buffer) dec_struct_message(p *Properties, base structPointer) (err error) { + raw, e := o.DecodeRawBytes(false) + if e != nil { + return e + } + + bas := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(bas) { + // allocate new nested message + bas = toStructPointer(reflect.New(p.stype)) + structPointer_SetStructPointer(base, p.field, bas) + } + + // If the object can unmarshal itself, let it. + if p.isUnmarshaler { + iv := structPointer_Interface(bas, p.stype) + return iv.(Unmarshaler).Unmarshal(raw) + } + + obuf := o.buf + oi := o.index + o.buf = raw + o.index = 0 + + err = o.unmarshalType(p.stype, p.sprop, false, bas) + o.buf = obuf + o.index = oi + + return err +} + +// Decode a slice of embedded messages. +func (o *Buffer) dec_slice_struct_message(p *Properties, base structPointer) error { + return o.dec_slice_struct(p, false, base) +} + +// Decode a slice of embedded groups. +func (o *Buffer) dec_slice_struct_group(p *Properties, base structPointer) error { + return o.dec_slice_struct(p, true, base) +} + +// Decode a slice of structs ([]*struct). +func (o *Buffer) dec_slice_struct(p *Properties, is_group bool, base structPointer) error { + v := reflect.New(p.stype) + bas := toStructPointer(v) + structPointer_StructPointerSlice(base, p.field).Append(bas) + + if is_group { + err := o.unmarshalType(p.stype, p.sprop, is_group, bas) + return err + } + + raw, err := o.DecodeRawBytes(false) + if err != nil { + return err + } + + // If the object can unmarshal itself, let it. + if p.isUnmarshaler { + iv := v.Interface() + return iv.(Unmarshaler).Unmarshal(raw) + } + + obuf := o.buf + oi := o.index + o.buf = raw + o.index = 0 + + err = o.unmarshalType(p.stype, p.sprop, is_group, bas) + + o.buf = obuf + o.index = oi + + return err +} diff --git a/vendor/github.com/gogo/protobuf/proto/decode_gogo.go b/vendor/github.com/gogo/protobuf/proto/decode_gogo.go new file mode 100644 index 0000000000..6a77aad766 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/decode_gogo.go @@ -0,0 +1,175 @@ +// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. +// http://github.com/gogo/protobuf/gogoproto +// +// 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. +// +// 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. + +package proto + +import ( + "reflect" +) + +// Decode a reference to a struct pointer. +func (o *Buffer) dec_ref_struct_message(p *Properties, base structPointer) (err error) { + raw, e := o.DecodeRawBytes(false) + if e != nil { + return e + } + + // If the object can unmarshal itself, let it. + if p.isUnmarshaler { + panic("not supported, since this is a pointer receiver") + } + + obuf := o.buf + oi := o.index + o.buf = raw + o.index = 0 + + bas := structPointer_FieldPointer(base, p.field) + + err = o.unmarshalType(p.stype, p.sprop, false, bas) + o.buf = obuf + o.index = oi + + return err +} + +// Decode a slice of references to struct pointers ([]struct). +func (o *Buffer) dec_slice_ref_struct(p *Properties, is_group bool, base structPointer) error { + newBas := appendStructPointer(base, p.field, p.sstype) + + if is_group { + panic("not supported, maybe in future, if requested.") + } + + raw, err := o.DecodeRawBytes(false) + if err != nil { + return err + } + + // If the object can unmarshal itself, let it. + if p.isUnmarshaler { + panic("not supported, since this is not a pointer receiver.") + } + + obuf := o.buf + oi := o.index + o.buf = raw + o.index = 0 + + err = o.unmarshalType(p.stype, p.sprop, is_group, newBas) + + o.buf = obuf + o.index = oi + + return err +} + +// Decode a slice of references to struct pointers. +func (o *Buffer) dec_slice_ref_struct_message(p *Properties, base structPointer) error { + return o.dec_slice_ref_struct(p, false, base) +} + +func setPtrCustomType(base structPointer, f field, v interface{}) { + if v == nil { + return + } + structPointer_SetStructPointer(base, f, structPointer(reflect.ValueOf(v).Pointer())) +} + +func setCustomType(base structPointer, f field, value interface{}) { + if value == nil { + return + } + v := reflect.ValueOf(value).Elem() + t := reflect.TypeOf(value).Elem() + kind := t.Kind() + switch kind { + case reflect.Slice: + slice := reflect.MakeSlice(t, v.Len(), v.Cap()) + reflect.Copy(slice, v) + oldHeader := structPointer_GetSliceHeader(base, f) + oldHeader.Data = slice.Pointer() + oldHeader.Len = v.Len() + oldHeader.Cap = v.Cap() + default: + l := 1 + size := reflect.TypeOf(value).Elem().Size() + if kind == reflect.Array { + l = reflect.TypeOf(value).Elem().Len() + size = reflect.TypeOf(value).Size() + } + total := int(size) * l + structPointer_Copy(toStructPointer(reflect.ValueOf(value)), structPointer_Add(base, f), total) + } +} + +func (o *Buffer) dec_custom_bytes(p *Properties, base structPointer) error { + b, err := o.DecodeRawBytes(true) + if err != nil { + return err + } + i := reflect.New(p.ctype.Elem()).Interface() + custom := (i).(Unmarshaler) + if err := custom.Unmarshal(b); err != nil { + return err + } + setPtrCustomType(base, p.field, custom) + return nil +} + +func (o *Buffer) dec_custom_ref_bytes(p *Properties, base structPointer) error { + b, err := o.DecodeRawBytes(true) + if err != nil { + return err + } + i := reflect.New(p.ctype).Interface() + custom := (i).(Unmarshaler) + if err := custom.Unmarshal(b); err != nil { + return err + } + if custom != nil { + setCustomType(base, p.field, custom) + } + return nil +} + +// Decode a slice of bytes ([]byte) into a slice of custom types. +func (o *Buffer) dec_custom_slice_bytes(p *Properties, base structPointer) error { + b, err := o.DecodeRawBytes(true) + if err != nil { + return err + } + i := reflect.New(p.ctype.Elem()).Interface() + custom := (i).(Unmarshaler) + if err := custom.Unmarshal(b); err != nil { + return err + } + newBas := appendStructPointer(base, p.field, p.ctype) + + setCustomType(newBas, 0, custom) + + return nil +} diff --git a/vendor/github.com/gogo/protobuf/proto/encode.go b/vendor/github.com/gogo/protobuf/proto/encode.go new file mode 100644 index 0000000000..231b07401a --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/encode.go @@ -0,0 +1,1325 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +package proto + +/* + * Routines for encoding data into the wire format for protocol buffers. + */ + +import ( + "errors" + "fmt" + "reflect" + "sort" +) + +// RequiredNotSetError is the error returned if Marshal is called with +// a protocol buffer struct whose required fields have not +// all been initialized. It is also the error returned if Unmarshal is +// called with an encoded protocol buffer that does not include all the +// required fields. +// +// When printed, RequiredNotSetError reports the first unset required field in a +// message. If the field cannot be precisely determined, it is reported as +// "{Unknown}". +type RequiredNotSetError struct { + field string +} + +func (e *RequiredNotSetError) Error() string { + return fmt.Sprintf("proto: required field %q not set", e.field) +} + +var ( + // errRepeatedHasNil is the error returned if Marshal is called with + // a struct with a repeated field containing a nil element. + errRepeatedHasNil = errors.New("proto: repeated field has nil element") + + // ErrNil is the error returned if Marshal is called with nil. + ErrNil = errors.New("proto: Marshal called with nil") +) + +// The fundamental encoders that put bytes on the wire. +// Those that take integer types all accept uint64 and are +// therefore of type valueEncoder. + +const maxVarintBytes = 10 // maximum length of a varint + +// EncodeVarint returns the varint encoding of x. +// This is the format for the +// int32, int64, uint32, uint64, bool, and enum +// protocol buffer types. +// Not used by the package itself, but helpful to clients +// wishing to use the same encoding. +func EncodeVarint(x uint64) []byte { + var buf [maxVarintBytes]byte + var n int + for n = 0; x > 127; n++ { + buf[n] = 0x80 | uint8(x&0x7F) + x >>= 7 + } + buf[n] = uint8(x) + n++ + return buf[0:n] +} + +// EncodeVarint writes a varint-encoded integer to the Buffer. +// This is the format for the +// int32, int64, uint32, uint64, bool, and enum +// protocol buffer types. +func (p *Buffer) EncodeVarint(x uint64) error { + for x >= 1<<7 { + p.buf = append(p.buf, uint8(x&0x7f|0x80)) + x >>= 7 + } + p.buf = append(p.buf, uint8(x)) + return nil +} + +// SizeVarint returns the varint encoding size of an integer. +func SizeVarint(x uint64) int { + return sizeVarint(x) +} + +func sizeVarint(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} + +// EncodeFixed64 writes a 64-bit integer to the Buffer. +// This is the format for the +// fixed64, sfixed64, and double protocol buffer types. +func (p *Buffer) EncodeFixed64(x uint64) error { + p.buf = append(p.buf, + uint8(x), + uint8(x>>8), + uint8(x>>16), + uint8(x>>24), + uint8(x>>32), + uint8(x>>40), + uint8(x>>48), + uint8(x>>56)) + return nil +} + +func sizeFixed64(x uint64) int { + return 8 +} + +// EncodeFixed32 writes a 32-bit integer to the Buffer. +// This is the format for the +// fixed32, sfixed32, and float protocol buffer types. +func (p *Buffer) EncodeFixed32(x uint64) error { + p.buf = append(p.buf, + uint8(x), + uint8(x>>8), + uint8(x>>16), + uint8(x>>24)) + return nil +} + +func sizeFixed32(x uint64) int { + return 4 +} + +// EncodeZigzag64 writes a zigzag-encoded 64-bit integer +// to the Buffer. +// This is the format used for the sint64 protocol buffer type. +func (p *Buffer) EncodeZigzag64(x uint64) error { + // use signed number to get arithmetic right shift. + return p.EncodeVarint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} + +func sizeZigzag64(x uint64) int { + return sizeVarint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} + +// EncodeZigzag32 writes a zigzag-encoded 32-bit integer +// to the Buffer. +// This is the format used for the sint32 protocol buffer type. +func (p *Buffer) EncodeZigzag32(x uint64) error { + // use signed number to get arithmetic right shift. + return p.EncodeVarint(uint64((uint32(x) << 1) ^ uint32((int32(x) >> 31)))) +} + +func sizeZigzag32(x uint64) int { + return sizeVarint(uint64((uint32(x) << 1) ^ uint32((int32(x) >> 31)))) +} + +// EncodeRawBytes writes a count-delimited byte buffer to the Buffer. +// This is the format used for the bytes protocol buffer +// type and for embedded messages. +func (p *Buffer) EncodeRawBytes(b []byte) error { + p.EncodeVarint(uint64(len(b))) + p.buf = append(p.buf, b...) + return nil +} + +func sizeRawBytes(b []byte) int { + return sizeVarint(uint64(len(b))) + + len(b) +} + +// EncodeStringBytes writes an encoded string to the Buffer. +// This is the format used for the proto2 string type. +func (p *Buffer) EncodeStringBytes(s string) error { + p.EncodeVarint(uint64(len(s))) + p.buf = append(p.buf, s...) + return nil +} + +func sizeStringBytes(s string) int { + return sizeVarint(uint64(len(s))) + + len(s) +} + +// Marshaler is the interface representing objects that can marshal themselves. +type Marshaler interface { + Marshal() ([]byte, error) +} + +// Marshal takes the protocol buffer +// and encodes it into the wire format, returning the data. +func Marshal(pb Message) ([]byte, error) { + // Can the object marshal itself? + if m, ok := pb.(Marshaler); ok { + return m.Marshal() + } + p := NewBuffer(nil) + err := p.Marshal(pb) + var state errorState + if err != nil && !state.shouldContinue(err, nil) { + return nil, err + } + if p.buf == nil && err == nil { + // Return a non-nil slice on success. + return []byte{}, nil + } + return p.buf, err +} + +// EncodeMessage writes the protocol buffer to the Buffer, +// prefixed by a varint-encoded length. +func (p *Buffer) EncodeMessage(pb Message) error { + t, base, err := getbase(pb) + if structPointer_IsNil(base) { + return ErrNil + } + if err == nil { + var state errorState + err = p.enc_len_struct(GetProperties(t.Elem()), base, &state) + } + return err +} + +// Marshal takes the protocol buffer +// and encodes it into the wire format, writing the result to the +// Buffer. +func (p *Buffer) Marshal(pb Message) error { + // Can the object marshal itself? + if m, ok := pb.(Marshaler); ok { + data, err := m.Marshal() + if err != nil { + return err + } + p.buf = append(p.buf, data...) + return nil + } + + t, base, err := getbase(pb) + if structPointer_IsNil(base) { + return ErrNil + } + if err == nil { + err = p.enc_struct(GetProperties(t.Elem()), base) + } + + if collectStats { + stats.Encode++ + } + + return err +} + +// Size returns the encoded size of a protocol buffer. +func Size(pb Message) (n int) { + // Can the object marshal itself? If so, Size is slow. + // TODO: add Size to Marshaler, or add a Sizer interface. + if m, ok := pb.(Marshaler); ok { + b, _ := m.Marshal() + return len(b) + } + + t, base, err := getbase(pb) + if structPointer_IsNil(base) { + return 0 + } + if err == nil { + n = size_struct(GetProperties(t.Elem()), base) + } + + if collectStats { + stats.Size++ + } + + return +} + +// Individual type encoders. + +// Encode a bool. +func (o *Buffer) enc_bool(p *Properties, base structPointer) error { + v := *structPointer_Bool(base, p.field) + if v == nil { + return ErrNil + } + x := 0 + if *v { + x = 1 + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func (o *Buffer) enc_proto3_bool(p *Properties, base structPointer) error { + v := *structPointer_BoolVal(base, p.field) + if !v { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, 1) + return nil +} + +func size_bool(p *Properties, base structPointer) int { + v := *structPointer_Bool(base, p.field) + if v == nil { + return 0 + } + return len(p.tagcode) + 1 // each bool takes exactly one byte +} + +func size_proto3_bool(p *Properties, base structPointer) int { + v := *structPointer_BoolVal(base, p.field) + if !v && !p.oneof { + return 0 + } + return len(p.tagcode) + 1 // each bool takes exactly one byte +} + +// Encode an int32. +func (o *Buffer) enc_int32(p *Properties, base structPointer) error { + v := structPointer_Word32(base, p.field) + if word32_IsNil(v) { + return ErrNil + } + x := int32(word32_Get(v)) // permit sign extension to use full 64-bit range + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func (o *Buffer) enc_proto3_int32(p *Properties, base structPointer) error { + v := structPointer_Word32Val(base, p.field) + x := int32(word32Val_Get(v)) // permit sign extension to use full 64-bit range + if x == 0 { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func size_int32(p *Properties, base structPointer) (n int) { + v := structPointer_Word32(base, p.field) + if word32_IsNil(v) { + return 0 + } + x := int32(word32_Get(v)) // permit sign extension to use full 64-bit range + n += len(p.tagcode) + n += p.valSize(uint64(x)) + return +} + +func size_proto3_int32(p *Properties, base structPointer) (n int) { + v := structPointer_Word32Val(base, p.field) + x := int32(word32Val_Get(v)) // permit sign extension to use full 64-bit range + if x == 0 && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += p.valSize(uint64(x)) + return +} + +// Encode a uint32. +// Exactly the same as int32, except for no sign extension. +func (o *Buffer) enc_uint32(p *Properties, base structPointer) error { + v := structPointer_Word32(base, p.field) + if word32_IsNil(v) { + return ErrNil + } + x := word32_Get(v) + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func (o *Buffer) enc_proto3_uint32(p *Properties, base structPointer) error { + v := structPointer_Word32Val(base, p.field) + x := word32Val_Get(v) + if x == 0 { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func size_uint32(p *Properties, base structPointer) (n int) { + v := structPointer_Word32(base, p.field) + if word32_IsNil(v) { + return 0 + } + x := word32_Get(v) + n += len(p.tagcode) + n += p.valSize(uint64(x)) + return +} + +func size_proto3_uint32(p *Properties, base structPointer) (n int) { + v := structPointer_Word32Val(base, p.field) + x := word32Val_Get(v) + if x == 0 && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += p.valSize(uint64(x)) + return +} + +// Encode an int64. +func (o *Buffer) enc_int64(p *Properties, base structPointer) error { + v := structPointer_Word64(base, p.field) + if word64_IsNil(v) { + return ErrNil + } + x := word64_Get(v) + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, x) + return nil +} + +func (o *Buffer) enc_proto3_int64(p *Properties, base structPointer) error { + v := structPointer_Word64Val(base, p.field) + x := word64Val_Get(v) + if x == 0 { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, x) + return nil +} + +func size_int64(p *Properties, base structPointer) (n int) { + v := structPointer_Word64(base, p.field) + if word64_IsNil(v) { + return 0 + } + x := word64_Get(v) + n += len(p.tagcode) + n += p.valSize(x) + return +} + +func size_proto3_int64(p *Properties, base structPointer) (n int) { + v := structPointer_Word64Val(base, p.field) + x := word64Val_Get(v) + if x == 0 && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += p.valSize(x) + return +} + +// Encode a string. +func (o *Buffer) enc_string(p *Properties, base structPointer) error { + v := *structPointer_String(base, p.field) + if v == nil { + return ErrNil + } + x := *v + o.buf = append(o.buf, p.tagcode...) + o.EncodeStringBytes(x) + return nil +} + +func (o *Buffer) enc_proto3_string(p *Properties, base structPointer) error { + v := *structPointer_StringVal(base, p.field) + if v == "" { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeStringBytes(v) + return nil +} + +func size_string(p *Properties, base structPointer) (n int) { + v := *structPointer_String(base, p.field) + if v == nil { + return 0 + } + x := *v + n += len(p.tagcode) + n += sizeStringBytes(x) + return +} + +func size_proto3_string(p *Properties, base structPointer) (n int) { + v := *structPointer_StringVal(base, p.field) + if v == "" && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += sizeStringBytes(v) + return +} + +// All protocol buffer fields are nillable, but be careful. +func isNil(v reflect.Value) bool { + switch v.Kind() { + case reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice: + return v.IsNil() + } + return false +} + +// Encode a message struct. +func (o *Buffer) enc_struct_message(p *Properties, base structPointer) error { + var state errorState + structp := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(structp) { + return ErrNil + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, err := m.Marshal() + if err != nil && !state.shouldContinue(err, nil) { + return err + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(data) + return state.err + } + + o.buf = append(o.buf, p.tagcode...) + return o.enc_len_struct(p.sprop, structp, &state) +} + +func size_struct_message(p *Properties, base structPointer) int { + structp := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(structp) { + return 0 + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, _ := m.Marshal() + n0 := len(p.tagcode) + n1 := sizeRawBytes(data) + return n0 + n1 + } + + n0 := len(p.tagcode) + n1 := size_struct(p.sprop, structp) + n2 := sizeVarint(uint64(n1)) // size of encoded length + return n0 + n1 + n2 +} + +// Encode a group struct. +func (o *Buffer) enc_struct_group(p *Properties, base structPointer) error { + var state errorState + b := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(b) { + return ErrNil + } + + o.EncodeVarint(uint64((p.Tag << 3) | WireStartGroup)) + err := o.enc_struct(p.sprop, b) + if err != nil && !state.shouldContinue(err, nil) { + return err + } + o.EncodeVarint(uint64((p.Tag << 3) | WireEndGroup)) + return state.err +} + +func size_struct_group(p *Properties, base structPointer) (n int) { + b := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(b) { + return 0 + } + + n += sizeVarint(uint64((p.Tag << 3) | WireStartGroup)) + n += size_struct(p.sprop, b) + n += sizeVarint(uint64((p.Tag << 3) | WireEndGroup)) + return +} + +// Encode a slice of bools ([]bool). +func (o *Buffer) enc_slice_bool(p *Properties, base structPointer) error { + s := *structPointer_BoolSlice(base, p.field) + l := len(s) + if l == 0 { + return ErrNil + } + for _, x := range s { + o.buf = append(o.buf, p.tagcode...) + v := uint64(0) + if x { + v = 1 + } + p.valEnc(o, v) + } + return nil +} + +func size_slice_bool(p *Properties, base structPointer) int { + s := *structPointer_BoolSlice(base, p.field) + l := len(s) + if l == 0 { + return 0 + } + return l * (len(p.tagcode) + 1) // each bool takes exactly one byte +} + +// Encode a slice of bools ([]bool) in packed format. +func (o *Buffer) enc_slice_packed_bool(p *Properties, base structPointer) error { + s := *structPointer_BoolSlice(base, p.field) + l := len(s) + if l == 0 { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeVarint(uint64(l)) // each bool takes exactly one byte + for _, x := range s { + v := uint64(0) + if x { + v = 1 + } + p.valEnc(o, v) + } + return nil +} + +func size_slice_packed_bool(p *Properties, base structPointer) (n int) { + s := *structPointer_BoolSlice(base, p.field) + l := len(s) + if l == 0 { + return 0 + } + n += len(p.tagcode) + n += sizeVarint(uint64(l)) + n += l // each bool takes exactly one byte + return +} + +// Encode a slice of bytes ([]byte). +func (o *Buffer) enc_slice_byte(p *Properties, base structPointer) error { + s := *structPointer_Bytes(base, p.field) + if s == nil { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(s) + return nil +} + +func (o *Buffer) enc_proto3_slice_byte(p *Properties, base structPointer) error { + s := *structPointer_Bytes(base, p.field) + if len(s) == 0 { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(s) + return nil +} + +func size_slice_byte(p *Properties, base structPointer) (n int) { + s := *structPointer_Bytes(base, p.field) + if s == nil && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += sizeRawBytes(s) + return +} + +func size_proto3_slice_byte(p *Properties, base structPointer) (n int) { + s := *structPointer_Bytes(base, p.field) + if len(s) == 0 && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += sizeRawBytes(s) + return +} + +// Encode a slice of int32s ([]int32). +func (o *Buffer) enc_slice_int32(p *Properties, base structPointer) error { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + for i := 0; i < l; i++ { + o.buf = append(o.buf, p.tagcode...) + x := int32(s.Index(i)) // permit sign extension to use full 64-bit range + p.valEnc(o, uint64(x)) + } + return nil +} + +func size_slice_int32(p *Properties, base structPointer) (n int) { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + for i := 0; i < l; i++ { + n += len(p.tagcode) + x := int32(s.Index(i)) // permit sign extension to use full 64-bit range + n += p.valSize(uint64(x)) + } + return +} + +// Encode a slice of int32s ([]int32) in packed format. +func (o *Buffer) enc_slice_packed_int32(p *Properties, base structPointer) error { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + // TODO: Reuse a Buffer. + buf := NewBuffer(nil) + for i := 0; i < l; i++ { + x := int32(s.Index(i)) // permit sign extension to use full 64-bit range + p.valEnc(buf, uint64(x)) + } + + o.buf = append(o.buf, p.tagcode...) + o.EncodeVarint(uint64(len(buf.buf))) + o.buf = append(o.buf, buf.buf...) + return nil +} + +func size_slice_packed_int32(p *Properties, base structPointer) (n int) { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + var bufSize int + for i := 0; i < l; i++ { + x := int32(s.Index(i)) // permit sign extension to use full 64-bit range + bufSize += p.valSize(uint64(x)) + } + + n += len(p.tagcode) + n += sizeVarint(uint64(bufSize)) + n += bufSize + return +} + +// Encode a slice of uint32s ([]uint32). +// Exactly the same as int32, except for no sign extension. +func (o *Buffer) enc_slice_uint32(p *Properties, base structPointer) error { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + for i := 0; i < l; i++ { + o.buf = append(o.buf, p.tagcode...) + x := s.Index(i) + p.valEnc(o, uint64(x)) + } + return nil +} + +func size_slice_uint32(p *Properties, base structPointer) (n int) { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + for i := 0; i < l; i++ { + n += len(p.tagcode) + x := s.Index(i) + n += p.valSize(uint64(x)) + } + return +} + +// Encode a slice of uint32s ([]uint32) in packed format. +// Exactly the same as int32, except for no sign extension. +func (o *Buffer) enc_slice_packed_uint32(p *Properties, base structPointer) error { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + // TODO: Reuse a Buffer. + buf := NewBuffer(nil) + for i := 0; i < l; i++ { + p.valEnc(buf, uint64(s.Index(i))) + } + + o.buf = append(o.buf, p.tagcode...) + o.EncodeVarint(uint64(len(buf.buf))) + o.buf = append(o.buf, buf.buf...) + return nil +} + +func size_slice_packed_uint32(p *Properties, base structPointer) (n int) { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + var bufSize int + for i := 0; i < l; i++ { + bufSize += p.valSize(uint64(s.Index(i))) + } + + n += len(p.tagcode) + n += sizeVarint(uint64(bufSize)) + n += bufSize + return +} + +// Encode a slice of int64s ([]int64). +func (o *Buffer) enc_slice_int64(p *Properties, base structPointer) error { + s := structPointer_Word64Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + for i := 0; i < l; i++ { + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, s.Index(i)) + } + return nil +} + +func size_slice_int64(p *Properties, base structPointer) (n int) { + s := structPointer_Word64Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + for i := 0; i < l; i++ { + n += len(p.tagcode) + n += p.valSize(s.Index(i)) + } + return +} + +// Encode a slice of int64s ([]int64) in packed format. +func (o *Buffer) enc_slice_packed_int64(p *Properties, base structPointer) error { + s := structPointer_Word64Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + // TODO: Reuse a Buffer. + buf := NewBuffer(nil) + for i := 0; i < l; i++ { + p.valEnc(buf, s.Index(i)) + } + + o.buf = append(o.buf, p.tagcode...) + o.EncodeVarint(uint64(len(buf.buf))) + o.buf = append(o.buf, buf.buf...) + return nil +} + +func size_slice_packed_int64(p *Properties, base structPointer) (n int) { + s := structPointer_Word64Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + var bufSize int + for i := 0; i < l; i++ { + bufSize += p.valSize(s.Index(i)) + } + + n += len(p.tagcode) + n += sizeVarint(uint64(bufSize)) + n += bufSize + return +} + +// Encode a slice of slice of bytes ([][]byte). +func (o *Buffer) enc_slice_slice_byte(p *Properties, base structPointer) error { + ss := *structPointer_BytesSlice(base, p.field) + l := len(ss) + if l == 0 { + return ErrNil + } + for i := 0; i < l; i++ { + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(ss[i]) + } + return nil +} + +func size_slice_slice_byte(p *Properties, base structPointer) (n int) { + ss := *structPointer_BytesSlice(base, p.field) + l := len(ss) + if l == 0 { + return 0 + } + n += l * len(p.tagcode) + for i := 0; i < l; i++ { + n += sizeRawBytes(ss[i]) + } + return +} + +// Encode a slice of strings ([]string). +func (o *Buffer) enc_slice_string(p *Properties, base structPointer) error { + ss := *structPointer_StringSlice(base, p.field) + l := len(ss) + for i := 0; i < l; i++ { + o.buf = append(o.buf, p.tagcode...) + o.EncodeStringBytes(ss[i]) + } + return nil +} + +func size_slice_string(p *Properties, base structPointer) (n int) { + ss := *structPointer_StringSlice(base, p.field) + l := len(ss) + n += l * len(p.tagcode) + for i := 0; i < l; i++ { + n += sizeStringBytes(ss[i]) + } + return +} + +// Encode a slice of message structs ([]*struct). +func (o *Buffer) enc_slice_struct_message(p *Properties, base structPointer) error { + var state errorState + s := structPointer_StructPointerSlice(base, p.field) + l := s.Len() + + for i := 0; i < l; i++ { + structp := s.Index(i) + if structPointer_IsNil(structp) { + return errRepeatedHasNil + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, err := m.Marshal() + if err != nil && !state.shouldContinue(err, nil) { + return err + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(data) + continue + } + + o.buf = append(o.buf, p.tagcode...) + err := o.enc_len_struct(p.sprop, structp, &state) + if err != nil && !state.shouldContinue(err, nil) { + if err == ErrNil { + return errRepeatedHasNil + } + return err + } + } + return state.err +} + +func size_slice_struct_message(p *Properties, base structPointer) (n int) { + s := structPointer_StructPointerSlice(base, p.field) + l := s.Len() + n += l * len(p.tagcode) + for i := 0; i < l; i++ { + structp := s.Index(i) + if structPointer_IsNil(structp) { + return // return the size up to this point + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, _ := m.Marshal() + n += len(p.tagcode) + n += sizeRawBytes(data) + continue + } + + n0 := size_struct(p.sprop, structp) + n1 := sizeVarint(uint64(n0)) // size of encoded length + n += n0 + n1 + } + return +} + +// Encode a slice of group structs ([]*struct). +func (o *Buffer) enc_slice_struct_group(p *Properties, base structPointer) error { + var state errorState + s := structPointer_StructPointerSlice(base, p.field) + l := s.Len() + + for i := 0; i < l; i++ { + b := s.Index(i) + if structPointer_IsNil(b) { + return errRepeatedHasNil + } + + o.EncodeVarint(uint64((p.Tag << 3) | WireStartGroup)) + + err := o.enc_struct(p.sprop, b) + + if err != nil && !state.shouldContinue(err, nil) { + if err == ErrNil { + return errRepeatedHasNil + } + return err + } + + o.EncodeVarint(uint64((p.Tag << 3) | WireEndGroup)) + } + return state.err +} + +func size_slice_struct_group(p *Properties, base structPointer) (n int) { + s := structPointer_StructPointerSlice(base, p.field) + l := s.Len() + + n += l * sizeVarint(uint64((p.Tag<<3)|WireStartGroup)) + n += l * sizeVarint(uint64((p.Tag<<3)|WireEndGroup)) + for i := 0; i < l; i++ { + b := s.Index(i) + if structPointer_IsNil(b) { + return // return size up to this point + } + + n += size_struct(p.sprop, b) + } + return +} + +// Encode an extension map. +func (o *Buffer) enc_map(p *Properties, base structPointer) error { + v := *structPointer_ExtMap(base, p.field) + if err := encodeExtensionMap(v); err != nil { + return err + } + // Fast-path for common cases: zero or one extensions. + if len(v) <= 1 { + for _, e := range v { + o.buf = append(o.buf, e.enc...) + } + return nil + } + + // Sort keys to provide a deterministic encoding. + keys := make([]int, 0, len(v)) + for k := range v { + keys = append(keys, int(k)) + } + sort.Ints(keys) + + for _, k := range keys { + o.buf = append(o.buf, v[int32(k)].enc...) + } + return nil +} + +func size_map(p *Properties, base structPointer) int { + v := *structPointer_ExtMap(base, p.field) + return sizeExtensionMap(v) +} + +// Encode a map field. +func (o *Buffer) enc_new_map(p *Properties, base structPointer) error { + var state errorState // XXX: or do we need to plumb this through? + + /* + A map defined as + map map_field = N; + is encoded in the same way as + message MapFieldEntry { + key_type key = 1; + value_type value = 2; + } + repeated MapFieldEntry map_field = N; + */ + + v := structPointer_NewAt(base, p.field, p.mtype).Elem() // map[K]V + if v.Len() == 0 { + return nil + } + + keycopy, valcopy, keybase, valbase := mapEncodeScratch(p.mtype) + + enc := func() error { + if err := p.mkeyprop.enc(o, p.mkeyprop, keybase); err != nil { + return err + } + if err := p.mvalprop.enc(o, p.mvalprop, valbase); err != nil { + return err + } + return nil + } + + // Don't sort map keys. It is not required by the spec, and C++ doesn't do it. + for _, key := range v.MapKeys() { + val := v.MapIndex(key) + + // The only illegal map entry values are nil message pointers. + if val.Kind() == reflect.Ptr && val.IsNil() { + return errors.New("proto: map has nil element") + } + + keycopy.Set(key) + valcopy.Set(val) + + o.buf = append(o.buf, p.tagcode...) + if err := o.enc_len_thing(enc, &state); err != nil { + return err + } + } + return nil +} + +func size_new_map(p *Properties, base structPointer) int { + v := structPointer_NewAt(base, p.field, p.mtype).Elem() // map[K]V + + keycopy, valcopy, keybase, valbase := mapEncodeScratch(p.mtype) + + n := 0 + for _, key := range v.MapKeys() { + val := v.MapIndex(key) + keycopy.Set(key) + valcopy.Set(val) + + // Tag codes for key and val are the responsibility of the sub-sizer. + keysize := p.mkeyprop.size(p.mkeyprop, keybase) + valsize := p.mvalprop.size(p.mvalprop, valbase) + entry := keysize + valsize + // Add on tag code and length of map entry itself. + n += len(p.tagcode) + sizeVarint(uint64(entry)) + entry + } + return n +} + +// mapEncodeScratch returns a new reflect.Value matching the map's value type, +// and a structPointer suitable for passing to an encoder or sizer. +func mapEncodeScratch(mapType reflect.Type) (keycopy, valcopy reflect.Value, keybase, valbase structPointer) { + // Prepare addressable doubly-indirect placeholders for the key and value types. + // This is needed because the element-type encoders expect **T, but the map iteration produces T. + + keycopy = reflect.New(mapType.Key()).Elem() // addressable K + keyptr := reflect.New(reflect.PtrTo(keycopy.Type())).Elem() // addressable *K + keyptr.Set(keycopy.Addr()) // + keybase = toStructPointer(keyptr.Addr()) // **K + + // Value types are more varied and require special handling. + switch mapType.Elem().Kind() { + case reflect.Slice: + // []byte + var dummy []byte + valcopy = reflect.ValueOf(&dummy).Elem() // addressable []byte + valbase = toStructPointer(valcopy.Addr()) + case reflect.Ptr: + // message; the generated field type is map[K]*Msg (so V is *Msg), + // so we only need one level of indirection. + valcopy = reflect.New(mapType.Elem()).Elem() // addressable V + valbase = toStructPointer(valcopy.Addr()) + default: + // everything else + valcopy = reflect.New(mapType.Elem()).Elem() // addressable V + valptr := reflect.New(reflect.PtrTo(valcopy.Type())).Elem() // addressable *V + valptr.Set(valcopy.Addr()) // + valbase = toStructPointer(valptr.Addr()) // **V + } + return +} + +// Encode a struct. +func (o *Buffer) enc_struct(prop *StructProperties, base structPointer) error { + var state errorState + // Encode fields in tag order so that decoders may use optimizations + // that depend on the ordering. + // https://developers.google.com/protocol-buffers/docs/encoding#order + for _, i := range prop.order { + p := prop.Prop[i] + if p.enc != nil { + err := p.enc(o, p, base) + if err != nil { + if err == ErrNil { + if p.Required && state.err == nil { + state.err = &RequiredNotSetError{p.Name} + } + } else if err == errRepeatedHasNil { + // Give more context to nil values in repeated fields. + return errors.New("repeated field " + p.OrigName + " has nil element") + } else if !state.shouldContinue(err, p) { + return err + } + } + } + } + + // Do oneof fields. + if prop.oneofMarshaler != nil { + m := structPointer_Interface(base, prop.stype).(Message) + if err := prop.oneofMarshaler(m, o); err != nil { + return err + } + } + + // Add unrecognized fields at the end. + if prop.unrecField.IsValid() { + v := *structPointer_Bytes(base, prop.unrecField) + if len(v) > 0 { + o.buf = append(o.buf, v...) + } + } + + return state.err +} + +func size_struct(prop *StructProperties, base structPointer) (n int) { + for _, i := range prop.order { + p := prop.Prop[i] + if p.size != nil { + n += p.size(p, base) + } + } + + // Add unrecognized fields at the end. + if prop.unrecField.IsValid() { + v := *structPointer_Bytes(base, prop.unrecField) + n += len(v) + } + + // Factor in any oneof fields. + if prop.oneofSizer != nil { + m := structPointer_Interface(base, prop.stype).(Message) + n += prop.oneofSizer(m) + } + + return +} + +var zeroes [20]byte // longer than any conceivable sizeVarint + +// Encode a struct, preceded by its encoded length (as a varint). +func (o *Buffer) enc_len_struct(prop *StructProperties, base structPointer, state *errorState) error { + return o.enc_len_thing(func() error { return o.enc_struct(prop, base) }, state) +} + +// Encode something, preceded by its encoded length (as a varint). +func (o *Buffer) enc_len_thing(enc func() error, state *errorState) error { + iLen := len(o.buf) + o.buf = append(o.buf, 0, 0, 0, 0) // reserve four bytes for length + iMsg := len(o.buf) + err := enc() + if err != nil && !state.shouldContinue(err, nil) { + return err + } + lMsg := len(o.buf) - iMsg + lLen := sizeVarint(uint64(lMsg)) + switch x := lLen - (iMsg - iLen); { + case x > 0: // actual length is x bytes larger than the space we reserved + // Move msg x bytes right. + o.buf = append(o.buf, zeroes[:x]...) + copy(o.buf[iMsg+x:], o.buf[iMsg:iMsg+lMsg]) + case x < 0: // actual length is x bytes smaller than the space we reserved + // Move msg x bytes left. + copy(o.buf[iMsg+x:], o.buf[iMsg:iMsg+lMsg]) + o.buf = o.buf[:len(o.buf)+x] // x is negative + } + // Encode the length in the reserved space. + o.buf = o.buf[:iLen] + o.EncodeVarint(uint64(lMsg)) + o.buf = o.buf[:len(o.buf)+lMsg] + return state.err +} + +// errorState maintains the first error that occurs and updates that error +// with additional context. +type errorState struct { + err error +} + +// shouldContinue reports whether encoding should continue upon encountering the +// given error. If the error is RequiredNotSetError, shouldContinue returns true +// and, if this is the first appearance of that error, remembers it for future +// reporting. +// +// If prop is not nil, it may update any error with additional context about the +// field with the error. +func (s *errorState) shouldContinue(err error, prop *Properties) bool { + // Ignore unset required fields. + reqNotSet, ok := err.(*RequiredNotSetError) + if !ok { + return false + } + if s.err == nil { + if prop != nil { + err = &RequiredNotSetError{prop.Name + "." + reqNotSet.field} + } + s.err = err + } + return true +} diff --git a/vendor/github.com/gogo/protobuf/proto/encode_gogo.go b/vendor/github.com/gogo/protobuf/proto/encode_gogo.go new file mode 100644 index 0000000000..f77cfb1eea --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/encode_gogo.go @@ -0,0 +1,354 @@ +// Extensions for Protocol Buffers to create more go like structures. +// +// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. +// http://github.com/gogo/protobuf/gogoproto +// +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// http://github.com/golang/protobuf/ +// +// 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. + +package proto + +import ( + "reflect" +) + +func NewRequiredNotSetError(field string) *RequiredNotSetError { + return &RequiredNotSetError{field} +} + +type Sizer interface { + Size() int +} + +func (o *Buffer) enc_ext_slice_byte(p *Properties, base structPointer) error { + s := *structPointer_Bytes(base, p.field) + if s == nil { + return ErrNil + } + o.buf = append(o.buf, s...) + return nil +} + +func size_ext_slice_byte(p *Properties, base structPointer) (n int) { + s := *structPointer_Bytes(base, p.field) + if s == nil { + return 0 + } + n += len(s) + return +} + +// Encode a reference to bool pointer. +func (o *Buffer) enc_ref_bool(p *Properties, base structPointer) error { + v := *structPointer_BoolVal(base, p.field) + x := 0 + if v { + x = 1 + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func size_ref_bool(p *Properties, base structPointer) int { + return len(p.tagcode) + 1 // each bool takes exactly one byte +} + +// Encode a reference to int32 pointer. +func (o *Buffer) enc_ref_int32(p *Properties, base structPointer) error { + v := structPointer_Word32Val(base, p.field) + x := int32(word32Val_Get(v)) + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func size_ref_int32(p *Properties, base structPointer) (n int) { + v := structPointer_Word32Val(base, p.field) + x := int32(word32Val_Get(v)) + n += len(p.tagcode) + n += p.valSize(uint64(x)) + return +} + +func (o *Buffer) enc_ref_uint32(p *Properties, base structPointer) error { + v := structPointer_Word32Val(base, p.field) + x := word32Val_Get(v) + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func size_ref_uint32(p *Properties, base structPointer) (n int) { + v := structPointer_Word32Val(base, p.field) + x := word32Val_Get(v) + n += len(p.tagcode) + n += p.valSize(uint64(x)) + return +} + +// Encode a reference to an int64 pointer. +func (o *Buffer) enc_ref_int64(p *Properties, base structPointer) error { + v := structPointer_Word64Val(base, p.field) + x := word64Val_Get(v) + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, x) + return nil +} + +func size_ref_int64(p *Properties, base structPointer) (n int) { + v := structPointer_Word64Val(base, p.field) + x := word64Val_Get(v) + n += len(p.tagcode) + n += p.valSize(x) + return +} + +// Encode a reference to a string pointer. +func (o *Buffer) enc_ref_string(p *Properties, base structPointer) error { + v := *structPointer_StringVal(base, p.field) + o.buf = append(o.buf, p.tagcode...) + o.EncodeStringBytes(v) + return nil +} + +func size_ref_string(p *Properties, base structPointer) (n int) { + v := *structPointer_StringVal(base, p.field) + n += len(p.tagcode) + n += sizeStringBytes(v) + return +} + +// Encode a reference to a message struct. +func (o *Buffer) enc_ref_struct_message(p *Properties, base structPointer) error { + var state errorState + structp := structPointer_GetRefStructPointer(base, p.field) + if structPointer_IsNil(structp) { + return ErrNil + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, err := m.Marshal() + if err != nil && !state.shouldContinue(err, nil) { + return err + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(data) + return nil + } + + o.buf = append(o.buf, p.tagcode...) + return o.enc_len_struct(p.sprop, structp, &state) +} + +//TODO this is only copied, please fix this +func size_ref_struct_message(p *Properties, base structPointer) int { + structp := structPointer_GetRefStructPointer(base, p.field) + if structPointer_IsNil(structp) { + return 0 + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, _ := m.Marshal() + n0 := len(p.tagcode) + n1 := sizeRawBytes(data) + return n0 + n1 + } + + n0 := len(p.tagcode) + n1 := size_struct(p.sprop, structp) + n2 := sizeVarint(uint64(n1)) // size of encoded length + return n0 + n1 + n2 +} + +// Encode a slice of references to message struct pointers ([]struct). +func (o *Buffer) enc_slice_ref_struct_message(p *Properties, base structPointer) error { + var state errorState + ss := structPointer_GetStructPointer(base, p.field) + ss1 := structPointer_GetRefStructPointer(ss, field(0)) + size := p.stype.Size() + l := structPointer_Len(base, p.field) + for i := 0; i < l; i++ { + structp := structPointer_Add(ss1, field(uintptr(i)*size)) + if structPointer_IsNil(structp) { + return errRepeatedHasNil + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, err := m.Marshal() + if err != nil && !state.shouldContinue(err, nil) { + return err + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(data) + continue + } + + o.buf = append(o.buf, p.tagcode...) + err := o.enc_len_struct(p.sprop, structp, &state) + if err != nil && !state.shouldContinue(err, nil) { + if err == ErrNil { + return errRepeatedHasNil + } + return err + } + + } + return state.err +} + +//TODO this is only copied, please fix this +func size_slice_ref_struct_message(p *Properties, base structPointer) (n int) { + ss := structPointer_GetStructPointer(base, p.field) + ss1 := structPointer_GetRefStructPointer(ss, field(0)) + size := p.stype.Size() + l := structPointer_Len(base, p.field) + n += l * len(p.tagcode) + for i := 0; i < l; i++ { + structp := structPointer_Add(ss1, field(uintptr(i)*size)) + if structPointer_IsNil(structp) { + return // return the size up to this point + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, _ := m.Marshal() + n += len(p.tagcode) + n += sizeRawBytes(data) + continue + } + + n0 := size_struct(p.sprop, structp) + n1 := sizeVarint(uint64(n0)) // size of encoded length + n += n0 + n1 + } + return +} + +func (o *Buffer) enc_custom_bytes(p *Properties, base structPointer) error { + i := structPointer_InterfaceRef(base, p.field, p.ctype) + if i == nil { + return ErrNil + } + custom := i.(Marshaler) + data, err := custom.Marshal() + if err != nil { + return err + } + if data == nil { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(data) + return nil +} + +func size_custom_bytes(p *Properties, base structPointer) (n int) { + n += len(p.tagcode) + i := structPointer_InterfaceRef(base, p.field, p.ctype) + if i == nil { + return 0 + } + custom := i.(Marshaler) + data, _ := custom.Marshal() + n += sizeRawBytes(data) + return +} + +func (o *Buffer) enc_custom_ref_bytes(p *Properties, base structPointer) error { + custom := structPointer_InterfaceAt(base, p.field, p.ctype).(Marshaler) + data, err := custom.Marshal() + if err != nil { + return err + } + if data == nil { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(data) + return nil +} + +func size_custom_ref_bytes(p *Properties, base structPointer) (n int) { + n += len(p.tagcode) + i := structPointer_InterfaceAt(base, p.field, p.ctype) + if i == nil { + return 0 + } + custom := i.(Marshaler) + data, _ := custom.Marshal() + n += sizeRawBytes(data) + return +} + +func (o *Buffer) enc_custom_slice_bytes(p *Properties, base structPointer) error { + inter := structPointer_InterfaceRef(base, p.field, p.ctype) + if inter == nil { + return ErrNil + } + slice := reflect.ValueOf(inter) + l := slice.Len() + for i := 0; i < l; i++ { + v := slice.Index(i) + custom := v.Interface().(Marshaler) + data, err := custom.Marshal() + if err != nil { + return err + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(data) + } + return nil +} + +func size_custom_slice_bytes(p *Properties, base structPointer) (n int) { + inter := structPointer_InterfaceRef(base, p.field, p.ctype) + if inter == nil { + return 0 + } + slice := reflect.ValueOf(inter) + l := slice.Len() + n += l * len(p.tagcode) + for i := 0; i < l; i++ { + v := slice.Index(i) + custom := v.Interface().(Marshaler) + data, _ := custom.Marshal() + n += sizeRawBytes(data) + } + return +} diff --git a/vendor/github.com/gogo/protobuf/proto/equal.go b/vendor/github.com/gogo/protobuf/proto/equal.go new file mode 100644 index 0000000000..f5db1def3c --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/equal.go @@ -0,0 +1,276 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2011 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +// Protocol buffer comparison. + +package proto + +import ( + "bytes" + "log" + "reflect" + "strings" +) + +/* +Equal returns true iff protocol buffers a and b are equal. +The arguments must both be pointers to protocol buffer structs. + +Equality is defined in this way: + - Two messages are equal iff they are the same type, + corresponding fields are equal, unknown field sets + are equal, and extensions sets are equal. + - Two set scalar fields are equal iff their values are equal. + If the fields are of a floating-point type, remember that + NaN != x for all x, including NaN. If the message is defined + in a proto3 .proto file, fields are not "set"; specifically, + zero length proto3 "bytes" fields are equal (nil == {}). + - Two repeated fields are equal iff their lengths are the same, + and their corresponding elements are equal (a "bytes" field, + although represented by []byte, is not a repeated field) + - Two unset fields are equal. + - Two unknown field sets are equal if their current + encoded state is equal. + - Two extension sets are equal iff they have corresponding + elements that are pairwise equal. + - Every other combination of things are not equal. + +The return value is undefined if a and b are not protocol buffers. +*/ +func Equal(a, b Message) bool { + if a == nil || b == nil { + return a == b + } + v1, v2 := reflect.ValueOf(a), reflect.ValueOf(b) + if v1.Type() != v2.Type() { + return false + } + if v1.Kind() == reflect.Ptr { + if v1.IsNil() { + return v2.IsNil() + } + if v2.IsNil() { + return false + } + v1, v2 = v1.Elem(), v2.Elem() + } + if v1.Kind() != reflect.Struct { + return false + } + return equalStruct(v1, v2) +} + +// v1 and v2 are known to have the same type. +func equalStruct(v1, v2 reflect.Value) bool { + sprop := GetProperties(v1.Type()) + for i := 0; i < v1.NumField(); i++ { + f := v1.Type().Field(i) + if strings.HasPrefix(f.Name, "XXX_") { + continue + } + f1, f2 := v1.Field(i), v2.Field(i) + if f.Type.Kind() == reflect.Ptr { + if n1, n2 := f1.IsNil(), f2.IsNil(); n1 && n2 { + // both unset + continue + } else if n1 != n2 { + // set/unset mismatch + return false + } + b1, ok := f1.Interface().(raw) + if ok { + b2 := f2.Interface().(raw) + // RawMessage + if !bytes.Equal(b1.Bytes(), b2.Bytes()) { + return false + } + continue + } + f1, f2 = f1.Elem(), f2.Elem() + } + if !equalAny(f1, f2, sprop.Prop[i]) { + return false + } + } + + if em1 := v1.FieldByName("XXX_extensions"); em1.IsValid() { + em2 := v2.FieldByName("XXX_extensions") + if !equalExtensions(v1.Type(), em1.Interface().(map[int32]Extension), em2.Interface().(map[int32]Extension)) { + return false + } + } + + uf := v1.FieldByName("XXX_unrecognized") + if !uf.IsValid() { + return true + } + + u1 := uf.Bytes() + u2 := v2.FieldByName("XXX_unrecognized").Bytes() + if !bytes.Equal(u1, u2) { + return false + } + + return true +} + +// v1 and v2 are known to have the same type. +// prop may be nil. +func equalAny(v1, v2 reflect.Value, prop *Properties) bool { + if v1.Type() == protoMessageType { + m1, _ := v1.Interface().(Message) + m2, _ := v2.Interface().(Message) + return Equal(m1, m2) + } + switch v1.Kind() { + case reflect.Bool: + return v1.Bool() == v2.Bool() + case reflect.Float32, reflect.Float64: + return v1.Float() == v2.Float() + case reflect.Int32, reflect.Int64: + return v1.Int() == v2.Int() + case reflect.Interface: + // Probably a oneof field; compare the inner values. + n1, n2 := v1.IsNil(), v2.IsNil() + if n1 || n2 { + return n1 == n2 + } + e1, e2 := v1.Elem(), v2.Elem() + if e1.Type() != e2.Type() { + return false + } + return equalAny(e1, e2, nil) + case reflect.Map: + if v1.Len() != v2.Len() { + return false + } + for _, key := range v1.MapKeys() { + val2 := v2.MapIndex(key) + if !val2.IsValid() { + // This key was not found in the second map. + return false + } + if !equalAny(v1.MapIndex(key), val2, nil) { + return false + } + } + return true + case reflect.Ptr: + return equalAny(v1.Elem(), v2.Elem(), prop) + case reflect.Slice: + if v1.Type().Elem().Kind() == reflect.Uint8 { + // short circuit: []byte + + // Edge case: if this is in a proto3 message, a zero length + // bytes field is considered the zero value. + if prop != nil && prop.proto3 && v1.Len() == 0 && v2.Len() == 0 { + return true + } + if v1.IsNil() != v2.IsNil() { + return false + } + return bytes.Equal(v1.Interface().([]byte), v2.Interface().([]byte)) + } + + if v1.Len() != v2.Len() { + return false + } + for i := 0; i < v1.Len(); i++ { + if !equalAny(v1.Index(i), v2.Index(i), prop) { + return false + } + } + return true + case reflect.String: + return v1.Interface().(string) == v2.Interface().(string) + case reflect.Struct: + return equalStruct(v1, v2) + case reflect.Uint32, reflect.Uint64: + return v1.Uint() == v2.Uint() + } + + // unknown type, so not a protocol buffer + log.Printf("proto: don't know how to compare %v", v1) + return false +} + +// base is the struct type that the extensions are based on. +// em1 and em2 are extension maps. +func equalExtensions(base reflect.Type, em1, em2 map[int32]Extension) bool { + if len(em1) != len(em2) { + return false + } + + for extNum, e1 := range em1 { + e2, ok := em2[extNum] + if !ok { + return false + } + + m1, m2 := e1.value, e2.value + + if m1 != nil && m2 != nil { + // Both are unencoded. + if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2), nil) { + return false + } + continue + } + + // At least one is encoded. To do a semantically correct comparison + // we need to unmarshal them first. + var desc *ExtensionDesc + if m := extensionMaps[base]; m != nil { + desc = m[extNum] + } + if desc == nil { + log.Printf("proto: don't know how to compare extension %d of %v", extNum, base) + continue + } + var err error + if m1 == nil { + m1, err = decodeExtension(e1.enc, desc) + } + if m2 == nil && err == nil { + m2, err = decodeExtension(e2.enc, desc) + } + if err != nil { + // The encoded form is invalid. + log.Printf("proto: badly encoded extension %d of %v: %v", extNum, base, err) + return false + } + if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2), nil) { + return false + } + } + + return true +} diff --git a/vendor/github.com/gogo/protobuf/proto/extensions.go b/vendor/github.com/gogo/protobuf/proto/extensions.go new file mode 100644 index 0000000000..6180347e39 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/extensions.go @@ -0,0 +1,518 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +package proto + +/* + * Types and routines for supporting protocol buffer extensions. + */ + +import ( + "errors" + "fmt" + "reflect" + "strconv" + "sync" +) + +// ErrMissingExtension is the error returned by GetExtension if the named extension is not in the message. +var ErrMissingExtension = errors.New("proto: missing extension") + +// ExtensionRange represents a range of message extensions for a protocol buffer. +// Used in code generated by the protocol compiler. +type ExtensionRange struct { + Start, End int32 // both inclusive +} + +// extendableProto is an interface implemented by any protocol buffer that may be extended. +type extendableProto interface { + Message + ExtensionRangeArray() []ExtensionRange +} + +type extensionsMap interface { + extendableProto + ExtensionMap() map[int32]Extension +} + +type extensionsBytes interface { + extendableProto + GetExtensions() *[]byte +} + +var extendableProtoType = reflect.TypeOf((*extendableProto)(nil)).Elem() + +// ExtensionDesc represents an extension specification. +// Used in generated code from the protocol compiler. +type ExtensionDesc struct { + ExtendedType Message // nil pointer to the type that is being extended + ExtensionType interface{} // nil pointer to the extension type + Field int32 // field number + Name string // fully-qualified name of extension, for text formatting + Tag string // protobuf tag style +} + +func (ed *ExtensionDesc) repeated() bool { + t := reflect.TypeOf(ed.ExtensionType) + return t.Kind() == reflect.Slice && t.Elem().Kind() != reflect.Uint8 +} + +// Extension represents an extension in a message. +type Extension struct { + // When an extension is stored in a message using SetExtension + // only desc and value are set. When the message is marshaled + // enc will be set to the encoded form of the message. + // + // When a message is unmarshaled and contains extensions, each + // extension will have only enc set. When such an extension is + // accessed using GetExtension (or GetExtensions) desc and value + // will be set. + desc *ExtensionDesc + value interface{} + enc []byte +} + +// SetRawExtension is for testing only. +func SetRawExtension(base extendableProto, id int32, b []byte) { + if ebase, ok := base.(extensionsMap); ok { + ebase.ExtensionMap()[id] = Extension{enc: b} + } else if ebase, ok := base.(extensionsBytes); ok { + clearExtension(base, id) + ext := ebase.GetExtensions() + *ext = append(*ext, b...) + } else { + panic("unreachable") + } +} + +// isExtensionField returns true iff the given field number is in an extension range. +func isExtensionField(pb extendableProto, field int32) bool { + for _, er := range pb.ExtensionRangeArray() { + if er.Start <= field && field <= er.End { + return true + } + } + return false +} + +// checkExtensionTypes checks that the given extension is valid for pb. +func checkExtensionTypes(pb extendableProto, extension *ExtensionDesc) error { + // Check the extended type. + if a, b := reflect.TypeOf(pb), reflect.TypeOf(extension.ExtendedType); a != b { + return errors.New("proto: bad extended type; " + b.String() + " does not extend " + a.String()) + } + // Check the range. + if !isExtensionField(pb, extension.Field) { + return errors.New("proto: bad extension number; not in declared ranges") + } + return nil +} + +// extPropKey is sufficient to uniquely identify an extension. +type extPropKey struct { + base reflect.Type + field int32 +} + +var extProp = struct { + sync.RWMutex + m map[extPropKey]*Properties +}{ + m: make(map[extPropKey]*Properties), +} + +func extensionProperties(ed *ExtensionDesc) *Properties { + key := extPropKey{base: reflect.TypeOf(ed.ExtendedType), field: ed.Field} + + extProp.RLock() + if prop, ok := extProp.m[key]; ok { + extProp.RUnlock() + return prop + } + extProp.RUnlock() + + extProp.Lock() + defer extProp.Unlock() + // Check again. + if prop, ok := extProp.m[key]; ok { + return prop + } + + prop := new(Properties) + prop.Init(reflect.TypeOf(ed.ExtensionType), "unknown_name", ed.Tag, nil) + extProp.m[key] = prop + return prop +} + +// encodeExtensionMap encodes any unmarshaled (unencoded) extensions in m. +func encodeExtensionMap(m map[int32]Extension) error { + for k, e := range m { + err := encodeExtension(&e) + if err != nil { + return err + } + m[k] = e + } + return nil +} + +func encodeExtension(e *Extension) error { + if e.value == nil || e.desc == nil { + // Extension is only in its encoded form. + return nil + } + // We don't skip extensions that have an encoded form set, + // because the extension value may have been mutated after + // the last time this function was called. + + et := reflect.TypeOf(e.desc.ExtensionType) + props := extensionProperties(e.desc) + + p := NewBuffer(nil) + // If e.value has type T, the encoder expects a *struct{ X T }. + // Pass a *T with a zero field and hope it all works out. + x := reflect.New(et) + x.Elem().Set(reflect.ValueOf(e.value)) + if err := props.enc(p, props, toStructPointer(x)); err != nil { + return err + } + e.enc = p.buf + return nil +} + +func sizeExtensionMap(m map[int32]Extension) (n int) { + for _, e := range m { + if e.value == nil || e.desc == nil { + // Extension is only in its encoded form. + n += len(e.enc) + continue + } + + // We don't skip extensions that have an encoded form set, + // because the extension value may have been mutated after + // the last time this function was called. + + et := reflect.TypeOf(e.desc.ExtensionType) + props := extensionProperties(e.desc) + + // If e.value has type T, the encoder expects a *struct{ X T }. + // Pass a *T with a zero field and hope it all works out. + x := reflect.New(et) + x.Elem().Set(reflect.ValueOf(e.value)) + n += props.size(props, toStructPointer(x)) + } + return +} + +// HasExtension returns whether the given extension is present in pb. +func HasExtension(pb extendableProto, extension *ExtensionDesc) bool { + // TODO: Check types, field numbers, etc.? + if epb, doki := pb.(extensionsMap); doki { + _, ok := epb.ExtensionMap()[extension.Field] + return ok + } else if epb, doki := pb.(extensionsBytes); doki { + ext := epb.GetExtensions() + buf := *ext + o := 0 + for o < len(buf) { + tag, n := DecodeVarint(buf[o:]) + fieldNum := int32(tag >> 3) + if int32(fieldNum) == extension.Field { + return true + } + wireType := int(tag & 0x7) + o += n + l, err := size(buf[o:], wireType) + if err != nil { + return false + } + o += l + } + return false + } + panic("unreachable") +} + +func deleteExtension(pb extensionsBytes, theFieldNum int32, offset int) int { + ext := pb.GetExtensions() + for offset < len(*ext) { + tag, n1 := DecodeVarint((*ext)[offset:]) + fieldNum := int32(tag >> 3) + wireType := int(tag & 0x7) + n2, err := size((*ext)[offset+n1:], wireType) + if err != nil { + panic(err) + } + newOffset := offset + n1 + n2 + if fieldNum == theFieldNum { + *ext = append((*ext)[:offset], (*ext)[newOffset:]...) + return offset + } + offset = newOffset + } + return -1 +} + +func clearExtension(pb extendableProto, fieldNum int32) { + if epb, doki := pb.(extensionsMap); doki { + delete(epb.ExtensionMap(), fieldNum) + } else if epb, doki := pb.(extensionsBytes); doki { + offset := 0 + for offset != -1 { + offset = deleteExtension(epb, fieldNum, offset) + } + } else { + panic("unreachable") + } +} + +// ClearExtension removes the given extension from pb. +func ClearExtension(pb extendableProto, extension *ExtensionDesc) { + // TODO: Check types, field numbers, etc.? + clearExtension(pb, extension.Field) +} + +// GetExtension parses and returns the given extension of pb. +// If the extension is not present it returns ErrMissingExtension. +func GetExtension(pb extendableProto, extension *ExtensionDesc) (interface{}, error) { + if err := checkExtensionTypes(pb, extension); err != nil { + return nil, err + } + + if epb, doki := pb.(extensionsMap); doki { + emap := epb.ExtensionMap() + e, ok := emap[extension.Field] + if !ok { + // defaultExtensionValue returns the default value or + // ErrMissingExtension if there is no default. + return defaultExtensionValue(extension) + } + if e.value != nil { + // Already decoded. Check the descriptor, though. + if e.desc != extension { + // This shouldn't happen. If it does, it means that + // GetExtension was called twice with two different + // descriptors with the same field number. + return nil, errors.New("proto: descriptor conflict") + } + return e.value, nil + } + + v, err := decodeExtension(e.enc, extension) + if err != nil { + return nil, err + } + + // Remember the decoded version and drop the encoded version. + // That way it is safe to mutate what we return. + e.value = v + e.desc = extension + e.enc = nil + emap[extension.Field] = e + return e.value, nil + } else if epb, doki := pb.(extensionsBytes); doki { + ext := epb.GetExtensions() + o := 0 + for o < len(*ext) { + tag, n := DecodeVarint((*ext)[o:]) + fieldNum := int32(tag >> 3) + wireType := int(tag & 0x7) + l, err := size((*ext)[o+n:], wireType) + if err != nil { + return nil, err + } + if int32(fieldNum) == extension.Field { + v, err := decodeExtension((*ext)[o:o+n+l], extension) + if err != nil { + return nil, err + } + return v, nil + } + o += n + l + } + return defaultExtensionValue(extension) + } + panic("unreachable") +} + +// defaultExtensionValue returns the default value for extension. +// If no default for an extension is defined ErrMissingExtension is returned. +func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) { + t := reflect.TypeOf(extension.ExtensionType) + props := extensionProperties(extension) + + sf, _, err := fieldDefault(t, props) + if err != nil { + return nil, err + } + + if sf == nil || sf.value == nil { + // There is no default value. + return nil, ErrMissingExtension + } + + if t.Kind() != reflect.Ptr { + // We do not need to return a Ptr, we can directly return sf.value. + return sf.value, nil + } + + // We need to return an interface{} that is a pointer to sf.value. + value := reflect.New(t).Elem() + value.Set(reflect.New(value.Type().Elem())) + if sf.kind == reflect.Int32 { + // We may have an int32 or an enum, but the underlying data is int32. + // Since we can't set an int32 into a non int32 reflect.value directly + // set it as a int32. + value.Elem().SetInt(int64(sf.value.(int32))) + } else { + value.Elem().Set(reflect.ValueOf(sf.value)) + } + return value.Interface(), nil +} + +// decodeExtension decodes an extension encoded in b. +func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) { + o := NewBuffer(b) + + t := reflect.TypeOf(extension.ExtensionType) + + props := extensionProperties(extension) + + // t is a pointer to a struct, pointer to basic type or a slice. + // Allocate a "field" to store the pointer/slice itself; the + // pointer/slice will be stored here. We pass + // the address of this field to props.dec. + // This passes a zero field and a *t and lets props.dec + // interpret it as a *struct{ x t }. + value := reflect.New(t).Elem() + + for { + // Discard wire type and field number varint. It isn't needed. + if _, err := o.DecodeVarint(); err != nil { + return nil, err + } + + if err := props.dec(o, props, toStructPointer(value.Addr())); err != nil { + return nil, err + } + + if o.index >= len(o.buf) { + break + } + } + return value.Interface(), nil +} + +// GetExtensions returns a slice of the extensions present in pb that are also listed in es. +// The returned slice has the same length as es; missing extensions will appear as nil elements. +func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, err error) { + epb, ok := pb.(extendableProto) + if !ok { + err = errors.New("proto: not an extendable proto") + return + } + extensions = make([]interface{}, len(es)) + for i, e := range es { + extensions[i], err = GetExtension(epb, e) + if err == ErrMissingExtension { + err = nil + } + if err != nil { + return + } + } + return +} + +// SetExtension sets the specified extension of pb to the specified value. +func SetExtension(pb extendableProto, extension *ExtensionDesc, value interface{}) error { + if err := checkExtensionTypes(pb, extension); err != nil { + return err + } + typ := reflect.TypeOf(extension.ExtensionType) + if typ != reflect.TypeOf(value) { + return errors.New("proto: bad extension value type") + } + // nil extension values need to be caught early, because the + // encoder can't distinguish an ErrNil due to a nil extension + // from an ErrNil due to a missing field. Extensions are + // always optional, so the encoder would just swallow the error + // and drop all the extensions from the encoded message. + if reflect.ValueOf(value).IsNil() { + return fmt.Errorf("proto: SetExtension called with nil value of type %T", value) + } + return setExtension(pb, extension, value) +} + +func setExtension(pb extendableProto, extension *ExtensionDesc, value interface{}) error { + if epb, doki := pb.(extensionsMap); doki { + epb.ExtensionMap()[extension.Field] = Extension{desc: extension, value: value} + } else if epb, doki := pb.(extensionsBytes); doki { + ClearExtension(pb, extension) + ext := epb.GetExtensions() + et := reflect.TypeOf(extension.ExtensionType) + props := extensionProperties(extension) + p := NewBuffer(nil) + x := reflect.New(et) + x.Elem().Set(reflect.ValueOf(value)) + if err := props.enc(p, props, toStructPointer(x)); err != nil { + return err + } + *ext = append(*ext, p.buf...) + } + return nil +} + +// A global registry of extensions. +// The generated code will register the generated descriptors by calling RegisterExtension. + +var extensionMaps = make(map[reflect.Type]map[int32]*ExtensionDesc) + +// RegisterExtension is called from the generated code. +func RegisterExtension(desc *ExtensionDesc) { + st := reflect.TypeOf(desc.ExtendedType).Elem() + m := extensionMaps[st] + if m == nil { + m = make(map[int32]*ExtensionDesc) + extensionMaps[st] = m + } + if _, ok := m[desc.Field]; ok { + panic("proto: duplicate extension registered: " + st.String() + " " + strconv.Itoa(int(desc.Field))) + } + m[desc.Field] = desc +} + +// RegisteredExtensions returns a map of the registered extensions of a +// protocol buffer struct, indexed by the extension number. +// The argument pb should be a nil pointer to the struct type. +func RegisteredExtensions(pb Message) map[int32]*ExtensionDesc { + return extensionMaps[reflect.TypeOf(pb).Elem()] +} diff --git a/vendor/github.com/gogo/protobuf/proto/extensions_gogo.go b/vendor/github.com/gogo/protobuf/proto/extensions_gogo.go new file mode 100644 index 0000000000..bd55fb68b6 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/extensions_gogo.go @@ -0,0 +1,221 @@ +// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. +// http://github.com/gogo/protobuf/gogoproto +// +// 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. +// +// 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. + +package proto + +import ( + "bytes" + "errors" + "fmt" + "reflect" + "sort" + "strings" +) + +func GetBoolExtension(pb extendableProto, extension *ExtensionDesc, ifnotset bool) bool { + if reflect.ValueOf(pb).IsNil() { + return ifnotset + } + value, err := GetExtension(pb, extension) + if err != nil { + return ifnotset + } + if value == nil { + return ifnotset + } + if value.(*bool) == nil { + return ifnotset + } + return *(value.(*bool)) +} + +func (this *Extension) Equal(that *Extension) bool { + return bytes.Equal(this.enc, that.enc) +} + +func SizeOfExtensionMap(m map[int32]Extension) (n int) { + return sizeExtensionMap(m) +} + +type sortableMapElem struct { + field int32 + ext Extension +} + +func newSortableExtensionsFromMap(m map[int32]Extension) sortableExtensions { + s := make(sortableExtensions, 0, len(m)) + for k, v := range m { + s = append(s, &sortableMapElem{field: k, ext: v}) + } + return s +} + +type sortableExtensions []*sortableMapElem + +func (this sortableExtensions) Len() int { return len(this) } + +func (this sortableExtensions) Swap(i, j int) { this[i], this[j] = this[j], this[i] } + +func (this sortableExtensions) Less(i, j int) bool { return this[i].field < this[j].field } + +func (this sortableExtensions) String() string { + sort.Sort(this) + ss := make([]string, len(this)) + for i := range this { + ss[i] = fmt.Sprintf("%d: %v", this[i].field, this[i].ext) + } + return "map[" + strings.Join(ss, ",") + "]" +} + +func StringFromExtensionsMap(m map[int32]Extension) string { + return newSortableExtensionsFromMap(m).String() +} + +func StringFromExtensionsBytes(ext []byte) string { + m, err := BytesToExtensionsMap(ext) + if err != nil { + panic(err) + } + return StringFromExtensionsMap(m) +} + +func EncodeExtensionMap(m map[int32]Extension, data []byte) (n int, err error) { + if err := encodeExtensionMap(m); err != nil { + return 0, err + } + keys := make([]int, 0, len(m)) + for k := range m { + keys = append(keys, int(k)) + } + sort.Ints(keys) + for _, k := range keys { + n += copy(data[n:], m[int32(k)].enc) + } + return n, nil +} + +func GetRawExtension(m map[int32]Extension, id int32) ([]byte, error) { + if m[id].value == nil || m[id].desc == nil { + return m[id].enc, nil + } + if err := encodeExtensionMap(m); err != nil { + return nil, err + } + return m[id].enc, nil +} + +func size(buf []byte, wire int) (int, error) { + switch wire { + case WireVarint: + _, n := DecodeVarint(buf) + return n, nil + case WireFixed64: + return 8, nil + case WireBytes: + v, n := DecodeVarint(buf) + return int(v) + n, nil + case WireFixed32: + return 4, nil + case WireStartGroup: + offset := 0 + for { + u, n := DecodeVarint(buf[offset:]) + fwire := int(u & 0x7) + offset += n + if fwire == WireEndGroup { + return offset, nil + } + s, err := size(buf[offset:], wire) + if err != nil { + return 0, err + } + offset += s + } + } + return 0, fmt.Errorf("proto: can't get size for unknown wire type %d", wire) +} + +func BytesToExtensionsMap(buf []byte) (map[int32]Extension, error) { + m := make(map[int32]Extension) + i := 0 + for i < len(buf) { + tag, n := DecodeVarint(buf[i:]) + if n <= 0 { + return nil, fmt.Errorf("unable to decode varint") + } + fieldNum := int32(tag >> 3) + wireType := int(tag & 0x7) + l, err := size(buf[i+n:], wireType) + if err != nil { + return nil, err + } + end := i + int(l) + n + m[int32(fieldNum)] = Extension{enc: buf[i:end]} + i = end + } + return m, nil +} + +func NewExtension(e []byte) Extension { + ee := Extension{enc: make([]byte, len(e))} + copy(ee.enc, e) + return ee +} + +func (this Extension) GoString() string { + if this.enc == nil { + if err := encodeExtension(&this); err != nil { + panic(err) + } + } + return fmt.Sprintf("proto.NewExtension(%#v)", this.enc) +} + +func SetUnsafeExtension(pb extendableProto, fieldNum int32, value interface{}) error { + typ := reflect.TypeOf(pb).Elem() + ext, ok := extensionMaps[typ] + if !ok { + return fmt.Errorf("proto: bad extended type; %s is not extendable", typ.String()) + } + desc, ok := ext[fieldNum] + if !ok { + return errors.New("proto: bad extension number; not in declared ranges") + } + return setExtension(pb, desc, value) +} + +func GetUnsafeExtension(pb extendableProto, fieldNum int32) (interface{}, error) { + typ := reflect.TypeOf(pb).Elem() + ext, ok := extensionMaps[typ] + if !ok { + return nil, fmt.Errorf("proto: bad extended type; %s is not extendable", typ.String()) + } + desc, ok := ext[fieldNum] + if !ok { + return nil, fmt.Errorf("unregistered field number %d", fieldNum) + } + return GetExtension(pb, desc) +} diff --git a/vendor/github.com/gogo/protobuf/proto/lib.go b/vendor/github.com/gogo/protobuf/proto/lib.go new file mode 100644 index 0000000000..2e35ae2d2a --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/lib.go @@ -0,0 +1,894 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +/* +Package proto converts data structures to and from the wire format of +protocol buffers. It works in concert with the Go source code generated +for .proto files by the protocol compiler. + +A summary of the properties of the protocol buffer interface +for a protocol buffer variable v: + + - Names are turned from camel_case to CamelCase for export. + - There are no methods on v to set fields; just treat + them as structure fields. + - There are getters that return a field's value if set, + and return the field's default value if unset. + The getters work even if the receiver is a nil message. + - The zero value for a struct is its correct initialization state. + All desired fields must be set before marshaling. + - A Reset() method will restore a protobuf struct to its zero state. + - Non-repeated fields are pointers to the values; nil means unset. + That is, optional or required field int32 f becomes F *int32. + - Repeated fields are slices. + - Helper functions are available to aid the setting of fields. + msg.Foo = proto.String("hello") // set field + - Constants are defined to hold the default values of all fields that + have them. They have the form Default_StructName_FieldName. + Because the getter methods handle defaulted values, + direct use of these constants should be rare. + - Enums are given type names and maps from names to values. + Enum values are prefixed by the enclosing message's name, or by the + enum's type name if it is a top-level enum. Enum types have a String + method, and a Enum method to assist in message construction. + - Nested messages, groups and enums have type names prefixed with the name of + the surrounding message type. + - Extensions are given descriptor names that start with E_, + followed by an underscore-delimited list of the nested messages + that contain it (if any) followed by the CamelCased name of the + extension field itself. HasExtension, ClearExtension, GetExtension + and SetExtension are functions for manipulating extensions. + - Oneof field sets are given a single field in their message, + with distinguished wrapper types for each possible field value. + - Marshal and Unmarshal are functions to encode and decode the wire format. + +When the .proto file specifies `syntax="proto3"`, there are some differences: + + - Non-repeated fields of non-message type are values instead of pointers. + - Getters are only generated for message and oneof fields. + - Enum types do not get an Enum method. + +The simplest way to describe this is to see an example. +Given file test.proto, containing + + package example; + + enum FOO { X = 17; } + + message Test { + required string label = 1; + optional int32 type = 2 [default=77]; + repeated int64 reps = 3; + optional group OptionalGroup = 4 { + required string RequiredField = 5; + } + oneof union { + int32 number = 6; + string name = 7; + } + } + +The resulting file, test.pb.go, is: + + package example + + import proto "github.com/gogo/protobuf/proto" + import math "math" + + type FOO int32 + const ( + FOO_X FOO = 17 + ) + var FOO_name = map[int32]string{ + 17: "X", + } + var FOO_value = map[string]int32{ + "X": 17, + } + + func (x FOO) Enum() *FOO { + p := new(FOO) + *p = x + return p + } + func (x FOO) String() string { + return proto.EnumName(FOO_name, int32(x)) + } + func (x *FOO) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(FOO_value, data) + if err != nil { + return err + } + *x = FOO(value) + return nil + } + + type Test struct { + Label *string `protobuf:"bytes,1,req,name=label" json:"label,omitempty"` + Type *int32 `protobuf:"varint,2,opt,name=type,def=77" json:"type,omitempty"` + Reps []int64 `protobuf:"varint,3,rep,name=reps" json:"reps,omitempty"` + Optionalgroup *Test_OptionalGroup `protobuf:"group,4,opt,name=OptionalGroup" json:"optionalgroup,omitempty"` + // Types that are valid to be assigned to Union: + // *Test_Number + // *Test_Name + Union isTest_Union `protobuf_oneof:"union"` + XXX_unrecognized []byte `json:"-"` + } + func (m *Test) Reset() { *m = Test{} } + func (m *Test) String() string { return proto.CompactTextString(m) } + func (*Test) ProtoMessage() {} + + type isTest_Union interface { + isTest_Union() + } + + type Test_Number struct { + Number int32 `protobuf:"varint,6,opt,name=number"` + } + type Test_Name struct { + Name string `protobuf:"bytes,7,opt,name=name"` + } + + func (*Test_Number) isTest_Union() {} + func (*Test_Name) isTest_Union() {} + + func (m *Test) GetUnion() isTest_Union { + if m != nil { + return m.Union + } + return nil + } + const Default_Test_Type int32 = 77 + + func (m *Test) GetLabel() string { + if m != nil && m.Label != nil { + return *m.Label + } + return "" + } + + func (m *Test) GetType() int32 { + if m != nil && m.Type != nil { + return *m.Type + } + return Default_Test_Type + } + + func (m *Test) GetOptionalgroup() *Test_OptionalGroup { + if m != nil { + return m.Optionalgroup + } + return nil + } + + type Test_OptionalGroup struct { + RequiredField *string `protobuf:"bytes,5,req" json:"RequiredField,omitempty"` + } + func (m *Test_OptionalGroup) Reset() { *m = Test_OptionalGroup{} } + func (m *Test_OptionalGroup) String() string { return proto.CompactTextString(m) } + + func (m *Test_OptionalGroup) GetRequiredField() string { + if m != nil && m.RequiredField != nil { + return *m.RequiredField + } + return "" + } + + func (m *Test) GetNumber() int32 { + if x, ok := m.GetUnion().(*Test_Number); ok { + return x.Number + } + return 0 + } + + func (m *Test) GetName() string { + if x, ok := m.GetUnion().(*Test_Name); ok { + return x.Name + } + return "" + } + + func init() { + proto.RegisterEnum("example.FOO", FOO_name, FOO_value) + } + +To create and play with a Test object: + + package main + + import ( + "log" + + "github.com/gogo/protobuf/proto" + pb "./example.pb" + ) + + func main() { + test := &pb.Test{ + Label: proto.String("hello"), + Type: proto.Int32(17), + Reps: []int64{1, 2, 3}, + Optionalgroup: &pb.Test_OptionalGroup{ + RequiredField: proto.String("good bye"), + }, + Union: &pb.Test_Name{"fred"}, + } + data, err := proto.Marshal(test) + if err != nil { + log.Fatal("marshaling error: ", err) + } + newTest := &pb.Test{} + err = proto.Unmarshal(data, newTest) + if err != nil { + log.Fatal("unmarshaling error: ", err) + } + // Now test and newTest contain the same data. + if test.GetLabel() != newTest.GetLabel() { + log.Fatalf("data mismatch %q != %q", test.GetLabel(), newTest.GetLabel()) + } + // Use a type switch to determine which oneof was set. + switch u := test.Union.(type) { + case *pb.Test_Number: // u.Number contains the number. + case *pb.Test_Name: // u.Name contains the string. + } + // etc. + } +*/ +package proto + +import ( + "encoding/json" + "fmt" + "log" + "reflect" + "sort" + "strconv" + "sync" +) + +// Message is implemented by generated protocol buffer messages. +type Message interface { + Reset() + String() string + ProtoMessage() +} + +// Stats records allocation details about the protocol buffer encoders +// and decoders. Useful for tuning the library itself. +type Stats struct { + Emalloc uint64 // mallocs in encode + Dmalloc uint64 // mallocs in decode + Encode uint64 // number of encodes + Decode uint64 // number of decodes + Chit uint64 // number of cache hits + Cmiss uint64 // number of cache misses + Size uint64 // number of sizes +} + +// Set to true to enable stats collection. +const collectStats = false + +var stats Stats + +// GetStats returns a copy of the global Stats structure. +func GetStats() Stats { return stats } + +// A Buffer is a buffer manager for marshaling and unmarshaling +// protocol buffers. It may be reused between invocations to +// reduce memory usage. It is not necessary to use a Buffer; +// the global functions Marshal and Unmarshal create a +// temporary Buffer and are fine for most applications. +type Buffer struct { + buf []byte // encode/decode byte stream + index int // write point + + // pools of basic types to amortize allocation. + bools []bool + uint32s []uint32 + uint64s []uint64 + + // extra pools, only used with pointer_reflect.go + int32s []int32 + int64s []int64 + float32s []float32 + float64s []float64 +} + +// NewBuffer allocates a new Buffer and initializes its internal data to +// the contents of the argument slice. +func NewBuffer(e []byte) *Buffer { + return &Buffer{buf: e} +} + +// Reset resets the Buffer, ready for marshaling a new protocol buffer. +func (p *Buffer) Reset() { + p.buf = p.buf[0:0] // for reading/writing + p.index = 0 // for reading +} + +// SetBuf replaces the internal buffer with the slice, +// ready for unmarshaling the contents of the slice. +func (p *Buffer) SetBuf(s []byte) { + p.buf = s + p.index = 0 +} + +// Bytes returns the contents of the Buffer. +func (p *Buffer) Bytes() []byte { return p.buf } + +/* + * Helper routines for simplifying the creation of optional fields of basic type. + */ + +// Bool is a helper routine that allocates a new bool value +// to store v and returns a pointer to it. +func Bool(v bool) *bool { + return &v +} + +// Int32 is a helper routine that allocates a new int32 value +// to store v and returns a pointer to it. +func Int32(v int32) *int32 { + return &v +} + +// Int is a helper routine that allocates a new int32 value +// to store v and returns a pointer to it, but unlike Int32 +// its argument value is an int. +func Int(v int) *int32 { + p := new(int32) + *p = int32(v) + return p +} + +// Int64 is a helper routine that allocates a new int64 value +// to store v and returns a pointer to it. +func Int64(v int64) *int64 { + return &v +} + +// Float32 is a helper routine that allocates a new float32 value +// to store v and returns a pointer to it. +func Float32(v float32) *float32 { + return &v +} + +// Float64 is a helper routine that allocates a new float64 value +// to store v and returns a pointer to it. +func Float64(v float64) *float64 { + return &v +} + +// Uint32 is a helper routine that allocates a new uint32 value +// to store v and returns a pointer to it. +func Uint32(v uint32) *uint32 { + return &v +} + +// Uint64 is a helper routine that allocates a new uint64 value +// to store v and returns a pointer to it. +func Uint64(v uint64) *uint64 { + return &v +} + +// String is a helper routine that allocates a new string value +// to store v and returns a pointer to it. +func String(v string) *string { + return &v +} + +// EnumName is a helper function to simplify printing protocol buffer enums +// by name. Given an enum map and a value, it returns a useful string. +func EnumName(m map[int32]string, v int32) string { + s, ok := m[v] + if ok { + return s + } + return strconv.Itoa(int(v)) +} + +// UnmarshalJSONEnum is a helper function to simplify recovering enum int values +// from their JSON-encoded representation. Given a map from the enum's symbolic +// names to its int values, and a byte buffer containing the JSON-encoded +// value, it returns an int32 that can be cast to the enum type by the caller. +// +// The function can deal with both JSON representations, numeric and symbolic. +func UnmarshalJSONEnum(m map[string]int32, data []byte, enumName string) (int32, error) { + if data[0] == '"' { + // New style: enums are strings. + var repr string + if err := json.Unmarshal(data, &repr); err != nil { + return -1, err + } + val, ok := m[repr] + if !ok { + return 0, fmt.Errorf("unrecognized enum %s value %q", enumName, repr) + } + return val, nil + } + // Old style: enums are ints. + var val int32 + if err := json.Unmarshal(data, &val); err != nil { + return 0, fmt.Errorf("cannot unmarshal %#q into enum %s", data, enumName) + } + return val, nil +} + +// DebugPrint dumps the encoded data in b in a debugging format with a header +// including the string s. Used in testing but made available for general debugging. +func (p *Buffer) DebugPrint(s string, b []byte) { + var u uint64 + + obuf := p.buf + sindex := p.index + p.buf = b + p.index = 0 + depth := 0 + + fmt.Printf("\n--- %s ---\n", s) + +out: + for { + for i := 0; i < depth; i++ { + fmt.Print(" ") + } + + index := p.index + if index == len(p.buf) { + break + } + + op, err := p.DecodeVarint() + if err != nil { + fmt.Printf("%3d: fetching op err %v\n", index, err) + break out + } + tag := op >> 3 + wire := op & 7 + + switch wire { + default: + fmt.Printf("%3d: t=%3d unknown wire=%d\n", + index, tag, wire) + break out + + case WireBytes: + var r []byte + + r, err = p.DecodeRawBytes(false) + if err != nil { + break out + } + fmt.Printf("%3d: t=%3d bytes [%d]", index, tag, len(r)) + if len(r) <= 6 { + for i := 0; i < len(r); i++ { + fmt.Printf(" %.2x", r[i]) + } + } else { + for i := 0; i < 3; i++ { + fmt.Printf(" %.2x", r[i]) + } + fmt.Printf(" ..") + for i := len(r) - 3; i < len(r); i++ { + fmt.Printf(" %.2x", r[i]) + } + } + fmt.Printf("\n") + + case WireFixed32: + u, err = p.DecodeFixed32() + if err != nil { + fmt.Printf("%3d: t=%3d fix32 err %v\n", index, tag, err) + break out + } + fmt.Printf("%3d: t=%3d fix32 %d\n", index, tag, u) + + case WireFixed64: + u, err = p.DecodeFixed64() + if err != nil { + fmt.Printf("%3d: t=%3d fix64 err %v\n", index, tag, err) + break out + } + fmt.Printf("%3d: t=%3d fix64 %d\n", index, tag, u) + + case WireVarint: + u, err = p.DecodeVarint() + if err != nil { + fmt.Printf("%3d: t=%3d varint err %v\n", index, tag, err) + break out + } + fmt.Printf("%3d: t=%3d varint %d\n", index, tag, u) + + case WireStartGroup: + fmt.Printf("%3d: t=%3d start\n", index, tag) + depth++ + + case WireEndGroup: + depth-- + fmt.Printf("%3d: t=%3d end\n", index, tag) + } + } + + if depth != 0 { + fmt.Printf("%3d: start-end not balanced %d\n", p.index, depth) + } + fmt.Printf("\n") + + p.buf = obuf + p.index = sindex +} + +// SetDefaults sets unset protocol buffer fields to their default values. +// It only modifies fields that are both unset and have defined defaults. +// It recursively sets default values in any non-nil sub-messages. +func SetDefaults(pb Message) { + setDefaults(reflect.ValueOf(pb), true, false) +} + +// v is a pointer to a struct. +func setDefaults(v reflect.Value, recur, zeros bool) { + v = v.Elem() + + defaultMu.RLock() + dm, ok := defaults[v.Type()] + defaultMu.RUnlock() + if !ok { + dm = buildDefaultMessage(v.Type()) + defaultMu.Lock() + defaults[v.Type()] = dm + defaultMu.Unlock() + } + + for _, sf := range dm.scalars { + f := v.Field(sf.index) + if !f.IsNil() { + // field already set + continue + } + dv := sf.value + if dv == nil && !zeros { + // no explicit default, and don't want to set zeros + continue + } + fptr := f.Addr().Interface() // **T + // TODO: Consider batching the allocations we do here. + switch sf.kind { + case reflect.Bool: + b := new(bool) + if dv != nil { + *b = dv.(bool) + } + *(fptr.(**bool)) = b + case reflect.Float32: + f := new(float32) + if dv != nil { + *f = dv.(float32) + } + *(fptr.(**float32)) = f + case reflect.Float64: + f := new(float64) + if dv != nil { + *f = dv.(float64) + } + *(fptr.(**float64)) = f + case reflect.Int32: + // might be an enum + if ft := f.Type(); ft != int32PtrType { + // enum + f.Set(reflect.New(ft.Elem())) + if dv != nil { + f.Elem().SetInt(int64(dv.(int32))) + } + } else { + // int32 field + i := new(int32) + if dv != nil { + *i = dv.(int32) + } + *(fptr.(**int32)) = i + } + case reflect.Int64: + i := new(int64) + if dv != nil { + *i = dv.(int64) + } + *(fptr.(**int64)) = i + case reflect.String: + s := new(string) + if dv != nil { + *s = dv.(string) + } + *(fptr.(**string)) = s + case reflect.Uint8: + // exceptional case: []byte + var b []byte + if dv != nil { + db := dv.([]byte) + b = make([]byte, len(db)) + copy(b, db) + } else { + b = []byte{} + } + *(fptr.(*[]byte)) = b + case reflect.Uint32: + u := new(uint32) + if dv != nil { + *u = dv.(uint32) + } + *(fptr.(**uint32)) = u + case reflect.Uint64: + u := new(uint64) + if dv != nil { + *u = dv.(uint64) + } + *(fptr.(**uint64)) = u + default: + log.Printf("proto: can't set default for field %v (sf.kind=%v)", f, sf.kind) + } + } + + for _, ni := range dm.nested { + f := v.Field(ni) + // f is *T or []*T or map[T]*T + switch f.Kind() { + case reflect.Ptr: + if f.IsNil() { + continue + } + setDefaults(f, recur, zeros) + + case reflect.Slice: + for i := 0; i < f.Len(); i++ { + e := f.Index(i) + if e.IsNil() { + continue + } + setDefaults(e, recur, zeros) + } + + case reflect.Map: + for _, k := range f.MapKeys() { + e := f.MapIndex(k) + if e.IsNil() { + continue + } + setDefaults(e, recur, zeros) + } + } + } +} + +var ( + // defaults maps a protocol buffer struct type to a slice of the fields, + // with its scalar fields set to their proto-declared non-zero default values. + defaultMu sync.RWMutex + defaults = make(map[reflect.Type]defaultMessage) + + int32PtrType = reflect.TypeOf((*int32)(nil)) +) + +// defaultMessage represents information about the default values of a message. +type defaultMessage struct { + scalars []scalarField + nested []int // struct field index of nested messages +} + +type scalarField struct { + index int // struct field index + kind reflect.Kind // element type (the T in *T or []T) + value interface{} // the proto-declared default value, or nil +} + +// t is a struct type. +func buildDefaultMessage(t reflect.Type) (dm defaultMessage) { + sprop := GetProperties(t) + for _, prop := range sprop.Prop { + fi, ok := sprop.decoderTags.get(prop.Tag) + if !ok { + // XXX_unrecognized + continue + } + ft := t.Field(fi).Type + + sf, nested, err := fieldDefault(ft, prop) + switch { + case err != nil: + log.Print(err) + case nested: + dm.nested = append(dm.nested, fi) + case sf != nil: + sf.index = fi + dm.scalars = append(dm.scalars, *sf) + } + } + + return dm +} + +// fieldDefault returns the scalarField for field type ft. +// sf will be nil if the field can not have a default. +// nestedMessage will be true if this is a nested message. +// Note that sf.index is not set on return. +func fieldDefault(ft reflect.Type, prop *Properties) (sf *scalarField, nestedMessage bool, err error) { + var canHaveDefault bool + switch ft.Kind() { + case reflect.Ptr: + if ft.Elem().Kind() == reflect.Struct { + nestedMessage = true + } else { + canHaveDefault = true // proto2 scalar field + } + + case reflect.Slice: + switch ft.Elem().Kind() { + case reflect.Ptr: + nestedMessage = true // repeated message + case reflect.Uint8: + canHaveDefault = true // bytes field + } + + case reflect.Map: + if ft.Elem().Kind() == reflect.Ptr { + nestedMessage = true // map with message values + } + } + + if !canHaveDefault { + if nestedMessage { + return nil, true, nil + } + return nil, false, nil + } + + // We now know that ft is a pointer or slice. + sf = &scalarField{kind: ft.Elem().Kind()} + + // scalar fields without defaults + if !prop.HasDefault { + return sf, false, nil + } + + // a scalar field: either *T or []byte + switch ft.Elem().Kind() { + case reflect.Bool: + x, err := strconv.ParseBool(prop.Default) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default bool %q: %v", prop.Default, err) + } + sf.value = x + case reflect.Float32: + x, err := strconv.ParseFloat(prop.Default, 32) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default float32 %q: %v", prop.Default, err) + } + sf.value = float32(x) + case reflect.Float64: + x, err := strconv.ParseFloat(prop.Default, 64) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default float64 %q: %v", prop.Default, err) + } + sf.value = x + case reflect.Int32: + x, err := strconv.ParseInt(prop.Default, 10, 32) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default int32 %q: %v", prop.Default, err) + } + sf.value = int32(x) + case reflect.Int64: + x, err := strconv.ParseInt(prop.Default, 10, 64) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default int64 %q: %v", prop.Default, err) + } + sf.value = x + case reflect.String: + sf.value = prop.Default + case reflect.Uint8: + // []byte (not *uint8) + sf.value = []byte(prop.Default) + case reflect.Uint32: + x, err := strconv.ParseUint(prop.Default, 10, 32) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default uint32 %q: %v", prop.Default, err) + } + sf.value = uint32(x) + case reflect.Uint64: + x, err := strconv.ParseUint(prop.Default, 10, 64) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default uint64 %q: %v", prop.Default, err) + } + sf.value = x + default: + return nil, false, fmt.Errorf("proto: unhandled def kind %v", ft.Elem().Kind()) + } + + return sf, false, nil +} + +// Map fields may have key types of non-float scalars, strings and enums. +// The easiest way to sort them in some deterministic order is to use fmt. +// If this turns out to be inefficient we can always consider other options, +// such as doing a Schwartzian transform. + +func mapKeys(vs []reflect.Value) sort.Interface { + s := mapKeySorter{ + vs: vs, + // default Less function: textual comparison + less: func(a, b reflect.Value) bool { + return fmt.Sprint(a.Interface()) < fmt.Sprint(b.Interface()) + }, + } + + // Type specialization per https://developers.google.com/protocol-buffers/docs/proto#maps; + // numeric keys are sorted numerically. + if len(vs) == 0 { + return s + } + switch vs[0].Kind() { + case reflect.Int32, reflect.Int64: + s.less = func(a, b reflect.Value) bool { return a.Int() < b.Int() } + case reflect.Uint32, reflect.Uint64: + s.less = func(a, b reflect.Value) bool { return a.Uint() < b.Uint() } + } + + return s +} + +type mapKeySorter struct { + vs []reflect.Value + less func(a, b reflect.Value) bool +} + +func (s mapKeySorter) Len() int { return len(s.vs) } +func (s mapKeySorter) Swap(i, j int) { s.vs[i], s.vs[j] = s.vs[j], s.vs[i] } +func (s mapKeySorter) Less(i, j int) bool { + return s.less(s.vs[i], s.vs[j]) +} + +// isProto3Zero reports whether v is a zero proto3 value. +func isProto3Zero(v reflect.Value) bool { + switch v.Kind() { + case reflect.Bool: + return !v.Bool() + case reflect.Int32, reflect.Int64: + return v.Int() == 0 + case reflect.Uint32, reflect.Uint64: + return v.Uint() == 0 + case reflect.Float32, reflect.Float64: + return v.Float() == 0 + case reflect.String: + return v.String() == "" + } + return false +} + +// ProtoPackageIsVersion1 is referenced from generated protocol buffer files +// to assert that that code is compatible with this version of the proto package. +const GoGoProtoPackageIsVersion1 = true diff --git a/vendor/github.com/gogo/protobuf/proto/lib_gogo.go b/vendor/github.com/gogo/protobuf/proto/lib_gogo.go new file mode 100644 index 0000000000..a6c2c06b23 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/lib_gogo.go @@ -0,0 +1,40 @@ +// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. +// http://github.com/gogo/protobuf/gogoproto +// +// 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. +// +// 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. + +package proto + +import ( + "encoding/json" + "strconv" +) + +func MarshalJSONEnum(m map[int32]string, value int32) ([]byte, error) { + s, ok := m[value] + if !ok { + s = strconv.Itoa(int(value)) + } + return json.Marshal(s) +} diff --git a/vendor/github.com/gogo/protobuf/proto/message_set.go b/vendor/github.com/gogo/protobuf/proto/message_set.go new file mode 100644 index 0000000000..e25e01e637 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/message_set.go @@ -0,0 +1,280 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +package proto + +/* + * Support for message sets. + */ + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + "reflect" + "sort" +) + +// errNoMessageTypeID occurs when a protocol buffer does not have a message type ID. +// A message type ID is required for storing a protocol buffer in a message set. +var errNoMessageTypeID = errors.New("proto does not have a message type ID") + +// The first two types (_MessageSet_Item and messageSet) +// model what the protocol compiler produces for the following protocol message: +// message MessageSet { +// repeated group Item = 1 { +// required int32 type_id = 2; +// required string message = 3; +// }; +// } +// That is the MessageSet wire format. We can't use a proto to generate these +// because that would introduce a circular dependency between it and this package. + +type _MessageSet_Item struct { + TypeId *int32 `protobuf:"varint,2,req,name=type_id"` + Message []byte `protobuf:"bytes,3,req,name=message"` +} + +type messageSet struct { + Item []*_MessageSet_Item `protobuf:"group,1,rep"` + XXX_unrecognized []byte + // TODO: caching? +} + +// Make sure messageSet is a Message. +var _ Message = (*messageSet)(nil) + +// messageTypeIder is an interface satisfied by a protocol buffer type +// that may be stored in a MessageSet. +type messageTypeIder interface { + MessageTypeId() int32 +} + +func (ms *messageSet) find(pb Message) *_MessageSet_Item { + mti, ok := pb.(messageTypeIder) + if !ok { + return nil + } + id := mti.MessageTypeId() + for _, item := range ms.Item { + if *item.TypeId == id { + return item + } + } + return nil +} + +func (ms *messageSet) Has(pb Message) bool { + if ms.find(pb) != nil { + return true + } + return false +} + +func (ms *messageSet) Unmarshal(pb Message) error { + if item := ms.find(pb); item != nil { + return Unmarshal(item.Message, pb) + } + if _, ok := pb.(messageTypeIder); !ok { + return errNoMessageTypeID + } + return nil // TODO: return error instead? +} + +func (ms *messageSet) Marshal(pb Message) error { + msg, err := Marshal(pb) + if err != nil { + return err + } + if item := ms.find(pb); item != nil { + // reuse existing item + item.Message = msg + return nil + } + + mti, ok := pb.(messageTypeIder) + if !ok { + return errNoMessageTypeID + } + + mtid := mti.MessageTypeId() + ms.Item = append(ms.Item, &_MessageSet_Item{ + TypeId: &mtid, + Message: msg, + }) + return nil +} + +func (ms *messageSet) Reset() { *ms = messageSet{} } +func (ms *messageSet) String() string { return CompactTextString(ms) } +func (*messageSet) ProtoMessage() {} + +// Support for the message_set_wire_format message option. + +func skipVarint(buf []byte) []byte { + i := 0 + for ; buf[i]&0x80 != 0; i++ { + } + return buf[i+1:] +} + +// MarshalMessageSet encodes the extension map represented by m in the message set wire format. +// It is called by generated Marshal methods on protocol buffer messages with the message_set_wire_format option. +func MarshalMessageSet(m map[int32]Extension) ([]byte, error) { + if err := encodeExtensionMap(m); err != nil { + return nil, err + } + + // Sort extension IDs to provide a deterministic encoding. + // See also enc_map in encode.go. + ids := make([]int, 0, len(m)) + for id := range m { + ids = append(ids, int(id)) + } + sort.Ints(ids) + + ms := &messageSet{Item: make([]*_MessageSet_Item, 0, len(m))} + for _, id := range ids { + e := m[int32(id)] + // Remove the wire type and field number varint, as well as the length varint. + msg := skipVarint(skipVarint(e.enc)) + + ms.Item = append(ms.Item, &_MessageSet_Item{ + TypeId: Int32(int32(id)), + Message: msg, + }) + } + return Marshal(ms) +} + +// UnmarshalMessageSet decodes the extension map encoded in buf in the message set wire format. +// It is called by generated Unmarshal methods on protocol buffer messages with the message_set_wire_format option. +func UnmarshalMessageSet(buf []byte, m map[int32]Extension) error { + ms := new(messageSet) + if err := Unmarshal(buf, ms); err != nil { + return err + } + for _, item := range ms.Item { + id := *item.TypeId + msg := item.Message + + // Restore wire type and field number varint, plus length varint. + // Be careful to preserve duplicate items. + b := EncodeVarint(uint64(id)<<3 | WireBytes) + if ext, ok := m[id]; ok { + // Existing data; rip off the tag and length varint + // so we join the new data correctly. + // We can assume that ext.enc is set because we are unmarshaling. + o := ext.enc[len(b):] // skip wire type and field number + _, n := DecodeVarint(o) // calculate length of length varint + o = o[n:] // skip length varint + msg = append(o, msg...) // join old data and new data + } + b = append(b, EncodeVarint(uint64(len(msg)))...) + b = append(b, msg...) + + m[id] = Extension{enc: b} + } + return nil +} + +// MarshalMessageSetJSON encodes the extension map represented by m in JSON format. +// It is called by generated MarshalJSON methods on protocol buffer messages with the message_set_wire_format option. +func MarshalMessageSetJSON(m map[int32]Extension) ([]byte, error) { + var b bytes.Buffer + b.WriteByte('{') + + // Process the map in key order for deterministic output. + ids := make([]int32, 0, len(m)) + for id := range m { + ids = append(ids, id) + } + sort.Sort(int32Slice(ids)) // int32Slice defined in text.go + + for i, id := range ids { + ext := m[id] + if i > 0 { + b.WriteByte(',') + } + + msd, ok := messageSetMap[id] + if !ok { + // Unknown type; we can't render it, so skip it. + continue + } + fmt.Fprintf(&b, `"[%s]":`, msd.name) + + x := ext.value + if x == nil { + x = reflect.New(msd.t.Elem()).Interface() + if err := Unmarshal(ext.enc, x.(Message)); err != nil { + return nil, err + } + } + d, err := json.Marshal(x) + if err != nil { + return nil, err + } + b.Write(d) + } + b.WriteByte('}') + return b.Bytes(), nil +} + +// UnmarshalMessageSetJSON decodes the extension map encoded in buf in JSON format. +// It is called by generated UnmarshalJSON methods on protocol buffer messages with the message_set_wire_format option. +func UnmarshalMessageSetJSON(buf []byte, m map[int32]Extension) error { + // Common-case fast path. + if len(buf) == 0 || bytes.Equal(buf, []byte("{}")) { + return nil + } + + // This is fairly tricky, and it's not clear that it is needed. + return errors.New("TODO: UnmarshalMessageSetJSON not yet implemented") +} + +// A global registry of types that can be used in a MessageSet. + +var messageSetMap = make(map[int32]messageSetDesc) + +type messageSetDesc struct { + t reflect.Type // pointer to struct + name string +} + +// RegisterMessageSetType is called from the generated code. +func RegisterMessageSetType(m Message, fieldNum int32, name string) { + messageSetMap[fieldNum] = messageSetDesc{ + t: reflect.TypeOf(m), + name: name, + } +} diff --git a/vendor/github.com/gogo/protobuf/proto/pointer_reflect.go b/vendor/github.com/gogo/protobuf/proto/pointer_reflect.go new file mode 100644 index 0000000000..749919d250 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/pointer_reflect.go @@ -0,0 +1,479 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2012 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +// +build appengine + +// This file contains an implementation of proto field accesses using package reflect. +// It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can +// be used on App Engine. + +package proto + +import ( + "math" + "reflect" +) + +// A structPointer is a pointer to a struct. +type structPointer struct { + v reflect.Value +} + +// toStructPointer returns a structPointer equivalent to the given reflect value. +// The reflect value must itself be a pointer to a struct. +func toStructPointer(v reflect.Value) structPointer { + return structPointer{v} +} + +// IsNil reports whether p is nil. +func structPointer_IsNil(p structPointer) bool { + return p.v.IsNil() +} + +// Interface returns the struct pointer as an interface value. +func structPointer_Interface(p structPointer, _ reflect.Type) interface{} { + return p.v.Interface() +} + +// A field identifies a field in a struct, accessible from a structPointer. +// In this implementation, a field is identified by the sequence of field indices +// passed to reflect's FieldByIndex. +type field []int + +// toField returns a field equivalent to the given reflect field. +func toField(f *reflect.StructField) field { + return f.Index +} + +// invalidField is an invalid field identifier. +var invalidField = field(nil) + +// IsValid reports whether the field identifier is valid. +func (f field) IsValid() bool { return f != nil } + +// field returns the given field in the struct as a reflect value. +func structPointer_field(p structPointer, f field) reflect.Value { + // Special case: an extension map entry with a value of type T + // passes a *T to the struct-handling code with a zero field, + // expecting that it will be treated as equivalent to *struct{ X T }, + // which has the same memory layout. We have to handle that case + // specially, because reflect will panic if we call FieldByIndex on a + // non-struct. + if f == nil { + return p.v.Elem() + } + + return p.v.Elem().FieldByIndex(f) +} + +// ifield returns the given field in the struct as an interface value. +func structPointer_ifield(p structPointer, f field) interface{} { + return structPointer_field(p, f).Addr().Interface() +} + +// Bytes returns the address of a []byte field in the struct. +func structPointer_Bytes(p structPointer, f field) *[]byte { + return structPointer_ifield(p, f).(*[]byte) +} + +// BytesSlice returns the address of a [][]byte field in the struct. +func structPointer_BytesSlice(p structPointer, f field) *[][]byte { + return structPointer_ifield(p, f).(*[][]byte) +} + +// Bool returns the address of a *bool field in the struct. +func structPointer_Bool(p structPointer, f field) **bool { + return structPointer_ifield(p, f).(**bool) +} + +// BoolVal returns the address of a bool field in the struct. +func structPointer_BoolVal(p structPointer, f field) *bool { + return structPointer_ifield(p, f).(*bool) +} + +// BoolSlice returns the address of a []bool field in the struct. +func structPointer_BoolSlice(p structPointer, f field) *[]bool { + return structPointer_ifield(p, f).(*[]bool) +} + +// String returns the address of a *string field in the struct. +func structPointer_String(p structPointer, f field) **string { + return structPointer_ifield(p, f).(**string) +} + +// StringVal returns the address of a string field in the struct. +func structPointer_StringVal(p structPointer, f field) *string { + return structPointer_ifield(p, f).(*string) +} + +// StringSlice returns the address of a []string field in the struct. +func structPointer_StringSlice(p structPointer, f field) *[]string { + return structPointer_ifield(p, f).(*[]string) +} + +// ExtMap returns the address of an extension map field in the struct. +func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension { + return structPointer_ifield(p, f).(*map[int32]Extension) +} + +// NewAt returns the reflect.Value for a pointer to a field in the struct. +func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value { + return structPointer_field(p, f).Addr() +} + +// SetStructPointer writes a *struct field in the struct. +func structPointer_SetStructPointer(p structPointer, f field, q structPointer) { + structPointer_field(p, f).Set(q.v) +} + +// GetStructPointer reads a *struct field in the struct. +func structPointer_GetStructPointer(p structPointer, f field) structPointer { + return structPointer{structPointer_field(p, f)} +} + +// StructPointerSlice the address of a []*struct field in the struct. +func structPointer_StructPointerSlice(p structPointer, f field) structPointerSlice { + return structPointerSlice{structPointer_field(p, f)} +} + +// A structPointerSlice represents the address of a slice of pointers to structs +// (themselves messages or groups). That is, v.Type() is *[]*struct{...}. +type structPointerSlice struct { + v reflect.Value +} + +func (p structPointerSlice) Len() int { return p.v.Len() } +func (p structPointerSlice) Index(i int) structPointer { return structPointer{p.v.Index(i)} } +func (p structPointerSlice) Append(q structPointer) { + p.v.Set(reflect.Append(p.v, q.v)) +} + +var ( + int32Type = reflect.TypeOf(int32(0)) + uint32Type = reflect.TypeOf(uint32(0)) + float32Type = reflect.TypeOf(float32(0)) + int64Type = reflect.TypeOf(int64(0)) + uint64Type = reflect.TypeOf(uint64(0)) + float64Type = reflect.TypeOf(float64(0)) +) + +// A word32 represents a field of type *int32, *uint32, *float32, or *enum. +// That is, v.Type() is *int32, *uint32, *float32, or *enum and v is assignable. +type word32 struct { + v reflect.Value +} + +// IsNil reports whether p is nil. +func word32_IsNil(p word32) bool { + return p.v.IsNil() +} + +// Set sets p to point at a newly allocated word with bits set to x. +func word32_Set(p word32, o *Buffer, x uint32) { + t := p.v.Type().Elem() + switch t { + case int32Type: + if len(o.int32s) == 0 { + o.int32s = make([]int32, uint32PoolSize) + } + o.int32s[0] = int32(x) + p.v.Set(reflect.ValueOf(&o.int32s[0])) + o.int32s = o.int32s[1:] + return + case uint32Type: + if len(o.uint32s) == 0 { + o.uint32s = make([]uint32, uint32PoolSize) + } + o.uint32s[0] = x + p.v.Set(reflect.ValueOf(&o.uint32s[0])) + o.uint32s = o.uint32s[1:] + return + case float32Type: + if len(o.float32s) == 0 { + o.float32s = make([]float32, uint32PoolSize) + } + o.float32s[0] = math.Float32frombits(x) + p.v.Set(reflect.ValueOf(&o.float32s[0])) + o.float32s = o.float32s[1:] + return + } + + // must be enum + p.v.Set(reflect.New(t)) + p.v.Elem().SetInt(int64(int32(x))) +} + +// Get gets the bits pointed at by p, as a uint32. +func word32_Get(p word32) uint32 { + elem := p.v.Elem() + switch elem.Kind() { + case reflect.Int32: + return uint32(elem.Int()) + case reflect.Uint32: + return uint32(elem.Uint()) + case reflect.Float32: + return math.Float32bits(float32(elem.Float())) + } + panic("unreachable") +} + +// Word32 returns a reference to a *int32, *uint32, *float32, or *enum field in the struct. +func structPointer_Word32(p structPointer, f field) word32 { + return word32{structPointer_field(p, f)} +} + +// A word32Val represents a field of type int32, uint32, float32, or enum. +// That is, v.Type() is int32, uint32, float32, or enum and v is assignable. +type word32Val struct { + v reflect.Value +} + +// Set sets *p to x. +func word32Val_Set(p word32Val, x uint32) { + switch p.v.Type() { + case int32Type: + p.v.SetInt(int64(x)) + return + case uint32Type: + p.v.SetUint(uint64(x)) + return + case float32Type: + p.v.SetFloat(float64(math.Float32frombits(x))) + return + } + + // must be enum + p.v.SetInt(int64(int32(x))) +} + +// Get gets the bits pointed at by p, as a uint32. +func word32Val_Get(p word32Val) uint32 { + elem := p.v + switch elem.Kind() { + case reflect.Int32: + return uint32(elem.Int()) + case reflect.Uint32: + return uint32(elem.Uint()) + case reflect.Float32: + return math.Float32bits(float32(elem.Float())) + } + panic("unreachable") +} + +// Word32Val returns a reference to a int32, uint32, float32, or enum field in the struct. +func structPointer_Word32Val(p structPointer, f field) word32Val { + return word32Val{structPointer_field(p, f)} +} + +// A word32Slice is a slice of 32-bit values. +// That is, v.Type() is []int32, []uint32, []float32, or []enum. +type word32Slice struct { + v reflect.Value +} + +func (p word32Slice) Append(x uint32) { + n, m := p.v.Len(), p.v.Cap() + if n < m { + p.v.SetLen(n + 1) + } else { + t := p.v.Type().Elem() + p.v.Set(reflect.Append(p.v, reflect.Zero(t))) + } + elem := p.v.Index(n) + switch elem.Kind() { + case reflect.Int32: + elem.SetInt(int64(int32(x))) + case reflect.Uint32: + elem.SetUint(uint64(x)) + case reflect.Float32: + elem.SetFloat(float64(math.Float32frombits(x))) + } +} + +func (p word32Slice) Len() int { + return p.v.Len() +} + +func (p word32Slice) Index(i int) uint32 { + elem := p.v.Index(i) + switch elem.Kind() { + case reflect.Int32: + return uint32(elem.Int()) + case reflect.Uint32: + return uint32(elem.Uint()) + case reflect.Float32: + return math.Float32bits(float32(elem.Float())) + } + panic("unreachable") +} + +// Word32Slice returns a reference to a []int32, []uint32, []float32, or []enum field in the struct. +func structPointer_Word32Slice(p structPointer, f field) word32Slice { + return word32Slice{structPointer_field(p, f)} +} + +// word64 is like word32 but for 64-bit values. +type word64 struct { + v reflect.Value +} + +func word64_Set(p word64, o *Buffer, x uint64) { + t := p.v.Type().Elem() + switch t { + case int64Type: + if len(o.int64s) == 0 { + o.int64s = make([]int64, uint64PoolSize) + } + o.int64s[0] = int64(x) + p.v.Set(reflect.ValueOf(&o.int64s[0])) + o.int64s = o.int64s[1:] + return + case uint64Type: + if len(o.uint64s) == 0 { + o.uint64s = make([]uint64, uint64PoolSize) + } + o.uint64s[0] = x + p.v.Set(reflect.ValueOf(&o.uint64s[0])) + o.uint64s = o.uint64s[1:] + return + case float64Type: + if len(o.float64s) == 0 { + o.float64s = make([]float64, uint64PoolSize) + } + o.float64s[0] = math.Float64frombits(x) + p.v.Set(reflect.ValueOf(&o.float64s[0])) + o.float64s = o.float64s[1:] + return + } + panic("unreachable") +} + +func word64_IsNil(p word64) bool { + return p.v.IsNil() +} + +func word64_Get(p word64) uint64 { + elem := p.v.Elem() + switch elem.Kind() { + case reflect.Int64: + return uint64(elem.Int()) + case reflect.Uint64: + return elem.Uint() + case reflect.Float64: + return math.Float64bits(elem.Float()) + } + panic("unreachable") +} + +func structPointer_Word64(p structPointer, f field) word64 { + return word64{structPointer_field(p, f)} +} + +// word64Val is like word32Val but for 64-bit values. +type word64Val struct { + v reflect.Value +} + +func word64Val_Set(p word64Val, o *Buffer, x uint64) { + switch p.v.Type() { + case int64Type: + p.v.SetInt(int64(x)) + return + case uint64Type: + p.v.SetUint(x) + return + case float64Type: + p.v.SetFloat(math.Float64frombits(x)) + return + } + panic("unreachable") +} + +func word64Val_Get(p word64Val) uint64 { + elem := p.v + switch elem.Kind() { + case reflect.Int64: + return uint64(elem.Int()) + case reflect.Uint64: + return elem.Uint() + case reflect.Float64: + return math.Float64bits(elem.Float()) + } + panic("unreachable") +} + +func structPointer_Word64Val(p structPointer, f field) word64Val { + return word64Val{structPointer_field(p, f)} +} + +type word64Slice struct { + v reflect.Value +} + +func (p word64Slice) Append(x uint64) { + n, m := p.v.Len(), p.v.Cap() + if n < m { + p.v.SetLen(n + 1) + } else { + t := p.v.Type().Elem() + p.v.Set(reflect.Append(p.v, reflect.Zero(t))) + } + elem := p.v.Index(n) + switch elem.Kind() { + case reflect.Int64: + elem.SetInt(int64(int64(x))) + case reflect.Uint64: + elem.SetUint(uint64(x)) + case reflect.Float64: + elem.SetFloat(float64(math.Float64frombits(x))) + } +} + +func (p word64Slice) Len() int { + return p.v.Len() +} + +func (p word64Slice) Index(i int) uint64 { + elem := p.v.Index(i) + switch elem.Kind() { + case reflect.Int64: + return uint64(elem.Int()) + case reflect.Uint64: + return uint64(elem.Uint()) + case reflect.Float64: + return math.Float64bits(float64(elem.Float())) + } + panic("unreachable") +} + +func structPointer_Word64Slice(p structPointer, f field) word64Slice { + return word64Slice{structPointer_field(p, f)} +} diff --git a/vendor/github.com/gogo/protobuf/proto/pointer_unsafe.go b/vendor/github.com/gogo/protobuf/proto/pointer_unsafe.go new file mode 100644 index 0000000000..e9be0fe92e --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/pointer_unsafe.go @@ -0,0 +1,266 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2012 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +// +build !appengine + +// This file contains the implementation of the proto field accesses using package unsafe. + +package proto + +import ( + "reflect" + "unsafe" +) + +// NOTE: These type_Foo functions would more idiomatically be methods, +// but Go does not allow methods on pointer types, and we must preserve +// some pointer type for the garbage collector. We use these +// funcs with clunky names as our poor approximation to methods. +// +// An alternative would be +// type structPointer struct { p unsafe.Pointer } +// but that does not registerize as well. + +// A structPointer is a pointer to a struct. +type structPointer unsafe.Pointer + +// toStructPointer returns a structPointer equivalent to the given reflect value. +func toStructPointer(v reflect.Value) structPointer { + return structPointer(unsafe.Pointer(v.Pointer())) +} + +// IsNil reports whether p is nil. +func structPointer_IsNil(p structPointer) bool { + return p == nil +} + +// Interface returns the struct pointer, assumed to have element type t, +// as an interface value. +func structPointer_Interface(p structPointer, t reflect.Type) interface{} { + return reflect.NewAt(t, unsafe.Pointer(p)).Interface() +} + +// A field identifies a field in a struct, accessible from a structPointer. +// In this implementation, a field is identified by its byte offset from the start of the struct. +type field uintptr + +// toField returns a field equivalent to the given reflect field. +func toField(f *reflect.StructField) field { + return field(f.Offset) +} + +// invalidField is an invalid field identifier. +const invalidField = ^field(0) + +// IsValid reports whether the field identifier is valid. +func (f field) IsValid() bool { + return f != ^field(0) +} + +// Bytes returns the address of a []byte field in the struct. +func structPointer_Bytes(p structPointer, f field) *[]byte { + return (*[]byte)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// BytesSlice returns the address of a [][]byte field in the struct. +func structPointer_BytesSlice(p structPointer, f field) *[][]byte { + return (*[][]byte)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// Bool returns the address of a *bool field in the struct. +func structPointer_Bool(p structPointer, f field) **bool { + return (**bool)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// BoolVal returns the address of a bool field in the struct. +func structPointer_BoolVal(p structPointer, f field) *bool { + return (*bool)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// BoolSlice returns the address of a []bool field in the struct. +func structPointer_BoolSlice(p structPointer, f field) *[]bool { + return (*[]bool)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// String returns the address of a *string field in the struct. +func structPointer_String(p structPointer, f field) **string { + return (**string)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// StringVal returns the address of a string field in the struct. +func structPointer_StringVal(p structPointer, f field) *string { + return (*string)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// StringSlice returns the address of a []string field in the struct. +func structPointer_StringSlice(p structPointer, f field) *[]string { + return (*[]string)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// ExtMap returns the address of an extension map field in the struct. +func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension { + return (*map[int32]Extension)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// NewAt returns the reflect.Value for a pointer to a field in the struct. +func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value { + return reflect.NewAt(typ, unsafe.Pointer(uintptr(p)+uintptr(f))) +} + +// SetStructPointer writes a *struct field in the struct. +func structPointer_SetStructPointer(p structPointer, f field, q structPointer) { + *(*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f))) = q +} + +// GetStructPointer reads a *struct field in the struct. +func structPointer_GetStructPointer(p structPointer, f field) structPointer { + return *(*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// StructPointerSlice the address of a []*struct field in the struct. +func structPointer_StructPointerSlice(p structPointer, f field) *structPointerSlice { + return (*structPointerSlice)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// A structPointerSlice represents a slice of pointers to structs (themselves submessages or groups). +type structPointerSlice []structPointer + +func (v *structPointerSlice) Len() int { return len(*v) } +func (v *structPointerSlice) Index(i int) structPointer { return (*v)[i] } +func (v *structPointerSlice) Append(p structPointer) { *v = append(*v, p) } + +// A word32 is the address of a "pointer to 32-bit value" field. +type word32 **uint32 + +// IsNil reports whether *v is nil. +func word32_IsNil(p word32) bool { + return *p == nil +} + +// Set sets *v to point at a newly allocated word set to x. +func word32_Set(p word32, o *Buffer, x uint32) { + if len(o.uint32s) == 0 { + o.uint32s = make([]uint32, uint32PoolSize) + } + o.uint32s[0] = x + *p = &o.uint32s[0] + o.uint32s = o.uint32s[1:] +} + +// Get gets the value pointed at by *v. +func word32_Get(p word32) uint32 { + return **p +} + +// Word32 returns the address of a *int32, *uint32, *float32, or *enum field in the struct. +func structPointer_Word32(p structPointer, f field) word32 { + return word32((**uint32)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +} + +// A word32Val is the address of a 32-bit value field. +type word32Val *uint32 + +// Set sets *p to x. +func word32Val_Set(p word32Val, x uint32) { + *p = x +} + +// Get gets the value pointed at by p. +func word32Val_Get(p word32Val) uint32 { + return *p +} + +// Word32Val returns the address of a *int32, *uint32, *float32, or *enum field in the struct. +func structPointer_Word32Val(p structPointer, f field) word32Val { + return word32Val((*uint32)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +} + +// A word32Slice is a slice of 32-bit values. +type word32Slice []uint32 + +func (v *word32Slice) Append(x uint32) { *v = append(*v, x) } +func (v *word32Slice) Len() int { return len(*v) } +func (v *word32Slice) Index(i int) uint32 { return (*v)[i] } + +// Word32Slice returns the address of a []int32, []uint32, []float32, or []enum field in the struct. +func structPointer_Word32Slice(p structPointer, f field) *word32Slice { + return (*word32Slice)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// word64 is like word32 but for 64-bit values. +type word64 **uint64 + +func word64_Set(p word64, o *Buffer, x uint64) { + if len(o.uint64s) == 0 { + o.uint64s = make([]uint64, uint64PoolSize) + } + o.uint64s[0] = x + *p = &o.uint64s[0] + o.uint64s = o.uint64s[1:] +} + +func word64_IsNil(p word64) bool { + return *p == nil +} + +func word64_Get(p word64) uint64 { + return **p +} + +func structPointer_Word64(p structPointer, f field) word64 { + return word64((**uint64)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +} + +// word64Val is like word32Val but for 64-bit values. +type word64Val *uint64 + +func word64Val_Set(p word64Val, o *Buffer, x uint64) { + *p = x +} + +func word64Val_Get(p word64Val) uint64 { + return *p +} + +func structPointer_Word64Val(p structPointer, f field) word64Val { + return word64Val((*uint64)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +} + +// word64Slice is like word32Slice but for 64-bit values. +type word64Slice []uint64 + +func (v *word64Slice) Append(x uint64) { *v = append(*v, x) } +func (v *word64Slice) Len() int { return len(*v) } +func (v *word64Slice) Index(i int) uint64 { return (*v)[i] } + +func structPointer_Word64Slice(p structPointer, f field) *word64Slice { + return (*word64Slice)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} diff --git a/vendor/github.com/gogo/protobuf/proto/pointer_unsafe_gogo.go b/vendor/github.com/gogo/protobuf/proto/pointer_unsafe_gogo.go new file mode 100644 index 0000000000..6bc85fa987 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/pointer_unsafe_gogo.go @@ -0,0 +1,108 @@ +// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. +// http://github.com/gogo/protobuf/gogoproto +// +// 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. +// +// 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. + +// +build !appengine + +// This file contains the implementation of the proto field accesses using package unsafe. + +package proto + +import ( + "reflect" + "unsafe" +) + +func structPointer_InterfaceAt(p structPointer, f field, t reflect.Type) interface{} { + point := unsafe.Pointer(uintptr(p) + uintptr(f)) + r := reflect.NewAt(t, point) + return r.Interface() +} + +func structPointer_InterfaceRef(p structPointer, f field, t reflect.Type) interface{} { + point := unsafe.Pointer(uintptr(p) + uintptr(f)) + r := reflect.NewAt(t, point) + if r.Elem().IsNil() { + return nil + } + return r.Elem().Interface() +} + +func copyUintPtr(oldptr, newptr uintptr, size int) { + oldbytes := make([]byte, 0) + oldslice := (*reflect.SliceHeader)(unsafe.Pointer(&oldbytes)) + oldslice.Data = oldptr + oldslice.Len = size + oldslice.Cap = size + newbytes := make([]byte, 0) + newslice := (*reflect.SliceHeader)(unsafe.Pointer(&newbytes)) + newslice.Data = newptr + newslice.Len = size + newslice.Cap = size + copy(newbytes, oldbytes) +} + +func structPointer_Copy(oldptr structPointer, newptr structPointer, size int) { + copyUintPtr(uintptr(oldptr), uintptr(newptr), size) +} + +func appendStructPointer(base structPointer, f field, typ reflect.Type) structPointer { + size := typ.Elem().Size() + oldHeader := structPointer_GetSliceHeader(base, f) + newLen := oldHeader.Len + 1 + slice := reflect.MakeSlice(typ, newLen, newLen) + bas := toStructPointer(slice) + for i := 0; i < oldHeader.Len; i++ { + newElemptr := uintptr(bas) + uintptr(i)*size + oldElemptr := oldHeader.Data + uintptr(i)*size + copyUintPtr(oldElemptr, newElemptr, int(size)) + } + + oldHeader.Data = uintptr(bas) + oldHeader.Len = newLen + oldHeader.Cap = newLen + + return structPointer(unsafe.Pointer(uintptr(unsafe.Pointer(bas)) + uintptr(uintptr(newLen-1)*size))) +} + +func structPointer_FieldPointer(p structPointer, f field) structPointer { + return structPointer(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +func structPointer_GetRefStructPointer(p structPointer, f field) structPointer { + return structPointer((*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +} + +func structPointer_GetSliceHeader(p structPointer, f field) *reflect.SliceHeader { + return (*reflect.SliceHeader)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +func structPointer_Add(p structPointer, size field) structPointer { + return structPointer(unsafe.Pointer(uintptr(p) + uintptr(size))) +} + +func structPointer_Len(p structPointer, f field) int { + return len(*(*[]interface{})(unsafe.Pointer(structPointer_GetRefStructPointer(p, f)))) +} diff --git a/vendor/github.com/gogo/protobuf/proto/properties.go b/vendor/github.com/gogo/protobuf/proto/properties.go new file mode 100644 index 0000000000..5e6a0b3ba7 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/properties.go @@ -0,0 +1,923 @@ +// Extensions for Protocol Buffers to create more go like structures. +// +// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. +// http://github.com/gogo/protobuf/gogoproto +// +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +package proto + +/* + * Routines for encoding data into the wire format for protocol buffers. + */ + +import ( + "fmt" + "log" + "os" + "reflect" + "sort" + "strconv" + "strings" + "sync" +) + +const debug bool = false + +// Constants that identify the encoding of a value on the wire. +const ( + WireVarint = 0 + WireFixed64 = 1 + WireBytes = 2 + WireStartGroup = 3 + WireEndGroup = 4 + WireFixed32 = 5 +) + +const startSize = 10 // initial slice/string sizes + +// Encoders are defined in encode.go +// An encoder outputs the full representation of a field, including its +// tag and encoder type. +type encoder func(p *Buffer, prop *Properties, base structPointer) error + +// A valueEncoder encodes a single integer in a particular encoding. +type valueEncoder func(o *Buffer, x uint64) error + +// Sizers are defined in encode.go +// A sizer returns the encoded size of a field, including its tag and encoder +// type. +type sizer func(prop *Properties, base structPointer) int + +// A valueSizer returns the encoded size of a single integer in a particular +// encoding. +type valueSizer func(x uint64) int + +// Decoders are defined in decode.go +// A decoder creates a value from its wire representation. +// Unrecognized subelements are saved in unrec. +type decoder func(p *Buffer, prop *Properties, base structPointer) error + +// A valueDecoder decodes a single integer in a particular encoding. +type valueDecoder func(o *Buffer) (x uint64, err error) + +// A oneofMarshaler does the marshaling for all oneof fields in a message. +type oneofMarshaler func(Message, *Buffer) error + +// A oneofUnmarshaler does the unmarshaling for a oneof field in a message. +type oneofUnmarshaler func(Message, int, int, *Buffer) (bool, error) + +// A oneofSizer does the sizing for all oneof fields in a message. +type oneofSizer func(Message) int + +// tagMap is an optimization over map[int]int for typical protocol buffer +// use-cases. Encoded protocol buffers are often in tag order with small tag +// numbers. +type tagMap struct { + fastTags []int + slowTags map[int]int +} + +// tagMapFastLimit is the upper bound on the tag number that will be stored in +// the tagMap slice rather than its map. +const tagMapFastLimit = 1024 + +func (p *tagMap) get(t int) (int, bool) { + if t > 0 && t < tagMapFastLimit { + if t >= len(p.fastTags) { + return 0, false + } + fi := p.fastTags[t] + return fi, fi >= 0 + } + fi, ok := p.slowTags[t] + return fi, ok +} + +func (p *tagMap) put(t int, fi int) { + if t > 0 && t < tagMapFastLimit { + for len(p.fastTags) < t+1 { + p.fastTags = append(p.fastTags, -1) + } + p.fastTags[t] = fi + return + } + if p.slowTags == nil { + p.slowTags = make(map[int]int) + } + p.slowTags[t] = fi +} + +// StructProperties represents properties for all the fields of a struct. +// decoderTags and decoderOrigNames should only be used by the decoder. +type StructProperties struct { + Prop []*Properties // properties for each field + reqCount int // required count + decoderTags tagMap // map from proto tag to struct field number + decoderOrigNames map[string]int // map from original name to struct field number + order []int // list of struct field numbers in tag order + unrecField field // field id of the XXX_unrecognized []byte field + extendable bool // is this an extendable proto + + oneofMarshaler oneofMarshaler + oneofUnmarshaler oneofUnmarshaler + oneofSizer oneofSizer + stype reflect.Type + + // OneofTypes contains information about the oneof fields in this message. + // It is keyed by the original name of a field. + OneofTypes map[string]*OneofProperties +} + +// OneofProperties represents information about a specific field in a oneof. +type OneofProperties struct { + Type reflect.Type // pointer to generated struct type for this oneof field + Field int // struct field number of the containing oneof in the message + Prop *Properties +} + +// Implement the sorting interface so we can sort the fields in tag order, as recommended by the spec. +// See encode.go, (*Buffer).enc_struct. + +func (sp *StructProperties) Len() int { return len(sp.order) } +func (sp *StructProperties) Less(i, j int) bool { + return sp.Prop[sp.order[i]].Tag < sp.Prop[sp.order[j]].Tag +} +func (sp *StructProperties) Swap(i, j int) { sp.order[i], sp.order[j] = sp.order[j], sp.order[i] } + +// Properties represents the protocol-specific behavior of a single struct field. +type Properties struct { + Name string // name of the field, for error messages + OrigName string // original name before protocol compiler (always set) + JSONName string // name to use for JSON; determined by protoc + Wire string + WireType int + Tag int + Required bool + Optional bool + Repeated bool + Packed bool // relevant for repeated primitives only + Enum string // set for enum types only + proto3 bool // whether this is known to be a proto3 field; set for []byte only + oneof bool // whether this is a oneof field + + Default string // default value + HasDefault bool // whether an explicit default was provided + CustomType string + def_uint64 uint64 + + enc encoder + valEnc valueEncoder // set for bool and numeric types only + field field + tagcode []byte // encoding of EncodeVarint((Tag<<3)|WireType) + tagbuf [8]byte + stype reflect.Type // set for struct types only + sstype reflect.Type // set for slices of structs types only + ctype reflect.Type // set for custom types only + sprop *StructProperties // set for struct types only + isMarshaler bool + isUnmarshaler bool + + mtype reflect.Type // set for map types only + mkeyprop *Properties // set for map types only + mvalprop *Properties // set for map types only + + size sizer + valSize valueSizer // set for bool and numeric types only + + dec decoder + valDec valueDecoder // set for bool and numeric types only + + // If this is a packable field, this will be the decoder for the packed version of the field. + packedDec decoder +} + +// String formats the properties in the protobuf struct field tag style. +func (p *Properties) String() string { + s := p.Wire + s = "," + s += strconv.Itoa(p.Tag) + if p.Required { + s += ",req" + } + if p.Optional { + s += ",opt" + } + if p.Repeated { + s += ",rep" + } + if p.Packed { + s += ",packed" + } + s += ",name=" + p.OrigName + if p.JSONName != p.OrigName { + s += ",json=" + p.JSONName + } + if p.proto3 { + s += ",proto3" + } + if p.oneof { + s += ",oneof" + } + if len(p.Enum) > 0 { + s += ",enum=" + p.Enum + } + if p.HasDefault { + s += ",def=" + p.Default + } + return s +} + +// Parse populates p by parsing a string in the protobuf struct field tag style. +func (p *Properties) Parse(s string) { + // "bytes,49,opt,name=foo,def=hello!" + fields := strings.Split(s, ",") // breaks def=, but handled below. + if len(fields) < 2 { + fmt.Fprintf(os.Stderr, "proto: tag has too few fields: %q\n", s) + return + } + + p.Wire = fields[0] + switch p.Wire { + case "varint": + p.WireType = WireVarint + p.valEnc = (*Buffer).EncodeVarint + p.valDec = (*Buffer).DecodeVarint + p.valSize = sizeVarint + case "fixed32": + p.WireType = WireFixed32 + p.valEnc = (*Buffer).EncodeFixed32 + p.valDec = (*Buffer).DecodeFixed32 + p.valSize = sizeFixed32 + case "fixed64": + p.WireType = WireFixed64 + p.valEnc = (*Buffer).EncodeFixed64 + p.valDec = (*Buffer).DecodeFixed64 + p.valSize = sizeFixed64 + case "zigzag32": + p.WireType = WireVarint + p.valEnc = (*Buffer).EncodeZigzag32 + p.valDec = (*Buffer).DecodeZigzag32 + p.valSize = sizeZigzag32 + case "zigzag64": + p.WireType = WireVarint + p.valEnc = (*Buffer).EncodeZigzag64 + p.valDec = (*Buffer).DecodeZigzag64 + p.valSize = sizeZigzag64 + case "bytes", "group": + p.WireType = WireBytes + // no numeric converter for non-numeric types + default: + fmt.Fprintf(os.Stderr, "proto: tag has unknown wire type: %q\n", s) + return + } + + var err error + p.Tag, err = strconv.Atoi(fields[1]) + if err != nil { + return + } + + for i := 2; i < len(fields); i++ { + f := fields[i] + switch { + case f == "req": + p.Required = true + case f == "opt": + p.Optional = true + case f == "rep": + p.Repeated = true + case f == "packed": + p.Packed = true + case strings.HasPrefix(f, "name="): + p.OrigName = f[5:] + case strings.HasPrefix(f, "json="): + p.JSONName = f[5:] + case strings.HasPrefix(f, "enum="): + p.Enum = f[5:] + case f == "proto3": + p.proto3 = true + case f == "oneof": + p.oneof = true + case strings.HasPrefix(f, "def="): + p.HasDefault = true + p.Default = f[4:] // rest of string + if i+1 < len(fields) { + // Commas aren't escaped, and def is always last. + p.Default += "," + strings.Join(fields[i+1:], ",") + break + } + case strings.HasPrefix(f, "embedded="): + p.OrigName = strings.Split(f, "=")[1] + case strings.HasPrefix(f, "customtype="): + p.CustomType = strings.Split(f, "=")[1] + } + } +} + +func logNoSliceEnc(t1, t2 reflect.Type) { + fmt.Fprintf(os.Stderr, "proto: no slice oenc for %T = []%T\n", t1, t2) +} + +var protoMessageType = reflect.TypeOf((*Message)(nil)).Elem() + +// Initialize the fields for encoding and decoding. +func (p *Properties) setEncAndDec(typ reflect.Type, f *reflect.StructField, lockGetProp bool) { + p.enc = nil + p.dec = nil + p.size = nil + if len(p.CustomType) > 0 { + p.setCustomEncAndDec(typ) + p.setTag(lockGetProp) + return + } + switch t1 := typ; t1.Kind() { + default: + fmt.Fprintf(os.Stderr, "proto: no coders for %v\n", t1) + + // proto3 scalar types + + case reflect.Bool: + if p.proto3 { + p.enc = (*Buffer).enc_proto3_bool + p.dec = (*Buffer).dec_proto3_bool + p.size = size_proto3_bool + } else { + p.enc = (*Buffer).enc_ref_bool + p.dec = (*Buffer).dec_proto3_bool + p.size = size_ref_bool + } + case reflect.Int32: + if p.proto3 { + p.enc = (*Buffer).enc_proto3_int32 + p.dec = (*Buffer).dec_proto3_int32 + p.size = size_proto3_int32 + } else { + p.enc = (*Buffer).enc_ref_int32 + p.dec = (*Buffer).dec_proto3_int32 + p.size = size_ref_int32 + } + case reflect.Uint32: + if p.proto3 { + p.enc = (*Buffer).enc_proto3_uint32 + p.dec = (*Buffer).dec_proto3_int32 // can reuse + p.size = size_proto3_uint32 + } else { + p.enc = (*Buffer).enc_ref_uint32 + p.dec = (*Buffer).dec_proto3_int32 // can reuse + p.size = size_ref_uint32 + } + case reflect.Int64, reflect.Uint64: + if p.proto3 { + p.enc = (*Buffer).enc_proto3_int64 + p.dec = (*Buffer).dec_proto3_int64 + p.size = size_proto3_int64 + } else { + p.enc = (*Buffer).enc_ref_int64 + p.dec = (*Buffer).dec_proto3_int64 + p.size = size_ref_int64 + } + case reflect.Float32: + if p.proto3 { + p.enc = (*Buffer).enc_proto3_uint32 // can just treat them as bits + p.dec = (*Buffer).dec_proto3_int32 + p.size = size_proto3_uint32 + } else { + p.enc = (*Buffer).enc_ref_uint32 // can just treat them as bits + p.dec = (*Buffer).dec_proto3_int32 + p.size = size_ref_uint32 + } + case reflect.Float64: + if p.proto3 { + p.enc = (*Buffer).enc_proto3_int64 // can just treat them as bits + p.dec = (*Buffer).dec_proto3_int64 + p.size = size_proto3_int64 + } else { + p.enc = (*Buffer).enc_ref_int64 // can just treat them as bits + p.dec = (*Buffer).dec_proto3_int64 + p.size = size_ref_int64 + } + case reflect.String: + if p.proto3 { + p.enc = (*Buffer).enc_proto3_string + p.dec = (*Buffer).dec_proto3_string + p.size = size_proto3_string + } else { + p.enc = (*Buffer).enc_ref_string + p.dec = (*Buffer).dec_proto3_string + p.size = size_ref_string + } + case reflect.Struct: + p.stype = typ + p.isMarshaler = isMarshaler(typ) + p.isUnmarshaler = isUnmarshaler(typ) + if p.Wire == "bytes" { + p.enc = (*Buffer).enc_ref_struct_message + p.dec = (*Buffer).dec_ref_struct_message + p.size = size_ref_struct_message + } else { + fmt.Fprintf(os.Stderr, "proto: no coders for struct %T\n", typ) + } + + case reflect.Ptr: + switch t2 := t1.Elem(); t2.Kind() { + default: + fmt.Fprintf(os.Stderr, "proto: no encoder function for %v -> %v\n", t1, t2) + break + case reflect.Bool: + p.enc = (*Buffer).enc_bool + p.dec = (*Buffer).dec_bool + p.size = size_bool + case reflect.Int32: + p.enc = (*Buffer).enc_int32 + p.dec = (*Buffer).dec_int32 + p.size = size_int32 + case reflect.Uint32: + p.enc = (*Buffer).enc_uint32 + p.dec = (*Buffer).dec_int32 // can reuse + p.size = size_uint32 + case reflect.Int64, reflect.Uint64: + p.enc = (*Buffer).enc_int64 + p.dec = (*Buffer).dec_int64 + p.size = size_int64 + case reflect.Float32: + p.enc = (*Buffer).enc_uint32 // can just treat them as bits + p.dec = (*Buffer).dec_int32 + p.size = size_uint32 + case reflect.Float64: + p.enc = (*Buffer).enc_int64 // can just treat them as bits + p.dec = (*Buffer).dec_int64 + p.size = size_int64 + case reflect.String: + p.enc = (*Buffer).enc_string + p.dec = (*Buffer).dec_string + p.size = size_string + case reflect.Struct: + p.stype = t1.Elem() + p.isMarshaler = isMarshaler(t1) + p.isUnmarshaler = isUnmarshaler(t1) + if p.Wire == "bytes" { + p.enc = (*Buffer).enc_struct_message + p.dec = (*Buffer).dec_struct_message + p.size = size_struct_message + } else { + p.enc = (*Buffer).enc_struct_group + p.dec = (*Buffer).dec_struct_group + p.size = size_struct_group + } + } + + case reflect.Slice: + switch t2 := t1.Elem(); t2.Kind() { + default: + logNoSliceEnc(t1, t2) + break + case reflect.Bool: + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_bool + p.size = size_slice_packed_bool + } else { + p.enc = (*Buffer).enc_slice_bool + p.size = size_slice_bool + } + p.dec = (*Buffer).dec_slice_bool + p.packedDec = (*Buffer).dec_slice_packed_bool + case reflect.Int32: + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_int32 + p.size = size_slice_packed_int32 + } else { + p.enc = (*Buffer).enc_slice_int32 + p.size = size_slice_int32 + } + p.dec = (*Buffer).dec_slice_int32 + p.packedDec = (*Buffer).dec_slice_packed_int32 + case reflect.Uint32: + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_uint32 + p.size = size_slice_packed_uint32 + } else { + p.enc = (*Buffer).enc_slice_uint32 + p.size = size_slice_uint32 + } + p.dec = (*Buffer).dec_slice_int32 + p.packedDec = (*Buffer).dec_slice_packed_int32 + case reflect.Int64, reflect.Uint64: + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_int64 + p.size = size_slice_packed_int64 + } else { + p.enc = (*Buffer).enc_slice_int64 + p.size = size_slice_int64 + } + p.dec = (*Buffer).dec_slice_int64 + p.packedDec = (*Buffer).dec_slice_packed_int64 + case reflect.Uint8: + p.enc = (*Buffer).enc_slice_byte + p.dec = (*Buffer).dec_slice_byte + p.size = size_slice_byte + // This is a []byte, which is either a bytes field, + // or the value of a map field. In the latter case, + // we always encode an empty []byte, so we should not + // use the proto3 enc/size funcs. + // f == nil iff this is the key/value of a map field. + if p.proto3 && f != nil { + p.enc = (*Buffer).enc_proto3_slice_byte + p.size = size_proto3_slice_byte + } + case reflect.Float32, reflect.Float64: + switch t2.Bits() { + case 32: + // can just treat them as bits + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_uint32 + p.size = size_slice_packed_uint32 + } else { + p.enc = (*Buffer).enc_slice_uint32 + p.size = size_slice_uint32 + } + p.dec = (*Buffer).dec_slice_int32 + p.packedDec = (*Buffer).dec_slice_packed_int32 + case 64: + // can just treat them as bits + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_int64 + p.size = size_slice_packed_int64 + } else { + p.enc = (*Buffer).enc_slice_int64 + p.size = size_slice_int64 + } + p.dec = (*Buffer).dec_slice_int64 + p.packedDec = (*Buffer).dec_slice_packed_int64 + default: + logNoSliceEnc(t1, t2) + break + } + case reflect.String: + p.enc = (*Buffer).enc_slice_string + p.dec = (*Buffer).dec_slice_string + p.size = size_slice_string + case reflect.Ptr: + switch t3 := t2.Elem(); t3.Kind() { + default: + fmt.Fprintf(os.Stderr, "proto: no ptr oenc for %T -> %T -> %T\n", t1, t2, t3) + break + case reflect.Struct: + p.stype = t2.Elem() + p.isMarshaler = isMarshaler(t2) + p.isUnmarshaler = isUnmarshaler(t2) + if p.Wire == "bytes" { + p.enc = (*Buffer).enc_slice_struct_message + p.dec = (*Buffer).dec_slice_struct_message + p.size = size_slice_struct_message + } else { + p.enc = (*Buffer).enc_slice_struct_group + p.dec = (*Buffer).dec_slice_struct_group + p.size = size_slice_struct_group + } + } + case reflect.Slice: + switch t2.Elem().Kind() { + default: + fmt.Fprintf(os.Stderr, "proto: no slice elem oenc for %T -> %T -> %T\n", t1, t2, t2.Elem()) + break + case reflect.Uint8: + p.enc = (*Buffer).enc_slice_slice_byte + p.dec = (*Buffer).dec_slice_slice_byte + p.size = size_slice_slice_byte + } + case reflect.Struct: + p.setSliceOfNonPointerStructs(t1) + } + + case reflect.Map: + p.enc = (*Buffer).enc_new_map + p.dec = (*Buffer).dec_new_map + p.size = size_new_map + + p.mtype = t1 + p.mkeyprop = &Properties{} + p.mkeyprop.init(reflect.PtrTo(p.mtype.Key()), "Key", f.Tag.Get("protobuf_key"), nil, lockGetProp) + p.mvalprop = &Properties{} + vtype := p.mtype.Elem() + if vtype.Kind() != reflect.Ptr && vtype.Kind() != reflect.Slice { + // The value type is not a message (*T) or bytes ([]byte), + // so we need encoders for the pointer to this type. + vtype = reflect.PtrTo(vtype) + } + p.mvalprop.init(vtype, "Value", f.Tag.Get("protobuf_val"), nil, lockGetProp) + } + p.setTag(lockGetProp) +} + +func (p *Properties) setTag(lockGetProp bool) { + // precalculate tag code + wire := p.WireType + if p.Packed { + wire = WireBytes + } + x := uint32(p.Tag)<<3 | uint32(wire) + i := 0 + for i = 0; x > 127; i++ { + p.tagbuf[i] = 0x80 | uint8(x&0x7F) + x >>= 7 + } + p.tagbuf[i] = uint8(x) + p.tagcode = p.tagbuf[0 : i+1] + + if p.stype != nil { + if lockGetProp { + p.sprop = GetProperties(p.stype) + } else { + p.sprop = getPropertiesLocked(p.stype) + } + } +} + +var ( + marshalerType = reflect.TypeOf((*Marshaler)(nil)).Elem() + unmarshalerType = reflect.TypeOf((*Unmarshaler)(nil)).Elem() +) + +// isMarshaler reports whether type t implements Marshaler. +func isMarshaler(t reflect.Type) bool { + return t.Implements(marshalerType) +} + +// isUnmarshaler reports whether type t implements Unmarshaler. +func isUnmarshaler(t reflect.Type) bool { + return t.Implements(unmarshalerType) +} + +// Init populates the properties from a protocol buffer struct tag. +func (p *Properties) Init(typ reflect.Type, name, tag string, f *reflect.StructField) { + p.init(typ, name, tag, f, true) +} + +func (p *Properties) init(typ reflect.Type, name, tag string, f *reflect.StructField, lockGetProp bool) { + // "bytes,49,opt,def=hello!" + p.Name = name + p.OrigName = name + if f != nil { + p.field = toField(f) + } + if tag == "" { + return + } + p.Parse(tag) + p.setEncAndDec(typ, f, lockGetProp) +} + +var ( + propertiesMu sync.RWMutex + propertiesMap = make(map[reflect.Type]*StructProperties) +) + +// GetProperties returns the list of properties for the type represented by t. +// t must represent a generated struct type of a protocol message. +func GetProperties(t reflect.Type) *StructProperties { + if t.Kind() != reflect.Struct { + panic("proto: type must have kind struct") + } + + // Most calls to GetProperties in a long-running program will be + // retrieving details for types we have seen before. + propertiesMu.RLock() + sprop, ok := propertiesMap[t] + propertiesMu.RUnlock() + if ok { + if collectStats { + stats.Chit++ + } + return sprop + } + + propertiesMu.Lock() + sprop = getPropertiesLocked(t) + propertiesMu.Unlock() + return sprop +} + +// getPropertiesLocked requires that propertiesMu is held. +func getPropertiesLocked(t reflect.Type) *StructProperties { + if prop, ok := propertiesMap[t]; ok { + if collectStats { + stats.Chit++ + } + return prop + } + if collectStats { + stats.Cmiss++ + } + + prop := new(StructProperties) + // in case of recursive protos, fill this in now. + propertiesMap[t] = prop + + // build properties + prop.extendable = reflect.PtrTo(t).Implements(extendableProtoType) + prop.unrecField = invalidField + prop.Prop = make([]*Properties, t.NumField()) + prop.order = make([]int, t.NumField()) + + isOneofMessage := false + for i := 0; i < t.NumField(); i++ { + f := t.Field(i) + p := new(Properties) + name := f.Name + p.init(f.Type, name, f.Tag.Get("protobuf"), &f, false) + + if f.Name == "XXX_extensions" { // special case + if len(f.Tag.Get("protobuf")) > 0 { + p.enc = (*Buffer).enc_ext_slice_byte + p.dec = nil // not needed + p.size = size_ext_slice_byte + } else { + p.enc = (*Buffer).enc_map + p.dec = nil // not needed + p.size = size_map + } + } + if f.Name == "XXX_unrecognized" { // special case + prop.unrecField = toField(&f) + } + oneof := f.Tag.Get("protobuf_oneof") != "" // special case + if oneof { + isOneofMessage = true + } + prop.Prop[i] = p + prop.order[i] = i + if debug { + print(i, " ", f.Name, " ", t.String(), " ") + if p.Tag > 0 { + print(p.String()) + } + print("\n") + } + if p.enc == nil && !strings.HasPrefix(f.Name, "XXX_") && !oneof { + fmt.Fprintln(os.Stderr, "proto: no encoder for", f.Name, f.Type.String(), "[GetProperties]") + } + } + + // Re-order prop.order. + sort.Sort(prop) + + type oneofMessage interface { + XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{}) + } + if om, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); isOneofMessage && ok { + var oots []interface{} + prop.oneofMarshaler, prop.oneofUnmarshaler, prop.oneofSizer, oots = om.XXX_OneofFuncs() + prop.stype = t + + // Interpret oneof metadata. + prop.OneofTypes = make(map[string]*OneofProperties) + for _, oot := range oots { + oop := &OneofProperties{ + Type: reflect.ValueOf(oot).Type(), // *T + Prop: new(Properties), + } + sft := oop.Type.Elem().Field(0) + oop.Prop.Name = sft.Name + oop.Prop.Parse(sft.Tag.Get("protobuf")) + // There will be exactly one interface field that + // this new value is assignable to. + for i := 0; i < t.NumField(); i++ { + f := t.Field(i) + if f.Type.Kind() != reflect.Interface { + continue + } + if !oop.Type.AssignableTo(f.Type) { + continue + } + oop.Field = i + break + } + prop.OneofTypes[oop.Prop.OrigName] = oop + } + } + + // build required counts + // build tags + reqCount := 0 + prop.decoderOrigNames = make(map[string]int) + for i, p := range prop.Prop { + if strings.HasPrefix(p.Name, "XXX_") { + // Internal fields should not appear in tags/origNames maps. + // They are handled specially when encoding and decoding. + continue + } + if p.Required { + reqCount++ + } + prop.decoderTags.put(p.Tag, i) + prop.decoderOrigNames[p.OrigName] = i + } + prop.reqCount = reqCount + + return prop +} + +// Return the Properties object for the x[0]'th field of the structure. +func propByIndex(t reflect.Type, x []int) *Properties { + if len(x) != 1 { + fmt.Fprintf(os.Stderr, "proto: field index dimension %d (not 1) for type %s\n", len(x), t) + return nil + } + prop := GetProperties(t) + return prop.Prop[x[0]] +} + +// Get the address and type of a pointer to a struct from an interface. +func getbase(pb Message) (t reflect.Type, b structPointer, err error) { + if pb == nil { + err = ErrNil + return + } + // get the reflect type of the pointer to the struct. + t = reflect.TypeOf(pb) + // get the address of the struct. + value := reflect.ValueOf(pb) + b = toStructPointer(value) + return +} + +// A global registry of enum types. +// The generated code will register the generated maps by calling RegisterEnum. + +var enumValueMaps = make(map[string]map[string]int32) +var enumStringMaps = make(map[string]map[int32]string) + +// RegisterEnum is called from the generated code to install the enum descriptor +// maps into the global table to aid parsing text format protocol buffers. +func RegisterEnum(typeName string, unusedNameMap map[int32]string, valueMap map[string]int32) { + if _, ok := enumValueMaps[typeName]; ok { + panic("proto: duplicate enum registered: " + typeName) + } + enumValueMaps[typeName] = valueMap + if _, ok := enumStringMaps[typeName]; ok { + panic("proto: duplicate enum registered: " + typeName) + } + enumStringMaps[typeName] = unusedNameMap +} + +// EnumValueMap returns the mapping from names to integers of the +// enum type enumType, or a nil if not found. +func EnumValueMap(enumType string) map[string]int32 { + return enumValueMaps[enumType] +} + +// A registry of all linked message types. +// The string is a fully-qualified proto name ("pkg.Message"). +var ( + protoTypes = make(map[string]reflect.Type) + revProtoTypes = make(map[reflect.Type]string) +) + +// RegisterType is called from generated code and maps from the fully qualified +// proto name to the type (pointer to struct) of the protocol buffer. +func RegisterType(x Message, name string) { + if _, ok := protoTypes[name]; ok { + // TODO: Some day, make this a panic. + log.Printf("proto: duplicate proto type registered: %s", name) + return + } + t := reflect.TypeOf(x) + protoTypes[name] = t + revProtoTypes[t] = name +} + +// MessageName returns the fully-qualified proto name for the given message type. +func MessageName(x Message) string { return revProtoTypes[reflect.TypeOf(x)] } + +// MessageType returns the message type (pointer to struct) for a named message. +func MessageType(name string) reflect.Type { return protoTypes[name] } diff --git a/vendor/github.com/gogo/protobuf/proto/properties_gogo.go b/vendor/github.com/gogo/protobuf/proto/properties_gogo.go new file mode 100644 index 0000000000..8daf9f7768 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/properties_gogo.go @@ -0,0 +1,64 @@ +// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. +// http://github.com/gogo/protobuf/gogoproto +// +// 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. +// +// 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. + +package proto + +import ( + "fmt" + "os" + "reflect" +) + +func (p *Properties) setCustomEncAndDec(typ reflect.Type) { + p.ctype = typ + if p.Repeated { + p.enc = (*Buffer).enc_custom_slice_bytes + p.dec = (*Buffer).dec_custom_slice_bytes + p.size = size_custom_slice_bytes + } else if typ.Kind() == reflect.Ptr { + p.enc = (*Buffer).enc_custom_bytes + p.dec = (*Buffer).dec_custom_bytes + p.size = size_custom_bytes + } else { + p.enc = (*Buffer).enc_custom_ref_bytes + p.dec = (*Buffer).dec_custom_ref_bytes + p.size = size_custom_ref_bytes + } +} + +func (p *Properties) setSliceOfNonPointerStructs(typ reflect.Type) { + t2 := typ.Elem() + p.sstype = typ + p.stype = t2 + p.isMarshaler = isMarshaler(t2) + p.isUnmarshaler = isUnmarshaler(t2) + p.enc = (*Buffer).enc_slice_ref_struct_message + p.dec = (*Buffer).dec_slice_ref_struct_message + p.size = size_slice_ref_struct_message + if p.Wire != "bytes" { + fmt.Fprintf(os.Stderr, "proto: no ptr oenc for %T -> %T \n", typ, t2) + } +} diff --git a/vendor/github.com/gogo/protobuf/proto/skip_gogo.go b/vendor/github.com/gogo/protobuf/proto/skip_gogo.go new file mode 100644 index 0000000000..4fe7e0815c --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/skip_gogo.go @@ -0,0 +1,117 @@ +// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. +// http://github.com/gogo/protobuf/gogoproto +// +// 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. +// +// 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. + +package proto + +import ( + "fmt" + "io" +) + +func Skip(data []byte) (n int, err error) { + l := len(data) + index := 0 + for index < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if index >= l { + return 0, io.ErrUnexpectedEOF + } + b := data[index] + index++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for { + if index >= l { + return 0, io.ErrUnexpectedEOF + } + index++ + if data[index-1] < 0x80 { + break + } + } + return index, nil + case 1: + index += 8 + return index, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if index >= l { + return 0, io.ErrUnexpectedEOF + } + b := data[index] + index++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + index += length + return index, nil + case 3: + for { + var innerWire uint64 + var start int = index + for shift := uint(0); ; shift += 7 { + if index >= l { + return 0, io.ErrUnexpectedEOF + } + b := data[index] + index++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := Skip(data[start:]) + if err != nil { + return 0, err + } + index = start + next + } + return index, nil + case 4: + return index, nil + case 5: + index += 4 + return index, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} diff --git a/vendor/github.com/gogo/protobuf/proto/text.go b/vendor/github.com/gogo/protobuf/proto/text.go new file mode 100644 index 0000000000..e2b99b122d --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/text.go @@ -0,0 +1,793 @@ +// Extensions for Protocol Buffers to create more go like structures. +// +// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. +// http://github.com/gogo/protobuf/gogoproto +// +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +package proto + +// Functions for writing the text protocol buffer format. + +import ( + "bufio" + "bytes" + "encoding" + "errors" + "fmt" + "io" + "log" + "math" + "reflect" + "sort" + "strings" +) + +var ( + newline = []byte("\n") + spaces = []byte(" ") + gtNewline = []byte(">\n") + endBraceNewline = []byte("}\n") + backslashN = []byte{'\\', 'n'} + backslashR = []byte{'\\', 'r'} + backslashT = []byte{'\\', 't'} + backslashDQ = []byte{'\\', '"'} + backslashBS = []byte{'\\', '\\'} + posInf = []byte("inf") + negInf = []byte("-inf") + nan = []byte("nan") +) + +type writer interface { + io.Writer + WriteByte(byte) error +} + +// textWriter is an io.Writer that tracks its indentation level. +type textWriter struct { + ind int + complete bool // if the current position is a complete line + compact bool // whether to write out as a one-liner + w writer +} + +func (w *textWriter) WriteString(s string) (n int, err error) { + if !strings.Contains(s, "\n") { + if !w.compact && w.complete { + w.writeIndent() + } + w.complete = false + return io.WriteString(w.w, s) + } + // WriteString is typically called without newlines, so this + // codepath and its copy are rare. We copy to avoid + // duplicating all of Write's logic here. + return w.Write([]byte(s)) +} + +func (w *textWriter) Write(p []byte) (n int, err error) { + newlines := bytes.Count(p, newline) + if newlines == 0 { + if !w.compact && w.complete { + w.writeIndent() + } + n, err = w.w.Write(p) + w.complete = false + return n, err + } + + frags := bytes.SplitN(p, newline, newlines+1) + if w.compact { + for i, frag := range frags { + if i > 0 { + if err := w.w.WriteByte(' '); err != nil { + return n, err + } + n++ + } + nn, err := w.w.Write(frag) + n += nn + if err != nil { + return n, err + } + } + return n, nil + } + + for i, frag := range frags { + if w.complete { + w.writeIndent() + } + nn, err := w.w.Write(frag) + n += nn + if err != nil { + return n, err + } + if i+1 < len(frags) { + if err := w.w.WriteByte('\n'); err != nil { + return n, err + } + n++ + } + } + w.complete = len(frags[len(frags)-1]) == 0 + return n, nil +} + +func (w *textWriter) WriteByte(c byte) error { + if w.compact && c == '\n' { + c = ' ' + } + if !w.compact && w.complete { + w.writeIndent() + } + err := w.w.WriteByte(c) + w.complete = c == '\n' + return err +} + +func (w *textWriter) indent() { w.ind++ } + +func (w *textWriter) unindent() { + if w.ind == 0 { + log.Printf("proto: textWriter unindented too far") + return + } + w.ind-- +} + +func writeName(w *textWriter, props *Properties) error { + if _, err := w.WriteString(props.OrigName); err != nil { + return err + } + if props.Wire != "group" { + return w.WriteByte(':') + } + return nil +} + +// raw is the interface satisfied by RawMessage. +type raw interface { + Bytes() []byte +} + +func writeStruct(w *textWriter, sv reflect.Value) error { + st := sv.Type() + sprops := GetProperties(st) + for i := 0; i < sv.NumField(); i++ { + fv := sv.Field(i) + props := sprops.Prop[i] + name := st.Field(i).Name + + if strings.HasPrefix(name, "XXX_") { + // There are two XXX_ fields: + // XXX_unrecognized []byte + // XXX_extensions map[int32]proto.Extension + // The first is handled here; + // the second is handled at the bottom of this function. + if name == "XXX_unrecognized" && !fv.IsNil() { + if err := writeUnknownStruct(w, fv.Interface().([]byte)); err != nil { + return err + } + } + continue + } + if fv.Kind() == reflect.Ptr && fv.IsNil() { + // Field not filled in. This could be an optional field or + // a required field that wasn't filled in. Either way, there + // isn't anything we can show for it. + continue + } + if fv.Kind() == reflect.Slice && fv.IsNil() { + // Repeated field that is empty, or a bytes field that is unused. + continue + } + + if props.Repeated && fv.Kind() == reflect.Slice { + // Repeated field. + for j := 0; j < fv.Len(); j++ { + if err := writeName(w, props); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + v := fv.Index(j) + if v.Kind() == reflect.Ptr && v.IsNil() { + // A nil message in a repeated field is not valid, + // but we can handle that more gracefully than panicking. + if _, err := w.Write([]byte("\n")); err != nil { + return err + } + continue + } + if len(props.Enum) > 0 { + if err := writeEnum(w, v, props); err != nil { + return err + } + } else if err := writeAny(w, v, props); err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + } + continue + } + if fv.Kind() == reflect.Map { + // Map fields are rendered as a repeated struct with key/value fields. + keys := fv.MapKeys() + sort.Sort(mapKeys(keys)) + for _, key := range keys { + val := fv.MapIndex(key) + if err := writeName(w, props); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + // open struct + if err := w.WriteByte('<'); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte('\n'); err != nil { + return err + } + } + w.indent() + // key + if _, err := w.WriteString("key:"); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + if err := writeAny(w, key, props.mkeyprop); err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + // nil values aren't legal, but we can avoid panicking because of them. + if val.Kind() != reflect.Ptr || !val.IsNil() { + // value + if _, err := w.WriteString("value:"); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + if err := writeAny(w, val, props.mvalprop); err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + } + // close struct + w.unindent() + if err := w.WriteByte('>'); err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + } + continue + } + if props.proto3 && fv.Kind() == reflect.Slice && fv.Len() == 0 { + // empty bytes field + continue + } + if props.proto3 && fv.Kind() != reflect.Ptr && fv.Kind() != reflect.Slice { + // proto3 non-repeated scalar field; skip if zero value + if isProto3Zero(fv) { + continue + } + } + + if fv.Kind() == reflect.Interface { + // Check if it is a oneof. + if st.Field(i).Tag.Get("protobuf_oneof") != "" { + // fv is nil, or holds a pointer to generated struct. + // That generated struct has exactly one field, + // which has a protobuf struct tag. + if fv.IsNil() { + continue + } + inner := fv.Elem().Elem() // interface -> *T -> T + tag := inner.Type().Field(0).Tag.Get("protobuf") + props.Parse(tag) // Overwrite the outer props. + // Write the value in the oneof, not the oneof itself. + fv = inner.Field(0) + + // Special case to cope with malformed messages gracefully: + // If the value in the oneof is a nil pointer, don't panic + // in writeAny. + if fv.Kind() == reflect.Ptr && fv.IsNil() { + // Use errors.New so writeAny won't render quotes. + msg := errors.New("/* nil */") + fv = reflect.ValueOf(&msg).Elem() + } + } + } + + if err := writeName(w, props); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + if b, ok := fv.Interface().(raw); ok { + if err := writeRaw(w, b.Bytes()); err != nil { + return err + } + continue + } + + if len(props.Enum) > 0 { + if err := writeEnum(w, fv, props); err != nil { + return err + } + } else if err := writeAny(w, fv, props); err != nil { + return err + } + + if err := w.WriteByte('\n'); err != nil { + return err + } + } + + // Extensions (the XXX_extensions field). + pv := sv + if pv.CanAddr() { + pv = sv.Addr() + } else { + pv = reflect.New(sv.Type()) + pv.Elem().Set(sv) + } + if pv.Type().Implements(extendableProtoType) { + if err := writeExtensions(w, pv); err != nil { + return err + } + } + + return nil +} + +// writeRaw writes an uninterpreted raw message. +func writeRaw(w *textWriter, b []byte) error { + if err := w.WriteByte('<'); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte('\n'); err != nil { + return err + } + } + w.indent() + if err := writeUnknownStruct(w, b); err != nil { + return err + } + w.unindent() + if err := w.WriteByte('>'); err != nil { + return err + } + return nil +} + +// writeAny writes an arbitrary field. +func writeAny(w *textWriter, v reflect.Value, props *Properties) error { + v = reflect.Indirect(v) + + if props != nil && len(props.CustomType) > 0 { + custom, ok := v.Interface().(Marshaler) + if ok { + data, err := custom.Marshal() + if err != nil { + return err + } + if err := writeString(w, string(data)); err != nil { + return err + } + return nil + } + } + + // Floats have special cases. + if v.Kind() == reflect.Float32 || v.Kind() == reflect.Float64 { + x := v.Float() + var b []byte + switch { + case math.IsInf(x, 1): + b = posInf + case math.IsInf(x, -1): + b = negInf + case math.IsNaN(x): + b = nan + } + if b != nil { + _, err := w.Write(b) + return err + } + // Other values are handled below. + } + + // We don't attempt to serialise every possible value type; only those + // that can occur in protocol buffers. + switch v.Kind() { + case reflect.Slice: + // Should only be a []byte; repeated fields are handled in writeStruct. + if err := writeString(w, string(v.Bytes())); err != nil { + return err + } + case reflect.String: + if err := writeString(w, v.String()); err != nil { + return err + } + case reflect.Struct: + // Required/optional group/message. + var bra, ket byte = '<', '>' + if props != nil && props.Wire == "group" { + bra, ket = '{', '}' + } + if err := w.WriteByte(bra); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte('\n'); err != nil { + return err + } + } + w.indent() + if tm, ok := v.Interface().(encoding.TextMarshaler); ok { + text, err := tm.MarshalText() + if err != nil { + return err + } + if _, err = w.Write(text); err != nil { + return err + } + } else if err := writeStruct(w, v); err != nil { + return err + } + w.unindent() + if err := w.WriteByte(ket); err != nil { + return err + } + default: + _, err := fmt.Fprint(w, v.Interface()) + return err + } + return nil +} + +// equivalent to C's isprint. +func isprint(c byte) bool { + return c >= 0x20 && c < 0x7f +} + +// writeString writes a string in the protocol buffer text format. +// It is similar to strconv.Quote except we don't use Go escape sequences, +// we treat the string as a byte sequence, and we use octal escapes. +// These differences are to maintain interoperability with the other +// languages' implementations of the text format. +func writeString(w *textWriter, s string) error { + // use WriteByte here to get any needed indent + if err := w.WriteByte('"'); err != nil { + return err + } + // Loop over the bytes, not the runes. + for i := 0; i < len(s); i++ { + var err error + // Divergence from C++: we don't escape apostrophes. + // There's no need to escape them, and the C++ parser + // copes with a naked apostrophe. + switch c := s[i]; c { + case '\n': + _, err = w.w.Write(backslashN) + case '\r': + _, err = w.w.Write(backslashR) + case '\t': + _, err = w.w.Write(backslashT) + case '"': + _, err = w.w.Write(backslashDQ) + case '\\': + _, err = w.w.Write(backslashBS) + default: + if isprint(c) { + err = w.w.WriteByte(c) + } else { + _, err = fmt.Fprintf(w.w, "\\%03o", c) + } + } + if err != nil { + return err + } + } + return w.WriteByte('"') +} + +func writeUnknownStruct(w *textWriter, data []byte) (err error) { + if !w.compact { + if _, err := fmt.Fprintf(w, "/* %d unknown bytes */\n", len(data)); err != nil { + return err + } + } + b := NewBuffer(data) + for b.index < len(b.buf) { + x, err := b.DecodeVarint() + if err != nil { + _, ferr := fmt.Fprintf(w, "/* %v */\n", err) + return ferr + } + wire, tag := x&7, x>>3 + if wire == WireEndGroup { + w.unindent() + if _, werr := w.Write(endBraceNewline); werr != nil { + return werr + } + continue + } + if _, ferr := fmt.Fprint(w, tag); ferr != nil { + return ferr + } + if wire != WireStartGroup { + if err = w.WriteByte(':'); err != nil { + return err + } + } + if !w.compact || wire == WireStartGroup { + if err = w.WriteByte(' '); err != nil { + return err + } + } + switch wire { + case WireBytes: + buf, e := b.DecodeRawBytes(false) + if e == nil { + _, err = fmt.Fprintf(w, "%q", buf) + } else { + _, err = fmt.Fprintf(w, "/* %v */", e) + } + case WireFixed32: + x, err = b.DecodeFixed32() + err = writeUnknownInt(w, x, err) + case WireFixed64: + x, err = b.DecodeFixed64() + err = writeUnknownInt(w, x, err) + case WireStartGroup: + err = w.WriteByte('{') + w.indent() + case WireVarint: + x, err = b.DecodeVarint() + err = writeUnknownInt(w, x, err) + default: + _, err = fmt.Fprintf(w, "/* unknown wire type %d */", wire) + } + if err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + } + return nil +} + +func writeUnknownInt(w *textWriter, x uint64, err error) error { + if err == nil { + _, err = fmt.Fprint(w, x) + } else { + _, err = fmt.Fprintf(w, "/* %v */", err) + } + return err +} + +type int32Slice []int32 + +func (s int32Slice) Len() int { return len(s) } +func (s int32Slice) Less(i, j int) bool { return s[i] < s[j] } +func (s int32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } + +// writeExtensions writes all the extensions in pv. +// pv is assumed to be a pointer to a protocol message struct that is extendable. +func writeExtensions(w *textWriter, pv reflect.Value) error { + emap := extensionMaps[pv.Type().Elem()] + ep := pv.Interface().(extendableProto) + + // Order the extensions by ID. + // This isn't strictly necessary, but it will give us + // canonical output, which will also make testing easier. + var m map[int32]Extension + if em, ok := ep.(extensionsMap); ok { + m = em.ExtensionMap() + } else if em, ok := ep.(extensionsBytes); ok { + eb := em.GetExtensions() + var err error + m, err = BytesToExtensionsMap(*eb) + if err != nil { + return err + } + } + + ids := make([]int32, 0, len(m)) + for id := range m { + ids = append(ids, id) + } + sort.Sort(int32Slice(ids)) + + for _, extNum := range ids { + ext := m[extNum] + var desc *ExtensionDesc + if emap != nil { + desc = emap[extNum] + } + if desc == nil { + // Unknown extension. + if err := writeUnknownStruct(w, ext.enc); err != nil { + return err + } + continue + } + + pb, err := GetExtension(ep, desc) + if err != nil { + return fmt.Errorf("failed getting extension: %v", err) + } + + // Repeated extensions will appear as a slice. + if !desc.repeated() { + if err := writeExtension(w, desc.Name, pb); err != nil { + return err + } + } else { + v := reflect.ValueOf(pb) + for i := 0; i < v.Len(); i++ { + if err := writeExtension(w, desc.Name, v.Index(i).Interface()); err != nil { + return err + } + } + } + } + return nil +} + +func writeExtension(w *textWriter, name string, pb interface{}) error { + if _, err := fmt.Fprintf(w, "[%s]:", name); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + if err := writeAny(w, reflect.ValueOf(pb), nil); err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + return nil +} + +func (w *textWriter) writeIndent() { + if !w.complete { + return + } + remain := w.ind * 2 + for remain > 0 { + n := remain + if n > len(spaces) { + n = len(spaces) + } + w.w.Write(spaces[:n]) + remain -= n + } + w.complete = false +} + +func marshalText(w io.Writer, pb Message, compact bool) error { + val := reflect.ValueOf(pb) + if pb == nil || val.IsNil() { + w.Write([]byte("")) + return nil + } + var bw *bufio.Writer + ww, ok := w.(writer) + if !ok { + bw = bufio.NewWriter(w) + ww = bw + } + aw := &textWriter{ + w: ww, + complete: true, + compact: compact, + } + + if tm, ok := pb.(encoding.TextMarshaler); ok { + text, err := tm.MarshalText() + if err != nil { + return err + } + if _, err = aw.Write(text); err != nil { + return err + } + if bw != nil { + return bw.Flush() + } + return nil + } + // Dereference the received pointer so we don't have outer < and >. + v := reflect.Indirect(val) + if err := writeStruct(aw, v); err != nil { + return err + } + if bw != nil { + return bw.Flush() + } + return nil +} + +// MarshalText writes a given protocol buffer in text format. +// The only errors returned are from w. +func MarshalText(w io.Writer, pb Message) error { + return marshalText(w, pb, false) +} + +// MarshalTextString is the same as MarshalText, but returns the string directly. +func MarshalTextString(pb Message) string { + var buf bytes.Buffer + marshalText(&buf, pb, false) + return buf.String() +} + +// CompactText writes a given protocol buffer in compact text format (one line). +func CompactText(w io.Writer, pb Message) error { return marshalText(w, pb, true) } + +// CompactTextString is the same as CompactText, but returns the string directly. +func CompactTextString(pb Message) string { + var buf bytes.Buffer + marshalText(&buf, pb, true) + return buf.String() +} diff --git a/vendor/github.com/gogo/protobuf/proto/text_gogo.go b/vendor/github.com/gogo/protobuf/proto/text_gogo.go new file mode 100644 index 0000000000..cdb23373c3 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/text_gogo.go @@ -0,0 +1,55 @@ +// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. +// http://github.com/gogo/protobuf/gogoproto +// +// 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. +// +// 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. + +package proto + +import ( + "fmt" + "reflect" +) + +func writeEnum(w *textWriter, v reflect.Value, props *Properties) error { + m, ok := enumStringMaps[props.Enum] + if !ok { + if err := writeAny(w, v, props); err != nil { + return err + } + } + key := int32(0) + if v.Kind() == reflect.Ptr { + key = int32(v.Elem().Int()) + } else { + key = int32(v.Int()) + } + s, ok := m[key] + if !ok { + if err := writeAny(w, v, props); err != nil { + return err + } + } + _, err := fmt.Fprint(w, s) + return err +} diff --git a/vendor/github.com/gogo/protobuf/proto/text_parser.go b/vendor/github.com/gogo/protobuf/proto/text_parser.go new file mode 100644 index 0000000000..61b4bc8cc8 --- /dev/null +++ b/vendor/github.com/gogo/protobuf/proto/text_parser.go @@ -0,0 +1,849 @@ +// Extensions for Protocol Buffers to create more go like structures. +// +// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. +// http://github.com/gogo/protobuf/gogoproto +// +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +package proto + +// Functions for parsing the Text protocol buffer format. +// TODO: message sets. + +import ( + "encoding" + "errors" + "fmt" + "reflect" + "strconv" + "strings" + "unicode/utf8" +) + +type ParseError struct { + Message string + Line int // 1-based line number + Offset int // 0-based byte offset from start of input +} + +func (p *ParseError) Error() string { + if p.Line == 1 { + // show offset only for first line + return fmt.Sprintf("line 1.%d: %v", p.Offset, p.Message) + } + return fmt.Sprintf("line %d: %v", p.Line, p.Message) +} + +type token struct { + value string + err *ParseError + line int // line number + offset int // byte number from start of input, not start of line + unquoted string // the unquoted version of value, if it was a quoted string +} + +func (t *token) String() string { + if t.err == nil { + return fmt.Sprintf("%q (line=%d, offset=%d)", t.value, t.line, t.offset) + } + return fmt.Sprintf("parse error: %v", t.err) +} + +type textParser struct { + s string // remaining input + done bool // whether the parsing is finished (success or error) + backed bool // whether back() was called + offset, line int + cur token +} + +func newTextParser(s string) *textParser { + p := new(textParser) + p.s = s + p.line = 1 + p.cur.line = 1 + return p +} + +func (p *textParser) errorf(format string, a ...interface{}) *ParseError { + pe := &ParseError{fmt.Sprintf(format, a...), p.cur.line, p.cur.offset} + p.cur.err = pe + p.done = true + return pe +} + +// Numbers and identifiers are matched by [-+._A-Za-z0-9] +func isIdentOrNumberChar(c byte) bool { + switch { + case 'A' <= c && c <= 'Z', 'a' <= c && c <= 'z': + return true + case '0' <= c && c <= '9': + return true + } + switch c { + case '-', '+', '.', '_': + return true + } + return false +} + +func isWhitespace(c byte) bool { + switch c { + case ' ', '\t', '\n', '\r': + return true + } + return false +} + +func isQuote(c byte) bool { + switch c { + case '"', '\'': + return true + } + return false +} + +func (p *textParser) skipWhitespace() { + i := 0 + for i < len(p.s) && (isWhitespace(p.s[i]) || p.s[i] == '#') { + if p.s[i] == '#' { + // comment; skip to end of line or input + for i < len(p.s) && p.s[i] != '\n' { + i++ + } + if i == len(p.s) { + break + } + } + if p.s[i] == '\n' { + p.line++ + } + i++ + } + p.offset += i + p.s = p.s[i:len(p.s)] + if len(p.s) == 0 { + p.done = true + } +} + +func (p *textParser) advance() { + // Skip whitespace + p.skipWhitespace() + if p.done { + return + } + + // Start of non-whitespace + p.cur.err = nil + p.cur.offset, p.cur.line = p.offset, p.line + p.cur.unquoted = "" + switch p.s[0] { + case '<', '>', '{', '}', ':', '[', ']', ';', ',': + // Single symbol + p.cur.value, p.s = p.s[0:1], p.s[1:len(p.s)] + case '"', '\'': + // Quoted string + i := 1 + for i < len(p.s) && p.s[i] != p.s[0] && p.s[i] != '\n' { + if p.s[i] == '\\' && i+1 < len(p.s) { + // skip escaped char + i++ + } + i++ + } + if i >= len(p.s) || p.s[i] != p.s[0] { + p.errorf("unmatched quote") + return + } + unq, err := unquoteC(p.s[1:i], rune(p.s[0])) + if err != nil { + p.errorf("invalid quoted string %s: %v", p.s[0:i+1], err) + return + } + p.cur.value, p.s = p.s[0:i+1], p.s[i+1:len(p.s)] + p.cur.unquoted = unq + default: + i := 0 + for i < len(p.s) && isIdentOrNumberChar(p.s[i]) { + i++ + } + if i == 0 { + p.errorf("unexpected byte %#x", p.s[0]) + return + } + p.cur.value, p.s = p.s[0:i], p.s[i:len(p.s)] + } + p.offset += len(p.cur.value) +} + +var ( + errBadUTF8 = errors.New("proto: bad UTF-8") + errBadHex = errors.New("proto: bad hexadecimal") +) + +func unquoteC(s string, quote rune) (string, error) { + // This is based on C++'s tokenizer.cc. + // Despite its name, this is *not* parsing C syntax. + // For instance, "\0" is an invalid quoted string. + + // Avoid allocation in trivial cases. + simple := true + for _, r := range s { + if r == '\\' || r == quote { + simple = false + break + } + } + if simple { + return s, nil + } + + buf := make([]byte, 0, 3*len(s)/2) + for len(s) > 0 { + r, n := utf8.DecodeRuneInString(s) + if r == utf8.RuneError && n == 1 { + return "", errBadUTF8 + } + s = s[n:] + if r != '\\' { + if r < utf8.RuneSelf { + buf = append(buf, byte(r)) + } else { + buf = append(buf, string(r)...) + } + continue + } + + ch, tail, err := unescape(s) + if err != nil { + return "", err + } + buf = append(buf, ch...) + s = tail + } + return string(buf), nil +} + +func unescape(s string) (ch string, tail string, err error) { + r, n := utf8.DecodeRuneInString(s) + if r == utf8.RuneError && n == 1 { + return "", "", errBadUTF8 + } + s = s[n:] + switch r { + case 'a': + return "\a", s, nil + case 'b': + return "\b", s, nil + case 'f': + return "\f", s, nil + case 'n': + return "\n", s, nil + case 'r': + return "\r", s, nil + case 't': + return "\t", s, nil + case 'v': + return "\v", s, nil + case '?': + return "?", s, nil // trigraph workaround + case '\'', '"', '\\': + return string(r), s, nil + case '0', '1', '2', '3', '4', '5', '6', '7', 'x', 'X': + if len(s) < 2 { + return "", "", fmt.Errorf(`\%c requires 2 following digits`, r) + } + base := 8 + ss := s[:2] + s = s[2:] + if r == 'x' || r == 'X' { + base = 16 + } else { + ss = string(r) + ss + } + i, err := strconv.ParseUint(ss, base, 8) + if err != nil { + return "", "", err + } + return string([]byte{byte(i)}), s, nil + case 'u', 'U': + n := 4 + if r == 'U' { + n = 8 + } + if len(s) < n { + return "", "", fmt.Errorf(`\%c requires %d digits`, r, n) + } + + bs := make([]byte, n/2) + for i := 0; i < n; i += 2 { + a, ok1 := unhex(s[i]) + b, ok2 := unhex(s[i+1]) + if !ok1 || !ok2 { + return "", "", errBadHex + } + bs[i/2] = a<<4 | b + } + s = s[n:] + return string(bs), s, nil + } + return "", "", fmt.Errorf(`unknown escape \%c`, r) +} + +// Adapted from src/pkg/strconv/quote.go. +func unhex(b byte) (v byte, ok bool) { + switch { + case '0' <= b && b <= '9': + return b - '0', true + case 'a' <= b && b <= 'f': + return b - 'a' + 10, true + case 'A' <= b && b <= 'F': + return b - 'A' + 10, true + } + return 0, false +} + +// Back off the parser by one token. Can only be done between calls to next(). +// It makes the next advance() a no-op. +func (p *textParser) back() { p.backed = true } + +// Advances the parser and returns the new current token. +func (p *textParser) next() *token { + if p.backed || p.done { + p.backed = false + return &p.cur + } + p.advance() + if p.done { + p.cur.value = "" + } else if len(p.cur.value) > 0 && isQuote(p.cur.value[0]) { + // Look for multiple quoted strings separated by whitespace, + // and concatenate them. + cat := p.cur + for { + p.skipWhitespace() + if p.done || !isQuote(p.s[0]) { + break + } + p.advance() + if p.cur.err != nil { + return &p.cur + } + cat.value += " " + p.cur.value + cat.unquoted += p.cur.unquoted + } + p.done = false // parser may have seen EOF, but we want to return cat + p.cur = cat + } + return &p.cur +} + +func (p *textParser) consumeToken(s string) error { + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value != s { + p.back() + return p.errorf("expected %q, found %q", s, tok.value) + } + return nil +} + +// Return a RequiredNotSetError indicating which required field was not set. +func (p *textParser) missingRequiredFieldError(sv reflect.Value) *RequiredNotSetError { + st := sv.Type() + sprops := GetProperties(st) + for i := 0; i < st.NumField(); i++ { + if !isNil(sv.Field(i)) { + continue + } + + props := sprops.Prop[i] + if props.Required { + return &RequiredNotSetError{fmt.Sprintf("%v.%v", st, props.OrigName)} + } + } + return &RequiredNotSetError{fmt.Sprintf("%v.", st)} // should not happen +} + +// Returns the index in the struct for the named field, as well as the parsed tag properties. +func structFieldByName(sprops *StructProperties, name string) (int, *Properties, bool) { + i, ok := sprops.decoderOrigNames[name] + if ok { + return i, sprops.Prop[i], true + } + return -1, nil, false +} + +// Consume a ':' from the input stream (if the next token is a colon), +// returning an error if a colon is needed but not present. +func (p *textParser) checkForColon(props *Properties, typ reflect.Type) *ParseError { + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value != ":" { + // Colon is optional when the field is a group or message. + needColon := true + switch props.Wire { + case "group": + needColon = false + case "bytes": + // A "bytes" field is either a message, a string, or a repeated field; + // those three become *T, *string and []T respectively, so we can check for + // this field being a pointer to a non-string. + if typ.Kind() == reflect.Ptr { + // *T or *string + if typ.Elem().Kind() == reflect.String { + break + } + } else if typ.Kind() == reflect.Slice { + // []T or []*T + if typ.Elem().Kind() != reflect.Ptr { + break + } + } else if typ.Kind() == reflect.String { + // The proto3 exception is for a string field, + // which requires a colon. + break + } + needColon = false + } + if needColon { + return p.errorf("expected ':', found %q", tok.value) + } + p.back() + } + return nil +} + +func (p *textParser) readStruct(sv reflect.Value, terminator string) error { + st := sv.Type() + sprops := GetProperties(st) + reqCount := sprops.reqCount + var reqFieldErr error + fieldSet := make(map[string]bool) + // A struct is a sequence of "name: value", terminated by one of + // '>' or '}', or the end of the input. A name may also be + // "[extension]". + for { + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value == terminator { + break + } + if tok.value == "[" { + // Looks like an extension. + // + // TODO: Check whether we need to handle + // namespace rooted names (e.g. ".something.Foo"). + tok = p.next() + if tok.err != nil { + return tok.err + } + var desc *ExtensionDesc + // This could be faster, but it's functional. + // TODO: Do something smarter than a linear scan. + for _, d := range RegisteredExtensions(reflect.New(st).Interface().(Message)) { + if d.Name == tok.value { + desc = d + break + } + } + if desc == nil { + return p.errorf("unrecognized extension %q", tok.value) + } + // Check the extension terminator. + tok = p.next() + if tok.err != nil { + return tok.err + } + if tok.value != "]" { + return p.errorf("unrecognized extension terminator %q", tok.value) + } + + props := &Properties{} + props.Parse(desc.Tag) + + typ := reflect.TypeOf(desc.ExtensionType) + if err := p.checkForColon(props, typ); err != nil { + return err + } + + rep := desc.repeated() + + // Read the extension structure, and set it in + // the value we're constructing. + var ext reflect.Value + if !rep { + ext = reflect.New(typ).Elem() + } else { + ext = reflect.New(typ.Elem()).Elem() + } + if err := p.readAny(ext, props); err != nil { + if _, ok := err.(*RequiredNotSetError); !ok { + return err + } + reqFieldErr = err + } + ep := sv.Addr().Interface().(extendableProto) + if !rep { + SetExtension(ep, desc, ext.Interface()) + } else { + old, err := GetExtension(ep, desc) + var sl reflect.Value + if err == nil { + sl = reflect.ValueOf(old) // existing slice + } else { + sl = reflect.MakeSlice(typ, 0, 1) + } + sl = reflect.Append(sl, ext) + SetExtension(ep, desc, sl.Interface()) + } + if err := p.consumeOptionalSeparator(); err != nil { + return err + } + continue + } + + // This is a normal, non-extension field. + name := tok.value + var dst reflect.Value + fi, props, ok := structFieldByName(sprops, name) + if ok { + dst = sv.Field(fi) + } else if oop, ok := sprops.OneofTypes[name]; ok { + // It is a oneof. + props = oop.Prop + nv := reflect.New(oop.Type.Elem()) + dst = nv.Elem().Field(0) + sv.Field(oop.Field).Set(nv) + } + if !dst.IsValid() { + return p.errorf("unknown field name %q in %v", name, st) + } + + if dst.Kind() == reflect.Map { + // Consume any colon. + if err := p.checkForColon(props, dst.Type()); err != nil { + return err + } + + // Construct the map if it doesn't already exist. + if dst.IsNil() { + dst.Set(reflect.MakeMap(dst.Type())) + } + key := reflect.New(dst.Type().Key()).Elem() + val := reflect.New(dst.Type().Elem()).Elem() + + // The map entry should be this sequence of tokens: + // < key : KEY value : VALUE > + // Technically the "key" and "value" could come in any order, + // but in practice they won't. + + tok := p.next() + var terminator string + switch tok.value { + case "<": + terminator = ">" + case "{": + terminator = "}" + default: + return p.errorf("expected '{' or '<', found %q", tok.value) + } + if err := p.consumeToken("key"); err != nil { + return err + } + if err := p.consumeToken(":"); err != nil { + return err + } + if err := p.readAny(key, props.mkeyprop); err != nil { + return err + } + if err := p.consumeOptionalSeparator(); err != nil { + return err + } + if err := p.consumeToken("value"); err != nil { + return err + } + if err := p.checkForColon(props.mvalprop, dst.Type().Elem()); err != nil { + return err + } + if err := p.readAny(val, props.mvalprop); err != nil { + return err + } + if err := p.consumeOptionalSeparator(); err != nil { + return err + } + if err := p.consumeToken(terminator); err != nil { + return err + } + + dst.SetMapIndex(key, val) + continue + } + + // Check that it's not already set if it's not a repeated field. + if !props.Repeated && fieldSet[name] { + return p.errorf("non-repeated field %q was repeated", name) + } + + if err := p.checkForColon(props, dst.Type()); err != nil { + return err + } + + // Parse into the field. + fieldSet[name] = true + if err := p.readAny(dst, props); err != nil { + if _, ok := err.(*RequiredNotSetError); !ok { + return err + } + reqFieldErr = err + } else if props.Required { + reqCount-- + } + + if err := p.consumeOptionalSeparator(); err != nil { + return err + } + + } + + if reqCount > 0 { + return p.missingRequiredFieldError(sv) + } + return reqFieldErr +} + +// consumeOptionalSeparator consumes an optional semicolon or comma. +// It is used in readStruct to provide backward compatibility. +func (p *textParser) consumeOptionalSeparator() error { + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value != ";" && tok.value != "," { + p.back() + } + return nil +} + +func (p *textParser) readAny(v reflect.Value, props *Properties) error { + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value == "" { + return p.errorf("unexpected EOF") + } + if len(props.CustomType) > 0 { + if props.Repeated { + t := reflect.TypeOf(v.Interface()) + if t.Kind() == reflect.Slice { + tc := reflect.TypeOf(new(Marshaler)) + ok := t.Elem().Implements(tc.Elem()) + if ok { + fv := v + flen := fv.Len() + if flen == fv.Cap() { + nav := reflect.MakeSlice(v.Type(), flen, 2*flen+1) + reflect.Copy(nav, fv) + fv.Set(nav) + } + fv.SetLen(flen + 1) + + // Read one. + p.back() + return p.readAny(fv.Index(flen), props) + } + } + } + if reflect.TypeOf(v.Interface()).Kind() == reflect.Ptr { + custom := reflect.New(props.ctype.Elem()).Interface().(Unmarshaler) + err := custom.Unmarshal([]byte(tok.unquoted)) + if err != nil { + return p.errorf("%v %v: %v", err, v.Type(), tok.value) + } + v.Set(reflect.ValueOf(custom)) + } else { + custom := reflect.New(reflect.TypeOf(v.Interface())).Interface().(Unmarshaler) + err := custom.Unmarshal([]byte(tok.unquoted)) + if err != nil { + return p.errorf("%v %v: %v", err, v.Type(), tok.value) + } + v.Set(reflect.Indirect(reflect.ValueOf(custom))) + } + return nil + } + switch fv := v; fv.Kind() { + case reflect.Slice: + at := v.Type() + if at.Elem().Kind() == reflect.Uint8 { + // Special case for []byte + if tok.value[0] != '"' && tok.value[0] != '\'' { + // Deliberately written out here, as the error after + // this switch statement would write "invalid []byte: ...", + // which is not as user-friendly. + return p.errorf("invalid string: %v", tok.value) + } + bytes := []byte(tok.unquoted) + fv.Set(reflect.ValueOf(bytes)) + return nil + } + // Repeated field. + if tok.value == "[" { + // Repeated field with list notation, like [1,2,3]. + for { + fv.Set(reflect.Append(fv, reflect.New(at.Elem()).Elem())) + err := p.readAny(fv.Index(fv.Len()-1), props) + if err != nil { + return err + } + ntok := p.next() + if ntok.err != nil { + return ntok.err + } + if ntok.value == "]" { + break + } + if ntok.value != "," { + return p.errorf("Expected ']' or ',' found %q", ntok.value) + } + } + return nil + } + // One value of the repeated field. + p.back() + fv.Set(reflect.Append(fv, reflect.New(at.Elem()).Elem())) + return p.readAny(fv.Index(fv.Len()-1), props) + case reflect.Bool: + // Either "true", "false", 1 or 0. + switch tok.value { + case "true", "1": + fv.SetBool(true) + return nil + case "false", "0": + fv.SetBool(false) + return nil + } + case reflect.Float32, reflect.Float64: + v := tok.value + // Ignore 'f' for compatibility with output generated by C++, but don't + // remove 'f' when the value is "-inf" or "inf". + if strings.HasSuffix(v, "f") && tok.value != "-inf" && tok.value != "inf" { + v = v[:len(v)-1] + } + if f, err := strconv.ParseFloat(v, fv.Type().Bits()); err == nil { + fv.SetFloat(f) + return nil + } + case reflect.Int32: + if x, err := strconv.ParseInt(tok.value, 0, 32); err == nil { + fv.SetInt(x) + return nil + } + + if len(props.Enum) == 0 { + break + } + m, ok := enumValueMaps[props.Enum] + if !ok { + break + } + x, ok := m[tok.value] + if !ok { + break + } + fv.SetInt(int64(x)) + return nil + case reflect.Int64: + if x, err := strconv.ParseInt(tok.value, 0, 64); err == nil { + fv.SetInt(x) + return nil + } + + case reflect.Ptr: + // A basic field (indirected through pointer), or a repeated message/group + p.back() + fv.Set(reflect.New(fv.Type().Elem())) + return p.readAny(fv.Elem(), props) + case reflect.String: + if tok.value[0] == '"' || tok.value[0] == '\'' { + fv.SetString(tok.unquoted) + return nil + } + case reflect.Struct: + var terminator string + switch tok.value { + case "{": + terminator = "}" + case "<": + terminator = ">" + default: + return p.errorf("expected '{' or '<', found %q", tok.value) + } + // TODO: Handle nested messages which implement encoding.TextUnmarshaler. + return p.readStruct(fv, terminator) + case reflect.Uint32: + if x, err := strconv.ParseUint(tok.value, 0, 32); err == nil { + fv.SetUint(uint64(x)) + return nil + } + case reflect.Uint64: + if x, err := strconv.ParseUint(tok.value, 0, 64); err == nil { + fv.SetUint(x) + return nil + } + } + return p.errorf("invalid %v: %v", v.Type(), tok.value) +} + +// UnmarshalText reads a protocol buffer in Text format. UnmarshalText resets pb +// before starting to unmarshal, so any existing data in pb is always removed. +// If a required field is not set and no other error occurs, +// UnmarshalText returns *RequiredNotSetError. +func UnmarshalText(s string, pb Message) error { + if um, ok := pb.(encoding.TextUnmarshaler); ok { + err := um.UnmarshalText([]byte(s)) + return err + } + pb.Reset() + v := reflect.ValueOf(pb) + if pe := newTextParser(s).readStruct(v.Elem(), ""); pe != nil { + return pe + } + return nil +} diff --git a/vendor/github.com/golang/protobuf/LICENSE b/vendor/github.com/golang/protobuf/LICENSE new file mode 100644 index 0000000000..1b1b1921ef --- /dev/null +++ b/vendor/github.com/golang/protobuf/LICENSE @@ -0,0 +1,31 @@ +Go support for Protocol Buffers - Google's data interchange format + +Copyright 2010 The Go Authors. All rights reserved. +https://github.com/golang/protobuf + +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. + diff --git a/vendor/github.com/golang/protobuf/proto/clone.go b/vendor/github.com/golang/protobuf/proto/clone.go new file mode 100644 index 0000000000..e98ddec981 --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/clone.go @@ -0,0 +1,223 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2011 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +// Protocol buffer deep copy and merge. +// TODO: RawMessage. + +package proto + +import ( + "log" + "reflect" + "strings" +) + +// Clone returns a deep copy of a protocol buffer. +func Clone(pb Message) Message { + in := reflect.ValueOf(pb) + if in.IsNil() { + return pb + } + + out := reflect.New(in.Type().Elem()) + // out is empty so a merge is a deep copy. + mergeStruct(out.Elem(), in.Elem()) + return out.Interface().(Message) +} + +// Merge merges src into dst. +// Required and optional fields that are set in src will be set to that value in dst. +// Elements of repeated fields will be appended. +// Merge panics if src and dst are not the same type, or if dst is nil. +func Merge(dst, src Message) { + in := reflect.ValueOf(src) + out := reflect.ValueOf(dst) + if out.IsNil() { + panic("proto: nil destination") + } + if in.Type() != out.Type() { + // Explicit test prior to mergeStruct so that mistyped nils will fail + panic("proto: type mismatch") + } + if in.IsNil() { + // Merging nil into non-nil is a quiet no-op + return + } + mergeStruct(out.Elem(), in.Elem()) +} + +func mergeStruct(out, in reflect.Value) { + sprop := GetProperties(in.Type()) + for i := 0; i < in.NumField(); i++ { + f := in.Type().Field(i) + if strings.HasPrefix(f.Name, "XXX_") { + continue + } + mergeAny(out.Field(i), in.Field(i), false, sprop.Prop[i]) + } + + if emIn, ok := in.Addr().Interface().(extendableProto); ok { + emOut := out.Addr().Interface().(extendableProto) + mergeExtension(emOut.ExtensionMap(), emIn.ExtensionMap()) + } + + uf := in.FieldByName("XXX_unrecognized") + if !uf.IsValid() { + return + } + uin := uf.Bytes() + if len(uin) > 0 { + out.FieldByName("XXX_unrecognized").SetBytes(append([]byte(nil), uin...)) + } +} + +// mergeAny performs a merge between two values of the same type. +// viaPtr indicates whether the values were indirected through a pointer (implying proto2). +// prop is set if this is a struct field (it may be nil). +func mergeAny(out, in reflect.Value, viaPtr bool, prop *Properties) { + if in.Type() == protoMessageType { + if !in.IsNil() { + if out.IsNil() { + out.Set(reflect.ValueOf(Clone(in.Interface().(Message)))) + } else { + Merge(out.Interface().(Message), in.Interface().(Message)) + } + } + return + } + switch in.Kind() { + case reflect.Bool, reflect.Float32, reflect.Float64, reflect.Int32, reflect.Int64, + reflect.String, reflect.Uint32, reflect.Uint64: + if !viaPtr && isProto3Zero(in) { + return + } + out.Set(in) + case reflect.Interface: + // Probably a oneof field; copy non-nil values. + if in.IsNil() { + return + } + // Allocate destination if it is not set, or set to a different type. + // Otherwise we will merge as normal. + if out.IsNil() || out.Elem().Type() != in.Elem().Type() { + out.Set(reflect.New(in.Elem().Elem().Type())) // interface -> *T -> T -> new(T) + } + mergeAny(out.Elem(), in.Elem(), false, nil) + case reflect.Map: + if in.Len() == 0 { + return + } + if out.IsNil() { + out.Set(reflect.MakeMap(in.Type())) + } + // For maps with value types of *T or []byte we need to deep copy each value. + elemKind := in.Type().Elem().Kind() + for _, key := range in.MapKeys() { + var val reflect.Value + switch elemKind { + case reflect.Ptr: + val = reflect.New(in.Type().Elem().Elem()) + mergeAny(val, in.MapIndex(key), false, nil) + case reflect.Slice: + val = in.MapIndex(key) + val = reflect.ValueOf(append([]byte{}, val.Bytes()...)) + default: + val = in.MapIndex(key) + } + out.SetMapIndex(key, val) + } + case reflect.Ptr: + if in.IsNil() { + return + } + if out.IsNil() { + out.Set(reflect.New(in.Elem().Type())) + } + mergeAny(out.Elem(), in.Elem(), true, nil) + case reflect.Slice: + if in.IsNil() { + return + } + if in.Type().Elem().Kind() == reflect.Uint8 { + // []byte is a scalar bytes field, not a repeated field. + + // Edge case: if this is in a proto3 message, a zero length + // bytes field is considered the zero value, and should not + // be merged. + if prop != nil && prop.proto3 && in.Len() == 0 { + return + } + + // Make a deep copy. + // Append to []byte{} instead of []byte(nil) so that we never end up + // with a nil result. + out.SetBytes(append([]byte{}, in.Bytes()...)) + return + } + n := in.Len() + if out.IsNil() { + out.Set(reflect.MakeSlice(in.Type(), 0, n)) + } + switch in.Type().Elem().Kind() { + case reflect.Bool, reflect.Float32, reflect.Float64, reflect.Int32, reflect.Int64, + reflect.String, reflect.Uint32, reflect.Uint64: + out.Set(reflect.AppendSlice(out, in)) + default: + for i := 0; i < n; i++ { + x := reflect.Indirect(reflect.New(in.Type().Elem())) + mergeAny(x, in.Index(i), false, nil) + out.Set(reflect.Append(out, x)) + } + } + case reflect.Struct: + mergeStruct(out, in) + default: + // unknown type, so not a protocol buffer + log.Printf("proto: don't know how to copy %v", in) + } +} + +func mergeExtension(out, in map[int32]Extension) { + for extNum, eIn := range in { + eOut := Extension{desc: eIn.desc} + if eIn.value != nil { + v := reflect.New(reflect.TypeOf(eIn.value)).Elem() + mergeAny(v, reflect.ValueOf(eIn.value), false, nil) + eOut.value = v.Interface() + } + if eIn.enc != nil { + eOut.enc = make([]byte, len(eIn.enc)) + copy(eOut.enc, eIn.enc) + } + + out[extNum] = eOut + } +} diff --git a/vendor/github.com/golang/protobuf/proto/decode.go b/vendor/github.com/golang/protobuf/proto/decode.go new file mode 100644 index 0000000000..5810782fd8 --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/decode.go @@ -0,0 +1,867 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +package proto + +/* + * Routines for decoding protocol buffer data to construct in-memory representations. + */ + +import ( + "errors" + "fmt" + "io" + "os" + "reflect" +) + +// errOverflow is returned when an integer is too large to be represented. +var errOverflow = errors.New("proto: integer overflow") + +// ErrInternalBadWireType is returned by generated code when an incorrect +// wire type is encountered. It does not get returned to user code. +var ErrInternalBadWireType = errors.New("proto: internal error: bad wiretype for oneof") + +// The fundamental decoders that interpret bytes on the wire. +// Those that take integer types all return uint64 and are +// therefore of type valueDecoder. + +// DecodeVarint reads a varint-encoded integer from the slice. +// It returns the integer and the number of bytes consumed, or +// zero if there is not enough. +// This is the format for the +// int32, int64, uint32, uint64, bool, and enum +// protocol buffer types. +func DecodeVarint(buf []byte) (x uint64, n int) { + // x, n already 0 + for shift := uint(0); shift < 64; shift += 7 { + if n >= len(buf) { + return 0, 0 + } + b := uint64(buf[n]) + n++ + x |= (b & 0x7F) << shift + if (b & 0x80) == 0 { + return x, n + } + } + + // The number is too large to represent in a 64-bit value. + return 0, 0 +} + +// DecodeVarint reads a varint-encoded integer from the Buffer. +// This is the format for the +// int32, int64, uint32, uint64, bool, and enum +// protocol buffer types. +func (p *Buffer) DecodeVarint() (x uint64, err error) { + // x, err already 0 + + i := p.index + l := len(p.buf) + + for shift := uint(0); shift < 64; shift += 7 { + if i >= l { + err = io.ErrUnexpectedEOF + return + } + b := p.buf[i] + i++ + x |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + p.index = i + return + } + } + + // The number is too large to represent in a 64-bit value. + err = errOverflow + return +} + +// DecodeFixed64 reads a 64-bit integer from the Buffer. +// This is the format for the +// fixed64, sfixed64, and double protocol buffer types. +func (p *Buffer) DecodeFixed64() (x uint64, err error) { + // x, err already 0 + i := p.index + 8 + if i < 0 || i > len(p.buf) { + err = io.ErrUnexpectedEOF + return + } + p.index = i + + x = uint64(p.buf[i-8]) + x |= uint64(p.buf[i-7]) << 8 + x |= uint64(p.buf[i-6]) << 16 + x |= uint64(p.buf[i-5]) << 24 + x |= uint64(p.buf[i-4]) << 32 + x |= uint64(p.buf[i-3]) << 40 + x |= uint64(p.buf[i-2]) << 48 + x |= uint64(p.buf[i-1]) << 56 + return +} + +// DecodeFixed32 reads a 32-bit integer from the Buffer. +// This is the format for the +// fixed32, sfixed32, and float protocol buffer types. +func (p *Buffer) DecodeFixed32() (x uint64, err error) { + // x, err already 0 + i := p.index + 4 + if i < 0 || i > len(p.buf) { + err = io.ErrUnexpectedEOF + return + } + p.index = i + + x = uint64(p.buf[i-4]) + x |= uint64(p.buf[i-3]) << 8 + x |= uint64(p.buf[i-2]) << 16 + x |= uint64(p.buf[i-1]) << 24 + return +} + +// DecodeZigzag64 reads a zigzag-encoded 64-bit integer +// from the Buffer. +// This is the format used for the sint64 protocol buffer type. +func (p *Buffer) DecodeZigzag64() (x uint64, err error) { + x, err = p.DecodeVarint() + if err != nil { + return + } + x = (x >> 1) ^ uint64((int64(x&1)<<63)>>63) + return +} + +// DecodeZigzag32 reads a zigzag-encoded 32-bit integer +// from the Buffer. +// This is the format used for the sint32 protocol buffer type. +func (p *Buffer) DecodeZigzag32() (x uint64, err error) { + x, err = p.DecodeVarint() + if err != nil { + return + } + x = uint64((uint32(x) >> 1) ^ uint32((int32(x&1)<<31)>>31)) + return +} + +// These are not ValueDecoders: they produce an array of bytes or a string. +// bytes, embedded messages + +// DecodeRawBytes reads a count-delimited byte buffer from the Buffer. +// This is the format used for the bytes protocol buffer +// type and for embedded messages. +func (p *Buffer) DecodeRawBytes(alloc bool) (buf []byte, err error) { + n, err := p.DecodeVarint() + if err != nil { + return nil, err + } + + nb := int(n) + if nb < 0 { + return nil, fmt.Errorf("proto: bad byte length %d", nb) + } + end := p.index + nb + if end < p.index || end > len(p.buf) { + return nil, io.ErrUnexpectedEOF + } + + if !alloc { + // todo: check if can get more uses of alloc=false + buf = p.buf[p.index:end] + p.index += nb + return + } + + buf = make([]byte, nb) + copy(buf, p.buf[p.index:]) + p.index += nb + return +} + +// DecodeStringBytes reads an encoded string from the Buffer. +// This is the format used for the proto2 string type. +func (p *Buffer) DecodeStringBytes() (s string, err error) { + buf, err := p.DecodeRawBytes(false) + if err != nil { + return + } + return string(buf), nil +} + +// Skip the next item in the buffer. Its wire type is decoded and presented as an argument. +// If the protocol buffer has extensions, and the field matches, add it as an extension. +// Otherwise, if the XXX_unrecognized field exists, append the skipped data there. +func (o *Buffer) skipAndSave(t reflect.Type, tag, wire int, base structPointer, unrecField field) error { + oi := o.index + + err := o.skip(t, tag, wire) + if err != nil { + return err + } + + if !unrecField.IsValid() { + return nil + } + + ptr := structPointer_Bytes(base, unrecField) + + // Add the skipped field to struct field + obuf := o.buf + + o.buf = *ptr + o.EncodeVarint(uint64(tag<<3 | wire)) + *ptr = append(o.buf, obuf[oi:o.index]...) + + o.buf = obuf + + return nil +} + +// Skip the next item in the buffer. Its wire type is decoded and presented as an argument. +func (o *Buffer) skip(t reflect.Type, tag, wire int) error { + + var u uint64 + var err error + + switch wire { + case WireVarint: + _, err = o.DecodeVarint() + case WireFixed64: + _, err = o.DecodeFixed64() + case WireBytes: + _, err = o.DecodeRawBytes(false) + case WireFixed32: + _, err = o.DecodeFixed32() + case WireStartGroup: + for { + u, err = o.DecodeVarint() + if err != nil { + break + } + fwire := int(u & 0x7) + if fwire == WireEndGroup { + break + } + ftag := int(u >> 3) + err = o.skip(t, ftag, fwire) + if err != nil { + break + } + } + default: + err = fmt.Errorf("proto: can't skip unknown wire type %d for %s", wire, t) + } + return err +} + +// Unmarshaler is the interface representing objects that can +// unmarshal themselves. The method should reset the receiver before +// decoding starts. The argument points to data that may be +// overwritten, so implementations should not keep references to the +// buffer. +type Unmarshaler interface { + Unmarshal([]byte) error +} + +// Unmarshal parses the protocol buffer representation in buf and places the +// decoded result in pb. If the struct underlying pb does not match +// the data in buf, the results can be unpredictable. +// +// Unmarshal resets pb before starting to unmarshal, so any +// existing data in pb is always removed. Use UnmarshalMerge +// to preserve and append to existing data. +func Unmarshal(buf []byte, pb Message) error { + pb.Reset() + return UnmarshalMerge(buf, pb) +} + +// UnmarshalMerge parses the protocol buffer representation in buf and +// writes the decoded result to pb. If the struct underlying pb does not match +// the data in buf, the results can be unpredictable. +// +// UnmarshalMerge merges into existing data in pb. +// Most code should use Unmarshal instead. +func UnmarshalMerge(buf []byte, pb Message) error { + // If the object can unmarshal itself, let it. + if u, ok := pb.(Unmarshaler); ok { + return u.Unmarshal(buf) + } + return NewBuffer(buf).Unmarshal(pb) +} + +// DecodeMessage reads a count-delimited message from the Buffer. +func (p *Buffer) DecodeMessage(pb Message) error { + enc, err := p.DecodeRawBytes(false) + if err != nil { + return err + } + return NewBuffer(enc).Unmarshal(pb) +} + +// DecodeGroup reads a tag-delimited group from the Buffer. +func (p *Buffer) DecodeGroup(pb Message) error { + typ, base, err := getbase(pb) + if err != nil { + return err + } + return p.unmarshalType(typ.Elem(), GetProperties(typ.Elem()), true, base) +} + +// Unmarshal parses the protocol buffer representation in the +// Buffer and places the decoded result in pb. If the struct +// underlying pb does not match the data in the buffer, the results can be +// unpredictable. +func (p *Buffer) Unmarshal(pb Message) error { + // If the object can unmarshal itself, let it. + if u, ok := pb.(Unmarshaler); ok { + err := u.Unmarshal(p.buf[p.index:]) + p.index = len(p.buf) + return err + } + + typ, base, err := getbase(pb) + if err != nil { + return err + } + + err = p.unmarshalType(typ.Elem(), GetProperties(typ.Elem()), false, base) + + if collectStats { + stats.Decode++ + } + + return err +} + +// unmarshalType does the work of unmarshaling a structure. +func (o *Buffer) unmarshalType(st reflect.Type, prop *StructProperties, is_group bool, base structPointer) error { + var state errorState + required, reqFields := prop.reqCount, uint64(0) + + var err error + for err == nil && o.index < len(o.buf) { + oi := o.index + var u uint64 + u, err = o.DecodeVarint() + if err != nil { + break + } + wire := int(u & 0x7) + if wire == WireEndGroup { + if is_group { + return nil // input is satisfied + } + return fmt.Errorf("proto: %s: wiretype end group for non-group", st) + } + tag := int(u >> 3) + if tag <= 0 { + return fmt.Errorf("proto: %s: illegal tag %d (wire type %d)", st, tag, wire) + } + fieldnum, ok := prop.decoderTags.get(tag) + if !ok { + // Maybe it's an extension? + if prop.extendable { + if e := structPointer_Interface(base, st).(extendableProto); isExtensionField(e, int32(tag)) { + if err = o.skip(st, tag, wire); err == nil { + ext := e.ExtensionMap()[int32(tag)] // may be missing + ext.enc = append(ext.enc, o.buf[oi:o.index]...) + e.ExtensionMap()[int32(tag)] = ext + } + continue + } + } + // Maybe it's a oneof? + if prop.oneofUnmarshaler != nil { + m := structPointer_Interface(base, st).(Message) + // First return value indicates whether tag is a oneof field. + ok, err = prop.oneofUnmarshaler(m, tag, wire, o) + if err == ErrInternalBadWireType { + // Map the error to something more descriptive. + // Do the formatting here to save generated code space. + err = fmt.Errorf("bad wiretype for oneof field in %T", m) + } + if ok { + continue + } + } + err = o.skipAndSave(st, tag, wire, base, prop.unrecField) + continue + } + p := prop.Prop[fieldnum] + + if p.dec == nil { + fmt.Fprintf(os.Stderr, "proto: no protobuf decoder for %s.%s\n", st, st.Field(fieldnum).Name) + continue + } + dec := p.dec + if wire != WireStartGroup && wire != p.WireType { + if wire == WireBytes && p.packedDec != nil { + // a packable field + dec = p.packedDec + } else { + err = fmt.Errorf("proto: bad wiretype for field %s.%s: got wiretype %d, want %d", st, st.Field(fieldnum).Name, wire, p.WireType) + continue + } + } + decErr := dec(o, p, base) + if decErr != nil && !state.shouldContinue(decErr, p) { + err = decErr + } + if err == nil && p.Required { + // Successfully decoded a required field. + if tag <= 64 { + // use bitmap for fields 1-64 to catch field reuse. + var mask uint64 = 1 << uint64(tag-1) + if reqFields&mask == 0 { + // new required field + reqFields |= mask + required-- + } + } else { + // This is imprecise. It can be fooled by a required field + // with a tag > 64 that is encoded twice; that's very rare. + // A fully correct implementation would require allocating + // a data structure, which we would like to avoid. + required-- + } + } + } + if err == nil { + if is_group { + return io.ErrUnexpectedEOF + } + if state.err != nil { + return state.err + } + if required > 0 { + // Not enough information to determine the exact field. If we use extra + // CPU, we could determine the field only if the missing required field + // has a tag <= 64 and we check reqFields. + return &RequiredNotSetError{"{Unknown}"} + } + } + return err +} + +// Individual type decoders +// For each, +// u is the decoded value, +// v is a pointer to the field (pointer) in the struct + +// Sizes of the pools to allocate inside the Buffer. +// The goal is modest amortization and allocation +// on at least 16-byte boundaries. +const ( + boolPoolSize = 16 + uint32PoolSize = 8 + uint64PoolSize = 4 +) + +// Decode a bool. +func (o *Buffer) dec_bool(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + if len(o.bools) == 0 { + o.bools = make([]bool, boolPoolSize) + } + o.bools[0] = u != 0 + *structPointer_Bool(base, p.field) = &o.bools[0] + o.bools = o.bools[1:] + return nil +} + +func (o *Buffer) dec_proto3_bool(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + *structPointer_BoolVal(base, p.field) = u != 0 + return nil +} + +// Decode an int32. +func (o *Buffer) dec_int32(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + word32_Set(structPointer_Word32(base, p.field), o, uint32(u)) + return nil +} + +func (o *Buffer) dec_proto3_int32(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + word32Val_Set(structPointer_Word32Val(base, p.field), uint32(u)) + return nil +} + +// Decode an int64. +func (o *Buffer) dec_int64(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + word64_Set(structPointer_Word64(base, p.field), o, u) + return nil +} + +func (o *Buffer) dec_proto3_int64(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + word64Val_Set(structPointer_Word64Val(base, p.field), o, u) + return nil +} + +// Decode a string. +func (o *Buffer) dec_string(p *Properties, base structPointer) error { + s, err := o.DecodeStringBytes() + if err != nil { + return err + } + *structPointer_String(base, p.field) = &s + return nil +} + +func (o *Buffer) dec_proto3_string(p *Properties, base structPointer) error { + s, err := o.DecodeStringBytes() + if err != nil { + return err + } + *structPointer_StringVal(base, p.field) = s + return nil +} + +// Decode a slice of bytes ([]byte). +func (o *Buffer) dec_slice_byte(p *Properties, base structPointer) error { + b, err := o.DecodeRawBytes(true) + if err != nil { + return err + } + *structPointer_Bytes(base, p.field) = b + return nil +} + +// Decode a slice of bools ([]bool). +func (o *Buffer) dec_slice_bool(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + v := structPointer_BoolSlice(base, p.field) + *v = append(*v, u != 0) + return nil +} + +// Decode a slice of bools ([]bool) in packed format. +func (o *Buffer) dec_slice_packed_bool(p *Properties, base structPointer) error { + v := structPointer_BoolSlice(base, p.field) + + nn, err := o.DecodeVarint() + if err != nil { + return err + } + nb := int(nn) // number of bytes of encoded bools + fin := o.index + nb + if fin < o.index { + return errOverflow + } + + y := *v + for o.index < fin { + u, err := p.valDec(o) + if err != nil { + return err + } + y = append(y, u != 0) + } + + *v = y + return nil +} + +// Decode a slice of int32s ([]int32). +func (o *Buffer) dec_slice_int32(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + structPointer_Word32Slice(base, p.field).Append(uint32(u)) + return nil +} + +// Decode a slice of int32s ([]int32) in packed format. +func (o *Buffer) dec_slice_packed_int32(p *Properties, base structPointer) error { + v := structPointer_Word32Slice(base, p.field) + + nn, err := o.DecodeVarint() + if err != nil { + return err + } + nb := int(nn) // number of bytes of encoded int32s + + fin := o.index + nb + if fin < o.index { + return errOverflow + } + for o.index < fin { + u, err := p.valDec(o) + if err != nil { + return err + } + v.Append(uint32(u)) + } + return nil +} + +// Decode a slice of int64s ([]int64). +func (o *Buffer) dec_slice_int64(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + + structPointer_Word64Slice(base, p.field).Append(u) + return nil +} + +// Decode a slice of int64s ([]int64) in packed format. +func (o *Buffer) dec_slice_packed_int64(p *Properties, base structPointer) error { + v := structPointer_Word64Slice(base, p.field) + + nn, err := o.DecodeVarint() + if err != nil { + return err + } + nb := int(nn) // number of bytes of encoded int64s + + fin := o.index + nb + if fin < o.index { + return errOverflow + } + for o.index < fin { + u, err := p.valDec(o) + if err != nil { + return err + } + v.Append(u) + } + return nil +} + +// Decode a slice of strings ([]string). +func (o *Buffer) dec_slice_string(p *Properties, base structPointer) error { + s, err := o.DecodeStringBytes() + if err != nil { + return err + } + v := structPointer_StringSlice(base, p.field) + *v = append(*v, s) + return nil +} + +// Decode a slice of slice of bytes ([][]byte). +func (o *Buffer) dec_slice_slice_byte(p *Properties, base structPointer) error { + b, err := o.DecodeRawBytes(true) + if err != nil { + return err + } + v := structPointer_BytesSlice(base, p.field) + *v = append(*v, b) + return nil +} + +// Decode a map field. +func (o *Buffer) dec_new_map(p *Properties, base structPointer) error { + raw, err := o.DecodeRawBytes(false) + if err != nil { + return err + } + oi := o.index // index at the end of this map entry + o.index -= len(raw) // move buffer back to start of map entry + + mptr := structPointer_NewAt(base, p.field, p.mtype) // *map[K]V + if mptr.Elem().IsNil() { + mptr.Elem().Set(reflect.MakeMap(mptr.Type().Elem())) + } + v := mptr.Elem() // map[K]V + + // Prepare addressable doubly-indirect placeholders for the key and value types. + // See enc_new_map for why. + keyptr := reflect.New(reflect.PtrTo(p.mtype.Key())).Elem() // addressable *K + keybase := toStructPointer(keyptr.Addr()) // **K + + var valbase structPointer + var valptr reflect.Value + switch p.mtype.Elem().Kind() { + case reflect.Slice: + // []byte + var dummy []byte + valptr = reflect.ValueOf(&dummy) // *[]byte + valbase = toStructPointer(valptr) // *[]byte + case reflect.Ptr: + // message; valptr is **Msg; need to allocate the intermediate pointer + valptr = reflect.New(reflect.PtrTo(p.mtype.Elem())).Elem() // addressable *V + valptr.Set(reflect.New(valptr.Type().Elem())) + valbase = toStructPointer(valptr) + default: + // everything else + valptr = reflect.New(reflect.PtrTo(p.mtype.Elem())).Elem() // addressable *V + valbase = toStructPointer(valptr.Addr()) // **V + } + + // Decode. + // This parses a restricted wire format, namely the encoding of a message + // with two fields. See enc_new_map for the format. + for o.index < oi { + // tagcode for key and value properties are always a single byte + // because they have tags 1 and 2. + tagcode := o.buf[o.index] + o.index++ + switch tagcode { + case p.mkeyprop.tagcode[0]: + if err := p.mkeyprop.dec(o, p.mkeyprop, keybase); err != nil { + return err + } + case p.mvalprop.tagcode[0]: + if err := p.mvalprop.dec(o, p.mvalprop, valbase); err != nil { + return err + } + default: + // TODO: Should we silently skip this instead? + return fmt.Errorf("proto: bad map data tag %d", raw[0]) + } + } + keyelem, valelem := keyptr.Elem(), valptr.Elem() + if !keyelem.IsValid() || !valelem.IsValid() { + // We did not decode the key or the value in the map entry. + // Either way, it's an invalid map entry. + return fmt.Errorf("proto: bad map data: missing key/val") + } + + v.SetMapIndex(keyelem, valelem) + return nil +} + +// Decode a group. +func (o *Buffer) dec_struct_group(p *Properties, base structPointer) error { + bas := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(bas) { + // allocate new nested message + bas = toStructPointer(reflect.New(p.stype)) + structPointer_SetStructPointer(base, p.field, bas) + } + return o.unmarshalType(p.stype, p.sprop, true, bas) +} + +// Decode an embedded message. +func (o *Buffer) dec_struct_message(p *Properties, base structPointer) (err error) { + raw, e := o.DecodeRawBytes(false) + if e != nil { + return e + } + + bas := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(bas) { + // allocate new nested message + bas = toStructPointer(reflect.New(p.stype)) + structPointer_SetStructPointer(base, p.field, bas) + } + + // If the object can unmarshal itself, let it. + if p.isUnmarshaler { + iv := structPointer_Interface(bas, p.stype) + return iv.(Unmarshaler).Unmarshal(raw) + } + + obuf := o.buf + oi := o.index + o.buf = raw + o.index = 0 + + err = o.unmarshalType(p.stype, p.sprop, false, bas) + o.buf = obuf + o.index = oi + + return err +} + +// Decode a slice of embedded messages. +func (o *Buffer) dec_slice_struct_message(p *Properties, base structPointer) error { + return o.dec_slice_struct(p, false, base) +} + +// Decode a slice of embedded groups. +func (o *Buffer) dec_slice_struct_group(p *Properties, base structPointer) error { + return o.dec_slice_struct(p, true, base) +} + +// Decode a slice of structs ([]*struct). +func (o *Buffer) dec_slice_struct(p *Properties, is_group bool, base structPointer) error { + v := reflect.New(p.stype) + bas := toStructPointer(v) + structPointer_StructPointerSlice(base, p.field).Append(bas) + + if is_group { + err := o.unmarshalType(p.stype, p.sprop, is_group, bas) + return err + } + + raw, err := o.DecodeRawBytes(false) + if err != nil { + return err + } + + // If the object can unmarshal itself, let it. + if p.isUnmarshaler { + iv := v.Interface() + return iv.(Unmarshaler).Unmarshal(raw) + } + + obuf := o.buf + oi := o.index + o.buf = raw + o.index = 0 + + err = o.unmarshalType(p.stype, p.sprop, is_group, bas) + + o.buf = obuf + o.index = oi + + return err +} diff --git a/vendor/github.com/golang/protobuf/proto/encode.go b/vendor/github.com/golang/protobuf/proto/encode.go new file mode 100644 index 0000000000..231b07401a --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/encode.go @@ -0,0 +1,1325 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +package proto + +/* + * Routines for encoding data into the wire format for protocol buffers. + */ + +import ( + "errors" + "fmt" + "reflect" + "sort" +) + +// RequiredNotSetError is the error returned if Marshal is called with +// a protocol buffer struct whose required fields have not +// all been initialized. It is also the error returned if Unmarshal is +// called with an encoded protocol buffer that does not include all the +// required fields. +// +// When printed, RequiredNotSetError reports the first unset required field in a +// message. If the field cannot be precisely determined, it is reported as +// "{Unknown}". +type RequiredNotSetError struct { + field string +} + +func (e *RequiredNotSetError) Error() string { + return fmt.Sprintf("proto: required field %q not set", e.field) +} + +var ( + // errRepeatedHasNil is the error returned if Marshal is called with + // a struct with a repeated field containing a nil element. + errRepeatedHasNil = errors.New("proto: repeated field has nil element") + + // ErrNil is the error returned if Marshal is called with nil. + ErrNil = errors.New("proto: Marshal called with nil") +) + +// The fundamental encoders that put bytes on the wire. +// Those that take integer types all accept uint64 and are +// therefore of type valueEncoder. + +const maxVarintBytes = 10 // maximum length of a varint + +// EncodeVarint returns the varint encoding of x. +// This is the format for the +// int32, int64, uint32, uint64, bool, and enum +// protocol buffer types. +// Not used by the package itself, but helpful to clients +// wishing to use the same encoding. +func EncodeVarint(x uint64) []byte { + var buf [maxVarintBytes]byte + var n int + for n = 0; x > 127; n++ { + buf[n] = 0x80 | uint8(x&0x7F) + x >>= 7 + } + buf[n] = uint8(x) + n++ + return buf[0:n] +} + +// EncodeVarint writes a varint-encoded integer to the Buffer. +// This is the format for the +// int32, int64, uint32, uint64, bool, and enum +// protocol buffer types. +func (p *Buffer) EncodeVarint(x uint64) error { + for x >= 1<<7 { + p.buf = append(p.buf, uint8(x&0x7f|0x80)) + x >>= 7 + } + p.buf = append(p.buf, uint8(x)) + return nil +} + +// SizeVarint returns the varint encoding size of an integer. +func SizeVarint(x uint64) int { + return sizeVarint(x) +} + +func sizeVarint(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} + +// EncodeFixed64 writes a 64-bit integer to the Buffer. +// This is the format for the +// fixed64, sfixed64, and double protocol buffer types. +func (p *Buffer) EncodeFixed64(x uint64) error { + p.buf = append(p.buf, + uint8(x), + uint8(x>>8), + uint8(x>>16), + uint8(x>>24), + uint8(x>>32), + uint8(x>>40), + uint8(x>>48), + uint8(x>>56)) + return nil +} + +func sizeFixed64(x uint64) int { + return 8 +} + +// EncodeFixed32 writes a 32-bit integer to the Buffer. +// This is the format for the +// fixed32, sfixed32, and float protocol buffer types. +func (p *Buffer) EncodeFixed32(x uint64) error { + p.buf = append(p.buf, + uint8(x), + uint8(x>>8), + uint8(x>>16), + uint8(x>>24)) + return nil +} + +func sizeFixed32(x uint64) int { + return 4 +} + +// EncodeZigzag64 writes a zigzag-encoded 64-bit integer +// to the Buffer. +// This is the format used for the sint64 protocol buffer type. +func (p *Buffer) EncodeZigzag64(x uint64) error { + // use signed number to get arithmetic right shift. + return p.EncodeVarint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} + +func sizeZigzag64(x uint64) int { + return sizeVarint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} + +// EncodeZigzag32 writes a zigzag-encoded 32-bit integer +// to the Buffer. +// This is the format used for the sint32 protocol buffer type. +func (p *Buffer) EncodeZigzag32(x uint64) error { + // use signed number to get arithmetic right shift. + return p.EncodeVarint(uint64((uint32(x) << 1) ^ uint32((int32(x) >> 31)))) +} + +func sizeZigzag32(x uint64) int { + return sizeVarint(uint64((uint32(x) << 1) ^ uint32((int32(x) >> 31)))) +} + +// EncodeRawBytes writes a count-delimited byte buffer to the Buffer. +// This is the format used for the bytes protocol buffer +// type and for embedded messages. +func (p *Buffer) EncodeRawBytes(b []byte) error { + p.EncodeVarint(uint64(len(b))) + p.buf = append(p.buf, b...) + return nil +} + +func sizeRawBytes(b []byte) int { + return sizeVarint(uint64(len(b))) + + len(b) +} + +// EncodeStringBytes writes an encoded string to the Buffer. +// This is the format used for the proto2 string type. +func (p *Buffer) EncodeStringBytes(s string) error { + p.EncodeVarint(uint64(len(s))) + p.buf = append(p.buf, s...) + return nil +} + +func sizeStringBytes(s string) int { + return sizeVarint(uint64(len(s))) + + len(s) +} + +// Marshaler is the interface representing objects that can marshal themselves. +type Marshaler interface { + Marshal() ([]byte, error) +} + +// Marshal takes the protocol buffer +// and encodes it into the wire format, returning the data. +func Marshal(pb Message) ([]byte, error) { + // Can the object marshal itself? + if m, ok := pb.(Marshaler); ok { + return m.Marshal() + } + p := NewBuffer(nil) + err := p.Marshal(pb) + var state errorState + if err != nil && !state.shouldContinue(err, nil) { + return nil, err + } + if p.buf == nil && err == nil { + // Return a non-nil slice on success. + return []byte{}, nil + } + return p.buf, err +} + +// EncodeMessage writes the protocol buffer to the Buffer, +// prefixed by a varint-encoded length. +func (p *Buffer) EncodeMessage(pb Message) error { + t, base, err := getbase(pb) + if structPointer_IsNil(base) { + return ErrNil + } + if err == nil { + var state errorState + err = p.enc_len_struct(GetProperties(t.Elem()), base, &state) + } + return err +} + +// Marshal takes the protocol buffer +// and encodes it into the wire format, writing the result to the +// Buffer. +func (p *Buffer) Marshal(pb Message) error { + // Can the object marshal itself? + if m, ok := pb.(Marshaler); ok { + data, err := m.Marshal() + if err != nil { + return err + } + p.buf = append(p.buf, data...) + return nil + } + + t, base, err := getbase(pb) + if structPointer_IsNil(base) { + return ErrNil + } + if err == nil { + err = p.enc_struct(GetProperties(t.Elem()), base) + } + + if collectStats { + stats.Encode++ + } + + return err +} + +// Size returns the encoded size of a protocol buffer. +func Size(pb Message) (n int) { + // Can the object marshal itself? If so, Size is slow. + // TODO: add Size to Marshaler, or add a Sizer interface. + if m, ok := pb.(Marshaler); ok { + b, _ := m.Marshal() + return len(b) + } + + t, base, err := getbase(pb) + if structPointer_IsNil(base) { + return 0 + } + if err == nil { + n = size_struct(GetProperties(t.Elem()), base) + } + + if collectStats { + stats.Size++ + } + + return +} + +// Individual type encoders. + +// Encode a bool. +func (o *Buffer) enc_bool(p *Properties, base structPointer) error { + v := *structPointer_Bool(base, p.field) + if v == nil { + return ErrNil + } + x := 0 + if *v { + x = 1 + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func (o *Buffer) enc_proto3_bool(p *Properties, base structPointer) error { + v := *structPointer_BoolVal(base, p.field) + if !v { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, 1) + return nil +} + +func size_bool(p *Properties, base structPointer) int { + v := *structPointer_Bool(base, p.field) + if v == nil { + return 0 + } + return len(p.tagcode) + 1 // each bool takes exactly one byte +} + +func size_proto3_bool(p *Properties, base structPointer) int { + v := *structPointer_BoolVal(base, p.field) + if !v && !p.oneof { + return 0 + } + return len(p.tagcode) + 1 // each bool takes exactly one byte +} + +// Encode an int32. +func (o *Buffer) enc_int32(p *Properties, base structPointer) error { + v := structPointer_Word32(base, p.field) + if word32_IsNil(v) { + return ErrNil + } + x := int32(word32_Get(v)) // permit sign extension to use full 64-bit range + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func (o *Buffer) enc_proto3_int32(p *Properties, base structPointer) error { + v := structPointer_Word32Val(base, p.field) + x := int32(word32Val_Get(v)) // permit sign extension to use full 64-bit range + if x == 0 { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func size_int32(p *Properties, base structPointer) (n int) { + v := structPointer_Word32(base, p.field) + if word32_IsNil(v) { + return 0 + } + x := int32(word32_Get(v)) // permit sign extension to use full 64-bit range + n += len(p.tagcode) + n += p.valSize(uint64(x)) + return +} + +func size_proto3_int32(p *Properties, base structPointer) (n int) { + v := structPointer_Word32Val(base, p.field) + x := int32(word32Val_Get(v)) // permit sign extension to use full 64-bit range + if x == 0 && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += p.valSize(uint64(x)) + return +} + +// Encode a uint32. +// Exactly the same as int32, except for no sign extension. +func (o *Buffer) enc_uint32(p *Properties, base structPointer) error { + v := structPointer_Word32(base, p.field) + if word32_IsNil(v) { + return ErrNil + } + x := word32_Get(v) + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func (o *Buffer) enc_proto3_uint32(p *Properties, base structPointer) error { + v := structPointer_Word32Val(base, p.field) + x := word32Val_Get(v) + if x == 0 { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func size_uint32(p *Properties, base structPointer) (n int) { + v := structPointer_Word32(base, p.field) + if word32_IsNil(v) { + return 0 + } + x := word32_Get(v) + n += len(p.tagcode) + n += p.valSize(uint64(x)) + return +} + +func size_proto3_uint32(p *Properties, base structPointer) (n int) { + v := structPointer_Word32Val(base, p.field) + x := word32Val_Get(v) + if x == 0 && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += p.valSize(uint64(x)) + return +} + +// Encode an int64. +func (o *Buffer) enc_int64(p *Properties, base structPointer) error { + v := structPointer_Word64(base, p.field) + if word64_IsNil(v) { + return ErrNil + } + x := word64_Get(v) + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, x) + return nil +} + +func (o *Buffer) enc_proto3_int64(p *Properties, base structPointer) error { + v := structPointer_Word64Val(base, p.field) + x := word64Val_Get(v) + if x == 0 { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, x) + return nil +} + +func size_int64(p *Properties, base structPointer) (n int) { + v := structPointer_Word64(base, p.field) + if word64_IsNil(v) { + return 0 + } + x := word64_Get(v) + n += len(p.tagcode) + n += p.valSize(x) + return +} + +func size_proto3_int64(p *Properties, base structPointer) (n int) { + v := structPointer_Word64Val(base, p.field) + x := word64Val_Get(v) + if x == 0 && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += p.valSize(x) + return +} + +// Encode a string. +func (o *Buffer) enc_string(p *Properties, base structPointer) error { + v := *structPointer_String(base, p.field) + if v == nil { + return ErrNil + } + x := *v + o.buf = append(o.buf, p.tagcode...) + o.EncodeStringBytes(x) + return nil +} + +func (o *Buffer) enc_proto3_string(p *Properties, base structPointer) error { + v := *structPointer_StringVal(base, p.field) + if v == "" { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeStringBytes(v) + return nil +} + +func size_string(p *Properties, base structPointer) (n int) { + v := *structPointer_String(base, p.field) + if v == nil { + return 0 + } + x := *v + n += len(p.tagcode) + n += sizeStringBytes(x) + return +} + +func size_proto3_string(p *Properties, base structPointer) (n int) { + v := *structPointer_StringVal(base, p.field) + if v == "" && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += sizeStringBytes(v) + return +} + +// All protocol buffer fields are nillable, but be careful. +func isNil(v reflect.Value) bool { + switch v.Kind() { + case reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice: + return v.IsNil() + } + return false +} + +// Encode a message struct. +func (o *Buffer) enc_struct_message(p *Properties, base structPointer) error { + var state errorState + structp := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(structp) { + return ErrNil + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, err := m.Marshal() + if err != nil && !state.shouldContinue(err, nil) { + return err + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(data) + return state.err + } + + o.buf = append(o.buf, p.tagcode...) + return o.enc_len_struct(p.sprop, structp, &state) +} + +func size_struct_message(p *Properties, base structPointer) int { + structp := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(structp) { + return 0 + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, _ := m.Marshal() + n0 := len(p.tagcode) + n1 := sizeRawBytes(data) + return n0 + n1 + } + + n0 := len(p.tagcode) + n1 := size_struct(p.sprop, structp) + n2 := sizeVarint(uint64(n1)) // size of encoded length + return n0 + n1 + n2 +} + +// Encode a group struct. +func (o *Buffer) enc_struct_group(p *Properties, base structPointer) error { + var state errorState + b := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(b) { + return ErrNil + } + + o.EncodeVarint(uint64((p.Tag << 3) | WireStartGroup)) + err := o.enc_struct(p.sprop, b) + if err != nil && !state.shouldContinue(err, nil) { + return err + } + o.EncodeVarint(uint64((p.Tag << 3) | WireEndGroup)) + return state.err +} + +func size_struct_group(p *Properties, base structPointer) (n int) { + b := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(b) { + return 0 + } + + n += sizeVarint(uint64((p.Tag << 3) | WireStartGroup)) + n += size_struct(p.sprop, b) + n += sizeVarint(uint64((p.Tag << 3) | WireEndGroup)) + return +} + +// Encode a slice of bools ([]bool). +func (o *Buffer) enc_slice_bool(p *Properties, base structPointer) error { + s := *structPointer_BoolSlice(base, p.field) + l := len(s) + if l == 0 { + return ErrNil + } + for _, x := range s { + o.buf = append(o.buf, p.tagcode...) + v := uint64(0) + if x { + v = 1 + } + p.valEnc(o, v) + } + return nil +} + +func size_slice_bool(p *Properties, base structPointer) int { + s := *structPointer_BoolSlice(base, p.field) + l := len(s) + if l == 0 { + return 0 + } + return l * (len(p.tagcode) + 1) // each bool takes exactly one byte +} + +// Encode a slice of bools ([]bool) in packed format. +func (o *Buffer) enc_slice_packed_bool(p *Properties, base structPointer) error { + s := *structPointer_BoolSlice(base, p.field) + l := len(s) + if l == 0 { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeVarint(uint64(l)) // each bool takes exactly one byte + for _, x := range s { + v := uint64(0) + if x { + v = 1 + } + p.valEnc(o, v) + } + return nil +} + +func size_slice_packed_bool(p *Properties, base structPointer) (n int) { + s := *structPointer_BoolSlice(base, p.field) + l := len(s) + if l == 0 { + return 0 + } + n += len(p.tagcode) + n += sizeVarint(uint64(l)) + n += l // each bool takes exactly one byte + return +} + +// Encode a slice of bytes ([]byte). +func (o *Buffer) enc_slice_byte(p *Properties, base structPointer) error { + s := *structPointer_Bytes(base, p.field) + if s == nil { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(s) + return nil +} + +func (o *Buffer) enc_proto3_slice_byte(p *Properties, base structPointer) error { + s := *structPointer_Bytes(base, p.field) + if len(s) == 0 { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(s) + return nil +} + +func size_slice_byte(p *Properties, base structPointer) (n int) { + s := *structPointer_Bytes(base, p.field) + if s == nil && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += sizeRawBytes(s) + return +} + +func size_proto3_slice_byte(p *Properties, base structPointer) (n int) { + s := *structPointer_Bytes(base, p.field) + if len(s) == 0 && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += sizeRawBytes(s) + return +} + +// Encode a slice of int32s ([]int32). +func (o *Buffer) enc_slice_int32(p *Properties, base structPointer) error { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + for i := 0; i < l; i++ { + o.buf = append(o.buf, p.tagcode...) + x := int32(s.Index(i)) // permit sign extension to use full 64-bit range + p.valEnc(o, uint64(x)) + } + return nil +} + +func size_slice_int32(p *Properties, base structPointer) (n int) { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + for i := 0; i < l; i++ { + n += len(p.tagcode) + x := int32(s.Index(i)) // permit sign extension to use full 64-bit range + n += p.valSize(uint64(x)) + } + return +} + +// Encode a slice of int32s ([]int32) in packed format. +func (o *Buffer) enc_slice_packed_int32(p *Properties, base structPointer) error { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + // TODO: Reuse a Buffer. + buf := NewBuffer(nil) + for i := 0; i < l; i++ { + x := int32(s.Index(i)) // permit sign extension to use full 64-bit range + p.valEnc(buf, uint64(x)) + } + + o.buf = append(o.buf, p.tagcode...) + o.EncodeVarint(uint64(len(buf.buf))) + o.buf = append(o.buf, buf.buf...) + return nil +} + +func size_slice_packed_int32(p *Properties, base structPointer) (n int) { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + var bufSize int + for i := 0; i < l; i++ { + x := int32(s.Index(i)) // permit sign extension to use full 64-bit range + bufSize += p.valSize(uint64(x)) + } + + n += len(p.tagcode) + n += sizeVarint(uint64(bufSize)) + n += bufSize + return +} + +// Encode a slice of uint32s ([]uint32). +// Exactly the same as int32, except for no sign extension. +func (o *Buffer) enc_slice_uint32(p *Properties, base structPointer) error { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + for i := 0; i < l; i++ { + o.buf = append(o.buf, p.tagcode...) + x := s.Index(i) + p.valEnc(o, uint64(x)) + } + return nil +} + +func size_slice_uint32(p *Properties, base structPointer) (n int) { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + for i := 0; i < l; i++ { + n += len(p.tagcode) + x := s.Index(i) + n += p.valSize(uint64(x)) + } + return +} + +// Encode a slice of uint32s ([]uint32) in packed format. +// Exactly the same as int32, except for no sign extension. +func (o *Buffer) enc_slice_packed_uint32(p *Properties, base structPointer) error { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + // TODO: Reuse a Buffer. + buf := NewBuffer(nil) + for i := 0; i < l; i++ { + p.valEnc(buf, uint64(s.Index(i))) + } + + o.buf = append(o.buf, p.tagcode...) + o.EncodeVarint(uint64(len(buf.buf))) + o.buf = append(o.buf, buf.buf...) + return nil +} + +func size_slice_packed_uint32(p *Properties, base structPointer) (n int) { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + var bufSize int + for i := 0; i < l; i++ { + bufSize += p.valSize(uint64(s.Index(i))) + } + + n += len(p.tagcode) + n += sizeVarint(uint64(bufSize)) + n += bufSize + return +} + +// Encode a slice of int64s ([]int64). +func (o *Buffer) enc_slice_int64(p *Properties, base structPointer) error { + s := structPointer_Word64Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + for i := 0; i < l; i++ { + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, s.Index(i)) + } + return nil +} + +func size_slice_int64(p *Properties, base structPointer) (n int) { + s := structPointer_Word64Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + for i := 0; i < l; i++ { + n += len(p.tagcode) + n += p.valSize(s.Index(i)) + } + return +} + +// Encode a slice of int64s ([]int64) in packed format. +func (o *Buffer) enc_slice_packed_int64(p *Properties, base structPointer) error { + s := structPointer_Word64Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + // TODO: Reuse a Buffer. + buf := NewBuffer(nil) + for i := 0; i < l; i++ { + p.valEnc(buf, s.Index(i)) + } + + o.buf = append(o.buf, p.tagcode...) + o.EncodeVarint(uint64(len(buf.buf))) + o.buf = append(o.buf, buf.buf...) + return nil +} + +func size_slice_packed_int64(p *Properties, base structPointer) (n int) { + s := structPointer_Word64Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + var bufSize int + for i := 0; i < l; i++ { + bufSize += p.valSize(s.Index(i)) + } + + n += len(p.tagcode) + n += sizeVarint(uint64(bufSize)) + n += bufSize + return +} + +// Encode a slice of slice of bytes ([][]byte). +func (o *Buffer) enc_slice_slice_byte(p *Properties, base structPointer) error { + ss := *structPointer_BytesSlice(base, p.field) + l := len(ss) + if l == 0 { + return ErrNil + } + for i := 0; i < l; i++ { + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(ss[i]) + } + return nil +} + +func size_slice_slice_byte(p *Properties, base structPointer) (n int) { + ss := *structPointer_BytesSlice(base, p.field) + l := len(ss) + if l == 0 { + return 0 + } + n += l * len(p.tagcode) + for i := 0; i < l; i++ { + n += sizeRawBytes(ss[i]) + } + return +} + +// Encode a slice of strings ([]string). +func (o *Buffer) enc_slice_string(p *Properties, base structPointer) error { + ss := *structPointer_StringSlice(base, p.field) + l := len(ss) + for i := 0; i < l; i++ { + o.buf = append(o.buf, p.tagcode...) + o.EncodeStringBytes(ss[i]) + } + return nil +} + +func size_slice_string(p *Properties, base structPointer) (n int) { + ss := *structPointer_StringSlice(base, p.field) + l := len(ss) + n += l * len(p.tagcode) + for i := 0; i < l; i++ { + n += sizeStringBytes(ss[i]) + } + return +} + +// Encode a slice of message structs ([]*struct). +func (o *Buffer) enc_slice_struct_message(p *Properties, base structPointer) error { + var state errorState + s := structPointer_StructPointerSlice(base, p.field) + l := s.Len() + + for i := 0; i < l; i++ { + structp := s.Index(i) + if structPointer_IsNil(structp) { + return errRepeatedHasNil + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, err := m.Marshal() + if err != nil && !state.shouldContinue(err, nil) { + return err + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(data) + continue + } + + o.buf = append(o.buf, p.tagcode...) + err := o.enc_len_struct(p.sprop, structp, &state) + if err != nil && !state.shouldContinue(err, nil) { + if err == ErrNil { + return errRepeatedHasNil + } + return err + } + } + return state.err +} + +func size_slice_struct_message(p *Properties, base structPointer) (n int) { + s := structPointer_StructPointerSlice(base, p.field) + l := s.Len() + n += l * len(p.tagcode) + for i := 0; i < l; i++ { + structp := s.Index(i) + if structPointer_IsNil(structp) { + return // return the size up to this point + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, _ := m.Marshal() + n += len(p.tagcode) + n += sizeRawBytes(data) + continue + } + + n0 := size_struct(p.sprop, structp) + n1 := sizeVarint(uint64(n0)) // size of encoded length + n += n0 + n1 + } + return +} + +// Encode a slice of group structs ([]*struct). +func (o *Buffer) enc_slice_struct_group(p *Properties, base structPointer) error { + var state errorState + s := structPointer_StructPointerSlice(base, p.field) + l := s.Len() + + for i := 0; i < l; i++ { + b := s.Index(i) + if structPointer_IsNil(b) { + return errRepeatedHasNil + } + + o.EncodeVarint(uint64((p.Tag << 3) | WireStartGroup)) + + err := o.enc_struct(p.sprop, b) + + if err != nil && !state.shouldContinue(err, nil) { + if err == ErrNil { + return errRepeatedHasNil + } + return err + } + + o.EncodeVarint(uint64((p.Tag << 3) | WireEndGroup)) + } + return state.err +} + +func size_slice_struct_group(p *Properties, base structPointer) (n int) { + s := structPointer_StructPointerSlice(base, p.field) + l := s.Len() + + n += l * sizeVarint(uint64((p.Tag<<3)|WireStartGroup)) + n += l * sizeVarint(uint64((p.Tag<<3)|WireEndGroup)) + for i := 0; i < l; i++ { + b := s.Index(i) + if structPointer_IsNil(b) { + return // return size up to this point + } + + n += size_struct(p.sprop, b) + } + return +} + +// Encode an extension map. +func (o *Buffer) enc_map(p *Properties, base structPointer) error { + v := *structPointer_ExtMap(base, p.field) + if err := encodeExtensionMap(v); err != nil { + return err + } + // Fast-path for common cases: zero or one extensions. + if len(v) <= 1 { + for _, e := range v { + o.buf = append(o.buf, e.enc...) + } + return nil + } + + // Sort keys to provide a deterministic encoding. + keys := make([]int, 0, len(v)) + for k := range v { + keys = append(keys, int(k)) + } + sort.Ints(keys) + + for _, k := range keys { + o.buf = append(o.buf, v[int32(k)].enc...) + } + return nil +} + +func size_map(p *Properties, base structPointer) int { + v := *structPointer_ExtMap(base, p.field) + return sizeExtensionMap(v) +} + +// Encode a map field. +func (o *Buffer) enc_new_map(p *Properties, base structPointer) error { + var state errorState // XXX: or do we need to plumb this through? + + /* + A map defined as + map map_field = N; + is encoded in the same way as + message MapFieldEntry { + key_type key = 1; + value_type value = 2; + } + repeated MapFieldEntry map_field = N; + */ + + v := structPointer_NewAt(base, p.field, p.mtype).Elem() // map[K]V + if v.Len() == 0 { + return nil + } + + keycopy, valcopy, keybase, valbase := mapEncodeScratch(p.mtype) + + enc := func() error { + if err := p.mkeyprop.enc(o, p.mkeyprop, keybase); err != nil { + return err + } + if err := p.mvalprop.enc(o, p.mvalprop, valbase); err != nil { + return err + } + return nil + } + + // Don't sort map keys. It is not required by the spec, and C++ doesn't do it. + for _, key := range v.MapKeys() { + val := v.MapIndex(key) + + // The only illegal map entry values are nil message pointers. + if val.Kind() == reflect.Ptr && val.IsNil() { + return errors.New("proto: map has nil element") + } + + keycopy.Set(key) + valcopy.Set(val) + + o.buf = append(o.buf, p.tagcode...) + if err := o.enc_len_thing(enc, &state); err != nil { + return err + } + } + return nil +} + +func size_new_map(p *Properties, base structPointer) int { + v := structPointer_NewAt(base, p.field, p.mtype).Elem() // map[K]V + + keycopy, valcopy, keybase, valbase := mapEncodeScratch(p.mtype) + + n := 0 + for _, key := range v.MapKeys() { + val := v.MapIndex(key) + keycopy.Set(key) + valcopy.Set(val) + + // Tag codes for key and val are the responsibility of the sub-sizer. + keysize := p.mkeyprop.size(p.mkeyprop, keybase) + valsize := p.mvalprop.size(p.mvalprop, valbase) + entry := keysize + valsize + // Add on tag code and length of map entry itself. + n += len(p.tagcode) + sizeVarint(uint64(entry)) + entry + } + return n +} + +// mapEncodeScratch returns a new reflect.Value matching the map's value type, +// and a structPointer suitable for passing to an encoder or sizer. +func mapEncodeScratch(mapType reflect.Type) (keycopy, valcopy reflect.Value, keybase, valbase structPointer) { + // Prepare addressable doubly-indirect placeholders for the key and value types. + // This is needed because the element-type encoders expect **T, but the map iteration produces T. + + keycopy = reflect.New(mapType.Key()).Elem() // addressable K + keyptr := reflect.New(reflect.PtrTo(keycopy.Type())).Elem() // addressable *K + keyptr.Set(keycopy.Addr()) // + keybase = toStructPointer(keyptr.Addr()) // **K + + // Value types are more varied and require special handling. + switch mapType.Elem().Kind() { + case reflect.Slice: + // []byte + var dummy []byte + valcopy = reflect.ValueOf(&dummy).Elem() // addressable []byte + valbase = toStructPointer(valcopy.Addr()) + case reflect.Ptr: + // message; the generated field type is map[K]*Msg (so V is *Msg), + // so we only need one level of indirection. + valcopy = reflect.New(mapType.Elem()).Elem() // addressable V + valbase = toStructPointer(valcopy.Addr()) + default: + // everything else + valcopy = reflect.New(mapType.Elem()).Elem() // addressable V + valptr := reflect.New(reflect.PtrTo(valcopy.Type())).Elem() // addressable *V + valptr.Set(valcopy.Addr()) // + valbase = toStructPointer(valptr.Addr()) // **V + } + return +} + +// Encode a struct. +func (o *Buffer) enc_struct(prop *StructProperties, base structPointer) error { + var state errorState + // Encode fields in tag order so that decoders may use optimizations + // that depend on the ordering. + // https://developers.google.com/protocol-buffers/docs/encoding#order + for _, i := range prop.order { + p := prop.Prop[i] + if p.enc != nil { + err := p.enc(o, p, base) + if err != nil { + if err == ErrNil { + if p.Required && state.err == nil { + state.err = &RequiredNotSetError{p.Name} + } + } else if err == errRepeatedHasNil { + // Give more context to nil values in repeated fields. + return errors.New("repeated field " + p.OrigName + " has nil element") + } else if !state.shouldContinue(err, p) { + return err + } + } + } + } + + // Do oneof fields. + if prop.oneofMarshaler != nil { + m := structPointer_Interface(base, prop.stype).(Message) + if err := prop.oneofMarshaler(m, o); err != nil { + return err + } + } + + // Add unrecognized fields at the end. + if prop.unrecField.IsValid() { + v := *structPointer_Bytes(base, prop.unrecField) + if len(v) > 0 { + o.buf = append(o.buf, v...) + } + } + + return state.err +} + +func size_struct(prop *StructProperties, base structPointer) (n int) { + for _, i := range prop.order { + p := prop.Prop[i] + if p.size != nil { + n += p.size(p, base) + } + } + + // Add unrecognized fields at the end. + if prop.unrecField.IsValid() { + v := *structPointer_Bytes(base, prop.unrecField) + n += len(v) + } + + // Factor in any oneof fields. + if prop.oneofSizer != nil { + m := structPointer_Interface(base, prop.stype).(Message) + n += prop.oneofSizer(m) + } + + return +} + +var zeroes [20]byte // longer than any conceivable sizeVarint + +// Encode a struct, preceded by its encoded length (as a varint). +func (o *Buffer) enc_len_struct(prop *StructProperties, base structPointer, state *errorState) error { + return o.enc_len_thing(func() error { return o.enc_struct(prop, base) }, state) +} + +// Encode something, preceded by its encoded length (as a varint). +func (o *Buffer) enc_len_thing(enc func() error, state *errorState) error { + iLen := len(o.buf) + o.buf = append(o.buf, 0, 0, 0, 0) // reserve four bytes for length + iMsg := len(o.buf) + err := enc() + if err != nil && !state.shouldContinue(err, nil) { + return err + } + lMsg := len(o.buf) - iMsg + lLen := sizeVarint(uint64(lMsg)) + switch x := lLen - (iMsg - iLen); { + case x > 0: // actual length is x bytes larger than the space we reserved + // Move msg x bytes right. + o.buf = append(o.buf, zeroes[:x]...) + copy(o.buf[iMsg+x:], o.buf[iMsg:iMsg+lMsg]) + case x < 0: // actual length is x bytes smaller than the space we reserved + // Move msg x bytes left. + copy(o.buf[iMsg+x:], o.buf[iMsg:iMsg+lMsg]) + o.buf = o.buf[:len(o.buf)+x] // x is negative + } + // Encode the length in the reserved space. + o.buf = o.buf[:iLen] + o.EncodeVarint(uint64(lMsg)) + o.buf = o.buf[:len(o.buf)+lMsg] + return state.err +} + +// errorState maintains the first error that occurs and updates that error +// with additional context. +type errorState struct { + err error +} + +// shouldContinue reports whether encoding should continue upon encountering the +// given error. If the error is RequiredNotSetError, shouldContinue returns true +// and, if this is the first appearance of that error, remembers it for future +// reporting. +// +// If prop is not nil, it may update any error with additional context about the +// field with the error. +func (s *errorState) shouldContinue(err error, prop *Properties) bool { + // Ignore unset required fields. + reqNotSet, ok := err.(*RequiredNotSetError) + if !ok { + return false + } + if s.err == nil { + if prop != nil { + err = &RequiredNotSetError{prop.Name + "." + reqNotSet.field} + } + s.err = err + } + return true +} diff --git a/vendor/github.com/golang/protobuf/proto/equal.go b/vendor/github.com/golang/protobuf/proto/equal.go new file mode 100644 index 0000000000..f5db1def3c --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/equal.go @@ -0,0 +1,276 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2011 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +// Protocol buffer comparison. + +package proto + +import ( + "bytes" + "log" + "reflect" + "strings" +) + +/* +Equal returns true iff protocol buffers a and b are equal. +The arguments must both be pointers to protocol buffer structs. + +Equality is defined in this way: + - Two messages are equal iff they are the same type, + corresponding fields are equal, unknown field sets + are equal, and extensions sets are equal. + - Two set scalar fields are equal iff their values are equal. + If the fields are of a floating-point type, remember that + NaN != x for all x, including NaN. If the message is defined + in a proto3 .proto file, fields are not "set"; specifically, + zero length proto3 "bytes" fields are equal (nil == {}). + - Two repeated fields are equal iff their lengths are the same, + and their corresponding elements are equal (a "bytes" field, + although represented by []byte, is not a repeated field) + - Two unset fields are equal. + - Two unknown field sets are equal if their current + encoded state is equal. + - Two extension sets are equal iff they have corresponding + elements that are pairwise equal. + - Every other combination of things are not equal. + +The return value is undefined if a and b are not protocol buffers. +*/ +func Equal(a, b Message) bool { + if a == nil || b == nil { + return a == b + } + v1, v2 := reflect.ValueOf(a), reflect.ValueOf(b) + if v1.Type() != v2.Type() { + return false + } + if v1.Kind() == reflect.Ptr { + if v1.IsNil() { + return v2.IsNil() + } + if v2.IsNil() { + return false + } + v1, v2 = v1.Elem(), v2.Elem() + } + if v1.Kind() != reflect.Struct { + return false + } + return equalStruct(v1, v2) +} + +// v1 and v2 are known to have the same type. +func equalStruct(v1, v2 reflect.Value) bool { + sprop := GetProperties(v1.Type()) + for i := 0; i < v1.NumField(); i++ { + f := v1.Type().Field(i) + if strings.HasPrefix(f.Name, "XXX_") { + continue + } + f1, f2 := v1.Field(i), v2.Field(i) + if f.Type.Kind() == reflect.Ptr { + if n1, n2 := f1.IsNil(), f2.IsNil(); n1 && n2 { + // both unset + continue + } else if n1 != n2 { + // set/unset mismatch + return false + } + b1, ok := f1.Interface().(raw) + if ok { + b2 := f2.Interface().(raw) + // RawMessage + if !bytes.Equal(b1.Bytes(), b2.Bytes()) { + return false + } + continue + } + f1, f2 = f1.Elem(), f2.Elem() + } + if !equalAny(f1, f2, sprop.Prop[i]) { + return false + } + } + + if em1 := v1.FieldByName("XXX_extensions"); em1.IsValid() { + em2 := v2.FieldByName("XXX_extensions") + if !equalExtensions(v1.Type(), em1.Interface().(map[int32]Extension), em2.Interface().(map[int32]Extension)) { + return false + } + } + + uf := v1.FieldByName("XXX_unrecognized") + if !uf.IsValid() { + return true + } + + u1 := uf.Bytes() + u2 := v2.FieldByName("XXX_unrecognized").Bytes() + if !bytes.Equal(u1, u2) { + return false + } + + return true +} + +// v1 and v2 are known to have the same type. +// prop may be nil. +func equalAny(v1, v2 reflect.Value, prop *Properties) bool { + if v1.Type() == protoMessageType { + m1, _ := v1.Interface().(Message) + m2, _ := v2.Interface().(Message) + return Equal(m1, m2) + } + switch v1.Kind() { + case reflect.Bool: + return v1.Bool() == v2.Bool() + case reflect.Float32, reflect.Float64: + return v1.Float() == v2.Float() + case reflect.Int32, reflect.Int64: + return v1.Int() == v2.Int() + case reflect.Interface: + // Probably a oneof field; compare the inner values. + n1, n2 := v1.IsNil(), v2.IsNil() + if n1 || n2 { + return n1 == n2 + } + e1, e2 := v1.Elem(), v2.Elem() + if e1.Type() != e2.Type() { + return false + } + return equalAny(e1, e2, nil) + case reflect.Map: + if v1.Len() != v2.Len() { + return false + } + for _, key := range v1.MapKeys() { + val2 := v2.MapIndex(key) + if !val2.IsValid() { + // This key was not found in the second map. + return false + } + if !equalAny(v1.MapIndex(key), val2, nil) { + return false + } + } + return true + case reflect.Ptr: + return equalAny(v1.Elem(), v2.Elem(), prop) + case reflect.Slice: + if v1.Type().Elem().Kind() == reflect.Uint8 { + // short circuit: []byte + + // Edge case: if this is in a proto3 message, a zero length + // bytes field is considered the zero value. + if prop != nil && prop.proto3 && v1.Len() == 0 && v2.Len() == 0 { + return true + } + if v1.IsNil() != v2.IsNil() { + return false + } + return bytes.Equal(v1.Interface().([]byte), v2.Interface().([]byte)) + } + + if v1.Len() != v2.Len() { + return false + } + for i := 0; i < v1.Len(); i++ { + if !equalAny(v1.Index(i), v2.Index(i), prop) { + return false + } + } + return true + case reflect.String: + return v1.Interface().(string) == v2.Interface().(string) + case reflect.Struct: + return equalStruct(v1, v2) + case reflect.Uint32, reflect.Uint64: + return v1.Uint() == v2.Uint() + } + + // unknown type, so not a protocol buffer + log.Printf("proto: don't know how to compare %v", v1) + return false +} + +// base is the struct type that the extensions are based on. +// em1 and em2 are extension maps. +func equalExtensions(base reflect.Type, em1, em2 map[int32]Extension) bool { + if len(em1) != len(em2) { + return false + } + + for extNum, e1 := range em1 { + e2, ok := em2[extNum] + if !ok { + return false + } + + m1, m2 := e1.value, e2.value + + if m1 != nil && m2 != nil { + // Both are unencoded. + if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2), nil) { + return false + } + continue + } + + // At least one is encoded. To do a semantically correct comparison + // we need to unmarshal them first. + var desc *ExtensionDesc + if m := extensionMaps[base]; m != nil { + desc = m[extNum] + } + if desc == nil { + log.Printf("proto: don't know how to compare extension %d of %v", extNum, base) + continue + } + var err error + if m1 == nil { + m1, err = decodeExtension(e1.enc, desc) + } + if m2 == nil && err == nil { + m2, err = decodeExtension(e2.enc, desc) + } + if err != nil { + // The encoded form is invalid. + log.Printf("proto: badly encoded extension %d of %v: %v", extNum, base, err) + return false + } + if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2), nil) { + return false + } + } + + return true +} diff --git a/vendor/github.com/golang/protobuf/proto/extensions.go b/vendor/github.com/golang/protobuf/proto/extensions.go new file mode 100644 index 0000000000..054f4f1df7 --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/extensions.go @@ -0,0 +1,399 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +package proto + +/* + * Types and routines for supporting protocol buffer extensions. + */ + +import ( + "errors" + "fmt" + "reflect" + "strconv" + "sync" +) + +// ErrMissingExtension is the error returned by GetExtension if the named extension is not in the message. +var ErrMissingExtension = errors.New("proto: missing extension") + +// ExtensionRange represents a range of message extensions for a protocol buffer. +// Used in code generated by the protocol compiler. +type ExtensionRange struct { + Start, End int32 // both inclusive +} + +// extendableProto is an interface implemented by any protocol buffer that may be extended. +type extendableProto interface { + Message + ExtensionRangeArray() []ExtensionRange + ExtensionMap() map[int32]Extension +} + +var extendableProtoType = reflect.TypeOf((*extendableProto)(nil)).Elem() + +// ExtensionDesc represents an extension specification. +// Used in generated code from the protocol compiler. +type ExtensionDesc struct { + ExtendedType Message // nil pointer to the type that is being extended + ExtensionType interface{} // nil pointer to the extension type + Field int32 // field number + Name string // fully-qualified name of extension, for text formatting + Tag string // protobuf tag style +} + +func (ed *ExtensionDesc) repeated() bool { + t := reflect.TypeOf(ed.ExtensionType) + return t.Kind() == reflect.Slice && t.Elem().Kind() != reflect.Uint8 +} + +// Extension represents an extension in a message. +type Extension struct { + // When an extension is stored in a message using SetExtension + // only desc and value are set. When the message is marshaled + // enc will be set to the encoded form of the message. + // + // When a message is unmarshaled and contains extensions, each + // extension will have only enc set. When such an extension is + // accessed using GetExtension (or GetExtensions) desc and value + // will be set. + desc *ExtensionDesc + value interface{} + enc []byte +} + +// SetRawExtension is for testing only. +func SetRawExtension(base extendableProto, id int32, b []byte) { + base.ExtensionMap()[id] = Extension{enc: b} +} + +// isExtensionField returns true iff the given field number is in an extension range. +func isExtensionField(pb extendableProto, field int32) bool { + for _, er := range pb.ExtensionRangeArray() { + if er.Start <= field && field <= er.End { + return true + } + } + return false +} + +// checkExtensionTypes checks that the given extension is valid for pb. +func checkExtensionTypes(pb extendableProto, extension *ExtensionDesc) error { + // Check the extended type. + if a, b := reflect.TypeOf(pb), reflect.TypeOf(extension.ExtendedType); a != b { + return errors.New("proto: bad extended type; " + b.String() + " does not extend " + a.String()) + } + // Check the range. + if !isExtensionField(pb, extension.Field) { + return errors.New("proto: bad extension number; not in declared ranges") + } + return nil +} + +// extPropKey is sufficient to uniquely identify an extension. +type extPropKey struct { + base reflect.Type + field int32 +} + +var extProp = struct { + sync.RWMutex + m map[extPropKey]*Properties +}{ + m: make(map[extPropKey]*Properties), +} + +func extensionProperties(ed *ExtensionDesc) *Properties { + key := extPropKey{base: reflect.TypeOf(ed.ExtendedType), field: ed.Field} + + extProp.RLock() + if prop, ok := extProp.m[key]; ok { + extProp.RUnlock() + return prop + } + extProp.RUnlock() + + extProp.Lock() + defer extProp.Unlock() + // Check again. + if prop, ok := extProp.m[key]; ok { + return prop + } + + prop := new(Properties) + prop.Init(reflect.TypeOf(ed.ExtensionType), "unknown_name", ed.Tag, nil) + extProp.m[key] = prop + return prop +} + +// encodeExtensionMap encodes any unmarshaled (unencoded) extensions in m. +func encodeExtensionMap(m map[int32]Extension) error { + for k, e := range m { + if e.value == nil || e.desc == nil { + // Extension is only in its encoded form. + continue + } + + // We don't skip extensions that have an encoded form set, + // because the extension value may have been mutated after + // the last time this function was called. + + et := reflect.TypeOf(e.desc.ExtensionType) + props := extensionProperties(e.desc) + + p := NewBuffer(nil) + // If e.value has type T, the encoder expects a *struct{ X T }. + // Pass a *T with a zero field and hope it all works out. + x := reflect.New(et) + x.Elem().Set(reflect.ValueOf(e.value)) + if err := props.enc(p, props, toStructPointer(x)); err != nil { + return err + } + e.enc = p.buf + m[k] = e + } + return nil +} + +func sizeExtensionMap(m map[int32]Extension) (n int) { + for _, e := range m { + if e.value == nil || e.desc == nil { + // Extension is only in its encoded form. + n += len(e.enc) + continue + } + + // We don't skip extensions that have an encoded form set, + // because the extension value may have been mutated after + // the last time this function was called. + + et := reflect.TypeOf(e.desc.ExtensionType) + props := extensionProperties(e.desc) + + // If e.value has type T, the encoder expects a *struct{ X T }. + // Pass a *T with a zero field and hope it all works out. + x := reflect.New(et) + x.Elem().Set(reflect.ValueOf(e.value)) + n += props.size(props, toStructPointer(x)) + } + return +} + +// HasExtension returns whether the given extension is present in pb. +func HasExtension(pb extendableProto, extension *ExtensionDesc) bool { + // TODO: Check types, field numbers, etc.? + _, ok := pb.ExtensionMap()[extension.Field] + return ok +} + +// ClearExtension removes the given extension from pb. +func ClearExtension(pb extendableProto, extension *ExtensionDesc) { + // TODO: Check types, field numbers, etc.? + delete(pb.ExtensionMap(), extension.Field) +} + +// GetExtension parses and returns the given extension of pb. +// If the extension is not present and has no default value it returns ErrMissingExtension. +func GetExtension(pb extendableProto, extension *ExtensionDesc) (interface{}, error) { + if err := checkExtensionTypes(pb, extension); err != nil { + return nil, err + } + + emap := pb.ExtensionMap() + e, ok := emap[extension.Field] + if !ok { + // defaultExtensionValue returns the default value or + // ErrMissingExtension if there is no default. + return defaultExtensionValue(extension) + } + + if e.value != nil { + // Already decoded. Check the descriptor, though. + if e.desc != extension { + // This shouldn't happen. If it does, it means that + // GetExtension was called twice with two different + // descriptors with the same field number. + return nil, errors.New("proto: descriptor conflict") + } + return e.value, nil + } + + v, err := decodeExtension(e.enc, extension) + if err != nil { + return nil, err + } + + // Remember the decoded version and drop the encoded version. + // That way it is safe to mutate what we return. + e.value = v + e.desc = extension + e.enc = nil + emap[extension.Field] = e + return e.value, nil +} + +// defaultExtensionValue returns the default value for extension. +// If no default for an extension is defined ErrMissingExtension is returned. +func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) { + t := reflect.TypeOf(extension.ExtensionType) + props := extensionProperties(extension) + + sf, _, err := fieldDefault(t, props) + if err != nil { + return nil, err + } + + if sf == nil || sf.value == nil { + // There is no default value. + return nil, ErrMissingExtension + } + + if t.Kind() != reflect.Ptr { + // We do not need to return a Ptr, we can directly return sf.value. + return sf.value, nil + } + + // We need to return an interface{} that is a pointer to sf.value. + value := reflect.New(t).Elem() + value.Set(reflect.New(value.Type().Elem())) + if sf.kind == reflect.Int32 { + // We may have an int32 or an enum, but the underlying data is int32. + // Since we can't set an int32 into a non int32 reflect.value directly + // set it as a int32. + value.Elem().SetInt(int64(sf.value.(int32))) + } else { + value.Elem().Set(reflect.ValueOf(sf.value)) + } + return value.Interface(), nil +} + +// decodeExtension decodes an extension encoded in b. +func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) { + o := NewBuffer(b) + + t := reflect.TypeOf(extension.ExtensionType) + + props := extensionProperties(extension) + + // t is a pointer to a struct, pointer to basic type or a slice. + // Allocate a "field" to store the pointer/slice itself; the + // pointer/slice will be stored here. We pass + // the address of this field to props.dec. + // This passes a zero field and a *t and lets props.dec + // interpret it as a *struct{ x t }. + value := reflect.New(t).Elem() + + for { + // Discard wire type and field number varint. It isn't needed. + if _, err := o.DecodeVarint(); err != nil { + return nil, err + } + + if err := props.dec(o, props, toStructPointer(value.Addr())); err != nil { + return nil, err + } + + if o.index >= len(o.buf) { + break + } + } + return value.Interface(), nil +} + +// GetExtensions returns a slice of the extensions present in pb that are also listed in es. +// The returned slice has the same length as es; missing extensions will appear as nil elements. +func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, err error) { + epb, ok := pb.(extendableProto) + if !ok { + err = errors.New("proto: not an extendable proto") + return + } + extensions = make([]interface{}, len(es)) + for i, e := range es { + extensions[i], err = GetExtension(epb, e) + if err == ErrMissingExtension { + err = nil + } + if err != nil { + return + } + } + return +} + +// SetExtension sets the specified extension of pb to the specified value. +func SetExtension(pb extendableProto, extension *ExtensionDesc, value interface{}) error { + if err := checkExtensionTypes(pb, extension); err != nil { + return err + } + typ := reflect.TypeOf(extension.ExtensionType) + if typ != reflect.TypeOf(value) { + return errors.New("proto: bad extension value type") + } + // nil extension values need to be caught early, because the + // encoder can't distinguish an ErrNil due to a nil extension + // from an ErrNil due to a missing field. Extensions are + // always optional, so the encoder would just swallow the error + // and drop all the extensions from the encoded message. + if reflect.ValueOf(value).IsNil() { + return fmt.Errorf("proto: SetExtension called with nil value of type %T", value) + } + + pb.ExtensionMap()[extension.Field] = Extension{desc: extension, value: value} + return nil +} + +// A global registry of extensions. +// The generated code will register the generated descriptors by calling RegisterExtension. + +var extensionMaps = make(map[reflect.Type]map[int32]*ExtensionDesc) + +// RegisterExtension is called from the generated code. +func RegisterExtension(desc *ExtensionDesc) { + st := reflect.TypeOf(desc.ExtendedType).Elem() + m := extensionMaps[st] + if m == nil { + m = make(map[int32]*ExtensionDesc) + extensionMaps[st] = m + } + if _, ok := m[desc.Field]; ok { + panic("proto: duplicate extension registered: " + st.String() + " " + strconv.Itoa(int(desc.Field))) + } + m[desc.Field] = desc +} + +// RegisteredExtensions returns a map of the registered extensions of a +// protocol buffer struct, indexed by the extension number. +// The argument pb should be a nil pointer to the struct type. +func RegisteredExtensions(pb Message) map[int32]*ExtensionDesc { + return extensionMaps[reflect.TypeOf(pb).Elem()] +} diff --git a/vendor/github.com/golang/protobuf/proto/lib.go b/vendor/github.com/golang/protobuf/proto/lib.go new file mode 100644 index 0000000000..42a58c6fd4 --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/lib.go @@ -0,0 +1,893 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +/* +Package proto converts data structures to and from the wire format of +protocol buffers. It works in concert with the Go source code generated +for .proto files by the protocol compiler. + +A summary of the properties of the protocol buffer interface +for a protocol buffer variable v: + + - Names are turned from camel_case to CamelCase for export. + - There are no methods on v to set fields; just treat + them as structure fields. + - There are getters that return a field's value if set, + and return the field's default value if unset. + The getters work even if the receiver is a nil message. + - The zero value for a struct is its correct initialization state. + All desired fields must be set before marshaling. + - A Reset() method will restore a protobuf struct to its zero state. + - Non-repeated fields are pointers to the values; nil means unset. + That is, optional or required field int32 f becomes F *int32. + - Repeated fields are slices. + - Helper functions are available to aid the setting of fields. + msg.Foo = proto.String("hello") // set field + - Constants are defined to hold the default values of all fields that + have them. They have the form Default_StructName_FieldName. + Because the getter methods handle defaulted values, + direct use of these constants should be rare. + - Enums are given type names and maps from names to values. + Enum values are prefixed by the enclosing message's name, or by the + enum's type name if it is a top-level enum. Enum types have a String + method, and a Enum method to assist in message construction. + - Nested messages, groups and enums have type names prefixed with the name of + the surrounding message type. + - Extensions are given descriptor names that start with E_, + followed by an underscore-delimited list of the nested messages + that contain it (if any) followed by the CamelCased name of the + extension field itself. HasExtension, ClearExtension, GetExtension + and SetExtension are functions for manipulating extensions. + - Oneof field sets are given a single field in their message, + with distinguished wrapper types for each possible field value. + - Marshal and Unmarshal are functions to encode and decode the wire format. + +When the .proto file specifies `syntax="proto3"`, there are some differences: + + - Non-repeated fields of non-message type are values instead of pointers. + - Getters are only generated for message and oneof fields. + - Enum types do not get an Enum method. + +The simplest way to describe this is to see an example. +Given file test.proto, containing + + package example; + + enum FOO { X = 17; } + + message Test { + required string label = 1; + optional int32 type = 2 [default=77]; + repeated int64 reps = 3; + optional group OptionalGroup = 4 { + required string RequiredField = 5; + } + oneof union { + int32 number = 6; + string name = 7; + } + } + +The resulting file, test.pb.go, is: + + package example + + import proto "github.com/golang/protobuf/proto" + import math "math" + + type FOO int32 + const ( + FOO_X FOO = 17 + ) + var FOO_name = map[int32]string{ + 17: "X", + } + var FOO_value = map[string]int32{ + "X": 17, + } + + func (x FOO) Enum() *FOO { + p := new(FOO) + *p = x + return p + } + func (x FOO) String() string { + return proto.EnumName(FOO_name, int32(x)) + } + func (x *FOO) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(FOO_value, data) + if err != nil { + return err + } + *x = FOO(value) + return nil + } + + type Test struct { + Label *string `protobuf:"bytes,1,req,name=label" json:"label,omitempty"` + Type *int32 `protobuf:"varint,2,opt,name=type,def=77" json:"type,omitempty"` + Reps []int64 `protobuf:"varint,3,rep,name=reps" json:"reps,omitempty"` + Optionalgroup *Test_OptionalGroup `protobuf:"group,4,opt,name=OptionalGroup" json:"optionalgroup,omitempty"` + // Types that are valid to be assigned to Union: + // *Test_Number + // *Test_Name + Union isTest_Union `protobuf_oneof:"union"` + XXX_unrecognized []byte `json:"-"` + } + func (m *Test) Reset() { *m = Test{} } + func (m *Test) String() string { return proto.CompactTextString(m) } + func (*Test) ProtoMessage() {} + + type isTest_Union interface { + isTest_Union() + } + + type Test_Number struct { + Number int32 `protobuf:"varint,6,opt,name=number"` + } + type Test_Name struct { + Name string `protobuf:"bytes,7,opt,name=name"` + } + + func (*Test_Number) isTest_Union() {} + func (*Test_Name) isTest_Union() {} + + func (m *Test) GetUnion() isTest_Union { + if m != nil { + return m.Union + } + return nil + } + const Default_Test_Type int32 = 77 + + func (m *Test) GetLabel() string { + if m != nil && m.Label != nil { + return *m.Label + } + return "" + } + + func (m *Test) GetType() int32 { + if m != nil && m.Type != nil { + return *m.Type + } + return Default_Test_Type + } + + func (m *Test) GetOptionalgroup() *Test_OptionalGroup { + if m != nil { + return m.Optionalgroup + } + return nil + } + + type Test_OptionalGroup struct { + RequiredField *string `protobuf:"bytes,5,req" json:"RequiredField,omitempty"` + } + func (m *Test_OptionalGroup) Reset() { *m = Test_OptionalGroup{} } + func (m *Test_OptionalGroup) String() string { return proto.CompactTextString(m) } + + func (m *Test_OptionalGroup) GetRequiredField() string { + if m != nil && m.RequiredField != nil { + return *m.RequiredField + } + return "" + } + + func (m *Test) GetNumber() int32 { + if x, ok := m.GetUnion().(*Test_Number); ok { + return x.Number + } + return 0 + } + + func (m *Test) GetName() string { + if x, ok := m.GetUnion().(*Test_Name); ok { + return x.Name + } + return "" + } + + func init() { + proto.RegisterEnum("example.FOO", FOO_name, FOO_value) + } + +To create and play with a Test object: + + package main + + import ( + "log" + + "github.com/golang/protobuf/proto" + pb "./example.pb" + ) + + func main() { + test := &pb.Test{ + Label: proto.String("hello"), + Type: proto.Int32(17), + Optionalgroup: &pb.Test_OptionalGroup{ + RequiredField: proto.String("good bye"), + }, + Union: &pb.Test_Name{"fred"}, + } + data, err := proto.Marshal(test) + if err != nil { + log.Fatal("marshaling error: ", err) + } + newTest := &pb.Test{} + err = proto.Unmarshal(data, newTest) + if err != nil { + log.Fatal("unmarshaling error: ", err) + } + // Now test and newTest contain the same data. + if test.GetLabel() != newTest.GetLabel() { + log.Fatalf("data mismatch %q != %q", test.GetLabel(), newTest.GetLabel()) + } + // Use a type switch to determine which oneof was set. + switch u := test.Union.(type) { + case *pb.Test_Number: // u.Number contains the number. + case *pb.Test_Name: // u.Name contains the string. + } + // etc. + } +*/ +package proto + +import ( + "encoding/json" + "fmt" + "log" + "reflect" + "sort" + "strconv" + "sync" +) + +// Message is implemented by generated protocol buffer messages. +type Message interface { + Reset() + String() string + ProtoMessage() +} + +// Stats records allocation details about the protocol buffer encoders +// and decoders. Useful for tuning the library itself. +type Stats struct { + Emalloc uint64 // mallocs in encode + Dmalloc uint64 // mallocs in decode + Encode uint64 // number of encodes + Decode uint64 // number of decodes + Chit uint64 // number of cache hits + Cmiss uint64 // number of cache misses + Size uint64 // number of sizes +} + +// Set to true to enable stats collection. +const collectStats = false + +var stats Stats + +// GetStats returns a copy of the global Stats structure. +func GetStats() Stats { return stats } + +// A Buffer is a buffer manager for marshaling and unmarshaling +// protocol buffers. It may be reused between invocations to +// reduce memory usage. It is not necessary to use a Buffer; +// the global functions Marshal and Unmarshal create a +// temporary Buffer and are fine for most applications. +type Buffer struct { + buf []byte // encode/decode byte stream + index int // write point + + // pools of basic types to amortize allocation. + bools []bool + uint32s []uint32 + uint64s []uint64 + + // extra pools, only used with pointer_reflect.go + int32s []int32 + int64s []int64 + float32s []float32 + float64s []float64 +} + +// NewBuffer allocates a new Buffer and initializes its internal data to +// the contents of the argument slice. +func NewBuffer(e []byte) *Buffer { + return &Buffer{buf: e} +} + +// Reset resets the Buffer, ready for marshaling a new protocol buffer. +func (p *Buffer) Reset() { + p.buf = p.buf[0:0] // for reading/writing + p.index = 0 // for reading +} + +// SetBuf replaces the internal buffer with the slice, +// ready for unmarshaling the contents of the slice. +func (p *Buffer) SetBuf(s []byte) { + p.buf = s + p.index = 0 +} + +// Bytes returns the contents of the Buffer. +func (p *Buffer) Bytes() []byte { return p.buf } + +/* + * Helper routines for simplifying the creation of optional fields of basic type. + */ + +// Bool is a helper routine that allocates a new bool value +// to store v and returns a pointer to it. +func Bool(v bool) *bool { + return &v +} + +// Int32 is a helper routine that allocates a new int32 value +// to store v and returns a pointer to it. +func Int32(v int32) *int32 { + return &v +} + +// Int is a helper routine that allocates a new int32 value +// to store v and returns a pointer to it, but unlike Int32 +// its argument value is an int. +func Int(v int) *int32 { + p := new(int32) + *p = int32(v) + return p +} + +// Int64 is a helper routine that allocates a new int64 value +// to store v and returns a pointer to it. +func Int64(v int64) *int64 { + return &v +} + +// Float32 is a helper routine that allocates a new float32 value +// to store v and returns a pointer to it. +func Float32(v float32) *float32 { + return &v +} + +// Float64 is a helper routine that allocates a new float64 value +// to store v and returns a pointer to it. +func Float64(v float64) *float64 { + return &v +} + +// Uint32 is a helper routine that allocates a new uint32 value +// to store v and returns a pointer to it. +func Uint32(v uint32) *uint32 { + return &v +} + +// Uint64 is a helper routine that allocates a new uint64 value +// to store v and returns a pointer to it. +func Uint64(v uint64) *uint64 { + return &v +} + +// String is a helper routine that allocates a new string value +// to store v and returns a pointer to it. +func String(v string) *string { + return &v +} + +// EnumName is a helper function to simplify printing protocol buffer enums +// by name. Given an enum map and a value, it returns a useful string. +func EnumName(m map[int32]string, v int32) string { + s, ok := m[v] + if ok { + return s + } + return strconv.Itoa(int(v)) +} + +// UnmarshalJSONEnum is a helper function to simplify recovering enum int values +// from their JSON-encoded representation. Given a map from the enum's symbolic +// names to its int values, and a byte buffer containing the JSON-encoded +// value, it returns an int32 that can be cast to the enum type by the caller. +// +// The function can deal with both JSON representations, numeric and symbolic. +func UnmarshalJSONEnum(m map[string]int32, data []byte, enumName string) (int32, error) { + if data[0] == '"' { + // New style: enums are strings. + var repr string + if err := json.Unmarshal(data, &repr); err != nil { + return -1, err + } + val, ok := m[repr] + if !ok { + return 0, fmt.Errorf("unrecognized enum %s value %q", enumName, repr) + } + return val, nil + } + // Old style: enums are ints. + var val int32 + if err := json.Unmarshal(data, &val); err != nil { + return 0, fmt.Errorf("cannot unmarshal %#q into enum %s", data, enumName) + } + return val, nil +} + +// DebugPrint dumps the encoded data in b in a debugging format with a header +// including the string s. Used in testing but made available for general debugging. +func (p *Buffer) DebugPrint(s string, b []byte) { + var u uint64 + + obuf := p.buf + index := p.index + p.buf = b + p.index = 0 + depth := 0 + + fmt.Printf("\n--- %s ---\n", s) + +out: + for { + for i := 0; i < depth; i++ { + fmt.Print(" ") + } + + index := p.index + if index == len(p.buf) { + break + } + + op, err := p.DecodeVarint() + if err != nil { + fmt.Printf("%3d: fetching op err %v\n", index, err) + break out + } + tag := op >> 3 + wire := op & 7 + + switch wire { + default: + fmt.Printf("%3d: t=%3d unknown wire=%d\n", + index, tag, wire) + break out + + case WireBytes: + var r []byte + + r, err = p.DecodeRawBytes(false) + if err != nil { + break out + } + fmt.Printf("%3d: t=%3d bytes [%d]", index, tag, len(r)) + if len(r) <= 6 { + for i := 0; i < len(r); i++ { + fmt.Printf(" %.2x", r[i]) + } + } else { + for i := 0; i < 3; i++ { + fmt.Printf(" %.2x", r[i]) + } + fmt.Printf(" ..") + for i := len(r) - 3; i < len(r); i++ { + fmt.Printf(" %.2x", r[i]) + } + } + fmt.Printf("\n") + + case WireFixed32: + u, err = p.DecodeFixed32() + if err != nil { + fmt.Printf("%3d: t=%3d fix32 err %v\n", index, tag, err) + break out + } + fmt.Printf("%3d: t=%3d fix32 %d\n", index, tag, u) + + case WireFixed64: + u, err = p.DecodeFixed64() + if err != nil { + fmt.Printf("%3d: t=%3d fix64 err %v\n", index, tag, err) + break out + } + fmt.Printf("%3d: t=%3d fix64 %d\n", index, tag, u) + + case WireVarint: + u, err = p.DecodeVarint() + if err != nil { + fmt.Printf("%3d: t=%3d varint err %v\n", index, tag, err) + break out + } + fmt.Printf("%3d: t=%3d varint %d\n", index, tag, u) + + case WireStartGroup: + fmt.Printf("%3d: t=%3d start\n", index, tag) + depth++ + + case WireEndGroup: + depth-- + fmt.Printf("%3d: t=%3d end\n", index, tag) + } + } + + if depth != 0 { + fmt.Printf("%3d: start-end not balanced %d\n", p.index, depth) + } + fmt.Printf("\n") + + p.buf = obuf + p.index = index +} + +// SetDefaults sets unset protocol buffer fields to their default values. +// It only modifies fields that are both unset and have defined defaults. +// It recursively sets default values in any non-nil sub-messages. +func SetDefaults(pb Message) { + setDefaults(reflect.ValueOf(pb), true, false) +} + +// v is a pointer to a struct. +func setDefaults(v reflect.Value, recur, zeros bool) { + v = v.Elem() + + defaultMu.RLock() + dm, ok := defaults[v.Type()] + defaultMu.RUnlock() + if !ok { + dm = buildDefaultMessage(v.Type()) + defaultMu.Lock() + defaults[v.Type()] = dm + defaultMu.Unlock() + } + + for _, sf := range dm.scalars { + f := v.Field(sf.index) + if !f.IsNil() { + // field already set + continue + } + dv := sf.value + if dv == nil && !zeros { + // no explicit default, and don't want to set zeros + continue + } + fptr := f.Addr().Interface() // **T + // TODO: Consider batching the allocations we do here. + switch sf.kind { + case reflect.Bool: + b := new(bool) + if dv != nil { + *b = dv.(bool) + } + *(fptr.(**bool)) = b + case reflect.Float32: + f := new(float32) + if dv != nil { + *f = dv.(float32) + } + *(fptr.(**float32)) = f + case reflect.Float64: + f := new(float64) + if dv != nil { + *f = dv.(float64) + } + *(fptr.(**float64)) = f + case reflect.Int32: + // might be an enum + if ft := f.Type(); ft != int32PtrType { + // enum + f.Set(reflect.New(ft.Elem())) + if dv != nil { + f.Elem().SetInt(int64(dv.(int32))) + } + } else { + // int32 field + i := new(int32) + if dv != nil { + *i = dv.(int32) + } + *(fptr.(**int32)) = i + } + case reflect.Int64: + i := new(int64) + if dv != nil { + *i = dv.(int64) + } + *(fptr.(**int64)) = i + case reflect.String: + s := new(string) + if dv != nil { + *s = dv.(string) + } + *(fptr.(**string)) = s + case reflect.Uint8: + // exceptional case: []byte + var b []byte + if dv != nil { + db := dv.([]byte) + b = make([]byte, len(db)) + copy(b, db) + } else { + b = []byte{} + } + *(fptr.(*[]byte)) = b + case reflect.Uint32: + u := new(uint32) + if dv != nil { + *u = dv.(uint32) + } + *(fptr.(**uint32)) = u + case reflect.Uint64: + u := new(uint64) + if dv != nil { + *u = dv.(uint64) + } + *(fptr.(**uint64)) = u + default: + log.Printf("proto: can't set default for field %v (sf.kind=%v)", f, sf.kind) + } + } + + for _, ni := range dm.nested { + f := v.Field(ni) + // f is *T or []*T or map[T]*T + switch f.Kind() { + case reflect.Ptr: + if f.IsNil() { + continue + } + setDefaults(f, recur, zeros) + + case reflect.Slice: + for i := 0; i < f.Len(); i++ { + e := f.Index(i) + if e.IsNil() { + continue + } + setDefaults(e, recur, zeros) + } + + case reflect.Map: + for _, k := range f.MapKeys() { + e := f.MapIndex(k) + if e.IsNil() { + continue + } + setDefaults(e, recur, zeros) + } + } + } +} + +var ( + // defaults maps a protocol buffer struct type to a slice of the fields, + // with its scalar fields set to their proto-declared non-zero default values. + defaultMu sync.RWMutex + defaults = make(map[reflect.Type]defaultMessage) + + int32PtrType = reflect.TypeOf((*int32)(nil)) +) + +// defaultMessage represents information about the default values of a message. +type defaultMessage struct { + scalars []scalarField + nested []int // struct field index of nested messages +} + +type scalarField struct { + index int // struct field index + kind reflect.Kind // element type (the T in *T or []T) + value interface{} // the proto-declared default value, or nil +} + +// t is a struct type. +func buildDefaultMessage(t reflect.Type) (dm defaultMessage) { + sprop := GetProperties(t) + for _, prop := range sprop.Prop { + fi, ok := sprop.decoderTags.get(prop.Tag) + if !ok { + // XXX_unrecognized + continue + } + ft := t.Field(fi).Type + + sf, nested, err := fieldDefault(ft, prop) + switch { + case err != nil: + log.Print(err) + case nested: + dm.nested = append(dm.nested, fi) + case sf != nil: + sf.index = fi + dm.scalars = append(dm.scalars, *sf) + } + } + + return dm +} + +// fieldDefault returns the scalarField for field type ft. +// sf will be nil if the field can not have a default. +// nestedMessage will be true if this is a nested message. +// Note that sf.index is not set on return. +func fieldDefault(ft reflect.Type, prop *Properties) (sf *scalarField, nestedMessage bool, err error) { + var canHaveDefault bool + switch ft.Kind() { + case reflect.Ptr: + if ft.Elem().Kind() == reflect.Struct { + nestedMessage = true + } else { + canHaveDefault = true // proto2 scalar field + } + + case reflect.Slice: + switch ft.Elem().Kind() { + case reflect.Ptr: + nestedMessage = true // repeated message + case reflect.Uint8: + canHaveDefault = true // bytes field + } + + case reflect.Map: + if ft.Elem().Kind() == reflect.Ptr { + nestedMessage = true // map with message values + } + } + + if !canHaveDefault { + if nestedMessage { + return nil, true, nil + } + return nil, false, nil + } + + // We now know that ft is a pointer or slice. + sf = &scalarField{kind: ft.Elem().Kind()} + + // scalar fields without defaults + if !prop.HasDefault { + return sf, false, nil + } + + // a scalar field: either *T or []byte + switch ft.Elem().Kind() { + case reflect.Bool: + x, err := strconv.ParseBool(prop.Default) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default bool %q: %v", prop.Default, err) + } + sf.value = x + case reflect.Float32: + x, err := strconv.ParseFloat(prop.Default, 32) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default float32 %q: %v", prop.Default, err) + } + sf.value = float32(x) + case reflect.Float64: + x, err := strconv.ParseFloat(prop.Default, 64) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default float64 %q: %v", prop.Default, err) + } + sf.value = x + case reflect.Int32: + x, err := strconv.ParseInt(prop.Default, 10, 32) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default int32 %q: %v", prop.Default, err) + } + sf.value = int32(x) + case reflect.Int64: + x, err := strconv.ParseInt(prop.Default, 10, 64) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default int64 %q: %v", prop.Default, err) + } + sf.value = x + case reflect.String: + sf.value = prop.Default + case reflect.Uint8: + // []byte (not *uint8) + sf.value = []byte(prop.Default) + case reflect.Uint32: + x, err := strconv.ParseUint(prop.Default, 10, 32) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default uint32 %q: %v", prop.Default, err) + } + sf.value = uint32(x) + case reflect.Uint64: + x, err := strconv.ParseUint(prop.Default, 10, 64) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default uint64 %q: %v", prop.Default, err) + } + sf.value = x + default: + return nil, false, fmt.Errorf("proto: unhandled def kind %v", ft.Elem().Kind()) + } + + return sf, false, nil +} + +// Map fields may have key types of non-float scalars, strings and enums. +// The easiest way to sort them in some deterministic order is to use fmt. +// If this turns out to be inefficient we can always consider other options, +// such as doing a Schwartzian transform. + +func mapKeys(vs []reflect.Value) sort.Interface { + s := mapKeySorter{ + vs: vs, + // default Less function: textual comparison + less: func(a, b reflect.Value) bool { + return fmt.Sprint(a.Interface()) < fmt.Sprint(b.Interface()) + }, + } + + // Type specialization per https://developers.google.com/protocol-buffers/docs/proto#maps; + // numeric keys are sorted numerically. + if len(vs) == 0 { + return s + } + switch vs[0].Kind() { + case reflect.Int32, reflect.Int64: + s.less = func(a, b reflect.Value) bool { return a.Int() < b.Int() } + case reflect.Uint32, reflect.Uint64: + s.less = func(a, b reflect.Value) bool { return a.Uint() < b.Uint() } + } + + return s +} + +type mapKeySorter struct { + vs []reflect.Value + less func(a, b reflect.Value) bool +} + +func (s mapKeySorter) Len() int { return len(s.vs) } +func (s mapKeySorter) Swap(i, j int) { s.vs[i], s.vs[j] = s.vs[j], s.vs[i] } +func (s mapKeySorter) Less(i, j int) bool { + return s.less(s.vs[i], s.vs[j]) +} + +// isProto3Zero reports whether v is a zero proto3 value. +func isProto3Zero(v reflect.Value) bool { + switch v.Kind() { + case reflect.Bool: + return !v.Bool() + case reflect.Int32, reflect.Int64: + return v.Int() == 0 + case reflect.Uint32, reflect.Uint64: + return v.Uint() == 0 + case reflect.Float32, reflect.Float64: + return v.Float() == 0 + case reflect.String: + return v.String() == "" + } + return false +} + +// ProtoPackageIsVersion1 is referenced from generated protocol buffer files +// to assert that that code is compatible with this version of the proto package. +const ProtoPackageIsVersion1 = true diff --git a/vendor/github.com/golang/protobuf/proto/message_set.go b/vendor/github.com/golang/protobuf/proto/message_set.go new file mode 100644 index 0000000000..e25e01e637 --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/message_set.go @@ -0,0 +1,280 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +package proto + +/* + * Support for message sets. + */ + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + "reflect" + "sort" +) + +// errNoMessageTypeID occurs when a protocol buffer does not have a message type ID. +// A message type ID is required for storing a protocol buffer in a message set. +var errNoMessageTypeID = errors.New("proto does not have a message type ID") + +// The first two types (_MessageSet_Item and messageSet) +// model what the protocol compiler produces for the following protocol message: +// message MessageSet { +// repeated group Item = 1 { +// required int32 type_id = 2; +// required string message = 3; +// }; +// } +// That is the MessageSet wire format. We can't use a proto to generate these +// because that would introduce a circular dependency between it and this package. + +type _MessageSet_Item struct { + TypeId *int32 `protobuf:"varint,2,req,name=type_id"` + Message []byte `protobuf:"bytes,3,req,name=message"` +} + +type messageSet struct { + Item []*_MessageSet_Item `protobuf:"group,1,rep"` + XXX_unrecognized []byte + // TODO: caching? +} + +// Make sure messageSet is a Message. +var _ Message = (*messageSet)(nil) + +// messageTypeIder is an interface satisfied by a protocol buffer type +// that may be stored in a MessageSet. +type messageTypeIder interface { + MessageTypeId() int32 +} + +func (ms *messageSet) find(pb Message) *_MessageSet_Item { + mti, ok := pb.(messageTypeIder) + if !ok { + return nil + } + id := mti.MessageTypeId() + for _, item := range ms.Item { + if *item.TypeId == id { + return item + } + } + return nil +} + +func (ms *messageSet) Has(pb Message) bool { + if ms.find(pb) != nil { + return true + } + return false +} + +func (ms *messageSet) Unmarshal(pb Message) error { + if item := ms.find(pb); item != nil { + return Unmarshal(item.Message, pb) + } + if _, ok := pb.(messageTypeIder); !ok { + return errNoMessageTypeID + } + return nil // TODO: return error instead? +} + +func (ms *messageSet) Marshal(pb Message) error { + msg, err := Marshal(pb) + if err != nil { + return err + } + if item := ms.find(pb); item != nil { + // reuse existing item + item.Message = msg + return nil + } + + mti, ok := pb.(messageTypeIder) + if !ok { + return errNoMessageTypeID + } + + mtid := mti.MessageTypeId() + ms.Item = append(ms.Item, &_MessageSet_Item{ + TypeId: &mtid, + Message: msg, + }) + return nil +} + +func (ms *messageSet) Reset() { *ms = messageSet{} } +func (ms *messageSet) String() string { return CompactTextString(ms) } +func (*messageSet) ProtoMessage() {} + +// Support for the message_set_wire_format message option. + +func skipVarint(buf []byte) []byte { + i := 0 + for ; buf[i]&0x80 != 0; i++ { + } + return buf[i+1:] +} + +// MarshalMessageSet encodes the extension map represented by m in the message set wire format. +// It is called by generated Marshal methods on protocol buffer messages with the message_set_wire_format option. +func MarshalMessageSet(m map[int32]Extension) ([]byte, error) { + if err := encodeExtensionMap(m); err != nil { + return nil, err + } + + // Sort extension IDs to provide a deterministic encoding. + // See also enc_map in encode.go. + ids := make([]int, 0, len(m)) + for id := range m { + ids = append(ids, int(id)) + } + sort.Ints(ids) + + ms := &messageSet{Item: make([]*_MessageSet_Item, 0, len(m))} + for _, id := range ids { + e := m[int32(id)] + // Remove the wire type and field number varint, as well as the length varint. + msg := skipVarint(skipVarint(e.enc)) + + ms.Item = append(ms.Item, &_MessageSet_Item{ + TypeId: Int32(int32(id)), + Message: msg, + }) + } + return Marshal(ms) +} + +// UnmarshalMessageSet decodes the extension map encoded in buf in the message set wire format. +// It is called by generated Unmarshal methods on protocol buffer messages with the message_set_wire_format option. +func UnmarshalMessageSet(buf []byte, m map[int32]Extension) error { + ms := new(messageSet) + if err := Unmarshal(buf, ms); err != nil { + return err + } + for _, item := range ms.Item { + id := *item.TypeId + msg := item.Message + + // Restore wire type and field number varint, plus length varint. + // Be careful to preserve duplicate items. + b := EncodeVarint(uint64(id)<<3 | WireBytes) + if ext, ok := m[id]; ok { + // Existing data; rip off the tag and length varint + // so we join the new data correctly. + // We can assume that ext.enc is set because we are unmarshaling. + o := ext.enc[len(b):] // skip wire type and field number + _, n := DecodeVarint(o) // calculate length of length varint + o = o[n:] // skip length varint + msg = append(o, msg...) // join old data and new data + } + b = append(b, EncodeVarint(uint64(len(msg)))...) + b = append(b, msg...) + + m[id] = Extension{enc: b} + } + return nil +} + +// MarshalMessageSetJSON encodes the extension map represented by m in JSON format. +// It is called by generated MarshalJSON methods on protocol buffer messages with the message_set_wire_format option. +func MarshalMessageSetJSON(m map[int32]Extension) ([]byte, error) { + var b bytes.Buffer + b.WriteByte('{') + + // Process the map in key order for deterministic output. + ids := make([]int32, 0, len(m)) + for id := range m { + ids = append(ids, id) + } + sort.Sort(int32Slice(ids)) // int32Slice defined in text.go + + for i, id := range ids { + ext := m[id] + if i > 0 { + b.WriteByte(',') + } + + msd, ok := messageSetMap[id] + if !ok { + // Unknown type; we can't render it, so skip it. + continue + } + fmt.Fprintf(&b, `"[%s]":`, msd.name) + + x := ext.value + if x == nil { + x = reflect.New(msd.t.Elem()).Interface() + if err := Unmarshal(ext.enc, x.(Message)); err != nil { + return nil, err + } + } + d, err := json.Marshal(x) + if err != nil { + return nil, err + } + b.Write(d) + } + b.WriteByte('}') + return b.Bytes(), nil +} + +// UnmarshalMessageSetJSON decodes the extension map encoded in buf in JSON format. +// It is called by generated UnmarshalJSON methods on protocol buffer messages with the message_set_wire_format option. +func UnmarshalMessageSetJSON(buf []byte, m map[int32]Extension) error { + // Common-case fast path. + if len(buf) == 0 || bytes.Equal(buf, []byte("{}")) { + return nil + } + + // This is fairly tricky, and it's not clear that it is needed. + return errors.New("TODO: UnmarshalMessageSetJSON not yet implemented") +} + +// A global registry of types that can be used in a MessageSet. + +var messageSetMap = make(map[int32]messageSetDesc) + +type messageSetDesc struct { + t reflect.Type // pointer to struct + name string +} + +// RegisterMessageSetType is called from the generated code. +func RegisterMessageSetType(m Message, fieldNum int32, name string) { + messageSetMap[fieldNum] = messageSetDesc{ + t: reflect.TypeOf(m), + name: name, + } +} diff --git a/vendor/github.com/golang/protobuf/proto/pointer_reflect.go b/vendor/github.com/golang/protobuf/proto/pointer_reflect.go new file mode 100644 index 0000000000..749919d250 --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/pointer_reflect.go @@ -0,0 +1,479 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2012 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +// +build appengine + +// This file contains an implementation of proto field accesses using package reflect. +// It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can +// be used on App Engine. + +package proto + +import ( + "math" + "reflect" +) + +// A structPointer is a pointer to a struct. +type structPointer struct { + v reflect.Value +} + +// toStructPointer returns a structPointer equivalent to the given reflect value. +// The reflect value must itself be a pointer to a struct. +func toStructPointer(v reflect.Value) structPointer { + return structPointer{v} +} + +// IsNil reports whether p is nil. +func structPointer_IsNil(p structPointer) bool { + return p.v.IsNil() +} + +// Interface returns the struct pointer as an interface value. +func structPointer_Interface(p structPointer, _ reflect.Type) interface{} { + return p.v.Interface() +} + +// A field identifies a field in a struct, accessible from a structPointer. +// In this implementation, a field is identified by the sequence of field indices +// passed to reflect's FieldByIndex. +type field []int + +// toField returns a field equivalent to the given reflect field. +func toField(f *reflect.StructField) field { + return f.Index +} + +// invalidField is an invalid field identifier. +var invalidField = field(nil) + +// IsValid reports whether the field identifier is valid. +func (f field) IsValid() bool { return f != nil } + +// field returns the given field in the struct as a reflect value. +func structPointer_field(p structPointer, f field) reflect.Value { + // Special case: an extension map entry with a value of type T + // passes a *T to the struct-handling code with a zero field, + // expecting that it will be treated as equivalent to *struct{ X T }, + // which has the same memory layout. We have to handle that case + // specially, because reflect will panic if we call FieldByIndex on a + // non-struct. + if f == nil { + return p.v.Elem() + } + + return p.v.Elem().FieldByIndex(f) +} + +// ifield returns the given field in the struct as an interface value. +func structPointer_ifield(p structPointer, f field) interface{} { + return structPointer_field(p, f).Addr().Interface() +} + +// Bytes returns the address of a []byte field in the struct. +func structPointer_Bytes(p structPointer, f field) *[]byte { + return structPointer_ifield(p, f).(*[]byte) +} + +// BytesSlice returns the address of a [][]byte field in the struct. +func structPointer_BytesSlice(p structPointer, f field) *[][]byte { + return structPointer_ifield(p, f).(*[][]byte) +} + +// Bool returns the address of a *bool field in the struct. +func structPointer_Bool(p structPointer, f field) **bool { + return structPointer_ifield(p, f).(**bool) +} + +// BoolVal returns the address of a bool field in the struct. +func structPointer_BoolVal(p structPointer, f field) *bool { + return structPointer_ifield(p, f).(*bool) +} + +// BoolSlice returns the address of a []bool field in the struct. +func structPointer_BoolSlice(p structPointer, f field) *[]bool { + return structPointer_ifield(p, f).(*[]bool) +} + +// String returns the address of a *string field in the struct. +func structPointer_String(p structPointer, f field) **string { + return structPointer_ifield(p, f).(**string) +} + +// StringVal returns the address of a string field in the struct. +func structPointer_StringVal(p structPointer, f field) *string { + return structPointer_ifield(p, f).(*string) +} + +// StringSlice returns the address of a []string field in the struct. +func structPointer_StringSlice(p structPointer, f field) *[]string { + return structPointer_ifield(p, f).(*[]string) +} + +// ExtMap returns the address of an extension map field in the struct. +func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension { + return structPointer_ifield(p, f).(*map[int32]Extension) +} + +// NewAt returns the reflect.Value for a pointer to a field in the struct. +func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value { + return structPointer_field(p, f).Addr() +} + +// SetStructPointer writes a *struct field in the struct. +func structPointer_SetStructPointer(p structPointer, f field, q structPointer) { + structPointer_field(p, f).Set(q.v) +} + +// GetStructPointer reads a *struct field in the struct. +func structPointer_GetStructPointer(p structPointer, f field) structPointer { + return structPointer{structPointer_field(p, f)} +} + +// StructPointerSlice the address of a []*struct field in the struct. +func structPointer_StructPointerSlice(p structPointer, f field) structPointerSlice { + return structPointerSlice{structPointer_field(p, f)} +} + +// A structPointerSlice represents the address of a slice of pointers to structs +// (themselves messages or groups). That is, v.Type() is *[]*struct{...}. +type structPointerSlice struct { + v reflect.Value +} + +func (p structPointerSlice) Len() int { return p.v.Len() } +func (p structPointerSlice) Index(i int) structPointer { return structPointer{p.v.Index(i)} } +func (p structPointerSlice) Append(q structPointer) { + p.v.Set(reflect.Append(p.v, q.v)) +} + +var ( + int32Type = reflect.TypeOf(int32(0)) + uint32Type = reflect.TypeOf(uint32(0)) + float32Type = reflect.TypeOf(float32(0)) + int64Type = reflect.TypeOf(int64(0)) + uint64Type = reflect.TypeOf(uint64(0)) + float64Type = reflect.TypeOf(float64(0)) +) + +// A word32 represents a field of type *int32, *uint32, *float32, or *enum. +// That is, v.Type() is *int32, *uint32, *float32, or *enum and v is assignable. +type word32 struct { + v reflect.Value +} + +// IsNil reports whether p is nil. +func word32_IsNil(p word32) bool { + return p.v.IsNil() +} + +// Set sets p to point at a newly allocated word with bits set to x. +func word32_Set(p word32, o *Buffer, x uint32) { + t := p.v.Type().Elem() + switch t { + case int32Type: + if len(o.int32s) == 0 { + o.int32s = make([]int32, uint32PoolSize) + } + o.int32s[0] = int32(x) + p.v.Set(reflect.ValueOf(&o.int32s[0])) + o.int32s = o.int32s[1:] + return + case uint32Type: + if len(o.uint32s) == 0 { + o.uint32s = make([]uint32, uint32PoolSize) + } + o.uint32s[0] = x + p.v.Set(reflect.ValueOf(&o.uint32s[0])) + o.uint32s = o.uint32s[1:] + return + case float32Type: + if len(o.float32s) == 0 { + o.float32s = make([]float32, uint32PoolSize) + } + o.float32s[0] = math.Float32frombits(x) + p.v.Set(reflect.ValueOf(&o.float32s[0])) + o.float32s = o.float32s[1:] + return + } + + // must be enum + p.v.Set(reflect.New(t)) + p.v.Elem().SetInt(int64(int32(x))) +} + +// Get gets the bits pointed at by p, as a uint32. +func word32_Get(p word32) uint32 { + elem := p.v.Elem() + switch elem.Kind() { + case reflect.Int32: + return uint32(elem.Int()) + case reflect.Uint32: + return uint32(elem.Uint()) + case reflect.Float32: + return math.Float32bits(float32(elem.Float())) + } + panic("unreachable") +} + +// Word32 returns a reference to a *int32, *uint32, *float32, or *enum field in the struct. +func structPointer_Word32(p structPointer, f field) word32 { + return word32{structPointer_field(p, f)} +} + +// A word32Val represents a field of type int32, uint32, float32, or enum. +// That is, v.Type() is int32, uint32, float32, or enum and v is assignable. +type word32Val struct { + v reflect.Value +} + +// Set sets *p to x. +func word32Val_Set(p word32Val, x uint32) { + switch p.v.Type() { + case int32Type: + p.v.SetInt(int64(x)) + return + case uint32Type: + p.v.SetUint(uint64(x)) + return + case float32Type: + p.v.SetFloat(float64(math.Float32frombits(x))) + return + } + + // must be enum + p.v.SetInt(int64(int32(x))) +} + +// Get gets the bits pointed at by p, as a uint32. +func word32Val_Get(p word32Val) uint32 { + elem := p.v + switch elem.Kind() { + case reflect.Int32: + return uint32(elem.Int()) + case reflect.Uint32: + return uint32(elem.Uint()) + case reflect.Float32: + return math.Float32bits(float32(elem.Float())) + } + panic("unreachable") +} + +// Word32Val returns a reference to a int32, uint32, float32, or enum field in the struct. +func structPointer_Word32Val(p structPointer, f field) word32Val { + return word32Val{structPointer_field(p, f)} +} + +// A word32Slice is a slice of 32-bit values. +// That is, v.Type() is []int32, []uint32, []float32, or []enum. +type word32Slice struct { + v reflect.Value +} + +func (p word32Slice) Append(x uint32) { + n, m := p.v.Len(), p.v.Cap() + if n < m { + p.v.SetLen(n + 1) + } else { + t := p.v.Type().Elem() + p.v.Set(reflect.Append(p.v, reflect.Zero(t))) + } + elem := p.v.Index(n) + switch elem.Kind() { + case reflect.Int32: + elem.SetInt(int64(int32(x))) + case reflect.Uint32: + elem.SetUint(uint64(x)) + case reflect.Float32: + elem.SetFloat(float64(math.Float32frombits(x))) + } +} + +func (p word32Slice) Len() int { + return p.v.Len() +} + +func (p word32Slice) Index(i int) uint32 { + elem := p.v.Index(i) + switch elem.Kind() { + case reflect.Int32: + return uint32(elem.Int()) + case reflect.Uint32: + return uint32(elem.Uint()) + case reflect.Float32: + return math.Float32bits(float32(elem.Float())) + } + panic("unreachable") +} + +// Word32Slice returns a reference to a []int32, []uint32, []float32, or []enum field in the struct. +func structPointer_Word32Slice(p structPointer, f field) word32Slice { + return word32Slice{structPointer_field(p, f)} +} + +// word64 is like word32 but for 64-bit values. +type word64 struct { + v reflect.Value +} + +func word64_Set(p word64, o *Buffer, x uint64) { + t := p.v.Type().Elem() + switch t { + case int64Type: + if len(o.int64s) == 0 { + o.int64s = make([]int64, uint64PoolSize) + } + o.int64s[0] = int64(x) + p.v.Set(reflect.ValueOf(&o.int64s[0])) + o.int64s = o.int64s[1:] + return + case uint64Type: + if len(o.uint64s) == 0 { + o.uint64s = make([]uint64, uint64PoolSize) + } + o.uint64s[0] = x + p.v.Set(reflect.ValueOf(&o.uint64s[0])) + o.uint64s = o.uint64s[1:] + return + case float64Type: + if len(o.float64s) == 0 { + o.float64s = make([]float64, uint64PoolSize) + } + o.float64s[0] = math.Float64frombits(x) + p.v.Set(reflect.ValueOf(&o.float64s[0])) + o.float64s = o.float64s[1:] + return + } + panic("unreachable") +} + +func word64_IsNil(p word64) bool { + return p.v.IsNil() +} + +func word64_Get(p word64) uint64 { + elem := p.v.Elem() + switch elem.Kind() { + case reflect.Int64: + return uint64(elem.Int()) + case reflect.Uint64: + return elem.Uint() + case reflect.Float64: + return math.Float64bits(elem.Float()) + } + panic("unreachable") +} + +func structPointer_Word64(p structPointer, f field) word64 { + return word64{structPointer_field(p, f)} +} + +// word64Val is like word32Val but for 64-bit values. +type word64Val struct { + v reflect.Value +} + +func word64Val_Set(p word64Val, o *Buffer, x uint64) { + switch p.v.Type() { + case int64Type: + p.v.SetInt(int64(x)) + return + case uint64Type: + p.v.SetUint(x) + return + case float64Type: + p.v.SetFloat(math.Float64frombits(x)) + return + } + panic("unreachable") +} + +func word64Val_Get(p word64Val) uint64 { + elem := p.v + switch elem.Kind() { + case reflect.Int64: + return uint64(elem.Int()) + case reflect.Uint64: + return elem.Uint() + case reflect.Float64: + return math.Float64bits(elem.Float()) + } + panic("unreachable") +} + +func structPointer_Word64Val(p structPointer, f field) word64Val { + return word64Val{structPointer_field(p, f)} +} + +type word64Slice struct { + v reflect.Value +} + +func (p word64Slice) Append(x uint64) { + n, m := p.v.Len(), p.v.Cap() + if n < m { + p.v.SetLen(n + 1) + } else { + t := p.v.Type().Elem() + p.v.Set(reflect.Append(p.v, reflect.Zero(t))) + } + elem := p.v.Index(n) + switch elem.Kind() { + case reflect.Int64: + elem.SetInt(int64(int64(x))) + case reflect.Uint64: + elem.SetUint(uint64(x)) + case reflect.Float64: + elem.SetFloat(float64(math.Float64frombits(x))) + } +} + +func (p word64Slice) Len() int { + return p.v.Len() +} + +func (p word64Slice) Index(i int) uint64 { + elem := p.v.Index(i) + switch elem.Kind() { + case reflect.Int64: + return uint64(elem.Int()) + case reflect.Uint64: + return uint64(elem.Uint()) + case reflect.Float64: + return math.Float64bits(float64(elem.Float())) + } + panic("unreachable") +} + +func structPointer_Word64Slice(p structPointer, f field) word64Slice { + return word64Slice{structPointer_field(p, f)} +} diff --git a/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go b/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go new file mode 100644 index 0000000000..e9be0fe92e --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/pointer_unsafe.go @@ -0,0 +1,266 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2012 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +// +build !appengine + +// This file contains the implementation of the proto field accesses using package unsafe. + +package proto + +import ( + "reflect" + "unsafe" +) + +// NOTE: These type_Foo functions would more idiomatically be methods, +// but Go does not allow methods on pointer types, and we must preserve +// some pointer type for the garbage collector. We use these +// funcs with clunky names as our poor approximation to methods. +// +// An alternative would be +// type structPointer struct { p unsafe.Pointer } +// but that does not registerize as well. + +// A structPointer is a pointer to a struct. +type structPointer unsafe.Pointer + +// toStructPointer returns a structPointer equivalent to the given reflect value. +func toStructPointer(v reflect.Value) structPointer { + return structPointer(unsafe.Pointer(v.Pointer())) +} + +// IsNil reports whether p is nil. +func structPointer_IsNil(p structPointer) bool { + return p == nil +} + +// Interface returns the struct pointer, assumed to have element type t, +// as an interface value. +func structPointer_Interface(p structPointer, t reflect.Type) interface{} { + return reflect.NewAt(t, unsafe.Pointer(p)).Interface() +} + +// A field identifies a field in a struct, accessible from a structPointer. +// In this implementation, a field is identified by its byte offset from the start of the struct. +type field uintptr + +// toField returns a field equivalent to the given reflect field. +func toField(f *reflect.StructField) field { + return field(f.Offset) +} + +// invalidField is an invalid field identifier. +const invalidField = ^field(0) + +// IsValid reports whether the field identifier is valid. +func (f field) IsValid() bool { + return f != ^field(0) +} + +// Bytes returns the address of a []byte field in the struct. +func structPointer_Bytes(p structPointer, f field) *[]byte { + return (*[]byte)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// BytesSlice returns the address of a [][]byte field in the struct. +func structPointer_BytesSlice(p structPointer, f field) *[][]byte { + return (*[][]byte)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// Bool returns the address of a *bool field in the struct. +func structPointer_Bool(p structPointer, f field) **bool { + return (**bool)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// BoolVal returns the address of a bool field in the struct. +func structPointer_BoolVal(p structPointer, f field) *bool { + return (*bool)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// BoolSlice returns the address of a []bool field in the struct. +func structPointer_BoolSlice(p structPointer, f field) *[]bool { + return (*[]bool)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// String returns the address of a *string field in the struct. +func structPointer_String(p structPointer, f field) **string { + return (**string)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// StringVal returns the address of a string field in the struct. +func structPointer_StringVal(p structPointer, f field) *string { + return (*string)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// StringSlice returns the address of a []string field in the struct. +func structPointer_StringSlice(p structPointer, f field) *[]string { + return (*[]string)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// ExtMap returns the address of an extension map field in the struct. +func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension { + return (*map[int32]Extension)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// NewAt returns the reflect.Value for a pointer to a field in the struct. +func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value { + return reflect.NewAt(typ, unsafe.Pointer(uintptr(p)+uintptr(f))) +} + +// SetStructPointer writes a *struct field in the struct. +func structPointer_SetStructPointer(p structPointer, f field, q structPointer) { + *(*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f))) = q +} + +// GetStructPointer reads a *struct field in the struct. +func structPointer_GetStructPointer(p structPointer, f field) structPointer { + return *(*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// StructPointerSlice the address of a []*struct field in the struct. +func structPointer_StructPointerSlice(p structPointer, f field) *structPointerSlice { + return (*structPointerSlice)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// A structPointerSlice represents a slice of pointers to structs (themselves submessages or groups). +type structPointerSlice []structPointer + +func (v *structPointerSlice) Len() int { return len(*v) } +func (v *structPointerSlice) Index(i int) structPointer { return (*v)[i] } +func (v *structPointerSlice) Append(p structPointer) { *v = append(*v, p) } + +// A word32 is the address of a "pointer to 32-bit value" field. +type word32 **uint32 + +// IsNil reports whether *v is nil. +func word32_IsNil(p word32) bool { + return *p == nil +} + +// Set sets *v to point at a newly allocated word set to x. +func word32_Set(p word32, o *Buffer, x uint32) { + if len(o.uint32s) == 0 { + o.uint32s = make([]uint32, uint32PoolSize) + } + o.uint32s[0] = x + *p = &o.uint32s[0] + o.uint32s = o.uint32s[1:] +} + +// Get gets the value pointed at by *v. +func word32_Get(p word32) uint32 { + return **p +} + +// Word32 returns the address of a *int32, *uint32, *float32, or *enum field in the struct. +func structPointer_Word32(p structPointer, f field) word32 { + return word32((**uint32)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +} + +// A word32Val is the address of a 32-bit value field. +type word32Val *uint32 + +// Set sets *p to x. +func word32Val_Set(p word32Val, x uint32) { + *p = x +} + +// Get gets the value pointed at by p. +func word32Val_Get(p word32Val) uint32 { + return *p +} + +// Word32Val returns the address of a *int32, *uint32, *float32, or *enum field in the struct. +func structPointer_Word32Val(p structPointer, f field) word32Val { + return word32Val((*uint32)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +} + +// A word32Slice is a slice of 32-bit values. +type word32Slice []uint32 + +func (v *word32Slice) Append(x uint32) { *v = append(*v, x) } +func (v *word32Slice) Len() int { return len(*v) } +func (v *word32Slice) Index(i int) uint32 { return (*v)[i] } + +// Word32Slice returns the address of a []int32, []uint32, []float32, or []enum field in the struct. +func structPointer_Word32Slice(p structPointer, f field) *word32Slice { + return (*word32Slice)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// word64 is like word32 but for 64-bit values. +type word64 **uint64 + +func word64_Set(p word64, o *Buffer, x uint64) { + if len(o.uint64s) == 0 { + o.uint64s = make([]uint64, uint64PoolSize) + } + o.uint64s[0] = x + *p = &o.uint64s[0] + o.uint64s = o.uint64s[1:] +} + +func word64_IsNil(p word64) bool { + return *p == nil +} + +func word64_Get(p word64) uint64 { + return **p +} + +func structPointer_Word64(p structPointer, f field) word64 { + return word64((**uint64)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +} + +// word64Val is like word32Val but for 64-bit values. +type word64Val *uint64 + +func word64Val_Set(p word64Val, o *Buffer, x uint64) { + *p = x +} + +func word64Val_Get(p word64Val) uint64 { + return *p +} + +func structPointer_Word64Val(p structPointer, f field) word64Val { + return word64Val((*uint64)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +} + +// word64Slice is like word32Slice but for 64-bit values. +type word64Slice []uint64 + +func (v *word64Slice) Append(x uint64) { *v = append(*v, x) } +func (v *word64Slice) Len() int { return len(*v) } +func (v *word64Slice) Index(i int) uint64 { return (*v)[i] } + +func structPointer_Word64Slice(p structPointer, f field) *word64Slice { + return (*word64Slice)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} diff --git a/vendor/github.com/golang/protobuf/proto/properties.go b/vendor/github.com/golang/protobuf/proto/properties.go new file mode 100644 index 0000000000..d4531c0563 --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/properties.go @@ -0,0 +1,842 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +package proto + +/* + * Routines for encoding data into the wire format for protocol buffers. + */ + +import ( + "fmt" + "log" + "os" + "reflect" + "sort" + "strconv" + "strings" + "sync" +) + +const debug bool = false + +// Constants that identify the encoding of a value on the wire. +const ( + WireVarint = 0 + WireFixed64 = 1 + WireBytes = 2 + WireStartGroup = 3 + WireEndGroup = 4 + WireFixed32 = 5 +) + +const startSize = 10 // initial slice/string sizes + +// Encoders are defined in encode.go +// An encoder outputs the full representation of a field, including its +// tag and encoder type. +type encoder func(p *Buffer, prop *Properties, base structPointer) error + +// A valueEncoder encodes a single integer in a particular encoding. +type valueEncoder func(o *Buffer, x uint64) error + +// Sizers are defined in encode.go +// A sizer returns the encoded size of a field, including its tag and encoder +// type. +type sizer func(prop *Properties, base structPointer) int + +// A valueSizer returns the encoded size of a single integer in a particular +// encoding. +type valueSizer func(x uint64) int + +// Decoders are defined in decode.go +// A decoder creates a value from its wire representation. +// Unrecognized subelements are saved in unrec. +type decoder func(p *Buffer, prop *Properties, base structPointer) error + +// A valueDecoder decodes a single integer in a particular encoding. +type valueDecoder func(o *Buffer) (x uint64, err error) + +// A oneofMarshaler does the marshaling for all oneof fields in a message. +type oneofMarshaler func(Message, *Buffer) error + +// A oneofUnmarshaler does the unmarshaling for a oneof field in a message. +type oneofUnmarshaler func(Message, int, int, *Buffer) (bool, error) + +// A oneofSizer does the sizing for all oneof fields in a message. +type oneofSizer func(Message) int + +// tagMap is an optimization over map[int]int for typical protocol buffer +// use-cases. Encoded protocol buffers are often in tag order with small tag +// numbers. +type tagMap struct { + fastTags []int + slowTags map[int]int +} + +// tagMapFastLimit is the upper bound on the tag number that will be stored in +// the tagMap slice rather than its map. +const tagMapFastLimit = 1024 + +func (p *tagMap) get(t int) (int, bool) { + if t > 0 && t < tagMapFastLimit { + if t >= len(p.fastTags) { + return 0, false + } + fi := p.fastTags[t] + return fi, fi >= 0 + } + fi, ok := p.slowTags[t] + return fi, ok +} + +func (p *tagMap) put(t int, fi int) { + if t > 0 && t < tagMapFastLimit { + for len(p.fastTags) < t+1 { + p.fastTags = append(p.fastTags, -1) + } + p.fastTags[t] = fi + return + } + if p.slowTags == nil { + p.slowTags = make(map[int]int) + } + p.slowTags[t] = fi +} + +// StructProperties represents properties for all the fields of a struct. +// decoderTags and decoderOrigNames should only be used by the decoder. +type StructProperties struct { + Prop []*Properties // properties for each field + reqCount int // required count + decoderTags tagMap // map from proto tag to struct field number + decoderOrigNames map[string]int // map from original name to struct field number + order []int // list of struct field numbers in tag order + unrecField field // field id of the XXX_unrecognized []byte field + extendable bool // is this an extendable proto + + oneofMarshaler oneofMarshaler + oneofUnmarshaler oneofUnmarshaler + oneofSizer oneofSizer + stype reflect.Type + + // OneofTypes contains information about the oneof fields in this message. + // It is keyed by the original name of a field. + OneofTypes map[string]*OneofProperties +} + +// OneofProperties represents information about a specific field in a oneof. +type OneofProperties struct { + Type reflect.Type // pointer to generated struct type for this oneof field + Field int // struct field number of the containing oneof in the message + Prop *Properties +} + +// Implement the sorting interface so we can sort the fields in tag order, as recommended by the spec. +// See encode.go, (*Buffer).enc_struct. + +func (sp *StructProperties) Len() int { return len(sp.order) } +func (sp *StructProperties) Less(i, j int) bool { + return sp.Prop[sp.order[i]].Tag < sp.Prop[sp.order[j]].Tag +} +func (sp *StructProperties) Swap(i, j int) { sp.order[i], sp.order[j] = sp.order[j], sp.order[i] } + +// Properties represents the protocol-specific behavior of a single struct field. +type Properties struct { + Name string // name of the field, for error messages + OrigName string // original name before protocol compiler (always set) + Wire string + WireType int + Tag int + Required bool + Optional bool + Repeated bool + Packed bool // relevant for repeated primitives only + Enum string // set for enum types only + proto3 bool // whether this is known to be a proto3 field; set for []byte only + oneof bool // whether this is a oneof field + + Default string // default value + HasDefault bool // whether an explicit default was provided + def_uint64 uint64 + + enc encoder + valEnc valueEncoder // set for bool and numeric types only + field field + tagcode []byte // encoding of EncodeVarint((Tag<<3)|WireType) + tagbuf [8]byte + stype reflect.Type // set for struct types only + sprop *StructProperties // set for struct types only + isMarshaler bool + isUnmarshaler bool + + mtype reflect.Type // set for map types only + mkeyprop *Properties // set for map types only + mvalprop *Properties // set for map types only + + size sizer + valSize valueSizer // set for bool and numeric types only + + dec decoder + valDec valueDecoder // set for bool and numeric types only + + // If this is a packable field, this will be the decoder for the packed version of the field. + packedDec decoder +} + +// String formats the properties in the protobuf struct field tag style. +func (p *Properties) String() string { + s := p.Wire + s = "," + s += strconv.Itoa(p.Tag) + if p.Required { + s += ",req" + } + if p.Optional { + s += ",opt" + } + if p.Repeated { + s += ",rep" + } + if p.Packed { + s += ",packed" + } + if p.OrigName != p.Name { + s += ",name=" + p.OrigName + } + if p.proto3 { + s += ",proto3" + } + if p.oneof { + s += ",oneof" + } + if len(p.Enum) > 0 { + s += ",enum=" + p.Enum + } + if p.HasDefault { + s += ",def=" + p.Default + } + return s +} + +// Parse populates p by parsing a string in the protobuf struct field tag style. +func (p *Properties) Parse(s string) { + // "bytes,49,opt,name=foo,def=hello!" + fields := strings.Split(s, ",") // breaks def=, but handled below. + if len(fields) < 2 { + fmt.Fprintf(os.Stderr, "proto: tag has too few fields: %q\n", s) + return + } + + p.Wire = fields[0] + switch p.Wire { + case "varint": + p.WireType = WireVarint + p.valEnc = (*Buffer).EncodeVarint + p.valDec = (*Buffer).DecodeVarint + p.valSize = sizeVarint + case "fixed32": + p.WireType = WireFixed32 + p.valEnc = (*Buffer).EncodeFixed32 + p.valDec = (*Buffer).DecodeFixed32 + p.valSize = sizeFixed32 + case "fixed64": + p.WireType = WireFixed64 + p.valEnc = (*Buffer).EncodeFixed64 + p.valDec = (*Buffer).DecodeFixed64 + p.valSize = sizeFixed64 + case "zigzag32": + p.WireType = WireVarint + p.valEnc = (*Buffer).EncodeZigzag32 + p.valDec = (*Buffer).DecodeZigzag32 + p.valSize = sizeZigzag32 + case "zigzag64": + p.WireType = WireVarint + p.valEnc = (*Buffer).EncodeZigzag64 + p.valDec = (*Buffer).DecodeZigzag64 + p.valSize = sizeZigzag64 + case "bytes", "group": + p.WireType = WireBytes + // no numeric converter for non-numeric types + default: + fmt.Fprintf(os.Stderr, "proto: tag has unknown wire type: %q\n", s) + return + } + + var err error + p.Tag, err = strconv.Atoi(fields[1]) + if err != nil { + return + } + + for i := 2; i < len(fields); i++ { + f := fields[i] + switch { + case f == "req": + p.Required = true + case f == "opt": + p.Optional = true + case f == "rep": + p.Repeated = true + case f == "packed": + p.Packed = true + case strings.HasPrefix(f, "name="): + p.OrigName = f[5:] + case strings.HasPrefix(f, "enum="): + p.Enum = f[5:] + case f == "proto3": + p.proto3 = true + case f == "oneof": + p.oneof = true + case strings.HasPrefix(f, "def="): + p.HasDefault = true + p.Default = f[4:] // rest of string + if i+1 < len(fields) { + // Commas aren't escaped, and def is always last. + p.Default += "," + strings.Join(fields[i+1:], ",") + break + } + } + } +} + +func logNoSliceEnc(t1, t2 reflect.Type) { + fmt.Fprintf(os.Stderr, "proto: no slice oenc for %T = []%T\n", t1, t2) +} + +var protoMessageType = reflect.TypeOf((*Message)(nil)).Elem() + +// Initialize the fields for encoding and decoding. +func (p *Properties) setEncAndDec(typ reflect.Type, f *reflect.StructField, lockGetProp bool) { + p.enc = nil + p.dec = nil + p.size = nil + + switch t1 := typ; t1.Kind() { + default: + fmt.Fprintf(os.Stderr, "proto: no coders for %v\n", t1) + + // proto3 scalar types + + case reflect.Bool: + p.enc = (*Buffer).enc_proto3_bool + p.dec = (*Buffer).dec_proto3_bool + p.size = size_proto3_bool + case reflect.Int32: + p.enc = (*Buffer).enc_proto3_int32 + p.dec = (*Buffer).dec_proto3_int32 + p.size = size_proto3_int32 + case reflect.Uint32: + p.enc = (*Buffer).enc_proto3_uint32 + p.dec = (*Buffer).dec_proto3_int32 // can reuse + p.size = size_proto3_uint32 + case reflect.Int64, reflect.Uint64: + p.enc = (*Buffer).enc_proto3_int64 + p.dec = (*Buffer).dec_proto3_int64 + p.size = size_proto3_int64 + case reflect.Float32: + p.enc = (*Buffer).enc_proto3_uint32 // can just treat them as bits + p.dec = (*Buffer).dec_proto3_int32 + p.size = size_proto3_uint32 + case reflect.Float64: + p.enc = (*Buffer).enc_proto3_int64 // can just treat them as bits + p.dec = (*Buffer).dec_proto3_int64 + p.size = size_proto3_int64 + case reflect.String: + p.enc = (*Buffer).enc_proto3_string + p.dec = (*Buffer).dec_proto3_string + p.size = size_proto3_string + + case reflect.Ptr: + switch t2 := t1.Elem(); t2.Kind() { + default: + fmt.Fprintf(os.Stderr, "proto: no encoder function for %v -> %v\n", t1, t2) + break + case reflect.Bool: + p.enc = (*Buffer).enc_bool + p.dec = (*Buffer).dec_bool + p.size = size_bool + case reflect.Int32: + p.enc = (*Buffer).enc_int32 + p.dec = (*Buffer).dec_int32 + p.size = size_int32 + case reflect.Uint32: + p.enc = (*Buffer).enc_uint32 + p.dec = (*Buffer).dec_int32 // can reuse + p.size = size_uint32 + case reflect.Int64, reflect.Uint64: + p.enc = (*Buffer).enc_int64 + p.dec = (*Buffer).dec_int64 + p.size = size_int64 + case reflect.Float32: + p.enc = (*Buffer).enc_uint32 // can just treat them as bits + p.dec = (*Buffer).dec_int32 + p.size = size_uint32 + case reflect.Float64: + p.enc = (*Buffer).enc_int64 // can just treat them as bits + p.dec = (*Buffer).dec_int64 + p.size = size_int64 + case reflect.String: + p.enc = (*Buffer).enc_string + p.dec = (*Buffer).dec_string + p.size = size_string + case reflect.Struct: + p.stype = t1.Elem() + p.isMarshaler = isMarshaler(t1) + p.isUnmarshaler = isUnmarshaler(t1) + if p.Wire == "bytes" { + p.enc = (*Buffer).enc_struct_message + p.dec = (*Buffer).dec_struct_message + p.size = size_struct_message + } else { + p.enc = (*Buffer).enc_struct_group + p.dec = (*Buffer).dec_struct_group + p.size = size_struct_group + } + } + + case reflect.Slice: + switch t2 := t1.Elem(); t2.Kind() { + default: + logNoSliceEnc(t1, t2) + break + case reflect.Bool: + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_bool + p.size = size_slice_packed_bool + } else { + p.enc = (*Buffer).enc_slice_bool + p.size = size_slice_bool + } + p.dec = (*Buffer).dec_slice_bool + p.packedDec = (*Buffer).dec_slice_packed_bool + case reflect.Int32: + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_int32 + p.size = size_slice_packed_int32 + } else { + p.enc = (*Buffer).enc_slice_int32 + p.size = size_slice_int32 + } + p.dec = (*Buffer).dec_slice_int32 + p.packedDec = (*Buffer).dec_slice_packed_int32 + case reflect.Uint32: + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_uint32 + p.size = size_slice_packed_uint32 + } else { + p.enc = (*Buffer).enc_slice_uint32 + p.size = size_slice_uint32 + } + p.dec = (*Buffer).dec_slice_int32 + p.packedDec = (*Buffer).dec_slice_packed_int32 + case reflect.Int64, reflect.Uint64: + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_int64 + p.size = size_slice_packed_int64 + } else { + p.enc = (*Buffer).enc_slice_int64 + p.size = size_slice_int64 + } + p.dec = (*Buffer).dec_slice_int64 + p.packedDec = (*Buffer).dec_slice_packed_int64 + case reflect.Uint8: + p.enc = (*Buffer).enc_slice_byte + p.dec = (*Buffer).dec_slice_byte + p.size = size_slice_byte + // This is a []byte, which is either a bytes field, + // or the value of a map field. In the latter case, + // we always encode an empty []byte, so we should not + // use the proto3 enc/size funcs. + // f == nil iff this is the key/value of a map field. + if p.proto3 && f != nil { + p.enc = (*Buffer).enc_proto3_slice_byte + p.size = size_proto3_slice_byte + } + case reflect.Float32, reflect.Float64: + switch t2.Bits() { + case 32: + // can just treat them as bits + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_uint32 + p.size = size_slice_packed_uint32 + } else { + p.enc = (*Buffer).enc_slice_uint32 + p.size = size_slice_uint32 + } + p.dec = (*Buffer).dec_slice_int32 + p.packedDec = (*Buffer).dec_slice_packed_int32 + case 64: + // can just treat them as bits + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_int64 + p.size = size_slice_packed_int64 + } else { + p.enc = (*Buffer).enc_slice_int64 + p.size = size_slice_int64 + } + p.dec = (*Buffer).dec_slice_int64 + p.packedDec = (*Buffer).dec_slice_packed_int64 + default: + logNoSliceEnc(t1, t2) + break + } + case reflect.String: + p.enc = (*Buffer).enc_slice_string + p.dec = (*Buffer).dec_slice_string + p.size = size_slice_string + case reflect.Ptr: + switch t3 := t2.Elem(); t3.Kind() { + default: + fmt.Fprintf(os.Stderr, "proto: no ptr oenc for %T -> %T -> %T\n", t1, t2, t3) + break + case reflect.Struct: + p.stype = t2.Elem() + p.isMarshaler = isMarshaler(t2) + p.isUnmarshaler = isUnmarshaler(t2) + if p.Wire == "bytes" { + p.enc = (*Buffer).enc_slice_struct_message + p.dec = (*Buffer).dec_slice_struct_message + p.size = size_slice_struct_message + } else { + p.enc = (*Buffer).enc_slice_struct_group + p.dec = (*Buffer).dec_slice_struct_group + p.size = size_slice_struct_group + } + } + case reflect.Slice: + switch t2.Elem().Kind() { + default: + fmt.Fprintf(os.Stderr, "proto: no slice elem oenc for %T -> %T -> %T\n", t1, t2, t2.Elem()) + break + case reflect.Uint8: + p.enc = (*Buffer).enc_slice_slice_byte + p.dec = (*Buffer).dec_slice_slice_byte + p.size = size_slice_slice_byte + } + } + + case reflect.Map: + p.enc = (*Buffer).enc_new_map + p.dec = (*Buffer).dec_new_map + p.size = size_new_map + + p.mtype = t1 + p.mkeyprop = &Properties{} + p.mkeyprop.init(reflect.PtrTo(p.mtype.Key()), "Key", f.Tag.Get("protobuf_key"), nil, lockGetProp) + p.mvalprop = &Properties{} + vtype := p.mtype.Elem() + if vtype.Kind() != reflect.Ptr && vtype.Kind() != reflect.Slice { + // The value type is not a message (*T) or bytes ([]byte), + // so we need encoders for the pointer to this type. + vtype = reflect.PtrTo(vtype) + } + p.mvalprop.init(vtype, "Value", f.Tag.Get("protobuf_val"), nil, lockGetProp) + } + + // precalculate tag code + wire := p.WireType + if p.Packed { + wire = WireBytes + } + x := uint32(p.Tag)<<3 | uint32(wire) + i := 0 + for i = 0; x > 127; i++ { + p.tagbuf[i] = 0x80 | uint8(x&0x7F) + x >>= 7 + } + p.tagbuf[i] = uint8(x) + p.tagcode = p.tagbuf[0 : i+1] + + if p.stype != nil { + if lockGetProp { + p.sprop = GetProperties(p.stype) + } else { + p.sprop = getPropertiesLocked(p.stype) + } + } +} + +var ( + marshalerType = reflect.TypeOf((*Marshaler)(nil)).Elem() + unmarshalerType = reflect.TypeOf((*Unmarshaler)(nil)).Elem() +) + +// isMarshaler reports whether type t implements Marshaler. +func isMarshaler(t reflect.Type) bool { + // We're checking for (likely) pointer-receiver methods + // so if t is not a pointer, something is very wrong. + // The calls above only invoke isMarshaler on pointer types. + if t.Kind() != reflect.Ptr { + panic("proto: misuse of isMarshaler") + } + return t.Implements(marshalerType) +} + +// isUnmarshaler reports whether type t implements Unmarshaler. +func isUnmarshaler(t reflect.Type) bool { + // We're checking for (likely) pointer-receiver methods + // so if t is not a pointer, something is very wrong. + // The calls above only invoke isUnmarshaler on pointer types. + if t.Kind() != reflect.Ptr { + panic("proto: misuse of isUnmarshaler") + } + return t.Implements(unmarshalerType) +} + +// Init populates the properties from a protocol buffer struct tag. +func (p *Properties) Init(typ reflect.Type, name, tag string, f *reflect.StructField) { + p.init(typ, name, tag, f, true) +} + +func (p *Properties) init(typ reflect.Type, name, tag string, f *reflect.StructField, lockGetProp bool) { + // "bytes,49,opt,def=hello!" + p.Name = name + p.OrigName = name + if f != nil { + p.field = toField(f) + } + if tag == "" { + return + } + p.Parse(tag) + p.setEncAndDec(typ, f, lockGetProp) +} + +var ( + propertiesMu sync.RWMutex + propertiesMap = make(map[reflect.Type]*StructProperties) +) + +// GetProperties returns the list of properties for the type represented by t. +// t must represent a generated struct type of a protocol message. +func GetProperties(t reflect.Type) *StructProperties { + if t.Kind() != reflect.Struct { + panic("proto: type must have kind struct") + } + + // Most calls to GetProperties in a long-running program will be + // retrieving details for types we have seen before. + propertiesMu.RLock() + sprop, ok := propertiesMap[t] + propertiesMu.RUnlock() + if ok { + if collectStats { + stats.Chit++ + } + return sprop + } + + propertiesMu.Lock() + sprop = getPropertiesLocked(t) + propertiesMu.Unlock() + return sprop +} + +// getPropertiesLocked requires that propertiesMu is held. +func getPropertiesLocked(t reflect.Type) *StructProperties { + if prop, ok := propertiesMap[t]; ok { + if collectStats { + stats.Chit++ + } + return prop + } + if collectStats { + stats.Cmiss++ + } + + prop := new(StructProperties) + // in case of recursive protos, fill this in now. + propertiesMap[t] = prop + + // build properties + prop.extendable = reflect.PtrTo(t).Implements(extendableProtoType) + prop.unrecField = invalidField + prop.Prop = make([]*Properties, t.NumField()) + prop.order = make([]int, t.NumField()) + + for i := 0; i < t.NumField(); i++ { + f := t.Field(i) + p := new(Properties) + name := f.Name + p.init(f.Type, name, f.Tag.Get("protobuf"), &f, false) + + if f.Name == "XXX_extensions" { // special case + p.enc = (*Buffer).enc_map + p.dec = nil // not needed + p.size = size_map + } + if f.Name == "XXX_unrecognized" { // special case + prop.unrecField = toField(&f) + } + oneof := f.Tag.Get("protobuf_oneof") != "" // special case + prop.Prop[i] = p + prop.order[i] = i + if debug { + print(i, " ", f.Name, " ", t.String(), " ") + if p.Tag > 0 { + print(p.String()) + } + print("\n") + } + if p.enc == nil && !strings.HasPrefix(f.Name, "XXX_") && !oneof { + fmt.Fprintln(os.Stderr, "proto: no encoder for", f.Name, f.Type.String(), "[GetProperties]") + } + } + + // Re-order prop.order. + sort.Sort(prop) + + type oneofMessage interface { + XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{}) + } + if om, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); ok { + var oots []interface{} + prop.oneofMarshaler, prop.oneofUnmarshaler, prop.oneofSizer, oots = om.XXX_OneofFuncs() + prop.stype = t + + // Interpret oneof metadata. + prop.OneofTypes = make(map[string]*OneofProperties) + for _, oot := range oots { + oop := &OneofProperties{ + Type: reflect.ValueOf(oot).Type(), // *T + Prop: new(Properties), + } + sft := oop.Type.Elem().Field(0) + oop.Prop.Name = sft.Name + oop.Prop.Parse(sft.Tag.Get("protobuf")) + // There will be exactly one interface field that + // this new value is assignable to. + for i := 0; i < t.NumField(); i++ { + f := t.Field(i) + if f.Type.Kind() != reflect.Interface { + continue + } + if !oop.Type.AssignableTo(f.Type) { + continue + } + oop.Field = i + break + } + prop.OneofTypes[oop.Prop.OrigName] = oop + } + } + + // build required counts + // build tags + reqCount := 0 + prop.decoderOrigNames = make(map[string]int) + for i, p := range prop.Prop { + if strings.HasPrefix(p.Name, "XXX_") { + // Internal fields should not appear in tags/origNames maps. + // They are handled specially when encoding and decoding. + continue + } + if p.Required { + reqCount++ + } + prop.decoderTags.put(p.Tag, i) + prop.decoderOrigNames[p.OrigName] = i + } + prop.reqCount = reqCount + + return prop +} + +// Return the Properties object for the x[0]'th field of the structure. +func propByIndex(t reflect.Type, x []int) *Properties { + if len(x) != 1 { + fmt.Fprintf(os.Stderr, "proto: field index dimension %d (not 1) for type %s\n", len(x), t) + return nil + } + prop := GetProperties(t) + return prop.Prop[x[0]] +} + +// Get the address and type of a pointer to a struct from an interface. +func getbase(pb Message) (t reflect.Type, b structPointer, err error) { + if pb == nil { + err = ErrNil + return + } + // get the reflect type of the pointer to the struct. + t = reflect.TypeOf(pb) + // get the address of the struct. + value := reflect.ValueOf(pb) + b = toStructPointer(value) + return +} + +// A global registry of enum types. +// The generated code will register the generated maps by calling RegisterEnum. + +var enumValueMaps = make(map[string]map[string]int32) + +// RegisterEnum is called from the generated code to install the enum descriptor +// maps into the global table to aid parsing text format protocol buffers. +func RegisterEnum(typeName string, unusedNameMap map[int32]string, valueMap map[string]int32) { + if _, ok := enumValueMaps[typeName]; ok { + panic("proto: duplicate enum registered: " + typeName) + } + enumValueMaps[typeName] = valueMap +} + +// EnumValueMap returns the mapping from names to integers of the +// enum type enumType, or a nil if not found. +func EnumValueMap(enumType string) map[string]int32 { + return enumValueMaps[enumType] +} + +// A registry of all linked message types. +// The string is a fully-qualified proto name ("pkg.Message"). +var ( + protoTypes = make(map[string]reflect.Type) + revProtoTypes = make(map[reflect.Type]string) +) + +// RegisterType is called from generated code and maps from the fully qualified +// proto name to the type (pointer to struct) of the protocol buffer. +func RegisterType(x Message, name string) { + if _, ok := protoTypes[name]; ok { + // TODO: Some day, make this a panic. + log.Printf("proto: duplicate proto type registered: %s", name) + return + } + t := reflect.TypeOf(x) + protoTypes[name] = t + revProtoTypes[t] = name +} + +// MessageName returns the fully-qualified proto name for the given message type. +func MessageName(x Message) string { return revProtoTypes[reflect.TypeOf(x)] } + +// MessageType returns the message type (pointer to struct) for a named message. +func MessageType(name string) reflect.Type { return protoTypes[name] } diff --git a/vendor/github.com/golang/protobuf/proto/text.go b/vendor/github.com/golang/protobuf/proto/text.go new file mode 100644 index 0000000000..2336b144c1 --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/text.go @@ -0,0 +1,751 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +package proto + +// Functions for writing the text protocol buffer format. + +import ( + "bufio" + "bytes" + "encoding" + "errors" + "fmt" + "io" + "log" + "math" + "reflect" + "sort" + "strings" +) + +var ( + newline = []byte("\n") + spaces = []byte(" ") + gtNewline = []byte(">\n") + endBraceNewline = []byte("}\n") + backslashN = []byte{'\\', 'n'} + backslashR = []byte{'\\', 'r'} + backslashT = []byte{'\\', 't'} + backslashDQ = []byte{'\\', '"'} + backslashBS = []byte{'\\', '\\'} + posInf = []byte("inf") + negInf = []byte("-inf") + nan = []byte("nan") +) + +type writer interface { + io.Writer + WriteByte(byte) error +} + +// textWriter is an io.Writer that tracks its indentation level. +type textWriter struct { + ind int + complete bool // if the current position is a complete line + compact bool // whether to write out as a one-liner + w writer +} + +func (w *textWriter) WriteString(s string) (n int, err error) { + if !strings.Contains(s, "\n") { + if !w.compact && w.complete { + w.writeIndent() + } + w.complete = false + return io.WriteString(w.w, s) + } + // WriteString is typically called without newlines, so this + // codepath and its copy are rare. We copy to avoid + // duplicating all of Write's logic here. + return w.Write([]byte(s)) +} + +func (w *textWriter) Write(p []byte) (n int, err error) { + newlines := bytes.Count(p, newline) + if newlines == 0 { + if !w.compact && w.complete { + w.writeIndent() + } + n, err = w.w.Write(p) + w.complete = false + return n, err + } + + frags := bytes.SplitN(p, newline, newlines+1) + if w.compact { + for i, frag := range frags { + if i > 0 { + if err := w.w.WriteByte(' '); err != nil { + return n, err + } + n++ + } + nn, err := w.w.Write(frag) + n += nn + if err != nil { + return n, err + } + } + return n, nil + } + + for i, frag := range frags { + if w.complete { + w.writeIndent() + } + nn, err := w.w.Write(frag) + n += nn + if err != nil { + return n, err + } + if i+1 < len(frags) { + if err := w.w.WriteByte('\n'); err != nil { + return n, err + } + n++ + } + } + w.complete = len(frags[len(frags)-1]) == 0 + return n, nil +} + +func (w *textWriter) WriteByte(c byte) error { + if w.compact && c == '\n' { + c = ' ' + } + if !w.compact && w.complete { + w.writeIndent() + } + err := w.w.WriteByte(c) + w.complete = c == '\n' + return err +} + +func (w *textWriter) indent() { w.ind++ } + +func (w *textWriter) unindent() { + if w.ind == 0 { + log.Printf("proto: textWriter unindented too far") + return + } + w.ind-- +} + +func writeName(w *textWriter, props *Properties) error { + if _, err := w.WriteString(props.OrigName); err != nil { + return err + } + if props.Wire != "group" { + return w.WriteByte(':') + } + return nil +} + +// raw is the interface satisfied by RawMessage. +type raw interface { + Bytes() []byte +} + +func writeStruct(w *textWriter, sv reflect.Value) error { + st := sv.Type() + sprops := GetProperties(st) + for i := 0; i < sv.NumField(); i++ { + fv := sv.Field(i) + props := sprops.Prop[i] + name := st.Field(i).Name + + if strings.HasPrefix(name, "XXX_") { + // There are two XXX_ fields: + // XXX_unrecognized []byte + // XXX_extensions map[int32]proto.Extension + // The first is handled here; + // the second is handled at the bottom of this function. + if name == "XXX_unrecognized" && !fv.IsNil() { + if err := writeUnknownStruct(w, fv.Interface().([]byte)); err != nil { + return err + } + } + continue + } + if fv.Kind() == reflect.Ptr && fv.IsNil() { + // Field not filled in. This could be an optional field or + // a required field that wasn't filled in. Either way, there + // isn't anything we can show for it. + continue + } + if fv.Kind() == reflect.Slice && fv.IsNil() { + // Repeated field that is empty, or a bytes field that is unused. + continue + } + + if props.Repeated && fv.Kind() == reflect.Slice { + // Repeated field. + for j := 0; j < fv.Len(); j++ { + if err := writeName(w, props); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + v := fv.Index(j) + if v.Kind() == reflect.Ptr && v.IsNil() { + // A nil message in a repeated field is not valid, + // but we can handle that more gracefully than panicking. + if _, err := w.Write([]byte("\n")); err != nil { + return err + } + continue + } + if err := writeAny(w, v, props); err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + } + continue + } + if fv.Kind() == reflect.Map { + // Map fields are rendered as a repeated struct with key/value fields. + keys := fv.MapKeys() + sort.Sort(mapKeys(keys)) + for _, key := range keys { + val := fv.MapIndex(key) + if err := writeName(w, props); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + // open struct + if err := w.WriteByte('<'); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte('\n'); err != nil { + return err + } + } + w.indent() + // key + if _, err := w.WriteString("key:"); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + if err := writeAny(w, key, props.mkeyprop); err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + // nil values aren't legal, but we can avoid panicking because of them. + if val.Kind() != reflect.Ptr || !val.IsNil() { + // value + if _, err := w.WriteString("value:"); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + if err := writeAny(w, val, props.mvalprop); err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + } + // close struct + w.unindent() + if err := w.WriteByte('>'); err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + } + continue + } + if props.proto3 && fv.Kind() == reflect.Slice && fv.Len() == 0 { + // empty bytes field + continue + } + if fv.Kind() != reflect.Ptr && fv.Kind() != reflect.Slice { + // proto3 non-repeated scalar field; skip if zero value + if isProto3Zero(fv) { + continue + } + } + + if fv.Kind() == reflect.Interface { + // Check if it is a oneof. + if st.Field(i).Tag.Get("protobuf_oneof") != "" { + // fv is nil, or holds a pointer to generated struct. + // That generated struct has exactly one field, + // which has a protobuf struct tag. + if fv.IsNil() { + continue + } + inner := fv.Elem().Elem() // interface -> *T -> T + tag := inner.Type().Field(0).Tag.Get("protobuf") + props = new(Properties) // Overwrite the outer props var, but not its pointee. + props.Parse(tag) + // Write the value in the oneof, not the oneof itself. + fv = inner.Field(0) + + // Special case to cope with malformed messages gracefully: + // If the value in the oneof is a nil pointer, don't panic + // in writeAny. + if fv.Kind() == reflect.Ptr && fv.IsNil() { + // Use errors.New so writeAny won't render quotes. + msg := errors.New("/* nil */") + fv = reflect.ValueOf(&msg).Elem() + } + } + } + + if err := writeName(w, props); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + if b, ok := fv.Interface().(raw); ok { + if err := writeRaw(w, b.Bytes()); err != nil { + return err + } + continue + } + + // Enums have a String method, so writeAny will work fine. + if err := writeAny(w, fv, props); err != nil { + return err + } + + if err := w.WriteByte('\n'); err != nil { + return err + } + } + + // Extensions (the XXX_extensions field). + pv := sv.Addr() + if pv.Type().Implements(extendableProtoType) { + if err := writeExtensions(w, pv); err != nil { + return err + } + } + + return nil +} + +// writeRaw writes an uninterpreted raw message. +func writeRaw(w *textWriter, b []byte) error { + if err := w.WriteByte('<'); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte('\n'); err != nil { + return err + } + } + w.indent() + if err := writeUnknownStruct(w, b); err != nil { + return err + } + w.unindent() + if err := w.WriteByte('>'); err != nil { + return err + } + return nil +} + +// writeAny writes an arbitrary field. +func writeAny(w *textWriter, v reflect.Value, props *Properties) error { + v = reflect.Indirect(v) + + // Floats have special cases. + if v.Kind() == reflect.Float32 || v.Kind() == reflect.Float64 { + x := v.Float() + var b []byte + switch { + case math.IsInf(x, 1): + b = posInf + case math.IsInf(x, -1): + b = negInf + case math.IsNaN(x): + b = nan + } + if b != nil { + _, err := w.Write(b) + return err + } + // Other values are handled below. + } + + // We don't attempt to serialise every possible value type; only those + // that can occur in protocol buffers. + switch v.Kind() { + case reflect.Slice: + // Should only be a []byte; repeated fields are handled in writeStruct. + if err := writeString(w, string(v.Interface().([]byte))); err != nil { + return err + } + case reflect.String: + if err := writeString(w, v.String()); err != nil { + return err + } + case reflect.Struct: + // Required/optional group/message. + var bra, ket byte = '<', '>' + if props != nil && props.Wire == "group" { + bra, ket = '{', '}' + } + if err := w.WriteByte(bra); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte('\n'); err != nil { + return err + } + } + w.indent() + if tm, ok := v.Interface().(encoding.TextMarshaler); ok { + text, err := tm.MarshalText() + if err != nil { + return err + } + if _, err = w.Write(text); err != nil { + return err + } + } else if err := writeStruct(w, v); err != nil { + return err + } + w.unindent() + if err := w.WriteByte(ket); err != nil { + return err + } + default: + _, err := fmt.Fprint(w, v.Interface()) + return err + } + return nil +} + +// equivalent to C's isprint. +func isprint(c byte) bool { + return c >= 0x20 && c < 0x7f +} + +// writeString writes a string in the protocol buffer text format. +// It is similar to strconv.Quote except we don't use Go escape sequences, +// we treat the string as a byte sequence, and we use octal escapes. +// These differences are to maintain interoperability with the other +// languages' implementations of the text format. +func writeString(w *textWriter, s string) error { + // use WriteByte here to get any needed indent + if err := w.WriteByte('"'); err != nil { + return err + } + // Loop over the bytes, not the runes. + for i := 0; i < len(s); i++ { + var err error + // Divergence from C++: we don't escape apostrophes. + // There's no need to escape them, and the C++ parser + // copes with a naked apostrophe. + switch c := s[i]; c { + case '\n': + _, err = w.w.Write(backslashN) + case '\r': + _, err = w.w.Write(backslashR) + case '\t': + _, err = w.w.Write(backslashT) + case '"': + _, err = w.w.Write(backslashDQ) + case '\\': + _, err = w.w.Write(backslashBS) + default: + if isprint(c) { + err = w.w.WriteByte(c) + } else { + _, err = fmt.Fprintf(w.w, "\\%03o", c) + } + } + if err != nil { + return err + } + } + return w.WriteByte('"') +} + +func writeUnknownStruct(w *textWriter, data []byte) (err error) { + if !w.compact { + if _, err := fmt.Fprintf(w, "/* %d unknown bytes */\n", len(data)); err != nil { + return err + } + } + b := NewBuffer(data) + for b.index < len(b.buf) { + x, err := b.DecodeVarint() + if err != nil { + _, err := fmt.Fprintf(w, "/* %v */\n", err) + return err + } + wire, tag := x&7, x>>3 + if wire == WireEndGroup { + w.unindent() + if _, err := w.Write(endBraceNewline); err != nil { + return err + } + continue + } + if _, err := fmt.Fprint(w, tag); err != nil { + return err + } + if wire != WireStartGroup { + if err := w.WriteByte(':'); err != nil { + return err + } + } + if !w.compact || wire == WireStartGroup { + if err := w.WriteByte(' '); err != nil { + return err + } + } + switch wire { + case WireBytes: + buf, e := b.DecodeRawBytes(false) + if e == nil { + _, err = fmt.Fprintf(w, "%q", buf) + } else { + _, err = fmt.Fprintf(w, "/* %v */", e) + } + case WireFixed32: + x, err = b.DecodeFixed32() + err = writeUnknownInt(w, x, err) + case WireFixed64: + x, err = b.DecodeFixed64() + err = writeUnknownInt(w, x, err) + case WireStartGroup: + err = w.WriteByte('{') + w.indent() + case WireVarint: + x, err = b.DecodeVarint() + err = writeUnknownInt(w, x, err) + default: + _, err = fmt.Fprintf(w, "/* unknown wire type %d */", wire) + } + if err != nil { + return err + } + if err = w.WriteByte('\n'); err != nil { + return err + } + } + return nil +} + +func writeUnknownInt(w *textWriter, x uint64, err error) error { + if err == nil { + _, err = fmt.Fprint(w, x) + } else { + _, err = fmt.Fprintf(w, "/* %v */", err) + } + return err +} + +type int32Slice []int32 + +func (s int32Slice) Len() int { return len(s) } +func (s int32Slice) Less(i, j int) bool { return s[i] < s[j] } +func (s int32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } + +// writeExtensions writes all the extensions in pv. +// pv is assumed to be a pointer to a protocol message struct that is extendable. +func writeExtensions(w *textWriter, pv reflect.Value) error { + emap := extensionMaps[pv.Type().Elem()] + ep := pv.Interface().(extendableProto) + + // Order the extensions by ID. + // This isn't strictly necessary, but it will give us + // canonical output, which will also make testing easier. + m := ep.ExtensionMap() + ids := make([]int32, 0, len(m)) + for id := range m { + ids = append(ids, id) + } + sort.Sort(int32Slice(ids)) + + for _, extNum := range ids { + ext := m[extNum] + var desc *ExtensionDesc + if emap != nil { + desc = emap[extNum] + } + if desc == nil { + // Unknown extension. + if err := writeUnknownStruct(w, ext.enc); err != nil { + return err + } + continue + } + + pb, err := GetExtension(ep, desc) + if err != nil { + return fmt.Errorf("failed getting extension: %v", err) + } + + // Repeated extensions will appear as a slice. + if !desc.repeated() { + if err := writeExtension(w, desc.Name, pb); err != nil { + return err + } + } else { + v := reflect.ValueOf(pb) + for i := 0; i < v.Len(); i++ { + if err := writeExtension(w, desc.Name, v.Index(i).Interface()); err != nil { + return err + } + } + } + } + return nil +} + +func writeExtension(w *textWriter, name string, pb interface{}) error { + if _, err := fmt.Fprintf(w, "[%s]:", name); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + if err := writeAny(w, reflect.ValueOf(pb), nil); err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + return nil +} + +func (w *textWriter) writeIndent() { + if !w.complete { + return + } + remain := w.ind * 2 + for remain > 0 { + n := remain + if n > len(spaces) { + n = len(spaces) + } + w.w.Write(spaces[:n]) + remain -= n + } + w.complete = false +} + +func marshalText(w io.Writer, pb Message, compact bool) error { + val := reflect.ValueOf(pb) + if pb == nil || val.IsNil() { + w.Write([]byte("")) + return nil + } + var bw *bufio.Writer + ww, ok := w.(writer) + if !ok { + bw = bufio.NewWriter(w) + ww = bw + } + aw := &textWriter{ + w: ww, + complete: true, + compact: compact, + } + + if tm, ok := pb.(encoding.TextMarshaler); ok { + text, err := tm.MarshalText() + if err != nil { + return err + } + if _, err = aw.Write(text); err != nil { + return err + } + if bw != nil { + return bw.Flush() + } + return nil + } + // Dereference the received pointer so we don't have outer < and >. + v := reflect.Indirect(val) + if err := writeStruct(aw, v); err != nil { + return err + } + if bw != nil { + return bw.Flush() + } + return nil +} + +// MarshalText writes a given protocol buffer in text format. +// The only errors returned are from w. +func MarshalText(w io.Writer, pb Message) error { + return marshalText(w, pb, false) +} + +// MarshalTextString is the same as MarshalText, but returns the string directly. +func MarshalTextString(pb Message) string { + var buf bytes.Buffer + marshalText(&buf, pb, false) + return buf.String() +} + +// CompactText writes a given protocol buffer in compact text format (one line). +func CompactText(w io.Writer, pb Message) error { return marshalText(w, pb, true) } + +// CompactTextString is the same as CompactText, but returns the string directly. +func CompactTextString(pb Message) string { + var buf bytes.Buffer + marshalText(&buf, pb, true) + return buf.String() +} diff --git a/vendor/github.com/golang/protobuf/proto/text_parser.go b/vendor/github.com/golang/protobuf/proto/text_parser.go new file mode 100644 index 0000000000..6d0cf25894 --- /dev/null +++ b/vendor/github.com/golang/protobuf/proto/text_parser.go @@ -0,0 +1,798 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +package proto + +// Functions for parsing the Text protocol buffer format. +// TODO: message sets. + +import ( + "encoding" + "errors" + "fmt" + "reflect" + "strconv" + "strings" + "unicode/utf8" +) + +type ParseError struct { + Message string + Line int // 1-based line number + Offset int // 0-based byte offset from start of input +} + +func (p *ParseError) Error() string { + if p.Line == 1 { + // show offset only for first line + return fmt.Sprintf("line 1.%d: %v", p.Offset, p.Message) + } + return fmt.Sprintf("line %d: %v", p.Line, p.Message) +} + +type token struct { + value string + err *ParseError + line int // line number + offset int // byte number from start of input, not start of line + unquoted string // the unquoted version of value, if it was a quoted string +} + +func (t *token) String() string { + if t.err == nil { + return fmt.Sprintf("%q (line=%d, offset=%d)", t.value, t.line, t.offset) + } + return fmt.Sprintf("parse error: %v", t.err) +} + +type textParser struct { + s string // remaining input + done bool // whether the parsing is finished (success or error) + backed bool // whether back() was called + offset, line int + cur token +} + +func newTextParser(s string) *textParser { + p := new(textParser) + p.s = s + p.line = 1 + p.cur.line = 1 + return p +} + +func (p *textParser) errorf(format string, a ...interface{}) *ParseError { + pe := &ParseError{fmt.Sprintf(format, a...), p.cur.line, p.cur.offset} + p.cur.err = pe + p.done = true + return pe +} + +// Numbers and identifiers are matched by [-+._A-Za-z0-9] +func isIdentOrNumberChar(c byte) bool { + switch { + case 'A' <= c && c <= 'Z', 'a' <= c && c <= 'z': + return true + case '0' <= c && c <= '9': + return true + } + switch c { + case '-', '+', '.', '_': + return true + } + return false +} + +func isWhitespace(c byte) bool { + switch c { + case ' ', '\t', '\n', '\r': + return true + } + return false +} + +func (p *textParser) skipWhitespace() { + i := 0 + for i < len(p.s) && (isWhitespace(p.s[i]) || p.s[i] == '#') { + if p.s[i] == '#' { + // comment; skip to end of line or input + for i < len(p.s) && p.s[i] != '\n' { + i++ + } + if i == len(p.s) { + break + } + } + if p.s[i] == '\n' { + p.line++ + } + i++ + } + p.offset += i + p.s = p.s[i:len(p.s)] + if len(p.s) == 0 { + p.done = true + } +} + +func (p *textParser) advance() { + // Skip whitespace + p.skipWhitespace() + if p.done { + return + } + + // Start of non-whitespace + p.cur.err = nil + p.cur.offset, p.cur.line = p.offset, p.line + p.cur.unquoted = "" + switch p.s[0] { + case '<', '>', '{', '}', ':', '[', ']', ';', ',': + // Single symbol + p.cur.value, p.s = p.s[0:1], p.s[1:len(p.s)] + case '"', '\'': + // Quoted string + i := 1 + for i < len(p.s) && p.s[i] != p.s[0] && p.s[i] != '\n' { + if p.s[i] == '\\' && i+1 < len(p.s) { + // skip escaped char + i++ + } + i++ + } + if i >= len(p.s) || p.s[i] != p.s[0] { + p.errorf("unmatched quote") + return + } + unq, err := unquoteC(p.s[1:i], rune(p.s[0])) + if err != nil { + p.errorf("invalid quoted string %s: %v", p.s[0:i+1], err) + return + } + p.cur.value, p.s = p.s[0:i+1], p.s[i+1:len(p.s)] + p.cur.unquoted = unq + default: + i := 0 + for i < len(p.s) && isIdentOrNumberChar(p.s[i]) { + i++ + } + if i == 0 { + p.errorf("unexpected byte %#x", p.s[0]) + return + } + p.cur.value, p.s = p.s[0:i], p.s[i:len(p.s)] + } + p.offset += len(p.cur.value) +} + +var ( + errBadUTF8 = errors.New("proto: bad UTF-8") + errBadHex = errors.New("proto: bad hexadecimal") +) + +func unquoteC(s string, quote rune) (string, error) { + // This is based on C++'s tokenizer.cc. + // Despite its name, this is *not* parsing C syntax. + // For instance, "\0" is an invalid quoted string. + + // Avoid allocation in trivial cases. + simple := true + for _, r := range s { + if r == '\\' || r == quote { + simple = false + break + } + } + if simple { + return s, nil + } + + buf := make([]byte, 0, 3*len(s)/2) + for len(s) > 0 { + r, n := utf8.DecodeRuneInString(s) + if r == utf8.RuneError && n == 1 { + return "", errBadUTF8 + } + s = s[n:] + if r != '\\' { + if r < utf8.RuneSelf { + buf = append(buf, byte(r)) + } else { + buf = append(buf, string(r)...) + } + continue + } + + ch, tail, err := unescape(s) + if err != nil { + return "", err + } + buf = append(buf, ch...) + s = tail + } + return string(buf), nil +} + +func unescape(s string) (ch string, tail string, err error) { + r, n := utf8.DecodeRuneInString(s) + if r == utf8.RuneError && n == 1 { + return "", "", errBadUTF8 + } + s = s[n:] + switch r { + case 'a': + return "\a", s, nil + case 'b': + return "\b", s, nil + case 'f': + return "\f", s, nil + case 'n': + return "\n", s, nil + case 'r': + return "\r", s, nil + case 't': + return "\t", s, nil + case 'v': + return "\v", s, nil + case '?': + return "?", s, nil // trigraph workaround + case '\'', '"', '\\': + return string(r), s, nil + case '0', '1', '2', '3', '4', '5', '6', '7', 'x', 'X': + if len(s) < 2 { + return "", "", fmt.Errorf(`\%c requires 2 following digits`, r) + } + base := 8 + ss := s[:2] + s = s[2:] + if r == 'x' || r == 'X' { + base = 16 + } else { + ss = string(r) + ss + } + i, err := strconv.ParseUint(ss, base, 8) + if err != nil { + return "", "", err + } + return string([]byte{byte(i)}), s, nil + case 'u', 'U': + n := 4 + if r == 'U' { + n = 8 + } + if len(s) < n { + return "", "", fmt.Errorf(`\%c requires %d digits`, r, n) + } + + bs := make([]byte, n/2) + for i := 0; i < n; i += 2 { + a, ok1 := unhex(s[i]) + b, ok2 := unhex(s[i+1]) + if !ok1 || !ok2 { + return "", "", errBadHex + } + bs[i/2] = a<<4 | b + } + s = s[n:] + return string(bs), s, nil + } + return "", "", fmt.Errorf(`unknown escape \%c`, r) +} + +// Adapted from src/pkg/strconv/quote.go. +func unhex(b byte) (v byte, ok bool) { + switch { + case '0' <= b && b <= '9': + return b - '0', true + case 'a' <= b && b <= 'f': + return b - 'a' + 10, true + case 'A' <= b && b <= 'F': + return b - 'A' + 10, true + } + return 0, false +} + +// Back off the parser by one token. Can only be done between calls to next(). +// It makes the next advance() a no-op. +func (p *textParser) back() { p.backed = true } + +// Advances the parser and returns the new current token. +func (p *textParser) next() *token { + if p.backed || p.done { + p.backed = false + return &p.cur + } + p.advance() + if p.done { + p.cur.value = "" + } else if len(p.cur.value) > 0 && p.cur.value[0] == '"' { + // Look for multiple quoted strings separated by whitespace, + // and concatenate them. + cat := p.cur + for { + p.skipWhitespace() + if p.done || p.s[0] != '"' { + break + } + p.advance() + if p.cur.err != nil { + return &p.cur + } + cat.value += " " + p.cur.value + cat.unquoted += p.cur.unquoted + } + p.done = false // parser may have seen EOF, but we want to return cat + p.cur = cat + } + return &p.cur +} + +func (p *textParser) consumeToken(s string) error { + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value != s { + p.back() + return p.errorf("expected %q, found %q", s, tok.value) + } + return nil +} + +// Return a RequiredNotSetError indicating which required field was not set. +func (p *textParser) missingRequiredFieldError(sv reflect.Value) *RequiredNotSetError { + st := sv.Type() + sprops := GetProperties(st) + for i := 0; i < st.NumField(); i++ { + if !isNil(sv.Field(i)) { + continue + } + + props := sprops.Prop[i] + if props.Required { + return &RequiredNotSetError{fmt.Sprintf("%v.%v", st, props.OrigName)} + } + } + return &RequiredNotSetError{fmt.Sprintf("%v.", st)} // should not happen +} + +// Returns the index in the struct for the named field, as well as the parsed tag properties. +func structFieldByName(sprops *StructProperties, name string) (int, *Properties, bool) { + i, ok := sprops.decoderOrigNames[name] + if ok { + return i, sprops.Prop[i], true + } + return -1, nil, false +} + +// Consume a ':' from the input stream (if the next token is a colon), +// returning an error if a colon is needed but not present. +func (p *textParser) checkForColon(props *Properties, typ reflect.Type) *ParseError { + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value != ":" { + // Colon is optional when the field is a group or message. + needColon := true + switch props.Wire { + case "group": + needColon = false + case "bytes": + // A "bytes" field is either a message, a string, or a repeated field; + // those three become *T, *string and []T respectively, so we can check for + // this field being a pointer to a non-string. + if typ.Kind() == reflect.Ptr { + // *T or *string + if typ.Elem().Kind() == reflect.String { + break + } + } else if typ.Kind() == reflect.Slice { + // []T or []*T + if typ.Elem().Kind() != reflect.Ptr { + break + } + } else if typ.Kind() == reflect.String { + // The proto3 exception is for a string field, + // which requires a colon. + break + } + needColon = false + } + if needColon { + return p.errorf("expected ':', found %q", tok.value) + } + p.back() + } + return nil +} + +func (p *textParser) readStruct(sv reflect.Value, terminator string) error { + st := sv.Type() + sprops := GetProperties(st) + reqCount := sprops.reqCount + var reqFieldErr error + fieldSet := make(map[string]bool) + // A struct is a sequence of "name: value", terminated by one of + // '>' or '}', or the end of the input. A name may also be + // "[extension]". + for { + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value == terminator { + break + } + if tok.value == "[" { + // Looks like an extension. + // + // TODO: Check whether we need to handle + // namespace rooted names (e.g. ".something.Foo"). + tok = p.next() + if tok.err != nil { + return tok.err + } + var desc *ExtensionDesc + // This could be faster, but it's functional. + // TODO: Do something smarter than a linear scan. + for _, d := range RegisteredExtensions(reflect.New(st).Interface().(Message)) { + if d.Name == tok.value { + desc = d + break + } + } + if desc == nil { + return p.errorf("unrecognized extension %q", tok.value) + } + // Check the extension terminator. + tok = p.next() + if tok.err != nil { + return tok.err + } + if tok.value != "]" { + return p.errorf("unrecognized extension terminator %q", tok.value) + } + + props := &Properties{} + props.Parse(desc.Tag) + + typ := reflect.TypeOf(desc.ExtensionType) + if err := p.checkForColon(props, typ); err != nil { + return err + } + + rep := desc.repeated() + + // Read the extension structure, and set it in + // the value we're constructing. + var ext reflect.Value + if !rep { + ext = reflect.New(typ).Elem() + } else { + ext = reflect.New(typ.Elem()).Elem() + } + if err := p.readAny(ext, props); err != nil { + if _, ok := err.(*RequiredNotSetError); !ok { + return err + } + reqFieldErr = err + } + ep := sv.Addr().Interface().(extendableProto) + if !rep { + SetExtension(ep, desc, ext.Interface()) + } else { + old, err := GetExtension(ep, desc) + var sl reflect.Value + if err == nil { + sl = reflect.ValueOf(old) // existing slice + } else { + sl = reflect.MakeSlice(typ, 0, 1) + } + sl = reflect.Append(sl, ext) + SetExtension(ep, desc, sl.Interface()) + } + if err := p.consumeOptionalSeparator(); err != nil { + return err + } + continue + } + + // This is a normal, non-extension field. + name := tok.value + var dst reflect.Value + fi, props, ok := structFieldByName(sprops, name) + if ok { + dst = sv.Field(fi) + } else if oop, ok := sprops.OneofTypes[name]; ok { + // It is a oneof. + props = oop.Prop + nv := reflect.New(oop.Type.Elem()) + dst = nv.Elem().Field(0) + sv.Field(oop.Field).Set(nv) + } + if !dst.IsValid() { + return p.errorf("unknown field name %q in %v", name, st) + } + + if dst.Kind() == reflect.Map { + // Consume any colon. + if err := p.checkForColon(props, dst.Type()); err != nil { + return err + } + + // Construct the map if it doesn't already exist. + if dst.IsNil() { + dst.Set(reflect.MakeMap(dst.Type())) + } + key := reflect.New(dst.Type().Key()).Elem() + val := reflect.New(dst.Type().Elem()).Elem() + + // The map entry should be this sequence of tokens: + // < key : KEY value : VALUE > + // Technically the "key" and "value" could come in any order, + // but in practice they won't. + + tok := p.next() + var terminator string + switch tok.value { + case "<": + terminator = ">" + case "{": + terminator = "}" + default: + return p.errorf("expected '{' or '<', found %q", tok.value) + } + if err := p.consumeToken("key"); err != nil { + return err + } + if err := p.consumeToken(":"); err != nil { + return err + } + if err := p.readAny(key, props.mkeyprop); err != nil { + return err + } + if err := p.consumeOptionalSeparator(); err != nil { + return err + } + if err := p.consumeToken("value"); err != nil { + return err + } + if err := p.checkForColon(props.mvalprop, dst.Type().Elem()); err != nil { + return err + } + if err := p.readAny(val, props.mvalprop); err != nil { + return err + } + if err := p.consumeOptionalSeparator(); err != nil { + return err + } + if err := p.consumeToken(terminator); err != nil { + return err + } + + dst.SetMapIndex(key, val) + continue + } + + // Check that it's not already set if it's not a repeated field. + if !props.Repeated && fieldSet[name] { + return p.errorf("non-repeated field %q was repeated", name) + } + + if err := p.checkForColon(props, dst.Type()); err != nil { + return err + } + + // Parse into the field. + fieldSet[name] = true + if err := p.readAny(dst, props); err != nil { + if _, ok := err.(*RequiredNotSetError); !ok { + return err + } + reqFieldErr = err + } else if props.Required { + reqCount-- + } + + if err := p.consumeOptionalSeparator(); err != nil { + return err + } + + } + + if reqCount > 0 { + return p.missingRequiredFieldError(sv) + } + return reqFieldErr +} + +// consumeOptionalSeparator consumes an optional semicolon or comma. +// It is used in readStruct to provide backward compatibility. +func (p *textParser) consumeOptionalSeparator() error { + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value != ";" && tok.value != "," { + p.back() + } + return nil +} + +func (p *textParser) readAny(v reflect.Value, props *Properties) error { + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value == "" { + return p.errorf("unexpected EOF") + } + + switch fv := v; fv.Kind() { + case reflect.Slice: + at := v.Type() + if at.Elem().Kind() == reflect.Uint8 { + // Special case for []byte + if tok.value[0] != '"' && tok.value[0] != '\'' { + // Deliberately written out here, as the error after + // this switch statement would write "invalid []byte: ...", + // which is not as user-friendly. + return p.errorf("invalid string: %v", tok.value) + } + bytes := []byte(tok.unquoted) + fv.Set(reflect.ValueOf(bytes)) + return nil + } + // Repeated field. + if tok.value == "[" { + // Repeated field with list notation, like [1,2,3]. + for { + fv.Set(reflect.Append(fv, reflect.New(at.Elem()).Elem())) + err := p.readAny(fv.Index(fv.Len()-1), props) + if err != nil { + return err + } + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value == "]" { + break + } + if tok.value != "," { + return p.errorf("Expected ']' or ',' found %q", tok.value) + } + } + return nil + } + // One value of the repeated field. + p.back() + fv.Set(reflect.Append(fv, reflect.New(at.Elem()).Elem())) + return p.readAny(fv.Index(fv.Len()-1), props) + case reflect.Bool: + // Either "true", "false", 1 or 0. + switch tok.value { + case "true", "1": + fv.SetBool(true) + return nil + case "false", "0": + fv.SetBool(false) + return nil + } + case reflect.Float32, reflect.Float64: + v := tok.value + // Ignore 'f' for compatibility with output generated by C++, but don't + // remove 'f' when the value is "-inf" or "inf". + if strings.HasSuffix(v, "f") && tok.value != "-inf" && tok.value != "inf" { + v = v[:len(v)-1] + } + if f, err := strconv.ParseFloat(v, fv.Type().Bits()); err == nil { + fv.SetFloat(f) + return nil + } + case reflect.Int32: + if x, err := strconv.ParseInt(tok.value, 0, 32); err == nil { + fv.SetInt(x) + return nil + } + + if len(props.Enum) == 0 { + break + } + m, ok := enumValueMaps[props.Enum] + if !ok { + break + } + x, ok := m[tok.value] + if !ok { + break + } + fv.SetInt(int64(x)) + return nil + case reflect.Int64: + if x, err := strconv.ParseInt(tok.value, 0, 64); err == nil { + fv.SetInt(x) + return nil + } + + case reflect.Ptr: + // A basic field (indirected through pointer), or a repeated message/group + p.back() + fv.Set(reflect.New(fv.Type().Elem())) + return p.readAny(fv.Elem(), props) + case reflect.String: + if tok.value[0] == '"' || tok.value[0] == '\'' { + fv.SetString(tok.unquoted) + return nil + } + case reflect.Struct: + var terminator string + switch tok.value { + case "{": + terminator = "}" + case "<": + terminator = ">" + default: + return p.errorf("expected '{' or '<', found %q", tok.value) + } + // TODO: Handle nested messages which implement encoding.TextUnmarshaler. + return p.readStruct(fv, terminator) + case reflect.Uint32: + if x, err := strconv.ParseUint(tok.value, 0, 32); err == nil { + fv.SetUint(uint64(x)) + return nil + } + case reflect.Uint64: + if x, err := strconv.ParseUint(tok.value, 0, 64); err == nil { + fv.SetUint(x) + return nil + } + } + return p.errorf("invalid %v: %v", v.Type(), tok.value) +} + +// UnmarshalText reads a protocol buffer in Text format. UnmarshalText resets pb +// before starting to unmarshal, so any existing data in pb is always removed. +// If a required field is not set and no other error occurs, +// UnmarshalText returns *RequiredNotSetError. +func UnmarshalText(s string, pb Message) error { + if um, ok := pb.(encoding.TextUnmarshaler); ok { + err := um.UnmarshalText([]byte(s)) + return err + } + pb.Reset() + v := reflect.ValueOf(pb) + if pe := newTextParser(s).readStruct(v.Elem(), ""); pe != nil { + return pe + } + return nil +} diff --git a/vendor/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.pb.go b/vendor/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.pb.go new file mode 100644 index 0000000000..6a3be28eb6 --- /dev/null +++ b/vendor/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.pb.go @@ -0,0 +1,1812 @@ +// Code generated by protoc-gen-go. +// source: google/protobuf/descriptor.proto +// DO NOT EDIT! + +/* +Package google_protobuf is a generated protocol buffer package. + +It is generated from these files: + google/protobuf/descriptor.proto + +It has these top-level messages: + FileDescriptorSet + FileDescriptorProto + DescriptorProto + FieldDescriptorProto + OneofDescriptorProto + EnumDescriptorProto + EnumValueDescriptorProto + ServiceDescriptorProto + MethodDescriptorProto + FileOptions + MessageOptions + FieldOptions + EnumOptions + EnumValueOptions + ServiceOptions + MethodOptions + UninterpretedOption + SourceCodeInfo +*/ +package descriptor + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +const _ = proto.ProtoPackageIsVersion1 + +type FieldDescriptorProto_Type int32 + +const ( + // 0 is reserved for errors. + // Order is weird for historical reasons. + FieldDescriptorProto_TYPE_DOUBLE FieldDescriptorProto_Type = 1 + FieldDescriptorProto_TYPE_FLOAT FieldDescriptorProto_Type = 2 + // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + // negative values are likely. + FieldDescriptorProto_TYPE_INT64 FieldDescriptorProto_Type = 3 + FieldDescriptorProto_TYPE_UINT64 FieldDescriptorProto_Type = 4 + // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + // negative values are likely. + FieldDescriptorProto_TYPE_INT32 FieldDescriptorProto_Type = 5 + FieldDescriptorProto_TYPE_FIXED64 FieldDescriptorProto_Type = 6 + FieldDescriptorProto_TYPE_FIXED32 FieldDescriptorProto_Type = 7 + FieldDescriptorProto_TYPE_BOOL FieldDescriptorProto_Type = 8 + FieldDescriptorProto_TYPE_STRING FieldDescriptorProto_Type = 9 + FieldDescriptorProto_TYPE_GROUP FieldDescriptorProto_Type = 10 + FieldDescriptorProto_TYPE_MESSAGE FieldDescriptorProto_Type = 11 + // New in version 2. + FieldDescriptorProto_TYPE_BYTES FieldDescriptorProto_Type = 12 + FieldDescriptorProto_TYPE_UINT32 FieldDescriptorProto_Type = 13 + FieldDescriptorProto_TYPE_ENUM FieldDescriptorProto_Type = 14 + FieldDescriptorProto_TYPE_SFIXED32 FieldDescriptorProto_Type = 15 + FieldDescriptorProto_TYPE_SFIXED64 FieldDescriptorProto_Type = 16 + FieldDescriptorProto_TYPE_SINT32 FieldDescriptorProto_Type = 17 + FieldDescriptorProto_TYPE_SINT64 FieldDescriptorProto_Type = 18 +) + +var FieldDescriptorProto_Type_name = map[int32]string{ + 1: "TYPE_DOUBLE", + 2: "TYPE_FLOAT", + 3: "TYPE_INT64", + 4: "TYPE_UINT64", + 5: "TYPE_INT32", + 6: "TYPE_FIXED64", + 7: "TYPE_FIXED32", + 8: "TYPE_BOOL", + 9: "TYPE_STRING", + 10: "TYPE_GROUP", + 11: "TYPE_MESSAGE", + 12: "TYPE_BYTES", + 13: "TYPE_UINT32", + 14: "TYPE_ENUM", + 15: "TYPE_SFIXED32", + 16: "TYPE_SFIXED64", + 17: "TYPE_SINT32", + 18: "TYPE_SINT64", +} +var FieldDescriptorProto_Type_value = map[string]int32{ + "TYPE_DOUBLE": 1, + "TYPE_FLOAT": 2, + "TYPE_INT64": 3, + "TYPE_UINT64": 4, + "TYPE_INT32": 5, + "TYPE_FIXED64": 6, + "TYPE_FIXED32": 7, + "TYPE_BOOL": 8, + "TYPE_STRING": 9, + "TYPE_GROUP": 10, + "TYPE_MESSAGE": 11, + "TYPE_BYTES": 12, + "TYPE_UINT32": 13, + "TYPE_ENUM": 14, + "TYPE_SFIXED32": 15, + "TYPE_SFIXED64": 16, + "TYPE_SINT32": 17, + "TYPE_SINT64": 18, +} + +func (x FieldDescriptorProto_Type) Enum() *FieldDescriptorProto_Type { + p := new(FieldDescriptorProto_Type) + *p = x + return p +} +func (x FieldDescriptorProto_Type) String() string { + return proto.EnumName(FieldDescriptorProto_Type_name, int32(x)) +} +func (x *FieldDescriptorProto_Type) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(FieldDescriptorProto_Type_value, data, "FieldDescriptorProto_Type") + if err != nil { + return err + } + *x = FieldDescriptorProto_Type(value) + return nil +} +func (FieldDescriptorProto_Type) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{3, 0} } + +type FieldDescriptorProto_Label int32 + +const ( + // 0 is reserved for errors + FieldDescriptorProto_LABEL_OPTIONAL FieldDescriptorProto_Label = 1 + FieldDescriptorProto_LABEL_REQUIRED FieldDescriptorProto_Label = 2 + FieldDescriptorProto_LABEL_REPEATED FieldDescriptorProto_Label = 3 +) + +var FieldDescriptorProto_Label_name = map[int32]string{ + 1: "LABEL_OPTIONAL", + 2: "LABEL_REQUIRED", + 3: "LABEL_REPEATED", +} +var FieldDescriptorProto_Label_value = map[string]int32{ + "LABEL_OPTIONAL": 1, + "LABEL_REQUIRED": 2, + "LABEL_REPEATED": 3, +} + +func (x FieldDescriptorProto_Label) Enum() *FieldDescriptorProto_Label { + p := new(FieldDescriptorProto_Label) + *p = x + return p +} +func (x FieldDescriptorProto_Label) String() string { + return proto.EnumName(FieldDescriptorProto_Label_name, int32(x)) +} +func (x *FieldDescriptorProto_Label) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(FieldDescriptorProto_Label_value, data, "FieldDescriptorProto_Label") + if err != nil { + return err + } + *x = FieldDescriptorProto_Label(value) + return nil +} +func (FieldDescriptorProto_Label) EnumDescriptor() ([]byte, []int) { + return fileDescriptor0, []int{3, 1} +} + +// Generated classes can be optimized for speed or code size. +type FileOptions_OptimizeMode int32 + +const ( + FileOptions_SPEED FileOptions_OptimizeMode = 1 + // etc. + FileOptions_CODE_SIZE FileOptions_OptimizeMode = 2 + FileOptions_LITE_RUNTIME FileOptions_OptimizeMode = 3 +) + +var FileOptions_OptimizeMode_name = map[int32]string{ + 1: "SPEED", + 2: "CODE_SIZE", + 3: "LITE_RUNTIME", +} +var FileOptions_OptimizeMode_value = map[string]int32{ + "SPEED": 1, + "CODE_SIZE": 2, + "LITE_RUNTIME": 3, +} + +func (x FileOptions_OptimizeMode) Enum() *FileOptions_OptimizeMode { + p := new(FileOptions_OptimizeMode) + *p = x + return p +} +func (x FileOptions_OptimizeMode) String() string { + return proto.EnumName(FileOptions_OptimizeMode_name, int32(x)) +} +func (x *FileOptions_OptimizeMode) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(FileOptions_OptimizeMode_value, data, "FileOptions_OptimizeMode") + if err != nil { + return err + } + *x = FileOptions_OptimizeMode(value) + return nil +} +func (FileOptions_OptimizeMode) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{9, 0} } + +type FieldOptions_CType int32 + +const ( + // Default mode. + FieldOptions_STRING FieldOptions_CType = 0 + FieldOptions_CORD FieldOptions_CType = 1 + FieldOptions_STRING_PIECE FieldOptions_CType = 2 +) + +var FieldOptions_CType_name = map[int32]string{ + 0: "STRING", + 1: "CORD", + 2: "STRING_PIECE", +} +var FieldOptions_CType_value = map[string]int32{ + "STRING": 0, + "CORD": 1, + "STRING_PIECE": 2, +} + +func (x FieldOptions_CType) Enum() *FieldOptions_CType { + p := new(FieldOptions_CType) + *p = x + return p +} +func (x FieldOptions_CType) String() string { + return proto.EnumName(FieldOptions_CType_name, int32(x)) +} +func (x *FieldOptions_CType) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(FieldOptions_CType_value, data, "FieldOptions_CType") + if err != nil { + return err + } + *x = FieldOptions_CType(value) + return nil +} +func (FieldOptions_CType) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{11, 0} } + +// The protocol compiler can output a FileDescriptorSet containing the .proto +// files it parses. +type FileDescriptorSet struct { + File []*FileDescriptorProto `protobuf:"bytes,1,rep,name=file" json:"file,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *FileDescriptorSet) Reset() { *m = FileDescriptorSet{} } +func (m *FileDescriptorSet) String() string { return proto.CompactTextString(m) } +func (*FileDescriptorSet) ProtoMessage() {} +func (*FileDescriptorSet) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } + +func (m *FileDescriptorSet) GetFile() []*FileDescriptorProto { + if m != nil { + return m.File + } + return nil +} + +// Describes a complete .proto file. +type FileDescriptorProto struct { + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Package *string `protobuf:"bytes,2,opt,name=package" json:"package,omitempty"` + // Names of files imported by this file. + Dependency []string `protobuf:"bytes,3,rep,name=dependency" json:"dependency,omitempty"` + // Indexes of the public imported files in the dependency list above. + PublicDependency []int32 `protobuf:"varint,10,rep,name=public_dependency" json:"public_dependency,omitempty"` + // Indexes of the weak imported files in the dependency list. + // For Google-internal migration only. Do not use. + WeakDependency []int32 `protobuf:"varint,11,rep,name=weak_dependency" json:"weak_dependency,omitempty"` + // All top-level definitions in this file. + MessageType []*DescriptorProto `protobuf:"bytes,4,rep,name=message_type" json:"message_type,omitempty"` + EnumType []*EnumDescriptorProto `protobuf:"bytes,5,rep,name=enum_type" json:"enum_type,omitempty"` + Service []*ServiceDescriptorProto `protobuf:"bytes,6,rep,name=service" json:"service,omitempty"` + Extension []*FieldDescriptorProto `protobuf:"bytes,7,rep,name=extension" json:"extension,omitempty"` + Options *FileOptions `protobuf:"bytes,8,opt,name=options" json:"options,omitempty"` + // This field contains optional information about the original source code. + // You may safely remove this entire field without harming runtime + // functionality of the descriptors -- the information is needed only by + // development tools. + SourceCodeInfo *SourceCodeInfo `protobuf:"bytes,9,opt,name=source_code_info" json:"source_code_info,omitempty"` + // The syntax of the proto file. + // The supported values are "proto2" and "proto3". + Syntax *string `protobuf:"bytes,12,opt,name=syntax" json:"syntax,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *FileDescriptorProto) Reset() { *m = FileDescriptorProto{} } +func (m *FileDescriptorProto) String() string { return proto.CompactTextString(m) } +func (*FileDescriptorProto) ProtoMessage() {} +func (*FileDescriptorProto) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } + +func (m *FileDescriptorProto) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *FileDescriptorProto) GetPackage() string { + if m != nil && m.Package != nil { + return *m.Package + } + return "" +} + +func (m *FileDescriptorProto) GetDependency() []string { + if m != nil { + return m.Dependency + } + return nil +} + +func (m *FileDescriptorProto) GetPublicDependency() []int32 { + if m != nil { + return m.PublicDependency + } + return nil +} + +func (m *FileDescriptorProto) GetWeakDependency() []int32 { + if m != nil { + return m.WeakDependency + } + return nil +} + +func (m *FileDescriptorProto) GetMessageType() []*DescriptorProto { + if m != nil { + return m.MessageType + } + return nil +} + +func (m *FileDescriptorProto) GetEnumType() []*EnumDescriptorProto { + if m != nil { + return m.EnumType + } + return nil +} + +func (m *FileDescriptorProto) GetService() []*ServiceDescriptorProto { + if m != nil { + return m.Service + } + return nil +} + +func (m *FileDescriptorProto) GetExtension() []*FieldDescriptorProto { + if m != nil { + return m.Extension + } + return nil +} + +func (m *FileDescriptorProto) GetOptions() *FileOptions { + if m != nil { + return m.Options + } + return nil +} + +func (m *FileDescriptorProto) GetSourceCodeInfo() *SourceCodeInfo { + if m != nil { + return m.SourceCodeInfo + } + return nil +} + +func (m *FileDescriptorProto) GetSyntax() string { + if m != nil && m.Syntax != nil { + return *m.Syntax + } + return "" +} + +// Describes a message type. +type DescriptorProto struct { + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Field []*FieldDescriptorProto `protobuf:"bytes,2,rep,name=field" json:"field,omitempty"` + Extension []*FieldDescriptorProto `protobuf:"bytes,6,rep,name=extension" json:"extension,omitempty"` + NestedType []*DescriptorProto `protobuf:"bytes,3,rep,name=nested_type" json:"nested_type,omitempty"` + EnumType []*EnumDescriptorProto `protobuf:"bytes,4,rep,name=enum_type" json:"enum_type,omitempty"` + ExtensionRange []*DescriptorProto_ExtensionRange `protobuf:"bytes,5,rep,name=extension_range" json:"extension_range,omitempty"` + OneofDecl []*OneofDescriptorProto `protobuf:"bytes,8,rep,name=oneof_decl" json:"oneof_decl,omitempty"` + Options *MessageOptions `protobuf:"bytes,7,opt,name=options" json:"options,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *DescriptorProto) Reset() { *m = DescriptorProto{} } +func (m *DescriptorProto) String() string { return proto.CompactTextString(m) } +func (*DescriptorProto) ProtoMessage() {} +func (*DescriptorProto) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } + +func (m *DescriptorProto) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *DescriptorProto) GetField() []*FieldDescriptorProto { + if m != nil { + return m.Field + } + return nil +} + +func (m *DescriptorProto) GetExtension() []*FieldDescriptorProto { + if m != nil { + return m.Extension + } + return nil +} + +func (m *DescriptorProto) GetNestedType() []*DescriptorProto { + if m != nil { + return m.NestedType + } + return nil +} + +func (m *DescriptorProto) GetEnumType() []*EnumDescriptorProto { + if m != nil { + return m.EnumType + } + return nil +} + +func (m *DescriptorProto) GetExtensionRange() []*DescriptorProto_ExtensionRange { + if m != nil { + return m.ExtensionRange + } + return nil +} + +func (m *DescriptorProto) GetOneofDecl() []*OneofDescriptorProto { + if m != nil { + return m.OneofDecl + } + return nil +} + +func (m *DescriptorProto) GetOptions() *MessageOptions { + if m != nil { + return m.Options + } + return nil +} + +type DescriptorProto_ExtensionRange struct { + Start *int32 `protobuf:"varint,1,opt,name=start" json:"start,omitempty"` + End *int32 `protobuf:"varint,2,opt,name=end" json:"end,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *DescriptorProto_ExtensionRange) Reset() { *m = DescriptorProto_ExtensionRange{} } +func (m *DescriptorProto_ExtensionRange) String() string { return proto.CompactTextString(m) } +func (*DescriptorProto_ExtensionRange) ProtoMessage() {} +func (*DescriptorProto_ExtensionRange) Descriptor() ([]byte, []int) { + return fileDescriptor0, []int{2, 0} +} + +func (m *DescriptorProto_ExtensionRange) GetStart() int32 { + if m != nil && m.Start != nil { + return *m.Start + } + return 0 +} + +func (m *DescriptorProto_ExtensionRange) GetEnd() int32 { + if m != nil && m.End != nil { + return *m.End + } + return 0 +} + +// Describes a field within a message. +type FieldDescriptorProto struct { + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Number *int32 `protobuf:"varint,3,opt,name=number" json:"number,omitempty"` + Label *FieldDescriptorProto_Label `protobuf:"varint,4,opt,name=label,enum=google.protobuf.FieldDescriptorProto_Label" json:"label,omitempty"` + // If type_name is set, this need not be set. If both this and type_name + // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + Type *FieldDescriptorProto_Type `protobuf:"varint,5,opt,name=type,enum=google.protobuf.FieldDescriptorProto_Type" json:"type,omitempty"` + // For message and enum types, this is the name of the type. If the name + // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + // rules are used to find the type (i.e. first the nested types within this + // message are searched, then within the parent, on up to the root + // namespace). + TypeName *string `protobuf:"bytes,6,opt,name=type_name" json:"type_name,omitempty"` + // For extensions, this is the name of the type being extended. It is + // resolved in the same manner as type_name. + Extendee *string `protobuf:"bytes,2,opt,name=extendee" json:"extendee,omitempty"` + // For numeric types, contains the original text representation of the value. + // For booleans, "true" or "false". + // For strings, contains the default text contents (not escaped in any way). + // For bytes, contains the C escaped value. All bytes >= 128 are escaped. + // TODO(kenton): Base-64 encode? + DefaultValue *string `protobuf:"bytes,7,opt,name=default_value" json:"default_value,omitempty"` + // If set, gives the index of a oneof in the containing type's oneof_decl + // list. This field is a member of that oneof. Extensions of a oneof should + // not set this since the oneof to which they belong will be inferred based + // on the extension range containing the extension's field number. + OneofIndex *int32 `protobuf:"varint,9,opt,name=oneof_index" json:"oneof_index,omitempty"` + // JSON name of this field. The value is set by protocol compiler. If the + // user has set a "json_name" option on this field, that option's value + // will be used. Otherwise, it's deduced from the field's name by converting + // it to camelCase. + JsonName *string `protobuf:"bytes,10,opt,name=json_name" json:"json_name,omitempty"` + Options *FieldOptions `protobuf:"bytes,8,opt,name=options" json:"options,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *FieldDescriptorProto) Reset() { *m = FieldDescriptorProto{} } +func (m *FieldDescriptorProto) String() string { return proto.CompactTextString(m) } +func (*FieldDescriptorProto) ProtoMessage() {} +func (*FieldDescriptorProto) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } + +func (m *FieldDescriptorProto) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *FieldDescriptorProto) GetNumber() int32 { + if m != nil && m.Number != nil { + return *m.Number + } + return 0 +} + +func (m *FieldDescriptorProto) GetLabel() FieldDescriptorProto_Label { + if m != nil && m.Label != nil { + return *m.Label + } + return FieldDescriptorProto_LABEL_OPTIONAL +} + +func (m *FieldDescriptorProto) GetType() FieldDescriptorProto_Type { + if m != nil && m.Type != nil { + return *m.Type + } + return FieldDescriptorProto_TYPE_DOUBLE +} + +func (m *FieldDescriptorProto) GetTypeName() string { + if m != nil && m.TypeName != nil { + return *m.TypeName + } + return "" +} + +func (m *FieldDescriptorProto) GetExtendee() string { + if m != nil && m.Extendee != nil { + return *m.Extendee + } + return "" +} + +func (m *FieldDescriptorProto) GetDefaultValue() string { + if m != nil && m.DefaultValue != nil { + return *m.DefaultValue + } + return "" +} + +func (m *FieldDescriptorProto) GetOneofIndex() int32 { + if m != nil && m.OneofIndex != nil { + return *m.OneofIndex + } + return 0 +} + +func (m *FieldDescriptorProto) GetJsonName() string { + if m != nil && m.JsonName != nil { + return *m.JsonName + } + return "" +} + +func (m *FieldDescriptorProto) GetOptions() *FieldOptions { + if m != nil { + return m.Options + } + return nil +} + +// Describes a oneof. +type OneofDescriptorProto struct { + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *OneofDescriptorProto) Reset() { *m = OneofDescriptorProto{} } +func (m *OneofDescriptorProto) String() string { return proto.CompactTextString(m) } +func (*OneofDescriptorProto) ProtoMessage() {} +func (*OneofDescriptorProto) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } + +func (m *OneofDescriptorProto) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +// Describes an enum type. +type EnumDescriptorProto struct { + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Value []*EnumValueDescriptorProto `protobuf:"bytes,2,rep,name=value" json:"value,omitempty"` + Options *EnumOptions `protobuf:"bytes,3,opt,name=options" json:"options,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *EnumDescriptorProto) Reset() { *m = EnumDescriptorProto{} } +func (m *EnumDescriptorProto) String() string { return proto.CompactTextString(m) } +func (*EnumDescriptorProto) ProtoMessage() {} +func (*EnumDescriptorProto) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} } + +func (m *EnumDescriptorProto) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *EnumDescriptorProto) GetValue() []*EnumValueDescriptorProto { + if m != nil { + return m.Value + } + return nil +} + +func (m *EnumDescriptorProto) GetOptions() *EnumOptions { + if m != nil { + return m.Options + } + return nil +} + +// Describes a value within an enum. +type EnumValueDescriptorProto struct { + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Number *int32 `protobuf:"varint,2,opt,name=number" json:"number,omitempty"` + Options *EnumValueOptions `protobuf:"bytes,3,opt,name=options" json:"options,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *EnumValueDescriptorProto) Reset() { *m = EnumValueDescriptorProto{} } +func (m *EnumValueDescriptorProto) String() string { return proto.CompactTextString(m) } +func (*EnumValueDescriptorProto) ProtoMessage() {} +func (*EnumValueDescriptorProto) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} } + +func (m *EnumValueDescriptorProto) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *EnumValueDescriptorProto) GetNumber() int32 { + if m != nil && m.Number != nil { + return *m.Number + } + return 0 +} + +func (m *EnumValueDescriptorProto) GetOptions() *EnumValueOptions { + if m != nil { + return m.Options + } + return nil +} + +// Describes a service. +type ServiceDescriptorProto struct { + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Method []*MethodDescriptorProto `protobuf:"bytes,2,rep,name=method" json:"method,omitempty"` + Options *ServiceOptions `protobuf:"bytes,3,opt,name=options" json:"options,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *ServiceDescriptorProto) Reset() { *m = ServiceDescriptorProto{} } +func (m *ServiceDescriptorProto) String() string { return proto.CompactTextString(m) } +func (*ServiceDescriptorProto) ProtoMessage() {} +func (*ServiceDescriptorProto) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} } + +func (m *ServiceDescriptorProto) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *ServiceDescriptorProto) GetMethod() []*MethodDescriptorProto { + if m != nil { + return m.Method + } + return nil +} + +func (m *ServiceDescriptorProto) GetOptions() *ServiceOptions { + if m != nil { + return m.Options + } + return nil +} + +// Describes a method of a service. +type MethodDescriptorProto struct { + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + // Input and output type names. These are resolved in the same way as + // FieldDescriptorProto.type_name, but must refer to a message type. + InputType *string `protobuf:"bytes,2,opt,name=input_type" json:"input_type,omitempty"` + OutputType *string `protobuf:"bytes,3,opt,name=output_type" json:"output_type,omitempty"` + Options *MethodOptions `protobuf:"bytes,4,opt,name=options" json:"options,omitempty"` + // Identifies if client streams multiple client messages + ClientStreaming *bool `protobuf:"varint,5,opt,name=client_streaming,def=0" json:"client_streaming,omitempty"` + // Identifies if server streams multiple server messages + ServerStreaming *bool `protobuf:"varint,6,opt,name=server_streaming,def=0" json:"server_streaming,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *MethodDescriptorProto) Reset() { *m = MethodDescriptorProto{} } +func (m *MethodDescriptorProto) String() string { return proto.CompactTextString(m) } +func (*MethodDescriptorProto) ProtoMessage() {} +func (*MethodDescriptorProto) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} } + +const Default_MethodDescriptorProto_ClientStreaming bool = false +const Default_MethodDescriptorProto_ServerStreaming bool = false + +func (m *MethodDescriptorProto) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *MethodDescriptorProto) GetInputType() string { + if m != nil && m.InputType != nil { + return *m.InputType + } + return "" +} + +func (m *MethodDescriptorProto) GetOutputType() string { + if m != nil && m.OutputType != nil { + return *m.OutputType + } + return "" +} + +func (m *MethodDescriptorProto) GetOptions() *MethodOptions { + if m != nil { + return m.Options + } + return nil +} + +func (m *MethodDescriptorProto) GetClientStreaming() bool { + if m != nil && m.ClientStreaming != nil { + return *m.ClientStreaming + } + return Default_MethodDescriptorProto_ClientStreaming +} + +func (m *MethodDescriptorProto) GetServerStreaming() bool { + if m != nil && m.ServerStreaming != nil { + return *m.ServerStreaming + } + return Default_MethodDescriptorProto_ServerStreaming +} + +type FileOptions struct { + // Sets the Java package where classes generated from this .proto will be + // placed. By default, the proto package is used, but this is often + // inappropriate because proto packages do not normally start with backwards + // domain names. + JavaPackage *string `protobuf:"bytes,1,opt,name=java_package" json:"java_package,omitempty"` + // If set, all the classes from the .proto file are wrapped in a single + // outer class with the given name. This applies to both Proto1 + // (equivalent to the old "--one_java_file" option) and Proto2 (where + // a .proto always translates to a single class, but you may want to + // explicitly choose the class name). + JavaOuterClassname *string `protobuf:"bytes,8,opt,name=java_outer_classname" json:"java_outer_classname,omitempty"` + // If set true, then the Java code generator will generate a separate .java + // file for each top-level message, enum, and service defined in the .proto + // file. Thus, these types will *not* be nested inside the outer class + // named by java_outer_classname. However, the outer class will still be + // generated to contain the file's getDescriptor() method as well as any + // top-level extensions defined in the file. + JavaMultipleFiles *bool `protobuf:"varint,10,opt,name=java_multiple_files,def=0" json:"java_multiple_files,omitempty"` + // If set true, then the Java code generator will generate equals() and + // hashCode() methods for all messages defined in the .proto file. + // - In the full runtime, this is purely a speed optimization, as the + // AbstractMessage base class includes reflection-based implementations of + // these methods. + // - In the lite runtime, setting this option changes the semantics of + // equals() and hashCode() to more closely match those of the full runtime; + // the generated methods compute their results based on field values rather + // than object identity. (Implementations should not assume that hashcodes + // will be consistent across runtimes or versions of the protocol compiler.) + JavaGenerateEqualsAndHash *bool `protobuf:"varint,20,opt,name=java_generate_equals_and_hash,def=0" json:"java_generate_equals_and_hash,omitempty"` + // If set true, then the Java2 code generator will generate code that + // throws an exception whenever an attempt is made to assign a non-UTF-8 + // byte sequence to a string field. + // Message reflection will do the same. + // However, an extension field still accepts non-UTF-8 byte sequences. + // This option has no effect on when used with the lite runtime. + JavaStringCheckUtf8 *bool `protobuf:"varint,27,opt,name=java_string_check_utf8,def=0" json:"java_string_check_utf8,omitempty"` + OptimizeFor *FileOptions_OptimizeMode `protobuf:"varint,9,opt,name=optimize_for,enum=google.protobuf.FileOptions_OptimizeMode,def=1" json:"optimize_for,omitempty"` + // Sets the Go package where structs generated from this .proto will be + // placed. If omitted, the Go package will be derived from the following: + // - The basename of the package import path, if provided. + // - Otherwise, the package statement in the .proto file, if present. + // - Otherwise, the basename of the .proto file, without extension. + GoPackage *string `protobuf:"bytes,11,opt,name=go_package" json:"go_package,omitempty"` + // Should generic services be generated in each language? "Generic" services + // are not specific to any particular RPC system. They are generated by the + // main code generators in each language (without additional plugins). + // Generic services were the only kind of service generation supported by + // early versions of google.protobuf. + // + // Generic services are now considered deprecated in favor of using plugins + // that generate code specific to your particular RPC system. Therefore, + // these default to false. Old code which depends on generic services should + // explicitly set them to true. + CcGenericServices *bool `protobuf:"varint,16,opt,name=cc_generic_services,def=0" json:"cc_generic_services,omitempty"` + JavaGenericServices *bool `protobuf:"varint,17,opt,name=java_generic_services,def=0" json:"java_generic_services,omitempty"` + PyGenericServices *bool `protobuf:"varint,18,opt,name=py_generic_services,def=0" json:"py_generic_services,omitempty"` + // Is this file deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for everything in the file, or it will be completely ignored; in the very + // least, this is a formalization for deprecating files. + Deprecated *bool `protobuf:"varint,23,opt,name=deprecated,def=0" json:"deprecated,omitempty"` + // Enables the use of arenas for the proto messages in this file. This applies + // only to generated classes for C++. + CcEnableArenas *bool `protobuf:"varint,31,opt,name=cc_enable_arenas,def=0" json:"cc_enable_arenas,omitempty"` + // The parser stores options it doesn't recognize here. See above. + UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option" json:"uninterpreted_option,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *FileOptions) Reset() { *m = FileOptions{} } +func (m *FileOptions) String() string { return proto.CompactTextString(m) } +func (*FileOptions) ProtoMessage() {} +func (*FileOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} } + +var extRange_FileOptions = []proto.ExtensionRange{ + {1000, 536870911}, +} + +func (*FileOptions) ExtensionRangeArray() []proto.ExtensionRange { + return extRange_FileOptions +} +func (m *FileOptions) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} + +const Default_FileOptions_JavaMultipleFiles bool = false +const Default_FileOptions_JavaGenerateEqualsAndHash bool = false +const Default_FileOptions_JavaStringCheckUtf8 bool = false +const Default_FileOptions_OptimizeFor FileOptions_OptimizeMode = FileOptions_SPEED +const Default_FileOptions_CcGenericServices bool = false +const Default_FileOptions_JavaGenericServices bool = false +const Default_FileOptions_PyGenericServices bool = false +const Default_FileOptions_Deprecated bool = false +const Default_FileOptions_CcEnableArenas bool = false + +func (m *FileOptions) GetJavaPackage() string { + if m != nil && m.JavaPackage != nil { + return *m.JavaPackage + } + return "" +} + +func (m *FileOptions) GetJavaOuterClassname() string { + if m != nil && m.JavaOuterClassname != nil { + return *m.JavaOuterClassname + } + return "" +} + +func (m *FileOptions) GetJavaMultipleFiles() bool { + if m != nil && m.JavaMultipleFiles != nil { + return *m.JavaMultipleFiles + } + return Default_FileOptions_JavaMultipleFiles +} + +func (m *FileOptions) GetJavaGenerateEqualsAndHash() bool { + if m != nil && m.JavaGenerateEqualsAndHash != nil { + return *m.JavaGenerateEqualsAndHash + } + return Default_FileOptions_JavaGenerateEqualsAndHash +} + +func (m *FileOptions) GetJavaStringCheckUtf8() bool { + if m != nil && m.JavaStringCheckUtf8 != nil { + return *m.JavaStringCheckUtf8 + } + return Default_FileOptions_JavaStringCheckUtf8 +} + +func (m *FileOptions) GetOptimizeFor() FileOptions_OptimizeMode { + if m != nil && m.OptimizeFor != nil { + return *m.OptimizeFor + } + return Default_FileOptions_OptimizeFor +} + +func (m *FileOptions) GetGoPackage() string { + if m != nil && m.GoPackage != nil { + return *m.GoPackage + } + return "" +} + +func (m *FileOptions) GetCcGenericServices() bool { + if m != nil && m.CcGenericServices != nil { + return *m.CcGenericServices + } + return Default_FileOptions_CcGenericServices +} + +func (m *FileOptions) GetJavaGenericServices() bool { + if m != nil && m.JavaGenericServices != nil { + return *m.JavaGenericServices + } + return Default_FileOptions_JavaGenericServices +} + +func (m *FileOptions) GetPyGenericServices() bool { + if m != nil && m.PyGenericServices != nil { + return *m.PyGenericServices + } + return Default_FileOptions_PyGenericServices +} + +func (m *FileOptions) GetDeprecated() bool { + if m != nil && m.Deprecated != nil { + return *m.Deprecated + } + return Default_FileOptions_Deprecated +} + +func (m *FileOptions) GetCcEnableArenas() bool { + if m != nil && m.CcEnableArenas != nil { + return *m.CcEnableArenas + } + return Default_FileOptions_CcEnableArenas +} + +func (m *FileOptions) GetUninterpretedOption() []*UninterpretedOption { + if m != nil { + return m.UninterpretedOption + } + return nil +} + +type MessageOptions struct { + // Set true to use the old proto1 MessageSet wire format for extensions. + // This is provided for backwards-compatibility with the MessageSet wire + // format. You should not use this for any other reason: It's less + // efficient, has fewer features, and is more complicated. + // + // The message must be defined exactly as follows: + // message Foo { + // option message_set_wire_format = true; + // extensions 4 to max; + // } + // Note that the message cannot have any defined fields; MessageSets only + // have extensions. + // + // All extensions of your type must be singular messages; e.g. they cannot + // be int32s, enums, or repeated messages. + // + // Because this is an option, the above two restrictions are not enforced by + // the protocol compiler. + MessageSetWireFormat *bool `protobuf:"varint,1,opt,name=message_set_wire_format,def=0" json:"message_set_wire_format,omitempty"` + // Disables the generation of the standard "descriptor()" accessor, which can + // conflict with a field of the same name. This is meant to make migration + // from proto1 easier; new code should avoid fields named "descriptor". + NoStandardDescriptorAccessor *bool `protobuf:"varint,2,opt,name=no_standard_descriptor_accessor,def=0" json:"no_standard_descriptor_accessor,omitempty"` + // Is this message deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for the message, or it will be completely ignored; in the very least, + // this is a formalization for deprecating messages. + Deprecated *bool `protobuf:"varint,3,opt,name=deprecated,def=0" json:"deprecated,omitempty"` + // Whether the message is an automatically generated map entry type for the + // maps field. + // + // For maps fields: + // map map_field = 1; + // The parsed descriptor looks like: + // message MapFieldEntry { + // option map_entry = true; + // optional KeyType key = 1; + // optional ValueType value = 2; + // } + // repeated MapFieldEntry map_field = 1; + // + // Implementations may choose not to generate the map_entry=true message, but + // use a native map in the target language to hold the keys and values. + // The reflection APIs in such implementions still need to work as + // if the field is a repeated message field. + // + // NOTE: Do not set the option in .proto files. Always use the maps syntax + // instead. The option should only be implicitly set by the proto compiler + // parser. + MapEntry *bool `protobuf:"varint,7,opt,name=map_entry" json:"map_entry,omitempty"` + // The parser stores options it doesn't recognize here. See above. + UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option" json:"uninterpreted_option,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *MessageOptions) Reset() { *m = MessageOptions{} } +func (m *MessageOptions) String() string { return proto.CompactTextString(m) } +func (*MessageOptions) ProtoMessage() {} +func (*MessageOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} } + +var extRange_MessageOptions = []proto.ExtensionRange{ + {1000, 536870911}, +} + +func (*MessageOptions) ExtensionRangeArray() []proto.ExtensionRange { + return extRange_MessageOptions +} +func (m *MessageOptions) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} + +const Default_MessageOptions_MessageSetWireFormat bool = false +const Default_MessageOptions_NoStandardDescriptorAccessor bool = false +const Default_MessageOptions_Deprecated bool = false + +func (m *MessageOptions) GetMessageSetWireFormat() bool { + if m != nil && m.MessageSetWireFormat != nil { + return *m.MessageSetWireFormat + } + return Default_MessageOptions_MessageSetWireFormat +} + +func (m *MessageOptions) GetNoStandardDescriptorAccessor() bool { + if m != nil && m.NoStandardDescriptorAccessor != nil { + return *m.NoStandardDescriptorAccessor + } + return Default_MessageOptions_NoStandardDescriptorAccessor +} + +func (m *MessageOptions) GetDeprecated() bool { + if m != nil && m.Deprecated != nil { + return *m.Deprecated + } + return Default_MessageOptions_Deprecated +} + +func (m *MessageOptions) GetMapEntry() bool { + if m != nil && m.MapEntry != nil { + return *m.MapEntry + } + return false +} + +func (m *MessageOptions) GetUninterpretedOption() []*UninterpretedOption { + if m != nil { + return m.UninterpretedOption + } + return nil +} + +type FieldOptions struct { + // The ctype option instructs the C++ code generator to use a different + // representation of the field than it normally would. See the specific + // options below. This option is not yet implemented in the open source + // release -- sorry, we'll try to include it in a future version! + Ctype *FieldOptions_CType `protobuf:"varint,1,opt,name=ctype,enum=google.protobuf.FieldOptions_CType,def=0" json:"ctype,omitempty"` + // The packed option can be enabled for repeated primitive fields to enable + // a more efficient representation on the wire. Rather than repeatedly + // writing the tag and type for each element, the entire array is encoded as + // a single length-delimited blob. + Packed *bool `protobuf:"varint,2,opt,name=packed" json:"packed,omitempty"` + // Should this field be parsed lazily? Lazy applies only to message-type + // fields. It means that when the outer message is initially parsed, the + // inner message's contents will not be parsed but instead stored in encoded + // form. The inner message will actually be parsed when it is first accessed. + // + // This is only a hint. Implementations are free to choose whether to use + // eager or lazy parsing regardless of the value of this option. However, + // setting this option true suggests that the protocol author believes that + // using lazy parsing on this field is worth the additional bookkeeping + // overhead typically needed to implement it. + // + // This option does not affect the public interface of any generated code; + // all method signatures remain the same. Furthermore, thread-safety of the + // interface is not affected by this option; const methods remain safe to + // call from multiple threads concurrently, while non-const methods continue + // to require exclusive access. + // + // + // Note that implementations may choose not to check required fields within + // a lazy sub-message. That is, calling IsInitialized() on the outher message + // may return true even if the inner message has missing required fields. + // This is necessary because otherwise the inner message would have to be + // parsed in order to perform the check, defeating the purpose of lazy + // parsing. An implementation which chooses not to check required fields + // must be consistent about it. That is, for any particular sub-message, the + // implementation must either *always* check its required fields, or *never* + // check its required fields, regardless of whether or not the message has + // been parsed. + Lazy *bool `protobuf:"varint,5,opt,name=lazy,def=0" json:"lazy,omitempty"` + // Is this field deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for accessors, or it will be completely ignored; in the very least, this + // is a formalization for deprecating fields. + Deprecated *bool `protobuf:"varint,3,opt,name=deprecated,def=0" json:"deprecated,omitempty"` + // For Google-internal migration only. Do not use. + Weak *bool `protobuf:"varint,10,opt,name=weak,def=0" json:"weak,omitempty"` + // The parser stores options it doesn't recognize here. See above. + UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option" json:"uninterpreted_option,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *FieldOptions) Reset() { *m = FieldOptions{} } +func (m *FieldOptions) String() string { return proto.CompactTextString(m) } +func (*FieldOptions) ProtoMessage() {} +func (*FieldOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} } + +var extRange_FieldOptions = []proto.ExtensionRange{ + {1000, 536870911}, +} + +func (*FieldOptions) ExtensionRangeArray() []proto.ExtensionRange { + return extRange_FieldOptions +} +func (m *FieldOptions) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} + +const Default_FieldOptions_Ctype FieldOptions_CType = FieldOptions_STRING +const Default_FieldOptions_Lazy bool = false +const Default_FieldOptions_Deprecated bool = false +const Default_FieldOptions_Weak bool = false + +func (m *FieldOptions) GetCtype() FieldOptions_CType { + if m != nil && m.Ctype != nil { + return *m.Ctype + } + return Default_FieldOptions_Ctype +} + +func (m *FieldOptions) GetPacked() bool { + if m != nil && m.Packed != nil { + return *m.Packed + } + return false +} + +func (m *FieldOptions) GetLazy() bool { + if m != nil && m.Lazy != nil { + return *m.Lazy + } + return Default_FieldOptions_Lazy +} + +func (m *FieldOptions) GetDeprecated() bool { + if m != nil && m.Deprecated != nil { + return *m.Deprecated + } + return Default_FieldOptions_Deprecated +} + +func (m *FieldOptions) GetWeak() bool { + if m != nil && m.Weak != nil { + return *m.Weak + } + return Default_FieldOptions_Weak +} + +func (m *FieldOptions) GetUninterpretedOption() []*UninterpretedOption { + if m != nil { + return m.UninterpretedOption + } + return nil +} + +type EnumOptions struct { + // Set this option to true to allow mapping different tag names to the same + // value. + AllowAlias *bool `protobuf:"varint,2,opt,name=allow_alias" json:"allow_alias,omitempty"` + // Is this enum deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for the enum, or it will be completely ignored; in the very least, this + // is a formalization for deprecating enums. + Deprecated *bool `protobuf:"varint,3,opt,name=deprecated,def=0" json:"deprecated,omitempty"` + // The parser stores options it doesn't recognize here. See above. + UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option" json:"uninterpreted_option,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *EnumOptions) Reset() { *m = EnumOptions{} } +func (m *EnumOptions) String() string { return proto.CompactTextString(m) } +func (*EnumOptions) ProtoMessage() {} +func (*EnumOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{12} } + +var extRange_EnumOptions = []proto.ExtensionRange{ + {1000, 536870911}, +} + +func (*EnumOptions) ExtensionRangeArray() []proto.ExtensionRange { + return extRange_EnumOptions +} +func (m *EnumOptions) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} + +const Default_EnumOptions_Deprecated bool = false + +func (m *EnumOptions) GetAllowAlias() bool { + if m != nil && m.AllowAlias != nil { + return *m.AllowAlias + } + return false +} + +func (m *EnumOptions) GetDeprecated() bool { + if m != nil && m.Deprecated != nil { + return *m.Deprecated + } + return Default_EnumOptions_Deprecated +} + +func (m *EnumOptions) GetUninterpretedOption() []*UninterpretedOption { + if m != nil { + return m.UninterpretedOption + } + return nil +} + +type EnumValueOptions struct { + // Is this enum value deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for the enum value, or it will be completely ignored; in the very least, + // this is a formalization for deprecating enum values. + Deprecated *bool `protobuf:"varint,1,opt,name=deprecated,def=0" json:"deprecated,omitempty"` + // The parser stores options it doesn't recognize here. See above. + UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option" json:"uninterpreted_option,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *EnumValueOptions) Reset() { *m = EnumValueOptions{} } +func (m *EnumValueOptions) String() string { return proto.CompactTextString(m) } +func (*EnumValueOptions) ProtoMessage() {} +func (*EnumValueOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{13} } + +var extRange_EnumValueOptions = []proto.ExtensionRange{ + {1000, 536870911}, +} + +func (*EnumValueOptions) ExtensionRangeArray() []proto.ExtensionRange { + return extRange_EnumValueOptions +} +func (m *EnumValueOptions) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} + +const Default_EnumValueOptions_Deprecated bool = false + +func (m *EnumValueOptions) GetDeprecated() bool { + if m != nil && m.Deprecated != nil { + return *m.Deprecated + } + return Default_EnumValueOptions_Deprecated +} + +func (m *EnumValueOptions) GetUninterpretedOption() []*UninterpretedOption { + if m != nil { + return m.UninterpretedOption + } + return nil +} + +type ServiceOptions struct { + // Is this service deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for the service, or it will be completely ignored; in the very least, + // this is a formalization for deprecating services. + Deprecated *bool `protobuf:"varint,33,opt,name=deprecated,def=0" json:"deprecated,omitempty"` + // The parser stores options it doesn't recognize here. See above. + UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option" json:"uninterpreted_option,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *ServiceOptions) Reset() { *m = ServiceOptions{} } +func (m *ServiceOptions) String() string { return proto.CompactTextString(m) } +func (*ServiceOptions) ProtoMessage() {} +func (*ServiceOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{14} } + +var extRange_ServiceOptions = []proto.ExtensionRange{ + {1000, 536870911}, +} + +func (*ServiceOptions) ExtensionRangeArray() []proto.ExtensionRange { + return extRange_ServiceOptions +} +func (m *ServiceOptions) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} + +const Default_ServiceOptions_Deprecated bool = false + +func (m *ServiceOptions) GetDeprecated() bool { + if m != nil && m.Deprecated != nil { + return *m.Deprecated + } + return Default_ServiceOptions_Deprecated +} + +func (m *ServiceOptions) GetUninterpretedOption() []*UninterpretedOption { + if m != nil { + return m.UninterpretedOption + } + return nil +} + +type MethodOptions struct { + // Is this method deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for the method, or it will be completely ignored; in the very least, + // this is a formalization for deprecating methods. + Deprecated *bool `protobuf:"varint,33,opt,name=deprecated,def=0" json:"deprecated,omitempty"` + // The parser stores options it doesn't recognize here. See above. + UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option" json:"uninterpreted_option,omitempty"` + XXX_extensions map[int32]proto.Extension `json:"-"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *MethodOptions) Reset() { *m = MethodOptions{} } +func (m *MethodOptions) String() string { return proto.CompactTextString(m) } +func (*MethodOptions) ProtoMessage() {} +func (*MethodOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{15} } + +var extRange_MethodOptions = []proto.ExtensionRange{ + {1000, 536870911}, +} + +func (*MethodOptions) ExtensionRangeArray() []proto.ExtensionRange { + return extRange_MethodOptions +} +func (m *MethodOptions) ExtensionMap() map[int32]proto.Extension { + if m.XXX_extensions == nil { + m.XXX_extensions = make(map[int32]proto.Extension) + } + return m.XXX_extensions +} + +const Default_MethodOptions_Deprecated bool = false + +func (m *MethodOptions) GetDeprecated() bool { + if m != nil && m.Deprecated != nil { + return *m.Deprecated + } + return Default_MethodOptions_Deprecated +} + +func (m *MethodOptions) GetUninterpretedOption() []*UninterpretedOption { + if m != nil { + return m.UninterpretedOption + } + return nil +} + +// A message representing a option the parser does not recognize. This only +// appears in options protos created by the compiler::Parser class. +// DescriptorPool resolves these when building Descriptor objects. Therefore, +// options protos in descriptor objects (e.g. returned by Descriptor::options(), +// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions +// in them. +type UninterpretedOption struct { + Name []*UninterpretedOption_NamePart `protobuf:"bytes,2,rep,name=name" json:"name,omitempty"` + // The value of the uninterpreted option, in whatever type the tokenizer + // identified it as during parsing. Exactly one of these should be set. + IdentifierValue *string `protobuf:"bytes,3,opt,name=identifier_value" json:"identifier_value,omitempty"` + PositiveIntValue *uint64 `protobuf:"varint,4,opt,name=positive_int_value" json:"positive_int_value,omitempty"` + NegativeIntValue *int64 `protobuf:"varint,5,opt,name=negative_int_value" json:"negative_int_value,omitempty"` + DoubleValue *float64 `protobuf:"fixed64,6,opt,name=double_value" json:"double_value,omitempty"` + StringValue []byte `protobuf:"bytes,7,opt,name=string_value" json:"string_value,omitempty"` + AggregateValue *string `protobuf:"bytes,8,opt,name=aggregate_value" json:"aggregate_value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *UninterpretedOption) Reset() { *m = UninterpretedOption{} } +func (m *UninterpretedOption) String() string { return proto.CompactTextString(m) } +func (*UninterpretedOption) ProtoMessage() {} +func (*UninterpretedOption) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{16} } + +func (m *UninterpretedOption) GetName() []*UninterpretedOption_NamePart { + if m != nil { + return m.Name + } + return nil +} + +func (m *UninterpretedOption) GetIdentifierValue() string { + if m != nil && m.IdentifierValue != nil { + return *m.IdentifierValue + } + return "" +} + +func (m *UninterpretedOption) GetPositiveIntValue() uint64 { + if m != nil && m.PositiveIntValue != nil { + return *m.PositiveIntValue + } + return 0 +} + +func (m *UninterpretedOption) GetNegativeIntValue() int64 { + if m != nil && m.NegativeIntValue != nil { + return *m.NegativeIntValue + } + return 0 +} + +func (m *UninterpretedOption) GetDoubleValue() float64 { + if m != nil && m.DoubleValue != nil { + return *m.DoubleValue + } + return 0 +} + +func (m *UninterpretedOption) GetStringValue() []byte { + if m != nil { + return m.StringValue + } + return nil +} + +func (m *UninterpretedOption) GetAggregateValue() string { + if m != nil && m.AggregateValue != nil { + return *m.AggregateValue + } + return "" +} + +// The name of the uninterpreted option. Each string represents a segment in +// a dot-separated name. is_extension is true iff a segment represents an +// extension (denoted with parentheses in options specs in .proto files). +// E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents +// "foo.(bar.baz).qux". +type UninterpretedOption_NamePart struct { + NamePart *string `protobuf:"bytes,1,req,name=name_part" json:"name_part,omitempty"` + IsExtension *bool `protobuf:"varint,2,req,name=is_extension" json:"is_extension,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *UninterpretedOption_NamePart) Reset() { *m = UninterpretedOption_NamePart{} } +func (m *UninterpretedOption_NamePart) String() string { return proto.CompactTextString(m) } +func (*UninterpretedOption_NamePart) ProtoMessage() {} +func (*UninterpretedOption_NamePart) Descriptor() ([]byte, []int) { + return fileDescriptor0, []int{16, 0} +} + +func (m *UninterpretedOption_NamePart) GetNamePart() string { + if m != nil && m.NamePart != nil { + return *m.NamePart + } + return "" +} + +func (m *UninterpretedOption_NamePart) GetIsExtension() bool { + if m != nil && m.IsExtension != nil { + return *m.IsExtension + } + return false +} + +// Encapsulates information about the original source file from which a +// FileDescriptorProto was generated. +type SourceCodeInfo struct { + // A Location identifies a piece of source code in a .proto file which + // corresponds to a particular definition. This information is intended + // to be useful to IDEs, code indexers, documentation generators, and similar + // tools. + // + // For example, say we have a file like: + // message Foo { + // optional string foo = 1; + // } + // Let's look at just the field definition: + // optional string foo = 1; + // ^ ^^ ^^ ^ ^^^ + // a bc de f ghi + // We have the following locations: + // span path represents + // [a,i) [ 4, 0, 2, 0 ] The whole field definition. + // [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + // [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + // [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + // [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + // + // Notes: + // - A location may refer to a repeated field itself (i.e. not to any + // particular index within it). This is used whenever a set of elements are + // logically enclosed in a single code segment. For example, an entire + // extend block (possibly containing multiple extension definitions) will + // have an outer location whose path refers to the "extensions" repeated + // field without an index. + // - Multiple locations may have the same path. This happens when a single + // logical declaration is spread out across multiple places. The most + // obvious example is the "extend" block again -- there may be multiple + // extend blocks in the same scope, each of which will have the same path. + // - A location's span is not always a subset of its parent's span. For + // example, the "extendee" of an extension declaration appears at the + // beginning of the "extend" block and is shared by all extensions within + // the block. + // - Just because a location's span is a subset of some other location's span + // does not mean that it is a descendent. For example, a "group" defines + // both a type and a field in a single declaration. Thus, the locations + // corresponding to the type and field and their components will overlap. + // - Code which tries to interpret locations should probably be designed to + // ignore those that it doesn't understand, as more types of locations could + // be recorded in the future. + Location []*SourceCodeInfo_Location `protobuf:"bytes,1,rep,name=location" json:"location,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *SourceCodeInfo) Reset() { *m = SourceCodeInfo{} } +func (m *SourceCodeInfo) String() string { return proto.CompactTextString(m) } +func (*SourceCodeInfo) ProtoMessage() {} +func (*SourceCodeInfo) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{17} } + +func (m *SourceCodeInfo) GetLocation() []*SourceCodeInfo_Location { + if m != nil { + return m.Location + } + return nil +} + +type SourceCodeInfo_Location struct { + // Identifies which part of the FileDescriptorProto was defined at this + // location. + // + // Each element is a field number or an index. They form a path from + // the root FileDescriptorProto to the place where the definition. For + // example, this path: + // [ 4, 3, 2, 7, 1 ] + // refers to: + // file.message_type(3) // 4, 3 + // .field(7) // 2, 7 + // .name() // 1 + // This is because FileDescriptorProto.message_type has field number 4: + // repeated DescriptorProto message_type = 4; + // and DescriptorProto.field has field number 2: + // repeated FieldDescriptorProto field = 2; + // and FieldDescriptorProto.name has field number 1: + // optional string name = 1; + // + // Thus, the above path gives the location of a field name. If we removed + // the last element: + // [ 4, 3, 2, 7 ] + // this path refers to the whole field declaration (from the beginning + // of the label to the terminating semicolon). + Path []int32 `protobuf:"varint,1,rep,packed,name=path" json:"path,omitempty"` + // Always has exactly three or four elements: start line, start column, + // end line (optional, otherwise assumed same as start line), end column. + // These are packed into a single field for efficiency. Note that line + // and column numbers are zero-based -- typically you will want to add + // 1 to each before displaying to a user. + Span []int32 `protobuf:"varint,2,rep,packed,name=span" json:"span,omitempty"` + // If this SourceCodeInfo represents a complete declaration, these are any + // comments appearing before and after the declaration which appear to be + // attached to the declaration. + // + // A series of line comments appearing on consecutive lines, with no other + // tokens appearing on those lines, will be treated as a single comment. + // + // Only the comment content is provided; comment markers (e.g. //) are + // stripped out. For block comments, leading whitespace and an asterisk + // will be stripped from the beginning of each line other than the first. + // Newlines are included in the output. + // + // Examples: + // + // optional int32 foo = 1; // Comment attached to foo. + // // Comment attached to bar. + // optional int32 bar = 2; + // + // optional string baz = 3; + // // Comment attached to baz. + // // Another line attached to baz. + // + // // Comment attached to qux. + // // + // // Another line attached to qux. + // optional double qux = 4; + // + // optional string corge = 5; + // /* Block comment attached + // * to corge. Leading asterisks + // * will be removed. */ + // /* Block comment attached to + // * grault. */ + // optional int32 grault = 6; + LeadingComments *string `protobuf:"bytes,3,opt,name=leading_comments" json:"leading_comments,omitempty"` + TrailingComments *string `protobuf:"bytes,4,opt,name=trailing_comments" json:"trailing_comments,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *SourceCodeInfo_Location) Reset() { *m = SourceCodeInfo_Location{} } +func (m *SourceCodeInfo_Location) String() string { return proto.CompactTextString(m) } +func (*SourceCodeInfo_Location) ProtoMessage() {} +func (*SourceCodeInfo_Location) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{17, 0} } + +func (m *SourceCodeInfo_Location) GetPath() []int32 { + if m != nil { + return m.Path + } + return nil +} + +func (m *SourceCodeInfo_Location) GetSpan() []int32 { + if m != nil { + return m.Span + } + return nil +} + +func (m *SourceCodeInfo_Location) GetLeadingComments() string { + if m != nil && m.LeadingComments != nil { + return *m.LeadingComments + } + return "" +} + +func (m *SourceCodeInfo_Location) GetTrailingComments() string { + if m != nil && m.TrailingComments != nil { + return *m.TrailingComments + } + return "" +} + +func init() { + proto.RegisterType((*FileDescriptorSet)(nil), "google.protobuf.FileDescriptorSet") + proto.RegisterType((*FileDescriptorProto)(nil), "google.protobuf.FileDescriptorProto") + proto.RegisterType((*DescriptorProto)(nil), "google.protobuf.DescriptorProto") + proto.RegisterType((*DescriptorProto_ExtensionRange)(nil), "google.protobuf.DescriptorProto.ExtensionRange") + proto.RegisterType((*FieldDescriptorProto)(nil), "google.protobuf.FieldDescriptorProto") + proto.RegisterType((*OneofDescriptorProto)(nil), "google.protobuf.OneofDescriptorProto") + proto.RegisterType((*EnumDescriptorProto)(nil), "google.protobuf.EnumDescriptorProto") + proto.RegisterType((*EnumValueDescriptorProto)(nil), "google.protobuf.EnumValueDescriptorProto") + proto.RegisterType((*ServiceDescriptorProto)(nil), "google.protobuf.ServiceDescriptorProto") + proto.RegisterType((*MethodDescriptorProto)(nil), "google.protobuf.MethodDescriptorProto") + proto.RegisterType((*FileOptions)(nil), "google.protobuf.FileOptions") + proto.RegisterType((*MessageOptions)(nil), "google.protobuf.MessageOptions") + proto.RegisterType((*FieldOptions)(nil), "google.protobuf.FieldOptions") + proto.RegisterType((*EnumOptions)(nil), "google.protobuf.EnumOptions") + proto.RegisterType((*EnumValueOptions)(nil), "google.protobuf.EnumValueOptions") + proto.RegisterType((*ServiceOptions)(nil), "google.protobuf.ServiceOptions") + proto.RegisterType((*MethodOptions)(nil), "google.protobuf.MethodOptions") + proto.RegisterType((*UninterpretedOption)(nil), "google.protobuf.UninterpretedOption") + proto.RegisterType((*UninterpretedOption_NamePart)(nil), "google.protobuf.UninterpretedOption.NamePart") + proto.RegisterType((*SourceCodeInfo)(nil), "google.protobuf.SourceCodeInfo") + proto.RegisterType((*SourceCodeInfo_Location)(nil), "google.protobuf.SourceCodeInfo.Location") + proto.RegisterEnum("google.protobuf.FieldDescriptorProto_Type", FieldDescriptorProto_Type_name, FieldDescriptorProto_Type_value) + proto.RegisterEnum("google.protobuf.FieldDescriptorProto_Label", FieldDescriptorProto_Label_name, FieldDescriptorProto_Label_value) + proto.RegisterEnum("google.protobuf.FileOptions_OptimizeMode", FileOptions_OptimizeMode_name, FileOptions_OptimizeMode_value) + proto.RegisterEnum("google.protobuf.FieldOptions_CType", FieldOptions_CType_name, FieldOptions_CType_value) +} + +var fileDescriptor0 = []byte{ + // 1635 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xbc, 0x58, 0xcd, 0x72, 0xdb, 0xd4, + 0x17, 0xff, 0xfb, 0x43, 0xfe, 0x38, 0x76, 0x1c, 0x45, 0x49, 0x5b, 0x35, 0xff, 0x96, 0xb4, 0xa6, + 0x2d, 0x69, 0x69, 0x1d, 0x26, 0x2d, 0xa5, 0x84, 0x55, 0x3e, 0xd4, 0xd4, 0x33, 0x4e, 0x6c, 0x12, + 0x87, 0xa1, 0x6c, 0x34, 0x37, 0xf2, 0xb5, 0xa3, 0x56, 0x96, 0x8c, 0x24, 0xa7, 0x4d, 0x19, 0x66, + 0x78, 0x00, 0x98, 0xe1, 0x09, 0x18, 0x5e, 0x81, 0x0d, 0x2b, 0x36, 0xec, 0x79, 0x03, 0xb6, 0x0c, + 0xf0, 0x18, 0x9c, 0x7b, 0xaf, 0x25, 0x4b, 0x8a, 0x9d, 0xb6, 0x4c, 0x4b, 0x57, 0xee, 0xb9, 0xbf, + 0x73, 0xce, 0xef, 0x9e, 0xcf, 0xab, 0xc0, 0x95, 0x9e, 0xe3, 0xf4, 0x2c, 0xba, 0x32, 0x70, 0x1d, + 0xdf, 0x39, 0x1c, 0x76, 0x57, 0x3a, 0xd4, 0x33, 0x5c, 0x73, 0xe0, 0x3b, 0x6e, 0x8d, 0xcb, 0x94, + 0x59, 0x81, 0xa8, 0x05, 0x88, 0xea, 0x36, 0xcc, 0x3d, 0x34, 0x2d, 0xba, 0x15, 0x02, 0xf7, 0xa9, + 0xaf, 0xac, 0x42, 0xb6, 0x8b, 0x42, 0x35, 0x75, 0x25, 0xb3, 0x5c, 0x5a, 0xbd, 0x56, 0x4b, 0x28, + 0xd5, 0xe2, 0x1a, 0x2d, 0x26, 0xae, 0xfe, 0x9e, 0x81, 0xf9, 0x09, 0x72, 0xa5, 0x0c, 0x59, 0x9b, + 0xf4, 0x99, 0xad, 0xd4, 0x72, 0x51, 0x99, 0x85, 0xfc, 0x80, 0x18, 0x4f, 0x49, 0x8f, 0xaa, 0x69, + 0x2e, 0x50, 0x00, 0x3a, 0x74, 0x40, 0xed, 0x0e, 0xb5, 0x8d, 0x13, 0x35, 0x83, 0x0e, 0x8b, 0xca, + 0x45, 0x98, 0x1b, 0x0c, 0x0f, 0x2d, 0xd3, 0xd0, 0x23, 0x47, 0x80, 0x47, 0x92, 0x72, 0x01, 0x66, + 0x9f, 0x51, 0xf2, 0x34, 0x7a, 0x50, 0xe2, 0x07, 0xf7, 0xa1, 0xdc, 0xa7, 0x9e, 0x87, 0x86, 0x75, + 0xff, 0x64, 0x40, 0xd5, 0x2c, 0xa7, 0x7e, 0xe5, 0x14, 0xf5, 0x24, 0xbd, 0x8f, 0xa0, 0x48, 0xed, + 0x61, 0x5f, 0x28, 0x49, 0x53, 0xee, 0xab, 0x21, 0x22, 0xa9, 0xf8, 0x00, 0xf2, 0x1e, 0x75, 0x8f, + 0x4d, 0x83, 0xaa, 0x39, 0xae, 0xf6, 0xde, 0x29, 0xb5, 0x7d, 0x71, 0x7e, 0x5a, 0xb3, 0x48, 0x9f, + 0xfb, 0xd4, 0xf6, 0x4c, 0xc7, 0x56, 0xf3, 0x5c, 0xf7, 0xfa, 0x84, 0x10, 0x53, 0xab, 0x93, 0xd4, + 0xbc, 0x03, 0x79, 0x67, 0xe0, 0xa3, 0x9a, 0xa7, 0x16, 0x30, 0x7a, 0xa5, 0xd5, 0x4b, 0x13, 0x53, + 0xd3, 0x14, 0x18, 0xe5, 0x63, 0x90, 0x3d, 0x67, 0xe8, 0x1a, 0x54, 0x37, 0x9c, 0x0e, 0xd5, 0x4d, + 0xbb, 0xeb, 0xa8, 0x45, 0xae, 0xb7, 0x74, 0x9a, 0x2b, 0x07, 0x6e, 0x22, 0xae, 0x8e, 0x30, 0xa5, + 0x02, 0x39, 0xef, 0xc4, 0xf6, 0xc9, 0x73, 0xb5, 0xcc, 0xd2, 0x54, 0xfd, 0x23, 0x03, 0xb3, 0x67, + 0x67, 0xf6, 0x1e, 0x48, 0x5d, 0xc6, 0x19, 0xf3, 0xfa, 0x1a, 0x37, 0x8a, 0xc5, 0x22, 0xf7, 0x3a, + 0x9a, 0x1f, 0x42, 0xc9, 0xa6, 0x9e, 0x4f, 0x3b, 0x22, 0x75, 0x99, 0x7f, 0x93, 0xef, 0xec, 0x6b, + 0xe4, 0xfb, 0x11, 0xcc, 0x86, 0x4c, 0x75, 0x97, 0xd8, 0xbd, 0xa0, 0x5c, 0x56, 0x5e, 0xe6, 0xb3, + 0xa6, 0x05, 0x7a, 0x7b, 0x4c, 0x0d, 0xd3, 0x02, 0x8e, 0x4d, 0x9d, 0x2e, 0x16, 0xb1, 0x61, 0x61, + 0x22, 0x27, 0x5f, 0xba, 0xc9, 0x20, 0x49, 0x12, 0x1f, 0x8c, 0x0b, 0x20, 0x3f, 0x25, 0x91, 0x3b, + 0xa2, 0x0b, 0x46, 0x35, 0xb0, 0x78, 0x1b, 0x2a, 0x09, 0xf7, 0x33, 0x20, 0x79, 0x3e, 0x71, 0x7d, + 0x9e, 0x37, 0x49, 0x29, 0x41, 0x06, 0x3b, 0x89, 0x77, 0xa3, 0x54, 0xfd, 0x45, 0x82, 0x85, 0x89, + 0xd1, 0x8e, 0xe7, 0x1a, 0xab, 0x03, 0x23, 0x74, 0x48, 0x5d, 0x0c, 0x3b, 0xb3, 0xb1, 0x06, 0x92, + 0x45, 0x0e, 0xa9, 0x85, 0x01, 0x4d, 0x2d, 0x57, 0x56, 0xdf, 0x7f, 0xa5, 0x0c, 0xd6, 0x1a, 0x4c, + 0x05, 0x2b, 0x20, 0x3b, 0xea, 0x3d, 0xa6, 0x7a, 0xeb, 0xd5, 0x54, 0xdb, 0xa8, 0xa1, 0xcc, 0x41, + 0x91, 0x69, 0xea, 0x9c, 0x58, 0x8e, 0x13, 0x93, 0xa1, 0xc0, 0x93, 0xd4, 0xa1, 0xc1, 0x7c, 0x39, + 0x07, 0x33, 0x1d, 0xda, 0x25, 0x43, 0xcb, 0xd7, 0x8f, 0x89, 0x35, 0xa4, 0x3c, 0x6e, 0x45, 0x65, + 0x1e, 0x4a, 0x22, 0x07, 0x26, 0x62, 0x9f, 0xf3, 0xae, 0x90, 0x98, 0xc1, 0x27, 0x1e, 0x66, 0x97, + 0x1b, 0x04, 0x8e, 0xab, 0x25, 0x3b, 0xee, 0xf2, 0x64, 0x82, 0xa3, 0x70, 0x57, 0x7f, 0x4e, 0x43, + 0x96, 0x93, 0x9b, 0x85, 0x52, 0xfb, 0x71, 0x4b, 0xd3, 0xb7, 0x9a, 0x07, 0x1b, 0x0d, 0x4d, 0x4e, + 0x61, 0xcc, 0x80, 0x0b, 0x1e, 0x36, 0x9a, 0xeb, 0x6d, 0x39, 0x1d, 0xfe, 0xbf, 0xbe, 0xdb, 0xbe, + 0x7f, 0x4f, 0xce, 0x84, 0x0a, 0x07, 0x42, 0x90, 0x8d, 0x02, 0xee, 0xae, 0xca, 0x12, 0xde, 0xad, + 0x2c, 0x0c, 0xd4, 0x3f, 0xd7, 0xb6, 0x10, 0x91, 0x8b, 0x4b, 0x10, 0x93, 0xc7, 0xdc, 0x16, 0xb9, + 0x64, 0xa3, 0xd9, 0x6c, 0xc8, 0x85, 0xd0, 0xe6, 0x7e, 0x7b, 0xaf, 0xbe, 0xbb, 0x2d, 0x17, 0x43, + 0x9b, 0xdb, 0x7b, 0xcd, 0x83, 0x96, 0x0c, 0xa1, 0x85, 0x1d, 0x6d, 0x7f, 0x7f, 0x7d, 0x5b, 0x93, + 0x4b, 0x21, 0x62, 0xe3, 0x71, 0x5b, 0xdb, 0x97, 0xcb, 0x31, 0x5a, 0xe8, 0x62, 0x26, 0x74, 0xa1, + 0xed, 0x1e, 0xec, 0xc8, 0x15, 0x8c, 0xd9, 0x8c, 0x70, 0x11, 0x90, 0x98, 0x4d, 0x88, 0x90, 0xa9, + 0x3c, 0x26, 0x22, 0xac, 0xcc, 0xc5, 0x04, 0x88, 0x50, 0xaa, 0x9b, 0x20, 0x89, 0x7a, 0x50, 0xa0, + 0xd2, 0x58, 0xdf, 0xd0, 0x1a, 0x7a, 0xb3, 0xd5, 0xae, 0x37, 0x77, 0xd7, 0x1b, 0x18, 0xbb, 0x50, + 0xb6, 0xa7, 0x7d, 0x7a, 0x50, 0xdf, 0xd3, 0xb6, 0x30, 0x7e, 0x11, 0x59, 0x4b, 0x5b, 0x6f, 0xa3, + 0x2c, 0x53, 0xbd, 0x06, 0x0b, 0x13, 0xdb, 0x26, 0x56, 0xbd, 0xd5, 0x6f, 0x53, 0x30, 0x3f, 0xa9, + 0xc3, 0xe3, 0x35, 0xfe, 0x00, 0x24, 0x51, 0x30, 0x62, 0x9e, 0xdd, 0x9c, 0x38, 0x24, 0x3e, 0x63, + 0x88, 0x33, 0xa6, 0x74, 0x66, 0xca, 0x94, 0x66, 0xba, 0x41, 0xc9, 0x58, 0xa0, 0x4e, 0x35, 0x35, + 0xad, 0xed, 0x78, 0xb7, 0xe2, 0x9a, 0x4e, 0x38, 0xba, 0x3a, 0x9d, 0x64, 0xe0, 0xed, 0xfb, 0x14, + 0x9c, 0x9f, 0xb2, 0x97, 0xe2, 0xce, 0xee, 0x43, 0xae, 0x4f, 0xfd, 0x23, 0x27, 0x18, 0xe8, 0x37, + 0x26, 0x4c, 0x1a, 0x76, 0x7c, 0xc6, 0x88, 0xca, 0x4c, 0xdb, 0x35, 0xc2, 0x7f, 0x40, 0xe9, 0xd7, + 0x14, 0x9c, 0x9b, 0x6c, 0x2b, 0xce, 0x08, 0x9f, 0x0a, 0xa6, 0x3d, 0x18, 0xfa, 0x62, 0x76, 0xa7, + 0xc3, 0x3e, 0x1e, 0xfa, 0xa1, 0x30, 0xc3, 0x85, 0x2b, 0x63, 0x0a, 0x59, 0x4e, 0xe1, 0x9d, 0x29, + 0xdc, 0x83, 0x45, 0xb9, 0x04, 0xb2, 0x61, 0x99, 0xd4, 0xf6, 0x75, 0xcf, 0x77, 0x29, 0xe9, 0x9b, + 0x76, 0x8f, 0xcf, 0xa3, 0xc2, 0x9a, 0xd4, 0x25, 0x96, 0x47, 0x19, 0x80, 0x2d, 0x7b, 0xea, 0x46, + 0x00, 0xb9, 0x08, 0xa0, 0xfa, 0x5b, 0x16, 0x4a, 0xd1, 0xd5, 0xbb, 0x00, 0xe5, 0x27, 0xe4, 0x98, + 0xe8, 0xc1, 0x63, 0x47, 0xdc, 0xe0, 0x12, 0x2c, 0x70, 0x29, 0x52, 0x46, 0x53, 0x86, 0x45, 0x3c, + 0x8f, 0xdf, 0xaf, 0xc0, 0x4f, 0xab, 0x30, 0xcf, 0x4f, 0xfb, 0x38, 0xac, 0xcc, 0x81, 0x45, 0x75, + 0xf6, 0x06, 0xf3, 0xf8, 0x20, 0x0a, 0x89, 0xdc, 0x86, 0xcb, 0x1c, 0xd3, 0xa3, 0x36, 0x75, 0x89, + 0x4f, 0x75, 0xfa, 0xe5, 0x10, 0x0f, 0x74, 0x62, 0x77, 0xf4, 0x23, 0xe2, 0x1d, 0xa9, 0x0b, 0x51, + 0xf4, 0x75, 0x38, 0xcf, 0xd1, 0x48, 0x1a, 0x19, 0xeb, 0xc6, 0x11, 0x35, 0x9e, 0xea, 0x43, 0xbf, + 0xfb, 0x40, 0xfd, 0x7f, 0x14, 0xf6, 0x10, 0xca, 0x2c, 0x5e, 0x7d, 0xf3, 0x05, 0xfa, 0x74, 0x5c, + 0x3e, 0x0d, 0x2b, 0x13, 0x2a, 0x3e, 0x72, 0xc1, 0x5a, 0x73, 0xa4, 0xb0, 0x83, 0x2f, 0x86, 0x35, + 0x69, 0xbf, 0xa5, 0x69, 0x5b, 0x2c, 0x41, 0x3d, 0x27, 0xbc, 0x72, 0x29, 0xb8, 0x94, 0x61, 0x08, + 0xba, 0xf8, 0x9e, 0x1b, 0xbd, 0x98, 0x3c, 0x55, 0x8e, 0xfa, 0xbf, 0x06, 0xe7, 0xc6, 0x97, 0x8a, + 0xa2, 0xe6, 0xa2, 0x28, 0xb4, 0x34, 0x38, 0x39, 0x8d, 0x51, 0xa2, 0x98, 0x8b, 0xfc, 0x35, 0xe9, + 0x52, 0x03, 0x43, 0xd3, 0x51, 0x2f, 0x24, 0x52, 0x88, 0x44, 0xa8, 0x4d, 0x0e, 0x31, 0xb2, 0xc4, + 0xc5, 0x1f, 0x9e, 0xba, 0x14, 0x05, 0x6c, 0xc2, 0xc2, 0xd0, 0x36, 0x6d, 0xcc, 0x0c, 0x1a, 0x60, + 0xef, 0x0a, 0x51, 0x43, 0xea, 0x5f, 0xf9, 0x29, 0xaf, 0x84, 0x83, 0x28, 0x5a, 0xc4, 0xa5, 0xba, + 0x06, 0xe5, 0x68, 0x64, 0x94, 0x22, 0x88, 0xd8, 0xe0, 0x10, 0xc3, 0xc1, 0xb9, 0xd9, 0xdc, 0x62, + 0x23, 0xef, 0x0b, 0x0d, 0xe7, 0x17, 0x8e, 0xde, 0x46, 0xbd, 0xad, 0xe9, 0x7b, 0x07, 0xbb, 0xed, + 0xfa, 0x8e, 0x26, 0x67, 0x6e, 0x15, 0x0b, 0x7f, 0xe7, 0xe5, 0x6f, 0xf0, 0x5f, 0xba, 0xfa, 0x67, + 0x0a, 0x2a, 0xf1, 0x45, 0xae, 0xdc, 0x80, 0x0b, 0xc1, 0x03, 0xd7, 0xa3, 0xbe, 0xfe, 0xcc, 0x74, + 0x79, 0xb2, 0xfa, 0x44, 0x2c, 0xf2, 0xf0, 0x1a, 0x35, 0x58, 0xb2, 0x1d, 0xcc, 0x38, 0x56, 0x04, + 0x71, 0x3b, 0xfa, 0xf8, 0x0b, 0x40, 0x27, 0x06, 0xc6, 0xcb, 0x73, 0xc4, 0xf4, 0x98, 0x12, 0xb2, + 0x4c, 0xf4, 0x08, 0xf7, 0x61, 0x9f, 0x0c, 0x30, 0x66, 0xbe, 0x7b, 0xc2, 0xf7, 0x66, 0xe1, 0x8d, + 0x04, 0x29, 0x7a, 0xd1, 0x1f, 0xd3, 0x50, 0x8e, 0x2e, 0x50, 0xf6, 0x94, 0x30, 0x78, 0x2b, 0xa7, + 0x78, 0x11, 0xbe, 0x7b, 0xe6, 0xba, 0xad, 0x6d, 0xb2, 0x5d, 0xbb, 0x96, 0x13, 0xfb, 0x8d, 0xcd, + 0x47, 0x56, 0x7c, 0x54, 0xbc, 0x66, 0x0a, 0x38, 0x1c, 0xb2, 0x16, 0x79, 0x71, 0x12, 0x6f, 0xe5, + 0x33, 0xee, 0x8b, 0x78, 0xf6, 0x71, 0x11, 0xef, 0xb8, 0x37, 0x52, 0x16, 0x2b, 0x20, 0x71, 0xaa, + 0xd8, 0x21, 0x23, 0xb2, 0xf2, 0xff, 0x94, 0x02, 0x64, 0x37, 0x9b, 0x7b, 0xac, 0x34, 0xb0, 0x16, + 0x84, 0x54, 0x6f, 0xd5, 0xb5, 0x4d, 0xac, 0x8e, 0x68, 0x88, 0xbe, 0x4b, 0x41, 0x29, 0xb2, 0x2f, + 0xd8, 0xc8, 0x23, 0x96, 0xe5, 0x3c, 0xd3, 0x89, 0x65, 0x62, 0x0d, 0x8b, 0xab, 0x9e, 0x71, 0xab, + 0x37, 0x9d, 0xb2, 0xaf, 0x41, 0x4e, 0x6e, 0x95, 0x84, 0xfb, 0xd4, 0xdb, 0x74, 0xff, 0x15, 0x54, + 0xe2, 0xfb, 0x23, 0xe1, 0xfc, 0xea, 0xdb, 0x74, 0xfe, 0x02, 0x66, 0xe2, 0x9b, 0xe3, 0x3f, 0xf4, + 0xfd, 0x43, 0x1a, 0xe6, 0x27, 0x40, 0x94, 0x4f, 0x46, 0x4b, 0x52, 0xac, 0xe9, 0x3b, 0xaf, 0x62, + 0xb6, 0xb6, 0x8b, 0x0a, 0x2d, 0xfc, 0x06, 0x50, 0x54, 0x90, 0x4d, 0xfc, 0x8c, 0xf6, 0x4d, 0xfc, + 0x76, 0x73, 0x47, 0x2f, 0x64, 0xb1, 0x44, 0x17, 0x41, 0x19, 0x38, 0x9e, 0xe9, 0x9b, 0xc7, 0xec, + 0xcb, 0x31, 0x78, 0x3d, 0xb3, 0x7d, 0x9a, 0x65, 0x67, 0x36, 0xed, 0x91, 0xc4, 0x19, 0x6b, 0xb3, + 0x0c, 0xdb, 0x7c, 0x1d, 0x67, 0xc8, 0x86, 0xac, 0x90, 0xb2, 0x35, 0x99, 0x62, 0xd2, 0xd1, 0x12, + 0x1a, 0xbf, 0xc2, 0xcb, 0xec, 0x6b, 0x9e, 0xf4, 0x7a, 0x2e, 0x33, 0x15, 0xc0, 0xf9, 0x2a, 0x5c, + 0xbc, 0x0b, 0x85, 0x90, 0x22, 0x4e, 0x21, 0x76, 0x3f, 0xdc, 0x2b, 0xfc, 0x9b, 0x25, 0x8d, 0xdc, + 0xd0, 0x9a, 0xe9, 0xe9, 0xe3, 0x0f, 0xc7, 0x34, 0x4a, 0x0b, 0xd5, 0x9f, 0x70, 0x68, 0x26, 0x3e, + 0x63, 0xd7, 0xa0, 0x60, 0x39, 0x98, 0x1b, 0x06, 0x12, 0x7f, 0xcc, 0x58, 0x7e, 0xc9, 0x97, 0x6f, + 0xad, 0x31, 0xc2, 0x2f, 0x1a, 0x50, 0x08, 0x7e, 0x63, 0x83, 0x66, 0x07, 0xc4, 0x3f, 0xe2, 0x36, + 0xa4, 0x8d, 0x34, 0x6f, 0xd9, 0xac, 0x37, 0x20, 0x36, 0x8f, 0xba, 0x90, 0x60, 0x28, 0x2d, 0x4a, + 0x3a, 0x7c, 0xd1, 0x3a, 0xfd, 0x3e, 0x06, 0xd5, 0x1b, 0x85, 0xf2, 0x22, 0xcc, 0xf9, 0x2e, 0x31, + 0xad, 0xd8, 0x11, 0x8b, 0x64, 0x71, 0xe3, 0x26, 0xae, 0x47, 0xa7, 0x9f, 0xe4, 0xb4, 0x21, 0x27, + 0x5e, 0x42, 0xde, 0xa3, 0xd4, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x3d, 0xe5, 0x5c, 0x96, 0xdd, + 0x11, 0x00, 0x00, +} diff --git a/vendor/github.com/golang/protobuf/protoc-gen-go/doc.go b/vendor/github.com/golang/protobuf/protoc-gen-go/doc.go new file mode 100644 index 0000000000..0d6055d610 --- /dev/null +++ b/vendor/github.com/golang/protobuf/protoc-gen-go/doc.go @@ -0,0 +1,51 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +/* + A plugin for the Google protocol buffer compiler to generate Go code. + Run it by building this program and putting it in your path with the name + protoc-gen-go + That word 'go' at the end becomes part of the option string set for the + protocol compiler, so once the protocol compiler (protoc) is installed + you can run + protoc --go_out=output_directory input_directory/file.proto + to generate Go bindings for the protocol defined by file.proto. + With that input, the output will be written to + output_directory/file.pb.go + + The generated code is documented in the package comment for + the library. + + See the README and documentation for protocol buffers to learn more: + https://developers.google.com/protocol-buffers/ + +*/ +package documentation diff --git a/vendor/github.com/golang/protobuf/protoc-gen-go/generator/generator.go b/vendor/github.com/golang/protobuf/protoc-gen-go/generator/generator.go new file mode 100644 index 0000000000..c2c96bf720 --- /dev/null +++ b/vendor/github.com/golang/protobuf/protoc-gen-go/generator/generator.go @@ -0,0 +1,2715 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +/* + The code generator for the plugin for the Google protocol buffer compiler. + It generates Go code from the protocol buffer description files read by the + main routine. +*/ +package generator + +import ( + "bufio" + "bytes" + "compress/gzip" + "fmt" + "go/parser" + "go/printer" + "go/token" + "log" + "os" + "path" + "strconv" + "strings" + "unicode" + "unicode/utf8" + + "github.com/golang/protobuf/proto" + + "github.com/golang/protobuf/protoc-gen-go/descriptor" + plugin "github.com/golang/protobuf/protoc-gen-go/plugin" +) + +// generatedCodeVersion indicates a version of the generated code. +// It is incremented whenever an incompatibility between the generated code and +// proto package is introduced; the generated code references +// a constant, proto.ProtoPackageIsVersionN (where N is generatedCodeVersion). +const generatedCodeVersion = 1 + +// A Plugin provides functionality to add to the output during Go code generation, +// such as to produce RPC stubs. +type Plugin interface { + // Name identifies the plugin. + Name() string + // Init is called once after data structures are built but before + // code generation begins. + Init(g *Generator) + // Generate produces the code generated by the plugin for this file, + // except for the imports, by calling the generator's methods P, In, and Out. + Generate(file *FileDescriptor) + // GenerateImports produces the import declarations for this file. + // It is called after Generate. + GenerateImports(file *FileDescriptor) +} + +var plugins []Plugin + +// RegisterPlugin installs a (second-order) plugin to be run when the Go output is generated. +// It is typically called during initialization. +func RegisterPlugin(p Plugin) { + plugins = append(plugins, p) +} + +// Each type we import as a protocol buffer (other than FileDescriptorProto) needs +// a pointer to the FileDescriptorProto that represents it. These types achieve that +// wrapping by placing each Proto inside a struct with the pointer to its File. The +// structs have the same names as their contents, with "Proto" removed. +// FileDescriptor is used to store the things that it points to. + +// The file and package name method are common to messages and enums. +type common struct { + file *descriptor.FileDescriptorProto // File this object comes from. +} + +// PackageName is name in the package clause in the generated file. +func (c *common) PackageName() string { return uniquePackageOf(c.file) } + +func (c *common) File() *descriptor.FileDescriptorProto { return c.file } + +func fileIsProto3(file *descriptor.FileDescriptorProto) bool { + return file.GetSyntax() == "proto3" +} + +func (c *common) proto3() bool { return fileIsProto3(c.file) } + +// Descriptor represents a protocol buffer message. +type Descriptor struct { + common + *descriptor.DescriptorProto + parent *Descriptor // The containing message, if any. + nested []*Descriptor // Inner messages, if any. + enums []*EnumDescriptor // Inner enums, if any. + ext []*ExtensionDescriptor // Extensions, if any. + typename []string // Cached typename vector. + index int // The index into the container, whether the file or another message. + path string // The SourceCodeInfo path as comma-separated integers. + group bool +} + +// TypeName returns the elements of the dotted type name. +// The package name is not part of this name. +func (d *Descriptor) TypeName() []string { + if d.typename != nil { + return d.typename + } + n := 0 + for parent := d; parent != nil; parent = parent.parent { + n++ + } + s := make([]string, n, n) + for parent := d; parent != nil; parent = parent.parent { + n-- + s[n] = parent.GetName() + } + d.typename = s + return s +} + +// EnumDescriptor describes an enum. If it's at top level, its parent will be nil. +// Otherwise it will be the descriptor of the message in which it is defined. +type EnumDescriptor struct { + common + *descriptor.EnumDescriptorProto + parent *Descriptor // The containing message, if any. + typename []string // Cached typename vector. + index int // The index into the container, whether the file or a message. + path string // The SourceCodeInfo path as comma-separated integers. +} + +// TypeName returns the elements of the dotted type name. +// The package name is not part of this name. +func (e *EnumDescriptor) TypeName() (s []string) { + if e.typename != nil { + return e.typename + } + name := e.GetName() + if e.parent == nil { + s = make([]string, 1) + } else { + pname := e.parent.TypeName() + s = make([]string, len(pname)+1) + copy(s, pname) + } + s[len(s)-1] = name + e.typename = s + return s +} + +// Everything but the last element of the full type name, CamelCased. +// The values of type Foo.Bar are call Foo_value1... not Foo_Bar_value1... . +func (e *EnumDescriptor) prefix() string { + if e.parent == nil { + // If the enum is not part of a message, the prefix is just the type name. + return CamelCase(*e.Name) + "_" + } + typeName := e.TypeName() + return CamelCaseSlice(typeName[0:len(typeName)-1]) + "_" +} + +// The integer value of the named constant in this enumerated type. +func (e *EnumDescriptor) integerValueAsString(name string) string { + for _, c := range e.Value { + if c.GetName() == name { + return fmt.Sprint(c.GetNumber()) + } + } + log.Fatal("cannot find value for enum constant") + return "" +} + +// ExtensionDescriptor describes an extension. If it's at top level, its parent will be nil. +// Otherwise it will be the descriptor of the message in which it is defined. +type ExtensionDescriptor struct { + common + *descriptor.FieldDescriptorProto + parent *Descriptor // The containing message, if any. +} + +// TypeName returns the elements of the dotted type name. +// The package name is not part of this name. +func (e *ExtensionDescriptor) TypeName() (s []string) { + name := e.GetName() + if e.parent == nil { + // top-level extension + s = make([]string, 1) + } else { + pname := e.parent.TypeName() + s = make([]string, len(pname)+1) + copy(s, pname) + } + s[len(s)-1] = name + return s +} + +// DescName returns the variable name used for the generated descriptor. +func (e *ExtensionDescriptor) DescName() string { + // The full type name. + typeName := e.TypeName() + // Each scope of the extension is individually CamelCased, and all are joined with "_" with an "E_" prefix. + for i, s := range typeName { + typeName[i] = CamelCase(s) + } + return "E_" + strings.Join(typeName, "_") +} + +// ImportedDescriptor describes a type that has been publicly imported from another file. +type ImportedDescriptor struct { + common + o Object +} + +func (id *ImportedDescriptor) TypeName() []string { return id.o.TypeName() } + +// FileDescriptor describes an protocol buffer descriptor file (.proto). +// It includes slices of all the messages and enums defined within it. +// Those slices are constructed by WrapTypes. +type FileDescriptor struct { + *descriptor.FileDescriptorProto + desc []*Descriptor // All the messages defined in this file. + enum []*EnumDescriptor // All the enums defined in this file. + ext []*ExtensionDescriptor // All the top-level extensions defined in this file. + imp []*ImportedDescriptor // All types defined in files publicly imported by this file. + + // Comments, stored as a map of path (comma-separated integers) to the comment. + comments map[string]*descriptor.SourceCodeInfo_Location + + // The full list of symbols that are exported, + // as a map from the exported object to its symbols. + // This is used for supporting public imports. + exported map[Object][]symbol + + index int // The index of this file in the list of files to generate code for + + proto3 bool // whether to generate proto3 code for this file +} + +// PackageName is the package name we'll use in the generated code to refer to this file. +func (d *FileDescriptor) PackageName() string { return uniquePackageOf(d.FileDescriptorProto) } + +// goPackageName returns the Go package name to use in the +// generated Go file. The result explicit reports whether the name +// came from an option go_package statement. If explicit is false, +// the name was derived from the protocol buffer's package statement +// or the input file name. +func (d *FileDescriptor) goPackageName() (name string, explicit bool) { + // Does the file have a "go_package" option? + if opts := d.Options; opts != nil { + if pkg := opts.GetGoPackage(); pkg != "" { + return pkg, true + } + } + + // Does the file have a package clause? + if pkg := d.GetPackage(); pkg != "" { + return pkg, false + } + // Use the file base name. + return baseName(d.GetName()), false +} + +func (d *FileDescriptor) addExport(obj Object, sym symbol) { + d.exported[obj] = append(d.exported[obj], sym) +} + +// symbol is an interface representing an exported Go symbol. +type symbol interface { + // GenerateAlias should generate an appropriate alias + // for the symbol from the named package. + GenerateAlias(g *Generator, pkg string) +} + +type messageSymbol struct { + sym string + hasExtensions, isMessageSet bool + hasOneof bool + getters []getterSymbol +} + +type getterSymbol struct { + name string + typ string + typeName string // canonical name in proto world; empty for proto.Message and similar + genType bool // whether typ contains a generated type (message/group/enum) +} + +func (ms *messageSymbol) GenerateAlias(g *Generator, pkg string) { + remoteSym := pkg + "." + ms.sym + + g.P("type ", ms.sym, " ", remoteSym) + g.P("func (m *", ms.sym, ") Reset() { (*", remoteSym, ")(m).Reset() }") + g.P("func (m *", ms.sym, ") String() string { return (*", remoteSym, ")(m).String() }") + g.P("func (*", ms.sym, ") ProtoMessage() {}") + if ms.hasExtensions { + g.P("func (*", ms.sym, ") ExtensionRangeArray() []", g.Pkg["proto"], ".ExtensionRange ", + "{ return (*", remoteSym, ")(nil).ExtensionRangeArray() }") + g.P("func (m *", ms.sym, ") ExtensionMap() map[int32]", g.Pkg["proto"], ".Extension ", + "{ return (*", remoteSym, ")(m).ExtensionMap() }") + if ms.isMessageSet { + g.P("func (m *", ms.sym, ") Marshal() ([]byte, error) ", + "{ return (*", remoteSym, ")(m).Marshal() }") + g.P("func (m *", ms.sym, ") Unmarshal(buf []byte) error ", + "{ return (*", remoteSym, ")(m).Unmarshal(buf) }") + } + } + if ms.hasOneof { + // Oneofs and public imports do not mix well. + // We can make them work okay for the binary format, + // but they're going to break weirdly for text/JSON. + enc := "_" + ms.sym + "_OneofMarshaler" + dec := "_" + ms.sym + "_OneofUnmarshaler" + size := "_" + ms.sym + "_OneofSizer" + encSig := "(msg " + g.Pkg["proto"] + ".Message, b *" + g.Pkg["proto"] + ".Buffer) error" + decSig := "(msg " + g.Pkg["proto"] + ".Message, tag, wire int, b *" + g.Pkg["proto"] + ".Buffer) (bool, error)" + sizeSig := "(msg " + g.Pkg["proto"] + ".Message) int" + g.P("func (m *", ms.sym, ") XXX_OneofFuncs() (func", encSig, ", func", decSig, ", func", sizeSig, ", []interface{}) {") + g.P("return ", enc, ", ", dec, ", ", size, ", nil") + g.P("}") + + g.P("func ", enc, encSig, " {") + g.P("m := msg.(*", ms.sym, ")") + g.P("m0 := (*", remoteSym, ")(m)") + g.P("enc, _, _, _ := m0.XXX_OneofFuncs()") + g.P("return enc(m0, b)") + g.P("}") + + g.P("func ", dec, decSig, " {") + g.P("m := msg.(*", ms.sym, ")") + g.P("m0 := (*", remoteSym, ")(m)") + g.P("_, dec, _, _ := m0.XXX_OneofFuncs()") + g.P("return dec(m0, tag, wire, b)") + g.P("}") + + g.P("func ", size, sizeSig, " {") + g.P("m := msg.(*", ms.sym, ")") + g.P("m0 := (*", remoteSym, ")(m)") + g.P("_, _, size, _ := m0.XXX_OneofFuncs()") + g.P("return size(m0)") + g.P("}") + } + for _, get := range ms.getters { + + if get.typeName != "" { + g.RecordTypeUse(get.typeName) + } + typ := get.typ + val := "(*" + remoteSym + ")(m)." + get.name + "()" + if get.genType { + // typ will be "*pkg.T" (message/group) or "pkg.T" (enum) + // or "map[t]*pkg.T" (map to message/enum). + // The first two of those might have a "[]" prefix if it is repeated. + // Drop any package qualifier since we have hoisted the type into this package. + rep := strings.HasPrefix(typ, "[]") + if rep { + typ = typ[2:] + } + isMap := strings.HasPrefix(typ, "map[") + star := typ[0] == '*' + if !isMap { // map types handled lower down + typ = typ[strings.Index(typ, ".")+1:] + } + if star { + typ = "*" + typ + } + if rep { + // Go does not permit conversion between slice types where both + // element types are named. That means we need to generate a bit + // of code in this situation. + // typ is the element type. + // val is the expression to get the slice from the imported type. + + ctyp := typ // conversion type expression; "Foo" or "(*Foo)" + if star { + ctyp = "(" + typ + ")" + } + + g.P("func (m *", ms.sym, ") ", get.name, "() []", typ, " {") + g.In() + g.P("o := ", val) + g.P("if o == nil {") + g.In() + g.P("return nil") + g.Out() + g.P("}") + g.P("s := make([]", typ, ", len(o))") + g.P("for i, x := range o {") + g.In() + g.P("s[i] = ", ctyp, "(x)") + g.Out() + g.P("}") + g.P("return s") + g.Out() + g.P("}") + continue + } + if isMap { + // Split map[keyTyp]valTyp. + bra, ket := strings.Index(typ, "["), strings.Index(typ, "]") + keyTyp, valTyp := typ[bra+1:ket], typ[ket+1:] + // Drop any package qualifier. + // Only the value type may be foreign. + star := valTyp[0] == '*' + valTyp = valTyp[strings.Index(valTyp, ".")+1:] + if star { + valTyp = "*" + valTyp + } + + typ := "map[" + keyTyp + "]" + valTyp + g.P("func (m *", ms.sym, ") ", get.name, "() ", typ, " {") + g.P("o := ", val) + g.P("if o == nil { return nil }") + g.P("s := make(", typ, ", len(o))") + g.P("for k, v := range o {") + g.P("s[k] = (", valTyp, ")(v)") + g.P("}") + g.P("return s") + g.P("}") + continue + } + // Convert imported type into the forwarding type. + val = "(" + typ + ")(" + val + ")" + } + + g.P("func (m *", ms.sym, ") ", get.name, "() ", typ, " { return ", val, " }") + } + +} + +type enumSymbol struct { + name string + proto3 bool // Whether this came from a proto3 file. +} + +func (es enumSymbol) GenerateAlias(g *Generator, pkg string) { + s := es.name + g.P("type ", s, " ", pkg, ".", s) + g.P("var ", s, "_name = ", pkg, ".", s, "_name") + g.P("var ", s, "_value = ", pkg, ".", s, "_value") + g.P("func (x ", s, ") String() string { return (", pkg, ".", s, ")(x).String() }") + if !es.proto3 { + g.P("func (x ", s, ") Enum() *", s, "{ return (*", s, ")((", pkg, ".", s, ")(x).Enum()) }") + g.P("func (x *", s, ") UnmarshalJSON(data []byte) error { return (*", pkg, ".", s, ")(x).UnmarshalJSON(data) }") + } +} + +type constOrVarSymbol struct { + sym string + typ string // either "const" or "var" + cast string // if non-empty, a type cast is required (used for enums) +} + +func (cs constOrVarSymbol) GenerateAlias(g *Generator, pkg string) { + v := pkg + "." + cs.sym + if cs.cast != "" { + v = cs.cast + "(" + v + ")" + } + g.P(cs.typ, " ", cs.sym, " = ", v) +} + +// Object is an interface abstracting the abilities shared by enums, messages, extensions and imported objects. +type Object interface { + PackageName() string // The name we use in our output (a_b_c), possibly renamed for uniqueness. + TypeName() []string + File() *descriptor.FileDescriptorProto +} + +// Each package name we generate must be unique. The package we're generating +// gets its own name but every other package must have a unique name that does +// not conflict in the code we generate. These names are chosen globally (although +// they don't have to be, it simplifies things to do them globally). +func uniquePackageOf(fd *descriptor.FileDescriptorProto) string { + s, ok := uniquePackageName[fd] + if !ok { + log.Fatal("internal error: no package name defined for " + fd.GetName()) + } + return s +} + +// Generator is the type whose methods generate the output, stored in the associated response structure. +type Generator struct { + *bytes.Buffer + + Request *plugin.CodeGeneratorRequest // The input. + Response *plugin.CodeGeneratorResponse // The output. + + Param map[string]string // Command-line parameters. + PackageImportPath string // Go import path of the package we're generating code for + ImportPrefix string // String to prefix to imported package file names. + ImportMap map[string]string // Mapping from import name to generated name + + Pkg map[string]string // The names under which we import support packages + + packageName string // What we're calling ourselves. + allFiles []*FileDescriptor // All files in the tree + allFilesByName map[string]*FileDescriptor // All files by filename. + genFiles []*FileDescriptor // Those files we will generate output for. + file *FileDescriptor // The file we are compiling now. + usedPackages map[string]bool // Names of packages used in current file. + typeNameToObject map[string]Object // Key is a fully-qualified name in input syntax. + init []string // Lines to emit in the init function. + indent string + writeOutput bool +} + +// New creates a new generator and allocates the request and response protobufs. +func New() *Generator { + g := new(Generator) + g.Buffer = new(bytes.Buffer) + g.Request = new(plugin.CodeGeneratorRequest) + g.Response = new(plugin.CodeGeneratorResponse) + return g +} + +// Error reports a problem, including an error, and exits the program. +func (g *Generator) Error(err error, msgs ...string) { + s := strings.Join(msgs, " ") + ":" + err.Error() + log.Print("protoc-gen-go: error:", s) + os.Exit(1) +} + +// Fail reports a problem and exits the program. +func (g *Generator) Fail(msgs ...string) { + s := strings.Join(msgs, " ") + log.Print("protoc-gen-go: error:", s) + os.Exit(1) +} + +// CommandLineParameters breaks the comma-separated list of key=value pairs +// in the parameter (a member of the request protobuf) into a key/value map. +// It then sets file name mappings defined by those entries. +func (g *Generator) CommandLineParameters(parameter string) { + g.Param = make(map[string]string) + for _, p := range strings.Split(parameter, ",") { + if i := strings.Index(p, "="); i < 0 { + g.Param[p] = "" + } else { + g.Param[p[0:i]] = p[i+1:] + } + } + + g.ImportMap = make(map[string]string) + pluginList := "none" // Default list of plugin names to enable (empty means all). + for k, v := range g.Param { + switch k { + case "import_prefix": + g.ImportPrefix = v + case "import_path": + g.PackageImportPath = v + case "plugins": + pluginList = v + default: + if len(k) > 0 && k[0] == 'M' { + g.ImportMap[k[1:]] = v + } + } + } + + if pluginList != "" { + // Amend the set of plugins. + enabled := make(map[string]bool) + for _, name := range strings.Split(pluginList, "+") { + enabled[name] = true + } + var nplugins []Plugin + for _, p := range plugins { + if enabled[p.Name()] { + nplugins = append(nplugins, p) + } + } + plugins = nplugins + } +} + +// DefaultPackageName returns the package name printed for the object. +// If its file is in a different package, it returns the package name we're using for this file, plus ".". +// Otherwise it returns the empty string. +func (g *Generator) DefaultPackageName(obj Object) string { + pkg := obj.PackageName() + if pkg == g.packageName { + return "" + } + return pkg + "." +} + +// For each input file, the unique package name to use, underscored. +var uniquePackageName = make(map[*descriptor.FileDescriptorProto]string) + +// Package names already registered. Key is the name from the .proto file; +// value is the name that appears in the generated code. +var pkgNamesInUse = make(map[string]bool) + +// Create and remember a guaranteed unique package name for this file descriptor. +// Pkg is the candidate name. If f is nil, it's a builtin package like "proto" and +// has no file descriptor. +func RegisterUniquePackageName(pkg string, f *FileDescriptor) string { + // Convert dots to underscores before finding a unique alias. + pkg = strings.Map(badToUnderscore, pkg) + + for i, orig := 1, pkg; pkgNamesInUse[pkg]; i++ { + // It's a duplicate; must rename. + pkg = orig + strconv.Itoa(i) + } + // Install it. + pkgNamesInUse[pkg] = true + if f != nil { + uniquePackageName[f.FileDescriptorProto] = pkg + } + return pkg +} + +var isGoKeyword = map[string]bool{ + "break": true, + "case": true, + "chan": true, + "const": true, + "continue": true, + "default": true, + "else": true, + "defer": true, + "fallthrough": true, + "for": true, + "func": true, + "go": true, + "goto": true, + "if": true, + "import": true, + "interface": true, + "map": true, + "package": true, + "range": true, + "return": true, + "select": true, + "struct": true, + "switch": true, + "type": true, + "var": true, +} + +// defaultGoPackage returns the package name to use, +// derived from the import path of the package we're building code for. +func (g *Generator) defaultGoPackage() string { + p := g.PackageImportPath + if i := strings.LastIndex(p, "/"); i >= 0 { + p = p[i+1:] + } + if p == "" { + return "" + } + + p = strings.Map(badToUnderscore, p) + // Identifier must not be keyword: insert _. + if isGoKeyword[p] { + p = "_" + p + } + // Identifier must not begin with digit: insert _. + if r, _ := utf8.DecodeRuneInString(p); unicode.IsDigit(r) { + p = "_" + p + } + return p +} + +// SetPackageNames sets the package name for this run. +// The package name must agree across all files being generated. +// It also defines unique package names for all imported files. +func (g *Generator) SetPackageNames() { + // Register the name for this package. It will be the first name + // registered so is guaranteed to be unmodified. + pkg, explicit := g.genFiles[0].goPackageName() + + // Check all files for an explicit go_package option. + for _, f := range g.genFiles { + thisPkg, thisExplicit := f.goPackageName() + if thisExplicit { + if !explicit { + // Let this file's go_package option serve for all input files. + pkg, explicit = thisPkg, true + } else if thisPkg != pkg { + g.Fail("inconsistent package names:", thisPkg, pkg) + } + } + } + + // If we don't have an explicit go_package option but we have an + // import path, use that. + if !explicit { + p := g.defaultGoPackage() + if p != "" { + pkg, explicit = p, true + } + } + + // If there was no go_package and no import path to use, + // double-check that all the inputs have the same implicit + // Go package name. + if !explicit { + for _, f := range g.genFiles { + thisPkg, _ := f.goPackageName() + if thisPkg != pkg { + g.Fail("inconsistent package names:", thisPkg, pkg) + } + } + } + + g.packageName = RegisterUniquePackageName(pkg, g.genFiles[0]) + + // Register the support package names. They might collide with the + // name of a package we import. + g.Pkg = map[string]string{ + "fmt": RegisterUniquePackageName("fmt", nil), + "math": RegisterUniquePackageName("math", nil), + "proto": RegisterUniquePackageName("proto", nil), + } + +AllFiles: + for _, f := range g.allFiles { + for _, genf := range g.genFiles { + if f == genf { + // In this package already. + uniquePackageName[f.FileDescriptorProto] = g.packageName + continue AllFiles + } + } + // The file is a dependency, so we want to ignore its go_package option + // because that is only relevant for its specific generated output. + pkg := f.GetPackage() + if pkg == "" { + pkg = baseName(*f.Name) + } + RegisterUniquePackageName(pkg, f) + } +} + +// WrapTypes walks the incoming data, wrapping DescriptorProtos, EnumDescriptorProtos +// and FileDescriptorProtos into file-referenced objects within the Generator. +// It also creates the list of files to generate and so should be called before GenerateAllFiles. +func (g *Generator) WrapTypes() { + g.allFiles = make([]*FileDescriptor, len(g.Request.ProtoFile)) + g.allFilesByName = make(map[string]*FileDescriptor, len(g.allFiles)) + for i, f := range g.Request.ProtoFile { + // We must wrap the descriptors before we wrap the enums + descs := wrapDescriptors(f) + g.buildNestedDescriptors(descs) + enums := wrapEnumDescriptors(f, descs) + g.buildNestedEnums(descs, enums) + exts := wrapExtensions(f) + fd := &FileDescriptor{ + FileDescriptorProto: f, + desc: descs, + enum: enums, + ext: exts, + exported: make(map[Object][]symbol), + proto3: fileIsProto3(f), + } + extractComments(fd) + g.allFiles[i] = fd + g.allFilesByName[f.GetName()] = fd + } + for _, fd := range g.allFiles { + fd.imp = wrapImported(fd.FileDescriptorProto, g) + } + + g.genFiles = make([]*FileDescriptor, len(g.Request.FileToGenerate)) + for i, fileName := range g.Request.FileToGenerate { + g.genFiles[i] = g.allFilesByName[fileName] + if g.genFiles[i] == nil { + g.Fail("could not find file named", fileName) + } + g.genFiles[i].index = i + } + g.Response.File = make([]*plugin.CodeGeneratorResponse_File, len(g.genFiles)) +} + +// Scan the descriptors in this file. For each one, build the slice of nested descriptors +func (g *Generator) buildNestedDescriptors(descs []*Descriptor) { + for _, desc := range descs { + if len(desc.NestedType) != 0 { + for _, nest := range descs { + if nest.parent == desc { + desc.nested = append(desc.nested, nest) + } + } + if len(desc.nested) != len(desc.NestedType) { + g.Fail("internal error: nesting failure for", desc.GetName()) + } + } + } +} + +func (g *Generator) buildNestedEnums(descs []*Descriptor, enums []*EnumDescriptor) { + for _, desc := range descs { + if len(desc.EnumType) != 0 { + for _, enum := range enums { + if enum.parent == desc { + desc.enums = append(desc.enums, enum) + } + } + if len(desc.enums) != len(desc.EnumType) { + g.Fail("internal error: enum nesting failure for", desc.GetName()) + } + } + } +} + +// Construct the Descriptor +func newDescriptor(desc *descriptor.DescriptorProto, parent *Descriptor, file *descriptor.FileDescriptorProto, index int) *Descriptor { + d := &Descriptor{ + common: common{file}, + DescriptorProto: desc, + parent: parent, + index: index, + } + if parent == nil { + d.path = fmt.Sprintf("%d,%d", messagePath, index) + } else { + d.path = fmt.Sprintf("%s,%d,%d", parent.path, messageMessagePath, index) + } + + // The only way to distinguish a group from a message is whether + // the containing message has a TYPE_GROUP field that matches. + if parent != nil { + parts := d.TypeName() + if file.Package != nil { + parts = append([]string{*file.Package}, parts...) + } + exp := "." + strings.Join(parts, ".") + for _, field := range parent.Field { + if field.GetType() == descriptor.FieldDescriptorProto_TYPE_GROUP && field.GetTypeName() == exp { + d.group = true + break + } + } + } + + d.ext = make([]*ExtensionDescriptor, len(desc.Extension)) + for i, field := range desc.Extension { + d.ext[i] = &ExtensionDescriptor{common{file}, field, d} + } + + return d +} + +// Return a slice of all the Descriptors defined within this file +func wrapDescriptors(file *descriptor.FileDescriptorProto) []*Descriptor { + sl := make([]*Descriptor, 0, len(file.MessageType)+10) + for i, desc := range file.MessageType { + sl = wrapThisDescriptor(sl, desc, nil, file, i) + } + return sl +} + +// Wrap this Descriptor, recursively +func wrapThisDescriptor(sl []*Descriptor, desc *descriptor.DescriptorProto, parent *Descriptor, file *descriptor.FileDescriptorProto, index int) []*Descriptor { + sl = append(sl, newDescriptor(desc, parent, file, index)) + me := sl[len(sl)-1] + for i, nested := range desc.NestedType { + sl = wrapThisDescriptor(sl, nested, me, file, i) + } + return sl +} + +// Construct the EnumDescriptor +func newEnumDescriptor(desc *descriptor.EnumDescriptorProto, parent *Descriptor, file *descriptor.FileDescriptorProto, index int) *EnumDescriptor { + ed := &EnumDescriptor{ + common: common{file}, + EnumDescriptorProto: desc, + parent: parent, + index: index, + } + if parent == nil { + ed.path = fmt.Sprintf("%d,%d", enumPath, index) + } else { + ed.path = fmt.Sprintf("%s,%d,%d", parent.path, messageEnumPath, index) + } + return ed +} + +// Return a slice of all the EnumDescriptors defined within this file +func wrapEnumDescriptors(file *descriptor.FileDescriptorProto, descs []*Descriptor) []*EnumDescriptor { + sl := make([]*EnumDescriptor, 0, len(file.EnumType)+10) + // Top-level enums. + for i, enum := range file.EnumType { + sl = append(sl, newEnumDescriptor(enum, nil, file, i)) + } + // Enums within messages. Enums within embedded messages appear in the outer-most message. + for _, nested := range descs { + for i, enum := range nested.EnumType { + sl = append(sl, newEnumDescriptor(enum, nested, file, i)) + } + } + return sl +} + +// Return a slice of all the top-level ExtensionDescriptors defined within this file. +func wrapExtensions(file *descriptor.FileDescriptorProto) []*ExtensionDescriptor { + sl := make([]*ExtensionDescriptor, len(file.Extension)) + for i, field := range file.Extension { + sl[i] = &ExtensionDescriptor{common{file}, field, nil} + } + return sl +} + +// Return a slice of all the types that are publicly imported into this file. +func wrapImported(file *descriptor.FileDescriptorProto, g *Generator) (sl []*ImportedDescriptor) { + for _, index := range file.PublicDependency { + df := g.fileByName(file.Dependency[index]) + for _, d := range df.desc { + if d.GetOptions().GetMapEntry() { + continue + } + sl = append(sl, &ImportedDescriptor{common{file}, d}) + } + for _, e := range df.enum { + sl = append(sl, &ImportedDescriptor{common{file}, e}) + } + for _, ext := range df.ext { + sl = append(sl, &ImportedDescriptor{common{file}, ext}) + } + } + return +} + +func extractComments(file *FileDescriptor) { + file.comments = make(map[string]*descriptor.SourceCodeInfo_Location) + for _, loc := range file.GetSourceCodeInfo().GetLocation() { + if loc.LeadingComments == nil { + continue + } + var p []string + for _, n := range loc.Path { + p = append(p, strconv.Itoa(int(n))) + } + file.comments[strings.Join(p, ",")] = loc + } +} + +// BuildTypeNameMap builds the map from fully qualified type names to objects. +// The key names for the map come from the input data, which puts a period at the beginning. +// It should be called after SetPackageNames and before GenerateAllFiles. +func (g *Generator) BuildTypeNameMap() { + g.typeNameToObject = make(map[string]Object) + for _, f := range g.allFiles { + // The names in this loop are defined by the proto world, not us, so the + // package name may be empty. If so, the dotted package name of X will + // be ".X"; otherwise it will be ".pkg.X". + dottedPkg := "." + f.GetPackage() + if dottedPkg != "." { + dottedPkg += "." + } + for _, enum := range f.enum { + name := dottedPkg + dottedSlice(enum.TypeName()) + g.typeNameToObject[name] = enum + } + for _, desc := range f.desc { + name := dottedPkg + dottedSlice(desc.TypeName()) + g.typeNameToObject[name] = desc + } + } +} + +// ObjectNamed, given a fully-qualified input type name as it appears in the input data, +// returns the descriptor for the message or enum with that name. +func (g *Generator) ObjectNamed(typeName string) Object { + o, ok := g.typeNameToObject[typeName] + if !ok { + g.Fail("can't find object with type", typeName) + } + + // If the file of this object isn't a direct dependency of the current file, + // or in the current file, then this object has been publicly imported into + // a dependency of the current file. + // We should return the ImportedDescriptor object for it instead. + direct := *o.File().Name == *g.file.Name + if !direct { + for _, dep := range g.file.Dependency { + if *g.fileByName(dep).Name == *o.File().Name { + direct = true + break + } + } + } + if !direct { + found := false + Loop: + for _, dep := range g.file.Dependency { + df := g.fileByName(*g.fileByName(dep).Name) + for _, td := range df.imp { + if td.o == o { + // Found it! + o = td + found = true + break Loop + } + } + } + if !found { + log.Printf("protoc-gen-go: WARNING: failed finding publicly imported dependency for %v, used in %v", typeName, *g.file.Name) + } + } + + return o +} + +// P prints the arguments to the generated output. It handles strings and int32s, plus +// handling indirections because they may be *string, etc. +func (g *Generator) P(str ...interface{}) { + if !g.writeOutput { + return + } + g.WriteString(g.indent) + for _, v := range str { + switch s := v.(type) { + case string: + g.WriteString(s) + case *string: + g.WriteString(*s) + case bool: + fmt.Fprintf(g, "%t", s) + case *bool: + fmt.Fprintf(g, "%t", *s) + case int: + fmt.Fprintf(g, "%d", s) + case *int32: + fmt.Fprintf(g, "%d", *s) + case *int64: + fmt.Fprintf(g, "%d", *s) + case float64: + fmt.Fprintf(g, "%g", s) + case *float64: + fmt.Fprintf(g, "%g", *s) + default: + g.Fail(fmt.Sprintf("unknown type in printer: %T", v)) + } + } + g.WriteByte('\n') +} + +// addInitf stores the given statement to be printed inside the file's init function. +// The statement is given as a format specifier and arguments. +func (g *Generator) addInitf(stmt string, a ...interface{}) { + g.init = append(g.init, fmt.Sprintf(stmt, a...)) +} + +// In Indents the output one tab stop. +func (g *Generator) In() { g.indent += "\t" } + +// Out unindents the output one tab stop. +func (g *Generator) Out() { + if len(g.indent) > 0 { + g.indent = g.indent[1:] + } +} + +// GenerateAllFiles generates the output for all the files we're outputting. +func (g *Generator) GenerateAllFiles() { + // Initialize the plugins + for _, p := range plugins { + p.Init(g) + } + // Generate the output. The generator runs for every file, even the files + // that we don't generate output for, so that we can collate the full list + // of exported symbols to support public imports. + genFileMap := make(map[*FileDescriptor]bool, len(g.genFiles)) + for _, file := range g.genFiles { + genFileMap[file] = true + } + i := 0 + for _, file := range g.allFiles { + g.Reset() + g.writeOutput = genFileMap[file] + g.generate(file) + if !g.writeOutput { + continue + } + g.Response.File[i] = new(plugin.CodeGeneratorResponse_File) + g.Response.File[i].Name = proto.String(goFileName(*file.Name)) + g.Response.File[i].Content = proto.String(g.String()) + i++ + } +} + +// Run all the plugins associated with the file. +func (g *Generator) runPlugins(file *FileDescriptor) { + for _, p := range plugins { + p.Generate(file) + } +} + +// FileOf return the FileDescriptor for this FileDescriptorProto. +func (g *Generator) FileOf(fd *descriptor.FileDescriptorProto) *FileDescriptor { + for _, file := range g.allFiles { + if file.FileDescriptorProto == fd { + return file + } + } + g.Fail("could not find file in table:", fd.GetName()) + return nil +} + +// Fill the response protocol buffer with the generated output for all the files we're +// supposed to generate. +func (g *Generator) generate(file *FileDescriptor) { + g.file = g.FileOf(file.FileDescriptorProto) + g.usedPackages = make(map[string]bool) + + if g.file.index == 0 { + // For one file in the package, assert version compatibility. + g.P("// This is a compile-time assertion to ensure that this generated file") + g.P("// is compatible with the proto package it is being compiled against.") + g.P("const _ = ", g.Pkg["proto"], ".ProtoPackageIsVersion", generatedCodeVersion) + g.P() + } + + for _, td := range g.file.imp { + g.generateImported(td) + } + for _, enum := range g.file.enum { + g.generateEnum(enum) + } + for _, desc := range g.file.desc { + // Don't generate virtual messages for maps. + if desc.GetOptions().GetMapEntry() { + continue + } + g.generateMessage(desc) + } + for _, ext := range g.file.ext { + g.generateExtension(ext) + } + g.generateInitFunction() + + // Run the plugins before the imports so we know which imports are necessary. + g.runPlugins(file) + + g.generateFileDescriptor(file) + + // Generate header and imports last, though they appear first in the output. + rem := g.Buffer + g.Buffer = new(bytes.Buffer) + g.generateHeader() + g.generateImports() + if !g.writeOutput { + return + } + g.Write(rem.Bytes()) + + // Reformat generated code. + fset := token.NewFileSet() + raw := g.Bytes() + ast, err := parser.ParseFile(fset, "", g, parser.ParseComments) + if err != nil { + // Print out the bad code with line numbers. + // This should never happen in practice, but it can while changing generated code, + // so consider this a debugging aid. + var src bytes.Buffer + s := bufio.NewScanner(bytes.NewReader(raw)) + for line := 1; s.Scan(); line++ { + fmt.Fprintf(&src, "%5d\t%s\n", line, s.Bytes()) + } + g.Fail("bad Go source code was generated:", err.Error(), "\n"+src.String()) + } + g.Reset() + err = (&printer.Config{Mode: printer.TabIndent | printer.UseSpaces, Tabwidth: 8}).Fprint(g, fset, ast) + if err != nil { + g.Fail("generated Go source code could not be reformatted:", err.Error()) + } +} + +// Generate the header, including package definition +func (g *Generator) generateHeader() { + g.P("// Code generated by protoc-gen-go.") + g.P("// source: ", g.file.Name) + g.P("// DO NOT EDIT!") + g.P() + + name := g.file.PackageName() + + if g.file.index == 0 { + // Generate package docs for the first file in the package. + g.P("/*") + g.P("Package ", name, " is a generated protocol buffer package.") + g.P() + if loc, ok := g.file.comments[strconv.Itoa(packagePath)]; ok { + // not using g.PrintComments because this is a /* */ comment block. + text := strings.TrimSuffix(loc.GetLeadingComments(), "\n") + for _, line := range strings.Split(text, "\n") { + line = strings.TrimPrefix(line, " ") + // ensure we don't escape from the block comment + line = strings.Replace(line, "*/", "* /", -1) + g.P(line) + } + g.P() + } + var topMsgs []string + g.P("It is generated from these files:") + for _, f := range g.genFiles { + g.P("\t", f.Name) + for _, msg := range f.desc { + if msg.parent != nil { + continue + } + topMsgs = append(topMsgs, CamelCaseSlice(msg.TypeName())) + } + } + g.P() + g.P("It has these top-level messages:") + for _, msg := range topMsgs { + g.P("\t", msg) + } + g.P("*/") + } + + g.P("package ", name) + g.P() +} + +// PrintComments prints any comments from the source .proto file. +// The path is a comma-separated list of integers. +// It returns an indication of whether any comments were printed. +// See descriptor.proto for its format. +func (g *Generator) PrintComments(path string) bool { + if !g.writeOutput { + return false + } + if loc, ok := g.file.comments[path]; ok { + text := strings.TrimSuffix(loc.GetLeadingComments(), "\n") + for _, line := range strings.Split(text, "\n") { + g.P("// ", strings.TrimPrefix(line, " ")) + } + return true + } + return false +} + +func (g *Generator) fileByName(filename string) *FileDescriptor { + return g.allFilesByName[filename] +} + +// weak returns whether the ith import of the current file is a weak import. +func (g *Generator) weak(i int32) bool { + for _, j := range g.file.WeakDependency { + if j == i { + return true + } + } + return false +} + +// Generate the imports +func (g *Generator) generateImports() { + // We almost always need a proto import. Rather than computing when we + // do, which is tricky when there's a plugin, just import it and + // reference it later. The same argument applies to the fmt and math packages. + g.P("import " + g.Pkg["proto"] + " " + strconv.Quote(g.ImportPrefix+"github.com/golang/protobuf/proto")) + g.P("import " + g.Pkg["fmt"] + ` "fmt"`) + g.P("import " + g.Pkg["math"] + ` "math"`) + for i, s := range g.file.Dependency { + fd := g.fileByName(s) + // Do not import our own package. + if fd.PackageName() == g.packageName { + continue + } + filename := goFileName(s) + // By default, import path is the dirname of the Go filename. + importPath := path.Dir(filename) + if substitution, ok := g.ImportMap[s]; ok { + importPath = substitution + } + importPath = g.ImportPrefix + importPath + // Skip weak imports. + if g.weak(int32(i)) { + g.P("// skipping weak import ", fd.PackageName(), " ", strconv.Quote(importPath)) + continue + } + // We need to import all the dependencies, even if we don't reference them, + // because other code and tools depend on having the full transitive closure + // of protocol buffer types in the binary. + pname := fd.PackageName() + if _, ok := g.usedPackages[pname]; !ok { + pname = "_" + } + g.P("import ", pname, " ", strconv.Quote(importPath)) + } + g.P() + // TODO: may need to worry about uniqueness across plugins + for _, p := range plugins { + p.GenerateImports(g.file) + g.P() + } + g.P("// Reference imports to suppress errors if they are not otherwise used.") + g.P("var _ = ", g.Pkg["proto"], ".Marshal") + g.P("var _ = ", g.Pkg["fmt"], ".Errorf") + g.P("var _ = ", g.Pkg["math"], ".Inf") + g.P() +} + +func (g *Generator) generateImported(id *ImportedDescriptor) { + // Don't generate public import symbols for files that we are generating + // code for, since those symbols will already be in this package. + // We can't simply avoid creating the ImportedDescriptor objects, + // because g.genFiles isn't populated at that stage. + tn := id.TypeName() + sn := tn[len(tn)-1] + df := g.FileOf(id.o.File()) + filename := *df.Name + for _, fd := range g.genFiles { + if *fd.Name == filename { + g.P("// Ignoring public import of ", sn, " from ", filename) + g.P() + return + } + } + g.P("// ", sn, " from public import ", filename) + g.usedPackages[df.PackageName()] = true + + for _, sym := range df.exported[id.o] { + sym.GenerateAlias(g, df.PackageName()) + } + + g.P() +} + +// Generate the enum definitions for this EnumDescriptor. +func (g *Generator) generateEnum(enum *EnumDescriptor) { + // The full type name + typeName := enum.TypeName() + // The full type name, CamelCased. + ccTypeName := CamelCaseSlice(typeName) + ccPrefix := enum.prefix() + + g.PrintComments(enum.path) + g.P("type ", ccTypeName, " int32") + g.file.addExport(enum, enumSymbol{ccTypeName, enum.proto3()}) + g.P("const (") + g.In() + for i, e := range enum.Value { + g.PrintComments(fmt.Sprintf("%s,%d,%d", enum.path, enumValuePath, i)) + + name := ccPrefix + *e.Name + g.P(name, " ", ccTypeName, " = ", e.Number) + g.file.addExport(enum, constOrVarSymbol{name, "const", ccTypeName}) + } + g.Out() + g.P(")") + g.P("var ", ccTypeName, "_name = map[int32]string{") + g.In() + generated := make(map[int32]bool) // avoid duplicate values + for _, e := range enum.Value { + duplicate := "" + if _, present := generated[*e.Number]; present { + duplicate = "// Duplicate value: " + } + g.P(duplicate, e.Number, ": ", strconv.Quote(*e.Name), ",") + generated[*e.Number] = true + } + g.Out() + g.P("}") + g.P("var ", ccTypeName, "_value = map[string]int32{") + g.In() + for _, e := range enum.Value { + g.P(strconv.Quote(*e.Name), ": ", e.Number, ",") + } + g.Out() + g.P("}") + + if !enum.proto3() { + g.P("func (x ", ccTypeName, ") Enum() *", ccTypeName, " {") + g.In() + g.P("p := new(", ccTypeName, ")") + g.P("*p = x") + g.P("return p") + g.Out() + g.P("}") + } + + g.P("func (x ", ccTypeName, ") String() string {") + g.In() + g.P("return ", g.Pkg["proto"], ".EnumName(", ccTypeName, "_name, int32(x))") + g.Out() + g.P("}") + + if !enum.proto3() { + g.P("func (x *", ccTypeName, ") UnmarshalJSON(data []byte) error {") + g.In() + g.P("value, err := ", g.Pkg["proto"], ".UnmarshalJSONEnum(", ccTypeName, `_value, data, "`, ccTypeName, `")`) + g.P("if err != nil {") + g.In() + g.P("return err") + g.Out() + g.P("}") + g.P("*x = ", ccTypeName, "(value)") + g.P("return nil") + g.Out() + g.P("}") + } + + var indexes []string + for m := enum.parent; m != nil; m = m.parent { + // XXX: skip groups? + indexes = append([]string{strconv.Itoa(m.index)}, indexes...) + } + indexes = append(indexes, strconv.Itoa(enum.index)) + g.P("func (", ccTypeName, ") EnumDescriptor() ([]byte, []int) { return fileDescriptor", g.file.index, ", []int{", strings.Join(indexes, ", "), "} }") + + g.P() +} + +// The tag is a string like "varint,2,opt,name=fieldname,def=7" that +// identifies details of the field for the protocol buffer marshaling and unmarshaling +// code. The fields are: +// wire encoding +// protocol tag number +// opt,req,rep for optional, required, or repeated +// packed whether the encoding is "packed" (optional; repeated primitives only) +// name= the original declared name +// enum= the name of the enum type if it is an enum-typed field. +// proto3 if this field is in a proto3 message +// def= string representation of the default value, if any. +// The default value must be in a representation that can be used at run-time +// to generate the default value. Thus bools become 0 and 1, for instance. +func (g *Generator) goTag(message *Descriptor, field *descriptor.FieldDescriptorProto, wiretype string) string { + optrepreq := "" + switch { + case isOptional(field): + optrepreq = "opt" + case isRequired(field): + optrepreq = "req" + case isRepeated(field): + optrepreq = "rep" + } + var defaultValue string + if dv := field.DefaultValue; dv != nil { // set means an explicit default + defaultValue = *dv + // Some types need tweaking. + switch *field.Type { + case descriptor.FieldDescriptorProto_TYPE_BOOL: + if defaultValue == "true" { + defaultValue = "1" + } else { + defaultValue = "0" + } + case descriptor.FieldDescriptorProto_TYPE_STRING, + descriptor.FieldDescriptorProto_TYPE_BYTES: + // Nothing to do. Quoting is done for the whole tag. + case descriptor.FieldDescriptorProto_TYPE_ENUM: + // For enums we need to provide the integer constant. + obj := g.ObjectNamed(field.GetTypeName()) + if id, ok := obj.(*ImportedDescriptor); ok { + // It is an enum that was publicly imported. + // We need the underlying type. + obj = id.o + } + enum, ok := obj.(*EnumDescriptor) + if !ok { + log.Printf("obj is a %T", obj) + if id, ok := obj.(*ImportedDescriptor); ok { + log.Printf("id.o is a %T", id.o) + } + g.Fail("unknown enum type", CamelCaseSlice(obj.TypeName())) + } + defaultValue = enum.integerValueAsString(defaultValue) + } + defaultValue = ",def=" + defaultValue + } + enum := "" + if *field.Type == descriptor.FieldDescriptorProto_TYPE_ENUM { + // We avoid using obj.PackageName(), because we want to use the + // original (proto-world) package name. + obj := g.ObjectNamed(field.GetTypeName()) + if id, ok := obj.(*ImportedDescriptor); ok { + obj = id.o + } + enum = ",enum=" + if pkg := obj.File().GetPackage(); pkg != "" { + enum += pkg + "." + } + enum += CamelCaseSlice(obj.TypeName()) + } + packed := "" + if field.Options != nil && field.Options.GetPacked() { + packed = ",packed" + } + fieldName := field.GetName() + name := fieldName + if *field.Type == descriptor.FieldDescriptorProto_TYPE_GROUP { + // We must use the type name for groups instead of + // the field name to preserve capitalization. + // type_name in FieldDescriptorProto is fully-qualified, + // but we only want the local part. + name = *field.TypeName + if i := strings.LastIndex(name, "."); i >= 0 { + name = name[i+1:] + } + } + name = ",name=" + name + if message.proto3() { + // We only need the extra tag for []byte fields; + // no need to add noise for the others. + if *field.Type == descriptor.FieldDescriptorProto_TYPE_BYTES { + name += ",proto3" + } + + } + oneof := "" + if field.OneofIndex != nil { + oneof = ",oneof" + } + return strconv.Quote(fmt.Sprintf("%s,%d,%s%s%s%s%s%s", + wiretype, + field.GetNumber(), + optrepreq, + packed, + name, + enum, + oneof, + defaultValue)) +} + +func needsStar(typ descriptor.FieldDescriptorProto_Type) bool { + switch typ { + case descriptor.FieldDescriptorProto_TYPE_GROUP: + return false + case descriptor.FieldDescriptorProto_TYPE_MESSAGE: + return false + case descriptor.FieldDescriptorProto_TYPE_BYTES: + return false + } + return true +} + +// TypeName is the printed name appropriate for an item. If the object is in the current file, +// TypeName drops the package name and underscores the rest. +// Otherwise the object is from another package; and the result is the underscored +// package name followed by the item name. +// The result always has an initial capital. +func (g *Generator) TypeName(obj Object) string { + return g.DefaultPackageName(obj) + CamelCaseSlice(obj.TypeName()) +} + +// TypeNameWithPackage is like TypeName, but always includes the package +// name even if the object is in our own package. +func (g *Generator) TypeNameWithPackage(obj Object) string { + return obj.PackageName() + CamelCaseSlice(obj.TypeName()) +} + +// GoType returns a string representing the type name, and the wire type +func (g *Generator) GoType(message *Descriptor, field *descriptor.FieldDescriptorProto) (typ string, wire string) { + // TODO: Options. + switch *field.Type { + case descriptor.FieldDescriptorProto_TYPE_DOUBLE: + typ, wire = "float64", "fixed64" + case descriptor.FieldDescriptorProto_TYPE_FLOAT: + typ, wire = "float32", "fixed32" + case descriptor.FieldDescriptorProto_TYPE_INT64: + typ, wire = "int64", "varint" + case descriptor.FieldDescriptorProto_TYPE_UINT64: + typ, wire = "uint64", "varint" + case descriptor.FieldDescriptorProto_TYPE_INT32: + typ, wire = "int32", "varint" + case descriptor.FieldDescriptorProto_TYPE_UINT32: + typ, wire = "uint32", "varint" + case descriptor.FieldDescriptorProto_TYPE_FIXED64: + typ, wire = "uint64", "fixed64" + case descriptor.FieldDescriptorProto_TYPE_FIXED32: + typ, wire = "uint32", "fixed32" + case descriptor.FieldDescriptorProto_TYPE_BOOL: + typ, wire = "bool", "varint" + case descriptor.FieldDescriptorProto_TYPE_STRING: + typ, wire = "string", "bytes" + case descriptor.FieldDescriptorProto_TYPE_GROUP: + desc := g.ObjectNamed(field.GetTypeName()) + typ, wire = "*"+g.TypeName(desc), "group" + case descriptor.FieldDescriptorProto_TYPE_MESSAGE: + desc := g.ObjectNamed(field.GetTypeName()) + typ, wire = "*"+g.TypeName(desc), "bytes" + case descriptor.FieldDescriptorProto_TYPE_BYTES: + typ, wire = "[]byte", "bytes" + case descriptor.FieldDescriptorProto_TYPE_ENUM: + desc := g.ObjectNamed(field.GetTypeName()) + typ, wire = g.TypeName(desc), "varint" + case descriptor.FieldDescriptorProto_TYPE_SFIXED32: + typ, wire = "int32", "fixed32" + case descriptor.FieldDescriptorProto_TYPE_SFIXED64: + typ, wire = "int64", "fixed64" + case descriptor.FieldDescriptorProto_TYPE_SINT32: + typ, wire = "int32", "zigzag32" + case descriptor.FieldDescriptorProto_TYPE_SINT64: + typ, wire = "int64", "zigzag64" + default: + g.Fail("unknown type for", field.GetName()) + } + if isRepeated(field) { + typ = "[]" + typ + } else if message != nil && message.proto3() { + return + } else if field.OneofIndex != nil && message != nil { + return + } else if needsStar(*field.Type) { + typ = "*" + typ + } + return +} + +func (g *Generator) RecordTypeUse(t string) { + if obj, ok := g.typeNameToObject[t]; ok { + // Call ObjectNamed to get the true object to record the use. + obj = g.ObjectNamed(t) + g.usedPackages[obj.PackageName()] = true + } +} + +// Method names that may be generated. Fields with these names get an +// underscore appended. +var methodNames = [...]string{ + "Reset", + "String", + "ProtoMessage", + "Marshal", + "Unmarshal", + "ExtensionRangeArray", + "ExtensionMap", + "Descriptor", +} + +// Generate the type and default constant definitions for this Descriptor. +func (g *Generator) generateMessage(message *Descriptor) { + // The full type name + typeName := message.TypeName() + // The full type name, CamelCased. + ccTypeName := CamelCaseSlice(typeName) + + usedNames := make(map[string]bool) + for _, n := range methodNames { + usedNames[n] = true + } + fieldNames := make(map[*descriptor.FieldDescriptorProto]string) + fieldGetterNames := make(map[*descriptor.FieldDescriptorProto]string) + fieldTypes := make(map[*descriptor.FieldDescriptorProto]string) + mapFieldTypes := make(map[*descriptor.FieldDescriptorProto]string) + + oneofFieldName := make(map[int32]string) // indexed by oneof_index field of FieldDescriptorProto + oneofDisc := make(map[int32]string) // name of discriminator method + oneofTypeName := make(map[*descriptor.FieldDescriptorProto]string) // without star + oneofInsertPoints := make(map[int32]int) // oneof_index => offset of g.Buffer + + g.PrintComments(message.path) + g.P("type ", ccTypeName, " struct {") + g.In() + + // allocNames finds a conflict-free variation of the given strings, + // consistently mutating their suffixes. + // It returns the same number of strings. + allocNames := func(ns ...string) []string { + Loop: + for { + for _, n := range ns { + if usedNames[n] { + for i := range ns { + ns[i] += "_" + } + continue Loop + } + } + for _, n := range ns { + usedNames[n] = true + } + return ns + } + } + + for i, field := range message.Field { + // Allocate the getter and the field at the same time so name + // collisions create field/method consistent names. + // TODO: This allocation occurs based on the order of the fields + // in the proto file, meaning that a change in the field + // ordering can change generated Method/Field names. + base := CamelCase(*field.Name) + ns := allocNames(base, "Get"+base) + fieldName, fieldGetterName := ns[0], ns[1] + typename, wiretype := g.GoType(message, field) + jsonName := *field.Name + tag := fmt.Sprintf("protobuf:%s json:%q", g.goTag(message, field, wiretype), jsonName+",omitempty") + + fieldNames[field] = fieldName + fieldGetterNames[field] = fieldGetterName + + oneof := field.OneofIndex != nil + if oneof && oneofFieldName[*field.OneofIndex] == "" { + odp := message.OneofDecl[int(*field.OneofIndex)] + fname := allocNames(CamelCase(odp.GetName()))[0] + + // This is the first field of a oneof we haven't seen before. + // Generate the union field. + com := g.PrintComments(fmt.Sprintf("%s,%d,%d", message.path, messageOneofPath, *field.OneofIndex)) + if com { + g.P("//") + } + g.P("// Types that are valid to be assigned to ", fname, ":") + // Generate the rest of this comment later, + // when we've computed any disambiguation. + oneofInsertPoints[*field.OneofIndex] = g.Buffer.Len() + + dname := "is" + ccTypeName + "_" + fname + oneofFieldName[*field.OneofIndex] = fname + oneofDisc[*field.OneofIndex] = dname + tag := `protobuf_oneof:"` + odp.GetName() + `"` + g.P(fname, " ", dname, " `", tag, "`") + } + + if *field.Type == descriptor.FieldDescriptorProto_TYPE_MESSAGE { + desc := g.ObjectNamed(field.GetTypeName()) + if d, ok := desc.(*Descriptor); ok && d.GetOptions().GetMapEntry() { + // Figure out the Go types and tags for the key and value types. + keyField, valField := d.Field[0], d.Field[1] + keyType, keyWire := g.GoType(d, keyField) + valType, valWire := g.GoType(d, valField) + keyTag, valTag := g.goTag(d, keyField, keyWire), g.goTag(d, valField, valWire) + + // We don't use stars, except for message-typed values. + // Message and enum types are the only two possibly foreign types used in maps, + // so record their use. They are not permitted as map keys. + keyType = strings.TrimPrefix(keyType, "*") + switch *valField.Type { + case descriptor.FieldDescriptorProto_TYPE_ENUM: + valType = strings.TrimPrefix(valType, "*") + g.RecordTypeUse(valField.GetTypeName()) + case descriptor.FieldDescriptorProto_TYPE_MESSAGE: + g.RecordTypeUse(valField.GetTypeName()) + default: + valType = strings.TrimPrefix(valType, "*") + } + + typename = fmt.Sprintf("map[%s]%s", keyType, valType) + mapFieldTypes[field] = typename // record for the getter generation + + tag += fmt.Sprintf(" protobuf_key:%s protobuf_val:%s", keyTag, valTag) + } + } + + fieldTypes[field] = typename + + if oneof { + tname := ccTypeName + "_" + fieldName + // It is possible for this to collide with a message or enum + // nested in this message. Check for collisions. + for { + ok := true + for _, desc := range message.nested { + if CamelCaseSlice(desc.TypeName()) == tname { + ok = false + break + } + } + for _, enum := range message.enums { + if CamelCaseSlice(enum.TypeName()) == tname { + ok = false + break + } + } + if !ok { + tname += "_" + continue + } + break + } + + oneofTypeName[field] = tname + continue + } + + g.PrintComments(fmt.Sprintf("%s,%d,%d", message.path, messageFieldPath, i)) + g.P(fieldName, "\t", typename, "\t`", tag, "`") + g.RecordTypeUse(field.GetTypeName()) + } + if len(message.ExtensionRange) > 0 { + g.P("XXX_extensions\t\tmap[int32]", g.Pkg["proto"], ".Extension `json:\"-\"`") + } + if !message.proto3() { + g.P("XXX_unrecognized\t[]byte `json:\"-\"`") + } + g.Out() + g.P("}") + + // Update g.Buffer to list valid oneof types. + // We do this down here, after we've disambiguated the oneof type names. + // We go in reverse order of insertion point to avoid invalidating offsets. + for oi := int32(len(message.OneofDecl)); oi >= 0; oi-- { + ip := oneofInsertPoints[oi] + all := g.Buffer.Bytes() + rem := all[ip:] + g.Buffer = bytes.NewBuffer(all[:ip:ip]) // set cap so we don't scribble on rem + for _, field := range message.Field { + if field.OneofIndex == nil || *field.OneofIndex != oi { + continue + } + g.P("//\t*", oneofTypeName[field]) + } + g.Buffer.Write(rem) + } + + // Reset, String and ProtoMessage methods. + g.P("func (m *", ccTypeName, ") Reset() { *m = ", ccTypeName, "{} }") + g.P("func (m *", ccTypeName, ") String() string { return ", g.Pkg["proto"], ".CompactTextString(m) }") + g.P("func (*", ccTypeName, ") ProtoMessage() {}") + if !message.group { + var indexes []string + for m := message; m != nil; m = m.parent { + // XXX: skip groups? + indexes = append([]string{strconv.Itoa(m.index)}, indexes...) + } + g.P("func (*", ccTypeName, ") Descriptor() ([]byte, []int) { return fileDescriptor", g.file.index, ", []int{", strings.Join(indexes, ", "), "} }") + } + + // Extension support methods + var hasExtensions, isMessageSet bool + if len(message.ExtensionRange) > 0 { + hasExtensions = true + // message_set_wire_format only makes sense when extensions are defined. + if opts := message.Options; opts != nil && opts.GetMessageSetWireFormat() { + isMessageSet = true + g.P() + g.P("func (m *", ccTypeName, ") Marshal() ([]byte, error) {") + g.In() + g.P("return ", g.Pkg["proto"], ".MarshalMessageSet(m.ExtensionMap())") + g.Out() + g.P("}") + g.P("func (m *", ccTypeName, ") Unmarshal(buf []byte) error {") + g.In() + g.P("return ", g.Pkg["proto"], ".UnmarshalMessageSet(buf, m.ExtensionMap())") + g.Out() + g.P("}") + g.P("func (m *", ccTypeName, ") MarshalJSON() ([]byte, error) {") + g.In() + g.P("return ", g.Pkg["proto"], ".MarshalMessageSetJSON(m.XXX_extensions)") + g.Out() + g.P("}") + g.P("func (m *", ccTypeName, ") UnmarshalJSON(buf []byte) error {") + g.In() + g.P("return ", g.Pkg["proto"], ".UnmarshalMessageSetJSON(buf, m.XXX_extensions)") + g.Out() + g.P("}") + g.P("// ensure ", ccTypeName, " satisfies proto.Marshaler and proto.Unmarshaler") + g.P("var _ ", g.Pkg["proto"], ".Marshaler = (*", ccTypeName, ")(nil)") + g.P("var _ ", g.Pkg["proto"], ".Unmarshaler = (*", ccTypeName, ")(nil)") + } + + g.P() + g.P("var extRange_", ccTypeName, " = []", g.Pkg["proto"], ".ExtensionRange{") + g.In() + for _, r := range message.ExtensionRange { + end := fmt.Sprint(*r.End - 1) // make range inclusive on both ends + g.P("{", r.Start, ", ", end, "},") + } + g.Out() + g.P("}") + g.P("func (*", ccTypeName, ") ExtensionRangeArray() []", g.Pkg["proto"], ".ExtensionRange {") + g.In() + g.P("return extRange_", ccTypeName) + g.Out() + g.P("}") + g.P("func (m *", ccTypeName, ") ExtensionMap() map[int32]", g.Pkg["proto"], ".Extension {") + g.In() + g.P("if m.XXX_extensions == nil {") + g.In() + g.P("m.XXX_extensions = make(map[int32]", g.Pkg["proto"], ".Extension)") + g.Out() + g.P("}") + g.P("return m.XXX_extensions") + g.Out() + g.P("}") + } + + // Default constants + defNames := make(map[*descriptor.FieldDescriptorProto]string) + for _, field := range message.Field { + def := field.GetDefaultValue() + if def == "" { + continue + } + fieldname := "Default_" + ccTypeName + "_" + CamelCase(*field.Name) + defNames[field] = fieldname + typename, _ := g.GoType(message, field) + if typename[0] == '*' { + typename = typename[1:] + } + kind := "const " + switch { + case typename == "bool": + case typename == "string": + def = strconv.Quote(def) + case typename == "[]byte": + def = "[]byte(" + strconv.Quote(def) + ")" + kind = "var " + case def == "inf", def == "-inf", def == "nan": + // These names are known to, and defined by, the protocol language. + switch def { + case "inf": + def = "math.Inf(1)" + case "-inf": + def = "math.Inf(-1)" + case "nan": + def = "math.NaN()" + } + if *field.Type == descriptor.FieldDescriptorProto_TYPE_FLOAT { + def = "float32(" + def + ")" + } + kind = "var " + case *field.Type == descriptor.FieldDescriptorProto_TYPE_ENUM: + // Must be an enum. Need to construct the prefixed name. + obj := g.ObjectNamed(field.GetTypeName()) + var enum *EnumDescriptor + if id, ok := obj.(*ImportedDescriptor); ok { + // The enum type has been publicly imported. + enum, _ = id.o.(*EnumDescriptor) + } else { + enum, _ = obj.(*EnumDescriptor) + } + if enum == nil { + log.Printf("don't know how to generate constant for %s", fieldname) + continue + } + def = g.DefaultPackageName(obj) + enum.prefix() + def + } + g.P(kind, fieldname, " ", typename, " = ", def) + g.file.addExport(message, constOrVarSymbol{fieldname, kind, ""}) + } + g.P() + + // Oneof per-field types, discriminants and getters. + // + // Generate unexported named types for the discriminant interfaces. + // We shouldn't have to do this, but there was (~19 Aug 2015) a compiler/linker bug + // that was triggered by using anonymous interfaces here. + // TODO: Revisit this and consider reverting back to anonymous interfaces. + for oi := range message.OneofDecl { + dname := oneofDisc[int32(oi)] + g.P("type ", dname, " interface { ", dname, "() }") + } + g.P() + for _, field := range message.Field { + if field.OneofIndex == nil { + continue + } + _, wiretype := g.GoType(message, field) + tag := "protobuf:" + g.goTag(message, field, wiretype) + g.P("type ", oneofTypeName[field], " struct{ ", fieldNames[field], " ", fieldTypes[field], " `", tag, "` }") + g.RecordTypeUse(field.GetTypeName()) + } + g.P() + for _, field := range message.Field { + if field.OneofIndex == nil { + continue + } + g.P("func (*", oneofTypeName[field], ") ", oneofDisc[*field.OneofIndex], "() {}") + } + g.P() + for oi := range message.OneofDecl { + fname := oneofFieldName[int32(oi)] + g.P("func (m *", ccTypeName, ") Get", fname, "() ", oneofDisc[int32(oi)], " {") + g.P("if m != nil { return m.", fname, " }") + g.P("return nil") + g.P("}") + } + g.P() + + // Field getters + var getters []getterSymbol + for _, field := range message.Field { + oneof := field.OneofIndex != nil + + fname := fieldNames[field] + typename, _ := g.GoType(message, field) + if t, ok := mapFieldTypes[field]; ok { + typename = t + } + mname := fieldGetterNames[field] + star := "" + if needsStar(*field.Type) && typename[0] == '*' { + typename = typename[1:] + star = "*" + } + + // In proto3, only generate getters for message fields and oneof fields. + if message.proto3() && *field.Type != descriptor.FieldDescriptorProto_TYPE_MESSAGE && !oneof { + continue + } + + // Only export getter symbols for basic types, + // and for messages and enums in the same package. + // Groups are not exported. + // Foreign types can't be hoisted through a public import because + // the importer may not already be importing the defining .proto. + // As an example, imagine we have an import tree like this: + // A.proto -> B.proto -> C.proto + // If A publicly imports B, we need to generate the getters from B in A's output, + // but if one such getter returns something from C then we cannot do that + // because A is not importing C already. + var getter, genType bool + switch *field.Type { + case descriptor.FieldDescriptorProto_TYPE_GROUP: + getter = false + case descriptor.FieldDescriptorProto_TYPE_MESSAGE, descriptor.FieldDescriptorProto_TYPE_ENUM: + // Only export getter if its return type is in this package. + getter = g.ObjectNamed(field.GetTypeName()).PackageName() == message.PackageName() + genType = true + default: + getter = true + } + if getter { + getters = append(getters, getterSymbol{ + name: mname, + typ: typename, + typeName: field.GetTypeName(), + genType: genType, + }) + } + + g.P("func (m *", ccTypeName, ") "+mname+"() "+typename+" {") + g.In() + def, hasDef := defNames[field] + typeDefaultIsNil := false // whether this field type's default value is a literal nil unless specified + switch *field.Type { + case descriptor.FieldDescriptorProto_TYPE_BYTES: + typeDefaultIsNil = !hasDef + case descriptor.FieldDescriptorProto_TYPE_GROUP, descriptor.FieldDescriptorProto_TYPE_MESSAGE: + typeDefaultIsNil = true + } + if isRepeated(field) { + typeDefaultIsNil = true + } + if typeDefaultIsNil && !oneof { + // A bytes field with no explicit default needs less generated code, + // as does a message or group field, or a repeated field. + g.P("if m != nil {") + g.In() + g.P("return m." + fname) + g.Out() + g.P("}") + g.P("return nil") + g.Out() + g.P("}") + g.P() + continue + } + if !oneof { + g.P("if m != nil && m." + fname + " != nil {") + g.In() + g.P("return " + star + "m." + fname) + g.Out() + g.P("}") + } else { + uname := oneofFieldName[*field.OneofIndex] + tname := oneofTypeName[field] + g.P("if x, ok := m.Get", uname, "().(*", tname, "); ok {") + g.P("return x.", fname) + g.P("}") + } + if hasDef { + if *field.Type != descriptor.FieldDescriptorProto_TYPE_BYTES { + g.P("return " + def) + } else { + // The default is a []byte var. + // Make a copy when returning it to be safe. + g.P("return append([]byte(nil), ", def, "...)") + } + } else { + switch *field.Type { + case descriptor.FieldDescriptorProto_TYPE_BOOL: + g.P("return false") + case descriptor.FieldDescriptorProto_TYPE_STRING: + g.P(`return ""`) + case descriptor.FieldDescriptorProto_TYPE_GROUP, + descriptor.FieldDescriptorProto_TYPE_MESSAGE, + descriptor.FieldDescriptorProto_TYPE_BYTES: + // This is only possible for oneof fields. + g.P("return nil") + case descriptor.FieldDescriptorProto_TYPE_ENUM: + // The default default for an enum is the first value in the enum, + // not zero. + obj := g.ObjectNamed(field.GetTypeName()) + var enum *EnumDescriptor + if id, ok := obj.(*ImportedDescriptor); ok { + // The enum type has been publicly imported. + enum, _ = id.o.(*EnumDescriptor) + } else { + enum, _ = obj.(*EnumDescriptor) + } + if enum == nil { + log.Printf("don't know how to generate getter for %s", field.GetName()) + continue + } + if len(enum.Value) == 0 { + g.P("return 0 // empty enum") + } else { + first := enum.Value[0].GetName() + g.P("return ", g.DefaultPackageName(obj)+enum.prefix()+first) + } + default: + g.P("return 0") + } + } + g.Out() + g.P("}") + g.P() + } + + if !message.group { + ms := &messageSymbol{ + sym: ccTypeName, + hasExtensions: hasExtensions, + isMessageSet: isMessageSet, + hasOneof: len(message.OneofDecl) > 0, + getters: getters, + } + g.file.addExport(message, ms) + } + + // Oneof functions + if len(message.OneofDecl) > 0 { + fieldWire := make(map[*descriptor.FieldDescriptorProto]string) + + // method + enc := "_" + ccTypeName + "_OneofMarshaler" + dec := "_" + ccTypeName + "_OneofUnmarshaler" + size := "_" + ccTypeName + "_OneofSizer" + encSig := "(msg " + g.Pkg["proto"] + ".Message, b *" + g.Pkg["proto"] + ".Buffer) error" + decSig := "(msg " + g.Pkg["proto"] + ".Message, tag, wire int, b *" + g.Pkg["proto"] + ".Buffer) (bool, error)" + sizeSig := "(msg " + g.Pkg["proto"] + ".Message) (n int)" + + g.P("// XXX_OneofFuncs is for the internal use of the proto package.") + g.P("func (*", ccTypeName, ") XXX_OneofFuncs() (func", encSig, ", func", decSig, ", func", sizeSig, ", []interface{}) {") + g.P("return ", enc, ", ", dec, ", ", size, ", []interface{}{") + for _, field := range message.Field { + if field.OneofIndex == nil { + continue + } + g.P("(*", oneofTypeName[field], ")(nil),") + } + g.P("}") + g.P("}") + g.P() + + // marshaler + g.P("func ", enc, encSig, " {") + g.P("m := msg.(*", ccTypeName, ")") + for oi, odp := range message.OneofDecl { + g.P("// ", odp.GetName()) + fname := oneofFieldName[int32(oi)] + g.P("switch x := m.", fname, ".(type) {") + for _, field := range message.Field { + if field.OneofIndex == nil || int(*field.OneofIndex) != oi { + continue + } + g.P("case *", oneofTypeName[field], ":") + var wire, pre, post string + val := "x." + fieldNames[field] // overridden for TYPE_BOOL + canFail := false // only TYPE_MESSAGE and TYPE_GROUP can fail + switch *field.Type { + case descriptor.FieldDescriptorProto_TYPE_DOUBLE: + wire = "WireFixed64" + pre = "b.EncodeFixed64(" + g.Pkg["math"] + ".Float64bits(" + post = "))" + case descriptor.FieldDescriptorProto_TYPE_FLOAT: + wire = "WireFixed32" + pre = "b.EncodeFixed32(uint64(" + g.Pkg["math"] + ".Float32bits(" + post = ")))" + case descriptor.FieldDescriptorProto_TYPE_INT64, + descriptor.FieldDescriptorProto_TYPE_UINT64: + wire = "WireVarint" + pre, post = "b.EncodeVarint(uint64(", "))" + case descriptor.FieldDescriptorProto_TYPE_INT32, + descriptor.FieldDescriptorProto_TYPE_UINT32, + descriptor.FieldDescriptorProto_TYPE_ENUM: + wire = "WireVarint" + pre, post = "b.EncodeVarint(uint64(", "))" + case descriptor.FieldDescriptorProto_TYPE_FIXED64, + descriptor.FieldDescriptorProto_TYPE_SFIXED64: + wire = "WireFixed64" + pre, post = "b.EncodeFixed64(uint64(", "))" + case descriptor.FieldDescriptorProto_TYPE_FIXED32, + descriptor.FieldDescriptorProto_TYPE_SFIXED32: + wire = "WireFixed32" + pre, post = "b.EncodeFixed32(uint64(", "))" + case descriptor.FieldDescriptorProto_TYPE_BOOL: + // bool needs special handling. + g.P("t := uint64(0)") + g.P("if ", val, " { t = 1 }") + val = "t" + wire = "WireVarint" + pre, post = "b.EncodeVarint(", ")" + case descriptor.FieldDescriptorProto_TYPE_STRING: + wire = "WireBytes" + pre, post = "b.EncodeStringBytes(", ")" + case descriptor.FieldDescriptorProto_TYPE_GROUP: + wire = "WireStartGroup" + pre, post = "b.Marshal(", ")" + canFail = true + case descriptor.FieldDescriptorProto_TYPE_MESSAGE: + wire = "WireBytes" + pre, post = "b.EncodeMessage(", ")" + canFail = true + case descriptor.FieldDescriptorProto_TYPE_BYTES: + wire = "WireBytes" + pre, post = "b.EncodeRawBytes(", ")" + case descriptor.FieldDescriptorProto_TYPE_SINT32: + wire = "WireVarint" + pre, post = "b.EncodeZigzag32(uint64(", "))" + case descriptor.FieldDescriptorProto_TYPE_SINT64: + wire = "WireVarint" + pre, post = "b.EncodeZigzag64(uint64(", "))" + default: + g.Fail("unhandled oneof field type ", field.Type.String()) + } + fieldWire[field] = wire + g.P("b.EncodeVarint(", field.Number, "<<3|", g.Pkg["proto"], ".", wire, ")") + if !canFail { + g.P(pre, val, post) + } else { + g.P("if err := ", pre, val, post, "; err != nil {") + g.P("return err") + g.P("}") + } + if *field.Type == descriptor.FieldDescriptorProto_TYPE_GROUP { + g.P("b.EncodeVarint(", field.Number, "<<3|", g.Pkg["proto"], ".WireEndGroup)") + } + } + g.P("case nil:") + g.P("default: return ", g.Pkg["fmt"], `.Errorf("`, ccTypeName, ".", fname, ` has unexpected type %T", x)`) + g.P("}") + } + g.P("return nil") + g.P("}") + g.P() + + // unmarshaler + g.P("func ", dec, decSig, " {") + g.P("m := msg.(*", ccTypeName, ")") + g.P("switch tag {") + for _, field := range message.Field { + if field.OneofIndex == nil { + continue + } + odp := message.OneofDecl[int(*field.OneofIndex)] + g.P("case ", field.Number, ": // ", odp.GetName(), ".", *field.Name) + g.P("if wire != ", g.Pkg["proto"], ".", fieldWire[field], " {") + g.P("return true, ", g.Pkg["proto"], ".ErrInternalBadWireType") + g.P("}") + lhs := "x, err" // overridden for TYPE_MESSAGE and TYPE_GROUP + var dec, cast, cast2 string + switch *field.Type { + case descriptor.FieldDescriptorProto_TYPE_DOUBLE: + dec, cast = "b.DecodeFixed64()", g.Pkg["math"]+".Float64frombits" + case descriptor.FieldDescriptorProto_TYPE_FLOAT: + dec, cast, cast2 = "b.DecodeFixed32()", "uint32", g.Pkg["math"]+".Float32frombits" + case descriptor.FieldDescriptorProto_TYPE_INT64: + dec, cast = "b.DecodeVarint()", "int64" + case descriptor.FieldDescriptorProto_TYPE_UINT64: + dec = "b.DecodeVarint()" + case descriptor.FieldDescriptorProto_TYPE_INT32: + dec, cast = "b.DecodeVarint()", "int32" + case descriptor.FieldDescriptorProto_TYPE_FIXED64: + dec = "b.DecodeFixed64()" + case descriptor.FieldDescriptorProto_TYPE_FIXED32: + dec, cast = "b.DecodeFixed32()", "uint32" + case descriptor.FieldDescriptorProto_TYPE_BOOL: + dec = "b.DecodeVarint()" + // handled specially below + case descriptor.FieldDescriptorProto_TYPE_STRING: + dec = "b.DecodeStringBytes()" + case descriptor.FieldDescriptorProto_TYPE_GROUP: + g.P("msg := new(", fieldTypes[field][1:], ")") // drop star + lhs = "err" + dec = "b.DecodeGroup(msg)" + // handled specially below + case descriptor.FieldDescriptorProto_TYPE_MESSAGE: + g.P("msg := new(", fieldTypes[field][1:], ")") // drop star + lhs = "err" + dec = "b.DecodeMessage(msg)" + // handled specially below + case descriptor.FieldDescriptorProto_TYPE_BYTES: + dec = "b.DecodeRawBytes(true)" + case descriptor.FieldDescriptorProto_TYPE_UINT32: + dec, cast = "b.DecodeVarint()", "uint32" + case descriptor.FieldDescriptorProto_TYPE_ENUM: + dec, cast = "b.DecodeVarint()", fieldTypes[field] + case descriptor.FieldDescriptorProto_TYPE_SFIXED32: + dec, cast = "b.DecodeFixed32()", "int32" + case descriptor.FieldDescriptorProto_TYPE_SFIXED64: + dec, cast = "b.DecodeFixed64()", "int64" + case descriptor.FieldDescriptorProto_TYPE_SINT32: + dec, cast = "b.DecodeZigzag32()", "int32" + case descriptor.FieldDescriptorProto_TYPE_SINT64: + dec, cast = "b.DecodeZigzag64()", "int64" + default: + g.Fail("unhandled oneof field type ", field.Type.String()) + } + g.P(lhs, " := ", dec) + val := "x" + if cast != "" { + val = cast + "(" + val + ")" + } + if cast2 != "" { + val = cast2 + "(" + val + ")" + } + switch *field.Type { + case descriptor.FieldDescriptorProto_TYPE_BOOL: + val += " != 0" + case descriptor.FieldDescriptorProto_TYPE_GROUP, + descriptor.FieldDescriptorProto_TYPE_MESSAGE: + val = "msg" + } + g.P("m.", oneofFieldName[*field.OneofIndex], " = &", oneofTypeName[field], "{", val, "}") + g.P("return true, err") + } + g.P("default: return false, nil") + g.P("}") + g.P("}") + g.P() + + // sizer + g.P("func ", size, sizeSig, " {") + g.P("m := msg.(*", ccTypeName, ")") + for oi, odp := range message.OneofDecl { + g.P("// ", odp.GetName()) + fname := oneofFieldName[int32(oi)] + g.P("switch x := m.", fname, ".(type) {") + for _, field := range message.Field { + if field.OneofIndex == nil || int(*field.OneofIndex) != oi { + continue + } + g.P("case *", oneofTypeName[field], ":") + val := "x." + fieldNames[field] + var wire, varint, fixed string + switch *field.Type { + case descriptor.FieldDescriptorProto_TYPE_DOUBLE: + wire = "WireFixed64" + fixed = "8" + case descriptor.FieldDescriptorProto_TYPE_FLOAT: + wire = "WireFixed32" + fixed = "4" + case descriptor.FieldDescriptorProto_TYPE_INT64, + descriptor.FieldDescriptorProto_TYPE_UINT64, + descriptor.FieldDescriptorProto_TYPE_INT32, + descriptor.FieldDescriptorProto_TYPE_UINT32, + descriptor.FieldDescriptorProto_TYPE_ENUM: + wire = "WireVarint" + varint = val + case descriptor.FieldDescriptorProto_TYPE_FIXED64, + descriptor.FieldDescriptorProto_TYPE_SFIXED64: + wire = "WireFixed64" + fixed = "8" + case descriptor.FieldDescriptorProto_TYPE_FIXED32, + descriptor.FieldDescriptorProto_TYPE_SFIXED32: + wire = "WireFixed32" + fixed = "4" + case descriptor.FieldDescriptorProto_TYPE_BOOL: + wire = "WireVarint" + fixed = "1" + case descriptor.FieldDescriptorProto_TYPE_STRING: + wire = "WireBytes" + fixed = "len(" + val + ")" + varint = fixed + case descriptor.FieldDescriptorProto_TYPE_GROUP: + wire = "WireStartGroup" + fixed = g.Pkg["proto"] + ".Size(" + val + ")" + case descriptor.FieldDescriptorProto_TYPE_MESSAGE: + wire = "WireBytes" + g.P("s := ", g.Pkg["proto"], ".Size(", val, ")") + fixed = "s" + varint = fixed + case descriptor.FieldDescriptorProto_TYPE_BYTES: + wire = "WireBytes" + fixed = "len(" + val + ")" + varint = fixed + case descriptor.FieldDescriptorProto_TYPE_SINT32: + wire = "WireVarint" + varint = "(uint32(" + val + ") << 1) ^ uint32((int32(" + val + ") >> 31))" + case descriptor.FieldDescriptorProto_TYPE_SINT64: + wire = "WireVarint" + varint = "uint64(" + val + " << 1) ^ uint64((int64(" + val + ") >> 63))" + default: + g.Fail("unhandled oneof field type ", field.Type.String()) + } + g.P("n += ", g.Pkg["proto"], ".SizeVarint(", field.Number, "<<3|", g.Pkg["proto"], ".", wire, ")") + if varint != "" { + g.P("n += ", g.Pkg["proto"], ".SizeVarint(uint64(", varint, "))") + } + if fixed != "" { + g.P("n += ", fixed) + } + if *field.Type == descriptor.FieldDescriptorProto_TYPE_GROUP { + g.P("n += ", g.Pkg["proto"], ".SizeVarint(", field.Number, "<<3|", g.Pkg["proto"], ".WireEndGroup)") + } + } + g.P("case nil:") + g.P("default:") + g.P("panic(", g.Pkg["fmt"], ".Sprintf(\"proto: unexpected type %T in oneof\", x))") + g.P("}") + } + g.P("return n") + g.P("}") + g.P() + } + + for _, ext := range message.ext { + g.generateExtension(ext) + } + + fullName := strings.Join(message.TypeName(), ".") + if g.file.Package != nil { + fullName = *g.file.Package + "." + fullName + } + + g.addInitf("%s.RegisterType((*%s)(nil), %q)", g.Pkg["proto"], ccTypeName, fullName) +} + +func (g *Generator) generateExtension(ext *ExtensionDescriptor) { + ccTypeName := ext.DescName() + + extObj := g.ObjectNamed(*ext.Extendee) + var extDesc *Descriptor + if id, ok := extObj.(*ImportedDescriptor); ok { + // This is extending a publicly imported message. + // We need the underlying type for goTag. + extDesc = id.o.(*Descriptor) + } else { + extDesc = extObj.(*Descriptor) + } + extendedType := "*" + g.TypeName(extObj) // always use the original + field := ext.FieldDescriptorProto + fieldType, wireType := g.GoType(ext.parent, field) + tag := g.goTag(extDesc, field, wireType) + g.RecordTypeUse(*ext.Extendee) + if n := ext.FieldDescriptorProto.TypeName; n != nil { + // foreign extension type + g.RecordTypeUse(*n) + } + + typeName := ext.TypeName() + + // Special case for proto2 message sets: If this extension is extending + // proto2_bridge.MessageSet, and its final name component is "message_set_extension", + // then drop that last component. + mset := false + if extendedType == "*proto2_bridge.MessageSet" && typeName[len(typeName)-1] == "message_set_extension" { + typeName = typeName[:len(typeName)-1] + mset = true + } + + // For text formatting, the package must be exactly what the .proto file declares, + // ignoring overrides such as the go_package option, and with no dot/underscore mapping. + extName := strings.Join(typeName, ".") + if g.file.Package != nil { + extName = *g.file.Package + "." + extName + } + + g.P("var ", ccTypeName, " = &", g.Pkg["proto"], ".ExtensionDesc{") + g.In() + g.P("ExtendedType: (", extendedType, ")(nil),") + g.P("ExtensionType: (", fieldType, ")(nil),") + g.P("Field: ", field.Number, ",") + g.P(`Name: "`, extName, `",`) + g.P("Tag: ", tag, ",") + + g.Out() + g.P("}") + g.P() + + if mset { + // Generate a bit more code to register with message_set.go. + g.addInitf("%s.RegisterMessageSetType((%s)(nil), %d, %q)", g.Pkg["proto"], fieldType, *field.Number, extName) + } + + g.file.addExport(ext, constOrVarSymbol{ccTypeName, "var", ""}) +} + +func (g *Generator) generateInitFunction() { + for _, enum := range g.file.enum { + g.generateEnumRegistration(enum) + } + for _, d := range g.file.desc { + for _, ext := range d.ext { + g.generateExtensionRegistration(ext) + } + } + for _, ext := range g.file.ext { + g.generateExtensionRegistration(ext) + } + if len(g.init) == 0 { + return + } + g.P("func init() {") + g.In() + for _, l := range g.init { + g.P(l) + } + g.Out() + g.P("}") + g.init = nil +} + +func (g *Generator) generateFileDescriptor(file *FileDescriptor) { + // Make a copy and trim source_code_info data. + // TODO: Trim this more when we know exactly what we need. + pb := proto.Clone(file.FileDescriptorProto).(*descriptor.FileDescriptorProto) + pb.SourceCodeInfo = nil + + b, err := proto.Marshal(pb) + if err != nil { + g.Fail(err.Error()) + } + + var buf bytes.Buffer + w, _ := gzip.NewWriterLevel(&buf, gzip.BestCompression) + w.Write(b) + w.Close() + b = buf.Bytes() + + g.P("var fileDescriptor", file.index, " = []byte{") + g.In() + g.P("// ", len(b), " bytes of a gzipped FileDescriptorProto") + for len(b) > 0 { + n := 16 + if n > len(b) { + n = len(b) + } + + s := "" + for _, c := range b[:n] { + s += fmt.Sprintf("0x%02x,", c) + } + g.P(s) + + b = b[n:] + } + g.Out() + g.P("}") +} + +func (g *Generator) generateEnumRegistration(enum *EnumDescriptor) { + // // We always print the full (proto-world) package name here. + pkg := enum.File().GetPackage() + if pkg != "" { + pkg += "." + } + // The full type name + typeName := enum.TypeName() + // The full type name, CamelCased. + ccTypeName := CamelCaseSlice(typeName) + g.addInitf("%s.RegisterEnum(%q, %[3]s_name, %[3]s_value)", g.Pkg["proto"], pkg+ccTypeName, ccTypeName) +} + +func (g *Generator) generateExtensionRegistration(ext *ExtensionDescriptor) { + g.addInitf("%s.RegisterExtension(%s)", g.Pkg["proto"], ext.DescName()) +} + +// And now lots of helper functions. + +// Is c an ASCII lower-case letter? +func isASCIILower(c byte) bool { + return 'a' <= c && c <= 'z' +} + +// Is c an ASCII digit? +func isASCIIDigit(c byte) bool { + return '0' <= c && c <= '9' +} + +// CamelCase returns the CamelCased name. +// If there is an interior underscore followed by a lower case letter, +// drop the underscore and convert the letter to upper case. +// There is a remote possibility of this rewrite causing a name collision, +// but it's so remote we're prepared to pretend it's nonexistent - since the +// C++ generator lowercases names, it's extremely unlikely to have two fields +// with different capitalizations. +// In short, _my_field_name_2 becomes XMyFieldName_2. +func CamelCase(s string) string { + if s == "" { + return "" + } + t := make([]byte, 0, 32) + i := 0 + if s[0] == '_' { + // Need a capital letter; drop the '_'. + t = append(t, 'X') + i++ + } + // Invariant: if the next letter is lower case, it must be converted + // to upper case. + // That is, we process a word at a time, where words are marked by _ or + // upper case letter. Digits are treated as words. + for ; i < len(s); i++ { + c := s[i] + if c == '_' && i+1 < len(s) && isASCIILower(s[i+1]) { + continue // Skip the underscore in s. + } + if isASCIIDigit(c) { + t = append(t, c) + continue + } + // Assume we have a letter now - if not, it's a bogus identifier. + // The next word is a sequence of characters that must start upper case. + if isASCIILower(c) { + c ^= ' ' // Make it a capital letter. + } + t = append(t, c) // Guaranteed not lower case. + // Accept lower case sequence that follows. + for i+1 < len(s) && isASCIILower(s[i+1]) { + i++ + t = append(t, s[i]) + } + } + return string(t) +} + +// CamelCaseSlice is like CamelCase, but the argument is a slice of strings to +// be joined with "_". +func CamelCaseSlice(elem []string) string { return CamelCase(strings.Join(elem, "_")) } + +// dottedSlice turns a sliced name into a dotted name. +func dottedSlice(elem []string) string { return strings.Join(elem, ".") } + +// Given a .proto file name, return the output name for the generated Go program. +func goFileName(name string) string { + ext := path.Ext(name) + if ext == ".proto" || ext == ".protodevel" { + name = name[0 : len(name)-len(ext)] + } + return name + ".pb.go" +} + +// Is this field optional? +func isOptional(field *descriptor.FieldDescriptorProto) bool { + return field.Label != nil && *field.Label == descriptor.FieldDescriptorProto_LABEL_OPTIONAL +} + +// Is this field required? +func isRequired(field *descriptor.FieldDescriptorProto) bool { + return field.Label != nil && *field.Label == descriptor.FieldDescriptorProto_LABEL_REQUIRED +} + +// Is this field repeated? +func isRepeated(field *descriptor.FieldDescriptorProto) bool { + return field.Label != nil && *field.Label == descriptor.FieldDescriptorProto_LABEL_REPEATED +} + +// badToUnderscore is the mapping function used to generate Go names from package names, +// which can be dotted in the input .proto file. It replaces non-identifier characters such as +// dot or dash with underscore. +func badToUnderscore(r rune) rune { + if unicode.IsLetter(r) || unicode.IsDigit(r) || r == '_' { + return r + } + return '_' +} + +// baseName returns the last path element of the name, with the last dotted suffix removed. +func baseName(name string) string { + // First, find the last element + if i := strings.LastIndex(name, "/"); i >= 0 { + name = name[i+1:] + } + // Now drop the suffix + if i := strings.LastIndex(name, "."); i >= 0 { + name = name[0:i] + } + return name +} + +// The SourceCodeInfo message describes the location of elements of a parsed +// .proto file by way of a "path", which is a sequence of integers that +// describe the route from a FileDescriptorProto to the relevant submessage. +// The path alternates between a field number of a repeated field, and an index +// into that repeated field. The constants below define the field numbers that +// are used. +// +// See descriptor.proto for more information about this. +const ( + // tag numbers in FileDescriptorProto + packagePath = 2 // package + messagePath = 4 // message_type + enumPath = 5 // enum_type + // tag numbers in DescriptorProto + messageFieldPath = 2 // field + messageMessagePath = 3 // nested_type + messageEnumPath = 4 // enum_type + messageOneofPath = 8 // oneof_decl + // tag numbers in EnumDescriptorProto + enumValuePath = 2 // value +) diff --git a/vendor/github.com/golang/protobuf/protoc-gen-go/internal/grpc/grpc.go b/vendor/github.com/golang/protobuf/protoc-gen-go/internal/grpc/grpc.go new file mode 100644 index 0000000000..f33f7011bf --- /dev/null +++ b/vendor/github.com/golang/protobuf/protoc-gen-go/internal/grpc/grpc.go @@ -0,0 +1,442 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2015 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +// Package grpc outputs gRPC service descriptions in Go code. +// It runs as a plugin for the Go protocol buffer compiler plugin. +// It is linked in to protoc-gen-go. +package grpc + +import ( + "fmt" + "path" + "strconv" + "strings" + + pb "github.com/golang/protobuf/protoc-gen-go/descriptor" + "github.com/golang/protobuf/protoc-gen-go/generator" +) + +// Paths for packages used by code generated in this file, +// relative to the import_prefix of the generator.Generator. +const ( + contextPkgPath = "golang.org/x/net/context" + grpcPkgPath = "google.golang.org/grpc" +) + +func init() { + generator.RegisterPlugin(new(grpc)) +} + +// grpc is an implementation of the Go protocol buffer compiler's +// plugin architecture. It generates bindings for gRPC support. +type grpc struct { + gen *generator.Generator +} + +// Name returns the name of this plugin, "grpc". +func (g *grpc) Name() string { + return "grpc" +} + +// The names for packages imported in the generated code. +// They may vary from the final path component of the import path +// if the name is used by other packages. +var ( + contextPkg string + grpcPkg string +) + +// Init initializes the plugin. +func (g *grpc) Init(gen *generator.Generator) { + g.gen = gen + contextPkg = generator.RegisterUniquePackageName("context", nil) + grpcPkg = generator.RegisterUniquePackageName("grpc", nil) +} + +// Given a type name defined in a .proto, return its object. +// Also record that we're using it, to guarantee the associated import. +func (g *grpc) objectNamed(name string) generator.Object { + g.gen.RecordTypeUse(name) + return g.gen.ObjectNamed(name) +} + +// Given a type name defined in a .proto, return its name as we will print it. +func (g *grpc) typeName(str string) string { + return g.gen.TypeName(g.objectNamed(str)) +} + +// P forwards to g.gen.P. +func (g *grpc) P(args ...interface{}) { g.gen.P(args...) } + +// Generate generates code for the services in the given file. +func (g *grpc) Generate(file *generator.FileDescriptor) { + if len(file.FileDescriptorProto.Service) == 0 { + return + } + g.P("// Reference imports to suppress errors if they are not otherwise used.") + g.P("var _ ", contextPkg, ".Context") + g.P("var _ ", grpcPkg, ".ClientConn") + g.P() + for i, service := range file.FileDescriptorProto.Service { + g.generateService(file, service, i) + } +} + +// GenerateImports generates the import declaration for this file. +func (g *grpc) GenerateImports(file *generator.FileDescriptor) { + if len(file.FileDescriptorProto.Service) == 0 { + return + } + g.P("import (") + g.P(contextPkg, " ", strconv.Quote(path.Join(g.gen.ImportPrefix, contextPkgPath))) + g.P(grpcPkg, " ", strconv.Quote(path.Join(g.gen.ImportPrefix, grpcPkgPath))) + g.P(")") + g.P() +} + +// reservedClientName records whether a client name is reserved on the client side. +var reservedClientName = map[string]bool{ +// TODO: do we need any in gRPC? +} + +func unexport(s string) string { return strings.ToLower(s[:1]) + s[1:] } + +// generateService generates all the code for the named service. +func (g *grpc) generateService(file *generator.FileDescriptor, service *pb.ServiceDescriptorProto, index int) { + path := fmt.Sprintf("6,%d", index) // 6 means service. + + origServName := service.GetName() + fullServName := origServName + if pkg := file.GetPackage(); pkg != "" { + fullServName = pkg + "." + fullServName + } + servName := generator.CamelCase(origServName) + + g.P() + g.P("// Client API for ", servName, " service") + g.P() + + // Client interface. + g.P("type ", servName, "Client interface {") + for i, method := range service.Method { + g.gen.PrintComments(fmt.Sprintf("%s,2,%d", path, i)) // 2 means method in a service. + g.P(g.generateClientSignature(servName, method)) + } + g.P("}") + g.P() + + // Client structure. + g.P("type ", unexport(servName), "Client struct {") + g.P("cc *", grpcPkg, ".ClientConn") + g.P("}") + g.P() + + // NewClient factory. + g.P("func New", servName, "Client (cc *", grpcPkg, ".ClientConn) ", servName, "Client {") + g.P("return &", unexport(servName), "Client{cc}") + g.P("}") + g.P() + + var methodIndex, streamIndex int + serviceDescVar := "_" + servName + "_serviceDesc" + // Client method implementations. + for _, method := range service.Method { + var descExpr string + if !method.GetServerStreaming() && !method.GetClientStreaming() { + // Unary RPC method + descExpr = fmt.Sprintf("&%s.Methods[%d]", serviceDescVar, methodIndex) + methodIndex++ + } else { + // Streaming RPC method + descExpr = fmt.Sprintf("&%s.Streams[%d]", serviceDescVar, streamIndex) + streamIndex++ + } + g.generateClientMethod(servName, fullServName, serviceDescVar, method, descExpr) + } + + g.P("// Server API for ", servName, " service") + g.P() + + // Server interface. + serverType := servName + "Server" + g.P("type ", serverType, " interface {") + for i, method := range service.Method { + g.gen.PrintComments(fmt.Sprintf("%s,2,%d", path, i)) // 2 means method in a service. + g.P(g.generateServerSignature(servName, method)) + } + g.P("}") + g.P() + + // Server registration. + g.P("func Register", servName, "Server(s *", grpcPkg, ".Server, srv ", serverType, ") {") + g.P("s.RegisterService(&", serviceDescVar, `, srv)`) + g.P("}") + g.P() + + // Server handler implementations. + var handlerNames []string + for _, method := range service.Method { + hname := g.generateServerMethod(servName, method) + handlerNames = append(handlerNames, hname) + } + + // Service descriptor. + g.P("var ", serviceDescVar, " = ", grpcPkg, ".ServiceDesc {") + g.P("ServiceName: ", strconv.Quote(fullServName), ",") + g.P("HandlerType: (*", serverType, ")(nil),") + g.P("Methods: []", grpcPkg, ".MethodDesc{") + for i, method := range service.Method { + if method.GetServerStreaming() || method.GetClientStreaming() { + continue + } + g.P("{") + g.P("MethodName: ", strconv.Quote(method.GetName()), ",") + g.P("Handler: ", handlerNames[i], ",") + g.P("},") + } + g.P("},") + g.P("Streams: []", grpcPkg, ".StreamDesc{") + for i, method := range service.Method { + if !method.GetServerStreaming() && !method.GetClientStreaming() { + continue + } + g.P("{") + g.P("StreamName: ", strconv.Quote(method.GetName()), ",") + g.P("Handler: ", handlerNames[i], ",") + if method.GetServerStreaming() { + g.P("ServerStreams: true,") + } + if method.GetClientStreaming() { + g.P("ClientStreams: true,") + } + g.P("},") + } + g.P("},") + g.P("}") + g.P() +} + +// generateClientSignature returns the client-side signature for a method. +func (g *grpc) generateClientSignature(servName string, method *pb.MethodDescriptorProto) string { + origMethName := method.GetName() + methName := generator.CamelCase(origMethName) + if reservedClientName[methName] { + methName += "_" + } + reqArg := ", in *" + g.typeName(method.GetInputType()) + if method.GetClientStreaming() { + reqArg = "" + } + respName := "*" + g.typeName(method.GetOutputType()) + if method.GetServerStreaming() || method.GetClientStreaming() { + respName = servName + "_" + generator.CamelCase(origMethName) + "Client" + } + return fmt.Sprintf("%s(ctx %s.Context%s, opts ...%s.CallOption) (%s, error)", methName, contextPkg, reqArg, grpcPkg, respName) +} + +func (g *grpc) generateClientMethod(servName, fullServName, serviceDescVar string, method *pb.MethodDescriptorProto, descExpr string) { + sname := fmt.Sprintf("/%s/%s", fullServName, method.GetName()) + methName := generator.CamelCase(method.GetName()) + inType := g.typeName(method.GetInputType()) + outType := g.typeName(method.GetOutputType()) + + g.P("func (c *", unexport(servName), "Client) ", g.generateClientSignature(servName, method), "{") + if !method.GetServerStreaming() && !method.GetClientStreaming() { + g.P("out := new(", outType, ")") + // TODO: Pass descExpr to Invoke. + g.P("err := ", grpcPkg, `.Invoke(ctx, "`, sname, `", in, out, c.cc, opts...)`) + g.P("if err != nil { return nil, err }") + g.P("return out, nil") + g.P("}") + g.P() + return + } + streamType := unexport(servName) + methName + "Client" + g.P("stream, err := ", grpcPkg, ".NewClientStream(ctx, ", descExpr, `, c.cc, "`, sname, `", opts...)`) + g.P("if err != nil { return nil, err }") + g.P("x := &", streamType, "{stream}") + if !method.GetClientStreaming() { + g.P("if err := x.ClientStream.SendMsg(in); err != nil { return nil, err }") + g.P("if err := x.ClientStream.CloseSend(); err != nil { return nil, err }") + } + g.P("return x, nil") + g.P("}") + g.P() + + genSend := method.GetClientStreaming() + genRecv := method.GetServerStreaming() + genCloseAndRecv := !method.GetServerStreaming() + + // Stream auxiliary types and methods. + g.P("type ", servName, "_", methName, "Client interface {") + if genSend { + g.P("Send(*", inType, ") error") + } + if genRecv { + g.P("Recv() (*", outType, ", error)") + } + if genCloseAndRecv { + g.P("CloseAndRecv() (*", outType, ", error)") + } + g.P(grpcPkg, ".ClientStream") + g.P("}") + g.P() + + g.P("type ", streamType, " struct {") + g.P(grpcPkg, ".ClientStream") + g.P("}") + g.P() + + if genSend { + g.P("func (x *", streamType, ") Send(m *", inType, ") error {") + g.P("return x.ClientStream.SendMsg(m)") + g.P("}") + g.P() + } + if genRecv { + g.P("func (x *", streamType, ") Recv() (*", outType, ", error) {") + g.P("m := new(", outType, ")") + g.P("if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err }") + g.P("return m, nil") + g.P("}") + g.P() + } + if genCloseAndRecv { + g.P("func (x *", streamType, ") CloseAndRecv() (*", outType, ", error) {") + g.P("if err := x.ClientStream.CloseSend(); err != nil { return nil, err }") + g.P("m := new(", outType, ")") + g.P("if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err }") + g.P("return m, nil") + g.P("}") + g.P() + } +} + +// generateServerSignature returns the server-side signature for a method. +func (g *grpc) generateServerSignature(servName string, method *pb.MethodDescriptorProto) string { + origMethName := method.GetName() + methName := generator.CamelCase(origMethName) + if reservedClientName[methName] { + methName += "_" + } + + var reqArgs []string + ret := "error" + if !method.GetServerStreaming() && !method.GetClientStreaming() { + reqArgs = append(reqArgs, contextPkg+".Context") + ret = "(*" + g.typeName(method.GetOutputType()) + ", error)" + } + if !method.GetClientStreaming() { + reqArgs = append(reqArgs, "*"+g.typeName(method.GetInputType())) + } + if method.GetServerStreaming() || method.GetClientStreaming() { + reqArgs = append(reqArgs, servName+"_"+generator.CamelCase(origMethName)+"Server") + } + + return methName + "(" + strings.Join(reqArgs, ", ") + ") " + ret +} + +func (g *grpc) generateServerMethod(servName string, method *pb.MethodDescriptorProto) string { + methName := generator.CamelCase(method.GetName()) + hname := fmt.Sprintf("_%s_%s_Handler", servName, methName) + inType := g.typeName(method.GetInputType()) + outType := g.typeName(method.GetOutputType()) + + if !method.GetServerStreaming() && !method.GetClientStreaming() { + g.P("func ", hname, "(srv interface{}, ctx ", contextPkg, ".Context, dec func(interface{}) error) (interface{}, error) {") + g.P("in := new(", inType, ")") + g.P("if err := dec(in); err != nil { return nil, err }") + g.P("out, err := srv.(", servName, "Server).", methName, "(ctx, in)") + g.P("if err != nil { return nil, err }") + g.P("return out, nil") + g.P("}") + g.P() + return hname + } + streamType := unexport(servName) + methName + "Server" + g.P("func ", hname, "(srv interface{}, stream ", grpcPkg, ".ServerStream) error {") + if !method.GetClientStreaming() { + g.P("m := new(", inType, ")") + g.P("if err := stream.RecvMsg(m); err != nil { return err }") + g.P("return srv.(", servName, "Server).", methName, "(m, &", streamType, "{stream})") + } else { + g.P("return srv.(", servName, "Server).", methName, "(&", streamType, "{stream})") + } + g.P("}") + g.P() + + genSend := method.GetServerStreaming() + genSendAndClose := !method.GetServerStreaming() + genRecv := method.GetClientStreaming() + + // Stream auxiliary types and methods. + g.P("type ", servName, "_", methName, "Server interface {") + if genSend { + g.P("Send(*", outType, ") error") + } + if genSendAndClose { + g.P("SendAndClose(*", outType, ") error") + } + if genRecv { + g.P("Recv() (*", inType, ", error)") + } + g.P(grpcPkg, ".ServerStream") + g.P("}") + g.P() + + g.P("type ", streamType, " struct {") + g.P(grpcPkg, ".ServerStream") + g.P("}") + g.P() + + if genSend { + g.P("func (x *", streamType, ") Send(m *", outType, ") error {") + g.P("return x.ServerStream.SendMsg(m)") + g.P("}") + g.P() + } + if genSendAndClose { + g.P("func (x *", streamType, ") SendAndClose(m *", outType, ") error {") + g.P("return x.ServerStream.SendMsg(m)") + g.P("}") + g.P() + } + if genRecv { + g.P("func (x *", streamType, ") Recv() (*", inType, ", error) {") + g.P("m := new(", inType, ")") + g.P("if err := x.ServerStream.RecvMsg(m); err != nil { return nil, err }") + g.P("return m, nil") + g.P("}") + g.P() + } + + return hname +} diff --git a/vendor/github.com/golang/protobuf/protoc-gen-go/link_grpc.go b/vendor/github.com/golang/protobuf/protoc-gen-go/link_grpc.go new file mode 100644 index 0000000000..24e490ec4b --- /dev/null +++ b/vendor/github.com/golang/protobuf/protoc-gen-go/link_grpc.go @@ -0,0 +1,34 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2015 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +package main + +import _ "github.com/golang/protobuf/protoc-gen-go/internal/grpc" diff --git a/vendor/github.com/golang/protobuf/protoc-gen-go/main.go b/vendor/github.com/golang/protobuf/protoc-gen-go/main.go new file mode 100644 index 0000000000..8e2486de0b --- /dev/null +++ b/vendor/github.com/golang/protobuf/protoc-gen-go/main.go @@ -0,0 +1,98 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// 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. + +// protoc-gen-go is a plugin for the Google protocol buffer compiler to generate +// Go code. Run it by building this program and putting it in your path with +// the name +// protoc-gen-go +// That word 'go' at the end becomes part of the option string set for the +// protocol compiler, so once the protocol compiler (protoc) is installed +// you can run +// protoc --go_out=output_directory input_directory/file.proto +// to generate Go bindings for the protocol defined by file.proto. +// With that input, the output will be written to +// output_directory/file.pb.go +// +// The generated code is documented in the package comment for +// the library. +// +// See the README and documentation for protocol buffers to learn more: +// https://developers.google.com/protocol-buffers/ +package main + +import ( + "io/ioutil" + "os" + + "github.com/golang/protobuf/proto" + "github.com/golang/protobuf/protoc-gen-go/generator" +) + +func main() { + // Begin by allocating a generator. The request and response structures are stored there + // so we can do error handling easily - the response structure contains the field to + // report failure. + g := generator.New() + + data, err := ioutil.ReadAll(os.Stdin) + if err != nil { + g.Error(err, "reading input") + } + + if err := proto.Unmarshal(data, g.Request); err != nil { + g.Error(err, "parsing input proto") + } + + if len(g.Request.FileToGenerate) == 0 { + g.Fail("no files to generate") + } + + g.CommandLineParameters(g.Request.GetParameter()) + + // Create a wrapped version of the Descriptors and EnumDescriptors that + // point to the file that defines them. + g.WrapTypes() + + g.SetPackageNames() + g.BuildTypeNameMap() + + g.GenerateAllFiles() + + // Send back the results. + data, err = proto.Marshal(g.Response) + if err != nil { + g.Error(err, "failed to marshal output proto") + } + _, err = os.Stdout.Write(data) + if err != nil { + g.Error(err, "failed to write output proto") + } +} diff --git a/vendor/github.com/golang/protobuf/protoc-gen-go/plugin/plugin.pb.go b/vendor/github.com/golang/protobuf/protoc-gen-go/plugin/plugin.pb.go new file mode 100644 index 0000000000..af31f733e9 --- /dev/null +++ b/vendor/github.com/golang/protobuf/protoc-gen-go/plugin/plugin.pb.go @@ -0,0 +1,222 @@ +// Code generated by protoc-gen-go. +// source: google/protobuf/compiler/plugin.proto +// DO NOT EDIT! + +/* +Package google_protobuf_compiler is a generated protocol buffer package. + +It is generated from these files: + google/protobuf/compiler/plugin.proto + +It has these top-level messages: + CodeGeneratorRequest + CodeGeneratorResponse +*/ +package google_protobuf_compiler + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" +import google_protobuf "github.com/golang/protobuf/protoc-gen-go/descriptor" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +const _ = proto.ProtoPackageIsVersion1 + +// An encoded CodeGeneratorRequest is written to the plugin's stdin. +type CodeGeneratorRequest struct { + // The .proto files that were explicitly listed on the command-line. The + // code generator should generate code only for these files. Each file's + // descriptor will be included in proto_file, below. + FileToGenerate []string `protobuf:"bytes,1,rep,name=file_to_generate" json:"file_to_generate,omitempty"` + // The generator parameter passed on the command-line. + Parameter *string `protobuf:"bytes,2,opt,name=parameter" json:"parameter,omitempty"` + // FileDescriptorProtos for all files in files_to_generate and everything + // they import. The files will appear in topological order, so each file + // appears before any file that imports it. + // + // protoc guarantees that all proto_files will be written after + // the fields above, even though this is not technically guaranteed by the + // protobuf wire format. This theoretically could allow a plugin to stream + // in the FileDescriptorProtos and handle them one by one rather than read + // the entire set into memory at once. However, as of this writing, this + // is not similarly optimized on protoc's end -- it will store all fields in + // memory at once before sending them to the plugin. + ProtoFile []*google_protobuf.FileDescriptorProto `protobuf:"bytes,15,rep,name=proto_file" json:"proto_file,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CodeGeneratorRequest) Reset() { *m = CodeGeneratorRequest{} } +func (m *CodeGeneratorRequest) String() string { return proto.CompactTextString(m) } +func (*CodeGeneratorRequest) ProtoMessage() {} +func (*CodeGeneratorRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } + +func (m *CodeGeneratorRequest) GetFileToGenerate() []string { + if m != nil { + return m.FileToGenerate + } + return nil +} + +func (m *CodeGeneratorRequest) GetParameter() string { + if m != nil && m.Parameter != nil { + return *m.Parameter + } + return "" +} + +func (m *CodeGeneratorRequest) GetProtoFile() []*google_protobuf.FileDescriptorProto { + if m != nil { + return m.ProtoFile + } + return nil +} + +// The plugin writes an encoded CodeGeneratorResponse to stdout. +type CodeGeneratorResponse struct { + // Error message. If non-empty, code generation failed. The plugin process + // should exit with status code zero even if it reports an error in this way. + // + // This should be used to indicate errors in .proto files which prevent the + // code generator from generating correct code. Errors which indicate a + // problem in protoc itself -- such as the input CodeGeneratorRequest being + // unparseable -- should be reported by writing a message to stderr and + // exiting with a non-zero status code. + Error *string `protobuf:"bytes,1,opt,name=error" json:"error,omitempty"` + File []*CodeGeneratorResponse_File `protobuf:"bytes,15,rep,name=file" json:"file,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CodeGeneratorResponse) Reset() { *m = CodeGeneratorResponse{} } +func (m *CodeGeneratorResponse) String() string { return proto.CompactTextString(m) } +func (*CodeGeneratorResponse) ProtoMessage() {} +func (*CodeGeneratorResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } + +func (m *CodeGeneratorResponse) GetError() string { + if m != nil && m.Error != nil { + return *m.Error + } + return "" +} + +func (m *CodeGeneratorResponse) GetFile() []*CodeGeneratorResponse_File { + if m != nil { + return m.File + } + return nil +} + +// Represents a single generated file. +type CodeGeneratorResponse_File struct { + // The file name, relative to the output directory. The name must not + // contain "." or ".." components and must be relative, not be absolute (so, + // the file cannot lie outside the output directory). "/" must be used as + // the path separator, not "\". + // + // If the name is omitted, the content will be appended to the previous + // file. This allows the generator to break large files into small chunks, + // and allows the generated text to be streamed back to protoc so that large + // files need not reside completely in memory at one time. Note that as of + // this writing protoc does not optimize for this -- it will read the entire + // CodeGeneratorResponse before writing files to disk. + Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + // If non-empty, indicates that the named file should already exist, and the + // content here is to be inserted into that file at a defined insertion + // point. This feature allows a code generator to extend the output + // produced by another code generator. The original generator may provide + // insertion points by placing special annotations in the file that look + // like: + // @@protoc_insertion_point(NAME) + // The annotation can have arbitrary text before and after it on the line, + // which allows it to be placed in a comment. NAME should be replaced with + // an identifier naming the point -- this is what other generators will use + // as the insertion_point. Code inserted at this point will be placed + // immediately above the line containing the insertion point (thus multiple + // insertions to the same point will come out in the order they were added). + // The double-@ is intended to make it unlikely that the generated code + // could contain things that look like insertion points by accident. + // + // For example, the C++ code generator places the following line in the + // .pb.h files that it generates: + // // @@protoc_insertion_point(namespace_scope) + // This line appears within the scope of the file's package namespace, but + // outside of any particular class. Another plugin can then specify the + // insertion_point "namespace_scope" to generate additional classes or + // other declarations that should be placed in this scope. + // + // Note that if the line containing the insertion point begins with + // whitespace, the same whitespace will be added to every line of the + // inserted text. This is useful for languages like Python, where + // indentation matters. In these languages, the insertion point comment + // should be indented the same amount as any inserted code will need to be + // in order to work correctly in that context. + // + // The code generator that generates the initial file and the one which + // inserts into it must both run as part of a single invocation of protoc. + // Code generators are executed in the order in which they appear on the + // command line. + // + // If |insertion_point| is present, |name| must also be present. + InsertionPoint *string `protobuf:"bytes,2,opt,name=insertion_point" json:"insertion_point,omitempty"` + // The file contents. + Content *string `protobuf:"bytes,15,opt,name=content" json:"content,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CodeGeneratorResponse_File) Reset() { *m = CodeGeneratorResponse_File{} } +func (m *CodeGeneratorResponse_File) String() string { return proto.CompactTextString(m) } +func (*CodeGeneratorResponse_File) ProtoMessage() {} +func (*CodeGeneratorResponse_File) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1, 0} } + +func (m *CodeGeneratorResponse_File) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *CodeGeneratorResponse_File) GetInsertionPoint() string { + if m != nil && m.InsertionPoint != nil { + return *m.InsertionPoint + } + return "" +} + +func (m *CodeGeneratorResponse_File) GetContent() string { + if m != nil && m.Content != nil { + return *m.Content + } + return "" +} + +func init() { + proto.RegisterType((*CodeGeneratorRequest)(nil), "google.protobuf.compiler.CodeGeneratorRequest") + proto.RegisterType((*CodeGeneratorResponse)(nil), "google.protobuf.compiler.CodeGeneratorResponse") + proto.RegisterType((*CodeGeneratorResponse_File)(nil), "google.protobuf.compiler.CodeGeneratorResponse.File") +} + +var fileDescriptor0 = []byte{ + // 269 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x74, 0x91, 0xc1, 0x4a, 0xc3, 0x40, + 0x10, 0x86, 0xa9, 0x46, 0xa4, 0x63, 0x25, 0x1a, 0x14, 0x43, 0xf1, 0x10, 0x44, 0xc1, 0x83, 0x6c, + 0x40, 0x3c, 0x78, 0xf2, 0x10, 0x45, 0xaf, 0xc5, 0x17, 0x08, 0x31, 0x9d, 0x86, 0x85, 0x74, 0x67, + 0x9d, 0xdd, 0x1c, 0x7d, 0x21, 0x9f, 0xd2, 0xc9, 0xa6, 0x15, 0x09, 0xf6, 0x14, 0xf8, 0xe7, 0xcf, + 0xf7, 0xcd, 0xb0, 0x70, 0xd3, 0x10, 0x35, 0x2d, 0xe6, 0x96, 0xc9, 0xd3, 0x47, 0xb7, 0xca, 0x6b, + 0x5a, 0x5b, 0xdd, 0x22, 0xe7, 0xb6, 0xed, 0x1a, 0x6d, 0x54, 0x18, 0x24, 0xe9, 0x50, 0x53, 0xdb, + 0x9a, 0xda, 0xd6, 0xe6, 0xd9, 0x18, 0xb0, 0x44, 0x57, 0xb3, 0xb6, 0x9e, 0x78, 0x68, 0x5f, 0x7d, + 0xc1, 0xd9, 0x33, 0x2d, 0xf1, 0x0d, 0x0d, 0x72, 0x25, 0xf1, 0x3b, 0x7e, 0x76, 0xe8, 0x7c, 0x92, + 0xc2, 0xc9, 0x4a, 0x10, 0xa5, 0xa7, 0xb2, 0x19, 0x66, 0x98, 0x4e, 0xb2, 0xfd, 0xdb, 0x69, 0x72, + 0x0a, 0x53, 0x5b, 0x71, 0xb5, 0x46, 0x8f, 0x9c, 0xee, 0x65, 0x13, 0x89, 0x1e, 0x01, 0x02, 0xad, + 0xec, 0x7f, 0x49, 0x63, 0xa9, 0x1d, 0xdd, 0x5f, 0xab, 0xf1, 0x56, 0xaf, 0x32, 0x7c, 0xf9, 0xf5, + 0x2f, 0x82, 0xfe, 0x7b, 0x02, 0xe7, 0x23, 0xbf, 0xb3, 0x64, 0x1c, 0x26, 0xc7, 0x70, 0x80, 0xcc, + 0xc4, 0x62, 0xed, 0x15, 0x05, 0x44, 0x7f, 0xe0, 0x0f, 0x6a, 0xd7, 0xc9, 0xea, 0x5f, 0x5a, 0x70, + 0xcf, 0x9f, 0x20, 0xea, 0xbf, 0xc9, 0x0c, 0x22, 0x23, 0xfb, 0x6f, 0xc8, 0x17, 0x10, 0x6b, 0xa9, + 0xb0, 0xd7, 0x64, 0x4a, 0x4b, 0xda, 0xf8, 0xcd, 0x55, 0x31, 0x1c, 0xd6, 0x64, 0x3c, 0x4a, 0x10, + 0xf7, 0x41, 0x71, 0x07, 0x97, 0xa2, 0xd9, 0xa9, 0x2e, 0x66, 0x8b, 0xf0, 0x2a, 0xe1, 0x32, 0xf7, + 0x13, 0x00, 0x00, 0xff, 0xff, 0xdb, 0x18, 0x2a, 0x2a, 0xbd, 0x01, 0x00, 0x00, +} diff --git a/vendor/github.com/google/btree/LICENSE b/vendor/github.com/google/btree/LICENSE new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/vendor/github.com/google/btree/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor 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, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/google/btree/btree.go b/vendor/github.com/google/btree/btree.go new file mode 100644 index 0000000000..eb1f75cda6 --- /dev/null +++ b/vendor/github.com/google/btree/btree.go @@ -0,0 +1,571 @@ +// Copyright 2014 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package btree implements in-memory B-Trees of arbitrary degree. +// +// btree implements an in-memory B-Tree for use as an ordered data structure. +// It is not meant for persistent storage solutions. +// +// It has a flatter structure than an equivalent red-black or other binary tree, +// which in some cases yields better memory usage and/or performance. +// See some discussion on the matter here: +// http://google-opensource.blogspot.com/2013/01/c-containers-that-save-memory-and-time.html +// Note, though, that this project is in no way related to the C++ B-Tree +// implmentation written about there. +// +// Within this tree, each node contains a slice of items and a (possibly nil) +// slice of children. For basic numeric values or raw structs, this can cause +// efficiency differences when compared to equivalent C++ template code that +// stores values in arrays within the node: +// * Due to the overhead of storing values as interfaces (each +// value needs to be stored as the value itself, then 2 words for the +// interface pointing to that value and its type), resulting in higher +// memory use. +// * Since interfaces can point to values anywhere in memory, values are +// most likely not stored in contiguous blocks, resulting in a higher +// number of cache misses. +// These issues don't tend to matter, though, when working with strings or other +// heap-allocated structures, since C++-equivalent structures also must store +// pointers and also distribute their values across the heap. +// +// This implementation is designed to be a drop-in replacement to gollrb.LLRB +// trees, (http://github.com/petar/gollrb), an excellent and probably the most +// widely used ordered tree implementation in the Go ecosystem currently. +// Its functions, therefore, exactly mirror those of +// llrb.LLRB where possible. Unlike gollrb, though, we currently don't +// support storing multiple equivalent values or backwards iteration. +package btree + +import ( + "fmt" + "io" + "sort" + "strings" +) + +// Item represents a single object in the tree. +type Item interface { + // Less tests whether the current item is less than the given argument. + // + // This must provide a strict weak ordering. + // If !a.Less(b) && !b.Less(a), we treat this to mean a == b (i.e. we can only + // hold one of either a or b in the tree). + Less(than Item) bool +} + +// ItemIterator allows callers of Ascend* to iterate in-order over portions of +// the tree. When this function returns false, iteration will stop and the +// associated Ascend* function will immediately return. +type ItemIterator func(i Item) bool + +// New creates a new B-Tree with the given degree. +// +// New(2), for example, will create a 2-3-4 tree (each node contains 1-3 items +// and 2-4 children). +func New(degree int) *BTree { + if degree <= 1 { + panic("bad degree") + } + return &BTree{ + degree: degree, + freelist: make([]*node, 0, 32), + } +} + +// items stores items in a node. +type items []Item + +// insertAt inserts a value into the given index, pushing all subsequent values +// forward. +func (s *items) insertAt(index int, item Item) { + *s = append(*s, nil) + if index < len(*s) { + copy((*s)[index+1:], (*s)[index:]) + } + (*s)[index] = item +} + +// removeAt removes a value at a given index, pulling all subsequent values +// back. +func (s *items) removeAt(index int) Item { + item := (*s)[index] + copy((*s)[index:], (*s)[index+1:]) + *s = (*s)[:len(*s)-1] + return item +} + +// pop removes and returns the last element in the list. +func (s *items) pop() (out Item) { + index := len(*s) - 1 + out, *s = (*s)[index], (*s)[:index] + return +} + +// find returns the index where the given item should be inserted into this +// list. 'found' is true if the item already exists in the list at the given +// index. +func (s items) find(item Item) (index int, found bool) { + i := sort.Search(len(s), func(i int) bool { + return item.Less(s[i]) + }) + if i > 0 && !s[i-1].Less(item) { + return i - 1, true + } + return i, false +} + +// children stores child nodes in a node. +type children []*node + +// insertAt inserts a value into the given index, pushing all subsequent values +// forward. +func (s *children) insertAt(index int, n *node) { + *s = append(*s, nil) + if index < len(*s) { + copy((*s)[index+1:], (*s)[index:]) + } + (*s)[index] = n +} + +// removeAt removes a value at a given index, pulling all subsequent values +// back. +func (s *children) removeAt(index int) *node { + n := (*s)[index] + copy((*s)[index:], (*s)[index+1:]) + *s = (*s)[:len(*s)-1] + return n +} + +// pop removes and returns the last element in the list. +func (s *children) pop() (out *node) { + index := len(*s) - 1 + out, *s = (*s)[index], (*s)[:index] + return +} + +// node is an internal node in a tree. +// +// It must at all times maintain the invariant that either +// * len(children) == 0, len(items) unconstrained +// * len(children) == len(items) + 1 +type node struct { + items items + children children + t *BTree +} + +// split splits the given node at the given index. The current node shrinks, +// and this function returns the item that existed at that index and a new node +// containing all items/children after it. +func (n *node) split(i int) (Item, *node) { + item := n.items[i] + next := n.t.newNode() + next.items = append(next.items, n.items[i+1:]...) + n.items = n.items[:i] + if len(n.children) > 0 { + next.children = append(next.children, n.children[i+1:]...) + n.children = n.children[:i+1] + } + return item, next +} + +// maybeSplitChild checks if a child should be split, and if so splits it. +// Returns whether or not a split occurred. +func (n *node) maybeSplitChild(i, maxItems int) bool { + if len(n.children[i].items) < maxItems { + return false + } + first := n.children[i] + item, second := first.split(maxItems / 2) + n.items.insertAt(i, item) + n.children.insertAt(i+1, second) + return true +} + +// insert inserts an item into the subtree rooted at this node, making sure +// no nodes in the subtree exceed maxItems items. Should an equivalent item be +// be found/replaced by insert, it will be returned. +func (n *node) insert(item Item, maxItems int) Item { + i, found := n.items.find(item) + if found { + out := n.items[i] + n.items[i] = item + return out + } + if len(n.children) == 0 { + n.items.insertAt(i, item) + return nil + } + if n.maybeSplitChild(i, maxItems) { + inTree := n.items[i] + switch { + case item.Less(inTree): + // no change, we want first split node + case inTree.Less(item): + i++ // we want second split node + default: + out := n.items[i] + n.items[i] = item + return out + } + } + return n.children[i].insert(item, maxItems) +} + +// get finds the given key in the subtree and returns it. +func (n *node) get(key Item) Item { + i, found := n.items.find(key) + if found { + return n.items[i] + } else if len(n.children) > 0 { + return n.children[i].get(key) + } + return nil +} + +// toRemove details what item to remove in a node.remove call. +type toRemove int + +const ( + removeItem toRemove = iota // removes the given item + removeMin // removes smallest item in the subtree + removeMax // removes largest item in the subtree +) + +// remove removes an item from the subtree rooted at this node. +func (n *node) remove(item Item, minItems int, typ toRemove) Item { + var i int + var found bool + switch typ { + case removeMax: + if len(n.children) == 0 { + return n.items.pop() + } + i = len(n.items) + case removeMin: + if len(n.children) == 0 { + return n.items.removeAt(0) + } + i = 0 + case removeItem: + i, found = n.items.find(item) + if len(n.children) == 0 { + if found { + return n.items.removeAt(i) + } + return nil + } + default: + panic("invalid type") + } + // If we get to here, we have children. + child := n.children[i] + if len(child.items) <= minItems { + return n.growChildAndRemove(i, item, minItems, typ) + } + // Either we had enough items to begin with, or we've done some + // merging/stealing, because we've got enough now and we're ready to return + // stuff. + if found { + // The item exists at index 'i', and the child we've selected can give us a + // predecessor, since if we've gotten here it's got > minItems items in it. + out := n.items[i] + // We use our special-case 'remove' call with typ=maxItem to pull the + // predecessor of item i (the rightmost leaf of our immediate left child) + // and set it into where we pulled the item from. + n.items[i] = child.remove(nil, minItems, removeMax) + return out + } + // Final recursive call. Once we're here, we know that the item isn't in this + // node and that the child is big enough to remove from. + return child.remove(item, minItems, typ) +} + +// growChildAndRemove grows child 'i' to make sure it's possible to remove an +// item from it while keeping it at minItems, then calls remove to actually +// remove it. +// +// Most documentation says we have to do two sets of special casing: +// 1) item is in this node +// 2) item is in child +// In both cases, we need to handle the two subcases: +// A) node has enough values that it can spare one +// B) node doesn't have enough values +// For the latter, we have to check: +// a) left sibling has node to spare +// b) right sibling has node to spare +// c) we must merge +// To simplify our code here, we handle cases #1 and #2 the same: +// If a node doesn't have enough items, we make sure it does (using a,b,c). +// We then simply redo our remove call, and the second time (regardless of +// whether we're in case 1 or 2), we'll have enough items and can guarantee +// that we hit case A. +func (n *node) growChildAndRemove(i int, item Item, minItems int, typ toRemove) Item { + child := n.children[i] + if i > 0 && len(n.children[i-1].items) > minItems { + // Steal from left child + stealFrom := n.children[i-1] + stolenItem := stealFrom.items.pop() + child.items.insertAt(0, n.items[i-1]) + n.items[i-1] = stolenItem + if len(stealFrom.children) > 0 { + child.children.insertAt(0, stealFrom.children.pop()) + } + } else if i < len(n.items) && len(n.children[i+1].items) > minItems { + // steal from right child + stealFrom := n.children[i+1] + stolenItem := stealFrom.items.removeAt(0) + child.items = append(child.items, n.items[i]) + n.items[i] = stolenItem + if len(stealFrom.children) > 0 { + child.children = append(child.children, stealFrom.children.removeAt(0)) + } + } else { + if i >= len(n.items) { + i-- + child = n.children[i] + } + // merge with right child + mergeItem := n.items.removeAt(i) + mergeChild := n.children.removeAt(i + 1) + child.items = append(child.items, mergeItem) + child.items = append(child.items, mergeChild.items...) + child.children = append(child.children, mergeChild.children...) + n.t.freeNode(mergeChild) + } + return n.remove(item, minItems, typ) +} + +// iterate provides a simple method for iterating over elements in the tree. +// It could probably use some work to be extra-efficient (it calls from() a +// little more than it should), but it works pretty well for now. +// +// It requires that 'from' and 'to' both return true for values we should hit +// with the iterator. It should also be the case that 'from' returns true for +// values less than or equal to values 'to' returns true for, and 'to' +// returns true for values greater than or equal to those that 'from' +// does. +func (n *node) iterate(from, to func(Item) bool, iter ItemIterator) bool { + for i, item := range n.items { + if !from(item) { + continue + } + if len(n.children) > 0 && !n.children[i].iterate(from, to, iter) { + return false + } + if !to(item) { + return false + } + if !iter(item) { + return false + } + } + if len(n.children) > 0 { + return n.children[len(n.children)-1].iterate(from, to, iter) + } + return true +} + +// Used for testing/debugging purposes. +func (n *node) print(w io.Writer, level int) { + fmt.Fprintf(w, "%sNODE:%v\n", strings.Repeat(" ", level), n.items) + for _, c := range n.children { + c.print(w, level+1) + } +} + +// BTree is an implementation of a B-Tree. +// +// BTree stores Item instances in an ordered structure, allowing easy insertion, +// removal, and iteration. +// +// Write operations are not safe for concurrent mutation by multiple +// goroutines, but Read operations are. +type BTree struct { + degree int + length int + root *node + freelist []*node +} + +// maxItems returns the max number of items to allow per node. +func (t *BTree) maxItems() int { + return t.degree*2 - 1 +} + +// minItems returns the min number of items to allow per node (ignored for the +// root node). +func (t *BTree) minItems() int { + return t.degree - 1 +} + +func (t *BTree) newNode() (n *node) { + index := len(t.freelist) - 1 + if index < 0 { + return &node{t: t} + } + t.freelist, n = t.freelist[:index], t.freelist[index] + return +} + +func (t *BTree) freeNode(n *node) { + if len(t.freelist) < cap(t.freelist) { + for i := range n.items { + n.items[i] = nil // clear to allow GC + } + n.items = n.items[:0] + for i := range n.children { + n.children[i] = nil // clear to allow GC + } + n.children = n.children[:0] + t.freelist = append(t.freelist, n) + } +} + +// ReplaceOrInsert adds the given item to the tree. If an item in the tree +// already equals the given one, it is removed from the tree and returned. +// Otherwise, nil is returned. +// +// nil cannot be added to the tree (will panic). +func (t *BTree) ReplaceOrInsert(item Item) Item { + if item == nil { + panic("nil item being added to BTree") + } + if t.root == nil { + t.root = t.newNode() + t.root.items = append(t.root.items, item) + t.length++ + return nil + } else if len(t.root.items) >= t.maxItems() { + item2, second := t.root.split(t.maxItems() / 2) + oldroot := t.root + t.root = t.newNode() + t.root.items = append(t.root.items, item2) + t.root.children = append(t.root.children, oldroot, second) + } + out := t.root.insert(item, t.maxItems()) + if out == nil { + t.length++ + } + return out +} + +// Delete removes an item equal to the passed in item from the tree, returning +// it. If no such item exists, returns nil. +func (t *BTree) Delete(item Item) Item { + return t.deleteItem(item, removeItem) +} + +// DeleteMin removes the smallest item in the tree and returns it. +// If no such item exists, returns nil. +func (t *BTree) DeleteMin() Item { + return t.deleteItem(nil, removeMin) +} + +// DeleteMax removes the largest item in the tree and returns it. +// If no such item exists, returns nil. +func (t *BTree) DeleteMax() Item { + return t.deleteItem(nil, removeMax) +} + +func (t *BTree) deleteItem(item Item, typ toRemove) Item { + if t.root == nil || len(t.root.items) == 0 { + return nil + } + out := t.root.remove(item, t.minItems(), typ) + if len(t.root.items) == 0 && len(t.root.children) > 0 { + oldroot := t.root + t.root = t.root.children[0] + t.freeNode(oldroot) + } + if out != nil { + t.length-- + } + return out +} + +// AscendRange calls the iterator for every value in the tree within the range +// [greaterOrEqual, lessThan), until iterator returns false. +func (t *BTree) AscendRange(greaterOrEqual, lessThan Item, iterator ItemIterator) { + if t.root == nil { + return + } + t.root.iterate( + func(a Item) bool { return !a.Less(greaterOrEqual) }, + func(a Item) bool { return a.Less(lessThan) }, + iterator) +} + +// AscendLessThan calls the iterator for every value in the tree within the range +// [first, pivot), until iterator returns false. +func (t *BTree) AscendLessThan(pivot Item, iterator ItemIterator) { + if t.root == nil { + return + } + t.root.iterate( + func(a Item) bool { return true }, + func(a Item) bool { return a.Less(pivot) }, + iterator) +} + +// AscendGreaterOrEqual calls the iterator for every value in the tree within +// the range [pivot, last], until iterator returns false. +func (t *BTree) AscendGreaterOrEqual(pivot Item, iterator ItemIterator) { + if t.root == nil { + return + } + t.root.iterate( + func(a Item) bool { return !a.Less(pivot) }, + func(a Item) bool { return true }, + iterator) +} + +// Ascend calls the iterator for every value in the tree within the range +// [first, last], until iterator returns false. +func (t *BTree) Ascend(iterator ItemIterator) { + if t.root == nil { + return + } + t.root.iterate( + func(a Item) bool { return true }, + func(a Item) bool { return true }, + iterator) +} + +// Get looks for the key item in the tree, returning it. It returns nil if +// unable to find that item. +func (t *BTree) Get(key Item) Item { + if t.root == nil { + return nil + } + return t.root.get(key) +} + +// Has returns true if the given key is in the tree. +func (t *BTree) Has(key Item) bool { + return t.Get(key) != nil +} + +// Len returns the number of items currently in the tree. +func (t *BTree) Len() int { + return t.length +} + +// Int implements the Item interface for integers. +type Int int + +// Less returns true if int(a) < int(b). +func (a Int) Less(b Item) bool { + return a < b.(Int) +} diff --git a/vendor/github.com/google/btree/btree_mem.go b/vendor/github.com/google/btree/btree_mem.go new file mode 100644 index 0000000000..cb95b7fa1b --- /dev/null +++ b/vendor/github.com/google/btree/btree_mem.go @@ -0,0 +1,76 @@ +// Copyright 2014 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build ignore + +// This binary compares memory usage between btree and gollrb. +package main + +import ( + "flag" + "fmt" + "math/rand" + "runtime" + "time" + + "github.com/google/btree" + "github.com/petar/GoLLRB/llrb" +) + +var ( + size = flag.Int("size", 1000000, "size of the tree to build") + degree = flag.Int("degree", 8, "degree of btree") + gollrb = flag.Bool("llrb", false, "use llrb instead of btree") +) + +func main() { + flag.Parse() + vals := rand.Perm(*size) + var t, v interface{} + v = vals + var stats runtime.MemStats + for i := 0; i < 10; i++ { + runtime.GC() + } + fmt.Println("-------- BEFORE ----------") + runtime.ReadMemStats(&stats) + fmt.Printf("%+v\n", stats) + start := time.Now() + if *gollrb { + tr := llrb.New() + for _, v := range vals { + tr.ReplaceOrInsert(llrb.Int(v)) + } + t = tr // keep it around + } else { + tr := btree.New(*degree) + for _, v := range vals { + tr.ReplaceOrInsert(btree.Int(v)) + } + t = tr // keep it around + } + fmt.Printf("%v inserts in %v\n", *size, time.Since(start)) + fmt.Println("-------- AFTER ----------") + runtime.ReadMemStats(&stats) + fmt.Printf("%+v\n", stats) + for i := 0; i < 10; i++ { + runtime.GC() + } + fmt.Println("-------- AFTER GC ----------") + runtime.ReadMemStats(&stats) + fmt.Printf("%+v\n", stats) + if t == v { + fmt.Println("to make sure vals and tree aren't GC'd") + } +} diff --git a/vendor/github.com/gorilla/context/LICENSE b/vendor/github.com/gorilla/context/LICENSE new file mode 100644 index 0000000000..0e5fb87280 --- /dev/null +++ b/vendor/github.com/gorilla/context/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2012 Rodrigo Moraes. 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. diff --git a/vendor/github.com/gorilla/context/context.go b/vendor/github.com/gorilla/context/context.go new file mode 100644 index 0000000000..81cb128b19 --- /dev/null +++ b/vendor/github.com/gorilla/context/context.go @@ -0,0 +1,143 @@ +// Copyright 2012 The Gorilla 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 context + +import ( + "net/http" + "sync" + "time" +) + +var ( + mutex sync.RWMutex + data = make(map[*http.Request]map[interface{}]interface{}) + datat = make(map[*http.Request]int64) +) + +// Set stores a value for a given key in a given request. +func Set(r *http.Request, key, val interface{}) { + mutex.Lock() + if data[r] == nil { + data[r] = make(map[interface{}]interface{}) + datat[r] = time.Now().Unix() + } + data[r][key] = val + mutex.Unlock() +} + +// Get returns a value stored for a given key in a given request. +func Get(r *http.Request, key interface{}) interface{} { + mutex.RLock() + if ctx := data[r]; ctx != nil { + value := ctx[key] + mutex.RUnlock() + return value + } + mutex.RUnlock() + return nil +} + +// GetOk returns stored value and presence state like multi-value return of map access. +func GetOk(r *http.Request, key interface{}) (interface{}, bool) { + mutex.RLock() + if _, ok := data[r]; ok { + value, ok := data[r][key] + mutex.RUnlock() + return value, ok + } + mutex.RUnlock() + return nil, false +} + +// GetAll returns all stored values for the request as a map. Nil is returned for invalid requests. +func GetAll(r *http.Request) map[interface{}]interface{} { + mutex.RLock() + if context, ok := data[r]; ok { + result := make(map[interface{}]interface{}, len(context)) + for k, v := range context { + result[k] = v + } + mutex.RUnlock() + return result + } + mutex.RUnlock() + return nil +} + +// GetAllOk returns all stored values for the request as a map and a boolean value that indicates if +// the request was registered. +func GetAllOk(r *http.Request) (map[interface{}]interface{}, bool) { + mutex.RLock() + context, ok := data[r] + result := make(map[interface{}]interface{}, len(context)) + for k, v := range context { + result[k] = v + } + mutex.RUnlock() + return result, ok +} + +// Delete removes a value stored for a given key in a given request. +func Delete(r *http.Request, key interface{}) { + mutex.Lock() + if data[r] != nil { + delete(data[r], key) + } + mutex.Unlock() +} + +// Clear removes all values stored for a given request. +// +// This is usually called by a handler wrapper to clean up request +// variables at the end of a request lifetime. See ClearHandler(). +func Clear(r *http.Request) { + mutex.Lock() + clear(r) + mutex.Unlock() +} + +// clear is Clear without the lock. +func clear(r *http.Request) { + delete(data, r) + delete(datat, r) +} + +// Purge removes request data stored for longer than maxAge, in seconds. +// It returns the amount of requests removed. +// +// If maxAge <= 0, all request data is removed. +// +// This is only used for sanity check: in case context cleaning was not +// properly set some request data can be kept forever, consuming an increasing +// amount of memory. In case this is detected, Purge() must be called +// periodically until the problem is fixed. +func Purge(maxAge int) int { + mutex.Lock() + count := 0 + if maxAge <= 0 { + count = len(data) + data = make(map[*http.Request]map[interface{}]interface{}) + datat = make(map[*http.Request]int64) + } else { + min := time.Now().Unix() - int64(maxAge) + for r := range data { + if datat[r] < min { + clear(r) + count++ + } + } + } + mutex.Unlock() + return count +} + +// ClearHandler wraps an http.Handler and clears request values at the end +// of a request lifetime. +func ClearHandler(h http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + defer Clear(r) + h.ServeHTTP(w, r) + }) +} diff --git a/vendor/github.com/gorilla/context/doc.go b/vendor/github.com/gorilla/context/doc.go new file mode 100644 index 0000000000..73c7400311 --- /dev/null +++ b/vendor/github.com/gorilla/context/doc.go @@ -0,0 +1,82 @@ +// Copyright 2012 The Gorilla 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 context stores values shared during a request lifetime. + +For example, a router can set variables extracted from the URL and later +application handlers can access those values, or it can be used to store +sessions values to be saved at the end of a request. There are several +others common uses. + +The idea was posted by Brad Fitzpatrick to the go-nuts mailing list: + + http://groups.google.com/group/golang-nuts/msg/e2d679d303aa5d53 + +Here's the basic usage: first define the keys that you will need. The key +type is interface{} so a key can be of any type that supports equality. +Here we define a key using a custom int type to avoid name collisions: + + package foo + + import ( + "github.com/gorilla/context" + ) + + type key int + + const MyKey key = 0 + +Then set a variable. Variables are bound to an http.Request object, so you +need a request instance to set a value: + + context.Set(r, MyKey, "bar") + +The application can later access the variable using the same key you provided: + + func MyHandler(w http.ResponseWriter, r *http.Request) { + // val is "bar". + val := context.Get(r, foo.MyKey) + + // returns ("bar", true) + val, ok := context.GetOk(r, foo.MyKey) + // ... + } + +And that's all about the basic usage. We discuss some other ideas below. + +Any type can be stored in the context. To enforce a given type, make the key +private and wrap Get() and Set() to accept and return values of a specific +type: + + type key int + + const mykey key = 0 + + // GetMyKey returns a value for this package from the request values. + func GetMyKey(r *http.Request) SomeType { + if rv := context.Get(r, mykey); rv != nil { + return rv.(SomeType) + } + return nil + } + + // SetMyKey sets a value for this package in the request values. + func SetMyKey(r *http.Request, val SomeType) { + context.Set(r, mykey, val) + } + +Variables must be cleared at the end of a request, to remove all values +that were stored. This can be done in an http.Handler, after a request was +served. Just call Clear() passing the request: + + context.Clear(r) + +...or use ClearHandler(), which conveniently wraps an http.Handler to clear +variables at the end of a request lifetime. + +The Routers from the packages gorilla/mux and gorilla/pat call Clear() +so if you are using either of them you don't need to clear the context manually. +*/ +package context diff --git a/vendor/github.com/gorilla/mux/LICENSE b/vendor/github.com/gorilla/mux/LICENSE new file mode 100644 index 0000000000..0e5fb87280 --- /dev/null +++ b/vendor/github.com/gorilla/mux/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2012 Rodrigo Moraes. 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. diff --git a/vendor/github.com/gorilla/mux/doc.go b/vendor/github.com/gorilla/mux/doc.go new file mode 100644 index 0000000000..b2deed34c4 --- /dev/null +++ b/vendor/github.com/gorilla/mux/doc.go @@ -0,0 +1,199 @@ +// Copyright 2012 The Gorilla 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 gorilla/mux implements a request router and dispatcher. + +The name mux stands for "HTTP request multiplexer". Like the standard +http.ServeMux, mux.Router matches incoming requests against a list of +registered routes and calls a handler for the route that matches the URL +or other conditions. The main features are: + + * Requests can be matched based on URL host, path, path prefix, schemes, + header and query values, HTTP methods or using custom matchers. + * URL hosts and paths can have variables with an optional regular + expression. + * Registered URLs can be built, or "reversed", which helps maintaining + references to resources. + * Routes can be used as subrouters: nested routes are only tested if the + parent route matches. This is useful to define groups of routes that + share common conditions like a host, a path prefix or other repeated + attributes. As a bonus, this optimizes request matching. + * It implements the http.Handler interface so it is compatible with the + standard http.ServeMux. + +Let's start registering a couple of URL paths and handlers: + + func main() { + r := mux.NewRouter() + r.HandleFunc("/", HomeHandler) + r.HandleFunc("/products", ProductsHandler) + r.HandleFunc("/articles", ArticlesHandler) + http.Handle("/", r) + } + +Here we register three routes mapping URL paths to handlers. This is +equivalent to how http.HandleFunc() works: if an incoming request URL matches +one of the paths, the corresponding handler is called passing +(http.ResponseWriter, *http.Request) as parameters. + +Paths can have variables. They are defined using the format {name} or +{name:pattern}. If a regular expression pattern is not defined, the matched +variable will be anything until the next slash. For example: + + r := mux.NewRouter() + r.HandleFunc("/products/{key}", ProductHandler) + r.HandleFunc("/articles/{category}/", ArticlesCategoryHandler) + r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler) + +The names are used to create a map of route variables which can be retrieved +calling mux.Vars(): + + vars := mux.Vars(request) + category := vars["category"] + +And this is all you need to know about the basic usage. More advanced options +are explained below. + +Routes can also be restricted to a domain or subdomain. Just define a host +pattern to be matched. They can also have variables: + + r := mux.NewRouter() + // Only matches if domain is "www.domain.com". + r.Host("www.domain.com") + // Matches a dynamic subdomain. + r.Host("{subdomain:[a-z]+}.domain.com") + +There are several other matchers that can be added. To match path prefixes: + + r.PathPrefix("/products/") + +...or HTTP methods: + + r.Methods("GET", "POST") + +...or URL schemes: + + r.Schemes("https") + +...or header values: + + r.Headers("X-Requested-With", "XMLHttpRequest") + +...or query values: + + r.Queries("key", "value") + +...or to use a custom matcher function: + + r.MatcherFunc(func(r *http.Request, rm *RouteMatch) bool { + return r.ProtoMajor == 0 + }) + +...and finally, it is possible to combine several matchers in a single route: + + r.HandleFunc("/products", ProductsHandler). + Host("www.domain.com"). + Methods("GET"). + Schemes("http") + +Setting the same matching conditions again and again can be boring, so we have +a way to group several routes that share the same requirements. +We call it "subrouting". + +For example, let's say we have several URLs that should only match when the +host is "www.domain.com". Create a route for that host and get a "subrouter" +from it: + + r := mux.NewRouter() + s := r.Host("www.domain.com").Subrouter() + +Then register routes in the subrouter: + + s.HandleFunc("/products/", ProductsHandler) + s.HandleFunc("/products/{key}", ProductHandler) + s.HandleFunc("/articles/{category}/{id:[0-9]+}"), ArticleHandler) + +The three URL paths we registered above will only be tested if the domain is +"www.domain.com", because the subrouter is tested first. This is not +only convenient, but also optimizes request matching. You can create +subrouters combining any attribute matchers accepted by a route. + +Subrouters can be used to create domain or path "namespaces": you define +subrouters in a central place and then parts of the app can register its +paths relatively to a given subrouter. + +There's one more thing about subroutes. When a subrouter has a path prefix, +the inner routes use it as base for their paths: + + r := mux.NewRouter() + s := r.PathPrefix("/products").Subrouter() + // "/products/" + s.HandleFunc("/", ProductsHandler) + // "/products/{key}/" + s.HandleFunc("/{key}/", ProductHandler) + // "/products/{key}/details" + s.HandleFunc("/{key}/details", ProductDetailsHandler) + +Now let's see how to build registered URLs. + +Routes can be named. All routes that define a name can have their URLs built, +or "reversed". We define a name calling Name() on a route. For example: + + r := mux.NewRouter() + r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler). + Name("article") + +To build a URL, get the route and call the URL() method, passing a sequence of +key/value pairs for the route variables. For the previous route, we would do: + + url, err := r.Get("article").URL("category", "technology", "id", "42") + +...and the result will be a url.URL with the following path: + + "/articles/technology/42" + +This also works for host variables: + + r := mux.NewRouter() + r.Host("{subdomain}.domain.com"). + Path("/articles/{category}/{id:[0-9]+}"). + HandlerFunc(ArticleHandler). + Name("article") + + // url.String() will be "http://news.domain.com/articles/technology/42" + url, err := r.Get("article").URL("subdomain", "news", + "category", "technology", + "id", "42") + +All variables defined in the route are required, and their values must +conform to the corresponding patterns. These requirements guarantee that a +generated URL will always match a registered route -- the only exception is +for explicitly defined "build-only" routes which never match. + +There's also a way to build only the URL host or path for a route: +use the methods URLHost() or URLPath() instead. For the previous route, +we would do: + + // "http://news.domain.com/" + host, err := r.Get("article").URLHost("subdomain", "news") + + // "/articles/technology/42" + path, err := r.Get("article").URLPath("category", "technology", "id", "42") + +And if you use subrouters, host and path defined separately can be built +as well: + + r := mux.NewRouter() + s := r.Host("{subdomain}.domain.com").Subrouter() + s.Path("/articles/{category}/{id:[0-9]+}"). + HandlerFunc(ArticleHandler). + Name("article") + + // "http://news.domain.com/articles/technology/42" + url, err := r.Get("article").URL("subdomain", "news", + "category", "technology", + "id", "42") +*/ +package mux diff --git a/vendor/github.com/gorilla/mux/mux.go b/vendor/github.com/gorilla/mux/mux.go new file mode 100644 index 0000000000..5b5f8e7db5 --- /dev/null +++ b/vendor/github.com/gorilla/mux/mux.go @@ -0,0 +1,353 @@ +// Copyright 2012 The Gorilla 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 mux + +import ( + "fmt" + "net/http" + "path" + + "github.com/gorilla/context" +) + +// NewRouter returns a new router instance. +func NewRouter() *Router { + return &Router{namedRoutes: make(map[string]*Route), KeepContext: false} +} + +// Router registers routes to be matched and dispatches a handler. +// +// It implements the http.Handler interface, so it can be registered to serve +// requests: +// +// var router = mux.NewRouter() +// +// func main() { +// http.Handle("/", router) +// } +// +// Or, for Google App Engine, register it in a init() function: +// +// func init() { +// http.Handle("/", router) +// } +// +// This will send all incoming requests to the router. +type Router struct { + // Configurable Handler to be used when no route matches. + NotFoundHandler http.Handler + // Parent route, if this is a subrouter. + parent parentRoute + // Routes to be matched, in order. + routes []*Route + // Routes by name for URL building. + namedRoutes map[string]*Route + // See Router.StrictSlash(). This defines the flag for new routes. + strictSlash bool + // If true, do not clear the request context after handling the request + KeepContext bool +} + +// Match matches registered routes against the request. +func (r *Router) Match(req *http.Request, match *RouteMatch) bool { + for _, route := range r.routes { + if route.Match(req, match) { + return true + } + } + return false +} + +// ServeHTTP dispatches the handler registered in the matched route. +// +// When there is a match, the route variables can be retrieved calling +// mux.Vars(request). +func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) { + // Clean path to canonical form and redirect. + if p := cleanPath(req.URL.Path); p != req.URL.Path { + + // Added 3 lines (Philip Schlump) - It was droping the query string and #whatever from query. + // This matches with fix in go 1.2 r.c. 4 for same problem. Go Issue: + // http://code.google.com/p/go/issues/detail?id=5252 + url := *req.URL + url.Path = p + p = url.String() + + w.Header().Set("Location", p) + w.WriteHeader(http.StatusMovedPermanently) + return + } + var match RouteMatch + var handler http.Handler + if r.Match(req, &match) { + handler = match.Handler + setVars(req, match.Vars) + setCurrentRoute(req, match.Route) + } + if handler == nil { + handler = r.NotFoundHandler + if handler == nil { + handler = http.NotFoundHandler() + } + } + if !r.KeepContext { + defer context.Clear(req) + } + handler.ServeHTTP(w, req) +} + +// Get returns a route registered with the given name. +func (r *Router) Get(name string) *Route { + return r.getNamedRoutes()[name] +} + +// GetRoute returns a route registered with the given name. This method +// was renamed to Get() and remains here for backwards compatibility. +func (r *Router) GetRoute(name string) *Route { + return r.getNamedRoutes()[name] +} + +// StrictSlash defines the trailing slash behavior for new routes. The initial +// value is false. +// +// When true, if the route path is "/path/", accessing "/path" will redirect +// to the former and vice versa. In other words, your application will always +// see the path as specified in the route. +// +// When false, if the route path is "/path", accessing "/path/" will not match +// this route and vice versa. +// +// Special case: when a route sets a path prefix using the PathPrefix() method, +// strict slash is ignored for that route because the redirect behavior can't +// be determined from a prefix alone. However, any subrouters created from that +// route inherit the original StrictSlash setting. +func (r *Router) StrictSlash(value bool) *Router { + r.strictSlash = value + return r +} + +// ---------------------------------------------------------------------------- +// parentRoute +// ---------------------------------------------------------------------------- + +// getNamedRoutes returns the map where named routes are registered. +func (r *Router) getNamedRoutes() map[string]*Route { + if r.namedRoutes == nil { + if r.parent != nil { + r.namedRoutes = r.parent.getNamedRoutes() + } else { + r.namedRoutes = make(map[string]*Route) + } + } + return r.namedRoutes +} + +// getRegexpGroup returns regexp definitions from the parent route, if any. +func (r *Router) getRegexpGroup() *routeRegexpGroup { + if r.parent != nil { + return r.parent.getRegexpGroup() + } + return nil +} + +// ---------------------------------------------------------------------------- +// Route factories +// ---------------------------------------------------------------------------- + +// NewRoute registers an empty route. +func (r *Router) NewRoute() *Route { + route := &Route{parent: r, strictSlash: r.strictSlash} + r.routes = append(r.routes, route) + return route +} + +// Handle registers a new route with a matcher for the URL path. +// See Route.Path() and Route.Handler(). +func (r *Router) Handle(path string, handler http.Handler) *Route { + return r.NewRoute().Path(path).Handler(handler) +} + +// HandleFunc registers a new route with a matcher for the URL path. +// See Route.Path() and Route.HandlerFunc(). +func (r *Router) HandleFunc(path string, f func(http.ResponseWriter, + *http.Request)) *Route { + return r.NewRoute().Path(path).HandlerFunc(f) +} + +// Headers registers a new route with a matcher for request header values. +// See Route.Headers(). +func (r *Router) Headers(pairs ...string) *Route { + return r.NewRoute().Headers(pairs...) +} + +// Host registers a new route with a matcher for the URL host. +// See Route.Host(). +func (r *Router) Host(tpl string) *Route { + return r.NewRoute().Host(tpl) +} + +// MatcherFunc registers a new route with a custom matcher function. +// See Route.MatcherFunc(). +func (r *Router) MatcherFunc(f MatcherFunc) *Route { + return r.NewRoute().MatcherFunc(f) +} + +// Methods registers a new route with a matcher for HTTP methods. +// See Route.Methods(). +func (r *Router) Methods(methods ...string) *Route { + return r.NewRoute().Methods(methods...) +} + +// Path registers a new route with a matcher for the URL path. +// See Route.Path(). +func (r *Router) Path(tpl string) *Route { + return r.NewRoute().Path(tpl) +} + +// PathPrefix registers a new route with a matcher for the URL path prefix. +// See Route.PathPrefix(). +func (r *Router) PathPrefix(tpl string) *Route { + return r.NewRoute().PathPrefix(tpl) +} + +// Queries registers a new route with a matcher for URL query values. +// See Route.Queries(). +func (r *Router) Queries(pairs ...string) *Route { + return r.NewRoute().Queries(pairs...) +} + +// Schemes registers a new route with a matcher for URL schemes. +// See Route.Schemes(). +func (r *Router) Schemes(schemes ...string) *Route { + return r.NewRoute().Schemes(schemes...) +} + +// ---------------------------------------------------------------------------- +// Context +// ---------------------------------------------------------------------------- + +// RouteMatch stores information about a matched route. +type RouteMatch struct { + Route *Route + Handler http.Handler + Vars map[string]string +} + +type contextKey int + +const ( + varsKey contextKey = iota + routeKey +) + +// Vars returns the route variables for the current request, if any. +func Vars(r *http.Request) map[string]string { + if rv := context.Get(r, varsKey); rv != nil { + return rv.(map[string]string) + } + return nil +} + +// CurrentRoute returns the matched route for the current request, if any. +func CurrentRoute(r *http.Request) *Route { + if rv := context.Get(r, routeKey); rv != nil { + return rv.(*Route) + } + return nil +} + +func setVars(r *http.Request, val interface{}) { + context.Set(r, varsKey, val) +} + +func setCurrentRoute(r *http.Request, val interface{}) { + context.Set(r, routeKey, val) +} + +// ---------------------------------------------------------------------------- +// Helpers +// ---------------------------------------------------------------------------- + +// cleanPath returns the canonical path for p, eliminating . and .. elements. +// Borrowed from the net/http package. +func cleanPath(p string) string { + if p == "" { + return "/" + } + if p[0] != '/' { + p = "/" + p + } + np := path.Clean(p) + // path.Clean removes trailing slash except for root; + // put the trailing slash back if necessary. + if p[len(p)-1] == '/' && np != "/" { + np += "/" + } + return np +} + +// uniqueVars returns an error if two slices contain duplicated strings. +func uniqueVars(s1, s2 []string) error { + for _, v1 := range s1 { + for _, v2 := range s2 { + if v1 == v2 { + return fmt.Errorf("mux: duplicated route variable %q", v2) + } + } + } + return nil +} + +// mapFromPairs converts variadic string parameters to a string map. +func mapFromPairs(pairs ...string) (map[string]string, error) { + length := len(pairs) + if length%2 != 0 { + return nil, fmt.Errorf( + "mux: number of parameters must be multiple of 2, got %v", pairs) + } + m := make(map[string]string, length/2) + for i := 0; i < length; i += 2 { + m[pairs[i]] = pairs[i+1] + } + return m, nil +} + +// matchInArray returns true if the given string value is in the array. +func matchInArray(arr []string, value string) bool { + for _, v := range arr { + if v == value { + return true + } + } + return false +} + +// matchMap returns true if the given key/value pairs exist in a given map. +func matchMap(toCheck map[string]string, toMatch map[string][]string, + canonicalKey bool) bool { + for k, v := range toCheck { + // Check if key exists. + if canonicalKey { + k = http.CanonicalHeaderKey(k) + } + if values := toMatch[k]; values == nil { + return false + } else if v != "" { + // If value was defined as an empty string we only check that the + // key exists. Otherwise we also check for equality. + valueExists := false + for _, value := range values { + if v == value { + valueExists = true + break + } + } + if !valueExists { + return false + } + } + } + return true +} diff --git a/vendor/github.com/gorilla/mux/regexp.go b/vendor/github.com/gorilla/mux/regexp.go new file mode 100644 index 0000000000..a6305483d5 --- /dev/null +++ b/vendor/github.com/gorilla/mux/regexp.go @@ -0,0 +1,276 @@ +// Copyright 2012 The Gorilla 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 mux + +import ( + "bytes" + "fmt" + "net/http" + "net/url" + "regexp" + "strings" +) + +// newRouteRegexp parses a route template and returns a routeRegexp, +// used to match a host, a path or a query string. +// +// It will extract named variables, assemble a regexp to be matched, create +// a "reverse" template to build URLs and compile regexps to validate variable +// values used in URL building. +// +// Previously we accepted only Python-like identifiers for variable +// names ([a-zA-Z_][a-zA-Z0-9_]*), but currently the only restriction is that +// name and pattern can't be empty, and names can't contain a colon. +func newRouteRegexp(tpl string, matchHost, matchPrefix, matchQuery, strictSlash bool) (*routeRegexp, error) { + // Check if it is well-formed. + idxs, errBraces := braceIndices(tpl) + if errBraces != nil { + return nil, errBraces + } + // Backup the original. + template := tpl + // Now let's parse it. + defaultPattern := "[^/]+" + if matchQuery { + defaultPattern = "[^?&]+" + matchPrefix = true + } else if matchHost { + defaultPattern = "[^.]+" + matchPrefix = false + } + // Only match strict slash if not matching + if matchPrefix || matchHost || matchQuery { + strictSlash = false + } + // Set a flag for strictSlash. + endSlash := false + if strictSlash && strings.HasSuffix(tpl, "/") { + tpl = tpl[:len(tpl)-1] + endSlash = true + } + varsN := make([]string, len(idxs)/2) + varsR := make([]*regexp.Regexp, len(idxs)/2) + pattern := bytes.NewBufferString("") + if !matchQuery { + pattern.WriteByte('^') + } + reverse := bytes.NewBufferString("") + var end int + var err error + for i := 0; i < len(idxs); i += 2 { + // Set all values we are interested in. + raw := tpl[end:idxs[i]] + end = idxs[i+1] + parts := strings.SplitN(tpl[idxs[i]+1:end-1], ":", 2) + name := parts[0] + patt := defaultPattern + if len(parts) == 2 { + patt = parts[1] + } + // Name or pattern can't be empty. + if name == "" || patt == "" { + return nil, fmt.Errorf("mux: missing name or pattern in %q", + tpl[idxs[i]:end]) + } + // Build the regexp pattern. + fmt.Fprintf(pattern, "%s(%s)", regexp.QuoteMeta(raw), patt) + // Build the reverse template. + fmt.Fprintf(reverse, "%s%%s", raw) + // Append variable name and compiled pattern. + varsN[i/2] = name + varsR[i/2], err = regexp.Compile(fmt.Sprintf("^%s$", patt)) + if err != nil { + return nil, err + } + } + // Add the remaining. + raw := tpl[end:] + pattern.WriteString(regexp.QuoteMeta(raw)) + if strictSlash { + pattern.WriteString("[/]?") + } + if !matchPrefix { + pattern.WriteByte('$') + } + reverse.WriteString(raw) + if endSlash { + reverse.WriteByte('/') + } + // Compile full regexp. + reg, errCompile := regexp.Compile(pattern.String()) + if errCompile != nil { + return nil, errCompile + } + // Done! + return &routeRegexp{ + template: template, + matchHost: matchHost, + matchQuery: matchQuery, + strictSlash: strictSlash, + regexp: reg, + reverse: reverse.String(), + varsN: varsN, + varsR: varsR, + }, nil +} + +// routeRegexp stores a regexp to match a host or path and information to +// collect and validate route variables. +type routeRegexp struct { + // The unmodified template. + template string + // True for host match, false for path or query string match. + matchHost bool + // True for query string match, false for path and host match. + matchQuery bool + // The strictSlash value defined on the route, but disabled if PathPrefix was used. + strictSlash bool + // Expanded regexp. + regexp *regexp.Regexp + // Reverse template. + reverse string + // Variable names. + varsN []string + // Variable regexps (validators). + varsR []*regexp.Regexp +} + +// Match matches the regexp against the URL host or path. +func (r *routeRegexp) Match(req *http.Request, match *RouteMatch) bool { + if !r.matchHost { + if r.matchQuery { + return r.regexp.MatchString(req.URL.RawQuery) + } else { + return r.regexp.MatchString(req.URL.Path) + } + } + return r.regexp.MatchString(getHost(req)) +} + +// url builds a URL part using the given values. +func (r *routeRegexp) url(pairs ...string) (string, error) { + values, err := mapFromPairs(pairs...) + if err != nil { + return "", err + } + urlValues := make([]interface{}, len(r.varsN)) + for k, v := range r.varsN { + value, ok := values[v] + if !ok { + return "", fmt.Errorf("mux: missing route variable %q", v) + } + urlValues[k] = value + } + rv := fmt.Sprintf(r.reverse, urlValues...) + if !r.regexp.MatchString(rv) { + // The URL is checked against the full regexp, instead of checking + // individual variables. This is faster but to provide a good error + // message, we check individual regexps if the URL doesn't match. + for k, v := range r.varsN { + if !r.varsR[k].MatchString(values[v]) { + return "", fmt.Errorf( + "mux: variable %q doesn't match, expected %q", values[v], + r.varsR[k].String()) + } + } + } + return rv, nil +} + +// braceIndices returns the first level curly brace indices from a string. +// It returns an error in case of unbalanced braces. +func braceIndices(s string) ([]int, error) { + var level, idx int + idxs := make([]int, 0) + for i := 0; i < len(s); i++ { + switch s[i] { + case '{': + if level++; level == 1 { + idx = i + } + case '}': + if level--; level == 0 { + idxs = append(idxs, idx, i+1) + } else if level < 0 { + return nil, fmt.Errorf("mux: unbalanced braces in %q", s) + } + } + } + if level != 0 { + return nil, fmt.Errorf("mux: unbalanced braces in %q", s) + } + return idxs, nil +} + +// ---------------------------------------------------------------------------- +// routeRegexpGroup +// ---------------------------------------------------------------------------- + +// routeRegexpGroup groups the route matchers that carry variables. +type routeRegexpGroup struct { + host *routeRegexp + path *routeRegexp + queries []*routeRegexp +} + +// setMatch extracts the variables from the URL once a route matches. +func (v *routeRegexpGroup) setMatch(req *http.Request, m *RouteMatch, r *Route) { + // Store host variables. + if v.host != nil { + hostVars := v.host.regexp.FindStringSubmatch(getHost(req)) + if hostVars != nil { + for k, v := range v.host.varsN { + m.Vars[v] = hostVars[k+1] + } + } + } + // Store path variables. + if v.path != nil { + pathVars := v.path.regexp.FindStringSubmatch(req.URL.Path) + if pathVars != nil { + for k, v := range v.path.varsN { + m.Vars[v] = pathVars[k+1] + } + // Check if we should redirect. + if v.path.strictSlash { + p1 := strings.HasSuffix(req.URL.Path, "/") + p2 := strings.HasSuffix(v.path.template, "/") + if p1 != p2 { + u, _ := url.Parse(req.URL.String()) + if p1 { + u.Path = u.Path[:len(u.Path)-1] + } else { + u.Path += "/" + } + m.Handler = http.RedirectHandler(u.String(), 301) + } + } + } + } + // Store query string variables. + rawQuery := req.URL.RawQuery + for _, q := range v.queries { + queryVars := q.regexp.FindStringSubmatch(rawQuery) + if queryVars != nil { + for k, v := range q.varsN { + m.Vars[v] = queryVars[k+1] + } + } + } +} + +// getHost tries its best to return the request host. +func getHost(r *http.Request) string { + if r.URL.IsAbs() { + return r.URL.Host + } + host := r.Host + // Slice off any port information. + if i := strings.Index(host, ":"); i != -1 { + host = host[:i] + } + return host + +} diff --git a/vendor/github.com/gorilla/mux/route.go b/vendor/github.com/gorilla/mux/route.go new file mode 100644 index 0000000000..c310e66bc7 --- /dev/null +++ b/vendor/github.com/gorilla/mux/route.go @@ -0,0 +1,524 @@ +// Copyright 2012 The Gorilla 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 mux + +import ( + "errors" + "fmt" + "net/http" + "net/url" + "strings" +) + +// Route stores information to match a request and build URLs. +type Route struct { + // Parent where the route was registered (a Router). + parent parentRoute + // Request handler for the route. + handler http.Handler + // List of matchers. + matchers []matcher + // Manager for the variables from host and path. + regexp *routeRegexpGroup + // If true, when the path pattern is "/path/", accessing "/path" will + // redirect to the former and vice versa. + strictSlash bool + // If true, this route never matches: it is only used to build URLs. + buildOnly bool + // The name used to build URLs. + name string + // Error resulted from building a route. + err error +} + +// Match matches the route against the request. +func (r *Route) Match(req *http.Request, match *RouteMatch) bool { + if r.buildOnly || r.err != nil { + return false + } + // Match everything. + for _, m := range r.matchers { + if matched := m.Match(req, match); !matched { + return false + } + } + // Yay, we have a match. Let's collect some info about it. + if match.Route == nil { + match.Route = r + } + if match.Handler == nil { + match.Handler = r.handler + } + if match.Vars == nil { + match.Vars = make(map[string]string) + } + // Set variables. + if r.regexp != nil { + r.regexp.setMatch(req, match, r) + } + return true +} + +// ---------------------------------------------------------------------------- +// Route attributes +// ---------------------------------------------------------------------------- + +// GetError returns an error resulted from building the route, if any. +func (r *Route) GetError() error { + return r.err +} + +// BuildOnly sets the route to never match: it is only used to build URLs. +func (r *Route) BuildOnly() *Route { + r.buildOnly = true + return r +} + +// Handler -------------------------------------------------------------------- + +// Handler sets a handler for the route. +func (r *Route) Handler(handler http.Handler) *Route { + if r.err == nil { + r.handler = handler + } + return r +} + +// HandlerFunc sets a handler function for the route. +func (r *Route) HandlerFunc(f func(http.ResponseWriter, *http.Request)) *Route { + return r.Handler(http.HandlerFunc(f)) +} + +// GetHandler returns the handler for the route, if any. +func (r *Route) GetHandler() http.Handler { + return r.handler +} + +// Name ----------------------------------------------------------------------- + +// Name sets the name for the route, used to build URLs. +// If the name was registered already it will be overwritten. +func (r *Route) Name(name string) *Route { + if r.name != "" { + r.err = fmt.Errorf("mux: route already has name %q, can't set %q", + r.name, name) + } + if r.err == nil { + r.name = name + r.getNamedRoutes()[name] = r + } + return r +} + +// GetName returns the name for the route, if any. +func (r *Route) GetName() string { + return r.name +} + +// ---------------------------------------------------------------------------- +// Matchers +// ---------------------------------------------------------------------------- + +// matcher types try to match a request. +type matcher interface { + Match(*http.Request, *RouteMatch) bool +} + +// addMatcher adds a matcher to the route. +func (r *Route) addMatcher(m matcher) *Route { + if r.err == nil { + r.matchers = append(r.matchers, m) + } + return r +} + +// addRegexpMatcher adds a host or path matcher and builder to a route. +func (r *Route) addRegexpMatcher(tpl string, matchHost, matchPrefix, matchQuery bool) error { + if r.err != nil { + return r.err + } + r.regexp = r.getRegexpGroup() + if !matchHost && !matchQuery { + if len(tpl) == 0 || tpl[0] != '/' { + return fmt.Errorf("mux: path must start with a slash, got %q", tpl) + } + if r.regexp.path != nil { + tpl = strings.TrimRight(r.regexp.path.template, "/") + tpl + } + } + rr, err := newRouteRegexp(tpl, matchHost, matchPrefix, matchQuery, r.strictSlash) + if err != nil { + return err + } + for _, q := range r.regexp.queries { + if err = uniqueVars(rr.varsN, q.varsN); err != nil { + return err + } + } + if matchHost { + if r.regexp.path != nil { + if err = uniqueVars(rr.varsN, r.regexp.path.varsN); err != nil { + return err + } + } + r.regexp.host = rr + } else { + if r.regexp.host != nil { + if err = uniqueVars(rr.varsN, r.regexp.host.varsN); err != nil { + return err + } + } + if matchQuery { + r.regexp.queries = append(r.regexp.queries, rr) + } else { + r.regexp.path = rr + } + } + r.addMatcher(rr) + return nil +} + +// Headers -------------------------------------------------------------------- + +// headerMatcher matches the request against header values. +type headerMatcher map[string]string + +func (m headerMatcher) Match(r *http.Request, match *RouteMatch) bool { + return matchMap(m, r.Header, true) +} + +// Headers adds a matcher for request header values. +// It accepts a sequence of key/value pairs to be matched. For example: +// +// r := mux.NewRouter() +// r.Headers("Content-Type", "application/json", +// "X-Requested-With", "XMLHttpRequest") +// +// The above route will only match if both request header values match. +// +// It the value is an empty string, it will match any value if the key is set. +func (r *Route) Headers(pairs ...string) *Route { + if r.err == nil { + var headers map[string]string + headers, r.err = mapFromPairs(pairs...) + return r.addMatcher(headerMatcher(headers)) + } + return r +} + +// Host ----------------------------------------------------------------------- + +// Host adds a matcher for the URL host. +// It accepts a template with zero or more URL variables enclosed by {}. +// Variables can define an optional regexp pattern to me matched: +// +// - {name} matches anything until the next dot. +// +// - {name:pattern} matches the given regexp pattern. +// +// For example: +// +// r := mux.NewRouter() +// r.Host("www.domain.com") +// r.Host("{subdomain}.domain.com") +// r.Host("{subdomain:[a-z]+}.domain.com") +// +// Variable names must be unique in a given route. They can be retrieved +// calling mux.Vars(request). +func (r *Route) Host(tpl string) *Route { + r.err = r.addRegexpMatcher(tpl, true, false, false) + return r +} + +// MatcherFunc ---------------------------------------------------------------- + +// MatcherFunc is the function signature used by custom matchers. +type MatcherFunc func(*http.Request, *RouteMatch) bool + +func (m MatcherFunc) Match(r *http.Request, match *RouteMatch) bool { + return m(r, match) +} + +// MatcherFunc adds a custom function to be used as request matcher. +func (r *Route) MatcherFunc(f MatcherFunc) *Route { + return r.addMatcher(f) +} + +// Methods -------------------------------------------------------------------- + +// methodMatcher matches the request against HTTP methods. +type methodMatcher []string + +func (m methodMatcher) Match(r *http.Request, match *RouteMatch) bool { + return matchInArray(m, r.Method) +} + +// Methods adds a matcher for HTTP methods. +// It accepts a sequence of one or more methods to be matched, e.g.: +// "GET", "POST", "PUT". +func (r *Route) Methods(methods ...string) *Route { + for k, v := range methods { + methods[k] = strings.ToUpper(v) + } + return r.addMatcher(methodMatcher(methods)) +} + +// Path ----------------------------------------------------------------------- + +// Path adds a matcher for the URL path. +// It accepts a template with zero or more URL variables enclosed by {}. The +// template must start with a "/". +// Variables can define an optional regexp pattern to me matched: +// +// - {name} matches anything until the next slash. +// +// - {name:pattern} matches the given regexp pattern. +// +// For example: +// +// r := mux.NewRouter() +// r.Path("/products/").Handler(ProductsHandler) +// r.Path("/products/{key}").Handler(ProductsHandler) +// r.Path("/articles/{category}/{id:[0-9]+}"). +// Handler(ArticleHandler) +// +// Variable names must be unique in a given route. They can be retrieved +// calling mux.Vars(request). +func (r *Route) Path(tpl string) *Route { + r.err = r.addRegexpMatcher(tpl, false, false, false) + return r +} + +// PathPrefix ----------------------------------------------------------------- + +// PathPrefix adds a matcher for the URL path prefix. This matches if the given +// template is a prefix of the full URL path. See Route.Path() for details on +// the tpl argument. +// +// Note that it does not treat slashes specially ("/foobar/" will be matched by +// the prefix "/foo") so you may want to use a trailing slash here. +// +// Also note that the setting of Router.StrictSlash() has no effect on routes +// with a PathPrefix matcher. +func (r *Route) PathPrefix(tpl string) *Route { + r.err = r.addRegexpMatcher(tpl, false, true, false) + return r +} + +// Query ---------------------------------------------------------------------- + +// Queries adds a matcher for URL query values. +// It accepts a sequence of key/value pairs. Values may define variables. +// For example: +// +// r := mux.NewRouter() +// r.Queries("foo", "bar", "id", "{id:[0-9]+}") +// +// The above route will only match if the URL contains the defined queries +// values, e.g.: ?foo=bar&id=42. +// +// It the value is an empty string, it will match any value if the key is set. +// +// Variables can define an optional regexp pattern to me matched: +// +// - {name} matches anything until the next slash. +// +// - {name:pattern} matches the given regexp pattern. +func (r *Route) Queries(pairs ...string) *Route { + length := len(pairs) + if length%2 != 0 { + r.err = fmt.Errorf( + "mux: number of parameters must be multiple of 2, got %v", pairs) + return nil + } + for i := 0; i < length; i += 2 { + if r.err = r.addRegexpMatcher(pairs[i]+"="+pairs[i+1], false, true, true); r.err != nil { + return r + } + } + + return r +} + +// Schemes -------------------------------------------------------------------- + +// schemeMatcher matches the request against URL schemes. +type schemeMatcher []string + +func (m schemeMatcher) Match(r *http.Request, match *RouteMatch) bool { + return matchInArray(m, r.URL.Scheme) +} + +// Schemes adds a matcher for URL schemes. +// It accepts a sequence of schemes to be matched, e.g.: "http", "https". +func (r *Route) Schemes(schemes ...string) *Route { + for k, v := range schemes { + schemes[k] = strings.ToLower(v) + } + return r.addMatcher(schemeMatcher(schemes)) +} + +// Subrouter ------------------------------------------------------------------ + +// Subrouter creates a subrouter for the route. +// +// It will test the inner routes only if the parent route matched. For example: +// +// r := mux.NewRouter() +// s := r.Host("www.domain.com").Subrouter() +// s.HandleFunc("/products/", ProductsHandler) +// s.HandleFunc("/products/{key}", ProductHandler) +// s.HandleFunc("/articles/{category}/{id:[0-9]+}"), ArticleHandler) +// +// Here, the routes registered in the subrouter won't be tested if the host +// doesn't match. +func (r *Route) Subrouter() *Router { + router := &Router{parent: r, strictSlash: r.strictSlash} + r.addMatcher(router) + return router +} + +// ---------------------------------------------------------------------------- +// URL building +// ---------------------------------------------------------------------------- + +// URL builds a URL for the route. +// +// It accepts a sequence of key/value pairs for the route variables. For +// example, given this route: +// +// r := mux.NewRouter() +// r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler). +// Name("article") +// +// ...a URL for it can be built using: +// +// url, err := r.Get("article").URL("category", "technology", "id", "42") +// +// ...which will return an url.URL with the following path: +// +// "/articles/technology/42" +// +// This also works for host variables: +// +// r := mux.NewRouter() +// r.Host("{subdomain}.domain.com"). +// HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler). +// Name("article") +// +// // url.String() will be "http://news.domain.com/articles/technology/42" +// url, err := r.Get("article").URL("subdomain", "news", +// "category", "technology", +// "id", "42") +// +// All variables defined in the route are required, and their values must +// conform to the corresponding patterns. +func (r *Route) URL(pairs ...string) (*url.URL, error) { + if r.err != nil { + return nil, r.err + } + if r.regexp == nil { + return nil, errors.New("mux: route doesn't have a host or path") + } + var scheme, host, path string + var err error + if r.regexp.host != nil { + // Set a default scheme. + scheme = "http" + if host, err = r.regexp.host.url(pairs...); err != nil { + return nil, err + } + } + if r.regexp.path != nil { + if path, err = r.regexp.path.url(pairs...); err != nil { + return nil, err + } + } + return &url.URL{ + Scheme: scheme, + Host: host, + Path: path, + }, nil +} + +// URLHost builds the host part of the URL for a route. See Route.URL(). +// +// The route must have a host defined. +func (r *Route) URLHost(pairs ...string) (*url.URL, error) { + if r.err != nil { + return nil, r.err + } + if r.regexp == nil || r.regexp.host == nil { + return nil, errors.New("mux: route doesn't have a host") + } + host, err := r.regexp.host.url(pairs...) + if err != nil { + return nil, err + } + return &url.URL{ + Scheme: "http", + Host: host, + }, nil +} + +// URLPath builds the path part of the URL for a route. See Route.URL(). +// +// The route must have a path defined. +func (r *Route) URLPath(pairs ...string) (*url.URL, error) { + if r.err != nil { + return nil, r.err + } + if r.regexp == nil || r.regexp.path == nil { + return nil, errors.New("mux: route doesn't have a path") + } + path, err := r.regexp.path.url(pairs...) + if err != nil { + return nil, err + } + return &url.URL{ + Path: path, + }, nil +} + +// ---------------------------------------------------------------------------- +// parentRoute +// ---------------------------------------------------------------------------- + +// parentRoute allows routes to know about parent host and path definitions. +type parentRoute interface { + getNamedRoutes() map[string]*Route + getRegexpGroup() *routeRegexpGroup +} + +// getNamedRoutes returns the map where named routes are registered. +func (r *Route) getNamedRoutes() map[string]*Route { + if r.parent == nil { + // During tests router is not always set. + r.parent = NewRouter() + } + return r.parent.getNamedRoutes() +} + +// getRegexpGroup returns regexp definitions from this route. +func (r *Route) getRegexpGroup() *routeRegexpGroup { + if r.regexp == nil { + if r.parent == nil { + // During tests router is not always set. + r.parent = NewRouter() + } + regexp := r.parent.getRegexpGroup() + if regexp == nil { + r.regexp = new(routeRegexpGroup) + } else { + // Copy. + r.regexp = &routeRegexpGroup{ + host: regexp.host, + path: regexp.path, + queries: regexp.queries, + } + } + } + return r.regexp +} diff --git a/vendor/github.com/hashicorp/errwrap/LICENSE b/vendor/github.com/hashicorp/errwrap/LICENSE new file mode 100644 index 0000000000..c33dcc7c92 --- /dev/null +++ b/vendor/github.com/hashicorp/errwrap/LICENSE @@ -0,0 +1,354 @@ +Mozilla Public License, version 2.0 + +1. Definitions + +1.1. “Contributor” + + means each individual or legal entity that creates, contributes to the + creation of, or owns Covered Software. + +1.2. “Contributor Version” + + means the combination of the Contributions of others (if any) used by a + Contributor and that particular Contributor’s Contribution. + +1.3. “Contribution” + + means Covered Software of a particular Contributor. + +1.4. “Covered Software” + + means Source Code Form to which the initial Contributor has attached the + notice in Exhibit A, the Executable Form of such Source Code Form, and + Modifications of such Source Code Form, in each case including portions + thereof. + +1.5. “Incompatible With Secondary Licenses” + means + + a. that the initial Contributor has attached the notice described in + Exhibit B to the Covered Software; or + + b. that the Covered Software was made available under the terms of version + 1.1 or earlier of the License, but not also under the terms of a + Secondary License. + +1.6. “Executable Form” + + means any form of the work other than Source Code Form. + +1.7. “Larger Work” + + means a work that combines Covered Software with other material, in a separate + file or files, that is not Covered Software. + +1.8. “License” + + means this document. + +1.9. “Licensable” + + means having the right to grant, to the maximum extent possible, whether at the + time of the initial grant or subsequently, any and all of the rights conveyed by + this License. + +1.10. “Modifications” + + means any of the following: + + a. any file in Source Code Form that results from an addition to, deletion + from, or modification of the contents of Covered Software; or + + b. any new file in Source Code Form that contains any Covered Software. + +1.11. “Patent Claims” of a Contributor + + means any patent claim(s), including without limitation, method, process, + and apparatus claims, in any patent Licensable by such Contributor that + would be infringed, but for the grant of the License, by the making, + using, selling, offering for sale, having made, import, or transfer of + either its Contributions or its Contributor Version. + +1.12. “Secondary License” + + means either the GNU General Public License, Version 2.0, the GNU Lesser + General Public License, Version 2.1, the GNU Affero General Public + License, Version 3.0, or any later versions of those licenses. + +1.13. “Source Code Form” + + means the form of the work preferred for making modifications. + +1.14. “You” (or “Your”) + + means an individual or a legal entity exercising rights under this + License. For legal entities, “You” includes any entity that controls, is + controlled by, or is under common control with You. For purposes of this + definition, “control” means (a) the power, direct or indirect, to cause + the direction or management of such entity, whether by contract or + otherwise, or (b) ownership of more than fifty percent (50%) of the + outstanding shares or beneficial ownership of such entity. + + +2. License Grants and Conditions + +2.1. Grants + + Each Contributor hereby grants You a world-wide, royalty-free, + non-exclusive license: + + a. under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or as + part of a Larger Work; and + + b. under Patent Claims of such Contributor to make, use, sell, offer for + sale, have made, import, and otherwise transfer either its Contributions + or its Contributor Version. + +2.2. Effective Date + + The licenses granted in Section 2.1 with respect to any Contribution become + effective for each Contribution on the date the Contributor first distributes + such Contribution. + +2.3. Limitations on Grant Scope + + The licenses granted in this Section 2 are the only rights granted under this + License. No additional rights or licenses will be implied from the distribution + or licensing of Covered Software under this License. Notwithstanding Section + 2.1(b) above, no patent license is granted by a Contributor: + + a. for any code that a Contributor has removed from Covered Software; or + + b. for infringements caused by: (i) Your and any other third party’s + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + + c. under Patent Claims infringed by Covered Software in the absence of its + Contributions. + + This License does not grant any rights in the trademarks, service marks, or + logos of any Contributor (except as may be necessary to comply with the + notice requirements in Section 3.4). + +2.4. Subsequent Licenses + + No Contributor makes additional grants as a result of Your choice to + distribute the Covered Software under a subsequent version of this License + (see Section 10.2) or under the terms of a Secondary License (if permitted + under the terms of Section 3.3). + +2.5. Representation + + Each Contributor represents that the Contributor believes its Contributions + are its original creation(s) or it has sufficient rights to grant the + rights to its Contributions conveyed by this License. + +2.6. Fair Use + + This License is not intended to limit any rights You have under applicable + copyright doctrines of fair use, fair dealing, or other equivalents. + +2.7. Conditions + + Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in + Section 2.1. + + +3. Responsibilities + +3.1. Distribution of Source Form + + All distribution of Covered Software in Source Code Form, including any + Modifications that You create or to which You contribute, must be under the + terms of this License. You must inform recipients that the Source Code Form + of the Covered Software is governed by the terms of this License, and how + they can obtain a copy of this License. You may not attempt to alter or + restrict the recipients’ rights in the Source Code Form. + +3.2. Distribution of Executable Form + + If You distribute Covered Software in Executable Form then: + + a. such Covered Software must also be made available in Source Code Form, + as described in Section 3.1, and You must inform recipients of the + Executable Form how they can obtain a copy of such Source Code Form by + reasonable means in a timely manner, at a charge no more than the cost + of distribution to the recipient; and + + b. You may distribute such Executable Form under the terms of this License, + or sublicense it under different terms, provided that the license for + the Executable Form does not attempt to limit or alter the recipients’ + rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + + You may create and distribute a Larger Work under terms of Your choice, + provided that You also comply with the requirements of this License for the + Covered Software. If the Larger Work is a combination of Covered Software + with a work governed by one or more Secondary Licenses, and the Covered + Software is not Incompatible With Secondary Licenses, this License permits + You to additionally distribute such Covered Software under the terms of + such Secondary License(s), so that the recipient of the Larger Work may, at + their option, further distribute the Covered Software under the terms of + either this License or such Secondary License(s). + +3.4. Notices + + You may not remove or alter the substance of any license notices (including + copyright notices, patent notices, disclaimers of warranty, or limitations + of liability) contained within the Source Code Form of the Covered + Software, except that You may alter any license notices to the extent + required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + + You may choose to offer, and to charge a fee for, warranty, support, + indemnity or liability obligations to one or more recipients of Covered + Software. However, You may do so only on Your own behalf, and not on behalf + of any Contributor. You must make it absolutely clear that any such + warranty, support, indemnity, or liability obligation is offered by You + alone, and You hereby agree to indemnify every Contributor for any + liability incurred by such Contributor as a result of warranty, support, + indemnity or liability terms You offer. You may include additional + disclaimers of warranty and limitations of liability specific to any + jurisdiction. + +4. Inability to Comply Due to Statute or Regulation + + If it is impossible for You to comply with any of the terms of this License + with respect to some or all of the Covered Software due to statute, judicial + order, or regulation then You must: (a) comply with the terms of this License + to the maximum extent possible; and (b) describe the limitations and the code + they affect. Such description must be placed in a text file included with all + distributions of the Covered Software under this License. Except to the + extent prohibited by statute or regulation, such description must be + sufficiently detailed for a recipient of ordinary skill to be able to + understand it. + +5. Termination + +5.1. The rights granted under this License will terminate automatically if You + fail to comply with any of its terms. However, if You become compliant, + then the rights granted under this License from a particular Contributor + are reinstated (a) provisionally, unless and until such Contributor + explicitly and finally terminates Your grants, and (b) on an ongoing basis, + if such Contributor fails to notify You of the non-compliance by some + reasonable means prior to 60 days after You have come back into compliance. + Moreover, Your grants from a particular Contributor are reinstated on an + ongoing basis if such Contributor notifies You of the non-compliance by + some reasonable means, this is the first time You have received notice of + non-compliance with this License from such Contributor, and You become + compliant prior to 30 days after Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent + infringement claim (excluding declaratory judgment actions, counter-claims, + and cross-claims) alleging that a Contributor Version directly or + indirectly infringes any patent, then the rights granted to You by any and + all Contributors for the Covered Software under Section 2.1 of this License + shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user + license agreements (excluding distributors and resellers) which have been + validly granted by You or Your distributors under this License prior to + termination shall survive termination. + +6. Disclaimer of Warranty + + Covered Software is provided under this License on an “as is” basis, without + warranty of any kind, either expressed, implied, or statutory, including, + without limitation, warranties that the Covered Software is free of defects, + merchantable, fit for a particular purpose or non-infringing. The entire + risk as to the quality and performance of the Covered Software is with You. + Should any Covered Software prove defective in any respect, You (not any + Contributor) assume the cost of any necessary servicing, repair, or + correction. This disclaimer of warranty constitutes an essential part of this + License. No use of any Covered Software is authorized under this License + except under this disclaimer. + +7. Limitation of Liability + + Under no circumstances and under no legal theory, whether tort (including + negligence), contract, or otherwise, shall any Contributor, or anyone who + distributes Covered Software as permitted above, be liable to You for any + direct, indirect, special, incidental, or consequential damages of any + character including, without limitation, damages for lost profits, loss of + goodwill, work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses, even if such party shall have been + informed of the possibility of such damages. This limitation of liability + shall not apply to liability for death or personal injury resulting from such + party’s negligence to the extent applicable law prohibits such limitation. + Some jurisdictions do not allow the exclusion or limitation of incidental or + consequential damages, so this exclusion and limitation may not apply to You. + +8. Litigation + + Any litigation relating to this License may be brought only in the courts of + a jurisdiction where the defendant maintains its principal place of business + and such litigation shall be governed by laws of that jurisdiction, without + reference to its conflict-of-law provisions. Nothing in this Section shall + prevent a party’s ability to bring cross-claims or counter-claims. + +9. Miscellaneous + + This License represents the complete agreement concerning the subject matter + hereof. If any provision of this License is held to be unenforceable, such + provision shall be reformed only to the extent necessary to make it + enforceable. Any law or regulation which provides that the language of a + contract shall be construed against the drafter shall not be used to construe + this License against a Contributor. + + +10. Versions of the License + +10.1. New Versions + + Mozilla Foundation is the license steward. Except as provided in Section + 10.3, no one other than the license steward has the right to modify or + publish new versions of this License. Each version will be given a + distinguishing version number. + +10.2. Effect of New Versions + + You may distribute the Covered Software under the terms of the version of + the License under which You originally received the Covered Software, or + under the terms of any subsequent version published by the license + steward. + +10.3. Modified Versions + + If you create software not governed by this License, and you want to + create a new license for such software, you may create and use a modified + version of this License if you rename the license and remove any + references to the name of the license steward (except to note that such + modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses + If You choose to distribute Source Code Form that is Incompatible With + Secondary Licenses under the terms of this version of the License, the + notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice + + This Source Code Form is subject to the + terms of the Mozilla Public License, v. + 2.0. If a copy of the MPL was not + distributed with this file, You can + obtain one at + http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular file, then +You may include the notice in a location (such as a LICENSE file in a relevant +directory) where a recipient would be likely to look for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - “Incompatible With Secondary Licenses” Notice + + This Source Code Form is “Incompatible + With Secondary Licenses”, as defined by + the Mozilla Public License, v. 2.0. + diff --git a/vendor/github.com/hashicorp/errwrap/errwrap.go b/vendor/github.com/hashicorp/errwrap/errwrap.go new file mode 100644 index 0000000000..a733bef18c --- /dev/null +++ b/vendor/github.com/hashicorp/errwrap/errwrap.go @@ -0,0 +1,169 @@ +// Package errwrap implements methods to formalize error wrapping in Go. +// +// All of the top-level functions that take an `error` are built to be able +// to take any error, not just wrapped errors. This allows you to use errwrap +// without having to type-check and type-cast everywhere. +package errwrap + +import ( + "errors" + "reflect" + "strings" +) + +// WalkFunc is the callback called for Walk. +type WalkFunc func(error) + +// Wrapper is an interface that can be implemented by custom types to +// have all the Contains, Get, etc. functions in errwrap work. +// +// When Walk reaches a Wrapper, it will call the callback for every +// wrapped error in addition to the wrapper itself. Since all the top-level +// functions in errwrap use Walk, this means that all those functions work +// with your custom type. +type Wrapper interface { + WrappedErrors() []error +} + +// Wrap defines that outer wraps inner, returning an error type that +// can be cleanly used with the other methods in this package, such as +// Contains, GetAll, etc. +// +// This function won't modify the error message at all (the outer message +// will be used). +func Wrap(outer, inner error) error { + return &wrappedError{ + Outer: outer, + Inner: inner, + } +} + +// Wrapf wraps an error with a formatting message. This is similar to using +// `fmt.Errorf` to wrap an error. If you're using `fmt.Errorf` to wrap +// errors, you should replace it with this. +// +// format is the format of the error message. The string '{{err}}' will +// be replaced with the original error message. +func Wrapf(format string, err error) error { + outerMsg := "" + if err != nil { + outerMsg = err.Error() + } + + outer := errors.New(strings.Replace( + format, "{{err}}", outerMsg, -1)) + + return Wrap(outer, err) +} + +// Contains checks if the given error contains an error with the +// message msg. If err is not a wrapped error, this will always return +// false unless the error itself happens to match this msg. +func Contains(err error, msg string) bool { + return len(GetAll(err, msg)) > 0 +} + +// ContainsType checks if the given error contains an error with +// the same concrete type as v. If err is not a wrapped error, this will +// check the err itself. +func ContainsType(err error, v interface{}) bool { + return len(GetAllType(err, v)) > 0 +} + +// Get is the same as GetAll but returns the deepest matching error. +func Get(err error, msg string) error { + es := GetAll(err, msg) + if len(es) > 0 { + return es[len(es)-1] + } + + return nil +} + +// GetType is the same as GetAllType but returns the deepest matching error. +func GetType(err error, v interface{}) error { + es := GetAllType(err, v) + if len(es) > 0 { + return es[len(es)-1] + } + + return nil +} + +// GetAll gets all the errors that might be wrapped in err with the +// given message. The order of the errors is such that the outermost +// matching error (the most recent wrap) is index zero, and so on. +func GetAll(err error, msg string) []error { + var result []error + + Walk(err, func(err error) { + if err.Error() == msg { + result = append(result, err) + } + }) + + return result +} + +// GetAllType gets all the errors that are the same type as v. +// +// The order of the return value is the same as described in GetAll. +func GetAllType(err error, v interface{}) []error { + var result []error + + var search string + if v != nil { + search = reflect.TypeOf(v).String() + } + Walk(err, func(err error) { + var needle string + if err != nil { + needle = reflect.TypeOf(err).String() + } + + if needle == search { + result = append(result, err) + } + }) + + return result +} + +// Walk walks all the wrapped errors in err and calls the callback. If +// err isn't a wrapped error, this will be called once for err. If err +// is a wrapped error, the callback will be called for both the wrapper +// that implements error as well as the wrapped error itself. +func Walk(err error, cb WalkFunc) { + if err == nil { + return + } + + switch e := err.(type) { + case *wrappedError: + cb(e.Outer) + Walk(e.Inner, cb) + case Wrapper: + cb(err) + + for _, err := range e.WrappedErrors() { + Walk(err, cb) + } + default: + cb(err) + } +} + +// wrappedError is an implementation of error that has both the +// outer and inner errors. +type wrappedError struct { + Outer error + Inner error +} + +func (w *wrappedError) Error() string { + return w.Outer.Error() +} + +func (w *wrappedError) WrappedErrors() []error { + return []error{w.Outer, w.Inner} +} diff --git a/vendor/github.com/hydrogen18/stoppableListener/LICENSE b/vendor/github.com/hydrogen18/stoppableListener/LICENSE new file mode 100644 index 0000000000..efcb2414a3 --- /dev/null +++ b/vendor/github.com/hydrogen18/stoppableListener/LICENSE @@ -0,0 +1,10 @@ +Copyright (c) 2014, Eric Urban +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. + +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. \ No newline at end of file diff --git a/vendor/github.com/hydrogen18/stoppableListener/listener.go b/vendor/github.com/hydrogen18/stoppableListener/listener.go new file mode 100644 index 0000000000..69a9f33cc3 --- /dev/null +++ b/vendor/github.com/hydrogen18/stoppableListener/listener.go @@ -0,0 +1,62 @@ +package stoppableListener + +import ( + "errors" + "net" + "time" +) + +type StoppableListener struct { + *net.TCPListener //Wrapped listener + stop chan int //Channel used only to indicate listener should shutdown +} + +func New(l net.Listener) (*StoppableListener, error) { + tcpL, ok := l.(*net.TCPListener) + + if !ok { + return nil, errors.New("Cannot wrap listener") + } + + retval := &StoppableListener{} + retval.TCPListener = tcpL + retval.stop = make(chan int) + + return retval, nil +} + +var StoppedError = errors.New("Listener stopped") + +func (sl *StoppableListener) Accept() (net.Conn, error) { + + for { + //Wait up to one second for a new connection + sl.SetDeadline(time.Now().Add(time.Second)) + + newConn, err := sl.TCPListener.Accept() + + //Check for the channel being closed + select { + case <-sl.stop: + return nil, StoppedError + default: + //If the channel is still open, continue as normal + } + + if err != nil { + netErr, ok := err.(net.Error) + + //If this is a timeout, then continue to wait for + //new connections + if ok && netErr.Timeout() && netErr.Temporary() { + continue + } + } + + return newConn, err + } +} + +func (sl *StoppableListener) Stop() { + close(sl.stop) +} diff --git a/vendor/github.com/inconshreveable/mousetrap/LICENSE b/vendor/github.com/inconshreveable/mousetrap/LICENSE new file mode 100644 index 0000000000..5f0d1fb6a7 --- /dev/null +++ b/vendor/github.com/inconshreveable/mousetrap/LICENSE @@ -0,0 +1,13 @@ +Copyright 2014 Alan Shreve + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/vendor/github.com/inconshreveable/mousetrap/trap_others.go b/vendor/github.com/inconshreveable/mousetrap/trap_others.go new file mode 100644 index 0000000000..9d2d8a4bab --- /dev/null +++ b/vendor/github.com/inconshreveable/mousetrap/trap_others.go @@ -0,0 +1,15 @@ +// +build !windows + +package mousetrap + +// StartedByExplorer returns true if the program was invoked by the user +// double-clicking on the executable from explorer.exe +// +// It is conservative and returns false if any of the internal calls fail. +// It does not guarantee that the program was run from a terminal. It only can tell you +// whether it was launched from explorer.exe +// +// On non-Windows platforms, it always returns false. +func StartedByExplorer() bool { + return false +} diff --git a/vendor/github.com/inconshreveable/mousetrap/trap_windows.go b/vendor/github.com/inconshreveable/mousetrap/trap_windows.go new file mode 100644 index 0000000000..336142a5e3 --- /dev/null +++ b/vendor/github.com/inconshreveable/mousetrap/trap_windows.go @@ -0,0 +1,98 @@ +// +build windows +// +build !go1.4 + +package mousetrap + +import ( + "fmt" + "os" + "syscall" + "unsafe" +) + +const ( + // defined by the Win32 API + th32cs_snapprocess uintptr = 0x2 +) + +var ( + kernel = syscall.MustLoadDLL("kernel32.dll") + CreateToolhelp32Snapshot = kernel.MustFindProc("CreateToolhelp32Snapshot") + Process32First = kernel.MustFindProc("Process32FirstW") + Process32Next = kernel.MustFindProc("Process32NextW") +) + +// ProcessEntry32 structure defined by the Win32 API +type processEntry32 struct { + dwSize uint32 + cntUsage uint32 + th32ProcessID uint32 + th32DefaultHeapID int + th32ModuleID uint32 + cntThreads uint32 + th32ParentProcessID uint32 + pcPriClassBase int32 + dwFlags uint32 + szExeFile [syscall.MAX_PATH]uint16 +} + +func getProcessEntry(pid int) (pe *processEntry32, err error) { + snapshot, _, e1 := CreateToolhelp32Snapshot.Call(th32cs_snapprocess, uintptr(0)) + if snapshot == uintptr(syscall.InvalidHandle) { + err = fmt.Errorf("CreateToolhelp32Snapshot: %v", e1) + return + } + defer syscall.CloseHandle(syscall.Handle(snapshot)) + + var processEntry processEntry32 + processEntry.dwSize = uint32(unsafe.Sizeof(processEntry)) + ok, _, e1 := Process32First.Call(snapshot, uintptr(unsafe.Pointer(&processEntry))) + if ok == 0 { + err = fmt.Errorf("Process32First: %v", e1) + return + } + + for { + if processEntry.th32ProcessID == uint32(pid) { + pe = &processEntry + return + } + + ok, _, e1 = Process32Next.Call(snapshot, uintptr(unsafe.Pointer(&processEntry))) + if ok == 0 { + err = fmt.Errorf("Process32Next: %v", e1) + return + } + } +} + +func getppid() (pid int, err error) { + pe, err := getProcessEntry(os.Getpid()) + if err != nil { + return + } + + pid = int(pe.th32ParentProcessID) + return +} + +// StartedByExplorer returns true if the program was invoked by the user double-clicking +// on the executable from explorer.exe +// +// It is conservative and returns false if any of the internal calls fail. +// It does not guarantee that the program was run from a terminal. It only can tell you +// whether it was launched from explorer.exe +func StartedByExplorer() bool { + ppid, err := getppid() + if err != nil { + return false + } + + pe, err := getProcessEntry(ppid) + if err != nil { + return false + } + + name := syscall.UTF16ToString(pe.szExeFile[:]) + return name == "explorer.exe" +} diff --git a/vendor/github.com/inconshreveable/mousetrap/trap_windows_1.4.go b/vendor/github.com/inconshreveable/mousetrap/trap_windows_1.4.go new file mode 100644 index 0000000000..9a28e57c3c --- /dev/null +++ b/vendor/github.com/inconshreveable/mousetrap/trap_windows_1.4.go @@ -0,0 +1,46 @@ +// +build windows +// +build go1.4 + +package mousetrap + +import ( + "os" + "syscall" + "unsafe" +) + +func getProcessEntry(pid int) (*syscall.ProcessEntry32, error) { + snapshot, err := syscall.CreateToolhelp32Snapshot(syscall.TH32CS_SNAPPROCESS, 0) + if err != nil { + return nil, err + } + defer syscall.CloseHandle(snapshot) + var procEntry syscall.ProcessEntry32 + procEntry.Size = uint32(unsafe.Sizeof(procEntry)) + if err = syscall.Process32First(snapshot, &procEntry); err != nil { + return nil, err + } + for { + if procEntry.ProcessID == uint32(pid) { + return &procEntry, nil + } + err = syscall.Process32Next(snapshot, &procEntry) + if err != nil { + return nil, err + } + } +} + +// StartedByExplorer returns true if the program was invoked by the user double-clicking +// on the executable from explorer.exe +// +// It is conservative and returns false if any of the internal calls fail. +// It does not guarantee that the program was run from a terminal. It only can tell you +// whether it was launched from explorer.exe +func StartedByExplorer() bool { + pe, err := getProcessEntry(os.Getppid()) + if err != nil { + return false + } + return "explorer.exe" == syscall.UTF16ToString(pe.ExeFile[:]) +} diff --git a/vendor/github.com/jmespath/go-jmespath/LICENSE b/vendor/github.com/jmespath/go-jmespath/LICENSE new file mode 100644 index 0000000000..b03310a91f --- /dev/null +++ b/vendor/github.com/jmespath/go-jmespath/LICENSE @@ -0,0 +1,13 @@ +Copyright 2015 James Saryerwinnie + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/vendor/github.com/jmespath/go-jmespath/api.go b/vendor/github.com/jmespath/go-jmespath/api.go new file mode 100644 index 0000000000..9cfa988bc5 --- /dev/null +++ b/vendor/github.com/jmespath/go-jmespath/api.go @@ -0,0 +1,49 @@ +package jmespath + +import "strconv" + +// JmesPath is the epresentation of a compiled JMES path query. A JmesPath is +// safe for concurrent use by multiple goroutines. +type JMESPath struct { + ast ASTNode + intr *treeInterpreter +} + +// Compile parses a JMESPath expression and returns, if successful, a JMESPath +// object that can be used to match against data. +func Compile(expression string) (*JMESPath, error) { + parser := NewParser() + ast, err := parser.Parse(expression) + if err != nil { + return nil, err + } + jmespath := &JMESPath{ast: ast, intr: newInterpreter()} + return jmespath, nil +} + +// MustCompile is like Compile but panics if the expression cannot be parsed. +// It simplifies safe initialization of global variables holding compiled +// JMESPaths. +func MustCompile(expression string) *JMESPath { + jmespath, err := Compile(expression) + if err != nil { + panic(`jmespath: Compile(` + strconv.Quote(expression) + `): ` + err.Error()) + } + return jmespath +} + +// Search evaluates a JMESPath expression against input data and returns the result. +func (jp *JMESPath) Search(data interface{}) (interface{}, error) { + return jp.intr.Execute(jp.ast, data) +} + +// Search evaluates a JMESPath expression against input data and returns the result. +func Search(expression string, data interface{}) (interface{}, error) { + intr := newInterpreter() + parser := NewParser() + ast, err := parser.Parse(expression) + if err != nil { + return nil, err + } + return intr.Execute(ast, data) +} diff --git a/vendor/github.com/jmespath/go-jmespath/astnodetype_string.go b/vendor/github.com/jmespath/go-jmespath/astnodetype_string.go new file mode 100644 index 0000000000..1cd2d239c9 --- /dev/null +++ b/vendor/github.com/jmespath/go-jmespath/astnodetype_string.go @@ -0,0 +1,16 @@ +// generated by stringer -type astNodeType; DO NOT EDIT + +package jmespath + +import "fmt" + +const _astNodeType_name = "ASTEmptyASTComparatorASTCurrentNodeASTExpRefASTFunctionExpressionASTFieldASTFilterProjectionASTFlattenASTIdentityASTIndexASTIndexExpressionASTKeyValPairASTLiteralASTMultiSelectHashASTMultiSelectListASTOrExpressionASTAndExpressionASTNotExpressionASTPipeASTProjectionASTSubexpressionASTSliceASTValueProjection" + +var _astNodeType_index = [...]uint16{0, 8, 21, 35, 44, 65, 73, 92, 102, 113, 121, 139, 152, 162, 180, 198, 213, 229, 245, 252, 265, 281, 289, 307} + +func (i astNodeType) String() string { + if i < 0 || i >= astNodeType(len(_astNodeType_index)-1) { + return fmt.Sprintf("astNodeType(%d)", i) + } + return _astNodeType_name[_astNodeType_index[i]:_astNodeType_index[i+1]] +} diff --git a/vendor/github.com/jmespath/go-jmespath/functions.go b/vendor/github.com/jmespath/go-jmespath/functions.go new file mode 100644 index 0000000000..9b7cd89b4b --- /dev/null +++ b/vendor/github.com/jmespath/go-jmespath/functions.go @@ -0,0 +1,842 @@ +package jmespath + +import ( + "encoding/json" + "errors" + "fmt" + "math" + "reflect" + "sort" + "strconv" + "strings" + "unicode/utf8" +) + +type jpFunction func(arguments []interface{}) (interface{}, error) + +type jpType string + +const ( + jpUnknown jpType = "unknown" + jpNumber jpType = "number" + jpString jpType = "string" + jpArray jpType = "array" + jpObject jpType = "object" + jpArrayNumber jpType = "array[number]" + jpArrayString jpType = "array[string]" + jpExpref jpType = "expref" + jpAny jpType = "any" +) + +type functionEntry struct { + name string + arguments []argSpec + handler jpFunction + hasExpRef bool +} + +type argSpec struct { + types []jpType + variadic bool +} + +type byExprString struct { + intr *treeInterpreter + node ASTNode + items []interface{} + hasError bool +} + +func (a *byExprString) Len() int { + return len(a.items) +} +func (a *byExprString) Swap(i, j int) { + a.items[i], a.items[j] = a.items[j], a.items[i] +} +func (a *byExprString) Less(i, j int) bool { + first, err := a.intr.Execute(a.node, a.items[i]) + if err != nil { + a.hasError = true + // Return a dummy value. + return true + } + ith, ok := first.(string) + if !ok { + a.hasError = true + return true + } + second, err := a.intr.Execute(a.node, a.items[j]) + if err != nil { + a.hasError = true + // Return a dummy value. + return true + } + jth, ok := second.(string) + if !ok { + a.hasError = true + return true + } + return ith < jth +} + +type byExprFloat struct { + intr *treeInterpreter + node ASTNode + items []interface{} + hasError bool +} + +func (a *byExprFloat) Len() int { + return len(a.items) +} +func (a *byExprFloat) Swap(i, j int) { + a.items[i], a.items[j] = a.items[j], a.items[i] +} +func (a *byExprFloat) Less(i, j int) bool { + first, err := a.intr.Execute(a.node, a.items[i]) + if err != nil { + a.hasError = true + // Return a dummy value. + return true + } + ith, ok := first.(float64) + if !ok { + a.hasError = true + return true + } + second, err := a.intr.Execute(a.node, a.items[j]) + if err != nil { + a.hasError = true + // Return a dummy value. + return true + } + jth, ok := second.(float64) + if !ok { + a.hasError = true + return true + } + return ith < jth +} + +type functionCaller struct { + functionTable map[string]functionEntry +} + +func newFunctionCaller() *functionCaller { + caller := &functionCaller{} + caller.functionTable = map[string]functionEntry{ + "length": { + name: "length", + arguments: []argSpec{ + {types: []jpType{jpString, jpArray, jpObject}}, + }, + handler: jpfLength, + }, + "starts_with": { + name: "starts_with", + arguments: []argSpec{ + {types: []jpType{jpString}}, + {types: []jpType{jpString}}, + }, + handler: jpfStartsWith, + }, + "abs": { + name: "abs", + arguments: []argSpec{ + {types: []jpType{jpNumber}}, + }, + handler: jpfAbs, + }, + "avg": { + name: "avg", + arguments: []argSpec{ + {types: []jpType{jpArrayNumber}}, + }, + handler: jpfAvg, + }, + "ceil": { + name: "ceil", + arguments: []argSpec{ + {types: []jpType{jpNumber}}, + }, + handler: jpfCeil, + }, + "contains": { + name: "contains", + arguments: []argSpec{ + {types: []jpType{jpArray, jpString}}, + {types: []jpType{jpAny}}, + }, + handler: jpfContains, + }, + "ends_with": { + name: "ends_with", + arguments: []argSpec{ + {types: []jpType{jpString}}, + {types: []jpType{jpString}}, + }, + handler: jpfEndsWith, + }, + "floor": { + name: "floor", + arguments: []argSpec{ + {types: []jpType{jpNumber}}, + }, + handler: jpfFloor, + }, + "map": { + name: "amp", + arguments: []argSpec{ + {types: []jpType{jpExpref}}, + {types: []jpType{jpArray}}, + }, + handler: jpfMap, + hasExpRef: true, + }, + "max": { + name: "max", + arguments: []argSpec{ + {types: []jpType{jpArrayNumber, jpArrayString}}, + }, + handler: jpfMax, + }, + "merge": { + name: "merge", + arguments: []argSpec{ + {types: []jpType{jpObject}, variadic: true}, + }, + handler: jpfMerge, + }, + "max_by": { + name: "max_by", + arguments: []argSpec{ + {types: []jpType{jpArray}}, + {types: []jpType{jpExpref}}, + }, + handler: jpfMaxBy, + hasExpRef: true, + }, + "sum": { + name: "sum", + arguments: []argSpec{ + {types: []jpType{jpArrayNumber}}, + }, + handler: jpfSum, + }, + "min": { + name: "min", + arguments: []argSpec{ + {types: []jpType{jpArrayNumber, jpArrayString}}, + }, + handler: jpfMin, + }, + "min_by": { + name: "min_by", + arguments: []argSpec{ + {types: []jpType{jpArray}}, + {types: []jpType{jpExpref}}, + }, + handler: jpfMinBy, + hasExpRef: true, + }, + "type": { + name: "type", + arguments: []argSpec{ + {types: []jpType{jpAny}}, + }, + handler: jpfType, + }, + "keys": { + name: "keys", + arguments: []argSpec{ + {types: []jpType{jpObject}}, + }, + handler: jpfKeys, + }, + "values": { + name: "values", + arguments: []argSpec{ + {types: []jpType{jpObject}}, + }, + handler: jpfValues, + }, + "sort": { + name: "sort", + arguments: []argSpec{ + {types: []jpType{jpArrayString, jpArrayNumber}}, + }, + handler: jpfSort, + }, + "sort_by": { + name: "sort_by", + arguments: []argSpec{ + {types: []jpType{jpArray}}, + {types: []jpType{jpExpref}}, + }, + handler: jpfSortBy, + hasExpRef: true, + }, + "join": { + name: "join", + arguments: []argSpec{ + {types: []jpType{jpString}}, + {types: []jpType{jpArrayString}}, + }, + handler: jpfJoin, + }, + "reverse": { + name: "reverse", + arguments: []argSpec{ + {types: []jpType{jpArray, jpString}}, + }, + handler: jpfReverse, + }, + "to_array": { + name: "to_array", + arguments: []argSpec{ + {types: []jpType{jpAny}}, + }, + handler: jpfToArray, + }, + "to_string": { + name: "to_string", + arguments: []argSpec{ + {types: []jpType{jpAny}}, + }, + handler: jpfToString, + }, + "to_number": { + name: "to_number", + arguments: []argSpec{ + {types: []jpType{jpAny}}, + }, + handler: jpfToNumber, + }, + "not_null": { + name: "not_null", + arguments: []argSpec{ + {types: []jpType{jpAny}, variadic: true}, + }, + handler: jpfNotNull, + }, + } + return caller +} + +func (e *functionEntry) resolveArgs(arguments []interface{}) ([]interface{}, error) { + if len(e.arguments) == 0 { + return arguments, nil + } + if !e.arguments[len(e.arguments)-1].variadic { + if len(e.arguments) != len(arguments) { + return nil, errors.New("incorrect number of args") + } + for i, spec := range e.arguments { + userArg := arguments[i] + err := spec.typeCheck(userArg) + if err != nil { + return nil, err + } + } + return arguments, nil + } + if len(arguments) < len(e.arguments) { + return nil, errors.New("Invalid arity.") + } + return arguments, nil +} + +func (a *argSpec) typeCheck(arg interface{}) error { + for _, t := range a.types { + switch t { + case jpNumber: + if _, ok := arg.(float64); ok { + return nil + } + case jpString: + if _, ok := arg.(string); ok { + return nil + } + case jpArray: + if isSliceType(arg) { + return nil + } + case jpObject: + if _, ok := arg.(map[string]interface{}); ok { + return nil + } + case jpArrayNumber: + if _, ok := toArrayNum(arg); ok { + return nil + } + case jpArrayString: + if _, ok := toArrayStr(arg); ok { + return nil + } + case jpAny: + return nil + case jpExpref: + if _, ok := arg.(expRef); ok { + return nil + } + } + } + return fmt.Errorf("Invalid type for: %v, expected: %#v", arg, a.types) +} + +func (f *functionCaller) CallFunction(name string, arguments []interface{}, intr *treeInterpreter) (interface{}, error) { + entry, ok := f.functionTable[name] + if !ok { + return nil, errors.New("unknown function: " + name) + } + resolvedArgs, err := entry.resolveArgs(arguments) + if err != nil { + return nil, err + } + if entry.hasExpRef { + var extra []interface{} + extra = append(extra, intr) + resolvedArgs = append(extra, resolvedArgs...) + } + return entry.handler(resolvedArgs) +} + +func jpfAbs(arguments []interface{}) (interface{}, error) { + num := arguments[0].(float64) + return math.Abs(num), nil +} + +func jpfLength(arguments []interface{}) (interface{}, error) { + arg := arguments[0] + if c, ok := arg.(string); ok { + return float64(utf8.RuneCountInString(c)), nil + } else if isSliceType(arg) { + v := reflect.ValueOf(arg) + return float64(v.Len()), nil + } else if c, ok := arg.(map[string]interface{}); ok { + return float64(len(c)), nil + } + return nil, errors.New("could not compute length()") +} + +func jpfStartsWith(arguments []interface{}) (interface{}, error) { + search := arguments[0].(string) + prefix := arguments[1].(string) + return strings.HasPrefix(search, prefix), nil +} + +func jpfAvg(arguments []interface{}) (interface{}, error) { + // We've already type checked the value so we can safely use + // type assertions. + args := arguments[0].([]interface{}) + length := float64(len(args)) + numerator := 0.0 + for _, n := range args { + numerator += n.(float64) + } + return numerator / length, nil +} +func jpfCeil(arguments []interface{}) (interface{}, error) { + val := arguments[0].(float64) + return math.Ceil(val), nil +} +func jpfContains(arguments []interface{}) (interface{}, error) { + search := arguments[0] + el := arguments[1] + if searchStr, ok := search.(string); ok { + if elStr, ok := el.(string); ok { + return strings.Index(searchStr, elStr) != -1, nil + } + return false, nil + } + // Otherwise this is a generic contains for []interface{} + general := search.([]interface{}) + for _, item := range general { + if item == el { + return true, nil + } + } + return false, nil +} +func jpfEndsWith(arguments []interface{}) (interface{}, error) { + search := arguments[0].(string) + suffix := arguments[1].(string) + return strings.HasSuffix(search, suffix), nil +} +func jpfFloor(arguments []interface{}) (interface{}, error) { + val := arguments[0].(float64) + return math.Floor(val), nil +} +func jpfMap(arguments []interface{}) (interface{}, error) { + intr := arguments[0].(*treeInterpreter) + exp := arguments[1].(expRef) + node := exp.ref + arr := arguments[2].([]interface{}) + mapped := make([]interface{}, 0, len(arr)) + for _, value := range arr { + current, err := intr.Execute(node, value) + if err != nil { + return nil, err + } + mapped = append(mapped, current) + } + return mapped, nil +} +func jpfMax(arguments []interface{}) (interface{}, error) { + if items, ok := toArrayNum(arguments[0]); ok { + if len(items) == 0 { + return nil, nil + } + if len(items) == 1 { + return items[0], nil + } + best := items[0] + for _, item := range items[1:] { + if item > best { + best = item + } + } + return best, nil + } + // Otherwise we're dealing with a max() of strings. + items, _ := toArrayStr(arguments[0]) + if len(items) == 0 { + return nil, nil + } + if len(items) == 1 { + return items[0], nil + } + best := items[0] + for _, item := range items[1:] { + if item > best { + best = item + } + } + return best, nil +} +func jpfMerge(arguments []interface{}) (interface{}, error) { + final := make(map[string]interface{}) + for _, m := range arguments { + mapped := m.(map[string]interface{}) + for key, value := range mapped { + final[key] = value + } + } + return final, nil +} +func jpfMaxBy(arguments []interface{}) (interface{}, error) { + intr := arguments[0].(*treeInterpreter) + arr := arguments[1].([]interface{}) + exp := arguments[2].(expRef) + node := exp.ref + if len(arr) == 0 { + return nil, nil + } else if len(arr) == 1 { + return arr[0], nil + } + start, err := intr.Execute(node, arr[0]) + if err != nil { + return nil, err + } + switch t := start.(type) { + case float64: + bestVal := t + bestItem := arr[0] + for _, item := range arr[1:] { + result, err := intr.Execute(node, item) + if err != nil { + return nil, err + } + current, ok := result.(float64) + if !ok { + return nil, errors.New("invalid type, must be number") + } + if current > bestVal { + bestVal = current + bestItem = item + } + } + return bestItem, nil + case string: + bestVal := t + bestItem := arr[0] + for _, item := range arr[1:] { + result, err := intr.Execute(node, item) + if err != nil { + return nil, err + } + current, ok := result.(string) + if !ok { + return nil, errors.New("invalid type, must be string") + } + if current > bestVal { + bestVal = current + bestItem = item + } + } + return bestItem, nil + default: + return nil, errors.New("invalid type, must be number of string") + } +} +func jpfSum(arguments []interface{}) (interface{}, error) { + items, _ := toArrayNum(arguments[0]) + sum := 0.0 + for _, item := range items { + sum += item + } + return sum, nil +} + +func jpfMin(arguments []interface{}) (interface{}, error) { + if items, ok := toArrayNum(arguments[0]); ok { + if len(items) == 0 { + return nil, nil + } + if len(items) == 1 { + return items[0], nil + } + best := items[0] + for _, item := range items[1:] { + if item < best { + best = item + } + } + return best, nil + } + items, _ := toArrayStr(arguments[0]) + if len(items) == 0 { + return nil, nil + } + if len(items) == 1 { + return items[0], nil + } + best := items[0] + for _, item := range items[1:] { + if item < best { + best = item + } + } + return best, nil +} + +func jpfMinBy(arguments []interface{}) (interface{}, error) { + intr := arguments[0].(*treeInterpreter) + arr := arguments[1].([]interface{}) + exp := arguments[2].(expRef) + node := exp.ref + if len(arr) == 0 { + return nil, nil + } else if len(arr) == 1 { + return arr[0], nil + } + start, err := intr.Execute(node, arr[0]) + if err != nil { + return nil, err + } + if t, ok := start.(float64); ok { + bestVal := t + bestItem := arr[0] + for _, item := range arr[1:] { + result, err := intr.Execute(node, item) + if err != nil { + return nil, err + } + current, ok := result.(float64) + if !ok { + return nil, errors.New("invalid type, must be number") + } + if current < bestVal { + bestVal = current + bestItem = item + } + } + return bestItem, nil + } else if t, ok := start.(string); ok { + bestVal := t + bestItem := arr[0] + for _, item := range arr[1:] { + result, err := intr.Execute(node, item) + if err != nil { + return nil, err + } + current, ok := result.(string) + if !ok { + return nil, errors.New("invalid type, must be string") + } + if current < bestVal { + bestVal = current + bestItem = item + } + } + return bestItem, nil + } else { + return nil, errors.New("invalid type, must be number of string") + } +} +func jpfType(arguments []interface{}) (interface{}, error) { + arg := arguments[0] + if _, ok := arg.(float64); ok { + return "number", nil + } + if _, ok := arg.(string); ok { + return "string", nil + } + if _, ok := arg.([]interface{}); ok { + return "array", nil + } + if _, ok := arg.(map[string]interface{}); ok { + return "object", nil + } + if arg == nil { + return "null", nil + } + if arg == true || arg == false { + return "boolean", nil + } + return nil, errors.New("unknown type") +} +func jpfKeys(arguments []interface{}) (interface{}, error) { + arg := arguments[0].(map[string]interface{}) + collected := make([]interface{}, 0, len(arg)) + for key := range arg { + collected = append(collected, key) + } + return collected, nil +} +func jpfValues(arguments []interface{}) (interface{}, error) { + arg := arguments[0].(map[string]interface{}) + collected := make([]interface{}, 0, len(arg)) + for _, value := range arg { + collected = append(collected, value) + } + return collected, nil +} +func jpfSort(arguments []interface{}) (interface{}, error) { + if items, ok := toArrayNum(arguments[0]); ok { + d := sort.Float64Slice(items) + sort.Stable(d) + final := make([]interface{}, len(d)) + for i, val := range d { + final[i] = val + } + return final, nil + } + // Otherwise we're dealing with sort()'ing strings. + items, _ := toArrayStr(arguments[0]) + d := sort.StringSlice(items) + sort.Stable(d) + final := make([]interface{}, len(d)) + for i, val := range d { + final[i] = val + } + return final, nil +} +func jpfSortBy(arguments []interface{}) (interface{}, error) { + intr := arguments[0].(*treeInterpreter) + arr := arguments[1].([]interface{}) + exp := arguments[2].(expRef) + node := exp.ref + if len(arr) == 0 { + return arr, nil + } else if len(arr) == 1 { + return arr, nil + } + start, err := intr.Execute(node, arr[0]) + if err != nil { + return nil, err + } + if _, ok := start.(float64); ok { + sortable := &byExprFloat{intr, node, arr, false} + sort.Stable(sortable) + if sortable.hasError { + return nil, errors.New("error in sort_by comparison") + } + return arr, nil + } else if _, ok := start.(string); ok { + sortable := &byExprString{intr, node, arr, false} + sort.Stable(sortable) + if sortable.hasError { + return nil, errors.New("error in sort_by comparison") + } + return arr, nil + } else { + return nil, errors.New("invalid type, must be number of string") + } +} +func jpfJoin(arguments []interface{}) (interface{}, error) { + sep := arguments[0].(string) + // We can't just do arguments[1].([]string), we have to + // manually convert each item to a string. + arrayStr := []string{} + for _, item := range arguments[1].([]interface{}) { + arrayStr = append(arrayStr, item.(string)) + } + return strings.Join(arrayStr, sep), nil +} +func jpfReverse(arguments []interface{}) (interface{}, error) { + if s, ok := arguments[0].(string); ok { + r := []rune(s) + for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 { + r[i], r[j] = r[j], r[i] + } + return string(r), nil + } + items := arguments[0].([]interface{}) + length := len(items) + reversed := make([]interface{}, length) + for i, item := range items { + reversed[length-(i+1)] = item + } + return reversed, nil +} +func jpfToArray(arguments []interface{}) (interface{}, error) { + if _, ok := arguments[0].([]interface{}); ok { + return arguments[0], nil + } + return arguments[:1:1], nil +} +func jpfToString(arguments []interface{}) (interface{}, error) { + if v, ok := arguments[0].(string); ok { + return v, nil + } + result, err := json.Marshal(arguments[0]) + if err != nil { + return nil, err + } + return string(result), nil +} +func jpfToNumber(arguments []interface{}) (interface{}, error) { + arg := arguments[0] + if v, ok := arg.(float64); ok { + return v, nil + } + if v, ok := arg.(string); ok { + conv, err := strconv.ParseFloat(v, 64) + if err != nil { + return nil, nil + } + return conv, nil + } + if _, ok := arg.([]interface{}); ok { + return nil, nil + } + if _, ok := arg.(map[string]interface{}); ok { + return nil, nil + } + if arg == nil { + return nil, nil + } + if arg == true || arg == false { + return nil, nil + } + return nil, errors.New("unknown type") +} +func jpfNotNull(arguments []interface{}) (interface{}, error) { + for _, arg := range arguments { + if arg != nil { + return arg, nil + } + } + return nil, nil +} diff --git a/vendor/github.com/jmespath/go-jmespath/interpreter.go b/vendor/github.com/jmespath/go-jmespath/interpreter.go new file mode 100644 index 0000000000..13c74604c2 --- /dev/null +++ b/vendor/github.com/jmespath/go-jmespath/interpreter.go @@ -0,0 +1,418 @@ +package jmespath + +import ( + "errors" + "reflect" + "unicode" + "unicode/utf8" +) + +/* This is a tree based interpreter. It walks the AST and directly + interprets the AST to search through a JSON document. +*/ + +type treeInterpreter struct { + fCall *functionCaller +} + +func newInterpreter() *treeInterpreter { + interpreter := treeInterpreter{} + interpreter.fCall = newFunctionCaller() + return &interpreter +} + +type expRef struct { + ref ASTNode +} + +// Execute takes an ASTNode and input data and interprets the AST directly. +// It will produce the result of applying the JMESPath expression associated +// with the ASTNode to the input data "value". +func (intr *treeInterpreter) Execute(node ASTNode, value interface{}) (interface{}, error) { + switch node.nodeType { + case ASTComparator: + left, err := intr.Execute(node.children[0], value) + if err != nil { + return nil, err + } + right, err := intr.Execute(node.children[1], value) + if err != nil { + return nil, err + } + switch node.value { + case tEQ: + return objsEqual(left, right), nil + case tNE: + return !objsEqual(left, right), nil + } + leftNum, ok := left.(float64) + if !ok { + return nil, nil + } + rightNum, ok := right.(float64) + if !ok { + return nil, nil + } + switch node.value { + case tGT: + return leftNum > rightNum, nil + case tGTE: + return leftNum >= rightNum, nil + case tLT: + return leftNum < rightNum, nil + case tLTE: + return leftNum <= rightNum, nil + } + case ASTExpRef: + return expRef{ref: node.children[0]}, nil + case ASTFunctionExpression: + resolvedArgs := []interface{}{} + for _, arg := range node.children { + current, err := intr.Execute(arg, value) + if err != nil { + return nil, err + } + resolvedArgs = append(resolvedArgs, current) + } + return intr.fCall.CallFunction(node.value.(string), resolvedArgs, intr) + case ASTField: + if m, ok := value.(map[string]interface{}); ok { + key := node.value.(string) + return m[key], nil + } + return intr.fieldFromStruct(node.value.(string), value) + case ASTFilterProjection: + left, err := intr.Execute(node.children[0], value) + if err != nil { + return nil, nil + } + sliceType, ok := left.([]interface{}) + if !ok { + if isSliceType(left) { + return intr.filterProjectionWithReflection(node, left) + } + return nil, nil + } + compareNode := node.children[2] + collected := []interface{}{} + for _, element := range sliceType { + result, err := intr.Execute(compareNode, element) + if err != nil { + return nil, err + } + if !isFalse(result) { + current, err := intr.Execute(node.children[1], element) + if err != nil { + return nil, err + } + if current != nil { + collected = append(collected, current) + } + } + } + return collected, nil + case ASTFlatten: + left, err := intr.Execute(node.children[0], value) + if err != nil { + return nil, nil + } + sliceType, ok := left.([]interface{}) + if !ok { + // If we can't type convert to []interface{}, there's + // a chance this could still work via reflection if we're + // dealing with user provided types. + if isSliceType(left) { + return intr.flattenWithReflection(left) + } + return nil, nil + } + flattened := []interface{}{} + for _, element := range sliceType { + if elementSlice, ok := element.([]interface{}); ok { + flattened = append(flattened, elementSlice...) + } else if isSliceType(element) { + reflectFlat := []interface{}{} + v := reflect.ValueOf(element) + for i := 0; i < v.Len(); i++ { + reflectFlat = append(reflectFlat, v.Index(i).Interface()) + } + flattened = append(flattened, reflectFlat...) + } else { + flattened = append(flattened, element) + } + } + return flattened, nil + case ASTIdentity, ASTCurrentNode: + return value, nil + case ASTIndex: + if sliceType, ok := value.([]interface{}); ok { + index := node.value.(int) + if index < 0 { + index += len(sliceType) + } + if index < len(sliceType) && index >= 0 { + return sliceType[index], nil + } + return nil, nil + } + // Otherwise try via reflection. + rv := reflect.ValueOf(value) + if rv.Kind() == reflect.Slice { + index := node.value.(int) + if index < 0 { + index += rv.Len() + } + if index < rv.Len() && index >= 0 { + v := rv.Index(index) + return v.Interface(), nil + } + } + return nil, nil + case ASTKeyValPair: + return intr.Execute(node.children[0], value) + case ASTLiteral: + return node.value, nil + case ASTMultiSelectHash: + if value == nil { + return nil, nil + } + collected := make(map[string]interface{}) + for _, child := range node.children { + current, err := intr.Execute(child, value) + if err != nil { + return nil, err + } + key := child.value.(string) + collected[key] = current + } + return collected, nil + case ASTMultiSelectList: + if value == nil { + return nil, nil + } + collected := []interface{}{} + for _, child := range node.children { + current, err := intr.Execute(child, value) + if err != nil { + return nil, err + } + collected = append(collected, current) + } + return collected, nil + case ASTOrExpression: + matched, err := intr.Execute(node.children[0], value) + if err != nil { + return nil, err + } + if isFalse(matched) { + matched, err = intr.Execute(node.children[1], value) + if err != nil { + return nil, err + } + } + return matched, nil + case ASTAndExpression: + matched, err := intr.Execute(node.children[0], value) + if err != nil { + return nil, err + } + if isFalse(matched) { + return matched, nil + } + return intr.Execute(node.children[1], value) + case ASTNotExpression: + matched, err := intr.Execute(node.children[0], value) + if err != nil { + return nil, err + } + if isFalse(matched) { + return true, nil + } + return false, nil + case ASTPipe: + result := value + var err error + for _, child := range node.children { + result, err = intr.Execute(child, result) + if err != nil { + return nil, err + } + } + return result, nil + case ASTProjection: + left, err := intr.Execute(node.children[0], value) + if err != nil { + return nil, err + } + sliceType, ok := left.([]interface{}) + if !ok { + if isSliceType(left) { + return intr.projectWithReflection(node, left) + } + return nil, nil + } + collected := []interface{}{} + var current interface{} + for _, element := range sliceType { + current, err = intr.Execute(node.children[1], element) + if err != nil { + return nil, err + } + if current != nil { + collected = append(collected, current) + } + } + return collected, nil + case ASTSubexpression, ASTIndexExpression: + left, err := intr.Execute(node.children[0], value) + if err != nil { + return nil, err + } + return intr.Execute(node.children[1], left) + case ASTSlice: + sliceType, ok := value.([]interface{}) + if !ok { + if isSliceType(value) { + return intr.sliceWithReflection(node, value) + } + return nil, nil + } + parts := node.value.([]*int) + sliceParams := make([]sliceParam, 3) + for i, part := range parts { + if part != nil { + sliceParams[i].Specified = true + sliceParams[i].N = *part + } + } + return slice(sliceType, sliceParams) + case ASTValueProjection: + left, err := intr.Execute(node.children[0], value) + if err != nil { + return nil, nil + } + mapType, ok := left.(map[string]interface{}) + if !ok { + return nil, nil + } + values := make([]interface{}, len(mapType)) + for _, value := range mapType { + values = append(values, value) + } + collected := []interface{}{} + for _, element := range values { + current, err := intr.Execute(node.children[1], element) + if err != nil { + return nil, err + } + if current != nil { + collected = append(collected, current) + } + } + return collected, nil + } + return nil, errors.New("Unknown AST node: " + node.nodeType.String()) +} + +func (intr *treeInterpreter) fieldFromStruct(key string, value interface{}) (interface{}, error) { + rv := reflect.ValueOf(value) + first, n := utf8.DecodeRuneInString(key) + fieldName := string(unicode.ToUpper(first)) + key[n:] + if rv.Kind() == reflect.Struct { + v := rv.FieldByName(fieldName) + if !v.IsValid() { + return nil, nil + } + return v.Interface(), nil + } else if rv.Kind() == reflect.Ptr { + // Handle multiple levels of indirection? + if rv.IsNil() { + return nil, nil + } + rv = rv.Elem() + v := rv.FieldByName(fieldName) + if !v.IsValid() { + return nil, nil + } + return v.Interface(), nil + } + return nil, nil +} + +func (intr *treeInterpreter) flattenWithReflection(value interface{}) (interface{}, error) { + v := reflect.ValueOf(value) + flattened := []interface{}{} + for i := 0; i < v.Len(); i++ { + element := v.Index(i).Interface() + if reflect.TypeOf(element).Kind() == reflect.Slice { + // Then insert the contents of the element + // slice into the flattened slice, + // i.e flattened = append(flattened, mySlice...) + elementV := reflect.ValueOf(element) + for j := 0; j < elementV.Len(); j++ { + flattened = append( + flattened, elementV.Index(j).Interface()) + } + } else { + flattened = append(flattened, element) + } + } + return flattened, nil +} + +func (intr *treeInterpreter) sliceWithReflection(node ASTNode, value interface{}) (interface{}, error) { + v := reflect.ValueOf(value) + parts := node.value.([]*int) + sliceParams := make([]sliceParam, 3) + for i, part := range parts { + if part != nil { + sliceParams[i].Specified = true + sliceParams[i].N = *part + } + } + final := []interface{}{} + for i := 0; i < v.Len(); i++ { + element := v.Index(i).Interface() + final = append(final, element) + } + return slice(final, sliceParams) +} + +func (intr *treeInterpreter) filterProjectionWithReflection(node ASTNode, value interface{}) (interface{}, error) { + compareNode := node.children[2] + collected := []interface{}{} + v := reflect.ValueOf(value) + for i := 0; i < v.Len(); i++ { + element := v.Index(i).Interface() + result, err := intr.Execute(compareNode, element) + if err != nil { + return nil, err + } + if !isFalse(result) { + current, err := intr.Execute(node.children[1], element) + if err != nil { + return nil, err + } + if current != nil { + collected = append(collected, current) + } + } + } + return collected, nil +} + +func (intr *treeInterpreter) projectWithReflection(node ASTNode, value interface{}) (interface{}, error) { + collected := []interface{}{} + v := reflect.ValueOf(value) + for i := 0; i < v.Len(); i++ { + element := v.Index(i).Interface() + result, err := intr.Execute(node.children[1], element) + if err != nil { + return nil, err + } + if result != nil { + collected = append(collected, result) + } + } + return collected, nil +} diff --git a/vendor/github.com/jmespath/go-jmespath/lexer.go b/vendor/github.com/jmespath/go-jmespath/lexer.go new file mode 100644 index 0000000000..817900c8f5 --- /dev/null +++ b/vendor/github.com/jmespath/go-jmespath/lexer.go @@ -0,0 +1,420 @@ +package jmespath + +import ( + "bytes" + "encoding/json" + "fmt" + "strconv" + "strings" + "unicode/utf8" +) + +type token struct { + tokenType tokType + value string + position int + length int +} + +type tokType int + +const eof = -1 + +// Lexer contains information about the expression being tokenized. +type Lexer struct { + expression string // The expression provided by the user. + currentPos int // The current position in the string. + lastWidth int // The width of the current rune. This + buf bytes.Buffer // Internal buffer used for building up values. +} + +// SyntaxError is the main error used whenever a lexing or parsing error occurs. +type SyntaxError struct { + msg string // Error message displayed to user + Expression string // Expression that generated a SyntaxError + Offset int // The location in the string where the error occurred +} + +func (e SyntaxError) Error() string { + // In the future, it would be good to underline the specific + // location where the error occurred. + return "SyntaxError: " + e.msg +} + +// HighlightLocation will show where the syntax error occurred. +// It will place a "^" character on a line below the expression +// at the point where the syntax error occurred. +func (e SyntaxError) HighlightLocation() string { + return e.Expression + "\n" + strings.Repeat(" ", e.Offset) + "^" +} + +//go:generate stringer -type=tokType +const ( + tUnknown tokType = iota + tStar + tDot + tFilter + tFlatten + tLparen + tRparen + tLbracket + tRbracket + tLbrace + tRbrace + tOr + tPipe + tNumber + tUnquotedIdentifier + tQuotedIdentifier + tComma + tColon + tLT + tLTE + tGT + tGTE + tEQ + tNE + tJSONLiteral + tStringLiteral + tCurrent + tExpref + tAnd + tNot + tEOF +) + +var basicTokens = map[rune]tokType{ + '.': tDot, + '*': tStar, + ',': tComma, + ':': tColon, + '{': tLbrace, + '}': tRbrace, + ']': tRbracket, // tLbracket not included because it could be "[]" + '(': tLparen, + ')': tRparen, + '@': tCurrent, +} + +// Bit mask for [a-zA-Z_] shifted down 64 bits to fit in a single uint64. +// When using this bitmask just be sure to shift the rune down 64 bits +// before checking against identifierStartBits. +const identifierStartBits uint64 = 576460745995190270 + +// Bit mask for [a-zA-Z0-9], 128 bits -> 2 uint64s. +var identifierTrailingBits = [2]uint64{287948901175001088, 576460745995190270} + +var whiteSpace = map[rune]bool{ + ' ': true, '\t': true, '\n': true, '\r': true, +} + +func (t token) String() string { + return fmt.Sprintf("Token{%+v, %s, %d, %d}", + t.tokenType, t.value, t.position, t.length) +} + +// NewLexer creates a new JMESPath lexer. +func NewLexer() *Lexer { + lexer := Lexer{} + return &lexer +} + +func (lexer *Lexer) next() rune { + if lexer.currentPos >= len(lexer.expression) { + lexer.lastWidth = 0 + return eof + } + r, w := utf8.DecodeRuneInString(lexer.expression[lexer.currentPos:]) + lexer.lastWidth = w + lexer.currentPos += w + return r +} + +func (lexer *Lexer) back() { + lexer.currentPos -= lexer.lastWidth +} + +func (lexer *Lexer) peek() rune { + t := lexer.next() + lexer.back() + return t +} + +// tokenize takes an expression and returns corresponding tokens. +func (lexer *Lexer) tokenize(expression string) ([]token, error) { + var tokens []token + lexer.expression = expression + lexer.currentPos = 0 + lexer.lastWidth = 0 +loop: + for { + r := lexer.next() + if identifierStartBits&(1<<(uint64(r)-64)) > 0 { + t := lexer.consumeUnquotedIdentifier() + tokens = append(tokens, t) + } else if val, ok := basicTokens[r]; ok { + // Basic single char token. + t := token{ + tokenType: val, + value: string(r), + position: lexer.currentPos - lexer.lastWidth, + length: 1, + } + tokens = append(tokens, t) + } else if r == '-' || (r >= '0' && r <= '9') { + t := lexer.consumeNumber() + tokens = append(tokens, t) + } else if r == '[' { + t := lexer.consumeLBracket() + tokens = append(tokens, t) + } else if r == '"' { + t, err := lexer.consumeQuotedIdentifier() + if err != nil { + return tokens, err + } + tokens = append(tokens, t) + } else if r == '\'' { + t, err := lexer.consumeRawStringLiteral() + if err != nil { + return tokens, err + } + tokens = append(tokens, t) + } else if r == '`' { + t, err := lexer.consumeLiteral() + if err != nil { + return tokens, err + } + tokens = append(tokens, t) + } else if r == '|' { + t := lexer.matchOrElse(r, '|', tOr, tPipe) + tokens = append(tokens, t) + } else if r == '<' { + t := lexer.matchOrElse(r, '=', tLTE, tLT) + tokens = append(tokens, t) + } else if r == '>' { + t := lexer.matchOrElse(r, '=', tGTE, tGT) + tokens = append(tokens, t) + } else if r == '!' { + t := lexer.matchOrElse(r, '=', tNE, tNot) + tokens = append(tokens, t) + } else if r == '=' { + t := lexer.matchOrElse(r, '=', tEQ, tUnknown) + tokens = append(tokens, t) + } else if r == '&' { + t := lexer.matchOrElse(r, '&', tAnd, tExpref) + tokens = append(tokens, t) + } else if r == eof { + break loop + } else if _, ok := whiteSpace[r]; ok { + // Ignore whitespace + } else { + return tokens, lexer.syntaxError(fmt.Sprintf("Unknown char: %s", strconv.QuoteRuneToASCII(r))) + } + } + tokens = append(tokens, token{tEOF, "", len(lexer.expression), 0}) + return tokens, nil +} + +// Consume characters until the ending rune "r" is reached. +// If the end of the expression is reached before seeing the +// terminating rune "r", then an error is returned. +// If no error occurs then the matching substring is returned. +// The returned string will not include the ending rune. +func (lexer *Lexer) consumeUntil(end rune) (string, error) { + start := lexer.currentPos + current := lexer.next() + for current != end && current != eof { + if current == '\\' && lexer.peek() != eof { + lexer.next() + } + current = lexer.next() + } + if lexer.lastWidth == 0 { + // Then we hit an EOF so we never reached the closing + // delimiter. + return "", SyntaxError{ + msg: "Unclosed delimiter: " + string(end), + Expression: lexer.expression, + Offset: len(lexer.expression), + } + } + return lexer.expression[start : lexer.currentPos-lexer.lastWidth], nil +} + +func (lexer *Lexer) consumeLiteral() (token, error) { + start := lexer.currentPos + value, err := lexer.consumeUntil('`') + if err != nil { + return token{}, err + } + value = strings.Replace(value, "\\`", "`", -1) + return token{ + tokenType: tJSONLiteral, + value: value, + position: start, + length: len(value), + }, nil +} + +func (lexer *Lexer) consumeRawStringLiteral() (token, error) { + start := lexer.currentPos + currentIndex := start + current := lexer.next() + for current != '\'' && lexer.peek() != eof { + if current == '\\' && lexer.peek() == '\'' { + chunk := lexer.expression[currentIndex : lexer.currentPos-1] + lexer.buf.WriteString(chunk) + lexer.buf.WriteString("'") + lexer.next() + currentIndex = lexer.currentPos + } + current = lexer.next() + } + if lexer.lastWidth == 0 { + // Then we hit an EOF so we never reached the closing + // delimiter. + return token{}, SyntaxError{ + msg: "Unclosed delimiter: '", + Expression: lexer.expression, + Offset: len(lexer.expression), + } + } + if currentIndex < lexer.currentPos { + lexer.buf.WriteString(lexer.expression[currentIndex : lexer.currentPos-1]) + } + value := lexer.buf.String() + // Reset the buffer so it can reused again. + lexer.buf.Reset() + return token{ + tokenType: tStringLiteral, + value: value, + position: start, + length: len(value), + }, nil +} + +func (lexer *Lexer) syntaxError(msg string) SyntaxError { + return SyntaxError{ + msg: msg, + Expression: lexer.expression, + Offset: lexer.currentPos - 1, + } +} + +// Checks for a two char token, otherwise matches a single character +// token. This is used whenever a two char token overlaps a single +// char token, e.g. "||" -> tPipe, "|" -> tOr. +func (lexer *Lexer) matchOrElse(first rune, second rune, matchedType tokType, singleCharType tokType) token { + start := lexer.currentPos - lexer.lastWidth + nextRune := lexer.next() + var t token + if nextRune == second { + t = token{ + tokenType: matchedType, + value: string(first) + string(second), + position: start, + length: 2, + } + } else { + lexer.back() + t = token{ + tokenType: singleCharType, + value: string(first), + position: start, + length: 1, + } + } + return t +} + +func (lexer *Lexer) consumeLBracket() token { + // There's three options here: + // 1. A filter expression "[?" + // 2. A flatten operator "[]" + // 3. A bare rbracket "[" + start := lexer.currentPos - lexer.lastWidth + nextRune := lexer.next() + var t token + if nextRune == '?' { + t = token{ + tokenType: tFilter, + value: "[?", + position: start, + length: 2, + } + } else if nextRune == ']' { + t = token{ + tokenType: tFlatten, + value: "[]", + position: start, + length: 2, + } + } else { + t = token{ + tokenType: tLbracket, + value: "[", + position: start, + length: 1, + } + lexer.back() + } + return t +} + +func (lexer *Lexer) consumeQuotedIdentifier() (token, error) { + start := lexer.currentPos + value, err := lexer.consumeUntil('"') + if err != nil { + return token{}, err + } + var decoded string + asJSON := []byte("\"" + value + "\"") + if err := json.Unmarshal([]byte(asJSON), &decoded); err != nil { + return token{}, err + } + return token{ + tokenType: tQuotedIdentifier, + value: decoded, + position: start - 1, + length: len(decoded), + }, nil +} + +func (lexer *Lexer) consumeUnquotedIdentifier() token { + // Consume runes until we reach the end of an unquoted + // identifier. + start := lexer.currentPos - lexer.lastWidth + for { + r := lexer.next() + if r < 0 || r > 128 || identifierTrailingBits[uint64(r)/64]&(1<<(uint64(r)%64)) == 0 { + lexer.back() + break + } + } + value := lexer.expression[start:lexer.currentPos] + return token{ + tokenType: tUnquotedIdentifier, + value: value, + position: start, + length: lexer.currentPos - start, + } +} + +func (lexer *Lexer) consumeNumber() token { + // Consume runes until we reach something that's not a number. + start := lexer.currentPos - lexer.lastWidth + for { + r := lexer.next() + if r < '0' || r > '9' { + lexer.back() + break + } + } + value := lexer.expression[start:lexer.currentPos] + return token{ + tokenType: tNumber, + value: value, + position: start, + length: lexer.currentPos - start, + } +} diff --git a/vendor/github.com/jmespath/go-jmespath/parser.go b/vendor/github.com/jmespath/go-jmespath/parser.go new file mode 100644 index 0000000000..1240a17552 --- /dev/null +++ b/vendor/github.com/jmespath/go-jmespath/parser.go @@ -0,0 +1,603 @@ +package jmespath + +import ( + "encoding/json" + "fmt" + "strconv" + "strings" +) + +type astNodeType int + +//go:generate stringer -type astNodeType +const ( + ASTEmpty astNodeType = iota + ASTComparator + ASTCurrentNode + ASTExpRef + ASTFunctionExpression + ASTField + ASTFilterProjection + ASTFlatten + ASTIdentity + ASTIndex + ASTIndexExpression + ASTKeyValPair + ASTLiteral + ASTMultiSelectHash + ASTMultiSelectList + ASTOrExpression + ASTAndExpression + ASTNotExpression + ASTPipe + ASTProjection + ASTSubexpression + ASTSlice + ASTValueProjection +) + +// ASTNode represents the abstract syntax tree of a JMESPath expression. +type ASTNode struct { + nodeType astNodeType + value interface{} + children []ASTNode +} + +func (node ASTNode) String() string { + return node.PrettyPrint(0) +} + +// PrettyPrint will pretty print the parsed AST. +// The AST is an implementation detail and this pretty print +// function is provided as a convenience method to help with +// debugging. You should not rely on its output as the internal +// structure of the AST may change at any time. +func (node ASTNode) PrettyPrint(indent int) string { + spaces := strings.Repeat(" ", indent) + output := fmt.Sprintf("%s%s {\n", spaces, node.nodeType) + nextIndent := indent + 2 + if node.value != nil { + if converted, ok := node.value.(fmt.Stringer); ok { + // Account for things like comparator nodes + // that are enums with a String() method. + output += fmt.Sprintf("%svalue: %s\n", strings.Repeat(" ", nextIndent), converted.String()) + } else { + output += fmt.Sprintf("%svalue: %#v\n", strings.Repeat(" ", nextIndent), node.value) + } + } + lastIndex := len(node.children) + if lastIndex > 0 { + output += fmt.Sprintf("%schildren: {\n", strings.Repeat(" ", nextIndent)) + childIndent := nextIndent + 2 + for _, elem := range node.children { + output += elem.PrettyPrint(childIndent) + } + } + output += fmt.Sprintf("%s}\n", spaces) + return output +} + +var bindingPowers = map[tokType]int{ + tEOF: 0, + tUnquotedIdentifier: 0, + tQuotedIdentifier: 0, + tRbracket: 0, + tRparen: 0, + tComma: 0, + tRbrace: 0, + tNumber: 0, + tCurrent: 0, + tExpref: 0, + tColon: 0, + tPipe: 1, + tOr: 2, + tAnd: 3, + tEQ: 5, + tLT: 5, + tLTE: 5, + tGT: 5, + tGTE: 5, + tNE: 5, + tFlatten: 9, + tStar: 20, + tFilter: 21, + tDot: 40, + tNot: 45, + tLbrace: 50, + tLbracket: 55, + tLparen: 60, +} + +// Parser holds state about the current expression being parsed. +type Parser struct { + expression string + tokens []token + index int +} + +// NewParser creates a new JMESPath parser. +func NewParser() *Parser { + p := Parser{} + return &p +} + +// Parse will compile a JMESPath expression. +func (p *Parser) Parse(expression string) (ASTNode, error) { + lexer := NewLexer() + p.expression = expression + p.index = 0 + tokens, err := lexer.tokenize(expression) + if err != nil { + return ASTNode{}, err + } + p.tokens = tokens + parsed, err := p.parseExpression(0) + if err != nil { + return ASTNode{}, err + } + if p.current() != tEOF { + return ASTNode{}, p.syntaxError(fmt.Sprintf( + "Unexpected token at the end of the expresssion: %s", p.current())) + } + return parsed, nil +} + +func (p *Parser) parseExpression(bindingPower int) (ASTNode, error) { + var err error + leftToken := p.lookaheadToken(0) + p.advance() + leftNode, err := p.nud(leftToken) + if err != nil { + return ASTNode{}, err + } + currentToken := p.current() + for bindingPower < bindingPowers[currentToken] { + p.advance() + leftNode, err = p.led(currentToken, leftNode) + if err != nil { + return ASTNode{}, err + } + currentToken = p.current() + } + return leftNode, nil +} + +func (p *Parser) parseIndexExpression() (ASTNode, error) { + if p.lookahead(0) == tColon || p.lookahead(1) == tColon { + return p.parseSliceExpression() + } + indexStr := p.lookaheadToken(0).value + parsedInt, err := strconv.Atoi(indexStr) + if err != nil { + return ASTNode{}, err + } + indexNode := ASTNode{nodeType: ASTIndex, value: parsedInt} + p.advance() + if err := p.match(tRbracket); err != nil { + return ASTNode{}, err + } + return indexNode, nil +} + +func (p *Parser) parseSliceExpression() (ASTNode, error) { + parts := []*int{nil, nil, nil} + index := 0 + current := p.current() + for current != tRbracket && index < 3 { + if current == tColon { + index++ + p.advance() + } else if current == tNumber { + parsedInt, err := strconv.Atoi(p.lookaheadToken(0).value) + if err != nil { + return ASTNode{}, err + } + parts[index] = &parsedInt + p.advance() + } else { + return ASTNode{}, p.syntaxError( + "Expected tColon or tNumber" + ", received: " + p.current().String()) + } + current = p.current() + } + if err := p.match(tRbracket); err != nil { + return ASTNode{}, err + } + return ASTNode{ + nodeType: ASTSlice, + value: parts, + }, nil +} + +func (p *Parser) match(tokenType tokType) error { + if p.current() == tokenType { + p.advance() + return nil + } + return p.syntaxError("Expected " + tokenType.String() + ", received: " + p.current().String()) +} + +func (p *Parser) led(tokenType tokType, node ASTNode) (ASTNode, error) { + switch tokenType { + case tDot: + if p.current() != tStar { + right, err := p.parseDotRHS(bindingPowers[tDot]) + return ASTNode{ + nodeType: ASTSubexpression, + children: []ASTNode{node, right}, + }, err + } + p.advance() + right, err := p.parseProjectionRHS(bindingPowers[tDot]) + return ASTNode{ + nodeType: ASTValueProjection, + children: []ASTNode{node, right}, + }, err + case tPipe: + right, err := p.parseExpression(bindingPowers[tPipe]) + return ASTNode{nodeType: ASTPipe, children: []ASTNode{node, right}}, err + case tOr: + right, err := p.parseExpression(bindingPowers[tOr]) + return ASTNode{nodeType: ASTOrExpression, children: []ASTNode{node, right}}, err + case tAnd: + right, err := p.parseExpression(bindingPowers[tAnd]) + return ASTNode{nodeType: ASTAndExpression, children: []ASTNode{node, right}}, err + case tLparen: + name := node.value + var args []ASTNode + for p.current() != tRparen { + expression, err := p.parseExpression(0) + if err != nil { + return ASTNode{}, err + } + if p.current() == tComma { + if err := p.match(tComma); err != nil { + return ASTNode{}, err + } + } + args = append(args, expression) + } + if err := p.match(tRparen); err != nil { + return ASTNode{}, err + } + return ASTNode{ + nodeType: ASTFunctionExpression, + value: name, + children: args, + }, nil + case tFilter: + return p.parseFilter(node) + case tFlatten: + left := ASTNode{nodeType: ASTFlatten, children: []ASTNode{node}} + right, err := p.parseProjectionRHS(bindingPowers[tFlatten]) + return ASTNode{ + nodeType: ASTProjection, + children: []ASTNode{left, right}, + }, err + case tEQ, tNE, tGT, tGTE, tLT, tLTE: + right, err := p.parseExpression(bindingPowers[tokenType]) + if err != nil { + return ASTNode{}, err + } + return ASTNode{ + nodeType: ASTComparator, + value: tokenType, + children: []ASTNode{node, right}, + }, nil + case tLbracket: + tokenType := p.current() + var right ASTNode + var err error + if tokenType == tNumber || tokenType == tColon { + right, err = p.parseIndexExpression() + if err != nil { + return ASTNode{}, err + } + return p.projectIfSlice(node, right) + } + // Otherwise this is a projection. + if err := p.match(tStar); err != nil { + return ASTNode{}, err + } + if err := p.match(tRbracket); err != nil { + return ASTNode{}, err + } + right, err = p.parseProjectionRHS(bindingPowers[tStar]) + if err != nil { + return ASTNode{}, err + } + return ASTNode{ + nodeType: ASTProjection, + children: []ASTNode{node, right}, + }, nil + } + return ASTNode{}, p.syntaxError("Unexpected token: " + tokenType.String()) +} + +func (p *Parser) nud(token token) (ASTNode, error) { + switch token.tokenType { + case tJSONLiteral: + var parsed interface{} + err := json.Unmarshal([]byte(token.value), &parsed) + if err != nil { + return ASTNode{}, err + } + return ASTNode{nodeType: ASTLiteral, value: parsed}, nil + case tStringLiteral: + return ASTNode{nodeType: ASTLiteral, value: token.value}, nil + case tUnquotedIdentifier: + return ASTNode{ + nodeType: ASTField, + value: token.value, + }, nil + case tQuotedIdentifier: + node := ASTNode{nodeType: ASTField, value: token.value} + if p.current() == tLparen { + return ASTNode{}, p.syntaxErrorToken("Can't have quoted identifier as function name.", token) + } + return node, nil + case tStar: + left := ASTNode{nodeType: ASTIdentity} + var right ASTNode + var err error + if p.current() == tRbracket { + right = ASTNode{nodeType: ASTIdentity} + } else { + right, err = p.parseProjectionRHS(bindingPowers[tStar]) + } + return ASTNode{nodeType: ASTValueProjection, children: []ASTNode{left, right}}, err + case tFilter: + return p.parseFilter(ASTNode{nodeType: ASTIdentity}) + case tLbrace: + return p.parseMultiSelectHash() + case tFlatten: + left := ASTNode{ + nodeType: ASTFlatten, + children: []ASTNode{{nodeType: ASTIdentity}}, + } + right, err := p.parseProjectionRHS(bindingPowers[tFlatten]) + if err != nil { + return ASTNode{}, err + } + return ASTNode{nodeType: ASTProjection, children: []ASTNode{left, right}}, nil + case tLbracket: + tokenType := p.current() + //var right ASTNode + if tokenType == tNumber || tokenType == tColon { + right, err := p.parseIndexExpression() + if err != nil { + return ASTNode{}, nil + } + return p.projectIfSlice(ASTNode{nodeType: ASTIdentity}, right) + } else if tokenType == tStar && p.lookahead(1) == tRbracket { + p.advance() + p.advance() + right, err := p.parseProjectionRHS(bindingPowers[tStar]) + if err != nil { + return ASTNode{}, err + } + return ASTNode{ + nodeType: ASTProjection, + children: []ASTNode{{nodeType: ASTIdentity}, right}, + }, nil + } else { + return p.parseMultiSelectList() + } + case tCurrent: + return ASTNode{nodeType: ASTCurrentNode}, nil + case tExpref: + expression, err := p.parseExpression(bindingPowers[tExpref]) + if err != nil { + return ASTNode{}, err + } + return ASTNode{nodeType: ASTExpRef, children: []ASTNode{expression}}, nil + case tNot: + expression, err := p.parseExpression(bindingPowers[tNot]) + if err != nil { + return ASTNode{}, err + } + return ASTNode{nodeType: ASTNotExpression, children: []ASTNode{expression}}, nil + case tLparen: + expression, err := p.parseExpression(0) + if err != nil { + return ASTNode{}, err + } + if err := p.match(tRparen); err != nil { + return ASTNode{}, err + } + return expression, nil + case tEOF: + return ASTNode{}, p.syntaxErrorToken("Incomplete expression", token) + } + + return ASTNode{}, p.syntaxErrorToken("Invalid token: "+token.tokenType.String(), token) +} + +func (p *Parser) parseMultiSelectList() (ASTNode, error) { + var expressions []ASTNode + for { + expression, err := p.parseExpression(0) + if err != nil { + return ASTNode{}, err + } + expressions = append(expressions, expression) + if p.current() == tRbracket { + break + } + err = p.match(tComma) + if err != nil { + return ASTNode{}, err + } + } + err := p.match(tRbracket) + if err != nil { + return ASTNode{}, err + } + return ASTNode{ + nodeType: ASTMultiSelectList, + children: expressions, + }, nil +} + +func (p *Parser) parseMultiSelectHash() (ASTNode, error) { + var children []ASTNode + for { + keyToken := p.lookaheadToken(0) + if err := p.match(tUnquotedIdentifier); err != nil { + if err := p.match(tQuotedIdentifier); err != nil { + return ASTNode{}, p.syntaxError("Expected tQuotedIdentifier or tUnquotedIdentifier") + } + } + keyName := keyToken.value + err := p.match(tColon) + if err != nil { + return ASTNode{}, err + } + value, err := p.parseExpression(0) + if err != nil { + return ASTNode{}, err + } + node := ASTNode{ + nodeType: ASTKeyValPair, + value: keyName, + children: []ASTNode{value}, + } + children = append(children, node) + if p.current() == tComma { + err := p.match(tComma) + if err != nil { + return ASTNode{}, nil + } + } else if p.current() == tRbrace { + err := p.match(tRbrace) + if err != nil { + return ASTNode{}, nil + } + break + } + } + return ASTNode{ + nodeType: ASTMultiSelectHash, + children: children, + }, nil +} + +func (p *Parser) projectIfSlice(left ASTNode, right ASTNode) (ASTNode, error) { + indexExpr := ASTNode{ + nodeType: ASTIndexExpression, + children: []ASTNode{left, right}, + } + if right.nodeType == ASTSlice { + right, err := p.parseProjectionRHS(bindingPowers[tStar]) + return ASTNode{ + nodeType: ASTProjection, + children: []ASTNode{indexExpr, right}, + }, err + } + return indexExpr, nil +} +func (p *Parser) parseFilter(node ASTNode) (ASTNode, error) { + var right, condition ASTNode + var err error + condition, err = p.parseExpression(0) + if err != nil { + return ASTNode{}, err + } + if err := p.match(tRbracket); err != nil { + return ASTNode{}, err + } + if p.current() == tFlatten { + right = ASTNode{nodeType: ASTIdentity} + } else { + right, err = p.parseProjectionRHS(bindingPowers[tFilter]) + if err != nil { + return ASTNode{}, err + } + } + + return ASTNode{ + nodeType: ASTFilterProjection, + children: []ASTNode{node, right, condition}, + }, nil +} + +func (p *Parser) parseDotRHS(bindingPower int) (ASTNode, error) { + lookahead := p.current() + if tokensOneOf([]tokType{tQuotedIdentifier, tUnquotedIdentifier, tStar}, lookahead) { + return p.parseExpression(bindingPower) + } else if lookahead == tLbracket { + if err := p.match(tLbracket); err != nil { + return ASTNode{}, err + } + return p.parseMultiSelectList() + } else if lookahead == tLbrace { + if err := p.match(tLbrace); err != nil { + return ASTNode{}, err + } + return p.parseMultiSelectHash() + } + return ASTNode{}, p.syntaxError("Expected identifier, lbracket, or lbrace") +} + +func (p *Parser) parseProjectionRHS(bindingPower int) (ASTNode, error) { + current := p.current() + if bindingPowers[current] < 10 { + return ASTNode{nodeType: ASTIdentity}, nil + } else if current == tLbracket { + return p.parseExpression(bindingPower) + } else if current == tFilter { + return p.parseExpression(bindingPower) + } else if current == tDot { + err := p.match(tDot) + if err != nil { + return ASTNode{}, err + } + return p.parseDotRHS(bindingPower) + } else { + return ASTNode{}, p.syntaxError("Error") + } +} + +func (p *Parser) lookahead(number int) tokType { + return p.lookaheadToken(number).tokenType +} + +func (p *Parser) current() tokType { + return p.lookahead(0) +} + +func (p *Parser) lookaheadToken(number int) token { + return p.tokens[p.index+number] +} + +func (p *Parser) advance() { + p.index++ +} + +func tokensOneOf(elements []tokType, token tokType) bool { + for _, elem := range elements { + if elem == token { + return true + } + } + return false +} + +func (p *Parser) syntaxError(msg string) SyntaxError { + return SyntaxError{ + msg: msg, + Expression: p.expression, + Offset: p.lookaheadToken(0).position, + } +} + +// Create a SyntaxError based on the provided token. +// This differs from syntaxError() which creates a SyntaxError +// based on the current lookahead token. +func (p *Parser) syntaxErrorToken(msg string, t token) SyntaxError { + return SyntaxError{ + msg: msg, + Expression: p.expression, + Offset: t.position, + } +} diff --git a/vendor/github.com/jmespath/go-jmespath/toktype_string.go b/vendor/github.com/jmespath/go-jmespath/toktype_string.go new file mode 100644 index 0000000000..dae79cbdf3 --- /dev/null +++ b/vendor/github.com/jmespath/go-jmespath/toktype_string.go @@ -0,0 +1,16 @@ +// generated by stringer -type=tokType; DO NOT EDIT + +package jmespath + +import "fmt" + +const _tokType_name = "tUnknowntStartDottFiltertFlattentLparentRparentLbrackettRbrackettLbracetRbracetOrtPipetNumbertUnquotedIdentifiertQuotedIdentifiertCommatColontLTtLTEtGTtGTEtEQtNEtJSONLiteraltStringLiteraltCurrenttExpreftAndtNottEOF" + +var _tokType_index = [...]uint8{0, 8, 13, 17, 24, 32, 39, 46, 55, 64, 71, 78, 81, 86, 93, 112, 129, 135, 141, 144, 148, 151, 155, 158, 161, 173, 187, 195, 202, 206, 210, 214} + +func (i tokType) String() string { + if i < 0 || i >= tokType(len(_tokType_index)-1) { + return fmt.Sprintf("tokType(%d)", i) + } + return _tokType_name[_tokType_index[i]:_tokType_index[i+1]] +} diff --git a/vendor/github.com/jmespath/go-jmespath/util.go b/vendor/github.com/jmespath/go-jmespath/util.go new file mode 100644 index 0000000000..ddc1b7d7d4 --- /dev/null +++ b/vendor/github.com/jmespath/go-jmespath/util.go @@ -0,0 +1,185 @@ +package jmespath + +import ( + "errors" + "reflect" +) + +// IsFalse determines if an object is false based on the JMESPath spec. +// JMESPath defines false values to be any of: +// - An empty string array, or hash. +// - The boolean value false. +// - nil +func isFalse(value interface{}) bool { + switch v := value.(type) { + case bool: + return !v + case []interface{}: + return len(v) == 0 + case map[string]interface{}: + return len(v) == 0 + case string: + return len(v) == 0 + case nil: + return true + } + // Try the reflection cases before returning false. + rv := reflect.ValueOf(value) + switch rv.Kind() { + case reflect.Struct: + // A struct type will never be false, even if + // all of its values are the zero type. + return false + case reflect.Slice, reflect.Map: + return rv.Len() == 0 + case reflect.Ptr: + if rv.IsNil() { + return true + } + // If it's a pointer type, we'll try to deref the pointer + // and evaluate the pointer value for isFalse. + element := rv.Elem() + return isFalse(element.Interface()) + } + return false +} + +// ObjsEqual is a generic object equality check. +// It will take two arbitrary objects and recursively determine +// if they are equal. +func objsEqual(left interface{}, right interface{}) bool { + return reflect.DeepEqual(left, right) +} + +// SliceParam refers to a single part of a slice. +// A slice consists of a start, a stop, and a step, similar to +// python slices. +type sliceParam struct { + N int + Specified bool +} + +// Slice supports [start:stop:step] style slicing that's supported in JMESPath. +func slice(slice []interface{}, parts []sliceParam) ([]interface{}, error) { + computed, err := computeSliceParams(len(slice), parts) + if err != nil { + return nil, err + } + start, stop, step := computed[0], computed[1], computed[2] + result := []interface{}{} + if step > 0 { + for i := start; i < stop; i += step { + result = append(result, slice[i]) + } + } else { + for i := start; i > stop; i += step { + result = append(result, slice[i]) + } + } + return result, nil +} + +func computeSliceParams(length int, parts []sliceParam) ([]int, error) { + var start, stop, step int + if !parts[2].Specified { + step = 1 + } else if parts[2].N == 0 { + return nil, errors.New("Invalid slice, step cannot be 0") + } else { + step = parts[2].N + } + var stepValueNegative bool + if step < 0 { + stepValueNegative = true + } else { + stepValueNegative = false + } + + if !parts[0].Specified { + if stepValueNegative { + start = length - 1 + } else { + start = 0 + } + } else { + start = capSlice(length, parts[0].N, step) + } + + if !parts[1].Specified { + if stepValueNegative { + stop = -1 + } else { + stop = length + } + } else { + stop = capSlice(length, parts[1].N, step) + } + return []int{start, stop, step}, nil +} + +func capSlice(length int, actual int, step int) int { + if actual < 0 { + actual += length + if actual < 0 { + if step < 0 { + actual = -1 + } else { + actual = 0 + } + } + } else if actual >= length { + if step < 0 { + actual = length - 1 + } else { + actual = length + } + } + return actual +} + +// ToArrayNum converts an empty interface type to a slice of float64. +// If any element in the array cannot be converted, then nil is returned +// along with a second value of false. +func toArrayNum(data interface{}) ([]float64, bool) { + // Is there a better way to do this with reflect? + if d, ok := data.([]interface{}); ok { + result := make([]float64, len(d)) + for i, el := range d { + item, ok := el.(float64) + if !ok { + return nil, false + } + result[i] = item + } + return result, true + } + return nil, false +} + +// ToArrayStr converts an empty interface type to a slice of strings. +// If any element in the array cannot be converted, then nil is returned +// along with a second value of false. If the input data could be entirely +// converted, then the converted data, along with a second value of true, +// will be returned. +func toArrayStr(data interface{}) ([]string, bool) { + // Is there a better way to do this with reflect? + if d, ok := data.([]interface{}); ok { + result := make([]string, len(d)) + for i, el := range d { + item, ok := el.(string) + if !ok { + return nil, false + } + result[i] = item + } + return result, true + } + return nil, false +} + +func isSliceType(v interface{}) bool { + if v == nil { + return false + } + return reflect.TypeOf(v).Kind() == reflect.Slice +} diff --git a/vendor/github.com/kballard/go-shellquote/LICENSE b/vendor/github.com/kballard/go-shellquote/LICENSE new file mode 100644 index 0000000000..a6d77312e1 --- /dev/null +++ b/vendor/github.com/kballard/go-shellquote/LICENSE @@ -0,0 +1,19 @@ +Copyright (C) 2014 Kevin Ballard + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE +OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/kballard/go-shellquote/doc.go b/vendor/github.com/kballard/go-shellquote/doc.go new file mode 100644 index 0000000000..9445fa4ad9 --- /dev/null +++ b/vendor/github.com/kballard/go-shellquote/doc.go @@ -0,0 +1,3 @@ +// Shellquote provides utilities for joining/splitting strings using sh's +// word-splitting rules. +package shellquote diff --git a/vendor/github.com/kballard/go-shellquote/quote.go b/vendor/github.com/kballard/go-shellquote/quote.go new file mode 100644 index 0000000000..f6cacee0f9 --- /dev/null +++ b/vendor/github.com/kballard/go-shellquote/quote.go @@ -0,0 +1,102 @@ +package shellquote + +import ( + "bytes" + "strings" + "unicode/utf8" +) + +// Join quotes each argument and joins them with a space. +// If passed to /bin/sh, the resulting string will be split back into the +// original arguments. +func Join(args ...string) string { + var buf bytes.Buffer + for i, arg := range args { + if i != 0 { + buf.WriteByte(' ') + } + quote(arg, &buf) + } + return buf.String() +} + +const ( + specialChars = "\\'\"`${[|&;<>()*?!" + extraSpecialChars = " \t\n" + prefixChars = "~" +) + +func quote(word string, buf *bytes.Buffer) { + // We want to try to produce a "nice" output. As such, we will + // backslash-escape most characters, but if we encounter a space, or if we + // encounter an extra-special char (which doesn't work with + // backslash-escaping) we switch over to quoting the whole word. We do this + // with a space because it's typically easier for people to read multi-word + // arguments when quoted with a space rather than with ugly backslashes + // everywhere. + origLen := buf.Len() + + if len(word) == 0 { + // oops, no content + buf.WriteString("''") + return + } + + cur, prev := word, word + atStart := true + for len(cur) > 0 { + c, l := utf8.DecodeRuneInString(cur) + cur = cur[l:] + if strings.ContainsRune(specialChars, c) || (atStart && strings.ContainsRune(prefixChars, c)) { + // copy the non-special chars up to this point + if len(cur) < len(prev) { + buf.WriteString(word[0 : len(prev)-len(cur)-l]) + } + buf.WriteByte('\\') + buf.WriteRune(c) + prev = cur + } else if strings.ContainsRune(extraSpecialChars, c) { + // start over in quote mode + buf.Truncate(origLen) + goto quote + } + atStart = false + } + if len(prev) > 0 { + buf.WriteString(prev) + } + return + +quote: + // quote mode + // Use single-quotes, but if we find a single-quote in the word, we need + // to terminate the string, emit an escaped quote, and start the string up + // again + inQuote := false + for len(word) > 0 { + i := strings.IndexRune(word, '\'') + if i == -1 { + break + } + if i > 0 { + if !inQuote { + buf.WriteByte('\'') + inQuote = true + } + buf.WriteString(word[0:i]) + word = word[i+1:] + } + if inQuote { + buf.WriteByte('\'') + inQuote = false + } + buf.WriteString("\\'") + } + if len(word) > 0 { + if !inQuote { + buf.WriteByte('\'') + } + buf.WriteString(word) + buf.WriteByte('\'') + } +} diff --git a/vendor/github.com/kballard/go-shellquote/unquote.go b/vendor/github.com/kballard/go-shellquote/unquote.go new file mode 100644 index 0000000000..ba3a0f2271 --- /dev/null +++ b/vendor/github.com/kballard/go-shellquote/unquote.go @@ -0,0 +1,144 @@ +package shellquote + +import ( + "bytes" + "errors" + "strings" + "unicode/utf8" +) + +var ( + UnterminatedSingleQuoteError = errors.New("Unterminated single-quoted string") + UnterminatedDoubleQuoteError = errors.New("Unterminated double-quoted string") + UnterminatedEscapeError = errors.New("Unterminated backslash-escape") +) + +var ( + splitChars = " \n\t" + singleChar = '\'' + doubleChar = '"' + escapeChar = '\\' + doubleEscapeChars = "$`\"\n\\" +) + +// Split splits a string according to /bin/sh's word-splitting rules. It +// supports backslash-escapes, single-quotes, and double-quotes. Notably it does +// not support the $'' style of quoting. It also doesn't attempt to perform any +// other sort of expansion, including brace expansion, shell expansion, or +// pathname expansion. +// +// If the given input has an unterminated quoted string or ends in a +// backslash-escape, one of UnterminatedSingleQuoteError, +// UnterminatedDoubleQuoteError, or UnterminatedEscapeError is returned. +func Split(input string) (words []string, err error) { + var buf bytes.Buffer + words = make([]string, 0) + + for len(input) > 0 { + // skip any splitChars at the start + c, l := utf8.DecodeRuneInString(input) + if strings.ContainsRune(splitChars, c) { + input = input[l:] + continue + } + + var word string + word, input, err = splitWord(input, &buf) + if err != nil { + return + } + words = append(words, word) + } + return +} + +func splitWord(input string, buf *bytes.Buffer) (word string, remainder string, err error) { + buf.Reset() + +raw: + { + cur := input + for len(cur) > 0 { + c, l := utf8.DecodeRuneInString(cur) + cur = cur[l:] + if c == singleChar { + buf.WriteString(input[0 : len(input)-len(cur)-l]) + input = cur + goto single + } else if c == doubleChar { + buf.WriteString(input[0 : len(input)-len(cur)-l]) + input = cur + goto double + } else if c == escapeChar { + buf.WriteString(input[0 : len(input)-len(cur)-l]) + input = cur + goto escape + } else if strings.ContainsRune(splitChars, c) { + buf.WriteString(input[0 : len(input)-len(cur)-l]) + return buf.String(), cur, nil + } + } + if len(input) > 0 { + buf.WriteString(input) + input = "" + } + goto done + } + +escape: + { + if len(input) == 0 { + return "", "", UnterminatedEscapeError + } + c, l := utf8.DecodeRuneInString(input) + if c == '\n' { + // a backslash-escaped newline is elided from the output entirely + } else { + buf.WriteString(input[:l]) + } + input = input[l:] + } + goto raw + +single: + { + i := strings.IndexRune(input, singleChar) + if i == -1 { + return "", "", UnterminatedSingleQuoteError + } + buf.WriteString(input[0:i]) + input = input[i+1:] + goto raw + } + +double: + { + cur := input + for len(cur) > 0 { + c, l := utf8.DecodeRuneInString(cur) + cur = cur[l:] + if c == doubleChar { + buf.WriteString(input[0 : len(input)-len(cur)-l]) + input = cur + goto raw + } else if c == escapeChar { + // bash only supports certain escapes in double-quoted strings + c2, l2 := utf8.DecodeRuneInString(cur) + cur = cur[l2:] + if strings.ContainsRune(doubleEscapeChars, c2) { + buf.WriteString(input[0 : len(input)-len(cur)-l-l2]) + if c2 == '\n' { + // newline is special, skip the backslash entirely + } else { + buf.WriteRune(c2) + } + input = cur + } + } + } + return "", "", UnterminatedDoubleQuoteError + } + +done: + return buf.String(), input, nil +} diff --git a/vendor/github.com/klauspost/compress/LICENSE b/vendor/github.com/klauspost/compress/LICENSE new file mode 100644 index 0000000000..7448756763 --- /dev/null +++ b/vendor/github.com/klauspost/compress/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2012 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. diff --git a/vendor/github.com/klauspost/compress/flate/copy.go b/vendor/github.com/klauspost/compress/flate/copy.go new file mode 100644 index 0000000000..a3200a8f49 --- /dev/null +++ b/vendor/github.com/klauspost/compress/flate/copy.go @@ -0,0 +1,32 @@ +// 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. + +package flate + +// forwardCopy is like the built-in copy function except that it always goes +// forward from the start, even if the dst and src overlap. +// It is equivalent to: +// for i := 0; i < n; i++ { +// mem[dst+i] = mem[src+i] +// } +func forwardCopy(mem []byte, dst, src, n int) { + if dst <= src { + copy(mem[dst:dst+n], mem[src:src+n]) + return + } + for { + if dst >= src+n { + copy(mem[dst:dst+n], mem[src:src+n]) + return + } + // There is some forward overlap. The destination + // will be filled with a repeated pattern of mem[src:src+k]. + // We copy one instance of the pattern here, then repeat. + // Each time around this loop k will double. + k := dst - src + copy(mem[dst:dst+k], mem[src:src+k]) + n -= k + dst += k + } +} diff --git a/vendor/github.com/klauspost/compress/flate/crc32_amd64.go b/vendor/github.com/klauspost/compress/flate/crc32_amd64.go new file mode 100644 index 0000000000..45d52f629c --- /dev/null +++ b/vendor/github.com/klauspost/compress/flate/crc32_amd64.go @@ -0,0 +1,39 @@ +//+build !noasm +//+build !appengine + +// Copyright 2015, Klaus Post, see LICENSE for details. + +package flate + +import ( + "github.com/klauspost/cpuid" +) + +// crc32sse returns a hash for the first 4 bytes of the slice +// len(a) must be >= 4. +//go:noescape +func crc32sse(a []byte) hash + +// crc32sseAll calculates hashes for each 4-byte set in a. +// dst must be east len(a) - 4 in size. +// The size is not checked by the assembly. +//go:noescape +func crc32sseAll(a []byte, dst []hash) + +// matchLenSSE4 returns the number of matching bytes in a and b +// up to length 'max'. Both slices must be at least 'max' +// bytes in size. +// It uses the PCMPESTRI SSE 4.2 instruction. +//go:noescape +func matchLenSSE4(a, b []byte, max int) int + +// histogram accumulates a histogram of b in h. +// h must be at least 256 entries in length, +// and must be cleared before calling this function. +//go:noescape +func histogram(b []byte, h []int32) + +// Detect SSE 4.2 feature. +func init() { + useSSE42 = cpuid.CPU.SSE42() +} diff --git a/vendor/github.com/klauspost/compress/flate/crc32_amd64.s b/vendor/github.com/klauspost/compress/flate/crc32_amd64.s new file mode 100644 index 0000000000..0212360d66 --- /dev/null +++ b/vendor/github.com/klauspost/compress/flate/crc32_amd64.s @@ -0,0 +1,218 @@ +//+build !noasm !appengine + +// Copyright 2015, Klaus Post, see LICENSE for details. + +// func crc32sse(a []byte) hash +TEXT ·crc32sse(SB), 7, $0 + MOVQ a+0(FP), R10 + XORQ BX, BX + + // CRC32 dword (R10), EBX + BYTE $0xF2; BYTE $0x41; BYTE $0x0f + BYTE $0x38; BYTE $0xf1; BYTE $0x1a + + MOVL BX, ret+24(FP) + RET + +// func crc32sseAll(a []byte, dst []hash) +TEXT ·crc32sseAll(SB), 7, $0 + MOVQ a+0(FP), R8 // R8: src + MOVQ a_len+8(FP), R10 // input length + MOVQ dst+24(FP), R9 // R9: dst + SUBQ $4, R10 + JS end + JZ one_crc + MOVQ R10, R13 + SHRQ $2, R10 // len/4 + ANDQ $3, R13 // len&3 + XORQ BX, BX + ADDQ $1, R13 + TESTQ R10, R10 + JZ rem_loop + +crc_loop: + MOVQ (R8), R11 + XORQ BX, BX + XORQ DX, DX + XORQ DI, DI + MOVQ R11, R12 + SHRQ $8, R11 + MOVQ R12, AX + MOVQ R11, CX + SHRQ $16, R12 + SHRQ $16, R11 + MOVQ R12, SI + + // CRC32 EAX, EBX + BYTE $0xF2; BYTE $0x0f + BYTE $0x38; BYTE $0xf1; BYTE $0xd8 + + // CRC32 ECX, EDX + BYTE $0xF2; BYTE $0x0f + BYTE $0x38; BYTE $0xf1; BYTE $0xd1 + + // CRC32 ESI, EDI + BYTE $0xF2; BYTE $0x0f + BYTE $0x38; BYTE $0xf1; BYTE $0xfe + MOVL BX, (R9) + MOVL DX, 4(R9) + MOVL DI, 8(R9) + + XORQ BX, BX + MOVL R11, AX + + // CRC32 EAX, EBX + BYTE $0xF2; BYTE $0x0f + BYTE $0x38; BYTE $0xf1; BYTE $0xd8 + MOVL BX, 12(R9) + + ADDQ $16, R9 + ADDQ $4, R8 + XORQ BX, BX + SUBQ $1, R10 + JNZ crc_loop + +rem_loop: + MOVL (R8), AX + + // CRC32 EAX, EBX + BYTE $0xF2; BYTE $0x0f + BYTE $0x38; BYTE $0xf1; BYTE $0xd8 + + MOVL BX, (R9) + ADDQ $4, R9 + ADDQ $1, R8 + XORQ BX, BX + SUBQ $1, R13 + JNZ rem_loop + +end: + RET + +one_crc: + MOVQ $1, R13 + XORQ BX, BX + JMP rem_loop + +// func matchLenSSE4(a, b []byte, max int) int +TEXT ·matchLenSSE4(SB), 7, $0 + MOVQ a+0(FP), SI // RSI: &a + MOVQ b+24(FP), DI // RDI: &b + MOVQ max+48(FP), R10 // R10: max + XORQ R11, R11 // R11: match length + MOVQ R10, R12 // R12: Remainder + SHRQ $4, R10 // max / 16 + MOVQ $16, AX // Set length for PCMPESTRI + MOVQ $16, DX // Set length for PCMPESTRI + ANDQ $15, R12 // max & 15 + TESTQ R10, R10 + JZ matchlen_verysmall + +loopback_matchlen: + MOVOU (SI), X0 // a[x] + MOVOU (DI), X1 // b[x] + + // PCMPESTRI $0x18, X1, X0 + // 0x18 = _SIDD_UBYTE_OPS (0x0) | _SIDD_CMP_EQUAL_EACH (0x8) | _SIDD_NEGATIVE_POLARITY (0x10) + BYTE $0x66; BYTE $0x0f; BYTE $0x3a + BYTE $0x61; BYTE $0xc1; BYTE $0x18 + + JC match_ended + + ADDQ $16, SI + ADDQ $16, DI + ADDQ $16, R11 + + SUBQ $1, R10 + JNZ loopback_matchlen + + // Check the remainder using REP CMPSB +matchlen_verysmall: + TESTQ R12, R12 + JZ done_matchlen + MOVQ R12, CX + ADDQ R12, R11 + + // Compare CX bytes at [SI] [DI] + // Subtract one from CX for every match. + // Terminates when CX is zero (checked pre-compare) + CLD + REP; CMPSB + + // Check if last was a match. + JZ done_matchlen + + // Subtract remanding bytes. + SUBQ CX, R11 + SUBQ $1, R11 + MOVQ R11, ret+56(FP) + RET + +match_ended: + ADDQ CX, R11 + +done_matchlen: + MOVQ R11, ret+56(FP) + RET + +// func histogram(b []byte, h []int32) +TEXT ·histogram(SB), 7, $0 + MOVQ b+0(FP), SI // SI: &b + MOVQ b_len+8(FP), R9 // R9: len(b) + MOVQ h+24(FP), DI // DI: Histogram + MOVQ R9, R8 + SHRQ $3, R8 + JZ hist1 + XORQ R11, R11 + +loop_hist8: + MOVQ (SI), R10 + + MOVB R10, R11 + INCL (DI)(R11*4) + SHRQ $8, R10 + + MOVB R10, R11 + INCL (DI)(R11*4) + SHRQ $8, R10 + + MOVB R10, R11 + INCL (DI)(R11*4) + SHRQ $8, R10 + + MOVB R10, R11 + INCL (DI)(R11*4) + SHRQ $8, R10 + + MOVB R10, R11 + INCL (DI)(R11*4) + SHRQ $8, R10 + + MOVB R10, R11 + INCL (DI)(R11*4) + SHRQ $8, R10 + + MOVB R10, R11 + INCL (DI)(R11*4) + SHRQ $8, R10 + + INCL (DI)(R10*4) + + ADDQ $8, SI + DECQ R8 + JNZ loop_hist8 + +hist1: + ANDQ $7, R9 + JZ end_hist + XORQ R10, R10 + +loop_hist1: + MOVB (SI), R10 + INCL (DI)(R10*4) + INCQ SI + DECQ R9 + JNZ loop_hist1 + +end_hist: + RET diff --git a/vendor/github.com/klauspost/compress/flate/crc32_noasm.go b/vendor/github.com/klauspost/compress/flate/crc32_noasm.go new file mode 100644 index 0000000000..1c6d23eed6 --- /dev/null +++ b/vendor/github.com/klauspost/compress/flate/crc32_noasm.go @@ -0,0 +1,34 @@ +//+build !amd64 noasm appengine + +// Copyright 2015, Klaus Post, see LICENSE for details. + +package flate + +func init() { + useSSE42 = false +} + +// crc32sse should never be called. +func crc32sse(a []byte) hash { + panic("no assembler") +} + +// crc32sseAll should never be called. +func crc32sseAll(a []byte, dst []hash) { + panic("no assembler") +} + +// matchLenSSE4 should never be called. +func matchLenSSE4(a, b []byte, max int) int { + panic("no assembler") + return 0 +} + +// histogram accumulates a histogram of b in h. +// h must be at least 256 entries in length, +// and must be cleared before calling this function. +func histogram(b []byte, h []int32) { + for _, t := range b { + h[t]++ + } +} diff --git a/vendor/github.com/klauspost/compress/flate/deflate.go b/vendor/github.com/klauspost/compress/flate/deflate.go new file mode 100644 index 0000000000..b1efa677a5 --- /dev/null +++ b/vendor/github.com/klauspost/compress/flate/deflate.go @@ -0,0 +1,1358 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Copyright (c) 2015 Klaus Post +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package flate + +import ( + "fmt" + "io" + "math" +) + +const ( + NoCompression = 0 + BestSpeed = 1 + BestCompression = 9 + DefaultCompression = -1 + ConstantCompression = -2 // Does only Huffman encoding + logWindowSize = 15 + windowSize = 1 << logWindowSize + windowMask = windowSize - 1 + logMaxOffsetSize = 15 // Standard DEFLATE + minMatchLength = 4 // The smallest match that the compressor looks for + maxMatchLength = 258 // The longest match for the compressor + minOffsetSize = 1 // The shortest offset that makes any sense + + // The maximum number of tokens we put into a single flat block, just too + // stop things from getting too large. + maxFlateBlockTokens = 1 << 14 + maxStoreBlockSize = 65535 + hashBits = 17 // After 17 performance degrades + hashSize = 1 << hashBits + hashMask = (1 << hashBits) - 1 + hashShift = (hashBits + minMatchLength - 1) / minMatchLength + maxHashOffset = 1 << 24 + + skipNever = math.MaxInt32 +) + +var useSSE42 bool + +type compressionLevel struct { + good, lazy, nice, chain, fastSkipHashing, level int +} + +// Compression levels have been rebalanced from zlib deflate defaults +// to give a bigger spread in speed and compression. +// See https://blog.klauspost.com/rebalancing-deflate-compression-levels/ +var levels = []compressionLevel{ + {}, // 0 + // Level 1+2 uses snappy algorithm - values not used + {0, 0, 0, 0, 0, 1}, + {0, 0, 0, 0, 0, 2}, + // For levels 3-6 we don't bother trying with lazy matches. + // Lazy matching is at least 30% slower, with 1.5% increase. + {4, 0, 8, 4, 4, 3}, + {4, 0, 12, 6, 5, 4}, + {6, 0, 24, 16, 6, 5}, + {8, 0, 32, 32, 7, 6}, + // Levels 7-9 use increasingly more lazy matching + // and increasingly stringent conditions for "good enough". + {4, 8, 16, 16, skipNever, 7}, + {6, 16, 32, 64, skipNever, 8}, + {32, 258, 258, 4096, skipNever, 9}, +} + +type hashid uint32 + +type compressor struct { + compressionLevel + + w *huffmanBitWriter + bulkHasher func([]byte, []hash) + + // compression algorithm + fill func(*compressor, []byte) int // copy data to window + step func(*compressor) // process window + sync bool // requesting flush + + // Input hash chains + // hashHead[hashValue] contains the largest inputIndex with the specified hash value + // If hashHead[hashValue] is within the current window, then + // hashPrev[hashHead[hashValue] & windowMask] contains the previous index + // with the same hash value. + chainHead int + hashHead []hashid + hashPrev []hashid + hashOffset int + + // input window: unprocessed data is window[index:windowEnd] + index int + window []byte + windowEnd int + blockStart int // window index where current tokens start + byteAvailable bool // if true, still need to process window[index-1]. + + // queued output tokens + tokens tokens + + // deflate state + length int + offset int + hash hash + maxInsertIndex int + err error + ii uint16 // position of last match, intended to overflow to reset. + + snap snappyEnc + hashMatch [maxMatchLength + minMatchLength]hash +} + +type hash int32 + +func (d *compressor) fillDeflate(b []byte) int { + if d.index >= 2*windowSize-(minMatchLength+maxMatchLength) { + // shift the window by windowSize + copy(d.window, d.window[windowSize:2*windowSize]) + d.index -= windowSize + d.windowEnd -= windowSize + if d.blockStart >= windowSize { + d.blockStart -= windowSize + } else { + d.blockStart = math.MaxInt32 + } + d.hashOffset += windowSize + if d.hashOffset > maxHashOffset { + delta := d.hashOffset - 1 + d.hashOffset -= delta + d.chainHead -= delta + for i, v := range d.hashPrev { + if int(v) > delta { + d.hashPrev[i] = hashid(int(v) - delta) + } else { + d.hashPrev[i] = 0 + } + } + for i, v := range d.hashHead { + if int(v) > delta { + d.hashHead[i] = hashid(int(v) - delta) + } else { + d.hashHead[i] = 0 + } + } + } + } + n := copy(d.window[d.windowEnd:], b) + d.windowEnd += n + return n +} + +func (d *compressor) writeBlock(tok tokens, index int, eof bool) error { + if index > 0 || eof { + var window []byte + if d.blockStart <= index { + window = d.window[d.blockStart:index] + } + d.blockStart = index + d.w.writeBlock(tok, eof, window) + return d.w.err + } + return nil +} + +// writeBlockSkip writes the current block and uses the number of tokens +// to determine if the block should be stored on no matches, or +// only huffman encoded. +func (d *compressor) writeBlockSkip(tok tokens, index int, eof bool) error { + if index > 0 || eof { + if d.blockStart <= index { + window := d.window[d.blockStart:index] + if tok.n == len(window) && !eof { + d.writeStoredBlock(window) + // If we removed less than 10 literals, huffman compress the block. + } else if tok.n > len(window)-10 { + d.w.writeBlockHuff(eof, window) + } else { + // Write a dynamic huffman block. + d.w.writeBlockDynamic(tok, eof, window) + } + } else { + d.w.writeBlock(tok, eof, nil) + } + d.blockStart = index + return d.w.err + } + return nil +} + +// fillWindow will fill the current window with the supplied +// dictionary and calculate all hashes. +// This is much faster than doing a full encode. +// Should only be used after a start/reset. +func (d *compressor) fillWindow(b []byte) { + // Do not fill window if we are in store-only mode, + // use constant or Snappy compression. + switch d.compressionLevel.level { + case 0, 1, 2: + return + } + // If we are given too much, cut it. + if len(b) > windowSize { + b = b[len(b)-windowSize:] + } + // Add all to window. + n := copy(d.window[d.windowEnd:], b) + + // Calculate 256 hashes at the time (more L1 cache hits) + loops := (n + 256 - minMatchLength) / 256 + for j := 0; j < loops; j++ { + startindex := j * 256 + end := startindex + 256 + minMatchLength - 1 + if end > n { + end = n + } + tocheck := d.window[startindex:end] + dstSize := len(tocheck) - minMatchLength + 1 + + if dstSize <= 0 { + continue + } + + dst := d.hashMatch[:dstSize] + d.bulkHasher(tocheck, dst) + var newH hash + for i, val := range dst { + di := i + startindex + newH = val & hashMask + // Get previous value with the same hash. + // Our chain should point to the previous value. + d.hashPrev[di&windowMask] = d.hashHead[newH] + // Set the head of the hash chain to us. + d.hashHead[newH] = hashid(di + d.hashOffset) + } + d.hash = newH + } + // Update window information. + d.windowEnd += n + d.index = n +} + +// Try to find a match starting at index whose length is greater than prevSize. +// We only look at chainCount possibilities before giving up. +// pos = d.index, prevHead = d.chainHead-d.hashOffset, prevLength=minMatchLength-1, lookahead +func (d *compressor) findMatch(pos int, prevHead int, prevLength int, lookahead int) (length, offset int, ok bool) { + minMatchLook := maxMatchLength + if lookahead < minMatchLook { + minMatchLook = lookahead + } + + win := d.window[0 : pos+minMatchLook] + + // We quit when we get a match that's at least nice long + nice := len(win) - pos + if d.nice < nice { + nice = d.nice + } + + // If we've got a match that's good enough, only look in 1/4 the chain. + tries := d.chain + length = prevLength + if length >= d.good { + tries >>= 2 + } + + wEnd := win[pos+length] + wPos := win[pos:] + minIndex := pos - windowSize + + for i := prevHead; tries > 0; tries-- { + if wEnd == win[i+length] { + n := matchLen(win[i:], wPos, minMatchLook) + + if n > length && (n > minMatchLength || pos-i <= 4096) { + length = n + offset = pos - i + ok = true + if n >= nice { + // The match is good enough that we don't try to find a better one. + break + } + wEnd = win[pos+n] + } + } + if i == minIndex { + // hashPrev[i & windowMask] has already been overwritten, so stop now. + break + } + i = int(d.hashPrev[i&windowMask]) - d.hashOffset + if i < minIndex || i < 0 { + break + } + } + return +} + +// Try to find a match starting at index whose length is greater than prevSize. +// We only look at chainCount possibilities before giving up. +// pos = d.index, prevHead = d.chainHead-d.hashOffset, prevLength=minMatchLength-1, lookahead +func (d *compressor) findMatchSSE(pos int, prevHead int, prevLength int, lookahead int) (length, offset int, ok bool) { + minMatchLook := maxMatchLength + if lookahead < minMatchLook { + minMatchLook = lookahead + } + + win := d.window[0 : pos+minMatchLook] + + // We quit when we get a match that's at least nice long + nice := len(win) - pos + if d.nice < nice { + nice = d.nice + } + + // If we've got a match that's good enough, only look in 1/4 the chain. + tries := d.chain + length = prevLength + if length >= d.good { + tries >>= 2 + } + + wEnd := win[pos+length] + wPos := win[pos:] + minIndex := pos - windowSize + + for i := prevHead; tries > 0; tries-- { + if wEnd == win[i+length] { + n := matchLenSSE4(win[i:], wPos, minMatchLook) + + if n > length && (n > minMatchLength || pos-i <= 4096) { + length = n + offset = pos - i + ok = true + if n >= nice { + // The match is good enough that we don't try to find a better one. + break + } + wEnd = win[pos+n] + } + } + if i == minIndex { + // hashPrev[i & windowMask] has already been overwritten, so stop now. + break + } + i = int(d.hashPrev[i&windowMask]) - d.hashOffset + if i < minIndex || i < 0 { + break + } + } + return +} + +func (d *compressor) writeStoredBlock(buf []byte) error { + if d.w.writeStoredHeader(len(buf), false); d.w.err != nil { + return d.w.err + } + d.w.writeBytes(buf) + return d.w.err +} + +// oldHash is the hash function used when no native crc32 calculation +// or similar is present. +func oldHash(b []byte) hash { + return hash(b[0])<<(hashShift*3) + hash(b[1])<<(hashShift*2) + hash(b[2])< d.windowEnd { + panic("index > windowEnd") + } + lookahead := d.windowEnd - d.index + if lookahead < minMatchLength+maxMatchLength { + if !d.sync { + return + } + if sanity && d.index > d.windowEnd { + panic("index > windowEnd") + } + if lookahead == 0 { + if d.tokens.n > 0 { + if d.err = d.writeBlockSkip(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + return + } + } + if d.index < d.maxInsertIndex { + // Update the hash + d.hash = oldHash(d.window[d.index:d.index+minMatchLength]) & hashMask + ch := d.hashHead[d.hash] + d.chainHead = int(ch) + d.hashPrev[d.index&windowMask] = ch + d.hashHead[d.hash] = hashid(d.index + d.hashOffset) + } + d.length = minMatchLength - 1 + d.offset = 0 + minIndex := d.index - windowSize + if minIndex < 0 { + minIndex = 0 + } + + if d.chainHead-d.hashOffset >= minIndex && lookahead > minMatchLength-1 { + if newLength, newOffset, ok := d.findMatch(d.index, d.chainHead-d.hashOffset, minMatchLength-1, lookahead); ok { + d.length = newLength + d.offset = newOffset + } + } + if d.length >= minMatchLength { + d.ii = 0 + // There was a match at the previous step, and the current match is + // not better. Output the previous match. + // "d.length-3" should NOT be "d.length-minMatchLength", since the format always assume 3 + d.tokens.tokens[d.tokens.n] = matchToken(uint32(d.length-3), uint32(d.offset-minOffsetSize)) + d.tokens.n++ + // Insert in the hash table all strings up to the end of the match. + // index and index-1 are already inserted. If there is not enough + // lookahead, the last two strings are not inserted into the hash + // table. + if d.length <= d.fastSkipHashing { + var newIndex int + newIndex = d.index + d.length + // Calculate missing hashes + end := newIndex + if end > d.maxInsertIndex { + end = d.maxInsertIndex + } + end += minMatchLength - 1 + startindex := d.index + 1 + if startindex > d.maxInsertIndex { + startindex = d.maxInsertIndex + } + tocheck := d.window[startindex:end] + dstSize := len(tocheck) - minMatchLength + 1 + if dstSize > 0 { + dst := d.hashMatch[:dstSize] + oldBulkHash(tocheck, dst) + var newH hash + for i, val := range dst { + di := i + startindex + newH = val & hashMask + // Get previous value with the same hash. + // Our chain should point to the previous value. + d.hashPrev[di&windowMask] = d.hashHead[newH] + // Set the head of the hash chain to us. + d.hashHead[newH] = hashid(di + d.hashOffset) + } + d.hash = newH + } + d.index = newIndex + } else { + // For matches this long, we don't bother inserting each individual + // item into the table. + d.index += d.length + if d.index < d.maxInsertIndex { + d.hash = oldHash(d.window[d.index:d.index+minMatchLength]) & hashMask + } + } + if d.tokens.n == maxFlateBlockTokens { + // The block includes the current character + if d.err = d.writeBlockSkip(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + } else { + d.ii++ + end := d.index + int(d.ii>>uint(d.fastSkipHashing)) + 1 + if end > d.windowEnd { + end = d.windowEnd + } + for i := d.index; i < end; i++ { + d.tokens.tokens[d.tokens.n] = literalToken(uint32(d.window[i])) + d.tokens.n++ + if d.tokens.n == maxFlateBlockTokens { + if d.err = d.writeBlockSkip(d.tokens, i+1, false); d.err != nil { + return + } + d.tokens.n = 0 + } + } + d.index = end + } + } +} + +// deflateLazy is the same as deflate, but with d.fastSkipHashing == skipNever, +// meaning it always has lazy matching on. +func (d *compressor) deflateLazy() { + // Sanity enables additional runtime tests. + // It's intended to be used during development + // to supplement the currently ad-hoc unit tests. + const sanity = false + + if d.windowEnd-d.index < minMatchLength+maxMatchLength && !d.sync { + return + } + + d.maxInsertIndex = d.windowEnd - (minMatchLength - 1) + if d.index < d.maxInsertIndex { + d.hash = oldHash(d.window[d.index:d.index+minMatchLength]) & hashMask + } + + for { + if sanity && d.index > d.windowEnd { + panic("index > windowEnd") + } + lookahead := d.windowEnd - d.index + if lookahead < minMatchLength+maxMatchLength { + if !d.sync { + return + } + if sanity && d.index > d.windowEnd { + panic("index > windowEnd") + } + if lookahead == 0 { + // Flush current output block if any. + if d.byteAvailable { + // There is still one pending token that needs to be flushed + d.tokens.tokens[d.tokens.n] = literalToken(uint32(d.window[d.index-1])) + d.tokens.n++ + d.byteAvailable = false + } + if d.tokens.n > 0 { + if d.err = d.writeBlock(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + return + } + } + if d.index < d.maxInsertIndex { + // Update the hash + d.hash = oldHash(d.window[d.index:d.index+minMatchLength]) & hashMask + ch := d.hashHead[d.hash] + d.chainHead = int(ch) + d.hashPrev[d.index&windowMask] = ch + d.hashHead[d.hash] = hashid(d.index + d.hashOffset) + } + prevLength := d.length + prevOffset := d.offset + d.length = minMatchLength - 1 + d.offset = 0 + minIndex := d.index - windowSize + if minIndex < 0 { + minIndex = 0 + } + + if d.chainHead-d.hashOffset >= minIndex && lookahead > prevLength && prevLength < d.lazy { + if newLength, newOffset, ok := d.findMatch(d.index, d.chainHead-d.hashOffset, minMatchLength-1, lookahead); ok { + d.length = newLength + d.offset = newOffset + } + } + if prevLength >= minMatchLength && d.length <= prevLength { + // There was a match at the previous step, and the current match is + // not better. Output the previous match. + d.tokens.tokens[d.tokens.n] = matchToken(uint32(prevLength-3), uint32(prevOffset-minOffsetSize)) + d.tokens.n++ + + // Insert in the hash table all strings up to the end of the match. + // index and index-1 are already inserted. If there is not enough + // lookahead, the last two strings are not inserted into the hash + // table. + var newIndex int + newIndex = d.index + prevLength - 1 + // Calculate missing hashes + end := newIndex + if end > d.maxInsertIndex { + end = d.maxInsertIndex + } + end += minMatchLength - 1 + startindex := d.index + 1 + if startindex > d.maxInsertIndex { + startindex = d.maxInsertIndex + } + tocheck := d.window[startindex:end] + dstSize := len(tocheck) - minMatchLength + 1 + if dstSize > 0 { + dst := d.hashMatch[:dstSize] + oldBulkHash(tocheck, dst) + var newH hash + for i, val := range dst { + di := i + startindex + newH = val & hashMask + // Get previous value with the same hash. + // Our chain should point to the previous value. + d.hashPrev[di&windowMask] = d.hashHead[newH] + // Set the head of the hash chain to us. + d.hashHead[newH] = hashid(di + d.hashOffset) + } + d.hash = newH + } + + d.index = newIndex + d.byteAvailable = false + d.length = minMatchLength - 1 + if d.tokens.n == maxFlateBlockTokens { + // The block includes the current character + if d.err = d.writeBlock(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + } else { + // Reset, if we got a match this run. + if d.length >= minMatchLength { + d.ii = 0 + } + // We have a byte waiting. Emit it. + if d.byteAvailable { + d.ii++ + d.tokens.tokens[d.tokens.n] = literalToken(uint32(d.window[d.index-1])) + d.tokens.n++ + if d.tokens.n == maxFlateBlockTokens { + if d.err = d.writeBlock(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + d.index++ + + // If we have a long run of no matches, skip additional bytes + // Resets when d.ii overflows after 64KB. + if d.ii > 31 { + n := int(d.ii >> 6) + for j := 0; j < n; j++ { + if d.index >= d.windowEnd-1 { + break + } + + d.tokens.tokens[d.tokens.n] = literalToken(uint32(d.window[d.index-1])) + d.tokens.n++ + if d.tokens.n == maxFlateBlockTokens { + if d.err = d.writeBlock(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + d.index++ + } + // Flush last byte + d.tokens.tokens[d.tokens.n] = literalToken(uint32(d.window[d.index-1])) + d.tokens.n++ + d.byteAvailable = false + // d.length = minMatchLength - 1 // not needed, since d.ii is reset above, so it should never be > minMatchLength + if d.tokens.n == maxFlateBlockTokens { + if d.err = d.writeBlock(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + } + } else { + d.index++ + d.byteAvailable = true + } + } + } +} + +// Assumes that d.fastSkipHashing != skipNever, +// otherwise use deflateLazySSE +func (d *compressor) deflateSSE() { + + // Sanity enables additional runtime tests. + // It's intended to be used during development + // to supplement the currently ad-hoc unit tests. + const sanity = false + + if d.windowEnd-d.index < minMatchLength+maxMatchLength && !d.sync { + return + } + + d.maxInsertIndex = d.windowEnd - (minMatchLength - 1) + if d.index < d.maxInsertIndex { + d.hash = oldHash(d.window[d.index:d.index+minMatchLength]) & hashMask + } + + for { + if sanity && d.index > d.windowEnd { + panic("index > windowEnd") + } + lookahead := d.windowEnd - d.index + if lookahead < minMatchLength+maxMatchLength { + if !d.sync { + return + } + if sanity && d.index > d.windowEnd { + panic("index > windowEnd") + } + if lookahead == 0 { + if d.tokens.n > 0 { + if d.err = d.writeBlockSkip(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + return + } + } + if d.index < d.maxInsertIndex { + // Update the hash + d.hash = crc32sse(d.window[d.index:d.index+minMatchLength]) & hashMask + ch := d.hashHead[d.hash] + d.chainHead = int(ch) + d.hashPrev[d.index&windowMask] = ch + d.hashHead[d.hash] = hashid(d.index + d.hashOffset) + } + d.length = minMatchLength - 1 + d.offset = 0 + minIndex := d.index - windowSize + if minIndex < 0 { + minIndex = 0 + } + + if d.chainHead-d.hashOffset >= minIndex && lookahead > minMatchLength-1 { + if newLength, newOffset, ok := d.findMatchSSE(d.index, d.chainHead-d.hashOffset, minMatchLength-1, lookahead); ok { + d.length = newLength + d.offset = newOffset + } + } + if d.length >= minMatchLength { + d.ii = 0 + // There was a match at the previous step, and the current match is + // not better. Output the previous match. + // "d.length-3" should NOT be "d.length-minMatchLength", since the format always assume 3 + d.tokens.tokens[d.tokens.n] = matchToken(uint32(d.length-3), uint32(d.offset-minOffsetSize)) + d.tokens.n++ + // Insert in the hash table all strings up to the end of the match. + // index and index-1 are already inserted. If there is not enough + // lookahead, the last two strings are not inserted into the hash + // table. + if d.length <= d.fastSkipHashing { + var newIndex int + newIndex = d.index + d.length + // Calculate missing hashes + end := newIndex + if end > d.maxInsertIndex { + end = d.maxInsertIndex + } + end += minMatchLength - 1 + startindex := d.index + 1 + if startindex > d.maxInsertIndex { + startindex = d.maxInsertIndex + } + tocheck := d.window[startindex:end] + dstSize := len(tocheck) - minMatchLength + 1 + if dstSize > 0 { + dst := d.hashMatch[:dstSize] + + crc32sseAll(tocheck, dst) + var newH hash + for i, val := range dst { + di := i + startindex + newH = val & hashMask + // Get previous value with the same hash. + // Our chain should point to the previous value. + d.hashPrev[di&windowMask] = d.hashHead[newH] + // Set the head of the hash chain to us. + d.hashHead[newH] = hashid(di + d.hashOffset) + } + d.hash = newH + } + d.index = newIndex + } else { + // For matches this long, we don't bother inserting each individual + // item into the table. + d.index += d.length + if d.index < d.maxInsertIndex { + d.hash = crc32sse(d.window[d.index:d.index+minMatchLength]) & hashMask + } + } + if d.tokens.n == maxFlateBlockTokens { + // The block includes the current character + if d.err = d.writeBlockSkip(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + } else { + d.ii++ + end := d.index + int(d.ii>>uint(d.fastSkipHashing)) + 1 + if end > d.windowEnd { + end = d.windowEnd + } + for i := d.index; i < end; i++ { + d.tokens.tokens[d.tokens.n] = literalToken(uint32(d.window[i])) + d.tokens.n++ + if d.tokens.n == maxFlateBlockTokens { + if d.err = d.writeBlockSkip(d.tokens, i+1, false); d.err != nil { + return + } + d.tokens.n = 0 + } + } + d.index = end + } + } +} + +// deflateLazy is the same as deflate, but with d.fastSkipHashing == skipNever, +// meaning it always has lazy matching on. +func (d *compressor) deflateLazySSE() { + // Sanity enables additional runtime tests. + // It's intended to be used during development + // to supplement the currently ad-hoc unit tests. + const sanity = false + + if d.windowEnd-d.index < minMatchLength+maxMatchLength && !d.sync { + return + } + + d.maxInsertIndex = d.windowEnd - (minMatchLength - 1) + if d.index < d.maxInsertIndex { + d.hash = crc32sse(d.window[d.index:d.index+minMatchLength]) & hashMask + } + + for { + if sanity && d.index > d.windowEnd { + panic("index > windowEnd") + } + lookahead := d.windowEnd - d.index + if lookahead < minMatchLength+maxMatchLength { + if !d.sync { + return + } + if sanity && d.index > d.windowEnd { + panic("index > windowEnd") + } + if lookahead == 0 { + // Flush current output block if any. + if d.byteAvailable { + // There is still one pending token that needs to be flushed + d.tokens.tokens[d.tokens.n] = literalToken(uint32(d.window[d.index-1])) + d.tokens.n++ + d.byteAvailable = false + } + if d.tokens.n > 0 { + if d.err = d.writeBlock(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + return + } + } + if d.index < d.maxInsertIndex { + // Update the hash + d.hash = crc32sse(d.window[d.index:d.index+minMatchLength]) & hashMask + ch := d.hashHead[d.hash] + d.chainHead = int(ch) + d.hashPrev[d.index&windowMask] = ch + d.hashHead[d.hash] = hashid(d.index + d.hashOffset) + } + prevLength := d.length + prevOffset := d.offset + d.length = minMatchLength - 1 + d.offset = 0 + minIndex := d.index - windowSize + if minIndex < 0 { + minIndex = 0 + } + + if d.chainHead-d.hashOffset >= minIndex && lookahead > prevLength && prevLength < d.lazy { + if newLength, newOffset, ok := d.findMatchSSE(d.index, d.chainHead-d.hashOffset, minMatchLength-1, lookahead); ok { + d.length = newLength + d.offset = newOffset + } + } + if prevLength >= minMatchLength && d.length <= prevLength { + // There was a match at the previous step, and the current match is + // not better. Output the previous match. + d.tokens.tokens[d.tokens.n] = matchToken(uint32(prevLength-3), uint32(prevOffset-minOffsetSize)) + d.tokens.n++ + + // Insert in the hash table all strings up to the end of the match. + // index and index-1 are already inserted. If there is not enough + // lookahead, the last two strings are not inserted into the hash + // table. + var newIndex int + newIndex = d.index + prevLength - 1 + // Calculate missing hashes + end := newIndex + if end > d.maxInsertIndex { + end = d.maxInsertIndex + } + end += minMatchLength - 1 + startindex := d.index + 1 + if startindex > d.maxInsertIndex { + startindex = d.maxInsertIndex + } + tocheck := d.window[startindex:end] + dstSize := len(tocheck) - minMatchLength + 1 + if dstSize > 0 { + dst := d.hashMatch[:dstSize] + crc32sseAll(tocheck, dst) + var newH hash + for i, val := range dst { + di := i + startindex + newH = val & hashMask + // Get previous value with the same hash. + // Our chain should point to the previous value. + d.hashPrev[di&windowMask] = d.hashHead[newH] + // Set the head of the hash chain to us. + d.hashHead[newH] = hashid(di + d.hashOffset) + } + d.hash = newH + } + + d.index = newIndex + d.byteAvailable = false + d.length = minMatchLength - 1 + if d.tokens.n == maxFlateBlockTokens { + // The block includes the current character + if d.err = d.writeBlock(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + } else { + // Reset, if we got a match this run. + if d.length >= minMatchLength { + d.ii = 0 + } + // We have a byte waiting. Emit it. + if d.byteAvailable { + d.ii++ + d.tokens.tokens[d.tokens.n] = literalToken(uint32(d.window[d.index-1])) + d.tokens.n++ + if d.tokens.n == maxFlateBlockTokens { + if d.err = d.writeBlock(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + d.index++ + + // If we have a long run of no matches, skip additional bytes + // Resets when d.ii overflows after 64KB. + if d.ii > 31 { + n := int(d.ii >> 6) + for j := 0; j < n; j++ { + if d.index >= d.windowEnd-1 { + break + } + + d.tokens.tokens[d.tokens.n] = literalToken(uint32(d.window[d.index-1])) + d.tokens.n++ + if d.tokens.n == maxFlateBlockTokens { + if d.err = d.writeBlock(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + d.index++ + } + // Flush last byte + d.tokens.tokens[d.tokens.n] = literalToken(uint32(d.window[d.index-1])) + d.tokens.n++ + d.byteAvailable = false + // d.length = minMatchLength - 1 // not needed, since d.ii is reset above, so it should never be > minMatchLength + if d.tokens.n == maxFlateBlockTokens { + if d.err = d.writeBlock(d.tokens, d.index, false); d.err != nil { + return + } + d.tokens.n = 0 + } + } + } else { + d.index++ + d.byteAvailable = true + } + } + } +} + +func (d *compressor) fillStore(b []byte) int { + n := copy(d.window[d.windowEnd:], b) + d.windowEnd += n + return n +} + +func (d *compressor) store() { + if d.windowEnd > 0 { + d.err = d.writeStoredBlock(d.window[:d.windowEnd]) + } + d.windowEnd = 0 +} + +// fillHuff will fill the buffer with data for huffman-only compression. +// The number of bytes copied is returned. +func (d *compressor) fillHuff(b []byte) int { + n := copy(d.window[d.windowEnd:], b) + d.windowEnd += n + return n +} + +// storeHuff will compress and store the currently added data, +// if enough has been accumulated or we at the end of the stream. +// Any error that occurred will be in d.err +func (d *compressor) storeHuff() { + // We only compress if we have maxStoreBlockSize or we are at end-of-stream + if d.windowEnd < maxStoreBlockSize && !d.sync { + return + } + if d.windowEnd == 0 { + return + } + d.w.writeBlockHuff(false, d.window[:d.windowEnd]) + d.err = d.w.err + d.windowEnd = 0 +} + +// storeHuff will compress and store the currently added data, +// if enough has been accumulated or we at the end of the stream. +// Any error that occurred will be in d.err +func (d *compressor) storeSnappy() { + // We only compress if we have maxStoreBlockSize. + if d.windowEnd < maxStoreBlockSize { + if !d.sync { + return + } + // Handle extremely small sizes. + if d.windowEnd < 128 { + if d.windowEnd == 0 { + return + } + if d.windowEnd <= 32 { + d.err = d.writeStoredBlock(d.window[:d.windowEnd]) + d.tokens.n = 0 + d.windowEnd = 0 + } else { + d.w.writeBlockHuff(false, d.window[:d.windowEnd]) + d.err = d.w.err + } + d.tokens.n = 0 + d.windowEnd = 0 + return + } + } + + d.snap.Encode(&d.tokens, d.window[:d.windowEnd]) + // If we made zero matches, store the block as is. + if d.tokens.n == d.windowEnd { + d.err = d.writeStoredBlock(d.window[:d.windowEnd]) + // If we removed less than 1/16th, huffman compress the block. + } else if d.tokens.n > d.windowEnd-(d.windowEnd>>4) { + d.w.writeBlockHuff(false, d.window[:d.windowEnd]) + d.err = d.w.err + } else { + d.w.writeBlockDynamic(d.tokens, false, d.window[:d.windowEnd]) + d.err = d.w.err + } + d.tokens.n = 0 + d.windowEnd = 0 +} + +// write will add input byte to the stream. +// Unless an error occurs all bytes will be consumed. +func (d *compressor) write(b []byte) (n int, err error) { + if d.err != nil { + return 0, d.err + } + n = len(b) + for len(b) > 0 { + d.step(d) + b = b[d.fill(d, b):] + if d.err != nil { + return 0, d.err + } + } + return n, d.err +} + +func (d *compressor) syncFlush() error { + d.sync = true + if d.err != nil { + return d.err + } + d.step(d) + if d.err == nil { + d.w.writeStoredHeader(0, false) + d.w.flush() + d.err = d.w.err + } + d.sync = false + return d.err +} + +func (d *compressor) init(w io.Writer, level int) (err error) { + d.w = newHuffmanBitWriter(w) + + switch { + case level == NoCompression: + d.window = make([]byte, maxStoreBlockSize) + d.fill = (*compressor).fillStore + d.step = (*compressor).store + case level == ConstantCompression: + d.window = make([]byte, maxStoreBlockSize) + d.fill = (*compressor).fillHuff + d.step = (*compressor).storeHuff + case level >= 1 && level <= 3: + d.snap = newSnappy(level) + d.window = make([]byte, maxStoreBlockSize) + d.fill = (*compressor).fillHuff + d.step = (*compressor).storeSnappy + d.tokens.tokens = make([]token, maxStoreBlockSize+1) + case level == DefaultCompression: + level = 5 + fallthrough + case 4 <= level && level <= 9: + d.compressionLevel = levels[level] + d.initDeflate() + d.fill = (*compressor).fillDeflate + if d.fastSkipHashing == skipNever { + if useSSE42 { + d.step = (*compressor).deflateLazySSE + } else { + d.step = (*compressor).deflateLazy + } + } else { + if useSSE42 { + d.step = (*compressor).deflateSSE + } else { + d.step = (*compressor).deflate + + } + } + default: + return fmt.Errorf("flate: invalid compression level %d: want value in range [-2, 9]", level) + } + return nil +} + +// Used for zeroing the hash slice +var hzeroes [256]hashid + +// reset the state of the compressor. +func (d *compressor) reset(w io.Writer) { + d.w.reset(w) + d.sync = false + d.err = nil + // We only need to reset a few things for Snappy. + if d.snap != nil { + d.snap.Reset() + d.windowEnd = 0 + d.tokens.n = 0 + return + } + switch d.compressionLevel.chain { + case 0: + // level was NoCompression or ConstantCompresssion. + d.windowEnd = 0 + default: + d.chainHead = -1 + for s := d.hashHead; len(s) > 0; { + n := copy(s, hzeroes[:]) + s = s[n:] + } + for s := d.hashPrev; len(s) > 0; s = s[len(hzeroes):] { + copy(s, hzeroes[:]) + } + d.hashOffset = 1 + + d.index, d.windowEnd = 0, 0 + d.blockStart, d.byteAvailable = 0, false + + d.tokens.n = 0 + d.length = minMatchLength - 1 + d.offset = 0 + d.hash = 0 + d.ii = 0 + d.maxInsertIndex = 0 + } +} + +func (d *compressor) close() error { + if d.err != nil { + return d.err + } + d.sync = true + d.step(d) + if d.err != nil { + return d.err + } + if d.w.writeStoredHeader(0, true); d.w.err != nil { + return d.w.err + } + d.w.flush() + return d.w.err +} + +// NewWriter returns a new Writer compressing data at the given level. +// Following zlib, levels range from 1 (BestSpeed) to 9 (BestCompression); +// higher levels typically run slower but compress more. +// Level 0 (NoCompression) does not attempt any compression; it only adds the +// necessary DEFLATE framing. +// Level -1 (DefaultCompression) uses the default compression level. +// Level -2 (ConstantCompression) will use Huffman compression only, giving +// a very fast compression for all types of input, but sacrificing considerable +// compression efficiency. +// +// If level is in the range [-2, 9] then the error returned will be nil. +// Otherwise the error returned will be non-nil. +func NewWriter(w io.Writer, level int) (*Writer, error) { + var dw Writer + if err := dw.d.init(w, level); err != nil { + return nil, err + } + return &dw, nil +} + +// NewWriterDict is like NewWriter but initializes the new +// Writer with a preset dictionary. The returned Writer behaves +// as if the dictionary had been written to it without producing +// any compressed output. The compressed data written to w +// can only be decompressed by a Reader initialized with the +// same dictionary. +func NewWriterDict(w io.Writer, level int, dict []byte) (*Writer, error) { + dw := &dictWriter{w} + zw, err := NewWriter(dw, level) + if err != nil { + return nil, err + } + zw.d.fillWindow(dict) + zw.dict = append(zw.dict, dict...) // duplicate dictionary for Reset method. + return zw, err +} + +type dictWriter struct { + w io.Writer +} + +func (w *dictWriter) Write(b []byte) (n int, err error) { + return w.w.Write(b) +} + +// A Writer takes data written to it and writes the compressed +// form of that data to an underlying writer (see NewWriter). +type Writer struct { + d compressor + dict []byte +} + +// Write writes data to w, which will eventually write the +// compressed form of data to its underlying writer. +func (w *Writer) Write(data []byte) (n int, err error) { + return w.d.write(data) +} + +// Flush flushes any pending compressed data to the underlying writer. +// It is useful mainly in compressed network protocols, to ensure that +// a remote reader has enough data to reconstruct a packet. +// Flush does not return until the data has been written. +// If the underlying writer returns an error, Flush returns that error. +// +// In the terminology of the zlib library, Flush is equivalent to Z_SYNC_FLUSH. +func (w *Writer) Flush() error { + // For more about flushing: + // http://www.bolet.org/~pornin/deflate-flush.html + return w.d.syncFlush() +} + +// Close flushes and closes the writer. +func (w *Writer) Close() error { + return w.d.close() +} + +// Reset discards the writer's state and makes it equivalent to +// the result of NewWriter or NewWriterDict called with dst +// and w's level and dictionary. +func (w *Writer) Reset(dst io.Writer) { + if dw, ok := w.d.w.w.(*dictWriter); ok { + // w was created with NewWriterDict + dw.w = dst + w.d.reset(dw) + w.d.fillWindow(w.dict) + } else { + // w was created with NewWriter + w.d.reset(dst) + } +} + +// ResetDict discards the writer's state and makes it equivalent to +// the result of NewWriter or NewWriterDict called with dst +// and w's level, but sets a specific dictionary. +func (w *Writer) ResetDict(dst io.Writer, dict []byte) { + w.dict = dict + w.d.reset(dst) + w.d.fillWindow(w.dict) +} diff --git a/vendor/github.com/klauspost/compress/flate/fixedhuff.go b/vendor/github.com/klauspost/compress/flate/fixedhuff.go new file mode 100644 index 0000000000..7df8b9a293 --- /dev/null +++ b/vendor/github.com/klauspost/compress/flate/fixedhuff.go @@ -0,0 +1,78 @@ +// 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. + +package flate + +// autogenerated by go run gen.go -output fixedhuff.go, DO NOT EDIT + +var fixedHuffmanDecoder = huffmanDecoder{ + 7, + [huffmanNumChunks]uint32{ + 0x1007, 0x0508, 0x0108, 0x1188, 0x1107, 0x0708, 0x0308, 0x0c09, + 0x1087, 0x0608, 0x0208, 0x0a09, 0x0008, 0x0808, 0x0408, 0x0e09, + 0x1047, 0x0588, 0x0188, 0x0909, 0x1147, 0x0788, 0x0388, 0x0d09, + 0x10c7, 0x0688, 0x0288, 0x0b09, 0x0088, 0x0888, 0x0488, 0x0f09, + 0x1027, 0x0548, 0x0148, 0x11c8, 0x1127, 0x0748, 0x0348, 0x0c89, + 0x10a7, 0x0648, 0x0248, 0x0a89, 0x0048, 0x0848, 0x0448, 0x0e89, + 0x1067, 0x05c8, 0x01c8, 0x0989, 0x1167, 0x07c8, 0x03c8, 0x0d89, + 0x10e7, 0x06c8, 0x02c8, 0x0b89, 0x00c8, 0x08c8, 0x04c8, 0x0f89, + 0x1017, 0x0528, 0x0128, 0x11a8, 0x1117, 0x0728, 0x0328, 0x0c49, + 0x1097, 0x0628, 0x0228, 0x0a49, 0x0028, 0x0828, 0x0428, 0x0e49, + 0x1057, 0x05a8, 0x01a8, 0x0949, 0x1157, 0x07a8, 0x03a8, 0x0d49, + 0x10d7, 0x06a8, 0x02a8, 0x0b49, 0x00a8, 0x08a8, 0x04a8, 0x0f49, + 0x1037, 0x0568, 0x0168, 0x11e8, 0x1137, 0x0768, 0x0368, 0x0cc9, + 0x10b7, 0x0668, 0x0268, 0x0ac9, 0x0068, 0x0868, 0x0468, 0x0ec9, + 0x1077, 0x05e8, 0x01e8, 0x09c9, 0x1177, 0x07e8, 0x03e8, 0x0dc9, + 0x10f7, 0x06e8, 0x02e8, 0x0bc9, 0x00e8, 0x08e8, 0x04e8, 0x0fc9, + 0x1007, 0x0518, 0x0118, 0x1198, 0x1107, 0x0718, 0x0318, 0x0c29, + 0x1087, 0x0618, 0x0218, 0x0a29, 0x0018, 0x0818, 0x0418, 0x0e29, + 0x1047, 0x0598, 0x0198, 0x0929, 0x1147, 0x0798, 0x0398, 0x0d29, + 0x10c7, 0x0698, 0x0298, 0x0b29, 0x0098, 0x0898, 0x0498, 0x0f29, + 0x1027, 0x0558, 0x0158, 0x11d8, 0x1127, 0x0758, 0x0358, 0x0ca9, + 0x10a7, 0x0658, 0x0258, 0x0aa9, 0x0058, 0x0858, 0x0458, 0x0ea9, + 0x1067, 0x05d8, 0x01d8, 0x09a9, 0x1167, 0x07d8, 0x03d8, 0x0da9, + 0x10e7, 0x06d8, 0x02d8, 0x0ba9, 0x00d8, 0x08d8, 0x04d8, 0x0fa9, + 0x1017, 0x0538, 0x0138, 0x11b8, 0x1117, 0x0738, 0x0338, 0x0c69, + 0x1097, 0x0638, 0x0238, 0x0a69, 0x0038, 0x0838, 0x0438, 0x0e69, + 0x1057, 0x05b8, 0x01b8, 0x0969, 0x1157, 0x07b8, 0x03b8, 0x0d69, + 0x10d7, 0x06b8, 0x02b8, 0x0b69, 0x00b8, 0x08b8, 0x04b8, 0x0f69, + 0x1037, 0x0578, 0x0178, 0x11f8, 0x1137, 0x0778, 0x0378, 0x0ce9, + 0x10b7, 0x0678, 0x0278, 0x0ae9, 0x0078, 0x0878, 0x0478, 0x0ee9, + 0x1077, 0x05f8, 0x01f8, 0x09e9, 0x1177, 0x07f8, 0x03f8, 0x0de9, + 0x10f7, 0x06f8, 0x02f8, 0x0be9, 0x00f8, 0x08f8, 0x04f8, 0x0fe9, + 0x1007, 0x0508, 0x0108, 0x1188, 0x1107, 0x0708, 0x0308, 0x0c19, + 0x1087, 0x0608, 0x0208, 0x0a19, 0x0008, 0x0808, 0x0408, 0x0e19, + 0x1047, 0x0588, 0x0188, 0x0919, 0x1147, 0x0788, 0x0388, 0x0d19, + 0x10c7, 0x0688, 0x0288, 0x0b19, 0x0088, 0x0888, 0x0488, 0x0f19, + 0x1027, 0x0548, 0x0148, 0x11c8, 0x1127, 0x0748, 0x0348, 0x0c99, + 0x10a7, 0x0648, 0x0248, 0x0a99, 0x0048, 0x0848, 0x0448, 0x0e99, + 0x1067, 0x05c8, 0x01c8, 0x0999, 0x1167, 0x07c8, 0x03c8, 0x0d99, + 0x10e7, 0x06c8, 0x02c8, 0x0b99, 0x00c8, 0x08c8, 0x04c8, 0x0f99, + 0x1017, 0x0528, 0x0128, 0x11a8, 0x1117, 0x0728, 0x0328, 0x0c59, + 0x1097, 0x0628, 0x0228, 0x0a59, 0x0028, 0x0828, 0x0428, 0x0e59, + 0x1057, 0x05a8, 0x01a8, 0x0959, 0x1157, 0x07a8, 0x03a8, 0x0d59, + 0x10d7, 0x06a8, 0x02a8, 0x0b59, 0x00a8, 0x08a8, 0x04a8, 0x0f59, + 0x1037, 0x0568, 0x0168, 0x11e8, 0x1137, 0x0768, 0x0368, 0x0cd9, + 0x10b7, 0x0668, 0x0268, 0x0ad9, 0x0068, 0x0868, 0x0468, 0x0ed9, + 0x1077, 0x05e8, 0x01e8, 0x09d9, 0x1177, 0x07e8, 0x03e8, 0x0dd9, + 0x10f7, 0x06e8, 0x02e8, 0x0bd9, 0x00e8, 0x08e8, 0x04e8, 0x0fd9, + 0x1007, 0x0518, 0x0118, 0x1198, 0x1107, 0x0718, 0x0318, 0x0c39, + 0x1087, 0x0618, 0x0218, 0x0a39, 0x0018, 0x0818, 0x0418, 0x0e39, + 0x1047, 0x0598, 0x0198, 0x0939, 0x1147, 0x0798, 0x0398, 0x0d39, + 0x10c7, 0x0698, 0x0298, 0x0b39, 0x0098, 0x0898, 0x0498, 0x0f39, + 0x1027, 0x0558, 0x0158, 0x11d8, 0x1127, 0x0758, 0x0358, 0x0cb9, + 0x10a7, 0x0658, 0x0258, 0x0ab9, 0x0058, 0x0858, 0x0458, 0x0eb9, + 0x1067, 0x05d8, 0x01d8, 0x09b9, 0x1167, 0x07d8, 0x03d8, 0x0db9, + 0x10e7, 0x06d8, 0x02d8, 0x0bb9, 0x00d8, 0x08d8, 0x04d8, 0x0fb9, + 0x1017, 0x0538, 0x0138, 0x11b8, 0x1117, 0x0738, 0x0338, 0x0c79, + 0x1097, 0x0638, 0x0238, 0x0a79, 0x0038, 0x0838, 0x0438, 0x0e79, + 0x1057, 0x05b8, 0x01b8, 0x0979, 0x1157, 0x07b8, 0x03b8, 0x0d79, + 0x10d7, 0x06b8, 0x02b8, 0x0b79, 0x00b8, 0x08b8, 0x04b8, 0x0f79, + 0x1037, 0x0578, 0x0178, 0x11f8, 0x1137, 0x0778, 0x0378, 0x0cf9, + 0x10b7, 0x0678, 0x0278, 0x0af9, 0x0078, 0x0878, 0x0478, 0x0ef9, + 0x1077, 0x05f8, 0x01f8, 0x09f9, 0x1177, 0x07f8, 0x03f8, 0x0df9, + 0x10f7, 0x06f8, 0x02f8, 0x0bf9, 0x00f8, 0x08f8, 0x04f8, 0x0ff9, + }, + nil, 0, +} diff --git a/vendor/github.com/klauspost/compress/flate/gen.go b/vendor/github.com/klauspost/compress/flate/gen.go new file mode 100644 index 0000000000..154c89a488 --- /dev/null +++ b/vendor/github.com/klauspost/compress/flate/gen.go @@ -0,0 +1,265 @@ +// 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 ignore + +// This program generates fixedhuff.go +// Invoke as +// +// go run gen.go -output fixedhuff.go + +package main + +import ( + "bytes" + "flag" + "fmt" + "go/format" + "io/ioutil" + "log" +) + +var filename = flag.String("output", "fixedhuff.go", "output file name") + +const maxCodeLen = 16 + +// Note: the definition of the huffmanDecoder struct is copied from +// inflate.go, as it is private to the implementation. + +// chunk & 15 is number of bits +// chunk >> 4 is value, including table link + +const ( + huffmanChunkBits = 9 + huffmanNumChunks = 1 << huffmanChunkBits + huffmanCountMask = 15 + huffmanValueShift = 4 +) + +type huffmanDecoder struct { + min int // the minimum code length + chunks [huffmanNumChunks]uint32 // chunks as described above + links [][]uint32 // overflow links + linkMask uint32 // mask the width of the link table +} + +// Initialize Huffman decoding tables from array of code lengths. +// Following this function, h is guaranteed to be initialized into a complete +// tree (i.e., neither over-subscribed nor under-subscribed). The exception is a +// degenerate case where the tree has only a single symbol with length 1. Empty +// trees are permitted. +func (h *huffmanDecoder) init(bits []int) bool { + // Sanity enables additional runtime tests during Huffman + // table construction. It's intended to be used during + // development to supplement the currently ad-hoc unit tests. + const sanity = false + + if h.min != 0 { + *h = huffmanDecoder{} + } + + // Count number of codes of each length, + // compute min and max length. + var count [maxCodeLen]int + var min, max int + for _, n := range bits { + if n == 0 { + continue + } + if min == 0 || n < min { + min = n + } + if n > max { + max = n + } + count[n]++ + } + + // Empty tree. The decompressor.huffSym function will fail later if the tree + // is used. Technically, an empty tree is only valid for the HDIST tree and + // not the HCLEN and HLIT tree. However, a stream with an empty HCLEN tree + // is guaranteed to fail since it will attempt to use the tree to decode the + // codes for the HLIT and HDIST trees. Similarly, an empty HLIT tree is + // guaranteed to fail later since the compressed data section must be + // composed of at least one symbol (the end-of-block marker). + if max == 0 { + return true + } + + code := 0 + var nextcode [maxCodeLen]int + for i := min; i <= max; i++ { + code <<= 1 + nextcode[i] = code + code += count[i] + } + + // Check that the coding is complete (i.e., that we've + // assigned all 2-to-the-max possible bit sequences). + // Exception: To be compatible with zlib, we also need to + // accept degenerate single-code codings. See also + // TestDegenerateHuffmanCoding. + if code != 1< huffmanChunkBits { + numLinks := 1 << (uint(max) - huffmanChunkBits) + h.linkMask = uint32(numLinks - 1) + + // create link tables + link := nextcode[huffmanChunkBits+1] >> 1 + h.links = make([][]uint32, huffmanNumChunks-link) + for j := uint(link); j < huffmanNumChunks; j++ { + reverse := int(reverseByte[j>>8]) | int(reverseByte[j&0xff])<<8 + reverse >>= uint(16 - huffmanChunkBits) + off := j - uint(link) + if sanity && h.chunks[reverse] != 0 { + panic("impossible: overwriting existing chunk") + } + h.chunks[reverse] = uint32(off<>8]) | int(reverseByte[code&0xff])<<8 + reverse >>= uint(16 - n) + if n <= huffmanChunkBits { + for off := reverse; off < len(h.chunks); off += 1 << uint(n) { + // We should never need to overwrite + // an existing chunk. Also, 0 is + // never a valid chunk, because the + // lower 4 "count" bits should be + // between 1 and 15. + if sanity && h.chunks[off] != 0 { + panic("impossible: overwriting existing chunk") + } + h.chunks[off] = chunk + } + } else { + j := reverse & (huffmanNumChunks - 1) + if sanity && h.chunks[j]&huffmanCountMask != huffmanChunkBits+1 { + // Longer codes should have been + // associated with a link table above. + panic("impossible: not an indirect chunk") + } + value := h.chunks[j] >> huffmanValueShift + linktab := h.links[value] + reverse >>= huffmanChunkBits + for off := reverse; off < len(linktab); off += 1 << uint(n-huffmanChunkBits) { + if sanity && linktab[off] != 0 { + panic("impossible: overwriting existing chunk") + } + linktab[off] = chunk + } + } + } + + if sanity { + // Above we've sanity checked that we never overwrote + // an existing entry. Here we additionally check that + // we filled the tables completely. + for i, chunk := range h.chunks { + if chunk == 0 { + // As an exception, in the degenerate + // single-code case, we allow odd + // chunks to be missing. + if code == 1 && i%2 == 1 { + continue + } + panic("impossible: missing chunk") + } + } + for _, linktab := range h.links { + for _, chunk := range linktab { + if chunk == 0 { + panic("impossible: missing chunk") + } + } + } + } + + return true +} + +func main() { + flag.Parse() + + var h huffmanDecoder + var bits [288]int + initReverseByte() + for i := 0; i < 144; i++ { + bits[i] = 8 + } + for i := 144; i < 256; i++ { + bits[i] = 9 + } + for i := 256; i < 280; i++ { + bits[i] = 7 + } + for i := 280; i < 288; i++ { + bits[i] = 8 + } + h.init(bits[:]) + if h.links != nil { + log.Fatal("Unexpected links table in fixed Huffman decoder") + } + + var buf bytes.Buffer + + fmt.Fprintf(&buf, `// 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.`+"\n\n") + + fmt.Fprintln(&buf, "package flate") + fmt.Fprintln(&buf) + fmt.Fprintln(&buf, "// autogenerated by go run gen.go -output fixedhuff.go, DO NOT EDIT") + fmt.Fprintln(&buf) + fmt.Fprintln(&buf, "var fixedHuffmanDecoder = huffmanDecoder{") + fmt.Fprintf(&buf, "\t%d,\n", h.min) + fmt.Fprintln(&buf, "\t[huffmanNumChunks]uint32{") + for i := 0; i < huffmanNumChunks; i++ { + if i&7 == 0 { + fmt.Fprintf(&buf, "\t\t") + } else { + fmt.Fprintf(&buf, " ") + } + fmt.Fprintf(&buf, "0x%04x,", h.chunks[i]) + if i&7 == 7 { + fmt.Fprintln(&buf) + } + } + fmt.Fprintln(&buf, "\t},") + fmt.Fprintln(&buf, "\tnil, 0,") + fmt.Fprintln(&buf, "}") + + data, err := format.Source(buf.Bytes()) + if err != nil { + log.Fatal(err) + } + err = ioutil.WriteFile(*filename, data, 0644) + if err != nil { + log.Fatal(err) + } +} + +var reverseByte [256]byte + +func initReverseByte() { + for x := 0; x < 256; x++ { + var result byte + for i := uint(0); i < 8; i++ { + result |= byte(((x >> i) & 1) << (7 - i)) + } + reverseByte[x] = result + } +} diff --git a/vendor/github.com/klauspost/compress/flate/huffman_bit_writer.go b/vendor/github.com/klauspost/compress/flate/huffman_bit_writer.go new file mode 100644 index 0000000000..5f7ffdd2e6 --- /dev/null +++ b/vendor/github.com/klauspost/compress/flate/huffman_bit_writer.go @@ -0,0 +1,717 @@ +// 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. + +package flate + +import ( + "io" + "math" +) + +const ( + // The largest offset code. + offsetCodeCount = 30 + + // The special code used to mark the end of a block. + endBlockMarker = 256 + + // The first length code. + lengthCodesStart = 257 + + // The number of codegen codes. + codegenCodeCount = 19 + badCode = 255 + + // Output byte buffer size + // Must be multiple of 6 (48 bits) + 8 + bufferSize = 240 + 8 +) + +// The number of extra bits needed by length code X - LENGTH_CODES_START. +var lengthExtraBits = []int8{ + /* 257 */ 0, 0, 0, + /* 260 */ 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, + /* 270 */ 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, + /* 280 */ 4, 5, 5, 5, 5, 0, +} + +// The length indicated by length code X - LENGTH_CODES_START. +var lengthBase = []uint32{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, + 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, + 64, 80, 96, 112, 128, 160, 192, 224, 255, +} + +// offset code word extra bits. +var offsetExtraBits = []int8{ + 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, + 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, + 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, + /* extended window */ + 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, +} + +var offsetBase = []uint32{ + /* normal deflate */ + 0x000000, 0x000001, 0x000002, 0x000003, 0x000004, + 0x000006, 0x000008, 0x00000c, 0x000010, 0x000018, + 0x000020, 0x000030, 0x000040, 0x000060, 0x000080, + 0x0000c0, 0x000100, 0x000180, 0x000200, 0x000300, + 0x000400, 0x000600, 0x000800, 0x000c00, 0x001000, + 0x001800, 0x002000, 0x003000, 0x004000, 0x006000, + + /* extended window */ + 0x008000, 0x00c000, 0x010000, 0x018000, 0x020000, + 0x030000, 0x040000, 0x060000, 0x080000, 0x0c0000, + 0x100000, 0x180000, 0x200000, 0x300000, +} + +// The odd order in which the codegen code sizes are written. +var codegenOrder = []uint32{16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15} + +type huffmanBitWriter struct { + w io.Writer + // Data waiting to be written is bytes[0:nbytes] + // and then the low nbits of bits. + bits uint64 + nbits uint + bytes [bufferSize]byte + nbytes int + literalFreq []int32 + offsetFreq []int32 + codegen []uint8 + codegenFreq []int32 + literalEncoding *huffmanEncoder + offsetEncoding *huffmanEncoder + codegenEncoding *huffmanEncoder + err error +} + +func newHuffmanBitWriter(w io.Writer) *huffmanBitWriter { + return &huffmanBitWriter{ + w: w, + literalFreq: make([]int32, maxNumLit), + offsetFreq: make([]int32, offsetCodeCount), + codegen: make([]uint8, maxNumLit+offsetCodeCount+1), + codegenFreq: make([]int32, codegenCodeCount), + literalEncoding: newHuffmanEncoder(maxNumLit), + codegenEncoding: newHuffmanEncoder(codegenCodeCount), + offsetEncoding: newHuffmanEncoder(offsetCodeCount), + } +} + +func (w *huffmanBitWriter) reset(writer io.Writer) { + w.w = writer + w.bits, w.nbits, w.nbytes, w.err = 0, 0, 0, nil + w.bytes = [bufferSize]byte{} +} + +func (w *huffmanBitWriter) flush() { + if w.err != nil { + w.nbits = 0 + return + } + n := w.nbytes + for w.nbits != 0 { + w.bytes[n] = byte(w.bits) + w.bits >>= 8 + if w.nbits > 8 { // Avoid underflow + w.nbits -= 8 + } else { + w.nbits = 0 + } + n++ + } + w.bits = 0 + _, w.err = w.w.Write(w.bytes[0:n]) + w.nbytes = 0 +} + +func (w *huffmanBitWriter) writeBits(b int32, nb uint) { + w.bits |= uint64(b) << w.nbits + w.nbits += nb + if w.nbits >= 48 { + bits := w.bits + w.bits >>= 48 + w.nbits -= 48 + n := w.nbytes + w.bytes[n] = byte(bits) + w.bytes[n+1] = byte(bits >> 8) + w.bytes[n+2] = byte(bits >> 16) + w.bytes[n+3] = byte(bits >> 24) + w.bytes[n+4] = byte(bits >> 32) + w.bytes[n+5] = byte(bits >> 40) + n += 6 + if n >= bufferSize-8 { + _, w.err = w.w.Write(w.bytes[:bufferSize-8]) + n = 0 + } + w.nbytes = n + } +} + +func (w *huffmanBitWriter) writeBytes(bytes []byte) { + if w.err != nil { + return + } + n := w.nbytes + for w.nbits != 0 { + w.bytes[n] = byte(w.bits) + w.bits >>= 8 + w.nbits -= 8 + n++ + } + if w.nbits != 0 { + w.err = InternalError("writeBytes with unfinished bits") + return + } + if n != 0 { + _, w.err = w.w.Write(w.bytes[0:n]) + if w.err != nil { + return + } + } + w.nbytes = 0 + _, w.err = w.w.Write(bytes) +} + +// RFC 1951 3.2.7 specifies a special run-length encoding for specifying +// the literal and offset lengths arrays (which are concatenated into a single +// array). This method generates that run-length encoding. +// +// The result is written into the codegen array, and the frequencies +// of each code is written into the codegenFreq array. +// Codes 0-15 are single byte codes. Codes 16-18 are followed by additional +// information. Code badCode is an end marker +// +// numLiterals The number of literals in literalEncoding +// numOffsets The number of offsets in offsetEncoding +func (w *huffmanBitWriter) generateCodegen(numLiterals int, numOffsets int, offenc *huffmanEncoder) { + for i := range w.codegenFreq { + w.codegenFreq[i] = 0 + } + // Note that we are using codegen both as a temporary variable for holding + // a copy of the frequencies, and as the place where we put the result. + // This is fine because the output is always shorter than the input used + // so far. + codegen := w.codegen // cache + // Copy the concatenated code sizes to codegen. Put a marker at the end. + cgnl := codegen[0:numLiterals] + for i := range cgnl { + cgnl[i] = uint8(w.literalEncoding.codes[i].bits()) + } + + cgnl = codegen[numLiterals : numLiterals+numOffsets] + for i := range cgnl { + cgnl[i] = uint8(offenc.codes[i].bits()) + } + codegen[numLiterals+numOffsets] = badCode + + size := codegen[0] + count := 1 + outIndex := 0 + for inIndex := 1; size != badCode; inIndex++ { + // INVARIANT: We have seen "count" copies of size that have not yet + // had output generated for them. + nextSize := codegen[inIndex] + if nextSize == size { + count++ + continue + } + // We need to generate codegen indicating "count" of size. + if size != 0 { + codegen[outIndex] = size + outIndex++ + w.codegenFreq[size]++ + count-- + for count >= 3 { + n := 6 + if n > count { + n = count + } + codegen[outIndex] = 16 + outIndex++ + codegen[outIndex] = uint8(n - 3) + outIndex++ + w.codegenFreq[16]++ + count -= n + } + } else { + for count >= 11 { + n := 138 + if n > count { + n = count + } + codegen[outIndex] = 18 + outIndex++ + codegen[outIndex] = uint8(n - 11) + outIndex++ + w.codegenFreq[18]++ + count -= n + } + if count >= 3 { + // count >= 3 && count <= 10 + codegen[outIndex] = 17 + outIndex++ + codegen[outIndex] = uint8(count - 3) + outIndex++ + w.codegenFreq[17]++ + count = 0 + } + } + count-- + for ; count >= 0; count-- { + codegen[outIndex] = size + outIndex++ + w.codegenFreq[size]++ + } + // Set up invariant for next time through the loop. + size = nextSize + count = 1 + } + // Marker indicating the end of the codegen. + codegen[outIndex] = badCode +} + +func (w *huffmanBitWriter) writeCode(c hcode) { + if w.err != nil { + return + } + w.bits |= uint64(c.code()) << w.nbits + w.nbits += c.bits() + if w.nbits >= 48 { + bits := w.bits + w.bits >>= 48 + w.nbits -= 48 + n := w.nbytes + w.bytes[n] = byte(bits) + w.bytes[n+1] = byte(bits >> 8) + w.bytes[n+2] = byte(bits >> 16) + w.bytes[n+3] = byte(bits >> 24) + w.bytes[n+4] = byte(bits >> 32) + w.bytes[n+5] = byte(bits >> 40) + n += 6 + if n >= bufferSize-8 { + _, w.err = w.w.Write(w.bytes[:bufferSize-8]) + n = 0 + } + w.nbytes = n + } + +} + +// Write the header of a dynamic Huffman block to the output stream. +// +// numLiterals The number of literals specified in codegen +// numOffsets The number of offsets specified in codegen +// numCodegens The number of codegens used in codegen +func (w *huffmanBitWriter) writeDynamicHeader(numLiterals int, numOffsets int, numCodegens int, isEof bool) { + if w.err != nil { + return + } + var firstBits int32 = 4 + if isEof { + firstBits = 5 + } + w.writeBits(firstBits, 3) + w.writeBits(int32(numLiterals-257), 5) + w.writeBits(int32(numOffsets-1), 5) + w.writeBits(int32(numCodegens-4), 4) + + for i := 0; i < numCodegens; i++ { + value := w.codegenEncoding.codes[codegenOrder[i]].bits() + w.writeBits(int32(value), 3) + } + + i := 0 + for { + var codeWord int = int(w.codegen[i]) + i++ + if codeWord == badCode { + break + } + // The low byte contains the actual code to generate. + w.writeCode(w.codegenEncoding.codes[uint32(codeWord)]) + + switch codeWord { + case 16: + w.writeBits(int32(w.codegen[i]), 2) + i++ + break + case 17: + w.writeBits(int32(w.codegen[i]), 3) + i++ + break + case 18: + w.writeBits(int32(w.codegen[i]), 7) + i++ + break + } + } +} + +func (w *huffmanBitWriter) writeStoredHeader(length int, isEof bool) { + if w.err != nil { + return + } + var flag int32 + if isEof { + flag = 1 + } + w.writeBits(flag, 3) + w.flush() + w.writeBits(int32(length), 16) + w.writeBits(int32(^uint16(length)), 16) +} + +func (w *huffmanBitWriter) writeFixedHeader(isEof bool) { + if w.err != nil { + return + } + // Indicate that we are a fixed Huffman block + var value int32 = 2 + if isEof { + value = 3 + } + w.writeBits(value, 3) +} + +func (w *huffmanBitWriter) writeBlock(tok tokens, eof bool, input []byte) { + if w.err != nil { + return + } + for i := range w.literalFreq { + w.literalFreq[i] = 0 + } + for i := range w.offsetFreq { + w.offsetFreq[i] = 0 + } + + tok.tokens[tok.n] = endBlockMarker + tokens := tok.tokens[0 : tok.n+1] + + for _, t := range tokens { + if t < matchType { + w.literalFreq[t.literal()]++ + } else { + length := t.length() + offset := t.offset() + w.literalFreq[lengthCodesStart+lengthCode(length)]++ + w.offsetFreq[offsetCode(offset)]++ + } + } + + // get the number of literals + numLiterals := len(w.literalFreq) + for w.literalFreq[numLiterals-1] == 0 { + numLiterals-- + } + // get the number of offsets + numOffsets := len(w.offsetFreq) + for numOffsets > 0 && w.offsetFreq[numOffsets-1] == 0 { + numOffsets-- + } + if numOffsets == 0 { + // We haven't found a single match. If we want to go with the dynamic encoding, + // we should count at least one offset to be sure that the offset huffman tree could be encoded. + w.offsetFreq[0] = 1 + numOffsets = 1 + } + + w.literalEncoding.generate(w.literalFreq, 15) + w.offsetEncoding.generate(w.offsetFreq, 15) + + storedBytes := 0 + if input != nil { + storedBytes = len(input) + } + var extraBits int64 + var storedSize int64 = math.MaxInt64 + if storedBytes <= maxStoreBlockSize && input != nil { + storedSize = int64((storedBytes + 5) * 8) + // We only bother calculating the costs of the extra bits required by + // the length of offset fields (which will be the same for both fixed + // and dynamic encoding), if we need to compare those two encodings + // against stored encoding. + for lengthCode := lengthCodesStart + 8; lengthCode < numLiterals; lengthCode++ { + // First eight length codes have extra size = 0. + extraBits += int64(w.literalFreq[lengthCode]) * int64(lengthExtraBits[lengthCode-lengthCodesStart]) + } + for offsetCode := 4; offsetCode < numOffsets; offsetCode++ { + // First four offset codes have extra size = 0. + extraBits += int64(w.offsetFreq[offsetCode]) * int64(offsetExtraBits[offsetCode]) + } + } + + // Figure out smallest code. + // Fixed Huffman baseline. + var size = int64(3) + + fixedLiteralEncoding.bitLength(w.literalFreq) + + fixedOffsetEncoding.bitLength(w.offsetFreq) + + extraBits + var literalEncoding = fixedLiteralEncoding + var offsetEncoding = fixedOffsetEncoding + + // Dynamic Huffman? + var numCodegens int + + // Generate codegen and codegenFrequencies, which indicates how to encode + // the literalEncoding and the offsetEncoding. + w.generateCodegen(numLiterals, numOffsets, w.offsetEncoding) + w.codegenEncoding.generate(w.codegenFreq, 7) + numCodegens = len(w.codegenFreq) + for numCodegens > 4 && w.codegenFreq[codegenOrder[numCodegens-1]] == 0 { + numCodegens-- + } + dynamicHeader := int64(3+5+5+4+(3*numCodegens)) + + w.codegenEncoding.bitLength(w.codegenFreq) + + int64(extraBits) + + int64(w.codegenFreq[16]*2) + + int64(w.codegenFreq[17]*3) + + int64(w.codegenFreq[18]*7) + dynamicSize := dynamicHeader + + w.literalEncoding.bitLength(w.literalFreq) + + w.offsetEncoding.bitLength(w.offsetFreq) + + if dynamicSize < size { + size = dynamicSize + literalEncoding = w.literalEncoding + offsetEncoding = w.offsetEncoding + } + + // Stored bytes? + if storedSize < size { + w.writeStoredHeader(storedBytes, eof) + w.writeBytes(input[0:storedBytes]) + return + } + + // Huffman. + if literalEncoding == fixedLiteralEncoding { + w.writeFixedHeader(eof) + } else { + w.writeDynamicHeader(numLiterals, numOffsets, numCodegens, eof) + } + + leCodes := literalEncoding.codes + oeCodes := offsetEncoding.codes + for _, t := range tokens { + if t < matchType { + w.writeCode(leCodes[t.literal()]) + } else { + // Write the length + length := t.length() + lengthCode := lengthCode(length) + w.writeCode(leCodes[lengthCode+lengthCodesStart]) + extraLengthBits := uint(lengthExtraBits[lengthCode]) + if extraLengthBits > 0 { + extraLength := int32(length - lengthBase[lengthCode]) + w.writeBits(extraLength, extraLengthBits) + } + // Write the offset + offset := t.offset() + offsetCode := offsetCode(offset) + w.writeCode(oeCodes[offsetCode]) + extraOffsetBits := uint(offsetExtraBits[offsetCode]) + if extraOffsetBits > 0 { + extraOffset := int32(offset - offsetBase[offsetCode]) + w.writeBits(extraOffset, extraOffsetBits) + } + } + } +} + +// writeBlockDynamic will write a block as dynamic Huffman table +// compressed. This should be used, if the caller has a reasonable expectation +// that this block contains compressible data. +func (w *huffmanBitWriter) writeBlockDynamic(tok tokens, eof bool, input []byte) { + if w.err != nil { + return + } + for i := range w.literalFreq { + w.literalFreq[i] = 0 + } + for i := range w.offsetFreq { + w.offsetFreq[i] = 0 + } + + tok.tokens[tok.n] = endBlockMarker + tokens := tok.tokens[0 : tok.n+1] + + for _, t := range tokens { + if t < matchType { + w.literalFreq[t.literal()]++ + } else { + length := t.length() + offset := t.offset() + w.literalFreq[lengthCodesStart+lengthCode(length)]++ + w.offsetFreq[offsetCode(offset)]++ + } + } + + // get the number of literals + numLiterals := len(w.literalFreq) + for w.literalFreq[numLiterals-1] == 0 { + numLiterals-- + } + // get the number of offsets + numOffsets := len(w.offsetFreq) + for numOffsets > 0 && w.offsetFreq[numOffsets-1] == 0 { + numOffsets-- + } + if numOffsets == 0 { + // We haven't found a single match. If we want to go with the dynamic encoding, + // we should count at least one offset to be sure that the offset huffman tree could be encoded. + w.offsetFreq[0] = 1 + numOffsets = 1 + } + + w.literalEncoding.generate(w.literalFreq, 15) + w.offsetEncoding.generate(w.offsetFreq, 15) + + var numCodegens int + + // Generate codegen and codegenFrequencies, which indicates how to encode + // the literalEncoding and the offsetEncoding. + w.generateCodegen(numLiterals, numOffsets, w.offsetEncoding) + w.codegenEncoding.generate(w.codegenFreq, 7) + numCodegens = len(w.codegenFreq) + for numCodegens > 4 && w.codegenFreq[codegenOrder[numCodegens-1]] == 0 { + numCodegens-- + } + var literalEncoding = w.literalEncoding + var offsetEncoding = w.offsetEncoding + + // Write Huffman table. + w.writeDynamicHeader(numLiterals, numOffsets, numCodegens, eof) + leCodes := literalEncoding.codes + oeCodes := offsetEncoding.codes + + for _, t := range tokens { + if t < matchType { + w.writeCode(leCodes[t.literal()]) + } else { + // Write the length + length := t.length() + lengthCode := lengthCode(length) + w.writeCode(leCodes[lengthCode+lengthCodesStart]) + extraLengthBits := uint(lengthExtraBits[lengthCode]) + if extraLengthBits > 0 { + extraLength := int32(length - lengthBase[lengthCode]) + w.writeBits(extraLength, extraLengthBits) + } + // Write the offset + offset := t.offset() + offsetCode := offsetCode(offset) + w.writeCode(oeCodes[offsetCode]) + extraOffsetBits := uint(offsetExtraBits[offsetCode]) + if extraOffsetBits > 0 { + extraOffset := int32(offset - offsetBase[offsetCode]) + w.writeBits(extraOffset, extraOffsetBits) + } + } + } +} + +// static offset encoder used for huffman only encoding. +var huffOffset *huffmanEncoder + +func init() { + var w = newHuffmanBitWriter(nil) + w.offsetFreq[0] = 1 + huffOffset = newHuffmanEncoder(offsetCodeCount) + huffOffset.generate(w.offsetFreq, 15) +} + +// writeBlockHuff will write a block of bytes as either +// Huffman encoded literals or uncompressed bytes if the +// results only gains very little from compression. +func (w *huffmanBitWriter) writeBlockHuff(eof bool, input []byte) { + if w.err != nil { + return + } + + // Clear histogram + for i := range w.literalFreq { + w.literalFreq[i] = 0 + } + + // Add everything as literals + histogram(input, w.literalFreq) + + w.literalFreq[endBlockMarker] = 1 + + const numLiterals = endBlockMarker + 1 + const numOffsets = 1 + + w.literalEncoding.generate(w.literalFreq, 15) + + // Figure out smallest code. + // Always use dynamic Huffman or Store + var numCodegens int + + // Generate codegen and codegenFrequencies, which indicates how to encode + // the literalEncoding and the offsetEncoding. + w.generateCodegen(numLiterals, numOffsets, huffOffset) + w.codegenEncoding.generate(w.codegenFreq, 7) + numCodegens = len(w.codegenFreq) + for numCodegens > 4 && w.codegenFreq[codegenOrder[numCodegens-1]] == 0 { + numCodegens-- + } + headerSize := int64(3+5+5+4+(3*numCodegens)) + + w.codegenEncoding.bitLength(w.codegenFreq) + + int64(w.codegenFreq[16]*2) + + int64(w.codegenFreq[17]*3) + + int64(w.codegenFreq[18]*7) + + // Includes EOB marker + size := headerSize + w.literalEncoding.bitLength(w.literalFreq) + + // Calculate stored size + var storedSize int64 = math.MaxInt64 + var storedBytes = len(input) + if storedBytes <= maxStoreBlockSize { + storedSize = int64(storedBytes+5) * 8 + } + + // Store bytes, if we don't get a reasonable improvement. + if storedSize < (size + size>>4) { + w.writeStoredHeader(storedBytes, eof) + w.writeBytes(input) + return + } + + // Huffman. + w.writeDynamicHeader(numLiterals, numOffsets, numCodegens, eof) + encoding := w.literalEncoding.codes + for _, t := range input { + // Bitwriting inlined, ~30% speedup + c := encoding[t] + w.bits |= uint64(c.code()) << w.nbits + w.nbits += c.bits() + if w.nbits >= 48 { + bits := w.bits + w.bits >>= 48 + w.nbits -= 48 + n := w.nbytes + w.bytes[n] = byte(bits) + w.bytes[n+1] = byte(bits >> 8) + w.bytes[n+2] = byte(bits >> 16) + w.bytes[n+3] = byte(bits >> 24) + w.bytes[n+4] = byte(bits >> 32) + w.bytes[n+5] = byte(bits >> 40) + n += 6 + if n >= bufferSize-8 { + _, w.err = w.w.Write(w.bytes[:bufferSize-8]) + if w.err != nil { + return + } + w.nbytes = 0 + } else { + w.nbytes = n + } + } + } + w.writeCode(encoding[endBlockMarker]) +} diff --git a/vendor/github.com/klauspost/compress/flate/huffman_code.go b/vendor/github.com/klauspost/compress/flate/huffman_code.go new file mode 100644 index 0000000000..9dba0faf33 --- /dev/null +++ b/vendor/github.com/klauspost/compress/flate/huffman_code.go @@ -0,0 +1,363 @@ +// 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. + +package flate + +import ( + "math" + "sort" +) + +type hcode uint32 + +type huffmanEncoder struct { + codes []hcode + freqcache []literalNode + bitCount [17]int32 + lns literalNodeSorter + lfs literalFreqSorter +} + +type literalNode struct { + literal uint16 + freq int32 +} + +// A levelInfo describes the state of the constructed tree for a given depth. +type levelInfo struct { + // Our level. for better printing + level int32 + + // The frequency of the last node at this level + lastFreq int32 + + // The frequency of the next character to add to this level + nextCharFreq int32 + + // The frequency of the next pair (from level below) to add to this level. + // Only valid if the "needed" value of the next lower level is 0. + nextPairFreq int32 + + // The number of chains remaining to generate for this level before moving + // up to the next level + needed int32 +} + +func (h hcode) codeBits() (code uint16, bits uint8) { + return uint16(h), uint8(h >> 16) +} + +func (h *hcode) set(code uint16, bits uint8) { + *h = hcode(code) | hcode(uint32(bits)<<16) +} + +func (h *hcode) setBits(bits uint8) { + *h = hcode(*h&0xffff) | hcode(uint32(bits)<<16) +} + +func toCode(code uint16, bits uint8) hcode { + return hcode(code) | hcode(uint32(bits)<<16) +} + +func (h hcode) code() (code uint16) { + return uint16(h) +} + +func (h hcode) bits() (bits uint) { + return uint(h >> 16) +} + +func maxNode() literalNode { return literalNode{math.MaxUint16, math.MaxInt32} } + +func newHuffmanEncoder(size int) *huffmanEncoder { + return &huffmanEncoder{codes: make([]hcode, size), freqcache: nil} +} + +// Generates a HuffmanCode corresponding to the fixed literal table +func generateFixedLiteralEncoding() *huffmanEncoder { + h := newHuffmanEncoder(maxNumLit) + codes := h.codes + var ch uint16 + for ch = 0; ch < maxNumLit; ch++ { + var bits uint16 + var size uint8 + switch { + case ch < 144: + // size 8, 000110000 .. 10111111 + bits = ch + 48 + size = 8 + break + case ch < 256: + // size 9, 110010000 .. 111111111 + bits = ch + 400 - 144 + size = 9 + break + case ch < 280: + // size 7, 0000000 .. 0010111 + bits = ch - 256 + size = 7 + break + default: + // size 8, 11000000 .. 11000111 + bits = ch + 192 - 280 + size = 8 + } + codes[ch] = toCode(reverseBits(bits, size), size) + } + return h +} + +func generateFixedOffsetEncoding() *huffmanEncoder { + h := newHuffmanEncoder(30) + codes := h.codes + for ch := uint16(0); ch < 30; ch++ { + codes[ch] = toCode(reverseBits(ch, 5), 5) + } + return h +} + +var fixedLiteralEncoding *huffmanEncoder = generateFixedLiteralEncoding() +var fixedOffsetEncoding *huffmanEncoder = generateFixedOffsetEncoding() + +func (h *huffmanEncoder) bitLength(freq []int32) int64 { + var total int64 + for i, f := range freq { + if f != 0 { + total += int64(f) * int64(h.codes[i].bits()) + } + } + return total +} + +const maxBitsLimit = 16 + +// Return the number of literals assigned to each bit size in the Huffman encoding +// +// This method is only called when list.length >= 3 +// The cases of 0, 1, and 2 literals are handled by special case code. +// +// list An array of the literals with non-zero frequencies +// and their associated frequencies. The array is in order of increasing +// frequency, and has as its last element a special element with frequency +// MaxInt32 +// maxBits The maximum number of bits that should be used to encode any literal. +// Must be less than 16. +// return An integer array in which array[i] indicates the number of literals +// that should be encoded in i bits. +func (h *huffmanEncoder) bitCounts(list []literalNode, maxBits int32) []int32 { + if maxBits >= maxBitsLimit { + panic("flate: maxBits too large") + } + n := int32(len(list)) + list = list[0 : n+1] + list[n] = maxNode() + + // The tree can't have greater depth than n - 1, no matter what. This + // saves a little bit of work in some small cases + if maxBits > n-1 { + maxBits = n - 1 + } + + // Create information about each of the levels. + // A bogus "Level 0" whose sole purpose is so that + // level1.prev.needed==0. This makes level1.nextPairFreq + // be a legitimate value that never gets chosen. + var levels [maxBitsLimit]levelInfo + // leafCounts[i] counts the number of literals at the left + // of ancestors of the rightmost node at level i. + // leafCounts[i][j] is the number of literals at the left + // of the level j ancestor. + var leafCounts [maxBitsLimit][maxBitsLimit]int32 + + for level := int32(1); level <= maxBits; level++ { + // For every level, the first two items are the first two characters. + // We initialize the levels as if we had already figured this out. + levels[level] = levelInfo{ + level: level, + lastFreq: list[1].freq, + nextCharFreq: list[2].freq, + nextPairFreq: list[0].freq + list[1].freq, + } + leafCounts[level][level] = 2 + if level == 1 { + levels[level].nextPairFreq = math.MaxInt32 + } + } + + // We need a total of 2*n - 2 items at top level and have already generated 2. + levels[maxBits].needed = 2*n - 4 + + level := maxBits + for { + l := &levels[level] + if l.nextPairFreq == math.MaxInt32 && l.nextCharFreq == math.MaxInt32 { + // We've run out of both leafs and pairs. + // End all calculations for this level. + // To make sure we never come back to this level or any lower level, + // set nextPairFreq impossibly large. + l.needed = 0 + levels[level+1].nextPairFreq = math.MaxInt32 + level++ + continue + } + + prevFreq := l.lastFreq + if l.nextCharFreq < l.nextPairFreq { + // The next item on this row is a leaf node. + n := leafCounts[level][level] + 1 + l.lastFreq = l.nextCharFreq + // Lower leafCounts are the same of the previous node. + leafCounts[level][level] = n + l.nextCharFreq = list[n].freq + } else { + // The next item on this row is a pair from the previous row. + // nextPairFreq isn't valid until we generate two + // more values in the level below + l.lastFreq = l.nextPairFreq + // Take leaf counts from the lower level, except counts[level] remains the same. + copy(leafCounts[level][:level], leafCounts[level-1][:level]) + levels[l.level-1].needed = 2 + } + + if l.needed--; l.needed == 0 { + // We've done everything we need to do for this level. + // Continue calculating one level up. Fill in nextPairFreq + // of that level with the sum of the two nodes we've just calculated on + // this level. + if l.level == maxBits { + // All done! + break + } + levels[l.level+1].nextPairFreq = prevFreq + l.lastFreq + level++ + } else { + // If we stole from below, move down temporarily to replenish it. + for levels[level-1].needed > 0 { + level-- + } + } + } + + // Somethings is wrong if at the end, the top level is null or hasn't used + // all of the leaves. + if leafCounts[maxBits][maxBits] != n { + panic("leafCounts[maxBits][maxBits] != n") + } + + bitCount := h.bitCount[:maxBits+1] + //make([]int32, maxBits+1) + bits := 1 + counts := &leafCounts[maxBits] + for level := maxBits; level > 0; level-- { + // chain.leafCount gives the number of literals requiring at least "bits" + // bits to encode. + bitCount[bits] = counts[level] - counts[level-1] + bits++ + } + return bitCount +} + +// Look at the leaves and assign them a bit count and an encoding as specified +// in RFC 1951 3.2.2 +func (h *huffmanEncoder) assignEncodingAndSize(bitCount []int32, list []literalNode) { + code := uint16(0) + for n, bits := range bitCount { + code <<= 1 + if n == 0 || bits == 0 { + continue + } + // The literals list[len(list)-bits] .. list[len(list)-bits] + // are encoded using "bits" bits, and get the values + // code, code + 1, .... The code values are + // assigned in literal order (not frequency order). + chunk := list[len(list)-int(bits):] + + h.lns.Sort(chunk) + for _, node := range chunk { + h.codes[node.literal] = toCode(reverseBits(code, uint8(n)), uint8(n)) + code++ + } + list = list[0 : len(list)-int(bits)] + } +} + +// Update this Huffman Code object to be the minimum code for the specified frequency count. +// +// freq An array of frequencies, in which frequency[i] gives the frequency of literal i. +// maxBits The maximum number of bits to use for any literal. +func (h *huffmanEncoder) generate(freq []int32, maxBits int32) { + if h.freqcache == nil { + h.freqcache = make([]literalNode, 300) + } + list := h.freqcache[:len(freq)+1] + // Number of non-zero literals + count := 0 + // Set list to be the set of all non-zero literals and their frequencies + for i, f := range freq { + if f != 0 { + list[count] = literalNode{uint16(i), f} + count++ + } else { + list[count] = literalNode{} + //h.codeBits[i] = 0 + h.codes[i].setBits(0) + } + } + list[len(freq)] = literalNode{} + // If freq[] is shorter than codeBits[], fill rest of codeBits[] with zeros + // FIXME: Doesn't do what it says on the tin (klauspost) + //h.codeBits = h.codeBits[0:len(freq)] + + list = list[0:count] + if count <= 2 { + // Handle the small cases here, because they are awkward for the general case code. With + // two or fewer literals, everything has bit length 1. + for i, node := range list { + // "list" is in order of increasing literal value. + h.codes[node.literal].set(uint16(i), 1) + //h.codeBits[node.literal] = 1 + //h.code[node.literal] = uint16(i) + } + return + } + h.lfs.Sort(list) + + // Get the number of literals for each bit count + bitCount := h.bitCounts(list, maxBits) + // And do the assignment + h.assignEncodingAndSize(bitCount, list) +} + +type literalNodeSorter []literalNode + +func (s *literalNodeSorter) Sort(a []literalNode) { + *s = literalNodeSorter(a) + sort.Sort(s) +} + +func (s literalNodeSorter) Len() int { return len(s) } + +func (s literalNodeSorter) Less(i, j int) bool { + return s[i].literal < s[j].literal +} + +func (s literalNodeSorter) Swap(i, j int) { s[i], s[j] = s[j], s[i] } + +type literalFreqSorter []literalNode + +func (s *literalFreqSorter) Sort(a []literalNode) { + *s = literalFreqSorter(a) + sort.Sort(s) +} + +func (s literalFreqSorter) Len() int { return len(s) } + +func (s literalFreqSorter) Less(i, j int) bool { + if s[i].freq == s[j].freq { + return s[i].literal < s[j].literal + } + return s[i].freq < s[j].freq +} + +func (s literalFreqSorter) Swap(i, j int) { s[i], s[j] = s[j], s[i] } diff --git a/vendor/github.com/klauspost/compress/flate/inflate.go b/vendor/github.com/klauspost/compress/flate/inflate.go new file mode 100644 index 0000000000..91e27e7e28 --- /dev/null +++ b/vendor/github.com/klauspost/compress/flate/inflate.go @@ -0,0 +1,846 @@ +// 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. + +//go:generate go run gen.go -output fixedhuff.go + +// Package flate implements the DEFLATE compressed data format, described in +// RFC 1951. The gzip and zlib packages implement access to DEFLATE-based file +// formats. +package flate + +import ( + "bufio" + "io" + "strconv" +) + +const ( + maxCodeLen = 16 // max length of Huffman code + maxHist = 32768 // max history required + // The next three numbers come from the RFC section 3.2.7, with the + // additional proviso in section 3.2.5 which implies that distance codes + // 30 and 31 should never occur in compressed data. + maxNumLit = 286 + maxNumDist = 30 + numCodes = 19 // number of codes in Huffman meta-code +) + +// A CorruptInputError reports the presence of corrupt input at a given offset. +type CorruptInputError int64 + +func (e CorruptInputError) Error() string { + return "flate: corrupt input before offset " + strconv.FormatInt(int64(e), 10) +} + +// An InternalError reports an error in the flate code itself. +type InternalError string + +func (e InternalError) Error() string { return "flate: internal error: " + string(e) } + +// A ReadError reports an error encountered while reading input. +type ReadError struct { + Offset int64 // byte offset where error occurred + Err error // error returned by underlying Read +} + +func (e *ReadError) Error() string { + return "flate: read error at offset " + strconv.FormatInt(e.Offset, 10) + ": " + e.Err.Error() +} + +// A WriteError reports an error encountered while writing output. +type WriteError struct { + Offset int64 // byte offset where error occurred + Err error // error returned by underlying Write +} + +func (e *WriteError) Error() string { + return "flate: write error at offset " + strconv.FormatInt(e.Offset, 10) + ": " + e.Err.Error() +} + +// Resetter resets a ReadCloser returned by NewReader or NewReaderDict to +// to switch to a new underlying Reader. This permits reusing a ReadCloser +// instead of allocating a new one. +type Resetter interface { + // Reset discards any buffered data and resets the Resetter as if it was + // newly initialized with the given reader. + Reset(r io.Reader, dict []byte) error +} + +// Note that much of the implementation of huffmanDecoder is also copied +// into gen.go (in package main) for the purpose of precomputing the +// fixed huffman tables so they can be included statically. + +// The data structure for decoding Huffman tables is based on that of +// zlib. There is a lookup table of a fixed bit width (huffmanChunkBits), +// For codes smaller than the table width, there are multiple entries +// (each combination of trailing bits has the same value). For codes +// larger than the table width, the table contains a link to an overflow +// table. The width of each entry in the link table is the maximum code +// size minus the chunk width. + +// Note that you can do a lookup in the table even without all bits +// filled. Since the extra bits are zero, and the DEFLATE Huffman codes +// have the property that shorter codes come before longer ones, the +// bit length estimate in the result is a lower bound on the actual +// number of bits. + +// chunk & 15 is number of bits +// chunk >> 4 is value, including table link + +const ( + huffmanChunkBits = 9 + huffmanNumChunks = 1 << huffmanChunkBits + huffmanCountMask = 15 + huffmanValueShift = 4 +) + +type huffmanDecoder struct { + min int // the minimum code length + chunks [huffmanNumChunks]uint32 // chunks as described above + links [][]uint32 // overflow links + linkMask uint32 // mask the width of the link table +} + +// Initialize Huffman decoding tables from array of code lengths. +// Following this function, h is guaranteed to be initialized into a complete +// tree (i.e., neither over-subscribed nor under-subscribed). The exception is a +// degenerate case where the tree has only a single symbol with length 1. Empty +// trees are permitted. +func (h *huffmanDecoder) init(bits []int) bool { + // Sanity enables additional runtime tests during Huffman + // table construction. It's intended to be used during + // development to supplement the currently ad-hoc unit tests. + const sanity = false + + if h.min != 0 { + *h = huffmanDecoder{} + } + + // Count number of codes of each length, + // compute min and max length. + var count [maxCodeLen]int + var min, max int + for _, n := range bits { + if n == 0 { + continue + } + if min == 0 || n < min { + min = n + } + if n > max { + max = n + } + count[n]++ + } + + // Empty tree. The decompressor.huffSym function will fail later if the tree + // is used. Technically, an empty tree is only valid for the HDIST tree and + // not the HCLEN and HLIT tree. However, a stream with an empty HCLEN tree + // is guaranteed to fail since it will attempt to use the tree to decode the + // codes for the HLIT and HDIST trees. Similarly, an empty HLIT tree is + // guaranteed to fail later since the compressed data section must be + // composed of at least one symbol (the end-of-block marker). + if max == 0 { + return true + } + + code := 0 + var nextcode [maxCodeLen]int + for i := min; i <= max; i++ { + code <<= 1 + nextcode[i] = code + code += count[i] + } + + // Check that the coding is complete (i.e., that we've + // assigned all 2-to-the-max possible bit sequences). + // Exception: To be compatible with zlib, we also need to + // accept degenerate single-code codings. See also + // TestDegenerateHuffmanCoding. + if code != 1< huffmanChunkBits { + numLinks := 1 << (uint(max) - huffmanChunkBits) + h.linkMask = uint32(numLinks - 1) + + // create link tables + link := nextcode[huffmanChunkBits+1] >> 1 + h.links = make([][]uint32, huffmanNumChunks-link) + for j := uint(link); j < huffmanNumChunks; j++ { + reverse := int(reverseByte[j>>8]) | int(reverseByte[j&0xff])<<8 + reverse >>= uint(16 - huffmanChunkBits) + off := j - uint(link) + if sanity && h.chunks[reverse] != 0 { + panic("impossible: overwriting existing chunk") + } + h.chunks[reverse] = uint32(off<>8]) | int(reverseByte[code&0xff])<<8 + reverse >>= uint(16 - n) + if n <= huffmanChunkBits { + for off := reverse; off < len(h.chunks); off += 1 << uint(n) { + // We should never need to overwrite + // an existing chunk. Also, 0 is + // never a valid chunk, because the + // lower 4 "count" bits should be + // between 1 and 15. + if sanity && h.chunks[off] != 0 { + panic("impossible: overwriting existing chunk") + } + h.chunks[off] = chunk + } + } else { + j := reverse & (huffmanNumChunks - 1) + if sanity && h.chunks[j]&huffmanCountMask != huffmanChunkBits+1 { + // Longer codes should have been + // associated with a link table above. + panic("impossible: not an indirect chunk") + } + value := h.chunks[j] >> huffmanValueShift + linktab := h.links[value] + reverse >>= huffmanChunkBits + for off := reverse; off < len(linktab); off += 1 << uint(n-huffmanChunkBits) { + if sanity && linktab[off] != 0 { + panic("impossible: overwriting existing chunk") + } + linktab[off] = chunk + } + } + } + + if sanity { + // Above we've sanity checked that we never overwrote + // an existing entry. Here we additionally check that + // we filled the tables completely. + for i, chunk := range h.chunks { + if chunk == 0 { + // As an exception, in the degenerate + // single-code case, we allow odd + // chunks to be missing. + if code == 1 && i%2 == 1 { + continue + } + panic("impossible: missing chunk") + } + } + for _, linktab := range h.links { + for _, chunk := range linktab { + if chunk == 0 { + panic("impossible: missing chunk") + } + } + } + } + + return true +} + +// The actual read interface needed by NewReader. +// If the passed in io.Reader does not also have ReadByte, +// the NewReader will introduce its own buffering. +type Reader interface { + io.Reader + io.ByteReader +} + +// Decompress state. +type decompressor struct { + // Input source. + r Reader + roffset int64 + woffset int64 + + // Input bits, in top of b. + b uint32 + nb uint + + // Huffman decoders for literal/length, distance. + h1, h2 huffmanDecoder + + // Length arrays used to define Huffman codes. + bits *[maxNumLit + maxNumDist]int + codebits *[numCodes]int + + // Output history, buffer. + hist *[maxHist]byte + hp int // current output position in buffer + hw int // have written hist[0:hw] already + hfull bool // buffer has filled at least once + + // Temporary buffer (avoids repeated allocation). + buf [4]byte + + // Next step in the decompression, + // and decompression state. + step func(*decompressor) + final bool + err error + toRead []byte + hl, hd *huffmanDecoder + copyLen int + copyDist int +} + +func (f *decompressor) nextBlock() { + if f.final { + if f.hw != f.hp { + f.flush((*decompressor).nextBlock) + return + } + f.err = io.EOF + return + } + for f.nb < 1+2 { + if f.err = f.moreBits(); f.err != nil { + return + } + } + f.final = f.b&1 == 1 + f.b >>= 1 + typ := f.b & 3 + f.b >>= 2 + f.nb -= 1 + 2 + switch typ { + case 0: + f.dataBlock() + case 1: + // compressed, fixed Huffman tables + f.hl = &fixedHuffmanDecoder + f.hd = nil + f.huffmanBlock() + case 2: + // compressed, dynamic Huffman tables + if f.err = f.readHuffman(); f.err != nil { + break + } + f.hl = &f.h1 + f.hd = &f.h2 + f.huffmanBlock() + default: + // 3 is reserved. + f.err = CorruptInputError(f.roffset) + } +} + +func (f *decompressor) Read(b []byte) (int, error) { + for { + if len(f.toRead) > 0 { + n := copy(b, f.toRead) + f.toRead = f.toRead[n:] + return n, nil + } + if f.err != nil { + return 0, f.err + } + f.step(f) + } +} + +// Support the io.WriteTo interface for io.Copy and friends. +func (f *decompressor) WriteTo(w io.Writer) (int64, error) { + total := int64(0) + for { + if f.err != nil { + if f.err == io.EOF { + return total, nil + } + return total, f.err + } + if len(f.toRead) > 0 { + var n int + n, f.err = w.Write(f.toRead) + if f.err != nil { + return total, f.err + } + if n != len(f.toRead) { + return total, io.ErrShortWrite + } + f.toRead = f.toRead[:0] + total += int64(n) + } + f.step(f) + } +} + +func (f *decompressor) Close() error { + if f.err == io.EOF { + return nil + } + return f.err +} + +// RFC 1951 section 3.2.7. +// Compression with dynamic Huffman codes + +var codeOrder = [...]int{16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15} + +func (f *decompressor) readHuffman() error { + // HLIT[5], HDIST[5], HCLEN[4]. + for f.nb < 5+5+4 { + if err := f.moreBits(); err != nil { + return err + } + } + nlit := int(f.b&0x1F) + 257 + if nlit > maxNumLit { + return CorruptInputError(f.roffset) + } + f.b >>= 5 + ndist := int(f.b&0x1F) + 1 + if ndist > maxNumDist { + return CorruptInputError(f.roffset) + } + f.b >>= 5 + nclen := int(f.b&0xF) + 4 + // numCodes is 19, so nclen is always valid. + f.b >>= 4 + f.nb -= 5 + 5 + 4 + + // (HCLEN+4)*3 bits: code lengths in the magic codeOrder order. + for i := 0; i < nclen; i++ { + for f.nb < 3 { + if err := f.moreBits(); err != nil { + return err + } + } + f.codebits[codeOrder[i]] = int(f.b & 0x7) + f.b >>= 3 + f.nb -= 3 + } + for i := nclen; i < len(codeOrder); i++ { + f.codebits[codeOrder[i]] = 0 + } + if !f.h1.init(f.codebits[0:]) { + return CorruptInputError(f.roffset) + } + + // HLIT + 257 code lengths, HDIST + 1 code lengths, + // using the code length Huffman code. + for i, n := 0, nlit+ndist; i < n; { + x, err := f.huffSym(&f.h1) + if err != nil { + return err + } + if x < 16 { + // Actual length. + f.bits[i] = x + i++ + continue + } + // Repeat previous length or zero. + var rep int + var nb uint + var b int + switch x { + default: + return InternalError("unexpected length code") + case 16: + rep = 3 + nb = 2 + if i == 0 { + return CorruptInputError(f.roffset) + } + b = f.bits[i-1] + case 17: + rep = 3 + nb = 3 + b = 0 + case 18: + rep = 11 + nb = 7 + b = 0 + } + for f.nb < nb { + if err := f.moreBits(); err != nil { + return err + } + } + rep += int(f.b & uint32(1<>= nb + f.nb -= nb + if i+rep > n { + return CorruptInputError(f.roffset) + } + for j := 0; j < rep; j++ { + f.bits[i] = b + i++ + } + } + + if !f.h1.init(f.bits[0:nlit]) || !f.h2.init(f.bits[nlit:nlit+ndist]) { + return CorruptInputError(f.roffset) + } + + // In order to preserve the property that we never read any extra bytes + // after the end of the DEFLATE stream, huffSym conservatively reads min + // bits at a time until it decodes the symbol. However, since every block + // must end with an EOB marker, we can use that as the minimum number of + // bits to read and guarantee we never read past the end of the stream. + if f.bits[endBlockMarker] > 0 { + f.h1.min = f.bits[endBlockMarker] // Length of EOB marker + } + + return nil +} + +// Decode a single Huffman block from f. +// hl and hd are the Huffman states for the lit/length values +// and the distance values, respectively. If hd == nil, using the +// fixed distance encoding associated with fixed Huffman blocks. +func (f *decompressor) huffmanBlock() { + for { + v, err := f.huffSym(f.hl) + if err != nil { + f.err = err + return + } + var n uint // number of bits extra + var length int + switch { + case v < 256: + f.hist[f.hp] = byte(v) + f.hp++ + if f.hp == len(f.hist) { + // After the flush, continue this loop. + f.flush((*decompressor).huffmanBlock) + return + } + continue + case v == 256: + // Done with huffman block; read next block. + f.step = (*decompressor).nextBlock + return + // otherwise, reference to older data + case v < 265: + length = v - (257 - 3) + n = 0 + case v < 269: + length = v*2 - (265*2 - 11) + n = 1 + case v < 273: + length = v*4 - (269*4 - 19) + n = 2 + case v < 277: + length = v*8 - (273*8 - 35) + n = 3 + case v < 281: + length = v*16 - (277*16 - 67) + n = 4 + case v < 285: + length = v*32 - (281*32 - 131) + n = 5 + case v < maxNumLit: + length = 258 + n = 0 + default: + f.err = CorruptInputError(f.roffset) + return + } + if n > 0 { + for f.nb < n { + if err = f.moreBits(); err != nil { + f.err = err + return + } + } + length += int(f.b & uint32(1<>= n + f.nb -= n + } + + var dist int + if f.hd == nil { + for f.nb < 5 { + if err = f.moreBits(); err != nil { + f.err = err + return + } + } + dist = int(reverseByte[(f.b&0x1F)<<3]) + f.b >>= 5 + f.nb -= 5 + } else { + if dist, err = f.huffSym(f.hd); err != nil { + f.err = err + return + } + } + + switch { + case dist < 4: + dist++ + case dist < maxNumDist: + nb := uint(dist-2) >> 1 + // have 1 bit in bottom of dist, need nb more. + extra := (dist & 1) << nb + for f.nb < nb { + if err = f.moreBits(); err != nil { + f.err = err + return + } + } + extra |= int(f.b & uint32(1<>= nb + f.nb -= nb + dist = 1<<(nb+1) + 1 + extra + default: + f.err = CorruptInputError(f.roffset) + return + } + + // Copy history[-dist:-dist+length] into output. + if dist > len(f.hist) { + f.err = InternalError("bad history distance") + return + } + + // No check on length; encoding can be prescient. + if !f.hfull && dist > f.hp { + f.err = CorruptInputError(f.roffset) + return + } + + f.copyLen, f.copyDist = length, dist + if f.copyHist() { + return + } + } +} + +// copyHist copies f.copyLen bytes from f.hist (f.copyDist bytes ago) to itself. +// It reports whether the f.hist buffer is full. +func (f *decompressor) copyHist() bool { + p := f.hp - f.copyDist + if p < 0 { + p += len(f.hist) + } + for f.copyLen > 0 { + n := f.copyLen + if x := len(f.hist) - f.hp; n > x { + n = x + } + if x := len(f.hist) - p; n > x { + n = x + } + forwardCopy(f.hist[:], f.hp, p, n) + p += n + f.hp += n + f.copyLen -= n + if f.hp == len(f.hist) { + // After flush continue copying out of history. + f.flush((*decompressor).copyHuff) + return true + } + if p == len(f.hist) { + p = 0 + } + } + return false +} + +func (f *decompressor) copyHuff() { + if f.copyHist() { + return + } + f.huffmanBlock() +} + +// Copy a single uncompressed data block from input to output. +func (f *decompressor) dataBlock() { + // Uncompressed. + // Discard current half-byte. + f.nb = 0 + f.b = 0 + + // Length then ones-complement of length. + nr, err := io.ReadFull(f.r, f.buf[0:4]) + f.roffset += int64(nr) + if err != nil { + f.err = &ReadError{f.roffset, err} + return + } + n := int(f.buf[0]) | int(f.buf[1])<<8 + nn := int(f.buf[2]) | int(f.buf[3])<<8 + if uint16(nn) != uint16(^n) { + f.err = CorruptInputError(f.roffset) + return + } + + if n == 0 { + // 0-length block means sync + f.flush((*decompressor).nextBlock) + return + } + + f.copyLen = n + f.copyData() +} + +// copyData copies f.copyLen bytes from the underlying reader into f.hist. +// It pauses for reads when f.hist is full. +func (f *decompressor) copyData() { + n := f.copyLen + for n > 0 { + m := len(f.hist) - f.hp + if m > n { + m = n + } + m, err := io.ReadFull(f.r, f.hist[f.hp:f.hp+m]) + f.roffset += int64(m) + if err != nil { + f.err = &ReadError{f.roffset, err} + return + } + n -= m + f.hp += m + if f.hp == len(f.hist) { + f.copyLen = n + f.flush((*decompressor).copyData) + return + } + } + f.step = (*decompressor).nextBlock +} + +func (f *decompressor) setDict(dict []byte) { + if len(dict) > len(f.hist) { + // Will only remember the tail. + dict = dict[len(dict)-len(f.hist):] + } + + f.hp = copy(f.hist[:], dict) + if f.hp == len(f.hist) { + f.hp = 0 + f.hfull = true + } + f.hw = f.hp +} + +func (f *decompressor) moreBits() error { + c, err := f.r.ReadByte() + if err != nil { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + return err + } + f.roffset++ + f.b |= uint32(c) << f.nb + f.nb += 8 + return nil +} + +// Read the next Huffman-encoded symbol from f according to h. +func (f *decompressor) huffSym(h *huffmanDecoder) (int, error) { + // Since a huffmanDecoder can be empty or be composed of a degenerate tree + // with single element, huffSym must error on these two edge cases. In both + // cases, the chunks slice will be 0 for the invalid sequence, leading it + // satisfy the n == 0 check below. + n := uint(h.min) + for { + for f.nb < n { + if err := f.moreBits(); err != nil { + return 0, err + } + } + chunk := h.chunks[f.b&(huffmanNumChunks-1)] + n = uint(chunk & huffmanCountMask) + if n > huffmanChunkBits { + chunk = h.links[chunk>>huffmanValueShift][(f.b>>huffmanChunkBits)&h.linkMask] + n = uint(chunk & huffmanCountMask) + } + if n <= f.nb { + if n == 0 { + f.err = CorruptInputError(f.roffset) + return 0, f.err + } + f.b >>= n + f.nb -= n + return int(chunk >> huffmanValueShift), nil + } + } +} + +// Flush any buffered output to the underlying writer. +func (f *decompressor) flush(step func(*decompressor)) { + f.toRead = f.hist[f.hw:f.hp] + f.woffset += int64(f.hp - f.hw) + f.hw = f.hp + if f.hp == len(f.hist) { + f.hp = 0 + f.hw = 0 + f.hfull = true + } + f.step = step +} + +func makeReader(r io.Reader) Reader { + if rr, ok := r.(Reader); ok { + return rr + } + return bufio.NewReader(r) +} + +func (f *decompressor) Reset(r io.Reader, dict []byte) error { + *f = decompressor{ + r: makeReader(r), + bits: f.bits, + codebits: f.codebits, + hist: f.hist, + step: (*decompressor).nextBlock, + } + if dict != nil { + f.setDict(dict) + } + return nil +} + +// NewReader returns a new ReadCloser that can be used +// to read the uncompressed version of r. +// If r does not also implement io.ByteReader, +// the decompressor may read more data than necessary from r. +// It is the caller's responsibility to call Close on the ReadCloser +// when finished reading. +// +// The ReadCloser returned by NewReader also implements Resetter. +func NewReader(r io.Reader) io.ReadCloser { + var f decompressor + f.bits = new([maxNumLit + maxNumDist]int) + f.codebits = new([numCodes]int) + f.r = makeReader(r) + f.hist = new([maxHist]byte) + f.step = (*decompressor).nextBlock + return &f +} + +// NewReaderDict is like NewReader but initializes the reader +// with a preset dictionary. The returned Reader behaves as if +// the uncompressed data stream started with the given dictionary, +// which has already been read. NewReaderDict is typically used +// to read data compressed by NewWriterDict. +// +// The ReadCloser returned by NewReader also implements Resetter. +func NewReaderDict(r io.Reader, dict []byte) io.ReadCloser { + var f decompressor + f.r = makeReader(r) + f.hist = new([maxHist]byte) + f.bits = new([maxNumLit + maxNumDist]int) + f.codebits = new([numCodes]int) + f.step = (*decompressor).nextBlock + f.setDict(dict) + return &f +} diff --git a/vendor/github.com/klauspost/compress/flate/reverse_bits.go b/vendor/github.com/klauspost/compress/flate/reverse_bits.go new file mode 100644 index 0000000000..c1a02720d1 --- /dev/null +++ b/vendor/github.com/klauspost/compress/flate/reverse_bits.go @@ -0,0 +1,48 @@ +// 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. + +package flate + +var reverseByte = [256]byte{ + 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, + 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, + 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, + 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, + 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, + 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, + 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, + 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, + 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, + 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, + 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, + 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, + 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, + 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, + 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, + 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, + 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, + 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, + 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, + 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, + 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, + 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, + 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, + 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, + 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, + 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, + 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, + 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, + 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, + 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, + 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, + 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, +} + +func reverseUint16(v uint16) uint16 { + return uint16(reverseByte[v>>8]) | uint16(reverseByte[v&0xFF])<<8 +} + +func reverseBits(number uint16, bitLength byte) uint16 { + return reverseUint16(number << uint8(16-bitLength)) +} diff --git a/vendor/github.com/klauspost/compress/flate/snappy.go b/vendor/github.com/klauspost/compress/flate/snappy.go new file mode 100644 index 0000000000..a7cbf351d0 --- /dev/null +++ b/vendor/github.com/klauspost/compress/flate/snappy.go @@ -0,0 +1,768 @@ +// Copyright 2011 The Snappy-Go Authors. All rights reserved. +// Modified for deflate by Klaus Post (c) 2015. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package flate + +// We limit how far copy back-references can go, the same as the C++ code. +const maxOffset = 1 << 15 + +// emitLiteral writes a literal chunk and returns the number of bytes written. +func emitLiteral(dst *tokens, lit []byte) { + ol := dst.n + for i, v := range lit { + dst.tokens[i+ol] = token(v) + } + dst.n += len(lit) +} + +// emitCopy writes a copy chunk and returns the number of bytes written. +func emitCopy(dst *tokens, offset, length int) { + dst.tokens[dst.n] = matchToken(uint32(length-3), uint32(offset-minOffsetSize)) + dst.n++ +} + +type snappyEnc interface { + Encode(dst *tokens, src []byte) + Reset() +} + +func newSnappy(level int) snappyEnc { + if useSSE42 { + e := &snappySSE4{} + switch level { + case 3: + e.enc = e.encodeL3 + return e + } + } + e := &snappyGen{} + switch level { + case 1: + e.enc = e.encodeL1 + case 2: + e.enc = e.encodeL2 + case 3: + e.enc = e.encodeL3 + default: + panic("invalid level specified") + } + return e +} + +const tableBits = 14 // Bits used in the table +const tableSize = 1 << tableBits // Size of the table + +// snappyGen maintains the table for matches, +// and the previous byte block for level 2. +// This is the generic implementation. +type snappyGen struct { + table [tableSize]int64 + block [maxStoreBlockSize]byte + prev []byte + cur int + enc func(dst *tokens, src []byte) +} + +func (e *snappyGen) Encode(dst *tokens, src []byte) { + e.enc(dst, src) +} + +// EncodeL1 uses Snappy-like compression, but stores as Huffman +// blocks. +func (e *snappyGen) encodeL1(dst *tokens, src []byte) { + // Return early if src is short. + if len(src) <= 4 { + if len(src) != 0 { + emitLiteral(dst, src) + } + e.cur += 4 + return + } + + // Ensure that e.cur doesn't wrap, mainly an issue on 32 bits. + if e.cur > 1<<30 { + e.cur = 0 + } + + // Iterate over the source bytes. + var ( + s int // The iterator position. + t int // The last position with the same hash as s. + lit int // The start position of any pending literal bytes. + ) + + for s+3 < len(src) { + // Update the hash table. + b0, b1, b2, b3 := src[s], src[s+1], src[s+2], src[s+3] + h := uint32(b0) | uint32(b1)<<8 | uint32(b2)<<16 | uint32(b3)<<24 + p := &e.table[(h*0x1e35a7bd)>>(32-tableBits)] + // We need to to store values in [-1, inf) in table. To save + // some initialization time, (re)use the table's zero value + // and shift the values against this zero: add 1 on writes, + // subtract 1 on reads. + t, *p = int(*p)-1-e.cur, int64(s+1+e.cur) + + offset := uint(s - t - 1) + + // If t is invalid or src[s:s+4] differs from src[t:t+4], accumulate a literal byte. + if t < 0 || offset >= (maxOffset-1) || b0 != src[t] || b1 != src[t+1] || b2 != src[t+2] || b3 != src[t+3] { + // Skip 1 byte for 16 consecutive missed. + s += 1 + ((s - lit) >> 4) + continue + } + // Otherwise, we have a match. First, emit any pending literal bytes. + if lit != s { + emitLiteral(dst, src[lit:s]) + } + // Extend the match to be as long as possible. + s0 := s + s1 := s + maxMatchLength + if s1 > len(src) { + s1 = len(src) + } + s, t = s+4, t+4 + for s < s1 && src[s] == src[t] { + s++ + t++ + } + // Emit the copied bytes. + // inlined: emitCopy(dst, s-t, s-s0) + + dst.tokens[dst.n] = matchToken(uint32(s-s0-3), uint32(s-t-minOffsetSize)) + dst.n++ + lit = s + } + + // Emit any final pending literal bytes and return. + if lit != len(src) { + emitLiteral(dst, src[lit:]) + } + e.cur += len(src) +} + +// EncodeL2 uses a similar algorithm to level 1, but is capable +// of matching across blocks giving better compression at a small slowdown. +func (e *snappyGen) encodeL2(dst *tokens, src []byte) { + // Return early if src is short. + if len(src) <= 4 { + if len(src) != 0 { + emitLiteral(dst, src) + } + e.prev = nil + e.cur += len(src) + return + } + + // Ensure that e.cur doesn't wrap, mainly an issue on 32 bits. + if e.cur > 1<<30 { + e.cur = 0 + } + + // Iterate over the source bytes. + var ( + s int // The iterator position. + t int // The last position with the same hash as s. + lit int // The start position of any pending literal bytes. + ) + + for s+3 < len(src) { + // Update the hash table. + b0, b1, b2, b3 := src[s], src[s+1], src[s+2], src[s+3] + h := uint32(b0) | uint32(b1)<<8 | uint32(b2)<<16 | uint32(b3)<<24 + p := &e.table[(h*0x1e35a7bd)>>(32-tableBits)] + // We need to to store values in [-1, inf) in table. To save + // some initialization time, (re)use the table's zero value + // and shift the values against this zero: add 1 on writes, + // subtract 1 on reads. + t, *p = int(*p)-1-e.cur, int64(s+1+e.cur) + + // If t is positive, the match starts in the current block + if t >= 0 { + + offset := uint(s - t - 1) + // Check that the offset is valid and that we match at least 4 bytes + if offset >= (maxOffset-1) || b0 != src[t] || b1 != src[t+1] || b2 != src[t+2] || b3 != src[t+3] { + // Skip 1 byte for 32 consecutive missed. + s += 1 + ((s - lit) >> 5) + continue + } + // Otherwise, we have a match. First, emit any pending literal bytes. + if lit != s { + emitLiteral(dst, src[lit:s]) + } + // Extend the match to be as long as possible. + s0 := s + s1 := s + maxMatchLength + if s1 > len(src) { + s1 = len(src) + } + s, t = s+4, t+4 + for s < s1 && src[s] == src[t] { + s++ + t++ + } + // Emit the copied bytes. + // inlined: emitCopy(dst, s-t, s-s0) + dst.tokens[dst.n] = matchToken(uint32(s-s0-3), uint32(s-t-minOffsetSize)) + dst.n++ + lit = s + continue + } + // We found a match in the previous block. + tp := len(e.prev) + t + if tp < 0 || t > -5 || s-t >= maxOffset || b0 != e.prev[tp] || b1 != e.prev[tp+1] || b2 != e.prev[tp+2] || b3 != e.prev[tp+3] { + // Skip 1 byte for 32 consecutive missed. + s += 1 + ((s - lit) >> 5) + continue + } + // Otherwise, we have a match. First, emit any pending literal bytes. + if lit != s { + emitLiteral(dst, src[lit:s]) + } + // Extend the match to be as long as possible. + s0 := s + s1 := s + maxMatchLength + if s1 > len(src) { + s1 = len(src) + } + s, tp = s+4, tp+4 + for s < s1 && src[s] == e.prev[tp] { + s++ + tp++ + if tp == len(e.prev) { + t = 0 + // continue in current buffer + for s < s1 && src[s] == src[t] { + s++ + t++ + } + goto l + } + } + l: + // Emit the copied bytes. + if t < 0 { + t = tp - len(e.prev) + } + dst.tokens[dst.n] = matchToken(uint32(s-s0-3), uint32(s-t-minOffsetSize)) + dst.n++ + lit = s + + } + + // Emit any final pending literal bytes and return. + if lit != len(src) { + emitLiteral(dst, src[lit:]) + } + e.cur += len(src) + // Store this block, if it was full length. + if len(src) == maxStoreBlockSize { + copy(e.block[:], src) + e.prev = e.block[:len(src)] + } else { + e.prev = nil + } +} + +// EncodeL3 uses a similar algorithm to level 2, but is capable +// will keep two matches per hash. +// Both hashes are checked if the first isn't ok, and the longest is selected. +func (e *snappyGen) encodeL3(dst *tokens, src []byte) { + // Return early if src is short. + if len(src) <= 4 { + if len(src) != 0 { + emitLiteral(dst, src) + } + e.prev = nil + e.cur += len(src) + return + } + + // Ensure that e.cur doesn't wrap, mainly an issue on 32 bits. + if e.cur > 1<<30 { + e.cur = 0 + } + + // Iterate over the source bytes. + var ( + s int // The iterator position. + lit int // The start position of any pending literal bytes. + ) + + for s+3 < len(src) { + // Update the hash table. + h := uint32(src[s]) | uint32(src[s+1])<<8 | uint32(src[s+2])<<16 | uint32(src[s+3])<<24 + p := &e.table[(h*0x1e35a7bd)>>(32-tableBits)] + tmp := *p + p1 := int(tmp & 0xffffffff) // Closest match position + p2 := int(tmp >> 32) // Furthest match position + + // We need to to store values in [-1, inf) in table. To save + // some initialization time, (re)use the table's zero value + // and shift the values against this zero: add 1 on writes, + // subtract 1 on reads. + t1 := p1 - 1 - e.cur + + var l2 int + var t2 int + l1 := e.matchlen(s, t1, src) + // If fist match was ok, don't do the second. + if l1 < 16 { + t2 = p2 - 1 - e.cur + l2 = e.matchlen(s, t2, src) + + // If both are short, continue + if l1 < 4 && l2 < 4 { + // Update hash table + *p = int64(s+1+e.cur) | (int64(p1) << 32) + // Skip 1 byte for 32 consecutive missed. + s += 1 + ((s - lit) >> 5) + continue + } + } + + // Otherwise, we have a match. First, emit any pending literal bytes. + if lit != s { + emitLiteral(dst, src[lit:s]) + } + // Update hash table + *p = int64(s+1+e.cur) | (int64(p1) << 32) + + // Store the longest match l1 will be closest, so we prefer that if equal length + if l1 >= l2 { + dst.tokens[dst.n] = matchToken(uint32(l1-3), uint32(s-t1-minOffsetSize)) + s += l1 + } else { + dst.tokens[dst.n] = matchToken(uint32(l2-3), uint32(s-t2-minOffsetSize)) + s += l2 + } + dst.n++ + lit = s + } + + // Emit any final pending literal bytes and return. + if lit != len(src) { + emitLiteral(dst, src[lit:]) + } + e.cur += len(src) + // Store this block, if it was full length. + if len(src) == maxStoreBlockSize { + copy(e.block[:], src) + e.prev = e.block[:len(src)] + } else { + e.prev = nil + } +} + +func (e *snappyGen) matchlen(s, t int, src []byte) int { + // If t is invalid or src[s:s+4] differs from src[t:t+4], accumulate a literal byte. + offset := uint(s - t - 1) + + // If we are inside the current block + if t >= 0 { + if offset >= (maxOffset-1) || + src[s] != src[t] || src[s+1] != src[t+1] || + src[s+2] != src[t+2] || src[s+3] != src[t+3] { + return 0 + } + // Extend the match to be as long as possible. + s0 := s + s1 := s + maxMatchLength + if s1 > len(src) { + s1 = len(src) + } + s, t = s+4, t+4 + for s < s1 && src[s] == src[t] { + s++ + t++ + } + return s - s0 + } + + // We found a match in the previous block. + tp := len(e.prev) + t + if tp < 0 || offset >= (maxOffset-1) || t > -5 || + src[s] != e.prev[tp] || src[s+1] != e.prev[tp+1] || + src[s+2] != e.prev[tp+2] || src[s+3] != e.prev[tp+3] { + return 0 + } + + // Extend the match to be as long as possible. + s0 := s + s1 := s + maxMatchLength + if s1 > len(src) { + s1 = len(src) + } + s, tp = s+4, tp+4 + for s < s1 && src[s] == e.prev[tp] { + s++ + tp++ + if tp == len(e.prev) { + t = 0 + // continue in current buffer + for s < s1 && src[s] == src[t] { + s++ + t++ + } + return s - s0 + } + } + return s - s0 +} + +// Reset the encoding table. +func (e *snappyGen) Reset() { + e.prev = nil +} + +// snappySSE4 extends snappyGen. +// This implementation can use SSE 4.2 for length matching. +type snappySSE4 struct { + snappyGen +} + +/* +// EncodeL1 uses Snappy-like compression, but stores as Huffman +// blocks. +func (e *snappySSE4) encodeL1(dst *tokens, src []byte) { + // Return early if src is short. + if len(src) <= 4 { + if len(src) != 0 { + emitLiteral(dst, src) + } + e.cur += 4 + return + } + + // Ensure that e.cur doesn't wrap, mainly an issue on 32 bits. + if e.cur > 1<<30 { + e.cur = 0 + } + + // Iterate over the source bytes. + var ( + s int // The iterator position. + t int // The last position with the same hash as s. + lit int // The start position of any pending literal bytes. + ) + + for s+3 < len(src) { + // Update the hash table. + h := uint32(src[s]) | uint32(src[s+1])<<8 | uint32(src[s+2])<<16 | uint32(src[s+3])<<24 + p := &e.table[(h*0x1e35a7bd)>>(32-tableBits)] + // We need to to store values in [-1, inf) in table. To save + // some initialization time, (re)use the table's zero value + // and shift the values against this zero: add 1 on writes, + // subtract 1 on reads. + t, *p = int(*p)-1-e.cur, int64(s+1+e.cur) + + offset := uint(s - t - 1) + + // If t is invalid or src[s:s+4] differs from src[t:t+4], accumulate a literal byte. + if t < 0 || offset >= (maxOffset-1) { + // Skip 1 byte for 16 consecutive missed. + s += 1 + ((s - lit) >> 4) + continue + } + + length := len(src) - s + if length > maxMatchLength { + length = maxMatchLength + } + // Extend the match to be as long as possible. + match := matchLenSSE4(src[t:], src[s:], length) + + // Return if short. + if match < 4 { + s += 1 + (s-lit)>>4 + continue + } + + // Otherwise, we have a match. First, emit any pending literal bytes. + if lit != s { + emitLiteral(dst, src[lit:s]) + } + + dst.tokens[dst.n] = matchToken(uint32(match-3), uint32(offset)) + dst.n++ + s += match + lit = s + } + + // Emit any final pending literal bytes and return. + if lit != len(src) { + emitLiteral(dst, src[lit:]) + } + e.cur += len(src) +} + +// EncodeL2 uses a similar algorithm to level 1, but is capable +// of matching across blocks giving better compression at a small slowdown. +func (e *snappySSE4) encodeL2(dst *tokens, src []byte) { + // Return early if src is short. + if len(src) <= 4 { + if len(src) != 0 { + emitLiteral(dst, src) + } + e.prev = nil + e.cur += len(src) + return + } + + // Ensure that e.cur doesn't wrap, mainly an issue on 32 bits. + if e.cur > 1<<30 { + e.cur = 0 + } + + // Iterate over the source bytes. + var ( + s int // The iterator position. + t int // The last position with the same hash as s. + lit int // The start position of any pending literal bytes. + ) + + for s+3 < len(src) { + // Update the hash table. + b0, b1, b2, b3 := src[s], src[s+1], src[s+2], src[s+3] + h := uint32(b0) | uint32(b1)<<8 | uint32(b2)<<16 | uint32(b3)<<24 + p := &e.table[(h*0x1e35a7bd)>>(32-tableBits)] + // We need to to store values in [-1, inf) in table. To save + // some initialization time, (re)use the table's zero value + // and shift the values against this zero: add 1 on writes, + // subtract 1 on reads. + t, *p = int(*p)-1-e.cur, int64(s+1+e.cur) + + // If t is positive, the match starts in the current block + if t >= 0 { + offset := uint(s - t - 1) + + // If t is invalid or src[s:s+4] differs from src[t:t+4], accumulate a literal byte. + if t < 0 || offset >= (maxOffset-1) { + // Skip 1 byte for 16 consecutive missed. + s += 1 + ((s - lit) >> 5) + continue + } + + length := maxMatchLength + if length > len(src)-s { + length = len(src) - s + } + // Extend the match to be as long as possible. + match := matchLenSSE4(src[t:], src[s:], length) + + // Return if short. + if match < 4 { + s += 1 + (s-lit)>>5 + continue + } + + // Otherwise, we have a match. First, emit any pending literal bytes. + if lit != s { + emitLiteral(dst, src[lit:s]) + } + + dst.tokens[dst.n] = matchToken(uint32(match-3), uint32(offset)) + s += match + dst.n++ + lit = s + continue + } + + // We found a match in the previous block. + tp := len(e.prev) + t + if tp < 0 || t > -5 || s-t >= maxOffset || b0 != e.prev[tp] || b1 != e.prev[tp+1] || b2 != e.prev[tp+2] || b3 != e.prev[tp+3] { + // Skip 1 byte for 32 consecutive missed. + s += 1 + ((s - lit) >> 5) + continue + } + // Otherwise, we have a match. First, emit any pending literal bytes. + if lit != s { + emitLiteral(dst, src[lit:s]) + } + // Extend the match to be as long as possible. + s0 := s + s1 := s + maxMatchLength + if s1 > len(src) { + s1 = len(src) + } + s, tp = s+4, tp+4 + for s < s1 && src[s] == e.prev[tp] { + s++ + tp++ + if tp == len(e.prev) { + t = 0 + // continue in current buffer + for s < s1 && src[s] == src[t] { + s++ + t++ + } + goto l + } + } + l: + // Emit the copied bytes. + // inlined: emitCopy(dst, s-t, s-s0) + if t < 0 { + t = tp - len(e.prev) + } + dst.tokens[dst.n] = matchToken(uint32(s-s0-3), uint32(s-t-minOffsetSize)) + dst.n++ + lit = s + continue + + } + + // Emit any final pending literal bytes and return. + if lit != len(src) { + emitLiteral(dst, src[lit:]) + } + e.cur += len(src) + // Store this block, if it was full length. + if len(src) == maxStoreBlockSize { + copy(e.block[:], src) + e.prev = e.block[:len(src)] + } else { + e.prev = nil + } +} +*/ + +// EncodeL3 uses a similar algorithm to level 2, +// but will keep two matches per hash. +// Both hashes are checked if the first isn't ok, and the longest is selected. +func (e *snappySSE4) encodeL3(dst *tokens, src []byte) { + // Return early if src is short. + if len(src) <= 4 { + if len(src) != 0 { + emitLiteral(dst, src) + } + e.prev = nil + e.cur += len(src) + return + } + + // Ensure that e.cur doesn't wrap, mainly an issue on 32 bits. + if e.cur > 1<<30 { + e.cur = 0 + } + + // Iterate over the source bytes. + var ( + s int // The iterator position. + lit int // The start position of any pending literal bytes. + ) + + for s+3 < len(src) { + // Load potential matches from hash table. + h := uint32(src[s]) | uint32(src[s+1])<<8 | uint32(src[s+2])<<16 | uint32(src[s+3])<<24 + p := &e.table[(h*0x1e35a7bd)>>(32-tableBits)] + tmp := *p + p1 := int(tmp & 0xffffffff) // Closest match position + p2 := int(tmp >> 32) // Furthest match position + + // We need to to store values in [-1, inf) in table. To save + // some initialization time, (re)use the table's zero value + // and shift the values against this zero: add 1 on writes, + // subtract 1 on reads. + t1 := int(p1) - 1 - e.cur + + var l2 int + var t2 int + l1 := e.matchlen(s, t1, src) + // If fist match was ok, don't do the second. + if l1 < 16 { + t2 = int(p2) - 1 - e.cur + l2 = e.matchlen(s, t2, src) + + // If both are short, continue + if l1 < 4 && l2 < 4 { + // Update hash table + *p = int64(s+1+e.cur) | (int64(p1) << 32) + // Skip 1 byte for 32 consecutive missed. + s += 1 + ((s - lit) >> 5) + continue + } + } + + // Otherwise, we have a match. First, emit any pending literal bytes. + if lit != s { + emitLiteral(dst, src[lit:s]) + } + // Update hash table + *p = int64(s+1+e.cur) | (int64(p1) << 32) + + // Store the longest match l1 will be closest, so we prefer that if equal length + if l1 >= l2 { + dst.tokens[dst.n] = matchToken(uint32(l1-3), uint32(s-t1-minOffsetSize)) + s += l1 + } else { + dst.tokens[dst.n] = matchToken(uint32(l2-3), uint32(s-t2-minOffsetSize)) + s += l2 + } + dst.n++ + lit = s + } + + // Emit any final pending literal bytes and return. + if lit != len(src) { + emitLiteral(dst, src[lit:]) + } + e.cur += len(src) + // Store this block, if it was full length. + if len(src) == maxStoreBlockSize { + copy(e.block[:], src) + e.prev = e.block[:len(src)] + } else { + e.prev = nil + } +} + +func (e *snappySSE4) matchlen(s, t int, src []byte) int { + // If t is invalid or src[s:s+4] differs from src[t:t+4], accumulate a literal byte. + offset := uint(s - t - 1) + + // If we are inside the current block + if t >= 0 { + if offset >= (maxOffset - 1) { + return 0 + } + length := len(src) - s + if length > maxMatchLength { + length = maxMatchLength + } + // Extend the match to be as long as possible. + return matchLenSSE4(src[t:], src[s:], length) + } + + // We found a match in the previous block. + tp := len(e.prev) + t + if tp < 0 || offset >= (maxOffset-1) || t > -5 || + src[s] != e.prev[tp] || src[s+1] != e.prev[tp+1] || + src[s+2] != e.prev[tp+2] || src[s+3] != e.prev[tp+3] { + return 0 + } + + // Extend the match to be as long as possible. + s0 := s + s1 := s + maxMatchLength + if s1 > len(src) { + s1 = len(src) + } + s, tp = s+4, tp+4 + for s < s1 && src[s] == e.prev[tp] { + s++ + tp++ + if tp == len(e.prev) { + t = 0 + // continue in current buffer + for s < s1 && src[s] == src[t] { + s++ + t++ + } + return s - s0 + } + } + return s - s0 +} diff --git a/vendor/github.com/klauspost/compress/flate/token.go b/vendor/github.com/klauspost/compress/flate/token.go new file mode 100644 index 0000000000..94fa5eb93a --- /dev/null +++ b/vendor/github.com/klauspost/compress/flate/token.go @@ -0,0 +1,105 @@ +// 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. + +package flate + +const ( + // 2 bits: type 0 = literal 1=EOF 2=Match 3=Unused + // 8 bits: xlength = length - MIN_MATCH_LENGTH + // 22 bits xoffset = offset - MIN_OFFSET_SIZE, or literal + lengthShift = 22 + offsetMask = 1< pair into a match token. +func matchToken(xlength uint32, xoffset uint32) token { + return token(matchType + xlength<> lengthShift) } + +func lengthCode(len uint32) uint32 { return lengthCodes[len] } + +// Returns the offset code corresponding to a specific offset +func offsetCode(off uint32) uint32 { + if off < uint32(len(offsetCodes)) { + return offsetCodes[off] + } else if off>>7 < uint32(len(offsetCodes)) { + return offsetCodes[off>>7] + 14 + } else { + return offsetCodes[off>>14] + 28 + } +} diff --git a/vendor/github.com/klauspost/cpuid/LICENSE b/vendor/github.com/klauspost/cpuid/LICENSE new file mode 100644 index 0000000000..5cec7ee949 --- /dev/null +++ b/vendor/github.com/klauspost/cpuid/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Klaus Post + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/vendor/github.com/klauspost/cpuid/cpuid.go b/vendor/github.com/klauspost/cpuid/cpuid.go new file mode 100644 index 0000000000..9230ca5628 --- /dev/null +++ b/vendor/github.com/klauspost/cpuid/cpuid.go @@ -0,0 +1,1022 @@ +// Copyright (c) 2015 Klaus Post, released under MIT License. See LICENSE file. + +// Package cpuid provides information about the CPU running the current program. +// +// CPU features are detected on startup, and kept for fast access through the life of the application. +// Currently x86 / x64 (AMD64) is supported. +// +// You can access the CPU information by accessing the shared CPU variable of the cpuid library. +// +// Package home: https://github.com/klauspost/cpuid +package cpuid + +import "strings" + +// Vendor is a representation of a CPU vendor. +type Vendor int + +const ( + Other Vendor = iota + Intel + AMD + VIA + Transmeta + NSC + KVM // Kernel-based Virtual Machine + MSVM // Microsoft Hyper-V or Windows Virtual PC + VMware + XenHVM +) + +const ( + CMOV = 1 << iota // i686 CMOV + NX // NX (No-Execute) bit + AMD3DNOW // AMD 3DNOW + AMD3DNOWEXT // AMD 3DNowExt + MMX // standard MMX + MMXEXT // SSE integer functions or AMD MMX ext + SSE // SSE functions + SSE2 // P4 SSE functions + SSE3 // Prescott SSE3 functions + SSSE3 // Conroe SSSE3 functions + SSE4 // Penryn SSE4.1 functions + SSE4A // AMD Barcelona microarchitecture SSE4a instructions + SSE42 // Nehalem SSE4.2 functions + AVX // AVX functions + AVX2 // AVX2 functions + FMA3 // Intel FMA 3 + FMA4 // Bulldozer FMA4 functions + XOP // Bulldozer XOP functions + F16C // Half-precision floating-point conversion + BMI1 // Bit Manipulation Instruction Set 1 + BMI2 // Bit Manipulation Instruction Set 2 + TBM // AMD Trailing Bit Manipulation + LZCNT // LZCNT instruction + POPCNT // POPCNT instruction + AESNI // Advanced Encryption Standard New Instructions + CLMUL // Carry-less Multiplication + HTT // Hyperthreading (enabled) + HLE // Hardware Lock Elision + RTM // Restricted Transactional Memory + RDRAND // RDRAND instruction is available + RDSEED // RDSEED instruction is available + ADX // Intel ADX (Multi-Precision Add-Carry Instruction Extensions) + SHA // Intel SHA Extensions + AVX512F // AVX-512 Foundation + AVX512DQ // AVX-512 Doubleword and Quadword Instructions + AVX512IFMA // AVX-512 Integer Fused Multiply-Add Instructions + AVX512PF // AVX-512 Prefetch Instructions + AVX512ER // AVX-512 Exponential and Reciprocal Instructions + AVX512CD // AVX-512 Conflict Detection Instructions + AVX512BW // AVX-512 Byte and Word Instructions + AVX512VL // AVX-512 Vector Length Extensions + AVX512VBMI // AVX-512 Vector Bit Manipulation Instructions + MPX // Intel MPX (Memory Protection Extensions) + ERMS // Enhanced REP MOVSB/STOSB + RDTSCP // RDTSCP Instruction + CX16 // CMPXCHG16B Instruction + SGX // Software Guard Extensions + + // Performance indicators + SSE2SLOW // SSE2 is supported, but usually not faster + SSE3SLOW // SSE3 is supported, but usually not faster + ATOM // Atom processor, some SSSE3 instructions are slower +) + +var flagNames = map[Flags]string{ + CMOV: "CMOV", // i686 CMOV + NX: "NX", // NX (No-Execute) bit + AMD3DNOW: "AMD3DNOW", // AMD 3DNOW + AMD3DNOWEXT: "AMD3DNOWEXT", // AMD 3DNowExt + MMX: "MMX", // Standard MMX + MMXEXT: "MMXEXT", // SSE integer functions or AMD MMX ext + SSE: "SSE", // SSE functions + SSE2: "SSE2", // P4 SSE2 functions + SSE3: "SSE3", // Prescott SSE3 functions + SSSE3: "SSSE3", // Conroe SSSE3 functions + SSE4: "SSE4.1", // Penryn SSE4.1 functions + SSE4A: "SSE4A", // AMD Barcelona microarchitecture SSE4a instructions + SSE42: "SSE4.2", // Nehalem SSE4.2 functions + AVX: "AVX", // AVX functions + AVX2: "AVX2", // AVX functions + FMA3: "FMA3", // Intel FMA 3 + FMA4: "FMA4", // Bulldozer FMA4 functions + XOP: "XOP", // Bulldozer XOP functions + F16C: "F16C", // Half-precision floating-point conversion + BMI1: "BMI1", // Bit Manipulation Instruction Set 1 + BMI2: "BMI2", // Bit Manipulation Instruction Set 2 + TBM: "TBM", // AMD Trailing Bit Manipulation + LZCNT: "LZCNT", // LZCNT instruction + POPCNT: "POPCNT", // POPCNT instruction + AESNI: "AESNI", // Advanced Encryption Standard New Instructions + CLMUL: "CLMUL", // Carry-less Multiplication + HTT: "HTT", // Hyperthreading (enabled) + HLE: "HLE", // Hardware Lock Elision + RTM: "RTM", // Restricted Transactional Memory + RDRAND: "RDRAND", // RDRAND instruction is available + RDSEED: "RDSEED", // RDSEED instruction is available + ADX: "ADX", // Intel ADX (Multi-Precision Add-Carry Instruction Extensions) + SHA: "SHA", // Intel SHA Extensions + AVX512F: "AVX512F", // AVX-512 Foundation + AVX512DQ: "AVX512DQ", // AVX-512 Doubleword and Quadword Instructions + AVX512IFMA: "AVX512IFMA", // AVX-512 Integer Fused Multiply-Add Instructions + AVX512PF: "AVX512PF", // AVX-512 Prefetch Instructions + AVX512ER: "AVX512ER", // AVX-512 Exponential and Reciprocal Instructions + AVX512CD: "AVX512CD", // AVX-512 Conflict Detection Instructions + AVX512BW: "AVX512BW", // AVX-512 Byte and Word Instructions + AVX512VL: "AVX512VL", // AVX-512 Vector Length Extensions + AVX512VBMI: "AVX512VBMI", // AVX-512 Vector Bit Manipulation Instructions + MPX: "MPX", // Intel MPX (Memory Protection Extensions) + ERMS: "ERMS", // Enhanced REP MOVSB/STOSB + RDTSCP: "RDTSCP", // RDTSCP Instruction + CX16: "CX16", // CMPXCHG16B Instruction + SGX: "SGX", // Software Guard Extensions + + // Performance indicators + SSE2SLOW: "SSE2SLOW", // SSE2 supported, but usually not faster + SSE3SLOW: "SSE3SLOW", // SSE3 supported, but usually not faster + ATOM: "ATOM", // Atom processor, some SSSE3 instructions are slower + +} + +// CPUInfo contains information about the detected system CPU. +type CPUInfo struct { + BrandName string // Brand name reported by the CPU + VendorID Vendor // Comparable CPU vendor ID + Features Flags // Features of the CPU + PhysicalCores int // Number of physical processor cores in your CPU. Will be 0 if undetectable. + ThreadsPerCore int // Number of threads per physical core. Will be 1 if undetectable. + LogicalCores int // Number of physical cores times threads that can run on each core through the use of hyperthreading. Will be 0 if undetectable. + Family int // CPU family number + Model int // CPU model number + CacheLine int // Cache line size in bytes. Will be 0 if undetectable. + Cache struct { + L1I int // L1 Instruction Cache (per core or shared). Will be -1 if undetected + L1D int // L1 Data Cache (per core or shared). Will be -1 if undetected + L2 int // L2 Cache (per core or shared). Will be -1 if undetected + L3 int // L3 Instruction Cache (per core or shared). Will be -1 if undetected + } + SGX SGXSupport + maxFunc uint32 + maxExFunc uint32 +} + +var cpuid func(op uint32) (eax, ebx, ecx, edx uint32) +var cpuidex func(op, op2 uint32) (eax, ebx, ecx, edx uint32) +var xgetbv func(index uint32) (eax, edx uint32) +var rdtscpAsm func() (eax, ebx, ecx, edx uint32) + +// CPU contains information about the CPU as detected on startup, +// or when Detect last was called. +// +// Use this as the primary entry point to you data, +// this way queries are +var CPU CPUInfo + +func init() { + initCPU() + Detect() +} + +// Detect will re-detect current CPU info. +// This will replace the content of the exported CPU variable. +// +// Unless you expect the CPU to change while you are running your program +// you should not need to call this function. +// If you call this, you must ensure that no other goroutine is accessing the +// exported CPU variable. +func Detect() { + CPU.maxFunc = maxFunctionID() + CPU.maxExFunc = maxExtendedFunction() + CPU.BrandName = brandName() + CPU.CacheLine = cacheLine() + CPU.Family, CPU.Model = familyModel() + CPU.Features = support() + CPU.SGX = sgx(CPU.Features&SGX != 0) + CPU.ThreadsPerCore = threadsPerCore() + CPU.LogicalCores = logicalCores() + CPU.PhysicalCores = physicalCores() + CPU.VendorID = vendorID() + CPU.cacheSize() +} + +// Generated here: http://play.golang.org/p/BxFH2Gdc0G + +// Cmov indicates support of CMOV instructions +func (c CPUInfo) Cmov() bool { + return c.Features&CMOV != 0 +} + +// Amd3dnow indicates support of AMD 3DNOW! instructions +func (c CPUInfo) Amd3dnow() bool { + return c.Features&AMD3DNOW != 0 +} + +// Amd3dnowExt indicates support of AMD 3DNOW! Extended instructions +func (c CPUInfo) Amd3dnowExt() bool { + return c.Features&AMD3DNOWEXT != 0 +} + +// MMX indicates support of MMX instructions +func (c CPUInfo) MMX() bool { + return c.Features&MMX != 0 +} + +// MMXExt indicates support of MMXEXT instructions +// (SSE integer functions or AMD MMX ext) +func (c CPUInfo) MMXExt() bool { + return c.Features&MMXEXT != 0 +} + +// SSE indicates support of SSE instructions +func (c CPUInfo) SSE() bool { + return c.Features&SSE != 0 +} + +// SSE2 indicates support of SSE 2 instructions +func (c CPUInfo) SSE2() bool { + return c.Features&SSE2 != 0 +} + +// SSE3 indicates support of SSE 3 instructions +func (c CPUInfo) SSE3() bool { + return c.Features&SSE3 != 0 +} + +// SSSE3 indicates support of SSSE 3 instructions +func (c CPUInfo) SSSE3() bool { + return c.Features&SSSE3 != 0 +} + +// SSE4 indicates support of SSE 4 (also called SSE 4.1) instructions +func (c CPUInfo) SSE4() bool { + return c.Features&SSE4 != 0 +} + +// SSE42 indicates support of SSE4.2 instructions +func (c CPUInfo) SSE42() bool { + return c.Features&SSE42 != 0 +} + +// AVX indicates support of AVX instructions +// and operating system support of AVX instructions +func (c CPUInfo) AVX() bool { + return c.Features&AVX != 0 +} + +// AVX2 indicates support of AVX2 instructions +func (c CPUInfo) AVX2() bool { + return c.Features&AVX2 != 0 +} + +// FMA3 indicates support of FMA3 instructions +func (c CPUInfo) FMA3() bool { + return c.Features&FMA3 != 0 +} + +// FMA4 indicates support of FMA4 instructions +func (c CPUInfo) FMA4() bool { + return c.Features&FMA4 != 0 +} + +// XOP indicates support of XOP instructions +func (c CPUInfo) XOP() bool { + return c.Features&XOP != 0 +} + +// F16C indicates support of F16C instructions +func (c CPUInfo) F16C() bool { + return c.Features&F16C != 0 +} + +// BMI1 indicates support of BMI1 instructions +func (c CPUInfo) BMI1() bool { + return c.Features&BMI1 != 0 +} + +// BMI2 indicates support of BMI2 instructions +func (c CPUInfo) BMI2() bool { + return c.Features&BMI2 != 0 +} + +// TBM indicates support of TBM instructions +// (AMD Trailing Bit Manipulation) +func (c CPUInfo) TBM() bool { + return c.Features&TBM != 0 +} + +// Lzcnt indicates support of LZCNT instruction +func (c CPUInfo) Lzcnt() bool { + return c.Features&LZCNT != 0 +} + +// Popcnt indicates support of POPCNT instruction +func (c CPUInfo) Popcnt() bool { + return c.Features&POPCNT != 0 +} + +// HTT indicates the processor has Hyperthreading enabled +func (c CPUInfo) HTT() bool { + return c.Features&HTT != 0 +} + +// SSE2Slow indicates that SSE2 may be slow on this processor +func (c CPUInfo) SSE2Slow() bool { + return c.Features&SSE2SLOW != 0 +} + +// SSE3Slow indicates that SSE3 may be slow on this processor +func (c CPUInfo) SSE3Slow() bool { + return c.Features&SSE3SLOW != 0 +} + +// AesNi indicates support of AES-NI instructions +// (Advanced Encryption Standard New Instructions) +func (c CPUInfo) AesNi() bool { + return c.Features&AESNI != 0 +} + +// Clmul indicates support of CLMUL instructions +// (Carry-less Multiplication) +func (c CPUInfo) Clmul() bool { + return c.Features&CLMUL != 0 +} + +// NX indicates support of NX (No-Execute) bit +func (c CPUInfo) NX() bool { + return c.Features&NX != 0 +} + +// SSE4A indicates support of AMD Barcelona microarchitecture SSE4a instructions +func (c CPUInfo) SSE4A() bool { + return c.Features&SSE4A != 0 +} + +// HLE indicates support of Hardware Lock Elision +func (c CPUInfo) HLE() bool { + return c.Features&HLE != 0 +} + +// RTM indicates support of Restricted Transactional Memory +func (c CPUInfo) RTM() bool { + return c.Features&RTM != 0 +} + +// Rdrand indicates support of RDRAND instruction is available +func (c CPUInfo) Rdrand() bool { + return c.Features&RDRAND != 0 +} + +// Rdseed indicates support of RDSEED instruction is available +func (c CPUInfo) Rdseed() bool { + return c.Features&RDSEED != 0 +} + +// ADX indicates support of Intel ADX (Multi-Precision Add-Carry Instruction Extensions) +func (c CPUInfo) ADX() bool { + return c.Features&ADX != 0 +} + +// SHA indicates support of Intel SHA Extensions +func (c CPUInfo) SHA() bool { + return c.Features&SHA != 0 +} + +// AVX512F indicates support of AVX-512 Foundation +func (c CPUInfo) AVX512F() bool { + return c.Features&AVX512F != 0 +} + +// AVX512DQ indicates support of AVX-512 Doubleword and Quadword Instructions +func (c CPUInfo) AVX512DQ() bool { + return c.Features&AVX512DQ != 0 +} + +// AVX512IFMA indicates support of AVX-512 Integer Fused Multiply-Add Instructions +func (c CPUInfo) AVX512IFMA() bool { + return c.Features&AVX512IFMA != 0 +} + +// AVX512PF indicates support of AVX-512 Prefetch Instructions +func (c CPUInfo) AVX512PF() bool { + return c.Features&AVX512PF != 0 +} + +// AVX512ER indicates support of AVX-512 Exponential and Reciprocal Instructions +func (c CPUInfo) AVX512ER() bool { + return c.Features&AVX512ER != 0 +} + +// AVX512CD indicates support of AVX-512 Conflict Detection Instructions +func (c CPUInfo) AVX512CD() bool { + return c.Features&AVX512CD != 0 +} + +// AVX512BW indicates support of AVX-512 Byte and Word Instructions +func (c CPUInfo) AVX512BW() bool { + return c.Features&AVX512BW != 0 +} + +// AVX512VL indicates support of AVX-512 Vector Length Extensions +func (c CPUInfo) AVX512VL() bool { + return c.Features&AVX512VL != 0 +} + +// AVX512VBMI indicates support of AVX-512 Vector Bit Manipulation Instructions +func (c CPUInfo) AVX512VBMI() bool { + return c.Features&AVX512VBMI != 0 +} + +// MPX indicates support of Intel MPX (Memory Protection Extensions) +func (c CPUInfo) MPX() bool { + return c.Features&MPX != 0 +} + +// ERMS indicates support of Enhanced REP MOVSB/STOSB +func (c CPUInfo) ERMS() bool { + return c.Features&ERMS != 0 +} + +func (c CPUInfo) RDTSCP() bool { + return c.Features&RDTSCP != 0 +} + +func (c CPUInfo) CX16() bool { + return c.Features&CX16 != 0 +} + +// Atom indicates an Atom processor +func (c CPUInfo) Atom() bool { + return c.Features&ATOM != 0 +} + +// Intel returns true if vendor is recognized as Intel +func (c CPUInfo) Intel() bool { + return c.VendorID == Intel +} + +// AMD returns true if vendor is recognized as AMD +func (c CPUInfo) AMD() bool { + return c.VendorID == AMD +} + +// Transmeta returns true if vendor is recognized as Transmeta +func (c CPUInfo) Transmeta() bool { + return c.VendorID == Transmeta +} + +// NSC returns true if vendor is recognized as National Semiconductor +func (c CPUInfo) NSC() bool { + return c.VendorID == NSC +} + +// VIA returns true if vendor is recognized as VIA +func (c CPUInfo) VIA() bool { + return c.VendorID == VIA +} + +// RTCounter returns the 64-bit time-stamp counter +// Uses the RDTSCP instruction. The value 0 is returned +// if the CPU does not support the instruction. +func (c CPUInfo) RTCounter() uint64 { + if !c.RDTSCP() { + return 0 + } + a, _, _, d := rdtscpAsm() + return uint64(a) | (uint64(d) << 32) +} + +// Ia32TscAux returns the IA32_TSC_AUX part of the RDTSCP. +// This variable is OS dependent, but on Linux contains information +// about the current cpu/core the code is running on. +// If the RDTSCP instruction isn't supported on the CPU, the value 0 is returned. +func (c CPUInfo) Ia32TscAux() uint32 { + if !c.RDTSCP() { + return 0 + } + _, _, ecx, _ := rdtscpAsm() + return ecx +} + +// LogicalCPU will return the Logical CPU the code is currently executing on. +// This is likely to change when the OS re-schedules the running thread +// to another CPU. +// If the current core cannot be detected, -1 will be returned. +func (c CPUInfo) LogicalCPU() int { + if c.maxFunc < 1 { + return -1 + } + _, ebx, _, _ := cpuid(1) + return int(ebx >> 24) +} + +// VM Will return true if the cpu id indicates we are in +// a virtual machine. This is only a hint, and will very likely +// have many false negatives. +func (c CPUInfo) VM() bool { + switch c.VendorID { + case MSVM, KVM, VMware, XenHVM: + return true + } + return false +} + +// Flags contains detected cpu features and caracteristics +type Flags uint64 + +// String returns a string representation of the detected +// CPU features. +func (f Flags) String() string { + return strings.Join(f.Strings(), ",") +} + +// Strings returns and array of the detected features. +func (f Flags) Strings() []string { + s := support() + r := make([]string, 0, 20) + for i := uint(0); i < 64; i++ { + key := Flags(1 << i) + val := flagNames[key] + if s&key != 0 { + r = append(r, val) + } + } + return r +} + +func maxExtendedFunction() uint32 { + eax, _, _, _ := cpuid(0x80000000) + return eax +} + +func maxFunctionID() uint32 { + a, _, _, _ := cpuid(0) + return a +} + +func brandName() string { + if maxExtendedFunction() >= 0x80000004 { + v := make([]uint32, 0, 48) + for i := uint32(0); i < 3; i++ { + a, b, c, d := cpuid(0x80000002 + i) + v = append(v, a, b, c, d) + } + return strings.Trim(string(valAsString(v...)), " ") + } + return "unknown" +} + +func threadsPerCore() int { + mfi := maxFunctionID() + if mfi < 0x4 || vendorID() != Intel { + return 1 + } + + if mfi < 0xb { + _, b, _, d := cpuid(1) + if (d & (1 << 28)) != 0 { + // v will contain logical core count + v := (b >> 16) & 255 + if v > 1 { + a4, _, _, _ := cpuid(4) + // physical cores + v2 := (a4 >> 26) + 1 + if v2 > 0 { + return int(v) / int(v2) + } + } + } + return 1 + } + _, b, _, _ := cpuidex(0xb, 0) + if b&0xffff == 0 { + return 1 + } + return int(b & 0xffff) +} + +func logicalCores() int { + mfi := maxFunctionID() + switch vendorID() { + case Intel: + // Use this on old Intel processors + if mfi < 0xb { + if mfi < 1 { + return 0 + } + // CPUID.1:EBX[23:16] represents the maximum number of addressable IDs (initial APIC ID) + // that can be assigned to logical processors in a physical package. + // The value may not be the same as the number of logical processors that are present in the hardware of a physical package. + _, ebx, _, _ := cpuid(1) + logical := (ebx >> 16) & 0xff + return int(logical) + } + _, b, _, _ := cpuidex(0xb, 1) + return int(b & 0xffff) + case AMD: + _, b, _, _ := cpuid(1) + return int((b >> 16) & 0xff) + default: + return 0 + } +} + +func familyModel() (int, int) { + if maxFunctionID() < 0x1 { + return 0, 0 + } + eax, _, _, _ := cpuid(1) + family := ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff) + model := ((eax >> 4) & 0xf) + ((eax >> 12) & 0xf0) + return int(family), int(model) +} + +func physicalCores() int { + switch vendorID() { + case Intel: + return logicalCores() / threadsPerCore() + case AMD: + if maxExtendedFunction() >= 0x80000008 { + _, _, c, _ := cpuid(0x80000008) + return int(c&0xff) + 1 + } + } + return 0 +} + +// Except from http://en.wikipedia.org/wiki/CPUID#EAX.3D0:_Get_vendor_ID +var vendorMapping = map[string]Vendor{ + "AMDisbetter!": AMD, + "AuthenticAMD": AMD, + "CentaurHauls": VIA, + "GenuineIntel": Intel, + "TransmetaCPU": Transmeta, + "GenuineTMx86": Transmeta, + "Geode by NSC": NSC, + "VIA VIA VIA ": VIA, + "KVMKVMKVMKVM": KVM, + "Microsoft Hv": MSVM, + "VMwareVMware": VMware, + "XenVMMXenVMM": XenHVM, +} + +func vendorID() Vendor { + _, b, c, d := cpuid(0) + v := valAsString(b, d, c) + vend, ok := vendorMapping[string(v)] + if !ok { + return Other + } + return vend +} + +func cacheLine() int { + if maxFunctionID() < 0x1 { + return 0 + } + + _, ebx, _, _ := cpuid(1) + cache := (ebx & 0xff00) >> 5 // cflush size + if cache == 0 && maxExtendedFunction() >= 0x80000006 { + _, _, ecx, _ := cpuid(0x80000006) + cache = ecx & 0xff // cacheline size + } + // TODO: Read from Cache and TLB Information + return int(cache) +} + +func (c *CPUInfo) cacheSize() { + c.Cache.L1D = -1 + c.Cache.L1I = -1 + c.Cache.L2 = -1 + c.Cache.L3 = -1 + vendor := vendorID() + switch vendor { + case Intel: + if maxFunctionID() < 4 { + return + } + for i := uint32(0); ; i++ { + eax, ebx, ecx, _ := cpuidex(4, i) + cacheType := eax & 15 + if cacheType == 0 { + break + } + cacheLevel := (eax >> 5) & 7 + coherency := int(ebx&0xfff) + 1 + partitions := int((ebx>>12)&0x3ff) + 1 + associativity := int((ebx>>22)&0x3ff) + 1 + sets := int(ecx) + 1 + size := associativity * partitions * coherency * sets + switch cacheLevel { + case 1: + if cacheType == 1 { + // 1 = Data Cache + c.Cache.L1D = size + } else if cacheType == 2 { + // 2 = Instruction Cache + c.Cache.L1I = size + } else { + if c.Cache.L1D < 0 { + c.Cache.L1I = size + } + if c.Cache.L1I < 0 { + c.Cache.L1I = size + } + } + case 2: + c.Cache.L2 = size + case 3: + c.Cache.L3 = size + } + } + case AMD: + // Untested. + if maxExtendedFunction() < 0x80000005 { + return + } + _, _, ecx, edx := cpuid(0x80000005) + c.Cache.L1D = int(((ecx >> 24) & 0xFF) * 1024) + c.Cache.L1I = int(((edx >> 24) & 0xFF) * 1024) + + if maxExtendedFunction() < 0x80000006 { + return + } + _, _, ecx, _ = cpuid(0x80000006) + c.Cache.L2 = int(((ecx >> 16) & 0xFFFF) * 1024) + } + + return +} + +type SGXSupport struct { + Available bool + SGX1Supported bool + SGX2Supported bool + MaxEnclaveSizeNot64 int64 + MaxEnclaveSize64 int64 +} + +func sgx(available bool) (rval SGXSupport) { + rval.Available = available + + if !available { + return + } + + a, _, _, d := cpuidex(0x12, 0) + rval.SGX1Supported = a&0x01 != 0 + rval.SGX2Supported = a&0x02 != 0 + rval.MaxEnclaveSizeNot64 = 1 << (d & 0xFF) // pow 2 + rval.MaxEnclaveSize64 = 1 << ((d >> 8) & 0xFF) // pow 2 + + return +} + +func support() Flags { + mfi := maxFunctionID() + vend := vendorID() + if mfi < 0x1 { + return 0 + } + rval := uint64(0) + _, _, c, d := cpuid(1) + if (d & (1 << 15)) != 0 { + rval |= CMOV + } + if (d & (1 << 23)) != 0 { + rval |= MMX + } + if (d & (1 << 25)) != 0 { + rval |= MMXEXT + } + if (d & (1 << 25)) != 0 { + rval |= SSE + } + if (d & (1 << 26)) != 0 { + rval |= SSE2 + } + if (c & 1) != 0 { + rval |= SSE3 + } + if (c & 0x00000200) != 0 { + rval |= SSSE3 + } + if (c & 0x00080000) != 0 { + rval |= SSE4 + } + if (c & 0x00100000) != 0 { + rval |= SSE42 + } + if (c & (1 << 25)) != 0 { + rval |= AESNI + } + if (c & (1 << 1)) != 0 { + rval |= CLMUL + } + if c&(1<<23) != 0 { + rval |= POPCNT + } + if c&(1<<30) != 0 { + rval |= RDRAND + } + if c&(1<<29) != 0 { + rval |= F16C + } + if c&(1<<13) != 0 { + rval |= CX16 + } + if vend == Intel && (d&(1<<28)) != 0 && mfi >= 4 { + if threadsPerCore() > 1 { + rval |= HTT + } + } + + // Check XGETBV, OXSAVE and AVX bits + if c&(1<<26) != 0 && c&(1<<27) != 0 && c&(1<<28) != 0 { + // Check for OS support + eax, _ := xgetbv(0) + if (eax & 0x6) == 0x6 { + rval |= AVX + if (c & 0x00001000) != 0 { + rval |= FMA3 + } + } + } + + // Check AVX2, AVX2 requires OS support, but BMI1/2 don't. + if mfi >= 7 { + _, ebx, ecx, _ := cpuidex(7, 0) + if (rval&AVX) != 0 && (ebx&0x00000020) != 0 { + rval |= AVX2 + } + if (ebx & 0x00000008) != 0 { + rval |= BMI1 + if (ebx & 0x00000100) != 0 { + rval |= BMI2 + } + } + if ebx&(1<<2) != 0 { + rval |= SGX + } + if ebx&(1<<4) != 0 { + rval |= HLE + } + if ebx&(1<<9) != 0 { + rval |= ERMS + } + if ebx&(1<<11) != 0 { + rval |= RTM + } + if ebx&(1<<14) != 0 { + rval |= MPX + } + if ebx&(1<<18) != 0 { + rval |= RDSEED + } + if ebx&(1<<19) != 0 { + rval |= ADX + } + if ebx&(1<<29) != 0 { + rval |= SHA + } + + // Only detect AVX-512 features if XGETBV is supported + if c&((1<<26)|(1<<27)) == (1<<26)|(1<<27) { + // Check for OS support + eax, _ := xgetbv(0) + + // Verify that XCR0[7:5] = ‘111b’ (OPMASK state, upper 256-bit of ZMM0-ZMM15 and + // ZMM16-ZMM31 state are enabled by OS) + /// and that XCR0[2:1] = ‘11b’ (XMM state and YMM state are enabled by OS). + if (eax>>5)&7 == 7 && (eax>>1)&3 == 3 { + if ebx&(1<<16) != 0 { + rval |= AVX512F + } + if ebx&(1<<17) != 0 { + rval |= AVX512DQ + } + if ebx&(1<<21) != 0 { + rval |= AVX512IFMA + } + if ebx&(1<<26) != 0 { + rval |= AVX512PF + } + if ebx&(1<<27) != 0 { + rval |= AVX512ER + } + if ebx&(1<<28) != 0 { + rval |= AVX512CD + } + if ebx&(1<<30) != 0 { + rval |= AVX512BW + } + if ebx&(1<<31) != 0 { + rval |= AVX512VL + } + // ecx + if ecx&(1<<1) != 0 { + rval |= AVX512VBMI + } + } + } + } + + if maxExtendedFunction() >= 0x80000001 { + _, _, c, d := cpuid(0x80000001) + if (c & (1 << 5)) != 0 { + rval |= LZCNT + rval |= POPCNT + } + if (d & (1 << 31)) != 0 { + rval |= AMD3DNOW + } + if (d & (1 << 30)) != 0 { + rval |= AMD3DNOWEXT + } + if (d & (1 << 23)) != 0 { + rval |= MMX + } + if (d & (1 << 22)) != 0 { + rval |= MMXEXT + } + if (c & (1 << 6)) != 0 { + rval |= SSE4A + } + if d&(1<<20) != 0 { + rval |= NX + } + if d&(1<<27) != 0 { + rval |= RDTSCP + } + + /* Allow for selectively disabling SSE2 functions on AMD processors + with SSE2 support but not SSE4a. This includes Athlon64, some + Opteron, and some Sempron processors. MMX, SSE, or 3DNow! are faster + than SSE2 often enough to utilize this special-case flag. + AV_CPU_FLAG_SSE2 and AV_CPU_FLAG_SSE2SLOW are both set in this case + so that SSE2 is used unless explicitly disabled by checking + AV_CPU_FLAG_SSE2SLOW. */ + if vendorID() != Intel && + rval&SSE2 != 0 && (c&0x00000040) == 0 { + rval |= SSE2SLOW + } + + /* XOP and FMA4 use the AVX instruction coding scheme, so they can't be + * used unless the OS has AVX support. */ + if (rval & AVX) != 0 { + if (c & 0x00000800) != 0 { + rval |= XOP + } + if (c & 0x00010000) != 0 { + rval |= FMA4 + } + } + + if vendorID() == Intel { + family, model := familyModel() + if family == 6 && (model == 9 || model == 13 || model == 14) { + /* 6/9 (pentium-m "banias"), 6/13 (pentium-m "dothan"), and + * 6/14 (core1 "yonah") theoretically support sse2, but it's + * usually slower than mmx. */ + if (rval & SSE2) != 0 { + rval |= SSE2SLOW + } + if (rval & SSE3) != 0 { + rval |= SSE3SLOW + } + } + /* The Atom processor has SSSE3 support, which is useful in many cases, + * but sometimes the SSSE3 version is slower than the SSE2 equivalent + * on the Atom, but is generally faster on other processors supporting + * SSSE3. This flag allows for selectively disabling certain SSSE3 + * functions on the Atom. */ + if family == 6 && model == 28 { + rval |= ATOM + } + } + } + return Flags(rval) +} + +func valAsString(values ...uint32) []byte { + r := make([]byte, 4*len(values)) + for i, v := range values { + dst := r[i*4:] + dst[0] = byte(v & 0xff) + dst[1] = byte((v >> 8) & 0xff) + dst[2] = byte((v >> 16) & 0xff) + dst[3] = byte((v >> 24) & 0xff) + switch { + case dst[0] == 0: + return r[:i*4] + case dst[1] == 0: + return r[:i*4+1] + case dst[2] == 0: + return r[:i*4+2] + case dst[3] == 0: + return r[:i*4+3] + } + } + return r +} diff --git a/vendor/github.com/klauspost/cpuid/cpuid_386.s b/vendor/github.com/klauspost/cpuid/cpuid_386.s new file mode 100644 index 0000000000..4d731711e4 --- /dev/null +++ b/vendor/github.com/klauspost/cpuid/cpuid_386.s @@ -0,0 +1,42 @@ +// Copyright (c) 2015 Klaus Post, released under MIT License. See LICENSE file. + +// +build 386,!gccgo + +// func asmCpuid(op uint32) (eax, ebx, ecx, edx uint32) +TEXT ·asmCpuid(SB), 7, $0 + XORL CX, CX + MOVL op+0(FP), AX + CPUID + MOVL AX, eax+4(FP) + MOVL BX, ebx+8(FP) + MOVL CX, ecx+12(FP) + MOVL DX, edx+16(FP) + RET + +// func asmCpuidex(op, op2 uint32) (eax, ebx, ecx, edx uint32) +TEXT ·asmCpuidex(SB), 7, $0 + MOVL op+0(FP), AX + MOVL op2+4(FP), CX + CPUID + MOVL AX, eax+8(FP) + MOVL BX, ebx+12(FP) + MOVL CX, ecx+16(FP) + MOVL DX, edx+20(FP) + RET + +// func xgetbv(index uint32) (eax, edx uint32) +TEXT ·asmXgetbv(SB), 7, $0 + MOVL index+0(FP), CX + BYTE $0x0f; BYTE $0x01; BYTE $0xd0 // XGETBV + MOVL AX, eax+4(FP) + MOVL DX, edx+8(FP) + RET + +// func asmRdtscpAsm() (eax, ebx, ecx, edx uint32) +TEXT ·asmRdtscpAsm(SB), 7, $0 + BYTE $0x0F; BYTE $0x01; BYTE $0xF9 // RDTSCP + MOVL AX, eax+0(FP) + MOVL BX, ebx+4(FP) + MOVL CX, ecx+8(FP) + MOVL DX, edx+12(FP) + RET diff --git a/vendor/github.com/klauspost/cpuid/cpuid_amd64.s b/vendor/github.com/klauspost/cpuid/cpuid_amd64.s new file mode 100644 index 0000000000..3c1d60e422 --- /dev/null +++ b/vendor/github.com/klauspost/cpuid/cpuid_amd64.s @@ -0,0 +1,42 @@ +// Copyright (c) 2015 Klaus Post, released under MIT License. See LICENSE file. + +//+build amd64,!gccgo + +// func asmCpuid(op uint32) (eax, ebx, ecx, edx uint32) +TEXT ·asmCpuid(SB), 7, $0 + XORQ CX, CX + MOVL op+0(FP), AX + CPUID + MOVL AX, eax+8(FP) + MOVL BX, ebx+12(FP) + MOVL CX, ecx+16(FP) + MOVL DX, edx+20(FP) + RET + +// func asmCpuidex(op, op2 uint32) (eax, ebx, ecx, edx uint32) +TEXT ·asmCpuidex(SB), 7, $0 + MOVL op+0(FP), AX + MOVL op2+4(FP), CX + CPUID + MOVL AX, eax+8(FP) + MOVL BX, ebx+12(FP) + MOVL CX, ecx+16(FP) + MOVL DX, edx+20(FP) + RET + +// func asmXgetbv(index uint32) (eax, edx uint32) +TEXT ·asmXgetbv(SB), 7, $0 + MOVL index+0(FP), CX + BYTE $0x0f; BYTE $0x01; BYTE $0xd0 // XGETBV + MOVL AX, eax+8(FP) + MOVL DX, edx+12(FP) + RET + +// func asmRdtscpAsm() (eax, ebx, ecx, edx uint32) +TEXT ·asmRdtscpAsm(SB), 7, $0 + BYTE $0x0F; BYTE $0x01; BYTE $0xF9 // RDTSCP + MOVL AX, eax+0(FP) + MOVL BX, ebx+4(FP) + MOVL CX, ecx+8(FP) + MOVL DX, edx+12(FP) + RET diff --git a/vendor/github.com/klauspost/cpuid/detect_intel.go b/vendor/github.com/klauspost/cpuid/detect_intel.go new file mode 100644 index 0000000000..a5f04dd6d0 --- /dev/null +++ b/vendor/github.com/klauspost/cpuid/detect_intel.go @@ -0,0 +1,17 @@ +// Copyright (c) 2015 Klaus Post, released under MIT License. See LICENSE file. + +// +build 386,!gccgo amd64,!gccgo + +package cpuid + +func asmCpuid(op uint32) (eax, ebx, ecx, edx uint32) +func asmCpuidex(op, op2 uint32) (eax, ebx, ecx, edx uint32) +func asmXgetbv(index uint32) (eax, edx uint32) +func asmRdtscpAsm() (eax, ebx, ecx, edx uint32) + +func initCPU() { + cpuid = asmCpuid + cpuidex = asmCpuidex + xgetbv = asmXgetbv + rdtscpAsm = asmRdtscpAsm +} diff --git a/vendor/github.com/klauspost/cpuid/detect_ref.go b/vendor/github.com/klauspost/cpuid/detect_ref.go new file mode 100644 index 0000000000..909c5d9a7a --- /dev/null +++ b/vendor/github.com/klauspost/cpuid/detect_ref.go @@ -0,0 +1,23 @@ +// Copyright (c) 2015 Klaus Post, released under MIT License. See LICENSE file. + +// +build !amd64,!386 gccgo + +package cpuid + +func initCPU() { + cpuid = func(op uint32) (eax, ebx, ecx, edx uint32) { + return 0, 0, 0, 0 + } + + cpuidex = func(op, op2 uint32) (eax, ebx, ecx, edx uint32) { + return 0, 0, 0, 0 + } + + xgetbv = func(index uint32) (eax, edx uint32) { + return 0, 0 + } + + rdtscpAsm = func() (eax, ebx, ecx, edx uint32) { + return 0, 0, 0, 0 + } +} diff --git a/vendor/github.com/klauspost/cpuid/generate.go b/vendor/github.com/klauspost/cpuid/generate.go new file mode 100644 index 0000000000..c060b8165e --- /dev/null +++ b/vendor/github.com/klauspost/cpuid/generate.go @@ -0,0 +1,3 @@ +package cpuid + +//go:generate go run private-gen.go diff --git a/vendor/github.com/klauspost/cpuid/private-gen.go b/vendor/github.com/klauspost/cpuid/private-gen.go new file mode 100644 index 0000000000..437333d292 --- /dev/null +++ b/vendor/github.com/klauspost/cpuid/private-gen.go @@ -0,0 +1,476 @@ +// +build ignore + +package main + +import ( + "bytes" + "fmt" + "go/ast" + "go/parser" + "go/printer" + "go/token" + "io" + "io/ioutil" + "log" + "os" + "reflect" + "strings" + "unicode" + "unicode/utf8" +) + +var inFiles = []string{"cpuid.go", "cpuid_test.go"} +var copyFiles = []string{"cpuid_amd64.s", "cpuid_386.s", "detect_ref.go", "detect_intel.go"} +var fileSet = token.NewFileSet() +var reWrites = []rewrite{ + initRewrite("CPUInfo -> cpuInfo"), + initRewrite("Vendor -> vendor"), + initRewrite("Flags -> flags"), + initRewrite("Detect -> detect"), + initRewrite("CPU -> cpu"), +} +var excludeNames = map[string]bool{"string": true, "join": true, "trim": true, + // cpuid_test.go + "t": true, "println": true, "logf": true, "log": true, "fatalf": true, "fatal": true, +} + +var excludePrefixes = []string{"test", "benchmark"} + +func main() { + Package := "private" + parserMode := parser.ParseComments + exported := make(map[string]rewrite) + for _, file := range inFiles { + in, err := os.Open(file) + if err != nil { + log.Fatalf("opening input", err) + } + + src, err := ioutil.ReadAll(in) + if err != nil { + log.Fatalf("reading input", err) + } + + astfile, err := parser.ParseFile(fileSet, file, src, parserMode) + if err != nil { + log.Fatalf("parsing input", err) + } + + for _, rw := range reWrites { + astfile = rw(astfile) + } + + // Inspect the AST and print all identifiers and literals. + var startDecl token.Pos + var endDecl token.Pos + ast.Inspect(astfile, func(n ast.Node) bool { + var s string + switch x := n.(type) { + case *ast.Ident: + if x.IsExported() { + t := strings.ToLower(x.Name) + for _, pre := range excludePrefixes { + if strings.HasPrefix(t, pre) { + return true + } + } + if excludeNames[t] != true { + //if x.Pos() > startDecl && x.Pos() < endDecl { + exported[x.Name] = initRewrite(x.Name + " -> " + t) + } + } + + case *ast.GenDecl: + if x.Tok == token.CONST && x.Lparen > 0 { + startDecl = x.Lparen + endDecl = x.Rparen + // fmt.Printf("Decl:%s -> %s\n", fileSet.Position(startDecl), fileSet.Position(endDecl)) + } + } + if s != "" { + fmt.Printf("%s:\t%s\n", fileSet.Position(n.Pos()), s) + } + return true + }) + + for _, rw := range exported { + astfile = rw(astfile) + } + + var buf bytes.Buffer + + printer.Fprint(&buf, fileSet, astfile) + + // Remove package documentation and insert information + s := buf.String() + ind := strings.Index(buf.String(), "\npackage cpuid") + s = s[ind:] + s = "// Generated, DO NOT EDIT,\n" + + "// but copy it to your own project and rename the package.\n" + + "// See more at http://github.com/klauspost/cpuid\n" + + s + + outputName := Package + string(os.PathSeparator) + file + + err = ioutil.WriteFile(outputName, []byte(s), 0644) + if err != nil { + log.Fatalf("writing output: %s", err) + } + log.Println("Generated", outputName) + } + + for _, file := range copyFiles { + dst := "" + if strings.HasPrefix(file, "cpuid") { + dst = Package + string(os.PathSeparator) + file + } else { + dst = Package + string(os.PathSeparator) + "cpuid_" + file + } + err := copyFile(file, dst) + if err != nil { + log.Fatalf("copying file: %s", err) + } + log.Println("Copied", dst) + } +} + +// CopyFile copies a file from src to dst. If src and dst files exist, and are +// the same, then return success. Copy the file contents from src to dst. +func copyFile(src, dst string) (err error) { + sfi, err := os.Stat(src) + if err != nil { + return + } + if !sfi.Mode().IsRegular() { + // cannot copy non-regular files (e.g., directories, + // symlinks, devices, etc.) + return fmt.Errorf("CopyFile: non-regular source file %s (%q)", sfi.Name(), sfi.Mode().String()) + } + dfi, err := os.Stat(dst) + if err != nil { + if !os.IsNotExist(err) { + return + } + } else { + if !(dfi.Mode().IsRegular()) { + return fmt.Errorf("CopyFile: non-regular destination file %s (%q)", dfi.Name(), dfi.Mode().String()) + } + if os.SameFile(sfi, dfi) { + return + } + } + err = copyFileContents(src, dst) + return +} + +// copyFileContents copies the contents of the file named src to the file named +// by dst. The file will be created if it does not already exist. If the +// destination file exists, all it's contents will be replaced by the contents +// of the source file. +func copyFileContents(src, dst string) (err error) { + in, err := os.Open(src) + if err != nil { + return + } + defer in.Close() + out, err := os.Create(dst) + if err != nil { + return + } + defer func() { + cerr := out.Close() + if err == nil { + err = cerr + } + }() + if _, err = io.Copy(out, in); err != nil { + return + } + err = out.Sync() + return +} + +type rewrite func(*ast.File) *ast.File + +// Mostly copied from gofmt +func initRewrite(rewriteRule string) rewrite { + f := strings.Split(rewriteRule, "->") + if len(f) != 2 { + fmt.Fprintf(os.Stderr, "rewrite rule must be of the form 'pattern -> replacement'\n") + os.Exit(2) + } + pattern := parseExpr(f[0], "pattern") + replace := parseExpr(f[1], "replacement") + return func(p *ast.File) *ast.File { return rewriteFile(pattern, replace, p) } +} + +// parseExpr parses s as an expression. +// It might make sense to expand this to allow statement patterns, +// but there are problems with preserving formatting and also +// with what a wildcard for a statement looks like. +func parseExpr(s, what string) ast.Expr { + x, err := parser.ParseExpr(s) + if err != nil { + fmt.Fprintf(os.Stderr, "parsing %s %s at %s\n", what, s, err) + os.Exit(2) + } + return x +} + +// Keep this function for debugging. +/* +func dump(msg string, val reflect.Value) { + fmt.Printf("%s:\n", msg) + ast.Print(fileSet, val.Interface()) + fmt.Println() +} +*/ + +// rewriteFile applies the rewrite rule 'pattern -> replace' to an entire file. +func rewriteFile(pattern, replace ast.Expr, p *ast.File) *ast.File { + cmap := ast.NewCommentMap(fileSet, p, p.Comments) + m := make(map[string]reflect.Value) + pat := reflect.ValueOf(pattern) + repl := reflect.ValueOf(replace) + + var rewriteVal func(val reflect.Value) reflect.Value + rewriteVal = func(val reflect.Value) reflect.Value { + // don't bother if val is invalid to start with + if !val.IsValid() { + return reflect.Value{} + } + for k := range m { + delete(m, k) + } + val = apply(rewriteVal, val) + if match(m, pat, val) { + val = subst(m, repl, reflect.ValueOf(val.Interface().(ast.Node).Pos())) + } + return val + } + + r := apply(rewriteVal, reflect.ValueOf(p)).Interface().(*ast.File) + r.Comments = cmap.Filter(r).Comments() // recreate comments list + return r +} + +// set is a wrapper for x.Set(y); it protects the caller from panics if x cannot be changed to y. +func set(x, y reflect.Value) { + // don't bother if x cannot be set or y is invalid + if !x.CanSet() || !y.IsValid() { + return + } + defer func() { + if x := recover(); x != nil { + if s, ok := x.(string); ok && + (strings.Contains(s, "type mismatch") || strings.Contains(s, "not assignable")) { + // x cannot be set to y - ignore this rewrite + return + } + panic(x) + } + }() + x.Set(y) +} + +// Values/types for special cases. +var ( + objectPtrNil = reflect.ValueOf((*ast.Object)(nil)) + scopePtrNil = reflect.ValueOf((*ast.Scope)(nil)) + + identType = reflect.TypeOf((*ast.Ident)(nil)) + objectPtrType = reflect.TypeOf((*ast.Object)(nil)) + positionType = reflect.TypeOf(token.NoPos) + callExprType = reflect.TypeOf((*ast.CallExpr)(nil)) + scopePtrType = reflect.TypeOf((*ast.Scope)(nil)) +) + +// apply replaces each AST field x in val with f(x), returning val. +// To avoid extra conversions, f operates on the reflect.Value form. +func apply(f func(reflect.Value) reflect.Value, val reflect.Value) reflect.Value { + if !val.IsValid() { + return reflect.Value{} + } + + // *ast.Objects introduce cycles and are likely incorrect after + // rewrite; don't follow them but replace with nil instead + if val.Type() == objectPtrType { + return objectPtrNil + } + + // similarly for scopes: they are likely incorrect after a rewrite; + // replace them with nil + if val.Type() == scopePtrType { + return scopePtrNil + } + + switch v := reflect.Indirect(val); v.Kind() { + case reflect.Slice: + for i := 0; i < v.Len(); i++ { + e := v.Index(i) + set(e, f(e)) + } + case reflect.Struct: + for i := 0; i < v.NumField(); i++ { + e := v.Field(i) + set(e, f(e)) + } + case reflect.Interface: + e := v.Elem() + set(v, f(e)) + } + return val +} + +func isWildcard(s string) bool { + rune, size := utf8.DecodeRuneInString(s) + return size == len(s) && unicode.IsLower(rune) +} + +// match returns true if pattern matches val, +// recording wildcard submatches in m. +// If m == nil, match checks whether pattern == val. +func match(m map[string]reflect.Value, pattern, val reflect.Value) bool { + // Wildcard matches any expression. If it appears multiple + // times in the pattern, it must match the same expression + // each time. + if m != nil && pattern.IsValid() && pattern.Type() == identType { + name := pattern.Interface().(*ast.Ident).Name + if isWildcard(name) && val.IsValid() { + // wildcards only match valid (non-nil) expressions. + if _, ok := val.Interface().(ast.Expr); ok && !val.IsNil() { + if old, ok := m[name]; ok { + return match(nil, old, val) + } + m[name] = val + return true + } + } + } + + // Otherwise, pattern and val must match recursively. + if !pattern.IsValid() || !val.IsValid() { + return !pattern.IsValid() && !val.IsValid() + } + if pattern.Type() != val.Type() { + return false + } + + // Special cases. + switch pattern.Type() { + case identType: + // For identifiers, only the names need to match + // (and none of the other *ast.Object information). + // This is a common case, handle it all here instead + // of recursing down any further via reflection. + p := pattern.Interface().(*ast.Ident) + v := val.Interface().(*ast.Ident) + return p == nil && v == nil || p != nil && v != nil && p.Name == v.Name + case objectPtrType, positionType: + // object pointers and token positions always match + return true + case callExprType: + // For calls, the Ellipsis fields (token.Position) must + // match since that is how f(x) and f(x...) are different. + // Check them here but fall through for the remaining fields. + p := pattern.Interface().(*ast.CallExpr) + v := val.Interface().(*ast.CallExpr) + if p.Ellipsis.IsValid() != v.Ellipsis.IsValid() { + return false + } + } + + p := reflect.Indirect(pattern) + v := reflect.Indirect(val) + if !p.IsValid() || !v.IsValid() { + return !p.IsValid() && !v.IsValid() + } + + switch p.Kind() { + case reflect.Slice: + if p.Len() != v.Len() { + return false + } + for i := 0; i < p.Len(); i++ { + if !match(m, p.Index(i), v.Index(i)) { + return false + } + } + return true + + case reflect.Struct: + for i := 0; i < p.NumField(); i++ { + if !match(m, p.Field(i), v.Field(i)) { + return false + } + } + return true + + case reflect.Interface: + return match(m, p.Elem(), v.Elem()) + } + + // Handle token integers, etc. + return p.Interface() == v.Interface() +} + +// subst returns a copy of pattern with values from m substituted in place +// of wildcards and pos used as the position of tokens from the pattern. +// if m == nil, subst returns a copy of pattern and doesn't change the line +// number information. +func subst(m map[string]reflect.Value, pattern reflect.Value, pos reflect.Value) reflect.Value { + if !pattern.IsValid() { + return reflect.Value{} + } + + // Wildcard gets replaced with map value. + if m != nil && pattern.Type() == identType { + name := pattern.Interface().(*ast.Ident).Name + if isWildcard(name) { + if old, ok := m[name]; ok { + return subst(nil, old, reflect.Value{}) + } + } + } + + if pos.IsValid() && pattern.Type() == positionType { + // use new position only if old position was valid in the first place + if old := pattern.Interface().(token.Pos); !old.IsValid() { + return pattern + } + return pos + } + + // Otherwise copy. + switch p := pattern; p.Kind() { + case reflect.Slice: + v := reflect.MakeSlice(p.Type(), p.Len(), p.Len()) + for i := 0; i < p.Len(); i++ { + v.Index(i).Set(subst(m, p.Index(i), pos)) + } + return v + + case reflect.Struct: + v := reflect.New(p.Type()).Elem() + for i := 0; i < p.NumField(); i++ { + v.Field(i).Set(subst(m, p.Field(i), pos)) + } + return v + + case reflect.Ptr: + v := reflect.New(p.Type()).Elem() + if elem := p.Elem(); elem.IsValid() { + v.Set(subst(m, elem, pos).Addr()) + } + return v + + case reflect.Interface: + v := reflect.New(p.Type()).Elem() + if elem := p.Elem(); elem.IsValid() { + v.Set(subst(m, elem, pos)) + } + return v + } + + return pattern +} diff --git a/vendor/github.com/klauspost/crc32/LICENSE b/vendor/github.com/klauspost/crc32/LICENSE new file mode 100644 index 0000000000..4fd5963e39 --- /dev/null +++ b/vendor/github.com/klauspost/crc32/LICENSE @@ -0,0 +1,28 @@ +Copyright (c) 2012 The Go Authors. All rights reserved. +Copyright (c) 2015 Klaus Post + +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. diff --git a/vendor/github.com/klauspost/crc32/crc32.go b/vendor/github.com/klauspost/crc32/crc32.go new file mode 100644 index 0000000000..8d6ba5d3dc --- /dev/null +++ b/vendor/github.com/klauspost/crc32/crc32.go @@ -0,0 +1,186 @@ +// 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. + +// Package crc32 implements the 32-bit cyclic redundancy check, or CRC-32, +// checksum. See http://en.wikipedia.org/wiki/Cyclic_redundancy_check for +// information. +// +// Polynomials are represented in LSB-first form also known as reversed representation. +// +// See http://en.wikipedia.org/wiki/Mathematics_of_cyclic_redundancy_checks#Reversed_representations_and_reciprocal_polynomials +// for information. +package crc32 + +import ( + "hash" + "sync" +) + +// The size of a CRC-32 checksum in bytes. +const Size = 4 + +// Predefined polynomials. +const ( + // IEEE is by far and away the most common CRC-32 polynomial. + // Used by ethernet (IEEE 802.3), v.42, fddi, gzip, zip, png, ... + IEEE = 0xedb88320 + + // Castagnoli's polynomial, used in iSCSI. + // Has better error detection characteristics than IEEE. + // http://dx.doi.org/10.1109/26.231911 + Castagnoli = 0x82f63b78 + + // Koopman's polynomial. + // Also has better error detection characteristics than IEEE. + // http://dx.doi.org/10.1109/DSN.2002.1028931 + Koopman = 0xeb31d82e +) + +// Table is a 256-word table representing the polynomial for efficient processing. +type Table [256]uint32 + +// castagnoliTable points to a lazily initialized Table for the Castagnoli +// polynomial. MakeTable will always return this value when asked to make a +// Castagnoli table so we can compare against it to find when the caller is +// using this polynomial. +var castagnoliTable *Table +var castagnoliTable8 *slicing8Table +var castagnoliOnce sync.Once + +func castagnoliInit() { + castagnoliTable = makeTable(Castagnoli) + castagnoliTable8 = makeTable8(Castagnoli) +} + +// IEEETable is the table for the IEEE polynomial. +var IEEETable = makeTable(IEEE) + +// slicing8Table is array of 8 Tables +type slicing8Table [8]Table + +// ieeeTable8 is the slicing8Table for IEEE +var ieeeTable8 *slicing8Table +var ieeeTable8Once sync.Once + +// MakeTable returns a Table constructed from the specified polynomial. +// The contents of this Table must not be modified. +func MakeTable(poly uint32) *Table { + switch poly { + case IEEE: + return IEEETable + case Castagnoli: + castagnoliOnce.Do(castagnoliInit) + return castagnoliTable + } + return makeTable(poly) +} + +// makeTable returns the Table constructed from the specified polynomial. +func makeTable(poly uint32) *Table { + t := new(Table) + for i := 0; i < 256; i++ { + crc := uint32(i) + for j := 0; j < 8; j++ { + if crc&1 == 1 { + crc = (crc >> 1) ^ poly + } else { + crc >>= 1 + } + } + t[i] = crc + } + return t +} + +// makeTable8 returns slicing8Table constructed from the specified polynomial. +func makeTable8(poly uint32) *slicing8Table { + t := new(slicing8Table) + t[0] = *makeTable(poly) + for i := 0; i < 256; i++ { + crc := t[0][i] + for j := 1; j < 8; j++ { + crc = t[0][crc&0xFF] ^ (crc >> 8) + t[j][i] = crc + } + } + return t +} + +// digest represents the partial evaluation of a checksum. +type digest struct { + crc uint32 + tab *Table +} + +// New creates a new hash.Hash32 computing the CRC-32 checksum +// using the polynomial represented by the Table. +// Its Sum method will lay the value out in big-endian byte order. +func New(tab *Table) hash.Hash32 { return &digest{0, tab} } + +// NewIEEE creates a new hash.Hash32 computing the CRC-32 checksum +// using the IEEE polynomial. +// Its Sum method will lay the value out in big-endian byte order. +func NewIEEE() hash.Hash32 { return New(IEEETable) } + +func (d *digest) Size() int { return Size } + +func (d *digest) BlockSize() int { return 1 } + +func (d *digest) Reset() { d.crc = 0 } + +func update(crc uint32, tab *Table, p []byte) uint32 { + crc = ^crc + for _, v := range p { + crc = tab[byte(crc)^v] ^ (crc >> 8) + } + return ^crc +} + +// updateSlicingBy8 updates CRC using Slicing-by-8 +func updateSlicingBy8(crc uint32, tab *slicing8Table, p []byte) uint32 { + crc = ^crc + for len(p) > 8 { + crc ^= uint32(p[0]) | uint32(p[1])<<8 | uint32(p[2])<<16 | uint32(p[3])<<24 + crc = tab[0][p[7]] ^ tab[1][p[6]] ^ tab[2][p[5]] ^ tab[3][p[4]] ^ + tab[4][crc>>24] ^ tab[5][(crc>>16)&0xFF] ^ + tab[6][(crc>>8)&0xFF] ^ tab[7][crc&0xFF] + p = p[8:] + } + crc = ^crc + if len(p) == 0 { + return crc + } + return update(crc, &tab[0], p) +} + +// Update returns the result of adding the bytes in p to the crc. +func Update(crc uint32, tab *Table, p []byte) uint32 { + if tab == castagnoliTable { + return updateCastagnoli(crc, p) + } + if tab == IEEETable { + return updateIEEE(crc, p) + } + return update(crc, tab, p) +} + +func (d *digest) Write(p []byte) (n int, err error) { + d.crc = Update(d.crc, d.tab, p) + return len(p), nil +} + +func (d *digest) Sum32() uint32 { return d.crc } + +func (d *digest) Sum(in []byte) []byte { + s := d.Sum32() + return append(in, byte(s>>24), byte(s>>16), byte(s>>8), byte(s)) +} + +// Checksum returns the CRC-32 checksum of data +// using the polynomial represented by the Table. +func Checksum(data []byte, tab *Table) uint32 { return Update(0, tab, data) } + +// ChecksumIEEE returns the CRC-32 checksum of data +// using the IEEE polynomial. +func ChecksumIEEE(data []byte) uint32 { return updateIEEE(0, data) } diff --git a/vendor/github.com/klauspost/crc32/crc32_amd64.go b/vendor/github.com/klauspost/crc32/crc32_amd64.go new file mode 100644 index 0000000000..4827128ea0 --- /dev/null +++ b/vendor/github.com/klauspost/crc32/crc32_amd64.go @@ -0,0 +1,62 @@ +// 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 !appengine,!gccgo + +package crc32 + +// This file contains the code to call the SSE 4.2 version of the Castagnoli +// and IEEE CRC. + +// haveSSE41/haveSSE42/haveCLMUL are defined in crc_amd64.s and use +// CPUID to test for SSE 4.1, 4.2 and CLMUL support. +func haveSSE41() bool +func haveSSE42() bool +func haveCLMUL() bool + +// castagnoliSSE42 is defined in crc_amd64.s and uses the SSE4.2 CRC32 +// instruction. +//go:noescape +func castagnoliSSE42(crc uint32, p []byte) uint32 + +// ieeeCLMUL is defined in crc_amd64.s and uses the PCLMULQDQ +// instruction as well as SSE 4.1. +//go:noescape +func ieeeCLMUL(crc uint32, p []byte) uint32 + +var sse42 = haveSSE42() +var useFastIEEE = haveCLMUL() && haveSSE41() + +func updateCastagnoli(crc uint32, p []byte) uint32 { + if sse42 { + return castagnoliSSE42(crc, p) + } + // only use slicing-by-8 when input is >= 16 Bytes + if len(p) >= 16 { + return updateSlicingBy8(crc, castagnoliTable8, p) + } + return update(crc, castagnoliTable, p) +} + +func updateIEEE(crc uint32, p []byte) uint32 { + if useFastIEEE && len(p) >= 64 { + left := len(p) & 15 + do := len(p) - left + crc = ^ieeeCLMUL(^crc, p[:do]) + if left > 0 { + crc = update(crc, IEEETable, p[do:]) + } + return crc + } + + // only use slicing-by-8 when input is >= 16 Bytes + if len(p) >= 16 { + ieeeTable8Once.Do(func() { + ieeeTable8 = makeTable8(IEEE) + }) + return updateSlicingBy8(crc, ieeeTable8, p) + } + + return update(crc, IEEETable, p) +} diff --git a/vendor/github.com/klauspost/crc32/crc32_amd64.s b/vendor/github.com/klauspost/crc32/crc32_amd64.s new file mode 100644 index 0000000000..9bf05d89b8 --- /dev/null +++ b/vendor/github.com/klauspost/crc32/crc32_amd64.s @@ -0,0 +1,237 @@ +// 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 gc + +#define NOSPLIT 4 +#define RODATA 8 + +// func castagnoliSSE42(crc uint32, p []byte) uint32 +TEXT ·castagnoliSSE42(SB), NOSPLIT, $0 + MOVL crc+0(FP), AX // CRC value + MOVQ p+8(FP), SI // data pointer + MOVQ p_len+16(FP), CX // len(p) + + NOTL AX + + // If there's less than 8 bytes to process, we do it byte-by-byte. + CMPQ CX, $8 + JL cleanup + + // Process individual bytes until the input is 8-byte aligned. +startup: + MOVQ SI, BX + ANDQ $7, BX + JZ aligned + + CRC32B (SI), AX + DECQ CX + INCQ SI + JMP startup + +aligned: + // The input is now 8-byte aligned and we can process 8-byte chunks. + CMPQ CX, $8 + JL cleanup + + CRC32Q (SI), AX + ADDQ $8, SI + SUBQ $8, CX + JMP aligned + +cleanup: + // We may have some bytes left over that we process one at a time. + CMPQ CX, $0 + JE done + + CRC32B (SI), AX + INCQ SI + DECQ CX + JMP cleanup + +done: + NOTL AX + MOVL AX, ret+32(FP) + RET + +// func haveSSE42() bool +TEXT ·haveSSE42(SB), NOSPLIT, $0 + XORQ AX, AX + INCL AX + CPUID + SHRQ $20, CX + ANDQ $1, CX + MOVB CX, ret+0(FP) + RET + +// func haveCLMUL() bool +TEXT ·haveCLMUL(SB), NOSPLIT, $0 + XORQ AX, AX + INCL AX + CPUID + SHRQ $1, CX + ANDQ $1, CX + MOVB CX, ret+0(FP) + RET + +// func haveSSE41() bool +TEXT ·haveSSE41(SB), NOSPLIT, $0 + XORQ AX, AX + INCL AX + CPUID + SHRQ $19, CX + ANDQ $1, CX + MOVB CX, ret+0(FP) + RET + +// CRC32 polynomial data +// +// These constants are lifted from the +// Linux kernel, since they avoid the costly +// PSHUFB 16 byte reversal proposed in the +// original Intel paper. +DATA r2r1kp<>+0(SB)/8, $0x154442bd4 +DATA r2r1kp<>+8(SB)/8, $0x1c6e41596 +DATA r4r3kp<>+0(SB)/8, $0x1751997d0 +DATA r4r3kp<>+8(SB)/8, $0x0ccaa009e +DATA rupolykp<>+0(SB)/8, $0x1db710641 +DATA rupolykp<>+8(SB)/8, $0x1f7011641 +DATA r5kp<>+0(SB)/8, $0x163cd6124 + +GLOBL r2r1kp<>(SB), RODATA, $16 +GLOBL r4r3kp<>(SB), RODATA, $16 +GLOBL rupolykp<>(SB), RODATA, $16 +GLOBL r5kp<>(SB), RODATA, $8 + +// Based on http://www.intel.com/content/dam/www/public/us/en/documents/white-papers/fast-crc-computation-generic-polynomials-pclmulqdq-paper.pdf +// len(p) must be at least 64, and must be a multiple of 16. + +// func ieeeCLMUL(crc uint32, p []byte) uint32 +TEXT ·ieeeCLMUL(SB), NOSPLIT, $0 + MOVL crc+0(FP), X0 // Initial CRC value + MOVQ p+8(FP), SI // data pointer + MOVQ p_len+16(FP), CX // len(p) + + MOVOU (SI), X1 + MOVOU 16(SI), X2 + MOVOU 32(SI), X3 + MOVOU 48(SI), X4 + PXOR X0, X1 + ADDQ $64, SI // buf+=64 + SUBQ $64, CX // len-=64 + CMPQ CX, $64 // Less than 64 bytes left + JB remain64 + + MOVOA r2r1kp<>+0(SB), X0 + +loopback64: + MOVOA X1, X5 + MOVOA X2, X6 + MOVOA X3, X7 + MOVOA X4, X8 + + PCLMULQDQ $0, X0, X1 + PCLMULQDQ $0, X0, X2 + PCLMULQDQ $0, X0, X3 + PCLMULQDQ $0, X0, X4 + + // Load next early + MOVOU (SI), X11 + MOVOU 16(SI), X12 + MOVOU 32(SI), X13 + MOVOU 48(SI), X14 + + PCLMULQDQ $0x11, X0, X5 + PCLMULQDQ $0x11, X0, X6 + PCLMULQDQ $0x11, X0, X7 + PCLMULQDQ $0x11, X0, X8 + + PXOR X5, X1 + PXOR X6, X2 + PXOR X7, X3 + PXOR X8, X4 + + PXOR X11, X1 + PXOR X12, X2 + PXOR X13, X3 + PXOR X14, X4 + + ADDQ $0x40, DI + ADDQ $64, SI // buf+=64 + SUBQ $64, CX // len-=64 + CMPQ CX, $64 // Less than 64 bytes left? + JGE loopback64 + + // Fold result into a single register (X1) +remain64: + MOVOA r4r3kp<>+0(SB), X0 + + MOVOA X1, X5 + PCLMULQDQ $0, X0, X1 + PCLMULQDQ $0x11, X0, X5 + PXOR X5, X1 + PXOR X2, X1 + + MOVOA X1, X5 + PCLMULQDQ $0, X0, X1 + PCLMULQDQ $0x11, X0, X5 + PXOR X5, X1 + PXOR X3, X1 + + MOVOA X1, X5 + PCLMULQDQ $0, X0, X1 + PCLMULQDQ $0x11, X0, X5 + PXOR X5, X1 + PXOR X4, X1 + + // More than 16 bytes left? + CMPQ CX, $16 + JB finish + + // Encode 16 bytes +remain16: + MOVOU (SI), X10 + MOVOA X1, X5 + PCLMULQDQ $0, X0, X1 + PCLMULQDQ $0x11, X0, X5 + PXOR X5, X1 + PXOR X10, X1 + SUBQ $16, CX + ADDQ $16, SI + CMPQ CX, $16 + JGE remain16 + +finish: + // Fold final result into 32 bits and return it + PCMPEQB X3, X3 + PCLMULQDQ $1, X1, X0 + PSRLDQ $8, X1 + PXOR X0, X1 + + MOVOA X1, X2 + MOVQ r5kp<>+0(SB), X0 + + // Creates 32 bit mask. Note that we don't care about upper half. + PSRLQ $32, X3 + + PSRLDQ $4, X2 + PAND X3, X1 + PCLMULQDQ $0, X0, X1 + PXOR X2, X1 + + MOVOA rupolykp<>+0(SB), X0 + + MOVOA X1, X2 + PAND X3, X1 + PCLMULQDQ $0x10, X0, X1 + PAND X3, X1 + PCLMULQDQ $0, X0, X1 + PXOR X2, X1 + + // PEXTRD $1, X1, AX (SSE 4.1) + BYTE $0x66; BYTE $0x0f; BYTE $0x3a + BYTE $0x16; BYTE $0xc8; BYTE $0x01 + MOVL AX, ret+32(FP) + + RET diff --git a/vendor/github.com/klauspost/crc32/crc32_amd64p32.go b/vendor/github.com/klauspost/crc32/crc32_amd64p32.go new file mode 100644 index 0000000000..926473e7c0 --- /dev/null +++ b/vendor/github.com/klauspost/crc32/crc32_amd64p32.go @@ -0,0 +1,40 @@ +// 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 !appengine,!gccgo + +package crc32 + +// This file contains the code to call the SSE 4.2 version of the Castagnoli +// CRC. + +// haveSSE42 is defined in crc_amd64p32.s and uses CPUID to test for SSE 4.2 +// support. +func haveSSE42() bool + +// castagnoliSSE42 is defined in crc_amd64.s and uses the SSE4.2 CRC32 +// instruction. +//go:noescape +func castagnoliSSE42(crc uint32, p []byte) uint32 + +var sse42 = haveSSE42() + +func updateCastagnoli(crc uint32, p []byte) uint32 { + if sse42 { + return castagnoliSSE42(crc, p) + } + return update(crc, castagnoliTable, p) +} + +func updateIEEE(crc uint32, p []byte) uint32 { + // only use slicing-by-8 when input is >= 4KB + if len(p) >= 4096 { + ieeeTable8Once.Do(func() { + ieeeTable8 = makeTable8(IEEE) + }) + return updateSlicingBy8(crc, ieeeTable8, p) + } + + return update(crc, IEEETable, p) +} diff --git a/vendor/github.com/klauspost/crc32/crc32_amd64p32.s b/vendor/github.com/klauspost/crc32/crc32_amd64p32.s new file mode 100644 index 0000000000..a578d685cc --- /dev/null +++ b/vendor/github.com/klauspost/crc32/crc32_amd64p32.s @@ -0,0 +1,67 @@ +// 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 gc + +#define NOSPLIT 4 +#define RODATA 8 + +// func castagnoliSSE42(crc uint32, p []byte) uint32 +TEXT ·castagnoliSSE42(SB), NOSPLIT, $0 + MOVL crc+0(FP), AX // CRC value + MOVL p+4(FP), SI // data pointer + MOVL p_len+8(FP), CX // len(p) + + NOTL AX + + // If there's less than 8 bytes to process, we do it byte-by-byte. + CMPQ CX, $8 + JL cleanup + + // Process individual bytes until the input is 8-byte aligned. +startup: + MOVQ SI, BX + ANDQ $7, BX + JZ aligned + + CRC32B (SI), AX + DECQ CX + INCQ SI + JMP startup + +aligned: + // The input is now 8-byte aligned and we can process 8-byte chunks. + CMPQ CX, $8 + JL cleanup + + CRC32Q (SI), AX + ADDQ $8, SI + SUBQ $8, CX + JMP aligned + +cleanup: + // We may have some bytes left over that we process one at a time. + CMPQ CX, $0 + JE done + + CRC32B (SI), AX + INCQ SI + DECQ CX + JMP cleanup + +done: + NOTL AX + MOVL AX, ret+16(FP) + RET + +// func haveSSE42() bool +TEXT ·haveSSE42(SB), NOSPLIT, $0 + XORQ AX, AX + INCL AX + CPUID + SHRQ $20, CX + ANDQ $1, CX + MOVB CX, ret+0(FP) + RET + diff --git a/vendor/github.com/klauspost/crc32/crc32_generic.go b/vendor/github.com/klauspost/crc32/crc32_generic.go new file mode 100644 index 0000000000..a53cf96a00 --- /dev/null +++ b/vendor/github.com/klauspost/crc32/crc32_generic.go @@ -0,0 +1,29 @@ +// 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 !amd64,!amd64p32 appengine gccgo + +package crc32 + +// This file contains the generic version of updateCastagnoli which does +// slicing-by-8, or uses the fallback for very small sizes. + +func updateCastagnoli(crc uint32, p []byte) uint32 { + // only use slicing-by-8 when input is >= 16 Bytes + if len(p) >= 16 { + return updateSlicingBy8(crc, castagnoliTable8, p) + } + return update(crc, castagnoliTable, p) +} + +func updateIEEE(crc uint32, p []byte) uint32 { + // only use slicing-by-8 when input is >= 16 Bytes + if len(p) >= 16 { + ieeeTable8Once.Do(func() { + ieeeTable8 = makeTable8(IEEE) + }) + return updateSlicingBy8(crc, ieeeTable8, p) + } + return update(crc, IEEETable, p) +} diff --git a/vendor/github.com/klauspost/pgzip/LICENSE b/vendor/github.com/klauspost/pgzip/LICENSE new file mode 100644 index 0000000000..2bdc0d7517 --- /dev/null +++ b/vendor/github.com/klauspost/pgzip/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2014 Klaus Post + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/vendor/github.com/klauspost/pgzip/gunzip.go b/vendor/github.com/klauspost/pgzip/gunzip.go new file mode 100644 index 0000000000..45b846e020 --- /dev/null +++ b/vendor/github.com/klauspost/pgzip/gunzip.go @@ -0,0 +1,564 @@ +// 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. + +// Package pgzip implements reading and writing of gzip format compressed files, +// as specified in RFC 1952. +// +// This is a drop in replacement for "compress/gzip". +// This will split compression into blocks that are compressed in parallel. +// This can be useful for compressing big amounts of data. +// The gzip decompression has not been modified, but remains in the package, +// so you can use it as a complete replacement for "compress/gzip". +// +// See more at https://github.com/klauspost/pgzip +package pgzip + +import ( + "bufio" + "errors" + "hash" + "io" + "sync" + "time" + + "github.com/klauspost/compress/flate" + "github.com/klauspost/crc32" +) + +const ( + gzipID1 = 0x1f + gzipID2 = 0x8b + gzipDeflate = 8 + flagText = 1 << 0 + flagHdrCrc = 1 << 1 + flagExtra = 1 << 2 + flagName = 1 << 3 + flagComment = 1 << 4 +) + +func makeReader(r io.Reader) flate.Reader { + if rr, ok := r.(flate.Reader); ok { + return rr + } + return bufio.NewReader(r) +} + +var ( + // ErrChecksum is returned when reading GZIP data that has an invalid checksum. + ErrChecksum = errors.New("gzip: invalid checksum") + // ErrHeader is returned when reading GZIP data that has an invalid header. + ErrHeader = errors.New("gzip: invalid header") +) + +// The gzip file stores a header giving metadata about the compressed file. +// That header is exposed as the fields of the Writer and Reader structs. +type Header struct { + Comment string // comment + Extra []byte // "extra data" + ModTime time.Time // modification time + Name string // file name + OS byte // operating system type +} + +// A Reader is an io.Reader that can be read to retrieve +// uncompressed data from a gzip-format compressed file. +// +// In general, a gzip file can be a concatenation of gzip files, +// each with its own header. Reads from the Reader +// return the concatenation of the uncompressed data of each. +// Only the first header is recorded in the Reader fields. +// +// Gzip files store a length and checksum of the uncompressed data. +// The Reader will return a ErrChecksum when Read +// reaches the end of the uncompressed data if it does not +// have the expected length or checksum. Clients should treat data +// returned by Read as tentative until they receive the io.EOF +// marking the end of the data. +type Reader struct { + Header + r flate.Reader + decompressor io.ReadCloser + digest hash.Hash32 + size uint32 + flg byte + buf [512]byte + err error + closeErr chan error + multistream bool + + readAhead chan read + roff int // read offset + current []byte + closeReader chan struct{} + lastBlock bool + blockSize int + blocks int + + activeRA bool // Indication if readahead is active + mu sync.Mutex // Lock for above + + blockPool chan []byte +} + +type read struct { + b []byte + err error +} + +// NewReader creates a new Reader reading the given reader. +// The implementation buffers input and may read more data than necessary from r. +// It is the caller's responsibility to call Close on the Reader when done. +func NewReader(r io.Reader) (*Reader, error) { + z := new(Reader) + z.blocks = defaultBlocks + z.blockSize = defaultBlockSize + z.r = makeReader(r) + z.digest = crc32.NewIEEE() + z.multistream = true + z.blockPool = make(chan []byte, z.blocks) + for i := 0; i < z.blocks; i++ { + z.blockPool <- make([]byte, z.blockSize) + } + if err := z.readHeader(true); err != nil { + return nil, err + } + return z, nil +} + +// NewReaderN creates a new Reader reading the given reader. +// The implementation buffers input and may read more data than necessary from r. +// It is the caller's responsibility to call Close on the Reader when done. +// +// With this you can control the approximate size of your blocks, +// as well as how many blocks you want to have prefetched. +// +// Default values for this is blockSize = 250000, blocks = 16, +// meaning up to 16 blocks of maximum 250000 bytes will be +// prefetched. +func NewReaderN(r io.Reader, blockSize, blocks int) (*Reader, error) { + z := new(Reader) + z.blocks = blocks + z.blockSize = blockSize + z.r = makeReader(r) + z.digest = crc32.NewIEEE() + z.multistream = true + + // Account for too small values + if z.blocks <= 0 { + z.blocks = defaultBlocks + } + if z.blockSize <= 512 { + z.blockSize = defaultBlockSize + } + z.blockPool = make(chan []byte, z.blocks) + for i := 0; i < z.blocks; i++ { + z.blockPool <- make([]byte, z.blockSize) + } + if err := z.readHeader(true); err != nil { + return nil, err + } + return z, nil +} + +// Reset discards the Reader z's state and makes it equivalent to the +// result of its original state from NewReader, but reading from r instead. +// This permits reusing a Reader rather than allocating a new one. +func (z *Reader) Reset(r io.Reader) error { + z.killReadAhead() + z.r = makeReader(r) + z.digest = crc32.NewIEEE() + z.size = 0 + z.err = nil + z.multistream = true + + // Account for uninitialized values + if z.blocks <= 0 { + z.blocks = defaultBlocks + } + if z.blockSize <= 512 { + z.blockSize = defaultBlockSize + } + + if z.blockPool == nil { + z.blockPool = make(chan []byte, z.blocks) + for i := 0; i < z.blocks; i++ { + z.blockPool <- make([]byte, z.blockSize) + } + } + + return z.readHeader(true) +} + +// Multistream controls whether the reader supports multistream files. +// +// If enabled (the default), the Reader expects the input to be a sequence +// of individually gzipped data streams, each with its own header and +// trailer, ending at EOF. The effect is that the concatenation of a sequence +// of gzipped files is treated as equivalent to the gzip of the concatenation +// of the sequence. This is standard behavior for gzip readers. +// +// Calling Multistream(false) disables this behavior; disabling the behavior +// can be useful when reading file formats that distinguish individual gzip +// data streams or mix gzip data streams with other data streams. +// In this mode, when the Reader reaches the end of the data stream, +// Read returns io.EOF. If the underlying reader implements io.ByteReader, +// it will be left positioned just after the gzip stream. +// To start the next stream, call z.Reset(r) followed by z.Multistream(false). +// If there is no next stream, z.Reset(r) will return io.EOF. +func (z *Reader) Multistream(ok bool) { + z.multistream = ok +} + +// GZIP (RFC 1952) is little-endian, unlike ZLIB (RFC 1950). +func get4(p []byte) uint32 { + return uint32(p[0]) | uint32(p[1])<<8 | uint32(p[2])<<16 | uint32(p[3])<<24 +} + +func (z *Reader) readString() (string, error) { + var err error + needconv := false + for i := 0; ; i++ { + if i >= len(z.buf) { + return "", ErrHeader + } + z.buf[i], err = z.r.ReadByte() + if err != nil { + return "", err + } + if z.buf[i] > 0x7f { + needconv = true + } + if z.buf[i] == 0 { + // GZIP (RFC 1952) specifies that strings are NUL-terminated ISO 8859-1 (Latin-1). + if needconv { + s := make([]rune, 0, i) + for _, v := range z.buf[0:i] { + s = append(s, rune(v)) + } + return string(s), nil + } + return string(z.buf[0:i]), nil + } + } +} + +func (z *Reader) read2() (uint32, error) { + _, err := io.ReadFull(z.r, z.buf[0:2]) + if err != nil { + return 0, err + } + return uint32(z.buf[0]) | uint32(z.buf[1])<<8, nil +} + +func (z *Reader) readHeader(save bool) error { + z.killReadAhead() + + _, err := io.ReadFull(z.r, z.buf[0:10]) + if err != nil { + return err + } + if z.buf[0] != gzipID1 || z.buf[1] != gzipID2 || z.buf[2] != gzipDeflate { + return ErrHeader + } + z.flg = z.buf[3] + if save { + z.ModTime = time.Unix(int64(get4(z.buf[4:8])), 0) + // z.buf[8] is xfl, ignored + z.OS = z.buf[9] + } + z.digest.Reset() + z.digest.Write(z.buf[0:10]) + + if z.flg&flagExtra != 0 { + n, err := z.read2() + if err != nil { + return err + } + data := make([]byte, n) + if _, err = io.ReadFull(z.r, data); err != nil { + return err + } + if save { + z.Extra = data + } + } + + var s string + if z.flg&flagName != 0 { + if s, err = z.readString(); err != nil { + return err + } + if save { + z.Name = s + } + } + + if z.flg&flagComment != 0 { + if s, err = z.readString(); err != nil { + return err + } + if save { + z.Comment = s + } + } + + if z.flg&flagHdrCrc != 0 { + n, err := z.read2() + if err != nil { + return err + } + sum := z.digest.Sum32() & 0xFFFF + if n != sum { + return ErrHeader + } + } + + z.digest.Reset() + z.decompressor = flate.NewReader(z.r) + z.doReadAhead() + return nil +} + +func (z *Reader) killReadAhead() error { + z.mu.Lock() + defer z.mu.Unlock() + if z.activeRA { + if z.closeReader != nil { + close(z.closeReader) + } + + // Wait for decompressor to be closed and return error, if any. + e, ok := <-z.closeErr + z.activeRA = false + if !ok { + // Channel is closed, so if there was any error it has already been returned. + return nil + } + return e + } + return nil +} + +// Starts readahead. +// Will return on error (including io.EOF) +// or when z.closeReader is closed. +func (z *Reader) doReadAhead() { + z.mu.Lock() + defer z.mu.Unlock() + z.activeRA = true + + if z.blocks <= 0 { + z.blocks = defaultBlocks + } + if z.blockSize <= 512 { + z.blockSize = defaultBlockSize + } + ra := make(chan read, z.blocks) + z.readAhead = ra + closeReader := make(chan struct{}, 0) + z.closeReader = closeReader + z.lastBlock = false + closeErr := make(chan error, 1) + z.closeErr = closeErr + z.size = 0 + z.roff = 0 + z.current = nil + decomp := z.decompressor + + go func() { + defer func() { + closeErr <- decomp.Close() + close(closeErr) + close(ra) + }() + + // We hold a local reference to digest, since + // it way be changed by reset. + digest := z.digest + var wg sync.WaitGroup + for { + var buf []byte + select { + case buf = <-z.blockPool: + case <-closeReader: + return + } + buf = buf[0:z.blockSize] + // Try to fill the buffer + n, err := io.ReadFull(decomp, buf) + if err == io.ErrUnexpectedEOF { + err = nil + } + if n < len(buf) { + buf = buf[0:n] + } + wg.Wait() + wg.Add(1) + go func() { + digest.Write(buf) + wg.Done() + }() + z.size += uint32(n) + + // If we return any error, out digest must be ready + if err != nil { + wg.Wait() + } + select { + case z.readAhead <- read{b: buf, err: err}: + case <-closeReader: + // Sent on close, we don't care about the next results + return + } + if err != nil { + return + } + } + }() +} + +func (z *Reader) Read(p []byte) (n int, err error) { + if z.err != nil { + return 0, z.err + } + if len(p) == 0 { + return 0, nil + } + + for { + if len(z.current) == 0 && !z.lastBlock { + read := <-z.readAhead + + if read.err != nil { + // If not nil, the reader will have exited + z.closeReader = nil + + if read.err != io.EOF { + z.err = read.err + return + } + if read.err == io.EOF { + z.lastBlock = true + err = nil + } + } + z.current = read.b + z.roff = 0 + } + avail := z.current[z.roff:] + if len(p) >= len(avail) { + // If len(p) >= len(current), return all content of current + n = copy(p, avail) + z.blockPool <- z.current + z.current = nil + if z.lastBlock { + err = io.EOF + break + } + } else { + // We copy as much as there is space for + n = copy(p, avail) + z.roff += n + } + return + } + + // Finished file; check checksum + size. + if _, err := io.ReadFull(z.r, z.buf[0:8]); err != nil { + z.err = err + return 0, err + } + crc32, isize := get4(z.buf[0:4]), get4(z.buf[4:8]) + sum := z.digest.Sum32() + if sum != crc32 || isize != z.size { + z.err = ErrChecksum + return 0, z.err + } + + // File is ok; should we attempt reading one more? + if !z.multistream { + return 0, io.EOF + } + + // Is there another? + if err = z.readHeader(false); err != nil { + z.err = err + return + } + + // Yes. Reset and read from it. + return z.Read(p) +} + +func (z *Reader) WriteTo(w io.Writer) (n int64, err error) { + total := int64(0) + for { + if z.err != nil { + return total, z.err + } + // We write both to output and digest. + for { + // Read from input + read := <-z.readAhead + if read.err != nil { + // If not nil, the reader will have exited + z.closeReader = nil + + if read.err != io.EOF { + z.err = read.err + return total, z.err + } + if read.err == io.EOF { + z.lastBlock = true + err = nil + } + } + // Write what we got + n, err := w.Write(read.b) + if n != len(read.b) { + return total, io.ErrShortWrite + } + total += int64(n) + if err != nil { + return total, err + } + // Put block back + z.blockPool <- read.b + if z.lastBlock { + break + } + } + + // Finished file; check checksum + size. + if _, err := io.ReadFull(z.r, z.buf[0:8]); err != nil { + z.err = err + return total, err + } + crc32, isize := get4(z.buf[0:4]), get4(z.buf[4:8]) + sum := z.digest.Sum32() + if sum != crc32 || isize != z.size { + z.err = ErrChecksum + return total, z.err + } + // File is ok; should we attempt reading one more? + if !z.multistream { + return total, nil + } + + // Is there another? + err = z.readHeader(false) + if err == io.EOF { + return total, nil + } + if err != nil { + z.err = err + return total, err + } + } +} + +// Close closes the Reader. It does not close the underlying io.Reader. +func (z *Reader) Close() error { + return z.killReadAhead() +} diff --git a/vendor/github.com/klauspost/pgzip/gzip.go b/vendor/github.com/klauspost/pgzip/gzip.go new file mode 100644 index 0000000000..872afe7eb0 --- /dev/null +++ b/vendor/github.com/klauspost/pgzip/gzip.go @@ -0,0 +1,485 @@ +// 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. + +package pgzip + +import ( + "bytes" + "errors" + "fmt" + "hash" + "io" + "sync" + + "github.com/klauspost/compress/flate" + "github.com/klauspost/crc32" +) + +const ( + defaultBlockSize = 250000 + tailSize = 16384 + defaultBlocks = 16 +) + +// These constants are copied from the flate package, so that code that imports +// "compress/gzip" does not also have to import "compress/flate". +const ( + NoCompression = flate.NoCompression + BestSpeed = flate.BestSpeed + BestCompression = flate.BestCompression + DefaultCompression = flate.DefaultCompression + ConstantCompression = flate.ConstantCompression +) + +// A Writer is an io.WriteCloser. +// Writes to a Writer are compressed and written to w. +type Writer struct { + Header + w io.Writer + level int + wroteHeader bool + blockSize int + blocks int + currentBuffer []byte + prevTail []byte + digest hash.Hash32 + size int + closed bool + buf [10]byte + err error + pushedErr chan error + results chan result + dictFlatePool *sync.Pool + dstPool *sync.Pool +} + +type result struct { + result chan []byte + notifyWritten chan struct{} +} + +// Use SetConcurrency to finetune the concurrency level if needed. +// +// With this you can control the approximate size of your blocks, +// as well as how many you want to be processing in parallel. +// +// Default values for this is SetConcurrency(250000, 16), +// meaning blocks are split at 250000 bytes and up to 16 blocks +// can be processing at once before the writer blocks. +func (z *Writer) SetConcurrency(blockSize, blocks int) error { + if blockSize <= tailSize { + return fmt.Errorf("gzip: block size cannot be less than or equal to %d", tailSize) + } + if blocks <= 0 { + return errors.New("gzip: blocks cannot be zero or less") + } + z.blockSize = blockSize + z.results = make(chan result, blocks) + z.blocks = blocks + return nil +} + +// NewWriter returns a new Writer. +// Writes to the returned writer are compressed and written to w. +// +// It is the caller's responsibility to call Close on the WriteCloser when done. +// Writes may be buffered and not flushed until Close. +// +// Callers that wish to set the fields in Writer.Header must do so before +// the first call to Write or Close. The Comment and Name header fields are +// UTF-8 strings in Go, but the underlying format requires NUL-terminated ISO +// 8859-1 (Latin-1). NUL or non-Latin-1 runes in those strings will lead to an +// error on Write. +func NewWriter(w io.Writer) *Writer { + z, _ := NewWriterLevel(w, DefaultCompression) + return z +} + +// NewWriterLevel is like NewWriter but specifies the compression level instead +// of assuming DefaultCompression. +// +// The compression level can be DefaultCompression, NoCompression, or any +// integer value between BestSpeed and BestCompression inclusive. The error +// returned will be nil if the level is valid. +func NewWriterLevel(w io.Writer, level int) (*Writer, error) { + if level < ConstantCompression || level > BestCompression { + return nil, fmt.Errorf("gzip: invalid compression level: %d", level) + } + z := new(Writer) + z.SetConcurrency(defaultBlockSize, defaultBlocks) + z.init(w, level) + return z, nil +} + +// This function must be used by goroutines to set an +// error condition, since z.err access is restricted +// to the callers goruotine. +func (z *Writer) pushError(err error) { + z.pushedErr <- err + close(z.pushedErr) +} + +func (z *Writer) init(w io.Writer, level int) { + digest := z.digest + if digest != nil { + digest.Reset() + } else { + digest = crc32.NewIEEE() + } + + *z = Writer{ + Header: Header{ + OS: 255, // unknown + }, + w: w, + level: level, + digest: digest, + pushedErr: make(chan error, 1), + results: make(chan result, z.blocks), + blockSize: z.blockSize, + blocks: z.blocks, + } + z.dictFlatePool = &sync.Pool{ + New: func() interface{} { + f, _ := flate.NewWriterDict(w, level, nil) + return f + }, + } + z.dstPool = &sync.Pool{New: func() interface{} { return make([]byte, 0, z.blockSize) }} + +} + +// Reset discards the Writer z's state and makes it equivalent to the +// result of its original state from NewWriter or NewWriterLevel, but +// writing to w instead. This permits reusing a Writer rather than +// allocating a new one. +func (z *Writer) Reset(w io.Writer) { + if z.results != nil && !z.closed { + close(z.results) + } + z.SetConcurrency(defaultBlockSize, defaultBlocks) + z.init(w, z.level) +} + +// GZIP (RFC 1952) is little-endian, unlike ZLIB (RFC 1950). +func put2(p []byte, v uint16) { + p[0] = uint8(v >> 0) + p[1] = uint8(v >> 8) +} + +func put4(p []byte, v uint32) { + p[0] = uint8(v >> 0) + p[1] = uint8(v >> 8) + p[2] = uint8(v >> 16) + p[3] = uint8(v >> 24) +} + +// writeBytes writes a length-prefixed byte slice to z.w. +func (z *Writer) writeBytes(b []byte) error { + if len(b) > 0xffff { + return errors.New("gzip.Write: Extra data is too large") + } + put2(z.buf[0:2], uint16(len(b))) + _, err := z.w.Write(z.buf[0:2]) + if err != nil { + return err + } + _, err = z.w.Write(b) + return err +} + +// writeString writes a UTF-8 string s in GZIP's format to z.w. +// GZIP (RFC 1952) specifies that strings are NUL-terminated ISO 8859-1 (Latin-1). +func (z *Writer) writeString(s string) (err error) { + // GZIP stores Latin-1 strings; error if non-Latin-1; convert if non-ASCII. + needconv := false + for _, v := range s { + if v == 0 || v > 0xff { + return errors.New("gzip.Write: non-Latin-1 header string") + } + if v > 0x7f { + needconv = true + } + } + if needconv { + b := make([]byte, 0, len(s)) + for _, v := range s { + b = append(b, byte(v)) + } + _, err = z.w.Write(b) + } else { + _, err = io.WriteString(z.w, s) + } + if err != nil { + return err + } + // GZIP strings are NUL-terminated. + z.buf[0] = 0 + _, err = z.w.Write(z.buf[0:1]) + return err +} + +// compressCurrent will compress the data currently buffered +// This should only be called from the main writer/flush/closer +func (z *Writer) compressCurrent(flush bool) { + r := result{} + r.result = make(chan []byte, 1) + r.notifyWritten = make(chan struct{}, 0) + z.results <- r + + // If block given is more than twice the block size, split it. + c := z.currentBuffer + if len(c) > z.blockSize*2 { + c = c[:z.blockSize] + go compressBlock(c, z.prevTail, *z, r) + z.prevTail = c[len(c)-tailSize:] + z.currentBuffer = z.currentBuffer[z.blockSize:] + z.compressCurrent(flush) + // Last one flushes if needed + return + } + + go compressBlock(c, z.prevTail, *z, r) + if len(c) > tailSize { + z.prevTail = c[len(c)-tailSize:] + } else { + z.prevTail = nil + } + z.currentBuffer = make([]byte, 0, z.blockSize+(z.blockSize/4)) + + // Wait if flushing + if flush { + _ = <-r.notifyWritten + } +} + +// Returns an error if it has been set. +// Cannot be used by functions that are from internal goroutines. +func (z *Writer) checkError() error { + if z.err != nil { + return z.err + } + select { + case err := <-z.pushedErr: + z.err = err + default: + } + return z.err +} + +// Write writes a compressed form of p to the underlying io.Writer. The +// compressed bytes are not necessarily flushed to output until +// the Writer is closed or Flush() is called. +// +// The function will return quickly, if there are unused buffers. +// The sent slice (p) is copied, and the caller is free to re-use the buffer +// when the function returns. +// +// Errors that occur during compression will be reported later, and a nil error +// does not signify that the compression succeeded (since it is most likely still running) +// That means that the call that returns an error may not be the call that caused it. +// Only Flush and Close functions are guaranteed to return any errors up to that point. +func (z *Writer) Write(p []byte) (int, error) { + if z.checkError() != nil { + return 0, z.err + } + // Write the GZIP header lazily. + if !z.wroteHeader { + z.wroteHeader = true + z.buf[0] = gzipID1 + z.buf[1] = gzipID2 + z.buf[2] = gzipDeflate + z.buf[3] = 0 + if z.Extra != nil { + z.buf[3] |= 0x04 + } + if z.Name != "" { + z.buf[3] |= 0x08 + } + if z.Comment != "" { + z.buf[3] |= 0x10 + } + put4(z.buf[4:8], uint32(z.ModTime.Unix())) + if z.level == BestCompression { + z.buf[8] = 2 + } else if z.level == BestSpeed { + z.buf[8] = 4 + } else { + z.buf[8] = 0 + } + z.buf[9] = z.OS + var n int + n, z.err = z.w.Write(z.buf[0:10]) + if z.err != nil { + return n, z.err + } + if z.Extra != nil { + z.err = z.writeBytes(z.Extra) + if z.err != nil { + return n, z.err + } + } + if z.Name != "" { + z.err = z.writeString(z.Name) + if z.err != nil { + return n, z.err + } + } + if z.Comment != "" { + z.err = z.writeString(z.Comment) + if z.err != nil { + return n, z.err + } + } + // Start receiving data from compressors + go func() { + listen := z.results + for { + r, ok := <-listen + // If closed, we are finished. + if !ok { + return + } + buf := <-r.result + n, err := z.w.Write(buf) + if err != nil { + z.pushError(err) + close(r.notifyWritten) + return + } + if n != len(buf) { + z.pushError(fmt.Errorf("gzip: short write %d should be %d", n, len(buf))) + close(r.notifyWritten) + return + } + z.dstPool.Put(buf) + close(r.notifyWritten) + } + }() + z.currentBuffer = make([]byte, 0, z.blockSize+(z.blockSize/4)) + } + // Handle very large writes in a loop + if len(p) > z.blockSize*z.blocks { + q := p + for len(q) > 0 { + length := len(q) + if length > z.blockSize { + length = z.blockSize + } + z.digest.Write(q[:length]) + z.currentBuffer = append(z.currentBuffer, q[:length]...) + if len(z.currentBuffer) >= z.blockSize { + z.compressCurrent(false) + if z.err != nil { + return len(p) - len(q) - length, z.err + } + } + z.size += length + q = q[length:] + } + return len(p), z.err + } else { + z.size += len(p) + z.digest.Write(p) + z.currentBuffer = append(z.currentBuffer, p...) + if len(z.currentBuffer) >= z.blockSize { + z.compressCurrent(false) + } + return len(p), z.err + } +} + +// Step 1: compresses buffer to buffer +// Step 2: send writer to channel +// Step 3: Close result channel to indicate we are done +func compressBlock(p, prevTail []byte, z Writer, r result) { + defer close(r.result) + buf := z.dstPool.Get().([]byte) + dest := bytes.NewBuffer(buf[:0]) + + compressor := z.dictFlatePool.Get().(*flate.Writer) + compressor.ResetDict(dest, prevTail) + compressor.Write(p) + + err := compressor.Flush() + if err != nil { + z.pushError(err) + return + } + if z.closed { + err = compressor.Close() + if err != nil { + z.pushError(err) + return + } + } + z.dictFlatePool.Put(compressor) + // Read back buffer + buf = dest.Bytes() + r.result <- buf +} + +// Flush flushes any pending compressed data to the underlying writer. +// +// It is useful mainly in compressed network protocols, to ensure that +// a remote reader has enough data to reconstruct a packet. Flush does +// not return until the data has been written. If the underlying +// writer returns an error, Flush returns that error. +// +// In the terminology of the zlib library, Flush is equivalent to Z_SYNC_FLUSH. +func (z *Writer) Flush() error { + if z.checkError() != nil { + return z.err + } + if z.closed { + return nil + } + if !z.wroteHeader { + _, err := z.Write(nil) + if err != nil { + return err + } + } + // We send current block to compression + z.compressCurrent(true) + if z.checkError() != nil { + return z.err + } + + return nil +} + +// UncompressedSize will return the number of bytes written. +// pgzip only, not a function in the official gzip package. +func (z Writer) UncompressedSize() int { + return z.size +} + +// Close closes the Writer, flushing any unwritten data to the underlying +// io.Writer, but does not close the underlying io.Writer. +func (z *Writer) Close() error { + if z.checkError() != nil { + return z.err + } + if z.closed { + return nil + } + + z.closed = true + if !z.wroteHeader { + z.Write(nil) + if z.err != nil { + return z.err + } + } + z.compressCurrent(true) + if z.checkError() != nil { + return z.err + } + close(z.results) + put4(z.buf[0:4], z.digest.Sum32()) + put4(z.buf[4:8], uint32(z.size)) + _, z.err = z.w.Write(z.buf[0:8]) + return z.err +} diff --git a/vendor/github.com/kr/pty/License b/vendor/github.com/kr/pty/License new file mode 100644 index 0000000000..6b7558b6b4 --- /dev/null +++ b/vendor/github.com/kr/pty/License @@ -0,0 +1,23 @@ +Copyright (c) 2011 Keith Rarick + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall +be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/kr/pty/doc.go b/vendor/github.com/kr/pty/doc.go new file mode 100644 index 0000000000..190cfbea92 --- /dev/null +++ b/vendor/github.com/kr/pty/doc.go @@ -0,0 +1,16 @@ +// Package pty provides functions for working with Unix terminals. +package pty + +import ( + "errors" + "os" +) + +// ErrUnsupported is returned if a function is not +// available on the current platform. +var ErrUnsupported = errors.New("unsupported") + +// Opens a pty and its corresponding tty. +func Open() (pty, tty *os.File, err error) { + return open() +} diff --git a/vendor/github.com/kr/pty/ioctl.go b/vendor/github.com/kr/pty/ioctl.go new file mode 100644 index 0000000000..5b856e8711 --- /dev/null +++ b/vendor/github.com/kr/pty/ioctl.go @@ -0,0 +1,11 @@ +package pty + +import "syscall" + +func ioctl(fd, cmd, ptr uintptr) error { + _, _, e := syscall.Syscall(syscall.SYS_IOCTL, fd, cmd, ptr) + if e != 0 { + return e + } + return nil +} diff --git a/vendor/github.com/kr/pty/ioctl_bsd.go b/vendor/github.com/kr/pty/ioctl_bsd.go new file mode 100644 index 0000000000..73b12c53cf --- /dev/null +++ b/vendor/github.com/kr/pty/ioctl_bsd.go @@ -0,0 +1,39 @@ +// +build darwin dragonfly freebsd netbsd openbsd + +package pty + +// from +const ( + _IOC_VOID uintptr = 0x20000000 + _IOC_OUT uintptr = 0x40000000 + _IOC_IN uintptr = 0x80000000 + _IOC_IN_OUT uintptr = _IOC_OUT | _IOC_IN + _IOC_DIRMASK = _IOC_VOID | _IOC_OUT | _IOC_IN + + _IOC_PARAM_SHIFT = 13 + _IOC_PARAM_MASK = (1 << _IOC_PARAM_SHIFT) - 1 +) + +func _IOC_PARM_LEN(ioctl uintptr) uintptr { + return (ioctl >> 16) & _IOC_PARAM_MASK +} + +func _IOC(inout uintptr, group byte, ioctl_num uintptr, param_len uintptr) uintptr { + return inout | (param_len&_IOC_PARAM_MASK)<<16 | uintptr(group)<<8 | ioctl_num +} + +func _IO(group byte, ioctl_num uintptr) uintptr { + return _IOC(_IOC_VOID, group, ioctl_num, 0) +} + +func _IOR(group byte, ioctl_num uintptr, param_len uintptr) uintptr { + return _IOC(_IOC_OUT, group, ioctl_num, param_len) +} + +func _IOW(group byte, ioctl_num uintptr, param_len uintptr) uintptr { + return _IOC(_IOC_IN, group, ioctl_num, param_len) +} + +func _IOWR(group byte, ioctl_num uintptr, param_len uintptr) uintptr { + return _IOC(_IOC_IN_OUT, group, ioctl_num, param_len) +} diff --git a/vendor/github.com/kr/pty/pty_darwin.go b/vendor/github.com/kr/pty/pty_darwin.go new file mode 100644 index 0000000000..4f4d5ca26e --- /dev/null +++ b/vendor/github.com/kr/pty/pty_darwin.go @@ -0,0 +1,60 @@ +package pty + +import ( + "errors" + "os" + "syscall" + "unsafe" +) + +func open() (pty, tty *os.File, err error) { + p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0) + if err != nil { + return nil, nil, err + } + + sname, err := ptsname(p) + if err != nil { + return nil, nil, err + } + + err = grantpt(p) + if err != nil { + return nil, nil, err + } + + err = unlockpt(p) + if err != nil { + return nil, nil, err + } + + t, err := os.OpenFile(sname, os.O_RDWR, 0) + if err != nil { + return nil, nil, err + } + return p, t, nil +} + +func ptsname(f *os.File) (string, error) { + n := make([]byte, _IOC_PARM_LEN(syscall.TIOCPTYGNAME)) + + err := ioctl(f.Fd(), syscall.TIOCPTYGNAME, uintptr(unsafe.Pointer(&n[0]))) + if err != nil { + return "", err + } + + for i, c := range n { + if c == 0 { + return string(n[:i]), nil + } + } + return "", errors.New("TIOCPTYGNAME string not NUL-terminated") +} + +func grantpt(f *os.File) error { + return ioctl(f.Fd(), syscall.TIOCPTYGRANT, 0) +} + +func unlockpt(f *os.File) error { + return ioctl(f.Fd(), syscall.TIOCPTYUNLK, 0) +} diff --git a/vendor/github.com/kr/pty/pty_freebsd.go b/vendor/github.com/kr/pty/pty_freebsd.go new file mode 100644 index 0000000000..b341babd05 --- /dev/null +++ b/vendor/github.com/kr/pty/pty_freebsd.go @@ -0,0 +1,73 @@ +package pty + +import ( + "errors" + "os" + "syscall" + "unsafe" +) + +func posix_openpt(oflag int) (fd int, err error) { + r0, _, e1 := syscall.Syscall(syscall.SYS_POSIX_OPENPT, uintptr(oflag), 0, 0) + fd = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func open() (pty, tty *os.File, err error) { + fd, err := posix_openpt(syscall.O_RDWR | syscall.O_CLOEXEC) + if err != nil { + return nil, nil, err + } + + p := os.NewFile(uintptr(fd), "/dev/pts") + sname, err := ptsname(p) + if err != nil { + return nil, nil, err + } + + t, err := os.OpenFile("/dev/"+sname, os.O_RDWR, 0) + if err != nil { + return nil, nil, err + } + return p, t, nil +} + +func isptmaster(fd uintptr) (bool, error) { + err := ioctl(fd, syscall.TIOCPTMASTER, 0) + return err == nil, err +} + +var ( + emptyFiodgnameArg fiodgnameArg + ioctl_FIODGNAME = _IOW('f', 120, unsafe.Sizeof(emptyFiodgnameArg)) +) + +func ptsname(f *os.File) (string, error) { + master, err := isptmaster(f.Fd()) + if err != nil { + return "", err + } + if !master { + return "", syscall.EINVAL + } + + const n = _C_SPECNAMELEN + 1 + var ( + buf = make([]byte, n) + arg = fiodgnameArg{Len: n, Buf: (*byte)(unsafe.Pointer(&buf[0]))} + ) + err = ioctl(f.Fd(), ioctl_FIODGNAME, uintptr(unsafe.Pointer(&arg))) + if err != nil { + return "", err + } + + for i, c := range buf { + if c == 0 { + return string(buf[:i]), nil + } + } + return "", errors.New("FIODGNAME string not NUL-terminated") +} diff --git a/vendor/github.com/kr/pty/pty_linux.go b/vendor/github.com/kr/pty/pty_linux.go new file mode 100644 index 0000000000..cb901a21e0 --- /dev/null +++ b/vendor/github.com/kr/pty/pty_linux.go @@ -0,0 +1,46 @@ +package pty + +import ( + "os" + "strconv" + "syscall" + "unsafe" +) + +func open() (pty, tty *os.File, err error) { + p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0) + if err != nil { + return nil, nil, err + } + + sname, err := ptsname(p) + if err != nil { + return nil, nil, err + } + + err = unlockpt(p) + if err != nil { + return nil, nil, err + } + + t, err := os.OpenFile(sname, os.O_RDWR|syscall.O_NOCTTY, 0) + if err != nil { + return nil, nil, err + } + return p, t, nil +} + +func ptsname(f *os.File) (string, error) { + var n _C_uint + err := ioctl(f.Fd(), syscall.TIOCGPTN, uintptr(unsafe.Pointer(&n))) + if err != nil { + return "", err + } + return "/dev/pts/" + strconv.Itoa(int(n)), nil +} + +func unlockpt(f *os.File) error { + var u _C_int + // use TIOCSPTLCK with a zero valued arg to clear the slave pty lock + return ioctl(f.Fd(), syscall.TIOCSPTLCK, uintptr(unsafe.Pointer(&u))) +} diff --git a/vendor/github.com/kr/pty/pty_unsupported.go b/vendor/github.com/kr/pty/pty_unsupported.go new file mode 100644 index 0000000000..898c7303c4 --- /dev/null +++ b/vendor/github.com/kr/pty/pty_unsupported.go @@ -0,0 +1,11 @@ +// +build !linux,!darwin,!freebsd + +package pty + +import ( + "os" +) + +func open() (pty, tty *os.File, err error) { + return nil, nil, ErrUnsupported +} diff --git a/vendor/github.com/kr/pty/run.go b/vendor/github.com/kr/pty/run.go new file mode 100644 index 0000000000..c2bc48878c --- /dev/null +++ b/vendor/github.com/kr/pty/run.go @@ -0,0 +1,32 @@ +package pty + +import ( + "os" + "os/exec" + "syscall" +) + +// Start assigns a pseudo-terminal tty os.File to c.Stdin, c.Stdout, +// and c.Stderr, calls c.Start, and returns the File of the tty's +// corresponding pty. +func Start(c *exec.Cmd) (pty *os.File, err error) { + pty, tty, err := Open() + if err != nil { + return nil, err + } + defer tty.Close() + c.Stdout = tty + c.Stdin = tty + c.Stderr = tty + if c.SysProcAttr == nil { + c.SysProcAttr = &syscall.SysProcAttr{} + } + c.SysProcAttr.Setctty = true + c.SysProcAttr.Setsid = true + err = c.Start() + if err != nil { + pty.Close() + return nil, err + } + return pty, err +} diff --git a/vendor/github.com/kr/pty/types.go b/vendor/github.com/kr/pty/types.go new file mode 100644 index 0000000000..5aecb6bcdc --- /dev/null +++ b/vendor/github.com/kr/pty/types.go @@ -0,0 +1,10 @@ +// +build ignore + +package pty + +import "C" + +type ( + _C_int C.int + _C_uint C.uint +) diff --git a/vendor/github.com/kr/pty/types_freebsd.go b/vendor/github.com/kr/pty/types_freebsd.go new file mode 100644 index 0000000000..ce3eb95181 --- /dev/null +++ b/vendor/github.com/kr/pty/types_freebsd.go @@ -0,0 +1,15 @@ +// +build ignore + +package pty + +/* +#include +#include +*/ +import "C" + +const ( + _C_SPECNAMELEN = C.SPECNAMELEN /* max length of devicename */ +) + +type fiodgnameArg C.struct_fiodgname_arg diff --git a/vendor/github.com/kr/pty/util.go b/vendor/github.com/kr/pty/util.go new file mode 100644 index 0000000000..67c52d06cd --- /dev/null +++ b/vendor/github.com/kr/pty/util.go @@ -0,0 +1,35 @@ +package pty + +import ( + "os" + "syscall" + "unsafe" +) + +// Getsize returns the number of rows (lines) and cols (positions +// in each line) in terminal t. +func Getsize(t *os.File) (rows, cols int, err error) { + var ws winsize + err = windowrect(&ws, t.Fd()) + return int(ws.ws_row), int(ws.ws_col), err +} + +type winsize struct { + ws_row uint16 + ws_col uint16 + ws_xpixel uint16 + ws_ypixel uint16 +} + +func windowrect(ws *winsize, fd uintptr) error { + _, _, errno := syscall.Syscall( + syscall.SYS_IOCTL, + fd, + syscall.TIOCGWINSZ, + uintptr(unsafe.Pointer(ws)), + ) + if errno != 0 { + return syscall.Errno(errno) + } + return nil +} diff --git a/vendor/github.com/kr/pty/ztypes_386.go b/vendor/github.com/kr/pty/ztypes_386.go new file mode 100644 index 0000000000..ff0b8fd838 --- /dev/null +++ b/vendor/github.com/kr/pty/ztypes_386.go @@ -0,0 +1,9 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types.go + +package pty + +type ( + _C_int int32 + _C_uint uint32 +) diff --git a/vendor/github.com/kr/pty/ztypes_amd64.go b/vendor/github.com/kr/pty/ztypes_amd64.go new file mode 100644 index 0000000000..ff0b8fd838 --- /dev/null +++ b/vendor/github.com/kr/pty/ztypes_amd64.go @@ -0,0 +1,9 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types.go + +package pty + +type ( + _C_int int32 + _C_uint uint32 +) diff --git a/vendor/github.com/kr/pty/ztypes_arm.go b/vendor/github.com/kr/pty/ztypes_arm.go new file mode 100644 index 0000000000..ff0b8fd838 --- /dev/null +++ b/vendor/github.com/kr/pty/ztypes_arm.go @@ -0,0 +1,9 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types.go + +package pty + +type ( + _C_int int32 + _C_uint uint32 +) diff --git a/vendor/github.com/kr/pty/ztypes_arm64.go b/vendor/github.com/kr/pty/ztypes_arm64.go new file mode 100644 index 0000000000..6c29a4b918 --- /dev/null +++ b/vendor/github.com/kr/pty/ztypes_arm64.go @@ -0,0 +1,11 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types.go + +// +build arm64 + +package pty + +type ( + _C_int int32 + _C_uint uint32 +) diff --git a/vendor/github.com/kr/pty/ztypes_freebsd_386.go b/vendor/github.com/kr/pty/ztypes_freebsd_386.go new file mode 100644 index 0000000000..d9975374e3 --- /dev/null +++ b/vendor/github.com/kr/pty/ztypes_freebsd_386.go @@ -0,0 +1,13 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_freebsd.go + +package pty + +const ( + _C_SPECNAMELEN = 0x3f +) + +type fiodgnameArg struct { + Len int32 + Buf *byte +} diff --git a/vendor/github.com/kr/pty/ztypes_freebsd_amd64.go b/vendor/github.com/kr/pty/ztypes_freebsd_amd64.go new file mode 100644 index 0000000000..5fa102fcdf --- /dev/null +++ b/vendor/github.com/kr/pty/ztypes_freebsd_amd64.go @@ -0,0 +1,14 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_freebsd.go + +package pty + +const ( + _C_SPECNAMELEN = 0x3f +) + +type fiodgnameArg struct { + Len int32 + Pad_cgo_0 [4]byte + Buf *byte +} diff --git a/vendor/github.com/kr/pty/ztypes_freebsd_arm.go b/vendor/github.com/kr/pty/ztypes_freebsd_arm.go new file mode 100644 index 0000000000..d9975374e3 --- /dev/null +++ b/vendor/github.com/kr/pty/ztypes_freebsd_arm.go @@ -0,0 +1,13 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_freebsd.go + +package pty + +const ( + _C_SPECNAMELEN = 0x3f +) + +type fiodgnameArg struct { + Len int32 + Buf *byte +} diff --git a/vendor/github.com/kr/pty/ztypes_ppc64.go b/vendor/github.com/kr/pty/ztypes_ppc64.go new file mode 100644 index 0000000000..4e1af84312 --- /dev/null +++ b/vendor/github.com/kr/pty/ztypes_ppc64.go @@ -0,0 +1,11 @@ +// +build ppc64 + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types.go + +package pty + +type ( + _C_int int32 + _C_uint uint32 +) diff --git a/vendor/github.com/kr/pty/ztypes_ppc64le.go b/vendor/github.com/kr/pty/ztypes_ppc64le.go new file mode 100644 index 0000000000..e6780f4e23 --- /dev/null +++ b/vendor/github.com/kr/pty/ztypes_ppc64le.go @@ -0,0 +1,11 @@ +// +build ppc64le + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types.go + +package pty + +type ( + _C_int int32 + _C_uint uint32 +) diff --git a/vendor/github.com/kr/pty/ztypes_s390x.go b/vendor/github.com/kr/pty/ztypes_s390x.go new file mode 100644 index 0000000000..a7452b61cb --- /dev/null +++ b/vendor/github.com/kr/pty/ztypes_s390x.go @@ -0,0 +1,11 @@ +// +build s390x + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types.go + +package pty + +type ( + _C_int int32 + _C_uint uint32 +) diff --git a/vendor/github.com/pborman/uuid/LICENSE b/vendor/github.com/pborman/uuid/LICENSE new file mode 100644 index 0000000000..5dc68268d9 --- /dev/null +++ b/vendor/github.com/pborman/uuid/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2009,2014 Google Inc. 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. diff --git a/vendor/github.com/pborman/uuid/dce.go b/vendor/github.com/pborman/uuid/dce.go new file mode 100755 index 0000000000..50a0f2d099 --- /dev/null +++ b/vendor/github.com/pborman/uuid/dce.go @@ -0,0 +1,84 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import ( + "encoding/binary" + "fmt" + "os" +) + +// A Domain represents a Version 2 domain +type Domain byte + +// Domain constants for DCE Security (Version 2) UUIDs. +const ( + Person = Domain(0) + Group = Domain(1) + Org = Domain(2) +) + +// NewDCESecurity returns a DCE Security (Version 2) UUID. +// +// The domain should be one of Person, Group or Org. +// On a POSIX system the id should be the users UID for the Person +// domain and the users GID for the Group. The meaning of id for +// the domain Org or on non-POSIX systems is site defined. +// +// For a given domain/id pair the same token may be returned for up to +// 7 minutes and 10 seconds. +func NewDCESecurity(domain Domain, id uint32) UUID { + uuid := NewUUID() + if uuid != nil { + uuid[6] = (uuid[6] & 0x0f) | 0x20 // Version 2 + uuid[9] = byte(domain) + binary.BigEndian.PutUint32(uuid[0:], id) + } + return uuid +} + +// NewDCEPerson returns a DCE Security (Version 2) UUID in the person +// domain with the id returned by os.Getuid. +// +// NewDCEPerson(Person, uint32(os.Getuid())) +func NewDCEPerson() UUID { + return NewDCESecurity(Person, uint32(os.Getuid())) +} + +// NewDCEGroup returns a DCE Security (Version 2) UUID in the group +// domain with the id returned by os.Getgid. +// +// NewDCEGroup(Group, uint32(os.Getgid())) +func NewDCEGroup() UUID { + return NewDCESecurity(Group, uint32(os.Getgid())) +} + +// Domain returns the domain for a Version 2 UUID or false. +func (uuid UUID) Domain() (Domain, bool) { + if v, _ := uuid.Version(); v != 2 { + return 0, false + } + return Domain(uuid[9]), true +} + +// Id returns the id for a Version 2 UUID or false. +func (uuid UUID) Id() (uint32, bool) { + if v, _ := uuid.Version(); v != 2 { + return 0, false + } + return binary.BigEndian.Uint32(uuid[0:4]), true +} + +func (d Domain) String() string { + switch d { + case Person: + return "Person" + case Group: + return "Group" + case Org: + return "Org" + } + return fmt.Sprintf("Domain%d", int(d)) +} diff --git a/vendor/github.com/pborman/uuid/doc.go b/vendor/github.com/pborman/uuid/doc.go new file mode 100755 index 0000000000..d8bd013e68 --- /dev/null +++ b/vendor/github.com/pborman/uuid/doc.go @@ -0,0 +1,8 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// The uuid package generates and inspects UUIDs. +// +// UUIDs are based on RFC 4122 and DCE 1.1: Authentication and Security Services. +package uuid diff --git a/vendor/github.com/pborman/uuid/hash.go b/vendor/github.com/pborman/uuid/hash.go new file mode 100644 index 0000000000..cdd4192fd9 --- /dev/null +++ b/vendor/github.com/pborman/uuid/hash.go @@ -0,0 +1,53 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import ( + "crypto/md5" + "crypto/sha1" + "hash" +) + +// Well known Name Space IDs and UUIDs +var ( + NameSpace_DNS = Parse("6ba7b810-9dad-11d1-80b4-00c04fd430c8") + NameSpace_URL = Parse("6ba7b811-9dad-11d1-80b4-00c04fd430c8") + NameSpace_OID = Parse("6ba7b812-9dad-11d1-80b4-00c04fd430c8") + NameSpace_X500 = Parse("6ba7b814-9dad-11d1-80b4-00c04fd430c8") + NIL = Parse("00000000-0000-0000-0000-000000000000") +) + +// NewHash returns a new UUID dervied from the hash of space concatenated with +// data generated by h. The hash should be at least 16 byte in length. The +// first 16 bytes of the hash are used to form the UUID. The version of the +// UUID will be the lower 4 bits of version. NewHash is used to implement +// NewMD5 and NewSHA1. +func NewHash(h hash.Hash, space UUID, data []byte, version int) UUID { + h.Reset() + h.Write(space) + h.Write([]byte(data)) + s := h.Sum(nil) + uuid := make([]byte, 16) + copy(uuid, s) + uuid[6] = (uuid[6] & 0x0f) | uint8((version&0xf)<<4) + uuid[8] = (uuid[8] & 0x3f) | 0x80 // RFC 4122 variant + return uuid +} + +// NewMD5 returns a new MD5 (Version 3) UUID based on the +// supplied name space and data. +// +// NewHash(md5.New(), space, data, 3) +func NewMD5(space UUID, data []byte) UUID { + return NewHash(md5.New(), space, data, 3) +} + +// NewSHA1 returns a new SHA1 (Version 5) UUID based on the +// supplied name space and data. +// +// NewHash(sha1.New(), space, data, 5) +func NewSHA1(space UUID, data []byte) UUID { + return NewHash(sha1.New(), space, data, 5) +} diff --git a/vendor/github.com/pborman/uuid/json.go b/vendor/github.com/pborman/uuid/json.go new file mode 100644 index 0000000000..760580a504 --- /dev/null +++ b/vendor/github.com/pborman/uuid/json.go @@ -0,0 +1,30 @@ +// Copyright 2014 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import "errors" + +func (u UUID) MarshalJSON() ([]byte, error) { + if len(u) == 0 { + return []byte(`""`), nil + } + return []byte(`"` + u.String() + `"`), nil +} + +func (u *UUID) UnmarshalJSON(data []byte) error { + if len(data) == 0 || string(data) == `""` { + return nil + } + if len(data) < 2 || data[0] != '"' || data[len(data)-1] != '"' { + return errors.New("invalid UUID format") + } + data = data[1 : len(data)-1] + uu := Parse(string(data)) + if uu == nil { + return errors.New("invalid UUID format") + } + *u = uu + return nil +} diff --git a/vendor/github.com/pborman/uuid/node.go b/vendor/github.com/pborman/uuid/node.go new file mode 100755 index 0000000000..dd0a8ac189 --- /dev/null +++ b/vendor/github.com/pborman/uuid/node.go @@ -0,0 +1,101 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import "net" + +var ( + interfaces []net.Interface // cached list of interfaces + ifname string // name of interface being used + nodeID []byte // hardware for version 1 UUIDs +) + +// NodeInterface returns the name of the interface from which the NodeID was +// derived. The interface "user" is returned if the NodeID was set by +// SetNodeID. +func NodeInterface() string { + return ifname +} + +// SetNodeInterface selects the hardware address to be used for Version 1 UUIDs. +// If name is "" then the first usable interface found will be used or a random +// Node ID will be generated. If a named interface cannot be found then false +// is returned. +// +// SetNodeInterface never fails when name is "". +func SetNodeInterface(name string) bool { + if interfaces == nil { + var err error + interfaces, err = net.Interfaces() + if err != nil && name != "" { + return false + } + } + + for _, ifs := range interfaces { + if len(ifs.HardwareAddr) >= 6 && (name == "" || name == ifs.Name) { + if setNodeID(ifs.HardwareAddr) { + ifname = ifs.Name + return true + } + } + } + + // We found no interfaces with a valid hardware address. If name + // does not specify a specific interface generate a random Node ID + // (section 4.1.6) + if name == "" { + if nodeID == nil { + nodeID = make([]byte, 6) + } + randomBits(nodeID) + return true + } + return false +} + +// NodeID returns a slice of a copy of the current Node ID, setting the Node ID +// if not already set. +func NodeID() []byte { + if nodeID == nil { + SetNodeInterface("") + } + nid := make([]byte, 6) + copy(nid, nodeID) + return nid +} + +// SetNodeID sets the Node ID to be used for Version 1 UUIDs. The first 6 bytes +// of id are used. If id is less than 6 bytes then false is returned and the +// Node ID is not set. +func SetNodeID(id []byte) bool { + if setNodeID(id) { + ifname = "user" + return true + } + return false +} + +func setNodeID(id []byte) bool { + if len(id) < 6 { + return false + } + if nodeID == nil { + nodeID = make([]byte, 6) + } + copy(nodeID, id) + return true +} + +// NodeID returns the 6 byte node id encoded in uuid. It returns nil if uuid is +// not valid. The NodeID is only well defined for version 1 and 2 UUIDs. +func (uuid UUID) NodeID() []byte { + if len(uuid) != 16 { + return nil + } + node := make([]byte, 6) + copy(node, uuid[10:]) + return node +} diff --git a/vendor/github.com/pborman/uuid/sql.go b/vendor/github.com/pborman/uuid/sql.go new file mode 100644 index 0000000000..2d7679e2af --- /dev/null +++ b/vendor/github.com/pborman/uuid/sql.go @@ -0,0 +1,40 @@ +// Copyright 2015 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import ( + "errors" + "fmt" +) + +// Scan implements sql.Scanner so UUIDs can be read from databases transparently +// Currently, database types that map to string and []byte are supported. Please +// consult database-specific driver documentation for matching types. +func (uuid *UUID) Scan(src interface{}) error { + switch src.(type) { + case string: + // see uuid.Parse for required string format + parsed := Parse(src.(string)) + + if parsed == nil { + return errors.New("Scan: invalid UUID format") + } + + *uuid = parsed + case []byte: + // assumes a simple slice of bytes, just check validity and store + u := UUID(src.([]byte)) + + if u.Variant() == Invalid { + return errors.New("Scan: invalid UUID format") + } + + *uuid = u + default: + return fmt.Errorf("Scan: unable to scan type %T into UUID", src) + } + + return nil +} diff --git a/vendor/github.com/pborman/uuid/time.go b/vendor/github.com/pborman/uuid/time.go new file mode 100755 index 0000000000..7ebc9bef10 --- /dev/null +++ b/vendor/github.com/pborman/uuid/time.go @@ -0,0 +1,132 @@ +// Copyright 2014 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import ( + "encoding/binary" + "sync" + "time" +) + +// A Time represents a time as the number of 100's of nanoseconds since 15 Oct +// 1582. +type Time int64 + +const ( + lillian = 2299160 // Julian day of 15 Oct 1582 + unix = 2440587 // Julian day of 1 Jan 1970 + epoch = unix - lillian // Days between epochs + g1582 = epoch * 86400 // seconds between epochs + g1582ns100 = g1582 * 10000000 // 100s of a nanoseconds between epochs +) + +var ( + mu sync.Mutex + lasttime uint64 // last time we returned + clock_seq uint16 // clock sequence for this run + + timeNow = time.Now // for testing +) + +// UnixTime converts t the number of seconds and nanoseconds using the Unix +// epoch of 1 Jan 1970. +func (t Time) UnixTime() (sec, nsec int64) { + sec = int64(t - g1582ns100) + nsec = (sec % 10000000) * 100 + sec /= 10000000 + return sec, nsec +} + +// GetTime returns the current Time (100s of nanoseconds since 15 Oct 1582) and +// clock sequence as well as adjusting the clock sequence as needed. An error +// is returned if the current time cannot be determined. +func GetTime() (Time, uint16, error) { + defer mu.Unlock() + mu.Lock() + return getTime() +} + +func getTime() (Time, uint16, error) { + t := timeNow() + + // If we don't have a clock sequence already, set one. + if clock_seq == 0 { + setClockSequence(-1) + } + now := uint64(t.UnixNano()/100) + g1582ns100 + + // If time has gone backwards with this clock sequence then we + // increment the clock sequence + if now <= lasttime { + clock_seq = ((clock_seq + 1) & 0x3fff) | 0x8000 + } + lasttime = now + return Time(now), clock_seq, nil +} + +// ClockSequence returns the current clock sequence, generating one if not +// already set. The clock sequence is only used for Version 1 UUIDs. +// +// The uuid package does not use global static storage for the clock sequence or +// the last time a UUID was generated. Unless SetClockSequence a new random +// clock sequence is generated the first time a clock sequence is requested by +// ClockSequence, GetTime, or NewUUID. (section 4.2.1.1) sequence is generated +// for +func ClockSequence() int { + defer mu.Unlock() + mu.Lock() + return clockSequence() +} + +func clockSequence() int { + if clock_seq == 0 { + setClockSequence(-1) + } + return int(clock_seq & 0x3fff) +} + +// SetClockSeq sets the clock sequence to the lower 14 bits of seq. Setting to +// -1 causes a new sequence to be generated. +func SetClockSequence(seq int) { + defer mu.Unlock() + mu.Lock() + setClockSequence(seq) +} + +func setClockSequence(seq int) { + if seq == -1 { + var b [2]byte + randomBits(b[:]) // clock sequence + seq = int(b[0])<<8 | int(b[1]) + } + old_seq := clock_seq + clock_seq = uint16(seq&0x3fff) | 0x8000 // Set our variant + if old_seq != clock_seq { + lasttime = 0 + } +} + +// Time returns the time in 100s of nanoseconds since 15 Oct 1582 encoded in +// uuid. It returns false if uuid is not valid. The time is only well defined +// for version 1 and 2 UUIDs. +func (uuid UUID) Time() (Time, bool) { + if len(uuid) != 16 { + return 0, false + } + time := int64(binary.BigEndian.Uint32(uuid[0:4])) + time |= int64(binary.BigEndian.Uint16(uuid[4:6])) << 32 + time |= int64(binary.BigEndian.Uint16(uuid[6:8])&0xfff) << 48 + return Time(time), true +} + +// ClockSequence returns the clock sequence encoded in uuid. It returns false +// if uuid is not valid. The clock sequence is only well defined for version 1 +// and 2 UUIDs. +func (uuid UUID) ClockSequence() (int, bool) { + if len(uuid) != 16 { + return 0, false + } + return int(binary.BigEndian.Uint16(uuid[8:10])) & 0x3fff, true +} diff --git a/vendor/github.com/pborman/uuid/util.go b/vendor/github.com/pborman/uuid/util.go new file mode 100644 index 0000000000..de40b102c4 --- /dev/null +++ b/vendor/github.com/pborman/uuid/util.go @@ -0,0 +1,43 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import ( + "io" +) + +// randomBits completely fills slice b with random data. +func randomBits(b []byte) { + if _, err := io.ReadFull(rander, b); err != nil { + panic(err.Error()) // rand should never fail + } +} + +// xvalues returns the value of a byte as a hexadecimal digit or 255. +var xvalues = []byte{ + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 255, 255, 255, 255, 255, 255, + 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, +} + +// xtob converts the the first two hex bytes of x into a byte. +func xtob(x string) (byte, bool) { + b1 := xvalues[x[0]] + b2 := xvalues[x[1]] + return (b1 << 4) | b2, b1 != 255 && b2 != 255 +} diff --git a/vendor/github.com/pborman/uuid/uuid.go b/vendor/github.com/pborman/uuid/uuid.go new file mode 100755 index 0000000000..2920fae632 --- /dev/null +++ b/vendor/github.com/pborman/uuid/uuid.go @@ -0,0 +1,163 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import ( + "bytes" + "crypto/rand" + "fmt" + "io" + "strings" +) + +// A UUID is a 128 bit (16 byte) Universal Unique IDentifier as defined in RFC +// 4122. +type UUID []byte + +// A Version represents a UUIDs version. +type Version byte + +// A Variant represents a UUIDs variant. +type Variant byte + +// Constants returned by Variant. +const ( + Invalid = Variant(iota) // Invalid UUID + RFC4122 // The variant specified in RFC4122 + Reserved // Reserved, NCS backward compatibility. + Microsoft // Reserved, Microsoft Corporation backward compatibility. + Future // Reserved for future definition. +) + +var rander = rand.Reader // random function + +// New returns a new random (version 4) UUID as a string. It is a convenience +// function for NewRandom().String(). +func New() string { + return NewRandom().String() +} + +// Parse decodes s into a UUID or returns nil. Both the UUID form of +// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and +// urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx are decoded. +func Parse(s string) UUID { + if len(s) == 36+9 { + if strings.ToLower(s[:9]) != "urn:uuid:" { + return nil + } + s = s[9:] + } else if len(s) != 36 { + return nil + } + if s[8] != '-' || s[13] != '-' || s[18] != '-' || s[23] != '-' { + return nil + } + uuid := make([]byte, 16) + for i, x := range []int{ + 0, 2, 4, 6, + 9, 11, + 14, 16, + 19, 21, + 24, 26, 28, 30, 32, 34} { + if v, ok := xtob(s[x:]); !ok { + return nil + } else { + uuid[i] = v + } + } + return uuid +} + +// Equal returns true if uuid1 and uuid2 are equal. +func Equal(uuid1, uuid2 UUID) bool { + return bytes.Equal(uuid1, uuid2) +} + +// String returns the string form of uuid, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx +// , or "" if uuid is invalid. +func (uuid UUID) String() string { + if uuid == nil || len(uuid) != 16 { + return "" + } + b := []byte(uuid) + return fmt.Sprintf("%08x-%04x-%04x-%04x-%012x", + b[:4], b[4:6], b[6:8], b[8:10], b[10:]) +} + +// URN returns the RFC 2141 URN form of uuid, +// urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, or "" if uuid is invalid. +func (uuid UUID) URN() string { + if uuid == nil || len(uuid) != 16 { + return "" + } + b := []byte(uuid) + return fmt.Sprintf("urn:uuid:%08x-%04x-%04x-%04x-%012x", + b[:4], b[4:6], b[6:8], b[8:10], b[10:]) +} + +// Variant returns the variant encoded in uuid. It returns Invalid if +// uuid is invalid. +func (uuid UUID) Variant() Variant { + if len(uuid) != 16 { + return Invalid + } + switch { + case (uuid[8] & 0xc0) == 0x80: + return RFC4122 + case (uuid[8] & 0xe0) == 0xc0: + return Microsoft + case (uuid[8] & 0xe0) == 0xe0: + return Future + default: + return Reserved + } + panic("unreachable") +} + +// Version returns the verison of uuid. It returns false if uuid is not +// valid. +func (uuid UUID) Version() (Version, bool) { + if len(uuid) != 16 { + return 0, false + } + return Version(uuid[6] >> 4), true +} + +func (v Version) String() string { + if v > 15 { + return fmt.Sprintf("BAD_VERSION_%d", v) + } + return fmt.Sprintf("VERSION_%d", v) +} + +func (v Variant) String() string { + switch v { + case RFC4122: + return "RFC4122" + case Reserved: + return "Reserved" + case Microsoft: + return "Microsoft" + case Future: + return "Future" + case Invalid: + return "Invalid" + } + return fmt.Sprintf("BadVariant%d", int(v)) +} + +// SetRand sets the random number generator to r, which implents io.Reader. +// If r.Read returns an error when the package requests random data then +// a panic will be issued. +// +// Calling SetRand with nil sets the random number generator to the default +// generator. +func SetRand(r io.Reader) { + if r == nil { + rander = rand.Reader + return + } + rander = r +} diff --git a/vendor/github.com/pborman/uuid/version1.go b/vendor/github.com/pborman/uuid/version1.go new file mode 100644 index 0000000000..0127eacfab --- /dev/null +++ b/vendor/github.com/pborman/uuid/version1.go @@ -0,0 +1,41 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import ( + "encoding/binary" +) + +// NewUUID returns a Version 1 UUID based on the current NodeID and clock +// sequence, and the current time. If the NodeID has not been set by SetNodeID +// or SetNodeInterface then it will be set automatically. If the NodeID cannot +// be set NewUUID returns nil. If clock sequence has not been set by +// SetClockSequence then it will be set automatically. If GetTime fails to +// return the current NewUUID returns nil. +func NewUUID() UUID { + if nodeID == nil { + SetNodeInterface("") + } + + now, seq, err := GetTime() + if err != nil { + return nil + } + + uuid := make([]byte, 16) + + time_low := uint32(now & 0xffffffff) + time_mid := uint16((now >> 32) & 0xffff) + time_hi := uint16((now >> 48) & 0x0fff) + time_hi |= 0x1000 // Version 1 + + binary.BigEndian.PutUint32(uuid[0:], time_low) + binary.BigEndian.PutUint16(uuid[4:], time_mid) + binary.BigEndian.PutUint16(uuid[6:], time_hi) + binary.BigEndian.PutUint16(uuid[8:], seq) + copy(uuid[10:], nodeID) + + return uuid +} diff --git a/vendor/github.com/pborman/uuid/version4.go b/vendor/github.com/pborman/uuid/version4.go new file mode 100644 index 0000000000..b3d4a368dd --- /dev/null +++ b/vendor/github.com/pborman/uuid/version4.go @@ -0,0 +1,25 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +// Random returns a Random (Version 4) UUID or panics. +// +// The strength of the UUIDs is based on the strength of the crypto/rand +// package. +// +// A note about uniqueness derived from from the UUID Wikipedia entry: +// +// Randomly generated UUIDs have 122 random bits. One's annual risk of being +// hit by a meteorite is estimated to be one chance in 17 billion, that +// means the probability is about 0.00000000006 (6 × 10−11), +// equivalent to the odds of creating a few tens of trillions of UUIDs in a +// year and having one duplicate. +func NewRandom() UUID { + uuid := make([]byte, 16) + randomBits([]byte(uuid)) + uuid[6] = (uuid[6] & 0x0f) | 0x40 // Version 4 + uuid[8] = (uuid[8] & 0x3f) | 0x80 // Variant is 10 + return uuid +} diff --git a/vendor/github.com/peterbourgon/diskv/LICENSE b/vendor/github.com/peterbourgon/diskv/LICENSE new file mode 100644 index 0000000000..41ce7f16e1 --- /dev/null +++ b/vendor/github.com/peterbourgon/diskv/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2011-2012 Peter Bourgon + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/github.com/peterbourgon/diskv/compression.go b/vendor/github.com/peterbourgon/diskv/compression.go new file mode 100644 index 0000000000..5192b02733 --- /dev/null +++ b/vendor/github.com/peterbourgon/diskv/compression.go @@ -0,0 +1,64 @@ +package diskv + +import ( + "compress/flate" + "compress/gzip" + "compress/zlib" + "io" +) + +// Compression is an interface that Diskv uses to implement compression of +// data. Writer takes a destination io.Writer and returns a WriteCloser that +// compresses all data written through it. Reader takes a source io.Reader and +// returns a ReadCloser that decompresses all data read through it. You may +// define these methods on your own type, or use one of the NewCompression +// helpers. +type Compression interface { + Writer(dst io.Writer) (io.WriteCloser, error) + Reader(src io.Reader) (io.ReadCloser, error) +} + +// NewGzipCompression returns a Gzip-based Compression. +func NewGzipCompression() Compression { + return NewGzipCompressionLevel(flate.DefaultCompression) +} + +// NewGzipCompressionLevel returns a Gzip-based Compression with the given level. +func NewGzipCompressionLevel(level int) Compression { + return &genericCompression{ + wf: func(w io.Writer) (io.WriteCloser, error) { return gzip.NewWriterLevel(w, level) }, + rf: func(r io.Reader) (io.ReadCloser, error) { return gzip.NewReader(r) }, + } +} + +// NewZlibCompression returns a Zlib-based Compression. +func NewZlibCompression() Compression { + return NewZlibCompressionLevel(flate.DefaultCompression) +} + +// NewZlibCompressionLevel returns a Zlib-based Compression with the given level. +func NewZlibCompressionLevel(level int) Compression { + return NewZlibCompressionLevelDict(level, nil) +} + +// NewZlibCompressionLevelDict returns a Zlib-based Compression with the given +// level, based on the given dictionary. +func NewZlibCompressionLevelDict(level int, dict []byte) Compression { + return &genericCompression{ + func(w io.Writer) (io.WriteCloser, error) { return zlib.NewWriterLevelDict(w, level, dict) }, + func(r io.Reader) (io.ReadCloser, error) { return zlib.NewReaderDict(r, dict) }, + } +} + +type genericCompression struct { + wf func(w io.Writer) (io.WriteCloser, error) + rf func(r io.Reader) (io.ReadCloser, error) +} + +func (g *genericCompression) Writer(dst io.Writer) (io.WriteCloser, error) { + return g.wf(dst) +} + +func (g *genericCompression) Reader(src io.Reader) (io.ReadCloser, error) { + return g.rf(src) +} diff --git a/vendor/github.com/peterbourgon/diskv/diskv.go b/vendor/github.com/peterbourgon/diskv/diskv.go new file mode 100644 index 0000000000..ea05842cbd --- /dev/null +++ b/vendor/github.com/peterbourgon/diskv/diskv.go @@ -0,0 +1,578 @@ +// Diskv (disk-vee) is a simple, persistent, key-value store. +// It stores all data flatly on the filesystem. + +package diskv + +import ( + "bytes" + "errors" + "fmt" + "io" + "io/ioutil" + "os" + "path/filepath" + "strings" + "sync" + "syscall" +) + +const ( + defaultBasePath = "diskv" + defaultFilePerm os.FileMode = 0666 + defaultPathPerm os.FileMode = 0777 +) + +var ( + defaultTransform = func(s string) []string { return []string{} } + errCanceled = errors.New("canceled") + errEmptyKey = errors.New("empty key") + errBadKey = errors.New("bad key") + errImportDirectory = errors.New("can't import a directory") +) + +// TransformFunction transforms a key into a slice of strings, with each +// element in the slice representing a directory in the file path where the +// key's entry will eventually be stored. +// +// For example, if TransformFunc transforms "abcdef" to ["ab", "cde", "f"], +// the final location of the data file will be /ab/cde/f/abcdef +type TransformFunction func(s string) []string + +// Options define a set of properties that dictate Diskv behavior. +// All values are optional. +type Options struct { + BasePath string + Transform TransformFunction + CacheSizeMax uint64 // bytes + PathPerm os.FileMode + FilePerm os.FileMode + + Index Index + IndexLess LessFunction + + Compression Compression +} + +// Diskv implements the Diskv interface. You shouldn't construct Diskv +// structures directly; instead, use the New constructor. +type Diskv struct { + Options + mu sync.RWMutex + cache map[string][]byte + cacheSize uint64 +} + +// New returns an initialized Diskv structure, ready to use. +// If the path identified by baseDir already contains data, +// it will be accessible, but not yet cached. +func New(o Options) *Diskv { + if o.BasePath == "" { + o.BasePath = defaultBasePath + } + if o.Transform == nil { + o.Transform = defaultTransform + } + if o.PathPerm == 0 { + o.PathPerm = defaultPathPerm + } + if o.FilePerm == 0 { + o.FilePerm = defaultFilePerm + } + + d := &Diskv{ + Options: o, + cache: map[string][]byte{}, + cacheSize: 0, + } + + if d.Index != nil && d.IndexLess != nil { + d.Index.Initialize(d.IndexLess, d.Keys(nil)) + } + + return d +} + +// Write synchronously writes the key-value pair to disk, making it immediately +// available for reads. Write relies on the filesystem to perform an eventual +// sync to physical media. If you need stronger guarantees, see WriteStream. +func (d *Diskv) Write(key string, val []byte) error { + return d.WriteStream(key, bytes.NewBuffer(val), false) +} + +// WriteStream writes the data represented by the io.Reader to the disk, under +// the provided key. If sync is true, WriteStream performs an explicit sync on +// the file as soon as it's written. +// +// bytes.Buffer provides io.Reader semantics for basic data types. +func (d *Diskv) WriteStream(key string, r io.Reader, sync bool) error { + if len(key) <= 0 { + return errEmptyKey + } + + d.mu.Lock() + defer d.mu.Unlock() + + return d.writeStreamWithLock(key, r, sync) +} + +// writeStream does no input validation checking. +// TODO: use atomic FS ops. +func (d *Diskv) writeStreamWithLock(key string, r io.Reader, sync bool) error { + if err := d.ensurePathWithLock(key); err != nil { + return fmt.Errorf("ensure path: %s", err) + } + + mode := os.O_WRONLY | os.O_CREATE | os.O_TRUNC // overwrite if exists + f, err := os.OpenFile(d.completeFilename(key), mode, d.FilePerm) + if err != nil { + return fmt.Errorf("open file: %s", err) + } + + wc := io.WriteCloser(&nopWriteCloser{f}) + if d.Compression != nil { + wc, err = d.Compression.Writer(f) + if err != nil { + f.Close() // error deliberately ignored + return fmt.Errorf("compression writer: %s", err) + } + } + + if _, err := io.Copy(wc, r); err != nil { + f.Close() // error deliberately ignored + return fmt.Errorf("i/o copy: %s", err) + } + + if err := wc.Close(); err != nil { + f.Close() // error deliberately ignored + return fmt.Errorf("compression close: %s", err) + } + + if sync { + if err := f.Sync(); err != nil { + f.Close() // error deliberately ignored + return fmt.Errorf("file sync: %s", err) + } + } + + if err := f.Close(); err != nil { + return fmt.Errorf("file close: %s", err) + } + + if d.Index != nil { + d.Index.Insert(key) + } + + d.bustCacheWithLock(key) // cache only on read + + return nil +} + +// Import imports the source file into diskv under the destination key. If the +// destination key already exists, it's overwritten. If move is true, the +// source file is removed after a successful import. +func (d *Diskv) Import(srcFilename, dstKey string, move bool) (err error) { + if dstKey == "" { + return errEmptyKey + } + + if fi, err := os.Stat(srcFilename); err != nil { + return err + } else if fi.IsDir() { + return errImportDirectory + } + + d.mu.Lock() + defer d.mu.Unlock() + + if err := d.ensurePathWithLock(dstKey); err != nil { + return fmt.Errorf("ensure path: %s", err) + } + + if move { + if err := syscall.Rename(srcFilename, d.completeFilename(dstKey)); err == nil { + d.bustCacheWithLock(dstKey) + return nil + } else if err != syscall.EXDEV { + // If it failed due to being on a different device, fall back to copying + return err + } + } + + f, err := os.Open(srcFilename) + if err != nil { + return err + } + defer f.Close() + err = d.writeStreamWithLock(dstKey, f, false) + if err == nil && move { + err = os.Remove(srcFilename) + } + return err +} + +// Read reads the key and returns the value. +// If the key is available in the cache, Read won't touch the disk. +// If the key is not in the cache, Read will have the side-effect of +// lazily caching the value. +func (d *Diskv) Read(key string) ([]byte, error) { + rc, err := d.ReadStream(key, false) + if err != nil { + return []byte{}, err + } + defer rc.Close() + return ioutil.ReadAll(rc) +} + +// ReadStream reads the key and returns the value (data) as an io.ReadCloser. +// If the value is cached from a previous read, and direct is false, +// ReadStream will use the cached value. Otherwise, it will return a handle to +// the file on disk, and cache the data on read. +// +// If direct is true, ReadStream will lazily delete any cached value for the +// key, and return a direct handle to the file on disk. +// +// If compression is enabled, ReadStream taps into the io.Reader stream prior +// to decompression, and caches the compressed data. +func (d *Diskv) ReadStream(key string, direct bool) (io.ReadCloser, error) { + d.mu.RLock() + defer d.mu.RUnlock() + + if val, ok := d.cache[key]; ok { + if !direct { + buf := bytes.NewBuffer(val) + if d.Compression != nil { + return d.Compression.Reader(buf) + } + return ioutil.NopCloser(buf), nil + } + + go func() { + d.mu.Lock() + defer d.mu.Unlock() + d.uncacheWithLock(key, uint64(len(val))) + }() + } + + return d.readWithRLock(key) +} + +// read ignores the cache, and returns an io.ReadCloser representing the +// decompressed data for the given key, streamed from the disk. Clients should +// acquire a read lock on the Diskv and check the cache themselves before +// calling read. +func (d *Diskv) readWithRLock(key string) (io.ReadCloser, error) { + filename := d.completeFilename(key) + + fi, err := os.Stat(filename) + if err != nil { + return nil, err + } + if fi.IsDir() { + return nil, os.ErrNotExist + } + + f, err := os.Open(filename) + if err != nil { + return nil, err + } + + var r io.Reader + if d.CacheSizeMax > 0 { + r = newSiphon(f, d, key) + } else { + r = &closingReader{f} + } + + var rc = io.ReadCloser(ioutil.NopCloser(r)) + if d.Compression != nil { + rc, err = d.Compression.Reader(r) + if err != nil { + return nil, err + } + } + + return rc, nil +} + +// closingReader provides a Reader that automatically closes the +// embedded ReadCloser when it reaches EOF +type closingReader struct { + rc io.ReadCloser +} + +func (cr closingReader) Read(p []byte) (int, error) { + n, err := cr.rc.Read(p) + if err == io.EOF { + if closeErr := cr.rc.Close(); closeErr != nil { + return n, closeErr // close must succeed for Read to succeed + } + } + return n, err +} + +// siphon is like a TeeReader: it copies all data read through it to an +// internal buffer, and moves that buffer to the cache at EOF. +type siphon struct { + f *os.File + d *Diskv + key string + buf *bytes.Buffer +} + +// newSiphon constructs a siphoning reader that represents the passed file. +// When a successful series of reads ends in an EOF, the siphon will write +// the buffered data to Diskv's cache under the given key. +func newSiphon(f *os.File, d *Diskv, key string) io.Reader { + return &siphon{ + f: f, + d: d, + key: key, + buf: &bytes.Buffer{}, + } +} + +// Read implements the io.Reader interface for siphon. +func (s *siphon) Read(p []byte) (int, error) { + n, err := s.f.Read(p) + + if err == nil { + return s.buf.Write(p[0:n]) // Write must succeed for Read to succeed + } + + if err == io.EOF { + s.d.cacheWithoutLock(s.key, s.buf.Bytes()) // cache may fail + if closeErr := s.f.Close(); closeErr != nil { + return n, closeErr // close must succeed for Read to succeed + } + return n, err + } + + return n, err +} + +// Erase synchronously erases the given key from the disk and the cache. +func (d *Diskv) Erase(key string) error { + d.mu.Lock() + defer d.mu.Unlock() + + d.bustCacheWithLock(key) + + // erase from index + if d.Index != nil { + d.Index.Delete(key) + } + + // erase from disk + filename := d.completeFilename(key) + if s, err := os.Stat(filename); err == nil { + if s.IsDir() { + return errBadKey + } + if err = os.Remove(filename); err != nil { + return err + } + } else { + // Return err as-is so caller can do os.IsNotExist(err). + return err + } + + // clean up and return + d.pruneDirsWithLock(key) + return nil +} + +// EraseAll will delete all of the data from the store, both in the cache and on +// the disk. Note that EraseAll doesn't distinguish diskv-related data from non- +// diskv-related data. Care should be taken to always specify a diskv base +// directory that is exclusively for diskv data. +func (d *Diskv) EraseAll() error { + d.mu.Lock() + defer d.mu.Unlock() + d.cache = make(map[string][]byte) + d.cacheSize = 0 + return os.RemoveAll(d.BasePath) +} + +// Has returns true if the given key exists. +func (d *Diskv) Has(key string) bool { + d.mu.Lock() + defer d.mu.Unlock() + + if _, ok := d.cache[key]; ok { + return true + } + + filename := d.completeFilename(key) + s, err := os.Stat(filename) + if err != nil { + return false + } + if s.IsDir() { + return false + } + + return true +} + +// Keys returns a channel that will yield every key accessible by the store, +// in undefined order. If a cancel channel is provided, closing it will +// terminate and close the keys channel. +func (d *Diskv) Keys(cancel <-chan struct{}) <-chan string { + return d.KeysPrefix("", cancel) +} + +// KeysPrefix returns a channel that will yield every key accessible by the +// store with the given prefix, in undefined order. If a cancel channel is +// provided, closing it will terminate and close the keys channel. If the +// provided prefix is the empty string, all keys will be yielded. +func (d *Diskv) KeysPrefix(prefix string, cancel <-chan struct{}) <-chan string { + var prepath string + if prefix == "" { + prepath = d.BasePath + } else { + prepath = d.pathFor(prefix) + } + c := make(chan string) + go func() { + filepath.Walk(prepath, walker(c, prefix, cancel)) + close(c) + }() + return c +} + +// walker returns a function which satisfies the filepath.WalkFunc interface. +// It sends every non-directory file entry down the channel c. +func walker(c chan<- string, prefix string, cancel <-chan struct{}) filepath.WalkFunc { + return func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + + if info.IsDir() || !strings.HasPrefix(info.Name(), prefix) { + return nil // "pass" + } + + select { + case c <- info.Name(): + case <-cancel: + return errCanceled + } + + return nil + } +} + +// pathFor returns the absolute path for location on the filesystem where the +// data for the given key will be stored. +func (d *Diskv) pathFor(key string) string { + return filepath.Join(d.BasePath, filepath.Join(d.Transform(key)...)) +} + +// ensurePathWithLock is a helper function that generates all necessary +// directories on the filesystem for the given key. +func (d *Diskv) ensurePathWithLock(key string) error { + return os.MkdirAll(d.pathFor(key), d.PathPerm) +} + +// completeFilename returns the absolute path to the file for the given key. +func (d *Diskv) completeFilename(key string) string { + return filepath.Join(d.pathFor(key), key) +} + +// cacheWithLock attempts to cache the given key-value pair in the store's +// cache. It can fail if the value is larger than the cache's maximum size. +func (d *Diskv) cacheWithLock(key string, val []byte) error { + valueSize := uint64(len(val)) + if err := d.ensureCacheSpaceWithLock(valueSize); err != nil { + return fmt.Errorf("%s; not caching", err) + } + + // be very strict about memory guarantees + if (d.cacheSize + valueSize) > d.CacheSizeMax { + panic(fmt.Sprintf("failed to make room for value (%d/%d)", valueSize, d.CacheSizeMax)) + } + + d.cache[key] = val + d.cacheSize += valueSize + return nil +} + +// cacheWithoutLock acquires the store's (write) mutex and calls cacheWithLock. +func (d *Diskv) cacheWithoutLock(key string, val []byte) error { + d.mu.Lock() + defer d.mu.Unlock() + return d.cacheWithLock(key, val) +} + +func (d *Diskv) bustCacheWithLock(key string) { + if val, ok := d.cache[key]; ok { + d.uncacheWithLock(key, uint64(len(val))) + } +} + +func (d *Diskv) uncacheWithLock(key string, sz uint64) { + d.cacheSize -= sz + delete(d.cache, key) +} + +// pruneDirsWithLock deletes empty directories in the path walk leading to the +// key k. Typically this function is called after an Erase is made. +func (d *Diskv) pruneDirsWithLock(key string) error { + pathlist := d.Transform(key) + for i := range pathlist { + dir := filepath.Join(d.BasePath, filepath.Join(pathlist[:len(pathlist)-i]...)) + + // thanks to Steven Blenkinsop for this snippet + switch fi, err := os.Stat(dir); true { + case err != nil: + return err + case !fi.IsDir(): + panic(fmt.Sprintf("corrupt dirstate at %s", dir)) + } + + nlinks, err := filepath.Glob(filepath.Join(dir, "*")) + if err != nil { + return err + } else if len(nlinks) > 0 { + return nil // has subdirs -- do not prune + } + if err = os.Remove(dir); err != nil { + return err + } + } + + return nil +} + +// ensureCacheSpaceWithLock deletes entries from the cache in arbitrary order +// until the cache has at least valueSize bytes available. +func (d *Diskv) ensureCacheSpaceWithLock(valueSize uint64) error { + if valueSize > d.CacheSizeMax { + return fmt.Errorf("value size (%d bytes) too large for cache (%d bytes)", valueSize, d.CacheSizeMax) + } + + safe := func() bool { return (d.cacheSize + valueSize) <= d.CacheSizeMax } + + for key, val := range d.cache { + if safe() { + break + } + + d.uncacheWithLock(key, uint64(len(val))) + } + + if !safe() { + panic(fmt.Sprintf("%d bytes still won't fit in the cache! (max %d bytes)", valueSize, d.CacheSizeMax)) + } + + return nil +} + +// nopWriteCloser wraps an io.Writer and provides a no-op Close method to +// satisfy the io.WriteCloser interface. +type nopWriteCloser struct { + io.Writer +} + +func (wc *nopWriteCloser) Write(p []byte) (int, error) { return wc.Writer.Write(p) } +func (wc *nopWriteCloser) Close() error { return nil } diff --git a/vendor/github.com/peterbourgon/diskv/index.go b/vendor/github.com/peterbourgon/diskv/index.go new file mode 100644 index 0000000000..96fee5152b --- /dev/null +++ b/vendor/github.com/peterbourgon/diskv/index.go @@ -0,0 +1,115 @@ +package diskv + +import ( + "sync" + + "github.com/google/btree" +) + +// Index is a generic interface for things that can +// provide an ordered list of keys. +type Index interface { + Initialize(less LessFunction, keys <-chan string) + Insert(key string) + Delete(key string) + Keys(from string, n int) []string +} + +// LessFunction is used to initialize an Index of keys in a specific order. +type LessFunction func(string, string) bool + +// btreeString is a custom data type that satisfies the BTree Less interface, +// making the strings it wraps sortable by the BTree package. +type btreeString struct { + s string + l LessFunction +} + +// Less satisfies the BTree.Less interface using the btreeString's LessFunction. +func (s btreeString) Less(i btree.Item) bool { + return s.l(s.s, i.(btreeString).s) +} + +// BTreeIndex is an implementation of the Index interface using google/btree. +type BTreeIndex struct { + sync.RWMutex + LessFunction + *btree.BTree +} + +// Initialize populates the BTree tree with data from the keys channel, +// according to the passed less function. It's destructive to the BTreeIndex. +func (i *BTreeIndex) Initialize(less LessFunction, keys <-chan string) { + i.Lock() + defer i.Unlock() + i.LessFunction = less + i.BTree = rebuild(less, keys) +} + +// Insert inserts the given key (only) into the BTree tree. +func (i *BTreeIndex) Insert(key string) { + i.Lock() + defer i.Unlock() + if i.BTree == nil || i.LessFunction == nil { + panic("uninitialized index") + } + i.BTree.ReplaceOrInsert(btreeString{s: key, l: i.LessFunction}) +} + +// Delete removes the given key (only) from the BTree tree. +func (i *BTreeIndex) Delete(key string) { + i.Lock() + defer i.Unlock() + if i.BTree == nil || i.LessFunction == nil { + panic("uninitialized index") + } + i.BTree.Delete(btreeString{s: key, l: i.LessFunction}) +} + +// Keys yields a maximum of n keys in order. If the passed 'from' key is empty, +// Keys will return the first n keys. If the passed 'from' key is non-empty, the +// first key in the returned slice will be the key that immediately follows the +// passed key, in key order. +func (i *BTreeIndex) Keys(from string, n int) []string { + i.RLock() + defer i.RUnlock() + + if i.BTree == nil || i.LessFunction == nil { + panic("uninitialized index") + } + + if i.BTree.Len() <= 0 { + return []string{} + } + + btreeFrom := btreeString{s: from, l: i.LessFunction} + skipFirst := true + if len(from) <= 0 || !i.BTree.Has(btreeFrom) { + // no such key, so fabricate an always-smallest item + btreeFrom = btreeString{s: "", l: func(string, string) bool { return true }} + skipFirst = false + } + + keys := []string{} + iterator := func(i btree.Item) bool { + keys = append(keys, i.(btreeString).s) + return len(keys) < n + } + i.BTree.AscendGreaterOrEqual(btreeFrom, iterator) + + if skipFirst && len(keys) > 0 { + keys = keys[1:] + } + + return keys +} + +// rebuildIndex does the work of regenerating the index +// with the given keys. +func rebuild(less LessFunction, keys <-chan string) *btree.BTree { + tree := btree.New(2) + for key := range keys { + tree.ReplaceOrInsert(btreeString{s: key, l: less}) + } + return tree +} diff --git a/vendor/github.com/russross/blackfriday/LICENSE.txt b/vendor/github.com/russross/blackfriday/LICENSE.txt new file mode 100644 index 0000000000..2885af3602 --- /dev/null +++ b/vendor/github.com/russross/blackfriday/LICENSE.txt @@ -0,0 +1,29 @@ +Blackfriday is distributed under the Simplified BSD License: + +> Copyright © 2011 Russ Ross +> 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. +> +> 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. diff --git a/vendor/github.com/russross/blackfriday/block.go b/vendor/github.com/russross/blackfriday/block.go new file mode 100644 index 0000000000..b5b084117c --- /dev/null +++ b/vendor/github.com/russross/blackfriday/block.go @@ -0,0 +1,1398 @@ +// +// Blackfriday Markdown Processor +// Available at http://github.com/russross/blackfriday +// +// Copyright © 2011 Russ Ross . +// Distributed under the Simplified BSD License. +// See README.md for details. +// + +// +// Functions to parse block-level elements. +// + +package blackfriday + +import ( + "bytes" + + "github.com/shurcooL/sanitized_anchor_name" +) + +// Parse block-level data. +// Note: this function and many that it calls assume that +// the input buffer ends with a newline. +func (p *parser) block(out *bytes.Buffer, data []byte) { + if len(data) == 0 || data[len(data)-1] != '\n' { + panic("block input is missing terminating newline") + } + + // this is called recursively: enforce a maximum depth + if p.nesting >= p.maxNesting { + return + } + p.nesting++ + + // parse out one block-level construct at a time + for len(data) > 0 { + // prefixed header: + // + // # Header 1 + // ## Header 2 + // ... + // ###### Header 6 + if p.isPrefixHeader(data) { + data = data[p.prefixHeader(out, data):] + continue + } + + // block of preformatted HTML: + // + //

+ // ... + //
+ if data[0] == '<' { + if i := p.html(out, data, true); i > 0 { + data = data[i:] + continue + } + } + + // title block + // + // % stuff + // % more stuff + // % even more stuff + if p.flags&EXTENSION_TITLEBLOCK != 0 { + if data[0] == '%' { + if i := p.titleBlock(out, data, true); i > 0 { + data = data[i:] + continue + } + } + } + + // blank lines. note: returns the # of bytes to skip + if i := p.isEmpty(data); i > 0 { + data = data[i:] + continue + } + + // indented code block: + // + // func max(a, b int) int { + // if a > b { + // return a + // } + // return b + // } + if p.codePrefix(data) > 0 { + data = data[p.code(out, data):] + continue + } + + // fenced code block: + // + // ``` go + // func fact(n int) int { + // if n <= 1 { + // return n + // } + // return n * fact(n-1) + // } + // ``` + if p.flags&EXTENSION_FENCED_CODE != 0 { + if i := p.fencedCode(out, data, true); i > 0 { + data = data[i:] + continue + } + } + + // horizontal rule: + // + // ------ + // or + // ****** + // or + // ______ + if p.isHRule(data) { + p.r.HRule(out) + var i int + for i = 0; data[i] != '\n'; i++ { + } + data = data[i:] + continue + } + + // block quote: + // + // > A big quote I found somewhere + // > on the web + if p.quotePrefix(data) > 0 { + data = data[p.quote(out, data):] + continue + } + + // table: + // + // Name | Age | Phone + // ------|-----|--------- + // Bob | 31 | 555-1234 + // Alice | 27 | 555-4321 + if p.flags&EXTENSION_TABLES != 0 { + if i := p.table(out, data); i > 0 { + data = data[i:] + continue + } + } + + // an itemized/unordered list: + // + // * Item 1 + // * Item 2 + // + // also works with + or - + if p.uliPrefix(data) > 0 { + data = data[p.list(out, data, 0):] + continue + } + + // a numbered/ordered list: + // + // 1. Item 1 + // 2. Item 2 + if p.oliPrefix(data) > 0 { + data = data[p.list(out, data, LIST_TYPE_ORDERED):] + continue + } + + // definition lists: + // + // Term 1 + // : Definition a + // : Definition b + // + // Term 2 + // : Definition c + if p.flags&EXTENSION_DEFINITION_LISTS != 0 { + if p.dliPrefix(data) > 0 { + data = data[p.list(out, data, LIST_TYPE_DEFINITION):] + continue + } + } + + // anything else must look like a normal paragraph + // note: this finds underlined headers, too + data = data[p.paragraph(out, data):] + } + + p.nesting-- +} + +func (p *parser) isPrefixHeader(data []byte) bool { + if data[0] != '#' { + return false + } + + if p.flags&EXTENSION_SPACE_HEADERS != 0 { + level := 0 + for level < 6 && data[level] == '#' { + level++ + } + if data[level] != ' ' { + return false + } + } + return true +} + +func (p *parser) prefixHeader(out *bytes.Buffer, data []byte) int { + level := 0 + for level < 6 && data[level] == '#' { + level++ + } + i := skipChar(data, level, ' ') + end := skipUntilChar(data, i, '\n') + skip := end + id := "" + if p.flags&EXTENSION_HEADER_IDS != 0 { + j, k := 0, 0 + // find start/end of header id + for j = i; j < end-1 && (data[j] != '{' || data[j+1] != '#'); j++ { + } + for k = j + 1; k < end && data[k] != '}'; k++ { + } + // extract header id iff found + if j < end && k < end { + id = string(data[j+2 : k]) + end = j + skip = k + 1 + for end > 0 && data[end-1] == ' ' { + end-- + } + } + } + for end > 0 && data[end-1] == '#' { + if isBackslashEscaped(data, end-1) { + break + } + end-- + } + for end > 0 && data[end-1] == ' ' { + end-- + } + if end > i { + if id == "" && p.flags&EXTENSION_AUTO_HEADER_IDS != 0 { + id = sanitized_anchor_name.Create(string(data[i:end])) + } + work := func() bool { + p.inline(out, data[i:end]) + return true + } + p.r.Header(out, work, level, id) + } + return skip +} + +func (p *parser) isUnderlinedHeader(data []byte) int { + // test of level 1 header + if data[0] == '=' { + i := skipChar(data, 1, '=') + i = skipChar(data, i, ' ') + if data[i] == '\n' { + return 1 + } else { + return 0 + } + } + + // test of level 2 header + if data[0] == '-' { + i := skipChar(data, 1, '-') + i = skipChar(data, i, ' ') + if data[i] == '\n' { + return 2 + } else { + return 0 + } + } + + return 0 +} + +func (p *parser) titleBlock(out *bytes.Buffer, data []byte, doRender bool) int { + if data[0] != '%' { + return 0 + } + splitData := bytes.Split(data, []byte("\n")) + var i int + for idx, b := range splitData { + if !bytes.HasPrefix(b, []byte("%")) { + i = idx // - 1 + break + } + } + + data = bytes.Join(splitData[0:i], []byte("\n")) + p.r.TitleBlock(out, data) + + return len(data) +} + +func (p *parser) html(out *bytes.Buffer, data []byte, doRender bool) int { + var i, j int + + // identify the opening tag + if data[0] != '<' { + return 0 + } + curtag, tagfound := p.htmlFindTag(data[1:]) + + // handle special cases + if !tagfound { + // check for an HTML comment + if size := p.htmlComment(out, data, doRender); size > 0 { + return size + } + + // check for an
tag + if size := p.htmlHr(out, data, doRender); size > 0 { + return size + } + + // no special case recognized + return 0 + } + + // look for an unindented matching closing tag + // followed by a blank line + found := false + /* + closetag := []byte("\n") + j = len(curtag) + 1 + for !found { + // scan for a closing tag at the beginning of a line + if skip := bytes.Index(data[j:], closetag); skip >= 0 { + j += skip + len(closetag) + } else { + break + } + + // see if it is the only thing on the line + if skip := p.isEmpty(data[j:]); skip > 0 { + // see if it is followed by a blank line/eof + j += skip + if j >= len(data) { + found = true + i = j + } else { + if skip := p.isEmpty(data[j:]); skip > 0 { + j += skip + found = true + i = j + } + } + } + } + */ + + // if not found, try a second pass looking for indented match + // but not if tag is "ins" or "del" (following original Markdown.pl) + if !found && curtag != "ins" && curtag != "del" { + i = 1 + for i < len(data) { + i++ + for i < len(data) && !(data[i-1] == '<' && data[i] == '/') { + i++ + } + + if i+2+len(curtag) >= len(data) { + break + } + + j = p.htmlFindEnd(curtag, data[i-1:]) + + if j > 0 { + i += j - 1 + found = true + break + } + } + } + + if !found { + return 0 + } + + // the end of the block has been found + if doRender { + // trim newlines + end := i + for end > 0 && data[end-1] == '\n' { + end-- + } + p.r.BlockHtml(out, data[:end]) + } + + return i +} + +// HTML comment, lax form +func (p *parser) htmlComment(out *bytes.Buffer, data []byte, doRender bool) int { + i := p.inlineHtmlComment(out, data) + // needs to end with a blank line + if j := p.isEmpty(data[i:]); j > 0 { + size := i + j + if doRender { + // trim trailing newlines + end := size + for end > 0 && data[end-1] == '\n' { + end-- + } + p.r.BlockHtml(out, data[:end]) + } + return size + } + return 0 +} + +// HR, which is the only self-closing block tag considered +func (p *parser) htmlHr(out *bytes.Buffer, data []byte, doRender bool) int { + if data[0] != '<' || (data[1] != 'h' && data[1] != 'H') || (data[2] != 'r' && data[2] != 'R') { + return 0 + } + if data[3] != ' ' && data[3] != '/' && data[3] != '>' { + // not an
tag after all; at least not a valid one + return 0 + } + + i := 3 + for data[i] != '>' && data[i] != '\n' { + i++ + } + + if data[i] == '>' { + i++ + if j := p.isEmpty(data[i:]); j > 0 { + size := i + j + if doRender { + // trim newlines + end := size + for end > 0 && data[end-1] == '\n' { + end-- + } + p.r.BlockHtml(out, data[:end]) + } + return size + } + } + + return 0 +} + +func (p *parser) htmlFindTag(data []byte) (string, bool) { + i := 0 + for isalnum(data[i]) { + i++ + } + key := string(data[:i]) + if _, ok := blockTags[key]; ok { + return key, true + } + return "", false +} + +func (p *parser) htmlFindEnd(tag string, data []byte) int { + // assume data[0] == '<' && data[1] == '/' already tested + + // check if tag is a match + closetag := []byte("") + if !bytes.HasPrefix(data, closetag) { + return 0 + } + i := len(closetag) + + // check that the rest of the line is blank + skip := 0 + if skip = p.isEmpty(data[i:]); skip == 0 { + return 0 + } + i += skip + skip = 0 + + if i >= len(data) { + return i + } + + if p.flags&EXTENSION_LAX_HTML_BLOCKS != 0 { + return i + } + if skip = p.isEmpty(data[i:]); skip == 0 { + // following line must be blank + return 0 + } + + return i + skip +} + +func (p *parser) isEmpty(data []byte) int { + // it is okay to call isEmpty on an empty buffer + if len(data) == 0 { + return 0 + } + + var i int + for i = 0; i < len(data) && data[i] != '\n'; i++ { + if data[i] != ' ' && data[i] != '\t' { + return 0 + } + } + return i + 1 +} + +func (p *parser) isHRule(data []byte) bool { + i := 0 + + // skip up to three spaces + for i < 3 && data[i] == ' ' { + i++ + } + + // look at the hrule char + if data[i] != '*' && data[i] != '-' && data[i] != '_' { + return false + } + c := data[i] + + // the whole line must be the char or whitespace + n := 0 + for data[i] != '\n' { + switch { + case data[i] == c: + n++ + case data[i] != ' ': + return false + } + i++ + } + + return n >= 3 +} + +func (p *parser) isFencedCode(data []byte, syntax **string, oldmarker string) (skip int, marker string) { + i, size := 0, 0 + skip = 0 + + // skip up to three spaces + for i < len(data) && i < 3 && data[i] == ' ' { + i++ + } + if i >= len(data) { + return + } + + // check for the marker characters: ~ or ` + if data[i] != '~' && data[i] != '`' { + return + } + + c := data[i] + + // the whole line must be the same char or whitespace + for i < len(data) && data[i] == c { + size++ + i++ + } + + if i >= len(data) { + return + } + + // the marker char must occur at least 3 times + if size < 3 { + return + } + marker = string(data[i-size : i]) + + // if this is the end marker, it must match the beginning marker + if oldmarker != "" && marker != oldmarker { + return + } + + if syntax != nil { + syn := 0 + i = skipChar(data, i, ' ') + + if i >= len(data) { + return + } + + syntaxStart := i + + if data[i] == '{' { + i++ + syntaxStart++ + + for i < len(data) && data[i] != '}' && data[i] != '\n' { + syn++ + i++ + } + + if i >= len(data) || data[i] != '}' { + return + } + + // strip all whitespace at the beginning and the end + // of the {} block + for syn > 0 && isspace(data[syntaxStart]) { + syntaxStart++ + syn-- + } + + for syn > 0 && isspace(data[syntaxStart+syn-1]) { + syn-- + } + + i++ + } else { + for i < len(data) && !isspace(data[i]) { + syn++ + i++ + } + } + + language := string(data[syntaxStart : syntaxStart+syn]) + *syntax = &language + } + + i = skipChar(data, i, ' ') + if i >= len(data) || data[i] != '\n' { + return + } + + skip = i + 1 + return +} + +func (p *parser) fencedCode(out *bytes.Buffer, data []byte, doRender bool) int { + var lang *string + beg, marker := p.isFencedCode(data, &lang, "") + if beg == 0 || beg >= len(data) { + return 0 + } + + var work bytes.Buffer + + for { + // safe to assume beg < len(data) + + // check for the end of the code block + fenceEnd, _ := p.isFencedCode(data[beg:], nil, marker) + if fenceEnd != 0 { + beg += fenceEnd + break + } + + // copy the current line + end := skipUntilChar(data, beg, '\n') + 1 + + // did we reach the end of the buffer without a closing marker? + if end >= len(data) { + return 0 + } + + // verbatim copy to the working buffer + if doRender { + work.Write(data[beg:end]) + } + beg = end + } + + syntax := "" + if lang != nil { + syntax = *lang + } + + if doRender { + p.r.BlockCode(out, work.Bytes(), syntax) + } + + return beg +} + +func (p *parser) table(out *bytes.Buffer, data []byte) int { + var header bytes.Buffer + i, columns := p.tableHeader(&header, data) + if i == 0 { + return 0 + } + + var body bytes.Buffer + + for i < len(data) { + pipes, rowStart := 0, i + for ; data[i] != '\n'; i++ { + if data[i] == '|' { + pipes++ + } + } + + if pipes == 0 { + i = rowStart + break + } + + // include the newline in data sent to tableRow + i++ + p.tableRow(&body, data[rowStart:i], columns, false) + } + + p.r.Table(out, header.Bytes(), body.Bytes(), columns) + + return i +} + +// check if the specified position is preceded by an odd number of backslashes +func isBackslashEscaped(data []byte, i int) bool { + backslashes := 0 + for i-backslashes-1 >= 0 && data[i-backslashes-1] == '\\' { + backslashes++ + } + return backslashes&1 == 1 +} + +func (p *parser) tableHeader(out *bytes.Buffer, data []byte) (size int, columns []int) { + i := 0 + colCount := 1 + for i = 0; data[i] != '\n'; i++ { + if data[i] == '|' && !isBackslashEscaped(data, i) { + colCount++ + } + } + + // doesn't look like a table header + if colCount == 1 { + return + } + + // include the newline in the data sent to tableRow + header := data[:i+1] + + // column count ignores pipes at beginning or end of line + if data[0] == '|' { + colCount-- + } + if i > 2 && data[i-1] == '|' && !isBackslashEscaped(data, i-1) { + colCount-- + } + + columns = make([]int, colCount) + + // move on to the header underline + i++ + if i >= len(data) { + return + } + + if data[i] == '|' && !isBackslashEscaped(data, i) { + i++ + } + i = skipChar(data, i, ' ') + + // each column header is of form: / *:?-+:? *|/ with # dashes + # colons >= 3 + // and trailing | optional on last column + col := 0 + for data[i] != '\n' { + dashes := 0 + + if data[i] == ':' { + i++ + columns[col] |= TABLE_ALIGNMENT_LEFT + dashes++ + } + for data[i] == '-' { + i++ + dashes++ + } + if data[i] == ':' { + i++ + columns[col] |= TABLE_ALIGNMENT_RIGHT + dashes++ + } + for data[i] == ' ' { + i++ + } + + // end of column test is messy + switch { + case dashes < 3: + // not a valid column + return + + case data[i] == '|' && !isBackslashEscaped(data, i): + // marker found, now skip past trailing whitespace + col++ + i++ + for data[i] == ' ' { + i++ + } + + // trailing junk found after last column + if col >= colCount && data[i] != '\n' { + return + } + + case (data[i] != '|' || isBackslashEscaped(data, i)) && col+1 < colCount: + // something else found where marker was required + return + + case data[i] == '\n': + // marker is optional for the last column + col++ + + default: + // trailing junk found after last column + return + } + } + if col != colCount { + return + } + + p.tableRow(out, header, columns, true) + size = i + 1 + return +} + +func (p *parser) tableRow(out *bytes.Buffer, data []byte, columns []int, header bool) { + i, col := 0, 0 + var rowWork bytes.Buffer + + if data[i] == '|' && !isBackslashEscaped(data, i) { + i++ + } + + for col = 0; col < len(columns) && i < len(data); col++ { + for data[i] == ' ' { + i++ + } + + cellStart := i + + for (data[i] != '|' || isBackslashEscaped(data, i)) && data[i] != '\n' { + i++ + } + + cellEnd := i + + // skip the end-of-cell marker, possibly taking us past end of buffer + i++ + + for cellEnd > cellStart && data[cellEnd-1] == ' ' { + cellEnd-- + } + + var cellWork bytes.Buffer + p.inline(&cellWork, data[cellStart:cellEnd]) + + if header { + p.r.TableHeaderCell(&rowWork, cellWork.Bytes(), columns[col]) + } else { + p.r.TableCell(&rowWork, cellWork.Bytes(), columns[col]) + } + } + + // pad it out with empty columns to get the right number + for ; col < len(columns); col++ { + if header { + p.r.TableHeaderCell(&rowWork, nil, columns[col]) + } else { + p.r.TableCell(&rowWork, nil, columns[col]) + } + } + + // silently ignore rows with too many cells + + p.r.TableRow(out, rowWork.Bytes()) +} + +// returns blockquote prefix length +func (p *parser) quotePrefix(data []byte) int { + i := 0 + for i < 3 && data[i] == ' ' { + i++ + } + if data[i] == '>' { + if data[i+1] == ' ' { + return i + 2 + } + return i + 1 + } + return 0 +} + +// blockquote ends with at least one blank line +// followed by something without a blockquote prefix +func (p *parser) terminateBlockquote(data []byte, beg, end int) bool { + if p.isEmpty(data[beg:]) <= 0 { + return false + } + if end >= len(data) { + return true + } + return p.quotePrefix(data[end:]) == 0 && p.isEmpty(data[end:]) == 0 +} + +// parse a blockquote fragment +func (p *parser) quote(out *bytes.Buffer, data []byte) int { + var raw bytes.Buffer + beg, end := 0, 0 + for beg < len(data) { + end = beg + // Step over whole lines, collecting them. While doing that, check for + // fenced code and if one's found, incorporate it altogether, + // irregardless of any contents inside it + for data[end] != '\n' { + if p.flags&EXTENSION_FENCED_CODE != 0 { + if i := p.fencedCode(out, data[end:], false); i > 0 { + // -1 to compensate for the extra end++ after the loop: + end += i - 1 + break + } + } + end++ + } + end++ + + if pre := p.quotePrefix(data[beg:]); pre > 0 { + // skip the prefix + beg += pre + } else if p.terminateBlockquote(data, beg, end) { + break + } + + // this line is part of the blockquote + raw.Write(data[beg:end]) + beg = end + } + + var cooked bytes.Buffer + p.block(&cooked, raw.Bytes()) + p.r.BlockQuote(out, cooked.Bytes()) + return end +} + +// returns prefix length for block code +func (p *parser) codePrefix(data []byte) int { + if data[0] == ' ' && data[1] == ' ' && data[2] == ' ' && data[3] == ' ' { + return 4 + } + return 0 +} + +func (p *parser) code(out *bytes.Buffer, data []byte) int { + var work bytes.Buffer + + i := 0 + for i < len(data) { + beg := i + for data[i] != '\n' { + i++ + } + i++ + + blankline := p.isEmpty(data[beg:i]) > 0 + if pre := p.codePrefix(data[beg:i]); pre > 0 { + beg += pre + } else if !blankline { + // non-empty, non-prefixed line breaks the pre + i = beg + break + } + + // verbatim copy to the working buffeu + if blankline { + work.WriteByte('\n') + } else { + work.Write(data[beg:i]) + } + } + + // trim all the \n off the end of work + workbytes := work.Bytes() + eol := len(workbytes) + for eol > 0 && workbytes[eol-1] == '\n' { + eol-- + } + if eol != len(workbytes) { + work.Truncate(eol) + } + + work.WriteByte('\n') + + p.r.BlockCode(out, work.Bytes(), "") + + return i +} + +// returns unordered list item prefix +func (p *parser) uliPrefix(data []byte) int { + i := 0 + + // start with up to 3 spaces + for i < 3 && data[i] == ' ' { + i++ + } + + // need a *, +, or - followed by a space + if (data[i] != '*' && data[i] != '+' && data[i] != '-') || + data[i+1] != ' ' { + return 0 + } + return i + 2 +} + +// returns ordered list item prefix +func (p *parser) oliPrefix(data []byte) int { + i := 0 + + // start with up to 3 spaces + for i < 3 && data[i] == ' ' { + i++ + } + + // count the digits + start := i + for data[i] >= '0' && data[i] <= '9' { + i++ + } + + // we need >= 1 digits followed by a dot and a space + if start == i || data[i] != '.' || data[i+1] != ' ' { + return 0 + } + return i + 2 +} + +// returns definition list item prefix +func (p *parser) dliPrefix(data []byte) int { + i := 0 + + // need a : followed by a spaces + if data[i] != ':' || data[i+1] != ' ' { + return 0 + } + for data[i] == ' ' { + i++ + } + return i + 2 +} + +// parse ordered or unordered list block +func (p *parser) list(out *bytes.Buffer, data []byte, flags int) int { + i := 0 + flags |= LIST_ITEM_BEGINNING_OF_LIST + work := func() bool { + for i < len(data) { + skip := p.listItem(out, data[i:], &flags) + i += skip + + if skip == 0 || flags&LIST_ITEM_END_OF_LIST != 0 { + break + } + flags &= ^LIST_ITEM_BEGINNING_OF_LIST + } + return true + } + + p.r.List(out, work, flags) + return i +} + +// Parse a single list item. +// Assumes initial prefix is already removed if this is a sublist. +func (p *parser) listItem(out *bytes.Buffer, data []byte, flags *int) int { + // keep track of the indentation of the first line + itemIndent := 0 + for itemIndent < 3 && data[itemIndent] == ' ' { + itemIndent++ + } + + i := p.uliPrefix(data) + if i == 0 { + i = p.oliPrefix(data) + } + if i == 0 { + i = p.dliPrefix(data) + // reset definition term flag + if i > 0 { + *flags &= ^LIST_TYPE_TERM + } + } + if i == 0 { + // if in defnition list, set term flag and continue + if *flags&LIST_TYPE_DEFINITION != 0 { + *flags |= LIST_TYPE_TERM + } else { + return 0 + } + } + + // skip leading whitespace on first line + for data[i] == ' ' { + i++ + } + + // find the end of the line + line := i + for i > 0 && data[i-1] != '\n' { + i++ + } + + // get working buffer + var raw bytes.Buffer + + // put the first line into the working buffer + raw.Write(data[line:i]) + line = i + + // process the following lines + containsBlankLine := false + sublist := 0 + +gatherlines: + for line < len(data) { + i++ + + // find the end of this line + for data[i-1] != '\n' { + i++ + } + + // if it is an empty line, guess that it is part of this item + // and move on to the next line + if p.isEmpty(data[line:i]) > 0 { + containsBlankLine = true + line = i + continue + } + + // calculate the indentation + indent := 0 + for indent < 4 && line+indent < i && data[line+indent] == ' ' { + indent++ + } + + chunk := data[line+indent : i] + + // evaluate how this line fits in + switch { + // is this a nested list item? + case (p.uliPrefix(chunk) > 0 && !p.isHRule(chunk)) || + p.oliPrefix(chunk) > 0 || + p.dliPrefix(chunk) > 0: + + if containsBlankLine { + *flags |= LIST_ITEM_CONTAINS_BLOCK + } + + // to be a nested list, it must be indented more + // if not, it is the next item in the same list + if indent <= itemIndent { + break gatherlines + } + + // is this the first item in the nested list? + if sublist == 0 { + sublist = raw.Len() + } + + // is this a nested prefix header? + case p.isPrefixHeader(chunk): + // if the header is not indented, it is not nested in the list + // and thus ends the list + if containsBlankLine && indent < 4 { + *flags |= LIST_ITEM_END_OF_LIST + break gatherlines + } + *flags |= LIST_ITEM_CONTAINS_BLOCK + + // anything following an empty line is only part + // of this item if it is indented 4 spaces + // (regardless of the indentation of the beginning of the item) + case containsBlankLine && indent < 4: + if *flags&LIST_TYPE_DEFINITION != 0 && i < len(data)-1 { + // is the next item still a part of this list? + next := i + for data[next] != '\n' { + next++ + } + for next < len(data)-1 && data[next] == '\n' { + next++ + } + if i < len(data)-1 && data[i] != ':' && data[next] != ':' { + *flags |= LIST_ITEM_END_OF_LIST + } + } else { + *flags |= LIST_ITEM_END_OF_LIST + } + break gatherlines + + // a blank line means this should be parsed as a block + case containsBlankLine: + raw.WriteByte('\n') + *flags |= LIST_ITEM_CONTAINS_BLOCK + } + + // if this line was preceeded by one or more blanks, + // re-introduce the blank into the buffer + if containsBlankLine { + containsBlankLine = false + raw.WriteByte('\n') + + } + + // add the line into the working buffer without prefix + raw.Write(data[line+indent : i]) + + line = i + } + + rawBytes := raw.Bytes() + + // render the contents of the list item + var cooked bytes.Buffer + if *flags&LIST_ITEM_CONTAINS_BLOCK != 0 && *flags&LIST_TYPE_TERM == 0 { + // intermediate render of block item, except for definition term + if sublist > 0 { + p.block(&cooked, rawBytes[:sublist]) + p.block(&cooked, rawBytes[sublist:]) + } else { + p.block(&cooked, rawBytes) + } + } else { + // intermediate render of inline item + if sublist > 0 { + p.inline(&cooked, rawBytes[:sublist]) + p.block(&cooked, rawBytes[sublist:]) + } else { + p.inline(&cooked, rawBytes) + } + } + + // render the actual list item + cookedBytes := cooked.Bytes() + parsedEnd := len(cookedBytes) + + // strip trailing newlines + for parsedEnd > 0 && cookedBytes[parsedEnd-1] == '\n' { + parsedEnd-- + } + p.r.ListItem(out, cookedBytes[:parsedEnd], *flags) + + return line +} + +// render a single paragraph that has already been parsed out +func (p *parser) renderParagraph(out *bytes.Buffer, data []byte) { + if len(data) == 0 { + return + } + + // trim leading spaces + beg := 0 + for data[beg] == ' ' { + beg++ + } + + // trim trailing newline + end := len(data) - 1 + + // trim trailing spaces + for end > beg && data[end-1] == ' ' { + end-- + } + + work := func() bool { + p.inline(out, data[beg:end]) + return true + } + p.r.Paragraph(out, work) +} + +func (p *parser) paragraph(out *bytes.Buffer, data []byte) int { + // prev: index of 1st char of previous line + // line: index of 1st char of current line + // i: index of cursor/end of current line + var prev, line, i int + + // keep going until we find something to mark the end of the paragraph + for i < len(data) { + // mark the beginning of the current line + prev = line + current := data[i:] + line = i + + // did we find a blank line marking the end of the paragraph? + if n := p.isEmpty(current); n > 0 { + // did this blank line followed by a definition list item? + if p.flags&EXTENSION_DEFINITION_LISTS != 0 { + if i < len(data)-1 && data[i+1] == ':' { + return p.list(out, data[prev:], LIST_TYPE_DEFINITION) + } + } + + p.renderParagraph(out, data[:i]) + return i + n + } + + // an underline under some text marks a header, so our paragraph ended on prev line + if i > 0 { + if level := p.isUnderlinedHeader(current); level > 0 { + // render the paragraph + p.renderParagraph(out, data[:prev]) + + // ignore leading and trailing whitespace + eol := i - 1 + for prev < eol && data[prev] == ' ' { + prev++ + } + for eol > prev && data[eol-1] == ' ' { + eol-- + } + + // render the header + // this ugly double closure avoids forcing variables onto the heap + work := func(o *bytes.Buffer, pp *parser, d []byte) func() bool { + return func() bool { + pp.inline(o, d) + return true + } + }(out, p, data[prev:eol]) + + id := "" + if p.flags&EXTENSION_AUTO_HEADER_IDS != 0 { + id = sanitized_anchor_name.Create(string(data[prev:eol])) + } + + p.r.Header(out, work, level, id) + + // find the end of the underline + for data[i] != '\n' { + i++ + } + return i + } + } + + // if the next line starts a block of HTML, then the paragraph ends here + if p.flags&EXTENSION_LAX_HTML_BLOCKS != 0 { + if data[i] == '<' && p.html(out, current, false) > 0 { + // rewind to before the HTML block + p.renderParagraph(out, data[:i]) + return i + } + } + + // if there's a prefixed header or a horizontal rule after this, paragraph is over + if p.isPrefixHeader(current) || p.isHRule(current) { + p.renderParagraph(out, data[:i]) + return i + } + + // if there's a fenced code block, paragraph is over + if p.flags&EXTENSION_FENCED_CODE != 0 { + if p.fencedCode(out, current, false) > 0 { + p.renderParagraph(out, data[:i]) + return i + } + } + + // if there's a definition list item, prev line is a definition term + if p.flags&EXTENSION_DEFINITION_LISTS != 0 { + if p.dliPrefix(current) != 0 { + return p.list(out, data[prev:], LIST_TYPE_DEFINITION) + } + } + + // if there's a list after this, paragraph is over + if p.flags&EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK != 0 { + if p.uliPrefix(current) != 0 || + p.oliPrefix(current) != 0 || + p.quotePrefix(current) != 0 || + p.codePrefix(current) != 0 { + p.renderParagraph(out, data[:i]) + return i + } + } + + // otherwise, scan to the beginning of the next line + for data[i] != '\n' { + i++ + } + i++ + } + + p.renderParagraph(out, data[:i]) + return i +} diff --git a/vendor/github.com/russross/blackfriday/html.go b/vendor/github.com/russross/blackfriday/html.go new file mode 100644 index 0000000000..74e67ee82b --- /dev/null +++ b/vendor/github.com/russross/blackfriday/html.go @@ -0,0 +1,949 @@ +// +// Blackfriday Markdown Processor +// Available at http://github.com/russross/blackfriday +// +// Copyright © 2011 Russ Ross . +// Distributed under the Simplified BSD License. +// See README.md for details. +// + +// +// +// HTML rendering backend +// +// + +package blackfriday + +import ( + "bytes" + "fmt" + "regexp" + "strconv" + "strings" +) + +// Html renderer configuration options. +const ( + HTML_SKIP_HTML = 1 << iota // skip preformatted HTML blocks + HTML_SKIP_STYLE // skip embedded + + +

/debug/events

+ + + {{range $i, $fam := .Families}} + + + + {{range $j, $bucket := $.Buckets}} + {{$n := index $.Counts $i $j}} + + {{end}} + + {{end}} +
{{$fam}} + {{if $n}}{{end}} + [{{$n}} {{$bucket.String}}] + {{if $n}}{{end}} +
+ +{{if $.EventLogs}} +
+

Family: {{$.Family}}

+ +{{if $.Expanded}}{{end}} +[Summary]{{if $.Expanded}}{{end}} + +{{if not $.Expanded}}{{end}} +[Expanded]{{if not $.Expanded}}{{end}} + + + + {{range $el := $.EventLogs}} + + + + + {{if $.Expanded}} + + + + + + {{range $el.Events}} + + + + + + {{end}} + {{end}} + {{end}} +
WhenElapsed
{{$el.When}}{{$el.ElapsedTime}}{{$el.Title}} +
{{$el.Stack|trimSpace}}
{{.WhenString}}{{elapsed .Elapsed}}.{{if .IsErr}}E{{else}}.{{end}}. {{.What}}
+{{end}} + + +` diff --git a/vendor/golang.org/x/net/trace/histogram.go b/vendor/golang.org/x/net/trace/histogram.go new file mode 100644 index 0000000000..bb42aa5320 --- /dev/null +++ b/vendor/golang.org/x/net/trace/histogram.go @@ -0,0 +1,356 @@ +// 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. + +package trace + +// This file implements histogramming for RPC statistics collection. + +import ( + "bytes" + "fmt" + "html/template" + "log" + "math" + + "golang.org/x/net/internal/timeseries" +) + +const ( + bucketCount = 38 +) + +// histogram keeps counts of values in buckets that are spaced +// out in powers of 2: 0-1, 2-3, 4-7... +// histogram implements timeseries.Observable +type histogram struct { + sum int64 // running total of measurements + sumOfSquares float64 // square of running total + buckets []int64 // bucketed values for histogram + value int // holds a single value as an optimization + valueCount int64 // number of values recorded for single value +} + +// AddMeasurement records a value measurement observation to the histogram. +func (h *histogram) addMeasurement(value int64) { + // TODO: assert invariant + h.sum += value + h.sumOfSquares += float64(value) * float64(value) + + bucketIndex := getBucket(value) + + if h.valueCount == 0 || (h.valueCount > 0 && h.value == bucketIndex) { + h.value = bucketIndex + h.valueCount++ + } else { + h.allocateBuckets() + h.buckets[bucketIndex]++ + } +} + +func (h *histogram) allocateBuckets() { + if h.buckets == nil { + h.buckets = make([]int64, bucketCount) + h.buckets[h.value] = h.valueCount + h.value = 0 + h.valueCount = -1 + } +} + +func log2(i int64) int { + n := 0 + for ; i >= 0x100; i >>= 8 { + n += 8 + } + for ; i > 0; i >>= 1 { + n += 1 + } + return n +} + +func getBucket(i int64) (index int) { + index = log2(i) - 1 + if index < 0 { + index = 0 + } + if index >= bucketCount { + index = bucketCount - 1 + } + return +} + +// Total returns the number of recorded observations. +func (h *histogram) total() (total int64) { + if h.valueCount >= 0 { + total = h.valueCount + } + for _, val := range h.buckets { + total += int64(val) + } + return +} + +// Average returns the average value of recorded observations. +func (h *histogram) average() float64 { + t := h.total() + if t == 0 { + return 0 + } + return float64(h.sum) / float64(t) +} + +// Variance returns the variance of recorded observations. +func (h *histogram) variance() float64 { + t := float64(h.total()) + if t == 0 { + return 0 + } + s := float64(h.sum) / t + return h.sumOfSquares/t - s*s +} + +// StandardDeviation returns the standard deviation of recorded observations. +func (h *histogram) standardDeviation() float64 { + return math.Sqrt(h.variance()) +} + +// PercentileBoundary estimates the value that the given fraction of recorded +// observations are less than. +func (h *histogram) percentileBoundary(percentile float64) int64 { + total := h.total() + + // Corner cases (make sure result is strictly less than Total()) + if total == 0 { + return 0 + } else if total == 1 { + return int64(h.average()) + } + + percentOfTotal := round(float64(total) * percentile) + var runningTotal int64 + + for i := range h.buckets { + value := h.buckets[i] + runningTotal += value + if runningTotal == percentOfTotal { + // We hit an exact bucket boundary. If the next bucket has data, it is a + // good estimate of the value. If the bucket is empty, we interpolate the + // midpoint between the next bucket's boundary and the next non-zero + // bucket. If the remaining buckets are all empty, then we use the + // boundary for the next bucket as the estimate. + j := uint8(i + 1) + min := bucketBoundary(j) + if runningTotal < total { + for h.buckets[j] == 0 { + j++ + } + } + max := bucketBoundary(j) + return min + round(float64(max-min)/2) + } else if runningTotal > percentOfTotal { + // The value is in this bucket. Interpolate the value. + delta := runningTotal - percentOfTotal + percentBucket := float64(value-delta) / float64(value) + bucketMin := bucketBoundary(uint8(i)) + nextBucketMin := bucketBoundary(uint8(i + 1)) + bucketSize := nextBucketMin - bucketMin + return bucketMin + round(percentBucket*float64(bucketSize)) + } + } + return bucketBoundary(bucketCount - 1) +} + +// Median returns the estimated median of the observed values. +func (h *histogram) median() int64 { + return h.percentileBoundary(0.5) +} + +// Add adds other to h. +func (h *histogram) Add(other timeseries.Observable) { + o := other.(*histogram) + if o.valueCount == 0 { + // Other histogram is empty + } else if h.valueCount >= 0 && o.valueCount > 0 && h.value == o.value { + // Both have a single bucketed value, aggregate them + h.valueCount += o.valueCount + } else { + // Two different values necessitate buckets in this histogram + h.allocateBuckets() + if o.valueCount >= 0 { + h.buckets[o.value] += o.valueCount + } else { + for i := range h.buckets { + h.buckets[i] += o.buckets[i] + } + } + } + h.sumOfSquares += o.sumOfSquares + h.sum += o.sum +} + +// Clear resets the histogram to an empty state, removing all observed values. +func (h *histogram) Clear() { + h.buckets = nil + h.value = 0 + h.valueCount = 0 + h.sum = 0 + h.sumOfSquares = 0 +} + +// CopyFrom copies from other, which must be a *histogram, into h. +func (h *histogram) CopyFrom(other timeseries.Observable) { + o := other.(*histogram) + if o.valueCount == -1 { + h.allocateBuckets() + copy(h.buckets, o.buckets) + } + h.sum = o.sum + h.sumOfSquares = o.sumOfSquares + h.value = o.value + h.valueCount = o.valueCount +} + +// Multiply scales the histogram by the specified ratio. +func (h *histogram) Multiply(ratio float64) { + if h.valueCount == -1 { + for i := range h.buckets { + h.buckets[i] = int64(float64(h.buckets[i]) * ratio) + } + } else { + h.valueCount = int64(float64(h.valueCount) * ratio) + } + h.sum = int64(float64(h.sum) * ratio) + h.sumOfSquares = h.sumOfSquares * ratio +} + +// New creates a new histogram. +func (h *histogram) New() timeseries.Observable { + r := new(histogram) + r.Clear() + return r +} + +func (h *histogram) String() string { + return fmt.Sprintf("%d, %f, %d, %d, %v", + h.sum, h.sumOfSquares, h.value, h.valueCount, h.buckets) +} + +// round returns the closest int64 to the argument +func round(in float64) int64 { + return int64(math.Floor(in + 0.5)) +} + +// bucketBoundary returns the first value in the bucket. +func bucketBoundary(bucket uint8) int64 { + if bucket == 0 { + return 0 + } + return 1 << bucket +} + +// bucketData holds data about a specific bucket for use in distTmpl. +type bucketData struct { + Lower, Upper int64 + N int64 + Pct, CumulativePct float64 + GraphWidth int +} + +// data holds data about a Distribution for use in distTmpl. +type data struct { + Buckets []*bucketData + Count, Median int64 + Mean, StandardDeviation float64 +} + +// maxHTMLBarWidth is the maximum width of the HTML bar for visualizing buckets. +const maxHTMLBarWidth = 350.0 + +// newData returns data representing h for use in distTmpl. +func (h *histogram) newData() *data { + // Force the allocation of buckets to simplify the rendering implementation + h.allocateBuckets() + // We scale the bars on the right so that the largest bar is + // maxHTMLBarWidth pixels in width. + maxBucket := int64(0) + for _, n := range h.buckets { + if n > maxBucket { + maxBucket = n + } + } + total := h.total() + barsizeMult := maxHTMLBarWidth / float64(maxBucket) + var pctMult float64 + if total == 0 { + pctMult = 1.0 + } else { + pctMult = 100.0 / float64(total) + } + + buckets := make([]*bucketData, len(h.buckets)) + runningTotal := int64(0) + for i, n := range h.buckets { + if n == 0 { + continue + } + runningTotal += n + var upperBound int64 + if i < bucketCount-1 { + upperBound = bucketBoundary(uint8(i + 1)) + } else { + upperBound = math.MaxInt64 + } + buckets[i] = &bucketData{ + Lower: bucketBoundary(uint8(i)), + Upper: upperBound, + N: n, + Pct: float64(n) * pctMult, + CumulativePct: float64(runningTotal) * pctMult, + GraphWidth: int(float64(n) * barsizeMult), + } + } + return &data{ + Buckets: buckets, + Count: total, + Median: h.median(), + Mean: h.average(), + StandardDeviation: h.standardDeviation(), + } +} + +func (h *histogram) html() template.HTML { + buf := new(bytes.Buffer) + if err := distTmpl.Execute(buf, h.newData()); err != nil { + buf.Reset() + log.Printf("net/trace: couldn't execute template: %v", err) + } + return template.HTML(buf.String()) +} + +// Input: data +var distTmpl = template.Must(template.New("distTmpl").Parse(` + + + + + + + +
Count: {{.Count}}Mean: {{printf "%.0f" .Mean}}StdDev: {{printf "%.0f" .StandardDeviation}}Median: {{.Median}}
+
+ +{{range $b := .Buckets}} +{{if $b}} + + + + + + + + + +{{end}} +{{end}} +
[{{.Lower}},{{.Upper}}){{.N}}{{printf "%#.3f" .Pct}}%{{printf "%#.3f" .CumulativePct}}%
+`)) diff --git a/vendor/golang.org/x/net/trace/trace.go b/vendor/golang.org/x/net/trace/trace.go new file mode 100644 index 0000000000..0767c8c69d --- /dev/null +++ b/vendor/golang.org/x/net/trace/trace.go @@ -0,0 +1,1059 @@ +// 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. + +/* +Package trace implements tracing of requests and long-lived objects. +It exports HTTP interfaces on /debug/requests and /debug/events. + +A trace.Trace provides tracing for short-lived objects, usually requests. +A request handler might be implemented like this: + + func fooHandler(w http.ResponseWriter, req *http.Request) { + tr := trace.New("mypkg.Foo", req.URL.Path) + defer tr.Finish() + ... + tr.LazyPrintf("some event %q happened", str) + ... + if err := somethingImportant(); err != nil { + tr.LazyPrintf("somethingImportant failed: %v", err) + tr.SetError() + } + } + +The /debug/requests HTTP endpoint organizes the traces by family, +errors, and duration. It also provides histogram of request duration +for each family. + +A trace.EventLog provides tracing for long-lived objects, such as RPC +connections. + + // A Fetcher fetches URL paths for a single domain. + type Fetcher struct { + domain string + events trace.EventLog + } + + func NewFetcher(domain string) *Fetcher { + return &Fetcher{ + domain, + trace.NewEventLog("mypkg.Fetcher", domain), + } + } + + func (f *Fetcher) Fetch(path string) (string, error) { + resp, err := http.Get("http://" + f.domain + "/" + path) + if err != nil { + f.events.Errorf("Get(%q) = %v", path, err) + return "", err + } + f.events.Printf("Get(%q) = %s", path, resp.Status) + ... + } + + func (f *Fetcher) Close() error { + f.events.Finish() + return nil + } + +The /debug/events HTTP endpoint organizes the event logs by family and +by time since the last error. The expanded view displays recent log +entries and the log's call stack. +*/ +package trace // import "golang.org/x/net/trace" + +import ( + "bytes" + "fmt" + "html/template" + "io" + "log" + "net" + "net/http" + "runtime" + "sort" + "strconv" + "sync" + "sync/atomic" + "time" + + "golang.org/x/net/context" + "golang.org/x/net/internal/timeseries" +) + +// DebugUseAfterFinish controls whether to debug uses of Trace values after finishing. +// FOR DEBUGGING ONLY. This will slow down the program. +var DebugUseAfterFinish = false + +// AuthRequest determines whether a specific request is permitted to load the +// /debug/requests or /debug/events pages. +// +// It returns two bools; the first indicates whether the page may be viewed at all, +// and the second indicates whether sensitive events will be shown. +// +// AuthRequest may be replaced by a program to customise its authorisation requirements. +// +// The default AuthRequest function returns (true, true) iff the request comes from localhost/127.0.0.1/[::1]. +var AuthRequest = func(req *http.Request) (any, sensitive bool) { + host, _, err := net.SplitHostPort(req.RemoteAddr) + switch { + case err != nil: // Badly formed address; fail closed. + return false, false + case host == "localhost" || host == "127.0.0.1" || host == "::1": + return true, true + default: + return false, false + } +} + +func init() { + http.HandleFunc("/debug/requests", func(w http.ResponseWriter, req *http.Request) { + any, sensitive := AuthRequest(req) + if !any { + http.Error(w, "not allowed", http.StatusUnauthorized) + return + } + w.Header().Set("Content-Type", "text/html; charset=utf-8") + Render(w, req, sensitive) + }) + http.HandleFunc("/debug/events", func(w http.ResponseWriter, req *http.Request) { + any, sensitive := AuthRequest(req) + if !any { + http.Error(w, "not allowed", http.StatusUnauthorized) + return + } + w.Header().Set("Content-Type", "text/html; charset=utf-8") + RenderEvents(w, req, sensitive) + }) +} + +// Render renders the HTML page typically served at /debug/requests. +// It does not do any auth checking; see AuthRequest for the default auth check +// used by the handler registered on http.DefaultServeMux. +// req may be nil. +func Render(w io.Writer, req *http.Request, sensitive bool) { + data := &struct { + Families []string + ActiveTraceCount map[string]int + CompletedTraces map[string]*family + + // Set when a bucket has been selected. + Traces traceList + Family string + Bucket int + Expanded bool + Traced bool + Active bool + ShowSensitive bool // whether to show sensitive events + + Histogram template.HTML + HistogramWindow string // e.g. "last minute", "last hour", "all time" + + // If non-zero, the set of traces is a partial set, + // and this is the total number. + Total int + }{ + CompletedTraces: completedTraces, + } + + data.ShowSensitive = sensitive + if req != nil { + // Allow show_sensitive=0 to force hiding of sensitive data for testing. + // This only goes one way; you can't use show_sensitive=1 to see things. + if req.FormValue("show_sensitive") == "0" { + data.ShowSensitive = false + } + + if exp, err := strconv.ParseBool(req.FormValue("exp")); err == nil { + data.Expanded = exp + } + if exp, err := strconv.ParseBool(req.FormValue("rtraced")); err == nil { + data.Traced = exp + } + } + + completedMu.RLock() + data.Families = make([]string, 0, len(completedTraces)) + for fam := range completedTraces { + data.Families = append(data.Families, fam) + } + completedMu.RUnlock() + sort.Strings(data.Families) + + // We are careful here to minimize the time spent locking activeMu, + // since that lock is required every time an RPC starts and finishes. + data.ActiveTraceCount = make(map[string]int, len(data.Families)) + activeMu.RLock() + for fam, s := range activeTraces { + data.ActiveTraceCount[fam] = s.Len() + } + activeMu.RUnlock() + + var ok bool + data.Family, data.Bucket, ok = parseArgs(req) + switch { + case !ok: + // No-op + case data.Bucket == -1: + data.Active = true + n := data.ActiveTraceCount[data.Family] + data.Traces = getActiveTraces(data.Family) + if len(data.Traces) < n { + data.Total = n + } + case data.Bucket < bucketsPerFamily: + if b := lookupBucket(data.Family, data.Bucket); b != nil { + data.Traces = b.Copy(data.Traced) + } + default: + if f := getFamily(data.Family, false); f != nil { + var obs timeseries.Observable + f.LatencyMu.RLock() + switch o := data.Bucket - bucketsPerFamily; o { + case 0: + obs = f.Latency.Minute() + data.HistogramWindow = "last minute" + case 1: + obs = f.Latency.Hour() + data.HistogramWindow = "last hour" + case 2: + obs = f.Latency.Total() + data.HistogramWindow = "all time" + } + f.LatencyMu.RUnlock() + if obs != nil { + data.Histogram = obs.(*histogram).html() + } + } + } + + if data.Traces != nil { + defer data.Traces.Free() + sort.Sort(data.Traces) + } + + completedMu.RLock() + defer completedMu.RUnlock() + if err := pageTmpl.ExecuteTemplate(w, "Page", data); err != nil { + log.Printf("net/trace: Failed executing template: %v", err) + } +} + +func parseArgs(req *http.Request) (fam string, b int, ok bool) { + if req == nil { + return "", 0, false + } + fam, bStr := req.FormValue("fam"), req.FormValue("b") + if fam == "" || bStr == "" { + return "", 0, false + } + b, err := strconv.Atoi(bStr) + if err != nil || b < -1 { + return "", 0, false + } + + return fam, b, true +} + +func lookupBucket(fam string, b int) *traceBucket { + f := getFamily(fam, false) + if f == nil || b < 0 || b >= len(f.Buckets) { + return nil + } + return f.Buckets[b] +} + +type contextKeyT string + +var contextKey = contextKeyT("golang.org/x/net/trace.Trace") + +// NewContext returns a copy of the parent context +// and associates it with a Trace. +func NewContext(ctx context.Context, tr Trace) context.Context { + return context.WithValue(ctx, contextKey, tr) +} + +// FromContext returns the Trace bound to the context, if any. +func FromContext(ctx context.Context) (tr Trace, ok bool) { + tr, ok = ctx.Value(contextKey).(Trace) + return +} + +// Trace represents an active request. +type Trace interface { + // LazyLog adds x to the event log. It will be evaluated each time the + // /debug/requests page is rendered. Any memory referenced by x will be + // pinned until the trace is finished and later discarded. + LazyLog(x fmt.Stringer, sensitive bool) + + // LazyPrintf evaluates its arguments with fmt.Sprintf each time the + // /debug/requests page is rendered. Any memory referenced by a will be + // pinned until the trace is finished and later discarded. + LazyPrintf(format string, a ...interface{}) + + // SetError declares that this trace resulted in an error. + SetError() + + // SetRecycler sets a recycler for the trace. + // f will be called for each event passed to LazyLog at a time when + // it is no longer required, whether while the trace is still active + // and the event is discarded, or when a completed trace is discarded. + SetRecycler(f func(interface{})) + + // SetTraceInfo sets the trace info for the trace. + // This is currently unused. + SetTraceInfo(traceID, spanID uint64) + + // SetMaxEvents sets the maximum number of events that will be stored + // in the trace. This has no effect if any events have already been + // added to the trace. + SetMaxEvents(m int) + + // Finish declares that this trace is complete. + // The trace should not be used after calling this method. + Finish() +} + +type lazySprintf struct { + format string + a []interface{} +} + +func (l *lazySprintf) String() string { + return fmt.Sprintf(l.format, l.a...) +} + +// New returns a new Trace with the specified family and title. +func New(family, title string) Trace { + tr := newTrace() + tr.ref() + tr.Family, tr.Title = family, title + tr.Start = time.Now() + tr.events = make([]event, 0, maxEventsPerTrace) + + activeMu.RLock() + s := activeTraces[tr.Family] + activeMu.RUnlock() + if s == nil { + activeMu.Lock() + s = activeTraces[tr.Family] // check again + if s == nil { + s = new(traceSet) + activeTraces[tr.Family] = s + } + activeMu.Unlock() + } + s.Add(tr) + + // Trigger allocation of the completed trace structure for this family. + // This will cause the family to be present in the request page during + // the first trace of this family. We don't care about the return value, + // nor is there any need for this to run inline, so we execute it in its + // own goroutine, but only if the family isn't allocated yet. + completedMu.RLock() + if _, ok := completedTraces[tr.Family]; !ok { + go allocFamily(tr.Family) + } + completedMu.RUnlock() + + return tr +} + +func (tr *trace) Finish() { + tr.Elapsed = time.Now().Sub(tr.Start) + if DebugUseAfterFinish { + buf := make([]byte, 4<<10) // 4 KB should be enough + n := runtime.Stack(buf, false) + tr.finishStack = buf[:n] + } + + activeMu.RLock() + m := activeTraces[tr.Family] + activeMu.RUnlock() + m.Remove(tr) + + f := getFamily(tr.Family, true) + for _, b := range f.Buckets { + if b.Cond.match(tr) { + b.Add(tr) + } + } + // Add a sample of elapsed time as microseconds to the family's timeseries + h := new(histogram) + h.addMeasurement(tr.Elapsed.Nanoseconds() / 1e3) + f.LatencyMu.Lock() + f.Latency.Add(h) + f.LatencyMu.Unlock() + + tr.unref() // matches ref in New +} + +const ( + bucketsPerFamily = 9 + tracesPerBucket = 10 + maxActiveTraces = 20 // Maximum number of active traces to show. + maxEventsPerTrace = 10 + numHistogramBuckets = 38 +) + +var ( + // The active traces. + activeMu sync.RWMutex + activeTraces = make(map[string]*traceSet) // family -> traces + + // Families of completed traces. + completedMu sync.RWMutex + completedTraces = make(map[string]*family) // family -> traces +) + +type traceSet struct { + mu sync.RWMutex + m map[*trace]bool + + // We could avoid the entire map scan in FirstN by having a slice of all the traces + // ordered by start time, and an index into that from the trace struct, with a periodic + // repack of the slice after enough traces finish; we could also use a skip list or similar. + // However, that would shift some of the expense from /debug/requests time to RPC time, + // which is probably the wrong trade-off. +} + +func (ts *traceSet) Len() int { + ts.mu.RLock() + defer ts.mu.RUnlock() + return len(ts.m) +} + +func (ts *traceSet) Add(tr *trace) { + ts.mu.Lock() + if ts.m == nil { + ts.m = make(map[*trace]bool) + } + ts.m[tr] = true + ts.mu.Unlock() +} + +func (ts *traceSet) Remove(tr *trace) { + ts.mu.Lock() + delete(ts.m, tr) + ts.mu.Unlock() +} + +// FirstN returns the first n traces ordered by time. +func (ts *traceSet) FirstN(n int) traceList { + ts.mu.RLock() + defer ts.mu.RUnlock() + + if n > len(ts.m) { + n = len(ts.m) + } + trl := make(traceList, 0, n) + + // Fast path for when no selectivity is needed. + if n == len(ts.m) { + for tr := range ts.m { + tr.ref() + trl = append(trl, tr) + } + sort.Sort(trl) + return trl + } + + // Pick the oldest n traces. + // This is inefficient. See the comment in the traceSet struct. + for tr := range ts.m { + // Put the first n traces into trl in the order they occur. + // When we have n, sort trl, and thereafter maintain its order. + if len(trl) < n { + tr.ref() + trl = append(trl, tr) + if len(trl) == n { + // This is guaranteed to happen exactly once during this loop. + sort.Sort(trl) + } + continue + } + if tr.Start.After(trl[n-1].Start) { + continue + } + + // Find where to insert this one. + tr.ref() + i := sort.Search(n, func(i int) bool { return trl[i].Start.After(tr.Start) }) + trl[n-1].unref() + copy(trl[i+1:], trl[i:]) + trl[i] = tr + } + + return trl +} + +func getActiveTraces(fam string) traceList { + activeMu.RLock() + s := activeTraces[fam] + activeMu.RUnlock() + if s == nil { + return nil + } + return s.FirstN(maxActiveTraces) +} + +func getFamily(fam string, allocNew bool) *family { + completedMu.RLock() + f := completedTraces[fam] + completedMu.RUnlock() + if f == nil && allocNew { + f = allocFamily(fam) + } + return f +} + +func allocFamily(fam string) *family { + completedMu.Lock() + defer completedMu.Unlock() + f := completedTraces[fam] + if f == nil { + f = newFamily() + completedTraces[fam] = f + } + return f +} + +// family represents a set of trace buckets and associated latency information. +type family struct { + // traces may occur in multiple buckets. + Buckets [bucketsPerFamily]*traceBucket + + // latency time series + LatencyMu sync.RWMutex + Latency *timeseries.MinuteHourSeries +} + +func newFamily() *family { + return &family{ + Buckets: [bucketsPerFamily]*traceBucket{ + {Cond: minCond(0)}, + {Cond: minCond(50 * time.Millisecond)}, + {Cond: minCond(100 * time.Millisecond)}, + {Cond: minCond(200 * time.Millisecond)}, + {Cond: minCond(500 * time.Millisecond)}, + {Cond: minCond(1 * time.Second)}, + {Cond: minCond(10 * time.Second)}, + {Cond: minCond(100 * time.Second)}, + {Cond: errorCond{}}, + }, + Latency: timeseries.NewMinuteHourSeries(func() timeseries.Observable { return new(histogram) }), + } +} + +// traceBucket represents a size-capped bucket of historic traces, +// along with a condition for a trace to belong to the bucket. +type traceBucket struct { + Cond cond + + // Ring buffer implementation of a fixed-size FIFO queue. + mu sync.RWMutex + buf [tracesPerBucket]*trace + start int // < tracesPerBucket + length int // <= tracesPerBucket +} + +func (b *traceBucket) Add(tr *trace) { + b.mu.Lock() + defer b.mu.Unlock() + + i := b.start + b.length + if i >= tracesPerBucket { + i -= tracesPerBucket + } + if b.length == tracesPerBucket { + // "Remove" an element from the bucket. + b.buf[i].unref() + b.start++ + if b.start == tracesPerBucket { + b.start = 0 + } + } + b.buf[i] = tr + if b.length < tracesPerBucket { + b.length++ + } + tr.ref() +} + +// Copy returns a copy of the traces in the bucket. +// If tracedOnly is true, only the traces with trace information will be returned. +// The logs will be ref'd before returning; the caller should call +// the Free method when it is done with them. +// TODO(dsymonds): keep track of traced requests in separate buckets. +func (b *traceBucket) Copy(tracedOnly bool) traceList { + b.mu.RLock() + defer b.mu.RUnlock() + + trl := make(traceList, 0, b.length) + for i, x := 0, b.start; i < b.length; i++ { + tr := b.buf[x] + if !tracedOnly || tr.spanID != 0 { + tr.ref() + trl = append(trl, tr) + } + x++ + if x == b.length { + x = 0 + } + } + return trl +} + +func (b *traceBucket) Empty() bool { + b.mu.RLock() + defer b.mu.RUnlock() + return b.length == 0 +} + +// cond represents a condition on a trace. +type cond interface { + match(t *trace) bool + String() string +} + +type minCond time.Duration + +func (m minCond) match(t *trace) bool { return t.Elapsed >= time.Duration(m) } +func (m minCond) String() string { return fmt.Sprintf("≥%gs", time.Duration(m).Seconds()) } + +type errorCond struct{} + +func (e errorCond) match(t *trace) bool { return t.IsError } +func (e errorCond) String() string { return "errors" } + +type traceList []*trace + +// Free calls unref on each element of the list. +func (trl traceList) Free() { + for _, t := range trl { + t.unref() + } +} + +// traceList may be sorted in reverse chronological order. +func (trl traceList) Len() int { return len(trl) } +func (trl traceList) Less(i, j int) bool { return trl[i].Start.After(trl[j].Start) } +func (trl traceList) Swap(i, j int) { trl[i], trl[j] = trl[j], trl[i] } + +// An event is a timestamped log entry in a trace. +type event struct { + When time.Time + Elapsed time.Duration // since previous event in trace + NewDay bool // whether this event is on a different day to the previous event + Recyclable bool // whether this event was passed via LazyLog + What interface{} // string or fmt.Stringer + Sensitive bool // whether this event contains sensitive information +} + +// WhenString returns a string representation of the elapsed time of the event. +// It will include the date if midnight was crossed. +func (e event) WhenString() string { + if e.NewDay { + return e.When.Format("2006/01/02 15:04:05.000000") + } + return e.When.Format("15:04:05.000000") +} + +// discarded represents a number of discarded events. +// It is stored as *discarded to make it easier to update in-place. +type discarded int + +func (d *discarded) String() string { + return fmt.Sprintf("(%d events discarded)", int(*d)) +} + +// trace represents an active or complete request, +// either sent or received by this program. +type trace struct { + // Family is the top-level grouping of traces to which this belongs. + Family string + + // Title is the title of this trace. + Title string + + // Timing information. + Start time.Time + Elapsed time.Duration // zero while active + + // Trace information if non-zero. + traceID uint64 + spanID uint64 + + // Whether this trace resulted in an error. + IsError bool + + // Append-only sequence of events (modulo discards). + mu sync.RWMutex + events []event + + refs int32 // how many buckets this is in + recycler func(interface{}) + disc discarded // scratch space to avoid allocation + + finishStack []byte // where finish was called, if DebugUseAfterFinish is set +} + +func (tr *trace) reset() { + // Clear all but the mutex. Mutexes may not be copied, even when unlocked. + tr.Family = "" + tr.Title = "" + tr.Start = time.Time{} + tr.Elapsed = 0 + tr.traceID = 0 + tr.spanID = 0 + tr.IsError = false + tr.events = nil + tr.refs = 0 + tr.recycler = nil + tr.disc = 0 + tr.finishStack = nil +} + +// delta returns the elapsed time since the last event or the trace start, +// and whether it spans midnight. +// L >= tr.mu +func (tr *trace) delta(t time.Time) (time.Duration, bool) { + if len(tr.events) == 0 { + return t.Sub(tr.Start), false + } + prev := tr.events[len(tr.events)-1].When + return t.Sub(prev), prev.Day() != t.Day() +} + +func (tr *trace) addEvent(x interface{}, recyclable, sensitive bool) { + if DebugUseAfterFinish && tr.finishStack != nil { + buf := make([]byte, 4<<10) // 4 KB should be enough + n := runtime.Stack(buf, false) + log.Printf("net/trace: trace used after finish:\nFinished at:\n%s\nUsed at:\n%s", tr.finishStack, buf[:n]) + } + + /* + NOTE TO DEBUGGERS + + If you are here because your program panicked in this code, + it is almost definitely the fault of code using this package, + and very unlikely to be the fault of this code. + + The most likely scenario is that some code elsewhere is using + a requestz.Trace after its Finish method is called. + You can temporarily set the DebugUseAfterFinish var + to help discover where that is; do not leave that var set, + since it makes this package much less efficient. + */ + + e := event{When: time.Now(), What: x, Recyclable: recyclable, Sensitive: sensitive} + tr.mu.Lock() + e.Elapsed, e.NewDay = tr.delta(e.When) + if len(tr.events) < cap(tr.events) { + tr.events = append(tr.events, e) + } else { + // Discard the middle events. + di := int((cap(tr.events) - 1) / 2) + if d, ok := tr.events[di].What.(*discarded); ok { + (*d)++ + } else { + // disc starts at two to count for the event it is replacing, + // plus the next one that we are about to drop. + tr.disc = 2 + if tr.recycler != nil && tr.events[di].Recyclable { + go tr.recycler(tr.events[di].What) + } + tr.events[di].What = &tr.disc + } + // The timestamp of the discarded meta-event should be + // the time of the last event it is representing. + tr.events[di].When = tr.events[di+1].When + + if tr.recycler != nil && tr.events[di+1].Recyclable { + go tr.recycler(tr.events[di+1].What) + } + copy(tr.events[di+1:], tr.events[di+2:]) + tr.events[cap(tr.events)-1] = e + } + tr.mu.Unlock() +} + +func (tr *trace) LazyLog(x fmt.Stringer, sensitive bool) { + tr.addEvent(x, true, sensitive) +} + +func (tr *trace) LazyPrintf(format string, a ...interface{}) { + tr.addEvent(&lazySprintf{format, a}, false, false) +} + +func (tr *trace) SetError() { tr.IsError = true } + +func (tr *trace) SetRecycler(f func(interface{})) { + tr.recycler = f +} + +func (tr *trace) SetTraceInfo(traceID, spanID uint64) { + tr.traceID, tr.spanID = traceID, spanID +} + +func (tr *trace) SetMaxEvents(m int) { + // Always keep at least three events: first, discarded count, last. + if len(tr.events) == 0 && m > 3 { + tr.events = make([]event, 0, m) + } +} + +func (tr *trace) ref() { + atomic.AddInt32(&tr.refs, 1) +} + +func (tr *trace) unref() { + if atomic.AddInt32(&tr.refs, -1) == 0 { + if tr.recycler != nil { + // freeTrace clears tr, so we hold tr.recycler and tr.events here. + go func(f func(interface{}), es []event) { + for _, e := range es { + if e.Recyclable { + f(e.What) + } + } + }(tr.recycler, tr.events) + } + + freeTrace(tr) + } +} + +func (tr *trace) When() string { + return tr.Start.Format("2006/01/02 15:04:05.000000") +} + +func (tr *trace) ElapsedTime() string { + t := tr.Elapsed + if t == 0 { + // Active trace. + t = time.Since(tr.Start) + } + return fmt.Sprintf("%.6f", t.Seconds()) +} + +func (tr *trace) Events() []event { + tr.mu.RLock() + defer tr.mu.RUnlock() + return tr.events +} + +var traceFreeList = make(chan *trace, 1000) // TODO(dsymonds): Use sync.Pool? + +// newTrace returns a trace ready to use. +func newTrace() *trace { + select { + case tr := <-traceFreeList: + return tr + default: + return new(trace) + } +} + +// freeTrace adds tr to traceFreeList if there's room. +// This is non-blocking. +func freeTrace(tr *trace) { + if DebugUseAfterFinish { + return // never reuse + } + tr.reset() + select { + case traceFreeList <- tr: + default: + } +} + +func elapsed(d time.Duration) string { + b := []byte(fmt.Sprintf("%.6f", d.Seconds())) + + // For subsecond durations, blank all zeros before decimal point, + // and all zeros between the decimal point and the first non-zero digit. + if d < time.Second { + dot := bytes.IndexByte(b, '.') + for i := 0; i < dot; i++ { + b[i] = ' ' + } + for i := dot + 1; i < len(b); i++ { + if b[i] == '0' { + b[i] = ' ' + } else { + break + } + } + } + + return string(b) +} + +var pageTmpl = template.Must(template.New("Page").Funcs(template.FuncMap{ + "elapsed": elapsed, + "add": func(a, b int) int { return a + b }, +}).Parse(pageHTML)) + +const pageHTML = ` +{{template "Prolog" .}} +{{template "StatusTable" .}} +{{template "Epilog" .}} + +{{define "Prolog"}} + + + /debug/requests + + + + +

/debug/requests

+{{end}} {{/* end of Prolog */}} + +{{define "StatusTable"}} + + {{range $fam := .Families}} + + + + {{$n := index $.ActiveTraceCount $fam}} + + + {{$f := index $.CompletedTraces $fam}} + {{range $i, $b := $f.Buckets}} + {{$empty := $b.Empty}} + + {{end}} + + {{$nb := len $f.Buckets}} + + + + + + {{end}} +
{{$fam}} + {{if $n}}{{end}} + [{{$n}} active] + {{if $n}}{{end}} + + {{if not $empty}}{{end}} + [{{.Cond}}] + {{if not $empty}}{{end}} + + [minute] + + [hour] + + [total] +
+{{end}} {{/* end of StatusTable */}} + +{{define "Epilog"}} +{{if $.Traces}} +
+

Family: {{$.Family}}

+ +{{if or $.Expanded $.Traced}} + [Normal/Summary] +{{else}} + [Normal/Summary] +{{end}} + +{{if or (not $.Expanded) $.Traced}} + [Normal/Expanded] +{{else}} + [Normal/Expanded] +{{end}} + +{{if not $.Active}} + {{if or $.Expanded (not $.Traced)}} + [Traced/Summary] + {{else}} + [Traced/Summary] + {{end}} + {{if or (not $.Expanded) (not $.Traced)}} + [Traced/Expanded] + {{else}} + [Traced/Expanded] + {{end}} +{{end}} + +{{if $.Total}} +

Showing {{len $.Traces}} of {{$.Total}} traces.

+{{end}} + + + + + {{range $tr := $.Traces}} + + + + + {{/* TODO: include traceID/spanID */}} + + {{if $.Expanded}} + {{range $tr.Events}} + + + + + + {{end}} + {{end}} + {{end}} +
+ {{if $.Active}}Active{{else}}Completed{{end}} Requests +
WhenElapsed (s)
{{$tr.When}}{{$tr.ElapsedTime}}{{$tr.Title}}
{{.WhenString}}{{elapsed .Elapsed}}{{if or $.ShowSensitive (not .Sensitive)}}... {{.What}}{{else}}[redacted]{{end}}
+{{end}} {{/* if $.Traces */}} + +{{if $.Histogram}} +

Latency (µs) of {{$.Family}} over {{$.HistogramWindow}}

+{{$.Histogram}} +{{end}} {{/* if $.Histogram */}} + + + +{{end}} {{/* end of Epilog */}} +` diff --git a/vendor/golang.org/x/sys/LICENSE b/vendor/golang.org/x/sys/LICENSE new file mode 100644 index 0000000000..6a66aea5ea --- /dev/null +++ b/vendor/golang.org/x/sys/LICENSE @@ -0,0 +1,27 @@ +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. diff --git a/vendor/golang.org/x/sys/PATENTS b/vendor/golang.org/x/sys/PATENTS new file mode 100644 index 0000000000..733099041f --- /dev/null +++ b/vendor/golang.org/x/sys/PATENTS @@ -0,0 +1,22 @@ +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. diff --git a/vendor/golang.org/x/sys/unix/asm.s b/vendor/golang.org/x/sys/unix/asm.s new file mode 100644 index 0000000000..8ed2fdb94b --- /dev/null +++ b/vendor/golang.org/x/sys/unix/asm.s @@ -0,0 +1,10 @@ +// 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" + +TEXT ·use(SB),NOSPLIT,$0 + RET diff --git a/vendor/golang.org/x/sys/unix/asm_darwin_386.s b/vendor/golang.org/x/sys/unix/asm_darwin_386.s new file mode 100644 index 0000000000..8a7278319e --- /dev/null +++ b/vendor/golang.org/x/sys/unix/asm_darwin_386.s @@ -0,0 +1,29 @@ +// 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) diff --git a/vendor/golang.org/x/sys/unix/asm_darwin_amd64.s b/vendor/golang.org/x/sys/unix/asm_darwin_amd64.s new file mode 100644 index 0000000000..6321421f27 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/asm_darwin_amd64.s @@ -0,0 +1,29 @@ +// 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) diff --git a/vendor/golang.org/x/sys/unix/asm_darwin_arm.s b/vendor/golang.org/x/sys/unix/asm_darwin_arm.s new file mode 100644 index 0000000000..333242d506 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/asm_darwin_arm.s @@ -0,0 +1,30 @@ +// 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) diff --git a/vendor/golang.org/x/sys/unix/asm_darwin_arm64.s b/vendor/golang.org/x/sys/unix/asm_darwin_arm64.s new file mode 100644 index 0000000000..97e0174371 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/asm_darwin_arm64.s @@ -0,0 +1,30 @@ +// 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) diff --git a/vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s b/vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s new file mode 100644 index 0000000000..d5ed6726cc --- /dev/null +++ b/vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s @@ -0,0 +1,29 @@ +// 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) diff --git a/vendor/golang.org/x/sys/unix/asm_freebsd_386.s b/vendor/golang.org/x/sys/unix/asm_freebsd_386.s new file mode 100644 index 0000000000..c9a0a26015 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/asm_freebsd_386.s @@ -0,0 +1,29 @@ +// 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) diff --git a/vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s b/vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s new file mode 100644 index 0000000000..35172477c8 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s @@ -0,0 +1,29 @@ +// 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) diff --git a/vendor/golang.org/x/sys/unix/asm_freebsd_arm.s b/vendor/golang.org/x/sys/unix/asm_freebsd_arm.s new file mode 100644 index 0000000000..9227c875bf --- /dev/null +++ b/vendor/golang.org/x/sys/unix/asm_freebsd_arm.s @@ -0,0 +1,29 @@ +// 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) diff --git a/vendor/golang.org/x/sys/unix/asm_linux_386.s b/vendor/golang.org/x/sys/unix/asm_linux_386.s new file mode 100644 index 0000000000..4db2909323 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/asm_linux_386.s @@ -0,0 +1,35 @@ +// 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) diff --git a/vendor/golang.org/x/sys/unix/asm_linux_amd64.s b/vendor/golang.org/x/sys/unix/asm_linux_amd64.s new file mode 100644 index 0000000000..44e25c62f9 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/asm_linux_amd64.s @@ -0,0 +1,29 @@ +// 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) diff --git a/vendor/golang.org/x/sys/unix/asm_linux_arm.s b/vendor/golang.org/x/sys/unix/asm_linux_arm.s new file mode 100644 index 0000000000..cf0b574658 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/asm_linux_arm.s @@ -0,0 +1,29 @@ +// 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) diff --git a/vendor/golang.org/x/sys/unix/asm_linux_arm64.s b/vendor/golang.org/x/sys/unix/asm_linux_arm64.s new file mode 100644 index 0000000000..4be9bfedea --- /dev/null +++ b/vendor/golang.org/x/sys/unix/asm_linux_arm64.s @@ -0,0 +1,24 @@ +// 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) diff --git a/vendor/golang.org/x/sys/unix/asm_linux_mips64x.s b/vendor/golang.org/x/sys/unix/asm_linux_mips64x.s new file mode 100644 index 0000000000..724e580c4e --- /dev/null +++ b/vendor/golang.org/x/sys/unix/asm_linux_mips64x.s @@ -0,0 +1,28 @@ +// 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) diff --git a/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s b/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s new file mode 100644 index 0000000000..8d231feb4b --- /dev/null +++ b/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s @@ -0,0 +1,28 @@ +// 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) diff --git a/vendor/golang.org/x/sys/unix/asm_linux_s390x.s b/vendor/golang.org/x/sys/unix/asm_linux_s390x.s new file mode 100644 index 0000000000..11889859fb --- /dev/null +++ b/vendor/golang.org/x/sys/unix/asm_linux_s390x.s @@ -0,0 +1,28 @@ +// 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) diff --git a/vendor/golang.org/x/sys/unix/asm_netbsd_386.s b/vendor/golang.org/x/sys/unix/asm_netbsd_386.s new file mode 100644 index 0000000000..48bdcd7632 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/asm_netbsd_386.s @@ -0,0 +1,29 @@ +// 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) diff --git a/vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s b/vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s new file mode 100644 index 0000000000..2ede05c72f --- /dev/null +++ b/vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s @@ -0,0 +1,29 @@ +// 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) diff --git a/vendor/golang.org/x/sys/unix/asm_netbsd_arm.s b/vendor/golang.org/x/sys/unix/asm_netbsd_arm.s new file mode 100644 index 0000000000..e8928571c4 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/asm_netbsd_arm.s @@ -0,0 +1,29 @@ +// 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) diff --git a/vendor/golang.org/x/sys/unix/asm_openbsd_386.s b/vendor/golang.org/x/sys/unix/asm_openbsd_386.s new file mode 100644 index 0000000000..00576f3c83 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/asm_openbsd_386.s @@ -0,0 +1,29 @@ +// 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) diff --git a/vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s b/vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s new file mode 100644 index 0000000000..790ef77f86 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s @@ -0,0 +1,29 @@ +// 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) diff --git a/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s b/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s new file mode 100644 index 0000000000..43ed17a05f --- /dev/null +++ b/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s @@ -0,0 +1,17 @@ +// 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-64 + JMP syscall·sysvicall6(SB) + +TEXT ·rawSysvicall6(SB),NOSPLIT,$0-64 + JMP syscall·rawSysvicall6(SB) diff --git a/vendor/golang.org/x/sys/unix/bluetooth_linux.go b/vendor/golang.org/x/sys/unix/bluetooth_linux.go new file mode 100644 index 0000000000..6e32296970 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/bluetooth_linux.go @@ -0,0 +1,35 @@ +// 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 +) diff --git a/vendor/golang.org/x/sys/unix/constants.go b/vendor/golang.org/x/sys/unix/constants.go new file mode 100644 index 0000000000..a96f0ebc26 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/constants.go @@ -0,0 +1,13 @@ +// 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 +) diff --git a/vendor/golang.org/x/sys/unix/env_unix.go b/vendor/golang.org/x/sys/unix/env_unix.go new file mode 100644 index 0000000000..45e281a047 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/env_unix.go @@ -0,0 +1,27 @@ +// 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() +} diff --git a/vendor/golang.org/x/sys/unix/env_unset.go b/vendor/golang.org/x/sys/unix/env_unset.go new file mode 100644 index 0000000000..9222262559 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/env_unset.go @@ -0,0 +1,14 @@ +// 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) +} diff --git a/vendor/golang.org/x/sys/unix/flock.go b/vendor/golang.org/x/sys/unix/flock.go new file mode 100644 index 0000000000..ce67a59528 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/flock.go @@ -0,0 +1,24 @@ +// +build linux darwin freebsd openbsd netbsd dragonfly + +// 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 +} diff --git a/vendor/golang.org/x/sys/unix/flock_linux_32bit.go b/vendor/golang.org/x/sys/unix/flock_linux_32bit.go new file mode 100644 index 0000000000..362831c3f7 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/flock_linux_32bit.go @@ -0,0 +1,13 @@ +// +build linux,386 linux,arm + +// 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 +} diff --git a/vendor/golang.org/x/sys/unix/gccgo.go b/vendor/golang.org/x/sys/unix/gccgo.go new file mode 100644 index 0000000000..94c8232124 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/gccgo.go @@ -0,0 +1,46 @@ +// 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) +} diff --git a/vendor/golang.org/x/sys/unix/gccgo_c.c b/vendor/golang.org/x/sys/unix/gccgo_c.c new file mode 100644 index 0000000000..07f6be0392 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/gccgo_c.c @@ -0,0 +1,41 @@ +// 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 +#include +#include + +#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))) +{ +} diff --git a/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go b/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go new file mode 100644 index 0000000000..bffe1a77db --- /dev/null +++ b/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go @@ -0,0 +1,20 @@ +// 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 +} diff --git a/vendor/golang.org/x/sys/unix/mkpost.go b/vendor/golang.org/x/sys/unix/mkpost.go new file mode 100644 index 0000000000..ed50d902af --- /dev/null +++ b/vendor/golang.org/x/sys/unix/mkpost.go @@ -0,0 +1,62 @@ +// 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 by mkall.sh. +package main + +import ( + "fmt" + "go/format" + "io/ioutil" + "log" + "os" + "regexp" +) + +func main() { + b, err := ioutil.ReadAll(os.Stdin) + if err != nil { + log.Fatal(err) + } + s := string(b) + + goarch := os.Getenv("GOARCH") + goos := os.Getenv("GOOS") + if goarch == "s390x" && goos == "linux" { + // Export the types of PtraceRegs fields. + re := regexp.MustCompile("ptrace(Psw|Fpregs|Per)") + s = re.ReplaceAllString(s, "Ptrace$1") + + // Replace padding fields inserted by cgo with blank identifiers. + re = regexp.MustCompile("Pad_cgo[A-Za-z0-9_]*") + s = re.ReplaceAllString(s, "_") + + // Replace other unwanted fields with blank identifiers. + re = regexp.MustCompile("X_[A-Za-z0-9_]*") + s = re.ReplaceAllString(s, "_") + + // Replace the control_regs union with a blank identifier for now. + re = regexp.MustCompile("(Control_regs)\\s+\\[0\\]uint64") + s = re.ReplaceAllString(s, "_ [0]uint64") + } + + // gofmt + b, err = format.Source([]byte(s)) + if err != nil { + log.Fatal(err) + } + + // Append this command to the header to show where the new file + // came from. + re := regexp.MustCompile("(cgo -godefs [a-zA-Z0-9_]+\\.go.*)") + b = re.ReplaceAll(b, []byte("$1 | go run mkpost.go")) + + fmt.Printf("%s", b) +} diff --git a/vendor/golang.org/x/sys/unix/race.go b/vendor/golang.org/x/sys/unix/race.go new file mode 100644 index 0000000000..3c7627eb5c --- /dev/null +++ b/vendor/golang.org/x/sys/unix/race.go @@ -0,0 +1,30 @@ +// 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) +} diff --git a/vendor/golang.org/x/sys/unix/race0.go b/vendor/golang.org/x/sys/unix/race0.go new file mode 100644 index 0000000000..f8678e0d21 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/race0.go @@ -0,0 +1,25 @@ +// 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) { +} diff --git a/vendor/golang.org/x/sys/unix/sockcmsg_linux.go b/vendor/golang.org/x/sys/unix/sockcmsg_linux.go new file mode 100644 index 0000000000..d9ff4731a2 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/sockcmsg_linux.go @@ -0,0 +1,36 @@ +// 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 +} diff --git a/vendor/golang.org/x/sys/unix/sockcmsg_unix.go b/vendor/golang.org/x/sys/unix/sockcmsg_unix.go new file mode 100644 index 0000000000..f1493a3e6f --- /dev/null +++ b/vendor/golang.org/x/sys/unix/sockcmsg_unix.go @@ -0,0 +1,103 @@ +// 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 and DragonFly BSD kernels + // still require 32-bit aligned access to network subsystem. + if darwin64Bit || dragonfly64Bit { + 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 +} diff --git a/vendor/golang.org/x/sys/unix/str.go b/vendor/golang.org/x/sys/unix/str.go new file mode 100644 index 0000000000..35ed664353 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/str.go @@ -0,0 +1,26 @@ +// 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:]) +} diff --git a/vendor/golang.org/x/sys/unix/syscall.go b/vendor/golang.org/x/sys/unix/syscall.go new file mode 100644 index 0000000000..a0bcf842ca --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall.go @@ -0,0 +1,76 @@ +// 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" + +import "unsafe" + +// 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 } + +// use is a no-op, but the compiler cannot see that it is. +// Calling use(p) ensures that p is kept live until that point. +//go:noescape +func use(p unsafe.Pointer) diff --git a/vendor/golang.org/x/sys/unix/syscall_bsd.go b/vendor/golang.org/x/sys/unix/syscall_bsd.go new file mode 100644 index 0000000000..e9671764cc --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_bsd.go @@ -0,0 +1,628 @@ +// 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 netbsd openbsd + +// BSD system call wrappers shared by *BSD based systems +// including OS X (Darwin) and FreeBSD. Like the other +// syscall_*.go files it is compiled as Go code but also +// used as input to mksyscall which parses the //sys +// lines and generates system call stubs. + +package unix + +import ( + "runtime" + "syscall" + "unsafe" +) + +/* + * Wrapped + */ + +//sysnb getgroups(ngid int, gid *_Gid_t) (n int, err error) +//sysnb setgroups(ngid int, gid *_Gid_t) (err error) + +func Getgroups() (gids []int, err error) { + n, err := getgroups(0, nil) + if err != nil { + return nil, err + } + if n == 0 { + return nil, nil + } + + // Sanity check group count. Max is 16 on BSD. + if n < 0 || n > 1000 { + return nil, EINVAL + } + + a := make([]_Gid_t, n) + n, err = getgroups(n, &a[0]) + if err != nil { + return nil, err + } + gids = make([]int, n) + for i, v := range a[0:n] { + gids[i] = int(v) + } + return +} + +func Setgroups(gids []int) (err error) { + if len(gids) == 0 { + return setgroups(0, nil) + } + + a := make([]_Gid_t, len(gids)) + for i, v := range gids { + a[i] = _Gid_t(v) + } + return setgroups(len(a), &a[0]) +} + +func ReadDirent(fd int, buf []byte) (n int, err error) { + // Final argument is (basep *uintptr) and the syscall doesn't take nil. + // 64 bits should be enough. (32 bits isn't even on 386). Since the + // actual system call is getdirentries64, 64 is a good guess. + // TODO(rsc): Can we use a single global basep for all calls? + var base = (*uintptr)(unsafe.Pointer(new(uint64))) + return Getdirentries(fd, buf, base) +} + +// Wait status is 7 bits at bottom, either 0 (exited), +// 0x7F (stopped), or a signal number that caused an exit. +// The 0x80 bit is whether there was a core dump. +// An extra number (exit code, signal causing a stop) +// is in the high bits. + +type WaitStatus uint32 + +const ( + mask = 0x7F + core = 0x80 + shift = 8 + + exited = 0 + stopped = 0x7F +) + +func (w WaitStatus) Exited() bool { return w&mask == exited } + +func (w WaitStatus) ExitStatus() int { + if w&mask != exited { + return -1 + } + return int(w >> shift) +} + +func (w WaitStatus) Signaled() bool { return w&mask != stopped && w&mask != 0 } + +func (w WaitStatus) Signal() syscall.Signal { + sig := syscall.Signal(w & mask) + if sig == stopped || sig == 0 { + return -1 + } + return sig +} + +func (w WaitStatus) CoreDump() bool { return w.Signaled() && w&core != 0 } + +func (w WaitStatus) Stopped() bool { return w&mask == stopped && syscall.Signal(w>>shift) != SIGSTOP } + +func (w WaitStatus) Continued() bool { return w&mask == stopped && syscall.Signal(w>>shift) == SIGSTOP } + +func (w WaitStatus) StopSignal() syscall.Signal { + if !w.Stopped() { + return -1 + } + return syscall.Signal(w>>shift) & 0xFF +} + +func (w WaitStatus) TrapCause() int { return -1 } + +//sys wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) + +func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) { + var status _C_int + wpid, err = wait4(pid, &status, options, rusage) + if wstatus != nil { + *wstatus = WaitStatus(status) + } + return +} + +//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) +//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) +//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) +//sysnb socket(domain int, typ int, proto int) (fd int, err error) +//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) +//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) +//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) +//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) +//sys Shutdown(s int, how int) (err error) + +func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) { + if sa.Port < 0 || sa.Port > 0xFFFF { + return nil, 0, EINVAL + } + sa.raw.Len = SizeofSockaddrInet4 + sa.raw.Family = AF_INET + p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) + p[0] = byte(sa.Port >> 8) + p[1] = byte(sa.Port) + for i := 0; i < len(sa.Addr); i++ { + sa.raw.Addr[i] = sa.Addr[i] + } + return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil +} + +func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) { + if sa.Port < 0 || sa.Port > 0xFFFF { + return nil, 0, EINVAL + } + sa.raw.Len = SizeofSockaddrInet6 + sa.raw.Family = AF_INET6 + p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) + p[0] = byte(sa.Port >> 8) + p[1] = byte(sa.Port) + sa.raw.Scope_id = sa.ZoneId + for i := 0; i < len(sa.Addr); i++ { + sa.raw.Addr[i] = sa.Addr[i] + } + return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil +} + +func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) { + name := sa.Name + n := len(name) + if n >= len(sa.raw.Path) || n == 0 { + return nil, 0, EINVAL + } + sa.raw.Len = byte(3 + n) // 2 for Family, Len; 1 for NUL + sa.raw.Family = AF_UNIX + for i := 0; i < n; i++ { + sa.raw.Path[i] = int8(name[i]) + } + return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil +} + +func (sa *SockaddrDatalink) sockaddr() (unsafe.Pointer, _Socklen, error) { + if sa.Index == 0 { + return nil, 0, EINVAL + } + sa.raw.Len = sa.Len + sa.raw.Family = AF_LINK + sa.raw.Index = sa.Index + sa.raw.Type = sa.Type + sa.raw.Nlen = sa.Nlen + sa.raw.Alen = sa.Alen + sa.raw.Slen = sa.Slen + for i := 0; i < len(sa.raw.Data); i++ { + sa.raw.Data[i] = sa.Data[i] + } + return unsafe.Pointer(&sa.raw), SizeofSockaddrDatalink, nil +} + +func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) { + switch rsa.Addr.Family { + case AF_LINK: + pp := (*RawSockaddrDatalink)(unsafe.Pointer(rsa)) + sa := new(SockaddrDatalink) + sa.Len = pp.Len + sa.Family = pp.Family + sa.Index = pp.Index + sa.Type = pp.Type + sa.Nlen = pp.Nlen + sa.Alen = pp.Alen + sa.Slen = pp.Slen + for i := 0; i < len(sa.Data); i++ { + sa.Data[i] = pp.Data[i] + } + return sa, nil + + case AF_UNIX: + pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa)) + if pp.Len < 2 || pp.Len > SizeofSockaddrUnix { + return nil, EINVAL + } + sa := new(SockaddrUnix) + + // Some BSDs include the trailing NUL in the length, whereas + // others do not. Work around this by subtracting the leading + // family and len. The path is then scanned to see if a NUL + // terminator still exists within the length. + n := int(pp.Len) - 2 // subtract leading Family, Len + for i := 0; i < n; i++ { + if pp.Path[i] == 0 { + // found early NUL; assume Len included the NUL + // or was overestimating. + n = i + break + } + } + bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n] + sa.Name = string(bytes) + return sa, nil + + case AF_INET: + pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa)) + sa := new(SockaddrInet4) + p := (*[2]byte)(unsafe.Pointer(&pp.Port)) + sa.Port = int(p[0])<<8 + int(p[1]) + for i := 0; i < len(sa.Addr); i++ { + sa.Addr[i] = pp.Addr[i] + } + return sa, nil + + case AF_INET6: + pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa)) + sa := new(SockaddrInet6) + p := (*[2]byte)(unsafe.Pointer(&pp.Port)) + sa.Port = int(p[0])<<8 + int(p[1]) + sa.ZoneId = pp.Scope_id + for i := 0; i < len(sa.Addr); i++ { + sa.Addr[i] = pp.Addr[i] + } + return sa, nil + } + return nil, EAFNOSUPPORT +} + +func Accept(fd int) (nfd int, sa Sockaddr, err error) { + var rsa RawSockaddrAny + var len _Socklen = SizeofSockaddrAny + nfd, err = accept(fd, &rsa, &len) + if err != nil { + return + } + if runtime.GOOS == "darwin" && len == 0 { + // Accepted socket has no address. + // This is likely due to a bug in xnu kernels, + // where instead of ECONNABORTED error socket + // is accepted, but has no address. + Close(nfd) + return 0, nil, ECONNABORTED + } + sa, err = anyToSockaddr(&rsa) + if err != nil { + Close(nfd) + nfd = 0 + } + return +} + +func Getsockname(fd int) (sa Sockaddr, err error) { + var rsa RawSockaddrAny + var len _Socklen = SizeofSockaddrAny + if err = getsockname(fd, &rsa, &len); err != nil { + return + } + // TODO(jsing): DragonFly has a "bug" (see issue 3349), which should be + // reported upstream. + if runtime.GOOS == "dragonfly" && rsa.Addr.Family == AF_UNSPEC && rsa.Addr.Len == 0 { + rsa.Addr.Family = AF_UNIX + rsa.Addr.Len = SizeofSockaddrUnix + } + return anyToSockaddr(&rsa) +} + +//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) + +func GetsockoptByte(fd, level, opt int) (value byte, err error) { + var n byte + vallen := _Socklen(1) + err = getsockopt(fd, level, opt, unsafe.Pointer(&n), &vallen) + return n, err +} + +func GetsockoptInet4Addr(fd, level, opt int) (value [4]byte, err error) { + vallen := _Socklen(4) + err = getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen) + return value, err +} + +func GetsockoptIPMreq(fd, level, opt int) (*IPMreq, error) { + var value IPMreq + vallen := _Socklen(SizeofIPMreq) + err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen) + return &value, err +} + +func GetsockoptIPv6Mreq(fd, level, opt int) (*IPv6Mreq, error) { + var value IPv6Mreq + vallen := _Socklen(SizeofIPv6Mreq) + err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen) + return &value, err +} + +func GetsockoptIPv6MTUInfo(fd, level, opt int) (*IPv6MTUInfo, error) { + var value IPv6MTUInfo + vallen := _Socklen(SizeofIPv6MTUInfo) + err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen) + return &value, err +} + +func GetsockoptICMPv6Filter(fd, level, opt int) (*ICMPv6Filter, error) { + var value ICMPv6Filter + vallen := _Socklen(SizeofICMPv6Filter) + err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen) + return &value, err +} + +//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) +//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) +//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) + +func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) { + var msg Msghdr + var rsa RawSockaddrAny + msg.Name = (*byte)(unsafe.Pointer(&rsa)) + msg.Namelen = uint32(SizeofSockaddrAny) + var iov Iovec + if len(p) > 0 { + iov.Base = (*byte)(unsafe.Pointer(&p[0])) + iov.SetLen(len(p)) + } + var dummy byte + if len(oob) > 0 { + // receive at least one normal byte + if len(p) == 0 { + iov.Base = &dummy + iov.SetLen(1) + } + msg.Control = (*byte)(unsafe.Pointer(&oob[0])) + msg.SetControllen(len(oob)) + } + msg.Iov = &iov + msg.Iovlen = 1 + if n, err = recvmsg(fd, &msg, flags); err != nil { + return + } + oobn = int(msg.Controllen) + recvflags = int(msg.Flags) + // source address is only specified if the socket is unconnected + if rsa.Addr.Family != AF_UNSPEC { + from, err = anyToSockaddr(&rsa) + } + return +} + +//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) + +func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) { + _, err = SendmsgN(fd, p, oob, to, flags) + return +} + +func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) { + var ptr unsafe.Pointer + var salen _Socklen + if to != nil { + ptr, salen, err = to.sockaddr() + if err != nil { + return 0, err + } + } + var msg Msghdr + msg.Name = (*byte)(unsafe.Pointer(ptr)) + msg.Namelen = uint32(salen) + var iov Iovec + if len(p) > 0 { + iov.Base = (*byte)(unsafe.Pointer(&p[0])) + iov.SetLen(len(p)) + } + var dummy byte + if len(oob) > 0 { + // send at least one normal byte + if len(p) == 0 { + iov.Base = &dummy + iov.SetLen(1) + } + msg.Control = (*byte)(unsafe.Pointer(&oob[0])) + msg.SetControllen(len(oob)) + } + msg.Iov = &iov + msg.Iovlen = 1 + if n, err = sendmsg(fd, &msg, flags); err != nil { + return 0, err + } + if len(oob) > 0 && len(p) == 0 { + n = 0 + } + return n, nil +} + +//sys kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) + +func Kevent(kq int, changes, events []Kevent_t, timeout *Timespec) (n int, err error) { + var change, event unsafe.Pointer + if len(changes) > 0 { + change = unsafe.Pointer(&changes[0]) + } + if len(events) > 0 { + event = unsafe.Pointer(&events[0]) + } + return kevent(kq, change, len(changes), event, len(events), timeout) +} + +//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL + +// sysctlmib translates name to mib number and appends any additional args. +func sysctlmib(name string, args ...int) ([]_C_int, error) { + // Translate name to mib number. + mib, err := nametomib(name) + if err != nil { + return nil, err + } + + for _, a := range args { + mib = append(mib, _C_int(a)) + } + + return mib, nil +} + +func Sysctl(name string) (string, error) { + return SysctlArgs(name) +} + +func SysctlArgs(name string, args ...int) (string, error) { + mib, err := sysctlmib(name, args...) + if err != nil { + return "", err + } + + // Find size. + n := uintptr(0) + if err := sysctl(mib, nil, &n, nil, 0); err != nil { + return "", err + } + if n == 0 { + return "", nil + } + + // Read into buffer of that size. + buf := make([]byte, n) + if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil { + return "", err + } + + // Throw away terminating NUL. + if n > 0 && buf[n-1] == '\x00' { + n-- + } + return string(buf[0:n]), nil +} + +func SysctlUint32(name string) (uint32, error) { + return SysctlUint32Args(name) +} + +func SysctlUint32Args(name string, args ...int) (uint32, error) { + mib, err := sysctlmib(name, args...) + if err != nil { + return 0, err + } + + n := uintptr(4) + buf := make([]byte, 4) + if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil { + return 0, err + } + if n != 4 { + return 0, EIO + } + return *(*uint32)(unsafe.Pointer(&buf[0])), nil +} + +func SysctlUint64(name string, args ...int) (uint64, error) { + mib, err := sysctlmib(name, args...) + if err != nil { + return 0, err + } + + n := uintptr(8) + buf := make([]byte, 8) + if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil { + return 0, err + } + if n != 8 { + return 0, EIO + } + return *(*uint64)(unsafe.Pointer(&buf[0])), nil +} + +func SysctlRaw(name string, args ...int) ([]byte, error) { + mib, err := sysctlmib(name, args...) + if err != nil { + return nil, err + } + + // Find size. + n := uintptr(0) + if err := sysctl(mib, nil, &n, nil, 0); err != nil { + return nil, err + } + if n == 0 { + return nil, nil + } + + // Read into buffer of that size. + buf := make([]byte, n) + if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil { + return nil, err + } + + // The actual call may return less than the original reported required + // size so ensure we deal with that. + return buf[:n], nil +} + +//sys utimes(path string, timeval *[2]Timeval) (err error) + +func Utimes(path string, tv []Timeval) error { + if tv == nil { + return utimes(path, nil) + } + if len(tv) != 2 { + return EINVAL + } + return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) +} + +func UtimesNano(path string, ts []Timespec) error { + if ts == nil { + return utimes(path, nil) + } + // TODO: The BSDs can do utimensat with SYS_UTIMENSAT but it + // isn't supported by darwin so this uses utimes instead + if len(ts) != 2 { + return EINVAL + } + // Not as efficient as it could be because Timespec and + // Timeval have different types in the different OSes + tv := [2]Timeval{ + NsecToTimeval(TimespecToNsec(ts[0])), + NsecToTimeval(TimespecToNsec(ts[1])), + } + return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) +} + +//sys futimes(fd int, timeval *[2]Timeval) (err error) + +func Futimes(fd int, tv []Timeval) error { + if tv == nil { + return futimes(fd, nil) + } + if len(tv) != 2 { + return EINVAL + } + return futimes(fd, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) +} + +//sys fcntl(fd int, cmd int, arg int) (val int, err error) + +// TODO: wrap +// Acct(name nil-string) (err error) +// Gethostuuid(uuid *byte, timeout *Timespec) (err error) +// Madvise(addr *byte, len int, behav int) (err error) +// Mprotect(addr *byte, len int, prot int) (err error) +// Msync(addr *byte, len int, flags int) (err error) +// Ptrace(req int, pid int, addr uintptr, data int) (ret uintptr, err error) + +var mapper = &mmapper{ + active: make(map[*byte][]byte), + mmap: mmap, + munmap: munmap, +} + +func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) { + return mapper.Mmap(fd, offset, length, prot, flags) +} + +func Munmap(b []byte) (err error) { + return mapper.Munmap(b) +} diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin.go b/vendor/golang.org/x/sys/unix/syscall_darwin.go new file mode 100644 index 0000000000..0d1771c3fc --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_darwin.go @@ -0,0 +1,509 @@ +// Copyright 2009,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. + +// Darwin system calls. +// This file is compiled as ordinary Go code, +// but it is also input to mksyscall, +// which parses the //sys lines and generates system call stubs. +// Note that sometimes we use a lowercase //sys name and wrap +// it in our own nicer implementation, either here or in +// syscall_bsd.go or syscall_unix.go. + +package unix + +import ( + errorspkg "errors" + "syscall" + "unsafe" +) + +const ImplementsGetwd = true + +func Getwd() (string, error) { + buf := make([]byte, 2048) + attrs, err := getAttrList(".", attrList{CommonAttr: attrCmnFullpath}, buf, 0) + if err == nil && len(attrs) == 1 && len(attrs[0]) >= 2 { + wd := string(attrs[0]) + // Sanity check that it's an absolute path and ends + // in a null byte, which we then strip. + if wd[0] == '/' && wd[len(wd)-1] == 0 { + return wd[:len(wd)-1], nil + } + } + // If pkg/os/getwd.go gets ENOTSUP, it will fall back to the + // slow algorithm. + return "", ENOTSUP +} + +type SockaddrDatalink struct { + Len uint8 + Family uint8 + Index uint16 + Type uint8 + Nlen uint8 + Alen uint8 + Slen uint8 + Data [12]int8 + raw RawSockaddrDatalink +} + +// Translate "kern.hostname" to []_C_int{0,1,2,3}. +func nametomib(name string) (mib []_C_int, err error) { + const siz = unsafe.Sizeof(mib[0]) + + // NOTE(rsc): It seems strange to set the buffer to have + // size CTL_MAXNAME+2 but use only CTL_MAXNAME + // as the size. I don't know why the +2 is here, but the + // kernel uses +2 for its own implementation of this function. + // I am scared that if we don't include the +2 here, the kernel + // will silently write 2 words farther than we specify + // and we'll get memory corruption. + var buf [CTL_MAXNAME + 2]_C_int + n := uintptr(CTL_MAXNAME) * siz + + p := (*byte)(unsafe.Pointer(&buf[0])) + bytes, err := ByteSliceFromString(name) + if err != nil { + return nil, err + } + + // Magic sysctl: "setting" 0.3 to a string name + // lets you read back the array of integers form. + if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil { + return nil, err + } + return buf[0 : n/siz], nil +} + +// ParseDirent parses up to max directory entries in buf, +// appending the names to names. It returns the number +// 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) + for max != 0 && len(buf) > 0 { + dirent := (*Dirent)(unsafe.Pointer(&buf[0])) + if dirent.Reclen == 0 { + buf = nil + break + } + buf = buf[dirent.Reclen:] + if dirent.Ino == 0 { // File absent in directory. + continue + } + bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0])) + var name = string(bytes[0:dirent.Namlen]) + if name == "." || name == ".." { // Useless names + continue + } + max-- + count++ + names = append(names, name) + } + return origlen - len(buf), count, names +} + +//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error) +func PtraceAttach(pid int) (err error) { return ptrace(PT_ATTACH, pid, 0, 0) } +func PtraceDetach(pid int) (err error) { return ptrace(PT_DETACH, pid, 0, 0) } + +const ( + attrBitMapCount = 5 + attrCmnFullpath = 0x08000000 +) + +type attrList struct { + bitmapCount uint16 + _ uint16 + CommonAttr uint32 + VolAttr uint32 + DirAttr uint32 + FileAttr uint32 + Forkattr uint32 +} + +func getAttrList(path string, attrList attrList, attrBuf []byte, options uint) (attrs [][]byte, err error) { + if len(attrBuf) < 4 { + return nil, errorspkg.New("attrBuf too small") + } + attrList.bitmapCount = attrBitMapCount + + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return nil, err + } + + _, _, e1 := Syscall6( + SYS_GETATTRLIST, + uintptr(unsafe.Pointer(_p0)), + uintptr(unsafe.Pointer(&attrList)), + uintptr(unsafe.Pointer(&attrBuf[0])), + uintptr(len(attrBuf)), + uintptr(options), + 0, + ) + if e1 != 0 { + return nil, e1 + } + size := *(*uint32)(unsafe.Pointer(&attrBuf[0])) + + // dat is the section of attrBuf that contains valid data, + // without the 4 byte length header. All attribute offsets + // are relative to dat. + dat := attrBuf + if int(size) < len(attrBuf) { + dat = dat[:size] + } + dat = dat[4:] // remove length prefix + + for i := uint32(0); int(i) < len(dat); { + header := dat[i:] + if len(header) < 8 { + return attrs, errorspkg.New("truncated attribute header") + } + datOff := *(*int32)(unsafe.Pointer(&header[0])) + attrLen := *(*uint32)(unsafe.Pointer(&header[4])) + if datOff < 0 || uint32(datOff)+attrLen > uint32(len(dat)) { + return attrs, errorspkg.New("truncated results; attrBuf too small") + } + end := uint32(datOff) + attrLen + attrs = append(attrs, dat[datOff:end]) + i = end + if r := i % 4; r != 0 { + i += (4 - r) + } + } + return +} + +//sysnb pipe() (r int, w int, err error) + +func Pipe(p []int) (err error) { + if len(p) != 2 { + return EINVAL + } + p[0], p[1], err = pipe() + return +} + +func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { + var _p0 unsafe.Pointer + var bufsize uintptr + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf)) + } + r0, _, e1 := Syscall(SYS_GETFSSTAT64, uintptr(_p0), bufsize, uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +/* + * Wrapped + */ + +//sys kill(pid int, signum int, posix int) (err error) + +func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(signum), 1) } + +/* + * Exposed directly + */ +//sys Access(path string, mode uint32) (err error) +//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error) +//sys Chdir(path string) (err error) +//sys Chflags(path string, flags int) (err error) +//sys Chmod(path string, mode uint32) (err error) +//sys Chown(path string, uid int, gid int) (err error) +//sys Chroot(path string) (err error) +//sys Close(fd int) (err error) +//sys Dup(fd int) (nfd int, err error) +//sys Dup2(from int, to int) (err error) +//sys Exchangedata(path1 string, path2 string, options int) (err error) +//sys Exit(code int) +//sys Fchdir(fd int) (err error) +//sys Fchflags(fd int, flags int) (err error) +//sys Fchmod(fd int, mode uint32) (err error) +//sys Fchown(fd int, uid int, gid int) (err error) +//sys Flock(fd int, how int) (err error) +//sys Fpathconf(fd int, name int) (val int, err error) +//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 +//sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64 +//sys Fsync(fd int) (err error) +//sys Ftruncate(fd int, length int64) (err error) +//sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) = SYS_GETDIRENTRIES64 +//sys Getdtablesize() (size int) +//sysnb Getegid() (egid int) +//sysnb Geteuid() (uid int) +//sysnb Getgid() (gid int) +//sysnb Getpgid(pid int) (pgid int, err error) +//sysnb Getpgrp() (pgrp int) +//sysnb Getpid() (pid int) +//sysnb Getppid() (ppid int) +//sys Getpriority(which int, who int) (prio int, err error) +//sysnb Getrlimit(which int, lim *Rlimit) (err error) +//sysnb Getrusage(who int, rusage *Rusage) (err error) +//sysnb Getsid(pid int) (sid int, err error) +//sysnb Getuid() (uid int) +//sysnb Issetugid() (tainted bool) +//sys Kqueue() (fd int, err error) +//sys Lchown(path string, uid int, gid int) (err error) +//sys Link(path string, link string) (err error) +//sys Listen(s int, backlog int) (err error) +//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64 +//sys Mkdir(path string, mode uint32) (err error) +//sys Mkfifo(path string, mode uint32) (err error) +//sys Mknod(path string, mode uint32, dev int) (err error) +//sys Mlock(b []byte) (err error) +//sys Mlockall(flags int) (err error) +//sys Mprotect(b []byte, prot int) (err error) +//sys Munlock(b []byte) (err error) +//sys Munlockall() (err error) +//sys Open(path string, mode int, perm uint32) (fd int, err error) +//sys Pathconf(path string, name int) (val int, err error) +//sys Pread(fd int, p []byte, offset int64) (n int, err error) +//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) +//sys read(fd int, p []byte) (n int, err error) +//sys Readlink(path string, buf []byte) (n int, err error) +//sys Rename(from string, to string) (err error) +//sys Revoke(path string) (err error) +//sys Rmdir(path string) (err error) +//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK +//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) +//sys Setegid(egid int) (err error) +//sysnb Seteuid(euid int) (err error) +//sysnb Setgid(gid int) (err error) +//sys Setlogin(name string) (err error) +//sysnb Setpgid(pid int, pgid int) (err error) +//sys Setpriority(which int, who int, prio int) (err error) +//sys Setprivexec(flag int) (err error) +//sysnb Setregid(rgid int, egid int) (err error) +//sysnb Setreuid(ruid int, euid int) (err error) +//sysnb Setrlimit(which int, lim *Rlimit) (err error) +//sysnb Setsid() (pid int, err error) +//sysnb Settimeofday(tp *Timeval) (err error) +//sysnb Setuid(uid int) (err error) +//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 +//sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64 +//sys Symlink(path string, link string) (err error) +//sys Sync() (err error) +//sys Truncate(path string, length int64) (err error) +//sys Umask(newmask int) (oldmask int) +//sys Undelete(path string) (err error) +//sys Unlink(path string) (err error) +//sys Unmount(path string, flags int) (err error) +//sys write(fd int, p []byte) (n int, err error) +//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) +//sys munmap(addr uintptr, length uintptr) (err error) +//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ +//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE + +/* + * Unimplemented + */ +// Profil +// Sigaction +// Sigprocmask +// Getlogin +// Sigpending +// Sigaltstack +// Ioctl +// Reboot +// Execve +// Vfork +// Sbrk +// Sstk +// Ovadvise +// Mincore +// Setitimer +// Swapon +// Select +// Sigsuspend +// Readv +// Writev +// Nfssvc +// Getfh +// Quotactl +// Mount +// Csops +// Waitid +// Add_profil +// Kdebug_trace +// Sigreturn +// Mmap +// Mlock +// Munlock +// Atsocket +// Kqueue_from_portset_np +// Kqueue_portset +// Getattrlist +// Setattrlist +// Getdirentriesattr +// Searchfs +// Delete +// Copyfile +// Poll +// Watchevent +// Waitevent +// Modwatch +// Getxattr +// Fgetxattr +// Setxattr +// Fsetxattr +// Removexattr +// Fremovexattr +// Listxattr +// Flistxattr +// Fsctl +// Initgroups +// Posix_spawn +// Nfsclnt +// Fhopen +// Minherit +// Semsys +// Msgsys +// Shmsys +// Semctl +// Semget +// Semop +// Msgctl +// Msgget +// Msgsnd +// Msgrcv +// Shmat +// Shmctl +// Shmdt +// Shmget +// Shm_open +// Shm_unlink +// Sem_open +// Sem_close +// Sem_unlink +// Sem_wait +// Sem_trywait +// Sem_post +// Sem_getvalue +// Sem_init +// Sem_destroy +// Open_extended +// Umask_extended +// Stat_extended +// Lstat_extended +// Fstat_extended +// Chmod_extended +// Fchmod_extended +// Access_extended +// Settid +// Gettid +// Setsgroups +// Getsgroups +// Setwgroups +// Getwgroups +// Mkfifo_extended +// Mkdir_extended +// Identitysvc +// Shared_region_check_np +// Shared_region_map_np +// __pthread_mutex_destroy +// __pthread_mutex_init +// __pthread_mutex_lock +// __pthread_mutex_trylock +// __pthread_mutex_unlock +// __pthread_cond_init +// __pthread_cond_destroy +// __pthread_cond_broadcast +// __pthread_cond_signal +// Setsid_with_pid +// __pthread_cond_timedwait +// Aio_fsync +// Aio_return +// Aio_suspend +// Aio_cancel +// Aio_error +// Aio_read +// Aio_write +// Lio_listio +// __pthread_cond_wait +// Iopolicysys +// Mlockall +// Munlockall +// __pthread_kill +// __pthread_sigmask +// __sigwait +// __disable_threadsignal +// __pthread_markcancel +// __pthread_canceled +// __semwait_signal +// Proc_info +// sendfile +// Stat64_extended +// Lstat64_extended +// Fstat64_extended +// __pthread_chdir +// __pthread_fchdir +// Audit +// Auditon +// Getauid +// Setauid +// Getaudit +// Setaudit +// Getaudit_addr +// Setaudit_addr +// Auditctl +// Bsdthread_create +// Bsdthread_terminate +// Stack_snapshot +// Bsdthread_register +// Workq_open +// Workq_ops +// __mac_execve +// __mac_syscall +// __mac_get_file +// __mac_set_file +// __mac_get_link +// __mac_set_link +// __mac_get_proc +// __mac_set_proc +// __mac_get_fd +// __mac_set_fd +// __mac_get_pid +// __mac_get_lcid +// __mac_get_lctx +// __mac_set_lctx +// Setlcid +// Read_nocancel +// Write_nocancel +// Open_nocancel +// Close_nocancel +// Wait4_nocancel +// Recvmsg_nocancel +// Sendmsg_nocancel +// Recvfrom_nocancel +// Accept_nocancel +// Msync_nocancel +// Fcntl_nocancel +// Select_nocancel +// Fsync_nocancel +// Connect_nocancel +// Sigsuspend_nocancel +// Readv_nocancel +// Writev_nocancel +// Sendto_nocancel +// Pread_nocancel +// Pwrite_nocancel +// Waitid_nocancel +// Poll_nocancel +// Msgsnd_nocancel +// Msgrcv_nocancel +// Sem_wait_nocancel +// Aio_suspend_nocancel +// __sigwait_nocancel +// __semwait_signal_nocancel +// __mac_mount +// __mac_get_mount +// __mac_getfsstat diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin_386.go b/vendor/golang.org/x/sys/unix/syscall_darwin_386.go new file mode 100644 index 0000000000..c172a3da5a --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_darwin_386.go @@ -0,0 +1,77 @@ +// 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 386,darwin + +package unix + +import ( + "syscall" + "unsafe" +) + +func Getpagesize() int { return 4096 } + +func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = int32(nsec / 1e9) + ts.Nsec = int32(nsec % 1e9) + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Usec = int32(nsec % 1e9 / 1e3) + tv.Sec = int32(nsec / 1e9) + return +} + +//sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) +func Gettimeofday(tv *Timeval) (err error) { + // The tv passed to gettimeofday must be non-nil + // but is otherwise unused. The answers come back + // in the two registers. + sec, usec, err := gettimeofday(tv) + tv.Sec = int32(sec) + tv.Usec = int32(usec) + return err +} + +func SetKevent(k *Kevent_t, fd, mode, flags int) { + k.Ident = uint32(fd) + k.Filter = int16(mode) + k.Flags = uint16(flags) +} + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint32(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint32(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint32(length) +} + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + var length = uint64(count) + + _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) + + written = int(length) + + if e1 != 0 { + err = e1 + } + return +} + +func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) + +// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions +// of darwin/386 the syscall is called sysctl instead of __sysctl. +const SYS___SYSCTL = SYS_SYSCTL diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go b/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go new file mode 100644 index 0000000000..fc1e5a4a82 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go @@ -0,0 +1,79 @@ +// 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 amd64,darwin + +package unix + +import ( + "syscall" + "unsafe" +) + +//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) + +func Getpagesize() int { return 4096 } + +func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = nsec / 1e9 + ts.Nsec = nsec % 1e9 + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Usec = int32(nsec % 1e9 / 1e3) + tv.Sec = int64(nsec / 1e9) + return +} + +//sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) +func Gettimeofday(tv *Timeval) (err error) { + // The tv passed to gettimeofday must be non-nil + // but is otherwise unused. The answers come back + // in the two registers. + sec, usec, err := gettimeofday(tv) + tv.Sec = sec + tv.Usec = usec + return err +} + +func SetKevent(k *Kevent_t, fd, mode, flags int) { + k.Ident = uint64(fd) + k.Filter = int16(mode) + k.Flags = uint16(flags) +} + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint64(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint32(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint32(length) +} + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + var length = uint64(count) + + _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) + + written = int(length) + + if e1 != 0 { + err = e1 + } + return +} + +func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) + +// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions +// of darwin/amd64 the syscall is called sysctl instead of __sysctl. +const SYS___SYSCTL = SYS_SYSCTL diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin_arm.go b/vendor/golang.org/x/sys/unix/syscall_darwin_arm.go new file mode 100644 index 0000000000..d286cf408d --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_darwin_arm.go @@ -0,0 +1,71 @@ +// 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. + +package unix + +import ( + "syscall" + "unsafe" +) + +func Getpagesize() int { return 4096 } + +func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = int32(nsec / 1e9) + ts.Nsec = int32(nsec % 1e9) + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Usec = int32(nsec % 1e9 / 1e3) + tv.Sec = int32(nsec / 1e9) + return +} + +//sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) +func Gettimeofday(tv *Timeval) (err error) { + // The tv passed to gettimeofday must be non-nil + // but is otherwise unused. The answers come back + // in the two registers. + sec, usec, err := gettimeofday(tv) + tv.Sec = int32(sec) + tv.Usec = int32(usec) + return err +} + +func SetKevent(k *Kevent_t, fd, mode, flags int) { + k.Ident = uint32(fd) + k.Filter = int16(mode) + k.Flags = uint16(flags) +} + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint32(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint32(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint32(length) +} + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + var length = uint64(count) + + _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) + + written = int(length) + + if e1 != 0 { + err = e1 + } + return +} + +func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go b/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go new file mode 100644 index 0000000000..c33905cdcd --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go @@ -0,0 +1,77 @@ +// 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 arm64,darwin + +package unix + +import ( + "syscall" + "unsafe" +) + +func Getpagesize() int { return 16384 } + +func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = nsec / 1e9 + ts.Nsec = nsec % 1e9 + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Usec = int32(nsec % 1e9 / 1e3) + tv.Sec = int64(nsec / 1e9) + return +} + +//sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) +func Gettimeofday(tv *Timeval) (err error) { + // The tv passed to gettimeofday must be non-nil + // but is otherwise unused. The answers come back + // in the two registers. + sec, usec, err := gettimeofday(tv) + tv.Sec = sec + tv.Usec = usec + return err +} + +func SetKevent(k *Kevent_t, fd, mode, flags int) { + k.Ident = uint64(fd) + k.Filter = int16(mode) + k.Flags = uint16(flags) +} + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint64(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint32(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint32(length) +} + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + var length = uint64(count) + + _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) + + written = int(length) + + if e1 != 0 { + err = e1 + } + return +} + +func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic + +// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions +// of darwin/arm64 the syscall is called sysctl instead of __sysctl. +const SYS___SYSCTL = SYS_SYSCTL diff --git a/vendor/golang.org/x/sys/unix/syscall_dragonfly.go b/vendor/golang.org/x/sys/unix/syscall_dragonfly.go new file mode 100644 index 0000000000..fbbe0dce25 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_dragonfly.go @@ -0,0 +1,411 @@ +// Copyright 2009,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. + +// FreeBSD system calls. +// This file is compiled as ordinary Go code, +// but it is also input to mksyscall, +// which parses the //sys lines and generates system call stubs. +// Note that sometimes we use a lowercase //sys name and wrap +// it in our own nicer implementation, either here or in +// syscall_bsd.go or syscall_unix.go. + +package unix + +import "unsafe" + +type SockaddrDatalink struct { + Len uint8 + Family uint8 + Index uint16 + Type uint8 + Nlen uint8 + Alen uint8 + Slen uint8 + Data [12]int8 + Rcf uint16 + Route [16]uint16 + raw RawSockaddrDatalink +} + +// Translate "kern.hostname" to []_C_int{0,1,2,3}. +func nametomib(name string) (mib []_C_int, err error) { + const siz = unsafe.Sizeof(mib[0]) + + // NOTE(rsc): It seems strange to set the buffer to have + // size CTL_MAXNAME+2 but use only CTL_MAXNAME + // as the size. I don't know why the +2 is here, but the + // kernel uses +2 for its own implementation of this function. + // I am scared that if we don't include the +2 here, the kernel + // will silently write 2 words farther than we specify + // and we'll get memory corruption. + var buf [CTL_MAXNAME + 2]_C_int + n := uintptr(CTL_MAXNAME) * siz + + p := (*byte)(unsafe.Pointer(&buf[0])) + bytes, err := ByteSliceFromString(name) + if err != nil { + return nil, err + } + + // Magic sysctl: "setting" 0.3 to a string name + // lets you read back the array of integers form. + if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil { + return nil, err + } + return buf[0 : n/siz], nil +} + +// ParseDirent parses up to max directory entries in buf, +// appending the names to names. It returns the number +// 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) + for max != 0 && len(buf) > 0 { + dirent := (*Dirent)(unsafe.Pointer(&buf[0])) + reclen := int(16+dirent.Namlen+1+7) & ^7 + buf = buf[reclen:] + if dirent.Fileno == 0 { // File absent in directory. + continue + } + bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0])) + var name = string(bytes[0:dirent.Namlen]) + if name == "." || name == ".." { // Useless names + continue + } + max-- + count++ + names = append(names, name) + } + return origlen - len(buf), count, names +} + +//sysnb pipe() (r int, w int, err error) + +func Pipe(p []int) (err error) { + if len(p) != 2 { + return EINVAL + } + p[0], p[1], err = pipe() + return +} + +//sys extpread(fd int, p []byte, flags int, offset int64) (n int, err error) +func Pread(fd int, p []byte, offset int64) (n int, err error) { + return extpread(fd, p, 0, offset) +} + +//sys extpwrite(fd int, p []byte, flags int, offset int64) (n int, err error) +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + return extpwrite(fd, p, 0, offset) +} + +func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { + var _p0 unsafe.Pointer + var bufsize uintptr + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf)) + } + r0, _, e1 := Syscall(SYS_GETFSSTAT, uintptr(_p0), bufsize, uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +/* + * Exposed directly + */ +//sys Access(path string, mode uint32) (err error) +//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error) +//sys Chdir(path string) (err error) +//sys Chflags(path string, flags int) (err error) +//sys Chmod(path string, mode uint32) (err error) +//sys Chown(path string, uid int, gid int) (err error) +//sys Chroot(path string) (err error) +//sys Close(fd int) (err error) +//sys Dup(fd int) (nfd int, err error) +//sys Dup2(from int, to int) (err error) +//sys Exit(code int) +//sys Fchdir(fd int) (err error) +//sys Fchflags(fd int, flags int) (err error) +//sys Fchmod(fd int, mode uint32) (err error) +//sys Fchown(fd int, uid int, gid int) (err error) +//sys Flock(fd int, how int) (err error) +//sys Fpathconf(fd int, name int) (val int, err error) +//sys Fstat(fd int, stat *Stat_t) (err error) +//sys Fstatfs(fd int, stat *Statfs_t) (err error) +//sys Fsync(fd int) (err error) +//sys Ftruncate(fd int, length int64) (err error) +//sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) +//sys Getdtablesize() (size int) +//sysnb Getegid() (egid int) +//sysnb Geteuid() (uid int) +//sysnb Getgid() (gid int) +//sysnb Getpgid(pid int) (pgid int, err error) +//sysnb Getpgrp() (pgrp int) +//sysnb Getpid() (pid int) +//sysnb Getppid() (ppid int) +//sys Getpriority(which int, who int) (prio int, err error) +//sysnb Getrlimit(which int, lim *Rlimit) (err error) +//sysnb Getrusage(who int, rusage *Rusage) (err error) +//sysnb Getsid(pid int) (sid int, err error) +//sysnb Gettimeofday(tv *Timeval) (err error) +//sysnb Getuid() (uid int) +//sys Issetugid() (tainted bool) +//sys Kill(pid int, signum syscall.Signal) (err error) +//sys Kqueue() (fd int, err error) +//sys Lchown(path string, uid int, gid int) (err error) +//sys Link(path string, link string) (err error) +//sys Listen(s int, backlog int) (err error) +//sys Lstat(path string, stat *Stat_t) (err error) +//sys Mkdir(path string, mode uint32) (err error) +//sys Mkfifo(path string, mode uint32) (err error) +//sys Mknod(path string, mode uint32, dev int) (err error) +//sys Mlock(b []byte) (err error) +//sys Mlockall(flags int) (err error) +//sys Mprotect(b []byte, prot int) (err error) +//sys Munlock(b []byte) (err error) +//sys Munlockall() (err error) +//sys Nanosleep(time *Timespec, leftover *Timespec) (err error) +//sys Open(path string, mode int, perm uint32) (fd int, err error) +//sys Pathconf(path string, name int) (val int, err error) +//sys read(fd int, p []byte) (n int, err error) +//sys Readlink(path string, buf []byte) (n int, err error) +//sys Rename(from string, to string) (err error) +//sys Revoke(path string) (err error) +//sys Rmdir(path string) (err error) +//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK +//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) +//sysnb Setegid(egid int) (err error) +//sysnb Seteuid(euid int) (err error) +//sysnb Setgid(gid int) (err error) +//sys Setlogin(name string) (err error) +//sysnb Setpgid(pid int, pgid int) (err error) +//sys Setpriority(which int, who int, prio int) (err error) +//sysnb Setregid(rgid int, egid int) (err error) +//sysnb Setreuid(ruid int, euid int) (err error) +//sysnb Setresgid(rgid int, egid int, sgid int) (err error) +//sysnb Setresuid(ruid int, euid int, suid int) (err error) +//sysnb Setrlimit(which int, lim *Rlimit) (err error) +//sysnb Setsid() (pid int, err error) +//sysnb Settimeofday(tp *Timeval) (err error) +//sysnb Setuid(uid int) (err error) +//sys Stat(path string, stat *Stat_t) (err error) +//sys Statfs(path string, stat *Statfs_t) (err error) +//sys Symlink(path string, link string) (err error) +//sys Sync() (err error) +//sys Truncate(path string, length int64) (err error) +//sys Umask(newmask int) (oldmask int) +//sys Undelete(path string) (err error) +//sys Unlink(path string) (err error) +//sys Unmount(path string, flags int) (err error) +//sys write(fd int, p []byte) (n int, err error) +//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) +//sys munmap(addr uintptr, length uintptr) (err error) +//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ +//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE + +/* + * Unimplemented + * TODO(jsing): Update this list for DragonFly. + */ +// Profil +// Sigaction +// Sigprocmask +// Getlogin +// Sigpending +// Sigaltstack +// Ioctl +// Reboot +// Execve +// Vfork +// Sbrk +// Sstk +// Ovadvise +// Mincore +// Setitimer +// Swapon +// Select +// Sigsuspend +// Readv +// Writev +// Nfssvc +// Getfh +// Quotactl +// Mount +// Csops +// Waitid +// Add_profil +// Kdebug_trace +// Sigreturn +// Mmap +// Atsocket +// Kqueue_from_portset_np +// Kqueue_portset +// Getattrlist +// Setattrlist +// Getdirentriesattr +// Searchfs +// Delete +// Copyfile +// Poll +// Watchevent +// Waitevent +// Modwatch +// Getxattr +// Fgetxattr +// Setxattr +// Fsetxattr +// Removexattr +// Fremovexattr +// Listxattr +// Flistxattr +// Fsctl +// Initgroups +// Posix_spawn +// Nfsclnt +// Fhopen +// Minherit +// Semsys +// Msgsys +// Shmsys +// Semctl +// Semget +// Semop +// Msgctl +// Msgget +// Msgsnd +// Msgrcv +// Shmat +// Shmctl +// Shmdt +// Shmget +// Shm_open +// Shm_unlink +// Sem_open +// Sem_close +// Sem_unlink +// Sem_wait +// Sem_trywait +// Sem_post +// Sem_getvalue +// Sem_init +// Sem_destroy +// Open_extended +// Umask_extended +// Stat_extended +// Lstat_extended +// Fstat_extended +// Chmod_extended +// Fchmod_extended +// Access_extended +// Settid +// Gettid +// Setsgroups +// Getsgroups +// Setwgroups +// Getwgroups +// Mkfifo_extended +// Mkdir_extended +// Identitysvc +// Shared_region_check_np +// Shared_region_map_np +// __pthread_mutex_destroy +// __pthread_mutex_init +// __pthread_mutex_lock +// __pthread_mutex_trylock +// __pthread_mutex_unlock +// __pthread_cond_init +// __pthread_cond_destroy +// __pthread_cond_broadcast +// __pthread_cond_signal +// Setsid_with_pid +// __pthread_cond_timedwait +// Aio_fsync +// Aio_return +// Aio_suspend +// Aio_cancel +// Aio_error +// Aio_read +// Aio_write +// Lio_listio +// __pthread_cond_wait +// Iopolicysys +// __pthread_kill +// __pthread_sigmask +// __sigwait +// __disable_threadsignal +// __pthread_markcancel +// __pthread_canceled +// __semwait_signal +// Proc_info +// Stat64_extended +// Lstat64_extended +// Fstat64_extended +// __pthread_chdir +// __pthread_fchdir +// Audit +// Auditon +// Getauid +// Setauid +// Getaudit +// Setaudit +// Getaudit_addr +// Setaudit_addr +// Auditctl +// Bsdthread_create +// Bsdthread_terminate +// Stack_snapshot +// Bsdthread_register +// Workq_open +// Workq_ops +// __mac_execve +// __mac_syscall +// __mac_get_file +// __mac_set_file +// __mac_get_link +// __mac_set_link +// __mac_get_proc +// __mac_set_proc +// __mac_get_fd +// __mac_set_fd +// __mac_get_pid +// __mac_get_lcid +// __mac_get_lctx +// __mac_set_lctx +// Setlcid +// Read_nocancel +// Write_nocancel +// Open_nocancel +// Close_nocancel +// Wait4_nocancel +// Recvmsg_nocancel +// Sendmsg_nocancel +// Recvfrom_nocancel +// Accept_nocancel +// Msync_nocancel +// Fcntl_nocancel +// Select_nocancel +// Fsync_nocancel +// Connect_nocancel +// Sigsuspend_nocancel +// Readv_nocancel +// Writev_nocancel +// Sendto_nocancel +// Pread_nocancel +// Pwrite_nocancel +// Waitid_nocancel +// Poll_nocancel +// Msgsnd_nocancel +// Msgrcv_nocancel +// Sem_wait_nocancel +// Aio_suspend_nocancel +// __sigwait_nocancel +// __semwait_signal_nocancel +// __mac_mount +// __mac_get_mount +// __mac_getfsstat diff --git a/vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go new file mode 100644 index 0000000000..da7cb7982c --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go @@ -0,0 +1,61 @@ +// 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 amd64,dragonfly + +package unix + +import ( + "syscall" + "unsafe" +) + +func Getpagesize() int { return 4096 } + +func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = nsec / 1e9 + ts.Nsec = nsec % 1e9 + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Usec = nsec % 1e9 / 1e3 + tv.Sec = int64(nsec / 1e9) + return +} + +func SetKevent(k *Kevent_t, fd, mode, flags int) { + k.Ident = uint64(fd) + k.Filter = int16(mode) + k.Flags = uint16(flags) +} + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint64(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint32(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint32(length) +} + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + var writtenOut uint64 = 0 + _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) + + written = int(writtenOut) + + if e1 != 0 { + err = e1 + } + return +} + +func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd.go b/vendor/golang.org/x/sys/unix/syscall_freebsd.go new file mode 100644 index 0000000000..ec56ed608a --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd.go @@ -0,0 +1,682 @@ +// Copyright 2009,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. + +// FreeBSD system calls. +// This file is compiled as ordinary Go code, +// but it is also input to mksyscall, +// which parses the //sys lines and generates system call stubs. +// Note that sometimes we use a lowercase //sys name and wrap +// it in our own nicer implementation, either here or in +// syscall_bsd.go or syscall_unix.go. + +package unix + +import "unsafe" + +type SockaddrDatalink struct { + Len uint8 + Family uint8 + Index uint16 + Type uint8 + Nlen uint8 + Alen uint8 + Slen uint8 + Data [46]int8 + raw RawSockaddrDatalink +} + +// Translate "kern.hostname" to []_C_int{0,1,2,3}. +func nametomib(name string) (mib []_C_int, err error) { + const siz = unsafe.Sizeof(mib[0]) + + // NOTE(rsc): It seems strange to set the buffer to have + // size CTL_MAXNAME+2 but use only CTL_MAXNAME + // as the size. I don't know why the +2 is here, but the + // kernel uses +2 for its own implementation of this function. + // I am scared that if we don't include the +2 here, the kernel + // will silently write 2 words farther than we specify + // and we'll get memory corruption. + var buf [CTL_MAXNAME + 2]_C_int + n := uintptr(CTL_MAXNAME) * siz + + p := (*byte)(unsafe.Pointer(&buf[0])) + bytes, err := ByteSliceFromString(name) + if err != nil { + return nil, err + } + + // Magic sysctl: "setting" 0.3 to a string name + // lets you read back the array of integers form. + if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil { + return nil, err + } + return buf[0 : n/siz], nil +} + +// ParseDirent parses up to max directory entries in buf, +// appending the names to names. It returns the number +// 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) + for max != 0 && len(buf) > 0 { + dirent := (*Dirent)(unsafe.Pointer(&buf[0])) + if dirent.Reclen == 0 { + buf = nil + break + } + buf = buf[dirent.Reclen:] + if dirent.Fileno == 0 { // File absent in directory. + continue + } + bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0])) + var name = string(bytes[0:dirent.Namlen]) + if name == "." || name == ".." { // Useless names + continue + } + max-- + count++ + names = append(names, name) + } + return origlen - len(buf), count, names +} + +//sysnb pipe() (r int, w int, err error) + +func Pipe(p []int) (err error) { + if len(p) != 2 { + return EINVAL + } + p[0], p[1], err = pipe() + return +} + +func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error) { + var value IPMreqn + vallen := _Socklen(SizeofIPMreqn) + errno := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen) + return &value, errno +} + +func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error) { + return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq)) +} + +func Accept4(fd, flags int) (nfd int, sa Sockaddr, err error) { + var rsa RawSockaddrAny + var len _Socklen = SizeofSockaddrAny + nfd, err = accept4(fd, &rsa, &len, flags) + if err != nil { + return + } + if len > SizeofSockaddrAny { + panic("RawSockaddrAny too small") + } + sa, err = anyToSockaddr(&rsa) + if err != nil { + Close(nfd) + nfd = 0 + } + return +} + +func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { + var _p0 unsafe.Pointer + var bufsize uintptr + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf)) + } + r0, _, e1 := Syscall(SYS_GETFSSTAT, uintptr(_p0), bufsize, uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +// Derive extattr namespace and attribute name + +func xattrnamespace(fullattr string) (ns int, attr string, err error) { + s := -1 + for idx, val := range fullattr { + if val == '.' { + s = idx + break + } + } + + if s == -1 { + return -1, "", ENOATTR + } + + namespace := fullattr[0:s] + attr = fullattr[s+1:] + + switch namespace { + case "user": + return EXTATTR_NAMESPACE_USER, attr, nil + case "system": + return EXTATTR_NAMESPACE_SYSTEM, attr, nil + default: + return -1, "", ENOATTR + } +} + +func initxattrdest(dest []byte, idx int) (d unsafe.Pointer) { + if len(dest) > idx { + return unsafe.Pointer(&dest[idx]) + } else { + return unsafe.Pointer(_zero) + } +} + +// FreeBSD implements its own syscalls to handle extended attributes + +func Getxattr(file string, attr string, dest []byte) (sz int, err error) { + d := initxattrdest(dest, 0) + destsize := len(dest) + + nsid, a, err := xattrnamespace(attr) + if err != nil { + return -1, err + } + + return ExtattrGetFile(file, nsid, a, uintptr(d), destsize) +} + +func Fgetxattr(fd int, attr string, dest []byte) (sz int, err error) { + d := initxattrdest(dest, 0) + destsize := len(dest) + + nsid, a, err := xattrnamespace(attr) + if err != nil { + return -1, err + } + + return ExtattrGetFd(fd, nsid, a, uintptr(d), destsize) +} + +func Lgetxattr(link string, attr string, dest []byte) (sz int, err error) { + d := initxattrdest(dest, 0) + destsize := len(dest) + + nsid, a, err := xattrnamespace(attr) + if err != nil { + return -1, err + } + + return ExtattrGetLink(link, nsid, a, uintptr(d), destsize) +} + +// flags are unused on FreeBSD + +func Fsetxattr(fd int, attr string, data []byte, flags int) (err error) { + d := unsafe.Pointer(&data[0]) + datasiz := len(data) + + nsid, a, err := xattrnamespace(attr) + if err != nil { + return + } + + _, err = ExtattrSetFd(fd, nsid, a, uintptr(d), datasiz) + return +} + +func Setxattr(file string, attr string, data []byte, flags int) (err error) { + d := unsafe.Pointer(&data[0]) + datasiz := len(data) + + nsid, a, err := xattrnamespace(attr) + if err != nil { + return + } + + _, err = ExtattrSetFile(file, nsid, a, uintptr(d), datasiz) + return +} + +func Lsetxattr(link string, attr string, data []byte, flags int) (err error) { + d := unsafe.Pointer(&data[0]) + datasiz := len(data) + + nsid, a, err := xattrnamespace(attr) + if err != nil { + return + } + + _, err = ExtattrSetLink(link, nsid, a, uintptr(d), datasiz) + return +} + +func Removexattr(file string, attr string) (err error) { + nsid, a, err := xattrnamespace(attr) + if err != nil { + return + } + + err = ExtattrDeleteFile(file, nsid, a) + return +} + +func Fremovexattr(fd int, attr string) (err error) { + nsid, a, err := xattrnamespace(attr) + if err != nil { + return + } + + err = ExtattrDeleteFd(fd, nsid, a) + return +} + +func Lremovexattr(link string, attr string) (err error) { + nsid, a, err := xattrnamespace(attr) + if err != nil { + return + } + + err = ExtattrDeleteLink(link, nsid, a) + return +} + +func Listxattr(file string, dest []byte) (sz int, err error) { + d := initxattrdest(dest, 0) + destsiz := len(dest) + + // FreeBSD won't allow you to list xattrs from multiple namespaces + s := 0 + var e error + for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} { + stmp, e := ExtattrListFile(file, nsid, uintptr(d), destsiz) + + /* Errors accessing system attrs are ignored so that + * we can implement the Linux-like behavior of omitting errors that + * we don't have read permissions on + * + * Linux will still error if we ask for user attributes on a file that + * we don't have read permissions on, so don't ignore those errors + */ + if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER { + e = nil + continue + } else if e != nil { + return s, e + } + + s += stmp + destsiz -= s + if destsiz < 0 { + destsiz = 0 + } + d = initxattrdest(dest, s) + } + + return s, e +} + +func Flistxattr(fd int, dest []byte) (sz int, err error) { + d := initxattrdest(dest, 0) + destsiz := len(dest) + + s := 0 + var e error + for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} { + stmp, e := ExtattrListFd(fd, nsid, uintptr(d), destsiz) + if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER { + e = nil + continue + } else if e != nil { + return s, e + } + + s += stmp + destsiz -= s + if destsiz < 0 { + destsiz = 0 + } + d = initxattrdest(dest, s) + } + + return s, e +} + +func Llistxattr(link string, dest []byte) (sz int, err error) { + d := initxattrdest(dest, 0) + destsiz := len(dest) + + s := 0 + var e error + for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} { + stmp, e := ExtattrListLink(link, nsid, uintptr(d), destsiz) + if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER { + e = nil + continue + } else if e != nil { + return s, e + } + + s += stmp + destsiz -= s + if destsiz < 0 { + destsiz = 0 + } + d = initxattrdest(dest, s) + } + + return s, e +} + +/* + * Exposed directly + */ +//sys Access(path string, mode uint32) (err error) +//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error) +//sys Chdir(path string) (err error) +//sys Chflags(path string, flags int) (err error) +//sys Chmod(path string, mode uint32) (err error) +//sys Chown(path string, uid int, gid int) (err error) +//sys Chroot(path string) (err error) +//sys Close(fd int) (err error) +//sys Dup(fd int) (nfd int, err error) +//sys Dup2(from int, to int) (err error) +//sys Exit(code int) +//sys ExtattrGetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) +//sys ExtattrSetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) +//sys ExtattrDeleteFd(fd int, attrnamespace int, attrname string) (err error) +//sys ExtattrListFd(fd int, attrnamespace int, data uintptr, nbytes int) (ret int, err error) +//sys ExtattrGetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) +//sys ExtattrSetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) +//sys ExtattrDeleteFile(file string, attrnamespace int, attrname string) (err error) +//sys ExtattrListFile(file string, attrnamespace int, data uintptr, nbytes int) (ret int, err error) +//sys ExtattrGetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) +//sys ExtattrSetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) +//sys ExtattrDeleteLink(link string, attrnamespace int, attrname string) (err error) +//sys ExtattrListLink(link string, attrnamespace int, data uintptr, nbytes int) (ret int, err error) +//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_POSIX_FADVISE +//sys Fchdir(fd int) (err error) +//sys Fchflags(fd int, flags int) (err error) +//sys Fchmod(fd int, mode uint32) (err error) +//sys Fchown(fd int, uid int, gid int) (err error) +//sys Flock(fd int, how int) (err error) +//sys Fpathconf(fd int, name int) (val int, err error) +//sys Fstat(fd int, stat *Stat_t) (err error) +//sys Fstatfs(fd int, stat *Statfs_t) (err error) +//sys Fsync(fd int) (err error) +//sys Ftruncate(fd int, length int64) (err error) +//sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) +//sys Getdtablesize() (size int) +//sysnb Getegid() (egid int) +//sysnb Geteuid() (uid int) +//sysnb Getgid() (gid int) +//sysnb Getpgid(pid int) (pgid int, err error) +//sysnb Getpgrp() (pgrp int) +//sysnb Getpid() (pid int) +//sysnb Getppid() (ppid int) +//sys Getpriority(which int, who int) (prio int, err error) +//sysnb Getrlimit(which int, lim *Rlimit) (err error) +//sysnb Getrusage(who int, rusage *Rusage) (err error) +//sysnb Getsid(pid int) (sid int, err error) +//sysnb Gettimeofday(tv *Timeval) (err error) +//sysnb Getuid() (uid int) +//sys Issetugid() (tainted bool) +//sys Kill(pid int, signum syscall.Signal) (err error) +//sys Kqueue() (fd int, err error) +//sys Lchown(path string, uid int, gid int) (err error) +//sys Link(path string, link string) (err error) +//sys Listen(s int, backlog int) (err error) +//sys Lstat(path string, stat *Stat_t) (err error) +//sys Mkdir(path string, mode uint32) (err error) +//sys Mkfifo(path string, mode uint32) (err error) +//sys Mknod(path string, mode uint32, dev int) (err error) +//sys Mlock(b []byte) (err error) +//sys Mlockall(flags int) (err error) +//sys Mprotect(b []byte, prot int) (err error) +//sys Munlock(b []byte) (err error) +//sys Munlockall() (err error) +//sys Nanosleep(time *Timespec, leftover *Timespec) (err error) +//sys Open(path string, mode int, perm uint32) (fd int, err error) +//sys Pathconf(path string, name int) (val int, err error) +//sys Pread(fd int, p []byte, offset int64) (n int, err error) +//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) +//sys read(fd int, p []byte) (n int, err error) +//sys Readlink(path string, buf []byte) (n int, err error) +//sys Rename(from string, to string) (err error) +//sys Revoke(path string) (err error) +//sys Rmdir(path string) (err error) +//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK +//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) +//sysnb Setegid(egid int) (err error) +//sysnb Seteuid(euid int) (err error) +//sysnb Setgid(gid int) (err error) +//sys Setlogin(name string) (err error) +//sysnb Setpgid(pid int, pgid int) (err error) +//sys Setpriority(which int, who int, prio int) (err error) +//sysnb Setregid(rgid int, egid int) (err error) +//sysnb Setreuid(ruid int, euid int) (err error) +//sysnb Setresgid(rgid int, egid int, sgid int) (err error) +//sysnb Setresuid(ruid int, euid int, suid int) (err error) +//sysnb Setrlimit(which int, lim *Rlimit) (err error) +//sysnb Setsid() (pid int, err error) +//sysnb Settimeofday(tp *Timeval) (err error) +//sysnb Setuid(uid int) (err error) +//sys Stat(path string, stat *Stat_t) (err error) +//sys Statfs(path string, stat *Statfs_t) (err error) +//sys Symlink(path string, link string) (err error) +//sys Sync() (err error) +//sys Truncate(path string, length int64) (err error) +//sys Umask(newmask int) (oldmask int) +//sys Undelete(path string) (err error) +//sys Unlink(path string) (err error) +//sys Unmount(path string, flags int) (err error) +//sys write(fd int, p []byte) (n int, err error) +//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) +//sys munmap(addr uintptr, length uintptr) (err error) +//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ +//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE +//sys accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int, err error) + +/* + * Unimplemented + */ +// Profil +// Sigaction +// Sigprocmask +// Getlogin +// Sigpending +// Sigaltstack +// Ioctl +// Reboot +// Execve +// Vfork +// Sbrk +// Sstk +// Ovadvise +// Mincore +// Setitimer +// Swapon +// Select +// Sigsuspend +// Readv +// Writev +// Nfssvc +// Getfh +// Quotactl +// Mount +// Csops +// Waitid +// Add_profil +// Kdebug_trace +// Sigreturn +// Mmap +// Mlock +// Munlock +// Atsocket +// Kqueue_from_portset_np +// Kqueue_portset +// Getattrlist +// Setattrlist +// Getdirentriesattr +// Searchfs +// Delete +// Copyfile +// Poll +// Watchevent +// Waitevent +// Modwatch +// Getxattr +// Fgetxattr +// Setxattr +// Fsetxattr +// Removexattr +// Fremovexattr +// Listxattr +// Flistxattr +// Fsctl +// Initgroups +// Posix_spawn +// Nfsclnt +// Fhopen +// Minherit +// Semsys +// Msgsys +// Shmsys +// Semctl +// Semget +// Semop +// Msgctl +// Msgget +// Msgsnd +// Msgrcv +// Shmat +// Shmctl +// Shmdt +// Shmget +// Shm_open +// Shm_unlink +// Sem_open +// Sem_close +// Sem_unlink +// Sem_wait +// Sem_trywait +// Sem_post +// Sem_getvalue +// Sem_init +// Sem_destroy +// Open_extended +// Umask_extended +// Stat_extended +// Lstat_extended +// Fstat_extended +// Chmod_extended +// Fchmod_extended +// Access_extended +// Settid +// Gettid +// Setsgroups +// Getsgroups +// Setwgroups +// Getwgroups +// Mkfifo_extended +// Mkdir_extended +// Identitysvc +// Shared_region_check_np +// Shared_region_map_np +// __pthread_mutex_destroy +// __pthread_mutex_init +// __pthread_mutex_lock +// __pthread_mutex_trylock +// __pthread_mutex_unlock +// __pthread_cond_init +// __pthread_cond_destroy +// __pthread_cond_broadcast +// __pthread_cond_signal +// Setsid_with_pid +// __pthread_cond_timedwait +// Aio_fsync +// Aio_return +// Aio_suspend +// Aio_cancel +// Aio_error +// Aio_read +// Aio_write +// Lio_listio +// __pthread_cond_wait +// Iopolicysys +// Mlockall +// Munlockall +// __pthread_kill +// __pthread_sigmask +// __sigwait +// __disable_threadsignal +// __pthread_markcancel +// __pthread_canceled +// __semwait_signal +// Proc_info +// Stat64_extended +// Lstat64_extended +// Fstat64_extended +// __pthread_chdir +// __pthread_fchdir +// Audit +// Auditon +// Getauid +// Setauid +// Getaudit +// Setaudit +// Getaudit_addr +// Setaudit_addr +// Auditctl +// Bsdthread_create +// Bsdthread_terminate +// Stack_snapshot +// Bsdthread_register +// Workq_open +// Workq_ops +// __mac_execve +// __mac_syscall +// __mac_get_file +// __mac_set_file +// __mac_get_link +// __mac_set_link +// __mac_get_proc +// __mac_set_proc +// __mac_get_fd +// __mac_set_fd +// __mac_get_pid +// __mac_get_lcid +// __mac_get_lctx +// __mac_set_lctx +// Setlcid +// Read_nocancel +// Write_nocancel +// Open_nocancel +// Close_nocancel +// Wait4_nocancel +// Recvmsg_nocancel +// Sendmsg_nocancel +// Recvfrom_nocancel +// Accept_nocancel +// Msync_nocancel +// Fcntl_nocancel +// Select_nocancel +// Fsync_nocancel +// Connect_nocancel +// Sigsuspend_nocancel +// Readv_nocancel +// Writev_nocancel +// Sendto_nocancel +// Pread_nocancel +// Pwrite_nocancel +// Waitid_nocancel +// Poll_nocancel +// Msgsnd_nocancel +// Msgrcv_nocancel +// Sem_wait_nocancel +// Aio_suspend_nocancel +// __sigwait_nocancel +// __semwait_signal_nocancel +// __mac_mount +// __mac_get_mount +// __mac_getfsstat diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go new file mode 100644 index 0000000000..6a0cd804d8 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go @@ -0,0 +1,61 @@ +// 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 386,freebsd + +package unix + +import ( + "syscall" + "unsafe" +) + +func Getpagesize() int { return 4096 } + +func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = int32(nsec / 1e9) + ts.Nsec = int32(nsec % 1e9) + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Usec = int32(nsec % 1e9 / 1e3) + tv.Sec = int32(nsec / 1e9) + return +} + +func SetKevent(k *Kevent_t, fd, mode, flags int) { + k.Ident = uint32(fd) + k.Filter = int16(mode) + k.Flags = uint16(flags) +} + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint32(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint32(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint32(length) +} + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + var writtenOut uint64 = 0 + _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) + + written = int(writtenOut) + + if e1 != 0 { + err = e1 + } + return +} + +func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go new file mode 100644 index 0000000000..e142540efa --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go @@ -0,0 +1,61 @@ +// 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 amd64,freebsd + +package unix + +import ( + "syscall" + "unsafe" +) + +func Getpagesize() int { return 4096 } + +func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = nsec / 1e9 + ts.Nsec = nsec % 1e9 + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Usec = nsec % 1e9 / 1e3 + tv.Sec = int64(nsec / 1e9) + return +} + +func SetKevent(k *Kevent_t, fd, mode, flags int) { + k.Ident = uint64(fd) + k.Filter = int16(mode) + k.Flags = uint16(flags) +} + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint64(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint32(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint32(length) +} + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + var writtenOut uint64 = 0 + _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) + + written = int(writtenOut) + + if e1 != 0 { + err = e1 + } + return +} + +func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go new file mode 100644 index 0000000000..5504cb1255 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go @@ -0,0 +1,61 @@ +// 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 arm,freebsd + +package unix + +import ( + "syscall" + "unsafe" +) + +func Getpagesize() int { return 4096 } + +func TimespecToNsec(ts Timespec) int64 { return ts.Sec*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = nsec / 1e9 + ts.Nsec = int32(nsec % 1e9) + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Usec = int32(nsec % 1e9 / 1e3) + tv.Sec = nsec / 1e9 + return +} + +func SetKevent(k *Kevent_t, fd, mode, flags int) { + k.Ident = uint32(fd) + k.Filter = int16(mode) + k.Flags = uint16(flags) +} + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint32(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint32(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint32(length) +} + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + var writtenOut uint64 = 0 + _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) + + written = int(writtenOut) + + if e1 != 0 { + err = e1 + } + return +} + +func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go new file mode 100644 index 0000000000..9ca104c957 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -0,0 +1,1108 @@ +// 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. + +// Linux system calls. +// This file is compiled as ordinary Go code, +// but it is also input to mksyscall, +// which parses the //sys lines and generates system call stubs. +// Note that sometimes we use a lowercase //sys name and +// wrap it in our own nicer implementation. + +package unix + +import ( + "syscall" + "unsafe" +) + +/* + * Wrapped + */ + +func Access(path string, mode uint32) (err error) { + return Faccessat(AT_FDCWD, path, mode, 0) +} + +func Chmod(path string, mode uint32) (err error) { + return Fchmodat(AT_FDCWD, path, mode, 0) +} + +func Chown(path string, uid int, gid int) (err error) { + return Fchownat(AT_FDCWD, path, uid, gid, 0) +} + +func Creat(path string, mode uint32) (fd int, err error) { + return Open(path, O_CREAT|O_WRONLY|O_TRUNC, mode) +} + +//sys Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) + +func Link(oldpath string, newpath string) (err error) { + return Linkat(AT_FDCWD, oldpath, AT_FDCWD, newpath, 0) +} + +func Mkdir(path string, mode uint32) (err error) { + return Mkdirat(AT_FDCWD, path, mode) +} + +func Mknod(path string, mode uint32, dev int) (err error) { + return Mknodat(AT_FDCWD, path, mode, dev) +} + +func Open(path string, mode int, perm uint32) (fd int, err error) { + return openat(AT_FDCWD, path, mode|O_LARGEFILE, perm) +} + +//sys openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) + +func Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) { + return openat(dirfd, path, flags|O_LARGEFILE, mode) +} + +//sys readlinkat(dirfd int, path string, buf []byte) (n int, err error) + +func Readlink(path string, buf []byte) (n int, err error) { + return readlinkat(AT_FDCWD, path, buf) +} + +func Rename(oldpath string, newpath string) (err error) { + return Renameat(AT_FDCWD, oldpath, AT_FDCWD, newpath) +} + +func Rmdir(path string) error { + return unlinkat(AT_FDCWD, path, AT_REMOVEDIR) +} + +//sys symlinkat(oldpath string, newdirfd int, newpath string) (err error) + +func Symlink(oldpath string, newpath string) (err error) { + return symlinkat(oldpath, AT_FDCWD, newpath) +} + +func Unlink(path string) error { + return unlinkat(AT_FDCWD, path, 0) +} + +//sys unlinkat(dirfd int, path string, flags int) (err error) + +func Unlinkat(dirfd int, path string, flags int) error { + return unlinkat(dirfd, path, flags) +} + +//sys utimes(path string, times *[2]Timeval) (err error) + +func Utimes(path string, tv []Timeval) error { + if tv == nil { + err := utimensat(AT_FDCWD, path, nil, 0) + if err != ENOSYS { + return err + } + return utimes(path, nil) + } + if len(tv) != 2 { + return EINVAL + } + var ts [2]Timespec + ts[0] = NsecToTimespec(TimevalToNsec(tv[0])) + ts[1] = NsecToTimespec(TimevalToNsec(tv[1])) + err := utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) + if err != ENOSYS { + return err + } + return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) +} + +//sys utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) + +func UtimesNano(path string, ts []Timespec) error { + if ts == nil { + err := utimensat(AT_FDCWD, path, nil, 0) + if err != ENOSYS { + return err + } + return utimes(path, nil) + } + if len(ts) != 2 { + return EINVAL + } + err := utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) + if err != ENOSYS { + return err + } + // If the utimensat syscall isn't available (utimensat was added to Linux + // in 2.6.22, Released, 8 July 2007) then fall back to utimes + var tv [2]Timeval + for i := 0; i < 2; i++ { + tv[i].Sec = ts[i].Sec + tv[i].Usec = ts[i].Nsec / 1000 + } + return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) +} + +func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) error { + if ts == nil { + return utimensat(dirfd, path, nil, flags) + } + if len(ts) != 2 { + return EINVAL + } + return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), flags) +} + +//sys futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) + +func Futimesat(dirfd int, path string, tv []Timeval) error { + pathp, err := BytePtrFromString(path) + if err != nil { + return err + } + if tv == nil { + return futimesat(dirfd, pathp, nil) + } + if len(tv) != 2 { + return EINVAL + } + return futimesat(dirfd, pathp, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) +} + +func Futimes(fd int, tv []Timeval) (err error) { + // Believe it or not, this is the best we can do on Linux + // (and is what glibc does). + return Utimes("/proc/self/fd/"+itoa(fd), tv) +} + +const ImplementsGetwd = true + +//sys Getcwd(buf []byte) (n int, err error) + +func Getwd() (wd string, err error) { + var buf [PathMax]byte + n, err := Getcwd(buf[0:]) + if err != nil { + return "", err + } + // Getcwd returns the number of bytes written to buf, including the NUL. + if n < 1 || n > len(buf) || buf[n-1] != 0 { + return "", EINVAL + } + return string(buf[0 : n-1]), nil +} + +func Getgroups() (gids []int, err error) { + n, err := getgroups(0, nil) + if err != nil { + return nil, err + } + if n == 0 { + return nil, nil + } + + // Sanity check group count. Max is 1<<16 on Linux. + if n < 0 || n > 1<<20 { + return nil, EINVAL + } + + a := make([]_Gid_t, n) + n, err = getgroups(n, &a[0]) + if err != nil { + return nil, err + } + gids = make([]int, n) + for i, v := range a[0:n] { + gids[i] = int(v) + } + return +} + +func Setgroups(gids []int) (err error) { + if len(gids) == 0 { + return setgroups(0, nil) + } + + a := make([]_Gid_t, len(gids)) + for i, v := range gids { + a[i] = _Gid_t(v) + } + return setgroups(len(a), &a[0]) +} + +type WaitStatus uint32 + +// Wait status is 7 bits at bottom, either 0 (exited), +// 0x7F (stopped), or a signal number that caused an exit. +// The 0x80 bit is whether there was a core dump. +// An extra number (exit code, signal causing a stop) +// is in the high bits. At least that's the idea. +// There are various irregularities. For example, the +// "continued" status is 0xFFFF, distinguishing itself +// from stopped via the core dump bit. + +const ( + mask = 0x7F + core = 0x80 + exited = 0x00 + stopped = 0x7F + shift = 8 +) + +func (w WaitStatus) Exited() bool { return w&mask == exited } + +func (w WaitStatus) Signaled() bool { return w&mask != stopped && w&mask != exited } + +func (w WaitStatus) Stopped() bool { return w&0xFF == stopped } + +func (w WaitStatus) Continued() bool { return w == 0xFFFF } + +func (w WaitStatus) CoreDump() bool { return w.Signaled() && w&core != 0 } + +func (w WaitStatus) ExitStatus() int { + if !w.Exited() { + return -1 + } + return int(w>>shift) & 0xFF +} + +func (w WaitStatus) Signal() syscall.Signal { + if !w.Signaled() { + return -1 + } + return syscall.Signal(w & mask) +} + +func (w WaitStatus) StopSignal() syscall.Signal { + if !w.Stopped() { + return -1 + } + return syscall.Signal(w>>shift) & 0xFF +} + +func (w WaitStatus) TrapCause() int { + if w.StopSignal() != SIGTRAP { + return -1 + } + return int(w>>shift) >> 8 +} + +//sys wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) + +func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) { + var status _C_int + wpid, err = wait4(pid, &status, options, rusage) + if wstatus != nil { + *wstatus = WaitStatus(status) + } + return +} + +func Mkfifo(path string, mode uint32) (err error) { + return Mknod(path, mode|S_IFIFO, 0) +} + +func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) { + if sa.Port < 0 || sa.Port > 0xFFFF { + return nil, 0, EINVAL + } + sa.raw.Family = AF_INET + p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) + p[0] = byte(sa.Port >> 8) + p[1] = byte(sa.Port) + for i := 0; i < len(sa.Addr); i++ { + sa.raw.Addr[i] = sa.Addr[i] + } + return unsafe.Pointer(&sa.raw), SizeofSockaddrInet4, nil +} + +func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) { + if sa.Port < 0 || sa.Port > 0xFFFF { + return nil, 0, EINVAL + } + sa.raw.Family = AF_INET6 + p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) + p[0] = byte(sa.Port >> 8) + p[1] = byte(sa.Port) + sa.raw.Scope_id = sa.ZoneId + for i := 0; i < len(sa.Addr); i++ { + sa.raw.Addr[i] = sa.Addr[i] + } + return unsafe.Pointer(&sa.raw), SizeofSockaddrInet6, nil +} + +func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) { + name := sa.Name + n := len(name) + if n >= len(sa.raw.Path) { + return nil, 0, EINVAL + } + sa.raw.Family = AF_UNIX + for i := 0; i < n; i++ { + sa.raw.Path[i] = int8(name[i]) + } + // length is family (uint16), name, NUL. + sl := _Socklen(2) + if n > 0 { + sl += _Socklen(n) + 1 + } + if sa.raw.Path[0] == '@' { + sa.raw.Path[0] = 0 + // Don't count trailing NUL for abstract address. + sl-- + } + + return unsafe.Pointer(&sa.raw), sl, nil +} + +type SockaddrLinklayer struct { + Protocol uint16 + Ifindex int + Hatype uint16 + Pkttype uint8 + Halen uint8 + Addr [8]byte + raw RawSockaddrLinklayer +} + +func (sa *SockaddrLinklayer) sockaddr() (unsafe.Pointer, _Socklen, error) { + if sa.Ifindex < 0 || sa.Ifindex > 0x7fffffff { + return nil, 0, EINVAL + } + sa.raw.Family = AF_PACKET + sa.raw.Protocol = sa.Protocol + sa.raw.Ifindex = int32(sa.Ifindex) + sa.raw.Hatype = sa.Hatype + sa.raw.Pkttype = sa.Pkttype + sa.raw.Halen = sa.Halen + for i := 0; i < len(sa.Addr); i++ { + sa.raw.Addr[i] = sa.Addr[i] + } + return unsafe.Pointer(&sa.raw), SizeofSockaddrLinklayer, nil +} + +type SockaddrNetlink struct { + Family uint16 + Pad uint16 + Pid uint32 + Groups uint32 + raw RawSockaddrNetlink +} + +func (sa *SockaddrNetlink) sockaddr() (unsafe.Pointer, _Socklen, error) { + sa.raw.Family = AF_NETLINK + sa.raw.Pad = sa.Pad + sa.raw.Pid = sa.Pid + sa.raw.Groups = sa.Groups + return unsafe.Pointer(&sa.raw), SizeofSockaddrNetlink, nil +} + +type SockaddrHCI struct { + Dev uint16 + Channel uint16 + raw RawSockaddrHCI +} + +func (sa *SockaddrHCI) sockaddr() (unsafe.Pointer, _Socklen, error) { + sa.raw.Family = AF_BLUETOOTH + sa.raw.Dev = sa.Dev + sa.raw.Channel = sa.Channel + return unsafe.Pointer(&sa.raw), SizeofSockaddrHCI, nil +} + +func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) { + switch rsa.Addr.Family { + case AF_NETLINK: + pp := (*RawSockaddrNetlink)(unsafe.Pointer(rsa)) + sa := new(SockaddrNetlink) + sa.Family = pp.Family + sa.Pad = pp.Pad + sa.Pid = pp.Pid + sa.Groups = pp.Groups + return sa, nil + + case AF_PACKET: + pp := (*RawSockaddrLinklayer)(unsafe.Pointer(rsa)) + sa := new(SockaddrLinklayer) + sa.Protocol = pp.Protocol + sa.Ifindex = int(pp.Ifindex) + sa.Hatype = pp.Hatype + sa.Pkttype = pp.Pkttype + sa.Halen = pp.Halen + for i := 0; i < len(sa.Addr); i++ { + sa.Addr[i] = pp.Addr[i] + } + return sa, nil + + case AF_UNIX: + pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa)) + sa := new(SockaddrUnix) + if pp.Path[0] == 0 { + // "Abstract" Unix domain socket. + // Rewrite leading NUL as @ for textual display. + // (This is the standard convention.) + // Not friendly to overwrite in place, + // but the callers below don't care. + pp.Path[0] = '@' + } + + // Assume path ends at NUL. + // This is not technically the Linux semantics for + // abstract Unix domain sockets--they are supposed + // to be uninterpreted fixed-size binary blobs--but + // everyone uses this convention. + n := 0 + for n < len(pp.Path) && pp.Path[n] != 0 { + n++ + } + bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n] + sa.Name = string(bytes) + return sa, nil + + case AF_INET: + pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa)) + sa := new(SockaddrInet4) + p := (*[2]byte)(unsafe.Pointer(&pp.Port)) + sa.Port = int(p[0])<<8 + int(p[1]) + for i := 0; i < len(sa.Addr); i++ { + sa.Addr[i] = pp.Addr[i] + } + return sa, nil + + case AF_INET6: + pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa)) + sa := new(SockaddrInet6) + p := (*[2]byte)(unsafe.Pointer(&pp.Port)) + sa.Port = int(p[0])<<8 + int(p[1]) + sa.ZoneId = pp.Scope_id + for i := 0; i < len(sa.Addr); i++ { + sa.Addr[i] = pp.Addr[i] + } + return sa, nil + } + return nil, EAFNOSUPPORT +} + +func Accept(fd int) (nfd int, sa Sockaddr, err error) { + var rsa RawSockaddrAny + var len _Socklen = SizeofSockaddrAny + nfd, err = accept(fd, &rsa, &len) + if err != nil { + return + } + sa, err = anyToSockaddr(&rsa) + if err != nil { + Close(nfd) + nfd = 0 + } + return +} + +func Accept4(fd int, flags int) (nfd int, sa Sockaddr, err error) { + var rsa RawSockaddrAny + var len _Socklen = SizeofSockaddrAny + nfd, err = accept4(fd, &rsa, &len, flags) + if err != nil { + return + } + if len > SizeofSockaddrAny { + panic("RawSockaddrAny too small") + } + sa, err = anyToSockaddr(&rsa) + if err != nil { + Close(nfd) + nfd = 0 + } + return +} + +func Getsockname(fd int) (sa Sockaddr, err error) { + var rsa RawSockaddrAny + var len _Socklen = SizeofSockaddrAny + if err = getsockname(fd, &rsa, &len); err != nil { + return + } + return anyToSockaddr(&rsa) +} + +func GetsockoptInet4Addr(fd, level, opt int) (value [4]byte, err error) { + vallen := _Socklen(4) + err = getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen) + return value, err +} + +func GetsockoptIPMreq(fd, level, opt int) (*IPMreq, error) { + var value IPMreq + vallen := _Socklen(SizeofIPMreq) + err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen) + return &value, err +} + +func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error) { + var value IPMreqn + vallen := _Socklen(SizeofIPMreqn) + err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen) + return &value, err +} + +func GetsockoptIPv6Mreq(fd, level, opt int) (*IPv6Mreq, error) { + var value IPv6Mreq + vallen := _Socklen(SizeofIPv6Mreq) + err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen) + return &value, err +} + +func GetsockoptIPv6MTUInfo(fd, level, opt int) (*IPv6MTUInfo, error) { + var value IPv6MTUInfo + vallen := _Socklen(SizeofIPv6MTUInfo) + err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen) + return &value, err +} + +func GetsockoptICMPv6Filter(fd, level, opt int) (*ICMPv6Filter, error) { + var value ICMPv6Filter + vallen := _Socklen(SizeofICMPv6Filter) + err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen) + return &value, err +} + +func GetsockoptUcred(fd, level, opt int) (*Ucred, error) { + var value Ucred + vallen := _Socklen(SizeofUcred) + err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen) + return &value, err +} + +func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error) { + return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq)) +} + +func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) { + var msg Msghdr + var rsa RawSockaddrAny + msg.Name = (*byte)(unsafe.Pointer(&rsa)) + msg.Namelen = uint32(SizeofSockaddrAny) + var iov Iovec + if len(p) > 0 { + iov.Base = (*byte)(unsafe.Pointer(&p[0])) + iov.SetLen(len(p)) + } + var dummy byte + if len(oob) > 0 { + // receive at least one normal byte + if len(p) == 0 { + iov.Base = &dummy + iov.SetLen(1) + } + msg.Control = (*byte)(unsafe.Pointer(&oob[0])) + msg.SetControllen(len(oob)) + } + msg.Iov = &iov + msg.Iovlen = 1 + if n, err = recvmsg(fd, &msg, flags); err != nil { + return + } + oobn = int(msg.Controllen) + recvflags = int(msg.Flags) + // source address is only specified if the socket is unconnected + if rsa.Addr.Family != AF_UNSPEC { + from, err = anyToSockaddr(&rsa) + } + return +} + +func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) { + _, err = SendmsgN(fd, p, oob, to, flags) + return +} + +func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) { + var ptr unsafe.Pointer + var salen _Socklen + if to != nil { + var err error + ptr, salen, err = to.sockaddr() + if err != nil { + return 0, err + } + } + var msg Msghdr + msg.Name = (*byte)(unsafe.Pointer(ptr)) + msg.Namelen = uint32(salen) + var iov Iovec + if len(p) > 0 { + iov.Base = (*byte)(unsafe.Pointer(&p[0])) + iov.SetLen(len(p)) + } + var dummy byte + if len(oob) > 0 { + // send at least one normal byte + if len(p) == 0 { + iov.Base = &dummy + iov.SetLen(1) + } + msg.Control = (*byte)(unsafe.Pointer(&oob[0])) + msg.SetControllen(len(oob)) + } + msg.Iov = &iov + msg.Iovlen = 1 + if n, err = sendmsg(fd, &msg, flags); err != nil { + return 0, err + } + if len(oob) > 0 && len(p) == 0 { + n = 0 + } + return n, nil +} + +// BindToDevice binds the socket associated with fd to device. +func BindToDevice(fd int, device string) (err error) { + return SetsockoptString(fd, SOL_SOCKET, SO_BINDTODEVICE, device) +} + +//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error) + +func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, err error) { + // The peek requests are machine-size oriented, so we wrap it + // to retrieve arbitrary-length data. + + // The ptrace syscall differs from glibc's ptrace. + // Peeks returns the word in *data, not as the return value. + + var buf [sizeofPtr]byte + + // Leading edge. PEEKTEXT/PEEKDATA don't require aligned + // access (PEEKUSER warns that it might), but if we don't + // align our reads, we might straddle an unmapped page + // boundary and not get the bytes leading up to the page + // boundary. + n := 0 + if addr%sizeofPtr != 0 { + err = ptrace(req, pid, addr-addr%sizeofPtr, uintptr(unsafe.Pointer(&buf[0]))) + if err != nil { + return 0, err + } + n += copy(out, buf[addr%sizeofPtr:]) + out = out[n:] + } + + // Remainder. + for len(out) > 0 { + // We use an internal buffer to guarantee alignment. + // It's not documented if this is necessary, but we're paranoid. + err = ptrace(req, pid, addr+uintptr(n), uintptr(unsafe.Pointer(&buf[0]))) + if err != nil { + return n, err + } + copied := copy(out, buf[0:]) + n += copied + out = out[copied:] + } + + return n, nil +} + +func PtracePeekText(pid int, addr uintptr, out []byte) (count int, err error) { + return ptracePeek(PTRACE_PEEKTEXT, pid, addr, out) +} + +func PtracePeekData(pid int, addr uintptr, out []byte) (count int, err error) { + return ptracePeek(PTRACE_PEEKDATA, pid, addr, out) +} + +func ptracePoke(pokeReq int, peekReq int, pid int, addr uintptr, data []byte) (count int, err error) { + // As for ptracePeek, we need to align our accesses to deal + // with the possibility of straddling an invalid page. + + // Leading edge. + n := 0 + if addr%sizeofPtr != 0 { + var buf [sizeofPtr]byte + err = ptrace(peekReq, pid, addr-addr%sizeofPtr, uintptr(unsafe.Pointer(&buf[0]))) + if err != nil { + return 0, err + } + n += copy(buf[addr%sizeofPtr:], data) + word := *((*uintptr)(unsafe.Pointer(&buf[0]))) + err = ptrace(pokeReq, pid, addr-addr%sizeofPtr, word) + if err != nil { + return 0, err + } + data = data[n:] + } + + // Interior. + for len(data) > sizeofPtr { + word := *((*uintptr)(unsafe.Pointer(&data[0]))) + err = ptrace(pokeReq, pid, addr+uintptr(n), word) + if err != nil { + return n, err + } + n += sizeofPtr + data = data[sizeofPtr:] + } + + // Trailing edge. + if len(data) > 0 { + var buf [sizeofPtr]byte + err = ptrace(peekReq, pid, addr+uintptr(n), uintptr(unsafe.Pointer(&buf[0]))) + if err != nil { + return n, err + } + copy(buf[0:], data) + word := *((*uintptr)(unsafe.Pointer(&buf[0]))) + err = ptrace(pokeReq, pid, addr+uintptr(n), word) + if err != nil { + return n, err + } + n += len(data) + } + + return n, nil +} + +func PtracePokeText(pid int, addr uintptr, data []byte) (count int, err error) { + return ptracePoke(PTRACE_POKETEXT, PTRACE_PEEKTEXT, pid, addr, data) +} + +func PtracePokeData(pid int, addr uintptr, data []byte) (count int, err error) { + return ptracePoke(PTRACE_POKEDATA, PTRACE_PEEKDATA, pid, addr, data) +} + +func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) { + return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) +} + +func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) { + return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) +} + +func PtraceSetOptions(pid int, options int) (err error) { + return ptrace(PTRACE_SETOPTIONS, pid, 0, uintptr(options)) +} + +func PtraceGetEventMsg(pid int) (msg uint, err error) { + var data _C_long + err = ptrace(PTRACE_GETEVENTMSG, pid, 0, uintptr(unsafe.Pointer(&data))) + msg = uint(data) + return +} + +func PtraceCont(pid int, signal int) (err error) { + return ptrace(PTRACE_CONT, pid, 0, uintptr(signal)) +} + +func PtraceSyscall(pid int, signal int) (err error) { + return ptrace(PTRACE_SYSCALL, pid, 0, uintptr(signal)) +} + +func PtraceSingleStep(pid int) (err error) { return ptrace(PTRACE_SINGLESTEP, pid, 0, 0) } + +func PtraceAttach(pid int) (err error) { return ptrace(PTRACE_ATTACH, pid, 0, 0) } + +func PtraceDetach(pid int) (err error) { return ptrace(PTRACE_DETACH, pid, 0, 0) } + +//sys reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) + +func Reboot(cmd int) (err error) { + return reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd, "") +} + +func clen(n []byte) int { + for i := 0; i < len(n); i++ { + if n[i] == 0 { + return i + } + } + return len(n) +} + +func ReadDirent(fd int, buf []byte) (n int, err error) { + return Getdents(fd, buf) +} + +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 { + dirent := (*Dirent)(unsafe.Pointer(&buf[0])) + buf = buf[dirent.Reclen:] + if dirent.Ino == 0 { // File absent in directory. + continue + } + bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0])) + var name = string(bytes[0:clen(bytes[:])]) + if name == "." || name == ".." { // Useless names + continue + } + max-- + count++ + names = append(names, name) + } + return origlen - len(buf), count, names +} + +//sys mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) + +func Mount(source string, target string, fstype string, flags uintptr, data string) (err error) { + // Certain file systems get rather angry and EINVAL if you give + // them an empty string of data, rather than NULL. + if data == "" { + return mount(source, target, fstype, flags, nil) + } + datap, err := BytePtrFromString(data) + if err != nil { + return err + } + return mount(source, target, fstype, flags, datap) +} + +// Sendto +// Recvfrom +// Socketpair + +/* + * Direct access + */ +//sys Acct(path string) (err error) +//sys Adjtimex(buf *Timex) (state int, err error) +//sys Chdir(path string) (err error) +//sys Chroot(path string) (err error) +//sys ClockGettime(clockid int32, time *Timespec) (err error) +//sys Close(fd int) (err error) +//sys Dup(oldfd int) (fd int, err error) +//sys Dup3(oldfd int, newfd int, flags int) (err error) +//sysnb EpollCreate(size int) (fd int, err error) +//sysnb EpollCreate1(flag int) (fd int, err error) +//sysnb EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) +//sys Exit(code int) = SYS_EXIT_GROUP +//sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error) +//sys Fallocate(fd int, mode uint32, off int64, len int64) (err error) +//sys Fchdir(fd int) (err error) +//sys Fchmod(fd int, mode uint32) (err error) +//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) +//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) +//sys fcntl(fd int, cmd int, arg int) (val int, err error) +//sys Fdatasync(fd int) (err error) +//sys Flock(fd int, how int) (err error) +//sys Fsync(fd int) (err error) +//sys Getdents(fd int, buf []byte) (n int, err error) = SYS_GETDENTS64 +//sysnb Getpgid(pid int) (pgid int, err error) + +func Getpgrp() (pid int) { + pid, _ = Getpgid(0) + return +} + +//sysnb Getpid() (pid int) +//sysnb Getppid() (ppid int) +//sys Getpriority(which int, who int) (prio int, err error) +//sysnb Getrusage(who int, rusage *Rusage) (err error) +//sysnb Gettid() (tid int) +//sys Getxattr(path string, attr string, dest []byte) (sz int, err error) +//sys InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) +//sysnb InotifyInit1(flags int) (fd int, err error) +//sysnb InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) +//sysnb Kill(pid int, sig syscall.Signal) (err error) +//sys Klogctl(typ int, buf []byte) (n int, err error) = SYS_SYSLOG +//sys Listxattr(path string, dest []byte) (sz int, err error) +//sys Mkdirat(dirfd int, path string, mode uint32) (err error) +//sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error) +//sys Nanosleep(time *Timespec, leftover *Timespec) (err error) +//sys PivotRoot(newroot string, putold string) (err error) = SYS_PIVOT_ROOT +//sysnb prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) = SYS_PRLIMIT64 +//sys Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) +//sys read(fd int, p []byte) (n int, err error) +//sys Removexattr(path string, attr string) (err error) +//sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) +//sys Setdomainname(p []byte) (err error) +//sys Sethostname(p []byte) (err error) +//sysnb Setpgid(pid int, pgid int) (err error) +//sysnb Setsid() (pid int, err error) +//sysnb Settimeofday(tv *Timeval) (err error) +//sys Setns(fd int, nstype int) (err error) + +// issue 1435. +// On linux Setuid and Setgid only affects the current thread, not the process. +// This does not match what most callers expect so we must return an error +// here rather than letting the caller think that the call succeeded. + +func Setuid(uid int) (err error) { + return EOPNOTSUPP +} + +func Setgid(uid int) (err error) { + return EOPNOTSUPP +} + +//sys Setpriority(which int, who int, prio int) (err error) +//sys Setxattr(path string, attr string, data []byte, flags int) (err error) +//sys Sync() +//sysnb Sysinfo(info *Sysinfo_t) (err error) +//sys Tee(rfd int, wfd int, len int, flags int) (n int64, err error) +//sysnb Tgkill(tgid int, tid int, sig syscall.Signal) (err error) +//sysnb Times(tms *Tms) (ticks uintptr, err error) +//sysnb Umask(mask int) (oldmask int) +//sysnb Uname(buf *Utsname) (err error) +//sys Unmount(target string, flags int) (err error) = SYS_UMOUNT2 +//sys Unshare(flags int) (err error) +//sys Ustat(dev int, ubuf *Ustat_t) (err error) +//sys write(fd int, p []byte) (n int, err error) +//sys exitThread(code int) (err error) = SYS_EXIT +//sys readlen(fd int, p *byte, np int) (n int, err error) = SYS_READ +//sys writelen(fd int, p *byte, np int) (n int, err error) = SYS_WRITE + +// mmap varies by architecture; see syscall_linux_*.go. +//sys munmap(addr uintptr, length uintptr) (err error) + +var mapper = &mmapper{ + active: make(map[*byte][]byte), + mmap: mmap, + munmap: munmap, +} + +func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) { + return mapper.Mmap(fd, offset, length, prot, flags) +} + +func Munmap(b []byte) (err error) { + return mapper.Munmap(b) +} + +//sys Madvise(b []byte, advice int) (err error) +//sys Mprotect(b []byte, prot int) (err error) +//sys Mlock(b []byte) (err error) +//sys Munlock(b []byte) (err error) +//sys Mlockall(flags int) (err error) +//sys Munlockall() (err error) + +/* + * Unimplemented + */ +// AddKey +// AfsSyscall +// Alarm +// ArchPrctl +// Brk +// Capget +// Capset +// ClockGetres +// ClockNanosleep +// ClockSettime +// Clone +// CreateModule +// DeleteModule +// EpollCtlOld +// EpollPwait +// EpollWaitOld +// Eventfd +// Execve +// Fgetxattr +// Flistxattr +// Fork +// Fremovexattr +// Fsetxattr +// Futex +// GetKernelSyms +// GetMempolicy +// GetRobustList +// GetThreadArea +// Getitimer +// Getpmsg +// IoCancel +// IoDestroy +// IoGetevents +// IoSetup +// IoSubmit +// Ioctl +// IoprioGet +// IoprioSet +// KexecLoad +// Keyctl +// Lgetxattr +// Llistxattr +// LookupDcookie +// Lremovexattr +// Lsetxattr +// Mbind +// MigratePages +// Mincore +// ModifyLdt +// Mount +// MovePages +// Mprotect +// MqGetsetattr +// MqNotify +// MqOpen +// MqTimedreceive +// MqTimedsend +// MqUnlink +// Mremap +// Msgctl +// Msgget +// Msgrcv +// Msgsnd +// Msync +// Newfstatat +// Nfsservctl +// Personality +// Poll +// Ppoll +// Pselect6 +// Ptrace +// Putpmsg +// QueryModule +// Quotactl +// Readahead +// Readv +// RemapFilePages +// RequestKey +// RestartSyscall +// RtSigaction +// RtSigpending +// RtSigprocmask +// RtSigqueueinfo +// RtSigreturn +// RtSigsuspend +// RtSigtimedwait +// SchedGetPriorityMax +// SchedGetPriorityMin +// SchedGetaffinity +// SchedGetparam +// SchedGetscheduler +// SchedRrGetInterval +// SchedSetaffinity +// SchedSetparam +// SchedYield +// Security +// Semctl +// Semget +// Semop +// Semtimedop +// SetMempolicy +// SetRobustList +// SetThreadArea +// SetTidAddress +// Shmat +// Shmctl +// Shmdt +// Shmget +// Sigaltstack +// Signalfd +// Swapoff +// Swapon +// Sysfs +// TimerCreate +// TimerDelete +// TimerGetoverrun +// TimerGettime +// TimerSettime +// Timerfd +// Tkill (obsolete) +// Tuxcall +// Umount2 +// Uselib +// Utimensat +// Vfork +// Vhangup +// Vmsplice +// Vserver +// Waitid +// _Sysctl diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_386.go b/vendor/golang.org/x/sys/unix/syscall_linux_386.go new file mode 100644 index 0000000000..bea01cb506 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_linux_386.go @@ -0,0 +1,390 @@ +// 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. + +// TODO(rsc): Rewrite all nn(SP) references into name+(nn-8)(FP) +// so that go vet can check that they are correct. + +// +build 386,linux + +package unix + +import ( + "syscall" + "unsafe" +) + +func Getpagesize() int { return 4096 } + +func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = int32(nsec / 1e9) + ts.Nsec = int32(nsec % 1e9) + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Sec = int32(nsec / 1e9) + tv.Usec = int32(nsec % 1e9 / 1e3) + return +} + +//sysnb pipe(p *[2]_C_int) (err error) + +func Pipe(p []int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe(&pp) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + +//sysnb pipe2(p *[2]_C_int, flags int) (err error) + +func Pipe2(p []int, flags int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe2(&pp, flags) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + +// 64-bit file system and 32-bit uid calls +// (386 default is 32-bit file system and 16-bit uid). +//sys Dup2(oldfd int, newfd int) (err error) +//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64_64 +//sys Fchown(fd int, uid int, gid int) (err error) = SYS_FCHOWN32 +//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 +//sys Ftruncate(fd int, length int64) (err error) = SYS_FTRUNCATE64 +//sysnb Getegid() (egid int) = SYS_GETEGID32 +//sysnb Geteuid() (euid int) = SYS_GETEUID32 +//sysnb Getgid() (gid int) = SYS_GETGID32 +//sysnb Getuid() (uid int) = SYS_GETUID32 +//sysnb InotifyInit() (fd int, err error) +//sys Ioperm(from int, num int, on int) (err error) +//sys Iopl(level int) (err error) +//sys Lchown(path string, uid int, gid int) (err error) = SYS_LCHOWN32 +//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64 +//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64 +//sys Setfsgid(gid int) (err error) = SYS_SETFSGID32 +//sys Setfsuid(uid int) (err error) = SYS_SETFSUID32 +//sysnb Setregid(rgid int, egid int) (err error) = SYS_SETREGID32 +//sysnb Setresgid(rgid int, egid int, sgid int) (err error) = SYS_SETRESGID32 +//sysnb Setresuid(ruid int, euid int, suid int) (err error) = SYS_SETRESUID32 +//sysnb Setreuid(ruid int, euid int) (err error) = SYS_SETREUID32 +//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) +//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 +//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) +//sys Truncate(path string, length int64) (err error) = SYS_TRUNCATE64 +//sysnb getgroups(n int, list *_Gid_t) (nn int, err error) = SYS_GETGROUPS32 +//sysnb setgroups(n int, list *_Gid_t) (err error) = SYS_SETGROUPS32 +//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT + +//sys mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error) +//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) +//sys Pause() (err error) + +func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { + page := uintptr(offset / 4096) + if offset != int64(page)*4096 { + return 0, EINVAL + } + return mmap2(addr, length, prot, flags, fd, page) +} + +type rlimit32 struct { + Cur uint32 + Max uint32 +} + +//sysnb getrlimit(resource int, rlim *rlimit32) (err error) = SYS_GETRLIMIT + +const rlimInf32 = ^uint32(0) +const rlimInf64 = ^uint64(0) + +func Getrlimit(resource int, rlim *Rlimit) (err error) { + err = prlimit(0, resource, nil, rlim) + if err != ENOSYS { + return err + } + + rl := rlimit32{} + err = getrlimit(resource, &rl) + if err != nil { + return + } + + if rl.Cur == rlimInf32 { + rlim.Cur = rlimInf64 + } else { + rlim.Cur = uint64(rl.Cur) + } + + if rl.Max == rlimInf32 { + rlim.Max = rlimInf64 + } else { + rlim.Max = uint64(rl.Max) + } + return +} + +//sysnb setrlimit(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT + +func Setrlimit(resource int, rlim *Rlimit) (err error) { + err = prlimit(0, resource, rlim, nil) + if err != ENOSYS { + return err + } + + rl := rlimit32{} + if rlim.Cur == rlimInf64 { + rl.Cur = rlimInf32 + } else if rlim.Cur < uint64(rlimInf32) { + rl.Cur = uint32(rlim.Cur) + } else { + return EINVAL + } + if rlim.Max == rlimInf64 { + rl.Max = rlimInf32 + } else if rlim.Max < uint64(rlimInf32) { + rl.Max = uint32(rlim.Max) + } else { + return EINVAL + } + + return setrlimit(resource, &rl) +} + +// Underlying system call writes to newoffset via pointer. +// Implemented in assembly to avoid allocation. +func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) + +func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { + newoffset, errno := seek(fd, offset, whence) + if errno != 0 { + return 0, errno + } + return newoffset, nil +} + +// Vsyscalls on amd64. +//sysnb Gettimeofday(tv *Timeval) (err error) +//sysnb Time(t *Time_t) (tt Time_t, err error) + +//sys Utime(path string, buf *Utimbuf) (err error) + +// On x86 Linux, all the socket calls go through an extra indirection, +// I think because the 5-register system call interface can't handle +// the 6-argument calls like sendto and recvfrom. Instead the +// arguments to the underlying system call are the number below +// and a pointer to an array of uintptr. We hide the pointer in the +// socketcall assembly to avoid allocation on every system call. + +const ( + // see linux/net.h + _SOCKET = 1 + _BIND = 2 + _CONNECT = 3 + _LISTEN = 4 + _ACCEPT = 5 + _GETSOCKNAME = 6 + _GETPEERNAME = 7 + _SOCKETPAIR = 8 + _SEND = 9 + _RECV = 10 + _SENDTO = 11 + _RECVFROM = 12 + _SHUTDOWN = 13 + _SETSOCKOPT = 14 + _GETSOCKOPT = 15 + _SENDMSG = 16 + _RECVMSG = 17 + _ACCEPT4 = 18 + _RECVMMSG = 19 + _SENDMMSG = 20 +) + +func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) +func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + fd, e := socketcall(_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0) + if e != 0 { + err = e + } + return +} + +func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { + fd, e := socketcall(_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) + if e != 0 { + err = e + } + return +} + +func getsockname(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, e := rawsocketcall(_GETSOCKNAME, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0) + if e != 0 { + err = e + } + return +} + +func getpeername(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, e := rawsocketcall(_GETPEERNAME, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0) + if e != 0 { + err = e + } + return +} + +func socketpair(domain int, typ int, flags int, fd *[2]int32) (err error) { + _, e := rawsocketcall(_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(flags), uintptr(unsafe.Pointer(fd)), 0, 0) + if e != 0 { + err = e + } + return +} + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, e := socketcall(_BIND, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0) + if e != 0 { + err = e + } + return +} + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, e := socketcall(_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0) + if e != 0 { + err = e + } + return +} + +func socket(domain int, typ int, proto int) (fd int, err error) { + fd, e := rawsocketcall(_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto), 0, 0, 0) + if e != 0 { + err = e + } + return +} + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, e := socketcall(_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e != 0 { + err = e + } + return +} + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, e := socketcall(_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), vallen, 0) + if e != 0 { + err = e + } + return +} + +func recvfrom(s int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var base uintptr + if len(p) > 0 { + base = uintptr(unsafe.Pointer(&p[0])) + } + n, e := socketcall(_RECVFROM, uintptr(s), base, uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + if e != 0 { + err = e + } + return +} + +func sendto(s int, p []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var base uintptr + if len(p) > 0 { + base = uintptr(unsafe.Pointer(&p[0])) + } + _, e := socketcall(_SENDTO, uintptr(s), base, uintptr(len(p)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e != 0 { + err = e + } + return +} + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + n, e := socketcall(_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags), 0, 0, 0) + if e != 0 { + err = e + } + return +} + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + n, e := socketcall(_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags), 0, 0, 0) + if e != 0 { + err = e + } + return +} + +func Listen(s int, n int) (err error) { + _, e := socketcall(_LISTEN, uintptr(s), uintptr(n), 0, 0, 0, 0) + if e != 0 { + err = e + } + return +} + +func Shutdown(s, how int) (err error) { + _, e := socketcall(_SHUTDOWN, uintptr(s), uintptr(how), 0, 0, 0, 0) + if e != 0 { + err = e + } + return +} + +func Fstatfs(fd int, buf *Statfs_t) (err error) { + _, _, e := Syscall(SYS_FSTATFS64, uintptr(fd), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf))) + if e != 0 { + err = e + } + return +} + +func Statfs(path string, buf *Statfs_t) (err error) { + pathp, err := BytePtrFromString(path) + if err != nil { + return err + } + _, _, e := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(pathp)), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf))) + if e != 0 { + err = e + } + return +} + +func (r *PtraceRegs) PC() uint64 { return uint64(uint32(r.Eip)) } + +func (r *PtraceRegs) SetPC(pc uint64) { r.Eip = int32(pc) } + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint32(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint32(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint32(length) +} diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go b/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go new file mode 100644 index 0000000000..721f24b68d --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go @@ -0,0 +1,148 @@ +// 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 amd64,linux + +package unix + +import "syscall" + +//sys Dup2(oldfd int, newfd int) (err error) +//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) +//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 +//sys Fchown(fd int, uid int, gid int) (err error) +//sys Fstat(fd int, stat *Stat_t) (err error) +//sys Fstatfs(fd int, buf *Statfs_t) (err error) +//sys Ftruncate(fd int, length int64) (err error) +//sysnb Getegid() (egid int) +//sysnb Geteuid() (euid int) +//sysnb Getgid() (gid int) +//sysnb Getrlimit(resource int, rlim *Rlimit) (err error) +//sysnb Getuid() (uid int) +//sysnb InotifyInit() (fd int, err error) +//sys Ioperm(from int, num int, on int) (err error) +//sys Iopl(level int) (err error) +//sys Lchown(path string, uid int, gid int) (err error) +//sys Listen(s int, n int) (err error) +//sys Lstat(path string, stat *Stat_t) (err error) +//sys Pause() (err error) +//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK +//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) +//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) +//sys Setfsgid(gid int) (err error) +//sys Setfsuid(uid int) (err error) +//sysnb Setregid(rgid int, egid int) (err error) +//sysnb Setresgid(rgid int, egid int, sgid int) (err error) +//sysnb Setresuid(ruid int, euid int, suid int) (err error) +//sysnb Setrlimit(resource int, rlim *Rlimit) (err error) +//sysnb Setreuid(ruid int, euid int) (err error) +//sys Shutdown(fd int, how int) (err error) +//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) +//sys Stat(path string, stat *Stat_t) (err error) +//sys Statfs(path string, buf *Statfs_t) (err error) +//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) +//sys Truncate(path string, length int64) (err error) +//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) +//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) +//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) +//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) +//sysnb getgroups(n int, list *_Gid_t) (nn int, err error) +//sysnb setgroups(n int, list *_Gid_t) (err error) +//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) +//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) +//sysnb socket(domain int, typ int, proto int) (fd int, err error) +//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) +//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) +//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) +//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) +//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) +//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) +//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) +//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) + +//go:noescape +func gettimeofday(tv *Timeval) (err syscall.Errno) + +func Gettimeofday(tv *Timeval) (err error) { + errno := gettimeofday(tv) + if errno != 0 { + return errno + } + return nil +} + +func Getpagesize() int { return 4096 } + +func Time(t *Time_t) (tt Time_t, err error) { + var tv Timeval + errno := gettimeofday(&tv) + if errno != 0 { + return 0, errno + } + if t != nil { + *t = Time_t(tv.Sec) + } + return Time_t(tv.Sec), nil +} + +//sys Utime(path string, buf *Utimbuf) (err error) + +func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = nsec / 1e9 + ts.Nsec = nsec % 1e9 + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Sec = nsec / 1e9 + tv.Usec = nsec % 1e9 / 1e3 + return +} + +//sysnb pipe(p *[2]_C_int) (err error) + +func Pipe(p []int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe(&pp) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + +//sysnb pipe2(p *[2]_C_int, flags int) (err error) + +func Pipe2(p []int, flags int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe2(&pp, flags) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + +func (r *PtraceRegs) PC() uint64 { return r.Rip } + +func (r *PtraceRegs) SetPC(pc uint64) { r.Rip = pc } + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint64(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint64(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint64(length) +} diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_arm.go b/vendor/golang.org/x/sys/unix/syscall_linux_arm.go new file mode 100644 index 0000000000..122df649af --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_linux_arm.go @@ -0,0 +1,254 @@ +// 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 arm,linux + +package unix + +import ( + "syscall" + "unsafe" +) + +func Getpagesize() int { return 4096 } + +func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = int32(nsec / 1e9) + ts.Nsec = int32(nsec % 1e9) + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Sec = int32(nsec / 1e9) + tv.Usec = int32(nsec % 1e9 / 1e3) + return +} + +func Pipe(p []int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe2(&pp, 0) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + +//sysnb pipe2(p *[2]_C_int, flags int) (err error) + +func Pipe2(p []int, flags int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe2(&pp, flags) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + +// Underlying system call writes to newoffset via pointer. +// Implemented in assembly to avoid allocation. +func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) + +func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { + newoffset, errno := seek(fd, offset, whence) + if errno != 0 { + return 0, errno + } + return newoffset, nil +} + +//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) +//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) +//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) +//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) +//sysnb getgroups(n int, list *_Gid_t) (nn int, err error) = SYS_GETGROUPS32 +//sysnb setgroups(n int, list *_Gid_t) (err error) = SYS_SETGROUPS32 +//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) +//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) +//sysnb socket(domain int, typ int, proto int) (fd int, err error) +//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) +//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) +//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) +//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) +//sysnb socketpair(domain int, typ int, flags int, fd *[2]int32) (err error) +//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) +//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) + +// 64-bit file system and 32-bit uid calls +// (16-bit uid calls are not always supported in newer kernels) +//sys Dup2(oldfd int, newfd int) (err error) +//sys Fchown(fd int, uid int, gid int) (err error) = SYS_FCHOWN32 +//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 +//sysnb Getegid() (egid int) = SYS_GETEGID32 +//sysnb Geteuid() (euid int) = SYS_GETEUID32 +//sysnb Getgid() (gid int) = SYS_GETGID32 +//sysnb Getuid() (uid int) = SYS_GETUID32 +//sysnb InotifyInit() (fd int, err error) +//sys Lchown(path string, uid int, gid int) (err error) = SYS_LCHOWN32 +//sys Listen(s int, n int) (err error) +//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64 +//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64 +//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT +//sys Setfsgid(gid int) (err error) = SYS_SETFSGID32 +//sys Setfsuid(uid int) (err error) = SYS_SETFSUID32 +//sysnb Setregid(rgid int, egid int) (err error) = SYS_SETREGID32 +//sysnb Setresgid(rgid int, egid int, sgid int) (err error) = SYS_SETRESGID32 +//sysnb Setresuid(ruid int, euid int, suid int) (err error) = SYS_SETRESUID32 +//sysnb Setreuid(ruid int, euid int) (err error) = SYS_SETREUID32 +//sys Shutdown(fd int, how int) (err error) +//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) +//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 + +// Vsyscalls on amd64. +//sysnb Gettimeofday(tv *Timeval) (err error) +//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) +//sys Pause() (err error) + +func Time(t *Time_t) (Time_t, error) { + var tv Timeval + err := Gettimeofday(&tv) + if err != nil { + return 0, err + } + if t != nil { + *t = Time_t(tv.Sec) + } + return Time_t(tv.Sec), nil +} + +func Utime(path string, buf *Utimbuf) error { + tv := []Timeval{ + {Sec: buf.Actime}, + {Sec: buf.Modtime}, + } + return Utimes(path, tv) +} + +//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys Truncate(path string, length int64) (err error) = SYS_TRUNCATE64 +//sys Ftruncate(fd int, length int64) (err error) = SYS_FTRUNCATE64 + +func Fadvise(fd int, offset int64, length int64, advice int) (err error) { + _, _, e1 := Syscall6(SYS_ARM_FADVISE64_64, uintptr(fd), uintptr(advice), uintptr(offset), uintptr(offset>>32), uintptr(length), uintptr(length>>32)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +//sys mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error) + +func Fstatfs(fd int, buf *Statfs_t) (err error) { + _, _, e := Syscall(SYS_FSTATFS64, uintptr(fd), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf))) + if e != 0 { + err = e + } + return +} + +func Statfs(path string, buf *Statfs_t) (err error) { + pathp, err := BytePtrFromString(path) + if err != nil { + return err + } + _, _, e := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(pathp)), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf))) + if e != 0 { + err = e + } + return +} + +func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { + page := uintptr(offset / 4096) + if offset != int64(page)*4096 { + return 0, EINVAL + } + return mmap2(addr, length, prot, flags, fd, page) +} + +type rlimit32 struct { + Cur uint32 + Max uint32 +} + +//sysnb getrlimit(resource int, rlim *rlimit32) (err error) = SYS_UGETRLIMIT + +const rlimInf32 = ^uint32(0) +const rlimInf64 = ^uint64(0) + +func Getrlimit(resource int, rlim *Rlimit) (err error) { + err = prlimit(0, resource, nil, rlim) + if err != ENOSYS { + return err + } + + rl := rlimit32{} + err = getrlimit(resource, &rl) + if err != nil { + return + } + + if rl.Cur == rlimInf32 { + rlim.Cur = rlimInf64 + } else { + rlim.Cur = uint64(rl.Cur) + } + + if rl.Max == rlimInf32 { + rlim.Max = rlimInf64 + } else { + rlim.Max = uint64(rl.Max) + } + return +} + +//sysnb setrlimit(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT + +func Setrlimit(resource int, rlim *Rlimit) (err error) { + err = prlimit(0, resource, rlim, nil) + if err != ENOSYS { + return err + } + + rl := rlimit32{} + if rlim.Cur == rlimInf64 { + rl.Cur = rlimInf32 + } else if rlim.Cur < uint64(rlimInf32) { + rl.Cur = uint32(rlim.Cur) + } else { + return EINVAL + } + if rlim.Max == rlimInf64 { + rl.Max = rlimInf32 + } else if rlim.Max < uint64(rlimInf32) { + rl.Max = uint32(rlim.Max) + } else { + return EINVAL + } + + return setrlimit(resource, &rl) +} + +func (r *PtraceRegs) PC() uint64 { return uint64(r.Uregs[15]) } + +func (r *PtraceRegs) SetPC(pc uint64) { r.Uregs[15] = uint32(pc) } + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint32(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint32(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint32(length) +} diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go b/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go new file mode 100644 index 0000000000..d105186803 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go @@ -0,0 +1,180 @@ +// 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 arm64,linux + +package unix + +const _SYS_dup = SYS_DUP3 + +//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) = SYS_EPOLL_PWAIT +//sys Fchown(fd int, uid int, gid int) (err error) +//sys Fstat(fd int, stat *Stat_t) (err error) +//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) +//sys Fstatfs(fd int, buf *Statfs_t) (err error) +//sys Ftruncate(fd int, length int64) (err error) +//sysnb Getegid() (egid int) +//sysnb Geteuid() (euid int) +//sysnb Getgid() (gid int) +//sysnb Getrlimit(resource int, rlim *Rlimit) (err error) +//sysnb Getuid() (uid int) +//sys Listen(s int, n int) (err error) +//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK +//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS_PSELECT6 +//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) +//sys Setfsgid(gid int) (err error) +//sys Setfsuid(uid int) (err error) +//sysnb Setregid(rgid int, egid int) (err error) +//sysnb Setresgid(rgid int, egid int, sgid int) (err error) +//sysnb Setresuid(ruid int, euid int, suid int) (err error) +//sysnb Setrlimit(resource int, rlim *Rlimit) (err error) +//sysnb Setreuid(ruid int, euid int) (err error) +//sys Shutdown(fd int, how int) (err error) +//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) + +func Stat(path string, stat *Stat_t) (err error) { + return Fstatat(AT_FDCWD, path, stat, 0) +} + +func Lchown(path string, uid int, gid int) (err error) { + return Fchownat(AT_FDCWD, path, uid, gid, AT_SYMLINK_NOFOLLOW) +} + +func Lstat(path string, stat *Stat_t) (err error) { + return Fstatat(AT_FDCWD, path, stat, AT_SYMLINK_NOFOLLOW) +} + +//sys Statfs(path string, buf *Statfs_t) (err error) +//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) +//sys Truncate(path string, length int64) (err error) +//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) +//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) +//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) +//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) +//sysnb getgroups(n int, list *_Gid_t) (nn int, err error) +//sysnb setgroups(n int, list *_Gid_t) (err error) +//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) +//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) +//sysnb socket(domain int, typ int, proto int) (fd int, err error) +//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) +//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) +//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) +//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) +//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) +//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) +//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) +//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) + +func Getpagesize() int { return 65536 } + +//sysnb Gettimeofday(tv *Timeval) (err error) + +func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = nsec / 1e9 + ts.Nsec = nsec % 1e9 + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Sec = nsec / 1e9 + tv.Usec = nsec % 1e9 / 1e3 + return +} + +func Time(t *Time_t) (Time_t, error) { + var tv Timeval + err := Gettimeofday(&tv) + if err != nil { + return 0, err + } + if t != nil { + *t = Time_t(tv.Sec) + } + return Time_t(tv.Sec), nil +} + +func Utime(path string, buf *Utimbuf) error { + tv := []Timeval{ + {Sec: buf.Actime}, + {Sec: buf.Modtime}, + } + return Utimes(path, tv) +} + +func Pipe(p []int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe2(&pp, 0) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + +//sysnb pipe2(p *[2]_C_int, flags int) (err error) + +func Pipe2(p []int, flags int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe2(&pp, flags) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + +func (r *PtraceRegs) PC() uint64 { return r.Pc } + +func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc } + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint64(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint64(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint64(length) +} + +func InotifyInit() (fd int, err error) { + return InotifyInit1(0) +} + +func Dup2(oldfd int, newfd int) (err error) { + return Dup3(oldfd, newfd, 0) +} + +func Pause() (err error) { + _, _, e1 := Syscall6(SYS_PPOLL, 0, 0, 0, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// TODO(dfc): constants that should be in zsysnum_linux_arm64.go, remove +// these when the deprecated syscalls that the syscall package relies on +// are removed. +const ( + SYS_GETPGRP = 1060 + SYS_UTIMES = 1037 + SYS_FUTIMESAT = 1066 + SYS_PAUSE = 1061 + SYS_USTAT = 1070 + SYS_UTIME = 1063 + SYS_LCHOWN = 1032 + SYS_TIME = 1062 + SYS_EPOLL_CREATE = 1042 + SYS_EPOLL_WAIT = 1069 +) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go b/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go new file mode 100644 index 0000000000..bb15ba3e68 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go @@ -0,0 +1,206 @@ +// 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 + +package unix + +// Linux introduced getdents64 syscall for N64 ABI only in 3.10 +// (May 21 2013, rev dec33abaafc89bcbd78f85fad0513170415a26d5), +// to support older kernels, we have to use getdents for mips64. +// Also note that struct dirent is different for these two. +// Lookup linux_dirent{,64} in kernel source code for details. +const _SYS_getdents = SYS_GETDENTS + +//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) +//sys Fchown(fd int, uid int, gid int) (err error) +//sys Fstatfs(fd int, buf *Statfs_t) (err error) +//sys Ftruncate(fd int, length int64) (err error) +//sysnb Getegid() (egid int) +//sysnb Geteuid() (euid int) +//sysnb Getgid() (gid int) +//sysnb Getrlimit(resource int, rlim *Rlimit) (err error) +//sysnb Getuid() (uid int) +//sys Lchown(path string, uid int, gid int) (err error) +//sys Listen(s int, n int) (err error) +//sys Pause() (err error) +//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK +//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS_PSELECT6 +//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) +//sys Setfsgid(gid int) (err error) +//sys Setfsuid(uid int) (err error) +//sysnb Setregid(rgid int, egid int) (err error) +//sysnb Setresgid(rgid int, egid int, sgid int) (err error) +//sysnb Setresuid(ruid int, euid int, suid int) (err error) +//sysnb Setrlimit(resource int, rlim *Rlimit) (err error) +//sysnb Setreuid(ruid int, euid int) (err error) +//sys Shutdown(fd int, how int) (err error) +//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) +//sys Statfs(path string, buf *Statfs_t) (err error) +//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) +//sys Truncate(path string, length int64) (err error) +//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) +//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) +//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) +//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) +//sysnb getgroups(n int, list *_Gid_t) (nn int, err error) +//sysnb setgroups(n int, list *_Gid_t) (err error) +//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) +//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) +//sysnb socket(domain int, typ int, proto int) (fd int, err error) +//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) +//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) +//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) +//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) +//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) +//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) +//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) +//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) + +func Getpagesize() int { return 65536 } + +//sysnb Gettimeofday(tv *Timeval) (err error) + +func Time(t *Time_t) (tt Time_t, err error) { + var tv Timeval + err = Gettimeofday(&tv) + if err != nil { + return 0, err + } + if t != nil { + *t = Time_t(tv.Sec) + } + return Time_t(tv.Sec), nil +} + +//sys Utime(path string, buf *Utimbuf) (err error) + +func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = nsec / 1e9 + ts.Nsec = nsec % 1e9 + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Sec = nsec / 1e9 + tv.Usec = nsec % 1e9 / 1e3 + return +} + +func Pipe(p []int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe2(&pp, 0) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + +//sysnb pipe2(p *[2]_C_int, flags int) (err error) + +func Pipe2(p []int, flags int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe2(&pp, flags) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + +func Ioperm(from int, num int, on int) (err error) { + return ENOSYS +} + +func Iopl(level int) (err error) { + return ENOSYS +} + +type stat_t struct { + Dev uint32 + Pad0 [3]int32 + Ino uint64 + Mode uint32 + Nlink uint32 + Uid uint32 + Gid uint32 + Rdev uint32 + Pad1 [3]uint32 + Size int64 + Atime uint32 + Atime_nsec uint32 + Mtime uint32 + Mtime_nsec uint32 + Ctime uint32 + Ctime_nsec uint32 + Blksize uint32 + Pad2 uint32 + Blocks int64 +} + +//sys fstat(fd int, st *stat_t) (err error) +//sys lstat(path string, st *stat_t) (err error) +//sys stat(path string, st *stat_t) (err error) + +func Fstat(fd int, s *Stat_t) (err error) { + st := &stat_t{} + err = fstat(fd, st) + fillStat_t(s, st) + return +} + +func Lstat(path string, s *Stat_t) (err error) { + st := &stat_t{} + err = lstat(path, st) + fillStat_t(s, st) + return +} + +func Stat(path string, s *Stat_t) (err error) { + st := &stat_t{} + err = stat(path, st) + fillStat_t(s, st) + return +} + +func fillStat_t(s *Stat_t, st *stat_t) { + s.Dev = st.Dev + s.Ino = st.Ino + s.Mode = st.Mode + s.Nlink = st.Nlink + s.Uid = st.Uid + s.Gid = st.Gid + s.Rdev = st.Rdev + s.Size = st.Size + s.Atim = Timespec{int64(st.Atime), int64(st.Atime_nsec)} + s.Mtim = Timespec{int64(st.Mtime), int64(st.Mtime_nsec)} + s.Ctim = Timespec{int64(st.Ctime), int64(st.Ctime_nsec)} + s.Blksize = st.Blksize + s.Blocks = st.Blocks +} + +func (r *PtraceRegs) PC() uint64 { return r.Regs[64] } + +func (r *PtraceRegs) SetPC(pc uint64) { r.Regs[64] = pc } + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint64(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint64(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint64(length) +} diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go b/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go new file mode 100644 index 0000000000..acd2e1c789 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go @@ -0,0 +1,126 @@ +// 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 linux +// +build ppc64 ppc64le + +package unix + +//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) +//sys Dup2(oldfd int, newfd int) (err error) +//sys Fchown(fd int, uid int, gid int) (err error) +//sys Fstat(fd int, stat *Stat_t) (err error) +//sys Fstatfs(fd int, buf *Statfs_t) (err error) +//sys Ftruncate(fd int, length int64) (err error) +//sysnb Getegid() (egid int) +//sysnb Geteuid() (euid int) +//sysnb Getgid() (gid int) +//sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = SYS_UGETRLIMIT +//sysnb Getuid() (uid int) +//sysnb InotifyInit() (fd int, err error) +//sys Ioperm(from int, num int, on int) (err error) +//sys Iopl(level int) (err error) +//sys Lchown(path string, uid int, gid int) (err error) +//sys Listen(s int, n int) (err error) +//sys Lstat(path string, stat *Stat_t) (err error) +//sys Pause() (err error) +//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK +//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) +//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) +//sys Setfsgid(gid int) (err error) +//sys Setfsuid(uid int) (err error) +//sysnb Setregid(rgid int, egid int) (err error) +//sysnb Setresgid(rgid int, egid int, sgid int) (err error) +//sysnb Setresuid(ruid int, euid int, suid int) (err error) +//sysnb Setrlimit(resource int, rlim *Rlimit) (err error) +//sysnb Setreuid(ruid int, euid int) (err error) +//sys Shutdown(fd int, how int) (err error) +//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) +//sys Stat(path string, stat *Stat_t) (err error) +//sys Statfs(path string, buf *Statfs_t) (err error) +//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) = SYS_SYNC_FILE_RANGE2 +//sys Truncate(path string, length int64) (err error) +//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) +//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) +//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) +//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) +//sysnb getgroups(n int, list *_Gid_t) (nn int, err error) +//sysnb setgroups(n int, list *_Gid_t) (err error) +//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) +//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) +//sysnb socket(domain int, typ int, proto int) (fd int, err error) +//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) +//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) +//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) +//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) +//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) +//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) +//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) +//sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) + +func Getpagesize() int { return 65536 } + +//sysnb Gettimeofday(tv *Timeval) (err error) +//sysnb Time(t *Time_t) (tt Time_t, err error) + +//sys Utime(path string, buf *Utimbuf) (err error) + +func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = nsec / 1e9 + ts.Nsec = nsec % 1e9 + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Sec = nsec / 1e9 + tv.Usec = nsec % 1e9 / 1e3 + return +} + +func (r *PtraceRegs) PC() uint64 { return r.Nip } + +func (r *PtraceRegs) SetPC(pc uint64) { r.Nip = pc } + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint64(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint64(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint64(length) +} + +//sysnb pipe(p *[2]_C_int) (err error) + +func Pipe(p []int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe(&pp) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + +//sysnb pipe2(p *[2]_C_int, flags int) (err error) + +func Pipe2(p []int, flags int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe2(&pp, flags) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go b/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go new file mode 100644 index 0000000000..3f98904e3c --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go @@ -0,0 +1,320 @@ +// 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,linux + +package unix + +import ( + "unsafe" +) + +//sys Dup2(oldfd int, newfd int) (err error) +//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) +//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 +//sys Fchown(fd int, uid int, gid int) (err error) +//sys Fstat(fd int, stat *Stat_t) (err error) +//sys Fstatfs(fd int, buf *Statfs_t) (err error) +//sys Ftruncate(fd int, length int64) (err error) +//sysnb Getegid() (egid int) +//sysnb Geteuid() (euid int) +//sysnb Getgid() (gid int) +//sysnb Getrlimit(resource int, rlim *Rlimit) (err error) +//sysnb Getuid() (uid int) +//sysnb InotifyInit() (fd int, err error) +//sys Lchown(path string, uid int, gid int) (err error) +//sys Lstat(path string, stat *Stat_t) (err error) +//sys Pause() (err error) +//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 +//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 +//sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK +//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) +//sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) +//sys Setfsgid(gid int) (err error) +//sys Setfsuid(uid int) (err error) +//sysnb Setregid(rgid int, egid int) (err error) +//sysnb Setresgid(rgid int, egid int, sgid int) (err error) +//sysnb Setresuid(ruid int, euid int, suid int) (err error) +//sysnb Setrlimit(resource int, rlim *Rlimit) (err error) +//sysnb Setreuid(ruid int, euid int) (err error) +//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) +//sys Stat(path string, stat *Stat_t) (err error) +//sys Statfs(path string, buf *Statfs_t) (err error) +//sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) +//sys Truncate(path string, length int64) (err error) +//sysnb getgroups(n int, list *_Gid_t) (nn int, err error) +//sysnb setgroups(n int, list *_Gid_t) (err error) + +func Getpagesize() int { return 4096 } + +//sysnb Gettimeofday(tv *Timeval) (err error) + +func Time(t *Time_t) (tt Time_t, err error) { + var tv Timeval + err = Gettimeofday(&tv) + if err != nil { + return 0, err + } + if t != nil { + *t = Time_t(tv.Sec) + } + return Time_t(tv.Sec), nil +} + +//sys Utime(path string, buf *Utimbuf) (err error) + +func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = nsec / 1e9 + ts.Nsec = nsec % 1e9 + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Sec = nsec / 1e9 + tv.Usec = nsec % 1e9 / 1e3 + return +} + +//sysnb pipe2(p *[2]_C_int, flags int) (err error) + +func Pipe(p []int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe2(&pp, 0) // pipe2 is the same as pipe when flags are set to 0. + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + +func Pipe2(p []int, flags int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe2(&pp, flags) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + +func Ioperm(from int, num int, on int) (err error) { + return ENOSYS +} + +func Iopl(level int) (err error) { + return ENOSYS +} + +func (r *PtraceRegs) PC() uint64 { return r.Psw.Addr } + +func (r *PtraceRegs) SetPC(pc uint64) { r.Psw.Addr = pc } + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint64(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint64(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint64(length) +} + +// Linux on s390x uses the old mmap interface, which requires arguments to be passed in a struct. +// mmap2 also requires arguments to be passed in a struct; it is currently not exposed in . +func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { + mmap_args := [6]uintptr{addr, length, uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset)} + r0, _, e1 := Syscall(SYS_MMAP, uintptr(unsafe.Pointer(&mmap_args[0])), 0, 0) + use(unsafe.Pointer(&mmap_args[0])) + xaddr = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// On s390x Linux, all the socket calls go through an extra indirection. +// The arguments to the underlying system call (SYS_SOCKETCALL) are the +// number below and a pointer to an array of uintptr. +const ( + // see linux/net.h + netSocket = 1 + netBind = 2 + netConnect = 3 + netListen = 4 + netAccept = 5 + netGetSockName = 6 + netGetPeerName = 7 + netSocketPair = 8 + netSend = 9 + netRecv = 10 + netSendTo = 11 + netRecvFrom = 12 + netShutdown = 13 + netSetSockOpt = 14 + netGetSockOpt = 15 + netSendMsg = 16 + netRecvMsg = 17 + netAccept4 = 18 + netRecvMMsg = 19 + netSendMMsg = 20 +) + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (int, error) { + args := [3]uintptr{uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))} + fd, _, err := Syscall(SYS_SOCKETCALL, netAccept, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return 0, err + } + return int(fd), nil +} + +func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (int, error) { + args := [4]uintptr{uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags)} + fd, _, err := Syscall(SYS_SOCKETCALL, netAccept4, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return 0, err + } + return int(fd), nil +} + +func getsockname(s int, rsa *RawSockaddrAny, addrlen *_Socklen) error { + args := [3]uintptr{uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))} + _, _, err := RawSyscall(SYS_SOCKETCALL, netGetSockName, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return err + } + return nil +} + +func getpeername(s int, rsa *RawSockaddrAny, addrlen *_Socklen) error { + args := [3]uintptr{uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))} + _, _, err := RawSyscall(SYS_SOCKETCALL, netGetPeerName, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return err + } + return nil +} + +func socketpair(domain int, typ int, flags int, fd *[2]int32) error { + args := [4]uintptr{uintptr(domain), uintptr(typ), uintptr(flags), uintptr(unsafe.Pointer(fd))} + _, _, err := RawSyscall(SYS_SOCKETCALL, netSocketPair, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return err + } + return nil +} + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) error { + args := [3]uintptr{uintptr(s), uintptr(addr), uintptr(addrlen)} + _, _, err := Syscall(SYS_SOCKETCALL, netBind, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return err + } + return nil +} + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) error { + args := [3]uintptr{uintptr(s), uintptr(addr), uintptr(addrlen)} + _, _, err := Syscall(SYS_SOCKETCALL, netConnect, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return err + } + return nil +} + +func socket(domain int, typ int, proto int) (int, error) { + args := [3]uintptr{uintptr(domain), uintptr(typ), uintptr(proto)} + fd, _, err := RawSyscall(SYS_SOCKETCALL, netSocket, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return 0, err + } + return int(fd), nil +} + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) error { + args := [5]uintptr{uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen))} + _, _, err := Syscall(SYS_SOCKETCALL, netGetSockOpt, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return err + } + return nil +} + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) error { + args := [4]uintptr{uintptr(s), uintptr(level), uintptr(name), uintptr(val)} + _, _, err := Syscall(SYS_SOCKETCALL, netSetSockOpt, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return err + } + return nil +} + +func recvfrom(s int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (int, error) { + var base uintptr + if len(p) > 0 { + base = uintptr(unsafe.Pointer(&p[0])) + } + args := [6]uintptr{uintptr(s), base, uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))} + n, _, err := Syscall(SYS_SOCKETCALL, netRecvFrom, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return 0, err + } + return int(n), nil +} + +func sendto(s int, p []byte, flags int, to unsafe.Pointer, addrlen _Socklen) error { + var base uintptr + if len(p) > 0 { + base = uintptr(unsafe.Pointer(&p[0])) + } + args := [6]uintptr{uintptr(s), base, uintptr(len(p)), uintptr(flags), uintptr(to), uintptr(addrlen)} + _, _, err := Syscall(SYS_SOCKETCALL, netSendTo, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return err + } + return nil +} + +func recvmsg(s int, msg *Msghdr, flags int) (int, error) { + args := [3]uintptr{uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)} + n, _, err := Syscall(SYS_SOCKETCALL, netRecvMsg, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return 0, err + } + return int(n), nil +} + +func sendmsg(s int, msg *Msghdr, flags int) (int, error) { + args := [3]uintptr{uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)} + n, _, err := Syscall(SYS_SOCKETCALL, netSendMsg, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return 0, err + } + return int(n), nil +} + +func Listen(s int, n int) error { + args := [2]uintptr{uintptr(s), uintptr(n)} + _, _, err := Syscall(SYS_SOCKETCALL, netListen, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return err + } + return nil +} + +func Shutdown(s, how int) error { + args := [2]uintptr{uintptr(s), uintptr(how)} + _, _, err := Syscall(SYS_SOCKETCALL, netShutdown, uintptr(unsafe.Pointer(&args)), 0) + if err != 0 { + return err + } + return nil +} diff --git a/vendor/golang.org/x/sys/unix/syscall_netbsd.go b/vendor/golang.org/x/sys/unix/syscall_netbsd.go new file mode 100644 index 0000000000..c4e945cd69 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_netbsd.go @@ -0,0 +1,492 @@ +// Copyright 2009,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. + +// NetBSD system calls. +// This file is compiled as ordinary Go code, +// but it is also input to mksyscall, +// which parses the //sys lines and generates system call stubs. +// Note that sometimes we use a lowercase //sys name and wrap +// it in our own nicer implementation, either here or in +// syscall_bsd.go or syscall_unix.go. + +package unix + +import ( + "syscall" + "unsafe" +) + +type SockaddrDatalink struct { + Len uint8 + Family uint8 + Index uint16 + Type uint8 + Nlen uint8 + Alen uint8 + Slen uint8 + Data [12]int8 + raw RawSockaddrDatalink +} + +func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) + +func sysctlNodes(mib []_C_int) (nodes []Sysctlnode, err error) { + var olen uintptr + + // Get a list of all sysctl nodes below the given MIB by performing + // a sysctl for the given MIB with CTL_QUERY appended. + mib = append(mib, CTL_QUERY) + qnode := Sysctlnode{Flags: SYSCTL_VERS_1} + qp := (*byte)(unsafe.Pointer(&qnode)) + sz := unsafe.Sizeof(qnode) + if err = sysctl(mib, nil, &olen, qp, sz); err != nil { + return nil, err + } + + // Now that we know the size, get the actual nodes. + nodes = make([]Sysctlnode, olen/sz) + np := (*byte)(unsafe.Pointer(&nodes[0])) + if err = sysctl(mib, np, &olen, qp, sz); err != nil { + return nil, err + } + + return nodes, nil +} + +func nametomib(name string) (mib []_C_int, err error) { + + // Split name into components. + var parts []string + last := 0 + for i := 0; i < len(name); i++ { + if name[i] == '.' { + parts = append(parts, name[last:i]) + last = i + 1 + } + } + parts = append(parts, name[last:]) + + // Discover the nodes and construct the MIB OID. + for partno, part := range parts { + nodes, err := sysctlNodes(mib) + if err != nil { + return nil, err + } + for _, node := range nodes { + n := make([]byte, 0) + for i := range node.Name { + if node.Name[i] != 0 { + n = append(n, byte(node.Name[i])) + } + } + if string(n) == part { + mib = append(mib, _C_int(node.Num)) + break + } + } + if len(mib) != partno+1 { + return nil, EINVAL + } + } + + return mib, nil +} + +// ParseDirent parses up to max directory entries in buf, +// appending the names to names. It returns the number +// 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) + for max != 0 && len(buf) > 0 { + dirent := (*Dirent)(unsafe.Pointer(&buf[0])) + if dirent.Reclen == 0 { + buf = nil + break + } + buf = buf[dirent.Reclen:] + if dirent.Fileno == 0 { // File absent in directory. + continue + } + bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0])) + var name = string(bytes[0:dirent.Namlen]) + if name == "." || name == ".." { // Useless names + continue + } + max-- + count++ + names = append(names, name) + } + return origlen - len(buf), count, names +} + +//sysnb pipe() (fd1 int, fd2 int, err error) +func Pipe(p []int) (err error) { + if len(p) != 2 { + return EINVAL + } + p[0], p[1], err = pipe() + return +} + +//sys getdents(fd int, buf []byte) (n int, err error) +func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { + return getdents(fd, buf) +} + +// TODO +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + return -1, ENOSYS +} + +/* + * Exposed directly + */ +//sys Access(path string, mode uint32) (err error) +//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error) +//sys Chdir(path string) (err error) +//sys Chflags(path string, flags int) (err error) +//sys Chmod(path string, mode uint32) (err error) +//sys Chown(path string, uid int, gid int) (err error) +//sys Chroot(path string) (err error) +//sys Close(fd int) (err error) +//sys Dup(fd int) (nfd int, err error) +//sys Dup2(from int, to int) (err error) +//sys Exit(code int) +//sys Fchdir(fd int) (err error) +//sys Fchflags(fd int, flags int) (err error) +//sys Fchmod(fd int, mode uint32) (err error) +//sys Fchown(fd int, uid int, gid int) (err error) +//sys Flock(fd int, how int) (err error) +//sys Fpathconf(fd int, name int) (val int, err error) +//sys Fstat(fd int, stat *Stat_t) (err error) +//sys Fsync(fd int) (err error) +//sys Ftruncate(fd int, length int64) (err error) +//sysnb Getegid() (egid int) +//sysnb Geteuid() (uid int) +//sysnb Getgid() (gid int) +//sysnb Getpgid(pid int) (pgid int, err error) +//sysnb Getpgrp() (pgrp int) +//sysnb Getpid() (pid int) +//sysnb Getppid() (ppid int) +//sys Getpriority(which int, who int) (prio int, err error) +//sysnb Getrlimit(which int, lim *Rlimit) (err error) +//sysnb Getrusage(who int, rusage *Rusage) (err error) +//sysnb Getsid(pid int) (sid int, err error) +//sysnb Gettimeofday(tv *Timeval) (err error) +//sysnb Getuid() (uid int) +//sys Issetugid() (tainted bool) +//sys Kill(pid int, signum syscall.Signal) (err error) +//sys Kqueue() (fd int, err error) +//sys Lchown(path string, uid int, gid int) (err error) +//sys Link(path string, link string) (err error) +//sys Listen(s int, backlog int) (err error) +//sys Lstat(path string, stat *Stat_t) (err error) +//sys Mkdir(path string, mode uint32) (err error) +//sys Mkfifo(path string, mode uint32) (err error) +//sys Mknod(path string, mode uint32, dev int) (err error) +//sys Mlock(b []byte) (err error) +//sys Mlockall(flags int) (err error) +//sys Mprotect(b []byte, prot int) (err error) +//sys Munlock(b []byte) (err error) +//sys Munlockall() (err error) +//sys Nanosleep(time *Timespec, leftover *Timespec) (err error) +//sys Open(path string, mode int, perm uint32) (fd int, err error) +//sys Pathconf(path string, name int) (val int, err error) +//sys Pread(fd int, p []byte, offset int64) (n int, err error) +//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) +//sys read(fd int, p []byte) (n int, err error) +//sys Readlink(path string, buf []byte) (n int, err error) +//sys Rename(from string, to string) (err error) +//sys Revoke(path string) (err error) +//sys Rmdir(path string) (err error) +//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK +//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) +//sysnb Setegid(egid int) (err error) +//sysnb Seteuid(euid int) (err error) +//sysnb Setgid(gid int) (err error) +//sysnb Setpgid(pid int, pgid int) (err error) +//sys Setpriority(which int, who int, prio int) (err error) +//sysnb Setregid(rgid int, egid int) (err error) +//sysnb Setreuid(ruid int, euid int) (err error) +//sysnb Setrlimit(which int, lim *Rlimit) (err error) +//sysnb Setsid() (pid int, err error) +//sysnb Settimeofday(tp *Timeval) (err error) +//sysnb Setuid(uid int) (err error) +//sys Stat(path string, stat *Stat_t) (err error) +//sys Symlink(path string, link string) (err error) +//sys Sync() (err error) +//sys Truncate(path string, length int64) (err error) +//sys Umask(newmask int) (oldmask int) +//sys Unlink(path string) (err error) +//sys Unmount(path string, flags int) (err error) +//sys write(fd int, p []byte) (n int, err error) +//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) +//sys munmap(addr uintptr, length uintptr) (err error) +//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ +//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE + +/* + * Unimplemented + */ +// ____semctl13 +// __clone +// __fhopen40 +// __fhstat40 +// __fhstatvfs140 +// __fstat30 +// __getcwd +// __getfh30 +// __getlogin +// __lstat30 +// __mount50 +// __msgctl13 +// __msync13 +// __ntp_gettime30 +// __posix_chown +// __posix_fadvise50 +// __posix_fchown +// __posix_lchown +// __posix_rename +// __setlogin +// __shmctl13 +// __sigaction_sigtramp +// __sigaltstack14 +// __sigpending14 +// __sigprocmask14 +// __sigsuspend14 +// __sigtimedwait +// __stat30 +// __syscall +// __vfork14 +// _ksem_close +// _ksem_destroy +// _ksem_getvalue +// _ksem_init +// _ksem_open +// _ksem_post +// _ksem_trywait +// _ksem_unlink +// _ksem_wait +// _lwp_continue +// _lwp_create +// _lwp_ctl +// _lwp_detach +// _lwp_exit +// _lwp_getname +// _lwp_getprivate +// _lwp_kill +// _lwp_park +// _lwp_self +// _lwp_setname +// _lwp_setprivate +// _lwp_suspend +// _lwp_unpark +// _lwp_unpark_all +// _lwp_wait +// _lwp_wakeup +// _pset_bind +// _sched_getaffinity +// _sched_getparam +// _sched_setaffinity +// _sched_setparam +// acct +// aio_cancel +// aio_error +// aio_fsync +// aio_read +// aio_return +// aio_suspend +// aio_write +// break +// clock_getres +// clock_gettime +// clock_settime +// compat_09_ogetdomainname +// compat_09_osetdomainname +// compat_09_ouname +// compat_10_omsgsys +// compat_10_osemsys +// compat_10_oshmsys +// compat_12_fstat12 +// compat_12_getdirentries +// compat_12_lstat12 +// compat_12_msync +// compat_12_oreboot +// compat_12_oswapon +// compat_12_stat12 +// compat_13_sigaction13 +// compat_13_sigaltstack13 +// compat_13_sigpending13 +// compat_13_sigprocmask13 +// compat_13_sigreturn13 +// compat_13_sigsuspend13 +// compat_14___semctl +// compat_14_msgctl +// compat_14_shmctl +// compat_16___sigaction14 +// compat_16___sigreturn14 +// compat_20_fhstatfs +// compat_20_fstatfs +// compat_20_getfsstat +// compat_20_statfs +// compat_30___fhstat30 +// compat_30___fstat13 +// compat_30___lstat13 +// compat_30___stat13 +// compat_30_fhopen +// compat_30_fhstat +// compat_30_fhstatvfs1 +// compat_30_getdents +// compat_30_getfh +// compat_30_ntp_gettime +// compat_30_socket +// compat_40_mount +// compat_43_fstat43 +// compat_43_lstat43 +// compat_43_oaccept +// compat_43_ocreat +// compat_43_oftruncate +// compat_43_ogetdirentries +// compat_43_ogetdtablesize +// compat_43_ogethostid +// compat_43_ogethostname +// compat_43_ogetkerninfo +// compat_43_ogetpagesize +// compat_43_ogetpeername +// compat_43_ogetrlimit +// compat_43_ogetsockname +// compat_43_okillpg +// compat_43_olseek +// compat_43_ommap +// compat_43_oquota +// compat_43_orecv +// compat_43_orecvfrom +// compat_43_orecvmsg +// compat_43_osend +// compat_43_osendmsg +// compat_43_osethostid +// compat_43_osethostname +// compat_43_osetrlimit +// compat_43_osigblock +// compat_43_osigsetmask +// compat_43_osigstack +// compat_43_osigvec +// compat_43_otruncate +// compat_43_owait +// compat_43_stat43 +// execve +// extattr_delete_fd +// extattr_delete_file +// extattr_delete_link +// extattr_get_fd +// extattr_get_file +// extattr_get_link +// extattr_list_fd +// extattr_list_file +// extattr_list_link +// extattr_set_fd +// extattr_set_file +// extattr_set_link +// extattrctl +// fchroot +// fdatasync +// fgetxattr +// fktrace +// flistxattr +// fork +// fremovexattr +// fsetxattr +// fstatvfs1 +// fsync_range +// getcontext +// getitimer +// getvfsstat +// getxattr +// ioctl +// ktrace +// lchflags +// lchmod +// lfs_bmapv +// lfs_markv +// lfs_segclean +// lfs_segwait +// lgetxattr +// lio_listio +// listxattr +// llistxattr +// lremovexattr +// lseek +// lsetxattr +// lutimes +// madvise +// mincore +// minherit +// modctl +// mq_close +// mq_getattr +// mq_notify +// mq_open +// mq_receive +// mq_send +// mq_setattr +// mq_timedreceive +// mq_timedsend +// mq_unlink +// mremap +// msgget +// msgrcv +// msgsnd +// nfssvc +// ntp_adjtime +// pmc_control +// pmc_get_info +// poll +// pollts +// preadv +// profil +// pselect +// pset_assign +// pset_create +// pset_destroy +// ptrace +// pwritev +// quotactl +// rasctl +// readv +// reboot +// removexattr +// sa_enable +// sa_preempt +// sa_register +// sa_setconcurrency +// sa_stacks +// sa_yield +// sbrk +// sched_yield +// semconfig +// semget +// semop +// setcontext +// setitimer +// setxattr +// shmat +// shmdt +// shmget +// sstk +// statvfs1 +// swapctl +// sysarch +// syscall +// timer_create +// timer_delete +// timer_getoverrun +// timer_gettime +// timer_settime +// undelete +// utrace +// uuidgen +// vadvise +// vfork +// writev diff --git a/vendor/golang.org/x/sys/unix/syscall_netbsd_386.go b/vendor/golang.org/x/sys/unix/syscall_netbsd_386.go new file mode 100644 index 0000000000..afaca09838 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_netbsd_386.go @@ -0,0 +1,42 @@ +// 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 386,netbsd + +package unix + +func Getpagesize() int { return 4096 } + +func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = int64(nsec / 1e9) + ts.Nsec = int32(nsec % 1e9) + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Usec = int32(nsec % 1e9 / 1e3) + tv.Sec = int64(nsec / 1e9) + return +} + +func SetKevent(k *Kevent_t, fd, mode, flags int) { + k.Ident = uint32(fd) + k.Filter = uint32(mode) + k.Flags = uint32(flags) +} + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint32(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint32(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint32(length) +} diff --git a/vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go new file mode 100644 index 0000000000..a6ff04ce5b --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go @@ -0,0 +1,42 @@ +// 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 amd64,netbsd + +package unix + +func Getpagesize() int { return 4096 } + +func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = int64(nsec / 1e9) + ts.Nsec = int64(nsec % 1e9) + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Usec = int32(nsec % 1e9 / 1e3) + tv.Sec = int64(nsec / 1e9) + return +} + +func SetKevent(k *Kevent_t, fd, mode, flags int) { + k.Ident = uint64(fd) + k.Filter = uint32(mode) + k.Flags = uint32(flags) +} + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint64(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint32(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint32(length) +} diff --git a/vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go b/vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go new file mode 100644 index 0000000000..68a6969b28 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go @@ -0,0 +1,42 @@ +// 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 arm,netbsd + +package unix + +func Getpagesize() int { return 4096 } + +func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = int64(nsec / 1e9) + ts.Nsec = int32(nsec % 1e9) + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Usec = int32(nsec % 1e9 / 1e3) + tv.Sec = int64(nsec / 1e9) + return +} + +func SetKevent(k *Kevent_t, fd, mode, flags int) { + k.Ident = uint32(fd) + k.Filter = uint32(mode) + k.Flags = uint32(flags) +} + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint32(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint32(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint32(length) +} diff --git a/vendor/golang.org/x/sys/unix/syscall_no_getwd.go b/vendor/golang.org/x/sys/unix/syscall_no_getwd.go new file mode 100644 index 0000000000..530792ea93 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_no_getwd.go @@ -0,0 +1,11 @@ +// 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 dragonfly freebsd netbsd openbsd + +package unix + +const ImplementsGetwd = false + +func Getwd() (string, error) { return "", ENOTSUP } diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd.go b/vendor/golang.org/x/sys/unix/syscall_openbsd.go new file mode 100644 index 0000000000..246131d2af --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd.go @@ -0,0 +1,303 @@ +// Copyright 2009,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. + +// OpenBSD system calls. +// This file is compiled as ordinary Go code, +// but it is also input to mksyscall, +// which parses the //sys lines and generates system call stubs. +// Note that sometimes we use a lowercase //sys name and wrap +// it in our own nicer implementation, either here or in +// syscall_bsd.go or syscall_unix.go. + +package unix + +import ( + "syscall" + "unsafe" +) + +type SockaddrDatalink struct { + Len uint8 + Family uint8 + Index uint16 + Type uint8 + Nlen uint8 + Alen uint8 + Slen uint8 + Data [24]int8 + raw RawSockaddrDatalink +} + +func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) + +func nametomib(name string) (mib []_C_int, err error) { + + // Perform lookup via a binary search + left := 0 + right := len(sysctlMib) - 1 + for { + idx := left + (right-left)/2 + switch { + case name == sysctlMib[idx].ctlname: + return sysctlMib[idx].ctloid, nil + case name > sysctlMib[idx].ctlname: + left = idx + 1 + default: + right = idx - 1 + } + if left > right { + break + } + } + return nil, EINVAL +} + +// ParseDirent parses up to max directory entries in buf, +// appending the names to names. It returns the number +// 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) + for max != 0 && len(buf) > 0 { + dirent := (*Dirent)(unsafe.Pointer(&buf[0])) + if dirent.Reclen == 0 { + buf = nil + break + } + buf = buf[dirent.Reclen:] + if dirent.Fileno == 0 { // File absent in directory. + continue + } + bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0])) + var name = string(bytes[0:dirent.Namlen]) + if name == "." || name == ".." { // Useless names + continue + } + max-- + count++ + names = append(names, name) + } + return origlen - len(buf), count, names +} + +//sysnb pipe(p *[2]_C_int) (err error) +func Pipe(p []int) (err error) { + if len(p) != 2 { + return EINVAL + } + var pp [2]_C_int + err = pipe(&pp) + p[0] = int(pp[0]) + p[1] = int(pp[1]) + return +} + +//sys getdents(fd int, buf []byte) (n int, err error) +func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { + return getdents(fd, buf) +} + +// TODO +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + return -1, ENOSYS +} + +func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { + var _p0 unsafe.Pointer + var bufsize uintptr + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf)) + } + r0, _, e1 := Syscall(SYS_GETFSSTAT, uintptr(_p0), bufsize, uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +/* + * Exposed directly + */ +//sys Access(path string, mode uint32) (err error) +//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error) +//sys Chdir(path string) (err error) +//sys Chflags(path string, flags int) (err error) +//sys Chmod(path string, mode uint32) (err error) +//sys Chown(path string, uid int, gid int) (err error) +//sys Chroot(path string) (err error) +//sys Close(fd int) (err error) +//sys Dup(fd int) (nfd int, err error) +//sys Dup2(from int, to int) (err error) +//sys Exit(code int) +//sys Fchdir(fd int) (err error) +//sys Fchflags(fd int, flags int) (err error) +//sys Fchmod(fd int, mode uint32) (err error) +//sys Fchown(fd int, uid int, gid int) (err error) +//sys Flock(fd int, how int) (err error) +//sys Fpathconf(fd int, name int) (val int, err error) +//sys Fstat(fd int, stat *Stat_t) (err error) +//sys Fstatfs(fd int, stat *Statfs_t) (err error) +//sys Fsync(fd int) (err error) +//sys Ftruncate(fd int, length int64) (err error) +//sysnb Getegid() (egid int) +//sysnb Geteuid() (uid int) +//sysnb Getgid() (gid int) +//sysnb Getpgid(pid int) (pgid int, err error) +//sysnb Getpgrp() (pgrp int) +//sysnb Getpid() (pid int) +//sysnb Getppid() (ppid int) +//sys Getpriority(which int, who int) (prio int, err error) +//sysnb Getrlimit(which int, lim *Rlimit) (err error) +//sysnb Getrusage(who int, rusage *Rusage) (err error) +//sysnb Getsid(pid int) (sid int, err error) +//sysnb Gettimeofday(tv *Timeval) (err error) +//sysnb Getuid() (uid int) +//sys Issetugid() (tainted bool) +//sys Kill(pid int, signum syscall.Signal) (err error) +//sys Kqueue() (fd int, err error) +//sys Lchown(path string, uid int, gid int) (err error) +//sys Link(path string, link string) (err error) +//sys Listen(s int, backlog int) (err error) +//sys Lstat(path string, stat *Stat_t) (err error) +//sys Mkdir(path string, mode uint32) (err error) +//sys Mkfifo(path string, mode uint32) (err error) +//sys Mknod(path string, mode uint32, dev int) (err error) +//sys Mlock(b []byte) (err error) +//sys Mlockall(flags int) (err error) +//sys Mprotect(b []byte, prot int) (err error) +//sys Munlock(b []byte) (err error) +//sys Munlockall() (err error) +//sys Nanosleep(time *Timespec, leftover *Timespec) (err error) +//sys Open(path string, mode int, perm uint32) (fd int, err error) +//sys Pathconf(path string, name int) (val int, err error) +//sys Pread(fd int, p []byte, offset int64) (n int, err error) +//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) +//sys read(fd int, p []byte) (n int, err error) +//sys Readlink(path string, buf []byte) (n int, err error) +//sys Rename(from string, to string) (err error) +//sys Revoke(path string) (err error) +//sys Rmdir(path string) (err error) +//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK +//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) +//sysnb Setegid(egid int) (err error) +//sysnb Seteuid(euid int) (err error) +//sysnb Setgid(gid int) (err error) +//sys Setlogin(name string) (err error) +//sysnb Setpgid(pid int, pgid int) (err error) +//sys Setpriority(which int, who int, prio int) (err error) +//sysnb Setregid(rgid int, egid int) (err error) +//sysnb Setreuid(ruid int, euid int) (err error) +//sysnb Setresgid(rgid int, egid int, sgid int) (err error) +//sysnb Setresuid(ruid int, euid int, suid int) (err error) +//sysnb Setrlimit(which int, lim *Rlimit) (err error) +//sysnb Setsid() (pid int, err error) +//sysnb Settimeofday(tp *Timeval) (err error) +//sysnb Setuid(uid int) (err error) +//sys Stat(path string, stat *Stat_t) (err error) +//sys Statfs(path string, stat *Statfs_t) (err error) +//sys Symlink(path string, link string) (err error) +//sys Sync() (err error) +//sys Truncate(path string, length int64) (err error) +//sys Umask(newmask int) (oldmask int) +//sys Unlink(path string) (err error) +//sys Unmount(path string, flags int) (err error) +//sys write(fd int, p []byte) (n int, err error) +//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) +//sys munmap(addr uintptr, length uintptr) (err error) +//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ +//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE + +/* + * Unimplemented + */ +// __getcwd +// __semctl +// __syscall +// __sysctl +// adjfreq +// break +// clock_getres +// clock_gettime +// clock_settime +// closefrom +// execve +// faccessat +// fchmodat +// fchownat +// fcntl +// fhopen +// fhstat +// fhstatfs +// fork +// fstatat +// futimens +// getfh +// getgid +// getitimer +// getlogin +// getresgid +// getresuid +// getrtable +// getthrid +// ioctl +// ktrace +// lfs_bmapv +// lfs_markv +// lfs_segclean +// lfs_segwait +// linkat +// mincore +// minherit +// mkdirat +// mkfifoat +// mknodat +// mount +// mquery +// msgctl +// msgget +// msgrcv +// msgsnd +// nfssvc +// nnpfspioctl +// openat +// poll +// preadv +// profil +// pwritev +// quotactl +// readlinkat +// readv +// reboot +// renameat +// rfork +// sched_yield +// semget +// semop +// setgroups +// setitimer +// setrtable +// setsockopt +// shmat +// shmctl +// shmdt +// shmget +// sigaction +// sigaltstack +// sigpending +// sigprocmask +// sigreturn +// sigsuspend +// symlinkat +// sysarch +// syscall +// threxit +// thrsigdivert +// thrsleep +// thrwakeup +// unlinkat +// utimensat +// vfork +// writev diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd_386.go b/vendor/golang.org/x/sys/unix/syscall_openbsd_386.go new file mode 100644 index 0000000000..a66ddc59ce --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd_386.go @@ -0,0 +1,42 @@ +// 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 386,openbsd + +package unix + +func Getpagesize() int { return 4096 } + +func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = int64(nsec / 1e9) + ts.Nsec = int32(nsec % 1e9) + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Usec = int32(nsec % 1e9 / 1e3) + tv.Sec = int64(nsec / 1e9) + return +} + +func SetKevent(k *Kevent_t, fd, mode, flags int) { + k.Ident = uint32(fd) + k.Filter = int16(mode) + k.Flags = uint16(flags) +} + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint32(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint32(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint32(length) +} diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go new file mode 100644 index 0000000000..0776c1faf9 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go @@ -0,0 +1,42 @@ +// 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 amd64,openbsd + +package unix + +func Getpagesize() int { return 4096 } + +func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = nsec / 1e9 + ts.Nsec = nsec % 1e9 + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Usec = nsec % 1e9 / 1e3 + tv.Sec = nsec / 1e9 + return +} + +func SetKevent(k *Kevent_t, fd, mode, flags int) { + k.Ident = uint64(fd) + k.Filter = int16(mode) + k.Flags = uint16(flags) +} + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint64(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint32(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint32(length) +} diff --git a/vendor/golang.org/x/sys/unix/syscall_solaris.go b/vendor/golang.org/x/sys/unix/syscall_solaris.go new file mode 100644 index 0000000000..eb489b159f --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_solaris.go @@ -0,0 +1,713 @@ +// 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. + +// Solaris system calls. +// This file is compiled as ordinary Go code, +// but it is also input to mksyscall, +// which parses the //sys lines and generates system call stubs. +// Note that sometimes we use a lowercase //sys name and wrap +// it in our own nicer implementation, either here or in +// syscall_solaris.go or syscall_unix.go. + +package unix + +import ( + "sync/atomic" + "syscall" + "unsafe" +) + +// Implemented in runtime/syscall_solaris.go. +type syscallFunc uintptr + +func rawSysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) +func sysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) + +type SockaddrDatalink struct { + Family uint16 + Index uint16 + Type uint8 + Nlen uint8 + Alen uint8 + Slen uint8 + Data [244]int8 + raw RawSockaddrDatalink +} + +func clen(n []byte) int { + for i := 0; i < len(n); i++ { + if n[i] == 0 { + return i + } + } + return len(n) +} + +// ParseDirent parses up to max directory entries in buf, +// appending the names to names. It returns the number +// 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) + for max != 0 && len(buf) > 0 { + dirent := (*Dirent)(unsafe.Pointer(&buf[0])) + if dirent.Reclen == 0 { + buf = nil + break + } + buf = buf[dirent.Reclen:] + if dirent.Ino == 0 { // File absent in directory. + continue + } + bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0])) + var name = string(bytes[0:clen(bytes[:])]) + if name == "." || name == ".." { // Useless names + continue + } + max-- + count++ + names = append(names, name) + } + return origlen - len(buf), count, names +} + +func pipe() (r uintptr, w uintptr, err uintptr) + +func Pipe(p []int) (err error) { + if len(p) != 2 { + return EINVAL + } + r0, w0, e1 := pipe() + if e1 != 0 { + err = syscall.Errno(e1) + } + p[0], p[1] = int(r0), int(w0) + return +} + +func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) { + if sa.Port < 0 || sa.Port > 0xFFFF { + return nil, 0, EINVAL + } + sa.raw.Family = AF_INET + p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) + p[0] = byte(sa.Port >> 8) + p[1] = byte(sa.Port) + for i := 0; i < len(sa.Addr); i++ { + sa.raw.Addr[i] = sa.Addr[i] + } + return unsafe.Pointer(&sa.raw), SizeofSockaddrInet4, nil +} + +func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) { + if sa.Port < 0 || sa.Port > 0xFFFF { + return nil, 0, EINVAL + } + sa.raw.Family = AF_INET6 + p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) + p[0] = byte(sa.Port >> 8) + p[1] = byte(sa.Port) + sa.raw.Scope_id = sa.ZoneId + for i := 0; i < len(sa.Addr); i++ { + sa.raw.Addr[i] = sa.Addr[i] + } + return unsafe.Pointer(&sa.raw), SizeofSockaddrInet6, nil +} + +func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) { + name := sa.Name + n := len(name) + if n >= len(sa.raw.Path) { + return nil, 0, EINVAL + } + sa.raw.Family = AF_UNIX + for i := 0; i < n; i++ { + sa.raw.Path[i] = int8(name[i]) + } + // length is family (uint16), name, NUL. + sl := _Socklen(2) + if n > 0 { + sl += _Socklen(n) + 1 + } + if sa.raw.Path[0] == '@' { + sa.raw.Path[0] = 0 + // Don't count trailing NUL for abstract address. + sl-- + } + + return unsafe.Pointer(&sa.raw), sl, nil +} + +//sys getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) = libsocket.getsockname + +func Getsockname(fd int) (sa Sockaddr, err error) { + var rsa RawSockaddrAny + var len _Socklen = SizeofSockaddrAny + if err = getsockname(fd, &rsa, &len); err != nil { + return + } + return anyToSockaddr(&rsa) +} + +const ImplementsGetwd = true + +//sys Getcwd(buf []byte) (n int, err error) + +func Getwd() (wd string, err error) { + var buf [PathMax]byte + // Getcwd will return an error if it failed for any reason. + _, err = Getcwd(buf[0:]) + if err != nil { + return "", err + } + n := clen(buf[:]) + if n < 1 { + return "", EINVAL + } + return string(buf[:n]), nil +} + +/* + * Wrapped + */ + +//sysnb getgroups(ngid int, gid *_Gid_t) (n int, err error) +//sysnb setgroups(ngid int, gid *_Gid_t) (err error) + +func Getgroups() (gids []int, err error) { + n, err := getgroups(0, nil) + // Check for error and sanity check group count. Newer versions of + // Solaris allow up to 1024 (NGROUPS_MAX). + if n < 0 || n > 1024 { + if err != nil { + return nil, err + } + return nil, EINVAL + } else if n == 0 { + return nil, nil + } + + a := make([]_Gid_t, n) + n, err = getgroups(n, &a[0]) + if n == -1 { + return nil, err + } + gids = make([]int, n) + for i, v := range a[0:n] { + gids[i] = int(v) + } + return +} + +func Setgroups(gids []int) (err error) { + if len(gids) == 0 { + return setgroups(0, nil) + } + + a := make([]_Gid_t, len(gids)) + for i, v := range gids { + a[i] = _Gid_t(v) + } + return setgroups(len(a), &a[0]) +} + +func ReadDirent(fd int, buf []byte) (n int, err error) { + // Final argument is (basep *uintptr) and the syscall doesn't take nil. + // TODO(rsc): Can we use a single global basep for all calls? + return Getdents(fd, buf, new(uintptr)) +} + +// Wait status is 7 bits at bottom, either 0 (exited), +// 0x7F (stopped), or a signal number that caused an exit. +// The 0x80 bit is whether there was a core dump. +// An extra number (exit code, signal causing a stop) +// is in the high bits. + +type WaitStatus uint32 + +const ( + mask = 0x7F + core = 0x80 + shift = 8 + + exited = 0 + stopped = 0x7F +) + +func (w WaitStatus) Exited() bool { return w&mask == exited } + +func (w WaitStatus) ExitStatus() int { + if w&mask != exited { + return -1 + } + return int(w >> shift) +} + +func (w WaitStatus) Signaled() bool { return w&mask != stopped && w&mask != 0 } + +func (w WaitStatus) Signal() syscall.Signal { + sig := syscall.Signal(w & mask) + if sig == stopped || sig == 0 { + return -1 + } + return sig +} + +func (w WaitStatus) CoreDump() bool { return w.Signaled() && w&core != 0 } + +func (w WaitStatus) Stopped() bool { return w&mask == stopped && syscall.Signal(w>>shift) != SIGSTOP } + +func (w WaitStatus) Continued() bool { return w&mask == stopped && syscall.Signal(w>>shift) == SIGSTOP } + +func (w WaitStatus) StopSignal() syscall.Signal { + if !w.Stopped() { + return -1 + } + return syscall.Signal(w>>shift) & 0xFF +} + +func (w WaitStatus) TrapCause() int { return -1 } + +func wait4(pid uintptr, wstatus *WaitStatus, options uintptr, rusage *Rusage) (wpid uintptr, err uintptr) + +func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) { + r0, e1 := wait4(uintptr(pid), wstatus, uintptr(options), rusage) + if e1 != 0 { + err = syscall.Errno(e1) + } + return int(r0), err +} + +func gethostname() (name string, err uintptr) + +func Gethostname() (name string, err error) { + name, e1 := gethostname() + if e1 != 0 { + err = syscall.Errno(e1) + } + return name, err +} + +//sys utimes(path string, times *[2]Timeval) (err error) + +func Utimes(path string, tv []Timeval) (err error) { + if tv == nil { + return utimes(path, nil) + } + if len(tv) != 2 { + return EINVAL + } + return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) +} + +//sys utimensat(fd int, path string, times *[2]Timespec, flag int) (err error) + +func UtimesNano(path string, ts []Timespec) error { + if ts == nil { + return utimensat(AT_FDCWD, path, nil, 0) + } + if len(ts) != 2 { + return EINVAL + } + return utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) +} + +func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) error { + if ts == nil { + return utimensat(dirfd, path, nil, flags) + } + if len(ts) != 2 { + return EINVAL + } + return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), flags) +} + +//sys fcntl(fd int, cmd int, arg int) (val int, err error) + +// 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 { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procfcntl)), 3, uintptr(fd), uintptr(cmd), uintptr(unsafe.Pointer(lk)), 0, 0, 0) + if e1 != 0 { + return e1 + } + return nil +} + +//sys futimesat(fildes int, path *byte, times *[2]Timeval) (err error) + +func Futimesat(dirfd int, path string, tv []Timeval) error { + pathp, err := BytePtrFromString(path) + if err != nil { + return err + } + if tv == nil { + return futimesat(dirfd, pathp, nil) + } + if len(tv) != 2 { + return EINVAL + } + return futimesat(dirfd, pathp, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) +} + +// Solaris doesn't have an futimes function because it allows NULL to be +// specified as the path for futimesat. However, Go doesn't like +// NULL-style string interfaces, so this simple wrapper is provided. +func Futimes(fd int, tv []Timeval) error { + if tv == nil { + return futimesat(fd, nil, nil) + } + if len(tv) != 2 { + return EINVAL + } + return futimesat(fd, nil, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) +} + +func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) { + switch rsa.Addr.Family { + case AF_UNIX: + pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa)) + sa := new(SockaddrUnix) + // Assume path ends at NUL. + // This is not technically the Solaris semantics for + // abstract Unix domain sockets -- they are supposed + // to be uninterpreted fixed-size binary blobs -- but + // everyone uses this convention. + n := 0 + for n < len(pp.Path) && pp.Path[n] != 0 { + n++ + } + bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n] + sa.Name = string(bytes) + return sa, nil + + case AF_INET: + pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa)) + sa := new(SockaddrInet4) + p := (*[2]byte)(unsafe.Pointer(&pp.Port)) + sa.Port = int(p[0])<<8 + int(p[1]) + for i := 0; i < len(sa.Addr); i++ { + sa.Addr[i] = pp.Addr[i] + } + return sa, nil + + case AF_INET6: + pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa)) + sa := new(SockaddrInet6) + p := (*[2]byte)(unsafe.Pointer(&pp.Port)) + sa.Port = int(p[0])<<8 + int(p[1]) + sa.ZoneId = pp.Scope_id + for i := 0; i < len(sa.Addr); i++ { + sa.Addr[i] = pp.Addr[i] + } + return sa, nil + } + return nil, EAFNOSUPPORT +} + +//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) = libsocket.accept + +func Accept(fd int) (nfd int, sa Sockaddr, err error) { + var rsa RawSockaddrAny + var len _Socklen = SizeofSockaddrAny + nfd, err = accept(fd, &rsa, &len) + if nfd == -1 { + return + } + sa, err = anyToSockaddr(&rsa) + if err != nil { + Close(nfd) + nfd = 0 + } + return +} + +//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) = libsocket.recvmsg + +func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) { + var msg Msghdr + var rsa RawSockaddrAny + msg.Name = (*byte)(unsafe.Pointer(&rsa)) + msg.Namelen = uint32(SizeofSockaddrAny) + var iov Iovec + if len(p) > 0 { + iov.Base = (*int8)(unsafe.Pointer(&p[0])) + iov.SetLen(len(p)) + } + var dummy int8 + if len(oob) > 0 { + // receive at least one normal byte + if len(p) == 0 { + iov.Base = &dummy + iov.SetLen(1) + } + msg.Accrights = (*int8)(unsafe.Pointer(&oob[0])) + } + msg.Iov = &iov + msg.Iovlen = 1 + if n, err = recvmsg(fd, &msg, flags); n == -1 { + return + } + oobn = int(msg.Accrightslen) + // source address is only specified if the socket is unconnected + if rsa.Addr.Family != AF_UNSPEC { + from, err = anyToSockaddr(&rsa) + } + return +} + +func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) { + _, err = SendmsgN(fd, p, oob, to, flags) + return +} + +//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) = libsocket.sendmsg + +func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) { + var ptr unsafe.Pointer + var salen _Socklen + if to != nil { + ptr, salen, err = to.sockaddr() + if err != nil { + return 0, err + } + } + var msg Msghdr + msg.Name = (*byte)(unsafe.Pointer(ptr)) + msg.Namelen = uint32(salen) + var iov Iovec + if len(p) > 0 { + iov.Base = (*int8)(unsafe.Pointer(&p[0])) + iov.SetLen(len(p)) + } + var dummy int8 + if len(oob) > 0 { + // send at least one normal byte + if len(p) == 0 { + iov.Base = &dummy + iov.SetLen(1) + } + msg.Accrights = (*int8)(unsafe.Pointer(&oob[0])) + } + msg.Iov = &iov + msg.Iovlen = 1 + if n, err = sendmsg(fd, &msg, flags); err != nil { + return 0, err + } + if len(oob) > 0 && len(p) == 0 { + n = 0 + } + return n, nil +} + +//sys acct(path *byte) (err error) + +func Acct(path string) (err error) { + if len(path) == 0 { + // Assume caller wants to disable accounting. + return acct(nil) + } + + pathp, err := BytePtrFromString(path) + if err != nil { + return err + } + return acct(pathp) +} + +/* + * Expose the ioctl function + */ + +//sys ioctl(fd int, req int, arg uintptr) (err error) + +func IoctlSetInt(fd int, req int, value int) (err error) { + return ioctl(fd, req, uintptr(value)) +} + +func IoctlSetWinsize(fd int, req int, value *Winsize) (err error) { + return ioctl(fd, req, uintptr(unsafe.Pointer(value))) +} + +func IoctlSetTermios(fd int, req int, value *Termios) (err error) { + return ioctl(fd, req, uintptr(unsafe.Pointer(value))) +} + +func IoctlSetTermio(fd int, req int, value *Termio) (err error) { + return ioctl(fd, req, uintptr(unsafe.Pointer(value))) +} + +func IoctlGetInt(fd int, req int) (int, error) { + var value int + err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) + return value, err +} + +func IoctlGetWinsize(fd int, req int) (*Winsize, error) { + var value Winsize + err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) + return &value, err +} + +func IoctlGetTermios(fd int, req int) (*Termios, error) { + var value Termios + err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) + return &value, err +} + +func IoctlGetTermio(fd int, req int) (*Termio, error) { + var value Termio + err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) + return &value, err +} + +/* + * Exposed directly + */ +//sys Access(path string, mode uint32) (err error) +//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error) +//sys Chdir(path string) (err error) +//sys Chmod(path string, mode uint32) (err error) +//sys Chown(path string, uid int, gid int) (err error) +//sys Chroot(path string) (err error) +//sys Close(fd int) (err error) +//sys Creat(path string, mode uint32) (fd int, err error) +//sys Dup(fd int) (nfd int, err error) +//sys Dup2(oldfd int, newfd int) (err error) +//sys Exit(code int) +//sys Fchdir(fd int) (err error) +//sys Fchmod(fd int, mode uint32) (err error) +//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) +//sys Fchown(fd int, uid int, gid int) (err error) +//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) +//sys Fdatasync(fd int) (err error) +//sys Fpathconf(fd int, name int) (val int, err error) +//sys Fstat(fd int, stat *Stat_t) (err error) +//sys Getdents(fd int, buf []byte, basep *uintptr) (n int, err error) +//sysnb Getgid() (gid int) +//sysnb Getpid() (pid int) +//sysnb Getpgid(pid int) (pgid int, err error) +//sysnb Getpgrp() (pgid int, err error) +//sys Geteuid() (euid int) +//sys Getegid() (egid int) +//sys Getppid() (ppid int) +//sys Getpriority(which int, who int) (n int, err error) +//sysnb Getrlimit(which int, lim *Rlimit) (err error) +//sysnb Getrusage(who int, rusage *Rusage) (err error) +//sysnb Gettimeofday(tv *Timeval) (err error) +//sysnb Getuid() (uid int) +//sys Kill(pid int, signum syscall.Signal) (err error) +//sys Lchown(path string, uid int, gid int) (err error) +//sys Link(path string, link string) (err error) +//sys Listen(s int, backlog int) (err error) = libsocket.listen +//sys Lstat(path string, stat *Stat_t) (err error) +//sys Madvise(b []byte, advice int) (err error) +//sys Mkdir(path string, mode uint32) (err error) +//sys Mkdirat(dirfd int, path string, mode uint32) (err error) +//sys Mkfifo(path string, mode uint32) (err error) +//sys Mkfifoat(dirfd int, path string, mode uint32) (err error) +//sys Mknod(path string, mode uint32, dev int) (err error) +//sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error) +//sys Mlock(b []byte) (err error) +//sys Mlockall(flags int) (err error) +//sys Mprotect(b []byte, prot int) (err error) +//sys Munlock(b []byte) (err error) +//sys Munlockall() (err error) +//sys Nanosleep(time *Timespec, leftover *Timespec) (err error) +//sys Open(path string, mode int, perm uint32) (fd int, err error) +//sys Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) +//sys Pathconf(path string, name int) (val int, err error) +//sys Pause() (err error) +//sys Pread(fd int, p []byte, offset int64) (n int, err error) +//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) +//sys read(fd int, p []byte) (n int, err error) +//sys Readlink(path string, buf []byte) (n int, err error) +//sys Rename(from string, to string) (err error) +//sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) +//sys Rmdir(path string) (err error) +//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = lseek +//sysnb Setegid(egid int) (err error) +//sysnb Seteuid(euid int) (err error) +//sysnb Setgid(gid int) (err error) +//sys Sethostname(p []byte) (err error) +//sysnb Setpgid(pid int, pgid int) (err error) +//sys Setpriority(which int, who int, prio int) (err error) +//sysnb Setregid(rgid int, egid int) (err error) +//sysnb Setreuid(ruid int, euid int) (err error) +//sysnb Setrlimit(which int, lim *Rlimit) (err error) +//sysnb Setsid() (pid int, err error) +//sysnb Setuid(uid int) (err error) +//sys Shutdown(s int, how int) (err error) = libsocket.shutdown +//sys Stat(path string, stat *Stat_t) (err error) +//sys Symlink(path string, link string) (err error) +//sys Sync() (err error) +//sysnb Times(tms *Tms) (ticks uintptr, err error) +//sys Truncate(path string, length int64) (err error) +//sys Fsync(fd int) (err error) +//sys Ftruncate(fd int, length int64) (err error) +//sys Umask(mask int) (oldmask int) +//sysnb Uname(buf *Utsname) (err error) +//sys Unmount(target string, flags int) (err error) = libc.umount +//sys Unlink(path string) (err error) +//sys Unlinkat(dirfd int, path string, flags int) (err error) +//sys Ustat(dev int, ubuf *Ustat_t) (err error) +//sys Utime(path string, buf *Utimbuf) (err error) +//sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.bind +//sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.connect +//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) +//sys munmap(addr uintptr, length uintptr) (err error) +//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.sendto +//sys socket(domain int, typ int, proto int) (fd int, err error) = libsocket.socket +//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) = libsocket.socketpair +//sys write(fd int, p []byte) (n int, err error) +//sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) = libsocket.getsockopt +//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) = libsocket.getpeername +//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) = libsocket.setsockopt +//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) = libsocket.recvfrom + +func readlen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procread)), 3, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf), 0, 0, 0) + n = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func writelen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procwrite)), 3, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf), 0, 0, 0) + n = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +var mapper = &mmapper{ + active: make(map[*byte][]byte), + mmap: mmap, + munmap: munmap, +} + +func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) { + return mapper.Mmap(fd, offset, length, prot, flags) +} + +func Munmap(b []byte) (err error) { + return mapper.Munmap(b) +} + +//sys sysconf(name int) (n int64, err error) + +// pageSize caches the value of Getpagesize, since it can't change +// once the system is booted. +var pageSize int64 // accessed atomically + +func Getpagesize() int { + n := atomic.LoadInt64(&pageSize) + if n == 0 { + n, _ = sysconf(_SC_PAGESIZE) + atomic.StoreInt64(&pageSize, n) + } + return int(n) +} diff --git a/vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go b/vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go new file mode 100644 index 0000000000..5aff62c3bb --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go @@ -0,0 +1,35 @@ +// 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 amd64,solaris + +package unix + +func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } + +func NsecToTimespec(nsec int64) (ts Timespec) { + ts.Sec = nsec / 1e9 + ts.Nsec = nsec % 1e9 + return +} + +func NsecToTimeval(nsec int64) (tv Timeval) { + nsec += 999 // round up to microsecond + tv.Usec = nsec % 1e9 / 1e3 + tv.Sec = int64(nsec / 1e9) + return +} + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint64(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint32(length) +} + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + // TODO(aram): implement this, see issue 5847. + panic("unimplemented") +} diff --git a/vendor/golang.org/x/sys/unix/syscall_unix.go b/vendor/golang.org/x/sys/unix/syscall_unix.go new file mode 100644 index 0000000000..b46b25028c --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_unix.go @@ -0,0 +1,297 @@ +// 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 + +import ( + "runtime" + "sync" + "syscall" + "unsafe" +) + +var ( + Stdin = 0 + Stdout = 1 + Stderr = 2 +) + +const ( + darwin64Bit = runtime.GOOS == "darwin" && sizeofPtr == 8 + dragonfly64Bit = runtime.GOOS == "dragonfly" && sizeofPtr == 8 + netbsd32Bit = runtime.GOOS == "netbsd" && sizeofPtr == 4 +) + +// Do the interface allocations only once for common +// Errno values. +var ( + errEAGAIN error = syscall.EAGAIN + errEINVAL error = syscall.EINVAL + errENOENT error = syscall.ENOENT +) + +// errnoErr returns common boxed Errno values, to prevent +// allocations at runtime. +func errnoErr(e syscall.Errno) error { + switch e { + case 0: + return nil + case EAGAIN: + return errEAGAIN + case EINVAL: + return errEINVAL + case ENOENT: + return errENOENT + } + return e +} + +func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) +func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) +func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) +func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) + +// Mmap manager, for use by operating system-specific implementations. + +type mmapper struct { + sync.Mutex + active map[*byte][]byte // active mappings; key is last byte in mapping + mmap func(addr, length uintptr, prot, flags, fd int, offset int64) (uintptr, error) + munmap func(addr uintptr, length uintptr) error +} + +func (m *mmapper) Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) { + if length <= 0 { + return nil, EINVAL + } + + // Map the requested memory. + addr, errno := m.mmap(0, uintptr(length), prot, flags, fd, offset) + if errno != nil { + return nil, errno + } + + // Slice memory layout + var sl = struct { + addr uintptr + len int + cap int + }{addr, length, length} + + // Use unsafe to turn sl into a []byte. + b := *(*[]byte)(unsafe.Pointer(&sl)) + + // Register mapping in m and return it. + p := &b[cap(b)-1] + m.Lock() + defer m.Unlock() + m.active[p] = b + return b, nil +} + +func (m *mmapper) Munmap(data []byte) (err error) { + if len(data) == 0 || len(data) != cap(data) { + return EINVAL + } + + // Find the base of the mapping. + p := &data[cap(data)-1] + m.Lock() + defer m.Unlock() + b := m.active[p] + if b == nil || &b[0] != &data[0] { + return EINVAL + } + + // Unmap the memory and update m. + if errno := m.munmap(uintptr(unsafe.Pointer(&b[0])), uintptr(len(b))); errno != nil { + return errno + } + delete(m.active, p) + return nil +} + +func Read(fd int, p []byte) (n int, err error) { + n, err = read(fd, p) + if raceenabled { + if n > 0 { + raceWriteRange(unsafe.Pointer(&p[0]), n) + } + if err == nil { + raceAcquire(unsafe.Pointer(&ioSync)) + } + } + return +} + +func Write(fd int, p []byte) (n int, err error) { + if raceenabled { + raceReleaseMerge(unsafe.Pointer(&ioSync)) + } + n, err = write(fd, p) + if raceenabled && n > 0 { + raceReadRange(unsafe.Pointer(&p[0]), n) + } + return +} + +// For testing: clients can set this flag to force +// creation of IPv6 sockets to return EAFNOSUPPORT. +var SocketDisableIPv6 bool + +type Sockaddr interface { + sockaddr() (ptr unsafe.Pointer, len _Socklen, err error) // lowercase; only we can define Sockaddrs +} + +type SockaddrInet4 struct { + Port int + Addr [4]byte + raw RawSockaddrInet4 +} + +type SockaddrInet6 struct { + Port int + ZoneId uint32 + Addr [16]byte + raw RawSockaddrInet6 +} + +type SockaddrUnix struct { + Name string + raw RawSockaddrUnix +} + +func Bind(fd int, sa Sockaddr) (err error) { + ptr, n, err := sa.sockaddr() + if err != nil { + return err + } + return bind(fd, ptr, n) +} + +func Connect(fd int, sa Sockaddr) (err error) { + ptr, n, err := sa.sockaddr() + if err != nil { + return err + } + return connect(fd, ptr, n) +} + +func Getpeername(fd int) (sa Sockaddr, err error) { + var rsa RawSockaddrAny + var len _Socklen = SizeofSockaddrAny + if err = getpeername(fd, &rsa, &len); err != nil { + return + } + return anyToSockaddr(&rsa) +} + +func GetsockoptInt(fd, level, opt int) (value int, err error) { + var n int32 + vallen := _Socklen(4) + err = getsockopt(fd, level, opt, unsafe.Pointer(&n), &vallen) + return int(n), err +} + +func Recvfrom(fd int, p []byte, flags int) (n int, from Sockaddr, err error) { + var rsa RawSockaddrAny + var len _Socklen = SizeofSockaddrAny + if n, err = recvfrom(fd, p, flags, &rsa, &len); err != nil { + return + } + if rsa.Addr.Family != AF_UNSPEC { + from, err = anyToSockaddr(&rsa) + } + return +} + +func Sendto(fd int, p []byte, flags int, to Sockaddr) (err error) { + ptr, n, err := to.sockaddr() + if err != nil { + return err + } + return sendto(fd, p, flags, ptr, n) +} + +func SetsockoptByte(fd, level, opt int, value byte) (err error) { + return setsockopt(fd, level, opt, unsafe.Pointer(&value), 1) +} + +func SetsockoptInt(fd, level, opt int, value int) (err error) { + var n = int32(value) + return setsockopt(fd, level, opt, unsafe.Pointer(&n), 4) +} + +func SetsockoptInet4Addr(fd, level, opt int, value [4]byte) (err error) { + return setsockopt(fd, level, opt, unsafe.Pointer(&value[0]), 4) +} + +func SetsockoptIPMreq(fd, level, opt int, mreq *IPMreq) (err error) { + return setsockopt(fd, level, opt, unsafe.Pointer(mreq), SizeofIPMreq) +} + +func SetsockoptIPv6Mreq(fd, level, opt int, mreq *IPv6Mreq) (err error) { + return setsockopt(fd, level, opt, unsafe.Pointer(mreq), SizeofIPv6Mreq) +} + +func SetsockoptICMPv6Filter(fd, level, opt int, filter *ICMPv6Filter) error { + return setsockopt(fd, level, opt, unsafe.Pointer(filter), SizeofICMPv6Filter) +} + +func SetsockoptLinger(fd, level, opt int, l *Linger) (err error) { + return setsockopt(fd, level, opt, unsafe.Pointer(l), SizeofLinger) +} + +func SetsockoptString(fd, level, opt int, s string) (err error) { + return setsockopt(fd, level, opt, unsafe.Pointer(&[]byte(s)[0]), uintptr(len(s))) +} + +func SetsockoptTimeval(fd, level, opt int, tv *Timeval) (err error) { + return setsockopt(fd, level, opt, unsafe.Pointer(tv), unsafe.Sizeof(*tv)) +} + +func Socket(domain, typ, proto int) (fd int, err error) { + if domain == AF_INET6 && SocketDisableIPv6 { + return -1, EAFNOSUPPORT + } + fd, err = socket(domain, typ, proto) + return +} + +func Socketpair(domain, typ, proto int) (fd [2]int, err error) { + var fdx [2]int32 + err = socketpair(domain, typ, proto, &fdx) + if err == nil { + fd[0] = int(fdx[0]) + fd[1] = int(fdx[1]) + } + return +} + +func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + if raceenabled { + raceReleaseMerge(unsafe.Pointer(&ioSync)) + } + return sendfile(outfd, infd, offset, count) +} + +var ioSync int64 + +func CloseOnExec(fd int) { fcntl(fd, F_SETFD, FD_CLOEXEC) } + +func SetNonblock(fd int, nonblocking bool) (err error) { + flag, err := fcntl(fd, F_GETFL, 0) + if err != nil { + return err + } + if nonblocking { + flag |= O_NONBLOCK + } else { + flag &= ^O_NONBLOCK + } + _, err = fcntl(fd, F_SETFL, flag) + return err +} diff --git a/vendor/golang.org/x/sys/unix/types_darwin.go b/vendor/golang.org/x/sys/unix/types_darwin.go new file mode 100644 index 0000000000..1153261822 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/types_darwin.go @@ -0,0 +1,250 @@ +// 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 ignore + +/* +Input to cgo -godefs. See also mkerrors.sh and mkall.sh +*/ + +// +godefs map struct_in_addr [4]byte /* in_addr */ +// +godefs map struct_in6_addr [16]byte /* in6_addr */ + +package unix + +/* +#define __DARWIN_UNIX03 0 +#define KERNEL +#define _DARWIN_USE_64_BIT_INODE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + sizeofPtr = sizeof(void*), +}; + +union sockaddr_all { + struct sockaddr s1; // this one gets used for fields + struct sockaddr_in s2; // these pad it out + struct sockaddr_in6 s3; + struct sockaddr_un s4; + struct sockaddr_dl s5; +}; + +struct sockaddr_any { + struct sockaddr addr; + char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; +}; + +*/ +import "C" + +// Machine characteristics; for internal use. + +const ( + sizeofPtr = C.sizeofPtr + sizeofShort = C.sizeof_short + sizeofInt = C.sizeof_int + sizeofLong = C.sizeof_long + sizeofLongLong = C.sizeof_longlong +) + +// Basic types + +type ( + _C_short C.short + _C_int C.int + _C_long C.long + _C_long_long C.longlong +) + +// Time + +type Timespec C.struct_timespec + +type Timeval C.struct_timeval + +type Timeval32 C.struct_timeval32 + +// Processes + +type Rusage C.struct_rusage + +type Rlimit C.struct_rlimit + +type _Gid_t C.gid_t + +// Files + +type Stat_t C.struct_stat64 + +type Statfs_t C.struct_statfs64 + +type Flock_t C.struct_flock + +type Fstore_t C.struct_fstore + +type Radvisory_t C.struct_radvisory + +type Fbootstraptransfer_t C.struct_fbootstraptransfer + +type Log2phys_t C.struct_log2phys + +type Fsid C.struct_fsid + +type Dirent C.struct_dirent + +// Sockets + +type RawSockaddrInet4 C.struct_sockaddr_in + +type RawSockaddrInet6 C.struct_sockaddr_in6 + +type RawSockaddrUnix C.struct_sockaddr_un + +type RawSockaddrDatalink C.struct_sockaddr_dl + +type RawSockaddr C.struct_sockaddr + +type RawSockaddrAny C.struct_sockaddr_any + +type _Socklen C.socklen_t + +type Linger C.struct_linger + +type Iovec C.struct_iovec + +type IPMreq C.struct_ip_mreq + +type IPv6Mreq C.struct_ipv6_mreq + +type Msghdr C.struct_msghdr + +type Cmsghdr C.struct_cmsghdr + +type Inet4Pktinfo C.struct_in_pktinfo + +type Inet6Pktinfo C.struct_in6_pktinfo + +type IPv6MTUInfo C.struct_ip6_mtuinfo + +type ICMPv6Filter C.struct_icmp6_filter + +const ( + SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in + SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 + SizeofSockaddrAny = C.sizeof_struct_sockaddr_any + SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un + SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl + SizeofLinger = C.sizeof_struct_linger + SizeofIPMreq = C.sizeof_struct_ip_mreq + SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq + SizeofMsghdr = C.sizeof_struct_msghdr + SizeofCmsghdr = C.sizeof_struct_cmsghdr + SizeofInet4Pktinfo = C.sizeof_struct_in_pktinfo + SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo + SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo + SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter +) + +// Ptrace requests + +const ( + PTRACE_TRACEME = C.PT_TRACE_ME + PTRACE_CONT = C.PT_CONTINUE + PTRACE_KILL = C.PT_KILL +) + +// Events (kqueue, kevent) + +type Kevent_t C.struct_kevent + +// Select + +type FdSet C.fd_set + +// Routing and interface messages + +const ( + SizeofIfMsghdr = C.sizeof_struct_if_msghdr + SizeofIfData = C.sizeof_struct_if_data + SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr + SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr + SizeofIfmaMsghdr2 = C.sizeof_struct_ifma_msghdr2 + SizeofRtMsghdr = C.sizeof_struct_rt_msghdr + SizeofRtMetrics = C.sizeof_struct_rt_metrics +) + +type IfMsghdr C.struct_if_msghdr + +type IfData C.struct_if_data + +type IfaMsghdr C.struct_ifa_msghdr + +type IfmaMsghdr C.struct_ifma_msghdr + +type IfmaMsghdr2 C.struct_ifma_msghdr2 + +type RtMsghdr C.struct_rt_msghdr + +type RtMetrics C.struct_rt_metrics + +// Berkeley packet filter + +const ( + SizeofBpfVersion = C.sizeof_struct_bpf_version + SizeofBpfStat = C.sizeof_struct_bpf_stat + SizeofBpfProgram = C.sizeof_struct_bpf_program + SizeofBpfInsn = C.sizeof_struct_bpf_insn + SizeofBpfHdr = C.sizeof_struct_bpf_hdr +) + +type BpfVersion C.struct_bpf_version + +type BpfStat C.struct_bpf_stat + +type BpfProgram C.struct_bpf_program + +type BpfInsn C.struct_bpf_insn + +type BpfHdr C.struct_bpf_hdr + +// Terminal handling + +type Termios C.struct_termios + +// fchmodat-like syscalls. + +const ( + AT_FDCWD = C.AT_FDCWD + AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW +) diff --git a/vendor/golang.org/x/sys/unix/types_dragonfly.go b/vendor/golang.org/x/sys/unix/types_dragonfly.go new file mode 100644 index 0000000000..f3c971dffd --- /dev/null +++ b/vendor/golang.org/x/sys/unix/types_dragonfly.go @@ -0,0 +1,242 @@ +// 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 ignore + +/* +Input to cgo -godefs. See also mkerrors.sh and mkall.sh +*/ + +// +godefs map struct_in_addr [4]byte /* in_addr */ +// +godefs map struct_in6_addr [16]byte /* in6_addr */ + +package unix + +/* +#define KERNEL +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + sizeofPtr = sizeof(void*), +}; + +union sockaddr_all { + struct sockaddr s1; // this one gets used for fields + struct sockaddr_in s2; // these pad it out + struct sockaddr_in6 s3; + struct sockaddr_un s4; + struct sockaddr_dl s5; +}; + +struct sockaddr_any { + struct sockaddr addr; + char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; +}; + +*/ +import "C" + +// Machine characteristics; for internal use. + +const ( + sizeofPtr = C.sizeofPtr + sizeofShort = C.sizeof_short + sizeofInt = C.sizeof_int + sizeofLong = C.sizeof_long + sizeofLongLong = C.sizeof_longlong +) + +// Basic types + +type ( + _C_short C.short + _C_int C.int + _C_long C.long + _C_long_long C.longlong +) + +// Time + +type Timespec C.struct_timespec + +type Timeval C.struct_timeval + +// Processes + +type Rusage C.struct_rusage + +type Rlimit C.struct_rlimit + +type _Gid_t C.gid_t + +// Files + +const ( // Directory mode bits + S_IFMT = C.S_IFMT + S_IFIFO = C.S_IFIFO + S_IFCHR = C.S_IFCHR + S_IFDIR = C.S_IFDIR + S_IFBLK = C.S_IFBLK + S_IFREG = C.S_IFREG + S_IFLNK = C.S_IFLNK + S_IFSOCK = C.S_IFSOCK + S_ISUID = C.S_ISUID + S_ISGID = C.S_ISGID + S_ISVTX = C.S_ISVTX + S_IRUSR = C.S_IRUSR + S_IWUSR = C.S_IWUSR + S_IXUSR = C.S_IXUSR +) + +type Stat_t C.struct_stat + +type Statfs_t C.struct_statfs + +type Flock_t C.struct_flock + +type Dirent C.struct_dirent + +type Fsid C.struct_fsid + +// Sockets + +type RawSockaddrInet4 C.struct_sockaddr_in + +type RawSockaddrInet6 C.struct_sockaddr_in6 + +type RawSockaddrUnix C.struct_sockaddr_un + +type RawSockaddrDatalink C.struct_sockaddr_dl + +type RawSockaddr C.struct_sockaddr + +type RawSockaddrAny C.struct_sockaddr_any + +type _Socklen C.socklen_t + +type Linger C.struct_linger + +type Iovec C.struct_iovec + +type IPMreq C.struct_ip_mreq + +type IPv6Mreq C.struct_ipv6_mreq + +type Msghdr C.struct_msghdr + +type Cmsghdr C.struct_cmsghdr + +type Inet6Pktinfo C.struct_in6_pktinfo + +type IPv6MTUInfo C.struct_ip6_mtuinfo + +type ICMPv6Filter C.struct_icmp6_filter + +const ( + SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in + SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 + SizeofSockaddrAny = C.sizeof_struct_sockaddr_any + SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un + SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl + SizeofLinger = C.sizeof_struct_linger + SizeofIPMreq = C.sizeof_struct_ip_mreq + SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq + SizeofMsghdr = C.sizeof_struct_msghdr + SizeofCmsghdr = C.sizeof_struct_cmsghdr + SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo + SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo + SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter +) + +// Ptrace requests + +const ( + PTRACE_TRACEME = C.PT_TRACE_ME + PTRACE_CONT = C.PT_CONTINUE + PTRACE_KILL = C.PT_KILL +) + +// Events (kqueue, kevent) + +type Kevent_t C.struct_kevent + +// Select + +type FdSet C.fd_set + +// Routing and interface messages + +const ( + SizeofIfMsghdr = C.sizeof_struct_if_msghdr + SizeofIfData = C.sizeof_struct_if_data + SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr + SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr + SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr + SizeofRtMsghdr = C.sizeof_struct_rt_msghdr + SizeofRtMetrics = C.sizeof_struct_rt_metrics +) + +type IfMsghdr C.struct_if_msghdr + +type IfData C.struct_if_data + +type IfaMsghdr C.struct_ifa_msghdr + +type IfmaMsghdr C.struct_ifma_msghdr + +type IfAnnounceMsghdr C.struct_if_announcemsghdr + +type RtMsghdr C.struct_rt_msghdr + +type RtMetrics C.struct_rt_metrics + +// Berkeley packet filter + +const ( + SizeofBpfVersion = C.sizeof_struct_bpf_version + SizeofBpfStat = C.sizeof_struct_bpf_stat + SizeofBpfProgram = C.sizeof_struct_bpf_program + SizeofBpfInsn = C.sizeof_struct_bpf_insn + SizeofBpfHdr = C.sizeof_struct_bpf_hdr +) + +type BpfVersion C.struct_bpf_version + +type BpfStat C.struct_bpf_stat + +type BpfProgram C.struct_bpf_program + +type BpfInsn C.struct_bpf_insn + +type BpfHdr C.struct_bpf_hdr + +// Terminal handling + +type Termios C.struct_termios diff --git a/vendor/golang.org/x/sys/unix/types_freebsd.go b/vendor/golang.org/x/sys/unix/types_freebsd.go new file mode 100644 index 0000000000..ae24557ad1 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/types_freebsd.go @@ -0,0 +1,353 @@ +// 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 ignore + +/* +Input to cgo -godefs. See also mkerrors.sh and mkall.sh +*/ + +// +godefs map struct_in_addr [4]byte /* in_addr */ +// +godefs map struct_in6_addr [16]byte /* in6_addr */ + +package unix + +/* +#define KERNEL +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + sizeofPtr = sizeof(void*), +}; + +union sockaddr_all { + struct sockaddr s1; // this one gets used for fields + struct sockaddr_in s2; // these pad it out + struct sockaddr_in6 s3; + struct sockaddr_un s4; + struct sockaddr_dl s5; +}; + +struct sockaddr_any { + struct sockaddr addr; + char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; +}; + +// This structure is a duplicate of stat on FreeBSD 8-STABLE. +// See /usr/include/sys/stat.h. +struct stat8 { +#undef st_atimespec st_atim +#undef st_mtimespec st_mtim +#undef st_ctimespec st_ctim +#undef st_birthtimespec st_birthtim + __dev_t st_dev; + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + __dev_t st_rdev; +#if __BSD_VISIBLE + struct timespec st_atimespec; + struct timespec st_mtimespec; + struct timespec st_ctimespec; +#else + time_t st_atime; + long __st_atimensec; + time_t st_mtime; + long __st_mtimensec; + time_t st_ctime; + long __st_ctimensec; +#endif + off_t st_size; + blkcnt_t st_blocks; + blksize_t st_blksize; + fflags_t st_flags; + __uint32_t st_gen; + __int32_t st_lspare; +#if __BSD_VISIBLE + struct timespec st_birthtimespec; + unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec)); + unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec)); +#else + time_t st_birthtime; + long st_birthtimensec; + unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec)); + unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec)); +#endif +}; + +// This structure is a duplicate of if_data on FreeBSD 8-STABLE. +// See /usr/include/net/if.h. +struct if_data8 { + u_char ifi_type; + u_char ifi_physical; + u_char ifi_addrlen; + u_char ifi_hdrlen; + u_char ifi_link_state; + u_char ifi_spare_char1; + u_char ifi_spare_char2; + u_char ifi_datalen; + u_long ifi_mtu; + u_long ifi_metric; + u_long ifi_baudrate; + u_long ifi_ipackets; + u_long ifi_ierrors; + u_long ifi_opackets; + u_long ifi_oerrors; + u_long ifi_collisions; + u_long ifi_ibytes; + u_long ifi_obytes; + u_long ifi_imcasts; + u_long ifi_omcasts; + u_long ifi_iqdrops; + u_long ifi_noproto; + u_long ifi_hwassist; + time_t ifi_epoch; + struct timeval ifi_lastchange; +}; + +// This structure is a duplicate of if_msghdr on FreeBSD 8-STABLE. +// See /usr/include/net/if.h. +struct if_msghdr8 { + u_short ifm_msglen; + u_char ifm_version; + u_char ifm_type; + int ifm_addrs; + int ifm_flags; + u_short ifm_index; + struct if_data8 ifm_data; +}; +*/ +import "C" + +// Machine characteristics; for internal use. + +const ( + sizeofPtr = C.sizeofPtr + sizeofShort = C.sizeof_short + sizeofInt = C.sizeof_int + sizeofLong = C.sizeof_long + sizeofLongLong = C.sizeof_longlong +) + +// Basic types + +type ( + _C_short C.short + _C_int C.int + _C_long C.long + _C_long_long C.longlong +) + +// Time + +type Timespec C.struct_timespec + +type Timeval C.struct_timeval + +// Processes + +type Rusage C.struct_rusage + +type Rlimit C.struct_rlimit + +type _Gid_t C.gid_t + +// Files + +const ( // Directory mode bits + S_IFMT = C.S_IFMT + S_IFIFO = C.S_IFIFO + S_IFCHR = C.S_IFCHR + S_IFDIR = C.S_IFDIR + S_IFBLK = C.S_IFBLK + S_IFREG = C.S_IFREG + S_IFLNK = C.S_IFLNK + S_IFSOCK = C.S_IFSOCK + S_ISUID = C.S_ISUID + S_ISGID = C.S_ISGID + S_ISVTX = C.S_ISVTX + S_IRUSR = C.S_IRUSR + S_IWUSR = C.S_IWUSR + S_IXUSR = C.S_IXUSR +) + +type Stat_t C.struct_stat8 + +type Statfs_t C.struct_statfs + +type Flock_t C.struct_flock + +type Dirent C.struct_dirent + +type Fsid C.struct_fsid + +// Advice to Fadvise + +const ( + FADV_NORMAL = C.POSIX_FADV_NORMAL + FADV_RANDOM = C.POSIX_FADV_RANDOM + FADV_SEQUENTIAL = C.POSIX_FADV_SEQUENTIAL + FADV_WILLNEED = C.POSIX_FADV_WILLNEED + FADV_DONTNEED = C.POSIX_FADV_DONTNEED + FADV_NOREUSE = C.POSIX_FADV_NOREUSE +) + +// Sockets + +type RawSockaddrInet4 C.struct_sockaddr_in + +type RawSockaddrInet6 C.struct_sockaddr_in6 + +type RawSockaddrUnix C.struct_sockaddr_un + +type RawSockaddrDatalink C.struct_sockaddr_dl + +type RawSockaddr C.struct_sockaddr + +type RawSockaddrAny C.struct_sockaddr_any + +type _Socklen C.socklen_t + +type Linger C.struct_linger + +type Iovec C.struct_iovec + +type IPMreq C.struct_ip_mreq + +type IPMreqn C.struct_ip_mreqn + +type IPv6Mreq C.struct_ipv6_mreq + +type Msghdr C.struct_msghdr + +type Cmsghdr C.struct_cmsghdr + +type Inet6Pktinfo C.struct_in6_pktinfo + +type IPv6MTUInfo C.struct_ip6_mtuinfo + +type ICMPv6Filter C.struct_icmp6_filter + +const ( + SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in + SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 + SizeofSockaddrAny = C.sizeof_struct_sockaddr_any + SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un + SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl + SizeofLinger = C.sizeof_struct_linger + SizeofIPMreq = C.sizeof_struct_ip_mreq + SizeofIPMreqn = C.sizeof_struct_ip_mreqn + SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq + SizeofMsghdr = C.sizeof_struct_msghdr + SizeofCmsghdr = C.sizeof_struct_cmsghdr + SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo + SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo + SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter +) + +// Ptrace requests + +const ( + PTRACE_TRACEME = C.PT_TRACE_ME + PTRACE_CONT = C.PT_CONTINUE + PTRACE_KILL = C.PT_KILL +) + +// Events (kqueue, kevent) + +type Kevent_t C.struct_kevent + +// Select + +type FdSet C.fd_set + +// Routing and interface messages + +const ( + sizeofIfMsghdr = C.sizeof_struct_if_msghdr + SizeofIfMsghdr = C.sizeof_struct_if_msghdr8 + sizeofIfData = C.sizeof_struct_if_data + SizeofIfData = C.sizeof_struct_if_data8 + SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr + SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr + SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr + SizeofRtMsghdr = C.sizeof_struct_rt_msghdr + SizeofRtMetrics = C.sizeof_struct_rt_metrics +) + +type ifMsghdr C.struct_if_msghdr + +type IfMsghdr C.struct_if_msghdr8 + +type ifData C.struct_if_data + +type IfData C.struct_if_data8 + +type IfaMsghdr C.struct_ifa_msghdr + +type IfmaMsghdr C.struct_ifma_msghdr + +type IfAnnounceMsghdr C.struct_if_announcemsghdr + +type RtMsghdr C.struct_rt_msghdr + +type RtMetrics C.struct_rt_metrics + +// Berkeley packet filter + +const ( + SizeofBpfVersion = C.sizeof_struct_bpf_version + SizeofBpfStat = C.sizeof_struct_bpf_stat + SizeofBpfZbuf = C.sizeof_struct_bpf_zbuf + SizeofBpfProgram = C.sizeof_struct_bpf_program + SizeofBpfInsn = C.sizeof_struct_bpf_insn + SizeofBpfHdr = C.sizeof_struct_bpf_hdr + SizeofBpfZbufHeader = C.sizeof_struct_bpf_zbuf_header +) + +type BpfVersion C.struct_bpf_version + +type BpfStat C.struct_bpf_stat + +type BpfZbuf C.struct_bpf_zbuf + +type BpfProgram C.struct_bpf_program + +type BpfInsn C.struct_bpf_insn + +type BpfHdr C.struct_bpf_hdr + +type BpfZbufHeader C.struct_bpf_zbuf_header + +// Terminal handling + +type Termios C.struct_termios diff --git a/vendor/golang.org/x/sys/unix/types_linux.go b/vendor/golang.org/x/sys/unix/types_linux.go new file mode 100644 index 0000000000..d004b4a484 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/types_linux.go @@ -0,0 +1,435 @@ +// 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 ignore + +/* +Input to cgo -godefs. See also mkerrors.sh and mkall.sh +*/ + +// +godefs map struct_in_addr [4]byte /* in_addr */ +// +godefs map struct_in6_addr [16]byte /* in6_addr */ + +package unix + +/* +#define _LARGEFILE_SOURCE +#define _LARGEFILE64_SOURCE +#define _FILE_OFFSET_BITS 64 +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef TCSETS2 +// On systems that have "struct termios2" use this as type Termios. +typedef struct termios2 termios_t; +#else +typedef struct termios termios_t; +#endif + +enum { + sizeofPtr = sizeof(void*), +}; + +union sockaddr_all { + struct sockaddr s1; // this one gets used for fields + struct sockaddr_in s2; // these pad it out + struct sockaddr_in6 s3; + struct sockaddr_un s4; + struct sockaddr_ll s5; + struct sockaddr_nl s6; +}; + +struct sockaddr_any { + struct sockaddr addr; + char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; +}; + +// copied from /usr/include/linux/un.h +struct my_sockaddr_un { + sa_family_t sun_family; +#if defined(__ARM_EABI__) || defined(__powerpc64__) + // on ARM char is by default unsigned + signed char sun_path[108]; +#else + char sun_path[108]; +#endif +}; + +#ifdef __ARM_EABI__ +typedef struct user_regs PtraceRegs; +#elif defined(__aarch64__) +typedef struct user_pt_regs PtraceRegs; +#elif defined(__powerpc64__) +typedef struct pt_regs PtraceRegs; +#elif defined(__mips__) +typedef struct user PtraceRegs; +#elif defined(__s390x__) +typedef struct _user_regs_struct PtraceRegs; +#else +typedef struct user_regs_struct PtraceRegs; +#endif + +#if defined(__s390x__) +typedef struct _user_psw_struct ptracePsw; +typedef struct _user_fpregs_struct ptraceFpregs; +typedef struct _user_per_struct ptracePer; +#else +typedef struct {} ptracePsw; +typedef struct {} ptraceFpregs; +typedef struct {} ptracePer; +#endif + +// The real epoll_event is a union, and godefs doesn't handle it well. +struct my_epoll_event { + uint32_t events; +#if defined(__ARM_EABI__) || defined(__aarch64__) + // padding is not specified in linux/eventpoll.h but added to conform to the + // alignment requirements of EABI + int32_t padFd; +#elif defined(__powerpc64__) || defined(__s390x__) + int32_t _padFd; +#endif + int32_t fd; + int32_t pad; +}; + +*/ +import "C" + +// Machine characteristics; for internal use. + +const ( + sizeofPtr = C.sizeofPtr + sizeofShort = C.sizeof_short + sizeofInt = C.sizeof_int + sizeofLong = C.sizeof_long + sizeofLongLong = C.sizeof_longlong + PathMax = C.PATH_MAX +) + +// Basic types + +type ( + _C_short C.short + _C_int C.int + _C_long C.long + _C_long_long C.longlong +) + +// Time + +type Timespec C.struct_timespec + +type Timeval C.struct_timeval + +type Timex C.struct_timex + +type Time_t C.time_t + +type Tms C.struct_tms + +type Utimbuf C.struct_utimbuf + +// Processes + +type Rusage C.struct_rusage + +type Rlimit C.struct_rlimit + +type _Gid_t C.gid_t + +// Files + +type Stat_t C.struct_stat + +type Statfs_t C.struct_statfs + +type Dirent C.struct_dirent + +type Fsid C.fsid_t + +type Flock_t C.struct_flock + +// Advice to Fadvise + +const ( + FADV_NORMAL = C.POSIX_FADV_NORMAL + FADV_RANDOM = C.POSIX_FADV_RANDOM + FADV_SEQUENTIAL = C.POSIX_FADV_SEQUENTIAL + FADV_WILLNEED = C.POSIX_FADV_WILLNEED + FADV_DONTNEED = C.POSIX_FADV_DONTNEED + FADV_NOREUSE = C.POSIX_FADV_NOREUSE +) + +// Sockets + +type RawSockaddrInet4 C.struct_sockaddr_in + +type RawSockaddrInet6 C.struct_sockaddr_in6 + +type RawSockaddrUnix C.struct_my_sockaddr_un + +type RawSockaddrLinklayer C.struct_sockaddr_ll + +type RawSockaddrNetlink C.struct_sockaddr_nl + +type RawSockaddrHCI C.struct_sockaddr_hci + +type RawSockaddr C.struct_sockaddr + +type RawSockaddrAny C.struct_sockaddr_any + +type _Socklen C.socklen_t + +type Linger C.struct_linger + +type Iovec C.struct_iovec + +type IPMreq C.struct_ip_mreq + +type IPMreqn C.struct_ip_mreqn + +type IPv6Mreq C.struct_ipv6_mreq + +type Msghdr C.struct_msghdr + +type Cmsghdr C.struct_cmsghdr + +type Inet4Pktinfo C.struct_in_pktinfo + +type Inet6Pktinfo C.struct_in6_pktinfo + +type IPv6MTUInfo C.struct_ip6_mtuinfo + +type ICMPv6Filter C.struct_icmp6_filter + +type Ucred C.struct_ucred + +type TCPInfo C.struct_tcp_info + +const ( + SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in + SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 + SizeofSockaddrAny = C.sizeof_struct_sockaddr_any + SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un + SizeofSockaddrLinklayer = C.sizeof_struct_sockaddr_ll + SizeofSockaddrNetlink = C.sizeof_struct_sockaddr_nl + SizeofSockaddrHCI = C.sizeof_struct_sockaddr_hci + SizeofLinger = C.sizeof_struct_linger + SizeofIPMreq = C.sizeof_struct_ip_mreq + SizeofIPMreqn = C.sizeof_struct_ip_mreqn + SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq + SizeofMsghdr = C.sizeof_struct_msghdr + SizeofCmsghdr = C.sizeof_struct_cmsghdr + SizeofInet4Pktinfo = C.sizeof_struct_in_pktinfo + SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo + SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo + SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter + SizeofUcred = C.sizeof_struct_ucred + SizeofTCPInfo = C.sizeof_struct_tcp_info +) + +// Netlink routing and interface messages + +const ( + IFA_UNSPEC = C.IFA_UNSPEC + IFA_ADDRESS = C.IFA_ADDRESS + IFA_LOCAL = C.IFA_LOCAL + IFA_LABEL = C.IFA_LABEL + IFA_BROADCAST = C.IFA_BROADCAST + IFA_ANYCAST = C.IFA_ANYCAST + IFA_CACHEINFO = C.IFA_CACHEINFO + IFA_MULTICAST = C.IFA_MULTICAST + IFLA_UNSPEC = C.IFLA_UNSPEC + IFLA_ADDRESS = C.IFLA_ADDRESS + IFLA_BROADCAST = C.IFLA_BROADCAST + IFLA_IFNAME = C.IFLA_IFNAME + IFLA_MTU = C.IFLA_MTU + IFLA_LINK = C.IFLA_LINK + IFLA_QDISC = C.IFLA_QDISC + IFLA_STATS = C.IFLA_STATS + IFLA_COST = C.IFLA_COST + IFLA_PRIORITY = C.IFLA_PRIORITY + IFLA_MASTER = C.IFLA_MASTER + IFLA_WIRELESS = C.IFLA_WIRELESS + IFLA_PROTINFO = C.IFLA_PROTINFO + IFLA_TXQLEN = C.IFLA_TXQLEN + IFLA_MAP = C.IFLA_MAP + IFLA_WEIGHT = C.IFLA_WEIGHT + IFLA_OPERSTATE = C.IFLA_OPERSTATE + IFLA_LINKMODE = C.IFLA_LINKMODE + IFLA_LINKINFO = C.IFLA_LINKINFO + IFLA_NET_NS_PID = C.IFLA_NET_NS_PID + IFLA_IFALIAS = C.IFLA_IFALIAS + IFLA_MAX = C.IFLA_MAX + RT_SCOPE_UNIVERSE = C.RT_SCOPE_UNIVERSE + RT_SCOPE_SITE = C.RT_SCOPE_SITE + RT_SCOPE_LINK = C.RT_SCOPE_LINK + RT_SCOPE_HOST = C.RT_SCOPE_HOST + RT_SCOPE_NOWHERE = C.RT_SCOPE_NOWHERE + RT_TABLE_UNSPEC = C.RT_TABLE_UNSPEC + RT_TABLE_COMPAT = C.RT_TABLE_COMPAT + RT_TABLE_DEFAULT = C.RT_TABLE_DEFAULT + RT_TABLE_MAIN = C.RT_TABLE_MAIN + RT_TABLE_LOCAL = C.RT_TABLE_LOCAL + RT_TABLE_MAX = C.RT_TABLE_MAX + RTA_UNSPEC = C.RTA_UNSPEC + RTA_DST = C.RTA_DST + RTA_SRC = C.RTA_SRC + RTA_IIF = C.RTA_IIF + RTA_OIF = C.RTA_OIF + RTA_GATEWAY = C.RTA_GATEWAY + RTA_PRIORITY = C.RTA_PRIORITY + RTA_PREFSRC = C.RTA_PREFSRC + RTA_METRICS = C.RTA_METRICS + RTA_MULTIPATH = C.RTA_MULTIPATH + RTA_FLOW = C.RTA_FLOW + RTA_CACHEINFO = C.RTA_CACHEINFO + RTA_TABLE = C.RTA_TABLE + RTN_UNSPEC = C.RTN_UNSPEC + RTN_UNICAST = C.RTN_UNICAST + RTN_LOCAL = C.RTN_LOCAL + RTN_BROADCAST = C.RTN_BROADCAST + RTN_ANYCAST = C.RTN_ANYCAST + RTN_MULTICAST = C.RTN_MULTICAST + RTN_BLACKHOLE = C.RTN_BLACKHOLE + RTN_UNREACHABLE = C.RTN_UNREACHABLE + RTN_PROHIBIT = C.RTN_PROHIBIT + RTN_THROW = C.RTN_THROW + RTN_NAT = C.RTN_NAT + RTN_XRESOLVE = C.RTN_XRESOLVE + RTNLGRP_NONE = C.RTNLGRP_NONE + RTNLGRP_LINK = C.RTNLGRP_LINK + RTNLGRP_NOTIFY = C.RTNLGRP_NOTIFY + RTNLGRP_NEIGH = C.RTNLGRP_NEIGH + RTNLGRP_TC = C.RTNLGRP_TC + RTNLGRP_IPV4_IFADDR = C.RTNLGRP_IPV4_IFADDR + RTNLGRP_IPV4_MROUTE = C.RTNLGRP_IPV4_MROUTE + RTNLGRP_IPV4_ROUTE = C.RTNLGRP_IPV4_ROUTE + RTNLGRP_IPV4_RULE = C.RTNLGRP_IPV4_RULE + RTNLGRP_IPV6_IFADDR = C.RTNLGRP_IPV6_IFADDR + RTNLGRP_IPV6_MROUTE = C.RTNLGRP_IPV6_MROUTE + RTNLGRP_IPV6_ROUTE = C.RTNLGRP_IPV6_ROUTE + RTNLGRP_IPV6_IFINFO = C.RTNLGRP_IPV6_IFINFO + RTNLGRP_IPV6_PREFIX = C.RTNLGRP_IPV6_PREFIX + RTNLGRP_IPV6_RULE = C.RTNLGRP_IPV6_RULE + RTNLGRP_ND_USEROPT = C.RTNLGRP_ND_USEROPT + SizeofNlMsghdr = C.sizeof_struct_nlmsghdr + SizeofNlMsgerr = C.sizeof_struct_nlmsgerr + SizeofRtGenmsg = C.sizeof_struct_rtgenmsg + SizeofNlAttr = C.sizeof_struct_nlattr + SizeofRtAttr = C.sizeof_struct_rtattr + SizeofIfInfomsg = C.sizeof_struct_ifinfomsg + SizeofIfAddrmsg = C.sizeof_struct_ifaddrmsg + SizeofRtMsg = C.sizeof_struct_rtmsg + SizeofRtNexthop = C.sizeof_struct_rtnexthop +) + +type NlMsghdr C.struct_nlmsghdr + +type NlMsgerr C.struct_nlmsgerr + +type RtGenmsg C.struct_rtgenmsg + +type NlAttr C.struct_nlattr + +type RtAttr C.struct_rtattr + +type IfInfomsg C.struct_ifinfomsg + +type IfAddrmsg C.struct_ifaddrmsg + +type RtMsg C.struct_rtmsg + +type RtNexthop C.struct_rtnexthop + +// Linux socket filter + +const ( + SizeofSockFilter = C.sizeof_struct_sock_filter + SizeofSockFprog = C.sizeof_struct_sock_fprog +) + +type SockFilter C.struct_sock_filter + +type SockFprog C.struct_sock_fprog + +// Inotify + +type InotifyEvent C.struct_inotify_event + +const SizeofInotifyEvent = C.sizeof_struct_inotify_event + +// Ptrace + +// Register structures +type PtraceRegs C.PtraceRegs + +// Structures contained in PtraceRegs on s390x (exported by mkpost.go) +type ptracePsw C.ptracePsw + +type ptraceFpregs C.ptraceFpregs + +type ptracePer C.ptracePer + +// Misc + +type FdSet C.fd_set + +type Sysinfo_t C.struct_sysinfo + +type Utsname C.struct_utsname + +type Ustat_t C.struct_ustat + +type EpollEvent C.struct_my_epoll_event + +const ( + AT_FDCWD = C.AT_FDCWD + AT_REMOVEDIR = C.AT_REMOVEDIR + AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW + AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW +) + +// Terminal handling + +type Termios C.termios_t diff --git a/vendor/golang.org/x/sys/unix/types_netbsd.go b/vendor/golang.org/x/sys/unix/types_netbsd.go new file mode 100644 index 0000000000..d15f93d192 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/types_netbsd.go @@ -0,0 +1,232 @@ +// 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 ignore + +/* +Input to cgo -godefs. See also mkerrors.sh and mkall.sh +*/ + +// +godefs map struct_in_addr [4]byte /* in_addr */ +// +godefs map struct_in6_addr [16]byte /* in6_addr */ + +package unix + +/* +#define KERNEL +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + sizeofPtr = sizeof(void*), +}; + +union sockaddr_all { + struct sockaddr s1; // this one gets used for fields + struct sockaddr_in s2; // these pad it out + struct sockaddr_in6 s3; + struct sockaddr_un s4; + struct sockaddr_dl s5; +}; + +struct sockaddr_any { + struct sockaddr addr; + char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; +}; + +*/ +import "C" + +// Machine characteristics; for internal use. + +const ( + sizeofPtr = C.sizeofPtr + sizeofShort = C.sizeof_short + sizeofInt = C.sizeof_int + sizeofLong = C.sizeof_long + sizeofLongLong = C.sizeof_longlong +) + +// Basic types + +type ( + _C_short C.short + _C_int C.int + _C_long C.long + _C_long_long C.longlong +) + +// Time + +type Timespec C.struct_timespec + +type Timeval C.struct_timeval + +// Processes + +type Rusage C.struct_rusage + +type Rlimit C.struct_rlimit + +type _Gid_t C.gid_t + +// Files + +type Stat_t C.struct_stat + +type Statfs_t C.struct_statfs + +type Flock_t C.struct_flock + +type Dirent C.struct_dirent + +type Fsid C.fsid_t + +// Sockets + +type RawSockaddrInet4 C.struct_sockaddr_in + +type RawSockaddrInet6 C.struct_sockaddr_in6 + +type RawSockaddrUnix C.struct_sockaddr_un + +type RawSockaddrDatalink C.struct_sockaddr_dl + +type RawSockaddr C.struct_sockaddr + +type RawSockaddrAny C.struct_sockaddr_any + +type _Socklen C.socklen_t + +type Linger C.struct_linger + +type Iovec C.struct_iovec + +type IPMreq C.struct_ip_mreq + +type IPv6Mreq C.struct_ipv6_mreq + +type Msghdr C.struct_msghdr + +type Cmsghdr C.struct_cmsghdr + +type Inet6Pktinfo C.struct_in6_pktinfo + +type IPv6MTUInfo C.struct_ip6_mtuinfo + +type ICMPv6Filter C.struct_icmp6_filter + +const ( + SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in + SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 + SizeofSockaddrAny = C.sizeof_struct_sockaddr_any + SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un + SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl + SizeofLinger = C.sizeof_struct_linger + SizeofIPMreq = C.sizeof_struct_ip_mreq + SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq + SizeofMsghdr = C.sizeof_struct_msghdr + SizeofCmsghdr = C.sizeof_struct_cmsghdr + SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo + SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo + SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter +) + +// Ptrace requests + +const ( + PTRACE_TRACEME = C.PT_TRACE_ME + PTRACE_CONT = C.PT_CONTINUE + PTRACE_KILL = C.PT_KILL +) + +// Events (kqueue, kevent) + +type Kevent_t C.struct_kevent + +// Select + +type FdSet C.fd_set + +// Routing and interface messages + +const ( + SizeofIfMsghdr = C.sizeof_struct_if_msghdr + SizeofIfData = C.sizeof_struct_if_data + SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr + SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr + SizeofRtMsghdr = C.sizeof_struct_rt_msghdr + SizeofRtMetrics = C.sizeof_struct_rt_metrics +) + +type IfMsghdr C.struct_if_msghdr + +type IfData C.struct_if_data + +type IfaMsghdr C.struct_ifa_msghdr + +type IfAnnounceMsghdr C.struct_if_announcemsghdr + +type RtMsghdr C.struct_rt_msghdr + +type RtMetrics C.struct_rt_metrics + +type Mclpool C.struct_mclpool + +// Berkeley packet filter + +const ( + SizeofBpfVersion = C.sizeof_struct_bpf_version + SizeofBpfStat = C.sizeof_struct_bpf_stat + SizeofBpfProgram = C.sizeof_struct_bpf_program + SizeofBpfInsn = C.sizeof_struct_bpf_insn + SizeofBpfHdr = C.sizeof_struct_bpf_hdr +) + +type BpfVersion C.struct_bpf_version + +type BpfStat C.struct_bpf_stat + +type BpfProgram C.struct_bpf_program + +type BpfInsn C.struct_bpf_insn + +type BpfHdr C.struct_bpf_hdr + +type BpfTimeval C.struct_bpf_timeval + +// Terminal handling + +type Termios C.struct_termios + +// Sysctl + +type Sysctlnode C.struct_sysctlnode diff --git a/vendor/golang.org/x/sys/unix/types_openbsd.go b/vendor/golang.org/x/sys/unix/types_openbsd.go new file mode 100644 index 0000000000..b66fe25f73 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/types_openbsd.go @@ -0,0 +1,244 @@ +// 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 ignore + +/* +Input to cgo -godefs. See also mkerrors.sh and mkall.sh +*/ + +// +godefs map struct_in_addr [4]byte /* in_addr */ +// +godefs map struct_in6_addr [16]byte /* in6_addr */ + +package unix + +/* +#define KERNEL +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + sizeofPtr = sizeof(void*), +}; + +union sockaddr_all { + struct sockaddr s1; // this one gets used for fields + struct sockaddr_in s2; // these pad it out + struct sockaddr_in6 s3; + struct sockaddr_un s4; + struct sockaddr_dl s5; +}; + +struct sockaddr_any { + struct sockaddr addr; + char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; +}; + +*/ +import "C" + +// Machine characteristics; for internal use. + +const ( + sizeofPtr = C.sizeofPtr + sizeofShort = C.sizeof_short + sizeofInt = C.sizeof_int + sizeofLong = C.sizeof_long + sizeofLongLong = C.sizeof_longlong +) + +// Basic types + +type ( + _C_short C.short + _C_int C.int + _C_long C.long + _C_long_long C.longlong +) + +// Time + +type Timespec C.struct_timespec + +type Timeval C.struct_timeval + +// Processes + +type Rusage C.struct_rusage + +type Rlimit C.struct_rlimit + +type _Gid_t C.gid_t + +// Files + +const ( // Directory mode bits + S_IFMT = C.S_IFMT + S_IFIFO = C.S_IFIFO + S_IFCHR = C.S_IFCHR + S_IFDIR = C.S_IFDIR + S_IFBLK = C.S_IFBLK + S_IFREG = C.S_IFREG + S_IFLNK = C.S_IFLNK + S_IFSOCK = C.S_IFSOCK + S_ISUID = C.S_ISUID + S_ISGID = C.S_ISGID + S_ISVTX = C.S_ISVTX + S_IRUSR = C.S_IRUSR + S_IWUSR = C.S_IWUSR + S_IXUSR = C.S_IXUSR +) + +type Stat_t C.struct_stat + +type Statfs_t C.struct_statfs + +type Flock_t C.struct_flock + +type Dirent C.struct_dirent + +type Fsid C.fsid_t + +// Sockets + +type RawSockaddrInet4 C.struct_sockaddr_in + +type RawSockaddrInet6 C.struct_sockaddr_in6 + +type RawSockaddrUnix C.struct_sockaddr_un + +type RawSockaddrDatalink C.struct_sockaddr_dl + +type RawSockaddr C.struct_sockaddr + +type RawSockaddrAny C.struct_sockaddr_any + +type _Socklen C.socklen_t + +type Linger C.struct_linger + +type Iovec C.struct_iovec + +type IPMreq C.struct_ip_mreq + +type IPv6Mreq C.struct_ipv6_mreq + +type Msghdr C.struct_msghdr + +type Cmsghdr C.struct_cmsghdr + +type Inet6Pktinfo C.struct_in6_pktinfo + +type IPv6MTUInfo C.struct_ip6_mtuinfo + +type ICMPv6Filter C.struct_icmp6_filter + +const ( + SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in + SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 + SizeofSockaddrAny = C.sizeof_struct_sockaddr_any + SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un + SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl + SizeofLinger = C.sizeof_struct_linger + SizeofIPMreq = C.sizeof_struct_ip_mreq + SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq + SizeofMsghdr = C.sizeof_struct_msghdr + SizeofCmsghdr = C.sizeof_struct_cmsghdr + SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo + SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo + SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter +) + +// Ptrace requests + +const ( + PTRACE_TRACEME = C.PT_TRACE_ME + PTRACE_CONT = C.PT_CONTINUE + PTRACE_KILL = C.PT_KILL +) + +// Events (kqueue, kevent) + +type Kevent_t C.struct_kevent + +// Select + +type FdSet C.fd_set + +// Routing and interface messages + +const ( + SizeofIfMsghdr = C.sizeof_struct_if_msghdr + SizeofIfData = C.sizeof_struct_if_data + SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr + SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr + SizeofRtMsghdr = C.sizeof_struct_rt_msghdr + SizeofRtMetrics = C.sizeof_struct_rt_metrics +) + +type IfMsghdr C.struct_if_msghdr + +type IfData C.struct_if_data + +type IfaMsghdr C.struct_ifa_msghdr + +type IfAnnounceMsghdr C.struct_if_announcemsghdr + +type RtMsghdr C.struct_rt_msghdr + +type RtMetrics C.struct_rt_metrics + +type Mclpool C.struct_mclpool + +// Berkeley packet filter + +const ( + SizeofBpfVersion = C.sizeof_struct_bpf_version + SizeofBpfStat = C.sizeof_struct_bpf_stat + SizeofBpfProgram = C.sizeof_struct_bpf_program + SizeofBpfInsn = C.sizeof_struct_bpf_insn + SizeofBpfHdr = C.sizeof_struct_bpf_hdr +) + +type BpfVersion C.struct_bpf_version + +type BpfStat C.struct_bpf_stat + +type BpfProgram C.struct_bpf_program + +type BpfInsn C.struct_bpf_insn + +type BpfHdr C.struct_bpf_hdr + +type BpfTimeval C.struct_bpf_timeval + +// Terminal handling + +type Termios C.struct_termios diff --git a/vendor/golang.org/x/sys/unix/types_solaris.go b/vendor/golang.org/x/sys/unix/types_solaris.go new file mode 100644 index 0000000000..6ad50eaba6 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/types_solaris.go @@ -0,0 +1,260 @@ +// 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 ignore + +/* +Input to cgo -godefs. See also mkerrors.sh and mkall.sh +*/ + +// +godefs map struct_in_addr [4]byte /* in_addr */ +// +godefs map struct_in6_addr [16]byte /* in6_addr */ + +package unix + +/* +#define KERNEL +// These defines ensure that builds done on newer versions of Solaris are +// backwards-compatible with older versions of Solaris and +// OpenSolaris-based derivatives. +#define __USE_SUNOS_SOCKETS__ // msghdr +#define __USE_LEGACY_PROTOTYPES__ // iovec +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + sizeofPtr = sizeof(void*), +}; + +union sockaddr_all { + struct sockaddr s1; // this one gets used for fields + struct sockaddr_in s2; // these pad it out + struct sockaddr_in6 s3; + struct sockaddr_un s4; + struct sockaddr_dl s5; +}; + +struct sockaddr_any { + struct sockaddr addr; + char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; +}; + +*/ +import "C" + +// Machine characteristics; for internal use. + +const ( + sizeofPtr = C.sizeofPtr + sizeofShort = C.sizeof_short + sizeofInt = C.sizeof_int + sizeofLong = C.sizeof_long + sizeofLongLong = C.sizeof_longlong + PathMax = C.PATH_MAX +) + +// Basic types + +type ( + _C_short C.short + _C_int C.int + _C_long C.long + _C_long_long C.longlong +) + +// Time + +type Timespec C.struct_timespec + +type Timeval C.struct_timeval + +type Timeval32 C.struct_timeval32 + +type Tms C.struct_tms + +type Utimbuf C.struct_utimbuf + +// Processes + +type Rusage C.struct_rusage + +type Rlimit C.struct_rlimit + +type _Gid_t C.gid_t + +// Files + +const ( // Directory mode bits + S_IFMT = C.S_IFMT + S_IFIFO = C.S_IFIFO + S_IFCHR = C.S_IFCHR + S_IFDIR = C.S_IFDIR + S_IFBLK = C.S_IFBLK + S_IFREG = C.S_IFREG + S_IFLNK = C.S_IFLNK + S_IFSOCK = C.S_IFSOCK + S_ISUID = C.S_ISUID + S_ISGID = C.S_ISGID + S_ISVTX = C.S_ISVTX + S_IRUSR = C.S_IRUSR + S_IWUSR = C.S_IWUSR + S_IXUSR = C.S_IXUSR +) + +type Stat_t C.struct_stat + +type Flock_t C.struct_flock + +type Dirent C.struct_dirent + +// Sockets + +type RawSockaddrInet4 C.struct_sockaddr_in + +type RawSockaddrInet6 C.struct_sockaddr_in6 + +type RawSockaddrUnix C.struct_sockaddr_un + +type RawSockaddrDatalink C.struct_sockaddr_dl + +type RawSockaddr C.struct_sockaddr + +type RawSockaddrAny C.struct_sockaddr_any + +type _Socklen C.socklen_t + +type Linger C.struct_linger + +type Iovec C.struct_iovec + +type IPMreq C.struct_ip_mreq + +type IPv6Mreq C.struct_ipv6_mreq + +type Msghdr C.struct_msghdr + +type Cmsghdr C.struct_cmsghdr + +type Inet6Pktinfo C.struct_in6_pktinfo + +type IPv6MTUInfo C.struct_ip6_mtuinfo + +type ICMPv6Filter C.struct_icmp6_filter + +const ( + SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in + SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 + SizeofSockaddrAny = C.sizeof_struct_sockaddr_any + SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un + SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl + SizeofLinger = C.sizeof_struct_linger + SizeofIPMreq = C.sizeof_struct_ip_mreq + SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq + SizeofMsghdr = C.sizeof_struct_msghdr + SizeofCmsghdr = C.sizeof_struct_cmsghdr + SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo + SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo + SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter +) + +// Select + +type FdSet C.fd_set + +// Misc + +type Utsname C.struct_utsname + +type Ustat_t C.struct_ustat + +const ( + AT_FDCWD = C.AT_FDCWD + AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW + AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW + AT_REMOVEDIR = C.AT_REMOVEDIR + AT_EACCESS = C.AT_EACCESS +) + +// Routing and interface messages + +const ( + SizeofIfMsghdr = C.sizeof_struct_if_msghdr + SizeofIfData = C.sizeof_struct_if_data + SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr + SizeofRtMsghdr = C.sizeof_struct_rt_msghdr + SizeofRtMetrics = C.sizeof_struct_rt_metrics +) + +type IfMsghdr C.struct_if_msghdr + +type IfData C.struct_if_data + +type IfaMsghdr C.struct_ifa_msghdr + +type RtMsghdr C.struct_rt_msghdr + +type RtMetrics C.struct_rt_metrics + +// Berkeley packet filter + +const ( + SizeofBpfVersion = C.sizeof_struct_bpf_version + SizeofBpfStat = C.sizeof_struct_bpf_stat + SizeofBpfProgram = C.sizeof_struct_bpf_program + SizeofBpfInsn = C.sizeof_struct_bpf_insn + SizeofBpfHdr = C.sizeof_struct_bpf_hdr +) + +type BpfVersion C.struct_bpf_version + +type BpfStat C.struct_bpf_stat + +type BpfProgram C.struct_bpf_program + +type BpfInsn C.struct_bpf_insn + +type BpfTimeval C.struct_bpf_timeval + +type BpfHdr C.struct_bpf_hdr + +// sysconf information + +const _SC_PAGESIZE = C._SC_PAGESIZE + +// Terminal handling + +type Termios C.struct_termios + +type Termio C.struct_termio + +type Winsize C.struct_winsize diff --git a/vendor/golang.org/x/sys/unix/zerrors_darwin_386.go b/vendor/golang.org/x/sys/unix/zerrors_darwin_386.go new file mode 100644 index 0000000000..8e63888351 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_darwin_386.go @@ -0,0 +1,1576 @@ +// mkerrors.sh -m32 +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build 386,darwin + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -m32 _const.go + +package unix + +import "syscall" + +const ( + AF_APPLETALK = 0x10 + AF_CCITT = 0xa + AF_CHAOS = 0x5 + AF_CNT = 0x15 + AF_COIP = 0x14 + AF_DATAKIT = 0x9 + AF_DECnet = 0xc + AF_DLI = 0xd + AF_E164 = 0x1c + AF_ECMA = 0x8 + AF_HYLINK = 0xf + AF_IEEE80211 = 0x25 + AF_IMPLINK = 0x3 + AF_INET = 0x2 + AF_INET6 = 0x1e + AF_IPX = 0x17 + AF_ISDN = 0x1c + AF_ISO = 0x7 + AF_LAT = 0xe + AF_LINK = 0x12 + AF_LOCAL = 0x1 + AF_MAX = 0x28 + AF_NATM = 0x1f + AF_NDRV = 0x1b + AF_NETBIOS = 0x21 + AF_NS = 0x6 + AF_OSI = 0x7 + AF_PPP = 0x22 + AF_PUP = 0x4 + AF_RESERVED_36 = 0x24 + AF_ROUTE = 0x11 + AF_SIP = 0x18 + AF_SNA = 0xb + AF_SYSTEM = 0x20 + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_UTUN = 0x26 + B0 = 0x0 + B110 = 0x6e + B115200 = 0x1c200 + B1200 = 0x4b0 + B134 = 0x86 + B14400 = 0x3840 + B150 = 0x96 + B1800 = 0x708 + B19200 = 0x4b00 + B200 = 0xc8 + B230400 = 0x38400 + B2400 = 0x960 + B28800 = 0x7080 + B300 = 0x12c + B38400 = 0x9600 + B4800 = 0x12c0 + B50 = 0x32 + B57600 = 0xe100 + B600 = 0x258 + B7200 = 0x1c20 + B75 = 0x4b + B76800 = 0x12c00 + B9600 = 0x2580 + BIOCFLUSH = 0x20004268 + BIOCGBLEN = 0x40044266 + BIOCGDLT = 0x4004426a + BIOCGDLTLIST = 0xc00c4279 + BIOCGETIF = 0x4020426b + BIOCGHDRCMPLT = 0x40044274 + BIOCGRSIG = 0x40044272 + BIOCGRTIMEOUT = 0x4008426e + BIOCGSEESENT = 0x40044276 + BIOCGSTATS = 0x4008426f + BIOCIMMEDIATE = 0x80044270 + BIOCPROMISC = 0x20004269 + BIOCSBLEN = 0xc0044266 + BIOCSDLT = 0x80044278 + BIOCSETF = 0x80084267 + BIOCSETFNR = 0x8008427e + BIOCSETIF = 0x8020426c + BIOCSHDRCMPLT = 0x80044275 + BIOCSRSIG = 0x80044273 + BIOCSRTIMEOUT = 0x8008426d + BIOCSSEESENT = 0x80044277 + BIOCVERSION = 0x40044271 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALIGNMENT = 0x4 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXBUFSIZE = 0x80000 + BPF_MAXINSNS = 0x200 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINBUFSIZE = 0x20 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RELEASE = 0x30bb6 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BRKINT = 0x2 + CFLUSH = 0xf + CLOCAL = 0x8000 + CREAD = 0x800 + CS5 = 0x0 + CS6 = 0x100 + CS7 = 0x200 + CS8 = 0x300 + CSIZE = 0x300 + CSTART = 0x11 + CSTATUS = 0x14 + CSTOP = 0x13 + CSTOPB = 0x400 + CSUSP = 0x1a + CTL_MAXNAME = 0xc + CTL_NET = 0x4 + DLT_A429 = 0xb8 + DLT_A653_ICM = 0xb9 + DLT_AIRONET_HEADER = 0x78 + DLT_AOS = 0xde + DLT_APPLE_IP_OVER_IEEE1394 = 0x8a + DLT_ARCNET = 0x7 + DLT_ARCNET_LINUX = 0x81 + DLT_ATM_CLIP = 0x13 + DLT_ATM_RFC1483 = 0xb + DLT_AURORA = 0x7e + DLT_AX25 = 0x3 + DLT_AX25_KISS = 0xca + DLT_BACNET_MS_TP = 0xa5 + DLT_BLUETOOTH_HCI_H4 = 0xbb + DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9 + DLT_CAN20B = 0xbe + DLT_CAN_SOCKETCAN = 0xe3 + DLT_CHAOS = 0x5 + DLT_CHDLC = 0x68 + DLT_CISCO_IOS = 0x76 + DLT_C_HDLC = 0x68 + DLT_C_HDLC_WITH_DIR = 0xcd + DLT_DBUS = 0xe7 + DLT_DECT = 0xdd + DLT_DOCSIS = 0x8f + DLT_DVB_CI = 0xeb + DLT_ECONET = 0x73 + DLT_EN10MB = 0x1 + DLT_EN3MB = 0x2 + DLT_ENC = 0x6d + DLT_ERF = 0xc5 + DLT_ERF_ETH = 0xaf + DLT_ERF_POS = 0xb0 + DLT_FC_2 = 0xe0 + DLT_FC_2_WITH_FRAME_DELIMS = 0xe1 + DLT_FDDI = 0xa + DLT_FLEXRAY = 0xd2 + DLT_FRELAY = 0x6b + DLT_FRELAY_WITH_DIR = 0xce + DLT_GCOM_SERIAL = 0xad + DLT_GCOM_T1E1 = 0xac + DLT_GPF_F = 0xab + DLT_GPF_T = 0xaa + DLT_GPRS_LLC = 0xa9 + DLT_GSMTAP_ABIS = 0xda + DLT_GSMTAP_UM = 0xd9 + DLT_HHDLC = 0x79 + DLT_IBM_SN = 0x92 + DLT_IBM_SP = 0x91 + DLT_IEEE802 = 0x6 + DLT_IEEE802_11 = 0x69 + DLT_IEEE802_11_RADIO = 0x7f + DLT_IEEE802_11_RADIO_AVS = 0xa3 + DLT_IEEE802_15_4 = 0xc3 + DLT_IEEE802_15_4_LINUX = 0xbf + DLT_IEEE802_15_4_NOFCS = 0xe6 + DLT_IEEE802_15_4_NONASK_PHY = 0xd7 + DLT_IEEE802_16_MAC_CPS = 0xbc + DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1 + DLT_IPFILTER = 0x74 + DLT_IPMB = 0xc7 + DLT_IPMB_LINUX = 0xd1 + DLT_IPNET = 0xe2 + DLT_IPOIB = 0xf2 + DLT_IPV4 = 0xe4 + DLT_IPV6 = 0xe5 + DLT_IP_OVER_FC = 0x7a + DLT_JUNIPER_ATM1 = 0x89 + DLT_JUNIPER_ATM2 = 0x87 + DLT_JUNIPER_ATM_CEMIC = 0xee + DLT_JUNIPER_CHDLC = 0xb5 + DLT_JUNIPER_ES = 0x84 + DLT_JUNIPER_ETHER = 0xb2 + DLT_JUNIPER_FIBRECHANNEL = 0xea + DLT_JUNIPER_FRELAY = 0xb4 + DLT_JUNIPER_GGSN = 0x85 + DLT_JUNIPER_ISM = 0xc2 + DLT_JUNIPER_MFR = 0x86 + DLT_JUNIPER_MLFR = 0x83 + DLT_JUNIPER_MLPPP = 0x82 + DLT_JUNIPER_MONITOR = 0xa4 + DLT_JUNIPER_PIC_PEER = 0xae + DLT_JUNIPER_PPP = 0xb3 + DLT_JUNIPER_PPPOE = 0xa7 + DLT_JUNIPER_PPPOE_ATM = 0xa8 + DLT_JUNIPER_SERVICES = 0x88 + DLT_JUNIPER_SRX_E2E = 0xe9 + DLT_JUNIPER_ST = 0xc8 + DLT_JUNIPER_VP = 0xb7 + DLT_JUNIPER_VS = 0xe8 + DLT_LAPB_WITH_DIR = 0xcf + DLT_LAPD = 0xcb + DLT_LIN = 0xd4 + DLT_LINUX_EVDEV = 0xd8 + DLT_LINUX_IRDA = 0x90 + DLT_LINUX_LAPD = 0xb1 + DLT_LINUX_PPP_WITHDIRECTION = 0xa6 + DLT_LINUX_SLL = 0x71 + DLT_LOOP = 0x6c + DLT_LTALK = 0x72 + DLT_MATCHING_MAX = 0xf5 + DLT_MATCHING_MIN = 0x68 + DLT_MFR = 0xb6 + DLT_MOST = 0xd3 + DLT_MPEG_2_TS = 0xf3 + DLT_MPLS = 0xdb + DLT_MTP2 = 0x8c + DLT_MTP2_WITH_PHDR = 0x8b + DLT_MTP3 = 0x8d + DLT_MUX27010 = 0xec + DLT_NETANALYZER = 0xf0 + DLT_NETANALYZER_TRANSPARENT = 0xf1 + DLT_NFC_LLCP = 0xf5 + DLT_NFLOG = 0xef + DLT_NG40 = 0xf4 + DLT_NULL = 0x0 + DLT_PCI_EXP = 0x7d + DLT_PFLOG = 0x75 + DLT_PFSYNC = 0x12 + DLT_PPI = 0xc0 + DLT_PPP = 0x9 + DLT_PPP_BSDOS = 0x10 + DLT_PPP_ETHER = 0x33 + DLT_PPP_PPPD = 0xa6 + DLT_PPP_SERIAL = 0x32 + DLT_PPP_WITH_DIR = 0xcc + DLT_PPP_WITH_DIRECTION = 0xa6 + DLT_PRISM_HEADER = 0x77 + DLT_PRONET = 0x4 + DLT_RAIF1 = 0xc6 + DLT_RAW = 0xc + DLT_RIO = 0x7c + DLT_SCCP = 0x8e + DLT_SITA = 0xc4 + DLT_SLIP = 0x8 + DLT_SLIP_BSDOS = 0xf + DLT_STANAG_5066_D_PDU = 0xed + DLT_SUNATM = 0x7b + DLT_SYMANTEC_FIREWALL = 0x63 + DLT_TZSP = 0x80 + DLT_USB = 0xba + DLT_USB_LINUX = 0xbd + DLT_USB_LINUX_MMAPPED = 0xdc + DLT_USER0 = 0x93 + DLT_USER1 = 0x94 + DLT_USER10 = 0x9d + DLT_USER11 = 0x9e + DLT_USER12 = 0x9f + DLT_USER13 = 0xa0 + DLT_USER14 = 0xa1 + DLT_USER15 = 0xa2 + DLT_USER2 = 0x95 + DLT_USER3 = 0x96 + DLT_USER4 = 0x97 + DLT_USER5 = 0x98 + DLT_USER6 = 0x99 + DLT_USER7 = 0x9a + DLT_USER8 = 0x9b + DLT_USER9 = 0x9c + DLT_WIHART = 0xdf + DLT_X2E_SERIAL = 0xd5 + DLT_X2E_XORAYA = 0xd6 + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x40 + ECHOE = 0x2 + ECHOK = 0x4 + ECHOKE = 0x1 + ECHONL = 0x10 + ECHOPRT = 0x20 + EVFILT_AIO = -0x3 + EVFILT_FS = -0x9 + EVFILT_MACHPORT = -0x8 + EVFILT_PROC = -0x5 + EVFILT_READ = -0x1 + EVFILT_SIGNAL = -0x6 + EVFILT_SYSCOUNT = 0xe + EVFILT_THREADMARKER = 0xe + EVFILT_TIMER = -0x7 + EVFILT_USER = -0xa + EVFILT_VM = -0xc + EVFILT_VNODE = -0x4 + EVFILT_WRITE = -0x2 + EV_ADD = 0x1 + EV_CLEAR = 0x20 + EV_DELETE = 0x2 + EV_DISABLE = 0x8 + EV_DISPATCH = 0x80 + EV_ENABLE = 0x4 + EV_EOF = 0x8000 + EV_ERROR = 0x4000 + EV_FLAG0 = 0x1000 + EV_FLAG1 = 0x2000 + EV_ONESHOT = 0x10 + EV_OOBAND = 0x2000 + EV_POLL = 0x1000 + EV_RECEIPT = 0x40 + EV_SYSFLAGS = 0xf000 + EXTA = 0x4b00 + EXTB = 0x9600 + EXTPROC = 0x800 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FLUSHO = 0x800000 + F_ADDFILESIGS = 0x3d + F_ADDSIGS = 0x3b + F_ALLOCATEALL = 0x4 + F_ALLOCATECONTIG = 0x2 + F_CHKCLEAN = 0x29 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x43 + F_FINDSIGS = 0x4e + F_FLUSH_DATA = 0x28 + F_FREEZE_FS = 0x35 + F_FULLFSYNC = 0x33 + F_GETCODEDIR = 0x48 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLK = 0x7 + F_GETLKPID = 0x42 + F_GETNOSIGPIPE = 0x4a + F_GETOWN = 0x5 + F_GETPATH = 0x32 + F_GETPATH_MTMINFO = 0x47 + F_GETPROTECTIONCLASS = 0x3f + F_GETPROTECTIONLEVEL = 0x4d + F_GLOBAL_NOCACHE = 0x37 + F_LOG2PHYS = 0x31 + F_LOG2PHYS_EXT = 0x41 + F_NOCACHE = 0x30 + F_NODIRECT = 0x3e + F_OK = 0x0 + F_PATHPKG_CHECK = 0x34 + F_PEOFPOSMODE = 0x3 + F_PREALLOCATE = 0x2a + F_RDADVISE = 0x2c + F_RDAHEAD = 0x2d + F_RDLCK = 0x1 + F_SETBACKINGSTORE = 0x46 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLK = 0x8 + F_SETLKW = 0x9 + F_SETLKWTIMEOUT = 0xa + F_SETNOSIGPIPE = 0x49 + F_SETOWN = 0x6 + F_SETPROTECTIONCLASS = 0x40 + F_SETSIZE = 0x2b + F_SINGLE_WRITER = 0x4c + F_THAW_FS = 0x36 + F_TRANSCODEKEY = 0x4b + F_UNLCK = 0x2 + F_VOLPOSMODE = 0x4 + F_WRLCK = 0x3 + HUPCL = 0x4000 + ICANON = 0x100 + ICMP6_FILTER = 0x12 + ICRNL = 0x100 + IEXTEN = 0x400 + IFF_ALLMULTI = 0x200 + IFF_ALTPHYS = 0x4000 + IFF_BROADCAST = 0x2 + IFF_DEBUG = 0x4 + IFF_LINK0 = 0x1000 + IFF_LINK1 = 0x2000 + IFF_LINK2 = 0x4000 + IFF_LOOPBACK = 0x8 + IFF_MULTICAST = 0x8000 + IFF_NOARP = 0x80 + IFF_NOTRAILERS = 0x20 + IFF_OACTIVE = 0x400 + IFF_POINTOPOINT = 0x10 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SIMPLEX = 0x800 + IFF_UP = 0x1 + IFNAMSIZ = 0x10 + IFT_1822 = 0x2 + IFT_AAL5 = 0x31 + IFT_ARCNET = 0x23 + IFT_ARCNETPLUS = 0x24 + IFT_ATM = 0x25 + IFT_BRIDGE = 0xd1 + IFT_CARP = 0xf8 + IFT_CELLULAR = 0xff + IFT_CEPT = 0x13 + IFT_DS3 = 0x1e + IFT_ENC = 0xf4 + IFT_EON = 0x19 + IFT_ETHER = 0x6 + IFT_FAITH = 0x38 + IFT_FDDI = 0xf + IFT_FRELAY = 0x20 + IFT_FRELAYDCE = 0x2c + IFT_GIF = 0x37 + IFT_HDH1822 = 0x3 + IFT_HIPPI = 0x2f + IFT_HSSI = 0x2e + IFT_HY = 0xe + IFT_IEEE1394 = 0x90 + IFT_IEEE8023ADLAG = 0x88 + IFT_ISDNBASIC = 0x14 + IFT_ISDNPRIMARY = 0x15 + IFT_ISO88022LLC = 0x29 + IFT_ISO88023 = 0x7 + IFT_ISO88024 = 0x8 + IFT_ISO88025 = 0x9 + IFT_ISO88026 = 0xa + IFT_L2VLAN = 0x87 + IFT_LAPB = 0x10 + IFT_LOCALTALK = 0x2a + IFT_LOOP = 0x18 + IFT_MIOX25 = 0x26 + IFT_MODEM = 0x30 + IFT_NSIP = 0x1b + IFT_OTHER = 0x1 + IFT_P10 = 0xc + IFT_P80 = 0xd + IFT_PARA = 0x22 + IFT_PDP = 0xff + IFT_PFLOG = 0xf5 + IFT_PFSYNC = 0xf6 + IFT_PKTAP = 0xfe + IFT_PPP = 0x17 + IFT_PROPMUX = 0x36 + IFT_PROPVIRTUAL = 0x35 + IFT_PTPSERIAL = 0x16 + IFT_RS232 = 0x21 + IFT_SDLC = 0x11 + IFT_SIP = 0x1f + IFT_SLIP = 0x1c + IFT_SMDSDXI = 0x2b + IFT_SMDSICIP = 0x34 + IFT_SONET = 0x27 + IFT_SONETPATH = 0x32 + IFT_SONETVT = 0x33 + IFT_STARLAN = 0xb + IFT_STF = 0x39 + IFT_T1 = 0x12 + IFT_ULTRA = 0x1d + IFT_V35 = 0x2d + IFT_X25 = 0x5 + IFT_X25DDN = 0x4 + IFT_X25PLE = 0x28 + IFT_XETHER = 0x1a + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLASSD_HOST = 0xfffffff + IN_CLASSD_NET = 0xf0000000 + IN_CLASSD_NSHIFT = 0x1c + IN_LINKLOCALNETNUM = 0xa9fe0000 + IN_LOOPBACKNET = 0x7f + IPPROTO_3PC = 0x22 + IPPROTO_ADFS = 0x44 + IPPROTO_AH = 0x33 + IPPROTO_AHIP = 0x3d + IPPROTO_APES = 0x63 + IPPROTO_ARGUS = 0xd + IPPROTO_AX25 = 0x5d + IPPROTO_BHA = 0x31 + IPPROTO_BLT = 0x1e + IPPROTO_BRSATMON = 0x4c + IPPROTO_CFTP = 0x3e + IPPROTO_CHAOS = 0x10 + IPPROTO_CMTP = 0x26 + IPPROTO_CPHB = 0x49 + IPPROTO_CPNX = 0x48 + IPPROTO_DDP = 0x25 + IPPROTO_DGP = 0x56 + IPPROTO_DIVERT = 0xfe + IPPROTO_DONE = 0x101 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_EMCON = 0xe + IPPROTO_ENCAP = 0x62 + IPPROTO_EON = 0x50 + IPPROTO_ESP = 0x32 + IPPROTO_ETHERIP = 0x61 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GGP = 0x3 + IPPROTO_GMTP = 0x64 + IPPROTO_GRE = 0x2f + IPPROTO_HELLO = 0x3f + IPPROTO_HMP = 0x14 + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IDPR = 0x23 + IPPROTO_IDRP = 0x2d + IPPROTO_IGMP = 0x2 + IPPROTO_IGP = 0x55 + IPPROTO_IGRP = 0x58 + IPPROTO_IL = 0x28 + IPPROTO_INLSP = 0x34 + IPPROTO_INP = 0x20 + IPPROTO_IP = 0x0 + IPPROTO_IPCOMP = 0x6c + IPPROTO_IPCV = 0x47 + IPPROTO_IPEIP = 0x5e + IPPROTO_IPIP = 0x4 + IPPROTO_IPPC = 0x43 + IPPROTO_IPV4 = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_IRTP = 0x1c + IPPROTO_KRYPTOLAN = 0x41 + IPPROTO_LARP = 0x5b + IPPROTO_LEAF1 = 0x19 + IPPROTO_LEAF2 = 0x1a + IPPROTO_MAX = 0x100 + IPPROTO_MAXID = 0x34 + IPPROTO_MEAS = 0x13 + IPPROTO_MHRP = 0x30 + IPPROTO_MICP = 0x5f + IPPROTO_MTP = 0x5c + IPPROTO_MUX = 0x12 + IPPROTO_ND = 0x4d + IPPROTO_NHRP = 0x36 + IPPROTO_NONE = 0x3b + IPPROTO_NSP = 0x1f + IPPROTO_NVPII = 0xb + IPPROTO_OSPFIGP = 0x59 + IPPROTO_PGM = 0x71 + IPPROTO_PIGP = 0x9 + IPPROTO_PIM = 0x67 + IPPROTO_PRM = 0x15 + IPPROTO_PUP = 0xc + IPPROTO_PVP = 0x4b + IPPROTO_RAW = 0xff + IPPROTO_RCCMON = 0xa + IPPROTO_RDP = 0x1b + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_RVD = 0x42 + IPPROTO_SATEXPAK = 0x40 + IPPROTO_SATMON = 0x45 + IPPROTO_SCCSP = 0x60 + IPPROTO_SCTP = 0x84 + IPPROTO_SDRP = 0x2a + IPPROTO_SEP = 0x21 + IPPROTO_SRPC = 0x5a + IPPROTO_ST = 0x7 + IPPROTO_SVMTP = 0x52 + IPPROTO_SWIPE = 0x35 + IPPROTO_TCF = 0x57 + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_TPXX = 0x27 + IPPROTO_TRUNK1 = 0x17 + IPPROTO_TRUNK2 = 0x18 + IPPROTO_TTP = 0x54 + IPPROTO_UDP = 0x11 + IPPROTO_VINES = 0x53 + IPPROTO_VISA = 0x46 + IPPROTO_VMTP = 0x51 + IPPROTO_WBEXPAK = 0x4f + IPPROTO_WBMON = 0x4e + IPPROTO_WSN = 0x4a + IPPROTO_XNET = 0xf + IPPROTO_XTP = 0x24 + IPV6_2292DSTOPTS = 0x17 + IPV6_2292HOPLIMIT = 0x14 + IPV6_2292HOPOPTS = 0x16 + IPV6_2292NEXTHOP = 0x15 + IPV6_2292PKTINFO = 0x13 + IPV6_2292PKTOPTIONS = 0x19 + IPV6_2292RTHDR = 0x18 + IPV6_BINDV6ONLY = 0x1b + IPV6_BOUND_IF = 0x7d + IPV6_CHECKSUM = 0x1a + IPV6_DEFAULT_MULTICAST_HOPS = 0x1 + IPV6_DEFAULT_MULTICAST_LOOP = 0x1 + IPV6_DEFHLIM = 0x40 + IPV6_FAITH = 0x1d + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 + IPV6_FRAGTTL = 0x3c + IPV6_FW_ADD = 0x1e + IPV6_FW_DEL = 0x1f + IPV6_FW_FLUSH = 0x20 + IPV6_FW_GET = 0x22 + IPV6_FW_ZERO = 0x21 + IPV6_HLIMDEC = 0x1 + IPV6_IPSEC_POLICY = 0x1c + IPV6_JOIN_GROUP = 0xc + IPV6_LEAVE_GROUP = 0xd + IPV6_MAXHLIM = 0xff + IPV6_MAXOPTHDR = 0x800 + IPV6_MAXPACKET = 0xffff + IPV6_MAX_GROUP_SRC_FILTER = 0x200 + IPV6_MAX_MEMBERSHIPS = 0xfff + IPV6_MAX_SOCK_SRC_FILTER = 0x80 + IPV6_MIN_MEMBERSHIPS = 0x1f + IPV6_MMTU = 0x500 + IPV6_MULTICAST_HOPS = 0xa + IPV6_MULTICAST_IF = 0x9 + IPV6_MULTICAST_LOOP = 0xb + IPV6_PORTRANGE = 0xe + IPV6_PORTRANGE_DEFAULT = 0x0 + IPV6_PORTRANGE_HIGH = 0x1 + IPV6_PORTRANGE_LOW = 0x2 + IPV6_RECVTCLASS = 0x23 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_SOCKOPT_RESERVED1 = 0x3 + IPV6_TCLASS = 0x24 + IPV6_UNICAST_HOPS = 0x4 + IPV6_V6ONLY = 0x1b + IPV6_VERSION = 0x60 + IPV6_VERSION_MASK = 0xf0 + IP_ADD_MEMBERSHIP = 0xc + IP_ADD_SOURCE_MEMBERSHIP = 0x46 + IP_BLOCK_SOURCE = 0x48 + IP_BOUND_IF = 0x19 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DROP_MEMBERSHIP = 0xd + IP_DROP_SOURCE_MEMBERSHIP = 0x47 + IP_DUMMYNET_CONFIGURE = 0x3c + IP_DUMMYNET_DEL = 0x3d + IP_DUMMYNET_FLUSH = 0x3e + IP_DUMMYNET_GET = 0x40 + IP_FAITH = 0x16 + IP_FW_ADD = 0x28 + IP_FW_DEL = 0x29 + IP_FW_FLUSH = 0x2a + IP_FW_GET = 0x2c + IP_FW_RESETLOG = 0x2d + IP_FW_ZERO = 0x2b + IP_HDRINCL = 0x2 + IP_IPSEC_POLICY = 0x15 + IP_MAXPACKET = 0xffff + IP_MAX_GROUP_SRC_FILTER = 0x200 + IP_MAX_MEMBERSHIPS = 0xfff + IP_MAX_SOCK_MUTE_FILTER = 0x80 + IP_MAX_SOCK_SRC_FILTER = 0x80 + IP_MF = 0x2000 + IP_MIN_MEMBERSHIPS = 0x1f + IP_MSFILTER = 0x4a + IP_MSS = 0x240 + IP_MULTICAST_IF = 0x9 + IP_MULTICAST_IFINDEX = 0x42 + IP_MULTICAST_LOOP = 0xb + IP_MULTICAST_TTL = 0xa + IP_MULTICAST_VIF = 0xe + IP_NAT__XXX = 0x37 + IP_OFFMASK = 0x1fff + IP_OLD_FW_ADD = 0x32 + IP_OLD_FW_DEL = 0x33 + IP_OLD_FW_FLUSH = 0x34 + IP_OLD_FW_GET = 0x36 + IP_OLD_FW_RESETLOG = 0x38 + IP_OLD_FW_ZERO = 0x35 + IP_OPTIONS = 0x1 + IP_PKTINFO = 0x1a + IP_PORTRANGE = 0x13 + IP_PORTRANGE_DEFAULT = 0x0 + IP_PORTRANGE_HIGH = 0x1 + IP_PORTRANGE_LOW = 0x2 + IP_RECVDSTADDR = 0x7 + IP_RECVIF = 0x14 + IP_RECVOPTS = 0x5 + IP_RECVPKTINFO = 0x1a + IP_RECVRETOPTS = 0x6 + IP_RECVTTL = 0x18 + IP_RETOPTS = 0x8 + IP_RF = 0x8000 + IP_RSVP_OFF = 0x10 + IP_RSVP_ON = 0xf + IP_RSVP_VIF_OFF = 0x12 + IP_RSVP_VIF_ON = 0x11 + IP_STRIPHDR = 0x17 + IP_TOS = 0x3 + IP_TRAFFIC_MGT_BACKGROUND = 0x41 + IP_TTL = 0x4 + IP_UNBLOCK_SOURCE = 0x49 + ISIG = 0x80 + ISTRIP = 0x20 + IUTF8 = 0x4000 + IXANY = 0x800 + IXOFF = 0x400 + IXON = 0x200 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_CAN_REUSE = 0x9 + MADV_DONTNEED = 0x4 + MADV_FREE = 0x5 + MADV_FREE_REUSABLE = 0x7 + MADV_FREE_REUSE = 0x8 + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_SEQUENTIAL = 0x2 + MADV_WILLNEED = 0x3 + MADV_ZERO_WIRED_PAGES = 0x6 + MAP_ANON = 0x1000 + MAP_COPY = 0x2 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_HASSEMAPHORE = 0x200 + MAP_JIT = 0x800 + MAP_NOCACHE = 0x400 + MAP_NOEXTEND = 0x100 + MAP_NORESERVE = 0x40 + MAP_PRIVATE = 0x2 + MAP_RENAME = 0x20 + MAP_RESERVED0080 = 0x80 + MAP_SHARED = 0x1 + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MSG_CTRUNC = 0x20 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x80 + MSG_EOF = 0x100 + MSG_EOR = 0x8 + MSG_FLUSH = 0x400 + MSG_HAVEMORE = 0x2000 + MSG_HOLD = 0x800 + MSG_NEEDSA = 0x10000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_RCVMORE = 0x4000 + MSG_SEND = 0x1000 + MSG_TRUNC = 0x10 + MSG_WAITALL = 0x40 + MSG_WAITSTREAM = 0x200 + MS_ASYNC = 0x1 + MS_DEACTIVATE = 0x8 + MS_INVALIDATE = 0x2 + MS_KILLPAGES = 0x4 + MS_SYNC = 0x10 + NAME_MAX = 0xff + NET_RT_DUMP = 0x1 + NET_RT_DUMP2 = 0x7 + NET_RT_FLAGS = 0x2 + NET_RT_IFLIST = 0x3 + NET_RT_IFLIST2 = 0x6 + NET_RT_MAXID = 0xa + NET_RT_STAT = 0x4 + NET_RT_TRASH = 0x5 + NOFLSH = 0x80000000 + NOTE_ABSOLUTE = 0x8 + NOTE_ATTRIB = 0x8 + NOTE_BACKGROUND = 0x40 + NOTE_CHILD = 0x4 + NOTE_CRITICAL = 0x20 + NOTE_DELETE = 0x1 + NOTE_EXEC = 0x20000000 + NOTE_EXIT = 0x80000000 + NOTE_EXITSTATUS = 0x4000000 + NOTE_EXIT_CSERROR = 0x40000 + NOTE_EXIT_DECRYPTFAIL = 0x10000 + NOTE_EXIT_DETAIL = 0x2000000 + NOTE_EXIT_DETAIL_MASK = 0x70000 + NOTE_EXIT_MEMORY = 0x20000 + NOTE_EXIT_REPARENTED = 0x80000 + NOTE_EXTEND = 0x4 + NOTE_FFAND = 0x40000000 + NOTE_FFCOPY = 0xc0000000 + NOTE_FFCTRLMASK = 0xc0000000 + NOTE_FFLAGSMASK = 0xffffff + NOTE_FFNOP = 0x0 + NOTE_FFOR = 0x80000000 + NOTE_FORK = 0x40000000 + NOTE_LEEWAY = 0x10 + NOTE_LINK = 0x10 + NOTE_LOWAT = 0x1 + NOTE_NONE = 0x80 + NOTE_NSECONDS = 0x4 + NOTE_PCTRLMASK = -0x100000 + NOTE_PDATAMASK = 0xfffff + NOTE_REAP = 0x10000000 + NOTE_RENAME = 0x20 + NOTE_REVOKE = 0x40 + NOTE_SECONDS = 0x1 + NOTE_SIGNAL = 0x8000000 + NOTE_TRACK = 0x1 + NOTE_TRACKERR = 0x2 + NOTE_TRIGGER = 0x1000000 + NOTE_USECONDS = 0x2 + NOTE_VM_ERROR = 0x10000000 + NOTE_VM_PRESSURE = 0x80000000 + NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000 + NOTE_VM_PRESSURE_TERMINATE = 0x40000000 + NOTE_WRITE = 0x2 + OCRNL = 0x10 + OFDEL = 0x20000 + OFILL = 0x80 + ONLCR = 0x2 + ONLRET = 0x40 + ONOCR = 0x20 + ONOEOT = 0x8 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_ALERT = 0x20000000 + O_APPEND = 0x8 + O_ASYNC = 0x40 + O_CLOEXEC = 0x1000000 + O_CREAT = 0x200 + O_DIRECTORY = 0x100000 + O_DP_GETRAWENCRYPTED = 0x1 + O_DSYNC = 0x400000 + O_EVTONLY = 0x8000 + O_EXCL = 0x800 + O_EXLOCK = 0x20 + O_FSYNC = 0x80 + O_NDELAY = 0x4 + O_NOCTTY = 0x20000 + O_NOFOLLOW = 0x100 + O_NONBLOCK = 0x4 + O_POPUP = 0x80000000 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_SHLOCK = 0x10 + O_SYMLINK = 0x200000 + O_SYNC = 0x80 + O_TRUNC = 0x400 + O_WRONLY = 0x1 + PARENB = 0x1000 + PARMRK = 0x8 + PARODD = 0x2000 + PENDIN = 0x20000000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + PT_ATTACH = 0xa + PT_ATTACHEXC = 0xe + PT_CONTINUE = 0x7 + PT_DENY_ATTACH = 0x1f + PT_DETACH = 0xb + PT_FIRSTMACH = 0x20 + PT_FORCEQUOTA = 0x1e + PT_KILL = 0x8 + PT_READ_D = 0x2 + PT_READ_I = 0x1 + PT_READ_U = 0x3 + PT_SIGEXC = 0xc + PT_STEP = 0x9 + PT_THUPDATE = 0xd + PT_TRACE_ME = 0x0 + PT_WRITE_D = 0x5 + PT_WRITE_I = 0x4 + PT_WRITE_U = 0x6 + RLIMIT_AS = 0x5 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_CPU_USAGE_MONITOR = 0x2 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x8 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = 0x7fffffffffffffff + RTAX_AUTHOR = 0x6 + RTAX_BRD = 0x7 + RTAX_DST = 0x0 + RTAX_GATEWAY = 0x1 + RTAX_GENMASK = 0x3 + RTAX_IFA = 0x5 + RTAX_IFP = 0x4 + RTAX_MAX = 0x8 + RTAX_NETMASK = 0x2 + RTA_AUTHOR = 0x40 + RTA_BRD = 0x80 + RTA_DST = 0x1 + RTA_GATEWAY = 0x2 + RTA_GENMASK = 0x8 + RTA_IFA = 0x20 + RTA_IFP = 0x10 + RTA_NETMASK = 0x4 + RTF_BLACKHOLE = 0x1000 + RTF_BROADCAST = 0x400000 + RTF_CLONING = 0x100 + RTF_CONDEMNED = 0x2000000 + RTF_DELCLONE = 0x80 + RTF_DONE = 0x40 + RTF_DYNAMIC = 0x10 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_IFREF = 0x4000000 + RTF_IFSCOPE = 0x1000000 + RTF_LLINFO = 0x400 + RTF_LOCAL = 0x200000 + RTF_MODIFIED = 0x20 + RTF_MULTICAST = 0x800000 + RTF_NOIFREF = 0x2000 + RTF_PINNED = 0x100000 + RTF_PRCLONING = 0x10000 + RTF_PROTO1 = 0x8000 + RTF_PROTO2 = 0x4000 + RTF_PROTO3 = 0x40000 + RTF_PROXY = 0x8000000 + RTF_REJECT = 0x8 + RTF_ROUTER = 0x10000000 + RTF_STATIC = 0x800 + RTF_UP = 0x1 + RTF_WASCLONED = 0x20000 + RTF_XRESOLVE = 0x200 + RTM_ADD = 0x1 + RTM_CHANGE = 0x3 + RTM_DELADDR = 0xd + RTM_DELETE = 0x2 + RTM_DELMADDR = 0x10 + RTM_GET = 0x4 + RTM_GET2 = 0x14 + RTM_IFINFO = 0xe + RTM_IFINFO2 = 0x12 + RTM_LOCK = 0x8 + RTM_LOSING = 0x5 + RTM_MISS = 0x7 + RTM_NEWADDR = 0xc + RTM_NEWMADDR = 0xf + RTM_NEWMADDR2 = 0x13 + RTM_OLDADD = 0x9 + RTM_OLDDEL = 0xa + RTM_REDIRECT = 0x6 + RTM_RESOLVE = 0xb + RTM_RTTUNIT = 0xf4240 + RTM_VERSION = 0x5 + RTV_EXPIRE = 0x4 + RTV_HOPCOUNT = 0x2 + RTV_MTU = 0x1 + RTV_RPIPE = 0x8 + RTV_RTT = 0x40 + RTV_RTTVAR = 0x80 + RTV_SPIPE = 0x10 + RTV_SSTHRESH = 0x20 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + SCM_CREDS = 0x3 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x2 + SCM_TIMESTAMP_MONOTONIC = 0x4 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDMULTI = 0x80206931 + SIOCAIFADDR = 0x8040691a + SIOCARPIPLL = 0xc0206928 + SIOCATMARK = 0x40047307 + SIOCAUTOADDR = 0xc0206926 + SIOCAUTONETMASK = 0x80206927 + SIOCDELMULTI = 0x80206932 + SIOCDIFADDR = 0x80206919 + SIOCDIFPHYADDR = 0x80206941 + SIOCGDRVSPEC = 0xc01c697b + SIOCGETVLAN = 0xc020697f + SIOCGHIWAT = 0x40047301 + SIOCGIFADDR = 0xc0206921 + SIOCGIFALTMTU = 0xc0206948 + SIOCGIFASYNCMAP = 0xc020697c + SIOCGIFBOND = 0xc0206947 + SIOCGIFBRDADDR = 0xc0206923 + SIOCGIFCAP = 0xc020695b + SIOCGIFCONF = 0xc0086924 + SIOCGIFDEVMTU = 0xc0206944 + SIOCGIFDSTADDR = 0xc0206922 + SIOCGIFFLAGS = 0xc0206911 + SIOCGIFGENERIC = 0xc020693a + SIOCGIFKPI = 0xc0206987 + SIOCGIFMAC = 0xc0206982 + SIOCGIFMEDIA = 0xc0286938 + SIOCGIFMETRIC = 0xc0206917 + SIOCGIFMTU = 0xc0206933 + SIOCGIFNETMASK = 0xc0206925 + SIOCGIFPDSTADDR = 0xc0206940 + SIOCGIFPHYS = 0xc0206935 + SIOCGIFPSRCADDR = 0xc020693f + SIOCGIFSTATUS = 0xc331693d + SIOCGIFVLAN = 0xc020697f + SIOCGIFWAKEFLAGS = 0xc0206988 + SIOCGLOWAT = 0x40047303 + SIOCGPGRP = 0x40047309 + SIOCIFCREATE = 0xc0206978 + SIOCIFCREATE2 = 0xc020697a + SIOCIFDESTROY = 0x80206979 + SIOCIFGCLONERS = 0xc00c6981 + SIOCRSLVMULTI = 0xc008693b + SIOCSDRVSPEC = 0x801c697b + SIOCSETVLAN = 0x8020697e + SIOCSHIWAT = 0x80047300 + SIOCSIFADDR = 0x8020690c + SIOCSIFALTMTU = 0x80206945 + SIOCSIFASYNCMAP = 0x8020697d + SIOCSIFBOND = 0x80206946 + SIOCSIFBRDADDR = 0x80206913 + SIOCSIFCAP = 0x8020695a + SIOCSIFDSTADDR = 0x8020690e + SIOCSIFFLAGS = 0x80206910 + SIOCSIFGENERIC = 0x80206939 + SIOCSIFKPI = 0x80206986 + SIOCSIFLLADDR = 0x8020693c + SIOCSIFMAC = 0x80206983 + SIOCSIFMEDIA = 0xc0206937 + SIOCSIFMETRIC = 0x80206918 + SIOCSIFMTU = 0x80206934 + SIOCSIFNETMASK = 0x80206916 + SIOCSIFPHYADDR = 0x8040693e + SIOCSIFPHYS = 0x80206936 + SIOCSIFVLAN = 0x8020697e + SIOCSLOWAT = 0x80047302 + SIOCSPGRP = 0x80047308 + SOCK_DGRAM = 0x2 + SOCK_MAXADDRLEN = 0xff + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_SOCKET = 0xffff + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x2 + SO_BROADCAST = 0x20 + SO_DEBUG = 0x1 + SO_DONTROUTE = 0x10 + SO_DONTTRUNC = 0x2000 + SO_ERROR = 0x1007 + SO_KEEPALIVE = 0x8 + SO_LABEL = 0x1010 + SO_LINGER = 0x80 + SO_LINGER_SEC = 0x1080 + SO_NKE = 0x1021 + SO_NOADDRERR = 0x1023 + SO_NOSIGPIPE = 0x1022 + SO_NOTIFYCONFLICT = 0x1026 + SO_NP_EXTENSIONS = 0x1083 + SO_NREAD = 0x1020 + SO_NUMRCVPKT = 0x1112 + SO_NWRITE = 0x1024 + SO_OOBINLINE = 0x100 + SO_PEERLABEL = 0x1011 + SO_RANDOMPORT = 0x1082 + SO_RCVBUF = 0x1002 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x1006 + SO_REUSEADDR = 0x4 + SO_REUSEPORT = 0x200 + SO_REUSESHAREUID = 0x1025 + SO_SNDBUF = 0x1001 + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x1005 + SO_TIMESTAMP = 0x400 + SO_TIMESTAMP_MONOTONIC = 0x800 + SO_TYPE = 0x1008 + SO_UPCALLCLOSEWAIT = 0x1027 + SO_USELOOPBACK = 0x40 + SO_WANTMORE = 0x4000 + SO_WANTOOBFLAG = 0x8000 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IFWHT = 0xe000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISTXT = 0x200 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + TCIFLUSH = 0x1 + TCIOFLUSH = 0x3 + TCOFLUSH = 0x2 + TCP_CONNECTIONTIMEOUT = 0x20 + TCP_ENABLE_ECN = 0x104 + TCP_KEEPALIVE = 0x10 + TCP_KEEPCNT = 0x102 + TCP_KEEPINTVL = 0x101 + TCP_MAXHLEN = 0x3c + TCP_MAXOLEN = 0x28 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_SACK = 0x4 + TCP_MAX_WINSHIFT = 0xe + TCP_MINMSS = 0xd8 + TCP_MSS = 0x200 + TCP_NODELAY = 0x1 + TCP_NOOPT = 0x8 + TCP_NOPUSH = 0x4 + TCP_NOTSENT_LOWAT = 0x201 + TCP_RXT_CONNDROPTIME = 0x80 + TCP_RXT_FINDROP = 0x100 + TCP_SENDMOREACKS = 0x103 + TCSAFLUSH = 0x2 + TIOCCBRK = 0x2000747a + TIOCCDTR = 0x20007478 + TIOCCONS = 0x80047462 + TIOCDCDTIMESTAMP = 0x40087458 + TIOCDRAIN = 0x2000745e + TIOCDSIMICROCODE = 0x20007455 + TIOCEXCL = 0x2000740d + TIOCEXT = 0x80047460 + TIOCFLUSH = 0x80047410 + TIOCGDRAINWAIT = 0x40047456 + TIOCGETA = 0x402c7413 + TIOCGETD = 0x4004741a + TIOCGPGRP = 0x40047477 + TIOCGWINSZ = 0x40087468 + TIOCIXOFF = 0x20007480 + TIOCIXON = 0x20007481 + TIOCMBIC = 0x8004746b + TIOCMBIS = 0x8004746c + TIOCMGDTRWAIT = 0x4004745a + TIOCMGET = 0x4004746a + TIOCMODG = 0x40047403 + TIOCMODS = 0x80047404 + TIOCMSDTRWAIT = 0x8004745b + TIOCMSET = 0x8004746d + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x20007471 + TIOCNXCL = 0x2000740e + TIOCOUTQ = 0x40047473 + TIOCPKT = 0x80047470 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCPTYGNAME = 0x40807453 + TIOCPTYGRANT = 0x20007454 + TIOCPTYUNLK = 0x20007452 + TIOCREMOTE = 0x80047469 + TIOCSBRK = 0x2000747b + TIOCSCONS = 0x20007463 + TIOCSCTTY = 0x20007461 + TIOCSDRAINWAIT = 0x80047457 + TIOCSDTR = 0x20007479 + TIOCSETA = 0x802c7414 + TIOCSETAF = 0x802c7416 + TIOCSETAW = 0x802c7415 + TIOCSETD = 0x8004741b + TIOCSIG = 0x2000745f + TIOCSPGRP = 0x80047476 + TIOCSTART = 0x2000746e + TIOCSTAT = 0x20007465 + TIOCSTI = 0x80017472 + TIOCSTOP = 0x2000746f + TIOCSWINSZ = 0x80087467 + TIOCTIMESTAMP = 0x40087459 + TIOCUCNTL = 0x80047466 + TOSTOP = 0x400000 + VDISCARD = 0xf + VDSUSP = 0xb + VEOF = 0x0 + VEOL = 0x1 + VEOL2 = 0x2 + VERASE = 0x3 + VINTR = 0x8 + VKILL = 0x5 + VLNEXT = 0xe + VMIN = 0x10 + VQUIT = 0x9 + VREPRINT = 0x6 + VSTART = 0xc + VSTATUS = 0x12 + VSTOP = 0xd + VSUSP = 0xa + VT0 = 0x0 + VT1 = 0x10000 + VTDLY = 0x10000 + VTIME = 0x11 + VWERASE = 0x4 + WCONTINUED = 0x10 + WCOREFLAG = 0x80 + WEXITED = 0x4 + WNOHANG = 0x1 + WNOWAIT = 0x20 + WORDSIZE = 0x20 + WSTOPPED = 0x8 + WUNTRACED = 0x2 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x30) + EADDRNOTAVAIL = syscall.Errno(0x31) + EAFNOSUPPORT = syscall.Errno(0x2f) + EAGAIN = syscall.Errno(0x23) + EALREADY = syscall.Errno(0x25) + EAUTH = syscall.Errno(0x50) + EBADARCH = syscall.Errno(0x56) + EBADEXEC = syscall.Errno(0x55) + EBADF = syscall.Errno(0x9) + EBADMACHO = syscall.Errno(0x58) + EBADMSG = syscall.Errno(0x5e) + EBADRPC = syscall.Errno(0x48) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x59) + ECHILD = syscall.Errno(0xa) + ECONNABORTED = syscall.Errno(0x35) + ECONNREFUSED = syscall.Errno(0x3d) + ECONNRESET = syscall.Errno(0x36) + EDEADLK = syscall.Errno(0xb) + EDESTADDRREQ = syscall.Errno(0x27) + EDEVERR = syscall.Errno(0x53) + EDOM = syscall.Errno(0x21) + EDQUOT = syscall.Errno(0x45) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EFTYPE = syscall.Errno(0x4f) + EHOSTDOWN = syscall.Errno(0x40) + EHOSTUNREACH = syscall.Errno(0x41) + EIDRM = syscall.Errno(0x5a) + EILSEQ = syscall.Errno(0x5c) + EINPROGRESS = syscall.Errno(0x24) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x38) + EISDIR = syscall.Errno(0x15) + ELAST = syscall.Errno(0x6a) + ELOOP = syscall.Errno(0x3e) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x28) + EMULTIHOP = syscall.Errno(0x5f) + ENAMETOOLONG = syscall.Errno(0x3f) + ENEEDAUTH = syscall.Errno(0x51) + ENETDOWN = syscall.Errno(0x32) + ENETRESET = syscall.Errno(0x34) + ENETUNREACH = syscall.Errno(0x33) + ENFILE = syscall.Errno(0x17) + ENOATTR = syscall.Errno(0x5d) + ENOBUFS = syscall.Errno(0x37) + ENODATA = syscall.Errno(0x60) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOLCK = syscall.Errno(0x4d) + ENOLINK = syscall.Errno(0x61) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x5b) + ENOPOLICY = syscall.Errno(0x67) + ENOPROTOOPT = syscall.Errno(0x2a) + ENOSPC = syscall.Errno(0x1c) + ENOSR = syscall.Errno(0x62) + ENOSTR = syscall.Errno(0x63) + ENOSYS = syscall.Errno(0x4e) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x39) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x42) + ENOTRECOVERABLE = syscall.Errno(0x68) + ENOTSOCK = syscall.Errno(0x26) + ENOTSUP = syscall.Errno(0x2d) + ENOTTY = syscall.Errno(0x19) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x66) + EOVERFLOW = syscall.Errno(0x54) + EOWNERDEAD = syscall.Errno(0x69) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x2e) + EPIPE = syscall.Errno(0x20) + EPROCLIM = syscall.Errno(0x43) + EPROCUNAVAIL = syscall.Errno(0x4c) + EPROGMISMATCH = syscall.Errno(0x4b) + EPROGUNAVAIL = syscall.Errno(0x4a) + EPROTO = syscall.Errno(0x64) + EPROTONOSUPPORT = syscall.Errno(0x2b) + EPROTOTYPE = syscall.Errno(0x29) + EPWROFF = syscall.Errno(0x52) + EQFULL = syscall.Errno(0x6a) + ERANGE = syscall.Errno(0x22) + EREMOTE = syscall.Errno(0x47) + EROFS = syscall.Errno(0x1e) + ERPCMISMATCH = syscall.Errno(0x49) + ESHLIBVERS = syscall.Errno(0x57) + ESHUTDOWN = syscall.Errno(0x3a) + ESOCKTNOSUPPORT = syscall.Errno(0x2c) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESTALE = syscall.Errno(0x46) + ETIME = syscall.Errno(0x65) + ETIMEDOUT = syscall.Errno(0x3c) + ETOOMANYREFS = syscall.Errno(0x3b) + ETXTBSY = syscall.Errno(0x1a) + EUSERS = syscall.Errno(0x44) + EWOULDBLOCK = syscall.Errno(0x23) + EXDEV = syscall.Errno(0x12) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0xa) + SIGCHLD = syscall.Signal(0x14) + SIGCONT = syscall.Signal(0x13) + SIGEMT = syscall.Signal(0x7) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINFO = syscall.Signal(0x1d) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x17) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPROF = syscall.Signal(0x1b) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTOP = syscall.Signal(0x11) + SIGSYS = syscall.Signal(0xc) + SIGTERM = syscall.Signal(0xf) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x12) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGURG = syscall.Signal(0x10) + SIGUSR1 = syscall.Signal(0x1e) + SIGUSR2 = syscall.Signal(0x1f) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "device not configured", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource deadlock avoided", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "resource busy", + 17: "file exists", + 18: "cross-device link", + 19: "operation not supported by device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "result too large", + 35: "resource temporarily unavailable", + 36: "operation now in progress", + 37: "operation already in progress", + 38: "socket operation on non-socket", + 39: "destination address required", + 40: "message too long", + 41: "protocol wrong type for socket", + 42: "protocol not available", + 43: "protocol not supported", + 44: "socket type not supported", + 45: "operation not supported", + 46: "protocol family not supported", + 47: "address family not supported by protocol family", + 48: "address already in use", + 49: "can't assign requested address", + 50: "network is down", + 51: "network is unreachable", + 52: "network dropped connection on reset", + 53: "software caused connection abort", + 54: "connection reset by peer", + 55: "no buffer space available", + 56: "socket is already connected", + 57: "socket is not connected", + 58: "can't send after socket shutdown", + 59: "too many references: can't splice", + 60: "operation timed out", + 61: "connection refused", + 62: "too many levels of symbolic links", + 63: "file name too long", + 64: "host is down", + 65: "no route to host", + 66: "directory not empty", + 67: "too many processes", + 68: "too many users", + 69: "disc quota exceeded", + 70: "stale NFS file handle", + 71: "too many levels of remote in path", + 72: "RPC struct is bad", + 73: "RPC version wrong", + 74: "RPC prog. not avail", + 75: "program version wrong", + 76: "bad procedure for program", + 77: "no locks available", + 78: "function not implemented", + 79: "inappropriate file type or format", + 80: "authentication error", + 81: "need authenticator", + 82: "device power is off", + 83: "device error", + 84: "value too large to be stored in data type", + 85: "bad executable (or shared library)", + 86: "bad CPU type in executable", + 87: "shared library version mismatch", + 88: "malformed Mach-o file", + 89: "operation canceled", + 90: "identifier removed", + 91: "no message of desired type", + 92: "illegal byte sequence", + 93: "attribute not found", + 94: "bad message", + 95: "EMULTIHOP (Reserved)", + 96: "no message available on STREAM", + 97: "ENOLINK (Reserved)", + 98: "no STREAM resources", + 99: "not a STREAM", + 100: "protocol error", + 101: "STREAM ioctl timeout", + 102: "operation not supported on socket", + 103: "policy not found", + 104: "state not recoverable", + 105: "previous owner died", + 106: "interface output queue is full", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/BPT trap", + 6: "abort trap", + 7: "EMT trap", + 8: "floating point exception", + 9: "killed", + 10: "bus error", + 11: "segmentation fault", + 12: "bad system call", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "urgent I/O condition", + 17: "suspended (signal)", + 18: "suspended", + 19: "continued", + 20: "child exited", + 21: "stopped (tty input)", + 22: "stopped (tty output)", + 23: "I/O possible", + 24: "cputime limit exceeded", + 25: "filesize limit exceeded", + 26: "virtual timer expired", + 27: "profiling timer expired", + 28: "window size changes", + 29: "information request", + 30: "user defined signal 1", + 31: "user defined signal 2", +} diff --git a/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go new file mode 100644 index 0000000000..9594f93817 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go @@ -0,0 +1,1576 @@ +// mkerrors.sh -m64 +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build amd64,darwin + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -m64 _const.go + +package unix + +import "syscall" + +const ( + AF_APPLETALK = 0x10 + AF_CCITT = 0xa + AF_CHAOS = 0x5 + AF_CNT = 0x15 + AF_COIP = 0x14 + AF_DATAKIT = 0x9 + AF_DECnet = 0xc + AF_DLI = 0xd + AF_E164 = 0x1c + AF_ECMA = 0x8 + AF_HYLINK = 0xf + AF_IEEE80211 = 0x25 + AF_IMPLINK = 0x3 + AF_INET = 0x2 + AF_INET6 = 0x1e + AF_IPX = 0x17 + AF_ISDN = 0x1c + AF_ISO = 0x7 + AF_LAT = 0xe + AF_LINK = 0x12 + AF_LOCAL = 0x1 + AF_MAX = 0x28 + AF_NATM = 0x1f + AF_NDRV = 0x1b + AF_NETBIOS = 0x21 + AF_NS = 0x6 + AF_OSI = 0x7 + AF_PPP = 0x22 + AF_PUP = 0x4 + AF_RESERVED_36 = 0x24 + AF_ROUTE = 0x11 + AF_SIP = 0x18 + AF_SNA = 0xb + AF_SYSTEM = 0x20 + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_UTUN = 0x26 + B0 = 0x0 + B110 = 0x6e + B115200 = 0x1c200 + B1200 = 0x4b0 + B134 = 0x86 + B14400 = 0x3840 + B150 = 0x96 + B1800 = 0x708 + B19200 = 0x4b00 + B200 = 0xc8 + B230400 = 0x38400 + B2400 = 0x960 + B28800 = 0x7080 + B300 = 0x12c + B38400 = 0x9600 + B4800 = 0x12c0 + B50 = 0x32 + B57600 = 0xe100 + B600 = 0x258 + B7200 = 0x1c20 + B75 = 0x4b + B76800 = 0x12c00 + B9600 = 0x2580 + BIOCFLUSH = 0x20004268 + BIOCGBLEN = 0x40044266 + BIOCGDLT = 0x4004426a + BIOCGDLTLIST = 0xc00c4279 + BIOCGETIF = 0x4020426b + BIOCGHDRCMPLT = 0x40044274 + BIOCGRSIG = 0x40044272 + BIOCGRTIMEOUT = 0x4010426e + BIOCGSEESENT = 0x40044276 + BIOCGSTATS = 0x4008426f + BIOCIMMEDIATE = 0x80044270 + BIOCPROMISC = 0x20004269 + BIOCSBLEN = 0xc0044266 + BIOCSDLT = 0x80044278 + BIOCSETF = 0x80104267 + BIOCSETFNR = 0x8010427e + BIOCSETIF = 0x8020426c + BIOCSHDRCMPLT = 0x80044275 + BIOCSRSIG = 0x80044273 + BIOCSRTIMEOUT = 0x8010426d + BIOCSSEESENT = 0x80044277 + BIOCVERSION = 0x40044271 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALIGNMENT = 0x4 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXBUFSIZE = 0x80000 + BPF_MAXINSNS = 0x200 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINBUFSIZE = 0x20 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RELEASE = 0x30bb6 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BRKINT = 0x2 + CFLUSH = 0xf + CLOCAL = 0x8000 + CREAD = 0x800 + CS5 = 0x0 + CS6 = 0x100 + CS7 = 0x200 + CS8 = 0x300 + CSIZE = 0x300 + CSTART = 0x11 + CSTATUS = 0x14 + CSTOP = 0x13 + CSTOPB = 0x400 + CSUSP = 0x1a + CTL_MAXNAME = 0xc + CTL_NET = 0x4 + DLT_A429 = 0xb8 + DLT_A653_ICM = 0xb9 + DLT_AIRONET_HEADER = 0x78 + DLT_AOS = 0xde + DLT_APPLE_IP_OVER_IEEE1394 = 0x8a + DLT_ARCNET = 0x7 + DLT_ARCNET_LINUX = 0x81 + DLT_ATM_CLIP = 0x13 + DLT_ATM_RFC1483 = 0xb + DLT_AURORA = 0x7e + DLT_AX25 = 0x3 + DLT_AX25_KISS = 0xca + DLT_BACNET_MS_TP = 0xa5 + DLT_BLUETOOTH_HCI_H4 = 0xbb + DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9 + DLT_CAN20B = 0xbe + DLT_CAN_SOCKETCAN = 0xe3 + DLT_CHAOS = 0x5 + DLT_CHDLC = 0x68 + DLT_CISCO_IOS = 0x76 + DLT_C_HDLC = 0x68 + DLT_C_HDLC_WITH_DIR = 0xcd + DLT_DBUS = 0xe7 + DLT_DECT = 0xdd + DLT_DOCSIS = 0x8f + DLT_DVB_CI = 0xeb + DLT_ECONET = 0x73 + DLT_EN10MB = 0x1 + DLT_EN3MB = 0x2 + DLT_ENC = 0x6d + DLT_ERF = 0xc5 + DLT_ERF_ETH = 0xaf + DLT_ERF_POS = 0xb0 + DLT_FC_2 = 0xe0 + DLT_FC_2_WITH_FRAME_DELIMS = 0xe1 + DLT_FDDI = 0xa + DLT_FLEXRAY = 0xd2 + DLT_FRELAY = 0x6b + DLT_FRELAY_WITH_DIR = 0xce + DLT_GCOM_SERIAL = 0xad + DLT_GCOM_T1E1 = 0xac + DLT_GPF_F = 0xab + DLT_GPF_T = 0xaa + DLT_GPRS_LLC = 0xa9 + DLT_GSMTAP_ABIS = 0xda + DLT_GSMTAP_UM = 0xd9 + DLT_HHDLC = 0x79 + DLT_IBM_SN = 0x92 + DLT_IBM_SP = 0x91 + DLT_IEEE802 = 0x6 + DLT_IEEE802_11 = 0x69 + DLT_IEEE802_11_RADIO = 0x7f + DLT_IEEE802_11_RADIO_AVS = 0xa3 + DLT_IEEE802_15_4 = 0xc3 + DLT_IEEE802_15_4_LINUX = 0xbf + DLT_IEEE802_15_4_NOFCS = 0xe6 + DLT_IEEE802_15_4_NONASK_PHY = 0xd7 + DLT_IEEE802_16_MAC_CPS = 0xbc + DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1 + DLT_IPFILTER = 0x74 + DLT_IPMB = 0xc7 + DLT_IPMB_LINUX = 0xd1 + DLT_IPNET = 0xe2 + DLT_IPOIB = 0xf2 + DLT_IPV4 = 0xe4 + DLT_IPV6 = 0xe5 + DLT_IP_OVER_FC = 0x7a + DLT_JUNIPER_ATM1 = 0x89 + DLT_JUNIPER_ATM2 = 0x87 + DLT_JUNIPER_ATM_CEMIC = 0xee + DLT_JUNIPER_CHDLC = 0xb5 + DLT_JUNIPER_ES = 0x84 + DLT_JUNIPER_ETHER = 0xb2 + DLT_JUNIPER_FIBRECHANNEL = 0xea + DLT_JUNIPER_FRELAY = 0xb4 + DLT_JUNIPER_GGSN = 0x85 + DLT_JUNIPER_ISM = 0xc2 + DLT_JUNIPER_MFR = 0x86 + DLT_JUNIPER_MLFR = 0x83 + DLT_JUNIPER_MLPPP = 0x82 + DLT_JUNIPER_MONITOR = 0xa4 + DLT_JUNIPER_PIC_PEER = 0xae + DLT_JUNIPER_PPP = 0xb3 + DLT_JUNIPER_PPPOE = 0xa7 + DLT_JUNIPER_PPPOE_ATM = 0xa8 + DLT_JUNIPER_SERVICES = 0x88 + DLT_JUNIPER_SRX_E2E = 0xe9 + DLT_JUNIPER_ST = 0xc8 + DLT_JUNIPER_VP = 0xb7 + DLT_JUNIPER_VS = 0xe8 + DLT_LAPB_WITH_DIR = 0xcf + DLT_LAPD = 0xcb + DLT_LIN = 0xd4 + DLT_LINUX_EVDEV = 0xd8 + DLT_LINUX_IRDA = 0x90 + DLT_LINUX_LAPD = 0xb1 + DLT_LINUX_PPP_WITHDIRECTION = 0xa6 + DLT_LINUX_SLL = 0x71 + DLT_LOOP = 0x6c + DLT_LTALK = 0x72 + DLT_MATCHING_MAX = 0xf5 + DLT_MATCHING_MIN = 0x68 + DLT_MFR = 0xb6 + DLT_MOST = 0xd3 + DLT_MPEG_2_TS = 0xf3 + DLT_MPLS = 0xdb + DLT_MTP2 = 0x8c + DLT_MTP2_WITH_PHDR = 0x8b + DLT_MTP3 = 0x8d + DLT_MUX27010 = 0xec + DLT_NETANALYZER = 0xf0 + DLT_NETANALYZER_TRANSPARENT = 0xf1 + DLT_NFC_LLCP = 0xf5 + DLT_NFLOG = 0xef + DLT_NG40 = 0xf4 + DLT_NULL = 0x0 + DLT_PCI_EXP = 0x7d + DLT_PFLOG = 0x75 + DLT_PFSYNC = 0x12 + DLT_PPI = 0xc0 + DLT_PPP = 0x9 + DLT_PPP_BSDOS = 0x10 + DLT_PPP_ETHER = 0x33 + DLT_PPP_PPPD = 0xa6 + DLT_PPP_SERIAL = 0x32 + DLT_PPP_WITH_DIR = 0xcc + DLT_PPP_WITH_DIRECTION = 0xa6 + DLT_PRISM_HEADER = 0x77 + DLT_PRONET = 0x4 + DLT_RAIF1 = 0xc6 + DLT_RAW = 0xc + DLT_RIO = 0x7c + DLT_SCCP = 0x8e + DLT_SITA = 0xc4 + DLT_SLIP = 0x8 + DLT_SLIP_BSDOS = 0xf + DLT_STANAG_5066_D_PDU = 0xed + DLT_SUNATM = 0x7b + DLT_SYMANTEC_FIREWALL = 0x63 + DLT_TZSP = 0x80 + DLT_USB = 0xba + DLT_USB_LINUX = 0xbd + DLT_USB_LINUX_MMAPPED = 0xdc + DLT_USER0 = 0x93 + DLT_USER1 = 0x94 + DLT_USER10 = 0x9d + DLT_USER11 = 0x9e + DLT_USER12 = 0x9f + DLT_USER13 = 0xa0 + DLT_USER14 = 0xa1 + DLT_USER15 = 0xa2 + DLT_USER2 = 0x95 + DLT_USER3 = 0x96 + DLT_USER4 = 0x97 + DLT_USER5 = 0x98 + DLT_USER6 = 0x99 + DLT_USER7 = 0x9a + DLT_USER8 = 0x9b + DLT_USER9 = 0x9c + DLT_WIHART = 0xdf + DLT_X2E_SERIAL = 0xd5 + DLT_X2E_XORAYA = 0xd6 + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x40 + ECHOE = 0x2 + ECHOK = 0x4 + ECHOKE = 0x1 + ECHONL = 0x10 + ECHOPRT = 0x20 + EVFILT_AIO = -0x3 + EVFILT_FS = -0x9 + EVFILT_MACHPORT = -0x8 + EVFILT_PROC = -0x5 + EVFILT_READ = -0x1 + EVFILT_SIGNAL = -0x6 + EVFILT_SYSCOUNT = 0xe + EVFILT_THREADMARKER = 0xe + EVFILT_TIMER = -0x7 + EVFILT_USER = -0xa + EVFILT_VM = -0xc + EVFILT_VNODE = -0x4 + EVFILT_WRITE = -0x2 + EV_ADD = 0x1 + EV_CLEAR = 0x20 + EV_DELETE = 0x2 + EV_DISABLE = 0x8 + EV_DISPATCH = 0x80 + EV_ENABLE = 0x4 + EV_EOF = 0x8000 + EV_ERROR = 0x4000 + EV_FLAG0 = 0x1000 + EV_FLAG1 = 0x2000 + EV_ONESHOT = 0x10 + EV_OOBAND = 0x2000 + EV_POLL = 0x1000 + EV_RECEIPT = 0x40 + EV_SYSFLAGS = 0xf000 + EXTA = 0x4b00 + EXTB = 0x9600 + EXTPROC = 0x800 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FLUSHO = 0x800000 + F_ADDFILESIGS = 0x3d + F_ADDSIGS = 0x3b + F_ALLOCATEALL = 0x4 + F_ALLOCATECONTIG = 0x2 + F_CHKCLEAN = 0x29 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x43 + F_FINDSIGS = 0x4e + F_FLUSH_DATA = 0x28 + F_FREEZE_FS = 0x35 + F_FULLFSYNC = 0x33 + F_GETCODEDIR = 0x48 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLK = 0x7 + F_GETLKPID = 0x42 + F_GETNOSIGPIPE = 0x4a + F_GETOWN = 0x5 + F_GETPATH = 0x32 + F_GETPATH_MTMINFO = 0x47 + F_GETPROTECTIONCLASS = 0x3f + F_GETPROTECTIONLEVEL = 0x4d + F_GLOBAL_NOCACHE = 0x37 + F_LOG2PHYS = 0x31 + F_LOG2PHYS_EXT = 0x41 + F_NOCACHE = 0x30 + F_NODIRECT = 0x3e + F_OK = 0x0 + F_PATHPKG_CHECK = 0x34 + F_PEOFPOSMODE = 0x3 + F_PREALLOCATE = 0x2a + F_RDADVISE = 0x2c + F_RDAHEAD = 0x2d + F_RDLCK = 0x1 + F_SETBACKINGSTORE = 0x46 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLK = 0x8 + F_SETLKW = 0x9 + F_SETLKWTIMEOUT = 0xa + F_SETNOSIGPIPE = 0x49 + F_SETOWN = 0x6 + F_SETPROTECTIONCLASS = 0x40 + F_SETSIZE = 0x2b + F_SINGLE_WRITER = 0x4c + F_THAW_FS = 0x36 + F_TRANSCODEKEY = 0x4b + F_UNLCK = 0x2 + F_VOLPOSMODE = 0x4 + F_WRLCK = 0x3 + HUPCL = 0x4000 + ICANON = 0x100 + ICMP6_FILTER = 0x12 + ICRNL = 0x100 + IEXTEN = 0x400 + IFF_ALLMULTI = 0x200 + IFF_ALTPHYS = 0x4000 + IFF_BROADCAST = 0x2 + IFF_DEBUG = 0x4 + IFF_LINK0 = 0x1000 + IFF_LINK1 = 0x2000 + IFF_LINK2 = 0x4000 + IFF_LOOPBACK = 0x8 + IFF_MULTICAST = 0x8000 + IFF_NOARP = 0x80 + IFF_NOTRAILERS = 0x20 + IFF_OACTIVE = 0x400 + IFF_POINTOPOINT = 0x10 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SIMPLEX = 0x800 + IFF_UP = 0x1 + IFNAMSIZ = 0x10 + IFT_1822 = 0x2 + IFT_AAL5 = 0x31 + IFT_ARCNET = 0x23 + IFT_ARCNETPLUS = 0x24 + IFT_ATM = 0x25 + IFT_BRIDGE = 0xd1 + IFT_CARP = 0xf8 + IFT_CELLULAR = 0xff + IFT_CEPT = 0x13 + IFT_DS3 = 0x1e + IFT_ENC = 0xf4 + IFT_EON = 0x19 + IFT_ETHER = 0x6 + IFT_FAITH = 0x38 + IFT_FDDI = 0xf + IFT_FRELAY = 0x20 + IFT_FRELAYDCE = 0x2c + IFT_GIF = 0x37 + IFT_HDH1822 = 0x3 + IFT_HIPPI = 0x2f + IFT_HSSI = 0x2e + IFT_HY = 0xe + IFT_IEEE1394 = 0x90 + IFT_IEEE8023ADLAG = 0x88 + IFT_ISDNBASIC = 0x14 + IFT_ISDNPRIMARY = 0x15 + IFT_ISO88022LLC = 0x29 + IFT_ISO88023 = 0x7 + IFT_ISO88024 = 0x8 + IFT_ISO88025 = 0x9 + IFT_ISO88026 = 0xa + IFT_L2VLAN = 0x87 + IFT_LAPB = 0x10 + IFT_LOCALTALK = 0x2a + IFT_LOOP = 0x18 + IFT_MIOX25 = 0x26 + IFT_MODEM = 0x30 + IFT_NSIP = 0x1b + IFT_OTHER = 0x1 + IFT_P10 = 0xc + IFT_P80 = 0xd + IFT_PARA = 0x22 + IFT_PDP = 0xff + IFT_PFLOG = 0xf5 + IFT_PFSYNC = 0xf6 + IFT_PKTAP = 0xfe + IFT_PPP = 0x17 + IFT_PROPMUX = 0x36 + IFT_PROPVIRTUAL = 0x35 + IFT_PTPSERIAL = 0x16 + IFT_RS232 = 0x21 + IFT_SDLC = 0x11 + IFT_SIP = 0x1f + IFT_SLIP = 0x1c + IFT_SMDSDXI = 0x2b + IFT_SMDSICIP = 0x34 + IFT_SONET = 0x27 + IFT_SONETPATH = 0x32 + IFT_SONETVT = 0x33 + IFT_STARLAN = 0xb + IFT_STF = 0x39 + IFT_T1 = 0x12 + IFT_ULTRA = 0x1d + IFT_V35 = 0x2d + IFT_X25 = 0x5 + IFT_X25DDN = 0x4 + IFT_X25PLE = 0x28 + IFT_XETHER = 0x1a + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLASSD_HOST = 0xfffffff + IN_CLASSD_NET = 0xf0000000 + IN_CLASSD_NSHIFT = 0x1c + IN_LINKLOCALNETNUM = 0xa9fe0000 + IN_LOOPBACKNET = 0x7f + IPPROTO_3PC = 0x22 + IPPROTO_ADFS = 0x44 + IPPROTO_AH = 0x33 + IPPROTO_AHIP = 0x3d + IPPROTO_APES = 0x63 + IPPROTO_ARGUS = 0xd + IPPROTO_AX25 = 0x5d + IPPROTO_BHA = 0x31 + IPPROTO_BLT = 0x1e + IPPROTO_BRSATMON = 0x4c + IPPROTO_CFTP = 0x3e + IPPROTO_CHAOS = 0x10 + IPPROTO_CMTP = 0x26 + IPPROTO_CPHB = 0x49 + IPPROTO_CPNX = 0x48 + IPPROTO_DDP = 0x25 + IPPROTO_DGP = 0x56 + IPPROTO_DIVERT = 0xfe + IPPROTO_DONE = 0x101 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_EMCON = 0xe + IPPROTO_ENCAP = 0x62 + IPPROTO_EON = 0x50 + IPPROTO_ESP = 0x32 + IPPROTO_ETHERIP = 0x61 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GGP = 0x3 + IPPROTO_GMTP = 0x64 + IPPROTO_GRE = 0x2f + IPPROTO_HELLO = 0x3f + IPPROTO_HMP = 0x14 + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IDPR = 0x23 + IPPROTO_IDRP = 0x2d + IPPROTO_IGMP = 0x2 + IPPROTO_IGP = 0x55 + IPPROTO_IGRP = 0x58 + IPPROTO_IL = 0x28 + IPPROTO_INLSP = 0x34 + IPPROTO_INP = 0x20 + IPPROTO_IP = 0x0 + IPPROTO_IPCOMP = 0x6c + IPPROTO_IPCV = 0x47 + IPPROTO_IPEIP = 0x5e + IPPROTO_IPIP = 0x4 + IPPROTO_IPPC = 0x43 + IPPROTO_IPV4 = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_IRTP = 0x1c + IPPROTO_KRYPTOLAN = 0x41 + IPPROTO_LARP = 0x5b + IPPROTO_LEAF1 = 0x19 + IPPROTO_LEAF2 = 0x1a + IPPROTO_MAX = 0x100 + IPPROTO_MAXID = 0x34 + IPPROTO_MEAS = 0x13 + IPPROTO_MHRP = 0x30 + IPPROTO_MICP = 0x5f + IPPROTO_MTP = 0x5c + IPPROTO_MUX = 0x12 + IPPROTO_ND = 0x4d + IPPROTO_NHRP = 0x36 + IPPROTO_NONE = 0x3b + IPPROTO_NSP = 0x1f + IPPROTO_NVPII = 0xb + IPPROTO_OSPFIGP = 0x59 + IPPROTO_PGM = 0x71 + IPPROTO_PIGP = 0x9 + IPPROTO_PIM = 0x67 + IPPROTO_PRM = 0x15 + IPPROTO_PUP = 0xc + IPPROTO_PVP = 0x4b + IPPROTO_RAW = 0xff + IPPROTO_RCCMON = 0xa + IPPROTO_RDP = 0x1b + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_RVD = 0x42 + IPPROTO_SATEXPAK = 0x40 + IPPROTO_SATMON = 0x45 + IPPROTO_SCCSP = 0x60 + IPPROTO_SCTP = 0x84 + IPPROTO_SDRP = 0x2a + IPPROTO_SEP = 0x21 + IPPROTO_SRPC = 0x5a + IPPROTO_ST = 0x7 + IPPROTO_SVMTP = 0x52 + IPPROTO_SWIPE = 0x35 + IPPROTO_TCF = 0x57 + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_TPXX = 0x27 + IPPROTO_TRUNK1 = 0x17 + IPPROTO_TRUNK2 = 0x18 + IPPROTO_TTP = 0x54 + IPPROTO_UDP = 0x11 + IPPROTO_VINES = 0x53 + IPPROTO_VISA = 0x46 + IPPROTO_VMTP = 0x51 + IPPROTO_WBEXPAK = 0x4f + IPPROTO_WBMON = 0x4e + IPPROTO_WSN = 0x4a + IPPROTO_XNET = 0xf + IPPROTO_XTP = 0x24 + IPV6_2292DSTOPTS = 0x17 + IPV6_2292HOPLIMIT = 0x14 + IPV6_2292HOPOPTS = 0x16 + IPV6_2292NEXTHOP = 0x15 + IPV6_2292PKTINFO = 0x13 + IPV6_2292PKTOPTIONS = 0x19 + IPV6_2292RTHDR = 0x18 + IPV6_BINDV6ONLY = 0x1b + IPV6_BOUND_IF = 0x7d + IPV6_CHECKSUM = 0x1a + IPV6_DEFAULT_MULTICAST_HOPS = 0x1 + IPV6_DEFAULT_MULTICAST_LOOP = 0x1 + IPV6_DEFHLIM = 0x40 + IPV6_FAITH = 0x1d + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 + IPV6_FRAGTTL = 0x3c + IPV6_FW_ADD = 0x1e + IPV6_FW_DEL = 0x1f + IPV6_FW_FLUSH = 0x20 + IPV6_FW_GET = 0x22 + IPV6_FW_ZERO = 0x21 + IPV6_HLIMDEC = 0x1 + IPV6_IPSEC_POLICY = 0x1c + IPV6_JOIN_GROUP = 0xc + IPV6_LEAVE_GROUP = 0xd + IPV6_MAXHLIM = 0xff + IPV6_MAXOPTHDR = 0x800 + IPV6_MAXPACKET = 0xffff + IPV6_MAX_GROUP_SRC_FILTER = 0x200 + IPV6_MAX_MEMBERSHIPS = 0xfff + IPV6_MAX_SOCK_SRC_FILTER = 0x80 + IPV6_MIN_MEMBERSHIPS = 0x1f + IPV6_MMTU = 0x500 + IPV6_MULTICAST_HOPS = 0xa + IPV6_MULTICAST_IF = 0x9 + IPV6_MULTICAST_LOOP = 0xb + IPV6_PORTRANGE = 0xe + IPV6_PORTRANGE_DEFAULT = 0x0 + IPV6_PORTRANGE_HIGH = 0x1 + IPV6_PORTRANGE_LOW = 0x2 + IPV6_RECVTCLASS = 0x23 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_SOCKOPT_RESERVED1 = 0x3 + IPV6_TCLASS = 0x24 + IPV6_UNICAST_HOPS = 0x4 + IPV6_V6ONLY = 0x1b + IPV6_VERSION = 0x60 + IPV6_VERSION_MASK = 0xf0 + IP_ADD_MEMBERSHIP = 0xc + IP_ADD_SOURCE_MEMBERSHIP = 0x46 + IP_BLOCK_SOURCE = 0x48 + IP_BOUND_IF = 0x19 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DROP_MEMBERSHIP = 0xd + IP_DROP_SOURCE_MEMBERSHIP = 0x47 + IP_DUMMYNET_CONFIGURE = 0x3c + IP_DUMMYNET_DEL = 0x3d + IP_DUMMYNET_FLUSH = 0x3e + IP_DUMMYNET_GET = 0x40 + IP_FAITH = 0x16 + IP_FW_ADD = 0x28 + IP_FW_DEL = 0x29 + IP_FW_FLUSH = 0x2a + IP_FW_GET = 0x2c + IP_FW_RESETLOG = 0x2d + IP_FW_ZERO = 0x2b + IP_HDRINCL = 0x2 + IP_IPSEC_POLICY = 0x15 + IP_MAXPACKET = 0xffff + IP_MAX_GROUP_SRC_FILTER = 0x200 + IP_MAX_MEMBERSHIPS = 0xfff + IP_MAX_SOCK_MUTE_FILTER = 0x80 + IP_MAX_SOCK_SRC_FILTER = 0x80 + IP_MF = 0x2000 + IP_MIN_MEMBERSHIPS = 0x1f + IP_MSFILTER = 0x4a + IP_MSS = 0x240 + IP_MULTICAST_IF = 0x9 + IP_MULTICAST_IFINDEX = 0x42 + IP_MULTICAST_LOOP = 0xb + IP_MULTICAST_TTL = 0xa + IP_MULTICAST_VIF = 0xe + IP_NAT__XXX = 0x37 + IP_OFFMASK = 0x1fff + IP_OLD_FW_ADD = 0x32 + IP_OLD_FW_DEL = 0x33 + IP_OLD_FW_FLUSH = 0x34 + IP_OLD_FW_GET = 0x36 + IP_OLD_FW_RESETLOG = 0x38 + IP_OLD_FW_ZERO = 0x35 + IP_OPTIONS = 0x1 + IP_PKTINFO = 0x1a + IP_PORTRANGE = 0x13 + IP_PORTRANGE_DEFAULT = 0x0 + IP_PORTRANGE_HIGH = 0x1 + IP_PORTRANGE_LOW = 0x2 + IP_RECVDSTADDR = 0x7 + IP_RECVIF = 0x14 + IP_RECVOPTS = 0x5 + IP_RECVPKTINFO = 0x1a + IP_RECVRETOPTS = 0x6 + IP_RECVTTL = 0x18 + IP_RETOPTS = 0x8 + IP_RF = 0x8000 + IP_RSVP_OFF = 0x10 + IP_RSVP_ON = 0xf + IP_RSVP_VIF_OFF = 0x12 + IP_RSVP_VIF_ON = 0x11 + IP_STRIPHDR = 0x17 + IP_TOS = 0x3 + IP_TRAFFIC_MGT_BACKGROUND = 0x41 + IP_TTL = 0x4 + IP_UNBLOCK_SOURCE = 0x49 + ISIG = 0x80 + ISTRIP = 0x20 + IUTF8 = 0x4000 + IXANY = 0x800 + IXOFF = 0x400 + IXON = 0x200 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_CAN_REUSE = 0x9 + MADV_DONTNEED = 0x4 + MADV_FREE = 0x5 + MADV_FREE_REUSABLE = 0x7 + MADV_FREE_REUSE = 0x8 + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_SEQUENTIAL = 0x2 + MADV_WILLNEED = 0x3 + MADV_ZERO_WIRED_PAGES = 0x6 + MAP_ANON = 0x1000 + MAP_COPY = 0x2 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_HASSEMAPHORE = 0x200 + MAP_JIT = 0x800 + MAP_NOCACHE = 0x400 + MAP_NOEXTEND = 0x100 + MAP_NORESERVE = 0x40 + MAP_PRIVATE = 0x2 + MAP_RENAME = 0x20 + MAP_RESERVED0080 = 0x80 + MAP_SHARED = 0x1 + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MSG_CTRUNC = 0x20 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x80 + MSG_EOF = 0x100 + MSG_EOR = 0x8 + MSG_FLUSH = 0x400 + MSG_HAVEMORE = 0x2000 + MSG_HOLD = 0x800 + MSG_NEEDSA = 0x10000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_RCVMORE = 0x4000 + MSG_SEND = 0x1000 + MSG_TRUNC = 0x10 + MSG_WAITALL = 0x40 + MSG_WAITSTREAM = 0x200 + MS_ASYNC = 0x1 + MS_DEACTIVATE = 0x8 + MS_INVALIDATE = 0x2 + MS_KILLPAGES = 0x4 + MS_SYNC = 0x10 + NAME_MAX = 0xff + NET_RT_DUMP = 0x1 + NET_RT_DUMP2 = 0x7 + NET_RT_FLAGS = 0x2 + NET_RT_IFLIST = 0x3 + NET_RT_IFLIST2 = 0x6 + NET_RT_MAXID = 0xa + NET_RT_STAT = 0x4 + NET_RT_TRASH = 0x5 + NOFLSH = 0x80000000 + NOTE_ABSOLUTE = 0x8 + NOTE_ATTRIB = 0x8 + NOTE_BACKGROUND = 0x40 + NOTE_CHILD = 0x4 + NOTE_CRITICAL = 0x20 + NOTE_DELETE = 0x1 + NOTE_EXEC = 0x20000000 + NOTE_EXIT = 0x80000000 + NOTE_EXITSTATUS = 0x4000000 + NOTE_EXIT_CSERROR = 0x40000 + NOTE_EXIT_DECRYPTFAIL = 0x10000 + NOTE_EXIT_DETAIL = 0x2000000 + NOTE_EXIT_DETAIL_MASK = 0x70000 + NOTE_EXIT_MEMORY = 0x20000 + NOTE_EXIT_REPARENTED = 0x80000 + NOTE_EXTEND = 0x4 + NOTE_FFAND = 0x40000000 + NOTE_FFCOPY = 0xc0000000 + NOTE_FFCTRLMASK = 0xc0000000 + NOTE_FFLAGSMASK = 0xffffff + NOTE_FFNOP = 0x0 + NOTE_FFOR = 0x80000000 + NOTE_FORK = 0x40000000 + NOTE_LEEWAY = 0x10 + NOTE_LINK = 0x10 + NOTE_LOWAT = 0x1 + NOTE_NONE = 0x80 + NOTE_NSECONDS = 0x4 + NOTE_PCTRLMASK = -0x100000 + NOTE_PDATAMASK = 0xfffff + NOTE_REAP = 0x10000000 + NOTE_RENAME = 0x20 + NOTE_REVOKE = 0x40 + NOTE_SECONDS = 0x1 + NOTE_SIGNAL = 0x8000000 + NOTE_TRACK = 0x1 + NOTE_TRACKERR = 0x2 + NOTE_TRIGGER = 0x1000000 + NOTE_USECONDS = 0x2 + NOTE_VM_ERROR = 0x10000000 + NOTE_VM_PRESSURE = 0x80000000 + NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000 + NOTE_VM_PRESSURE_TERMINATE = 0x40000000 + NOTE_WRITE = 0x2 + OCRNL = 0x10 + OFDEL = 0x20000 + OFILL = 0x80 + ONLCR = 0x2 + ONLRET = 0x40 + ONOCR = 0x20 + ONOEOT = 0x8 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_ALERT = 0x20000000 + O_APPEND = 0x8 + O_ASYNC = 0x40 + O_CLOEXEC = 0x1000000 + O_CREAT = 0x200 + O_DIRECTORY = 0x100000 + O_DP_GETRAWENCRYPTED = 0x1 + O_DSYNC = 0x400000 + O_EVTONLY = 0x8000 + O_EXCL = 0x800 + O_EXLOCK = 0x20 + O_FSYNC = 0x80 + O_NDELAY = 0x4 + O_NOCTTY = 0x20000 + O_NOFOLLOW = 0x100 + O_NONBLOCK = 0x4 + O_POPUP = 0x80000000 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_SHLOCK = 0x10 + O_SYMLINK = 0x200000 + O_SYNC = 0x80 + O_TRUNC = 0x400 + O_WRONLY = 0x1 + PARENB = 0x1000 + PARMRK = 0x8 + PARODD = 0x2000 + PENDIN = 0x20000000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + PT_ATTACH = 0xa + PT_ATTACHEXC = 0xe + PT_CONTINUE = 0x7 + PT_DENY_ATTACH = 0x1f + PT_DETACH = 0xb + PT_FIRSTMACH = 0x20 + PT_FORCEQUOTA = 0x1e + PT_KILL = 0x8 + PT_READ_D = 0x2 + PT_READ_I = 0x1 + PT_READ_U = 0x3 + PT_SIGEXC = 0xc + PT_STEP = 0x9 + PT_THUPDATE = 0xd + PT_TRACE_ME = 0x0 + PT_WRITE_D = 0x5 + PT_WRITE_I = 0x4 + PT_WRITE_U = 0x6 + RLIMIT_AS = 0x5 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_CPU_USAGE_MONITOR = 0x2 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x8 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = 0x7fffffffffffffff + RTAX_AUTHOR = 0x6 + RTAX_BRD = 0x7 + RTAX_DST = 0x0 + RTAX_GATEWAY = 0x1 + RTAX_GENMASK = 0x3 + RTAX_IFA = 0x5 + RTAX_IFP = 0x4 + RTAX_MAX = 0x8 + RTAX_NETMASK = 0x2 + RTA_AUTHOR = 0x40 + RTA_BRD = 0x80 + RTA_DST = 0x1 + RTA_GATEWAY = 0x2 + RTA_GENMASK = 0x8 + RTA_IFA = 0x20 + RTA_IFP = 0x10 + RTA_NETMASK = 0x4 + RTF_BLACKHOLE = 0x1000 + RTF_BROADCAST = 0x400000 + RTF_CLONING = 0x100 + RTF_CONDEMNED = 0x2000000 + RTF_DELCLONE = 0x80 + RTF_DONE = 0x40 + RTF_DYNAMIC = 0x10 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_IFREF = 0x4000000 + RTF_IFSCOPE = 0x1000000 + RTF_LLINFO = 0x400 + RTF_LOCAL = 0x200000 + RTF_MODIFIED = 0x20 + RTF_MULTICAST = 0x800000 + RTF_NOIFREF = 0x2000 + RTF_PINNED = 0x100000 + RTF_PRCLONING = 0x10000 + RTF_PROTO1 = 0x8000 + RTF_PROTO2 = 0x4000 + RTF_PROTO3 = 0x40000 + RTF_PROXY = 0x8000000 + RTF_REJECT = 0x8 + RTF_ROUTER = 0x10000000 + RTF_STATIC = 0x800 + RTF_UP = 0x1 + RTF_WASCLONED = 0x20000 + RTF_XRESOLVE = 0x200 + RTM_ADD = 0x1 + RTM_CHANGE = 0x3 + RTM_DELADDR = 0xd + RTM_DELETE = 0x2 + RTM_DELMADDR = 0x10 + RTM_GET = 0x4 + RTM_GET2 = 0x14 + RTM_IFINFO = 0xe + RTM_IFINFO2 = 0x12 + RTM_LOCK = 0x8 + RTM_LOSING = 0x5 + RTM_MISS = 0x7 + RTM_NEWADDR = 0xc + RTM_NEWMADDR = 0xf + RTM_NEWMADDR2 = 0x13 + RTM_OLDADD = 0x9 + RTM_OLDDEL = 0xa + RTM_REDIRECT = 0x6 + RTM_RESOLVE = 0xb + RTM_RTTUNIT = 0xf4240 + RTM_VERSION = 0x5 + RTV_EXPIRE = 0x4 + RTV_HOPCOUNT = 0x2 + RTV_MTU = 0x1 + RTV_RPIPE = 0x8 + RTV_RTT = 0x40 + RTV_RTTVAR = 0x80 + RTV_SPIPE = 0x10 + RTV_SSTHRESH = 0x20 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + SCM_CREDS = 0x3 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x2 + SCM_TIMESTAMP_MONOTONIC = 0x4 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDMULTI = 0x80206931 + SIOCAIFADDR = 0x8040691a + SIOCARPIPLL = 0xc0206928 + SIOCATMARK = 0x40047307 + SIOCAUTOADDR = 0xc0206926 + SIOCAUTONETMASK = 0x80206927 + SIOCDELMULTI = 0x80206932 + SIOCDIFADDR = 0x80206919 + SIOCDIFPHYADDR = 0x80206941 + SIOCGDRVSPEC = 0xc028697b + SIOCGETVLAN = 0xc020697f + SIOCGHIWAT = 0x40047301 + SIOCGIFADDR = 0xc0206921 + SIOCGIFALTMTU = 0xc0206948 + SIOCGIFASYNCMAP = 0xc020697c + SIOCGIFBOND = 0xc0206947 + SIOCGIFBRDADDR = 0xc0206923 + SIOCGIFCAP = 0xc020695b + SIOCGIFCONF = 0xc00c6924 + SIOCGIFDEVMTU = 0xc0206944 + SIOCGIFDSTADDR = 0xc0206922 + SIOCGIFFLAGS = 0xc0206911 + SIOCGIFGENERIC = 0xc020693a + SIOCGIFKPI = 0xc0206987 + SIOCGIFMAC = 0xc0206982 + SIOCGIFMEDIA = 0xc02c6938 + SIOCGIFMETRIC = 0xc0206917 + SIOCGIFMTU = 0xc0206933 + SIOCGIFNETMASK = 0xc0206925 + SIOCGIFPDSTADDR = 0xc0206940 + SIOCGIFPHYS = 0xc0206935 + SIOCGIFPSRCADDR = 0xc020693f + SIOCGIFSTATUS = 0xc331693d + SIOCGIFVLAN = 0xc020697f + SIOCGIFWAKEFLAGS = 0xc0206988 + SIOCGLOWAT = 0x40047303 + SIOCGPGRP = 0x40047309 + SIOCIFCREATE = 0xc0206978 + SIOCIFCREATE2 = 0xc020697a + SIOCIFDESTROY = 0x80206979 + SIOCIFGCLONERS = 0xc0106981 + SIOCRSLVMULTI = 0xc010693b + SIOCSDRVSPEC = 0x8028697b + SIOCSETVLAN = 0x8020697e + SIOCSHIWAT = 0x80047300 + SIOCSIFADDR = 0x8020690c + SIOCSIFALTMTU = 0x80206945 + SIOCSIFASYNCMAP = 0x8020697d + SIOCSIFBOND = 0x80206946 + SIOCSIFBRDADDR = 0x80206913 + SIOCSIFCAP = 0x8020695a + SIOCSIFDSTADDR = 0x8020690e + SIOCSIFFLAGS = 0x80206910 + SIOCSIFGENERIC = 0x80206939 + SIOCSIFKPI = 0x80206986 + SIOCSIFLLADDR = 0x8020693c + SIOCSIFMAC = 0x80206983 + SIOCSIFMEDIA = 0xc0206937 + SIOCSIFMETRIC = 0x80206918 + SIOCSIFMTU = 0x80206934 + SIOCSIFNETMASK = 0x80206916 + SIOCSIFPHYADDR = 0x8040693e + SIOCSIFPHYS = 0x80206936 + SIOCSIFVLAN = 0x8020697e + SIOCSLOWAT = 0x80047302 + SIOCSPGRP = 0x80047308 + SOCK_DGRAM = 0x2 + SOCK_MAXADDRLEN = 0xff + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_SOCKET = 0xffff + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x2 + SO_BROADCAST = 0x20 + SO_DEBUG = 0x1 + SO_DONTROUTE = 0x10 + SO_DONTTRUNC = 0x2000 + SO_ERROR = 0x1007 + SO_KEEPALIVE = 0x8 + SO_LABEL = 0x1010 + SO_LINGER = 0x80 + SO_LINGER_SEC = 0x1080 + SO_NKE = 0x1021 + SO_NOADDRERR = 0x1023 + SO_NOSIGPIPE = 0x1022 + SO_NOTIFYCONFLICT = 0x1026 + SO_NP_EXTENSIONS = 0x1083 + SO_NREAD = 0x1020 + SO_NUMRCVPKT = 0x1112 + SO_NWRITE = 0x1024 + SO_OOBINLINE = 0x100 + SO_PEERLABEL = 0x1011 + SO_RANDOMPORT = 0x1082 + SO_RCVBUF = 0x1002 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x1006 + SO_REUSEADDR = 0x4 + SO_REUSEPORT = 0x200 + SO_REUSESHAREUID = 0x1025 + SO_SNDBUF = 0x1001 + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x1005 + SO_TIMESTAMP = 0x400 + SO_TIMESTAMP_MONOTONIC = 0x800 + SO_TYPE = 0x1008 + SO_UPCALLCLOSEWAIT = 0x1027 + SO_USELOOPBACK = 0x40 + SO_WANTMORE = 0x4000 + SO_WANTOOBFLAG = 0x8000 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IFWHT = 0xe000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISTXT = 0x200 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + TCIFLUSH = 0x1 + TCIOFLUSH = 0x3 + TCOFLUSH = 0x2 + TCP_CONNECTIONTIMEOUT = 0x20 + TCP_ENABLE_ECN = 0x104 + TCP_KEEPALIVE = 0x10 + TCP_KEEPCNT = 0x102 + TCP_KEEPINTVL = 0x101 + TCP_MAXHLEN = 0x3c + TCP_MAXOLEN = 0x28 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_SACK = 0x4 + TCP_MAX_WINSHIFT = 0xe + TCP_MINMSS = 0xd8 + TCP_MSS = 0x200 + TCP_NODELAY = 0x1 + TCP_NOOPT = 0x8 + TCP_NOPUSH = 0x4 + TCP_NOTSENT_LOWAT = 0x201 + TCP_RXT_CONNDROPTIME = 0x80 + TCP_RXT_FINDROP = 0x100 + TCP_SENDMOREACKS = 0x103 + TCSAFLUSH = 0x2 + TIOCCBRK = 0x2000747a + TIOCCDTR = 0x20007478 + TIOCCONS = 0x80047462 + TIOCDCDTIMESTAMP = 0x40107458 + TIOCDRAIN = 0x2000745e + TIOCDSIMICROCODE = 0x20007455 + TIOCEXCL = 0x2000740d + TIOCEXT = 0x80047460 + TIOCFLUSH = 0x80047410 + TIOCGDRAINWAIT = 0x40047456 + TIOCGETA = 0x40487413 + TIOCGETD = 0x4004741a + TIOCGPGRP = 0x40047477 + TIOCGWINSZ = 0x40087468 + TIOCIXOFF = 0x20007480 + TIOCIXON = 0x20007481 + TIOCMBIC = 0x8004746b + TIOCMBIS = 0x8004746c + TIOCMGDTRWAIT = 0x4004745a + TIOCMGET = 0x4004746a + TIOCMODG = 0x40047403 + TIOCMODS = 0x80047404 + TIOCMSDTRWAIT = 0x8004745b + TIOCMSET = 0x8004746d + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x20007471 + TIOCNXCL = 0x2000740e + TIOCOUTQ = 0x40047473 + TIOCPKT = 0x80047470 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCPTYGNAME = 0x40807453 + TIOCPTYGRANT = 0x20007454 + TIOCPTYUNLK = 0x20007452 + TIOCREMOTE = 0x80047469 + TIOCSBRK = 0x2000747b + TIOCSCONS = 0x20007463 + TIOCSCTTY = 0x20007461 + TIOCSDRAINWAIT = 0x80047457 + TIOCSDTR = 0x20007479 + TIOCSETA = 0x80487414 + TIOCSETAF = 0x80487416 + TIOCSETAW = 0x80487415 + TIOCSETD = 0x8004741b + TIOCSIG = 0x2000745f + TIOCSPGRP = 0x80047476 + TIOCSTART = 0x2000746e + TIOCSTAT = 0x20007465 + TIOCSTI = 0x80017472 + TIOCSTOP = 0x2000746f + TIOCSWINSZ = 0x80087467 + TIOCTIMESTAMP = 0x40107459 + TIOCUCNTL = 0x80047466 + TOSTOP = 0x400000 + VDISCARD = 0xf + VDSUSP = 0xb + VEOF = 0x0 + VEOL = 0x1 + VEOL2 = 0x2 + VERASE = 0x3 + VINTR = 0x8 + VKILL = 0x5 + VLNEXT = 0xe + VMIN = 0x10 + VQUIT = 0x9 + VREPRINT = 0x6 + VSTART = 0xc + VSTATUS = 0x12 + VSTOP = 0xd + VSUSP = 0xa + VT0 = 0x0 + VT1 = 0x10000 + VTDLY = 0x10000 + VTIME = 0x11 + VWERASE = 0x4 + WCONTINUED = 0x10 + WCOREFLAG = 0x80 + WEXITED = 0x4 + WNOHANG = 0x1 + WNOWAIT = 0x20 + WORDSIZE = 0x40 + WSTOPPED = 0x8 + WUNTRACED = 0x2 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x30) + EADDRNOTAVAIL = syscall.Errno(0x31) + EAFNOSUPPORT = syscall.Errno(0x2f) + EAGAIN = syscall.Errno(0x23) + EALREADY = syscall.Errno(0x25) + EAUTH = syscall.Errno(0x50) + EBADARCH = syscall.Errno(0x56) + EBADEXEC = syscall.Errno(0x55) + EBADF = syscall.Errno(0x9) + EBADMACHO = syscall.Errno(0x58) + EBADMSG = syscall.Errno(0x5e) + EBADRPC = syscall.Errno(0x48) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x59) + ECHILD = syscall.Errno(0xa) + ECONNABORTED = syscall.Errno(0x35) + ECONNREFUSED = syscall.Errno(0x3d) + ECONNRESET = syscall.Errno(0x36) + EDEADLK = syscall.Errno(0xb) + EDESTADDRREQ = syscall.Errno(0x27) + EDEVERR = syscall.Errno(0x53) + EDOM = syscall.Errno(0x21) + EDQUOT = syscall.Errno(0x45) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EFTYPE = syscall.Errno(0x4f) + EHOSTDOWN = syscall.Errno(0x40) + EHOSTUNREACH = syscall.Errno(0x41) + EIDRM = syscall.Errno(0x5a) + EILSEQ = syscall.Errno(0x5c) + EINPROGRESS = syscall.Errno(0x24) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x38) + EISDIR = syscall.Errno(0x15) + ELAST = syscall.Errno(0x6a) + ELOOP = syscall.Errno(0x3e) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x28) + EMULTIHOP = syscall.Errno(0x5f) + ENAMETOOLONG = syscall.Errno(0x3f) + ENEEDAUTH = syscall.Errno(0x51) + ENETDOWN = syscall.Errno(0x32) + ENETRESET = syscall.Errno(0x34) + ENETUNREACH = syscall.Errno(0x33) + ENFILE = syscall.Errno(0x17) + ENOATTR = syscall.Errno(0x5d) + ENOBUFS = syscall.Errno(0x37) + ENODATA = syscall.Errno(0x60) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOLCK = syscall.Errno(0x4d) + ENOLINK = syscall.Errno(0x61) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x5b) + ENOPOLICY = syscall.Errno(0x67) + ENOPROTOOPT = syscall.Errno(0x2a) + ENOSPC = syscall.Errno(0x1c) + ENOSR = syscall.Errno(0x62) + ENOSTR = syscall.Errno(0x63) + ENOSYS = syscall.Errno(0x4e) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x39) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x42) + ENOTRECOVERABLE = syscall.Errno(0x68) + ENOTSOCK = syscall.Errno(0x26) + ENOTSUP = syscall.Errno(0x2d) + ENOTTY = syscall.Errno(0x19) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x66) + EOVERFLOW = syscall.Errno(0x54) + EOWNERDEAD = syscall.Errno(0x69) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x2e) + EPIPE = syscall.Errno(0x20) + EPROCLIM = syscall.Errno(0x43) + EPROCUNAVAIL = syscall.Errno(0x4c) + EPROGMISMATCH = syscall.Errno(0x4b) + EPROGUNAVAIL = syscall.Errno(0x4a) + EPROTO = syscall.Errno(0x64) + EPROTONOSUPPORT = syscall.Errno(0x2b) + EPROTOTYPE = syscall.Errno(0x29) + EPWROFF = syscall.Errno(0x52) + EQFULL = syscall.Errno(0x6a) + ERANGE = syscall.Errno(0x22) + EREMOTE = syscall.Errno(0x47) + EROFS = syscall.Errno(0x1e) + ERPCMISMATCH = syscall.Errno(0x49) + ESHLIBVERS = syscall.Errno(0x57) + ESHUTDOWN = syscall.Errno(0x3a) + ESOCKTNOSUPPORT = syscall.Errno(0x2c) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESTALE = syscall.Errno(0x46) + ETIME = syscall.Errno(0x65) + ETIMEDOUT = syscall.Errno(0x3c) + ETOOMANYREFS = syscall.Errno(0x3b) + ETXTBSY = syscall.Errno(0x1a) + EUSERS = syscall.Errno(0x44) + EWOULDBLOCK = syscall.Errno(0x23) + EXDEV = syscall.Errno(0x12) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0xa) + SIGCHLD = syscall.Signal(0x14) + SIGCONT = syscall.Signal(0x13) + SIGEMT = syscall.Signal(0x7) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINFO = syscall.Signal(0x1d) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x17) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPROF = syscall.Signal(0x1b) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTOP = syscall.Signal(0x11) + SIGSYS = syscall.Signal(0xc) + SIGTERM = syscall.Signal(0xf) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x12) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGURG = syscall.Signal(0x10) + SIGUSR1 = syscall.Signal(0x1e) + SIGUSR2 = syscall.Signal(0x1f) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "device not configured", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource deadlock avoided", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "resource busy", + 17: "file exists", + 18: "cross-device link", + 19: "operation not supported by device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "result too large", + 35: "resource temporarily unavailable", + 36: "operation now in progress", + 37: "operation already in progress", + 38: "socket operation on non-socket", + 39: "destination address required", + 40: "message too long", + 41: "protocol wrong type for socket", + 42: "protocol not available", + 43: "protocol not supported", + 44: "socket type not supported", + 45: "operation not supported", + 46: "protocol family not supported", + 47: "address family not supported by protocol family", + 48: "address already in use", + 49: "can't assign requested address", + 50: "network is down", + 51: "network is unreachable", + 52: "network dropped connection on reset", + 53: "software caused connection abort", + 54: "connection reset by peer", + 55: "no buffer space available", + 56: "socket is already connected", + 57: "socket is not connected", + 58: "can't send after socket shutdown", + 59: "too many references: can't splice", + 60: "operation timed out", + 61: "connection refused", + 62: "too many levels of symbolic links", + 63: "file name too long", + 64: "host is down", + 65: "no route to host", + 66: "directory not empty", + 67: "too many processes", + 68: "too many users", + 69: "disc quota exceeded", + 70: "stale NFS file handle", + 71: "too many levels of remote in path", + 72: "RPC struct is bad", + 73: "RPC version wrong", + 74: "RPC prog. not avail", + 75: "program version wrong", + 76: "bad procedure for program", + 77: "no locks available", + 78: "function not implemented", + 79: "inappropriate file type or format", + 80: "authentication error", + 81: "need authenticator", + 82: "device power is off", + 83: "device error", + 84: "value too large to be stored in data type", + 85: "bad executable (or shared library)", + 86: "bad CPU type in executable", + 87: "shared library version mismatch", + 88: "malformed Mach-o file", + 89: "operation canceled", + 90: "identifier removed", + 91: "no message of desired type", + 92: "illegal byte sequence", + 93: "attribute not found", + 94: "bad message", + 95: "EMULTIHOP (Reserved)", + 96: "no message available on STREAM", + 97: "ENOLINK (Reserved)", + 98: "no STREAM resources", + 99: "not a STREAM", + 100: "protocol error", + 101: "STREAM ioctl timeout", + 102: "operation not supported on socket", + 103: "policy not found", + 104: "state not recoverable", + 105: "previous owner died", + 106: "interface output queue is full", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/BPT trap", + 6: "abort trap", + 7: "EMT trap", + 8: "floating point exception", + 9: "killed", + 10: "bus error", + 11: "segmentation fault", + 12: "bad system call", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "urgent I/O condition", + 17: "suspended (signal)", + 18: "suspended", + 19: "continued", + 20: "child exited", + 21: "stopped (tty input)", + 22: "stopped (tty output)", + 23: "I/O possible", + 24: "cputime limit exceeded", + 25: "filesize limit exceeded", + 26: "virtual timer expired", + 27: "profiling timer expired", + 28: "window size changes", + 29: "information request", + 30: "user defined signal 1", + 31: "user defined signal 2", +} diff --git a/vendor/golang.org/x/sys/unix/zerrors_darwin_arm.go b/vendor/golang.org/x/sys/unix/zerrors_darwin_arm.go new file mode 100644 index 0000000000..a410e88edd --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_darwin_arm.go @@ -0,0 +1,1293 @@ +// mkerrors.sh +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- _const.go + +// +build arm,darwin + +package unix + +import "syscall" + +const ( + AF_APPLETALK = 0x10 + AF_CCITT = 0xa + AF_CHAOS = 0x5 + AF_CNT = 0x15 + AF_COIP = 0x14 + AF_DATAKIT = 0x9 + AF_DECnet = 0xc + AF_DLI = 0xd + AF_E164 = 0x1c + AF_ECMA = 0x8 + AF_HYLINK = 0xf + AF_IEEE80211 = 0x25 + AF_IMPLINK = 0x3 + AF_INET = 0x2 + AF_INET6 = 0x1e + AF_IPX = 0x17 + AF_ISDN = 0x1c + AF_ISO = 0x7 + AF_LAT = 0xe + AF_LINK = 0x12 + AF_LOCAL = 0x1 + AF_MAX = 0x28 + AF_NATM = 0x1f + AF_NDRV = 0x1b + AF_NETBIOS = 0x21 + AF_NS = 0x6 + AF_OSI = 0x7 + AF_PPP = 0x22 + AF_PUP = 0x4 + AF_RESERVED_36 = 0x24 + AF_ROUTE = 0x11 + AF_SIP = 0x18 + AF_SNA = 0xb + AF_SYSTEM = 0x20 + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_UTUN = 0x26 + B0 = 0x0 + B110 = 0x6e + B115200 = 0x1c200 + B1200 = 0x4b0 + B134 = 0x86 + B14400 = 0x3840 + B150 = 0x96 + B1800 = 0x708 + B19200 = 0x4b00 + B200 = 0xc8 + B230400 = 0x38400 + B2400 = 0x960 + B28800 = 0x7080 + B300 = 0x12c + B38400 = 0x9600 + B4800 = 0x12c0 + B50 = 0x32 + B57600 = 0xe100 + B600 = 0x258 + B7200 = 0x1c20 + B75 = 0x4b + B76800 = 0x12c00 + B9600 = 0x2580 + BIOCFLUSH = 0x20004268 + BIOCGBLEN = 0x40044266 + BIOCGDLT = 0x4004426a + BIOCGDLTLIST = 0xc00c4279 + BIOCGETIF = 0x4020426b + BIOCGHDRCMPLT = 0x40044274 + BIOCGRSIG = 0x40044272 + BIOCGRTIMEOUT = 0x4010426e + BIOCGSEESENT = 0x40044276 + BIOCGSTATS = 0x4008426f + BIOCIMMEDIATE = 0x80044270 + BIOCPROMISC = 0x20004269 + BIOCSBLEN = 0xc0044266 + BIOCSDLT = 0x80044278 + BIOCSETF = 0x80104267 + BIOCSETIF = 0x8020426c + BIOCSHDRCMPLT = 0x80044275 + BIOCSRSIG = 0x80044273 + BIOCSRTIMEOUT = 0x8010426d + BIOCSSEESENT = 0x80044277 + BIOCVERSION = 0x40044271 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALIGNMENT = 0x4 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXBUFSIZE = 0x80000 + BPF_MAXINSNS = 0x200 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINBUFSIZE = 0x20 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RELEASE = 0x30bb6 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BRKINT = 0x2 + CFLUSH = 0xf + CLOCAL = 0x8000 + CREAD = 0x800 + CS5 = 0x0 + CS6 = 0x100 + CS7 = 0x200 + CS8 = 0x300 + CSIZE = 0x300 + CSTART = 0x11 + CSTATUS = 0x14 + CSTOP = 0x13 + CSTOPB = 0x400 + CSUSP = 0x1a + CTL_MAXNAME = 0xc + CTL_NET = 0x4 + DLT_APPLE_IP_OVER_IEEE1394 = 0x8a + DLT_ARCNET = 0x7 + DLT_ATM_CLIP = 0x13 + DLT_ATM_RFC1483 = 0xb + DLT_AX25 = 0x3 + DLT_CHAOS = 0x5 + DLT_CHDLC = 0x68 + DLT_C_HDLC = 0x68 + DLT_EN10MB = 0x1 + DLT_EN3MB = 0x2 + DLT_FDDI = 0xa + DLT_IEEE802 = 0x6 + DLT_IEEE802_11 = 0x69 + DLT_IEEE802_11_RADIO = 0x7f + DLT_IEEE802_11_RADIO_AVS = 0xa3 + DLT_LINUX_SLL = 0x71 + DLT_LOOP = 0x6c + DLT_NULL = 0x0 + DLT_PFLOG = 0x75 + DLT_PFSYNC = 0x12 + DLT_PPP = 0x9 + DLT_PPP_BSDOS = 0x10 + DLT_PPP_SERIAL = 0x32 + DLT_PRONET = 0x4 + DLT_RAW = 0xc + DLT_SLIP = 0x8 + DLT_SLIP_BSDOS = 0xf + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x40 + ECHOE = 0x2 + ECHOK = 0x4 + ECHOKE = 0x1 + ECHONL = 0x10 + ECHOPRT = 0x20 + EVFILT_AIO = -0x3 + EVFILT_FS = -0x9 + EVFILT_MACHPORT = -0x8 + EVFILT_PROC = -0x5 + EVFILT_READ = -0x1 + EVFILT_SIGNAL = -0x6 + EVFILT_SYSCOUNT = 0xe + EVFILT_THREADMARKER = 0xe + EVFILT_TIMER = -0x7 + EVFILT_USER = -0xa + EVFILT_VM = -0xc + EVFILT_VNODE = -0x4 + EVFILT_WRITE = -0x2 + EV_ADD = 0x1 + EV_CLEAR = 0x20 + EV_DELETE = 0x2 + EV_DISABLE = 0x8 + EV_DISPATCH = 0x80 + EV_ENABLE = 0x4 + EV_EOF = 0x8000 + EV_ERROR = 0x4000 + EV_FLAG0 = 0x1000 + EV_FLAG1 = 0x2000 + EV_ONESHOT = 0x10 + EV_OOBAND = 0x2000 + EV_POLL = 0x1000 + EV_RECEIPT = 0x40 + EV_SYSFLAGS = 0xf000 + EXTA = 0x4b00 + EXTB = 0x9600 + EXTPROC = 0x800 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FLUSHO = 0x800000 + F_ADDFILESIGS = 0x3d + F_ADDSIGS = 0x3b + F_ALLOCATEALL = 0x4 + F_ALLOCATECONTIG = 0x2 + F_CHKCLEAN = 0x29 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x43 + F_FINDSIGS = 0x4e + F_FLUSH_DATA = 0x28 + F_FREEZE_FS = 0x35 + F_FULLFSYNC = 0x33 + F_GETCODEDIR = 0x48 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLK = 0x7 + F_GETLKPID = 0x42 + F_GETNOSIGPIPE = 0x4a + F_GETOWN = 0x5 + F_GETPATH = 0x32 + F_GETPATH_MTMINFO = 0x47 + F_GETPROTECTIONCLASS = 0x3f + F_GETPROTECTIONLEVEL = 0x4d + F_GLOBAL_NOCACHE = 0x37 + F_LOG2PHYS = 0x31 + F_LOG2PHYS_EXT = 0x41 + F_NOCACHE = 0x30 + F_NODIRECT = 0x3e + F_OK = 0x0 + F_PATHPKG_CHECK = 0x34 + F_PEOFPOSMODE = 0x3 + F_PREALLOCATE = 0x2a + F_RDADVISE = 0x2c + F_RDAHEAD = 0x2d + F_RDLCK = 0x1 + F_SETBACKINGSTORE = 0x46 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLK = 0x8 + F_SETLKW = 0x9 + F_SETLKWTIMEOUT = 0xa + F_SETNOSIGPIPE = 0x49 + F_SETOWN = 0x6 + F_SETPROTECTIONCLASS = 0x40 + F_SETSIZE = 0x2b + F_SINGLE_WRITER = 0x4c + F_THAW_FS = 0x36 + F_TRANSCODEKEY = 0x4b + F_UNLCK = 0x2 + F_VOLPOSMODE = 0x4 + F_WRLCK = 0x3 + HUPCL = 0x4000 + ICANON = 0x100 + ICMP6_FILTER = 0x12 + ICRNL = 0x100 + IEXTEN = 0x400 + IFF_ALLMULTI = 0x200 + IFF_ALTPHYS = 0x4000 + IFF_BROADCAST = 0x2 + IFF_DEBUG = 0x4 + IFF_LINK0 = 0x1000 + IFF_LINK1 = 0x2000 + IFF_LINK2 = 0x4000 + IFF_LOOPBACK = 0x8 + IFF_MULTICAST = 0x8000 + IFF_NOARP = 0x80 + IFF_NOTRAILERS = 0x20 + IFF_OACTIVE = 0x400 + IFF_POINTOPOINT = 0x10 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SIMPLEX = 0x800 + IFF_UP = 0x1 + IFNAMSIZ = 0x10 + IFT_1822 = 0x2 + IFT_AAL5 = 0x31 + IFT_ARCNET = 0x23 + IFT_ARCNETPLUS = 0x24 + IFT_ATM = 0x25 + IFT_BRIDGE = 0xd1 + IFT_CARP = 0xf8 + IFT_CELLULAR = 0xff + IFT_CEPT = 0x13 + IFT_DS3 = 0x1e + IFT_ENC = 0xf4 + IFT_EON = 0x19 + IFT_ETHER = 0x6 + IFT_FAITH = 0x38 + IFT_FDDI = 0xf + IFT_FRELAY = 0x20 + IFT_FRELAYDCE = 0x2c + IFT_GIF = 0x37 + IFT_HDH1822 = 0x3 + IFT_HIPPI = 0x2f + IFT_HSSI = 0x2e + IFT_HY = 0xe + IFT_IEEE1394 = 0x90 + IFT_IEEE8023ADLAG = 0x88 + IFT_ISDNBASIC = 0x14 + IFT_ISDNPRIMARY = 0x15 + IFT_ISO88022LLC = 0x29 + IFT_ISO88023 = 0x7 + IFT_ISO88024 = 0x8 + IFT_ISO88025 = 0x9 + IFT_ISO88026 = 0xa + IFT_L2VLAN = 0x87 + IFT_LAPB = 0x10 + IFT_LOCALTALK = 0x2a + IFT_LOOP = 0x18 + IFT_MIOX25 = 0x26 + IFT_MODEM = 0x30 + IFT_NSIP = 0x1b + IFT_OTHER = 0x1 + IFT_P10 = 0xc + IFT_P80 = 0xd + IFT_PARA = 0x22 + IFT_PDP = 0xff + IFT_PFLOG = 0xf5 + IFT_PFSYNC = 0xf6 + IFT_PPP = 0x17 + IFT_PROPMUX = 0x36 + IFT_PROPVIRTUAL = 0x35 + IFT_PTPSERIAL = 0x16 + IFT_RS232 = 0x21 + IFT_SDLC = 0x11 + IFT_SIP = 0x1f + IFT_SLIP = 0x1c + IFT_SMDSDXI = 0x2b + IFT_SMDSICIP = 0x34 + IFT_SONET = 0x27 + IFT_SONETPATH = 0x32 + IFT_SONETVT = 0x33 + IFT_STARLAN = 0xb + IFT_STF = 0x39 + IFT_T1 = 0x12 + IFT_ULTRA = 0x1d + IFT_V35 = 0x2d + IFT_X25 = 0x5 + IFT_X25DDN = 0x4 + IFT_X25PLE = 0x28 + IFT_XETHER = 0x1a + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLASSD_HOST = 0xfffffff + IN_CLASSD_NET = 0xf0000000 + IN_CLASSD_NSHIFT = 0x1c + IN_LINKLOCALNETNUM = 0xa9fe0000 + IN_LOOPBACKNET = 0x7f + IPPROTO_3PC = 0x22 + IPPROTO_ADFS = 0x44 + IPPROTO_AH = 0x33 + IPPROTO_AHIP = 0x3d + IPPROTO_APES = 0x63 + IPPROTO_ARGUS = 0xd + IPPROTO_AX25 = 0x5d + IPPROTO_BHA = 0x31 + IPPROTO_BLT = 0x1e + IPPROTO_BRSATMON = 0x4c + IPPROTO_CFTP = 0x3e + IPPROTO_CHAOS = 0x10 + IPPROTO_CMTP = 0x26 + IPPROTO_CPHB = 0x49 + IPPROTO_CPNX = 0x48 + IPPROTO_DDP = 0x25 + IPPROTO_DGP = 0x56 + IPPROTO_DIVERT = 0xfe + IPPROTO_DONE = 0x101 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_EMCON = 0xe + IPPROTO_ENCAP = 0x62 + IPPROTO_EON = 0x50 + IPPROTO_ESP = 0x32 + IPPROTO_ETHERIP = 0x61 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GGP = 0x3 + IPPROTO_GMTP = 0x64 + IPPROTO_GRE = 0x2f + IPPROTO_HELLO = 0x3f + IPPROTO_HMP = 0x14 + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IDPR = 0x23 + IPPROTO_IDRP = 0x2d + IPPROTO_IGMP = 0x2 + IPPROTO_IGP = 0x55 + IPPROTO_IGRP = 0x58 + IPPROTO_IL = 0x28 + IPPROTO_INLSP = 0x34 + IPPROTO_INP = 0x20 + IPPROTO_IP = 0x0 + IPPROTO_IPCOMP = 0x6c + IPPROTO_IPCV = 0x47 + IPPROTO_IPEIP = 0x5e + IPPROTO_IPIP = 0x4 + IPPROTO_IPPC = 0x43 + IPPROTO_IPV4 = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_IRTP = 0x1c + IPPROTO_KRYPTOLAN = 0x41 + IPPROTO_LARP = 0x5b + IPPROTO_LEAF1 = 0x19 + IPPROTO_LEAF2 = 0x1a + IPPROTO_MAX = 0x100 + IPPROTO_MAXID = 0x34 + IPPROTO_MEAS = 0x13 + IPPROTO_MHRP = 0x30 + IPPROTO_MICP = 0x5f + IPPROTO_MTP = 0x5c + IPPROTO_MUX = 0x12 + IPPROTO_ND = 0x4d + IPPROTO_NHRP = 0x36 + IPPROTO_NONE = 0x3b + IPPROTO_NSP = 0x1f + IPPROTO_NVPII = 0xb + IPPROTO_OSPFIGP = 0x59 + IPPROTO_PGM = 0x71 + IPPROTO_PIGP = 0x9 + IPPROTO_PIM = 0x67 + IPPROTO_PRM = 0x15 + IPPROTO_PUP = 0xc + IPPROTO_PVP = 0x4b + IPPROTO_RAW = 0xff + IPPROTO_RCCMON = 0xa + IPPROTO_RDP = 0x1b + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_RVD = 0x42 + IPPROTO_SATEXPAK = 0x40 + IPPROTO_SATMON = 0x45 + IPPROTO_SCCSP = 0x60 + IPPROTO_SCTP = 0x84 + IPPROTO_SDRP = 0x2a + IPPROTO_SEP = 0x21 + IPPROTO_SRPC = 0x5a + IPPROTO_ST = 0x7 + IPPROTO_SVMTP = 0x52 + IPPROTO_SWIPE = 0x35 + IPPROTO_TCF = 0x57 + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_TPXX = 0x27 + IPPROTO_TRUNK1 = 0x17 + IPPROTO_TRUNK2 = 0x18 + IPPROTO_TTP = 0x54 + IPPROTO_UDP = 0x11 + IPPROTO_VINES = 0x53 + IPPROTO_VISA = 0x46 + IPPROTO_VMTP = 0x51 + IPPROTO_WBEXPAK = 0x4f + IPPROTO_WBMON = 0x4e + IPPROTO_WSN = 0x4a + IPPROTO_XNET = 0xf + IPPROTO_XTP = 0x24 + IPV6_2292DSTOPTS = 0x17 + IPV6_2292HOPLIMIT = 0x14 + IPV6_2292HOPOPTS = 0x16 + IPV6_2292NEXTHOP = 0x15 + IPV6_2292PKTINFO = 0x13 + IPV6_2292PKTOPTIONS = 0x19 + IPV6_2292RTHDR = 0x18 + IPV6_BINDV6ONLY = 0x1b + IPV6_BOUND_IF = 0x7d + IPV6_CHECKSUM = 0x1a + IPV6_DEFAULT_MULTICAST_HOPS = 0x1 + IPV6_DEFAULT_MULTICAST_LOOP = 0x1 + IPV6_DEFHLIM = 0x40 + IPV6_FAITH = 0x1d + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 + IPV6_FRAGTTL = 0x78 + IPV6_FW_ADD = 0x1e + IPV6_FW_DEL = 0x1f + IPV6_FW_FLUSH = 0x20 + IPV6_FW_GET = 0x22 + IPV6_FW_ZERO = 0x21 + IPV6_HLIMDEC = 0x1 + IPV6_IPSEC_POLICY = 0x1c + IPV6_JOIN_GROUP = 0xc + IPV6_LEAVE_GROUP = 0xd + IPV6_MAXHLIM = 0xff + IPV6_MAXOPTHDR = 0x800 + IPV6_MAXPACKET = 0xffff + IPV6_MAX_GROUP_SRC_FILTER = 0x200 + IPV6_MAX_MEMBERSHIPS = 0xfff + IPV6_MAX_SOCK_SRC_FILTER = 0x80 + IPV6_MIN_MEMBERSHIPS = 0x1f + IPV6_MMTU = 0x500 + IPV6_MULTICAST_HOPS = 0xa + IPV6_MULTICAST_IF = 0x9 + IPV6_MULTICAST_LOOP = 0xb + IPV6_PORTRANGE = 0xe + IPV6_PORTRANGE_DEFAULT = 0x0 + IPV6_PORTRANGE_HIGH = 0x1 + IPV6_PORTRANGE_LOW = 0x2 + IPV6_RECVTCLASS = 0x23 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_SOCKOPT_RESERVED1 = 0x3 + IPV6_TCLASS = 0x24 + IPV6_UNICAST_HOPS = 0x4 + IPV6_V6ONLY = 0x1b + IPV6_VERSION = 0x60 + IPV6_VERSION_MASK = 0xf0 + IP_ADD_MEMBERSHIP = 0xc + IP_ADD_SOURCE_MEMBERSHIP = 0x46 + IP_BLOCK_SOURCE = 0x48 + IP_BOUND_IF = 0x19 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DROP_MEMBERSHIP = 0xd + IP_DROP_SOURCE_MEMBERSHIP = 0x47 + IP_DUMMYNET_CONFIGURE = 0x3c + IP_DUMMYNET_DEL = 0x3d + IP_DUMMYNET_FLUSH = 0x3e + IP_DUMMYNET_GET = 0x40 + IP_FAITH = 0x16 + IP_FW_ADD = 0x28 + IP_FW_DEL = 0x29 + IP_FW_FLUSH = 0x2a + IP_FW_GET = 0x2c + IP_FW_RESETLOG = 0x2d + IP_FW_ZERO = 0x2b + IP_HDRINCL = 0x2 + IP_IPSEC_POLICY = 0x15 + IP_MAXPACKET = 0xffff + IP_MAX_GROUP_SRC_FILTER = 0x200 + IP_MAX_MEMBERSHIPS = 0xfff + IP_MAX_SOCK_MUTE_FILTER = 0x80 + IP_MAX_SOCK_SRC_FILTER = 0x80 + IP_MF = 0x2000 + IP_MIN_MEMBERSHIPS = 0x1f + IP_MSFILTER = 0x4a + IP_MSS = 0x240 + IP_MULTICAST_IF = 0x9 + IP_MULTICAST_IFINDEX = 0x42 + IP_MULTICAST_LOOP = 0xb + IP_MULTICAST_TTL = 0xa + IP_MULTICAST_VIF = 0xe + IP_NAT__XXX = 0x37 + IP_OFFMASK = 0x1fff + IP_OLD_FW_ADD = 0x32 + IP_OLD_FW_DEL = 0x33 + IP_OLD_FW_FLUSH = 0x34 + IP_OLD_FW_GET = 0x36 + IP_OLD_FW_RESETLOG = 0x38 + IP_OLD_FW_ZERO = 0x35 + IP_OPTIONS = 0x1 + IP_PKTINFO = 0x1a + IP_PORTRANGE = 0x13 + IP_PORTRANGE_DEFAULT = 0x0 + IP_PORTRANGE_HIGH = 0x1 + IP_PORTRANGE_LOW = 0x2 + IP_RECVDSTADDR = 0x7 + IP_RECVIF = 0x14 + IP_RECVOPTS = 0x5 + IP_RECVPKTINFO = 0x1a + IP_RECVRETOPTS = 0x6 + IP_RECVTTL = 0x18 + IP_RETOPTS = 0x8 + IP_RF = 0x8000 + IP_RSVP_OFF = 0x10 + IP_RSVP_ON = 0xf + IP_RSVP_VIF_OFF = 0x12 + IP_RSVP_VIF_ON = 0x11 + IP_STRIPHDR = 0x17 + IP_TOS = 0x3 + IP_TRAFFIC_MGT_BACKGROUND = 0x41 + IP_TTL = 0x4 + IP_UNBLOCK_SOURCE = 0x49 + ISIG = 0x80 + ISTRIP = 0x20 + IUTF8 = 0x4000 + IXANY = 0x800 + IXOFF = 0x400 + IXON = 0x200 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_CAN_REUSE = 0x9 + MADV_DONTNEED = 0x4 + MADV_FREE = 0x5 + MADV_FREE_REUSABLE = 0x7 + MADV_FREE_REUSE = 0x8 + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_SEQUENTIAL = 0x2 + MADV_WILLNEED = 0x3 + MADV_ZERO_WIRED_PAGES = 0x6 + MAP_ANON = 0x1000 + MAP_COPY = 0x2 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_HASSEMAPHORE = 0x200 + MAP_JIT = 0x800 + MAP_NOCACHE = 0x400 + MAP_NOEXTEND = 0x100 + MAP_NORESERVE = 0x40 + MAP_PRIVATE = 0x2 + MAP_RENAME = 0x20 + MAP_RESERVED0080 = 0x80 + MAP_SHARED = 0x1 + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MSG_CTRUNC = 0x20 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x80 + MSG_EOF = 0x100 + MSG_EOR = 0x8 + MSG_FLUSH = 0x400 + MSG_HAVEMORE = 0x2000 + MSG_HOLD = 0x800 + MSG_NEEDSA = 0x10000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_RCVMORE = 0x4000 + MSG_SEND = 0x1000 + MSG_TRUNC = 0x10 + MSG_WAITALL = 0x40 + MSG_WAITSTREAM = 0x200 + MS_ASYNC = 0x1 + MS_DEACTIVATE = 0x8 + MS_INVALIDATE = 0x2 + MS_KILLPAGES = 0x4 + MS_SYNC = 0x10 + NAME_MAX = 0xff + NET_RT_DUMP = 0x1 + NET_RT_DUMP2 = 0x7 + NET_RT_FLAGS = 0x2 + NET_RT_IFLIST = 0x3 + NET_RT_IFLIST2 = 0x6 + NET_RT_MAXID = 0xa + NET_RT_STAT = 0x4 + NET_RT_TRASH = 0x5 + NOFLSH = 0x80000000 + NOTE_ABSOLUTE = 0x8 + NOTE_ATTRIB = 0x8 + NOTE_BACKGROUND = 0x40 + NOTE_CHILD = 0x4 + NOTE_CRITICAL = 0x20 + NOTE_DELETE = 0x1 + NOTE_EXEC = 0x20000000 + NOTE_EXIT = 0x80000000 + NOTE_EXITSTATUS = 0x4000000 + NOTE_EXIT_CSERROR = 0x40000 + NOTE_EXIT_DECRYPTFAIL = 0x10000 + NOTE_EXIT_DETAIL = 0x2000000 + NOTE_EXIT_DETAIL_MASK = 0x70000 + NOTE_EXIT_MEMORY = 0x20000 + NOTE_EXIT_REPARENTED = 0x80000 + NOTE_EXTEND = 0x4 + NOTE_FFAND = 0x40000000 + NOTE_FFCOPY = 0xc0000000 + NOTE_FFCTRLMASK = 0xc0000000 + NOTE_FFLAGSMASK = 0xffffff + NOTE_FFNOP = 0x0 + NOTE_FFOR = 0x80000000 + NOTE_FORK = 0x40000000 + NOTE_LEEWAY = 0x10 + NOTE_LINK = 0x10 + NOTE_LOWAT = 0x1 + NOTE_NONE = 0x80 + NOTE_NSECONDS = 0x4 + NOTE_PCTRLMASK = -0x100000 + NOTE_PDATAMASK = 0xfffff + NOTE_REAP = 0x10000000 + NOTE_RENAME = 0x20 + NOTE_REVOKE = 0x40 + NOTE_SECONDS = 0x1 + NOTE_SIGNAL = 0x8000000 + NOTE_TRACK = 0x1 + NOTE_TRACKERR = 0x2 + NOTE_TRIGGER = 0x1000000 + NOTE_USECONDS = 0x2 + NOTE_VM_ERROR = 0x10000000 + NOTE_VM_PRESSURE = 0x80000000 + NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000 + NOTE_VM_PRESSURE_TERMINATE = 0x40000000 + NOTE_WRITE = 0x2 + OCRNL = 0x10 + OFDEL = 0x20000 + OFILL = 0x80 + ONLCR = 0x2 + ONLRET = 0x40 + ONOCR = 0x20 + ONOEOT = 0x8 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_ALERT = 0x20000000 + O_APPEND = 0x8 + O_ASYNC = 0x40 + O_CLOEXEC = 0x1000000 + O_CREAT = 0x200 + O_DIRECTORY = 0x100000 + O_DP_GETRAWENCRYPTED = 0x1 + O_DSYNC = 0x400000 + O_EVTONLY = 0x8000 + O_EXCL = 0x800 + O_EXLOCK = 0x20 + O_FSYNC = 0x80 + O_NDELAY = 0x4 + O_NOCTTY = 0x20000 + O_NOFOLLOW = 0x100 + O_NONBLOCK = 0x4 + O_POPUP = 0x80000000 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_SHLOCK = 0x10 + O_SYMLINK = 0x200000 + O_SYNC = 0x80 + O_TRUNC = 0x400 + O_WRONLY = 0x1 + PARENB = 0x1000 + PARMRK = 0x8 + PARODD = 0x2000 + PENDIN = 0x20000000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + PT_ATTACH = 0xa + PT_ATTACHEXC = 0xe + PT_CONTINUE = 0x7 + PT_DENY_ATTACH = 0x1f + PT_DETACH = 0xb + PT_FIRSTMACH = 0x20 + PT_FORCEQUOTA = 0x1e + PT_KILL = 0x8 + PT_READ_D = 0x2 + PT_READ_I = 0x1 + PT_READ_U = 0x3 + PT_SIGEXC = 0xc + PT_STEP = 0x9 + PT_THUPDATE = 0xd + PT_TRACE_ME = 0x0 + PT_WRITE_D = 0x5 + PT_WRITE_I = 0x4 + PT_WRITE_U = 0x6 + RLIMIT_AS = 0x5 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_CPU_USAGE_MONITOR = 0x2 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x8 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = 0x7fffffffffffffff + RTAX_AUTHOR = 0x6 + RTAX_BRD = 0x7 + RTAX_DST = 0x0 + RTAX_GATEWAY = 0x1 + RTAX_GENMASK = 0x3 + RTAX_IFA = 0x5 + RTAX_IFP = 0x4 + RTAX_MAX = 0x8 + RTAX_NETMASK = 0x2 + RTA_AUTHOR = 0x40 + RTA_BRD = 0x80 + RTA_DST = 0x1 + RTA_GATEWAY = 0x2 + RTA_GENMASK = 0x8 + RTA_IFA = 0x20 + RTA_IFP = 0x10 + RTA_NETMASK = 0x4 + RTF_BLACKHOLE = 0x1000 + RTF_BROADCAST = 0x400000 + RTF_CLONING = 0x100 + RTF_CONDEMNED = 0x2000000 + RTF_DELCLONE = 0x80 + RTF_DONE = 0x40 + RTF_DYNAMIC = 0x10 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_IFREF = 0x4000000 + RTF_IFSCOPE = 0x1000000 + RTF_LLINFO = 0x400 + RTF_LOCAL = 0x200000 + RTF_MODIFIED = 0x20 + RTF_MULTICAST = 0x800000 + RTF_PINNED = 0x100000 + RTF_PRCLONING = 0x10000 + RTF_PROTO1 = 0x8000 + RTF_PROTO2 = 0x4000 + RTF_PROTO3 = 0x40000 + RTF_PROXY = 0x8000000 + RTF_REJECT = 0x8 + RTF_ROUTER = 0x10000000 + RTF_STATIC = 0x800 + RTF_UP = 0x1 + RTF_WASCLONED = 0x20000 + RTF_XRESOLVE = 0x200 + RTM_ADD = 0x1 + RTM_CHANGE = 0x3 + RTM_DELADDR = 0xd + RTM_DELETE = 0x2 + RTM_DELMADDR = 0x10 + RTM_GET = 0x4 + RTM_GET2 = 0x14 + RTM_IFINFO = 0xe + RTM_IFINFO2 = 0x12 + RTM_LOCK = 0x8 + RTM_LOSING = 0x5 + RTM_MISS = 0x7 + RTM_NEWADDR = 0xc + RTM_NEWMADDR = 0xf + RTM_NEWMADDR2 = 0x13 + RTM_OLDADD = 0x9 + RTM_OLDDEL = 0xa + RTM_REDIRECT = 0x6 + RTM_RESOLVE = 0xb + RTM_RTTUNIT = 0xf4240 + RTM_VERSION = 0x5 + RTV_EXPIRE = 0x4 + RTV_HOPCOUNT = 0x2 + RTV_MTU = 0x1 + RTV_RPIPE = 0x8 + RTV_RTT = 0x40 + RTV_RTTVAR = 0x80 + RTV_SPIPE = 0x10 + RTV_SSTHRESH = 0x20 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + SCM_CREDS = 0x3 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x2 + SCM_TIMESTAMP_MONOTONIC = 0x4 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDMULTI = 0x80206931 + SIOCAIFADDR = 0x8040691a + SIOCARPIPLL = 0xc0206928 + SIOCATMARK = 0x40047307 + SIOCAUTOADDR = 0xc0206926 + SIOCAUTONETMASK = 0x80206927 + SIOCDELMULTI = 0x80206932 + SIOCDIFADDR = 0x80206919 + SIOCDIFPHYADDR = 0x80206941 + SIOCGDRVSPEC = 0xc028697b + SIOCGETVLAN = 0xc020697f + SIOCGHIWAT = 0x40047301 + SIOCGIFADDR = 0xc0206921 + SIOCGIFALTMTU = 0xc0206948 + SIOCGIFASYNCMAP = 0xc020697c + SIOCGIFBOND = 0xc0206947 + SIOCGIFBRDADDR = 0xc0206923 + SIOCGIFCAP = 0xc020695b + SIOCGIFCONF = 0xc00c6924 + SIOCGIFDEVMTU = 0xc0206944 + SIOCGIFDSTADDR = 0xc0206922 + SIOCGIFFLAGS = 0xc0206911 + SIOCGIFGENERIC = 0xc020693a + SIOCGIFKPI = 0xc0206987 + SIOCGIFMAC = 0xc0206982 + SIOCGIFMEDIA = 0xc02c6938 + SIOCGIFMETRIC = 0xc0206917 + SIOCGIFMTU = 0xc0206933 + SIOCGIFNETMASK = 0xc0206925 + SIOCGIFPDSTADDR = 0xc0206940 + SIOCGIFPHYS = 0xc0206935 + SIOCGIFPSRCADDR = 0xc020693f + SIOCGIFSTATUS = 0xc331693d + SIOCGIFVLAN = 0xc020697f + SIOCGIFWAKEFLAGS = 0xc0206988 + SIOCGLOWAT = 0x40047303 + SIOCGPGRP = 0x40047309 + SIOCIFCREATE = 0xc0206978 + SIOCIFCREATE2 = 0xc020697a + SIOCIFDESTROY = 0x80206979 + SIOCIFGCLONERS = 0xc0106981 + SIOCRSLVMULTI = 0xc010693b + SIOCSDRVSPEC = 0x8028697b + SIOCSETVLAN = 0x8020697e + SIOCSHIWAT = 0x80047300 + SIOCSIFADDR = 0x8020690c + SIOCSIFALTMTU = 0x80206945 + SIOCSIFASYNCMAP = 0x8020697d + SIOCSIFBOND = 0x80206946 + SIOCSIFBRDADDR = 0x80206913 + SIOCSIFCAP = 0x8020695a + SIOCSIFDSTADDR = 0x8020690e + SIOCSIFFLAGS = 0x80206910 + SIOCSIFGENERIC = 0x80206939 + SIOCSIFKPI = 0x80206986 + SIOCSIFLLADDR = 0x8020693c + SIOCSIFMAC = 0x80206983 + SIOCSIFMEDIA = 0xc0206937 + SIOCSIFMETRIC = 0x80206918 + SIOCSIFMTU = 0x80206934 + SIOCSIFNETMASK = 0x80206916 + SIOCSIFPHYADDR = 0x8040693e + SIOCSIFPHYS = 0x80206936 + SIOCSIFVLAN = 0x8020697e + SIOCSLOWAT = 0x80047302 + SIOCSPGRP = 0x80047308 + SOCK_DGRAM = 0x2 + SOCK_MAXADDRLEN = 0xff + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_SOCKET = 0xffff + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x2 + SO_BROADCAST = 0x20 + SO_DEBUG = 0x1 + SO_DONTROUTE = 0x10 + SO_DONTTRUNC = 0x2000 + SO_ERROR = 0x1007 + SO_KEEPALIVE = 0x8 + SO_LABEL = 0x1010 + SO_LINGER = 0x80 + SO_LINGER_SEC = 0x1080 + SO_NKE = 0x1021 + SO_NOADDRERR = 0x1023 + SO_NOSIGPIPE = 0x1022 + SO_NOTIFYCONFLICT = 0x1026 + SO_NP_EXTENSIONS = 0x1083 + SO_NREAD = 0x1020 + SO_NUMRCVPKT = 0x1112 + SO_NWRITE = 0x1024 + SO_OOBINLINE = 0x100 + SO_PEERLABEL = 0x1011 + SO_RANDOMPORT = 0x1082 + SO_RCVBUF = 0x1002 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x1006 + SO_REUSEADDR = 0x4 + SO_REUSEPORT = 0x200 + SO_REUSESHAREUID = 0x1025 + SO_SNDBUF = 0x1001 + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x1005 + SO_TIMESTAMP = 0x400 + SO_TIMESTAMP_MONOTONIC = 0x800 + SO_TYPE = 0x1008 + SO_UPCALLCLOSEWAIT = 0x1027 + SO_USELOOPBACK = 0x40 + SO_WANTMORE = 0x4000 + SO_WANTOOBFLAG = 0x8000 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IFWHT = 0xe000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISTXT = 0x200 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + TCIFLUSH = 0x1 + TCIOFLUSH = 0x3 + TCOFLUSH = 0x2 + TCP_CONNECTIONTIMEOUT = 0x20 + TCP_ENABLE_ECN = 0x104 + TCP_KEEPALIVE = 0x10 + TCP_KEEPCNT = 0x102 + TCP_KEEPINTVL = 0x101 + TCP_MAXHLEN = 0x3c + TCP_MAXOLEN = 0x28 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_SACK = 0x4 + TCP_MAX_WINSHIFT = 0xe + TCP_MINMSS = 0xd8 + TCP_MSS = 0x200 + TCP_NODELAY = 0x1 + TCP_NOOPT = 0x8 + TCP_NOPUSH = 0x4 + TCP_NOTSENT_LOWAT = 0x201 + TCP_RXT_CONNDROPTIME = 0x80 + TCP_RXT_FINDROP = 0x100 + TCP_SENDMOREACKS = 0x103 + TCSAFLUSH = 0x2 + TIOCCBRK = 0x2000747a + TIOCCDTR = 0x20007478 + TIOCCONS = 0x80047462 + TIOCDCDTIMESTAMP = 0x40107458 + TIOCDRAIN = 0x2000745e + TIOCDSIMICROCODE = 0x20007455 + TIOCEXCL = 0x2000740d + TIOCEXT = 0x80047460 + TIOCFLUSH = 0x80047410 + TIOCGDRAINWAIT = 0x40047456 + TIOCGETA = 0x40487413 + TIOCGETD = 0x4004741a + TIOCGPGRP = 0x40047477 + TIOCGWINSZ = 0x40087468 + TIOCIXOFF = 0x20007480 + TIOCIXON = 0x20007481 + TIOCMBIC = 0x8004746b + TIOCMBIS = 0x8004746c + TIOCMGDTRWAIT = 0x4004745a + TIOCMGET = 0x4004746a + TIOCMODG = 0x40047403 + TIOCMODS = 0x80047404 + TIOCMSDTRWAIT = 0x8004745b + TIOCMSET = 0x8004746d + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x20007471 + TIOCNXCL = 0x2000740e + TIOCOUTQ = 0x40047473 + TIOCPKT = 0x80047470 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCPTYGNAME = 0x40807453 + TIOCPTYGRANT = 0x20007454 + TIOCPTYUNLK = 0x20007452 + TIOCREMOTE = 0x80047469 + TIOCSBRK = 0x2000747b + TIOCSCONS = 0x20007463 + TIOCSCTTY = 0x20007461 + TIOCSDRAINWAIT = 0x80047457 + TIOCSDTR = 0x20007479 + TIOCSETA = 0x80487414 + TIOCSETAF = 0x80487416 + TIOCSETAW = 0x80487415 + TIOCSETD = 0x8004741b + TIOCSIG = 0x2000745f + TIOCSPGRP = 0x80047476 + TIOCSTART = 0x2000746e + TIOCSTAT = 0x20007465 + TIOCSTI = 0x80017472 + TIOCSTOP = 0x2000746f + TIOCSWINSZ = 0x80087467 + TIOCTIMESTAMP = 0x40107459 + TIOCUCNTL = 0x80047466 + TOSTOP = 0x400000 + VDISCARD = 0xf + VDSUSP = 0xb + VEOF = 0x0 + VEOL = 0x1 + VEOL2 = 0x2 + VERASE = 0x3 + VINTR = 0x8 + VKILL = 0x5 + VLNEXT = 0xe + VMIN = 0x10 + VQUIT = 0x9 + VREPRINT = 0x6 + VSTART = 0xc + VSTATUS = 0x12 + VSTOP = 0xd + VSUSP = 0xa + VT0 = 0x0 + VT1 = 0x10000 + VTDLY = 0x10000 + VTIME = 0x11 + VWERASE = 0x4 + WCONTINUED = 0x10 + WCOREFLAG = 0x80 + WEXITED = 0x4 + WNOHANG = 0x1 + WNOWAIT = 0x20 + WORDSIZE = 0x40 + WSTOPPED = 0x8 + WUNTRACED = 0x2 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x30) + EADDRNOTAVAIL = syscall.Errno(0x31) + EAFNOSUPPORT = syscall.Errno(0x2f) + EAGAIN = syscall.Errno(0x23) + EALREADY = syscall.Errno(0x25) + EAUTH = syscall.Errno(0x50) + EBADARCH = syscall.Errno(0x56) + EBADEXEC = syscall.Errno(0x55) + EBADF = syscall.Errno(0x9) + EBADMACHO = syscall.Errno(0x58) + EBADMSG = syscall.Errno(0x5e) + EBADRPC = syscall.Errno(0x48) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x59) + ECHILD = syscall.Errno(0xa) + ECONNABORTED = syscall.Errno(0x35) + ECONNREFUSED = syscall.Errno(0x3d) + ECONNRESET = syscall.Errno(0x36) + EDEADLK = syscall.Errno(0xb) + EDESTADDRREQ = syscall.Errno(0x27) + EDEVERR = syscall.Errno(0x53) + EDOM = syscall.Errno(0x21) + EDQUOT = syscall.Errno(0x45) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EFTYPE = syscall.Errno(0x4f) + EHOSTDOWN = syscall.Errno(0x40) + EHOSTUNREACH = syscall.Errno(0x41) + EIDRM = syscall.Errno(0x5a) + EILSEQ = syscall.Errno(0x5c) + EINPROGRESS = syscall.Errno(0x24) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x38) + EISDIR = syscall.Errno(0x15) + ELAST = syscall.Errno(0x6a) + ELOOP = syscall.Errno(0x3e) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x28) + EMULTIHOP = syscall.Errno(0x5f) + ENAMETOOLONG = syscall.Errno(0x3f) + ENEEDAUTH = syscall.Errno(0x51) + ENETDOWN = syscall.Errno(0x32) + ENETRESET = syscall.Errno(0x34) + ENETUNREACH = syscall.Errno(0x33) + ENFILE = syscall.Errno(0x17) + ENOATTR = syscall.Errno(0x5d) + ENOBUFS = syscall.Errno(0x37) + ENODATA = syscall.Errno(0x60) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOLCK = syscall.Errno(0x4d) + ENOLINK = syscall.Errno(0x61) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x5b) + ENOPOLICY = syscall.Errno(0x67) + ENOPROTOOPT = syscall.Errno(0x2a) + ENOSPC = syscall.Errno(0x1c) + ENOSR = syscall.Errno(0x62) + ENOSTR = syscall.Errno(0x63) + ENOSYS = syscall.Errno(0x4e) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x39) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x42) + ENOTRECOVERABLE = syscall.Errno(0x68) + ENOTSOCK = syscall.Errno(0x26) + ENOTSUP = syscall.Errno(0x2d) + ENOTTY = syscall.Errno(0x19) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x66) + EOVERFLOW = syscall.Errno(0x54) + EOWNERDEAD = syscall.Errno(0x69) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x2e) + EPIPE = syscall.Errno(0x20) + EPROCLIM = syscall.Errno(0x43) + EPROCUNAVAIL = syscall.Errno(0x4c) + EPROGMISMATCH = syscall.Errno(0x4b) + EPROGUNAVAIL = syscall.Errno(0x4a) + EPROTO = syscall.Errno(0x64) + EPROTONOSUPPORT = syscall.Errno(0x2b) + EPROTOTYPE = syscall.Errno(0x29) + EPWROFF = syscall.Errno(0x52) + EQFULL = syscall.Errno(0x6a) + ERANGE = syscall.Errno(0x22) + EREMOTE = syscall.Errno(0x47) + EROFS = syscall.Errno(0x1e) + ERPCMISMATCH = syscall.Errno(0x49) + ESHLIBVERS = syscall.Errno(0x57) + ESHUTDOWN = syscall.Errno(0x3a) + ESOCKTNOSUPPORT = syscall.Errno(0x2c) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESTALE = syscall.Errno(0x46) + ETIME = syscall.Errno(0x65) + ETIMEDOUT = syscall.Errno(0x3c) + ETOOMANYREFS = syscall.Errno(0x3b) + ETXTBSY = syscall.Errno(0x1a) + EUSERS = syscall.Errno(0x44) + EWOULDBLOCK = syscall.Errno(0x23) + EXDEV = syscall.Errno(0x12) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0xa) + SIGCHLD = syscall.Signal(0x14) + SIGCONT = syscall.Signal(0x13) + SIGEMT = syscall.Signal(0x7) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINFO = syscall.Signal(0x1d) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x17) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPROF = syscall.Signal(0x1b) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTOP = syscall.Signal(0x11) + SIGSYS = syscall.Signal(0xc) + SIGTERM = syscall.Signal(0xf) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x12) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGURG = syscall.Signal(0x10) + SIGUSR1 = syscall.Signal(0x1e) + SIGUSR2 = syscall.Signal(0x1f) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) diff --git a/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go new file mode 100644 index 0000000000..3189c6b345 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go @@ -0,0 +1,1576 @@ +// mkerrors.sh -m64 +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build arm64,darwin + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -m64 _const.go + +package unix + +import "syscall" + +const ( + AF_APPLETALK = 0x10 + AF_CCITT = 0xa + AF_CHAOS = 0x5 + AF_CNT = 0x15 + AF_COIP = 0x14 + AF_DATAKIT = 0x9 + AF_DECnet = 0xc + AF_DLI = 0xd + AF_E164 = 0x1c + AF_ECMA = 0x8 + AF_HYLINK = 0xf + AF_IEEE80211 = 0x25 + AF_IMPLINK = 0x3 + AF_INET = 0x2 + AF_INET6 = 0x1e + AF_IPX = 0x17 + AF_ISDN = 0x1c + AF_ISO = 0x7 + AF_LAT = 0xe + AF_LINK = 0x12 + AF_LOCAL = 0x1 + AF_MAX = 0x28 + AF_NATM = 0x1f + AF_NDRV = 0x1b + AF_NETBIOS = 0x21 + AF_NS = 0x6 + AF_OSI = 0x7 + AF_PPP = 0x22 + AF_PUP = 0x4 + AF_RESERVED_36 = 0x24 + AF_ROUTE = 0x11 + AF_SIP = 0x18 + AF_SNA = 0xb + AF_SYSTEM = 0x20 + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_UTUN = 0x26 + B0 = 0x0 + B110 = 0x6e + B115200 = 0x1c200 + B1200 = 0x4b0 + B134 = 0x86 + B14400 = 0x3840 + B150 = 0x96 + B1800 = 0x708 + B19200 = 0x4b00 + B200 = 0xc8 + B230400 = 0x38400 + B2400 = 0x960 + B28800 = 0x7080 + B300 = 0x12c + B38400 = 0x9600 + B4800 = 0x12c0 + B50 = 0x32 + B57600 = 0xe100 + B600 = 0x258 + B7200 = 0x1c20 + B75 = 0x4b + B76800 = 0x12c00 + B9600 = 0x2580 + BIOCFLUSH = 0x20004268 + BIOCGBLEN = 0x40044266 + BIOCGDLT = 0x4004426a + BIOCGDLTLIST = 0xc00c4279 + BIOCGETIF = 0x4020426b + BIOCGHDRCMPLT = 0x40044274 + BIOCGRSIG = 0x40044272 + BIOCGRTIMEOUT = 0x4010426e + BIOCGSEESENT = 0x40044276 + BIOCGSTATS = 0x4008426f + BIOCIMMEDIATE = 0x80044270 + BIOCPROMISC = 0x20004269 + BIOCSBLEN = 0xc0044266 + BIOCSDLT = 0x80044278 + BIOCSETF = 0x80104267 + BIOCSETFNR = 0x8010427e + BIOCSETIF = 0x8020426c + BIOCSHDRCMPLT = 0x80044275 + BIOCSRSIG = 0x80044273 + BIOCSRTIMEOUT = 0x8010426d + BIOCSSEESENT = 0x80044277 + BIOCVERSION = 0x40044271 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALIGNMENT = 0x4 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXBUFSIZE = 0x80000 + BPF_MAXINSNS = 0x200 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINBUFSIZE = 0x20 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RELEASE = 0x30bb6 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BRKINT = 0x2 + CFLUSH = 0xf + CLOCAL = 0x8000 + CREAD = 0x800 + CS5 = 0x0 + CS6 = 0x100 + CS7 = 0x200 + CS8 = 0x300 + CSIZE = 0x300 + CSTART = 0x11 + CSTATUS = 0x14 + CSTOP = 0x13 + CSTOPB = 0x400 + CSUSP = 0x1a + CTL_MAXNAME = 0xc + CTL_NET = 0x4 + DLT_A429 = 0xb8 + DLT_A653_ICM = 0xb9 + DLT_AIRONET_HEADER = 0x78 + DLT_AOS = 0xde + DLT_APPLE_IP_OVER_IEEE1394 = 0x8a + DLT_ARCNET = 0x7 + DLT_ARCNET_LINUX = 0x81 + DLT_ATM_CLIP = 0x13 + DLT_ATM_RFC1483 = 0xb + DLT_AURORA = 0x7e + DLT_AX25 = 0x3 + DLT_AX25_KISS = 0xca + DLT_BACNET_MS_TP = 0xa5 + DLT_BLUETOOTH_HCI_H4 = 0xbb + DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9 + DLT_CAN20B = 0xbe + DLT_CAN_SOCKETCAN = 0xe3 + DLT_CHAOS = 0x5 + DLT_CHDLC = 0x68 + DLT_CISCO_IOS = 0x76 + DLT_C_HDLC = 0x68 + DLT_C_HDLC_WITH_DIR = 0xcd + DLT_DBUS = 0xe7 + DLT_DECT = 0xdd + DLT_DOCSIS = 0x8f + DLT_DVB_CI = 0xeb + DLT_ECONET = 0x73 + DLT_EN10MB = 0x1 + DLT_EN3MB = 0x2 + DLT_ENC = 0x6d + DLT_ERF = 0xc5 + DLT_ERF_ETH = 0xaf + DLT_ERF_POS = 0xb0 + DLT_FC_2 = 0xe0 + DLT_FC_2_WITH_FRAME_DELIMS = 0xe1 + DLT_FDDI = 0xa + DLT_FLEXRAY = 0xd2 + DLT_FRELAY = 0x6b + DLT_FRELAY_WITH_DIR = 0xce + DLT_GCOM_SERIAL = 0xad + DLT_GCOM_T1E1 = 0xac + DLT_GPF_F = 0xab + DLT_GPF_T = 0xaa + DLT_GPRS_LLC = 0xa9 + DLT_GSMTAP_ABIS = 0xda + DLT_GSMTAP_UM = 0xd9 + DLT_HHDLC = 0x79 + DLT_IBM_SN = 0x92 + DLT_IBM_SP = 0x91 + DLT_IEEE802 = 0x6 + DLT_IEEE802_11 = 0x69 + DLT_IEEE802_11_RADIO = 0x7f + DLT_IEEE802_11_RADIO_AVS = 0xa3 + DLT_IEEE802_15_4 = 0xc3 + DLT_IEEE802_15_4_LINUX = 0xbf + DLT_IEEE802_15_4_NOFCS = 0xe6 + DLT_IEEE802_15_4_NONASK_PHY = 0xd7 + DLT_IEEE802_16_MAC_CPS = 0xbc + DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1 + DLT_IPFILTER = 0x74 + DLT_IPMB = 0xc7 + DLT_IPMB_LINUX = 0xd1 + DLT_IPNET = 0xe2 + DLT_IPOIB = 0xf2 + DLT_IPV4 = 0xe4 + DLT_IPV6 = 0xe5 + DLT_IP_OVER_FC = 0x7a + DLT_JUNIPER_ATM1 = 0x89 + DLT_JUNIPER_ATM2 = 0x87 + DLT_JUNIPER_ATM_CEMIC = 0xee + DLT_JUNIPER_CHDLC = 0xb5 + DLT_JUNIPER_ES = 0x84 + DLT_JUNIPER_ETHER = 0xb2 + DLT_JUNIPER_FIBRECHANNEL = 0xea + DLT_JUNIPER_FRELAY = 0xb4 + DLT_JUNIPER_GGSN = 0x85 + DLT_JUNIPER_ISM = 0xc2 + DLT_JUNIPER_MFR = 0x86 + DLT_JUNIPER_MLFR = 0x83 + DLT_JUNIPER_MLPPP = 0x82 + DLT_JUNIPER_MONITOR = 0xa4 + DLT_JUNIPER_PIC_PEER = 0xae + DLT_JUNIPER_PPP = 0xb3 + DLT_JUNIPER_PPPOE = 0xa7 + DLT_JUNIPER_PPPOE_ATM = 0xa8 + DLT_JUNIPER_SERVICES = 0x88 + DLT_JUNIPER_SRX_E2E = 0xe9 + DLT_JUNIPER_ST = 0xc8 + DLT_JUNIPER_VP = 0xb7 + DLT_JUNIPER_VS = 0xe8 + DLT_LAPB_WITH_DIR = 0xcf + DLT_LAPD = 0xcb + DLT_LIN = 0xd4 + DLT_LINUX_EVDEV = 0xd8 + DLT_LINUX_IRDA = 0x90 + DLT_LINUX_LAPD = 0xb1 + DLT_LINUX_PPP_WITHDIRECTION = 0xa6 + DLT_LINUX_SLL = 0x71 + DLT_LOOP = 0x6c + DLT_LTALK = 0x72 + DLT_MATCHING_MAX = 0xf5 + DLT_MATCHING_MIN = 0x68 + DLT_MFR = 0xb6 + DLT_MOST = 0xd3 + DLT_MPEG_2_TS = 0xf3 + DLT_MPLS = 0xdb + DLT_MTP2 = 0x8c + DLT_MTP2_WITH_PHDR = 0x8b + DLT_MTP3 = 0x8d + DLT_MUX27010 = 0xec + DLT_NETANALYZER = 0xf0 + DLT_NETANALYZER_TRANSPARENT = 0xf1 + DLT_NFC_LLCP = 0xf5 + DLT_NFLOG = 0xef + DLT_NG40 = 0xf4 + DLT_NULL = 0x0 + DLT_PCI_EXP = 0x7d + DLT_PFLOG = 0x75 + DLT_PFSYNC = 0x12 + DLT_PPI = 0xc0 + DLT_PPP = 0x9 + DLT_PPP_BSDOS = 0x10 + DLT_PPP_ETHER = 0x33 + DLT_PPP_PPPD = 0xa6 + DLT_PPP_SERIAL = 0x32 + DLT_PPP_WITH_DIR = 0xcc + DLT_PPP_WITH_DIRECTION = 0xa6 + DLT_PRISM_HEADER = 0x77 + DLT_PRONET = 0x4 + DLT_RAIF1 = 0xc6 + DLT_RAW = 0xc + DLT_RIO = 0x7c + DLT_SCCP = 0x8e + DLT_SITA = 0xc4 + DLT_SLIP = 0x8 + DLT_SLIP_BSDOS = 0xf + DLT_STANAG_5066_D_PDU = 0xed + DLT_SUNATM = 0x7b + DLT_SYMANTEC_FIREWALL = 0x63 + DLT_TZSP = 0x80 + DLT_USB = 0xba + DLT_USB_LINUX = 0xbd + DLT_USB_LINUX_MMAPPED = 0xdc + DLT_USER0 = 0x93 + DLT_USER1 = 0x94 + DLT_USER10 = 0x9d + DLT_USER11 = 0x9e + DLT_USER12 = 0x9f + DLT_USER13 = 0xa0 + DLT_USER14 = 0xa1 + DLT_USER15 = 0xa2 + DLT_USER2 = 0x95 + DLT_USER3 = 0x96 + DLT_USER4 = 0x97 + DLT_USER5 = 0x98 + DLT_USER6 = 0x99 + DLT_USER7 = 0x9a + DLT_USER8 = 0x9b + DLT_USER9 = 0x9c + DLT_WIHART = 0xdf + DLT_X2E_SERIAL = 0xd5 + DLT_X2E_XORAYA = 0xd6 + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x40 + ECHOE = 0x2 + ECHOK = 0x4 + ECHOKE = 0x1 + ECHONL = 0x10 + ECHOPRT = 0x20 + EVFILT_AIO = -0x3 + EVFILT_FS = -0x9 + EVFILT_MACHPORT = -0x8 + EVFILT_PROC = -0x5 + EVFILT_READ = -0x1 + EVFILT_SIGNAL = -0x6 + EVFILT_SYSCOUNT = 0xe + EVFILT_THREADMARKER = 0xe + EVFILT_TIMER = -0x7 + EVFILT_USER = -0xa + EVFILT_VM = -0xc + EVFILT_VNODE = -0x4 + EVFILT_WRITE = -0x2 + EV_ADD = 0x1 + EV_CLEAR = 0x20 + EV_DELETE = 0x2 + EV_DISABLE = 0x8 + EV_DISPATCH = 0x80 + EV_ENABLE = 0x4 + EV_EOF = 0x8000 + EV_ERROR = 0x4000 + EV_FLAG0 = 0x1000 + EV_FLAG1 = 0x2000 + EV_ONESHOT = 0x10 + EV_OOBAND = 0x2000 + EV_POLL = 0x1000 + EV_RECEIPT = 0x40 + EV_SYSFLAGS = 0xf000 + EXTA = 0x4b00 + EXTB = 0x9600 + EXTPROC = 0x800 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FLUSHO = 0x800000 + F_ADDFILESIGS = 0x3d + F_ADDSIGS = 0x3b + F_ALLOCATEALL = 0x4 + F_ALLOCATECONTIG = 0x2 + F_CHKCLEAN = 0x29 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x43 + F_FINDSIGS = 0x4e + F_FLUSH_DATA = 0x28 + F_FREEZE_FS = 0x35 + F_FULLFSYNC = 0x33 + F_GETCODEDIR = 0x48 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLK = 0x7 + F_GETLKPID = 0x42 + F_GETNOSIGPIPE = 0x4a + F_GETOWN = 0x5 + F_GETPATH = 0x32 + F_GETPATH_MTMINFO = 0x47 + F_GETPROTECTIONCLASS = 0x3f + F_GETPROTECTIONLEVEL = 0x4d + F_GLOBAL_NOCACHE = 0x37 + F_LOG2PHYS = 0x31 + F_LOG2PHYS_EXT = 0x41 + F_NOCACHE = 0x30 + F_NODIRECT = 0x3e + F_OK = 0x0 + F_PATHPKG_CHECK = 0x34 + F_PEOFPOSMODE = 0x3 + F_PREALLOCATE = 0x2a + F_RDADVISE = 0x2c + F_RDAHEAD = 0x2d + F_RDLCK = 0x1 + F_SETBACKINGSTORE = 0x46 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLK = 0x8 + F_SETLKW = 0x9 + F_SETLKWTIMEOUT = 0xa + F_SETNOSIGPIPE = 0x49 + F_SETOWN = 0x6 + F_SETPROTECTIONCLASS = 0x40 + F_SETSIZE = 0x2b + F_SINGLE_WRITER = 0x4c + F_THAW_FS = 0x36 + F_TRANSCODEKEY = 0x4b + F_UNLCK = 0x2 + F_VOLPOSMODE = 0x4 + F_WRLCK = 0x3 + HUPCL = 0x4000 + ICANON = 0x100 + ICMP6_FILTER = 0x12 + ICRNL = 0x100 + IEXTEN = 0x400 + IFF_ALLMULTI = 0x200 + IFF_ALTPHYS = 0x4000 + IFF_BROADCAST = 0x2 + IFF_DEBUG = 0x4 + IFF_LINK0 = 0x1000 + IFF_LINK1 = 0x2000 + IFF_LINK2 = 0x4000 + IFF_LOOPBACK = 0x8 + IFF_MULTICAST = 0x8000 + IFF_NOARP = 0x80 + IFF_NOTRAILERS = 0x20 + IFF_OACTIVE = 0x400 + IFF_POINTOPOINT = 0x10 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SIMPLEX = 0x800 + IFF_UP = 0x1 + IFNAMSIZ = 0x10 + IFT_1822 = 0x2 + IFT_AAL5 = 0x31 + IFT_ARCNET = 0x23 + IFT_ARCNETPLUS = 0x24 + IFT_ATM = 0x25 + IFT_BRIDGE = 0xd1 + IFT_CARP = 0xf8 + IFT_CELLULAR = 0xff + IFT_CEPT = 0x13 + IFT_DS3 = 0x1e + IFT_ENC = 0xf4 + IFT_EON = 0x19 + IFT_ETHER = 0x6 + IFT_FAITH = 0x38 + IFT_FDDI = 0xf + IFT_FRELAY = 0x20 + IFT_FRELAYDCE = 0x2c + IFT_GIF = 0x37 + IFT_HDH1822 = 0x3 + IFT_HIPPI = 0x2f + IFT_HSSI = 0x2e + IFT_HY = 0xe + IFT_IEEE1394 = 0x90 + IFT_IEEE8023ADLAG = 0x88 + IFT_ISDNBASIC = 0x14 + IFT_ISDNPRIMARY = 0x15 + IFT_ISO88022LLC = 0x29 + IFT_ISO88023 = 0x7 + IFT_ISO88024 = 0x8 + IFT_ISO88025 = 0x9 + IFT_ISO88026 = 0xa + IFT_L2VLAN = 0x87 + IFT_LAPB = 0x10 + IFT_LOCALTALK = 0x2a + IFT_LOOP = 0x18 + IFT_MIOX25 = 0x26 + IFT_MODEM = 0x30 + IFT_NSIP = 0x1b + IFT_OTHER = 0x1 + IFT_P10 = 0xc + IFT_P80 = 0xd + IFT_PARA = 0x22 + IFT_PDP = 0xff + IFT_PFLOG = 0xf5 + IFT_PFSYNC = 0xf6 + IFT_PKTAP = 0xfe + IFT_PPP = 0x17 + IFT_PROPMUX = 0x36 + IFT_PROPVIRTUAL = 0x35 + IFT_PTPSERIAL = 0x16 + IFT_RS232 = 0x21 + IFT_SDLC = 0x11 + IFT_SIP = 0x1f + IFT_SLIP = 0x1c + IFT_SMDSDXI = 0x2b + IFT_SMDSICIP = 0x34 + IFT_SONET = 0x27 + IFT_SONETPATH = 0x32 + IFT_SONETVT = 0x33 + IFT_STARLAN = 0xb + IFT_STF = 0x39 + IFT_T1 = 0x12 + IFT_ULTRA = 0x1d + IFT_V35 = 0x2d + IFT_X25 = 0x5 + IFT_X25DDN = 0x4 + IFT_X25PLE = 0x28 + IFT_XETHER = 0x1a + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLASSD_HOST = 0xfffffff + IN_CLASSD_NET = 0xf0000000 + IN_CLASSD_NSHIFT = 0x1c + IN_LINKLOCALNETNUM = 0xa9fe0000 + IN_LOOPBACKNET = 0x7f + IPPROTO_3PC = 0x22 + IPPROTO_ADFS = 0x44 + IPPROTO_AH = 0x33 + IPPROTO_AHIP = 0x3d + IPPROTO_APES = 0x63 + IPPROTO_ARGUS = 0xd + IPPROTO_AX25 = 0x5d + IPPROTO_BHA = 0x31 + IPPROTO_BLT = 0x1e + IPPROTO_BRSATMON = 0x4c + IPPROTO_CFTP = 0x3e + IPPROTO_CHAOS = 0x10 + IPPROTO_CMTP = 0x26 + IPPROTO_CPHB = 0x49 + IPPROTO_CPNX = 0x48 + IPPROTO_DDP = 0x25 + IPPROTO_DGP = 0x56 + IPPROTO_DIVERT = 0xfe + IPPROTO_DONE = 0x101 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_EMCON = 0xe + IPPROTO_ENCAP = 0x62 + IPPROTO_EON = 0x50 + IPPROTO_ESP = 0x32 + IPPROTO_ETHERIP = 0x61 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GGP = 0x3 + IPPROTO_GMTP = 0x64 + IPPROTO_GRE = 0x2f + IPPROTO_HELLO = 0x3f + IPPROTO_HMP = 0x14 + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IDPR = 0x23 + IPPROTO_IDRP = 0x2d + IPPROTO_IGMP = 0x2 + IPPROTO_IGP = 0x55 + IPPROTO_IGRP = 0x58 + IPPROTO_IL = 0x28 + IPPROTO_INLSP = 0x34 + IPPROTO_INP = 0x20 + IPPROTO_IP = 0x0 + IPPROTO_IPCOMP = 0x6c + IPPROTO_IPCV = 0x47 + IPPROTO_IPEIP = 0x5e + IPPROTO_IPIP = 0x4 + IPPROTO_IPPC = 0x43 + IPPROTO_IPV4 = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_IRTP = 0x1c + IPPROTO_KRYPTOLAN = 0x41 + IPPROTO_LARP = 0x5b + IPPROTO_LEAF1 = 0x19 + IPPROTO_LEAF2 = 0x1a + IPPROTO_MAX = 0x100 + IPPROTO_MAXID = 0x34 + IPPROTO_MEAS = 0x13 + IPPROTO_MHRP = 0x30 + IPPROTO_MICP = 0x5f + IPPROTO_MTP = 0x5c + IPPROTO_MUX = 0x12 + IPPROTO_ND = 0x4d + IPPROTO_NHRP = 0x36 + IPPROTO_NONE = 0x3b + IPPROTO_NSP = 0x1f + IPPROTO_NVPII = 0xb + IPPROTO_OSPFIGP = 0x59 + IPPROTO_PGM = 0x71 + IPPROTO_PIGP = 0x9 + IPPROTO_PIM = 0x67 + IPPROTO_PRM = 0x15 + IPPROTO_PUP = 0xc + IPPROTO_PVP = 0x4b + IPPROTO_RAW = 0xff + IPPROTO_RCCMON = 0xa + IPPROTO_RDP = 0x1b + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_RVD = 0x42 + IPPROTO_SATEXPAK = 0x40 + IPPROTO_SATMON = 0x45 + IPPROTO_SCCSP = 0x60 + IPPROTO_SCTP = 0x84 + IPPROTO_SDRP = 0x2a + IPPROTO_SEP = 0x21 + IPPROTO_SRPC = 0x5a + IPPROTO_ST = 0x7 + IPPROTO_SVMTP = 0x52 + IPPROTO_SWIPE = 0x35 + IPPROTO_TCF = 0x57 + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_TPXX = 0x27 + IPPROTO_TRUNK1 = 0x17 + IPPROTO_TRUNK2 = 0x18 + IPPROTO_TTP = 0x54 + IPPROTO_UDP = 0x11 + IPPROTO_VINES = 0x53 + IPPROTO_VISA = 0x46 + IPPROTO_VMTP = 0x51 + IPPROTO_WBEXPAK = 0x4f + IPPROTO_WBMON = 0x4e + IPPROTO_WSN = 0x4a + IPPROTO_XNET = 0xf + IPPROTO_XTP = 0x24 + IPV6_2292DSTOPTS = 0x17 + IPV6_2292HOPLIMIT = 0x14 + IPV6_2292HOPOPTS = 0x16 + IPV6_2292NEXTHOP = 0x15 + IPV6_2292PKTINFO = 0x13 + IPV6_2292PKTOPTIONS = 0x19 + IPV6_2292RTHDR = 0x18 + IPV6_BINDV6ONLY = 0x1b + IPV6_BOUND_IF = 0x7d + IPV6_CHECKSUM = 0x1a + IPV6_DEFAULT_MULTICAST_HOPS = 0x1 + IPV6_DEFAULT_MULTICAST_LOOP = 0x1 + IPV6_DEFHLIM = 0x40 + IPV6_FAITH = 0x1d + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 + IPV6_FRAGTTL = 0x3c + IPV6_FW_ADD = 0x1e + IPV6_FW_DEL = 0x1f + IPV6_FW_FLUSH = 0x20 + IPV6_FW_GET = 0x22 + IPV6_FW_ZERO = 0x21 + IPV6_HLIMDEC = 0x1 + IPV6_IPSEC_POLICY = 0x1c + IPV6_JOIN_GROUP = 0xc + IPV6_LEAVE_GROUP = 0xd + IPV6_MAXHLIM = 0xff + IPV6_MAXOPTHDR = 0x800 + IPV6_MAXPACKET = 0xffff + IPV6_MAX_GROUP_SRC_FILTER = 0x200 + IPV6_MAX_MEMBERSHIPS = 0xfff + IPV6_MAX_SOCK_SRC_FILTER = 0x80 + IPV6_MIN_MEMBERSHIPS = 0x1f + IPV6_MMTU = 0x500 + IPV6_MULTICAST_HOPS = 0xa + IPV6_MULTICAST_IF = 0x9 + IPV6_MULTICAST_LOOP = 0xb + IPV6_PORTRANGE = 0xe + IPV6_PORTRANGE_DEFAULT = 0x0 + IPV6_PORTRANGE_HIGH = 0x1 + IPV6_PORTRANGE_LOW = 0x2 + IPV6_RECVTCLASS = 0x23 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_SOCKOPT_RESERVED1 = 0x3 + IPV6_TCLASS = 0x24 + IPV6_UNICAST_HOPS = 0x4 + IPV6_V6ONLY = 0x1b + IPV6_VERSION = 0x60 + IPV6_VERSION_MASK = 0xf0 + IP_ADD_MEMBERSHIP = 0xc + IP_ADD_SOURCE_MEMBERSHIP = 0x46 + IP_BLOCK_SOURCE = 0x48 + IP_BOUND_IF = 0x19 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DROP_MEMBERSHIP = 0xd + IP_DROP_SOURCE_MEMBERSHIP = 0x47 + IP_DUMMYNET_CONFIGURE = 0x3c + IP_DUMMYNET_DEL = 0x3d + IP_DUMMYNET_FLUSH = 0x3e + IP_DUMMYNET_GET = 0x40 + IP_FAITH = 0x16 + IP_FW_ADD = 0x28 + IP_FW_DEL = 0x29 + IP_FW_FLUSH = 0x2a + IP_FW_GET = 0x2c + IP_FW_RESETLOG = 0x2d + IP_FW_ZERO = 0x2b + IP_HDRINCL = 0x2 + IP_IPSEC_POLICY = 0x15 + IP_MAXPACKET = 0xffff + IP_MAX_GROUP_SRC_FILTER = 0x200 + IP_MAX_MEMBERSHIPS = 0xfff + IP_MAX_SOCK_MUTE_FILTER = 0x80 + IP_MAX_SOCK_SRC_FILTER = 0x80 + IP_MF = 0x2000 + IP_MIN_MEMBERSHIPS = 0x1f + IP_MSFILTER = 0x4a + IP_MSS = 0x240 + IP_MULTICAST_IF = 0x9 + IP_MULTICAST_IFINDEX = 0x42 + IP_MULTICAST_LOOP = 0xb + IP_MULTICAST_TTL = 0xa + IP_MULTICAST_VIF = 0xe + IP_NAT__XXX = 0x37 + IP_OFFMASK = 0x1fff + IP_OLD_FW_ADD = 0x32 + IP_OLD_FW_DEL = 0x33 + IP_OLD_FW_FLUSH = 0x34 + IP_OLD_FW_GET = 0x36 + IP_OLD_FW_RESETLOG = 0x38 + IP_OLD_FW_ZERO = 0x35 + IP_OPTIONS = 0x1 + IP_PKTINFO = 0x1a + IP_PORTRANGE = 0x13 + IP_PORTRANGE_DEFAULT = 0x0 + IP_PORTRANGE_HIGH = 0x1 + IP_PORTRANGE_LOW = 0x2 + IP_RECVDSTADDR = 0x7 + IP_RECVIF = 0x14 + IP_RECVOPTS = 0x5 + IP_RECVPKTINFO = 0x1a + IP_RECVRETOPTS = 0x6 + IP_RECVTTL = 0x18 + IP_RETOPTS = 0x8 + IP_RF = 0x8000 + IP_RSVP_OFF = 0x10 + IP_RSVP_ON = 0xf + IP_RSVP_VIF_OFF = 0x12 + IP_RSVP_VIF_ON = 0x11 + IP_STRIPHDR = 0x17 + IP_TOS = 0x3 + IP_TRAFFIC_MGT_BACKGROUND = 0x41 + IP_TTL = 0x4 + IP_UNBLOCK_SOURCE = 0x49 + ISIG = 0x80 + ISTRIP = 0x20 + IUTF8 = 0x4000 + IXANY = 0x800 + IXOFF = 0x400 + IXON = 0x200 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_CAN_REUSE = 0x9 + MADV_DONTNEED = 0x4 + MADV_FREE = 0x5 + MADV_FREE_REUSABLE = 0x7 + MADV_FREE_REUSE = 0x8 + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_SEQUENTIAL = 0x2 + MADV_WILLNEED = 0x3 + MADV_ZERO_WIRED_PAGES = 0x6 + MAP_ANON = 0x1000 + MAP_COPY = 0x2 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_HASSEMAPHORE = 0x200 + MAP_JIT = 0x800 + MAP_NOCACHE = 0x400 + MAP_NOEXTEND = 0x100 + MAP_NORESERVE = 0x40 + MAP_PRIVATE = 0x2 + MAP_RENAME = 0x20 + MAP_RESERVED0080 = 0x80 + MAP_SHARED = 0x1 + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MSG_CTRUNC = 0x20 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x80 + MSG_EOF = 0x100 + MSG_EOR = 0x8 + MSG_FLUSH = 0x400 + MSG_HAVEMORE = 0x2000 + MSG_HOLD = 0x800 + MSG_NEEDSA = 0x10000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_RCVMORE = 0x4000 + MSG_SEND = 0x1000 + MSG_TRUNC = 0x10 + MSG_WAITALL = 0x40 + MSG_WAITSTREAM = 0x200 + MS_ASYNC = 0x1 + MS_DEACTIVATE = 0x8 + MS_INVALIDATE = 0x2 + MS_KILLPAGES = 0x4 + MS_SYNC = 0x10 + NAME_MAX = 0xff + NET_RT_DUMP = 0x1 + NET_RT_DUMP2 = 0x7 + NET_RT_FLAGS = 0x2 + NET_RT_IFLIST = 0x3 + NET_RT_IFLIST2 = 0x6 + NET_RT_MAXID = 0xa + NET_RT_STAT = 0x4 + NET_RT_TRASH = 0x5 + NOFLSH = 0x80000000 + NOTE_ABSOLUTE = 0x8 + NOTE_ATTRIB = 0x8 + NOTE_BACKGROUND = 0x40 + NOTE_CHILD = 0x4 + NOTE_CRITICAL = 0x20 + NOTE_DELETE = 0x1 + NOTE_EXEC = 0x20000000 + NOTE_EXIT = 0x80000000 + NOTE_EXITSTATUS = 0x4000000 + NOTE_EXIT_CSERROR = 0x40000 + NOTE_EXIT_DECRYPTFAIL = 0x10000 + NOTE_EXIT_DETAIL = 0x2000000 + NOTE_EXIT_DETAIL_MASK = 0x70000 + NOTE_EXIT_MEMORY = 0x20000 + NOTE_EXIT_REPARENTED = 0x80000 + NOTE_EXTEND = 0x4 + NOTE_FFAND = 0x40000000 + NOTE_FFCOPY = 0xc0000000 + NOTE_FFCTRLMASK = 0xc0000000 + NOTE_FFLAGSMASK = 0xffffff + NOTE_FFNOP = 0x0 + NOTE_FFOR = 0x80000000 + NOTE_FORK = 0x40000000 + NOTE_LEEWAY = 0x10 + NOTE_LINK = 0x10 + NOTE_LOWAT = 0x1 + NOTE_NONE = 0x80 + NOTE_NSECONDS = 0x4 + NOTE_PCTRLMASK = -0x100000 + NOTE_PDATAMASK = 0xfffff + NOTE_REAP = 0x10000000 + NOTE_RENAME = 0x20 + NOTE_REVOKE = 0x40 + NOTE_SECONDS = 0x1 + NOTE_SIGNAL = 0x8000000 + NOTE_TRACK = 0x1 + NOTE_TRACKERR = 0x2 + NOTE_TRIGGER = 0x1000000 + NOTE_USECONDS = 0x2 + NOTE_VM_ERROR = 0x10000000 + NOTE_VM_PRESSURE = 0x80000000 + NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000 + NOTE_VM_PRESSURE_TERMINATE = 0x40000000 + NOTE_WRITE = 0x2 + OCRNL = 0x10 + OFDEL = 0x20000 + OFILL = 0x80 + ONLCR = 0x2 + ONLRET = 0x40 + ONOCR = 0x20 + ONOEOT = 0x8 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_ALERT = 0x20000000 + O_APPEND = 0x8 + O_ASYNC = 0x40 + O_CLOEXEC = 0x1000000 + O_CREAT = 0x200 + O_DIRECTORY = 0x100000 + O_DP_GETRAWENCRYPTED = 0x1 + O_DSYNC = 0x400000 + O_EVTONLY = 0x8000 + O_EXCL = 0x800 + O_EXLOCK = 0x20 + O_FSYNC = 0x80 + O_NDELAY = 0x4 + O_NOCTTY = 0x20000 + O_NOFOLLOW = 0x100 + O_NONBLOCK = 0x4 + O_POPUP = 0x80000000 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_SHLOCK = 0x10 + O_SYMLINK = 0x200000 + O_SYNC = 0x80 + O_TRUNC = 0x400 + O_WRONLY = 0x1 + PARENB = 0x1000 + PARMRK = 0x8 + PARODD = 0x2000 + PENDIN = 0x20000000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + PT_ATTACH = 0xa + PT_ATTACHEXC = 0xe + PT_CONTINUE = 0x7 + PT_DENY_ATTACH = 0x1f + PT_DETACH = 0xb + PT_FIRSTMACH = 0x20 + PT_FORCEQUOTA = 0x1e + PT_KILL = 0x8 + PT_READ_D = 0x2 + PT_READ_I = 0x1 + PT_READ_U = 0x3 + PT_SIGEXC = 0xc + PT_STEP = 0x9 + PT_THUPDATE = 0xd + PT_TRACE_ME = 0x0 + PT_WRITE_D = 0x5 + PT_WRITE_I = 0x4 + PT_WRITE_U = 0x6 + RLIMIT_AS = 0x5 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_CPU_USAGE_MONITOR = 0x2 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x8 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = 0x7fffffffffffffff + RTAX_AUTHOR = 0x6 + RTAX_BRD = 0x7 + RTAX_DST = 0x0 + RTAX_GATEWAY = 0x1 + RTAX_GENMASK = 0x3 + RTAX_IFA = 0x5 + RTAX_IFP = 0x4 + RTAX_MAX = 0x8 + RTAX_NETMASK = 0x2 + RTA_AUTHOR = 0x40 + RTA_BRD = 0x80 + RTA_DST = 0x1 + RTA_GATEWAY = 0x2 + RTA_GENMASK = 0x8 + RTA_IFA = 0x20 + RTA_IFP = 0x10 + RTA_NETMASK = 0x4 + RTF_BLACKHOLE = 0x1000 + RTF_BROADCAST = 0x400000 + RTF_CLONING = 0x100 + RTF_CONDEMNED = 0x2000000 + RTF_DELCLONE = 0x80 + RTF_DONE = 0x40 + RTF_DYNAMIC = 0x10 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_IFREF = 0x4000000 + RTF_IFSCOPE = 0x1000000 + RTF_LLINFO = 0x400 + RTF_LOCAL = 0x200000 + RTF_MODIFIED = 0x20 + RTF_MULTICAST = 0x800000 + RTF_NOIFREF = 0x2000 + RTF_PINNED = 0x100000 + RTF_PRCLONING = 0x10000 + RTF_PROTO1 = 0x8000 + RTF_PROTO2 = 0x4000 + RTF_PROTO3 = 0x40000 + RTF_PROXY = 0x8000000 + RTF_REJECT = 0x8 + RTF_ROUTER = 0x10000000 + RTF_STATIC = 0x800 + RTF_UP = 0x1 + RTF_WASCLONED = 0x20000 + RTF_XRESOLVE = 0x200 + RTM_ADD = 0x1 + RTM_CHANGE = 0x3 + RTM_DELADDR = 0xd + RTM_DELETE = 0x2 + RTM_DELMADDR = 0x10 + RTM_GET = 0x4 + RTM_GET2 = 0x14 + RTM_IFINFO = 0xe + RTM_IFINFO2 = 0x12 + RTM_LOCK = 0x8 + RTM_LOSING = 0x5 + RTM_MISS = 0x7 + RTM_NEWADDR = 0xc + RTM_NEWMADDR = 0xf + RTM_NEWMADDR2 = 0x13 + RTM_OLDADD = 0x9 + RTM_OLDDEL = 0xa + RTM_REDIRECT = 0x6 + RTM_RESOLVE = 0xb + RTM_RTTUNIT = 0xf4240 + RTM_VERSION = 0x5 + RTV_EXPIRE = 0x4 + RTV_HOPCOUNT = 0x2 + RTV_MTU = 0x1 + RTV_RPIPE = 0x8 + RTV_RTT = 0x40 + RTV_RTTVAR = 0x80 + RTV_SPIPE = 0x10 + RTV_SSTHRESH = 0x20 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + SCM_CREDS = 0x3 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x2 + SCM_TIMESTAMP_MONOTONIC = 0x4 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDMULTI = 0x80206931 + SIOCAIFADDR = 0x8040691a + SIOCARPIPLL = 0xc0206928 + SIOCATMARK = 0x40047307 + SIOCAUTOADDR = 0xc0206926 + SIOCAUTONETMASK = 0x80206927 + SIOCDELMULTI = 0x80206932 + SIOCDIFADDR = 0x80206919 + SIOCDIFPHYADDR = 0x80206941 + SIOCGDRVSPEC = 0xc028697b + SIOCGETVLAN = 0xc020697f + SIOCGHIWAT = 0x40047301 + SIOCGIFADDR = 0xc0206921 + SIOCGIFALTMTU = 0xc0206948 + SIOCGIFASYNCMAP = 0xc020697c + SIOCGIFBOND = 0xc0206947 + SIOCGIFBRDADDR = 0xc0206923 + SIOCGIFCAP = 0xc020695b + SIOCGIFCONF = 0xc00c6924 + SIOCGIFDEVMTU = 0xc0206944 + SIOCGIFDSTADDR = 0xc0206922 + SIOCGIFFLAGS = 0xc0206911 + SIOCGIFGENERIC = 0xc020693a + SIOCGIFKPI = 0xc0206987 + SIOCGIFMAC = 0xc0206982 + SIOCGIFMEDIA = 0xc02c6938 + SIOCGIFMETRIC = 0xc0206917 + SIOCGIFMTU = 0xc0206933 + SIOCGIFNETMASK = 0xc0206925 + SIOCGIFPDSTADDR = 0xc0206940 + SIOCGIFPHYS = 0xc0206935 + SIOCGIFPSRCADDR = 0xc020693f + SIOCGIFSTATUS = 0xc331693d + SIOCGIFVLAN = 0xc020697f + SIOCGIFWAKEFLAGS = 0xc0206988 + SIOCGLOWAT = 0x40047303 + SIOCGPGRP = 0x40047309 + SIOCIFCREATE = 0xc0206978 + SIOCIFCREATE2 = 0xc020697a + SIOCIFDESTROY = 0x80206979 + SIOCIFGCLONERS = 0xc0106981 + SIOCRSLVMULTI = 0xc010693b + SIOCSDRVSPEC = 0x8028697b + SIOCSETVLAN = 0x8020697e + SIOCSHIWAT = 0x80047300 + SIOCSIFADDR = 0x8020690c + SIOCSIFALTMTU = 0x80206945 + SIOCSIFASYNCMAP = 0x8020697d + SIOCSIFBOND = 0x80206946 + SIOCSIFBRDADDR = 0x80206913 + SIOCSIFCAP = 0x8020695a + SIOCSIFDSTADDR = 0x8020690e + SIOCSIFFLAGS = 0x80206910 + SIOCSIFGENERIC = 0x80206939 + SIOCSIFKPI = 0x80206986 + SIOCSIFLLADDR = 0x8020693c + SIOCSIFMAC = 0x80206983 + SIOCSIFMEDIA = 0xc0206937 + SIOCSIFMETRIC = 0x80206918 + SIOCSIFMTU = 0x80206934 + SIOCSIFNETMASK = 0x80206916 + SIOCSIFPHYADDR = 0x8040693e + SIOCSIFPHYS = 0x80206936 + SIOCSIFVLAN = 0x8020697e + SIOCSLOWAT = 0x80047302 + SIOCSPGRP = 0x80047308 + SOCK_DGRAM = 0x2 + SOCK_MAXADDRLEN = 0xff + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_SOCKET = 0xffff + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x2 + SO_BROADCAST = 0x20 + SO_DEBUG = 0x1 + SO_DONTROUTE = 0x10 + SO_DONTTRUNC = 0x2000 + SO_ERROR = 0x1007 + SO_KEEPALIVE = 0x8 + SO_LABEL = 0x1010 + SO_LINGER = 0x80 + SO_LINGER_SEC = 0x1080 + SO_NKE = 0x1021 + SO_NOADDRERR = 0x1023 + SO_NOSIGPIPE = 0x1022 + SO_NOTIFYCONFLICT = 0x1026 + SO_NP_EXTENSIONS = 0x1083 + SO_NREAD = 0x1020 + SO_NUMRCVPKT = 0x1112 + SO_NWRITE = 0x1024 + SO_OOBINLINE = 0x100 + SO_PEERLABEL = 0x1011 + SO_RANDOMPORT = 0x1082 + SO_RCVBUF = 0x1002 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x1006 + SO_REUSEADDR = 0x4 + SO_REUSEPORT = 0x200 + SO_REUSESHAREUID = 0x1025 + SO_SNDBUF = 0x1001 + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x1005 + SO_TIMESTAMP = 0x400 + SO_TIMESTAMP_MONOTONIC = 0x800 + SO_TYPE = 0x1008 + SO_UPCALLCLOSEWAIT = 0x1027 + SO_USELOOPBACK = 0x40 + SO_WANTMORE = 0x4000 + SO_WANTOOBFLAG = 0x8000 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IFWHT = 0xe000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISTXT = 0x200 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + TCIFLUSH = 0x1 + TCIOFLUSH = 0x3 + TCOFLUSH = 0x2 + TCP_CONNECTIONTIMEOUT = 0x20 + TCP_ENABLE_ECN = 0x104 + TCP_KEEPALIVE = 0x10 + TCP_KEEPCNT = 0x102 + TCP_KEEPINTVL = 0x101 + TCP_MAXHLEN = 0x3c + TCP_MAXOLEN = 0x28 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_SACK = 0x4 + TCP_MAX_WINSHIFT = 0xe + TCP_MINMSS = 0xd8 + TCP_MSS = 0x200 + TCP_NODELAY = 0x1 + TCP_NOOPT = 0x8 + TCP_NOPUSH = 0x4 + TCP_NOTSENT_LOWAT = 0x201 + TCP_RXT_CONNDROPTIME = 0x80 + TCP_RXT_FINDROP = 0x100 + TCP_SENDMOREACKS = 0x103 + TCSAFLUSH = 0x2 + TIOCCBRK = 0x2000747a + TIOCCDTR = 0x20007478 + TIOCCONS = 0x80047462 + TIOCDCDTIMESTAMP = 0x40107458 + TIOCDRAIN = 0x2000745e + TIOCDSIMICROCODE = 0x20007455 + TIOCEXCL = 0x2000740d + TIOCEXT = 0x80047460 + TIOCFLUSH = 0x80047410 + TIOCGDRAINWAIT = 0x40047456 + TIOCGETA = 0x40487413 + TIOCGETD = 0x4004741a + TIOCGPGRP = 0x40047477 + TIOCGWINSZ = 0x40087468 + TIOCIXOFF = 0x20007480 + TIOCIXON = 0x20007481 + TIOCMBIC = 0x8004746b + TIOCMBIS = 0x8004746c + TIOCMGDTRWAIT = 0x4004745a + TIOCMGET = 0x4004746a + TIOCMODG = 0x40047403 + TIOCMODS = 0x80047404 + TIOCMSDTRWAIT = 0x8004745b + TIOCMSET = 0x8004746d + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x20007471 + TIOCNXCL = 0x2000740e + TIOCOUTQ = 0x40047473 + TIOCPKT = 0x80047470 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCPTYGNAME = 0x40807453 + TIOCPTYGRANT = 0x20007454 + TIOCPTYUNLK = 0x20007452 + TIOCREMOTE = 0x80047469 + TIOCSBRK = 0x2000747b + TIOCSCONS = 0x20007463 + TIOCSCTTY = 0x20007461 + TIOCSDRAINWAIT = 0x80047457 + TIOCSDTR = 0x20007479 + TIOCSETA = 0x80487414 + TIOCSETAF = 0x80487416 + TIOCSETAW = 0x80487415 + TIOCSETD = 0x8004741b + TIOCSIG = 0x2000745f + TIOCSPGRP = 0x80047476 + TIOCSTART = 0x2000746e + TIOCSTAT = 0x20007465 + TIOCSTI = 0x80017472 + TIOCSTOP = 0x2000746f + TIOCSWINSZ = 0x80087467 + TIOCTIMESTAMP = 0x40107459 + TIOCUCNTL = 0x80047466 + TOSTOP = 0x400000 + VDISCARD = 0xf + VDSUSP = 0xb + VEOF = 0x0 + VEOL = 0x1 + VEOL2 = 0x2 + VERASE = 0x3 + VINTR = 0x8 + VKILL = 0x5 + VLNEXT = 0xe + VMIN = 0x10 + VQUIT = 0x9 + VREPRINT = 0x6 + VSTART = 0xc + VSTATUS = 0x12 + VSTOP = 0xd + VSUSP = 0xa + VT0 = 0x0 + VT1 = 0x10000 + VTDLY = 0x10000 + VTIME = 0x11 + VWERASE = 0x4 + WCONTINUED = 0x10 + WCOREFLAG = 0x80 + WEXITED = 0x4 + WNOHANG = 0x1 + WNOWAIT = 0x20 + WORDSIZE = 0x40 + WSTOPPED = 0x8 + WUNTRACED = 0x2 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x30) + EADDRNOTAVAIL = syscall.Errno(0x31) + EAFNOSUPPORT = syscall.Errno(0x2f) + EAGAIN = syscall.Errno(0x23) + EALREADY = syscall.Errno(0x25) + EAUTH = syscall.Errno(0x50) + EBADARCH = syscall.Errno(0x56) + EBADEXEC = syscall.Errno(0x55) + EBADF = syscall.Errno(0x9) + EBADMACHO = syscall.Errno(0x58) + EBADMSG = syscall.Errno(0x5e) + EBADRPC = syscall.Errno(0x48) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x59) + ECHILD = syscall.Errno(0xa) + ECONNABORTED = syscall.Errno(0x35) + ECONNREFUSED = syscall.Errno(0x3d) + ECONNRESET = syscall.Errno(0x36) + EDEADLK = syscall.Errno(0xb) + EDESTADDRREQ = syscall.Errno(0x27) + EDEVERR = syscall.Errno(0x53) + EDOM = syscall.Errno(0x21) + EDQUOT = syscall.Errno(0x45) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EFTYPE = syscall.Errno(0x4f) + EHOSTDOWN = syscall.Errno(0x40) + EHOSTUNREACH = syscall.Errno(0x41) + EIDRM = syscall.Errno(0x5a) + EILSEQ = syscall.Errno(0x5c) + EINPROGRESS = syscall.Errno(0x24) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x38) + EISDIR = syscall.Errno(0x15) + ELAST = syscall.Errno(0x6a) + ELOOP = syscall.Errno(0x3e) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x28) + EMULTIHOP = syscall.Errno(0x5f) + ENAMETOOLONG = syscall.Errno(0x3f) + ENEEDAUTH = syscall.Errno(0x51) + ENETDOWN = syscall.Errno(0x32) + ENETRESET = syscall.Errno(0x34) + ENETUNREACH = syscall.Errno(0x33) + ENFILE = syscall.Errno(0x17) + ENOATTR = syscall.Errno(0x5d) + ENOBUFS = syscall.Errno(0x37) + ENODATA = syscall.Errno(0x60) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOLCK = syscall.Errno(0x4d) + ENOLINK = syscall.Errno(0x61) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x5b) + ENOPOLICY = syscall.Errno(0x67) + ENOPROTOOPT = syscall.Errno(0x2a) + ENOSPC = syscall.Errno(0x1c) + ENOSR = syscall.Errno(0x62) + ENOSTR = syscall.Errno(0x63) + ENOSYS = syscall.Errno(0x4e) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x39) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x42) + ENOTRECOVERABLE = syscall.Errno(0x68) + ENOTSOCK = syscall.Errno(0x26) + ENOTSUP = syscall.Errno(0x2d) + ENOTTY = syscall.Errno(0x19) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x66) + EOVERFLOW = syscall.Errno(0x54) + EOWNERDEAD = syscall.Errno(0x69) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x2e) + EPIPE = syscall.Errno(0x20) + EPROCLIM = syscall.Errno(0x43) + EPROCUNAVAIL = syscall.Errno(0x4c) + EPROGMISMATCH = syscall.Errno(0x4b) + EPROGUNAVAIL = syscall.Errno(0x4a) + EPROTO = syscall.Errno(0x64) + EPROTONOSUPPORT = syscall.Errno(0x2b) + EPROTOTYPE = syscall.Errno(0x29) + EPWROFF = syscall.Errno(0x52) + EQFULL = syscall.Errno(0x6a) + ERANGE = syscall.Errno(0x22) + EREMOTE = syscall.Errno(0x47) + EROFS = syscall.Errno(0x1e) + ERPCMISMATCH = syscall.Errno(0x49) + ESHLIBVERS = syscall.Errno(0x57) + ESHUTDOWN = syscall.Errno(0x3a) + ESOCKTNOSUPPORT = syscall.Errno(0x2c) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESTALE = syscall.Errno(0x46) + ETIME = syscall.Errno(0x65) + ETIMEDOUT = syscall.Errno(0x3c) + ETOOMANYREFS = syscall.Errno(0x3b) + ETXTBSY = syscall.Errno(0x1a) + EUSERS = syscall.Errno(0x44) + EWOULDBLOCK = syscall.Errno(0x23) + EXDEV = syscall.Errno(0x12) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0xa) + SIGCHLD = syscall.Signal(0x14) + SIGCONT = syscall.Signal(0x13) + SIGEMT = syscall.Signal(0x7) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINFO = syscall.Signal(0x1d) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x17) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPROF = syscall.Signal(0x1b) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTOP = syscall.Signal(0x11) + SIGSYS = syscall.Signal(0xc) + SIGTERM = syscall.Signal(0xf) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x12) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGURG = syscall.Signal(0x10) + SIGUSR1 = syscall.Signal(0x1e) + SIGUSR2 = syscall.Signal(0x1f) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "device not configured", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource deadlock avoided", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "resource busy", + 17: "file exists", + 18: "cross-device link", + 19: "operation not supported by device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "result too large", + 35: "resource temporarily unavailable", + 36: "operation now in progress", + 37: "operation already in progress", + 38: "socket operation on non-socket", + 39: "destination address required", + 40: "message too long", + 41: "protocol wrong type for socket", + 42: "protocol not available", + 43: "protocol not supported", + 44: "socket type not supported", + 45: "operation not supported", + 46: "protocol family not supported", + 47: "address family not supported by protocol family", + 48: "address already in use", + 49: "can't assign requested address", + 50: "network is down", + 51: "network is unreachable", + 52: "network dropped connection on reset", + 53: "software caused connection abort", + 54: "connection reset by peer", + 55: "no buffer space available", + 56: "socket is already connected", + 57: "socket is not connected", + 58: "can't send after socket shutdown", + 59: "too many references: can't splice", + 60: "operation timed out", + 61: "connection refused", + 62: "too many levels of symbolic links", + 63: "file name too long", + 64: "host is down", + 65: "no route to host", + 66: "directory not empty", + 67: "too many processes", + 68: "too many users", + 69: "disc quota exceeded", + 70: "stale NFS file handle", + 71: "too many levels of remote in path", + 72: "RPC struct is bad", + 73: "RPC version wrong", + 74: "RPC prog. not avail", + 75: "program version wrong", + 76: "bad procedure for program", + 77: "no locks available", + 78: "function not implemented", + 79: "inappropriate file type or format", + 80: "authentication error", + 81: "need authenticator", + 82: "device power is off", + 83: "device error", + 84: "value too large to be stored in data type", + 85: "bad executable (or shared library)", + 86: "bad CPU type in executable", + 87: "shared library version mismatch", + 88: "malformed Mach-o file", + 89: "operation canceled", + 90: "identifier removed", + 91: "no message of desired type", + 92: "illegal byte sequence", + 93: "attribute not found", + 94: "bad message", + 95: "EMULTIHOP (Reserved)", + 96: "no message available on STREAM", + 97: "ENOLINK (Reserved)", + 98: "no STREAM resources", + 99: "not a STREAM", + 100: "protocol error", + 101: "STREAM ioctl timeout", + 102: "operation not supported on socket", + 103: "policy not found", + 104: "state not recoverable", + 105: "previous owner died", + 106: "interface output queue is full", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/BPT trap", + 6: "abort trap", + 7: "EMT trap", + 8: "floating point exception", + 9: "killed", + 10: "bus error", + 11: "segmentation fault", + 12: "bad system call", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "urgent I/O condition", + 17: "suspended (signal)", + 18: "suspended", + 19: "continued", + 20: "child exited", + 21: "stopped (tty input)", + 22: "stopped (tty output)", + 23: "I/O possible", + 24: "cputime limit exceeded", + 25: "filesize limit exceeded", + 26: "virtual timer expired", + 27: "profiling timer expired", + 28: "window size changes", + 29: "information request", + 30: "user defined signal 1", + 31: "user defined signal 2", +} diff --git a/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go new file mode 100644 index 0000000000..0feceee151 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go @@ -0,0 +1,1530 @@ +// mkerrors.sh -m64 +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build amd64,dragonfly + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -m64 _const.go + +package unix + +import "syscall" + +const ( + AF_APPLETALK = 0x10 + AF_ATM = 0x1e + AF_BLUETOOTH = 0x21 + AF_CCITT = 0xa + AF_CHAOS = 0x5 + AF_CNT = 0x15 + AF_COIP = 0x14 + AF_DATAKIT = 0x9 + AF_DECnet = 0xc + AF_DLI = 0xd + AF_E164 = 0x1a + AF_ECMA = 0x8 + AF_HYLINK = 0xf + AF_IEEE80211 = 0x23 + AF_IMPLINK = 0x3 + AF_INET = 0x2 + AF_INET6 = 0x1c + AF_IPX = 0x17 + AF_ISDN = 0x1a + AF_ISO = 0x7 + AF_LAT = 0xe + AF_LINK = 0x12 + AF_LOCAL = 0x1 + AF_MAX = 0x24 + AF_MPLS = 0x22 + AF_NATM = 0x1d + AF_NETGRAPH = 0x20 + AF_NS = 0x6 + AF_OSI = 0x7 + AF_PUP = 0x4 + AF_ROUTE = 0x11 + AF_SIP = 0x18 + AF_SNA = 0xb + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + B0 = 0x0 + B110 = 0x6e + B115200 = 0x1c200 + B1200 = 0x4b0 + B134 = 0x86 + B14400 = 0x3840 + B150 = 0x96 + B1800 = 0x708 + B19200 = 0x4b00 + B200 = 0xc8 + B230400 = 0x38400 + B2400 = 0x960 + B28800 = 0x7080 + B300 = 0x12c + B38400 = 0x9600 + B4800 = 0x12c0 + B50 = 0x32 + B57600 = 0xe100 + B600 = 0x258 + B7200 = 0x1c20 + B75 = 0x4b + B76800 = 0x12c00 + B9600 = 0x2580 + BIOCFLUSH = 0x20004268 + BIOCGBLEN = 0x40044266 + BIOCGDLT = 0x4004426a + BIOCGDLTLIST = 0xc0104279 + BIOCGETIF = 0x4020426b + BIOCGHDRCMPLT = 0x40044274 + BIOCGRSIG = 0x40044272 + BIOCGRTIMEOUT = 0x4010426e + BIOCGSEESENT = 0x40044276 + BIOCGSTATS = 0x4008426f + BIOCIMMEDIATE = 0x80044270 + BIOCLOCK = 0x2000427a + BIOCPROMISC = 0x20004269 + BIOCSBLEN = 0xc0044266 + BIOCSDLT = 0x80044278 + BIOCSETF = 0x80104267 + BIOCSETIF = 0x8020426c + BIOCSETWF = 0x8010427b + BIOCSHDRCMPLT = 0x80044275 + BIOCSRSIG = 0x80044273 + BIOCSRTIMEOUT = 0x8010426d + BIOCSSEESENT = 0x80044277 + BIOCVERSION = 0x40044271 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALIGNMENT = 0x8 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DEFAULTBUFSIZE = 0x1000 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXBUFSIZE = 0x80000 + BPF_MAXINSNS = 0x200 + BPF_MAX_CLONES = 0x80 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINBUFSIZE = 0x20 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RELEASE = 0x30bb6 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BRKINT = 0x2 + CFLUSH = 0xf + CLOCAL = 0x8000 + CREAD = 0x800 + CS5 = 0x0 + CS6 = 0x100 + CS7 = 0x200 + CS8 = 0x300 + CSIZE = 0x300 + CSTART = 0x11 + CSTATUS = 0x14 + CSTOP = 0x13 + CSTOPB = 0x400 + CSUSP = 0x1a + CTL_MAXNAME = 0xc + CTL_NET = 0x4 + DLT_A429 = 0xb8 + DLT_A653_ICM = 0xb9 + DLT_AIRONET_HEADER = 0x78 + DLT_APPLE_IP_OVER_IEEE1394 = 0x8a + DLT_ARCNET = 0x7 + DLT_ARCNET_LINUX = 0x81 + DLT_ATM_CLIP = 0x13 + DLT_ATM_RFC1483 = 0xb + DLT_AURORA = 0x7e + DLT_AX25 = 0x3 + DLT_AX25_KISS = 0xca + DLT_BACNET_MS_TP = 0xa5 + DLT_BLUETOOTH_HCI_H4 = 0xbb + DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9 + DLT_CAN20B = 0xbe + DLT_CHAOS = 0x5 + DLT_CHDLC = 0x68 + DLT_CISCO_IOS = 0x76 + DLT_C_HDLC = 0x68 + DLT_C_HDLC_WITH_DIR = 0xcd + DLT_DOCSIS = 0x8f + DLT_ECONET = 0x73 + DLT_EN10MB = 0x1 + DLT_EN3MB = 0x2 + DLT_ENC = 0x6d + DLT_ERF = 0xc5 + DLT_ERF_ETH = 0xaf + DLT_ERF_POS = 0xb0 + DLT_FDDI = 0xa + DLT_FLEXRAY = 0xd2 + DLT_FRELAY = 0x6b + DLT_FRELAY_WITH_DIR = 0xce + DLT_GCOM_SERIAL = 0xad + DLT_GCOM_T1E1 = 0xac + DLT_GPF_F = 0xab + DLT_GPF_T = 0xaa + DLT_GPRS_LLC = 0xa9 + DLT_HHDLC = 0x79 + DLT_IBM_SN = 0x92 + DLT_IBM_SP = 0x91 + DLT_IEEE802 = 0x6 + DLT_IEEE802_11 = 0x69 + DLT_IEEE802_11_RADIO = 0x7f + DLT_IEEE802_11_RADIO_AVS = 0xa3 + DLT_IEEE802_15_4 = 0xc3 + DLT_IEEE802_15_4_LINUX = 0xbf + DLT_IEEE802_15_4_NONASK_PHY = 0xd7 + DLT_IEEE802_16_MAC_CPS = 0xbc + DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1 + DLT_IPFILTER = 0x74 + DLT_IPMB = 0xc7 + DLT_IPMB_LINUX = 0xd1 + DLT_IP_OVER_FC = 0x7a + DLT_JUNIPER_ATM1 = 0x89 + DLT_JUNIPER_ATM2 = 0x87 + DLT_JUNIPER_CHDLC = 0xb5 + DLT_JUNIPER_ES = 0x84 + DLT_JUNIPER_ETHER = 0xb2 + DLT_JUNIPER_FRELAY = 0xb4 + DLT_JUNIPER_GGSN = 0x85 + DLT_JUNIPER_ISM = 0xc2 + DLT_JUNIPER_MFR = 0x86 + DLT_JUNIPER_MLFR = 0x83 + DLT_JUNIPER_MLPPP = 0x82 + DLT_JUNIPER_MONITOR = 0xa4 + DLT_JUNIPER_PIC_PEER = 0xae + DLT_JUNIPER_PPP = 0xb3 + DLT_JUNIPER_PPPOE = 0xa7 + DLT_JUNIPER_PPPOE_ATM = 0xa8 + DLT_JUNIPER_SERVICES = 0x88 + DLT_JUNIPER_ST = 0xc8 + DLT_JUNIPER_VP = 0xb7 + DLT_LAPB_WITH_DIR = 0xcf + DLT_LAPD = 0xcb + DLT_LIN = 0xd4 + DLT_LINUX_IRDA = 0x90 + DLT_LINUX_LAPD = 0xb1 + DLT_LINUX_SLL = 0x71 + DLT_LOOP = 0x6c + DLT_LTALK = 0x72 + DLT_MFR = 0xb6 + DLT_MOST = 0xd3 + DLT_MTP2 = 0x8c + DLT_MTP2_WITH_PHDR = 0x8b + DLT_MTP3 = 0x8d + DLT_NULL = 0x0 + DLT_PCI_EXP = 0x7d + DLT_PFLOG = 0x75 + DLT_PFSYNC = 0x12 + DLT_PPI = 0xc0 + DLT_PPP = 0x9 + DLT_PPP_BSDOS = 0x10 + DLT_PPP_ETHER = 0x33 + DLT_PPP_PPPD = 0xa6 + DLT_PPP_SERIAL = 0x32 + DLT_PPP_WITH_DIR = 0xcc + DLT_PRISM_HEADER = 0x77 + DLT_PRONET = 0x4 + DLT_RAIF1 = 0xc6 + DLT_RAW = 0xc + DLT_REDBACK_SMARTEDGE = 0x20 + DLT_RIO = 0x7c + DLT_SCCP = 0x8e + DLT_SITA = 0xc4 + DLT_SLIP = 0x8 + DLT_SLIP_BSDOS = 0xf + DLT_SUNATM = 0x7b + DLT_SYMANTEC_FIREWALL = 0x63 + DLT_TZSP = 0x80 + DLT_USB = 0xba + DLT_USB_LINUX = 0xbd + DLT_X2E_SERIAL = 0xd5 + DLT_X2E_XORAYA = 0xd6 + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DBF = 0xf + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x40 + ECHOE = 0x2 + ECHOK = 0x4 + ECHOKE = 0x1 + ECHONL = 0x10 + ECHOPRT = 0x20 + EVFILT_AIO = -0x3 + EVFILT_EXCEPT = -0x8 + EVFILT_MARKER = 0xf + EVFILT_PROC = -0x5 + EVFILT_READ = -0x1 + EVFILT_SIGNAL = -0x6 + EVFILT_SYSCOUNT = 0x8 + EVFILT_TIMER = -0x7 + EVFILT_VNODE = -0x4 + EVFILT_WRITE = -0x2 + EV_ADD = 0x1 + EV_CLEAR = 0x20 + EV_DELETE = 0x2 + EV_DISABLE = 0x8 + EV_ENABLE = 0x4 + EV_EOF = 0x8000 + EV_ERROR = 0x4000 + EV_FLAG1 = 0x2000 + EV_NODATA = 0x1000 + EV_ONESHOT = 0x10 + EV_SYSFLAGS = 0xf000 + EXTA = 0x4b00 + EXTB = 0x9600 + EXTEXIT_LWP = 0x10000 + EXTEXIT_PROC = 0x0 + EXTEXIT_SETINT = 0x1 + EXTEXIT_SIMPLE = 0x0 + EXTPROC = 0x800 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FLUSHO = 0x800000 + F_DUP2FD = 0xa + F_DUP2FD_CLOEXEC = 0x12 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x11 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLK = 0x7 + F_GETOWN = 0x5 + F_OK = 0x0 + F_RDLCK = 0x1 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLK = 0x8 + F_SETLKW = 0x9 + F_SETOWN = 0x6 + F_UNLCK = 0x2 + F_WRLCK = 0x3 + HUPCL = 0x4000 + ICANON = 0x100 + ICMP6_FILTER = 0x12 + ICRNL = 0x100 + IEXTEN = 0x400 + IFAN_ARRIVAL = 0x0 + IFAN_DEPARTURE = 0x1 + IFF_ALLMULTI = 0x200 + IFF_ALTPHYS = 0x4000 + IFF_BROADCAST = 0x2 + IFF_CANTCHANGE = 0x118e72 + IFF_DEBUG = 0x4 + IFF_LINK0 = 0x1000 + IFF_LINK1 = 0x2000 + IFF_LINK2 = 0x4000 + IFF_LOOPBACK = 0x8 + IFF_MONITOR = 0x40000 + IFF_MULTICAST = 0x8000 + IFF_NOARP = 0x80 + IFF_NPOLLING = 0x100000 + IFF_OACTIVE = 0x400 + IFF_OACTIVE_COMPAT = 0x400 + IFF_POINTOPOINT = 0x10 + IFF_POLLING = 0x10000 + IFF_POLLING_COMPAT = 0x10000 + IFF_PPROMISC = 0x20000 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SIMPLEX = 0x800 + IFF_SMART = 0x20 + IFF_STATICARP = 0x80000 + IFF_UP = 0x1 + IFNAMSIZ = 0x10 + 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_BRIDGE = 0xd1 + IFT_BSC = 0x53 + IFT_CARP = 0xf8 + 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_IEEE1394 = 0x90 + 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_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_L2VLAN = 0x87 + IFT_L3IPVLAN = 0x88 + 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 = 0xf5 + IFT_PFSYNC = 0xf6 + IFT_PLC = 0xae + IFT_POS = 0xab + IFT_PPP = 0x17 + IFT_PPPMULTILINKBUNDLE = 0x6c + IFT_PROPBWAP2MP = 0xb8 + IFT_PROPCNLS = 0x59 + IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5 + IFT_PROPDOCSWIRELESSMACLAYER = 0xb4 + IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6 + IFT_PROPMUX = 0x36 + IFT_PROPVIRTUAL = 0x35 + 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 = 0xf3 + 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 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLASSD_HOST = 0xfffffff + IN_CLASSD_NET = 0xf0000000 + IN_CLASSD_NSHIFT = 0x1c + IN_LOOPBACKNET = 0x7f + IPPROTO_3PC = 0x22 + IPPROTO_ADFS = 0x44 + IPPROTO_AH = 0x33 + IPPROTO_AHIP = 0x3d + IPPROTO_APES = 0x63 + IPPROTO_ARGUS = 0xd + IPPROTO_AX25 = 0x5d + IPPROTO_BHA = 0x31 + IPPROTO_BLT = 0x1e + IPPROTO_BRSATMON = 0x4c + IPPROTO_CARP = 0x70 + IPPROTO_CFTP = 0x3e + IPPROTO_CHAOS = 0x10 + IPPROTO_CMTP = 0x26 + IPPROTO_CPHB = 0x49 + IPPROTO_CPNX = 0x48 + IPPROTO_DDP = 0x25 + IPPROTO_DGP = 0x56 + IPPROTO_DIVERT = 0xfe + IPPROTO_DONE = 0x101 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_EMCON = 0xe + IPPROTO_ENCAP = 0x62 + IPPROTO_EON = 0x50 + IPPROTO_ESP = 0x32 + IPPROTO_ETHERIP = 0x61 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GGP = 0x3 + IPPROTO_GMTP = 0x64 + IPPROTO_GRE = 0x2f + IPPROTO_HELLO = 0x3f + IPPROTO_HMP = 0x14 + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IDPR = 0x23 + IPPROTO_IDRP = 0x2d + IPPROTO_IGMP = 0x2 + IPPROTO_IGP = 0x55 + IPPROTO_IGRP = 0x58 + IPPROTO_IL = 0x28 + IPPROTO_INLSP = 0x34 + IPPROTO_INP = 0x20 + IPPROTO_IP = 0x0 + IPPROTO_IPCOMP = 0x6c + IPPROTO_IPCV = 0x47 + IPPROTO_IPEIP = 0x5e + IPPROTO_IPIP = 0x4 + IPPROTO_IPPC = 0x43 + IPPROTO_IPV4 = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_IRTP = 0x1c + IPPROTO_KRYPTOLAN = 0x41 + IPPROTO_LARP = 0x5b + IPPROTO_LEAF1 = 0x19 + IPPROTO_LEAF2 = 0x1a + IPPROTO_MAX = 0x100 + IPPROTO_MAXID = 0x34 + IPPROTO_MEAS = 0x13 + IPPROTO_MHRP = 0x30 + IPPROTO_MICP = 0x5f + IPPROTO_MOBILE = 0x37 + IPPROTO_MTP = 0x5c + IPPROTO_MUX = 0x12 + IPPROTO_ND = 0x4d + IPPROTO_NHRP = 0x36 + IPPROTO_NONE = 0x3b + IPPROTO_NSP = 0x1f + IPPROTO_NVPII = 0xb + IPPROTO_OSPFIGP = 0x59 + IPPROTO_PFSYNC = 0xf0 + IPPROTO_PGM = 0x71 + IPPROTO_PIGP = 0x9 + IPPROTO_PIM = 0x67 + IPPROTO_PRM = 0x15 + IPPROTO_PUP = 0xc + IPPROTO_PVP = 0x4b + IPPROTO_RAW = 0xff + IPPROTO_RCCMON = 0xa + IPPROTO_RDP = 0x1b + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_RVD = 0x42 + IPPROTO_SATEXPAK = 0x40 + IPPROTO_SATMON = 0x45 + IPPROTO_SCCSP = 0x60 + IPPROTO_SCTP = 0x84 + IPPROTO_SDRP = 0x2a + IPPROTO_SEP = 0x21 + IPPROTO_SKIP = 0x39 + IPPROTO_SRPC = 0x5a + IPPROTO_ST = 0x7 + IPPROTO_SVMTP = 0x52 + IPPROTO_SWIPE = 0x35 + IPPROTO_TCF = 0x57 + IPPROTO_TCP = 0x6 + IPPROTO_TLSP = 0x38 + IPPROTO_TP = 0x1d + IPPROTO_TPXX = 0x27 + IPPROTO_TRUNK1 = 0x17 + IPPROTO_TRUNK2 = 0x18 + IPPROTO_TTP = 0x54 + IPPROTO_UDP = 0x11 + IPPROTO_UNKNOWN = 0x102 + IPPROTO_VINES = 0x53 + IPPROTO_VISA = 0x46 + IPPROTO_VMTP = 0x51 + IPPROTO_WBEXPAK = 0x4f + IPPROTO_WBMON = 0x4e + IPPROTO_WSN = 0x4a + IPPROTO_XNET = 0xf + IPPROTO_XTP = 0x24 + IPV6_AUTOFLOWLABEL = 0x3b + IPV6_BINDV6ONLY = 0x1b + IPV6_CHECKSUM = 0x1a + IPV6_DEFAULT_MULTICAST_HOPS = 0x1 + IPV6_DEFAULT_MULTICAST_LOOP = 0x1 + IPV6_DEFHLIM = 0x40 + IPV6_DONTFRAG = 0x3e + IPV6_DSTOPTS = 0x32 + IPV6_FAITH = 0x1d + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 + IPV6_FRAGTTL = 0x78 + IPV6_FW_ADD = 0x1e + IPV6_FW_DEL = 0x1f + IPV6_FW_FLUSH = 0x20 + IPV6_FW_GET = 0x22 + IPV6_FW_ZERO = 0x21 + IPV6_HLIMDEC = 0x1 + IPV6_HOPLIMIT = 0x2f + IPV6_HOPOPTS = 0x31 + IPV6_IPSEC_POLICY = 0x1c + IPV6_JOIN_GROUP = 0xc + IPV6_LEAVE_GROUP = 0xd + IPV6_MAXHLIM = 0xff + IPV6_MAXPACKET = 0xffff + IPV6_MMTU = 0x500 + IPV6_MSFILTER = 0x4a + IPV6_MULTICAST_HOPS = 0xa + IPV6_MULTICAST_IF = 0x9 + IPV6_MULTICAST_LOOP = 0xb + IPV6_NEXTHOP = 0x30 + IPV6_PATHMTU = 0x2c + IPV6_PKTINFO = 0x2e + IPV6_PKTOPTIONS = 0x34 + IPV6_PORTRANGE = 0xe + IPV6_PORTRANGE_DEFAULT = 0x0 + IPV6_PORTRANGE_HIGH = 0x1 + IPV6_PORTRANGE_LOW = 0x2 + IPV6_PREFER_TEMPADDR = 0x3f + IPV6_RECVDSTOPTS = 0x28 + IPV6_RECVHOPLIMIT = 0x25 + IPV6_RECVHOPOPTS = 0x27 + IPV6_RECVPATHMTU = 0x2b + IPV6_RECVPKTINFO = 0x24 + IPV6_RECVRTHDR = 0x26 + IPV6_RECVTCLASS = 0x39 + IPV6_RTHDR = 0x33 + IPV6_RTHDRDSTOPTS = 0x23 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_SOCKOPT_RESERVED1 = 0x3 + IPV6_TCLASS = 0x3d + IPV6_UNICAST_HOPS = 0x4 + IPV6_USE_MIN_MTU = 0x2a + IPV6_V6ONLY = 0x1b + IPV6_VERSION = 0x60 + IPV6_VERSION_MASK = 0xf0 + IP_ADD_MEMBERSHIP = 0xc + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DROP_MEMBERSHIP = 0xd + IP_DUMMYNET_CONFIGURE = 0x3c + IP_DUMMYNET_DEL = 0x3d + IP_DUMMYNET_FLUSH = 0x3e + IP_DUMMYNET_GET = 0x40 + IP_FAITH = 0x16 + IP_FW_ADD = 0x32 + IP_FW_DEL = 0x33 + IP_FW_FLUSH = 0x34 + IP_FW_GET = 0x36 + IP_FW_RESETLOG = 0x37 + IP_FW_ZERO = 0x35 + IP_HDRINCL = 0x2 + IP_IPSEC_POLICY = 0x15 + IP_MAXPACKET = 0xffff + IP_MAX_MEMBERSHIPS = 0x14 + IP_MF = 0x2000 + IP_MINTTL = 0x42 + IP_MSS = 0x240 + IP_MULTICAST_IF = 0x9 + IP_MULTICAST_LOOP = 0xb + IP_MULTICAST_TTL = 0xa + IP_MULTICAST_VIF = 0xe + IP_OFFMASK = 0x1fff + IP_OPTIONS = 0x1 + IP_PORTRANGE = 0x13 + IP_PORTRANGE_DEFAULT = 0x0 + IP_PORTRANGE_HIGH = 0x1 + IP_PORTRANGE_LOW = 0x2 + IP_RECVDSTADDR = 0x7 + IP_RECVIF = 0x14 + IP_RECVOPTS = 0x5 + IP_RECVRETOPTS = 0x6 + IP_RECVTTL = 0x41 + IP_RETOPTS = 0x8 + IP_RF = 0x8000 + IP_RSVP_OFF = 0x10 + IP_RSVP_ON = 0xf + IP_RSVP_VIF_OFF = 0x12 + IP_RSVP_VIF_ON = 0x11 + IP_TOS = 0x3 + IP_TTL = 0x4 + ISIG = 0x80 + ISTRIP = 0x20 + IXANY = 0x800 + IXOFF = 0x400 + IXON = 0x200 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_AUTOSYNC = 0x7 + MADV_CONTROL_END = 0xb + MADV_CONTROL_START = 0xa + MADV_CORE = 0x9 + MADV_DONTNEED = 0x4 + MADV_FREE = 0x5 + MADV_INVAL = 0xa + MADV_NOCORE = 0x8 + MADV_NORMAL = 0x0 + MADV_NOSYNC = 0x6 + MADV_RANDOM = 0x1 + MADV_SEQUENTIAL = 0x2 + MADV_SETMAP = 0xb + MADV_WILLNEED = 0x3 + MAP_ANON = 0x1000 + MAP_COPY = 0x2 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_HASSEMAPHORE = 0x200 + MAP_INHERIT = 0x80 + MAP_NOCORE = 0x20000 + MAP_NOEXTEND = 0x100 + MAP_NORESERVE = 0x40 + MAP_NOSYNC = 0x800 + MAP_PRIVATE = 0x2 + MAP_RENAME = 0x20 + MAP_SHARED = 0x1 + MAP_SIZEALIGN = 0x40000 + MAP_STACK = 0x400 + MAP_TRYFIXED = 0x10000 + MAP_VPAGETABLE = 0x2000 + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MSG_CTRUNC = 0x20 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x80 + MSG_EOF = 0x100 + MSG_EOR = 0x8 + MSG_FBLOCKING = 0x10000 + MSG_FMASK = 0xffff0000 + MSG_FNONBLOCKING = 0x20000 + MSG_NOSIGNAL = 0x400 + MSG_NOTIFICATION = 0x200 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_SYNC = 0x800 + MSG_TRUNC = 0x10 + MSG_WAITALL = 0x40 + MS_ASYNC = 0x1 + MS_INVALIDATE = 0x2 + MS_SYNC = 0x0 + NAME_MAX = 0xff + NET_RT_DUMP = 0x1 + NET_RT_FLAGS = 0x2 + NET_RT_IFLIST = 0x3 + NET_RT_MAXID = 0x4 + NOFLSH = 0x80000000 + NOTE_ATTRIB = 0x8 + NOTE_CHILD = 0x4 + NOTE_DELETE = 0x1 + NOTE_EXEC = 0x20000000 + NOTE_EXIT = 0x80000000 + NOTE_EXTEND = 0x4 + NOTE_FORK = 0x40000000 + NOTE_LINK = 0x10 + NOTE_LOWAT = 0x1 + NOTE_OOB = 0x2 + NOTE_PCTRLMASK = 0xf0000000 + NOTE_PDATAMASK = 0xfffff + NOTE_RENAME = 0x20 + NOTE_REVOKE = 0x40 + NOTE_TRACK = 0x1 + NOTE_TRACKERR = 0x2 + NOTE_WRITE = 0x2 + OCRNL = 0x10 + ONLCR = 0x2 + ONLRET = 0x40 + ONOCR = 0x20 + ONOEOT = 0x8 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_APPEND = 0x8 + O_ASYNC = 0x40 + O_CLOEXEC = 0x20000 + O_CREAT = 0x200 + O_DIRECT = 0x10000 + O_DIRECTORY = 0x8000000 + O_EXCL = 0x800 + O_EXLOCK = 0x20 + O_FAPPEND = 0x100000 + O_FASYNCWRITE = 0x800000 + O_FBLOCKING = 0x40000 + O_FBUFFERED = 0x2000000 + O_FMASK = 0x7fc0000 + O_FNONBLOCKING = 0x80000 + O_FOFFSET = 0x200000 + O_FSYNC = 0x80 + O_FSYNCWRITE = 0x400000 + O_FUNBUFFERED = 0x1000000 + O_MAPONREAD = 0x4000000 + O_NDELAY = 0x4 + O_NOCTTY = 0x8000 + O_NOFOLLOW = 0x100 + O_NONBLOCK = 0x4 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_SHLOCK = 0x10 + O_SYNC = 0x80 + O_TRUNC = 0x400 + O_WRONLY = 0x1 + PARENB = 0x1000 + PARMRK = 0x8 + PARODD = 0x2000 + PENDIN = 0x20000000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + RLIMIT_AS = 0xa + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x8 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = 0x7fffffffffffffff + RTAX_AUTHOR = 0x6 + RTAX_BRD = 0x7 + RTAX_DST = 0x0 + RTAX_GATEWAY = 0x1 + RTAX_GENMASK = 0x3 + RTAX_IFA = 0x5 + RTAX_IFP = 0x4 + RTAX_MAX = 0xb + RTAX_MPLS1 = 0x8 + RTAX_MPLS2 = 0x9 + RTAX_MPLS3 = 0xa + RTAX_NETMASK = 0x2 + RTA_AUTHOR = 0x40 + RTA_BRD = 0x80 + RTA_DST = 0x1 + RTA_GATEWAY = 0x2 + RTA_GENMASK = 0x8 + RTA_IFA = 0x20 + RTA_IFP = 0x10 + RTA_MPLS1 = 0x100 + RTA_MPLS2 = 0x200 + RTA_MPLS3 = 0x400 + RTA_NETMASK = 0x4 + RTF_BLACKHOLE = 0x1000 + RTF_BROADCAST = 0x400000 + RTF_CLONING = 0x100 + RTF_DONE = 0x40 + RTF_DYNAMIC = 0x10 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_LLINFO = 0x400 + RTF_LOCAL = 0x200000 + RTF_MODIFIED = 0x20 + RTF_MPLSOPS = 0x1000000 + RTF_MULTICAST = 0x800000 + RTF_PINNED = 0x100000 + RTF_PRCLONING = 0x10000 + RTF_PROTO1 = 0x8000 + RTF_PROTO2 = 0x4000 + RTF_PROTO3 = 0x40000 + RTF_REJECT = 0x8 + RTF_STATIC = 0x800 + RTF_UP = 0x1 + RTF_WASCLONED = 0x20000 + RTF_XRESOLVE = 0x200 + RTM_ADD = 0x1 + RTM_CHANGE = 0x3 + RTM_DELADDR = 0xd + RTM_DELETE = 0x2 + RTM_DELMADDR = 0x10 + RTM_GET = 0x4 + RTM_IEEE80211 = 0x12 + RTM_IFANNOUNCE = 0x11 + RTM_IFINFO = 0xe + RTM_LOCK = 0x8 + RTM_LOSING = 0x5 + RTM_MISS = 0x7 + RTM_NEWADDR = 0xc + RTM_NEWMADDR = 0xf + RTM_OLDADD = 0x9 + RTM_OLDDEL = 0xa + RTM_REDIRECT = 0x6 + RTM_RESOLVE = 0xb + RTM_RTTUNIT = 0xf4240 + RTM_VERSION = 0x6 + RTV_EXPIRE = 0x4 + RTV_HOPCOUNT = 0x2 + RTV_IWCAPSEGS = 0x400 + RTV_IWMAXSEGS = 0x200 + RTV_MSL = 0x100 + RTV_MTU = 0x1 + RTV_RPIPE = 0x8 + RTV_RTT = 0x40 + RTV_RTTVAR = 0x80 + RTV_SPIPE = 0x10 + RTV_SSTHRESH = 0x20 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + SCM_CREDS = 0x3 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x2 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDMULTI = 0x80206931 + SIOCADDRT = 0x8040720a + SIOCAIFADDR = 0x8040691a + SIOCALIFADDR = 0x8118691b + SIOCATMARK = 0x40047307 + SIOCDELMULTI = 0x80206932 + SIOCDELRT = 0x8040720b + SIOCDIFADDR = 0x80206919 + SIOCDIFPHYADDR = 0x80206949 + SIOCDLIFADDR = 0x8118691d + SIOCGDRVSPEC = 0xc028697b + SIOCGETSGCNT = 0xc0207210 + SIOCGETVIFCNT = 0xc028720f + SIOCGHIWAT = 0x40047301 + SIOCGIFADDR = 0xc0206921 + SIOCGIFBRDADDR = 0xc0206923 + SIOCGIFCAP = 0xc020691f + SIOCGIFCONF = 0xc0106924 + SIOCGIFDATA = 0xc0206926 + SIOCGIFDSTADDR = 0xc0206922 + SIOCGIFFLAGS = 0xc0206911 + SIOCGIFGENERIC = 0xc020693a + SIOCGIFGMEMB = 0xc028698a + SIOCGIFINDEX = 0xc0206920 + SIOCGIFMEDIA = 0xc0306938 + SIOCGIFMETRIC = 0xc0206917 + SIOCGIFMTU = 0xc0206933 + SIOCGIFNETMASK = 0xc0206925 + SIOCGIFPDSTADDR = 0xc0206948 + SIOCGIFPHYS = 0xc0206935 + SIOCGIFPOLLCPU = 0xc020697e + SIOCGIFPSRCADDR = 0xc0206947 + SIOCGIFSTATUS = 0xc331693b + SIOCGIFTSOLEN = 0xc0206980 + SIOCGLIFADDR = 0xc118691c + SIOCGLIFPHYADDR = 0xc118694b + SIOCGLOWAT = 0x40047303 + SIOCGPGRP = 0x40047309 + SIOCGPRIVATE_0 = 0xc0206950 + SIOCGPRIVATE_1 = 0xc0206951 + SIOCIFCREATE = 0xc020697a + SIOCIFCREATE2 = 0xc020697c + SIOCIFDESTROY = 0x80206979 + SIOCIFGCLONERS = 0xc0106978 + SIOCSDRVSPEC = 0x8028697b + SIOCSHIWAT = 0x80047300 + SIOCSIFADDR = 0x8020690c + SIOCSIFBRDADDR = 0x80206913 + SIOCSIFCAP = 0x8020691e + SIOCSIFDSTADDR = 0x8020690e + SIOCSIFFLAGS = 0x80206910 + SIOCSIFGENERIC = 0x80206939 + SIOCSIFLLADDR = 0x8020693c + SIOCSIFMEDIA = 0xc0206937 + SIOCSIFMETRIC = 0x80206918 + SIOCSIFMTU = 0x80206934 + SIOCSIFNAME = 0x80206928 + SIOCSIFNETMASK = 0x80206916 + SIOCSIFPHYADDR = 0x80406946 + SIOCSIFPHYS = 0x80206936 + SIOCSIFPOLLCPU = 0x8020697d + SIOCSIFTSOLEN = 0x8020697f + SIOCSLIFPHYADDR = 0x8118694a + SIOCSLOWAT = 0x80047302 + SIOCSPGRP = 0x80047308 + SOCK_DGRAM = 0x2 + SOCK_MAXADDRLEN = 0xff + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_SOCKET = 0xffff + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x2 + SO_ACCEPTFILTER = 0x1000 + SO_BROADCAST = 0x20 + SO_DEBUG = 0x1 + SO_DONTROUTE = 0x10 + SO_ERROR = 0x1007 + SO_KEEPALIVE = 0x8 + SO_LINGER = 0x80 + SO_NOSIGPIPE = 0x800 + SO_OOBINLINE = 0x100 + SO_RCVBUF = 0x1002 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x1006 + SO_REUSEADDR = 0x4 + SO_REUSEPORT = 0x200 + SO_SNDBUF = 0x1001 + SO_SNDLOWAT = 0x1003 + SO_SNDSPACE = 0x100a + SO_SNDTIMEO = 0x1005 + SO_TIMESTAMP = 0x400 + SO_TYPE = 0x1008 + SO_USELOOPBACK = 0x40 + TCIFLUSH = 0x1 + TCIOFLUSH = 0x3 + TCOFLUSH = 0x2 + TCP_FASTKEEP = 0x80 + TCP_KEEPCNT = 0x400 + TCP_KEEPIDLE = 0x100 + TCP_KEEPINIT = 0x20 + TCP_KEEPINTVL = 0x200 + TCP_MAXBURST = 0x4 + TCP_MAXHLEN = 0x3c + TCP_MAXOLEN = 0x28 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_WINSHIFT = 0xe + TCP_MINMSS = 0x100 + TCP_MIN_WINSHIFT = 0x5 + TCP_MSS = 0x200 + TCP_NODELAY = 0x1 + TCP_NOOPT = 0x8 + TCP_NOPUSH = 0x4 + TCP_SIGNATURE_ENABLE = 0x10 + TCSAFLUSH = 0x2 + TIOCCBRK = 0x2000747a + TIOCCDTR = 0x20007478 + TIOCCONS = 0x80047462 + TIOCDCDTIMESTAMP = 0x40107458 + TIOCDRAIN = 0x2000745e + TIOCEXCL = 0x2000740d + TIOCEXT = 0x80047460 + TIOCFLUSH = 0x80047410 + TIOCGDRAINWAIT = 0x40047456 + TIOCGETA = 0x402c7413 + TIOCGETD = 0x4004741a + TIOCGPGRP = 0x40047477 + TIOCGSID = 0x40047463 + TIOCGSIZE = 0x40087468 + TIOCGWINSZ = 0x40087468 + TIOCISPTMASTER = 0x20007455 + TIOCMBIC = 0x8004746b + TIOCMBIS = 0x8004746c + TIOCMGDTRWAIT = 0x4004745a + TIOCMGET = 0x4004746a + TIOCMODG = 0x40047403 + TIOCMODS = 0x80047404 + TIOCMSDTRWAIT = 0x8004745b + TIOCMSET = 0x8004746d + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x20007471 + TIOCNXCL = 0x2000740e + TIOCOUTQ = 0x40047473 + TIOCPKT = 0x80047470 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCREMOTE = 0x80047469 + TIOCSBRK = 0x2000747b + TIOCSCTTY = 0x20007461 + TIOCSDRAINWAIT = 0x80047457 + TIOCSDTR = 0x20007479 + TIOCSETA = 0x802c7414 + TIOCSETAF = 0x802c7416 + TIOCSETAW = 0x802c7415 + TIOCSETD = 0x8004741b + TIOCSIG = 0x2000745f + TIOCSPGRP = 0x80047476 + TIOCSSIZE = 0x80087467 + TIOCSTART = 0x2000746e + TIOCSTAT = 0x20007465 + TIOCSTI = 0x80017472 + TIOCSTOP = 0x2000746f + TIOCSWINSZ = 0x80087467 + TIOCTIMESTAMP = 0x40107459 + TIOCUCNTL = 0x80047466 + TOSTOP = 0x400000 + VCHECKPT = 0x13 + VDISCARD = 0xf + VDSUSP = 0xb + VEOF = 0x0 + VEOL = 0x1 + VEOL2 = 0x2 + VERASE = 0x3 + VERASE2 = 0x7 + VINTR = 0x8 + VKILL = 0x5 + VLNEXT = 0xe + VMIN = 0x10 + VQUIT = 0x9 + VREPRINT = 0x6 + VSTART = 0xc + VSTATUS = 0x12 + VSTOP = 0xd + VSUSP = 0xa + VTIME = 0x11 + VWERASE = 0x4 + WCONTINUED = 0x4 + WCOREFLAG = 0x80 + WLINUXCLONE = 0x80000000 + WNOHANG = 0x1 + WSTOPPED = 0x7f + WUNTRACED = 0x2 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x30) + EADDRNOTAVAIL = syscall.Errno(0x31) + EAFNOSUPPORT = syscall.Errno(0x2f) + EAGAIN = syscall.Errno(0x23) + EALREADY = syscall.Errno(0x25) + EASYNC = syscall.Errno(0x63) + EAUTH = syscall.Errno(0x50) + EBADF = syscall.Errno(0x9) + EBADMSG = syscall.Errno(0x59) + EBADRPC = syscall.Errno(0x48) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x55) + ECHILD = syscall.Errno(0xa) + ECONNABORTED = syscall.Errno(0x35) + ECONNREFUSED = syscall.Errno(0x3d) + ECONNRESET = syscall.Errno(0x36) + EDEADLK = syscall.Errno(0xb) + EDESTADDRREQ = syscall.Errno(0x27) + EDOM = syscall.Errno(0x21) + EDOOFUS = syscall.Errno(0x58) + EDQUOT = syscall.Errno(0x45) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EFTYPE = syscall.Errno(0x4f) + EHOSTDOWN = syscall.Errno(0x40) + EHOSTUNREACH = syscall.Errno(0x41) + EIDRM = syscall.Errno(0x52) + EILSEQ = syscall.Errno(0x56) + EINPROGRESS = syscall.Errno(0x24) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x38) + EISDIR = syscall.Errno(0x15) + ELAST = syscall.Errno(0x63) + ELOOP = syscall.Errno(0x3e) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x28) + EMULTIHOP = syscall.Errno(0x5a) + ENAMETOOLONG = syscall.Errno(0x3f) + ENEEDAUTH = syscall.Errno(0x51) + ENETDOWN = syscall.Errno(0x32) + ENETRESET = syscall.Errno(0x34) + ENETUNREACH = syscall.Errno(0x33) + ENFILE = syscall.Errno(0x17) + ENOATTR = syscall.Errno(0x57) + ENOBUFS = syscall.Errno(0x37) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOLCK = syscall.Errno(0x4d) + ENOLINK = syscall.Errno(0x5b) + ENOMEDIUM = syscall.Errno(0x5d) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x53) + ENOPROTOOPT = syscall.Errno(0x2a) + ENOSPC = syscall.Errno(0x1c) + ENOSYS = syscall.Errno(0x4e) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x39) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x42) + ENOTSOCK = syscall.Errno(0x26) + ENOTSUP = syscall.Errno(0x2d) + ENOTTY = syscall.Errno(0x19) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x2d) + EOVERFLOW = syscall.Errno(0x54) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x2e) + EPIPE = syscall.Errno(0x20) + EPROCLIM = syscall.Errno(0x43) + EPROCUNAVAIL = syscall.Errno(0x4c) + EPROGMISMATCH = syscall.Errno(0x4b) + EPROGUNAVAIL = syscall.Errno(0x4a) + EPROTO = syscall.Errno(0x5c) + EPROTONOSUPPORT = syscall.Errno(0x2b) + EPROTOTYPE = syscall.Errno(0x29) + ERANGE = syscall.Errno(0x22) + EREMOTE = syscall.Errno(0x47) + EROFS = syscall.Errno(0x1e) + ERPCMISMATCH = syscall.Errno(0x49) + ESHUTDOWN = syscall.Errno(0x3a) + ESOCKTNOSUPPORT = syscall.Errno(0x2c) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESTALE = syscall.Errno(0x46) + ETIMEDOUT = syscall.Errno(0x3c) + ETOOMANYREFS = syscall.Errno(0x3b) + ETXTBSY = syscall.Errno(0x1a) + EUNUSED94 = syscall.Errno(0x5e) + EUNUSED95 = syscall.Errno(0x5f) + EUNUSED96 = syscall.Errno(0x60) + EUNUSED97 = syscall.Errno(0x61) + EUNUSED98 = syscall.Errno(0x62) + EUSERS = syscall.Errno(0x44) + EWOULDBLOCK = syscall.Errno(0x23) + EXDEV = syscall.Errno(0x12) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0xa) + SIGCHLD = syscall.Signal(0x14) + SIGCKPT = syscall.Signal(0x21) + SIGCKPTEXIT = syscall.Signal(0x22) + SIGCONT = syscall.Signal(0x13) + SIGEMT = syscall.Signal(0x7) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINFO = syscall.Signal(0x1d) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x17) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPROF = syscall.Signal(0x1b) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTOP = syscall.Signal(0x11) + SIGSYS = syscall.Signal(0xc) + SIGTERM = syscall.Signal(0xf) + SIGTHR = syscall.Signal(0x20) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x12) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGURG = syscall.Signal(0x10) + SIGUSR1 = syscall.Signal(0x1e) + SIGUSR2 = syscall.Signal(0x1f) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "device not configured", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource deadlock avoided", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device busy", + 17: "file exists", + 18: "cross-device link", + 19: "operation not supported by device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "result too large", + 35: "resource temporarily unavailable", + 36: "operation now in progress", + 37: "operation already in progress", + 38: "socket operation on non-socket", + 39: "destination address required", + 40: "message too long", + 41: "protocol wrong type for socket", + 42: "protocol not available", + 43: "protocol not supported", + 44: "socket type not supported", + 45: "operation not supported", + 46: "protocol family not supported", + 47: "address family not supported by protocol family", + 48: "address already in use", + 49: "can't assign requested address", + 50: "network is down", + 51: "network is unreachable", + 52: "network dropped connection on reset", + 53: "software caused connection abort", + 54: "connection reset by peer", + 55: "no buffer space available", + 56: "socket is already connected", + 57: "socket is not connected", + 58: "can't send after socket shutdown", + 59: "too many references: can't splice", + 60: "operation timed out", + 61: "connection refused", + 62: "too many levels of symbolic links", + 63: "file name too long", + 64: "host is down", + 65: "no route to host", + 66: "directory not empty", + 67: "too many processes", + 68: "too many users", + 69: "disc quota exceeded", + 70: "stale NFS file handle", + 71: "too many levels of remote in path", + 72: "RPC struct is bad", + 73: "RPC version wrong", + 74: "RPC prog. not avail", + 75: "program version wrong", + 76: "bad procedure for program", + 77: "no locks available", + 78: "function not implemented", + 79: "inappropriate file type or format", + 80: "authentication error", + 81: "need authenticator", + 82: "identifier removed", + 83: "no message of desired type", + 84: "value too large to be stored in data type", + 85: "operation canceled", + 86: "illegal byte sequence", + 87: "attribute not found", + 88: "programming error", + 89: "bad message", + 90: "multihop attempted", + 91: "link has been severed", + 92: "protocol error", + 93: "no medium found", + 94: "unknown error: 94", + 95: "unknown error: 95", + 96: "unknown error: 96", + 97: "unknown error: 97", + 98: "unknown error: 98", + 99: "unknown error: 99", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/BPT trap", + 6: "abort trap", + 7: "EMT trap", + 8: "floating point exception", + 9: "killed", + 10: "bus error", + 11: "segmentation fault", + 12: "bad system call", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "urgent I/O condition", + 17: "suspended (signal)", + 18: "suspended", + 19: "continued", + 20: "child exited", + 21: "stopped (tty input)", + 22: "stopped (tty output)", + 23: "I/O possible", + 24: "cputime limit exceeded", + 25: "filesize limit exceeded", + 26: "virtual timer expired", + 27: "profiling timer expired", + 28: "window size changes", + 29: "information request", + 30: "user defined signal 1", + 31: "user defined signal 2", + 32: "thread Scheduler", + 33: "checkPoint", + 34: "checkPointExit", +} diff --git a/vendor/golang.org/x/sys/unix/zerrors_freebsd_386.go b/vendor/golang.org/x/sys/unix/zerrors_freebsd_386.go new file mode 100644 index 0000000000..7b95751c3d --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_freebsd_386.go @@ -0,0 +1,1743 @@ +// mkerrors.sh -m32 +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build 386,freebsd + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -m32 _const.go + +package unix + +import "syscall" + +const ( + AF_APPLETALK = 0x10 + AF_ARP = 0x23 + AF_ATM = 0x1e + AF_BLUETOOTH = 0x24 + AF_CCITT = 0xa + AF_CHAOS = 0x5 + AF_CNT = 0x15 + AF_COIP = 0x14 + AF_DATAKIT = 0x9 + AF_DECnet = 0xc + AF_DLI = 0xd + AF_E164 = 0x1a + AF_ECMA = 0x8 + AF_HYLINK = 0xf + AF_IEEE80211 = 0x25 + AF_IMPLINK = 0x3 + AF_INET = 0x2 + AF_INET6 = 0x1c + AF_INET6_SDP = 0x2a + AF_INET_SDP = 0x28 + AF_IPX = 0x17 + AF_ISDN = 0x1a + AF_ISO = 0x7 + AF_LAT = 0xe + AF_LINK = 0x12 + AF_LOCAL = 0x1 + AF_MAX = 0x2a + AF_NATM = 0x1d + AF_NETBIOS = 0x6 + AF_NETGRAPH = 0x20 + AF_OSI = 0x7 + AF_PUP = 0x4 + AF_ROUTE = 0x11 + AF_SCLUSTER = 0x22 + AF_SIP = 0x18 + AF_SLOW = 0x21 + AF_SNA = 0xb + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_VENDOR00 = 0x27 + AF_VENDOR01 = 0x29 + AF_VENDOR02 = 0x2b + AF_VENDOR03 = 0x2d + AF_VENDOR04 = 0x2f + AF_VENDOR05 = 0x31 + AF_VENDOR06 = 0x33 + AF_VENDOR07 = 0x35 + AF_VENDOR08 = 0x37 + AF_VENDOR09 = 0x39 + AF_VENDOR10 = 0x3b + AF_VENDOR11 = 0x3d + AF_VENDOR12 = 0x3f + AF_VENDOR13 = 0x41 + AF_VENDOR14 = 0x43 + AF_VENDOR15 = 0x45 + AF_VENDOR16 = 0x47 + AF_VENDOR17 = 0x49 + AF_VENDOR18 = 0x4b + AF_VENDOR19 = 0x4d + AF_VENDOR20 = 0x4f + AF_VENDOR21 = 0x51 + AF_VENDOR22 = 0x53 + AF_VENDOR23 = 0x55 + AF_VENDOR24 = 0x57 + AF_VENDOR25 = 0x59 + AF_VENDOR26 = 0x5b + AF_VENDOR27 = 0x5d + AF_VENDOR28 = 0x5f + AF_VENDOR29 = 0x61 + AF_VENDOR30 = 0x63 + AF_VENDOR31 = 0x65 + AF_VENDOR32 = 0x67 + AF_VENDOR33 = 0x69 + AF_VENDOR34 = 0x6b + AF_VENDOR35 = 0x6d + AF_VENDOR36 = 0x6f + AF_VENDOR37 = 0x71 + AF_VENDOR38 = 0x73 + AF_VENDOR39 = 0x75 + AF_VENDOR40 = 0x77 + AF_VENDOR41 = 0x79 + AF_VENDOR42 = 0x7b + AF_VENDOR43 = 0x7d + AF_VENDOR44 = 0x7f + AF_VENDOR45 = 0x81 + AF_VENDOR46 = 0x83 + AF_VENDOR47 = 0x85 + B0 = 0x0 + B110 = 0x6e + B115200 = 0x1c200 + B1200 = 0x4b0 + B134 = 0x86 + B14400 = 0x3840 + B150 = 0x96 + B1800 = 0x708 + B19200 = 0x4b00 + B200 = 0xc8 + B230400 = 0x38400 + B2400 = 0x960 + B28800 = 0x7080 + B300 = 0x12c + B38400 = 0x9600 + B460800 = 0x70800 + B4800 = 0x12c0 + B50 = 0x32 + B57600 = 0xe100 + B600 = 0x258 + B7200 = 0x1c20 + B75 = 0x4b + B76800 = 0x12c00 + B921600 = 0xe1000 + B9600 = 0x2580 + BIOCFEEDBACK = 0x8004427c + BIOCFLUSH = 0x20004268 + BIOCGBLEN = 0x40044266 + BIOCGDIRECTION = 0x40044276 + BIOCGDLT = 0x4004426a + BIOCGDLTLIST = 0xc0084279 + BIOCGETBUFMODE = 0x4004427d + BIOCGETIF = 0x4020426b + BIOCGETZMAX = 0x4004427f + BIOCGHDRCMPLT = 0x40044274 + BIOCGRSIG = 0x40044272 + BIOCGRTIMEOUT = 0x4008426e + BIOCGSEESENT = 0x40044276 + BIOCGSTATS = 0x4008426f + BIOCGTSTAMP = 0x40044283 + BIOCIMMEDIATE = 0x80044270 + BIOCLOCK = 0x2000427a + BIOCPROMISC = 0x20004269 + BIOCROTZBUF = 0x400c4280 + BIOCSBLEN = 0xc0044266 + BIOCSDIRECTION = 0x80044277 + BIOCSDLT = 0x80044278 + BIOCSETBUFMODE = 0x8004427e + BIOCSETF = 0x80084267 + BIOCSETFNR = 0x80084282 + BIOCSETIF = 0x8020426c + BIOCSETWF = 0x8008427b + BIOCSETZBUF = 0x800c4281 + BIOCSHDRCMPLT = 0x80044275 + BIOCSRSIG = 0x80044273 + BIOCSRTIMEOUT = 0x8008426d + BIOCSSEESENT = 0x80044277 + BIOCSTSTAMP = 0x80044284 + BIOCVERSION = 0x40044271 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALIGNMENT = 0x4 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_BUFMODE_BUFFER = 0x1 + BPF_BUFMODE_ZBUF = 0x2 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXBUFSIZE = 0x80000 + BPF_MAXINSNS = 0x200 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINBUFSIZE = 0x20 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RELEASE = 0x30bb6 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_T_BINTIME = 0x2 + BPF_T_BINTIME_FAST = 0x102 + BPF_T_BINTIME_MONOTONIC = 0x202 + BPF_T_BINTIME_MONOTONIC_FAST = 0x302 + BPF_T_FAST = 0x100 + BPF_T_FLAG_MASK = 0x300 + BPF_T_FORMAT_MASK = 0x3 + BPF_T_MICROTIME = 0x0 + BPF_T_MICROTIME_FAST = 0x100 + BPF_T_MICROTIME_MONOTONIC = 0x200 + BPF_T_MICROTIME_MONOTONIC_FAST = 0x300 + BPF_T_MONOTONIC = 0x200 + BPF_T_MONOTONIC_FAST = 0x300 + BPF_T_NANOTIME = 0x1 + BPF_T_NANOTIME_FAST = 0x101 + BPF_T_NANOTIME_MONOTONIC = 0x201 + BPF_T_NANOTIME_MONOTONIC_FAST = 0x301 + BPF_T_NONE = 0x3 + BPF_T_NORMAL = 0x0 + BPF_W = 0x0 + BPF_X = 0x8 + BRKINT = 0x2 + CFLUSH = 0xf + CLOCAL = 0x8000 + CLOCK_MONOTONIC = 0x4 + CLOCK_MONOTONIC_FAST = 0xc + CLOCK_MONOTONIC_PRECISE = 0xb + CLOCK_PROCESS_CPUTIME_ID = 0xf + CLOCK_PROF = 0x2 + CLOCK_REALTIME = 0x0 + CLOCK_REALTIME_FAST = 0xa + CLOCK_REALTIME_PRECISE = 0x9 + CLOCK_SECOND = 0xd + CLOCK_THREAD_CPUTIME_ID = 0xe + CLOCK_UPTIME = 0x5 + CLOCK_UPTIME_FAST = 0x8 + CLOCK_UPTIME_PRECISE = 0x7 + CLOCK_VIRTUAL = 0x1 + CREAD = 0x800 + CS5 = 0x0 + CS6 = 0x100 + CS7 = 0x200 + CS8 = 0x300 + CSIZE = 0x300 + CSTART = 0x11 + CSTATUS = 0x14 + CSTOP = 0x13 + CSTOPB = 0x400 + CSUSP = 0x1a + CTL_MAXNAME = 0x18 + CTL_NET = 0x4 + DLT_A429 = 0xb8 + DLT_A653_ICM = 0xb9 + DLT_AIRONET_HEADER = 0x78 + DLT_AOS = 0xde + DLT_APPLE_IP_OVER_IEEE1394 = 0x8a + DLT_ARCNET = 0x7 + DLT_ARCNET_LINUX = 0x81 + DLT_ATM_CLIP = 0x13 + DLT_ATM_RFC1483 = 0xb + DLT_AURORA = 0x7e + DLT_AX25 = 0x3 + DLT_AX25_KISS = 0xca + DLT_BACNET_MS_TP = 0xa5 + DLT_BLUETOOTH_HCI_H4 = 0xbb + DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9 + DLT_CAN20B = 0xbe + DLT_CAN_SOCKETCAN = 0xe3 + DLT_CHAOS = 0x5 + DLT_CHDLC = 0x68 + DLT_CISCO_IOS = 0x76 + DLT_C_HDLC = 0x68 + DLT_C_HDLC_WITH_DIR = 0xcd + DLT_DBUS = 0xe7 + DLT_DECT = 0xdd + DLT_DOCSIS = 0x8f + DLT_DVB_CI = 0xeb + DLT_ECONET = 0x73 + DLT_EN10MB = 0x1 + DLT_EN3MB = 0x2 + DLT_ENC = 0x6d + DLT_ERF = 0xc5 + DLT_ERF_ETH = 0xaf + DLT_ERF_POS = 0xb0 + DLT_FC_2 = 0xe0 + DLT_FC_2_WITH_FRAME_DELIMS = 0xe1 + DLT_FDDI = 0xa + DLT_FLEXRAY = 0xd2 + DLT_FRELAY = 0x6b + DLT_FRELAY_WITH_DIR = 0xce + DLT_GCOM_SERIAL = 0xad + DLT_GCOM_T1E1 = 0xac + DLT_GPF_F = 0xab + DLT_GPF_T = 0xaa + DLT_GPRS_LLC = 0xa9 + DLT_GSMTAP_ABIS = 0xda + DLT_GSMTAP_UM = 0xd9 + DLT_HHDLC = 0x79 + DLT_IBM_SN = 0x92 + DLT_IBM_SP = 0x91 + DLT_IEEE802 = 0x6 + DLT_IEEE802_11 = 0x69 + DLT_IEEE802_11_RADIO = 0x7f + DLT_IEEE802_11_RADIO_AVS = 0xa3 + DLT_IEEE802_15_4 = 0xc3 + DLT_IEEE802_15_4_LINUX = 0xbf + DLT_IEEE802_15_4_NOFCS = 0xe6 + DLT_IEEE802_15_4_NONASK_PHY = 0xd7 + DLT_IEEE802_16_MAC_CPS = 0xbc + DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1 + DLT_IPFILTER = 0x74 + DLT_IPMB = 0xc7 + DLT_IPMB_LINUX = 0xd1 + DLT_IPNET = 0xe2 + DLT_IPOIB = 0xf2 + DLT_IPV4 = 0xe4 + DLT_IPV6 = 0xe5 + DLT_IP_OVER_FC = 0x7a + DLT_JUNIPER_ATM1 = 0x89 + DLT_JUNIPER_ATM2 = 0x87 + DLT_JUNIPER_ATM_CEMIC = 0xee + DLT_JUNIPER_CHDLC = 0xb5 + DLT_JUNIPER_ES = 0x84 + DLT_JUNIPER_ETHER = 0xb2 + DLT_JUNIPER_FIBRECHANNEL = 0xea + DLT_JUNIPER_FRELAY = 0xb4 + DLT_JUNIPER_GGSN = 0x85 + DLT_JUNIPER_ISM = 0xc2 + DLT_JUNIPER_MFR = 0x86 + DLT_JUNIPER_MLFR = 0x83 + DLT_JUNIPER_MLPPP = 0x82 + DLT_JUNIPER_MONITOR = 0xa4 + DLT_JUNIPER_PIC_PEER = 0xae + DLT_JUNIPER_PPP = 0xb3 + DLT_JUNIPER_PPPOE = 0xa7 + DLT_JUNIPER_PPPOE_ATM = 0xa8 + DLT_JUNIPER_SERVICES = 0x88 + DLT_JUNIPER_SRX_E2E = 0xe9 + DLT_JUNIPER_ST = 0xc8 + DLT_JUNIPER_VP = 0xb7 + DLT_JUNIPER_VS = 0xe8 + DLT_LAPB_WITH_DIR = 0xcf + DLT_LAPD = 0xcb + DLT_LIN = 0xd4 + DLT_LINUX_EVDEV = 0xd8 + DLT_LINUX_IRDA = 0x90 + DLT_LINUX_LAPD = 0xb1 + DLT_LINUX_PPP_WITHDIRECTION = 0xa6 + DLT_LINUX_SLL = 0x71 + DLT_LOOP = 0x6c + DLT_LTALK = 0x72 + DLT_MATCHING_MAX = 0xf6 + DLT_MATCHING_MIN = 0x68 + DLT_MFR = 0xb6 + DLT_MOST = 0xd3 + DLT_MPEG_2_TS = 0xf3 + DLT_MPLS = 0xdb + DLT_MTP2 = 0x8c + DLT_MTP2_WITH_PHDR = 0x8b + DLT_MTP3 = 0x8d + DLT_MUX27010 = 0xec + DLT_NETANALYZER = 0xf0 + DLT_NETANALYZER_TRANSPARENT = 0xf1 + DLT_NFC_LLCP = 0xf5 + DLT_NFLOG = 0xef + DLT_NG40 = 0xf4 + DLT_NULL = 0x0 + DLT_PCI_EXP = 0x7d + DLT_PFLOG = 0x75 + DLT_PFSYNC = 0x79 + DLT_PPI = 0xc0 + DLT_PPP = 0x9 + DLT_PPP_BSDOS = 0x10 + DLT_PPP_ETHER = 0x33 + DLT_PPP_PPPD = 0xa6 + DLT_PPP_SERIAL = 0x32 + DLT_PPP_WITH_DIR = 0xcc + DLT_PPP_WITH_DIRECTION = 0xa6 + DLT_PRISM_HEADER = 0x77 + DLT_PRONET = 0x4 + DLT_RAIF1 = 0xc6 + DLT_RAW = 0xc + DLT_RIO = 0x7c + DLT_SCCP = 0x8e + DLT_SITA = 0xc4 + DLT_SLIP = 0x8 + DLT_SLIP_BSDOS = 0xf + DLT_STANAG_5066_D_PDU = 0xed + DLT_SUNATM = 0x7b + DLT_SYMANTEC_FIREWALL = 0x63 + DLT_TZSP = 0x80 + DLT_USB = 0xba + DLT_USB_LINUX = 0xbd + DLT_USB_LINUX_MMAPPED = 0xdc + DLT_USER0 = 0x93 + DLT_USER1 = 0x94 + DLT_USER10 = 0x9d + DLT_USER11 = 0x9e + DLT_USER12 = 0x9f + DLT_USER13 = 0xa0 + DLT_USER14 = 0xa1 + DLT_USER15 = 0xa2 + DLT_USER2 = 0x95 + DLT_USER3 = 0x96 + DLT_USER4 = 0x97 + DLT_USER5 = 0x98 + DLT_USER6 = 0x99 + DLT_USER7 = 0x9a + DLT_USER8 = 0x9b + DLT_USER9 = 0x9c + DLT_WIHART = 0xdf + DLT_X2E_SERIAL = 0xd5 + DLT_X2E_XORAYA = 0xd6 + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x40 + ECHOE = 0x2 + ECHOK = 0x4 + ECHOKE = 0x1 + ECHONL = 0x10 + ECHOPRT = 0x20 + EVFILT_AIO = -0x3 + EVFILT_FS = -0x9 + EVFILT_LIO = -0xa + EVFILT_PROC = -0x5 + EVFILT_READ = -0x1 + EVFILT_SIGNAL = -0x6 + EVFILT_SYSCOUNT = 0xb + EVFILT_TIMER = -0x7 + EVFILT_USER = -0xb + EVFILT_VNODE = -0x4 + EVFILT_WRITE = -0x2 + EV_ADD = 0x1 + EV_CLEAR = 0x20 + EV_DELETE = 0x2 + EV_DISABLE = 0x8 + EV_DISPATCH = 0x80 + EV_DROP = 0x1000 + EV_ENABLE = 0x4 + EV_EOF = 0x8000 + EV_ERROR = 0x4000 + EV_FLAG1 = 0x2000 + EV_ONESHOT = 0x10 + EV_RECEIPT = 0x40 + EV_SYSFLAGS = 0xf000 + EXTA = 0x4b00 + EXTATTR_NAMESPACE_EMPTY = 0x0 + EXTATTR_NAMESPACE_SYSTEM = 0x2 + EXTATTR_NAMESPACE_USER = 0x1 + EXTB = 0x9600 + EXTPROC = 0x800 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FLUSHO = 0x800000 + F_CANCEL = 0x5 + F_DUP2FD = 0xa + F_DUP2FD_CLOEXEC = 0x12 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x11 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLK = 0xb + F_GETOWN = 0x5 + F_OGETLK = 0x7 + F_OK = 0x0 + F_OSETLK = 0x8 + F_OSETLKW = 0x9 + F_RDAHEAD = 0x10 + F_RDLCK = 0x1 + F_READAHEAD = 0xf + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLK = 0xc + F_SETLKW = 0xd + F_SETLK_REMOTE = 0xe + F_SETOWN = 0x6 + F_UNLCK = 0x2 + F_UNLCKSYS = 0x4 + F_WRLCK = 0x3 + HUPCL = 0x4000 + ICANON = 0x100 + ICMP6_FILTER = 0x12 + ICRNL = 0x100 + IEXTEN = 0x400 + IFAN_ARRIVAL = 0x0 + IFAN_DEPARTURE = 0x1 + IFF_ALLMULTI = 0x200 + IFF_ALTPHYS = 0x4000 + IFF_BROADCAST = 0x2 + IFF_CANTCHANGE = 0x218f72 + IFF_CANTCONFIG = 0x10000 + IFF_DEBUG = 0x4 + IFF_DRV_OACTIVE = 0x400 + IFF_DRV_RUNNING = 0x40 + IFF_DYING = 0x200000 + IFF_LINK0 = 0x1000 + IFF_LINK1 = 0x2000 + IFF_LINK2 = 0x4000 + IFF_LOOPBACK = 0x8 + IFF_MONITOR = 0x40000 + IFF_MULTICAST = 0x8000 + IFF_NOARP = 0x80 + IFF_OACTIVE = 0x400 + IFF_POINTOPOINT = 0x10 + IFF_PPROMISC = 0x20000 + IFF_PROMISC = 0x100 + IFF_RENAMING = 0x400000 + IFF_RUNNING = 0x40 + IFF_SIMPLEX = 0x800 + IFF_SMART = 0x20 + IFF_STATICARP = 0x80000 + IFF_UP = 0x1 + IFNAMSIZ = 0x10 + 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_BRIDGE = 0xd1 + IFT_BSC = 0x53 + IFT_CARP = 0xf8 + 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_IEEE1394 = 0x90 + IFT_IEEE80211 = 0x47 + IFT_IEEE80212 = 0x37 + IFT_IEEE8023ADLAG = 0xa1 + IFT_IFGSN = 0x91 + IFT_IMT = 0xbe + IFT_INFINIBAND = 0xc7 + 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_L2VLAN = 0x87 + IFT_L3IPVLAN = 0x88 + 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_PPP = 0x17 + IFT_PPPMULTILINKBUNDLE = 0x6c + IFT_PROPBWAP2MP = 0xb8 + IFT_PROPCNLS = 0x59 + IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5 + IFT_PROPDOCSWIRELESSMACLAYER = 0xb4 + IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6 + IFT_PROPMUX = 0x36 + IFT_PROPVIRTUAL = 0x35 + 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 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLASSD_HOST = 0xfffffff + IN_CLASSD_NET = 0xf0000000 + IN_CLASSD_NSHIFT = 0x1c + IN_LOOPBACKNET = 0x7f + IN_RFC3021_MASK = 0xfffffffe + IPPROTO_3PC = 0x22 + IPPROTO_ADFS = 0x44 + IPPROTO_AH = 0x33 + IPPROTO_AHIP = 0x3d + IPPROTO_APES = 0x63 + IPPROTO_ARGUS = 0xd + IPPROTO_AX25 = 0x5d + IPPROTO_BHA = 0x31 + IPPROTO_BLT = 0x1e + IPPROTO_BRSATMON = 0x4c + IPPROTO_CARP = 0x70 + IPPROTO_CFTP = 0x3e + IPPROTO_CHAOS = 0x10 + IPPROTO_CMTP = 0x26 + IPPROTO_CPHB = 0x49 + IPPROTO_CPNX = 0x48 + IPPROTO_DDP = 0x25 + IPPROTO_DGP = 0x56 + IPPROTO_DIVERT = 0x102 + IPPROTO_DONE = 0x101 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_EMCON = 0xe + IPPROTO_ENCAP = 0x62 + IPPROTO_EON = 0x50 + IPPROTO_ESP = 0x32 + IPPROTO_ETHERIP = 0x61 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GGP = 0x3 + IPPROTO_GMTP = 0x64 + IPPROTO_GRE = 0x2f + IPPROTO_HELLO = 0x3f + IPPROTO_HIP = 0x8b + IPPROTO_HMP = 0x14 + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IDPR = 0x23 + IPPROTO_IDRP = 0x2d + IPPROTO_IGMP = 0x2 + IPPROTO_IGP = 0x55 + IPPROTO_IGRP = 0x58 + IPPROTO_IL = 0x28 + IPPROTO_INLSP = 0x34 + IPPROTO_INP = 0x20 + IPPROTO_IP = 0x0 + IPPROTO_IPCOMP = 0x6c + IPPROTO_IPCV = 0x47 + IPPROTO_IPEIP = 0x5e + IPPROTO_IPIP = 0x4 + IPPROTO_IPPC = 0x43 + IPPROTO_IPV4 = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_IRTP = 0x1c + IPPROTO_KRYPTOLAN = 0x41 + IPPROTO_LARP = 0x5b + IPPROTO_LEAF1 = 0x19 + IPPROTO_LEAF2 = 0x1a + IPPROTO_MAX = 0x100 + IPPROTO_MAXID = 0x34 + IPPROTO_MEAS = 0x13 + IPPROTO_MH = 0x87 + IPPROTO_MHRP = 0x30 + IPPROTO_MICP = 0x5f + IPPROTO_MOBILE = 0x37 + IPPROTO_MPLS = 0x89 + IPPROTO_MTP = 0x5c + IPPROTO_MUX = 0x12 + IPPROTO_ND = 0x4d + IPPROTO_NHRP = 0x36 + IPPROTO_NONE = 0x3b + IPPROTO_NSP = 0x1f + IPPROTO_NVPII = 0xb + IPPROTO_OLD_DIVERT = 0xfe + IPPROTO_OSPFIGP = 0x59 + IPPROTO_PFSYNC = 0xf0 + IPPROTO_PGM = 0x71 + IPPROTO_PIGP = 0x9 + IPPROTO_PIM = 0x67 + IPPROTO_PRM = 0x15 + IPPROTO_PUP = 0xc + IPPROTO_PVP = 0x4b + IPPROTO_RAW = 0xff + IPPROTO_RCCMON = 0xa + IPPROTO_RDP = 0x1b + IPPROTO_RESERVED_253 = 0xfd + IPPROTO_RESERVED_254 = 0xfe + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_RVD = 0x42 + IPPROTO_SATEXPAK = 0x40 + IPPROTO_SATMON = 0x45 + IPPROTO_SCCSP = 0x60 + IPPROTO_SCTP = 0x84 + IPPROTO_SDRP = 0x2a + IPPROTO_SEND = 0x103 + IPPROTO_SEP = 0x21 + IPPROTO_SHIM6 = 0x8c + IPPROTO_SKIP = 0x39 + IPPROTO_SPACER = 0x7fff + IPPROTO_SRPC = 0x5a + IPPROTO_ST = 0x7 + IPPROTO_SVMTP = 0x52 + IPPROTO_SWIPE = 0x35 + IPPROTO_TCF = 0x57 + IPPROTO_TCP = 0x6 + IPPROTO_TLSP = 0x38 + IPPROTO_TP = 0x1d + IPPROTO_TPXX = 0x27 + IPPROTO_TRUNK1 = 0x17 + IPPROTO_TRUNK2 = 0x18 + IPPROTO_TTP = 0x54 + IPPROTO_UDP = 0x11 + IPPROTO_UDPLITE = 0x88 + IPPROTO_VINES = 0x53 + IPPROTO_VISA = 0x46 + IPPROTO_VMTP = 0x51 + IPPROTO_WBEXPAK = 0x4f + IPPROTO_WBMON = 0x4e + IPPROTO_WSN = 0x4a + IPPROTO_XNET = 0xf + IPPROTO_XTP = 0x24 + IPV6_AUTOFLOWLABEL = 0x3b + IPV6_BINDANY = 0x40 + IPV6_BINDV6ONLY = 0x1b + IPV6_CHECKSUM = 0x1a + IPV6_DEFAULT_MULTICAST_HOPS = 0x1 + IPV6_DEFAULT_MULTICAST_LOOP = 0x1 + IPV6_DEFHLIM = 0x40 + IPV6_DONTFRAG = 0x3e + IPV6_DSTOPTS = 0x32 + IPV6_FAITH = 0x1d + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 + IPV6_FRAGTTL = 0x78 + IPV6_FW_ADD = 0x1e + IPV6_FW_DEL = 0x1f + IPV6_FW_FLUSH = 0x20 + IPV6_FW_GET = 0x22 + IPV6_FW_ZERO = 0x21 + IPV6_HLIMDEC = 0x1 + IPV6_HOPLIMIT = 0x2f + IPV6_HOPOPTS = 0x31 + IPV6_IPSEC_POLICY = 0x1c + IPV6_JOIN_GROUP = 0xc + IPV6_LEAVE_GROUP = 0xd + IPV6_MAXHLIM = 0xff + IPV6_MAXOPTHDR = 0x800 + IPV6_MAXPACKET = 0xffff + IPV6_MAX_GROUP_SRC_FILTER = 0x200 + IPV6_MAX_MEMBERSHIPS = 0xfff + IPV6_MAX_SOCK_SRC_FILTER = 0x80 + IPV6_MIN_MEMBERSHIPS = 0x1f + IPV6_MMTU = 0x500 + IPV6_MSFILTER = 0x4a + IPV6_MULTICAST_HOPS = 0xa + IPV6_MULTICAST_IF = 0x9 + IPV6_MULTICAST_LOOP = 0xb + IPV6_NEXTHOP = 0x30 + IPV6_PATHMTU = 0x2c + IPV6_PKTINFO = 0x2e + IPV6_PORTRANGE = 0xe + IPV6_PORTRANGE_DEFAULT = 0x0 + IPV6_PORTRANGE_HIGH = 0x1 + IPV6_PORTRANGE_LOW = 0x2 + IPV6_PREFER_TEMPADDR = 0x3f + IPV6_RECVDSTOPTS = 0x28 + IPV6_RECVHOPLIMIT = 0x25 + IPV6_RECVHOPOPTS = 0x27 + IPV6_RECVPATHMTU = 0x2b + IPV6_RECVPKTINFO = 0x24 + IPV6_RECVRTHDR = 0x26 + IPV6_RECVTCLASS = 0x39 + IPV6_RTHDR = 0x33 + IPV6_RTHDRDSTOPTS = 0x23 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_SOCKOPT_RESERVED1 = 0x3 + IPV6_TCLASS = 0x3d + IPV6_UNICAST_HOPS = 0x4 + IPV6_USE_MIN_MTU = 0x2a + IPV6_V6ONLY = 0x1b + IPV6_VERSION = 0x60 + IPV6_VERSION_MASK = 0xf0 + IP_ADD_MEMBERSHIP = 0xc + IP_ADD_SOURCE_MEMBERSHIP = 0x46 + IP_BINDANY = 0x18 + IP_BLOCK_SOURCE = 0x48 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DONTFRAG = 0x43 + IP_DROP_MEMBERSHIP = 0xd + IP_DROP_SOURCE_MEMBERSHIP = 0x47 + IP_DUMMYNET3 = 0x31 + IP_DUMMYNET_CONFIGURE = 0x3c + IP_DUMMYNET_DEL = 0x3d + IP_DUMMYNET_FLUSH = 0x3e + IP_DUMMYNET_GET = 0x40 + IP_FAITH = 0x16 + IP_FW3 = 0x30 + IP_FW_ADD = 0x32 + IP_FW_DEL = 0x33 + IP_FW_FLUSH = 0x34 + IP_FW_GET = 0x36 + IP_FW_NAT_CFG = 0x38 + IP_FW_NAT_DEL = 0x39 + IP_FW_NAT_GET_CONFIG = 0x3a + IP_FW_NAT_GET_LOG = 0x3b + IP_FW_RESETLOG = 0x37 + IP_FW_TABLE_ADD = 0x28 + IP_FW_TABLE_DEL = 0x29 + IP_FW_TABLE_FLUSH = 0x2a + IP_FW_TABLE_GETSIZE = 0x2b + IP_FW_TABLE_LIST = 0x2c + IP_FW_ZERO = 0x35 + IP_HDRINCL = 0x2 + IP_IPSEC_POLICY = 0x15 + IP_MAXPACKET = 0xffff + IP_MAX_GROUP_SRC_FILTER = 0x200 + IP_MAX_MEMBERSHIPS = 0xfff + IP_MAX_SOCK_MUTE_FILTER = 0x80 + IP_MAX_SOCK_SRC_FILTER = 0x80 + IP_MAX_SOURCE_FILTER = 0x400 + IP_MF = 0x2000 + IP_MINTTL = 0x42 + IP_MIN_MEMBERSHIPS = 0x1f + IP_MSFILTER = 0x4a + IP_MSS = 0x240 + IP_MULTICAST_IF = 0x9 + IP_MULTICAST_LOOP = 0xb + IP_MULTICAST_TTL = 0xa + IP_MULTICAST_VIF = 0xe + IP_OFFMASK = 0x1fff + IP_ONESBCAST = 0x17 + IP_OPTIONS = 0x1 + IP_PORTRANGE = 0x13 + IP_PORTRANGE_DEFAULT = 0x0 + IP_PORTRANGE_HIGH = 0x1 + IP_PORTRANGE_LOW = 0x2 + IP_RECVDSTADDR = 0x7 + IP_RECVIF = 0x14 + IP_RECVOPTS = 0x5 + IP_RECVRETOPTS = 0x6 + IP_RECVTOS = 0x44 + IP_RECVTTL = 0x41 + IP_RETOPTS = 0x8 + IP_RF = 0x8000 + IP_RSVP_OFF = 0x10 + IP_RSVP_ON = 0xf + IP_RSVP_VIF_OFF = 0x12 + IP_RSVP_VIF_ON = 0x11 + IP_SENDSRCADDR = 0x7 + IP_TOS = 0x3 + IP_TTL = 0x4 + IP_UNBLOCK_SOURCE = 0x49 + ISIG = 0x80 + ISTRIP = 0x20 + IXANY = 0x800 + IXOFF = 0x400 + IXON = 0x200 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_AUTOSYNC = 0x7 + MADV_CORE = 0x9 + MADV_DONTNEED = 0x4 + MADV_FREE = 0x5 + MADV_NOCORE = 0x8 + MADV_NORMAL = 0x0 + MADV_NOSYNC = 0x6 + MADV_PROTECT = 0xa + MADV_RANDOM = 0x1 + MADV_SEQUENTIAL = 0x2 + MADV_WILLNEED = 0x3 + MAP_ALIGNED_SUPER = 0x1000000 + MAP_ALIGNMENT_MASK = -0x1000000 + MAP_ALIGNMENT_SHIFT = 0x18 + MAP_ANON = 0x1000 + MAP_ANONYMOUS = 0x1000 + MAP_COPY = 0x2 + MAP_EXCL = 0x4000 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_HASSEMAPHORE = 0x200 + MAP_NOCORE = 0x20000 + MAP_NORESERVE = 0x40 + MAP_NOSYNC = 0x800 + MAP_PREFAULT_READ = 0x40000 + MAP_PRIVATE = 0x2 + MAP_RENAME = 0x20 + MAP_RESERVED0080 = 0x80 + MAP_RESERVED0100 = 0x100 + MAP_SHARED = 0x1 + MAP_STACK = 0x400 + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MSG_CMSG_CLOEXEC = 0x40000 + MSG_COMPAT = 0x8000 + MSG_CTRUNC = 0x20 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x80 + MSG_EOF = 0x100 + MSG_EOR = 0x8 + MSG_NBIO = 0x4000 + MSG_NOSIGNAL = 0x20000 + MSG_NOTIFICATION = 0x2000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_TRUNC = 0x10 + MSG_WAITALL = 0x40 + MS_ASYNC = 0x1 + MS_INVALIDATE = 0x2 + MS_SYNC = 0x0 + NAME_MAX = 0xff + NET_RT_DUMP = 0x1 + NET_RT_FLAGS = 0x2 + NET_RT_IFLIST = 0x3 + NET_RT_IFLISTL = 0x5 + NET_RT_IFMALIST = 0x4 + NET_RT_MAXID = 0x6 + NOFLSH = 0x80000000 + NOTE_ATTRIB = 0x8 + NOTE_CHILD = 0x4 + NOTE_DELETE = 0x1 + NOTE_EXEC = 0x20000000 + NOTE_EXIT = 0x80000000 + NOTE_EXTEND = 0x4 + NOTE_FFAND = 0x40000000 + NOTE_FFCOPY = 0xc0000000 + NOTE_FFCTRLMASK = 0xc0000000 + NOTE_FFLAGSMASK = 0xffffff + NOTE_FFNOP = 0x0 + NOTE_FFOR = 0x80000000 + NOTE_FORK = 0x40000000 + NOTE_LINK = 0x10 + NOTE_LOWAT = 0x1 + NOTE_PCTRLMASK = 0xf0000000 + NOTE_PDATAMASK = 0xfffff + NOTE_RENAME = 0x20 + NOTE_REVOKE = 0x40 + NOTE_TRACK = 0x1 + NOTE_TRACKERR = 0x2 + NOTE_TRIGGER = 0x1000000 + NOTE_WRITE = 0x2 + OCRNL = 0x10 + ONLCR = 0x2 + ONLRET = 0x40 + ONOCR = 0x20 + ONOEOT = 0x8 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_APPEND = 0x8 + O_ASYNC = 0x40 + O_CLOEXEC = 0x100000 + O_CREAT = 0x200 + O_DIRECT = 0x10000 + O_DIRECTORY = 0x20000 + O_EXCL = 0x800 + O_EXEC = 0x40000 + O_EXLOCK = 0x20 + O_FSYNC = 0x80 + O_NDELAY = 0x4 + O_NOCTTY = 0x8000 + O_NOFOLLOW = 0x100 + O_NONBLOCK = 0x4 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_SHLOCK = 0x10 + O_SYNC = 0x80 + O_TRUNC = 0x400 + O_TTY_INIT = 0x80000 + O_WRONLY = 0x1 + PARENB = 0x1000 + PARMRK = 0x8 + PARODD = 0x2000 + PENDIN = 0x20000000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + RLIMIT_AS = 0xa + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x8 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = 0x7fffffffffffffff + RTAX_AUTHOR = 0x6 + RTAX_BRD = 0x7 + RTAX_DST = 0x0 + RTAX_GATEWAY = 0x1 + RTAX_GENMASK = 0x3 + RTAX_IFA = 0x5 + RTAX_IFP = 0x4 + RTAX_MAX = 0x8 + RTAX_NETMASK = 0x2 + RTA_AUTHOR = 0x40 + RTA_BRD = 0x80 + RTA_DST = 0x1 + RTA_GATEWAY = 0x2 + RTA_GENMASK = 0x8 + RTA_IFA = 0x20 + RTA_IFP = 0x10 + RTA_NETMASK = 0x4 + RTF_BLACKHOLE = 0x1000 + RTF_BROADCAST = 0x400000 + RTF_DONE = 0x40 + RTF_DYNAMIC = 0x10 + RTF_FMASK = 0x1004d808 + RTF_GATEWAY = 0x2 + RTF_GWFLAG_COMPAT = 0x80000000 + RTF_HOST = 0x4 + RTF_LLDATA = 0x400 + RTF_LLINFO = 0x400 + RTF_LOCAL = 0x200000 + RTF_MODIFIED = 0x20 + RTF_MULTICAST = 0x800000 + RTF_PINNED = 0x100000 + RTF_PRCLONING = 0x10000 + RTF_PROTO1 = 0x8000 + RTF_PROTO2 = 0x4000 + RTF_PROTO3 = 0x40000 + RTF_REJECT = 0x8 + RTF_RNH_LOCKED = 0x40000000 + RTF_STATIC = 0x800 + RTF_STICKY = 0x10000000 + RTF_UP = 0x1 + RTF_XRESOLVE = 0x200 + RTM_ADD = 0x1 + RTM_CHANGE = 0x3 + RTM_DELADDR = 0xd + RTM_DELETE = 0x2 + RTM_DELMADDR = 0x10 + RTM_GET = 0x4 + RTM_IEEE80211 = 0x12 + RTM_IFANNOUNCE = 0x11 + RTM_IFINFO = 0xe + RTM_LOCK = 0x8 + RTM_LOSING = 0x5 + RTM_MISS = 0x7 + RTM_NEWADDR = 0xc + RTM_NEWMADDR = 0xf + RTM_OLDADD = 0x9 + RTM_OLDDEL = 0xa + RTM_REDIRECT = 0x6 + RTM_RESOLVE = 0xb + RTM_RTTUNIT = 0xf4240 + RTM_VERSION = 0x5 + RTV_EXPIRE = 0x4 + RTV_HOPCOUNT = 0x2 + RTV_MTU = 0x1 + RTV_RPIPE = 0x8 + RTV_RTT = 0x40 + RTV_RTTVAR = 0x80 + RTV_SPIPE = 0x10 + RTV_SSTHRESH = 0x20 + RTV_WEIGHT = 0x100 + RT_ALL_FIBS = -0x1 + RT_CACHING_CONTEXT = 0x1 + RT_DEFAULT_FIB = 0x0 + RT_NORTREF = 0x2 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + RUSAGE_THREAD = 0x1 + SCM_BINTIME = 0x4 + SCM_CREDS = 0x3 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x2 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDMULTI = 0x80206931 + SIOCADDRT = 0x8030720a + SIOCAIFADDR = 0x8040691a + SIOCAIFGROUP = 0x80246987 + SIOCALIFADDR = 0x8118691b + SIOCATMARK = 0x40047307 + SIOCDELMULTI = 0x80206932 + SIOCDELRT = 0x8030720b + SIOCDIFADDR = 0x80206919 + SIOCDIFGROUP = 0x80246989 + SIOCDIFPHYADDR = 0x80206949 + SIOCDLIFADDR = 0x8118691d + SIOCGDRVSPEC = 0xc01c697b + SIOCGETSGCNT = 0xc0147210 + SIOCGETVIFCNT = 0xc014720f + SIOCGHIWAT = 0x40047301 + SIOCGIFADDR = 0xc0206921 + SIOCGIFBRDADDR = 0xc0206923 + SIOCGIFCAP = 0xc020691f + SIOCGIFCONF = 0xc0086924 + SIOCGIFDESCR = 0xc020692a + SIOCGIFDSTADDR = 0xc0206922 + SIOCGIFFIB = 0xc020695c + SIOCGIFFLAGS = 0xc0206911 + SIOCGIFGENERIC = 0xc020693a + SIOCGIFGMEMB = 0xc024698a + SIOCGIFGROUP = 0xc0246988 + SIOCGIFINDEX = 0xc0206920 + SIOCGIFMAC = 0xc0206926 + SIOCGIFMEDIA = 0xc0286938 + SIOCGIFMETRIC = 0xc0206917 + SIOCGIFMTU = 0xc0206933 + SIOCGIFNETMASK = 0xc0206925 + SIOCGIFPDSTADDR = 0xc0206948 + SIOCGIFPHYS = 0xc0206935 + SIOCGIFPSRCADDR = 0xc0206947 + SIOCGIFSTATUS = 0xc331693b + SIOCGLIFADDR = 0xc118691c + SIOCGLIFPHYADDR = 0xc118694b + SIOCGLOWAT = 0x40047303 + SIOCGPGRP = 0x40047309 + SIOCGPRIVATE_0 = 0xc0206950 + SIOCGPRIVATE_1 = 0xc0206951 + SIOCIFCREATE = 0xc020697a + SIOCIFCREATE2 = 0xc020697c + SIOCIFDESTROY = 0x80206979 + SIOCIFGCLONERS = 0xc00c6978 + SIOCSDRVSPEC = 0x801c697b + SIOCSHIWAT = 0x80047300 + SIOCSIFADDR = 0x8020690c + SIOCSIFBRDADDR = 0x80206913 + SIOCSIFCAP = 0x8020691e + SIOCSIFDESCR = 0x80206929 + SIOCSIFDSTADDR = 0x8020690e + SIOCSIFFIB = 0x8020695d + SIOCSIFFLAGS = 0x80206910 + SIOCSIFGENERIC = 0x80206939 + SIOCSIFLLADDR = 0x8020693c + SIOCSIFMAC = 0x80206927 + SIOCSIFMEDIA = 0xc0206937 + SIOCSIFMETRIC = 0x80206918 + SIOCSIFMTU = 0x80206934 + SIOCSIFNAME = 0x80206928 + SIOCSIFNETMASK = 0x80206916 + SIOCSIFPHYADDR = 0x80406946 + SIOCSIFPHYS = 0x80206936 + SIOCSIFRVNET = 0xc020695b + SIOCSIFVNET = 0xc020695a + SIOCSLIFPHYADDR = 0x8118694a + SIOCSLOWAT = 0x80047302 + SIOCSPGRP = 0x80047308 + SOCK_CLOEXEC = 0x10000000 + SOCK_DGRAM = 0x2 + SOCK_MAXADDRLEN = 0xff + SOCK_NONBLOCK = 0x20000000 + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_SOCKET = 0xffff + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x2 + SO_ACCEPTFILTER = 0x1000 + SO_BINTIME = 0x2000 + SO_BROADCAST = 0x20 + SO_DEBUG = 0x1 + SO_DONTROUTE = 0x10 + SO_ERROR = 0x1007 + SO_KEEPALIVE = 0x8 + SO_LABEL = 0x1009 + SO_LINGER = 0x80 + SO_LISTENINCQLEN = 0x1013 + SO_LISTENQLEN = 0x1012 + SO_LISTENQLIMIT = 0x1011 + SO_NOSIGPIPE = 0x800 + SO_NO_DDP = 0x8000 + SO_NO_OFFLOAD = 0x4000 + SO_OOBINLINE = 0x100 + SO_PEERLABEL = 0x1010 + SO_PROTOCOL = 0x1016 + SO_PROTOTYPE = 0x1016 + SO_RCVBUF = 0x1002 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x1006 + SO_REUSEADDR = 0x4 + SO_REUSEPORT = 0x200 + SO_SETFIB = 0x1014 + SO_SNDBUF = 0x1001 + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x1005 + SO_TIMESTAMP = 0x400 + SO_TYPE = 0x1008 + SO_USELOOPBACK = 0x40 + SO_USER_COOKIE = 0x1015 + SO_VENDOR = 0x80000000 + TCIFLUSH = 0x1 + TCIOFLUSH = 0x3 + TCOFLUSH = 0x2 + TCP_CA_NAME_MAX = 0x10 + TCP_CONGESTION = 0x40 + TCP_INFO = 0x20 + TCP_KEEPCNT = 0x400 + TCP_KEEPIDLE = 0x100 + TCP_KEEPINIT = 0x80 + TCP_KEEPINTVL = 0x200 + TCP_MAXBURST = 0x4 + TCP_MAXHLEN = 0x3c + TCP_MAXOLEN = 0x28 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_SACK = 0x4 + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0x10 + TCP_MINMSS = 0xd8 + TCP_MSS = 0x218 + TCP_NODELAY = 0x1 + TCP_NOOPT = 0x8 + TCP_NOPUSH = 0x4 + TCP_VENDOR = 0x80000000 + TCSAFLUSH = 0x2 + TIOCCBRK = 0x2000747a + TIOCCDTR = 0x20007478 + TIOCCONS = 0x80047462 + TIOCDRAIN = 0x2000745e + TIOCEXCL = 0x2000740d + TIOCEXT = 0x80047460 + TIOCFLUSH = 0x80047410 + TIOCGDRAINWAIT = 0x40047456 + TIOCGETA = 0x402c7413 + TIOCGETD = 0x4004741a + TIOCGPGRP = 0x40047477 + TIOCGPTN = 0x4004740f + TIOCGSID = 0x40047463 + TIOCGWINSZ = 0x40087468 + TIOCMBIC = 0x8004746b + TIOCMBIS = 0x8004746c + TIOCMGDTRWAIT = 0x4004745a + TIOCMGET = 0x4004746a + TIOCMSDTRWAIT = 0x8004745b + TIOCMSET = 0x8004746d + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DCD = 0x40 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x20007471 + TIOCNXCL = 0x2000740e + TIOCOUTQ = 0x40047473 + TIOCPKT = 0x80047470 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCPTMASTER = 0x2000741c + TIOCSBRK = 0x2000747b + TIOCSCTTY = 0x20007461 + TIOCSDRAINWAIT = 0x80047457 + TIOCSDTR = 0x20007479 + TIOCSETA = 0x802c7414 + TIOCSETAF = 0x802c7416 + TIOCSETAW = 0x802c7415 + TIOCSETD = 0x8004741b + TIOCSIG = 0x2004745f + TIOCSPGRP = 0x80047476 + TIOCSTART = 0x2000746e + TIOCSTAT = 0x20007465 + TIOCSTI = 0x80017472 + TIOCSTOP = 0x2000746f + TIOCSWINSZ = 0x80087467 + TIOCTIMESTAMP = 0x40087459 + TIOCUCNTL = 0x80047466 + TOSTOP = 0x400000 + VDISCARD = 0xf + VDSUSP = 0xb + VEOF = 0x0 + VEOL = 0x1 + VEOL2 = 0x2 + VERASE = 0x3 + VERASE2 = 0x7 + VINTR = 0x8 + VKILL = 0x5 + VLNEXT = 0xe + VMIN = 0x10 + VQUIT = 0x9 + VREPRINT = 0x6 + VSTART = 0xc + VSTATUS = 0x12 + VSTOP = 0xd + VSUSP = 0xa + VTIME = 0x11 + VWERASE = 0x4 + WCONTINUED = 0x4 + WCOREFLAG = 0x80 + WEXITED = 0x10 + WLINUXCLONE = 0x80000000 + WNOHANG = 0x1 + WNOWAIT = 0x8 + WSTOPPED = 0x2 + WTRAPPED = 0x20 + WUNTRACED = 0x2 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x30) + EADDRNOTAVAIL = syscall.Errno(0x31) + EAFNOSUPPORT = syscall.Errno(0x2f) + EAGAIN = syscall.Errno(0x23) + EALREADY = syscall.Errno(0x25) + EAUTH = syscall.Errno(0x50) + EBADF = syscall.Errno(0x9) + EBADMSG = syscall.Errno(0x59) + EBADRPC = syscall.Errno(0x48) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x55) + ECAPMODE = syscall.Errno(0x5e) + ECHILD = syscall.Errno(0xa) + ECONNABORTED = syscall.Errno(0x35) + ECONNREFUSED = syscall.Errno(0x3d) + ECONNRESET = syscall.Errno(0x36) + EDEADLK = syscall.Errno(0xb) + EDESTADDRREQ = syscall.Errno(0x27) + EDOM = syscall.Errno(0x21) + EDOOFUS = syscall.Errno(0x58) + EDQUOT = syscall.Errno(0x45) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EFTYPE = syscall.Errno(0x4f) + EHOSTDOWN = syscall.Errno(0x40) + EHOSTUNREACH = syscall.Errno(0x41) + EIDRM = syscall.Errno(0x52) + EILSEQ = syscall.Errno(0x56) + EINPROGRESS = syscall.Errno(0x24) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x38) + EISDIR = syscall.Errno(0x15) + ELAST = syscall.Errno(0x60) + ELOOP = syscall.Errno(0x3e) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x28) + EMULTIHOP = syscall.Errno(0x5a) + ENAMETOOLONG = syscall.Errno(0x3f) + ENEEDAUTH = syscall.Errno(0x51) + ENETDOWN = syscall.Errno(0x32) + ENETRESET = syscall.Errno(0x34) + ENETUNREACH = syscall.Errno(0x33) + ENFILE = syscall.Errno(0x17) + ENOATTR = syscall.Errno(0x57) + ENOBUFS = syscall.Errno(0x37) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOLCK = syscall.Errno(0x4d) + ENOLINK = syscall.Errno(0x5b) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x53) + ENOPROTOOPT = syscall.Errno(0x2a) + ENOSPC = syscall.Errno(0x1c) + ENOSYS = syscall.Errno(0x4e) + ENOTBLK = syscall.Errno(0xf) + ENOTCAPABLE = syscall.Errno(0x5d) + ENOTCONN = syscall.Errno(0x39) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x42) + ENOTRECOVERABLE = syscall.Errno(0x5f) + ENOTSOCK = syscall.Errno(0x26) + ENOTSUP = syscall.Errno(0x2d) + ENOTTY = syscall.Errno(0x19) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x2d) + EOVERFLOW = syscall.Errno(0x54) + EOWNERDEAD = syscall.Errno(0x60) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x2e) + EPIPE = syscall.Errno(0x20) + EPROCLIM = syscall.Errno(0x43) + EPROCUNAVAIL = syscall.Errno(0x4c) + EPROGMISMATCH = syscall.Errno(0x4b) + EPROGUNAVAIL = syscall.Errno(0x4a) + EPROTO = syscall.Errno(0x5c) + EPROTONOSUPPORT = syscall.Errno(0x2b) + EPROTOTYPE = syscall.Errno(0x29) + ERANGE = syscall.Errno(0x22) + EREMOTE = syscall.Errno(0x47) + EROFS = syscall.Errno(0x1e) + ERPCMISMATCH = syscall.Errno(0x49) + ESHUTDOWN = syscall.Errno(0x3a) + ESOCKTNOSUPPORT = syscall.Errno(0x2c) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESTALE = syscall.Errno(0x46) + ETIMEDOUT = syscall.Errno(0x3c) + ETOOMANYREFS = syscall.Errno(0x3b) + ETXTBSY = syscall.Errno(0x1a) + EUSERS = syscall.Errno(0x44) + EWOULDBLOCK = syscall.Errno(0x23) + EXDEV = syscall.Errno(0x12) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0xa) + SIGCHLD = syscall.Signal(0x14) + SIGCONT = syscall.Signal(0x13) + SIGEMT = syscall.Signal(0x7) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINFO = syscall.Signal(0x1d) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x17) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGLIBRT = syscall.Signal(0x21) + SIGLWP = syscall.Signal(0x20) + SIGPIPE = syscall.Signal(0xd) + SIGPROF = syscall.Signal(0x1b) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTOP = syscall.Signal(0x11) + SIGSYS = syscall.Signal(0xc) + SIGTERM = syscall.Signal(0xf) + SIGTHR = syscall.Signal(0x20) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x12) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGURG = syscall.Signal(0x10) + SIGUSR1 = syscall.Signal(0x1e) + SIGUSR2 = syscall.Signal(0x1f) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "device not configured", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource deadlock avoided", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device busy", + 17: "file exists", + 18: "cross-device link", + 19: "operation not supported by device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "result too large", + 35: "resource temporarily unavailable", + 36: "operation now in progress", + 37: "operation already in progress", + 38: "socket operation on non-socket", + 39: "destination address required", + 40: "message too long", + 41: "protocol wrong type for socket", + 42: "protocol not available", + 43: "protocol not supported", + 44: "socket type not supported", + 45: "operation not supported", + 46: "protocol family not supported", + 47: "address family not supported by protocol family", + 48: "address already in use", + 49: "can't assign requested address", + 50: "network is down", + 51: "network is unreachable", + 52: "network dropped connection on reset", + 53: "software caused connection abort", + 54: "connection reset by peer", + 55: "no buffer space available", + 56: "socket is already connected", + 57: "socket is not connected", + 58: "can't send after socket shutdown", + 59: "too many references: can't splice", + 60: "operation timed out", + 61: "connection refused", + 62: "too many levels of symbolic links", + 63: "file name too long", + 64: "host is down", + 65: "no route to host", + 66: "directory not empty", + 67: "too many processes", + 68: "too many users", + 69: "disc quota exceeded", + 70: "stale NFS file handle", + 71: "too many levels of remote in path", + 72: "RPC struct is bad", + 73: "RPC version wrong", + 74: "RPC prog. not avail", + 75: "program version wrong", + 76: "bad procedure for program", + 77: "no locks available", + 78: "function not implemented", + 79: "inappropriate file type or format", + 80: "authentication error", + 81: "need authenticator", + 82: "identifier removed", + 83: "no message of desired type", + 84: "value too large to be stored in data type", + 85: "operation canceled", + 86: "illegal byte sequence", + 87: "attribute not found", + 88: "programming error", + 89: "bad message", + 90: "multihop attempted", + 91: "link has been severed", + 92: "protocol error", + 93: "capabilities insufficient", + 94: "not permitted in capability mode", + 95: "state not recoverable", + 96: "previous owner died", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/BPT trap", + 6: "abort trap", + 7: "EMT trap", + 8: "floating point exception", + 9: "killed", + 10: "bus error", + 11: "segmentation fault", + 12: "bad system call", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "urgent I/O condition", + 17: "suspended (signal)", + 18: "suspended", + 19: "continued", + 20: "child exited", + 21: "stopped (tty input)", + 22: "stopped (tty output)", + 23: "I/O possible", + 24: "cputime limit exceeded", + 25: "filesize limit exceeded", + 26: "virtual timer expired", + 27: "profiling timer expired", + 28: "window size changes", + 29: "information request", + 30: "user defined signal 1", + 31: "user defined signal 2", + 32: "unknown signal", + 33: "unknown signal", +} diff --git a/vendor/golang.org/x/sys/unix/zerrors_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_freebsd_amd64.go new file mode 100644 index 0000000000..e48e7799a1 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_freebsd_amd64.go @@ -0,0 +1,1748 @@ +// mkerrors.sh -m64 +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build amd64,freebsd + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -m64 _const.go + +package unix + +import "syscall" + +const ( + AF_APPLETALK = 0x10 + AF_ARP = 0x23 + AF_ATM = 0x1e + AF_BLUETOOTH = 0x24 + AF_CCITT = 0xa + AF_CHAOS = 0x5 + AF_CNT = 0x15 + AF_COIP = 0x14 + AF_DATAKIT = 0x9 + AF_DECnet = 0xc + AF_DLI = 0xd + AF_E164 = 0x1a + AF_ECMA = 0x8 + AF_HYLINK = 0xf + AF_IEEE80211 = 0x25 + AF_IMPLINK = 0x3 + AF_INET = 0x2 + AF_INET6 = 0x1c + AF_INET6_SDP = 0x2a + AF_INET_SDP = 0x28 + AF_IPX = 0x17 + AF_ISDN = 0x1a + AF_ISO = 0x7 + AF_LAT = 0xe + AF_LINK = 0x12 + AF_LOCAL = 0x1 + AF_MAX = 0x2a + AF_NATM = 0x1d + AF_NETBIOS = 0x6 + AF_NETGRAPH = 0x20 + AF_OSI = 0x7 + AF_PUP = 0x4 + AF_ROUTE = 0x11 + AF_SCLUSTER = 0x22 + AF_SIP = 0x18 + AF_SLOW = 0x21 + AF_SNA = 0xb + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_VENDOR00 = 0x27 + AF_VENDOR01 = 0x29 + AF_VENDOR02 = 0x2b + AF_VENDOR03 = 0x2d + AF_VENDOR04 = 0x2f + AF_VENDOR05 = 0x31 + AF_VENDOR06 = 0x33 + AF_VENDOR07 = 0x35 + AF_VENDOR08 = 0x37 + AF_VENDOR09 = 0x39 + AF_VENDOR10 = 0x3b + AF_VENDOR11 = 0x3d + AF_VENDOR12 = 0x3f + AF_VENDOR13 = 0x41 + AF_VENDOR14 = 0x43 + AF_VENDOR15 = 0x45 + AF_VENDOR16 = 0x47 + AF_VENDOR17 = 0x49 + AF_VENDOR18 = 0x4b + AF_VENDOR19 = 0x4d + AF_VENDOR20 = 0x4f + AF_VENDOR21 = 0x51 + AF_VENDOR22 = 0x53 + AF_VENDOR23 = 0x55 + AF_VENDOR24 = 0x57 + AF_VENDOR25 = 0x59 + AF_VENDOR26 = 0x5b + AF_VENDOR27 = 0x5d + AF_VENDOR28 = 0x5f + AF_VENDOR29 = 0x61 + AF_VENDOR30 = 0x63 + AF_VENDOR31 = 0x65 + AF_VENDOR32 = 0x67 + AF_VENDOR33 = 0x69 + AF_VENDOR34 = 0x6b + AF_VENDOR35 = 0x6d + AF_VENDOR36 = 0x6f + AF_VENDOR37 = 0x71 + AF_VENDOR38 = 0x73 + AF_VENDOR39 = 0x75 + AF_VENDOR40 = 0x77 + AF_VENDOR41 = 0x79 + AF_VENDOR42 = 0x7b + AF_VENDOR43 = 0x7d + AF_VENDOR44 = 0x7f + AF_VENDOR45 = 0x81 + AF_VENDOR46 = 0x83 + AF_VENDOR47 = 0x85 + B0 = 0x0 + B110 = 0x6e + B115200 = 0x1c200 + B1200 = 0x4b0 + B134 = 0x86 + B14400 = 0x3840 + B150 = 0x96 + B1800 = 0x708 + B19200 = 0x4b00 + B200 = 0xc8 + B230400 = 0x38400 + B2400 = 0x960 + B28800 = 0x7080 + B300 = 0x12c + B38400 = 0x9600 + B460800 = 0x70800 + B4800 = 0x12c0 + B50 = 0x32 + B57600 = 0xe100 + B600 = 0x258 + B7200 = 0x1c20 + B75 = 0x4b + B76800 = 0x12c00 + B921600 = 0xe1000 + B9600 = 0x2580 + BIOCFEEDBACK = 0x8004427c + BIOCFLUSH = 0x20004268 + BIOCGBLEN = 0x40044266 + BIOCGDIRECTION = 0x40044276 + BIOCGDLT = 0x4004426a + BIOCGDLTLIST = 0xc0104279 + BIOCGETBUFMODE = 0x4004427d + BIOCGETIF = 0x4020426b + BIOCGETZMAX = 0x4008427f + BIOCGHDRCMPLT = 0x40044274 + BIOCGRSIG = 0x40044272 + BIOCGRTIMEOUT = 0x4010426e + BIOCGSEESENT = 0x40044276 + BIOCGSTATS = 0x4008426f + BIOCGTSTAMP = 0x40044283 + BIOCIMMEDIATE = 0x80044270 + BIOCLOCK = 0x2000427a + BIOCPROMISC = 0x20004269 + BIOCROTZBUF = 0x40184280 + BIOCSBLEN = 0xc0044266 + BIOCSDIRECTION = 0x80044277 + BIOCSDLT = 0x80044278 + BIOCSETBUFMODE = 0x8004427e + BIOCSETF = 0x80104267 + BIOCSETFNR = 0x80104282 + BIOCSETIF = 0x8020426c + BIOCSETWF = 0x8010427b + BIOCSETZBUF = 0x80184281 + BIOCSHDRCMPLT = 0x80044275 + BIOCSRSIG = 0x80044273 + BIOCSRTIMEOUT = 0x8010426d + BIOCSSEESENT = 0x80044277 + BIOCSTSTAMP = 0x80044284 + BIOCVERSION = 0x40044271 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALIGNMENT = 0x8 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_BUFMODE_BUFFER = 0x1 + BPF_BUFMODE_ZBUF = 0x2 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXBUFSIZE = 0x80000 + BPF_MAXINSNS = 0x200 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINBUFSIZE = 0x20 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RELEASE = 0x30bb6 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_T_BINTIME = 0x2 + BPF_T_BINTIME_FAST = 0x102 + BPF_T_BINTIME_MONOTONIC = 0x202 + BPF_T_BINTIME_MONOTONIC_FAST = 0x302 + BPF_T_FAST = 0x100 + BPF_T_FLAG_MASK = 0x300 + BPF_T_FORMAT_MASK = 0x3 + BPF_T_MICROTIME = 0x0 + BPF_T_MICROTIME_FAST = 0x100 + BPF_T_MICROTIME_MONOTONIC = 0x200 + BPF_T_MICROTIME_MONOTONIC_FAST = 0x300 + BPF_T_MONOTONIC = 0x200 + BPF_T_MONOTONIC_FAST = 0x300 + BPF_T_NANOTIME = 0x1 + BPF_T_NANOTIME_FAST = 0x101 + BPF_T_NANOTIME_MONOTONIC = 0x201 + BPF_T_NANOTIME_MONOTONIC_FAST = 0x301 + BPF_T_NONE = 0x3 + BPF_T_NORMAL = 0x0 + BPF_W = 0x0 + BPF_X = 0x8 + BRKINT = 0x2 + CFLUSH = 0xf + CLOCAL = 0x8000 + CLOCK_MONOTONIC = 0x4 + CLOCK_MONOTONIC_FAST = 0xc + CLOCK_MONOTONIC_PRECISE = 0xb + CLOCK_PROCESS_CPUTIME_ID = 0xf + CLOCK_PROF = 0x2 + CLOCK_REALTIME = 0x0 + CLOCK_REALTIME_FAST = 0xa + CLOCK_REALTIME_PRECISE = 0x9 + CLOCK_SECOND = 0xd + CLOCK_THREAD_CPUTIME_ID = 0xe + CLOCK_UPTIME = 0x5 + CLOCK_UPTIME_FAST = 0x8 + CLOCK_UPTIME_PRECISE = 0x7 + CLOCK_VIRTUAL = 0x1 + CREAD = 0x800 + CS5 = 0x0 + CS6 = 0x100 + CS7 = 0x200 + CS8 = 0x300 + CSIZE = 0x300 + CSTART = 0x11 + CSTATUS = 0x14 + CSTOP = 0x13 + CSTOPB = 0x400 + CSUSP = 0x1a + CTL_MAXNAME = 0x18 + CTL_NET = 0x4 + DLT_A429 = 0xb8 + DLT_A653_ICM = 0xb9 + DLT_AIRONET_HEADER = 0x78 + DLT_AOS = 0xde + DLT_APPLE_IP_OVER_IEEE1394 = 0x8a + DLT_ARCNET = 0x7 + DLT_ARCNET_LINUX = 0x81 + DLT_ATM_CLIP = 0x13 + DLT_ATM_RFC1483 = 0xb + DLT_AURORA = 0x7e + DLT_AX25 = 0x3 + DLT_AX25_KISS = 0xca + DLT_BACNET_MS_TP = 0xa5 + DLT_BLUETOOTH_HCI_H4 = 0xbb + DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9 + DLT_CAN20B = 0xbe + DLT_CAN_SOCKETCAN = 0xe3 + DLT_CHAOS = 0x5 + DLT_CHDLC = 0x68 + DLT_CISCO_IOS = 0x76 + DLT_C_HDLC = 0x68 + DLT_C_HDLC_WITH_DIR = 0xcd + DLT_DBUS = 0xe7 + DLT_DECT = 0xdd + DLT_DOCSIS = 0x8f + DLT_DVB_CI = 0xeb + DLT_ECONET = 0x73 + DLT_EN10MB = 0x1 + DLT_EN3MB = 0x2 + DLT_ENC = 0x6d + DLT_ERF = 0xc5 + DLT_ERF_ETH = 0xaf + DLT_ERF_POS = 0xb0 + DLT_FC_2 = 0xe0 + DLT_FC_2_WITH_FRAME_DELIMS = 0xe1 + DLT_FDDI = 0xa + DLT_FLEXRAY = 0xd2 + DLT_FRELAY = 0x6b + DLT_FRELAY_WITH_DIR = 0xce + DLT_GCOM_SERIAL = 0xad + DLT_GCOM_T1E1 = 0xac + DLT_GPF_F = 0xab + DLT_GPF_T = 0xaa + DLT_GPRS_LLC = 0xa9 + DLT_GSMTAP_ABIS = 0xda + DLT_GSMTAP_UM = 0xd9 + DLT_HHDLC = 0x79 + DLT_IBM_SN = 0x92 + DLT_IBM_SP = 0x91 + DLT_IEEE802 = 0x6 + DLT_IEEE802_11 = 0x69 + DLT_IEEE802_11_RADIO = 0x7f + DLT_IEEE802_11_RADIO_AVS = 0xa3 + DLT_IEEE802_15_4 = 0xc3 + DLT_IEEE802_15_4_LINUX = 0xbf + DLT_IEEE802_15_4_NOFCS = 0xe6 + DLT_IEEE802_15_4_NONASK_PHY = 0xd7 + DLT_IEEE802_16_MAC_CPS = 0xbc + DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1 + DLT_IPFILTER = 0x74 + DLT_IPMB = 0xc7 + DLT_IPMB_LINUX = 0xd1 + DLT_IPNET = 0xe2 + DLT_IPOIB = 0xf2 + DLT_IPV4 = 0xe4 + DLT_IPV6 = 0xe5 + DLT_IP_OVER_FC = 0x7a + DLT_JUNIPER_ATM1 = 0x89 + DLT_JUNIPER_ATM2 = 0x87 + DLT_JUNIPER_ATM_CEMIC = 0xee + DLT_JUNIPER_CHDLC = 0xb5 + DLT_JUNIPER_ES = 0x84 + DLT_JUNIPER_ETHER = 0xb2 + DLT_JUNIPER_FIBRECHANNEL = 0xea + DLT_JUNIPER_FRELAY = 0xb4 + DLT_JUNIPER_GGSN = 0x85 + DLT_JUNIPER_ISM = 0xc2 + DLT_JUNIPER_MFR = 0x86 + DLT_JUNIPER_MLFR = 0x83 + DLT_JUNIPER_MLPPP = 0x82 + DLT_JUNIPER_MONITOR = 0xa4 + DLT_JUNIPER_PIC_PEER = 0xae + DLT_JUNIPER_PPP = 0xb3 + DLT_JUNIPER_PPPOE = 0xa7 + DLT_JUNIPER_PPPOE_ATM = 0xa8 + DLT_JUNIPER_SERVICES = 0x88 + DLT_JUNIPER_SRX_E2E = 0xe9 + DLT_JUNIPER_ST = 0xc8 + DLT_JUNIPER_VP = 0xb7 + DLT_JUNIPER_VS = 0xe8 + DLT_LAPB_WITH_DIR = 0xcf + DLT_LAPD = 0xcb + DLT_LIN = 0xd4 + DLT_LINUX_EVDEV = 0xd8 + DLT_LINUX_IRDA = 0x90 + DLT_LINUX_LAPD = 0xb1 + DLT_LINUX_PPP_WITHDIRECTION = 0xa6 + DLT_LINUX_SLL = 0x71 + DLT_LOOP = 0x6c + DLT_LTALK = 0x72 + DLT_MATCHING_MAX = 0xf6 + DLT_MATCHING_MIN = 0x68 + DLT_MFR = 0xb6 + DLT_MOST = 0xd3 + DLT_MPEG_2_TS = 0xf3 + DLT_MPLS = 0xdb + DLT_MTP2 = 0x8c + DLT_MTP2_WITH_PHDR = 0x8b + DLT_MTP3 = 0x8d + DLT_MUX27010 = 0xec + DLT_NETANALYZER = 0xf0 + DLT_NETANALYZER_TRANSPARENT = 0xf1 + DLT_NFC_LLCP = 0xf5 + DLT_NFLOG = 0xef + DLT_NG40 = 0xf4 + DLT_NULL = 0x0 + DLT_PCI_EXP = 0x7d + DLT_PFLOG = 0x75 + DLT_PFSYNC = 0x79 + DLT_PPI = 0xc0 + DLT_PPP = 0x9 + DLT_PPP_BSDOS = 0x10 + DLT_PPP_ETHER = 0x33 + DLT_PPP_PPPD = 0xa6 + DLT_PPP_SERIAL = 0x32 + DLT_PPP_WITH_DIR = 0xcc + DLT_PPP_WITH_DIRECTION = 0xa6 + DLT_PRISM_HEADER = 0x77 + DLT_PRONET = 0x4 + DLT_RAIF1 = 0xc6 + DLT_RAW = 0xc + DLT_RIO = 0x7c + DLT_SCCP = 0x8e + DLT_SITA = 0xc4 + DLT_SLIP = 0x8 + DLT_SLIP_BSDOS = 0xf + DLT_STANAG_5066_D_PDU = 0xed + DLT_SUNATM = 0x7b + DLT_SYMANTEC_FIREWALL = 0x63 + DLT_TZSP = 0x80 + DLT_USB = 0xba + DLT_USB_LINUX = 0xbd + DLT_USB_LINUX_MMAPPED = 0xdc + DLT_USER0 = 0x93 + DLT_USER1 = 0x94 + DLT_USER10 = 0x9d + DLT_USER11 = 0x9e + DLT_USER12 = 0x9f + DLT_USER13 = 0xa0 + DLT_USER14 = 0xa1 + DLT_USER15 = 0xa2 + DLT_USER2 = 0x95 + DLT_USER3 = 0x96 + DLT_USER4 = 0x97 + DLT_USER5 = 0x98 + DLT_USER6 = 0x99 + DLT_USER7 = 0x9a + DLT_USER8 = 0x9b + DLT_USER9 = 0x9c + DLT_WIHART = 0xdf + DLT_X2E_SERIAL = 0xd5 + DLT_X2E_XORAYA = 0xd6 + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x40 + ECHOE = 0x2 + ECHOK = 0x4 + ECHOKE = 0x1 + ECHONL = 0x10 + ECHOPRT = 0x20 + EVFILT_AIO = -0x3 + EVFILT_FS = -0x9 + EVFILT_LIO = -0xa + EVFILT_PROC = -0x5 + EVFILT_READ = -0x1 + EVFILT_SIGNAL = -0x6 + EVFILT_SYSCOUNT = 0xb + EVFILT_TIMER = -0x7 + EVFILT_USER = -0xb + EVFILT_VNODE = -0x4 + EVFILT_WRITE = -0x2 + EV_ADD = 0x1 + EV_CLEAR = 0x20 + EV_DELETE = 0x2 + EV_DISABLE = 0x8 + EV_DISPATCH = 0x80 + EV_DROP = 0x1000 + EV_ENABLE = 0x4 + EV_EOF = 0x8000 + EV_ERROR = 0x4000 + EV_FLAG1 = 0x2000 + EV_ONESHOT = 0x10 + EV_RECEIPT = 0x40 + EV_SYSFLAGS = 0xf000 + EXTA = 0x4b00 + EXTATTR_NAMESPACE_EMPTY = 0x0 + EXTATTR_NAMESPACE_SYSTEM = 0x2 + EXTATTR_NAMESPACE_USER = 0x1 + EXTB = 0x9600 + EXTPROC = 0x800 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FLUSHO = 0x800000 + F_CANCEL = 0x5 + F_DUP2FD = 0xa + F_DUP2FD_CLOEXEC = 0x12 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x11 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLK = 0xb + F_GETOWN = 0x5 + F_OGETLK = 0x7 + F_OK = 0x0 + F_OSETLK = 0x8 + F_OSETLKW = 0x9 + F_RDAHEAD = 0x10 + F_RDLCK = 0x1 + F_READAHEAD = 0xf + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLK = 0xc + F_SETLKW = 0xd + F_SETLK_REMOTE = 0xe + F_SETOWN = 0x6 + F_UNLCK = 0x2 + F_UNLCKSYS = 0x4 + F_WRLCK = 0x3 + HUPCL = 0x4000 + ICANON = 0x100 + ICMP6_FILTER = 0x12 + ICRNL = 0x100 + IEXTEN = 0x400 + IFAN_ARRIVAL = 0x0 + IFAN_DEPARTURE = 0x1 + IFF_ALLMULTI = 0x200 + IFF_ALTPHYS = 0x4000 + IFF_BROADCAST = 0x2 + IFF_CANTCHANGE = 0x218f72 + IFF_CANTCONFIG = 0x10000 + IFF_DEBUG = 0x4 + IFF_DRV_OACTIVE = 0x400 + IFF_DRV_RUNNING = 0x40 + IFF_DYING = 0x200000 + IFF_LINK0 = 0x1000 + IFF_LINK1 = 0x2000 + IFF_LINK2 = 0x4000 + IFF_LOOPBACK = 0x8 + IFF_MONITOR = 0x40000 + IFF_MULTICAST = 0x8000 + IFF_NOARP = 0x80 + IFF_OACTIVE = 0x400 + IFF_POINTOPOINT = 0x10 + IFF_PPROMISC = 0x20000 + IFF_PROMISC = 0x100 + IFF_RENAMING = 0x400000 + IFF_RUNNING = 0x40 + IFF_SIMPLEX = 0x800 + IFF_SMART = 0x20 + IFF_STATICARP = 0x80000 + IFF_UP = 0x1 + IFNAMSIZ = 0x10 + 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_BRIDGE = 0xd1 + IFT_BSC = 0x53 + IFT_CARP = 0xf8 + 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_IEEE1394 = 0x90 + IFT_IEEE80211 = 0x47 + IFT_IEEE80212 = 0x37 + IFT_IEEE8023ADLAG = 0xa1 + IFT_IFGSN = 0x91 + IFT_IMT = 0xbe + IFT_INFINIBAND = 0xc7 + 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_L2VLAN = 0x87 + IFT_L3IPVLAN = 0x88 + 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_PPP = 0x17 + IFT_PPPMULTILINKBUNDLE = 0x6c + IFT_PROPBWAP2MP = 0xb8 + IFT_PROPCNLS = 0x59 + IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5 + IFT_PROPDOCSWIRELESSMACLAYER = 0xb4 + IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6 + IFT_PROPMUX = 0x36 + IFT_PROPVIRTUAL = 0x35 + 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 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLASSD_HOST = 0xfffffff + IN_CLASSD_NET = 0xf0000000 + IN_CLASSD_NSHIFT = 0x1c + IN_LOOPBACKNET = 0x7f + IN_RFC3021_MASK = 0xfffffffe + IPPROTO_3PC = 0x22 + IPPROTO_ADFS = 0x44 + IPPROTO_AH = 0x33 + IPPROTO_AHIP = 0x3d + IPPROTO_APES = 0x63 + IPPROTO_ARGUS = 0xd + IPPROTO_AX25 = 0x5d + IPPROTO_BHA = 0x31 + IPPROTO_BLT = 0x1e + IPPROTO_BRSATMON = 0x4c + IPPROTO_CARP = 0x70 + IPPROTO_CFTP = 0x3e + IPPROTO_CHAOS = 0x10 + IPPROTO_CMTP = 0x26 + IPPROTO_CPHB = 0x49 + IPPROTO_CPNX = 0x48 + IPPROTO_DDP = 0x25 + IPPROTO_DGP = 0x56 + IPPROTO_DIVERT = 0x102 + IPPROTO_DONE = 0x101 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_EMCON = 0xe + IPPROTO_ENCAP = 0x62 + IPPROTO_EON = 0x50 + IPPROTO_ESP = 0x32 + IPPROTO_ETHERIP = 0x61 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GGP = 0x3 + IPPROTO_GMTP = 0x64 + IPPROTO_GRE = 0x2f + IPPROTO_HELLO = 0x3f + IPPROTO_HIP = 0x8b + IPPROTO_HMP = 0x14 + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IDPR = 0x23 + IPPROTO_IDRP = 0x2d + IPPROTO_IGMP = 0x2 + IPPROTO_IGP = 0x55 + IPPROTO_IGRP = 0x58 + IPPROTO_IL = 0x28 + IPPROTO_INLSP = 0x34 + IPPROTO_INP = 0x20 + IPPROTO_IP = 0x0 + IPPROTO_IPCOMP = 0x6c + IPPROTO_IPCV = 0x47 + IPPROTO_IPEIP = 0x5e + IPPROTO_IPIP = 0x4 + IPPROTO_IPPC = 0x43 + IPPROTO_IPV4 = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_IRTP = 0x1c + IPPROTO_KRYPTOLAN = 0x41 + IPPROTO_LARP = 0x5b + IPPROTO_LEAF1 = 0x19 + IPPROTO_LEAF2 = 0x1a + IPPROTO_MAX = 0x100 + IPPROTO_MAXID = 0x34 + IPPROTO_MEAS = 0x13 + IPPROTO_MH = 0x87 + IPPROTO_MHRP = 0x30 + IPPROTO_MICP = 0x5f + IPPROTO_MOBILE = 0x37 + IPPROTO_MPLS = 0x89 + IPPROTO_MTP = 0x5c + IPPROTO_MUX = 0x12 + IPPROTO_ND = 0x4d + IPPROTO_NHRP = 0x36 + IPPROTO_NONE = 0x3b + IPPROTO_NSP = 0x1f + IPPROTO_NVPII = 0xb + IPPROTO_OLD_DIVERT = 0xfe + IPPROTO_OSPFIGP = 0x59 + IPPROTO_PFSYNC = 0xf0 + IPPROTO_PGM = 0x71 + IPPROTO_PIGP = 0x9 + IPPROTO_PIM = 0x67 + IPPROTO_PRM = 0x15 + IPPROTO_PUP = 0xc + IPPROTO_PVP = 0x4b + IPPROTO_RAW = 0xff + IPPROTO_RCCMON = 0xa + IPPROTO_RDP = 0x1b + IPPROTO_RESERVED_253 = 0xfd + IPPROTO_RESERVED_254 = 0xfe + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_RVD = 0x42 + IPPROTO_SATEXPAK = 0x40 + IPPROTO_SATMON = 0x45 + IPPROTO_SCCSP = 0x60 + IPPROTO_SCTP = 0x84 + IPPROTO_SDRP = 0x2a + IPPROTO_SEND = 0x103 + IPPROTO_SEP = 0x21 + IPPROTO_SHIM6 = 0x8c + IPPROTO_SKIP = 0x39 + IPPROTO_SPACER = 0x7fff + IPPROTO_SRPC = 0x5a + IPPROTO_ST = 0x7 + IPPROTO_SVMTP = 0x52 + IPPROTO_SWIPE = 0x35 + IPPROTO_TCF = 0x57 + IPPROTO_TCP = 0x6 + IPPROTO_TLSP = 0x38 + IPPROTO_TP = 0x1d + IPPROTO_TPXX = 0x27 + IPPROTO_TRUNK1 = 0x17 + IPPROTO_TRUNK2 = 0x18 + IPPROTO_TTP = 0x54 + IPPROTO_UDP = 0x11 + IPPROTO_UDPLITE = 0x88 + IPPROTO_VINES = 0x53 + IPPROTO_VISA = 0x46 + IPPROTO_VMTP = 0x51 + IPPROTO_WBEXPAK = 0x4f + IPPROTO_WBMON = 0x4e + IPPROTO_WSN = 0x4a + IPPROTO_XNET = 0xf + IPPROTO_XTP = 0x24 + IPV6_AUTOFLOWLABEL = 0x3b + IPV6_BINDANY = 0x40 + IPV6_BINDV6ONLY = 0x1b + IPV6_CHECKSUM = 0x1a + IPV6_DEFAULT_MULTICAST_HOPS = 0x1 + IPV6_DEFAULT_MULTICAST_LOOP = 0x1 + IPV6_DEFHLIM = 0x40 + IPV6_DONTFRAG = 0x3e + IPV6_DSTOPTS = 0x32 + IPV6_FAITH = 0x1d + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 + IPV6_FRAGTTL = 0x78 + IPV6_FW_ADD = 0x1e + IPV6_FW_DEL = 0x1f + IPV6_FW_FLUSH = 0x20 + IPV6_FW_GET = 0x22 + IPV6_FW_ZERO = 0x21 + IPV6_HLIMDEC = 0x1 + IPV6_HOPLIMIT = 0x2f + IPV6_HOPOPTS = 0x31 + IPV6_IPSEC_POLICY = 0x1c + IPV6_JOIN_GROUP = 0xc + IPV6_LEAVE_GROUP = 0xd + IPV6_MAXHLIM = 0xff + IPV6_MAXOPTHDR = 0x800 + IPV6_MAXPACKET = 0xffff + IPV6_MAX_GROUP_SRC_FILTER = 0x200 + IPV6_MAX_MEMBERSHIPS = 0xfff + IPV6_MAX_SOCK_SRC_FILTER = 0x80 + IPV6_MIN_MEMBERSHIPS = 0x1f + IPV6_MMTU = 0x500 + IPV6_MSFILTER = 0x4a + IPV6_MULTICAST_HOPS = 0xa + IPV6_MULTICAST_IF = 0x9 + IPV6_MULTICAST_LOOP = 0xb + IPV6_NEXTHOP = 0x30 + IPV6_PATHMTU = 0x2c + IPV6_PKTINFO = 0x2e + IPV6_PORTRANGE = 0xe + IPV6_PORTRANGE_DEFAULT = 0x0 + IPV6_PORTRANGE_HIGH = 0x1 + IPV6_PORTRANGE_LOW = 0x2 + IPV6_PREFER_TEMPADDR = 0x3f + IPV6_RECVDSTOPTS = 0x28 + IPV6_RECVHOPLIMIT = 0x25 + IPV6_RECVHOPOPTS = 0x27 + IPV6_RECVPATHMTU = 0x2b + IPV6_RECVPKTINFO = 0x24 + IPV6_RECVRTHDR = 0x26 + IPV6_RECVTCLASS = 0x39 + IPV6_RTHDR = 0x33 + IPV6_RTHDRDSTOPTS = 0x23 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_SOCKOPT_RESERVED1 = 0x3 + IPV6_TCLASS = 0x3d + IPV6_UNICAST_HOPS = 0x4 + IPV6_USE_MIN_MTU = 0x2a + IPV6_V6ONLY = 0x1b + IPV6_VERSION = 0x60 + IPV6_VERSION_MASK = 0xf0 + IP_ADD_MEMBERSHIP = 0xc + IP_ADD_SOURCE_MEMBERSHIP = 0x46 + IP_BINDANY = 0x18 + IP_BLOCK_SOURCE = 0x48 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DONTFRAG = 0x43 + IP_DROP_MEMBERSHIP = 0xd + IP_DROP_SOURCE_MEMBERSHIP = 0x47 + IP_DUMMYNET3 = 0x31 + IP_DUMMYNET_CONFIGURE = 0x3c + IP_DUMMYNET_DEL = 0x3d + IP_DUMMYNET_FLUSH = 0x3e + IP_DUMMYNET_GET = 0x40 + IP_FAITH = 0x16 + IP_FW3 = 0x30 + IP_FW_ADD = 0x32 + IP_FW_DEL = 0x33 + IP_FW_FLUSH = 0x34 + IP_FW_GET = 0x36 + IP_FW_NAT_CFG = 0x38 + IP_FW_NAT_DEL = 0x39 + IP_FW_NAT_GET_CONFIG = 0x3a + IP_FW_NAT_GET_LOG = 0x3b + IP_FW_RESETLOG = 0x37 + IP_FW_TABLE_ADD = 0x28 + IP_FW_TABLE_DEL = 0x29 + IP_FW_TABLE_FLUSH = 0x2a + IP_FW_TABLE_GETSIZE = 0x2b + IP_FW_TABLE_LIST = 0x2c + IP_FW_ZERO = 0x35 + IP_HDRINCL = 0x2 + IP_IPSEC_POLICY = 0x15 + IP_MAXPACKET = 0xffff + IP_MAX_GROUP_SRC_FILTER = 0x200 + IP_MAX_MEMBERSHIPS = 0xfff + IP_MAX_SOCK_MUTE_FILTER = 0x80 + IP_MAX_SOCK_SRC_FILTER = 0x80 + IP_MAX_SOURCE_FILTER = 0x400 + IP_MF = 0x2000 + IP_MINTTL = 0x42 + IP_MIN_MEMBERSHIPS = 0x1f + IP_MSFILTER = 0x4a + IP_MSS = 0x240 + IP_MULTICAST_IF = 0x9 + IP_MULTICAST_LOOP = 0xb + IP_MULTICAST_TTL = 0xa + IP_MULTICAST_VIF = 0xe + IP_OFFMASK = 0x1fff + IP_ONESBCAST = 0x17 + IP_OPTIONS = 0x1 + IP_PORTRANGE = 0x13 + IP_PORTRANGE_DEFAULT = 0x0 + IP_PORTRANGE_HIGH = 0x1 + IP_PORTRANGE_LOW = 0x2 + IP_RECVDSTADDR = 0x7 + IP_RECVIF = 0x14 + IP_RECVOPTS = 0x5 + IP_RECVRETOPTS = 0x6 + IP_RECVTOS = 0x44 + IP_RECVTTL = 0x41 + IP_RETOPTS = 0x8 + IP_RF = 0x8000 + IP_RSVP_OFF = 0x10 + IP_RSVP_ON = 0xf + IP_RSVP_VIF_OFF = 0x12 + IP_RSVP_VIF_ON = 0x11 + IP_SENDSRCADDR = 0x7 + IP_TOS = 0x3 + IP_TTL = 0x4 + IP_UNBLOCK_SOURCE = 0x49 + ISIG = 0x80 + ISTRIP = 0x20 + IXANY = 0x800 + IXOFF = 0x400 + IXON = 0x200 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_AUTOSYNC = 0x7 + MADV_CORE = 0x9 + MADV_DONTNEED = 0x4 + MADV_FREE = 0x5 + MADV_NOCORE = 0x8 + MADV_NORMAL = 0x0 + MADV_NOSYNC = 0x6 + MADV_PROTECT = 0xa + MADV_RANDOM = 0x1 + MADV_SEQUENTIAL = 0x2 + MADV_WILLNEED = 0x3 + MAP_32BIT = 0x80000 + MAP_ALIGNED_SUPER = 0x1000000 + MAP_ALIGNMENT_MASK = -0x1000000 + MAP_ALIGNMENT_SHIFT = 0x18 + MAP_ANON = 0x1000 + MAP_ANONYMOUS = 0x1000 + MAP_COPY = 0x2 + MAP_EXCL = 0x4000 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_HASSEMAPHORE = 0x200 + MAP_NOCORE = 0x20000 + MAP_NORESERVE = 0x40 + MAP_NOSYNC = 0x800 + MAP_PREFAULT_READ = 0x40000 + MAP_PRIVATE = 0x2 + MAP_RENAME = 0x20 + MAP_RESERVED0080 = 0x80 + MAP_RESERVED0100 = 0x100 + MAP_SHARED = 0x1 + MAP_STACK = 0x400 + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MSG_CMSG_CLOEXEC = 0x40000 + MSG_COMPAT = 0x8000 + MSG_CTRUNC = 0x20 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x80 + MSG_EOF = 0x100 + MSG_EOR = 0x8 + MSG_NBIO = 0x4000 + MSG_NOSIGNAL = 0x20000 + MSG_NOTIFICATION = 0x2000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_TRUNC = 0x10 + MSG_WAITALL = 0x40 + MS_ASYNC = 0x1 + MS_INVALIDATE = 0x2 + MS_SYNC = 0x0 + NAME_MAX = 0xff + NET_RT_DUMP = 0x1 + NET_RT_FLAGS = 0x2 + NET_RT_IFLIST = 0x3 + NET_RT_IFLISTL = 0x5 + NET_RT_IFMALIST = 0x4 + NET_RT_MAXID = 0x6 + NOFLSH = 0x80000000 + NOTE_ATTRIB = 0x8 + NOTE_CHILD = 0x4 + NOTE_DELETE = 0x1 + NOTE_EXEC = 0x20000000 + NOTE_EXIT = 0x80000000 + NOTE_EXTEND = 0x4 + NOTE_FFAND = 0x40000000 + NOTE_FFCOPY = 0xc0000000 + NOTE_FFCTRLMASK = 0xc0000000 + NOTE_FFLAGSMASK = 0xffffff + NOTE_FFNOP = 0x0 + NOTE_FFOR = 0x80000000 + NOTE_FORK = 0x40000000 + NOTE_LINK = 0x10 + NOTE_LOWAT = 0x1 + NOTE_MSECONDS = 0x2 + NOTE_NSECONDS = 0x8 + NOTE_PCTRLMASK = 0xf0000000 + NOTE_PDATAMASK = 0xfffff + NOTE_RENAME = 0x20 + NOTE_REVOKE = 0x40 + NOTE_SECONDS = 0x1 + NOTE_TRACK = 0x1 + NOTE_TRACKERR = 0x2 + NOTE_TRIGGER = 0x1000000 + NOTE_USECONDS = 0x4 + NOTE_WRITE = 0x2 + OCRNL = 0x10 + ONLCR = 0x2 + ONLRET = 0x40 + ONOCR = 0x20 + ONOEOT = 0x8 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_APPEND = 0x8 + O_ASYNC = 0x40 + O_CLOEXEC = 0x100000 + O_CREAT = 0x200 + O_DIRECT = 0x10000 + O_DIRECTORY = 0x20000 + O_EXCL = 0x800 + O_EXEC = 0x40000 + O_EXLOCK = 0x20 + O_FSYNC = 0x80 + O_NDELAY = 0x4 + O_NOCTTY = 0x8000 + O_NOFOLLOW = 0x100 + O_NONBLOCK = 0x4 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_SHLOCK = 0x10 + O_SYNC = 0x80 + O_TRUNC = 0x400 + O_TTY_INIT = 0x80000 + O_WRONLY = 0x1 + PARENB = 0x1000 + PARMRK = 0x8 + PARODD = 0x2000 + PENDIN = 0x20000000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + RLIMIT_AS = 0xa + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x8 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = 0x7fffffffffffffff + RTAX_AUTHOR = 0x6 + RTAX_BRD = 0x7 + RTAX_DST = 0x0 + RTAX_GATEWAY = 0x1 + RTAX_GENMASK = 0x3 + RTAX_IFA = 0x5 + RTAX_IFP = 0x4 + RTAX_MAX = 0x8 + RTAX_NETMASK = 0x2 + RTA_AUTHOR = 0x40 + RTA_BRD = 0x80 + RTA_DST = 0x1 + RTA_GATEWAY = 0x2 + RTA_GENMASK = 0x8 + RTA_IFA = 0x20 + RTA_IFP = 0x10 + RTA_NETMASK = 0x4 + RTF_BLACKHOLE = 0x1000 + RTF_BROADCAST = 0x400000 + RTF_DONE = 0x40 + RTF_DYNAMIC = 0x10 + RTF_FMASK = 0x1004d808 + RTF_GATEWAY = 0x2 + RTF_GWFLAG_COMPAT = 0x80000000 + RTF_HOST = 0x4 + RTF_LLDATA = 0x400 + RTF_LLINFO = 0x400 + RTF_LOCAL = 0x200000 + RTF_MODIFIED = 0x20 + RTF_MULTICAST = 0x800000 + RTF_PINNED = 0x100000 + RTF_PRCLONING = 0x10000 + RTF_PROTO1 = 0x8000 + RTF_PROTO2 = 0x4000 + RTF_PROTO3 = 0x40000 + RTF_REJECT = 0x8 + RTF_RNH_LOCKED = 0x40000000 + RTF_STATIC = 0x800 + RTF_STICKY = 0x10000000 + RTF_UP = 0x1 + RTF_XRESOLVE = 0x200 + RTM_ADD = 0x1 + RTM_CHANGE = 0x3 + RTM_DELADDR = 0xd + RTM_DELETE = 0x2 + RTM_DELMADDR = 0x10 + RTM_GET = 0x4 + RTM_IEEE80211 = 0x12 + RTM_IFANNOUNCE = 0x11 + RTM_IFINFO = 0xe + RTM_LOCK = 0x8 + RTM_LOSING = 0x5 + RTM_MISS = 0x7 + RTM_NEWADDR = 0xc + RTM_NEWMADDR = 0xf + RTM_OLDADD = 0x9 + RTM_OLDDEL = 0xa + RTM_REDIRECT = 0x6 + RTM_RESOLVE = 0xb + RTM_RTTUNIT = 0xf4240 + RTM_VERSION = 0x5 + RTV_EXPIRE = 0x4 + RTV_HOPCOUNT = 0x2 + RTV_MTU = 0x1 + RTV_RPIPE = 0x8 + RTV_RTT = 0x40 + RTV_RTTVAR = 0x80 + RTV_SPIPE = 0x10 + RTV_SSTHRESH = 0x20 + RTV_WEIGHT = 0x100 + RT_ALL_FIBS = -0x1 + RT_CACHING_CONTEXT = 0x1 + RT_DEFAULT_FIB = 0x0 + RT_NORTREF = 0x2 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + RUSAGE_THREAD = 0x1 + SCM_BINTIME = 0x4 + SCM_CREDS = 0x3 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x2 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDMULTI = 0x80206931 + SIOCADDRT = 0x8040720a + SIOCAIFADDR = 0x8040691a + SIOCAIFGROUP = 0x80286987 + SIOCALIFADDR = 0x8118691b + SIOCATMARK = 0x40047307 + SIOCDELMULTI = 0x80206932 + SIOCDELRT = 0x8040720b + SIOCDIFADDR = 0x80206919 + SIOCDIFGROUP = 0x80286989 + SIOCDIFPHYADDR = 0x80206949 + SIOCDLIFADDR = 0x8118691d + SIOCGDRVSPEC = 0xc028697b + SIOCGETSGCNT = 0xc0207210 + SIOCGETVIFCNT = 0xc028720f + SIOCGHIWAT = 0x40047301 + SIOCGIFADDR = 0xc0206921 + SIOCGIFBRDADDR = 0xc0206923 + SIOCGIFCAP = 0xc020691f + SIOCGIFCONF = 0xc0106924 + SIOCGIFDESCR = 0xc020692a + SIOCGIFDSTADDR = 0xc0206922 + SIOCGIFFIB = 0xc020695c + SIOCGIFFLAGS = 0xc0206911 + SIOCGIFGENERIC = 0xc020693a + SIOCGIFGMEMB = 0xc028698a + SIOCGIFGROUP = 0xc0286988 + SIOCGIFINDEX = 0xc0206920 + SIOCGIFMAC = 0xc0206926 + SIOCGIFMEDIA = 0xc0306938 + SIOCGIFMETRIC = 0xc0206917 + SIOCGIFMTU = 0xc0206933 + SIOCGIFNETMASK = 0xc0206925 + SIOCGIFPDSTADDR = 0xc0206948 + SIOCGIFPHYS = 0xc0206935 + SIOCGIFPSRCADDR = 0xc0206947 + SIOCGIFSTATUS = 0xc331693b + SIOCGLIFADDR = 0xc118691c + SIOCGLIFPHYADDR = 0xc118694b + SIOCGLOWAT = 0x40047303 + SIOCGPGRP = 0x40047309 + SIOCGPRIVATE_0 = 0xc0206950 + SIOCGPRIVATE_1 = 0xc0206951 + SIOCIFCREATE = 0xc020697a + SIOCIFCREATE2 = 0xc020697c + SIOCIFDESTROY = 0x80206979 + SIOCIFGCLONERS = 0xc0106978 + SIOCSDRVSPEC = 0x8028697b + SIOCSHIWAT = 0x80047300 + SIOCSIFADDR = 0x8020690c + SIOCSIFBRDADDR = 0x80206913 + SIOCSIFCAP = 0x8020691e + SIOCSIFDESCR = 0x80206929 + SIOCSIFDSTADDR = 0x8020690e + SIOCSIFFIB = 0x8020695d + SIOCSIFFLAGS = 0x80206910 + SIOCSIFGENERIC = 0x80206939 + SIOCSIFLLADDR = 0x8020693c + SIOCSIFMAC = 0x80206927 + SIOCSIFMEDIA = 0xc0206937 + SIOCSIFMETRIC = 0x80206918 + SIOCSIFMTU = 0x80206934 + SIOCSIFNAME = 0x80206928 + SIOCSIFNETMASK = 0x80206916 + SIOCSIFPHYADDR = 0x80406946 + SIOCSIFPHYS = 0x80206936 + SIOCSIFRVNET = 0xc020695b + SIOCSIFVNET = 0xc020695a + SIOCSLIFPHYADDR = 0x8118694a + SIOCSLOWAT = 0x80047302 + SIOCSPGRP = 0x80047308 + SOCK_CLOEXEC = 0x10000000 + SOCK_DGRAM = 0x2 + SOCK_MAXADDRLEN = 0xff + SOCK_NONBLOCK = 0x20000000 + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_SOCKET = 0xffff + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x2 + SO_ACCEPTFILTER = 0x1000 + SO_BINTIME = 0x2000 + SO_BROADCAST = 0x20 + SO_DEBUG = 0x1 + SO_DONTROUTE = 0x10 + SO_ERROR = 0x1007 + SO_KEEPALIVE = 0x8 + SO_LABEL = 0x1009 + SO_LINGER = 0x80 + SO_LISTENINCQLEN = 0x1013 + SO_LISTENQLEN = 0x1012 + SO_LISTENQLIMIT = 0x1011 + SO_NOSIGPIPE = 0x800 + SO_NO_DDP = 0x8000 + SO_NO_OFFLOAD = 0x4000 + SO_OOBINLINE = 0x100 + SO_PEERLABEL = 0x1010 + SO_PROTOCOL = 0x1016 + SO_PROTOTYPE = 0x1016 + SO_RCVBUF = 0x1002 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x1006 + SO_REUSEADDR = 0x4 + SO_REUSEPORT = 0x200 + SO_SETFIB = 0x1014 + SO_SNDBUF = 0x1001 + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x1005 + SO_TIMESTAMP = 0x400 + SO_TYPE = 0x1008 + SO_USELOOPBACK = 0x40 + SO_USER_COOKIE = 0x1015 + SO_VENDOR = 0x80000000 + TCIFLUSH = 0x1 + TCIOFLUSH = 0x3 + TCOFLUSH = 0x2 + TCP_CA_NAME_MAX = 0x10 + TCP_CONGESTION = 0x40 + TCP_INFO = 0x20 + TCP_KEEPCNT = 0x400 + TCP_KEEPIDLE = 0x100 + TCP_KEEPINIT = 0x80 + TCP_KEEPINTVL = 0x200 + TCP_MAXBURST = 0x4 + TCP_MAXHLEN = 0x3c + TCP_MAXOLEN = 0x28 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_SACK = 0x4 + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0x10 + TCP_MINMSS = 0xd8 + TCP_MSS = 0x218 + TCP_NODELAY = 0x1 + TCP_NOOPT = 0x8 + TCP_NOPUSH = 0x4 + TCP_VENDOR = 0x80000000 + TCSAFLUSH = 0x2 + TIOCCBRK = 0x2000747a + TIOCCDTR = 0x20007478 + TIOCCONS = 0x80047462 + TIOCDRAIN = 0x2000745e + TIOCEXCL = 0x2000740d + TIOCEXT = 0x80047460 + TIOCFLUSH = 0x80047410 + TIOCGDRAINWAIT = 0x40047456 + TIOCGETA = 0x402c7413 + TIOCGETD = 0x4004741a + TIOCGPGRP = 0x40047477 + TIOCGPTN = 0x4004740f + TIOCGSID = 0x40047463 + TIOCGWINSZ = 0x40087468 + TIOCMBIC = 0x8004746b + TIOCMBIS = 0x8004746c + TIOCMGDTRWAIT = 0x4004745a + TIOCMGET = 0x4004746a + TIOCMSDTRWAIT = 0x8004745b + TIOCMSET = 0x8004746d + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DCD = 0x40 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x20007471 + TIOCNXCL = 0x2000740e + TIOCOUTQ = 0x40047473 + TIOCPKT = 0x80047470 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCPTMASTER = 0x2000741c + TIOCSBRK = 0x2000747b + TIOCSCTTY = 0x20007461 + TIOCSDRAINWAIT = 0x80047457 + TIOCSDTR = 0x20007479 + TIOCSETA = 0x802c7414 + TIOCSETAF = 0x802c7416 + TIOCSETAW = 0x802c7415 + TIOCSETD = 0x8004741b + TIOCSIG = 0x2004745f + TIOCSPGRP = 0x80047476 + TIOCSTART = 0x2000746e + TIOCSTAT = 0x20007465 + TIOCSTI = 0x80017472 + TIOCSTOP = 0x2000746f + TIOCSWINSZ = 0x80087467 + TIOCTIMESTAMP = 0x40107459 + TIOCUCNTL = 0x80047466 + TOSTOP = 0x400000 + VDISCARD = 0xf + VDSUSP = 0xb + VEOF = 0x0 + VEOL = 0x1 + VEOL2 = 0x2 + VERASE = 0x3 + VERASE2 = 0x7 + VINTR = 0x8 + VKILL = 0x5 + VLNEXT = 0xe + VMIN = 0x10 + VQUIT = 0x9 + VREPRINT = 0x6 + VSTART = 0xc + VSTATUS = 0x12 + VSTOP = 0xd + VSUSP = 0xa + VTIME = 0x11 + VWERASE = 0x4 + WCONTINUED = 0x4 + WCOREFLAG = 0x80 + WEXITED = 0x10 + WLINUXCLONE = 0x80000000 + WNOHANG = 0x1 + WNOWAIT = 0x8 + WSTOPPED = 0x2 + WTRAPPED = 0x20 + WUNTRACED = 0x2 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x30) + EADDRNOTAVAIL = syscall.Errno(0x31) + EAFNOSUPPORT = syscall.Errno(0x2f) + EAGAIN = syscall.Errno(0x23) + EALREADY = syscall.Errno(0x25) + EAUTH = syscall.Errno(0x50) + EBADF = syscall.Errno(0x9) + EBADMSG = syscall.Errno(0x59) + EBADRPC = syscall.Errno(0x48) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x55) + ECAPMODE = syscall.Errno(0x5e) + ECHILD = syscall.Errno(0xa) + ECONNABORTED = syscall.Errno(0x35) + ECONNREFUSED = syscall.Errno(0x3d) + ECONNRESET = syscall.Errno(0x36) + EDEADLK = syscall.Errno(0xb) + EDESTADDRREQ = syscall.Errno(0x27) + EDOM = syscall.Errno(0x21) + EDOOFUS = syscall.Errno(0x58) + EDQUOT = syscall.Errno(0x45) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EFTYPE = syscall.Errno(0x4f) + EHOSTDOWN = syscall.Errno(0x40) + EHOSTUNREACH = syscall.Errno(0x41) + EIDRM = syscall.Errno(0x52) + EILSEQ = syscall.Errno(0x56) + EINPROGRESS = syscall.Errno(0x24) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x38) + EISDIR = syscall.Errno(0x15) + ELAST = syscall.Errno(0x60) + ELOOP = syscall.Errno(0x3e) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x28) + EMULTIHOP = syscall.Errno(0x5a) + ENAMETOOLONG = syscall.Errno(0x3f) + ENEEDAUTH = syscall.Errno(0x51) + ENETDOWN = syscall.Errno(0x32) + ENETRESET = syscall.Errno(0x34) + ENETUNREACH = syscall.Errno(0x33) + ENFILE = syscall.Errno(0x17) + ENOATTR = syscall.Errno(0x57) + ENOBUFS = syscall.Errno(0x37) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOLCK = syscall.Errno(0x4d) + ENOLINK = syscall.Errno(0x5b) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x53) + ENOPROTOOPT = syscall.Errno(0x2a) + ENOSPC = syscall.Errno(0x1c) + ENOSYS = syscall.Errno(0x4e) + ENOTBLK = syscall.Errno(0xf) + ENOTCAPABLE = syscall.Errno(0x5d) + ENOTCONN = syscall.Errno(0x39) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x42) + ENOTRECOVERABLE = syscall.Errno(0x5f) + ENOTSOCK = syscall.Errno(0x26) + ENOTSUP = syscall.Errno(0x2d) + ENOTTY = syscall.Errno(0x19) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x2d) + EOVERFLOW = syscall.Errno(0x54) + EOWNERDEAD = syscall.Errno(0x60) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x2e) + EPIPE = syscall.Errno(0x20) + EPROCLIM = syscall.Errno(0x43) + EPROCUNAVAIL = syscall.Errno(0x4c) + EPROGMISMATCH = syscall.Errno(0x4b) + EPROGUNAVAIL = syscall.Errno(0x4a) + EPROTO = syscall.Errno(0x5c) + EPROTONOSUPPORT = syscall.Errno(0x2b) + EPROTOTYPE = syscall.Errno(0x29) + ERANGE = syscall.Errno(0x22) + EREMOTE = syscall.Errno(0x47) + EROFS = syscall.Errno(0x1e) + ERPCMISMATCH = syscall.Errno(0x49) + ESHUTDOWN = syscall.Errno(0x3a) + ESOCKTNOSUPPORT = syscall.Errno(0x2c) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESTALE = syscall.Errno(0x46) + ETIMEDOUT = syscall.Errno(0x3c) + ETOOMANYREFS = syscall.Errno(0x3b) + ETXTBSY = syscall.Errno(0x1a) + EUSERS = syscall.Errno(0x44) + EWOULDBLOCK = syscall.Errno(0x23) + EXDEV = syscall.Errno(0x12) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0xa) + SIGCHLD = syscall.Signal(0x14) + SIGCONT = syscall.Signal(0x13) + SIGEMT = syscall.Signal(0x7) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINFO = syscall.Signal(0x1d) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x17) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGLIBRT = syscall.Signal(0x21) + SIGLWP = syscall.Signal(0x20) + SIGPIPE = syscall.Signal(0xd) + SIGPROF = syscall.Signal(0x1b) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTOP = syscall.Signal(0x11) + SIGSYS = syscall.Signal(0xc) + SIGTERM = syscall.Signal(0xf) + SIGTHR = syscall.Signal(0x20) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x12) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGURG = syscall.Signal(0x10) + SIGUSR1 = syscall.Signal(0x1e) + SIGUSR2 = syscall.Signal(0x1f) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "device not configured", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource deadlock avoided", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device busy", + 17: "file exists", + 18: "cross-device link", + 19: "operation not supported by device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "result too large", + 35: "resource temporarily unavailable", + 36: "operation now in progress", + 37: "operation already in progress", + 38: "socket operation on non-socket", + 39: "destination address required", + 40: "message too long", + 41: "protocol wrong type for socket", + 42: "protocol not available", + 43: "protocol not supported", + 44: "socket type not supported", + 45: "operation not supported", + 46: "protocol family not supported", + 47: "address family not supported by protocol family", + 48: "address already in use", + 49: "can't assign requested address", + 50: "network is down", + 51: "network is unreachable", + 52: "network dropped connection on reset", + 53: "software caused connection abort", + 54: "connection reset by peer", + 55: "no buffer space available", + 56: "socket is already connected", + 57: "socket is not connected", + 58: "can't send after socket shutdown", + 59: "too many references: can't splice", + 60: "operation timed out", + 61: "connection refused", + 62: "too many levels of symbolic links", + 63: "file name too long", + 64: "host is down", + 65: "no route to host", + 66: "directory not empty", + 67: "too many processes", + 68: "too many users", + 69: "disc quota exceeded", + 70: "stale NFS file handle", + 71: "too many levels of remote in path", + 72: "RPC struct is bad", + 73: "RPC version wrong", + 74: "RPC prog. not avail", + 75: "program version wrong", + 76: "bad procedure for program", + 77: "no locks available", + 78: "function not implemented", + 79: "inappropriate file type or format", + 80: "authentication error", + 81: "need authenticator", + 82: "identifier removed", + 83: "no message of desired type", + 84: "value too large to be stored in data type", + 85: "operation canceled", + 86: "illegal byte sequence", + 87: "attribute not found", + 88: "programming error", + 89: "bad message", + 90: "multihop attempted", + 91: "link has been severed", + 92: "protocol error", + 93: "capabilities insufficient", + 94: "not permitted in capability mode", + 95: "state not recoverable", + 96: "previous owner died", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/BPT trap", + 6: "abort trap", + 7: "EMT trap", + 8: "floating point exception", + 9: "killed", + 10: "bus error", + 11: "segmentation fault", + 12: "bad system call", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "urgent I/O condition", + 17: "suspended (signal)", + 18: "suspended", + 19: "continued", + 20: "child exited", + 21: "stopped (tty input)", + 22: "stopped (tty output)", + 23: "I/O possible", + 24: "cputime limit exceeded", + 25: "filesize limit exceeded", + 26: "virtual timer expired", + 27: "profiling timer expired", + 28: "window size changes", + 29: "information request", + 30: "user defined signal 1", + 31: "user defined signal 2", + 32: "unknown signal", + 33: "unknown signal", +} diff --git a/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm.go b/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm.go new file mode 100644 index 0000000000..2afbe2d5ed --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_freebsd_arm.go @@ -0,0 +1,1729 @@ +// mkerrors.sh +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build arm,freebsd + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- _const.go + +package unix + +import "syscall" + +const ( + AF_APPLETALK = 0x10 + AF_ARP = 0x23 + AF_ATM = 0x1e + AF_BLUETOOTH = 0x24 + AF_CCITT = 0xa + AF_CHAOS = 0x5 + AF_CNT = 0x15 + AF_COIP = 0x14 + AF_DATAKIT = 0x9 + AF_DECnet = 0xc + AF_DLI = 0xd + AF_E164 = 0x1a + AF_ECMA = 0x8 + AF_HYLINK = 0xf + AF_IEEE80211 = 0x25 + AF_IMPLINK = 0x3 + AF_INET = 0x2 + AF_INET6 = 0x1c + AF_INET6_SDP = 0x2a + AF_INET_SDP = 0x28 + AF_IPX = 0x17 + AF_ISDN = 0x1a + AF_ISO = 0x7 + AF_LAT = 0xe + AF_LINK = 0x12 + AF_LOCAL = 0x1 + AF_MAX = 0x2a + AF_NATM = 0x1d + AF_NETBIOS = 0x6 + AF_NETGRAPH = 0x20 + AF_OSI = 0x7 + AF_PUP = 0x4 + AF_ROUTE = 0x11 + AF_SCLUSTER = 0x22 + AF_SIP = 0x18 + AF_SLOW = 0x21 + AF_SNA = 0xb + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_VENDOR00 = 0x27 + AF_VENDOR01 = 0x29 + AF_VENDOR02 = 0x2b + AF_VENDOR03 = 0x2d + AF_VENDOR04 = 0x2f + AF_VENDOR05 = 0x31 + AF_VENDOR06 = 0x33 + AF_VENDOR07 = 0x35 + AF_VENDOR08 = 0x37 + AF_VENDOR09 = 0x39 + AF_VENDOR10 = 0x3b + AF_VENDOR11 = 0x3d + AF_VENDOR12 = 0x3f + AF_VENDOR13 = 0x41 + AF_VENDOR14 = 0x43 + AF_VENDOR15 = 0x45 + AF_VENDOR16 = 0x47 + AF_VENDOR17 = 0x49 + AF_VENDOR18 = 0x4b + AF_VENDOR19 = 0x4d + AF_VENDOR20 = 0x4f + AF_VENDOR21 = 0x51 + AF_VENDOR22 = 0x53 + AF_VENDOR23 = 0x55 + AF_VENDOR24 = 0x57 + AF_VENDOR25 = 0x59 + AF_VENDOR26 = 0x5b + AF_VENDOR27 = 0x5d + AF_VENDOR28 = 0x5f + AF_VENDOR29 = 0x61 + AF_VENDOR30 = 0x63 + AF_VENDOR31 = 0x65 + AF_VENDOR32 = 0x67 + AF_VENDOR33 = 0x69 + AF_VENDOR34 = 0x6b + AF_VENDOR35 = 0x6d + AF_VENDOR36 = 0x6f + AF_VENDOR37 = 0x71 + AF_VENDOR38 = 0x73 + AF_VENDOR39 = 0x75 + AF_VENDOR40 = 0x77 + AF_VENDOR41 = 0x79 + AF_VENDOR42 = 0x7b + AF_VENDOR43 = 0x7d + AF_VENDOR44 = 0x7f + AF_VENDOR45 = 0x81 + AF_VENDOR46 = 0x83 + AF_VENDOR47 = 0x85 + B0 = 0x0 + B110 = 0x6e + B115200 = 0x1c200 + B1200 = 0x4b0 + B134 = 0x86 + B14400 = 0x3840 + B150 = 0x96 + B1800 = 0x708 + B19200 = 0x4b00 + B200 = 0xc8 + B230400 = 0x38400 + B2400 = 0x960 + B28800 = 0x7080 + B300 = 0x12c + B38400 = 0x9600 + B460800 = 0x70800 + B4800 = 0x12c0 + B50 = 0x32 + B57600 = 0xe100 + B600 = 0x258 + B7200 = 0x1c20 + B75 = 0x4b + B76800 = 0x12c00 + B921600 = 0xe1000 + B9600 = 0x2580 + BIOCFEEDBACK = 0x8004427c + BIOCFLUSH = 0x20004268 + BIOCGBLEN = 0x40044266 + BIOCGDIRECTION = 0x40044276 + BIOCGDLT = 0x4004426a + BIOCGDLTLIST = 0xc0084279 + BIOCGETBUFMODE = 0x4004427d + BIOCGETIF = 0x4020426b + BIOCGETZMAX = 0x4004427f + BIOCGHDRCMPLT = 0x40044274 + BIOCGRSIG = 0x40044272 + BIOCGRTIMEOUT = 0x4008426e + BIOCGSEESENT = 0x40044276 + BIOCGSTATS = 0x4008426f + BIOCGTSTAMP = 0x40044283 + BIOCIMMEDIATE = 0x80044270 + BIOCLOCK = 0x2000427a + BIOCPROMISC = 0x20004269 + BIOCROTZBUF = 0x400c4280 + BIOCSBLEN = 0xc0044266 + BIOCSDIRECTION = 0x80044277 + BIOCSDLT = 0x80044278 + BIOCSETBUFMODE = 0x8004427e + BIOCSETF = 0x80084267 + BIOCSETFNR = 0x80084282 + BIOCSETIF = 0x8020426c + BIOCSETWF = 0x8008427b + BIOCSETZBUF = 0x800c4281 + BIOCSHDRCMPLT = 0x80044275 + BIOCSRSIG = 0x80044273 + BIOCSRTIMEOUT = 0x8008426d + BIOCSSEESENT = 0x80044277 + BIOCSTSTAMP = 0x80044284 + BIOCVERSION = 0x40044271 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALIGNMENT = 0x4 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_BUFMODE_BUFFER = 0x1 + BPF_BUFMODE_ZBUF = 0x2 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXBUFSIZE = 0x80000 + BPF_MAXINSNS = 0x200 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINBUFSIZE = 0x20 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RELEASE = 0x30bb6 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_T_BINTIME = 0x2 + BPF_T_BINTIME_FAST = 0x102 + BPF_T_BINTIME_MONOTONIC = 0x202 + BPF_T_BINTIME_MONOTONIC_FAST = 0x302 + BPF_T_FAST = 0x100 + BPF_T_FLAG_MASK = 0x300 + BPF_T_FORMAT_MASK = 0x3 + BPF_T_MICROTIME = 0x0 + BPF_T_MICROTIME_FAST = 0x100 + BPF_T_MICROTIME_MONOTONIC = 0x200 + BPF_T_MICROTIME_MONOTONIC_FAST = 0x300 + BPF_T_MONOTONIC = 0x200 + BPF_T_MONOTONIC_FAST = 0x300 + BPF_T_NANOTIME = 0x1 + BPF_T_NANOTIME_FAST = 0x101 + BPF_T_NANOTIME_MONOTONIC = 0x201 + BPF_T_NANOTIME_MONOTONIC_FAST = 0x301 + BPF_T_NONE = 0x3 + BPF_T_NORMAL = 0x0 + BPF_W = 0x0 + BPF_X = 0x8 + BRKINT = 0x2 + CFLUSH = 0xf + CLOCAL = 0x8000 + CREAD = 0x800 + CS5 = 0x0 + CS6 = 0x100 + CS7 = 0x200 + CS8 = 0x300 + CSIZE = 0x300 + CSTART = 0x11 + CSTATUS = 0x14 + CSTOP = 0x13 + CSTOPB = 0x400 + CSUSP = 0x1a + CTL_MAXNAME = 0x18 + CTL_NET = 0x4 + DLT_A429 = 0xb8 + DLT_A653_ICM = 0xb9 + DLT_AIRONET_HEADER = 0x78 + DLT_AOS = 0xde + DLT_APPLE_IP_OVER_IEEE1394 = 0x8a + DLT_ARCNET = 0x7 + DLT_ARCNET_LINUX = 0x81 + DLT_ATM_CLIP = 0x13 + DLT_ATM_RFC1483 = 0xb + DLT_AURORA = 0x7e + DLT_AX25 = 0x3 + DLT_AX25_KISS = 0xca + DLT_BACNET_MS_TP = 0xa5 + DLT_BLUETOOTH_HCI_H4 = 0xbb + DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9 + DLT_CAN20B = 0xbe + DLT_CAN_SOCKETCAN = 0xe3 + DLT_CHAOS = 0x5 + DLT_CHDLC = 0x68 + DLT_CISCO_IOS = 0x76 + DLT_C_HDLC = 0x68 + DLT_C_HDLC_WITH_DIR = 0xcd + DLT_DBUS = 0xe7 + DLT_DECT = 0xdd + DLT_DOCSIS = 0x8f + DLT_DVB_CI = 0xeb + DLT_ECONET = 0x73 + DLT_EN10MB = 0x1 + DLT_EN3MB = 0x2 + DLT_ENC = 0x6d + DLT_ERF = 0xc5 + DLT_ERF_ETH = 0xaf + DLT_ERF_POS = 0xb0 + DLT_FC_2 = 0xe0 + DLT_FC_2_WITH_FRAME_DELIMS = 0xe1 + DLT_FDDI = 0xa + DLT_FLEXRAY = 0xd2 + DLT_FRELAY = 0x6b + DLT_FRELAY_WITH_DIR = 0xce + DLT_GCOM_SERIAL = 0xad + DLT_GCOM_T1E1 = 0xac + DLT_GPF_F = 0xab + DLT_GPF_T = 0xaa + DLT_GPRS_LLC = 0xa9 + DLT_GSMTAP_ABIS = 0xda + DLT_GSMTAP_UM = 0xd9 + DLT_HHDLC = 0x79 + DLT_IBM_SN = 0x92 + DLT_IBM_SP = 0x91 + DLT_IEEE802 = 0x6 + DLT_IEEE802_11 = 0x69 + DLT_IEEE802_11_RADIO = 0x7f + DLT_IEEE802_11_RADIO_AVS = 0xa3 + DLT_IEEE802_15_4 = 0xc3 + DLT_IEEE802_15_4_LINUX = 0xbf + DLT_IEEE802_15_4_NOFCS = 0xe6 + DLT_IEEE802_15_4_NONASK_PHY = 0xd7 + DLT_IEEE802_16_MAC_CPS = 0xbc + DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1 + DLT_IPFILTER = 0x74 + DLT_IPMB = 0xc7 + DLT_IPMB_LINUX = 0xd1 + DLT_IPNET = 0xe2 + DLT_IPOIB = 0xf2 + DLT_IPV4 = 0xe4 + DLT_IPV6 = 0xe5 + DLT_IP_OVER_FC = 0x7a + DLT_JUNIPER_ATM1 = 0x89 + DLT_JUNIPER_ATM2 = 0x87 + DLT_JUNIPER_ATM_CEMIC = 0xee + DLT_JUNIPER_CHDLC = 0xb5 + DLT_JUNIPER_ES = 0x84 + DLT_JUNIPER_ETHER = 0xb2 + DLT_JUNIPER_FIBRECHANNEL = 0xea + DLT_JUNIPER_FRELAY = 0xb4 + DLT_JUNIPER_GGSN = 0x85 + DLT_JUNIPER_ISM = 0xc2 + DLT_JUNIPER_MFR = 0x86 + DLT_JUNIPER_MLFR = 0x83 + DLT_JUNIPER_MLPPP = 0x82 + DLT_JUNIPER_MONITOR = 0xa4 + DLT_JUNIPER_PIC_PEER = 0xae + DLT_JUNIPER_PPP = 0xb3 + DLT_JUNIPER_PPPOE = 0xa7 + DLT_JUNIPER_PPPOE_ATM = 0xa8 + DLT_JUNIPER_SERVICES = 0x88 + DLT_JUNIPER_SRX_E2E = 0xe9 + DLT_JUNIPER_ST = 0xc8 + DLT_JUNIPER_VP = 0xb7 + DLT_JUNIPER_VS = 0xe8 + DLT_LAPB_WITH_DIR = 0xcf + DLT_LAPD = 0xcb + DLT_LIN = 0xd4 + DLT_LINUX_EVDEV = 0xd8 + DLT_LINUX_IRDA = 0x90 + DLT_LINUX_LAPD = 0xb1 + DLT_LINUX_PPP_WITHDIRECTION = 0xa6 + DLT_LINUX_SLL = 0x71 + DLT_LOOP = 0x6c + DLT_LTALK = 0x72 + DLT_MATCHING_MAX = 0xf6 + DLT_MATCHING_MIN = 0x68 + DLT_MFR = 0xb6 + DLT_MOST = 0xd3 + DLT_MPEG_2_TS = 0xf3 + DLT_MPLS = 0xdb + DLT_MTP2 = 0x8c + DLT_MTP2_WITH_PHDR = 0x8b + DLT_MTP3 = 0x8d + DLT_MUX27010 = 0xec + DLT_NETANALYZER = 0xf0 + DLT_NETANALYZER_TRANSPARENT = 0xf1 + DLT_NFC_LLCP = 0xf5 + DLT_NFLOG = 0xef + DLT_NG40 = 0xf4 + DLT_NULL = 0x0 + DLT_PCI_EXP = 0x7d + DLT_PFLOG = 0x75 + DLT_PFSYNC = 0x79 + DLT_PPI = 0xc0 + DLT_PPP = 0x9 + DLT_PPP_BSDOS = 0x10 + DLT_PPP_ETHER = 0x33 + DLT_PPP_PPPD = 0xa6 + DLT_PPP_SERIAL = 0x32 + DLT_PPP_WITH_DIR = 0xcc + DLT_PPP_WITH_DIRECTION = 0xa6 + DLT_PRISM_HEADER = 0x77 + DLT_PRONET = 0x4 + DLT_RAIF1 = 0xc6 + DLT_RAW = 0xc + DLT_RIO = 0x7c + DLT_SCCP = 0x8e + DLT_SITA = 0xc4 + DLT_SLIP = 0x8 + DLT_SLIP_BSDOS = 0xf + DLT_STANAG_5066_D_PDU = 0xed + DLT_SUNATM = 0x7b + DLT_SYMANTEC_FIREWALL = 0x63 + DLT_TZSP = 0x80 + DLT_USB = 0xba + DLT_USB_LINUX = 0xbd + DLT_USB_LINUX_MMAPPED = 0xdc + DLT_USER0 = 0x93 + DLT_USER1 = 0x94 + DLT_USER10 = 0x9d + DLT_USER11 = 0x9e + DLT_USER12 = 0x9f + DLT_USER13 = 0xa0 + DLT_USER14 = 0xa1 + DLT_USER15 = 0xa2 + DLT_USER2 = 0x95 + DLT_USER3 = 0x96 + DLT_USER4 = 0x97 + DLT_USER5 = 0x98 + DLT_USER6 = 0x99 + DLT_USER7 = 0x9a + DLT_USER8 = 0x9b + DLT_USER9 = 0x9c + DLT_WIHART = 0xdf + DLT_X2E_SERIAL = 0xd5 + DLT_X2E_XORAYA = 0xd6 + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x40 + ECHOE = 0x2 + ECHOK = 0x4 + ECHOKE = 0x1 + ECHONL = 0x10 + ECHOPRT = 0x20 + EVFILT_AIO = -0x3 + EVFILT_FS = -0x9 + EVFILT_LIO = -0xa + EVFILT_PROC = -0x5 + EVFILT_READ = -0x1 + EVFILT_SIGNAL = -0x6 + EVFILT_SYSCOUNT = 0xb + EVFILT_TIMER = -0x7 + EVFILT_USER = -0xb + EVFILT_VNODE = -0x4 + EVFILT_WRITE = -0x2 + EV_ADD = 0x1 + EV_CLEAR = 0x20 + EV_DELETE = 0x2 + EV_DISABLE = 0x8 + EV_DISPATCH = 0x80 + EV_DROP = 0x1000 + EV_ENABLE = 0x4 + EV_EOF = 0x8000 + EV_ERROR = 0x4000 + EV_FLAG1 = 0x2000 + EV_ONESHOT = 0x10 + EV_RECEIPT = 0x40 + EV_SYSFLAGS = 0xf000 + EXTA = 0x4b00 + EXTATTR_NAMESPACE_EMPTY = 0x0 + EXTATTR_NAMESPACE_SYSTEM = 0x2 + EXTATTR_NAMESPACE_USER = 0x1 + EXTB = 0x9600 + EXTPROC = 0x800 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FLUSHO = 0x800000 + F_CANCEL = 0x5 + F_DUP2FD = 0xa + F_DUP2FD_CLOEXEC = 0x12 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x11 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLK = 0xb + F_GETOWN = 0x5 + F_OGETLK = 0x7 + F_OK = 0x0 + F_OSETLK = 0x8 + F_OSETLKW = 0x9 + F_RDAHEAD = 0x10 + F_RDLCK = 0x1 + F_READAHEAD = 0xf + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLK = 0xc + F_SETLKW = 0xd + F_SETLK_REMOTE = 0xe + F_SETOWN = 0x6 + F_UNLCK = 0x2 + F_UNLCKSYS = 0x4 + F_WRLCK = 0x3 + HUPCL = 0x4000 + ICANON = 0x100 + ICMP6_FILTER = 0x12 + ICRNL = 0x100 + IEXTEN = 0x400 + IFAN_ARRIVAL = 0x0 + IFAN_DEPARTURE = 0x1 + IFF_ALLMULTI = 0x200 + IFF_ALTPHYS = 0x4000 + IFF_BROADCAST = 0x2 + IFF_CANTCHANGE = 0x218f72 + IFF_CANTCONFIG = 0x10000 + IFF_DEBUG = 0x4 + IFF_DRV_OACTIVE = 0x400 + IFF_DRV_RUNNING = 0x40 + IFF_DYING = 0x200000 + IFF_LINK0 = 0x1000 + IFF_LINK1 = 0x2000 + IFF_LINK2 = 0x4000 + IFF_LOOPBACK = 0x8 + IFF_MONITOR = 0x40000 + IFF_MULTICAST = 0x8000 + IFF_NOARP = 0x80 + IFF_OACTIVE = 0x400 + IFF_POINTOPOINT = 0x10 + IFF_PPROMISC = 0x20000 + IFF_PROMISC = 0x100 + IFF_RENAMING = 0x400000 + IFF_RUNNING = 0x40 + IFF_SIMPLEX = 0x800 + IFF_SMART = 0x20 + IFF_STATICARP = 0x80000 + IFF_UP = 0x1 + IFNAMSIZ = 0x10 + 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_BRIDGE = 0xd1 + IFT_BSC = 0x53 + IFT_CARP = 0xf8 + 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_IEEE1394 = 0x90 + IFT_IEEE80211 = 0x47 + IFT_IEEE80212 = 0x37 + IFT_IEEE8023ADLAG = 0xa1 + IFT_IFGSN = 0x91 + IFT_IMT = 0xbe + IFT_INFINIBAND = 0xc7 + 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_L2VLAN = 0x87 + IFT_L3IPVLAN = 0x88 + 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_PPP = 0x17 + IFT_PPPMULTILINKBUNDLE = 0x6c + IFT_PROPBWAP2MP = 0xb8 + IFT_PROPCNLS = 0x59 + IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5 + IFT_PROPDOCSWIRELESSMACLAYER = 0xb4 + IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6 + IFT_PROPMUX = 0x36 + IFT_PROPVIRTUAL = 0x35 + 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 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLASSD_HOST = 0xfffffff + IN_CLASSD_NET = 0xf0000000 + IN_CLASSD_NSHIFT = 0x1c + IN_LOOPBACKNET = 0x7f + IN_RFC3021_MASK = 0xfffffffe + IPPROTO_3PC = 0x22 + IPPROTO_ADFS = 0x44 + IPPROTO_AH = 0x33 + IPPROTO_AHIP = 0x3d + IPPROTO_APES = 0x63 + IPPROTO_ARGUS = 0xd + IPPROTO_AX25 = 0x5d + IPPROTO_BHA = 0x31 + IPPROTO_BLT = 0x1e + IPPROTO_BRSATMON = 0x4c + IPPROTO_CARP = 0x70 + IPPROTO_CFTP = 0x3e + IPPROTO_CHAOS = 0x10 + IPPROTO_CMTP = 0x26 + IPPROTO_CPHB = 0x49 + IPPROTO_CPNX = 0x48 + IPPROTO_DDP = 0x25 + IPPROTO_DGP = 0x56 + IPPROTO_DIVERT = 0x102 + IPPROTO_DONE = 0x101 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_EMCON = 0xe + IPPROTO_ENCAP = 0x62 + IPPROTO_EON = 0x50 + IPPROTO_ESP = 0x32 + IPPROTO_ETHERIP = 0x61 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GGP = 0x3 + IPPROTO_GMTP = 0x64 + IPPROTO_GRE = 0x2f + IPPROTO_HELLO = 0x3f + IPPROTO_HIP = 0x8b + IPPROTO_HMP = 0x14 + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IDPR = 0x23 + IPPROTO_IDRP = 0x2d + IPPROTO_IGMP = 0x2 + IPPROTO_IGP = 0x55 + IPPROTO_IGRP = 0x58 + IPPROTO_IL = 0x28 + IPPROTO_INLSP = 0x34 + IPPROTO_INP = 0x20 + IPPROTO_IP = 0x0 + IPPROTO_IPCOMP = 0x6c + IPPROTO_IPCV = 0x47 + IPPROTO_IPEIP = 0x5e + IPPROTO_IPIP = 0x4 + IPPROTO_IPPC = 0x43 + IPPROTO_IPV4 = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_IRTP = 0x1c + IPPROTO_KRYPTOLAN = 0x41 + IPPROTO_LARP = 0x5b + IPPROTO_LEAF1 = 0x19 + IPPROTO_LEAF2 = 0x1a + IPPROTO_MAX = 0x100 + IPPROTO_MAXID = 0x34 + IPPROTO_MEAS = 0x13 + IPPROTO_MH = 0x87 + IPPROTO_MHRP = 0x30 + IPPROTO_MICP = 0x5f + IPPROTO_MOBILE = 0x37 + IPPROTO_MPLS = 0x89 + IPPROTO_MTP = 0x5c + IPPROTO_MUX = 0x12 + IPPROTO_ND = 0x4d + IPPROTO_NHRP = 0x36 + IPPROTO_NONE = 0x3b + IPPROTO_NSP = 0x1f + IPPROTO_NVPII = 0xb + IPPROTO_OLD_DIVERT = 0xfe + IPPROTO_OSPFIGP = 0x59 + IPPROTO_PFSYNC = 0xf0 + IPPROTO_PGM = 0x71 + IPPROTO_PIGP = 0x9 + IPPROTO_PIM = 0x67 + IPPROTO_PRM = 0x15 + IPPROTO_PUP = 0xc + IPPROTO_PVP = 0x4b + IPPROTO_RAW = 0xff + IPPROTO_RCCMON = 0xa + IPPROTO_RDP = 0x1b + IPPROTO_RESERVED_253 = 0xfd + IPPROTO_RESERVED_254 = 0xfe + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_RVD = 0x42 + IPPROTO_SATEXPAK = 0x40 + IPPROTO_SATMON = 0x45 + IPPROTO_SCCSP = 0x60 + IPPROTO_SCTP = 0x84 + IPPROTO_SDRP = 0x2a + IPPROTO_SEND = 0x103 + IPPROTO_SEP = 0x21 + IPPROTO_SHIM6 = 0x8c + IPPROTO_SKIP = 0x39 + IPPROTO_SPACER = 0x7fff + IPPROTO_SRPC = 0x5a + IPPROTO_ST = 0x7 + IPPROTO_SVMTP = 0x52 + IPPROTO_SWIPE = 0x35 + IPPROTO_TCF = 0x57 + IPPROTO_TCP = 0x6 + IPPROTO_TLSP = 0x38 + IPPROTO_TP = 0x1d + IPPROTO_TPXX = 0x27 + IPPROTO_TRUNK1 = 0x17 + IPPROTO_TRUNK2 = 0x18 + IPPROTO_TTP = 0x54 + IPPROTO_UDP = 0x11 + IPPROTO_UDPLITE = 0x88 + IPPROTO_VINES = 0x53 + IPPROTO_VISA = 0x46 + IPPROTO_VMTP = 0x51 + IPPROTO_WBEXPAK = 0x4f + IPPROTO_WBMON = 0x4e + IPPROTO_WSN = 0x4a + IPPROTO_XNET = 0xf + IPPROTO_XTP = 0x24 + IPV6_AUTOFLOWLABEL = 0x3b + IPV6_BINDANY = 0x40 + IPV6_BINDV6ONLY = 0x1b + IPV6_CHECKSUM = 0x1a + IPV6_DEFAULT_MULTICAST_HOPS = 0x1 + IPV6_DEFAULT_MULTICAST_LOOP = 0x1 + IPV6_DEFHLIM = 0x40 + IPV6_DONTFRAG = 0x3e + IPV6_DSTOPTS = 0x32 + IPV6_FAITH = 0x1d + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 + IPV6_FRAGTTL = 0x78 + IPV6_FW_ADD = 0x1e + IPV6_FW_DEL = 0x1f + IPV6_FW_FLUSH = 0x20 + IPV6_FW_GET = 0x22 + IPV6_FW_ZERO = 0x21 + IPV6_HLIMDEC = 0x1 + IPV6_HOPLIMIT = 0x2f + IPV6_HOPOPTS = 0x31 + IPV6_IPSEC_POLICY = 0x1c + IPV6_JOIN_GROUP = 0xc + IPV6_LEAVE_GROUP = 0xd + IPV6_MAXHLIM = 0xff + IPV6_MAXOPTHDR = 0x800 + IPV6_MAXPACKET = 0xffff + IPV6_MAX_GROUP_SRC_FILTER = 0x200 + IPV6_MAX_MEMBERSHIPS = 0xfff + IPV6_MAX_SOCK_SRC_FILTER = 0x80 + IPV6_MIN_MEMBERSHIPS = 0x1f + IPV6_MMTU = 0x500 + IPV6_MSFILTER = 0x4a + IPV6_MULTICAST_HOPS = 0xa + IPV6_MULTICAST_IF = 0x9 + IPV6_MULTICAST_LOOP = 0xb + IPV6_NEXTHOP = 0x30 + IPV6_PATHMTU = 0x2c + IPV6_PKTINFO = 0x2e + IPV6_PORTRANGE = 0xe + IPV6_PORTRANGE_DEFAULT = 0x0 + IPV6_PORTRANGE_HIGH = 0x1 + IPV6_PORTRANGE_LOW = 0x2 + IPV6_PREFER_TEMPADDR = 0x3f + IPV6_RECVDSTOPTS = 0x28 + IPV6_RECVHOPLIMIT = 0x25 + IPV6_RECVHOPOPTS = 0x27 + IPV6_RECVPATHMTU = 0x2b + IPV6_RECVPKTINFO = 0x24 + IPV6_RECVRTHDR = 0x26 + IPV6_RECVTCLASS = 0x39 + IPV6_RTHDR = 0x33 + IPV6_RTHDRDSTOPTS = 0x23 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_SOCKOPT_RESERVED1 = 0x3 + IPV6_TCLASS = 0x3d + IPV6_UNICAST_HOPS = 0x4 + IPV6_USE_MIN_MTU = 0x2a + IPV6_V6ONLY = 0x1b + IPV6_VERSION = 0x60 + IPV6_VERSION_MASK = 0xf0 + IP_ADD_MEMBERSHIP = 0xc + IP_ADD_SOURCE_MEMBERSHIP = 0x46 + IP_BINDANY = 0x18 + IP_BLOCK_SOURCE = 0x48 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DONTFRAG = 0x43 + IP_DROP_MEMBERSHIP = 0xd + IP_DROP_SOURCE_MEMBERSHIP = 0x47 + IP_DUMMYNET3 = 0x31 + IP_DUMMYNET_CONFIGURE = 0x3c + IP_DUMMYNET_DEL = 0x3d + IP_DUMMYNET_FLUSH = 0x3e + IP_DUMMYNET_GET = 0x40 + IP_FAITH = 0x16 + IP_FW3 = 0x30 + IP_FW_ADD = 0x32 + IP_FW_DEL = 0x33 + IP_FW_FLUSH = 0x34 + IP_FW_GET = 0x36 + IP_FW_NAT_CFG = 0x38 + IP_FW_NAT_DEL = 0x39 + IP_FW_NAT_GET_CONFIG = 0x3a + IP_FW_NAT_GET_LOG = 0x3b + IP_FW_RESETLOG = 0x37 + IP_FW_TABLE_ADD = 0x28 + IP_FW_TABLE_DEL = 0x29 + IP_FW_TABLE_FLUSH = 0x2a + IP_FW_TABLE_GETSIZE = 0x2b + IP_FW_TABLE_LIST = 0x2c + IP_FW_ZERO = 0x35 + IP_HDRINCL = 0x2 + IP_IPSEC_POLICY = 0x15 + IP_MAXPACKET = 0xffff + IP_MAX_GROUP_SRC_FILTER = 0x200 + IP_MAX_MEMBERSHIPS = 0xfff + IP_MAX_SOCK_MUTE_FILTER = 0x80 + IP_MAX_SOCK_SRC_FILTER = 0x80 + IP_MAX_SOURCE_FILTER = 0x400 + IP_MF = 0x2000 + IP_MINTTL = 0x42 + IP_MIN_MEMBERSHIPS = 0x1f + IP_MSFILTER = 0x4a + IP_MSS = 0x240 + IP_MULTICAST_IF = 0x9 + IP_MULTICAST_LOOP = 0xb + IP_MULTICAST_TTL = 0xa + IP_MULTICAST_VIF = 0xe + IP_OFFMASK = 0x1fff + IP_ONESBCAST = 0x17 + IP_OPTIONS = 0x1 + IP_PORTRANGE = 0x13 + IP_PORTRANGE_DEFAULT = 0x0 + IP_PORTRANGE_HIGH = 0x1 + IP_PORTRANGE_LOW = 0x2 + IP_RECVDSTADDR = 0x7 + IP_RECVIF = 0x14 + IP_RECVOPTS = 0x5 + IP_RECVRETOPTS = 0x6 + IP_RECVTOS = 0x44 + IP_RECVTTL = 0x41 + IP_RETOPTS = 0x8 + IP_RF = 0x8000 + IP_RSVP_OFF = 0x10 + IP_RSVP_ON = 0xf + IP_RSVP_VIF_OFF = 0x12 + IP_RSVP_VIF_ON = 0x11 + IP_SENDSRCADDR = 0x7 + IP_TOS = 0x3 + IP_TTL = 0x4 + IP_UNBLOCK_SOURCE = 0x49 + ISIG = 0x80 + ISTRIP = 0x20 + IXANY = 0x800 + IXOFF = 0x400 + IXON = 0x200 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_AUTOSYNC = 0x7 + MADV_CORE = 0x9 + MADV_DONTNEED = 0x4 + MADV_FREE = 0x5 + MADV_NOCORE = 0x8 + MADV_NORMAL = 0x0 + MADV_NOSYNC = 0x6 + MADV_PROTECT = 0xa + MADV_RANDOM = 0x1 + MADV_SEQUENTIAL = 0x2 + MADV_WILLNEED = 0x3 + MAP_ALIGNED_SUPER = 0x1000000 + MAP_ALIGNMENT_MASK = -0x1000000 + MAP_ALIGNMENT_SHIFT = 0x18 + MAP_ANON = 0x1000 + MAP_ANONYMOUS = 0x1000 + MAP_COPY = 0x2 + MAP_EXCL = 0x4000 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_HASSEMAPHORE = 0x200 + MAP_NOCORE = 0x20000 + MAP_NORESERVE = 0x40 + MAP_NOSYNC = 0x800 + MAP_PREFAULT_READ = 0x40000 + MAP_PRIVATE = 0x2 + MAP_RENAME = 0x20 + MAP_RESERVED0080 = 0x80 + MAP_RESERVED0100 = 0x100 + MAP_SHARED = 0x1 + MAP_STACK = 0x400 + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MSG_CMSG_CLOEXEC = 0x40000 + MSG_COMPAT = 0x8000 + MSG_CTRUNC = 0x20 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x80 + MSG_EOF = 0x100 + MSG_EOR = 0x8 + MSG_NBIO = 0x4000 + MSG_NOSIGNAL = 0x20000 + MSG_NOTIFICATION = 0x2000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_TRUNC = 0x10 + MSG_WAITALL = 0x40 + MS_ASYNC = 0x1 + MS_INVALIDATE = 0x2 + MS_SYNC = 0x0 + NAME_MAX = 0xff + NET_RT_DUMP = 0x1 + NET_RT_FLAGS = 0x2 + NET_RT_IFLIST = 0x3 + NET_RT_IFLISTL = 0x5 + NET_RT_IFMALIST = 0x4 + NET_RT_MAXID = 0x6 + NOFLSH = 0x80000000 + NOTE_ATTRIB = 0x8 + NOTE_CHILD = 0x4 + NOTE_DELETE = 0x1 + NOTE_EXEC = 0x20000000 + NOTE_EXIT = 0x80000000 + NOTE_EXTEND = 0x4 + NOTE_FFAND = 0x40000000 + NOTE_FFCOPY = 0xc0000000 + NOTE_FFCTRLMASK = 0xc0000000 + NOTE_FFLAGSMASK = 0xffffff + NOTE_FFNOP = 0x0 + NOTE_FFOR = 0x80000000 + NOTE_FORK = 0x40000000 + NOTE_LINK = 0x10 + NOTE_LOWAT = 0x1 + NOTE_PCTRLMASK = 0xf0000000 + NOTE_PDATAMASK = 0xfffff + NOTE_RENAME = 0x20 + NOTE_REVOKE = 0x40 + NOTE_TRACK = 0x1 + NOTE_TRACKERR = 0x2 + NOTE_TRIGGER = 0x1000000 + NOTE_WRITE = 0x2 + OCRNL = 0x10 + ONLCR = 0x2 + ONLRET = 0x40 + ONOCR = 0x20 + ONOEOT = 0x8 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_APPEND = 0x8 + O_ASYNC = 0x40 + O_CLOEXEC = 0x100000 + O_CREAT = 0x200 + O_DIRECT = 0x10000 + O_DIRECTORY = 0x20000 + O_EXCL = 0x800 + O_EXEC = 0x40000 + O_EXLOCK = 0x20 + O_FSYNC = 0x80 + O_NDELAY = 0x4 + O_NOCTTY = 0x8000 + O_NOFOLLOW = 0x100 + O_NONBLOCK = 0x4 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_SHLOCK = 0x10 + O_SYNC = 0x80 + O_TRUNC = 0x400 + O_TTY_INIT = 0x80000 + O_WRONLY = 0x1 + PARENB = 0x1000 + PARMRK = 0x8 + PARODD = 0x2000 + PENDIN = 0x20000000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + RLIMIT_AS = 0xa + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x8 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = 0x7fffffffffffffff + RTAX_AUTHOR = 0x6 + RTAX_BRD = 0x7 + RTAX_DST = 0x0 + RTAX_GATEWAY = 0x1 + RTAX_GENMASK = 0x3 + RTAX_IFA = 0x5 + RTAX_IFP = 0x4 + RTAX_MAX = 0x8 + RTAX_NETMASK = 0x2 + RTA_AUTHOR = 0x40 + RTA_BRD = 0x80 + RTA_DST = 0x1 + RTA_GATEWAY = 0x2 + RTA_GENMASK = 0x8 + RTA_IFA = 0x20 + RTA_IFP = 0x10 + RTA_NETMASK = 0x4 + RTF_BLACKHOLE = 0x1000 + RTF_BROADCAST = 0x400000 + RTF_DONE = 0x40 + RTF_DYNAMIC = 0x10 + RTF_FMASK = 0x1004d808 + RTF_GATEWAY = 0x2 + RTF_GWFLAG_COMPAT = 0x80000000 + RTF_HOST = 0x4 + RTF_LLDATA = 0x400 + RTF_LLINFO = 0x400 + RTF_LOCAL = 0x200000 + RTF_MODIFIED = 0x20 + RTF_MULTICAST = 0x800000 + RTF_PINNED = 0x100000 + RTF_PRCLONING = 0x10000 + RTF_PROTO1 = 0x8000 + RTF_PROTO2 = 0x4000 + RTF_PROTO3 = 0x40000 + RTF_REJECT = 0x8 + RTF_RNH_LOCKED = 0x40000000 + RTF_STATIC = 0x800 + RTF_STICKY = 0x10000000 + RTF_UP = 0x1 + RTF_XRESOLVE = 0x200 + RTM_ADD = 0x1 + RTM_CHANGE = 0x3 + RTM_DELADDR = 0xd + RTM_DELETE = 0x2 + RTM_DELMADDR = 0x10 + RTM_GET = 0x4 + RTM_IEEE80211 = 0x12 + RTM_IFANNOUNCE = 0x11 + RTM_IFINFO = 0xe + RTM_LOCK = 0x8 + RTM_LOSING = 0x5 + RTM_MISS = 0x7 + RTM_NEWADDR = 0xc + RTM_NEWMADDR = 0xf + RTM_OLDADD = 0x9 + RTM_OLDDEL = 0xa + RTM_REDIRECT = 0x6 + RTM_RESOLVE = 0xb + RTM_RTTUNIT = 0xf4240 + RTM_VERSION = 0x5 + RTV_EXPIRE = 0x4 + RTV_HOPCOUNT = 0x2 + RTV_MTU = 0x1 + RTV_RPIPE = 0x8 + RTV_RTT = 0x40 + RTV_RTTVAR = 0x80 + RTV_SPIPE = 0x10 + RTV_SSTHRESH = 0x20 + RTV_WEIGHT = 0x100 + RT_ALL_FIBS = -0x1 + RT_CACHING_CONTEXT = 0x1 + RT_DEFAULT_FIB = 0x0 + RT_NORTREF = 0x2 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + RUSAGE_THREAD = 0x1 + SCM_BINTIME = 0x4 + SCM_CREDS = 0x3 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x2 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDMULTI = 0x80206931 + SIOCADDRT = 0x8030720a + SIOCAIFADDR = 0x8040691a + SIOCAIFGROUP = 0x80246987 + SIOCALIFADDR = 0x8118691b + SIOCATMARK = 0x40047307 + SIOCDELMULTI = 0x80206932 + SIOCDELRT = 0x8030720b + SIOCDIFADDR = 0x80206919 + SIOCDIFGROUP = 0x80246989 + SIOCDIFPHYADDR = 0x80206949 + SIOCDLIFADDR = 0x8118691d + SIOCGDRVSPEC = 0xc01c697b + SIOCGETSGCNT = 0xc0147210 + SIOCGETVIFCNT = 0xc014720f + SIOCGHIWAT = 0x40047301 + SIOCGIFADDR = 0xc0206921 + SIOCGIFBRDADDR = 0xc0206923 + SIOCGIFCAP = 0xc020691f + SIOCGIFCONF = 0xc0086924 + SIOCGIFDESCR = 0xc020692a + SIOCGIFDSTADDR = 0xc0206922 + SIOCGIFFIB = 0xc020695c + SIOCGIFFLAGS = 0xc0206911 + SIOCGIFGENERIC = 0xc020693a + SIOCGIFGMEMB = 0xc024698a + SIOCGIFGROUP = 0xc0246988 + SIOCGIFINDEX = 0xc0206920 + SIOCGIFMAC = 0xc0206926 + SIOCGIFMEDIA = 0xc0286938 + SIOCGIFMETRIC = 0xc0206917 + SIOCGIFMTU = 0xc0206933 + SIOCGIFNETMASK = 0xc0206925 + SIOCGIFPDSTADDR = 0xc0206948 + SIOCGIFPHYS = 0xc0206935 + SIOCGIFPSRCADDR = 0xc0206947 + SIOCGIFSTATUS = 0xc331693b + SIOCGLIFADDR = 0xc118691c + SIOCGLIFPHYADDR = 0xc118694b + SIOCGLOWAT = 0x40047303 + SIOCGPGRP = 0x40047309 + SIOCGPRIVATE_0 = 0xc0206950 + SIOCGPRIVATE_1 = 0xc0206951 + SIOCIFCREATE = 0xc020697a + SIOCIFCREATE2 = 0xc020697c + SIOCIFDESTROY = 0x80206979 + SIOCIFGCLONERS = 0xc00c6978 + SIOCSDRVSPEC = 0x801c697b + SIOCSHIWAT = 0x80047300 + SIOCSIFADDR = 0x8020690c + SIOCSIFBRDADDR = 0x80206913 + SIOCSIFCAP = 0x8020691e + SIOCSIFDESCR = 0x80206929 + SIOCSIFDSTADDR = 0x8020690e + SIOCSIFFIB = 0x8020695d + SIOCSIFFLAGS = 0x80206910 + SIOCSIFGENERIC = 0x80206939 + SIOCSIFLLADDR = 0x8020693c + SIOCSIFMAC = 0x80206927 + SIOCSIFMEDIA = 0xc0206937 + SIOCSIFMETRIC = 0x80206918 + SIOCSIFMTU = 0x80206934 + SIOCSIFNAME = 0x80206928 + SIOCSIFNETMASK = 0x80206916 + SIOCSIFPHYADDR = 0x80406946 + SIOCSIFPHYS = 0x80206936 + SIOCSIFRVNET = 0xc020695b + SIOCSIFVNET = 0xc020695a + SIOCSLIFPHYADDR = 0x8118694a + SIOCSLOWAT = 0x80047302 + SIOCSPGRP = 0x80047308 + SOCK_CLOEXEC = 0x10000000 + SOCK_DGRAM = 0x2 + SOCK_MAXADDRLEN = 0xff + SOCK_NONBLOCK = 0x20000000 + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_SOCKET = 0xffff + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x2 + SO_ACCEPTFILTER = 0x1000 + SO_BINTIME = 0x2000 + SO_BROADCAST = 0x20 + SO_DEBUG = 0x1 + SO_DONTROUTE = 0x10 + SO_ERROR = 0x1007 + SO_KEEPALIVE = 0x8 + SO_LABEL = 0x1009 + SO_LINGER = 0x80 + SO_LISTENINCQLEN = 0x1013 + SO_LISTENQLEN = 0x1012 + SO_LISTENQLIMIT = 0x1011 + SO_NOSIGPIPE = 0x800 + SO_NO_DDP = 0x8000 + SO_NO_OFFLOAD = 0x4000 + SO_OOBINLINE = 0x100 + SO_PEERLABEL = 0x1010 + SO_PROTOCOL = 0x1016 + SO_PROTOTYPE = 0x1016 + SO_RCVBUF = 0x1002 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x1006 + SO_REUSEADDR = 0x4 + SO_REUSEPORT = 0x200 + SO_SETFIB = 0x1014 + SO_SNDBUF = 0x1001 + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x1005 + SO_TIMESTAMP = 0x400 + SO_TYPE = 0x1008 + SO_USELOOPBACK = 0x40 + SO_USER_COOKIE = 0x1015 + SO_VENDOR = 0x80000000 + TCIFLUSH = 0x1 + TCIOFLUSH = 0x3 + TCOFLUSH = 0x2 + TCP_CA_NAME_MAX = 0x10 + TCP_CONGESTION = 0x40 + TCP_INFO = 0x20 + TCP_KEEPCNT = 0x400 + TCP_KEEPIDLE = 0x100 + TCP_KEEPINIT = 0x80 + TCP_KEEPINTVL = 0x200 + TCP_MAXBURST = 0x4 + TCP_MAXHLEN = 0x3c + TCP_MAXOLEN = 0x28 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_SACK = 0x4 + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0x10 + TCP_MINMSS = 0xd8 + TCP_MSS = 0x218 + TCP_NODELAY = 0x1 + TCP_NOOPT = 0x8 + TCP_NOPUSH = 0x4 + TCP_VENDOR = 0x80000000 + TCSAFLUSH = 0x2 + TIOCCBRK = 0x2000747a + TIOCCDTR = 0x20007478 + TIOCCONS = 0x80047462 + TIOCDRAIN = 0x2000745e + TIOCEXCL = 0x2000740d + TIOCEXT = 0x80047460 + TIOCFLUSH = 0x80047410 + TIOCGDRAINWAIT = 0x40047456 + TIOCGETA = 0x402c7413 + TIOCGETD = 0x4004741a + TIOCGPGRP = 0x40047477 + TIOCGPTN = 0x4004740f + TIOCGSID = 0x40047463 + TIOCGWINSZ = 0x40087468 + TIOCMBIC = 0x8004746b + TIOCMBIS = 0x8004746c + TIOCMGDTRWAIT = 0x4004745a + TIOCMGET = 0x4004746a + TIOCMSDTRWAIT = 0x8004745b + TIOCMSET = 0x8004746d + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DCD = 0x40 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x20007471 + TIOCNXCL = 0x2000740e + TIOCOUTQ = 0x40047473 + TIOCPKT = 0x80047470 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCPTMASTER = 0x2000741c + TIOCSBRK = 0x2000747b + TIOCSCTTY = 0x20007461 + TIOCSDRAINWAIT = 0x80047457 + TIOCSDTR = 0x20007479 + TIOCSETA = 0x802c7414 + TIOCSETAF = 0x802c7416 + TIOCSETAW = 0x802c7415 + TIOCSETD = 0x8004741b + TIOCSIG = 0x2004745f + TIOCSPGRP = 0x80047476 + TIOCSTART = 0x2000746e + TIOCSTAT = 0x20007465 + TIOCSTI = 0x80017472 + TIOCSTOP = 0x2000746f + TIOCSWINSZ = 0x80087467 + TIOCTIMESTAMP = 0x40087459 + TIOCUCNTL = 0x80047466 + TOSTOP = 0x400000 + VDISCARD = 0xf + VDSUSP = 0xb + VEOF = 0x0 + VEOL = 0x1 + VEOL2 = 0x2 + VERASE = 0x3 + VERASE2 = 0x7 + VINTR = 0x8 + VKILL = 0x5 + VLNEXT = 0xe + VMIN = 0x10 + VQUIT = 0x9 + VREPRINT = 0x6 + VSTART = 0xc + VSTATUS = 0x12 + VSTOP = 0xd + VSUSP = 0xa + VTIME = 0x11 + VWERASE = 0x4 + WCONTINUED = 0x4 + WCOREFLAG = 0x80 + WEXITED = 0x10 + WLINUXCLONE = 0x80000000 + WNOHANG = 0x1 + WNOWAIT = 0x8 + WSTOPPED = 0x2 + WTRAPPED = 0x20 + WUNTRACED = 0x2 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x30) + EADDRNOTAVAIL = syscall.Errno(0x31) + EAFNOSUPPORT = syscall.Errno(0x2f) + EAGAIN = syscall.Errno(0x23) + EALREADY = syscall.Errno(0x25) + EAUTH = syscall.Errno(0x50) + EBADF = syscall.Errno(0x9) + EBADMSG = syscall.Errno(0x59) + EBADRPC = syscall.Errno(0x48) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x55) + ECAPMODE = syscall.Errno(0x5e) + ECHILD = syscall.Errno(0xa) + ECONNABORTED = syscall.Errno(0x35) + ECONNREFUSED = syscall.Errno(0x3d) + ECONNRESET = syscall.Errno(0x36) + EDEADLK = syscall.Errno(0xb) + EDESTADDRREQ = syscall.Errno(0x27) + EDOM = syscall.Errno(0x21) + EDOOFUS = syscall.Errno(0x58) + EDQUOT = syscall.Errno(0x45) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EFTYPE = syscall.Errno(0x4f) + EHOSTDOWN = syscall.Errno(0x40) + EHOSTUNREACH = syscall.Errno(0x41) + EIDRM = syscall.Errno(0x52) + EILSEQ = syscall.Errno(0x56) + EINPROGRESS = syscall.Errno(0x24) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x38) + EISDIR = syscall.Errno(0x15) + ELAST = syscall.Errno(0x60) + ELOOP = syscall.Errno(0x3e) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x28) + EMULTIHOP = syscall.Errno(0x5a) + ENAMETOOLONG = syscall.Errno(0x3f) + ENEEDAUTH = syscall.Errno(0x51) + ENETDOWN = syscall.Errno(0x32) + ENETRESET = syscall.Errno(0x34) + ENETUNREACH = syscall.Errno(0x33) + ENFILE = syscall.Errno(0x17) + ENOATTR = syscall.Errno(0x57) + ENOBUFS = syscall.Errno(0x37) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOLCK = syscall.Errno(0x4d) + ENOLINK = syscall.Errno(0x5b) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x53) + ENOPROTOOPT = syscall.Errno(0x2a) + ENOSPC = syscall.Errno(0x1c) + ENOSYS = syscall.Errno(0x4e) + ENOTBLK = syscall.Errno(0xf) + ENOTCAPABLE = syscall.Errno(0x5d) + ENOTCONN = syscall.Errno(0x39) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x42) + ENOTRECOVERABLE = syscall.Errno(0x5f) + ENOTSOCK = syscall.Errno(0x26) + ENOTSUP = syscall.Errno(0x2d) + ENOTTY = syscall.Errno(0x19) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x2d) + EOVERFLOW = syscall.Errno(0x54) + EOWNERDEAD = syscall.Errno(0x60) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x2e) + EPIPE = syscall.Errno(0x20) + EPROCLIM = syscall.Errno(0x43) + EPROCUNAVAIL = syscall.Errno(0x4c) + EPROGMISMATCH = syscall.Errno(0x4b) + EPROGUNAVAIL = syscall.Errno(0x4a) + EPROTO = syscall.Errno(0x5c) + EPROTONOSUPPORT = syscall.Errno(0x2b) + EPROTOTYPE = syscall.Errno(0x29) + ERANGE = syscall.Errno(0x22) + EREMOTE = syscall.Errno(0x47) + EROFS = syscall.Errno(0x1e) + ERPCMISMATCH = syscall.Errno(0x49) + ESHUTDOWN = syscall.Errno(0x3a) + ESOCKTNOSUPPORT = syscall.Errno(0x2c) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESTALE = syscall.Errno(0x46) + ETIMEDOUT = syscall.Errno(0x3c) + ETOOMANYREFS = syscall.Errno(0x3b) + ETXTBSY = syscall.Errno(0x1a) + EUSERS = syscall.Errno(0x44) + EWOULDBLOCK = syscall.Errno(0x23) + EXDEV = syscall.Errno(0x12) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0xa) + SIGCHLD = syscall.Signal(0x14) + SIGCONT = syscall.Signal(0x13) + SIGEMT = syscall.Signal(0x7) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINFO = syscall.Signal(0x1d) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x17) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGLIBRT = syscall.Signal(0x21) + SIGLWP = syscall.Signal(0x20) + SIGPIPE = syscall.Signal(0xd) + SIGPROF = syscall.Signal(0x1b) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTOP = syscall.Signal(0x11) + SIGSYS = syscall.Signal(0xc) + SIGTERM = syscall.Signal(0xf) + SIGTHR = syscall.Signal(0x20) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x12) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGURG = syscall.Signal(0x10) + SIGUSR1 = syscall.Signal(0x1e) + SIGUSR2 = syscall.Signal(0x1f) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "device not configured", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource deadlock avoided", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device busy", + 17: "file exists", + 18: "cross-device link", + 19: "operation not supported by device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "result too large", + 35: "resource temporarily unavailable", + 36: "operation now in progress", + 37: "operation already in progress", + 38: "socket operation on non-socket", + 39: "destination address required", + 40: "message too long", + 41: "protocol wrong type for socket", + 42: "protocol not available", + 43: "protocol not supported", + 44: "socket type not supported", + 45: "operation not supported", + 46: "protocol family not supported", + 47: "address family not supported by protocol family", + 48: "address already in use", + 49: "can't assign requested address", + 50: "network is down", + 51: "network is unreachable", + 52: "network dropped connection on reset", + 53: "software caused connection abort", + 54: "connection reset by peer", + 55: "no buffer space available", + 56: "socket is already connected", + 57: "socket is not connected", + 58: "can't send after socket shutdown", + 59: "too many references: can't splice", + 60: "operation timed out", + 61: "connection refused", + 62: "too many levels of symbolic links", + 63: "file name too long", + 64: "host is down", + 65: "no route to host", + 66: "directory not empty", + 67: "too many processes", + 68: "too many users", + 69: "disc quota exceeded", + 70: "stale NFS file handle", + 71: "too many levels of remote in path", + 72: "RPC struct is bad", + 73: "RPC version wrong", + 74: "RPC prog. not avail", + 75: "program version wrong", + 76: "bad procedure for program", + 77: "no locks available", + 78: "function not implemented", + 79: "inappropriate file type or format", + 80: "authentication error", + 81: "need authenticator", + 82: "identifier removed", + 83: "no message of desired type", + 84: "value too large to be stored in data type", + 85: "operation canceled", + 86: "illegal byte sequence", + 87: "attribute not found", + 88: "programming error", + 89: "bad message", + 90: "multihop attempted", + 91: "link has been severed", + 92: "protocol error", + 93: "capabilities insufficient", + 94: "not permitted in capability mode", + 95: "state not recoverable", + 96: "previous owner died", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/BPT trap", + 6: "abort trap", + 7: "EMT trap", + 8: "floating point exception", + 9: "killed", + 10: "bus error", + 11: "segmentation fault", + 12: "bad system call", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "urgent I/O condition", + 17: "suspended (signal)", + 18: "suspended", + 19: "continued", + 20: "child exited", + 21: "stopped (tty input)", + 22: "stopped (tty output)", + 23: "I/O possible", + 24: "cputime limit exceeded", + 25: "filesize limit exceeded", + 26: "virtual timer expired", + 27: "profiling timer expired", + 28: "window size changes", + 29: "information request", + 30: "user defined signal 1", + 31: "user defined signal 2", + 32: "unknown signal", + 33: "unknown signal", +} diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go new file mode 100644 index 0000000000..8f920124b8 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -0,0 +1,1819 @@ +// mkerrors.sh -m32 +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build 386,linux + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -m32 _const.go + +package unix + +import "syscall" + +const ( + AF_ALG = 0x26 + AF_APPLETALK = 0x5 + AF_ASH = 0x12 + AF_ATMPVC = 0x8 + AF_ATMSVC = 0x14 + AF_AX25 = 0x3 + AF_BLUETOOTH = 0x1f + AF_BRIDGE = 0x7 + AF_CAIF = 0x25 + AF_CAN = 0x1d + AF_DECnet = 0xc + AF_ECONET = 0x13 + AF_FILE = 0x1 + AF_IEEE802154 = 0x24 + AF_INET = 0x2 + AF_INET6 = 0xa + AF_IPX = 0x4 + AF_IRDA = 0x17 + AF_ISDN = 0x22 + AF_IUCV = 0x20 + AF_KEY = 0xf + AF_LLC = 0x1a + AF_LOCAL = 0x1 + AF_MAX = 0x28 + AF_NETBEUI = 0xd + AF_NETLINK = 0x10 + AF_NETROM = 0x6 + AF_NFC = 0x27 + AF_PACKET = 0x11 + AF_PHONET = 0x23 + AF_PPPOX = 0x18 + AF_RDS = 0x15 + AF_ROSE = 0xb + AF_ROUTE = 0x10 + AF_RXRPC = 0x21 + AF_SECURITY = 0xe + AF_SNA = 0x16 + AF_TIPC = 0x1e + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_WANPIPE = 0x19 + AF_X25 = 0x9 + ARPHRD_ADAPT = 0x108 + ARPHRD_APPLETLK = 0x8 + ARPHRD_ARCNET = 0x7 + ARPHRD_ASH = 0x30d + ARPHRD_ATM = 0x13 + ARPHRD_AX25 = 0x3 + ARPHRD_BIF = 0x307 + ARPHRD_CAIF = 0x336 + ARPHRD_CAN = 0x118 + ARPHRD_CHAOS = 0x5 + ARPHRD_CISCO = 0x201 + ARPHRD_CSLIP = 0x101 + ARPHRD_CSLIP6 = 0x103 + ARPHRD_DDCMP = 0x205 + ARPHRD_DLCI = 0xf + ARPHRD_ECONET = 0x30e + ARPHRD_EETHER = 0x2 + ARPHRD_ETHER = 0x1 + ARPHRD_EUI64 = 0x1b + ARPHRD_FCAL = 0x311 + ARPHRD_FCFABRIC = 0x313 + ARPHRD_FCPL = 0x312 + ARPHRD_FCPP = 0x310 + ARPHRD_FDDI = 0x306 + ARPHRD_FRAD = 0x302 + ARPHRD_HDLC = 0x201 + ARPHRD_HIPPI = 0x30c + ARPHRD_HWX25 = 0x110 + ARPHRD_IEEE1394 = 0x18 + ARPHRD_IEEE802 = 0x6 + ARPHRD_IEEE80211 = 0x321 + ARPHRD_IEEE80211_PRISM = 0x322 + ARPHRD_IEEE80211_RADIOTAP = 0x323 + ARPHRD_IEEE802154 = 0x324 + ARPHRD_IEEE802_TR = 0x320 + ARPHRD_INFINIBAND = 0x20 + ARPHRD_IPDDP = 0x309 + ARPHRD_IPGRE = 0x30a + ARPHRD_IRDA = 0x30f + ARPHRD_LAPB = 0x204 + ARPHRD_LOCALTLK = 0x305 + ARPHRD_LOOPBACK = 0x304 + ARPHRD_METRICOM = 0x17 + ARPHRD_NETROM = 0x0 + ARPHRD_NONE = 0xfffe + ARPHRD_PHONET = 0x334 + ARPHRD_PHONET_PIPE = 0x335 + ARPHRD_PIMREG = 0x30b + ARPHRD_PPP = 0x200 + ARPHRD_PRONET = 0x4 + ARPHRD_RAWHDLC = 0x206 + ARPHRD_ROSE = 0x10e + ARPHRD_RSRVD = 0x104 + ARPHRD_SIT = 0x308 + ARPHRD_SKIP = 0x303 + ARPHRD_SLIP = 0x100 + ARPHRD_SLIP6 = 0x102 + ARPHRD_TUNNEL = 0x300 + ARPHRD_TUNNEL6 = 0x301 + ARPHRD_VOID = 0xffff + ARPHRD_X25 = 0x10f + B0 = 0x0 + B1000000 = 0x1008 + B110 = 0x3 + B115200 = 0x1002 + B1152000 = 0x1009 + B1200 = 0x9 + B134 = 0x4 + B150 = 0x5 + B1500000 = 0x100a + B1800 = 0xa + B19200 = 0xe + B200 = 0x6 + B2000000 = 0x100b + B230400 = 0x1003 + B2400 = 0xb + B2500000 = 0x100c + B300 = 0x7 + B3000000 = 0x100d + B3500000 = 0x100e + B38400 = 0xf + B4000000 = 0x100f + B460800 = 0x1004 + B4800 = 0xc + B50 = 0x1 + B500000 = 0x1005 + B57600 = 0x1001 + B576000 = 0x1006 + B600 = 0x8 + B75 = 0x2 + B921600 = 0x1007 + B9600 = 0xd + BOTHER = 0x1000 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXINSNS = 0x1000 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BRKINT = 0x2 + BS0 = 0x0 + BS1 = 0x2000 + BSDLY = 0x2000 + CBAUD = 0x100f + CBAUDEX = 0x1000 + CFLUSH = 0xf + CIBAUD = 0x100f0000 + CLOCAL = 0x800 + CLOCK_BOOTTIME = 0x7 + CLOCK_BOOTTIME_ALARM = 0x9 + CLOCK_DEFAULT = 0x0 + CLOCK_EXT = 0x1 + CLOCK_INT = 0x2 + CLOCK_MONOTONIC = 0x1 + CLOCK_MONOTONIC_COARSE = 0x6 + CLOCK_MONOTONIC_RAW = 0x4 + CLOCK_PROCESS_CPUTIME_ID = 0x2 + CLOCK_REALTIME = 0x0 + CLOCK_REALTIME_ALARM = 0x8 + CLOCK_REALTIME_COARSE = 0x5 + CLOCK_THREAD_CPUTIME_ID = 0x3 + CLOCK_TXFROMRX = 0x4 + CLOCK_TXINT = 0x3 + CLONE_CHILD_CLEARTID = 0x200000 + CLONE_CHILD_SETTID = 0x1000000 + CLONE_DETACHED = 0x400000 + CLONE_FILES = 0x400 + CLONE_FS = 0x200 + CLONE_IO = 0x80000000 + CLONE_NEWCGROUP = 0x2000000 + CLONE_NEWIPC = 0x8000000 + CLONE_NEWNET = 0x40000000 + CLONE_NEWNS = 0x20000 + CLONE_NEWPID = 0x20000000 + CLONE_NEWUSER = 0x10000000 + CLONE_NEWUTS = 0x4000000 + CLONE_PARENT = 0x8000 + CLONE_PARENT_SETTID = 0x100000 + CLONE_PTRACE = 0x2000 + CLONE_SETTLS = 0x80000 + CLONE_SIGHAND = 0x800 + CLONE_SYSVSEM = 0x40000 + CLONE_THREAD = 0x10000 + CLONE_UNTRACED = 0x800000 + CLONE_VFORK = 0x4000 + CLONE_VM = 0x100 + CMSPAR = 0x40000000 + CR0 = 0x0 + CR1 = 0x200 + CR2 = 0x400 + CR3 = 0x600 + CRDLY = 0x600 + CREAD = 0x80 + CRTSCTS = 0x80000000 + CS5 = 0x0 + CS6 = 0x10 + CS7 = 0x20 + CS8 = 0x30 + CSIGNAL = 0xff + CSIZE = 0x30 + CSTART = 0x11 + CSTATUS = 0x0 + CSTOP = 0x13 + CSTOPB = 0x40 + CSUSP = 0x1a + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x200 + ECHOE = 0x10 + ECHOK = 0x20 + ECHOKE = 0x800 + ECHONL = 0x40 + ECHOPRT = 0x400 + ENCODING_DEFAULT = 0x0 + ENCODING_FM_MARK = 0x3 + ENCODING_FM_SPACE = 0x4 + ENCODING_MANCHESTER = 0x5 + ENCODING_NRZ = 0x1 + ENCODING_NRZI = 0x2 + EPOLLERR = 0x8 + EPOLLET = 0x80000000 + EPOLLHUP = 0x10 + EPOLLIN = 0x1 + EPOLLMSG = 0x400 + EPOLLONESHOT = 0x40000000 + EPOLLOUT = 0x4 + EPOLLPRI = 0x2 + EPOLLRDBAND = 0x80 + EPOLLRDHUP = 0x2000 + EPOLLRDNORM = 0x40 + EPOLLWRBAND = 0x200 + EPOLLWRNORM = 0x100 + EPOLL_CLOEXEC = 0x80000 + EPOLL_CTL_ADD = 0x1 + EPOLL_CTL_DEL = 0x2 + EPOLL_CTL_MOD = 0x3 + EPOLL_NONBLOCK = 0x800 + ETH_P_1588 = 0x88f7 + ETH_P_8021AD = 0x88a8 + ETH_P_8021AH = 0x88e7 + ETH_P_8021Q = 0x8100 + ETH_P_802_2 = 0x4 + ETH_P_802_3 = 0x1 + ETH_P_AARP = 0x80f3 + ETH_P_AF_IUCV = 0xfbfb + ETH_P_ALL = 0x3 + ETH_P_AOE = 0x88a2 + ETH_P_ARCNET = 0x1a + ETH_P_ARP = 0x806 + ETH_P_ATALK = 0x809b + ETH_P_ATMFATE = 0x8884 + ETH_P_ATMMPOA = 0x884c + ETH_P_AX25 = 0x2 + ETH_P_BPQ = 0x8ff + ETH_P_CAIF = 0xf7 + ETH_P_CAN = 0xc + ETH_P_CONTROL = 0x16 + ETH_P_CUST = 0x6006 + ETH_P_DDCMP = 0x6 + ETH_P_DEC = 0x6000 + ETH_P_DIAG = 0x6005 + ETH_P_DNA_DL = 0x6001 + ETH_P_DNA_RC = 0x6002 + ETH_P_DNA_RT = 0x6003 + ETH_P_DSA = 0x1b + ETH_P_ECONET = 0x18 + ETH_P_EDSA = 0xdada + ETH_P_FCOE = 0x8906 + ETH_P_FIP = 0x8914 + ETH_P_HDLC = 0x19 + ETH_P_IEEE802154 = 0xf6 + ETH_P_IEEEPUP = 0xa00 + ETH_P_IEEEPUPAT = 0xa01 + ETH_P_IP = 0x800 + ETH_P_IPV6 = 0x86dd + ETH_P_IPX = 0x8137 + ETH_P_IRDA = 0x17 + ETH_P_LAT = 0x6004 + ETH_P_LINK_CTL = 0x886c + ETH_P_LOCALTALK = 0x9 + ETH_P_LOOP = 0x60 + ETH_P_MOBITEX = 0x15 + ETH_P_MPLS_MC = 0x8848 + ETH_P_MPLS_UC = 0x8847 + ETH_P_PAE = 0x888e + ETH_P_PAUSE = 0x8808 + ETH_P_PHONET = 0xf5 + ETH_P_PPPTALK = 0x10 + ETH_P_PPP_DISC = 0x8863 + ETH_P_PPP_MP = 0x8 + ETH_P_PPP_SES = 0x8864 + ETH_P_PUP = 0x200 + ETH_P_PUPAT = 0x201 + ETH_P_QINQ1 = 0x9100 + ETH_P_QINQ2 = 0x9200 + ETH_P_QINQ3 = 0x9300 + ETH_P_RARP = 0x8035 + ETH_P_SCA = 0x6007 + ETH_P_SLOW = 0x8809 + ETH_P_SNAP = 0x5 + ETH_P_TDLS = 0x890d + ETH_P_TEB = 0x6558 + ETH_P_TIPC = 0x88ca + ETH_P_TRAILER = 0x1c + ETH_P_TR_802_2 = 0x11 + ETH_P_WAN_PPP = 0x7 + ETH_P_WCCP = 0x883e + ETH_P_X25 = 0x805 + EXTA = 0xe + EXTB = 0xf + EXTPROC = 0x10000 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FF0 = 0x0 + FF1 = 0x8000 + FFDLY = 0x8000 + FLUSHO = 0x1000 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x406 + F_EXLCK = 0x4 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLEASE = 0x401 + F_GETLK = 0xc + F_GETLK64 = 0xc + F_GETOWN = 0x9 + F_GETOWN_EX = 0x10 + F_GETPIPE_SZ = 0x408 + F_GETSIG = 0xb + F_LOCK = 0x1 + F_NOTIFY = 0x402 + F_OK = 0x0 + F_RDLCK = 0x0 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLEASE = 0x400 + F_SETLK = 0xd + F_SETLK64 = 0xd + F_SETLKW = 0xe + F_SETLKW64 = 0xe + F_SETOWN = 0x8 + F_SETOWN_EX = 0xf + F_SETPIPE_SZ = 0x407 + F_SETSIG = 0xa + F_SHLCK = 0x8 + F_TEST = 0x3 + F_TLOCK = 0x2 + F_ULOCK = 0x0 + F_UNLCK = 0x2 + F_WRLCK = 0x1 + HUPCL = 0x400 + IBSHIFT = 0x10 + ICANON = 0x2 + ICMPV6_FILTER = 0x1 + ICRNL = 0x100 + IEXTEN = 0x8000 + IFA_F_DADFAILED = 0x8 + IFA_F_DEPRECATED = 0x20 + IFA_F_HOMEADDRESS = 0x10 + IFA_F_NODAD = 0x2 + IFA_F_OPTIMISTIC = 0x4 + IFA_F_PERMANENT = 0x80 + IFA_F_SECONDARY = 0x1 + IFA_F_TEMPORARY = 0x1 + IFA_F_TENTATIVE = 0x40 + IFA_MAX = 0x7 + IFF_802_1Q_VLAN = 0x1 + IFF_ALLMULTI = 0x200 + IFF_AUTOMEDIA = 0x4000 + IFF_BONDING = 0x20 + IFF_BRIDGE_PORT = 0x4000 + IFF_BROADCAST = 0x2 + IFF_DEBUG = 0x4 + IFF_DISABLE_NETPOLL = 0x1000 + IFF_DONT_BRIDGE = 0x800 + IFF_DORMANT = 0x20000 + IFF_DYNAMIC = 0x8000 + IFF_EBRIDGE = 0x2 + IFF_ECHO = 0x40000 + IFF_ISATAP = 0x80 + IFF_LOOPBACK = 0x8 + IFF_LOWER_UP = 0x10000 + IFF_MACVLAN_PORT = 0x2000 + IFF_MASTER = 0x400 + IFF_MASTER_8023AD = 0x8 + IFF_MASTER_ALB = 0x10 + IFF_MASTER_ARPMON = 0x100 + IFF_MULTICAST = 0x1000 + IFF_NOARP = 0x80 + IFF_NOTRAILERS = 0x20 + IFF_NO_PI = 0x1000 + IFF_ONE_QUEUE = 0x2000 + IFF_OVS_DATAPATH = 0x8000 + IFF_POINTOPOINT = 0x10 + IFF_PORTSEL = 0x2000 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SLAVE = 0x800 + IFF_SLAVE_INACTIVE = 0x4 + IFF_SLAVE_NEEDARP = 0x40 + IFF_TAP = 0x2 + IFF_TUN = 0x1 + IFF_TUN_EXCL = 0x8000 + IFF_TX_SKB_SHARING = 0x10000 + IFF_UNICAST_FLT = 0x20000 + IFF_UP = 0x1 + IFF_VNET_HDR = 0x4000 + IFF_VOLATILE = 0x70c5a + IFF_WAN_HDLC = 0x200 + IFF_XMIT_DST_RELEASE = 0x400 + IFNAMSIZ = 0x10 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_ACCESS = 0x1 + IN_ALL_EVENTS = 0xfff + IN_ATTRIB = 0x4 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLOEXEC = 0x80000 + IN_CLOSE = 0x18 + IN_CLOSE_NOWRITE = 0x10 + IN_CLOSE_WRITE = 0x8 + IN_CREATE = 0x100 + IN_DELETE = 0x200 + IN_DELETE_SELF = 0x400 + IN_DONT_FOLLOW = 0x2000000 + IN_EXCL_UNLINK = 0x4000000 + IN_IGNORED = 0x8000 + IN_ISDIR = 0x40000000 + IN_LOOPBACKNET = 0x7f + IN_MASK_ADD = 0x20000000 + IN_MODIFY = 0x2 + IN_MOVE = 0xc0 + IN_MOVED_FROM = 0x40 + IN_MOVED_TO = 0x80 + IN_MOVE_SELF = 0x800 + IN_NONBLOCK = 0x800 + IN_ONESHOT = 0x80000000 + IN_ONLYDIR = 0x1000000 + IN_OPEN = 0x20 + IN_Q_OVERFLOW = 0x4000 + IN_UNMOUNT = 0x2000 + IPPROTO_AH = 0x33 + IPPROTO_COMP = 0x6c + IPPROTO_DCCP = 0x21 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_ENCAP = 0x62 + IPPROTO_ESP = 0x32 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GRE = 0x2f + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IGMP = 0x2 + IPPROTO_IP = 0x0 + IPPROTO_IPIP = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_MTP = 0x5c + IPPROTO_NONE = 0x3b + IPPROTO_PIM = 0x67 + IPPROTO_PUP = 0xc + IPPROTO_RAW = 0xff + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_SCTP = 0x84 + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_UDP = 0x11 + IPPROTO_UDPLITE = 0x88 + IPV6_2292DSTOPTS = 0x4 + IPV6_2292HOPLIMIT = 0x8 + IPV6_2292HOPOPTS = 0x3 + IPV6_2292PKTINFO = 0x2 + IPV6_2292PKTOPTIONS = 0x6 + IPV6_2292RTHDR = 0x5 + IPV6_ADDRFORM = 0x1 + IPV6_ADD_MEMBERSHIP = 0x14 + IPV6_AUTHHDR = 0xa + IPV6_CHECKSUM = 0x7 + IPV6_DROP_MEMBERSHIP = 0x15 + IPV6_DSTOPTS = 0x3b + IPV6_HOPLIMIT = 0x34 + IPV6_HOPOPTS = 0x36 + IPV6_IPSEC_POLICY = 0x22 + IPV6_JOIN_ANYCAST = 0x1b + IPV6_JOIN_GROUP = 0x14 + IPV6_LEAVE_ANYCAST = 0x1c + IPV6_LEAVE_GROUP = 0x15 + IPV6_MTU = 0x18 + IPV6_MTU_DISCOVER = 0x17 + IPV6_MULTICAST_HOPS = 0x12 + IPV6_MULTICAST_IF = 0x11 + IPV6_MULTICAST_LOOP = 0x13 + IPV6_NEXTHOP = 0x9 + IPV6_PKTINFO = 0x32 + IPV6_PMTUDISC_DO = 0x2 + IPV6_PMTUDISC_DONT = 0x0 + IPV6_PMTUDISC_PROBE = 0x3 + IPV6_PMTUDISC_WANT = 0x1 + IPV6_RECVDSTOPTS = 0x3a + IPV6_RECVERR = 0x19 + IPV6_RECVHOPLIMIT = 0x33 + IPV6_RECVHOPOPTS = 0x35 + IPV6_RECVPKTINFO = 0x31 + IPV6_RECVRTHDR = 0x38 + IPV6_RECVTCLASS = 0x42 + IPV6_ROUTER_ALERT = 0x16 + IPV6_RTHDR = 0x39 + IPV6_RTHDRDSTOPTS = 0x37 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_RXDSTOPTS = 0x3b + IPV6_RXHOPOPTS = 0x36 + IPV6_TCLASS = 0x43 + IPV6_UNICAST_HOPS = 0x10 + IPV6_V6ONLY = 0x1a + IPV6_XFRM_POLICY = 0x23 + IP_ADD_MEMBERSHIP = 0x23 + IP_ADD_SOURCE_MEMBERSHIP = 0x27 + IP_BLOCK_SOURCE = 0x26 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DROP_MEMBERSHIP = 0x24 + IP_DROP_SOURCE_MEMBERSHIP = 0x28 + IP_FREEBIND = 0xf + IP_HDRINCL = 0x3 + IP_IPSEC_POLICY = 0x10 + IP_MAXPACKET = 0xffff + IP_MAX_MEMBERSHIPS = 0x14 + IP_MF = 0x2000 + IP_MINTTL = 0x15 + IP_MSFILTER = 0x29 + IP_MSS = 0x240 + IP_MTU = 0xe + IP_MTU_DISCOVER = 0xa + IP_MULTICAST_ALL = 0x31 + IP_MULTICAST_IF = 0x20 + IP_MULTICAST_LOOP = 0x22 + IP_MULTICAST_TTL = 0x21 + IP_OFFMASK = 0x1fff + IP_OPTIONS = 0x4 + IP_ORIGDSTADDR = 0x14 + IP_PASSSEC = 0x12 + IP_PKTINFO = 0x8 + IP_PKTOPTIONS = 0x9 + IP_PMTUDISC = 0xa + IP_PMTUDISC_DO = 0x2 + IP_PMTUDISC_DONT = 0x0 + IP_PMTUDISC_PROBE = 0x3 + IP_PMTUDISC_WANT = 0x1 + IP_RECVERR = 0xb + IP_RECVOPTS = 0x6 + IP_RECVORIGDSTADDR = 0x14 + IP_RECVRETOPTS = 0x7 + IP_RECVTOS = 0xd + IP_RECVTTL = 0xc + IP_RETOPTS = 0x7 + IP_RF = 0x8000 + IP_ROUTER_ALERT = 0x5 + IP_TOS = 0x1 + IP_TRANSPARENT = 0x13 + IP_TTL = 0x2 + IP_UNBLOCK_SOURCE = 0x25 + IP_XFRM_POLICY = 0x11 + ISIG = 0x1 + ISTRIP = 0x20 + IUCLC = 0x200 + IUTF8 = 0x4000 + IXANY = 0x800 + IXOFF = 0x1000 + IXON = 0x400 + LINUX_REBOOT_CMD_CAD_OFF = 0x0 + LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef + LINUX_REBOOT_CMD_HALT = 0xcdef0123 + LINUX_REBOOT_CMD_KEXEC = 0x45584543 + LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc + LINUX_REBOOT_CMD_RESTART = 0x1234567 + LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4 + LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2 + LINUX_REBOOT_MAGIC1 = 0xfee1dead + LINUX_REBOOT_MAGIC2 = 0x28121969 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_DOFORK = 0xb + MADV_DONTFORK = 0xa + MADV_DONTNEED = 0x4 + MADV_HUGEPAGE = 0xe + MADV_HWPOISON = 0x64 + MADV_MERGEABLE = 0xc + MADV_NOHUGEPAGE = 0xf + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_REMOVE = 0x9 + MADV_SEQUENTIAL = 0x2 + MADV_UNMERGEABLE = 0xd + MADV_WILLNEED = 0x3 + MAP_32BIT = 0x40 + MAP_ANON = 0x20 + MAP_ANONYMOUS = 0x20 + MAP_DENYWRITE = 0x800 + MAP_EXECUTABLE = 0x1000 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_GROWSDOWN = 0x100 + MAP_HUGETLB = 0x40000 + MAP_LOCKED = 0x2000 + MAP_NONBLOCK = 0x10000 + MAP_NORESERVE = 0x4000 + MAP_POPULATE = 0x8000 + MAP_PRIVATE = 0x2 + MAP_SHARED = 0x1 + MAP_STACK = 0x20000 + MAP_TYPE = 0xf + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MNT_DETACH = 0x2 + MNT_EXPIRE = 0x4 + MNT_FORCE = 0x1 + MSG_CMSG_CLOEXEC = 0x40000000 + MSG_CONFIRM = 0x800 + MSG_CTRUNC = 0x8 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x40 + MSG_EOR = 0x80 + MSG_ERRQUEUE = 0x2000 + MSG_FASTOPEN = 0x20000000 + MSG_FIN = 0x200 + MSG_MORE = 0x8000 + MSG_NOSIGNAL = 0x4000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_PROXY = 0x10 + MSG_RST = 0x1000 + MSG_SYN = 0x400 + MSG_TRUNC = 0x20 + MSG_TRYHARD = 0x4 + MSG_WAITALL = 0x100 + MSG_WAITFORONE = 0x10000 + MS_ACTIVE = 0x40000000 + MS_ASYNC = 0x1 + MS_BIND = 0x1000 + MS_DIRSYNC = 0x80 + MS_INVALIDATE = 0x2 + MS_I_VERSION = 0x800000 + MS_KERNMOUNT = 0x400000 + MS_MANDLOCK = 0x40 + MS_MGC_MSK = 0xffff0000 + MS_MGC_VAL = 0xc0ed0000 + MS_MOVE = 0x2000 + MS_NOATIME = 0x400 + MS_NODEV = 0x4 + MS_NODIRATIME = 0x800 + MS_NOEXEC = 0x8 + MS_NOSUID = 0x2 + MS_NOUSER = -0x80000000 + MS_POSIXACL = 0x10000 + MS_PRIVATE = 0x40000 + MS_RDONLY = 0x1 + MS_REC = 0x4000 + MS_RELATIME = 0x200000 + MS_REMOUNT = 0x20 + MS_RMT_MASK = 0x800051 + MS_SHARED = 0x100000 + MS_SILENT = 0x8000 + MS_SLAVE = 0x80000 + MS_STRICTATIME = 0x1000000 + MS_SYNC = 0x4 + MS_SYNCHRONOUS = 0x10 + MS_UNBINDABLE = 0x20000 + NAME_MAX = 0xff + NETLINK_ADD_MEMBERSHIP = 0x1 + NETLINK_AUDIT = 0x9 + NETLINK_BROADCAST_ERROR = 0x4 + NETLINK_CONNECTOR = 0xb + NETLINK_CRYPTO = 0x15 + NETLINK_DNRTMSG = 0xe + NETLINK_DROP_MEMBERSHIP = 0x2 + NETLINK_ECRYPTFS = 0x13 + NETLINK_FIB_LOOKUP = 0xa + NETLINK_FIREWALL = 0x3 + NETLINK_GENERIC = 0x10 + NETLINK_INET_DIAG = 0x4 + NETLINK_IP6_FW = 0xd + NETLINK_ISCSI = 0x8 + NETLINK_KOBJECT_UEVENT = 0xf + NETLINK_NETFILTER = 0xc + NETLINK_NFLOG = 0x5 + NETLINK_NO_ENOBUFS = 0x5 + NETLINK_PKTINFO = 0x3 + NETLINK_RDMA = 0x14 + NETLINK_ROUTE = 0x0 + NETLINK_SCSITRANSPORT = 0x12 + NETLINK_SELINUX = 0x7 + NETLINK_UNUSED = 0x1 + NETLINK_USERSOCK = 0x2 + NETLINK_XFRM = 0x6 + NL0 = 0x0 + NL1 = 0x100 + NLA_ALIGNTO = 0x4 + NLA_F_NESTED = 0x8000 + NLA_F_NET_BYTEORDER = 0x4000 + NLA_HDRLEN = 0x4 + NLDLY = 0x100 + NLMSG_ALIGNTO = 0x4 + NLMSG_DONE = 0x3 + NLMSG_ERROR = 0x2 + NLMSG_HDRLEN = 0x10 + NLMSG_MIN_TYPE = 0x10 + NLMSG_NOOP = 0x1 + NLMSG_OVERRUN = 0x4 + NLM_F_ACK = 0x4 + NLM_F_APPEND = 0x800 + NLM_F_ATOMIC = 0x400 + NLM_F_CREATE = 0x400 + NLM_F_DUMP = 0x300 + NLM_F_DUMP_INTR = 0x10 + NLM_F_ECHO = 0x8 + NLM_F_EXCL = 0x200 + NLM_F_MATCH = 0x200 + NLM_F_MULTI = 0x2 + NLM_F_REPLACE = 0x100 + NLM_F_REQUEST = 0x1 + NLM_F_ROOT = 0x100 + NOFLSH = 0x80 + OCRNL = 0x8 + OFDEL = 0x80 + OFILL = 0x40 + OLCUC = 0x2 + ONLCR = 0x4 + ONLRET = 0x20 + ONOCR = 0x10 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_APPEND = 0x400 + O_ASYNC = 0x2000 + O_CLOEXEC = 0x80000 + O_CREAT = 0x40 + O_DIRECT = 0x4000 + O_DIRECTORY = 0x10000 + O_DSYNC = 0x1000 + O_EXCL = 0x80 + O_FSYNC = 0x101000 + O_LARGEFILE = 0x8000 + O_NDELAY = 0x800 + O_NOATIME = 0x40000 + O_NOCTTY = 0x100 + O_NOFOLLOW = 0x20000 + O_NONBLOCK = 0x800 + O_PATH = 0x200000 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_RSYNC = 0x101000 + O_SYNC = 0x101000 + O_TMPFILE = 0x410000 + O_TRUNC = 0x200 + O_WRONLY = 0x1 + PACKET_ADD_MEMBERSHIP = 0x1 + PACKET_AUXDATA = 0x8 + PACKET_BROADCAST = 0x1 + PACKET_COPY_THRESH = 0x7 + PACKET_DROP_MEMBERSHIP = 0x2 + PACKET_FANOUT = 0x12 + PACKET_FANOUT_CPU = 0x2 + PACKET_FANOUT_FLAG_DEFRAG = 0x8000 + PACKET_FANOUT_HASH = 0x0 + PACKET_FANOUT_LB = 0x1 + PACKET_FASTROUTE = 0x6 + PACKET_HDRLEN = 0xb + PACKET_HOST = 0x0 + PACKET_LOOPBACK = 0x5 + PACKET_LOSS = 0xe + PACKET_MR_ALLMULTI = 0x2 + PACKET_MR_MULTICAST = 0x0 + PACKET_MR_PROMISC = 0x1 + PACKET_MR_UNICAST = 0x3 + PACKET_MULTICAST = 0x2 + PACKET_ORIGDEV = 0x9 + PACKET_OTHERHOST = 0x3 + PACKET_OUTGOING = 0x4 + PACKET_RECV_OUTPUT = 0x3 + PACKET_RESERVE = 0xc + PACKET_RX_RING = 0x5 + PACKET_STATISTICS = 0x6 + PACKET_TIMESTAMP = 0x11 + PACKET_TX_RING = 0xd + PACKET_TX_TIMESTAMP = 0x10 + PACKET_VERSION = 0xa + PACKET_VNET_HDR = 0xf + PARENB = 0x100 + PARITY_CRC16_PR0 = 0x2 + PARITY_CRC16_PR0_CCITT = 0x4 + PARITY_CRC16_PR1 = 0x3 + PARITY_CRC16_PR1_CCITT = 0x5 + PARITY_CRC32_PR0_CCITT = 0x6 + PARITY_CRC32_PR1_CCITT = 0x7 + PARITY_DEFAULT = 0x0 + PARITY_NONE = 0x1 + PARMRK = 0x8 + PARODD = 0x200 + PENDIN = 0x4000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_GROWSDOWN = 0x1000000 + PROT_GROWSUP = 0x2000000 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + PR_CAPBSET_DROP = 0x18 + PR_CAPBSET_READ = 0x17 + PR_ENDIAN_BIG = 0x0 + PR_ENDIAN_LITTLE = 0x1 + PR_ENDIAN_PPC_LITTLE = 0x2 + PR_FPEMU_NOPRINT = 0x1 + PR_FPEMU_SIGFPE = 0x2 + PR_FP_EXC_ASYNC = 0x2 + PR_FP_EXC_DISABLED = 0x0 + PR_FP_EXC_DIV = 0x10000 + PR_FP_EXC_INV = 0x100000 + PR_FP_EXC_NONRECOV = 0x1 + PR_FP_EXC_OVF = 0x20000 + PR_FP_EXC_PRECISE = 0x3 + PR_FP_EXC_RES = 0x80000 + PR_FP_EXC_SW_ENABLE = 0x80 + PR_FP_EXC_UND = 0x40000 + PR_GET_DUMPABLE = 0x3 + PR_GET_ENDIAN = 0x13 + PR_GET_FPEMU = 0x9 + PR_GET_FPEXC = 0xb + PR_GET_KEEPCAPS = 0x7 + PR_GET_NAME = 0x10 + PR_GET_NO_NEW_PRIVS = 0x27 + PR_GET_PDEATHSIG = 0x2 + PR_GET_SECCOMP = 0x15 + PR_GET_SECUREBITS = 0x1b + PR_GET_TIMERSLACK = 0x1e + PR_GET_TIMING = 0xd + PR_GET_TSC = 0x19 + PR_GET_UNALIGN = 0x5 + PR_MCE_KILL = 0x21 + PR_MCE_KILL_CLEAR = 0x0 + PR_MCE_KILL_DEFAULT = 0x2 + PR_MCE_KILL_EARLY = 0x1 + PR_MCE_KILL_GET = 0x22 + PR_MCE_KILL_LATE = 0x0 + PR_MCE_KILL_SET = 0x1 + PR_SET_DUMPABLE = 0x4 + PR_SET_ENDIAN = 0x14 + PR_SET_FPEMU = 0xa + PR_SET_FPEXC = 0xc + PR_SET_KEEPCAPS = 0x8 + PR_SET_MM = 0x23 + PR_SET_MM_BRK = 0x7 + PR_SET_MM_END_CODE = 0x2 + PR_SET_MM_END_DATA = 0x4 + PR_SET_MM_START_BRK = 0x6 + PR_SET_MM_START_CODE = 0x1 + PR_SET_MM_START_DATA = 0x3 + PR_SET_MM_START_STACK = 0x5 + PR_SET_NAME = 0xf + PR_SET_NO_NEW_PRIVS = 0x26 + PR_SET_PDEATHSIG = 0x1 + PR_SET_PTRACER = 0x59616d61 + PR_SET_PTRACER_ANY = 0xffffffff + PR_SET_SECCOMP = 0x16 + PR_SET_SECUREBITS = 0x1c + PR_SET_TIMERSLACK = 0x1d + PR_SET_TIMING = 0xe + PR_SET_TSC = 0x1a + PR_SET_UNALIGN = 0x6 + PR_TASK_PERF_EVENTS_DISABLE = 0x1f + PR_TASK_PERF_EVENTS_ENABLE = 0x20 + PR_TIMING_STATISTICAL = 0x0 + PR_TIMING_TIMESTAMP = 0x1 + PR_TSC_ENABLE = 0x1 + PR_TSC_SIGSEGV = 0x2 + PR_UNALIGN_NOPRINT = 0x1 + PR_UNALIGN_SIGBUS = 0x2 + PTRACE_ATTACH = 0x10 + PTRACE_CONT = 0x7 + PTRACE_DETACH = 0x11 + PTRACE_EVENT_CLONE = 0x3 + PTRACE_EVENT_EXEC = 0x4 + PTRACE_EVENT_EXIT = 0x6 + PTRACE_EVENT_FORK = 0x1 + PTRACE_EVENT_SECCOMP = 0x7 + PTRACE_EVENT_STOP = 0x80 + PTRACE_EVENT_VFORK = 0x2 + PTRACE_EVENT_VFORK_DONE = 0x5 + PTRACE_GETEVENTMSG = 0x4201 + PTRACE_GETFPREGS = 0xe + PTRACE_GETFPXREGS = 0x12 + PTRACE_GETREGS = 0xc + PTRACE_GETREGSET = 0x4204 + PTRACE_GETSIGINFO = 0x4202 + PTRACE_GET_THREAD_AREA = 0x19 + PTRACE_INTERRUPT = 0x4207 + PTRACE_KILL = 0x8 + PTRACE_LISTEN = 0x4208 + PTRACE_OLDSETOPTIONS = 0x15 + PTRACE_O_MASK = 0xff + PTRACE_O_TRACECLONE = 0x8 + PTRACE_O_TRACEEXEC = 0x10 + PTRACE_O_TRACEEXIT = 0x40 + PTRACE_O_TRACEFORK = 0x2 + PTRACE_O_TRACESECCOMP = 0x80 + PTRACE_O_TRACESYSGOOD = 0x1 + PTRACE_O_TRACEVFORK = 0x4 + PTRACE_O_TRACEVFORKDONE = 0x20 + PTRACE_PEEKDATA = 0x2 + PTRACE_PEEKTEXT = 0x1 + PTRACE_PEEKUSR = 0x3 + PTRACE_POKEDATA = 0x5 + PTRACE_POKETEXT = 0x4 + PTRACE_POKEUSR = 0x6 + PTRACE_SEIZE = 0x4206 + PTRACE_SEIZE_DEVEL = 0x80000000 + PTRACE_SETFPREGS = 0xf + PTRACE_SETFPXREGS = 0x13 + PTRACE_SETOPTIONS = 0x4200 + PTRACE_SETREGS = 0xd + PTRACE_SETREGSET = 0x4205 + PTRACE_SETSIGINFO = 0x4203 + PTRACE_SET_THREAD_AREA = 0x1a + PTRACE_SINGLEBLOCK = 0x21 + PTRACE_SINGLESTEP = 0x9 + PTRACE_SYSCALL = 0x18 + PTRACE_SYSEMU = 0x1f + PTRACE_SYSEMU_SINGLESTEP = 0x20 + PTRACE_TRACEME = 0x0 + RLIMIT_AS = 0x9 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x7 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = -0x1 + RTAX_ADVMSS = 0x8 + RTAX_CWND = 0x7 + RTAX_FEATURES = 0xc + RTAX_FEATURE_ALLFRAG = 0x8 + RTAX_FEATURE_ECN = 0x1 + RTAX_FEATURE_SACK = 0x2 + RTAX_FEATURE_TIMESTAMP = 0x4 + RTAX_HOPLIMIT = 0xa + RTAX_INITCWND = 0xb + RTAX_INITRWND = 0xe + RTAX_LOCK = 0x1 + RTAX_MAX = 0xe + RTAX_MTU = 0x2 + RTAX_REORDERING = 0x9 + RTAX_RTO_MIN = 0xd + RTAX_RTT = 0x4 + RTAX_RTTVAR = 0x5 + RTAX_SSTHRESH = 0x6 + RTAX_UNSPEC = 0x0 + RTAX_WINDOW = 0x3 + RTA_ALIGNTO = 0x4 + RTA_MAX = 0x10 + RTCF_DIRECTSRC = 0x4000000 + RTCF_DOREDIRECT = 0x1000000 + RTCF_LOG = 0x2000000 + RTCF_MASQ = 0x400000 + RTCF_NAT = 0x800000 + RTCF_VALVE = 0x200000 + RTF_ADDRCLASSMASK = 0xf8000000 + RTF_ADDRCONF = 0x40000 + RTF_ALLONLINK = 0x20000 + RTF_BROADCAST = 0x10000000 + RTF_CACHE = 0x1000000 + RTF_DEFAULT = 0x10000 + RTF_DYNAMIC = 0x10 + RTF_FLOW = 0x2000000 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_INTERFACE = 0x40000000 + RTF_IRTT = 0x100 + RTF_LINKRT = 0x100000 + RTF_LOCAL = 0x80000000 + RTF_MODIFIED = 0x20 + RTF_MSS = 0x40 + RTF_MTU = 0x40 + RTF_MULTICAST = 0x20000000 + RTF_NAT = 0x8000000 + RTF_NOFORWARD = 0x1000 + RTF_NONEXTHOP = 0x200000 + RTF_NOPMTUDISC = 0x4000 + RTF_POLICY = 0x4000000 + RTF_REINSTATE = 0x8 + RTF_REJECT = 0x200 + RTF_STATIC = 0x400 + RTF_THROW = 0x2000 + RTF_UP = 0x1 + RTF_WINDOW = 0x80 + RTF_XRESOLVE = 0x800 + RTM_BASE = 0x10 + RTM_DELACTION = 0x31 + RTM_DELADDR = 0x15 + RTM_DELADDRLABEL = 0x49 + RTM_DELLINK = 0x11 + RTM_DELNEIGH = 0x1d + RTM_DELQDISC = 0x25 + RTM_DELROUTE = 0x19 + RTM_DELRULE = 0x21 + RTM_DELTCLASS = 0x29 + RTM_DELTFILTER = 0x2d + RTM_F_CLONED = 0x200 + RTM_F_EQUALIZE = 0x400 + RTM_F_NOTIFY = 0x100 + RTM_F_PREFIX = 0x800 + RTM_GETACTION = 0x32 + RTM_GETADDR = 0x16 + RTM_GETADDRLABEL = 0x4a + RTM_GETANYCAST = 0x3e + RTM_GETDCB = 0x4e + RTM_GETLINK = 0x12 + RTM_GETMULTICAST = 0x3a + RTM_GETNEIGH = 0x1e + RTM_GETNEIGHTBL = 0x42 + RTM_GETQDISC = 0x26 + RTM_GETROUTE = 0x1a + RTM_GETRULE = 0x22 + RTM_GETTCLASS = 0x2a + RTM_GETTFILTER = 0x2e + RTM_MAX = 0x4f + RTM_NEWACTION = 0x30 + RTM_NEWADDR = 0x14 + RTM_NEWADDRLABEL = 0x48 + RTM_NEWLINK = 0x10 + RTM_NEWNDUSEROPT = 0x44 + RTM_NEWNEIGH = 0x1c + RTM_NEWNEIGHTBL = 0x40 + RTM_NEWPREFIX = 0x34 + RTM_NEWQDISC = 0x24 + RTM_NEWROUTE = 0x18 + RTM_NEWRULE = 0x20 + RTM_NEWTCLASS = 0x28 + RTM_NEWTFILTER = 0x2c + RTM_NR_FAMILIES = 0x10 + RTM_NR_MSGTYPES = 0x40 + RTM_SETDCB = 0x4f + RTM_SETLINK = 0x13 + RTM_SETNEIGHTBL = 0x43 + RTNH_ALIGNTO = 0x4 + RTNH_F_DEAD = 0x1 + RTNH_F_ONLINK = 0x4 + RTNH_F_PERVASIVE = 0x2 + RTN_MAX = 0xb + RTPROT_BIRD = 0xc + RTPROT_BOOT = 0x3 + RTPROT_DHCP = 0x10 + RTPROT_DNROUTED = 0xd + RTPROT_GATED = 0x8 + RTPROT_KERNEL = 0x2 + RTPROT_MRT = 0xa + RTPROT_NTK = 0xf + RTPROT_RA = 0x9 + RTPROT_REDIRECT = 0x1 + RTPROT_STATIC = 0x4 + RTPROT_UNSPEC = 0x0 + RTPROT_XORP = 0xe + RTPROT_ZEBRA = 0xb + RT_CLASS_DEFAULT = 0xfd + RT_CLASS_LOCAL = 0xff + RT_CLASS_MAIN = 0xfe + RT_CLASS_MAX = 0xff + RT_CLASS_UNSPEC = 0x0 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + RUSAGE_THREAD = 0x1 + SCM_CREDENTIALS = 0x2 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x1d + SCM_TIMESTAMPING = 0x25 + SCM_TIMESTAMPNS = 0x23 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDDLCI = 0x8980 + SIOCADDMULTI = 0x8931 + SIOCADDRT = 0x890b + SIOCATMARK = 0x8905 + SIOCDARP = 0x8953 + SIOCDELDLCI = 0x8981 + SIOCDELMULTI = 0x8932 + SIOCDELRT = 0x890c + SIOCDEVPRIVATE = 0x89f0 + SIOCDIFADDR = 0x8936 + SIOCDRARP = 0x8960 + SIOCGARP = 0x8954 + SIOCGIFADDR = 0x8915 + SIOCGIFBR = 0x8940 + SIOCGIFBRDADDR = 0x8919 + SIOCGIFCONF = 0x8912 + SIOCGIFCOUNT = 0x8938 + SIOCGIFDSTADDR = 0x8917 + SIOCGIFENCAP = 0x8925 + SIOCGIFFLAGS = 0x8913 + SIOCGIFHWADDR = 0x8927 + SIOCGIFINDEX = 0x8933 + SIOCGIFMAP = 0x8970 + SIOCGIFMEM = 0x891f + SIOCGIFMETRIC = 0x891d + SIOCGIFMTU = 0x8921 + SIOCGIFNAME = 0x8910 + SIOCGIFNETMASK = 0x891b + SIOCGIFPFLAGS = 0x8935 + SIOCGIFSLAVE = 0x8929 + SIOCGIFTXQLEN = 0x8942 + SIOCGPGRP = 0x8904 + SIOCGRARP = 0x8961 + SIOCGSTAMP = 0x8906 + SIOCGSTAMPNS = 0x8907 + SIOCPROTOPRIVATE = 0x89e0 + SIOCRTMSG = 0x890d + SIOCSARP = 0x8955 + SIOCSIFADDR = 0x8916 + SIOCSIFBR = 0x8941 + SIOCSIFBRDADDR = 0x891a + SIOCSIFDSTADDR = 0x8918 + SIOCSIFENCAP = 0x8926 + SIOCSIFFLAGS = 0x8914 + SIOCSIFHWADDR = 0x8924 + SIOCSIFHWBROADCAST = 0x8937 + SIOCSIFLINK = 0x8911 + SIOCSIFMAP = 0x8971 + SIOCSIFMEM = 0x8920 + SIOCSIFMETRIC = 0x891e + SIOCSIFMTU = 0x8922 + SIOCSIFNAME = 0x8923 + SIOCSIFNETMASK = 0x891c + SIOCSIFPFLAGS = 0x8934 + SIOCSIFSLAVE = 0x8930 + SIOCSIFTXQLEN = 0x8943 + SIOCSPGRP = 0x8902 + SIOCSRARP = 0x8962 + SOCK_CLOEXEC = 0x80000 + SOCK_DCCP = 0x6 + SOCK_DGRAM = 0x2 + SOCK_NONBLOCK = 0x800 + SOCK_PACKET = 0xa + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_AAL = 0x109 + SOL_ATM = 0x108 + SOL_DECNET = 0x105 + SOL_ICMPV6 = 0x3a + SOL_IP = 0x0 + SOL_IPV6 = 0x29 + SOL_IRDA = 0x10a + SOL_PACKET = 0x107 + SOL_RAW = 0xff + SOL_SOCKET = 0x1 + SOL_TCP = 0x6 + SOL_X25 = 0x106 + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x1e + SO_ATTACH_FILTER = 0x1a + SO_BINDTODEVICE = 0x19 + SO_BROADCAST = 0x6 + SO_BSDCOMPAT = 0xe + SO_DEBUG = 0x1 + SO_DETACH_FILTER = 0x1b + SO_DOMAIN = 0x27 + SO_DONTROUTE = 0x5 + SO_ERROR = 0x4 + SO_KEEPALIVE = 0x9 + SO_LINGER = 0xd + SO_MARK = 0x24 + SO_NO_CHECK = 0xb + SO_OOBINLINE = 0xa + SO_PASSCRED = 0x10 + SO_PASSSEC = 0x22 + SO_PEERCRED = 0x11 + SO_PEERNAME = 0x1c + SO_PEERSEC = 0x1f + SO_PRIORITY = 0xc + SO_PROTOCOL = 0x26 + SO_RCVBUF = 0x8 + SO_RCVBUFFORCE = 0x21 + SO_RCVLOWAT = 0x12 + SO_RCVTIMEO = 0x14 + SO_REUSEADDR = 0x2 + SO_RXQ_OVFL = 0x28 + SO_SECURITY_AUTHENTICATION = 0x16 + SO_SECURITY_ENCRYPTION_NETWORK = 0x18 + SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17 + SO_SNDBUF = 0x7 + SO_SNDBUFFORCE = 0x20 + SO_SNDLOWAT = 0x13 + SO_SNDTIMEO = 0x15 + SO_TIMESTAMP = 0x1d + SO_TIMESTAMPING = 0x25 + SO_TIMESTAMPNS = 0x23 + SO_TYPE = 0x3 + S_BLKSIZE = 0x200 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + TAB0 = 0x0 + TAB1 = 0x800 + TAB2 = 0x1000 + TAB3 = 0x1800 + TABDLY = 0x1800 + TCFLSH = 0x540b + TCGETA = 0x5405 + TCGETS = 0x5401 + TCGETS2 = 0x802c542a + TCGETX = 0x5432 + TCIFLUSH = 0x0 + TCIOFF = 0x2 + TCIOFLUSH = 0x2 + TCION = 0x3 + TCOFLUSH = 0x1 + TCOOFF = 0x0 + TCOON = 0x1 + TCP_CONGESTION = 0xd + TCP_CORK = 0x3 + TCP_DEFER_ACCEPT = 0x9 + TCP_INFO = 0xb + TCP_KEEPCNT = 0x6 + TCP_KEEPIDLE = 0x4 + TCP_KEEPINTVL = 0x5 + TCP_LINGER2 = 0x8 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0xe + TCP_MD5SIG_MAXKEYLEN = 0x50 + TCP_MSS = 0x200 + TCP_NODELAY = 0x1 + TCP_QUICKACK = 0xc + TCP_SYNCNT = 0x7 + TCP_WINDOW_CLAMP = 0xa + TCSAFLUSH = 0x2 + TCSBRK = 0x5409 + TCSBRKP = 0x5425 + TCSETA = 0x5406 + TCSETAF = 0x5408 + TCSETAW = 0x5407 + TCSETS = 0x5402 + TCSETS2 = 0x402c542b + TCSETSF = 0x5404 + TCSETSF2 = 0x402c542d + TCSETSW = 0x5403 + TCSETSW2 = 0x402c542c + TCSETX = 0x5433 + TCSETXF = 0x5434 + TCSETXW = 0x5435 + TCXONC = 0x540a + TIOCCBRK = 0x5428 + TIOCCONS = 0x541d + TIOCEXCL = 0x540c + TIOCGDEV = 0x80045432 + TIOCGETD = 0x5424 + TIOCGEXCL = 0x80045440 + TIOCGICOUNT = 0x545d + TIOCGLCKTRMIOS = 0x5456 + TIOCGPGRP = 0x540f + TIOCGPKT = 0x80045438 + TIOCGPTLCK = 0x80045439 + TIOCGPTN = 0x80045430 + TIOCGRS485 = 0x542e + TIOCGSERIAL = 0x541e + TIOCGSID = 0x5429 + TIOCGSOFTCAR = 0x5419 + TIOCGWINSZ = 0x5413 + TIOCINQ = 0x541b + TIOCLINUX = 0x541c + TIOCMBIC = 0x5417 + TIOCMBIS = 0x5416 + TIOCMGET = 0x5415 + TIOCMIWAIT = 0x545c + TIOCMSET = 0x5418 + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x5422 + TIOCNXCL = 0x540d + TIOCOUTQ = 0x5411 + TIOCPKT = 0x5420 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCSBRK = 0x5427 + TIOCSCTTY = 0x540e + TIOCSERCONFIG = 0x5453 + TIOCSERGETLSR = 0x5459 + TIOCSERGETMULTI = 0x545a + TIOCSERGSTRUCT = 0x5458 + TIOCSERGWILD = 0x5454 + TIOCSERSETMULTI = 0x545b + TIOCSERSWILD = 0x5455 + TIOCSER_TEMT = 0x1 + TIOCSETD = 0x5423 + TIOCSIG = 0x40045436 + TIOCSLCKTRMIOS = 0x5457 + TIOCSPGRP = 0x5410 + TIOCSPTLCK = 0x40045431 + TIOCSRS485 = 0x542f + TIOCSSERIAL = 0x541f + TIOCSSOFTCAR = 0x541a + TIOCSTI = 0x5412 + TIOCSWINSZ = 0x5414 + TIOCVHANGUP = 0x5437 + TOSTOP = 0x100 + TUNATTACHFILTER = 0x400854d5 + TUNDETACHFILTER = 0x400854d6 + TUNGETFEATURES = 0x800454cf + TUNGETIFF = 0x800454d2 + TUNGETSNDBUF = 0x800454d3 + TUNGETVNETHDRSZ = 0x800454d7 + TUNSETDEBUG = 0x400454c9 + TUNSETGROUP = 0x400454ce + TUNSETIFF = 0x400454ca + TUNSETLINK = 0x400454cd + TUNSETNOCSUM = 0x400454c8 + TUNSETOFFLOAD = 0x400454d0 + TUNSETOWNER = 0x400454cc + TUNSETPERSIST = 0x400454cb + TUNSETSNDBUF = 0x400454d4 + TUNSETTXFILTER = 0x400454d1 + TUNSETVNETHDRSZ = 0x400454d8 + VDISCARD = 0xd + VEOF = 0x4 + VEOL = 0xb + VEOL2 = 0x10 + VERASE = 0x2 + VINTR = 0x0 + VKILL = 0x3 + VLNEXT = 0xf + VMIN = 0x6 + VQUIT = 0x1 + VREPRINT = 0xc + VSTART = 0x8 + VSTOP = 0x9 + VSUSP = 0xa + VSWTC = 0x7 + VT0 = 0x0 + VT1 = 0x4000 + VTDLY = 0x4000 + VTIME = 0x5 + VWERASE = 0xe + WALL = 0x40000000 + WCLONE = 0x80000000 + WCONTINUED = 0x8 + WEXITED = 0x4 + WNOHANG = 0x1 + WNOTHREAD = 0x20000000 + WNOWAIT = 0x1000000 + WORDSIZE = 0x20 + WSTOPPED = 0x2 + WUNTRACED = 0x2 + XCASE = 0x4 + XTABS = 0x1800 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x62) + EADDRNOTAVAIL = syscall.Errno(0x63) + EADV = syscall.Errno(0x44) + EAFNOSUPPORT = syscall.Errno(0x61) + EAGAIN = syscall.Errno(0xb) + EALREADY = syscall.Errno(0x72) + EBADE = syscall.Errno(0x34) + EBADF = syscall.Errno(0x9) + EBADFD = syscall.Errno(0x4d) + EBADMSG = syscall.Errno(0x4a) + EBADR = syscall.Errno(0x35) + EBADRQC = syscall.Errno(0x38) + EBADSLT = syscall.Errno(0x39) + EBFONT = syscall.Errno(0x3b) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x7d) + ECHILD = syscall.Errno(0xa) + ECHRNG = syscall.Errno(0x2c) + ECOMM = syscall.Errno(0x46) + ECONNABORTED = syscall.Errno(0x67) + ECONNREFUSED = syscall.Errno(0x6f) + ECONNRESET = syscall.Errno(0x68) + EDEADLK = syscall.Errno(0x23) + EDEADLOCK = syscall.Errno(0x23) + EDESTADDRREQ = syscall.Errno(0x59) + EDOM = syscall.Errno(0x21) + EDOTDOT = syscall.Errno(0x49) + EDQUOT = syscall.Errno(0x7a) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EHOSTDOWN = syscall.Errno(0x70) + EHOSTUNREACH = syscall.Errno(0x71) + EHWPOISON = syscall.Errno(0x85) + EIDRM = syscall.Errno(0x2b) + EILSEQ = syscall.Errno(0x54) + EINPROGRESS = syscall.Errno(0x73) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x6a) + EISDIR = syscall.Errno(0x15) + EISNAM = syscall.Errno(0x78) + EKEYEXPIRED = syscall.Errno(0x7f) + EKEYREJECTED = syscall.Errno(0x81) + EKEYREVOKED = syscall.Errno(0x80) + EL2HLT = syscall.Errno(0x33) + EL2NSYNC = syscall.Errno(0x2d) + EL3HLT = syscall.Errno(0x2e) + EL3RST = syscall.Errno(0x2f) + ELIBACC = syscall.Errno(0x4f) + ELIBBAD = syscall.Errno(0x50) + ELIBEXEC = syscall.Errno(0x53) + ELIBMAX = syscall.Errno(0x52) + ELIBSCN = syscall.Errno(0x51) + ELNRNG = syscall.Errno(0x30) + ELOOP = syscall.Errno(0x28) + EMEDIUMTYPE = syscall.Errno(0x7c) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x5a) + EMULTIHOP = syscall.Errno(0x48) + ENAMETOOLONG = syscall.Errno(0x24) + ENAVAIL = syscall.Errno(0x77) + ENETDOWN = syscall.Errno(0x64) + ENETRESET = syscall.Errno(0x66) + ENETUNREACH = syscall.Errno(0x65) + ENFILE = syscall.Errno(0x17) + ENOANO = syscall.Errno(0x37) + ENOBUFS = syscall.Errno(0x69) + ENOCSI = syscall.Errno(0x32) + ENODATA = syscall.Errno(0x3d) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOKEY = syscall.Errno(0x7e) + ENOLCK = syscall.Errno(0x25) + ENOLINK = syscall.Errno(0x43) + ENOMEDIUM = syscall.Errno(0x7b) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x2a) + ENONET = syscall.Errno(0x40) + ENOPKG = syscall.Errno(0x41) + ENOPROTOOPT = syscall.Errno(0x5c) + ENOSPC = syscall.Errno(0x1c) + ENOSR = syscall.Errno(0x3f) + ENOSTR = syscall.Errno(0x3c) + ENOSYS = syscall.Errno(0x26) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x6b) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x27) + ENOTNAM = syscall.Errno(0x76) + ENOTRECOVERABLE = syscall.Errno(0x83) + ENOTSOCK = syscall.Errno(0x58) + ENOTSUP = syscall.Errno(0x5f) + ENOTTY = syscall.Errno(0x19) + ENOTUNIQ = syscall.Errno(0x4c) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x5f) + EOVERFLOW = syscall.Errno(0x4b) + EOWNERDEAD = syscall.Errno(0x82) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x60) + EPIPE = syscall.Errno(0x20) + EPROTO = syscall.Errno(0x47) + EPROTONOSUPPORT = syscall.Errno(0x5d) + EPROTOTYPE = syscall.Errno(0x5b) + ERANGE = syscall.Errno(0x22) + EREMCHG = syscall.Errno(0x4e) + EREMOTE = syscall.Errno(0x42) + EREMOTEIO = syscall.Errno(0x79) + ERESTART = syscall.Errno(0x55) + ERFKILL = syscall.Errno(0x84) + EROFS = syscall.Errno(0x1e) + ESHUTDOWN = syscall.Errno(0x6c) + ESOCKTNOSUPPORT = syscall.Errno(0x5e) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESRMNT = syscall.Errno(0x45) + ESTALE = syscall.Errno(0x74) + ESTRPIPE = syscall.Errno(0x56) + ETIME = syscall.Errno(0x3e) + ETIMEDOUT = syscall.Errno(0x6e) + ETOOMANYREFS = syscall.Errno(0x6d) + ETXTBSY = syscall.Errno(0x1a) + EUCLEAN = syscall.Errno(0x75) + EUNATCH = syscall.Errno(0x31) + EUSERS = syscall.Errno(0x57) + EWOULDBLOCK = syscall.Errno(0xb) + EXDEV = syscall.Errno(0x12) + EXFULL = syscall.Errno(0x36) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0x7) + SIGCHLD = syscall.Signal(0x11) + SIGCLD = syscall.Signal(0x11) + SIGCONT = syscall.Signal(0x12) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x1d) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPOLL = syscall.Signal(0x1d) + SIGPROF = syscall.Signal(0x1b) + SIGPWR = syscall.Signal(0x1e) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTKFLT = syscall.Signal(0x10) + SIGSTOP = syscall.Signal(0x13) + SIGSYS = syscall.Signal(0x1f) + SIGTERM = syscall.Signal(0xf) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x14) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGUNUSED = syscall.Signal(0x1f) + SIGURG = syscall.Signal(0x17) + SIGUSR1 = syscall.Signal(0xa) + SIGUSR2 = syscall.Signal(0xc) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "no such device or address", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource temporarily unavailable", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device or resource busy", + 17: "file exists", + 18: "invalid cross-device link", + 19: "no such device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "numerical result out of range", + 35: "resource deadlock avoided", + 36: "file name too long", + 37: "no locks available", + 38: "function not implemented", + 39: "directory not empty", + 40: "too many levels of symbolic links", + 42: "no message of desired type", + 43: "identifier removed", + 44: "channel number out of range", + 45: "level 2 not synchronized", + 46: "level 3 halted", + 47: "level 3 reset", + 48: "link number out of range", + 49: "protocol driver not attached", + 50: "no CSI structure available", + 51: "level 2 halted", + 52: "invalid exchange", + 53: "invalid request descriptor", + 54: "exchange full", + 55: "no anode", + 56: "invalid request code", + 57: "invalid slot", + 59: "bad font file format", + 60: "device not a stream", + 61: "no data available", + 62: "timer expired", + 63: "out of streams resources", + 64: "machine is not on the network", + 65: "package not installed", + 66: "object is remote", + 67: "link has been severed", + 68: "advertise error", + 69: "srmount error", + 70: "communication error on send", + 71: "protocol error", + 72: "multihop attempted", + 73: "RFS specific error", + 74: "bad message", + 75: "value too large for defined data type", + 76: "name not unique on network", + 77: "file descriptor in bad state", + 78: "remote address changed", + 79: "can not access a needed shared library", + 80: "accessing a corrupted shared library", + 81: ".lib section in a.out corrupted", + 82: "attempting to link in too many shared libraries", + 83: "cannot exec a shared library directly", + 84: "invalid or incomplete multibyte or wide character", + 85: "interrupted system call should be restarted", + 86: "streams pipe error", + 87: "too many users", + 88: "socket operation on non-socket", + 89: "destination address required", + 90: "message too long", + 91: "protocol wrong type for socket", + 92: "protocol not available", + 93: "protocol not supported", + 94: "socket type not supported", + 95: "operation not supported", + 96: "protocol family not supported", + 97: "address family not supported by protocol", + 98: "address already in use", + 99: "cannot assign requested address", + 100: "network is down", + 101: "network is unreachable", + 102: "network dropped connection on reset", + 103: "software caused connection abort", + 104: "connection reset by peer", + 105: "no buffer space available", + 106: "transport endpoint is already connected", + 107: "transport endpoint is not connected", + 108: "cannot send after transport endpoint shutdown", + 109: "too many references: cannot splice", + 110: "connection timed out", + 111: "connection refused", + 112: "host is down", + 113: "no route to host", + 114: "operation already in progress", + 115: "operation now in progress", + 116: "stale NFS file handle", + 117: "structure needs cleaning", + 118: "not a XENIX named type file", + 119: "no XENIX semaphores available", + 120: "is a named type file", + 121: "remote I/O error", + 122: "disk quota exceeded", + 123: "no medium found", + 124: "wrong medium type", + 125: "operation canceled", + 126: "required key not available", + 127: "key has expired", + 128: "key has been revoked", + 129: "key was rejected by service", + 130: "owner died", + 131: "state not recoverable", + 132: "operation not possible due to RF-kill", + 133: "unknown error 133", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/breakpoint trap", + 6: "aborted", + 7: "bus error", + 8: "floating point exception", + 9: "killed", + 10: "user defined signal 1", + 11: "segmentation fault", + 12: "user defined signal 2", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "stack fault", + 17: "child exited", + 18: "continued", + 19: "stopped (signal)", + 20: "stopped", + 21: "stopped (tty input)", + 22: "stopped (tty output)", + 23: "urgent I/O condition", + 24: "CPU time limit exceeded", + 25: "file size limit exceeded", + 26: "virtual timer expired", + 27: "profiling timer expired", + 28: "window changed", + 29: "I/O possible", + 30: "power failure", + 31: "bad system call", +} diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go new file mode 100644 index 0000000000..49b6c35467 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -0,0 +1,1820 @@ +// mkerrors.sh -m64 +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build amd64,linux + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -m64 _const.go + +package unix + +import "syscall" + +const ( + AF_ALG = 0x26 + AF_APPLETALK = 0x5 + AF_ASH = 0x12 + AF_ATMPVC = 0x8 + AF_ATMSVC = 0x14 + AF_AX25 = 0x3 + AF_BLUETOOTH = 0x1f + AF_BRIDGE = 0x7 + AF_CAIF = 0x25 + AF_CAN = 0x1d + AF_DECnet = 0xc + AF_ECONET = 0x13 + AF_FILE = 0x1 + AF_IEEE802154 = 0x24 + AF_INET = 0x2 + AF_INET6 = 0xa + AF_IPX = 0x4 + AF_IRDA = 0x17 + AF_ISDN = 0x22 + AF_IUCV = 0x20 + AF_KEY = 0xf + AF_LLC = 0x1a + AF_LOCAL = 0x1 + AF_MAX = 0x28 + AF_NETBEUI = 0xd + AF_NETLINK = 0x10 + AF_NETROM = 0x6 + AF_NFC = 0x27 + AF_PACKET = 0x11 + AF_PHONET = 0x23 + AF_PPPOX = 0x18 + AF_RDS = 0x15 + AF_ROSE = 0xb + AF_ROUTE = 0x10 + AF_RXRPC = 0x21 + AF_SECURITY = 0xe + AF_SNA = 0x16 + AF_TIPC = 0x1e + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_WANPIPE = 0x19 + AF_X25 = 0x9 + ARPHRD_ADAPT = 0x108 + ARPHRD_APPLETLK = 0x8 + ARPHRD_ARCNET = 0x7 + ARPHRD_ASH = 0x30d + ARPHRD_ATM = 0x13 + ARPHRD_AX25 = 0x3 + ARPHRD_BIF = 0x307 + ARPHRD_CAIF = 0x336 + ARPHRD_CAN = 0x118 + ARPHRD_CHAOS = 0x5 + ARPHRD_CISCO = 0x201 + ARPHRD_CSLIP = 0x101 + ARPHRD_CSLIP6 = 0x103 + ARPHRD_DDCMP = 0x205 + ARPHRD_DLCI = 0xf + ARPHRD_ECONET = 0x30e + ARPHRD_EETHER = 0x2 + ARPHRD_ETHER = 0x1 + ARPHRD_EUI64 = 0x1b + ARPHRD_FCAL = 0x311 + ARPHRD_FCFABRIC = 0x313 + ARPHRD_FCPL = 0x312 + ARPHRD_FCPP = 0x310 + ARPHRD_FDDI = 0x306 + ARPHRD_FRAD = 0x302 + ARPHRD_HDLC = 0x201 + ARPHRD_HIPPI = 0x30c + ARPHRD_HWX25 = 0x110 + ARPHRD_IEEE1394 = 0x18 + ARPHRD_IEEE802 = 0x6 + ARPHRD_IEEE80211 = 0x321 + ARPHRD_IEEE80211_PRISM = 0x322 + ARPHRD_IEEE80211_RADIOTAP = 0x323 + ARPHRD_IEEE802154 = 0x324 + ARPHRD_IEEE802_TR = 0x320 + ARPHRD_INFINIBAND = 0x20 + ARPHRD_IPDDP = 0x309 + ARPHRD_IPGRE = 0x30a + ARPHRD_IRDA = 0x30f + ARPHRD_LAPB = 0x204 + ARPHRD_LOCALTLK = 0x305 + ARPHRD_LOOPBACK = 0x304 + ARPHRD_METRICOM = 0x17 + ARPHRD_NETROM = 0x0 + ARPHRD_NONE = 0xfffe + ARPHRD_PHONET = 0x334 + ARPHRD_PHONET_PIPE = 0x335 + ARPHRD_PIMREG = 0x30b + ARPHRD_PPP = 0x200 + ARPHRD_PRONET = 0x4 + ARPHRD_RAWHDLC = 0x206 + ARPHRD_ROSE = 0x10e + ARPHRD_RSRVD = 0x104 + ARPHRD_SIT = 0x308 + ARPHRD_SKIP = 0x303 + ARPHRD_SLIP = 0x100 + ARPHRD_SLIP6 = 0x102 + ARPHRD_TUNNEL = 0x300 + ARPHRD_TUNNEL6 = 0x301 + ARPHRD_VOID = 0xffff + ARPHRD_X25 = 0x10f + B0 = 0x0 + B1000000 = 0x1008 + B110 = 0x3 + B115200 = 0x1002 + B1152000 = 0x1009 + B1200 = 0x9 + B134 = 0x4 + B150 = 0x5 + B1500000 = 0x100a + B1800 = 0xa + B19200 = 0xe + B200 = 0x6 + B2000000 = 0x100b + B230400 = 0x1003 + B2400 = 0xb + B2500000 = 0x100c + B300 = 0x7 + B3000000 = 0x100d + B3500000 = 0x100e + B38400 = 0xf + B4000000 = 0x100f + B460800 = 0x1004 + B4800 = 0xc + B50 = 0x1 + B500000 = 0x1005 + B57600 = 0x1001 + B576000 = 0x1006 + B600 = 0x8 + B75 = 0x2 + B921600 = 0x1007 + B9600 = 0xd + BOTHER = 0x1000 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXINSNS = 0x1000 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BRKINT = 0x2 + BS0 = 0x0 + BS1 = 0x2000 + BSDLY = 0x2000 + CBAUD = 0x100f + CBAUDEX = 0x1000 + CFLUSH = 0xf + CIBAUD = 0x100f0000 + CLOCAL = 0x800 + CLOCK_BOOTTIME = 0x7 + CLOCK_BOOTTIME_ALARM = 0x9 + CLOCK_DEFAULT = 0x0 + CLOCK_EXT = 0x1 + CLOCK_INT = 0x2 + CLOCK_MONOTONIC = 0x1 + CLOCK_MONOTONIC_COARSE = 0x6 + CLOCK_MONOTONIC_RAW = 0x4 + CLOCK_PROCESS_CPUTIME_ID = 0x2 + CLOCK_REALTIME = 0x0 + CLOCK_REALTIME_ALARM = 0x8 + CLOCK_REALTIME_COARSE = 0x5 + CLOCK_THREAD_CPUTIME_ID = 0x3 + CLOCK_TXFROMRX = 0x4 + CLOCK_TXINT = 0x3 + CLONE_CHILD_CLEARTID = 0x200000 + CLONE_CHILD_SETTID = 0x1000000 + CLONE_DETACHED = 0x400000 + CLONE_FILES = 0x400 + CLONE_FS = 0x200 + CLONE_IO = 0x80000000 + CLONE_NEWCGROUP = 0x2000000 + CLONE_NEWIPC = 0x8000000 + CLONE_NEWNET = 0x40000000 + CLONE_NEWNS = 0x20000 + CLONE_NEWPID = 0x20000000 + CLONE_NEWUSER = 0x10000000 + CLONE_NEWUTS = 0x4000000 + CLONE_PARENT = 0x8000 + CLONE_PARENT_SETTID = 0x100000 + CLONE_PTRACE = 0x2000 + CLONE_SETTLS = 0x80000 + CLONE_SIGHAND = 0x800 + CLONE_SYSVSEM = 0x40000 + CLONE_THREAD = 0x10000 + CLONE_UNTRACED = 0x800000 + CLONE_VFORK = 0x4000 + CLONE_VM = 0x100 + CMSPAR = 0x40000000 + CR0 = 0x0 + CR1 = 0x200 + CR2 = 0x400 + CR3 = 0x600 + CRDLY = 0x600 + CREAD = 0x80 + CRTSCTS = 0x80000000 + CS5 = 0x0 + CS6 = 0x10 + CS7 = 0x20 + CS8 = 0x30 + CSIGNAL = 0xff + CSIZE = 0x30 + CSTART = 0x11 + CSTATUS = 0x0 + CSTOP = 0x13 + CSTOPB = 0x40 + CSUSP = 0x1a + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x200 + ECHOE = 0x10 + ECHOK = 0x20 + ECHOKE = 0x800 + ECHONL = 0x40 + ECHOPRT = 0x400 + ENCODING_DEFAULT = 0x0 + ENCODING_FM_MARK = 0x3 + ENCODING_FM_SPACE = 0x4 + ENCODING_MANCHESTER = 0x5 + ENCODING_NRZ = 0x1 + ENCODING_NRZI = 0x2 + EPOLLERR = 0x8 + EPOLLET = 0x80000000 + EPOLLHUP = 0x10 + EPOLLIN = 0x1 + EPOLLMSG = 0x400 + EPOLLONESHOT = 0x40000000 + EPOLLOUT = 0x4 + EPOLLPRI = 0x2 + EPOLLRDBAND = 0x80 + EPOLLRDHUP = 0x2000 + EPOLLRDNORM = 0x40 + EPOLLWRBAND = 0x200 + EPOLLWRNORM = 0x100 + EPOLL_CLOEXEC = 0x80000 + EPOLL_CTL_ADD = 0x1 + EPOLL_CTL_DEL = 0x2 + EPOLL_CTL_MOD = 0x3 + EPOLL_NONBLOCK = 0x800 + ETH_P_1588 = 0x88f7 + ETH_P_8021AD = 0x88a8 + ETH_P_8021AH = 0x88e7 + ETH_P_8021Q = 0x8100 + ETH_P_802_2 = 0x4 + ETH_P_802_3 = 0x1 + ETH_P_AARP = 0x80f3 + ETH_P_AF_IUCV = 0xfbfb + ETH_P_ALL = 0x3 + ETH_P_AOE = 0x88a2 + ETH_P_ARCNET = 0x1a + ETH_P_ARP = 0x806 + ETH_P_ATALK = 0x809b + ETH_P_ATMFATE = 0x8884 + ETH_P_ATMMPOA = 0x884c + ETH_P_AX25 = 0x2 + ETH_P_BPQ = 0x8ff + ETH_P_CAIF = 0xf7 + ETH_P_CAN = 0xc + ETH_P_CONTROL = 0x16 + ETH_P_CUST = 0x6006 + ETH_P_DDCMP = 0x6 + ETH_P_DEC = 0x6000 + ETH_P_DIAG = 0x6005 + ETH_P_DNA_DL = 0x6001 + ETH_P_DNA_RC = 0x6002 + ETH_P_DNA_RT = 0x6003 + ETH_P_DSA = 0x1b + ETH_P_ECONET = 0x18 + ETH_P_EDSA = 0xdada + ETH_P_FCOE = 0x8906 + ETH_P_FIP = 0x8914 + ETH_P_HDLC = 0x19 + ETH_P_IEEE802154 = 0xf6 + ETH_P_IEEEPUP = 0xa00 + ETH_P_IEEEPUPAT = 0xa01 + ETH_P_IP = 0x800 + ETH_P_IPV6 = 0x86dd + ETH_P_IPX = 0x8137 + ETH_P_IRDA = 0x17 + ETH_P_LAT = 0x6004 + ETH_P_LINK_CTL = 0x886c + ETH_P_LOCALTALK = 0x9 + ETH_P_LOOP = 0x60 + ETH_P_MOBITEX = 0x15 + ETH_P_MPLS_MC = 0x8848 + ETH_P_MPLS_UC = 0x8847 + ETH_P_PAE = 0x888e + ETH_P_PAUSE = 0x8808 + ETH_P_PHONET = 0xf5 + ETH_P_PPPTALK = 0x10 + ETH_P_PPP_DISC = 0x8863 + ETH_P_PPP_MP = 0x8 + ETH_P_PPP_SES = 0x8864 + ETH_P_PUP = 0x200 + ETH_P_PUPAT = 0x201 + ETH_P_QINQ1 = 0x9100 + ETH_P_QINQ2 = 0x9200 + ETH_P_QINQ3 = 0x9300 + ETH_P_RARP = 0x8035 + ETH_P_SCA = 0x6007 + ETH_P_SLOW = 0x8809 + ETH_P_SNAP = 0x5 + ETH_P_TDLS = 0x890d + ETH_P_TEB = 0x6558 + ETH_P_TIPC = 0x88ca + ETH_P_TRAILER = 0x1c + ETH_P_TR_802_2 = 0x11 + ETH_P_WAN_PPP = 0x7 + ETH_P_WCCP = 0x883e + ETH_P_X25 = 0x805 + EXTA = 0xe + EXTB = 0xf + EXTPROC = 0x10000 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FF0 = 0x0 + FF1 = 0x8000 + FFDLY = 0x8000 + FLUSHO = 0x1000 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x406 + F_EXLCK = 0x4 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLEASE = 0x401 + F_GETLK = 0x5 + F_GETLK64 = 0x5 + F_GETOWN = 0x9 + F_GETOWN_EX = 0x10 + F_GETPIPE_SZ = 0x408 + F_GETSIG = 0xb + F_LOCK = 0x1 + F_NOTIFY = 0x402 + F_OK = 0x0 + F_RDLCK = 0x0 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLEASE = 0x400 + F_SETLK = 0x6 + F_SETLK64 = 0x6 + F_SETLKW = 0x7 + F_SETLKW64 = 0x7 + F_SETOWN = 0x8 + F_SETOWN_EX = 0xf + F_SETPIPE_SZ = 0x407 + F_SETSIG = 0xa + F_SHLCK = 0x8 + F_TEST = 0x3 + F_TLOCK = 0x2 + F_ULOCK = 0x0 + F_UNLCK = 0x2 + F_WRLCK = 0x1 + HUPCL = 0x400 + IBSHIFT = 0x10 + ICANON = 0x2 + ICMPV6_FILTER = 0x1 + ICRNL = 0x100 + IEXTEN = 0x8000 + IFA_F_DADFAILED = 0x8 + IFA_F_DEPRECATED = 0x20 + IFA_F_HOMEADDRESS = 0x10 + IFA_F_NODAD = 0x2 + IFA_F_OPTIMISTIC = 0x4 + IFA_F_PERMANENT = 0x80 + IFA_F_SECONDARY = 0x1 + IFA_F_TEMPORARY = 0x1 + IFA_F_TENTATIVE = 0x40 + IFA_MAX = 0x7 + IFF_802_1Q_VLAN = 0x1 + IFF_ALLMULTI = 0x200 + IFF_AUTOMEDIA = 0x4000 + IFF_BONDING = 0x20 + IFF_BRIDGE_PORT = 0x4000 + IFF_BROADCAST = 0x2 + IFF_DEBUG = 0x4 + IFF_DISABLE_NETPOLL = 0x1000 + IFF_DONT_BRIDGE = 0x800 + IFF_DORMANT = 0x20000 + IFF_DYNAMIC = 0x8000 + IFF_EBRIDGE = 0x2 + IFF_ECHO = 0x40000 + IFF_ISATAP = 0x80 + IFF_LOOPBACK = 0x8 + IFF_LOWER_UP = 0x10000 + IFF_MACVLAN_PORT = 0x2000 + IFF_MASTER = 0x400 + IFF_MASTER_8023AD = 0x8 + IFF_MASTER_ALB = 0x10 + IFF_MASTER_ARPMON = 0x100 + IFF_MULTICAST = 0x1000 + IFF_NOARP = 0x80 + IFF_NOTRAILERS = 0x20 + IFF_NO_PI = 0x1000 + IFF_ONE_QUEUE = 0x2000 + IFF_OVS_DATAPATH = 0x8000 + IFF_POINTOPOINT = 0x10 + IFF_PORTSEL = 0x2000 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SLAVE = 0x800 + IFF_SLAVE_INACTIVE = 0x4 + IFF_SLAVE_NEEDARP = 0x40 + IFF_TAP = 0x2 + IFF_TUN = 0x1 + IFF_TUN_EXCL = 0x8000 + IFF_TX_SKB_SHARING = 0x10000 + IFF_UNICAST_FLT = 0x20000 + IFF_UP = 0x1 + IFF_VNET_HDR = 0x4000 + IFF_VOLATILE = 0x70c5a + IFF_WAN_HDLC = 0x200 + IFF_XMIT_DST_RELEASE = 0x400 + IFNAMSIZ = 0x10 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_ACCESS = 0x1 + IN_ALL_EVENTS = 0xfff + IN_ATTRIB = 0x4 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLOEXEC = 0x80000 + IN_CLOSE = 0x18 + IN_CLOSE_NOWRITE = 0x10 + IN_CLOSE_WRITE = 0x8 + IN_CREATE = 0x100 + IN_DELETE = 0x200 + IN_DELETE_SELF = 0x400 + IN_DONT_FOLLOW = 0x2000000 + IN_EXCL_UNLINK = 0x4000000 + IN_IGNORED = 0x8000 + IN_ISDIR = 0x40000000 + IN_LOOPBACKNET = 0x7f + IN_MASK_ADD = 0x20000000 + IN_MODIFY = 0x2 + IN_MOVE = 0xc0 + IN_MOVED_FROM = 0x40 + IN_MOVED_TO = 0x80 + IN_MOVE_SELF = 0x800 + IN_NONBLOCK = 0x800 + IN_ONESHOT = 0x80000000 + IN_ONLYDIR = 0x1000000 + IN_OPEN = 0x20 + IN_Q_OVERFLOW = 0x4000 + IN_UNMOUNT = 0x2000 + IPPROTO_AH = 0x33 + IPPROTO_COMP = 0x6c + IPPROTO_DCCP = 0x21 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_ENCAP = 0x62 + IPPROTO_ESP = 0x32 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GRE = 0x2f + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IGMP = 0x2 + IPPROTO_IP = 0x0 + IPPROTO_IPIP = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_MTP = 0x5c + IPPROTO_NONE = 0x3b + IPPROTO_PIM = 0x67 + IPPROTO_PUP = 0xc + IPPROTO_RAW = 0xff + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_SCTP = 0x84 + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_UDP = 0x11 + IPPROTO_UDPLITE = 0x88 + IPV6_2292DSTOPTS = 0x4 + IPV6_2292HOPLIMIT = 0x8 + IPV6_2292HOPOPTS = 0x3 + IPV6_2292PKTINFO = 0x2 + IPV6_2292PKTOPTIONS = 0x6 + IPV6_2292RTHDR = 0x5 + IPV6_ADDRFORM = 0x1 + IPV6_ADD_MEMBERSHIP = 0x14 + IPV6_AUTHHDR = 0xa + IPV6_CHECKSUM = 0x7 + IPV6_DROP_MEMBERSHIP = 0x15 + IPV6_DSTOPTS = 0x3b + IPV6_HOPLIMIT = 0x34 + IPV6_HOPOPTS = 0x36 + IPV6_IPSEC_POLICY = 0x22 + IPV6_JOIN_ANYCAST = 0x1b + IPV6_JOIN_GROUP = 0x14 + IPV6_LEAVE_ANYCAST = 0x1c + IPV6_LEAVE_GROUP = 0x15 + IPV6_MTU = 0x18 + IPV6_MTU_DISCOVER = 0x17 + IPV6_MULTICAST_HOPS = 0x12 + IPV6_MULTICAST_IF = 0x11 + IPV6_MULTICAST_LOOP = 0x13 + IPV6_NEXTHOP = 0x9 + IPV6_PKTINFO = 0x32 + IPV6_PMTUDISC_DO = 0x2 + IPV6_PMTUDISC_DONT = 0x0 + IPV6_PMTUDISC_PROBE = 0x3 + IPV6_PMTUDISC_WANT = 0x1 + IPV6_RECVDSTOPTS = 0x3a + IPV6_RECVERR = 0x19 + IPV6_RECVHOPLIMIT = 0x33 + IPV6_RECVHOPOPTS = 0x35 + IPV6_RECVPKTINFO = 0x31 + IPV6_RECVRTHDR = 0x38 + IPV6_RECVTCLASS = 0x42 + IPV6_ROUTER_ALERT = 0x16 + IPV6_RTHDR = 0x39 + IPV6_RTHDRDSTOPTS = 0x37 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_RXDSTOPTS = 0x3b + IPV6_RXHOPOPTS = 0x36 + IPV6_TCLASS = 0x43 + IPV6_UNICAST_HOPS = 0x10 + IPV6_V6ONLY = 0x1a + IPV6_XFRM_POLICY = 0x23 + IP_ADD_MEMBERSHIP = 0x23 + IP_ADD_SOURCE_MEMBERSHIP = 0x27 + IP_BLOCK_SOURCE = 0x26 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DROP_MEMBERSHIP = 0x24 + IP_DROP_SOURCE_MEMBERSHIP = 0x28 + IP_FREEBIND = 0xf + IP_HDRINCL = 0x3 + IP_IPSEC_POLICY = 0x10 + IP_MAXPACKET = 0xffff + IP_MAX_MEMBERSHIPS = 0x14 + IP_MF = 0x2000 + IP_MINTTL = 0x15 + IP_MSFILTER = 0x29 + IP_MSS = 0x240 + IP_MTU = 0xe + IP_MTU_DISCOVER = 0xa + IP_MULTICAST_ALL = 0x31 + IP_MULTICAST_IF = 0x20 + IP_MULTICAST_LOOP = 0x22 + IP_MULTICAST_TTL = 0x21 + IP_OFFMASK = 0x1fff + IP_OPTIONS = 0x4 + IP_ORIGDSTADDR = 0x14 + IP_PASSSEC = 0x12 + IP_PKTINFO = 0x8 + IP_PKTOPTIONS = 0x9 + IP_PMTUDISC = 0xa + IP_PMTUDISC_DO = 0x2 + IP_PMTUDISC_DONT = 0x0 + IP_PMTUDISC_PROBE = 0x3 + IP_PMTUDISC_WANT = 0x1 + IP_RECVERR = 0xb + IP_RECVOPTS = 0x6 + IP_RECVORIGDSTADDR = 0x14 + IP_RECVRETOPTS = 0x7 + IP_RECVTOS = 0xd + IP_RECVTTL = 0xc + IP_RETOPTS = 0x7 + IP_RF = 0x8000 + IP_ROUTER_ALERT = 0x5 + IP_TOS = 0x1 + IP_TRANSPARENT = 0x13 + IP_TTL = 0x2 + IP_UNBLOCK_SOURCE = 0x25 + IP_XFRM_POLICY = 0x11 + ISIG = 0x1 + ISTRIP = 0x20 + IUCLC = 0x200 + IUTF8 = 0x4000 + IXANY = 0x800 + IXOFF = 0x1000 + IXON = 0x400 + LINUX_REBOOT_CMD_CAD_OFF = 0x0 + LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef + LINUX_REBOOT_CMD_HALT = 0xcdef0123 + LINUX_REBOOT_CMD_KEXEC = 0x45584543 + LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc + LINUX_REBOOT_CMD_RESTART = 0x1234567 + LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4 + LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2 + LINUX_REBOOT_MAGIC1 = 0xfee1dead + LINUX_REBOOT_MAGIC2 = 0x28121969 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_DOFORK = 0xb + MADV_DONTFORK = 0xa + MADV_DONTNEED = 0x4 + MADV_HUGEPAGE = 0xe + MADV_HWPOISON = 0x64 + MADV_MERGEABLE = 0xc + MADV_NOHUGEPAGE = 0xf + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_REMOVE = 0x9 + MADV_SEQUENTIAL = 0x2 + MADV_UNMERGEABLE = 0xd + MADV_WILLNEED = 0x3 + MAP_32BIT = 0x40 + MAP_ANON = 0x20 + MAP_ANONYMOUS = 0x20 + MAP_DENYWRITE = 0x800 + MAP_EXECUTABLE = 0x1000 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_GROWSDOWN = 0x100 + MAP_HUGETLB = 0x40000 + MAP_LOCKED = 0x2000 + MAP_NONBLOCK = 0x10000 + MAP_NORESERVE = 0x4000 + MAP_POPULATE = 0x8000 + MAP_PRIVATE = 0x2 + MAP_SHARED = 0x1 + MAP_STACK = 0x20000 + MAP_TYPE = 0xf + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MNT_DETACH = 0x2 + MNT_EXPIRE = 0x4 + MNT_FORCE = 0x1 + MSG_CMSG_CLOEXEC = 0x40000000 + MSG_CONFIRM = 0x800 + MSG_CTRUNC = 0x8 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x40 + MSG_EOR = 0x80 + MSG_ERRQUEUE = 0x2000 + MSG_FASTOPEN = 0x20000000 + MSG_FIN = 0x200 + MSG_MORE = 0x8000 + MSG_NOSIGNAL = 0x4000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_PROXY = 0x10 + MSG_RST = 0x1000 + MSG_SYN = 0x400 + MSG_TRUNC = 0x20 + MSG_TRYHARD = 0x4 + MSG_WAITALL = 0x100 + MSG_WAITFORONE = 0x10000 + MS_ACTIVE = 0x40000000 + MS_ASYNC = 0x1 + MS_BIND = 0x1000 + MS_DIRSYNC = 0x80 + MS_INVALIDATE = 0x2 + MS_I_VERSION = 0x800000 + MS_KERNMOUNT = 0x400000 + MS_MANDLOCK = 0x40 + MS_MGC_MSK = 0xffff0000 + MS_MGC_VAL = 0xc0ed0000 + MS_MOVE = 0x2000 + MS_NOATIME = 0x400 + MS_NODEV = 0x4 + MS_NODIRATIME = 0x800 + MS_NOEXEC = 0x8 + MS_NOSUID = 0x2 + MS_NOUSER = -0x80000000 + MS_POSIXACL = 0x10000 + MS_PRIVATE = 0x40000 + MS_RDONLY = 0x1 + MS_REC = 0x4000 + MS_RELATIME = 0x200000 + MS_REMOUNT = 0x20 + MS_RMT_MASK = 0x800051 + MS_SHARED = 0x100000 + MS_SILENT = 0x8000 + MS_SLAVE = 0x80000 + MS_STRICTATIME = 0x1000000 + MS_SYNC = 0x4 + MS_SYNCHRONOUS = 0x10 + MS_UNBINDABLE = 0x20000 + NAME_MAX = 0xff + NETLINK_ADD_MEMBERSHIP = 0x1 + NETLINK_AUDIT = 0x9 + NETLINK_BROADCAST_ERROR = 0x4 + NETLINK_CONNECTOR = 0xb + NETLINK_CRYPTO = 0x15 + NETLINK_DNRTMSG = 0xe + NETLINK_DROP_MEMBERSHIP = 0x2 + NETLINK_ECRYPTFS = 0x13 + NETLINK_FIB_LOOKUP = 0xa + NETLINK_FIREWALL = 0x3 + NETLINK_GENERIC = 0x10 + NETLINK_INET_DIAG = 0x4 + NETLINK_IP6_FW = 0xd + NETLINK_ISCSI = 0x8 + NETLINK_KOBJECT_UEVENT = 0xf + NETLINK_NETFILTER = 0xc + NETLINK_NFLOG = 0x5 + NETLINK_NO_ENOBUFS = 0x5 + NETLINK_PKTINFO = 0x3 + NETLINK_RDMA = 0x14 + NETLINK_ROUTE = 0x0 + NETLINK_SCSITRANSPORT = 0x12 + NETLINK_SELINUX = 0x7 + NETLINK_UNUSED = 0x1 + NETLINK_USERSOCK = 0x2 + NETLINK_XFRM = 0x6 + NL0 = 0x0 + NL1 = 0x100 + NLA_ALIGNTO = 0x4 + NLA_F_NESTED = 0x8000 + NLA_F_NET_BYTEORDER = 0x4000 + NLA_HDRLEN = 0x4 + NLDLY = 0x100 + NLMSG_ALIGNTO = 0x4 + NLMSG_DONE = 0x3 + NLMSG_ERROR = 0x2 + NLMSG_HDRLEN = 0x10 + NLMSG_MIN_TYPE = 0x10 + NLMSG_NOOP = 0x1 + NLMSG_OVERRUN = 0x4 + NLM_F_ACK = 0x4 + NLM_F_APPEND = 0x800 + NLM_F_ATOMIC = 0x400 + NLM_F_CREATE = 0x400 + NLM_F_DUMP = 0x300 + NLM_F_DUMP_INTR = 0x10 + NLM_F_ECHO = 0x8 + NLM_F_EXCL = 0x200 + NLM_F_MATCH = 0x200 + NLM_F_MULTI = 0x2 + NLM_F_REPLACE = 0x100 + NLM_F_REQUEST = 0x1 + NLM_F_ROOT = 0x100 + NOFLSH = 0x80 + OCRNL = 0x8 + OFDEL = 0x80 + OFILL = 0x40 + OLCUC = 0x2 + ONLCR = 0x4 + ONLRET = 0x20 + ONOCR = 0x10 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_APPEND = 0x400 + O_ASYNC = 0x2000 + O_CLOEXEC = 0x80000 + O_CREAT = 0x40 + O_DIRECT = 0x4000 + O_DIRECTORY = 0x10000 + O_DSYNC = 0x1000 + O_EXCL = 0x80 + O_FSYNC = 0x101000 + O_LARGEFILE = 0x0 + O_NDELAY = 0x800 + O_NOATIME = 0x40000 + O_NOCTTY = 0x100 + O_NOFOLLOW = 0x20000 + O_NONBLOCK = 0x800 + O_PATH = 0x200000 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_RSYNC = 0x101000 + O_SYNC = 0x101000 + O_TMPFILE = 0x410000 + O_TRUNC = 0x200 + O_WRONLY = 0x1 + PACKET_ADD_MEMBERSHIP = 0x1 + PACKET_AUXDATA = 0x8 + PACKET_BROADCAST = 0x1 + PACKET_COPY_THRESH = 0x7 + PACKET_DROP_MEMBERSHIP = 0x2 + PACKET_FANOUT = 0x12 + PACKET_FANOUT_CPU = 0x2 + PACKET_FANOUT_FLAG_DEFRAG = 0x8000 + PACKET_FANOUT_HASH = 0x0 + PACKET_FANOUT_LB = 0x1 + PACKET_FASTROUTE = 0x6 + PACKET_HDRLEN = 0xb + PACKET_HOST = 0x0 + PACKET_LOOPBACK = 0x5 + PACKET_LOSS = 0xe + PACKET_MR_ALLMULTI = 0x2 + PACKET_MR_MULTICAST = 0x0 + PACKET_MR_PROMISC = 0x1 + PACKET_MR_UNICAST = 0x3 + PACKET_MULTICAST = 0x2 + PACKET_ORIGDEV = 0x9 + PACKET_OTHERHOST = 0x3 + PACKET_OUTGOING = 0x4 + PACKET_RECV_OUTPUT = 0x3 + PACKET_RESERVE = 0xc + PACKET_RX_RING = 0x5 + PACKET_STATISTICS = 0x6 + PACKET_TIMESTAMP = 0x11 + PACKET_TX_RING = 0xd + PACKET_TX_TIMESTAMP = 0x10 + PACKET_VERSION = 0xa + PACKET_VNET_HDR = 0xf + PARENB = 0x100 + PARITY_CRC16_PR0 = 0x2 + PARITY_CRC16_PR0_CCITT = 0x4 + PARITY_CRC16_PR1 = 0x3 + PARITY_CRC16_PR1_CCITT = 0x5 + PARITY_CRC32_PR0_CCITT = 0x6 + PARITY_CRC32_PR1_CCITT = 0x7 + PARITY_DEFAULT = 0x0 + PARITY_NONE = 0x1 + PARMRK = 0x8 + PARODD = 0x200 + PENDIN = 0x4000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_GROWSDOWN = 0x1000000 + PROT_GROWSUP = 0x2000000 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + PR_CAPBSET_DROP = 0x18 + PR_CAPBSET_READ = 0x17 + PR_ENDIAN_BIG = 0x0 + PR_ENDIAN_LITTLE = 0x1 + PR_ENDIAN_PPC_LITTLE = 0x2 + PR_FPEMU_NOPRINT = 0x1 + PR_FPEMU_SIGFPE = 0x2 + PR_FP_EXC_ASYNC = 0x2 + PR_FP_EXC_DISABLED = 0x0 + PR_FP_EXC_DIV = 0x10000 + PR_FP_EXC_INV = 0x100000 + PR_FP_EXC_NONRECOV = 0x1 + PR_FP_EXC_OVF = 0x20000 + PR_FP_EXC_PRECISE = 0x3 + PR_FP_EXC_RES = 0x80000 + PR_FP_EXC_SW_ENABLE = 0x80 + PR_FP_EXC_UND = 0x40000 + PR_GET_DUMPABLE = 0x3 + PR_GET_ENDIAN = 0x13 + PR_GET_FPEMU = 0x9 + PR_GET_FPEXC = 0xb + PR_GET_KEEPCAPS = 0x7 + PR_GET_NAME = 0x10 + PR_GET_NO_NEW_PRIVS = 0x27 + PR_GET_PDEATHSIG = 0x2 + PR_GET_SECCOMP = 0x15 + PR_GET_SECUREBITS = 0x1b + PR_GET_TIMERSLACK = 0x1e + PR_GET_TIMING = 0xd + PR_GET_TSC = 0x19 + PR_GET_UNALIGN = 0x5 + PR_MCE_KILL = 0x21 + PR_MCE_KILL_CLEAR = 0x0 + PR_MCE_KILL_DEFAULT = 0x2 + PR_MCE_KILL_EARLY = 0x1 + PR_MCE_KILL_GET = 0x22 + PR_MCE_KILL_LATE = 0x0 + PR_MCE_KILL_SET = 0x1 + PR_SET_DUMPABLE = 0x4 + PR_SET_ENDIAN = 0x14 + PR_SET_FPEMU = 0xa + PR_SET_FPEXC = 0xc + PR_SET_KEEPCAPS = 0x8 + PR_SET_MM = 0x23 + PR_SET_MM_BRK = 0x7 + PR_SET_MM_END_CODE = 0x2 + PR_SET_MM_END_DATA = 0x4 + PR_SET_MM_START_BRK = 0x6 + PR_SET_MM_START_CODE = 0x1 + PR_SET_MM_START_DATA = 0x3 + PR_SET_MM_START_STACK = 0x5 + PR_SET_NAME = 0xf + PR_SET_NO_NEW_PRIVS = 0x26 + PR_SET_PDEATHSIG = 0x1 + PR_SET_PTRACER = 0x59616d61 + PR_SET_PTRACER_ANY = -0x1 + PR_SET_SECCOMP = 0x16 + PR_SET_SECUREBITS = 0x1c + PR_SET_TIMERSLACK = 0x1d + PR_SET_TIMING = 0xe + PR_SET_TSC = 0x1a + PR_SET_UNALIGN = 0x6 + PR_TASK_PERF_EVENTS_DISABLE = 0x1f + PR_TASK_PERF_EVENTS_ENABLE = 0x20 + PR_TIMING_STATISTICAL = 0x0 + PR_TIMING_TIMESTAMP = 0x1 + PR_TSC_ENABLE = 0x1 + PR_TSC_SIGSEGV = 0x2 + PR_UNALIGN_NOPRINT = 0x1 + PR_UNALIGN_SIGBUS = 0x2 + PTRACE_ARCH_PRCTL = 0x1e + PTRACE_ATTACH = 0x10 + PTRACE_CONT = 0x7 + PTRACE_DETACH = 0x11 + PTRACE_EVENT_CLONE = 0x3 + PTRACE_EVENT_EXEC = 0x4 + PTRACE_EVENT_EXIT = 0x6 + PTRACE_EVENT_FORK = 0x1 + PTRACE_EVENT_SECCOMP = 0x7 + PTRACE_EVENT_STOP = 0x80 + PTRACE_EVENT_VFORK = 0x2 + PTRACE_EVENT_VFORK_DONE = 0x5 + PTRACE_GETEVENTMSG = 0x4201 + PTRACE_GETFPREGS = 0xe + PTRACE_GETFPXREGS = 0x12 + PTRACE_GETREGS = 0xc + PTRACE_GETREGSET = 0x4204 + PTRACE_GETSIGINFO = 0x4202 + PTRACE_GET_THREAD_AREA = 0x19 + PTRACE_INTERRUPT = 0x4207 + PTRACE_KILL = 0x8 + PTRACE_LISTEN = 0x4208 + PTRACE_OLDSETOPTIONS = 0x15 + PTRACE_O_MASK = 0xff + PTRACE_O_TRACECLONE = 0x8 + PTRACE_O_TRACEEXEC = 0x10 + PTRACE_O_TRACEEXIT = 0x40 + PTRACE_O_TRACEFORK = 0x2 + PTRACE_O_TRACESECCOMP = 0x80 + PTRACE_O_TRACESYSGOOD = 0x1 + PTRACE_O_TRACEVFORK = 0x4 + PTRACE_O_TRACEVFORKDONE = 0x20 + PTRACE_PEEKDATA = 0x2 + PTRACE_PEEKTEXT = 0x1 + PTRACE_PEEKUSR = 0x3 + PTRACE_POKEDATA = 0x5 + PTRACE_POKETEXT = 0x4 + PTRACE_POKEUSR = 0x6 + PTRACE_SEIZE = 0x4206 + PTRACE_SEIZE_DEVEL = 0x80000000 + PTRACE_SETFPREGS = 0xf + PTRACE_SETFPXREGS = 0x13 + PTRACE_SETOPTIONS = 0x4200 + PTRACE_SETREGS = 0xd + PTRACE_SETREGSET = 0x4205 + PTRACE_SETSIGINFO = 0x4203 + PTRACE_SET_THREAD_AREA = 0x1a + PTRACE_SINGLEBLOCK = 0x21 + PTRACE_SINGLESTEP = 0x9 + PTRACE_SYSCALL = 0x18 + PTRACE_SYSEMU = 0x1f + PTRACE_SYSEMU_SINGLESTEP = 0x20 + PTRACE_TRACEME = 0x0 + RLIMIT_AS = 0x9 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x7 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = -0x1 + RTAX_ADVMSS = 0x8 + RTAX_CWND = 0x7 + RTAX_FEATURES = 0xc + RTAX_FEATURE_ALLFRAG = 0x8 + RTAX_FEATURE_ECN = 0x1 + RTAX_FEATURE_SACK = 0x2 + RTAX_FEATURE_TIMESTAMP = 0x4 + RTAX_HOPLIMIT = 0xa + RTAX_INITCWND = 0xb + RTAX_INITRWND = 0xe + RTAX_LOCK = 0x1 + RTAX_MAX = 0xe + RTAX_MTU = 0x2 + RTAX_REORDERING = 0x9 + RTAX_RTO_MIN = 0xd + RTAX_RTT = 0x4 + RTAX_RTTVAR = 0x5 + RTAX_SSTHRESH = 0x6 + RTAX_UNSPEC = 0x0 + RTAX_WINDOW = 0x3 + RTA_ALIGNTO = 0x4 + RTA_MAX = 0x10 + RTCF_DIRECTSRC = 0x4000000 + RTCF_DOREDIRECT = 0x1000000 + RTCF_LOG = 0x2000000 + RTCF_MASQ = 0x400000 + RTCF_NAT = 0x800000 + RTCF_VALVE = 0x200000 + RTF_ADDRCLASSMASK = 0xf8000000 + RTF_ADDRCONF = 0x40000 + RTF_ALLONLINK = 0x20000 + RTF_BROADCAST = 0x10000000 + RTF_CACHE = 0x1000000 + RTF_DEFAULT = 0x10000 + RTF_DYNAMIC = 0x10 + RTF_FLOW = 0x2000000 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_INTERFACE = 0x40000000 + RTF_IRTT = 0x100 + RTF_LINKRT = 0x100000 + RTF_LOCAL = 0x80000000 + RTF_MODIFIED = 0x20 + RTF_MSS = 0x40 + RTF_MTU = 0x40 + RTF_MULTICAST = 0x20000000 + RTF_NAT = 0x8000000 + RTF_NOFORWARD = 0x1000 + RTF_NONEXTHOP = 0x200000 + RTF_NOPMTUDISC = 0x4000 + RTF_POLICY = 0x4000000 + RTF_REINSTATE = 0x8 + RTF_REJECT = 0x200 + RTF_STATIC = 0x400 + RTF_THROW = 0x2000 + RTF_UP = 0x1 + RTF_WINDOW = 0x80 + RTF_XRESOLVE = 0x800 + RTM_BASE = 0x10 + RTM_DELACTION = 0x31 + RTM_DELADDR = 0x15 + RTM_DELADDRLABEL = 0x49 + RTM_DELLINK = 0x11 + RTM_DELNEIGH = 0x1d + RTM_DELQDISC = 0x25 + RTM_DELROUTE = 0x19 + RTM_DELRULE = 0x21 + RTM_DELTCLASS = 0x29 + RTM_DELTFILTER = 0x2d + RTM_F_CLONED = 0x200 + RTM_F_EQUALIZE = 0x400 + RTM_F_NOTIFY = 0x100 + RTM_F_PREFIX = 0x800 + RTM_GETACTION = 0x32 + RTM_GETADDR = 0x16 + RTM_GETADDRLABEL = 0x4a + RTM_GETANYCAST = 0x3e + RTM_GETDCB = 0x4e + RTM_GETLINK = 0x12 + RTM_GETMULTICAST = 0x3a + RTM_GETNEIGH = 0x1e + RTM_GETNEIGHTBL = 0x42 + RTM_GETQDISC = 0x26 + RTM_GETROUTE = 0x1a + RTM_GETRULE = 0x22 + RTM_GETTCLASS = 0x2a + RTM_GETTFILTER = 0x2e + RTM_MAX = 0x4f + RTM_NEWACTION = 0x30 + RTM_NEWADDR = 0x14 + RTM_NEWADDRLABEL = 0x48 + RTM_NEWLINK = 0x10 + RTM_NEWNDUSEROPT = 0x44 + RTM_NEWNEIGH = 0x1c + RTM_NEWNEIGHTBL = 0x40 + RTM_NEWPREFIX = 0x34 + RTM_NEWQDISC = 0x24 + RTM_NEWROUTE = 0x18 + RTM_NEWRULE = 0x20 + RTM_NEWTCLASS = 0x28 + RTM_NEWTFILTER = 0x2c + RTM_NR_FAMILIES = 0x10 + RTM_NR_MSGTYPES = 0x40 + RTM_SETDCB = 0x4f + RTM_SETLINK = 0x13 + RTM_SETNEIGHTBL = 0x43 + RTNH_ALIGNTO = 0x4 + RTNH_F_DEAD = 0x1 + RTNH_F_ONLINK = 0x4 + RTNH_F_PERVASIVE = 0x2 + RTN_MAX = 0xb + RTPROT_BIRD = 0xc + RTPROT_BOOT = 0x3 + RTPROT_DHCP = 0x10 + RTPROT_DNROUTED = 0xd + RTPROT_GATED = 0x8 + RTPROT_KERNEL = 0x2 + RTPROT_MRT = 0xa + RTPROT_NTK = 0xf + RTPROT_RA = 0x9 + RTPROT_REDIRECT = 0x1 + RTPROT_STATIC = 0x4 + RTPROT_UNSPEC = 0x0 + RTPROT_XORP = 0xe + RTPROT_ZEBRA = 0xb + RT_CLASS_DEFAULT = 0xfd + RT_CLASS_LOCAL = 0xff + RT_CLASS_MAIN = 0xfe + RT_CLASS_MAX = 0xff + RT_CLASS_UNSPEC = 0x0 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + RUSAGE_THREAD = 0x1 + SCM_CREDENTIALS = 0x2 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x1d + SCM_TIMESTAMPING = 0x25 + SCM_TIMESTAMPNS = 0x23 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDDLCI = 0x8980 + SIOCADDMULTI = 0x8931 + SIOCADDRT = 0x890b + SIOCATMARK = 0x8905 + SIOCDARP = 0x8953 + SIOCDELDLCI = 0x8981 + SIOCDELMULTI = 0x8932 + SIOCDELRT = 0x890c + SIOCDEVPRIVATE = 0x89f0 + SIOCDIFADDR = 0x8936 + SIOCDRARP = 0x8960 + SIOCGARP = 0x8954 + SIOCGIFADDR = 0x8915 + SIOCGIFBR = 0x8940 + SIOCGIFBRDADDR = 0x8919 + SIOCGIFCONF = 0x8912 + SIOCGIFCOUNT = 0x8938 + SIOCGIFDSTADDR = 0x8917 + SIOCGIFENCAP = 0x8925 + SIOCGIFFLAGS = 0x8913 + SIOCGIFHWADDR = 0x8927 + SIOCGIFINDEX = 0x8933 + SIOCGIFMAP = 0x8970 + SIOCGIFMEM = 0x891f + SIOCGIFMETRIC = 0x891d + SIOCGIFMTU = 0x8921 + SIOCGIFNAME = 0x8910 + SIOCGIFNETMASK = 0x891b + SIOCGIFPFLAGS = 0x8935 + SIOCGIFSLAVE = 0x8929 + SIOCGIFTXQLEN = 0x8942 + SIOCGPGRP = 0x8904 + SIOCGRARP = 0x8961 + SIOCGSTAMP = 0x8906 + SIOCGSTAMPNS = 0x8907 + SIOCPROTOPRIVATE = 0x89e0 + SIOCRTMSG = 0x890d + SIOCSARP = 0x8955 + SIOCSIFADDR = 0x8916 + SIOCSIFBR = 0x8941 + SIOCSIFBRDADDR = 0x891a + SIOCSIFDSTADDR = 0x8918 + SIOCSIFENCAP = 0x8926 + SIOCSIFFLAGS = 0x8914 + SIOCSIFHWADDR = 0x8924 + SIOCSIFHWBROADCAST = 0x8937 + SIOCSIFLINK = 0x8911 + SIOCSIFMAP = 0x8971 + SIOCSIFMEM = 0x8920 + SIOCSIFMETRIC = 0x891e + SIOCSIFMTU = 0x8922 + SIOCSIFNAME = 0x8923 + SIOCSIFNETMASK = 0x891c + SIOCSIFPFLAGS = 0x8934 + SIOCSIFSLAVE = 0x8930 + SIOCSIFTXQLEN = 0x8943 + SIOCSPGRP = 0x8902 + SIOCSRARP = 0x8962 + SOCK_CLOEXEC = 0x80000 + SOCK_DCCP = 0x6 + SOCK_DGRAM = 0x2 + SOCK_NONBLOCK = 0x800 + SOCK_PACKET = 0xa + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_AAL = 0x109 + SOL_ATM = 0x108 + SOL_DECNET = 0x105 + SOL_ICMPV6 = 0x3a + SOL_IP = 0x0 + SOL_IPV6 = 0x29 + SOL_IRDA = 0x10a + SOL_PACKET = 0x107 + SOL_RAW = 0xff + SOL_SOCKET = 0x1 + SOL_TCP = 0x6 + SOL_X25 = 0x106 + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x1e + SO_ATTACH_FILTER = 0x1a + SO_BINDTODEVICE = 0x19 + SO_BROADCAST = 0x6 + SO_BSDCOMPAT = 0xe + SO_DEBUG = 0x1 + SO_DETACH_FILTER = 0x1b + SO_DOMAIN = 0x27 + SO_DONTROUTE = 0x5 + SO_ERROR = 0x4 + SO_KEEPALIVE = 0x9 + SO_LINGER = 0xd + SO_MARK = 0x24 + SO_NO_CHECK = 0xb + SO_OOBINLINE = 0xa + SO_PASSCRED = 0x10 + SO_PASSSEC = 0x22 + SO_PEERCRED = 0x11 + SO_PEERNAME = 0x1c + SO_PEERSEC = 0x1f + SO_PRIORITY = 0xc + SO_PROTOCOL = 0x26 + SO_RCVBUF = 0x8 + SO_RCVBUFFORCE = 0x21 + SO_RCVLOWAT = 0x12 + SO_RCVTIMEO = 0x14 + SO_REUSEADDR = 0x2 + SO_RXQ_OVFL = 0x28 + SO_SECURITY_AUTHENTICATION = 0x16 + SO_SECURITY_ENCRYPTION_NETWORK = 0x18 + SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17 + SO_SNDBUF = 0x7 + SO_SNDBUFFORCE = 0x20 + SO_SNDLOWAT = 0x13 + SO_SNDTIMEO = 0x15 + SO_TIMESTAMP = 0x1d + SO_TIMESTAMPING = 0x25 + SO_TIMESTAMPNS = 0x23 + SO_TYPE = 0x3 + S_BLKSIZE = 0x200 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + TAB0 = 0x0 + TAB1 = 0x800 + TAB2 = 0x1000 + TAB3 = 0x1800 + TABDLY = 0x1800 + TCFLSH = 0x540b + TCGETA = 0x5405 + TCGETS = 0x5401 + TCGETS2 = 0x802c542a + TCGETX = 0x5432 + TCIFLUSH = 0x0 + TCIOFF = 0x2 + TCIOFLUSH = 0x2 + TCION = 0x3 + TCOFLUSH = 0x1 + TCOOFF = 0x0 + TCOON = 0x1 + TCP_CONGESTION = 0xd + TCP_CORK = 0x3 + TCP_DEFER_ACCEPT = 0x9 + TCP_INFO = 0xb + TCP_KEEPCNT = 0x6 + TCP_KEEPIDLE = 0x4 + TCP_KEEPINTVL = 0x5 + TCP_LINGER2 = 0x8 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0xe + TCP_MD5SIG_MAXKEYLEN = 0x50 + TCP_MSS = 0x200 + TCP_NODELAY = 0x1 + TCP_QUICKACK = 0xc + TCP_SYNCNT = 0x7 + TCP_WINDOW_CLAMP = 0xa + TCSAFLUSH = 0x2 + TCSBRK = 0x5409 + TCSBRKP = 0x5425 + TCSETA = 0x5406 + TCSETAF = 0x5408 + TCSETAW = 0x5407 + TCSETS = 0x5402 + TCSETS2 = 0x402c542b + TCSETSF = 0x5404 + TCSETSF2 = 0x402c542d + TCSETSW = 0x5403 + TCSETSW2 = 0x402c542c + TCSETX = 0x5433 + TCSETXF = 0x5434 + TCSETXW = 0x5435 + TCXONC = 0x540a + TIOCCBRK = 0x5428 + TIOCCONS = 0x541d + TIOCEXCL = 0x540c + TIOCGDEV = 0x80045432 + TIOCGETD = 0x5424 + TIOCGEXCL = 0x80045440 + TIOCGICOUNT = 0x545d + TIOCGLCKTRMIOS = 0x5456 + TIOCGPGRP = 0x540f + TIOCGPKT = 0x80045438 + TIOCGPTLCK = 0x80045439 + TIOCGPTN = 0x80045430 + TIOCGRS485 = 0x542e + TIOCGSERIAL = 0x541e + TIOCGSID = 0x5429 + TIOCGSOFTCAR = 0x5419 + TIOCGWINSZ = 0x5413 + TIOCINQ = 0x541b + TIOCLINUX = 0x541c + TIOCMBIC = 0x5417 + TIOCMBIS = 0x5416 + TIOCMGET = 0x5415 + TIOCMIWAIT = 0x545c + TIOCMSET = 0x5418 + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x5422 + TIOCNXCL = 0x540d + TIOCOUTQ = 0x5411 + TIOCPKT = 0x5420 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCSBRK = 0x5427 + TIOCSCTTY = 0x540e + TIOCSERCONFIG = 0x5453 + TIOCSERGETLSR = 0x5459 + TIOCSERGETMULTI = 0x545a + TIOCSERGSTRUCT = 0x5458 + TIOCSERGWILD = 0x5454 + TIOCSERSETMULTI = 0x545b + TIOCSERSWILD = 0x5455 + TIOCSER_TEMT = 0x1 + TIOCSETD = 0x5423 + TIOCSIG = 0x40045436 + TIOCSLCKTRMIOS = 0x5457 + TIOCSPGRP = 0x5410 + TIOCSPTLCK = 0x40045431 + TIOCSRS485 = 0x542f + TIOCSSERIAL = 0x541f + TIOCSSOFTCAR = 0x541a + TIOCSTI = 0x5412 + TIOCSWINSZ = 0x5414 + TIOCVHANGUP = 0x5437 + TOSTOP = 0x100 + TUNATTACHFILTER = 0x401054d5 + TUNDETACHFILTER = 0x401054d6 + TUNGETFEATURES = 0x800454cf + TUNGETIFF = 0x800454d2 + TUNGETSNDBUF = 0x800454d3 + TUNGETVNETHDRSZ = 0x800454d7 + TUNSETDEBUG = 0x400454c9 + TUNSETGROUP = 0x400454ce + TUNSETIFF = 0x400454ca + TUNSETLINK = 0x400454cd + TUNSETNOCSUM = 0x400454c8 + TUNSETOFFLOAD = 0x400454d0 + TUNSETOWNER = 0x400454cc + TUNSETPERSIST = 0x400454cb + TUNSETSNDBUF = 0x400454d4 + TUNSETTXFILTER = 0x400454d1 + TUNSETVNETHDRSZ = 0x400454d8 + VDISCARD = 0xd + VEOF = 0x4 + VEOL = 0xb + VEOL2 = 0x10 + VERASE = 0x2 + VINTR = 0x0 + VKILL = 0x3 + VLNEXT = 0xf + VMIN = 0x6 + VQUIT = 0x1 + VREPRINT = 0xc + VSTART = 0x8 + VSTOP = 0x9 + VSUSP = 0xa + VSWTC = 0x7 + VT0 = 0x0 + VT1 = 0x4000 + VTDLY = 0x4000 + VTIME = 0x5 + VWERASE = 0xe + WALL = 0x40000000 + WCLONE = 0x80000000 + WCONTINUED = 0x8 + WEXITED = 0x4 + WNOHANG = 0x1 + WNOTHREAD = 0x20000000 + WNOWAIT = 0x1000000 + WORDSIZE = 0x40 + WSTOPPED = 0x2 + WUNTRACED = 0x2 + XCASE = 0x4 + XTABS = 0x1800 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x62) + EADDRNOTAVAIL = syscall.Errno(0x63) + EADV = syscall.Errno(0x44) + EAFNOSUPPORT = syscall.Errno(0x61) + EAGAIN = syscall.Errno(0xb) + EALREADY = syscall.Errno(0x72) + EBADE = syscall.Errno(0x34) + EBADF = syscall.Errno(0x9) + EBADFD = syscall.Errno(0x4d) + EBADMSG = syscall.Errno(0x4a) + EBADR = syscall.Errno(0x35) + EBADRQC = syscall.Errno(0x38) + EBADSLT = syscall.Errno(0x39) + EBFONT = syscall.Errno(0x3b) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x7d) + ECHILD = syscall.Errno(0xa) + ECHRNG = syscall.Errno(0x2c) + ECOMM = syscall.Errno(0x46) + ECONNABORTED = syscall.Errno(0x67) + ECONNREFUSED = syscall.Errno(0x6f) + ECONNRESET = syscall.Errno(0x68) + EDEADLK = syscall.Errno(0x23) + EDEADLOCK = syscall.Errno(0x23) + EDESTADDRREQ = syscall.Errno(0x59) + EDOM = syscall.Errno(0x21) + EDOTDOT = syscall.Errno(0x49) + EDQUOT = syscall.Errno(0x7a) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EHOSTDOWN = syscall.Errno(0x70) + EHOSTUNREACH = syscall.Errno(0x71) + EHWPOISON = syscall.Errno(0x85) + EIDRM = syscall.Errno(0x2b) + EILSEQ = syscall.Errno(0x54) + EINPROGRESS = syscall.Errno(0x73) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x6a) + EISDIR = syscall.Errno(0x15) + EISNAM = syscall.Errno(0x78) + EKEYEXPIRED = syscall.Errno(0x7f) + EKEYREJECTED = syscall.Errno(0x81) + EKEYREVOKED = syscall.Errno(0x80) + EL2HLT = syscall.Errno(0x33) + EL2NSYNC = syscall.Errno(0x2d) + EL3HLT = syscall.Errno(0x2e) + EL3RST = syscall.Errno(0x2f) + ELIBACC = syscall.Errno(0x4f) + ELIBBAD = syscall.Errno(0x50) + ELIBEXEC = syscall.Errno(0x53) + ELIBMAX = syscall.Errno(0x52) + ELIBSCN = syscall.Errno(0x51) + ELNRNG = syscall.Errno(0x30) + ELOOP = syscall.Errno(0x28) + EMEDIUMTYPE = syscall.Errno(0x7c) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x5a) + EMULTIHOP = syscall.Errno(0x48) + ENAMETOOLONG = syscall.Errno(0x24) + ENAVAIL = syscall.Errno(0x77) + ENETDOWN = syscall.Errno(0x64) + ENETRESET = syscall.Errno(0x66) + ENETUNREACH = syscall.Errno(0x65) + ENFILE = syscall.Errno(0x17) + ENOANO = syscall.Errno(0x37) + ENOBUFS = syscall.Errno(0x69) + ENOCSI = syscall.Errno(0x32) + ENODATA = syscall.Errno(0x3d) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOKEY = syscall.Errno(0x7e) + ENOLCK = syscall.Errno(0x25) + ENOLINK = syscall.Errno(0x43) + ENOMEDIUM = syscall.Errno(0x7b) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x2a) + ENONET = syscall.Errno(0x40) + ENOPKG = syscall.Errno(0x41) + ENOPROTOOPT = syscall.Errno(0x5c) + ENOSPC = syscall.Errno(0x1c) + ENOSR = syscall.Errno(0x3f) + ENOSTR = syscall.Errno(0x3c) + ENOSYS = syscall.Errno(0x26) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x6b) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x27) + ENOTNAM = syscall.Errno(0x76) + ENOTRECOVERABLE = syscall.Errno(0x83) + ENOTSOCK = syscall.Errno(0x58) + ENOTSUP = syscall.Errno(0x5f) + ENOTTY = syscall.Errno(0x19) + ENOTUNIQ = syscall.Errno(0x4c) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x5f) + EOVERFLOW = syscall.Errno(0x4b) + EOWNERDEAD = syscall.Errno(0x82) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x60) + EPIPE = syscall.Errno(0x20) + EPROTO = syscall.Errno(0x47) + EPROTONOSUPPORT = syscall.Errno(0x5d) + EPROTOTYPE = syscall.Errno(0x5b) + ERANGE = syscall.Errno(0x22) + EREMCHG = syscall.Errno(0x4e) + EREMOTE = syscall.Errno(0x42) + EREMOTEIO = syscall.Errno(0x79) + ERESTART = syscall.Errno(0x55) + ERFKILL = syscall.Errno(0x84) + EROFS = syscall.Errno(0x1e) + ESHUTDOWN = syscall.Errno(0x6c) + ESOCKTNOSUPPORT = syscall.Errno(0x5e) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESRMNT = syscall.Errno(0x45) + ESTALE = syscall.Errno(0x74) + ESTRPIPE = syscall.Errno(0x56) + ETIME = syscall.Errno(0x3e) + ETIMEDOUT = syscall.Errno(0x6e) + ETOOMANYREFS = syscall.Errno(0x6d) + ETXTBSY = syscall.Errno(0x1a) + EUCLEAN = syscall.Errno(0x75) + EUNATCH = syscall.Errno(0x31) + EUSERS = syscall.Errno(0x57) + EWOULDBLOCK = syscall.Errno(0xb) + EXDEV = syscall.Errno(0x12) + EXFULL = syscall.Errno(0x36) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0x7) + SIGCHLD = syscall.Signal(0x11) + SIGCLD = syscall.Signal(0x11) + SIGCONT = syscall.Signal(0x12) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x1d) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPOLL = syscall.Signal(0x1d) + SIGPROF = syscall.Signal(0x1b) + SIGPWR = syscall.Signal(0x1e) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTKFLT = syscall.Signal(0x10) + SIGSTOP = syscall.Signal(0x13) + SIGSYS = syscall.Signal(0x1f) + SIGTERM = syscall.Signal(0xf) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x14) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGUNUSED = syscall.Signal(0x1f) + SIGURG = syscall.Signal(0x17) + SIGUSR1 = syscall.Signal(0xa) + SIGUSR2 = syscall.Signal(0xc) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "no such device or address", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource temporarily unavailable", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device or resource busy", + 17: "file exists", + 18: "invalid cross-device link", + 19: "no such device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "numerical result out of range", + 35: "resource deadlock avoided", + 36: "file name too long", + 37: "no locks available", + 38: "function not implemented", + 39: "directory not empty", + 40: "too many levels of symbolic links", + 42: "no message of desired type", + 43: "identifier removed", + 44: "channel number out of range", + 45: "level 2 not synchronized", + 46: "level 3 halted", + 47: "level 3 reset", + 48: "link number out of range", + 49: "protocol driver not attached", + 50: "no CSI structure available", + 51: "level 2 halted", + 52: "invalid exchange", + 53: "invalid request descriptor", + 54: "exchange full", + 55: "no anode", + 56: "invalid request code", + 57: "invalid slot", + 59: "bad font file format", + 60: "device not a stream", + 61: "no data available", + 62: "timer expired", + 63: "out of streams resources", + 64: "machine is not on the network", + 65: "package not installed", + 66: "object is remote", + 67: "link has been severed", + 68: "advertise error", + 69: "srmount error", + 70: "communication error on send", + 71: "protocol error", + 72: "multihop attempted", + 73: "RFS specific error", + 74: "bad message", + 75: "value too large for defined data type", + 76: "name not unique on network", + 77: "file descriptor in bad state", + 78: "remote address changed", + 79: "can not access a needed shared library", + 80: "accessing a corrupted shared library", + 81: ".lib section in a.out corrupted", + 82: "attempting to link in too many shared libraries", + 83: "cannot exec a shared library directly", + 84: "invalid or incomplete multibyte or wide character", + 85: "interrupted system call should be restarted", + 86: "streams pipe error", + 87: "too many users", + 88: "socket operation on non-socket", + 89: "destination address required", + 90: "message too long", + 91: "protocol wrong type for socket", + 92: "protocol not available", + 93: "protocol not supported", + 94: "socket type not supported", + 95: "operation not supported", + 96: "protocol family not supported", + 97: "address family not supported by protocol", + 98: "address already in use", + 99: "cannot assign requested address", + 100: "network is down", + 101: "network is unreachable", + 102: "network dropped connection on reset", + 103: "software caused connection abort", + 104: "connection reset by peer", + 105: "no buffer space available", + 106: "transport endpoint is already connected", + 107: "transport endpoint is not connected", + 108: "cannot send after transport endpoint shutdown", + 109: "too many references: cannot splice", + 110: "connection timed out", + 111: "connection refused", + 112: "host is down", + 113: "no route to host", + 114: "operation already in progress", + 115: "operation now in progress", + 116: "stale NFS file handle", + 117: "structure needs cleaning", + 118: "not a XENIX named type file", + 119: "no XENIX semaphores available", + 120: "is a named type file", + 121: "remote I/O error", + 122: "disk quota exceeded", + 123: "no medium found", + 124: "wrong medium type", + 125: "operation canceled", + 126: "required key not available", + 127: "key has expired", + 128: "key has been revoked", + 129: "key was rejected by service", + 130: "owner died", + 131: "state not recoverable", + 132: "operation not possible due to RF-kill", + 133: "unknown error 133", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/breakpoint trap", + 6: "aborted", + 7: "bus error", + 8: "floating point exception", + 9: "killed", + 10: "user defined signal 1", + 11: "segmentation fault", + 12: "user defined signal 2", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "stack fault", + 17: "child exited", + 18: "continued", + 19: "stopped (signal)", + 20: "stopped", + 21: "stopped (tty input)", + 22: "stopped (tty output)", + 23: "urgent I/O condition", + 24: "CPU time limit exceeded", + 25: "file size limit exceeded", + 26: "virtual timer expired", + 27: "profiling timer expired", + 28: "window changed", + 29: "I/O possible", + 30: "power failure", + 31: "bad system call", +} diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go new file mode 100644 index 0000000000..f036758f92 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -0,0 +1,1743 @@ +// mkerrors.sh +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build arm,linux + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- _const.go + +package unix + +import "syscall" + +const ( + AF_ALG = 0x26 + AF_APPLETALK = 0x5 + AF_ASH = 0x12 + AF_ATMPVC = 0x8 + AF_ATMSVC = 0x14 + AF_AX25 = 0x3 + AF_BLUETOOTH = 0x1f + AF_BRIDGE = 0x7 + AF_CAIF = 0x25 + AF_CAN = 0x1d + AF_DECnet = 0xc + AF_ECONET = 0x13 + AF_FILE = 0x1 + AF_IEEE802154 = 0x24 + AF_INET = 0x2 + AF_INET6 = 0xa + AF_IPX = 0x4 + AF_IRDA = 0x17 + AF_ISDN = 0x22 + AF_IUCV = 0x20 + AF_KEY = 0xf + AF_LLC = 0x1a + AF_LOCAL = 0x1 + AF_MAX = 0x27 + AF_NETBEUI = 0xd + AF_NETLINK = 0x10 + AF_NETROM = 0x6 + AF_PACKET = 0x11 + AF_PHONET = 0x23 + AF_PPPOX = 0x18 + AF_RDS = 0x15 + AF_ROSE = 0xb + AF_ROUTE = 0x10 + AF_RXRPC = 0x21 + AF_SECURITY = 0xe + AF_SNA = 0x16 + AF_TIPC = 0x1e + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_WANPIPE = 0x19 + AF_X25 = 0x9 + ARPHRD_ADAPT = 0x108 + ARPHRD_APPLETLK = 0x8 + ARPHRD_ARCNET = 0x7 + ARPHRD_ASH = 0x30d + ARPHRD_ATM = 0x13 + ARPHRD_AX25 = 0x3 + ARPHRD_BIF = 0x307 + ARPHRD_CHAOS = 0x5 + ARPHRD_CISCO = 0x201 + ARPHRD_CSLIP = 0x101 + ARPHRD_CSLIP6 = 0x103 + ARPHRD_DDCMP = 0x205 + ARPHRD_DLCI = 0xf + ARPHRD_ECONET = 0x30e + ARPHRD_EETHER = 0x2 + ARPHRD_ETHER = 0x1 + ARPHRD_EUI64 = 0x1b + ARPHRD_FCAL = 0x311 + ARPHRD_FCFABRIC = 0x313 + ARPHRD_FCPL = 0x312 + ARPHRD_FCPP = 0x310 + ARPHRD_FDDI = 0x306 + ARPHRD_FRAD = 0x302 + ARPHRD_HDLC = 0x201 + ARPHRD_HIPPI = 0x30c + ARPHRD_HWX25 = 0x110 + ARPHRD_IEEE1394 = 0x18 + ARPHRD_IEEE802 = 0x6 + ARPHRD_IEEE80211 = 0x321 + ARPHRD_IEEE80211_PRISM = 0x322 + ARPHRD_IEEE80211_RADIOTAP = 0x323 + ARPHRD_IEEE802154 = 0x324 + ARPHRD_IEEE802154_PHY = 0x325 + ARPHRD_IEEE802_TR = 0x320 + ARPHRD_INFINIBAND = 0x20 + ARPHRD_IPDDP = 0x309 + ARPHRD_IPGRE = 0x30a + ARPHRD_IRDA = 0x30f + ARPHRD_LAPB = 0x204 + ARPHRD_LOCALTLK = 0x305 + ARPHRD_LOOPBACK = 0x304 + ARPHRD_METRICOM = 0x17 + ARPHRD_NETROM = 0x0 + ARPHRD_NONE = 0xfffe + ARPHRD_PIMREG = 0x30b + ARPHRD_PPP = 0x200 + ARPHRD_PRONET = 0x4 + ARPHRD_RAWHDLC = 0x206 + ARPHRD_ROSE = 0x10e + ARPHRD_RSRVD = 0x104 + ARPHRD_SIT = 0x308 + ARPHRD_SKIP = 0x303 + ARPHRD_SLIP = 0x100 + ARPHRD_SLIP6 = 0x102 + ARPHRD_TUNNEL = 0x300 + ARPHRD_TUNNEL6 = 0x301 + ARPHRD_VOID = 0xffff + ARPHRD_X25 = 0x10f + B0 = 0x0 + B1000000 = 0x1008 + B110 = 0x3 + B115200 = 0x1002 + B1152000 = 0x1009 + B1200 = 0x9 + B134 = 0x4 + B150 = 0x5 + B1500000 = 0x100a + B1800 = 0xa + B19200 = 0xe + B200 = 0x6 + B2000000 = 0x100b + B230400 = 0x1003 + B2400 = 0xb + B2500000 = 0x100c + B300 = 0x7 + B3000000 = 0x100d + B3500000 = 0x100e + B38400 = 0xf + B4000000 = 0x100f + B460800 = 0x1004 + B4800 = 0xc + B50 = 0x1 + B500000 = 0x1005 + B57600 = 0x1001 + B576000 = 0x1006 + B600 = 0x8 + B75 = 0x2 + B921600 = 0x1007 + B9600 = 0xd + BOTHER = 0x1000 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXINSNS = 0x1000 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BRKINT = 0x2 + BS0 = 0x0 + BS1 = 0x2000 + BSDLY = 0x2000 + CBAUD = 0x100f + CBAUDEX = 0x1000 + CFLUSH = 0xf + CIBAUD = 0x100f0000 + CLOCAL = 0x800 + CLOCK_BOOTTIME = 0x7 + CLOCK_BOOTTIME_ALARM = 0x9 + CLOCK_DEFAULT = 0x0 + CLOCK_EXT = 0x1 + CLOCK_INT = 0x2 + CLOCK_MONOTONIC = 0x1 + CLOCK_MONOTONIC_COARSE = 0x6 + CLOCK_MONOTONIC_RAW = 0x4 + CLOCK_PROCESS_CPUTIME_ID = 0x2 + CLOCK_REALTIME = 0x0 + CLOCK_REALTIME_ALARM = 0x8 + CLOCK_REALTIME_COARSE = 0x5 + CLOCK_THREAD_CPUTIME_ID = 0x3 + CLOCK_TXFROMRX = 0x4 + CLOCK_TXINT = 0x3 + CLONE_CHILD_CLEARTID = 0x200000 + CLONE_CHILD_SETTID = 0x1000000 + CLONE_DETACHED = 0x400000 + CLONE_FILES = 0x400 + CLONE_FS = 0x200 + CLONE_IO = 0x80000000 + CLONE_NEWCGROUP = 0x2000000 + CLONE_NEWIPC = 0x8000000 + CLONE_NEWNET = 0x40000000 + CLONE_NEWNS = 0x20000 + CLONE_NEWPID = 0x20000000 + CLONE_NEWUSER = 0x10000000 + CLONE_NEWUTS = 0x4000000 + CLONE_PARENT = 0x8000 + CLONE_PARENT_SETTID = 0x100000 + CLONE_PTRACE = 0x2000 + CLONE_SETTLS = 0x80000 + CLONE_SIGHAND = 0x800 + CLONE_SYSVSEM = 0x40000 + CLONE_THREAD = 0x10000 + CLONE_UNTRACED = 0x800000 + CLONE_VFORK = 0x4000 + CLONE_VM = 0x100 + CMSPAR = 0x40000000 + CR0 = 0x0 + CR1 = 0x200 + CR2 = 0x400 + CR3 = 0x600 + CRDLY = 0x600 + CREAD = 0x80 + CRTSCTS = 0x80000000 + CS5 = 0x0 + CS6 = 0x10 + CS7 = 0x20 + CS8 = 0x30 + CSIGNAL = 0xff + CSIZE = 0x30 + CSTART = 0x11 + CSTATUS = 0x0 + CSTOP = 0x13 + CSTOPB = 0x40 + CSUSP = 0x1a + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ELF_NGREG = 0x12 + ELF_PRARGSZ = 0x50 + ECHO = 0x8 + ECHOCTL = 0x200 + ECHOE = 0x10 + ECHOK = 0x20 + ECHOKE = 0x800 + ECHONL = 0x40 + ECHOPRT = 0x400 + EPOLLERR = 0x8 + EPOLLET = -0x80000000 + EPOLLHUP = 0x10 + EPOLLIN = 0x1 + EPOLLMSG = 0x400 + EPOLLONESHOT = 0x40000000 + EPOLLOUT = 0x4 + EPOLLPRI = 0x2 + EPOLLRDBAND = 0x80 + EPOLLRDHUP = 0x2000 + EPOLLRDNORM = 0x40 + EPOLLWRBAND = 0x200 + EPOLLWRNORM = 0x100 + EPOLL_CLOEXEC = 0x80000 + EPOLL_CTL_ADD = 0x1 + EPOLL_CTL_DEL = 0x2 + EPOLL_CTL_MOD = 0x3 + EPOLL_NONBLOCK = 0x800 + ETH_P_1588 = 0x88f7 + ETH_P_8021Q = 0x8100 + ETH_P_802_2 = 0x4 + ETH_P_802_3 = 0x1 + ETH_P_AARP = 0x80f3 + ETH_P_ALL = 0x3 + ETH_P_AOE = 0x88a2 + ETH_P_ARCNET = 0x1a + ETH_P_ARP = 0x806 + ETH_P_ATALK = 0x809b + ETH_P_ATMFATE = 0x8884 + ETH_P_ATMMPOA = 0x884c + ETH_P_AX25 = 0x2 + ETH_P_BPQ = 0x8ff + ETH_P_CAIF = 0xf7 + ETH_P_CAN = 0xc + ETH_P_CONTROL = 0x16 + ETH_P_CUST = 0x6006 + ETH_P_DDCMP = 0x6 + ETH_P_DEC = 0x6000 + ETH_P_DIAG = 0x6005 + ETH_P_DNA_DL = 0x6001 + ETH_P_DNA_RC = 0x6002 + ETH_P_DNA_RT = 0x6003 + ETH_P_DSA = 0x1b + ETH_P_ECONET = 0x18 + ETH_P_EDSA = 0xdada + ETH_P_FCOE = 0x8906 + ETH_P_FIP = 0x8914 + ETH_P_HDLC = 0x19 + ETH_P_IEEE802154 = 0xf6 + ETH_P_IEEEPUP = 0xa00 + ETH_P_IEEEPUPAT = 0xa01 + ETH_P_IP = 0x800 + ETH_P_IPV6 = 0x86dd + ETH_P_IPX = 0x8137 + ETH_P_IRDA = 0x17 + ETH_P_LAT = 0x6004 + ETH_P_LINK_CTL = 0x886c + ETH_P_LOCALTALK = 0x9 + ETH_P_LOOP = 0x60 + ETH_P_MOBITEX = 0x15 + ETH_P_MPLS_MC = 0x8848 + ETH_P_MPLS_UC = 0x8847 + ETH_P_PAE = 0x888e + ETH_P_PAUSE = 0x8808 + ETH_P_PHONET = 0xf5 + ETH_P_PPPTALK = 0x10 + ETH_P_PPP_DISC = 0x8863 + ETH_P_PPP_MP = 0x8 + ETH_P_PPP_SES = 0x8864 + ETH_P_PUP = 0x200 + ETH_P_PUPAT = 0x201 + ETH_P_RARP = 0x8035 + ETH_P_SCA = 0x6007 + ETH_P_SLOW = 0x8809 + ETH_P_SNAP = 0x5 + ETH_P_TEB = 0x6558 + ETH_P_TIPC = 0x88ca + ETH_P_TRAILER = 0x1c + ETH_P_TR_802_2 = 0x11 + ETH_P_WAN_PPP = 0x7 + ETH_P_WCCP = 0x883e + ETH_P_X25 = 0x805 + EXTA = 0xe + EXTB = 0xf + EXTPROC = 0x10000 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FF0 = 0x0 + FF1 = 0x8000 + FFDLY = 0x8000 + FLUSHO = 0x1000 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x406 + F_EXLCK = 0x4 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLEASE = 0x401 + F_GETLK = 0xc + F_GETLK64 = 0xc + F_GETOWN = 0x9 + F_GETOWN_EX = 0x10 + F_GETPIPE_SZ = 0x408 + F_GETSIG = 0xb + F_LOCK = 0x1 + F_NOTIFY = 0x402 + F_OK = 0x0 + F_RDLCK = 0x0 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLEASE = 0x400 + F_SETLK = 0xd + F_SETLK64 = 0xd + F_SETLKW = 0xe + F_SETLKW64 = 0xe + F_SETOWN = 0x8 + F_SETOWN_EX = 0xf + F_SETPIPE_SZ = 0x407 + F_SETSIG = 0xa + F_SHLCK = 0x8 + F_TEST = 0x3 + F_TLOCK = 0x2 + F_ULOCK = 0x0 + F_UNLCK = 0x2 + F_WRLCK = 0x1 + HUPCL = 0x400 + IBSHIFT = 0x10 + ICANON = 0x2 + ICMPV6_FILTER = 0x1 + ICRNL = 0x100 + IEXTEN = 0x8000 + IFA_F_DADFAILED = 0x8 + IFA_F_DEPRECATED = 0x20 + IFA_F_HOMEADDRESS = 0x10 + IFA_F_NODAD = 0x2 + IFA_F_OPTIMISTIC = 0x4 + IFA_F_PERMANENT = 0x80 + IFA_F_SECONDARY = 0x1 + IFA_F_TEMPORARY = 0x1 + IFA_F_TENTATIVE = 0x40 + IFA_MAX = 0x7 + IFF_ALLMULTI = 0x200 + IFF_AUTOMEDIA = 0x4000 + IFF_BROADCAST = 0x2 + IFF_DEBUG = 0x4 + IFF_DYNAMIC = 0x8000 + IFF_LOOPBACK = 0x8 + IFF_MASTER = 0x400 + IFF_MULTICAST = 0x1000 + IFF_NOARP = 0x80 + IFF_NOTRAILERS = 0x20 + IFF_NO_PI = 0x1000 + IFF_ONE_QUEUE = 0x2000 + IFF_POINTOPOINT = 0x10 + IFF_PORTSEL = 0x2000 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SLAVE = 0x800 + IFF_TAP = 0x2 + IFF_TUN = 0x1 + IFF_TUN_EXCL = 0x8000 + IFF_UP = 0x1 + IFF_VNET_HDR = 0x4000 + IFNAMSIZ = 0x10 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_ACCESS = 0x1 + IN_ALL_EVENTS = 0xfff + IN_ATTRIB = 0x4 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLOEXEC = 0x80000 + IN_CLOSE = 0x18 + IN_CLOSE_NOWRITE = 0x10 + IN_CLOSE_WRITE = 0x8 + IN_CREATE = 0x100 + IN_DELETE = 0x200 + IN_DELETE_SELF = 0x400 + IN_DONT_FOLLOW = 0x2000000 + IN_EXCL_UNLINK = 0x4000000 + IN_IGNORED = 0x8000 + IN_ISDIR = 0x40000000 + IN_LOOPBACKNET = 0x7f + IN_MASK_ADD = 0x20000000 + IN_MODIFY = 0x2 + IN_MOVE = 0xc0 + IN_MOVED_FROM = 0x40 + IN_MOVED_TO = 0x80 + IN_MOVE_SELF = 0x800 + IN_NONBLOCK = 0x800 + IN_ONESHOT = 0x80000000 + IN_ONLYDIR = 0x1000000 + IN_OPEN = 0x20 + IN_Q_OVERFLOW = 0x4000 + IN_UNMOUNT = 0x2000 + IPPROTO_AH = 0x33 + IPPROTO_COMP = 0x6c + IPPROTO_DCCP = 0x21 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_ENCAP = 0x62 + IPPROTO_ESP = 0x32 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GRE = 0x2f + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IGMP = 0x2 + IPPROTO_IP = 0x0 + IPPROTO_IPIP = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_MTP = 0x5c + IPPROTO_NONE = 0x3b + IPPROTO_PIM = 0x67 + IPPROTO_PUP = 0xc + IPPROTO_RAW = 0xff + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_SCTP = 0x84 + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_UDP = 0x11 + IPPROTO_UDPLITE = 0x88 + IPV6_2292DSTOPTS = 0x4 + IPV6_2292HOPLIMIT = 0x8 + IPV6_2292HOPOPTS = 0x3 + IPV6_2292PKTINFO = 0x2 + IPV6_2292PKTOPTIONS = 0x6 + IPV6_2292RTHDR = 0x5 + IPV6_ADDRFORM = 0x1 + IPV6_ADD_MEMBERSHIP = 0x14 + IPV6_AUTHHDR = 0xa + IPV6_CHECKSUM = 0x7 + IPV6_DROP_MEMBERSHIP = 0x15 + IPV6_DSTOPTS = 0x3b + IPV6_HOPLIMIT = 0x34 + IPV6_HOPOPTS = 0x36 + IPV6_IPSEC_POLICY = 0x22 + IPV6_JOIN_ANYCAST = 0x1b + IPV6_JOIN_GROUP = 0x14 + IPV6_LEAVE_ANYCAST = 0x1c + IPV6_LEAVE_GROUP = 0x15 + IPV6_MTU = 0x18 + IPV6_MTU_DISCOVER = 0x17 + IPV6_MULTICAST_HOPS = 0x12 + IPV6_MULTICAST_IF = 0x11 + IPV6_MULTICAST_LOOP = 0x13 + IPV6_NEXTHOP = 0x9 + IPV6_PKTINFO = 0x32 + IPV6_PMTUDISC_DO = 0x2 + IPV6_PMTUDISC_DONT = 0x0 + IPV6_PMTUDISC_PROBE = 0x3 + IPV6_PMTUDISC_WANT = 0x1 + IPV6_RECVDSTOPTS = 0x3a + IPV6_RECVERR = 0x19 + IPV6_RECVHOPLIMIT = 0x33 + IPV6_RECVHOPOPTS = 0x35 + IPV6_RECVPKTINFO = 0x31 + IPV6_RECVRTHDR = 0x38 + IPV6_RECVTCLASS = 0x42 + IPV6_ROUTER_ALERT = 0x16 + IPV6_RTHDR = 0x39 + IPV6_RTHDRDSTOPTS = 0x37 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_RXDSTOPTS = 0x3b + IPV6_RXHOPOPTS = 0x36 + IPV6_TCLASS = 0x43 + IPV6_UNICAST_HOPS = 0x10 + IPV6_V6ONLY = 0x1a + IPV6_XFRM_POLICY = 0x23 + IP_ADD_MEMBERSHIP = 0x23 + IP_ADD_SOURCE_MEMBERSHIP = 0x27 + IP_BLOCK_SOURCE = 0x26 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DROP_MEMBERSHIP = 0x24 + IP_DROP_SOURCE_MEMBERSHIP = 0x28 + IP_FREEBIND = 0xf + IP_HDRINCL = 0x3 + IP_IPSEC_POLICY = 0x10 + IP_MAXPACKET = 0xffff + IP_MAX_MEMBERSHIPS = 0x14 + IP_MF = 0x2000 + IP_MINTTL = 0x15 + IP_MSFILTER = 0x29 + IP_MSS = 0x240 + IP_MTU = 0xe + IP_MTU_DISCOVER = 0xa + IP_MULTICAST_IF = 0x20 + IP_MULTICAST_LOOP = 0x22 + IP_MULTICAST_TTL = 0x21 + IP_OFFMASK = 0x1fff + IP_OPTIONS = 0x4 + IP_ORIGDSTADDR = 0x14 + IP_PASSSEC = 0x12 + IP_PKTINFO = 0x8 + IP_PKTOPTIONS = 0x9 + IP_PMTUDISC = 0xa + IP_PMTUDISC_DO = 0x2 + IP_PMTUDISC_DONT = 0x0 + IP_PMTUDISC_PROBE = 0x3 + IP_PMTUDISC_WANT = 0x1 + IP_RECVERR = 0xb + IP_RECVOPTS = 0x6 + IP_RECVORIGDSTADDR = 0x14 + IP_RECVRETOPTS = 0x7 + IP_RECVTOS = 0xd + IP_RECVTTL = 0xc + IP_RETOPTS = 0x7 + IP_RF = 0x8000 + IP_ROUTER_ALERT = 0x5 + IP_TOS = 0x1 + IP_TRANSPARENT = 0x13 + IP_TTL = 0x2 + IP_UNBLOCK_SOURCE = 0x25 + IP_XFRM_POLICY = 0x11 + ISIG = 0x1 + ISTRIP = 0x20 + IUCLC = 0x200 + IUTF8 = 0x4000 + IXANY = 0x800 + IXOFF = 0x1000 + IXON = 0x400 + LINUX_REBOOT_CMD_CAD_OFF = 0x0 + LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef + LINUX_REBOOT_CMD_HALT = 0xcdef0123 + LINUX_REBOOT_CMD_KEXEC = 0x45584543 + LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc + LINUX_REBOOT_CMD_RESTART = 0x1234567 + LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4 + LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2 + LINUX_REBOOT_MAGIC1 = 0xfee1dead + LINUX_REBOOT_MAGIC2 = 0x28121969 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_DOFORK = 0xb + MADV_DONTFORK = 0xa + MADV_DONTNEED = 0x4 + MADV_HUGEPAGE = 0xe + MADV_HWPOISON = 0x64 + MADV_MERGEABLE = 0xc + MADV_NOHUGEPAGE = 0xf + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_REMOVE = 0x9 + MADV_SEQUENTIAL = 0x2 + MADV_UNMERGEABLE = 0xd + MADV_WILLNEED = 0x3 + MAP_ANON = 0x20 + MAP_ANONYMOUS = 0x20 + MAP_DENYWRITE = 0x800 + MAP_EXECUTABLE = 0x1000 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_GROWSDOWN = 0x100 + MAP_LOCKED = 0x2000 + MAP_NONBLOCK = 0x10000 + MAP_NORESERVE = 0x4000 + MAP_POPULATE = 0x8000 + MAP_PRIVATE = 0x2 + MAP_SHARED = 0x1 + MAP_TYPE = 0xf + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MNT_DETACH = 0x2 + MNT_EXPIRE = 0x4 + MNT_FORCE = 0x1 + MSG_CMSG_CLOEXEC = 0x40000000 + MSG_CONFIRM = 0x800 + MSG_CTRUNC = 0x8 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x40 + MSG_EOR = 0x80 + MSG_ERRQUEUE = 0x2000 + MSG_FASTOPEN = 0x20000000 + MSG_FIN = 0x200 + MSG_MORE = 0x8000 + MSG_NOSIGNAL = 0x4000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_PROXY = 0x10 + MSG_RST = 0x1000 + MSG_SYN = 0x400 + MSG_TRUNC = 0x20 + MSG_TRYHARD = 0x4 + MSG_WAITALL = 0x100 + MSG_WAITFORONE = 0x10000 + MS_ACTIVE = 0x40000000 + MS_ASYNC = 0x1 + MS_BIND = 0x1000 + MS_DIRSYNC = 0x80 + MS_INVALIDATE = 0x2 + MS_I_VERSION = 0x800000 + MS_KERNMOUNT = 0x400000 + MS_MANDLOCK = 0x40 + MS_MGC_MSK = 0xffff0000 + MS_MGC_VAL = 0xc0ed0000 + MS_MOVE = 0x2000 + MS_NOATIME = 0x400 + MS_NODEV = 0x4 + MS_NODIRATIME = 0x800 + MS_NOEXEC = 0x8 + MS_NOSUID = 0x2 + MS_NOUSER = -0x80000000 + MS_POSIXACL = 0x10000 + MS_PRIVATE = 0x40000 + MS_RDONLY = 0x1 + MS_REC = 0x4000 + MS_RELATIME = 0x200000 + MS_REMOUNT = 0x20 + MS_RMT_MASK = 0x800051 + MS_SHARED = 0x100000 + MS_SILENT = 0x8000 + MS_SLAVE = 0x80000 + MS_STRICTATIME = 0x1000000 + MS_SYNC = 0x4 + MS_SYNCHRONOUS = 0x10 + MS_UNBINDABLE = 0x20000 + NAME_MAX = 0xff + NETLINK_ADD_MEMBERSHIP = 0x1 + NETLINK_AUDIT = 0x9 + NETLINK_BROADCAST_ERROR = 0x4 + NETLINK_CONNECTOR = 0xb + NETLINK_DNRTMSG = 0xe + NETLINK_DROP_MEMBERSHIP = 0x2 + NETLINK_ECRYPTFS = 0x13 + NETLINK_FIB_LOOKUP = 0xa + NETLINK_FIREWALL = 0x3 + NETLINK_GENERIC = 0x10 + NETLINK_INET_DIAG = 0x4 + NETLINK_IP6_FW = 0xd + NETLINK_ISCSI = 0x8 + NETLINK_KOBJECT_UEVENT = 0xf + NETLINK_NETFILTER = 0xc + NETLINK_NFLOG = 0x5 + NETLINK_NO_ENOBUFS = 0x5 + NETLINK_PKTINFO = 0x3 + NETLINK_RDMA = 0x14 + NETLINK_ROUTE = 0x0 + NETLINK_SCSITRANSPORT = 0x12 + NETLINK_SELINUX = 0x7 + NETLINK_UNUSED = 0x1 + NETLINK_USERSOCK = 0x2 + NETLINK_XFRM = 0x6 + NL0 = 0x0 + NL1 = 0x100 + NLA_ALIGNTO = 0x4 + NLA_F_NESTED = 0x8000 + NLA_F_NET_BYTEORDER = 0x4000 + NLA_HDRLEN = 0x4 + NLDLY = 0x100 + NLMSG_ALIGNTO = 0x4 + NLMSG_DONE = 0x3 + NLMSG_ERROR = 0x2 + NLMSG_HDRLEN = 0x10 + NLMSG_MIN_TYPE = 0x10 + NLMSG_NOOP = 0x1 + NLMSG_OVERRUN = 0x4 + NLM_F_ACK = 0x4 + NLM_F_APPEND = 0x800 + NLM_F_ATOMIC = 0x400 + NLM_F_CREATE = 0x400 + NLM_F_DUMP = 0x300 + NLM_F_ECHO = 0x8 + NLM_F_EXCL = 0x200 + NLM_F_MATCH = 0x200 + NLM_F_MULTI = 0x2 + NLM_F_REPLACE = 0x100 + NLM_F_REQUEST = 0x1 + NLM_F_ROOT = 0x100 + NOFLSH = 0x80 + OCRNL = 0x8 + OFDEL = 0x80 + OFILL = 0x40 + OLCUC = 0x2 + ONLCR = 0x4 + ONLRET = 0x20 + ONOCR = 0x10 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_APPEND = 0x400 + O_ASYNC = 0x2000 + O_CLOEXEC = 0x80000 + O_CREAT = 0x40 + O_DIRECT = 0x10000 + O_DIRECTORY = 0x4000 + O_DSYNC = 0x1000 + O_EXCL = 0x80 + O_FSYNC = 0x1000 + O_LARGEFILE = 0x20000 + O_NDELAY = 0x800 + O_NOATIME = 0x40000 + O_NOCTTY = 0x100 + O_NOFOLLOW = 0x8000 + O_NONBLOCK = 0x800 + O_PATH = 0x200000 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_RSYNC = 0x1000 + O_SYNC = 0x1000 + O_TRUNC = 0x200 + O_WRONLY = 0x1 + PACKET_ADD_MEMBERSHIP = 0x1 + PACKET_BROADCAST = 0x1 + PACKET_DROP_MEMBERSHIP = 0x2 + PACKET_FASTROUTE = 0x6 + PACKET_HOST = 0x0 + PACKET_LOOPBACK = 0x5 + PACKET_MR_ALLMULTI = 0x2 + PACKET_MR_MULTICAST = 0x0 + PACKET_MR_PROMISC = 0x1 + PACKET_MULTICAST = 0x2 + PACKET_OTHERHOST = 0x3 + PACKET_OUTGOING = 0x4 + PACKET_RECV_OUTPUT = 0x3 + PACKET_RX_RING = 0x5 + PACKET_STATISTICS = 0x6 + PARENB = 0x100 + PARMRK = 0x8 + PARODD = 0x200 + PENDIN = 0x4000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_GROWSDOWN = 0x1000000 + PROT_GROWSUP = 0x2000000 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + PR_CAPBSET_DROP = 0x18 + PR_CAPBSET_READ = 0x17 + PR_CLEAR_SECCOMP_FILTER = 0x25 + PR_ENDIAN_BIG = 0x0 + PR_ENDIAN_LITTLE = 0x1 + PR_ENDIAN_PPC_LITTLE = 0x2 + PR_FPEMU_NOPRINT = 0x1 + PR_FPEMU_SIGFPE = 0x2 + PR_FP_EXC_ASYNC = 0x2 + PR_FP_EXC_DISABLED = 0x0 + PR_FP_EXC_DIV = 0x10000 + PR_FP_EXC_INV = 0x100000 + PR_FP_EXC_NONRECOV = 0x1 + PR_FP_EXC_OVF = 0x20000 + PR_FP_EXC_PRECISE = 0x3 + PR_FP_EXC_RES = 0x80000 + PR_FP_EXC_SW_ENABLE = 0x80 + PR_FP_EXC_UND = 0x40000 + PR_GET_DUMPABLE = 0x3 + PR_GET_ENDIAN = 0x13 + PR_GET_FPEMU = 0x9 + PR_GET_FPEXC = 0xb + PR_GET_KEEPCAPS = 0x7 + PR_GET_NAME = 0x10 + PR_GET_PDEATHSIG = 0x2 + PR_GET_SECCOMP = 0x15 + PR_GET_SECCOMP_FILTER = 0x23 + PR_GET_SECUREBITS = 0x1b + PR_GET_TIMERSLACK = 0x1e + PR_GET_TIMING = 0xd + PR_GET_TSC = 0x19 + PR_GET_UNALIGN = 0x5 + PR_MCE_KILL = 0x21 + PR_MCE_KILL_CLEAR = 0x0 + PR_MCE_KILL_DEFAULT = 0x2 + PR_MCE_KILL_EARLY = 0x1 + PR_MCE_KILL_GET = 0x22 + PR_MCE_KILL_LATE = 0x0 + PR_MCE_KILL_SET = 0x1 + PR_SECCOMP_FILTER_EVENT = 0x1 + PR_SECCOMP_FILTER_SYSCALL = 0x0 + PR_SET_DUMPABLE = 0x4 + PR_SET_ENDIAN = 0x14 + PR_SET_FPEMU = 0xa + PR_SET_FPEXC = 0xc + PR_SET_KEEPCAPS = 0x8 + PR_SET_NAME = 0xf + PR_SET_PDEATHSIG = 0x1 + PR_SET_PTRACER = 0x59616d61 + PR_SET_SECCOMP = 0x16 + PR_SET_SECCOMP_FILTER = 0x24 + PR_SET_SECUREBITS = 0x1c + PR_SET_TIMERSLACK = 0x1d + PR_SET_TIMING = 0xe + PR_SET_TSC = 0x1a + PR_SET_UNALIGN = 0x6 + PR_TASK_PERF_EVENTS_DISABLE = 0x1f + PR_TASK_PERF_EVENTS_ENABLE = 0x20 + PR_TIMING_STATISTICAL = 0x0 + PR_TIMING_TIMESTAMP = 0x1 + PR_TSC_ENABLE = 0x1 + PR_TSC_SIGSEGV = 0x2 + PR_UNALIGN_NOPRINT = 0x1 + PR_UNALIGN_SIGBUS = 0x2 + PTRACE_ATTACH = 0x10 + PTRACE_CONT = 0x7 + PTRACE_DETACH = 0x11 + PTRACE_EVENT_CLONE = 0x3 + PTRACE_EVENT_EXEC = 0x4 + PTRACE_EVENT_EXIT = 0x6 + PTRACE_EVENT_FORK = 0x1 + PTRACE_EVENT_VFORK = 0x2 + PTRACE_EVENT_VFORK_DONE = 0x5 + PTRACE_GETCRUNCHREGS = 0x19 + PTRACE_GETEVENTMSG = 0x4201 + PTRACE_GETFPREGS = 0xe + PTRACE_GETHBPREGS = 0x1d + PTRACE_GETREGS = 0xc + PTRACE_GETREGSET = 0x4204 + PTRACE_GETSIGINFO = 0x4202 + PTRACE_GETVFPREGS = 0x1b + PTRACE_GETWMMXREGS = 0x12 + PTRACE_GET_THREAD_AREA = 0x16 + PTRACE_KILL = 0x8 + PTRACE_OLDSETOPTIONS = 0x15 + PTRACE_O_MASK = 0x7f + PTRACE_O_TRACECLONE = 0x8 + PTRACE_O_TRACEEXEC = 0x10 + PTRACE_O_TRACEEXIT = 0x40 + PTRACE_O_TRACEFORK = 0x2 + PTRACE_O_TRACESYSGOOD = 0x1 + PTRACE_O_TRACEVFORK = 0x4 + PTRACE_O_TRACEVFORKDONE = 0x20 + PTRACE_PEEKDATA = 0x2 + PTRACE_PEEKTEXT = 0x1 + PTRACE_PEEKUSR = 0x3 + PTRACE_POKEDATA = 0x5 + PTRACE_POKETEXT = 0x4 + PTRACE_POKEUSR = 0x6 + PTRACE_SETCRUNCHREGS = 0x1a + PTRACE_SETFPREGS = 0xf + PTRACE_SETHBPREGS = 0x1e + PTRACE_SETOPTIONS = 0x4200 + PTRACE_SETREGS = 0xd + PTRACE_SETREGSET = 0x4205 + PTRACE_SETSIGINFO = 0x4203 + PTRACE_SETVFPREGS = 0x1c + PTRACE_SETWMMXREGS = 0x13 + PTRACE_SET_SYSCALL = 0x17 + PTRACE_SINGLESTEP = 0x9 + PTRACE_SYSCALL = 0x18 + PTRACE_TRACEME = 0x0 + PT_DATA_ADDR = 0x10004 + PT_TEXT_ADDR = 0x10000 + PT_TEXT_END_ADDR = 0x10008 + RLIMIT_AS = 0x9 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x7 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = -0x1 + RTAX_ADVMSS = 0x8 + RTAX_CWND = 0x7 + RTAX_FEATURES = 0xc + RTAX_FEATURE_ALLFRAG = 0x8 + RTAX_FEATURE_ECN = 0x1 + RTAX_FEATURE_SACK = 0x2 + RTAX_FEATURE_TIMESTAMP = 0x4 + RTAX_HOPLIMIT = 0xa + RTAX_INITCWND = 0xb + RTAX_INITRWND = 0xe + RTAX_LOCK = 0x1 + RTAX_MAX = 0xe + RTAX_MTU = 0x2 + RTAX_REORDERING = 0x9 + RTAX_RTO_MIN = 0xd + RTAX_RTT = 0x4 + RTAX_RTTVAR = 0x5 + RTAX_SSTHRESH = 0x6 + RTAX_UNSPEC = 0x0 + RTAX_WINDOW = 0x3 + RTA_ALIGNTO = 0x4 + RTA_MAX = 0x10 + RTCF_DIRECTSRC = 0x4000000 + RTCF_DOREDIRECT = 0x1000000 + RTCF_LOG = 0x2000000 + RTCF_MASQ = 0x400000 + RTCF_NAT = 0x800000 + RTCF_VALVE = 0x200000 + RTF_ADDRCLASSMASK = 0xf8000000 + RTF_ADDRCONF = 0x40000 + RTF_ALLONLINK = 0x20000 + RTF_BROADCAST = 0x10000000 + RTF_CACHE = 0x1000000 + RTF_DEFAULT = 0x10000 + RTF_DYNAMIC = 0x10 + RTF_FLOW = 0x2000000 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_INTERFACE = 0x40000000 + RTF_IRTT = 0x100 + RTF_LINKRT = 0x100000 + RTF_LOCAL = 0x80000000 + RTF_MODIFIED = 0x20 + RTF_MSS = 0x40 + RTF_MTU = 0x40 + RTF_MULTICAST = 0x20000000 + RTF_NAT = 0x8000000 + RTF_NOFORWARD = 0x1000 + RTF_NONEXTHOP = 0x200000 + RTF_NOPMTUDISC = 0x4000 + RTF_POLICY = 0x4000000 + RTF_REINSTATE = 0x8 + RTF_REJECT = 0x200 + RTF_STATIC = 0x400 + RTF_THROW = 0x2000 + RTF_UP = 0x1 + RTF_WINDOW = 0x80 + RTF_XRESOLVE = 0x800 + RTM_BASE = 0x10 + RTM_DELACTION = 0x31 + RTM_DELADDR = 0x15 + RTM_DELADDRLABEL = 0x49 + RTM_DELLINK = 0x11 + RTM_DELNEIGH = 0x1d + RTM_DELQDISC = 0x25 + RTM_DELROUTE = 0x19 + RTM_DELRULE = 0x21 + RTM_DELTCLASS = 0x29 + RTM_DELTFILTER = 0x2d + RTM_F_CLONED = 0x200 + RTM_F_EQUALIZE = 0x400 + RTM_F_NOTIFY = 0x100 + RTM_F_PREFIX = 0x800 + RTM_GETACTION = 0x32 + RTM_GETADDR = 0x16 + RTM_GETADDRLABEL = 0x4a + RTM_GETANYCAST = 0x3e + RTM_GETDCB = 0x4e + RTM_GETLINK = 0x12 + RTM_GETMULTICAST = 0x3a + RTM_GETNEIGH = 0x1e + RTM_GETNEIGHTBL = 0x42 + RTM_GETQDISC = 0x26 + RTM_GETROUTE = 0x1a + RTM_GETRULE = 0x22 + RTM_GETTCLASS = 0x2a + RTM_GETTFILTER = 0x2e + RTM_MAX = 0x4f + RTM_NEWACTION = 0x30 + RTM_NEWADDR = 0x14 + RTM_NEWADDRLABEL = 0x48 + RTM_NEWLINK = 0x10 + RTM_NEWNDUSEROPT = 0x44 + RTM_NEWNEIGH = 0x1c + RTM_NEWNEIGHTBL = 0x40 + RTM_NEWPREFIX = 0x34 + RTM_NEWQDISC = 0x24 + RTM_NEWROUTE = 0x18 + RTM_NEWRULE = 0x20 + RTM_NEWTCLASS = 0x28 + RTM_NEWTFILTER = 0x2c + RTM_NR_FAMILIES = 0x10 + RTM_NR_MSGTYPES = 0x40 + RTM_SETDCB = 0x4f + RTM_SETLINK = 0x13 + RTM_SETNEIGHTBL = 0x43 + RTNH_ALIGNTO = 0x4 + RTNH_F_DEAD = 0x1 + RTNH_F_ONLINK = 0x4 + RTNH_F_PERVASIVE = 0x2 + RTN_MAX = 0xb + RTPROT_BIRD = 0xc + RTPROT_BOOT = 0x3 + RTPROT_DHCP = 0x10 + RTPROT_DNROUTED = 0xd + RTPROT_GATED = 0x8 + RTPROT_KERNEL = 0x2 + RTPROT_MRT = 0xa + RTPROT_NTK = 0xf + RTPROT_RA = 0x9 + RTPROT_REDIRECT = 0x1 + RTPROT_STATIC = 0x4 + RTPROT_UNSPEC = 0x0 + RTPROT_XORP = 0xe + RTPROT_ZEBRA = 0xb + RT_CLASS_DEFAULT = 0xfd + RT_CLASS_LOCAL = 0xff + RT_CLASS_MAIN = 0xfe + RT_CLASS_MAX = 0xff + RT_CLASS_UNSPEC = 0x0 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + RUSAGE_THREAD = 0x1 + SCM_CREDENTIALS = 0x2 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x1d + SCM_TIMESTAMPING = 0x25 + SCM_TIMESTAMPNS = 0x23 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDDLCI = 0x8980 + SIOCADDMULTI = 0x8931 + SIOCADDRT = 0x890b + SIOCATMARK = 0x8905 + SIOCDARP = 0x8953 + SIOCDELDLCI = 0x8981 + SIOCDELMULTI = 0x8932 + SIOCDELRT = 0x890c + SIOCDEVPRIVATE = 0x89f0 + SIOCDIFADDR = 0x8936 + SIOCDRARP = 0x8960 + SIOCGARP = 0x8954 + SIOCGIFADDR = 0x8915 + SIOCGIFBR = 0x8940 + SIOCGIFBRDADDR = 0x8919 + SIOCGIFCONF = 0x8912 + SIOCGIFCOUNT = 0x8938 + SIOCGIFDSTADDR = 0x8917 + SIOCGIFENCAP = 0x8925 + SIOCGIFFLAGS = 0x8913 + SIOCGIFHWADDR = 0x8927 + SIOCGIFINDEX = 0x8933 + SIOCGIFMAP = 0x8970 + SIOCGIFMEM = 0x891f + SIOCGIFMETRIC = 0x891d + SIOCGIFMTU = 0x8921 + SIOCGIFNAME = 0x8910 + SIOCGIFNETMASK = 0x891b + SIOCGIFPFLAGS = 0x8935 + SIOCGIFSLAVE = 0x8929 + SIOCGIFTXQLEN = 0x8942 + SIOCGPGRP = 0x8904 + SIOCGRARP = 0x8961 + SIOCGSTAMP = 0x8906 + SIOCGSTAMPNS = 0x8907 + SIOCPROTOPRIVATE = 0x89e0 + SIOCRTMSG = 0x890d + SIOCSARP = 0x8955 + SIOCSIFADDR = 0x8916 + SIOCSIFBR = 0x8941 + SIOCSIFBRDADDR = 0x891a + SIOCSIFDSTADDR = 0x8918 + SIOCSIFENCAP = 0x8926 + SIOCSIFFLAGS = 0x8914 + SIOCSIFHWADDR = 0x8924 + SIOCSIFHWBROADCAST = 0x8937 + SIOCSIFLINK = 0x8911 + SIOCSIFMAP = 0x8971 + SIOCSIFMEM = 0x8920 + SIOCSIFMETRIC = 0x891e + SIOCSIFMTU = 0x8922 + SIOCSIFNAME = 0x8923 + SIOCSIFNETMASK = 0x891c + SIOCSIFPFLAGS = 0x8934 + SIOCSIFSLAVE = 0x8930 + SIOCSIFTXQLEN = 0x8943 + SIOCSPGRP = 0x8902 + SIOCSRARP = 0x8962 + SOCK_CLOEXEC = 0x80000 + SOCK_DCCP = 0x6 + SOCK_DGRAM = 0x2 + SOCK_NONBLOCK = 0x800 + SOCK_PACKET = 0xa + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_AAL = 0x109 + SOL_ATM = 0x108 + SOL_DECNET = 0x105 + SOL_ICMPV6 = 0x3a + SOL_IP = 0x0 + SOL_IPV6 = 0x29 + SOL_IRDA = 0x10a + SOL_PACKET = 0x107 + SOL_RAW = 0xff + SOL_SOCKET = 0x1 + SOL_TCP = 0x6 + SOL_X25 = 0x106 + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x1e + SO_ATTACH_FILTER = 0x1a + SO_BINDTODEVICE = 0x19 + SO_BROADCAST = 0x6 + SO_BSDCOMPAT = 0xe + SO_DEBUG = 0x1 + SO_DETACH_FILTER = 0x1b + SO_DOMAIN = 0x27 + SO_DONTROUTE = 0x5 + SO_ERROR = 0x4 + SO_KEEPALIVE = 0x9 + SO_LINGER = 0xd + SO_MARK = 0x24 + SO_NO_CHECK = 0xb + SO_OOBINLINE = 0xa + SO_PASSCRED = 0x10 + SO_PASSSEC = 0x22 + SO_PEERCRED = 0x11 + SO_PEERNAME = 0x1c + SO_PEERSEC = 0x1f + SO_PRIORITY = 0xc + SO_PROTOCOL = 0x26 + SO_RCVBUF = 0x8 + SO_RCVBUFFORCE = 0x21 + SO_RCVLOWAT = 0x12 + SO_RCVTIMEO = 0x14 + SO_REUSEADDR = 0x2 + SO_RXQ_OVFL = 0x28 + SO_SECURITY_AUTHENTICATION = 0x16 + SO_SECURITY_ENCRYPTION_NETWORK = 0x18 + SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17 + SO_SNDBUF = 0x7 + SO_SNDBUFFORCE = 0x20 + SO_SNDLOWAT = 0x13 + SO_SNDTIMEO = 0x15 + SO_TIMESTAMP = 0x1d + SO_TIMESTAMPING = 0x25 + SO_TIMESTAMPNS = 0x23 + SO_TYPE = 0x3 + S_BLKSIZE = 0x200 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + TAB0 = 0x0 + TAB1 = 0x800 + TAB2 = 0x1000 + TAB3 = 0x1800 + TABDLY = 0x1800 + TCFLSH = 0x540b + TCGETA = 0x5405 + TCGETS = 0x5401 + TCGETS2 = 0x802c542a + TCGETX = 0x5432 + TCIFLUSH = 0x0 + TCIOFF = 0x2 + TCIOFLUSH = 0x2 + TCION = 0x3 + TCOFLUSH = 0x1 + TCOOFF = 0x0 + TCOON = 0x1 + TCP_CONGESTION = 0xd + TCP_CORK = 0x3 + TCP_DEFER_ACCEPT = 0x9 + TCP_INFO = 0xb + TCP_KEEPCNT = 0x6 + TCP_KEEPIDLE = 0x4 + TCP_KEEPINTVL = 0x5 + TCP_LINGER2 = 0x8 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0xe + TCP_MD5SIG_MAXKEYLEN = 0x50 + TCP_MSS = 0x200 + TCP_NODELAY = 0x1 + TCP_QUICKACK = 0xc + TCP_SYNCNT = 0x7 + TCP_WINDOW_CLAMP = 0xa + TCSAFLUSH = 0x2 + TCSBRK = 0x5409 + TCSBRKP = 0x5425 + TCSETA = 0x5406 + TCSETAF = 0x5408 + TCSETAW = 0x5407 + TCSETS = 0x5402 + TCSETS2 = 0x402c542b + TCSETSF = 0x5404 + TCSETSF2 = 0x402c542d + TCSETSW = 0x5403 + TCSETSW2 = 0x402c542c + TCSETX = 0x5433 + TCSETXF = 0x5434 + TCSETXW = 0x5435 + TCXONC = 0x540a + TIOCCBRK = 0x5428 + TIOCCONS = 0x541d + TIOCEXCL = 0x540c + TIOCGDEV = 0x80045432 + TIOCGETD = 0x5424 + TIOCGEXCL = 0x80045440 + TIOCGICOUNT = 0x545d + TIOCGLCKTRMIOS = 0x5456 + TIOCGPGRP = 0x540f + TIOCGPKT = 0x80045438 + TIOCGPTLCK = 0x80045439 + TIOCGPTN = 0x80045430 + TIOCGRS485 = 0x542e + TIOCGSERIAL = 0x541e + TIOCGSID = 0x5429 + TIOCGSOFTCAR = 0x5419 + TIOCGWINSZ = 0x5413 + TIOCINQ = 0x541b + TIOCLINUX = 0x541c + TIOCMBIC = 0x5417 + TIOCMBIS = 0x5416 + TIOCMGET = 0x5415 + TIOCMIWAIT = 0x545c + TIOCMSET = 0x5418 + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x5422 + TIOCNXCL = 0x540d + TIOCOUTQ = 0x5411 + TIOCPKT = 0x5420 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCSBRK = 0x5427 + TIOCSCTTY = 0x540e + TIOCSERCONFIG = 0x5453 + TIOCSERGETLSR = 0x5459 + TIOCSERGETMULTI = 0x545a + TIOCSERGSTRUCT = 0x5458 + TIOCSERGWILD = 0x5454 + TIOCSERSETMULTI = 0x545b + TIOCSERSWILD = 0x5455 + TIOCSER_TEMT = 0x1 + TIOCSETD = 0x5423 + TIOCSIG = 0x40045436 + TIOCSLCKTRMIOS = 0x5457 + TIOCSPGRP = 0x5410 + TIOCSPTLCK = 0x40045431 + TIOCSRS485 = 0x542f + TIOCSSERIAL = 0x541f + TIOCSSOFTCAR = 0x541a + TIOCSTI = 0x5412 + TIOCSWINSZ = 0x5414 + TIOCVHANGUP = 0x5437 + TOSTOP = 0x100 + TUNATTACHFILTER = 0x400854d5 + TUNDETACHFILTER = 0x400854d6 + TUNGETFEATURES = 0x800454cf + TUNGETIFF = 0x800454d2 + TUNGETSNDBUF = 0x800454d3 + TUNGETVNETHDRSZ = 0x800454d7 + TUNSETDEBUG = 0x400454c9 + TUNSETGROUP = 0x400454ce + TUNSETIFF = 0x400454ca + TUNSETLINK = 0x400454cd + TUNSETNOCSUM = 0x400454c8 + TUNSETOFFLOAD = 0x400454d0 + TUNSETOWNER = 0x400454cc + TUNSETPERSIST = 0x400454cb + TUNSETSNDBUF = 0x400454d4 + TUNSETTXFILTER = 0x400454d1 + TUNSETVNETHDRSZ = 0x400454d8 + VDISCARD = 0xd + VEOF = 0x4 + VEOL = 0xb + VEOL2 = 0x10 + VERASE = 0x2 + VINTR = 0x0 + VKILL = 0x3 + VLNEXT = 0xf + VMIN = 0x6 + VQUIT = 0x1 + VREPRINT = 0xc + VSTART = 0x8 + VSTOP = 0x9 + VSUSP = 0xa + VSWTC = 0x7 + VT0 = 0x0 + VT1 = 0x4000 + VTDLY = 0x4000 + VTIME = 0x5 + VWERASE = 0xe + WALL = 0x40000000 + WCLONE = 0x80000000 + WCONTINUED = 0x8 + WEXITED = 0x4 + WNOHANG = 0x1 + WNOTHREAD = 0x20000000 + WNOWAIT = 0x1000000 + WORDSIZE = 0x20 + WSTOPPED = 0x2 + WUNTRACED = 0x2 + XCASE = 0x4 + XTABS = 0x1800 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x62) + EADDRNOTAVAIL = syscall.Errno(0x63) + EADV = syscall.Errno(0x44) + EAFNOSUPPORT = syscall.Errno(0x61) + EAGAIN = syscall.Errno(0xb) + EALREADY = syscall.Errno(0x72) + EBADE = syscall.Errno(0x34) + EBADF = syscall.Errno(0x9) + EBADFD = syscall.Errno(0x4d) + EBADMSG = syscall.Errno(0x4a) + EBADR = syscall.Errno(0x35) + EBADRQC = syscall.Errno(0x38) + EBADSLT = syscall.Errno(0x39) + EBFONT = syscall.Errno(0x3b) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x7d) + ECHILD = syscall.Errno(0xa) + ECHRNG = syscall.Errno(0x2c) + ECOMM = syscall.Errno(0x46) + ECONNABORTED = syscall.Errno(0x67) + ECONNREFUSED = syscall.Errno(0x6f) + ECONNRESET = syscall.Errno(0x68) + EDEADLK = syscall.Errno(0x23) + EDEADLOCK = syscall.Errno(0x23) + EDESTADDRREQ = syscall.Errno(0x59) + EDOM = syscall.Errno(0x21) + EDOTDOT = syscall.Errno(0x49) + EDQUOT = syscall.Errno(0x7a) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EHOSTDOWN = syscall.Errno(0x70) + EHOSTUNREACH = syscall.Errno(0x71) + EHWPOISON = syscall.Errno(0x85) + EIDRM = syscall.Errno(0x2b) + EILSEQ = syscall.Errno(0x54) + EINPROGRESS = syscall.Errno(0x73) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x6a) + EISDIR = syscall.Errno(0x15) + EISNAM = syscall.Errno(0x78) + EKEYEXPIRED = syscall.Errno(0x7f) + EKEYREJECTED = syscall.Errno(0x81) + EKEYREVOKED = syscall.Errno(0x80) + EL2HLT = syscall.Errno(0x33) + EL2NSYNC = syscall.Errno(0x2d) + EL3HLT = syscall.Errno(0x2e) + EL3RST = syscall.Errno(0x2f) + ELIBACC = syscall.Errno(0x4f) + ELIBBAD = syscall.Errno(0x50) + ELIBEXEC = syscall.Errno(0x53) + ELIBMAX = syscall.Errno(0x52) + ELIBSCN = syscall.Errno(0x51) + ELNRNG = syscall.Errno(0x30) + ELOOP = syscall.Errno(0x28) + EMEDIUMTYPE = syscall.Errno(0x7c) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x5a) + EMULTIHOP = syscall.Errno(0x48) + ENAMETOOLONG = syscall.Errno(0x24) + ENAVAIL = syscall.Errno(0x77) + ENETDOWN = syscall.Errno(0x64) + ENETRESET = syscall.Errno(0x66) + ENETUNREACH = syscall.Errno(0x65) + ENFILE = syscall.Errno(0x17) + ENOANO = syscall.Errno(0x37) + ENOBUFS = syscall.Errno(0x69) + ENOCSI = syscall.Errno(0x32) + ENODATA = syscall.Errno(0x3d) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOKEY = syscall.Errno(0x7e) + ENOLCK = syscall.Errno(0x25) + ENOLINK = syscall.Errno(0x43) + ENOMEDIUM = syscall.Errno(0x7b) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x2a) + ENONET = syscall.Errno(0x40) + ENOPKG = syscall.Errno(0x41) + ENOPROTOOPT = syscall.Errno(0x5c) + ENOSPC = syscall.Errno(0x1c) + ENOSR = syscall.Errno(0x3f) + ENOSTR = syscall.Errno(0x3c) + ENOSYS = syscall.Errno(0x26) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x6b) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x27) + ENOTNAM = syscall.Errno(0x76) + ENOTRECOVERABLE = syscall.Errno(0x83) + ENOTSOCK = syscall.Errno(0x58) + ENOTSUP = syscall.Errno(0x5f) + ENOTTY = syscall.Errno(0x19) + ENOTUNIQ = syscall.Errno(0x4c) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x5f) + EOVERFLOW = syscall.Errno(0x4b) + EOWNERDEAD = syscall.Errno(0x82) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x60) + EPIPE = syscall.Errno(0x20) + EPROTO = syscall.Errno(0x47) + EPROTONOSUPPORT = syscall.Errno(0x5d) + EPROTOTYPE = syscall.Errno(0x5b) + ERANGE = syscall.Errno(0x22) + EREMCHG = syscall.Errno(0x4e) + EREMOTE = syscall.Errno(0x42) + EREMOTEIO = syscall.Errno(0x79) + ERESTART = syscall.Errno(0x55) + ERFKILL = syscall.Errno(0x84) + EROFS = syscall.Errno(0x1e) + ESHUTDOWN = syscall.Errno(0x6c) + ESOCKTNOSUPPORT = syscall.Errno(0x5e) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESRMNT = syscall.Errno(0x45) + ESTALE = syscall.Errno(0x74) + ESTRPIPE = syscall.Errno(0x56) + ETIME = syscall.Errno(0x3e) + ETIMEDOUT = syscall.Errno(0x6e) + ETOOMANYREFS = syscall.Errno(0x6d) + ETXTBSY = syscall.Errno(0x1a) + EUCLEAN = syscall.Errno(0x75) + EUNATCH = syscall.Errno(0x31) + EUSERS = syscall.Errno(0x57) + EWOULDBLOCK = syscall.Errno(0xb) + EXDEV = syscall.Errno(0x12) + EXFULL = syscall.Errno(0x36) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0x7) + SIGCHLD = syscall.Signal(0x11) + SIGCLD = syscall.Signal(0x11) + SIGCONT = syscall.Signal(0x12) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x1d) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPOLL = syscall.Signal(0x1d) + SIGPROF = syscall.Signal(0x1b) + SIGPWR = syscall.Signal(0x1e) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTKFLT = syscall.Signal(0x10) + SIGSTOP = syscall.Signal(0x13) + SIGSYS = syscall.Signal(0x1f) + SIGTERM = syscall.Signal(0xf) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x14) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGUNUSED = syscall.Signal(0x1f) + SIGURG = syscall.Signal(0x17) + SIGUSR1 = syscall.Signal(0xa) + SIGUSR2 = syscall.Signal(0xc) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "no such device or address", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource temporarily unavailable", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device or resource busy", + 17: "file exists", + 18: "invalid cross-device link", + 19: "no such device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "numerical result out of range", + 35: "resource deadlock avoided", + 36: "file name too long", + 37: "no locks available", + 38: "function not implemented", + 39: "directory not empty", + 40: "too many levels of symbolic links", + 42: "no message of desired type", + 43: "identifier removed", + 44: "channel number out of range", + 45: "level 2 not synchronized", + 46: "level 3 halted", + 47: "level 3 reset", + 48: "link number out of range", + 49: "protocol driver not attached", + 50: "no CSI structure available", + 51: "level 2 halted", + 52: "invalid exchange", + 53: "invalid request descriptor", + 54: "exchange full", + 55: "no anode", + 56: "invalid request code", + 57: "invalid slot", + 59: "bad font file format", + 60: "device not a stream", + 61: "no data available", + 62: "timer expired", + 63: "out of streams resources", + 64: "machine is not on the network", + 65: "package not installed", + 66: "object is remote", + 67: "link has been severed", + 68: "advertise error", + 69: "srmount error", + 70: "communication error on send", + 71: "protocol error", + 72: "multihop attempted", + 73: "RFS specific error", + 74: "bad message", + 75: "value too large for defined data type", + 76: "name not unique on network", + 77: "file descriptor in bad state", + 78: "remote address changed", + 79: "can not access a needed shared library", + 80: "accessing a corrupted shared library", + 81: ".lib section in a.out corrupted", + 82: "attempting to link in too many shared libraries", + 83: "cannot exec a shared library directly", + 84: "invalid or incomplete multibyte or wide character", + 85: "interrupted system call should be restarted", + 86: "streams pipe error", + 87: "too many users", + 88: "socket operation on non-socket", + 89: "destination address required", + 90: "message too long", + 91: "protocol wrong type for socket", + 92: "protocol not available", + 93: "protocol not supported", + 94: "socket type not supported", + 95: "operation not supported", + 96: "protocol family not supported", + 97: "address family not supported by protocol", + 98: "address already in use", + 99: "cannot assign requested address", + 100: "network is down", + 101: "network is unreachable", + 102: "network dropped connection on reset", + 103: "software caused connection abort", + 104: "connection reset by peer", + 105: "no buffer space available", + 106: "transport endpoint is already connected", + 107: "transport endpoint is not connected", + 108: "cannot send after transport endpoint shutdown", + 109: "too many references: cannot splice", + 110: "connection timed out", + 111: "connection refused", + 112: "host is down", + 113: "no route to host", + 114: "operation already in progress", + 115: "operation now in progress", + 116: "stale NFS file handle", + 117: "structure needs cleaning", + 118: "not a XENIX named type file", + 119: "no XENIX semaphores available", + 120: "is a named type file", + 121: "remote I/O error", + 122: "disk quota exceeded", + 123: "no medium found", + 124: "wrong medium type", + 125: "operation canceled", + 126: "required key not available", + 127: "key has expired", + 128: "key has been revoked", + 129: "key was rejected by service", + 130: "owner died", + 131: "state not recoverable", + 132: "operation not possible due to RF-kill", + 133: "unknown error 133", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/breakpoint trap", + 6: "aborted", + 7: "bus error", + 8: "floating point exception", + 9: "killed", + 10: "user defined signal 1", + 11: "segmentation fault", + 12: "user defined signal 2", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "stack fault", + 17: "child exited", + 18: "continued", + 19: "stopped (signal)", + 20: "stopped", + 21: "stopped (tty input)", + 22: "stopped (tty output)", + 23: "urgent I/O condition", + 24: "CPU time limit exceeded", + 25: "file size limit exceeded", + 26: "virtual timer expired", + 27: "profiling timer expired", + 28: "window changed", + 29: "I/O possible", + 30: "power failure", + 31: "bad system call", +} diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go new file mode 100644 index 0000000000..16dcbc9cb2 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -0,0 +1,1897 @@ +// mkerrors.sh +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build arm64,linux + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- _const.go + +package unix + +import "syscall" + +const ( + AF_ALG = 0x26 + AF_APPLETALK = 0x5 + AF_ASH = 0x12 + AF_ATMPVC = 0x8 + AF_ATMSVC = 0x14 + AF_AX25 = 0x3 + AF_BLUETOOTH = 0x1f + AF_BRIDGE = 0x7 + AF_CAIF = 0x25 + AF_CAN = 0x1d + AF_DECnet = 0xc + AF_ECONET = 0x13 + AF_FILE = 0x1 + AF_IEEE802154 = 0x24 + AF_INET = 0x2 + AF_INET6 = 0xa + AF_IPX = 0x4 + AF_IRDA = 0x17 + AF_ISDN = 0x22 + AF_IUCV = 0x20 + AF_KEY = 0xf + AF_LLC = 0x1a + AF_LOCAL = 0x1 + AF_MAX = 0x29 + AF_NETBEUI = 0xd + AF_NETLINK = 0x10 + AF_NETROM = 0x6 + AF_NFC = 0x27 + AF_PACKET = 0x11 + AF_PHONET = 0x23 + AF_PPPOX = 0x18 + AF_RDS = 0x15 + AF_ROSE = 0xb + AF_ROUTE = 0x10 + AF_RXRPC = 0x21 + AF_SECURITY = 0xe + AF_SNA = 0x16 + AF_TIPC = 0x1e + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_VSOCK = 0x28 + AF_WANPIPE = 0x19 + AF_X25 = 0x9 + ARPHRD_ADAPT = 0x108 + ARPHRD_APPLETLK = 0x8 + ARPHRD_ARCNET = 0x7 + ARPHRD_ASH = 0x30d + ARPHRD_ATM = 0x13 + ARPHRD_AX25 = 0x3 + ARPHRD_BIF = 0x307 + ARPHRD_CAIF = 0x336 + ARPHRD_CAN = 0x118 + ARPHRD_CHAOS = 0x5 + ARPHRD_CISCO = 0x201 + ARPHRD_CSLIP = 0x101 + ARPHRD_CSLIP6 = 0x103 + ARPHRD_DDCMP = 0x205 + ARPHRD_DLCI = 0xf + ARPHRD_ECONET = 0x30e + ARPHRD_EETHER = 0x2 + ARPHRD_ETHER = 0x1 + ARPHRD_EUI64 = 0x1b + ARPHRD_FCAL = 0x311 + ARPHRD_FCFABRIC = 0x313 + ARPHRD_FCPL = 0x312 + ARPHRD_FCPP = 0x310 + ARPHRD_FDDI = 0x306 + ARPHRD_FRAD = 0x302 + ARPHRD_HDLC = 0x201 + ARPHRD_HIPPI = 0x30c + ARPHRD_HWX25 = 0x110 + ARPHRD_IEEE1394 = 0x18 + ARPHRD_IEEE802 = 0x6 + ARPHRD_IEEE80211 = 0x321 + ARPHRD_IEEE80211_PRISM = 0x322 + ARPHRD_IEEE80211_RADIOTAP = 0x323 + ARPHRD_IEEE802154 = 0x324 + ARPHRD_IEEE802154_MONITOR = 0x325 + ARPHRD_IEEE802_TR = 0x320 + ARPHRD_INFINIBAND = 0x20 + ARPHRD_IP6GRE = 0x337 + ARPHRD_IPDDP = 0x309 + ARPHRD_IPGRE = 0x30a + ARPHRD_IRDA = 0x30f + ARPHRD_LAPB = 0x204 + ARPHRD_LOCALTLK = 0x305 + ARPHRD_LOOPBACK = 0x304 + ARPHRD_METRICOM = 0x17 + ARPHRD_NETLINK = 0x338 + ARPHRD_NETROM = 0x0 + ARPHRD_NONE = 0xfffe + ARPHRD_PHONET = 0x334 + ARPHRD_PHONET_PIPE = 0x335 + ARPHRD_PIMREG = 0x30b + ARPHRD_PPP = 0x200 + ARPHRD_PRONET = 0x4 + ARPHRD_RAWHDLC = 0x206 + ARPHRD_ROSE = 0x10e + ARPHRD_RSRVD = 0x104 + ARPHRD_SIT = 0x308 + ARPHRD_SKIP = 0x303 + ARPHRD_SLIP = 0x100 + ARPHRD_SLIP6 = 0x102 + ARPHRD_TUNNEL = 0x300 + ARPHRD_TUNNEL6 = 0x301 + ARPHRD_VOID = 0xffff + ARPHRD_X25 = 0x10f + B0 = 0x0 + B1000000 = 0x1008 + B110 = 0x3 + B115200 = 0x1002 + B1152000 = 0x1009 + B1200 = 0x9 + B134 = 0x4 + B150 = 0x5 + B1500000 = 0x100a + B1800 = 0xa + B19200 = 0xe + B200 = 0x6 + B2000000 = 0x100b + B230400 = 0x1003 + B2400 = 0xb + B2500000 = 0x100c + B300 = 0x7 + B3000000 = 0x100d + B3500000 = 0x100e + B38400 = 0xf + B4000000 = 0x100f + B460800 = 0x1004 + B4800 = 0xc + B50 = 0x1 + B500000 = 0x1005 + B57600 = 0x1001 + B576000 = 0x1006 + B600 = 0x8 + B75 = 0x2 + B921600 = 0x1007 + B9600 = 0xd + BOTHER = 0x1000 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXINSNS = 0x1000 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MOD = 0x90 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BPF_XOR = 0xa0 + BRKINT = 0x2 + BS0 = 0x0 + BS1 = 0x2000 + BSDLY = 0x2000 + CBAUD = 0x100f + CBAUDEX = 0x1000 + CFLUSH = 0xf + CIBAUD = 0x100f0000 + CLOCAL = 0x800 + CLOCK_BOOTTIME = 0x7 + CLOCK_BOOTTIME_ALARM = 0x9 + CLOCK_DEFAULT = 0x0 + CLOCK_EXT = 0x1 + CLOCK_INT = 0x2 + CLOCK_MONOTONIC = 0x1 + CLOCK_MONOTONIC_COARSE = 0x6 + CLOCK_MONOTONIC_RAW = 0x4 + CLOCK_PROCESS_CPUTIME_ID = 0x2 + CLOCK_REALTIME = 0x0 + CLOCK_REALTIME_ALARM = 0x8 + CLOCK_REALTIME_COARSE = 0x5 + CLOCK_THREAD_CPUTIME_ID = 0x3 + CLOCK_TXFROMRX = 0x4 + CLOCK_TXINT = 0x3 + CLONE_CHILD_CLEARTID = 0x200000 + CLONE_CHILD_SETTID = 0x1000000 + CLONE_DETACHED = 0x400000 + CLONE_FILES = 0x400 + CLONE_FS = 0x200 + CLONE_IO = 0x80000000 + CLONE_NEWCGROUP = 0x2000000 + CLONE_NEWIPC = 0x8000000 + CLONE_NEWNET = 0x40000000 + CLONE_NEWNS = 0x20000 + CLONE_NEWPID = 0x20000000 + CLONE_NEWUSER = 0x10000000 + CLONE_NEWUTS = 0x4000000 + CLONE_PARENT = 0x8000 + CLONE_PARENT_SETTID = 0x100000 + CLONE_PTRACE = 0x2000 + CLONE_SETTLS = 0x80000 + CLONE_SIGHAND = 0x800 + CLONE_SYSVSEM = 0x40000 + CLONE_THREAD = 0x10000 + CLONE_UNTRACED = 0x800000 + CLONE_VFORK = 0x4000 + CLONE_VM = 0x100 + CMSPAR = 0x40000000 + CR0 = 0x0 + CR1 = 0x200 + CR2 = 0x400 + CR3 = 0x600 + CRDLY = 0x600 + CREAD = 0x80 + CRTSCTS = 0x80000000 + CS5 = 0x0 + CS6 = 0x10 + CS7 = 0x20 + CS8 = 0x30 + CSIGNAL = 0xff + CSIZE = 0x30 + CSTART = 0x11 + CSTATUS = 0x0 + CSTOP = 0x13 + CSTOPB = 0x40 + CSUSP = 0x1a + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x200 + ECHOE = 0x10 + ECHOK = 0x20 + ECHOKE = 0x800 + ECHONL = 0x40 + ECHOPRT = 0x400 + ELF_NGREG = 0x22 + ELF_PRARGSZ = 0x50 + ENCODING_DEFAULT = 0x0 + ENCODING_FM_MARK = 0x3 + ENCODING_FM_SPACE = 0x4 + ENCODING_MANCHESTER = 0x5 + ENCODING_NRZ = 0x1 + ENCODING_NRZI = 0x2 + EPOLLERR = 0x8 + EPOLLET = 0x80000000 + EPOLLHUP = 0x10 + EPOLLIN = 0x1 + EPOLLMSG = 0x400 + EPOLLONESHOT = 0x40000000 + EPOLLOUT = 0x4 + EPOLLPRI = 0x2 + EPOLLRDBAND = 0x80 + EPOLLRDHUP = 0x2000 + EPOLLRDNORM = 0x40 + EPOLLWAKEUP = 0x20000000 + EPOLLWRBAND = 0x200 + EPOLLWRNORM = 0x100 + EPOLL_CLOEXEC = 0x80000 + EPOLL_CTL_ADD = 0x1 + EPOLL_CTL_DEL = 0x2 + EPOLL_CTL_MOD = 0x3 + ETH_P_1588 = 0x88f7 + ETH_P_8021AD = 0x88a8 + ETH_P_8021AH = 0x88e7 + ETH_P_8021Q = 0x8100 + ETH_P_802_2 = 0x4 + ETH_P_802_3 = 0x1 + ETH_P_802_3_MIN = 0x600 + ETH_P_802_EX1 = 0x88b5 + ETH_P_AARP = 0x80f3 + ETH_P_AF_IUCV = 0xfbfb + ETH_P_ALL = 0x3 + ETH_P_AOE = 0x88a2 + ETH_P_ARCNET = 0x1a + ETH_P_ARP = 0x806 + ETH_P_ATALK = 0x809b + ETH_P_ATMFATE = 0x8884 + ETH_P_ATMMPOA = 0x884c + ETH_P_AX25 = 0x2 + ETH_P_BATMAN = 0x4305 + ETH_P_BPQ = 0x8ff + ETH_P_CAIF = 0xf7 + ETH_P_CAN = 0xc + ETH_P_CANFD = 0xd + ETH_P_CONTROL = 0x16 + ETH_P_CUST = 0x6006 + ETH_P_DDCMP = 0x6 + ETH_P_DEC = 0x6000 + ETH_P_DIAG = 0x6005 + ETH_P_DNA_DL = 0x6001 + ETH_P_DNA_RC = 0x6002 + ETH_P_DNA_RT = 0x6003 + ETH_P_DSA = 0x1b + ETH_P_ECONET = 0x18 + ETH_P_EDSA = 0xdada + ETH_P_FCOE = 0x8906 + ETH_P_FIP = 0x8914 + ETH_P_HDLC = 0x19 + ETH_P_IEEE802154 = 0xf6 + ETH_P_IEEEPUP = 0xa00 + ETH_P_IEEEPUPAT = 0xa01 + ETH_P_IP = 0x800 + ETH_P_IPV6 = 0x86dd + ETH_P_IPX = 0x8137 + ETH_P_IRDA = 0x17 + ETH_P_LAT = 0x6004 + ETH_P_LINK_CTL = 0x886c + ETH_P_LOCALTALK = 0x9 + ETH_P_LOOP = 0x60 + ETH_P_MOBITEX = 0x15 + ETH_P_MPLS_MC = 0x8848 + ETH_P_MPLS_UC = 0x8847 + ETH_P_MVRP = 0x88f5 + ETH_P_PAE = 0x888e + ETH_P_PAUSE = 0x8808 + ETH_P_PHONET = 0xf5 + ETH_P_PPPTALK = 0x10 + ETH_P_PPP_DISC = 0x8863 + ETH_P_PPP_MP = 0x8 + ETH_P_PPP_SES = 0x8864 + ETH_P_PRP = 0x88fb + ETH_P_PUP = 0x200 + ETH_P_PUPAT = 0x201 + ETH_P_QINQ1 = 0x9100 + ETH_P_QINQ2 = 0x9200 + ETH_P_QINQ3 = 0x9300 + ETH_P_RARP = 0x8035 + ETH_P_SCA = 0x6007 + ETH_P_SLOW = 0x8809 + ETH_P_SNAP = 0x5 + ETH_P_TDLS = 0x890d + ETH_P_TEB = 0x6558 + ETH_P_TIPC = 0x88ca + ETH_P_TRAILER = 0x1c + ETH_P_TR_802_2 = 0x11 + ETH_P_WAN_PPP = 0x7 + ETH_P_WCCP = 0x883e + ETH_P_X25 = 0x805 + EXTA = 0xe + EXTB = 0xf + EXTPROC = 0x10000 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FF0 = 0x0 + FF1 = 0x8000 + FFDLY = 0x8000 + FLUSHO = 0x1000 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x406 + F_EXLCK = 0x4 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLEASE = 0x401 + F_GETLK = 0x5 + F_GETLK64 = 0x5 + F_GETOWN = 0x9 + F_GETOWN_EX = 0x10 + F_GETPIPE_SZ = 0x408 + F_GETSIG = 0xb + F_LOCK = 0x1 + F_NOTIFY = 0x402 + F_OK = 0x0 + F_RDLCK = 0x0 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLEASE = 0x400 + F_SETLK = 0x6 + F_SETLK64 = 0x6 + F_SETLKW = 0x7 + F_SETLKW64 = 0x7 + F_SETOWN = 0x8 + F_SETOWN_EX = 0xf + F_SETPIPE_SZ = 0x407 + F_SETSIG = 0xa + F_SHLCK = 0x8 + F_TEST = 0x3 + F_TLOCK = 0x2 + F_ULOCK = 0x0 + F_UNLCK = 0x2 + F_WRLCK = 0x1 + HUPCL = 0x400 + IBSHIFT = 0x10 + ICANON = 0x2 + ICMPV6_FILTER = 0x1 + ICRNL = 0x100 + IEXTEN = 0x8000 + IFA_F_DADFAILED = 0x8 + IFA_F_DEPRECATED = 0x20 + IFA_F_HOMEADDRESS = 0x10 + IFA_F_NODAD = 0x2 + IFA_F_OPTIMISTIC = 0x4 + IFA_F_PERMANENT = 0x80 + IFA_F_SECONDARY = 0x1 + IFA_F_TEMPORARY = 0x1 + IFA_F_TENTATIVE = 0x40 + IFA_MAX = 0x7 + IFF_802_1Q_VLAN = 0x1 + IFF_ALLMULTI = 0x200 + IFF_ATTACH_QUEUE = 0x200 + IFF_AUTOMEDIA = 0x4000 + IFF_BONDING = 0x20 + IFF_BRIDGE_PORT = 0x4000 + IFF_BROADCAST = 0x2 + IFF_DEBUG = 0x4 + IFF_DETACH_QUEUE = 0x400 + IFF_DISABLE_NETPOLL = 0x1000 + IFF_DONT_BRIDGE = 0x800 + IFF_DORMANT = 0x20000 + IFF_DYNAMIC = 0x8000 + IFF_EBRIDGE = 0x2 + IFF_ECHO = 0x40000 + IFF_ISATAP = 0x80 + IFF_LIVE_ADDR_CHANGE = 0x100000 + IFF_LOOPBACK = 0x8 + IFF_LOWER_UP = 0x10000 + IFF_MACVLAN = 0x200000 + IFF_MACVLAN_PORT = 0x2000 + IFF_MASTER = 0x400 + IFF_MASTER_8023AD = 0x8 + IFF_MASTER_ALB = 0x10 + IFF_MASTER_ARPMON = 0x100 + IFF_MULTICAST = 0x1000 + IFF_MULTI_QUEUE = 0x100 + IFF_NOARP = 0x80 + IFF_NOFILTER = 0x1000 + IFF_NOTRAILERS = 0x20 + IFF_NO_PI = 0x1000 + IFF_ONE_QUEUE = 0x2000 + IFF_OVS_DATAPATH = 0x8000 + IFF_PERSIST = 0x800 + IFF_POINTOPOINT = 0x10 + IFF_PORTSEL = 0x2000 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SLAVE = 0x800 + IFF_SLAVE_INACTIVE = 0x4 + IFF_SLAVE_NEEDARP = 0x40 + IFF_SUPP_NOFCS = 0x80000 + IFF_TAP = 0x2 + IFF_TEAM_PORT = 0x40000 + IFF_TUN = 0x1 + IFF_TUN_EXCL = 0x8000 + IFF_TX_SKB_SHARING = 0x10000 + IFF_UNICAST_FLT = 0x20000 + IFF_UP = 0x1 + IFF_VNET_HDR = 0x4000 + IFF_VOLATILE = 0x70c5a + IFF_WAN_HDLC = 0x200 + IFF_XMIT_DST_RELEASE = 0x400 + IFNAMSIZ = 0x10 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_ACCESS = 0x1 + IN_ALL_EVENTS = 0xfff + IN_ATTRIB = 0x4 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLOEXEC = 0x80000 + IN_CLOSE = 0x18 + IN_CLOSE_NOWRITE = 0x10 + IN_CLOSE_WRITE = 0x8 + IN_CREATE = 0x100 + IN_DELETE = 0x200 + IN_DELETE_SELF = 0x400 + IN_DONT_FOLLOW = 0x2000000 + IN_EXCL_UNLINK = 0x4000000 + IN_IGNORED = 0x8000 + IN_ISDIR = 0x40000000 + IN_LOOPBACKNET = 0x7f + IN_MASK_ADD = 0x20000000 + IN_MODIFY = 0x2 + IN_MOVE = 0xc0 + IN_MOVED_FROM = 0x40 + IN_MOVED_TO = 0x80 + IN_MOVE_SELF = 0x800 + IN_NONBLOCK = 0x800 + IN_ONESHOT = 0x80000000 + IN_ONLYDIR = 0x1000000 + IN_OPEN = 0x20 + IN_Q_OVERFLOW = 0x4000 + IN_UNMOUNT = 0x2000 + IPPROTO_AH = 0x33 + IPPROTO_BEETPH = 0x5e + IPPROTO_COMP = 0x6c + IPPROTO_DCCP = 0x21 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_ENCAP = 0x62 + IPPROTO_ESP = 0x32 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GRE = 0x2f + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IGMP = 0x2 + IPPROTO_IP = 0x0 + IPPROTO_IPIP = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_MH = 0x87 + IPPROTO_MTP = 0x5c + IPPROTO_NONE = 0x3b + IPPROTO_PIM = 0x67 + IPPROTO_PUP = 0xc + IPPROTO_RAW = 0xff + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_SCTP = 0x84 + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_UDP = 0x11 + IPPROTO_UDPLITE = 0x88 + IPV6_2292DSTOPTS = 0x4 + IPV6_2292HOPLIMIT = 0x8 + IPV6_2292HOPOPTS = 0x3 + IPV6_2292PKTINFO = 0x2 + IPV6_2292PKTOPTIONS = 0x6 + IPV6_2292RTHDR = 0x5 + IPV6_ADDRFORM = 0x1 + IPV6_ADD_MEMBERSHIP = 0x14 + IPV6_AUTHHDR = 0xa + IPV6_CHECKSUM = 0x7 + IPV6_DROP_MEMBERSHIP = 0x15 + IPV6_DSTOPTS = 0x3b + IPV6_HOPLIMIT = 0x34 + IPV6_HOPOPTS = 0x36 + IPV6_IPSEC_POLICY = 0x22 + IPV6_JOIN_ANYCAST = 0x1b + IPV6_JOIN_GROUP = 0x14 + IPV6_LEAVE_ANYCAST = 0x1c + IPV6_LEAVE_GROUP = 0x15 + IPV6_MTU = 0x18 + IPV6_MTU_DISCOVER = 0x17 + IPV6_MULTICAST_HOPS = 0x12 + IPV6_MULTICAST_IF = 0x11 + IPV6_MULTICAST_LOOP = 0x13 + IPV6_NEXTHOP = 0x9 + IPV6_PKTINFO = 0x32 + IPV6_PMTUDISC_DO = 0x2 + IPV6_PMTUDISC_DONT = 0x0 + IPV6_PMTUDISC_PROBE = 0x3 + IPV6_PMTUDISC_WANT = 0x1 + IPV6_RECVDSTOPTS = 0x3a + IPV6_RECVERR = 0x19 + IPV6_RECVHOPLIMIT = 0x33 + IPV6_RECVHOPOPTS = 0x35 + IPV6_RECVPKTINFO = 0x31 + IPV6_RECVRTHDR = 0x38 + IPV6_RECVTCLASS = 0x42 + IPV6_ROUTER_ALERT = 0x16 + IPV6_RTHDR = 0x39 + IPV6_RTHDRDSTOPTS = 0x37 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_RXDSTOPTS = 0x3b + IPV6_RXHOPOPTS = 0x36 + IPV6_TCLASS = 0x43 + IPV6_UNICAST_HOPS = 0x10 + IPV6_V6ONLY = 0x1a + IPV6_XFRM_POLICY = 0x23 + IP_ADD_MEMBERSHIP = 0x23 + IP_ADD_SOURCE_MEMBERSHIP = 0x27 + IP_BLOCK_SOURCE = 0x26 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DROP_MEMBERSHIP = 0x24 + IP_DROP_SOURCE_MEMBERSHIP = 0x28 + IP_FREEBIND = 0xf + IP_HDRINCL = 0x3 + IP_IPSEC_POLICY = 0x10 + IP_MAXPACKET = 0xffff + IP_MAX_MEMBERSHIPS = 0x14 + IP_MF = 0x2000 + IP_MINTTL = 0x15 + IP_MSFILTER = 0x29 + IP_MSS = 0x240 + IP_MTU = 0xe + IP_MTU_DISCOVER = 0xa + IP_MULTICAST_ALL = 0x31 + IP_MULTICAST_IF = 0x20 + IP_MULTICAST_LOOP = 0x22 + IP_MULTICAST_TTL = 0x21 + IP_OFFMASK = 0x1fff + IP_OPTIONS = 0x4 + IP_ORIGDSTADDR = 0x14 + IP_PASSSEC = 0x12 + IP_PKTINFO = 0x8 + IP_PKTOPTIONS = 0x9 + IP_PMTUDISC = 0xa + IP_PMTUDISC_DO = 0x2 + IP_PMTUDISC_DONT = 0x0 + IP_PMTUDISC_PROBE = 0x3 + IP_PMTUDISC_WANT = 0x1 + IP_RECVERR = 0xb + IP_RECVOPTS = 0x6 + IP_RECVORIGDSTADDR = 0x14 + IP_RECVRETOPTS = 0x7 + IP_RECVTOS = 0xd + IP_RECVTTL = 0xc + IP_RETOPTS = 0x7 + IP_RF = 0x8000 + IP_ROUTER_ALERT = 0x5 + IP_TOS = 0x1 + IP_TRANSPARENT = 0x13 + IP_TTL = 0x2 + IP_UNBLOCK_SOURCE = 0x25 + IP_UNICAST_IF = 0x32 + IP_XFRM_POLICY = 0x11 + ISIG = 0x1 + ISTRIP = 0x20 + IUCLC = 0x200 + IUTF8 = 0x4000 + IXANY = 0x800 + IXOFF = 0x1000 + IXON = 0x400 + LINUX_REBOOT_CMD_CAD_OFF = 0x0 + LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef + LINUX_REBOOT_CMD_HALT = 0xcdef0123 + LINUX_REBOOT_CMD_KEXEC = 0x45584543 + LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc + LINUX_REBOOT_CMD_RESTART = 0x1234567 + LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4 + LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2 + LINUX_REBOOT_MAGIC1 = 0xfee1dead + LINUX_REBOOT_MAGIC2 = 0x28121969 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_DODUMP = 0x11 + MADV_DOFORK = 0xb + MADV_DONTDUMP = 0x10 + MADV_DONTFORK = 0xa + MADV_DONTNEED = 0x4 + MADV_HUGEPAGE = 0xe + MADV_HWPOISON = 0x64 + MADV_MERGEABLE = 0xc + MADV_NOHUGEPAGE = 0xf + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_REMOVE = 0x9 + MADV_SEQUENTIAL = 0x2 + MADV_UNMERGEABLE = 0xd + MADV_WILLNEED = 0x3 + MAP_ANON = 0x20 + MAP_ANONYMOUS = 0x20 + MAP_DENYWRITE = 0x800 + MAP_EXECUTABLE = 0x1000 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_GROWSDOWN = 0x100 + MAP_HUGETLB = 0x40000 + MAP_HUGE_MASK = 0x3f + MAP_HUGE_SHIFT = 0x1a + MAP_LOCKED = 0x2000 + MAP_NONBLOCK = 0x10000 + MAP_NORESERVE = 0x4000 + MAP_POPULATE = 0x8000 + MAP_PRIVATE = 0x2 + MAP_SHARED = 0x1 + MAP_STACK = 0x20000 + MAP_TYPE = 0xf + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MNT_DETACH = 0x2 + MNT_EXPIRE = 0x4 + MNT_FORCE = 0x1 + MSG_CMSG_CLOEXEC = 0x40000000 + MSG_CONFIRM = 0x800 + MSG_CTRUNC = 0x8 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x40 + MSG_EOR = 0x80 + MSG_ERRQUEUE = 0x2000 + MSG_FASTOPEN = 0x20000000 + MSG_FIN = 0x200 + MSG_MORE = 0x8000 + MSG_NOSIGNAL = 0x4000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_PROXY = 0x10 + MSG_RST = 0x1000 + MSG_SYN = 0x400 + MSG_TRUNC = 0x20 + MSG_TRYHARD = 0x4 + MSG_WAITALL = 0x100 + MSG_WAITFORONE = 0x10000 + MS_ACTIVE = 0x40000000 + MS_ASYNC = 0x1 + MS_BIND = 0x1000 + MS_DIRSYNC = 0x80 + MS_INVALIDATE = 0x2 + MS_I_VERSION = 0x800000 + MS_KERNMOUNT = 0x400000 + MS_MANDLOCK = 0x40 + MS_MGC_MSK = 0xffff0000 + MS_MGC_VAL = 0xc0ed0000 + MS_MOVE = 0x2000 + MS_NOATIME = 0x400 + MS_NODEV = 0x4 + MS_NODIRATIME = 0x800 + MS_NOEXEC = 0x8 + MS_NOSUID = 0x2 + MS_NOUSER = -0x80000000 + MS_POSIXACL = 0x10000 + MS_PRIVATE = 0x40000 + MS_RDONLY = 0x1 + MS_REC = 0x4000 + MS_RELATIME = 0x200000 + MS_REMOUNT = 0x20 + MS_RMT_MASK = 0x800051 + MS_SHARED = 0x100000 + MS_SILENT = 0x8000 + MS_SLAVE = 0x80000 + MS_STRICTATIME = 0x1000000 + MS_SYNC = 0x4 + MS_SYNCHRONOUS = 0x10 + MS_UNBINDABLE = 0x20000 + NAME_MAX = 0xff + NETLINK_ADD_MEMBERSHIP = 0x1 + NETLINK_AUDIT = 0x9 + NETLINK_BROADCAST_ERROR = 0x4 + NETLINK_CONNECTOR = 0xb + NETLINK_CRYPTO = 0x15 + NETLINK_DNRTMSG = 0xe + NETLINK_DROP_MEMBERSHIP = 0x2 + NETLINK_ECRYPTFS = 0x13 + NETLINK_FIB_LOOKUP = 0xa + NETLINK_FIREWALL = 0x3 + NETLINK_GENERIC = 0x10 + NETLINK_INET_DIAG = 0x4 + NETLINK_IP6_FW = 0xd + NETLINK_ISCSI = 0x8 + NETLINK_KOBJECT_UEVENT = 0xf + NETLINK_NETFILTER = 0xc + NETLINK_NFLOG = 0x5 + NETLINK_NO_ENOBUFS = 0x5 + NETLINK_PKTINFO = 0x3 + NETLINK_RDMA = 0x14 + NETLINK_ROUTE = 0x0 + NETLINK_RX_RING = 0x6 + NETLINK_SCSITRANSPORT = 0x12 + NETLINK_SELINUX = 0x7 + NETLINK_SOCK_DIAG = 0x4 + NETLINK_TX_RING = 0x7 + NETLINK_UNUSED = 0x1 + NETLINK_USERSOCK = 0x2 + NETLINK_XFRM = 0x6 + NL0 = 0x0 + NL1 = 0x100 + NLA_ALIGNTO = 0x4 + NLA_F_NESTED = 0x8000 + NLA_F_NET_BYTEORDER = 0x4000 + NLA_HDRLEN = 0x4 + NLDLY = 0x100 + NLMSG_ALIGNTO = 0x4 + NLMSG_DONE = 0x3 + NLMSG_ERROR = 0x2 + NLMSG_HDRLEN = 0x10 + NLMSG_MIN_TYPE = 0x10 + NLMSG_NOOP = 0x1 + NLMSG_OVERRUN = 0x4 + NLM_F_ACK = 0x4 + NLM_F_APPEND = 0x800 + NLM_F_ATOMIC = 0x400 + NLM_F_CREATE = 0x400 + NLM_F_DUMP = 0x300 + NLM_F_DUMP_INTR = 0x10 + NLM_F_ECHO = 0x8 + NLM_F_EXCL = 0x200 + NLM_F_MATCH = 0x200 + NLM_F_MULTI = 0x2 + NLM_F_REPLACE = 0x100 + NLM_F_REQUEST = 0x1 + NLM_F_ROOT = 0x100 + NOFLSH = 0x80 + OCRNL = 0x8 + OFDEL = 0x80 + OFILL = 0x40 + OLCUC = 0x2 + ONLCR = 0x4 + ONLRET = 0x20 + ONOCR = 0x10 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_APPEND = 0x400 + O_ASYNC = 0x2000 + O_CLOEXEC = 0x80000 + O_CREAT = 0x40 + O_DIRECT = 0x10000 + O_DIRECTORY = 0x4000 + O_DSYNC = 0x1000 + O_EXCL = 0x80 + O_FSYNC = 0x101000 + O_LARGEFILE = 0x0 + O_NDELAY = 0x800 + O_NOATIME = 0x40000 + O_NOCTTY = 0x100 + O_NOFOLLOW = 0x8000 + O_NONBLOCK = 0x800 + O_PATH = 0x200000 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_RSYNC = 0x101000 + O_SYNC = 0x101000 + O_TMPFILE = 0x410000 + O_TRUNC = 0x200 + O_WRONLY = 0x1 + PACKET_ADD_MEMBERSHIP = 0x1 + PACKET_AUXDATA = 0x8 + PACKET_BROADCAST = 0x1 + PACKET_COPY_THRESH = 0x7 + PACKET_DROP_MEMBERSHIP = 0x2 + PACKET_FANOUT = 0x12 + PACKET_FANOUT_CPU = 0x2 + PACKET_FANOUT_FLAG_DEFRAG = 0x8000 + PACKET_FANOUT_FLAG_ROLLOVER = 0x1000 + PACKET_FANOUT_HASH = 0x0 + PACKET_FANOUT_LB = 0x1 + PACKET_FANOUT_RND = 0x4 + PACKET_FANOUT_ROLLOVER = 0x3 + PACKET_FASTROUTE = 0x6 + PACKET_HDRLEN = 0xb + PACKET_HOST = 0x0 + PACKET_LOOPBACK = 0x5 + PACKET_LOSS = 0xe + PACKET_MR_ALLMULTI = 0x2 + PACKET_MR_MULTICAST = 0x0 + PACKET_MR_PROMISC = 0x1 + PACKET_MR_UNICAST = 0x3 + PACKET_MULTICAST = 0x2 + PACKET_ORIGDEV = 0x9 + PACKET_OTHERHOST = 0x3 + PACKET_OUTGOING = 0x4 + PACKET_RECV_OUTPUT = 0x3 + PACKET_RESERVE = 0xc + PACKET_RX_RING = 0x5 + PACKET_STATISTICS = 0x6 + PACKET_TIMESTAMP = 0x11 + PACKET_TX_HAS_OFF = 0x13 + PACKET_TX_RING = 0xd + PACKET_TX_TIMESTAMP = 0x10 + PACKET_VERSION = 0xa + PACKET_VNET_HDR = 0xf + PARENB = 0x100 + PARITY_CRC16_PR0 = 0x2 + PARITY_CRC16_PR0_CCITT = 0x4 + PARITY_CRC16_PR1 = 0x3 + PARITY_CRC16_PR1_CCITT = 0x5 + PARITY_CRC32_PR0_CCITT = 0x6 + PARITY_CRC32_PR1_CCITT = 0x7 + PARITY_DEFAULT = 0x0 + PARITY_NONE = 0x1 + PARMRK = 0x8 + PARODD = 0x200 + PENDIN = 0x4000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_GROWSDOWN = 0x1000000 + PROT_GROWSUP = 0x2000000 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + PR_CAPBSET_DROP = 0x18 + PR_CAPBSET_READ = 0x17 + PR_ENDIAN_BIG = 0x0 + PR_ENDIAN_LITTLE = 0x1 + PR_ENDIAN_PPC_LITTLE = 0x2 + PR_FPEMU_NOPRINT = 0x1 + PR_FPEMU_SIGFPE = 0x2 + PR_FP_EXC_ASYNC = 0x2 + PR_FP_EXC_DISABLED = 0x0 + PR_FP_EXC_DIV = 0x10000 + PR_FP_EXC_INV = 0x100000 + PR_FP_EXC_NONRECOV = 0x1 + PR_FP_EXC_OVF = 0x20000 + PR_FP_EXC_PRECISE = 0x3 + PR_FP_EXC_RES = 0x80000 + PR_FP_EXC_SW_ENABLE = 0x80 + PR_FP_EXC_UND = 0x40000 + PR_GET_CHILD_SUBREAPER = 0x25 + PR_GET_DUMPABLE = 0x3 + PR_GET_ENDIAN = 0x13 + PR_GET_FPEMU = 0x9 + PR_GET_FPEXC = 0xb + PR_GET_KEEPCAPS = 0x7 + PR_GET_NAME = 0x10 + PR_GET_NO_NEW_PRIVS = 0x27 + PR_GET_PDEATHSIG = 0x2 + PR_GET_SECCOMP = 0x15 + PR_GET_SECUREBITS = 0x1b + PR_GET_TID_ADDRESS = 0x28 + PR_GET_TIMERSLACK = 0x1e + PR_GET_TIMING = 0xd + PR_GET_TSC = 0x19 + PR_GET_UNALIGN = 0x5 + PR_MCE_KILL = 0x21 + PR_MCE_KILL_CLEAR = 0x0 + PR_MCE_KILL_DEFAULT = 0x2 + PR_MCE_KILL_EARLY = 0x1 + PR_MCE_KILL_GET = 0x22 + PR_MCE_KILL_LATE = 0x0 + PR_MCE_KILL_SET = 0x1 + PR_SET_CHILD_SUBREAPER = 0x24 + PR_SET_DUMPABLE = 0x4 + PR_SET_ENDIAN = 0x14 + PR_SET_FPEMU = 0xa + PR_SET_FPEXC = 0xc + PR_SET_KEEPCAPS = 0x8 + PR_SET_MM = 0x23 + PR_SET_MM_ARG_END = 0x9 + PR_SET_MM_ARG_START = 0x8 + PR_SET_MM_AUXV = 0xc + PR_SET_MM_BRK = 0x7 + PR_SET_MM_END_CODE = 0x2 + PR_SET_MM_END_DATA = 0x4 + PR_SET_MM_ENV_END = 0xb + PR_SET_MM_ENV_START = 0xa + PR_SET_MM_EXE_FILE = 0xd + PR_SET_MM_START_BRK = 0x6 + PR_SET_MM_START_CODE = 0x1 + PR_SET_MM_START_DATA = 0x3 + PR_SET_MM_START_STACK = 0x5 + PR_SET_NAME = 0xf + PR_SET_NO_NEW_PRIVS = 0x26 + PR_SET_PDEATHSIG = 0x1 + PR_SET_PTRACER = 0x59616d61 + PR_SET_PTRACER_ANY = -0x1 + PR_SET_SECCOMP = 0x16 + PR_SET_SECUREBITS = 0x1c + PR_SET_TIMERSLACK = 0x1d + PR_SET_TIMING = 0xe + PR_SET_TSC = 0x1a + PR_SET_UNALIGN = 0x6 + PR_TASK_PERF_EVENTS_DISABLE = 0x1f + PR_TASK_PERF_EVENTS_ENABLE = 0x20 + PR_TIMING_STATISTICAL = 0x0 + PR_TIMING_TIMESTAMP = 0x1 + PR_TSC_ENABLE = 0x1 + PR_TSC_SIGSEGV = 0x2 + PR_UNALIGN_NOPRINT = 0x1 + PR_UNALIGN_SIGBUS = 0x2 + PTRACE_ATTACH = 0x10 + PTRACE_CONT = 0x7 + PTRACE_DETACH = 0x11 + PTRACE_EVENT_CLONE = 0x3 + PTRACE_EVENT_EXEC = 0x4 + PTRACE_EVENT_EXIT = 0x6 + PTRACE_EVENT_FORK = 0x1 + PTRACE_EVENT_SECCOMP = 0x7 + PTRACE_EVENT_STOP = 0x80 + PTRACE_EVENT_VFORK = 0x2 + PTRACE_EVENT_VFORK_DONE = 0x5 + PTRACE_GETEVENTMSG = 0x4201 + PTRACE_GETREGS = 0xc + PTRACE_GETREGSET = 0x4204 + PTRACE_GETSIGINFO = 0x4202 + PTRACE_GETSIGMASK = 0x420a + PTRACE_INTERRUPT = 0x4207 + PTRACE_KILL = 0x8 + PTRACE_LISTEN = 0x4208 + PTRACE_O_EXITKILL = 0x100000 + PTRACE_O_MASK = 0x1000ff + PTRACE_O_TRACECLONE = 0x8 + PTRACE_O_TRACEEXEC = 0x10 + PTRACE_O_TRACEEXIT = 0x40 + PTRACE_O_TRACEFORK = 0x2 + PTRACE_O_TRACESECCOMP = 0x80 + PTRACE_O_TRACESYSGOOD = 0x1 + PTRACE_O_TRACEVFORK = 0x4 + PTRACE_O_TRACEVFORKDONE = 0x20 + PTRACE_PEEKDATA = 0x2 + PTRACE_PEEKSIGINFO = 0x4209 + PTRACE_PEEKSIGINFO_SHARED = 0x1 + PTRACE_PEEKTEXT = 0x1 + PTRACE_PEEKUSR = 0x3 + PTRACE_POKEDATA = 0x5 + PTRACE_POKETEXT = 0x4 + PTRACE_POKEUSR = 0x6 + PTRACE_SEIZE = 0x4206 + PTRACE_SETOPTIONS = 0x4200 + PTRACE_SETREGS = 0xd + PTRACE_SETREGSET = 0x4205 + PTRACE_SETSIGINFO = 0x4203 + PTRACE_SETSIGMASK = 0x420b + PTRACE_SINGLESTEP = 0x9 + PTRACE_SYSCALL = 0x18 + PTRACE_TRACEME = 0x0 + RLIMIT_AS = 0x9 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x7 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = -0x1 + RTAX_ADVMSS = 0x8 + RTAX_CWND = 0x7 + RTAX_FEATURES = 0xc + RTAX_FEATURE_ALLFRAG = 0x8 + RTAX_FEATURE_ECN = 0x1 + RTAX_FEATURE_SACK = 0x2 + RTAX_FEATURE_TIMESTAMP = 0x4 + RTAX_HOPLIMIT = 0xa + RTAX_INITCWND = 0xb + RTAX_INITRWND = 0xe + RTAX_LOCK = 0x1 + RTAX_MAX = 0xf + RTAX_MTU = 0x2 + RTAX_QUICKACK = 0xf + RTAX_REORDERING = 0x9 + RTAX_RTO_MIN = 0xd + RTAX_RTT = 0x4 + RTAX_RTTVAR = 0x5 + RTAX_SSTHRESH = 0x6 + RTAX_UNSPEC = 0x0 + RTAX_WINDOW = 0x3 + RTA_ALIGNTO = 0x4 + RTA_MAX = 0x11 + RTCF_DIRECTSRC = 0x4000000 + RTCF_DOREDIRECT = 0x1000000 + RTCF_LOG = 0x2000000 + RTCF_MASQ = 0x400000 + RTCF_NAT = 0x800000 + RTCF_VALVE = 0x200000 + RTF_ADDRCLASSMASK = 0xf8000000 + RTF_ADDRCONF = 0x40000 + RTF_ALLONLINK = 0x20000 + RTF_BROADCAST = 0x10000000 + RTF_CACHE = 0x1000000 + RTF_DEFAULT = 0x10000 + RTF_DYNAMIC = 0x10 + RTF_FLOW = 0x2000000 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_INTERFACE = 0x40000000 + RTF_IRTT = 0x100 + RTF_LINKRT = 0x100000 + RTF_LOCAL = 0x80000000 + RTF_MODIFIED = 0x20 + RTF_MSS = 0x40 + RTF_MTU = 0x40 + RTF_MULTICAST = 0x20000000 + RTF_NAT = 0x8000000 + RTF_NOFORWARD = 0x1000 + RTF_NONEXTHOP = 0x200000 + RTF_NOPMTUDISC = 0x4000 + RTF_POLICY = 0x4000000 + RTF_REINSTATE = 0x8 + RTF_REJECT = 0x200 + RTF_STATIC = 0x400 + RTF_THROW = 0x2000 + RTF_UP = 0x1 + RTF_WINDOW = 0x80 + RTF_XRESOLVE = 0x800 + RTM_BASE = 0x10 + RTM_DELACTION = 0x31 + RTM_DELADDR = 0x15 + RTM_DELADDRLABEL = 0x49 + RTM_DELLINK = 0x11 + RTM_DELMDB = 0x55 + RTM_DELNEIGH = 0x1d + RTM_DELQDISC = 0x25 + RTM_DELROUTE = 0x19 + RTM_DELRULE = 0x21 + RTM_DELTCLASS = 0x29 + RTM_DELTFILTER = 0x2d + RTM_F_CLONED = 0x200 + RTM_F_EQUALIZE = 0x400 + RTM_F_NOTIFY = 0x100 + RTM_F_PREFIX = 0x800 + RTM_GETACTION = 0x32 + RTM_GETADDR = 0x16 + RTM_GETADDRLABEL = 0x4a + RTM_GETANYCAST = 0x3e + RTM_GETDCB = 0x4e + RTM_GETLINK = 0x12 + RTM_GETMDB = 0x56 + RTM_GETMULTICAST = 0x3a + RTM_GETNEIGH = 0x1e + RTM_GETNEIGHTBL = 0x42 + RTM_GETNETCONF = 0x52 + RTM_GETQDISC = 0x26 + RTM_GETROUTE = 0x1a + RTM_GETRULE = 0x22 + RTM_GETTCLASS = 0x2a + RTM_GETTFILTER = 0x2e + RTM_MAX = 0x57 + RTM_NEWACTION = 0x30 + RTM_NEWADDR = 0x14 + RTM_NEWADDRLABEL = 0x48 + RTM_NEWLINK = 0x10 + RTM_NEWMDB = 0x54 + RTM_NEWNDUSEROPT = 0x44 + RTM_NEWNEIGH = 0x1c + RTM_NEWNEIGHTBL = 0x40 + RTM_NEWNETCONF = 0x50 + RTM_NEWPREFIX = 0x34 + RTM_NEWQDISC = 0x24 + RTM_NEWROUTE = 0x18 + RTM_NEWRULE = 0x20 + RTM_NEWTCLASS = 0x28 + RTM_NEWTFILTER = 0x2c + RTM_NR_FAMILIES = 0x12 + RTM_NR_MSGTYPES = 0x48 + RTM_SETDCB = 0x4f + RTM_SETLINK = 0x13 + RTM_SETNEIGHTBL = 0x43 + RTNH_ALIGNTO = 0x4 + RTNH_F_DEAD = 0x1 + RTNH_F_ONLINK = 0x4 + RTNH_F_PERVASIVE = 0x2 + RTN_MAX = 0xb + RTPROT_BIRD = 0xc + RTPROT_BOOT = 0x3 + RTPROT_DHCP = 0x10 + RTPROT_DNROUTED = 0xd + RTPROT_GATED = 0x8 + RTPROT_KERNEL = 0x2 + RTPROT_MROUTED = 0x11 + RTPROT_MRT = 0xa + RTPROT_NTK = 0xf + RTPROT_RA = 0x9 + RTPROT_REDIRECT = 0x1 + RTPROT_STATIC = 0x4 + RTPROT_UNSPEC = 0x0 + RTPROT_XORP = 0xe + RTPROT_ZEBRA = 0xb + RT_CLASS_DEFAULT = 0xfd + RT_CLASS_LOCAL = 0xff + RT_CLASS_MAIN = 0xfe + RT_CLASS_MAX = 0xff + RT_CLASS_UNSPEC = 0x0 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + RUSAGE_THREAD = 0x1 + SCM_CREDENTIALS = 0x2 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x1d + SCM_TIMESTAMPING = 0x25 + SCM_TIMESTAMPNS = 0x23 + SCM_WIFI_STATUS = 0x29 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDDLCI = 0x8980 + SIOCADDMULTI = 0x8931 + SIOCADDRT = 0x890b + SIOCATMARK = 0x8905 + SIOCDARP = 0x8953 + SIOCDELDLCI = 0x8981 + SIOCDELMULTI = 0x8932 + SIOCDELRT = 0x890c + SIOCDEVPRIVATE = 0x89f0 + SIOCDIFADDR = 0x8936 + SIOCDRARP = 0x8960 + SIOCGARP = 0x8954 + SIOCGIFADDR = 0x8915 + SIOCGIFBR = 0x8940 + SIOCGIFBRDADDR = 0x8919 + SIOCGIFCONF = 0x8912 + SIOCGIFCOUNT = 0x8938 + SIOCGIFDSTADDR = 0x8917 + SIOCGIFENCAP = 0x8925 + SIOCGIFFLAGS = 0x8913 + SIOCGIFHWADDR = 0x8927 + SIOCGIFINDEX = 0x8933 + SIOCGIFMAP = 0x8970 + SIOCGIFMEM = 0x891f + SIOCGIFMETRIC = 0x891d + SIOCGIFMTU = 0x8921 + SIOCGIFNAME = 0x8910 + SIOCGIFNETMASK = 0x891b + SIOCGIFPFLAGS = 0x8935 + SIOCGIFSLAVE = 0x8929 + SIOCGIFTXQLEN = 0x8942 + SIOCGPGRP = 0x8904 + SIOCGRARP = 0x8961 + SIOCGSTAMP = 0x8906 + SIOCGSTAMPNS = 0x8907 + SIOCPROTOPRIVATE = 0x89e0 + SIOCRTMSG = 0x890d + SIOCSARP = 0x8955 + SIOCSIFADDR = 0x8916 + SIOCSIFBR = 0x8941 + SIOCSIFBRDADDR = 0x891a + SIOCSIFDSTADDR = 0x8918 + SIOCSIFENCAP = 0x8926 + SIOCSIFFLAGS = 0x8914 + SIOCSIFHWADDR = 0x8924 + SIOCSIFHWBROADCAST = 0x8937 + SIOCSIFLINK = 0x8911 + SIOCSIFMAP = 0x8971 + SIOCSIFMEM = 0x8920 + SIOCSIFMETRIC = 0x891e + SIOCSIFMTU = 0x8922 + SIOCSIFNAME = 0x8923 + SIOCSIFNETMASK = 0x891c + SIOCSIFPFLAGS = 0x8934 + SIOCSIFSLAVE = 0x8930 + SIOCSIFTXQLEN = 0x8943 + SIOCSPGRP = 0x8902 + SIOCSRARP = 0x8962 + SOCK_CLOEXEC = 0x80000 + SOCK_DCCP = 0x6 + SOCK_DGRAM = 0x2 + SOCK_NONBLOCK = 0x800 + SOCK_PACKET = 0xa + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_AAL = 0x109 + SOL_ATM = 0x108 + SOL_DECNET = 0x105 + SOL_ICMPV6 = 0x3a + SOL_IP = 0x0 + SOL_IPV6 = 0x29 + SOL_IRDA = 0x10a + SOL_PACKET = 0x107 + SOL_RAW = 0xff + SOL_SOCKET = 0x1 + SOL_TCP = 0x6 + SOL_X25 = 0x106 + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x1e + SO_ATTACH_FILTER = 0x1a + SO_BINDTODEVICE = 0x19 + SO_BROADCAST = 0x6 + SO_BSDCOMPAT = 0xe + SO_BUSY_POLL = 0x2e + SO_DEBUG = 0x1 + SO_DETACH_FILTER = 0x1b + SO_DOMAIN = 0x27 + SO_DONTROUTE = 0x5 + SO_ERROR = 0x4 + SO_GET_FILTER = 0x1a + SO_KEEPALIVE = 0x9 + SO_LINGER = 0xd + SO_LOCK_FILTER = 0x2c + SO_MARK = 0x24 + SO_MAX_PACING_RATE = 0x2f + SO_NOFCS = 0x2b + SO_NO_CHECK = 0xb + SO_OOBINLINE = 0xa + SO_PASSCRED = 0x10 + SO_PASSSEC = 0x22 + SO_PEEK_OFF = 0x2a + SO_PEERCRED = 0x11 + SO_PEERNAME = 0x1c + SO_PEERSEC = 0x1f + SO_PRIORITY = 0xc + SO_PROTOCOL = 0x26 + SO_RCVBUF = 0x8 + SO_RCVBUFFORCE = 0x21 + SO_RCVLOWAT = 0x12 + SO_RCVTIMEO = 0x14 + SO_REUSEADDR = 0x2 + SO_REUSEPORT = 0xf + SO_RXQ_OVFL = 0x28 + SO_SECURITY_AUTHENTICATION = 0x16 + SO_SECURITY_ENCRYPTION_NETWORK = 0x18 + SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17 + SO_SELECT_ERR_QUEUE = 0x2d + SO_SNDBUF = 0x7 + SO_SNDBUFFORCE = 0x20 + SO_SNDLOWAT = 0x13 + SO_SNDTIMEO = 0x15 + SO_TIMESTAMP = 0x1d + SO_TIMESTAMPING = 0x25 + SO_TIMESTAMPNS = 0x23 + SO_TYPE = 0x3 + SO_WIFI_STATUS = 0x29 + S_BLKSIZE = 0x200 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + TAB0 = 0x0 + TAB1 = 0x800 + TAB2 = 0x1000 + TAB3 = 0x1800 + TABDLY = 0x1800 + TCFLSH = 0x540b + TCGETA = 0x5405 + TCGETS = 0x5401 + TCGETS2 = 0x802c542a + TCGETX = 0x5432 + TCIFLUSH = 0x0 + TCIOFF = 0x2 + TCIOFLUSH = 0x2 + TCION = 0x3 + TCOFLUSH = 0x1 + TCOOFF = 0x0 + TCOON = 0x1 + TCP_CONGESTION = 0xd + TCP_COOKIE_IN_ALWAYS = 0x1 + TCP_COOKIE_MAX = 0x10 + TCP_COOKIE_MIN = 0x8 + TCP_COOKIE_OUT_NEVER = 0x2 + TCP_COOKIE_PAIR_SIZE = 0x20 + TCP_COOKIE_TRANSACTIONS = 0xf + TCP_CORK = 0x3 + TCP_DEFER_ACCEPT = 0x9 + TCP_FASTOPEN = 0x17 + TCP_INFO = 0xb + TCP_KEEPCNT = 0x6 + TCP_KEEPIDLE = 0x4 + TCP_KEEPINTVL = 0x5 + TCP_LINGER2 = 0x8 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0xe + TCP_MD5SIG_MAXKEYLEN = 0x50 + TCP_MSS = 0x200 + TCP_MSS_DEFAULT = 0x218 + TCP_MSS_DESIRED = 0x4c4 + TCP_NODELAY = 0x1 + TCP_QUEUE_SEQ = 0x15 + TCP_QUICKACK = 0xc + TCP_REPAIR = 0x13 + TCP_REPAIR_OPTIONS = 0x16 + TCP_REPAIR_QUEUE = 0x14 + TCP_SYNCNT = 0x7 + TCP_S_DATA_IN = 0x4 + TCP_S_DATA_OUT = 0x8 + TCP_THIN_DUPACK = 0x11 + TCP_THIN_LINEAR_TIMEOUTS = 0x10 + TCP_TIMESTAMP = 0x18 + TCP_USER_TIMEOUT = 0x12 + TCP_WINDOW_CLAMP = 0xa + TCSAFLUSH = 0x2 + TCSBRK = 0x5409 + TCSBRKP = 0x5425 + TCSETA = 0x5406 + TCSETAF = 0x5408 + TCSETAW = 0x5407 + TCSETS = 0x5402 + TCSETS2 = 0x402c542b + TCSETSF = 0x5404 + TCSETSF2 = 0x402c542d + TCSETSW = 0x5403 + TCSETSW2 = 0x402c542c + TCSETX = 0x5433 + TCSETXF = 0x5434 + TCSETXW = 0x5435 + TCXONC = 0x540a + TIOCCBRK = 0x5428 + TIOCCONS = 0x541d + TIOCEXCL = 0x540c + TIOCGDEV = 0x80045432 + TIOCGETD = 0x5424 + TIOCGEXCL = 0x80045440 + TIOCGICOUNT = 0x545d + TIOCGLCKTRMIOS = 0x5456 + TIOCGPGRP = 0x540f + TIOCGPKT = 0x80045438 + TIOCGPTLCK = 0x80045439 + TIOCGPTN = 0x80045430 + TIOCGRS485 = 0x542e + TIOCGSERIAL = 0x541e + TIOCGSID = 0x5429 + TIOCGSOFTCAR = 0x5419 + TIOCGWINSZ = 0x5413 + TIOCINQ = 0x541b + TIOCLINUX = 0x541c + TIOCMBIC = 0x5417 + TIOCMBIS = 0x5416 + TIOCMGET = 0x5415 + TIOCMIWAIT = 0x545c + TIOCMSET = 0x5418 + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x5422 + TIOCNXCL = 0x540d + TIOCOUTQ = 0x5411 + TIOCPKT = 0x5420 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCSBRK = 0x5427 + TIOCSCTTY = 0x540e + TIOCSERCONFIG = 0x5453 + TIOCSERGETLSR = 0x5459 + TIOCSERGETMULTI = 0x545a + TIOCSERGSTRUCT = 0x5458 + TIOCSERGWILD = 0x5454 + TIOCSERSETMULTI = 0x545b + TIOCSERSWILD = 0x5455 + TIOCSER_TEMT = 0x1 + TIOCSETD = 0x5423 + TIOCSIG = 0x40045436 + TIOCSLCKTRMIOS = 0x5457 + TIOCSPGRP = 0x5410 + TIOCSPTLCK = 0x40045431 + TIOCSRS485 = 0x542f + TIOCSSERIAL = 0x541f + TIOCSSOFTCAR = 0x541a + TIOCSTI = 0x5412 + TIOCSWINSZ = 0x5414 + TIOCVHANGUP = 0x5437 + TOSTOP = 0x100 + TUNATTACHFILTER = 0x401054d5 + TUNDETACHFILTER = 0x401054d6 + TUNGETFEATURES = 0x800454cf + TUNGETFILTER = 0x801054db + TUNGETIFF = 0x800454d2 + TUNGETSNDBUF = 0x800454d3 + TUNGETVNETHDRSZ = 0x800454d7 + TUNSETDEBUG = 0x400454c9 + TUNSETGROUP = 0x400454ce + TUNSETIFF = 0x400454ca + TUNSETIFINDEX = 0x400454da + TUNSETLINK = 0x400454cd + TUNSETNOCSUM = 0x400454c8 + TUNSETOFFLOAD = 0x400454d0 + TUNSETOWNER = 0x400454cc + TUNSETPERSIST = 0x400454cb + TUNSETQUEUE = 0x400454d9 + TUNSETSNDBUF = 0x400454d4 + TUNSETTXFILTER = 0x400454d1 + TUNSETVNETHDRSZ = 0x400454d8 + VDISCARD = 0xd + VEOF = 0x4 + VEOL = 0xb + VEOL2 = 0x10 + VERASE = 0x2 + VINTR = 0x0 + VKILL = 0x3 + VLNEXT = 0xf + VMIN = 0x6 + VQUIT = 0x1 + VREPRINT = 0xc + VSTART = 0x8 + VSTOP = 0x9 + VSUSP = 0xa + VSWTC = 0x7 + VT0 = 0x0 + VT1 = 0x4000 + VTDLY = 0x4000 + VTIME = 0x5 + VWERASE = 0xe + WALL = 0x40000000 + WCLONE = 0x80000000 + WCONTINUED = 0x8 + WEXITED = 0x4 + WNOHANG = 0x1 + WNOTHREAD = 0x20000000 + WNOWAIT = 0x1000000 + WORDSIZE = 0x40 + WSTOPPED = 0x2 + WUNTRACED = 0x2 + XCASE = 0x4 + XTABS = 0x1800 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x62) + EADDRNOTAVAIL = syscall.Errno(0x63) + EADV = syscall.Errno(0x44) + EAFNOSUPPORT = syscall.Errno(0x61) + EAGAIN = syscall.Errno(0xb) + EALREADY = syscall.Errno(0x72) + EBADE = syscall.Errno(0x34) + EBADF = syscall.Errno(0x9) + EBADFD = syscall.Errno(0x4d) + EBADMSG = syscall.Errno(0x4a) + EBADR = syscall.Errno(0x35) + EBADRQC = syscall.Errno(0x38) + EBADSLT = syscall.Errno(0x39) + EBFONT = syscall.Errno(0x3b) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x7d) + ECHILD = syscall.Errno(0xa) + ECHRNG = syscall.Errno(0x2c) + ECOMM = syscall.Errno(0x46) + ECONNABORTED = syscall.Errno(0x67) + ECONNREFUSED = syscall.Errno(0x6f) + ECONNRESET = syscall.Errno(0x68) + EDEADLK = syscall.Errno(0x23) + EDEADLOCK = syscall.Errno(0x23) + EDESTADDRREQ = syscall.Errno(0x59) + EDOM = syscall.Errno(0x21) + EDOTDOT = syscall.Errno(0x49) + EDQUOT = syscall.Errno(0x7a) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EHOSTDOWN = syscall.Errno(0x70) + EHOSTUNREACH = syscall.Errno(0x71) + EHWPOISON = syscall.Errno(0x85) + EIDRM = syscall.Errno(0x2b) + EILSEQ = syscall.Errno(0x54) + EINPROGRESS = syscall.Errno(0x73) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x6a) + EISDIR = syscall.Errno(0x15) + EISNAM = syscall.Errno(0x78) + EKEYEXPIRED = syscall.Errno(0x7f) + EKEYREJECTED = syscall.Errno(0x81) + EKEYREVOKED = syscall.Errno(0x80) + EL2HLT = syscall.Errno(0x33) + EL2NSYNC = syscall.Errno(0x2d) + EL3HLT = syscall.Errno(0x2e) + EL3RST = syscall.Errno(0x2f) + ELIBACC = syscall.Errno(0x4f) + ELIBBAD = syscall.Errno(0x50) + ELIBEXEC = syscall.Errno(0x53) + ELIBMAX = syscall.Errno(0x52) + ELIBSCN = syscall.Errno(0x51) + ELNRNG = syscall.Errno(0x30) + ELOOP = syscall.Errno(0x28) + EMEDIUMTYPE = syscall.Errno(0x7c) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x5a) + EMULTIHOP = syscall.Errno(0x48) + ENAMETOOLONG = syscall.Errno(0x24) + ENAVAIL = syscall.Errno(0x77) + ENETDOWN = syscall.Errno(0x64) + ENETRESET = syscall.Errno(0x66) + ENETUNREACH = syscall.Errno(0x65) + ENFILE = syscall.Errno(0x17) + ENOANO = syscall.Errno(0x37) + ENOBUFS = syscall.Errno(0x69) + ENOCSI = syscall.Errno(0x32) + ENODATA = syscall.Errno(0x3d) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOKEY = syscall.Errno(0x7e) + ENOLCK = syscall.Errno(0x25) + ENOLINK = syscall.Errno(0x43) + ENOMEDIUM = syscall.Errno(0x7b) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x2a) + ENONET = syscall.Errno(0x40) + ENOPKG = syscall.Errno(0x41) + ENOPROTOOPT = syscall.Errno(0x5c) + ENOSPC = syscall.Errno(0x1c) + ENOSR = syscall.Errno(0x3f) + ENOSTR = syscall.Errno(0x3c) + ENOSYS = syscall.Errno(0x26) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x6b) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x27) + ENOTNAM = syscall.Errno(0x76) + ENOTRECOVERABLE = syscall.Errno(0x83) + ENOTSOCK = syscall.Errno(0x58) + ENOTSUP = syscall.Errno(0x5f) + ENOTTY = syscall.Errno(0x19) + ENOTUNIQ = syscall.Errno(0x4c) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x5f) + EOVERFLOW = syscall.Errno(0x4b) + EOWNERDEAD = syscall.Errno(0x82) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x60) + EPIPE = syscall.Errno(0x20) + EPROTO = syscall.Errno(0x47) + EPROTONOSUPPORT = syscall.Errno(0x5d) + EPROTOTYPE = syscall.Errno(0x5b) + ERANGE = syscall.Errno(0x22) + EREMCHG = syscall.Errno(0x4e) + EREMOTE = syscall.Errno(0x42) + EREMOTEIO = syscall.Errno(0x79) + ERESTART = syscall.Errno(0x55) + ERFKILL = syscall.Errno(0x84) + EROFS = syscall.Errno(0x1e) + ESHUTDOWN = syscall.Errno(0x6c) + ESOCKTNOSUPPORT = syscall.Errno(0x5e) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESRMNT = syscall.Errno(0x45) + ESTALE = syscall.Errno(0x74) + ESTRPIPE = syscall.Errno(0x56) + ETIME = syscall.Errno(0x3e) + ETIMEDOUT = syscall.Errno(0x6e) + ETOOMANYREFS = syscall.Errno(0x6d) + ETXTBSY = syscall.Errno(0x1a) + EUCLEAN = syscall.Errno(0x75) + EUNATCH = syscall.Errno(0x31) + EUSERS = syscall.Errno(0x57) + EWOULDBLOCK = syscall.Errno(0xb) + EXDEV = syscall.Errno(0x12) + EXFULL = syscall.Errno(0x36) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0x7) + SIGCHLD = syscall.Signal(0x11) + SIGCLD = syscall.Signal(0x11) + SIGCONT = syscall.Signal(0x12) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x1d) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPOLL = syscall.Signal(0x1d) + SIGPROF = syscall.Signal(0x1b) + SIGPWR = syscall.Signal(0x1e) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTKFLT = syscall.Signal(0x10) + SIGSTOP = syscall.Signal(0x13) + SIGSYS = syscall.Signal(0x1f) + SIGTERM = syscall.Signal(0xf) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x14) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGUNUSED = syscall.Signal(0x1f) + SIGURG = syscall.Signal(0x17) + SIGUSR1 = syscall.Signal(0xa) + SIGUSR2 = syscall.Signal(0xc) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "no such device or address", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource temporarily unavailable", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device or resource busy", + 17: "file exists", + 18: "invalid cross-device link", + 19: "no such device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "numerical result out of range", + 35: "resource deadlock avoided", + 36: "file name too long", + 37: "no locks available", + 38: "function not implemented", + 39: "directory not empty", + 40: "too many levels of symbolic links", + 42: "no message of desired type", + 43: "identifier removed", + 44: "channel number out of range", + 45: "level 2 not synchronized", + 46: "level 3 halted", + 47: "level 3 reset", + 48: "link number out of range", + 49: "protocol driver not attached", + 50: "no CSI structure available", + 51: "level 2 halted", + 52: "invalid exchange", + 53: "invalid request descriptor", + 54: "exchange full", + 55: "no anode", + 56: "invalid request code", + 57: "invalid slot", + 59: "bad font file format", + 60: "device not a stream", + 61: "no data available", + 62: "timer expired", + 63: "out of streams resources", + 64: "machine is not on the network", + 65: "package not installed", + 66: "object is remote", + 67: "link has been severed", + 68: "advertise error", + 69: "srmount error", + 70: "communication error on send", + 71: "protocol error", + 72: "multihop attempted", + 73: "RFS specific error", + 74: "bad message", + 75: "value too large for defined data type", + 76: "name not unique on network", + 77: "file descriptor in bad state", + 78: "remote address changed", + 79: "can not access a needed shared library", + 80: "accessing a corrupted shared library", + 81: ".lib section in a.out corrupted", + 82: "attempting to link in too many shared libraries", + 83: "cannot exec a shared library directly", + 84: "invalid or incomplete multibyte or wide character", + 85: "interrupted system call should be restarted", + 86: "streams pipe error", + 87: "too many users", + 88: "socket operation on non-socket", + 89: "destination address required", + 90: "message too long", + 91: "protocol wrong type for socket", + 92: "protocol not available", + 93: "protocol not supported", + 94: "socket type not supported", + 95: "operation not supported", + 96: "protocol family not supported", + 97: "address family not supported by protocol", + 98: "address already in use", + 99: "cannot assign requested address", + 100: "network is down", + 101: "network is unreachable", + 102: "network dropped connection on reset", + 103: "software caused connection abort", + 104: "connection reset by peer", + 105: "no buffer space available", + 106: "transport endpoint is already connected", + 107: "transport endpoint is not connected", + 108: "cannot send after transport endpoint shutdown", + 109: "too many references: cannot splice", + 110: "connection timed out", + 111: "connection refused", + 112: "host is down", + 113: "no route to host", + 114: "operation already in progress", + 115: "operation now in progress", + 116: "stale file handle", + 117: "structure needs cleaning", + 118: "not a XENIX named type file", + 119: "no XENIX semaphores available", + 120: "is a named type file", + 121: "remote I/O error", + 122: "disk quota exceeded", + 123: "no medium found", + 124: "wrong medium type", + 125: "operation canceled", + 126: "required key not available", + 127: "key has expired", + 128: "key has been revoked", + 129: "key was rejected by service", + 130: "owner died", + 131: "state not recoverable", + 132: "operation not possible due to RF-kill", + 133: "memory page has hardware error", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/breakpoint trap", + 6: "aborted", + 7: "bus error", + 8: "floating point exception", + 9: "killed", + 10: "user defined signal 1", + 11: "segmentation fault", + 12: "user defined signal 2", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "stack fault", + 17: "child exited", + 18: "continued", + 19: "stopped (signal)", + 20: "stopped", + 21: "stopped (tty input)", + 22: "stopped (tty output)", + 23: "urgent I/O condition", + 24: "CPU time limit exceeded", + 25: "file size limit exceeded", + 26: "virtual timer expired", + 27: "profiling timer expired", + 28: "window changed", + 29: "I/O possible", + 30: "power failure", + 31: "bad system call", +} diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go new file mode 100644 index 0000000000..36535b242d --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -0,0 +1,1917 @@ +// mkerrors.sh +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build mips64,linux + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- _const.go + +package unix + +import "syscall" + +const ( + AF_ALG = 0x26 + AF_APPLETALK = 0x5 + AF_ASH = 0x12 + AF_ATMPVC = 0x8 + AF_ATMSVC = 0x14 + AF_AX25 = 0x3 + AF_BLUETOOTH = 0x1f + AF_BRIDGE = 0x7 + AF_CAIF = 0x25 + AF_CAN = 0x1d + AF_DECnet = 0xc + AF_ECONET = 0x13 + AF_FILE = 0x1 + AF_IB = 0x1b + AF_IEEE802154 = 0x24 + AF_INET = 0x2 + AF_INET6 = 0xa + AF_IPX = 0x4 + AF_IRDA = 0x17 + AF_ISDN = 0x22 + AF_IUCV = 0x20 + AF_KEY = 0xf + AF_LLC = 0x1a + AF_LOCAL = 0x1 + AF_MAX = 0x29 + AF_MPLS = 0x1c + AF_NETBEUI = 0xd + AF_NETLINK = 0x10 + AF_NETROM = 0x6 + AF_NFC = 0x27 + AF_PACKET = 0x11 + AF_PHONET = 0x23 + AF_PPPOX = 0x18 + AF_RDS = 0x15 + AF_ROSE = 0xb + AF_ROUTE = 0x10 + AF_RXRPC = 0x21 + AF_SECURITY = 0xe + AF_SNA = 0x16 + AF_TIPC = 0x1e + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_VSOCK = 0x28 + AF_WANPIPE = 0x19 + AF_X25 = 0x9 + ARPHRD_6LOWPAN = 0x339 + ARPHRD_ADAPT = 0x108 + ARPHRD_APPLETLK = 0x8 + ARPHRD_ARCNET = 0x7 + ARPHRD_ASH = 0x30d + ARPHRD_ATM = 0x13 + ARPHRD_AX25 = 0x3 + ARPHRD_BIF = 0x307 + ARPHRD_CAIF = 0x336 + ARPHRD_CAN = 0x118 + ARPHRD_CHAOS = 0x5 + ARPHRD_CISCO = 0x201 + ARPHRD_CSLIP = 0x101 + ARPHRD_CSLIP6 = 0x103 + ARPHRD_DDCMP = 0x205 + ARPHRD_DLCI = 0xf + ARPHRD_ECONET = 0x30e + ARPHRD_EETHER = 0x2 + ARPHRD_ETHER = 0x1 + ARPHRD_EUI64 = 0x1b + ARPHRD_FCAL = 0x311 + ARPHRD_FCFABRIC = 0x313 + ARPHRD_FCPL = 0x312 + ARPHRD_FCPP = 0x310 + ARPHRD_FDDI = 0x306 + ARPHRD_FRAD = 0x302 + ARPHRD_HDLC = 0x201 + ARPHRD_HIPPI = 0x30c + ARPHRD_HWX25 = 0x110 + ARPHRD_IEEE1394 = 0x18 + ARPHRD_IEEE802 = 0x6 + ARPHRD_IEEE80211 = 0x321 + ARPHRD_IEEE80211_PRISM = 0x322 + ARPHRD_IEEE80211_RADIOTAP = 0x323 + ARPHRD_IEEE802154 = 0x324 + ARPHRD_IEEE802154_MONITOR = 0x325 + ARPHRD_IEEE802_TR = 0x320 + ARPHRD_INFINIBAND = 0x20 + ARPHRD_IP6GRE = 0x337 + ARPHRD_IPDDP = 0x309 + ARPHRD_IPGRE = 0x30a + ARPHRD_IRDA = 0x30f + ARPHRD_LAPB = 0x204 + ARPHRD_LOCALTLK = 0x305 + ARPHRD_LOOPBACK = 0x304 + ARPHRD_METRICOM = 0x17 + ARPHRD_NETLINK = 0x338 + ARPHRD_NETROM = 0x0 + ARPHRD_NONE = 0xfffe + ARPHRD_PHONET = 0x334 + ARPHRD_PHONET_PIPE = 0x335 + ARPHRD_PIMREG = 0x30b + ARPHRD_PPP = 0x200 + ARPHRD_PRONET = 0x4 + ARPHRD_RAWHDLC = 0x206 + ARPHRD_ROSE = 0x10e + ARPHRD_RSRVD = 0x104 + ARPHRD_SIT = 0x308 + ARPHRD_SKIP = 0x303 + ARPHRD_SLIP = 0x100 + ARPHRD_SLIP6 = 0x102 + ARPHRD_TUNNEL = 0x300 + ARPHRD_TUNNEL6 = 0x301 + ARPHRD_VOID = 0xffff + ARPHRD_X25 = 0x10f + B0 = 0x0 + B1000000 = 0x1008 + B110 = 0x3 + B115200 = 0x1002 + B1152000 = 0x1009 + B1200 = 0x9 + B134 = 0x4 + B150 = 0x5 + B1500000 = 0x100a + B1800 = 0xa + B19200 = 0xe + B200 = 0x6 + B2000000 = 0x100b + B230400 = 0x1003 + B2400 = 0xb + B2500000 = 0x100c + B300 = 0x7 + B3000000 = 0x100d + B3500000 = 0x100e + B38400 = 0xf + B4000000 = 0x100f + B460800 = 0x1004 + B4800 = 0xc + B50 = 0x1 + B500000 = 0x1005 + B57600 = 0x1001 + B576000 = 0x1006 + B600 = 0x8 + B75 = 0x2 + B921600 = 0x1007 + B9600 = 0xd + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LL_OFF = -0x200000 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXINSNS = 0x1000 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MOD = 0x90 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_NET_OFF = -0x100000 + BPF_OR = 0x40 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BPF_XOR = 0xa0 + BRKINT = 0x2 + CFLUSH = 0xf + CLOCAL = 0x800 + CLOCK_BOOTTIME = 0x7 + CLOCK_BOOTTIME_ALARM = 0x9 + CLOCK_DEFAULT = 0x0 + CLOCK_EXT = 0x1 + CLOCK_INT = 0x2 + CLOCK_MONOTONIC = 0x1 + CLOCK_MONOTONIC_COARSE = 0x6 + CLOCK_MONOTONIC_RAW = 0x4 + CLOCK_PROCESS_CPUTIME_ID = 0x2 + CLOCK_REALTIME = 0x0 + CLOCK_REALTIME_ALARM = 0x8 + CLOCK_REALTIME_COARSE = 0x5 + CLOCK_TAI = 0xb + CLOCK_THREAD_CPUTIME_ID = 0x3 + CLOCK_TXFROMRX = 0x4 + CLOCK_TXINT = 0x3 + CLONE_CHILD_CLEARTID = 0x200000 + CLONE_CHILD_SETTID = 0x1000000 + CLONE_DETACHED = 0x400000 + CLONE_FILES = 0x400 + CLONE_FS = 0x200 + CLONE_IO = 0x80000000 + CLONE_NEWCGROUP = 0x2000000 + CLONE_NEWIPC = 0x8000000 + CLONE_NEWNET = 0x40000000 + CLONE_NEWNS = 0x20000 + CLONE_NEWPID = 0x20000000 + CLONE_NEWUSER = 0x10000000 + CLONE_NEWUTS = 0x4000000 + CLONE_PARENT = 0x8000 + CLONE_PARENT_SETTID = 0x100000 + CLONE_PTRACE = 0x2000 + CLONE_SETTLS = 0x80000 + CLONE_SIGHAND = 0x800 + CLONE_SYSVSEM = 0x40000 + CLONE_THREAD = 0x10000 + CLONE_UNTRACED = 0x800000 + CLONE_VFORK = 0x4000 + CLONE_VM = 0x100 + CREAD = 0x80 + CS5 = 0x0 + CS6 = 0x10 + CS7 = 0x20 + CS8 = 0x30 + CSIGNAL = 0xff + CSIZE = 0x30 + CSTART = 0x11 + CSTATUS = 0x0 + CSTOP = 0x13 + CSTOPB = 0x40 + CSUSP = 0x1a + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x200 + ECHOE = 0x10 + ECHOK = 0x20 + ECHOKE = 0x800 + ECHONL = 0x40 + ECHOPRT = 0x400 + ENCODING_DEFAULT = 0x0 + ENCODING_FM_MARK = 0x3 + ENCODING_FM_SPACE = 0x4 + ENCODING_MANCHESTER = 0x5 + ENCODING_NRZ = 0x1 + ENCODING_NRZI = 0x2 + EPOLLERR = 0x8 + EPOLLET = 0x80000000 + EPOLLHUP = 0x10 + EPOLLIN = 0x1 + EPOLLMSG = 0x400 + EPOLLONESHOT = 0x40000000 + EPOLLOUT = 0x4 + EPOLLPRI = 0x2 + EPOLLRDBAND = 0x80 + EPOLLRDHUP = 0x2000 + EPOLLRDNORM = 0x40 + EPOLLWAKEUP = 0x20000000 + EPOLLWRBAND = 0x200 + EPOLLWRNORM = 0x100 + EPOLL_CLOEXEC = 0x80000 + EPOLL_CTL_ADD = 0x1 + EPOLL_CTL_DEL = 0x2 + EPOLL_CTL_MOD = 0x3 + ETH_P_1588 = 0x88f7 + ETH_P_8021AD = 0x88a8 + ETH_P_8021AH = 0x88e7 + ETH_P_8021Q = 0x8100 + ETH_P_80221 = 0x8917 + ETH_P_802_2 = 0x4 + ETH_P_802_3 = 0x1 + ETH_P_802_3_MIN = 0x600 + ETH_P_802_EX1 = 0x88b5 + ETH_P_AARP = 0x80f3 + ETH_P_AF_IUCV = 0xfbfb + ETH_P_ALL = 0x3 + ETH_P_AOE = 0x88a2 + ETH_P_ARCNET = 0x1a + ETH_P_ARP = 0x806 + ETH_P_ATALK = 0x809b + ETH_P_ATMFATE = 0x8884 + ETH_P_ATMMPOA = 0x884c + ETH_P_AX25 = 0x2 + ETH_P_BATMAN = 0x4305 + ETH_P_BPQ = 0x8ff + ETH_P_CAIF = 0xf7 + ETH_P_CAN = 0xc + ETH_P_CANFD = 0xd + ETH_P_CONTROL = 0x16 + ETH_P_CUST = 0x6006 + ETH_P_DDCMP = 0x6 + ETH_P_DEC = 0x6000 + ETH_P_DIAG = 0x6005 + ETH_P_DNA_DL = 0x6001 + ETH_P_DNA_RC = 0x6002 + ETH_P_DNA_RT = 0x6003 + ETH_P_DSA = 0x1b + ETH_P_ECONET = 0x18 + ETH_P_EDSA = 0xdada + ETH_P_FCOE = 0x8906 + ETH_P_FIP = 0x8914 + ETH_P_HDLC = 0x19 + ETH_P_IEEE802154 = 0xf6 + ETH_P_IEEEPUP = 0xa00 + ETH_P_IEEEPUPAT = 0xa01 + ETH_P_IP = 0x800 + ETH_P_IPV6 = 0x86dd + ETH_P_IPX = 0x8137 + ETH_P_IRDA = 0x17 + ETH_P_LAT = 0x6004 + ETH_P_LINK_CTL = 0x886c + ETH_P_LOCALTALK = 0x9 + ETH_P_LOOP = 0x60 + ETH_P_LOOPBACK = 0x9000 + ETH_P_MOBITEX = 0x15 + ETH_P_MPLS_MC = 0x8848 + ETH_P_MPLS_UC = 0x8847 + ETH_P_MVRP = 0x88f5 + ETH_P_PAE = 0x888e + ETH_P_PAUSE = 0x8808 + ETH_P_PHONET = 0xf5 + ETH_P_PPPTALK = 0x10 + ETH_P_PPP_DISC = 0x8863 + ETH_P_PPP_MP = 0x8 + ETH_P_PPP_SES = 0x8864 + ETH_P_PRP = 0x88fb + ETH_P_PUP = 0x200 + ETH_P_PUPAT = 0x201 + ETH_P_QINQ1 = 0x9100 + ETH_P_QINQ2 = 0x9200 + ETH_P_QINQ3 = 0x9300 + ETH_P_RARP = 0x8035 + ETH_P_SCA = 0x6007 + ETH_P_SLOW = 0x8809 + ETH_P_SNAP = 0x5 + ETH_P_TDLS = 0x890d + ETH_P_TEB = 0x6558 + ETH_P_TIPC = 0x88ca + ETH_P_TRAILER = 0x1c + ETH_P_TR_802_2 = 0x11 + ETH_P_TSN = 0x22f0 + ETH_P_WAN_PPP = 0x7 + ETH_P_WCCP = 0x883e + ETH_P_X25 = 0x805 + ETH_P_XDSA = 0xf8 + EXTA = 0xe + EXTB = 0xf + EXTPROC = 0x10000 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FLUSHO = 0x2000 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x406 + F_EXLCK = 0x4 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLEASE = 0x401 + F_GETLK = 0xe + F_GETLK64 = 0xe + F_GETOWN = 0x17 + F_GETOWN_EX = 0x10 + F_GETPIPE_SZ = 0x408 + F_GETSIG = 0xb + F_LOCK = 0x1 + F_NOTIFY = 0x402 + F_OFD_GETLK = 0x24 + F_OFD_SETLK = 0x25 + F_OFD_SETLKW = 0x26 + F_OK = 0x0 + F_RDLCK = 0x0 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLEASE = 0x400 + F_SETLK = 0x6 + F_SETLK64 = 0x6 + F_SETLKW = 0x7 + F_SETLKW64 = 0x7 + F_SETOWN = 0x18 + F_SETOWN_EX = 0xf + F_SETPIPE_SZ = 0x407 + F_SETSIG = 0xa + F_SHLCK = 0x8 + F_TEST = 0x3 + F_TLOCK = 0x2 + F_ULOCK = 0x0 + F_UNLCK = 0x2 + F_WRLCK = 0x1 + HUPCL = 0x400 + ICANON = 0x2 + ICMPV6_FILTER = 0x1 + ICRNL = 0x100 + IEXTEN = 0x100 + IFA_F_DADFAILED = 0x8 + IFA_F_DEPRECATED = 0x20 + IFA_F_HOMEADDRESS = 0x10 + IFA_F_MANAGETEMPADDR = 0x100 + IFA_F_MCAUTOJOIN = 0x400 + IFA_F_NODAD = 0x2 + IFA_F_NOPREFIXROUTE = 0x200 + IFA_F_OPTIMISTIC = 0x4 + IFA_F_PERMANENT = 0x80 + IFA_F_SECONDARY = 0x1 + IFA_F_STABLE_PRIVACY = 0x800 + IFA_F_TEMPORARY = 0x1 + IFA_F_TENTATIVE = 0x40 + IFA_MAX = 0x8 + IFF_ALLMULTI = 0x200 + IFF_ATTACH_QUEUE = 0x200 + IFF_AUTOMEDIA = 0x4000 + IFF_BROADCAST = 0x2 + IFF_DEBUG = 0x4 + IFF_DETACH_QUEUE = 0x400 + IFF_DORMANT = 0x20000 + IFF_DYNAMIC = 0x8000 + IFF_ECHO = 0x40000 + IFF_LOOPBACK = 0x8 + IFF_LOWER_UP = 0x10000 + IFF_MASTER = 0x400 + IFF_MULTICAST = 0x1000 + IFF_MULTI_QUEUE = 0x100 + IFF_NOARP = 0x80 + IFF_NOFILTER = 0x1000 + IFF_NOTRAILERS = 0x20 + IFF_NO_PI = 0x1000 + IFF_ONE_QUEUE = 0x2000 + IFF_PERSIST = 0x800 + IFF_POINTOPOINT = 0x10 + IFF_PORTSEL = 0x2000 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SLAVE = 0x800 + IFF_TAP = 0x2 + IFF_TUN = 0x1 + IFF_TUN_EXCL = 0x8000 + IFF_UP = 0x1 + IFF_VNET_HDR = 0x4000 + IFF_VOLATILE = 0x70c5a + IFNAMSIZ = 0x10 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_ACCESS = 0x1 + IN_ALL_EVENTS = 0xfff + IN_ATTRIB = 0x4 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLOEXEC = 0x80000 + IN_CLOSE = 0x18 + IN_CLOSE_NOWRITE = 0x10 + IN_CLOSE_WRITE = 0x8 + IN_CREATE = 0x100 + IN_DELETE = 0x200 + IN_DELETE_SELF = 0x400 + IN_DONT_FOLLOW = 0x2000000 + IN_EXCL_UNLINK = 0x4000000 + IN_IGNORED = 0x8000 + IN_ISDIR = 0x40000000 + IN_LOOPBACKNET = 0x7f + IN_MASK_ADD = 0x20000000 + IN_MODIFY = 0x2 + IN_MOVE = 0xc0 + IN_MOVED_FROM = 0x40 + IN_MOVED_TO = 0x80 + IN_MOVE_SELF = 0x800 + IN_NONBLOCK = 0x80 + IN_ONESHOT = 0x80000000 + IN_ONLYDIR = 0x1000000 + IN_OPEN = 0x20 + IN_Q_OVERFLOW = 0x4000 + IN_UNMOUNT = 0x2000 + IPPROTO_AH = 0x33 + IPPROTO_BEETPH = 0x5e + IPPROTO_COMP = 0x6c + IPPROTO_DCCP = 0x21 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_ENCAP = 0x62 + IPPROTO_ESP = 0x32 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GRE = 0x2f + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IGMP = 0x2 + IPPROTO_IP = 0x0 + IPPROTO_IPIP = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_MH = 0x87 + IPPROTO_MTP = 0x5c + IPPROTO_NONE = 0x3b + IPPROTO_PIM = 0x67 + IPPROTO_PUP = 0xc + IPPROTO_RAW = 0xff + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_SCTP = 0x84 + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_UDP = 0x11 + IPPROTO_UDPLITE = 0x88 + IPV6_2292DSTOPTS = 0x4 + IPV6_2292HOPLIMIT = 0x8 + IPV6_2292HOPOPTS = 0x3 + IPV6_2292PKTINFO = 0x2 + IPV6_2292PKTOPTIONS = 0x6 + IPV6_2292RTHDR = 0x5 + IPV6_ADDRFORM = 0x1 + IPV6_ADD_MEMBERSHIP = 0x14 + IPV6_AUTHHDR = 0xa + IPV6_CHECKSUM = 0x7 + IPV6_DONTFRAG = 0x3e + IPV6_DROP_MEMBERSHIP = 0x15 + IPV6_DSTOPTS = 0x3b + IPV6_HOPLIMIT = 0x34 + IPV6_HOPOPTS = 0x36 + IPV6_IPSEC_POLICY = 0x22 + IPV6_JOIN_ANYCAST = 0x1b + IPV6_JOIN_GROUP = 0x14 + IPV6_LEAVE_ANYCAST = 0x1c + IPV6_LEAVE_GROUP = 0x15 + IPV6_MTU = 0x18 + IPV6_MTU_DISCOVER = 0x17 + IPV6_MULTICAST_HOPS = 0x12 + IPV6_MULTICAST_IF = 0x11 + IPV6_MULTICAST_LOOP = 0x13 + IPV6_NEXTHOP = 0x9 + IPV6_PATHMTU = 0x3d + IPV6_PKTINFO = 0x32 + IPV6_PMTUDISC_DO = 0x2 + IPV6_PMTUDISC_DONT = 0x0 + IPV6_PMTUDISC_INTERFACE = 0x4 + IPV6_PMTUDISC_OMIT = 0x5 + IPV6_PMTUDISC_PROBE = 0x3 + IPV6_PMTUDISC_WANT = 0x1 + IPV6_RECVDSTOPTS = 0x3a + IPV6_RECVERR = 0x19 + IPV6_RECVHOPLIMIT = 0x33 + IPV6_RECVHOPOPTS = 0x35 + IPV6_RECVPATHMTU = 0x3c + IPV6_RECVPKTINFO = 0x31 + IPV6_RECVRTHDR = 0x38 + IPV6_RECVTCLASS = 0x42 + IPV6_ROUTER_ALERT = 0x16 + IPV6_RTHDR = 0x39 + IPV6_RTHDRDSTOPTS = 0x37 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_RXDSTOPTS = 0x3b + IPV6_RXHOPOPTS = 0x36 + IPV6_TCLASS = 0x43 + IPV6_UNICAST_HOPS = 0x10 + IPV6_V6ONLY = 0x1a + IPV6_XFRM_POLICY = 0x23 + IP_ADD_MEMBERSHIP = 0x23 + IP_ADD_SOURCE_MEMBERSHIP = 0x27 + IP_BLOCK_SOURCE = 0x26 + IP_CHECKSUM = 0x17 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DROP_MEMBERSHIP = 0x24 + IP_DROP_SOURCE_MEMBERSHIP = 0x28 + IP_FREEBIND = 0xf + IP_HDRINCL = 0x3 + IP_IPSEC_POLICY = 0x10 + IP_MAXPACKET = 0xffff + IP_MAX_MEMBERSHIPS = 0x14 + IP_MF = 0x2000 + IP_MINTTL = 0x15 + IP_MSFILTER = 0x29 + IP_MSS = 0x240 + IP_MTU = 0xe + IP_MTU_DISCOVER = 0xa + IP_MULTICAST_ALL = 0x31 + IP_MULTICAST_IF = 0x20 + IP_MULTICAST_LOOP = 0x22 + IP_MULTICAST_TTL = 0x21 + IP_NODEFRAG = 0x16 + IP_OFFMASK = 0x1fff + IP_OPTIONS = 0x4 + IP_ORIGDSTADDR = 0x14 + IP_PASSSEC = 0x12 + IP_PKTINFO = 0x8 + IP_PKTOPTIONS = 0x9 + IP_PMTUDISC = 0xa + IP_PMTUDISC_DO = 0x2 + IP_PMTUDISC_DONT = 0x0 + IP_PMTUDISC_INTERFACE = 0x4 + IP_PMTUDISC_OMIT = 0x5 + IP_PMTUDISC_PROBE = 0x3 + IP_PMTUDISC_WANT = 0x1 + IP_RECVERR = 0xb + IP_RECVOPTS = 0x6 + IP_RECVORIGDSTADDR = 0x14 + IP_RECVRETOPTS = 0x7 + IP_RECVTOS = 0xd + IP_RECVTTL = 0xc + IP_RETOPTS = 0x7 + IP_RF = 0x8000 + IP_ROUTER_ALERT = 0x5 + IP_TOS = 0x1 + IP_TRANSPARENT = 0x13 + IP_TTL = 0x2 + IP_UNBLOCK_SOURCE = 0x25 + IP_UNICAST_IF = 0x32 + IP_XFRM_POLICY = 0x11 + ISIG = 0x1 + ISTRIP = 0x20 + IUTF8 = 0x4000 + IXANY = 0x800 + IXOFF = 0x1000 + IXON = 0x400 + LINUX_REBOOT_CMD_CAD_OFF = 0x0 + LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef + LINUX_REBOOT_CMD_HALT = 0xcdef0123 + LINUX_REBOOT_CMD_KEXEC = 0x45584543 + LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc + LINUX_REBOOT_CMD_RESTART = 0x1234567 + LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4 + LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2 + LINUX_REBOOT_MAGIC1 = 0xfee1dead + LINUX_REBOOT_MAGIC2 = 0x28121969 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_DODUMP = 0x11 + MADV_DOFORK = 0xb + MADV_DONTDUMP = 0x10 + MADV_DONTFORK = 0xa + MADV_DONTNEED = 0x4 + MADV_HUGEPAGE = 0xe + MADV_HWPOISON = 0x64 + MADV_MERGEABLE = 0xc + MADV_NOHUGEPAGE = 0xf + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_REMOVE = 0x9 + MADV_SEQUENTIAL = 0x2 + MADV_UNMERGEABLE = 0xd + MADV_WILLNEED = 0x3 + MAP_ANON = 0x800 + MAP_ANONYMOUS = 0x800 + MAP_DENYWRITE = 0x2000 + MAP_EXECUTABLE = 0x4000 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_GROWSDOWN = 0x1000 + MAP_HUGETLB = 0x80000 + MAP_HUGE_MASK = 0x3f + MAP_HUGE_SHIFT = 0x1a + MAP_LOCKED = 0x8000 + MAP_NONBLOCK = 0x20000 + MAP_NORESERVE = 0x400 + MAP_POPULATE = 0x10000 + MAP_PRIVATE = 0x2 + MAP_RENAME = 0x800 + MAP_SHARED = 0x1 + MAP_STACK = 0x40000 + MAP_TYPE = 0xf + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MNT_DETACH = 0x2 + MNT_EXPIRE = 0x4 + MNT_FORCE = 0x1 + MSG_CMSG_CLOEXEC = 0x40000000 + MSG_CONFIRM = 0x800 + MSG_CTRUNC = 0x8 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x40 + MSG_EOR = 0x80 + MSG_ERRQUEUE = 0x2000 + MSG_FASTOPEN = 0x20000000 + MSG_FIN = 0x200 + MSG_MORE = 0x8000 + MSG_NOSIGNAL = 0x4000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_PROXY = 0x10 + MSG_RST = 0x1000 + MSG_SYN = 0x400 + MSG_TRUNC = 0x20 + MSG_TRYHARD = 0x4 + MSG_WAITALL = 0x100 + MSG_WAITFORONE = 0x10000 + MS_ACTIVE = 0x40000000 + MS_ASYNC = 0x1 + MS_BIND = 0x1000 + MS_DIRSYNC = 0x80 + MS_INVALIDATE = 0x2 + MS_I_VERSION = 0x800000 + MS_KERNMOUNT = 0x400000 + MS_LAZYTIME = 0x2000000 + MS_MANDLOCK = 0x40 + MS_MGC_MSK = 0xffff0000 + MS_MGC_VAL = 0xc0ed0000 + MS_MOVE = 0x2000 + MS_NOATIME = 0x400 + MS_NODEV = 0x4 + MS_NODIRATIME = 0x800 + MS_NOEXEC = 0x8 + MS_NOSUID = 0x2 + MS_NOUSER = -0x80000000 + MS_POSIXACL = 0x10000 + MS_PRIVATE = 0x40000 + MS_RDONLY = 0x1 + MS_REC = 0x4000 + MS_RELATIME = 0x200000 + MS_REMOUNT = 0x20 + MS_RMT_MASK = 0x2800051 + MS_SHARED = 0x100000 + MS_SILENT = 0x8000 + MS_SLAVE = 0x80000 + MS_STRICTATIME = 0x1000000 + MS_SYNC = 0x4 + MS_SYNCHRONOUS = 0x10 + MS_UNBINDABLE = 0x20000 + NAME_MAX = 0xff + NETLINK_ADD_MEMBERSHIP = 0x1 + NETLINK_AUDIT = 0x9 + NETLINK_BROADCAST_ERROR = 0x4 + NETLINK_CAP_ACK = 0xa + NETLINK_CONNECTOR = 0xb + NETLINK_CRYPTO = 0x15 + NETLINK_DNRTMSG = 0xe + NETLINK_DROP_MEMBERSHIP = 0x2 + NETLINK_ECRYPTFS = 0x13 + NETLINK_FIB_LOOKUP = 0xa + NETLINK_FIREWALL = 0x3 + NETLINK_GENERIC = 0x10 + NETLINK_INET_DIAG = 0x4 + NETLINK_IP6_FW = 0xd + NETLINK_ISCSI = 0x8 + NETLINK_KOBJECT_UEVENT = 0xf + NETLINK_LISTEN_ALL_NSID = 0x8 + NETLINK_LIST_MEMBERSHIPS = 0x9 + NETLINK_NETFILTER = 0xc + NETLINK_NFLOG = 0x5 + NETLINK_NO_ENOBUFS = 0x5 + NETLINK_PKTINFO = 0x3 + NETLINK_RDMA = 0x14 + NETLINK_ROUTE = 0x0 + NETLINK_RX_RING = 0x6 + NETLINK_SCSITRANSPORT = 0x12 + NETLINK_SELINUX = 0x7 + NETLINK_SOCK_DIAG = 0x4 + NETLINK_TX_RING = 0x7 + NETLINK_UNUSED = 0x1 + NETLINK_USERSOCK = 0x2 + NETLINK_XFRM = 0x6 + NLA_ALIGNTO = 0x4 + NLA_F_NESTED = 0x8000 + NLA_F_NET_BYTEORDER = 0x4000 + NLA_HDRLEN = 0x4 + NLMSG_ALIGNTO = 0x4 + NLMSG_DONE = 0x3 + NLMSG_ERROR = 0x2 + NLMSG_HDRLEN = 0x10 + NLMSG_MIN_TYPE = 0x10 + NLMSG_NOOP = 0x1 + NLMSG_OVERRUN = 0x4 + NLM_F_ACK = 0x4 + NLM_F_APPEND = 0x800 + NLM_F_ATOMIC = 0x400 + NLM_F_CREATE = 0x400 + NLM_F_DUMP = 0x300 + NLM_F_DUMP_INTR = 0x10 + NLM_F_ECHO = 0x8 + NLM_F_EXCL = 0x200 + NLM_F_MATCH = 0x200 + NLM_F_MULTI = 0x2 + NLM_F_REPLACE = 0x100 + NLM_F_REQUEST = 0x1 + NLM_F_ROOT = 0x100 + NOFLSH = 0x80 + OCRNL = 0x8 + OFDEL = 0x80 + OFILL = 0x40 + ONLCR = 0x4 + ONLRET = 0x20 + ONOCR = 0x10 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_APPEND = 0x8 + O_ASYNC = 0x1000 + O_CLOEXEC = 0x80000 + O_CREAT = 0x100 + O_DIRECT = 0x8000 + O_DIRECTORY = 0x10000 + O_DSYNC = 0x10 + O_EXCL = 0x400 + O_FSYNC = 0x4010 + O_LARGEFILE = 0x0 + O_NDELAY = 0x80 + O_NOATIME = 0x40000 + O_NOCTTY = 0x800 + O_NOFOLLOW = 0x20000 + O_NONBLOCK = 0x80 + O_PATH = 0x200000 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_RSYNC = 0x4010 + O_SYNC = 0x4010 + O_TMPFILE = 0x410000 + O_TRUNC = 0x200 + O_WRONLY = 0x1 + PACKET_ADD_MEMBERSHIP = 0x1 + PACKET_AUXDATA = 0x8 + PACKET_BROADCAST = 0x1 + PACKET_COPY_THRESH = 0x7 + PACKET_DROP_MEMBERSHIP = 0x2 + PACKET_FANOUT = 0x12 + PACKET_FANOUT_CBPF = 0x6 + PACKET_FANOUT_CPU = 0x2 + PACKET_FANOUT_DATA = 0x16 + PACKET_FANOUT_EBPF = 0x7 + PACKET_FANOUT_FLAG_DEFRAG = 0x8000 + PACKET_FANOUT_FLAG_ROLLOVER = 0x1000 + PACKET_FANOUT_HASH = 0x0 + PACKET_FANOUT_LB = 0x1 + PACKET_FANOUT_QM = 0x5 + PACKET_FANOUT_RND = 0x4 + PACKET_FANOUT_ROLLOVER = 0x3 + PACKET_FASTROUTE = 0x6 + PACKET_HDRLEN = 0xb + PACKET_HOST = 0x0 + PACKET_KERNEL = 0x7 + PACKET_LOOPBACK = 0x5 + PACKET_LOSS = 0xe + PACKET_MR_ALLMULTI = 0x2 + PACKET_MR_MULTICAST = 0x0 + PACKET_MR_PROMISC = 0x1 + PACKET_MR_UNICAST = 0x3 + PACKET_MULTICAST = 0x2 + PACKET_ORIGDEV = 0x9 + PACKET_OTHERHOST = 0x3 + PACKET_OUTGOING = 0x4 + PACKET_QDISC_BYPASS = 0x14 + PACKET_RECV_OUTPUT = 0x3 + PACKET_RESERVE = 0xc + PACKET_ROLLOVER_STATS = 0x15 + PACKET_RX_RING = 0x5 + PACKET_STATISTICS = 0x6 + PACKET_TIMESTAMP = 0x11 + PACKET_TX_HAS_OFF = 0x13 + PACKET_TX_RING = 0xd + PACKET_TX_TIMESTAMP = 0x10 + PACKET_USER = 0x6 + PACKET_VERSION = 0xa + PACKET_VNET_HDR = 0xf + PARENB = 0x100 + PARITY_CRC16_PR0 = 0x2 + PARITY_CRC16_PR0_CCITT = 0x4 + PARITY_CRC16_PR1 = 0x3 + PARITY_CRC16_PR1_CCITT = 0x5 + PARITY_CRC32_PR0_CCITT = 0x6 + PARITY_CRC32_PR1_CCITT = 0x7 + PARITY_DEFAULT = 0x0 + PARITY_NONE = 0x1 + PARMRK = 0x8 + PARODD = 0x200 + PENDIN = 0x4000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_GROWSDOWN = 0x1000000 + PROT_GROWSUP = 0x2000000 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + PR_CAPBSET_DROP = 0x18 + PR_CAPBSET_READ = 0x17 + PR_CAP_AMBIENT = 0x2f + PR_CAP_AMBIENT_CLEAR_ALL = 0x4 + PR_CAP_AMBIENT_IS_SET = 0x1 + PR_CAP_AMBIENT_LOWER = 0x3 + PR_CAP_AMBIENT_RAISE = 0x2 + PR_ENDIAN_BIG = 0x0 + PR_ENDIAN_LITTLE = 0x1 + PR_ENDIAN_PPC_LITTLE = 0x2 + PR_FPEMU_NOPRINT = 0x1 + PR_FPEMU_SIGFPE = 0x2 + PR_FP_EXC_ASYNC = 0x2 + PR_FP_EXC_DISABLED = 0x0 + PR_FP_EXC_DIV = 0x10000 + PR_FP_EXC_INV = 0x100000 + PR_FP_EXC_NONRECOV = 0x1 + PR_FP_EXC_OVF = 0x20000 + PR_FP_EXC_PRECISE = 0x3 + PR_FP_EXC_RES = 0x80000 + PR_FP_EXC_SW_ENABLE = 0x80 + PR_FP_EXC_UND = 0x40000 + PR_FP_MODE_FR = 0x1 + PR_FP_MODE_FRE = 0x2 + PR_GET_CHILD_SUBREAPER = 0x25 + PR_GET_DUMPABLE = 0x3 + PR_GET_ENDIAN = 0x13 + PR_GET_FPEMU = 0x9 + PR_GET_FPEXC = 0xb + PR_GET_FP_MODE = 0x2e + PR_GET_KEEPCAPS = 0x7 + PR_GET_NAME = 0x10 + PR_GET_NO_NEW_PRIVS = 0x27 + PR_GET_PDEATHSIG = 0x2 + PR_GET_SECCOMP = 0x15 + PR_GET_SECUREBITS = 0x1b + PR_GET_THP_DISABLE = 0x2a + PR_GET_TID_ADDRESS = 0x28 + PR_GET_TIMERSLACK = 0x1e + PR_GET_TIMING = 0xd + PR_GET_TSC = 0x19 + PR_GET_UNALIGN = 0x5 + PR_MCE_KILL = 0x21 + PR_MCE_KILL_CLEAR = 0x0 + PR_MCE_KILL_DEFAULT = 0x2 + PR_MCE_KILL_EARLY = 0x1 + PR_MCE_KILL_GET = 0x22 + PR_MCE_KILL_LATE = 0x0 + PR_MCE_KILL_SET = 0x1 + PR_MPX_DISABLE_MANAGEMENT = 0x2c + PR_MPX_ENABLE_MANAGEMENT = 0x2b + PR_SET_CHILD_SUBREAPER = 0x24 + PR_SET_DUMPABLE = 0x4 + PR_SET_ENDIAN = 0x14 + PR_SET_FPEMU = 0xa + PR_SET_FPEXC = 0xc + PR_SET_FP_MODE = 0x2d + PR_SET_KEEPCAPS = 0x8 + PR_SET_MM = 0x23 + PR_SET_MM_ARG_END = 0x9 + PR_SET_MM_ARG_START = 0x8 + PR_SET_MM_AUXV = 0xc + PR_SET_MM_BRK = 0x7 + PR_SET_MM_END_CODE = 0x2 + PR_SET_MM_END_DATA = 0x4 + PR_SET_MM_ENV_END = 0xb + PR_SET_MM_ENV_START = 0xa + PR_SET_MM_EXE_FILE = 0xd + PR_SET_MM_MAP = 0xe + PR_SET_MM_MAP_SIZE = 0xf + PR_SET_MM_START_BRK = 0x6 + PR_SET_MM_START_CODE = 0x1 + PR_SET_MM_START_DATA = 0x3 + PR_SET_MM_START_STACK = 0x5 + PR_SET_NAME = 0xf + PR_SET_NO_NEW_PRIVS = 0x26 + PR_SET_PDEATHSIG = 0x1 + PR_SET_PTRACER = 0x59616d61 + PR_SET_PTRACER_ANY = -0x1 + PR_SET_SECCOMP = 0x16 + PR_SET_SECUREBITS = 0x1c + PR_SET_THP_DISABLE = 0x29 + PR_SET_TIMERSLACK = 0x1d + PR_SET_TIMING = 0xe + PR_SET_TSC = 0x1a + PR_SET_UNALIGN = 0x6 + PR_TASK_PERF_EVENTS_DISABLE = 0x1f + PR_TASK_PERF_EVENTS_ENABLE = 0x20 + PR_TIMING_STATISTICAL = 0x0 + PR_TIMING_TIMESTAMP = 0x1 + PR_TSC_ENABLE = 0x1 + PR_TSC_SIGSEGV = 0x2 + PR_UNALIGN_NOPRINT = 0x1 + PR_UNALIGN_SIGBUS = 0x2 + PTRACE_ATTACH = 0x10 + PTRACE_CONT = 0x7 + PTRACE_DETACH = 0x11 + PTRACE_EVENT_CLONE = 0x3 + PTRACE_EVENT_EXEC = 0x4 + PTRACE_EVENT_EXIT = 0x6 + PTRACE_EVENT_FORK = 0x1 + PTRACE_EVENT_SECCOMP = 0x7 + PTRACE_EVENT_STOP = 0x80 + PTRACE_EVENT_VFORK = 0x2 + PTRACE_EVENT_VFORK_DONE = 0x5 + PTRACE_GETEVENTMSG = 0x4201 + PTRACE_GETFPREGS = 0xe + PTRACE_GETREGS = 0xc + PTRACE_GETREGSET = 0x4204 + PTRACE_GETSIGINFO = 0x4202 + PTRACE_GETSIGMASK = 0x420a + PTRACE_GET_THREAD_AREA = 0x19 + PTRACE_GET_THREAD_AREA_3264 = 0xc4 + PTRACE_GET_WATCH_REGS = 0xd0 + PTRACE_INTERRUPT = 0x4207 + PTRACE_KILL = 0x8 + PTRACE_LISTEN = 0x4208 + PTRACE_OLDSETOPTIONS = 0x15 + PTRACE_O_EXITKILL = 0x100000 + PTRACE_O_MASK = 0x3000ff + PTRACE_O_SUSPEND_SECCOMP = 0x200000 + PTRACE_O_TRACECLONE = 0x8 + PTRACE_O_TRACEEXEC = 0x10 + PTRACE_O_TRACEEXIT = 0x40 + PTRACE_O_TRACEFORK = 0x2 + PTRACE_O_TRACESECCOMP = 0x80 + PTRACE_O_TRACESYSGOOD = 0x1 + PTRACE_O_TRACEVFORK = 0x4 + PTRACE_O_TRACEVFORKDONE = 0x20 + PTRACE_PEEKDATA = 0x2 + PTRACE_PEEKDATA_3264 = 0xc1 + PTRACE_PEEKSIGINFO = 0x4209 + PTRACE_PEEKSIGINFO_SHARED = 0x1 + PTRACE_PEEKTEXT = 0x1 + PTRACE_PEEKTEXT_3264 = 0xc0 + PTRACE_PEEKUSR = 0x3 + PTRACE_POKEDATA = 0x5 + PTRACE_POKEDATA_3264 = 0xc3 + PTRACE_POKETEXT = 0x4 + PTRACE_POKETEXT_3264 = 0xc2 + PTRACE_POKEUSR = 0x6 + PTRACE_SEIZE = 0x4206 + PTRACE_SETFPREGS = 0xf + PTRACE_SETOPTIONS = 0x4200 + PTRACE_SETREGS = 0xd + PTRACE_SETREGSET = 0x4205 + PTRACE_SETSIGINFO = 0x4203 + PTRACE_SETSIGMASK = 0x420b + PTRACE_SET_THREAD_AREA = 0x1a + PTRACE_SET_WATCH_REGS = 0xd1 + PTRACE_SINGLESTEP = 0x9 + PTRACE_SYSCALL = 0x18 + PTRACE_TRACEME = 0x0 + RLIMIT_AS = 0x6 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x5 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = -0x1 + RTAX_ADVMSS = 0x8 + RTAX_CC_ALGO = 0x10 + RTAX_CWND = 0x7 + RTAX_FEATURES = 0xc + RTAX_FEATURE_ALLFRAG = 0x8 + RTAX_FEATURE_ECN = 0x1 + RTAX_FEATURE_MASK = 0xf + RTAX_FEATURE_SACK = 0x2 + RTAX_FEATURE_TIMESTAMP = 0x4 + RTAX_HOPLIMIT = 0xa + RTAX_INITCWND = 0xb + RTAX_INITRWND = 0xe + RTAX_LOCK = 0x1 + RTAX_MAX = 0x10 + RTAX_MTU = 0x2 + RTAX_QUICKACK = 0xf + RTAX_REORDERING = 0x9 + RTAX_RTO_MIN = 0xd + RTAX_RTT = 0x4 + RTAX_RTTVAR = 0x5 + RTAX_SSTHRESH = 0x6 + RTAX_UNSPEC = 0x0 + RTAX_WINDOW = 0x3 + RTA_ALIGNTO = 0x4 + RTA_MAX = 0x16 + RTCF_DIRECTSRC = 0x4000000 + RTCF_DOREDIRECT = 0x1000000 + RTCF_LOG = 0x2000000 + RTCF_MASQ = 0x400000 + RTCF_NAT = 0x800000 + RTCF_VALVE = 0x200000 + RTF_ADDRCLASSMASK = 0xf8000000 + RTF_ADDRCONF = 0x40000 + RTF_ALLONLINK = 0x20000 + RTF_BROADCAST = 0x10000000 + RTF_CACHE = 0x1000000 + RTF_DEFAULT = 0x10000 + RTF_DYNAMIC = 0x10 + RTF_FLOW = 0x2000000 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_INTERFACE = 0x40000000 + RTF_IRTT = 0x100 + RTF_LINKRT = 0x100000 + RTF_LOCAL = 0x80000000 + RTF_MODIFIED = 0x20 + RTF_MSS = 0x40 + RTF_MTU = 0x40 + RTF_MULTICAST = 0x20000000 + RTF_NAT = 0x8000000 + RTF_NOFORWARD = 0x1000 + RTF_NONEXTHOP = 0x200000 + RTF_NOPMTUDISC = 0x4000 + RTF_POLICY = 0x4000000 + RTF_REINSTATE = 0x8 + RTF_REJECT = 0x200 + RTF_STATIC = 0x400 + RTF_THROW = 0x2000 + RTF_UP = 0x1 + RTF_WINDOW = 0x80 + RTF_XRESOLVE = 0x800 + RTM_BASE = 0x10 + RTM_DELACTION = 0x31 + RTM_DELADDR = 0x15 + RTM_DELADDRLABEL = 0x49 + RTM_DELLINK = 0x11 + RTM_DELMDB = 0x55 + RTM_DELNEIGH = 0x1d + RTM_DELNSID = 0x59 + RTM_DELQDISC = 0x25 + RTM_DELROUTE = 0x19 + RTM_DELRULE = 0x21 + RTM_DELTCLASS = 0x29 + RTM_DELTFILTER = 0x2d + RTM_F_CLONED = 0x200 + RTM_F_EQUALIZE = 0x400 + RTM_F_NOTIFY = 0x100 + RTM_F_PREFIX = 0x800 + RTM_GETACTION = 0x32 + RTM_GETADDR = 0x16 + RTM_GETADDRLABEL = 0x4a + RTM_GETANYCAST = 0x3e + RTM_GETDCB = 0x4e + RTM_GETLINK = 0x12 + RTM_GETMDB = 0x56 + RTM_GETMULTICAST = 0x3a + RTM_GETNEIGH = 0x1e + RTM_GETNEIGHTBL = 0x42 + RTM_GETNETCONF = 0x52 + RTM_GETNSID = 0x5a + RTM_GETQDISC = 0x26 + RTM_GETROUTE = 0x1a + RTM_GETRULE = 0x22 + RTM_GETTCLASS = 0x2a + RTM_GETTFILTER = 0x2e + RTM_MAX = 0x5b + RTM_NEWACTION = 0x30 + RTM_NEWADDR = 0x14 + RTM_NEWADDRLABEL = 0x48 + RTM_NEWLINK = 0x10 + RTM_NEWMDB = 0x54 + RTM_NEWNDUSEROPT = 0x44 + RTM_NEWNEIGH = 0x1c + RTM_NEWNEIGHTBL = 0x40 + RTM_NEWNETCONF = 0x50 + RTM_NEWNSID = 0x58 + RTM_NEWPREFIX = 0x34 + RTM_NEWQDISC = 0x24 + RTM_NEWROUTE = 0x18 + RTM_NEWRULE = 0x20 + RTM_NEWTCLASS = 0x28 + RTM_NEWTFILTER = 0x2c + RTM_NR_FAMILIES = 0x13 + RTM_NR_MSGTYPES = 0x4c + RTM_SETDCB = 0x4f + RTM_SETLINK = 0x13 + RTM_SETNEIGHTBL = 0x43 + RTNH_ALIGNTO = 0x4 + RTNH_COMPARE_MASK = 0x11 + RTNH_F_DEAD = 0x1 + RTNH_F_LINKDOWN = 0x10 + RTNH_F_OFFLOAD = 0x8 + RTNH_F_ONLINK = 0x4 + RTNH_F_PERVASIVE = 0x2 + RTN_MAX = 0xb + RTPROT_BABEL = 0x2a + RTPROT_BIRD = 0xc + RTPROT_BOOT = 0x3 + RTPROT_DHCP = 0x10 + RTPROT_DNROUTED = 0xd + RTPROT_GATED = 0x8 + RTPROT_KERNEL = 0x2 + RTPROT_MROUTED = 0x11 + RTPROT_MRT = 0xa + RTPROT_NTK = 0xf + RTPROT_RA = 0x9 + RTPROT_REDIRECT = 0x1 + RTPROT_STATIC = 0x4 + RTPROT_UNSPEC = 0x0 + RTPROT_XORP = 0xe + RTPROT_ZEBRA = 0xb + RT_CLASS_DEFAULT = 0xfd + RT_CLASS_LOCAL = 0xff + RT_CLASS_MAIN = 0xfe + RT_CLASS_MAX = 0xff + RT_CLASS_UNSPEC = 0x0 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + RUSAGE_THREAD = 0x1 + SCM_CREDENTIALS = 0x2 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x1d + SCM_TIMESTAMPING = 0x25 + SCM_TIMESTAMPNS = 0x23 + SCM_WIFI_STATUS = 0x29 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDDLCI = 0x8980 + SIOCADDMULTI = 0x8931 + SIOCADDRT = 0x890b + SIOCATMARK = 0x40047307 + SIOCDARP = 0x8953 + SIOCDELDLCI = 0x8981 + SIOCDELMULTI = 0x8932 + SIOCDELRT = 0x890c + SIOCDEVPRIVATE = 0x89f0 + SIOCDIFADDR = 0x8936 + SIOCDRARP = 0x8960 + SIOCGARP = 0x8954 + SIOCGIFADDR = 0x8915 + SIOCGIFBR = 0x8940 + SIOCGIFBRDADDR = 0x8919 + SIOCGIFCONF = 0x8912 + SIOCGIFCOUNT = 0x8938 + SIOCGIFDSTADDR = 0x8917 + SIOCGIFENCAP = 0x8925 + SIOCGIFFLAGS = 0x8913 + SIOCGIFHWADDR = 0x8927 + SIOCGIFINDEX = 0x8933 + SIOCGIFMAP = 0x8970 + SIOCGIFMEM = 0x891f + SIOCGIFMETRIC = 0x891d + SIOCGIFMTU = 0x8921 + SIOCGIFNAME = 0x8910 + SIOCGIFNETMASK = 0x891b + SIOCGIFPFLAGS = 0x8935 + SIOCGIFSLAVE = 0x8929 + SIOCGIFTXQLEN = 0x8942 + SIOCGPGRP = 0x40047309 + SIOCGRARP = 0x8961 + SIOCGSTAMP = 0x8906 + SIOCGSTAMPNS = 0x8907 + SIOCPROTOPRIVATE = 0x89e0 + SIOCRTMSG = 0x890d + SIOCSARP = 0x8955 + SIOCSIFADDR = 0x8916 + SIOCSIFBR = 0x8941 + SIOCSIFBRDADDR = 0x891a + SIOCSIFDSTADDR = 0x8918 + SIOCSIFENCAP = 0x8926 + SIOCSIFFLAGS = 0x8914 + SIOCSIFHWADDR = 0x8924 + SIOCSIFHWBROADCAST = 0x8937 + SIOCSIFLINK = 0x8911 + SIOCSIFMAP = 0x8971 + SIOCSIFMEM = 0x8920 + SIOCSIFMETRIC = 0x891e + SIOCSIFMTU = 0x8922 + SIOCSIFNAME = 0x8923 + SIOCSIFNETMASK = 0x891c + SIOCSIFPFLAGS = 0x8934 + SIOCSIFSLAVE = 0x8930 + SIOCSIFTXQLEN = 0x8943 + SIOCSPGRP = 0x80047308 + SIOCSRARP = 0x8962 + SOCK_CLOEXEC = 0x80000 + SOCK_DCCP = 0x6 + SOCK_DGRAM = 0x1 + SOCK_NONBLOCK = 0x80 + SOCK_PACKET = 0xa + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x2 + SOL_AAL = 0x109 + SOL_ATM = 0x108 + SOL_DECNET = 0x105 + SOL_ICMPV6 = 0x3a + SOL_IP = 0x0 + SOL_IPV6 = 0x29 + SOL_IRDA = 0x10a + SOL_PACKET = 0x107 + SOL_RAW = 0xff + SOL_SOCKET = 0xffff + SOL_TCP = 0x6 + SOL_X25 = 0x106 + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x1009 + SO_ATTACH_BPF = 0x32 + SO_ATTACH_FILTER = 0x1a + SO_BINDTODEVICE = 0x19 + SO_BPF_EXTENSIONS = 0x30 + SO_BROADCAST = 0x20 + SO_BSDCOMPAT = 0xe + SO_BUSY_POLL = 0x2e + SO_DEBUG = 0x1 + SO_DETACH_BPF = 0x1b + SO_DETACH_FILTER = 0x1b + SO_DOMAIN = 0x1029 + SO_DONTROUTE = 0x10 + SO_ERROR = 0x1007 + SO_GET_FILTER = 0x1a + SO_INCOMING_CPU = 0x31 + SO_KEEPALIVE = 0x8 + SO_LINGER = 0x80 + SO_LOCK_FILTER = 0x2c + SO_MARK = 0x24 + SO_MAX_PACING_RATE = 0x2f + SO_NOFCS = 0x2b + SO_NO_CHECK = 0xb + SO_OOBINLINE = 0x100 + SO_PASSCRED = 0x11 + SO_PASSSEC = 0x22 + SO_PEEK_OFF = 0x2a + SO_PEERCRED = 0x12 + SO_PEERNAME = 0x1c + SO_PEERSEC = 0x1e + SO_PRIORITY = 0xc + SO_PROTOCOL = 0x1028 + SO_RCVBUF = 0x1002 + SO_RCVBUFFORCE = 0x21 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x1006 + SO_REUSEADDR = 0x4 + SO_REUSEPORT = 0x200 + SO_RXQ_OVFL = 0x28 + SO_SECURITY_AUTHENTICATION = 0x16 + SO_SECURITY_ENCRYPTION_NETWORK = 0x18 + SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17 + SO_SELECT_ERR_QUEUE = 0x2d + SO_SNDBUF = 0x1001 + SO_SNDBUFFORCE = 0x1f + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x1005 + SO_STYLE = 0x1008 + SO_TIMESTAMP = 0x1d + SO_TIMESTAMPING = 0x25 + SO_TIMESTAMPNS = 0x23 + SO_TYPE = 0x1008 + SO_WIFI_STATUS = 0x29 + S_BLKSIZE = 0x200 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + TCFLSH = 0x5407 + TCIFLUSH = 0x0 + TCIOFLUSH = 0x2 + TCOFLUSH = 0x1 + TCP_CONGESTION = 0xd + TCP_COOKIE_IN_ALWAYS = 0x1 + TCP_COOKIE_MAX = 0x10 + TCP_COOKIE_MIN = 0x8 + TCP_COOKIE_OUT_NEVER = 0x2 + TCP_COOKIE_PAIR_SIZE = 0x20 + TCP_COOKIE_TRANSACTIONS = 0xf + TCP_CORK = 0x3 + TCP_DEFER_ACCEPT = 0x9 + TCP_FASTOPEN = 0x17 + TCP_INFO = 0xb + TCP_KEEPCNT = 0x6 + TCP_KEEPIDLE = 0x4 + TCP_KEEPINTVL = 0x5 + TCP_LINGER2 = 0x8 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0xe + TCP_MD5SIG_MAXKEYLEN = 0x50 + TCP_MSS = 0x200 + TCP_MSS_DEFAULT = 0x218 + TCP_MSS_DESIRED = 0x4c4 + TCP_NODELAY = 0x1 + TCP_QUEUE_SEQ = 0x15 + TCP_QUICKACK = 0xc + TCP_REPAIR = 0x13 + TCP_REPAIR_OPTIONS = 0x16 + TCP_REPAIR_QUEUE = 0x14 + TCP_SYNCNT = 0x7 + TCP_S_DATA_IN = 0x4 + TCP_S_DATA_OUT = 0x8 + TCP_THIN_DUPACK = 0x11 + TCP_THIN_LINEAR_TIMEOUTS = 0x10 + TCP_TIMESTAMP = 0x18 + TCP_USER_TIMEOUT = 0x12 + TCP_WINDOW_CLAMP = 0xa + TCSAFLUSH = 0x5410 + TCSBRK = 0x5405 + TCXONC = 0x5406 + TIOCCBRK = 0x5428 + TIOCCONS = 0x80047478 + TIOCEXCL = 0x740d + TIOCGDEV = 0x40045432 + TIOCGETD = 0x7400 + TIOCGETP = 0x7408 + TIOCGEXCL = 0x40045440 + TIOCGICOUNT = 0x5492 + TIOCGLCKTRMIOS = 0x548b + TIOCGLTC = 0x7474 + TIOCGPGRP = 0x40047477 + TIOCGPKT = 0x40045438 + TIOCGPTLCK = 0x40045439 + TIOCGPTN = 0x40045430 + TIOCGRS485 = 0x4020542e + TIOCGSERIAL = 0x5484 + TIOCGSID = 0x7416 + TIOCGSOFTCAR = 0x5481 + TIOCGWINSZ = 0x40087468 + TIOCINQ = 0x467f + TIOCLINUX = 0x5483 + TIOCMBIC = 0x741c + TIOCMBIS = 0x741b + TIOCMGET = 0x741d + TIOCMIWAIT = 0x5491 + TIOCMSET = 0x741a + TIOCM_CAR = 0x100 + TIOCM_CD = 0x100 + TIOCM_CTS = 0x40 + TIOCM_DSR = 0x400 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x200 + TIOCM_RNG = 0x200 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x20 + TIOCM_ST = 0x10 + TIOCNOTTY = 0x5471 + TIOCNXCL = 0x740e + TIOCOUTQ = 0x7472 + TIOCPKT = 0x5470 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCSBRK = 0x5427 + TIOCSCTTY = 0x5480 + TIOCSERCONFIG = 0x5488 + TIOCSERGETLSR = 0x548e + TIOCSERGETMULTI = 0x548f + TIOCSERGSTRUCT = 0x548d + TIOCSERGWILD = 0x5489 + TIOCSERSETMULTI = 0x5490 + TIOCSERSWILD = 0x548a + TIOCSER_TEMT = 0x1 + TIOCSETD = 0x7401 + TIOCSETN = 0x740a + TIOCSETP = 0x7409 + TIOCSIG = 0x80045436 + TIOCSLCKTRMIOS = 0x548c + TIOCSLTC = 0x7475 + TIOCSPGRP = 0x80047476 + TIOCSPTLCK = 0x80045431 + TIOCSRS485 = 0xc020542f + TIOCSSERIAL = 0x5485 + TIOCSSOFTCAR = 0x5482 + TIOCSTI = 0x5472 + TIOCSWINSZ = 0x80087467 + TIOCVHANGUP = 0x5437 + TOSTOP = 0x8000 + TUNATTACHFILTER = 0x801054d5 + TUNDETACHFILTER = 0x801054d6 + TUNGETFEATURES = 0x400454cf + TUNGETFILTER = 0x401054db + TUNGETIFF = 0x400454d2 + TUNGETSNDBUF = 0x400454d3 + TUNGETVNETBE = 0x400454df + TUNGETVNETHDRSZ = 0x400454d7 + TUNGETVNETLE = 0x400454dd + TUNSETDEBUG = 0x800454c9 + TUNSETGROUP = 0x800454ce + TUNSETIFF = 0x800454ca + TUNSETIFINDEX = 0x800454da + TUNSETLINK = 0x800454cd + TUNSETNOCSUM = 0x800454c8 + TUNSETOFFLOAD = 0x800454d0 + TUNSETOWNER = 0x800454cc + TUNSETPERSIST = 0x800454cb + TUNSETQUEUE = 0x800454d9 + TUNSETSNDBUF = 0x800454d4 + TUNSETTXFILTER = 0x800454d1 + TUNSETVNETBE = 0x800454de + TUNSETVNETHDRSZ = 0x800454d8 + TUNSETVNETLE = 0x800454dc + VDISCARD = 0xd + VEOF = 0x10 + VEOL = 0x11 + VEOL2 = 0x6 + VERASE = 0x2 + VINTR = 0x0 + VKILL = 0x3 + VLNEXT = 0xf + VMIN = 0x4 + VQUIT = 0x1 + VREPRINT = 0xc + VSTART = 0x8 + VSTOP = 0x9 + VSUSP = 0xa + VSWTC = 0x7 + VSWTCH = 0x7 + VT0 = 0x0 + VT1 = 0x4000 + VTDLY = 0x4000 + VTIME = 0x5 + VWERASE = 0xe + WALL = 0x40000000 + WCLONE = 0x80000000 + WCONTINUED = 0x8 + WEXITED = 0x4 + WNOHANG = 0x1 + WNOTHREAD = 0x20000000 + WNOWAIT = 0x1000000 + WORDSIZE = 0x40 + WSTOPPED = 0x2 + WUNTRACED = 0x2 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x7d) + EADDRNOTAVAIL = syscall.Errno(0x7e) + EADV = syscall.Errno(0x44) + EAFNOSUPPORT = syscall.Errno(0x7c) + EAGAIN = syscall.Errno(0xb) + EALREADY = syscall.Errno(0x95) + EBADE = syscall.Errno(0x32) + EBADF = syscall.Errno(0x9) + EBADFD = syscall.Errno(0x51) + EBADMSG = syscall.Errno(0x4d) + EBADR = syscall.Errno(0x33) + EBADRQC = syscall.Errno(0x36) + EBADSLT = syscall.Errno(0x37) + EBFONT = syscall.Errno(0x3b) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x9e) + ECHILD = syscall.Errno(0xa) + ECHRNG = syscall.Errno(0x25) + ECOMM = syscall.Errno(0x46) + ECONNABORTED = syscall.Errno(0x82) + ECONNREFUSED = syscall.Errno(0x92) + ECONNRESET = syscall.Errno(0x83) + EDEADLK = syscall.Errno(0x2d) + EDEADLOCK = syscall.Errno(0x38) + EDESTADDRREQ = syscall.Errno(0x60) + EDOM = syscall.Errno(0x21) + EDOTDOT = syscall.Errno(0x49) + EDQUOT = syscall.Errno(0x46d) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EHOSTDOWN = syscall.Errno(0x93) + EHOSTUNREACH = syscall.Errno(0x94) + EHWPOISON = syscall.Errno(0xa8) + EIDRM = syscall.Errno(0x24) + EILSEQ = syscall.Errno(0x58) + EINIT = syscall.Errno(0x8d) + EINPROGRESS = syscall.Errno(0x96) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x85) + EISDIR = syscall.Errno(0x15) + EISNAM = syscall.Errno(0x8b) + EKEYEXPIRED = syscall.Errno(0xa2) + EKEYREJECTED = syscall.Errno(0xa4) + EKEYREVOKED = syscall.Errno(0xa3) + EL2HLT = syscall.Errno(0x2c) + EL2NSYNC = syscall.Errno(0x26) + EL3HLT = syscall.Errno(0x27) + EL3RST = syscall.Errno(0x28) + ELIBACC = syscall.Errno(0x53) + ELIBBAD = syscall.Errno(0x54) + ELIBEXEC = syscall.Errno(0x57) + ELIBMAX = syscall.Errno(0x56) + ELIBSCN = syscall.Errno(0x55) + ELNRNG = syscall.Errno(0x29) + ELOOP = syscall.Errno(0x5a) + EMEDIUMTYPE = syscall.Errno(0xa0) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x61) + EMULTIHOP = syscall.Errno(0x4a) + ENAMETOOLONG = syscall.Errno(0x4e) + ENAVAIL = syscall.Errno(0x8a) + ENETDOWN = syscall.Errno(0x7f) + ENETRESET = syscall.Errno(0x81) + ENETUNREACH = syscall.Errno(0x80) + ENFILE = syscall.Errno(0x17) + ENOANO = syscall.Errno(0x35) + ENOBUFS = syscall.Errno(0x84) + ENOCSI = syscall.Errno(0x2b) + ENODATA = syscall.Errno(0x3d) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOKEY = syscall.Errno(0xa1) + ENOLCK = syscall.Errno(0x2e) + ENOLINK = syscall.Errno(0x43) + ENOMEDIUM = syscall.Errno(0x9f) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x23) + ENONET = syscall.Errno(0x40) + ENOPKG = syscall.Errno(0x41) + ENOPROTOOPT = syscall.Errno(0x63) + ENOSPC = syscall.Errno(0x1c) + ENOSR = syscall.Errno(0x3f) + ENOSTR = syscall.Errno(0x3c) + ENOSYS = syscall.Errno(0x59) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x86) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x5d) + ENOTNAM = syscall.Errno(0x89) + ENOTRECOVERABLE = syscall.Errno(0xa6) + ENOTSOCK = syscall.Errno(0x5f) + ENOTSUP = syscall.Errno(0x7a) + ENOTTY = syscall.Errno(0x19) + ENOTUNIQ = syscall.Errno(0x50) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x7a) + EOVERFLOW = syscall.Errno(0x4f) + EOWNERDEAD = syscall.Errno(0xa5) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x7b) + EPIPE = syscall.Errno(0x20) + EPROTO = syscall.Errno(0x47) + EPROTONOSUPPORT = syscall.Errno(0x78) + EPROTOTYPE = syscall.Errno(0x62) + ERANGE = syscall.Errno(0x22) + EREMCHG = syscall.Errno(0x52) + EREMDEV = syscall.Errno(0x8e) + EREMOTE = syscall.Errno(0x42) + EREMOTEIO = syscall.Errno(0x8c) + ERESTART = syscall.Errno(0x5b) + ERFKILL = syscall.Errno(0xa7) + EROFS = syscall.Errno(0x1e) + ESHUTDOWN = syscall.Errno(0x8f) + ESOCKTNOSUPPORT = syscall.Errno(0x79) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESRMNT = syscall.Errno(0x45) + ESTALE = syscall.Errno(0x97) + ESTRPIPE = syscall.Errno(0x5c) + ETIME = syscall.Errno(0x3e) + ETIMEDOUT = syscall.Errno(0x91) + ETOOMANYREFS = syscall.Errno(0x90) + ETXTBSY = syscall.Errno(0x1a) + EUCLEAN = syscall.Errno(0x87) + EUNATCH = syscall.Errno(0x2a) + EUSERS = syscall.Errno(0x5e) + EWOULDBLOCK = syscall.Errno(0xb) + EXDEV = syscall.Errno(0x12) + EXFULL = syscall.Errno(0x34) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0xa) + SIGCHLD = syscall.Signal(0x12) + SIGCLD = syscall.Signal(0x12) + SIGCONT = syscall.Signal(0x19) + SIGEMT = syscall.Signal(0x7) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x16) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPOLL = syscall.Signal(0x16) + SIGPROF = syscall.Signal(0x1d) + SIGPWR = syscall.Signal(0x13) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTOP = syscall.Signal(0x17) + SIGSYS = syscall.Signal(0xc) + SIGTERM = syscall.Signal(0xf) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x18) + SIGTTIN = syscall.Signal(0x1a) + SIGTTOU = syscall.Signal(0x1b) + SIGURG = syscall.Signal(0x15) + SIGUSR1 = syscall.Signal(0x10) + SIGUSR2 = syscall.Signal(0x11) + SIGVTALRM = syscall.Signal(0x1c) + SIGWINCH = syscall.Signal(0x14) + SIGXCPU = syscall.Signal(0x1e) + SIGXFSZ = syscall.Signal(0x1f) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "no such device or address", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource temporarily unavailable", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device or resource busy", + 17: "file exists", + 18: "invalid cross-device link", + 19: "no such device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "numerical result out of range", + 35: "no message of desired type", + 36: "identifier removed", + 37: "channel number out of range", + 38: "level 2 not synchronized", + 39: "level 3 halted", + 40: "level 3 reset", + 41: "link number out of range", + 42: "protocol driver not attached", + 43: "no CSI structure available", + 44: "level 2 halted", + 45: "resource deadlock avoided", + 46: "no locks available", + 50: "invalid exchange", + 51: "invalid request descriptor", + 52: "exchange full", + 53: "no anode", + 54: "invalid request code", + 55: "invalid slot", + 56: "file locking deadlock error", + 59: "bad font file format", + 60: "device not a stream", + 61: "no data available", + 62: "timer expired", + 63: "out of streams resources", + 64: "machine is not on the network", + 65: "package not installed", + 66: "object is remote", + 67: "link has been severed", + 68: "advertise error", + 69: "srmount error", + 70: "communication error on send", + 71: "protocol error", + 73: "RFS specific error", + 74: "multihop attempted", + 77: "bad message", + 78: "file name too long", + 79: "value too large for defined data type", + 80: "name not unique on network", + 81: "file descriptor in bad state", + 82: "remote address changed", + 83: "can not access a needed shared library", + 84: "accessing a corrupted shared library", + 85: ".lib section in a.out corrupted", + 86: "attempting to link in too many shared libraries", + 87: "cannot exec a shared library directly", + 88: "invalid or incomplete multibyte or wide character", + 89: "function not implemented", + 90: "too many levels of symbolic links", + 91: "interrupted system call should be restarted", + 92: "streams pipe error", + 93: "directory not empty", + 94: "too many users", + 95: "socket operation on non-socket", + 96: "destination address required", + 97: "message too long", + 98: "protocol wrong type for socket", + 99: "protocol not available", + 120: "protocol not supported", + 121: "socket type not supported", + 122: "operation not supported", + 123: "protocol family not supported", + 124: "address family not supported by protocol", + 125: "address already in use", + 126: "cannot assign requested address", + 127: "network is down", + 128: "network is unreachable", + 129: "network dropped connection on reset", + 130: "software caused connection abort", + 131: "connection reset by peer", + 132: "no buffer space available", + 133: "transport endpoint is already connected", + 134: "transport endpoint is not connected", + 135: "structure needs cleaning", + 137: "not a XENIX named type file", + 138: "no XENIX semaphores available", + 139: "is a named type file", + 140: "remote I/O error", + 141: "unknown error 141", + 142: "unknown error 142", + 143: "cannot send after transport endpoint shutdown", + 144: "too many references: cannot splice", + 145: "connection timed out", + 146: "connection refused", + 147: "host is down", + 148: "no route to host", + 149: "operation already in progress", + 150: "operation now in progress", + 151: "stale file handle", + 158: "operation canceled", + 159: "no medium found", + 160: "wrong medium type", + 161: "required key not available", + 162: "key has expired", + 163: "key has been revoked", + 164: "key was rejected by service", + 165: "owner died", + 166: "state not recoverable", + 167: "operation not possible due to RF-kill", + 168: "memory page has hardware error", + 1133: "disk quota exceeded", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/breakpoint trap", + 6: "aborted", + 7: "EMT trap", + 8: "floating point exception", + 9: "killed", + 10: "bus error", + 11: "segmentation fault", + 12: "bad system call", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "user defined signal 1", + 17: "user defined signal 2", + 18: "child exited", + 19: "power failure", + 20: "window changed", + 21: "urgent I/O condition", + 22: "I/O possible", + 23: "stopped (signal)", + 24: "stopped", + 25: "continued", + 26: "stopped (tty input)", + 27: "stopped (tty output)", + 28: "virtual timer expired", + 29: "profiling timer expired", + 30: "CPU time limit exceeded", + 31: "file size limit exceeded", +} diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go new file mode 100644 index 0000000000..112f05de56 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -0,0 +1,1917 @@ +// mkerrors.sh +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build mips64le,linux + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- _const.go + +package unix + +import "syscall" + +const ( + AF_ALG = 0x26 + AF_APPLETALK = 0x5 + AF_ASH = 0x12 + AF_ATMPVC = 0x8 + AF_ATMSVC = 0x14 + AF_AX25 = 0x3 + AF_BLUETOOTH = 0x1f + AF_BRIDGE = 0x7 + AF_CAIF = 0x25 + AF_CAN = 0x1d + AF_DECnet = 0xc + AF_ECONET = 0x13 + AF_FILE = 0x1 + AF_IB = 0x1b + AF_IEEE802154 = 0x24 + AF_INET = 0x2 + AF_INET6 = 0xa + AF_IPX = 0x4 + AF_IRDA = 0x17 + AF_ISDN = 0x22 + AF_IUCV = 0x20 + AF_KEY = 0xf + AF_LLC = 0x1a + AF_LOCAL = 0x1 + AF_MAX = 0x29 + AF_MPLS = 0x1c + AF_NETBEUI = 0xd + AF_NETLINK = 0x10 + AF_NETROM = 0x6 + AF_NFC = 0x27 + AF_PACKET = 0x11 + AF_PHONET = 0x23 + AF_PPPOX = 0x18 + AF_RDS = 0x15 + AF_ROSE = 0xb + AF_ROUTE = 0x10 + AF_RXRPC = 0x21 + AF_SECURITY = 0xe + AF_SNA = 0x16 + AF_TIPC = 0x1e + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_VSOCK = 0x28 + AF_WANPIPE = 0x19 + AF_X25 = 0x9 + ARPHRD_6LOWPAN = 0x339 + ARPHRD_ADAPT = 0x108 + ARPHRD_APPLETLK = 0x8 + ARPHRD_ARCNET = 0x7 + ARPHRD_ASH = 0x30d + ARPHRD_ATM = 0x13 + ARPHRD_AX25 = 0x3 + ARPHRD_BIF = 0x307 + ARPHRD_CAIF = 0x336 + ARPHRD_CAN = 0x118 + ARPHRD_CHAOS = 0x5 + ARPHRD_CISCO = 0x201 + ARPHRD_CSLIP = 0x101 + ARPHRD_CSLIP6 = 0x103 + ARPHRD_DDCMP = 0x205 + ARPHRD_DLCI = 0xf + ARPHRD_ECONET = 0x30e + ARPHRD_EETHER = 0x2 + ARPHRD_ETHER = 0x1 + ARPHRD_EUI64 = 0x1b + ARPHRD_FCAL = 0x311 + ARPHRD_FCFABRIC = 0x313 + ARPHRD_FCPL = 0x312 + ARPHRD_FCPP = 0x310 + ARPHRD_FDDI = 0x306 + ARPHRD_FRAD = 0x302 + ARPHRD_HDLC = 0x201 + ARPHRD_HIPPI = 0x30c + ARPHRD_HWX25 = 0x110 + ARPHRD_IEEE1394 = 0x18 + ARPHRD_IEEE802 = 0x6 + ARPHRD_IEEE80211 = 0x321 + ARPHRD_IEEE80211_PRISM = 0x322 + ARPHRD_IEEE80211_RADIOTAP = 0x323 + ARPHRD_IEEE802154 = 0x324 + ARPHRD_IEEE802154_MONITOR = 0x325 + ARPHRD_IEEE802_TR = 0x320 + ARPHRD_INFINIBAND = 0x20 + ARPHRD_IP6GRE = 0x337 + ARPHRD_IPDDP = 0x309 + ARPHRD_IPGRE = 0x30a + ARPHRD_IRDA = 0x30f + ARPHRD_LAPB = 0x204 + ARPHRD_LOCALTLK = 0x305 + ARPHRD_LOOPBACK = 0x304 + ARPHRD_METRICOM = 0x17 + ARPHRD_NETLINK = 0x338 + ARPHRD_NETROM = 0x0 + ARPHRD_NONE = 0xfffe + ARPHRD_PHONET = 0x334 + ARPHRD_PHONET_PIPE = 0x335 + ARPHRD_PIMREG = 0x30b + ARPHRD_PPP = 0x200 + ARPHRD_PRONET = 0x4 + ARPHRD_RAWHDLC = 0x206 + ARPHRD_ROSE = 0x10e + ARPHRD_RSRVD = 0x104 + ARPHRD_SIT = 0x308 + ARPHRD_SKIP = 0x303 + ARPHRD_SLIP = 0x100 + ARPHRD_SLIP6 = 0x102 + ARPHRD_TUNNEL = 0x300 + ARPHRD_TUNNEL6 = 0x301 + ARPHRD_VOID = 0xffff + ARPHRD_X25 = 0x10f + B0 = 0x0 + B1000000 = 0x1008 + B110 = 0x3 + B115200 = 0x1002 + B1152000 = 0x1009 + B1200 = 0x9 + B134 = 0x4 + B150 = 0x5 + B1500000 = 0x100a + B1800 = 0xa + B19200 = 0xe + B200 = 0x6 + B2000000 = 0x100b + B230400 = 0x1003 + B2400 = 0xb + B2500000 = 0x100c + B300 = 0x7 + B3000000 = 0x100d + B3500000 = 0x100e + B38400 = 0xf + B4000000 = 0x100f + B460800 = 0x1004 + B4800 = 0xc + B50 = 0x1 + B500000 = 0x1005 + B57600 = 0x1001 + B576000 = 0x1006 + B600 = 0x8 + B75 = 0x2 + B921600 = 0x1007 + B9600 = 0xd + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LL_OFF = -0x200000 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXINSNS = 0x1000 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MOD = 0x90 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_NET_OFF = -0x100000 + BPF_OR = 0x40 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BPF_XOR = 0xa0 + BRKINT = 0x2 + CFLUSH = 0xf + CLOCAL = 0x800 + CLOCK_BOOTTIME = 0x7 + CLOCK_BOOTTIME_ALARM = 0x9 + CLOCK_DEFAULT = 0x0 + CLOCK_EXT = 0x1 + CLOCK_INT = 0x2 + CLOCK_MONOTONIC = 0x1 + CLOCK_MONOTONIC_COARSE = 0x6 + CLOCK_MONOTONIC_RAW = 0x4 + CLOCK_PROCESS_CPUTIME_ID = 0x2 + CLOCK_REALTIME = 0x0 + CLOCK_REALTIME_ALARM = 0x8 + CLOCK_REALTIME_COARSE = 0x5 + CLOCK_TAI = 0xb + CLOCK_THREAD_CPUTIME_ID = 0x3 + CLOCK_TXFROMRX = 0x4 + CLOCK_TXINT = 0x3 + CLONE_CHILD_CLEARTID = 0x200000 + CLONE_CHILD_SETTID = 0x1000000 + CLONE_DETACHED = 0x400000 + CLONE_FILES = 0x400 + CLONE_FS = 0x200 + CLONE_IO = 0x80000000 + CLONE_NEWCGROUP = 0x2000000 + CLONE_NEWIPC = 0x8000000 + CLONE_NEWNET = 0x40000000 + CLONE_NEWNS = 0x20000 + CLONE_NEWPID = 0x20000000 + CLONE_NEWUSER = 0x10000000 + CLONE_NEWUTS = 0x4000000 + CLONE_PARENT = 0x8000 + CLONE_PARENT_SETTID = 0x100000 + CLONE_PTRACE = 0x2000 + CLONE_SETTLS = 0x80000 + CLONE_SIGHAND = 0x800 + CLONE_SYSVSEM = 0x40000 + CLONE_THREAD = 0x10000 + CLONE_UNTRACED = 0x800000 + CLONE_VFORK = 0x4000 + CLONE_VM = 0x100 + CREAD = 0x80 + CS5 = 0x0 + CS6 = 0x10 + CS7 = 0x20 + CS8 = 0x30 + CSIGNAL = 0xff + CSIZE = 0x30 + CSTART = 0x11 + CSTATUS = 0x0 + CSTOP = 0x13 + CSTOPB = 0x40 + CSUSP = 0x1a + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x200 + ECHOE = 0x10 + ECHOK = 0x20 + ECHOKE = 0x800 + ECHONL = 0x40 + ECHOPRT = 0x400 + ENCODING_DEFAULT = 0x0 + ENCODING_FM_MARK = 0x3 + ENCODING_FM_SPACE = 0x4 + ENCODING_MANCHESTER = 0x5 + ENCODING_NRZ = 0x1 + ENCODING_NRZI = 0x2 + EPOLLERR = 0x8 + EPOLLET = 0x80000000 + EPOLLHUP = 0x10 + EPOLLIN = 0x1 + EPOLLMSG = 0x400 + EPOLLONESHOT = 0x40000000 + EPOLLOUT = 0x4 + EPOLLPRI = 0x2 + EPOLLRDBAND = 0x80 + EPOLLRDHUP = 0x2000 + EPOLLRDNORM = 0x40 + EPOLLWAKEUP = 0x20000000 + EPOLLWRBAND = 0x200 + EPOLLWRNORM = 0x100 + EPOLL_CLOEXEC = 0x80000 + EPOLL_CTL_ADD = 0x1 + EPOLL_CTL_DEL = 0x2 + EPOLL_CTL_MOD = 0x3 + ETH_P_1588 = 0x88f7 + ETH_P_8021AD = 0x88a8 + ETH_P_8021AH = 0x88e7 + ETH_P_8021Q = 0x8100 + ETH_P_80221 = 0x8917 + ETH_P_802_2 = 0x4 + ETH_P_802_3 = 0x1 + ETH_P_802_3_MIN = 0x600 + ETH_P_802_EX1 = 0x88b5 + ETH_P_AARP = 0x80f3 + ETH_P_AF_IUCV = 0xfbfb + ETH_P_ALL = 0x3 + ETH_P_AOE = 0x88a2 + ETH_P_ARCNET = 0x1a + ETH_P_ARP = 0x806 + ETH_P_ATALK = 0x809b + ETH_P_ATMFATE = 0x8884 + ETH_P_ATMMPOA = 0x884c + ETH_P_AX25 = 0x2 + ETH_P_BATMAN = 0x4305 + ETH_P_BPQ = 0x8ff + ETH_P_CAIF = 0xf7 + ETH_P_CAN = 0xc + ETH_P_CANFD = 0xd + ETH_P_CONTROL = 0x16 + ETH_P_CUST = 0x6006 + ETH_P_DDCMP = 0x6 + ETH_P_DEC = 0x6000 + ETH_P_DIAG = 0x6005 + ETH_P_DNA_DL = 0x6001 + ETH_P_DNA_RC = 0x6002 + ETH_P_DNA_RT = 0x6003 + ETH_P_DSA = 0x1b + ETH_P_ECONET = 0x18 + ETH_P_EDSA = 0xdada + ETH_P_FCOE = 0x8906 + ETH_P_FIP = 0x8914 + ETH_P_HDLC = 0x19 + ETH_P_IEEE802154 = 0xf6 + ETH_P_IEEEPUP = 0xa00 + ETH_P_IEEEPUPAT = 0xa01 + ETH_P_IP = 0x800 + ETH_P_IPV6 = 0x86dd + ETH_P_IPX = 0x8137 + ETH_P_IRDA = 0x17 + ETH_P_LAT = 0x6004 + ETH_P_LINK_CTL = 0x886c + ETH_P_LOCALTALK = 0x9 + ETH_P_LOOP = 0x60 + ETH_P_LOOPBACK = 0x9000 + ETH_P_MOBITEX = 0x15 + ETH_P_MPLS_MC = 0x8848 + ETH_P_MPLS_UC = 0x8847 + ETH_P_MVRP = 0x88f5 + ETH_P_PAE = 0x888e + ETH_P_PAUSE = 0x8808 + ETH_P_PHONET = 0xf5 + ETH_P_PPPTALK = 0x10 + ETH_P_PPP_DISC = 0x8863 + ETH_P_PPP_MP = 0x8 + ETH_P_PPP_SES = 0x8864 + ETH_P_PRP = 0x88fb + ETH_P_PUP = 0x200 + ETH_P_PUPAT = 0x201 + ETH_P_QINQ1 = 0x9100 + ETH_P_QINQ2 = 0x9200 + ETH_P_QINQ3 = 0x9300 + ETH_P_RARP = 0x8035 + ETH_P_SCA = 0x6007 + ETH_P_SLOW = 0x8809 + ETH_P_SNAP = 0x5 + ETH_P_TDLS = 0x890d + ETH_P_TEB = 0x6558 + ETH_P_TIPC = 0x88ca + ETH_P_TRAILER = 0x1c + ETH_P_TR_802_2 = 0x11 + ETH_P_TSN = 0x22f0 + ETH_P_WAN_PPP = 0x7 + ETH_P_WCCP = 0x883e + ETH_P_X25 = 0x805 + ETH_P_XDSA = 0xf8 + EXTA = 0xe + EXTB = 0xf + EXTPROC = 0x10000 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FLUSHO = 0x2000 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x406 + F_EXLCK = 0x4 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLEASE = 0x401 + F_GETLK = 0xe + F_GETLK64 = 0xe + F_GETOWN = 0x17 + F_GETOWN_EX = 0x10 + F_GETPIPE_SZ = 0x408 + F_GETSIG = 0xb + F_LOCK = 0x1 + F_NOTIFY = 0x402 + F_OFD_GETLK = 0x24 + F_OFD_SETLK = 0x25 + F_OFD_SETLKW = 0x26 + F_OK = 0x0 + F_RDLCK = 0x0 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLEASE = 0x400 + F_SETLK = 0x6 + F_SETLK64 = 0x6 + F_SETLKW = 0x7 + F_SETLKW64 = 0x7 + F_SETOWN = 0x18 + F_SETOWN_EX = 0xf + F_SETPIPE_SZ = 0x407 + F_SETSIG = 0xa + F_SHLCK = 0x8 + F_TEST = 0x3 + F_TLOCK = 0x2 + F_ULOCK = 0x0 + F_UNLCK = 0x2 + F_WRLCK = 0x1 + HUPCL = 0x400 + ICANON = 0x2 + ICMPV6_FILTER = 0x1 + ICRNL = 0x100 + IEXTEN = 0x100 + IFA_F_DADFAILED = 0x8 + IFA_F_DEPRECATED = 0x20 + IFA_F_HOMEADDRESS = 0x10 + IFA_F_MANAGETEMPADDR = 0x100 + IFA_F_MCAUTOJOIN = 0x400 + IFA_F_NODAD = 0x2 + IFA_F_NOPREFIXROUTE = 0x200 + IFA_F_OPTIMISTIC = 0x4 + IFA_F_PERMANENT = 0x80 + IFA_F_SECONDARY = 0x1 + IFA_F_STABLE_PRIVACY = 0x800 + IFA_F_TEMPORARY = 0x1 + IFA_F_TENTATIVE = 0x40 + IFA_MAX = 0x8 + IFF_ALLMULTI = 0x200 + IFF_ATTACH_QUEUE = 0x200 + IFF_AUTOMEDIA = 0x4000 + IFF_BROADCAST = 0x2 + IFF_DEBUG = 0x4 + IFF_DETACH_QUEUE = 0x400 + IFF_DORMANT = 0x20000 + IFF_DYNAMIC = 0x8000 + IFF_ECHO = 0x40000 + IFF_LOOPBACK = 0x8 + IFF_LOWER_UP = 0x10000 + IFF_MASTER = 0x400 + IFF_MULTICAST = 0x1000 + IFF_MULTI_QUEUE = 0x100 + IFF_NOARP = 0x80 + IFF_NOFILTER = 0x1000 + IFF_NOTRAILERS = 0x20 + IFF_NO_PI = 0x1000 + IFF_ONE_QUEUE = 0x2000 + IFF_PERSIST = 0x800 + IFF_POINTOPOINT = 0x10 + IFF_PORTSEL = 0x2000 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SLAVE = 0x800 + IFF_TAP = 0x2 + IFF_TUN = 0x1 + IFF_TUN_EXCL = 0x8000 + IFF_UP = 0x1 + IFF_VNET_HDR = 0x4000 + IFF_VOLATILE = 0x70c5a + IFNAMSIZ = 0x10 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_ACCESS = 0x1 + IN_ALL_EVENTS = 0xfff + IN_ATTRIB = 0x4 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLOEXEC = 0x80000 + IN_CLOSE = 0x18 + IN_CLOSE_NOWRITE = 0x10 + IN_CLOSE_WRITE = 0x8 + IN_CREATE = 0x100 + IN_DELETE = 0x200 + IN_DELETE_SELF = 0x400 + IN_DONT_FOLLOW = 0x2000000 + IN_EXCL_UNLINK = 0x4000000 + IN_IGNORED = 0x8000 + IN_ISDIR = 0x40000000 + IN_LOOPBACKNET = 0x7f + IN_MASK_ADD = 0x20000000 + IN_MODIFY = 0x2 + IN_MOVE = 0xc0 + IN_MOVED_FROM = 0x40 + IN_MOVED_TO = 0x80 + IN_MOVE_SELF = 0x800 + IN_NONBLOCK = 0x80 + IN_ONESHOT = 0x80000000 + IN_ONLYDIR = 0x1000000 + IN_OPEN = 0x20 + IN_Q_OVERFLOW = 0x4000 + IN_UNMOUNT = 0x2000 + IPPROTO_AH = 0x33 + IPPROTO_BEETPH = 0x5e + IPPROTO_COMP = 0x6c + IPPROTO_DCCP = 0x21 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_ENCAP = 0x62 + IPPROTO_ESP = 0x32 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GRE = 0x2f + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IGMP = 0x2 + IPPROTO_IP = 0x0 + IPPROTO_IPIP = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_MH = 0x87 + IPPROTO_MTP = 0x5c + IPPROTO_NONE = 0x3b + IPPROTO_PIM = 0x67 + IPPROTO_PUP = 0xc + IPPROTO_RAW = 0xff + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_SCTP = 0x84 + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_UDP = 0x11 + IPPROTO_UDPLITE = 0x88 + IPV6_2292DSTOPTS = 0x4 + IPV6_2292HOPLIMIT = 0x8 + IPV6_2292HOPOPTS = 0x3 + IPV6_2292PKTINFO = 0x2 + IPV6_2292PKTOPTIONS = 0x6 + IPV6_2292RTHDR = 0x5 + IPV6_ADDRFORM = 0x1 + IPV6_ADD_MEMBERSHIP = 0x14 + IPV6_AUTHHDR = 0xa + IPV6_CHECKSUM = 0x7 + IPV6_DONTFRAG = 0x3e + IPV6_DROP_MEMBERSHIP = 0x15 + IPV6_DSTOPTS = 0x3b + IPV6_HOPLIMIT = 0x34 + IPV6_HOPOPTS = 0x36 + IPV6_IPSEC_POLICY = 0x22 + IPV6_JOIN_ANYCAST = 0x1b + IPV6_JOIN_GROUP = 0x14 + IPV6_LEAVE_ANYCAST = 0x1c + IPV6_LEAVE_GROUP = 0x15 + IPV6_MTU = 0x18 + IPV6_MTU_DISCOVER = 0x17 + IPV6_MULTICAST_HOPS = 0x12 + IPV6_MULTICAST_IF = 0x11 + IPV6_MULTICAST_LOOP = 0x13 + IPV6_NEXTHOP = 0x9 + IPV6_PATHMTU = 0x3d + IPV6_PKTINFO = 0x32 + IPV6_PMTUDISC_DO = 0x2 + IPV6_PMTUDISC_DONT = 0x0 + IPV6_PMTUDISC_INTERFACE = 0x4 + IPV6_PMTUDISC_OMIT = 0x5 + IPV6_PMTUDISC_PROBE = 0x3 + IPV6_PMTUDISC_WANT = 0x1 + IPV6_RECVDSTOPTS = 0x3a + IPV6_RECVERR = 0x19 + IPV6_RECVHOPLIMIT = 0x33 + IPV6_RECVHOPOPTS = 0x35 + IPV6_RECVPATHMTU = 0x3c + IPV6_RECVPKTINFO = 0x31 + IPV6_RECVRTHDR = 0x38 + IPV6_RECVTCLASS = 0x42 + IPV6_ROUTER_ALERT = 0x16 + IPV6_RTHDR = 0x39 + IPV6_RTHDRDSTOPTS = 0x37 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_RXDSTOPTS = 0x3b + IPV6_RXHOPOPTS = 0x36 + IPV6_TCLASS = 0x43 + IPV6_UNICAST_HOPS = 0x10 + IPV6_V6ONLY = 0x1a + IPV6_XFRM_POLICY = 0x23 + IP_ADD_MEMBERSHIP = 0x23 + IP_ADD_SOURCE_MEMBERSHIP = 0x27 + IP_BLOCK_SOURCE = 0x26 + IP_CHECKSUM = 0x17 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DROP_MEMBERSHIP = 0x24 + IP_DROP_SOURCE_MEMBERSHIP = 0x28 + IP_FREEBIND = 0xf + IP_HDRINCL = 0x3 + IP_IPSEC_POLICY = 0x10 + IP_MAXPACKET = 0xffff + IP_MAX_MEMBERSHIPS = 0x14 + IP_MF = 0x2000 + IP_MINTTL = 0x15 + IP_MSFILTER = 0x29 + IP_MSS = 0x240 + IP_MTU = 0xe + IP_MTU_DISCOVER = 0xa + IP_MULTICAST_ALL = 0x31 + IP_MULTICAST_IF = 0x20 + IP_MULTICAST_LOOP = 0x22 + IP_MULTICAST_TTL = 0x21 + IP_NODEFRAG = 0x16 + IP_OFFMASK = 0x1fff + IP_OPTIONS = 0x4 + IP_ORIGDSTADDR = 0x14 + IP_PASSSEC = 0x12 + IP_PKTINFO = 0x8 + IP_PKTOPTIONS = 0x9 + IP_PMTUDISC = 0xa + IP_PMTUDISC_DO = 0x2 + IP_PMTUDISC_DONT = 0x0 + IP_PMTUDISC_INTERFACE = 0x4 + IP_PMTUDISC_OMIT = 0x5 + IP_PMTUDISC_PROBE = 0x3 + IP_PMTUDISC_WANT = 0x1 + IP_RECVERR = 0xb + IP_RECVOPTS = 0x6 + IP_RECVORIGDSTADDR = 0x14 + IP_RECVRETOPTS = 0x7 + IP_RECVTOS = 0xd + IP_RECVTTL = 0xc + IP_RETOPTS = 0x7 + IP_RF = 0x8000 + IP_ROUTER_ALERT = 0x5 + IP_TOS = 0x1 + IP_TRANSPARENT = 0x13 + IP_TTL = 0x2 + IP_UNBLOCK_SOURCE = 0x25 + IP_UNICAST_IF = 0x32 + IP_XFRM_POLICY = 0x11 + ISIG = 0x1 + ISTRIP = 0x20 + IUTF8 = 0x4000 + IXANY = 0x800 + IXOFF = 0x1000 + IXON = 0x400 + LINUX_REBOOT_CMD_CAD_OFF = 0x0 + LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef + LINUX_REBOOT_CMD_HALT = 0xcdef0123 + LINUX_REBOOT_CMD_KEXEC = 0x45584543 + LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc + LINUX_REBOOT_CMD_RESTART = 0x1234567 + LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4 + LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2 + LINUX_REBOOT_MAGIC1 = 0xfee1dead + LINUX_REBOOT_MAGIC2 = 0x28121969 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_DODUMP = 0x11 + MADV_DOFORK = 0xb + MADV_DONTDUMP = 0x10 + MADV_DONTFORK = 0xa + MADV_DONTNEED = 0x4 + MADV_HUGEPAGE = 0xe + MADV_HWPOISON = 0x64 + MADV_MERGEABLE = 0xc + MADV_NOHUGEPAGE = 0xf + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_REMOVE = 0x9 + MADV_SEQUENTIAL = 0x2 + MADV_UNMERGEABLE = 0xd + MADV_WILLNEED = 0x3 + MAP_ANON = 0x800 + MAP_ANONYMOUS = 0x800 + MAP_DENYWRITE = 0x2000 + MAP_EXECUTABLE = 0x4000 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_GROWSDOWN = 0x1000 + MAP_HUGETLB = 0x80000 + MAP_HUGE_MASK = 0x3f + MAP_HUGE_SHIFT = 0x1a + MAP_LOCKED = 0x8000 + MAP_NONBLOCK = 0x20000 + MAP_NORESERVE = 0x400 + MAP_POPULATE = 0x10000 + MAP_PRIVATE = 0x2 + MAP_RENAME = 0x800 + MAP_SHARED = 0x1 + MAP_STACK = 0x40000 + MAP_TYPE = 0xf + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MNT_DETACH = 0x2 + MNT_EXPIRE = 0x4 + MNT_FORCE = 0x1 + MSG_CMSG_CLOEXEC = 0x40000000 + MSG_CONFIRM = 0x800 + MSG_CTRUNC = 0x8 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x40 + MSG_EOR = 0x80 + MSG_ERRQUEUE = 0x2000 + MSG_FASTOPEN = 0x20000000 + MSG_FIN = 0x200 + MSG_MORE = 0x8000 + MSG_NOSIGNAL = 0x4000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_PROXY = 0x10 + MSG_RST = 0x1000 + MSG_SYN = 0x400 + MSG_TRUNC = 0x20 + MSG_TRYHARD = 0x4 + MSG_WAITALL = 0x100 + MSG_WAITFORONE = 0x10000 + MS_ACTIVE = 0x40000000 + MS_ASYNC = 0x1 + MS_BIND = 0x1000 + MS_DIRSYNC = 0x80 + MS_INVALIDATE = 0x2 + MS_I_VERSION = 0x800000 + MS_KERNMOUNT = 0x400000 + MS_LAZYTIME = 0x2000000 + MS_MANDLOCK = 0x40 + MS_MGC_MSK = 0xffff0000 + MS_MGC_VAL = 0xc0ed0000 + MS_MOVE = 0x2000 + MS_NOATIME = 0x400 + MS_NODEV = 0x4 + MS_NODIRATIME = 0x800 + MS_NOEXEC = 0x8 + MS_NOSUID = 0x2 + MS_NOUSER = -0x80000000 + MS_POSIXACL = 0x10000 + MS_PRIVATE = 0x40000 + MS_RDONLY = 0x1 + MS_REC = 0x4000 + MS_RELATIME = 0x200000 + MS_REMOUNT = 0x20 + MS_RMT_MASK = 0x2800051 + MS_SHARED = 0x100000 + MS_SILENT = 0x8000 + MS_SLAVE = 0x80000 + MS_STRICTATIME = 0x1000000 + MS_SYNC = 0x4 + MS_SYNCHRONOUS = 0x10 + MS_UNBINDABLE = 0x20000 + NAME_MAX = 0xff + NETLINK_ADD_MEMBERSHIP = 0x1 + NETLINK_AUDIT = 0x9 + NETLINK_BROADCAST_ERROR = 0x4 + NETLINK_CAP_ACK = 0xa + NETLINK_CONNECTOR = 0xb + NETLINK_CRYPTO = 0x15 + NETLINK_DNRTMSG = 0xe + NETLINK_DROP_MEMBERSHIP = 0x2 + NETLINK_ECRYPTFS = 0x13 + NETLINK_FIB_LOOKUP = 0xa + NETLINK_FIREWALL = 0x3 + NETLINK_GENERIC = 0x10 + NETLINK_INET_DIAG = 0x4 + NETLINK_IP6_FW = 0xd + NETLINK_ISCSI = 0x8 + NETLINK_KOBJECT_UEVENT = 0xf + NETLINK_LISTEN_ALL_NSID = 0x8 + NETLINK_LIST_MEMBERSHIPS = 0x9 + NETLINK_NETFILTER = 0xc + NETLINK_NFLOG = 0x5 + NETLINK_NO_ENOBUFS = 0x5 + NETLINK_PKTINFO = 0x3 + NETLINK_RDMA = 0x14 + NETLINK_ROUTE = 0x0 + NETLINK_RX_RING = 0x6 + NETLINK_SCSITRANSPORT = 0x12 + NETLINK_SELINUX = 0x7 + NETLINK_SOCK_DIAG = 0x4 + NETLINK_TX_RING = 0x7 + NETLINK_UNUSED = 0x1 + NETLINK_USERSOCK = 0x2 + NETLINK_XFRM = 0x6 + NLA_ALIGNTO = 0x4 + NLA_F_NESTED = 0x8000 + NLA_F_NET_BYTEORDER = 0x4000 + NLA_HDRLEN = 0x4 + NLMSG_ALIGNTO = 0x4 + NLMSG_DONE = 0x3 + NLMSG_ERROR = 0x2 + NLMSG_HDRLEN = 0x10 + NLMSG_MIN_TYPE = 0x10 + NLMSG_NOOP = 0x1 + NLMSG_OVERRUN = 0x4 + NLM_F_ACK = 0x4 + NLM_F_APPEND = 0x800 + NLM_F_ATOMIC = 0x400 + NLM_F_CREATE = 0x400 + NLM_F_DUMP = 0x300 + NLM_F_DUMP_INTR = 0x10 + NLM_F_ECHO = 0x8 + NLM_F_EXCL = 0x200 + NLM_F_MATCH = 0x200 + NLM_F_MULTI = 0x2 + NLM_F_REPLACE = 0x100 + NLM_F_REQUEST = 0x1 + NLM_F_ROOT = 0x100 + NOFLSH = 0x80 + OCRNL = 0x8 + OFDEL = 0x80 + OFILL = 0x40 + ONLCR = 0x4 + ONLRET = 0x20 + ONOCR = 0x10 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_APPEND = 0x8 + O_ASYNC = 0x1000 + O_CLOEXEC = 0x80000 + O_CREAT = 0x100 + O_DIRECT = 0x8000 + O_DIRECTORY = 0x10000 + O_DSYNC = 0x10 + O_EXCL = 0x400 + O_FSYNC = 0x4010 + O_LARGEFILE = 0x0 + O_NDELAY = 0x80 + O_NOATIME = 0x40000 + O_NOCTTY = 0x800 + O_NOFOLLOW = 0x20000 + O_NONBLOCK = 0x80 + O_PATH = 0x200000 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_RSYNC = 0x4010 + O_SYNC = 0x4010 + O_TMPFILE = 0x410000 + O_TRUNC = 0x200 + O_WRONLY = 0x1 + PACKET_ADD_MEMBERSHIP = 0x1 + PACKET_AUXDATA = 0x8 + PACKET_BROADCAST = 0x1 + PACKET_COPY_THRESH = 0x7 + PACKET_DROP_MEMBERSHIP = 0x2 + PACKET_FANOUT = 0x12 + PACKET_FANOUT_CBPF = 0x6 + PACKET_FANOUT_CPU = 0x2 + PACKET_FANOUT_DATA = 0x16 + PACKET_FANOUT_EBPF = 0x7 + PACKET_FANOUT_FLAG_DEFRAG = 0x8000 + PACKET_FANOUT_FLAG_ROLLOVER = 0x1000 + PACKET_FANOUT_HASH = 0x0 + PACKET_FANOUT_LB = 0x1 + PACKET_FANOUT_QM = 0x5 + PACKET_FANOUT_RND = 0x4 + PACKET_FANOUT_ROLLOVER = 0x3 + PACKET_FASTROUTE = 0x6 + PACKET_HDRLEN = 0xb + PACKET_HOST = 0x0 + PACKET_KERNEL = 0x7 + PACKET_LOOPBACK = 0x5 + PACKET_LOSS = 0xe + PACKET_MR_ALLMULTI = 0x2 + PACKET_MR_MULTICAST = 0x0 + PACKET_MR_PROMISC = 0x1 + PACKET_MR_UNICAST = 0x3 + PACKET_MULTICAST = 0x2 + PACKET_ORIGDEV = 0x9 + PACKET_OTHERHOST = 0x3 + PACKET_OUTGOING = 0x4 + PACKET_QDISC_BYPASS = 0x14 + PACKET_RECV_OUTPUT = 0x3 + PACKET_RESERVE = 0xc + PACKET_ROLLOVER_STATS = 0x15 + PACKET_RX_RING = 0x5 + PACKET_STATISTICS = 0x6 + PACKET_TIMESTAMP = 0x11 + PACKET_TX_HAS_OFF = 0x13 + PACKET_TX_RING = 0xd + PACKET_TX_TIMESTAMP = 0x10 + PACKET_USER = 0x6 + PACKET_VERSION = 0xa + PACKET_VNET_HDR = 0xf + PARENB = 0x100 + PARITY_CRC16_PR0 = 0x2 + PARITY_CRC16_PR0_CCITT = 0x4 + PARITY_CRC16_PR1 = 0x3 + PARITY_CRC16_PR1_CCITT = 0x5 + PARITY_CRC32_PR0_CCITT = 0x6 + PARITY_CRC32_PR1_CCITT = 0x7 + PARITY_DEFAULT = 0x0 + PARITY_NONE = 0x1 + PARMRK = 0x8 + PARODD = 0x200 + PENDIN = 0x4000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_GROWSDOWN = 0x1000000 + PROT_GROWSUP = 0x2000000 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + PR_CAPBSET_DROP = 0x18 + PR_CAPBSET_READ = 0x17 + PR_CAP_AMBIENT = 0x2f + PR_CAP_AMBIENT_CLEAR_ALL = 0x4 + PR_CAP_AMBIENT_IS_SET = 0x1 + PR_CAP_AMBIENT_LOWER = 0x3 + PR_CAP_AMBIENT_RAISE = 0x2 + PR_ENDIAN_BIG = 0x0 + PR_ENDIAN_LITTLE = 0x1 + PR_ENDIAN_PPC_LITTLE = 0x2 + PR_FPEMU_NOPRINT = 0x1 + PR_FPEMU_SIGFPE = 0x2 + PR_FP_EXC_ASYNC = 0x2 + PR_FP_EXC_DISABLED = 0x0 + PR_FP_EXC_DIV = 0x10000 + PR_FP_EXC_INV = 0x100000 + PR_FP_EXC_NONRECOV = 0x1 + PR_FP_EXC_OVF = 0x20000 + PR_FP_EXC_PRECISE = 0x3 + PR_FP_EXC_RES = 0x80000 + PR_FP_EXC_SW_ENABLE = 0x80 + PR_FP_EXC_UND = 0x40000 + PR_FP_MODE_FR = 0x1 + PR_FP_MODE_FRE = 0x2 + PR_GET_CHILD_SUBREAPER = 0x25 + PR_GET_DUMPABLE = 0x3 + PR_GET_ENDIAN = 0x13 + PR_GET_FPEMU = 0x9 + PR_GET_FPEXC = 0xb + PR_GET_FP_MODE = 0x2e + PR_GET_KEEPCAPS = 0x7 + PR_GET_NAME = 0x10 + PR_GET_NO_NEW_PRIVS = 0x27 + PR_GET_PDEATHSIG = 0x2 + PR_GET_SECCOMP = 0x15 + PR_GET_SECUREBITS = 0x1b + PR_GET_THP_DISABLE = 0x2a + PR_GET_TID_ADDRESS = 0x28 + PR_GET_TIMERSLACK = 0x1e + PR_GET_TIMING = 0xd + PR_GET_TSC = 0x19 + PR_GET_UNALIGN = 0x5 + PR_MCE_KILL = 0x21 + PR_MCE_KILL_CLEAR = 0x0 + PR_MCE_KILL_DEFAULT = 0x2 + PR_MCE_KILL_EARLY = 0x1 + PR_MCE_KILL_GET = 0x22 + PR_MCE_KILL_LATE = 0x0 + PR_MCE_KILL_SET = 0x1 + PR_MPX_DISABLE_MANAGEMENT = 0x2c + PR_MPX_ENABLE_MANAGEMENT = 0x2b + PR_SET_CHILD_SUBREAPER = 0x24 + PR_SET_DUMPABLE = 0x4 + PR_SET_ENDIAN = 0x14 + PR_SET_FPEMU = 0xa + PR_SET_FPEXC = 0xc + PR_SET_FP_MODE = 0x2d + PR_SET_KEEPCAPS = 0x8 + PR_SET_MM = 0x23 + PR_SET_MM_ARG_END = 0x9 + PR_SET_MM_ARG_START = 0x8 + PR_SET_MM_AUXV = 0xc + PR_SET_MM_BRK = 0x7 + PR_SET_MM_END_CODE = 0x2 + PR_SET_MM_END_DATA = 0x4 + PR_SET_MM_ENV_END = 0xb + PR_SET_MM_ENV_START = 0xa + PR_SET_MM_EXE_FILE = 0xd + PR_SET_MM_MAP = 0xe + PR_SET_MM_MAP_SIZE = 0xf + PR_SET_MM_START_BRK = 0x6 + PR_SET_MM_START_CODE = 0x1 + PR_SET_MM_START_DATA = 0x3 + PR_SET_MM_START_STACK = 0x5 + PR_SET_NAME = 0xf + PR_SET_NO_NEW_PRIVS = 0x26 + PR_SET_PDEATHSIG = 0x1 + PR_SET_PTRACER = 0x59616d61 + PR_SET_PTRACER_ANY = -0x1 + PR_SET_SECCOMP = 0x16 + PR_SET_SECUREBITS = 0x1c + PR_SET_THP_DISABLE = 0x29 + PR_SET_TIMERSLACK = 0x1d + PR_SET_TIMING = 0xe + PR_SET_TSC = 0x1a + PR_SET_UNALIGN = 0x6 + PR_TASK_PERF_EVENTS_DISABLE = 0x1f + PR_TASK_PERF_EVENTS_ENABLE = 0x20 + PR_TIMING_STATISTICAL = 0x0 + PR_TIMING_TIMESTAMP = 0x1 + PR_TSC_ENABLE = 0x1 + PR_TSC_SIGSEGV = 0x2 + PR_UNALIGN_NOPRINT = 0x1 + PR_UNALIGN_SIGBUS = 0x2 + PTRACE_ATTACH = 0x10 + PTRACE_CONT = 0x7 + PTRACE_DETACH = 0x11 + PTRACE_EVENT_CLONE = 0x3 + PTRACE_EVENT_EXEC = 0x4 + PTRACE_EVENT_EXIT = 0x6 + PTRACE_EVENT_FORK = 0x1 + PTRACE_EVENT_SECCOMP = 0x7 + PTRACE_EVENT_STOP = 0x80 + PTRACE_EVENT_VFORK = 0x2 + PTRACE_EVENT_VFORK_DONE = 0x5 + PTRACE_GETEVENTMSG = 0x4201 + PTRACE_GETFPREGS = 0xe + PTRACE_GETREGS = 0xc + PTRACE_GETREGSET = 0x4204 + PTRACE_GETSIGINFO = 0x4202 + PTRACE_GETSIGMASK = 0x420a + PTRACE_GET_THREAD_AREA = 0x19 + PTRACE_GET_THREAD_AREA_3264 = 0xc4 + PTRACE_GET_WATCH_REGS = 0xd0 + PTRACE_INTERRUPT = 0x4207 + PTRACE_KILL = 0x8 + PTRACE_LISTEN = 0x4208 + PTRACE_OLDSETOPTIONS = 0x15 + PTRACE_O_EXITKILL = 0x100000 + PTRACE_O_MASK = 0x3000ff + PTRACE_O_SUSPEND_SECCOMP = 0x200000 + PTRACE_O_TRACECLONE = 0x8 + PTRACE_O_TRACEEXEC = 0x10 + PTRACE_O_TRACEEXIT = 0x40 + PTRACE_O_TRACEFORK = 0x2 + PTRACE_O_TRACESECCOMP = 0x80 + PTRACE_O_TRACESYSGOOD = 0x1 + PTRACE_O_TRACEVFORK = 0x4 + PTRACE_O_TRACEVFORKDONE = 0x20 + PTRACE_PEEKDATA = 0x2 + PTRACE_PEEKDATA_3264 = 0xc1 + PTRACE_PEEKSIGINFO = 0x4209 + PTRACE_PEEKSIGINFO_SHARED = 0x1 + PTRACE_PEEKTEXT = 0x1 + PTRACE_PEEKTEXT_3264 = 0xc0 + PTRACE_PEEKUSR = 0x3 + PTRACE_POKEDATA = 0x5 + PTRACE_POKEDATA_3264 = 0xc3 + PTRACE_POKETEXT = 0x4 + PTRACE_POKETEXT_3264 = 0xc2 + PTRACE_POKEUSR = 0x6 + PTRACE_SEIZE = 0x4206 + PTRACE_SETFPREGS = 0xf + PTRACE_SETOPTIONS = 0x4200 + PTRACE_SETREGS = 0xd + PTRACE_SETREGSET = 0x4205 + PTRACE_SETSIGINFO = 0x4203 + PTRACE_SETSIGMASK = 0x420b + PTRACE_SET_THREAD_AREA = 0x1a + PTRACE_SET_WATCH_REGS = 0xd1 + PTRACE_SINGLESTEP = 0x9 + PTRACE_SYSCALL = 0x18 + PTRACE_TRACEME = 0x0 + RLIMIT_AS = 0x6 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x5 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = -0x1 + RTAX_ADVMSS = 0x8 + RTAX_CC_ALGO = 0x10 + RTAX_CWND = 0x7 + RTAX_FEATURES = 0xc + RTAX_FEATURE_ALLFRAG = 0x8 + RTAX_FEATURE_ECN = 0x1 + RTAX_FEATURE_MASK = 0xf + RTAX_FEATURE_SACK = 0x2 + RTAX_FEATURE_TIMESTAMP = 0x4 + RTAX_HOPLIMIT = 0xa + RTAX_INITCWND = 0xb + RTAX_INITRWND = 0xe + RTAX_LOCK = 0x1 + RTAX_MAX = 0x10 + RTAX_MTU = 0x2 + RTAX_QUICKACK = 0xf + RTAX_REORDERING = 0x9 + RTAX_RTO_MIN = 0xd + RTAX_RTT = 0x4 + RTAX_RTTVAR = 0x5 + RTAX_SSTHRESH = 0x6 + RTAX_UNSPEC = 0x0 + RTAX_WINDOW = 0x3 + RTA_ALIGNTO = 0x4 + RTA_MAX = 0x16 + RTCF_DIRECTSRC = 0x4000000 + RTCF_DOREDIRECT = 0x1000000 + RTCF_LOG = 0x2000000 + RTCF_MASQ = 0x400000 + RTCF_NAT = 0x800000 + RTCF_VALVE = 0x200000 + RTF_ADDRCLASSMASK = 0xf8000000 + RTF_ADDRCONF = 0x40000 + RTF_ALLONLINK = 0x20000 + RTF_BROADCAST = 0x10000000 + RTF_CACHE = 0x1000000 + RTF_DEFAULT = 0x10000 + RTF_DYNAMIC = 0x10 + RTF_FLOW = 0x2000000 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_INTERFACE = 0x40000000 + RTF_IRTT = 0x100 + RTF_LINKRT = 0x100000 + RTF_LOCAL = 0x80000000 + RTF_MODIFIED = 0x20 + RTF_MSS = 0x40 + RTF_MTU = 0x40 + RTF_MULTICAST = 0x20000000 + RTF_NAT = 0x8000000 + RTF_NOFORWARD = 0x1000 + RTF_NONEXTHOP = 0x200000 + RTF_NOPMTUDISC = 0x4000 + RTF_POLICY = 0x4000000 + RTF_REINSTATE = 0x8 + RTF_REJECT = 0x200 + RTF_STATIC = 0x400 + RTF_THROW = 0x2000 + RTF_UP = 0x1 + RTF_WINDOW = 0x80 + RTF_XRESOLVE = 0x800 + RTM_BASE = 0x10 + RTM_DELACTION = 0x31 + RTM_DELADDR = 0x15 + RTM_DELADDRLABEL = 0x49 + RTM_DELLINK = 0x11 + RTM_DELMDB = 0x55 + RTM_DELNEIGH = 0x1d + RTM_DELNSID = 0x59 + RTM_DELQDISC = 0x25 + RTM_DELROUTE = 0x19 + RTM_DELRULE = 0x21 + RTM_DELTCLASS = 0x29 + RTM_DELTFILTER = 0x2d + RTM_F_CLONED = 0x200 + RTM_F_EQUALIZE = 0x400 + RTM_F_NOTIFY = 0x100 + RTM_F_PREFIX = 0x800 + RTM_GETACTION = 0x32 + RTM_GETADDR = 0x16 + RTM_GETADDRLABEL = 0x4a + RTM_GETANYCAST = 0x3e + RTM_GETDCB = 0x4e + RTM_GETLINK = 0x12 + RTM_GETMDB = 0x56 + RTM_GETMULTICAST = 0x3a + RTM_GETNEIGH = 0x1e + RTM_GETNEIGHTBL = 0x42 + RTM_GETNETCONF = 0x52 + RTM_GETNSID = 0x5a + RTM_GETQDISC = 0x26 + RTM_GETROUTE = 0x1a + RTM_GETRULE = 0x22 + RTM_GETTCLASS = 0x2a + RTM_GETTFILTER = 0x2e + RTM_MAX = 0x5b + RTM_NEWACTION = 0x30 + RTM_NEWADDR = 0x14 + RTM_NEWADDRLABEL = 0x48 + RTM_NEWLINK = 0x10 + RTM_NEWMDB = 0x54 + RTM_NEWNDUSEROPT = 0x44 + RTM_NEWNEIGH = 0x1c + RTM_NEWNEIGHTBL = 0x40 + RTM_NEWNETCONF = 0x50 + RTM_NEWNSID = 0x58 + RTM_NEWPREFIX = 0x34 + RTM_NEWQDISC = 0x24 + RTM_NEWROUTE = 0x18 + RTM_NEWRULE = 0x20 + RTM_NEWTCLASS = 0x28 + RTM_NEWTFILTER = 0x2c + RTM_NR_FAMILIES = 0x13 + RTM_NR_MSGTYPES = 0x4c + RTM_SETDCB = 0x4f + RTM_SETLINK = 0x13 + RTM_SETNEIGHTBL = 0x43 + RTNH_ALIGNTO = 0x4 + RTNH_COMPARE_MASK = 0x11 + RTNH_F_DEAD = 0x1 + RTNH_F_LINKDOWN = 0x10 + RTNH_F_OFFLOAD = 0x8 + RTNH_F_ONLINK = 0x4 + RTNH_F_PERVASIVE = 0x2 + RTN_MAX = 0xb + RTPROT_BABEL = 0x2a + RTPROT_BIRD = 0xc + RTPROT_BOOT = 0x3 + RTPROT_DHCP = 0x10 + RTPROT_DNROUTED = 0xd + RTPROT_GATED = 0x8 + RTPROT_KERNEL = 0x2 + RTPROT_MROUTED = 0x11 + RTPROT_MRT = 0xa + RTPROT_NTK = 0xf + RTPROT_RA = 0x9 + RTPROT_REDIRECT = 0x1 + RTPROT_STATIC = 0x4 + RTPROT_UNSPEC = 0x0 + RTPROT_XORP = 0xe + RTPROT_ZEBRA = 0xb + RT_CLASS_DEFAULT = 0xfd + RT_CLASS_LOCAL = 0xff + RT_CLASS_MAIN = 0xfe + RT_CLASS_MAX = 0xff + RT_CLASS_UNSPEC = 0x0 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + RUSAGE_THREAD = 0x1 + SCM_CREDENTIALS = 0x2 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x1d + SCM_TIMESTAMPING = 0x25 + SCM_TIMESTAMPNS = 0x23 + SCM_WIFI_STATUS = 0x29 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDDLCI = 0x8980 + SIOCADDMULTI = 0x8931 + SIOCADDRT = 0x890b + SIOCATMARK = 0x40047307 + SIOCDARP = 0x8953 + SIOCDELDLCI = 0x8981 + SIOCDELMULTI = 0x8932 + SIOCDELRT = 0x890c + SIOCDEVPRIVATE = 0x89f0 + SIOCDIFADDR = 0x8936 + SIOCDRARP = 0x8960 + SIOCGARP = 0x8954 + SIOCGIFADDR = 0x8915 + SIOCGIFBR = 0x8940 + SIOCGIFBRDADDR = 0x8919 + SIOCGIFCONF = 0x8912 + SIOCGIFCOUNT = 0x8938 + SIOCGIFDSTADDR = 0x8917 + SIOCGIFENCAP = 0x8925 + SIOCGIFFLAGS = 0x8913 + SIOCGIFHWADDR = 0x8927 + SIOCGIFINDEX = 0x8933 + SIOCGIFMAP = 0x8970 + SIOCGIFMEM = 0x891f + SIOCGIFMETRIC = 0x891d + SIOCGIFMTU = 0x8921 + SIOCGIFNAME = 0x8910 + SIOCGIFNETMASK = 0x891b + SIOCGIFPFLAGS = 0x8935 + SIOCGIFSLAVE = 0x8929 + SIOCGIFTXQLEN = 0x8942 + SIOCGPGRP = 0x40047309 + SIOCGRARP = 0x8961 + SIOCGSTAMP = 0x8906 + SIOCGSTAMPNS = 0x8907 + SIOCPROTOPRIVATE = 0x89e0 + SIOCRTMSG = 0x890d + SIOCSARP = 0x8955 + SIOCSIFADDR = 0x8916 + SIOCSIFBR = 0x8941 + SIOCSIFBRDADDR = 0x891a + SIOCSIFDSTADDR = 0x8918 + SIOCSIFENCAP = 0x8926 + SIOCSIFFLAGS = 0x8914 + SIOCSIFHWADDR = 0x8924 + SIOCSIFHWBROADCAST = 0x8937 + SIOCSIFLINK = 0x8911 + SIOCSIFMAP = 0x8971 + SIOCSIFMEM = 0x8920 + SIOCSIFMETRIC = 0x891e + SIOCSIFMTU = 0x8922 + SIOCSIFNAME = 0x8923 + SIOCSIFNETMASK = 0x891c + SIOCSIFPFLAGS = 0x8934 + SIOCSIFSLAVE = 0x8930 + SIOCSIFTXQLEN = 0x8943 + SIOCSPGRP = 0x80047308 + SIOCSRARP = 0x8962 + SOCK_CLOEXEC = 0x80000 + SOCK_DCCP = 0x6 + SOCK_DGRAM = 0x1 + SOCK_NONBLOCK = 0x80 + SOCK_PACKET = 0xa + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x2 + SOL_AAL = 0x109 + SOL_ATM = 0x108 + SOL_DECNET = 0x105 + SOL_ICMPV6 = 0x3a + SOL_IP = 0x0 + SOL_IPV6 = 0x29 + SOL_IRDA = 0x10a + SOL_PACKET = 0x107 + SOL_RAW = 0xff + SOL_SOCKET = 0xffff + SOL_TCP = 0x6 + SOL_X25 = 0x106 + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x1009 + SO_ATTACH_BPF = 0x32 + SO_ATTACH_FILTER = 0x1a + SO_BINDTODEVICE = 0x19 + SO_BPF_EXTENSIONS = 0x30 + SO_BROADCAST = 0x20 + SO_BSDCOMPAT = 0xe + SO_BUSY_POLL = 0x2e + SO_DEBUG = 0x1 + SO_DETACH_BPF = 0x1b + SO_DETACH_FILTER = 0x1b + SO_DOMAIN = 0x1029 + SO_DONTROUTE = 0x10 + SO_ERROR = 0x1007 + SO_GET_FILTER = 0x1a + SO_INCOMING_CPU = 0x31 + SO_KEEPALIVE = 0x8 + SO_LINGER = 0x80 + SO_LOCK_FILTER = 0x2c + SO_MARK = 0x24 + SO_MAX_PACING_RATE = 0x2f + SO_NOFCS = 0x2b + SO_NO_CHECK = 0xb + SO_OOBINLINE = 0x100 + SO_PASSCRED = 0x11 + SO_PASSSEC = 0x22 + SO_PEEK_OFF = 0x2a + SO_PEERCRED = 0x12 + SO_PEERNAME = 0x1c + SO_PEERSEC = 0x1e + SO_PRIORITY = 0xc + SO_PROTOCOL = 0x1028 + SO_RCVBUF = 0x1002 + SO_RCVBUFFORCE = 0x21 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x1006 + SO_REUSEADDR = 0x4 + SO_REUSEPORT = 0x200 + SO_RXQ_OVFL = 0x28 + SO_SECURITY_AUTHENTICATION = 0x16 + SO_SECURITY_ENCRYPTION_NETWORK = 0x18 + SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17 + SO_SELECT_ERR_QUEUE = 0x2d + SO_SNDBUF = 0x1001 + SO_SNDBUFFORCE = 0x1f + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x1005 + SO_STYLE = 0x1008 + SO_TIMESTAMP = 0x1d + SO_TIMESTAMPING = 0x25 + SO_TIMESTAMPNS = 0x23 + SO_TYPE = 0x1008 + SO_WIFI_STATUS = 0x29 + S_BLKSIZE = 0x200 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + TCFLSH = 0x5407 + TCIFLUSH = 0x0 + TCIOFLUSH = 0x2 + TCOFLUSH = 0x1 + TCP_CONGESTION = 0xd + TCP_COOKIE_IN_ALWAYS = 0x1 + TCP_COOKIE_MAX = 0x10 + TCP_COOKIE_MIN = 0x8 + TCP_COOKIE_OUT_NEVER = 0x2 + TCP_COOKIE_PAIR_SIZE = 0x20 + TCP_COOKIE_TRANSACTIONS = 0xf + TCP_CORK = 0x3 + TCP_DEFER_ACCEPT = 0x9 + TCP_FASTOPEN = 0x17 + TCP_INFO = 0xb + TCP_KEEPCNT = 0x6 + TCP_KEEPIDLE = 0x4 + TCP_KEEPINTVL = 0x5 + TCP_LINGER2 = 0x8 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0xe + TCP_MD5SIG_MAXKEYLEN = 0x50 + TCP_MSS = 0x200 + TCP_MSS_DEFAULT = 0x218 + TCP_MSS_DESIRED = 0x4c4 + TCP_NODELAY = 0x1 + TCP_QUEUE_SEQ = 0x15 + TCP_QUICKACK = 0xc + TCP_REPAIR = 0x13 + TCP_REPAIR_OPTIONS = 0x16 + TCP_REPAIR_QUEUE = 0x14 + TCP_SYNCNT = 0x7 + TCP_S_DATA_IN = 0x4 + TCP_S_DATA_OUT = 0x8 + TCP_THIN_DUPACK = 0x11 + TCP_THIN_LINEAR_TIMEOUTS = 0x10 + TCP_TIMESTAMP = 0x18 + TCP_USER_TIMEOUT = 0x12 + TCP_WINDOW_CLAMP = 0xa + TCSAFLUSH = 0x5410 + TCSBRK = 0x5405 + TCXONC = 0x5406 + TIOCCBRK = 0x5428 + TIOCCONS = 0x80047478 + TIOCEXCL = 0x740d + TIOCGDEV = 0x40045432 + TIOCGETD = 0x7400 + TIOCGETP = 0x7408 + TIOCGEXCL = 0x40045440 + TIOCGICOUNT = 0x5492 + TIOCGLCKTRMIOS = 0x548b + TIOCGLTC = 0x7474 + TIOCGPGRP = 0x40047477 + TIOCGPKT = 0x40045438 + TIOCGPTLCK = 0x40045439 + TIOCGPTN = 0x40045430 + TIOCGRS485 = 0x4020542e + TIOCGSERIAL = 0x5484 + TIOCGSID = 0x7416 + TIOCGSOFTCAR = 0x5481 + TIOCGWINSZ = 0x40087468 + TIOCINQ = 0x467f + TIOCLINUX = 0x5483 + TIOCMBIC = 0x741c + TIOCMBIS = 0x741b + TIOCMGET = 0x741d + TIOCMIWAIT = 0x5491 + TIOCMSET = 0x741a + TIOCM_CAR = 0x100 + TIOCM_CD = 0x100 + TIOCM_CTS = 0x40 + TIOCM_DSR = 0x400 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x200 + TIOCM_RNG = 0x200 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x20 + TIOCM_ST = 0x10 + TIOCNOTTY = 0x5471 + TIOCNXCL = 0x740e + TIOCOUTQ = 0x7472 + TIOCPKT = 0x5470 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCSBRK = 0x5427 + TIOCSCTTY = 0x5480 + TIOCSERCONFIG = 0x5488 + TIOCSERGETLSR = 0x548e + TIOCSERGETMULTI = 0x548f + TIOCSERGSTRUCT = 0x548d + TIOCSERGWILD = 0x5489 + TIOCSERSETMULTI = 0x5490 + TIOCSERSWILD = 0x548a + TIOCSER_TEMT = 0x1 + TIOCSETD = 0x7401 + TIOCSETN = 0x740a + TIOCSETP = 0x7409 + TIOCSIG = 0x80045436 + TIOCSLCKTRMIOS = 0x548c + TIOCSLTC = 0x7475 + TIOCSPGRP = 0x80047476 + TIOCSPTLCK = 0x80045431 + TIOCSRS485 = 0xc020542f + TIOCSSERIAL = 0x5485 + TIOCSSOFTCAR = 0x5482 + TIOCSTI = 0x5472 + TIOCSWINSZ = 0x80087467 + TIOCVHANGUP = 0x5437 + TOSTOP = 0x8000 + TUNATTACHFILTER = 0x801054d5 + TUNDETACHFILTER = 0x801054d6 + TUNGETFEATURES = 0x400454cf + TUNGETFILTER = 0x401054db + TUNGETIFF = 0x400454d2 + TUNGETSNDBUF = 0x400454d3 + TUNGETVNETBE = 0x400454df + TUNGETVNETHDRSZ = 0x400454d7 + TUNGETVNETLE = 0x400454dd + TUNSETDEBUG = 0x800454c9 + TUNSETGROUP = 0x800454ce + TUNSETIFF = 0x800454ca + TUNSETIFINDEX = 0x800454da + TUNSETLINK = 0x800454cd + TUNSETNOCSUM = 0x800454c8 + TUNSETOFFLOAD = 0x800454d0 + TUNSETOWNER = 0x800454cc + TUNSETPERSIST = 0x800454cb + TUNSETQUEUE = 0x800454d9 + TUNSETSNDBUF = 0x800454d4 + TUNSETTXFILTER = 0x800454d1 + TUNSETVNETBE = 0x800454de + TUNSETVNETHDRSZ = 0x800454d8 + TUNSETVNETLE = 0x800454dc + VDISCARD = 0xd + VEOF = 0x10 + VEOL = 0x11 + VEOL2 = 0x6 + VERASE = 0x2 + VINTR = 0x0 + VKILL = 0x3 + VLNEXT = 0xf + VMIN = 0x4 + VQUIT = 0x1 + VREPRINT = 0xc + VSTART = 0x8 + VSTOP = 0x9 + VSUSP = 0xa + VSWTC = 0x7 + VSWTCH = 0x7 + VT0 = 0x0 + VT1 = 0x4000 + VTDLY = 0x4000 + VTIME = 0x5 + VWERASE = 0xe + WALL = 0x40000000 + WCLONE = 0x80000000 + WCONTINUED = 0x8 + WEXITED = 0x4 + WNOHANG = 0x1 + WNOTHREAD = 0x20000000 + WNOWAIT = 0x1000000 + WORDSIZE = 0x40 + WSTOPPED = 0x2 + WUNTRACED = 0x2 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x7d) + EADDRNOTAVAIL = syscall.Errno(0x7e) + EADV = syscall.Errno(0x44) + EAFNOSUPPORT = syscall.Errno(0x7c) + EAGAIN = syscall.Errno(0xb) + EALREADY = syscall.Errno(0x95) + EBADE = syscall.Errno(0x32) + EBADF = syscall.Errno(0x9) + EBADFD = syscall.Errno(0x51) + EBADMSG = syscall.Errno(0x4d) + EBADR = syscall.Errno(0x33) + EBADRQC = syscall.Errno(0x36) + EBADSLT = syscall.Errno(0x37) + EBFONT = syscall.Errno(0x3b) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x9e) + ECHILD = syscall.Errno(0xa) + ECHRNG = syscall.Errno(0x25) + ECOMM = syscall.Errno(0x46) + ECONNABORTED = syscall.Errno(0x82) + ECONNREFUSED = syscall.Errno(0x92) + ECONNRESET = syscall.Errno(0x83) + EDEADLK = syscall.Errno(0x2d) + EDEADLOCK = syscall.Errno(0x38) + EDESTADDRREQ = syscall.Errno(0x60) + EDOM = syscall.Errno(0x21) + EDOTDOT = syscall.Errno(0x49) + EDQUOT = syscall.Errno(0x46d) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EHOSTDOWN = syscall.Errno(0x93) + EHOSTUNREACH = syscall.Errno(0x94) + EHWPOISON = syscall.Errno(0xa8) + EIDRM = syscall.Errno(0x24) + EILSEQ = syscall.Errno(0x58) + EINIT = syscall.Errno(0x8d) + EINPROGRESS = syscall.Errno(0x96) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x85) + EISDIR = syscall.Errno(0x15) + EISNAM = syscall.Errno(0x8b) + EKEYEXPIRED = syscall.Errno(0xa2) + EKEYREJECTED = syscall.Errno(0xa4) + EKEYREVOKED = syscall.Errno(0xa3) + EL2HLT = syscall.Errno(0x2c) + EL2NSYNC = syscall.Errno(0x26) + EL3HLT = syscall.Errno(0x27) + EL3RST = syscall.Errno(0x28) + ELIBACC = syscall.Errno(0x53) + ELIBBAD = syscall.Errno(0x54) + ELIBEXEC = syscall.Errno(0x57) + ELIBMAX = syscall.Errno(0x56) + ELIBSCN = syscall.Errno(0x55) + ELNRNG = syscall.Errno(0x29) + ELOOP = syscall.Errno(0x5a) + EMEDIUMTYPE = syscall.Errno(0xa0) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x61) + EMULTIHOP = syscall.Errno(0x4a) + ENAMETOOLONG = syscall.Errno(0x4e) + ENAVAIL = syscall.Errno(0x8a) + ENETDOWN = syscall.Errno(0x7f) + ENETRESET = syscall.Errno(0x81) + ENETUNREACH = syscall.Errno(0x80) + ENFILE = syscall.Errno(0x17) + ENOANO = syscall.Errno(0x35) + ENOBUFS = syscall.Errno(0x84) + ENOCSI = syscall.Errno(0x2b) + ENODATA = syscall.Errno(0x3d) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOKEY = syscall.Errno(0xa1) + ENOLCK = syscall.Errno(0x2e) + ENOLINK = syscall.Errno(0x43) + ENOMEDIUM = syscall.Errno(0x9f) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x23) + ENONET = syscall.Errno(0x40) + ENOPKG = syscall.Errno(0x41) + ENOPROTOOPT = syscall.Errno(0x63) + ENOSPC = syscall.Errno(0x1c) + ENOSR = syscall.Errno(0x3f) + ENOSTR = syscall.Errno(0x3c) + ENOSYS = syscall.Errno(0x59) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x86) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x5d) + ENOTNAM = syscall.Errno(0x89) + ENOTRECOVERABLE = syscall.Errno(0xa6) + ENOTSOCK = syscall.Errno(0x5f) + ENOTSUP = syscall.Errno(0x7a) + ENOTTY = syscall.Errno(0x19) + ENOTUNIQ = syscall.Errno(0x50) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x7a) + EOVERFLOW = syscall.Errno(0x4f) + EOWNERDEAD = syscall.Errno(0xa5) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x7b) + EPIPE = syscall.Errno(0x20) + EPROTO = syscall.Errno(0x47) + EPROTONOSUPPORT = syscall.Errno(0x78) + EPROTOTYPE = syscall.Errno(0x62) + ERANGE = syscall.Errno(0x22) + EREMCHG = syscall.Errno(0x52) + EREMDEV = syscall.Errno(0x8e) + EREMOTE = syscall.Errno(0x42) + EREMOTEIO = syscall.Errno(0x8c) + ERESTART = syscall.Errno(0x5b) + ERFKILL = syscall.Errno(0xa7) + EROFS = syscall.Errno(0x1e) + ESHUTDOWN = syscall.Errno(0x8f) + ESOCKTNOSUPPORT = syscall.Errno(0x79) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESRMNT = syscall.Errno(0x45) + ESTALE = syscall.Errno(0x97) + ESTRPIPE = syscall.Errno(0x5c) + ETIME = syscall.Errno(0x3e) + ETIMEDOUT = syscall.Errno(0x91) + ETOOMANYREFS = syscall.Errno(0x90) + ETXTBSY = syscall.Errno(0x1a) + EUCLEAN = syscall.Errno(0x87) + EUNATCH = syscall.Errno(0x2a) + EUSERS = syscall.Errno(0x5e) + EWOULDBLOCK = syscall.Errno(0xb) + EXDEV = syscall.Errno(0x12) + EXFULL = syscall.Errno(0x34) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0xa) + SIGCHLD = syscall.Signal(0x12) + SIGCLD = syscall.Signal(0x12) + SIGCONT = syscall.Signal(0x19) + SIGEMT = syscall.Signal(0x7) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x16) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPOLL = syscall.Signal(0x16) + SIGPROF = syscall.Signal(0x1d) + SIGPWR = syscall.Signal(0x13) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTOP = syscall.Signal(0x17) + SIGSYS = syscall.Signal(0xc) + SIGTERM = syscall.Signal(0xf) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x18) + SIGTTIN = syscall.Signal(0x1a) + SIGTTOU = syscall.Signal(0x1b) + SIGURG = syscall.Signal(0x15) + SIGUSR1 = syscall.Signal(0x10) + SIGUSR2 = syscall.Signal(0x11) + SIGVTALRM = syscall.Signal(0x1c) + SIGWINCH = syscall.Signal(0x14) + SIGXCPU = syscall.Signal(0x1e) + SIGXFSZ = syscall.Signal(0x1f) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "no such device or address", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource temporarily unavailable", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device or resource busy", + 17: "file exists", + 18: "invalid cross-device link", + 19: "no such device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "numerical result out of range", + 35: "no message of desired type", + 36: "identifier removed", + 37: "channel number out of range", + 38: "level 2 not synchronized", + 39: "level 3 halted", + 40: "level 3 reset", + 41: "link number out of range", + 42: "protocol driver not attached", + 43: "no CSI structure available", + 44: "level 2 halted", + 45: "resource deadlock avoided", + 46: "no locks available", + 50: "invalid exchange", + 51: "invalid request descriptor", + 52: "exchange full", + 53: "no anode", + 54: "invalid request code", + 55: "invalid slot", + 56: "file locking deadlock error", + 59: "bad font file format", + 60: "device not a stream", + 61: "no data available", + 62: "timer expired", + 63: "out of streams resources", + 64: "machine is not on the network", + 65: "package not installed", + 66: "object is remote", + 67: "link has been severed", + 68: "advertise error", + 69: "srmount error", + 70: "communication error on send", + 71: "protocol error", + 73: "RFS specific error", + 74: "multihop attempted", + 77: "bad message", + 78: "file name too long", + 79: "value too large for defined data type", + 80: "name not unique on network", + 81: "file descriptor in bad state", + 82: "remote address changed", + 83: "can not access a needed shared library", + 84: "accessing a corrupted shared library", + 85: ".lib section in a.out corrupted", + 86: "attempting to link in too many shared libraries", + 87: "cannot exec a shared library directly", + 88: "invalid or incomplete multibyte or wide character", + 89: "function not implemented", + 90: "too many levels of symbolic links", + 91: "interrupted system call should be restarted", + 92: "streams pipe error", + 93: "directory not empty", + 94: "too many users", + 95: "socket operation on non-socket", + 96: "destination address required", + 97: "message too long", + 98: "protocol wrong type for socket", + 99: "protocol not available", + 120: "protocol not supported", + 121: "socket type not supported", + 122: "operation not supported", + 123: "protocol family not supported", + 124: "address family not supported by protocol", + 125: "address already in use", + 126: "cannot assign requested address", + 127: "network is down", + 128: "network is unreachable", + 129: "network dropped connection on reset", + 130: "software caused connection abort", + 131: "connection reset by peer", + 132: "no buffer space available", + 133: "transport endpoint is already connected", + 134: "transport endpoint is not connected", + 135: "structure needs cleaning", + 137: "not a XENIX named type file", + 138: "no XENIX semaphores available", + 139: "is a named type file", + 140: "remote I/O error", + 141: "unknown error 141", + 142: "unknown error 142", + 143: "cannot send after transport endpoint shutdown", + 144: "too many references: cannot splice", + 145: "connection timed out", + 146: "connection refused", + 147: "host is down", + 148: "no route to host", + 149: "operation already in progress", + 150: "operation now in progress", + 151: "stale file handle", + 158: "operation canceled", + 159: "no medium found", + 160: "wrong medium type", + 161: "required key not available", + 162: "key has expired", + 163: "key has been revoked", + 164: "key was rejected by service", + 165: "owner died", + 166: "state not recoverable", + 167: "operation not possible due to RF-kill", + 168: "memory page has hardware error", + 1133: "disk quota exceeded", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/breakpoint trap", + 6: "aborted", + 7: "EMT trap", + 8: "floating point exception", + 9: "killed", + 10: "bus error", + 11: "segmentation fault", + 12: "bad system call", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "user defined signal 1", + 17: "user defined signal 2", + 18: "child exited", + 19: "power failure", + 20: "window changed", + 21: "urgent I/O condition", + 22: "I/O possible", + 23: "stopped (signal)", + 24: "stopped", + 25: "continued", + 26: "stopped (tty input)", + 27: "stopped (tty output)", + 28: "virtual timer expired", + 29: "profiling timer expired", + 30: "CPU time limit exceeded", + 31: "file size limit exceeded", +} diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go new file mode 100644 index 0000000000..8b42ca2fe9 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -0,0 +1,1970 @@ +// mkerrors.sh -m64 +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build ppc64,linux + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -m64 _const.go + +package unix + +import "syscall" + +const ( + AF_ALG = 0x26 + AF_APPLETALK = 0x5 + AF_ASH = 0x12 + AF_ATMPVC = 0x8 + AF_ATMSVC = 0x14 + AF_AX25 = 0x3 + AF_BLUETOOTH = 0x1f + AF_BRIDGE = 0x7 + AF_CAIF = 0x25 + AF_CAN = 0x1d + AF_DECnet = 0xc + AF_ECONET = 0x13 + AF_FILE = 0x1 + AF_IEEE802154 = 0x24 + AF_INET = 0x2 + AF_INET6 = 0xa + AF_IPX = 0x4 + AF_IRDA = 0x17 + AF_ISDN = 0x22 + AF_IUCV = 0x20 + AF_KEY = 0xf + AF_LLC = 0x1a + AF_LOCAL = 0x1 + AF_MAX = 0x29 + AF_NETBEUI = 0xd + AF_NETLINK = 0x10 + AF_NETROM = 0x6 + AF_NFC = 0x27 + AF_PACKET = 0x11 + AF_PHONET = 0x23 + AF_PPPOX = 0x18 + AF_RDS = 0x15 + AF_ROSE = 0xb + AF_ROUTE = 0x10 + AF_RXRPC = 0x21 + AF_SECURITY = 0xe + AF_SNA = 0x16 + AF_TIPC = 0x1e + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_VSOCK = 0x28 + AF_WANPIPE = 0x19 + AF_X25 = 0x9 + ARPHRD_6LOWPAN = 0x339 + ARPHRD_ADAPT = 0x108 + ARPHRD_APPLETLK = 0x8 + ARPHRD_ARCNET = 0x7 + ARPHRD_ASH = 0x30d + ARPHRD_ATM = 0x13 + ARPHRD_AX25 = 0x3 + ARPHRD_BIF = 0x307 + ARPHRD_CAIF = 0x336 + ARPHRD_CAN = 0x118 + ARPHRD_CHAOS = 0x5 + ARPHRD_CISCO = 0x201 + ARPHRD_CSLIP = 0x101 + ARPHRD_CSLIP6 = 0x103 + ARPHRD_DDCMP = 0x205 + ARPHRD_DLCI = 0xf + ARPHRD_ECONET = 0x30e + ARPHRD_EETHER = 0x2 + ARPHRD_ETHER = 0x1 + ARPHRD_EUI64 = 0x1b + ARPHRD_FCAL = 0x311 + ARPHRD_FCFABRIC = 0x313 + ARPHRD_FCPL = 0x312 + ARPHRD_FCPP = 0x310 + ARPHRD_FDDI = 0x306 + ARPHRD_FRAD = 0x302 + ARPHRD_HDLC = 0x201 + ARPHRD_HIPPI = 0x30c + ARPHRD_HWX25 = 0x110 + ARPHRD_IEEE1394 = 0x18 + ARPHRD_IEEE802 = 0x6 + ARPHRD_IEEE80211 = 0x321 + ARPHRD_IEEE80211_PRISM = 0x322 + ARPHRD_IEEE80211_RADIOTAP = 0x323 + ARPHRD_IEEE802154 = 0x324 + ARPHRD_IEEE802154_MONITOR = 0x325 + ARPHRD_IEEE802_TR = 0x320 + ARPHRD_INFINIBAND = 0x20 + ARPHRD_IP6GRE = 0x337 + ARPHRD_IPDDP = 0x309 + ARPHRD_IPGRE = 0x30a + ARPHRD_IRDA = 0x30f + ARPHRD_LAPB = 0x204 + ARPHRD_LOCALTLK = 0x305 + ARPHRD_LOOPBACK = 0x304 + ARPHRD_METRICOM = 0x17 + ARPHRD_NETLINK = 0x338 + ARPHRD_NETROM = 0x0 + ARPHRD_NONE = 0xfffe + ARPHRD_PHONET = 0x334 + ARPHRD_PHONET_PIPE = 0x335 + ARPHRD_PIMREG = 0x30b + ARPHRD_PPP = 0x200 + ARPHRD_PRONET = 0x4 + ARPHRD_RAWHDLC = 0x206 + ARPHRD_ROSE = 0x10e + ARPHRD_RSRVD = 0x104 + ARPHRD_SIT = 0x308 + ARPHRD_SKIP = 0x303 + ARPHRD_SLIP = 0x100 + ARPHRD_SLIP6 = 0x102 + ARPHRD_TUNNEL = 0x300 + ARPHRD_TUNNEL6 = 0x301 + ARPHRD_VOID = 0xffff + ARPHRD_X25 = 0x10f + B0 = 0x0 + B1000000 = 0x17 + B110 = 0x3 + B115200 = 0x11 + B1152000 = 0x18 + B1200 = 0x9 + B134 = 0x4 + B150 = 0x5 + B1500000 = 0x19 + B1800 = 0xa + B19200 = 0xe + B200 = 0x6 + B2000000 = 0x1a + B230400 = 0x12 + B2400 = 0xb + B2500000 = 0x1b + B300 = 0x7 + B3000000 = 0x1c + B3500000 = 0x1d + B38400 = 0xf + B4000000 = 0x1e + B460800 = 0x13 + B4800 = 0xc + B50 = 0x1 + B500000 = 0x14 + B57600 = 0x10 + B576000 = 0x15 + B600 = 0x8 + B75 = 0x2 + B921600 = 0x16 + B9600 = 0xd + BOTHER = 0x1f + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXINSNS = 0x1000 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MOD = 0x90 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BPF_XOR = 0xa0 + BRKINT = 0x2 + BS0 = 0x0 + BS1 = 0x8000 + BSDLY = 0x8000 + CBAUD = 0xff + CBAUDEX = 0x0 + CFLUSH = 0xf + CIBAUD = 0xff0000 + CLOCAL = 0x8000 + CLOCK_BOOTTIME = 0x7 + CLOCK_BOOTTIME_ALARM = 0x9 + CLOCK_DEFAULT = 0x0 + CLOCK_EXT = 0x1 + CLOCK_INT = 0x2 + CLOCK_MONOTONIC = 0x1 + CLOCK_MONOTONIC_COARSE = 0x6 + CLOCK_MONOTONIC_RAW = 0x4 + CLOCK_PROCESS_CPUTIME_ID = 0x2 + CLOCK_REALTIME = 0x0 + CLOCK_REALTIME_ALARM = 0x8 + CLOCK_REALTIME_COARSE = 0x5 + CLOCK_THREAD_CPUTIME_ID = 0x3 + CLOCK_TXFROMRX = 0x4 + CLOCK_TXINT = 0x3 + CLONE_CHILD_CLEARTID = 0x200000 + CLONE_CHILD_SETTID = 0x1000000 + CLONE_DETACHED = 0x400000 + CLONE_FILES = 0x400 + CLONE_FS = 0x200 + CLONE_IO = 0x80000000 + CLONE_NEWCGROUP = 0x2000000 + CLONE_NEWIPC = 0x8000000 + CLONE_NEWNET = 0x40000000 + CLONE_NEWNS = 0x20000 + CLONE_NEWPID = 0x20000000 + CLONE_NEWUSER = 0x10000000 + CLONE_NEWUTS = 0x4000000 + CLONE_PARENT = 0x8000 + CLONE_PARENT_SETTID = 0x100000 + CLONE_PTRACE = 0x2000 + CLONE_SETTLS = 0x80000 + CLONE_SIGHAND = 0x800 + CLONE_SYSVSEM = 0x40000 + CLONE_THREAD = 0x10000 + CLONE_UNTRACED = 0x800000 + CLONE_VFORK = 0x4000 + CLONE_VM = 0x100 + CMSPAR = 0x40000000 + CR0 = 0x0 + CR1 = 0x1000 + CR2 = 0x2000 + CR3 = 0x3000 + CRDLY = 0x3000 + CREAD = 0x800 + CRTSCTS = 0x80000000 + CS5 = 0x0 + CS6 = 0x100 + CS7 = 0x200 + CS8 = 0x300 + CSIGNAL = 0xff + CSIZE = 0x300 + CSTART = 0x11 + CSTATUS = 0x0 + CSTOP = 0x13 + CSTOPB = 0x400 + CSUSP = 0x1a + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x40 + ECHOE = 0x2 + ECHOK = 0x4 + ECHOKE = 0x1 + ECHONL = 0x10 + ECHOPRT = 0x20 + ENCODING_DEFAULT = 0x0 + ENCODING_FM_MARK = 0x3 + ENCODING_FM_SPACE = 0x4 + ENCODING_MANCHESTER = 0x5 + ENCODING_NRZ = 0x1 + ENCODING_NRZI = 0x2 + EPOLLERR = 0x8 + EPOLLET = 0x80000000 + EPOLLHUP = 0x10 + EPOLLIN = 0x1 + EPOLLMSG = 0x400 + EPOLLONESHOT = 0x40000000 + EPOLLOUT = 0x4 + EPOLLPRI = 0x2 + EPOLLRDBAND = 0x80 + EPOLLRDHUP = 0x2000 + EPOLLRDNORM = 0x40 + EPOLLWAKEUP = 0x20000000 + EPOLLWRBAND = 0x200 + EPOLLWRNORM = 0x100 + EPOLL_CLOEXEC = 0x80000 + EPOLL_CTL_ADD = 0x1 + EPOLL_CTL_DEL = 0x2 + EPOLL_CTL_MOD = 0x3 + ETH_P_1588 = 0x88f7 + ETH_P_8021AD = 0x88a8 + ETH_P_8021AH = 0x88e7 + ETH_P_8021Q = 0x8100 + ETH_P_80221 = 0x8917 + ETH_P_802_2 = 0x4 + ETH_P_802_3 = 0x1 + ETH_P_802_3_MIN = 0x600 + ETH_P_802_EX1 = 0x88b5 + ETH_P_AARP = 0x80f3 + ETH_P_AF_IUCV = 0xfbfb + ETH_P_ALL = 0x3 + ETH_P_AOE = 0x88a2 + ETH_P_ARCNET = 0x1a + ETH_P_ARP = 0x806 + ETH_P_ATALK = 0x809b + ETH_P_ATMFATE = 0x8884 + ETH_P_ATMMPOA = 0x884c + ETH_P_AX25 = 0x2 + ETH_P_BATMAN = 0x4305 + ETH_P_BPQ = 0x8ff + ETH_P_CAIF = 0xf7 + ETH_P_CAN = 0xc + ETH_P_CANFD = 0xd + ETH_P_CONTROL = 0x16 + ETH_P_CUST = 0x6006 + ETH_P_DDCMP = 0x6 + ETH_P_DEC = 0x6000 + ETH_P_DIAG = 0x6005 + ETH_P_DNA_DL = 0x6001 + ETH_P_DNA_RC = 0x6002 + ETH_P_DNA_RT = 0x6003 + ETH_P_DSA = 0x1b + ETH_P_ECONET = 0x18 + ETH_P_EDSA = 0xdada + ETH_P_FCOE = 0x8906 + ETH_P_FIP = 0x8914 + ETH_P_HDLC = 0x19 + ETH_P_IEEE802154 = 0xf6 + ETH_P_IEEEPUP = 0xa00 + ETH_P_IEEEPUPAT = 0xa01 + ETH_P_IP = 0x800 + ETH_P_IPV6 = 0x86dd + ETH_P_IPX = 0x8137 + ETH_P_IRDA = 0x17 + ETH_P_LAT = 0x6004 + ETH_P_LINK_CTL = 0x886c + ETH_P_LOCALTALK = 0x9 + ETH_P_LOOP = 0x60 + ETH_P_LOOPBACK = 0x9000 + ETH_P_MOBITEX = 0x15 + ETH_P_MPLS_MC = 0x8848 + ETH_P_MPLS_UC = 0x8847 + ETH_P_MVRP = 0x88f5 + ETH_P_PAE = 0x888e + ETH_P_PAUSE = 0x8808 + ETH_P_PHONET = 0xf5 + ETH_P_PPPTALK = 0x10 + ETH_P_PPP_DISC = 0x8863 + ETH_P_PPP_MP = 0x8 + ETH_P_PPP_SES = 0x8864 + ETH_P_PRP = 0x88fb + ETH_P_PUP = 0x200 + ETH_P_PUPAT = 0x201 + ETH_P_QINQ1 = 0x9100 + ETH_P_QINQ2 = 0x9200 + ETH_P_QINQ3 = 0x9300 + ETH_P_RARP = 0x8035 + ETH_P_SCA = 0x6007 + ETH_P_SLOW = 0x8809 + ETH_P_SNAP = 0x5 + ETH_P_TDLS = 0x890d + ETH_P_TEB = 0x6558 + ETH_P_TIPC = 0x88ca + ETH_P_TRAILER = 0x1c + ETH_P_TR_802_2 = 0x11 + ETH_P_WAN_PPP = 0x7 + ETH_P_WCCP = 0x883e + ETH_P_X25 = 0x805 + ETH_P_XDSA = 0xf8 + EXTA = 0xe + EXTB = 0xf + EXTPROC = 0x10000000 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FF0 = 0x0 + FF1 = 0x4000 + FFDLY = 0x4000 + FLUSHO = 0x800000 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x406 + F_EXLCK = 0x4 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLEASE = 0x401 + F_GETLK = 0x5 + F_GETLK64 = 0xc + F_GETOWN = 0x9 + F_GETOWN_EX = 0x10 + F_GETPIPE_SZ = 0x408 + F_GETSIG = 0xb + F_LOCK = 0x1 + F_NOTIFY = 0x402 + F_OFD_GETLK = 0x24 + F_OFD_SETLK = 0x25 + F_OFD_SETLKW = 0x26 + F_OK = 0x0 + F_RDLCK = 0x0 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLEASE = 0x400 + F_SETLK = 0x6 + F_SETLK64 = 0xd + F_SETLKW = 0x7 + F_SETLKW64 = 0xe + F_SETOWN = 0x8 + F_SETOWN_EX = 0xf + F_SETPIPE_SZ = 0x407 + F_SETSIG = 0xa + F_SHLCK = 0x8 + F_TEST = 0x3 + F_TLOCK = 0x2 + F_ULOCK = 0x0 + F_UNLCK = 0x2 + F_WRLCK = 0x1 + HUPCL = 0x4000 + IBSHIFT = 0x10 + ICANON = 0x100 + ICMPV6_FILTER = 0x1 + ICRNL = 0x100 + IEXTEN = 0x400 + IFA_F_DADFAILED = 0x8 + IFA_F_DEPRECATED = 0x20 + IFA_F_HOMEADDRESS = 0x10 + IFA_F_MANAGETEMPADDR = 0x100 + IFA_F_NODAD = 0x2 + IFA_F_NOPREFIXROUTE = 0x200 + IFA_F_OPTIMISTIC = 0x4 + IFA_F_PERMANENT = 0x80 + IFA_F_SECONDARY = 0x1 + IFA_F_TEMPORARY = 0x1 + IFA_F_TENTATIVE = 0x40 + IFA_MAX = 0x8 + IFF_ALLMULTI = 0x200 + IFF_ATTACH_QUEUE = 0x200 + IFF_AUTOMEDIA = 0x4000 + IFF_BROADCAST = 0x2 + IFF_DEBUG = 0x4 + IFF_DETACH_QUEUE = 0x400 + IFF_DORMANT = 0x20000 + IFF_DYNAMIC = 0x8000 + IFF_ECHO = 0x40000 + IFF_LOOPBACK = 0x8 + IFF_LOWER_UP = 0x10000 + IFF_MASTER = 0x400 + IFF_MULTICAST = 0x1000 + IFF_MULTI_QUEUE = 0x100 + IFF_NOARP = 0x80 + IFF_NOFILTER = 0x1000 + IFF_NOTRAILERS = 0x20 + IFF_NO_PI = 0x1000 + IFF_ONE_QUEUE = 0x2000 + IFF_PERSIST = 0x800 + IFF_POINTOPOINT = 0x10 + IFF_PORTSEL = 0x2000 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SLAVE = 0x800 + IFF_TAP = 0x2 + IFF_TUN = 0x1 + IFF_TUN_EXCL = 0x8000 + IFF_UP = 0x1 + IFF_VNET_HDR = 0x4000 + IFF_VOLATILE = 0x70c5a + IFNAMSIZ = 0x10 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_ACCESS = 0x1 + IN_ALL_EVENTS = 0xfff + IN_ATTRIB = 0x4 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLOEXEC = 0x80000 + IN_CLOSE = 0x18 + IN_CLOSE_NOWRITE = 0x10 + IN_CLOSE_WRITE = 0x8 + IN_CREATE = 0x100 + IN_DELETE = 0x200 + IN_DELETE_SELF = 0x400 + IN_DONT_FOLLOW = 0x2000000 + IN_EXCL_UNLINK = 0x4000000 + IN_IGNORED = 0x8000 + IN_ISDIR = 0x40000000 + IN_LOOPBACKNET = 0x7f + IN_MASK_ADD = 0x20000000 + IN_MODIFY = 0x2 + IN_MOVE = 0xc0 + IN_MOVED_FROM = 0x40 + IN_MOVED_TO = 0x80 + IN_MOVE_SELF = 0x800 + IN_NONBLOCK = 0x800 + IN_ONESHOT = 0x80000000 + IN_ONLYDIR = 0x1000000 + IN_OPEN = 0x20 + IN_Q_OVERFLOW = 0x4000 + IN_UNMOUNT = 0x2000 + IPPROTO_AH = 0x33 + IPPROTO_BEETPH = 0x5e + IPPROTO_COMP = 0x6c + IPPROTO_DCCP = 0x21 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_ENCAP = 0x62 + IPPROTO_ESP = 0x32 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GRE = 0x2f + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IGMP = 0x2 + IPPROTO_IP = 0x0 + IPPROTO_IPIP = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_MH = 0x87 + IPPROTO_MTP = 0x5c + IPPROTO_NONE = 0x3b + IPPROTO_PIM = 0x67 + IPPROTO_PUP = 0xc + IPPROTO_RAW = 0xff + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_SCTP = 0x84 + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_UDP = 0x11 + IPPROTO_UDPLITE = 0x88 + IPV6_2292DSTOPTS = 0x4 + IPV6_2292HOPLIMIT = 0x8 + IPV6_2292HOPOPTS = 0x3 + IPV6_2292PKTINFO = 0x2 + IPV6_2292PKTOPTIONS = 0x6 + IPV6_2292RTHDR = 0x5 + IPV6_ADDRFORM = 0x1 + IPV6_ADD_MEMBERSHIP = 0x14 + IPV6_AUTHHDR = 0xa + IPV6_CHECKSUM = 0x7 + IPV6_DROP_MEMBERSHIP = 0x15 + IPV6_DSTOPTS = 0x3b + IPV6_HOPLIMIT = 0x34 + IPV6_HOPOPTS = 0x36 + IPV6_IPSEC_POLICY = 0x22 + IPV6_JOIN_ANYCAST = 0x1b + IPV6_JOIN_GROUP = 0x14 + IPV6_LEAVE_ANYCAST = 0x1c + IPV6_LEAVE_GROUP = 0x15 + IPV6_MTU = 0x18 + IPV6_MTU_DISCOVER = 0x17 + IPV6_MULTICAST_HOPS = 0x12 + IPV6_MULTICAST_IF = 0x11 + IPV6_MULTICAST_LOOP = 0x13 + IPV6_NEXTHOP = 0x9 + IPV6_PKTINFO = 0x32 + IPV6_PMTUDISC_DO = 0x2 + IPV6_PMTUDISC_DONT = 0x0 + IPV6_PMTUDISC_INTERFACE = 0x4 + IPV6_PMTUDISC_OMIT = 0x5 + IPV6_PMTUDISC_PROBE = 0x3 + IPV6_PMTUDISC_WANT = 0x1 + IPV6_RECVDSTOPTS = 0x3a + IPV6_RECVERR = 0x19 + IPV6_RECVHOPLIMIT = 0x33 + IPV6_RECVHOPOPTS = 0x35 + IPV6_RECVPKTINFO = 0x31 + IPV6_RECVRTHDR = 0x38 + IPV6_RECVTCLASS = 0x42 + IPV6_ROUTER_ALERT = 0x16 + IPV6_RTHDR = 0x39 + IPV6_RTHDRDSTOPTS = 0x37 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_RXDSTOPTS = 0x3b + IPV6_RXHOPOPTS = 0x36 + IPV6_TCLASS = 0x43 + IPV6_UNICAST_HOPS = 0x10 + IPV6_V6ONLY = 0x1a + IPV6_XFRM_POLICY = 0x23 + IP_ADD_MEMBERSHIP = 0x23 + IP_ADD_SOURCE_MEMBERSHIP = 0x27 + IP_BLOCK_SOURCE = 0x26 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DROP_MEMBERSHIP = 0x24 + IP_DROP_SOURCE_MEMBERSHIP = 0x28 + IP_FREEBIND = 0xf + IP_HDRINCL = 0x3 + IP_IPSEC_POLICY = 0x10 + IP_MAXPACKET = 0xffff + IP_MAX_MEMBERSHIPS = 0x14 + IP_MF = 0x2000 + IP_MINTTL = 0x15 + IP_MSFILTER = 0x29 + IP_MSS = 0x240 + IP_MTU = 0xe + IP_MTU_DISCOVER = 0xa + IP_MULTICAST_ALL = 0x31 + IP_MULTICAST_IF = 0x20 + IP_MULTICAST_LOOP = 0x22 + IP_MULTICAST_TTL = 0x21 + IP_NODEFRAG = 0x16 + IP_OFFMASK = 0x1fff + IP_OPTIONS = 0x4 + IP_ORIGDSTADDR = 0x14 + IP_PASSSEC = 0x12 + IP_PKTINFO = 0x8 + IP_PKTOPTIONS = 0x9 + IP_PMTUDISC = 0xa + IP_PMTUDISC_DO = 0x2 + IP_PMTUDISC_DONT = 0x0 + IP_PMTUDISC_INTERFACE = 0x4 + IP_PMTUDISC_OMIT = 0x5 + IP_PMTUDISC_PROBE = 0x3 + IP_PMTUDISC_WANT = 0x1 + IP_RECVERR = 0xb + IP_RECVOPTS = 0x6 + IP_RECVORIGDSTADDR = 0x14 + IP_RECVRETOPTS = 0x7 + IP_RECVTOS = 0xd + IP_RECVTTL = 0xc + IP_RETOPTS = 0x7 + IP_RF = 0x8000 + IP_ROUTER_ALERT = 0x5 + IP_TOS = 0x1 + IP_TRANSPARENT = 0x13 + IP_TTL = 0x2 + IP_UNBLOCK_SOURCE = 0x25 + IP_UNICAST_IF = 0x32 + IP_XFRM_POLICY = 0x11 + ISIG = 0x80 + ISTRIP = 0x20 + IUCLC = 0x1000 + IUTF8 = 0x4000 + IXANY = 0x800 + IXOFF = 0x400 + IXON = 0x200 + LINUX_REBOOT_CMD_CAD_OFF = 0x0 + LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef + LINUX_REBOOT_CMD_HALT = 0xcdef0123 + LINUX_REBOOT_CMD_KEXEC = 0x45584543 + LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc + LINUX_REBOOT_CMD_RESTART = 0x1234567 + LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4 + LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2 + LINUX_REBOOT_MAGIC1 = 0xfee1dead + LINUX_REBOOT_MAGIC2 = 0x28121969 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_DODUMP = 0x11 + MADV_DOFORK = 0xb + MADV_DONTDUMP = 0x10 + MADV_DONTFORK = 0xa + MADV_DONTNEED = 0x4 + MADV_HUGEPAGE = 0xe + MADV_HWPOISON = 0x64 + MADV_MERGEABLE = 0xc + MADV_NOHUGEPAGE = 0xf + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_REMOVE = 0x9 + MADV_SEQUENTIAL = 0x2 + MADV_UNMERGEABLE = 0xd + MADV_WILLNEED = 0x3 + MAP_ANON = 0x20 + MAP_ANONYMOUS = 0x20 + MAP_DENYWRITE = 0x800 + MAP_EXECUTABLE = 0x1000 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_GROWSDOWN = 0x100 + MAP_HUGETLB = 0x40000 + MAP_HUGE_MASK = 0x3f + MAP_HUGE_SHIFT = 0x1a + MAP_LOCKED = 0x80 + MAP_NONBLOCK = 0x10000 + MAP_NORESERVE = 0x40 + MAP_POPULATE = 0x8000 + MAP_PRIVATE = 0x2 + MAP_SHARED = 0x1 + MAP_STACK = 0x20000 + MAP_TYPE = 0xf + MCL_CURRENT = 0x2000 + MCL_FUTURE = 0x4000 + MNT_DETACH = 0x2 + MNT_EXPIRE = 0x4 + MNT_FORCE = 0x1 + MSG_CMSG_CLOEXEC = 0x40000000 + MSG_CONFIRM = 0x800 + MSG_CTRUNC = 0x8 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x40 + MSG_EOR = 0x80 + MSG_ERRQUEUE = 0x2000 + MSG_FASTOPEN = 0x20000000 + MSG_FIN = 0x200 + MSG_MORE = 0x8000 + MSG_NOSIGNAL = 0x4000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_PROXY = 0x10 + MSG_RST = 0x1000 + MSG_SYN = 0x400 + MSG_TRUNC = 0x20 + MSG_TRYHARD = 0x4 + MSG_WAITALL = 0x100 + MSG_WAITFORONE = 0x10000 + MS_ACTIVE = 0x40000000 + MS_ASYNC = 0x1 + MS_BIND = 0x1000 + MS_DIRSYNC = 0x80 + MS_INVALIDATE = 0x2 + MS_I_VERSION = 0x800000 + MS_KERNMOUNT = 0x400000 + MS_MANDLOCK = 0x40 + MS_MGC_MSK = 0xffff0000 + MS_MGC_VAL = 0xc0ed0000 + MS_MOVE = 0x2000 + MS_NOATIME = 0x400 + MS_NODEV = 0x4 + MS_NODIRATIME = 0x800 + MS_NOEXEC = 0x8 + MS_NOSUID = 0x2 + MS_NOUSER = -0x80000000 + MS_POSIXACL = 0x10000 + MS_PRIVATE = 0x40000 + MS_RDONLY = 0x1 + MS_REC = 0x4000 + MS_RELATIME = 0x200000 + MS_REMOUNT = 0x20 + MS_RMT_MASK = 0x800051 + MS_SHARED = 0x100000 + MS_SILENT = 0x8000 + MS_SLAVE = 0x80000 + MS_STRICTATIME = 0x1000000 + MS_SYNC = 0x4 + MS_SYNCHRONOUS = 0x10 + MS_UNBINDABLE = 0x20000 + NAME_MAX = 0xff + NETLINK_ADD_MEMBERSHIP = 0x1 + NETLINK_AUDIT = 0x9 + NETLINK_BROADCAST_ERROR = 0x4 + NETLINK_CONNECTOR = 0xb + NETLINK_CRYPTO = 0x15 + NETLINK_DNRTMSG = 0xe + NETLINK_DROP_MEMBERSHIP = 0x2 + NETLINK_ECRYPTFS = 0x13 + NETLINK_FIB_LOOKUP = 0xa + NETLINK_FIREWALL = 0x3 + NETLINK_GENERIC = 0x10 + NETLINK_INET_DIAG = 0x4 + NETLINK_IP6_FW = 0xd + NETLINK_ISCSI = 0x8 + NETLINK_KOBJECT_UEVENT = 0xf + NETLINK_NETFILTER = 0xc + NETLINK_NFLOG = 0x5 + NETLINK_NO_ENOBUFS = 0x5 + NETLINK_PKTINFO = 0x3 + NETLINK_RDMA = 0x14 + NETLINK_ROUTE = 0x0 + NETLINK_RX_RING = 0x6 + NETLINK_SCSITRANSPORT = 0x12 + NETLINK_SELINUX = 0x7 + NETLINK_SOCK_DIAG = 0x4 + NETLINK_TX_RING = 0x7 + NETLINK_UNUSED = 0x1 + NETLINK_USERSOCK = 0x2 + NETLINK_XFRM = 0x6 + NL0 = 0x0 + NL1 = 0x100 + NL2 = 0x200 + NL3 = 0x300 + NLA_ALIGNTO = 0x4 + NLA_F_NESTED = 0x8000 + NLA_F_NET_BYTEORDER = 0x4000 + NLA_HDRLEN = 0x4 + NLDLY = 0x300 + NLMSG_ALIGNTO = 0x4 + NLMSG_DONE = 0x3 + NLMSG_ERROR = 0x2 + NLMSG_HDRLEN = 0x10 + NLMSG_MIN_TYPE = 0x10 + NLMSG_NOOP = 0x1 + NLMSG_OVERRUN = 0x4 + NLM_F_ACK = 0x4 + NLM_F_APPEND = 0x800 + NLM_F_ATOMIC = 0x400 + NLM_F_CREATE = 0x400 + NLM_F_DUMP = 0x300 + NLM_F_DUMP_INTR = 0x10 + NLM_F_ECHO = 0x8 + NLM_F_EXCL = 0x200 + NLM_F_MATCH = 0x200 + NLM_F_MULTI = 0x2 + NLM_F_REPLACE = 0x100 + NLM_F_REQUEST = 0x1 + NLM_F_ROOT = 0x100 + NOFLSH = 0x80000000 + OCRNL = 0x8 + OFDEL = 0x80 + OFILL = 0x40 + OLCUC = 0x4 + ONLCR = 0x2 + ONLRET = 0x20 + ONOCR = 0x10 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_APPEND = 0x400 + O_ASYNC = 0x2000 + O_CLOEXEC = 0x80000 + O_CREAT = 0x40 + O_DIRECT = 0x20000 + O_DIRECTORY = 0x4000 + O_DSYNC = 0x1000 + O_EXCL = 0x80 + O_FSYNC = 0x101000 + O_LARGEFILE = 0x0 + O_NDELAY = 0x800 + O_NOATIME = 0x40000 + O_NOCTTY = 0x100 + O_NOFOLLOW = 0x8000 + O_NONBLOCK = 0x800 + O_PATH = 0x200000 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_RSYNC = 0x101000 + O_SYNC = 0x101000 + O_TMPFILE = 0x410000 + O_TRUNC = 0x200 + O_WRONLY = 0x1 + PACKET_ADD_MEMBERSHIP = 0x1 + PACKET_AUXDATA = 0x8 + PACKET_BROADCAST = 0x1 + PACKET_COPY_THRESH = 0x7 + PACKET_DROP_MEMBERSHIP = 0x2 + PACKET_FANOUT = 0x12 + PACKET_FANOUT_CPU = 0x2 + PACKET_FANOUT_FLAG_DEFRAG = 0x8000 + PACKET_FANOUT_FLAG_ROLLOVER = 0x1000 + PACKET_FANOUT_HASH = 0x0 + PACKET_FANOUT_LB = 0x1 + PACKET_FANOUT_QM = 0x5 + PACKET_FANOUT_RND = 0x4 + PACKET_FANOUT_ROLLOVER = 0x3 + PACKET_FASTROUTE = 0x6 + PACKET_HDRLEN = 0xb + PACKET_HOST = 0x0 + PACKET_KERNEL = 0x7 + PACKET_LOOPBACK = 0x5 + PACKET_LOSS = 0xe + PACKET_MR_ALLMULTI = 0x2 + PACKET_MR_MULTICAST = 0x0 + PACKET_MR_PROMISC = 0x1 + PACKET_MR_UNICAST = 0x3 + PACKET_MULTICAST = 0x2 + PACKET_ORIGDEV = 0x9 + PACKET_OTHERHOST = 0x3 + PACKET_OUTGOING = 0x4 + PACKET_QDISC_BYPASS = 0x14 + PACKET_RECV_OUTPUT = 0x3 + PACKET_RESERVE = 0xc + PACKET_RX_RING = 0x5 + PACKET_STATISTICS = 0x6 + PACKET_TIMESTAMP = 0x11 + PACKET_TX_HAS_OFF = 0x13 + PACKET_TX_RING = 0xd + PACKET_TX_TIMESTAMP = 0x10 + PACKET_USER = 0x6 + PACKET_VERSION = 0xa + PACKET_VNET_HDR = 0xf + PARENB = 0x1000 + PARITY_CRC16_PR0 = 0x2 + PARITY_CRC16_PR0_CCITT = 0x4 + PARITY_CRC16_PR1 = 0x3 + PARITY_CRC16_PR1_CCITT = 0x5 + PARITY_CRC32_PR0_CCITT = 0x6 + PARITY_CRC32_PR1_CCITT = 0x7 + PARITY_DEFAULT = 0x0 + PARITY_NONE = 0x1 + PARMRK = 0x8 + PARODD = 0x2000 + PENDIN = 0x20000000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_GROWSDOWN = 0x1000000 + PROT_GROWSUP = 0x2000000 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_SAO = 0x10 + PROT_WRITE = 0x2 + PR_CAPBSET_DROP = 0x18 + PR_CAPBSET_READ = 0x17 + PR_ENDIAN_BIG = 0x0 + PR_ENDIAN_LITTLE = 0x1 + PR_ENDIAN_PPC_LITTLE = 0x2 + PR_FPEMU_NOPRINT = 0x1 + PR_FPEMU_SIGFPE = 0x2 + PR_FP_EXC_ASYNC = 0x2 + PR_FP_EXC_DISABLED = 0x0 + PR_FP_EXC_DIV = 0x10000 + PR_FP_EXC_INV = 0x100000 + PR_FP_EXC_NONRECOV = 0x1 + PR_FP_EXC_OVF = 0x20000 + PR_FP_EXC_PRECISE = 0x3 + PR_FP_EXC_RES = 0x80000 + PR_FP_EXC_SW_ENABLE = 0x80 + PR_FP_EXC_UND = 0x40000 + PR_GET_CHILD_SUBREAPER = 0x25 + PR_GET_DUMPABLE = 0x3 + PR_GET_ENDIAN = 0x13 + PR_GET_FPEMU = 0x9 + PR_GET_FPEXC = 0xb + PR_GET_KEEPCAPS = 0x7 + PR_GET_NAME = 0x10 + PR_GET_NO_NEW_PRIVS = 0x27 + PR_GET_PDEATHSIG = 0x2 + PR_GET_SECCOMP = 0x15 + PR_GET_SECUREBITS = 0x1b + PR_GET_THP_DISABLE = 0x2a + PR_GET_TID_ADDRESS = 0x28 + PR_GET_TIMERSLACK = 0x1e + PR_GET_TIMING = 0xd + PR_GET_TSC = 0x19 + PR_GET_UNALIGN = 0x5 + PR_MCE_KILL = 0x21 + PR_MCE_KILL_CLEAR = 0x0 + PR_MCE_KILL_DEFAULT = 0x2 + PR_MCE_KILL_EARLY = 0x1 + PR_MCE_KILL_GET = 0x22 + PR_MCE_KILL_LATE = 0x0 + PR_MCE_KILL_SET = 0x1 + PR_SET_CHILD_SUBREAPER = 0x24 + PR_SET_DUMPABLE = 0x4 + PR_SET_ENDIAN = 0x14 + PR_SET_FPEMU = 0xa + PR_SET_FPEXC = 0xc + PR_SET_KEEPCAPS = 0x8 + PR_SET_MM = 0x23 + PR_SET_MM_ARG_END = 0x9 + PR_SET_MM_ARG_START = 0x8 + PR_SET_MM_AUXV = 0xc + PR_SET_MM_BRK = 0x7 + PR_SET_MM_END_CODE = 0x2 + PR_SET_MM_END_DATA = 0x4 + PR_SET_MM_ENV_END = 0xb + PR_SET_MM_ENV_START = 0xa + PR_SET_MM_EXE_FILE = 0xd + PR_SET_MM_MAP = 0xe + PR_SET_MM_MAP_SIZE = 0xf + PR_SET_MM_START_BRK = 0x6 + PR_SET_MM_START_CODE = 0x1 + PR_SET_MM_START_DATA = 0x3 + PR_SET_MM_START_STACK = 0x5 + PR_SET_NAME = 0xf + PR_SET_NO_NEW_PRIVS = 0x26 + PR_SET_PDEATHSIG = 0x1 + PR_SET_PTRACER = 0x59616d61 + PR_SET_PTRACER_ANY = -0x1 + PR_SET_SECCOMP = 0x16 + PR_SET_SECUREBITS = 0x1c + PR_SET_THP_DISABLE = 0x29 + PR_SET_TIMERSLACK = 0x1d + PR_SET_TIMING = 0xe + PR_SET_TSC = 0x1a + PR_SET_UNALIGN = 0x6 + PR_TASK_PERF_EVENTS_DISABLE = 0x1f + PR_TASK_PERF_EVENTS_ENABLE = 0x20 + PR_TIMING_STATISTICAL = 0x0 + PR_TIMING_TIMESTAMP = 0x1 + PR_TSC_ENABLE = 0x1 + PR_TSC_SIGSEGV = 0x2 + PR_UNALIGN_NOPRINT = 0x1 + PR_UNALIGN_SIGBUS = 0x2 + PTRACE_ATTACH = 0x10 + PTRACE_CONT = 0x7 + PTRACE_DETACH = 0x11 + PTRACE_EVENT_CLONE = 0x3 + PTRACE_EVENT_EXEC = 0x4 + PTRACE_EVENT_EXIT = 0x6 + PTRACE_EVENT_FORK = 0x1 + PTRACE_EVENT_SECCOMP = 0x7 + PTRACE_EVENT_STOP = 0x80 + PTRACE_EVENT_VFORK = 0x2 + PTRACE_EVENT_VFORK_DONE = 0x5 + PTRACE_GETEVENTMSG = 0x4201 + PTRACE_GETEVRREGS = 0x14 + PTRACE_GETFPREGS = 0xe + PTRACE_GETREGS = 0xc + PTRACE_GETREGS64 = 0x16 + PTRACE_GETREGSET = 0x4204 + PTRACE_GETSIGINFO = 0x4202 + PTRACE_GETSIGMASK = 0x420a + PTRACE_GETVRREGS = 0x12 + PTRACE_GETVSRREGS = 0x1b + PTRACE_GET_DEBUGREG = 0x19 + PTRACE_INTERRUPT = 0x4207 + PTRACE_KILL = 0x8 + PTRACE_LISTEN = 0x4208 + PTRACE_O_EXITKILL = 0x100000 + PTRACE_O_MASK = 0x1000ff + PTRACE_O_TRACECLONE = 0x8 + PTRACE_O_TRACEEXEC = 0x10 + PTRACE_O_TRACEEXIT = 0x40 + PTRACE_O_TRACEFORK = 0x2 + PTRACE_O_TRACESECCOMP = 0x80 + PTRACE_O_TRACESYSGOOD = 0x1 + PTRACE_O_TRACEVFORK = 0x4 + PTRACE_O_TRACEVFORKDONE = 0x20 + PTRACE_PEEKDATA = 0x2 + PTRACE_PEEKSIGINFO = 0x4209 + PTRACE_PEEKSIGINFO_SHARED = 0x1 + PTRACE_PEEKTEXT = 0x1 + PTRACE_PEEKUSR = 0x3 + PTRACE_POKEDATA = 0x5 + PTRACE_POKETEXT = 0x4 + PTRACE_POKEUSR = 0x6 + PTRACE_SEIZE = 0x4206 + PTRACE_SETEVRREGS = 0x15 + PTRACE_SETFPREGS = 0xf + PTRACE_SETOPTIONS = 0x4200 + PTRACE_SETREGS = 0xd + PTRACE_SETREGS64 = 0x17 + PTRACE_SETREGSET = 0x4205 + PTRACE_SETSIGINFO = 0x4203 + PTRACE_SETSIGMASK = 0x420b + PTRACE_SETVRREGS = 0x13 + PTRACE_SETVSRREGS = 0x1c + PTRACE_SET_DEBUGREG = 0x1a + PTRACE_SINGLEBLOCK = 0x100 + PTRACE_SINGLESTEP = 0x9 + PTRACE_SYSCALL = 0x18 + PTRACE_TRACEME = 0x0 + PT_CCR = 0x26 + PT_CTR = 0x23 + PT_DAR = 0x29 + PT_DSCR = 0x2c + PT_DSISR = 0x2a + PT_FPR0 = 0x30 + PT_FPSCR = 0x50 + PT_LNK = 0x24 + PT_MSR = 0x21 + PT_NIP = 0x20 + PT_ORIG_R3 = 0x22 + PT_R0 = 0x0 + PT_R1 = 0x1 + PT_R10 = 0xa + PT_R11 = 0xb + PT_R12 = 0xc + PT_R13 = 0xd + PT_R14 = 0xe + PT_R15 = 0xf + PT_R16 = 0x10 + PT_R17 = 0x11 + PT_R18 = 0x12 + PT_R19 = 0x13 + PT_R2 = 0x2 + PT_R20 = 0x14 + PT_R21 = 0x15 + PT_R22 = 0x16 + PT_R23 = 0x17 + PT_R24 = 0x18 + PT_R25 = 0x19 + PT_R26 = 0x1a + PT_R27 = 0x1b + PT_R28 = 0x1c + PT_R29 = 0x1d + PT_R3 = 0x3 + PT_R30 = 0x1e + PT_R31 = 0x1f + PT_R4 = 0x4 + PT_R5 = 0x5 + PT_R6 = 0x6 + PT_R7 = 0x7 + PT_R8 = 0x8 + PT_R9 = 0x9 + PT_REGS_COUNT = 0x2c + PT_RESULT = 0x2b + PT_SOFTE = 0x27 + PT_TRAP = 0x28 + PT_VR0 = 0x52 + PT_VRSAVE = 0x94 + PT_VSCR = 0x93 + PT_VSR0 = 0x96 + PT_VSR31 = 0xd4 + PT_XER = 0x25 + RLIMIT_AS = 0x9 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x7 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = -0x1 + RTAX_ADVMSS = 0x8 + RTAX_CWND = 0x7 + RTAX_FEATURES = 0xc + RTAX_FEATURE_ALLFRAG = 0x8 + RTAX_FEATURE_ECN = 0x1 + RTAX_FEATURE_SACK = 0x2 + RTAX_FEATURE_TIMESTAMP = 0x4 + RTAX_HOPLIMIT = 0xa + RTAX_INITCWND = 0xb + RTAX_INITRWND = 0xe + RTAX_LOCK = 0x1 + RTAX_MAX = 0xf + RTAX_MTU = 0x2 + RTAX_QUICKACK = 0xf + RTAX_REORDERING = 0x9 + RTAX_RTO_MIN = 0xd + RTAX_RTT = 0x4 + RTAX_RTTVAR = 0x5 + RTAX_SSTHRESH = 0x6 + RTAX_UNSPEC = 0x0 + RTAX_WINDOW = 0x3 + RTA_ALIGNTO = 0x4 + RTA_MAX = 0x11 + RTCF_DIRECTSRC = 0x4000000 + RTCF_DOREDIRECT = 0x1000000 + RTCF_LOG = 0x2000000 + RTCF_MASQ = 0x400000 + RTCF_NAT = 0x800000 + RTCF_VALVE = 0x200000 + RTF_ADDRCLASSMASK = 0xf8000000 + RTF_ADDRCONF = 0x40000 + RTF_ALLONLINK = 0x20000 + RTF_BROADCAST = 0x10000000 + RTF_CACHE = 0x1000000 + RTF_DEFAULT = 0x10000 + RTF_DYNAMIC = 0x10 + RTF_FLOW = 0x2000000 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_INTERFACE = 0x40000000 + RTF_IRTT = 0x100 + RTF_LINKRT = 0x100000 + RTF_LOCAL = 0x80000000 + RTF_MODIFIED = 0x20 + RTF_MSS = 0x40 + RTF_MTU = 0x40 + RTF_MULTICAST = 0x20000000 + RTF_NAT = 0x8000000 + RTF_NOFORWARD = 0x1000 + RTF_NONEXTHOP = 0x200000 + RTF_NOPMTUDISC = 0x4000 + RTF_POLICY = 0x4000000 + RTF_REINSTATE = 0x8 + RTF_REJECT = 0x200 + RTF_STATIC = 0x400 + RTF_THROW = 0x2000 + RTF_UP = 0x1 + RTF_WINDOW = 0x80 + RTF_XRESOLVE = 0x800 + RTM_BASE = 0x10 + RTM_DELACTION = 0x31 + RTM_DELADDR = 0x15 + RTM_DELADDRLABEL = 0x49 + RTM_DELLINK = 0x11 + RTM_DELMDB = 0x55 + RTM_DELNEIGH = 0x1d + RTM_DELQDISC = 0x25 + RTM_DELROUTE = 0x19 + RTM_DELRULE = 0x21 + RTM_DELTCLASS = 0x29 + RTM_DELTFILTER = 0x2d + RTM_F_CLONED = 0x200 + RTM_F_EQUALIZE = 0x400 + RTM_F_NOTIFY = 0x100 + RTM_F_PREFIX = 0x800 + RTM_GETACTION = 0x32 + RTM_GETADDR = 0x16 + RTM_GETADDRLABEL = 0x4a + RTM_GETANYCAST = 0x3e + RTM_GETDCB = 0x4e + RTM_GETLINK = 0x12 + RTM_GETMDB = 0x56 + RTM_GETMULTICAST = 0x3a + RTM_GETNEIGH = 0x1e + RTM_GETNEIGHTBL = 0x42 + RTM_GETNETCONF = 0x52 + RTM_GETQDISC = 0x26 + RTM_GETROUTE = 0x1a + RTM_GETRULE = 0x22 + RTM_GETTCLASS = 0x2a + RTM_GETTFILTER = 0x2e + RTM_MAX = 0x57 + RTM_NEWACTION = 0x30 + RTM_NEWADDR = 0x14 + RTM_NEWADDRLABEL = 0x48 + RTM_NEWLINK = 0x10 + RTM_NEWMDB = 0x54 + RTM_NEWNDUSEROPT = 0x44 + RTM_NEWNEIGH = 0x1c + RTM_NEWNEIGHTBL = 0x40 + RTM_NEWNETCONF = 0x50 + RTM_NEWPREFIX = 0x34 + RTM_NEWQDISC = 0x24 + RTM_NEWROUTE = 0x18 + RTM_NEWRULE = 0x20 + RTM_NEWTCLASS = 0x28 + RTM_NEWTFILTER = 0x2c + RTM_NR_FAMILIES = 0x12 + RTM_NR_MSGTYPES = 0x48 + RTM_SETDCB = 0x4f + RTM_SETLINK = 0x13 + RTM_SETNEIGHTBL = 0x43 + RTNH_ALIGNTO = 0x4 + RTNH_F_DEAD = 0x1 + RTNH_F_ONLINK = 0x4 + RTNH_F_PERVASIVE = 0x2 + RTN_MAX = 0xb + RTPROT_BIRD = 0xc + RTPROT_BOOT = 0x3 + RTPROT_DHCP = 0x10 + RTPROT_DNROUTED = 0xd + RTPROT_GATED = 0x8 + RTPROT_KERNEL = 0x2 + RTPROT_MROUTED = 0x11 + RTPROT_MRT = 0xa + RTPROT_NTK = 0xf + RTPROT_RA = 0x9 + RTPROT_REDIRECT = 0x1 + RTPROT_STATIC = 0x4 + RTPROT_UNSPEC = 0x0 + RTPROT_XORP = 0xe + RTPROT_ZEBRA = 0xb + RT_CLASS_DEFAULT = 0xfd + RT_CLASS_LOCAL = 0xff + RT_CLASS_MAIN = 0xfe + RT_CLASS_MAX = 0xff + RT_CLASS_UNSPEC = 0x0 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + RUSAGE_THREAD = 0x1 + SCM_CREDENTIALS = 0x2 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x1d + SCM_TIMESTAMPING = 0x25 + SCM_TIMESTAMPNS = 0x23 + SCM_WIFI_STATUS = 0x29 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDDLCI = 0x8980 + SIOCADDMULTI = 0x8931 + SIOCADDRT = 0x890b + SIOCATMARK = 0x8905 + SIOCDARP = 0x8953 + SIOCDELDLCI = 0x8981 + SIOCDELMULTI = 0x8932 + SIOCDELRT = 0x890c + SIOCDEVPRIVATE = 0x89f0 + SIOCDIFADDR = 0x8936 + SIOCDRARP = 0x8960 + SIOCGARP = 0x8954 + SIOCGIFADDR = 0x8915 + SIOCGIFBR = 0x8940 + SIOCGIFBRDADDR = 0x8919 + SIOCGIFCONF = 0x8912 + SIOCGIFCOUNT = 0x8938 + SIOCGIFDSTADDR = 0x8917 + SIOCGIFENCAP = 0x8925 + SIOCGIFFLAGS = 0x8913 + SIOCGIFHWADDR = 0x8927 + SIOCGIFINDEX = 0x8933 + SIOCGIFMAP = 0x8970 + SIOCGIFMEM = 0x891f + SIOCGIFMETRIC = 0x891d + SIOCGIFMTU = 0x8921 + SIOCGIFNAME = 0x8910 + SIOCGIFNETMASK = 0x891b + SIOCGIFPFLAGS = 0x8935 + SIOCGIFSLAVE = 0x8929 + SIOCGIFTXQLEN = 0x8942 + SIOCGPGRP = 0x8904 + SIOCGRARP = 0x8961 + SIOCGSTAMP = 0x8906 + SIOCGSTAMPNS = 0x8907 + SIOCPROTOPRIVATE = 0x89e0 + SIOCRTMSG = 0x890d + SIOCSARP = 0x8955 + SIOCSIFADDR = 0x8916 + SIOCSIFBR = 0x8941 + SIOCSIFBRDADDR = 0x891a + SIOCSIFDSTADDR = 0x8918 + SIOCSIFENCAP = 0x8926 + SIOCSIFFLAGS = 0x8914 + SIOCSIFHWADDR = 0x8924 + SIOCSIFHWBROADCAST = 0x8937 + SIOCSIFLINK = 0x8911 + SIOCSIFMAP = 0x8971 + SIOCSIFMEM = 0x8920 + SIOCSIFMETRIC = 0x891e + SIOCSIFMTU = 0x8922 + SIOCSIFNAME = 0x8923 + SIOCSIFNETMASK = 0x891c + SIOCSIFPFLAGS = 0x8934 + SIOCSIFSLAVE = 0x8930 + SIOCSIFTXQLEN = 0x8943 + SIOCSPGRP = 0x8902 + SIOCSRARP = 0x8962 + SOCK_CLOEXEC = 0x80000 + SOCK_DCCP = 0x6 + SOCK_DGRAM = 0x2 + SOCK_NONBLOCK = 0x800 + SOCK_PACKET = 0xa + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_AAL = 0x109 + SOL_ATM = 0x108 + SOL_DECNET = 0x105 + SOL_ICMPV6 = 0x3a + SOL_IP = 0x0 + SOL_IPV6 = 0x29 + SOL_IRDA = 0x10a + SOL_PACKET = 0x107 + SOL_RAW = 0xff + SOL_SOCKET = 0x1 + SOL_TCP = 0x6 + SOL_X25 = 0x106 + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x1e + SO_ATTACH_FILTER = 0x1a + SO_BINDTODEVICE = 0x19 + SO_BPF_EXTENSIONS = 0x30 + SO_BROADCAST = 0x6 + SO_BSDCOMPAT = 0xe + SO_BUSY_POLL = 0x2e + SO_DEBUG = 0x1 + SO_DETACH_FILTER = 0x1b + SO_DOMAIN = 0x27 + SO_DONTROUTE = 0x5 + SO_ERROR = 0x4 + SO_GET_FILTER = 0x1a + SO_KEEPALIVE = 0x9 + SO_LINGER = 0xd + SO_LOCK_FILTER = 0x2c + SO_MARK = 0x24 + SO_MAX_PACING_RATE = 0x2f + SO_NOFCS = 0x2b + SO_NO_CHECK = 0xb + SO_OOBINLINE = 0xa + SO_PASSCRED = 0x14 + SO_PASSSEC = 0x22 + SO_PEEK_OFF = 0x2a + SO_PEERCRED = 0x15 + SO_PEERNAME = 0x1c + SO_PEERSEC = 0x1f + SO_PRIORITY = 0xc + SO_PROTOCOL = 0x26 + SO_RCVBUF = 0x8 + SO_RCVBUFFORCE = 0x21 + SO_RCVLOWAT = 0x10 + SO_RCVTIMEO = 0x12 + SO_REUSEADDR = 0x2 + SO_REUSEPORT = 0xf + SO_RXQ_OVFL = 0x28 + SO_SECURITY_AUTHENTICATION = 0x16 + SO_SECURITY_ENCRYPTION_NETWORK = 0x18 + SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17 + SO_SELECT_ERR_QUEUE = 0x2d + SO_SNDBUF = 0x7 + SO_SNDBUFFORCE = 0x20 + SO_SNDLOWAT = 0x11 + SO_SNDTIMEO = 0x13 + SO_TIMESTAMP = 0x1d + SO_TIMESTAMPING = 0x25 + SO_TIMESTAMPNS = 0x23 + SO_TYPE = 0x3 + SO_WIFI_STATUS = 0x29 + S_BLKSIZE = 0x200 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + TAB0 = 0x0 + TAB1 = 0x400 + TAB2 = 0x800 + TAB3 = 0xc00 + TABDLY = 0xc00 + TCFLSH = 0x2000741f + TCGETA = 0x40147417 + TCGETS = 0x402c7413 + TCIFLUSH = 0x0 + TCIOFF = 0x2 + TCIOFLUSH = 0x2 + TCION = 0x3 + TCOFLUSH = 0x1 + TCOOFF = 0x0 + TCOON = 0x1 + TCP_CONGESTION = 0xd + TCP_COOKIE_IN_ALWAYS = 0x1 + TCP_COOKIE_MAX = 0x10 + TCP_COOKIE_MIN = 0x8 + TCP_COOKIE_OUT_NEVER = 0x2 + TCP_COOKIE_PAIR_SIZE = 0x20 + TCP_COOKIE_TRANSACTIONS = 0xf + TCP_CORK = 0x3 + TCP_DEFER_ACCEPT = 0x9 + TCP_FASTOPEN = 0x17 + TCP_INFO = 0xb + TCP_KEEPCNT = 0x6 + TCP_KEEPIDLE = 0x4 + TCP_KEEPINTVL = 0x5 + TCP_LINGER2 = 0x8 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0xe + TCP_MD5SIG_MAXKEYLEN = 0x50 + TCP_MSS = 0x200 + TCP_MSS_DEFAULT = 0x218 + TCP_MSS_DESIRED = 0x4c4 + TCP_NODELAY = 0x1 + TCP_QUEUE_SEQ = 0x15 + TCP_QUICKACK = 0xc + TCP_REPAIR = 0x13 + TCP_REPAIR_OPTIONS = 0x16 + TCP_REPAIR_QUEUE = 0x14 + TCP_SYNCNT = 0x7 + TCP_S_DATA_IN = 0x4 + TCP_S_DATA_OUT = 0x8 + TCP_THIN_DUPACK = 0x11 + TCP_THIN_LINEAR_TIMEOUTS = 0x10 + TCP_TIMESTAMP = 0x18 + TCP_USER_TIMEOUT = 0x12 + TCP_WINDOW_CLAMP = 0xa + TCSAFLUSH = 0x2 + TCSBRK = 0x2000741d + TCSBRKP = 0x5425 + TCSETA = 0x80147418 + TCSETAF = 0x8014741c + TCSETAW = 0x80147419 + TCSETS = 0x802c7414 + TCSETSF = 0x802c7416 + TCSETSW = 0x802c7415 + TCXONC = 0x2000741e + TIOCCBRK = 0x5428 + TIOCCONS = 0x541d + TIOCEXCL = 0x540c + TIOCGDEV = 0x40045432 + TIOCGETC = 0x40067412 + TIOCGETD = 0x5424 + TIOCGETP = 0x40067408 + TIOCGEXCL = 0x40045440 + TIOCGICOUNT = 0x545d + TIOCGLCKTRMIOS = 0x5456 + TIOCGLTC = 0x40067474 + TIOCGPGRP = 0x40047477 + TIOCGPKT = 0x40045438 + TIOCGPTLCK = 0x40045439 + TIOCGPTN = 0x40045430 + TIOCGRS485 = 0x542e + TIOCGSERIAL = 0x541e + TIOCGSID = 0x5429 + TIOCGSOFTCAR = 0x5419 + TIOCGWINSZ = 0x40087468 + TIOCINQ = 0x4004667f + TIOCLINUX = 0x541c + TIOCMBIC = 0x5417 + TIOCMBIS = 0x5416 + TIOCMGET = 0x5415 + TIOCMIWAIT = 0x545c + TIOCMSET = 0x5418 + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_LOOP = 0x8000 + TIOCM_OUT1 = 0x2000 + TIOCM_OUT2 = 0x4000 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x5422 + TIOCNXCL = 0x540d + TIOCOUTQ = 0x40047473 + TIOCPKT = 0x5420 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCSBRK = 0x5427 + TIOCSCTTY = 0x540e + TIOCSERCONFIG = 0x5453 + TIOCSERGETLSR = 0x5459 + TIOCSERGETMULTI = 0x545a + TIOCSERGSTRUCT = 0x5458 + TIOCSERGWILD = 0x5454 + TIOCSERSETMULTI = 0x545b + TIOCSERSWILD = 0x5455 + TIOCSER_TEMT = 0x1 + TIOCSETC = 0x80067411 + TIOCSETD = 0x5423 + TIOCSETN = 0x8006740a + TIOCSETP = 0x80067409 + TIOCSIG = 0x80045436 + TIOCSLCKTRMIOS = 0x5457 + TIOCSLTC = 0x80067475 + TIOCSPGRP = 0x80047476 + TIOCSPTLCK = 0x80045431 + TIOCSRS485 = 0x542f + TIOCSSERIAL = 0x541f + TIOCSSOFTCAR = 0x541a + TIOCSTART = 0x2000746e + TIOCSTI = 0x5412 + TIOCSTOP = 0x2000746f + TIOCSWINSZ = 0x80087467 + TIOCVHANGUP = 0x5437 + TOSTOP = 0x400000 + TUNATTACHFILTER = 0x801054d5 + TUNDETACHFILTER = 0x801054d6 + TUNGETFEATURES = 0x400454cf + TUNGETFILTER = 0x401054db + TUNGETIFF = 0x400454d2 + TUNGETSNDBUF = 0x400454d3 + TUNGETVNETHDRSZ = 0x400454d7 + TUNSETDEBUG = 0x800454c9 + TUNSETGROUP = 0x800454ce + TUNSETIFF = 0x800454ca + TUNSETIFINDEX = 0x800454da + TUNSETLINK = 0x800454cd + TUNSETNOCSUM = 0x800454c8 + TUNSETOFFLOAD = 0x800454d0 + TUNSETOWNER = 0x800454cc + TUNSETPERSIST = 0x800454cb + TUNSETQUEUE = 0x800454d9 + TUNSETSNDBUF = 0x800454d4 + TUNSETTXFILTER = 0x800454d1 + TUNSETVNETHDRSZ = 0x800454d8 + VDISCARD = 0x10 + VEOF = 0x4 + VEOL = 0x6 + VEOL2 = 0x8 + VERASE = 0x2 + VINTR = 0x0 + VKILL = 0x3 + VLNEXT = 0xf + VMIN = 0x5 + VQUIT = 0x1 + VREPRINT = 0xb + VSTART = 0xd + VSTOP = 0xe + VSUSP = 0xc + VSWTC = 0x9 + VT0 = 0x0 + VT1 = 0x10000 + VTDLY = 0x10000 + VTIME = 0x7 + VWERASE = 0xa + WALL = 0x40000000 + WCLONE = 0x80000000 + WCONTINUED = 0x8 + WEXITED = 0x4 + WNOHANG = 0x1 + WNOTHREAD = 0x20000000 + WNOWAIT = 0x1000000 + WORDSIZE = 0x40 + WSTOPPED = 0x2 + WUNTRACED = 0x2 + XCASE = 0x4000 + XTABS = 0xc00 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x62) + EADDRNOTAVAIL = syscall.Errno(0x63) + EADV = syscall.Errno(0x44) + EAFNOSUPPORT = syscall.Errno(0x61) + EAGAIN = syscall.Errno(0xb) + EALREADY = syscall.Errno(0x72) + EBADE = syscall.Errno(0x34) + EBADF = syscall.Errno(0x9) + EBADFD = syscall.Errno(0x4d) + EBADMSG = syscall.Errno(0x4a) + EBADR = syscall.Errno(0x35) + EBADRQC = syscall.Errno(0x38) + EBADSLT = syscall.Errno(0x39) + EBFONT = syscall.Errno(0x3b) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x7d) + ECHILD = syscall.Errno(0xa) + ECHRNG = syscall.Errno(0x2c) + ECOMM = syscall.Errno(0x46) + ECONNABORTED = syscall.Errno(0x67) + ECONNREFUSED = syscall.Errno(0x6f) + ECONNRESET = syscall.Errno(0x68) + EDEADLK = syscall.Errno(0x23) + EDEADLOCK = syscall.Errno(0x3a) + EDESTADDRREQ = syscall.Errno(0x59) + EDOM = syscall.Errno(0x21) + EDOTDOT = syscall.Errno(0x49) + EDQUOT = syscall.Errno(0x7a) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EHOSTDOWN = syscall.Errno(0x70) + EHOSTUNREACH = syscall.Errno(0x71) + EHWPOISON = syscall.Errno(0x85) + EIDRM = syscall.Errno(0x2b) + EILSEQ = syscall.Errno(0x54) + EINPROGRESS = syscall.Errno(0x73) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x6a) + EISDIR = syscall.Errno(0x15) + EISNAM = syscall.Errno(0x78) + EKEYEXPIRED = syscall.Errno(0x7f) + EKEYREJECTED = syscall.Errno(0x81) + EKEYREVOKED = syscall.Errno(0x80) + EL2HLT = syscall.Errno(0x33) + EL2NSYNC = syscall.Errno(0x2d) + EL3HLT = syscall.Errno(0x2e) + EL3RST = syscall.Errno(0x2f) + ELIBACC = syscall.Errno(0x4f) + ELIBBAD = syscall.Errno(0x50) + ELIBEXEC = syscall.Errno(0x53) + ELIBMAX = syscall.Errno(0x52) + ELIBSCN = syscall.Errno(0x51) + ELNRNG = syscall.Errno(0x30) + ELOOP = syscall.Errno(0x28) + EMEDIUMTYPE = syscall.Errno(0x7c) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x5a) + EMULTIHOP = syscall.Errno(0x48) + ENAMETOOLONG = syscall.Errno(0x24) + ENAVAIL = syscall.Errno(0x77) + ENETDOWN = syscall.Errno(0x64) + ENETRESET = syscall.Errno(0x66) + ENETUNREACH = syscall.Errno(0x65) + ENFILE = syscall.Errno(0x17) + ENOANO = syscall.Errno(0x37) + ENOBUFS = syscall.Errno(0x69) + ENOCSI = syscall.Errno(0x32) + ENODATA = syscall.Errno(0x3d) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOKEY = syscall.Errno(0x7e) + ENOLCK = syscall.Errno(0x25) + ENOLINK = syscall.Errno(0x43) + ENOMEDIUM = syscall.Errno(0x7b) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x2a) + ENONET = syscall.Errno(0x40) + ENOPKG = syscall.Errno(0x41) + ENOPROTOOPT = syscall.Errno(0x5c) + ENOSPC = syscall.Errno(0x1c) + ENOSR = syscall.Errno(0x3f) + ENOSTR = syscall.Errno(0x3c) + ENOSYS = syscall.Errno(0x26) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x6b) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x27) + ENOTNAM = syscall.Errno(0x76) + ENOTRECOVERABLE = syscall.Errno(0x83) + ENOTSOCK = syscall.Errno(0x58) + ENOTSUP = syscall.Errno(0x5f) + ENOTTY = syscall.Errno(0x19) + ENOTUNIQ = syscall.Errno(0x4c) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x5f) + EOVERFLOW = syscall.Errno(0x4b) + EOWNERDEAD = syscall.Errno(0x82) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x60) + EPIPE = syscall.Errno(0x20) + EPROTO = syscall.Errno(0x47) + EPROTONOSUPPORT = syscall.Errno(0x5d) + EPROTOTYPE = syscall.Errno(0x5b) + ERANGE = syscall.Errno(0x22) + EREMCHG = syscall.Errno(0x4e) + EREMOTE = syscall.Errno(0x42) + EREMOTEIO = syscall.Errno(0x79) + ERESTART = syscall.Errno(0x55) + ERFKILL = syscall.Errno(0x84) + EROFS = syscall.Errno(0x1e) + ESHUTDOWN = syscall.Errno(0x6c) + ESOCKTNOSUPPORT = syscall.Errno(0x5e) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESRMNT = syscall.Errno(0x45) + ESTALE = syscall.Errno(0x74) + ESTRPIPE = syscall.Errno(0x56) + ETIME = syscall.Errno(0x3e) + ETIMEDOUT = syscall.Errno(0x6e) + ETOOMANYREFS = syscall.Errno(0x6d) + ETXTBSY = syscall.Errno(0x1a) + EUCLEAN = syscall.Errno(0x75) + EUNATCH = syscall.Errno(0x31) + EUSERS = syscall.Errno(0x57) + EWOULDBLOCK = syscall.Errno(0xb) + EXDEV = syscall.Errno(0x12) + EXFULL = syscall.Errno(0x36) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0x7) + SIGCHLD = syscall.Signal(0x11) + SIGCLD = syscall.Signal(0x11) + SIGCONT = syscall.Signal(0x12) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x1d) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPOLL = syscall.Signal(0x1d) + SIGPROF = syscall.Signal(0x1b) + SIGPWR = syscall.Signal(0x1e) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTKFLT = syscall.Signal(0x10) + SIGSTOP = syscall.Signal(0x13) + SIGSYS = syscall.Signal(0x1f) + SIGTERM = syscall.Signal(0xf) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x14) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGUNUSED = syscall.Signal(0x1f) + SIGURG = syscall.Signal(0x17) + SIGUSR1 = syscall.Signal(0xa) + SIGUSR2 = syscall.Signal(0xc) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "no such device or address", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource temporarily unavailable", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device or resource busy", + 17: "file exists", + 18: "invalid cross-device link", + 19: "no such device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "numerical result out of range", + 35: "resource deadlock avoided", + 36: "file name too long", + 37: "no locks available", + 38: "function not implemented", + 39: "directory not empty", + 40: "too many levels of symbolic links", + 42: "no message of desired type", + 43: "identifier removed", + 44: "channel number out of range", + 45: "level 2 not synchronized", + 46: "level 3 halted", + 47: "level 3 reset", + 48: "link number out of range", + 49: "protocol driver not attached", + 50: "no CSI structure available", + 51: "level 2 halted", + 52: "invalid exchange", + 53: "invalid request descriptor", + 54: "exchange full", + 55: "no anode", + 56: "invalid request code", + 57: "invalid slot", + 58: "file locking deadlock error", + 59: "bad font file format", + 60: "device not a stream", + 61: "no data available", + 62: "timer expired", + 63: "out of streams resources", + 64: "machine is not on the network", + 65: "package not installed", + 66: "object is remote", + 67: "link has been severed", + 68: "advertise error", + 69: "srmount error", + 70: "communication error on send", + 71: "protocol error", + 72: "multihop attempted", + 73: "RFS specific error", + 74: "bad message", + 75: "value too large for defined data type", + 76: "name not unique on network", + 77: "file descriptor in bad state", + 78: "remote address changed", + 79: "can not access a needed shared library", + 80: "accessing a corrupted shared library", + 81: ".lib section in a.out corrupted", + 82: "attempting to link in too many shared libraries", + 83: "cannot exec a shared library directly", + 84: "invalid or incomplete multibyte or wide character", + 85: "interrupted system call should be restarted", + 86: "streams pipe error", + 87: "too many users", + 88: "socket operation on non-socket", + 89: "destination address required", + 90: "message too long", + 91: "protocol wrong type for socket", + 92: "protocol not available", + 93: "protocol not supported", + 94: "socket type not supported", + 95: "operation not supported", + 96: "protocol family not supported", + 97: "address family not supported by protocol", + 98: "address already in use", + 99: "cannot assign requested address", + 100: "network is down", + 101: "network is unreachable", + 102: "network dropped connection on reset", + 103: "software caused connection abort", + 104: "connection reset by peer", + 105: "no buffer space available", + 106: "transport endpoint is already connected", + 107: "transport endpoint is not connected", + 108: "cannot send after transport endpoint shutdown", + 109: "too many references: cannot splice", + 110: "connection timed out", + 111: "connection refused", + 112: "host is down", + 113: "no route to host", + 114: "operation already in progress", + 115: "operation now in progress", + 116: "stale file handle", + 117: "structure needs cleaning", + 118: "not a XENIX named type file", + 119: "no XENIX semaphores available", + 120: "is a named type file", + 121: "remote I/O error", + 122: "disk quota exceeded", + 123: "no medium found", + 124: "wrong medium type", + 125: "operation canceled", + 126: "required key not available", + 127: "key has expired", + 128: "key has been revoked", + 129: "key was rejected by service", + 130: "owner died", + 131: "state not recoverable", + 132: "operation not possible due to RF-kill", + 133: "memory page has hardware error", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/breakpoint trap", + 6: "aborted", + 7: "bus error", + 8: "floating point exception", + 9: "killed", + 10: "user defined signal 1", + 11: "segmentation fault", + 12: "user defined signal 2", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "stack fault", + 17: "child exited", + 18: "continued", + 19: "stopped (signal)", + 20: "stopped", + 21: "stopped (tty input)", + 22: "stopped (tty output)", + 23: "urgent I/O condition", + 24: "CPU time limit exceeded", + 25: "file size limit exceeded", + 26: "virtual timer expired", + 27: "profiling timer expired", + 28: "window changed", + 29: "I/O possible", + 30: "power failure", + 31: "bad system call", +} diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go new file mode 100644 index 0000000000..e8d12b5d6d --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -0,0 +1,1969 @@ +// mkerrors.sh -m64 +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build ppc64le,linux + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -m64 _const.go + +package unix + +import "syscall" + +const ( + AF_ALG = 0x26 + AF_APPLETALK = 0x5 + AF_ASH = 0x12 + AF_ATMPVC = 0x8 + AF_ATMSVC = 0x14 + AF_AX25 = 0x3 + AF_BLUETOOTH = 0x1f + AF_BRIDGE = 0x7 + AF_CAIF = 0x25 + AF_CAN = 0x1d + AF_DECnet = 0xc + AF_ECONET = 0x13 + AF_FILE = 0x1 + AF_IEEE802154 = 0x24 + AF_INET = 0x2 + AF_INET6 = 0xa + AF_IPX = 0x4 + AF_IRDA = 0x17 + AF_ISDN = 0x22 + AF_IUCV = 0x20 + AF_KEY = 0xf + AF_LLC = 0x1a + AF_LOCAL = 0x1 + AF_MAX = 0x29 + AF_NETBEUI = 0xd + AF_NETLINK = 0x10 + AF_NETROM = 0x6 + AF_NFC = 0x27 + AF_PACKET = 0x11 + AF_PHONET = 0x23 + AF_PPPOX = 0x18 + AF_RDS = 0x15 + AF_ROSE = 0xb + AF_ROUTE = 0x10 + AF_RXRPC = 0x21 + AF_SECURITY = 0xe + AF_SNA = 0x16 + AF_TIPC = 0x1e + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_VSOCK = 0x28 + AF_WANPIPE = 0x19 + AF_X25 = 0x9 + ARPHRD_ADAPT = 0x108 + ARPHRD_APPLETLK = 0x8 + ARPHRD_ARCNET = 0x7 + ARPHRD_ASH = 0x30d + ARPHRD_ATM = 0x13 + ARPHRD_AX25 = 0x3 + ARPHRD_BIF = 0x307 + ARPHRD_CAIF = 0x336 + ARPHRD_CAN = 0x118 + ARPHRD_CHAOS = 0x5 + ARPHRD_CISCO = 0x201 + ARPHRD_CSLIP = 0x101 + ARPHRD_CSLIP6 = 0x103 + ARPHRD_DDCMP = 0x205 + ARPHRD_DLCI = 0xf + ARPHRD_ECONET = 0x30e + ARPHRD_EETHER = 0x2 + ARPHRD_ETHER = 0x1 + ARPHRD_EUI64 = 0x1b + ARPHRD_FCAL = 0x311 + ARPHRD_FCFABRIC = 0x313 + ARPHRD_FCPL = 0x312 + ARPHRD_FCPP = 0x310 + ARPHRD_FDDI = 0x306 + ARPHRD_FRAD = 0x302 + ARPHRD_HDLC = 0x201 + ARPHRD_HIPPI = 0x30c + ARPHRD_HWX25 = 0x110 + ARPHRD_IEEE1394 = 0x18 + ARPHRD_IEEE802 = 0x6 + ARPHRD_IEEE80211 = 0x321 + ARPHRD_IEEE80211_PRISM = 0x322 + ARPHRD_IEEE80211_RADIOTAP = 0x323 + ARPHRD_IEEE802154 = 0x324 + ARPHRD_IEEE802154_MONITOR = 0x325 + ARPHRD_IEEE802_TR = 0x320 + ARPHRD_INFINIBAND = 0x20 + ARPHRD_IP6GRE = 0x337 + ARPHRD_IPDDP = 0x309 + ARPHRD_IPGRE = 0x30a + ARPHRD_IRDA = 0x30f + ARPHRD_LAPB = 0x204 + ARPHRD_LOCALTLK = 0x305 + ARPHRD_LOOPBACK = 0x304 + ARPHRD_METRICOM = 0x17 + ARPHRD_NETLINK = 0x338 + ARPHRD_NETROM = 0x0 + ARPHRD_NONE = 0xfffe + ARPHRD_PHONET = 0x334 + ARPHRD_PHONET_PIPE = 0x335 + ARPHRD_PIMREG = 0x30b + ARPHRD_PPP = 0x200 + ARPHRD_PRONET = 0x4 + ARPHRD_RAWHDLC = 0x206 + ARPHRD_ROSE = 0x10e + ARPHRD_RSRVD = 0x104 + ARPHRD_SIT = 0x308 + ARPHRD_SKIP = 0x303 + ARPHRD_SLIP = 0x100 + ARPHRD_SLIP6 = 0x102 + ARPHRD_TUNNEL = 0x300 + ARPHRD_TUNNEL6 = 0x301 + ARPHRD_VOID = 0xffff + ARPHRD_X25 = 0x10f + B0 = 0x0 + B1000000 = 0x17 + B110 = 0x3 + B115200 = 0x11 + B1152000 = 0x18 + B1200 = 0x9 + B134 = 0x4 + B150 = 0x5 + B1500000 = 0x19 + B1800 = 0xa + B19200 = 0xe + B200 = 0x6 + B2000000 = 0x1a + B230400 = 0x12 + B2400 = 0xb + B2500000 = 0x1b + B300 = 0x7 + B3000000 = 0x1c + B3500000 = 0x1d + B38400 = 0xf + B4000000 = 0x1e + B460800 = 0x13 + B4800 = 0xc + B50 = 0x1 + B500000 = 0x14 + B57600 = 0x10 + B576000 = 0x15 + B600 = 0x8 + B75 = 0x2 + B921600 = 0x16 + B9600 = 0xd + BOTHER = 0x1f + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXINSNS = 0x1000 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MOD = 0x90 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BPF_XOR = 0xa0 + BRKINT = 0x2 + BS0 = 0x0 + BS1 = 0x8000 + BSDLY = 0x8000 + CBAUD = 0xff + CBAUDEX = 0x0 + CFLUSH = 0xf + CIBAUD = 0xff0000 + CLOCAL = 0x8000 + CLOCK_BOOTTIME = 0x7 + CLOCK_BOOTTIME_ALARM = 0x9 + CLOCK_DEFAULT = 0x0 + CLOCK_EXT = 0x1 + CLOCK_INT = 0x2 + CLOCK_MONOTONIC = 0x1 + CLOCK_MONOTONIC_COARSE = 0x6 + CLOCK_MONOTONIC_RAW = 0x4 + CLOCK_PROCESS_CPUTIME_ID = 0x2 + CLOCK_REALTIME = 0x0 + CLOCK_REALTIME_ALARM = 0x8 + CLOCK_REALTIME_COARSE = 0x5 + CLOCK_THREAD_CPUTIME_ID = 0x3 + CLOCK_TXFROMRX = 0x4 + CLOCK_TXINT = 0x3 + CLONE_CHILD_CLEARTID = 0x200000 + CLONE_CHILD_SETTID = 0x1000000 + CLONE_DETACHED = 0x400000 + CLONE_FILES = 0x400 + CLONE_FS = 0x200 + CLONE_IO = 0x80000000 + CLONE_NEWCGROUP = 0x2000000 + CLONE_NEWIPC = 0x8000000 + CLONE_NEWNET = 0x40000000 + CLONE_NEWNS = 0x20000 + CLONE_NEWPID = 0x20000000 + CLONE_NEWUSER = 0x10000000 + CLONE_NEWUTS = 0x4000000 + CLONE_PARENT = 0x8000 + CLONE_PARENT_SETTID = 0x100000 + CLONE_PTRACE = 0x2000 + CLONE_SETTLS = 0x80000 + CLONE_SIGHAND = 0x800 + CLONE_SYSVSEM = 0x40000 + CLONE_THREAD = 0x10000 + CLONE_UNTRACED = 0x800000 + CLONE_VFORK = 0x4000 + CLONE_VM = 0x100 + CMSPAR = 0x40000000 + CR0 = 0x0 + CR1 = 0x1000 + CR2 = 0x2000 + CR3 = 0x3000 + CRDLY = 0x3000 + CREAD = 0x800 + CRTSCTS = 0x80000000 + CS5 = 0x0 + CS6 = 0x100 + CS7 = 0x200 + CS8 = 0x300 + CSIGNAL = 0xff + CSIZE = 0x300 + CSTART = 0x11 + CSTATUS = 0x0 + CSTOP = 0x13 + CSTOPB = 0x400 + CSUSP = 0x1a + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x40 + ECHOE = 0x2 + ECHOK = 0x4 + ECHOKE = 0x1 + ECHONL = 0x10 + ECHOPRT = 0x20 + ENCODING_DEFAULT = 0x0 + ENCODING_FM_MARK = 0x3 + ENCODING_FM_SPACE = 0x4 + ENCODING_MANCHESTER = 0x5 + ENCODING_NRZ = 0x1 + ENCODING_NRZI = 0x2 + EPOLLERR = 0x8 + EPOLLET = 0x80000000 + EPOLLHUP = 0x10 + EPOLLIN = 0x1 + EPOLLMSG = 0x400 + EPOLLONESHOT = 0x40000000 + EPOLLOUT = 0x4 + EPOLLPRI = 0x2 + EPOLLRDBAND = 0x80 + EPOLLRDHUP = 0x2000 + EPOLLRDNORM = 0x40 + EPOLLWAKEUP = 0x20000000 + EPOLLWRBAND = 0x200 + EPOLLWRNORM = 0x100 + EPOLL_CLOEXEC = 0x80000 + EPOLL_CTL_ADD = 0x1 + EPOLL_CTL_DEL = 0x2 + EPOLL_CTL_MOD = 0x3 + ETH_P_1588 = 0x88f7 + ETH_P_8021AD = 0x88a8 + ETH_P_8021AH = 0x88e7 + ETH_P_8021Q = 0x8100 + ETH_P_802_2 = 0x4 + ETH_P_802_3 = 0x1 + ETH_P_802_3_MIN = 0x600 + ETH_P_802_EX1 = 0x88b5 + ETH_P_AARP = 0x80f3 + ETH_P_AF_IUCV = 0xfbfb + ETH_P_ALL = 0x3 + ETH_P_AOE = 0x88a2 + ETH_P_ARCNET = 0x1a + ETH_P_ARP = 0x806 + ETH_P_ATALK = 0x809b + ETH_P_ATMFATE = 0x8884 + ETH_P_ATMMPOA = 0x884c + ETH_P_AX25 = 0x2 + ETH_P_BATMAN = 0x4305 + ETH_P_BPQ = 0x8ff + ETH_P_CAIF = 0xf7 + ETH_P_CAN = 0xc + ETH_P_CANFD = 0xd + ETH_P_CONTROL = 0x16 + ETH_P_CUST = 0x6006 + ETH_P_DDCMP = 0x6 + ETH_P_DEC = 0x6000 + ETH_P_DIAG = 0x6005 + ETH_P_DNA_DL = 0x6001 + ETH_P_DNA_RC = 0x6002 + ETH_P_DNA_RT = 0x6003 + ETH_P_DSA = 0x1b + ETH_P_ECONET = 0x18 + ETH_P_EDSA = 0xdada + ETH_P_FCOE = 0x8906 + ETH_P_FIP = 0x8914 + ETH_P_HDLC = 0x19 + ETH_P_IEEE802154 = 0xf6 + ETH_P_IEEEPUP = 0xa00 + ETH_P_IEEEPUPAT = 0xa01 + ETH_P_IP = 0x800 + ETH_P_IPV6 = 0x86dd + ETH_P_IPX = 0x8137 + ETH_P_IRDA = 0x17 + ETH_P_LAT = 0x6004 + ETH_P_LINK_CTL = 0x886c + ETH_P_LOCALTALK = 0x9 + ETH_P_LOOP = 0x60 + ETH_P_MOBITEX = 0x15 + ETH_P_MPLS_MC = 0x8848 + ETH_P_MPLS_UC = 0x8847 + ETH_P_MVRP = 0x88f5 + ETH_P_PAE = 0x888e + ETH_P_PAUSE = 0x8808 + ETH_P_PHONET = 0xf5 + ETH_P_PPPTALK = 0x10 + ETH_P_PPP_DISC = 0x8863 + ETH_P_PPP_MP = 0x8 + ETH_P_PPP_SES = 0x8864 + ETH_P_PRP = 0x88fb + ETH_P_PUP = 0x200 + ETH_P_PUPAT = 0x201 + ETH_P_QINQ1 = 0x9100 + ETH_P_QINQ2 = 0x9200 + ETH_P_QINQ3 = 0x9300 + ETH_P_RARP = 0x8035 + ETH_P_SCA = 0x6007 + ETH_P_SLOW = 0x8809 + ETH_P_SNAP = 0x5 + ETH_P_TDLS = 0x890d + ETH_P_TEB = 0x6558 + ETH_P_TIPC = 0x88ca + ETH_P_TRAILER = 0x1c + ETH_P_TR_802_2 = 0x11 + ETH_P_WAN_PPP = 0x7 + ETH_P_WCCP = 0x883e + ETH_P_X25 = 0x805 + EXTA = 0xe + EXTB = 0xf + EXTPROC = 0x10000000 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FF0 = 0x0 + FF1 = 0x4000 + FFDLY = 0x4000 + FLUSHO = 0x800000 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x406 + F_EXLCK = 0x4 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLEASE = 0x401 + F_GETLK = 0x5 + F_GETLK64 = 0xc + F_GETOWN = 0x9 + F_GETOWN_EX = 0x10 + F_GETPIPE_SZ = 0x408 + F_GETSIG = 0xb + F_LOCK = 0x1 + F_NOTIFY = 0x402 + F_OK = 0x0 + F_RDLCK = 0x0 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLEASE = 0x400 + F_SETLK = 0x6 + F_SETLK64 = 0xd + F_SETLKW = 0x7 + F_SETLKW64 = 0xe + F_SETOWN = 0x8 + F_SETOWN_EX = 0xf + F_SETPIPE_SZ = 0x407 + F_SETSIG = 0xa + F_SHLCK = 0x8 + F_TEST = 0x3 + F_TLOCK = 0x2 + F_ULOCK = 0x0 + F_UNLCK = 0x2 + F_WRLCK = 0x1 + HUPCL = 0x4000 + IBSHIFT = 0x10 + ICANON = 0x100 + ICMPV6_FILTER = 0x1 + ICRNL = 0x100 + IEXTEN = 0x400 + IFA_F_DADFAILED = 0x8 + IFA_F_DEPRECATED = 0x20 + IFA_F_HOMEADDRESS = 0x10 + IFA_F_NODAD = 0x2 + IFA_F_OPTIMISTIC = 0x4 + IFA_F_PERMANENT = 0x80 + IFA_F_SECONDARY = 0x1 + IFA_F_TEMPORARY = 0x1 + IFA_F_TENTATIVE = 0x40 + IFA_MAX = 0x7 + IFF_802_1Q_VLAN = 0x1 + IFF_ALLMULTI = 0x200 + IFF_ATTACH_QUEUE = 0x200 + IFF_AUTOMEDIA = 0x4000 + IFF_BONDING = 0x20 + IFF_BRIDGE_PORT = 0x4000 + IFF_BROADCAST = 0x2 + IFF_DEBUG = 0x4 + IFF_DETACH_QUEUE = 0x400 + IFF_DISABLE_NETPOLL = 0x1000 + IFF_DONT_BRIDGE = 0x800 + IFF_DORMANT = 0x20000 + IFF_DYNAMIC = 0x8000 + IFF_EBRIDGE = 0x2 + IFF_ECHO = 0x40000 + IFF_ISATAP = 0x80 + IFF_LIVE_ADDR_CHANGE = 0x100000 + IFF_LOOPBACK = 0x8 + IFF_LOWER_UP = 0x10000 + IFF_MACVLAN = 0x200000 + IFF_MACVLAN_PORT = 0x2000 + IFF_MASTER = 0x400 + IFF_MASTER_8023AD = 0x8 + IFF_MASTER_ALB = 0x10 + IFF_MASTER_ARPMON = 0x100 + IFF_MULTICAST = 0x1000 + IFF_MULTI_QUEUE = 0x100 + IFF_NOARP = 0x80 + IFF_NOFILTER = 0x1000 + IFF_NOTRAILERS = 0x20 + IFF_NO_PI = 0x1000 + IFF_ONE_QUEUE = 0x2000 + IFF_OVS_DATAPATH = 0x8000 + IFF_PERSIST = 0x800 + IFF_POINTOPOINT = 0x10 + IFF_PORTSEL = 0x2000 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SLAVE = 0x800 + IFF_SLAVE_INACTIVE = 0x4 + IFF_SLAVE_NEEDARP = 0x40 + IFF_SUPP_NOFCS = 0x80000 + IFF_TAP = 0x2 + IFF_TEAM_PORT = 0x40000 + IFF_TUN = 0x1 + IFF_TUN_EXCL = 0x8000 + IFF_TX_SKB_SHARING = 0x10000 + IFF_UNICAST_FLT = 0x20000 + IFF_UP = 0x1 + IFF_VNET_HDR = 0x4000 + IFF_VOLATILE = 0x70c5a + IFF_WAN_HDLC = 0x200 + IFF_XMIT_DST_RELEASE = 0x400 + IFNAMSIZ = 0x10 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_ACCESS = 0x1 + IN_ALL_EVENTS = 0xfff + IN_ATTRIB = 0x4 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLOEXEC = 0x80000 + IN_CLOSE = 0x18 + IN_CLOSE_NOWRITE = 0x10 + IN_CLOSE_WRITE = 0x8 + IN_CREATE = 0x100 + IN_DELETE = 0x200 + IN_DELETE_SELF = 0x400 + IN_DONT_FOLLOW = 0x2000000 + IN_EXCL_UNLINK = 0x4000000 + IN_IGNORED = 0x8000 + IN_ISDIR = 0x40000000 + IN_LOOPBACKNET = 0x7f + IN_MASK_ADD = 0x20000000 + IN_MODIFY = 0x2 + IN_MOVE = 0xc0 + IN_MOVED_FROM = 0x40 + IN_MOVED_TO = 0x80 + IN_MOVE_SELF = 0x800 + IN_NONBLOCK = 0x800 + IN_ONESHOT = 0x80000000 + IN_ONLYDIR = 0x1000000 + IN_OPEN = 0x20 + IN_Q_OVERFLOW = 0x4000 + IN_UNMOUNT = 0x2000 + IPPROTO_AH = 0x33 + IPPROTO_BEETPH = 0x5e + IPPROTO_COMP = 0x6c + IPPROTO_DCCP = 0x21 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_ENCAP = 0x62 + IPPROTO_ESP = 0x32 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GRE = 0x2f + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IGMP = 0x2 + IPPROTO_IP = 0x0 + IPPROTO_IPIP = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_MH = 0x87 + IPPROTO_MTP = 0x5c + IPPROTO_NONE = 0x3b + IPPROTO_PIM = 0x67 + IPPROTO_PUP = 0xc + IPPROTO_RAW = 0xff + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_SCTP = 0x84 + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_UDP = 0x11 + IPPROTO_UDPLITE = 0x88 + IPV6_2292DSTOPTS = 0x4 + IPV6_2292HOPLIMIT = 0x8 + IPV6_2292HOPOPTS = 0x3 + IPV6_2292PKTINFO = 0x2 + IPV6_2292PKTOPTIONS = 0x6 + IPV6_2292RTHDR = 0x5 + IPV6_ADDRFORM = 0x1 + IPV6_ADD_MEMBERSHIP = 0x14 + IPV6_AUTHHDR = 0xa + IPV6_CHECKSUM = 0x7 + IPV6_DROP_MEMBERSHIP = 0x15 + IPV6_DSTOPTS = 0x3b + IPV6_HOPLIMIT = 0x34 + IPV6_HOPOPTS = 0x36 + IPV6_IPSEC_POLICY = 0x22 + IPV6_JOIN_ANYCAST = 0x1b + IPV6_JOIN_GROUP = 0x14 + IPV6_LEAVE_ANYCAST = 0x1c + IPV6_LEAVE_GROUP = 0x15 + IPV6_MTU = 0x18 + IPV6_MTU_DISCOVER = 0x17 + IPV6_MULTICAST_HOPS = 0x12 + IPV6_MULTICAST_IF = 0x11 + IPV6_MULTICAST_LOOP = 0x13 + IPV6_NEXTHOP = 0x9 + IPV6_PKTINFO = 0x32 + IPV6_PMTUDISC_DO = 0x2 + IPV6_PMTUDISC_DONT = 0x0 + IPV6_PMTUDISC_PROBE = 0x3 + IPV6_PMTUDISC_WANT = 0x1 + IPV6_RECVDSTOPTS = 0x3a + IPV6_RECVERR = 0x19 + IPV6_RECVHOPLIMIT = 0x33 + IPV6_RECVHOPOPTS = 0x35 + IPV6_RECVPKTINFO = 0x31 + IPV6_RECVRTHDR = 0x38 + IPV6_RECVTCLASS = 0x42 + IPV6_ROUTER_ALERT = 0x16 + IPV6_RTHDR = 0x39 + IPV6_RTHDRDSTOPTS = 0x37 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_RXDSTOPTS = 0x3b + IPV6_RXHOPOPTS = 0x36 + IPV6_TCLASS = 0x43 + IPV6_UNICAST_HOPS = 0x10 + IPV6_V6ONLY = 0x1a + IPV6_XFRM_POLICY = 0x23 + IP_ADD_MEMBERSHIP = 0x23 + IP_ADD_SOURCE_MEMBERSHIP = 0x27 + IP_BLOCK_SOURCE = 0x26 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DROP_MEMBERSHIP = 0x24 + IP_DROP_SOURCE_MEMBERSHIP = 0x28 + IP_FREEBIND = 0xf + IP_HDRINCL = 0x3 + IP_IPSEC_POLICY = 0x10 + IP_MAXPACKET = 0xffff + IP_MAX_MEMBERSHIPS = 0x14 + IP_MF = 0x2000 + IP_MINTTL = 0x15 + IP_MSFILTER = 0x29 + IP_MSS = 0x240 + IP_MTU = 0xe + IP_MTU_DISCOVER = 0xa + IP_MULTICAST_ALL = 0x31 + IP_MULTICAST_IF = 0x20 + IP_MULTICAST_LOOP = 0x22 + IP_MULTICAST_TTL = 0x21 + IP_OFFMASK = 0x1fff + IP_OPTIONS = 0x4 + IP_ORIGDSTADDR = 0x14 + IP_PASSSEC = 0x12 + IP_PKTINFO = 0x8 + IP_PKTOPTIONS = 0x9 + IP_PMTUDISC = 0xa + IP_PMTUDISC_DO = 0x2 + IP_PMTUDISC_DONT = 0x0 + IP_PMTUDISC_PROBE = 0x3 + IP_PMTUDISC_WANT = 0x1 + IP_RECVERR = 0xb + IP_RECVOPTS = 0x6 + IP_RECVORIGDSTADDR = 0x14 + IP_RECVRETOPTS = 0x7 + IP_RECVTOS = 0xd + IP_RECVTTL = 0xc + IP_RETOPTS = 0x7 + IP_RF = 0x8000 + IP_ROUTER_ALERT = 0x5 + IP_TOS = 0x1 + IP_TRANSPARENT = 0x13 + IP_TTL = 0x2 + IP_UNBLOCK_SOURCE = 0x25 + IP_UNICAST_IF = 0x32 + IP_XFRM_POLICY = 0x11 + ISIG = 0x80 + ISTRIP = 0x20 + IUCLC = 0x1000 + IUTF8 = 0x4000 + IXANY = 0x800 + IXOFF = 0x400 + IXON = 0x200 + LINUX_REBOOT_CMD_CAD_OFF = 0x0 + LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef + LINUX_REBOOT_CMD_HALT = 0xcdef0123 + LINUX_REBOOT_CMD_KEXEC = 0x45584543 + LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc + LINUX_REBOOT_CMD_RESTART = 0x1234567 + LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4 + LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2 + LINUX_REBOOT_MAGIC1 = 0xfee1dead + LINUX_REBOOT_MAGIC2 = 0x28121969 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_DODUMP = 0x11 + MADV_DOFORK = 0xb + MADV_DONTDUMP = 0x10 + MADV_DONTFORK = 0xa + MADV_DONTNEED = 0x4 + MADV_HUGEPAGE = 0xe + MADV_HWPOISON = 0x64 + MADV_MERGEABLE = 0xc + MADV_NOHUGEPAGE = 0xf + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_REMOVE = 0x9 + MADV_SEQUENTIAL = 0x2 + MADV_UNMERGEABLE = 0xd + MADV_WILLNEED = 0x3 + MAP_ANON = 0x20 + MAP_ANONYMOUS = 0x20 + MAP_DENYWRITE = 0x800 + MAP_EXECUTABLE = 0x1000 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_GROWSDOWN = 0x100 + MAP_HUGETLB = 0x40000 + MAP_HUGE_MASK = 0x3f + MAP_HUGE_SHIFT = 0x1a + MAP_LOCKED = 0x80 + MAP_NONBLOCK = 0x10000 + MAP_NORESERVE = 0x40 + MAP_POPULATE = 0x8000 + MAP_PRIVATE = 0x2 + MAP_SHARED = 0x1 + MAP_STACK = 0x20000 + MAP_TYPE = 0xf + MCL_CURRENT = 0x2000 + MCL_FUTURE = 0x4000 + MNT_DETACH = 0x2 + MNT_EXPIRE = 0x4 + MNT_FORCE = 0x1 + MSG_CMSG_CLOEXEC = 0x40000000 + MSG_CONFIRM = 0x800 + MSG_CTRUNC = 0x8 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x40 + MSG_EOR = 0x80 + MSG_ERRQUEUE = 0x2000 + MSG_FASTOPEN = 0x20000000 + MSG_FIN = 0x200 + MSG_MORE = 0x8000 + MSG_NOSIGNAL = 0x4000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_PROXY = 0x10 + MSG_RST = 0x1000 + MSG_SYN = 0x400 + MSG_TRUNC = 0x20 + MSG_TRYHARD = 0x4 + MSG_WAITALL = 0x100 + MSG_WAITFORONE = 0x10000 + MS_ACTIVE = 0x40000000 + MS_ASYNC = 0x1 + MS_BIND = 0x1000 + MS_DIRSYNC = 0x80 + MS_INVALIDATE = 0x2 + MS_I_VERSION = 0x800000 + MS_KERNMOUNT = 0x400000 + MS_MANDLOCK = 0x40 + MS_MGC_MSK = 0xffff0000 + MS_MGC_VAL = 0xc0ed0000 + MS_MOVE = 0x2000 + MS_NOATIME = 0x400 + MS_NODEV = 0x4 + MS_NODIRATIME = 0x800 + MS_NOEXEC = 0x8 + MS_NOSUID = 0x2 + MS_NOUSER = -0x80000000 + MS_POSIXACL = 0x10000 + MS_PRIVATE = 0x40000 + MS_RDONLY = 0x1 + MS_REC = 0x4000 + MS_RELATIME = 0x200000 + MS_REMOUNT = 0x20 + MS_RMT_MASK = 0x800051 + MS_SHARED = 0x100000 + MS_SILENT = 0x8000 + MS_SLAVE = 0x80000 + MS_STRICTATIME = 0x1000000 + MS_SYNC = 0x4 + MS_SYNCHRONOUS = 0x10 + MS_UNBINDABLE = 0x20000 + NAME_MAX = 0xff + NETLINK_ADD_MEMBERSHIP = 0x1 + NETLINK_AUDIT = 0x9 + NETLINK_BROADCAST_ERROR = 0x4 + NETLINK_CONNECTOR = 0xb + NETLINK_CRYPTO = 0x15 + NETLINK_DNRTMSG = 0xe + NETLINK_DROP_MEMBERSHIP = 0x2 + NETLINK_ECRYPTFS = 0x13 + NETLINK_FIB_LOOKUP = 0xa + NETLINK_FIREWALL = 0x3 + NETLINK_GENERIC = 0x10 + NETLINK_INET_DIAG = 0x4 + NETLINK_IP6_FW = 0xd + NETLINK_ISCSI = 0x8 + NETLINK_KOBJECT_UEVENT = 0xf + NETLINK_NETFILTER = 0xc + NETLINK_NFLOG = 0x5 + NETLINK_NO_ENOBUFS = 0x5 + NETLINK_PKTINFO = 0x3 + NETLINK_RDMA = 0x14 + NETLINK_ROUTE = 0x0 + NETLINK_RX_RING = 0x6 + NETLINK_SCSITRANSPORT = 0x12 + NETLINK_SELINUX = 0x7 + NETLINK_SOCK_DIAG = 0x4 + NETLINK_TX_RING = 0x7 + NETLINK_UNUSED = 0x1 + NETLINK_USERSOCK = 0x2 + NETLINK_XFRM = 0x6 + NL0 = 0x0 + NL1 = 0x100 + NL2 = 0x200 + NL3 = 0x300 + NLA_ALIGNTO = 0x4 + NLA_F_NESTED = 0x8000 + NLA_F_NET_BYTEORDER = 0x4000 + NLA_HDRLEN = 0x4 + NLDLY = 0x300 + NLMSG_ALIGNTO = 0x4 + NLMSG_DONE = 0x3 + NLMSG_ERROR = 0x2 + NLMSG_HDRLEN = 0x10 + NLMSG_MIN_TYPE = 0x10 + NLMSG_NOOP = 0x1 + NLMSG_OVERRUN = 0x4 + NLM_F_ACK = 0x4 + NLM_F_APPEND = 0x800 + NLM_F_ATOMIC = 0x400 + NLM_F_CREATE = 0x400 + NLM_F_DUMP = 0x300 + NLM_F_DUMP_INTR = 0x10 + NLM_F_ECHO = 0x8 + NLM_F_EXCL = 0x200 + NLM_F_MATCH = 0x200 + NLM_F_MULTI = 0x2 + NLM_F_REPLACE = 0x100 + NLM_F_REQUEST = 0x1 + NLM_F_ROOT = 0x100 + NOFLSH = 0x80000000 + OCRNL = 0x8 + OFDEL = 0x80 + OFILL = 0x40 + OLCUC = 0x4 + ONLCR = 0x2 + ONLRET = 0x20 + ONOCR = 0x10 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_APPEND = 0x400 + O_ASYNC = 0x2000 + O_CLOEXEC = 0x80000 + O_CREAT = 0x40 + O_DIRECT = 0x20000 + O_DIRECTORY = 0x4000 + O_DSYNC = 0x1000 + O_EXCL = 0x80 + O_FSYNC = 0x101000 + O_LARGEFILE = 0x0 + O_NDELAY = 0x800 + O_NOATIME = 0x40000 + O_NOCTTY = 0x100 + O_NOFOLLOW = 0x8000 + O_NONBLOCK = 0x800 + O_PATH = 0x200000 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_RSYNC = 0x101000 + O_SYNC = 0x101000 + O_TMPFILE = 0x410000 + O_TRUNC = 0x200 + O_WRONLY = 0x1 + PACKET_ADD_MEMBERSHIP = 0x1 + PACKET_AUXDATA = 0x8 + PACKET_BROADCAST = 0x1 + PACKET_COPY_THRESH = 0x7 + PACKET_DROP_MEMBERSHIP = 0x2 + PACKET_FANOUT = 0x12 + PACKET_FANOUT_CPU = 0x2 + PACKET_FANOUT_FLAG_DEFRAG = 0x8000 + PACKET_FANOUT_FLAG_ROLLOVER = 0x1000 + PACKET_FANOUT_HASH = 0x0 + PACKET_FANOUT_LB = 0x1 + PACKET_FANOUT_RND = 0x4 + PACKET_FANOUT_ROLLOVER = 0x3 + PACKET_FASTROUTE = 0x6 + PACKET_HDRLEN = 0xb + PACKET_HOST = 0x0 + PACKET_LOOPBACK = 0x5 + PACKET_LOSS = 0xe + PACKET_MR_ALLMULTI = 0x2 + PACKET_MR_MULTICAST = 0x0 + PACKET_MR_PROMISC = 0x1 + PACKET_MR_UNICAST = 0x3 + PACKET_MULTICAST = 0x2 + PACKET_ORIGDEV = 0x9 + PACKET_OTHERHOST = 0x3 + PACKET_OUTGOING = 0x4 + PACKET_RECV_OUTPUT = 0x3 + PACKET_RESERVE = 0xc + PACKET_RX_RING = 0x5 + PACKET_STATISTICS = 0x6 + PACKET_TIMESTAMP = 0x11 + PACKET_TX_HAS_OFF = 0x13 + PACKET_TX_RING = 0xd + PACKET_TX_TIMESTAMP = 0x10 + PACKET_VERSION = 0xa + PACKET_VNET_HDR = 0xf + PARENB = 0x1000 + PARITY_CRC16_PR0 = 0x2 + PARITY_CRC16_PR0_CCITT = 0x4 + PARITY_CRC16_PR1 = 0x3 + PARITY_CRC16_PR1_CCITT = 0x5 + PARITY_CRC32_PR0_CCITT = 0x6 + PARITY_CRC32_PR1_CCITT = 0x7 + PARITY_DEFAULT = 0x0 + PARITY_NONE = 0x1 + PARMRK = 0x8 + PARODD = 0x2000 + PENDIN = 0x20000000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_GROWSDOWN = 0x1000000 + PROT_GROWSUP = 0x2000000 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_SAO = 0x10 + PROT_WRITE = 0x2 + PR_CAPBSET_DROP = 0x18 + PR_CAPBSET_READ = 0x17 + PR_ENDIAN_BIG = 0x0 + PR_ENDIAN_LITTLE = 0x1 + PR_ENDIAN_PPC_LITTLE = 0x2 + PR_FPEMU_NOPRINT = 0x1 + PR_FPEMU_SIGFPE = 0x2 + PR_FP_EXC_ASYNC = 0x2 + PR_FP_EXC_DISABLED = 0x0 + PR_FP_EXC_DIV = 0x10000 + PR_FP_EXC_INV = 0x100000 + PR_FP_EXC_NONRECOV = 0x1 + PR_FP_EXC_OVF = 0x20000 + PR_FP_EXC_PRECISE = 0x3 + PR_FP_EXC_RES = 0x80000 + PR_FP_EXC_SW_ENABLE = 0x80 + PR_FP_EXC_UND = 0x40000 + PR_GET_CHILD_SUBREAPER = 0x25 + PR_GET_DUMPABLE = 0x3 + PR_GET_ENDIAN = 0x13 + PR_GET_FPEMU = 0x9 + PR_GET_FPEXC = 0xb + PR_GET_KEEPCAPS = 0x7 + PR_GET_NAME = 0x10 + PR_GET_NO_NEW_PRIVS = 0x27 + PR_GET_PDEATHSIG = 0x2 + PR_GET_SECCOMP = 0x15 + PR_GET_SECUREBITS = 0x1b + PR_GET_TID_ADDRESS = 0x28 + PR_GET_TIMERSLACK = 0x1e + PR_GET_TIMING = 0xd + PR_GET_TSC = 0x19 + PR_GET_UNALIGN = 0x5 + PR_MCE_KILL = 0x21 + PR_MCE_KILL_CLEAR = 0x0 + PR_MCE_KILL_DEFAULT = 0x2 + PR_MCE_KILL_EARLY = 0x1 + PR_MCE_KILL_GET = 0x22 + PR_MCE_KILL_LATE = 0x0 + PR_MCE_KILL_SET = 0x1 + PR_SET_CHILD_SUBREAPER = 0x24 + PR_SET_DUMPABLE = 0x4 + PR_SET_ENDIAN = 0x14 + PR_SET_FPEMU = 0xa + PR_SET_FPEXC = 0xc + PR_SET_KEEPCAPS = 0x8 + PR_SET_MM = 0x23 + PR_SET_MM_ARG_END = 0x9 + PR_SET_MM_ARG_START = 0x8 + PR_SET_MM_AUXV = 0xc + PR_SET_MM_BRK = 0x7 + PR_SET_MM_END_CODE = 0x2 + PR_SET_MM_END_DATA = 0x4 + PR_SET_MM_ENV_END = 0xb + PR_SET_MM_ENV_START = 0xa + PR_SET_MM_EXE_FILE = 0xd + PR_SET_MM_START_BRK = 0x6 + PR_SET_MM_START_CODE = 0x1 + PR_SET_MM_START_DATA = 0x3 + PR_SET_MM_START_STACK = 0x5 + PR_SET_NAME = 0xf + PR_SET_NO_NEW_PRIVS = 0x26 + PR_SET_PDEATHSIG = 0x1 + PR_SET_PTRACER = 0x59616d61 + PR_SET_PTRACER_ANY = -0x1 + PR_SET_SECCOMP = 0x16 + PR_SET_SECUREBITS = 0x1c + PR_SET_TIMERSLACK = 0x1d + PR_SET_TIMING = 0xe + PR_SET_TSC = 0x1a + PR_SET_UNALIGN = 0x6 + PR_TASK_PERF_EVENTS_DISABLE = 0x1f + PR_TASK_PERF_EVENTS_ENABLE = 0x20 + PR_TIMING_STATISTICAL = 0x0 + PR_TIMING_TIMESTAMP = 0x1 + PR_TSC_ENABLE = 0x1 + PR_TSC_SIGSEGV = 0x2 + PR_UNALIGN_NOPRINT = 0x1 + PR_UNALIGN_SIGBUS = 0x2 + PTRACE_ATTACH = 0x10 + PTRACE_CONT = 0x7 + PTRACE_DETACH = 0x11 + PTRACE_EVENT_CLONE = 0x3 + PTRACE_EVENT_EXEC = 0x4 + PTRACE_EVENT_EXIT = 0x6 + PTRACE_EVENT_FORK = 0x1 + PTRACE_EVENT_SECCOMP = 0x7 + PTRACE_EVENT_STOP = 0x80 + PTRACE_EVENT_VFORK = 0x2 + PTRACE_EVENT_VFORK_DONE = 0x5 + PTRACE_GETEVENTMSG = 0x4201 + PTRACE_GETEVRREGS = 0x14 + PTRACE_GETFPREGS = 0xe + PTRACE_GETREGS = 0xc + PTRACE_GETREGS64 = 0x16 + PTRACE_GETREGSET = 0x4204 + PTRACE_GETSIGINFO = 0x4202 + PTRACE_GETSIGMASK = 0x420a + PTRACE_GETVRREGS = 0x12 + PTRACE_GETVSRREGS = 0x1b + PTRACE_GET_DEBUGREG = 0x19 + PTRACE_INTERRUPT = 0x4207 + PTRACE_KILL = 0x8 + PTRACE_LISTEN = 0x4208 + PTRACE_O_EXITKILL = 0x100000 + PTRACE_O_MASK = 0x1000ff + PTRACE_O_TRACECLONE = 0x8 + PTRACE_O_TRACEEXEC = 0x10 + PTRACE_O_TRACEEXIT = 0x40 + PTRACE_O_TRACEFORK = 0x2 + PTRACE_O_TRACESECCOMP = 0x80 + PTRACE_O_TRACESYSGOOD = 0x1 + PTRACE_O_TRACEVFORK = 0x4 + PTRACE_O_TRACEVFORKDONE = 0x20 + PTRACE_PEEKDATA = 0x2 + PTRACE_PEEKSIGINFO = 0x4209 + PTRACE_PEEKSIGINFO_SHARED = 0x1 + PTRACE_PEEKTEXT = 0x1 + PTRACE_PEEKUSR = 0x3 + PTRACE_POKEDATA = 0x5 + PTRACE_POKETEXT = 0x4 + PTRACE_POKEUSR = 0x6 + PTRACE_SEIZE = 0x4206 + PTRACE_SETEVRREGS = 0x15 + PTRACE_SETFPREGS = 0xf + PTRACE_SETOPTIONS = 0x4200 + PTRACE_SETREGS = 0xd + PTRACE_SETREGS64 = 0x17 + PTRACE_SETREGSET = 0x4205 + PTRACE_SETSIGINFO = 0x4203 + PTRACE_SETSIGMASK = 0x420b + PTRACE_SETVRREGS = 0x13 + PTRACE_SETVSRREGS = 0x1c + PTRACE_SET_DEBUGREG = 0x1a + PTRACE_SINGLEBLOCK = 0x100 + PTRACE_SINGLESTEP = 0x9 + PTRACE_SYSCALL = 0x18 + PTRACE_TRACEME = 0x0 + PT_CCR = 0x26 + PT_CTR = 0x23 + PT_DAR = 0x29 + PT_DSCR = 0x2c + PT_DSISR = 0x2a + PT_FPR0 = 0x30 + PT_FPSCR = 0x50 + PT_LNK = 0x24 + PT_MSR = 0x21 + PT_NIP = 0x20 + PT_ORIG_R3 = 0x22 + PT_R0 = 0x0 + PT_R1 = 0x1 + PT_R10 = 0xa + PT_R11 = 0xb + PT_R12 = 0xc + PT_R13 = 0xd + PT_R14 = 0xe + PT_R15 = 0xf + PT_R16 = 0x10 + PT_R17 = 0x11 + PT_R18 = 0x12 + PT_R19 = 0x13 + PT_R2 = 0x2 + PT_R20 = 0x14 + PT_R21 = 0x15 + PT_R22 = 0x16 + PT_R23 = 0x17 + PT_R24 = 0x18 + PT_R25 = 0x19 + PT_R26 = 0x1a + PT_R27 = 0x1b + PT_R28 = 0x1c + PT_R29 = 0x1d + PT_R3 = 0x3 + PT_R30 = 0x1e + PT_R31 = 0x1f + PT_R4 = 0x4 + PT_R5 = 0x5 + PT_R6 = 0x6 + PT_R7 = 0x7 + PT_R8 = 0x8 + PT_R9 = 0x9 + PT_REGS_COUNT = 0x2c + PT_RESULT = 0x2b + PT_SOFTE = 0x27 + PT_TRAP = 0x28 + PT_VR0 = 0x52 + PT_VRSAVE = 0x94 + PT_VSCR = 0x93 + PT_VSR0 = 0x96 + PT_VSR31 = 0xd4 + PT_XER = 0x25 + RLIMIT_AS = 0x9 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x7 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = -0x1 + RTAX_ADVMSS = 0x8 + RTAX_CWND = 0x7 + RTAX_FEATURES = 0xc + RTAX_FEATURE_ALLFRAG = 0x8 + RTAX_FEATURE_ECN = 0x1 + RTAX_FEATURE_SACK = 0x2 + RTAX_FEATURE_TIMESTAMP = 0x4 + RTAX_HOPLIMIT = 0xa + RTAX_INITCWND = 0xb + RTAX_INITRWND = 0xe + RTAX_LOCK = 0x1 + RTAX_MAX = 0xf + RTAX_MTU = 0x2 + RTAX_QUICKACK = 0xf + RTAX_REORDERING = 0x9 + RTAX_RTO_MIN = 0xd + RTAX_RTT = 0x4 + RTAX_RTTVAR = 0x5 + RTAX_SSTHRESH = 0x6 + RTAX_UNSPEC = 0x0 + RTAX_WINDOW = 0x3 + RTA_ALIGNTO = 0x4 + RTA_MAX = 0x11 + RTCF_DIRECTSRC = 0x4000000 + RTCF_DOREDIRECT = 0x1000000 + RTCF_LOG = 0x2000000 + RTCF_MASQ = 0x400000 + RTCF_NAT = 0x800000 + RTCF_VALVE = 0x200000 + RTF_ADDRCLASSMASK = 0xf8000000 + RTF_ADDRCONF = 0x40000 + RTF_ALLONLINK = 0x20000 + RTF_BROADCAST = 0x10000000 + RTF_CACHE = 0x1000000 + RTF_DEFAULT = 0x10000 + RTF_DYNAMIC = 0x10 + RTF_FLOW = 0x2000000 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_INTERFACE = 0x40000000 + RTF_IRTT = 0x100 + RTF_LINKRT = 0x100000 + RTF_LOCAL = 0x80000000 + RTF_MODIFIED = 0x20 + RTF_MSS = 0x40 + RTF_MTU = 0x40 + RTF_MULTICAST = 0x20000000 + RTF_NAT = 0x8000000 + RTF_NOFORWARD = 0x1000 + RTF_NONEXTHOP = 0x200000 + RTF_NOPMTUDISC = 0x4000 + RTF_POLICY = 0x4000000 + RTF_REINSTATE = 0x8 + RTF_REJECT = 0x200 + RTF_STATIC = 0x400 + RTF_THROW = 0x2000 + RTF_UP = 0x1 + RTF_WINDOW = 0x80 + RTF_XRESOLVE = 0x800 + RTM_BASE = 0x10 + RTM_DELACTION = 0x31 + RTM_DELADDR = 0x15 + RTM_DELADDRLABEL = 0x49 + RTM_DELLINK = 0x11 + RTM_DELMDB = 0x55 + RTM_DELNEIGH = 0x1d + RTM_DELQDISC = 0x25 + RTM_DELROUTE = 0x19 + RTM_DELRULE = 0x21 + RTM_DELTCLASS = 0x29 + RTM_DELTFILTER = 0x2d + RTM_F_CLONED = 0x200 + RTM_F_EQUALIZE = 0x400 + RTM_F_NOTIFY = 0x100 + RTM_F_PREFIX = 0x800 + RTM_GETACTION = 0x32 + RTM_GETADDR = 0x16 + RTM_GETADDRLABEL = 0x4a + RTM_GETANYCAST = 0x3e + RTM_GETDCB = 0x4e + RTM_GETLINK = 0x12 + RTM_GETMDB = 0x56 + RTM_GETMULTICAST = 0x3a + RTM_GETNEIGH = 0x1e + RTM_GETNEIGHTBL = 0x42 + RTM_GETNETCONF = 0x52 + RTM_GETQDISC = 0x26 + RTM_GETROUTE = 0x1a + RTM_GETRULE = 0x22 + RTM_GETTCLASS = 0x2a + RTM_GETTFILTER = 0x2e + RTM_MAX = 0x57 + RTM_NEWACTION = 0x30 + RTM_NEWADDR = 0x14 + RTM_NEWADDRLABEL = 0x48 + RTM_NEWLINK = 0x10 + RTM_NEWMDB = 0x54 + RTM_NEWNDUSEROPT = 0x44 + RTM_NEWNEIGH = 0x1c + RTM_NEWNEIGHTBL = 0x40 + RTM_NEWNETCONF = 0x50 + RTM_NEWPREFIX = 0x34 + RTM_NEWQDISC = 0x24 + RTM_NEWROUTE = 0x18 + RTM_NEWRULE = 0x20 + RTM_NEWTCLASS = 0x28 + RTM_NEWTFILTER = 0x2c + RTM_NR_FAMILIES = 0x12 + RTM_NR_MSGTYPES = 0x48 + RTM_SETDCB = 0x4f + RTM_SETLINK = 0x13 + RTM_SETNEIGHTBL = 0x43 + RTNH_ALIGNTO = 0x4 + RTNH_F_DEAD = 0x1 + RTNH_F_ONLINK = 0x4 + RTNH_F_PERVASIVE = 0x2 + RTN_MAX = 0xb + RTPROT_BIRD = 0xc + RTPROT_BOOT = 0x3 + RTPROT_DHCP = 0x10 + RTPROT_DNROUTED = 0xd + RTPROT_GATED = 0x8 + RTPROT_KERNEL = 0x2 + RTPROT_MROUTED = 0x11 + RTPROT_MRT = 0xa + RTPROT_NTK = 0xf + RTPROT_RA = 0x9 + RTPROT_REDIRECT = 0x1 + RTPROT_STATIC = 0x4 + RTPROT_UNSPEC = 0x0 + RTPROT_XORP = 0xe + RTPROT_ZEBRA = 0xb + RT_CLASS_DEFAULT = 0xfd + RT_CLASS_LOCAL = 0xff + RT_CLASS_MAIN = 0xfe + RT_CLASS_MAX = 0xff + RT_CLASS_UNSPEC = 0x0 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + RUSAGE_THREAD = 0x1 + SCM_CREDENTIALS = 0x2 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x1d + SCM_TIMESTAMPING = 0x25 + SCM_TIMESTAMPNS = 0x23 + SCM_WIFI_STATUS = 0x29 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDDLCI = 0x8980 + SIOCADDMULTI = 0x8931 + SIOCADDRT = 0x890b + SIOCATMARK = 0x8905 + SIOCDARP = 0x8953 + SIOCDELDLCI = 0x8981 + SIOCDELMULTI = 0x8932 + SIOCDELRT = 0x890c + SIOCDEVPRIVATE = 0x89f0 + SIOCDIFADDR = 0x8936 + SIOCDRARP = 0x8960 + SIOCGARP = 0x8954 + SIOCGIFADDR = 0x8915 + SIOCGIFBR = 0x8940 + SIOCGIFBRDADDR = 0x8919 + SIOCGIFCONF = 0x8912 + SIOCGIFCOUNT = 0x8938 + SIOCGIFDSTADDR = 0x8917 + SIOCGIFENCAP = 0x8925 + SIOCGIFFLAGS = 0x8913 + SIOCGIFHWADDR = 0x8927 + SIOCGIFINDEX = 0x8933 + SIOCGIFMAP = 0x8970 + SIOCGIFMEM = 0x891f + SIOCGIFMETRIC = 0x891d + SIOCGIFMTU = 0x8921 + SIOCGIFNAME = 0x8910 + SIOCGIFNETMASK = 0x891b + SIOCGIFPFLAGS = 0x8935 + SIOCGIFSLAVE = 0x8929 + SIOCGIFTXQLEN = 0x8942 + SIOCGPGRP = 0x8904 + SIOCGRARP = 0x8961 + SIOCGSTAMP = 0x8906 + SIOCGSTAMPNS = 0x8907 + SIOCPROTOPRIVATE = 0x89e0 + SIOCRTMSG = 0x890d + SIOCSARP = 0x8955 + SIOCSIFADDR = 0x8916 + SIOCSIFBR = 0x8941 + SIOCSIFBRDADDR = 0x891a + SIOCSIFDSTADDR = 0x8918 + SIOCSIFENCAP = 0x8926 + SIOCSIFFLAGS = 0x8914 + SIOCSIFHWADDR = 0x8924 + SIOCSIFHWBROADCAST = 0x8937 + SIOCSIFLINK = 0x8911 + SIOCSIFMAP = 0x8971 + SIOCSIFMEM = 0x8920 + SIOCSIFMETRIC = 0x891e + SIOCSIFMTU = 0x8922 + SIOCSIFNAME = 0x8923 + SIOCSIFNETMASK = 0x891c + SIOCSIFPFLAGS = 0x8934 + SIOCSIFSLAVE = 0x8930 + SIOCSIFTXQLEN = 0x8943 + SIOCSPGRP = 0x8902 + SIOCSRARP = 0x8962 + SOCK_CLOEXEC = 0x80000 + SOCK_DCCP = 0x6 + SOCK_DGRAM = 0x2 + SOCK_NONBLOCK = 0x800 + SOCK_PACKET = 0xa + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_AAL = 0x109 + SOL_ATM = 0x108 + SOL_DECNET = 0x105 + SOL_ICMPV6 = 0x3a + SOL_IP = 0x0 + SOL_IPV6 = 0x29 + SOL_IRDA = 0x10a + SOL_PACKET = 0x107 + SOL_RAW = 0xff + SOL_SOCKET = 0x1 + SOL_TCP = 0x6 + SOL_X25 = 0x106 + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x1e + SO_ATTACH_FILTER = 0x1a + SO_BINDTODEVICE = 0x19 + SO_BROADCAST = 0x6 + SO_BSDCOMPAT = 0xe + SO_BUSY_POLL = 0x2e + SO_DEBUG = 0x1 + SO_DETACH_FILTER = 0x1b + SO_DOMAIN = 0x27 + SO_DONTROUTE = 0x5 + SO_ERROR = 0x4 + SO_GET_FILTER = 0x1a + SO_KEEPALIVE = 0x9 + SO_LINGER = 0xd + SO_LOCK_FILTER = 0x2c + SO_MARK = 0x24 + SO_MAX_PACING_RATE = 0x2f + SO_NOFCS = 0x2b + SO_NO_CHECK = 0xb + SO_OOBINLINE = 0xa + SO_PASSCRED = 0x14 + SO_PASSSEC = 0x22 + SO_PEEK_OFF = 0x2a + SO_PEERCRED = 0x15 + SO_PEERNAME = 0x1c + SO_PEERSEC = 0x1f + SO_PRIORITY = 0xc + SO_PROTOCOL = 0x26 + SO_RCVBUF = 0x8 + SO_RCVBUFFORCE = 0x21 + SO_RCVLOWAT = 0x10 + SO_RCVTIMEO = 0x12 + SO_REUSEADDR = 0x2 + SO_REUSEPORT = 0xf + SO_RXQ_OVFL = 0x28 + SO_SECURITY_AUTHENTICATION = 0x16 + SO_SECURITY_ENCRYPTION_NETWORK = 0x18 + SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17 + SO_SELECT_ERR_QUEUE = 0x2d + SO_SNDBUF = 0x7 + SO_SNDBUFFORCE = 0x20 + SO_SNDLOWAT = 0x11 + SO_SNDTIMEO = 0x13 + SO_TIMESTAMP = 0x1d + SO_TIMESTAMPING = 0x25 + SO_TIMESTAMPNS = 0x23 + SO_TYPE = 0x3 + SO_WIFI_STATUS = 0x29 + S_BLKSIZE = 0x200 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + TAB0 = 0x0 + TAB1 = 0x400 + TAB2 = 0x800 + TAB3 = 0xc00 + TABDLY = 0xc00 + TCFLSH = 0x2000741f + TCGETA = 0x40147417 + TCGETS = 0x402c7413 + TCIFLUSH = 0x0 + TCIOFF = 0x2 + TCIOFLUSH = 0x2 + TCION = 0x3 + TCOFLUSH = 0x1 + TCOOFF = 0x0 + TCOON = 0x1 + TCP_CONGESTION = 0xd + TCP_COOKIE_IN_ALWAYS = 0x1 + TCP_COOKIE_MAX = 0x10 + TCP_COOKIE_MIN = 0x8 + TCP_COOKIE_OUT_NEVER = 0x2 + TCP_COOKIE_PAIR_SIZE = 0x20 + TCP_COOKIE_TRANSACTIONS = 0xf + TCP_CORK = 0x3 + TCP_DEFER_ACCEPT = 0x9 + TCP_FASTOPEN = 0x17 + TCP_INFO = 0xb + TCP_KEEPCNT = 0x6 + TCP_KEEPIDLE = 0x4 + TCP_KEEPINTVL = 0x5 + TCP_LINGER2 = 0x8 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0xe + TCP_MD5SIG_MAXKEYLEN = 0x50 + TCP_MSS = 0x200 + TCP_MSS_DEFAULT = 0x218 + TCP_MSS_DESIRED = 0x4c4 + TCP_NODELAY = 0x1 + TCP_QUEUE_SEQ = 0x15 + TCP_QUICKACK = 0xc + TCP_REPAIR = 0x13 + TCP_REPAIR_OPTIONS = 0x16 + TCP_REPAIR_QUEUE = 0x14 + TCP_SYNCNT = 0x7 + TCP_S_DATA_IN = 0x4 + TCP_S_DATA_OUT = 0x8 + TCP_THIN_DUPACK = 0x11 + TCP_THIN_LINEAR_TIMEOUTS = 0x10 + TCP_TIMESTAMP = 0x18 + TCP_USER_TIMEOUT = 0x12 + TCP_WINDOW_CLAMP = 0xa + TCSAFLUSH = 0x2 + TCSBRK = 0x2000741d + TCSBRKP = 0x5425 + TCSETA = 0x80147418 + TCSETAF = 0x8014741c + TCSETAW = 0x80147419 + TCSETS = 0x802c7414 + TCSETSF = 0x802c7416 + TCSETSW = 0x802c7415 + TCXONC = 0x2000741e + TIOCCBRK = 0x5428 + TIOCCONS = 0x541d + TIOCEXCL = 0x540c + TIOCGDEV = 0x40045432 + TIOCGETC = 0x40067412 + TIOCGETD = 0x5424 + TIOCGETP = 0x40067408 + TIOCGEXCL = 0x40045440 + TIOCGICOUNT = 0x545d + TIOCGLCKTRMIOS = 0x5456 + TIOCGLTC = 0x40067474 + TIOCGPGRP = 0x40047477 + TIOCGPKT = 0x40045438 + TIOCGPTLCK = 0x40045439 + TIOCGPTN = 0x40045430 + TIOCGRS485 = 0x542e + TIOCGSERIAL = 0x541e + TIOCGSID = 0x5429 + TIOCGSOFTCAR = 0x5419 + TIOCGWINSZ = 0x40087468 + TIOCINQ = 0x4004667f + TIOCLINUX = 0x541c + TIOCMBIC = 0x5417 + TIOCMBIS = 0x5416 + TIOCMGET = 0x5415 + TIOCMIWAIT = 0x545c + TIOCMSET = 0x5418 + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_LOOP = 0x8000 + TIOCM_OUT1 = 0x2000 + TIOCM_OUT2 = 0x4000 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x5422 + TIOCNXCL = 0x540d + TIOCOUTQ = 0x40047473 + TIOCPKT = 0x5420 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCSBRK = 0x5427 + TIOCSCTTY = 0x540e + TIOCSERCONFIG = 0x5453 + TIOCSERGETLSR = 0x5459 + TIOCSERGETMULTI = 0x545a + TIOCSERGSTRUCT = 0x5458 + TIOCSERGWILD = 0x5454 + TIOCSERSETMULTI = 0x545b + TIOCSERSWILD = 0x5455 + TIOCSER_TEMT = 0x1 + TIOCSETC = 0x80067411 + TIOCSETD = 0x5423 + TIOCSETN = 0x8006740a + TIOCSETP = 0x80067409 + TIOCSIG = 0x80045436 + TIOCSLCKTRMIOS = 0x5457 + TIOCSLTC = 0x80067475 + TIOCSPGRP = 0x80047476 + TIOCSPTLCK = 0x80045431 + TIOCSRS485 = 0x542f + TIOCSSERIAL = 0x541f + TIOCSSOFTCAR = 0x541a + TIOCSTART = 0x2000746e + TIOCSTI = 0x5412 + TIOCSTOP = 0x2000746f + TIOCSWINSZ = 0x80087467 + TIOCVHANGUP = 0x5437 + TOSTOP = 0x400000 + TUNATTACHFILTER = 0x801054d5 + TUNDETACHFILTER = 0x801054d6 + TUNGETFEATURES = 0x400454cf + TUNGETFILTER = 0x401054db + TUNGETIFF = 0x400454d2 + TUNGETSNDBUF = 0x400454d3 + TUNGETVNETHDRSZ = 0x400454d7 + TUNSETDEBUG = 0x800454c9 + TUNSETGROUP = 0x800454ce + TUNSETIFF = 0x800454ca + TUNSETIFINDEX = 0x800454da + TUNSETLINK = 0x800454cd + TUNSETNOCSUM = 0x800454c8 + TUNSETOFFLOAD = 0x800454d0 + TUNSETOWNER = 0x800454cc + TUNSETPERSIST = 0x800454cb + TUNSETQUEUE = 0x800454d9 + TUNSETSNDBUF = 0x800454d4 + TUNSETTXFILTER = 0x800454d1 + TUNSETVNETHDRSZ = 0x800454d8 + VDISCARD = 0x10 + VEOF = 0x4 + VEOL = 0x6 + VEOL2 = 0x8 + VERASE = 0x2 + VINTR = 0x0 + VKILL = 0x3 + VLNEXT = 0xf + VMIN = 0x5 + VQUIT = 0x1 + VREPRINT = 0xb + VSTART = 0xd + VSTOP = 0xe + VSUSP = 0xc + VSWTC = 0x9 + VT0 = 0x0 + VT1 = 0x10000 + VTDLY = 0x10000 + VTIME = 0x7 + VWERASE = 0xa + WALL = 0x40000000 + WCLONE = 0x80000000 + WCONTINUED = 0x8 + WEXITED = 0x4 + WNOHANG = 0x1 + WNOTHREAD = 0x20000000 + WNOWAIT = 0x1000000 + WORDSIZE = 0x40 + WSTOPPED = 0x2 + WUNTRACED = 0x2 + XCASE = 0x4000 + XTABS = 0xc00 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x62) + EADDRNOTAVAIL = syscall.Errno(0x63) + EADV = syscall.Errno(0x44) + EAFNOSUPPORT = syscall.Errno(0x61) + EAGAIN = syscall.Errno(0xb) + EALREADY = syscall.Errno(0x72) + EBADE = syscall.Errno(0x34) + EBADF = syscall.Errno(0x9) + EBADFD = syscall.Errno(0x4d) + EBADMSG = syscall.Errno(0x4a) + EBADR = syscall.Errno(0x35) + EBADRQC = syscall.Errno(0x38) + EBADSLT = syscall.Errno(0x39) + EBFONT = syscall.Errno(0x3b) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x7d) + ECHILD = syscall.Errno(0xa) + ECHRNG = syscall.Errno(0x2c) + ECOMM = syscall.Errno(0x46) + ECONNABORTED = syscall.Errno(0x67) + ECONNREFUSED = syscall.Errno(0x6f) + ECONNRESET = syscall.Errno(0x68) + EDEADLK = syscall.Errno(0x23) + EDEADLOCK = syscall.Errno(0x3a) + EDESTADDRREQ = syscall.Errno(0x59) + EDOM = syscall.Errno(0x21) + EDOTDOT = syscall.Errno(0x49) + EDQUOT = syscall.Errno(0x7a) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EHOSTDOWN = syscall.Errno(0x70) + EHOSTUNREACH = syscall.Errno(0x71) + EHWPOISON = syscall.Errno(0x85) + EIDRM = syscall.Errno(0x2b) + EILSEQ = syscall.Errno(0x54) + EINPROGRESS = syscall.Errno(0x73) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x6a) + EISDIR = syscall.Errno(0x15) + EISNAM = syscall.Errno(0x78) + EKEYEXPIRED = syscall.Errno(0x7f) + EKEYREJECTED = syscall.Errno(0x81) + EKEYREVOKED = syscall.Errno(0x80) + EL2HLT = syscall.Errno(0x33) + EL2NSYNC = syscall.Errno(0x2d) + EL3HLT = syscall.Errno(0x2e) + EL3RST = syscall.Errno(0x2f) + ELIBACC = syscall.Errno(0x4f) + ELIBBAD = syscall.Errno(0x50) + ELIBEXEC = syscall.Errno(0x53) + ELIBMAX = syscall.Errno(0x52) + ELIBSCN = syscall.Errno(0x51) + ELNRNG = syscall.Errno(0x30) + ELOOP = syscall.Errno(0x28) + EMEDIUMTYPE = syscall.Errno(0x7c) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x5a) + EMULTIHOP = syscall.Errno(0x48) + ENAMETOOLONG = syscall.Errno(0x24) + ENAVAIL = syscall.Errno(0x77) + ENETDOWN = syscall.Errno(0x64) + ENETRESET = syscall.Errno(0x66) + ENETUNREACH = syscall.Errno(0x65) + ENFILE = syscall.Errno(0x17) + ENOANO = syscall.Errno(0x37) + ENOBUFS = syscall.Errno(0x69) + ENOCSI = syscall.Errno(0x32) + ENODATA = syscall.Errno(0x3d) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOKEY = syscall.Errno(0x7e) + ENOLCK = syscall.Errno(0x25) + ENOLINK = syscall.Errno(0x43) + ENOMEDIUM = syscall.Errno(0x7b) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x2a) + ENONET = syscall.Errno(0x40) + ENOPKG = syscall.Errno(0x41) + ENOPROTOOPT = syscall.Errno(0x5c) + ENOSPC = syscall.Errno(0x1c) + ENOSR = syscall.Errno(0x3f) + ENOSTR = syscall.Errno(0x3c) + ENOSYS = syscall.Errno(0x26) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x6b) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x27) + ENOTNAM = syscall.Errno(0x76) + ENOTRECOVERABLE = syscall.Errno(0x83) + ENOTSOCK = syscall.Errno(0x58) + ENOTSUP = syscall.Errno(0x5f) + ENOTTY = syscall.Errno(0x19) + ENOTUNIQ = syscall.Errno(0x4c) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x5f) + EOVERFLOW = syscall.Errno(0x4b) + EOWNERDEAD = syscall.Errno(0x82) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x60) + EPIPE = syscall.Errno(0x20) + EPROTO = syscall.Errno(0x47) + EPROTONOSUPPORT = syscall.Errno(0x5d) + EPROTOTYPE = syscall.Errno(0x5b) + ERANGE = syscall.Errno(0x22) + EREMCHG = syscall.Errno(0x4e) + EREMOTE = syscall.Errno(0x42) + EREMOTEIO = syscall.Errno(0x79) + ERESTART = syscall.Errno(0x55) + ERFKILL = syscall.Errno(0x84) + EROFS = syscall.Errno(0x1e) + ESHUTDOWN = syscall.Errno(0x6c) + ESOCKTNOSUPPORT = syscall.Errno(0x5e) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESRMNT = syscall.Errno(0x45) + ESTALE = syscall.Errno(0x74) + ESTRPIPE = syscall.Errno(0x56) + ETIME = syscall.Errno(0x3e) + ETIMEDOUT = syscall.Errno(0x6e) + ETOOMANYREFS = syscall.Errno(0x6d) + ETXTBSY = syscall.Errno(0x1a) + EUCLEAN = syscall.Errno(0x75) + EUNATCH = syscall.Errno(0x31) + EUSERS = syscall.Errno(0x57) + EWOULDBLOCK = syscall.Errno(0xb) + EXDEV = syscall.Errno(0x12) + EXFULL = syscall.Errno(0x36) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0x7) + SIGCHLD = syscall.Signal(0x11) + SIGCLD = syscall.Signal(0x11) + SIGCONT = syscall.Signal(0x12) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x1d) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPOLL = syscall.Signal(0x1d) + SIGPROF = syscall.Signal(0x1b) + SIGPWR = syscall.Signal(0x1e) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTKFLT = syscall.Signal(0x10) + SIGSTOP = syscall.Signal(0x13) + SIGSYS = syscall.Signal(0x1f) + SIGTERM = syscall.Signal(0xf) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x14) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGUNUSED = syscall.Signal(0x1f) + SIGURG = syscall.Signal(0x17) + SIGUSR1 = syscall.Signal(0xa) + SIGUSR2 = syscall.Signal(0xc) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "no such device or address", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource temporarily unavailable", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device or resource busy", + 17: "file exists", + 18: "invalid cross-device link", + 19: "no such device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "numerical result out of range", + 35: "resource deadlock avoided", + 36: "file name too long", + 37: "no locks available", + 38: "function not implemented", + 39: "directory not empty", + 40: "too many levels of symbolic links", + 42: "no message of desired type", + 43: "identifier removed", + 44: "channel number out of range", + 45: "level 2 not synchronized", + 46: "level 3 halted", + 47: "level 3 reset", + 48: "link number out of range", + 49: "protocol driver not attached", + 50: "no CSI structure available", + 51: "level 2 halted", + 52: "invalid exchange", + 53: "invalid request descriptor", + 54: "exchange full", + 55: "no anode", + 56: "invalid request code", + 57: "invalid slot", + 58: "file locking deadlock error", + 59: "bad font file format", + 60: "device not a stream", + 61: "no data available", + 62: "timer expired", + 63: "out of streams resources", + 64: "machine is not on the network", + 65: "package not installed", + 66: "object is remote", + 67: "link has been severed", + 68: "advertise error", + 69: "srmount error", + 70: "communication error on send", + 71: "protocol error", + 72: "multihop attempted", + 73: "RFS specific error", + 74: "bad message", + 75: "value too large for defined data type", + 76: "name not unique on network", + 77: "file descriptor in bad state", + 78: "remote address changed", + 79: "can not access a needed shared library", + 80: "accessing a corrupted shared library", + 81: ".lib section in a.out corrupted", + 82: "attempting to link in too many shared libraries", + 83: "cannot exec a shared library directly", + 84: "invalid or incomplete multibyte or wide character", + 85: "interrupted system call should be restarted", + 86: "streams pipe error", + 87: "too many users", + 88: "socket operation on non-socket", + 89: "destination address required", + 90: "message too long", + 91: "protocol wrong type for socket", + 92: "protocol not available", + 93: "protocol not supported", + 94: "socket type not supported", + 95: "operation not supported", + 96: "protocol family not supported", + 97: "address family not supported by protocol", + 98: "address already in use", + 99: "cannot assign requested address", + 100: "network is down", + 101: "network is unreachable", + 102: "network dropped connection on reset", + 103: "software caused connection abort", + 104: "connection reset by peer", + 105: "no buffer space available", + 106: "transport endpoint is already connected", + 107: "transport endpoint is not connected", + 108: "cannot send after transport endpoint shutdown", + 109: "too many references: cannot splice", + 110: "connection timed out", + 111: "connection refused", + 112: "host is down", + 113: "no route to host", + 114: "operation already in progress", + 115: "operation now in progress", + 116: "stale file handle", + 117: "structure needs cleaning", + 118: "not a XENIX named type file", + 119: "no XENIX semaphores available", + 120: "is a named type file", + 121: "remote I/O error", + 122: "disk quota exceeded", + 123: "no medium found", + 124: "wrong medium type", + 125: "operation canceled", + 126: "required key not available", + 127: "key has expired", + 128: "key has been revoked", + 129: "key was rejected by service", + 130: "owner died", + 131: "state not recoverable", + 132: "operation not possible due to RF-kill", + 133: "memory page has hardware error", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/breakpoint trap", + 6: "aborted", + 7: "bus error", + 8: "floating point exception", + 9: "killed", + 10: "user defined signal 1", + 11: "segmentation fault", + 12: "user defined signal 2", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "stack fault", + 17: "child exited", + 18: "continued", + 19: "stopped (signal)", + 20: "stopped", + 21: "stopped (tty input)", + 22: "stopped (tty output)", + 23: "urgent I/O condition", + 24: "CPU time limit exceeded", + 25: "file size limit exceeded", + 26: "virtual timer expired", + 27: "profiling timer expired", + 28: "window changed", + 29: "I/O possible", + 30: "power failure", + 31: "bad system call", +} diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go new file mode 100644 index 0000000000..329f25e7cf --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go @@ -0,0 +1,2027 @@ +// mkerrors.sh -m64 +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build s390x,linux + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -m64 _const.go + +package unix + +import "syscall" + +const ( + AF_ALG = 0x26 + AF_APPLETALK = 0x5 + AF_ASH = 0x12 + AF_ATMPVC = 0x8 + AF_ATMSVC = 0x14 + AF_AX25 = 0x3 + AF_BLUETOOTH = 0x1f + AF_BRIDGE = 0x7 + AF_CAIF = 0x25 + AF_CAN = 0x1d + AF_DECnet = 0xc + AF_ECONET = 0x13 + AF_FILE = 0x1 + AF_IB = 0x1b + AF_IEEE802154 = 0x24 + AF_INET = 0x2 + AF_INET6 = 0xa + AF_IPX = 0x4 + AF_IRDA = 0x17 + AF_ISDN = 0x22 + AF_IUCV = 0x20 + AF_KEY = 0xf + AF_LLC = 0x1a + AF_LOCAL = 0x1 + AF_MAX = 0x29 + AF_MPLS = 0x1c + AF_NETBEUI = 0xd + AF_NETLINK = 0x10 + AF_NETROM = 0x6 + AF_NFC = 0x27 + AF_PACKET = 0x11 + AF_PHONET = 0x23 + AF_PPPOX = 0x18 + AF_RDS = 0x15 + AF_ROSE = 0xb + AF_ROUTE = 0x10 + AF_RXRPC = 0x21 + AF_SECURITY = 0xe + AF_SNA = 0x16 + AF_TIPC = 0x1e + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_VSOCK = 0x28 + AF_WANPIPE = 0x19 + AF_X25 = 0x9 + ARPHRD_6LOWPAN = 0x339 + ARPHRD_ADAPT = 0x108 + ARPHRD_APPLETLK = 0x8 + ARPHRD_ARCNET = 0x7 + ARPHRD_ASH = 0x30d + ARPHRD_ATM = 0x13 + ARPHRD_AX25 = 0x3 + ARPHRD_BIF = 0x307 + ARPHRD_CAIF = 0x336 + ARPHRD_CAN = 0x118 + ARPHRD_CHAOS = 0x5 + ARPHRD_CISCO = 0x201 + ARPHRD_CSLIP = 0x101 + ARPHRD_CSLIP6 = 0x103 + ARPHRD_DDCMP = 0x205 + ARPHRD_DLCI = 0xf + ARPHRD_ECONET = 0x30e + ARPHRD_EETHER = 0x2 + ARPHRD_ETHER = 0x1 + ARPHRD_EUI64 = 0x1b + ARPHRD_FCAL = 0x311 + ARPHRD_FCFABRIC = 0x313 + ARPHRD_FCPL = 0x312 + ARPHRD_FCPP = 0x310 + ARPHRD_FDDI = 0x306 + ARPHRD_FRAD = 0x302 + ARPHRD_HDLC = 0x201 + ARPHRD_HIPPI = 0x30c + ARPHRD_HWX25 = 0x110 + ARPHRD_IEEE1394 = 0x18 + ARPHRD_IEEE802 = 0x6 + ARPHRD_IEEE80211 = 0x321 + ARPHRD_IEEE80211_PRISM = 0x322 + ARPHRD_IEEE80211_RADIOTAP = 0x323 + ARPHRD_IEEE802154 = 0x324 + ARPHRD_IEEE802154_MONITOR = 0x325 + ARPHRD_IEEE802_TR = 0x320 + ARPHRD_INFINIBAND = 0x20 + ARPHRD_IP6GRE = 0x337 + ARPHRD_IPDDP = 0x309 + ARPHRD_IPGRE = 0x30a + ARPHRD_IRDA = 0x30f + ARPHRD_LAPB = 0x204 + ARPHRD_LOCALTLK = 0x305 + ARPHRD_LOOPBACK = 0x304 + ARPHRD_METRICOM = 0x17 + ARPHRD_NETLINK = 0x338 + ARPHRD_NETROM = 0x0 + ARPHRD_NONE = 0xfffe + ARPHRD_PHONET = 0x334 + ARPHRD_PHONET_PIPE = 0x335 + ARPHRD_PIMREG = 0x30b + ARPHRD_PPP = 0x200 + ARPHRD_PRONET = 0x4 + ARPHRD_RAWHDLC = 0x206 + ARPHRD_ROSE = 0x10e + ARPHRD_RSRVD = 0x104 + ARPHRD_SIT = 0x308 + ARPHRD_SKIP = 0x303 + ARPHRD_SLIP = 0x100 + ARPHRD_SLIP6 = 0x102 + ARPHRD_TUNNEL = 0x300 + ARPHRD_TUNNEL6 = 0x301 + ARPHRD_VOID = 0xffff + ARPHRD_X25 = 0x10f + B0 = 0x0 + B1000000 = 0x1008 + B110 = 0x3 + B115200 = 0x1002 + B1152000 = 0x1009 + B1200 = 0x9 + B134 = 0x4 + B150 = 0x5 + B1500000 = 0x100a + B1800 = 0xa + B19200 = 0xe + B200 = 0x6 + B2000000 = 0x100b + B230400 = 0x1003 + B2400 = 0xb + B2500000 = 0x100c + B300 = 0x7 + B3000000 = 0x100d + B3500000 = 0x100e + B38400 = 0xf + B4000000 = 0x100f + B460800 = 0x1004 + B4800 = 0xc + B50 = 0x1 + B500000 = 0x1005 + B57600 = 0x1001 + B576000 = 0x1006 + B600 = 0x8 + B75 = 0x2 + B921600 = 0x1007 + B9600 = 0xd + BOTHER = 0x1000 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LL_OFF = -0x200000 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXINSNS = 0x1000 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MOD = 0x90 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_NET_OFF = -0x100000 + BPF_OR = 0x40 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BPF_XOR = 0xa0 + BRKINT = 0x2 + BS0 = 0x0 + BS1 = 0x2000 + BSDLY = 0x2000 + CBAUD = 0x100f + CBAUDEX = 0x1000 + CFLUSH = 0xf + CIBAUD = 0x100f0000 + CLOCAL = 0x800 + CLOCK_BOOTTIME = 0x7 + CLOCK_BOOTTIME_ALARM = 0x9 + CLOCK_DEFAULT = 0x0 + CLOCK_EXT = 0x1 + CLOCK_INT = 0x2 + CLOCK_MONOTONIC = 0x1 + CLOCK_MONOTONIC_COARSE = 0x6 + CLOCK_MONOTONIC_RAW = 0x4 + CLOCK_PROCESS_CPUTIME_ID = 0x2 + CLOCK_REALTIME = 0x0 + CLOCK_REALTIME_ALARM = 0x8 + CLOCK_REALTIME_COARSE = 0x5 + CLOCK_TAI = 0xb + CLOCK_THREAD_CPUTIME_ID = 0x3 + CLOCK_TXFROMRX = 0x4 + CLOCK_TXINT = 0x3 + CLONE_CHILD_CLEARTID = 0x200000 + CLONE_CHILD_SETTID = 0x1000000 + CLONE_DETACHED = 0x400000 + CLONE_FILES = 0x400 + CLONE_FS = 0x200 + CLONE_IO = 0x80000000 + CLONE_NEWCGROUP = 0x2000000 + CLONE_NEWIPC = 0x8000000 + CLONE_NEWNET = 0x40000000 + CLONE_NEWNS = 0x20000 + CLONE_NEWPID = 0x20000000 + CLONE_NEWUSER = 0x10000000 + CLONE_NEWUTS = 0x4000000 + CLONE_PARENT = 0x8000 + CLONE_PARENT_SETTID = 0x100000 + CLONE_PTRACE = 0x2000 + CLONE_SETTLS = 0x80000 + CLONE_SIGHAND = 0x800 + CLONE_SYSVSEM = 0x40000 + CLONE_THREAD = 0x10000 + CLONE_UNTRACED = 0x800000 + CLONE_VFORK = 0x4000 + CLONE_VM = 0x100 + CMSPAR = 0x40000000 + CR0 = 0x0 + CR1 = 0x200 + CR2 = 0x400 + CR3 = 0x600 + CRDLY = 0x600 + CREAD = 0x80 + CRTSCTS = 0x80000000 + CS5 = 0x0 + CS6 = 0x10 + CS7 = 0x20 + CS8 = 0x30 + CSIGNAL = 0xff + CSIZE = 0x30 + CSTART = 0x11 + CSTATUS = 0x0 + CSTOP = 0x13 + CSTOPB = 0x40 + CSUSP = 0x1a + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x200 + ECHOE = 0x10 + ECHOK = 0x20 + ECHOKE = 0x800 + ECHONL = 0x40 + ECHOPRT = 0x400 + ENCODING_DEFAULT = 0x0 + ENCODING_FM_MARK = 0x3 + ENCODING_FM_SPACE = 0x4 + ENCODING_MANCHESTER = 0x5 + ENCODING_NRZ = 0x1 + ENCODING_NRZI = 0x2 + EPOLLERR = 0x8 + EPOLLET = 0x80000000 + EPOLLHUP = 0x10 + EPOLLIN = 0x1 + EPOLLMSG = 0x400 + EPOLLONESHOT = 0x40000000 + EPOLLOUT = 0x4 + EPOLLPRI = 0x2 + EPOLLRDBAND = 0x80 + EPOLLRDHUP = 0x2000 + EPOLLRDNORM = 0x40 + EPOLLWAKEUP = 0x20000000 + EPOLLWRBAND = 0x200 + EPOLLWRNORM = 0x100 + EPOLL_CLOEXEC = 0x80000 + EPOLL_CTL_ADD = 0x1 + EPOLL_CTL_DEL = 0x2 + EPOLL_CTL_MOD = 0x3 + ETH_P_1588 = 0x88f7 + ETH_P_8021AD = 0x88a8 + ETH_P_8021AH = 0x88e7 + ETH_P_8021Q = 0x8100 + ETH_P_80221 = 0x8917 + ETH_P_802_2 = 0x4 + ETH_P_802_3 = 0x1 + ETH_P_802_3_MIN = 0x600 + ETH_P_802_EX1 = 0x88b5 + ETH_P_AARP = 0x80f3 + ETH_P_AF_IUCV = 0xfbfb + ETH_P_ALL = 0x3 + ETH_P_AOE = 0x88a2 + ETH_P_ARCNET = 0x1a + ETH_P_ARP = 0x806 + ETH_P_ATALK = 0x809b + ETH_P_ATMFATE = 0x8884 + ETH_P_ATMMPOA = 0x884c + ETH_P_AX25 = 0x2 + ETH_P_BATMAN = 0x4305 + ETH_P_BPQ = 0x8ff + ETH_P_CAIF = 0xf7 + ETH_P_CAN = 0xc + ETH_P_CANFD = 0xd + ETH_P_CONTROL = 0x16 + ETH_P_CUST = 0x6006 + ETH_P_DDCMP = 0x6 + ETH_P_DEC = 0x6000 + ETH_P_DIAG = 0x6005 + ETH_P_DNA_DL = 0x6001 + ETH_P_DNA_RC = 0x6002 + ETH_P_DNA_RT = 0x6003 + ETH_P_DSA = 0x1b + ETH_P_ECONET = 0x18 + ETH_P_EDSA = 0xdada + ETH_P_FCOE = 0x8906 + ETH_P_FIP = 0x8914 + ETH_P_HDLC = 0x19 + ETH_P_IEEE802154 = 0xf6 + ETH_P_IEEEPUP = 0xa00 + ETH_P_IEEEPUPAT = 0xa01 + ETH_P_IP = 0x800 + ETH_P_IPV6 = 0x86dd + ETH_P_IPX = 0x8137 + ETH_P_IRDA = 0x17 + ETH_P_LAT = 0x6004 + ETH_P_LINK_CTL = 0x886c + ETH_P_LOCALTALK = 0x9 + ETH_P_LOOP = 0x60 + ETH_P_LOOPBACK = 0x9000 + ETH_P_MOBITEX = 0x15 + ETH_P_MPLS_MC = 0x8848 + ETH_P_MPLS_UC = 0x8847 + ETH_P_MVRP = 0x88f5 + ETH_P_PAE = 0x888e + ETH_P_PAUSE = 0x8808 + ETH_P_PHONET = 0xf5 + ETH_P_PPPTALK = 0x10 + ETH_P_PPP_DISC = 0x8863 + ETH_P_PPP_MP = 0x8 + ETH_P_PPP_SES = 0x8864 + ETH_P_PRP = 0x88fb + ETH_P_PUP = 0x200 + ETH_P_PUPAT = 0x201 + ETH_P_QINQ1 = 0x9100 + ETH_P_QINQ2 = 0x9200 + ETH_P_QINQ3 = 0x9300 + ETH_P_RARP = 0x8035 + ETH_P_SCA = 0x6007 + ETH_P_SLOW = 0x8809 + ETH_P_SNAP = 0x5 + ETH_P_TDLS = 0x890d + ETH_P_TEB = 0x6558 + ETH_P_TIPC = 0x88ca + ETH_P_TRAILER = 0x1c + ETH_P_TR_802_2 = 0x11 + ETH_P_TSN = 0x22f0 + ETH_P_WAN_PPP = 0x7 + ETH_P_WCCP = 0x883e + ETH_P_X25 = 0x805 + ETH_P_XDSA = 0xf8 + EXTA = 0xe + EXTB = 0xf + EXTPROC = 0x10000 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FF0 = 0x0 + FF1 = 0x8000 + FFDLY = 0x8000 + FLUSHO = 0x1000 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x406 + F_EXLCK = 0x4 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLEASE = 0x401 + F_GETLK = 0x5 + F_GETLK64 = 0x5 + F_GETOWN = 0x9 + F_GETOWN_EX = 0x10 + F_GETPIPE_SZ = 0x408 + F_GETSIG = 0xb + F_LOCK = 0x1 + F_NOTIFY = 0x402 + F_OFD_GETLK = 0x24 + F_OFD_SETLK = 0x25 + F_OFD_SETLKW = 0x26 + F_OK = 0x0 + F_RDLCK = 0x0 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLEASE = 0x400 + F_SETLK = 0x6 + F_SETLK64 = 0x6 + F_SETLKW = 0x7 + F_SETLKW64 = 0x7 + F_SETOWN = 0x8 + F_SETOWN_EX = 0xf + F_SETPIPE_SZ = 0x407 + F_SETSIG = 0xa + F_SHLCK = 0x8 + F_TEST = 0x3 + F_TLOCK = 0x2 + F_ULOCK = 0x0 + F_UNLCK = 0x2 + F_WRLCK = 0x1 + HUPCL = 0x400 + IBSHIFT = 0x10 + ICANON = 0x2 + ICMPV6_FILTER = 0x1 + ICRNL = 0x100 + IEXTEN = 0x8000 + IFA_F_DADFAILED = 0x8 + IFA_F_DEPRECATED = 0x20 + IFA_F_HOMEADDRESS = 0x10 + IFA_F_MANAGETEMPADDR = 0x100 + IFA_F_MCAUTOJOIN = 0x400 + IFA_F_NODAD = 0x2 + IFA_F_NOPREFIXROUTE = 0x200 + IFA_F_OPTIMISTIC = 0x4 + IFA_F_PERMANENT = 0x80 + IFA_F_SECONDARY = 0x1 + IFA_F_STABLE_PRIVACY = 0x800 + IFA_F_TEMPORARY = 0x1 + IFA_F_TENTATIVE = 0x40 + IFA_MAX = 0x8 + IFF_ALLMULTI = 0x200 + IFF_ATTACH_QUEUE = 0x200 + IFF_AUTOMEDIA = 0x4000 + IFF_BROADCAST = 0x2 + IFF_DEBUG = 0x4 + IFF_DETACH_QUEUE = 0x400 + IFF_DORMANT = 0x20000 + IFF_DYNAMIC = 0x8000 + IFF_ECHO = 0x40000 + IFF_LOOPBACK = 0x8 + IFF_LOWER_UP = 0x10000 + IFF_MASTER = 0x400 + IFF_MULTICAST = 0x1000 + IFF_MULTI_QUEUE = 0x100 + IFF_NOARP = 0x80 + IFF_NOFILTER = 0x1000 + IFF_NOTRAILERS = 0x20 + IFF_NO_PI = 0x1000 + IFF_ONE_QUEUE = 0x2000 + IFF_PERSIST = 0x800 + IFF_POINTOPOINT = 0x10 + IFF_PORTSEL = 0x2000 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SLAVE = 0x800 + IFF_TAP = 0x2 + IFF_TUN = 0x1 + IFF_TUN_EXCL = 0x8000 + IFF_UP = 0x1 + IFF_VNET_HDR = 0x4000 + IFF_VOLATILE = 0x70c5a + IFNAMSIZ = 0x10 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_ACCESS = 0x1 + IN_ALL_EVENTS = 0xfff + IN_ATTRIB = 0x4 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLOEXEC = 0x80000 + IN_CLOSE = 0x18 + IN_CLOSE_NOWRITE = 0x10 + IN_CLOSE_WRITE = 0x8 + IN_CREATE = 0x100 + IN_DELETE = 0x200 + IN_DELETE_SELF = 0x400 + IN_DONT_FOLLOW = 0x2000000 + IN_EXCL_UNLINK = 0x4000000 + IN_IGNORED = 0x8000 + IN_ISDIR = 0x40000000 + IN_LOOPBACKNET = 0x7f + IN_MASK_ADD = 0x20000000 + IN_MODIFY = 0x2 + IN_MOVE = 0xc0 + IN_MOVED_FROM = 0x40 + IN_MOVED_TO = 0x80 + IN_MOVE_SELF = 0x800 + IN_NONBLOCK = 0x800 + IN_ONESHOT = 0x80000000 + IN_ONLYDIR = 0x1000000 + IN_OPEN = 0x20 + IN_Q_OVERFLOW = 0x4000 + IN_UNMOUNT = 0x2000 + IPPROTO_AH = 0x33 + IPPROTO_BEETPH = 0x5e + IPPROTO_COMP = 0x6c + IPPROTO_DCCP = 0x21 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_ENCAP = 0x62 + IPPROTO_ESP = 0x32 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GRE = 0x2f + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IGMP = 0x2 + IPPROTO_IP = 0x0 + IPPROTO_IPIP = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_MH = 0x87 + IPPROTO_MPLS = 0x89 + IPPROTO_MTP = 0x5c + IPPROTO_NONE = 0x3b + IPPROTO_PIM = 0x67 + IPPROTO_PUP = 0xc + IPPROTO_RAW = 0xff + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_SCTP = 0x84 + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_UDP = 0x11 + IPPROTO_UDPLITE = 0x88 + IPV6_2292DSTOPTS = 0x4 + IPV6_2292HOPLIMIT = 0x8 + IPV6_2292HOPOPTS = 0x3 + IPV6_2292PKTINFO = 0x2 + IPV6_2292PKTOPTIONS = 0x6 + IPV6_2292RTHDR = 0x5 + IPV6_ADDRFORM = 0x1 + IPV6_ADD_MEMBERSHIP = 0x14 + IPV6_AUTHHDR = 0xa + IPV6_CHECKSUM = 0x7 + IPV6_DONTFRAG = 0x3e + IPV6_DROP_MEMBERSHIP = 0x15 + IPV6_DSTOPTS = 0x3b + IPV6_HOPLIMIT = 0x34 + IPV6_HOPOPTS = 0x36 + IPV6_IPSEC_POLICY = 0x22 + IPV6_JOIN_ANYCAST = 0x1b + IPV6_JOIN_GROUP = 0x14 + IPV6_LEAVE_ANYCAST = 0x1c + IPV6_LEAVE_GROUP = 0x15 + IPV6_MTU = 0x18 + IPV6_MTU_DISCOVER = 0x17 + IPV6_MULTICAST_HOPS = 0x12 + IPV6_MULTICAST_IF = 0x11 + IPV6_MULTICAST_LOOP = 0x13 + IPV6_NEXTHOP = 0x9 + IPV6_PATHMTU = 0x3d + IPV6_PKTINFO = 0x32 + IPV6_PMTUDISC_DO = 0x2 + IPV6_PMTUDISC_DONT = 0x0 + IPV6_PMTUDISC_INTERFACE = 0x4 + IPV6_PMTUDISC_OMIT = 0x5 + IPV6_PMTUDISC_PROBE = 0x3 + IPV6_PMTUDISC_WANT = 0x1 + IPV6_RECVDSTOPTS = 0x3a + IPV6_RECVERR = 0x19 + IPV6_RECVHOPLIMIT = 0x33 + IPV6_RECVHOPOPTS = 0x35 + IPV6_RECVPATHMTU = 0x3c + IPV6_RECVPKTINFO = 0x31 + IPV6_RECVRTHDR = 0x38 + IPV6_RECVTCLASS = 0x42 + IPV6_ROUTER_ALERT = 0x16 + IPV6_RTHDR = 0x39 + IPV6_RTHDRDSTOPTS = 0x37 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_RXDSTOPTS = 0x3b + IPV6_RXHOPOPTS = 0x36 + IPV6_TCLASS = 0x43 + IPV6_UNICAST_HOPS = 0x10 + IPV6_V6ONLY = 0x1a + IPV6_XFRM_POLICY = 0x23 + IP_ADD_MEMBERSHIP = 0x23 + IP_ADD_SOURCE_MEMBERSHIP = 0x27 + IP_BIND_ADDRESS_NO_PORT = 0x18 + IP_BLOCK_SOURCE = 0x26 + IP_CHECKSUM = 0x17 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DROP_MEMBERSHIP = 0x24 + IP_DROP_SOURCE_MEMBERSHIP = 0x28 + IP_FREEBIND = 0xf + IP_HDRINCL = 0x3 + IP_IPSEC_POLICY = 0x10 + IP_MAXPACKET = 0xffff + IP_MAX_MEMBERSHIPS = 0x14 + IP_MF = 0x2000 + IP_MINTTL = 0x15 + IP_MSFILTER = 0x29 + IP_MSS = 0x240 + IP_MTU = 0xe + IP_MTU_DISCOVER = 0xa + IP_MULTICAST_ALL = 0x31 + IP_MULTICAST_IF = 0x20 + IP_MULTICAST_LOOP = 0x22 + IP_MULTICAST_TTL = 0x21 + IP_NODEFRAG = 0x16 + IP_OFFMASK = 0x1fff + IP_OPTIONS = 0x4 + IP_ORIGDSTADDR = 0x14 + IP_PASSSEC = 0x12 + IP_PKTINFO = 0x8 + IP_PKTOPTIONS = 0x9 + IP_PMTUDISC = 0xa + IP_PMTUDISC_DO = 0x2 + IP_PMTUDISC_DONT = 0x0 + IP_PMTUDISC_INTERFACE = 0x4 + IP_PMTUDISC_OMIT = 0x5 + IP_PMTUDISC_PROBE = 0x3 + IP_PMTUDISC_WANT = 0x1 + IP_RECVERR = 0xb + IP_RECVOPTS = 0x6 + IP_RECVORIGDSTADDR = 0x14 + IP_RECVRETOPTS = 0x7 + IP_RECVTOS = 0xd + IP_RECVTTL = 0xc + IP_RETOPTS = 0x7 + IP_RF = 0x8000 + IP_ROUTER_ALERT = 0x5 + IP_TOS = 0x1 + IP_TRANSPARENT = 0x13 + IP_TTL = 0x2 + IP_UNBLOCK_SOURCE = 0x25 + IP_UNICAST_IF = 0x32 + IP_XFRM_POLICY = 0x11 + ISIG = 0x1 + ISTRIP = 0x20 + IUCLC = 0x200 + IUTF8 = 0x4000 + IXANY = 0x800 + IXOFF = 0x1000 + IXON = 0x400 + LINUX_REBOOT_CMD_CAD_OFF = 0x0 + LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef + LINUX_REBOOT_CMD_HALT = 0xcdef0123 + LINUX_REBOOT_CMD_KEXEC = 0x45584543 + LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc + LINUX_REBOOT_CMD_RESTART = 0x1234567 + LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4 + LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2 + LINUX_REBOOT_MAGIC1 = 0xfee1dead + LINUX_REBOOT_MAGIC2 = 0x28121969 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_DODUMP = 0x11 + MADV_DOFORK = 0xb + MADV_DONTDUMP = 0x10 + MADV_DONTFORK = 0xa + MADV_DONTNEED = 0x4 + MADV_HUGEPAGE = 0xe + MADV_HWPOISON = 0x64 + MADV_MERGEABLE = 0xc + MADV_NOHUGEPAGE = 0xf + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_REMOVE = 0x9 + MADV_SEQUENTIAL = 0x2 + MADV_UNMERGEABLE = 0xd + MADV_WILLNEED = 0x3 + MAP_ANON = 0x20 + MAP_ANONYMOUS = 0x20 + MAP_DENYWRITE = 0x800 + MAP_EXECUTABLE = 0x1000 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_GROWSDOWN = 0x100 + MAP_HUGETLB = 0x40000 + MAP_HUGE_MASK = 0x3f + MAP_HUGE_SHIFT = 0x1a + MAP_LOCKED = 0x2000 + MAP_NONBLOCK = 0x10000 + MAP_NORESERVE = 0x4000 + MAP_POPULATE = 0x8000 + MAP_PRIVATE = 0x2 + MAP_SHARED = 0x1 + MAP_STACK = 0x20000 + MAP_TYPE = 0xf + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MCL_ONFAULT = 0x4 + MNT_DETACH = 0x2 + MNT_EXPIRE = 0x4 + MNT_FORCE = 0x1 + MSG_CMSG_CLOEXEC = 0x40000000 + MSG_CONFIRM = 0x800 + MSG_CTRUNC = 0x8 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x40 + MSG_EOR = 0x80 + MSG_ERRQUEUE = 0x2000 + MSG_FASTOPEN = 0x20000000 + MSG_FIN = 0x200 + MSG_MORE = 0x8000 + MSG_NOSIGNAL = 0x4000 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_PROXY = 0x10 + MSG_RST = 0x1000 + MSG_SYN = 0x400 + MSG_TRUNC = 0x20 + MSG_TRYHARD = 0x4 + MSG_WAITALL = 0x100 + MSG_WAITFORONE = 0x10000 + MS_ACTIVE = 0x40000000 + MS_ASYNC = 0x1 + MS_BIND = 0x1000 + MS_DIRSYNC = 0x80 + MS_INVALIDATE = 0x2 + MS_I_VERSION = 0x800000 + MS_KERNMOUNT = 0x400000 + MS_LAZYTIME = 0x2000000 + MS_MANDLOCK = 0x40 + MS_MGC_MSK = 0xffff0000 + MS_MGC_VAL = 0xc0ed0000 + MS_MOVE = 0x2000 + MS_NOATIME = 0x400 + MS_NODEV = 0x4 + MS_NODIRATIME = 0x800 + MS_NOEXEC = 0x8 + MS_NOSUID = 0x2 + MS_NOUSER = -0x80000000 + MS_POSIXACL = 0x10000 + MS_PRIVATE = 0x40000 + MS_RDONLY = 0x1 + MS_REC = 0x4000 + MS_RELATIME = 0x200000 + MS_REMOUNT = 0x20 + MS_RMT_MASK = 0x2800051 + MS_SHARED = 0x100000 + MS_SILENT = 0x8000 + MS_SLAVE = 0x80000 + MS_STRICTATIME = 0x1000000 + MS_SYNC = 0x4 + MS_SYNCHRONOUS = 0x10 + MS_UNBINDABLE = 0x20000 + NAME_MAX = 0xff + NETLINK_ADD_MEMBERSHIP = 0x1 + NETLINK_AUDIT = 0x9 + NETLINK_BROADCAST_ERROR = 0x4 + NETLINK_CAP_ACK = 0xa + NETLINK_CONNECTOR = 0xb + NETLINK_CRYPTO = 0x15 + NETLINK_DNRTMSG = 0xe + NETLINK_DROP_MEMBERSHIP = 0x2 + NETLINK_ECRYPTFS = 0x13 + NETLINK_FIB_LOOKUP = 0xa + NETLINK_FIREWALL = 0x3 + NETLINK_GENERIC = 0x10 + NETLINK_INET_DIAG = 0x4 + NETLINK_IP6_FW = 0xd + NETLINK_ISCSI = 0x8 + NETLINK_KOBJECT_UEVENT = 0xf + NETLINK_LISTEN_ALL_NSID = 0x8 + NETLINK_LIST_MEMBERSHIPS = 0x9 + NETLINK_NETFILTER = 0xc + NETLINK_NFLOG = 0x5 + NETLINK_NO_ENOBUFS = 0x5 + NETLINK_PKTINFO = 0x3 + NETLINK_RDMA = 0x14 + NETLINK_ROUTE = 0x0 + NETLINK_RX_RING = 0x6 + NETLINK_SCSITRANSPORT = 0x12 + NETLINK_SELINUX = 0x7 + NETLINK_SOCK_DIAG = 0x4 + NETLINK_TX_RING = 0x7 + NETLINK_UNUSED = 0x1 + NETLINK_USERSOCK = 0x2 + NETLINK_XFRM = 0x6 + NL0 = 0x0 + NL1 = 0x100 + NLA_ALIGNTO = 0x4 + NLA_F_NESTED = 0x8000 + NLA_F_NET_BYTEORDER = 0x4000 + NLA_HDRLEN = 0x4 + NLDLY = 0x100 + NLMSG_ALIGNTO = 0x4 + NLMSG_DONE = 0x3 + NLMSG_ERROR = 0x2 + NLMSG_HDRLEN = 0x10 + NLMSG_MIN_TYPE = 0x10 + NLMSG_NOOP = 0x1 + NLMSG_OVERRUN = 0x4 + NLM_F_ACK = 0x4 + NLM_F_APPEND = 0x800 + NLM_F_ATOMIC = 0x400 + NLM_F_CREATE = 0x400 + NLM_F_DUMP = 0x300 + NLM_F_DUMP_FILTERED = 0x20 + NLM_F_DUMP_INTR = 0x10 + NLM_F_ECHO = 0x8 + NLM_F_EXCL = 0x200 + NLM_F_MATCH = 0x200 + NLM_F_MULTI = 0x2 + NLM_F_REPLACE = 0x100 + NLM_F_REQUEST = 0x1 + NLM_F_ROOT = 0x100 + NOFLSH = 0x80 + OCRNL = 0x8 + OFDEL = 0x80 + OFILL = 0x40 + OLCUC = 0x2 + ONLCR = 0x4 + ONLRET = 0x20 + ONOCR = 0x10 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_APPEND = 0x400 + O_ASYNC = 0x2000 + O_CLOEXEC = 0x80000 + O_CREAT = 0x40 + O_DIRECT = 0x4000 + O_DIRECTORY = 0x10000 + O_DSYNC = 0x1000 + O_EXCL = 0x80 + O_FSYNC = 0x101000 + O_LARGEFILE = 0x0 + O_NDELAY = 0x800 + O_NOATIME = 0x40000 + O_NOCTTY = 0x100 + O_NOFOLLOW = 0x20000 + O_NONBLOCK = 0x800 + O_PATH = 0x200000 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_RSYNC = 0x101000 + O_SYNC = 0x101000 + O_TMPFILE = 0x410000 + O_TRUNC = 0x200 + O_WRONLY = 0x1 + PACKET_ADD_MEMBERSHIP = 0x1 + PACKET_AUXDATA = 0x8 + PACKET_BROADCAST = 0x1 + PACKET_COPY_THRESH = 0x7 + PACKET_DROP_MEMBERSHIP = 0x2 + PACKET_FANOUT = 0x12 + PACKET_FANOUT_CBPF = 0x6 + PACKET_FANOUT_CPU = 0x2 + PACKET_FANOUT_DATA = 0x16 + PACKET_FANOUT_EBPF = 0x7 + PACKET_FANOUT_FLAG_DEFRAG = 0x8000 + PACKET_FANOUT_FLAG_ROLLOVER = 0x1000 + PACKET_FANOUT_HASH = 0x0 + PACKET_FANOUT_LB = 0x1 + PACKET_FANOUT_QM = 0x5 + PACKET_FANOUT_RND = 0x4 + PACKET_FANOUT_ROLLOVER = 0x3 + PACKET_FASTROUTE = 0x6 + PACKET_HDRLEN = 0xb + PACKET_HOST = 0x0 + PACKET_KERNEL = 0x7 + PACKET_LOOPBACK = 0x5 + PACKET_LOSS = 0xe + PACKET_MR_ALLMULTI = 0x2 + PACKET_MR_MULTICAST = 0x0 + PACKET_MR_PROMISC = 0x1 + PACKET_MR_UNICAST = 0x3 + PACKET_MULTICAST = 0x2 + PACKET_ORIGDEV = 0x9 + PACKET_OTHERHOST = 0x3 + PACKET_OUTGOING = 0x4 + PACKET_QDISC_BYPASS = 0x14 + PACKET_RECV_OUTPUT = 0x3 + PACKET_RESERVE = 0xc + PACKET_ROLLOVER_STATS = 0x15 + PACKET_RX_RING = 0x5 + PACKET_STATISTICS = 0x6 + PACKET_TIMESTAMP = 0x11 + PACKET_TX_HAS_OFF = 0x13 + PACKET_TX_RING = 0xd + PACKET_TX_TIMESTAMP = 0x10 + PACKET_USER = 0x6 + PACKET_VERSION = 0xa + PACKET_VNET_HDR = 0xf + PARENB = 0x100 + PARITY_CRC16_PR0 = 0x2 + PARITY_CRC16_PR0_CCITT = 0x4 + PARITY_CRC16_PR1 = 0x3 + PARITY_CRC16_PR1_CCITT = 0x5 + PARITY_CRC32_PR0_CCITT = 0x6 + PARITY_CRC32_PR1_CCITT = 0x7 + PARITY_DEFAULT = 0x0 + PARITY_NONE = 0x1 + PARMRK = 0x8 + PARODD = 0x200 + PENDIN = 0x4000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_GROWSDOWN = 0x1000000 + PROT_GROWSUP = 0x2000000 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + PR_CAPBSET_DROP = 0x18 + PR_CAPBSET_READ = 0x17 + PR_CAP_AMBIENT = 0x2f + PR_CAP_AMBIENT_CLEAR_ALL = 0x4 + PR_CAP_AMBIENT_IS_SET = 0x1 + PR_CAP_AMBIENT_LOWER = 0x3 + PR_CAP_AMBIENT_RAISE = 0x2 + PR_ENDIAN_BIG = 0x0 + PR_ENDIAN_LITTLE = 0x1 + PR_ENDIAN_PPC_LITTLE = 0x2 + PR_FPEMU_NOPRINT = 0x1 + PR_FPEMU_SIGFPE = 0x2 + PR_FP_EXC_ASYNC = 0x2 + PR_FP_EXC_DISABLED = 0x0 + PR_FP_EXC_DIV = 0x10000 + PR_FP_EXC_INV = 0x100000 + PR_FP_EXC_NONRECOV = 0x1 + PR_FP_EXC_OVF = 0x20000 + PR_FP_EXC_PRECISE = 0x3 + PR_FP_EXC_RES = 0x80000 + PR_FP_EXC_SW_ENABLE = 0x80 + PR_FP_EXC_UND = 0x40000 + PR_FP_MODE_FR = 0x1 + PR_FP_MODE_FRE = 0x2 + PR_GET_CHILD_SUBREAPER = 0x25 + PR_GET_DUMPABLE = 0x3 + PR_GET_ENDIAN = 0x13 + PR_GET_FPEMU = 0x9 + PR_GET_FPEXC = 0xb + PR_GET_FP_MODE = 0x2e + PR_GET_KEEPCAPS = 0x7 + PR_GET_NAME = 0x10 + PR_GET_NO_NEW_PRIVS = 0x27 + PR_GET_PDEATHSIG = 0x2 + PR_GET_SECCOMP = 0x15 + PR_GET_SECUREBITS = 0x1b + PR_GET_THP_DISABLE = 0x2a + PR_GET_TID_ADDRESS = 0x28 + PR_GET_TIMERSLACK = 0x1e + PR_GET_TIMING = 0xd + PR_GET_TSC = 0x19 + PR_GET_UNALIGN = 0x5 + PR_MCE_KILL = 0x21 + PR_MCE_KILL_CLEAR = 0x0 + PR_MCE_KILL_DEFAULT = 0x2 + PR_MCE_KILL_EARLY = 0x1 + PR_MCE_KILL_GET = 0x22 + PR_MCE_KILL_LATE = 0x0 + PR_MCE_KILL_SET = 0x1 + PR_MPX_DISABLE_MANAGEMENT = 0x2c + PR_MPX_ENABLE_MANAGEMENT = 0x2b + PR_SET_CHILD_SUBREAPER = 0x24 + PR_SET_DUMPABLE = 0x4 + PR_SET_ENDIAN = 0x14 + PR_SET_FPEMU = 0xa + PR_SET_FPEXC = 0xc + PR_SET_FP_MODE = 0x2d + PR_SET_KEEPCAPS = 0x8 + PR_SET_MM = 0x23 + PR_SET_MM_ARG_END = 0x9 + PR_SET_MM_ARG_START = 0x8 + PR_SET_MM_AUXV = 0xc + PR_SET_MM_BRK = 0x7 + PR_SET_MM_END_CODE = 0x2 + PR_SET_MM_END_DATA = 0x4 + PR_SET_MM_ENV_END = 0xb + PR_SET_MM_ENV_START = 0xa + PR_SET_MM_EXE_FILE = 0xd + PR_SET_MM_MAP = 0xe + PR_SET_MM_MAP_SIZE = 0xf + PR_SET_MM_START_BRK = 0x6 + PR_SET_MM_START_CODE = 0x1 + PR_SET_MM_START_DATA = 0x3 + PR_SET_MM_START_STACK = 0x5 + PR_SET_NAME = 0xf + PR_SET_NO_NEW_PRIVS = 0x26 + PR_SET_PDEATHSIG = 0x1 + PR_SET_PTRACER = 0x59616d61 + PR_SET_PTRACER_ANY = -0x1 + PR_SET_SECCOMP = 0x16 + PR_SET_SECUREBITS = 0x1c + PR_SET_THP_DISABLE = 0x29 + PR_SET_TIMERSLACK = 0x1d + PR_SET_TIMING = 0xe + PR_SET_TSC = 0x1a + PR_SET_UNALIGN = 0x6 + PR_TASK_PERF_EVENTS_DISABLE = 0x1f + PR_TASK_PERF_EVENTS_ENABLE = 0x20 + PR_TIMING_STATISTICAL = 0x0 + PR_TIMING_TIMESTAMP = 0x1 + PR_TSC_ENABLE = 0x1 + PR_TSC_SIGSEGV = 0x2 + PR_UNALIGN_NOPRINT = 0x1 + PR_UNALIGN_SIGBUS = 0x2 + PTRACE_ATTACH = 0x10 + PTRACE_CONT = 0x7 + PTRACE_DETACH = 0x11 + PTRACE_DISABLE_TE = 0x5010 + PTRACE_ENABLE_TE = 0x5009 + PTRACE_EVENT_CLONE = 0x3 + PTRACE_EVENT_EXEC = 0x4 + PTRACE_EVENT_EXIT = 0x6 + PTRACE_EVENT_FORK = 0x1 + PTRACE_EVENT_SECCOMP = 0x7 + PTRACE_EVENT_STOP = 0x80 + PTRACE_EVENT_VFORK = 0x2 + PTRACE_EVENT_VFORK_DONE = 0x5 + PTRACE_GETEVENTMSG = 0x4201 + PTRACE_GETREGS = 0xc + PTRACE_GETREGSET = 0x4204 + PTRACE_GETSIGINFO = 0x4202 + PTRACE_GETSIGMASK = 0x420a + PTRACE_GET_LAST_BREAK = 0x5006 + PTRACE_INTERRUPT = 0x4207 + PTRACE_KILL = 0x8 + PTRACE_LISTEN = 0x4208 + PTRACE_OLDSETOPTIONS = 0x15 + PTRACE_O_EXITKILL = 0x100000 + PTRACE_O_MASK = 0x3000ff + PTRACE_O_SUSPEND_SECCOMP = 0x200000 + PTRACE_O_TRACECLONE = 0x8 + PTRACE_O_TRACEEXEC = 0x10 + PTRACE_O_TRACEEXIT = 0x40 + PTRACE_O_TRACEFORK = 0x2 + PTRACE_O_TRACESECCOMP = 0x80 + PTRACE_O_TRACESYSGOOD = 0x1 + PTRACE_O_TRACEVFORK = 0x4 + PTRACE_O_TRACEVFORKDONE = 0x20 + PTRACE_PEEKDATA = 0x2 + PTRACE_PEEKDATA_AREA = 0x5003 + PTRACE_PEEKSIGINFO = 0x4209 + PTRACE_PEEKSIGINFO_SHARED = 0x1 + PTRACE_PEEKTEXT = 0x1 + PTRACE_PEEKTEXT_AREA = 0x5002 + PTRACE_PEEKUSR = 0x3 + PTRACE_PEEKUSR_AREA = 0x5000 + PTRACE_PEEK_SYSTEM_CALL = 0x5007 + PTRACE_POKEDATA = 0x5 + PTRACE_POKEDATA_AREA = 0x5005 + PTRACE_POKETEXT = 0x4 + PTRACE_POKETEXT_AREA = 0x5004 + PTRACE_POKEUSR = 0x6 + PTRACE_POKEUSR_AREA = 0x5001 + PTRACE_POKE_SYSTEM_CALL = 0x5008 + PTRACE_PROT = 0x15 + PTRACE_SECCOMP_GET_FILTER = 0x420c + PTRACE_SEIZE = 0x4206 + PTRACE_SETOPTIONS = 0x4200 + PTRACE_SETREGS = 0xd + PTRACE_SETREGSET = 0x4205 + PTRACE_SETSIGINFO = 0x4203 + PTRACE_SETSIGMASK = 0x420b + PTRACE_SINGLEBLOCK = 0xc + PTRACE_SINGLESTEP = 0x9 + PTRACE_SYSCALL = 0x18 + PTRACE_TE_ABORT_RAND = 0x5011 + PTRACE_TRACEME = 0x0 + PT_ACR0 = 0x90 + PT_ACR1 = 0x94 + PT_ACR10 = 0xb8 + PT_ACR11 = 0xbc + PT_ACR12 = 0xc0 + PT_ACR13 = 0xc4 + PT_ACR14 = 0xc8 + PT_ACR15 = 0xcc + PT_ACR2 = 0x98 + PT_ACR3 = 0x9c + PT_ACR4 = 0xa0 + PT_ACR5 = 0xa4 + PT_ACR6 = 0xa8 + PT_ACR7 = 0xac + PT_ACR8 = 0xb0 + PT_ACR9 = 0xb4 + PT_CR_10 = 0x168 + PT_CR_11 = 0x170 + PT_CR_9 = 0x160 + PT_ENDREGS = 0x1af + PT_FPC = 0xd8 + PT_FPR0 = 0xe0 + PT_FPR1 = 0xe8 + PT_FPR10 = 0x130 + PT_FPR11 = 0x138 + PT_FPR12 = 0x140 + PT_FPR13 = 0x148 + PT_FPR14 = 0x150 + PT_FPR15 = 0x158 + PT_FPR2 = 0xf0 + PT_FPR3 = 0xf8 + PT_FPR4 = 0x100 + PT_FPR5 = 0x108 + PT_FPR6 = 0x110 + PT_FPR7 = 0x118 + PT_FPR8 = 0x120 + PT_FPR9 = 0x128 + PT_GPR0 = 0x10 + PT_GPR1 = 0x18 + PT_GPR10 = 0x60 + PT_GPR11 = 0x68 + PT_GPR12 = 0x70 + PT_GPR13 = 0x78 + PT_GPR14 = 0x80 + PT_GPR15 = 0x88 + PT_GPR2 = 0x20 + PT_GPR3 = 0x28 + PT_GPR4 = 0x30 + PT_GPR5 = 0x38 + PT_GPR6 = 0x40 + PT_GPR7 = 0x48 + PT_GPR8 = 0x50 + PT_GPR9 = 0x58 + PT_IEEE_IP = 0x1a8 + PT_LASTOFF = 0x1a8 + PT_ORIGGPR2 = 0xd0 + PT_PSWADDR = 0x8 + PT_PSWMASK = 0x0 + RLIMIT_AS = 0x9 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x7 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = -0x1 + RTAX_ADVMSS = 0x8 + RTAX_CC_ALGO = 0x10 + RTAX_CWND = 0x7 + RTAX_FEATURES = 0xc + RTAX_FEATURE_ALLFRAG = 0x8 + RTAX_FEATURE_ECN = 0x1 + RTAX_FEATURE_MASK = 0xf + RTAX_FEATURE_SACK = 0x2 + RTAX_FEATURE_TIMESTAMP = 0x4 + RTAX_HOPLIMIT = 0xa + RTAX_INITCWND = 0xb + RTAX_INITRWND = 0xe + RTAX_LOCK = 0x1 + RTAX_MAX = 0x10 + RTAX_MTU = 0x2 + RTAX_QUICKACK = 0xf + RTAX_REORDERING = 0x9 + RTAX_RTO_MIN = 0xd + RTAX_RTT = 0x4 + RTAX_RTTVAR = 0x5 + RTAX_SSTHRESH = 0x6 + RTAX_UNSPEC = 0x0 + RTAX_WINDOW = 0x3 + RTA_ALIGNTO = 0x4 + RTA_MAX = 0x16 + RTCF_DIRECTSRC = 0x4000000 + RTCF_DOREDIRECT = 0x1000000 + RTCF_LOG = 0x2000000 + RTCF_MASQ = 0x400000 + RTCF_NAT = 0x800000 + RTCF_VALVE = 0x200000 + RTF_ADDRCLASSMASK = 0xf8000000 + RTF_ADDRCONF = 0x40000 + RTF_ALLONLINK = 0x20000 + RTF_BROADCAST = 0x10000000 + RTF_CACHE = 0x1000000 + RTF_DEFAULT = 0x10000 + RTF_DYNAMIC = 0x10 + RTF_FLOW = 0x2000000 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_INTERFACE = 0x40000000 + RTF_IRTT = 0x100 + RTF_LINKRT = 0x100000 + RTF_LOCAL = 0x80000000 + RTF_MODIFIED = 0x20 + RTF_MSS = 0x40 + RTF_MTU = 0x40 + RTF_MULTICAST = 0x20000000 + RTF_NAT = 0x8000000 + RTF_NOFORWARD = 0x1000 + RTF_NONEXTHOP = 0x200000 + RTF_NOPMTUDISC = 0x4000 + RTF_POLICY = 0x4000000 + RTF_REINSTATE = 0x8 + RTF_REJECT = 0x200 + RTF_STATIC = 0x400 + RTF_THROW = 0x2000 + RTF_UP = 0x1 + RTF_WINDOW = 0x80 + RTF_XRESOLVE = 0x800 + RTM_BASE = 0x10 + RTM_DELACTION = 0x31 + RTM_DELADDR = 0x15 + RTM_DELADDRLABEL = 0x49 + RTM_DELLINK = 0x11 + RTM_DELMDB = 0x55 + RTM_DELNEIGH = 0x1d + RTM_DELNSID = 0x59 + RTM_DELQDISC = 0x25 + RTM_DELROUTE = 0x19 + RTM_DELRULE = 0x21 + RTM_DELTCLASS = 0x29 + RTM_DELTFILTER = 0x2d + RTM_F_CLONED = 0x200 + RTM_F_EQUALIZE = 0x400 + RTM_F_LOOKUP_TABLE = 0x1000 + RTM_F_NOTIFY = 0x100 + RTM_F_PREFIX = 0x800 + RTM_GETACTION = 0x32 + RTM_GETADDR = 0x16 + RTM_GETADDRLABEL = 0x4a + RTM_GETANYCAST = 0x3e + RTM_GETDCB = 0x4e + RTM_GETLINK = 0x12 + RTM_GETMDB = 0x56 + RTM_GETMULTICAST = 0x3a + RTM_GETNEIGH = 0x1e + RTM_GETNEIGHTBL = 0x42 + RTM_GETNETCONF = 0x52 + RTM_GETNSID = 0x5a + RTM_GETQDISC = 0x26 + RTM_GETROUTE = 0x1a + RTM_GETRULE = 0x22 + RTM_GETTCLASS = 0x2a + RTM_GETTFILTER = 0x2e + RTM_MAX = 0x5b + RTM_NEWACTION = 0x30 + RTM_NEWADDR = 0x14 + RTM_NEWADDRLABEL = 0x48 + RTM_NEWLINK = 0x10 + RTM_NEWMDB = 0x54 + RTM_NEWNDUSEROPT = 0x44 + RTM_NEWNEIGH = 0x1c + RTM_NEWNEIGHTBL = 0x40 + RTM_NEWNETCONF = 0x50 + RTM_NEWNSID = 0x58 + RTM_NEWPREFIX = 0x34 + RTM_NEWQDISC = 0x24 + RTM_NEWROUTE = 0x18 + RTM_NEWRULE = 0x20 + RTM_NEWTCLASS = 0x28 + RTM_NEWTFILTER = 0x2c + RTM_NR_FAMILIES = 0x13 + RTM_NR_MSGTYPES = 0x4c + RTM_SETDCB = 0x4f + RTM_SETLINK = 0x13 + RTM_SETNEIGHTBL = 0x43 + RTNH_ALIGNTO = 0x4 + RTNH_COMPARE_MASK = 0x11 + RTNH_F_DEAD = 0x1 + RTNH_F_LINKDOWN = 0x10 + RTNH_F_OFFLOAD = 0x8 + RTNH_F_ONLINK = 0x4 + RTNH_F_PERVASIVE = 0x2 + RTN_MAX = 0xb + RTPROT_BABEL = 0x2a + RTPROT_BIRD = 0xc + RTPROT_BOOT = 0x3 + RTPROT_DHCP = 0x10 + RTPROT_DNROUTED = 0xd + RTPROT_GATED = 0x8 + RTPROT_KERNEL = 0x2 + RTPROT_MROUTED = 0x11 + RTPROT_MRT = 0xa + RTPROT_NTK = 0xf + RTPROT_RA = 0x9 + RTPROT_REDIRECT = 0x1 + RTPROT_STATIC = 0x4 + RTPROT_UNSPEC = 0x0 + RTPROT_XORP = 0xe + RTPROT_ZEBRA = 0xb + RT_CLASS_DEFAULT = 0xfd + RT_CLASS_LOCAL = 0xff + RT_CLASS_MAIN = 0xfe + RT_CLASS_MAX = 0xff + RT_CLASS_UNSPEC = 0x0 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + RUSAGE_THREAD = 0x1 + SCM_CREDENTIALS = 0x2 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x1d + SCM_TIMESTAMPING = 0x25 + SCM_TIMESTAMPNS = 0x23 + SCM_WIFI_STATUS = 0x29 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDDLCI = 0x8980 + SIOCADDMULTI = 0x8931 + SIOCADDRT = 0x890b + SIOCATMARK = 0x8905 + SIOCDARP = 0x8953 + SIOCDELDLCI = 0x8981 + SIOCDELMULTI = 0x8932 + SIOCDELRT = 0x890c + SIOCDEVPRIVATE = 0x89f0 + SIOCDIFADDR = 0x8936 + SIOCDRARP = 0x8960 + SIOCGARP = 0x8954 + SIOCGIFADDR = 0x8915 + SIOCGIFBR = 0x8940 + SIOCGIFBRDADDR = 0x8919 + SIOCGIFCONF = 0x8912 + SIOCGIFCOUNT = 0x8938 + SIOCGIFDSTADDR = 0x8917 + SIOCGIFENCAP = 0x8925 + SIOCGIFFLAGS = 0x8913 + SIOCGIFHWADDR = 0x8927 + SIOCGIFINDEX = 0x8933 + SIOCGIFMAP = 0x8970 + SIOCGIFMEM = 0x891f + SIOCGIFMETRIC = 0x891d + SIOCGIFMTU = 0x8921 + SIOCGIFNAME = 0x8910 + SIOCGIFNETMASK = 0x891b + SIOCGIFPFLAGS = 0x8935 + SIOCGIFSLAVE = 0x8929 + SIOCGIFTXQLEN = 0x8942 + SIOCGPGRP = 0x8904 + SIOCGRARP = 0x8961 + SIOCGSTAMP = 0x8906 + SIOCGSTAMPNS = 0x8907 + SIOCPROTOPRIVATE = 0x89e0 + SIOCRTMSG = 0x890d + SIOCSARP = 0x8955 + SIOCSIFADDR = 0x8916 + SIOCSIFBR = 0x8941 + SIOCSIFBRDADDR = 0x891a + SIOCSIFDSTADDR = 0x8918 + SIOCSIFENCAP = 0x8926 + SIOCSIFFLAGS = 0x8914 + SIOCSIFHWADDR = 0x8924 + SIOCSIFHWBROADCAST = 0x8937 + SIOCSIFLINK = 0x8911 + SIOCSIFMAP = 0x8971 + SIOCSIFMEM = 0x8920 + SIOCSIFMETRIC = 0x891e + SIOCSIFMTU = 0x8922 + SIOCSIFNAME = 0x8923 + SIOCSIFNETMASK = 0x891c + SIOCSIFPFLAGS = 0x8934 + SIOCSIFSLAVE = 0x8930 + SIOCSIFTXQLEN = 0x8943 + SIOCSPGRP = 0x8902 + SIOCSRARP = 0x8962 + SOCK_CLOEXEC = 0x80000 + SOCK_DCCP = 0x6 + SOCK_DGRAM = 0x2 + SOCK_NONBLOCK = 0x800 + SOCK_PACKET = 0xa + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_AAL = 0x109 + SOL_ATM = 0x108 + SOL_DECNET = 0x105 + SOL_ICMPV6 = 0x3a + SOL_IP = 0x0 + SOL_IPV6 = 0x29 + SOL_IRDA = 0x10a + SOL_PACKET = 0x107 + SOL_RAW = 0xff + SOL_SOCKET = 0x1 + SOL_TCP = 0x6 + SOL_X25 = 0x106 + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x1e + SO_ATTACH_BPF = 0x32 + SO_ATTACH_FILTER = 0x1a + SO_BINDTODEVICE = 0x19 + SO_BPF_EXTENSIONS = 0x30 + SO_BROADCAST = 0x6 + SO_BSDCOMPAT = 0xe + SO_BUSY_POLL = 0x2e + SO_DEBUG = 0x1 + SO_DETACH_BPF = 0x1b + SO_DETACH_FILTER = 0x1b + SO_DOMAIN = 0x27 + SO_DONTROUTE = 0x5 + SO_ERROR = 0x4 + SO_GET_FILTER = 0x1a + SO_INCOMING_CPU = 0x31 + SO_KEEPALIVE = 0x9 + SO_LINGER = 0xd + SO_LOCK_FILTER = 0x2c + SO_MARK = 0x24 + SO_MAX_PACING_RATE = 0x2f + SO_NOFCS = 0x2b + SO_NO_CHECK = 0xb + SO_OOBINLINE = 0xa + SO_PASSCRED = 0x10 + SO_PASSSEC = 0x22 + SO_PEEK_OFF = 0x2a + SO_PEERCRED = 0x11 + SO_PEERNAME = 0x1c + SO_PEERSEC = 0x1f + SO_PRIORITY = 0xc + SO_PROTOCOL = 0x26 + SO_RCVBUF = 0x8 + SO_RCVBUFFORCE = 0x21 + SO_RCVLOWAT = 0x12 + SO_RCVTIMEO = 0x14 + SO_REUSEADDR = 0x2 + SO_REUSEPORT = 0xf + SO_RXQ_OVFL = 0x28 + SO_SECURITY_AUTHENTICATION = 0x16 + SO_SECURITY_ENCRYPTION_NETWORK = 0x18 + SO_SECURITY_ENCRYPTION_TRANSPORT = 0x17 + SO_SELECT_ERR_QUEUE = 0x2d + SO_SNDBUF = 0x7 + SO_SNDBUFFORCE = 0x20 + SO_SNDLOWAT = 0x13 + SO_SNDTIMEO = 0x15 + SO_TIMESTAMP = 0x1d + SO_TIMESTAMPING = 0x25 + SO_TIMESTAMPNS = 0x23 + SO_TYPE = 0x3 + SO_WIFI_STATUS = 0x29 + S_BLKSIZE = 0x200 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + TAB0 = 0x0 + TAB1 = 0x800 + TAB2 = 0x1000 + TAB3 = 0x1800 + TABDLY = 0x1800 + TCFLSH = 0x540b + TCGETA = 0x5405 + TCGETS = 0x5401 + TCGETS2 = 0x802c542a + TCGETX = 0x5432 + TCIFLUSH = 0x0 + TCIOFF = 0x2 + TCIOFLUSH = 0x2 + TCION = 0x3 + TCOFLUSH = 0x1 + TCOOFF = 0x0 + TCOON = 0x1 + TCP_CC_INFO = 0x1a + TCP_CONGESTION = 0xd + TCP_COOKIE_IN_ALWAYS = 0x1 + TCP_COOKIE_MAX = 0x10 + TCP_COOKIE_MIN = 0x8 + TCP_COOKIE_OUT_NEVER = 0x2 + TCP_COOKIE_PAIR_SIZE = 0x20 + TCP_COOKIE_TRANSACTIONS = 0xf + TCP_CORK = 0x3 + TCP_DEFER_ACCEPT = 0x9 + TCP_FASTOPEN = 0x17 + TCP_INFO = 0xb + TCP_KEEPCNT = 0x6 + TCP_KEEPIDLE = 0x4 + TCP_KEEPINTVL = 0x5 + TCP_LINGER2 = 0x8 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0xe + TCP_MD5SIG_MAXKEYLEN = 0x50 + TCP_MSS = 0x200 + TCP_MSS_DEFAULT = 0x218 + TCP_MSS_DESIRED = 0x4c4 + TCP_NODELAY = 0x1 + TCP_NOTSENT_LOWAT = 0x19 + TCP_QUEUE_SEQ = 0x15 + TCP_QUICKACK = 0xc + TCP_REPAIR = 0x13 + TCP_REPAIR_OPTIONS = 0x16 + TCP_REPAIR_QUEUE = 0x14 + TCP_SAVED_SYN = 0x1c + TCP_SAVE_SYN = 0x1b + TCP_SYNCNT = 0x7 + TCP_S_DATA_IN = 0x4 + TCP_S_DATA_OUT = 0x8 + TCP_THIN_DUPACK = 0x11 + TCP_THIN_LINEAR_TIMEOUTS = 0x10 + TCP_TIMESTAMP = 0x18 + TCP_USER_TIMEOUT = 0x12 + TCP_WINDOW_CLAMP = 0xa + TCSAFLUSH = 0x2 + TCSBRK = 0x5409 + TCSBRKP = 0x5425 + TCSETA = 0x5406 + TCSETAF = 0x5408 + TCSETAW = 0x5407 + TCSETS = 0x5402 + TCSETS2 = 0x402c542b + TCSETSF = 0x5404 + TCSETSF2 = 0x402c542d + TCSETSW = 0x5403 + TCSETSW2 = 0x402c542c + TCSETX = 0x5433 + TCSETXF = 0x5434 + TCSETXW = 0x5435 + TCXONC = 0x540a + TIOCCBRK = 0x5428 + TIOCCONS = 0x541d + TIOCEXCL = 0x540c + TIOCGDEV = 0x80045432 + TIOCGETD = 0x5424 + TIOCGEXCL = 0x80045440 + TIOCGICOUNT = 0x545d + TIOCGLCKTRMIOS = 0x5456 + TIOCGPGRP = 0x540f + TIOCGPKT = 0x80045438 + TIOCGPTLCK = 0x80045439 + TIOCGPTN = 0x80045430 + TIOCGRS485 = 0x542e + TIOCGSERIAL = 0x541e + TIOCGSID = 0x5429 + TIOCGSOFTCAR = 0x5419 + TIOCGWINSZ = 0x5413 + TIOCINQ = 0x541b + TIOCLINUX = 0x541c + TIOCMBIC = 0x5417 + TIOCMBIS = 0x5416 + TIOCMGET = 0x5415 + TIOCMIWAIT = 0x545c + TIOCMSET = 0x5418 + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x5422 + TIOCNXCL = 0x540d + TIOCOUTQ = 0x5411 + TIOCPKT = 0x5420 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCSBRK = 0x5427 + TIOCSCTTY = 0x540e + TIOCSERCONFIG = 0x5453 + TIOCSERGETLSR = 0x5459 + TIOCSERGETMULTI = 0x545a + TIOCSERGSTRUCT = 0x5458 + TIOCSERGWILD = 0x5454 + TIOCSERSETMULTI = 0x545b + TIOCSERSWILD = 0x5455 + TIOCSER_TEMT = 0x1 + TIOCSETD = 0x5423 + TIOCSIG = 0x40045436 + TIOCSLCKTRMIOS = 0x5457 + TIOCSPGRP = 0x5410 + TIOCSPTLCK = 0x40045431 + TIOCSRS485 = 0x542f + TIOCSSERIAL = 0x541f + TIOCSSOFTCAR = 0x541a + TIOCSTI = 0x5412 + TIOCSWINSZ = 0x5414 + TIOCVHANGUP = 0x5437 + TOSTOP = 0x100 + TUNATTACHFILTER = 0x401054d5 + TUNDETACHFILTER = 0x401054d6 + TUNGETFEATURES = 0x800454cf + TUNGETFILTER = 0x801054db + TUNGETIFF = 0x800454d2 + TUNGETSNDBUF = 0x800454d3 + TUNGETVNETBE = 0x800454df + TUNGETVNETHDRSZ = 0x800454d7 + TUNGETVNETLE = 0x800454dd + TUNSETDEBUG = 0x400454c9 + TUNSETGROUP = 0x400454ce + TUNSETIFF = 0x400454ca + TUNSETIFINDEX = 0x400454da + TUNSETLINK = 0x400454cd + TUNSETNOCSUM = 0x400454c8 + TUNSETOFFLOAD = 0x400454d0 + TUNSETOWNER = 0x400454cc + TUNSETPERSIST = 0x400454cb + TUNSETQUEUE = 0x400454d9 + TUNSETSNDBUF = 0x400454d4 + TUNSETTXFILTER = 0x400454d1 + TUNSETVNETBE = 0x400454de + TUNSETVNETHDRSZ = 0x400454d8 + TUNSETVNETLE = 0x400454dc + VDISCARD = 0xd + VEOF = 0x4 + VEOL = 0xb + VEOL2 = 0x10 + VERASE = 0x2 + VINTR = 0x0 + VKILL = 0x3 + VLNEXT = 0xf + VMIN = 0x6 + VQUIT = 0x1 + VREPRINT = 0xc + VSTART = 0x8 + VSTOP = 0x9 + VSUSP = 0xa + VSWTC = 0x7 + VT0 = 0x0 + VT1 = 0x4000 + VTDLY = 0x4000 + VTIME = 0x5 + VWERASE = 0xe + WALL = 0x40000000 + WCLONE = 0x80000000 + WCONTINUED = 0x8 + WEXITED = 0x4 + WNOHANG = 0x1 + WNOTHREAD = 0x20000000 + WNOWAIT = 0x1000000 + WORDSIZE = 0x40 + WSTOPPED = 0x2 + WUNTRACED = 0x2 + XCASE = 0x4 + XTABS = 0x1800 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x62) + EADDRNOTAVAIL = syscall.Errno(0x63) + EADV = syscall.Errno(0x44) + EAFNOSUPPORT = syscall.Errno(0x61) + EAGAIN = syscall.Errno(0xb) + EALREADY = syscall.Errno(0x72) + EBADE = syscall.Errno(0x34) + EBADF = syscall.Errno(0x9) + EBADFD = syscall.Errno(0x4d) + EBADMSG = syscall.Errno(0x4a) + EBADR = syscall.Errno(0x35) + EBADRQC = syscall.Errno(0x38) + EBADSLT = syscall.Errno(0x39) + EBFONT = syscall.Errno(0x3b) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x7d) + ECHILD = syscall.Errno(0xa) + ECHRNG = syscall.Errno(0x2c) + ECOMM = syscall.Errno(0x46) + ECONNABORTED = syscall.Errno(0x67) + ECONNREFUSED = syscall.Errno(0x6f) + ECONNRESET = syscall.Errno(0x68) + EDEADLK = syscall.Errno(0x23) + EDEADLOCK = syscall.Errno(0x23) + EDESTADDRREQ = syscall.Errno(0x59) + EDOM = syscall.Errno(0x21) + EDOTDOT = syscall.Errno(0x49) + EDQUOT = syscall.Errno(0x7a) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EHOSTDOWN = syscall.Errno(0x70) + EHOSTUNREACH = syscall.Errno(0x71) + EHWPOISON = syscall.Errno(0x85) + EIDRM = syscall.Errno(0x2b) + EILSEQ = syscall.Errno(0x54) + EINPROGRESS = syscall.Errno(0x73) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x6a) + EISDIR = syscall.Errno(0x15) + EISNAM = syscall.Errno(0x78) + EKEYEXPIRED = syscall.Errno(0x7f) + EKEYREJECTED = syscall.Errno(0x81) + EKEYREVOKED = syscall.Errno(0x80) + EL2HLT = syscall.Errno(0x33) + EL2NSYNC = syscall.Errno(0x2d) + EL3HLT = syscall.Errno(0x2e) + EL3RST = syscall.Errno(0x2f) + ELIBACC = syscall.Errno(0x4f) + ELIBBAD = syscall.Errno(0x50) + ELIBEXEC = syscall.Errno(0x53) + ELIBMAX = syscall.Errno(0x52) + ELIBSCN = syscall.Errno(0x51) + ELNRNG = syscall.Errno(0x30) + ELOOP = syscall.Errno(0x28) + EMEDIUMTYPE = syscall.Errno(0x7c) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x5a) + EMULTIHOP = syscall.Errno(0x48) + ENAMETOOLONG = syscall.Errno(0x24) + ENAVAIL = syscall.Errno(0x77) + ENETDOWN = syscall.Errno(0x64) + ENETRESET = syscall.Errno(0x66) + ENETUNREACH = syscall.Errno(0x65) + ENFILE = syscall.Errno(0x17) + ENOANO = syscall.Errno(0x37) + ENOBUFS = syscall.Errno(0x69) + ENOCSI = syscall.Errno(0x32) + ENODATA = syscall.Errno(0x3d) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOKEY = syscall.Errno(0x7e) + ENOLCK = syscall.Errno(0x25) + ENOLINK = syscall.Errno(0x43) + ENOMEDIUM = syscall.Errno(0x7b) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x2a) + ENONET = syscall.Errno(0x40) + ENOPKG = syscall.Errno(0x41) + ENOPROTOOPT = syscall.Errno(0x5c) + ENOSPC = syscall.Errno(0x1c) + ENOSR = syscall.Errno(0x3f) + ENOSTR = syscall.Errno(0x3c) + ENOSYS = syscall.Errno(0x26) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x6b) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x27) + ENOTNAM = syscall.Errno(0x76) + ENOTRECOVERABLE = syscall.Errno(0x83) + ENOTSOCK = syscall.Errno(0x58) + ENOTSUP = syscall.Errno(0x5f) + ENOTTY = syscall.Errno(0x19) + ENOTUNIQ = syscall.Errno(0x4c) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x5f) + EOVERFLOW = syscall.Errno(0x4b) + EOWNERDEAD = syscall.Errno(0x82) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x60) + EPIPE = syscall.Errno(0x20) + EPROTO = syscall.Errno(0x47) + EPROTONOSUPPORT = syscall.Errno(0x5d) + EPROTOTYPE = syscall.Errno(0x5b) + ERANGE = syscall.Errno(0x22) + EREMCHG = syscall.Errno(0x4e) + EREMOTE = syscall.Errno(0x42) + EREMOTEIO = syscall.Errno(0x79) + ERESTART = syscall.Errno(0x55) + ERFKILL = syscall.Errno(0x84) + EROFS = syscall.Errno(0x1e) + ESHUTDOWN = syscall.Errno(0x6c) + ESOCKTNOSUPPORT = syscall.Errno(0x5e) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESRMNT = syscall.Errno(0x45) + ESTALE = syscall.Errno(0x74) + ESTRPIPE = syscall.Errno(0x56) + ETIME = syscall.Errno(0x3e) + ETIMEDOUT = syscall.Errno(0x6e) + ETOOMANYREFS = syscall.Errno(0x6d) + ETXTBSY = syscall.Errno(0x1a) + EUCLEAN = syscall.Errno(0x75) + EUNATCH = syscall.Errno(0x31) + EUSERS = syscall.Errno(0x57) + EWOULDBLOCK = syscall.Errno(0xb) + EXDEV = syscall.Errno(0x12) + EXFULL = syscall.Errno(0x36) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0x7) + SIGCHLD = syscall.Signal(0x11) + SIGCLD = syscall.Signal(0x11) + SIGCONT = syscall.Signal(0x12) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x1d) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPOLL = syscall.Signal(0x1d) + SIGPROF = syscall.Signal(0x1b) + SIGPWR = syscall.Signal(0x1e) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTKFLT = syscall.Signal(0x10) + SIGSTOP = syscall.Signal(0x13) + SIGSYS = syscall.Signal(0x1f) + SIGTERM = syscall.Signal(0xf) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x14) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGUNUSED = syscall.Signal(0x1f) + SIGURG = syscall.Signal(0x17) + SIGUSR1 = syscall.Signal(0xa) + SIGUSR2 = syscall.Signal(0xc) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "no such device or address", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource temporarily unavailable", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device or resource busy", + 17: "file exists", + 18: "invalid cross-device link", + 19: "no such device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "numerical result out of range", + 35: "resource deadlock avoided", + 36: "file name too long", + 37: "no locks available", + 38: "function not implemented", + 39: "directory not empty", + 40: "too many levels of symbolic links", + 42: "no message of desired type", + 43: "identifier removed", + 44: "channel number out of range", + 45: "level 2 not synchronized", + 46: "level 3 halted", + 47: "level 3 reset", + 48: "link number out of range", + 49: "protocol driver not attached", + 50: "no CSI structure available", + 51: "level 2 halted", + 52: "invalid exchange", + 53: "invalid request descriptor", + 54: "exchange full", + 55: "no anode", + 56: "invalid request code", + 57: "invalid slot", + 59: "bad font file format", + 60: "device not a stream", + 61: "no data available", + 62: "timer expired", + 63: "out of streams resources", + 64: "machine is not on the network", + 65: "package not installed", + 66: "object is remote", + 67: "link has been severed", + 68: "advertise error", + 69: "srmount error", + 70: "communication error on send", + 71: "protocol error", + 72: "multihop attempted", + 73: "RFS specific error", + 74: "bad message", + 75: "value too large for defined data type", + 76: "name not unique on network", + 77: "file descriptor in bad state", + 78: "remote address changed", + 79: "can not access a needed shared library", + 80: "accessing a corrupted shared library", + 81: ".lib section in a.out corrupted", + 82: "attempting to link in too many shared libraries", + 83: "cannot exec a shared library directly", + 84: "invalid or incomplete multibyte or wide character", + 85: "interrupted system call should be restarted", + 86: "streams pipe error", + 87: "too many users", + 88: "socket operation on non-socket", + 89: "destination address required", + 90: "message too long", + 91: "protocol wrong type for socket", + 92: "protocol not available", + 93: "protocol not supported", + 94: "socket type not supported", + 95: "operation not supported", + 96: "protocol family not supported", + 97: "address family not supported by protocol", + 98: "address already in use", + 99: "cannot assign requested address", + 100: "network is down", + 101: "network is unreachable", + 102: "network dropped connection on reset", + 103: "software caused connection abort", + 104: "connection reset by peer", + 105: "no buffer space available", + 106: "transport endpoint is already connected", + 107: "transport endpoint is not connected", + 108: "cannot send after transport endpoint shutdown", + 109: "too many references: cannot splice", + 110: "connection timed out", + 111: "connection refused", + 112: "host is down", + 113: "no route to host", + 114: "operation already in progress", + 115: "operation now in progress", + 116: "stale file handle", + 117: "structure needs cleaning", + 118: "not a XENIX named type file", + 119: "no XENIX semaphores available", + 120: "is a named type file", + 121: "remote I/O error", + 122: "disk quota exceeded", + 123: "no medium found", + 124: "wrong medium type", + 125: "operation canceled", + 126: "required key not available", + 127: "key has expired", + 128: "key has been revoked", + 129: "key was rejected by service", + 130: "owner died", + 131: "state not recoverable", + 132: "operation not possible due to RF-kill", + 133: "memory page has hardware error", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/breakpoint trap", + 6: "aborted", + 7: "bus error", + 8: "floating point exception", + 9: "killed", + 10: "user defined signal 1", + 11: "segmentation fault", + 12: "user defined signal 2", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "stack fault", + 17: "child exited", + 18: "continued", + 19: "stopped (signal)", + 20: "stopped", + 21: "stopped (tty input)", + 22: "stopped (tty output)", + 23: "urgent I/O condition", + 24: "CPU time limit exceeded", + 25: "file size limit exceeded", + 26: "virtual timer expired", + 27: "profiling timer expired", + 28: "window changed", + 29: "I/O possible", + 30: "power failure", + 31: "bad system call", +} diff --git a/vendor/golang.org/x/sys/unix/zerrors_netbsd_386.go b/vendor/golang.org/x/sys/unix/zerrors_netbsd_386.go new file mode 100644 index 0000000000..b4338d5f26 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_netbsd_386.go @@ -0,0 +1,1712 @@ +// mkerrors.sh -m32 +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build 386,netbsd + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -m32 _const.go + +package unix + +import "syscall" + +const ( + AF_APPLETALK = 0x10 + AF_ARP = 0x1c + AF_BLUETOOTH = 0x1f + AF_CCITT = 0xa + AF_CHAOS = 0x5 + AF_CNT = 0x15 + AF_COIP = 0x14 + AF_DATAKIT = 0x9 + AF_DECnet = 0xc + AF_DLI = 0xd + AF_E164 = 0x1a + AF_ECMA = 0x8 + AF_HYLINK = 0xf + AF_IEEE80211 = 0x20 + AF_IMPLINK = 0x3 + AF_INET = 0x2 + AF_INET6 = 0x18 + AF_IPX = 0x17 + AF_ISDN = 0x1a + AF_ISO = 0x7 + AF_LAT = 0xe + AF_LINK = 0x12 + AF_LOCAL = 0x1 + AF_MAX = 0x23 + AF_MPLS = 0x21 + AF_NATM = 0x1b + AF_NS = 0x6 + AF_OROUTE = 0x11 + AF_OSI = 0x7 + AF_PUP = 0x4 + AF_ROUTE = 0x22 + AF_SNA = 0xb + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + ARPHRD_ARCNET = 0x7 + ARPHRD_ETHER = 0x1 + ARPHRD_FRELAY = 0xf + ARPHRD_IEEE1394 = 0x18 + ARPHRD_IEEE802 = 0x6 + ARPHRD_STRIP = 0x17 + B0 = 0x0 + B110 = 0x6e + B115200 = 0x1c200 + B1200 = 0x4b0 + B134 = 0x86 + B14400 = 0x3840 + B150 = 0x96 + B1800 = 0x708 + B19200 = 0x4b00 + B200 = 0xc8 + B230400 = 0x38400 + B2400 = 0x960 + B28800 = 0x7080 + B300 = 0x12c + B38400 = 0x9600 + B460800 = 0x70800 + B4800 = 0x12c0 + B50 = 0x32 + B57600 = 0xe100 + B600 = 0x258 + B7200 = 0x1c20 + B75 = 0x4b + B76800 = 0x12c00 + B921600 = 0xe1000 + B9600 = 0x2580 + BIOCFEEDBACK = 0x8004427d + BIOCFLUSH = 0x20004268 + BIOCGBLEN = 0x40044266 + BIOCGDLT = 0x4004426a + BIOCGDLTLIST = 0xc0084277 + BIOCGETIF = 0x4090426b + BIOCGFEEDBACK = 0x4004427c + BIOCGHDRCMPLT = 0x40044274 + BIOCGRTIMEOUT = 0x400c427b + BIOCGSEESENT = 0x40044278 + BIOCGSTATS = 0x4080426f + BIOCGSTATSOLD = 0x4008426f + BIOCIMMEDIATE = 0x80044270 + BIOCPROMISC = 0x20004269 + BIOCSBLEN = 0xc0044266 + BIOCSDLT = 0x80044276 + BIOCSETF = 0x80084267 + BIOCSETIF = 0x8090426c + BIOCSFEEDBACK = 0x8004427d + BIOCSHDRCMPLT = 0x80044275 + BIOCSRTIMEOUT = 0x800c427a + BIOCSSEESENT = 0x80044279 + BIOCSTCPF = 0x80084272 + BIOCSUDPF = 0x80084273 + BIOCVERSION = 0x40044271 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALIGNMENT = 0x4 + BPF_ALIGNMENT32 = 0x4 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DFLTBUFSIZE = 0x100000 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXBUFSIZE = 0x1000000 + BPF_MAXINSNS = 0x200 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINBUFSIZE = 0x20 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RELEASE = 0x30bb6 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BRKINT = 0x2 + CFLUSH = 0xf + CLOCAL = 0x8000 + CLONE_CSIGNAL = 0xff + CLONE_FILES = 0x400 + CLONE_FS = 0x200 + CLONE_PID = 0x1000 + CLONE_PTRACE = 0x2000 + CLONE_SIGHAND = 0x800 + CLONE_VFORK = 0x4000 + CLONE_VM = 0x100 + CREAD = 0x800 + CS5 = 0x0 + CS6 = 0x100 + CS7 = 0x200 + CS8 = 0x300 + CSIZE = 0x300 + CSTART = 0x11 + CSTATUS = 0x14 + CSTOP = 0x13 + CSTOPB = 0x400 + CSUSP = 0x1a + CTL_MAXNAME = 0xc + CTL_NET = 0x4 + CTL_QUERY = -0x2 + DIOCBSFLUSH = 0x20006478 + DLT_A429 = 0xb8 + DLT_A653_ICM = 0xb9 + DLT_AIRONET_HEADER = 0x78 + DLT_AOS = 0xde + DLT_APPLE_IP_OVER_IEEE1394 = 0x8a + DLT_ARCNET = 0x7 + DLT_ARCNET_LINUX = 0x81 + DLT_ATM_CLIP = 0x13 + DLT_ATM_RFC1483 = 0xb + DLT_AURORA = 0x7e + DLT_AX25 = 0x3 + DLT_AX25_KISS = 0xca + DLT_BACNET_MS_TP = 0xa5 + DLT_BLUETOOTH_HCI_H4 = 0xbb + DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9 + DLT_CAN20B = 0xbe + DLT_CAN_SOCKETCAN = 0xe3 + DLT_CHAOS = 0x5 + DLT_CISCO_IOS = 0x76 + DLT_C_HDLC = 0x68 + DLT_C_HDLC_WITH_DIR = 0xcd + DLT_DECT = 0xdd + DLT_DOCSIS = 0x8f + DLT_ECONET = 0x73 + DLT_EN10MB = 0x1 + DLT_EN3MB = 0x2 + DLT_ENC = 0x6d + DLT_ERF = 0xc5 + DLT_ERF_ETH = 0xaf + DLT_ERF_POS = 0xb0 + DLT_FC_2 = 0xe0 + DLT_FC_2_WITH_FRAME_DELIMS = 0xe1 + DLT_FDDI = 0xa + DLT_FLEXRAY = 0xd2 + DLT_FRELAY = 0x6b + DLT_FRELAY_WITH_DIR = 0xce + DLT_GCOM_SERIAL = 0xad + DLT_GCOM_T1E1 = 0xac + DLT_GPF_F = 0xab + DLT_GPF_T = 0xaa + DLT_GPRS_LLC = 0xa9 + DLT_GSMTAP_ABIS = 0xda + DLT_GSMTAP_UM = 0xd9 + DLT_HDLC = 0x10 + DLT_HHDLC = 0x79 + DLT_HIPPI = 0xf + DLT_IBM_SN = 0x92 + DLT_IBM_SP = 0x91 + DLT_IEEE802 = 0x6 + DLT_IEEE802_11 = 0x69 + DLT_IEEE802_11_RADIO = 0x7f + DLT_IEEE802_11_RADIO_AVS = 0xa3 + DLT_IEEE802_15_4 = 0xc3 + DLT_IEEE802_15_4_LINUX = 0xbf + DLT_IEEE802_15_4_NONASK_PHY = 0xd7 + DLT_IEEE802_16_MAC_CPS = 0xbc + DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1 + DLT_IPMB = 0xc7 + DLT_IPMB_LINUX = 0xd1 + DLT_IPNET = 0xe2 + DLT_IPV4 = 0xe4 + DLT_IPV6 = 0xe5 + DLT_IP_OVER_FC = 0x7a + DLT_JUNIPER_ATM1 = 0x89 + DLT_JUNIPER_ATM2 = 0x87 + DLT_JUNIPER_CHDLC = 0xb5 + DLT_JUNIPER_ES = 0x84 + DLT_JUNIPER_ETHER = 0xb2 + DLT_JUNIPER_FRELAY = 0xb4 + DLT_JUNIPER_GGSN = 0x85 + DLT_JUNIPER_ISM = 0xc2 + DLT_JUNIPER_MFR = 0x86 + DLT_JUNIPER_MLFR = 0x83 + DLT_JUNIPER_MLPPP = 0x82 + DLT_JUNIPER_MONITOR = 0xa4 + DLT_JUNIPER_PIC_PEER = 0xae + DLT_JUNIPER_PPP = 0xb3 + DLT_JUNIPER_PPPOE = 0xa7 + DLT_JUNIPER_PPPOE_ATM = 0xa8 + DLT_JUNIPER_SERVICES = 0x88 + DLT_JUNIPER_ST = 0xc8 + DLT_JUNIPER_VP = 0xb7 + DLT_LAPB_WITH_DIR = 0xcf + DLT_LAPD = 0xcb + DLT_LIN = 0xd4 + DLT_LINUX_EVDEV = 0xd8 + DLT_LINUX_IRDA = 0x90 + DLT_LINUX_LAPD = 0xb1 + DLT_LINUX_SLL = 0x71 + DLT_LOOP = 0x6c + DLT_LTALK = 0x72 + DLT_MFR = 0xb6 + DLT_MOST = 0xd3 + DLT_MPLS = 0xdb + DLT_MTP2 = 0x8c + DLT_MTP2_WITH_PHDR = 0x8b + DLT_MTP3 = 0x8d + DLT_NULL = 0x0 + DLT_PCI_EXP = 0x7d + DLT_PFLOG = 0x75 + DLT_PFSYNC = 0x12 + DLT_PPI = 0xc0 + DLT_PPP = 0x9 + DLT_PPP_BSDOS = 0xe + DLT_PPP_ETHER = 0x33 + DLT_PPP_PPPD = 0xa6 + DLT_PPP_SERIAL = 0x32 + DLT_PPP_WITH_DIR = 0xcc + DLT_PRISM_HEADER = 0x77 + DLT_PRONET = 0x4 + DLT_RAIF1 = 0xc6 + DLT_RAW = 0xc + DLT_RAWAF_MASK = 0x2240000 + DLT_RIO = 0x7c + DLT_SCCP = 0x8e + DLT_SITA = 0xc4 + DLT_SLIP = 0x8 + DLT_SLIP_BSDOS = 0xd + DLT_SUNATM = 0x7b + DLT_SYMANTEC_FIREWALL = 0x63 + DLT_TZSP = 0x80 + DLT_USB = 0xba + DLT_USB_LINUX = 0xbd + DLT_USB_LINUX_MMAPPED = 0xdc + DLT_WIHART = 0xdf + DLT_X2E_SERIAL = 0xd5 + DLT_X2E_XORAYA = 0xd6 + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x40 + ECHOE = 0x2 + ECHOK = 0x4 + ECHOKE = 0x1 + ECHONL = 0x10 + ECHOPRT = 0x20 + EMUL_LINUX = 0x1 + EMUL_LINUX32 = 0x5 + EMUL_MAXID = 0x6 + EN_SW_CTL_INF = 0x1000 + EN_SW_CTL_PREC = 0x300 + EN_SW_CTL_ROUND = 0xc00 + EN_SW_DATACHAIN = 0x80 + EN_SW_DENORM = 0x2 + EN_SW_INVOP = 0x1 + EN_SW_OVERFLOW = 0x8 + EN_SW_PRECLOSS = 0x20 + EN_SW_UNDERFLOW = 0x10 + EN_SW_ZERODIV = 0x4 + ETHERCAP_JUMBO_MTU = 0x4 + ETHERCAP_VLAN_HWTAGGING = 0x2 + ETHERCAP_VLAN_MTU = 0x1 + ETHERMIN = 0x2e + ETHERMTU = 0x5dc + ETHERMTU_JUMBO = 0x2328 + ETHERTYPE_8023 = 0x4 + ETHERTYPE_AARP = 0x80f3 + ETHERTYPE_ACCTON = 0x8390 + ETHERTYPE_AEONIC = 0x8036 + ETHERTYPE_ALPHA = 0x814a + ETHERTYPE_AMBER = 0x6008 + ETHERTYPE_AMOEBA = 0x8145 + ETHERTYPE_APOLLO = 0x80f7 + ETHERTYPE_APOLLODOMAIN = 0x8019 + ETHERTYPE_APPLETALK = 0x809b + ETHERTYPE_APPLITEK = 0x80c7 + ETHERTYPE_ARGONAUT = 0x803a + ETHERTYPE_ARP = 0x806 + ETHERTYPE_AT = 0x809b + ETHERTYPE_ATALK = 0x809b + ETHERTYPE_ATOMIC = 0x86df + ETHERTYPE_ATT = 0x8069 + ETHERTYPE_ATTSTANFORD = 0x8008 + ETHERTYPE_AUTOPHON = 0x806a + ETHERTYPE_AXIS = 0x8856 + ETHERTYPE_BCLOOP = 0x9003 + ETHERTYPE_BOFL = 0x8102 + ETHERTYPE_CABLETRON = 0x7034 + ETHERTYPE_CHAOS = 0x804 + ETHERTYPE_COMDESIGN = 0x806c + ETHERTYPE_COMPUGRAPHIC = 0x806d + ETHERTYPE_COUNTERPOINT = 0x8062 + ETHERTYPE_CRONUS = 0x8004 + ETHERTYPE_CRONUSVLN = 0x8003 + ETHERTYPE_DCA = 0x1234 + ETHERTYPE_DDE = 0x807b + ETHERTYPE_DEBNI = 0xaaaa + ETHERTYPE_DECAM = 0x8048 + ETHERTYPE_DECCUST = 0x6006 + ETHERTYPE_DECDIAG = 0x6005 + ETHERTYPE_DECDNS = 0x803c + ETHERTYPE_DECDTS = 0x803e + ETHERTYPE_DECEXPER = 0x6000 + ETHERTYPE_DECLAST = 0x8041 + ETHERTYPE_DECLTM = 0x803f + ETHERTYPE_DECMUMPS = 0x6009 + ETHERTYPE_DECNETBIOS = 0x8040 + ETHERTYPE_DELTACON = 0x86de + ETHERTYPE_DIDDLE = 0x4321 + ETHERTYPE_DLOG1 = 0x660 + ETHERTYPE_DLOG2 = 0x661 + ETHERTYPE_DN = 0x6003 + ETHERTYPE_DOGFIGHT = 0x1989 + ETHERTYPE_DSMD = 0x8039 + ETHERTYPE_ECMA = 0x803 + ETHERTYPE_ENCRYPT = 0x803d + ETHERTYPE_ES = 0x805d + ETHERTYPE_EXCELAN = 0x8010 + ETHERTYPE_EXPERDATA = 0x8049 + ETHERTYPE_FLIP = 0x8146 + ETHERTYPE_FLOWCONTROL = 0x8808 + ETHERTYPE_FRARP = 0x808 + ETHERTYPE_GENDYN = 0x8068 + ETHERTYPE_HAYES = 0x8130 + ETHERTYPE_HIPPI_FP = 0x8180 + ETHERTYPE_HITACHI = 0x8820 + ETHERTYPE_HP = 0x8005 + ETHERTYPE_IEEEPUP = 0xa00 + ETHERTYPE_IEEEPUPAT = 0xa01 + ETHERTYPE_IMLBL = 0x4c42 + ETHERTYPE_IMLBLDIAG = 0x424c + ETHERTYPE_IP = 0x800 + ETHERTYPE_IPAS = 0x876c + ETHERTYPE_IPV6 = 0x86dd + ETHERTYPE_IPX = 0x8137 + ETHERTYPE_IPXNEW = 0x8037 + ETHERTYPE_KALPANA = 0x8582 + ETHERTYPE_LANBRIDGE = 0x8038 + ETHERTYPE_LANPROBE = 0x8888 + ETHERTYPE_LAT = 0x6004 + ETHERTYPE_LBACK = 0x9000 + ETHERTYPE_LITTLE = 0x8060 + ETHERTYPE_LOGICRAFT = 0x8148 + ETHERTYPE_LOOPBACK = 0x9000 + ETHERTYPE_MATRA = 0x807a + ETHERTYPE_MAX = 0xffff + ETHERTYPE_MERIT = 0x807c + ETHERTYPE_MICP = 0x873a + ETHERTYPE_MOPDL = 0x6001 + ETHERTYPE_MOPRC = 0x6002 + ETHERTYPE_MOTOROLA = 0x818d + ETHERTYPE_MPLS = 0x8847 + ETHERTYPE_MPLS_MCAST = 0x8848 + ETHERTYPE_MUMPS = 0x813f + ETHERTYPE_NBPCC = 0x3c04 + ETHERTYPE_NBPCLAIM = 0x3c09 + ETHERTYPE_NBPCLREQ = 0x3c05 + ETHERTYPE_NBPCLRSP = 0x3c06 + ETHERTYPE_NBPCREQ = 0x3c02 + ETHERTYPE_NBPCRSP = 0x3c03 + ETHERTYPE_NBPDG = 0x3c07 + ETHERTYPE_NBPDGB = 0x3c08 + ETHERTYPE_NBPDLTE = 0x3c0a + ETHERTYPE_NBPRAR = 0x3c0c + ETHERTYPE_NBPRAS = 0x3c0b + ETHERTYPE_NBPRST = 0x3c0d + ETHERTYPE_NBPSCD = 0x3c01 + ETHERTYPE_NBPVCD = 0x3c00 + ETHERTYPE_NBS = 0x802 + ETHERTYPE_NCD = 0x8149 + ETHERTYPE_NESTAR = 0x8006 + ETHERTYPE_NETBEUI = 0x8191 + ETHERTYPE_NOVELL = 0x8138 + ETHERTYPE_NS = 0x600 + ETHERTYPE_NSAT = 0x601 + ETHERTYPE_NSCOMPAT = 0x807 + ETHERTYPE_NTRAILER = 0x10 + ETHERTYPE_OS9 = 0x7007 + ETHERTYPE_OS9NET = 0x7009 + ETHERTYPE_PACER = 0x80c6 + ETHERTYPE_PAE = 0x888e + ETHERTYPE_PCS = 0x4242 + ETHERTYPE_PLANNING = 0x8044 + ETHERTYPE_PPP = 0x880b + ETHERTYPE_PPPOE = 0x8864 + ETHERTYPE_PPPOEDISC = 0x8863 + ETHERTYPE_PRIMENTS = 0x7031 + ETHERTYPE_PUP = 0x200 + ETHERTYPE_PUPAT = 0x200 + ETHERTYPE_RACAL = 0x7030 + ETHERTYPE_RATIONAL = 0x8150 + ETHERTYPE_RAWFR = 0x6559 + ETHERTYPE_RCL = 0x1995 + ETHERTYPE_RDP = 0x8739 + ETHERTYPE_RETIX = 0x80f2 + ETHERTYPE_REVARP = 0x8035 + ETHERTYPE_SCA = 0x6007 + ETHERTYPE_SECTRA = 0x86db + ETHERTYPE_SECUREDATA = 0x876d + ETHERTYPE_SGITW = 0x817e + ETHERTYPE_SG_BOUNCE = 0x8016 + ETHERTYPE_SG_DIAG = 0x8013 + ETHERTYPE_SG_NETGAMES = 0x8014 + ETHERTYPE_SG_RESV = 0x8015 + ETHERTYPE_SIMNET = 0x5208 + ETHERTYPE_SLOWPROTOCOLS = 0x8809 + ETHERTYPE_SNA = 0x80d5 + ETHERTYPE_SNMP = 0x814c + ETHERTYPE_SONIX = 0xfaf5 + ETHERTYPE_SPIDER = 0x809f + ETHERTYPE_SPRITE = 0x500 + ETHERTYPE_STP = 0x8181 + ETHERTYPE_TALARIS = 0x812b + ETHERTYPE_TALARISMC = 0x852b + ETHERTYPE_TCPCOMP = 0x876b + ETHERTYPE_TCPSM = 0x9002 + ETHERTYPE_TEC = 0x814f + ETHERTYPE_TIGAN = 0x802f + ETHERTYPE_TRAIL = 0x1000 + ETHERTYPE_TRANSETHER = 0x6558 + ETHERTYPE_TYMSHARE = 0x802e + ETHERTYPE_UBBST = 0x7005 + ETHERTYPE_UBDEBUG = 0x900 + ETHERTYPE_UBDIAGLOOP = 0x7002 + ETHERTYPE_UBDL = 0x7000 + ETHERTYPE_UBNIU = 0x7001 + ETHERTYPE_UBNMC = 0x7003 + ETHERTYPE_VALID = 0x1600 + ETHERTYPE_VARIAN = 0x80dd + ETHERTYPE_VAXELN = 0x803b + ETHERTYPE_VEECO = 0x8067 + ETHERTYPE_VEXP = 0x805b + ETHERTYPE_VGLAB = 0x8131 + ETHERTYPE_VINES = 0xbad + ETHERTYPE_VINESECHO = 0xbaf + ETHERTYPE_VINESLOOP = 0xbae + ETHERTYPE_VITAL = 0xff00 + ETHERTYPE_VLAN = 0x8100 + ETHERTYPE_VLTLMAN = 0x8080 + ETHERTYPE_VPROD = 0x805c + ETHERTYPE_VURESERVED = 0x8147 + ETHERTYPE_WATERLOO = 0x8130 + ETHERTYPE_WELLFLEET = 0x8103 + ETHERTYPE_X25 = 0x805 + ETHERTYPE_X75 = 0x801 + ETHERTYPE_XNSSM = 0x9001 + ETHERTYPE_XTP = 0x817d + ETHER_ADDR_LEN = 0x6 + ETHER_CRC_LEN = 0x4 + ETHER_CRC_POLY_BE = 0x4c11db6 + ETHER_CRC_POLY_LE = 0xedb88320 + ETHER_HDR_LEN = 0xe + ETHER_MAX_LEN = 0x5ee + ETHER_MAX_LEN_JUMBO = 0x233a + ETHER_MIN_LEN = 0x40 + ETHER_PPPOE_ENCAP_LEN = 0x8 + ETHER_TYPE_LEN = 0x2 + ETHER_VLAN_ENCAP_LEN = 0x4 + EVFILT_AIO = 0x2 + EVFILT_PROC = 0x4 + EVFILT_READ = 0x0 + EVFILT_SIGNAL = 0x5 + EVFILT_SYSCOUNT = 0x7 + EVFILT_TIMER = 0x6 + EVFILT_VNODE = 0x3 + EVFILT_WRITE = 0x1 + EV_ADD = 0x1 + EV_CLEAR = 0x20 + EV_DELETE = 0x2 + EV_DISABLE = 0x8 + EV_ENABLE = 0x4 + EV_EOF = 0x8000 + EV_ERROR = 0x4000 + EV_FLAG1 = 0x2000 + EV_ONESHOT = 0x10 + EV_SYSFLAGS = 0xf000 + EXTA = 0x4b00 + EXTB = 0x9600 + EXTPROC = 0x800 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x100 + FLUSHO = 0x800000 + F_CLOSEM = 0xa + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0xc + F_FSCTL = -0x80000000 + F_FSDIRMASK = 0x70000000 + F_FSIN = 0x10000000 + F_FSINOUT = 0x30000000 + F_FSOUT = 0x20000000 + F_FSPRIV = 0x8000 + F_FSVOID = 0x40000000 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLK = 0x7 + F_GETNOSIGPIPE = 0xd + F_GETOWN = 0x5 + F_MAXFD = 0xb + F_OK = 0x0 + F_PARAM_MASK = 0xfff + F_PARAM_MAX = 0xfff + F_RDLCK = 0x1 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLK = 0x8 + F_SETLKW = 0x9 + F_SETNOSIGPIPE = 0xe + F_SETOWN = 0x6 + F_UNLCK = 0x2 + F_WRLCK = 0x3 + HUPCL = 0x4000 + ICANON = 0x100 + ICMP6_FILTER = 0x12 + ICRNL = 0x100 + IEXTEN = 0x400 + IFAN_ARRIVAL = 0x0 + IFAN_DEPARTURE = 0x1 + IFA_ROUTE = 0x1 + IFF_ALLMULTI = 0x200 + IFF_BROADCAST = 0x2 + IFF_CANTCHANGE = 0x8f52 + IFF_DEBUG = 0x4 + IFF_LINK0 = 0x1000 + IFF_LINK1 = 0x2000 + IFF_LINK2 = 0x4000 + IFF_LOOPBACK = 0x8 + IFF_MULTICAST = 0x8000 + IFF_NOARP = 0x80 + IFF_NOTRAILERS = 0x20 + IFF_OACTIVE = 0x400 + IFF_POINTOPOINT = 0x10 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SIMPLEX = 0x800 + IFF_UP = 0x1 + IFNAMSIZ = 0x10 + 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_BRIDGE = 0xd1 + IFT_BSC = 0x53 + IFT_CARP = 0xf8 + 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_DOCSCABLEUPSTREAMCHANNEL = 0xcd + 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_ECONET = 0xce + 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_IEEE1394 = 0x90 + IFT_IEEE80211 = 0x47 + IFT_IEEE80212 = 0x37 + IFT_IEEE8023ADLAG = 0xa1 + IFT_IFGSN = 0x91 + IFT_IMT = 0xbe + IFT_INFINIBAND = 0xc7 + IFT_INTERLEAVE = 0x7c + IFT_IP = 0x7e + IFT_IPFORWARD = 0x8e + IFT_IPOVERATM = 0x72 + IFT_IPOVERCDLC = 0x6d + IFT_IPOVERCLAW = 0x6e + IFT_IPSWITCH = 0x4e + 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_L2VLAN = 0x87 + IFT_L3IPVLAN = 0x88 + IFT_L3IPXVLAN = 0x89 + IFT_LAPB = 0x10 + IFT_LAPD = 0x4d + IFT_LAPF = 0x77 + IFT_LINEGROUP = 0xd2 + 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 = 0xf5 + IFT_PFSYNC = 0xf6 + IFT_PLC = 0xae + IFT_PON155 = 0xcf + IFT_PON622 = 0xd0 + IFT_POS = 0xab + IFT_PPP = 0x17 + IFT_PPPMULTILINKBUNDLE = 0x6c + IFT_PROPATM = 0xc5 + IFT_PROPBWAP2MP = 0xb8 + IFT_PROPCNLS = 0x59 + IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5 + IFT_PROPDOCSWIRELESSMACLAYER = 0xb4 + IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6 + IFT_PROPMUX = 0x36 + IFT_PROPVIRTUAL = 0x35 + IFT_PROPWIRELESSP2P = 0x9d + IFT_PTPSERIAL = 0x16 + IFT_PVC = 0xf1 + IFT_Q2931 = 0xc9 + 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_SIPSIG = 0xcc + IFT_SIPTG = 0xcb + 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_TELINK = 0xc8 + 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_VIRTUALTG = 0xca + IFT_VOICEDID = 0xd5 + IFT_VOICEEM = 0x64 + IFT_VOICEEMFGD = 0xd3 + IFT_VOICEENCAP = 0x67 + IFT_VOICEFGDEANA = 0xd4 + IFT_VOICEFXO = 0x65 + IFT_VOICEFXS = 0x66 + IFT_VOICEOVERATM = 0x98 + IFT_VOICEOVERCABLE = 0xc6 + 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 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLASSD_HOST = 0xfffffff + IN_CLASSD_NET = 0xf0000000 + IN_CLASSD_NSHIFT = 0x1c + IN_LOOPBACKNET = 0x7f + IPPROTO_AH = 0x33 + IPPROTO_CARP = 0x70 + IPPROTO_DONE = 0x101 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_ENCAP = 0x62 + IPPROTO_EON = 0x50 + IPPROTO_ESP = 0x32 + IPPROTO_ETHERIP = 0x61 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GGP = 0x3 + IPPROTO_GRE = 0x2f + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IGMP = 0x2 + IPPROTO_IP = 0x0 + IPPROTO_IPCOMP = 0x6c + IPPROTO_IPIP = 0x4 + IPPROTO_IPV4 = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_IPV6_ICMP = 0x3a + IPPROTO_MAX = 0x100 + IPPROTO_MAXID = 0x34 + IPPROTO_MOBILE = 0x37 + IPPROTO_NONE = 0x3b + IPPROTO_PFSYNC = 0xf0 + IPPROTO_PIM = 0x67 + IPPROTO_PUP = 0xc + IPPROTO_RAW = 0xff + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_UDP = 0x11 + IPPROTO_VRRP = 0x70 + IPV6_CHECKSUM = 0x1a + IPV6_DEFAULT_MULTICAST_HOPS = 0x1 + IPV6_DEFAULT_MULTICAST_LOOP = 0x1 + IPV6_DEFHLIM = 0x40 + IPV6_DONTFRAG = 0x3e + IPV6_DSTOPTS = 0x32 + IPV6_FAITH = 0x1d + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 + IPV6_FRAGTTL = 0x78 + IPV6_HLIMDEC = 0x1 + IPV6_HOPLIMIT = 0x2f + IPV6_HOPOPTS = 0x31 + IPV6_IPSEC_POLICY = 0x1c + IPV6_JOIN_GROUP = 0xc + IPV6_LEAVE_GROUP = 0xd + IPV6_MAXHLIM = 0xff + IPV6_MAXPACKET = 0xffff + IPV6_MMTU = 0x500 + IPV6_MULTICAST_HOPS = 0xa + IPV6_MULTICAST_IF = 0x9 + IPV6_MULTICAST_LOOP = 0xb + IPV6_NEXTHOP = 0x30 + IPV6_PATHMTU = 0x2c + IPV6_PKTINFO = 0x2e + IPV6_PORTRANGE = 0xe + IPV6_PORTRANGE_DEFAULT = 0x0 + IPV6_PORTRANGE_HIGH = 0x1 + IPV6_PORTRANGE_LOW = 0x2 + IPV6_RECVDSTOPTS = 0x28 + IPV6_RECVHOPLIMIT = 0x25 + IPV6_RECVHOPOPTS = 0x27 + IPV6_RECVPATHMTU = 0x2b + IPV6_RECVPKTINFO = 0x24 + IPV6_RECVRTHDR = 0x26 + IPV6_RECVTCLASS = 0x39 + IPV6_RTHDR = 0x33 + IPV6_RTHDRDSTOPTS = 0x23 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_SOCKOPT_RESERVED1 = 0x3 + IPV6_TCLASS = 0x3d + IPV6_UNICAST_HOPS = 0x4 + IPV6_USE_MIN_MTU = 0x2a + IPV6_V6ONLY = 0x1b + IPV6_VERSION = 0x60 + IPV6_VERSION_MASK = 0xf0 + IP_ADD_MEMBERSHIP = 0xc + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DROP_MEMBERSHIP = 0xd + IP_EF = 0x8000 + IP_ERRORMTU = 0x15 + IP_HDRINCL = 0x2 + IP_IPSEC_POLICY = 0x16 + IP_MAXPACKET = 0xffff + IP_MAX_MEMBERSHIPS = 0x14 + IP_MF = 0x2000 + IP_MINFRAGSIZE = 0x45 + IP_MINTTL = 0x18 + IP_MSS = 0x240 + IP_MULTICAST_IF = 0x9 + IP_MULTICAST_LOOP = 0xb + IP_MULTICAST_TTL = 0xa + IP_OFFMASK = 0x1fff + IP_OPTIONS = 0x1 + IP_PORTRANGE = 0x13 + IP_PORTRANGE_DEFAULT = 0x0 + IP_PORTRANGE_HIGH = 0x1 + IP_PORTRANGE_LOW = 0x2 + IP_RECVDSTADDR = 0x7 + IP_RECVIF = 0x14 + IP_RECVOPTS = 0x5 + IP_RECVRETOPTS = 0x6 + IP_RECVTTL = 0x17 + IP_RETOPTS = 0x8 + IP_RF = 0x8000 + IP_TOS = 0x3 + IP_TTL = 0x4 + ISIG = 0x80 + ISTRIP = 0x20 + IXANY = 0x800 + IXOFF = 0x400 + IXON = 0x200 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_DONTNEED = 0x4 + MADV_FREE = 0x6 + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_SEQUENTIAL = 0x2 + MADV_SPACEAVAIL = 0x5 + MADV_WILLNEED = 0x3 + MAP_ALIGNMENT_16MB = 0x18000000 + MAP_ALIGNMENT_1TB = 0x28000000 + MAP_ALIGNMENT_256TB = 0x30000000 + MAP_ALIGNMENT_4GB = 0x20000000 + MAP_ALIGNMENT_64KB = 0x10000000 + MAP_ALIGNMENT_64PB = 0x38000000 + MAP_ALIGNMENT_MASK = -0x1000000 + MAP_ALIGNMENT_SHIFT = 0x18 + MAP_ANON = 0x1000 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_HASSEMAPHORE = 0x200 + MAP_INHERIT = 0x80 + MAP_INHERIT_COPY = 0x1 + MAP_INHERIT_DEFAULT = 0x1 + MAP_INHERIT_DONATE_COPY = 0x3 + MAP_INHERIT_NONE = 0x2 + MAP_INHERIT_SHARE = 0x0 + MAP_NORESERVE = 0x40 + MAP_PRIVATE = 0x2 + MAP_RENAME = 0x20 + MAP_SHARED = 0x1 + MAP_STACK = 0x2000 + MAP_TRYFIXED = 0x400 + MAP_WIRED = 0x800 + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MSG_BCAST = 0x100 + MSG_CMSG_CLOEXEC = 0x800 + MSG_CONTROLMBUF = 0x2000000 + MSG_CTRUNC = 0x20 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x80 + MSG_EOR = 0x8 + MSG_IOVUSRSPACE = 0x4000000 + MSG_LENUSRSPACE = 0x8000000 + MSG_MCAST = 0x200 + MSG_NAMEMBUF = 0x1000000 + MSG_NBIO = 0x1000 + MSG_NOSIGNAL = 0x400 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_TRUNC = 0x10 + MSG_USERFLAGS = 0xffffff + MSG_WAITALL = 0x40 + MS_ASYNC = 0x1 + MS_INVALIDATE = 0x2 + MS_SYNC = 0x4 + NAME_MAX = 0x1ff + NET_RT_DUMP = 0x1 + NET_RT_FLAGS = 0x2 + NET_RT_IFLIST = 0x5 + NET_RT_MAXID = 0x6 + NET_RT_OIFLIST = 0x4 + NET_RT_OOIFLIST = 0x3 + NOFLSH = 0x80000000 + NOTE_ATTRIB = 0x8 + NOTE_CHILD = 0x4 + NOTE_DELETE = 0x1 + NOTE_EXEC = 0x20000000 + NOTE_EXIT = 0x80000000 + NOTE_EXTEND = 0x4 + NOTE_FORK = 0x40000000 + NOTE_LINK = 0x10 + NOTE_LOWAT = 0x1 + NOTE_PCTRLMASK = 0xf0000000 + NOTE_PDATAMASK = 0xfffff + NOTE_RENAME = 0x20 + NOTE_REVOKE = 0x40 + NOTE_TRACK = 0x1 + NOTE_TRACKERR = 0x2 + NOTE_WRITE = 0x2 + OCRNL = 0x10 + OFIOGETBMAP = 0xc004667a + ONLCR = 0x2 + ONLRET = 0x40 + ONOCR = 0x20 + ONOEOT = 0x8 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_ALT_IO = 0x40000 + O_APPEND = 0x8 + O_ASYNC = 0x40 + O_CLOEXEC = 0x400000 + O_CREAT = 0x200 + O_DIRECT = 0x80000 + O_DIRECTORY = 0x200000 + O_DSYNC = 0x10000 + O_EXCL = 0x800 + O_EXLOCK = 0x20 + O_FSYNC = 0x80 + O_NDELAY = 0x4 + O_NOCTTY = 0x8000 + O_NOFOLLOW = 0x100 + O_NONBLOCK = 0x4 + O_NOSIGPIPE = 0x1000000 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_RSYNC = 0x20000 + O_SHLOCK = 0x10 + O_SYNC = 0x80 + O_TRUNC = 0x400 + O_WRONLY = 0x1 + PARENB = 0x1000 + PARMRK = 0x8 + PARODD = 0x2000 + PENDIN = 0x20000000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PRI_IOFLUSH = 0x7c + PROT_EXEC = 0x4 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + RLIMIT_AS = 0xa + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x8 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = 0x7fffffffffffffff + RTAX_AUTHOR = 0x6 + RTAX_BRD = 0x7 + RTAX_DST = 0x0 + RTAX_GATEWAY = 0x1 + RTAX_GENMASK = 0x3 + RTAX_IFA = 0x5 + RTAX_IFP = 0x4 + RTAX_MAX = 0x9 + RTAX_NETMASK = 0x2 + RTAX_TAG = 0x8 + RTA_AUTHOR = 0x40 + RTA_BRD = 0x80 + RTA_DST = 0x1 + RTA_GATEWAY = 0x2 + RTA_GENMASK = 0x8 + RTA_IFA = 0x20 + RTA_IFP = 0x10 + RTA_NETMASK = 0x4 + RTA_TAG = 0x100 + RTF_ANNOUNCE = 0x20000 + RTF_BLACKHOLE = 0x1000 + RTF_CLONED = 0x2000 + RTF_CLONING = 0x100 + RTF_DONE = 0x40 + RTF_DYNAMIC = 0x10 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_LLINFO = 0x400 + RTF_MASK = 0x80 + RTF_MODIFIED = 0x20 + RTF_PROTO1 = 0x8000 + RTF_PROTO2 = 0x4000 + RTF_REJECT = 0x8 + RTF_SRC = 0x10000 + RTF_STATIC = 0x800 + RTF_UP = 0x1 + RTF_XRESOLVE = 0x200 + RTM_ADD = 0x1 + RTM_CHANGE = 0x3 + RTM_CHGADDR = 0x15 + RTM_DELADDR = 0xd + RTM_DELETE = 0x2 + RTM_GET = 0x4 + RTM_IEEE80211 = 0x11 + RTM_IFANNOUNCE = 0x10 + RTM_IFINFO = 0x14 + RTM_LLINFO_UPD = 0x13 + RTM_LOCK = 0x8 + RTM_LOSING = 0x5 + RTM_MISS = 0x7 + RTM_NEWADDR = 0xc + RTM_OIFINFO = 0xf + RTM_OLDADD = 0x9 + RTM_OLDDEL = 0xa + RTM_OOIFINFO = 0xe + RTM_REDIRECT = 0x6 + RTM_RESOLVE = 0xb + RTM_RTTUNIT = 0xf4240 + RTM_SETGATE = 0x12 + RTM_VERSION = 0x4 + RTV_EXPIRE = 0x4 + RTV_HOPCOUNT = 0x2 + RTV_MTU = 0x1 + RTV_RPIPE = 0x8 + RTV_RTT = 0x40 + RTV_RTTVAR = 0x80 + RTV_SPIPE = 0x10 + RTV_SSTHRESH = 0x20 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + SCM_CREDS = 0x4 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x8 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDMULTI = 0x80906931 + SIOCADDRT = 0x8030720a + SIOCAIFADDR = 0x8040691a + SIOCALIFADDR = 0x8118691c + SIOCATMARK = 0x40047307 + SIOCDELMULTI = 0x80906932 + SIOCDELRT = 0x8030720b + SIOCDIFADDR = 0x80906919 + SIOCDIFPHYADDR = 0x80906949 + SIOCDLIFADDR = 0x8118691e + SIOCGDRVSPEC = 0xc01c697b + SIOCGETPFSYNC = 0xc09069f8 + SIOCGETSGCNT = 0xc0147534 + SIOCGETVIFCNT = 0xc0147533 + SIOCGHIWAT = 0x40047301 + SIOCGIFADDR = 0xc0906921 + SIOCGIFADDRPREF = 0xc0946920 + SIOCGIFALIAS = 0xc040691b + SIOCGIFBRDADDR = 0xc0906923 + SIOCGIFCAP = 0xc0206976 + SIOCGIFCONF = 0xc0086926 + SIOCGIFDATA = 0xc0946985 + SIOCGIFDLT = 0xc0906977 + SIOCGIFDSTADDR = 0xc0906922 + SIOCGIFFLAGS = 0xc0906911 + SIOCGIFGENERIC = 0xc090693a + SIOCGIFMEDIA = 0xc0286936 + SIOCGIFMETRIC = 0xc0906917 + SIOCGIFMTU = 0xc090697e + SIOCGIFNETMASK = 0xc0906925 + SIOCGIFPDSTADDR = 0xc0906948 + SIOCGIFPSRCADDR = 0xc0906947 + SIOCGLIFADDR = 0xc118691d + SIOCGLIFPHYADDR = 0xc118694b + SIOCGLINKSTR = 0xc01c6987 + SIOCGLOWAT = 0x40047303 + SIOCGPGRP = 0x40047309 + SIOCGVH = 0xc0906983 + SIOCIFCREATE = 0x8090697a + SIOCIFDESTROY = 0x80906979 + SIOCIFGCLONERS = 0xc00c6978 + SIOCINITIFADDR = 0xc0446984 + SIOCSDRVSPEC = 0x801c697b + SIOCSETPFSYNC = 0x809069f7 + SIOCSHIWAT = 0x80047300 + SIOCSIFADDR = 0x8090690c + SIOCSIFADDRPREF = 0x8094691f + SIOCSIFBRDADDR = 0x80906913 + SIOCSIFCAP = 0x80206975 + SIOCSIFDSTADDR = 0x8090690e + SIOCSIFFLAGS = 0x80906910 + SIOCSIFGENERIC = 0x80906939 + SIOCSIFMEDIA = 0xc0906935 + SIOCSIFMETRIC = 0x80906918 + SIOCSIFMTU = 0x8090697f + SIOCSIFNETMASK = 0x80906916 + SIOCSIFPHYADDR = 0x80406946 + SIOCSLIFPHYADDR = 0x8118694a + SIOCSLINKSTR = 0x801c6988 + SIOCSLOWAT = 0x80047302 + SIOCSPGRP = 0x80047308 + SIOCSVH = 0xc0906982 + SIOCZIFDATA = 0xc0946986 + SOCK_CLOEXEC = 0x10000000 + SOCK_DGRAM = 0x2 + SOCK_FLAGS_MASK = 0xf0000000 + SOCK_NONBLOCK = 0x20000000 + SOCK_NOSIGPIPE = 0x40000000 + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_SOCKET = 0xffff + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x2 + SO_ACCEPTFILTER = 0x1000 + SO_BROADCAST = 0x20 + SO_DEBUG = 0x1 + SO_DONTROUTE = 0x10 + SO_ERROR = 0x1007 + SO_KEEPALIVE = 0x8 + SO_LINGER = 0x80 + SO_NOHEADER = 0x100a + SO_NOSIGPIPE = 0x800 + SO_OOBINLINE = 0x100 + SO_OVERFLOWED = 0x1009 + SO_RCVBUF = 0x1002 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x100c + SO_REUSEADDR = 0x4 + SO_REUSEPORT = 0x200 + SO_SNDBUF = 0x1001 + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x100b + SO_TIMESTAMP = 0x2000 + SO_TYPE = 0x1008 + SO_USELOOPBACK = 0x40 + SYSCTL_VERSION = 0x1000000 + SYSCTL_VERS_0 = 0x0 + SYSCTL_VERS_1 = 0x1000000 + SYSCTL_VERS_MASK = 0xff000000 + S_ARCH1 = 0x10000 + S_ARCH2 = 0x20000 + S_BLKSIZE = 0x200 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IFWHT = 0xe000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISTXT = 0x200 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + S_LOGIN_SET = 0x1 + TCIFLUSH = 0x1 + TCIOFLUSH = 0x3 + TCOFLUSH = 0x2 + TCP_CONGCTL = 0x20 + TCP_KEEPCNT = 0x6 + TCP_KEEPIDLE = 0x3 + TCP_KEEPINIT = 0x7 + TCP_KEEPINTVL = 0x5 + TCP_MAXBURST = 0x4 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0x10 + TCP_MINMSS = 0xd8 + TCP_MSS = 0x218 + TCP_NODELAY = 0x1 + TCSAFLUSH = 0x2 + TIOCCBRK = 0x2000747a + TIOCCDTR = 0x20007478 + TIOCCONS = 0x80047462 + TIOCDCDTIMESTAMP = 0x400c7458 + TIOCDRAIN = 0x2000745e + TIOCEXCL = 0x2000740d + TIOCEXT = 0x80047460 + TIOCFLAG_CDTRCTS = 0x10 + TIOCFLAG_CLOCAL = 0x2 + TIOCFLAG_CRTSCTS = 0x4 + TIOCFLAG_MDMBUF = 0x8 + TIOCFLAG_SOFTCAR = 0x1 + TIOCFLUSH = 0x80047410 + TIOCGETA = 0x402c7413 + TIOCGETD = 0x4004741a + TIOCGFLAGS = 0x4004745d + TIOCGLINED = 0x40207442 + TIOCGPGRP = 0x40047477 + TIOCGQSIZE = 0x40047481 + TIOCGRANTPT = 0x20007447 + TIOCGSID = 0x40047463 + TIOCGSIZE = 0x40087468 + TIOCGWINSZ = 0x40087468 + TIOCMBIC = 0x8004746b + TIOCMBIS = 0x8004746c + TIOCMGET = 0x4004746a + TIOCMSET = 0x8004746d + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x20007471 + TIOCNXCL = 0x2000740e + TIOCOUTQ = 0x40047473 + TIOCPKT = 0x80047470 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCPTMGET = 0x40287446 + TIOCPTSNAME = 0x40287448 + TIOCRCVFRAME = 0x80047445 + TIOCREMOTE = 0x80047469 + TIOCSBRK = 0x2000747b + TIOCSCTTY = 0x20007461 + TIOCSDTR = 0x20007479 + TIOCSETA = 0x802c7414 + TIOCSETAF = 0x802c7416 + TIOCSETAW = 0x802c7415 + TIOCSETD = 0x8004741b + TIOCSFLAGS = 0x8004745c + TIOCSIG = 0x2000745f + TIOCSLINED = 0x80207443 + TIOCSPGRP = 0x80047476 + TIOCSQSIZE = 0x80047480 + TIOCSSIZE = 0x80087467 + TIOCSTART = 0x2000746e + TIOCSTAT = 0x80047465 + TIOCSTI = 0x80017472 + TIOCSTOP = 0x2000746f + TIOCSWINSZ = 0x80087467 + TIOCUCNTL = 0x80047466 + TIOCXMTFRAME = 0x80047444 + TOSTOP = 0x400000 + VDISCARD = 0xf + VDSUSP = 0xb + VEOF = 0x0 + VEOL = 0x1 + VEOL2 = 0x2 + VERASE = 0x3 + VINTR = 0x8 + VKILL = 0x5 + VLNEXT = 0xe + VMIN = 0x10 + VQUIT = 0x9 + VREPRINT = 0x6 + VSTART = 0xc + VSTATUS = 0x12 + VSTOP = 0xd + VSUSP = 0xa + VTIME = 0x11 + VWERASE = 0x4 + WALL = 0x8 + WALLSIG = 0x8 + WALTSIG = 0x4 + WCLONE = 0x4 + WCOREFLAG = 0x80 + WNOHANG = 0x1 + WNOWAIT = 0x10000 + WNOZOMBIE = 0x20000 + WOPTSCHECKED = 0x40000 + WSTOPPED = 0x7f + WUNTRACED = 0x2 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x30) + EADDRNOTAVAIL = syscall.Errno(0x31) + EAFNOSUPPORT = syscall.Errno(0x2f) + EAGAIN = syscall.Errno(0x23) + EALREADY = syscall.Errno(0x25) + EAUTH = syscall.Errno(0x50) + EBADF = syscall.Errno(0x9) + EBADMSG = syscall.Errno(0x58) + EBADRPC = syscall.Errno(0x48) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x57) + ECHILD = syscall.Errno(0xa) + ECONNABORTED = syscall.Errno(0x35) + ECONNREFUSED = syscall.Errno(0x3d) + ECONNRESET = syscall.Errno(0x36) + EDEADLK = syscall.Errno(0xb) + EDESTADDRREQ = syscall.Errno(0x27) + EDOM = syscall.Errno(0x21) + EDQUOT = syscall.Errno(0x45) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EFTYPE = syscall.Errno(0x4f) + EHOSTDOWN = syscall.Errno(0x40) + EHOSTUNREACH = syscall.Errno(0x41) + EIDRM = syscall.Errno(0x52) + EILSEQ = syscall.Errno(0x55) + EINPROGRESS = syscall.Errno(0x24) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x38) + EISDIR = syscall.Errno(0x15) + ELAST = syscall.Errno(0x60) + ELOOP = syscall.Errno(0x3e) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x28) + EMULTIHOP = syscall.Errno(0x5e) + ENAMETOOLONG = syscall.Errno(0x3f) + ENEEDAUTH = syscall.Errno(0x51) + ENETDOWN = syscall.Errno(0x32) + ENETRESET = syscall.Errno(0x34) + ENETUNREACH = syscall.Errno(0x33) + ENFILE = syscall.Errno(0x17) + ENOATTR = syscall.Errno(0x5d) + ENOBUFS = syscall.Errno(0x37) + ENODATA = syscall.Errno(0x59) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOLCK = syscall.Errno(0x4d) + ENOLINK = syscall.Errno(0x5f) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x53) + ENOPROTOOPT = syscall.Errno(0x2a) + ENOSPC = syscall.Errno(0x1c) + ENOSR = syscall.Errno(0x5a) + ENOSTR = syscall.Errno(0x5b) + ENOSYS = syscall.Errno(0x4e) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x39) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x42) + ENOTSOCK = syscall.Errno(0x26) + ENOTSUP = syscall.Errno(0x56) + ENOTTY = syscall.Errno(0x19) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x2d) + EOVERFLOW = syscall.Errno(0x54) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x2e) + EPIPE = syscall.Errno(0x20) + EPROCLIM = syscall.Errno(0x43) + EPROCUNAVAIL = syscall.Errno(0x4c) + EPROGMISMATCH = syscall.Errno(0x4b) + EPROGUNAVAIL = syscall.Errno(0x4a) + EPROTO = syscall.Errno(0x60) + EPROTONOSUPPORT = syscall.Errno(0x2b) + EPROTOTYPE = syscall.Errno(0x29) + ERANGE = syscall.Errno(0x22) + EREMOTE = syscall.Errno(0x47) + EROFS = syscall.Errno(0x1e) + ERPCMISMATCH = syscall.Errno(0x49) + ESHUTDOWN = syscall.Errno(0x3a) + ESOCKTNOSUPPORT = syscall.Errno(0x2c) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESTALE = syscall.Errno(0x46) + ETIME = syscall.Errno(0x5c) + ETIMEDOUT = syscall.Errno(0x3c) + ETOOMANYREFS = syscall.Errno(0x3b) + ETXTBSY = syscall.Errno(0x1a) + EUSERS = syscall.Errno(0x44) + EWOULDBLOCK = syscall.Errno(0x23) + EXDEV = syscall.Errno(0x12) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0xa) + SIGCHLD = syscall.Signal(0x14) + SIGCONT = syscall.Signal(0x13) + SIGEMT = syscall.Signal(0x7) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINFO = syscall.Signal(0x1d) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x17) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPROF = syscall.Signal(0x1b) + SIGPWR = syscall.Signal(0x20) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTOP = syscall.Signal(0x11) + SIGSYS = syscall.Signal(0xc) + SIGTERM = syscall.Signal(0xf) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x12) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGURG = syscall.Signal(0x10) + SIGUSR1 = syscall.Signal(0x1e) + SIGUSR2 = syscall.Signal(0x1f) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "device not configured", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource deadlock avoided", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device busy", + 17: "file exists", + 18: "cross-device link", + 19: "operation not supported by device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "result too large or too small", + 35: "resource temporarily unavailable", + 36: "operation now in progress", + 37: "operation already in progress", + 38: "socket operation on non-socket", + 39: "destination address required", + 40: "message too long", + 41: "protocol wrong type for socket", + 42: "protocol option not available", + 43: "protocol not supported", + 44: "socket type not supported", + 45: "operation not supported", + 46: "protocol family not supported", + 47: "address family not supported by protocol family", + 48: "address already in use", + 49: "can't assign requested address", + 50: "network is down", + 51: "network is unreachable", + 52: "network dropped connection on reset", + 53: "software caused connection abort", + 54: "connection reset by peer", + 55: "no buffer space available", + 56: "socket is already connected", + 57: "socket is not connected", + 58: "can't send after socket shutdown", + 59: "too many references: can't splice", + 60: "connection timed out", + 61: "connection refused", + 62: "too many levels of symbolic links", + 63: "file name too long", + 64: "host is down", + 65: "no route to host", + 66: "directory not empty", + 67: "too many processes", + 68: "too many users", + 69: "disc quota exceeded", + 70: "stale NFS file handle", + 71: "too many levels of remote in path", + 72: "RPC struct is bad", + 73: "RPC version wrong", + 74: "RPC prog. not avail", + 75: "program version wrong", + 76: "bad procedure for program", + 77: "no locks available", + 78: "function not implemented", + 79: "inappropriate file type or format", + 80: "authentication error", + 81: "need authenticator", + 82: "identifier removed", + 83: "no message of desired type", + 84: "value too large to be stored in data type", + 85: "illegal byte sequence", + 86: "not supported", + 87: "operation Canceled", + 88: "bad or Corrupt message", + 89: "no message available", + 90: "no STREAM resources", + 91: "not a STREAM", + 92: "STREAM ioctl timeout", + 93: "attribute not found", + 94: "multihop attempted", + 95: "link has been severed", + 96: "protocol error", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/BPT trap", + 6: "abort trap", + 7: "EMT trap", + 8: "floating point exception", + 9: "killed", + 10: "bus error", + 11: "segmentation fault", + 12: "bad system call", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "urgent I/O condition", + 17: "stopped (signal)", + 18: "stopped", + 19: "continued", + 20: "child exited", + 21: "stopped (tty input)", + 22: "stopped (tty output)", + 23: "I/O possible", + 24: "cputime limit exceeded", + 25: "filesize limit exceeded", + 26: "virtual timer expired", + 27: "profiling timer expired", + 28: "window size changes", + 29: "information request", + 30: "user defined signal 1", + 31: "user defined signal 2", + 32: "power fail/restart", +} diff --git a/vendor/golang.org/x/sys/unix/zerrors_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_netbsd_amd64.go new file mode 100644 index 0000000000..4994437b63 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_netbsd_amd64.go @@ -0,0 +1,1702 @@ +// mkerrors.sh -m64 +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build amd64,netbsd + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -m64 _const.go + +package unix + +import "syscall" + +const ( + AF_APPLETALK = 0x10 + AF_ARP = 0x1c + AF_BLUETOOTH = 0x1f + AF_CCITT = 0xa + AF_CHAOS = 0x5 + AF_CNT = 0x15 + AF_COIP = 0x14 + AF_DATAKIT = 0x9 + AF_DECnet = 0xc + AF_DLI = 0xd + AF_E164 = 0x1a + AF_ECMA = 0x8 + AF_HYLINK = 0xf + AF_IEEE80211 = 0x20 + AF_IMPLINK = 0x3 + AF_INET = 0x2 + AF_INET6 = 0x18 + AF_IPX = 0x17 + AF_ISDN = 0x1a + AF_ISO = 0x7 + AF_LAT = 0xe + AF_LINK = 0x12 + AF_LOCAL = 0x1 + AF_MAX = 0x23 + AF_MPLS = 0x21 + AF_NATM = 0x1b + AF_NS = 0x6 + AF_OROUTE = 0x11 + AF_OSI = 0x7 + AF_PUP = 0x4 + AF_ROUTE = 0x22 + AF_SNA = 0xb + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + ARPHRD_ARCNET = 0x7 + ARPHRD_ETHER = 0x1 + ARPHRD_FRELAY = 0xf + ARPHRD_IEEE1394 = 0x18 + ARPHRD_IEEE802 = 0x6 + ARPHRD_STRIP = 0x17 + B0 = 0x0 + B110 = 0x6e + B115200 = 0x1c200 + B1200 = 0x4b0 + B134 = 0x86 + B14400 = 0x3840 + B150 = 0x96 + B1800 = 0x708 + B19200 = 0x4b00 + B200 = 0xc8 + B230400 = 0x38400 + B2400 = 0x960 + B28800 = 0x7080 + B300 = 0x12c + B38400 = 0x9600 + B460800 = 0x70800 + B4800 = 0x12c0 + B50 = 0x32 + B57600 = 0xe100 + B600 = 0x258 + B7200 = 0x1c20 + B75 = 0x4b + B76800 = 0x12c00 + B921600 = 0xe1000 + B9600 = 0x2580 + BIOCFEEDBACK = 0x8004427d + BIOCFLUSH = 0x20004268 + BIOCGBLEN = 0x40044266 + BIOCGDLT = 0x4004426a + BIOCGDLTLIST = 0xc0104277 + BIOCGETIF = 0x4090426b + BIOCGFEEDBACK = 0x4004427c + BIOCGHDRCMPLT = 0x40044274 + BIOCGRTIMEOUT = 0x4010427b + BIOCGSEESENT = 0x40044278 + BIOCGSTATS = 0x4080426f + BIOCGSTATSOLD = 0x4008426f + BIOCIMMEDIATE = 0x80044270 + BIOCPROMISC = 0x20004269 + BIOCSBLEN = 0xc0044266 + BIOCSDLT = 0x80044276 + BIOCSETF = 0x80104267 + BIOCSETIF = 0x8090426c + BIOCSFEEDBACK = 0x8004427d + BIOCSHDRCMPLT = 0x80044275 + BIOCSRTIMEOUT = 0x8010427a + BIOCSSEESENT = 0x80044279 + BIOCSTCPF = 0x80104272 + BIOCSUDPF = 0x80104273 + BIOCVERSION = 0x40044271 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALIGNMENT = 0x8 + BPF_ALIGNMENT32 = 0x4 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DFLTBUFSIZE = 0x100000 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXBUFSIZE = 0x1000000 + BPF_MAXINSNS = 0x200 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINBUFSIZE = 0x20 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RELEASE = 0x30bb6 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BRKINT = 0x2 + CFLUSH = 0xf + CLOCAL = 0x8000 + CLONE_CSIGNAL = 0xff + CLONE_FILES = 0x400 + CLONE_FS = 0x200 + CLONE_PID = 0x1000 + CLONE_PTRACE = 0x2000 + CLONE_SIGHAND = 0x800 + CLONE_VFORK = 0x4000 + CLONE_VM = 0x100 + CREAD = 0x800 + CS5 = 0x0 + CS6 = 0x100 + CS7 = 0x200 + CS8 = 0x300 + CSIZE = 0x300 + CSTART = 0x11 + CSTATUS = 0x14 + CSTOP = 0x13 + CSTOPB = 0x400 + CSUSP = 0x1a + CTL_MAXNAME = 0xc + CTL_NET = 0x4 + CTL_QUERY = -0x2 + DIOCBSFLUSH = 0x20006478 + DLT_A429 = 0xb8 + DLT_A653_ICM = 0xb9 + DLT_AIRONET_HEADER = 0x78 + DLT_AOS = 0xde + DLT_APPLE_IP_OVER_IEEE1394 = 0x8a + DLT_ARCNET = 0x7 + DLT_ARCNET_LINUX = 0x81 + DLT_ATM_CLIP = 0x13 + DLT_ATM_RFC1483 = 0xb + DLT_AURORA = 0x7e + DLT_AX25 = 0x3 + DLT_AX25_KISS = 0xca + DLT_BACNET_MS_TP = 0xa5 + DLT_BLUETOOTH_HCI_H4 = 0xbb + DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9 + DLT_CAN20B = 0xbe + DLT_CAN_SOCKETCAN = 0xe3 + DLT_CHAOS = 0x5 + DLT_CISCO_IOS = 0x76 + DLT_C_HDLC = 0x68 + DLT_C_HDLC_WITH_DIR = 0xcd + DLT_DECT = 0xdd + DLT_DOCSIS = 0x8f + DLT_ECONET = 0x73 + DLT_EN10MB = 0x1 + DLT_EN3MB = 0x2 + DLT_ENC = 0x6d + DLT_ERF = 0xc5 + DLT_ERF_ETH = 0xaf + DLT_ERF_POS = 0xb0 + DLT_FC_2 = 0xe0 + DLT_FC_2_WITH_FRAME_DELIMS = 0xe1 + DLT_FDDI = 0xa + DLT_FLEXRAY = 0xd2 + DLT_FRELAY = 0x6b + DLT_FRELAY_WITH_DIR = 0xce + DLT_GCOM_SERIAL = 0xad + DLT_GCOM_T1E1 = 0xac + DLT_GPF_F = 0xab + DLT_GPF_T = 0xaa + DLT_GPRS_LLC = 0xa9 + DLT_GSMTAP_ABIS = 0xda + DLT_GSMTAP_UM = 0xd9 + DLT_HDLC = 0x10 + DLT_HHDLC = 0x79 + DLT_HIPPI = 0xf + DLT_IBM_SN = 0x92 + DLT_IBM_SP = 0x91 + DLT_IEEE802 = 0x6 + DLT_IEEE802_11 = 0x69 + DLT_IEEE802_11_RADIO = 0x7f + DLT_IEEE802_11_RADIO_AVS = 0xa3 + DLT_IEEE802_15_4 = 0xc3 + DLT_IEEE802_15_4_LINUX = 0xbf + DLT_IEEE802_15_4_NONASK_PHY = 0xd7 + DLT_IEEE802_16_MAC_CPS = 0xbc + DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1 + DLT_IPMB = 0xc7 + DLT_IPMB_LINUX = 0xd1 + DLT_IPNET = 0xe2 + DLT_IPV4 = 0xe4 + DLT_IPV6 = 0xe5 + DLT_IP_OVER_FC = 0x7a + DLT_JUNIPER_ATM1 = 0x89 + DLT_JUNIPER_ATM2 = 0x87 + DLT_JUNIPER_CHDLC = 0xb5 + DLT_JUNIPER_ES = 0x84 + DLT_JUNIPER_ETHER = 0xb2 + DLT_JUNIPER_FRELAY = 0xb4 + DLT_JUNIPER_GGSN = 0x85 + DLT_JUNIPER_ISM = 0xc2 + DLT_JUNIPER_MFR = 0x86 + DLT_JUNIPER_MLFR = 0x83 + DLT_JUNIPER_MLPPP = 0x82 + DLT_JUNIPER_MONITOR = 0xa4 + DLT_JUNIPER_PIC_PEER = 0xae + DLT_JUNIPER_PPP = 0xb3 + DLT_JUNIPER_PPPOE = 0xa7 + DLT_JUNIPER_PPPOE_ATM = 0xa8 + DLT_JUNIPER_SERVICES = 0x88 + DLT_JUNIPER_ST = 0xc8 + DLT_JUNIPER_VP = 0xb7 + DLT_LAPB_WITH_DIR = 0xcf + DLT_LAPD = 0xcb + DLT_LIN = 0xd4 + DLT_LINUX_EVDEV = 0xd8 + DLT_LINUX_IRDA = 0x90 + DLT_LINUX_LAPD = 0xb1 + DLT_LINUX_SLL = 0x71 + DLT_LOOP = 0x6c + DLT_LTALK = 0x72 + DLT_MFR = 0xb6 + DLT_MOST = 0xd3 + DLT_MPLS = 0xdb + DLT_MTP2 = 0x8c + DLT_MTP2_WITH_PHDR = 0x8b + DLT_MTP3 = 0x8d + DLT_NULL = 0x0 + DLT_PCI_EXP = 0x7d + DLT_PFLOG = 0x75 + DLT_PFSYNC = 0x12 + DLT_PPI = 0xc0 + DLT_PPP = 0x9 + DLT_PPP_BSDOS = 0xe + DLT_PPP_ETHER = 0x33 + DLT_PPP_PPPD = 0xa6 + DLT_PPP_SERIAL = 0x32 + DLT_PPP_WITH_DIR = 0xcc + DLT_PRISM_HEADER = 0x77 + DLT_PRONET = 0x4 + DLT_RAIF1 = 0xc6 + DLT_RAW = 0xc + DLT_RAWAF_MASK = 0x2240000 + DLT_RIO = 0x7c + DLT_SCCP = 0x8e + DLT_SITA = 0xc4 + DLT_SLIP = 0x8 + DLT_SLIP_BSDOS = 0xd + DLT_SUNATM = 0x7b + DLT_SYMANTEC_FIREWALL = 0x63 + DLT_TZSP = 0x80 + DLT_USB = 0xba + DLT_USB_LINUX = 0xbd + DLT_USB_LINUX_MMAPPED = 0xdc + DLT_WIHART = 0xdf + DLT_X2E_SERIAL = 0xd5 + DLT_X2E_XORAYA = 0xd6 + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x40 + ECHOE = 0x2 + ECHOK = 0x4 + ECHOKE = 0x1 + ECHONL = 0x10 + ECHOPRT = 0x20 + EMUL_LINUX = 0x1 + EMUL_LINUX32 = 0x5 + EMUL_MAXID = 0x6 + ETHERCAP_JUMBO_MTU = 0x4 + ETHERCAP_VLAN_HWTAGGING = 0x2 + ETHERCAP_VLAN_MTU = 0x1 + ETHERMIN = 0x2e + ETHERMTU = 0x5dc + ETHERMTU_JUMBO = 0x2328 + ETHERTYPE_8023 = 0x4 + ETHERTYPE_AARP = 0x80f3 + ETHERTYPE_ACCTON = 0x8390 + ETHERTYPE_AEONIC = 0x8036 + ETHERTYPE_ALPHA = 0x814a + ETHERTYPE_AMBER = 0x6008 + ETHERTYPE_AMOEBA = 0x8145 + ETHERTYPE_APOLLO = 0x80f7 + ETHERTYPE_APOLLODOMAIN = 0x8019 + ETHERTYPE_APPLETALK = 0x809b + ETHERTYPE_APPLITEK = 0x80c7 + ETHERTYPE_ARGONAUT = 0x803a + ETHERTYPE_ARP = 0x806 + ETHERTYPE_AT = 0x809b + ETHERTYPE_ATALK = 0x809b + ETHERTYPE_ATOMIC = 0x86df + ETHERTYPE_ATT = 0x8069 + ETHERTYPE_ATTSTANFORD = 0x8008 + ETHERTYPE_AUTOPHON = 0x806a + ETHERTYPE_AXIS = 0x8856 + ETHERTYPE_BCLOOP = 0x9003 + ETHERTYPE_BOFL = 0x8102 + ETHERTYPE_CABLETRON = 0x7034 + ETHERTYPE_CHAOS = 0x804 + ETHERTYPE_COMDESIGN = 0x806c + ETHERTYPE_COMPUGRAPHIC = 0x806d + ETHERTYPE_COUNTERPOINT = 0x8062 + ETHERTYPE_CRONUS = 0x8004 + ETHERTYPE_CRONUSVLN = 0x8003 + ETHERTYPE_DCA = 0x1234 + ETHERTYPE_DDE = 0x807b + ETHERTYPE_DEBNI = 0xaaaa + ETHERTYPE_DECAM = 0x8048 + ETHERTYPE_DECCUST = 0x6006 + ETHERTYPE_DECDIAG = 0x6005 + ETHERTYPE_DECDNS = 0x803c + ETHERTYPE_DECDTS = 0x803e + ETHERTYPE_DECEXPER = 0x6000 + ETHERTYPE_DECLAST = 0x8041 + ETHERTYPE_DECLTM = 0x803f + ETHERTYPE_DECMUMPS = 0x6009 + ETHERTYPE_DECNETBIOS = 0x8040 + ETHERTYPE_DELTACON = 0x86de + ETHERTYPE_DIDDLE = 0x4321 + ETHERTYPE_DLOG1 = 0x660 + ETHERTYPE_DLOG2 = 0x661 + ETHERTYPE_DN = 0x6003 + ETHERTYPE_DOGFIGHT = 0x1989 + ETHERTYPE_DSMD = 0x8039 + ETHERTYPE_ECMA = 0x803 + ETHERTYPE_ENCRYPT = 0x803d + ETHERTYPE_ES = 0x805d + ETHERTYPE_EXCELAN = 0x8010 + ETHERTYPE_EXPERDATA = 0x8049 + ETHERTYPE_FLIP = 0x8146 + ETHERTYPE_FLOWCONTROL = 0x8808 + ETHERTYPE_FRARP = 0x808 + ETHERTYPE_GENDYN = 0x8068 + ETHERTYPE_HAYES = 0x8130 + ETHERTYPE_HIPPI_FP = 0x8180 + ETHERTYPE_HITACHI = 0x8820 + ETHERTYPE_HP = 0x8005 + ETHERTYPE_IEEEPUP = 0xa00 + ETHERTYPE_IEEEPUPAT = 0xa01 + ETHERTYPE_IMLBL = 0x4c42 + ETHERTYPE_IMLBLDIAG = 0x424c + ETHERTYPE_IP = 0x800 + ETHERTYPE_IPAS = 0x876c + ETHERTYPE_IPV6 = 0x86dd + ETHERTYPE_IPX = 0x8137 + ETHERTYPE_IPXNEW = 0x8037 + ETHERTYPE_KALPANA = 0x8582 + ETHERTYPE_LANBRIDGE = 0x8038 + ETHERTYPE_LANPROBE = 0x8888 + ETHERTYPE_LAT = 0x6004 + ETHERTYPE_LBACK = 0x9000 + ETHERTYPE_LITTLE = 0x8060 + ETHERTYPE_LOGICRAFT = 0x8148 + ETHERTYPE_LOOPBACK = 0x9000 + ETHERTYPE_MATRA = 0x807a + ETHERTYPE_MAX = 0xffff + ETHERTYPE_MERIT = 0x807c + ETHERTYPE_MICP = 0x873a + ETHERTYPE_MOPDL = 0x6001 + ETHERTYPE_MOPRC = 0x6002 + ETHERTYPE_MOTOROLA = 0x818d + ETHERTYPE_MPLS = 0x8847 + ETHERTYPE_MPLS_MCAST = 0x8848 + ETHERTYPE_MUMPS = 0x813f + ETHERTYPE_NBPCC = 0x3c04 + ETHERTYPE_NBPCLAIM = 0x3c09 + ETHERTYPE_NBPCLREQ = 0x3c05 + ETHERTYPE_NBPCLRSP = 0x3c06 + ETHERTYPE_NBPCREQ = 0x3c02 + ETHERTYPE_NBPCRSP = 0x3c03 + ETHERTYPE_NBPDG = 0x3c07 + ETHERTYPE_NBPDGB = 0x3c08 + ETHERTYPE_NBPDLTE = 0x3c0a + ETHERTYPE_NBPRAR = 0x3c0c + ETHERTYPE_NBPRAS = 0x3c0b + ETHERTYPE_NBPRST = 0x3c0d + ETHERTYPE_NBPSCD = 0x3c01 + ETHERTYPE_NBPVCD = 0x3c00 + ETHERTYPE_NBS = 0x802 + ETHERTYPE_NCD = 0x8149 + ETHERTYPE_NESTAR = 0x8006 + ETHERTYPE_NETBEUI = 0x8191 + ETHERTYPE_NOVELL = 0x8138 + ETHERTYPE_NS = 0x600 + ETHERTYPE_NSAT = 0x601 + ETHERTYPE_NSCOMPAT = 0x807 + ETHERTYPE_NTRAILER = 0x10 + ETHERTYPE_OS9 = 0x7007 + ETHERTYPE_OS9NET = 0x7009 + ETHERTYPE_PACER = 0x80c6 + ETHERTYPE_PAE = 0x888e + ETHERTYPE_PCS = 0x4242 + ETHERTYPE_PLANNING = 0x8044 + ETHERTYPE_PPP = 0x880b + ETHERTYPE_PPPOE = 0x8864 + ETHERTYPE_PPPOEDISC = 0x8863 + ETHERTYPE_PRIMENTS = 0x7031 + ETHERTYPE_PUP = 0x200 + ETHERTYPE_PUPAT = 0x200 + ETHERTYPE_RACAL = 0x7030 + ETHERTYPE_RATIONAL = 0x8150 + ETHERTYPE_RAWFR = 0x6559 + ETHERTYPE_RCL = 0x1995 + ETHERTYPE_RDP = 0x8739 + ETHERTYPE_RETIX = 0x80f2 + ETHERTYPE_REVARP = 0x8035 + ETHERTYPE_SCA = 0x6007 + ETHERTYPE_SECTRA = 0x86db + ETHERTYPE_SECUREDATA = 0x876d + ETHERTYPE_SGITW = 0x817e + ETHERTYPE_SG_BOUNCE = 0x8016 + ETHERTYPE_SG_DIAG = 0x8013 + ETHERTYPE_SG_NETGAMES = 0x8014 + ETHERTYPE_SG_RESV = 0x8015 + ETHERTYPE_SIMNET = 0x5208 + ETHERTYPE_SLOWPROTOCOLS = 0x8809 + ETHERTYPE_SNA = 0x80d5 + ETHERTYPE_SNMP = 0x814c + ETHERTYPE_SONIX = 0xfaf5 + ETHERTYPE_SPIDER = 0x809f + ETHERTYPE_SPRITE = 0x500 + ETHERTYPE_STP = 0x8181 + ETHERTYPE_TALARIS = 0x812b + ETHERTYPE_TALARISMC = 0x852b + ETHERTYPE_TCPCOMP = 0x876b + ETHERTYPE_TCPSM = 0x9002 + ETHERTYPE_TEC = 0x814f + ETHERTYPE_TIGAN = 0x802f + ETHERTYPE_TRAIL = 0x1000 + ETHERTYPE_TRANSETHER = 0x6558 + ETHERTYPE_TYMSHARE = 0x802e + ETHERTYPE_UBBST = 0x7005 + ETHERTYPE_UBDEBUG = 0x900 + ETHERTYPE_UBDIAGLOOP = 0x7002 + ETHERTYPE_UBDL = 0x7000 + ETHERTYPE_UBNIU = 0x7001 + ETHERTYPE_UBNMC = 0x7003 + ETHERTYPE_VALID = 0x1600 + ETHERTYPE_VARIAN = 0x80dd + ETHERTYPE_VAXELN = 0x803b + ETHERTYPE_VEECO = 0x8067 + ETHERTYPE_VEXP = 0x805b + ETHERTYPE_VGLAB = 0x8131 + ETHERTYPE_VINES = 0xbad + ETHERTYPE_VINESECHO = 0xbaf + ETHERTYPE_VINESLOOP = 0xbae + ETHERTYPE_VITAL = 0xff00 + ETHERTYPE_VLAN = 0x8100 + ETHERTYPE_VLTLMAN = 0x8080 + ETHERTYPE_VPROD = 0x805c + ETHERTYPE_VURESERVED = 0x8147 + ETHERTYPE_WATERLOO = 0x8130 + ETHERTYPE_WELLFLEET = 0x8103 + ETHERTYPE_X25 = 0x805 + ETHERTYPE_X75 = 0x801 + ETHERTYPE_XNSSM = 0x9001 + ETHERTYPE_XTP = 0x817d + ETHER_ADDR_LEN = 0x6 + ETHER_CRC_LEN = 0x4 + ETHER_CRC_POLY_BE = 0x4c11db6 + ETHER_CRC_POLY_LE = 0xedb88320 + ETHER_HDR_LEN = 0xe + ETHER_MAX_LEN = 0x5ee + ETHER_MAX_LEN_JUMBO = 0x233a + ETHER_MIN_LEN = 0x40 + ETHER_PPPOE_ENCAP_LEN = 0x8 + ETHER_TYPE_LEN = 0x2 + ETHER_VLAN_ENCAP_LEN = 0x4 + EVFILT_AIO = 0x2 + EVFILT_PROC = 0x4 + EVFILT_READ = 0x0 + EVFILT_SIGNAL = 0x5 + EVFILT_SYSCOUNT = 0x7 + EVFILT_TIMER = 0x6 + EVFILT_VNODE = 0x3 + EVFILT_WRITE = 0x1 + EV_ADD = 0x1 + EV_CLEAR = 0x20 + EV_DELETE = 0x2 + EV_DISABLE = 0x8 + EV_ENABLE = 0x4 + EV_EOF = 0x8000 + EV_ERROR = 0x4000 + EV_FLAG1 = 0x2000 + EV_ONESHOT = 0x10 + EV_SYSFLAGS = 0xf000 + EXTA = 0x4b00 + EXTB = 0x9600 + EXTPROC = 0x800 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x100 + FLUSHO = 0x800000 + F_CLOSEM = 0xa + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0xc + F_FSCTL = -0x80000000 + F_FSDIRMASK = 0x70000000 + F_FSIN = 0x10000000 + F_FSINOUT = 0x30000000 + F_FSOUT = 0x20000000 + F_FSPRIV = 0x8000 + F_FSVOID = 0x40000000 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLK = 0x7 + F_GETNOSIGPIPE = 0xd + F_GETOWN = 0x5 + F_MAXFD = 0xb + F_OK = 0x0 + F_PARAM_MASK = 0xfff + F_PARAM_MAX = 0xfff + F_RDLCK = 0x1 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLK = 0x8 + F_SETLKW = 0x9 + F_SETNOSIGPIPE = 0xe + F_SETOWN = 0x6 + F_UNLCK = 0x2 + F_WRLCK = 0x3 + HUPCL = 0x4000 + ICANON = 0x100 + ICMP6_FILTER = 0x12 + ICRNL = 0x100 + IEXTEN = 0x400 + IFAN_ARRIVAL = 0x0 + IFAN_DEPARTURE = 0x1 + IFA_ROUTE = 0x1 + IFF_ALLMULTI = 0x200 + IFF_BROADCAST = 0x2 + IFF_CANTCHANGE = 0x8f52 + IFF_DEBUG = 0x4 + IFF_LINK0 = 0x1000 + IFF_LINK1 = 0x2000 + IFF_LINK2 = 0x4000 + IFF_LOOPBACK = 0x8 + IFF_MULTICAST = 0x8000 + IFF_NOARP = 0x80 + IFF_NOTRAILERS = 0x20 + IFF_OACTIVE = 0x400 + IFF_POINTOPOINT = 0x10 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SIMPLEX = 0x800 + IFF_UP = 0x1 + IFNAMSIZ = 0x10 + 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_BRIDGE = 0xd1 + IFT_BSC = 0x53 + IFT_CARP = 0xf8 + 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_DOCSCABLEUPSTREAMCHANNEL = 0xcd + 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_ECONET = 0xce + 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_IEEE1394 = 0x90 + IFT_IEEE80211 = 0x47 + IFT_IEEE80212 = 0x37 + IFT_IEEE8023ADLAG = 0xa1 + IFT_IFGSN = 0x91 + IFT_IMT = 0xbe + IFT_INFINIBAND = 0xc7 + IFT_INTERLEAVE = 0x7c + IFT_IP = 0x7e + IFT_IPFORWARD = 0x8e + IFT_IPOVERATM = 0x72 + IFT_IPOVERCDLC = 0x6d + IFT_IPOVERCLAW = 0x6e + IFT_IPSWITCH = 0x4e + 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_L2VLAN = 0x87 + IFT_L3IPVLAN = 0x88 + IFT_L3IPXVLAN = 0x89 + IFT_LAPB = 0x10 + IFT_LAPD = 0x4d + IFT_LAPF = 0x77 + IFT_LINEGROUP = 0xd2 + 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 = 0xf5 + IFT_PFSYNC = 0xf6 + IFT_PLC = 0xae + IFT_PON155 = 0xcf + IFT_PON622 = 0xd0 + IFT_POS = 0xab + IFT_PPP = 0x17 + IFT_PPPMULTILINKBUNDLE = 0x6c + IFT_PROPATM = 0xc5 + IFT_PROPBWAP2MP = 0xb8 + IFT_PROPCNLS = 0x59 + IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5 + IFT_PROPDOCSWIRELESSMACLAYER = 0xb4 + IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6 + IFT_PROPMUX = 0x36 + IFT_PROPVIRTUAL = 0x35 + IFT_PROPWIRELESSP2P = 0x9d + IFT_PTPSERIAL = 0x16 + IFT_PVC = 0xf1 + IFT_Q2931 = 0xc9 + 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_SIPSIG = 0xcc + IFT_SIPTG = 0xcb + 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_TELINK = 0xc8 + 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_VIRTUALTG = 0xca + IFT_VOICEDID = 0xd5 + IFT_VOICEEM = 0x64 + IFT_VOICEEMFGD = 0xd3 + IFT_VOICEENCAP = 0x67 + IFT_VOICEFGDEANA = 0xd4 + IFT_VOICEFXO = 0x65 + IFT_VOICEFXS = 0x66 + IFT_VOICEOVERATM = 0x98 + IFT_VOICEOVERCABLE = 0xc6 + 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 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLASSD_HOST = 0xfffffff + IN_CLASSD_NET = 0xf0000000 + IN_CLASSD_NSHIFT = 0x1c + IN_LOOPBACKNET = 0x7f + IPPROTO_AH = 0x33 + IPPROTO_CARP = 0x70 + IPPROTO_DONE = 0x101 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_ENCAP = 0x62 + IPPROTO_EON = 0x50 + IPPROTO_ESP = 0x32 + IPPROTO_ETHERIP = 0x61 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GGP = 0x3 + IPPROTO_GRE = 0x2f + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IGMP = 0x2 + IPPROTO_IP = 0x0 + IPPROTO_IPCOMP = 0x6c + IPPROTO_IPIP = 0x4 + IPPROTO_IPV4 = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_IPV6_ICMP = 0x3a + IPPROTO_MAX = 0x100 + IPPROTO_MAXID = 0x34 + IPPROTO_MOBILE = 0x37 + IPPROTO_NONE = 0x3b + IPPROTO_PFSYNC = 0xf0 + IPPROTO_PIM = 0x67 + IPPROTO_PUP = 0xc + IPPROTO_RAW = 0xff + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_UDP = 0x11 + IPPROTO_VRRP = 0x70 + IPV6_CHECKSUM = 0x1a + IPV6_DEFAULT_MULTICAST_HOPS = 0x1 + IPV6_DEFAULT_MULTICAST_LOOP = 0x1 + IPV6_DEFHLIM = 0x40 + IPV6_DONTFRAG = 0x3e + IPV6_DSTOPTS = 0x32 + IPV6_FAITH = 0x1d + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 + IPV6_FRAGTTL = 0x78 + IPV6_HLIMDEC = 0x1 + IPV6_HOPLIMIT = 0x2f + IPV6_HOPOPTS = 0x31 + IPV6_IPSEC_POLICY = 0x1c + IPV6_JOIN_GROUP = 0xc + IPV6_LEAVE_GROUP = 0xd + IPV6_MAXHLIM = 0xff + IPV6_MAXPACKET = 0xffff + IPV6_MMTU = 0x500 + IPV6_MULTICAST_HOPS = 0xa + IPV6_MULTICAST_IF = 0x9 + IPV6_MULTICAST_LOOP = 0xb + IPV6_NEXTHOP = 0x30 + IPV6_PATHMTU = 0x2c + IPV6_PKTINFO = 0x2e + IPV6_PORTRANGE = 0xe + IPV6_PORTRANGE_DEFAULT = 0x0 + IPV6_PORTRANGE_HIGH = 0x1 + IPV6_PORTRANGE_LOW = 0x2 + IPV6_RECVDSTOPTS = 0x28 + IPV6_RECVHOPLIMIT = 0x25 + IPV6_RECVHOPOPTS = 0x27 + IPV6_RECVPATHMTU = 0x2b + IPV6_RECVPKTINFO = 0x24 + IPV6_RECVRTHDR = 0x26 + IPV6_RECVTCLASS = 0x39 + IPV6_RTHDR = 0x33 + IPV6_RTHDRDSTOPTS = 0x23 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_SOCKOPT_RESERVED1 = 0x3 + IPV6_TCLASS = 0x3d + IPV6_UNICAST_HOPS = 0x4 + IPV6_USE_MIN_MTU = 0x2a + IPV6_V6ONLY = 0x1b + IPV6_VERSION = 0x60 + IPV6_VERSION_MASK = 0xf0 + IP_ADD_MEMBERSHIP = 0xc + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DROP_MEMBERSHIP = 0xd + IP_EF = 0x8000 + IP_ERRORMTU = 0x15 + IP_HDRINCL = 0x2 + IP_IPSEC_POLICY = 0x16 + IP_MAXPACKET = 0xffff + IP_MAX_MEMBERSHIPS = 0x14 + IP_MF = 0x2000 + IP_MINFRAGSIZE = 0x45 + IP_MINTTL = 0x18 + IP_MSS = 0x240 + IP_MULTICAST_IF = 0x9 + IP_MULTICAST_LOOP = 0xb + IP_MULTICAST_TTL = 0xa + IP_OFFMASK = 0x1fff + IP_OPTIONS = 0x1 + IP_PORTRANGE = 0x13 + IP_PORTRANGE_DEFAULT = 0x0 + IP_PORTRANGE_HIGH = 0x1 + IP_PORTRANGE_LOW = 0x2 + IP_RECVDSTADDR = 0x7 + IP_RECVIF = 0x14 + IP_RECVOPTS = 0x5 + IP_RECVRETOPTS = 0x6 + IP_RECVTTL = 0x17 + IP_RETOPTS = 0x8 + IP_RF = 0x8000 + IP_TOS = 0x3 + IP_TTL = 0x4 + ISIG = 0x80 + ISTRIP = 0x20 + IXANY = 0x800 + IXOFF = 0x400 + IXON = 0x200 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_DONTNEED = 0x4 + MADV_FREE = 0x6 + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_SEQUENTIAL = 0x2 + MADV_SPACEAVAIL = 0x5 + MADV_WILLNEED = 0x3 + MAP_ALIGNMENT_16MB = 0x18000000 + MAP_ALIGNMENT_1TB = 0x28000000 + MAP_ALIGNMENT_256TB = 0x30000000 + MAP_ALIGNMENT_4GB = 0x20000000 + MAP_ALIGNMENT_64KB = 0x10000000 + MAP_ALIGNMENT_64PB = 0x38000000 + MAP_ALIGNMENT_MASK = -0x1000000 + MAP_ALIGNMENT_SHIFT = 0x18 + MAP_ANON = 0x1000 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_HASSEMAPHORE = 0x200 + MAP_INHERIT = 0x80 + MAP_INHERIT_COPY = 0x1 + MAP_INHERIT_DEFAULT = 0x1 + MAP_INHERIT_DONATE_COPY = 0x3 + MAP_INHERIT_NONE = 0x2 + MAP_INHERIT_SHARE = 0x0 + MAP_NORESERVE = 0x40 + MAP_PRIVATE = 0x2 + MAP_RENAME = 0x20 + MAP_SHARED = 0x1 + MAP_STACK = 0x2000 + MAP_TRYFIXED = 0x400 + MAP_WIRED = 0x800 + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MSG_BCAST = 0x100 + MSG_CMSG_CLOEXEC = 0x800 + MSG_CONTROLMBUF = 0x2000000 + MSG_CTRUNC = 0x20 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x80 + MSG_EOR = 0x8 + MSG_IOVUSRSPACE = 0x4000000 + MSG_LENUSRSPACE = 0x8000000 + MSG_MCAST = 0x200 + MSG_NAMEMBUF = 0x1000000 + MSG_NBIO = 0x1000 + MSG_NOSIGNAL = 0x400 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_TRUNC = 0x10 + MSG_USERFLAGS = 0xffffff + MSG_WAITALL = 0x40 + MS_ASYNC = 0x1 + MS_INVALIDATE = 0x2 + MS_SYNC = 0x4 + NAME_MAX = 0x1ff + NET_RT_DUMP = 0x1 + NET_RT_FLAGS = 0x2 + NET_RT_IFLIST = 0x5 + NET_RT_MAXID = 0x6 + NET_RT_OIFLIST = 0x4 + NET_RT_OOIFLIST = 0x3 + NOFLSH = 0x80000000 + NOTE_ATTRIB = 0x8 + NOTE_CHILD = 0x4 + NOTE_DELETE = 0x1 + NOTE_EXEC = 0x20000000 + NOTE_EXIT = 0x80000000 + NOTE_EXTEND = 0x4 + NOTE_FORK = 0x40000000 + NOTE_LINK = 0x10 + NOTE_LOWAT = 0x1 + NOTE_PCTRLMASK = 0xf0000000 + NOTE_PDATAMASK = 0xfffff + NOTE_RENAME = 0x20 + NOTE_REVOKE = 0x40 + NOTE_TRACK = 0x1 + NOTE_TRACKERR = 0x2 + NOTE_WRITE = 0x2 + OCRNL = 0x10 + OFIOGETBMAP = 0xc004667a + ONLCR = 0x2 + ONLRET = 0x40 + ONOCR = 0x20 + ONOEOT = 0x8 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_ALT_IO = 0x40000 + O_APPEND = 0x8 + O_ASYNC = 0x40 + O_CLOEXEC = 0x400000 + O_CREAT = 0x200 + O_DIRECT = 0x80000 + O_DIRECTORY = 0x200000 + O_DSYNC = 0x10000 + O_EXCL = 0x800 + O_EXLOCK = 0x20 + O_FSYNC = 0x80 + O_NDELAY = 0x4 + O_NOCTTY = 0x8000 + O_NOFOLLOW = 0x100 + O_NONBLOCK = 0x4 + O_NOSIGPIPE = 0x1000000 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_RSYNC = 0x20000 + O_SHLOCK = 0x10 + O_SYNC = 0x80 + O_TRUNC = 0x400 + O_WRONLY = 0x1 + PARENB = 0x1000 + PARMRK = 0x8 + PARODD = 0x2000 + PENDIN = 0x20000000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PRI_IOFLUSH = 0x7c + PROT_EXEC = 0x4 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + RLIMIT_AS = 0xa + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x8 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = 0x7fffffffffffffff + RTAX_AUTHOR = 0x6 + RTAX_BRD = 0x7 + RTAX_DST = 0x0 + RTAX_GATEWAY = 0x1 + RTAX_GENMASK = 0x3 + RTAX_IFA = 0x5 + RTAX_IFP = 0x4 + RTAX_MAX = 0x9 + RTAX_NETMASK = 0x2 + RTAX_TAG = 0x8 + RTA_AUTHOR = 0x40 + RTA_BRD = 0x80 + RTA_DST = 0x1 + RTA_GATEWAY = 0x2 + RTA_GENMASK = 0x8 + RTA_IFA = 0x20 + RTA_IFP = 0x10 + RTA_NETMASK = 0x4 + RTA_TAG = 0x100 + RTF_ANNOUNCE = 0x20000 + RTF_BLACKHOLE = 0x1000 + RTF_CLONED = 0x2000 + RTF_CLONING = 0x100 + RTF_DONE = 0x40 + RTF_DYNAMIC = 0x10 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_LLINFO = 0x400 + RTF_MASK = 0x80 + RTF_MODIFIED = 0x20 + RTF_PROTO1 = 0x8000 + RTF_PROTO2 = 0x4000 + RTF_REJECT = 0x8 + RTF_SRC = 0x10000 + RTF_STATIC = 0x800 + RTF_UP = 0x1 + RTF_XRESOLVE = 0x200 + RTM_ADD = 0x1 + RTM_CHANGE = 0x3 + RTM_CHGADDR = 0x15 + RTM_DELADDR = 0xd + RTM_DELETE = 0x2 + RTM_GET = 0x4 + RTM_IEEE80211 = 0x11 + RTM_IFANNOUNCE = 0x10 + RTM_IFINFO = 0x14 + RTM_LLINFO_UPD = 0x13 + RTM_LOCK = 0x8 + RTM_LOSING = 0x5 + RTM_MISS = 0x7 + RTM_NEWADDR = 0xc + RTM_OIFINFO = 0xf + RTM_OLDADD = 0x9 + RTM_OLDDEL = 0xa + RTM_OOIFINFO = 0xe + RTM_REDIRECT = 0x6 + RTM_RESOLVE = 0xb + RTM_RTTUNIT = 0xf4240 + RTM_SETGATE = 0x12 + RTM_VERSION = 0x4 + RTV_EXPIRE = 0x4 + RTV_HOPCOUNT = 0x2 + RTV_MTU = 0x1 + RTV_RPIPE = 0x8 + RTV_RTT = 0x40 + RTV_RTTVAR = 0x80 + RTV_SPIPE = 0x10 + RTV_SSTHRESH = 0x20 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + SCM_CREDS = 0x4 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x8 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDMULTI = 0x80906931 + SIOCADDRT = 0x8038720a + SIOCAIFADDR = 0x8040691a + SIOCALIFADDR = 0x8118691c + SIOCATMARK = 0x40047307 + SIOCDELMULTI = 0x80906932 + SIOCDELRT = 0x8038720b + SIOCDIFADDR = 0x80906919 + SIOCDIFPHYADDR = 0x80906949 + SIOCDLIFADDR = 0x8118691e + SIOCGDRVSPEC = 0xc028697b + SIOCGETPFSYNC = 0xc09069f8 + SIOCGETSGCNT = 0xc0207534 + SIOCGETVIFCNT = 0xc0287533 + SIOCGHIWAT = 0x40047301 + SIOCGIFADDR = 0xc0906921 + SIOCGIFADDRPREF = 0xc0986920 + SIOCGIFALIAS = 0xc040691b + SIOCGIFBRDADDR = 0xc0906923 + SIOCGIFCAP = 0xc0206976 + SIOCGIFCONF = 0xc0106926 + SIOCGIFDATA = 0xc0986985 + SIOCGIFDLT = 0xc0906977 + SIOCGIFDSTADDR = 0xc0906922 + SIOCGIFFLAGS = 0xc0906911 + SIOCGIFGENERIC = 0xc090693a + SIOCGIFMEDIA = 0xc0306936 + SIOCGIFMETRIC = 0xc0906917 + SIOCGIFMTU = 0xc090697e + SIOCGIFNETMASK = 0xc0906925 + SIOCGIFPDSTADDR = 0xc0906948 + SIOCGIFPSRCADDR = 0xc0906947 + SIOCGLIFADDR = 0xc118691d + SIOCGLIFPHYADDR = 0xc118694b + SIOCGLINKSTR = 0xc0286987 + SIOCGLOWAT = 0x40047303 + SIOCGPGRP = 0x40047309 + SIOCGVH = 0xc0906983 + SIOCIFCREATE = 0x8090697a + SIOCIFDESTROY = 0x80906979 + SIOCIFGCLONERS = 0xc0106978 + SIOCINITIFADDR = 0xc0706984 + SIOCSDRVSPEC = 0x8028697b + SIOCSETPFSYNC = 0x809069f7 + SIOCSHIWAT = 0x80047300 + SIOCSIFADDR = 0x8090690c + SIOCSIFADDRPREF = 0x8098691f + SIOCSIFBRDADDR = 0x80906913 + SIOCSIFCAP = 0x80206975 + SIOCSIFDSTADDR = 0x8090690e + SIOCSIFFLAGS = 0x80906910 + SIOCSIFGENERIC = 0x80906939 + SIOCSIFMEDIA = 0xc0906935 + SIOCSIFMETRIC = 0x80906918 + SIOCSIFMTU = 0x8090697f + SIOCSIFNETMASK = 0x80906916 + SIOCSIFPHYADDR = 0x80406946 + SIOCSLIFPHYADDR = 0x8118694a + SIOCSLINKSTR = 0x80286988 + SIOCSLOWAT = 0x80047302 + SIOCSPGRP = 0x80047308 + SIOCSVH = 0xc0906982 + SIOCZIFDATA = 0xc0986986 + SOCK_CLOEXEC = 0x10000000 + SOCK_DGRAM = 0x2 + SOCK_FLAGS_MASK = 0xf0000000 + SOCK_NONBLOCK = 0x20000000 + SOCK_NOSIGPIPE = 0x40000000 + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_SOCKET = 0xffff + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x2 + SO_ACCEPTFILTER = 0x1000 + SO_BROADCAST = 0x20 + SO_DEBUG = 0x1 + SO_DONTROUTE = 0x10 + SO_ERROR = 0x1007 + SO_KEEPALIVE = 0x8 + SO_LINGER = 0x80 + SO_NOHEADER = 0x100a + SO_NOSIGPIPE = 0x800 + SO_OOBINLINE = 0x100 + SO_OVERFLOWED = 0x1009 + SO_RCVBUF = 0x1002 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x100c + SO_REUSEADDR = 0x4 + SO_REUSEPORT = 0x200 + SO_SNDBUF = 0x1001 + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x100b + SO_TIMESTAMP = 0x2000 + SO_TYPE = 0x1008 + SO_USELOOPBACK = 0x40 + SYSCTL_VERSION = 0x1000000 + SYSCTL_VERS_0 = 0x0 + SYSCTL_VERS_1 = 0x1000000 + SYSCTL_VERS_MASK = 0xff000000 + S_ARCH1 = 0x10000 + S_ARCH2 = 0x20000 + S_BLKSIZE = 0x200 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IFWHT = 0xe000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISTXT = 0x200 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + S_LOGIN_SET = 0x1 + TCIFLUSH = 0x1 + TCIOFLUSH = 0x3 + TCOFLUSH = 0x2 + TCP_CONGCTL = 0x20 + TCP_KEEPCNT = 0x6 + TCP_KEEPIDLE = 0x3 + TCP_KEEPINIT = 0x7 + TCP_KEEPINTVL = 0x5 + TCP_MAXBURST = 0x4 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0x10 + TCP_MINMSS = 0xd8 + TCP_MSS = 0x218 + TCP_NODELAY = 0x1 + TCSAFLUSH = 0x2 + TIOCCBRK = 0x2000747a + TIOCCDTR = 0x20007478 + TIOCCONS = 0x80047462 + TIOCDCDTIMESTAMP = 0x40107458 + TIOCDRAIN = 0x2000745e + TIOCEXCL = 0x2000740d + TIOCEXT = 0x80047460 + TIOCFLAG_CDTRCTS = 0x10 + TIOCFLAG_CLOCAL = 0x2 + TIOCFLAG_CRTSCTS = 0x4 + TIOCFLAG_MDMBUF = 0x8 + TIOCFLAG_SOFTCAR = 0x1 + TIOCFLUSH = 0x80047410 + TIOCGETA = 0x402c7413 + TIOCGETD = 0x4004741a + TIOCGFLAGS = 0x4004745d + TIOCGLINED = 0x40207442 + TIOCGPGRP = 0x40047477 + TIOCGQSIZE = 0x40047481 + TIOCGRANTPT = 0x20007447 + TIOCGSID = 0x40047463 + TIOCGSIZE = 0x40087468 + TIOCGWINSZ = 0x40087468 + TIOCMBIC = 0x8004746b + TIOCMBIS = 0x8004746c + TIOCMGET = 0x4004746a + TIOCMSET = 0x8004746d + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x20007471 + TIOCNXCL = 0x2000740e + TIOCOUTQ = 0x40047473 + TIOCPKT = 0x80047470 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCPTMGET = 0x40287446 + TIOCPTSNAME = 0x40287448 + TIOCRCVFRAME = 0x80087445 + TIOCREMOTE = 0x80047469 + TIOCSBRK = 0x2000747b + TIOCSCTTY = 0x20007461 + TIOCSDTR = 0x20007479 + TIOCSETA = 0x802c7414 + TIOCSETAF = 0x802c7416 + TIOCSETAW = 0x802c7415 + TIOCSETD = 0x8004741b + TIOCSFLAGS = 0x8004745c + TIOCSIG = 0x2000745f + TIOCSLINED = 0x80207443 + TIOCSPGRP = 0x80047476 + TIOCSQSIZE = 0x80047480 + TIOCSSIZE = 0x80087467 + TIOCSTART = 0x2000746e + TIOCSTAT = 0x80047465 + TIOCSTI = 0x80017472 + TIOCSTOP = 0x2000746f + TIOCSWINSZ = 0x80087467 + TIOCUCNTL = 0x80047466 + TIOCXMTFRAME = 0x80087444 + TOSTOP = 0x400000 + VDISCARD = 0xf + VDSUSP = 0xb + VEOF = 0x0 + VEOL = 0x1 + VEOL2 = 0x2 + VERASE = 0x3 + VINTR = 0x8 + VKILL = 0x5 + VLNEXT = 0xe + VMIN = 0x10 + VQUIT = 0x9 + VREPRINT = 0x6 + VSTART = 0xc + VSTATUS = 0x12 + VSTOP = 0xd + VSUSP = 0xa + VTIME = 0x11 + VWERASE = 0x4 + WALL = 0x8 + WALLSIG = 0x8 + WALTSIG = 0x4 + WCLONE = 0x4 + WCOREFLAG = 0x80 + WNOHANG = 0x1 + WNOWAIT = 0x10000 + WNOZOMBIE = 0x20000 + WOPTSCHECKED = 0x40000 + WSTOPPED = 0x7f + WUNTRACED = 0x2 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x30) + EADDRNOTAVAIL = syscall.Errno(0x31) + EAFNOSUPPORT = syscall.Errno(0x2f) + EAGAIN = syscall.Errno(0x23) + EALREADY = syscall.Errno(0x25) + EAUTH = syscall.Errno(0x50) + EBADF = syscall.Errno(0x9) + EBADMSG = syscall.Errno(0x58) + EBADRPC = syscall.Errno(0x48) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x57) + ECHILD = syscall.Errno(0xa) + ECONNABORTED = syscall.Errno(0x35) + ECONNREFUSED = syscall.Errno(0x3d) + ECONNRESET = syscall.Errno(0x36) + EDEADLK = syscall.Errno(0xb) + EDESTADDRREQ = syscall.Errno(0x27) + EDOM = syscall.Errno(0x21) + EDQUOT = syscall.Errno(0x45) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EFTYPE = syscall.Errno(0x4f) + EHOSTDOWN = syscall.Errno(0x40) + EHOSTUNREACH = syscall.Errno(0x41) + EIDRM = syscall.Errno(0x52) + EILSEQ = syscall.Errno(0x55) + EINPROGRESS = syscall.Errno(0x24) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x38) + EISDIR = syscall.Errno(0x15) + ELAST = syscall.Errno(0x60) + ELOOP = syscall.Errno(0x3e) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x28) + EMULTIHOP = syscall.Errno(0x5e) + ENAMETOOLONG = syscall.Errno(0x3f) + ENEEDAUTH = syscall.Errno(0x51) + ENETDOWN = syscall.Errno(0x32) + ENETRESET = syscall.Errno(0x34) + ENETUNREACH = syscall.Errno(0x33) + ENFILE = syscall.Errno(0x17) + ENOATTR = syscall.Errno(0x5d) + ENOBUFS = syscall.Errno(0x37) + ENODATA = syscall.Errno(0x59) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOLCK = syscall.Errno(0x4d) + ENOLINK = syscall.Errno(0x5f) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x53) + ENOPROTOOPT = syscall.Errno(0x2a) + ENOSPC = syscall.Errno(0x1c) + ENOSR = syscall.Errno(0x5a) + ENOSTR = syscall.Errno(0x5b) + ENOSYS = syscall.Errno(0x4e) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x39) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x42) + ENOTSOCK = syscall.Errno(0x26) + ENOTSUP = syscall.Errno(0x56) + ENOTTY = syscall.Errno(0x19) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x2d) + EOVERFLOW = syscall.Errno(0x54) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x2e) + EPIPE = syscall.Errno(0x20) + EPROCLIM = syscall.Errno(0x43) + EPROCUNAVAIL = syscall.Errno(0x4c) + EPROGMISMATCH = syscall.Errno(0x4b) + EPROGUNAVAIL = syscall.Errno(0x4a) + EPROTO = syscall.Errno(0x60) + EPROTONOSUPPORT = syscall.Errno(0x2b) + EPROTOTYPE = syscall.Errno(0x29) + ERANGE = syscall.Errno(0x22) + EREMOTE = syscall.Errno(0x47) + EROFS = syscall.Errno(0x1e) + ERPCMISMATCH = syscall.Errno(0x49) + ESHUTDOWN = syscall.Errno(0x3a) + ESOCKTNOSUPPORT = syscall.Errno(0x2c) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESTALE = syscall.Errno(0x46) + ETIME = syscall.Errno(0x5c) + ETIMEDOUT = syscall.Errno(0x3c) + ETOOMANYREFS = syscall.Errno(0x3b) + ETXTBSY = syscall.Errno(0x1a) + EUSERS = syscall.Errno(0x44) + EWOULDBLOCK = syscall.Errno(0x23) + EXDEV = syscall.Errno(0x12) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0xa) + SIGCHLD = syscall.Signal(0x14) + SIGCONT = syscall.Signal(0x13) + SIGEMT = syscall.Signal(0x7) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINFO = syscall.Signal(0x1d) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x17) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPROF = syscall.Signal(0x1b) + SIGPWR = syscall.Signal(0x20) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTOP = syscall.Signal(0x11) + SIGSYS = syscall.Signal(0xc) + SIGTERM = syscall.Signal(0xf) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x12) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGURG = syscall.Signal(0x10) + SIGUSR1 = syscall.Signal(0x1e) + SIGUSR2 = syscall.Signal(0x1f) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "device not configured", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource deadlock avoided", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device busy", + 17: "file exists", + 18: "cross-device link", + 19: "operation not supported by device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "result too large or too small", + 35: "resource temporarily unavailable", + 36: "operation now in progress", + 37: "operation already in progress", + 38: "socket operation on non-socket", + 39: "destination address required", + 40: "message too long", + 41: "protocol wrong type for socket", + 42: "protocol option not available", + 43: "protocol not supported", + 44: "socket type not supported", + 45: "operation not supported", + 46: "protocol family not supported", + 47: "address family not supported by protocol family", + 48: "address already in use", + 49: "can't assign requested address", + 50: "network is down", + 51: "network is unreachable", + 52: "network dropped connection on reset", + 53: "software caused connection abort", + 54: "connection reset by peer", + 55: "no buffer space available", + 56: "socket is already connected", + 57: "socket is not connected", + 58: "can't send after socket shutdown", + 59: "too many references: can't splice", + 60: "connection timed out", + 61: "connection refused", + 62: "too many levels of symbolic links", + 63: "file name too long", + 64: "host is down", + 65: "no route to host", + 66: "directory not empty", + 67: "too many processes", + 68: "too many users", + 69: "disc quota exceeded", + 70: "stale NFS file handle", + 71: "too many levels of remote in path", + 72: "RPC struct is bad", + 73: "RPC version wrong", + 74: "RPC prog. not avail", + 75: "program version wrong", + 76: "bad procedure for program", + 77: "no locks available", + 78: "function not implemented", + 79: "inappropriate file type or format", + 80: "authentication error", + 81: "need authenticator", + 82: "identifier removed", + 83: "no message of desired type", + 84: "value too large to be stored in data type", + 85: "illegal byte sequence", + 86: "not supported", + 87: "operation Canceled", + 88: "bad or Corrupt message", + 89: "no message available", + 90: "no STREAM resources", + 91: "not a STREAM", + 92: "STREAM ioctl timeout", + 93: "attribute not found", + 94: "multihop attempted", + 95: "link has been severed", + 96: "protocol error", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/BPT trap", + 6: "abort trap", + 7: "EMT trap", + 8: "floating point exception", + 9: "killed", + 10: "bus error", + 11: "segmentation fault", + 12: "bad system call", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "urgent I/O condition", + 17: "stopped (signal)", + 18: "stopped", + 19: "continued", + 20: "child exited", + 21: "stopped (tty input)", + 22: "stopped (tty output)", + 23: "I/O possible", + 24: "cputime limit exceeded", + 25: "filesize limit exceeded", + 26: "virtual timer expired", + 27: "profiling timer expired", + 28: "window size changes", + 29: "information request", + 30: "user defined signal 1", + 31: "user defined signal 2", + 32: "power fail/restart", +} diff --git a/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm.go b/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm.go new file mode 100644 index 0000000000..ac85ca6452 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_netbsd_arm.go @@ -0,0 +1,1688 @@ +// mkerrors.sh -marm +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build arm,netbsd + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -marm _const.go + +package unix + +import "syscall" + +const ( + AF_APPLETALK = 0x10 + AF_ARP = 0x1c + AF_BLUETOOTH = 0x1f + AF_CCITT = 0xa + AF_CHAOS = 0x5 + AF_CNT = 0x15 + AF_COIP = 0x14 + AF_DATAKIT = 0x9 + AF_DECnet = 0xc + AF_DLI = 0xd + AF_E164 = 0x1a + AF_ECMA = 0x8 + AF_HYLINK = 0xf + AF_IEEE80211 = 0x20 + AF_IMPLINK = 0x3 + AF_INET = 0x2 + AF_INET6 = 0x18 + AF_IPX = 0x17 + AF_ISDN = 0x1a + AF_ISO = 0x7 + AF_LAT = 0xe + AF_LINK = 0x12 + AF_LOCAL = 0x1 + AF_MAX = 0x23 + AF_MPLS = 0x21 + AF_NATM = 0x1b + AF_NS = 0x6 + AF_OROUTE = 0x11 + AF_OSI = 0x7 + AF_PUP = 0x4 + AF_ROUTE = 0x22 + AF_SNA = 0xb + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + ARPHRD_ARCNET = 0x7 + ARPHRD_ETHER = 0x1 + ARPHRD_FRELAY = 0xf + ARPHRD_IEEE1394 = 0x18 + ARPHRD_IEEE802 = 0x6 + ARPHRD_STRIP = 0x17 + B0 = 0x0 + B110 = 0x6e + B115200 = 0x1c200 + B1200 = 0x4b0 + B134 = 0x86 + B14400 = 0x3840 + B150 = 0x96 + B1800 = 0x708 + B19200 = 0x4b00 + B200 = 0xc8 + B230400 = 0x38400 + B2400 = 0x960 + B28800 = 0x7080 + B300 = 0x12c + B38400 = 0x9600 + B460800 = 0x70800 + B4800 = 0x12c0 + B50 = 0x32 + B57600 = 0xe100 + B600 = 0x258 + B7200 = 0x1c20 + B75 = 0x4b + B76800 = 0x12c00 + B921600 = 0xe1000 + B9600 = 0x2580 + BIOCFEEDBACK = 0x8004427d + BIOCFLUSH = 0x20004268 + BIOCGBLEN = 0x40044266 + BIOCGDLT = 0x4004426a + BIOCGDLTLIST = 0xc0084277 + BIOCGETIF = 0x4090426b + BIOCGFEEDBACK = 0x4004427c + BIOCGHDRCMPLT = 0x40044274 + BIOCGRTIMEOUT = 0x400c427b + BIOCGSEESENT = 0x40044278 + BIOCGSTATS = 0x4080426f + BIOCGSTATSOLD = 0x4008426f + BIOCIMMEDIATE = 0x80044270 + BIOCPROMISC = 0x20004269 + BIOCSBLEN = 0xc0044266 + BIOCSDLT = 0x80044276 + BIOCSETF = 0x80084267 + BIOCSETIF = 0x8090426c + BIOCSFEEDBACK = 0x8004427d + BIOCSHDRCMPLT = 0x80044275 + BIOCSRTIMEOUT = 0x800c427a + BIOCSSEESENT = 0x80044279 + BIOCSTCPF = 0x80084272 + BIOCSUDPF = 0x80084273 + BIOCVERSION = 0x40044271 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALIGNMENT = 0x4 + BPF_ALIGNMENT32 = 0x4 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DFLTBUFSIZE = 0x100000 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXBUFSIZE = 0x1000000 + BPF_MAXINSNS = 0x200 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINBUFSIZE = 0x20 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RELEASE = 0x30bb6 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BRKINT = 0x2 + CFLUSH = 0xf + CLOCAL = 0x8000 + CREAD = 0x800 + CS5 = 0x0 + CS6 = 0x100 + CS7 = 0x200 + CS8 = 0x300 + CSIZE = 0x300 + CSTART = 0x11 + CSTATUS = 0x14 + CSTOP = 0x13 + CSTOPB = 0x400 + CSUSP = 0x1a + CTL_MAXNAME = 0xc + CTL_NET = 0x4 + CTL_QUERY = -0x2 + DIOCBSFLUSH = 0x20006478 + DLT_A429 = 0xb8 + DLT_A653_ICM = 0xb9 + DLT_AIRONET_HEADER = 0x78 + DLT_AOS = 0xde + DLT_APPLE_IP_OVER_IEEE1394 = 0x8a + DLT_ARCNET = 0x7 + DLT_ARCNET_LINUX = 0x81 + DLT_ATM_CLIP = 0x13 + DLT_ATM_RFC1483 = 0xb + DLT_AURORA = 0x7e + DLT_AX25 = 0x3 + DLT_AX25_KISS = 0xca + DLT_BACNET_MS_TP = 0xa5 + DLT_BLUETOOTH_HCI_H4 = 0xbb + DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9 + DLT_CAN20B = 0xbe + DLT_CAN_SOCKETCAN = 0xe3 + DLT_CHAOS = 0x5 + DLT_CISCO_IOS = 0x76 + DLT_C_HDLC = 0x68 + DLT_C_HDLC_WITH_DIR = 0xcd + DLT_DECT = 0xdd + DLT_DOCSIS = 0x8f + DLT_ECONET = 0x73 + DLT_EN10MB = 0x1 + DLT_EN3MB = 0x2 + DLT_ENC = 0x6d + DLT_ERF = 0xc5 + DLT_ERF_ETH = 0xaf + DLT_ERF_POS = 0xb0 + DLT_FC_2 = 0xe0 + DLT_FC_2_WITH_FRAME_DELIMS = 0xe1 + DLT_FDDI = 0xa + DLT_FLEXRAY = 0xd2 + DLT_FRELAY = 0x6b + DLT_FRELAY_WITH_DIR = 0xce + DLT_GCOM_SERIAL = 0xad + DLT_GCOM_T1E1 = 0xac + DLT_GPF_F = 0xab + DLT_GPF_T = 0xaa + DLT_GPRS_LLC = 0xa9 + DLT_GSMTAP_ABIS = 0xda + DLT_GSMTAP_UM = 0xd9 + DLT_HDLC = 0x10 + DLT_HHDLC = 0x79 + DLT_HIPPI = 0xf + DLT_IBM_SN = 0x92 + DLT_IBM_SP = 0x91 + DLT_IEEE802 = 0x6 + DLT_IEEE802_11 = 0x69 + DLT_IEEE802_11_RADIO = 0x7f + DLT_IEEE802_11_RADIO_AVS = 0xa3 + DLT_IEEE802_15_4 = 0xc3 + DLT_IEEE802_15_4_LINUX = 0xbf + DLT_IEEE802_15_4_NONASK_PHY = 0xd7 + DLT_IEEE802_16_MAC_CPS = 0xbc + DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1 + DLT_IPMB = 0xc7 + DLT_IPMB_LINUX = 0xd1 + DLT_IPNET = 0xe2 + DLT_IPV4 = 0xe4 + DLT_IPV6 = 0xe5 + DLT_IP_OVER_FC = 0x7a + DLT_JUNIPER_ATM1 = 0x89 + DLT_JUNIPER_ATM2 = 0x87 + DLT_JUNIPER_CHDLC = 0xb5 + DLT_JUNIPER_ES = 0x84 + DLT_JUNIPER_ETHER = 0xb2 + DLT_JUNIPER_FRELAY = 0xb4 + DLT_JUNIPER_GGSN = 0x85 + DLT_JUNIPER_ISM = 0xc2 + DLT_JUNIPER_MFR = 0x86 + DLT_JUNIPER_MLFR = 0x83 + DLT_JUNIPER_MLPPP = 0x82 + DLT_JUNIPER_MONITOR = 0xa4 + DLT_JUNIPER_PIC_PEER = 0xae + DLT_JUNIPER_PPP = 0xb3 + DLT_JUNIPER_PPPOE = 0xa7 + DLT_JUNIPER_PPPOE_ATM = 0xa8 + DLT_JUNIPER_SERVICES = 0x88 + DLT_JUNIPER_ST = 0xc8 + DLT_JUNIPER_VP = 0xb7 + DLT_LAPB_WITH_DIR = 0xcf + DLT_LAPD = 0xcb + DLT_LIN = 0xd4 + DLT_LINUX_EVDEV = 0xd8 + DLT_LINUX_IRDA = 0x90 + DLT_LINUX_LAPD = 0xb1 + DLT_LINUX_SLL = 0x71 + DLT_LOOP = 0x6c + DLT_LTALK = 0x72 + DLT_MFR = 0xb6 + DLT_MOST = 0xd3 + DLT_MPLS = 0xdb + DLT_MTP2 = 0x8c + DLT_MTP2_WITH_PHDR = 0x8b + DLT_MTP3 = 0x8d + DLT_NULL = 0x0 + DLT_PCI_EXP = 0x7d + DLT_PFLOG = 0x75 + DLT_PFSYNC = 0x12 + DLT_PPI = 0xc0 + DLT_PPP = 0x9 + DLT_PPP_BSDOS = 0xe + DLT_PPP_ETHER = 0x33 + DLT_PPP_PPPD = 0xa6 + DLT_PPP_SERIAL = 0x32 + DLT_PPP_WITH_DIR = 0xcc + DLT_PRISM_HEADER = 0x77 + DLT_PRONET = 0x4 + DLT_RAIF1 = 0xc6 + DLT_RAW = 0xc + DLT_RAWAF_MASK = 0x2240000 + DLT_RIO = 0x7c + DLT_SCCP = 0x8e + DLT_SITA = 0xc4 + DLT_SLIP = 0x8 + DLT_SLIP_BSDOS = 0xd + DLT_SUNATM = 0x7b + DLT_SYMANTEC_FIREWALL = 0x63 + DLT_TZSP = 0x80 + DLT_USB = 0xba + DLT_USB_LINUX = 0xbd + DLT_USB_LINUX_MMAPPED = 0xdc + DLT_WIHART = 0xdf + DLT_X2E_SERIAL = 0xd5 + DLT_X2E_XORAYA = 0xd6 + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + DT_WHT = 0xe + ECHO = 0x8 + ECHOCTL = 0x40 + ECHOE = 0x2 + ECHOK = 0x4 + ECHOKE = 0x1 + ECHONL = 0x10 + ECHOPRT = 0x20 + EMUL_LINUX = 0x1 + EMUL_LINUX32 = 0x5 + EMUL_MAXID = 0x6 + ETHERCAP_JUMBO_MTU = 0x4 + ETHERCAP_VLAN_HWTAGGING = 0x2 + ETHERCAP_VLAN_MTU = 0x1 + ETHERMIN = 0x2e + ETHERMTU = 0x5dc + ETHERMTU_JUMBO = 0x2328 + ETHERTYPE_8023 = 0x4 + ETHERTYPE_AARP = 0x80f3 + ETHERTYPE_ACCTON = 0x8390 + ETHERTYPE_AEONIC = 0x8036 + ETHERTYPE_ALPHA = 0x814a + ETHERTYPE_AMBER = 0x6008 + ETHERTYPE_AMOEBA = 0x8145 + ETHERTYPE_APOLLO = 0x80f7 + ETHERTYPE_APOLLODOMAIN = 0x8019 + ETHERTYPE_APPLETALK = 0x809b + ETHERTYPE_APPLITEK = 0x80c7 + ETHERTYPE_ARGONAUT = 0x803a + ETHERTYPE_ARP = 0x806 + ETHERTYPE_AT = 0x809b + ETHERTYPE_ATALK = 0x809b + ETHERTYPE_ATOMIC = 0x86df + ETHERTYPE_ATT = 0x8069 + ETHERTYPE_ATTSTANFORD = 0x8008 + ETHERTYPE_AUTOPHON = 0x806a + ETHERTYPE_AXIS = 0x8856 + ETHERTYPE_BCLOOP = 0x9003 + ETHERTYPE_BOFL = 0x8102 + ETHERTYPE_CABLETRON = 0x7034 + ETHERTYPE_CHAOS = 0x804 + ETHERTYPE_COMDESIGN = 0x806c + ETHERTYPE_COMPUGRAPHIC = 0x806d + ETHERTYPE_COUNTERPOINT = 0x8062 + ETHERTYPE_CRONUS = 0x8004 + ETHERTYPE_CRONUSVLN = 0x8003 + ETHERTYPE_DCA = 0x1234 + ETHERTYPE_DDE = 0x807b + ETHERTYPE_DEBNI = 0xaaaa + ETHERTYPE_DECAM = 0x8048 + ETHERTYPE_DECCUST = 0x6006 + ETHERTYPE_DECDIAG = 0x6005 + ETHERTYPE_DECDNS = 0x803c + ETHERTYPE_DECDTS = 0x803e + ETHERTYPE_DECEXPER = 0x6000 + ETHERTYPE_DECLAST = 0x8041 + ETHERTYPE_DECLTM = 0x803f + ETHERTYPE_DECMUMPS = 0x6009 + ETHERTYPE_DECNETBIOS = 0x8040 + ETHERTYPE_DELTACON = 0x86de + ETHERTYPE_DIDDLE = 0x4321 + ETHERTYPE_DLOG1 = 0x660 + ETHERTYPE_DLOG2 = 0x661 + ETHERTYPE_DN = 0x6003 + ETHERTYPE_DOGFIGHT = 0x1989 + ETHERTYPE_DSMD = 0x8039 + ETHERTYPE_ECMA = 0x803 + ETHERTYPE_ENCRYPT = 0x803d + ETHERTYPE_ES = 0x805d + ETHERTYPE_EXCELAN = 0x8010 + ETHERTYPE_EXPERDATA = 0x8049 + ETHERTYPE_FLIP = 0x8146 + ETHERTYPE_FLOWCONTROL = 0x8808 + ETHERTYPE_FRARP = 0x808 + ETHERTYPE_GENDYN = 0x8068 + ETHERTYPE_HAYES = 0x8130 + ETHERTYPE_HIPPI_FP = 0x8180 + ETHERTYPE_HITACHI = 0x8820 + ETHERTYPE_HP = 0x8005 + ETHERTYPE_IEEEPUP = 0xa00 + ETHERTYPE_IEEEPUPAT = 0xa01 + ETHERTYPE_IMLBL = 0x4c42 + ETHERTYPE_IMLBLDIAG = 0x424c + ETHERTYPE_IP = 0x800 + ETHERTYPE_IPAS = 0x876c + ETHERTYPE_IPV6 = 0x86dd + ETHERTYPE_IPX = 0x8137 + ETHERTYPE_IPXNEW = 0x8037 + ETHERTYPE_KALPANA = 0x8582 + ETHERTYPE_LANBRIDGE = 0x8038 + ETHERTYPE_LANPROBE = 0x8888 + ETHERTYPE_LAT = 0x6004 + ETHERTYPE_LBACK = 0x9000 + ETHERTYPE_LITTLE = 0x8060 + ETHERTYPE_LOGICRAFT = 0x8148 + ETHERTYPE_LOOPBACK = 0x9000 + ETHERTYPE_MATRA = 0x807a + ETHERTYPE_MAX = 0xffff + ETHERTYPE_MERIT = 0x807c + ETHERTYPE_MICP = 0x873a + ETHERTYPE_MOPDL = 0x6001 + ETHERTYPE_MOPRC = 0x6002 + ETHERTYPE_MOTOROLA = 0x818d + ETHERTYPE_MPLS = 0x8847 + ETHERTYPE_MPLS_MCAST = 0x8848 + ETHERTYPE_MUMPS = 0x813f + ETHERTYPE_NBPCC = 0x3c04 + ETHERTYPE_NBPCLAIM = 0x3c09 + ETHERTYPE_NBPCLREQ = 0x3c05 + ETHERTYPE_NBPCLRSP = 0x3c06 + ETHERTYPE_NBPCREQ = 0x3c02 + ETHERTYPE_NBPCRSP = 0x3c03 + ETHERTYPE_NBPDG = 0x3c07 + ETHERTYPE_NBPDGB = 0x3c08 + ETHERTYPE_NBPDLTE = 0x3c0a + ETHERTYPE_NBPRAR = 0x3c0c + ETHERTYPE_NBPRAS = 0x3c0b + ETHERTYPE_NBPRST = 0x3c0d + ETHERTYPE_NBPSCD = 0x3c01 + ETHERTYPE_NBPVCD = 0x3c00 + ETHERTYPE_NBS = 0x802 + ETHERTYPE_NCD = 0x8149 + ETHERTYPE_NESTAR = 0x8006 + ETHERTYPE_NETBEUI = 0x8191 + ETHERTYPE_NOVELL = 0x8138 + ETHERTYPE_NS = 0x600 + ETHERTYPE_NSAT = 0x601 + ETHERTYPE_NSCOMPAT = 0x807 + ETHERTYPE_NTRAILER = 0x10 + ETHERTYPE_OS9 = 0x7007 + ETHERTYPE_OS9NET = 0x7009 + ETHERTYPE_PACER = 0x80c6 + ETHERTYPE_PAE = 0x888e + ETHERTYPE_PCS = 0x4242 + ETHERTYPE_PLANNING = 0x8044 + ETHERTYPE_PPP = 0x880b + ETHERTYPE_PPPOE = 0x8864 + ETHERTYPE_PPPOEDISC = 0x8863 + ETHERTYPE_PRIMENTS = 0x7031 + ETHERTYPE_PUP = 0x200 + ETHERTYPE_PUPAT = 0x200 + ETHERTYPE_RACAL = 0x7030 + ETHERTYPE_RATIONAL = 0x8150 + ETHERTYPE_RAWFR = 0x6559 + ETHERTYPE_RCL = 0x1995 + ETHERTYPE_RDP = 0x8739 + ETHERTYPE_RETIX = 0x80f2 + ETHERTYPE_REVARP = 0x8035 + ETHERTYPE_SCA = 0x6007 + ETHERTYPE_SECTRA = 0x86db + ETHERTYPE_SECUREDATA = 0x876d + ETHERTYPE_SGITW = 0x817e + ETHERTYPE_SG_BOUNCE = 0x8016 + ETHERTYPE_SG_DIAG = 0x8013 + ETHERTYPE_SG_NETGAMES = 0x8014 + ETHERTYPE_SG_RESV = 0x8015 + ETHERTYPE_SIMNET = 0x5208 + ETHERTYPE_SLOWPROTOCOLS = 0x8809 + ETHERTYPE_SNA = 0x80d5 + ETHERTYPE_SNMP = 0x814c + ETHERTYPE_SONIX = 0xfaf5 + ETHERTYPE_SPIDER = 0x809f + ETHERTYPE_SPRITE = 0x500 + ETHERTYPE_STP = 0x8181 + ETHERTYPE_TALARIS = 0x812b + ETHERTYPE_TALARISMC = 0x852b + ETHERTYPE_TCPCOMP = 0x876b + ETHERTYPE_TCPSM = 0x9002 + ETHERTYPE_TEC = 0x814f + ETHERTYPE_TIGAN = 0x802f + ETHERTYPE_TRAIL = 0x1000 + ETHERTYPE_TRANSETHER = 0x6558 + ETHERTYPE_TYMSHARE = 0x802e + ETHERTYPE_UBBST = 0x7005 + ETHERTYPE_UBDEBUG = 0x900 + ETHERTYPE_UBDIAGLOOP = 0x7002 + ETHERTYPE_UBDL = 0x7000 + ETHERTYPE_UBNIU = 0x7001 + ETHERTYPE_UBNMC = 0x7003 + ETHERTYPE_VALID = 0x1600 + ETHERTYPE_VARIAN = 0x80dd + ETHERTYPE_VAXELN = 0x803b + ETHERTYPE_VEECO = 0x8067 + ETHERTYPE_VEXP = 0x805b + ETHERTYPE_VGLAB = 0x8131 + ETHERTYPE_VINES = 0xbad + ETHERTYPE_VINESECHO = 0xbaf + ETHERTYPE_VINESLOOP = 0xbae + ETHERTYPE_VITAL = 0xff00 + ETHERTYPE_VLAN = 0x8100 + ETHERTYPE_VLTLMAN = 0x8080 + ETHERTYPE_VPROD = 0x805c + ETHERTYPE_VURESERVED = 0x8147 + ETHERTYPE_WATERLOO = 0x8130 + ETHERTYPE_WELLFLEET = 0x8103 + ETHERTYPE_X25 = 0x805 + ETHERTYPE_X75 = 0x801 + ETHERTYPE_XNSSM = 0x9001 + ETHERTYPE_XTP = 0x817d + ETHER_ADDR_LEN = 0x6 + ETHER_CRC_LEN = 0x4 + ETHER_CRC_POLY_BE = 0x4c11db6 + ETHER_CRC_POLY_LE = 0xedb88320 + ETHER_HDR_LEN = 0xe + ETHER_MAX_LEN = 0x5ee + ETHER_MAX_LEN_JUMBO = 0x233a + ETHER_MIN_LEN = 0x40 + ETHER_PPPOE_ENCAP_LEN = 0x8 + ETHER_TYPE_LEN = 0x2 + ETHER_VLAN_ENCAP_LEN = 0x4 + EVFILT_AIO = 0x2 + EVFILT_PROC = 0x4 + EVFILT_READ = 0x0 + EVFILT_SIGNAL = 0x5 + EVFILT_SYSCOUNT = 0x7 + EVFILT_TIMER = 0x6 + EVFILT_VNODE = 0x3 + EVFILT_WRITE = 0x1 + EV_ADD = 0x1 + EV_CLEAR = 0x20 + EV_DELETE = 0x2 + EV_DISABLE = 0x8 + EV_ENABLE = 0x4 + EV_EOF = 0x8000 + EV_ERROR = 0x4000 + EV_FLAG1 = 0x2000 + EV_ONESHOT = 0x10 + EV_SYSFLAGS = 0xf000 + EXTA = 0x4b00 + EXTB = 0x9600 + EXTPROC = 0x800 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x100 + FLUSHO = 0x800000 + F_CLOSEM = 0xa + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0xc + F_FSCTL = -0x80000000 + F_FSDIRMASK = 0x70000000 + F_FSIN = 0x10000000 + F_FSINOUT = 0x30000000 + F_FSOUT = 0x20000000 + F_FSPRIV = 0x8000 + F_FSVOID = 0x40000000 + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLK = 0x7 + F_GETNOSIGPIPE = 0xd + F_GETOWN = 0x5 + F_MAXFD = 0xb + F_OK = 0x0 + F_PARAM_MASK = 0xfff + F_PARAM_MAX = 0xfff + F_RDLCK = 0x1 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLK = 0x8 + F_SETLKW = 0x9 + F_SETNOSIGPIPE = 0xe + F_SETOWN = 0x6 + F_UNLCK = 0x2 + F_WRLCK = 0x3 + HUPCL = 0x4000 + ICANON = 0x100 + ICMP6_FILTER = 0x12 + ICRNL = 0x100 + IEXTEN = 0x400 + IFAN_ARRIVAL = 0x0 + IFAN_DEPARTURE = 0x1 + IFA_ROUTE = 0x1 + IFF_ALLMULTI = 0x200 + IFF_BROADCAST = 0x2 + IFF_CANTCHANGE = 0x8f52 + IFF_DEBUG = 0x4 + IFF_LINK0 = 0x1000 + IFF_LINK1 = 0x2000 + IFF_LINK2 = 0x4000 + IFF_LOOPBACK = 0x8 + IFF_MULTICAST = 0x8000 + IFF_NOARP = 0x80 + IFF_NOTRAILERS = 0x20 + IFF_OACTIVE = 0x400 + IFF_POINTOPOINT = 0x10 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SIMPLEX = 0x800 + IFF_UP = 0x1 + IFNAMSIZ = 0x10 + 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_BRIDGE = 0xd1 + IFT_BSC = 0x53 + IFT_CARP = 0xf8 + 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_DOCSCABLEUPSTREAMCHANNEL = 0xcd + 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_ECONET = 0xce + 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_IEEE1394 = 0x90 + IFT_IEEE80211 = 0x47 + IFT_IEEE80212 = 0x37 + IFT_IEEE8023ADLAG = 0xa1 + IFT_IFGSN = 0x91 + IFT_IMT = 0xbe + IFT_INFINIBAND = 0xc7 + IFT_INTERLEAVE = 0x7c + IFT_IP = 0x7e + IFT_IPFORWARD = 0x8e + IFT_IPOVERATM = 0x72 + IFT_IPOVERCDLC = 0x6d + IFT_IPOVERCLAW = 0x6e + IFT_IPSWITCH = 0x4e + 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_L2VLAN = 0x87 + IFT_L3IPVLAN = 0x88 + IFT_L3IPXVLAN = 0x89 + IFT_LAPB = 0x10 + IFT_LAPD = 0x4d + IFT_LAPF = 0x77 + IFT_LINEGROUP = 0xd2 + 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 = 0xf5 + IFT_PFSYNC = 0xf6 + IFT_PLC = 0xae + IFT_PON155 = 0xcf + IFT_PON622 = 0xd0 + IFT_POS = 0xab + IFT_PPP = 0x17 + IFT_PPPMULTILINKBUNDLE = 0x6c + IFT_PROPATM = 0xc5 + IFT_PROPBWAP2MP = 0xb8 + IFT_PROPCNLS = 0x59 + IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5 + IFT_PROPDOCSWIRELESSMACLAYER = 0xb4 + IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6 + IFT_PROPMUX = 0x36 + IFT_PROPVIRTUAL = 0x35 + IFT_PROPWIRELESSP2P = 0x9d + IFT_PTPSERIAL = 0x16 + IFT_PVC = 0xf1 + IFT_Q2931 = 0xc9 + 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_SIPSIG = 0xcc + IFT_SIPTG = 0xcb + 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_TELINK = 0xc8 + 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_VIRTUALTG = 0xca + IFT_VOICEDID = 0xd5 + IFT_VOICEEM = 0x64 + IFT_VOICEEMFGD = 0xd3 + IFT_VOICEENCAP = 0x67 + IFT_VOICEFGDEANA = 0xd4 + IFT_VOICEFXO = 0x65 + IFT_VOICEFXS = 0x66 + IFT_VOICEOVERATM = 0x98 + IFT_VOICEOVERCABLE = 0xc6 + 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 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLASSD_HOST = 0xfffffff + IN_CLASSD_NET = 0xf0000000 + IN_CLASSD_NSHIFT = 0x1c + IN_LOOPBACKNET = 0x7f + IPPROTO_AH = 0x33 + IPPROTO_CARP = 0x70 + IPPROTO_DONE = 0x101 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_ENCAP = 0x62 + IPPROTO_EON = 0x50 + IPPROTO_ESP = 0x32 + IPPROTO_ETHERIP = 0x61 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GGP = 0x3 + IPPROTO_GRE = 0x2f + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IGMP = 0x2 + IPPROTO_IP = 0x0 + IPPROTO_IPCOMP = 0x6c + IPPROTO_IPIP = 0x4 + IPPROTO_IPV4 = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_IPV6_ICMP = 0x3a + IPPROTO_MAX = 0x100 + IPPROTO_MAXID = 0x34 + IPPROTO_MOBILE = 0x37 + IPPROTO_NONE = 0x3b + IPPROTO_PFSYNC = 0xf0 + IPPROTO_PIM = 0x67 + IPPROTO_PUP = 0xc + IPPROTO_RAW = 0xff + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_UDP = 0x11 + IPPROTO_VRRP = 0x70 + IPV6_CHECKSUM = 0x1a + IPV6_DEFAULT_MULTICAST_HOPS = 0x1 + IPV6_DEFAULT_MULTICAST_LOOP = 0x1 + IPV6_DEFHLIM = 0x40 + IPV6_DONTFRAG = 0x3e + IPV6_DSTOPTS = 0x32 + IPV6_FAITH = 0x1d + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 + IPV6_FRAGTTL = 0x78 + IPV6_HLIMDEC = 0x1 + IPV6_HOPLIMIT = 0x2f + IPV6_HOPOPTS = 0x31 + IPV6_IPSEC_POLICY = 0x1c + IPV6_JOIN_GROUP = 0xc + IPV6_LEAVE_GROUP = 0xd + IPV6_MAXHLIM = 0xff + IPV6_MAXPACKET = 0xffff + IPV6_MMTU = 0x500 + IPV6_MULTICAST_HOPS = 0xa + IPV6_MULTICAST_IF = 0x9 + IPV6_MULTICAST_LOOP = 0xb + IPV6_NEXTHOP = 0x30 + IPV6_PATHMTU = 0x2c + IPV6_PKTINFO = 0x2e + IPV6_PORTRANGE = 0xe + IPV6_PORTRANGE_DEFAULT = 0x0 + IPV6_PORTRANGE_HIGH = 0x1 + IPV6_PORTRANGE_LOW = 0x2 + IPV6_RECVDSTOPTS = 0x28 + IPV6_RECVHOPLIMIT = 0x25 + IPV6_RECVHOPOPTS = 0x27 + IPV6_RECVPATHMTU = 0x2b + IPV6_RECVPKTINFO = 0x24 + IPV6_RECVRTHDR = 0x26 + IPV6_RECVTCLASS = 0x39 + IPV6_RTHDR = 0x33 + IPV6_RTHDRDSTOPTS = 0x23 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_SOCKOPT_RESERVED1 = 0x3 + IPV6_TCLASS = 0x3d + IPV6_UNICAST_HOPS = 0x4 + IPV6_USE_MIN_MTU = 0x2a + IPV6_V6ONLY = 0x1b + IPV6_VERSION = 0x60 + IPV6_VERSION_MASK = 0xf0 + IP_ADD_MEMBERSHIP = 0xc + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DROP_MEMBERSHIP = 0xd + IP_EF = 0x8000 + IP_ERRORMTU = 0x15 + IP_HDRINCL = 0x2 + IP_IPSEC_POLICY = 0x16 + IP_MAXPACKET = 0xffff + IP_MAX_MEMBERSHIPS = 0x14 + IP_MF = 0x2000 + IP_MINFRAGSIZE = 0x45 + IP_MINTTL = 0x18 + IP_MSS = 0x240 + IP_MULTICAST_IF = 0x9 + IP_MULTICAST_LOOP = 0xb + IP_MULTICAST_TTL = 0xa + IP_OFFMASK = 0x1fff + IP_OPTIONS = 0x1 + IP_PORTRANGE = 0x13 + IP_PORTRANGE_DEFAULT = 0x0 + IP_PORTRANGE_HIGH = 0x1 + IP_PORTRANGE_LOW = 0x2 + IP_RECVDSTADDR = 0x7 + IP_RECVIF = 0x14 + IP_RECVOPTS = 0x5 + IP_RECVRETOPTS = 0x6 + IP_RECVTTL = 0x17 + IP_RETOPTS = 0x8 + IP_RF = 0x8000 + IP_TOS = 0x3 + IP_TTL = 0x4 + ISIG = 0x80 + ISTRIP = 0x20 + IXANY = 0x800 + IXOFF = 0x400 + IXON = 0x200 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_DONTNEED = 0x4 + MADV_FREE = 0x6 + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_SEQUENTIAL = 0x2 + MADV_SPACEAVAIL = 0x5 + MADV_WILLNEED = 0x3 + MAP_ALIGNMENT_16MB = 0x18000000 + MAP_ALIGNMENT_1TB = 0x28000000 + MAP_ALIGNMENT_256TB = 0x30000000 + MAP_ALIGNMENT_4GB = 0x20000000 + MAP_ALIGNMENT_64KB = 0x10000000 + MAP_ALIGNMENT_64PB = 0x38000000 + MAP_ALIGNMENT_MASK = -0x1000000 + MAP_ALIGNMENT_SHIFT = 0x18 + MAP_ANON = 0x1000 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_HASSEMAPHORE = 0x200 + MAP_INHERIT = 0x80 + MAP_INHERIT_COPY = 0x1 + MAP_INHERIT_DEFAULT = 0x1 + MAP_INHERIT_DONATE_COPY = 0x3 + MAP_INHERIT_NONE = 0x2 + MAP_INHERIT_SHARE = 0x0 + MAP_NORESERVE = 0x40 + MAP_PRIVATE = 0x2 + MAP_RENAME = 0x20 + MAP_SHARED = 0x1 + MAP_STACK = 0x2000 + MAP_TRYFIXED = 0x400 + MAP_WIRED = 0x800 + MSG_BCAST = 0x100 + MSG_CMSG_CLOEXEC = 0x800 + MSG_CONTROLMBUF = 0x2000000 + MSG_CTRUNC = 0x20 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x80 + MSG_EOR = 0x8 + MSG_IOVUSRSPACE = 0x4000000 + MSG_LENUSRSPACE = 0x8000000 + MSG_MCAST = 0x200 + MSG_NAMEMBUF = 0x1000000 + MSG_NBIO = 0x1000 + MSG_NOSIGNAL = 0x400 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_TRUNC = 0x10 + MSG_USERFLAGS = 0xffffff + MSG_WAITALL = 0x40 + NAME_MAX = 0x1ff + NET_RT_DUMP = 0x1 + NET_RT_FLAGS = 0x2 + NET_RT_IFLIST = 0x5 + NET_RT_MAXID = 0x6 + NET_RT_OIFLIST = 0x4 + NET_RT_OOIFLIST = 0x3 + NOFLSH = 0x80000000 + NOTE_ATTRIB = 0x8 + NOTE_CHILD = 0x4 + NOTE_DELETE = 0x1 + NOTE_EXEC = 0x20000000 + NOTE_EXIT = 0x80000000 + NOTE_EXTEND = 0x4 + NOTE_FORK = 0x40000000 + NOTE_LINK = 0x10 + NOTE_LOWAT = 0x1 + NOTE_PCTRLMASK = 0xf0000000 + NOTE_PDATAMASK = 0xfffff + NOTE_RENAME = 0x20 + NOTE_REVOKE = 0x40 + NOTE_TRACK = 0x1 + NOTE_TRACKERR = 0x2 + NOTE_WRITE = 0x2 + OCRNL = 0x10 + OFIOGETBMAP = 0xc004667a + ONLCR = 0x2 + ONLRET = 0x40 + ONOCR = 0x20 + ONOEOT = 0x8 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_ALT_IO = 0x40000 + O_APPEND = 0x8 + O_ASYNC = 0x40 + O_CLOEXEC = 0x400000 + O_CREAT = 0x200 + O_DIRECT = 0x80000 + O_DIRECTORY = 0x200000 + O_DSYNC = 0x10000 + O_EXCL = 0x800 + O_EXLOCK = 0x20 + O_FSYNC = 0x80 + O_NDELAY = 0x4 + O_NOCTTY = 0x8000 + O_NOFOLLOW = 0x100 + O_NONBLOCK = 0x4 + O_NOSIGPIPE = 0x1000000 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_RSYNC = 0x20000 + O_SHLOCK = 0x10 + O_SYNC = 0x80 + O_TRUNC = 0x400 + O_WRONLY = 0x1 + PARENB = 0x1000 + PARMRK = 0x8 + PARODD = 0x2000 + PENDIN = 0x20000000 + PROT_EXEC = 0x4 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + PRI_IOFLUSH = 0x7c + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + RLIMIT_AS = 0xa + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x8 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = 0x7fffffffffffffff + RTAX_AUTHOR = 0x6 + RTAX_BRD = 0x7 + RTAX_DST = 0x0 + RTAX_GATEWAY = 0x1 + RTAX_GENMASK = 0x3 + RTAX_IFA = 0x5 + RTAX_IFP = 0x4 + RTAX_MAX = 0x9 + RTAX_NETMASK = 0x2 + RTAX_TAG = 0x8 + RTA_AUTHOR = 0x40 + RTA_BRD = 0x80 + RTA_DST = 0x1 + RTA_GATEWAY = 0x2 + RTA_GENMASK = 0x8 + RTA_IFA = 0x20 + RTA_IFP = 0x10 + RTA_NETMASK = 0x4 + RTA_TAG = 0x100 + RTF_ANNOUNCE = 0x20000 + RTF_BLACKHOLE = 0x1000 + RTF_CLONED = 0x2000 + RTF_CLONING = 0x100 + RTF_DONE = 0x40 + RTF_DYNAMIC = 0x10 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_LLINFO = 0x400 + RTF_MASK = 0x80 + RTF_MODIFIED = 0x20 + RTF_PROTO1 = 0x8000 + RTF_PROTO2 = 0x4000 + RTF_REJECT = 0x8 + RTF_SRC = 0x10000 + RTF_STATIC = 0x800 + RTF_UP = 0x1 + RTF_XRESOLVE = 0x200 + RTM_ADD = 0x1 + RTM_CHANGE = 0x3 + RTM_CHGADDR = 0x15 + RTM_DELADDR = 0xd + RTM_DELETE = 0x2 + RTM_GET = 0x4 + RTM_IEEE80211 = 0x11 + RTM_IFANNOUNCE = 0x10 + RTM_IFINFO = 0x14 + RTM_LLINFO_UPD = 0x13 + RTM_LOCK = 0x8 + RTM_LOSING = 0x5 + RTM_MISS = 0x7 + RTM_NEWADDR = 0xc + RTM_OIFINFO = 0xf + RTM_OLDADD = 0x9 + RTM_OLDDEL = 0xa + RTM_OOIFINFO = 0xe + RTM_REDIRECT = 0x6 + RTM_RESOLVE = 0xb + RTM_RTTUNIT = 0xf4240 + RTM_SETGATE = 0x12 + RTM_VERSION = 0x4 + RTV_EXPIRE = 0x4 + RTV_HOPCOUNT = 0x2 + RTV_MTU = 0x1 + RTV_RPIPE = 0x8 + RTV_RTT = 0x40 + RTV_RTTVAR = 0x80 + RTV_SPIPE = 0x10 + RTV_SSTHRESH = 0x20 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + SCM_CREDS = 0x4 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x8 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDMULTI = 0x80906931 + SIOCADDRT = 0x8030720a + SIOCAIFADDR = 0x8040691a + SIOCALIFADDR = 0x8118691c + SIOCATMARK = 0x40047307 + SIOCDELMULTI = 0x80906932 + SIOCDELRT = 0x8030720b + SIOCDIFADDR = 0x80906919 + SIOCDIFPHYADDR = 0x80906949 + SIOCDLIFADDR = 0x8118691e + SIOCGDRVSPEC = 0xc01c697b + SIOCGETPFSYNC = 0xc09069f8 + SIOCGETSGCNT = 0xc0147534 + SIOCGETVIFCNT = 0xc0147533 + SIOCGHIWAT = 0x40047301 + SIOCGIFADDR = 0xc0906921 + SIOCGIFADDRPREF = 0xc0946920 + SIOCGIFALIAS = 0xc040691b + SIOCGIFBRDADDR = 0xc0906923 + SIOCGIFCAP = 0xc0206976 + SIOCGIFCONF = 0xc0086926 + SIOCGIFDATA = 0xc0946985 + SIOCGIFDLT = 0xc0906977 + SIOCGIFDSTADDR = 0xc0906922 + SIOCGIFFLAGS = 0xc0906911 + SIOCGIFGENERIC = 0xc090693a + SIOCGIFMEDIA = 0xc0286936 + SIOCGIFMETRIC = 0xc0906917 + SIOCGIFMTU = 0xc090697e + SIOCGIFNETMASK = 0xc0906925 + SIOCGIFPDSTADDR = 0xc0906948 + SIOCGIFPSRCADDR = 0xc0906947 + SIOCGLIFADDR = 0xc118691d + SIOCGLIFPHYADDR = 0xc118694b + SIOCGLINKSTR = 0xc01c6987 + SIOCGLOWAT = 0x40047303 + SIOCGPGRP = 0x40047309 + SIOCGVH = 0xc0906983 + SIOCIFCREATE = 0x8090697a + SIOCIFDESTROY = 0x80906979 + SIOCIFGCLONERS = 0xc00c6978 + SIOCINITIFADDR = 0xc0446984 + SIOCSDRVSPEC = 0x801c697b + SIOCSETPFSYNC = 0x809069f7 + SIOCSHIWAT = 0x80047300 + SIOCSIFADDR = 0x8090690c + SIOCSIFADDRPREF = 0x8094691f + SIOCSIFBRDADDR = 0x80906913 + SIOCSIFCAP = 0x80206975 + SIOCSIFDSTADDR = 0x8090690e + SIOCSIFFLAGS = 0x80906910 + SIOCSIFGENERIC = 0x80906939 + SIOCSIFMEDIA = 0xc0906935 + SIOCSIFMETRIC = 0x80906918 + SIOCSIFMTU = 0x8090697f + SIOCSIFNETMASK = 0x80906916 + SIOCSIFPHYADDR = 0x80406946 + SIOCSLIFPHYADDR = 0x8118694a + SIOCSLINKSTR = 0x801c6988 + SIOCSLOWAT = 0x80047302 + SIOCSPGRP = 0x80047308 + SIOCSVH = 0xc0906982 + SIOCZIFDATA = 0xc0946986 + SOCK_CLOEXEC = 0x10000000 + SOCK_DGRAM = 0x2 + SOCK_FLAGS_MASK = 0xf0000000 + SOCK_NONBLOCK = 0x20000000 + SOCK_NOSIGPIPE = 0x40000000 + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_SOCKET = 0xffff + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x2 + SO_ACCEPTFILTER = 0x1000 + SO_BROADCAST = 0x20 + SO_DEBUG = 0x1 + SO_DONTROUTE = 0x10 + SO_ERROR = 0x1007 + SO_KEEPALIVE = 0x8 + SO_LINGER = 0x80 + SO_NOHEADER = 0x100a + SO_NOSIGPIPE = 0x800 + SO_OOBINLINE = 0x100 + SO_OVERFLOWED = 0x1009 + SO_RCVBUF = 0x1002 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x100c + SO_REUSEADDR = 0x4 + SO_REUSEPORT = 0x200 + SO_SNDBUF = 0x1001 + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x100b + SO_TIMESTAMP = 0x2000 + SO_TYPE = 0x1008 + SO_USELOOPBACK = 0x40 + SYSCTL_VERSION = 0x1000000 + SYSCTL_VERS_0 = 0x0 + SYSCTL_VERS_1 = 0x1000000 + SYSCTL_VERS_MASK = 0xff000000 + S_ARCH1 = 0x10000 + S_ARCH2 = 0x20000 + S_BLKSIZE = 0x200 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IFWHT = 0xe000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISTXT = 0x200 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + TCIFLUSH = 0x1 + TCIOFLUSH = 0x3 + TCOFLUSH = 0x2 + TCP_CONGCTL = 0x20 + TCP_KEEPCNT = 0x6 + TCP_KEEPIDLE = 0x3 + TCP_KEEPINIT = 0x7 + TCP_KEEPINTVL = 0x5 + TCP_MAXBURST = 0x4 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0x10 + TCP_MINMSS = 0xd8 + TCP_MSS = 0x218 + TCP_NODELAY = 0x1 + TCSAFLUSH = 0x2 + TIOCCBRK = 0x2000747a + TIOCCDTR = 0x20007478 + TIOCCONS = 0x80047462 + TIOCDCDTIMESTAMP = 0x400c7458 + TIOCDRAIN = 0x2000745e + TIOCEXCL = 0x2000740d + TIOCEXT = 0x80047460 + TIOCFLAG_CDTRCTS = 0x10 + TIOCFLAG_CLOCAL = 0x2 + TIOCFLAG_CRTSCTS = 0x4 + TIOCFLAG_MDMBUF = 0x8 + TIOCFLAG_SOFTCAR = 0x1 + TIOCFLUSH = 0x80047410 + TIOCGETA = 0x402c7413 + TIOCGETD = 0x4004741a + TIOCGFLAGS = 0x4004745d + TIOCGLINED = 0x40207442 + TIOCGPGRP = 0x40047477 + TIOCGQSIZE = 0x40047481 + TIOCGRANTPT = 0x20007447 + TIOCGSID = 0x40047463 + TIOCGSIZE = 0x40087468 + TIOCGWINSZ = 0x40087468 + TIOCMBIC = 0x8004746b + TIOCMBIS = 0x8004746c + TIOCMGET = 0x4004746a + TIOCMSET = 0x8004746d + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x20007471 + TIOCNXCL = 0x2000740e + TIOCOUTQ = 0x40047473 + TIOCPKT = 0x80047470 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCPTMGET = 0x48087446 + TIOCPTSNAME = 0x48087448 + TIOCRCVFRAME = 0x80047445 + TIOCREMOTE = 0x80047469 + TIOCSBRK = 0x2000747b + TIOCSCTTY = 0x20007461 + TIOCSDTR = 0x20007479 + TIOCSETA = 0x802c7414 + TIOCSETAF = 0x802c7416 + TIOCSETAW = 0x802c7415 + TIOCSETD = 0x8004741b + TIOCSFLAGS = 0x8004745c + TIOCSIG = 0x2000745f + TIOCSLINED = 0x80207443 + TIOCSPGRP = 0x80047476 + TIOCSQSIZE = 0x80047480 + TIOCSSIZE = 0x80087467 + TIOCSTART = 0x2000746e + TIOCSTAT = 0x80047465 + TIOCSTI = 0x80017472 + TIOCSTOP = 0x2000746f + TIOCSWINSZ = 0x80087467 + TIOCUCNTL = 0x80047466 + TIOCXMTFRAME = 0x80047444 + TOSTOP = 0x400000 + VDISCARD = 0xf + VDSUSP = 0xb + VEOF = 0x0 + VEOL = 0x1 + VEOL2 = 0x2 + VERASE = 0x3 + VINTR = 0x8 + VKILL = 0x5 + VLNEXT = 0xe + VMIN = 0x10 + VQUIT = 0x9 + VREPRINT = 0x6 + VSTART = 0xc + VSTATUS = 0x12 + VSTOP = 0xd + VSUSP = 0xa + VTIME = 0x11 + VWERASE = 0x4 + WALL = 0x8 + WALLSIG = 0x8 + WALTSIG = 0x4 + WCLONE = 0x4 + WCOREFLAG = 0x80 + WNOHANG = 0x1 + WNOWAIT = 0x10000 + WNOZOMBIE = 0x20000 + WOPTSCHECKED = 0x40000 + WSTOPPED = 0x7f + WUNTRACED = 0x2 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x30) + EADDRNOTAVAIL = syscall.Errno(0x31) + EAFNOSUPPORT = syscall.Errno(0x2f) + EAGAIN = syscall.Errno(0x23) + EALREADY = syscall.Errno(0x25) + EAUTH = syscall.Errno(0x50) + EBADF = syscall.Errno(0x9) + EBADMSG = syscall.Errno(0x58) + EBADRPC = syscall.Errno(0x48) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x57) + ECHILD = syscall.Errno(0xa) + ECONNABORTED = syscall.Errno(0x35) + ECONNREFUSED = syscall.Errno(0x3d) + ECONNRESET = syscall.Errno(0x36) + EDEADLK = syscall.Errno(0xb) + EDESTADDRREQ = syscall.Errno(0x27) + EDOM = syscall.Errno(0x21) + EDQUOT = syscall.Errno(0x45) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EFTYPE = syscall.Errno(0x4f) + EHOSTDOWN = syscall.Errno(0x40) + EHOSTUNREACH = syscall.Errno(0x41) + EIDRM = syscall.Errno(0x52) + EILSEQ = syscall.Errno(0x55) + EINPROGRESS = syscall.Errno(0x24) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x38) + EISDIR = syscall.Errno(0x15) + ELAST = syscall.Errno(0x60) + ELOOP = syscall.Errno(0x3e) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x28) + EMULTIHOP = syscall.Errno(0x5e) + ENAMETOOLONG = syscall.Errno(0x3f) + ENEEDAUTH = syscall.Errno(0x51) + ENETDOWN = syscall.Errno(0x32) + ENETRESET = syscall.Errno(0x34) + ENETUNREACH = syscall.Errno(0x33) + ENFILE = syscall.Errno(0x17) + ENOATTR = syscall.Errno(0x5d) + ENOBUFS = syscall.Errno(0x37) + ENODATA = syscall.Errno(0x59) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOLCK = syscall.Errno(0x4d) + ENOLINK = syscall.Errno(0x5f) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x53) + ENOPROTOOPT = syscall.Errno(0x2a) + ENOSPC = syscall.Errno(0x1c) + ENOSR = syscall.Errno(0x5a) + ENOSTR = syscall.Errno(0x5b) + ENOSYS = syscall.Errno(0x4e) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x39) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x42) + ENOTSOCK = syscall.Errno(0x26) + ENOTSUP = syscall.Errno(0x56) + ENOTTY = syscall.Errno(0x19) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x2d) + EOVERFLOW = syscall.Errno(0x54) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x2e) + EPIPE = syscall.Errno(0x20) + EPROCLIM = syscall.Errno(0x43) + EPROCUNAVAIL = syscall.Errno(0x4c) + EPROGMISMATCH = syscall.Errno(0x4b) + EPROGUNAVAIL = syscall.Errno(0x4a) + EPROTO = syscall.Errno(0x60) + EPROTONOSUPPORT = syscall.Errno(0x2b) + EPROTOTYPE = syscall.Errno(0x29) + ERANGE = syscall.Errno(0x22) + EREMOTE = syscall.Errno(0x47) + EROFS = syscall.Errno(0x1e) + ERPCMISMATCH = syscall.Errno(0x49) + ESHUTDOWN = syscall.Errno(0x3a) + ESOCKTNOSUPPORT = syscall.Errno(0x2c) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESTALE = syscall.Errno(0x46) + ETIME = syscall.Errno(0x5c) + ETIMEDOUT = syscall.Errno(0x3c) + ETOOMANYREFS = syscall.Errno(0x3b) + ETXTBSY = syscall.Errno(0x1a) + EUSERS = syscall.Errno(0x44) + EWOULDBLOCK = syscall.Errno(0x23) + EXDEV = syscall.Errno(0x12) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0xa) + SIGCHLD = syscall.Signal(0x14) + SIGCONT = syscall.Signal(0x13) + SIGEMT = syscall.Signal(0x7) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINFO = syscall.Signal(0x1d) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x17) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPROF = syscall.Signal(0x1b) + SIGPWR = syscall.Signal(0x20) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTOP = syscall.Signal(0x11) + SIGSYS = syscall.Signal(0xc) + SIGTERM = syscall.Signal(0xf) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x12) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGURG = syscall.Signal(0x10) + SIGUSR1 = syscall.Signal(0x1e) + SIGUSR2 = syscall.Signal(0x1f) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "device not configured", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource deadlock avoided", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device busy", + 17: "file exists", + 18: "cross-device link", + 19: "operation not supported by device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "result too large or too small", + 35: "resource temporarily unavailable", + 36: "operation now in progress", + 37: "operation already in progress", + 38: "socket operation on non-socket", + 39: "destination address required", + 40: "message too long", + 41: "protocol wrong type for socket", + 42: "protocol option not available", + 43: "protocol not supported", + 44: "socket type not supported", + 45: "operation not supported", + 46: "protocol family not supported", + 47: "address family not supported by protocol family", + 48: "address already in use", + 49: "can't assign requested address", + 50: "network is down", + 51: "network is unreachable", + 52: "network dropped connection on reset", + 53: "software caused connection abort", + 54: "connection reset by peer", + 55: "no buffer space available", + 56: "socket is already connected", + 57: "socket is not connected", + 58: "can't send after socket shutdown", + 59: "too many references: can't splice", + 60: "connection timed out", + 61: "connection refused", + 62: "too many levels of symbolic links", + 63: "file name too long", + 64: "host is down", + 65: "no route to host", + 66: "directory not empty", + 67: "too many processes", + 68: "too many users", + 69: "disc quota exceeded", + 70: "stale NFS file handle", + 71: "too many levels of remote in path", + 72: "RPC struct is bad", + 73: "RPC version wrong", + 74: "RPC prog. not avail", + 75: "program version wrong", + 76: "bad procedure for program", + 77: "no locks available", + 78: "function not implemented", + 79: "inappropriate file type or format", + 80: "authentication error", + 81: "need authenticator", + 82: "identifier removed", + 83: "no message of desired type", + 84: "value too large to be stored in data type", + 85: "illegal byte sequence", + 86: "not supported", + 87: "operation Canceled", + 88: "bad or Corrupt message", + 89: "no message available", + 90: "no STREAM resources", + 91: "not a STREAM", + 92: "STREAM ioctl timeout", + 93: "attribute not found", + 94: "multihop attempted", + 95: "link has been severed", + 96: "protocol error", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/BPT trap", + 6: "abort trap", + 7: "EMT trap", + 8: "floating point exception", + 9: "killed", + 10: "bus error", + 11: "segmentation fault", + 12: "bad system call", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "urgent I/O condition", + 17: "stopped (signal)", + 18: "stopped", + 19: "continued", + 20: "child exited", + 21: "stopped (tty input)", + 22: "stopped (tty output)", + 23: "I/O possible", + 24: "cputime limit exceeded", + 25: "filesize limit exceeded", + 26: "virtual timer expired", + 27: "profiling timer expired", + 28: "window size changes", + 29: "information request", + 30: "user defined signal 1", + 31: "user defined signal 2", + 32: "power fail/restart", +} diff --git a/vendor/golang.org/x/sys/unix/zerrors_openbsd_386.go b/vendor/golang.org/x/sys/unix/zerrors_openbsd_386.go new file mode 100644 index 0000000000..3322e998d3 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_openbsd_386.go @@ -0,0 +1,1584 @@ +// mkerrors.sh -m32 +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build 386,openbsd + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -m32 _const.go + +package unix + +import "syscall" + +const ( + AF_APPLETALK = 0x10 + AF_BLUETOOTH = 0x20 + AF_CCITT = 0xa + AF_CHAOS = 0x5 + AF_CNT = 0x15 + AF_COIP = 0x14 + AF_DATAKIT = 0x9 + AF_DECnet = 0xc + AF_DLI = 0xd + AF_E164 = 0x1a + AF_ECMA = 0x8 + AF_ENCAP = 0x1c + AF_HYLINK = 0xf + AF_IMPLINK = 0x3 + AF_INET = 0x2 + AF_INET6 = 0x18 + AF_IPX = 0x17 + AF_ISDN = 0x1a + AF_ISO = 0x7 + AF_KEY = 0x1e + AF_LAT = 0xe + AF_LINK = 0x12 + AF_LOCAL = 0x1 + AF_MAX = 0x24 + AF_MPLS = 0x21 + AF_NATM = 0x1b + AF_NS = 0x6 + AF_OSI = 0x7 + AF_PUP = 0x4 + AF_ROUTE = 0x11 + AF_SIP = 0x1d + AF_SNA = 0xb + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + ARPHRD_ETHER = 0x1 + ARPHRD_FRELAY = 0xf + ARPHRD_IEEE1394 = 0x18 + ARPHRD_IEEE802 = 0x6 + B0 = 0x0 + B110 = 0x6e + B115200 = 0x1c200 + B1200 = 0x4b0 + B134 = 0x86 + B14400 = 0x3840 + B150 = 0x96 + B1800 = 0x708 + B19200 = 0x4b00 + B200 = 0xc8 + B230400 = 0x38400 + B2400 = 0x960 + B28800 = 0x7080 + B300 = 0x12c + B38400 = 0x9600 + B4800 = 0x12c0 + B50 = 0x32 + B57600 = 0xe100 + B600 = 0x258 + B7200 = 0x1c20 + B75 = 0x4b + B76800 = 0x12c00 + B9600 = 0x2580 + BIOCFLUSH = 0x20004268 + BIOCGBLEN = 0x40044266 + BIOCGDIRFILT = 0x4004427c + BIOCGDLT = 0x4004426a + BIOCGDLTLIST = 0xc008427b + BIOCGETIF = 0x4020426b + BIOCGFILDROP = 0x40044278 + BIOCGHDRCMPLT = 0x40044274 + BIOCGRSIG = 0x40044273 + BIOCGRTIMEOUT = 0x400c426e + BIOCGSTATS = 0x4008426f + BIOCIMMEDIATE = 0x80044270 + BIOCLOCK = 0x20004276 + BIOCPROMISC = 0x20004269 + BIOCSBLEN = 0xc0044266 + BIOCSDIRFILT = 0x8004427d + BIOCSDLT = 0x8004427a + BIOCSETF = 0x80084267 + BIOCSETIF = 0x8020426c + BIOCSETWF = 0x80084277 + BIOCSFILDROP = 0x80044279 + BIOCSHDRCMPLT = 0x80044275 + BIOCSRSIG = 0x80044272 + BIOCSRTIMEOUT = 0x800c426d + BIOCVERSION = 0x40044271 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALIGNMENT = 0x4 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIRECTION_IN = 0x1 + BPF_DIRECTION_OUT = 0x2 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXBUFSIZE = 0x200000 + BPF_MAXINSNS = 0x200 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINBUFSIZE = 0x20 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RELEASE = 0x30bb6 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BRKINT = 0x2 + CFLUSH = 0xf + CLOCAL = 0x8000 + CREAD = 0x800 + CS5 = 0x0 + CS6 = 0x100 + CS7 = 0x200 + CS8 = 0x300 + CSIZE = 0x300 + CSTART = 0x11 + CSTATUS = 0xff + CSTOP = 0x13 + CSTOPB = 0x400 + CSUSP = 0x1a + CTL_MAXNAME = 0xc + CTL_NET = 0x4 + DIOCOSFPFLUSH = 0x2000444e + DLT_ARCNET = 0x7 + DLT_ATM_RFC1483 = 0xb + DLT_AX25 = 0x3 + DLT_CHAOS = 0x5 + DLT_C_HDLC = 0x68 + DLT_EN10MB = 0x1 + DLT_EN3MB = 0x2 + DLT_ENC = 0xd + DLT_FDDI = 0xa + DLT_IEEE802 = 0x6 + DLT_IEEE802_11 = 0x69 + DLT_IEEE802_11_RADIO = 0x7f + DLT_LOOP = 0xc + DLT_MPLS = 0xdb + DLT_NULL = 0x0 + DLT_PFLOG = 0x75 + DLT_PFSYNC = 0x12 + DLT_PPP = 0x9 + DLT_PPP_BSDOS = 0x10 + DLT_PPP_ETHER = 0x33 + DLT_PPP_SERIAL = 0x32 + DLT_PRONET = 0x4 + DLT_RAW = 0xe + DLT_SLIP = 0x8 + DLT_SLIP_BSDOS = 0xf + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + ECHO = 0x8 + ECHOCTL = 0x40 + ECHOE = 0x2 + ECHOK = 0x4 + ECHOKE = 0x1 + ECHONL = 0x10 + ECHOPRT = 0x20 + EMT_TAGOVF = 0x1 + EMUL_ENABLED = 0x1 + EMUL_NATIVE = 0x2 + ENDRUNDISC = 0x9 + ETHERMIN = 0x2e + ETHERMTU = 0x5dc + ETHERTYPE_8023 = 0x4 + ETHERTYPE_AARP = 0x80f3 + ETHERTYPE_ACCTON = 0x8390 + ETHERTYPE_AEONIC = 0x8036 + ETHERTYPE_ALPHA = 0x814a + ETHERTYPE_AMBER = 0x6008 + ETHERTYPE_AMOEBA = 0x8145 + ETHERTYPE_AOE = 0x88a2 + ETHERTYPE_APOLLO = 0x80f7 + ETHERTYPE_APOLLODOMAIN = 0x8019 + ETHERTYPE_APPLETALK = 0x809b + ETHERTYPE_APPLITEK = 0x80c7 + ETHERTYPE_ARGONAUT = 0x803a + ETHERTYPE_ARP = 0x806 + ETHERTYPE_AT = 0x809b + ETHERTYPE_ATALK = 0x809b + ETHERTYPE_ATOMIC = 0x86df + ETHERTYPE_ATT = 0x8069 + ETHERTYPE_ATTSTANFORD = 0x8008 + ETHERTYPE_AUTOPHON = 0x806a + ETHERTYPE_AXIS = 0x8856 + ETHERTYPE_BCLOOP = 0x9003 + ETHERTYPE_BOFL = 0x8102 + ETHERTYPE_CABLETRON = 0x7034 + ETHERTYPE_CHAOS = 0x804 + ETHERTYPE_COMDESIGN = 0x806c + ETHERTYPE_COMPUGRAPHIC = 0x806d + ETHERTYPE_COUNTERPOINT = 0x8062 + ETHERTYPE_CRONUS = 0x8004 + ETHERTYPE_CRONUSVLN = 0x8003 + ETHERTYPE_DCA = 0x1234 + ETHERTYPE_DDE = 0x807b + ETHERTYPE_DEBNI = 0xaaaa + ETHERTYPE_DECAM = 0x8048 + ETHERTYPE_DECCUST = 0x6006 + ETHERTYPE_DECDIAG = 0x6005 + ETHERTYPE_DECDNS = 0x803c + ETHERTYPE_DECDTS = 0x803e + ETHERTYPE_DECEXPER = 0x6000 + ETHERTYPE_DECLAST = 0x8041 + ETHERTYPE_DECLTM = 0x803f + ETHERTYPE_DECMUMPS = 0x6009 + ETHERTYPE_DECNETBIOS = 0x8040 + ETHERTYPE_DELTACON = 0x86de + ETHERTYPE_DIDDLE = 0x4321 + ETHERTYPE_DLOG1 = 0x660 + ETHERTYPE_DLOG2 = 0x661 + ETHERTYPE_DN = 0x6003 + ETHERTYPE_DOGFIGHT = 0x1989 + ETHERTYPE_DSMD = 0x8039 + ETHERTYPE_ECMA = 0x803 + ETHERTYPE_ENCRYPT = 0x803d + ETHERTYPE_ES = 0x805d + ETHERTYPE_EXCELAN = 0x8010 + ETHERTYPE_EXPERDATA = 0x8049 + ETHERTYPE_FLIP = 0x8146 + ETHERTYPE_FLOWCONTROL = 0x8808 + ETHERTYPE_FRARP = 0x808 + ETHERTYPE_GENDYN = 0x8068 + ETHERTYPE_HAYES = 0x8130 + ETHERTYPE_HIPPI_FP = 0x8180 + ETHERTYPE_HITACHI = 0x8820 + ETHERTYPE_HP = 0x8005 + ETHERTYPE_IEEEPUP = 0xa00 + ETHERTYPE_IEEEPUPAT = 0xa01 + ETHERTYPE_IMLBL = 0x4c42 + ETHERTYPE_IMLBLDIAG = 0x424c + ETHERTYPE_IP = 0x800 + ETHERTYPE_IPAS = 0x876c + ETHERTYPE_IPV6 = 0x86dd + ETHERTYPE_IPX = 0x8137 + ETHERTYPE_IPXNEW = 0x8037 + ETHERTYPE_KALPANA = 0x8582 + ETHERTYPE_LANBRIDGE = 0x8038 + ETHERTYPE_LANPROBE = 0x8888 + ETHERTYPE_LAT = 0x6004 + ETHERTYPE_LBACK = 0x9000 + ETHERTYPE_LITTLE = 0x8060 + ETHERTYPE_LLDP = 0x88cc + ETHERTYPE_LOGICRAFT = 0x8148 + ETHERTYPE_LOOPBACK = 0x9000 + ETHERTYPE_MATRA = 0x807a + ETHERTYPE_MAX = 0xffff + ETHERTYPE_MERIT = 0x807c + ETHERTYPE_MICP = 0x873a + ETHERTYPE_MOPDL = 0x6001 + ETHERTYPE_MOPRC = 0x6002 + ETHERTYPE_MOTOROLA = 0x818d + ETHERTYPE_MPLS = 0x8847 + ETHERTYPE_MPLS_MCAST = 0x8848 + ETHERTYPE_MUMPS = 0x813f + ETHERTYPE_NBPCC = 0x3c04 + ETHERTYPE_NBPCLAIM = 0x3c09 + ETHERTYPE_NBPCLREQ = 0x3c05 + ETHERTYPE_NBPCLRSP = 0x3c06 + ETHERTYPE_NBPCREQ = 0x3c02 + ETHERTYPE_NBPCRSP = 0x3c03 + ETHERTYPE_NBPDG = 0x3c07 + ETHERTYPE_NBPDGB = 0x3c08 + ETHERTYPE_NBPDLTE = 0x3c0a + ETHERTYPE_NBPRAR = 0x3c0c + ETHERTYPE_NBPRAS = 0x3c0b + ETHERTYPE_NBPRST = 0x3c0d + ETHERTYPE_NBPSCD = 0x3c01 + ETHERTYPE_NBPVCD = 0x3c00 + ETHERTYPE_NBS = 0x802 + ETHERTYPE_NCD = 0x8149 + ETHERTYPE_NESTAR = 0x8006 + ETHERTYPE_NETBEUI = 0x8191 + ETHERTYPE_NOVELL = 0x8138 + ETHERTYPE_NS = 0x600 + ETHERTYPE_NSAT = 0x601 + ETHERTYPE_NSCOMPAT = 0x807 + ETHERTYPE_NTRAILER = 0x10 + ETHERTYPE_OS9 = 0x7007 + ETHERTYPE_OS9NET = 0x7009 + ETHERTYPE_PACER = 0x80c6 + ETHERTYPE_PAE = 0x888e + ETHERTYPE_PCS = 0x4242 + ETHERTYPE_PLANNING = 0x8044 + ETHERTYPE_PPP = 0x880b + ETHERTYPE_PPPOE = 0x8864 + ETHERTYPE_PPPOEDISC = 0x8863 + ETHERTYPE_PRIMENTS = 0x7031 + ETHERTYPE_PUP = 0x200 + ETHERTYPE_PUPAT = 0x200 + ETHERTYPE_QINQ = 0x88a8 + ETHERTYPE_RACAL = 0x7030 + ETHERTYPE_RATIONAL = 0x8150 + ETHERTYPE_RAWFR = 0x6559 + ETHERTYPE_RCL = 0x1995 + ETHERTYPE_RDP = 0x8739 + ETHERTYPE_RETIX = 0x80f2 + ETHERTYPE_REVARP = 0x8035 + ETHERTYPE_SCA = 0x6007 + ETHERTYPE_SECTRA = 0x86db + ETHERTYPE_SECUREDATA = 0x876d + ETHERTYPE_SGITW = 0x817e + ETHERTYPE_SG_BOUNCE = 0x8016 + ETHERTYPE_SG_DIAG = 0x8013 + ETHERTYPE_SG_NETGAMES = 0x8014 + ETHERTYPE_SG_RESV = 0x8015 + ETHERTYPE_SIMNET = 0x5208 + ETHERTYPE_SLOW = 0x8809 + ETHERTYPE_SNA = 0x80d5 + ETHERTYPE_SNMP = 0x814c + ETHERTYPE_SONIX = 0xfaf5 + ETHERTYPE_SPIDER = 0x809f + ETHERTYPE_SPRITE = 0x500 + ETHERTYPE_STP = 0x8181 + ETHERTYPE_TALARIS = 0x812b + ETHERTYPE_TALARISMC = 0x852b + ETHERTYPE_TCPCOMP = 0x876b + ETHERTYPE_TCPSM = 0x9002 + ETHERTYPE_TEC = 0x814f + ETHERTYPE_TIGAN = 0x802f + ETHERTYPE_TRAIL = 0x1000 + ETHERTYPE_TRANSETHER = 0x6558 + ETHERTYPE_TYMSHARE = 0x802e + ETHERTYPE_UBBST = 0x7005 + ETHERTYPE_UBDEBUG = 0x900 + ETHERTYPE_UBDIAGLOOP = 0x7002 + ETHERTYPE_UBDL = 0x7000 + ETHERTYPE_UBNIU = 0x7001 + ETHERTYPE_UBNMC = 0x7003 + ETHERTYPE_VALID = 0x1600 + ETHERTYPE_VARIAN = 0x80dd + ETHERTYPE_VAXELN = 0x803b + ETHERTYPE_VEECO = 0x8067 + ETHERTYPE_VEXP = 0x805b + ETHERTYPE_VGLAB = 0x8131 + ETHERTYPE_VINES = 0xbad + ETHERTYPE_VINESECHO = 0xbaf + ETHERTYPE_VINESLOOP = 0xbae + ETHERTYPE_VITAL = 0xff00 + ETHERTYPE_VLAN = 0x8100 + ETHERTYPE_VLTLMAN = 0x8080 + ETHERTYPE_VPROD = 0x805c + ETHERTYPE_VURESERVED = 0x8147 + ETHERTYPE_WATERLOO = 0x8130 + ETHERTYPE_WELLFLEET = 0x8103 + ETHERTYPE_X25 = 0x805 + ETHERTYPE_X75 = 0x801 + ETHERTYPE_XNSSM = 0x9001 + ETHERTYPE_XTP = 0x817d + ETHER_ADDR_LEN = 0x6 + ETHER_ALIGN = 0x2 + ETHER_CRC_LEN = 0x4 + ETHER_CRC_POLY_BE = 0x4c11db6 + ETHER_CRC_POLY_LE = 0xedb88320 + ETHER_HDR_LEN = 0xe + ETHER_MAX_DIX_LEN = 0x600 + ETHER_MAX_LEN = 0x5ee + ETHER_MIN_LEN = 0x40 + ETHER_TYPE_LEN = 0x2 + ETHER_VLAN_ENCAP_LEN = 0x4 + EVFILT_AIO = -0x3 + EVFILT_PROC = -0x5 + EVFILT_READ = -0x1 + EVFILT_SIGNAL = -0x6 + EVFILT_SYSCOUNT = 0x7 + EVFILT_TIMER = -0x7 + EVFILT_VNODE = -0x4 + EVFILT_WRITE = -0x2 + EV_ADD = 0x1 + EV_CLEAR = 0x20 + EV_DELETE = 0x2 + EV_DISABLE = 0x8 + EV_ENABLE = 0x4 + EV_EOF = 0x8000 + EV_ERROR = 0x4000 + EV_FLAG1 = 0x2000 + EV_ONESHOT = 0x10 + EV_SYSFLAGS = 0xf000 + EXTA = 0x4b00 + EXTB = 0x9600 + EXTPROC = 0x800 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FLUSHO = 0x800000 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0xa + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLK = 0x7 + F_GETOWN = 0x5 + F_OK = 0x0 + F_RDLCK = 0x1 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLK = 0x8 + F_SETLKW = 0x9 + F_SETOWN = 0x6 + F_UNLCK = 0x2 + F_WRLCK = 0x3 + HUPCL = 0x4000 + ICANON = 0x100 + ICMP6_FILTER = 0x12 + ICRNL = 0x100 + IEXTEN = 0x400 + IFAN_ARRIVAL = 0x0 + IFAN_DEPARTURE = 0x1 + IFA_ROUTE = 0x1 + IFF_ALLMULTI = 0x200 + IFF_BROADCAST = 0x2 + IFF_CANTCHANGE = 0x8e52 + IFF_DEBUG = 0x4 + IFF_LINK0 = 0x1000 + IFF_LINK1 = 0x2000 + IFF_LINK2 = 0x4000 + IFF_LOOPBACK = 0x8 + IFF_MULTICAST = 0x8000 + IFF_NOARP = 0x80 + IFF_NOTRAILERS = 0x20 + IFF_OACTIVE = 0x400 + IFF_POINTOPOINT = 0x10 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SIMPLEX = 0x800 + IFF_UP = 0x1 + IFNAMSIZ = 0x10 + 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_BLUETOOTH = 0xf8 + IFT_BRIDGE = 0xd1 + IFT_BSC = 0x53 + IFT_CARP = 0xf7 + 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_DOCSCABLEUPSTREAMCHANNEL = 0xcd + IFT_DS0 = 0x51 + IFT_DS0BUNDLE = 0x52 + IFT_DS1FDL = 0xaa + IFT_DS3 = 0x1e + IFT_DTM = 0x8c + IFT_DUMMY = 0xf1 + IFT_DVBASILN = 0xac + IFT_DVBASIOUT = 0xad + IFT_DVBRCCDOWNSTREAM = 0x93 + IFT_DVBRCCMACLAYER = 0x92 + IFT_DVBRCCUPSTREAM = 0x94 + IFT_ECONET = 0xce + IFT_ENC = 0xf4 + IFT_EON = 0x19 + IFT_EPLRS = 0x57 + IFT_ESCON = 0x49 + IFT_ETHER = 0x6 + IFT_FAITH = 0xf3 + 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_IEEE1394 = 0x90 + IFT_IEEE80211 = 0x47 + IFT_IEEE80212 = 0x37 + IFT_IEEE8023ADLAG = 0xa1 + IFT_IFGSN = 0x91 + IFT_IMT = 0xbe + IFT_INFINIBAND = 0xc7 + IFT_INTERLEAVE = 0x7c + IFT_IP = 0x7e + IFT_IPFORWARD = 0x8e + IFT_IPOVERATM = 0x72 + IFT_IPOVERCDLC = 0x6d + IFT_IPOVERCLAW = 0x6e + IFT_IPSWITCH = 0x4e + 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_L2VLAN = 0x87 + IFT_L3IPVLAN = 0x88 + IFT_L3IPXVLAN = 0x89 + IFT_LAPB = 0x10 + IFT_LAPD = 0x4d + IFT_LAPF = 0x77 + IFT_LINEGROUP = 0xd2 + 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 = 0xf5 + IFT_PFLOW = 0xf9 + IFT_PFSYNC = 0xf6 + IFT_PLC = 0xae + IFT_PON155 = 0xcf + IFT_PON622 = 0xd0 + IFT_POS = 0xab + IFT_PPP = 0x17 + IFT_PPPMULTILINKBUNDLE = 0x6c + IFT_PROPATM = 0xc5 + IFT_PROPBWAP2MP = 0xb8 + IFT_PROPCNLS = 0x59 + IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5 + IFT_PROPDOCSWIRELESSMACLAYER = 0xb4 + IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6 + IFT_PROPMUX = 0x36 + IFT_PROPVIRTUAL = 0x35 + IFT_PROPWIRELESSP2P = 0x9d + IFT_PTPSERIAL = 0x16 + IFT_PVC = 0xf2 + IFT_Q2931 = 0xc9 + 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_SIPSIG = 0xcc + IFT_SIPTG = 0xcb + 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_T1 = 0x12 + IFT_TDLC = 0x74 + IFT_TELINK = 0xc8 + 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_VIRTUALTG = 0xca + IFT_VOICEDID = 0xd5 + IFT_VOICEEM = 0x64 + IFT_VOICEEMFGD = 0xd3 + IFT_VOICEENCAP = 0x67 + IFT_VOICEFGDEANA = 0xd4 + IFT_VOICEFXO = 0x65 + IFT_VOICEFXS = 0x66 + IFT_VOICEOVERATM = 0x98 + IFT_VOICEOVERCABLE = 0xc6 + 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 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLASSD_HOST = 0xfffffff + IN_CLASSD_NET = 0xf0000000 + IN_CLASSD_NSHIFT = 0x1c + IN_LOOPBACKNET = 0x7f + IN_RFC3021_HOST = 0x1 + IN_RFC3021_NET = 0xfffffffe + IN_RFC3021_NSHIFT = 0x1f + IPPROTO_AH = 0x33 + IPPROTO_CARP = 0x70 + IPPROTO_DIVERT = 0x102 + IPPROTO_DIVERT_INIT = 0x2 + IPPROTO_DIVERT_RESP = 0x1 + IPPROTO_DONE = 0x101 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_ENCAP = 0x62 + IPPROTO_EON = 0x50 + IPPROTO_ESP = 0x32 + IPPROTO_ETHERIP = 0x61 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GGP = 0x3 + IPPROTO_GRE = 0x2f + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IGMP = 0x2 + IPPROTO_IP = 0x0 + IPPROTO_IPCOMP = 0x6c + IPPROTO_IPIP = 0x4 + IPPROTO_IPV4 = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_MAX = 0x100 + IPPROTO_MAXID = 0x103 + IPPROTO_MOBILE = 0x37 + IPPROTO_MPLS = 0x89 + IPPROTO_NONE = 0x3b + IPPROTO_PFSYNC = 0xf0 + IPPROTO_PIM = 0x67 + IPPROTO_PUP = 0xc + IPPROTO_RAW = 0xff + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_UDP = 0x11 + IPV6_AUTH_LEVEL = 0x35 + IPV6_AUTOFLOWLABEL = 0x3b + IPV6_CHECKSUM = 0x1a + IPV6_DEFAULT_MULTICAST_HOPS = 0x1 + IPV6_DEFAULT_MULTICAST_LOOP = 0x1 + IPV6_DEFHLIM = 0x40 + IPV6_DONTFRAG = 0x3e + IPV6_DSTOPTS = 0x32 + IPV6_ESP_NETWORK_LEVEL = 0x37 + IPV6_ESP_TRANS_LEVEL = 0x36 + IPV6_FAITH = 0x1d + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 + IPV6_FRAGTTL = 0x78 + IPV6_HLIMDEC = 0x1 + IPV6_HOPLIMIT = 0x2f + IPV6_HOPOPTS = 0x31 + IPV6_IPCOMP_LEVEL = 0x3c + IPV6_JOIN_GROUP = 0xc + IPV6_LEAVE_GROUP = 0xd + IPV6_MAXHLIM = 0xff + IPV6_MAXPACKET = 0xffff + IPV6_MMTU = 0x500 + IPV6_MULTICAST_HOPS = 0xa + IPV6_MULTICAST_IF = 0x9 + IPV6_MULTICAST_LOOP = 0xb + IPV6_NEXTHOP = 0x30 + IPV6_OPTIONS = 0x1 + IPV6_PATHMTU = 0x2c + IPV6_PIPEX = 0x3f + IPV6_PKTINFO = 0x2e + IPV6_PORTRANGE = 0xe + IPV6_PORTRANGE_DEFAULT = 0x0 + IPV6_PORTRANGE_HIGH = 0x1 + IPV6_PORTRANGE_LOW = 0x2 + IPV6_RECVDSTOPTS = 0x28 + IPV6_RECVDSTPORT = 0x40 + IPV6_RECVHOPLIMIT = 0x25 + IPV6_RECVHOPOPTS = 0x27 + IPV6_RECVPATHMTU = 0x2b + IPV6_RECVPKTINFO = 0x24 + IPV6_RECVRTHDR = 0x26 + IPV6_RECVTCLASS = 0x39 + IPV6_RTABLE = 0x1021 + IPV6_RTHDR = 0x33 + IPV6_RTHDRDSTOPTS = 0x23 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_SOCKOPT_RESERVED1 = 0x3 + IPV6_TCLASS = 0x3d + IPV6_UNICAST_HOPS = 0x4 + IPV6_USE_MIN_MTU = 0x2a + IPV6_V6ONLY = 0x1b + IPV6_VERSION = 0x60 + IPV6_VERSION_MASK = 0xf0 + IP_ADD_MEMBERSHIP = 0xc + IP_AUTH_LEVEL = 0x14 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DIVERTFL = 0x1022 + IP_DROP_MEMBERSHIP = 0xd + IP_ESP_NETWORK_LEVEL = 0x16 + IP_ESP_TRANS_LEVEL = 0x15 + IP_HDRINCL = 0x2 + IP_IPCOMP_LEVEL = 0x1d + IP_IPSECFLOWINFO = 0x24 + IP_IPSEC_LOCAL_AUTH = 0x1b + IP_IPSEC_LOCAL_CRED = 0x19 + IP_IPSEC_LOCAL_ID = 0x17 + IP_IPSEC_REMOTE_AUTH = 0x1c + IP_IPSEC_REMOTE_CRED = 0x1a + IP_IPSEC_REMOTE_ID = 0x18 + IP_MAXPACKET = 0xffff + IP_MAX_MEMBERSHIPS = 0xfff + IP_MF = 0x2000 + IP_MINTTL = 0x20 + IP_MIN_MEMBERSHIPS = 0xf + IP_MSS = 0x240 + IP_MULTICAST_IF = 0x9 + IP_MULTICAST_LOOP = 0xb + IP_MULTICAST_TTL = 0xa + IP_OFFMASK = 0x1fff + IP_OPTIONS = 0x1 + IP_PIPEX = 0x22 + IP_PORTRANGE = 0x13 + IP_PORTRANGE_DEFAULT = 0x0 + IP_PORTRANGE_HIGH = 0x1 + IP_PORTRANGE_LOW = 0x2 + IP_RECVDSTADDR = 0x7 + IP_RECVDSTPORT = 0x21 + IP_RECVIF = 0x1e + IP_RECVOPTS = 0x5 + IP_RECVRETOPTS = 0x6 + IP_RECVRTABLE = 0x23 + IP_RECVTTL = 0x1f + IP_RETOPTS = 0x8 + IP_RF = 0x8000 + IP_RTABLE = 0x1021 + IP_TOS = 0x3 + IP_TTL = 0x4 + ISIG = 0x80 + ISTRIP = 0x20 + IXANY = 0x800 + IXOFF = 0x400 + IXON = 0x200 + LCNT_OVERLOAD_FLUSH = 0x6 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_DONTNEED = 0x4 + MADV_FREE = 0x6 + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_SEQUENTIAL = 0x2 + MADV_SPACEAVAIL = 0x5 + MADV_WILLNEED = 0x3 + MAP_ANON = 0x1000 + MAP_COPY = 0x4 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_FLAGMASK = 0x1ff7 + MAP_HASSEMAPHORE = 0x200 + MAP_INHERIT = 0x80 + MAP_INHERIT_COPY = 0x1 + MAP_INHERIT_DONATE_COPY = 0x3 + MAP_INHERIT_NONE = 0x2 + MAP_INHERIT_SHARE = 0x0 + MAP_NOEXTEND = 0x100 + MAP_NORESERVE = 0x40 + MAP_PRIVATE = 0x2 + MAP_RENAME = 0x20 + MAP_SHARED = 0x1 + MAP_TRYFIXED = 0x400 + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MSG_BCAST = 0x100 + MSG_CTRUNC = 0x20 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x80 + MSG_EOR = 0x8 + MSG_MCAST = 0x200 + MSG_NOSIGNAL = 0x400 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_TRUNC = 0x10 + MSG_WAITALL = 0x40 + MS_ASYNC = 0x1 + MS_INVALIDATE = 0x4 + MS_SYNC = 0x2 + NAME_MAX = 0xff + NET_RT_DUMP = 0x1 + NET_RT_FLAGS = 0x2 + NET_RT_IFLIST = 0x3 + NET_RT_MAXID = 0x6 + NET_RT_STATS = 0x4 + NET_RT_TABLE = 0x5 + NOFLSH = 0x80000000 + NOTE_ATTRIB = 0x8 + NOTE_CHILD = 0x4 + NOTE_DELETE = 0x1 + NOTE_EOF = 0x2 + NOTE_EXEC = 0x20000000 + NOTE_EXIT = 0x80000000 + NOTE_EXTEND = 0x4 + NOTE_FORK = 0x40000000 + NOTE_LINK = 0x10 + NOTE_LOWAT = 0x1 + NOTE_PCTRLMASK = 0xf0000000 + NOTE_PDATAMASK = 0xfffff + NOTE_RENAME = 0x20 + NOTE_REVOKE = 0x40 + NOTE_TRACK = 0x1 + NOTE_TRACKERR = 0x2 + NOTE_TRUNCATE = 0x80 + NOTE_WRITE = 0x2 + OCRNL = 0x10 + ONLCR = 0x2 + ONLRET = 0x80 + ONOCR = 0x40 + ONOEOT = 0x8 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_APPEND = 0x8 + O_ASYNC = 0x40 + O_CLOEXEC = 0x10000 + O_CREAT = 0x200 + O_DIRECTORY = 0x20000 + O_DSYNC = 0x80 + O_EXCL = 0x800 + O_EXLOCK = 0x20 + O_FSYNC = 0x80 + O_NDELAY = 0x4 + O_NOCTTY = 0x8000 + O_NOFOLLOW = 0x100 + O_NONBLOCK = 0x4 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_RSYNC = 0x80 + O_SHLOCK = 0x10 + O_SYNC = 0x80 + O_TRUNC = 0x400 + O_WRONLY = 0x1 + PARENB = 0x1000 + PARMRK = 0x8 + PARODD = 0x2000 + PENDIN = 0x20000000 + PF_FLUSH = 0x1 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + PT_MASK = 0x3ff000 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x8 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = 0x7fffffffffffffff + RTAX_AUTHOR = 0x6 + RTAX_BRD = 0x7 + RTAX_DST = 0x0 + RTAX_GATEWAY = 0x1 + RTAX_GENMASK = 0x3 + RTAX_IFA = 0x5 + RTAX_IFP = 0x4 + RTAX_LABEL = 0xa + RTAX_MAX = 0xb + RTAX_NETMASK = 0x2 + RTAX_SRC = 0x8 + RTAX_SRCMASK = 0x9 + RTA_AUTHOR = 0x40 + RTA_BRD = 0x80 + RTA_DST = 0x1 + RTA_GATEWAY = 0x2 + RTA_GENMASK = 0x8 + RTA_IFA = 0x20 + RTA_IFP = 0x10 + RTA_LABEL = 0x400 + RTA_NETMASK = 0x4 + RTA_SRC = 0x100 + RTA_SRCMASK = 0x200 + RTF_ANNOUNCE = 0x4000 + RTF_BLACKHOLE = 0x1000 + RTF_CLONED = 0x10000 + RTF_CLONING = 0x100 + RTF_DONE = 0x40 + RTF_DYNAMIC = 0x10 + RTF_FMASK = 0x10f808 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_LLINFO = 0x400 + RTF_MASK = 0x80 + RTF_MODIFIED = 0x20 + RTF_MPATH = 0x40000 + RTF_MPLS = 0x100000 + RTF_PERMANENT_ARP = 0x2000 + RTF_PROTO1 = 0x8000 + RTF_PROTO2 = 0x4000 + RTF_PROTO3 = 0x2000 + RTF_REJECT = 0x8 + RTF_SOURCE = 0x20000 + RTF_STATIC = 0x800 + RTF_TUNNEL = 0x100000 + RTF_UP = 0x1 + RTF_USETRAILERS = 0x8000 + RTF_XRESOLVE = 0x200 + RTM_ADD = 0x1 + RTM_CHANGE = 0x3 + RTM_DELADDR = 0xd + RTM_DELETE = 0x2 + RTM_DESYNC = 0x10 + RTM_GET = 0x4 + RTM_IFANNOUNCE = 0xf + RTM_IFINFO = 0xe + RTM_LOCK = 0x8 + RTM_LOSING = 0x5 + RTM_MAXSIZE = 0x800 + RTM_MISS = 0x7 + RTM_NEWADDR = 0xc + RTM_REDIRECT = 0x6 + RTM_RESOLVE = 0xb + RTM_RTTUNIT = 0xf4240 + RTM_VERSION = 0x5 + RTV_EXPIRE = 0x4 + RTV_HOPCOUNT = 0x2 + RTV_MTU = 0x1 + RTV_RPIPE = 0x8 + RTV_RTT = 0x40 + RTV_RTTVAR = 0x80 + RTV_SPIPE = 0x10 + RTV_SSTHRESH = 0x20 + RT_TABLEID_MAX = 0xff + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + RUSAGE_THREAD = 0x1 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x4 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDMULTI = 0x80206931 + SIOCAIFADDR = 0x8040691a + SIOCAIFGROUP = 0x80246987 + SIOCALIFADDR = 0x8218691c + SIOCATMARK = 0x40047307 + SIOCBRDGADD = 0x8054693c + SIOCBRDGADDS = 0x80546941 + SIOCBRDGARL = 0x806e694d + SIOCBRDGDADDR = 0x81286947 + SIOCBRDGDEL = 0x8054693d + SIOCBRDGDELS = 0x80546942 + SIOCBRDGFLUSH = 0x80546948 + SIOCBRDGFRL = 0x806e694e + SIOCBRDGGCACHE = 0xc0146941 + SIOCBRDGGFD = 0xc0146952 + SIOCBRDGGHT = 0xc0146951 + SIOCBRDGGIFFLGS = 0xc054693e + SIOCBRDGGMA = 0xc0146953 + SIOCBRDGGPARAM = 0xc03c6958 + SIOCBRDGGPRI = 0xc0146950 + SIOCBRDGGRL = 0xc028694f + SIOCBRDGGSIFS = 0xc054693c + SIOCBRDGGTO = 0xc0146946 + SIOCBRDGIFS = 0xc0546942 + SIOCBRDGRTS = 0xc0186943 + SIOCBRDGSADDR = 0xc1286944 + SIOCBRDGSCACHE = 0x80146940 + SIOCBRDGSFD = 0x80146952 + SIOCBRDGSHT = 0x80146951 + SIOCBRDGSIFCOST = 0x80546955 + SIOCBRDGSIFFLGS = 0x8054693f + SIOCBRDGSIFPRIO = 0x80546954 + SIOCBRDGSMA = 0x80146953 + SIOCBRDGSPRI = 0x80146950 + SIOCBRDGSPROTO = 0x8014695a + SIOCBRDGSTO = 0x80146945 + SIOCBRDGSTXHC = 0x80146959 + SIOCDELMULTI = 0x80206932 + SIOCDIFADDR = 0x80206919 + SIOCDIFGROUP = 0x80246989 + SIOCDIFPHYADDR = 0x80206949 + SIOCDLIFADDR = 0x8218691e + SIOCGETKALIVE = 0xc01869a4 + SIOCGETLABEL = 0x8020699a + SIOCGETPFLOW = 0xc02069fe + SIOCGETPFSYNC = 0xc02069f8 + SIOCGETSGCNT = 0xc0147534 + SIOCGETVIFCNT = 0xc0147533 + SIOCGETVLAN = 0xc0206990 + SIOCGHIWAT = 0x40047301 + SIOCGIFADDR = 0xc0206921 + SIOCGIFASYNCMAP = 0xc020697c + SIOCGIFBRDADDR = 0xc0206923 + SIOCGIFCONF = 0xc0086924 + SIOCGIFDATA = 0xc020691b + SIOCGIFDESCR = 0xc0206981 + SIOCGIFDSTADDR = 0xc0206922 + SIOCGIFFLAGS = 0xc0206911 + SIOCGIFGATTR = 0xc024698b + SIOCGIFGENERIC = 0xc020693a + SIOCGIFGMEMB = 0xc024698a + SIOCGIFGROUP = 0xc0246988 + SIOCGIFHARDMTU = 0xc02069a5 + SIOCGIFMEDIA = 0xc0286936 + SIOCGIFMETRIC = 0xc0206917 + SIOCGIFMTU = 0xc020697e + SIOCGIFNETMASK = 0xc0206925 + SIOCGIFPDSTADDR = 0xc0206948 + SIOCGIFPRIORITY = 0xc020699c + SIOCGIFPSRCADDR = 0xc0206947 + SIOCGIFRDOMAIN = 0xc02069a0 + SIOCGIFRTLABEL = 0xc0206983 + SIOCGIFTIMESLOT = 0xc0206986 + SIOCGIFXFLAGS = 0xc020699e + SIOCGLIFADDR = 0xc218691d + SIOCGLIFPHYADDR = 0xc218694b + SIOCGLIFPHYRTABLE = 0xc02069a2 + SIOCGLIFPHYTTL = 0xc02069a9 + SIOCGLOWAT = 0x40047303 + SIOCGPGRP = 0x40047309 + SIOCGSPPPPARAMS = 0xc0206994 + SIOCGVH = 0xc02069f6 + SIOCGVNETID = 0xc02069a7 + SIOCIFCREATE = 0x8020697a + SIOCIFDESTROY = 0x80206979 + SIOCIFGCLONERS = 0xc00c6978 + SIOCSETKALIVE = 0x801869a3 + SIOCSETLABEL = 0x80206999 + SIOCSETPFLOW = 0x802069fd + SIOCSETPFSYNC = 0x802069f7 + SIOCSETVLAN = 0x8020698f + SIOCSHIWAT = 0x80047300 + SIOCSIFADDR = 0x8020690c + SIOCSIFASYNCMAP = 0x8020697d + SIOCSIFBRDADDR = 0x80206913 + SIOCSIFDESCR = 0x80206980 + SIOCSIFDSTADDR = 0x8020690e + SIOCSIFFLAGS = 0x80206910 + SIOCSIFGATTR = 0x8024698c + SIOCSIFGENERIC = 0x80206939 + SIOCSIFLLADDR = 0x8020691f + SIOCSIFMEDIA = 0xc0206935 + SIOCSIFMETRIC = 0x80206918 + SIOCSIFMTU = 0x8020697f + SIOCSIFNETMASK = 0x80206916 + SIOCSIFPHYADDR = 0x80406946 + SIOCSIFPRIORITY = 0x8020699b + SIOCSIFRDOMAIN = 0x8020699f + SIOCSIFRTLABEL = 0x80206982 + SIOCSIFTIMESLOT = 0x80206985 + SIOCSIFXFLAGS = 0x8020699d + SIOCSLIFPHYADDR = 0x8218694a + SIOCSLIFPHYRTABLE = 0x802069a1 + SIOCSLIFPHYTTL = 0x802069a8 + SIOCSLOWAT = 0x80047302 + SIOCSPGRP = 0x80047308 + SIOCSSPPPPARAMS = 0x80206993 + SIOCSVH = 0xc02069f5 + SIOCSVNETID = 0x802069a6 + SOCK_DGRAM = 0x2 + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_SOCKET = 0xffff + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x2 + SO_BINDANY = 0x1000 + SO_BROADCAST = 0x20 + SO_DEBUG = 0x1 + SO_DONTROUTE = 0x10 + SO_ERROR = 0x1007 + SO_KEEPALIVE = 0x8 + SO_LINGER = 0x80 + SO_NETPROC = 0x1020 + SO_OOBINLINE = 0x100 + SO_PEERCRED = 0x1022 + SO_RCVBUF = 0x1002 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x1006 + SO_REUSEADDR = 0x4 + SO_REUSEPORT = 0x200 + SO_RTABLE = 0x1021 + SO_SNDBUF = 0x1001 + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x1005 + SO_SPLICE = 0x1023 + SO_TIMESTAMP = 0x800 + SO_TYPE = 0x1008 + SO_USELOOPBACK = 0x40 + TCIFLUSH = 0x1 + TCIOFLUSH = 0x3 + TCOFLUSH = 0x2 + TCP_MAXBURST = 0x4 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_SACK = 0x3 + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0x4 + TCP_MSS = 0x200 + TCP_NODELAY = 0x1 + TCP_NOPUSH = 0x10 + TCP_NSTATES = 0xb + TCP_SACK_ENABLE = 0x8 + TCSAFLUSH = 0x2 + TIOCCBRK = 0x2000747a + TIOCCDTR = 0x20007478 + TIOCCONS = 0x80047462 + TIOCDRAIN = 0x2000745e + TIOCEXCL = 0x2000740d + TIOCEXT = 0x80047460 + TIOCFLAG_CLOCAL = 0x2 + TIOCFLAG_CRTSCTS = 0x4 + TIOCFLAG_MDMBUF = 0x8 + TIOCFLAG_PPS = 0x10 + TIOCFLAG_SOFTCAR = 0x1 + TIOCFLUSH = 0x80047410 + TIOCGETA = 0x402c7413 + TIOCGETD = 0x4004741a + TIOCGFLAGS = 0x4004745d + TIOCGPGRP = 0x40047477 + TIOCGSID = 0x40047463 + TIOCGTSTAMP = 0x400c745b + TIOCGWINSZ = 0x40087468 + TIOCMBIC = 0x8004746b + TIOCMBIS = 0x8004746c + TIOCMGET = 0x4004746a + TIOCMODG = 0x4004746a + TIOCMODS = 0x8004746d + TIOCMSET = 0x8004746d + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x20007471 + TIOCNXCL = 0x2000740e + TIOCOUTQ = 0x40047473 + TIOCPKT = 0x80047470 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCREMOTE = 0x80047469 + TIOCSBRK = 0x2000747b + TIOCSCTTY = 0x20007461 + TIOCSDTR = 0x20007479 + TIOCSETA = 0x802c7414 + TIOCSETAF = 0x802c7416 + TIOCSETAW = 0x802c7415 + TIOCSETD = 0x8004741b + TIOCSFLAGS = 0x8004745c + TIOCSIG = 0x8004745f + TIOCSPGRP = 0x80047476 + TIOCSTART = 0x2000746e + TIOCSTAT = 0x80047465 + TIOCSTI = 0x80017472 + TIOCSTOP = 0x2000746f + TIOCSTSTAMP = 0x8008745a + TIOCSWINSZ = 0x80087467 + TIOCUCNTL = 0x80047466 + TOSTOP = 0x400000 + VDISCARD = 0xf + VDSUSP = 0xb + VEOF = 0x0 + VEOL = 0x1 + VEOL2 = 0x2 + VERASE = 0x3 + VINTR = 0x8 + VKILL = 0x5 + VLNEXT = 0xe + VMIN = 0x10 + VQUIT = 0x9 + VREPRINT = 0x6 + VSTART = 0xc + VSTATUS = 0x12 + VSTOP = 0xd + VSUSP = 0xa + VTIME = 0x11 + VWERASE = 0x4 + WALTSIG = 0x4 + WCONTINUED = 0x8 + WCOREFLAG = 0x80 + WNOHANG = 0x1 + WSTOPPED = 0x7f + WUNTRACED = 0x2 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x30) + EADDRNOTAVAIL = syscall.Errno(0x31) + EAFNOSUPPORT = syscall.Errno(0x2f) + EAGAIN = syscall.Errno(0x23) + EALREADY = syscall.Errno(0x25) + EAUTH = syscall.Errno(0x50) + EBADF = syscall.Errno(0x9) + EBADRPC = syscall.Errno(0x48) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x58) + ECHILD = syscall.Errno(0xa) + ECONNABORTED = syscall.Errno(0x35) + ECONNREFUSED = syscall.Errno(0x3d) + ECONNRESET = syscall.Errno(0x36) + EDEADLK = syscall.Errno(0xb) + EDESTADDRREQ = syscall.Errno(0x27) + EDOM = syscall.Errno(0x21) + EDQUOT = syscall.Errno(0x45) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EFTYPE = syscall.Errno(0x4f) + EHOSTDOWN = syscall.Errno(0x40) + EHOSTUNREACH = syscall.Errno(0x41) + EIDRM = syscall.Errno(0x59) + EILSEQ = syscall.Errno(0x54) + EINPROGRESS = syscall.Errno(0x24) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EIPSEC = syscall.Errno(0x52) + EISCONN = syscall.Errno(0x38) + EISDIR = syscall.Errno(0x15) + ELAST = syscall.Errno(0x5b) + ELOOP = syscall.Errno(0x3e) + EMEDIUMTYPE = syscall.Errno(0x56) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x28) + ENAMETOOLONG = syscall.Errno(0x3f) + ENEEDAUTH = syscall.Errno(0x51) + ENETDOWN = syscall.Errno(0x32) + ENETRESET = syscall.Errno(0x34) + ENETUNREACH = syscall.Errno(0x33) + ENFILE = syscall.Errno(0x17) + ENOATTR = syscall.Errno(0x53) + ENOBUFS = syscall.Errno(0x37) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOLCK = syscall.Errno(0x4d) + ENOMEDIUM = syscall.Errno(0x55) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x5a) + ENOPROTOOPT = syscall.Errno(0x2a) + ENOSPC = syscall.Errno(0x1c) + ENOSYS = syscall.Errno(0x4e) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x39) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x42) + ENOTSOCK = syscall.Errno(0x26) + ENOTSUP = syscall.Errno(0x5b) + ENOTTY = syscall.Errno(0x19) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x2d) + EOVERFLOW = syscall.Errno(0x57) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x2e) + EPIPE = syscall.Errno(0x20) + EPROCLIM = syscall.Errno(0x43) + EPROCUNAVAIL = syscall.Errno(0x4c) + EPROGMISMATCH = syscall.Errno(0x4b) + EPROGUNAVAIL = syscall.Errno(0x4a) + EPROTONOSUPPORT = syscall.Errno(0x2b) + EPROTOTYPE = syscall.Errno(0x29) + ERANGE = syscall.Errno(0x22) + EREMOTE = syscall.Errno(0x47) + EROFS = syscall.Errno(0x1e) + ERPCMISMATCH = syscall.Errno(0x49) + ESHUTDOWN = syscall.Errno(0x3a) + ESOCKTNOSUPPORT = syscall.Errno(0x2c) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESTALE = syscall.Errno(0x46) + ETIMEDOUT = syscall.Errno(0x3c) + ETOOMANYREFS = syscall.Errno(0x3b) + ETXTBSY = syscall.Errno(0x1a) + EUSERS = syscall.Errno(0x44) + EWOULDBLOCK = syscall.Errno(0x23) + EXDEV = syscall.Errno(0x12) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0xa) + SIGCHLD = syscall.Signal(0x14) + SIGCONT = syscall.Signal(0x13) + SIGEMT = syscall.Signal(0x7) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINFO = syscall.Signal(0x1d) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x17) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPROF = syscall.Signal(0x1b) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTOP = syscall.Signal(0x11) + SIGSYS = syscall.Signal(0xc) + SIGTERM = syscall.Signal(0xf) + SIGTHR = syscall.Signal(0x20) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x12) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGURG = syscall.Signal(0x10) + SIGUSR1 = syscall.Signal(0x1e) + SIGUSR2 = syscall.Signal(0x1f) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "device not configured", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource deadlock avoided", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device busy", + 17: "file exists", + 18: "cross-device link", + 19: "operation not supported by device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "result too large", + 35: "resource temporarily unavailable", + 36: "operation now in progress", + 37: "operation already in progress", + 38: "socket operation on non-socket", + 39: "destination address required", + 40: "message too long", + 41: "protocol wrong type for socket", + 42: "protocol not available", + 43: "protocol not supported", + 44: "socket type not supported", + 45: "operation not supported", + 46: "protocol family not supported", + 47: "address family not supported by protocol family", + 48: "address already in use", + 49: "can't assign requested address", + 50: "network is down", + 51: "network is unreachable", + 52: "network dropped connection on reset", + 53: "software caused connection abort", + 54: "connection reset by peer", + 55: "no buffer space available", + 56: "socket is already connected", + 57: "socket is not connected", + 58: "can't send after socket shutdown", + 59: "too many references: can't splice", + 60: "connection timed out", + 61: "connection refused", + 62: "too many levels of symbolic links", + 63: "file name too long", + 64: "host is down", + 65: "no route to host", + 66: "directory not empty", + 67: "too many processes", + 68: "too many users", + 69: "disc quota exceeded", + 70: "stale NFS file handle", + 71: "too many levels of remote in path", + 72: "RPC struct is bad", + 73: "RPC version wrong", + 74: "RPC prog. not avail", + 75: "program version wrong", + 76: "bad procedure for program", + 77: "no locks available", + 78: "function not implemented", + 79: "inappropriate file type or format", + 80: "authentication error", + 81: "need authenticator", + 82: "IPsec processing failure", + 83: "attribute not found", + 84: "illegal byte sequence", + 85: "no medium found", + 86: "wrong medium type", + 87: "value too large to be stored in data type", + 88: "operation canceled", + 89: "identifier removed", + 90: "no message of desired type", + 91: "not supported", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/BPT trap", + 6: "abort trap", + 7: "EMT trap", + 8: "floating point exception", + 9: "killed", + 10: "bus error", + 11: "segmentation fault", + 12: "bad system call", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "urgent I/O condition", + 17: "stopped (signal)", + 18: "stopped", + 19: "continued", + 20: "child exited", + 21: "stopped (tty input)", + 22: "stopped (tty output)", + 23: "I/O possible", + 24: "cputime limit exceeded", + 25: "filesize limit exceeded", + 26: "virtual timer expired", + 27: "profiling timer expired", + 28: "window size changes", + 29: "information request", + 30: "user defined signal 1", + 31: "user defined signal 2", + 32: "thread AST", +} diff --git a/vendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go new file mode 100644 index 0000000000..1758ecca93 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_openbsd_amd64.go @@ -0,0 +1,1583 @@ +// mkerrors.sh -m64 +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build amd64,openbsd + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -m64 _const.go + +package unix + +import "syscall" + +const ( + AF_APPLETALK = 0x10 + AF_BLUETOOTH = 0x20 + AF_CCITT = 0xa + AF_CHAOS = 0x5 + AF_CNT = 0x15 + AF_COIP = 0x14 + AF_DATAKIT = 0x9 + AF_DECnet = 0xc + AF_DLI = 0xd + AF_E164 = 0x1a + AF_ECMA = 0x8 + AF_ENCAP = 0x1c + AF_HYLINK = 0xf + AF_IMPLINK = 0x3 + AF_INET = 0x2 + AF_INET6 = 0x18 + AF_IPX = 0x17 + AF_ISDN = 0x1a + AF_ISO = 0x7 + AF_KEY = 0x1e + AF_LAT = 0xe + AF_LINK = 0x12 + AF_LOCAL = 0x1 + AF_MAX = 0x24 + AF_MPLS = 0x21 + AF_NATM = 0x1b + AF_NS = 0x6 + AF_OSI = 0x7 + AF_PUP = 0x4 + AF_ROUTE = 0x11 + AF_SIP = 0x1d + AF_SNA = 0xb + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + ARPHRD_ETHER = 0x1 + ARPHRD_FRELAY = 0xf + ARPHRD_IEEE1394 = 0x18 + ARPHRD_IEEE802 = 0x6 + B0 = 0x0 + B110 = 0x6e + B115200 = 0x1c200 + B1200 = 0x4b0 + B134 = 0x86 + B14400 = 0x3840 + B150 = 0x96 + B1800 = 0x708 + B19200 = 0x4b00 + B200 = 0xc8 + B230400 = 0x38400 + B2400 = 0x960 + B28800 = 0x7080 + B300 = 0x12c + B38400 = 0x9600 + B4800 = 0x12c0 + B50 = 0x32 + B57600 = 0xe100 + B600 = 0x258 + B7200 = 0x1c20 + B75 = 0x4b + B76800 = 0x12c00 + B9600 = 0x2580 + BIOCFLUSH = 0x20004268 + BIOCGBLEN = 0x40044266 + BIOCGDIRFILT = 0x4004427c + BIOCGDLT = 0x4004426a + BIOCGDLTLIST = 0xc010427b + BIOCGETIF = 0x4020426b + BIOCGFILDROP = 0x40044278 + BIOCGHDRCMPLT = 0x40044274 + BIOCGRSIG = 0x40044273 + BIOCGRTIMEOUT = 0x4010426e + BIOCGSTATS = 0x4008426f + BIOCIMMEDIATE = 0x80044270 + BIOCLOCK = 0x20004276 + BIOCPROMISC = 0x20004269 + BIOCSBLEN = 0xc0044266 + BIOCSDIRFILT = 0x8004427d + BIOCSDLT = 0x8004427a + BIOCSETF = 0x80104267 + BIOCSETIF = 0x8020426c + BIOCSETWF = 0x80104277 + BIOCSFILDROP = 0x80044279 + BIOCSHDRCMPLT = 0x80044275 + BIOCSRSIG = 0x80044272 + BIOCSRTIMEOUT = 0x8010426d + BIOCVERSION = 0x40044271 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALIGNMENT = 0x4 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIRECTION_IN = 0x1 + BPF_DIRECTION_OUT = 0x2 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXBUFSIZE = 0x200000 + BPF_MAXINSNS = 0x200 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINBUFSIZE = 0x20 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RELEASE = 0x30bb6 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BRKINT = 0x2 + CFLUSH = 0xf + CLOCAL = 0x8000 + CREAD = 0x800 + CS5 = 0x0 + CS6 = 0x100 + CS7 = 0x200 + CS8 = 0x300 + CSIZE = 0x300 + CSTART = 0x11 + CSTATUS = 0xff + CSTOP = 0x13 + CSTOPB = 0x400 + CSUSP = 0x1a + CTL_MAXNAME = 0xc + CTL_NET = 0x4 + DIOCOSFPFLUSH = 0x2000444e + DLT_ARCNET = 0x7 + DLT_ATM_RFC1483 = 0xb + DLT_AX25 = 0x3 + DLT_CHAOS = 0x5 + DLT_C_HDLC = 0x68 + DLT_EN10MB = 0x1 + DLT_EN3MB = 0x2 + DLT_ENC = 0xd + DLT_FDDI = 0xa + DLT_IEEE802 = 0x6 + DLT_IEEE802_11 = 0x69 + DLT_IEEE802_11_RADIO = 0x7f + DLT_LOOP = 0xc + DLT_MPLS = 0xdb + DLT_NULL = 0x0 + DLT_PFLOG = 0x75 + DLT_PFSYNC = 0x12 + DLT_PPP = 0x9 + DLT_PPP_BSDOS = 0x10 + DLT_PPP_ETHER = 0x33 + DLT_PPP_SERIAL = 0x32 + DLT_PRONET = 0x4 + DLT_RAW = 0xe + DLT_SLIP = 0x8 + DLT_SLIP_BSDOS = 0xf + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + ECHO = 0x8 + ECHOCTL = 0x40 + ECHOE = 0x2 + ECHOK = 0x4 + ECHOKE = 0x1 + ECHONL = 0x10 + ECHOPRT = 0x20 + EMT_TAGOVF = 0x1 + EMUL_ENABLED = 0x1 + EMUL_NATIVE = 0x2 + ENDRUNDISC = 0x9 + ETHERMIN = 0x2e + ETHERMTU = 0x5dc + ETHERTYPE_8023 = 0x4 + ETHERTYPE_AARP = 0x80f3 + ETHERTYPE_ACCTON = 0x8390 + ETHERTYPE_AEONIC = 0x8036 + ETHERTYPE_ALPHA = 0x814a + ETHERTYPE_AMBER = 0x6008 + ETHERTYPE_AMOEBA = 0x8145 + ETHERTYPE_AOE = 0x88a2 + ETHERTYPE_APOLLO = 0x80f7 + ETHERTYPE_APOLLODOMAIN = 0x8019 + ETHERTYPE_APPLETALK = 0x809b + ETHERTYPE_APPLITEK = 0x80c7 + ETHERTYPE_ARGONAUT = 0x803a + ETHERTYPE_ARP = 0x806 + ETHERTYPE_AT = 0x809b + ETHERTYPE_ATALK = 0x809b + ETHERTYPE_ATOMIC = 0x86df + ETHERTYPE_ATT = 0x8069 + ETHERTYPE_ATTSTANFORD = 0x8008 + ETHERTYPE_AUTOPHON = 0x806a + ETHERTYPE_AXIS = 0x8856 + ETHERTYPE_BCLOOP = 0x9003 + ETHERTYPE_BOFL = 0x8102 + ETHERTYPE_CABLETRON = 0x7034 + ETHERTYPE_CHAOS = 0x804 + ETHERTYPE_COMDESIGN = 0x806c + ETHERTYPE_COMPUGRAPHIC = 0x806d + ETHERTYPE_COUNTERPOINT = 0x8062 + ETHERTYPE_CRONUS = 0x8004 + ETHERTYPE_CRONUSVLN = 0x8003 + ETHERTYPE_DCA = 0x1234 + ETHERTYPE_DDE = 0x807b + ETHERTYPE_DEBNI = 0xaaaa + ETHERTYPE_DECAM = 0x8048 + ETHERTYPE_DECCUST = 0x6006 + ETHERTYPE_DECDIAG = 0x6005 + ETHERTYPE_DECDNS = 0x803c + ETHERTYPE_DECDTS = 0x803e + ETHERTYPE_DECEXPER = 0x6000 + ETHERTYPE_DECLAST = 0x8041 + ETHERTYPE_DECLTM = 0x803f + ETHERTYPE_DECMUMPS = 0x6009 + ETHERTYPE_DECNETBIOS = 0x8040 + ETHERTYPE_DELTACON = 0x86de + ETHERTYPE_DIDDLE = 0x4321 + ETHERTYPE_DLOG1 = 0x660 + ETHERTYPE_DLOG2 = 0x661 + ETHERTYPE_DN = 0x6003 + ETHERTYPE_DOGFIGHT = 0x1989 + ETHERTYPE_DSMD = 0x8039 + ETHERTYPE_ECMA = 0x803 + ETHERTYPE_ENCRYPT = 0x803d + ETHERTYPE_ES = 0x805d + ETHERTYPE_EXCELAN = 0x8010 + ETHERTYPE_EXPERDATA = 0x8049 + ETHERTYPE_FLIP = 0x8146 + ETHERTYPE_FLOWCONTROL = 0x8808 + ETHERTYPE_FRARP = 0x808 + ETHERTYPE_GENDYN = 0x8068 + ETHERTYPE_HAYES = 0x8130 + ETHERTYPE_HIPPI_FP = 0x8180 + ETHERTYPE_HITACHI = 0x8820 + ETHERTYPE_HP = 0x8005 + ETHERTYPE_IEEEPUP = 0xa00 + ETHERTYPE_IEEEPUPAT = 0xa01 + ETHERTYPE_IMLBL = 0x4c42 + ETHERTYPE_IMLBLDIAG = 0x424c + ETHERTYPE_IP = 0x800 + ETHERTYPE_IPAS = 0x876c + ETHERTYPE_IPV6 = 0x86dd + ETHERTYPE_IPX = 0x8137 + ETHERTYPE_IPXNEW = 0x8037 + ETHERTYPE_KALPANA = 0x8582 + ETHERTYPE_LANBRIDGE = 0x8038 + ETHERTYPE_LANPROBE = 0x8888 + ETHERTYPE_LAT = 0x6004 + ETHERTYPE_LBACK = 0x9000 + ETHERTYPE_LITTLE = 0x8060 + ETHERTYPE_LLDP = 0x88cc + ETHERTYPE_LOGICRAFT = 0x8148 + ETHERTYPE_LOOPBACK = 0x9000 + ETHERTYPE_MATRA = 0x807a + ETHERTYPE_MAX = 0xffff + ETHERTYPE_MERIT = 0x807c + ETHERTYPE_MICP = 0x873a + ETHERTYPE_MOPDL = 0x6001 + ETHERTYPE_MOPRC = 0x6002 + ETHERTYPE_MOTOROLA = 0x818d + ETHERTYPE_MPLS = 0x8847 + ETHERTYPE_MPLS_MCAST = 0x8848 + ETHERTYPE_MUMPS = 0x813f + ETHERTYPE_NBPCC = 0x3c04 + ETHERTYPE_NBPCLAIM = 0x3c09 + ETHERTYPE_NBPCLREQ = 0x3c05 + ETHERTYPE_NBPCLRSP = 0x3c06 + ETHERTYPE_NBPCREQ = 0x3c02 + ETHERTYPE_NBPCRSP = 0x3c03 + ETHERTYPE_NBPDG = 0x3c07 + ETHERTYPE_NBPDGB = 0x3c08 + ETHERTYPE_NBPDLTE = 0x3c0a + ETHERTYPE_NBPRAR = 0x3c0c + ETHERTYPE_NBPRAS = 0x3c0b + ETHERTYPE_NBPRST = 0x3c0d + ETHERTYPE_NBPSCD = 0x3c01 + ETHERTYPE_NBPVCD = 0x3c00 + ETHERTYPE_NBS = 0x802 + ETHERTYPE_NCD = 0x8149 + ETHERTYPE_NESTAR = 0x8006 + ETHERTYPE_NETBEUI = 0x8191 + ETHERTYPE_NOVELL = 0x8138 + ETHERTYPE_NS = 0x600 + ETHERTYPE_NSAT = 0x601 + ETHERTYPE_NSCOMPAT = 0x807 + ETHERTYPE_NTRAILER = 0x10 + ETHERTYPE_OS9 = 0x7007 + ETHERTYPE_OS9NET = 0x7009 + ETHERTYPE_PACER = 0x80c6 + ETHERTYPE_PAE = 0x888e + ETHERTYPE_PCS = 0x4242 + ETHERTYPE_PLANNING = 0x8044 + ETHERTYPE_PPP = 0x880b + ETHERTYPE_PPPOE = 0x8864 + ETHERTYPE_PPPOEDISC = 0x8863 + ETHERTYPE_PRIMENTS = 0x7031 + ETHERTYPE_PUP = 0x200 + ETHERTYPE_PUPAT = 0x200 + ETHERTYPE_QINQ = 0x88a8 + ETHERTYPE_RACAL = 0x7030 + ETHERTYPE_RATIONAL = 0x8150 + ETHERTYPE_RAWFR = 0x6559 + ETHERTYPE_RCL = 0x1995 + ETHERTYPE_RDP = 0x8739 + ETHERTYPE_RETIX = 0x80f2 + ETHERTYPE_REVARP = 0x8035 + ETHERTYPE_SCA = 0x6007 + ETHERTYPE_SECTRA = 0x86db + ETHERTYPE_SECUREDATA = 0x876d + ETHERTYPE_SGITW = 0x817e + ETHERTYPE_SG_BOUNCE = 0x8016 + ETHERTYPE_SG_DIAG = 0x8013 + ETHERTYPE_SG_NETGAMES = 0x8014 + ETHERTYPE_SG_RESV = 0x8015 + ETHERTYPE_SIMNET = 0x5208 + ETHERTYPE_SLOW = 0x8809 + ETHERTYPE_SNA = 0x80d5 + ETHERTYPE_SNMP = 0x814c + ETHERTYPE_SONIX = 0xfaf5 + ETHERTYPE_SPIDER = 0x809f + ETHERTYPE_SPRITE = 0x500 + ETHERTYPE_STP = 0x8181 + ETHERTYPE_TALARIS = 0x812b + ETHERTYPE_TALARISMC = 0x852b + ETHERTYPE_TCPCOMP = 0x876b + ETHERTYPE_TCPSM = 0x9002 + ETHERTYPE_TEC = 0x814f + ETHERTYPE_TIGAN = 0x802f + ETHERTYPE_TRAIL = 0x1000 + ETHERTYPE_TRANSETHER = 0x6558 + ETHERTYPE_TYMSHARE = 0x802e + ETHERTYPE_UBBST = 0x7005 + ETHERTYPE_UBDEBUG = 0x900 + ETHERTYPE_UBDIAGLOOP = 0x7002 + ETHERTYPE_UBDL = 0x7000 + ETHERTYPE_UBNIU = 0x7001 + ETHERTYPE_UBNMC = 0x7003 + ETHERTYPE_VALID = 0x1600 + ETHERTYPE_VARIAN = 0x80dd + ETHERTYPE_VAXELN = 0x803b + ETHERTYPE_VEECO = 0x8067 + ETHERTYPE_VEXP = 0x805b + ETHERTYPE_VGLAB = 0x8131 + ETHERTYPE_VINES = 0xbad + ETHERTYPE_VINESECHO = 0xbaf + ETHERTYPE_VINESLOOP = 0xbae + ETHERTYPE_VITAL = 0xff00 + ETHERTYPE_VLAN = 0x8100 + ETHERTYPE_VLTLMAN = 0x8080 + ETHERTYPE_VPROD = 0x805c + ETHERTYPE_VURESERVED = 0x8147 + ETHERTYPE_WATERLOO = 0x8130 + ETHERTYPE_WELLFLEET = 0x8103 + ETHERTYPE_X25 = 0x805 + ETHERTYPE_X75 = 0x801 + ETHERTYPE_XNSSM = 0x9001 + ETHERTYPE_XTP = 0x817d + ETHER_ADDR_LEN = 0x6 + ETHER_ALIGN = 0x2 + ETHER_CRC_LEN = 0x4 + ETHER_CRC_POLY_BE = 0x4c11db6 + ETHER_CRC_POLY_LE = 0xedb88320 + ETHER_HDR_LEN = 0xe + ETHER_MAX_DIX_LEN = 0x600 + ETHER_MAX_LEN = 0x5ee + ETHER_MIN_LEN = 0x40 + ETHER_TYPE_LEN = 0x2 + ETHER_VLAN_ENCAP_LEN = 0x4 + EVFILT_AIO = -0x3 + EVFILT_PROC = -0x5 + EVFILT_READ = -0x1 + EVFILT_SIGNAL = -0x6 + EVFILT_SYSCOUNT = 0x7 + EVFILT_TIMER = -0x7 + EVFILT_VNODE = -0x4 + EVFILT_WRITE = -0x2 + EV_ADD = 0x1 + EV_CLEAR = 0x20 + EV_DELETE = 0x2 + EV_DISABLE = 0x8 + EV_ENABLE = 0x4 + EV_EOF = 0x8000 + EV_ERROR = 0x4000 + EV_FLAG1 = 0x2000 + EV_ONESHOT = 0x10 + EV_SYSFLAGS = 0xf000 + EXTA = 0x4b00 + EXTB = 0x9600 + EXTPROC = 0x800 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FLUSHO = 0x800000 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0xa + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLK = 0x7 + F_GETOWN = 0x5 + F_OK = 0x0 + F_RDLCK = 0x1 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLK = 0x8 + F_SETLKW = 0x9 + F_SETOWN = 0x6 + F_UNLCK = 0x2 + F_WRLCK = 0x3 + HUPCL = 0x4000 + ICANON = 0x100 + ICMP6_FILTER = 0x12 + ICRNL = 0x100 + IEXTEN = 0x400 + IFAN_ARRIVAL = 0x0 + IFAN_DEPARTURE = 0x1 + IFA_ROUTE = 0x1 + IFF_ALLMULTI = 0x200 + IFF_BROADCAST = 0x2 + IFF_CANTCHANGE = 0x8e52 + IFF_DEBUG = 0x4 + IFF_LINK0 = 0x1000 + IFF_LINK1 = 0x2000 + IFF_LINK2 = 0x4000 + IFF_LOOPBACK = 0x8 + IFF_MULTICAST = 0x8000 + IFF_NOARP = 0x80 + IFF_NOTRAILERS = 0x20 + IFF_OACTIVE = 0x400 + IFF_POINTOPOINT = 0x10 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SIMPLEX = 0x800 + IFF_UP = 0x1 + IFNAMSIZ = 0x10 + 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_BLUETOOTH = 0xf8 + IFT_BRIDGE = 0xd1 + IFT_BSC = 0x53 + IFT_CARP = 0xf7 + 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_DOCSCABLEUPSTREAMCHANNEL = 0xcd + IFT_DS0 = 0x51 + IFT_DS0BUNDLE = 0x52 + IFT_DS1FDL = 0xaa + IFT_DS3 = 0x1e + IFT_DTM = 0x8c + IFT_DUMMY = 0xf1 + IFT_DVBASILN = 0xac + IFT_DVBASIOUT = 0xad + IFT_DVBRCCDOWNSTREAM = 0x93 + IFT_DVBRCCMACLAYER = 0x92 + IFT_DVBRCCUPSTREAM = 0x94 + IFT_ECONET = 0xce + IFT_ENC = 0xf4 + IFT_EON = 0x19 + IFT_EPLRS = 0x57 + IFT_ESCON = 0x49 + IFT_ETHER = 0x6 + IFT_FAITH = 0xf3 + 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_IEEE1394 = 0x90 + IFT_IEEE80211 = 0x47 + IFT_IEEE80212 = 0x37 + IFT_IEEE8023ADLAG = 0xa1 + IFT_IFGSN = 0x91 + IFT_IMT = 0xbe + IFT_INFINIBAND = 0xc7 + IFT_INTERLEAVE = 0x7c + IFT_IP = 0x7e + IFT_IPFORWARD = 0x8e + IFT_IPOVERATM = 0x72 + IFT_IPOVERCDLC = 0x6d + IFT_IPOVERCLAW = 0x6e + IFT_IPSWITCH = 0x4e + 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_L2VLAN = 0x87 + IFT_L3IPVLAN = 0x88 + IFT_L3IPXVLAN = 0x89 + IFT_LAPB = 0x10 + IFT_LAPD = 0x4d + IFT_LAPF = 0x77 + IFT_LINEGROUP = 0xd2 + 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 = 0xf5 + IFT_PFLOW = 0xf9 + IFT_PFSYNC = 0xf6 + IFT_PLC = 0xae + IFT_PON155 = 0xcf + IFT_PON622 = 0xd0 + IFT_POS = 0xab + IFT_PPP = 0x17 + IFT_PPPMULTILINKBUNDLE = 0x6c + IFT_PROPATM = 0xc5 + IFT_PROPBWAP2MP = 0xb8 + IFT_PROPCNLS = 0x59 + IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5 + IFT_PROPDOCSWIRELESSMACLAYER = 0xb4 + IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6 + IFT_PROPMUX = 0x36 + IFT_PROPVIRTUAL = 0x35 + IFT_PROPWIRELESSP2P = 0x9d + IFT_PTPSERIAL = 0x16 + IFT_PVC = 0xf2 + IFT_Q2931 = 0xc9 + 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_SIPSIG = 0xcc + IFT_SIPTG = 0xcb + 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_T1 = 0x12 + IFT_TDLC = 0x74 + IFT_TELINK = 0xc8 + 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_VIRTUALTG = 0xca + IFT_VOICEDID = 0xd5 + IFT_VOICEEM = 0x64 + IFT_VOICEEMFGD = 0xd3 + IFT_VOICEENCAP = 0x67 + IFT_VOICEFGDEANA = 0xd4 + IFT_VOICEFXO = 0x65 + IFT_VOICEFXS = 0x66 + IFT_VOICEOVERATM = 0x98 + IFT_VOICEOVERCABLE = 0xc6 + 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 + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLASSD_HOST = 0xfffffff + IN_CLASSD_NET = 0xf0000000 + IN_CLASSD_NSHIFT = 0x1c + IN_LOOPBACKNET = 0x7f + IN_RFC3021_HOST = 0x1 + IN_RFC3021_NET = 0xfffffffe + IN_RFC3021_NSHIFT = 0x1f + IPPROTO_AH = 0x33 + IPPROTO_CARP = 0x70 + IPPROTO_DIVERT = 0x102 + IPPROTO_DIVERT_INIT = 0x2 + IPPROTO_DIVERT_RESP = 0x1 + IPPROTO_DONE = 0x101 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_ENCAP = 0x62 + IPPROTO_EON = 0x50 + IPPROTO_ESP = 0x32 + IPPROTO_ETHERIP = 0x61 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GGP = 0x3 + IPPROTO_GRE = 0x2f + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IGMP = 0x2 + IPPROTO_IP = 0x0 + IPPROTO_IPCOMP = 0x6c + IPPROTO_IPIP = 0x4 + IPPROTO_IPV4 = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_MAX = 0x100 + IPPROTO_MAXID = 0x103 + IPPROTO_MOBILE = 0x37 + IPPROTO_MPLS = 0x89 + IPPROTO_NONE = 0x3b + IPPROTO_PFSYNC = 0xf0 + IPPROTO_PIM = 0x67 + IPPROTO_PUP = 0xc + IPPROTO_RAW = 0xff + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_UDP = 0x11 + IPV6_AUTH_LEVEL = 0x35 + IPV6_AUTOFLOWLABEL = 0x3b + IPV6_CHECKSUM = 0x1a + IPV6_DEFAULT_MULTICAST_HOPS = 0x1 + IPV6_DEFAULT_MULTICAST_LOOP = 0x1 + IPV6_DEFHLIM = 0x40 + IPV6_DONTFRAG = 0x3e + IPV6_DSTOPTS = 0x32 + IPV6_ESP_NETWORK_LEVEL = 0x37 + IPV6_ESP_TRANS_LEVEL = 0x36 + IPV6_FAITH = 0x1d + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 + IPV6_FRAGTTL = 0x78 + IPV6_HLIMDEC = 0x1 + IPV6_HOPLIMIT = 0x2f + IPV6_HOPOPTS = 0x31 + IPV6_IPCOMP_LEVEL = 0x3c + IPV6_JOIN_GROUP = 0xc + IPV6_LEAVE_GROUP = 0xd + IPV6_MAXHLIM = 0xff + IPV6_MAXPACKET = 0xffff + IPV6_MMTU = 0x500 + IPV6_MULTICAST_HOPS = 0xa + IPV6_MULTICAST_IF = 0x9 + IPV6_MULTICAST_LOOP = 0xb + IPV6_NEXTHOP = 0x30 + IPV6_OPTIONS = 0x1 + IPV6_PATHMTU = 0x2c + IPV6_PIPEX = 0x3f + IPV6_PKTINFO = 0x2e + IPV6_PORTRANGE = 0xe + IPV6_PORTRANGE_DEFAULT = 0x0 + IPV6_PORTRANGE_HIGH = 0x1 + IPV6_PORTRANGE_LOW = 0x2 + IPV6_RECVDSTOPTS = 0x28 + IPV6_RECVDSTPORT = 0x40 + IPV6_RECVHOPLIMIT = 0x25 + IPV6_RECVHOPOPTS = 0x27 + IPV6_RECVPATHMTU = 0x2b + IPV6_RECVPKTINFO = 0x24 + IPV6_RECVRTHDR = 0x26 + IPV6_RECVTCLASS = 0x39 + IPV6_RTABLE = 0x1021 + IPV6_RTHDR = 0x33 + IPV6_RTHDRDSTOPTS = 0x23 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_SOCKOPT_RESERVED1 = 0x3 + IPV6_TCLASS = 0x3d + IPV6_UNICAST_HOPS = 0x4 + IPV6_USE_MIN_MTU = 0x2a + IPV6_V6ONLY = 0x1b + IPV6_VERSION = 0x60 + IPV6_VERSION_MASK = 0xf0 + IP_ADD_MEMBERSHIP = 0xc + IP_AUTH_LEVEL = 0x14 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DIVERTFL = 0x1022 + IP_DROP_MEMBERSHIP = 0xd + IP_ESP_NETWORK_LEVEL = 0x16 + IP_ESP_TRANS_LEVEL = 0x15 + IP_HDRINCL = 0x2 + IP_IPCOMP_LEVEL = 0x1d + IP_IPSECFLOWINFO = 0x24 + IP_IPSEC_LOCAL_AUTH = 0x1b + IP_IPSEC_LOCAL_CRED = 0x19 + IP_IPSEC_LOCAL_ID = 0x17 + IP_IPSEC_REMOTE_AUTH = 0x1c + IP_IPSEC_REMOTE_CRED = 0x1a + IP_IPSEC_REMOTE_ID = 0x18 + IP_MAXPACKET = 0xffff + IP_MAX_MEMBERSHIPS = 0xfff + IP_MF = 0x2000 + IP_MINTTL = 0x20 + IP_MIN_MEMBERSHIPS = 0xf + IP_MSS = 0x240 + IP_MULTICAST_IF = 0x9 + IP_MULTICAST_LOOP = 0xb + IP_MULTICAST_TTL = 0xa + IP_OFFMASK = 0x1fff + IP_OPTIONS = 0x1 + IP_PIPEX = 0x22 + IP_PORTRANGE = 0x13 + IP_PORTRANGE_DEFAULT = 0x0 + IP_PORTRANGE_HIGH = 0x1 + IP_PORTRANGE_LOW = 0x2 + IP_RECVDSTADDR = 0x7 + IP_RECVDSTPORT = 0x21 + IP_RECVIF = 0x1e + IP_RECVOPTS = 0x5 + IP_RECVRETOPTS = 0x6 + IP_RECVRTABLE = 0x23 + IP_RECVTTL = 0x1f + IP_RETOPTS = 0x8 + IP_RF = 0x8000 + IP_RTABLE = 0x1021 + IP_TOS = 0x3 + IP_TTL = 0x4 + ISIG = 0x80 + ISTRIP = 0x20 + IXANY = 0x800 + IXOFF = 0x400 + IXON = 0x200 + LCNT_OVERLOAD_FLUSH = 0x6 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_DONTNEED = 0x4 + MADV_FREE = 0x6 + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_SEQUENTIAL = 0x2 + MADV_SPACEAVAIL = 0x5 + MADV_WILLNEED = 0x3 + MAP_ANON = 0x1000 + MAP_COPY = 0x4 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_FLAGMASK = 0x1ff7 + MAP_HASSEMAPHORE = 0x200 + MAP_INHERIT = 0x80 + MAP_INHERIT_COPY = 0x1 + MAP_INHERIT_DONATE_COPY = 0x3 + MAP_INHERIT_NONE = 0x2 + MAP_INHERIT_SHARE = 0x0 + MAP_NOEXTEND = 0x100 + MAP_NORESERVE = 0x40 + MAP_PRIVATE = 0x2 + MAP_RENAME = 0x20 + MAP_SHARED = 0x1 + MAP_TRYFIXED = 0x400 + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MSG_BCAST = 0x100 + MSG_CTRUNC = 0x20 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x80 + MSG_EOR = 0x8 + MSG_MCAST = 0x200 + MSG_NOSIGNAL = 0x400 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_TRUNC = 0x10 + MSG_WAITALL = 0x40 + MS_ASYNC = 0x1 + MS_INVALIDATE = 0x4 + MS_SYNC = 0x2 + NAME_MAX = 0xff + NET_RT_DUMP = 0x1 + NET_RT_FLAGS = 0x2 + NET_RT_IFLIST = 0x3 + NET_RT_MAXID = 0x6 + NET_RT_STATS = 0x4 + NET_RT_TABLE = 0x5 + NOFLSH = 0x80000000 + NOTE_ATTRIB = 0x8 + NOTE_CHILD = 0x4 + NOTE_DELETE = 0x1 + NOTE_EOF = 0x2 + NOTE_EXEC = 0x20000000 + NOTE_EXIT = 0x80000000 + NOTE_EXTEND = 0x4 + NOTE_FORK = 0x40000000 + NOTE_LINK = 0x10 + NOTE_LOWAT = 0x1 + NOTE_PCTRLMASK = 0xf0000000 + NOTE_PDATAMASK = 0xfffff + NOTE_RENAME = 0x20 + NOTE_REVOKE = 0x40 + NOTE_TRACK = 0x1 + NOTE_TRACKERR = 0x2 + NOTE_TRUNCATE = 0x80 + NOTE_WRITE = 0x2 + OCRNL = 0x10 + ONLCR = 0x2 + ONLRET = 0x80 + ONOCR = 0x40 + ONOEOT = 0x8 + OPOST = 0x1 + O_ACCMODE = 0x3 + O_APPEND = 0x8 + O_ASYNC = 0x40 + O_CLOEXEC = 0x10000 + O_CREAT = 0x200 + O_DIRECTORY = 0x20000 + O_DSYNC = 0x80 + O_EXCL = 0x800 + O_EXLOCK = 0x20 + O_FSYNC = 0x80 + O_NDELAY = 0x4 + O_NOCTTY = 0x8000 + O_NOFOLLOW = 0x100 + O_NONBLOCK = 0x4 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_RSYNC = 0x80 + O_SHLOCK = 0x10 + O_SYNC = 0x80 + O_TRUNC = 0x400 + O_WRONLY = 0x1 + PARENB = 0x1000 + PARMRK = 0x8 + PARODD = 0x2000 + PENDIN = 0x20000000 + PF_FLUSH = 0x1 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x8 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = 0x7fffffffffffffff + RTAX_AUTHOR = 0x6 + RTAX_BRD = 0x7 + RTAX_DST = 0x0 + RTAX_GATEWAY = 0x1 + RTAX_GENMASK = 0x3 + RTAX_IFA = 0x5 + RTAX_IFP = 0x4 + RTAX_LABEL = 0xa + RTAX_MAX = 0xb + RTAX_NETMASK = 0x2 + RTAX_SRC = 0x8 + RTAX_SRCMASK = 0x9 + RTA_AUTHOR = 0x40 + RTA_BRD = 0x80 + RTA_DST = 0x1 + RTA_GATEWAY = 0x2 + RTA_GENMASK = 0x8 + RTA_IFA = 0x20 + RTA_IFP = 0x10 + RTA_LABEL = 0x400 + RTA_NETMASK = 0x4 + RTA_SRC = 0x100 + RTA_SRCMASK = 0x200 + RTF_ANNOUNCE = 0x4000 + RTF_BLACKHOLE = 0x1000 + RTF_CLONED = 0x10000 + RTF_CLONING = 0x100 + RTF_DONE = 0x40 + RTF_DYNAMIC = 0x10 + RTF_FMASK = 0x10f808 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_LLINFO = 0x400 + RTF_MASK = 0x80 + RTF_MODIFIED = 0x20 + RTF_MPATH = 0x40000 + RTF_MPLS = 0x100000 + RTF_PERMANENT_ARP = 0x2000 + RTF_PROTO1 = 0x8000 + RTF_PROTO2 = 0x4000 + RTF_PROTO3 = 0x2000 + RTF_REJECT = 0x8 + RTF_SOURCE = 0x20000 + RTF_STATIC = 0x800 + RTF_TUNNEL = 0x100000 + RTF_UP = 0x1 + RTF_USETRAILERS = 0x8000 + RTF_XRESOLVE = 0x200 + RTM_ADD = 0x1 + RTM_CHANGE = 0x3 + RTM_DELADDR = 0xd + RTM_DELETE = 0x2 + RTM_DESYNC = 0x10 + RTM_GET = 0x4 + RTM_IFANNOUNCE = 0xf + RTM_IFINFO = 0xe + RTM_LOCK = 0x8 + RTM_LOSING = 0x5 + RTM_MAXSIZE = 0x800 + RTM_MISS = 0x7 + RTM_NEWADDR = 0xc + RTM_REDIRECT = 0x6 + RTM_RESOLVE = 0xb + RTM_RTTUNIT = 0xf4240 + RTM_VERSION = 0x5 + RTV_EXPIRE = 0x4 + RTV_HOPCOUNT = 0x2 + RTV_MTU = 0x1 + RTV_RPIPE = 0x8 + RTV_RTT = 0x40 + RTV_RTTVAR = 0x80 + RTV_SPIPE = 0x10 + RTV_SSTHRESH = 0x20 + RT_TABLEID_MAX = 0xff + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + RUSAGE_THREAD = 0x1 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x4 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDMULTI = 0x80206931 + SIOCAIFADDR = 0x8040691a + SIOCAIFGROUP = 0x80286987 + SIOCALIFADDR = 0x8218691c + SIOCATMARK = 0x40047307 + SIOCBRDGADD = 0x8058693c + SIOCBRDGADDS = 0x80586941 + SIOCBRDGARL = 0x806e694d + SIOCBRDGDADDR = 0x81286947 + SIOCBRDGDEL = 0x8058693d + SIOCBRDGDELS = 0x80586942 + SIOCBRDGFLUSH = 0x80586948 + SIOCBRDGFRL = 0x806e694e + SIOCBRDGGCACHE = 0xc0146941 + SIOCBRDGGFD = 0xc0146952 + SIOCBRDGGHT = 0xc0146951 + SIOCBRDGGIFFLGS = 0xc058693e + SIOCBRDGGMA = 0xc0146953 + SIOCBRDGGPARAM = 0xc0406958 + SIOCBRDGGPRI = 0xc0146950 + SIOCBRDGGRL = 0xc030694f + SIOCBRDGGSIFS = 0xc058693c + SIOCBRDGGTO = 0xc0146946 + SIOCBRDGIFS = 0xc0586942 + SIOCBRDGRTS = 0xc0206943 + SIOCBRDGSADDR = 0xc1286944 + SIOCBRDGSCACHE = 0x80146940 + SIOCBRDGSFD = 0x80146952 + SIOCBRDGSHT = 0x80146951 + SIOCBRDGSIFCOST = 0x80586955 + SIOCBRDGSIFFLGS = 0x8058693f + SIOCBRDGSIFPRIO = 0x80586954 + SIOCBRDGSMA = 0x80146953 + SIOCBRDGSPRI = 0x80146950 + SIOCBRDGSPROTO = 0x8014695a + SIOCBRDGSTO = 0x80146945 + SIOCBRDGSTXHC = 0x80146959 + SIOCDELMULTI = 0x80206932 + SIOCDIFADDR = 0x80206919 + SIOCDIFGROUP = 0x80286989 + SIOCDIFPHYADDR = 0x80206949 + SIOCDLIFADDR = 0x8218691e + SIOCGETKALIVE = 0xc01869a4 + SIOCGETLABEL = 0x8020699a + SIOCGETPFLOW = 0xc02069fe + SIOCGETPFSYNC = 0xc02069f8 + SIOCGETSGCNT = 0xc0207534 + SIOCGETVIFCNT = 0xc0287533 + SIOCGETVLAN = 0xc0206990 + SIOCGHIWAT = 0x40047301 + SIOCGIFADDR = 0xc0206921 + SIOCGIFASYNCMAP = 0xc020697c + SIOCGIFBRDADDR = 0xc0206923 + SIOCGIFCONF = 0xc0106924 + SIOCGIFDATA = 0xc020691b + SIOCGIFDESCR = 0xc0206981 + SIOCGIFDSTADDR = 0xc0206922 + SIOCGIFFLAGS = 0xc0206911 + SIOCGIFGATTR = 0xc028698b + SIOCGIFGENERIC = 0xc020693a + SIOCGIFGMEMB = 0xc028698a + SIOCGIFGROUP = 0xc0286988 + SIOCGIFHARDMTU = 0xc02069a5 + SIOCGIFMEDIA = 0xc0306936 + SIOCGIFMETRIC = 0xc0206917 + SIOCGIFMTU = 0xc020697e + SIOCGIFNETMASK = 0xc0206925 + SIOCGIFPDSTADDR = 0xc0206948 + SIOCGIFPRIORITY = 0xc020699c + SIOCGIFPSRCADDR = 0xc0206947 + SIOCGIFRDOMAIN = 0xc02069a0 + SIOCGIFRTLABEL = 0xc0206983 + SIOCGIFTIMESLOT = 0xc0206986 + SIOCGIFXFLAGS = 0xc020699e + SIOCGLIFADDR = 0xc218691d + SIOCGLIFPHYADDR = 0xc218694b + SIOCGLIFPHYRTABLE = 0xc02069a2 + SIOCGLIFPHYTTL = 0xc02069a9 + SIOCGLOWAT = 0x40047303 + SIOCGPGRP = 0x40047309 + SIOCGSPPPPARAMS = 0xc0206994 + SIOCGVH = 0xc02069f6 + SIOCGVNETID = 0xc02069a7 + SIOCIFCREATE = 0x8020697a + SIOCIFDESTROY = 0x80206979 + SIOCIFGCLONERS = 0xc0106978 + SIOCSETKALIVE = 0x801869a3 + SIOCSETLABEL = 0x80206999 + SIOCSETPFLOW = 0x802069fd + SIOCSETPFSYNC = 0x802069f7 + SIOCSETVLAN = 0x8020698f + SIOCSHIWAT = 0x80047300 + SIOCSIFADDR = 0x8020690c + SIOCSIFASYNCMAP = 0x8020697d + SIOCSIFBRDADDR = 0x80206913 + SIOCSIFDESCR = 0x80206980 + SIOCSIFDSTADDR = 0x8020690e + SIOCSIFFLAGS = 0x80206910 + SIOCSIFGATTR = 0x8028698c + SIOCSIFGENERIC = 0x80206939 + SIOCSIFLLADDR = 0x8020691f + SIOCSIFMEDIA = 0xc0206935 + SIOCSIFMETRIC = 0x80206918 + SIOCSIFMTU = 0x8020697f + SIOCSIFNETMASK = 0x80206916 + SIOCSIFPHYADDR = 0x80406946 + SIOCSIFPRIORITY = 0x8020699b + SIOCSIFRDOMAIN = 0x8020699f + SIOCSIFRTLABEL = 0x80206982 + SIOCSIFTIMESLOT = 0x80206985 + SIOCSIFXFLAGS = 0x8020699d + SIOCSLIFPHYADDR = 0x8218694a + SIOCSLIFPHYRTABLE = 0x802069a1 + SIOCSLIFPHYTTL = 0x802069a8 + SIOCSLOWAT = 0x80047302 + SIOCSPGRP = 0x80047308 + SIOCSSPPPPARAMS = 0x80206993 + SIOCSVH = 0xc02069f5 + SIOCSVNETID = 0x802069a6 + SOCK_DGRAM = 0x2 + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_SOCKET = 0xffff + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x2 + SO_BINDANY = 0x1000 + SO_BROADCAST = 0x20 + SO_DEBUG = 0x1 + SO_DONTROUTE = 0x10 + SO_ERROR = 0x1007 + SO_KEEPALIVE = 0x8 + SO_LINGER = 0x80 + SO_NETPROC = 0x1020 + SO_OOBINLINE = 0x100 + SO_PEERCRED = 0x1022 + SO_RCVBUF = 0x1002 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x1006 + SO_REUSEADDR = 0x4 + SO_REUSEPORT = 0x200 + SO_RTABLE = 0x1021 + SO_SNDBUF = 0x1001 + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x1005 + SO_SPLICE = 0x1023 + SO_TIMESTAMP = 0x800 + SO_TYPE = 0x1008 + SO_USELOOPBACK = 0x40 + TCIFLUSH = 0x1 + TCIOFLUSH = 0x3 + TCOFLUSH = 0x2 + TCP_MAXBURST = 0x4 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_SACK = 0x3 + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0x4 + TCP_MSS = 0x200 + TCP_NODELAY = 0x1 + TCP_NOPUSH = 0x10 + TCP_NSTATES = 0xb + TCP_SACK_ENABLE = 0x8 + TCSAFLUSH = 0x2 + TIOCCBRK = 0x2000747a + TIOCCDTR = 0x20007478 + TIOCCONS = 0x80047462 + TIOCDRAIN = 0x2000745e + TIOCEXCL = 0x2000740d + TIOCEXT = 0x80047460 + TIOCFLAG_CLOCAL = 0x2 + TIOCFLAG_CRTSCTS = 0x4 + TIOCFLAG_MDMBUF = 0x8 + TIOCFLAG_PPS = 0x10 + TIOCFLAG_SOFTCAR = 0x1 + TIOCFLUSH = 0x80047410 + TIOCGETA = 0x402c7413 + TIOCGETD = 0x4004741a + TIOCGFLAGS = 0x4004745d + TIOCGPGRP = 0x40047477 + TIOCGSID = 0x40047463 + TIOCGTSTAMP = 0x4010745b + TIOCGWINSZ = 0x40087468 + TIOCMBIC = 0x8004746b + TIOCMBIS = 0x8004746c + TIOCMGET = 0x4004746a + TIOCMODG = 0x4004746a + TIOCMODS = 0x8004746d + TIOCMSET = 0x8004746d + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x20007471 + TIOCNXCL = 0x2000740e + TIOCOUTQ = 0x40047473 + TIOCPKT = 0x80047470 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCREMOTE = 0x80047469 + TIOCSBRK = 0x2000747b + TIOCSCTTY = 0x20007461 + TIOCSDTR = 0x20007479 + TIOCSETA = 0x802c7414 + TIOCSETAF = 0x802c7416 + TIOCSETAW = 0x802c7415 + TIOCSETD = 0x8004741b + TIOCSFLAGS = 0x8004745c + TIOCSIG = 0x8004745f + TIOCSPGRP = 0x80047476 + TIOCSTART = 0x2000746e + TIOCSTAT = 0x80047465 + TIOCSTI = 0x80017472 + TIOCSTOP = 0x2000746f + TIOCSTSTAMP = 0x8008745a + TIOCSWINSZ = 0x80087467 + TIOCUCNTL = 0x80047466 + TOSTOP = 0x400000 + VDISCARD = 0xf + VDSUSP = 0xb + VEOF = 0x0 + VEOL = 0x1 + VEOL2 = 0x2 + VERASE = 0x3 + VINTR = 0x8 + VKILL = 0x5 + VLNEXT = 0xe + VMIN = 0x10 + VQUIT = 0x9 + VREPRINT = 0x6 + VSTART = 0xc + VSTATUS = 0x12 + VSTOP = 0xd + VSUSP = 0xa + VTIME = 0x11 + VWERASE = 0x4 + WALTSIG = 0x4 + WCONTINUED = 0x8 + WCOREFLAG = 0x80 + WNOHANG = 0x1 + WSTOPPED = 0x7f + WUNTRACED = 0x2 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x30) + EADDRNOTAVAIL = syscall.Errno(0x31) + EAFNOSUPPORT = syscall.Errno(0x2f) + EAGAIN = syscall.Errno(0x23) + EALREADY = syscall.Errno(0x25) + EAUTH = syscall.Errno(0x50) + EBADF = syscall.Errno(0x9) + EBADRPC = syscall.Errno(0x48) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x58) + ECHILD = syscall.Errno(0xa) + ECONNABORTED = syscall.Errno(0x35) + ECONNREFUSED = syscall.Errno(0x3d) + ECONNRESET = syscall.Errno(0x36) + EDEADLK = syscall.Errno(0xb) + EDESTADDRREQ = syscall.Errno(0x27) + EDOM = syscall.Errno(0x21) + EDQUOT = syscall.Errno(0x45) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EFTYPE = syscall.Errno(0x4f) + EHOSTDOWN = syscall.Errno(0x40) + EHOSTUNREACH = syscall.Errno(0x41) + EIDRM = syscall.Errno(0x59) + EILSEQ = syscall.Errno(0x54) + EINPROGRESS = syscall.Errno(0x24) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EIPSEC = syscall.Errno(0x52) + EISCONN = syscall.Errno(0x38) + EISDIR = syscall.Errno(0x15) + ELAST = syscall.Errno(0x5b) + ELOOP = syscall.Errno(0x3e) + EMEDIUMTYPE = syscall.Errno(0x56) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x28) + ENAMETOOLONG = syscall.Errno(0x3f) + ENEEDAUTH = syscall.Errno(0x51) + ENETDOWN = syscall.Errno(0x32) + ENETRESET = syscall.Errno(0x34) + ENETUNREACH = syscall.Errno(0x33) + ENFILE = syscall.Errno(0x17) + ENOATTR = syscall.Errno(0x53) + ENOBUFS = syscall.Errno(0x37) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOLCK = syscall.Errno(0x4d) + ENOMEDIUM = syscall.Errno(0x55) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x5a) + ENOPROTOOPT = syscall.Errno(0x2a) + ENOSPC = syscall.Errno(0x1c) + ENOSYS = syscall.Errno(0x4e) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x39) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x42) + ENOTSOCK = syscall.Errno(0x26) + ENOTSUP = syscall.Errno(0x5b) + ENOTTY = syscall.Errno(0x19) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x2d) + EOVERFLOW = syscall.Errno(0x57) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x2e) + EPIPE = syscall.Errno(0x20) + EPROCLIM = syscall.Errno(0x43) + EPROCUNAVAIL = syscall.Errno(0x4c) + EPROGMISMATCH = syscall.Errno(0x4b) + EPROGUNAVAIL = syscall.Errno(0x4a) + EPROTONOSUPPORT = syscall.Errno(0x2b) + EPROTOTYPE = syscall.Errno(0x29) + ERANGE = syscall.Errno(0x22) + EREMOTE = syscall.Errno(0x47) + EROFS = syscall.Errno(0x1e) + ERPCMISMATCH = syscall.Errno(0x49) + ESHUTDOWN = syscall.Errno(0x3a) + ESOCKTNOSUPPORT = syscall.Errno(0x2c) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESTALE = syscall.Errno(0x46) + ETIMEDOUT = syscall.Errno(0x3c) + ETOOMANYREFS = syscall.Errno(0x3b) + ETXTBSY = syscall.Errno(0x1a) + EUSERS = syscall.Errno(0x44) + EWOULDBLOCK = syscall.Errno(0x23) + EXDEV = syscall.Errno(0x12) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0xa) + SIGCHLD = syscall.Signal(0x14) + SIGCONT = syscall.Signal(0x13) + SIGEMT = syscall.Signal(0x7) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINFO = syscall.Signal(0x1d) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x17) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPROF = syscall.Signal(0x1b) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTOP = syscall.Signal(0x11) + SIGSYS = syscall.Signal(0xc) + SIGTERM = syscall.Signal(0xf) + SIGTHR = syscall.Signal(0x20) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x12) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGURG = syscall.Signal(0x10) + SIGUSR1 = syscall.Signal(0x1e) + SIGUSR2 = syscall.Signal(0x1f) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errors = [...]string{ + 1: "operation not permitted", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "input/output error", + 6: "device not configured", + 7: "argument list too long", + 8: "exec format error", + 9: "bad file descriptor", + 10: "no child processes", + 11: "resource deadlock avoided", + 12: "cannot allocate memory", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device busy", + 17: "file exists", + 18: "cross-device link", + 19: "operation not supported by device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "too many open files in system", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "numerical argument out of domain", + 34: "result too large", + 35: "resource temporarily unavailable", + 36: "operation now in progress", + 37: "operation already in progress", + 38: "socket operation on non-socket", + 39: "destination address required", + 40: "message too long", + 41: "protocol wrong type for socket", + 42: "protocol not available", + 43: "protocol not supported", + 44: "socket type not supported", + 45: "operation not supported", + 46: "protocol family not supported", + 47: "address family not supported by protocol family", + 48: "address already in use", + 49: "can't assign requested address", + 50: "network is down", + 51: "network is unreachable", + 52: "network dropped connection on reset", + 53: "software caused connection abort", + 54: "connection reset by peer", + 55: "no buffer space available", + 56: "socket is already connected", + 57: "socket is not connected", + 58: "can't send after socket shutdown", + 59: "too many references: can't splice", + 60: "connection timed out", + 61: "connection refused", + 62: "too many levels of symbolic links", + 63: "file name too long", + 64: "host is down", + 65: "no route to host", + 66: "directory not empty", + 67: "too many processes", + 68: "too many users", + 69: "disc quota exceeded", + 70: "stale NFS file handle", + 71: "too many levels of remote in path", + 72: "RPC struct is bad", + 73: "RPC version wrong", + 74: "RPC prog. not avail", + 75: "program version wrong", + 76: "bad procedure for program", + 77: "no locks available", + 78: "function not implemented", + 79: "inappropriate file type or format", + 80: "authentication error", + 81: "need authenticator", + 82: "IPsec processing failure", + 83: "attribute not found", + 84: "illegal byte sequence", + 85: "no medium found", + 86: "wrong medium type", + 87: "value too large to be stored in data type", + 88: "operation canceled", + 89: "identifier removed", + 90: "no message of desired type", + 91: "not supported", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal instruction", + 5: "trace/BPT trap", + 6: "abort trap", + 7: "EMT trap", + 8: "floating point exception", + 9: "killed", + 10: "bus error", + 11: "segmentation fault", + 12: "bad system call", + 13: "broken pipe", + 14: "alarm clock", + 15: "terminated", + 16: "urgent I/O condition", + 17: "stopped (signal)", + 18: "stopped", + 19: "continued", + 20: "child exited", + 21: "stopped (tty input)", + 22: "stopped (tty output)", + 23: "I/O possible", + 24: "cputime limit exceeded", + 25: "filesize limit exceeded", + 26: "virtual timer expired", + 27: "profiling timer expired", + 28: "window size changes", + 29: "information request", + 30: "user defined signal 1", + 31: "user defined signal 2", + 32: "thread AST", +} diff --git a/vendor/golang.org/x/sys/unix/zerrors_solaris_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_solaris_amd64.go new file mode 100644 index 0000000000..a08922b981 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_solaris_amd64.go @@ -0,0 +1,1436 @@ +// mkerrors.sh -m64 +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build amd64,solaris + +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -m64 _const.go + +package unix + +import "syscall" + +const ( + AF_802 = 0x12 + AF_APPLETALK = 0x10 + AF_CCITT = 0xa + AF_CHAOS = 0x5 + AF_DATAKIT = 0x9 + AF_DECnet = 0xc + AF_DLI = 0xd + AF_ECMA = 0x8 + AF_FILE = 0x1 + AF_GOSIP = 0x16 + AF_HYLINK = 0xf + AF_IMPLINK = 0x3 + AF_INET = 0x2 + AF_INET6 = 0x1a + AF_INET_OFFLOAD = 0x1e + AF_IPX = 0x17 + AF_KEY = 0x1b + AF_LAT = 0xe + AF_LINK = 0x19 + AF_LOCAL = 0x1 + AF_MAX = 0x20 + AF_NBS = 0x7 + AF_NCA = 0x1c + AF_NIT = 0x11 + AF_NS = 0x6 + AF_OSI = 0x13 + AF_OSINET = 0x15 + AF_PACKET = 0x20 + AF_POLICY = 0x1d + AF_PUP = 0x4 + AF_ROUTE = 0x18 + AF_SNA = 0xb + AF_TRILL = 0x1f + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + AF_X25 = 0x14 + ARPHRD_ARCNET = 0x7 + ARPHRD_ATM = 0x10 + ARPHRD_AX25 = 0x3 + ARPHRD_CHAOS = 0x5 + ARPHRD_EETHER = 0x2 + ARPHRD_ETHER = 0x1 + ARPHRD_FC = 0x12 + ARPHRD_FRAME = 0xf + ARPHRD_HDLC = 0x11 + ARPHRD_IB = 0x20 + ARPHRD_IEEE802 = 0x6 + ARPHRD_IPATM = 0x13 + ARPHRD_METRICOM = 0x17 + ARPHRD_TUNNEL = 0x1f + B0 = 0x0 + B110 = 0x3 + B115200 = 0x12 + B1200 = 0x9 + B134 = 0x4 + B150 = 0x5 + B153600 = 0x13 + B1800 = 0xa + B19200 = 0xe + B200 = 0x6 + B230400 = 0x14 + B2400 = 0xb + B300 = 0x7 + B307200 = 0x15 + B38400 = 0xf + B460800 = 0x16 + B4800 = 0xc + B50 = 0x1 + B57600 = 0x10 + B600 = 0x8 + B75 = 0x2 + B76800 = 0x11 + B921600 = 0x17 + B9600 = 0xd + BIOCFLUSH = 0x20004268 + BIOCGBLEN = 0x40044266 + BIOCGDLT = 0x4004426a + BIOCGDLTLIST = -0x3fefbd89 + BIOCGDLTLIST32 = -0x3ff7bd89 + BIOCGETIF = 0x4020426b + BIOCGETLIF = 0x4078426b + BIOCGHDRCMPLT = 0x40044274 + BIOCGRTIMEOUT = 0x4010427b + BIOCGRTIMEOUT32 = 0x4008427b + BIOCGSEESENT = 0x40044278 + BIOCGSTATS = 0x4080426f + BIOCGSTATSOLD = 0x4008426f + BIOCIMMEDIATE = -0x7ffbbd90 + BIOCPROMISC = 0x20004269 + BIOCSBLEN = -0x3ffbbd9a + BIOCSDLT = -0x7ffbbd8a + BIOCSETF = -0x7fefbd99 + BIOCSETF32 = -0x7ff7bd99 + BIOCSETIF = -0x7fdfbd94 + BIOCSETLIF = -0x7f87bd94 + BIOCSHDRCMPLT = -0x7ffbbd8b + BIOCSRTIMEOUT = -0x7fefbd86 + BIOCSRTIMEOUT32 = -0x7ff7bd86 + BIOCSSEESENT = -0x7ffbbd87 + BIOCSTCPF = -0x7fefbd8e + BIOCSUDPF = -0x7fefbd8d + BIOCVERSION = 0x40044271 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALIGNMENT = 0x4 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DFLTBUFSIZE = 0x100000 + BPF_DIV = 0x30 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXBUFSIZE = 0x1000000 + BPF_MAXINSNS = 0x200 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINBUFSIZE = 0x20 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RELEASE = 0x30bb6 + BPF_RET = 0x6 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BRKINT = 0x2 + CFLUSH = 0xf + CLOCAL = 0x800 + CLOCK_HIGHRES = 0x4 + CLOCK_LEVEL = 0xa + CLOCK_MONOTONIC = 0x4 + CLOCK_PROCESS_CPUTIME_ID = 0x5 + CLOCK_PROF = 0x2 + CLOCK_REALTIME = 0x3 + CLOCK_THREAD_CPUTIME_ID = 0x2 + CLOCK_VIRTUAL = 0x1 + CREAD = 0x80 + CS5 = 0x0 + CS6 = 0x10 + CS7 = 0x20 + CS8 = 0x30 + CSIZE = 0x30 + CSTART = 0x11 + CSTATUS = 0x14 + CSTOP = 0x13 + CSTOPB = 0x40 + CSUSP = 0x1a + CSWTCH = 0x1a + DLT_AIRONET_HEADER = 0x78 + DLT_APPLE_IP_OVER_IEEE1394 = 0x8a + DLT_ARCNET = 0x7 + DLT_ARCNET_LINUX = 0x81 + DLT_ATM_CLIP = 0x13 + DLT_ATM_RFC1483 = 0xb + DLT_AURORA = 0x7e + DLT_AX25 = 0x3 + DLT_BACNET_MS_TP = 0xa5 + DLT_CHAOS = 0x5 + DLT_CISCO_IOS = 0x76 + DLT_C_HDLC = 0x68 + DLT_DOCSIS = 0x8f + DLT_ECONET = 0x73 + DLT_EN10MB = 0x1 + DLT_EN3MB = 0x2 + DLT_ENC = 0x6d + DLT_ERF_ETH = 0xaf + DLT_ERF_POS = 0xb0 + DLT_FDDI = 0xa + DLT_FRELAY = 0x6b + DLT_GCOM_SERIAL = 0xad + DLT_GCOM_T1E1 = 0xac + DLT_GPF_F = 0xab + DLT_GPF_T = 0xaa + DLT_GPRS_LLC = 0xa9 + DLT_HDLC = 0x10 + DLT_HHDLC = 0x79 + DLT_HIPPI = 0xf + DLT_IBM_SN = 0x92 + DLT_IBM_SP = 0x91 + DLT_IEEE802 = 0x6 + DLT_IEEE802_11 = 0x69 + DLT_IEEE802_11_RADIO = 0x7f + DLT_IEEE802_11_RADIO_AVS = 0xa3 + DLT_IPNET = 0xe2 + DLT_IPOIB = 0xa2 + DLT_IP_OVER_FC = 0x7a + DLT_JUNIPER_ATM1 = 0x89 + DLT_JUNIPER_ATM2 = 0x87 + DLT_JUNIPER_CHDLC = 0xb5 + DLT_JUNIPER_ES = 0x84 + DLT_JUNIPER_ETHER = 0xb2 + DLT_JUNIPER_FRELAY = 0xb4 + DLT_JUNIPER_GGSN = 0x85 + DLT_JUNIPER_MFR = 0x86 + DLT_JUNIPER_MLFR = 0x83 + DLT_JUNIPER_MLPPP = 0x82 + DLT_JUNIPER_MONITOR = 0xa4 + DLT_JUNIPER_PIC_PEER = 0xae + DLT_JUNIPER_PPP = 0xb3 + DLT_JUNIPER_PPPOE = 0xa7 + DLT_JUNIPER_PPPOE_ATM = 0xa8 + DLT_JUNIPER_SERVICES = 0x88 + DLT_LINUX_IRDA = 0x90 + DLT_LINUX_LAPD = 0xb1 + DLT_LINUX_SLL = 0x71 + DLT_LOOP = 0x6c + DLT_LTALK = 0x72 + DLT_MTP2 = 0x8c + DLT_MTP2_WITH_PHDR = 0x8b + DLT_MTP3 = 0x8d + DLT_NULL = 0x0 + DLT_PCI_EXP = 0x7d + DLT_PFLOG = 0x75 + DLT_PFSYNC = 0x12 + DLT_PPP = 0x9 + DLT_PPP_BSDOS = 0xe + DLT_PPP_PPPD = 0xa6 + DLT_PRISM_HEADER = 0x77 + DLT_PRONET = 0x4 + DLT_RAW = 0xc + DLT_RAWAF_MASK = 0x2240000 + DLT_RIO = 0x7c + DLT_SCCP = 0x8e + DLT_SLIP = 0x8 + DLT_SLIP_BSDOS = 0xd + DLT_SUNATM = 0x7b + DLT_SYMANTEC_FIREWALL = 0x63 + DLT_TZSP = 0x80 + ECHO = 0x8 + ECHOCTL = 0x200 + ECHOE = 0x10 + ECHOK = 0x20 + ECHOKE = 0x800 + ECHONL = 0x40 + ECHOPRT = 0x400 + EMPTY_SET = 0x0 + EMT_CPCOVF = 0x1 + EQUALITY_CHECK = 0x0 + EXTA = 0xe + EXTB = 0xf + FD_CLOEXEC = 0x1 + FD_NFDBITS = 0x40 + FD_SETSIZE = 0x10000 + FLUSHALL = 0x1 + FLUSHDATA = 0x0 + FLUSHO = 0x2000 + F_ALLOCSP = 0xa + F_ALLOCSP64 = 0xa + F_BADFD = 0x2e + F_BLKSIZE = 0x13 + F_BLOCKS = 0x12 + F_CHKFL = 0x8 + F_COMPAT = 0x8 + F_DUP2FD = 0x9 + F_DUP2FD_CLOEXEC = 0x24 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0x25 + F_FREESP = 0xb + F_FREESP64 = 0xb + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLK = 0xe + F_GETLK64 = 0xe + F_GETOWN = 0x17 + F_GETXFL = 0x2d + F_HASREMOTELOCKS = 0x1a + F_ISSTREAM = 0xd + F_MANDDNY = 0x10 + F_MDACC = 0x20 + F_NODNY = 0x0 + F_NPRIV = 0x10 + F_PRIV = 0xf + F_QUOTACTL = 0x11 + F_RDACC = 0x1 + F_RDDNY = 0x1 + F_RDLCK = 0x1 + F_REVOKE = 0x19 + F_RMACC = 0x4 + F_RMDNY = 0x4 + F_RWACC = 0x3 + F_RWDNY = 0x3 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLK = 0x6 + F_SETLK64 = 0x6 + F_SETLK64_NBMAND = 0x2a + F_SETLKW = 0x7 + F_SETLKW64 = 0x7 + F_SETLK_NBMAND = 0x2a + F_SETOWN = 0x18 + F_SHARE = 0x28 + F_SHARE_NBMAND = 0x2b + F_UNLCK = 0x3 + F_UNLKSYS = 0x4 + F_UNSHARE = 0x29 + F_WRACC = 0x2 + F_WRDNY = 0x2 + F_WRLCK = 0x2 + HUPCL = 0x400 + ICANON = 0x2 + ICRNL = 0x100 + IEXTEN = 0x8000 + IFF_ADDRCONF = 0x80000 + IFF_ALLMULTI = 0x200 + IFF_ANYCAST = 0x400000 + IFF_BROADCAST = 0x2 + IFF_CANTCHANGE = 0x7f203003b5a + IFF_COS_ENABLED = 0x200000000 + IFF_DEBUG = 0x4 + IFF_DEPRECATED = 0x40000 + IFF_DHCPRUNNING = 0x4000 + IFF_DUPLICATE = 0x4000000000 + IFF_FAILED = 0x10000000 + IFF_FIXEDMTU = 0x1000000000 + IFF_INACTIVE = 0x40000000 + IFF_INTELLIGENT = 0x400 + IFF_IPMP = 0x8000000000 + IFF_IPMP_CANTCHANGE = 0x10000000 + IFF_IPMP_INVALID = 0x1ec200080 + IFF_IPV4 = 0x1000000 + IFF_IPV6 = 0x2000000 + IFF_L3PROTECT = 0x40000000000 + IFF_LOOPBACK = 0x8 + IFF_MULTICAST = 0x800 + IFF_MULTI_BCAST = 0x1000 + IFF_NOACCEPT = 0x4000000 + IFF_NOARP = 0x80 + IFF_NOFAILOVER = 0x8000000 + IFF_NOLINKLOCAL = 0x20000000000 + IFF_NOLOCAL = 0x20000 + IFF_NONUD = 0x200000 + IFF_NORTEXCH = 0x800000 + IFF_NOTRAILERS = 0x20 + IFF_NOXMIT = 0x10000 + IFF_OFFLINE = 0x80000000 + IFF_POINTOPOINT = 0x10 + IFF_PREFERRED = 0x400000000 + IFF_PRIVATE = 0x8000 + IFF_PROMISC = 0x100 + IFF_ROUTER = 0x100000 + IFF_RUNNING = 0x40 + IFF_STANDBY = 0x20000000 + IFF_TEMPORARY = 0x800000000 + IFF_UNNUMBERED = 0x2000 + IFF_UP = 0x1 + IFF_VIRTUAL = 0x2000000000 + IFF_VRRP = 0x10000000000 + IFF_XRESOLV = 0x100000000 + IFNAMSIZ = 0x10 + IFT_1822 = 0x2 + IFT_6TO4 = 0xca + IFT_AAL5 = 0x31 + IFT_ARCNET = 0x23 + IFT_ARCNETPLUS = 0x24 + IFT_ATM = 0x25 + IFT_CEPT = 0x13 + IFT_DS3 = 0x1e + IFT_EON = 0x19 + IFT_ETHER = 0x6 + IFT_FDDI = 0xf + IFT_FRELAY = 0x20 + IFT_FRELAYDCE = 0x2c + IFT_HDH1822 = 0x3 + IFT_HIPPI = 0x2f + IFT_HSSI = 0x2e + IFT_HY = 0xe + IFT_IB = 0xc7 + IFT_IPV4 = 0xc8 + IFT_IPV6 = 0xc9 + IFT_ISDNBASIC = 0x14 + IFT_ISDNPRIMARY = 0x15 + IFT_ISO88022LLC = 0x29 + IFT_ISO88023 = 0x7 + IFT_ISO88024 = 0x8 + IFT_ISO88025 = 0x9 + IFT_ISO88026 = 0xa + IFT_LAPB = 0x10 + IFT_LOCALTALK = 0x2a + IFT_LOOP = 0x18 + IFT_MIOX25 = 0x26 + IFT_MODEM = 0x30 + IFT_NSIP = 0x1b + IFT_OTHER = 0x1 + IFT_P10 = 0xc + IFT_P80 = 0xd + IFT_PARA = 0x22 + IFT_PPP = 0x17 + IFT_PROPMUX = 0x36 + IFT_PROPVIRTUAL = 0x35 + IFT_PTPSERIAL = 0x16 + IFT_RS232 = 0x21 + IFT_SDLC = 0x11 + IFT_SIP = 0x1f + IFT_SLIP = 0x1c + IFT_SMDSDXI = 0x2b + IFT_SMDSICIP = 0x34 + IFT_SONET = 0x27 + IFT_SONETPATH = 0x32 + IFT_SONETVT = 0x33 + IFT_STARLAN = 0xb + IFT_T1 = 0x12 + IFT_ULTRA = 0x1d + IFT_V35 = 0x2d + IFT_X25 = 0x5 + IFT_X25DDN = 0x4 + IFT_X25PLE = 0x28 + IFT_XETHER = 0x1a + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_AUTOCONF_MASK = 0xffff0000 + IN_AUTOCONF_NET = 0xa9fe0000 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLASSD_HOST = 0xfffffff + IN_CLASSD_NET = 0xf0000000 + IN_CLASSD_NSHIFT = 0x1c + IN_CLASSE_NET = 0xffffffff + IN_LOOPBACKNET = 0x7f + IN_PRIVATE12_MASK = 0xfff00000 + IN_PRIVATE12_NET = 0xac100000 + IN_PRIVATE16_MASK = 0xffff0000 + IN_PRIVATE16_NET = 0xc0a80000 + IN_PRIVATE8_MASK = 0xff000000 + IN_PRIVATE8_NET = 0xa000000 + IPPROTO_AH = 0x33 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_ENCAP = 0x4 + IPPROTO_EON = 0x50 + IPPROTO_ESP = 0x32 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GGP = 0x3 + IPPROTO_HELLO = 0x3f + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IGMP = 0x2 + IPPROTO_IP = 0x0 + IPPROTO_IPV6 = 0x29 + IPPROTO_MAX = 0x100 + IPPROTO_ND = 0x4d + IPPROTO_NONE = 0x3b + IPPROTO_OSPF = 0x59 + IPPROTO_PIM = 0x67 + IPPROTO_PUP = 0xc + IPPROTO_RAW = 0xff + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_SCTP = 0x84 + IPPROTO_TCP = 0x6 + IPPROTO_UDP = 0x11 + IPV6_ADD_MEMBERSHIP = 0x9 + IPV6_BOUND_IF = 0x41 + IPV6_CHECKSUM = 0x18 + IPV6_DONTFRAG = 0x21 + IPV6_DROP_MEMBERSHIP = 0xa + IPV6_DSTOPTS = 0xf + IPV6_FLOWINFO_FLOWLABEL = 0xffff0f00 + IPV6_FLOWINFO_TCLASS = 0xf00f + IPV6_HOPLIMIT = 0xc + IPV6_HOPOPTS = 0xe + IPV6_JOIN_GROUP = 0x9 + IPV6_LEAVE_GROUP = 0xa + IPV6_MULTICAST_HOPS = 0x7 + IPV6_MULTICAST_IF = 0x6 + IPV6_MULTICAST_LOOP = 0x8 + IPV6_NEXTHOP = 0xd + IPV6_PAD1_OPT = 0x0 + IPV6_PATHMTU = 0x25 + IPV6_PKTINFO = 0xb + IPV6_PREFER_SRC_CGA = 0x20 + IPV6_PREFER_SRC_CGADEFAULT = 0x10 + IPV6_PREFER_SRC_CGAMASK = 0x30 + IPV6_PREFER_SRC_COA = 0x2 + IPV6_PREFER_SRC_DEFAULT = 0x15 + IPV6_PREFER_SRC_HOME = 0x1 + IPV6_PREFER_SRC_MASK = 0x3f + IPV6_PREFER_SRC_MIPDEFAULT = 0x1 + IPV6_PREFER_SRC_MIPMASK = 0x3 + IPV6_PREFER_SRC_NONCGA = 0x10 + IPV6_PREFER_SRC_PUBLIC = 0x4 + IPV6_PREFER_SRC_TMP = 0x8 + IPV6_PREFER_SRC_TMPDEFAULT = 0x4 + IPV6_PREFER_SRC_TMPMASK = 0xc + IPV6_RECVDSTOPTS = 0x28 + IPV6_RECVHOPLIMIT = 0x13 + IPV6_RECVHOPOPTS = 0x14 + IPV6_RECVPATHMTU = 0x24 + IPV6_RECVPKTINFO = 0x12 + IPV6_RECVRTHDR = 0x16 + IPV6_RECVRTHDRDSTOPTS = 0x17 + IPV6_RECVTCLASS = 0x19 + IPV6_RTHDR = 0x10 + IPV6_RTHDRDSTOPTS = 0x11 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_SEC_OPT = 0x22 + IPV6_SRC_PREFERENCES = 0x23 + IPV6_TCLASS = 0x26 + IPV6_UNICAST_HOPS = 0x5 + IPV6_UNSPEC_SRC = 0x42 + IPV6_USE_MIN_MTU = 0x20 + IPV6_V6ONLY = 0x27 + IP_ADD_MEMBERSHIP = 0x13 + IP_ADD_SOURCE_MEMBERSHIP = 0x17 + IP_BLOCK_SOURCE = 0x15 + IP_BOUND_IF = 0x41 + IP_BROADCAST = 0x106 + IP_BROADCAST_TTL = 0x43 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DHCPINIT_IF = 0x45 + IP_DONTFRAG = 0x1b + IP_DONTROUTE = 0x105 + IP_DROP_MEMBERSHIP = 0x14 + IP_DROP_SOURCE_MEMBERSHIP = 0x18 + IP_HDRINCL = 0x2 + IP_MAXPACKET = 0xffff + IP_MF = 0x2000 + IP_MSS = 0x240 + IP_MULTICAST_IF = 0x10 + IP_MULTICAST_LOOP = 0x12 + IP_MULTICAST_TTL = 0x11 + IP_NEXTHOP = 0x19 + IP_OPTIONS = 0x1 + IP_PKTINFO = 0x1a + IP_RECVDSTADDR = 0x7 + IP_RECVIF = 0x9 + IP_RECVOPTS = 0x5 + IP_RECVPKTINFO = 0x1a + IP_RECVRETOPTS = 0x6 + IP_RECVSLLA = 0xa + IP_RECVTTL = 0xb + IP_RETOPTS = 0x8 + IP_REUSEADDR = 0x104 + IP_SEC_OPT = 0x22 + IP_TOS = 0x3 + IP_TTL = 0x4 + IP_UNBLOCK_SOURCE = 0x16 + IP_UNSPEC_SRC = 0x42 + ISIG = 0x1 + ISTRIP = 0x20 + IXANY = 0x800 + IXOFF = 0x1000 + IXON = 0x400 + MADV_ACCESS_DEFAULT = 0x6 + MADV_ACCESS_LWP = 0x7 + MADV_ACCESS_MANY = 0x8 + MADV_DONTNEED = 0x4 + MADV_FREE = 0x5 + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_SEQUENTIAL = 0x2 + MADV_WILLNEED = 0x3 + MAP_32BIT = 0x80 + MAP_ALIGN = 0x200 + MAP_ANON = 0x100 + MAP_ANONYMOUS = 0x100 + MAP_FIXED = 0x10 + MAP_INITDATA = 0x800 + MAP_NORESERVE = 0x40 + MAP_PRIVATE = 0x2 + MAP_RENAME = 0x20 + MAP_SHARED = 0x1 + MAP_TEXT = 0x400 + MAP_TYPE = 0xf + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MSG_CTRUNC = 0x10 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x80 + MSG_DUPCTRL = 0x800 + MSG_EOR = 0x8 + MSG_MAXIOVLEN = 0x10 + MSG_NOTIFICATION = 0x100 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_TRUNC = 0x20 + MSG_WAITALL = 0x40 + MSG_XPG4_2 = 0x8000 + MS_ASYNC = 0x1 + MS_INVALIDATE = 0x2 + MS_OLDSYNC = 0x0 + MS_SYNC = 0x4 + M_FLUSH = 0x86 + NOFLSH = 0x80 + OCRNL = 0x8 + OFDEL = 0x80 + OFILL = 0x40 + ONLCR = 0x4 + ONLRET = 0x20 + ONOCR = 0x10 + OPENFAIL = -0x1 + OPOST = 0x1 + O_ACCMODE = 0x600003 + O_APPEND = 0x8 + O_CLOEXEC = 0x800000 + O_CREAT = 0x100 + O_DSYNC = 0x40 + O_EXCL = 0x400 + O_EXEC = 0x400000 + O_LARGEFILE = 0x2000 + O_NDELAY = 0x4 + O_NOCTTY = 0x800 + O_NOFOLLOW = 0x20000 + O_NOLINKS = 0x40000 + O_NONBLOCK = 0x80 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_RSYNC = 0x8000 + O_SEARCH = 0x200000 + O_SIOCGIFCONF = -0x3ff796ec + O_SIOCGLIFCONF = -0x3fef9688 + O_SYNC = 0x10 + O_TRUNC = 0x200 + O_WRONLY = 0x1 + O_XATTR = 0x4000 + PARENB = 0x100 + PAREXT = 0x100000 + PARMRK = 0x8 + PARODD = 0x200 + PENDIN = 0x4000 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + RLIMIT_AS = 0x6 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_NOFILE = 0x5 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = -0x3 + RTAX_AUTHOR = 0x6 + RTAX_BRD = 0x7 + RTAX_DST = 0x0 + RTAX_GATEWAY = 0x1 + RTAX_GENMASK = 0x3 + RTAX_IFA = 0x5 + RTAX_IFP = 0x4 + RTAX_MAX = 0x9 + RTAX_NETMASK = 0x2 + RTAX_SRC = 0x8 + RTA_AUTHOR = 0x40 + RTA_BRD = 0x80 + RTA_DST = 0x1 + RTA_GATEWAY = 0x2 + RTA_GENMASK = 0x8 + RTA_IFA = 0x20 + RTA_IFP = 0x10 + RTA_NETMASK = 0x4 + RTA_NUMBITS = 0x9 + RTA_SRC = 0x100 + RTF_BLACKHOLE = 0x1000 + RTF_CLONING = 0x100 + RTF_DONE = 0x40 + RTF_DYNAMIC = 0x10 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_INDIRECT = 0x40000 + RTF_KERNEL = 0x80000 + RTF_LLINFO = 0x400 + RTF_MASK = 0x80 + RTF_MODIFIED = 0x20 + RTF_MULTIRT = 0x10000 + RTF_PRIVATE = 0x2000 + RTF_PROTO1 = 0x8000 + RTF_PROTO2 = 0x4000 + RTF_REJECT = 0x8 + RTF_SETSRC = 0x20000 + RTF_STATIC = 0x800 + RTF_UP = 0x1 + RTF_XRESOLVE = 0x200 + RTF_ZONE = 0x100000 + RTM_ADD = 0x1 + RTM_CHANGE = 0x3 + RTM_CHGADDR = 0xf + RTM_DELADDR = 0xd + RTM_DELETE = 0x2 + RTM_FREEADDR = 0x10 + RTM_GET = 0x4 + RTM_IFINFO = 0xe + RTM_LOCK = 0x8 + RTM_LOSING = 0x5 + RTM_MISS = 0x7 + RTM_NEWADDR = 0xc + RTM_OLDADD = 0x9 + RTM_OLDDEL = 0xa + RTM_REDIRECT = 0x6 + RTM_RESOLVE = 0xb + RTM_VERSION = 0x3 + RTV_EXPIRE = 0x4 + RTV_HOPCOUNT = 0x2 + RTV_MTU = 0x1 + RTV_RPIPE = 0x8 + RTV_RTT = 0x40 + RTV_RTTVAR = 0x80 + RTV_SPIPE = 0x10 + RTV_SSTHRESH = 0x20 + RT_AWARE = 0x1 + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + SCM_RIGHTS = 0x1010 + SCM_TIMESTAMP = 0x1013 + SCM_UCRED = 0x1012 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIG2STR_MAX = 0x20 + SIOCADDMULTI = -0x7fdf96cf + SIOCADDRT = -0x7fcf8df6 + SIOCATMARK = 0x40047307 + SIOCDARP = -0x7fdb96e0 + SIOCDELMULTI = -0x7fdf96ce + SIOCDELRT = -0x7fcf8df5 + SIOCDXARP = -0x7fff9658 + SIOCGARP = -0x3fdb96e1 + SIOCGDSTINFO = -0x3fff965c + SIOCGENADDR = -0x3fdf96ab + SIOCGENPSTATS = -0x3fdf96c7 + SIOCGETLSGCNT = -0x3fef8deb + SIOCGETNAME = 0x40107334 + SIOCGETPEER = 0x40107335 + SIOCGETPROP = -0x3fff8f44 + SIOCGETSGCNT = -0x3feb8deb + SIOCGETSYNC = -0x3fdf96d3 + SIOCGETVIFCNT = -0x3feb8dec + SIOCGHIWAT = 0x40047301 + SIOCGIFADDR = -0x3fdf96f3 + SIOCGIFBRDADDR = -0x3fdf96e9 + SIOCGIFCONF = -0x3ff796a4 + SIOCGIFDSTADDR = -0x3fdf96f1 + SIOCGIFFLAGS = -0x3fdf96ef + SIOCGIFHWADDR = -0x3fdf9647 + SIOCGIFINDEX = -0x3fdf96a6 + SIOCGIFMEM = -0x3fdf96ed + SIOCGIFMETRIC = -0x3fdf96e5 + SIOCGIFMTU = -0x3fdf96ea + SIOCGIFMUXID = -0x3fdf96a8 + SIOCGIFNETMASK = -0x3fdf96e7 + SIOCGIFNUM = 0x40046957 + SIOCGIP6ADDRPOLICY = -0x3fff965e + SIOCGIPMSFILTER = -0x3ffb964c + SIOCGLIFADDR = -0x3f87968f + SIOCGLIFBINDING = -0x3f879666 + SIOCGLIFBRDADDR = -0x3f879685 + SIOCGLIFCONF = -0x3fef965b + SIOCGLIFDADSTATE = -0x3f879642 + SIOCGLIFDSTADDR = -0x3f87968d + SIOCGLIFFLAGS = -0x3f87968b + SIOCGLIFGROUPINFO = -0x3f4b9663 + SIOCGLIFGROUPNAME = -0x3f879664 + SIOCGLIFHWADDR = -0x3f879640 + SIOCGLIFINDEX = -0x3f87967b + SIOCGLIFLNKINFO = -0x3f879674 + SIOCGLIFMETRIC = -0x3f879681 + SIOCGLIFMTU = -0x3f879686 + SIOCGLIFMUXID = -0x3f87967d + SIOCGLIFNETMASK = -0x3f879683 + SIOCGLIFNUM = -0x3ff3967e + SIOCGLIFSRCOF = -0x3fef964f + SIOCGLIFSUBNET = -0x3f879676 + SIOCGLIFTOKEN = -0x3f879678 + SIOCGLIFUSESRC = -0x3f879651 + SIOCGLIFZONE = -0x3f879656 + SIOCGLOWAT = 0x40047303 + SIOCGMSFILTER = -0x3ffb964e + SIOCGPGRP = 0x40047309 + SIOCGSTAMP = -0x3fef9646 + SIOCGXARP = -0x3fff9659 + SIOCIFDETACH = -0x7fdf96c8 + SIOCILB = -0x3ffb9645 + SIOCLIFADDIF = -0x3f879691 + SIOCLIFDELND = -0x7f879673 + SIOCLIFGETND = -0x3f879672 + SIOCLIFREMOVEIF = -0x7f879692 + SIOCLIFSETND = -0x7f879671 + SIOCLOWER = -0x7fdf96d7 + SIOCSARP = -0x7fdb96e2 + SIOCSCTPGOPT = -0x3fef9653 + SIOCSCTPPEELOFF = -0x3ffb9652 + SIOCSCTPSOPT = -0x7fef9654 + SIOCSENABLESDP = -0x3ffb9649 + SIOCSETPROP = -0x7ffb8f43 + SIOCSETSYNC = -0x7fdf96d4 + SIOCSHIWAT = -0x7ffb8d00 + SIOCSIFADDR = -0x7fdf96f4 + SIOCSIFBRDADDR = -0x7fdf96e8 + SIOCSIFDSTADDR = -0x7fdf96f2 + SIOCSIFFLAGS = -0x7fdf96f0 + SIOCSIFINDEX = -0x7fdf96a5 + SIOCSIFMEM = -0x7fdf96ee + SIOCSIFMETRIC = -0x7fdf96e4 + SIOCSIFMTU = -0x7fdf96eb + SIOCSIFMUXID = -0x7fdf96a7 + SIOCSIFNAME = -0x7fdf96b7 + SIOCSIFNETMASK = -0x7fdf96e6 + SIOCSIP6ADDRPOLICY = -0x7fff965d + SIOCSIPMSFILTER = -0x7ffb964b + SIOCSLGETREQ = -0x3fdf96b9 + SIOCSLIFADDR = -0x7f879690 + SIOCSLIFBRDADDR = -0x7f879684 + SIOCSLIFDSTADDR = -0x7f87968e + SIOCSLIFFLAGS = -0x7f87968c + SIOCSLIFGROUPNAME = -0x7f879665 + SIOCSLIFINDEX = -0x7f87967a + SIOCSLIFLNKINFO = -0x7f879675 + SIOCSLIFMETRIC = -0x7f879680 + SIOCSLIFMTU = -0x7f879687 + SIOCSLIFMUXID = -0x7f87967c + SIOCSLIFNAME = -0x3f87967f + SIOCSLIFNETMASK = -0x7f879682 + SIOCSLIFPREFIX = -0x3f879641 + SIOCSLIFSUBNET = -0x7f879677 + SIOCSLIFTOKEN = -0x7f879679 + SIOCSLIFUSESRC = -0x7f879650 + SIOCSLIFZONE = -0x7f879655 + SIOCSLOWAT = -0x7ffb8cfe + SIOCSLSTAT = -0x7fdf96b8 + SIOCSMSFILTER = -0x7ffb964d + SIOCSPGRP = -0x7ffb8cf8 + SIOCSPROMISC = -0x7ffb96d0 + SIOCSQPTR = -0x3ffb9648 + SIOCSSDSTATS = -0x3fdf96d2 + SIOCSSESTATS = -0x3fdf96d1 + SIOCSXARP = -0x7fff965a + SIOCTMYADDR = -0x3ff79670 + SIOCTMYSITE = -0x3ff7966e + SIOCTONLINK = -0x3ff7966f + SIOCUPPER = -0x7fdf96d8 + SIOCX25RCV = -0x3fdf96c4 + SIOCX25TBL = -0x3fdf96c3 + SIOCX25XMT = -0x3fdf96c5 + SIOCXPROTO = 0x20007337 + SOCK_CLOEXEC = 0x80000 + SOCK_DGRAM = 0x1 + SOCK_NDELAY = 0x200000 + SOCK_NONBLOCK = 0x100000 + SOCK_RAW = 0x4 + SOCK_RDM = 0x5 + SOCK_SEQPACKET = 0x6 + SOCK_STREAM = 0x2 + SOCK_TYPE_MASK = 0xffff + SOL_FILTER = 0xfffc + SOL_PACKET = 0xfffd + SOL_ROUTE = 0xfffe + SOL_SOCKET = 0xffff + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x2 + SO_ALL = 0x3f + SO_ALLZONES = 0x1014 + SO_ANON_MLP = 0x100a + SO_ATTACH_FILTER = 0x40000001 + SO_BAND = 0x4000 + SO_BROADCAST = 0x20 + SO_COPYOPT = 0x80000 + SO_DEBUG = 0x1 + SO_DELIM = 0x8000 + SO_DETACH_FILTER = 0x40000002 + SO_DGRAM_ERRIND = 0x200 + SO_DOMAIN = 0x100c + SO_DONTLINGER = -0x81 + SO_DONTROUTE = 0x10 + SO_ERROPT = 0x40000 + SO_ERROR = 0x1007 + SO_EXCLBIND = 0x1015 + SO_HIWAT = 0x10 + SO_ISNTTY = 0x800 + SO_ISTTY = 0x400 + SO_KEEPALIVE = 0x8 + SO_LINGER = 0x80 + SO_LOWAT = 0x20 + SO_MAC_EXEMPT = 0x100b + SO_MAC_IMPLICIT = 0x1016 + SO_MAXBLK = 0x100000 + SO_MAXPSZ = 0x8 + SO_MINPSZ = 0x4 + SO_MREADOFF = 0x80 + SO_MREADON = 0x40 + SO_NDELOFF = 0x200 + SO_NDELON = 0x100 + SO_NODELIM = 0x10000 + SO_OOBINLINE = 0x100 + SO_PROTOTYPE = 0x1009 + SO_RCVBUF = 0x1002 + SO_RCVLOWAT = 0x1004 + SO_RCVPSH = 0x100d + SO_RCVTIMEO = 0x1006 + SO_READOPT = 0x1 + SO_RECVUCRED = 0x400 + SO_REUSEADDR = 0x4 + SO_SECATTR = 0x1011 + SO_SNDBUF = 0x1001 + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x1005 + SO_STRHOLD = 0x20000 + SO_TAIL = 0x200000 + SO_TIMESTAMP = 0x1013 + SO_TONSTOP = 0x2000 + SO_TOSTOP = 0x1000 + SO_TYPE = 0x1008 + SO_USELOOPBACK = 0x40 + SO_VRRP = 0x1017 + SO_WROFF = 0x2 + TCFLSH = 0x5407 + TCGETA = 0x5401 + TCGETS = 0x540d + TCIFLUSH = 0x0 + TCIOFLUSH = 0x2 + TCOFLUSH = 0x1 + TCP_ABORT_THRESHOLD = 0x11 + TCP_ANONPRIVBIND = 0x20 + TCP_CONN_ABORT_THRESHOLD = 0x13 + TCP_CONN_NOTIFY_THRESHOLD = 0x12 + TCP_CORK = 0x18 + TCP_EXCLBIND = 0x21 + TCP_INIT_CWND = 0x15 + TCP_KEEPALIVE = 0x8 + TCP_KEEPALIVE_ABORT_THRESHOLD = 0x17 + TCP_KEEPALIVE_THRESHOLD = 0x16 + TCP_KEEPCNT = 0x23 + TCP_KEEPIDLE = 0x22 + TCP_KEEPINTVL = 0x24 + TCP_LINGER2 = 0x1c + TCP_MAXSEG = 0x2 + TCP_MSS = 0x218 + TCP_NODELAY = 0x1 + TCP_NOTIFY_THRESHOLD = 0x10 + TCP_RECVDSTADDR = 0x14 + TCP_RTO_INITIAL = 0x19 + TCP_RTO_MAX = 0x1b + TCP_RTO_MIN = 0x1a + TCSAFLUSH = 0x5410 + TCSBRK = 0x5405 + TCSETA = 0x5402 + TCSETAF = 0x5404 + TCSETAW = 0x5403 + TCSETS = 0x540e + TCSETSF = 0x5410 + TCSETSW = 0x540f + TCXONC = 0x5406 + TIOC = 0x5400 + TIOCCBRK = 0x747a + TIOCCDTR = 0x7478 + TIOCCILOOP = 0x746c + TIOCEXCL = 0x740d + TIOCFLUSH = 0x7410 + TIOCGETC = 0x7412 + TIOCGETD = 0x7400 + TIOCGETP = 0x7408 + TIOCGLTC = 0x7474 + TIOCGPGRP = 0x7414 + TIOCGPPS = 0x547d + TIOCGPPSEV = 0x547f + TIOCGSID = 0x7416 + TIOCGSOFTCAR = 0x5469 + TIOCGWINSZ = 0x5468 + TIOCHPCL = 0x7402 + TIOCKBOF = 0x5409 + TIOCKBON = 0x5408 + TIOCLBIC = 0x747e + TIOCLBIS = 0x747f + TIOCLGET = 0x747c + TIOCLSET = 0x747d + TIOCMBIC = 0x741c + TIOCMBIS = 0x741b + TIOCMGET = 0x741d + TIOCMSET = 0x741a + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x7471 + TIOCNXCL = 0x740e + TIOCOUTQ = 0x7473 + TIOCREMOTE = 0x741e + TIOCSBRK = 0x747b + TIOCSCTTY = 0x7484 + TIOCSDTR = 0x7479 + TIOCSETC = 0x7411 + TIOCSETD = 0x7401 + TIOCSETN = 0x740a + TIOCSETP = 0x7409 + TIOCSIGNAL = 0x741f + TIOCSILOOP = 0x746d + TIOCSLTC = 0x7475 + TIOCSPGRP = 0x7415 + TIOCSPPS = 0x547e + TIOCSSOFTCAR = 0x546a + TIOCSTART = 0x746e + TIOCSTI = 0x7417 + TIOCSTOP = 0x746f + TIOCSWINSZ = 0x5467 + TOSTOP = 0x100 + VCEOF = 0x8 + VCEOL = 0x9 + VDISCARD = 0xd + VDSUSP = 0xb + VEOF = 0x4 + VEOL = 0x5 + VEOL2 = 0x6 + VERASE = 0x2 + VINTR = 0x0 + VKILL = 0x3 + VLNEXT = 0xf + VMIN = 0x4 + VQUIT = 0x1 + VREPRINT = 0xc + VSTART = 0x8 + VSTATUS = 0x10 + VSTOP = 0x9 + VSUSP = 0xa + VSWTCH = 0x7 + VT0 = 0x0 + VT1 = 0x4000 + VTDLY = 0x4000 + VTIME = 0x5 + VWERASE = 0xe + WCONTFLG = 0xffff + WCONTINUED = 0x8 + WCOREFLG = 0x80 + WEXITED = 0x1 + WNOHANG = 0x40 + WNOWAIT = 0x80 + WOPTMASK = 0xcf + WRAP = 0x20000 + WSIGMASK = 0x7f + WSTOPFLG = 0x7f + WSTOPPED = 0x4 + WTRAPPED = 0x2 + WUNTRACED = 0x4 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x7d) + EADDRNOTAVAIL = syscall.Errno(0x7e) + EADV = syscall.Errno(0x44) + EAFNOSUPPORT = syscall.Errno(0x7c) + EAGAIN = syscall.Errno(0xb) + EALREADY = syscall.Errno(0x95) + EBADE = syscall.Errno(0x32) + EBADF = syscall.Errno(0x9) + EBADFD = syscall.Errno(0x51) + EBADMSG = syscall.Errno(0x4d) + EBADR = syscall.Errno(0x33) + EBADRQC = syscall.Errno(0x36) + EBADSLT = syscall.Errno(0x37) + EBFONT = syscall.Errno(0x39) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x2f) + ECHILD = syscall.Errno(0xa) + ECHRNG = syscall.Errno(0x25) + ECOMM = syscall.Errno(0x46) + ECONNABORTED = syscall.Errno(0x82) + ECONNREFUSED = syscall.Errno(0x92) + ECONNRESET = syscall.Errno(0x83) + EDEADLK = syscall.Errno(0x2d) + EDEADLOCK = syscall.Errno(0x38) + EDESTADDRREQ = syscall.Errno(0x60) + EDOM = syscall.Errno(0x21) + EDQUOT = syscall.Errno(0x31) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EHOSTDOWN = syscall.Errno(0x93) + EHOSTUNREACH = syscall.Errno(0x94) + EIDRM = syscall.Errno(0x24) + EILSEQ = syscall.Errno(0x58) + EINPROGRESS = syscall.Errno(0x96) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EISCONN = syscall.Errno(0x85) + EISDIR = syscall.Errno(0x15) + EL2HLT = syscall.Errno(0x2c) + EL2NSYNC = syscall.Errno(0x26) + EL3HLT = syscall.Errno(0x27) + EL3RST = syscall.Errno(0x28) + ELIBACC = syscall.Errno(0x53) + ELIBBAD = syscall.Errno(0x54) + ELIBEXEC = syscall.Errno(0x57) + ELIBMAX = syscall.Errno(0x56) + ELIBSCN = syscall.Errno(0x55) + ELNRNG = syscall.Errno(0x29) + ELOCKUNMAPPED = syscall.Errno(0x48) + ELOOP = syscall.Errno(0x5a) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x61) + EMULTIHOP = syscall.Errno(0x4a) + ENAMETOOLONG = syscall.Errno(0x4e) + ENETDOWN = syscall.Errno(0x7f) + ENETRESET = syscall.Errno(0x81) + ENETUNREACH = syscall.Errno(0x80) + ENFILE = syscall.Errno(0x17) + ENOANO = syscall.Errno(0x35) + ENOBUFS = syscall.Errno(0x84) + ENOCSI = syscall.Errno(0x2b) + ENODATA = syscall.Errno(0x3d) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOLCK = syscall.Errno(0x2e) + ENOLINK = syscall.Errno(0x43) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x23) + ENONET = syscall.Errno(0x40) + ENOPKG = syscall.Errno(0x41) + ENOPROTOOPT = syscall.Errno(0x63) + ENOSPC = syscall.Errno(0x1c) + ENOSR = syscall.Errno(0x3f) + ENOSTR = syscall.Errno(0x3c) + ENOSYS = syscall.Errno(0x59) + ENOTACTIVE = syscall.Errno(0x49) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x86) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x5d) + ENOTRECOVERABLE = syscall.Errno(0x3b) + ENOTSOCK = syscall.Errno(0x5f) + ENOTSUP = syscall.Errno(0x30) + ENOTTY = syscall.Errno(0x19) + ENOTUNIQ = syscall.Errno(0x50) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x7a) + EOVERFLOW = syscall.Errno(0x4f) + EOWNERDEAD = syscall.Errno(0x3a) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x7b) + EPIPE = syscall.Errno(0x20) + EPROTO = syscall.Errno(0x47) + EPROTONOSUPPORT = syscall.Errno(0x78) + EPROTOTYPE = syscall.Errno(0x62) + ERANGE = syscall.Errno(0x22) + EREMCHG = syscall.Errno(0x52) + EREMOTE = syscall.Errno(0x42) + ERESTART = syscall.Errno(0x5b) + EROFS = syscall.Errno(0x1e) + ESHUTDOWN = syscall.Errno(0x8f) + ESOCKTNOSUPPORT = syscall.Errno(0x79) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESRMNT = syscall.Errno(0x45) + ESTALE = syscall.Errno(0x97) + ESTRPIPE = syscall.Errno(0x5c) + ETIME = syscall.Errno(0x3e) + ETIMEDOUT = syscall.Errno(0x91) + ETOOMANYREFS = syscall.Errno(0x90) + ETXTBSY = syscall.Errno(0x1a) + EUNATCH = syscall.Errno(0x2a) + EUSERS = syscall.Errno(0x5e) + EWOULDBLOCK = syscall.Errno(0xb) + EXDEV = syscall.Errno(0x12) + EXFULL = syscall.Errno(0x34) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0xa) + SIGCANCEL = syscall.Signal(0x24) + SIGCHLD = syscall.Signal(0x12) + SIGCLD = syscall.Signal(0x12) + SIGCONT = syscall.Signal(0x19) + SIGEMT = syscall.Signal(0x7) + SIGFPE = syscall.Signal(0x8) + SIGFREEZE = syscall.Signal(0x22) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINFO = syscall.Signal(0x29) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x16) + SIGIOT = syscall.Signal(0x6) + SIGJVM1 = syscall.Signal(0x27) + SIGJVM2 = syscall.Signal(0x28) + SIGKILL = syscall.Signal(0x9) + SIGLOST = syscall.Signal(0x25) + SIGLWP = syscall.Signal(0x21) + SIGPIPE = syscall.Signal(0xd) + SIGPOLL = syscall.Signal(0x16) + SIGPROF = syscall.Signal(0x1d) + SIGPWR = syscall.Signal(0x13) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTOP = syscall.Signal(0x17) + SIGSYS = syscall.Signal(0xc) + SIGTERM = syscall.Signal(0xf) + SIGTHAW = syscall.Signal(0x23) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x18) + SIGTTIN = syscall.Signal(0x1a) + SIGTTOU = syscall.Signal(0x1b) + SIGURG = syscall.Signal(0x15) + SIGUSR1 = syscall.Signal(0x10) + SIGUSR2 = syscall.Signal(0x11) + SIGVTALRM = syscall.Signal(0x1c) + SIGWAITING = syscall.Signal(0x20) + SIGWINCH = syscall.Signal(0x14) + SIGXCPU = syscall.Signal(0x1e) + SIGXFSZ = syscall.Signal(0x1f) + SIGXRES = syscall.Signal(0x26) +) + +// Error table +var errors = [...]string{ + 1: "not owner", + 2: "no such file or directory", + 3: "no such process", + 4: "interrupted system call", + 5: "I/O error", + 6: "no such device or address", + 7: "arg list too long", + 8: "exec format error", + 9: "bad file number", + 10: "no child processes", + 11: "resource temporarily unavailable", + 12: "not enough space", + 13: "permission denied", + 14: "bad address", + 15: "block device required", + 16: "device busy", + 17: "file exists", + 18: "cross-device link", + 19: "no such device", + 20: "not a directory", + 21: "is a directory", + 22: "invalid argument", + 23: "file table overflow", + 24: "too many open files", + 25: "inappropriate ioctl for device", + 26: "text file busy", + 27: "file too large", + 28: "no space left on device", + 29: "illegal seek", + 30: "read-only file system", + 31: "too many links", + 32: "broken pipe", + 33: "argument out of domain", + 34: "result too large", + 35: "no message of desired type", + 36: "identifier removed", + 37: "channel number out of range", + 38: "level 2 not synchronized", + 39: "level 3 halted", + 40: "level 3 reset", + 41: "link number out of range", + 42: "protocol driver not attached", + 43: "no CSI structure available", + 44: "level 2 halted", + 45: "deadlock situation detected/avoided", + 46: "no record locks available", + 47: "operation canceled", + 48: "operation not supported", + 49: "disc quota exceeded", + 50: "bad exchange descriptor", + 51: "bad request descriptor", + 52: "message tables full", + 53: "anode table overflow", + 54: "bad request code", + 55: "invalid slot", + 56: "file locking deadlock", + 57: "bad font file format", + 58: "owner of the lock died", + 59: "lock is not recoverable", + 60: "not a stream device", + 61: "no data available", + 62: "timer expired", + 63: "out of stream resources", + 64: "machine is not on the network", + 65: "package not installed", + 66: "object is remote", + 67: "link has been severed", + 68: "advertise error", + 69: "srmount error", + 70: "communication error on send", + 71: "protocol error", + 72: "locked lock was unmapped ", + 73: "facility is not active", + 74: "multihop attempted", + 77: "not a data message", + 78: "file name too long", + 79: "value too large for defined data type", + 80: "name not unique on network", + 81: "file descriptor in bad state", + 82: "remote address changed", + 83: "can not access a needed shared library", + 84: "accessing a corrupted shared library", + 85: ".lib section in a.out corrupted", + 86: "attempting to link in more shared libraries than system limit", + 87: "can not exec a shared library directly", + 88: "illegal byte sequence", + 89: "operation not applicable", + 90: "number of symbolic links encountered during path name traversal exceeds MAXSYMLINKS", + 91: "error 91", + 92: "error 92", + 93: "directory not empty", + 94: "too many users", + 95: "socket operation on non-socket", + 96: "destination address required", + 97: "message too long", + 98: "protocol wrong type for socket", + 99: "option not supported by protocol", + 120: "protocol not supported", + 121: "socket type not supported", + 122: "operation not supported on transport endpoint", + 123: "protocol family not supported", + 124: "address family not supported by protocol family", + 125: "address already in use", + 126: "cannot assign requested address", + 127: "network is down", + 128: "network is unreachable", + 129: "network dropped connection because of reset", + 130: "software caused connection abort", + 131: "connection reset by peer", + 132: "no buffer space available", + 133: "transport endpoint is already connected", + 134: "transport endpoint is not connected", + 143: "cannot send after socket shutdown", + 144: "too many references: cannot splice", + 145: "connection timed out", + 146: "connection refused", + 147: "host is down", + 148: "no route to host", + 149: "operation already in progress", + 150: "operation now in progress", + 151: "stale NFS file handle", +} + +// Signal table +var signals = [...]string{ + 1: "hangup", + 2: "interrupt", + 3: "quit", + 4: "illegal Instruction", + 5: "trace/Breakpoint Trap", + 6: "abort", + 7: "emulation Trap", + 8: "arithmetic Exception", + 9: "killed", + 10: "bus Error", + 11: "segmentation Fault", + 12: "bad System Call", + 13: "broken Pipe", + 14: "alarm Clock", + 15: "terminated", + 16: "user Signal 1", + 17: "user Signal 2", + 18: "child Status Changed", + 19: "power-Fail/Restart", + 20: "window Size Change", + 21: "urgent Socket Condition", + 22: "pollable Event", + 23: "stopped (signal)", + 24: "stopped (user)", + 25: "continued", + 26: "stopped (tty input)", + 27: "stopped (tty output)", + 28: "virtual Timer Expired", + 29: "profiling Timer Expired", + 30: "cpu Limit Exceeded", + 31: "file Size Limit Exceeded", + 32: "no runnable lwp", + 33: "inter-lwp signal", + 34: "checkpoint Freeze", + 35: "checkpoint Thaw", + 36: "thread Cancellation", + 37: "resource Lost", + 38: "resource Control Exceeded", + 39: "reserved for JVM 1", + 40: "reserved for JVM 2", + 41: "information Request", +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go new file mode 100644 index 0000000000..031034a345 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go @@ -0,0 +1,1427 @@ +// mksyscall.pl -l32 syscall_bsd.go syscall_darwin.go syscall_darwin_386.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build 386,darwin + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(ngid int, gid *_Gid_t) (n int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(ngid int, gid *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(s int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) { + r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { + var _p0 unsafe.Pointer + if len(mib) > 0 { + _p0 = unsafe.Pointer(&mib[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + use(_p0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, timeval *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimes(fd int, timeval *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe() (r int, w int, err error) { + r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) + r = int(r0) + w = int(r1) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kill(pid int, signum int, posix int) (err error) { + _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Access(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { + _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chflags(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chmod(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(fd int) (nfd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0) + nfd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(from int, to int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exchangedata(path1 string, path2 string, options int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path1) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(path2) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_EXCHANGEDATA, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options)) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchflags(fd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fpathconf(fd int, name int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, stat *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), uintptr(length>>32)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_GETDIRENTRIES64, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdtablesize() (size int) { + r0, _, _ := Syscall(SYS_GETDTABLESIZE, 0, 0, 0) + size = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgrp() (pgrp int) { + r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0) + pgrp = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Issetugid() (tainted bool) { + r0, _, _ := RawSyscall(SYS_ISSETUGID, 0, 0, 0) + tainted = bool(r0 != 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kqueue() (fd int, err error) { + r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Link(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, backlog int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdir(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkfifo(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknod(path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Open(path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pathconf(path string, name int) (val int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0) + use(unsafe.Pointer(_p0)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Readlink(path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf))) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rename(from string, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Revoke(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rmdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { + r0, r1, e1 := Syscall6(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(offset>>32), uintptr(whence), 0, 0) + newoffset = int64(int64(r1)<<32 | int64(r0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) { + _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setegid(egid int) (err error) { + _, _, e1 := Syscall(SYS_SETEGID, uintptr(egid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seteuid(euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setgid(gid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setlogin(name string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(name) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setprivexec(flag int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIVEXEC, uintptr(flag), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tp *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setuid(uid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, stat *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Symlink(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() (err error) { + _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), uintptr(length>>32)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(newmask int) (oldmask int) { + r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Undelete(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unlink(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { + r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos), uintptr(pos>>32), 0, 0) + ret = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func gettimeofday(tp *Timeval) (sec int32, usec int32, err error) { + r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0) + sec = int32(r0) + usec = int32(r1) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go new file mode 100644 index 0000000000..ee96f78bad --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go @@ -0,0 +1,1443 @@ +// mksyscall.pl syscall_bsd.go syscall_darwin.go syscall_darwin_amd64.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build amd64,darwin + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(ngid int, gid *_Gid_t) (n int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(ngid int, gid *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(s int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) { + r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { + var _p0 unsafe.Pointer + if len(mib) > 0 { + _p0 = unsafe.Pointer(&mib[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + use(_p0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, timeval *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimes(fd int, timeval *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe() (r int, w int, err error) { + r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) + r = int(r0) + w = int(r1) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kill(pid int, signum int, posix int) (err error) { + _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Access(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { + _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chflags(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chmod(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(fd int) (nfd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0) + nfd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(from int, to int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exchangedata(path1 string, path2 string, options int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path1) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(path2) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_EXCHANGEDATA, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options)) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchflags(fd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fpathconf(fd int, name int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, stat *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_GETDIRENTRIES64, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdtablesize() (size int) { + r0, _, _ := Syscall(SYS_GETDTABLESIZE, 0, 0, 0) + size = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgrp() (pgrp int) { + r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0) + pgrp = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Issetugid() (tainted bool) { + r0, _, _ := RawSyscall(SYS_ISSETUGID, 0, 0, 0) + tainted = bool(r0 != 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kqueue() (fd int, err error) { + r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Link(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, backlog int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdir(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkfifo(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknod(path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Open(path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pathconf(path string, name int) (val int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0) + use(unsafe.Pointer(_p0)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Readlink(path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf))) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rename(from string, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Revoke(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rmdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { + r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence)) + newoffset = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) { + _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setegid(egid int) (err error) { + _, _, e1 := Syscall(SYS_SETEGID, uintptr(egid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seteuid(euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setgid(gid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setlogin(name string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(name) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setprivexec(flag int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIVEXEC, uintptr(flag), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tp *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setuid(uid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, stat *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Symlink(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() (err error) { + _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(newmask int) (oldmask int) { + r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Undelete(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unlink(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { + r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos)) + ret = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func gettimeofday(tp *Timeval) (sec int64, usec int32, err error) { + r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0) + sec = int64(r0) + usec = int32(r1) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go new file mode 100644 index 0000000000..e52cd0d54c --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go @@ -0,0 +1,1427 @@ +// mksyscall.pl syscall_bsd.go syscall_darwin.go syscall_darwin_arm.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build arm,darwin + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(ngid int, gid *_Gid_t) (n int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(ngid int, gid *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(s int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) { + r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { + var _p0 unsafe.Pointer + if len(mib) > 0 { + _p0 = unsafe.Pointer(&mib[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + use(_p0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, timeval *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimes(fd int, timeval *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe() (r int, w int, err error) { + r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) + r = int(r0) + w = int(r1) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kill(pid int, signum int, posix int) (err error) { + _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Access(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { + _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chflags(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chmod(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(fd int) (nfd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0) + nfd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(from int, to int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exchangedata(path1 string, path2 string, options int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path1) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(path2) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_EXCHANGEDATA, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options)) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchflags(fd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fpathconf(fd int, name int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, stat *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_GETDIRENTRIES64, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdtablesize() (size int) { + r0, _, _ := Syscall(SYS_GETDTABLESIZE, 0, 0, 0) + size = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgrp() (pgrp int) { + r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0) + pgrp = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Issetugid() (tainted bool) { + r0, _, _ := RawSyscall(SYS_ISSETUGID, 0, 0, 0) + tainted = bool(r0 != 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kqueue() (fd int, err error) { + r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Link(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, backlog int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdir(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkfifo(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknod(path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Open(path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pathconf(path string, name int) (val int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0) + use(unsafe.Pointer(_p0)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Readlink(path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf))) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rename(from string, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Revoke(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rmdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { + r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence)) + newoffset = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) { + _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setegid(egid int) (err error) { + _, _, e1 := Syscall(SYS_SETEGID, uintptr(egid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seteuid(euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setgid(gid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setlogin(name string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(name) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setprivexec(flag int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIVEXEC, uintptr(flag), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tp *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setuid(uid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, stat *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Symlink(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() (err error) { + _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(newmask int) (oldmask int) { + r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Undelete(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unlink(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { + r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos)) + ret = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func gettimeofday(tp *Timeval) (sec int32, usec int32, err error) { + r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0) + sec = int32(r0) + usec = int32(r1) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go new file mode 100644 index 0000000000..9863ef99e3 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go @@ -0,0 +1,1427 @@ +// mksyscall.pl syscall_bsd.go syscall_darwin.go syscall_darwin_arm64.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build arm64,darwin + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(ngid int, gid *_Gid_t) (n int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(ngid int, gid *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(s int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) { + r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { + var _p0 unsafe.Pointer + if len(mib) > 0 { + _p0 = unsafe.Pointer(&mib[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + use(_p0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, timeval *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimes(fd int, timeval *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe() (r int, w int, err error) { + r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) + r = int(r0) + w = int(r1) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kill(pid int, signum int, posix int) (err error) { + _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Access(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { + _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chflags(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chmod(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(fd int) (nfd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0) + nfd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(from int, to int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exchangedata(path1 string, path2 string, options int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path1) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(path2) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_EXCHANGEDATA, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options)) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchflags(fd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fpathconf(fd int, name int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, stat *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_GETDIRENTRIES64, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdtablesize() (size int) { + r0, _, _ := Syscall(SYS_GETDTABLESIZE, 0, 0, 0) + size = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgrp() (pgrp int) { + r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0) + pgrp = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Issetugid() (tainted bool) { + r0, _, _ := RawSyscall(SYS_ISSETUGID, 0, 0, 0) + tainted = bool(r0 != 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kqueue() (fd int, err error) { + r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Link(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, backlog int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdir(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkfifo(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknod(path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Open(path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pathconf(path string, name int) (val int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0) + use(unsafe.Pointer(_p0)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Readlink(path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf))) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rename(from string, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Revoke(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rmdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { + r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence)) + newoffset = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) { + _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setegid(egid int) (err error) { + _, _, e1 := Syscall(SYS_SETEGID, uintptr(egid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seteuid(euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setgid(gid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setlogin(name string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(name) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setprivexec(flag int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIVEXEC, uintptr(flag), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tp *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setuid(uid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, stat *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Symlink(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() (err error) { + _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(newmask int) (oldmask int) { + r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Undelete(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unlink(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { + r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos)) + ret = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func gettimeofday(tp *Timeval) (sec int64, usec int32, err error) { + r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0) + sec = int64(r0) + usec = int32(r1) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go new file mode 100644 index 0000000000..78de48dcf3 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go @@ -0,0 +1,1413 @@ +// mksyscall.pl -dragonfly syscall_bsd.go syscall_dragonfly.go syscall_dragonfly_amd64.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build amd64,dragonfly + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(ngid int, gid *_Gid_t) (n int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(ngid int, gid *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(s int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) { + r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { + var _p0 unsafe.Pointer + if len(mib) > 0 { + _p0 = unsafe.Pointer(&mib[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + use(_p0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, timeval *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimes(fd int, timeval *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe() (r int, w int, err error) { + r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) + r = int(r0) + w = int(r1) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func extpread(fd int, p []byte, flags int, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_EXTPREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(offset), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func extpwrite(fd int, p []byte, flags int, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_EXTPWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(offset), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Access(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { + _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chflags(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chmod(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(fd int) (nfd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0) + nfd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(from int, to int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchflags(fd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fpathconf(fd int, name int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, stat *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), 0, uintptr(length)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_GETDIRENTRIES, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdtablesize() (size int) { + r0, _, _ := Syscall(SYS_GETDTABLESIZE, 0, 0, 0) + size = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgrp() (pgrp int) { + r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0) + pgrp = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Issetugid() (tainted bool) { + r0, _, _ := Syscall(SYS_ISSETUGID, 0, 0, 0) + tainted = bool(r0 != 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, signum syscall.Signal) (err error) { + _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kqueue() (fd int, err error) { + r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Link(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, backlog int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdir(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkfifo(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknod(path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Open(path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pathconf(path string, name int) (val int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0) + use(unsafe.Pointer(_p0)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Readlink(path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf))) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rename(from string, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Revoke(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rmdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { + r0, _, e1 := Syscall6(SYS_LSEEK, uintptr(fd), 0, uintptr(offset), uintptr(whence), 0, 0) + newoffset = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) { + _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setegid(egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETEGID, uintptr(egid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seteuid(euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setgid(gid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setlogin(name string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(name) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresgid(rgid int, egid int, sgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresuid(ruid int, euid int, suid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tp *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setuid(uid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, stat *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Symlink(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() (err error) { + _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), 0, uintptr(length)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(newmask int) (oldmask int) { + r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Undelete(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unlink(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { + r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), 0, uintptr(pos), 0, 0) + ret = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go new file mode 100644 index 0000000000..fade994dcf --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go @@ -0,0 +1,1665 @@ +// mksyscall.pl -l32 syscall_bsd.go syscall_freebsd.go syscall_freebsd_386.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build 386,freebsd + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(ngid int, gid *_Gid_t) (n int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(ngid int, gid *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(s int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) { + r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { + var _p0 unsafe.Pointer + if len(mib) > 0 { + _p0 = unsafe.Pointer(&mib[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + use(_p0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, timeval *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimes(fd int, timeval *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe() (r int, w int, err error) { + r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) + r = int(r0) + w = int(r1) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Access(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { + _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chflags(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chmod(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(fd int) (nfd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0) + nfd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(from int, to int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrGetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(attrname) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_EXTATTR_GET_FD, uintptr(fd), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p0)), uintptr(data), uintptr(nbytes), 0) + use(unsafe.Pointer(_p0)) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrSetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(attrname) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_EXTATTR_SET_FD, uintptr(fd), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p0)), uintptr(data), uintptr(nbytes), 0) + use(unsafe.Pointer(_p0)) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrDeleteFd(fd int, attrnamespace int, attrname string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(attrname) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_EXTATTR_DELETE_FD, uintptr(fd), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p0))) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrListFd(fd int, attrnamespace int, data uintptr, nbytes int) (ret int, err error) { + r0, _, e1 := Syscall6(SYS_EXTATTR_LIST_FD, uintptr(fd), uintptr(attrnamespace), uintptr(data), uintptr(nbytes), 0, 0) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrGetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(file) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attrname) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_EXTATTR_GET_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrSetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(file) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attrname) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_EXTATTR_SET_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrDeleteFile(file string, attrnamespace int, attrname string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(file) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attrname) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_EXTATTR_DELETE_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1))) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrListFile(file string, attrnamespace int, data uintptr, nbytes int) (ret int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(file) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_EXTATTR_LIST_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(data), uintptr(nbytes), 0, 0) + use(unsafe.Pointer(_p0)) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrGetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(link) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attrname) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_EXTATTR_GET_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrSetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(link) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attrname) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_EXTATTR_SET_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrDeleteLink(link string, attrnamespace int, attrname string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(link) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attrname) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_EXTATTR_DELETE_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1))) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrListLink(link string, attrnamespace int, data uintptr, nbytes int) (ret int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(link) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_EXTATTR_LIST_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(data), uintptr(nbytes), 0, 0) + use(unsafe.Pointer(_p0)) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fadvise(fd int, offset int64, length int64, advice int) (err error) { + _, _, e1 := Syscall6(SYS_POSIX_FADVISE, uintptr(fd), uintptr(offset), uintptr(offset>>32), uintptr(length), uintptr(length>>32), uintptr(advice)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchflags(fd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fpathconf(fd int, name int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, stat *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), uintptr(length>>32)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_GETDIRENTRIES, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdtablesize() (size int) { + r0, _, _ := Syscall(SYS_GETDTABLESIZE, 0, 0, 0) + size = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgrp() (pgrp int) { + r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0) + pgrp = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Issetugid() (tainted bool) { + r0, _, _ := Syscall(SYS_ISSETUGID, 0, 0, 0) + tainted = bool(r0 != 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, signum syscall.Signal) (err error) { + _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kqueue() (fd int, err error) { + r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Link(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, backlog int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdir(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkfifo(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknod(path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Open(path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pathconf(path string, name int) (val int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0) + use(unsafe.Pointer(_p0)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Readlink(path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf))) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rename(from string, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Revoke(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rmdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { + r0, r1, e1 := Syscall6(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(offset>>32), uintptr(whence), 0, 0) + newoffset = int64(int64(r1)<<32 | int64(r0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) { + _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setegid(egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETEGID, uintptr(egid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seteuid(euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setgid(gid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setlogin(name string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(name) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresgid(rgid int, egid int, sgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresuid(ruid int, euid int, suid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tp *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setuid(uid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, stat *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Symlink(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() (err error) { + _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), uintptr(length>>32)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(newmask int) (oldmask int) { + r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Undelete(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unlink(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { + r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos), uintptr(pos>>32), 0, 0) + ret = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int, err error) { + r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) + nfd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go new file mode 100644 index 0000000000..c28281e83e --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go @@ -0,0 +1,1665 @@ +// mksyscall.pl syscall_bsd.go syscall_freebsd.go syscall_freebsd_amd64.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build amd64,freebsd + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(ngid int, gid *_Gid_t) (n int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(ngid int, gid *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(s int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) { + r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { + var _p0 unsafe.Pointer + if len(mib) > 0 { + _p0 = unsafe.Pointer(&mib[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + use(_p0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, timeval *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimes(fd int, timeval *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe() (r int, w int, err error) { + r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) + r = int(r0) + w = int(r1) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Access(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { + _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chflags(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chmod(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(fd int) (nfd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0) + nfd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(from int, to int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrGetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(attrname) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_EXTATTR_GET_FD, uintptr(fd), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p0)), uintptr(data), uintptr(nbytes), 0) + use(unsafe.Pointer(_p0)) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrSetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(attrname) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_EXTATTR_SET_FD, uintptr(fd), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p0)), uintptr(data), uintptr(nbytes), 0) + use(unsafe.Pointer(_p0)) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrDeleteFd(fd int, attrnamespace int, attrname string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(attrname) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_EXTATTR_DELETE_FD, uintptr(fd), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p0))) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrListFd(fd int, attrnamespace int, data uintptr, nbytes int) (ret int, err error) { + r0, _, e1 := Syscall6(SYS_EXTATTR_LIST_FD, uintptr(fd), uintptr(attrnamespace), uintptr(data), uintptr(nbytes), 0, 0) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrGetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(file) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attrname) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_EXTATTR_GET_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrSetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(file) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attrname) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_EXTATTR_SET_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrDeleteFile(file string, attrnamespace int, attrname string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(file) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attrname) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_EXTATTR_DELETE_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1))) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrListFile(file string, attrnamespace int, data uintptr, nbytes int) (ret int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(file) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_EXTATTR_LIST_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(data), uintptr(nbytes), 0, 0) + use(unsafe.Pointer(_p0)) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrGetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(link) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attrname) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_EXTATTR_GET_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrSetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(link) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attrname) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_EXTATTR_SET_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrDeleteLink(link string, attrnamespace int, attrname string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(link) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attrname) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_EXTATTR_DELETE_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1))) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrListLink(link string, attrnamespace int, data uintptr, nbytes int) (ret int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(link) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_EXTATTR_LIST_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(data), uintptr(nbytes), 0, 0) + use(unsafe.Pointer(_p0)) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fadvise(fd int, offset int64, length int64, advice int) (err error) { + _, _, e1 := Syscall6(SYS_POSIX_FADVISE, uintptr(fd), uintptr(offset), uintptr(length), uintptr(advice), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchflags(fd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fpathconf(fd int, name int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, stat *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_GETDIRENTRIES, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdtablesize() (size int) { + r0, _, _ := Syscall(SYS_GETDTABLESIZE, 0, 0, 0) + size = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgrp() (pgrp int) { + r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0) + pgrp = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Issetugid() (tainted bool) { + r0, _, _ := Syscall(SYS_ISSETUGID, 0, 0, 0) + tainted = bool(r0 != 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, signum syscall.Signal) (err error) { + _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kqueue() (fd int, err error) { + r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Link(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, backlog int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdir(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkfifo(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknod(path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Open(path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pathconf(path string, name int) (val int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0) + use(unsafe.Pointer(_p0)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Readlink(path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf))) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rename(from string, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Revoke(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rmdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { + r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence)) + newoffset = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) { + _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setegid(egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETEGID, uintptr(egid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seteuid(euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setgid(gid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setlogin(name string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(name) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresgid(rgid int, egid int, sgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresuid(ruid int, euid int, suid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tp *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setuid(uid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, stat *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Symlink(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() (err error) { + _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(newmask int) (oldmask int) { + r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Undelete(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unlink(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { + r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos)) + ret = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int, err error) { + r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) + nfd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go new file mode 100644 index 0000000000..a18ba5c88b --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go @@ -0,0 +1,1665 @@ +// mksyscall.pl -l32 -arm syscall_bsd.go syscall_freebsd.go syscall_freebsd_arm.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build arm,freebsd + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(ngid int, gid *_Gid_t) (n int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(ngid int, gid *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(s int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) { + r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { + var _p0 unsafe.Pointer + if len(mib) > 0 { + _p0 = unsafe.Pointer(&mib[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + use(_p0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, timeval *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimes(fd int, timeval *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe() (r int, w int, err error) { + r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) + r = int(r0) + w = int(r1) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Access(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { + _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chflags(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chmod(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(fd int) (nfd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0) + nfd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(from int, to int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrGetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(attrname) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_EXTATTR_GET_FD, uintptr(fd), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p0)), uintptr(data), uintptr(nbytes), 0) + use(unsafe.Pointer(_p0)) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrSetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(attrname) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_EXTATTR_SET_FD, uintptr(fd), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p0)), uintptr(data), uintptr(nbytes), 0) + use(unsafe.Pointer(_p0)) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrDeleteFd(fd int, attrnamespace int, attrname string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(attrname) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_EXTATTR_DELETE_FD, uintptr(fd), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p0))) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrListFd(fd int, attrnamespace int, data uintptr, nbytes int) (ret int, err error) { + r0, _, e1 := Syscall6(SYS_EXTATTR_LIST_FD, uintptr(fd), uintptr(attrnamespace), uintptr(data), uintptr(nbytes), 0, 0) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrGetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(file) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attrname) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_EXTATTR_GET_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrSetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(file) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attrname) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_EXTATTR_SET_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrDeleteFile(file string, attrnamespace int, attrname string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(file) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attrname) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_EXTATTR_DELETE_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1))) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrListFile(file string, attrnamespace int, data uintptr, nbytes int) (ret int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(file) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_EXTATTR_LIST_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(data), uintptr(nbytes), 0, 0) + use(unsafe.Pointer(_p0)) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrGetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(link) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attrname) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_EXTATTR_GET_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrSetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(link) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attrname) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_EXTATTR_SET_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrDeleteLink(link string, attrnamespace int, attrname string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(link) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attrname) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_EXTATTR_DELETE_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1))) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ExtattrListLink(link string, attrnamespace int, data uintptr, nbytes int) (ret int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(link) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_EXTATTR_LIST_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(data), uintptr(nbytes), 0, 0) + use(unsafe.Pointer(_p0)) + ret = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fadvise(fd int, offset int64, length int64, advice int) (err error) { + _, _, e1 := Syscall9(SYS_POSIX_FADVISE, uintptr(fd), 0, uintptr(offset), uintptr(offset>>32), uintptr(length), uintptr(length>>32), uintptr(advice), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchflags(fd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fpathconf(fd int, name int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, stat *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall6(SYS_FTRUNCATE, uintptr(fd), 0, uintptr(length), uintptr(length>>32), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_GETDIRENTRIES, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdtablesize() (size int) { + r0, _, _ := Syscall(SYS_GETDTABLESIZE, 0, 0, 0) + size = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgrp() (pgrp int) { + r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0) + pgrp = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Issetugid() (tainted bool) { + r0, _, _ := Syscall(SYS_ISSETUGID, 0, 0, 0) + tainted = bool(r0 != 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, signum syscall.Signal) (err error) { + _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kqueue() (fd int, err error) { + r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Link(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, backlog int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdir(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkfifo(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknod(path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Open(path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pathconf(path string, name int) (val int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0) + use(unsafe.Pointer(_p0)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Readlink(path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf))) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rename(from string, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Revoke(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rmdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { + r0, r1, e1 := Syscall6(SYS_LSEEK, uintptr(fd), 0, uintptr(offset), uintptr(offset>>32), uintptr(whence), 0) + newoffset = int64(int64(r1)<<32 | int64(r0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) { + _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setegid(egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETEGID, uintptr(egid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seteuid(euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setgid(gid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setlogin(name string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(name) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresgid(rgid int, egid int, sgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresuid(ruid int, euid int, suid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tp *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setuid(uid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, stat *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Symlink(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() (err error) { + _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), 0, uintptr(length), uintptr(length>>32), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(newmask int) (oldmask int) { + r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Undelete(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unlink(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { + r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), 0, uintptr(pos), uintptr(pos>>32), 0) + ret = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int, err error) { + r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) + nfd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go new file mode 100644 index 0000000000..749f3e46e6 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go @@ -0,0 +1,1638 @@ +// mksyscall.pl -l32 syscall_linux.go syscall_linux_386.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build 386,linux + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, times *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getcwd(buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETCWD, uintptr(_p0), uintptr(len(buf)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(arg) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(source) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(target) + if err != nil { + return + } + var _p2 *byte + _p2, err = BytePtrFromString(fstype) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(flags), uintptr(unsafe.Pointer(data)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + use(unsafe.Pointer(_p2)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Acct(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtimex(buf *Timex) (state int, err error) { + r0, _, e1 := Syscall(SYS_ADJTIMEX, uintptr(unsafe.Pointer(buf)), 0, 0) + state = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ClockGettime(clockid int32, time *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(oldfd int) (fd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup3(oldfd int, newfd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate(size int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate1(flag int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE1, uintptr(flag), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) { + _, _, e1 := RawSyscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fallocate(fd int, mode uint32, off int64, len int64) (err error) { + _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(off>>32), uintptr(len), uintptr(len>>32)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fdatasync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdents(fd int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettid() (tid int) { + r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0) + tid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getxattr(path string, attr string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(dest) > 0 { + _p2 = unsafe.Pointer(&dest[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(pathname) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(mask)) + use(unsafe.Pointer(_p0)) + watchdesc = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyInit1(flags int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0) + success = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Klogctl(typ int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listxattr(path string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(dest) > 0 { + _p1 = unsafe.Pointer(&dest[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest))) + use(unsafe.Pointer(_p0)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdirat(dirfd int, path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func PivotRoot(newroot string, putold string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(newroot) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(putold) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_PIVOT_ROOT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { + _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(newlimit)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Removexattr(path string, attr string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setdomainname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETDOMAINNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sethostname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETHOSTNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setns(fd int, nstype int) (err error) { + _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setxattr(path string, attr string, data []byte, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(data) > 0 { + _p2 = unsafe.Pointer(&data[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() { + Syscall(SYS_SYNC, 0, 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sysinfo(info *Sysinfo_t) (err error) { + _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { + r0, r1, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0) + n = int64(int64(r1)<<32 | int64(r0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Times(tms *Tms) (ticks uintptr, err error) { + r0, _, e1 := RawSyscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0) + ticks = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(mask int) (oldmask int) { + r0, _, _ := RawSyscall(SYS_UMASK, uintptr(mask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Uname(buf *Utsname) (err error) { + _, _, e1 := RawSyscall(SYS_UNAME, uintptr(unsafe.Pointer(buf)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(target string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(target) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unshare(flags int) (err error) { + _, _, e1 := Syscall(SYS_UNSHARE, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ustat(dev int, ubuf *Ustat_t) (err error) { + _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func exitThread(code int) (err error) { + _, _, e1 := Syscall(SYS_EXIT, uintptr(code), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Madvise(b []byte, advice int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe(p *[2]_C_int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(oldfd int, newfd int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fadvise(fd int, offset int64, length int64, advice int) (err error) { + _, _, e1 := Syscall6(SYS_FADVISE64_64, uintptr(fd), uintptr(offset), uintptr(offset>>32), uintptr(length), uintptr(length>>32), uintptr(advice)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN32, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE64, uintptr(fd), uintptr(length), uintptr(length>>32)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID32, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (euid int) { + r0, _, _ := RawSyscall(SYS_GETEUID32, 0, 0, 0) + euid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID32, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID32, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyInit() (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ioperm(from int, num int, on int) (err error) { + _, _, e1 := Syscall(SYS_IOPERM, uintptr(from), uintptr(num), uintptr(on)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Iopl(level int) (err error) { + _, _, e1 := Syscall(SYS_IOPL, uintptr(level), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN32, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + r0, _, e1 := Syscall6(SYS_SENDFILE64, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0) + written = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsgid(gid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSGID32, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsuid(uid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSUID32, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID32, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresgid(rgid int, egid int, sgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESGID32, uintptr(rgid), uintptr(egid), uintptr(sgid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresuid(ruid int, euid int, suid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESUID32, uintptr(ruid), uintptr(euid), uintptr(suid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID32, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) { + r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func SyncFileRange(fd int, off int64, n int64, flags int) (err error) { + _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(off>>32), uintptr(n), uintptr(n>>32), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_TRUNCATE64, uintptr(unsafe.Pointer(_p0)), uintptr(length), uintptr(length>>32)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(n int, list *_Gid_t) (nn int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS32, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + nn = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(n int, list *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS32, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { + r0, _, e1 := Syscall6(SYS__NEWSELECT, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error) { + r0, _, e1 := Syscall6(SYS_MMAP2, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(pageOffset)) + xaddr = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { + var _p0 unsafe.Pointer + if len(events) > 0 { + _p0 = unsafe.Pointer(&events[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pause() (err error) { + _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getrlimit(resource int, rlim *rlimit32) (err error) { + _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setrlimit(resource int, rlim *rlimit32) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Time(t *Time_t) (tt Time_t, err error) { + r0, _, e1 := RawSyscall(SYS_TIME, uintptr(unsafe.Pointer(t)), 0, 0) + tt = Time_t(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Utime(path string, buf *Utimbuf) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go new file mode 100644 index 0000000000..1096aa5443 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go @@ -0,0 +1,1832 @@ +// mksyscall.pl syscall_linux.go syscall_linux_amd64.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build amd64,linux + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, times *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getcwd(buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETCWD, uintptr(_p0), uintptr(len(buf)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(arg) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(source) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(target) + if err != nil { + return + } + var _p2 *byte + _p2, err = BytePtrFromString(fstype) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(flags), uintptr(unsafe.Pointer(data)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + use(unsafe.Pointer(_p2)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Acct(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtimex(buf *Timex) (state int, err error) { + r0, _, e1 := Syscall(SYS_ADJTIMEX, uintptr(unsafe.Pointer(buf)), 0, 0) + state = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ClockGettime(clockid int32, time *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(oldfd int) (fd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup3(oldfd int, newfd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate(size int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate1(flag int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE1, uintptr(flag), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) { + _, _, e1 := RawSyscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fallocate(fd int, mode uint32, off int64, len int64) (err error) { + _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(len), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fdatasync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdents(fd int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettid() (tid int) { + r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0) + tid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getxattr(path string, attr string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(dest) > 0 { + _p2 = unsafe.Pointer(&dest[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(pathname) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(mask)) + use(unsafe.Pointer(_p0)) + watchdesc = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyInit1(flags int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0) + success = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Klogctl(typ int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listxattr(path string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(dest) > 0 { + _p1 = unsafe.Pointer(&dest[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest))) + use(unsafe.Pointer(_p0)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdirat(dirfd int, path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func PivotRoot(newroot string, putold string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(newroot) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(putold) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_PIVOT_ROOT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { + _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(newlimit)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Removexattr(path string, attr string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setdomainname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETDOMAINNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sethostname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETHOSTNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setns(fd int, nstype int) (err error) { + _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setxattr(path string, attr string, data []byte, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(data) > 0 { + _p2 = unsafe.Pointer(&data[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() { + Syscall(SYS_SYNC, 0, 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sysinfo(info *Sysinfo_t) (err error) { + _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Times(tms *Tms) (ticks uintptr, err error) { + r0, _, e1 := RawSyscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0) + ticks = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(mask int) (oldmask int) { + r0, _, _ := RawSyscall(SYS_UMASK, uintptr(mask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Uname(buf *Utsname) (err error) { + _, _, e1 := RawSyscall(SYS_UNAME, uintptr(unsafe.Pointer(buf)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(target string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(target) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unshare(flags int) (err error) { + _, _, e1 := Syscall(SYS_UNSHARE, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ustat(dev int, ubuf *Ustat_t) (err error) { + _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func exitThread(code int) (err error) { + _, _, e1 := Syscall(SYS_EXIT, uintptr(code), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Madvise(b []byte, advice int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(oldfd int, newfd int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { + var _p0 unsafe.Pointer + if len(events) > 0 { + _p0 = unsafe.Pointer(&events[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fadvise(fd int, offset int64, length int64, advice int) (err error) { + _, _, e1 := Syscall6(SYS_FADVISE64, uintptr(fd), uintptr(offset), uintptr(length), uintptr(advice), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, buf *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (euid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + euid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyInit() (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ioperm(from int, num int, on int) (err error) { + _, _, e1 := Syscall(SYS_IOPERM, uintptr(from), uintptr(num), uintptr(on)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Iopl(level int) (err error) { + _, _, e1 := Syscall(SYS_IOPL, uintptr(level), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, n int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pause() (err error) { + _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (off int64, err error) { + r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence)) + off = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { + r0, _, e1 := Syscall6(SYS_SELECT, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0) + written = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsgid(gid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsuid(uid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresgid(rgid int, egid int, sgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresuid(ruid int, euid int, suid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, buf *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func SyncFileRange(fd int, off int64, n int64, flags int) (err error) { + _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { + r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(n int, list *_Gid_t) (nn int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + nn = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(n int, list *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { + r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset)) + xaddr = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Utime(path string, buf *Utimbuf) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe(p *[2]_C_int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go new file mode 100644 index 0000000000..9066e1cb77 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go @@ -0,0 +1,1739 @@ +// mksyscall.pl -l32 -arm syscall_linux.go syscall_linux_arm.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build arm,linux + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, times *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getcwd(buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETCWD, uintptr(_p0), uintptr(len(buf)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(arg) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(source) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(target) + if err != nil { + return + } + var _p2 *byte + _p2, err = BytePtrFromString(fstype) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(flags), uintptr(unsafe.Pointer(data)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + use(unsafe.Pointer(_p2)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Acct(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtimex(buf *Timex) (state int, err error) { + r0, _, e1 := Syscall(SYS_ADJTIMEX, uintptr(unsafe.Pointer(buf)), 0, 0) + state = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ClockGettime(clockid int32, time *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(oldfd int) (fd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup3(oldfd int, newfd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate(size int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate1(flag int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE1, uintptr(flag), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) { + _, _, e1 := RawSyscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fallocate(fd int, mode uint32, off int64, len int64) (err error) { + _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(off>>32), uintptr(len), uintptr(len>>32)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fdatasync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdents(fd int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettid() (tid int) { + r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0) + tid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getxattr(path string, attr string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(dest) > 0 { + _p2 = unsafe.Pointer(&dest[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(pathname) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(mask)) + use(unsafe.Pointer(_p0)) + watchdesc = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyInit1(flags int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0) + success = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Klogctl(typ int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listxattr(path string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(dest) > 0 { + _p1 = unsafe.Pointer(&dest[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest))) + use(unsafe.Pointer(_p0)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdirat(dirfd int, path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func PivotRoot(newroot string, putold string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(newroot) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(putold) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_PIVOT_ROOT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { + _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(newlimit)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Removexattr(path string, attr string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setdomainname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETDOMAINNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sethostname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETHOSTNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setns(fd int, nstype int) (err error) { + _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setxattr(path string, attr string, data []byte, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(data) > 0 { + _p2 = unsafe.Pointer(&data[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() { + Syscall(SYS_SYNC, 0, 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sysinfo(info *Sysinfo_t) (err error) { + _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { + r0, r1, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0) + n = int64(int64(r1)<<32 | int64(r0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Times(tms *Tms) (ticks uintptr, err error) { + r0, _, e1 := RawSyscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0) + ticks = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(mask int) (oldmask int) { + r0, _, _ := RawSyscall(SYS_UMASK, uintptr(mask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Uname(buf *Utsname) (err error) { + _, _, e1 := RawSyscall(SYS_UNAME, uintptr(unsafe.Pointer(buf)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(target string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(target) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unshare(flags int) (err error) { + _, _, e1 := Syscall(SYS_UNSHARE, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ustat(dev int, ubuf *Ustat_t) (err error) { + _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func exitThread(code int) (err error) { + _, _, e1 := Syscall(SYS_EXIT, uintptr(code), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Madvise(b []byte, advice int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { + r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(n int, list *_Gid_t) (nn int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS32, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + nn = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(n int, list *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS32, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, flags int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(flags), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(oldfd int, newfd int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN32, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID32, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (euid int) { + r0, _, _ := RawSyscall(SYS_GETEUID32, 0, 0, 0) + euid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID32, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID32, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyInit() (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN32, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, n int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + r0, _, e1 := Syscall6(SYS_SENDFILE64, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0) + written = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { + r0, _, e1 := Syscall6(SYS__NEWSELECT, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsgid(gid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSGID32, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsuid(uid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSUID32, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID32, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresgid(rgid int, egid int, sgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESGID32, uintptr(rgid), uintptr(egid), uintptr(sgid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresuid(ruid int, euid int, suid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESUID32, uintptr(ruid), uintptr(euid), uintptr(suid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID32, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) { + r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { + var _p0 unsafe.Pointer + if len(events) > 0 { + _p0 = unsafe.Pointer(&events[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pause() (err error) { + _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_TRUNCATE64, uintptr(unsafe.Pointer(_p0)), 0, uintptr(length), uintptr(length>>32), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall6(SYS_FTRUNCATE64, uintptr(fd), 0, uintptr(length), uintptr(length>>32), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error) { + r0, _, e1 := Syscall6(SYS_MMAP2, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(pageOffset)) + xaddr = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getrlimit(resource int, rlim *rlimit32) (err error) { + _, _, e1 := RawSyscall(SYS_UGETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setrlimit(resource int, rlim *rlimit32) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go new file mode 100644 index 0000000000..5b91612265 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go @@ -0,0 +1,1723 @@ +// mksyscall.pl syscall_linux.go syscall_linux_arm64.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build arm64,linux + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, times *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getcwd(buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETCWD, uintptr(_p0), uintptr(len(buf)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(arg) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(source) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(target) + if err != nil { + return + } + var _p2 *byte + _p2, err = BytePtrFromString(fstype) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(flags), uintptr(unsafe.Pointer(data)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + use(unsafe.Pointer(_p2)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Acct(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtimex(buf *Timex) (state int, err error) { + r0, _, e1 := Syscall(SYS_ADJTIMEX, uintptr(unsafe.Pointer(buf)), 0, 0) + state = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ClockGettime(clockid int32, time *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(oldfd int) (fd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup3(oldfd int, newfd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate(size int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate1(flag int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE1, uintptr(flag), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) { + _, _, e1 := RawSyscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fallocate(fd int, mode uint32, off int64, len int64) (err error) { + _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(len), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fdatasync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdents(fd int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettid() (tid int) { + r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0) + tid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getxattr(path string, attr string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(dest) > 0 { + _p2 = unsafe.Pointer(&dest[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(pathname) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(mask)) + use(unsafe.Pointer(_p0)) + watchdesc = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyInit1(flags int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0) + success = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Klogctl(typ int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listxattr(path string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(dest) > 0 { + _p1 = unsafe.Pointer(&dest[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest))) + use(unsafe.Pointer(_p0)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdirat(dirfd int, path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func PivotRoot(newroot string, putold string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(newroot) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(putold) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_PIVOT_ROOT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { + _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(newlimit)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Removexattr(path string, attr string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setdomainname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETDOMAINNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sethostname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETHOSTNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setns(fd int, nstype int) (err error) { + _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setxattr(path string, attr string, data []byte, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(data) > 0 { + _p2 = unsafe.Pointer(&data[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() { + Syscall(SYS_SYNC, 0, 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sysinfo(info *Sysinfo_t) (err error) { + _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Times(tms *Tms) (ticks uintptr, err error) { + r0, _, e1 := RawSyscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0) + ticks = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(mask int) (oldmask int) { + r0, _, _ := RawSyscall(SYS_UMASK, uintptr(mask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Uname(buf *Utsname) (err error) { + _, _, e1 := RawSyscall(SYS_UNAME, uintptr(unsafe.Pointer(buf)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(target string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(target) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unshare(flags int) (err error) { + _, _, e1 := Syscall(SYS_UNSHARE, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ustat(dev int, ubuf *Ustat_t) (err error) { + _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func exitThread(code int) (err error) { + _, _, e1 := Syscall(SYS_EXIT, uintptr(code), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Madvise(b []byte, advice int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { + var _p0 unsafe.Pointer + if len(events) > 0 { + _p0 = unsafe.Pointer(&events[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_EPOLL_PWAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FSTATAT, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, buf *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (euid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + euid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, n int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (off int64, err error) { + r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence)) + off = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { + r0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0) + written = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsgid(gid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsuid(uid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresgid(rgid int, egid int, sgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresuid(ruid int, euid int, suid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, buf *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func SyncFileRange(fd int, off int64, n int64, flags int) (err error) { + _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { + r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(n int, list *_Gid_t) (nn int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + nn = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(n int, list *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { + r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset)) + xaddr = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go new file mode 100644 index 0000000000..738c830914 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go @@ -0,0 +1,1781 @@ +// mksyscall.pl syscall_linux.go syscall_linux_mips64x.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build mips64,linux + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, times *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getcwd(buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETCWD, uintptr(_p0), uintptr(len(buf)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(arg) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(source) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(target) + if err != nil { + return + } + var _p2 *byte + _p2, err = BytePtrFromString(fstype) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(flags), uintptr(unsafe.Pointer(data)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + use(unsafe.Pointer(_p2)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Acct(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtimex(buf *Timex) (state int, err error) { + r0, _, e1 := Syscall(SYS_ADJTIMEX, uintptr(unsafe.Pointer(buf)), 0, 0) + state = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ClockGettime(clockid int32, time *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(oldfd int) (fd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup3(oldfd int, newfd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate(size int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate1(flag int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE1, uintptr(flag), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) { + _, _, e1 := RawSyscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fallocate(fd int, mode uint32, off int64, len int64) (err error) { + _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(len), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fdatasync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdents(fd int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettid() (tid int) { + r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0) + tid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getxattr(path string, attr string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(dest) > 0 { + _p2 = unsafe.Pointer(&dest[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(pathname) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(mask)) + use(unsafe.Pointer(_p0)) + watchdesc = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyInit1(flags int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0) + success = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Klogctl(typ int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listxattr(path string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(dest) > 0 { + _p1 = unsafe.Pointer(&dest[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest))) + use(unsafe.Pointer(_p0)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdirat(dirfd int, path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func PivotRoot(newroot string, putold string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(newroot) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(putold) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_PIVOT_ROOT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { + _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(newlimit)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Removexattr(path string, attr string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setdomainname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETDOMAINNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sethostname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETHOSTNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setns(fd int, nstype int) (err error) { + _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setxattr(path string, attr string, data []byte, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(data) > 0 { + _p2 = unsafe.Pointer(&data[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() { + Syscall(SYS_SYNC, 0, 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sysinfo(info *Sysinfo_t) (err error) { + _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Times(tms *Tms) (ticks uintptr, err error) { + r0, _, e1 := RawSyscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0) + ticks = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(mask int) (oldmask int) { + r0, _, _ := RawSyscall(SYS_UMASK, uintptr(mask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Uname(buf *Utsname) (err error) { + _, _, e1 := RawSyscall(SYS_UNAME, uintptr(unsafe.Pointer(buf)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(target string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(target) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unshare(flags int) (err error) { + _, _, e1 := Syscall(SYS_UNSHARE, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ustat(dev int, ubuf *Ustat_t) (err error) { + _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func exitThread(code int) (err error) { + _, _, e1 := Syscall(SYS_EXIT, uintptr(code), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Madvise(b []byte, advice int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { + var _p0 unsafe.Pointer + if len(events) > 0 { + _p0 = unsafe.Pointer(&events[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, buf *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (euid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + euid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, n int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pause() (err error) { + _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (off int64, err error) { + r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence)) + off = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { + r0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0) + written = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsgid(gid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsuid(uid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresgid(rgid int, egid int, sgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresuid(ruid int, euid int, suid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, buf *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func SyncFileRange(fd int, off int64, n int64, flags int) (err error) { + _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { + r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(n int, list *_Gid_t) (nn int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + nn = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(n int, list *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { + r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset)) + xaddr = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Utime(path string, buf *Utimbuf) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fstat(fd int, st *stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(st)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func lstat(path string, st *stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(st)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func stat(path string, st *stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(st)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go new file mode 100644 index 0000000000..2a03578322 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go @@ -0,0 +1,1781 @@ +// mksyscall.pl syscall_linux.go syscall_linux_mips64x.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build mips64le,linux + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, times *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getcwd(buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETCWD, uintptr(_p0), uintptr(len(buf)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(arg) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(source) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(target) + if err != nil { + return + } + var _p2 *byte + _p2, err = BytePtrFromString(fstype) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(flags), uintptr(unsafe.Pointer(data)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + use(unsafe.Pointer(_p2)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Acct(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtimex(buf *Timex) (state int, err error) { + r0, _, e1 := Syscall(SYS_ADJTIMEX, uintptr(unsafe.Pointer(buf)), 0, 0) + state = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ClockGettime(clockid int32, time *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(oldfd int) (fd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup3(oldfd int, newfd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate(size int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate1(flag int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE1, uintptr(flag), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) { + _, _, e1 := RawSyscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fallocate(fd int, mode uint32, off int64, len int64) (err error) { + _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(len), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fdatasync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdents(fd int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettid() (tid int) { + r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0) + tid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getxattr(path string, attr string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(dest) > 0 { + _p2 = unsafe.Pointer(&dest[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(pathname) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(mask)) + use(unsafe.Pointer(_p0)) + watchdesc = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyInit1(flags int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0) + success = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Klogctl(typ int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listxattr(path string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(dest) > 0 { + _p1 = unsafe.Pointer(&dest[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest))) + use(unsafe.Pointer(_p0)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdirat(dirfd int, path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func PivotRoot(newroot string, putold string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(newroot) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(putold) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_PIVOT_ROOT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { + _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(newlimit)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Removexattr(path string, attr string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setdomainname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETDOMAINNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sethostname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETHOSTNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setns(fd int, nstype int) (err error) { + _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setxattr(path string, attr string, data []byte, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(data) > 0 { + _p2 = unsafe.Pointer(&data[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() { + Syscall(SYS_SYNC, 0, 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sysinfo(info *Sysinfo_t) (err error) { + _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Times(tms *Tms) (ticks uintptr, err error) { + r0, _, e1 := RawSyscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0) + ticks = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(mask int) (oldmask int) { + r0, _, _ := RawSyscall(SYS_UMASK, uintptr(mask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Uname(buf *Utsname) (err error) { + _, _, e1 := RawSyscall(SYS_UNAME, uintptr(unsafe.Pointer(buf)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(target string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(target) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unshare(flags int) (err error) { + _, _, e1 := Syscall(SYS_UNSHARE, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ustat(dev int, ubuf *Ustat_t) (err error) { + _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func exitThread(code int) (err error) { + _, _, e1 := Syscall(SYS_EXIT, uintptr(code), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Madvise(b []byte, advice int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { + var _p0 unsafe.Pointer + if len(events) > 0 { + _p0 = unsafe.Pointer(&events[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, buf *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (euid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + euid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, n int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pause() (err error) { + _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (off int64, err error) { + r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence)) + off = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { + r0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0) + written = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsgid(gid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsuid(uid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresgid(rgid int, egid int, sgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresuid(ruid int, euid int, suid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, buf *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func SyncFileRange(fd int, off int64, n int64, flags int) (err error) { + _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { + r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(n int, list *_Gid_t) (nn int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + nn = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(n int, list *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { + r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset)) + xaddr = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Utime(path string, buf *Utimbuf) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fstat(fd int, st *stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(st)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func lstat(path string, st *stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(st)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func stat(path string, st *stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(st)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go new file mode 100644 index 0000000000..4bd18dcee6 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go @@ -0,0 +1,1843 @@ +// mksyscall.pl syscall_linux.go syscall_linux_ppc64x.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build ppc64,linux + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, times *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getcwd(buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETCWD, uintptr(_p0), uintptr(len(buf)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(arg) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(source) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(target) + if err != nil { + return + } + var _p2 *byte + _p2, err = BytePtrFromString(fstype) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(flags), uintptr(unsafe.Pointer(data)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + use(unsafe.Pointer(_p2)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Acct(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtimex(buf *Timex) (state int, err error) { + r0, _, e1 := Syscall(SYS_ADJTIMEX, uintptr(unsafe.Pointer(buf)), 0, 0) + state = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ClockGettime(clockid int32, time *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(oldfd int) (fd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup3(oldfd int, newfd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate(size int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate1(flag int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE1, uintptr(flag), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) { + _, _, e1 := RawSyscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fallocate(fd int, mode uint32, off int64, len int64) (err error) { + _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(len), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fdatasync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdents(fd int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettid() (tid int) { + r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0) + tid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getxattr(path string, attr string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(dest) > 0 { + _p2 = unsafe.Pointer(&dest[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(pathname) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(mask)) + use(unsafe.Pointer(_p0)) + watchdesc = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyInit1(flags int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0) + success = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Klogctl(typ int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listxattr(path string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(dest) > 0 { + _p1 = unsafe.Pointer(&dest[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest))) + use(unsafe.Pointer(_p0)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdirat(dirfd int, path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func PivotRoot(newroot string, putold string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(newroot) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(putold) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_PIVOT_ROOT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { + _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(newlimit)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Removexattr(path string, attr string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setdomainname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETDOMAINNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sethostname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETHOSTNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setns(fd int, nstype int) (err error) { + _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setxattr(path string, attr string, data []byte, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(data) > 0 { + _p2 = unsafe.Pointer(&data[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() { + Syscall(SYS_SYNC, 0, 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sysinfo(info *Sysinfo_t) (err error) { + _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Times(tms *Tms) (ticks uintptr, err error) { + r0, _, e1 := RawSyscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0) + ticks = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(mask int) (oldmask int) { + r0, _, _ := RawSyscall(SYS_UMASK, uintptr(mask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Uname(buf *Utsname) (err error) { + _, _, e1 := RawSyscall(SYS_UNAME, uintptr(unsafe.Pointer(buf)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(target string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(target) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unshare(flags int) (err error) { + _, _, e1 := Syscall(SYS_UNSHARE, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ustat(dev int, ubuf *Ustat_t) (err error) { + _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func exitThread(code int) (err error) { + _, _, e1 := Syscall(SYS_EXIT, uintptr(code), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Madvise(b []byte, advice int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { + var _p0 unsafe.Pointer + if len(events) > 0 { + _p0 = unsafe.Pointer(&events[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(oldfd int, newfd int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, buf *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (euid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + euid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_UGETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyInit() (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ioperm(from int, num int, on int) (err error) { + _, _, e1 := Syscall(SYS_IOPERM, uintptr(from), uintptr(num), uintptr(on)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Iopl(level int) (err error) { + _, _, e1 := Syscall(SYS_IOPL, uintptr(level), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, n int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pause() (err error) { + _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (off int64, err error) { + r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence)) + off = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { + r0, _, e1 := Syscall6(SYS_SELECT, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0) + written = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsgid(gid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsuid(uid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresgid(rgid int, egid int, sgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresuid(ruid int, euid int, suid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, buf *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func SyncFileRange(fd int, off int64, n int64, flags int) (err error) { + _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE2, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { + r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(n int, list *_Gid_t) (nn int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + nn = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(n int, list *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { + r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset)) + xaddr = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Time(t *Time_t) (tt Time_t, err error) { + r0, _, e1 := RawSyscall(SYS_TIME, uintptr(unsafe.Pointer(t)), 0, 0) + tt = Time_t(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Utime(path string, buf *Utimbuf) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe(p *[2]_C_int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go new file mode 100644 index 0000000000..fbb43516cc --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go @@ -0,0 +1,1843 @@ +// mksyscall.pl syscall_linux.go syscall_linux_ppc64x.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build ppc64le,linux + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, times *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getcwd(buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETCWD, uintptr(_p0), uintptr(len(buf)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(arg) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(source) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(target) + if err != nil { + return + } + var _p2 *byte + _p2, err = BytePtrFromString(fstype) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(flags), uintptr(unsafe.Pointer(data)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + use(unsafe.Pointer(_p2)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Acct(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtimex(buf *Timex) (state int, err error) { + r0, _, e1 := Syscall(SYS_ADJTIMEX, uintptr(unsafe.Pointer(buf)), 0, 0) + state = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ClockGettime(clockid int32, time *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(oldfd int) (fd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup3(oldfd int, newfd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate(size int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate1(flag int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE1, uintptr(flag), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) { + _, _, e1 := RawSyscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fallocate(fd int, mode uint32, off int64, len int64) (err error) { + _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(len), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fdatasync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdents(fd int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettid() (tid int) { + r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0) + tid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getxattr(path string, attr string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(dest) > 0 { + _p2 = unsafe.Pointer(&dest[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(pathname) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(mask)) + use(unsafe.Pointer(_p0)) + watchdesc = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyInit1(flags int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0) + success = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Klogctl(typ int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listxattr(path string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(dest) > 0 { + _p1 = unsafe.Pointer(&dest[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest))) + use(unsafe.Pointer(_p0)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdirat(dirfd int, path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func PivotRoot(newroot string, putold string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(newroot) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(putold) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_PIVOT_ROOT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { + _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(newlimit)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Removexattr(path string, attr string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setdomainname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETDOMAINNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sethostname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETHOSTNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setns(fd int, nstype int) (err error) { + _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setxattr(path string, attr string, data []byte, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(data) > 0 { + _p2 = unsafe.Pointer(&data[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() { + Syscall(SYS_SYNC, 0, 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sysinfo(info *Sysinfo_t) (err error) { + _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Times(tms *Tms) (ticks uintptr, err error) { + r0, _, e1 := RawSyscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0) + ticks = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(mask int) (oldmask int) { + r0, _, _ := RawSyscall(SYS_UMASK, uintptr(mask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Uname(buf *Utsname) (err error) { + _, _, e1 := RawSyscall(SYS_UNAME, uintptr(unsafe.Pointer(buf)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(target string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(target) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unshare(flags int) (err error) { + _, _, e1 := Syscall(SYS_UNSHARE, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ustat(dev int, ubuf *Ustat_t) (err error) { + _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func exitThread(code int) (err error) { + _, _, e1 := Syscall(SYS_EXIT, uintptr(code), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Madvise(b []byte, advice int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { + var _p0 unsafe.Pointer + if len(events) > 0 { + _p0 = unsafe.Pointer(&events[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(oldfd int, newfd int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, buf *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (euid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + euid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_UGETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyInit() (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ioperm(from int, num int, on int) (err error) { + _, _, e1 := Syscall(SYS_IOPERM, uintptr(from), uintptr(num), uintptr(on)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Iopl(level int) (err error) { + _, _, e1 := Syscall(SYS_IOPL, uintptr(level), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, n int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pause() (err error) { + _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (off int64, err error) { + r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence)) + off = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { + r0, _, e1 := Syscall6(SYS_SELECT, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0) + written = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsgid(gid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsuid(uid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresgid(rgid int, egid int, sgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresuid(ruid int, euid int, suid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, buf *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func SyncFileRange(fd int, off int64, n int64, flags int) (err error) { + _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE2, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { + r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(n int, list *_Gid_t) (nn int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + nn = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(n int, list *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { + r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset)) + xaddr = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Time(t *Time_t) (tt Time_t, err error) { + r0, _, e1 := RawSyscall(SYS_TIME, uintptr(unsafe.Pointer(t)), 0, 0) + tt = Time_t(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Utime(path string, buf *Utimbuf) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe(p *[2]_C_int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go new file mode 100644 index 0000000000..f8aa91f149 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go @@ -0,0 +1,1623 @@ +// mksyscall.pl syscall_linux.go syscall_linux_s390x.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build s390x,linux + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, times *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimesat(dirfd int, path *byte, times *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getcwd(buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETCWD, uintptr(_p0), uintptr(len(buf)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(arg) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(source) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(target) + if err != nil { + return + } + var _p2 *byte + _p2, err = BytePtrFromString(fstype) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(flags), uintptr(unsafe.Pointer(data)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + use(unsafe.Pointer(_p2)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Acct(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtimex(buf *Timex) (state int, err error) { + r0, _, e1 := Syscall(SYS_ADJTIMEX, uintptr(unsafe.Pointer(buf)), 0, 0) + state = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ClockGettime(clockid int32, time *Timespec) (err error) { + _, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(oldfd int) (fd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup3(oldfd int, newfd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate(size int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCreate1(flag int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE1, uintptr(flag), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) { + _, _, e1 := RawSyscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT_GROUP, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fallocate(fd int, mode uint32, off int64, len int64) (err error) { + _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(len), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fdatasync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdents(fd int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettid() (tid int) { + r0, _, _ := RawSyscall(SYS_GETTID, 0, 0, 0) + tid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getxattr(path string, attr string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(dest) > 0 { + _p2 = unsafe.Pointer(&dest[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(pathname) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(mask)) + use(unsafe.Pointer(_p0)) + watchdesc = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyInit1(flags int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0) + success = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Klogctl(typ int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listxattr(path string, dest []byte) (sz int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(dest) > 0 { + _p1 = unsafe.Pointer(&dest[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest))) + use(unsafe.Pointer(_p0)) + sz = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdirat(dirfd int, path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func PivotRoot(newroot string, putold string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(newroot) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(putold) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_PIVOT_ROOT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func prlimit(pid int, resource int, old *Rlimit, newlimit *Rlimit) (err error) { + _, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(newlimit)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) { + _, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Removexattr(path string, attr string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setdomainname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETDOMAINNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sethostname(p []byte) (err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_SETHOSTNAME, uintptr(_p0), uintptr(len(p)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setns(fd int, nstype int) (err error) { + _, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setxattr(path string, attr string, data []byte, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(attr) + if err != nil { + return + } + var _p2 unsafe.Pointer + if len(data) > 0 { + _p2 = unsafe.Pointer(&data[0]) + } else { + _p2 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() { + Syscall(SYS_SYNC, 0, 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sysinfo(info *Sysinfo_t) (err error) { + _, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) { + _, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Times(tms *Tms) (ticks uintptr, err error) { + r0, _, e1 := RawSyscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0) + ticks = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(mask int) (oldmask int) { + r0, _, _ := RawSyscall(SYS_UMASK, uintptr(mask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Uname(buf *Utsname) (err error) { + _, _, e1 := RawSyscall(SYS_UNAME, uintptr(unsafe.Pointer(buf)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(target string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(target) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unshare(flags int) (err error) { + _, _, e1 := Syscall(SYS_UNSHARE, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ustat(dev int, ubuf *Ustat_t) (err error) { + _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func exitThread(code int) (err error) { + _, _, e1 := Syscall(SYS_EXIT, uintptr(code), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, p *byte, np int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Madvise(b []byte, advice int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(oldfd int, newfd int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { + var _p0 unsafe.Pointer + if len(events) > 0 { + _p0 = unsafe.Pointer(&events[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fadvise(fd int, offset int64, length int64, advice int) (err error) { + _, _, e1 := Syscall6(SYS_FADVISE64, uintptr(fd), uintptr(offset), uintptr(length), uintptr(advice), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, buf *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (euid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + euid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func InotifyInit() (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pause() (err error) { + _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (off int64, err error) { + r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence)) + off = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { + r0, _, e1 := Syscall6(SYS_SELECT, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0) + written = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsgid(gid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setfsuid(uid int) (err error) { + _, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresgid(rgid int, egid int, sgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresuid(ruid int, euid int, suid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(resource int, rlim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) { + r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) + n = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, buf *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func SyncFileRange(fd int, off int64, n int64, flags int) (err error) { + _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(n int, list *_Gid_t) (nn int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + nn = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(n int, list *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Utime(path string, buf *Utimbuf) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go new file mode 100644 index 0000000000..b16e1d0ee3 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go @@ -0,0 +1,1327 @@ +// mksyscall.pl -l32 -netbsd syscall_bsd.go syscall_netbsd.go syscall_netbsd_386.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build 386,netbsd + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(ngid int, gid *_Gid_t) (n int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(ngid int, gid *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(s int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) { + r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { + var _p0 unsafe.Pointer + if len(mib) > 0 { + _p0 = unsafe.Pointer(&mib[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + use(_p0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, timeval *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimes(fd int, timeval *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe() (fd1 int, fd2 int, err error) { + r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) + fd1 = int(r0) + fd2 = int(r1) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getdents(fd int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETDENTS, uintptr(fd), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Access(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { + _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chflags(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chmod(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(fd int) (nfd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0) + nfd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(from int, to int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchflags(fd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fpathconf(fd int, name int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall6(SYS_FTRUNCATE, uintptr(fd), 0, uintptr(length), uintptr(length>>32), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgrp() (pgrp int) { + r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0) + pgrp = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Issetugid() (tainted bool) { + r0, _, _ := Syscall(SYS_ISSETUGID, 0, 0, 0) + tainted = bool(r0 != 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, signum syscall.Signal) (err error) { + _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kqueue() (fd int, err error) { + r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Link(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, backlog int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdir(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkfifo(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknod(path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Open(path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pathconf(path string, name int) (val int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0) + use(unsafe.Pointer(_p0)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Readlink(path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf))) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rename(from string, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Revoke(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rmdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { + r0, r1, e1 := Syscall6(SYS_LSEEK, uintptr(fd), 0, uintptr(offset), uintptr(offset>>32), uintptr(whence), 0) + newoffset = int64(int64(r1)<<32 | int64(r0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) { + _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setegid(egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETEGID, uintptr(egid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seteuid(euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setgid(gid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tp *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setuid(uid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Symlink(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() (err error) { + _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), 0, uintptr(length), uintptr(length>>32), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(newmask int) (oldmask int) { + r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unlink(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { + r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), 0, uintptr(pos), uintptr(pos>>32), 0) + ret = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go new file mode 100644 index 0000000000..b63667da9c --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go @@ -0,0 +1,1327 @@ +// mksyscall.pl -netbsd syscall_bsd.go syscall_netbsd.go syscall_netbsd_amd64.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build amd64,netbsd + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(ngid int, gid *_Gid_t) (n int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(ngid int, gid *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(s int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) { + r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { + var _p0 unsafe.Pointer + if len(mib) > 0 { + _p0 = unsafe.Pointer(&mib[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + use(_p0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, timeval *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimes(fd int, timeval *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe() (fd1 int, fd2 int, err error) { + r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) + fd1 = int(r0) + fd2 = int(r1) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getdents(fd int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETDENTS, uintptr(fd), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Access(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { + _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chflags(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chmod(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(fd int) (nfd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0) + nfd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(from int, to int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchflags(fd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fpathconf(fd int, name int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), 0, uintptr(length)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgrp() (pgrp int) { + r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0) + pgrp = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Issetugid() (tainted bool) { + r0, _, _ := Syscall(SYS_ISSETUGID, 0, 0, 0) + tainted = bool(r0 != 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, signum syscall.Signal) (err error) { + _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kqueue() (fd int, err error) { + r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Link(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, backlog int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdir(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkfifo(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknod(path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Open(path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pathconf(path string, name int) (val int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0) + use(unsafe.Pointer(_p0)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Readlink(path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf))) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rename(from string, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Revoke(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rmdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { + r0, _, e1 := Syscall6(SYS_LSEEK, uintptr(fd), 0, uintptr(offset), uintptr(whence), 0, 0) + newoffset = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) { + _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setegid(egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETEGID, uintptr(egid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seteuid(euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setgid(gid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tp *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setuid(uid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Symlink(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() (err error) { + _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), 0, uintptr(length)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(newmask int) (oldmask int) { + r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unlink(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { + r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), 0, uintptr(pos), 0, 0) + ret = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go new file mode 100644 index 0000000000..b0d19038d2 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go @@ -0,0 +1,1327 @@ +// mksyscall.pl -l32 -arm syscall_bsd.go syscall_netbsd.go syscall_netbsd_arm.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build arm,netbsd + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(ngid int, gid *_Gid_t) (n int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(ngid int, gid *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(s int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) { + r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { + var _p0 unsafe.Pointer + if len(mib) > 0 { + _p0 = unsafe.Pointer(&mib[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + use(_p0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, timeval *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimes(fd int, timeval *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe() (fd1 int, fd2 int, err error) { + r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) + fd1 = int(r0) + fd2 = int(r1) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getdents(fd int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETDENTS, uintptr(fd), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Access(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { + _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chflags(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chmod(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(fd int) (nfd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0) + nfd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(from int, to int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchflags(fd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fpathconf(fd int, name int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall6(SYS_FTRUNCATE, uintptr(fd), 0, uintptr(length), uintptr(length>>32), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgrp() (pgrp int) { + r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0) + pgrp = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Issetugid() (tainted bool) { + r0, _, _ := Syscall(SYS_ISSETUGID, 0, 0, 0) + tainted = bool(r0 != 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, signum syscall.Signal) (err error) { + _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kqueue() (fd int, err error) { + r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Link(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, backlog int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdir(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkfifo(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknod(path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Open(path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pathconf(path string, name int) (val int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0) + use(unsafe.Pointer(_p0)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Readlink(path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf))) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rename(from string, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Revoke(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rmdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { + r0, r1, e1 := Syscall6(SYS_LSEEK, uintptr(fd), 0, uintptr(offset), uintptr(offset>>32), uintptr(whence), 0) + newoffset = int64(int64(r1)<<32 | int64(r0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) { + _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setegid(egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETEGID, uintptr(egid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seteuid(euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setgid(gid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tp *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setuid(uid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Symlink(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() (err error) { + _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), 0, uintptr(length), uintptr(length>>32), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(newmask int) (oldmask int) { + r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unlink(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { + r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), 0, uintptr(pos), uintptr(pos>>32), 0) + ret = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go new file mode 100644 index 0000000000..f91a5b8564 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go @@ -0,0 +1,1387 @@ +// mksyscall.pl -l32 -openbsd syscall_bsd.go syscall_openbsd.go syscall_openbsd_386.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build 386,openbsd + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(ngid int, gid *_Gid_t) (n int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(ngid int, gid *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(s int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) { + r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { + var _p0 unsafe.Pointer + if len(mib) > 0 { + _p0 = unsafe.Pointer(&mib[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + use(_p0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, timeval *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimes(fd int, timeval *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe(p *[2]_C_int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getdents(fd int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETDENTS, uintptr(fd), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Access(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { + _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chflags(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chmod(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(fd int) (nfd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0) + nfd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(from int, to int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchflags(fd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fpathconf(fd int, name int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, stat *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall6(SYS_FTRUNCATE, uintptr(fd), 0, uintptr(length), uintptr(length>>32), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgrp() (pgrp int) { + r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0) + pgrp = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Issetugid() (tainted bool) { + r0, _, _ := Syscall(SYS_ISSETUGID, 0, 0, 0) + tainted = bool(r0 != 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, signum syscall.Signal) (err error) { + _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kqueue() (fd int, err error) { + r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Link(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, backlog int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdir(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkfifo(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknod(path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Open(path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pathconf(path string, name int) (val int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0) + use(unsafe.Pointer(_p0)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Readlink(path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf))) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rename(from string, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Revoke(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rmdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { + r0, r1, e1 := Syscall6(SYS_LSEEK, uintptr(fd), 0, uintptr(offset), uintptr(offset>>32), uintptr(whence), 0) + newoffset = int64(int64(r1)<<32 | int64(r0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) { + _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setegid(egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETEGID, uintptr(egid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seteuid(euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setgid(gid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setlogin(name string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(name) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresgid(rgid int, egid int, sgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresuid(ruid int, euid int, suid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tp *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setuid(uid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, stat *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Symlink(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() (err error) { + _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall6(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), 0, uintptr(length), uintptr(length>>32), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(newmask int) (oldmask int) { + r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unlink(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { + r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), 0, uintptr(pos), uintptr(pos>>32), 0) + ret = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go new file mode 100644 index 0000000000..2e8d59d724 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go @@ -0,0 +1,1387 @@ +// mksyscall.pl -openbsd syscall_bsd.go syscall_openbsd.go syscall_openbsd_amd64.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build amd64,openbsd + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(ngid int, gid *_Gid_t) (n int, err error) { + r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(ngid int, gid *_Gid_t) (err error) { + _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(s int, how int) (err error) { + _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) { + r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { + var _p0 unsafe.Pointer + if len(mib) > 0 { + _p0 = unsafe.Pointer(&mib[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + use(_p0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, timeval *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimes(fd int, timeval *[2]Timeval) (err error) { + _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe(p *[2]_C_int) (err error) { + _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getdents(fd int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_GETDENTS, uintptr(fd), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Access(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { + _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chflags(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chmod(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(fd int) (nfd int, err error) { + r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0) + nfd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(from int, to int) (err error) { + _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + Syscall(SYS_EXIT, uintptr(code), 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchflags(fd int, flags int) (err error) { + _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fpathconf(fd int, name int) (val int, err error) { + r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, stat *Statfs_t) (err error) { + _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), 0, uintptr(length)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) + egid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) + gid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgrp() (pgrp int) { + r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0) + pgrp = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) + ppid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) + uid = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Issetugid() (tainted bool) { + r0, _, _ := Syscall(SYS_ISSETUGID, 0, 0, 0) + tainted = bool(r0 != 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, signum syscall.Signal) (err error) { + _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kqueue() (fd int, err error) { + r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Link(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, backlog int) (err error) { + _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdir(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkfifo(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknod(path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Open(path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pathconf(path string, name int) (val int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0) + use(unsafe.Pointer(_p0)) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Readlink(path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf))) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rename(from string, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Revoke(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rmdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { + r0, _, e1 := Syscall6(SYS_LSEEK, uintptr(fd), 0, uintptr(offset), uintptr(whence), 0, 0) + newoffset = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) { + _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setegid(egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETEGID, uintptr(egid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seteuid(euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setgid(gid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setlogin(name string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(name) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresgid(rgid int, egid int, sgid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresuid(ruid int, euid int, suid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tp *Timeval) (err error) { + _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setuid(uid int) (err error) { + _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, stat *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Symlink(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() (err error) { + _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), 0, uintptr(length)) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(newmask int) (oldmask int) { + r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0) + oldmask = int(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unlink(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { + r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), 0, uintptr(pos), 0, 0) + ret = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go new file mode 100644 index 0000000000..4326427817 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go @@ -0,0 +1,1559 @@ +// mksyscall_solaris.pl syscall_solaris.go syscall_solaris_amd64.go +// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT + +// +build amd64,solaris + +package unix + +import ( + "syscall" + "unsafe" +) + +//go:cgo_import_dynamic libc_getsockname getsockname "libsocket.so" +//go:cgo_import_dynamic libc_getcwd getcwd "libc.so" +//go:cgo_import_dynamic libc_getgroups getgroups "libc.so" +//go:cgo_import_dynamic libc_setgroups setgroups "libc.so" +//go:cgo_import_dynamic libc_utimes utimes "libc.so" +//go:cgo_import_dynamic libc_utimensat utimensat "libc.so" +//go:cgo_import_dynamic libc_fcntl fcntl "libc.so" +//go:cgo_import_dynamic libc_futimesat futimesat "libc.so" +//go:cgo_import_dynamic libc_accept accept "libsocket.so" +//go:cgo_import_dynamic libc_recvmsg recvmsg "libsocket.so" +//go:cgo_import_dynamic libc_sendmsg sendmsg "libsocket.so" +//go:cgo_import_dynamic libc_acct acct "libc.so" +//go:cgo_import_dynamic libc_ioctl ioctl "libc.so" +//go:cgo_import_dynamic libc_access access "libc.so" +//go:cgo_import_dynamic libc_adjtime adjtime "libc.so" +//go:cgo_import_dynamic libc_chdir chdir "libc.so" +//go:cgo_import_dynamic libc_chmod chmod "libc.so" +//go:cgo_import_dynamic libc_chown chown "libc.so" +//go:cgo_import_dynamic libc_chroot chroot "libc.so" +//go:cgo_import_dynamic libc_close close "libc.so" +//go:cgo_import_dynamic libc_creat creat "libc.so" +//go:cgo_import_dynamic libc_dup dup "libc.so" +//go:cgo_import_dynamic libc_dup2 dup2 "libc.so" +//go:cgo_import_dynamic libc_exit exit "libc.so" +//go:cgo_import_dynamic libc_fchdir fchdir "libc.so" +//go:cgo_import_dynamic libc_fchmod fchmod "libc.so" +//go:cgo_import_dynamic libc_fchmodat fchmodat "libc.so" +//go:cgo_import_dynamic libc_fchown fchown "libc.so" +//go:cgo_import_dynamic libc_fchownat fchownat "libc.so" +//go:cgo_import_dynamic libc_fdatasync fdatasync "libc.so" +//go:cgo_import_dynamic libc_fpathconf fpathconf "libc.so" +//go:cgo_import_dynamic libc_fstat fstat "libc.so" +//go:cgo_import_dynamic libc_getdents getdents "libc.so" +//go:cgo_import_dynamic libc_getgid getgid "libc.so" +//go:cgo_import_dynamic libc_getpid getpid "libc.so" +//go:cgo_import_dynamic libc_getpgid getpgid "libc.so" +//go:cgo_import_dynamic libc_getpgrp getpgrp "libc.so" +//go:cgo_import_dynamic libc_geteuid geteuid "libc.so" +//go:cgo_import_dynamic libc_getegid getegid "libc.so" +//go:cgo_import_dynamic libc_getppid getppid "libc.so" +//go:cgo_import_dynamic libc_getpriority getpriority "libc.so" +//go:cgo_import_dynamic libc_getrlimit getrlimit "libc.so" +//go:cgo_import_dynamic libc_getrusage getrusage "libc.so" +//go:cgo_import_dynamic libc_gettimeofday gettimeofday "libc.so" +//go:cgo_import_dynamic libc_getuid getuid "libc.so" +//go:cgo_import_dynamic libc_kill kill "libc.so" +//go:cgo_import_dynamic libc_lchown lchown "libc.so" +//go:cgo_import_dynamic libc_link link "libc.so" +//go:cgo_import_dynamic libc_listen listen "libsocket.so" +//go:cgo_import_dynamic libc_lstat lstat "libc.so" +//go:cgo_import_dynamic libc_madvise madvise "libc.so" +//go:cgo_import_dynamic libc_mkdir mkdir "libc.so" +//go:cgo_import_dynamic libc_mkdirat mkdirat "libc.so" +//go:cgo_import_dynamic libc_mkfifo mkfifo "libc.so" +//go:cgo_import_dynamic libc_mkfifoat mkfifoat "libc.so" +//go:cgo_import_dynamic libc_mknod mknod "libc.so" +//go:cgo_import_dynamic libc_mknodat mknodat "libc.so" +//go:cgo_import_dynamic libc_mlock mlock "libc.so" +//go:cgo_import_dynamic libc_mlockall mlockall "libc.so" +//go:cgo_import_dynamic libc_mprotect mprotect "libc.so" +//go:cgo_import_dynamic libc_munlock munlock "libc.so" +//go:cgo_import_dynamic libc_munlockall munlockall "libc.so" +//go:cgo_import_dynamic libc_nanosleep nanosleep "libc.so" +//go:cgo_import_dynamic libc_open open "libc.so" +//go:cgo_import_dynamic libc_openat openat "libc.so" +//go:cgo_import_dynamic libc_pathconf pathconf "libc.so" +//go:cgo_import_dynamic libc_pause pause "libc.so" +//go:cgo_import_dynamic libc_pread pread "libc.so" +//go:cgo_import_dynamic libc_pwrite pwrite "libc.so" +//go:cgo_import_dynamic libc_read read "libc.so" +//go:cgo_import_dynamic libc_readlink readlink "libc.so" +//go:cgo_import_dynamic libc_rename rename "libc.so" +//go:cgo_import_dynamic libc_renameat renameat "libc.so" +//go:cgo_import_dynamic libc_rmdir rmdir "libc.so" +//go:cgo_import_dynamic libc_lseek lseek "libc.so" +//go:cgo_import_dynamic libc_setegid setegid "libc.so" +//go:cgo_import_dynamic libc_seteuid seteuid "libc.so" +//go:cgo_import_dynamic libc_setgid setgid "libc.so" +//go:cgo_import_dynamic libc_sethostname sethostname "libc.so" +//go:cgo_import_dynamic libc_setpgid setpgid "libc.so" +//go:cgo_import_dynamic libc_setpriority setpriority "libc.so" +//go:cgo_import_dynamic libc_setregid setregid "libc.so" +//go:cgo_import_dynamic libc_setreuid setreuid "libc.so" +//go:cgo_import_dynamic libc_setrlimit setrlimit "libc.so" +//go:cgo_import_dynamic libc_setsid setsid "libc.so" +//go:cgo_import_dynamic libc_setuid setuid "libc.so" +//go:cgo_import_dynamic libc_shutdown shutdown "libsocket.so" +//go:cgo_import_dynamic libc_stat stat "libc.so" +//go:cgo_import_dynamic libc_symlink symlink "libc.so" +//go:cgo_import_dynamic libc_sync sync "libc.so" +//go:cgo_import_dynamic libc_times times "libc.so" +//go:cgo_import_dynamic libc_truncate truncate "libc.so" +//go:cgo_import_dynamic libc_fsync fsync "libc.so" +//go:cgo_import_dynamic libc_ftruncate ftruncate "libc.so" +//go:cgo_import_dynamic libc_umask umask "libc.so" +//go:cgo_import_dynamic libc_uname uname "libc.so" +//go:cgo_import_dynamic libc_umount umount "libc.so" +//go:cgo_import_dynamic libc_unlink unlink "libc.so" +//go:cgo_import_dynamic libc_unlinkat unlinkat "libc.so" +//go:cgo_import_dynamic libc_ustat ustat "libc.so" +//go:cgo_import_dynamic libc_utime utime "libc.so" +//go:cgo_import_dynamic libc_bind bind "libsocket.so" +//go:cgo_import_dynamic libc_connect connect "libsocket.so" +//go:cgo_import_dynamic libc_mmap mmap "libc.so" +//go:cgo_import_dynamic libc_munmap munmap "libc.so" +//go:cgo_import_dynamic libc_sendto sendto "libsocket.so" +//go:cgo_import_dynamic libc_socket socket "libsocket.so" +//go:cgo_import_dynamic libc_socketpair socketpair "libsocket.so" +//go:cgo_import_dynamic libc_write write "libc.so" +//go:cgo_import_dynamic libc_getsockopt getsockopt "libsocket.so" +//go:cgo_import_dynamic libc_getpeername getpeername "libsocket.so" +//go:cgo_import_dynamic libc_setsockopt setsockopt "libsocket.so" +//go:cgo_import_dynamic libc_recvfrom recvfrom "libsocket.so" +//go:cgo_import_dynamic libc_sysconf sysconf "libc.so" + +//go:linkname procgetsockname libc_getsockname +//go:linkname procGetcwd libc_getcwd +//go:linkname procgetgroups libc_getgroups +//go:linkname procsetgroups libc_setgroups +//go:linkname procutimes libc_utimes +//go:linkname procutimensat libc_utimensat +//go:linkname procfcntl libc_fcntl +//go:linkname procfutimesat libc_futimesat +//go:linkname procaccept libc_accept +//go:linkname procrecvmsg libc_recvmsg +//go:linkname procsendmsg libc_sendmsg +//go:linkname procacct libc_acct +//go:linkname procioctl libc_ioctl +//go:linkname procAccess libc_access +//go:linkname procAdjtime libc_adjtime +//go:linkname procChdir libc_chdir +//go:linkname procChmod libc_chmod +//go:linkname procChown libc_chown +//go:linkname procChroot libc_chroot +//go:linkname procClose libc_close +//go:linkname procCreat libc_creat +//go:linkname procDup libc_dup +//go:linkname procDup2 libc_dup2 +//go:linkname procExit libc_exit +//go:linkname procFchdir libc_fchdir +//go:linkname procFchmod libc_fchmod +//go:linkname procFchmodat libc_fchmodat +//go:linkname procFchown libc_fchown +//go:linkname procFchownat libc_fchownat +//go:linkname procFdatasync libc_fdatasync +//go:linkname procFpathconf libc_fpathconf +//go:linkname procFstat libc_fstat +//go:linkname procGetdents libc_getdents +//go:linkname procGetgid libc_getgid +//go:linkname procGetpid libc_getpid +//go:linkname procGetpgid libc_getpgid +//go:linkname procGetpgrp libc_getpgrp +//go:linkname procGeteuid libc_geteuid +//go:linkname procGetegid libc_getegid +//go:linkname procGetppid libc_getppid +//go:linkname procGetpriority libc_getpriority +//go:linkname procGetrlimit libc_getrlimit +//go:linkname procGetrusage libc_getrusage +//go:linkname procGettimeofday libc_gettimeofday +//go:linkname procGetuid libc_getuid +//go:linkname procKill libc_kill +//go:linkname procLchown libc_lchown +//go:linkname procLink libc_link +//go:linkname proclisten libc_listen +//go:linkname procLstat libc_lstat +//go:linkname procMadvise libc_madvise +//go:linkname procMkdir libc_mkdir +//go:linkname procMkdirat libc_mkdirat +//go:linkname procMkfifo libc_mkfifo +//go:linkname procMkfifoat libc_mkfifoat +//go:linkname procMknod libc_mknod +//go:linkname procMknodat libc_mknodat +//go:linkname procMlock libc_mlock +//go:linkname procMlockall libc_mlockall +//go:linkname procMprotect libc_mprotect +//go:linkname procMunlock libc_munlock +//go:linkname procMunlockall libc_munlockall +//go:linkname procNanosleep libc_nanosleep +//go:linkname procOpen libc_open +//go:linkname procOpenat libc_openat +//go:linkname procPathconf libc_pathconf +//go:linkname procPause libc_pause +//go:linkname procPread libc_pread +//go:linkname procPwrite libc_pwrite +//go:linkname procread libc_read +//go:linkname procReadlink libc_readlink +//go:linkname procRename libc_rename +//go:linkname procRenameat libc_renameat +//go:linkname procRmdir libc_rmdir +//go:linkname proclseek libc_lseek +//go:linkname procSetegid libc_setegid +//go:linkname procSeteuid libc_seteuid +//go:linkname procSetgid libc_setgid +//go:linkname procSethostname libc_sethostname +//go:linkname procSetpgid libc_setpgid +//go:linkname procSetpriority libc_setpriority +//go:linkname procSetregid libc_setregid +//go:linkname procSetreuid libc_setreuid +//go:linkname procSetrlimit libc_setrlimit +//go:linkname procSetsid libc_setsid +//go:linkname procSetuid libc_setuid +//go:linkname procshutdown libc_shutdown +//go:linkname procStat libc_stat +//go:linkname procSymlink libc_symlink +//go:linkname procSync libc_sync +//go:linkname procTimes libc_times +//go:linkname procTruncate libc_truncate +//go:linkname procFsync libc_fsync +//go:linkname procFtruncate libc_ftruncate +//go:linkname procUmask libc_umask +//go:linkname procUname libc_uname +//go:linkname procumount libc_umount +//go:linkname procUnlink libc_unlink +//go:linkname procUnlinkat libc_unlinkat +//go:linkname procUstat libc_ustat +//go:linkname procUtime libc_utime +//go:linkname procbind libc_bind +//go:linkname procconnect libc_connect +//go:linkname procmmap libc_mmap +//go:linkname procmunmap libc_munmap +//go:linkname procsendto libc_sendto +//go:linkname procsocket libc_socket +//go:linkname procsocketpair libc_socketpair +//go:linkname procwrite libc_write +//go:linkname procgetsockopt libc_getsockopt +//go:linkname procgetpeername libc_getpeername +//go:linkname procsetsockopt libc_setsockopt +//go:linkname procrecvfrom libc_recvfrom +//go:linkname procsysconf libc_sysconf + +var ( + procgetsockname, + procGetcwd, + procgetgroups, + procsetgroups, + procutimes, + procutimensat, + procfcntl, + procfutimesat, + procaccept, + procrecvmsg, + procsendmsg, + procacct, + procioctl, + procAccess, + procAdjtime, + procChdir, + procChmod, + procChown, + procChroot, + procClose, + procCreat, + procDup, + procDup2, + procExit, + procFchdir, + procFchmod, + procFchmodat, + procFchown, + procFchownat, + procFdatasync, + procFpathconf, + procFstat, + procGetdents, + procGetgid, + procGetpid, + procGetpgid, + procGetpgrp, + procGeteuid, + procGetegid, + procGetppid, + procGetpriority, + procGetrlimit, + procGetrusage, + procGettimeofday, + procGetuid, + procKill, + procLchown, + procLink, + proclisten, + procLstat, + procMadvise, + procMkdir, + procMkdirat, + procMkfifo, + procMkfifoat, + procMknod, + procMknodat, + procMlock, + procMlockall, + procMprotect, + procMunlock, + procMunlockall, + procNanosleep, + procOpen, + procOpenat, + procPathconf, + procPause, + procPread, + procPwrite, + procread, + procReadlink, + procRename, + procRenameat, + procRmdir, + proclseek, + procSetegid, + procSeteuid, + procSetgid, + procSethostname, + procSetpgid, + procSetpriority, + procSetregid, + procSetreuid, + procSetrlimit, + procSetsid, + procSetuid, + procshutdown, + procStat, + procSymlink, + procSync, + procTimes, + procTruncate, + procFsync, + procFtruncate, + procUmask, + procUname, + procumount, + procUnlink, + procUnlinkat, + procUstat, + procUtime, + procbind, + procconnect, + procmmap, + procmunmap, + procsendto, + procsocket, + procsocketpair, + procwrite, + procgetsockopt, + procgetpeername, + procsetsockopt, + procrecvfrom, + procsysconf syscallFunc +) + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procgetsockname)), 3, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Getcwd(buf []byte) (n int, err error) { + var _p0 *byte + if len(buf) > 0 { + _p0 = &buf[0] + } + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procGetcwd)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), 0, 0, 0, 0) + n = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func getgroups(ngid int, gid *_Gid_t) (n int, err error) { + r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procgetgroups)), 2, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0, 0, 0, 0) + n = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func setgroups(ngid int, gid *_Gid_t) (err error) { + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procsetgroups)), 2, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func utimes(path string, times *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procutimes)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0, 0, 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func utimensat(fd int, path string, times *[2]Timespec, flag int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procutimensat)), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flag), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func fcntl(fd int, cmd int, arg int) (val int, err error) { + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procfcntl)), 3, uintptr(fd), uintptr(cmd), uintptr(arg), 0, 0, 0) + val = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func futimesat(fildes int, path *byte, times *[2]Timeval) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procfutimesat)), 3, uintptr(fildes), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(times)), 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procaccept)), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procrecvmsg)), 3, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags), 0, 0, 0) + n = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procsendmsg)), 3, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags), 0, 0, 0) + n = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func acct(path *byte) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procacct)), 1, uintptr(unsafe.Pointer(path)), 0, 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func ioctl(fd int, req int, arg uintptr) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procioctl)), 3, uintptr(fd), uintptr(req), uintptr(arg), 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Access(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procAccess)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0, 0, 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procAdjtime)), 2, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procChdir)), 1, uintptr(unsafe.Pointer(_p0)), 0, 0, 0, 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Chmod(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procChmod)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0, 0, 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Chown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procChown)), 3, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), 0, 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procChroot)), 1, uintptr(unsafe.Pointer(_p0)), 0, 0, 0, 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Close(fd int) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procClose)), 1, uintptr(fd), 0, 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Creat(path string, mode uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procCreat)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0, 0, 0, 0) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func Dup(fd int) (nfd int, err error) { + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procDup)), 1, uintptr(fd), 0, 0, 0, 0, 0) + nfd = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func Dup2(oldfd int, newfd int) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procDup2)), 2, uintptr(oldfd), uintptr(newfd), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Exit(code int) { + sysvicall6(uintptr(unsafe.Pointer(&procExit)), 1, uintptr(code), 0, 0, 0, 0, 0) + return +} + +func Fchdir(fd int) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFchdir)), 1, uintptr(fd), 0, 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFchmod)), 2, uintptr(fd), uintptr(mode), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFchmodat)), 4, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFchown)), 3, uintptr(fd), uintptr(uid), uintptr(gid), 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFchownat)), 5, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Fdatasync(fd int) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFdatasync)), 1, uintptr(fd), 0, 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Fpathconf(fd int, name int) (val int, err error) { + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFpathconf)), 2, uintptr(fd), uintptr(name), 0, 0, 0, 0) + val = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFstat)), 2, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Getdents(fd int, buf []byte, basep *uintptr) (n int, err error) { + var _p0 *byte + if len(buf) > 0 { + _p0 = &buf[0] + } + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procGetdents)), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0) + n = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func Getgid() (gid int) { + r0, _, _ := rawSysvicall6(uintptr(unsafe.Pointer(&procGetgid)), 0, 0, 0, 0, 0, 0, 0) + gid = int(r0) + return +} + +func Getpid() (pid int) { + r0, _, _ := rawSysvicall6(uintptr(unsafe.Pointer(&procGetpid)), 0, 0, 0, 0, 0, 0, 0) + pid = int(r0) + return +} + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procGetpgid)), 1, uintptr(pid), 0, 0, 0, 0, 0) + pgid = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func Getpgrp() (pgid int, err error) { + r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procGetpgrp)), 0, 0, 0, 0, 0, 0, 0) + pgid = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func Geteuid() (euid int) { + r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procGeteuid)), 0, 0, 0, 0, 0, 0, 0) + euid = int(r0) + return +} + +func Getegid() (egid int) { + r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procGetegid)), 0, 0, 0, 0, 0, 0, 0) + egid = int(r0) + return +} + +func Getppid() (ppid int) { + r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procGetppid)), 0, 0, 0, 0, 0, 0, 0) + ppid = int(r0) + return +} + +func Getpriority(which int, who int) (n int, err error) { + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procGetpriority)), 2, uintptr(which), uintptr(who), 0, 0, 0, 0) + n = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func Getrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procGetrlimit)), 2, uintptr(which), uintptr(unsafe.Pointer(lim)), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procGetrusage)), 2, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procGettimeofday)), 1, uintptr(unsafe.Pointer(tv)), 0, 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Getuid() (uid int) { + r0, _, _ := rawSysvicall6(uintptr(unsafe.Pointer(&procGetuid)), 0, 0, 0, 0, 0, 0, 0) + uid = int(r0) + return +} + +func Kill(pid int, signum syscall.Signal) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procKill)), 2, uintptr(pid), uintptr(signum), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procLchown)), 3, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), 0, 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Link(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procLink)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0, 0, 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = e1 + } + return +} + +func Listen(s int, backlog int) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proclisten)), 2, uintptr(s), uintptr(backlog), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procLstat)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0, 0, 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Madvise(b []byte, advice int) (err error) { + var _p0 *byte + if len(b) > 0 { + _p0 = &b[0] + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMadvise)), 3, uintptr(unsafe.Pointer(_p0)), uintptr(len(b)), uintptr(advice), 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Mkdir(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMkdir)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0, 0, 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Mkdirat(dirfd int, path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMkdirat)), 3, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0, 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Mkfifo(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMkfifo)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0, 0, 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Mkfifoat(dirfd int, path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMkfifoat)), 3, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0, 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Mknod(path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMknod)), 3, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMknodat)), 4, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Mlock(b []byte) (err error) { + var _p0 *byte + if len(b) > 0 { + _p0 = &b[0] + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMlock)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(len(b)), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Mlockall(flags int) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMlockall)), 1, uintptr(flags), 0, 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Mprotect(b []byte, prot int) (err error) { + var _p0 *byte + if len(b) > 0 { + _p0 = &b[0] + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMprotect)), 3, uintptr(unsafe.Pointer(_p0)), uintptr(len(b)), uintptr(prot), 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Munlock(b []byte) (err error) { + var _p0 *byte + if len(b) > 0 { + _p0 = &b[0] + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMunlock)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(len(b)), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Munlockall() (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procMunlockall)), 0, 0, 0, 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procNanosleep)), 2, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Open(path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procOpen)), 3, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0, 0) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procOpenat)), 4, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0) + use(unsafe.Pointer(_p0)) + fd = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func Pathconf(path string, name int) (val int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procPathconf)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0, 0, 0, 0) + use(unsafe.Pointer(_p0)) + val = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func Pause() (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procPause)), 0, 0, 0, 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 *byte + if len(p) > 0 { + _p0 = &p[0] + } + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procPread)), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func Pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 *byte + if len(p) > 0 { + _p0 = &p[0] + } + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procPwrite)), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func read(fd int, p []byte) (n int, err error) { + var _p0 *byte + if len(p) > 0 { + _p0 = &p[0] + } + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procread)), 3, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), 0, 0, 0) + n = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func Readlink(path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + if len(buf) > 0 { + _p1 = &buf[0] + } + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procReadlink)), 3, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(len(buf)), 0, 0, 0) + use(unsafe.Pointer(_p0)) + n = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func Rename(from string, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procRename)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0, 0, 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = e1 + } + return +} + +func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procRenameat)), 4, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = e1 + } + return +} + +func Rmdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procRmdir)), 1, uintptr(unsafe.Pointer(_p0)), 0, 0, 0, 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&proclseek)), 3, uintptr(fd), uintptr(offset), uintptr(whence), 0, 0, 0) + newoffset = int64(r0) + if e1 != 0 { + err = e1 + } + return +} + +func Setegid(egid int) (err error) { + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetegid)), 1, uintptr(egid), 0, 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Seteuid(euid int) (err error) { + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSeteuid)), 1, uintptr(euid), 0, 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Setgid(gid int) (err error) { + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetgid)), 1, uintptr(gid), 0, 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Sethostname(p []byte) (err error) { + var _p0 *byte + if len(p) > 0 { + _p0 = &p[0] + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procSethostname)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetpgid)), 2, uintptr(pid), uintptr(pgid), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procSetpriority)), 3, uintptr(which), uintptr(who), uintptr(prio), 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetregid)), 2, uintptr(rgid), uintptr(egid), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetreuid)), 2, uintptr(ruid), uintptr(euid), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Setrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetrlimit)), 2, uintptr(which), uintptr(unsafe.Pointer(lim)), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Setsid() (pid int, err error) { + r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetsid)), 0, 0, 0, 0, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func Setuid(uid int) (err error) { + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procSetuid)), 1, uintptr(uid), 0, 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Shutdown(s int, how int) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procshutdown)), 2, uintptr(s), uintptr(how), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procStat)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0, 0, 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Symlink(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procSymlink)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0, 0, 0, 0) + use(unsafe.Pointer(_p0)) + use(unsafe.Pointer(_p1)) + if e1 != 0 { + err = e1 + } + return +} + +func Sync() (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procSync)), 0, 0, 0, 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Times(tms *Tms) (ticks uintptr, err error) { + r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procTimes)), 1, uintptr(unsafe.Pointer(tms)), 0, 0, 0, 0, 0) + ticks = uintptr(r0) + if e1 != 0 { + err = e1 + } + return +} + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procTruncate)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0, 0, 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Fsync(fd int) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFsync)), 1, uintptr(fd), 0, 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFtruncate)), 2, uintptr(fd), uintptr(length), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Umask(mask int) (oldmask int) { + r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procUmask)), 1, uintptr(mask), 0, 0, 0, 0, 0) + oldmask = int(r0) + return +} + +func Uname(buf *Utsname) (err error) { + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procUname)), 1, uintptr(unsafe.Pointer(buf)), 0, 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Unmount(target string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(target) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procumount)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0, 0, 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Unlink(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procUnlink)), 1, uintptr(unsafe.Pointer(_p0)), 0, 0, 0, 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procUnlinkat)), 3, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0, 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func Ustat(dev int, ubuf *Ustat_t) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procUstat)), 2, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func Utime(path string, buf *Utimbuf) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procUtime)), 2, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0, 0, 0, 0) + use(unsafe.Pointer(_p0)) + if e1 != 0 { + err = e1 + } + return +} + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procbind)), 3, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procconnect)), 3, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procmmap)), 6, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos)) + ret = uintptr(r0) + if e1 != 0 { + err = e1 + } + return +} + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procmunmap)), 2, uintptr(addr), uintptr(length), 0, 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 *byte + if len(buf) > 0 { + _p0 = &buf[0] + } + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procsendto)), 6, uintptr(s), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = e1 + } + return +} + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procsocket)), 3, uintptr(domain), uintptr(typ), uintptr(proto), 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procsocketpair)), 4, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func write(fd int, p []byte) (n int, err error) { + var _p0 *byte + if len(p) > 0 { + _p0 = &p[0] + } + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procwrite)), 3, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), 0, 0, 0) + n = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procgetsockopt)), 5, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = e1 + } + return +} + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procgetpeername)), 3, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procsetsockopt)), 5, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = e1 + } + return +} + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 *byte + if len(p) > 0 { + _p0 = &p[0] + } + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procrecvfrom)), 6, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = e1 + } + return +} + +func sysconf(name int) (n int64, err error) { + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procsysconf)), 1, uintptr(name), 0, 0, 0, 0, 0) + n = int64(r0) + if e1 != 0 { + err = e1 + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsysctl_openbsd.go b/vendor/golang.org/x/sys/unix/zsysctl_openbsd.go new file mode 100644 index 0000000000..83bb935b91 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysctl_openbsd.go @@ -0,0 +1,270 @@ +// mksysctl_openbsd.pl +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +package unix + +type mibentry struct { + ctlname string + ctloid []_C_int +} + +var sysctlMib = []mibentry{ + {"ddb.console", []_C_int{9, 6}}, + {"ddb.log", []_C_int{9, 7}}, + {"ddb.max_line", []_C_int{9, 3}}, + {"ddb.max_width", []_C_int{9, 2}}, + {"ddb.panic", []_C_int{9, 5}}, + {"ddb.radix", []_C_int{9, 1}}, + {"ddb.tab_stop_width", []_C_int{9, 4}}, + {"ddb.trigger", []_C_int{9, 8}}, + {"fs.posix.setuid", []_C_int{3, 1, 1}}, + {"hw.allowpowerdown", []_C_int{6, 22}}, + {"hw.byteorder", []_C_int{6, 4}}, + {"hw.cpuspeed", []_C_int{6, 12}}, + {"hw.diskcount", []_C_int{6, 10}}, + {"hw.disknames", []_C_int{6, 8}}, + {"hw.diskstats", []_C_int{6, 9}}, + {"hw.machine", []_C_int{6, 1}}, + {"hw.model", []_C_int{6, 2}}, + {"hw.ncpu", []_C_int{6, 3}}, + {"hw.ncpufound", []_C_int{6, 21}}, + {"hw.pagesize", []_C_int{6, 7}}, + {"hw.physmem", []_C_int{6, 19}}, + {"hw.product", []_C_int{6, 15}}, + {"hw.serialno", []_C_int{6, 17}}, + {"hw.setperf", []_C_int{6, 13}}, + {"hw.usermem", []_C_int{6, 20}}, + {"hw.uuid", []_C_int{6, 18}}, + {"hw.vendor", []_C_int{6, 14}}, + {"hw.version", []_C_int{6, 16}}, + {"kern.arandom", []_C_int{1, 37}}, + {"kern.argmax", []_C_int{1, 8}}, + {"kern.boottime", []_C_int{1, 21}}, + {"kern.bufcachepercent", []_C_int{1, 72}}, + {"kern.ccpu", []_C_int{1, 45}}, + {"kern.clockrate", []_C_int{1, 12}}, + {"kern.consdev", []_C_int{1, 75}}, + {"kern.cp_time", []_C_int{1, 40}}, + {"kern.cp_time2", []_C_int{1, 71}}, + {"kern.cryptodevallowsoft", []_C_int{1, 53}}, + {"kern.domainname", []_C_int{1, 22}}, + {"kern.file", []_C_int{1, 73}}, + {"kern.forkstat", []_C_int{1, 42}}, + {"kern.fscale", []_C_int{1, 46}}, + {"kern.fsync", []_C_int{1, 33}}, + {"kern.hostid", []_C_int{1, 11}}, + {"kern.hostname", []_C_int{1, 10}}, + {"kern.intrcnt.nintrcnt", []_C_int{1, 63, 1}}, + {"kern.job_control", []_C_int{1, 19}}, + {"kern.malloc.buckets", []_C_int{1, 39, 1}}, + {"kern.malloc.kmemnames", []_C_int{1, 39, 3}}, + {"kern.maxclusters", []_C_int{1, 67}}, + {"kern.maxfiles", []_C_int{1, 7}}, + {"kern.maxlocksperuid", []_C_int{1, 70}}, + {"kern.maxpartitions", []_C_int{1, 23}}, + {"kern.maxproc", []_C_int{1, 6}}, + {"kern.maxthread", []_C_int{1, 25}}, + {"kern.maxvnodes", []_C_int{1, 5}}, + {"kern.mbstat", []_C_int{1, 59}}, + {"kern.msgbuf", []_C_int{1, 48}}, + {"kern.msgbufsize", []_C_int{1, 38}}, + {"kern.nchstats", []_C_int{1, 41}}, + {"kern.netlivelocks", []_C_int{1, 76}}, + {"kern.nfiles", []_C_int{1, 56}}, + {"kern.ngroups", []_C_int{1, 18}}, + {"kern.nosuidcoredump", []_C_int{1, 32}}, + {"kern.nprocs", []_C_int{1, 47}}, + {"kern.nselcoll", []_C_int{1, 43}}, + {"kern.nthreads", []_C_int{1, 26}}, + {"kern.numvnodes", []_C_int{1, 58}}, + {"kern.osrelease", []_C_int{1, 2}}, + {"kern.osrevision", []_C_int{1, 3}}, + {"kern.ostype", []_C_int{1, 1}}, + {"kern.osversion", []_C_int{1, 27}}, + {"kern.pool_debug", []_C_int{1, 77}}, + {"kern.posix1version", []_C_int{1, 17}}, + {"kern.proc", []_C_int{1, 66}}, + {"kern.random", []_C_int{1, 31}}, + {"kern.rawpartition", []_C_int{1, 24}}, + {"kern.saved_ids", []_C_int{1, 20}}, + {"kern.securelevel", []_C_int{1, 9}}, + {"kern.seminfo", []_C_int{1, 61}}, + {"kern.shminfo", []_C_int{1, 62}}, + {"kern.somaxconn", []_C_int{1, 28}}, + {"kern.sominconn", []_C_int{1, 29}}, + {"kern.splassert", []_C_int{1, 54}}, + {"kern.stackgap_random", []_C_int{1, 50}}, + {"kern.sysvipc_info", []_C_int{1, 51}}, + {"kern.sysvmsg", []_C_int{1, 34}}, + {"kern.sysvsem", []_C_int{1, 35}}, + {"kern.sysvshm", []_C_int{1, 36}}, + {"kern.timecounter.choice", []_C_int{1, 69, 4}}, + {"kern.timecounter.hardware", []_C_int{1, 69, 3}}, + {"kern.timecounter.tick", []_C_int{1, 69, 1}}, + {"kern.timecounter.timestepwarnings", []_C_int{1, 69, 2}}, + {"kern.tty.maxptys", []_C_int{1, 44, 6}}, + {"kern.tty.nptys", []_C_int{1, 44, 7}}, + {"kern.tty.tk_cancc", []_C_int{1, 44, 4}}, + {"kern.tty.tk_nin", []_C_int{1, 44, 1}}, + {"kern.tty.tk_nout", []_C_int{1, 44, 2}}, + {"kern.tty.tk_rawcc", []_C_int{1, 44, 3}}, + {"kern.tty.ttyinfo", []_C_int{1, 44, 5}}, + {"kern.ttycount", []_C_int{1, 57}}, + {"kern.userasymcrypto", []_C_int{1, 60}}, + {"kern.usercrypto", []_C_int{1, 52}}, + {"kern.usermount", []_C_int{1, 30}}, + {"kern.version", []_C_int{1, 4}}, + {"kern.vnode", []_C_int{1, 13}}, + {"kern.watchdog.auto", []_C_int{1, 64, 2}}, + {"kern.watchdog.period", []_C_int{1, 64, 1}}, + {"net.bpf.bufsize", []_C_int{4, 31, 1}}, + {"net.bpf.maxbufsize", []_C_int{4, 31, 2}}, + {"net.inet.ah.enable", []_C_int{4, 2, 51, 1}}, + {"net.inet.ah.stats", []_C_int{4, 2, 51, 2}}, + {"net.inet.carp.allow", []_C_int{4, 2, 112, 1}}, + {"net.inet.carp.log", []_C_int{4, 2, 112, 3}}, + {"net.inet.carp.preempt", []_C_int{4, 2, 112, 2}}, + {"net.inet.carp.stats", []_C_int{4, 2, 112, 4}}, + {"net.inet.divert.recvspace", []_C_int{4, 2, 258, 1}}, + {"net.inet.divert.sendspace", []_C_int{4, 2, 258, 2}}, + {"net.inet.divert.stats", []_C_int{4, 2, 258, 3}}, + {"net.inet.esp.enable", []_C_int{4, 2, 50, 1}}, + {"net.inet.esp.stats", []_C_int{4, 2, 50, 4}}, + {"net.inet.esp.udpencap", []_C_int{4, 2, 50, 2}}, + {"net.inet.esp.udpencap_port", []_C_int{4, 2, 50, 3}}, + {"net.inet.etherip.allow", []_C_int{4, 2, 97, 1}}, + {"net.inet.etherip.stats", []_C_int{4, 2, 97, 2}}, + {"net.inet.gre.allow", []_C_int{4, 2, 47, 1}}, + {"net.inet.gre.wccp", []_C_int{4, 2, 47, 2}}, + {"net.inet.icmp.bmcastecho", []_C_int{4, 2, 1, 2}}, + {"net.inet.icmp.errppslimit", []_C_int{4, 2, 1, 3}}, + {"net.inet.icmp.maskrepl", []_C_int{4, 2, 1, 1}}, + {"net.inet.icmp.rediraccept", []_C_int{4, 2, 1, 4}}, + {"net.inet.icmp.redirtimeout", []_C_int{4, 2, 1, 5}}, + {"net.inet.icmp.stats", []_C_int{4, 2, 1, 7}}, + {"net.inet.icmp.tstamprepl", []_C_int{4, 2, 1, 6}}, + {"net.inet.igmp.stats", []_C_int{4, 2, 2, 1}}, + {"net.inet.ip.arpqueued", []_C_int{4, 2, 0, 36}}, + {"net.inet.ip.encdebug", []_C_int{4, 2, 0, 12}}, + {"net.inet.ip.forwarding", []_C_int{4, 2, 0, 1}}, + {"net.inet.ip.ifq.congestion", []_C_int{4, 2, 0, 30, 4}}, + {"net.inet.ip.ifq.drops", []_C_int{4, 2, 0, 30, 3}}, + {"net.inet.ip.ifq.len", []_C_int{4, 2, 0, 30, 1}}, + {"net.inet.ip.ifq.maxlen", []_C_int{4, 2, 0, 30, 2}}, + {"net.inet.ip.maxqueue", []_C_int{4, 2, 0, 11}}, + {"net.inet.ip.mforwarding", []_C_int{4, 2, 0, 31}}, + {"net.inet.ip.mrtproto", []_C_int{4, 2, 0, 34}}, + {"net.inet.ip.mrtstats", []_C_int{4, 2, 0, 35}}, + {"net.inet.ip.mtu", []_C_int{4, 2, 0, 4}}, + {"net.inet.ip.mtudisc", []_C_int{4, 2, 0, 27}}, + {"net.inet.ip.mtudisctimeout", []_C_int{4, 2, 0, 28}}, + {"net.inet.ip.multipath", []_C_int{4, 2, 0, 32}}, + {"net.inet.ip.portfirst", []_C_int{4, 2, 0, 7}}, + {"net.inet.ip.porthifirst", []_C_int{4, 2, 0, 9}}, + {"net.inet.ip.porthilast", []_C_int{4, 2, 0, 10}}, + {"net.inet.ip.portlast", []_C_int{4, 2, 0, 8}}, + {"net.inet.ip.redirect", []_C_int{4, 2, 0, 2}}, + {"net.inet.ip.sourceroute", []_C_int{4, 2, 0, 5}}, + {"net.inet.ip.stats", []_C_int{4, 2, 0, 33}}, + {"net.inet.ip.ttl", []_C_int{4, 2, 0, 3}}, + {"net.inet.ipcomp.enable", []_C_int{4, 2, 108, 1}}, + {"net.inet.ipcomp.stats", []_C_int{4, 2, 108, 2}}, + {"net.inet.ipip.allow", []_C_int{4, 2, 4, 1}}, + {"net.inet.ipip.stats", []_C_int{4, 2, 4, 2}}, + {"net.inet.mobileip.allow", []_C_int{4, 2, 55, 1}}, + {"net.inet.pfsync.stats", []_C_int{4, 2, 240, 1}}, + {"net.inet.pim.stats", []_C_int{4, 2, 103, 1}}, + {"net.inet.tcp.ackonpush", []_C_int{4, 2, 6, 13}}, + {"net.inet.tcp.always_keepalive", []_C_int{4, 2, 6, 22}}, + {"net.inet.tcp.baddynamic", []_C_int{4, 2, 6, 6}}, + {"net.inet.tcp.drop", []_C_int{4, 2, 6, 19}}, + {"net.inet.tcp.ecn", []_C_int{4, 2, 6, 14}}, + {"net.inet.tcp.ident", []_C_int{4, 2, 6, 9}}, + {"net.inet.tcp.keepidle", []_C_int{4, 2, 6, 3}}, + {"net.inet.tcp.keepinittime", []_C_int{4, 2, 6, 2}}, + {"net.inet.tcp.keepintvl", []_C_int{4, 2, 6, 4}}, + {"net.inet.tcp.mssdflt", []_C_int{4, 2, 6, 11}}, + {"net.inet.tcp.reasslimit", []_C_int{4, 2, 6, 18}}, + {"net.inet.tcp.rfc1323", []_C_int{4, 2, 6, 1}}, + {"net.inet.tcp.rfc3390", []_C_int{4, 2, 6, 17}}, + {"net.inet.tcp.rstppslimit", []_C_int{4, 2, 6, 12}}, + {"net.inet.tcp.sack", []_C_int{4, 2, 6, 10}}, + {"net.inet.tcp.sackholelimit", []_C_int{4, 2, 6, 20}}, + {"net.inet.tcp.slowhz", []_C_int{4, 2, 6, 5}}, + {"net.inet.tcp.stats", []_C_int{4, 2, 6, 21}}, + {"net.inet.tcp.synbucketlimit", []_C_int{4, 2, 6, 16}}, + {"net.inet.tcp.syncachelimit", []_C_int{4, 2, 6, 15}}, + {"net.inet.udp.baddynamic", []_C_int{4, 2, 17, 2}}, + {"net.inet.udp.checksum", []_C_int{4, 2, 17, 1}}, + {"net.inet.udp.recvspace", []_C_int{4, 2, 17, 3}}, + {"net.inet.udp.sendspace", []_C_int{4, 2, 17, 4}}, + {"net.inet.udp.stats", []_C_int{4, 2, 17, 5}}, + {"net.inet6.divert.recvspace", []_C_int{4, 24, 86, 1}}, + {"net.inet6.divert.sendspace", []_C_int{4, 24, 86, 2}}, + {"net.inet6.divert.stats", []_C_int{4, 24, 86, 3}}, + {"net.inet6.icmp6.errppslimit", []_C_int{4, 24, 30, 14}}, + {"net.inet6.icmp6.mtudisc_hiwat", []_C_int{4, 24, 30, 16}}, + {"net.inet6.icmp6.mtudisc_lowat", []_C_int{4, 24, 30, 17}}, + {"net.inet6.icmp6.nd6_debug", []_C_int{4, 24, 30, 18}}, + {"net.inet6.icmp6.nd6_delay", []_C_int{4, 24, 30, 8}}, + {"net.inet6.icmp6.nd6_maxnudhint", []_C_int{4, 24, 30, 15}}, + {"net.inet6.icmp6.nd6_mmaxtries", []_C_int{4, 24, 30, 10}}, + {"net.inet6.icmp6.nd6_prune", []_C_int{4, 24, 30, 6}}, + {"net.inet6.icmp6.nd6_umaxtries", []_C_int{4, 24, 30, 9}}, + {"net.inet6.icmp6.nd6_useloopback", []_C_int{4, 24, 30, 11}}, + {"net.inet6.icmp6.nodeinfo", []_C_int{4, 24, 30, 13}}, + {"net.inet6.icmp6.rediraccept", []_C_int{4, 24, 30, 2}}, + {"net.inet6.icmp6.redirtimeout", []_C_int{4, 24, 30, 3}}, + {"net.inet6.ip6.accept_rtadv", []_C_int{4, 24, 17, 12}}, + {"net.inet6.ip6.auto_flowlabel", []_C_int{4, 24, 17, 17}}, + {"net.inet6.ip6.dad_count", []_C_int{4, 24, 17, 16}}, + {"net.inet6.ip6.dad_pending", []_C_int{4, 24, 17, 49}}, + {"net.inet6.ip6.defmcasthlim", []_C_int{4, 24, 17, 18}}, + {"net.inet6.ip6.forwarding", []_C_int{4, 24, 17, 1}}, + {"net.inet6.ip6.forwsrcrt", []_C_int{4, 24, 17, 5}}, + {"net.inet6.ip6.hdrnestlimit", []_C_int{4, 24, 17, 15}}, + {"net.inet6.ip6.hlim", []_C_int{4, 24, 17, 3}}, + {"net.inet6.ip6.log_interval", []_C_int{4, 24, 17, 14}}, + {"net.inet6.ip6.maxdynroutes", []_C_int{4, 24, 17, 48}}, + {"net.inet6.ip6.maxfragpackets", []_C_int{4, 24, 17, 9}}, + {"net.inet6.ip6.maxfrags", []_C_int{4, 24, 17, 41}}, + {"net.inet6.ip6.maxifdefrouters", []_C_int{4, 24, 17, 47}}, + {"net.inet6.ip6.maxifprefixes", []_C_int{4, 24, 17, 46}}, + {"net.inet6.ip6.mforwarding", []_C_int{4, 24, 17, 42}}, + {"net.inet6.ip6.mrtproto", []_C_int{4, 24, 17, 8}}, + {"net.inet6.ip6.mtudisctimeout", []_C_int{4, 24, 17, 50}}, + {"net.inet6.ip6.multicast_mtudisc", []_C_int{4, 24, 17, 44}}, + {"net.inet6.ip6.multipath", []_C_int{4, 24, 17, 43}}, + {"net.inet6.ip6.neighborgcthresh", []_C_int{4, 24, 17, 45}}, + {"net.inet6.ip6.redirect", []_C_int{4, 24, 17, 2}}, + {"net.inet6.ip6.rr_prune", []_C_int{4, 24, 17, 22}}, + {"net.inet6.ip6.sourcecheck", []_C_int{4, 24, 17, 10}}, + {"net.inet6.ip6.sourcecheck_logint", []_C_int{4, 24, 17, 11}}, + {"net.inet6.ip6.use_deprecated", []_C_int{4, 24, 17, 21}}, + {"net.inet6.ip6.v6only", []_C_int{4, 24, 17, 24}}, + {"net.key.sadb_dump", []_C_int{4, 30, 1}}, + {"net.key.spd_dump", []_C_int{4, 30, 2}}, + {"net.mpls.ifq.congestion", []_C_int{4, 33, 3, 4}}, + {"net.mpls.ifq.drops", []_C_int{4, 33, 3, 3}}, + {"net.mpls.ifq.len", []_C_int{4, 33, 3, 1}}, + {"net.mpls.ifq.maxlen", []_C_int{4, 33, 3, 2}}, + {"net.mpls.mapttl_ip", []_C_int{4, 33, 5}}, + {"net.mpls.mapttl_ip6", []_C_int{4, 33, 6}}, + {"net.mpls.maxloop_inkernel", []_C_int{4, 33, 4}}, + {"net.mpls.ttl", []_C_int{4, 33, 2}}, + {"net.pflow.stats", []_C_int{4, 34, 1}}, + {"net.pipex.enable", []_C_int{4, 35, 1}}, + {"vm.anonmin", []_C_int{2, 7}}, + {"vm.loadavg", []_C_int{2, 2}}, + {"vm.maxslp", []_C_int{2, 10}}, + {"vm.nkmempages", []_C_int{2, 6}}, + {"vm.psstrings", []_C_int{2, 3}}, + {"vm.swapencrypt.enable", []_C_int{2, 5, 0}}, + {"vm.swapencrypt.keyscreated", []_C_int{2, 5, 1}}, + {"vm.swapencrypt.keysdeleted", []_C_int{2, 5, 2}}, + {"vm.uspace", []_C_int{2, 11}}, + {"vm.uvmexp", []_C_int{2, 4}}, + {"vm.vmmeter", []_C_int{2, 1}}, + {"vm.vnodemin", []_C_int{2, 9}}, + {"vm.vtextmin", []_C_int{2, 8}}, +} diff --git a/vendor/golang.org/x/sys/unix/zsysnum_darwin_386.go b/vendor/golang.org/x/sys/unix/zsysnum_darwin_386.go new file mode 100644 index 0000000000..2786773ba3 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_darwin_386.go @@ -0,0 +1,398 @@ +// mksysnum_darwin.pl /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/sys/syscall.h +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build 386,darwin + +package unix + +const ( + SYS_SYSCALL = 0 + SYS_EXIT = 1 + SYS_FORK = 2 + SYS_READ = 3 + SYS_WRITE = 4 + SYS_OPEN = 5 + SYS_CLOSE = 6 + SYS_WAIT4 = 7 + SYS_LINK = 9 + SYS_UNLINK = 10 + SYS_CHDIR = 12 + SYS_FCHDIR = 13 + SYS_MKNOD = 14 + SYS_CHMOD = 15 + SYS_CHOWN = 16 + SYS_GETFSSTAT = 18 + SYS_GETPID = 20 + SYS_SETUID = 23 + SYS_GETUID = 24 + SYS_GETEUID = 25 + SYS_PTRACE = 26 + SYS_RECVMSG = 27 + SYS_SENDMSG = 28 + SYS_RECVFROM = 29 + SYS_ACCEPT = 30 + SYS_GETPEERNAME = 31 + SYS_GETSOCKNAME = 32 + SYS_ACCESS = 33 + SYS_CHFLAGS = 34 + SYS_FCHFLAGS = 35 + SYS_SYNC = 36 + SYS_KILL = 37 + SYS_GETPPID = 39 + SYS_DUP = 41 + SYS_PIPE = 42 + SYS_GETEGID = 43 + SYS_SIGACTION = 46 + SYS_GETGID = 47 + SYS_SIGPROCMASK = 48 + SYS_GETLOGIN = 49 + SYS_SETLOGIN = 50 + SYS_ACCT = 51 + SYS_SIGPENDING = 52 + SYS_SIGALTSTACK = 53 + SYS_IOCTL = 54 + SYS_REBOOT = 55 + SYS_REVOKE = 56 + SYS_SYMLINK = 57 + SYS_READLINK = 58 + SYS_EXECVE = 59 + SYS_UMASK = 60 + SYS_CHROOT = 61 + SYS_MSYNC = 65 + SYS_VFORK = 66 + SYS_MUNMAP = 73 + SYS_MPROTECT = 74 + SYS_MADVISE = 75 + SYS_MINCORE = 78 + SYS_GETGROUPS = 79 + SYS_SETGROUPS = 80 + SYS_GETPGRP = 81 + SYS_SETPGID = 82 + SYS_SETITIMER = 83 + SYS_SWAPON = 85 + SYS_GETITIMER = 86 + SYS_GETDTABLESIZE = 89 + SYS_DUP2 = 90 + SYS_FCNTL = 92 + SYS_SELECT = 93 + SYS_FSYNC = 95 + SYS_SETPRIORITY = 96 + SYS_SOCKET = 97 + SYS_CONNECT = 98 + SYS_GETPRIORITY = 100 + SYS_BIND = 104 + SYS_SETSOCKOPT = 105 + SYS_LISTEN = 106 + SYS_SIGSUSPEND = 111 + SYS_GETTIMEOFDAY = 116 + SYS_GETRUSAGE = 117 + SYS_GETSOCKOPT = 118 + SYS_READV = 120 + SYS_WRITEV = 121 + SYS_SETTIMEOFDAY = 122 + SYS_FCHOWN = 123 + SYS_FCHMOD = 124 + SYS_SETREUID = 126 + SYS_SETREGID = 127 + SYS_RENAME = 128 + SYS_FLOCK = 131 + SYS_MKFIFO = 132 + SYS_SENDTO = 133 + SYS_SHUTDOWN = 134 + SYS_SOCKETPAIR = 135 + SYS_MKDIR = 136 + SYS_RMDIR = 137 + SYS_UTIMES = 138 + SYS_FUTIMES = 139 + SYS_ADJTIME = 140 + SYS_GETHOSTUUID = 142 + SYS_SETSID = 147 + SYS_GETPGID = 151 + SYS_SETPRIVEXEC = 152 + SYS_PREAD = 153 + SYS_PWRITE = 154 + SYS_NFSSVC = 155 + SYS_STATFS = 157 + SYS_FSTATFS = 158 + SYS_UNMOUNT = 159 + SYS_GETFH = 161 + SYS_QUOTACTL = 165 + SYS_MOUNT = 167 + SYS_CSOPS = 169 + SYS_CSOPS_AUDITTOKEN = 170 + SYS_WAITID = 173 + SYS_KDEBUG_TRACE64 = 179 + SYS_KDEBUG_TRACE = 180 + SYS_SETGID = 181 + SYS_SETEGID = 182 + SYS_SETEUID = 183 + SYS_SIGRETURN = 184 + SYS_CHUD = 185 + SYS_FDATASYNC = 187 + SYS_STAT = 188 + SYS_FSTAT = 189 + SYS_LSTAT = 190 + SYS_PATHCONF = 191 + SYS_FPATHCONF = 192 + SYS_GETRLIMIT = 194 + SYS_SETRLIMIT = 195 + SYS_GETDIRENTRIES = 196 + SYS_MMAP = 197 + SYS_LSEEK = 199 + SYS_TRUNCATE = 200 + SYS_FTRUNCATE = 201 + SYS_SYSCTL = 202 + SYS_MLOCK = 203 + SYS_MUNLOCK = 204 + SYS_UNDELETE = 205 + SYS_OPEN_DPROTECTED_NP = 216 + SYS_GETATTRLIST = 220 + SYS_SETATTRLIST = 221 + SYS_GETDIRENTRIESATTR = 222 + SYS_EXCHANGEDATA = 223 + SYS_SEARCHFS = 225 + SYS_DELETE = 226 + SYS_COPYFILE = 227 + SYS_FGETATTRLIST = 228 + SYS_FSETATTRLIST = 229 + SYS_POLL = 230 + SYS_WATCHEVENT = 231 + SYS_WAITEVENT = 232 + SYS_MODWATCH = 233 + SYS_GETXATTR = 234 + SYS_FGETXATTR = 235 + SYS_SETXATTR = 236 + SYS_FSETXATTR = 237 + SYS_REMOVEXATTR = 238 + SYS_FREMOVEXATTR = 239 + SYS_LISTXATTR = 240 + SYS_FLISTXATTR = 241 + SYS_FSCTL = 242 + SYS_INITGROUPS = 243 + SYS_POSIX_SPAWN = 244 + SYS_FFSCTL = 245 + SYS_NFSCLNT = 247 + SYS_FHOPEN = 248 + SYS_MINHERIT = 250 + SYS_SEMSYS = 251 + SYS_MSGSYS = 252 + SYS_SHMSYS = 253 + SYS_SEMCTL = 254 + SYS_SEMGET = 255 + SYS_SEMOP = 256 + SYS_MSGCTL = 258 + SYS_MSGGET = 259 + SYS_MSGSND = 260 + SYS_MSGRCV = 261 + SYS_SHMAT = 262 + SYS_SHMCTL = 263 + SYS_SHMDT = 264 + SYS_SHMGET = 265 + SYS_SHM_OPEN = 266 + SYS_SHM_UNLINK = 267 + SYS_SEM_OPEN = 268 + SYS_SEM_CLOSE = 269 + SYS_SEM_UNLINK = 270 + SYS_SEM_WAIT = 271 + SYS_SEM_TRYWAIT = 272 + SYS_SEM_POST = 273 + SYS_SYSCTLBYNAME = 274 + SYS_OPEN_EXTENDED = 277 + SYS_UMASK_EXTENDED = 278 + SYS_STAT_EXTENDED = 279 + SYS_LSTAT_EXTENDED = 280 + SYS_FSTAT_EXTENDED = 281 + SYS_CHMOD_EXTENDED = 282 + SYS_FCHMOD_EXTENDED = 283 + SYS_ACCESS_EXTENDED = 284 + SYS_SETTID = 285 + SYS_GETTID = 286 + SYS_SETSGROUPS = 287 + SYS_GETSGROUPS = 288 + SYS_SETWGROUPS = 289 + SYS_GETWGROUPS = 290 + SYS_MKFIFO_EXTENDED = 291 + SYS_MKDIR_EXTENDED = 292 + SYS_IDENTITYSVC = 293 + SYS_SHARED_REGION_CHECK_NP = 294 + SYS_VM_PRESSURE_MONITOR = 296 + SYS_PSYNCH_RW_LONGRDLOCK = 297 + SYS_PSYNCH_RW_YIELDWRLOCK = 298 + SYS_PSYNCH_RW_DOWNGRADE = 299 + SYS_PSYNCH_RW_UPGRADE = 300 + SYS_PSYNCH_MUTEXWAIT = 301 + SYS_PSYNCH_MUTEXDROP = 302 + SYS_PSYNCH_CVBROAD = 303 + SYS_PSYNCH_CVSIGNAL = 304 + SYS_PSYNCH_CVWAIT = 305 + SYS_PSYNCH_RW_RDLOCK = 306 + SYS_PSYNCH_RW_WRLOCK = 307 + SYS_PSYNCH_RW_UNLOCK = 308 + SYS_PSYNCH_RW_UNLOCK2 = 309 + SYS_GETSID = 310 + SYS_SETTID_WITH_PID = 311 + SYS_PSYNCH_CVCLRPREPOST = 312 + SYS_AIO_FSYNC = 313 + SYS_AIO_RETURN = 314 + SYS_AIO_SUSPEND = 315 + SYS_AIO_CANCEL = 316 + SYS_AIO_ERROR = 317 + SYS_AIO_READ = 318 + SYS_AIO_WRITE = 319 + SYS_LIO_LISTIO = 320 + SYS_IOPOLICYSYS = 322 + SYS_PROCESS_POLICY = 323 + SYS_MLOCKALL = 324 + SYS_MUNLOCKALL = 325 + SYS_ISSETUGID = 327 + SYS___PTHREAD_KILL = 328 + SYS___PTHREAD_SIGMASK = 329 + SYS___SIGWAIT = 330 + SYS___DISABLE_THREADSIGNAL = 331 + SYS___PTHREAD_MARKCANCEL = 332 + SYS___PTHREAD_CANCELED = 333 + SYS___SEMWAIT_SIGNAL = 334 + SYS_PROC_INFO = 336 + SYS_SENDFILE = 337 + SYS_STAT64 = 338 + SYS_FSTAT64 = 339 + SYS_LSTAT64 = 340 + SYS_STAT64_EXTENDED = 341 + SYS_LSTAT64_EXTENDED = 342 + SYS_FSTAT64_EXTENDED = 343 + SYS_GETDIRENTRIES64 = 344 + SYS_STATFS64 = 345 + SYS_FSTATFS64 = 346 + SYS_GETFSSTAT64 = 347 + SYS___PTHREAD_CHDIR = 348 + SYS___PTHREAD_FCHDIR = 349 + SYS_AUDIT = 350 + SYS_AUDITON = 351 + SYS_GETAUID = 353 + SYS_SETAUID = 354 + SYS_GETAUDIT_ADDR = 357 + SYS_SETAUDIT_ADDR = 358 + SYS_AUDITCTL = 359 + SYS_BSDTHREAD_CREATE = 360 + SYS_BSDTHREAD_TERMINATE = 361 + SYS_KQUEUE = 362 + SYS_KEVENT = 363 + SYS_LCHOWN = 364 + SYS_STACK_SNAPSHOT = 365 + SYS_BSDTHREAD_REGISTER = 366 + SYS_WORKQ_OPEN = 367 + SYS_WORKQ_KERNRETURN = 368 + SYS_KEVENT64 = 369 + SYS___OLD_SEMWAIT_SIGNAL = 370 + SYS___OLD_SEMWAIT_SIGNAL_NOCANCEL = 371 + SYS_THREAD_SELFID = 372 + SYS_LEDGER = 373 + SYS___MAC_EXECVE = 380 + SYS___MAC_SYSCALL = 381 + SYS___MAC_GET_FILE = 382 + SYS___MAC_SET_FILE = 383 + SYS___MAC_GET_LINK = 384 + SYS___MAC_SET_LINK = 385 + SYS___MAC_GET_PROC = 386 + SYS___MAC_SET_PROC = 387 + SYS___MAC_GET_FD = 388 + SYS___MAC_SET_FD = 389 + SYS___MAC_GET_PID = 390 + SYS___MAC_GET_LCID = 391 + SYS___MAC_GET_LCTX = 392 + SYS___MAC_SET_LCTX = 393 + SYS_SETLCID = 394 + SYS_GETLCID = 395 + SYS_READ_NOCANCEL = 396 + SYS_WRITE_NOCANCEL = 397 + SYS_OPEN_NOCANCEL = 398 + SYS_CLOSE_NOCANCEL = 399 + SYS_WAIT4_NOCANCEL = 400 + SYS_RECVMSG_NOCANCEL = 401 + SYS_SENDMSG_NOCANCEL = 402 + SYS_RECVFROM_NOCANCEL = 403 + SYS_ACCEPT_NOCANCEL = 404 + SYS_MSYNC_NOCANCEL = 405 + SYS_FCNTL_NOCANCEL = 406 + SYS_SELECT_NOCANCEL = 407 + SYS_FSYNC_NOCANCEL = 408 + SYS_CONNECT_NOCANCEL = 409 + SYS_SIGSUSPEND_NOCANCEL = 410 + SYS_READV_NOCANCEL = 411 + SYS_WRITEV_NOCANCEL = 412 + SYS_SENDTO_NOCANCEL = 413 + SYS_PREAD_NOCANCEL = 414 + SYS_PWRITE_NOCANCEL = 415 + SYS_WAITID_NOCANCEL = 416 + SYS_POLL_NOCANCEL = 417 + SYS_MSGSND_NOCANCEL = 418 + SYS_MSGRCV_NOCANCEL = 419 + SYS_SEM_WAIT_NOCANCEL = 420 + SYS_AIO_SUSPEND_NOCANCEL = 421 + SYS___SIGWAIT_NOCANCEL = 422 + SYS___SEMWAIT_SIGNAL_NOCANCEL = 423 + SYS___MAC_MOUNT = 424 + SYS___MAC_GET_MOUNT = 425 + SYS___MAC_GETFSSTAT = 426 + SYS_FSGETPATH = 427 + SYS_AUDIT_SESSION_SELF = 428 + SYS_AUDIT_SESSION_JOIN = 429 + SYS_FILEPORT_MAKEPORT = 430 + SYS_FILEPORT_MAKEFD = 431 + SYS_AUDIT_SESSION_PORT = 432 + SYS_PID_SUSPEND = 433 + SYS_PID_RESUME = 434 + SYS_PID_HIBERNATE = 435 + SYS_PID_SHUTDOWN_SOCKETS = 436 + SYS_SHARED_REGION_MAP_AND_SLIDE_NP = 438 + SYS_KAS_INFO = 439 + SYS_MEMORYSTATUS_CONTROL = 440 + SYS_GUARDED_OPEN_NP = 441 + SYS_GUARDED_CLOSE_NP = 442 + SYS_GUARDED_KQUEUE_NP = 443 + SYS_CHANGE_FDGUARD_NP = 444 + SYS_PROC_RLIMIT_CONTROL = 446 + SYS_CONNECTX = 447 + SYS_DISCONNECTX = 448 + SYS_PEELOFF = 449 + SYS_SOCKET_DELEGATE = 450 + SYS_TELEMETRY = 451 + SYS_PROC_UUID_POLICY = 452 + SYS_MEMORYSTATUS_GET_LEVEL = 453 + SYS_SYSTEM_OVERRIDE = 454 + SYS_VFS_PURGE = 455 + SYS_SFI_CTL = 456 + SYS_SFI_PIDCTL = 457 + SYS_COALITION = 458 + SYS_COALITION_INFO = 459 + SYS_NECP_MATCH_POLICY = 460 + SYS_GETATTRLISTBULK = 461 + SYS_OPENAT = 463 + SYS_OPENAT_NOCANCEL = 464 + SYS_RENAMEAT = 465 + SYS_FACCESSAT = 466 + SYS_FCHMODAT = 467 + SYS_FCHOWNAT = 468 + SYS_FSTATAT = 469 + SYS_FSTATAT64 = 470 + SYS_LINKAT = 471 + SYS_UNLINKAT = 472 + SYS_READLINKAT = 473 + SYS_SYMLINKAT = 474 + SYS_MKDIRAT = 475 + SYS_GETATTRLISTAT = 476 + SYS_PROC_TRACE_LOG = 477 + SYS_BSDTHREAD_CTL = 478 + SYS_OPENBYID_NP = 479 + SYS_RECVMSG_X = 480 + SYS_SENDMSG_X = 481 + SYS_THREAD_SELFUSAGE = 482 + SYS_CSRCTL = 483 + SYS_GUARDED_OPEN_DPROTECTED_NP = 484 + SYS_GUARDED_WRITE_NP = 485 + SYS_GUARDED_PWRITE_NP = 486 + SYS_GUARDED_WRITEV_NP = 487 + SYS_RENAME_EXT = 488 + SYS_MREMAP_ENCRYPTED = 489 + SYS_MAXSYSCALL = 490 +) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_darwin_amd64.go new file mode 100644 index 0000000000..09de240c8f --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_darwin_amd64.go @@ -0,0 +1,398 @@ +// mksysnum_darwin.pl /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/sys/syscall.h +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build amd64,darwin + +package unix + +const ( + SYS_SYSCALL = 0 + SYS_EXIT = 1 + SYS_FORK = 2 + SYS_READ = 3 + SYS_WRITE = 4 + SYS_OPEN = 5 + SYS_CLOSE = 6 + SYS_WAIT4 = 7 + SYS_LINK = 9 + SYS_UNLINK = 10 + SYS_CHDIR = 12 + SYS_FCHDIR = 13 + SYS_MKNOD = 14 + SYS_CHMOD = 15 + SYS_CHOWN = 16 + SYS_GETFSSTAT = 18 + SYS_GETPID = 20 + SYS_SETUID = 23 + SYS_GETUID = 24 + SYS_GETEUID = 25 + SYS_PTRACE = 26 + SYS_RECVMSG = 27 + SYS_SENDMSG = 28 + SYS_RECVFROM = 29 + SYS_ACCEPT = 30 + SYS_GETPEERNAME = 31 + SYS_GETSOCKNAME = 32 + SYS_ACCESS = 33 + SYS_CHFLAGS = 34 + SYS_FCHFLAGS = 35 + SYS_SYNC = 36 + SYS_KILL = 37 + SYS_GETPPID = 39 + SYS_DUP = 41 + SYS_PIPE = 42 + SYS_GETEGID = 43 + SYS_SIGACTION = 46 + SYS_GETGID = 47 + SYS_SIGPROCMASK = 48 + SYS_GETLOGIN = 49 + SYS_SETLOGIN = 50 + SYS_ACCT = 51 + SYS_SIGPENDING = 52 + SYS_SIGALTSTACK = 53 + SYS_IOCTL = 54 + SYS_REBOOT = 55 + SYS_REVOKE = 56 + SYS_SYMLINK = 57 + SYS_READLINK = 58 + SYS_EXECVE = 59 + SYS_UMASK = 60 + SYS_CHROOT = 61 + SYS_MSYNC = 65 + SYS_VFORK = 66 + SYS_MUNMAP = 73 + SYS_MPROTECT = 74 + SYS_MADVISE = 75 + SYS_MINCORE = 78 + SYS_GETGROUPS = 79 + SYS_SETGROUPS = 80 + SYS_GETPGRP = 81 + SYS_SETPGID = 82 + SYS_SETITIMER = 83 + SYS_SWAPON = 85 + SYS_GETITIMER = 86 + SYS_GETDTABLESIZE = 89 + SYS_DUP2 = 90 + SYS_FCNTL = 92 + SYS_SELECT = 93 + SYS_FSYNC = 95 + SYS_SETPRIORITY = 96 + SYS_SOCKET = 97 + SYS_CONNECT = 98 + SYS_GETPRIORITY = 100 + SYS_BIND = 104 + SYS_SETSOCKOPT = 105 + SYS_LISTEN = 106 + SYS_SIGSUSPEND = 111 + SYS_GETTIMEOFDAY = 116 + SYS_GETRUSAGE = 117 + SYS_GETSOCKOPT = 118 + SYS_READV = 120 + SYS_WRITEV = 121 + SYS_SETTIMEOFDAY = 122 + SYS_FCHOWN = 123 + SYS_FCHMOD = 124 + SYS_SETREUID = 126 + SYS_SETREGID = 127 + SYS_RENAME = 128 + SYS_FLOCK = 131 + SYS_MKFIFO = 132 + SYS_SENDTO = 133 + SYS_SHUTDOWN = 134 + SYS_SOCKETPAIR = 135 + SYS_MKDIR = 136 + SYS_RMDIR = 137 + SYS_UTIMES = 138 + SYS_FUTIMES = 139 + SYS_ADJTIME = 140 + SYS_GETHOSTUUID = 142 + SYS_SETSID = 147 + SYS_GETPGID = 151 + SYS_SETPRIVEXEC = 152 + SYS_PREAD = 153 + SYS_PWRITE = 154 + SYS_NFSSVC = 155 + SYS_STATFS = 157 + SYS_FSTATFS = 158 + SYS_UNMOUNT = 159 + SYS_GETFH = 161 + SYS_QUOTACTL = 165 + SYS_MOUNT = 167 + SYS_CSOPS = 169 + SYS_CSOPS_AUDITTOKEN = 170 + SYS_WAITID = 173 + SYS_KDEBUG_TRACE64 = 179 + SYS_KDEBUG_TRACE = 180 + SYS_SETGID = 181 + SYS_SETEGID = 182 + SYS_SETEUID = 183 + SYS_SIGRETURN = 184 + SYS_CHUD = 185 + SYS_FDATASYNC = 187 + SYS_STAT = 188 + SYS_FSTAT = 189 + SYS_LSTAT = 190 + SYS_PATHCONF = 191 + SYS_FPATHCONF = 192 + SYS_GETRLIMIT = 194 + SYS_SETRLIMIT = 195 + SYS_GETDIRENTRIES = 196 + SYS_MMAP = 197 + SYS_LSEEK = 199 + SYS_TRUNCATE = 200 + SYS_FTRUNCATE = 201 + SYS_SYSCTL = 202 + SYS_MLOCK = 203 + SYS_MUNLOCK = 204 + SYS_UNDELETE = 205 + SYS_OPEN_DPROTECTED_NP = 216 + SYS_GETATTRLIST = 220 + SYS_SETATTRLIST = 221 + SYS_GETDIRENTRIESATTR = 222 + SYS_EXCHANGEDATA = 223 + SYS_SEARCHFS = 225 + SYS_DELETE = 226 + SYS_COPYFILE = 227 + SYS_FGETATTRLIST = 228 + SYS_FSETATTRLIST = 229 + SYS_POLL = 230 + SYS_WATCHEVENT = 231 + SYS_WAITEVENT = 232 + SYS_MODWATCH = 233 + SYS_GETXATTR = 234 + SYS_FGETXATTR = 235 + SYS_SETXATTR = 236 + SYS_FSETXATTR = 237 + SYS_REMOVEXATTR = 238 + SYS_FREMOVEXATTR = 239 + SYS_LISTXATTR = 240 + SYS_FLISTXATTR = 241 + SYS_FSCTL = 242 + SYS_INITGROUPS = 243 + SYS_POSIX_SPAWN = 244 + SYS_FFSCTL = 245 + SYS_NFSCLNT = 247 + SYS_FHOPEN = 248 + SYS_MINHERIT = 250 + SYS_SEMSYS = 251 + SYS_MSGSYS = 252 + SYS_SHMSYS = 253 + SYS_SEMCTL = 254 + SYS_SEMGET = 255 + SYS_SEMOP = 256 + SYS_MSGCTL = 258 + SYS_MSGGET = 259 + SYS_MSGSND = 260 + SYS_MSGRCV = 261 + SYS_SHMAT = 262 + SYS_SHMCTL = 263 + SYS_SHMDT = 264 + SYS_SHMGET = 265 + SYS_SHM_OPEN = 266 + SYS_SHM_UNLINK = 267 + SYS_SEM_OPEN = 268 + SYS_SEM_CLOSE = 269 + SYS_SEM_UNLINK = 270 + SYS_SEM_WAIT = 271 + SYS_SEM_TRYWAIT = 272 + SYS_SEM_POST = 273 + SYS_SYSCTLBYNAME = 274 + SYS_OPEN_EXTENDED = 277 + SYS_UMASK_EXTENDED = 278 + SYS_STAT_EXTENDED = 279 + SYS_LSTAT_EXTENDED = 280 + SYS_FSTAT_EXTENDED = 281 + SYS_CHMOD_EXTENDED = 282 + SYS_FCHMOD_EXTENDED = 283 + SYS_ACCESS_EXTENDED = 284 + SYS_SETTID = 285 + SYS_GETTID = 286 + SYS_SETSGROUPS = 287 + SYS_GETSGROUPS = 288 + SYS_SETWGROUPS = 289 + SYS_GETWGROUPS = 290 + SYS_MKFIFO_EXTENDED = 291 + SYS_MKDIR_EXTENDED = 292 + SYS_IDENTITYSVC = 293 + SYS_SHARED_REGION_CHECK_NP = 294 + SYS_VM_PRESSURE_MONITOR = 296 + SYS_PSYNCH_RW_LONGRDLOCK = 297 + SYS_PSYNCH_RW_YIELDWRLOCK = 298 + SYS_PSYNCH_RW_DOWNGRADE = 299 + SYS_PSYNCH_RW_UPGRADE = 300 + SYS_PSYNCH_MUTEXWAIT = 301 + SYS_PSYNCH_MUTEXDROP = 302 + SYS_PSYNCH_CVBROAD = 303 + SYS_PSYNCH_CVSIGNAL = 304 + SYS_PSYNCH_CVWAIT = 305 + SYS_PSYNCH_RW_RDLOCK = 306 + SYS_PSYNCH_RW_WRLOCK = 307 + SYS_PSYNCH_RW_UNLOCK = 308 + SYS_PSYNCH_RW_UNLOCK2 = 309 + SYS_GETSID = 310 + SYS_SETTID_WITH_PID = 311 + SYS_PSYNCH_CVCLRPREPOST = 312 + SYS_AIO_FSYNC = 313 + SYS_AIO_RETURN = 314 + SYS_AIO_SUSPEND = 315 + SYS_AIO_CANCEL = 316 + SYS_AIO_ERROR = 317 + SYS_AIO_READ = 318 + SYS_AIO_WRITE = 319 + SYS_LIO_LISTIO = 320 + SYS_IOPOLICYSYS = 322 + SYS_PROCESS_POLICY = 323 + SYS_MLOCKALL = 324 + SYS_MUNLOCKALL = 325 + SYS_ISSETUGID = 327 + SYS___PTHREAD_KILL = 328 + SYS___PTHREAD_SIGMASK = 329 + SYS___SIGWAIT = 330 + SYS___DISABLE_THREADSIGNAL = 331 + SYS___PTHREAD_MARKCANCEL = 332 + SYS___PTHREAD_CANCELED = 333 + SYS___SEMWAIT_SIGNAL = 334 + SYS_PROC_INFO = 336 + SYS_SENDFILE = 337 + SYS_STAT64 = 338 + SYS_FSTAT64 = 339 + SYS_LSTAT64 = 340 + SYS_STAT64_EXTENDED = 341 + SYS_LSTAT64_EXTENDED = 342 + SYS_FSTAT64_EXTENDED = 343 + SYS_GETDIRENTRIES64 = 344 + SYS_STATFS64 = 345 + SYS_FSTATFS64 = 346 + SYS_GETFSSTAT64 = 347 + SYS___PTHREAD_CHDIR = 348 + SYS___PTHREAD_FCHDIR = 349 + SYS_AUDIT = 350 + SYS_AUDITON = 351 + SYS_GETAUID = 353 + SYS_SETAUID = 354 + SYS_GETAUDIT_ADDR = 357 + SYS_SETAUDIT_ADDR = 358 + SYS_AUDITCTL = 359 + SYS_BSDTHREAD_CREATE = 360 + SYS_BSDTHREAD_TERMINATE = 361 + SYS_KQUEUE = 362 + SYS_KEVENT = 363 + SYS_LCHOWN = 364 + SYS_STACK_SNAPSHOT = 365 + SYS_BSDTHREAD_REGISTER = 366 + SYS_WORKQ_OPEN = 367 + SYS_WORKQ_KERNRETURN = 368 + SYS_KEVENT64 = 369 + SYS___OLD_SEMWAIT_SIGNAL = 370 + SYS___OLD_SEMWAIT_SIGNAL_NOCANCEL = 371 + SYS_THREAD_SELFID = 372 + SYS_LEDGER = 373 + SYS___MAC_EXECVE = 380 + SYS___MAC_SYSCALL = 381 + SYS___MAC_GET_FILE = 382 + SYS___MAC_SET_FILE = 383 + SYS___MAC_GET_LINK = 384 + SYS___MAC_SET_LINK = 385 + SYS___MAC_GET_PROC = 386 + SYS___MAC_SET_PROC = 387 + SYS___MAC_GET_FD = 388 + SYS___MAC_SET_FD = 389 + SYS___MAC_GET_PID = 390 + SYS___MAC_GET_LCID = 391 + SYS___MAC_GET_LCTX = 392 + SYS___MAC_SET_LCTX = 393 + SYS_SETLCID = 394 + SYS_GETLCID = 395 + SYS_READ_NOCANCEL = 396 + SYS_WRITE_NOCANCEL = 397 + SYS_OPEN_NOCANCEL = 398 + SYS_CLOSE_NOCANCEL = 399 + SYS_WAIT4_NOCANCEL = 400 + SYS_RECVMSG_NOCANCEL = 401 + SYS_SENDMSG_NOCANCEL = 402 + SYS_RECVFROM_NOCANCEL = 403 + SYS_ACCEPT_NOCANCEL = 404 + SYS_MSYNC_NOCANCEL = 405 + SYS_FCNTL_NOCANCEL = 406 + SYS_SELECT_NOCANCEL = 407 + SYS_FSYNC_NOCANCEL = 408 + SYS_CONNECT_NOCANCEL = 409 + SYS_SIGSUSPEND_NOCANCEL = 410 + SYS_READV_NOCANCEL = 411 + SYS_WRITEV_NOCANCEL = 412 + SYS_SENDTO_NOCANCEL = 413 + SYS_PREAD_NOCANCEL = 414 + SYS_PWRITE_NOCANCEL = 415 + SYS_WAITID_NOCANCEL = 416 + SYS_POLL_NOCANCEL = 417 + SYS_MSGSND_NOCANCEL = 418 + SYS_MSGRCV_NOCANCEL = 419 + SYS_SEM_WAIT_NOCANCEL = 420 + SYS_AIO_SUSPEND_NOCANCEL = 421 + SYS___SIGWAIT_NOCANCEL = 422 + SYS___SEMWAIT_SIGNAL_NOCANCEL = 423 + SYS___MAC_MOUNT = 424 + SYS___MAC_GET_MOUNT = 425 + SYS___MAC_GETFSSTAT = 426 + SYS_FSGETPATH = 427 + SYS_AUDIT_SESSION_SELF = 428 + SYS_AUDIT_SESSION_JOIN = 429 + SYS_FILEPORT_MAKEPORT = 430 + SYS_FILEPORT_MAKEFD = 431 + SYS_AUDIT_SESSION_PORT = 432 + SYS_PID_SUSPEND = 433 + SYS_PID_RESUME = 434 + SYS_PID_HIBERNATE = 435 + SYS_PID_SHUTDOWN_SOCKETS = 436 + SYS_SHARED_REGION_MAP_AND_SLIDE_NP = 438 + SYS_KAS_INFO = 439 + SYS_MEMORYSTATUS_CONTROL = 440 + SYS_GUARDED_OPEN_NP = 441 + SYS_GUARDED_CLOSE_NP = 442 + SYS_GUARDED_KQUEUE_NP = 443 + SYS_CHANGE_FDGUARD_NP = 444 + SYS_PROC_RLIMIT_CONTROL = 446 + SYS_CONNECTX = 447 + SYS_DISCONNECTX = 448 + SYS_PEELOFF = 449 + SYS_SOCKET_DELEGATE = 450 + SYS_TELEMETRY = 451 + SYS_PROC_UUID_POLICY = 452 + SYS_MEMORYSTATUS_GET_LEVEL = 453 + SYS_SYSTEM_OVERRIDE = 454 + SYS_VFS_PURGE = 455 + SYS_SFI_CTL = 456 + SYS_SFI_PIDCTL = 457 + SYS_COALITION = 458 + SYS_COALITION_INFO = 459 + SYS_NECP_MATCH_POLICY = 460 + SYS_GETATTRLISTBULK = 461 + SYS_OPENAT = 463 + SYS_OPENAT_NOCANCEL = 464 + SYS_RENAMEAT = 465 + SYS_FACCESSAT = 466 + SYS_FCHMODAT = 467 + SYS_FCHOWNAT = 468 + SYS_FSTATAT = 469 + SYS_FSTATAT64 = 470 + SYS_LINKAT = 471 + SYS_UNLINKAT = 472 + SYS_READLINKAT = 473 + SYS_SYMLINKAT = 474 + SYS_MKDIRAT = 475 + SYS_GETATTRLISTAT = 476 + SYS_PROC_TRACE_LOG = 477 + SYS_BSDTHREAD_CTL = 478 + SYS_OPENBYID_NP = 479 + SYS_RECVMSG_X = 480 + SYS_SENDMSG_X = 481 + SYS_THREAD_SELFUSAGE = 482 + SYS_CSRCTL = 483 + SYS_GUARDED_OPEN_DPROTECTED_NP = 484 + SYS_GUARDED_WRITE_NP = 485 + SYS_GUARDED_PWRITE_NP = 486 + SYS_GUARDED_WRITEV_NP = 487 + SYS_RENAME_EXT = 488 + SYS_MREMAP_ENCRYPTED = 489 + SYS_MAXSYSCALL = 490 +) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm.go b/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm.go new file mode 100644 index 0000000000..b8c9aea852 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm.go @@ -0,0 +1,358 @@ +// mksysnum_darwin.pl /usr/include/sys/syscall.h +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build arm,darwin + +package unix + +const ( + SYS_SYSCALL = 0 + SYS_EXIT = 1 + SYS_FORK = 2 + SYS_READ = 3 + SYS_WRITE = 4 + SYS_OPEN = 5 + SYS_CLOSE = 6 + SYS_WAIT4 = 7 + SYS_LINK = 9 + SYS_UNLINK = 10 + SYS_CHDIR = 12 + SYS_FCHDIR = 13 + SYS_MKNOD = 14 + SYS_CHMOD = 15 + SYS_CHOWN = 16 + SYS_GETFSSTAT = 18 + SYS_GETPID = 20 + SYS_SETUID = 23 + SYS_GETUID = 24 + SYS_GETEUID = 25 + SYS_PTRACE = 26 + SYS_RECVMSG = 27 + SYS_SENDMSG = 28 + SYS_RECVFROM = 29 + SYS_ACCEPT = 30 + SYS_GETPEERNAME = 31 + SYS_GETSOCKNAME = 32 + SYS_ACCESS = 33 + SYS_CHFLAGS = 34 + SYS_FCHFLAGS = 35 + SYS_SYNC = 36 + SYS_KILL = 37 + SYS_GETPPID = 39 + SYS_DUP = 41 + SYS_PIPE = 42 + SYS_GETEGID = 43 + SYS_SIGACTION = 46 + SYS_GETGID = 47 + SYS_SIGPROCMASK = 48 + SYS_GETLOGIN = 49 + SYS_SETLOGIN = 50 + SYS_ACCT = 51 + SYS_SIGPENDING = 52 + SYS_SIGALTSTACK = 53 + SYS_IOCTL = 54 + SYS_REBOOT = 55 + SYS_REVOKE = 56 + SYS_SYMLINK = 57 + SYS_READLINK = 58 + SYS_EXECVE = 59 + SYS_UMASK = 60 + SYS_CHROOT = 61 + SYS_MSYNC = 65 + SYS_VFORK = 66 + SYS_MUNMAP = 73 + SYS_MPROTECT = 74 + SYS_MADVISE = 75 + SYS_MINCORE = 78 + SYS_GETGROUPS = 79 + SYS_SETGROUPS = 80 + SYS_GETPGRP = 81 + SYS_SETPGID = 82 + SYS_SETITIMER = 83 + SYS_SWAPON = 85 + SYS_GETITIMER = 86 + SYS_GETDTABLESIZE = 89 + SYS_DUP2 = 90 + SYS_FCNTL = 92 + SYS_SELECT = 93 + SYS_FSYNC = 95 + SYS_SETPRIORITY = 96 + SYS_SOCKET = 97 + SYS_CONNECT = 98 + SYS_GETPRIORITY = 100 + SYS_BIND = 104 + SYS_SETSOCKOPT = 105 + SYS_LISTEN = 106 + SYS_SIGSUSPEND = 111 + SYS_GETTIMEOFDAY = 116 + SYS_GETRUSAGE = 117 + SYS_GETSOCKOPT = 118 + SYS_READV = 120 + SYS_WRITEV = 121 + SYS_SETTIMEOFDAY = 122 + SYS_FCHOWN = 123 + SYS_FCHMOD = 124 + SYS_SETREUID = 126 + SYS_SETREGID = 127 + SYS_RENAME = 128 + SYS_FLOCK = 131 + SYS_MKFIFO = 132 + SYS_SENDTO = 133 + SYS_SHUTDOWN = 134 + SYS_SOCKETPAIR = 135 + SYS_MKDIR = 136 + SYS_RMDIR = 137 + SYS_UTIMES = 138 + SYS_FUTIMES = 139 + SYS_ADJTIME = 140 + SYS_GETHOSTUUID = 142 + SYS_SETSID = 147 + SYS_GETPGID = 151 + SYS_SETPRIVEXEC = 152 + SYS_PREAD = 153 + SYS_PWRITE = 154 + SYS_NFSSVC = 155 + SYS_STATFS = 157 + SYS_FSTATFS = 158 + SYS_UNMOUNT = 159 + SYS_GETFH = 161 + SYS_QUOTACTL = 165 + SYS_MOUNT = 167 + SYS_CSOPS = 169 + SYS_CSOPS_AUDITTOKEN = 170 + SYS_WAITID = 173 + SYS_KDEBUG_TRACE = 180 + SYS_SETGID = 181 + SYS_SETEGID = 182 + SYS_SETEUID = 183 + SYS_SIGRETURN = 184 + SYS_CHUD = 185 + SYS_FDATASYNC = 187 + SYS_STAT = 188 + SYS_FSTAT = 189 + SYS_LSTAT = 190 + SYS_PATHCONF = 191 + SYS_FPATHCONF = 192 + SYS_GETRLIMIT = 194 + SYS_SETRLIMIT = 195 + SYS_GETDIRENTRIES = 196 + SYS_MMAP = 197 + SYS_LSEEK = 199 + SYS_TRUNCATE = 200 + SYS_FTRUNCATE = 201 + SYS___SYSCTL = 202 + SYS_MLOCK = 203 + SYS_MUNLOCK = 204 + SYS_UNDELETE = 205 + SYS_ATSOCKET = 206 + SYS_ATGETMSG = 207 + SYS_ATPUTMSG = 208 + SYS_ATPSNDREQ = 209 + SYS_ATPSNDRSP = 210 + SYS_ATPGETREQ = 211 + SYS_ATPGETRSP = 212 + SYS_OPEN_DPROTECTED_NP = 216 + SYS_GETATTRLIST = 220 + SYS_SETATTRLIST = 221 + SYS_GETDIRENTRIESATTR = 222 + SYS_EXCHANGEDATA = 223 + SYS_SEARCHFS = 225 + SYS_DELETE = 226 + SYS_COPYFILE = 227 + SYS_FGETATTRLIST = 228 + SYS_FSETATTRLIST = 229 + SYS_POLL = 230 + SYS_WATCHEVENT = 231 + SYS_WAITEVENT = 232 + SYS_MODWATCH = 233 + SYS_GETXATTR = 234 + SYS_FGETXATTR = 235 + SYS_SETXATTR = 236 + SYS_FSETXATTR = 237 + SYS_REMOVEXATTR = 238 + SYS_FREMOVEXATTR = 239 + SYS_LISTXATTR = 240 + SYS_FLISTXATTR = 241 + SYS_FSCTL = 242 + SYS_INITGROUPS = 243 + SYS_POSIX_SPAWN = 244 + SYS_FFSCTL = 245 + SYS_NFSCLNT = 247 + SYS_FHOPEN = 248 + SYS_MINHERIT = 250 + SYS_SEMSYS = 251 + SYS_MSGSYS = 252 + SYS_SHMSYS = 253 + SYS_SEMCTL = 254 + SYS_SEMGET = 255 + SYS_SEMOP = 256 + SYS_MSGCTL = 258 + SYS_MSGGET = 259 + SYS_MSGSND = 260 + SYS_MSGRCV = 261 + SYS_SHMAT = 262 + SYS_SHMCTL = 263 + SYS_SHMDT = 264 + SYS_SHMGET = 265 + SYS_SHM_OPEN = 266 + SYS_SHM_UNLINK = 267 + SYS_SEM_OPEN = 268 + SYS_SEM_CLOSE = 269 + SYS_SEM_UNLINK = 270 + SYS_SEM_WAIT = 271 + SYS_SEM_TRYWAIT = 272 + SYS_SEM_POST = 273 + SYS_SEM_GETVALUE = 274 + SYS_SEM_INIT = 275 + SYS_SEM_DESTROY = 276 + SYS_OPEN_EXTENDED = 277 + SYS_UMASK_EXTENDED = 278 + SYS_STAT_EXTENDED = 279 + SYS_LSTAT_EXTENDED = 280 + SYS_FSTAT_EXTENDED = 281 + SYS_CHMOD_EXTENDED = 282 + SYS_FCHMOD_EXTENDED = 283 + SYS_ACCESS_EXTENDED = 284 + SYS_SETTID = 285 + SYS_GETTID = 286 + SYS_SETSGROUPS = 287 + SYS_GETSGROUPS = 288 + SYS_SETWGROUPS = 289 + SYS_GETWGROUPS = 290 + SYS_MKFIFO_EXTENDED = 291 + SYS_MKDIR_EXTENDED = 292 + SYS_IDENTITYSVC = 293 + SYS_SHARED_REGION_CHECK_NP = 294 + SYS_VM_PRESSURE_MONITOR = 296 + SYS_PSYNCH_RW_LONGRDLOCK = 297 + SYS_PSYNCH_RW_YIELDWRLOCK = 298 + SYS_PSYNCH_RW_DOWNGRADE = 299 + SYS_PSYNCH_RW_UPGRADE = 300 + SYS_PSYNCH_MUTEXWAIT = 301 + SYS_PSYNCH_MUTEXDROP = 302 + SYS_PSYNCH_CVBROAD = 303 + SYS_PSYNCH_CVSIGNAL = 304 + SYS_PSYNCH_CVWAIT = 305 + SYS_PSYNCH_RW_RDLOCK = 306 + SYS_PSYNCH_RW_WRLOCK = 307 + SYS_PSYNCH_RW_UNLOCK = 308 + SYS_PSYNCH_RW_UNLOCK2 = 309 + SYS_GETSID = 310 + SYS_SETTID_WITH_PID = 311 + SYS_PSYNCH_CVCLRPREPOST = 312 + SYS_AIO_FSYNC = 313 + SYS_AIO_RETURN = 314 + SYS_AIO_SUSPEND = 315 + SYS_AIO_CANCEL = 316 + SYS_AIO_ERROR = 317 + SYS_AIO_READ = 318 + SYS_AIO_WRITE = 319 + SYS_LIO_LISTIO = 320 + SYS_IOPOLICYSYS = 322 + SYS_PROCESS_POLICY = 323 + SYS_MLOCKALL = 324 + SYS_MUNLOCKALL = 325 + SYS_ISSETUGID = 327 + SYS___PTHREAD_KILL = 328 + SYS___PTHREAD_SIGMASK = 329 + SYS___SIGWAIT = 330 + SYS___DISABLE_THREADSIGNAL = 331 + SYS___PTHREAD_MARKCANCEL = 332 + SYS___PTHREAD_CANCELED = 333 + SYS___SEMWAIT_SIGNAL = 334 + SYS_PROC_INFO = 336 + SYS_SENDFILE = 337 + SYS_STAT64 = 338 + SYS_FSTAT64 = 339 + SYS_LSTAT64 = 340 + SYS_STAT64_EXTENDED = 341 + SYS_LSTAT64_EXTENDED = 342 + SYS_FSTAT64_EXTENDED = 343 + SYS_GETDIRENTRIES64 = 344 + SYS_STATFS64 = 345 + SYS_FSTATFS64 = 346 + SYS_GETFSSTAT64 = 347 + SYS___PTHREAD_CHDIR = 348 + SYS___PTHREAD_FCHDIR = 349 + SYS_AUDIT = 350 + SYS_AUDITON = 351 + SYS_GETAUID = 353 + SYS_SETAUID = 354 + SYS_GETAUDIT_ADDR = 357 + SYS_SETAUDIT_ADDR = 358 + SYS_AUDITCTL = 359 + SYS_BSDTHREAD_CREATE = 360 + SYS_BSDTHREAD_TERMINATE = 361 + SYS_KQUEUE = 362 + SYS_KEVENT = 363 + SYS_LCHOWN = 364 + SYS_STACK_SNAPSHOT = 365 + SYS_BSDTHREAD_REGISTER = 366 + SYS_WORKQ_OPEN = 367 + SYS_WORKQ_KERNRETURN = 368 + SYS_KEVENT64 = 369 + SYS___OLD_SEMWAIT_SIGNAL = 370 + SYS___OLD_SEMWAIT_SIGNAL_NOCANCEL = 371 + SYS_THREAD_SELFID = 372 + SYS_LEDGER = 373 + SYS___MAC_EXECVE = 380 + SYS___MAC_SYSCALL = 381 + SYS___MAC_GET_FILE = 382 + SYS___MAC_SET_FILE = 383 + SYS___MAC_GET_LINK = 384 + SYS___MAC_SET_LINK = 385 + SYS___MAC_GET_PROC = 386 + SYS___MAC_SET_PROC = 387 + SYS___MAC_GET_FD = 388 + SYS___MAC_SET_FD = 389 + SYS___MAC_GET_PID = 390 + SYS___MAC_GET_LCID = 391 + SYS___MAC_GET_LCTX = 392 + SYS___MAC_SET_LCTX = 393 + SYS_SETLCID = 394 + SYS_GETLCID = 395 + SYS_READ_NOCANCEL = 396 + SYS_WRITE_NOCANCEL = 397 + SYS_OPEN_NOCANCEL = 398 + SYS_CLOSE_NOCANCEL = 399 + SYS_WAIT4_NOCANCEL = 400 + SYS_RECVMSG_NOCANCEL = 401 + SYS_SENDMSG_NOCANCEL = 402 + SYS_RECVFROM_NOCANCEL = 403 + SYS_ACCEPT_NOCANCEL = 404 + SYS_MSYNC_NOCANCEL = 405 + SYS_FCNTL_NOCANCEL = 406 + SYS_SELECT_NOCANCEL = 407 + SYS_FSYNC_NOCANCEL = 408 + SYS_CONNECT_NOCANCEL = 409 + SYS_SIGSUSPEND_NOCANCEL = 410 + SYS_READV_NOCANCEL = 411 + SYS_WRITEV_NOCANCEL = 412 + SYS_SENDTO_NOCANCEL = 413 + SYS_PREAD_NOCANCEL = 414 + SYS_PWRITE_NOCANCEL = 415 + SYS_WAITID_NOCANCEL = 416 + SYS_POLL_NOCANCEL = 417 + SYS_MSGSND_NOCANCEL = 418 + SYS_MSGRCV_NOCANCEL = 419 + SYS_SEM_WAIT_NOCANCEL = 420 + SYS_AIO_SUSPEND_NOCANCEL = 421 + SYS___SIGWAIT_NOCANCEL = 422 + SYS___SEMWAIT_SIGNAL_NOCANCEL = 423 + SYS___MAC_MOUNT = 424 + SYS___MAC_GET_MOUNT = 425 + SYS___MAC_GETFSSTAT = 426 + SYS_FSGETPATH = 427 + SYS_AUDIT_SESSION_SELF = 428 + SYS_AUDIT_SESSION_JOIN = 429 + SYS_FILEPORT_MAKEPORT = 430 + SYS_FILEPORT_MAKEFD = 431 + SYS_AUDIT_SESSION_PORT = 432 + SYS_PID_SUSPEND = 433 + SYS_PID_RESUME = 434 + SYS_PID_HIBERNATE = 435 + SYS_PID_SHUTDOWN_SOCKETS = 436 + SYS_SHARED_REGION_MAP_AND_SLIDE_NP = 438 + SYS_KAS_INFO = 439 + SYS_MAXSYSCALL = 440 +) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm64.go new file mode 100644 index 0000000000..26677ebbf5 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_darwin_arm64.go @@ -0,0 +1,398 @@ +// mksysnum_darwin.pl /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.4.sdk/usr/include/sys/syscall.h +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build arm64,darwin + +package unix + +const ( + SYS_SYSCALL = 0 + SYS_EXIT = 1 + SYS_FORK = 2 + SYS_READ = 3 + SYS_WRITE = 4 + SYS_OPEN = 5 + SYS_CLOSE = 6 + SYS_WAIT4 = 7 + SYS_LINK = 9 + SYS_UNLINK = 10 + SYS_CHDIR = 12 + SYS_FCHDIR = 13 + SYS_MKNOD = 14 + SYS_CHMOD = 15 + SYS_CHOWN = 16 + SYS_GETFSSTAT = 18 + SYS_GETPID = 20 + SYS_SETUID = 23 + SYS_GETUID = 24 + SYS_GETEUID = 25 + SYS_PTRACE = 26 + SYS_RECVMSG = 27 + SYS_SENDMSG = 28 + SYS_RECVFROM = 29 + SYS_ACCEPT = 30 + SYS_GETPEERNAME = 31 + SYS_GETSOCKNAME = 32 + SYS_ACCESS = 33 + SYS_CHFLAGS = 34 + SYS_FCHFLAGS = 35 + SYS_SYNC = 36 + SYS_KILL = 37 + SYS_GETPPID = 39 + SYS_DUP = 41 + SYS_PIPE = 42 + SYS_GETEGID = 43 + SYS_SIGACTION = 46 + SYS_GETGID = 47 + SYS_SIGPROCMASK = 48 + SYS_GETLOGIN = 49 + SYS_SETLOGIN = 50 + SYS_ACCT = 51 + SYS_SIGPENDING = 52 + SYS_SIGALTSTACK = 53 + SYS_IOCTL = 54 + SYS_REBOOT = 55 + SYS_REVOKE = 56 + SYS_SYMLINK = 57 + SYS_READLINK = 58 + SYS_EXECVE = 59 + SYS_UMASK = 60 + SYS_CHROOT = 61 + SYS_MSYNC = 65 + SYS_VFORK = 66 + SYS_MUNMAP = 73 + SYS_MPROTECT = 74 + SYS_MADVISE = 75 + SYS_MINCORE = 78 + SYS_GETGROUPS = 79 + SYS_SETGROUPS = 80 + SYS_GETPGRP = 81 + SYS_SETPGID = 82 + SYS_SETITIMER = 83 + SYS_SWAPON = 85 + SYS_GETITIMER = 86 + SYS_GETDTABLESIZE = 89 + SYS_DUP2 = 90 + SYS_FCNTL = 92 + SYS_SELECT = 93 + SYS_FSYNC = 95 + SYS_SETPRIORITY = 96 + SYS_SOCKET = 97 + SYS_CONNECT = 98 + SYS_GETPRIORITY = 100 + SYS_BIND = 104 + SYS_SETSOCKOPT = 105 + SYS_LISTEN = 106 + SYS_SIGSUSPEND = 111 + SYS_GETTIMEOFDAY = 116 + SYS_GETRUSAGE = 117 + SYS_GETSOCKOPT = 118 + SYS_READV = 120 + SYS_WRITEV = 121 + SYS_SETTIMEOFDAY = 122 + SYS_FCHOWN = 123 + SYS_FCHMOD = 124 + SYS_SETREUID = 126 + SYS_SETREGID = 127 + SYS_RENAME = 128 + SYS_FLOCK = 131 + SYS_MKFIFO = 132 + SYS_SENDTO = 133 + SYS_SHUTDOWN = 134 + SYS_SOCKETPAIR = 135 + SYS_MKDIR = 136 + SYS_RMDIR = 137 + SYS_UTIMES = 138 + SYS_FUTIMES = 139 + SYS_ADJTIME = 140 + SYS_GETHOSTUUID = 142 + SYS_SETSID = 147 + SYS_GETPGID = 151 + SYS_SETPRIVEXEC = 152 + SYS_PREAD = 153 + SYS_PWRITE = 154 + SYS_NFSSVC = 155 + SYS_STATFS = 157 + SYS_FSTATFS = 158 + SYS_UNMOUNT = 159 + SYS_GETFH = 161 + SYS_QUOTACTL = 165 + SYS_MOUNT = 167 + SYS_CSOPS = 169 + SYS_CSOPS_AUDITTOKEN = 170 + SYS_WAITID = 173 + SYS_KDEBUG_TRACE64 = 179 + SYS_KDEBUG_TRACE = 180 + SYS_SETGID = 181 + SYS_SETEGID = 182 + SYS_SETEUID = 183 + SYS_SIGRETURN = 184 + SYS_CHUD = 185 + SYS_FDATASYNC = 187 + SYS_STAT = 188 + SYS_FSTAT = 189 + SYS_LSTAT = 190 + SYS_PATHCONF = 191 + SYS_FPATHCONF = 192 + SYS_GETRLIMIT = 194 + SYS_SETRLIMIT = 195 + SYS_GETDIRENTRIES = 196 + SYS_MMAP = 197 + SYS_LSEEK = 199 + SYS_TRUNCATE = 200 + SYS_FTRUNCATE = 201 + SYS_SYSCTL = 202 + SYS_MLOCK = 203 + SYS_MUNLOCK = 204 + SYS_UNDELETE = 205 + SYS_OPEN_DPROTECTED_NP = 216 + SYS_GETATTRLIST = 220 + SYS_SETATTRLIST = 221 + SYS_GETDIRENTRIESATTR = 222 + SYS_EXCHANGEDATA = 223 + SYS_SEARCHFS = 225 + SYS_DELETE = 226 + SYS_COPYFILE = 227 + SYS_FGETATTRLIST = 228 + SYS_FSETATTRLIST = 229 + SYS_POLL = 230 + SYS_WATCHEVENT = 231 + SYS_WAITEVENT = 232 + SYS_MODWATCH = 233 + SYS_GETXATTR = 234 + SYS_FGETXATTR = 235 + SYS_SETXATTR = 236 + SYS_FSETXATTR = 237 + SYS_REMOVEXATTR = 238 + SYS_FREMOVEXATTR = 239 + SYS_LISTXATTR = 240 + SYS_FLISTXATTR = 241 + SYS_FSCTL = 242 + SYS_INITGROUPS = 243 + SYS_POSIX_SPAWN = 244 + SYS_FFSCTL = 245 + SYS_NFSCLNT = 247 + SYS_FHOPEN = 248 + SYS_MINHERIT = 250 + SYS_SEMSYS = 251 + SYS_MSGSYS = 252 + SYS_SHMSYS = 253 + SYS_SEMCTL = 254 + SYS_SEMGET = 255 + SYS_SEMOP = 256 + SYS_MSGCTL = 258 + SYS_MSGGET = 259 + SYS_MSGSND = 260 + SYS_MSGRCV = 261 + SYS_SHMAT = 262 + SYS_SHMCTL = 263 + SYS_SHMDT = 264 + SYS_SHMGET = 265 + SYS_SHM_OPEN = 266 + SYS_SHM_UNLINK = 267 + SYS_SEM_OPEN = 268 + SYS_SEM_CLOSE = 269 + SYS_SEM_UNLINK = 270 + SYS_SEM_WAIT = 271 + SYS_SEM_TRYWAIT = 272 + SYS_SEM_POST = 273 + SYS_SYSCTLBYNAME = 274 + SYS_OPEN_EXTENDED = 277 + SYS_UMASK_EXTENDED = 278 + SYS_STAT_EXTENDED = 279 + SYS_LSTAT_EXTENDED = 280 + SYS_FSTAT_EXTENDED = 281 + SYS_CHMOD_EXTENDED = 282 + SYS_FCHMOD_EXTENDED = 283 + SYS_ACCESS_EXTENDED = 284 + SYS_SETTID = 285 + SYS_GETTID = 286 + SYS_SETSGROUPS = 287 + SYS_GETSGROUPS = 288 + SYS_SETWGROUPS = 289 + SYS_GETWGROUPS = 290 + SYS_MKFIFO_EXTENDED = 291 + SYS_MKDIR_EXTENDED = 292 + SYS_IDENTITYSVC = 293 + SYS_SHARED_REGION_CHECK_NP = 294 + SYS_VM_PRESSURE_MONITOR = 296 + SYS_PSYNCH_RW_LONGRDLOCK = 297 + SYS_PSYNCH_RW_YIELDWRLOCK = 298 + SYS_PSYNCH_RW_DOWNGRADE = 299 + SYS_PSYNCH_RW_UPGRADE = 300 + SYS_PSYNCH_MUTEXWAIT = 301 + SYS_PSYNCH_MUTEXDROP = 302 + SYS_PSYNCH_CVBROAD = 303 + SYS_PSYNCH_CVSIGNAL = 304 + SYS_PSYNCH_CVWAIT = 305 + SYS_PSYNCH_RW_RDLOCK = 306 + SYS_PSYNCH_RW_WRLOCK = 307 + SYS_PSYNCH_RW_UNLOCK = 308 + SYS_PSYNCH_RW_UNLOCK2 = 309 + SYS_GETSID = 310 + SYS_SETTID_WITH_PID = 311 + SYS_PSYNCH_CVCLRPREPOST = 312 + SYS_AIO_FSYNC = 313 + SYS_AIO_RETURN = 314 + SYS_AIO_SUSPEND = 315 + SYS_AIO_CANCEL = 316 + SYS_AIO_ERROR = 317 + SYS_AIO_READ = 318 + SYS_AIO_WRITE = 319 + SYS_LIO_LISTIO = 320 + SYS_IOPOLICYSYS = 322 + SYS_PROCESS_POLICY = 323 + SYS_MLOCKALL = 324 + SYS_MUNLOCKALL = 325 + SYS_ISSETUGID = 327 + SYS___PTHREAD_KILL = 328 + SYS___PTHREAD_SIGMASK = 329 + SYS___SIGWAIT = 330 + SYS___DISABLE_THREADSIGNAL = 331 + SYS___PTHREAD_MARKCANCEL = 332 + SYS___PTHREAD_CANCELED = 333 + SYS___SEMWAIT_SIGNAL = 334 + SYS_PROC_INFO = 336 + SYS_SENDFILE = 337 + SYS_STAT64 = 338 + SYS_FSTAT64 = 339 + SYS_LSTAT64 = 340 + SYS_STAT64_EXTENDED = 341 + SYS_LSTAT64_EXTENDED = 342 + SYS_FSTAT64_EXTENDED = 343 + SYS_GETDIRENTRIES64 = 344 + SYS_STATFS64 = 345 + SYS_FSTATFS64 = 346 + SYS_GETFSSTAT64 = 347 + SYS___PTHREAD_CHDIR = 348 + SYS___PTHREAD_FCHDIR = 349 + SYS_AUDIT = 350 + SYS_AUDITON = 351 + SYS_GETAUID = 353 + SYS_SETAUID = 354 + SYS_GETAUDIT_ADDR = 357 + SYS_SETAUDIT_ADDR = 358 + SYS_AUDITCTL = 359 + SYS_BSDTHREAD_CREATE = 360 + SYS_BSDTHREAD_TERMINATE = 361 + SYS_KQUEUE = 362 + SYS_KEVENT = 363 + SYS_LCHOWN = 364 + SYS_STACK_SNAPSHOT = 365 + SYS_BSDTHREAD_REGISTER = 366 + SYS_WORKQ_OPEN = 367 + SYS_WORKQ_KERNRETURN = 368 + SYS_KEVENT64 = 369 + SYS___OLD_SEMWAIT_SIGNAL = 370 + SYS___OLD_SEMWAIT_SIGNAL_NOCANCEL = 371 + SYS_THREAD_SELFID = 372 + SYS_LEDGER = 373 + SYS___MAC_EXECVE = 380 + SYS___MAC_SYSCALL = 381 + SYS___MAC_GET_FILE = 382 + SYS___MAC_SET_FILE = 383 + SYS___MAC_GET_LINK = 384 + SYS___MAC_SET_LINK = 385 + SYS___MAC_GET_PROC = 386 + SYS___MAC_SET_PROC = 387 + SYS___MAC_GET_FD = 388 + SYS___MAC_SET_FD = 389 + SYS___MAC_GET_PID = 390 + SYS___MAC_GET_LCID = 391 + SYS___MAC_GET_LCTX = 392 + SYS___MAC_SET_LCTX = 393 + SYS_SETLCID = 394 + SYS_GETLCID = 395 + SYS_READ_NOCANCEL = 396 + SYS_WRITE_NOCANCEL = 397 + SYS_OPEN_NOCANCEL = 398 + SYS_CLOSE_NOCANCEL = 399 + SYS_WAIT4_NOCANCEL = 400 + SYS_RECVMSG_NOCANCEL = 401 + SYS_SENDMSG_NOCANCEL = 402 + SYS_RECVFROM_NOCANCEL = 403 + SYS_ACCEPT_NOCANCEL = 404 + SYS_MSYNC_NOCANCEL = 405 + SYS_FCNTL_NOCANCEL = 406 + SYS_SELECT_NOCANCEL = 407 + SYS_FSYNC_NOCANCEL = 408 + SYS_CONNECT_NOCANCEL = 409 + SYS_SIGSUSPEND_NOCANCEL = 410 + SYS_READV_NOCANCEL = 411 + SYS_WRITEV_NOCANCEL = 412 + SYS_SENDTO_NOCANCEL = 413 + SYS_PREAD_NOCANCEL = 414 + SYS_PWRITE_NOCANCEL = 415 + SYS_WAITID_NOCANCEL = 416 + SYS_POLL_NOCANCEL = 417 + SYS_MSGSND_NOCANCEL = 418 + SYS_MSGRCV_NOCANCEL = 419 + SYS_SEM_WAIT_NOCANCEL = 420 + SYS_AIO_SUSPEND_NOCANCEL = 421 + SYS___SIGWAIT_NOCANCEL = 422 + SYS___SEMWAIT_SIGNAL_NOCANCEL = 423 + SYS___MAC_MOUNT = 424 + SYS___MAC_GET_MOUNT = 425 + SYS___MAC_GETFSSTAT = 426 + SYS_FSGETPATH = 427 + SYS_AUDIT_SESSION_SELF = 428 + SYS_AUDIT_SESSION_JOIN = 429 + SYS_FILEPORT_MAKEPORT = 430 + SYS_FILEPORT_MAKEFD = 431 + SYS_AUDIT_SESSION_PORT = 432 + SYS_PID_SUSPEND = 433 + SYS_PID_RESUME = 434 + SYS_PID_HIBERNATE = 435 + SYS_PID_SHUTDOWN_SOCKETS = 436 + SYS_SHARED_REGION_MAP_AND_SLIDE_NP = 438 + SYS_KAS_INFO = 439 + SYS_MEMORYSTATUS_CONTROL = 440 + SYS_GUARDED_OPEN_NP = 441 + SYS_GUARDED_CLOSE_NP = 442 + SYS_GUARDED_KQUEUE_NP = 443 + SYS_CHANGE_FDGUARD_NP = 444 + SYS_PROC_RLIMIT_CONTROL = 446 + SYS_CONNECTX = 447 + SYS_DISCONNECTX = 448 + SYS_PEELOFF = 449 + SYS_SOCKET_DELEGATE = 450 + SYS_TELEMETRY = 451 + SYS_PROC_UUID_POLICY = 452 + SYS_MEMORYSTATUS_GET_LEVEL = 453 + SYS_SYSTEM_OVERRIDE = 454 + SYS_VFS_PURGE = 455 + SYS_SFI_CTL = 456 + SYS_SFI_PIDCTL = 457 + SYS_COALITION = 458 + SYS_COALITION_INFO = 459 + SYS_NECP_MATCH_POLICY = 460 + SYS_GETATTRLISTBULK = 461 + SYS_OPENAT = 463 + SYS_OPENAT_NOCANCEL = 464 + SYS_RENAMEAT = 465 + SYS_FACCESSAT = 466 + SYS_FCHMODAT = 467 + SYS_FCHOWNAT = 468 + SYS_FSTATAT = 469 + SYS_FSTATAT64 = 470 + SYS_LINKAT = 471 + SYS_UNLINKAT = 472 + SYS_READLINKAT = 473 + SYS_SYMLINKAT = 474 + SYS_MKDIRAT = 475 + SYS_GETATTRLISTAT = 476 + SYS_PROC_TRACE_LOG = 477 + SYS_BSDTHREAD_CTL = 478 + SYS_OPENBYID_NP = 479 + SYS_RECVMSG_X = 480 + SYS_SENDMSG_X = 481 + SYS_THREAD_SELFUSAGE = 482 + SYS_CSRCTL = 483 + SYS_GUARDED_OPEN_DPROTECTED_NP = 484 + SYS_GUARDED_WRITE_NP = 485 + SYS_GUARDED_PWRITE_NP = 486 + SYS_GUARDED_WRITEV_NP = 487 + SYS_RENAME_EXT = 488 + SYS_MREMAP_ENCRYPTED = 489 + SYS_MAXSYSCALL = 490 +) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go new file mode 100644 index 0000000000..d6038fa9b0 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go @@ -0,0 +1,304 @@ +// mksysnum_dragonfly.pl +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build amd64,dragonfly + +package unix + +const ( + // SYS_NOSYS = 0; // { int nosys(void); } syscall nosys_args int + SYS_EXIT = 1 // { void exit(int rval); } + SYS_FORK = 2 // { int fork(void); } + SYS_READ = 3 // { ssize_t read(int fd, void *buf, size_t nbyte); } + SYS_WRITE = 4 // { ssize_t write(int fd, const void *buf, size_t nbyte); } + SYS_OPEN = 5 // { int open(char *path, int flags, int mode); } + SYS_CLOSE = 6 // { int close(int fd); } + SYS_WAIT4 = 7 // { int wait4(int pid, int *status, int options, \ + SYS_LINK = 9 // { int link(char *path, char *link); } + SYS_UNLINK = 10 // { int unlink(char *path); } + SYS_CHDIR = 12 // { int chdir(char *path); } + SYS_FCHDIR = 13 // { int fchdir(int fd); } + SYS_MKNOD = 14 // { int mknod(char *path, int mode, int dev); } + SYS_CHMOD = 15 // { int chmod(char *path, int mode); } + SYS_CHOWN = 16 // { int chown(char *path, int uid, int gid); } + SYS_OBREAK = 17 // { int obreak(char *nsize); } break obreak_args int + SYS_GETFSSTAT = 18 // { int getfsstat(struct statfs *buf, long bufsize, \ + SYS_GETPID = 20 // { pid_t getpid(void); } + SYS_MOUNT = 21 // { int mount(char *type, char *path, int flags, \ + SYS_UNMOUNT = 22 // { int unmount(char *path, int flags); } + SYS_SETUID = 23 // { int setuid(uid_t uid); } + SYS_GETUID = 24 // { uid_t getuid(void); } + SYS_GETEUID = 25 // { uid_t geteuid(void); } + SYS_PTRACE = 26 // { int ptrace(int req, pid_t pid, caddr_t addr, \ + SYS_RECVMSG = 27 // { int recvmsg(int s, struct msghdr *msg, int flags); } + SYS_SENDMSG = 28 // { int sendmsg(int s, caddr_t msg, int flags); } + SYS_RECVFROM = 29 // { int recvfrom(int s, caddr_t buf, size_t len, \ + SYS_ACCEPT = 30 // { int accept(int s, caddr_t name, int *anamelen); } + SYS_GETPEERNAME = 31 // { int getpeername(int fdes, caddr_t asa, int *alen); } + SYS_GETSOCKNAME = 32 // { int getsockname(int fdes, caddr_t asa, int *alen); } + SYS_ACCESS = 33 // { int access(char *path, int flags); } + SYS_CHFLAGS = 34 // { int chflags(char *path, int flags); } + SYS_FCHFLAGS = 35 // { int fchflags(int fd, int flags); } + SYS_SYNC = 36 // { int sync(void); } + SYS_KILL = 37 // { int kill(int pid, int signum); } + SYS_GETPPID = 39 // { pid_t getppid(void); } + SYS_DUP = 41 // { int dup(u_int fd); } + SYS_PIPE = 42 // { int pipe(void); } + SYS_GETEGID = 43 // { gid_t getegid(void); } + SYS_PROFIL = 44 // { int profil(caddr_t samples, size_t size, \ + SYS_KTRACE = 45 // { int ktrace(const char *fname, int ops, int facs, \ + SYS_GETGID = 47 // { gid_t getgid(void); } + SYS_GETLOGIN = 49 // { int getlogin(char *namebuf, u_int namelen); } + SYS_SETLOGIN = 50 // { int setlogin(char *namebuf); } + SYS_ACCT = 51 // { int acct(char *path); } + SYS_SIGALTSTACK = 53 // { int sigaltstack(stack_t *ss, stack_t *oss); } + SYS_IOCTL = 54 // { int ioctl(int fd, u_long com, caddr_t data); } + SYS_REBOOT = 55 // { int reboot(int opt); } + SYS_REVOKE = 56 // { int revoke(char *path); } + SYS_SYMLINK = 57 // { int symlink(char *path, char *link); } + SYS_READLINK = 58 // { int readlink(char *path, char *buf, int count); } + SYS_EXECVE = 59 // { int execve(char *fname, char **argv, char **envv); } + SYS_UMASK = 60 // { int umask(int newmask); } umask umask_args int + SYS_CHROOT = 61 // { int chroot(char *path); } + SYS_MSYNC = 65 // { int msync(void *addr, size_t len, int flags); } + SYS_VFORK = 66 // { pid_t vfork(void); } + SYS_SBRK = 69 // { int sbrk(int incr); } + SYS_SSTK = 70 // { int sstk(int incr); } + SYS_MUNMAP = 73 // { int munmap(void *addr, size_t len); } + SYS_MPROTECT = 74 // { int mprotect(void *addr, size_t len, int prot); } + SYS_MADVISE = 75 // { int madvise(void *addr, size_t len, int behav); } + SYS_MINCORE = 78 // { int mincore(const void *addr, size_t len, \ + SYS_GETGROUPS = 79 // { int getgroups(u_int gidsetsize, gid_t *gidset); } + SYS_SETGROUPS = 80 // { int setgroups(u_int gidsetsize, gid_t *gidset); } + SYS_GETPGRP = 81 // { int getpgrp(void); } + SYS_SETPGID = 82 // { int setpgid(int pid, int pgid); } + SYS_SETITIMER = 83 // { int setitimer(u_int which, struct itimerval *itv, \ + SYS_SWAPON = 85 // { int swapon(char *name); } + SYS_GETITIMER = 86 // { int getitimer(u_int which, struct itimerval *itv); } + SYS_GETDTABLESIZE = 89 // { int getdtablesize(void); } + SYS_DUP2 = 90 // { int dup2(u_int from, u_int to); } + SYS_FCNTL = 92 // { int fcntl(int fd, int cmd, long arg); } + SYS_SELECT = 93 // { int select(int nd, fd_set *in, fd_set *ou, \ + SYS_FSYNC = 95 // { int fsync(int fd); } + SYS_SETPRIORITY = 96 // { int setpriority(int which, int who, int prio); } + SYS_SOCKET = 97 // { int socket(int domain, int type, int protocol); } + SYS_CONNECT = 98 // { int connect(int s, caddr_t name, int namelen); } + SYS_GETPRIORITY = 100 // { int getpriority(int which, int who); } + SYS_BIND = 104 // { int bind(int s, caddr_t name, int namelen); } + SYS_SETSOCKOPT = 105 // { int setsockopt(int s, int level, int name, \ + SYS_LISTEN = 106 // { int listen(int s, int backlog); } + SYS_GETTIMEOFDAY = 116 // { int gettimeofday(struct timeval *tp, \ + SYS_GETRUSAGE = 117 // { int getrusage(int who, struct rusage *rusage); } + SYS_GETSOCKOPT = 118 // { int getsockopt(int s, int level, int name, \ + SYS_READV = 120 // { int readv(int fd, struct iovec *iovp, u_int iovcnt); } + SYS_WRITEV = 121 // { int writev(int fd, struct iovec *iovp, \ + SYS_SETTIMEOFDAY = 122 // { int settimeofday(struct timeval *tv, \ + SYS_FCHOWN = 123 // { int fchown(int fd, int uid, int gid); } + SYS_FCHMOD = 124 // { int fchmod(int fd, int mode); } + SYS_SETREUID = 126 // { int setreuid(int ruid, int euid); } + SYS_SETREGID = 127 // { int setregid(int rgid, int egid); } + SYS_RENAME = 128 // { int rename(char *from, char *to); } + SYS_FLOCK = 131 // { int flock(int fd, int how); } + SYS_MKFIFO = 132 // { int mkfifo(char *path, int mode); } + SYS_SENDTO = 133 // { int sendto(int s, caddr_t buf, size_t len, \ + SYS_SHUTDOWN = 134 // { int shutdown(int s, int how); } + SYS_SOCKETPAIR = 135 // { int socketpair(int domain, int type, int protocol, \ + SYS_MKDIR = 136 // { int mkdir(char *path, int mode); } + SYS_RMDIR = 137 // { int rmdir(char *path); } + SYS_UTIMES = 138 // { int utimes(char *path, struct timeval *tptr); } + SYS_ADJTIME = 140 // { int adjtime(struct timeval *delta, \ + SYS_SETSID = 147 // { int setsid(void); } + SYS_QUOTACTL = 148 // { int quotactl(char *path, int cmd, int uid, \ + SYS_STATFS = 157 // { int statfs(char *path, struct statfs *buf); } + SYS_FSTATFS = 158 // { int fstatfs(int fd, struct statfs *buf); } + SYS_GETFH = 161 // { int getfh(char *fname, struct fhandle *fhp); } + SYS_GETDOMAINNAME = 162 // { int getdomainname(char *domainname, int len); } + SYS_SETDOMAINNAME = 163 // { int setdomainname(char *domainname, int len); } + SYS_UNAME = 164 // { int uname(struct utsname *name); } + SYS_SYSARCH = 165 // { int sysarch(int op, char *parms); } + SYS_RTPRIO = 166 // { int rtprio(int function, pid_t pid, \ + SYS_EXTPREAD = 173 // { ssize_t extpread(int fd, void *buf, \ + SYS_EXTPWRITE = 174 // { ssize_t extpwrite(int fd, const void *buf, \ + SYS_NTP_ADJTIME = 176 // { int ntp_adjtime(struct timex *tp); } + SYS_SETGID = 181 // { int setgid(gid_t gid); } + SYS_SETEGID = 182 // { int setegid(gid_t egid); } + SYS_SETEUID = 183 // { int seteuid(uid_t euid); } + SYS_PATHCONF = 191 // { int pathconf(char *path, int name); } + SYS_FPATHCONF = 192 // { int fpathconf(int fd, int name); } + SYS_GETRLIMIT = 194 // { int getrlimit(u_int which, \ + SYS_SETRLIMIT = 195 // { int setrlimit(u_int which, \ + SYS_MMAP = 197 // { caddr_t mmap(caddr_t addr, size_t len, int prot, \ + // SYS_NOSYS = 198; // { int nosys(void); } __syscall __syscall_args int + SYS_LSEEK = 199 // { off_t lseek(int fd, int pad, off_t offset, \ + SYS_TRUNCATE = 200 // { int truncate(char *path, int pad, off_t length); } + SYS_FTRUNCATE = 201 // { int ftruncate(int fd, int pad, off_t length); } + SYS___SYSCTL = 202 // { int __sysctl(int *name, u_int namelen, void *old, \ + SYS_MLOCK = 203 // { int mlock(const void *addr, size_t len); } + SYS_MUNLOCK = 204 // { int munlock(const void *addr, size_t len); } + SYS_UNDELETE = 205 // { int undelete(char *path); } + SYS_FUTIMES = 206 // { int futimes(int fd, struct timeval *tptr); } + SYS_GETPGID = 207 // { int getpgid(pid_t pid); } + SYS_POLL = 209 // { int poll(struct pollfd *fds, u_int nfds, \ + SYS___SEMCTL = 220 // { int __semctl(int semid, int semnum, int cmd, \ + SYS_SEMGET = 221 // { int semget(key_t key, int nsems, int semflg); } + SYS_SEMOP = 222 // { int semop(int semid, struct sembuf *sops, \ + SYS_MSGCTL = 224 // { int msgctl(int msqid, int cmd, \ + SYS_MSGGET = 225 // { int msgget(key_t key, int msgflg); } + SYS_MSGSND = 226 // { int msgsnd(int msqid, void *msgp, size_t msgsz, \ + SYS_MSGRCV = 227 // { int msgrcv(int msqid, void *msgp, size_t msgsz, \ + SYS_SHMAT = 228 // { caddr_t shmat(int shmid, const void *shmaddr, \ + SYS_SHMCTL = 229 // { int shmctl(int shmid, int cmd, \ + SYS_SHMDT = 230 // { int shmdt(const void *shmaddr); } + SYS_SHMGET = 231 // { int shmget(key_t key, size_t size, int shmflg); } + SYS_CLOCK_GETTIME = 232 // { int clock_gettime(clockid_t clock_id, \ + SYS_CLOCK_SETTIME = 233 // { int clock_settime(clockid_t clock_id, \ + SYS_CLOCK_GETRES = 234 // { int clock_getres(clockid_t clock_id, \ + SYS_NANOSLEEP = 240 // { int nanosleep(const struct timespec *rqtp, \ + SYS_MINHERIT = 250 // { int minherit(void *addr, size_t len, int inherit); } + SYS_RFORK = 251 // { int rfork(int flags); } + SYS_OPENBSD_POLL = 252 // { int openbsd_poll(struct pollfd *fds, u_int nfds, \ + SYS_ISSETUGID = 253 // { int issetugid(void); } + SYS_LCHOWN = 254 // { int lchown(char *path, int uid, int gid); } + SYS_LCHMOD = 274 // { int lchmod(char *path, mode_t mode); } + SYS_LUTIMES = 276 // { int lutimes(char *path, struct timeval *tptr); } + SYS_EXTPREADV = 289 // { ssize_t extpreadv(int fd, struct iovec *iovp, \ + SYS_EXTPWRITEV = 290 // { ssize_t extpwritev(int fd, struct iovec *iovp,\ + SYS_FHSTATFS = 297 // { int fhstatfs(const struct fhandle *u_fhp, struct statfs *buf); } + SYS_FHOPEN = 298 // { int fhopen(const struct fhandle *u_fhp, int flags); } + SYS_MODNEXT = 300 // { int modnext(int modid); } + SYS_MODSTAT = 301 // { int modstat(int modid, struct module_stat* stat); } + SYS_MODFNEXT = 302 // { int modfnext(int modid); } + SYS_MODFIND = 303 // { int modfind(const char *name); } + SYS_KLDLOAD = 304 // { int kldload(const char *file); } + SYS_KLDUNLOAD = 305 // { int kldunload(int fileid); } + SYS_KLDFIND = 306 // { int kldfind(const char *file); } + SYS_KLDNEXT = 307 // { int kldnext(int fileid); } + SYS_KLDSTAT = 308 // { int kldstat(int fileid, struct kld_file_stat* stat); } + SYS_KLDFIRSTMOD = 309 // { int kldfirstmod(int fileid); } + SYS_GETSID = 310 // { int getsid(pid_t pid); } + SYS_SETRESUID = 311 // { int setresuid(uid_t ruid, uid_t euid, uid_t suid); } + SYS_SETRESGID = 312 // { int setresgid(gid_t rgid, gid_t egid, gid_t sgid); } + SYS_AIO_RETURN = 314 // { int aio_return(struct aiocb *aiocbp); } + SYS_AIO_SUSPEND = 315 // { int aio_suspend(struct aiocb * const * aiocbp, int nent, const struct timespec *timeout); } + SYS_AIO_CANCEL = 316 // { int aio_cancel(int fd, struct aiocb *aiocbp); } + SYS_AIO_ERROR = 317 // { int aio_error(struct aiocb *aiocbp); } + SYS_AIO_READ = 318 // { int aio_read(struct aiocb *aiocbp); } + SYS_AIO_WRITE = 319 // { int aio_write(struct aiocb *aiocbp); } + SYS_LIO_LISTIO = 320 // { int lio_listio(int mode, struct aiocb * const *acb_list, int nent, struct sigevent *sig); } + SYS_YIELD = 321 // { int yield(void); } + SYS_MLOCKALL = 324 // { int mlockall(int how); } + SYS_MUNLOCKALL = 325 // { int munlockall(void); } + SYS___GETCWD = 326 // { int __getcwd(u_char *buf, u_int buflen); } + SYS_SCHED_SETPARAM = 327 // { int sched_setparam (pid_t pid, const struct sched_param *param); } + SYS_SCHED_GETPARAM = 328 // { int sched_getparam (pid_t pid, struct sched_param *param); } + SYS_SCHED_SETSCHEDULER = 329 // { int sched_setscheduler (pid_t pid, int policy, const struct sched_param *param); } + SYS_SCHED_GETSCHEDULER = 330 // { int sched_getscheduler (pid_t pid); } + SYS_SCHED_YIELD = 331 // { int sched_yield (void); } + SYS_SCHED_GET_PRIORITY_MAX = 332 // { int sched_get_priority_max (int policy); } + SYS_SCHED_GET_PRIORITY_MIN = 333 // { int sched_get_priority_min (int policy); } + SYS_SCHED_RR_GET_INTERVAL = 334 // { int sched_rr_get_interval (pid_t pid, struct timespec *interval); } + SYS_UTRACE = 335 // { int utrace(const void *addr, size_t len); } + SYS_KLDSYM = 337 // { int kldsym(int fileid, int cmd, void *data); } + SYS_JAIL = 338 // { int jail(struct jail *jail); } + SYS_SIGPROCMASK = 340 // { int sigprocmask(int how, const sigset_t *set, \ + SYS_SIGSUSPEND = 341 // { int sigsuspend(const sigset_t *sigmask); } + SYS_SIGACTION = 342 // { int sigaction(int sig, const struct sigaction *act, \ + SYS_SIGPENDING = 343 // { int sigpending(sigset_t *set); } + SYS_SIGRETURN = 344 // { int sigreturn(ucontext_t *sigcntxp); } + SYS_SIGTIMEDWAIT = 345 // { int sigtimedwait(const sigset_t *set,\ + SYS_SIGWAITINFO = 346 // { int sigwaitinfo(const sigset_t *set,\ + SYS___ACL_GET_FILE = 347 // { int __acl_get_file(const char *path, \ + SYS___ACL_SET_FILE = 348 // { int __acl_set_file(const char *path, \ + SYS___ACL_GET_FD = 349 // { int __acl_get_fd(int filedes, acl_type_t type, \ + SYS___ACL_SET_FD = 350 // { int __acl_set_fd(int filedes, acl_type_t type, \ + SYS___ACL_DELETE_FILE = 351 // { int __acl_delete_file(const char *path, \ + SYS___ACL_DELETE_FD = 352 // { int __acl_delete_fd(int filedes, acl_type_t type); } + SYS___ACL_ACLCHECK_FILE = 353 // { int __acl_aclcheck_file(const char *path, \ + SYS___ACL_ACLCHECK_FD = 354 // { int __acl_aclcheck_fd(int filedes, acl_type_t type, \ + SYS_EXTATTRCTL = 355 // { int extattrctl(const char *path, int cmd, \ + SYS_EXTATTR_SET_FILE = 356 // { int extattr_set_file(const char *path, \ + SYS_EXTATTR_GET_FILE = 357 // { int extattr_get_file(const char *path, \ + SYS_EXTATTR_DELETE_FILE = 358 // { int extattr_delete_file(const char *path, \ + SYS_AIO_WAITCOMPLETE = 359 // { int aio_waitcomplete(struct aiocb **aiocbp, struct timespec *timeout); } + SYS_GETRESUID = 360 // { int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid); } + SYS_GETRESGID = 361 // { int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid); } + SYS_KQUEUE = 362 // { int kqueue(void); } + SYS_KEVENT = 363 // { int kevent(int fd, \ + SYS_SCTP_PEELOFF = 364 // { int sctp_peeloff(int sd, caddr_t name ); } + SYS_LCHFLAGS = 391 // { int lchflags(char *path, int flags); } + SYS_UUIDGEN = 392 // { int uuidgen(struct uuid *store, int count); } + SYS_SENDFILE = 393 // { int sendfile(int fd, int s, off_t offset, size_t nbytes, \ + SYS_VARSYM_SET = 450 // { int varsym_set(int level, const char *name, const char *data); } + SYS_VARSYM_GET = 451 // { int varsym_get(int mask, const char *wild, char *buf, int bufsize); } + SYS_VARSYM_LIST = 452 // { int varsym_list(int level, char *buf, int maxsize, int *marker); } + SYS_EXEC_SYS_REGISTER = 465 // { int exec_sys_register(void *entry); } + SYS_EXEC_SYS_UNREGISTER = 466 // { int exec_sys_unregister(int id); } + SYS_SYS_CHECKPOINT = 467 // { int sys_checkpoint(int type, int fd, pid_t pid, int retval); } + SYS_MOUNTCTL = 468 // { int mountctl(const char *path, int op, int fd, const void *ctl, int ctllen, void *buf, int buflen); } + SYS_UMTX_SLEEP = 469 // { int umtx_sleep(volatile const int *ptr, int value, int timeout); } + SYS_UMTX_WAKEUP = 470 // { int umtx_wakeup(volatile const int *ptr, int count); } + SYS_JAIL_ATTACH = 471 // { int jail_attach(int jid); } + SYS_SET_TLS_AREA = 472 // { int set_tls_area(int which, struct tls_info *info, size_t infosize); } + SYS_GET_TLS_AREA = 473 // { int get_tls_area(int which, struct tls_info *info, size_t infosize); } + SYS_CLOSEFROM = 474 // { int closefrom(int fd); } + SYS_STAT = 475 // { int stat(const char *path, struct stat *ub); } + SYS_FSTAT = 476 // { int fstat(int fd, struct stat *sb); } + SYS_LSTAT = 477 // { int lstat(const char *path, struct stat *ub); } + SYS_FHSTAT = 478 // { int fhstat(const struct fhandle *u_fhp, struct stat *sb); } + SYS_GETDIRENTRIES = 479 // { int getdirentries(int fd, char *buf, u_int count, \ + SYS_GETDENTS = 480 // { int getdents(int fd, char *buf, size_t count); } + SYS_USCHED_SET = 481 // { int usched_set(pid_t pid, int cmd, void *data, \ + SYS_EXTACCEPT = 482 // { int extaccept(int s, int flags, caddr_t name, int *anamelen); } + SYS_EXTCONNECT = 483 // { int extconnect(int s, int flags, caddr_t name, int namelen); } + SYS_MCONTROL = 485 // { int mcontrol(void *addr, size_t len, int behav, off_t value); } + SYS_VMSPACE_CREATE = 486 // { int vmspace_create(void *id, int type, void *data); } + SYS_VMSPACE_DESTROY = 487 // { int vmspace_destroy(void *id); } + SYS_VMSPACE_CTL = 488 // { int vmspace_ctl(void *id, int cmd, \ + SYS_VMSPACE_MMAP = 489 // { int vmspace_mmap(void *id, void *addr, size_t len, \ + SYS_VMSPACE_MUNMAP = 490 // { int vmspace_munmap(void *id, void *addr, \ + SYS_VMSPACE_MCONTROL = 491 // { int vmspace_mcontrol(void *id, void *addr, \ + SYS_VMSPACE_PREAD = 492 // { ssize_t vmspace_pread(void *id, void *buf, \ + SYS_VMSPACE_PWRITE = 493 // { ssize_t vmspace_pwrite(void *id, const void *buf, \ + SYS_EXTEXIT = 494 // { void extexit(int how, int status, void *addr); } + SYS_LWP_CREATE = 495 // { int lwp_create(struct lwp_params *params); } + SYS_LWP_GETTID = 496 // { lwpid_t lwp_gettid(void); } + SYS_LWP_KILL = 497 // { int lwp_kill(pid_t pid, lwpid_t tid, int signum); } + SYS_LWP_RTPRIO = 498 // { int lwp_rtprio(int function, pid_t pid, lwpid_t tid, struct rtprio *rtp); } + SYS_PSELECT = 499 // { int pselect(int nd, fd_set *in, fd_set *ou, \ + SYS_STATVFS = 500 // { int statvfs(const char *path, struct statvfs *buf); } + SYS_FSTATVFS = 501 // { int fstatvfs(int fd, struct statvfs *buf); } + SYS_FHSTATVFS = 502 // { int fhstatvfs(const struct fhandle *u_fhp, struct statvfs *buf); } + SYS_GETVFSSTAT = 503 // { int getvfsstat(struct statfs *buf, \ + SYS_OPENAT = 504 // { int openat(int fd, char *path, int flags, int mode); } + SYS_FSTATAT = 505 // { int fstatat(int fd, char *path, \ + SYS_FCHMODAT = 506 // { int fchmodat(int fd, char *path, int mode, \ + SYS_FCHOWNAT = 507 // { int fchownat(int fd, char *path, int uid, int gid, \ + SYS_UNLINKAT = 508 // { int unlinkat(int fd, char *path, int flags); } + SYS_FACCESSAT = 509 // { int faccessat(int fd, char *path, int amode, \ + SYS_MQ_OPEN = 510 // { mqd_t mq_open(const char * name, int oflag, \ + SYS_MQ_CLOSE = 511 // { int mq_close(mqd_t mqdes); } + SYS_MQ_UNLINK = 512 // { int mq_unlink(const char *name); } + SYS_MQ_GETATTR = 513 // { int mq_getattr(mqd_t mqdes, \ + SYS_MQ_SETATTR = 514 // { int mq_setattr(mqd_t mqdes, \ + SYS_MQ_NOTIFY = 515 // { int mq_notify(mqd_t mqdes, \ + SYS_MQ_SEND = 516 // { int mq_send(mqd_t mqdes, const char *msg_ptr, \ + SYS_MQ_RECEIVE = 517 // { ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, \ + SYS_MQ_TIMEDSEND = 518 // { int mq_timedsend(mqd_t mqdes, \ + SYS_MQ_TIMEDRECEIVE = 519 // { ssize_t mq_timedreceive(mqd_t mqdes, \ + SYS_IOPRIO_SET = 520 // { int ioprio_set(int which, int who, int prio); } + SYS_IOPRIO_GET = 521 // { int ioprio_get(int which, int who); } + SYS_CHROOT_KERNEL = 522 // { int chroot_kernel(char *path); } + SYS_RENAMEAT = 523 // { int renameat(int oldfd, char *old, int newfd, \ + SYS_MKDIRAT = 524 // { int mkdirat(int fd, char *path, mode_t mode); } + SYS_MKFIFOAT = 525 // { int mkfifoat(int fd, char *path, mode_t mode); } + SYS_MKNODAT = 526 // { int mknodat(int fd, char *path, mode_t mode, \ + SYS_READLINKAT = 527 // { int readlinkat(int fd, char *path, char *buf, \ + SYS_SYMLINKAT = 528 // { int symlinkat(char *path1, int fd, char *path2); } + SYS_SWAPOFF = 529 // { int swapoff(char *name); } + SYS_VQUOTACTL = 530 // { int vquotactl(const char *path, \ + SYS_LINKAT = 531 // { int linkat(int fd1, char *path1, int fd2, \ + SYS_EACCESS = 532 // { int eaccess(char *path, int flags); } + SYS_LPATHCONF = 533 // { int lpathconf(char *path, int name); } + SYS_VMM_GUEST_CTL = 534 // { int vmm_guest_ctl(int op, struct vmm_guest_options *options); } + SYS_VMM_GUEST_SYNC_ADDR = 535 // { int vmm_guest_sync_addr(long *dstaddr, long *srcaddr); } +) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_freebsd_386.go b/vendor/golang.org/x/sys/unix/zsysnum_freebsd_386.go new file mode 100644 index 0000000000..262a84536a --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_freebsd_386.go @@ -0,0 +1,351 @@ +// mksysnum_freebsd.pl +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build 386,freebsd + +package unix + +const ( + // SYS_NOSYS = 0; // { int nosys(void); } syscall nosys_args int + SYS_EXIT = 1 // { void sys_exit(int rval); } exit \ + SYS_FORK = 2 // { int fork(void); } + SYS_READ = 3 // { ssize_t read(int fd, void *buf, \ + SYS_WRITE = 4 // { ssize_t write(int fd, const void *buf, \ + SYS_OPEN = 5 // { int open(char *path, int flags, int mode); } + SYS_CLOSE = 6 // { int close(int fd); } + SYS_WAIT4 = 7 // { int wait4(int pid, int *status, \ + SYS_LINK = 9 // { int link(char *path, char *link); } + SYS_UNLINK = 10 // { int unlink(char *path); } + SYS_CHDIR = 12 // { int chdir(char *path); } + SYS_FCHDIR = 13 // { int fchdir(int fd); } + SYS_MKNOD = 14 // { int mknod(char *path, int mode, int dev); } + SYS_CHMOD = 15 // { int chmod(char *path, int mode); } + SYS_CHOWN = 16 // { int chown(char *path, int uid, int gid); } + SYS_OBREAK = 17 // { int obreak(char *nsize); } break \ + SYS_GETPID = 20 // { pid_t getpid(void); } + SYS_MOUNT = 21 // { int mount(char *type, char *path, \ + SYS_UNMOUNT = 22 // { int unmount(char *path, int flags); } + SYS_SETUID = 23 // { int setuid(uid_t uid); } + SYS_GETUID = 24 // { uid_t getuid(void); } + SYS_GETEUID = 25 // { uid_t geteuid(void); } + SYS_PTRACE = 26 // { int ptrace(int req, pid_t pid, \ + SYS_RECVMSG = 27 // { int recvmsg(int s, struct msghdr *msg, \ + SYS_SENDMSG = 28 // { int sendmsg(int s, struct msghdr *msg, \ + SYS_RECVFROM = 29 // { int recvfrom(int s, caddr_t buf, \ + SYS_ACCEPT = 30 // { int accept(int s, \ + SYS_GETPEERNAME = 31 // { int getpeername(int fdes, \ + SYS_GETSOCKNAME = 32 // { int getsockname(int fdes, \ + SYS_ACCESS = 33 // { int access(char *path, int amode); } + SYS_CHFLAGS = 34 // { int chflags(const char *path, u_long flags); } + SYS_FCHFLAGS = 35 // { int fchflags(int fd, u_long flags); } + SYS_SYNC = 36 // { int sync(void); } + SYS_KILL = 37 // { int kill(int pid, int signum); } + SYS_GETPPID = 39 // { pid_t getppid(void); } + SYS_DUP = 41 // { int dup(u_int fd); } + SYS_PIPE = 42 // { int pipe(void); } + SYS_GETEGID = 43 // { gid_t getegid(void); } + SYS_PROFIL = 44 // { int profil(caddr_t samples, size_t size, \ + SYS_KTRACE = 45 // { int ktrace(const char *fname, int ops, \ + SYS_GETGID = 47 // { gid_t getgid(void); } + SYS_GETLOGIN = 49 // { int getlogin(char *namebuf, u_int \ + SYS_SETLOGIN = 50 // { int setlogin(char *namebuf); } + SYS_ACCT = 51 // { int acct(char *path); } + SYS_SIGALTSTACK = 53 // { int sigaltstack(stack_t *ss, \ + SYS_IOCTL = 54 // { int ioctl(int fd, u_long com, \ + SYS_REBOOT = 55 // { int reboot(int opt); } + SYS_REVOKE = 56 // { int revoke(char *path); } + SYS_SYMLINK = 57 // { int symlink(char *path, char *link); } + SYS_READLINK = 58 // { ssize_t readlink(char *path, char *buf, \ + SYS_EXECVE = 59 // { int execve(char *fname, char **argv, \ + SYS_UMASK = 60 // { int umask(int newmask); } umask umask_args \ + SYS_CHROOT = 61 // { int chroot(char *path); } + SYS_MSYNC = 65 // { int msync(void *addr, size_t len, \ + SYS_VFORK = 66 // { int vfork(void); } + SYS_SBRK = 69 // { int sbrk(int incr); } + SYS_SSTK = 70 // { int sstk(int incr); } + SYS_OVADVISE = 72 // { int ovadvise(int anom); } vadvise \ + SYS_MUNMAP = 73 // { int munmap(void *addr, size_t len); } + SYS_MPROTECT = 74 // { int mprotect(const void *addr, size_t len, \ + SYS_MADVISE = 75 // { int madvise(void *addr, size_t len, \ + SYS_MINCORE = 78 // { int mincore(const void *addr, size_t len, \ + SYS_GETGROUPS = 79 // { int getgroups(u_int gidsetsize, \ + SYS_SETGROUPS = 80 // { int setgroups(u_int gidsetsize, \ + SYS_GETPGRP = 81 // { int getpgrp(void); } + SYS_SETPGID = 82 // { int setpgid(int pid, int pgid); } + SYS_SETITIMER = 83 // { int setitimer(u_int which, struct \ + SYS_SWAPON = 85 // { int swapon(char *name); } + SYS_GETITIMER = 86 // { int getitimer(u_int which, \ + SYS_GETDTABLESIZE = 89 // { int getdtablesize(void); } + SYS_DUP2 = 90 // { int dup2(u_int from, u_int to); } + SYS_FCNTL = 92 // { int fcntl(int fd, int cmd, long arg); } + SYS_SELECT = 93 // { int select(int nd, fd_set *in, fd_set *ou, \ + SYS_FSYNC = 95 // { int fsync(int fd); } + SYS_SETPRIORITY = 96 // { int setpriority(int which, int who, \ + SYS_SOCKET = 97 // { int socket(int domain, int type, \ + SYS_CONNECT = 98 // { int connect(int s, caddr_t name, \ + SYS_GETPRIORITY = 100 // { int getpriority(int which, int who); } + SYS_BIND = 104 // { int bind(int s, caddr_t name, \ + SYS_SETSOCKOPT = 105 // { int setsockopt(int s, int level, int name, \ + SYS_LISTEN = 106 // { int listen(int s, int backlog); } + SYS_GETTIMEOFDAY = 116 // { int gettimeofday(struct timeval *tp, \ + SYS_GETRUSAGE = 117 // { int getrusage(int who, \ + SYS_GETSOCKOPT = 118 // { int getsockopt(int s, int level, int name, \ + SYS_READV = 120 // { int readv(int fd, struct iovec *iovp, \ + SYS_WRITEV = 121 // { int writev(int fd, struct iovec *iovp, \ + SYS_SETTIMEOFDAY = 122 // { int settimeofday(struct timeval *tv, \ + SYS_FCHOWN = 123 // { int fchown(int fd, int uid, int gid); } + SYS_FCHMOD = 124 // { int fchmod(int fd, int mode); } + SYS_SETREUID = 126 // { int setreuid(int ruid, int euid); } + SYS_SETREGID = 127 // { int setregid(int rgid, int egid); } + SYS_RENAME = 128 // { int rename(char *from, char *to); } + SYS_FLOCK = 131 // { int flock(int fd, int how); } + SYS_MKFIFO = 132 // { int mkfifo(char *path, int mode); } + SYS_SENDTO = 133 // { int sendto(int s, caddr_t buf, size_t len, \ + SYS_SHUTDOWN = 134 // { int shutdown(int s, int how); } + SYS_SOCKETPAIR = 135 // { int socketpair(int domain, int type, \ + SYS_MKDIR = 136 // { int mkdir(char *path, int mode); } + SYS_RMDIR = 137 // { int rmdir(char *path); } + SYS_UTIMES = 138 // { int utimes(char *path, \ + SYS_ADJTIME = 140 // { int adjtime(struct timeval *delta, \ + SYS_SETSID = 147 // { int setsid(void); } + SYS_QUOTACTL = 148 // { int quotactl(char *path, int cmd, int uid, \ + SYS_LGETFH = 160 // { int lgetfh(char *fname, \ + SYS_GETFH = 161 // { int getfh(char *fname, \ + SYS_SYSARCH = 165 // { int sysarch(int op, char *parms); } + SYS_RTPRIO = 166 // { int rtprio(int function, pid_t pid, \ + SYS_FREEBSD6_PREAD = 173 // { ssize_t freebsd6_pread(int fd, void *buf, \ + SYS_FREEBSD6_PWRITE = 174 // { ssize_t freebsd6_pwrite(int fd, \ + SYS_SETFIB = 175 // { int setfib(int fibnum); } + SYS_NTP_ADJTIME = 176 // { int ntp_adjtime(struct timex *tp); } + SYS_SETGID = 181 // { int setgid(gid_t gid); } + SYS_SETEGID = 182 // { int setegid(gid_t egid); } + SYS_SETEUID = 183 // { int seteuid(uid_t euid); } + SYS_STAT = 188 // { int stat(char *path, struct stat *ub); } + SYS_FSTAT = 189 // { int fstat(int fd, struct stat *sb); } + SYS_LSTAT = 190 // { int lstat(char *path, struct stat *ub); } + SYS_PATHCONF = 191 // { int pathconf(char *path, int name); } + SYS_FPATHCONF = 192 // { int fpathconf(int fd, int name); } + SYS_GETRLIMIT = 194 // { int getrlimit(u_int which, \ + SYS_SETRLIMIT = 195 // { int setrlimit(u_int which, \ + SYS_GETDIRENTRIES = 196 // { int getdirentries(int fd, char *buf, \ + SYS_FREEBSD6_MMAP = 197 // { caddr_t freebsd6_mmap(caddr_t addr, \ + SYS_FREEBSD6_LSEEK = 199 // { off_t freebsd6_lseek(int fd, int pad, \ + SYS_FREEBSD6_TRUNCATE = 200 // { int freebsd6_truncate(char *path, int pad, \ + SYS_FREEBSD6_FTRUNCATE = 201 // { int freebsd6_ftruncate(int fd, int pad, \ + SYS___SYSCTL = 202 // { int __sysctl(int *name, u_int namelen, \ + SYS_MLOCK = 203 // { int mlock(const void *addr, size_t len); } + SYS_MUNLOCK = 204 // { int munlock(const void *addr, size_t len); } + SYS_UNDELETE = 205 // { int undelete(char *path); } + SYS_FUTIMES = 206 // { int futimes(int fd, struct timeval *tptr); } + SYS_GETPGID = 207 // { int getpgid(pid_t pid); } + SYS_POLL = 209 // { int poll(struct pollfd *fds, u_int nfds, \ + SYS_CLOCK_GETTIME = 232 // { int clock_gettime(clockid_t clock_id, \ + SYS_CLOCK_SETTIME = 233 // { int clock_settime( \ + SYS_CLOCK_GETRES = 234 // { int clock_getres(clockid_t clock_id, \ + SYS_KTIMER_CREATE = 235 // { int ktimer_create(clockid_t clock_id, \ + SYS_KTIMER_DELETE = 236 // { int ktimer_delete(int timerid); } + SYS_KTIMER_SETTIME = 237 // { int ktimer_settime(int timerid, int flags, \ + SYS_KTIMER_GETTIME = 238 // { int ktimer_gettime(int timerid, struct \ + SYS_KTIMER_GETOVERRUN = 239 // { int ktimer_getoverrun(int timerid); } + SYS_NANOSLEEP = 240 // { int nanosleep(const struct timespec *rqtp, \ + SYS_FFCLOCK_GETCOUNTER = 241 // { int ffclock_getcounter(ffcounter *ffcount); } + SYS_FFCLOCK_SETESTIMATE = 242 // { int ffclock_setestimate( \ + SYS_FFCLOCK_GETESTIMATE = 243 // { int ffclock_getestimate( \ + SYS_CLOCK_GETCPUCLOCKID2 = 247 // { int clock_getcpuclockid2(id_t id,\ + SYS_NTP_GETTIME = 248 // { int ntp_gettime(struct ntptimeval *ntvp); } + SYS_MINHERIT = 250 // { int minherit(void *addr, size_t len, \ + SYS_RFORK = 251 // { int rfork(int flags); } + SYS_OPENBSD_POLL = 252 // { int openbsd_poll(struct pollfd *fds, \ + SYS_ISSETUGID = 253 // { int issetugid(void); } + SYS_LCHOWN = 254 // { int lchown(char *path, int uid, int gid); } + SYS_GETDENTS = 272 // { int getdents(int fd, char *buf, \ + SYS_LCHMOD = 274 // { int lchmod(char *path, mode_t mode); } + SYS_LUTIMES = 276 // { int lutimes(char *path, \ + SYS_NSTAT = 278 // { int nstat(char *path, struct nstat *ub); } + SYS_NFSTAT = 279 // { int nfstat(int fd, struct nstat *sb); } + SYS_NLSTAT = 280 // { int nlstat(char *path, struct nstat *ub); } + SYS_PREADV = 289 // { ssize_t preadv(int fd, struct iovec *iovp, \ + SYS_PWRITEV = 290 // { ssize_t pwritev(int fd, struct iovec *iovp, \ + SYS_FHOPEN = 298 // { int fhopen(const struct fhandle *u_fhp, \ + SYS_FHSTAT = 299 // { int fhstat(const struct fhandle *u_fhp, \ + SYS_MODNEXT = 300 // { int modnext(int modid); } + SYS_MODSTAT = 301 // { int modstat(int modid, \ + SYS_MODFNEXT = 302 // { int modfnext(int modid); } + SYS_MODFIND = 303 // { int modfind(const char *name); } + SYS_KLDLOAD = 304 // { int kldload(const char *file); } + SYS_KLDUNLOAD = 305 // { int kldunload(int fileid); } + SYS_KLDFIND = 306 // { int kldfind(const char *file); } + SYS_KLDNEXT = 307 // { int kldnext(int fileid); } + SYS_KLDSTAT = 308 // { int kldstat(int fileid, struct \ + SYS_KLDFIRSTMOD = 309 // { int kldfirstmod(int fileid); } + SYS_GETSID = 310 // { int getsid(pid_t pid); } + SYS_SETRESUID = 311 // { int setresuid(uid_t ruid, uid_t euid, \ + SYS_SETRESGID = 312 // { int setresgid(gid_t rgid, gid_t egid, \ + SYS_YIELD = 321 // { int yield(void); } + SYS_MLOCKALL = 324 // { int mlockall(int how); } + SYS_MUNLOCKALL = 325 // { int munlockall(void); } + SYS___GETCWD = 326 // { int __getcwd(char *buf, u_int buflen); } + SYS_SCHED_SETPARAM = 327 // { int sched_setparam (pid_t pid, \ + SYS_SCHED_GETPARAM = 328 // { int sched_getparam (pid_t pid, struct \ + SYS_SCHED_SETSCHEDULER = 329 // { int sched_setscheduler (pid_t pid, int \ + SYS_SCHED_GETSCHEDULER = 330 // { int sched_getscheduler (pid_t pid); } + SYS_SCHED_YIELD = 331 // { int sched_yield (void); } + SYS_SCHED_GET_PRIORITY_MAX = 332 // { int sched_get_priority_max (int policy); } + SYS_SCHED_GET_PRIORITY_MIN = 333 // { int sched_get_priority_min (int policy); } + SYS_SCHED_RR_GET_INTERVAL = 334 // { int sched_rr_get_interval (pid_t pid, \ + SYS_UTRACE = 335 // { int utrace(const void *addr, size_t len); } + SYS_KLDSYM = 337 // { int kldsym(int fileid, int cmd, \ + SYS_JAIL = 338 // { int jail(struct jail *jail); } + SYS_SIGPROCMASK = 340 // { int sigprocmask(int how, \ + SYS_SIGSUSPEND = 341 // { int sigsuspend(const sigset_t *sigmask); } + SYS_SIGPENDING = 343 // { int sigpending(sigset_t *set); } + SYS_SIGTIMEDWAIT = 345 // { int sigtimedwait(const sigset_t *set, \ + SYS_SIGWAITINFO = 346 // { int sigwaitinfo(const sigset_t *set, \ + SYS___ACL_GET_FILE = 347 // { int __acl_get_file(const char *path, \ + SYS___ACL_SET_FILE = 348 // { int __acl_set_file(const char *path, \ + SYS___ACL_GET_FD = 349 // { int __acl_get_fd(int filedes, \ + SYS___ACL_SET_FD = 350 // { int __acl_set_fd(int filedes, \ + SYS___ACL_DELETE_FILE = 351 // { int __acl_delete_file(const char *path, \ + SYS___ACL_DELETE_FD = 352 // { int __acl_delete_fd(int filedes, \ + SYS___ACL_ACLCHECK_FILE = 353 // { int __acl_aclcheck_file(const char *path, \ + SYS___ACL_ACLCHECK_FD = 354 // { int __acl_aclcheck_fd(int filedes, \ + SYS_EXTATTRCTL = 355 // { int extattrctl(const char *path, int cmd, \ + SYS_EXTATTR_SET_FILE = 356 // { ssize_t extattr_set_file( \ + SYS_EXTATTR_GET_FILE = 357 // { ssize_t extattr_get_file( \ + SYS_EXTATTR_DELETE_FILE = 358 // { int extattr_delete_file(const char *path, \ + SYS_GETRESUID = 360 // { int getresuid(uid_t *ruid, uid_t *euid, \ + SYS_GETRESGID = 361 // { int getresgid(gid_t *rgid, gid_t *egid, \ + SYS_KQUEUE = 362 // { int kqueue(void); } + SYS_KEVENT = 363 // { int kevent(int fd, \ + SYS_EXTATTR_SET_FD = 371 // { ssize_t extattr_set_fd(int fd, \ + SYS_EXTATTR_GET_FD = 372 // { ssize_t extattr_get_fd(int fd, \ + SYS_EXTATTR_DELETE_FD = 373 // { int extattr_delete_fd(int fd, \ + SYS___SETUGID = 374 // { int __setugid(int flag); } + SYS_EACCESS = 376 // { int eaccess(char *path, int amode); } + SYS_NMOUNT = 378 // { int nmount(struct iovec *iovp, \ + SYS___MAC_GET_PROC = 384 // { int __mac_get_proc(struct mac *mac_p); } + SYS___MAC_SET_PROC = 385 // { int __mac_set_proc(struct mac *mac_p); } + SYS___MAC_GET_FD = 386 // { int __mac_get_fd(int fd, \ + SYS___MAC_GET_FILE = 387 // { int __mac_get_file(const char *path_p, \ + SYS___MAC_SET_FD = 388 // { int __mac_set_fd(int fd, \ + SYS___MAC_SET_FILE = 389 // { int __mac_set_file(const char *path_p, \ + SYS_KENV = 390 // { int kenv(int what, const char *name, \ + SYS_LCHFLAGS = 391 // { int lchflags(const char *path, \ + SYS_UUIDGEN = 392 // { int uuidgen(struct uuid *store, \ + SYS_SENDFILE = 393 // { int sendfile(int fd, int s, off_t offset, \ + SYS_MAC_SYSCALL = 394 // { int mac_syscall(const char *policy, \ + SYS_GETFSSTAT = 395 // { int getfsstat(struct statfs *buf, \ + SYS_STATFS = 396 // { int statfs(char *path, \ + SYS_FSTATFS = 397 // { int fstatfs(int fd, struct statfs *buf); } + SYS_FHSTATFS = 398 // { int fhstatfs(const struct fhandle *u_fhp, \ + SYS___MAC_GET_PID = 409 // { int __mac_get_pid(pid_t pid, \ + SYS___MAC_GET_LINK = 410 // { int __mac_get_link(const char *path_p, \ + SYS___MAC_SET_LINK = 411 // { int __mac_set_link(const char *path_p, \ + SYS_EXTATTR_SET_LINK = 412 // { ssize_t extattr_set_link( \ + SYS_EXTATTR_GET_LINK = 413 // { ssize_t extattr_get_link( \ + SYS_EXTATTR_DELETE_LINK = 414 // { int extattr_delete_link( \ + SYS___MAC_EXECVE = 415 // { int __mac_execve(char *fname, char **argv, \ + SYS_SIGACTION = 416 // { int sigaction(int sig, \ + SYS_SIGRETURN = 417 // { int sigreturn( \ + SYS_GETCONTEXT = 421 // { int getcontext(struct __ucontext *ucp); } + SYS_SETCONTEXT = 422 // { int setcontext( \ + SYS_SWAPCONTEXT = 423 // { int swapcontext(struct __ucontext *oucp, \ + SYS_SWAPOFF = 424 // { int swapoff(const char *name); } + SYS___ACL_GET_LINK = 425 // { int __acl_get_link(const char *path, \ + SYS___ACL_SET_LINK = 426 // { int __acl_set_link(const char *path, \ + SYS___ACL_DELETE_LINK = 427 // { int __acl_delete_link(const char *path, \ + SYS___ACL_ACLCHECK_LINK = 428 // { int __acl_aclcheck_link(const char *path, \ + SYS_SIGWAIT = 429 // { int sigwait(const sigset_t *set, \ + SYS_THR_CREATE = 430 // { int thr_create(ucontext_t *ctx, long *id, \ + SYS_THR_EXIT = 431 // { void thr_exit(long *state); } + SYS_THR_SELF = 432 // { int thr_self(long *id); } + SYS_THR_KILL = 433 // { int thr_kill(long id, int sig); } + SYS__UMTX_LOCK = 434 // { int _umtx_lock(struct umtx *umtx); } + SYS__UMTX_UNLOCK = 435 // { int _umtx_unlock(struct umtx *umtx); } + SYS_JAIL_ATTACH = 436 // { int jail_attach(int jid); } + SYS_EXTATTR_LIST_FD = 437 // { ssize_t extattr_list_fd(int fd, \ + SYS_EXTATTR_LIST_FILE = 438 // { ssize_t extattr_list_file( \ + SYS_EXTATTR_LIST_LINK = 439 // { ssize_t extattr_list_link( \ + SYS_THR_SUSPEND = 442 // { int thr_suspend( \ + SYS_THR_WAKE = 443 // { int thr_wake(long id); } + SYS_KLDUNLOADF = 444 // { int kldunloadf(int fileid, int flags); } + SYS_AUDIT = 445 // { int audit(const void *record, \ + SYS_AUDITON = 446 // { int auditon(int cmd, void *data, \ + SYS_GETAUID = 447 // { int getauid(uid_t *auid); } + SYS_SETAUID = 448 // { int setauid(uid_t *auid); } + SYS_GETAUDIT = 449 // { int getaudit(struct auditinfo *auditinfo); } + SYS_SETAUDIT = 450 // { int setaudit(struct auditinfo *auditinfo); } + SYS_GETAUDIT_ADDR = 451 // { int getaudit_addr( \ + SYS_SETAUDIT_ADDR = 452 // { int setaudit_addr( \ + SYS_AUDITCTL = 453 // { int auditctl(char *path); } + SYS__UMTX_OP = 454 // { int _umtx_op(void *obj, int op, \ + SYS_THR_NEW = 455 // { int thr_new(struct thr_param *param, \ + SYS_SIGQUEUE = 456 // { int sigqueue(pid_t pid, int signum, void *value); } + SYS_ABORT2 = 463 // { int abort2(const char *why, int nargs, void **args); } + SYS_THR_SET_NAME = 464 // { int thr_set_name(long id, const char *name); } + SYS_RTPRIO_THREAD = 466 // { int rtprio_thread(int function, \ + SYS_SCTP_PEELOFF = 471 // { int sctp_peeloff(int sd, uint32_t name); } + SYS_SCTP_GENERIC_SENDMSG = 472 // { int sctp_generic_sendmsg(int sd, caddr_t msg, int mlen, \ + SYS_SCTP_GENERIC_SENDMSG_IOV = 473 // { int sctp_generic_sendmsg_iov(int sd, struct iovec *iov, int iovlen, \ + SYS_SCTP_GENERIC_RECVMSG = 474 // { int sctp_generic_recvmsg(int sd, struct iovec *iov, int iovlen, \ + SYS_PREAD = 475 // { ssize_t pread(int fd, void *buf, \ + SYS_PWRITE = 476 // { ssize_t pwrite(int fd, const void *buf, \ + SYS_MMAP = 477 // { caddr_t mmap(caddr_t addr, size_t len, \ + SYS_LSEEK = 478 // { off_t lseek(int fd, off_t offset, \ + SYS_TRUNCATE = 479 // { int truncate(char *path, off_t length); } + SYS_FTRUNCATE = 480 // { int ftruncate(int fd, off_t length); } + SYS_THR_KILL2 = 481 // { int thr_kill2(pid_t pid, long id, int sig); } + SYS_SHM_OPEN = 482 // { int shm_open(const char *path, int flags, \ + SYS_SHM_UNLINK = 483 // { int shm_unlink(const char *path); } + SYS_CPUSET = 484 // { int cpuset(cpusetid_t *setid); } + SYS_CPUSET_SETID = 485 // { int cpuset_setid(cpuwhich_t which, id_t id, \ + SYS_CPUSET_GETID = 486 // { int cpuset_getid(cpulevel_t level, \ + SYS_CPUSET_GETAFFINITY = 487 // { int cpuset_getaffinity(cpulevel_t level, \ + SYS_CPUSET_SETAFFINITY = 488 // { int cpuset_setaffinity(cpulevel_t level, \ + SYS_FACCESSAT = 489 // { int faccessat(int fd, char *path, int amode, \ + SYS_FCHMODAT = 490 // { int fchmodat(int fd, char *path, mode_t mode, \ + SYS_FCHOWNAT = 491 // { int fchownat(int fd, char *path, uid_t uid, \ + SYS_FEXECVE = 492 // { int fexecve(int fd, char **argv, \ + SYS_FSTATAT = 493 // { int fstatat(int fd, char *path, \ + SYS_FUTIMESAT = 494 // { int futimesat(int fd, char *path, \ + SYS_LINKAT = 495 // { int linkat(int fd1, char *path1, int fd2, \ + SYS_MKDIRAT = 496 // { int mkdirat(int fd, char *path, mode_t mode); } + SYS_MKFIFOAT = 497 // { int mkfifoat(int fd, char *path, mode_t mode); } + SYS_MKNODAT = 498 // { int mknodat(int fd, char *path, mode_t mode, \ + SYS_OPENAT = 499 // { int openat(int fd, char *path, int flag, \ + SYS_READLINKAT = 500 // { int readlinkat(int fd, char *path, char *buf, \ + SYS_RENAMEAT = 501 // { int renameat(int oldfd, char *old, int newfd, \ + SYS_SYMLINKAT = 502 // { int symlinkat(char *path1, int fd, \ + SYS_UNLINKAT = 503 // { int unlinkat(int fd, char *path, int flag); } + SYS_POSIX_OPENPT = 504 // { int posix_openpt(int flags); } + SYS_JAIL_GET = 506 // { int jail_get(struct iovec *iovp, \ + SYS_JAIL_SET = 507 // { int jail_set(struct iovec *iovp, \ + SYS_JAIL_REMOVE = 508 // { int jail_remove(int jid); } + SYS_CLOSEFROM = 509 // { int closefrom(int lowfd); } + SYS_LPATHCONF = 513 // { int lpathconf(char *path, int name); } + SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); } + SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \ + SYS_CAP_ENTER = 516 // { int cap_enter(void); } + SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); } + SYS_PDFORK = 518 // { int pdfork(int *fdp, int flags); } + SYS_PDKILL = 519 // { int pdkill(int fd, int signum); } + SYS_PDGETPID = 520 // { int pdgetpid(int fd, pid_t *pidp); } + SYS_PSELECT = 522 // { int pselect(int nd, fd_set *in, \ + SYS_GETLOGINCLASS = 523 // { int getloginclass(char *namebuf, \ + SYS_SETLOGINCLASS = 524 // { int setloginclass(const char *namebuf); } + SYS_RCTL_GET_RACCT = 525 // { int rctl_get_racct(const void *inbufp, \ + SYS_RCTL_GET_RULES = 526 // { int rctl_get_rules(const void *inbufp, \ + SYS_RCTL_GET_LIMITS = 527 // { int rctl_get_limits(const void *inbufp, \ + SYS_RCTL_ADD_RULE = 528 // { int rctl_add_rule(const void *inbufp, \ + SYS_RCTL_REMOVE_RULE = 529 // { int rctl_remove_rule(const void *inbufp, \ + SYS_POSIX_FALLOCATE = 530 // { int posix_fallocate(int fd, \ + SYS_POSIX_FADVISE = 531 // { int posix_fadvise(int fd, off_t offset, \ + SYS_WAIT6 = 532 // { int wait6(idtype_t idtype, id_t id, \ + SYS_BINDAT = 538 // { int bindat(int fd, int s, caddr_t name, \ + SYS_CONNECTAT = 539 // { int connectat(int fd, int s, caddr_t name, \ + SYS_CHFLAGSAT = 540 // { int chflagsat(int fd, const char *path, \ + SYS_ACCEPT4 = 541 // { int accept4(int s, \ + SYS_PIPE2 = 542 // { int pipe2(int *fildes, int flags); } + SYS_PROCCTL = 544 // { int procctl(idtype_t idtype, id_t id, \ + SYS_PPOLL = 545 // { int ppoll(struct pollfd *fds, u_int nfds, \ +) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go new file mode 100644 index 0000000000..57a60ea126 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go @@ -0,0 +1,351 @@ +// mksysnum_freebsd.pl +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build amd64,freebsd + +package unix + +const ( + // SYS_NOSYS = 0; // { int nosys(void); } syscall nosys_args int + SYS_EXIT = 1 // { void sys_exit(int rval); } exit \ + SYS_FORK = 2 // { int fork(void); } + SYS_READ = 3 // { ssize_t read(int fd, void *buf, \ + SYS_WRITE = 4 // { ssize_t write(int fd, const void *buf, \ + SYS_OPEN = 5 // { int open(char *path, int flags, int mode); } + SYS_CLOSE = 6 // { int close(int fd); } + SYS_WAIT4 = 7 // { int wait4(int pid, int *status, \ + SYS_LINK = 9 // { int link(char *path, char *link); } + SYS_UNLINK = 10 // { int unlink(char *path); } + SYS_CHDIR = 12 // { int chdir(char *path); } + SYS_FCHDIR = 13 // { int fchdir(int fd); } + SYS_MKNOD = 14 // { int mknod(char *path, int mode, int dev); } + SYS_CHMOD = 15 // { int chmod(char *path, int mode); } + SYS_CHOWN = 16 // { int chown(char *path, int uid, int gid); } + SYS_OBREAK = 17 // { int obreak(char *nsize); } break \ + SYS_GETPID = 20 // { pid_t getpid(void); } + SYS_MOUNT = 21 // { int mount(char *type, char *path, \ + SYS_UNMOUNT = 22 // { int unmount(char *path, int flags); } + SYS_SETUID = 23 // { int setuid(uid_t uid); } + SYS_GETUID = 24 // { uid_t getuid(void); } + SYS_GETEUID = 25 // { uid_t geteuid(void); } + SYS_PTRACE = 26 // { int ptrace(int req, pid_t pid, \ + SYS_RECVMSG = 27 // { int recvmsg(int s, struct msghdr *msg, \ + SYS_SENDMSG = 28 // { int sendmsg(int s, struct msghdr *msg, \ + SYS_RECVFROM = 29 // { int recvfrom(int s, caddr_t buf, \ + SYS_ACCEPT = 30 // { int accept(int s, \ + SYS_GETPEERNAME = 31 // { int getpeername(int fdes, \ + SYS_GETSOCKNAME = 32 // { int getsockname(int fdes, \ + SYS_ACCESS = 33 // { int access(char *path, int amode); } + SYS_CHFLAGS = 34 // { int chflags(const char *path, u_long flags); } + SYS_FCHFLAGS = 35 // { int fchflags(int fd, u_long flags); } + SYS_SYNC = 36 // { int sync(void); } + SYS_KILL = 37 // { int kill(int pid, int signum); } + SYS_GETPPID = 39 // { pid_t getppid(void); } + SYS_DUP = 41 // { int dup(u_int fd); } + SYS_PIPE = 42 // { int pipe(void); } + SYS_GETEGID = 43 // { gid_t getegid(void); } + SYS_PROFIL = 44 // { int profil(caddr_t samples, size_t size, \ + SYS_KTRACE = 45 // { int ktrace(const char *fname, int ops, \ + SYS_GETGID = 47 // { gid_t getgid(void); } + SYS_GETLOGIN = 49 // { int getlogin(char *namebuf, u_int \ + SYS_SETLOGIN = 50 // { int setlogin(char *namebuf); } + SYS_ACCT = 51 // { int acct(char *path); } + SYS_SIGALTSTACK = 53 // { int sigaltstack(stack_t *ss, \ + SYS_IOCTL = 54 // { int ioctl(int fd, u_long com, \ + SYS_REBOOT = 55 // { int reboot(int opt); } + SYS_REVOKE = 56 // { int revoke(char *path); } + SYS_SYMLINK = 57 // { int symlink(char *path, char *link); } + SYS_READLINK = 58 // { ssize_t readlink(char *path, char *buf, \ + SYS_EXECVE = 59 // { int execve(char *fname, char **argv, \ + SYS_UMASK = 60 // { int umask(int newmask); } umask umask_args \ + SYS_CHROOT = 61 // { int chroot(char *path); } + SYS_MSYNC = 65 // { int msync(void *addr, size_t len, \ + SYS_VFORK = 66 // { int vfork(void); } + SYS_SBRK = 69 // { int sbrk(int incr); } + SYS_SSTK = 70 // { int sstk(int incr); } + SYS_OVADVISE = 72 // { int ovadvise(int anom); } vadvise \ + SYS_MUNMAP = 73 // { int munmap(void *addr, size_t len); } + SYS_MPROTECT = 74 // { int mprotect(const void *addr, size_t len, \ + SYS_MADVISE = 75 // { int madvise(void *addr, size_t len, \ + SYS_MINCORE = 78 // { int mincore(const void *addr, size_t len, \ + SYS_GETGROUPS = 79 // { int getgroups(u_int gidsetsize, \ + SYS_SETGROUPS = 80 // { int setgroups(u_int gidsetsize, \ + SYS_GETPGRP = 81 // { int getpgrp(void); } + SYS_SETPGID = 82 // { int setpgid(int pid, int pgid); } + SYS_SETITIMER = 83 // { int setitimer(u_int which, struct \ + SYS_SWAPON = 85 // { int swapon(char *name); } + SYS_GETITIMER = 86 // { int getitimer(u_int which, \ + SYS_GETDTABLESIZE = 89 // { int getdtablesize(void); } + SYS_DUP2 = 90 // { int dup2(u_int from, u_int to); } + SYS_FCNTL = 92 // { int fcntl(int fd, int cmd, long arg); } + SYS_SELECT = 93 // { int select(int nd, fd_set *in, fd_set *ou, \ + SYS_FSYNC = 95 // { int fsync(int fd); } + SYS_SETPRIORITY = 96 // { int setpriority(int which, int who, \ + SYS_SOCKET = 97 // { int socket(int domain, int type, \ + SYS_CONNECT = 98 // { int connect(int s, caddr_t name, \ + SYS_GETPRIORITY = 100 // { int getpriority(int which, int who); } + SYS_BIND = 104 // { int bind(int s, caddr_t name, \ + SYS_SETSOCKOPT = 105 // { int setsockopt(int s, int level, int name, \ + SYS_LISTEN = 106 // { int listen(int s, int backlog); } + SYS_GETTIMEOFDAY = 116 // { int gettimeofday(struct timeval *tp, \ + SYS_GETRUSAGE = 117 // { int getrusage(int who, \ + SYS_GETSOCKOPT = 118 // { int getsockopt(int s, int level, int name, \ + SYS_READV = 120 // { int readv(int fd, struct iovec *iovp, \ + SYS_WRITEV = 121 // { int writev(int fd, struct iovec *iovp, \ + SYS_SETTIMEOFDAY = 122 // { int settimeofday(struct timeval *tv, \ + SYS_FCHOWN = 123 // { int fchown(int fd, int uid, int gid); } + SYS_FCHMOD = 124 // { int fchmod(int fd, int mode); } + SYS_SETREUID = 126 // { int setreuid(int ruid, int euid); } + SYS_SETREGID = 127 // { int setregid(int rgid, int egid); } + SYS_RENAME = 128 // { int rename(char *from, char *to); } + SYS_FLOCK = 131 // { int flock(int fd, int how); } + SYS_MKFIFO = 132 // { int mkfifo(char *path, int mode); } + SYS_SENDTO = 133 // { int sendto(int s, caddr_t buf, size_t len, \ + SYS_SHUTDOWN = 134 // { int shutdown(int s, int how); } + SYS_SOCKETPAIR = 135 // { int socketpair(int domain, int type, \ + SYS_MKDIR = 136 // { int mkdir(char *path, int mode); } + SYS_RMDIR = 137 // { int rmdir(char *path); } + SYS_UTIMES = 138 // { int utimes(char *path, \ + SYS_ADJTIME = 140 // { int adjtime(struct timeval *delta, \ + SYS_SETSID = 147 // { int setsid(void); } + SYS_QUOTACTL = 148 // { int quotactl(char *path, int cmd, int uid, \ + SYS_LGETFH = 160 // { int lgetfh(char *fname, \ + SYS_GETFH = 161 // { int getfh(char *fname, \ + SYS_SYSARCH = 165 // { int sysarch(int op, char *parms); } + SYS_RTPRIO = 166 // { int rtprio(int function, pid_t pid, \ + SYS_FREEBSD6_PREAD = 173 // { ssize_t freebsd6_pread(int fd, void *buf, \ + SYS_FREEBSD6_PWRITE = 174 // { ssize_t freebsd6_pwrite(int fd, \ + SYS_SETFIB = 175 // { int setfib(int fibnum); } + SYS_NTP_ADJTIME = 176 // { int ntp_adjtime(struct timex *tp); } + SYS_SETGID = 181 // { int setgid(gid_t gid); } + SYS_SETEGID = 182 // { int setegid(gid_t egid); } + SYS_SETEUID = 183 // { int seteuid(uid_t euid); } + SYS_STAT = 188 // { int stat(char *path, struct stat *ub); } + SYS_FSTAT = 189 // { int fstat(int fd, struct stat *sb); } + SYS_LSTAT = 190 // { int lstat(char *path, struct stat *ub); } + SYS_PATHCONF = 191 // { int pathconf(char *path, int name); } + SYS_FPATHCONF = 192 // { int fpathconf(int fd, int name); } + SYS_GETRLIMIT = 194 // { int getrlimit(u_int which, \ + SYS_SETRLIMIT = 195 // { int setrlimit(u_int which, \ + SYS_GETDIRENTRIES = 196 // { int getdirentries(int fd, char *buf, \ + SYS_FREEBSD6_MMAP = 197 // { caddr_t freebsd6_mmap(caddr_t addr, \ + SYS_FREEBSD6_LSEEK = 199 // { off_t freebsd6_lseek(int fd, int pad, \ + SYS_FREEBSD6_TRUNCATE = 200 // { int freebsd6_truncate(char *path, int pad, \ + SYS_FREEBSD6_FTRUNCATE = 201 // { int freebsd6_ftruncate(int fd, int pad, \ + SYS___SYSCTL = 202 // { int __sysctl(int *name, u_int namelen, \ + SYS_MLOCK = 203 // { int mlock(const void *addr, size_t len); } + SYS_MUNLOCK = 204 // { int munlock(const void *addr, size_t len); } + SYS_UNDELETE = 205 // { int undelete(char *path); } + SYS_FUTIMES = 206 // { int futimes(int fd, struct timeval *tptr); } + SYS_GETPGID = 207 // { int getpgid(pid_t pid); } + SYS_POLL = 209 // { int poll(struct pollfd *fds, u_int nfds, \ + SYS_CLOCK_GETTIME = 232 // { int clock_gettime(clockid_t clock_id, \ + SYS_CLOCK_SETTIME = 233 // { int clock_settime( \ + SYS_CLOCK_GETRES = 234 // { int clock_getres(clockid_t clock_id, \ + SYS_KTIMER_CREATE = 235 // { int ktimer_create(clockid_t clock_id, \ + SYS_KTIMER_DELETE = 236 // { int ktimer_delete(int timerid); } + SYS_KTIMER_SETTIME = 237 // { int ktimer_settime(int timerid, int flags, \ + SYS_KTIMER_GETTIME = 238 // { int ktimer_gettime(int timerid, struct \ + SYS_KTIMER_GETOVERRUN = 239 // { int ktimer_getoverrun(int timerid); } + SYS_NANOSLEEP = 240 // { int nanosleep(const struct timespec *rqtp, \ + SYS_FFCLOCK_GETCOUNTER = 241 // { int ffclock_getcounter(ffcounter *ffcount); } + SYS_FFCLOCK_SETESTIMATE = 242 // { int ffclock_setestimate( \ + SYS_FFCLOCK_GETESTIMATE = 243 // { int ffclock_getestimate( \ + SYS_CLOCK_GETCPUCLOCKID2 = 247 // { int clock_getcpuclockid2(id_t id,\ + SYS_NTP_GETTIME = 248 // { int ntp_gettime(struct ntptimeval *ntvp); } + SYS_MINHERIT = 250 // { int minherit(void *addr, size_t len, \ + SYS_RFORK = 251 // { int rfork(int flags); } + SYS_OPENBSD_POLL = 252 // { int openbsd_poll(struct pollfd *fds, \ + SYS_ISSETUGID = 253 // { int issetugid(void); } + SYS_LCHOWN = 254 // { int lchown(char *path, int uid, int gid); } + SYS_GETDENTS = 272 // { int getdents(int fd, char *buf, \ + SYS_LCHMOD = 274 // { int lchmod(char *path, mode_t mode); } + SYS_LUTIMES = 276 // { int lutimes(char *path, \ + SYS_NSTAT = 278 // { int nstat(char *path, struct nstat *ub); } + SYS_NFSTAT = 279 // { int nfstat(int fd, struct nstat *sb); } + SYS_NLSTAT = 280 // { int nlstat(char *path, struct nstat *ub); } + SYS_PREADV = 289 // { ssize_t preadv(int fd, struct iovec *iovp, \ + SYS_PWRITEV = 290 // { ssize_t pwritev(int fd, struct iovec *iovp, \ + SYS_FHOPEN = 298 // { int fhopen(const struct fhandle *u_fhp, \ + SYS_FHSTAT = 299 // { int fhstat(const struct fhandle *u_fhp, \ + SYS_MODNEXT = 300 // { int modnext(int modid); } + SYS_MODSTAT = 301 // { int modstat(int modid, \ + SYS_MODFNEXT = 302 // { int modfnext(int modid); } + SYS_MODFIND = 303 // { int modfind(const char *name); } + SYS_KLDLOAD = 304 // { int kldload(const char *file); } + SYS_KLDUNLOAD = 305 // { int kldunload(int fileid); } + SYS_KLDFIND = 306 // { int kldfind(const char *file); } + SYS_KLDNEXT = 307 // { int kldnext(int fileid); } + SYS_KLDSTAT = 308 // { int kldstat(int fileid, struct \ + SYS_KLDFIRSTMOD = 309 // { int kldfirstmod(int fileid); } + SYS_GETSID = 310 // { int getsid(pid_t pid); } + SYS_SETRESUID = 311 // { int setresuid(uid_t ruid, uid_t euid, \ + SYS_SETRESGID = 312 // { int setresgid(gid_t rgid, gid_t egid, \ + SYS_YIELD = 321 // { int yield(void); } + SYS_MLOCKALL = 324 // { int mlockall(int how); } + SYS_MUNLOCKALL = 325 // { int munlockall(void); } + SYS___GETCWD = 326 // { int __getcwd(char *buf, u_int buflen); } + SYS_SCHED_SETPARAM = 327 // { int sched_setparam (pid_t pid, \ + SYS_SCHED_GETPARAM = 328 // { int sched_getparam (pid_t pid, struct \ + SYS_SCHED_SETSCHEDULER = 329 // { int sched_setscheduler (pid_t pid, int \ + SYS_SCHED_GETSCHEDULER = 330 // { int sched_getscheduler (pid_t pid); } + SYS_SCHED_YIELD = 331 // { int sched_yield (void); } + SYS_SCHED_GET_PRIORITY_MAX = 332 // { int sched_get_priority_max (int policy); } + SYS_SCHED_GET_PRIORITY_MIN = 333 // { int sched_get_priority_min (int policy); } + SYS_SCHED_RR_GET_INTERVAL = 334 // { int sched_rr_get_interval (pid_t pid, \ + SYS_UTRACE = 335 // { int utrace(const void *addr, size_t len); } + SYS_KLDSYM = 337 // { int kldsym(int fileid, int cmd, \ + SYS_JAIL = 338 // { int jail(struct jail *jail); } + SYS_SIGPROCMASK = 340 // { int sigprocmask(int how, \ + SYS_SIGSUSPEND = 341 // { int sigsuspend(const sigset_t *sigmask); } + SYS_SIGPENDING = 343 // { int sigpending(sigset_t *set); } + SYS_SIGTIMEDWAIT = 345 // { int sigtimedwait(const sigset_t *set, \ + SYS_SIGWAITINFO = 346 // { int sigwaitinfo(const sigset_t *set, \ + SYS___ACL_GET_FILE = 347 // { int __acl_get_file(const char *path, \ + SYS___ACL_SET_FILE = 348 // { int __acl_set_file(const char *path, \ + SYS___ACL_GET_FD = 349 // { int __acl_get_fd(int filedes, \ + SYS___ACL_SET_FD = 350 // { int __acl_set_fd(int filedes, \ + SYS___ACL_DELETE_FILE = 351 // { int __acl_delete_file(const char *path, \ + SYS___ACL_DELETE_FD = 352 // { int __acl_delete_fd(int filedes, \ + SYS___ACL_ACLCHECK_FILE = 353 // { int __acl_aclcheck_file(const char *path, \ + SYS___ACL_ACLCHECK_FD = 354 // { int __acl_aclcheck_fd(int filedes, \ + SYS_EXTATTRCTL = 355 // { int extattrctl(const char *path, int cmd, \ + SYS_EXTATTR_SET_FILE = 356 // { ssize_t extattr_set_file( \ + SYS_EXTATTR_GET_FILE = 357 // { ssize_t extattr_get_file( \ + SYS_EXTATTR_DELETE_FILE = 358 // { int extattr_delete_file(const char *path, \ + SYS_GETRESUID = 360 // { int getresuid(uid_t *ruid, uid_t *euid, \ + SYS_GETRESGID = 361 // { int getresgid(gid_t *rgid, gid_t *egid, \ + SYS_KQUEUE = 362 // { int kqueue(void); } + SYS_KEVENT = 363 // { int kevent(int fd, \ + SYS_EXTATTR_SET_FD = 371 // { ssize_t extattr_set_fd(int fd, \ + SYS_EXTATTR_GET_FD = 372 // { ssize_t extattr_get_fd(int fd, \ + SYS_EXTATTR_DELETE_FD = 373 // { int extattr_delete_fd(int fd, \ + SYS___SETUGID = 374 // { int __setugid(int flag); } + SYS_EACCESS = 376 // { int eaccess(char *path, int amode); } + SYS_NMOUNT = 378 // { int nmount(struct iovec *iovp, \ + SYS___MAC_GET_PROC = 384 // { int __mac_get_proc(struct mac *mac_p); } + SYS___MAC_SET_PROC = 385 // { int __mac_set_proc(struct mac *mac_p); } + SYS___MAC_GET_FD = 386 // { int __mac_get_fd(int fd, \ + SYS___MAC_GET_FILE = 387 // { int __mac_get_file(const char *path_p, \ + SYS___MAC_SET_FD = 388 // { int __mac_set_fd(int fd, \ + SYS___MAC_SET_FILE = 389 // { int __mac_set_file(const char *path_p, \ + SYS_KENV = 390 // { int kenv(int what, const char *name, \ + SYS_LCHFLAGS = 391 // { int lchflags(const char *path, \ + SYS_UUIDGEN = 392 // { int uuidgen(struct uuid *store, \ + SYS_SENDFILE = 393 // { int sendfile(int fd, int s, off_t offset, \ + SYS_MAC_SYSCALL = 394 // { int mac_syscall(const char *policy, \ + SYS_GETFSSTAT = 395 // { int getfsstat(struct statfs *buf, \ + SYS_STATFS = 396 // { int statfs(char *path, \ + SYS_FSTATFS = 397 // { int fstatfs(int fd, struct statfs *buf); } + SYS_FHSTATFS = 398 // { int fhstatfs(const struct fhandle *u_fhp, \ + SYS___MAC_GET_PID = 409 // { int __mac_get_pid(pid_t pid, \ + SYS___MAC_GET_LINK = 410 // { int __mac_get_link(const char *path_p, \ + SYS___MAC_SET_LINK = 411 // { int __mac_set_link(const char *path_p, \ + SYS_EXTATTR_SET_LINK = 412 // { ssize_t extattr_set_link( \ + SYS_EXTATTR_GET_LINK = 413 // { ssize_t extattr_get_link( \ + SYS_EXTATTR_DELETE_LINK = 414 // { int extattr_delete_link( \ + SYS___MAC_EXECVE = 415 // { int __mac_execve(char *fname, char **argv, \ + SYS_SIGACTION = 416 // { int sigaction(int sig, \ + SYS_SIGRETURN = 417 // { int sigreturn( \ + SYS_GETCONTEXT = 421 // { int getcontext(struct __ucontext *ucp); } + SYS_SETCONTEXT = 422 // { int setcontext( \ + SYS_SWAPCONTEXT = 423 // { int swapcontext(struct __ucontext *oucp, \ + SYS_SWAPOFF = 424 // { int swapoff(const char *name); } + SYS___ACL_GET_LINK = 425 // { int __acl_get_link(const char *path, \ + SYS___ACL_SET_LINK = 426 // { int __acl_set_link(const char *path, \ + SYS___ACL_DELETE_LINK = 427 // { int __acl_delete_link(const char *path, \ + SYS___ACL_ACLCHECK_LINK = 428 // { int __acl_aclcheck_link(const char *path, \ + SYS_SIGWAIT = 429 // { int sigwait(const sigset_t *set, \ + SYS_THR_CREATE = 430 // { int thr_create(ucontext_t *ctx, long *id, \ + SYS_THR_EXIT = 431 // { void thr_exit(long *state); } + SYS_THR_SELF = 432 // { int thr_self(long *id); } + SYS_THR_KILL = 433 // { int thr_kill(long id, int sig); } + SYS__UMTX_LOCK = 434 // { int _umtx_lock(struct umtx *umtx); } + SYS__UMTX_UNLOCK = 435 // { int _umtx_unlock(struct umtx *umtx); } + SYS_JAIL_ATTACH = 436 // { int jail_attach(int jid); } + SYS_EXTATTR_LIST_FD = 437 // { ssize_t extattr_list_fd(int fd, \ + SYS_EXTATTR_LIST_FILE = 438 // { ssize_t extattr_list_file( \ + SYS_EXTATTR_LIST_LINK = 439 // { ssize_t extattr_list_link( \ + SYS_THR_SUSPEND = 442 // { int thr_suspend( \ + SYS_THR_WAKE = 443 // { int thr_wake(long id); } + SYS_KLDUNLOADF = 444 // { int kldunloadf(int fileid, int flags); } + SYS_AUDIT = 445 // { int audit(const void *record, \ + SYS_AUDITON = 446 // { int auditon(int cmd, void *data, \ + SYS_GETAUID = 447 // { int getauid(uid_t *auid); } + SYS_SETAUID = 448 // { int setauid(uid_t *auid); } + SYS_GETAUDIT = 449 // { int getaudit(struct auditinfo *auditinfo); } + SYS_SETAUDIT = 450 // { int setaudit(struct auditinfo *auditinfo); } + SYS_GETAUDIT_ADDR = 451 // { int getaudit_addr( \ + SYS_SETAUDIT_ADDR = 452 // { int setaudit_addr( \ + SYS_AUDITCTL = 453 // { int auditctl(char *path); } + SYS__UMTX_OP = 454 // { int _umtx_op(void *obj, int op, \ + SYS_THR_NEW = 455 // { int thr_new(struct thr_param *param, \ + SYS_SIGQUEUE = 456 // { int sigqueue(pid_t pid, int signum, void *value); } + SYS_ABORT2 = 463 // { int abort2(const char *why, int nargs, void **args); } + SYS_THR_SET_NAME = 464 // { int thr_set_name(long id, const char *name); } + SYS_RTPRIO_THREAD = 466 // { int rtprio_thread(int function, \ + SYS_SCTP_PEELOFF = 471 // { int sctp_peeloff(int sd, uint32_t name); } + SYS_SCTP_GENERIC_SENDMSG = 472 // { int sctp_generic_sendmsg(int sd, caddr_t msg, int mlen, \ + SYS_SCTP_GENERIC_SENDMSG_IOV = 473 // { int sctp_generic_sendmsg_iov(int sd, struct iovec *iov, int iovlen, \ + SYS_SCTP_GENERIC_RECVMSG = 474 // { int sctp_generic_recvmsg(int sd, struct iovec *iov, int iovlen, \ + SYS_PREAD = 475 // { ssize_t pread(int fd, void *buf, \ + SYS_PWRITE = 476 // { ssize_t pwrite(int fd, const void *buf, \ + SYS_MMAP = 477 // { caddr_t mmap(caddr_t addr, size_t len, \ + SYS_LSEEK = 478 // { off_t lseek(int fd, off_t offset, \ + SYS_TRUNCATE = 479 // { int truncate(char *path, off_t length); } + SYS_FTRUNCATE = 480 // { int ftruncate(int fd, off_t length); } + SYS_THR_KILL2 = 481 // { int thr_kill2(pid_t pid, long id, int sig); } + SYS_SHM_OPEN = 482 // { int shm_open(const char *path, int flags, \ + SYS_SHM_UNLINK = 483 // { int shm_unlink(const char *path); } + SYS_CPUSET = 484 // { int cpuset(cpusetid_t *setid); } + SYS_CPUSET_SETID = 485 // { int cpuset_setid(cpuwhich_t which, id_t id, \ + SYS_CPUSET_GETID = 486 // { int cpuset_getid(cpulevel_t level, \ + SYS_CPUSET_GETAFFINITY = 487 // { int cpuset_getaffinity(cpulevel_t level, \ + SYS_CPUSET_SETAFFINITY = 488 // { int cpuset_setaffinity(cpulevel_t level, \ + SYS_FACCESSAT = 489 // { int faccessat(int fd, char *path, int amode, \ + SYS_FCHMODAT = 490 // { int fchmodat(int fd, char *path, mode_t mode, \ + SYS_FCHOWNAT = 491 // { int fchownat(int fd, char *path, uid_t uid, \ + SYS_FEXECVE = 492 // { int fexecve(int fd, char **argv, \ + SYS_FSTATAT = 493 // { int fstatat(int fd, char *path, \ + SYS_FUTIMESAT = 494 // { int futimesat(int fd, char *path, \ + SYS_LINKAT = 495 // { int linkat(int fd1, char *path1, int fd2, \ + SYS_MKDIRAT = 496 // { int mkdirat(int fd, char *path, mode_t mode); } + SYS_MKFIFOAT = 497 // { int mkfifoat(int fd, char *path, mode_t mode); } + SYS_MKNODAT = 498 // { int mknodat(int fd, char *path, mode_t mode, \ + SYS_OPENAT = 499 // { int openat(int fd, char *path, int flag, \ + SYS_READLINKAT = 500 // { int readlinkat(int fd, char *path, char *buf, \ + SYS_RENAMEAT = 501 // { int renameat(int oldfd, char *old, int newfd, \ + SYS_SYMLINKAT = 502 // { int symlinkat(char *path1, int fd, \ + SYS_UNLINKAT = 503 // { int unlinkat(int fd, char *path, int flag); } + SYS_POSIX_OPENPT = 504 // { int posix_openpt(int flags); } + SYS_JAIL_GET = 506 // { int jail_get(struct iovec *iovp, \ + SYS_JAIL_SET = 507 // { int jail_set(struct iovec *iovp, \ + SYS_JAIL_REMOVE = 508 // { int jail_remove(int jid); } + SYS_CLOSEFROM = 509 // { int closefrom(int lowfd); } + SYS_LPATHCONF = 513 // { int lpathconf(char *path, int name); } + SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); } + SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \ + SYS_CAP_ENTER = 516 // { int cap_enter(void); } + SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); } + SYS_PDFORK = 518 // { int pdfork(int *fdp, int flags); } + SYS_PDKILL = 519 // { int pdkill(int fd, int signum); } + SYS_PDGETPID = 520 // { int pdgetpid(int fd, pid_t *pidp); } + SYS_PSELECT = 522 // { int pselect(int nd, fd_set *in, \ + SYS_GETLOGINCLASS = 523 // { int getloginclass(char *namebuf, \ + SYS_SETLOGINCLASS = 524 // { int setloginclass(const char *namebuf); } + SYS_RCTL_GET_RACCT = 525 // { int rctl_get_racct(const void *inbufp, \ + SYS_RCTL_GET_RULES = 526 // { int rctl_get_rules(const void *inbufp, \ + SYS_RCTL_GET_LIMITS = 527 // { int rctl_get_limits(const void *inbufp, \ + SYS_RCTL_ADD_RULE = 528 // { int rctl_add_rule(const void *inbufp, \ + SYS_RCTL_REMOVE_RULE = 529 // { int rctl_remove_rule(const void *inbufp, \ + SYS_POSIX_FALLOCATE = 530 // { int posix_fallocate(int fd, \ + SYS_POSIX_FADVISE = 531 // { int posix_fadvise(int fd, off_t offset, \ + SYS_WAIT6 = 532 // { int wait6(idtype_t idtype, id_t id, \ + SYS_BINDAT = 538 // { int bindat(int fd, int s, caddr_t name, \ + SYS_CONNECTAT = 539 // { int connectat(int fd, int s, caddr_t name, \ + SYS_CHFLAGSAT = 540 // { int chflagsat(int fd, const char *path, \ + SYS_ACCEPT4 = 541 // { int accept4(int s, \ + SYS_PIPE2 = 542 // { int pipe2(int *fildes, int flags); } + SYS_PROCCTL = 544 // { int procctl(idtype_t idtype, id_t id, \ + SYS_PPOLL = 545 // { int ppoll(struct pollfd *fds, u_int nfds, \ +) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm.go b/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm.go new file mode 100644 index 0000000000..206b9f612d --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_freebsd_arm.go @@ -0,0 +1,351 @@ +// mksysnum_freebsd.pl +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build arm,freebsd + +package unix + +const ( + // SYS_NOSYS = 0; // { int nosys(void); } syscall nosys_args int + SYS_EXIT = 1 // { void sys_exit(int rval); } exit \ + SYS_FORK = 2 // { int fork(void); } + SYS_READ = 3 // { ssize_t read(int fd, void *buf, \ + SYS_WRITE = 4 // { ssize_t write(int fd, const void *buf, \ + SYS_OPEN = 5 // { int open(char *path, int flags, int mode); } + SYS_CLOSE = 6 // { int close(int fd); } + SYS_WAIT4 = 7 // { int wait4(int pid, int *status, \ + SYS_LINK = 9 // { int link(char *path, char *link); } + SYS_UNLINK = 10 // { int unlink(char *path); } + SYS_CHDIR = 12 // { int chdir(char *path); } + SYS_FCHDIR = 13 // { int fchdir(int fd); } + SYS_MKNOD = 14 // { int mknod(char *path, int mode, int dev); } + SYS_CHMOD = 15 // { int chmod(char *path, int mode); } + SYS_CHOWN = 16 // { int chown(char *path, int uid, int gid); } + SYS_OBREAK = 17 // { int obreak(char *nsize); } break \ + SYS_GETPID = 20 // { pid_t getpid(void); } + SYS_MOUNT = 21 // { int mount(char *type, char *path, \ + SYS_UNMOUNT = 22 // { int unmount(char *path, int flags); } + SYS_SETUID = 23 // { int setuid(uid_t uid); } + SYS_GETUID = 24 // { uid_t getuid(void); } + SYS_GETEUID = 25 // { uid_t geteuid(void); } + SYS_PTRACE = 26 // { int ptrace(int req, pid_t pid, \ + SYS_RECVMSG = 27 // { int recvmsg(int s, struct msghdr *msg, \ + SYS_SENDMSG = 28 // { int sendmsg(int s, struct msghdr *msg, \ + SYS_RECVFROM = 29 // { int recvfrom(int s, caddr_t buf, \ + SYS_ACCEPT = 30 // { int accept(int s, \ + SYS_GETPEERNAME = 31 // { int getpeername(int fdes, \ + SYS_GETSOCKNAME = 32 // { int getsockname(int fdes, \ + SYS_ACCESS = 33 // { int access(char *path, int amode); } + SYS_CHFLAGS = 34 // { int chflags(const char *path, u_long flags); } + SYS_FCHFLAGS = 35 // { int fchflags(int fd, u_long flags); } + SYS_SYNC = 36 // { int sync(void); } + SYS_KILL = 37 // { int kill(int pid, int signum); } + SYS_GETPPID = 39 // { pid_t getppid(void); } + SYS_DUP = 41 // { int dup(u_int fd); } + SYS_PIPE = 42 // { int pipe(void); } + SYS_GETEGID = 43 // { gid_t getegid(void); } + SYS_PROFIL = 44 // { int profil(caddr_t samples, size_t size, \ + SYS_KTRACE = 45 // { int ktrace(const char *fname, int ops, \ + SYS_GETGID = 47 // { gid_t getgid(void); } + SYS_GETLOGIN = 49 // { int getlogin(char *namebuf, u_int \ + SYS_SETLOGIN = 50 // { int setlogin(char *namebuf); } + SYS_ACCT = 51 // { int acct(char *path); } + SYS_SIGALTSTACK = 53 // { int sigaltstack(stack_t *ss, \ + SYS_IOCTL = 54 // { int ioctl(int fd, u_long com, \ + SYS_REBOOT = 55 // { int reboot(int opt); } + SYS_REVOKE = 56 // { int revoke(char *path); } + SYS_SYMLINK = 57 // { int symlink(char *path, char *link); } + SYS_READLINK = 58 // { ssize_t readlink(char *path, char *buf, \ + SYS_EXECVE = 59 // { int execve(char *fname, char **argv, \ + SYS_UMASK = 60 // { int umask(int newmask); } umask umask_args \ + SYS_CHROOT = 61 // { int chroot(char *path); } + SYS_MSYNC = 65 // { int msync(void *addr, size_t len, \ + SYS_VFORK = 66 // { int vfork(void); } + SYS_SBRK = 69 // { int sbrk(int incr); } + SYS_SSTK = 70 // { int sstk(int incr); } + SYS_OVADVISE = 72 // { int ovadvise(int anom); } vadvise \ + SYS_MUNMAP = 73 // { int munmap(void *addr, size_t len); } + SYS_MPROTECT = 74 // { int mprotect(const void *addr, size_t len, \ + SYS_MADVISE = 75 // { int madvise(void *addr, size_t len, \ + SYS_MINCORE = 78 // { int mincore(const void *addr, size_t len, \ + SYS_GETGROUPS = 79 // { int getgroups(u_int gidsetsize, \ + SYS_SETGROUPS = 80 // { int setgroups(u_int gidsetsize, \ + SYS_GETPGRP = 81 // { int getpgrp(void); } + SYS_SETPGID = 82 // { int setpgid(int pid, int pgid); } + SYS_SETITIMER = 83 // { int setitimer(u_int which, struct \ + SYS_SWAPON = 85 // { int swapon(char *name); } + SYS_GETITIMER = 86 // { int getitimer(u_int which, \ + SYS_GETDTABLESIZE = 89 // { int getdtablesize(void); } + SYS_DUP2 = 90 // { int dup2(u_int from, u_int to); } + SYS_FCNTL = 92 // { int fcntl(int fd, int cmd, long arg); } + SYS_SELECT = 93 // { int select(int nd, fd_set *in, fd_set *ou, \ + SYS_FSYNC = 95 // { int fsync(int fd); } + SYS_SETPRIORITY = 96 // { int setpriority(int which, int who, \ + SYS_SOCKET = 97 // { int socket(int domain, int type, \ + SYS_CONNECT = 98 // { int connect(int s, caddr_t name, \ + SYS_GETPRIORITY = 100 // { int getpriority(int which, int who); } + SYS_BIND = 104 // { int bind(int s, caddr_t name, \ + SYS_SETSOCKOPT = 105 // { int setsockopt(int s, int level, int name, \ + SYS_LISTEN = 106 // { int listen(int s, int backlog); } + SYS_GETTIMEOFDAY = 116 // { int gettimeofday(struct timeval *tp, \ + SYS_GETRUSAGE = 117 // { int getrusage(int who, \ + SYS_GETSOCKOPT = 118 // { int getsockopt(int s, int level, int name, \ + SYS_READV = 120 // { int readv(int fd, struct iovec *iovp, \ + SYS_WRITEV = 121 // { int writev(int fd, struct iovec *iovp, \ + SYS_SETTIMEOFDAY = 122 // { int settimeofday(struct timeval *tv, \ + SYS_FCHOWN = 123 // { int fchown(int fd, int uid, int gid); } + SYS_FCHMOD = 124 // { int fchmod(int fd, int mode); } + SYS_SETREUID = 126 // { int setreuid(int ruid, int euid); } + SYS_SETREGID = 127 // { int setregid(int rgid, int egid); } + SYS_RENAME = 128 // { int rename(char *from, char *to); } + SYS_FLOCK = 131 // { int flock(int fd, int how); } + SYS_MKFIFO = 132 // { int mkfifo(char *path, int mode); } + SYS_SENDTO = 133 // { int sendto(int s, caddr_t buf, size_t len, \ + SYS_SHUTDOWN = 134 // { int shutdown(int s, int how); } + SYS_SOCKETPAIR = 135 // { int socketpair(int domain, int type, \ + SYS_MKDIR = 136 // { int mkdir(char *path, int mode); } + SYS_RMDIR = 137 // { int rmdir(char *path); } + SYS_UTIMES = 138 // { int utimes(char *path, \ + SYS_ADJTIME = 140 // { int adjtime(struct timeval *delta, \ + SYS_SETSID = 147 // { int setsid(void); } + SYS_QUOTACTL = 148 // { int quotactl(char *path, int cmd, int uid, \ + SYS_LGETFH = 160 // { int lgetfh(char *fname, \ + SYS_GETFH = 161 // { int getfh(char *fname, \ + SYS_SYSARCH = 165 // { int sysarch(int op, char *parms); } + SYS_RTPRIO = 166 // { int rtprio(int function, pid_t pid, \ + SYS_FREEBSD6_PREAD = 173 // { ssize_t freebsd6_pread(int fd, void *buf, \ + SYS_FREEBSD6_PWRITE = 174 // { ssize_t freebsd6_pwrite(int fd, \ + SYS_SETFIB = 175 // { int setfib(int fibnum); } + SYS_NTP_ADJTIME = 176 // { int ntp_adjtime(struct timex *tp); } + SYS_SETGID = 181 // { int setgid(gid_t gid); } + SYS_SETEGID = 182 // { int setegid(gid_t egid); } + SYS_SETEUID = 183 // { int seteuid(uid_t euid); } + SYS_STAT = 188 // { int stat(char *path, struct stat *ub); } + SYS_FSTAT = 189 // { int fstat(int fd, struct stat *sb); } + SYS_LSTAT = 190 // { int lstat(char *path, struct stat *ub); } + SYS_PATHCONF = 191 // { int pathconf(char *path, int name); } + SYS_FPATHCONF = 192 // { int fpathconf(int fd, int name); } + SYS_GETRLIMIT = 194 // { int getrlimit(u_int which, \ + SYS_SETRLIMIT = 195 // { int setrlimit(u_int which, \ + SYS_GETDIRENTRIES = 196 // { int getdirentries(int fd, char *buf, \ + SYS_FREEBSD6_MMAP = 197 // { caddr_t freebsd6_mmap(caddr_t addr, \ + SYS_FREEBSD6_LSEEK = 199 // { off_t freebsd6_lseek(int fd, int pad, \ + SYS_FREEBSD6_TRUNCATE = 200 // { int freebsd6_truncate(char *path, int pad, \ + SYS_FREEBSD6_FTRUNCATE = 201 // { int freebsd6_ftruncate(int fd, int pad, \ + SYS___SYSCTL = 202 // { int __sysctl(int *name, u_int namelen, \ + SYS_MLOCK = 203 // { int mlock(const void *addr, size_t len); } + SYS_MUNLOCK = 204 // { int munlock(const void *addr, size_t len); } + SYS_UNDELETE = 205 // { int undelete(char *path); } + SYS_FUTIMES = 206 // { int futimes(int fd, struct timeval *tptr); } + SYS_GETPGID = 207 // { int getpgid(pid_t pid); } + SYS_POLL = 209 // { int poll(struct pollfd *fds, u_int nfds, \ + SYS_CLOCK_GETTIME = 232 // { int clock_gettime(clockid_t clock_id, \ + SYS_CLOCK_SETTIME = 233 // { int clock_settime( \ + SYS_CLOCK_GETRES = 234 // { int clock_getres(clockid_t clock_id, \ + SYS_KTIMER_CREATE = 235 // { int ktimer_create(clockid_t clock_id, \ + SYS_KTIMER_DELETE = 236 // { int ktimer_delete(int timerid); } + SYS_KTIMER_SETTIME = 237 // { int ktimer_settime(int timerid, int flags, \ + SYS_KTIMER_GETTIME = 238 // { int ktimer_gettime(int timerid, struct \ + SYS_KTIMER_GETOVERRUN = 239 // { int ktimer_getoverrun(int timerid); } + SYS_NANOSLEEP = 240 // { int nanosleep(const struct timespec *rqtp, \ + SYS_FFCLOCK_GETCOUNTER = 241 // { int ffclock_getcounter(ffcounter *ffcount); } + SYS_FFCLOCK_SETESTIMATE = 242 // { int ffclock_setestimate( \ + SYS_FFCLOCK_GETESTIMATE = 243 // { int ffclock_getestimate( \ + SYS_CLOCK_GETCPUCLOCKID2 = 247 // { int clock_getcpuclockid2(id_t id,\ + SYS_NTP_GETTIME = 248 // { int ntp_gettime(struct ntptimeval *ntvp); } + SYS_MINHERIT = 250 // { int minherit(void *addr, size_t len, \ + SYS_RFORK = 251 // { int rfork(int flags); } + SYS_OPENBSD_POLL = 252 // { int openbsd_poll(struct pollfd *fds, \ + SYS_ISSETUGID = 253 // { int issetugid(void); } + SYS_LCHOWN = 254 // { int lchown(char *path, int uid, int gid); } + SYS_GETDENTS = 272 // { int getdents(int fd, char *buf, \ + SYS_LCHMOD = 274 // { int lchmod(char *path, mode_t mode); } + SYS_LUTIMES = 276 // { int lutimes(char *path, \ + SYS_NSTAT = 278 // { int nstat(char *path, struct nstat *ub); } + SYS_NFSTAT = 279 // { int nfstat(int fd, struct nstat *sb); } + SYS_NLSTAT = 280 // { int nlstat(char *path, struct nstat *ub); } + SYS_PREADV = 289 // { ssize_t preadv(int fd, struct iovec *iovp, \ + SYS_PWRITEV = 290 // { ssize_t pwritev(int fd, struct iovec *iovp, \ + SYS_FHOPEN = 298 // { int fhopen(const struct fhandle *u_fhp, \ + SYS_FHSTAT = 299 // { int fhstat(const struct fhandle *u_fhp, \ + SYS_MODNEXT = 300 // { int modnext(int modid); } + SYS_MODSTAT = 301 // { int modstat(int modid, \ + SYS_MODFNEXT = 302 // { int modfnext(int modid); } + SYS_MODFIND = 303 // { int modfind(const char *name); } + SYS_KLDLOAD = 304 // { int kldload(const char *file); } + SYS_KLDUNLOAD = 305 // { int kldunload(int fileid); } + SYS_KLDFIND = 306 // { int kldfind(const char *file); } + SYS_KLDNEXT = 307 // { int kldnext(int fileid); } + SYS_KLDSTAT = 308 // { int kldstat(int fileid, struct \ + SYS_KLDFIRSTMOD = 309 // { int kldfirstmod(int fileid); } + SYS_GETSID = 310 // { int getsid(pid_t pid); } + SYS_SETRESUID = 311 // { int setresuid(uid_t ruid, uid_t euid, \ + SYS_SETRESGID = 312 // { int setresgid(gid_t rgid, gid_t egid, \ + SYS_YIELD = 321 // { int yield(void); } + SYS_MLOCKALL = 324 // { int mlockall(int how); } + SYS_MUNLOCKALL = 325 // { int munlockall(void); } + SYS___GETCWD = 326 // { int __getcwd(char *buf, u_int buflen); } + SYS_SCHED_SETPARAM = 327 // { int sched_setparam (pid_t pid, \ + SYS_SCHED_GETPARAM = 328 // { int sched_getparam (pid_t pid, struct \ + SYS_SCHED_SETSCHEDULER = 329 // { int sched_setscheduler (pid_t pid, int \ + SYS_SCHED_GETSCHEDULER = 330 // { int sched_getscheduler (pid_t pid); } + SYS_SCHED_YIELD = 331 // { int sched_yield (void); } + SYS_SCHED_GET_PRIORITY_MAX = 332 // { int sched_get_priority_max (int policy); } + SYS_SCHED_GET_PRIORITY_MIN = 333 // { int sched_get_priority_min (int policy); } + SYS_SCHED_RR_GET_INTERVAL = 334 // { int sched_rr_get_interval (pid_t pid, \ + SYS_UTRACE = 335 // { int utrace(const void *addr, size_t len); } + SYS_KLDSYM = 337 // { int kldsym(int fileid, int cmd, \ + SYS_JAIL = 338 // { int jail(struct jail *jail); } + SYS_SIGPROCMASK = 340 // { int sigprocmask(int how, \ + SYS_SIGSUSPEND = 341 // { int sigsuspend(const sigset_t *sigmask); } + SYS_SIGPENDING = 343 // { int sigpending(sigset_t *set); } + SYS_SIGTIMEDWAIT = 345 // { int sigtimedwait(const sigset_t *set, \ + SYS_SIGWAITINFO = 346 // { int sigwaitinfo(const sigset_t *set, \ + SYS___ACL_GET_FILE = 347 // { int __acl_get_file(const char *path, \ + SYS___ACL_SET_FILE = 348 // { int __acl_set_file(const char *path, \ + SYS___ACL_GET_FD = 349 // { int __acl_get_fd(int filedes, \ + SYS___ACL_SET_FD = 350 // { int __acl_set_fd(int filedes, \ + SYS___ACL_DELETE_FILE = 351 // { int __acl_delete_file(const char *path, \ + SYS___ACL_DELETE_FD = 352 // { int __acl_delete_fd(int filedes, \ + SYS___ACL_ACLCHECK_FILE = 353 // { int __acl_aclcheck_file(const char *path, \ + SYS___ACL_ACLCHECK_FD = 354 // { int __acl_aclcheck_fd(int filedes, \ + SYS_EXTATTRCTL = 355 // { int extattrctl(const char *path, int cmd, \ + SYS_EXTATTR_SET_FILE = 356 // { ssize_t extattr_set_file( \ + SYS_EXTATTR_GET_FILE = 357 // { ssize_t extattr_get_file( \ + SYS_EXTATTR_DELETE_FILE = 358 // { int extattr_delete_file(const char *path, \ + SYS_GETRESUID = 360 // { int getresuid(uid_t *ruid, uid_t *euid, \ + SYS_GETRESGID = 361 // { int getresgid(gid_t *rgid, gid_t *egid, \ + SYS_KQUEUE = 362 // { int kqueue(void); } + SYS_KEVENT = 363 // { int kevent(int fd, \ + SYS_EXTATTR_SET_FD = 371 // { ssize_t extattr_set_fd(int fd, \ + SYS_EXTATTR_GET_FD = 372 // { ssize_t extattr_get_fd(int fd, \ + SYS_EXTATTR_DELETE_FD = 373 // { int extattr_delete_fd(int fd, \ + SYS___SETUGID = 374 // { int __setugid(int flag); } + SYS_EACCESS = 376 // { int eaccess(char *path, int amode); } + SYS_NMOUNT = 378 // { int nmount(struct iovec *iovp, \ + SYS___MAC_GET_PROC = 384 // { int __mac_get_proc(struct mac *mac_p); } + SYS___MAC_SET_PROC = 385 // { int __mac_set_proc(struct mac *mac_p); } + SYS___MAC_GET_FD = 386 // { int __mac_get_fd(int fd, \ + SYS___MAC_GET_FILE = 387 // { int __mac_get_file(const char *path_p, \ + SYS___MAC_SET_FD = 388 // { int __mac_set_fd(int fd, \ + SYS___MAC_SET_FILE = 389 // { int __mac_set_file(const char *path_p, \ + SYS_KENV = 390 // { int kenv(int what, const char *name, \ + SYS_LCHFLAGS = 391 // { int lchflags(const char *path, \ + SYS_UUIDGEN = 392 // { int uuidgen(struct uuid *store, \ + SYS_SENDFILE = 393 // { int sendfile(int fd, int s, off_t offset, \ + SYS_MAC_SYSCALL = 394 // { int mac_syscall(const char *policy, \ + SYS_GETFSSTAT = 395 // { int getfsstat(struct statfs *buf, \ + SYS_STATFS = 396 // { int statfs(char *path, \ + SYS_FSTATFS = 397 // { int fstatfs(int fd, struct statfs *buf); } + SYS_FHSTATFS = 398 // { int fhstatfs(const struct fhandle *u_fhp, \ + SYS___MAC_GET_PID = 409 // { int __mac_get_pid(pid_t pid, \ + SYS___MAC_GET_LINK = 410 // { int __mac_get_link(const char *path_p, \ + SYS___MAC_SET_LINK = 411 // { int __mac_set_link(const char *path_p, \ + SYS_EXTATTR_SET_LINK = 412 // { ssize_t extattr_set_link( \ + SYS_EXTATTR_GET_LINK = 413 // { ssize_t extattr_get_link( \ + SYS_EXTATTR_DELETE_LINK = 414 // { int extattr_delete_link( \ + SYS___MAC_EXECVE = 415 // { int __mac_execve(char *fname, char **argv, \ + SYS_SIGACTION = 416 // { int sigaction(int sig, \ + SYS_SIGRETURN = 417 // { int sigreturn( \ + SYS_GETCONTEXT = 421 // { int getcontext(struct __ucontext *ucp); } + SYS_SETCONTEXT = 422 // { int setcontext( \ + SYS_SWAPCONTEXT = 423 // { int swapcontext(struct __ucontext *oucp, \ + SYS_SWAPOFF = 424 // { int swapoff(const char *name); } + SYS___ACL_GET_LINK = 425 // { int __acl_get_link(const char *path, \ + SYS___ACL_SET_LINK = 426 // { int __acl_set_link(const char *path, \ + SYS___ACL_DELETE_LINK = 427 // { int __acl_delete_link(const char *path, \ + SYS___ACL_ACLCHECK_LINK = 428 // { int __acl_aclcheck_link(const char *path, \ + SYS_SIGWAIT = 429 // { int sigwait(const sigset_t *set, \ + SYS_THR_CREATE = 430 // { int thr_create(ucontext_t *ctx, long *id, \ + SYS_THR_EXIT = 431 // { void thr_exit(long *state); } + SYS_THR_SELF = 432 // { int thr_self(long *id); } + SYS_THR_KILL = 433 // { int thr_kill(long id, int sig); } + SYS__UMTX_LOCK = 434 // { int _umtx_lock(struct umtx *umtx); } + SYS__UMTX_UNLOCK = 435 // { int _umtx_unlock(struct umtx *umtx); } + SYS_JAIL_ATTACH = 436 // { int jail_attach(int jid); } + SYS_EXTATTR_LIST_FD = 437 // { ssize_t extattr_list_fd(int fd, \ + SYS_EXTATTR_LIST_FILE = 438 // { ssize_t extattr_list_file( \ + SYS_EXTATTR_LIST_LINK = 439 // { ssize_t extattr_list_link( \ + SYS_THR_SUSPEND = 442 // { int thr_suspend( \ + SYS_THR_WAKE = 443 // { int thr_wake(long id); } + SYS_KLDUNLOADF = 444 // { int kldunloadf(int fileid, int flags); } + SYS_AUDIT = 445 // { int audit(const void *record, \ + SYS_AUDITON = 446 // { int auditon(int cmd, void *data, \ + SYS_GETAUID = 447 // { int getauid(uid_t *auid); } + SYS_SETAUID = 448 // { int setauid(uid_t *auid); } + SYS_GETAUDIT = 449 // { int getaudit(struct auditinfo *auditinfo); } + SYS_SETAUDIT = 450 // { int setaudit(struct auditinfo *auditinfo); } + SYS_GETAUDIT_ADDR = 451 // { int getaudit_addr( \ + SYS_SETAUDIT_ADDR = 452 // { int setaudit_addr( \ + SYS_AUDITCTL = 453 // { int auditctl(char *path); } + SYS__UMTX_OP = 454 // { int _umtx_op(void *obj, int op, \ + SYS_THR_NEW = 455 // { int thr_new(struct thr_param *param, \ + SYS_SIGQUEUE = 456 // { int sigqueue(pid_t pid, int signum, void *value); } + SYS_ABORT2 = 463 // { int abort2(const char *why, int nargs, void **args); } + SYS_THR_SET_NAME = 464 // { int thr_set_name(long id, const char *name); } + SYS_RTPRIO_THREAD = 466 // { int rtprio_thread(int function, \ + SYS_SCTP_PEELOFF = 471 // { int sctp_peeloff(int sd, uint32_t name); } + SYS_SCTP_GENERIC_SENDMSG = 472 // { int sctp_generic_sendmsg(int sd, caddr_t msg, int mlen, \ + SYS_SCTP_GENERIC_SENDMSG_IOV = 473 // { int sctp_generic_sendmsg_iov(int sd, struct iovec *iov, int iovlen, \ + SYS_SCTP_GENERIC_RECVMSG = 474 // { int sctp_generic_recvmsg(int sd, struct iovec *iov, int iovlen, \ + SYS_PREAD = 475 // { ssize_t pread(int fd, void *buf, \ + SYS_PWRITE = 476 // { ssize_t pwrite(int fd, const void *buf, \ + SYS_MMAP = 477 // { caddr_t mmap(caddr_t addr, size_t len, \ + SYS_LSEEK = 478 // { off_t lseek(int fd, off_t offset, \ + SYS_TRUNCATE = 479 // { int truncate(char *path, off_t length); } + SYS_FTRUNCATE = 480 // { int ftruncate(int fd, off_t length); } + SYS_THR_KILL2 = 481 // { int thr_kill2(pid_t pid, long id, int sig); } + SYS_SHM_OPEN = 482 // { int shm_open(const char *path, int flags, \ + SYS_SHM_UNLINK = 483 // { int shm_unlink(const char *path); } + SYS_CPUSET = 484 // { int cpuset(cpusetid_t *setid); } + SYS_CPUSET_SETID = 485 // { int cpuset_setid(cpuwhich_t which, id_t id, \ + SYS_CPUSET_GETID = 486 // { int cpuset_getid(cpulevel_t level, \ + SYS_CPUSET_GETAFFINITY = 487 // { int cpuset_getaffinity(cpulevel_t level, \ + SYS_CPUSET_SETAFFINITY = 488 // { int cpuset_setaffinity(cpulevel_t level, \ + SYS_FACCESSAT = 489 // { int faccessat(int fd, char *path, int amode, \ + SYS_FCHMODAT = 490 // { int fchmodat(int fd, char *path, mode_t mode, \ + SYS_FCHOWNAT = 491 // { int fchownat(int fd, char *path, uid_t uid, \ + SYS_FEXECVE = 492 // { int fexecve(int fd, char **argv, \ + SYS_FSTATAT = 493 // { int fstatat(int fd, char *path, \ + SYS_FUTIMESAT = 494 // { int futimesat(int fd, char *path, \ + SYS_LINKAT = 495 // { int linkat(int fd1, char *path1, int fd2, \ + SYS_MKDIRAT = 496 // { int mkdirat(int fd, char *path, mode_t mode); } + SYS_MKFIFOAT = 497 // { int mkfifoat(int fd, char *path, mode_t mode); } + SYS_MKNODAT = 498 // { int mknodat(int fd, char *path, mode_t mode, \ + SYS_OPENAT = 499 // { int openat(int fd, char *path, int flag, \ + SYS_READLINKAT = 500 // { int readlinkat(int fd, char *path, char *buf, \ + SYS_RENAMEAT = 501 // { int renameat(int oldfd, char *old, int newfd, \ + SYS_SYMLINKAT = 502 // { int symlinkat(char *path1, int fd, \ + SYS_UNLINKAT = 503 // { int unlinkat(int fd, char *path, int flag); } + SYS_POSIX_OPENPT = 504 // { int posix_openpt(int flags); } + SYS_JAIL_GET = 506 // { int jail_get(struct iovec *iovp, \ + SYS_JAIL_SET = 507 // { int jail_set(struct iovec *iovp, \ + SYS_JAIL_REMOVE = 508 // { int jail_remove(int jid); } + SYS_CLOSEFROM = 509 // { int closefrom(int lowfd); } + SYS_LPATHCONF = 513 // { int lpathconf(char *path, int name); } + SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); } + SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \ + SYS_CAP_ENTER = 516 // { int cap_enter(void); } + SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); } + SYS_PDFORK = 518 // { int pdfork(int *fdp, int flags); } + SYS_PDKILL = 519 // { int pdkill(int fd, int signum); } + SYS_PDGETPID = 520 // { int pdgetpid(int fd, pid_t *pidp); } + SYS_PSELECT = 522 // { int pselect(int nd, fd_set *in, \ + SYS_GETLOGINCLASS = 523 // { int getloginclass(char *namebuf, \ + SYS_SETLOGINCLASS = 524 // { int setloginclass(const char *namebuf); } + SYS_RCTL_GET_RACCT = 525 // { int rctl_get_racct(const void *inbufp, \ + SYS_RCTL_GET_RULES = 526 // { int rctl_get_rules(const void *inbufp, \ + SYS_RCTL_GET_LIMITS = 527 // { int rctl_get_limits(const void *inbufp, \ + SYS_RCTL_ADD_RULE = 528 // { int rctl_add_rule(const void *inbufp, \ + SYS_RCTL_REMOVE_RULE = 529 // { int rctl_remove_rule(const void *inbufp, \ + SYS_POSIX_FALLOCATE = 530 // { int posix_fallocate(int fd, \ + SYS_POSIX_FADVISE = 531 // { int posix_fadvise(int fd, off_t offset, \ + SYS_WAIT6 = 532 // { int wait6(idtype_t idtype, id_t id, \ + SYS_BINDAT = 538 // { int bindat(int fd, int s, caddr_t name, \ + SYS_CONNECTAT = 539 // { int connectat(int fd, int s, caddr_t name, \ + SYS_CHFLAGSAT = 540 // { int chflagsat(int fd, const char *path, \ + SYS_ACCEPT4 = 541 // { int accept4(int s, \ + SYS_PIPE2 = 542 // { int pipe2(int *fildes, int flags); } + SYS_PROCCTL = 544 // { int procctl(idtype_t idtype, id_t id, \ + SYS_PPOLL = 545 // { int ppoll(struct pollfd *fds, u_int nfds, \ +) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go new file mode 100644 index 0000000000..ba952c6754 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go @@ -0,0 +1,355 @@ +// mksysnum_linux.pl /usr/include/asm/unistd_32.h +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build 386,linux + +package unix + +const ( + SYS_RESTART_SYSCALL = 0 + SYS_EXIT = 1 + SYS_FORK = 2 + SYS_READ = 3 + SYS_WRITE = 4 + SYS_OPEN = 5 + SYS_CLOSE = 6 + SYS_WAITPID = 7 + SYS_CREAT = 8 + SYS_LINK = 9 + SYS_UNLINK = 10 + SYS_EXECVE = 11 + SYS_CHDIR = 12 + SYS_TIME = 13 + SYS_MKNOD = 14 + SYS_CHMOD = 15 + SYS_LCHOWN = 16 + SYS_BREAK = 17 + SYS_OLDSTAT = 18 + SYS_LSEEK = 19 + SYS_GETPID = 20 + SYS_MOUNT = 21 + SYS_UMOUNT = 22 + SYS_SETUID = 23 + SYS_GETUID = 24 + SYS_STIME = 25 + SYS_PTRACE = 26 + SYS_ALARM = 27 + SYS_OLDFSTAT = 28 + SYS_PAUSE = 29 + SYS_UTIME = 30 + SYS_STTY = 31 + SYS_GTTY = 32 + SYS_ACCESS = 33 + SYS_NICE = 34 + SYS_FTIME = 35 + SYS_SYNC = 36 + SYS_KILL = 37 + SYS_RENAME = 38 + SYS_MKDIR = 39 + SYS_RMDIR = 40 + SYS_DUP = 41 + SYS_PIPE = 42 + SYS_TIMES = 43 + SYS_PROF = 44 + SYS_BRK = 45 + SYS_SETGID = 46 + SYS_GETGID = 47 + SYS_SIGNAL = 48 + SYS_GETEUID = 49 + SYS_GETEGID = 50 + SYS_ACCT = 51 + SYS_UMOUNT2 = 52 + SYS_LOCK = 53 + SYS_IOCTL = 54 + SYS_FCNTL = 55 + SYS_MPX = 56 + SYS_SETPGID = 57 + SYS_ULIMIT = 58 + SYS_OLDOLDUNAME = 59 + SYS_UMASK = 60 + SYS_CHROOT = 61 + SYS_USTAT = 62 + SYS_DUP2 = 63 + SYS_GETPPID = 64 + SYS_GETPGRP = 65 + SYS_SETSID = 66 + SYS_SIGACTION = 67 + SYS_SGETMASK = 68 + SYS_SSETMASK = 69 + SYS_SETREUID = 70 + SYS_SETREGID = 71 + SYS_SIGSUSPEND = 72 + SYS_SIGPENDING = 73 + SYS_SETHOSTNAME = 74 + SYS_SETRLIMIT = 75 + SYS_GETRLIMIT = 76 + SYS_GETRUSAGE = 77 + SYS_GETTIMEOFDAY = 78 + SYS_SETTIMEOFDAY = 79 + SYS_GETGROUPS = 80 + SYS_SETGROUPS = 81 + SYS_SELECT = 82 + SYS_SYMLINK = 83 + SYS_OLDLSTAT = 84 + SYS_READLINK = 85 + SYS_USELIB = 86 + SYS_SWAPON = 87 + SYS_REBOOT = 88 + SYS_READDIR = 89 + SYS_MMAP = 90 + SYS_MUNMAP = 91 + SYS_TRUNCATE = 92 + SYS_FTRUNCATE = 93 + SYS_FCHMOD = 94 + SYS_FCHOWN = 95 + SYS_GETPRIORITY = 96 + SYS_SETPRIORITY = 97 + SYS_PROFIL = 98 + SYS_STATFS = 99 + SYS_FSTATFS = 100 + SYS_IOPERM = 101 + SYS_SOCKETCALL = 102 + SYS_SYSLOG = 103 + SYS_SETITIMER = 104 + SYS_GETITIMER = 105 + SYS_STAT = 106 + SYS_LSTAT = 107 + SYS_FSTAT = 108 + SYS_OLDUNAME = 109 + SYS_IOPL = 110 + SYS_VHANGUP = 111 + SYS_IDLE = 112 + SYS_VM86OLD = 113 + SYS_WAIT4 = 114 + SYS_SWAPOFF = 115 + SYS_SYSINFO = 116 + SYS_IPC = 117 + SYS_FSYNC = 118 + SYS_SIGRETURN = 119 + SYS_CLONE = 120 + SYS_SETDOMAINNAME = 121 + SYS_UNAME = 122 + SYS_MODIFY_LDT = 123 + SYS_ADJTIMEX = 124 + SYS_MPROTECT = 125 + SYS_SIGPROCMASK = 126 + SYS_CREATE_MODULE = 127 + SYS_INIT_MODULE = 128 + SYS_DELETE_MODULE = 129 + SYS_GET_KERNEL_SYMS = 130 + SYS_QUOTACTL = 131 + SYS_GETPGID = 132 + SYS_FCHDIR = 133 + SYS_BDFLUSH = 134 + SYS_SYSFS = 135 + SYS_PERSONALITY = 136 + SYS_AFS_SYSCALL = 137 + SYS_SETFSUID = 138 + SYS_SETFSGID = 139 + SYS__LLSEEK = 140 + SYS_GETDENTS = 141 + SYS__NEWSELECT = 142 + SYS_FLOCK = 143 + SYS_MSYNC = 144 + SYS_READV = 145 + SYS_WRITEV = 146 + SYS_GETSID = 147 + SYS_FDATASYNC = 148 + SYS__SYSCTL = 149 + SYS_MLOCK = 150 + SYS_MUNLOCK = 151 + SYS_MLOCKALL = 152 + SYS_MUNLOCKALL = 153 + SYS_SCHED_SETPARAM = 154 + SYS_SCHED_GETPARAM = 155 + SYS_SCHED_SETSCHEDULER = 156 + SYS_SCHED_GETSCHEDULER = 157 + SYS_SCHED_YIELD = 158 + SYS_SCHED_GET_PRIORITY_MAX = 159 + SYS_SCHED_GET_PRIORITY_MIN = 160 + SYS_SCHED_RR_GET_INTERVAL = 161 + SYS_NANOSLEEP = 162 + SYS_MREMAP = 163 + SYS_SETRESUID = 164 + SYS_GETRESUID = 165 + SYS_VM86 = 166 + SYS_QUERY_MODULE = 167 + SYS_POLL = 168 + SYS_NFSSERVCTL = 169 + SYS_SETRESGID = 170 + SYS_GETRESGID = 171 + SYS_PRCTL = 172 + SYS_RT_SIGRETURN = 173 + SYS_RT_SIGACTION = 174 + SYS_RT_SIGPROCMASK = 175 + SYS_RT_SIGPENDING = 176 + SYS_RT_SIGTIMEDWAIT = 177 + SYS_RT_SIGQUEUEINFO = 178 + SYS_RT_SIGSUSPEND = 179 + SYS_PREAD64 = 180 + SYS_PWRITE64 = 181 + SYS_CHOWN = 182 + SYS_GETCWD = 183 + SYS_CAPGET = 184 + SYS_CAPSET = 185 + SYS_SIGALTSTACK = 186 + SYS_SENDFILE = 187 + SYS_GETPMSG = 188 + SYS_PUTPMSG = 189 + SYS_VFORK = 190 + SYS_UGETRLIMIT = 191 + SYS_MMAP2 = 192 + SYS_TRUNCATE64 = 193 + SYS_FTRUNCATE64 = 194 + SYS_STAT64 = 195 + SYS_LSTAT64 = 196 + SYS_FSTAT64 = 197 + SYS_LCHOWN32 = 198 + SYS_GETUID32 = 199 + SYS_GETGID32 = 200 + SYS_GETEUID32 = 201 + SYS_GETEGID32 = 202 + SYS_SETREUID32 = 203 + SYS_SETREGID32 = 204 + SYS_GETGROUPS32 = 205 + SYS_SETGROUPS32 = 206 + SYS_FCHOWN32 = 207 + SYS_SETRESUID32 = 208 + SYS_GETRESUID32 = 209 + SYS_SETRESGID32 = 210 + SYS_GETRESGID32 = 211 + SYS_CHOWN32 = 212 + SYS_SETUID32 = 213 + SYS_SETGID32 = 214 + SYS_SETFSUID32 = 215 + SYS_SETFSGID32 = 216 + SYS_PIVOT_ROOT = 217 + SYS_MINCORE = 218 + SYS_MADVISE = 219 + SYS_MADVISE1 = 219 + SYS_GETDENTS64 = 220 + SYS_FCNTL64 = 221 + SYS_GETTID = 224 + SYS_READAHEAD = 225 + SYS_SETXATTR = 226 + SYS_LSETXATTR = 227 + SYS_FSETXATTR = 228 + SYS_GETXATTR = 229 + SYS_LGETXATTR = 230 + SYS_FGETXATTR = 231 + SYS_LISTXATTR = 232 + SYS_LLISTXATTR = 233 + SYS_FLISTXATTR = 234 + SYS_REMOVEXATTR = 235 + SYS_LREMOVEXATTR = 236 + SYS_FREMOVEXATTR = 237 + SYS_TKILL = 238 + SYS_SENDFILE64 = 239 + SYS_FUTEX = 240 + SYS_SCHED_SETAFFINITY = 241 + SYS_SCHED_GETAFFINITY = 242 + SYS_SET_THREAD_AREA = 243 + SYS_GET_THREAD_AREA = 244 + SYS_IO_SETUP = 245 + SYS_IO_DESTROY = 246 + SYS_IO_GETEVENTS = 247 + SYS_IO_SUBMIT = 248 + SYS_IO_CANCEL = 249 + SYS_FADVISE64 = 250 + SYS_EXIT_GROUP = 252 + SYS_LOOKUP_DCOOKIE = 253 + SYS_EPOLL_CREATE = 254 + SYS_EPOLL_CTL = 255 + SYS_EPOLL_WAIT = 256 + SYS_REMAP_FILE_PAGES = 257 + SYS_SET_TID_ADDRESS = 258 + SYS_TIMER_CREATE = 259 + SYS_TIMER_SETTIME = 260 + SYS_TIMER_GETTIME = 261 + SYS_TIMER_GETOVERRUN = 262 + SYS_TIMER_DELETE = 263 + SYS_CLOCK_SETTIME = 264 + SYS_CLOCK_GETTIME = 265 + SYS_CLOCK_GETRES = 266 + SYS_CLOCK_NANOSLEEP = 267 + SYS_STATFS64 = 268 + SYS_FSTATFS64 = 269 + SYS_TGKILL = 270 + SYS_UTIMES = 271 + SYS_FADVISE64_64 = 272 + SYS_VSERVER = 273 + SYS_MBIND = 274 + SYS_GET_MEMPOLICY = 275 + SYS_SET_MEMPOLICY = 276 + SYS_MQ_OPEN = 277 + SYS_MQ_UNLINK = 278 + SYS_MQ_TIMEDSEND = 279 + SYS_MQ_TIMEDRECEIVE = 280 + SYS_MQ_NOTIFY = 281 + SYS_MQ_GETSETATTR = 282 + SYS_KEXEC_LOAD = 283 + SYS_WAITID = 284 + SYS_ADD_KEY = 286 + SYS_REQUEST_KEY = 287 + SYS_KEYCTL = 288 + SYS_IOPRIO_SET = 289 + SYS_IOPRIO_GET = 290 + SYS_INOTIFY_INIT = 291 + SYS_INOTIFY_ADD_WATCH = 292 + SYS_INOTIFY_RM_WATCH = 293 + SYS_MIGRATE_PAGES = 294 + SYS_OPENAT = 295 + SYS_MKDIRAT = 296 + SYS_MKNODAT = 297 + SYS_FCHOWNAT = 298 + SYS_FUTIMESAT = 299 + SYS_FSTATAT64 = 300 + SYS_UNLINKAT = 301 + SYS_RENAMEAT = 302 + SYS_LINKAT = 303 + SYS_SYMLINKAT = 304 + SYS_READLINKAT = 305 + SYS_FCHMODAT = 306 + SYS_FACCESSAT = 307 + SYS_PSELECT6 = 308 + SYS_PPOLL = 309 + SYS_UNSHARE = 310 + SYS_SET_ROBUST_LIST = 311 + SYS_GET_ROBUST_LIST = 312 + SYS_SPLICE = 313 + SYS_SYNC_FILE_RANGE = 314 + SYS_TEE = 315 + SYS_VMSPLICE = 316 + SYS_MOVE_PAGES = 317 + SYS_GETCPU = 318 + SYS_EPOLL_PWAIT = 319 + SYS_UTIMENSAT = 320 + SYS_SIGNALFD = 321 + SYS_TIMERFD_CREATE = 322 + SYS_EVENTFD = 323 + SYS_FALLOCATE = 324 + SYS_TIMERFD_SETTIME = 325 + SYS_TIMERFD_GETTIME = 326 + SYS_SIGNALFD4 = 327 + SYS_EVENTFD2 = 328 + SYS_EPOLL_CREATE1 = 329 + SYS_DUP3 = 330 + SYS_PIPE2 = 331 + SYS_INOTIFY_INIT1 = 332 + SYS_PREADV = 333 + SYS_PWRITEV = 334 + SYS_RT_TGSIGQUEUEINFO = 335 + SYS_PERF_EVENT_OPEN = 336 + SYS_RECVMMSG = 337 + SYS_FANOTIFY_INIT = 338 + SYS_FANOTIFY_MARK = 339 + SYS_PRLIMIT64 = 340 + SYS_NAME_TO_HANDLE_AT = 341 + SYS_OPEN_BY_HANDLE_AT = 342 + SYS_CLOCK_ADJTIME = 343 + SYS_SYNCFS = 344 + SYS_SENDMMSG = 345 + SYS_SETNS = 346 + SYS_PROCESS_VM_READV = 347 + SYS_PROCESS_VM_WRITEV = 348 +) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go new file mode 100644 index 0000000000..ddac31f58a --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go @@ -0,0 +1,321 @@ +// mksysnum_linux.pl /usr/include/asm/unistd_64.h +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build amd64,linux + +package unix + +const ( + SYS_READ = 0 + SYS_WRITE = 1 + SYS_OPEN = 2 + SYS_CLOSE = 3 + SYS_STAT = 4 + SYS_FSTAT = 5 + SYS_LSTAT = 6 + SYS_POLL = 7 + SYS_LSEEK = 8 + SYS_MMAP = 9 + SYS_MPROTECT = 10 + SYS_MUNMAP = 11 + SYS_BRK = 12 + SYS_RT_SIGACTION = 13 + SYS_RT_SIGPROCMASK = 14 + SYS_RT_SIGRETURN = 15 + SYS_IOCTL = 16 + SYS_PREAD64 = 17 + SYS_PWRITE64 = 18 + SYS_READV = 19 + SYS_WRITEV = 20 + SYS_ACCESS = 21 + SYS_PIPE = 22 + SYS_SELECT = 23 + SYS_SCHED_YIELD = 24 + SYS_MREMAP = 25 + SYS_MSYNC = 26 + SYS_MINCORE = 27 + SYS_MADVISE = 28 + SYS_SHMGET = 29 + SYS_SHMAT = 30 + SYS_SHMCTL = 31 + SYS_DUP = 32 + SYS_DUP2 = 33 + SYS_PAUSE = 34 + SYS_NANOSLEEP = 35 + SYS_GETITIMER = 36 + SYS_ALARM = 37 + SYS_SETITIMER = 38 + SYS_GETPID = 39 + SYS_SENDFILE = 40 + SYS_SOCKET = 41 + SYS_CONNECT = 42 + SYS_ACCEPT = 43 + SYS_SENDTO = 44 + SYS_RECVFROM = 45 + SYS_SENDMSG = 46 + SYS_RECVMSG = 47 + SYS_SHUTDOWN = 48 + SYS_BIND = 49 + SYS_LISTEN = 50 + SYS_GETSOCKNAME = 51 + SYS_GETPEERNAME = 52 + SYS_SOCKETPAIR = 53 + SYS_SETSOCKOPT = 54 + SYS_GETSOCKOPT = 55 + SYS_CLONE = 56 + SYS_FORK = 57 + SYS_VFORK = 58 + SYS_EXECVE = 59 + SYS_EXIT = 60 + SYS_WAIT4 = 61 + SYS_KILL = 62 + SYS_UNAME = 63 + SYS_SEMGET = 64 + SYS_SEMOP = 65 + SYS_SEMCTL = 66 + SYS_SHMDT = 67 + SYS_MSGGET = 68 + SYS_MSGSND = 69 + SYS_MSGRCV = 70 + SYS_MSGCTL = 71 + SYS_FCNTL = 72 + SYS_FLOCK = 73 + SYS_FSYNC = 74 + SYS_FDATASYNC = 75 + SYS_TRUNCATE = 76 + SYS_FTRUNCATE = 77 + SYS_GETDENTS = 78 + SYS_GETCWD = 79 + SYS_CHDIR = 80 + SYS_FCHDIR = 81 + SYS_RENAME = 82 + SYS_MKDIR = 83 + SYS_RMDIR = 84 + SYS_CREAT = 85 + SYS_LINK = 86 + SYS_UNLINK = 87 + SYS_SYMLINK = 88 + SYS_READLINK = 89 + SYS_CHMOD = 90 + SYS_FCHMOD = 91 + SYS_CHOWN = 92 + SYS_FCHOWN = 93 + SYS_LCHOWN = 94 + SYS_UMASK = 95 + SYS_GETTIMEOFDAY = 96 + SYS_GETRLIMIT = 97 + SYS_GETRUSAGE = 98 + SYS_SYSINFO = 99 + SYS_TIMES = 100 + SYS_PTRACE = 101 + SYS_GETUID = 102 + SYS_SYSLOG = 103 + SYS_GETGID = 104 + SYS_SETUID = 105 + SYS_SETGID = 106 + SYS_GETEUID = 107 + SYS_GETEGID = 108 + SYS_SETPGID = 109 + SYS_GETPPID = 110 + SYS_GETPGRP = 111 + SYS_SETSID = 112 + SYS_SETREUID = 113 + SYS_SETREGID = 114 + SYS_GETGROUPS = 115 + SYS_SETGROUPS = 116 + SYS_SETRESUID = 117 + SYS_GETRESUID = 118 + SYS_SETRESGID = 119 + SYS_GETRESGID = 120 + SYS_GETPGID = 121 + SYS_SETFSUID = 122 + SYS_SETFSGID = 123 + SYS_GETSID = 124 + SYS_CAPGET = 125 + SYS_CAPSET = 126 + SYS_RT_SIGPENDING = 127 + SYS_RT_SIGTIMEDWAIT = 128 + SYS_RT_SIGQUEUEINFO = 129 + SYS_RT_SIGSUSPEND = 130 + SYS_SIGALTSTACK = 131 + SYS_UTIME = 132 + SYS_MKNOD = 133 + SYS_USELIB = 134 + SYS_PERSONALITY = 135 + SYS_USTAT = 136 + SYS_STATFS = 137 + SYS_FSTATFS = 138 + SYS_SYSFS = 139 + SYS_GETPRIORITY = 140 + SYS_SETPRIORITY = 141 + SYS_SCHED_SETPARAM = 142 + SYS_SCHED_GETPARAM = 143 + SYS_SCHED_SETSCHEDULER = 144 + SYS_SCHED_GETSCHEDULER = 145 + SYS_SCHED_GET_PRIORITY_MAX = 146 + SYS_SCHED_GET_PRIORITY_MIN = 147 + SYS_SCHED_RR_GET_INTERVAL = 148 + SYS_MLOCK = 149 + SYS_MUNLOCK = 150 + SYS_MLOCKALL = 151 + SYS_MUNLOCKALL = 152 + SYS_VHANGUP = 153 + SYS_MODIFY_LDT = 154 + SYS_PIVOT_ROOT = 155 + SYS__SYSCTL = 156 + SYS_PRCTL = 157 + SYS_ARCH_PRCTL = 158 + SYS_ADJTIMEX = 159 + SYS_SETRLIMIT = 160 + SYS_CHROOT = 161 + SYS_SYNC = 162 + SYS_ACCT = 163 + SYS_SETTIMEOFDAY = 164 + SYS_MOUNT = 165 + SYS_UMOUNT2 = 166 + SYS_SWAPON = 167 + SYS_SWAPOFF = 168 + SYS_REBOOT = 169 + SYS_SETHOSTNAME = 170 + SYS_SETDOMAINNAME = 171 + SYS_IOPL = 172 + SYS_IOPERM = 173 + SYS_CREATE_MODULE = 174 + SYS_INIT_MODULE = 175 + SYS_DELETE_MODULE = 176 + SYS_GET_KERNEL_SYMS = 177 + SYS_QUERY_MODULE = 178 + SYS_QUOTACTL = 179 + SYS_NFSSERVCTL = 180 + SYS_GETPMSG = 181 + SYS_PUTPMSG = 182 + SYS_AFS_SYSCALL = 183 + SYS_TUXCALL = 184 + SYS_SECURITY = 185 + SYS_GETTID = 186 + SYS_READAHEAD = 187 + SYS_SETXATTR = 188 + SYS_LSETXATTR = 189 + SYS_FSETXATTR = 190 + SYS_GETXATTR = 191 + SYS_LGETXATTR = 192 + SYS_FGETXATTR = 193 + SYS_LISTXATTR = 194 + SYS_LLISTXATTR = 195 + SYS_FLISTXATTR = 196 + SYS_REMOVEXATTR = 197 + SYS_LREMOVEXATTR = 198 + SYS_FREMOVEXATTR = 199 + SYS_TKILL = 200 + SYS_TIME = 201 + SYS_FUTEX = 202 + SYS_SCHED_SETAFFINITY = 203 + SYS_SCHED_GETAFFINITY = 204 + SYS_SET_THREAD_AREA = 205 + SYS_IO_SETUP = 206 + SYS_IO_DESTROY = 207 + SYS_IO_GETEVENTS = 208 + SYS_IO_SUBMIT = 209 + SYS_IO_CANCEL = 210 + SYS_GET_THREAD_AREA = 211 + SYS_LOOKUP_DCOOKIE = 212 + SYS_EPOLL_CREATE = 213 + SYS_EPOLL_CTL_OLD = 214 + SYS_EPOLL_WAIT_OLD = 215 + SYS_REMAP_FILE_PAGES = 216 + SYS_GETDENTS64 = 217 + SYS_SET_TID_ADDRESS = 218 + SYS_RESTART_SYSCALL = 219 + SYS_SEMTIMEDOP = 220 + SYS_FADVISE64 = 221 + SYS_TIMER_CREATE = 222 + SYS_TIMER_SETTIME = 223 + SYS_TIMER_GETTIME = 224 + SYS_TIMER_GETOVERRUN = 225 + SYS_TIMER_DELETE = 226 + SYS_CLOCK_SETTIME = 227 + SYS_CLOCK_GETTIME = 228 + SYS_CLOCK_GETRES = 229 + SYS_CLOCK_NANOSLEEP = 230 + SYS_EXIT_GROUP = 231 + SYS_EPOLL_WAIT = 232 + SYS_EPOLL_CTL = 233 + SYS_TGKILL = 234 + SYS_UTIMES = 235 + SYS_VSERVER = 236 + SYS_MBIND = 237 + SYS_SET_MEMPOLICY = 238 + SYS_GET_MEMPOLICY = 239 + SYS_MQ_OPEN = 240 + SYS_MQ_UNLINK = 241 + SYS_MQ_TIMEDSEND = 242 + SYS_MQ_TIMEDRECEIVE = 243 + SYS_MQ_NOTIFY = 244 + SYS_MQ_GETSETATTR = 245 + SYS_KEXEC_LOAD = 246 + SYS_WAITID = 247 + SYS_ADD_KEY = 248 + SYS_REQUEST_KEY = 249 + SYS_KEYCTL = 250 + SYS_IOPRIO_SET = 251 + SYS_IOPRIO_GET = 252 + SYS_INOTIFY_INIT = 253 + SYS_INOTIFY_ADD_WATCH = 254 + SYS_INOTIFY_RM_WATCH = 255 + SYS_MIGRATE_PAGES = 256 + SYS_OPENAT = 257 + SYS_MKDIRAT = 258 + SYS_MKNODAT = 259 + SYS_FCHOWNAT = 260 + SYS_FUTIMESAT = 261 + SYS_NEWFSTATAT = 262 + SYS_UNLINKAT = 263 + SYS_RENAMEAT = 264 + SYS_LINKAT = 265 + SYS_SYMLINKAT = 266 + SYS_READLINKAT = 267 + SYS_FCHMODAT = 268 + SYS_FACCESSAT = 269 + SYS_PSELECT6 = 270 + SYS_PPOLL = 271 + SYS_UNSHARE = 272 + SYS_SET_ROBUST_LIST = 273 + SYS_GET_ROBUST_LIST = 274 + SYS_SPLICE = 275 + SYS_TEE = 276 + SYS_SYNC_FILE_RANGE = 277 + SYS_VMSPLICE = 278 + SYS_MOVE_PAGES = 279 + SYS_UTIMENSAT = 280 + SYS_EPOLL_PWAIT = 281 + SYS_SIGNALFD = 282 + SYS_TIMERFD_CREATE = 283 + SYS_EVENTFD = 284 + SYS_FALLOCATE = 285 + SYS_TIMERFD_SETTIME = 286 + SYS_TIMERFD_GETTIME = 287 + SYS_ACCEPT4 = 288 + SYS_SIGNALFD4 = 289 + SYS_EVENTFD2 = 290 + SYS_EPOLL_CREATE1 = 291 + SYS_DUP3 = 292 + SYS_PIPE2 = 293 + SYS_INOTIFY_INIT1 = 294 + SYS_PREADV = 295 + SYS_PWRITEV = 296 + SYS_RT_TGSIGQUEUEINFO = 297 + SYS_PERF_EVENT_OPEN = 298 + SYS_RECVMMSG = 299 + SYS_FANOTIFY_INIT = 300 + SYS_FANOTIFY_MARK = 301 + SYS_PRLIMIT64 = 302 + SYS_NAME_TO_HANDLE_AT = 303 + SYS_OPEN_BY_HANDLE_AT = 304 + SYS_CLOCK_ADJTIME = 305 + SYS_SYNCFS = 306 + SYS_SENDMMSG = 307 + SYS_SETNS = 308 + SYS_GETCPU = 309 + SYS_PROCESS_VM_READV = 310 + SYS_PROCESS_VM_WRITEV = 311 +) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go new file mode 100644 index 0000000000..45ced17fc4 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go @@ -0,0 +1,356 @@ +// mksysnum_linux.pl +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build arm,linux + +package unix + +const ( + SYS_OABI_SYSCALL_BASE = 0 + SYS_SYSCALL_BASE = 0 + SYS_RESTART_SYSCALL = 0 + SYS_EXIT = 1 + SYS_FORK = 2 + SYS_READ = 3 + SYS_WRITE = 4 + SYS_OPEN = 5 + SYS_CLOSE = 6 + SYS_CREAT = 8 + SYS_LINK = 9 + SYS_UNLINK = 10 + SYS_EXECVE = 11 + SYS_CHDIR = 12 + SYS_TIME = 13 + SYS_MKNOD = 14 + SYS_CHMOD = 15 + SYS_LCHOWN = 16 + SYS_LSEEK = 19 + SYS_GETPID = 20 + SYS_MOUNT = 21 + SYS_UMOUNT = 22 + SYS_SETUID = 23 + SYS_GETUID = 24 + SYS_STIME = 25 + SYS_PTRACE = 26 + SYS_ALARM = 27 + SYS_PAUSE = 29 + SYS_UTIME = 30 + SYS_ACCESS = 33 + SYS_NICE = 34 + SYS_SYNC = 36 + SYS_KILL = 37 + SYS_RENAME = 38 + SYS_MKDIR = 39 + SYS_RMDIR = 40 + SYS_DUP = 41 + SYS_PIPE = 42 + SYS_TIMES = 43 + SYS_BRK = 45 + SYS_SETGID = 46 + SYS_GETGID = 47 + SYS_GETEUID = 49 + SYS_GETEGID = 50 + SYS_ACCT = 51 + SYS_UMOUNT2 = 52 + SYS_IOCTL = 54 + SYS_FCNTL = 55 + SYS_SETPGID = 57 + SYS_UMASK = 60 + SYS_CHROOT = 61 + SYS_USTAT = 62 + SYS_DUP2 = 63 + SYS_GETPPID = 64 + SYS_GETPGRP = 65 + SYS_SETSID = 66 + SYS_SIGACTION = 67 + SYS_SETREUID = 70 + SYS_SETREGID = 71 + SYS_SIGSUSPEND = 72 + SYS_SIGPENDING = 73 + SYS_SETHOSTNAME = 74 + SYS_SETRLIMIT = 75 + SYS_GETRLIMIT = 76 + SYS_GETRUSAGE = 77 + SYS_GETTIMEOFDAY = 78 + SYS_SETTIMEOFDAY = 79 + SYS_GETGROUPS = 80 + SYS_SETGROUPS = 81 + SYS_SELECT = 82 + SYS_SYMLINK = 83 + SYS_READLINK = 85 + SYS_USELIB = 86 + SYS_SWAPON = 87 + SYS_REBOOT = 88 + SYS_READDIR = 89 + SYS_MMAP = 90 + SYS_MUNMAP = 91 + SYS_TRUNCATE = 92 + SYS_FTRUNCATE = 93 + SYS_FCHMOD = 94 + SYS_FCHOWN = 95 + SYS_GETPRIORITY = 96 + SYS_SETPRIORITY = 97 + SYS_STATFS = 99 + SYS_FSTATFS = 100 + SYS_SOCKETCALL = 102 + SYS_SYSLOG = 103 + SYS_SETITIMER = 104 + SYS_GETITIMER = 105 + SYS_STAT = 106 + SYS_LSTAT = 107 + SYS_FSTAT = 108 + SYS_VHANGUP = 111 + SYS_SYSCALL = 113 + SYS_WAIT4 = 114 + SYS_SWAPOFF = 115 + SYS_SYSINFO = 116 + SYS_IPC = 117 + SYS_FSYNC = 118 + SYS_SIGRETURN = 119 + SYS_CLONE = 120 + SYS_SETDOMAINNAME = 121 + SYS_UNAME = 122 + SYS_ADJTIMEX = 124 + SYS_MPROTECT = 125 + SYS_SIGPROCMASK = 126 + SYS_INIT_MODULE = 128 + SYS_DELETE_MODULE = 129 + SYS_QUOTACTL = 131 + SYS_GETPGID = 132 + SYS_FCHDIR = 133 + SYS_BDFLUSH = 134 + SYS_SYSFS = 135 + SYS_PERSONALITY = 136 + SYS_SETFSUID = 138 + SYS_SETFSGID = 139 + SYS__LLSEEK = 140 + SYS_GETDENTS = 141 + SYS__NEWSELECT = 142 + SYS_FLOCK = 143 + SYS_MSYNC = 144 + SYS_READV = 145 + SYS_WRITEV = 146 + SYS_GETSID = 147 + SYS_FDATASYNC = 148 + SYS__SYSCTL = 149 + SYS_MLOCK = 150 + SYS_MUNLOCK = 151 + SYS_MLOCKALL = 152 + SYS_MUNLOCKALL = 153 + SYS_SCHED_SETPARAM = 154 + SYS_SCHED_GETPARAM = 155 + SYS_SCHED_SETSCHEDULER = 156 + SYS_SCHED_GETSCHEDULER = 157 + SYS_SCHED_YIELD = 158 + SYS_SCHED_GET_PRIORITY_MAX = 159 + SYS_SCHED_GET_PRIORITY_MIN = 160 + SYS_SCHED_RR_GET_INTERVAL = 161 + SYS_NANOSLEEP = 162 + SYS_MREMAP = 163 + SYS_SETRESUID = 164 + SYS_GETRESUID = 165 + SYS_POLL = 168 + SYS_NFSSERVCTL = 169 + SYS_SETRESGID = 170 + SYS_GETRESGID = 171 + SYS_PRCTL = 172 + SYS_RT_SIGRETURN = 173 + SYS_RT_SIGACTION = 174 + SYS_RT_SIGPROCMASK = 175 + SYS_RT_SIGPENDING = 176 + SYS_RT_SIGTIMEDWAIT = 177 + SYS_RT_SIGQUEUEINFO = 178 + SYS_RT_SIGSUSPEND = 179 + SYS_PREAD64 = 180 + SYS_PWRITE64 = 181 + SYS_CHOWN = 182 + SYS_GETCWD = 183 + SYS_CAPGET = 184 + SYS_CAPSET = 185 + SYS_SIGALTSTACK = 186 + SYS_SENDFILE = 187 + SYS_VFORK = 190 + SYS_UGETRLIMIT = 191 + SYS_MMAP2 = 192 + SYS_TRUNCATE64 = 193 + SYS_FTRUNCATE64 = 194 + SYS_STAT64 = 195 + SYS_LSTAT64 = 196 + SYS_FSTAT64 = 197 + SYS_LCHOWN32 = 198 + SYS_GETUID32 = 199 + SYS_GETGID32 = 200 + SYS_GETEUID32 = 201 + SYS_GETEGID32 = 202 + SYS_SETREUID32 = 203 + SYS_SETREGID32 = 204 + SYS_GETGROUPS32 = 205 + SYS_SETGROUPS32 = 206 + SYS_FCHOWN32 = 207 + SYS_SETRESUID32 = 208 + SYS_GETRESUID32 = 209 + SYS_SETRESGID32 = 210 + SYS_GETRESGID32 = 211 + SYS_CHOWN32 = 212 + SYS_SETUID32 = 213 + SYS_SETGID32 = 214 + SYS_SETFSUID32 = 215 + SYS_SETFSGID32 = 216 + SYS_GETDENTS64 = 217 + SYS_PIVOT_ROOT = 218 + SYS_MINCORE = 219 + SYS_MADVISE = 220 + SYS_FCNTL64 = 221 + SYS_GETTID = 224 + SYS_READAHEAD = 225 + SYS_SETXATTR = 226 + SYS_LSETXATTR = 227 + SYS_FSETXATTR = 228 + SYS_GETXATTR = 229 + SYS_LGETXATTR = 230 + SYS_FGETXATTR = 231 + SYS_LISTXATTR = 232 + SYS_LLISTXATTR = 233 + SYS_FLISTXATTR = 234 + SYS_REMOVEXATTR = 235 + SYS_LREMOVEXATTR = 236 + SYS_FREMOVEXATTR = 237 + SYS_TKILL = 238 + SYS_SENDFILE64 = 239 + SYS_FUTEX = 240 + SYS_SCHED_SETAFFINITY = 241 + SYS_SCHED_GETAFFINITY = 242 + SYS_IO_SETUP = 243 + SYS_IO_DESTROY = 244 + SYS_IO_GETEVENTS = 245 + SYS_IO_SUBMIT = 246 + SYS_IO_CANCEL = 247 + SYS_EXIT_GROUP = 248 + SYS_LOOKUP_DCOOKIE = 249 + SYS_EPOLL_CREATE = 250 + SYS_EPOLL_CTL = 251 + SYS_EPOLL_WAIT = 252 + SYS_REMAP_FILE_PAGES = 253 + SYS_SET_TID_ADDRESS = 256 + SYS_TIMER_CREATE = 257 + SYS_TIMER_SETTIME = 258 + SYS_TIMER_GETTIME = 259 + SYS_TIMER_GETOVERRUN = 260 + SYS_TIMER_DELETE = 261 + SYS_CLOCK_SETTIME = 262 + SYS_CLOCK_GETTIME = 263 + SYS_CLOCK_GETRES = 264 + SYS_CLOCK_NANOSLEEP = 265 + SYS_STATFS64 = 266 + SYS_FSTATFS64 = 267 + SYS_TGKILL = 268 + SYS_UTIMES = 269 + SYS_ARM_FADVISE64_64 = 270 + SYS_PCICONFIG_IOBASE = 271 + SYS_PCICONFIG_READ = 272 + SYS_PCICONFIG_WRITE = 273 + SYS_MQ_OPEN = 274 + SYS_MQ_UNLINK = 275 + SYS_MQ_TIMEDSEND = 276 + SYS_MQ_TIMEDRECEIVE = 277 + SYS_MQ_NOTIFY = 278 + SYS_MQ_GETSETATTR = 279 + SYS_WAITID = 280 + SYS_SOCKET = 281 + SYS_BIND = 282 + SYS_CONNECT = 283 + SYS_LISTEN = 284 + SYS_ACCEPT = 285 + SYS_GETSOCKNAME = 286 + SYS_GETPEERNAME = 287 + SYS_SOCKETPAIR = 288 + SYS_SEND = 289 + SYS_SENDTO = 290 + SYS_RECV = 291 + SYS_RECVFROM = 292 + SYS_SHUTDOWN = 293 + SYS_SETSOCKOPT = 294 + SYS_GETSOCKOPT = 295 + SYS_SENDMSG = 296 + SYS_RECVMSG = 297 + SYS_SEMOP = 298 + SYS_SEMGET = 299 + SYS_SEMCTL = 300 + SYS_MSGSND = 301 + SYS_MSGRCV = 302 + SYS_MSGGET = 303 + SYS_MSGCTL = 304 + SYS_SHMAT = 305 + SYS_SHMDT = 306 + SYS_SHMGET = 307 + SYS_SHMCTL = 308 + SYS_ADD_KEY = 309 + SYS_REQUEST_KEY = 310 + SYS_KEYCTL = 311 + SYS_SEMTIMEDOP = 312 + SYS_VSERVER = 313 + SYS_IOPRIO_SET = 314 + SYS_IOPRIO_GET = 315 + SYS_INOTIFY_INIT = 316 + SYS_INOTIFY_ADD_WATCH = 317 + SYS_INOTIFY_RM_WATCH = 318 + SYS_MBIND = 319 + SYS_GET_MEMPOLICY = 320 + SYS_SET_MEMPOLICY = 321 + SYS_OPENAT = 322 + SYS_MKDIRAT = 323 + SYS_MKNODAT = 324 + SYS_FCHOWNAT = 325 + SYS_FUTIMESAT = 326 + SYS_FSTATAT64 = 327 + SYS_UNLINKAT = 328 + SYS_RENAMEAT = 329 + SYS_LINKAT = 330 + SYS_SYMLINKAT = 331 + SYS_READLINKAT = 332 + SYS_FCHMODAT = 333 + SYS_FACCESSAT = 334 + SYS_PSELECT6 = 335 + SYS_PPOLL = 336 + SYS_UNSHARE = 337 + SYS_SET_ROBUST_LIST = 338 + SYS_GET_ROBUST_LIST = 339 + SYS_SPLICE = 340 + SYS_ARM_SYNC_FILE_RANGE = 341 + SYS_TEE = 342 + SYS_VMSPLICE = 343 + SYS_MOVE_PAGES = 344 + SYS_GETCPU = 345 + SYS_EPOLL_PWAIT = 346 + SYS_KEXEC_LOAD = 347 + SYS_UTIMENSAT = 348 + SYS_SIGNALFD = 349 + SYS_TIMERFD_CREATE = 350 + SYS_EVENTFD = 351 + SYS_FALLOCATE = 352 + SYS_TIMERFD_SETTIME = 353 + SYS_TIMERFD_GETTIME = 354 + SYS_SIGNALFD4 = 355 + SYS_EVENTFD2 = 356 + SYS_EPOLL_CREATE1 = 357 + SYS_DUP3 = 358 + SYS_PIPE2 = 359 + SYS_INOTIFY_INIT1 = 360 + SYS_PREADV = 361 + SYS_PWRITEV = 362 + SYS_RT_TGSIGQUEUEINFO = 363 + SYS_PERF_EVENT_OPEN = 364 + SYS_RECVMMSG = 365 + SYS_ACCEPT4 = 366 + SYS_FANOTIFY_INIT = 367 + SYS_FANOTIFY_MARK = 368 + SYS_PRLIMIT64 = 369 + SYS_NAME_TO_HANDLE_AT = 370 + SYS_OPEN_BY_HANDLE_AT = 371 + SYS_CLOCK_ADJTIME = 372 + SYS_SYNCFS = 373 + SYS_SENDMMSG = 374 + SYS_SETNS = 375 + SYS_PROCESS_VM_READV = 376 + SYS_PROCESS_VM_WRITEV = 377 +) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go new file mode 100644 index 0000000000..2e9514f280 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go @@ -0,0 +1,272 @@ +// mksysnum_linux.pl /usr/include/asm-generic/unistd.h +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build arm64,linux + +package unix + +const ( + SYS_IO_SETUP = 0 + SYS_IO_DESTROY = 1 + SYS_IO_SUBMIT = 2 + SYS_IO_CANCEL = 3 + SYS_IO_GETEVENTS = 4 + SYS_SETXATTR = 5 + SYS_LSETXATTR = 6 + SYS_FSETXATTR = 7 + SYS_GETXATTR = 8 + SYS_LGETXATTR = 9 + SYS_FGETXATTR = 10 + SYS_LISTXATTR = 11 + SYS_LLISTXATTR = 12 + SYS_FLISTXATTR = 13 + SYS_REMOVEXATTR = 14 + SYS_LREMOVEXATTR = 15 + SYS_FREMOVEXATTR = 16 + SYS_GETCWD = 17 + SYS_LOOKUP_DCOOKIE = 18 + SYS_EVENTFD2 = 19 + SYS_EPOLL_CREATE1 = 20 + SYS_EPOLL_CTL = 21 + SYS_EPOLL_PWAIT = 22 + SYS_DUP = 23 + SYS_DUP3 = 24 + SYS_FCNTL = 25 + SYS_INOTIFY_INIT1 = 26 + SYS_INOTIFY_ADD_WATCH = 27 + SYS_INOTIFY_RM_WATCH = 28 + SYS_IOCTL = 29 + SYS_IOPRIO_SET = 30 + SYS_IOPRIO_GET = 31 + SYS_FLOCK = 32 + SYS_MKNODAT = 33 + SYS_MKDIRAT = 34 + SYS_UNLINKAT = 35 + SYS_SYMLINKAT = 36 + SYS_LINKAT = 37 + SYS_RENAMEAT = 38 + SYS_UMOUNT2 = 39 + SYS_MOUNT = 40 + SYS_PIVOT_ROOT = 41 + SYS_NFSSERVCTL = 42 + SYS_STATFS = 43 + SYS_FSTATFS = 44 + SYS_TRUNCATE = 45 + SYS_FTRUNCATE = 46 + SYS_FALLOCATE = 47 + SYS_FACCESSAT = 48 + SYS_CHDIR = 49 + SYS_FCHDIR = 50 + SYS_CHROOT = 51 + SYS_FCHMOD = 52 + SYS_FCHMODAT = 53 + SYS_FCHOWNAT = 54 + SYS_FCHOWN = 55 + SYS_OPENAT = 56 + SYS_CLOSE = 57 + SYS_VHANGUP = 58 + SYS_PIPE2 = 59 + SYS_QUOTACTL = 60 + SYS_GETDENTS64 = 61 + SYS_LSEEK = 62 + SYS_READ = 63 + SYS_WRITE = 64 + SYS_READV = 65 + SYS_WRITEV = 66 + SYS_PREAD64 = 67 + SYS_PWRITE64 = 68 + SYS_PREADV = 69 + SYS_PWRITEV = 70 + SYS_SENDFILE = 71 + SYS_PSELECT6 = 72 + SYS_PPOLL = 73 + SYS_SIGNALFD4 = 74 + SYS_VMSPLICE = 75 + SYS_SPLICE = 76 + SYS_TEE = 77 + SYS_READLINKAT = 78 + SYS_FSTATAT = 79 + SYS_FSTAT = 80 + SYS_SYNC = 81 + SYS_FSYNC = 82 + SYS_FDATASYNC = 83 + SYS_SYNC_FILE_RANGE = 84 + SYS_TIMERFD_CREATE = 85 + SYS_TIMERFD_SETTIME = 86 + SYS_TIMERFD_GETTIME = 87 + SYS_UTIMENSAT = 88 + SYS_ACCT = 89 + SYS_CAPGET = 90 + SYS_CAPSET = 91 + SYS_PERSONALITY = 92 + SYS_EXIT = 93 + SYS_EXIT_GROUP = 94 + SYS_WAITID = 95 + SYS_SET_TID_ADDRESS = 96 + SYS_UNSHARE = 97 + SYS_FUTEX = 98 + SYS_SET_ROBUST_LIST = 99 + SYS_GET_ROBUST_LIST = 100 + SYS_NANOSLEEP = 101 + SYS_GETITIMER = 102 + SYS_SETITIMER = 103 + SYS_KEXEC_LOAD = 104 + SYS_INIT_MODULE = 105 + SYS_DELETE_MODULE = 106 + SYS_TIMER_CREATE = 107 + SYS_TIMER_GETTIME = 108 + SYS_TIMER_GETOVERRUN = 109 + SYS_TIMER_SETTIME = 110 + SYS_TIMER_DELETE = 111 + SYS_CLOCK_SETTIME = 112 + SYS_CLOCK_GETTIME = 113 + SYS_CLOCK_GETRES = 114 + SYS_CLOCK_NANOSLEEP = 115 + SYS_SYSLOG = 116 + SYS_PTRACE = 117 + SYS_SCHED_SETPARAM = 118 + SYS_SCHED_SETSCHEDULER = 119 + SYS_SCHED_GETSCHEDULER = 120 + SYS_SCHED_GETPARAM = 121 + SYS_SCHED_SETAFFINITY = 122 + SYS_SCHED_GETAFFINITY = 123 + SYS_SCHED_YIELD = 124 + SYS_SCHED_GET_PRIORITY_MAX = 125 + SYS_SCHED_GET_PRIORITY_MIN = 126 + SYS_SCHED_RR_GET_INTERVAL = 127 + SYS_RESTART_SYSCALL = 128 + SYS_KILL = 129 + SYS_TKILL = 130 + SYS_TGKILL = 131 + SYS_SIGALTSTACK = 132 + SYS_RT_SIGSUSPEND = 133 + SYS_RT_SIGACTION = 134 + SYS_RT_SIGPROCMASK = 135 + SYS_RT_SIGPENDING = 136 + SYS_RT_SIGTIMEDWAIT = 137 + SYS_RT_SIGQUEUEINFO = 138 + SYS_RT_SIGRETURN = 139 + SYS_SETPRIORITY = 140 + SYS_GETPRIORITY = 141 + SYS_REBOOT = 142 + SYS_SETREGID = 143 + SYS_SETGID = 144 + SYS_SETREUID = 145 + SYS_SETUID = 146 + SYS_SETRESUID = 147 + SYS_GETRESUID = 148 + SYS_SETRESGID = 149 + SYS_GETRESGID = 150 + SYS_SETFSUID = 151 + SYS_SETFSGID = 152 + SYS_TIMES = 153 + SYS_SETPGID = 154 + SYS_GETPGID = 155 + SYS_GETSID = 156 + SYS_SETSID = 157 + SYS_GETGROUPS = 158 + SYS_SETGROUPS = 159 + SYS_UNAME = 160 + SYS_SETHOSTNAME = 161 + SYS_SETDOMAINNAME = 162 + SYS_GETRLIMIT = 163 + SYS_SETRLIMIT = 164 + SYS_GETRUSAGE = 165 + SYS_UMASK = 166 + SYS_PRCTL = 167 + SYS_GETCPU = 168 + SYS_GETTIMEOFDAY = 169 + SYS_SETTIMEOFDAY = 170 + SYS_ADJTIMEX = 171 + SYS_GETPID = 172 + SYS_GETPPID = 173 + SYS_GETUID = 174 + SYS_GETEUID = 175 + SYS_GETGID = 176 + SYS_GETEGID = 177 + SYS_GETTID = 178 + SYS_SYSINFO = 179 + SYS_MQ_OPEN = 180 + SYS_MQ_UNLINK = 181 + SYS_MQ_TIMEDSEND = 182 + SYS_MQ_TIMEDRECEIVE = 183 + SYS_MQ_NOTIFY = 184 + SYS_MQ_GETSETATTR = 185 + SYS_MSGGET = 186 + SYS_MSGCTL = 187 + SYS_MSGRCV = 188 + SYS_MSGSND = 189 + SYS_SEMGET = 190 + SYS_SEMCTL = 191 + SYS_SEMTIMEDOP = 192 + SYS_SEMOP = 193 + SYS_SHMGET = 194 + SYS_SHMCTL = 195 + SYS_SHMAT = 196 + SYS_SHMDT = 197 + SYS_SOCKET = 198 + SYS_SOCKETPAIR = 199 + SYS_BIND = 200 + SYS_LISTEN = 201 + SYS_ACCEPT = 202 + SYS_CONNECT = 203 + SYS_GETSOCKNAME = 204 + SYS_GETPEERNAME = 205 + SYS_SENDTO = 206 + SYS_RECVFROM = 207 + SYS_SETSOCKOPT = 208 + SYS_GETSOCKOPT = 209 + SYS_SHUTDOWN = 210 + SYS_SENDMSG = 211 + SYS_RECVMSG = 212 + SYS_READAHEAD = 213 + SYS_BRK = 214 + SYS_MUNMAP = 215 + SYS_MREMAP = 216 + SYS_ADD_KEY = 217 + SYS_REQUEST_KEY = 218 + SYS_KEYCTL = 219 + SYS_CLONE = 220 + SYS_EXECVE = 221 + SYS_MMAP = 222 + SYS_FADVISE64 = 223 + SYS_SWAPON = 224 + SYS_SWAPOFF = 225 + SYS_MPROTECT = 226 + SYS_MSYNC = 227 + SYS_MLOCK = 228 + SYS_MUNLOCK = 229 + SYS_MLOCKALL = 230 + SYS_MUNLOCKALL = 231 + SYS_MINCORE = 232 + SYS_MADVISE = 233 + SYS_REMAP_FILE_PAGES = 234 + SYS_MBIND = 235 + SYS_GET_MEMPOLICY = 236 + SYS_SET_MEMPOLICY = 237 + SYS_MIGRATE_PAGES = 238 + SYS_MOVE_PAGES = 239 + SYS_RT_TGSIGQUEUEINFO = 240 + SYS_PERF_EVENT_OPEN = 241 + SYS_ACCEPT4 = 242 + SYS_RECVMMSG = 243 + SYS_ARCH_SPECIFIC_SYSCALL = 244 + SYS_WAIT4 = 260 + SYS_PRLIMIT64 = 261 + SYS_FANOTIFY_INIT = 262 + SYS_FANOTIFY_MARK = 263 + SYS_NAME_TO_HANDLE_AT = 264 + SYS_OPEN_BY_HANDLE_AT = 265 + SYS_CLOCK_ADJTIME = 266 + SYS_SYNCFS = 267 + SYS_SETNS = 268 + SYS_SENDMMSG = 269 + SYS_PROCESS_VM_READV = 270 + SYS_PROCESS_VM_WRITEV = 271 + SYS_KCMP = 272 + SYS_FINIT_MODULE = 273 + SYS_SCHED_SETATTR = 274 + SYS_SCHED_GETATTR = 275 + SYS_RENAMEAT2 = 276 + SYS_SECCOMP = 277 +) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go new file mode 100644 index 0000000000..5ffe1c7191 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go @@ -0,0 +1,327 @@ +// mksysnum_linux.pl /usr/include/asm/unistd.h +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build mips64,linux + +package unix + +const ( + SYS_READ = 5000 + SYS_WRITE = 5001 + SYS_OPEN = 5002 + SYS_CLOSE = 5003 + SYS_STAT = 5004 + SYS_FSTAT = 5005 + SYS_LSTAT = 5006 + SYS_POLL = 5007 + SYS_LSEEK = 5008 + SYS_MMAP = 5009 + SYS_MPROTECT = 5010 + SYS_MUNMAP = 5011 + SYS_BRK = 5012 + SYS_RT_SIGACTION = 5013 + SYS_RT_SIGPROCMASK = 5014 + SYS_IOCTL = 5015 + SYS_PREAD64 = 5016 + SYS_PWRITE64 = 5017 + SYS_READV = 5018 + SYS_WRITEV = 5019 + SYS_ACCESS = 5020 + SYS_PIPE = 5021 + SYS__NEWSELECT = 5022 + SYS_SCHED_YIELD = 5023 + SYS_MREMAP = 5024 + SYS_MSYNC = 5025 + SYS_MINCORE = 5026 + SYS_MADVISE = 5027 + SYS_SHMGET = 5028 + SYS_SHMAT = 5029 + SYS_SHMCTL = 5030 + SYS_DUP = 5031 + SYS_DUP2 = 5032 + SYS_PAUSE = 5033 + SYS_NANOSLEEP = 5034 + SYS_GETITIMER = 5035 + SYS_SETITIMER = 5036 + SYS_ALARM = 5037 + SYS_GETPID = 5038 + SYS_SENDFILE = 5039 + SYS_SOCKET = 5040 + SYS_CONNECT = 5041 + SYS_ACCEPT = 5042 + SYS_SENDTO = 5043 + SYS_RECVFROM = 5044 + SYS_SENDMSG = 5045 + SYS_RECVMSG = 5046 + SYS_SHUTDOWN = 5047 + SYS_BIND = 5048 + SYS_LISTEN = 5049 + SYS_GETSOCKNAME = 5050 + SYS_GETPEERNAME = 5051 + SYS_SOCKETPAIR = 5052 + SYS_SETSOCKOPT = 5053 + SYS_GETSOCKOPT = 5054 + SYS_CLONE = 5055 + SYS_FORK = 5056 + SYS_EXECVE = 5057 + SYS_EXIT = 5058 + SYS_WAIT4 = 5059 + SYS_KILL = 5060 + SYS_UNAME = 5061 + SYS_SEMGET = 5062 + SYS_SEMOP = 5063 + SYS_SEMCTL = 5064 + SYS_SHMDT = 5065 + SYS_MSGGET = 5066 + SYS_MSGSND = 5067 + SYS_MSGRCV = 5068 + SYS_MSGCTL = 5069 + SYS_FCNTL = 5070 + SYS_FLOCK = 5071 + SYS_FSYNC = 5072 + SYS_FDATASYNC = 5073 + SYS_TRUNCATE = 5074 + SYS_FTRUNCATE = 5075 + SYS_GETDENTS = 5076 + SYS_GETCWD = 5077 + SYS_CHDIR = 5078 + SYS_FCHDIR = 5079 + SYS_RENAME = 5080 + SYS_MKDIR = 5081 + SYS_RMDIR = 5082 + SYS_CREAT = 5083 + SYS_LINK = 5084 + SYS_UNLINK = 5085 + SYS_SYMLINK = 5086 + SYS_READLINK = 5087 + SYS_CHMOD = 5088 + SYS_FCHMOD = 5089 + SYS_CHOWN = 5090 + SYS_FCHOWN = 5091 + SYS_LCHOWN = 5092 + SYS_UMASK = 5093 + SYS_GETTIMEOFDAY = 5094 + SYS_GETRLIMIT = 5095 + SYS_GETRUSAGE = 5096 + SYS_SYSINFO = 5097 + SYS_TIMES = 5098 + SYS_PTRACE = 5099 + SYS_GETUID = 5100 + SYS_SYSLOG = 5101 + SYS_GETGID = 5102 + SYS_SETUID = 5103 + SYS_SETGID = 5104 + SYS_GETEUID = 5105 + SYS_GETEGID = 5106 + SYS_SETPGID = 5107 + SYS_GETPPID = 5108 + SYS_GETPGRP = 5109 + SYS_SETSID = 5110 + SYS_SETREUID = 5111 + SYS_SETREGID = 5112 + SYS_GETGROUPS = 5113 + SYS_SETGROUPS = 5114 + SYS_SETRESUID = 5115 + SYS_GETRESUID = 5116 + SYS_SETRESGID = 5117 + SYS_GETRESGID = 5118 + SYS_GETPGID = 5119 + SYS_SETFSUID = 5120 + SYS_SETFSGID = 5121 + SYS_GETSID = 5122 + SYS_CAPGET = 5123 + SYS_CAPSET = 5124 + SYS_RT_SIGPENDING = 5125 + SYS_RT_SIGTIMEDWAIT = 5126 + SYS_RT_SIGQUEUEINFO = 5127 + SYS_RT_SIGSUSPEND = 5128 + SYS_SIGALTSTACK = 5129 + SYS_UTIME = 5130 + SYS_MKNOD = 5131 + SYS_PERSONALITY = 5132 + SYS_USTAT = 5133 + SYS_STATFS = 5134 + SYS_FSTATFS = 5135 + SYS_SYSFS = 5136 + SYS_GETPRIORITY = 5137 + SYS_SETPRIORITY = 5138 + SYS_SCHED_SETPARAM = 5139 + SYS_SCHED_GETPARAM = 5140 + SYS_SCHED_SETSCHEDULER = 5141 + SYS_SCHED_GETSCHEDULER = 5142 + SYS_SCHED_GET_PRIORITY_MAX = 5143 + SYS_SCHED_GET_PRIORITY_MIN = 5144 + SYS_SCHED_RR_GET_INTERVAL = 5145 + SYS_MLOCK = 5146 + SYS_MUNLOCK = 5147 + SYS_MLOCKALL = 5148 + SYS_MUNLOCKALL = 5149 + SYS_VHANGUP = 5150 + SYS_PIVOT_ROOT = 5151 + SYS__SYSCTL = 5152 + SYS_PRCTL = 5153 + SYS_ADJTIMEX = 5154 + SYS_SETRLIMIT = 5155 + SYS_CHROOT = 5156 + SYS_SYNC = 5157 + SYS_ACCT = 5158 + SYS_SETTIMEOFDAY = 5159 + SYS_MOUNT = 5160 + SYS_UMOUNT2 = 5161 + SYS_SWAPON = 5162 + SYS_SWAPOFF = 5163 + SYS_REBOOT = 5164 + SYS_SETHOSTNAME = 5165 + SYS_SETDOMAINNAME = 5166 + SYS_CREATE_MODULE = 5167 + SYS_INIT_MODULE = 5168 + SYS_DELETE_MODULE = 5169 + SYS_GET_KERNEL_SYMS = 5170 + SYS_QUERY_MODULE = 5171 + SYS_QUOTACTL = 5172 + SYS_NFSSERVCTL = 5173 + SYS_GETPMSG = 5174 + SYS_PUTPMSG = 5175 + SYS_AFS_SYSCALL = 5176 + SYS_RESERVED177 = 5177 + SYS_GETTID = 5178 + SYS_READAHEAD = 5179 + SYS_SETXATTR = 5180 + SYS_LSETXATTR = 5181 + SYS_FSETXATTR = 5182 + SYS_GETXATTR = 5183 + SYS_LGETXATTR = 5184 + SYS_FGETXATTR = 5185 + SYS_LISTXATTR = 5186 + SYS_LLISTXATTR = 5187 + SYS_FLISTXATTR = 5188 + SYS_REMOVEXATTR = 5189 + SYS_LREMOVEXATTR = 5190 + SYS_FREMOVEXATTR = 5191 + SYS_TKILL = 5192 + SYS_RESERVED193 = 5193 + SYS_FUTEX = 5194 + SYS_SCHED_SETAFFINITY = 5195 + SYS_SCHED_GETAFFINITY = 5196 + SYS_CACHEFLUSH = 5197 + SYS_CACHECTL = 5198 + SYS_SYSMIPS = 5199 + SYS_IO_SETUP = 5200 + SYS_IO_DESTROY = 5201 + SYS_IO_GETEVENTS = 5202 + SYS_IO_SUBMIT = 5203 + SYS_IO_CANCEL = 5204 + SYS_EXIT_GROUP = 5205 + SYS_LOOKUP_DCOOKIE = 5206 + SYS_EPOLL_CREATE = 5207 + SYS_EPOLL_CTL = 5208 + SYS_EPOLL_WAIT = 5209 + SYS_REMAP_FILE_PAGES = 5210 + SYS_RT_SIGRETURN = 5211 + SYS_SET_TID_ADDRESS = 5212 + SYS_RESTART_SYSCALL = 5213 + SYS_SEMTIMEDOP = 5214 + SYS_FADVISE64 = 5215 + SYS_TIMER_CREATE = 5216 + SYS_TIMER_SETTIME = 5217 + SYS_TIMER_GETTIME = 5218 + SYS_TIMER_GETOVERRUN = 5219 + SYS_TIMER_DELETE = 5220 + SYS_CLOCK_SETTIME = 5221 + SYS_CLOCK_GETTIME = 5222 + SYS_CLOCK_GETRES = 5223 + SYS_CLOCK_NANOSLEEP = 5224 + SYS_TGKILL = 5225 + SYS_UTIMES = 5226 + SYS_MBIND = 5227 + SYS_GET_MEMPOLICY = 5228 + SYS_SET_MEMPOLICY = 5229 + SYS_MQ_OPEN = 5230 + SYS_MQ_UNLINK = 5231 + SYS_MQ_TIMEDSEND = 5232 + SYS_MQ_TIMEDRECEIVE = 5233 + SYS_MQ_NOTIFY = 5234 + SYS_MQ_GETSETATTR = 5235 + SYS_VSERVER = 5236 + SYS_WAITID = 5237 + SYS_ADD_KEY = 5239 + SYS_REQUEST_KEY = 5240 + SYS_KEYCTL = 5241 + SYS_SET_THREAD_AREA = 5242 + SYS_INOTIFY_INIT = 5243 + SYS_INOTIFY_ADD_WATCH = 5244 + SYS_INOTIFY_RM_WATCH = 5245 + SYS_MIGRATE_PAGES = 5246 + SYS_OPENAT = 5247 + SYS_MKDIRAT = 5248 + SYS_MKNODAT = 5249 + SYS_FCHOWNAT = 5250 + SYS_FUTIMESAT = 5251 + SYS_NEWFSTATAT = 5252 + SYS_UNLINKAT = 5253 + SYS_RENAMEAT = 5254 + SYS_LINKAT = 5255 + SYS_SYMLINKAT = 5256 + SYS_READLINKAT = 5257 + SYS_FCHMODAT = 5258 + SYS_FACCESSAT = 5259 + SYS_PSELECT6 = 5260 + SYS_PPOLL = 5261 + SYS_UNSHARE = 5262 + SYS_SPLICE = 5263 + SYS_SYNC_FILE_RANGE = 5264 + SYS_TEE = 5265 + SYS_VMSPLICE = 5266 + SYS_MOVE_PAGES = 5267 + SYS_SET_ROBUST_LIST = 5268 + SYS_GET_ROBUST_LIST = 5269 + SYS_KEXEC_LOAD = 5270 + SYS_GETCPU = 5271 + SYS_EPOLL_PWAIT = 5272 + SYS_IOPRIO_SET = 5273 + SYS_IOPRIO_GET = 5274 + SYS_UTIMENSAT = 5275 + SYS_SIGNALFD = 5276 + SYS_TIMERFD = 5277 + SYS_EVENTFD = 5278 + SYS_FALLOCATE = 5279 + SYS_TIMERFD_CREATE = 5280 + SYS_TIMERFD_GETTIME = 5281 + SYS_TIMERFD_SETTIME = 5282 + SYS_SIGNALFD4 = 5283 + SYS_EVENTFD2 = 5284 + SYS_EPOLL_CREATE1 = 5285 + SYS_DUP3 = 5286 + SYS_PIPE2 = 5287 + SYS_INOTIFY_INIT1 = 5288 + SYS_PREADV = 5289 + SYS_PWRITEV = 5290 + SYS_RT_TGSIGQUEUEINFO = 5291 + SYS_PERF_EVENT_OPEN = 5292 + SYS_ACCEPT4 = 5293 + SYS_RECVMMSG = 5294 + SYS_FANOTIFY_INIT = 5295 + SYS_FANOTIFY_MARK = 5296 + SYS_PRLIMIT64 = 5297 + SYS_NAME_TO_HANDLE_AT = 5298 + SYS_OPEN_BY_HANDLE_AT = 5299 + SYS_CLOCK_ADJTIME = 5300 + SYS_SYNCFS = 5301 + SYS_SENDMMSG = 5302 + SYS_SETNS = 5303 + SYS_PROCESS_VM_READV = 5304 + SYS_PROCESS_VM_WRITEV = 5305 + SYS_KCMP = 5306 + SYS_FINIT_MODULE = 5307 + SYS_GETDENTS64 = 5308 + SYS_SCHED_SETATTR = 5309 + SYS_SCHED_GETATTR = 5310 + SYS_RENAMEAT2 = 5311 + SYS_SECCOMP = 5312 + SYS_GETRANDOM = 5313 + SYS_MEMFD_CREATE = 5314 + SYS_BPF = 5315 + SYS_EXECVEAT = 5316 + SYS_USERFAULTFD = 5317 + SYS_MEMBARRIER = 5318 +) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go new file mode 100644 index 0000000000..d192b940ce --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go @@ -0,0 +1,327 @@ +// mksysnum_linux.pl /usr/include/asm/unistd.h +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build mips64le,linux + +package unix + +const ( + SYS_READ = 5000 + SYS_WRITE = 5001 + SYS_OPEN = 5002 + SYS_CLOSE = 5003 + SYS_STAT = 5004 + SYS_FSTAT = 5005 + SYS_LSTAT = 5006 + SYS_POLL = 5007 + SYS_LSEEK = 5008 + SYS_MMAP = 5009 + SYS_MPROTECT = 5010 + SYS_MUNMAP = 5011 + SYS_BRK = 5012 + SYS_RT_SIGACTION = 5013 + SYS_RT_SIGPROCMASK = 5014 + SYS_IOCTL = 5015 + SYS_PREAD64 = 5016 + SYS_PWRITE64 = 5017 + SYS_READV = 5018 + SYS_WRITEV = 5019 + SYS_ACCESS = 5020 + SYS_PIPE = 5021 + SYS__NEWSELECT = 5022 + SYS_SCHED_YIELD = 5023 + SYS_MREMAP = 5024 + SYS_MSYNC = 5025 + SYS_MINCORE = 5026 + SYS_MADVISE = 5027 + SYS_SHMGET = 5028 + SYS_SHMAT = 5029 + SYS_SHMCTL = 5030 + SYS_DUP = 5031 + SYS_DUP2 = 5032 + SYS_PAUSE = 5033 + SYS_NANOSLEEP = 5034 + SYS_GETITIMER = 5035 + SYS_SETITIMER = 5036 + SYS_ALARM = 5037 + SYS_GETPID = 5038 + SYS_SENDFILE = 5039 + SYS_SOCKET = 5040 + SYS_CONNECT = 5041 + SYS_ACCEPT = 5042 + SYS_SENDTO = 5043 + SYS_RECVFROM = 5044 + SYS_SENDMSG = 5045 + SYS_RECVMSG = 5046 + SYS_SHUTDOWN = 5047 + SYS_BIND = 5048 + SYS_LISTEN = 5049 + SYS_GETSOCKNAME = 5050 + SYS_GETPEERNAME = 5051 + SYS_SOCKETPAIR = 5052 + SYS_SETSOCKOPT = 5053 + SYS_GETSOCKOPT = 5054 + SYS_CLONE = 5055 + SYS_FORK = 5056 + SYS_EXECVE = 5057 + SYS_EXIT = 5058 + SYS_WAIT4 = 5059 + SYS_KILL = 5060 + SYS_UNAME = 5061 + SYS_SEMGET = 5062 + SYS_SEMOP = 5063 + SYS_SEMCTL = 5064 + SYS_SHMDT = 5065 + SYS_MSGGET = 5066 + SYS_MSGSND = 5067 + SYS_MSGRCV = 5068 + SYS_MSGCTL = 5069 + SYS_FCNTL = 5070 + SYS_FLOCK = 5071 + SYS_FSYNC = 5072 + SYS_FDATASYNC = 5073 + SYS_TRUNCATE = 5074 + SYS_FTRUNCATE = 5075 + SYS_GETDENTS = 5076 + SYS_GETCWD = 5077 + SYS_CHDIR = 5078 + SYS_FCHDIR = 5079 + SYS_RENAME = 5080 + SYS_MKDIR = 5081 + SYS_RMDIR = 5082 + SYS_CREAT = 5083 + SYS_LINK = 5084 + SYS_UNLINK = 5085 + SYS_SYMLINK = 5086 + SYS_READLINK = 5087 + SYS_CHMOD = 5088 + SYS_FCHMOD = 5089 + SYS_CHOWN = 5090 + SYS_FCHOWN = 5091 + SYS_LCHOWN = 5092 + SYS_UMASK = 5093 + SYS_GETTIMEOFDAY = 5094 + SYS_GETRLIMIT = 5095 + SYS_GETRUSAGE = 5096 + SYS_SYSINFO = 5097 + SYS_TIMES = 5098 + SYS_PTRACE = 5099 + SYS_GETUID = 5100 + SYS_SYSLOG = 5101 + SYS_GETGID = 5102 + SYS_SETUID = 5103 + SYS_SETGID = 5104 + SYS_GETEUID = 5105 + SYS_GETEGID = 5106 + SYS_SETPGID = 5107 + SYS_GETPPID = 5108 + SYS_GETPGRP = 5109 + SYS_SETSID = 5110 + SYS_SETREUID = 5111 + SYS_SETREGID = 5112 + SYS_GETGROUPS = 5113 + SYS_SETGROUPS = 5114 + SYS_SETRESUID = 5115 + SYS_GETRESUID = 5116 + SYS_SETRESGID = 5117 + SYS_GETRESGID = 5118 + SYS_GETPGID = 5119 + SYS_SETFSUID = 5120 + SYS_SETFSGID = 5121 + SYS_GETSID = 5122 + SYS_CAPGET = 5123 + SYS_CAPSET = 5124 + SYS_RT_SIGPENDING = 5125 + SYS_RT_SIGTIMEDWAIT = 5126 + SYS_RT_SIGQUEUEINFO = 5127 + SYS_RT_SIGSUSPEND = 5128 + SYS_SIGALTSTACK = 5129 + SYS_UTIME = 5130 + SYS_MKNOD = 5131 + SYS_PERSONALITY = 5132 + SYS_USTAT = 5133 + SYS_STATFS = 5134 + SYS_FSTATFS = 5135 + SYS_SYSFS = 5136 + SYS_GETPRIORITY = 5137 + SYS_SETPRIORITY = 5138 + SYS_SCHED_SETPARAM = 5139 + SYS_SCHED_GETPARAM = 5140 + SYS_SCHED_SETSCHEDULER = 5141 + SYS_SCHED_GETSCHEDULER = 5142 + SYS_SCHED_GET_PRIORITY_MAX = 5143 + SYS_SCHED_GET_PRIORITY_MIN = 5144 + SYS_SCHED_RR_GET_INTERVAL = 5145 + SYS_MLOCK = 5146 + SYS_MUNLOCK = 5147 + SYS_MLOCKALL = 5148 + SYS_MUNLOCKALL = 5149 + SYS_VHANGUP = 5150 + SYS_PIVOT_ROOT = 5151 + SYS__SYSCTL = 5152 + SYS_PRCTL = 5153 + SYS_ADJTIMEX = 5154 + SYS_SETRLIMIT = 5155 + SYS_CHROOT = 5156 + SYS_SYNC = 5157 + SYS_ACCT = 5158 + SYS_SETTIMEOFDAY = 5159 + SYS_MOUNT = 5160 + SYS_UMOUNT2 = 5161 + SYS_SWAPON = 5162 + SYS_SWAPOFF = 5163 + SYS_REBOOT = 5164 + SYS_SETHOSTNAME = 5165 + SYS_SETDOMAINNAME = 5166 + SYS_CREATE_MODULE = 5167 + SYS_INIT_MODULE = 5168 + SYS_DELETE_MODULE = 5169 + SYS_GET_KERNEL_SYMS = 5170 + SYS_QUERY_MODULE = 5171 + SYS_QUOTACTL = 5172 + SYS_NFSSERVCTL = 5173 + SYS_GETPMSG = 5174 + SYS_PUTPMSG = 5175 + SYS_AFS_SYSCALL = 5176 + SYS_RESERVED177 = 5177 + SYS_GETTID = 5178 + SYS_READAHEAD = 5179 + SYS_SETXATTR = 5180 + SYS_LSETXATTR = 5181 + SYS_FSETXATTR = 5182 + SYS_GETXATTR = 5183 + SYS_LGETXATTR = 5184 + SYS_FGETXATTR = 5185 + SYS_LISTXATTR = 5186 + SYS_LLISTXATTR = 5187 + SYS_FLISTXATTR = 5188 + SYS_REMOVEXATTR = 5189 + SYS_LREMOVEXATTR = 5190 + SYS_FREMOVEXATTR = 5191 + SYS_TKILL = 5192 + SYS_RESERVED193 = 5193 + SYS_FUTEX = 5194 + SYS_SCHED_SETAFFINITY = 5195 + SYS_SCHED_GETAFFINITY = 5196 + SYS_CACHEFLUSH = 5197 + SYS_CACHECTL = 5198 + SYS_SYSMIPS = 5199 + SYS_IO_SETUP = 5200 + SYS_IO_DESTROY = 5201 + SYS_IO_GETEVENTS = 5202 + SYS_IO_SUBMIT = 5203 + SYS_IO_CANCEL = 5204 + SYS_EXIT_GROUP = 5205 + SYS_LOOKUP_DCOOKIE = 5206 + SYS_EPOLL_CREATE = 5207 + SYS_EPOLL_CTL = 5208 + SYS_EPOLL_WAIT = 5209 + SYS_REMAP_FILE_PAGES = 5210 + SYS_RT_SIGRETURN = 5211 + SYS_SET_TID_ADDRESS = 5212 + SYS_RESTART_SYSCALL = 5213 + SYS_SEMTIMEDOP = 5214 + SYS_FADVISE64 = 5215 + SYS_TIMER_CREATE = 5216 + SYS_TIMER_SETTIME = 5217 + SYS_TIMER_GETTIME = 5218 + SYS_TIMER_GETOVERRUN = 5219 + SYS_TIMER_DELETE = 5220 + SYS_CLOCK_SETTIME = 5221 + SYS_CLOCK_GETTIME = 5222 + SYS_CLOCK_GETRES = 5223 + SYS_CLOCK_NANOSLEEP = 5224 + SYS_TGKILL = 5225 + SYS_UTIMES = 5226 + SYS_MBIND = 5227 + SYS_GET_MEMPOLICY = 5228 + SYS_SET_MEMPOLICY = 5229 + SYS_MQ_OPEN = 5230 + SYS_MQ_UNLINK = 5231 + SYS_MQ_TIMEDSEND = 5232 + SYS_MQ_TIMEDRECEIVE = 5233 + SYS_MQ_NOTIFY = 5234 + SYS_MQ_GETSETATTR = 5235 + SYS_VSERVER = 5236 + SYS_WAITID = 5237 + SYS_ADD_KEY = 5239 + SYS_REQUEST_KEY = 5240 + SYS_KEYCTL = 5241 + SYS_SET_THREAD_AREA = 5242 + SYS_INOTIFY_INIT = 5243 + SYS_INOTIFY_ADD_WATCH = 5244 + SYS_INOTIFY_RM_WATCH = 5245 + SYS_MIGRATE_PAGES = 5246 + SYS_OPENAT = 5247 + SYS_MKDIRAT = 5248 + SYS_MKNODAT = 5249 + SYS_FCHOWNAT = 5250 + SYS_FUTIMESAT = 5251 + SYS_NEWFSTATAT = 5252 + SYS_UNLINKAT = 5253 + SYS_RENAMEAT = 5254 + SYS_LINKAT = 5255 + SYS_SYMLINKAT = 5256 + SYS_READLINKAT = 5257 + SYS_FCHMODAT = 5258 + SYS_FACCESSAT = 5259 + SYS_PSELECT6 = 5260 + SYS_PPOLL = 5261 + SYS_UNSHARE = 5262 + SYS_SPLICE = 5263 + SYS_SYNC_FILE_RANGE = 5264 + SYS_TEE = 5265 + SYS_VMSPLICE = 5266 + SYS_MOVE_PAGES = 5267 + SYS_SET_ROBUST_LIST = 5268 + SYS_GET_ROBUST_LIST = 5269 + SYS_KEXEC_LOAD = 5270 + SYS_GETCPU = 5271 + SYS_EPOLL_PWAIT = 5272 + SYS_IOPRIO_SET = 5273 + SYS_IOPRIO_GET = 5274 + SYS_UTIMENSAT = 5275 + SYS_SIGNALFD = 5276 + SYS_TIMERFD = 5277 + SYS_EVENTFD = 5278 + SYS_FALLOCATE = 5279 + SYS_TIMERFD_CREATE = 5280 + SYS_TIMERFD_GETTIME = 5281 + SYS_TIMERFD_SETTIME = 5282 + SYS_SIGNALFD4 = 5283 + SYS_EVENTFD2 = 5284 + SYS_EPOLL_CREATE1 = 5285 + SYS_DUP3 = 5286 + SYS_PIPE2 = 5287 + SYS_INOTIFY_INIT1 = 5288 + SYS_PREADV = 5289 + SYS_PWRITEV = 5290 + SYS_RT_TGSIGQUEUEINFO = 5291 + SYS_PERF_EVENT_OPEN = 5292 + SYS_ACCEPT4 = 5293 + SYS_RECVMMSG = 5294 + SYS_FANOTIFY_INIT = 5295 + SYS_FANOTIFY_MARK = 5296 + SYS_PRLIMIT64 = 5297 + SYS_NAME_TO_HANDLE_AT = 5298 + SYS_OPEN_BY_HANDLE_AT = 5299 + SYS_CLOCK_ADJTIME = 5300 + SYS_SYNCFS = 5301 + SYS_SENDMMSG = 5302 + SYS_SETNS = 5303 + SYS_PROCESS_VM_READV = 5304 + SYS_PROCESS_VM_WRITEV = 5305 + SYS_KCMP = 5306 + SYS_FINIT_MODULE = 5307 + SYS_GETDENTS64 = 5308 + SYS_SCHED_SETATTR = 5309 + SYS_SCHED_GETATTR = 5310 + SYS_RENAMEAT2 = 5311 + SYS_SECCOMP = 5312 + SYS_GETRANDOM = 5313 + SYS_MEMFD_CREATE = 5314 + SYS_BPF = 5315 + SYS_EXECVEAT = 5316 + SYS_USERFAULTFD = 5317 + SYS_MEMBARRIER = 5318 +) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go new file mode 100644 index 0000000000..e1b08f00d3 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go @@ -0,0 +1,360 @@ +// mksysnum_linux.pl /usr/include/asm/unistd.h +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build ppc64,linux + +package unix + +const ( + SYS_RESTART_SYSCALL = 0 + SYS_EXIT = 1 + SYS_FORK = 2 + SYS_READ = 3 + SYS_WRITE = 4 + SYS_OPEN = 5 + SYS_CLOSE = 6 + SYS_WAITPID = 7 + SYS_CREAT = 8 + SYS_LINK = 9 + SYS_UNLINK = 10 + SYS_EXECVE = 11 + SYS_CHDIR = 12 + SYS_TIME = 13 + SYS_MKNOD = 14 + SYS_CHMOD = 15 + SYS_LCHOWN = 16 + SYS_BREAK = 17 + SYS_OLDSTAT = 18 + SYS_LSEEK = 19 + SYS_GETPID = 20 + SYS_MOUNT = 21 + SYS_UMOUNT = 22 + SYS_SETUID = 23 + SYS_GETUID = 24 + SYS_STIME = 25 + SYS_PTRACE = 26 + SYS_ALARM = 27 + SYS_OLDFSTAT = 28 + SYS_PAUSE = 29 + SYS_UTIME = 30 + SYS_STTY = 31 + SYS_GTTY = 32 + SYS_ACCESS = 33 + SYS_NICE = 34 + SYS_FTIME = 35 + SYS_SYNC = 36 + SYS_KILL = 37 + SYS_RENAME = 38 + SYS_MKDIR = 39 + SYS_RMDIR = 40 + SYS_DUP = 41 + SYS_PIPE = 42 + SYS_TIMES = 43 + SYS_PROF = 44 + SYS_BRK = 45 + SYS_SETGID = 46 + SYS_GETGID = 47 + SYS_SIGNAL = 48 + SYS_GETEUID = 49 + SYS_GETEGID = 50 + SYS_ACCT = 51 + SYS_UMOUNT2 = 52 + SYS_LOCK = 53 + SYS_IOCTL = 54 + SYS_FCNTL = 55 + SYS_MPX = 56 + SYS_SETPGID = 57 + SYS_ULIMIT = 58 + SYS_OLDOLDUNAME = 59 + SYS_UMASK = 60 + SYS_CHROOT = 61 + SYS_USTAT = 62 + SYS_DUP2 = 63 + SYS_GETPPID = 64 + SYS_GETPGRP = 65 + SYS_SETSID = 66 + SYS_SIGACTION = 67 + SYS_SGETMASK = 68 + SYS_SSETMASK = 69 + SYS_SETREUID = 70 + SYS_SETREGID = 71 + SYS_SIGSUSPEND = 72 + SYS_SIGPENDING = 73 + SYS_SETHOSTNAME = 74 + SYS_SETRLIMIT = 75 + SYS_GETRLIMIT = 76 + SYS_GETRUSAGE = 77 + SYS_GETTIMEOFDAY = 78 + SYS_SETTIMEOFDAY = 79 + SYS_GETGROUPS = 80 + SYS_SETGROUPS = 81 + SYS_SELECT = 82 + SYS_SYMLINK = 83 + SYS_OLDLSTAT = 84 + SYS_READLINK = 85 + SYS_USELIB = 86 + SYS_SWAPON = 87 + SYS_REBOOT = 88 + SYS_READDIR = 89 + SYS_MMAP = 90 + SYS_MUNMAP = 91 + SYS_TRUNCATE = 92 + SYS_FTRUNCATE = 93 + SYS_FCHMOD = 94 + SYS_FCHOWN = 95 + SYS_GETPRIORITY = 96 + SYS_SETPRIORITY = 97 + SYS_PROFIL = 98 + SYS_STATFS = 99 + SYS_FSTATFS = 100 + SYS_IOPERM = 101 + SYS_SOCKETCALL = 102 + SYS_SYSLOG = 103 + SYS_SETITIMER = 104 + SYS_GETITIMER = 105 + SYS_STAT = 106 + SYS_LSTAT = 107 + SYS_FSTAT = 108 + SYS_OLDUNAME = 109 + SYS_IOPL = 110 + SYS_VHANGUP = 111 + SYS_IDLE = 112 + SYS_VM86 = 113 + SYS_WAIT4 = 114 + SYS_SWAPOFF = 115 + SYS_SYSINFO = 116 + SYS_IPC = 117 + SYS_FSYNC = 118 + SYS_SIGRETURN = 119 + SYS_CLONE = 120 + SYS_SETDOMAINNAME = 121 + SYS_UNAME = 122 + SYS_MODIFY_LDT = 123 + SYS_ADJTIMEX = 124 + SYS_MPROTECT = 125 + SYS_SIGPROCMASK = 126 + SYS_CREATE_MODULE = 127 + SYS_INIT_MODULE = 128 + SYS_DELETE_MODULE = 129 + SYS_GET_KERNEL_SYMS = 130 + SYS_QUOTACTL = 131 + SYS_GETPGID = 132 + SYS_FCHDIR = 133 + SYS_BDFLUSH = 134 + SYS_SYSFS = 135 + SYS_PERSONALITY = 136 + SYS_AFS_SYSCALL = 137 + SYS_SETFSUID = 138 + SYS_SETFSGID = 139 + SYS__LLSEEK = 140 + SYS_GETDENTS = 141 + SYS__NEWSELECT = 142 + SYS_FLOCK = 143 + SYS_MSYNC = 144 + SYS_READV = 145 + SYS_WRITEV = 146 + SYS_GETSID = 147 + SYS_FDATASYNC = 148 + SYS__SYSCTL = 149 + SYS_MLOCK = 150 + SYS_MUNLOCK = 151 + SYS_MLOCKALL = 152 + SYS_MUNLOCKALL = 153 + SYS_SCHED_SETPARAM = 154 + SYS_SCHED_GETPARAM = 155 + SYS_SCHED_SETSCHEDULER = 156 + SYS_SCHED_GETSCHEDULER = 157 + SYS_SCHED_YIELD = 158 + SYS_SCHED_GET_PRIORITY_MAX = 159 + SYS_SCHED_GET_PRIORITY_MIN = 160 + SYS_SCHED_RR_GET_INTERVAL = 161 + SYS_NANOSLEEP = 162 + SYS_MREMAP = 163 + SYS_SETRESUID = 164 + SYS_GETRESUID = 165 + SYS_QUERY_MODULE = 166 + SYS_POLL = 167 + SYS_NFSSERVCTL = 168 + SYS_SETRESGID = 169 + SYS_GETRESGID = 170 + SYS_PRCTL = 171 + SYS_RT_SIGRETURN = 172 + SYS_RT_SIGACTION = 173 + SYS_RT_SIGPROCMASK = 174 + SYS_RT_SIGPENDING = 175 + SYS_RT_SIGTIMEDWAIT = 176 + SYS_RT_SIGQUEUEINFO = 177 + SYS_RT_SIGSUSPEND = 178 + SYS_PREAD64 = 179 + SYS_PWRITE64 = 180 + SYS_CHOWN = 181 + SYS_GETCWD = 182 + SYS_CAPGET = 183 + SYS_CAPSET = 184 + SYS_SIGALTSTACK = 185 + SYS_SENDFILE = 186 + SYS_GETPMSG = 187 + SYS_PUTPMSG = 188 + SYS_VFORK = 189 + SYS_UGETRLIMIT = 190 + SYS_READAHEAD = 191 + SYS_PCICONFIG_READ = 198 + SYS_PCICONFIG_WRITE = 199 + SYS_PCICONFIG_IOBASE = 200 + SYS_MULTIPLEXER = 201 + SYS_GETDENTS64 = 202 + SYS_PIVOT_ROOT = 203 + SYS_MADVISE = 205 + SYS_MINCORE = 206 + SYS_GETTID = 207 + SYS_TKILL = 208 + SYS_SETXATTR = 209 + SYS_LSETXATTR = 210 + SYS_FSETXATTR = 211 + SYS_GETXATTR = 212 + SYS_LGETXATTR = 213 + SYS_FGETXATTR = 214 + SYS_LISTXATTR = 215 + SYS_LLISTXATTR = 216 + SYS_FLISTXATTR = 217 + SYS_REMOVEXATTR = 218 + SYS_LREMOVEXATTR = 219 + SYS_FREMOVEXATTR = 220 + SYS_FUTEX = 221 + SYS_SCHED_SETAFFINITY = 222 + SYS_SCHED_GETAFFINITY = 223 + SYS_TUXCALL = 225 + SYS_IO_SETUP = 227 + SYS_IO_DESTROY = 228 + SYS_IO_GETEVENTS = 229 + SYS_IO_SUBMIT = 230 + SYS_IO_CANCEL = 231 + SYS_SET_TID_ADDRESS = 232 + SYS_FADVISE64 = 233 + SYS_EXIT_GROUP = 234 + SYS_LOOKUP_DCOOKIE = 235 + SYS_EPOLL_CREATE = 236 + SYS_EPOLL_CTL = 237 + SYS_EPOLL_WAIT = 238 + SYS_REMAP_FILE_PAGES = 239 + SYS_TIMER_CREATE = 240 + SYS_TIMER_SETTIME = 241 + SYS_TIMER_GETTIME = 242 + SYS_TIMER_GETOVERRUN = 243 + SYS_TIMER_DELETE = 244 + SYS_CLOCK_SETTIME = 245 + SYS_CLOCK_GETTIME = 246 + SYS_CLOCK_GETRES = 247 + SYS_CLOCK_NANOSLEEP = 248 + SYS_SWAPCONTEXT = 249 + SYS_TGKILL = 250 + SYS_UTIMES = 251 + SYS_STATFS64 = 252 + SYS_FSTATFS64 = 253 + SYS_RTAS = 255 + SYS_SYS_DEBUG_SETCONTEXT = 256 + SYS_MIGRATE_PAGES = 258 + SYS_MBIND = 259 + SYS_GET_MEMPOLICY = 260 + SYS_SET_MEMPOLICY = 261 + SYS_MQ_OPEN = 262 + SYS_MQ_UNLINK = 263 + SYS_MQ_TIMEDSEND = 264 + SYS_MQ_TIMEDRECEIVE = 265 + SYS_MQ_NOTIFY = 266 + SYS_MQ_GETSETATTR = 267 + SYS_KEXEC_LOAD = 268 + SYS_ADD_KEY = 269 + SYS_REQUEST_KEY = 270 + SYS_KEYCTL = 271 + SYS_WAITID = 272 + SYS_IOPRIO_SET = 273 + SYS_IOPRIO_GET = 274 + SYS_INOTIFY_INIT = 275 + SYS_INOTIFY_ADD_WATCH = 276 + SYS_INOTIFY_RM_WATCH = 277 + SYS_SPU_RUN = 278 + SYS_SPU_CREATE = 279 + SYS_PSELECT6 = 280 + SYS_PPOLL = 281 + SYS_UNSHARE = 282 + SYS_SPLICE = 283 + SYS_TEE = 284 + SYS_VMSPLICE = 285 + SYS_OPENAT = 286 + SYS_MKDIRAT = 287 + SYS_MKNODAT = 288 + SYS_FCHOWNAT = 289 + SYS_FUTIMESAT = 290 + SYS_NEWFSTATAT = 291 + SYS_UNLINKAT = 292 + SYS_RENAMEAT = 293 + SYS_LINKAT = 294 + SYS_SYMLINKAT = 295 + SYS_READLINKAT = 296 + SYS_FCHMODAT = 297 + SYS_FACCESSAT = 298 + SYS_GET_ROBUST_LIST = 299 + SYS_SET_ROBUST_LIST = 300 + SYS_MOVE_PAGES = 301 + SYS_GETCPU = 302 + SYS_EPOLL_PWAIT = 303 + SYS_UTIMENSAT = 304 + SYS_SIGNALFD = 305 + SYS_TIMERFD_CREATE = 306 + SYS_EVENTFD = 307 + SYS_SYNC_FILE_RANGE2 = 308 + SYS_FALLOCATE = 309 + SYS_SUBPAGE_PROT = 310 + SYS_TIMERFD_SETTIME = 311 + SYS_TIMERFD_GETTIME = 312 + SYS_SIGNALFD4 = 313 + SYS_EVENTFD2 = 314 + SYS_EPOLL_CREATE1 = 315 + SYS_DUP3 = 316 + SYS_PIPE2 = 317 + SYS_INOTIFY_INIT1 = 318 + SYS_PERF_EVENT_OPEN = 319 + SYS_PREADV = 320 + SYS_PWRITEV = 321 + SYS_RT_TGSIGQUEUEINFO = 322 + SYS_FANOTIFY_INIT = 323 + SYS_FANOTIFY_MARK = 324 + SYS_PRLIMIT64 = 325 + SYS_SOCKET = 326 + SYS_BIND = 327 + SYS_CONNECT = 328 + SYS_LISTEN = 329 + SYS_ACCEPT = 330 + SYS_GETSOCKNAME = 331 + SYS_GETPEERNAME = 332 + SYS_SOCKETPAIR = 333 + SYS_SEND = 334 + SYS_SENDTO = 335 + SYS_RECV = 336 + SYS_RECVFROM = 337 + SYS_SHUTDOWN = 338 + SYS_SETSOCKOPT = 339 + SYS_GETSOCKOPT = 340 + SYS_SENDMSG = 341 + SYS_RECVMSG = 342 + SYS_RECVMMSG = 343 + SYS_ACCEPT4 = 344 + SYS_NAME_TO_HANDLE_AT = 345 + SYS_OPEN_BY_HANDLE_AT = 346 + SYS_CLOCK_ADJTIME = 347 + SYS_SYNCFS = 348 + SYS_SENDMMSG = 349 + SYS_SETNS = 350 + SYS_PROCESS_VM_READV = 351 + SYS_PROCESS_VM_WRITEV = 352 + SYS_FINIT_MODULE = 353 + SYS_KCMP = 354 + SYS_SCHED_SETATTR = 355 + SYS_SCHED_GETATTR = 356 + SYS_RENAMEAT2 = 357 + SYS_SECCOMP = 358 + SYS_GETRANDOM = 359 + SYS_MEMFD_CREATE = 360 + SYS_BPF = 361 +) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go new file mode 100644 index 0000000000..45e63f51a4 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go @@ -0,0 +1,353 @@ +// mksysnum_linux.pl /usr/include/powerpc64le-linux-gnu/asm/unistd.h +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build ppc64le,linux + +package unix + +const ( + SYS_RESTART_SYSCALL = 0 + SYS_EXIT = 1 + SYS_FORK = 2 + SYS_READ = 3 + SYS_WRITE = 4 + SYS_OPEN = 5 + SYS_CLOSE = 6 + SYS_WAITPID = 7 + SYS_CREAT = 8 + SYS_LINK = 9 + SYS_UNLINK = 10 + SYS_EXECVE = 11 + SYS_CHDIR = 12 + SYS_TIME = 13 + SYS_MKNOD = 14 + SYS_CHMOD = 15 + SYS_LCHOWN = 16 + SYS_BREAK = 17 + SYS_OLDSTAT = 18 + SYS_LSEEK = 19 + SYS_GETPID = 20 + SYS_MOUNT = 21 + SYS_UMOUNT = 22 + SYS_SETUID = 23 + SYS_GETUID = 24 + SYS_STIME = 25 + SYS_PTRACE = 26 + SYS_ALARM = 27 + SYS_OLDFSTAT = 28 + SYS_PAUSE = 29 + SYS_UTIME = 30 + SYS_STTY = 31 + SYS_GTTY = 32 + SYS_ACCESS = 33 + SYS_NICE = 34 + SYS_FTIME = 35 + SYS_SYNC = 36 + SYS_KILL = 37 + SYS_RENAME = 38 + SYS_MKDIR = 39 + SYS_RMDIR = 40 + SYS_DUP = 41 + SYS_PIPE = 42 + SYS_TIMES = 43 + SYS_PROF = 44 + SYS_BRK = 45 + SYS_SETGID = 46 + SYS_GETGID = 47 + SYS_SIGNAL = 48 + SYS_GETEUID = 49 + SYS_GETEGID = 50 + SYS_ACCT = 51 + SYS_UMOUNT2 = 52 + SYS_LOCK = 53 + SYS_IOCTL = 54 + SYS_FCNTL = 55 + SYS_MPX = 56 + SYS_SETPGID = 57 + SYS_ULIMIT = 58 + SYS_OLDOLDUNAME = 59 + SYS_UMASK = 60 + SYS_CHROOT = 61 + SYS_USTAT = 62 + SYS_DUP2 = 63 + SYS_GETPPID = 64 + SYS_GETPGRP = 65 + SYS_SETSID = 66 + SYS_SIGACTION = 67 + SYS_SGETMASK = 68 + SYS_SSETMASK = 69 + SYS_SETREUID = 70 + SYS_SETREGID = 71 + SYS_SIGSUSPEND = 72 + SYS_SIGPENDING = 73 + SYS_SETHOSTNAME = 74 + SYS_SETRLIMIT = 75 + SYS_GETRLIMIT = 76 + SYS_GETRUSAGE = 77 + SYS_GETTIMEOFDAY = 78 + SYS_SETTIMEOFDAY = 79 + SYS_GETGROUPS = 80 + SYS_SETGROUPS = 81 + SYS_SELECT = 82 + SYS_SYMLINK = 83 + SYS_OLDLSTAT = 84 + SYS_READLINK = 85 + SYS_USELIB = 86 + SYS_SWAPON = 87 + SYS_REBOOT = 88 + SYS_READDIR = 89 + SYS_MMAP = 90 + SYS_MUNMAP = 91 + SYS_TRUNCATE = 92 + SYS_FTRUNCATE = 93 + SYS_FCHMOD = 94 + SYS_FCHOWN = 95 + SYS_GETPRIORITY = 96 + SYS_SETPRIORITY = 97 + SYS_PROFIL = 98 + SYS_STATFS = 99 + SYS_FSTATFS = 100 + SYS_IOPERM = 101 + SYS_SOCKETCALL = 102 + SYS_SYSLOG = 103 + SYS_SETITIMER = 104 + SYS_GETITIMER = 105 + SYS_STAT = 106 + SYS_LSTAT = 107 + SYS_FSTAT = 108 + SYS_OLDUNAME = 109 + SYS_IOPL = 110 + SYS_VHANGUP = 111 + SYS_IDLE = 112 + SYS_VM86 = 113 + SYS_WAIT4 = 114 + SYS_SWAPOFF = 115 + SYS_SYSINFO = 116 + SYS_IPC = 117 + SYS_FSYNC = 118 + SYS_SIGRETURN = 119 + SYS_CLONE = 120 + SYS_SETDOMAINNAME = 121 + SYS_UNAME = 122 + SYS_MODIFY_LDT = 123 + SYS_ADJTIMEX = 124 + SYS_MPROTECT = 125 + SYS_SIGPROCMASK = 126 + SYS_CREATE_MODULE = 127 + SYS_INIT_MODULE = 128 + SYS_DELETE_MODULE = 129 + SYS_GET_KERNEL_SYMS = 130 + SYS_QUOTACTL = 131 + SYS_GETPGID = 132 + SYS_FCHDIR = 133 + SYS_BDFLUSH = 134 + SYS_SYSFS = 135 + SYS_PERSONALITY = 136 + SYS_AFS_SYSCALL = 137 + SYS_SETFSUID = 138 + SYS_SETFSGID = 139 + SYS__LLSEEK = 140 + SYS_GETDENTS = 141 + SYS__NEWSELECT = 142 + SYS_FLOCK = 143 + SYS_MSYNC = 144 + SYS_READV = 145 + SYS_WRITEV = 146 + SYS_GETSID = 147 + SYS_FDATASYNC = 148 + SYS__SYSCTL = 149 + SYS_MLOCK = 150 + SYS_MUNLOCK = 151 + SYS_MLOCKALL = 152 + SYS_MUNLOCKALL = 153 + SYS_SCHED_SETPARAM = 154 + SYS_SCHED_GETPARAM = 155 + SYS_SCHED_SETSCHEDULER = 156 + SYS_SCHED_GETSCHEDULER = 157 + SYS_SCHED_YIELD = 158 + SYS_SCHED_GET_PRIORITY_MAX = 159 + SYS_SCHED_GET_PRIORITY_MIN = 160 + SYS_SCHED_RR_GET_INTERVAL = 161 + SYS_NANOSLEEP = 162 + SYS_MREMAP = 163 + SYS_SETRESUID = 164 + SYS_GETRESUID = 165 + SYS_QUERY_MODULE = 166 + SYS_POLL = 167 + SYS_NFSSERVCTL = 168 + SYS_SETRESGID = 169 + SYS_GETRESGID = 170 + SYS_PRCTL = 171 + SYS_RT_SIGRETURN = 172 + SYS_RT_SIGACTION = 173 + SYS_RT_SIGPROCMASK = 174 + SYS_RT_SIGPENDING = 175 + SYS_RT_SIGTIMEDWAIT = 176 + SYS_RT_SIGQUEUEINFO = 177 + SYS_RT_SIGSUSPEND = 178 + SYS_PREAD64 = 179 + SYS_PWRITE64 = 180 + SYS_CHOWN = 181 + SYS_GETCWD = 182 + SYS_CAPGET = 183 + SYS_CAPSET = 184 + SYS_SIGALTSTACK = 185 + SYS_SENDFILE = 186 + SYS_GETPMSG = 187 + SYS_PUTPMSG = 188 + SYS_VFORK = 189 + SYS_UGETRLIMIT = 190 + SYS_READAHEAD = 191 + SYS_PCICONFIG_READ = 198 + SYS_PCICONFIG_WRITE = 199 + SYS_PCICONFIG_IOBASE = 200 + SYS_MULTIPLEXER = 201 + SYS_GETDENTS64 = 202 + SYS_PIVOT_ROOT = 203 + SYS_MADVISE = 205 + SYS_MINCORE = 206 + SYS_GETTID = 207 + SYS_TKILL = 208 + SYS_SETXATTR = 209 + SYS_LSETXATTR = 210 + SYS_FSETXATTR = 211 + SYS_GETXATTR = 212 + SYS_LGETXATTR = 213 + SYS_FGETXATTR = 214 + SYS_LISTXATTR = 215 + SYS_LLISTXATTR = 216 + SYS_FLISTXATTR = 217 + SYS_REMOVEXATTR = 218 + SYS_LREMOVEXATTR = 219 + SYS_FREMOVEXATTR = 220 + SYS_FUTEX = 221 + SYS_SCHED_SETAFFINITY = 222 + SYS_SCHED_GETAFFINITY = 223 + SYS_TUXCALL = 225 + SYS_IO_SETUP = 227 + SYS_IO_DESTROY = 228 + SYS_IO_GETEVENTS = 229 + SYS_IO_SUBMIT = 230 + SYS_IO_CANCEL = 231 + SYS_SET_TID_ADDRESS = 232 + SYS_FADVISE64 = 233 + SYS_EXIT_GROUP = 234 + SYS_LOOKUP_DCOOKIE = 235 + SYS_EPOLL_CREATE = 236 + SYS_EPOLL_CTL = 237 + SYS_EPOLL_WAIT = 238 + SYS_REMAP_FILE_PAGES = 239 + SYS_TIMER_CREATE = 240 + SYS_TIMER_SETTIME = 241 + SYS_TIMER_GETTIME = 242 + SYS_TIMER_GETOVERRUN = 243 + SYS_TIMER_DELETE = 244 + SYS_CLOCK_SETTIME = 245 + SYS_CLOCK_GETTIME = 246 + SYS_CLOCK_GETRES = 247 + SYS_CLOCK_NANOSLEEP = 248 + SYS_SWAPCONTEXT = 249 + SYS_TGKILL = 250 + SYS_UTIMES = 251 + SYS_STATFS64 = 252 + SYS_FSTATFS64 = 253 + SYS_RTAS = 255 + SYS_SYS_DEBUG_SETCONTEXT = 256 + SYS_MIGRATE_PAGES = 258 + SYS_MBIND = 259 + SYS_GET_MEMPOLICY = 260 + SYS_SET_MEMPOLICY = 261 + SYS_MQ_OPEN = 262 + SYS_MQ_UNLINK = 263 + SYS_MQ_TIMEDSEND = 264 + SYS_MQ_TIMEDRECEIVE = 265 + SYS_MQ_NOTIFY = 266 + SYS_MQ_GETSETATTR = 267 + SYS_KEXEC_LOAD = 268 + SYS_ADD_KEY = 269 + SYS_REQUEST_KEY = 270 + SYS_KEYCTL = 271 + SYS_WAITID = 272 + SYS_IOPRIO_SET = 273 + SYS_IOPRIO_GET = 274 + SYS_INOTIFY_INIT = 275 + SYS_INOTIFY_ADD_WATCH = 276 + SYS_INOTIFY_RM_WATCH = 277 + SYS_SPU_RUN = 278 + SYS_SPU_CREATE = 279 + SYS_PSELECT6 = 280 + SYS_PPOLL = 281 + SYS_UNSHARE = 282 + SYS_SPLICE = 283 + SYS_TEE = 284 + SYS_VMSPLICE = 285 + SYS_OPENAT = 286 + SYS_MKDIRAT = 287 + SYS_MKNODAT = 288 + SYS_FCHOWNAT = 289 + SYS_FUTIMESAT = 290 + SYS_NEWFSTATAT = 291 + SYS_UNLINKAT = 292 + SYS_RENAMEAT = 293 + SYS_LINKAT = 294 + SYS_SYMLINKAT = 295 + SYS_READLINKAT = 296 + SYS_FCHMODAT = 297 + SYS_FACCESSAT = 298 + SYS_GET_ROBUST_LIST = 299 + SYS_SET_ROBUST_LIST = 300 + SYS_MOVE_PAGES = 301 + SYS_GETCPU = 302 + SYS_EPOLL_PWAIT = 303 + SYS_UTIMENSAT = 304 + SYS_SIGNALFD = 305 + SYS_TIMERFD_CREATE = 306 + SYS_EVENTFD = 307 + SYS_SYNC_FILE_RANGE2 = 308 + SYS_FALLOCATE = 309 + SYS_SUBPAGE_PROT = 310 + SYS_TIMERFD_SETTIME = 311 + SYS_TIMERFD_GETTIME = 312 + SYS_SIGNALFD4 = 313 + SYS_EVENTFD2 = 314 + SYS_EPOLL_CREATE1 = 315 + SYS_DUP3 = 316 + SYS_PIPE2 = 317 + SYS_INOTIFY_INIT1 = 318 + SYS_PERF_EVENT_OPEN = 319 + SYS_PREADV = 320 + SYS_PWRITEV = 321 + SYS_RT_TGSIGQUEUEINFO = 322 + SYS_FANOTIFY_INIT = 323 + SYS_FANOTIFY_MARK = 324 + SYS_PRLIMIT64 = 325 + SYS_SOCKET = 326 + SYS_BIND = 327 + SYS_CONNECT = 328 + SYS_LISTEN = 329 + SYS_ACCEPT = 330 + SYS_GETSOCKNAME = 331 + SYS_GETPEERNAME = 332 + SYS_SOCKETPAIR = 333 + SYS_SEND = 334 + SYS_SENDTO = 335 + SYS_RECV = 336 + SYS_RECVFROM = 337 + SYS_SHUTDOWN = 338 + SYS_SETSOCKOPT = 339 + SYS_GETSOCKOPT = 340 + SYS_SENDMSG = 341 + SYS_RECVMSG = 342 + SYS_RECVMMSG = 343 + SYS_ACCEPT4 = 344 + SYS_NAME_TO_HANDLE_AT = 345 + SYS_OPEN_BY_HANDLE_AT = 346 + SYS_CLOCK_ADJTIME = 347 + SYS_SYNCFS = 348 + SYS_SENDMMSG = 349 + SYS_SETNS = 350 + SYS_PROCESS_VM_READV = 351 + SYS_PROCESS_VM_WRITEV = 352 + SYS_FINIT_MODULE = 353 + SYS_KCMP = 354 +) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go new file mode 100644 index 0000000000..42d4f5cda8 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go @@ -0,0 +1,328 @@ +// mksysnum_linux.pl /usr/include/asm/unistd.h +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build s390x,linux + +package unix + +const ( + SYS_EXIT = 1 + SYS_FORK = 2 + SYS_READ = 3 + SYS_WRITE = 4 + SYS_OPEN = 5 + SYS_CLOSE = 6 + SYS_RESTART_SYSCALL = 7 + SYS_CREAT = 8 + SYS_LINK = 9 + SYS_UNLINK = 10 + SYS_EXECVE = 11 + SYS_CHDIR = 12 + SYS_MKNOD = 14 + SYS_CHMOD = 15 + SYS_LSEEK = 19 + SYS_GETPID = 20 + SYS_MOUNT = 21 + SYS_UMOUNT = 22 + SYS_PTRACE = 26 + SYS_ALARM = 27 + SYS_PAUSE = 29 + SYS_UTIME = 30 + SYS_ACCESS = 33 + SYS_NICE = 34 + SYS_SYNC = 36 + SYS_KILL = 37 + SYS_RENAME = 38 + SYS_MKDIR = 39 + SYS_RMDIR = 40 + SYS_DUP = 41 + SYS_PIPE = 42 + SYS_TIMES = 43 + SYS_BRK = 45 + SYS_SIGNAL = 48 + SYS_ACCT = 51 + SYS_UMOUNT2 = 52 + SYS_IOCTL = 54 + SYS_FCNTL = 55 + SYS_SETPGID = 57 + SYS_UMASK = 60 + SYS_CHROOT = 61 + SYS_USTAT = 62 + SYS_DUP2 = 63 + SYS_GETPPID = 64 + SYS_GETPGRP = 65 + SYS_SETSID = 66 + SYS_SIGACTION = 67 + SYS_SIGSUSPEND = 72 + SYS_SIGPENDING = 73 + SYS_SETHOSTNAME = 74 + SYS_SETRLIMIT = 75 + SYS_GETRUSAGE = 77 + SYS_GETTIMEOFDAY = 78 + SYS_SETTIMEOFDAY = 79 + SYS_SYMLINK = 83 + SYS_READLINK = 85 + SYS_USELIB = 86 + SYS_SWAPON = 87 + SYS_REBOOT = 88 + SYS_READDIR = 89 + SYS_MMAP = 90 + SYS_MUNMAP = 91 + SYS_TRUNCATE = 92 + SYS_FTRUNCATE = 93 + SYS_FCHMOD = 94 + SYS_GETPRIORITY = 96 + SYS_SETPRIORITY = 97 + SYS_STATFS = 99 + SYS_FSTATFS = 100 + SYS_SOCKETCALL = 102 + SYS_SYSLOG = 103 + SYS_SETITIMER = 104 + SYS_GETITIMER = 105 + SYS_STAT = 106 + SYS_LSTAT = 107 + SYS_FSTAT = 108 + SYS_LOOKUP_DCOOKIE = 110 + SYS_VHANGUP = 111 + SYS_IDLE = 112 + SYS_WAIT4 = 114 + SYS_SWAPOFF = 115 + SYS_SYSINFO = 116 + SYS_IPC = 117 + SYS_FSYNC = 118 + SYS_SIGRETURN = 119 + SYS_CLONE = 120 + SYS_SETDOMAINNAME = 121 + SYS_UNAME = 122 + SYS_ADJTIMEX = 124 + SYS_MPROTECT = 125 + SYS_SIGPROCMASK = 126 + SYS_CREATE_MODULE = 127 + SYS_INIT_MODULE = 128 + SYS_DELETE_MODULE = 129 + SYS_GET_KERNEL_SYMS = 130 + SYS_QUOTACTL = 131 + SYS_GETPGID = 132 + SYS_FCHDIR = 133 + SYS_BDFLUSH = 134 + SYS_SYSFS = 135 + SYS_PERSONALITY = 136 + SYS_AFS_SYSCALL = 137 + SYS_GETDENTS = 141 + SYS_FLOCK = 143 + SYS_MSYNC = 144 + SYS_READV = 145 + SYS_WRITEV = 146 + SYS_GETSID = 147 + SYS_FDATASYNC = 148 + SYS__SYSCTL = 149 + SYS_MLOCK = 150 + SYS_MUNLOCK = 151 + SYS_MLOCKALL = 152 + SYS_MUNLOCKALL = 153 + SYS_SCHED_SETPARAM = 154 + SYS_SCHED_GETPARAM = 155 + SYS_SCHED_SETSCHEDULER = 156 + SYS_SCHED_GETSCHEDULER = 157 + SYS_SCHED_YIELD = 158 + SYS_SCHED_GET_PRIORITY_MAX = 159 + SYS_SCHED_GET_PRIORITY_MIN = 160 + SYS_SCHED_RR_GET_INTERVAL = 161 + SYS_NANOSLEEP = 162 + SYS_MREMAP = 163 + SYS_QUERY_MODULE = 167 + SYS_POLL = 168 + SYS_NFSSERVCTL = 169 + SYS_PRCTL = 172 + SYS_RT_SIGRETURN = 173 + SYS_RT_SIGACTION = 174 + SYS_RT_SIGPROCMASK = 175 + SYS_RT_SIGPENDING = 176 + SYS_RT_SIGTIMEDWAIT = 177 + SYS_RT_SIGQUEUEINFO = 178 + SYS_RT_SIGSUSPEND = 179 + SYS_PREAD64 = 180 + SYS_PWRITE64 = 181 + SYS_GETCWD = 183 + SYS_CAPGET = 184 + SYS_CAPSET = 185 + SYS_SIGALTSTACK = 186 + SYS_SENDFILE = 187 + SYS_GETPMSG = 188 + SYS_PUTPMSG = 189 + SYS_VFORK = 190 + SYS_PIVOT_ROOT = 217 + SYS_MINCORE = 218 + SYS_MADVISE = 219 + SYS_GETDENTS64 = 220 + SYS_READAHEAD = 222 + SYS_SETXATTR = 224 + SYS_LSETXATTR = 225 + SYS_FSETXATTR = 226 + SYS_GETXATTR = 227 + SYS_LGETXATTR = 228 + SYS_FGETXATTR = 229 + SYS_LISTXATTR = 230 + SYS_LLISTXATTR = 231 + SYS_FLISTXATTR = 232 + SYS_REMOVEXATTR = 233 + SYS_LREMOVEXATTR = 234 + SYS_FREMOVEXATTR = 235 + SYS_GETTID = 236 + SYS_TKILL = 237 + SYS_FUTEX = 238 + SYS_SCHED_SETAFFINITY = 239 + SYS_SCHED_GETAFFINITY = 240 + SYS_TGKILL = 241 + SYS_IO_SETUP = 243 + SYS_IO_DESTROY = 244 + SYS_IO_GETEVENTS = 245 + SYS_IO_SUBMIT = 246 + SYS_IO_CANCEL = 247 + SYS_EXIT_GROUP = 248 + SYS_EPOLL_CREATE = 249 + SYS_EPOLL_CTL = 250 + SYS_EPOLL_WAIT = 251 + SYS_SET_TID_ADDRESS = 252 + SYS_FADVISE64 = 253 + SYS_TIMER_CREATE = 254 + SYS_TIMER_SETTIME = 255 + SYS_TIMER_GETTIME = 256 + SYS_TIMER_GETOVERRUN = 257 + SYS_TIMER_DELETE = 258 + SYS_CLOCK_SETTIME = 259 + SYS_CLOCK_GETTIME = 260 + SYS_CLOCK_GETRES = 261 + SYS_CLOCK_NANOSLEEP = 262 + SYS_STATFS64 = 265 + SYS_FSTATFS64 = 266 + SYS_REMAP_FILE_PAGES = 267 + SYS_MBIND = 268 + SYS_GET_MEMPOLICY = 269 + SYS_SET_MEMPOLICY = 270 + SYS_MQ_OPEN = 271 + SYS_MQ_UNLINK = 272 + SYS_MQ_TIMEDSEND = 273 + SYS_MQ_TIMEDRECEIVE = 274 + SYS_MQ_NOTIFY = 275 + SYS_MQ_GETSETATTR = 276 + SYS_KEXEC_LOAD = 277 + SYS_ADD_KEY = 278 + SYS_REQUEST_KEY = 279 + SYS_KEYCTL = 280 + SYS_WAITID = 281 + SYS_IOPRIO_SET = 282 + SYS_IOPRIO_GET = 283 + SYS_INOTIFY_INIT = 284 + SYS_INOTIFY_ADD_WATCH = 285 + SYS_INOTIFY_RM_WATCH = 286 + SYS_MIGRATE_PAGES = 287 + SYS_OPENAT = 288 + SYS_MKDIRAT = 289 + SYS_MKNODAT = 290 + SYS_FCHOWNAT = 291 + SYS_FUTIMESAT = 292 + SYS_UNLINKAT = 294 + SYS_RENAMEAT = 295 + SYS_LINKAT = 296 + SYS_SYMLINKAT = 297 + SYS_READLINKAT = 298 + SYS_FCHMODAT = 299 + SYS_FACCESSAT = 300 + SYS_PSELECT6 = 301 + SYS_PPOLL = 302 + SYS_UNSHARE = 303 + SYS_SET_ROBUST_LIST = 304 + SYS_GET_ROBUST_LIST = 305 + SYS_SPLICE = 306 + SYS_SYNC_FILE_RANGE = 307 + SYS_TEE = 308 + SYS_VMSPLICE = 309 + SYS_MOVE_PAGES = 310 + SYS_GETCPU = 311 + SYS_EPOLL_PWAIT = 312 + SYS_UTIMES = 313 + SYS_FALLOCATE = 314 + SYS_UTIMENSAT = 315 + SYS_SIGNALFD = 316 + SYS_TIMERFD = 317 + SYS_EVENTFD = 318 + SYS_TIMERFD_CREATE = 319 + SYS_TIMERFD_SETTIME = 320 + SYS_TIMERFD_GETTIME = 321 + SYS_SIGNALFD4 = 322 + SYS_EVENTFD2 = 323 + SYS_INOTIFY_INIT1 = 324 + SYS_PIPE2 = 325 + SYS_DUP3 = 326 + SYS_EPOLL_CREATE1 = 327 + SYS_PREADV = 328 + SYS_PWRITEV = 329 + SYS_RT_TGSIGQUEUEINFO = 330 + SYS_PERF_EVENT_OPEN = 331 + SYS_FANOTIFY_INIT = 332 + SYS_FANOTIFY_MARK = 333 + SYS_PRLIMIT64 = 334 + SYS_NAME_TO_HANDLE_AT = 335 + SYS_OPEN_BY_HANDLE_AT = 336 + SYS_CLOCK_ADJTIME = 337 + SYS_SYNCFS = 338 + SYS_SETNS = 339 + SYS_PROCESS_VM_READV = 340 + SYS_PROCESS_VM_WRITEV = 341 + SYS_S390_RUNTIME_INSTR = 342 + SYS_KCMP = 343 + SYS_FINIT_MODULE = 344 + SYS_SCHED_SETATTR = 345 + SYS_SCHED_GETATTR = 346 + SYS_RENAMEAT2 = 347 + SYS_SECCOMP = 348 + SYS_GETRANDOM = 349 + SYS_MEMFD_CREATE = 350 + SYS_BPF = 351 + SYS_S390_PCI_MMIO_WRITE = 352 + SYS_S390_PCI_MMIO_READ = 353 + SYS_EXECVEAT = 354 + SYS_USERFAULTFD = 355 + SYS_MEMBARRIER = 356 + SYS_RECVMMSG = 357 + SYS_SENDMMSG = 358 + SYS_SOCKET = 359 + SYS_SOCKETPAIR = 360 + SYS_BIND = 361 + SYS_CONNECT = 362 + SYS_LISTEN = 363 + SYS_ACCEPT4 = 364 + SYS_GETSOCKOPT = 365 + SYS_SETSOCKOPT = 366 + SYS_GETSOCKNAME = 367 + SYS_GETPEERNAME = 368 + SYS_SENDTO = 369 + SYS_SENDMSG = 370 + SYS_RECVFROM = 371 + SYS_RECVMSG = 372 + SYS_SHUTDOWN = 373 + SYS_MLOCK2 = 374 + SYS_SELECT = 142 + SYS_GETRLIMIT = 191 + SYS_LCHOWN = 198 + SYS_GETUID = 199 + SYS_GETGID = 200 + SYS_GETEUID = 201 + SYS_GETEGID = 202 + SYS_SETREUID = 203 + SYS_SETREGID = 204 + SYS_GETGROUPS = 205 + SYS_SETGROUPS = 206 + SYS_FCHOWN = 207 + SYS_SETRESUID = 208 + SYS_GETRESUID = 209 + SYS_SETRESGID = 210 + SYS_GETRESGID = 211 + SYS_CHOWN = 212 + SYS_SETUID = 213 + SYS_SETGID = 214 + SYS_SETFSUID = 215 + SYS_SETFSGID = 216 + SYS_NEWFSTATAT = 293 +) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_netbsd_386.go b/vendor/golang.org/x/sys/unix/zsysnum_netbsd_386.go new file mode 100644 index 0000000000..f60d8f9882 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_netbsd_386.go @@ -0,0 +1,273 @@ +// mksysnum_netbsd.pl +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build 386,netbsd + +package unix + +const ( + SYS_EXIT = 1 // { void|sys||exit(int rval); } + SYS_FORK = 2 // { int|sys||fork(void); } + SYS_READ = 3 // { ssize_t|sys||read(int fd, void *buf, size_t nbyte); } + SYS_WRITE = 4 // { ssize_t|sys||write(int fd, const void *buf, size_t nbyte); } + SYS_OPEN = 5 // { int|sys||open(const char *path, int flags, ... mode_t mode); } + SYS_CLOSE = 6 // { int|sys||close(int fd); } + SYS_LINK = 9 // { int|sys||link(const char *path, const char *link); } + SYS_UNLINK = 10 // { int|sys||unlink(const char *path); } + SYS_CHDIR = 12 // { int|sys||chdir(const char *path); } + SYS_FCHDIR = 13 // { int|sys||fchdir(int fd); } + SYS_CHMOD = 15 // { int|sys||chmod(const char *path, mode_t mode); } + SYS_CHOWN = 16 // { int|sys||chown(const char *path, uid_t uid, gid_t gid); } + SYS_BREAK = 17 // { int|sys||obreak(char *nsize); } + SYS_GETPID = 20 // { pid_t|sys||getpid_with_ppid(void); } + SYS_UNMOUNT = 22 // { int|sys||unmount(const char *path, int flags); } + SYS_SETUID = 23 // { int|sys||setuid(uid_t uid); } + SYS_GETUID = 24 // { uid_t|sys||getuid_with_euid(void); } + SYS_GETEUID = 25 // { uid_t|sys||geteuid(void); } + SYS_PTRACE = 26 // { int|sys||ptrace(int req, pid_t pid, void *addr, int data); } + SYS_RECVMSG = 27 // { ssize_t|sys||recvmsg(int s, struct msghdr *msg, int flags); } + SYS_SENDMSG = 28 // { ssize_t|sys||sendmsg(int s, const struct msghdr *msg, int flags); } + SYS_RECVFROM = 29 // { ssize_t|sys||recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlenaddr); } + SYS_ACCEPT = 30 // { int|sys||accept(int s, struct sockaddr *name, socklen_t *anamelen); } + SYS_GETPEERNAME = 31 // { int|sys||getpeername(int fdes, struct sockaddr *asa, socklen_t *alen); } + SYS_GETSOCKNAME = 32 // { int|sys||getsockname(int fdes, struct sockaddr *asa, socklen_t *alen); } + SYS_ACCESS = 33 // { int|sys||access(const char *path, int flags); } + SYS_CHFLAGS = 34 // { int|sys||chflags(const char *path, u_long flags); } + SYS_FCHFLAGS = 35 // { int|sys||fchflags(int fd, u_long flags); } + SYS_SYNC = 36 // { void|sys||sync(void); } + SYS_KILL = 37 // { int|sys||kill(pid_t pid, int signum); } + SYS_GETPPID = 39 // { pid_t|sys||getppid(void); } + SYS_DUP = 41 // { int|sys||dup(int fd); } + SYS_PIPE = 42 // { int|sys||pipe(void); } + SYS_GETEGID = 43 // { gid_t|sys||getegid(void); } + SYS_PROFIL = 44 // { int|sys||profil(char *samples, size_t size, u_long offset, u_int scale); } + SYS_KTRACE = 45 // { int|sys||ktrace(const char *fname, int ops, int facs, pid_t pid); } + SYS_GETGID = 47 // { gid_t|sys||getgid_with_egid(void); } + SYS___GETLOGIN = 49 // { int|sys||__getlogin(char *namebuf, size_t namelen); } + SYS___SETLOGIN = 50 // { int|sys||__setlogin(const char *namebuf); } + SYS_ACCT = 51 // { int|sys||acct(const char *path); } + SYS_IOCTL = 54 // { int|sys||ioctl(int fd, u_long com, ... void *data); } + SYS_REVOKE = 56 // { int|sys||revoke(const char *path); } + SYS_SYMLINK = 57 // { int|sys||symlink(const char *path, const char *link); } + SYS_READLINK = 58 // { ssize_t|sys||readlink(const char *path, char *buf, size_t count); } + SYS_EXECVE = 59 // { int|sys||execve(const char *path, char * const *argp, char * const *envp); } + SYS_UMASK = 60 // { mode_t|sys||umask(mode_t newmask); } + SYS_CHROOT = 61 // { int|sys||chroot(const char *path); } + SYS_VFORK = 66 // { int|sys||vfork(void); } + SYS_SBRK = 69 // { int|sys||sbrk(intptr_t incr); } + SYS_SSTK = 70 // { int|sys||sstk(int incr); } + SYS_VADVISE = 72 // { int|sys||ovadvise(int anom); } + SYS_MUNMAP = 73 // { int|sys||munmap(void *addr, size_t len); } + SYS_MPROTECT = 74 // { int|sys||mprotect(void *addr, size_t len, int prot); } + SYS_MADVISE = 75 // { int|sys||madvise(void *addr, size_t len, int behav); } + SYS_MINCORE = 78 // { int|sys||mincore(void *addr, size_t len, char *vec); } + SYS_GETGROUPS = 79 // { int|sys||getgroups(int gidsetsize, gid_t *gidset); } + SYS_SETGROUPS = 80 // { int|sys||setgroups(int gidsetsize, const gid_t *gidset); } + SYS_GETPGRP = 81 // { int|sys||getpgrp(void); } + SYS_SETPGID = 82 // { int|sys||setpgid(pid_t pid, pid_t pgid); } + SYS_DUP2 = 90 // { int|sys||dup2(int from, int to); } + SYS_FCNTL = 92 // { int|sys||fcntl(int fd, int cmd, ... void *arg); } + SYS_FSYNC = 95 // { int|sys||fsync(int fd); } + SYS_SETPRIORITY = 96 // { int|sys||setpriority(int which, id_t who, int prio); } + SYS_CONNECT = 98 // { int|sys||connect(int s, const struct sockaddr *name, socklen_t namelen); } + SYS_GETPRIORITY = 100 // { int|sys||getpriority(int which, id_t who); } + SYS_BIND = 104 // { int|sys||bind(int s, const struct sockaddr *name, socklen_t namelen); } + SYS_SETSOCKOPT = 105 // { int|sys||setsockopt(int s, int level, int name, const void *val, socklen_t valsize); } + SYS_LISTEN = 106 // { int|sys||listen(int s, int backlog); } + SYS_GETSOCKOPT = 118 // { int|sys||getsockopt(int s, int level, int name, void *val, socklen_t *avalsize); } + SYS_READV = 120 // { ssize_t|sys||readv(int fd, const struct iovec *iovp, int iovcnt); } + SYS_WRITEV = 121 // { ssize_t|sys||writev(int fd, const struct iovec *iovp, int iovcnt); } + SYS_FCHOWN = 123 // { int|sys||fchown(int fd, uid_t uid, gid_t gid); } + SYS_FCHMOD = 124 // { int|sys||fchmod(int fd, mode_t mode); } + SYS_SETREUID = 126 // { int|sys||setreuid(uid_t ruid, uid_t euid); } + SYS_SETREGID = 127 // { int|sys||setregid(gid_t rgid, gid_t egid); } + SYS_RENAME = 128 // { int|sys||rename(const char *from, const char *to); } + SYS_FLOCK = 131 // { int|sys||flock(int fd, int how); } + SYS_MKFIFO = 132 // { int|sys||mkfifo(const char *path, mode_t mode); } + SYS_SENDTO = 133 // { ssize_t|sys||sendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen); } + SYS_SHUTDOWN = 134 // { int|sys||shutdown(int s, int how); } + SYS_SOCKETPAIR = 135 // { int|sys||socketpair(int domain, int type, int protocol, int *rsv); } + SYS_MKDIR = 136 // { int|sys||mkdir(const char *path, mode_t mode); } + SYS_RMDIR = 137 // { int|sys||rmdir(const char *path); } + SYS_SETSID = 147 // { int|sys||setsid(void); } + SYS_SYSARCH = 165 // { int|sys||sysarch(int op, void *parms); } + SYS_PREAD = 173 // { ssize_t|sys||pread(int fd, void *buf, size_t nbyte, int PAD, off_t offset); } + SYS_PWRITE = 174 // { ssize_t|sys||pwrite(int fd, const void *buf, size_t nbyte, int PAD, off_t offset); } + SYS_NTP_ADJTIME = 176 // { int|sys||ntp_adjtime(struct timex *tp); } + SYS_SETGID = 181 // { int|sys||setgid(gid_t gid); } + SYS_SETEGID = 182 // { int|sys||setegid(gid_t egid); } + SYS_SETEUID = 183 // { int|sys||seteuid(uid_t euid); } + SYS_PATHCONF = 191 // { long|sys||pathconf(const char *path, int name); } + SYS_FPATHCONF = 192 // { long|sys||fpathconf(int fd, int name); } + SYS_GETRLIMIT = 194 // { int|sys||getrlimit(int which, struct rlimit *rlp); } + SYS_SETRLIMIT = 195 // { int|sys||setrlimit(int which, const struct rlimit *rlp); } + SYS_MMAP = 197 // { void *|sys||mmap(void *addr, size_t len, int prot, int flags, int fd, long PAD, off_t pos); } + SYS_LSEEK = 199 // { off_t|sys||lseek(int fd, int PAD, off_t offset, int whence); } + SYS_TRUNCATE = 200 // { int|sys||truncate(const char *path, int PAD, off_t length); } + SYS_FTRUNCATE = 201 // { int|sys||ftruncate(int fd, int PAD, off_t length); } + SYS___SYSCTL = 202 // { int|sys||__sysctl(const int *name, u_int namelen, void *old, size_t *oldlenp, const void *new, size_t newlen); } + SYS_MLOCK = 203 // { int|sys||mlock(const void *addr, size_t len); } + SYS_MUNLOCK = 204 // { int|sys||munlock(const void *addr, size_t len); } + SYS_UNDELETE = 205 // { int|sys||undelete(const char *path); } + SYS_GETPGID = 207 // { pid_t|sys||getpgid(pid_t pid); } + SYS_REBOOT = 208 // { int|sys||reboot(int opt, char *bootstr); } + SYS_POLL = 209 // { int|sys||poll(struct pollfd *fds, u_int nfds, int timeout); } + SYS_SEMGET = 221 // { int|sys||semget(key_t key, int nsems, int semflg); } + SYS_SEMOP = 222 // { int|sys||semop(int semid, struct sembuf *sops, size_t nsops); } + SYS_SEMCONFIG = 223 // { int|sys||semconfig(int flag); } + SYS_MSGGET = 225 // { int|sys||msgget(key_t key, int msgflg); } + SYS_MSGSND = 226 // { int|sys||msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg); } + SYS_MSGRCV = 227 // { ssize_t|sys||msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg); } + SYS_SHMAT = 228 // { void *|sys||shmat(int shmid, const void *shmaddr, int shmflg); } + SYS_SHMDT = 230 // { int|sys||shmdt(const void *shmaddr); } + SYS_SHMGET = 231 // { int|sys||shmget(key_t key, size_t size, int shmflg); } + SYS_TIMER_CREATE = 235 // { int|sys||timer_create(clockid_t clock_id, struct sigevent *evp, timer_t *timerid); } + SYS_TIMER_DELETE = 236 // { int|sys||timer_delete(timer_t timerid); } + SYS_TIMER_GETOVERRUN = 239 // { int|sys||timer_getoverrun(timer_t timerid); } + SYS_FDATASYNC = 241 // { int|sys||fdatasync(int fd); } + SYS_MLOCKALL = 242 // { int|sys||mlockall(int flags); } + SYS_MUNLOCKALL = 243 // { int|sys||munlockall(void); } + SYS_SIGQUEUEINFO = 245 // { int|sys||sigqueueinfo(pid_t pid, const siginfo_t *info); } + SYS_MODCTL = 246 // { int|sys||modctl(int cmd, void *arg); } + SYS___POSIX_RENAME = 270 // { int|sys||__posix_rename(const char *from, const char *to); } + SYS_SWAPCTL = 271 // { int|sys||swapctl(int cmd, void *arg, int misc); } + SYS_MINHERIT = 273 // { int|sys||minherit(void *addr, size_t len, int inherit); } + SYS_LCHMOD = 274 // { int|sys||lchmod(const char *path, mode_t mode); } + SYS_LCHOWN = 275 // { int|sys||lchown(const char *path, uid_t uid, gid_t gid); } + SYS___POSIX_CHOWN = 283 // { int|sys||__posix_chown(const char *path, uid_t uid, gid_t gid); } + SYS___POSIX_FCHOWN = 284 // { int|sys||__posix_fchown(int fd, uid_t uid, gid_t gid); } + SYS___POSIX_LCHOWN = 285 // { int|sys||__posix_lchown(const char *path, uid_t uid, gid_t gid); } + SYS_GETSID = 286 // { pid_t|sys||getsid(pid_t pid); } + SYS___CLONE = 287 // { pid_t|sys||__clone(int flags, void *stack); } + SYS_FKTRACE = 288 // { int|sys||fktrace(int fd, int ops, int facs, pid_t pid); } + SYS_PREADV = 289 // { ssize_t|sys||preadv(int fd, const struct iovec *iovp, int iovcnt, int PAD, off_t offset); } + SYS_PWRITEV = 290 // { ssize_t|sys||pwritev(int fd, const struct iovec *iovp, int iovcnt, int PAD, off_t offset); } + SYS___GETCWD = 296 // { int|sys||__getcwd(char *bufp, size_t length); } + SYS_FCHROOT = 297 // { int|sys||fchroot(int fd); } + SYS_LCHFLAGS = 304 // { int|sys||lchflags(const char *path, u_long flags); } + SYS_ISSETUGID = 305 // { int|sys||issetugid(void); } + SYS_UTRACE = 306 // { int|sys||utrace(const char *label, void *addr, size_t len); } + SYS_GETCONTEXT = 307 // { int|sys||getcontext(struct __ucontext *ucp); } + SYS_SETCONTEXT = 308 // { int|sys||setcontext(const struct __ucontext *ucp); } + SYS__LWP_CREATE = 309 // { int|sys||_lwp_create(const struct __ucontext *ucp, u_long flags, lwpid_t *new_lwp); } + SYS__LWP_EXIT = 310 // { int|sys||_lwp_exit(void); } + SYS__LWP_SELF = 311 // { lwpid_t|sys||_lwp_self(void); } + SYS__LWP_WAIT = 312 // { int|sys||_lwp_wait(lwpid_t wait_for, lwpid_t *departed); } + SYS__LWP_SUSPEND = 313 // { int|sys||_lwp_suspend(lwpid_t target); } + SYS__LWP_CONTINUE = 314 // { int|sys||_lwp_continue(lwpid_t target); } + SYS__LWP_WAKEUP = 315 // { int|sys||_lwp_wakeup(lwpid_t target); } + SYS__LWP_GETPRIVATE = 316 // { void *|sys||_lwp_getprivate(void); } + SYS__LWP_SETPRIVATE = 317 // { void|sys||_lwp_setprivate(void *ptr); } + SYS__LWP_KILL = 318 // { int|sys||_lwp_kill(lwpid_t target, int signo); } + SYS__LWP_DETACH = 319 // { int|sys||_lwp_detach(lwpid_t target); } + SYS__LWP_UNPARK = 321 // { int|sys||_lwp_unpark(lwpid_t target, const void *hint); } + SYS__LWP_UNPARK_ALL = 322 // { ssize_t|sys||_lwp_unpark_all(const lwpid_t *targets, size_t ntargets, const void *hint); } + SYS__LWP_SETNAME = 323 // { int|sys||_lwp_setname(lwpid_t target, const char *name); } + SYS__LWP_GETNAME = 324 // { int|sys||_lwp_getname(lwpid_t target, char *name, size_t len); } + SYS__LWP_CTL = 325 // { int|sys||_lwp_ctl(int features, struct lwpctl **address); } + SYS___SIGACTION_SIGTRAMP = 340 // { int|sys||__sigaction_sigtramp(int signum, const struct sigaction *nsa, struct sigaction *osa, const void *tramp, int vers); } + SYS_PMC_GET_INFO = 341 // { int|sys||pmc_get_info(int ctr, int op, void *args); } + SYS_PMC_CONTROL = 342 // { int|sys||pmc_control(int ctr, int op, void *args); } + SYS_RASCTL = 343 // { int|sys||rasctl(void *addr, size_t len, int op); } + SYS_KQUEUE = 344 // { int|sys||kqueue(void); } + SYS__SCHED_SETPARAM = 346 // { int|sys||_sched_setparam(pid_t pid, lwpid_t lid, int policy, const struct sched_param *params); } + SYS__SCHED_GETPARAM = 347 // { int|sys||_sched_getparam(pid_t pid, lwpid_t lid, int *policy, struct sched_param *params); } + SYS__SCHED_SETAFFINITY = 348 // { int|sys||_sched_setaffinity(pid_t pid, lwpid_t lid, size_t size, const cpuset_t *cpuset); } + SYS__SCHED_GETAFFINITY = 349 // { int|sys||_sched_getaffinity(pid_t pid, lwpid_t lid, size_t size, cpuset_t *cpuset); } + SYS_SCHED_YIELD = 350 // { int|sys||sched_yield(void); } + SYS_FSYNC_RANGE = 354 // { int|sys||fsync_range(int fd, int flags, off_t start, off_t length); } + SYS_UUIDGEN = 355 // { int|sys||uuidgen(struct uuid *store, int count); } + SYS_GETVFSSTAT = 356 // { int|sys||getvfsstat(struct statvfs *buf, size_t bufsize, int flags); } + SYS_STATVFS1 = 357 // { int|sys||statvfs1(const char *path, struct statvfs *buf, int flags); } + SYS_FSTATVFS1 = 358 // { int|sys||fstatvfs1(int fd, struct statvfs *buf, int flags); } + SYS_EXTATTRCTL = 360 // { int|sys||extattrctl(const char *path, int cmd, const char *filename, int attrnamespace, const char *attrname); } + SYS_EXTATTR_SET_FILE = 361 // { int|sys||extattr_set_file(const char *path, int attrnamespace, const char *attrname, const void *data, size_t nbytes); } + SYS_EXTATTR_GET_FILE = 362 // { ssize_t|sys||extattr_get_file(const char *path, int attrnamespace, const char *attrname, void *data, size_t nbytes); } + SYS_EXTATTR_DELETE_FILE = 363 // { int|sys||extattr_delete_file(const char *path, int attrnamespace, const char *attrname); } + SYS_EXTATTR_SET_FD = 364 // { int|sys||extattr_set_fd(int fd, int attrnamespace, const char *attrname, const void *data, size_t nbytes); } + SYS_EXTATTR_GET_FD = 365 // { ssize_t|sys||extattr_get_fd(int fd, int attrnamespace, const char *attrname, void *data, size_t nbytes); } + SYS_EXTATTR_DELETE_FD = 366 // { int|sys||extattr_delete_fd(int fd, int attrnamespace, const char *attrname); } + SYS_EXTATTR_SET_LINK = 367 // { int|sys||extattr_set_link(const char *path, int attrnamespace, const char *attrname, const void *data, size_t nbytes); } + SYS_EXTATTR_GET_LINK = 368 // { ssize_t|sys||extattr_get_link(const char *path, int attrnamespace, const char *attrname, void *data, size_t nbytes); } + SYS_EXTATTR_DELETE_LINK = 369 // { int|sys||extattr_delete_link(const char *path, int attrnamespace, const char *attrname); } + SYS_EXTATTR_LIST_FD = 370 // { ssize_t|sys||extattr_list_fd(int fd, int attrnamespace, void *data, size_t nbytes); } + SYS_EXTATTR_LIST_FILE = 371 // { ssize_t|sys||extattr_list_file(const char *path, int attrnamespace, void *data, size_t nbytes); } + SYS_EXTATTR_LIST_LINK = 372 // { ssize_t|sys||extattr_list_link(const char *path, int attrnamespace, void *data, size_t nbytes); } + SYS_SETXATTR = 375 // { int|sys||setxattr(const char *path, const char *name, const void *value, size_t size, int flags); } + SYS_LSETXATTR = 376 // { int|sys||lsetxattr(const char *path, const char *name, const void *value, size_t size, int flags); } + SYS_FSETXATTR = 377 // { int|sys||fsetxattr(int fd, const char *name, const void *value, size_t size, int flags); } + SYS_GETXATTR = 378 // { int|sys||getxattr(const char *path, const char *name, void *value, size_t size); } + SYS_LGETXATTR = 379 // { int|sys||lgetxattr(const char *path, const char *name, void *value, size_t size); } + SYS_FGETXATTR = 380 // { int|sys||fgetxattr(int fd, const char *name, void *value, size_t size); } + SYS_LISTXATTR = 381 // { int|sys||listxattr(const char *path, char *list, size_t size); } + SYS_LLISTXATTR = 382 // { int|sys||llistxattr(const char *path, char *list, size_t size); } + SYS_FLISTXATTR = 383 // { int|sys||flistxattr(int fd, char *list, size_t size); } + SYS_REMOVEXATTR = 384 // { int|sys||removexattr(const char *path, const char *name); } + SYS_LREMOVEXATTR = 385 // { int|sys||lremovexattr(const char *path, const char *name); } + SYS_FREMOVEXATTR = 386 // { int|sys||fremovexattr(int fd, const char *name); } + SYS_GETDENTS = 390 // { int|sys|30|getdents(int fd, char *buf, size_t count); } + SYS_SOCKET = 394 // { int|sys|30|socket(int domain, int type, int protocol); } + SYS_GETFH = 395 // { int|sys|30|getfh(const char *fname, void *fhp, size_t *fh_size); } + SYS_MOUNT = 410 // { int|sys|50|mount(const char *type, const char *path, int flags, void *data, size_t data_len); } + SYS_MREMAP = 411 // { void *|sys||mremap(void *old_address, size_t old_size, void *new_address, size_t new_size, int flags); } + SYS_PSET_CREATE = 412 // { int|sys||pset_create(psetid_t *psid); } + SYS_PSET_DESTROY = 413 // { int|sys||pset_destroy(psetid_t psid); } + SYS_PSET_ASSIGN = 414 // { int|sys||pset_assign(psetid_t psid, cpuid_t cpuid, psetid_t *opsid); } + SYS__PSET_BIND = 415 // { int|sys||_pset_bind(idtype_t idtype, id_t first_id, id_t second_id, psetid_t psid, psetid_t *opsid); } + SYS_POSIX_FADVISE = 416 // { int|sys|50|posix_fadvise(int fd, int PAD, off_t offset, off_t len, int advice); } + SYS_SELECT = 417 // { int|sys|50|select(int nd, fd_set *in, fd_set *ou, fd_set *ex, struct timeval *tv); } + SYS_GETTIMEOFDAY = 418 // { int|sys|50|gettimeofday(struct timeval *tp, void *tzp); } + SYS_SETTIMEOFDAY = 419 // { int|sys|50|settimeofday(const struct timeval *tv, const void *tzp); } + SYS_UTIMES = 420 // { int|sys|50|utimes(const char *path, const struct timeval *tptr); } + SYS_ADJTIME = 421 // { int|sys|50|adjtime(const struct timeval *delta, struct timeval *olddelta); } + SYS_FUTIMES = 423 // { int|sys|50|futimes(int fd, const struct timeval *tptr); } + SYS_LUTIMES = 424 // { int|sys|50|lutimes(const char *path, const struct timeval *tptr); } + SYS_SETITIMER = 425 // { int|sys|50|setitimer(int which, const struct itimerval *itv, struct itimerval *oitv); } + SYS_GETITIMER = 426 // { int|sys|50|getitimer(int which, struct itimerval *itv); } + SYS_CLOCK_GETTIME = 427 // { int|sys|50|clock_gettime(clockid_t clock_id, struct timespec *tp); } + SYS_CLOCK_SETTIME = 428 // { int|sys|50|clock_settime(clockid_t clock_id, const struct timespec *tp); } + SYS_CLOCK_GETRES = 429 // { int|sys|50|clock_getres(clockid_t clock_id, struct timespec *tp); } + SYS_NANOSLEEP = 430 // { int|sys|50|nanosleep(const struct timespec *rqtp, struct timespec *rmtp); } + SYS___SIGTIMEDWAIT = 431 // { int|sys|50|__sigtimedwait(const sigset_t *set, siginfo_t *info, struct timespec *timeout); } + SYS__LWP_PARK = 434 // { int|sys|50|_lwp_park(const struct timespec *ts, lwpid_t unpark, const void *hint, const void *unparkhint); } + SYS_KEVENT = 435 // { int|sys|50|kevent(int fd, const struct kevent *changelist, size_t nchanges, struct kevent *eventlist, size_t nevents, const struct timespec *timeout); } + SYS_PSELECT = 436 // { int|sys|50|pselect(int nd, fd_set *in, fd_set *ou, fd_set *ex, const struct timespec *ts, const sigset_t *mask); } + SYS_POLLTS = 437 // { int|sys|50|pollts(struct pollfd *fds, u_int nfds, const struct timespec *ts, const sigset_t *mask); } + SYS_STAT = 439 // { int|sys|50|stat(const char *path, struct stat *ub); } + SYS_FSTAT = 440 // { int|sys|50|fstat(int fd, struct stat *sb); } + SYS_LSTAT = 441 // { int|sys|50|lstat(const char *path, struct stat *ub); } + SYS___SEMCTL = 442 // { int|sys|50|__semctl(int semid, int semnum, int cmd, ... union __semun *arg); } + SYS_SHMCTL = 443 // { int|sys|50|shmctl(int shmid, int cmd, struct shmid_ds *buf); } + SYS_MSGCTL = 444 // { int|sys|50|msgctl(int msqid, int cmd, struct msqid_ds *buf); } + SYS_GETRUSAGE = 445 // { int|sys|50|getrusage(int who, struct rusage *rusage); } + SYS_TIMER_SETTIME = 446 // { int|sys|50|timer_settime(timer_t timerid, int flags, const struct itimerspec *value, struct itimerspec *ovalue); } + SYS_TIMER_GETTIME = 447 // { int|sys|50|timer_gettime(timer_t timerid, struct itimerspec *value); } + SYS_NTP_GETTIME = 448 // { int|sys|50|ntp_gettime(struct ntptimeval *ntvp); } + SYS_WAIT4 = 449 // { int|sys|50|wait4(pid_t pid, int *status, int options, struct rusage *rusage); } + SYS_MKNOD = 450 // { int|sys|50|mknod(const char *path, mode_t mode, dev_t dev); } + SYS_FHSTAT = 451 // { int|sys|50|fhstat(const void *fhp, size_t fh_size, struct stat *sb); } + SYS_PIPE2 = 453 // { int|sys||pipe2(int *fildes, int flags); } + SYS_DUP3 = 454 // { int|sys||dup3(int from, int to, int flags); } + SYS_KQUEUE1 = 455 // { int|sys||kqueue1(int flags); } + SYS_PACCEPT = 456 // { int|sys||paccept(int s, struct sockaddr *name, socklen_t *anamelen, const sigset_t *mask, int flags); } + SYS_LINKAT = 457 // { int|sys||linkat(int fd1, const char *name1, int fd2, const char *name2, int flags); } + SYS_RENAMEAT = 458 // { int|sys||renameat(int fromfd, const char *from, int tofd, const char *to); } + SYS_MKFIFOAT = 459 // { int|sys||mkfifoat(int fd, const char *path, mode_t mode); } + SYS_MKNODAT = 460 // { int|sys||mknodat(int fd, const char *path, mode_t mode, uint32_t dev); } + SYS_MKDIRAT = 461 // { int|sys||mkdirat(int fd, const char *path, mode_t mode); } + SYS_FACCESSAT = 462 // { int|sys||faccessat(int fd, const char *path, int amode, int flag); } + SYS_FCHMODAT = 463 // { int|sys||fchmodat(int fd, const char *path, mode_t mode, int flag); } + SYS_FCHOWNAT = 464 // { int|sys||fchownat(int fd, const char *path, uid_t owner, gid_t group, int flag); } + SYS_FEXECVE = 465 // { int|sys||fexecve(int fd, char * const *argp, char * const *envp); } + SYS_FSTATAT = 466 // { int|sys||fstatat(int fd, const char *path, struct stat *buf, int flag); } + SYS_UTIMENSAT = 467 // { int|sys||utimensat(int fd, const char *path, const struct timespec *tptr, int flag); } + SYS_OPENAT = 468 // { int|sys||openat(int fd, const char *path, int oflags, ... mode_t mode); } + SYS_READLINKAT = 469 // { int|sys||readlinkat(int fd, const char *path, char *buf, size_t bufsize); } + SYS_SYMLINKAT = 470 // { int|sys||symlinkat(const char *path1, int fd, const char *path2); } + SYS_UNLINKAT = 471 // { int|sys||unlinkat(int fd, const char *path, int flag); } + SYS_FUTIMENS = 472 // { int|sys||futimens(int fd, const struct timespec *tptr); } + SYS___QUOTACTL = 473 // { int|sys||__quotactl(const char *path, struct quotactl_args *args); } + SYS_POSIX_SPAWN = 474 // { int|sys||posix_spawn(pid_t *pid, const char *path, const struct posix_spawn_file_actions *file_actions, const struct posix_spawnattr *attrp, char *const *argv, char *const *envp); } + SYS_RECVMMSG = 475 // { int|sys||recvmmsg(int s, struct mmsghdr *mmsg, unsigned int vlen, unsigned int flags, struct timespec *timeout); } + SYS_SENDMMSG = 476 // { int|sys||sendmmsg(int s, struct mmsghdr *mmsg, unsigned int vlen, unsigned int flags); } +) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go new file mode 100644 index 0000000000..48a91d4646 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go @@ -0,0 +1,273 @@ +// mksysnum_netbsd.pl +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build amd64,netbsd + +package unix + +const ( + SYS_EXIT = 1 // { void|sys||exit(int rval); } + SYS_FORK = 2 // { int|sys||fork(void); } + SYS_READ = 3 // { ssize_t|sys||read(int fd, void *buf, size_t nbyte); } + SYS_WRITE = 4 // { ssize_t|sys||write(int fd, const void *buf, size_t nbyte); } + SYS_OPEN = 5 // { int|sys||open(const char *path, int flags, ... mode_t mode); } + SYS_CLOSE = 6 // { int|sys||close(int fd); } + SYS_LINK = 9 // { int|sys||link(const char *path, const char *link); } + SYS_UNLINK = 10 // { int|sys||unlink(const char *path); } + SYS_CHDIR = 12 // { int|sys||chdir(const char *path); } + SYS_FCHDIR = 13 // { int|sys||fchdir(int fd); } + SYS_CHMOD = 15 // { int|sys||chmod(const char *path, mode_t mode); } + SYS_CHOWN = 16 // { int|sys||chown(const char *path, uid_t uid, gid_t gid); } + SYS_BREAK = 17 // { int|sys||obreak(char *nsize); } + SYS_GETPID = 20 // { pid_t|sys||getpid_with_ppid(void); } + SYS_UNMOUNT = 22 // { int|sys||unmount(const char *path, int flags); } + SYS_SETUID = 23 // { int|sys||setuid(uid_t uid); } + SYS_GETUID = 24 // { uid_t|sys||getuid_with_euid(void); } + SYS_GETEUID = 25 // { uid_t|sys||geteuid(void); } + SYS_PTRACE = 26 // { int|sys||ptrace(int req, pid_t pid, void *addr, int data); } + SYS_RECVMSG = 27 // { ssize_t|sys||recvmsg(int s, struct msghdr *msg, int flags); } + SYS_SENDMSG = 28 // { ssize_t|sys||sendmsg(int s, const struct msghdr *msg, int flags); } + SYS_RECVFROM = 29 // { ssize_t|sys||recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlenaddr); } + SYS_ACCEPT = 30 // { int|sys||accept(int s, struct sockaddr *name, socklen_t *anamelen); } + SYS_GETPEERNAME = 31 // { int|sys||getpeername(int fdes, struct sockaddr *asa, socklen_t *alen); } + SYS_GETSOCKNAME = 32 // { int|sys||getsockname(int fdes, struct sockaddr *asa, socklen_t *alen); } + SYS_ACCESS = 33 // { int|sys||access(const char *path, int flags); } + SYS_CHFLAGS = 34 // { int|sys||chflags(const char *path, u_long flags); } + SYS_FCHFLAGS = 35 // { int|sys||fchflags(int fd, u_long flags); } + SYS_SYNC = 36 // { void|sys||sync(void); } + SYS_KILL = 37 // { int|sys||kill(pid_t pid, int signum); } + SYS_GETPPID = 39 // { pid_t|sys||getppid(void); } + SYS_DUP = 41 // { int|sys||dup(int fd); } + SYS_PIPE = 42 // { int|sys||pipe(void); } + SYS_GETEGID = 43 // { gid_t|sys||getegid(void); } + SYS_PROFIL = 44 // { int|sys||profil(char *samples, size_t size, u_long offset, u_int scale); } + SYS_KTRACE = 45 // { int|sys||ktrace(const char *fname, int ops, int facs, pid_t pid); } + SYS_GETGID = 47 // { gid_t|sys||getgid_with_egid(void); } + SYS___GETLOGIN = 49 // { int|sys||__getlogin(char *namebuf, size_t namelen); } + SYS___SETLOGIN = 50 // { int|sys||__setlogin(const char *namebuf); } + SYS_ACCT = 51 // { int|sys||acct(const char *path); } + SYS_IOCTL = 54 // { int|sys||ioctl(int fd, u_long com, ... void *data); } + SYS_REVOKE = 56 // { int|sys||revoke(const char *path); } + SYS_SYMLINK = 57 // { int|sys||symlink(const char *path, const char *link); } + SYS_READLINK = 58 // { ssize_t|sys||readlink(const char *path, char *buf, size_t count); } + SYS_EXECVE = 59 // { int|sys||execve(const char *path, char * const *argp, char * const *envp); } + SYS_UMASK = 60 // { mode_t|sys||umask(mode_t newmask); } + SYS_CHROOT = 61 // { int|sys||chroot(const char *path); } + SYS_VFORK = 66 // { int|sys||vfork(void); } + SYS_SBRK = 69 // { int|sys||sbrk(intptr_t incr); } + SYS_SSTK = 70 // { int|sys||sstk(int incr); } + SYS_VADVISE = 72 // { int|sys||ovadvise(int anom); } + SYS_MUNMAP = 73 // { int|sys||munmap(void *addr, size_t len); } + SYS_MPROTECT = 74 // { int|sys||mprotect(void *addr, size_t len, int prot); } + SYS_MADVISE = 75 // { int|sys||madvise(void *addr, size_t len, int behav); } + SYS_MINCORE = 78 // { int|sys||mincore(void *addr, size_t len, char *vec); } + SYS_GETGROUPS = 79 // { int|sys||getgroups(int gidsetsize, gid_t *gidset); } + SYS_SETGROUPS = 80 // { int|sys||setgroups(int gidsetsize, const gid_t *gidset); } + SYS_GETPGRP = 81 // { int|sys||getpgrp(void); } + SYS_SETPGID = 82 // { int|sys||setpgid(pid_t pid, pid_t pgid); } + SYS_DUP2 = 90 // { int|sys||dup2(int from, int to); } + SYS_FCNTL = 92 // { int|sys||fcntl(int fd, int cmd, ... void *arg); } + SYS_FSYNC = 95 // { int|sys||fsync(int fd); } + SYS_SETPRIORITY = 96 // { int|sys||setpriority(int which, id_t who, int prio); } + SYS_CONNECT = 98 // { int|sys||connect(int s, const struct sockaddr *name, socklen_t namelen); } + SYS_GETPRIORITY = 100 // { int|sys||getpriority(int which, id_t who); } + SYS_BIND = 104 // { int|sys||bind(int s, const struct sockaddr *name, socklen_t namelen); } + SYS_SETSOCKOPT = 105 // { int|sys||setsockopt(int s, int level, int name, const void *val, socklen_t valsize); } + SYS_LISTEN = 106 // { int|sys||listen(int s, int backlog); } + SYS_GETSOCKOPT = 118 // { int|sys||getsockopt(int s, int level, int name, void *val, socklen_t *avalsize); } + SYS_READV = 120 // { ssize_t|sys||readv(int fd, const struct iovec *iovp, int iovcnt); } + SYS_WRITEV = 121 // { ssize_t|sys||writev(int fd, const struct iovec *iovp, int iovcnt); } + SYS_FCHOWN = 123 // { int|sys||fchown(int fd, uid_t uid, gid_t gid); } + SYS_FCHMOD = 124 // { int|sys||fchmod(int fd, mode_t mode); } + SYS_SETREUID = 126 // { int|sys||setreuid(uid_t ruid, uid_t euid); } + SYS_SETREGID = 127 // { int|sys||setregid(gid_t rgid, gid_t egid); } + SYS_RENAME = 128 // { int|sys||rename(const char *from, const char *to); } + SYS_FLOCK = 131 // { int|sys||flock(int fd, int how); } + SYS_MKFIFO = 132 // { int|sys||mkfifo(const char *path, mode_t mode); } + SYS_SENDTO = 133 // { ssize_t|sys||sendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen); } + SYS_SHUTDOWN = 134 // { int|sys||shutdown(int s, int how); } + SYS_SOCKETPAIR = 135 // { int|sys||socketpair(int domain, int type, int protocol, int *rsv); } + SYS_MKDIR = 136 // { int|sys||mkdir(const char *path, mode_t mode); } + SYS_RMDIR = 137 // { int|sys||rmdir(const char *path); } + SYS_SETSID = 147 // { int|sys||setsid(void); } + SYS_SYSARCH = 165 // { int|sys||sysarch(int op, void *parms); } + SYS_PREAD = 173 // { ssize_t|sys||pread(int fd, void *buf, size_t nbyte, int PAD, off_t offset); } + SYS_PWRITE = 174 // { ssize_t|sys||pwrite(int fd, const void *buf, size_t nbyte, int PAD, off_t offset); } + SYS_NTP_ADJTIME = 176 // { int|sys||ntp_adjtime(struct timex *tp); } + SYS_SETGID = 181 // { int|sys||setgid(gid_t gid); } + SYS_SETEGID = 182 // { int|sys||setegid(gid_t egid); } + SYS_SETEUID = 183 // { int|sys||seteuid(uid_t euid); } + SYS_PATHCONF = 191 // { long|sys||pathconf(const char *path, int name); } + SYS_FPATHCONF = 192 // { long|sys||fpathconf(int fd, int name); } + SYS_GETRLIMIT = 194 // { int|sys||getrlimit(int which, struct rlimit *rlp); } + SYS_SETRLIMIT = 195 // { int|sys||setrlimit(int which, const struct rlimit *rlp); } + SYS_MMAP = 197 // { void *|sys||mmap(void *addr, size_t len, int prot, int flags, int fd, long PAD, off_t pos); } + SYS_LSEEK = 199 // { off_t|sys||lseek(int fd, int PAD, off_t offset, int whence); } + SYS_TRUNCATE = 200 // { int|sys||truncate(const char *path, int PAD, off_t length); } + SYS_FTRUNCATE = 201 // { int|sys||ftruncate(int fd, int PAD, off_t length); } + SYS___SYSCTL = 202 // { int|sys||__sysctl(const int *name, u_int namelen, void *old, size_t *oldlenp, const void *new, size_t newlen); } + SYS_MLOCK = 203 // { int|sys||mlock(const void *addr, size_t len); } + SYS_MUNLOCK = 204 // { int|sys||munlock(const void *addr, size_t len); } + SYS_UNDELETE = 205 // { int|sys||undelete(const char *path); } + SYS_GETPGID = 207 // { pid_t|sys||getpgid(pid_t pid); } + SYS_REBOOT = 208 // { int|sys||reboot(int opt, char *bootstr); } + SYS_POLL = 209 // { int|sys||poll(struct pollfd *fds, u_int nfds, int timeout); } + SYS_SEMGET = 221 // { int|sys||semget(key_t key, int nsems, int semflg); } + SYS_SEMOP = 222 // { int|sys||semop(int semid, struct sembuf *sops, size_t nsops); } + SYS_SEMCONFIG = 223 // { int|sys||semconfig(int flag); } + SYS_MSGGET = 225 // { int|sys||msgget(key_t key, int msgflg); } + SYS_MSGSND = 226 // { int|sys||msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg); } + SYS_MSGRCV = 227 // { ssize_t|sys||msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg); } + SYS_SHMAT = 228 // { void *|sys||shmat(int shmid, const void *shmaddr, int shmflg); } + SYS_SHMDT = 230 // { int|sys||shmdt(const void *shmaddr); } + SYS_SHMGET = 231 // { int|sys||shmget(key_t key, size_t size, int shmflg); } + SYS_TIMER_CREATE = 235 // { int|sys||timer_create(clockid_t clock_id, struct sigevent *evp, timer_t *timerid); } + SYS_TIMER_DELETE = 236 // { int|sys||timer_delete(timer_t timerid); } + SYS_TIMER_GETOVERRUN = 239 // { int|sys||timer_getoverrun(timer_t timerid); } + SYS_FDATASYNC = 241 // { int|sys||fdatasync(int fd); } + SYS_MLOCKALL = 242 // { int|sys||mlockall(int flags); } + SYS_MUNLOCKALL = 243 // { int|sys||munlockall(void); } + SYS_SIGQUEUEINFO = 245 // { int|sys||sigqueueinfo(pid_t pid, const siginfo_t *info); } + SYS_MODCTL = 246 // { int|sys||modctl(int cmd, void *arg); } + SYS___POSIX_RENAME = 270 // { int|sys||__posix_rename(const char *from, const char *to); } + SYS_SWAPCTL = 271 // { int|sys||swapctl(int cmd, void *arg, int misc); } + SYS_MINHERIT = 273 // { int|sys||minherit(void *addr, size_t len, int inherit); } + SYS_LCHMOD = 274 // { int|sys||lchmod(const char *path, mode_t mode); } + SYS_LCHOWN = 275 // { int|sys||lchown(const char *path, uid_t uid, gid_t gid); } + SYS___POSIX_CHOWN = 283 // { int|sys||__posix_chown(const char *path, uid_t uid, gid_t gid); } + SYS___POSIX_FCHOWN = 284 // { int|sys||__posix_fchown(int fd, uid_t uid, gid_t gid); } + SYS___POSIX_LCHOWN = 285 // { int|sys||__posix_lchown(const char *path, uid_t uid, gid_t gid); } + SYS_GETSID = 286 // { pid_t|sys||getsid(pid_t pid); } + SYS___CLONE = 287 // { pid_t|sys||__clone(int flags, void *stack); } + SYS_FKTRACE = 288 // { int|sys||fktrace(int fd, int ops, int facs, pid_t pid); } + SYS_PREADV = 289 // { ssize_t|sys||preadv(int fd, const struct iovec *iovp, int iovcnt, int PAD, off_t offset); } + SYS_PWRITEV = 290 // { ssize_t|sys||pwritev(int fd, const struct iovec *iovp, int iovcnt, int PAD, off_t offset); } + SYS___GETCWD = 296 // { int|sys||__getcwd(char *bufp, size_t length); } + SYS_FCHROOT = 297 // { int|sys||fchroot(int fd); } + SYS_LCHFLAGS = 304 // { int|sys||lchflags(const char *path, u_long flags); } + SYS_ISSETUGID = 305 // { int|sys||issetugid(void); } + SYS_UTRACE = 306 // { int|sys||utrace(const char *label, void *addr, size_t len); } + SYS_GETCONTEXT = 307 // { int|sys||getcontext(struct __ucontext *ucp); } + SYS_SETCONTEXT = 308 // { int|sys||setcontext(const struct __ucontext *ucp); } + SYS__LWP_CREATE = 309 // { int|sys||_lwp_create(const struct __ucontext *ucp, u_long flags, lwpid_t *new_lwp); } + SYS__LWP_EXIT = 310 // { int|sys||_lwp_exit(void); } + SYS__LWP_SELF = 311 // { lwpid_t|sys||_lwp_self(void); } + SYS__LWP_WAIT = 312 // { int|sys||_lwp_wait(lwpid_t wait_for, lwpid_t *departed); } + SYS__LWP_SUSPEND = 313 // { int|sys||_lwp_suspend(lwpid_t target); } + SYS__LWP_CONTINUE = 314 // { int|sys||_lwp_continue(lwpid_t target); } + SYS__LWP_WAKEUP = 315 // { int|sys||_lwp_wakeup(lwpid_t target); } + SYS__LWP_GETPRIVATE = 316 // { void *|sys||_lwp_getprivate(void); } + SYS__LWP_SETPRIVATE = 317 // { void|sys||_lwp_setprivate(void *ptr); } + SYS__LWP_KILL = 318 // { int|sys||_lwp_kill(lwpid_t target, int signo); } + SYS__LWP_DETACH = 319 // { int|sys||_lwp_detach(lwpid_t target); } + SYS__LWP_UNPARK = 321 // { int|sys||_lwp_unpark(lwpid_t target, const void *hint); } + SYS__LWP_UNPARK_ALL = 322 // { ssize_t|sys||_lwp_unpark_all(const lwpid_t *targets, size_t ntargets, const void *hint); } + SYS__LWP_SETNAME = 323 // { int|sys||_lwp_setname(lwpid_t target, const char *name); } + SYS__LWP_GETNAME = 324 // { int|sys||_lwp_getname(lwpid_t target, char *name, size_t len); } + SYS__LWP_CTL = 325 // { int|sys||_lwp_ctl(int features, struct lwpctl **address); } + SYS___SIGACTION_SIGTRAMP = 340 // { int|sys||__sigaction_sigtramp(int signum, const struct sigaction *nsa, struct sigaction *osa, const void *tramp, int vers); } + SYS_PMC_GET_INFO = 341 // { int|sys||pmc_get_info(int ctr, int op, void *args); } + SYS_PMC_CONTROL = 342 // { int|sys||pmc_control(int ctr, int op, void *args); } + SYS_RASCTL = 343 // { int|sys||rasctl(void *addr, size_t len, int op); } + SYS_KQUEUE = 344 // { int|sys||kqueue(void); } + SYS__SCHED_SETPARAM = 346 // { int|sys||_sched_setparam(pid_t pid, lwpid_t lid, int policy, const struct sched_param *params); } + SYS__SCHED_GETPARAM = 347 // { int|sys||_sched_getparam(pid_t pid, lwpid_t lid, int *policy, struct sched_param *params); } + SYS__SCHED_SETAFFINITY = 348 // { int|sys||_sched_setaffinity(pid_t pid, lwpid_t lid, size_t size, const cpuset_t *cpuset); } + SYS__SCHED_GETAFFINITY = 349 // { int|sys||_sched_getaffinity(pid_t pid, lwpid_t lid, size_t size, cpuset_t *cpuset); } + SYS_SCHED_YIELD = 350 // { int|sys||sched_yield(void); } + SYS_FSYNC_RANGE = 354 // { int|sys||fsync_range(int fd, int flags, off_t start, off_t length); } + SYS_UUIDGEN = 355 // { int|sys||uuidgen(struct uuid *store, int count); } + SYS_GETVFSSTAT = 356 // { int|sys||getvfsstat(struct statvfs *buf, size_t bufsize, int flags); } + SYS_STATVFS1 = 357 // { int|sys||statvfs1(const char *path, struct statvfs *buf, int flags); } + SYS_FSTATVFS1 = 358 // { int|sys||fstatvfs1(int fd, struct statvfs *buf, int flags); } + SYS_EXTATTRCTL = 360 // { int|sys||extattrctl(const char *path, int cmd, const char *filename, int attrnamespace, const char *attrname); } + SYS_EXTATTR_SET_FILE = 361 // { int|sys||extattr_set_file(const char *path, int attrnamespace, const char *attrname, const void *data, size_t nbytes); } + SYS_EXTATTR_GET_FILE = 362 // { ssize_t|sys||extattr_get_file(const char *path, int attrnamespace, const char *attrname, void *data, size_t nbytes); } + SYS_EXTATTR_DELETE_FILE = 363 // { int|sys||extattr_delete_file(const char *path, int attrnamespace, const char *attrname); } + SYS_EXTATTR_SET_FD = 364 // { int|sys||extattr_set_fd(int fd, int attrnamespace, const char *attrname, const void *data, size_t nbytes); } + SYS_EXTATTR_GET_FD = 365 // { ssize_t|sys||extattr_get_fd(int fd, int attrnamespace, const char *attrname, void *data, size_t nbytes); } + SYS_EXTATTR_DELETE_FD = 366 // { int|sys||extattr_delete_fd(int fd, int attrnamespace, const char *attrname); } + SYS_EXTATTR_SET_LINK = 367 // { int|sys||extattr_set_link(const char *path, int attrnamespace, const char *attrname, const void *data, size_t nbytes); } + SYS_EXTATTR_GET_LINK = 368 // { ssize_t|sys||extattr_get_link(const char *path, int attrnamespace, const char *attrname, void *data, size_t nbytes); } + SYS_EXTATTR_DELETE_LINK = 369 // { int|sys||extattr_delete_link(const char *path, int attrnamespace, const char *attrname); } + SYS_EXTATTR_LIST_FD = 370 // { ssize_t|sys||extattr_list_fd(int fd, int attrnamespace, void *data, size_t nbytes); } + SYS_EXTATTR_LIST_FILE = 371 // { ssize_t|sys||extattr_list_file(const char *path, int attrnamespace, void *data, size_t nbytes); } + SYS_EXTATTR_LIST_LINK = 372 // { ssize_t|sys||extattr_list_link(const char *path, int attrnamespace, void *data, size_t nbytes); } + SYS_SETXATTR = 375 // { int|sys||setxattr(const char *path, const char *name, const void *value, size_t size, int flags); } + SYS_LSETXATTR = 376 // { int|sys||lsetxattr(const char *path, const char *name, const void *value, size_t size, int flags); } + SYS_FSETXATTR = 377 // { int|sys||fsetxattr(int fd, const char *name, const void *value, size_t size, int flags); } + SYS_GETXATTR = 378 // { int|sys||getxattr(const char *path, const char *name, void *value, size_t size); } + SYS_LGETXATTR = 379 // { int|sys||lgetxattr(const char *path, const char *name, void *value, size_t size); } + SYS_FGETXATTR = 380 // { int|sys||fgetxattr(int fd, const char *name, void *value, size_t size); } + SYS_LISTXATTR = 381 // { int|sys||listxattr(const char *path, char *list, size_t size); } + SYS_LLISTXATTR = 382 // { int|sys||llistxattr(const char *path, char *list, size_t size); } + SYS_FLISTXATTR = 383 // { int|sys||flistxattr(int fd, char *list, size_t size); } + SYS_REMOVEXATTR = 384 // { int|sys||removexattr(const char *path, const char *name); } + SYS_LREMOVEXATTR = 385 // { int|sys||lremovexattr(const char *path, const char *name); } + SYS_FREMOVEXATTR = 386 // { int|sys||fremovexattr(int fd, const char *name); } + SYS_GETDENTS = 390 // { int|sys|30|getdents(int fd, char *buf, size_t count); } + SYS_SOCKET = 394 // { int|sys|30|socket(int domain, int type, int protocol); } + SYS_GETFH = 395 // { int|sys|30|getfh(const char *fname, void *fhp, size_t *fh_size); } + SYS_MOUNT = 410 // { int|sys|50|mount(const char *type, const char *path, int flags, void *data, size_t data_len); } + SYS_MREMAP = 411 // { void *|sys||mremap(void *old_address, size_t old_size, void *new_address, size_t new_size, int flags); } + SYS_PSET_CREATE = 412 // { int|sys||pset_create(psetid_t *psid); } + SYS_PSET_DESTROY = 413 // { int|sys||pset_destroy(psetid_t psid); } + SYS_PSET_ASSIGN = 414 // { int|sys||pset_assign(psetid_t psid, cpuid_t cpuid, psetid_t *opsid); } + SYS__PSET_BIND = 415 // { int|sys||_pset_bind(idtype_t idtype, id_t first_id, id_t second_id, psetid_t psid, psetid_t *opsid); } + SYS_POSIX_FADVISE = 416 // { int|sys|50|posix_fadvise(int fd, int PAD, off_t offset, off_t len, int advice); } + SYS_SELECT = 417 // { int|sys|50|select(int nd, fd_set *in, fd_set *ou, fd_set *ex, struct timeval *tv); } + SYS_GETTIMEOFDAY = 418 // { int|sys|50|gettimeofday(struct timeval *tp, void *tzp); } + SYS_SETTIMEOFDAY = 419 // { int|sys|50|settimeofday(const struct timeval *tv, const void *tzp); } + SYS_UTIMES = 420 // { int|sys|50|utimes(const char *path, const struct timeval *tptr); } + SYS_ADJTIME = 421 // { int|sys|50|adjtime(const struct timeval *delta, struct timeval *olddelta); } + SYS_FUTIMES = 423 // { int|sys|50|futimes(int fd, const struct timeval *tptr); } + SYS_LUTIMES = 424 // { int|sys|50|lutimes(const char *path, const struct timeval *tptr); } + SYS_SETITIMER = 425 // { int|sys|50|setitimer(int which, const struct itimerval *itv, struct itimerval *oitv); } + SYS_GETITIMER = 426 // { int|sys|50|getitimer(int which, struct itimerval *itv); } + SYS_CLOCK_GETTIME = 427 // { int|sys|50|clock_gettime(clockid_t clock_id, struct timespec *tp); } + SYS_CLOCK_SETTIME = 428 // { int|sys|50|clock_settime(clockid_t clock_id, const struct timespec *tp); } + SYS_CLOCK_GETRES = 429 // { int|sys|50|clock_getres(clockid_t clock_id, struct timespec *tp); } + SYS_NANOSLEEP = 430 // { int|sys|50|nanosleep(const struct timespec *rqtp, struct timespec *rmtp); } + SYS___SIGTIMEDWAIT = 431 // { int|sys|50|__sigtimedwait(const sigset_t *set, siginfo_t *info, struct timespec *timeout); } + SYS__LWP_PARK = 434 // { int|sys|50|_lwp_park(const struct timespec *ts, lwpid_t unpark, const void *hint, const void *unparkhint); } + SYS_KEVENT = 435 // { int|sys|50|kevent(int fd, const struct kevent *changelist, size_t nchanges, struct kevent *eventlist, size_t nevents, const struct timespec *timeout); } + SYS_PSELECT = 436 // { int|sys|50|pselect(int nd, fd_set *in, fd_set *ou, fd_set *ex, const struct timespec *ts, const sigset_t *mask); } + SYS_POLLTS = 437 // { int|sys|50|pollts(struct pollfd *fds, u_int nfds, const struct timespec *ts, const sigset_t *mask); } + SYS_STAT = 439 // { int|sys|50|stat(const char *path, struct stat *ub); } + SYS_FSTAT = 440 // { int|sys|50|fstat(int fd, struct stat *sb); } + SYS_LSTAT = 441 // { int|sys|50|lstat(const char *path, struct stat *ub); } + SYS___SEMCTL = 442 // { int|sys|50|__semctl(int semid, int semnum, int cmd, ... union __semun *arg); } + SYS_SHMCTL = 443 // { int|sys|50|shmctl(int shmid, int cmd, struct shmid_ds *buf); } + SYS_MSGCTL = 444 // { int|sys|50|msgctl(int msqid, int cmd, struct msqid_ds *buf); } + SYS_GETRUSAGE = 445 // { int|sys|50|getrusage(int who, struct rusage *rusage); } + SYS_TIMER_SETTIME = 446 // { int|sys|50|timer_settime(timer_t timerid, int flags, const struct itimerspec *value, struct itimerspec *ovalue); } + SYS_TIMER_GETTIME = 447 // { int|sys|50|timer_gettime(timer_t timerid, struct itimerspec *value); } + SYS_NTP_GETTIME = 448 // { int|sys|50|ntp_gettime(struct ntptimeval *ntvp); } + SYS_WAIT4 = 449 // { int|sys|50|wait4(pid_t pid, int *status, int options, struct rusage *rusage); } + SYS_MKNOD = 450 // { int|sys|50|mknod(const char *path, mode_t mode, dev_t dev); } + SYS_FHSTAT = 451 // { int|sys|50|fhstat(const void *fhp, size_t fh_size, struct stat *sb); } + SYS_PIPE2 = 453 // { int|sys||pipe2(int *fildes, int flags); } + SYS_DUP3 = 454 // { int|sys||dup3(int from, int to, int flags); } + SYS_KQUEUE1 = 455 // { int|sys||kqueue1(int flags); } + SYS_PACCEPT = 456 // { int|sys||paccept(int s, struct sockaddr *name, socklen_t *anamelen, const sigset_t *mask, int flags); } + SYS_LINKAT = 457 // { int|sys||linkat(int fd1, const char *name1, int fd2, const char *name2, int flags); } + SYS_RENAMEAT = 458 // { int|sys||renameat(int fromfd, const char *from, int tofd, const char *to); } + SYS_MKFIFOAT = 459 // { int|sys||mkfifoat(int fd, const char *path, mode_t mode); } + SYS_MKNODAT = 460 // { int|sys||mknodat(int fd, const char *path, mode_t mode, uint32_t dev); } + SYS_MKDIRAT = 461 // { int|sys||mkdirat(int fd, const char *path, mode_t mode); } + SYS_FACCESSAT = 462 // { int|sys||faccessat(int fd, const char *path, int amode, int flag); } + SYS_FCHMODAT = 463 // { int|sys||fchmodat(int fd, const char *path, mode_t mode, int flag); } + SYS_FCHOWNAT = 464 // { int|sys||fchownat(int fd, const char *path, uid_t owner, gid_t group, int flag); } + SYS_FEXECVE = 465 // { int|sys||fexecve(int fd, char * const *argp, char * const *envp); } + SYS_FSTATAT = 466 // { int|sys||fstatat(int fd, const char *path, struct stat *buf, int flag); } + SYS_UTIMENSAT = 467 // { int|sys||utimensat(int fd, const char *path, const struct timespec *tptr, int flag); } + SYS_OPENAT = 468 // { int|sys||openat(int fd, const char *path, int oflags, ... mode_t mode); } + SYS_READLINKAT = 469 // { int|sys||readlinkat(int fd, const char *path, char *buf, size_t bufsize); } + SYS_SYMLINKAT = 470 // { int|sys||symlinkat(const char *path1, int fd, const char *path2); } + SYS_UNLINKAT = 471 // { int|sys||unlinkat(int fd, const char *path, int flag); } + SYS_FUTIMENS = 472 // { int|sys||futimens(int fd, const struct timespec *tptr); } + SYS___QUOTACTL = 473 // { int|sys||__quotactl(const char *path, struct quotactl_args *args); } + SYS_POSIX_SPAWN = 474 // { int|sys||posix_spawn(pid_t *pid, const char *path, const struct posix_spawn_file_actions *file_actions, const struct posix_spawnattr *attrp, char *const *argv, char *const *envp); } + SYS_RECVMMSG = 475 // { int|sys||recvmmsg(int s, struct mmsghdr *mmsg, unsigned int vlen, unsigned int flags, struct timespec *timeout); } + SYS_SENDMMSG = 476 // { int|sys||sendmmsg(int s, struct mmsghdr *mmsg, unsigned int vlen, unsigned int flags); } +) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm.go b/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm.go new file mode 100644 index 0000000000..612ba662cb --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_netbsd_arm.go @@ -0,0 +1,273 @@ +// mksysnum_netbsd.pl +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build arm,netbsd + +package unix + +const ( + SYS_EXIT = 1 // { void|sys||exit(int rval); } + SYS_FORK = 2 // { int|sys||fork(void); } + SYS_READ = 3 // { ssize_t|sys||read(int fd, void *buf, size_t nbyte); } + SYS_WRITE = 4 // { ssize_t|sys||write(int fd, const void *buf, size_t nbyte); } + SYS_OPEN = 5 // { int|sys||open(const char *path, int flags, ... mode_t mode); } + SYS_CLOSE = 6 // { int|sys||close(int fd); } + SYS_LINK = 9 // { int|sys||link(const char *path, const char *link); } + SYS_UNLINK = 10 // { int|sys||unlink(const char *path); } + SYS_CHDIR = 12 // { int|sys||chdir(const char *path); } + SYS_FCHDIR = 13 // { int|sys||fchdir(int fd); } + SYS_CHMOD = 15 // { int|sys||chmod(const char *path, mode_t mode); } + SYS_CHOWN = 16 // { int|sys||chown(const char *path, uid_t uid, gid_t gid); } + SYS_BREAK = 17 // { int|sys||obreak(char *nsize); } + SYS_GETPID = 20 // { pid_t|sys||getpid_with_ppid(void); } + SYS_UNMOUNT = 22 // { int|sys||unmount(const char *path, int flags); } + SYS_SETUID = 23 // { int|sys||setuid(uid_t uid); } + SYS_GETUID = 24 // { uid_t|sys||getuid_with_euid(void); } + SYS_GETEUID = 25 // { uid_t|sys||geteuid(void); } + SYS_PTRACE = 26 // { int|sys||ptrace(int req, pid_t pid, void *addr, int data); } + SYS_RECVMSG = 27 // { ssize_t|sys||recvmsg(int s, struct msghdr *msg, int flags); } + SYS_SENDMSG = 28 // { ssize_t|sys||sendmsg(int s, const struct msghdr *msg, int flags); } + SYS_RECVFROM = 29 // { ssize_t|sys||recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlenaddr); } + SYS_ACCEPT = 30 // { int|sys||accept(int s, struct sockaddr *name, socklen_t *anamelen); } + SYS_GETPEERNAME = 31 // { int|sys||getpeername(int fdes, struct sockaddr *asa, socklen_t *alen); } + SYS_GETSOCKNAME = 32 // { int|sys||getsockname(int fdes, struct sockaddr *asa, socklen_t *alen); } + SYS_ACCESS = 33 // { int|sys||access(const char *path, int flags); } + SYS_CHFLAGS = 34 // { int|sys||chflags(const char *path, u_long flags); } + SYS_FCHFLAGS = 35 // { int|sys||fchflags(int fd, u_long flags); } + SYS_SYNC = 36 // { void|sys||sync(void); } + SYS_KILL = 37 // { int|sys||kill(pid_t pid, int signum); } + SYS_GETPPID = 39 // { pid_t|sys||getppid(void); } + SYS_DUP = 41 // { int|sys||dup(int fd); } + SYS_PIPE = 42 // { int|sys||pipe(void); } + SYS_GETEGID = 43 // { gid_t|sys||getegid(void); } + SYS_PROFIL = 44 // { int|sys||profil(char *samples, size_t size, u_long offset, u_int scale); } + SYS_KTRACE = 45 // { int|sys||ktrace(const char *fname, int ops, int facs, pid_t pid); } + SYS_GETGID = 47 // { gid_t|sys||getgid_with_egid(void); } + SYS___GETLOGIN = 49 // { int|sys||__getlogin(char *namebuf, size_t namelen); } + SYS___SETLOGIN = 50 // { int|sys||__setlogin(const char *namebuf); } + SYS_ACCT = 51 // { int|sys||acct(const char *path); } + SYS_IOCTL = 54 // { int|sys||ioctl(int fd, u_long com, ... void *data); } + SYS_REVOKE = 56 // { int|sys||revoke(const char *path); } + SYS_SYMLINK = 57 // { int|sys||symlink(const char *path, const char *link); } + SYS_READLINK = 58 // { ssize_t|sys||readlink(const char *path, char *buf, size_t count); } + SYS_EXECVE = 59 // { int|sys||execve(const char *path, char * const *argp, char * const *envp); } + SYS_UMASK = 60 // { mode_t|sys||umask(mode_t newmask); } + SYS_CHROOT = 61 // { int|sys||chroot(const char *path); } + SYS_VFORK = 66 // { int|sys||vfork(void); } + SYS_SBRK = 69 // { int|sys||sbrk(intptr_t incr); } + SYS_SSTK = 70 // { int|sys||sstk(int incr); } + SYS_VADVISE = 72 // { int|sys||ovadvise(int anom); } + SYS_MUNMAP = 73 // { int|sys||munmap(void *addr, size_t len); } + SYS_MPROTECT = 74 // { int|sys||mprotect(void *addr, size_t len, int prot); } + SYS_MADVISE = 75 // { int|sys||madvise(void *addr, size_t len, int behav); } + SYS_MINCORE = 78 // { int|sys||mincore(void *addr, size_t len, char *vec); } + SYS_GETGROUPS = 79 // { int|sys||getgroups(int gidsetsize, gid_t *gidset); } + SYS_SETGROUPS = 80 // { int|sys||setgroups(int gidsetsize, const gid_t *gidset); } + SYS_GETPGRP = 81 // { int|sys||getpgrp(void); } + SYS_SETPGID = 82 // { int|sys||setpgid(pid_t pid, pid_t pgid); } + SYS_DUP2 = 90 // { int|sys||dup2(int from, int to); } + SYS_FCNTL = 92 // { int|sys||fcntl(int fd, int cmd, ... void *arg); } + SYS_FSYNC = 95 // { int|sys||fsync(int fd); } + SYS_SETPRIORITY = 96 // { int|sys||setpriority(int which, id_t who, int prio); } + SYS_CONNECT = 98 // { int|sys||connect(int s, const struct sockaddr *name, socklen_t namelen); } + SYS_GETPRIORITY = 100 // { int|sys||getpriority(int which, id_t who); } + SYS_BIND = 104 // { int|sys||bind(int s, const struct sockaddr *name, socklen_t namelen); } + SYS_SETSOCKOPT = 105 // { int|sys||setsockopt(int s, int level, int name, const void *val, socklen_t valsize); } + SYS_LISTEN = 106 // { int|sys||listen(int s, int backlog); } + SYS_GETSOCKOPT = 118 // { int|sys||getsockopt(int s, int level, int name, void *val, socklen_t *avalsize); } + SYS_READV = 120 // { ssize_t|sys||readv(int fd, const struct iovec *iovp, int iovcnt); } + SYS_WRITEV = 121 // { ssize_t|sys||writev(int fd, const struct iovec *iovp, int iovcnt); } + SYS_FCHOWN = 123 // { int|sys||fchown(int fd, uid_t uid, gid_t gid); } + SYS_FCHMOD = 124 // { int|sys||fchmod(int fd, mode_t mode); } + SYS_SETREUID = 126 // { int|sys||setreuid(uid_t ruid, uid_t euid); } + SYS_SETREGID = 127 // { int|sys||setregid(gid_t rgid, gid_t egid); } + SYS_RENAME = 128 // { int|sys||rename(const char *from, const char *to); } + SYS_FLOCK = 131 // { int|sys||flock(int fd, int how); } + SYS_MKFIFO = 132 // { int|sys||mkfifo(const char *path, mode_t mode); } + SYS_SENDTO = 133 // { ssize_t|sys||sendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen); } + SYS_SHUTDOWN = 134 // { int|sys||shutdown(int s, int how); } + SYS_SOCKETPAIR = 135 // { int|sys||socketpair(int domain, int type, int protocol, int *rsv); } + SYS_MKDIR = 136 // { int|sys||mkdir(const char *path, mode_t mode); } + SYS_RMDIR = 137 // { int|sys||rmdir(const char *path); } + SYS_SETSID = 147 // { int|sys||setsid(void); } + SYS_SYSARCH = 165 // { int|sys||sysarch(int op, void *parms); } + SYS_PREAD = 173 // { ssize_t|sys||pread(int fd, void *buf, size_t nbyte, int PAD, off_t offset); } + SYS_PWRITE = 174 // { ssize_t|sys||pwrite(int fd, const void *buf, size_t nbyte, int PAD, off_t offset); } + SYS_NTP_ADJTIME = 176 // { int|sys||ntp_adjtime(struct timex *tp); } + SYS_SETGID = 181 // { int|sys||setgid(gid_t gid); } + SYS_SETEGID = 182 // { int|sys||setegid(gid_t egid); } + SYS_SETEUID = 183 // { int|sys||seteuid(uid_t euid); } + SYS_PATHCONF = 191 // { long|sys||pathconf(const char *path, int name); } + SYS_FPATHCONF = 192 // { long|sys||fpathconf(int fd, int name); } + SYS_GETRLIMIT = 194 // { int|sys||getrlimit(int which, struct rlimit *rlp); } + SYS_SETRLIMIT = 195 // { int|sys||setrlimit(int which, const struct rlimit *rlp); } + SYS_MMAP = 197 // { void *|sys||mmap(void *addr, size_t len, int prot, int flags, int fd, long PAD, off_t pos); } + SYS_LSEEK = 199 // { off_t|sys||lseek(int fd, int PAD, off_t offset, int whence); } + SYS_TRUNCATE = 200 // { int|sys||truncate(const char *path, int PAD, off_t length); } + SYS_FTRUNCATE = 201 // { int|sys||ftruncate(int fd, int PAD, off_t length); } + SYS___SYSCTL = 202 // { int|sys||__sysctl(const int *name, u_int namelen, void *old, size_t *oldlenp, const void *new, size_t newlen); } + SYS_MLOCK = 203 // { int|sys||mlock(const void *addr, size_t len); } + SYS_MUNLOCK = 204 // { int|sys||munlock(const void *addr, size_t len); } + SYS_UNDELETE = 205 // { int|sys||undelete(const char *path); } + SYS_GETPGID = 207 // { pid_t|sys||getpgid(pid_t pid); } + SYS_REBOOT = 208 // { int|sys||reboot(int opt, char *bootstr); } + SYS_POLL = 209 // { int|sys||poll(struct pollfd *fds, u_int nfds, int timeout); } + SYS_SEMGET = 221 // { int|sys||semget(key_t key, int nsems, int semflg); } + SYS_SEMOP = 222 // { int|sys||semop(int semid, struct sembuf *sops, size_t nsops); } + SYS_SEMCONFIG = 223 // { int|sys||semconfig(int flag); } + SYS_MSGGET = 225 // { int|sys||msgget(key_t key, int msgflg); } + SYS_MSGSND = 226 // { int|sys||msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg); } + SYS_MSGRCV = 227 // { ssize_t|sys||msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg); } + SYS_SHMAT = 228 // { void *|sys||shmat(int shmid, const void *shmaddr, int shmflg); } + SYS_SHMDT = 230 // { int|sys||shmdt(const void *shmaddr); } + SYS_SHMGET = 231 // { int|sys||shmget(key_t key, size_t size, int shmflg); } + SYS_TIMER_CREATE = 235 // { int|sys||timer_create(clockid_t clock_id, struct sigevent *evp, timer_t *timerid); } + SYS_TIMER_DELETE = 236 // { int|sys||timer_delete(timer_t timerid); } + SYS_TIMER_GETOVERRUN = 239 // { int|sys||timer_getoverrun(timer_t timerid); } + SYS_FDATASYNC = 241 // { int|sys||fdatasync(int fd); } + SYS_MLOCKALL = 242 // { int|sys||mlockall(int flags); } + SYS_MUNLOCKALL = 243 // { int|sys||munlockall(void); } + SYS_SIGQUEUEINFO = 245 // { int|sys||sigqueueinfo(pid_t pid, const siginfo_t *info); } + SYS_MODCTL = 246 // { int|sys||modctl(int cmd, void *arg); } + SYS___POSIX_RENAME = 270 // { int|sys||__posix_rename(const char *from, const char *to); } + SYS_SWAPCTL = 271 // { int|sys||swapctl(int cmd, void *arg, int misc); } + SYS_MINHERIT = 273 // { int|sys||minherit(void *addr, size_t len, int inherit); } + SYS_LCHMOD = 274 // { int|sys||lchmod(const char *path, mode_t mode); } + SYS_LCHOWN = 275 // { int|sys||lchown(const char *path, uid_t uid, gid_t gid); } + SYS___POSIX_CHOWN = 283 // { int|sys||__posix_chown(const char *path, uid_t uid, gid_t gid); } + SYS___POSIX_FCHOWN = 284 // { int|sys||__posix_fchown(int fd, uid_t uid, gid_t gid); } + SYS___POSIX_LCHOWN = 285 // { int|sys||__posix_lchown(const char *path, uid_t uid, gid_t gid); } + SYS_GETSID = 286 // { pid_t|sys||getsid(pid_t pid); } + SYS___CLONE = 287 // { pid_t|sys||__clone(int flags, void *stack); } + SYS_FKTRACE = 288 // { int|sys||fktrace(int fd, int ops, int facs, pid_t pid); } + SYS_PREADV = 289 // { ssize_t|sys||preadv(int fd, const struct iovec *iovp, int iovcnt, int PAD, off_t offset); } + SYS_PWRITEV = 290 // { ssize_t|sys||pwritev(int fd, const struct iovec *iovp, int iovcnt, int PAD, off_t offset); } + SYS___GETCWD = 296 // { int|sys||__getcwd(char *bufp, size_t length); } + SYS_FCHROOT = 297 // { int|sys||fchroot(int fd); } + SYS_LCHFLAGS = 304 // { int|sys||lchflags(const char *path, u_long flags); } + SYS_ISSETUGID = 305 // { int|sys||issetugid(void); } + SYS_UTRACE = 306 // { int|sys||utrace(const char *label, void *addr, size_t len); } + SYS_GETCONTEXT = 307 // { int|sys||getcontext(struct __ucontext *ucp); } + SYS_SETCONTEXT = 308 // { int|sys||setcontext(const struct __ucontext *ucp); } + SYS__LWP_CREATE = 309 // { int|sys||_lwp_create(const struct __ucontext *ucp, u_long flags, lwpid_t *new_lwp); } + SYS__LWP_EXIT = 310 // { int|sys||_lwp_exit(void); } + SYS__LWP_SELF = 311 // { lwpid_t|sys||_lwp_self(void); } + SYS__LWP_WAIT = 312 // { int|sys||_lwp_wait(lwpid_t wait_for, lwpid_t *departed); } + SYS__LWP_SUSPEND = 313 // { int|sys||_lwp_suspend(lwpid_t target); } + SYS__LWP_CONTINUE = 314 // { int|sys||_lwp_continue(lwpid_t target); } + SYS__LWP_WAKEUP = 315 // { int|sys||_lwp_wakeup(lwpid_t target); } + SYS__LWP_GETPRIVATE = 316 // { void *|sys||_lwp_getprivate(void); } + SYS__LWP_SETPRIVATE = 317 // { void|sys||_lwp_setprivate(void *ptr); } + SYS__LWP_KILL = 318 // { int|sys||_lwp_kill(lwpid_t target, int signo); } + SYS__LWP_DETACH = 319 // { int|sys||_lwp_detach(lwpid_t target); } + SYS__LWP_UNPARK = 321 // { int|sys||_lwp_unpark(lwpid_t target, const void *hint); } + SYS__LWP_UNPARK_ALL = 322 // { ssize_t|sys||_lwp_unpark_all(const lwpid_t *targets, size_t ntargets, const void *hint); } + SYS__LWP_SETNAME = 323 // { int|sys||_lwp_setname(lwpid_t target, const char *name); } + SYS__LWP_GETNAME = 324 // { int|sys||_lwp_getname(lwpid_t target, char *name, size_t len); } + SYS__LWP_CTL = 325 // { int|sys||_lwp_ctl(int features, struct lwpctl **address); } + SYS___SIGACTION_SIGTRAMP = 340 // { int|sys||__sigaction_sigtramp(int signum, const struct sigaction *nsa, struct sigaction *osa, const void *tramp, int vers); } + SYS_PMC_GET_INFO = 341 // { int|sys||pmc_get_info(int ctr, int op, void *args); } + SYS_PMC_CONTROL = 342 // { int|sys||pmc_control(int ctr, int op, void *args); } + SYS_RASCTL = 343 // { int|sys||rasctl(void *addr, size_t len, int op); } + SYS_KQUEUE = 344 // { int|sys||kqueue(void); } + SYS__SCHED_SETPARAM = 346 // { int|sys||_sched_setparam(pid_t pid, lwpid_t lid, int policy, const struct sched_param *params); } + SYS__SCHED_GETPARAM = 347 // { int|sys||_sched_getparam(pid_t pid, lwpid_t lid, int *policy, struct sched_param *params); } + SYS__SCHED_SETAFFINITY = 348 // { int|sys||_sched_setaffinity(pid_t pid, lwpid_t lid, size_t size, const cpuset_t *cpuset); } + SYS__SCHED_GETAFFINITY = 349 // { int|sys||_sched_getaffinity(pid_t pid, lwpid_t lid, size_t size, cpuset_t *cpuset); } + SYS_SCHED_YIELD = 350 // { int|sys||sched_yield(void); } + SYS_FSYNC_RANGE = 354 // { int|sys||fsync_range(int fd, int flags, off_t start, off_t length); } + SYS_UUIDGEN = 355 // { int|sys||uuidgen(struct uuid *store, int count); } + SYS_GETVFSSTAT = 356 // { int|sys||getvfsstat(struct statvfs *buf, size_t bufsize, int flags); } + SYS_STATVFS1 = 357 // { int|sys||statvfs1(const char *path, struct statvfs *buf, int flags); } + SYS_FSTATVFS1 = 358 // { int|sys||fstatvfs1(int fd, struct statvfs *buf, int flags); } + SYS_EXTATTRCTL = 360 // { int|sys||extattrctl(const char *path, int cmd, const char *filename, int attrnamespace, const char *attrname); } + SYS_EXTATTR_SET_FILE = 361 // { int|sys||extattr_set_file(const char *path, int attrnamespace, const char *attrname, const void *data, size_t nbytes); } + SYS_EXTATTR_GET_FILE = 362 // { ssize_t|sys||extattr_get_file(const char *path, int attrnamespace, const char *attrname, void *data, size_t nbytes); } + SYS_EXTATTR_DELETE_FILE = 363 // { int|sys||extattr_delete_file(const char *path, int attrnamespace, const char *attrname); } + SYS_EXTATTR_SET_FD = 364 // { int|sys||extattr_set_fd(int fd, int attrnamespace, const char *attrname, const void *data, size_t nbytes); } + SYS_EXTATTR_GET_FD = 365 // { ssize_t|sys||extattr_get_fd(int fd, int attrnamespace, const char *attrname, void *data, size_t nbytes); } + SYS_EXTATTR_DELETE_FD = 366 // { int|sys||extattr_delete_fd(int fd, int attrnamespace, const char *attrname); } + SYS_EXTATTR_SET_LINK = 367 // { int|sys||extattr_set_link(const char *path, int attrnamespace, const char *attrname, const void *data, size_t nbytes); } + SYS_EXTATTR_GET_LINK = 368 // { ssize_t|sys||extattr_get_link(const char *path, int attrnamespace, const char *attrname, void *data, size_t nbytes); } + SYS_EXTATTR_DELETE_LINK = 369 // { int|sys||extattr_delete_link(const char *path, int attrnamespace, const char *attrname); } + SYS_EXTATTR_LIST_FD = 370 // { ssize_t|sys||extattr_list_fd(int fd, int attrnamespace, void *data, size_t nbytes); } + SYS_EXTATTR_LIST_FILE = 371 // { ssize_t|sys||extattr_list_file(const char *path, int attrnamespace, void *data, size_t nbytes); } + SYS_EXTATTR_LIST_LINK = 372 // { ssize_t|sys||extattr_list_link(const char *path, int attrnamespace, void *data, size_t nbytes); } + SYS_SETXATTR = 375 // { int|sys||setxattr(const char *path, const char *name, const void *value, size_t size, int flags); } + SYS_LSETXATTR = 376 // { int|sys||lsetxattr(const char *path, const char *name, const void *value, size_t size, int flags); } + SYS_FSETXATTR = 377 // { int|sys||fsetxattr(int fd, const char *name, const void *value, size_t size, int flags); } + SYS_GETXATTR = 378 // { int|sys||getxattr(const char *path, const char *name, void *value, size_t size); } + SYS_LGETXATTR = 379 // { int|sys||lgetxattr(const char *path, const char *name, void *value, size_t size); } + SYS_FGETXATTR = 380 // { int|sys||fgetxattr(int fd, const char *name, void *value, size_t size); } + SYS_LISTXATTR = 381 // { int|sys||listxattr(const char *path, char *list, size_t size); } + SYS_LLISTXATTR = 382 // { int|sys||llistxattr(const char *path, char *list, size_t size); } + SYS_FLISTXATTR = 383 // { int|sys||flistxattr(int fd, char *list, size_t size); } + SYS_REMOVEXATTR = 384 // { int|sys||removexattr(const char *path, const char *name); } + SYS_LREMOVEXATTR = 385 // { int|sys||lremovexattr(const char *path, const char *name); } + SYS_FREMOVEXATTR = 386 // { int|sys||fremovexattr(int fd, const char *name); } + SYS_GETDENTS = 390 // { int|sys|30|getdents(int fd, char *buf, size_t count); } + SYS_SOCKET = 394 // { int|sys|30|socket(int domain, int type, int protocol); } + SYS_GETFH = 395 // { int|sys|30|getfh(const char *fname, void *fhp, size_t *fh_size); } + SYS_MOUNT = 410 // { int|sys|50|mount(const char *type, const char *path, int flags, void *data, size_t data_len); } + SYS_MREMAP = 411 // { void *|sys||mremap(void *old_address, size_t old_size, void *new_address, size_t new_size, int flags); } + SYS_PSET_CREATE = 412 // { int|sys||pset_create(psetid_t *psid); } + SYS_PSET_DESTROY = 413 // { int|sys||pset_destroy(psetid_t psid); } + SYS_PSET_ASSIGN = 414 // { int|sys||pset_assign(psetid_t psid, cpuid_t cpuid, psetid_t *opsid); } + SYS__PSET_BIND = 415 // { int|sys||_pset_bind(idtype_t idtype, id_t first_id, id_t second_id, psetid_t psid, psetid_t *opsid); } + SYS_POSIX_FADVISE = 416 // { int|sys|50|posix_fadvise(int fd, int PAD, off_t offset, off_t len, int advice); } + SYS_SELECT = 417 // { int|sys|50|select(int nd, fd_set *in, fd_set *ou, fd_set *ex, struct timeval *tv); } + SYS_GETTIMEOFDAY = 418 // { int|sys|50|gettimeofday(struct timeval *tp, void *tzp); } + SYS_SETTIMEOFDAY = 419 // { int|sys|50|settimeofday(const struct timeval *tv, const void *tzp); } + SYS_UTIMES = 420 // { int|sys|50|utimes(const char *path, const struct timeval *tptr); } + SYS_ADJTIME = 421 // { int|sys|50|adjtime(const struct timeval *delta, struct timeval *olddelta); } + SYS_FUTIMES = 423 // { int|sys|50|futimes(int fd, const struct timeval *tptr); } + SYS_LUTIMES = 424 // { int|sys|50|lutimes(const char *path, const struct timeval *tptr); } + SYS_SETITIMER = 425 // { int|sys|50|setitimer(int which, const struct itimerval *itv, struct itimerval *oitv); } + SYS_GETITIMER = 426 // { int|sys|50|getitimer(int which, struct itimerval *itv); } + SYS_CLOCK_GETTIME = 427 // { int|sys|50|clock_gettime(clockid_t clock_id, struct timespec *tp); } + SYS_CLOCK_SETTIME = 428 // { int|sys|50|clock_settime(clockid_t clock_id, const struct timespec *tp); } + SYS_CLOCK_GETRES = 429 // { int|sys|50|clock_getres(clockid_t clock_id, struct timespec *tp); } + SYS_NANOSLEEP = 430 // { int|sys|50|nanosleep(const struct timespec *rqtp, struct timespec *rmtp); } + SYS___SIGTIMEDWAIT = 431 // { int|sys|50|__sigtimedwait(const sigset_t *set, siginfo_t *info, struct timespec *timeout); } + SYS__LWP_PARK = 434 // { int|sys|50|_lwp_park(const struct timespec *ts, lwpid_t unpark, const void *hint, const void *unparkhint); } + SYS_KEVENT = 435 // { int|sys|50|kevent(int fd, const struct kevent *changelist, size_t nchanges, struct kevent *eventlist, size_t nevents, const struct timespec *timeout); } + SYS_PSELECT = 436 // { int|sys|50|pselect(int nd, fd_set *in, fd_set *ou, fd_set *ex, const struct timespec *ts, const sigset_t *mask); } + SYS_POLLTS = 437 // { int|sys|50|pollts(struct pollfd *fds, u_int nfds, const struct timespec *ts, const sigset_t *mask); } + SYS_STAT = 439 // { int|sys|50|stat(const char *path, struct stat *ub); } + SYS_FSTAT = 440 // { int|sys|50|fstat(int fd, struct stat *sb); } + SYS_LSTAT = 441 // { int|sys|50|lstat(const char *path, struct stat *ub); } + SYS___SEMCTL = 442 // { int|sys|50|__semctl(int semid, int semnum, int cmd, ... union __semun *arg); } + SYS_SHMCTL = 443 // { int|sys|50|shmctl(int shmid, int cmd, struct shmid_ds *buf); } + SYS_MSGCTL = 444 // { int|sys|50|msgctl(int msqid, int cmd, struct msqid_ds *buf); } + SYS_GETRUSAGE = 445 // { int|sys|50|getrusage(int who, struct rusage *rusage); } + SYS_TIMER_SETTIME = 446 // { int|sys|50|timer_settime(timer_t timerid, int flags, const struct itimerspec *value, struct itimerspec *ovalue); } + SYS_TIMER_GETTIME = 447 // { int|sys|50|timer_gettime(timer_t timerid, struct itimerspec *value); } + SYS_NTP_GETTIME = 448 // { int|sys|50|ntp_gettime(struct ntptimeval *ntvp); } + SYS_WAIT4 = 449 // { int|sys|50|wait4(pid_t pid, int *status, int options, struct rusage *rusage); } + SYS_MKNOD = 450 // { int|sys|50|mknod(const char *path, mode_t mode, dev_t dev); } + SYS_FHSTAT = 451 // { int|sys|50|fhstat(const void *fhp, size_t fh_size, struct stat *sb); } + SYS_PIPE2 = 453 // { int|sys||pipe2(int *fildes, int flags); } + SYS_DUP3 = 454 // { int|sys||dup3(int from, int to, int flags); } + SYS_KQUEUE1 = 455 // { int|sys||kqueue1(int flags); } + SYS_PACCEPT = 456 // { int|sys||paccept(int s, struct sockaddr *name, socklen_t *anamelen, const sigset_t *mask, int flags); } + SYS_LINKAT = 457 // { int|sys||linkat(int fd1, const char *name1, int fd2, const char *name2, int flags); } + SYS_RENAMEAT = 458 // { int|sys||renameat(int fromfd, const char *from, int tofd, const char *to); } + SYS_MKFIFOAT = 459 // { int|sys||mkfifoat(int fd, const char *path, mode_t mode); } + SYS_MKNODAT = 460 // { int|sys||mknodat(int fd, const char *path, mode_t mode, uint32_t dev); } + SYS_MKDIRAT = 461 // { int|sys||mkdirat(int fd, const char *path, mode_t mode); } + SYS_FACCESSAT = 462 // { int|sys||faccessat(int fd, const char *path, int amode, int flag); } + SYS_FCHMODAT = 463 // { int|sys||fchmodat(int fd, const char *path, mode_t mode, int flag); } + SYS_FCHOWNAT = 464 // { int|sys||fchownat(int fd, const char *path, uid_t owner, gid_t group, int flag); } + SYS_FEXECVE = 465 // { int|sys||fexecve(int fd, char * const *argp, char * const *envp); } + SYS_FSTATAT = 466 // { int|sys||fstatat(int fd, const char *path, struct stat *buf, int flag); } + SYS_UTIMENSAT = 467 // { int|sys||utimensat(int fd, const char *path, const struct timespec *tptr, int flag); } + SYS_OPENAT = 468 // { int|sys||openat(int fd, const char *path, int oflags, ... mode_t mode); } + SYS_READLINKAT = 469 // { int|sys||readlinkat(int fd, const char *path, char *buf, size_t bufsize); } + SYS_SYMLINKAT = 470 // { int|sys||symlinkat(const char *path1, int fd, const char *path2); } + SYS_UNLINKAT = 471 // { int|sys||unlinkat(int fd, const char *path, int flag); } + SYS_FUTIMENS = 472 // { int|sys||futimens(int fd, const struct timespec *tptr); } + SYS___QUOTACTL = 473 // { int|sys||__quotactl(const char *path, struct quotactl_args *args); } + SYS_POSIX_SPAWN = 474 // { int|sys||posix_spawn(pid_t *pid, const char *path, const struct posix_spawn_file_actions *file_actions, const struct posix_spawnattr *attrp, char *const *argv, char *const *envp); } + SYS_RECVMMSG = 475 // { int|sys||recvmmsg(int s, struct mmsghdr *mmsg, unsigned int vlen, unsigned int flags, struct timespec *timeout); } + SYS_SENDMMSG = 476 // { int|sys||sendmmsg(int s, struct mmsghdr *mmsg, unsigned int vlen, unsigned int flags); } +) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_386.go b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_386.go new file mode 100644 index 0000000000..3e8ce2a1dd --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_386.go @@ -0,0 +1,207 @@ +// mksysnum_openbsd.pl +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build 386,openbsd + +package unix + +const ( + SYS_EXIT = 1 // { void sys_exit(int rval); } + SYS_FORK = 2 // { int sys_fork(void); } + SYS_READ = 3 // { ssize_t sys_read(int fd, void *buf, size_t nbyte); } + SYS_WRITE = 4 // { ssize_t sys_write(int fd, const void *buf, \ + SYS_OPEN = 5 // { int sys_open(const char *path, \ + SYS_CLOSE = 6 // { int sys_close(int fd); } + SYS___TFORK = 8 // { int sys___tfork(const struct __tfork *param, \ + SYS_LINK = 9 // { int sys_link(const char *path, const char *link); } + SYS_UNLINK = 10 // { int sys_unlink(const char *path); } + SYS_WAIT4 = 11 // { pid_t sys_wait4(pid_t pid, int *status, \ + SYS_CHDIR = 12 // { int sys_chdir(const char *path); } + SYS_FCHDIR = 13 // { int sys_fchdir(int fd); } + SYS_MKNOD = 14 // { int sys_mknod(const char *path, mode_t mode, \ + SYS_CHMOD = 15 // { int sys_chmod(const char *path, mode_t mode); } + SYS_CHOWN = 16 // { int sys_chown(const char *path, uid_t uid, \ + SYS_OBREAK = 17 // { int sys_obreak(char *nsize); } break + SYS_GETDTABLECOUNT = 18 // { int sys_getdtablecount(void); } + SYS_GETRUSAGE = 19 // { int sys_getrusage(int who, \ + SYS_GETPID = 20 // { pid_t sys_getpid(void); } + SYS_MOUNT = 21 // { int sys_mount(const char *type, const char *path, \ + SYS_UNMOUNT = 22 // { int sys_unmount(const char *path, int flags); } + SYS_SETUID = 23 // { int sys_setuid(uid_t uid); } + SYS_GETUID = 24 // { uid_t sys_getuid(void); } + SYS_GETEUID = 25 // { uid_t sys_geteuid(void); } + SYS_PTRACE = 26 // { int sys_ptrace(int req, pid_t pid, caddr_t addr, \ + SYS_RECVMSG = 27 // { ssize_t sys_recvmsg(int s, struct msghdr *msg, \ + SYS_SENDMSG = 28 // { ssize_t sys_sendmsg(int s, \ + SYS_RECVFROM = 29 // { ssize_t sys_recvfrom(int s, void *buf, size_t len, \ + SYS_ACCEPT = 30 // { int sys_accept(int s, struct sockaddr *name, \ + SYS_GETPEERNAME = 31 // { int sys_getpeername(int fdes, struct sockaddr *asa, \ + SYS_GETSOCKNAME = 32 // { int sys_getsockname(int fdes, struct sockaddr *asa, \ + SYS_ACCESS = 33 // { int sys_access(const char *path, int flags); } + SYS_CHFLAGS = 34 // { int sys_chflags(const char *path, u_int flags); } + SYS_FCHFLAGS = 35 // { int sys_fchflags(int fd, u_int flags); } + SYS_SYNC = 36 // { void sys_sync(void); } + SYS_KILL = 37 // { int sys_kill(int pid, int signum); } + SYS_STAT = 38 // { int sys_stat(const char *path, struct stat *ub); } + SYS_GETPPID = 39 // { pid_t sys_getppid(void); } + SYS_LSTAT = 40 // { int sys_lstat(const char *path, struct stat *ub); } + SYS_DUP = 41 // { int sys_dup(int fd); } + SYS_FSTATAT = 42 // { int sys_fstatat(int fd, const char *path, \ + SYS_GETEGID = 43 // { gid_t sys_getegid(void); } + SYS_PROFIL = 44 // { int sys_profil(caddr_t samples, size_t size, \ + SYS_KTRACE = 45 // { int sys_ktrace(const char *fname, int ops, \ + SYS_SIGACTION = 46 // { int sys_sigaction(int signum, \ + SYS_GETGID = 47 // { gid_t sys_getgid(void); } + SYS_SIGPROCMASK = 48 // { int sys_sigprocmask(int how, sigset_t mask); } + SYS_GETLOGIN = 49 // { int sys_getlogin(char *namebuf, u_int namelen); } + SYS_SETLOGIN = 50 // { int sys_setlogin(const char *namebuf); } + SYS_ACCT = 51 // { int sys_acct(const char *path); } + SYS_SIGPENDING = 52 // { int sys_sigpending(void); } + SYS_FSTAT = 53 // { int sys_fstat(int fd, struct stat *sb); } + SYS_IOCTL = 54 // { int sys_ioctl(int fd, \ + SYS_REBOOT = 55 // { int sys_reboot(int opt); } + SYS_REVOKE = 56 // { int sys_revoke(const char *path); } + SYS_SYMLINK = 57 // { int sys_symlink(const char *path, \ + SYS_READLINK = 58 // { int sys_readlink(const char *path, char *buf, \ + SYS_EXECVE = 59 // { int sys_execve(const char *path, \ + SYS_UMASK = 60 // { mode_t sys_umask(mode_t newmask); } + SYS_CHROOT = 61 // { int sys_chroot(const char *path); } + SYS_GETFSSTAT = 62 // { int sys_getfsstat(struct statfs *buf, size_t bufsize, \ + SYS_STATFS = 63 // { int sys_statfs(const char *path, \ + SYS_FSTATFS = 64 // { int sys_fstatfs(int fd, struct statfs *buf); } + SYS_FHSTATFS = 65 // { int sys_fhstatfs(const fhandle_t *fhp, \ + SYS_VFORK = 66 // { int sys_vfork(void); } + SYS_GETTIMEOFDAY = 67 // { int sys_gettimeofday(struct timeval *tp, \ + SYS_SETTIMEOFDAY = 68 // { int sys_settimeofday(const struct timeval *tv, \ + SYS_SETITIMER = 69 // { int sys_setitimer(int which, \ + SYS_GETITIMER = 70 // { int sys_getitimer(int which, \ + SYS_SELECT = 71 // { int sys_select(int nd, fd_set *in, fd_set *ou, \ + SYS_KEVENT = 72 // { int sys_kevent(int fd, \ + SYS_MUNMAP = 73 // { int sys_munmap(void *addr, size_t len); } + SYS_MPROTECT = 74 // { int sys_mprotect(void *addr, size_t len, \ + SYS_MADVISE = 75 // { int sys_madvise(void *addr, size_t len, \ + SYS_UTIMES = 76 // { int sys_utimes(const char *path, \ + SYS_FUTIMES = 77 // { int sys_futimes(int fd, \ + SYS_MINCORE = 78 // { int sys_mincore(void *addr, size_t len, \ + SYS_GETGROUPS = 79 // { int sys_getgroups(int gidsetsize, \ + SYS_SETGROUPS = 80 // { int sys_setgroups(int gidsetsize, \ + SYS_GETPGRP = 81 // { int sys_getpgrp(void); } + SYS_SETPGID = 82 // { int sys_setpgid(pid_t pid, int pgid); } + SYS_UTIMENSAT = 84 // { int sys_utimensat(int fd, const char *path, \ + SYS_FUTIMENS = 85 // { int sys_futimens(int fd, \ + SYS_CLOCK_GETTIME = 87 // { int sys_clock_gettime(clockid_t clock_id, \ + SYS_CLOCK_SETTIME = 88 // { int sys_clock_settime(clockid_t clock_id, \ + SYS_CLOCK_GETRES = 89 // { int sys_clock_getres(clockid_t clock_id, \ + SYS_DUP2 = 90 // { int sys_dup2(int from, int to); } + SYS_NANOSLEEP = 91 // { int sys_nanosleep(const struct timespec *rqtp, \ + SYS_FCNTL = 92 // { int sys_fcntl(int fd, int cmd, ... void *arg); } + SYS___THRSLEEP = 94 // { int sys___thrsleep(const volatile void *ident, \ + SYS_FSYNC = 95 // { int sys_fsync(int fd); } + SYS_SETPRIORITY = 96 // { int sys_setpriority(int which, id_t who, int prio); } + SYS_SOCKET = 97 // { int sys_socket(int domain, int type, int protocol); } + SYS_CONNECT = 98 // { int sys_connect(int s, const struct sockaddr *name, \ + SYS_GETDENTS = 99 // { int sys_getdents(int fd, void *buf, size_t buflen); } + SYS_GETPRIORITY = 100 // { int sys_getpriority(int which, id_t who); } + SYS_SIGRETURN = 103 // { int sys_sigreturn(struct sigcontext *sigcntxp); } + SYS_BIND = 104 // { int sys_bind(int s, const struct sockaddr *name, \ + SYS_SETSOCKOPT = 105 // { int sys_setsockopt(int s, int level, int name, \ + SYS_LISTEN = 106 // { int sys_listen(int s, int backlog); } + SYS_PPOLL = 109 // { int sys_ppoll(struct pollfd *fds, \ + SYS_PSELECT = 110 // { int sys_pselect(int nd, fd_set *in, fd_set *ou, \ + SYS_SIGSUSPEND = 111 // { int sys_sigsuspend(int mask); } + SYS_GETSOCKOPT = 118 // { int sys_getsockopt(int s, int level, int name, \ + SYS_READV = 120 // { ssize_t sys_readv(int fd, \ + SYS_WRITEV = 121 // { ssize_t sys_writev(int fd, \ + SYS_FCHOWN = 123 // { int sys_fchown(int fd, uid_t uid, gid_t gid); } + SYS_FCHMOD = 124 // { int sys_fchmod(int fd, mode_t mode); } + SYS_SETREUID = 126 // { int sys_setreuid(uid_t ruid, uid_t euid); } + SYS_SETREGID = 127 // { int sys_setregid(gid_t rgid, gid_t egid); } + SYS_RENAME = 128 // { int sys_rename(const char *from, const char *to); } + SYS_FLOCK = 131 // { int sys_flock(int fd, int how); } + SYS_MKFIFO = 132 // { int sys_mkfifo(const char *path, mode_t mode); } + SYS_SENDTO = 133 // { ssize_t sys_sendto(int s, const void *buf, \ + SYS_SHUTDOWN = 134 // { int sys_shutdown(int s, int how); } + SYS_SOCKETPAIR = 135 // { int sys_socketpair(int domain, int type, \ + SYS_MKDIR = 136 // { int sys_mkdir(const char *path, mode_t mode); } + SYS_RMDIR = 137 // { int sys_rmdir(const char *path); } + SYS_ADJTIME = 140 // { int sys_adjtime(const struct timeval *delta, \ + SYS_SETSID = 147 // { int sys_setsid(void); } + SYS_QUOTACTL = 148 // { int sys_quotactl(const char *path, int cmd, \ + SYS_NFSSVC = 155 // { int sys_nfssvc(int flag, void *argp); } + SYS_GETFH = 161 // { int sys_getfh(const char *fname, fhandle_t *fhp); } + SYS_SYSARCH = 165 // { int sys_sysarch(int op, void *parms); } + SYS_PREAD = 173 // { ssize_t sys_pread(int fd, void *buf, \ + SYS_PWRITE = 174 // { ssize_t sys_pwrite(int fd, const void *buf, \ + SYS_SETGID = 181 // { int sys_setgid(gid_t gid); } + SYS_SETEGID = 182 // { int sys_setegid(gid_t egid); } + SYS_SETEUID = 183 // { int sys_seteuid(uid_t euid); } + SYS_PATHCONF = 191 // { long sys_pathconf(const char *path, int name); } + SYS_FPATHCONF = 192 // { long sys_fpathconf(int fd, int name); } + SYS_SWAPCTL = 193 // { int sys_swapctl(int cmd, const void *arg, int misc); } + SYS_GETRLIMIT = 194 // { int sys_getrlimit(int which, \ + SYS_SETRLIMIT = 195 // { int sys_setrlimit(int which, \ + SYS_MMAP = 197 // { void *sys_mmap(void *addr, size_t len, int prot, \ + SYS_LSEEK = 199 // { off_t sys_lseek(int fd, int pad, off_t offset, \ + SYS_TRUNCATE = 200 // { int sys_truncate(const char *path, int pad, \ + SYS_FTRUNCATE = 201 // { int sys_ftruncate(int fd, int pad, off_t length); } + SYS___SYSCTL = 202 // { int sys___sysctl(const int *name, u_int namelen, \ + SYS_MLOCK = 203 // { int sys_mlock(const void *addr, size_t len); } + SYS_MUNLOCK = 204 // { int sys_munlock(const void *addr, size_t len); } + SYS_GETPGID = 207 // { pid_t sys_getpgid(pid_t pid); } + SYS_UTRACE = 209 // { int sys_utrace(const char *label, const void *addr, \ + SYS_SEMGET = 221 // { int sys_semget(key_t key, int nsems, int semflg); } + SYS_MSGGET = 225 // { int sys_msgget(key_t key, int msgflg); } + SYS_MSGSND = 226 // { int sys_msgsnd(int msqid, const void *msgp, size_t msgsz, \ + SYS_MSGRCV = 227 // { int sys_msgrcv(int msqid, void *msgp, size_t msgsz, \ + SYS_SHMAT = 228 // { void *sys_shmat(int shmid, const void *shmaddr, \ + SYS_SHMDT = 230 // { int sys_shmdt(const void *shmaddr); } + SYS_MINHERIT = 250 // { int sys_minherit(void *addr, size_t len, \ + SYS_POLL = 252 // { int sys_poll(struct pollfd *fds, \ + SYS_ISSETUGID = 253 // { int sys_issetugid(void); } + SYS_LCHOWN = 254 // { int sys_lchown(const char *path, uid_t uid, gid_t gid); } + SYS_GETSID = 255 // { pid_t sys_getsid(pid_t pid); } + SYS_MSYNC = 256 // { int sys_msync(void *addr, size_t len, int flags); } + SYS_PIPE = 263 // { int sys_pipe(int *fdp); } + SYS_FHOPEN = 264 // { int sys_fhopen(const fhandle_t *fhp, int flags); } + SYS_PREADV = 267 // { ssize_t sys_preadv(int fd, \ + SYS_PWRITEV = 268 // { ssize_t sys_pwritev(int fd, \ + SYS_KQUEUE = 269 // { int sys_kqueue(void); } + SYS_MLOCKALL = 271 // { int sys_mlockall(int flags); } + SYS_MUNLOCKALL = 272 // { int sys_munlockall(void); } + SYS_GETRESUID = 281 // { int sys_getresuid(uid_t *ruid, uid_t *euid, \ + SYS_SETRESUID = 282 // { int sys_setresuid(uid_t ruid, uid_t euid, \ + SYS_GETRESGID = 283 // { int sys_getresgid(gid_t *rgid, gid_t *egid, \ + SYS_SETRESGID = 284 // { int sys_setresgid(gid_t rgid, gid_t egid, \ + SYS_MQUERY = 286 // { void *sys_mquery(void *addr, size_t len, int prot, \ + SYS_CLOSEFROM = 287 // { int sys_closefrom(int fd); } + SYS_SIGALTSTACK = 288 // { int sys_sigaltstack(const struct sigaltstack *nss, \ + SYS_SHMGET = 289 // { int sys_shmget(key_t key, size_t size, int shmflg); } + SYS_SEMOP = 290 // { int sys_semop(int semid, struct sembuf *sops, \ + SYS_FHSTAT = 294 // { int sys_fhstat(const fhandle_t *fhp, \ + SYS___SEMCTL = 295 // { int sys___semctl(int semid, int semnum, int cmd, \ + SYS_SHMCTL = 296 // { int sys_shmctl(int shmid, int cmd, \ + SYS_MSGCTL = 297 // { int sys_msgctl(int msqid, int cmd, \ + SYS_SCHED_YIELD = 298 // { int sys_sched_yield(void); } + SYS_GETTHRID = 299 // { pid_t sys_getthrid(void); } + SYS___THRWAKEUP = 301 // { int sys___thrwakeup(const volatile void *ident, \ + SYS___THREXIT = 302 // { void sys___threxit(pid_t *notdead); } + SYS___THRSIGDIVERT = 303 // { int sys___thrsigdivert(sigset_t sigmask, \ + SYS___GETCWD = 304 // { int sys___getcwd(char *buf, size_t len); } + SYS_ADJFREQ = 305 // { int sys_adjfreq(const int64_t *freq, \ + SYS_SETRTABLE = 310 // { int sys_setrtable(int rtableid); } + SYS_GETRTABLE = 311 // { int sys_getrtable(void); } + SYS_FACCESSAT = 313 // { int sys_faccessat(int fd, const char *path, \ + SYS_FCHMODAT = 314 // { int sys_fchmodat(int fd, const char *path, \ + SYS_FCHOWNAT = 315 // { int sys_fchownat(int fd, const char *path, \ + SYS_LINKAT = 317 // { int sys_linkat(int fd1, const char *path1, int fd2, \ + SYS_MKDIRAT = 318 // { int sys_mkdirat(int fd, const char *path, \ + SYS_MKFIFOAT = 319 // { int sys_mkfifoat(int fd, const char *path, \ + SYS_MKNODAT = 320 // { int sys_mknodat(int fd, const char *path, \ + SYS_OPENAT = 321 // { int sys_openat(int fd, const char *path, int flags, \ + SYS_READLINKAT = 322 // { ssize_t sys_readlinkat(int fd, const char *path, \ + SYS_RENAMEAT = 323 // { int sys_renameat(int fromfd, const char *from, \ + SYS_SYMLINKAT = 324 // { int sys_symlinkat(const char *path, int fd, \ + SYS_UNLINKAT = 325 // { int sys_unlinkat(int fd, const char *path, \ + SYS___SET_TCB = 329 // { void sys___set_tcb(void *tcb); } + SYS___GET_TCB = 330 // { void *sys___get_tcb(void); } +) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_amd64.go new file mode 100644 index 0000000000..bd28146ddd --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_amd64.go @@ -0,0 +1,207 @@ +// mksysnum_openbsd.pl +// MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT + +// +build amd64,openbsd + +package unix + +const ( + SYS_EXIT = 1 // { void sys_exit(int rval); } + SYS_FORK = 2 // { int sys_fork(void); } + SYS_READ = 3 // { ssize_t sys_read(int fd, void *buf, size_t nbyte); } + SYS_WRITE = 4 // { ssize_t sys_write(int fd, const void *buf, \ + SYS_OPEN = 5 // { int sys_open(const char *path, \ + SYS_CLOSE = 6 // { int sys_close(int fd); } + SYS___TFORK = 8 // { int sys___tfork(const struct __tfork *param, \ + SYS_LINK = 9 // { int sys_link(const char *path, const char *link); } + SYS_UNLINK = 10 // { int sys_unlink(const char *path); } + SYS_WAIT4 = 11 // { pid_t sys_wait4(pid_t pid, int *status, \ + SYS_CHDIR = 12 // { int sys_chdir(const char *path); } + SYS_FCHDIR = 13 // { int sys_fchdir(int fd); } + SYS_MKNOD = 14 // { int sys_mknod(const char *path, mode_t mode, \ + SYS_CHMOD = 15 // { int sys_chmod(const char *path, mode_t mode); } + SYS_CHOWN = 16 // { int sys_chown(const char *path, uid_t uid, \ + SYS_OBREAK = 17 // { int sys_obreak(char *nsize); } break + SYS_GETDTABLECOUNT = 18 // { int sys_getdtablecount(void); } + SYS_GETRUSAGE = 19 // { int sys_getrusage(int who, \ + SYS_GETPID = 20 // { pid_t sys_getpid(void); } + SYS_MOUNT = 21 // { int sys_mount(const char *type, const char *path, \ + SYS_UNMOUNT = 22 // { int sys_unmount(const char *path, int flags); } + SYS_SETUID = 23 // { int sys_setuid(uid_t uid); } + SYS_GETUID = 24 // { uid_t sys_getuid(void); } + SYS_GETEUID = 25 // { uid_t sys_geteuid(void); } + SYS_PTRACE = 26 // { int sys_ptrace(int req, pid_t pid, caddr_t addr, \ + SYS_RECVMSG = 27 // { ssize_t sys_recvmsg(int s, struct msghdr *msg, \ + SYS_SENDMSG = 28 // { ssize_t sys_sendmsg(int s, \ + SYS_RECVFROM = 29 // { ssize_t sys_recvfrom(int s, void *buf, size_t len, \ + SYS_ACCEPT = 30 // { int sys_accept(int s, struct sockaddr *name, \ + SYS_GETPEERNAME = 31 // { int sys_getpeername(int fdes, struct sockaddr *asa, \ + SYS_GETSOCKNAME = 32 // { int sys_getsockname(int fdes, struct sockaddr *asa, \ + SYS_ACCESS = 33 // { int sys_access(const char *path, int flags); } + SYS_CHFLAGS = 34 // { int sys_chflags(const char *path, u_int flags); } + SYS_FCHFLAGS = 35 // { int sys_fchflags(int fd, u_int flags); } + SYS_SYNC = 36 // { void sys_sync(void); } + SYS_KILL = 37 // { int sys_kill(int pid, int signum); } + SYS_STAT = 38 // { int sys_stat(const char *path, struct stat *ub); } + SYS_GETPPID = 39 // { pid_t sys_getppid(void); } + SYS_LSTAT = 40 // { int sys_lstat(const char *path, struct stat *ub); } + SYS_DUP = 41 // { int sys_dup(int fd); } + SYS_FSTATAT = 42 // { int sys_fstatat(int fd, const char *path, \ + SYS_GETEGID = 43 // { gid_t sys_getegid(void); } + SYS_PROFIL = 44 // { int sys_profil(caddr_t samples, size_t size, \ + SYS_KTRACE = 45 // { int sys_ktrace(const char *fname, int ops, \ + SYS_SIGACTION = 46 // { int sys_sigaction(int signum, \ + SYS_GETGID = 47 // { gid_t sys_getgid(void); } + SYS_SIGPROCMASK = 48 // { int sys_sigprocmask(int how, sigset_t mask); } + SYS_GETLOGIN = 49 // { int sys_getlogin(char *namebuf, u_int namelen); } + SYS_SETLOGIN = 50 // { int sys_setlogin(const char *namebuf); } + SYS_ACCT = 51 // { int sys_acct(const char *path); } + SYS_SIGPENDING = 52 // { int sys_sigpending(void); } + SYS_FSTAT = 53 // { int sys_fstat(int fd, struct stat *sb); } + SYS_IOCTL = 54 // { int sys_ioctl(int fd, \ + SYS_REBOOT = 55 // { int sys_reboot(int opt); } + SYS_REVOKE = 56 // { int sys_revoke(const char *path); } + SYS_SYMLINK = 57 // { int sys_symlink(const char *path, \ + SYS_READLINK = 58 // { int sys_readlink(const char *path, char *buf, \ + SYS_EXECVE = 59 // { int sys_execve(const char *path, \ + SYS_UMASK = 60 // { mode_t sys_umask(mode_t newmask); } + SYS_CHROOT = 61 // { int sys_chroot(const char *path); } + SYS_GETFSSTAT = 62 // { int sys_getfsstat(struct statfs *buf, size_t bufsize, \ + SYS_STATFS = 63 // { int sys_statfs(const char *path, \ + SYS_FSTATFS = 64 // { int sys_fstatfs(int fd, struct statfs *buf); } + SYS_FHSTATFS = 65 // { int sys_fhstatfs(const fhandle_t *fhp, \ + SYS_VFORK = 66 // { int sys_vfork(void); } + SYS_GETTIMEOFDAY = 67 // { int sys_gettimeofday(struct timeval *tp, \ + SYS_SETTIMEOFDAY = 68 // { int sys_settimeofday(const struct timeval *tv, \ + SYS_SETITIMER = 69 // { int sys_setitimer(int which, \ + SYS_GETITIMER = 70 // { int sys_getitimer(int which, \ + SYS_SELECT = 71 // { int sys_select(int nd, fd_set *in, fd_set *ou, \ + SYS_KEVENT = 72 // { int sys_kevent(int fd, \ + SYS_MUNMAP = 73 // { int sys_munmap(void *addr, size_t len); } + SYS_MPROTECT = 74 // { int sys_mprotect(void *addr, size_t len, \ + SYS_MADVISE = 75 // { int sys_madvise(void *addr, size_t len, \ + SYS_UTIMES = 76 // { int sys_utimes(const char *path, \ + SYS_FUTIMES = 77 // { int sys_futimes(int fd, \ + SYS_MINCORE = 78 // { int sys_mincore(void *addr, size_t len, \ + SYS_GETGROUPS = 79 // { int sys_getgroups(int gidsetsize, \ + SYS_SETGROUPS = 80 // { int sys_setgroups(int gidsetsize, \ + SYS_GETPGRP = 81 // { int sys_getpgrp(void); } + SYS_SETPGID = 82 // { int sys_setpgid(pid_t pid, int pgid); } + SYS_UTIMENSAT = 84 // { int sys_utimensat(int fd, const char *path, \ + SYS_FUTIMENS = 85 // { int sys_futimens(int fd, \ + SYS_CLOCK_GETTIME = 87 // { int sys_clock_gettime(clockid_t clock_id, \ + SYS_CLOCK_SETTIME = 88 // { int sys_clock_settime(clockid_t clock_id, \ + SYS_CLOCK_GETRES = 89 // { int sys_clock_getres(clockid_t clock_id, \ + SYS_DUP2 = 90 // { int sys_dup2(int from, int to); } + SYS_NANOSLEEP = 91 // { int sys_nanosleep(const struct timespec *rqtp, \ + SYS_FCNTL = 92 // { int sys_fcntl(int fd, int cmd, ... void *arg); } + SYS___THRSLEEP = 94 // { int sys___thrsleep(const volatile void *ident, \ + SYS_FSYNC = 95 // { int sys_fsync(int fd); } + SYS_SETPRIORITY = 96 // { int sys_setpriority(int which, id_t who, int prio); } + SYS_SOCKET = 97 // { int sys_socket(int domain, int type, int protocol); } + SYS_CONNECT = 98 // { int sys_connect(int s, const struct sockaddr *name, \ + SYS_GETDENTS = 99 // { int sys_getdents(int fd, void *buf, size_t buflen); } + SYS_GETPRIORITY = 100 // { int sys_getpriority(int which, id_t who); } + SYS_SIGRETURN = 103 // { int sys_sigreturn(struct sigcontext *sigcntxp); } + SYS_BIND = 104 // { int sys_bind(int s, const struct sockaddr *name, \ + SYS_SETSOCKOPT = 105 // { int sys_setsockopt(int s, int level, int name, \ + SYS_LISTEN = 106 // { int sys_listen(int s, int backlog); } + SYS_PPOLL = 109 // { int sys_ppoll(struct pollfd *fds, \ + SYS_PSELECT = 110 // { int sys_pselect(int nd, fd_set *in, fd_set *ou, \ + SYS_SIGSUSPEND = 111 // { int sys_sigsuspend(int mask); } + SYS_GETSOCKOPT = 118 // { int sys_getsockopt(int s, int level, int name, \ + SYS_READV = 120 // { ssize_t sys_readv(int fd, \ + SYS_WRITEV = 121 // { ssize_t sys_writev(int fd, \ + SYS_FCHOWN = 123 // { int sys_fchown(int fd, uid_t uid, gid_t gid); } + SYS_FCHMOD = 124 // { int sys_fchmod(int fd, mode_t mode); } + SYS_SETREUID = 126 // { int sys_setreuid(uid_t ruid, uid_t euid); } + SYS_SETREGID = 127 // { int sys_setregid(gid_t rgid, gid_t egid); } + SYS_RENAME = 128 // { int sys_rename(const char *from, const char *to); } + SYS_FLOCK = 131 // { int sys_flock(int fd, int how); } + SYS_MKFIFO = 132 // { int sys_mkfifo(const char *path, mode_t mode); } + SYS_SENDTO = 133 // { ssize_t sys_sendto(int s, const void *buf, \ + SYS_SHUTDOWN = 134 // { int sys_shutdown(int s, int how); } + SYS_SOCKETPAIR = 135 // { int sys_socketpair(int domain, int type, \ + SYS_MKDIR = 136 // { int sys_mkdir(const char *path, mode_t mode); } + SYS_RMDIR = 137 // { int sys_rmdir(const char *path); } + SYS_ADJTIME = 140 // { int sys_adjtime(const struct timeval *delta, \ + SYS_SETSID = 147 // { int sys_setsid(void); } + SYS_QUOTACTL = 148 // { int sys_quotactl(const char *path, int cmd, \ + SYS_NFSSVC = 155 // { int sys_nfssvc(int flag, void *argp); } + SYS_GETFH = 161 // { int sys_getfh(const char *fname, fhandle_t *fhp); } + SYS_SYSARCH = 165 // { int sys_sysarch(int op, void *parms); } + SYS_PREAD = 173 // { ssize_t sys_pread(int fd, void *buf, \ + SYS_PWRITE = 174 // { ssize_t sys_pwrite(int fd, const void *buf, \ + SYS_SETGID = 181 // { int sys_setgid(gid_t gid); } + SYS_SETEGID = 182 // { int sys_setegid(gid_t egid); } + SYS_SETEUID = 183 // { int sys_seteuid(uid_t euid); } + SYS_PATHCONF = 191 // { long sys_pathconf(const char *path, int name); } + SYS_FPATHCONF = 192 // { long sys_fpathconf(int fd, int name); } + SYS_SWAPCTL = 193 // { int sys_swapctl(int cmd, const void *arg, int misc); } + SYS_GETRLIMIT = 194 // { int sys_getrlimit(int which, \ + SYS_SETRLIMIT = 195 // { int sys_setrlimit(int which, \ + SYS_MMAP = 197 // { void *sys_mmap(void *addr, size_t len, int prot, \ + SYS_LSEEK = 199 // { off_t sys_lseek(int fd, int pad, off_t offset, \ + SYS_TRUNCATE = 200 // { int sys_truncate(const char *path, int pad, \ + SYS_FTRUNCATE = 201 // { int sys_ftruncate(int fd, int pad, off_t length); } + SYS___SYSCTL = 202 // { int sys___sysctl(const int *name, u_int namelen, \ + SYS_MLOCK = 203 // { int sys_mlock(const void *addr, size_t len); } + SYS_MUNLOCK = 204 // { int sys_munlock(const void *addr, size_t len); } + SYS_GETPGID = 207 // { pid_t sys_getpgid(pid_t pid); } + SYS_UTRACE = 209 // { int sys_utrace(const char *label, const void *addr, \ + SYS_SEMGET = 221 // { int sys_semget(key_t key, int nsems, int semflg); } + SYS_MSGGET = 225 // { int sys_msgget(key_t key, int msgflg); } + SYS_MSGSND = 226 // { int sys_msgsnd(int msqid, const void *msgp, size_t msgsz, \ + SYS_MSGRCV = 227 // { int sys_msgrcv(int msqid, void *msgp, size_t msgsz, \ + SYS_SHMAT = 228 // { void *sys_shmat(int shmid, const void *shmaddr, \ + SYS_SHMDT = 230 // { int sys_shmdt(const void *shmaddr); } + SYS_MINHERIT = 250 // { int sys_minherit(void *addr, size_t len, \ + SYS_POLL = 252 // { int sys_poll(struct pollfd *fds, \ + SYS_ISSETUGID = 253 // { int sys_issetugid(void); } + SYS_LCHOWN = 254 // { int sys_lchown(const char *path, uid_t uid, gid_t gid); } + SYS_GETSID = 255 // { pid_t sys_getsid(pid_t pid); } + SYS_MSYNC = 256 // { int sys_msync(void *addr, size_t len, int flags); } + SYS_PIPE = 263 // { int sys_pipe(int *fdp); } + SYS_FHOPEN = 264 // { int sys_fhopen(const fhandle_t *fhp, int flags); } + SYS_PREADV = 267 // { ssize_t sys_preadv(int fd, \ + SYS_PWRITEV = 268 // { ssize_t sys_pwritev(int fd, \ + SYS_KQUEUE = 269 // { int sys_kqueue(void); } + SYS_MLOCKALL = 271 // { int sys_mlockall(int flags); } + SYS_MUNLOCKALL = 272 // { int sys_munlockall(void); } + SYS_GETRESUID = 281 // { int sys_getresuid(uid_t *ruid, uid_t *euid, \ + SYS_SETRESUID = 282 // { int sys_setresuid(uid_t ruid, uid_t euid, \ + SYS_GETRESGID = 283 // { int sys_getresgid(gid_t *rgid, gid_t *egid, \ + SYS_SETRESGID = 284 // { int sys_setresgid(gid_t rgid, gid_t egid, \ + SYS_MQUERY = 286 // { void *sys_mquery(void *addr, size_t len, int prot, \ + SYS_CLOSEFROM = 287 // { int sys_closefrom(int fd); } + SYS_SIGALTSTACK = 288 // { int sys_sigaltstack(const struct sigaltstack *nss, \ + SYS_SHMGET = 289 // { int sys_shmget(key_t key, size_t size, int shmflg); } + SYS_SEMOP = 290 // { int sys_semop(int semid, struct sembuf *sops, \ + SYS_FHSTAT = 294 // { int sys_fhstat(const fhandle_t *fhp, \ + SYS___SEMCTL = 295 // { int sys___semctl(int semid, int semnum, int cmd, \ + SYS_SHMCTL = 296 // { int sys_shmctl(int shmid, int cmd, \ + SYS_MSGCTL = 297 // { int sys_msgctl(int msqid, int cmd, \ + SYS_SCHED_YIELD = 298 // { int sys_sched_yield(void); } + SYS_GETTHRID = 299 // { pid_t sys_getthrid(void); } + SYS___THRWAKEUP = 301 // { int sys___thrwakeup(const volatile void *ident, \ + SYS___THREXIT = 302 // { void sys___threxit(pid_t *notdead); } + SYS___THRSIGDIVERT = 303 // { int sys___thrsigdivert(sigset_t sigmask, \ + SYS___GETCWD = 304 // { int sys___getcwd(char *buf, size_t len); } + SYS_ADJFREQ = 305 // { int sys_adjfreq(const int64_t *freq, \ + SYS_SETRTABLE = 310 // { int sys_setrtable(int rtableid); } + SYS_GETRTABLE = 311 // { int sys_getrtable(void); } + SYS_FACCESSAT = 313 // { int sys_faccessat(int fd, const char *path, \ + SYS_FCHMODAT = 314 // { int sys_fchmodat(int fd, const char *path, \ + SYS_FCHOWNAT = 315 // { int sys_fchownat(int fd, const char *path, \ + SYS_LINKAT = 317 // { int sys_linkat(int fd1, const char *path1, int fd2, \ + SYS_MKDIRAT = 318 // { int sys_mkdirat(int fd, const char *path, \ + SYS_MKFIFOAT = 319 // { int sys_mkfifoat(int fd, const char *path, \ + SYS_MKNODAT = 320 // { int sys_mknodat(int fd, const char *path, \ + SYS_OPENAT = 321 // { int sys_openat(int fd, const char *path, int flags, \ + SYS_READLINKAT = 322 // { ssize_t sys_readlinkat(int fd, const char *path, \ + SYS_RENAMEAT = 323 // { int sys_renameat(int fromfd, const char *from, \ + SYS_SYMLINKAT = 324 // { int sys_symlinkat(const char *path, int fd, \ + SYS_UNLINKAT = 325 // { int sys_unlinkat(int fd, const char *path, \ + SYS___SET_TCB = 329 // { void sys___set_tcb(void *tcb); } + SYS___GET_TCB = 330 // { void *sys___get_tcb(void); } +) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_solaris_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_solaris_amd64.go new file mode 100644 index 0000000000..c708659859 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_solaris_amd64.go @@ -0,0 +1,13 @@ +// 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 amd64,solaris + +package unix + +// TODO(aram): remove these before Go 1.3. +const ( + SYS_EXECVE = 59 + SYS_FCNTL = 62 +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go new file mode 100644 index 0000000000..2de1d44e28 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go @@ -0,0 +1,447 @@ +// +build 386,darwin +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_darwin.go + +package unix + +const ( + sizeofPtr = 0x4 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x4 + sizeofLongLong = 0x8 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int32 + _C_long_long int64 +) + +type Timespec struct { + Sec int32 + Nsec int32 +} + +type Timeval struct { + Sec int32 + Usec int32 +} + +type Timeval32 struct{} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int32 + Ixrss int32 + Idrss int32 + Isrss int32 + Minflt int32 + Majflt int32 + Nswap int32 + Inblock int32 + Oublock int32 + Msgsnd int32 + Msgrcv int32 + Nsignals int32 + Nvcsw int32 + Nivcsw int32 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +type Stat_t struct { + Dev int32 + Mode uint16 + Nlink uint16 + Ino uint64 + Uid uint32 + Gid uint32 + Rdev int32 + Atimespec Timespec + Mtimespec Timespec + Ctimespec Timespec + Birthtimespec Timespec + Size int64 + Blocks int64 + Blksize int32 + Flags uint32 + Gen uint32 + Lspare int32 + Qspare [2]int64 +} + +type Statfs_t struct { + Bsize uint32 + Iosize int32 + Blocks uint64 + Bfree uint64 + Bavail uint64 + Files uint64 + Ffree uint64 + Fsid Fsid + Owner uint32 + Type uint32 + Flags uint32 + Fssubtype uint32 + Fstypename [16]int8 + Mntonname [1024]int8 + Mntfromname [1024]int8 + Reserved [8]uint32 +} + +type Flock_t struct { + Start int64 + Len int64 + Pid int32 + Type int16 + Whence int16 +} + +type Fstore_t struct { + Flags uint32 + Posmode int32 + Offset int64 + Length int64 + Bytesalloc int64 +} + +type Radvisory_t struct { + Offset int64 + Count int32 +} + +type Fbootstraptransfer_t struct { + Offset int64 + Length uint32 + Buffer *byte +} + +type Log2phys_t struct { + Flags uint32 + Contigbytes int64 + Devoffset int64 +} + +type Fsid struct { + Val [2]int32 +} + +type Dirent struct { + Ino uint64 + Seekoff uint64 + Reclen uint16 + Namlen uint16 + Type uint8 + Name [1024]int8 + Pad_cgo_0 [3]byte +} + +type RawSockaddrInet4 struct { + Len uint8 + Family uint8 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]int8 +} + +type RawSockaddrInet6 struct { + Len uint8 + Family uint8 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Len uint8 + Family uint8 + Path [104]int8 +} + +type RawSockaddrDatalink struct { + Len uint8 + Family uint8 + Index uint16 + Type uint8 + Nlen uint8 + Alen uint8 + Slen uint8 + Data [12]int8 +} + +type RawSockaddr struct { + Len uint8 + Family uint8 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [92]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint32 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Iov *Iovec + Iovlen int32 + Control *byte + Controllen uint32 + Flags int32 +} + +type Cmsghdr struct { + Len uint32 + Level int32 + Type int32 +} + +type Inet4Pktinfo struct { + Ifindex uint32 + Spec_dst [4]byte /* in_addr */ + Addr [4]byte /* in_addr */ +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Filt [8]uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x6c + SizeofSockaddrUnix = 0x6a + SizeofSockaddrDatalink = 0x14 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x1c + SizeofCmsghdr = 0xc + SizeofInet4Pktinfo = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 +) + +const ( + PTRACE_TRACEME = 0x0 + PTRACE_CONT = 0x7 + PTRACE_KILL = 0x8 +) + +type Kevent_t struct { + Ident uint32 + Filter int16 + Flags uint16 + Fflags uint32 + Data int32 + Udata *byte +} + +type FdSet struct { + Bits [32]int32 +} + +const ( + SizeofIfMsghdr = 0x70 + SizeofIfData = 0x60 + SizeofIfaMsghdr = 0x14 + SizeofIfmaMsghdr = 0x10 + SizeofIfmaMsghdr2 = 0x14 + SizeofRtMsghdr = 0x5c + SizeofRtMetrics = 0x38 +) + +type IfMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Data IfData +} + +type IfData struct { + Type uint8 + Typelen uint8 + Physical uint8 + Addrlen uint8 + Hdrlen uint8 + Recvquota uint8 + Xmitquota uint8 + Unused1 uint8 + Mtu uint32 + Metric uint32 + Baudrate uint32 + Ipackets uint32 + Ierrors uint32 + Opackets uint32 + Oerrors uint32 + Collisions uint32 + Ibytes uint32 + Obytes uint32 + Imcasts uint32 + Omcasts uint32 + Iqdrops uint32 + Noproto uint32 + Recvtiming uint32 + Xmittiming uint32 + Lastchange Timeval + Unused2 uint32 + Hwassist uint32 + Reserved1 uint32 + Reserved2 uint32 +} + +type IfaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Metric int32 +} + +type IfmaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte +} + +type IfmaMsghdr2 struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Refcount int32 +} + +type RtMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Index uint16 + Pad_cgo_0 [2]byte + Flags int32 + Addrs int32 + Pid int32 + Seq int32 + Errno int32 + Use int32 + Inits uint32 + Rmx RtMetrics +} + +type RtMetrics struct { + Locks uint32 + Mtu uint32 + Hopcount uint32 + Expire int32 + Recvpipe uint32 + Sendpipe uint32 + Ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Pksent uint32 + Filler [4]uint32 +} + +const ( + SizeofBpfVersion = 0x4 + SizeofBpfStat = 0x8 + SizeofBpfProgram = 0x8 + SizeofBpfInsn = 0x8 + SizeofBpfHdr = 0x14 +) + +type BpfVersion struct { + Major uint16 + Minor uint16 +} + +type BpfStat struct { + Recv uint32 + Drop uint32 +} + +type BpfProgram struct { + Len uint32 + Insns *BpfInsn +} + +type BpfInsn struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type BpfHdr struct { + Tstamp Timeval + Caplen uint32 + Datalen uint32 + Hdrlen uint16 + Pad_cgo_0 [2]byte +} + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Cc [20]uint8 + Ispeed uint32 + Ospeed uint32 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go new file mode 100644 index 0000000000..044657878c --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go @@ -0,0 +1,462 @@ +// +build amd64,darwin +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_darwin.go + +package unix + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int32 + Pad_cgo_0 [4]byte +} + +type Timeval32 struct { + Sec int32 + Usec int32 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +type Stat_t struct { + Dev int32 + Mode uint16 + Nlink uint16 + Ino uint64 + Uid uint32 + Gid uint32 + Rdev int32 + Pad_cgo_0 [4]byte + Atimespec Timespec + Mtimespec Timespec + Ctimespec Timespec + Birthtimespec Timespec + Size int64 + Blocks int64 + Blksize int32 + Flags uint32 + Gen uint32 + Lspare int32 + Qspare [2]int64 +} + +type Statfs_t struct { + Bsize uint32 + Iosize int32 + Blocks uint64 + Bfree uint64 + Bavail uint64 + Files uint64 + Ffree uint64 + Fsid Fsid + Owner uint32 + Type uint32 + Flags uint32 + Fssubtype uint32 + Fstypename [16]int8 + Mntonname [1024]int8 + Mntfromname [1024]int8 + Reserved [8]uint32 +} + +type Flock_t struct { + Start int64 + Len int64 + Pid int32 + Type int16 + Whence int16 +} + +type Fstore_t struct { + Flags uint32 + Posmode int32 + Offset int64 + Length int64 + Bytesalloc int64 +} + +type Radvisory_t struct { + Offset int64 + Count int32 + Pad_cgo_0 [4]byte +} + +type Fbootstraptransfer_t struct { + Offset int64 + Length uint64 + Buffer *byte +} + +type Log2phys_t struct { + Flags uint32 + Pad_cgo_0 [8]byte + Pad_cgo_1 [8]byte +} + +type Fsid struct { + Val [2]int32 +} + +type Dirent struct { + Ino uint64 + Seekoff uint64 + Reclen uint16 + Namlen uint16 + Type uint8 + Name [1024]int8 + Pad_cgo_0 [3]byte +} + +type RawSockaddrInet4 struct { + Len uint8 + Family uint8 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]int8 +} + +type RawSockaddrInet6 struct { + Len uint8 + Family uint8 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Len uint8 + Family uint8 + Path [104]int8 +} + +type RawSockaddrDatalink struct { + Len uint8 + Family uint8 + Index uint16 + Type uint8 + Nlen uint8 + Alen uint8 + Slen uint8 + Data [12]int8 +} + +type RawSockaddr struct { + Len uint8 + Family uint8 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [92]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint64 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Pad_cgo_0 [4]byte + Iov *Iovec + Iovlen int32 + Pad_cgo_1 [4]byte + Control *byte + Controllen uint32 + Flags int32 +} + +type Cmsghdr struct { + Len uint32 + Level int32 + Type int32 +} + +type Inet4Pktinfo struct { + Ifindex uint32 + Spec_dst [4]byte /* in_addr */ + Addr [4]byte /* in_addr */ +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Filt [8]uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x6c + SizeofSockaddrUnix = 0x6a + SizeofSockaddrDatalink = 0x14 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x30 + SizeofCmsghdr = 0xc + SizeofInet4Pktinfo = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 +) + +const ( + PTRACE_TRACEME = 0x0 + PTRACE_CONT = 0x7 + PTRACE_KILL = 0x8 +) + +type Kevent_t struct { + Ident uint64 + Filter int16 + Flags uint16 + Fflags uint32 + Data int64 + Udata *byte +} + +type FdSet struct { + Bits [32]int32 +} + +const ( + SizeofIfMsghdr = 0x70 + SizeofIfData = 0x60 + SizeofIfaMsghdr = 0x14 + SizeofIfmaMsghdr = 0x10 + SizeofIfmaMsghdr2 = 0x14 + SizeofRtMsghdr = 0x5c + SizeofRtMetrics = 0x38 +) + +type IfMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Data IfData +} + +type IfData struct { + Type uint8 + Typelen uint8 + Physical uint8 + Addrlen uint8 + Hdrlen uint8 + Recvquota uint8 + Xmitquota uint8 + Unused1 uint8 + Mtu uint32 + Metric uint32 + Baudrate uint32 + Ipackets uint32 + Ierrors uint32 + Opackets uint32 + Oerrors uint32 + Collisions uint32 + Ibytes uint32 + Obytes uint32 + Imcasts uint32 + Omcasts uint32 + Iqdrops uint32 + Noproto uint32 + Recvtiming uint32 + Xmittiming uint32 + Lastchange Timeval32 + Unused2 uint32 + Hwassist uint32 + Reserved1 uint32 + Reserved2 uint32 +} + +type IfaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Metric int32 +} + +type IfmaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte +} + +type IfmaMsghdr2 struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Refcount int32 +} + +type RtMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Index uint16 + Pad_cgo_0 [2]byte + Flags int32 + Addrs int32 + Pid int32 + Seq int32 + Errno int32 + Use int32 + Inits uint32 + Rmx RtMetrics +} + +type RtMetrics struct { + Locks uint32 + Mtu uint32 + Hopcount uint32 + Expire int32 + Recvpipe uint32 + Sendpipe uint32 + Ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Pksent uint32 + Filler [4]uint32 +} + +const ( + SizeofBpfVersion = 0x4 + SizeofBpfStat = 0x8 + SizeofBpfProgram = 0x10 + SizeofBpfInsn = 0x8 + SizeofBpfHdr = 0x14 +) + +type BpfVersion struct { + Major uint16 + Minor uint16 +} + +type BpfStat struct { + Recv uint32 + Drop uint32 +} + +type BpfProgram struct { + Len uint32 + Pad_cgo_0 [4]byte + Insns *BpfInsn +} + +type BpfInsn struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type BpfHdr struct { + Tstamp Timeval32 + Caplen uint32 + Datalen uint32 + Hdrlen uint16 + Pad_cgo_0 [2]byte +} + +type Termios struct { + Iflag uint64 + Oflag uint64 + Cflag uint64 + Lflag uint64 + Cc [20]uint8 + Pad_cgo_0 [4]byte + Ispeed uint64 + Ospeed uint64 +} + +const ( + AT_FDCWD = -0x2 + AT_SYMLINK_NOFOLLOW = 0x20 +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go new file mode 100644 index 0000000000..66df363ce5 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go @@ -0,0 +1,449 @@ +// NOTE: cgo can't generate struct Stat_t and struct Statfs_t yet +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_darwin.go + +// +build arm,darwin + +package unix + +const ( + sizeofPtr = 0x4 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x4 + sizeofLongLong = 0x8 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int32 + _C_long_long int64 +) + +type Timespec struct { + Sec int32 + Nsec int32 +} + +type Timeval struct { + Sec int32 + Usec int32 +} + +type Timeval32 [0]byte + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int32 + Ixrss int32 + Idrss int32 + Isrss int32 + Minflt int32 + Majflt int32 + Nswap int32 + Inblock int32 + Oublock int32 + Msgsnd int32 + Msgrcv int32 + Nsignals int32 + Nvcsw int32 + Nivcsw int32 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +type Stat_t struct { + Dev int32 + Mode uint16 + Nlink uint16 + Ino uint64 + Uid uint32 + Gid uint32 + Rdev int32 + Atimespec Timespec + Mtimespec Timespec + Ctimespec Timespec + Birthtimespec Timespec + Size int64 + Blocks int64 + Blksize int32 + Flags uint32 + Gen uint32 + Lspare int32 + Qspare [2]int64 +} + +type Statfs_t struct { + Bsize uint32 + Iosize int32 + Blocks uint64 + Bfree uint64 + Bavail uint64 + Files uint64 + Ffree uint64 + Fsid Fsid + Owner uint32 + Type uint32 + Flags uint32 + Fssubtype uint32 + Fstypename [16]int8 + Mntonname [1024]int8 + Mntfromname [1024]int8 + Reserved [8]uint32 +} + +type Flock_t struct { + Start int64 + Len int64 + Pid int32 + Type int16 + Whence int16 +} + +type Fstore_t struct { + Flags uint32 + Posmode int32 + Offset int64 + Length int64 + Bytesalloc int64 +} + +type Radvisory_t struct { + Offset int64 + Count int32 +} + +type Fbootstraptransfer_t struct { + Offset int64 + Length uint32 + Buffer *byte +} + +type Log2phys_t struct { + Flags uint32 + Contigbytes int64 + Devoffset int64 +} + +type Fsid struct { + Val [2]int32 +} + +type Dirent struct { + Ino uint64 + Seekoff uint64 + Reclen uint16 + Namlen uint16 + Type uint8 + Name [1024]int8 + Pad_cgo_0 [3]byte +} + +type RawSockaddrInet4 struct { + Len uint8 + Family uint8 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]int8 +} + +type RawSockaddrInet6 struct { + Len uint8 + Family uint8 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Len uint8 + Family uint8 + Path [104]int8 +} + +type RawSockaddrDatalink struct { + Len uint8 + Family uint8 + Index uint16 + Type uint8 + Nlen uint8 + Alen uint8 + Slen uint8 + Data [12]int8 +} + +type RawSockaddr struct { + Len uint8 + Family uint8 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [92]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint32 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Iov *Iovec + Iovlen int32 + Control *byte + Controllen uint32 + Flags int32 +} + +type Cmsghdr struct { + Len uint32 + Level int32 + Type int32 +} + +type Inet4Pktinfo struct { + Ifindex uint32 + Spec_dst [4]byte /* in_addr */ + Addr [4]byte /* in_addr */ +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Filt [8]uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x6c + SizeofSockaddrUnix = 0x6a + SizeofSockaddrDatalink = 0x14 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x1c + SizeofCmsghdr = 0xc + SizeofInet4Pktinfo = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 +) + +const ( + PTRACE_TRACEME = 0x0 + PTRACE_CONT = 0x7 + PTRACE_KILL = 0x8 +) + +type Kevent_t struct { + Ident uint32 + Filter int16 + Flags uint16 + Fflags uint32 + Data int32 + Udata *byte +} + +type FdSet struct { + Bits [32]int32 +} + +const ( + SizeofIfMsghdr = 0x70 + SizeofIfData = 0x60 + SizeofIfaMsghdr = 0x14 + SizeofIfmaMsghdr = 0x10 + SizeofIfmaMsghdr2 = 0x14 + SizeofRtMsghdr = 0x5c + SizeofRtMetrics = 0x38 +) + +type IfMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Data IfData +} + +type IfData struct { + Type uint8 + Typelen uint8 + Physical uint8 + Addrlen uint8 + Hdrlen uint8 + Recvquota uint8 + Xmitquota uint8 + Unused1 uint8 + Mtu uint32 + Metric uint32 + Baudrate uint32 + Ipackets uint32 + Ierrors uint32 + Opackets uint32 + Oerrors uint32 + Collisions uint32 + Ibytes uint32 + Obytes uint32 + Imcasts uint32 + Omcasts uint32 + Iqdrops uint32 + Noproto uint32 + Recvtiming uint32 + Xmittiming uint32 + Lastchange Timeval + Unused2 uint32 + Hwassist uint32 + Reserved1 uint32 + Reserved2 uint32 +} + +type IfaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Metric int32 +} + +type IfmaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte +} + +type IfmaMsghdr2 struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Refcount int32 +} + +type RtMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Index uint16 + Pad_cgo_0 [2]byte + Flags int32 + Addrs int32 + Pid int32 + Seq int32 + Errno int32 + Use int32 + Inits uint32 + Rmx RtMetrics +} + +type RtMetrics struct { + Locks uint32 + Mtu uint32 + Hopcount uint32 + Expire int32 + Recvpipe uint32 + Sendpipe uint32 + Ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Pksent uint32 + Filler [4]uint32 +} + +const ( + SizeofBpfVersion = 0x4 + SizeofBpfStat = 0x8 + SizeofBpfProgram = 0x8 + SizeofBpfInsn = 0x8 + SizeofBpfHdr = 0x14 +) + +type BpfVersion struct { + Major uint16 + Minor uint16 +} + +type BpfStat struct { + Recv uint32 + Drop uint32 +} + +type BpfProgram struct { + Len uint32 + Insns *BpfInsn +} + +type BpfInsn struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type BpfHdr struct { + Tstamp Timeval + Caplen uint32 + Datalen uint32 + Hdrlen uint16 + Pad_cgo_0 [2]byte +} + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Cc [20]uint8 + Ispeed uint32 + Ospeed uint32 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go new file mode 100644 index 0000000000..85d56eabd3 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go @@ -0,0 +1,457 @@ +// +build arm64,darwin +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_darwin.go + +package unix + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int32 + Pad_cgo_0 [4]byte +} + +type Timeval32 struct { + Sec int32 + Usec int32 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +type Stat_t struct { + Dev int32 + Mode uint16 + Nlink uint16 + Ino uint64 + Uid uint32 + Gid uint32 + Rdev int32 + Pad_cgo_0 [4]byte + Atimespec Timespec + Mtimespec Timespec + Ctimespec Timespec + Birthtimespec Timespec + Size int64 + Blocks int64 + Blksize int32 + Flags uint32 + Gen uint32 + Lspare int32 + Qspare [2]int64 +} + +type Statfs_t struct { + Bsize uint32 + Iosize int32 + Blocks uint64 + Bfree uint64 + Bavail uint64 + Files uint64 + Ffree uint64 + Fsid Fsid + Owner uint32 + Type uint32 + Flags uint32 + Fssubtype uint32 + Fstypename [16]int8 + Mntonname [1024]int8 + Mntfromname [1024]int8 + Reserved [8]uint32 +} + +type Flock_t struct { + Start int64 + Len int64 + Pid int32 + Type int16 + Whence int16 +} + +type Fstore_t struct { + Flags uint32 + Posmode int32 + Offset int64 + Length int64 + Bytesalloc int64 +} + +type Radvisory_t struct { + Offset int64 + Count int32 + Pad_cgo_0 [4]byte +} + +type Fbootstraptransfer_t struct { + Offset int64 + Length uint64 + Buffer *byte +} + +type Log2phys_t struct { + Flags uint32 + Pad_cgo_0 [8]byte + Pad_cgo_1 [8]byte +} + +type Fsid struct { + Val [2]int32 +} + +type Dirent struct { + Ino uint64 + Seekoff uint64 + Reclen uint16 + Namlen uint16 + Type uint8 + Name [1024]int8 + Pad_cgo_0 [3]byte +} + +type RawSockaddrInet4 struct { + Len uint8 + Family uint8 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]int8 +} + +type RawSockaddrInet6 struct { + Len uint8 + Family uint8 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Len uint8 + Family uint8 + Path [104]int8 +} + +type RawSockaddrDatalink struct { + Len uint8 + Family uint8 + Index uint16 + Type uint8 + Nlen uint8 + Alen uint8 + Slen uint8 + Data [12]int8 +} + +type RawSockaddr struct { + Len uint8 + Family uint8 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [92]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint64 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Pad_cgo_0 [4]byte + Iov *Iovec + Iovlen int32 + Pad_cgo_1 [4]byte + Control *byte + Controllen uint32 + Flags int32 +} + +type Cmsghdr struct { + Len uint32 + Level int32 + Type int32 +} + +type Inet4Pktinfo struct { + Ifindex uint32 + Spec_dst [4]byte /* in_addr */ + Addr [4]byte /* in_addr */ +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Filt [8]uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x6c + SizeofSockaddrUnix = 0x6a + SizeofSockaddrDatalink = 0x14 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x30 + SizeofCmsghdr = 0xc + SizeofInet4Pktinfo = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 +) + +const ( + PTRACE_TRACEME = 0x0 + PTRACE_CONT = 0x7 + PTRACE_KILL = 0x8 +) + +type Kevent_t struct { + Ident uint64 + Filter int16 + Flags uint16 + Fflags uint32 + Data int64 + Udata *byte +} + +type FdSet struct { + Bits [32]int32 +} + +const ( + SizeofIfMsghdr = 0x70 + SizeofIfData = 0x60 + SizeofIfaMsghdr = 0x14 + SizeofIfmaMsghdr = 0x10 + SizeofIfmaMsghdr2 = 0x14 + SizeofRtMsghdr = 0x5c + SizeofRtMetrics = 0x38 +) + +type IfMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Data IfData +} + +type IfData struct { + Type uint8 + Typelen uint8 + Physical uint8 + Addrlen uint8 + Hdrlen uint8 + Recvquota uint8 + Xmitquota uint8 + Unused1 uint8 + Mtu uint32 + Metric uint32 + Baudrate uint32 + Ipackets uint32 + Ierrors uint32 + Opackets uint32 + Oerrors uint32 + Collisions uint32 + Ibytes uint32 + Obytes uint32 + Imcasts uint32 + Omcasts uint32 + Iqdrops uint32 + Noproto uint32 + Recvtiming uint32 + Xmittiming uint32 + Lastchange Timeval32 + Unused2 uint32 + Hwassist uint32 + Reserved1 uint32 + Reserved2 uint32 +} + +type IfaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Metric int32 +} + +type IfmaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte +} + +type IfmaMsghdr2 struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Refcount int32 +} + +type RtMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Index uint16 + Pad_cgo_0 [2]byte + Flags int32 + Addrs int32 + Pid int32 + Seq int32 + Errno int32 + Use int32 + Inits uint32 + Rmx RtMetrics +} + +type RtMetrics struct { + Locks uint32 + Mtu uint32 + Hopcount uint32 + Expire int32 + Recvpipe uint32 + Sendpipe uint32 + Ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Pksent uint32 + Filler [4]uint32 +} + +const ( + SizeofBpfVersion = 0x4 + SizeofBpfStat = 0x8 + SizeofBpfProgram = 0x10 + SizeofBpfInsn = 0x8 + SizeofBpfHdr = 0x14 +) + +type BpfVersion struct { + Major uint16 + Minor uint16 +} + +type BpfStat struct { + Recv uint32 + Drop uint32 +} + +type BpfProgram struct { + Len uint32 + Pad_cgo_0 [4]byte + Insns *BpfInsn +} + +type BpfInsn struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type BpfHdr struct { + Tstamp Timeval32 + Caplen uint32 + Datalen uint32 + Hdrlen uint16 + Pad_cgo_0 [2]byte +} + +type Termios struct { + Iflag uint64 + Oflag uint64 + Cflag uint64 + Lflag uint64 + Cc [20]uint8 + Pad_cgo_0 [4]byte + Ispeed uint64 + Ospeed uint64 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go new file mode 100644 index 0000000000..8a6f4e1ce3 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go @@ -0,0 +1,443 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_dragonfly.go + +// +build amd64,dragonfly + +package unix + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int64 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur int64 + Max int64 +} + +type _Gid_t uint32 + +const ( + S_IFMT = 0xf000 + S_IFIFO = 0x1000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFBLK = 0x6000 + S_IFREG = 0x8000 + S_IFLNK = 0xa000 + S_IFSOCK = 0xc000 + S_ISUID = 0x800 + S_ISGID = 0x400 + S_ISVTX = 0x200 + S_IRUSR = 0x100 + S_IWUSR = 0x80 + S_IXUSR = 0x40 +) + +type Stat_t struct { + Ino uint64 + Nlink uint32 + Dev uint32 + Mode uint16 + Padding1 uint16 + Uid uint32 + Gid uint32 + Rdev uint32 + Atim Timespec + Mtim Timespec + Ctim Timespec + Size int64 + Blocks int64 + Blksize uint32 + Flags uint32 + Gen uint32 + Lspare int32 + Qspare1 int64 + Qspare2 int64 +} + +type Statfs_t struct { + Spare2 int64 + Bsize int64 + Iosize int64 + Blocks int64 + Bfree int64 + Bavail int64 + Files int64 + Ffree int64 + Fsid Fsid + Owner uint32 + Type int32 + Flags int32 + Pad_cgo_0 [4]byte + Syncwrites int64 + Asyncwrites int64 + Fstypename [16]int8 + Mntonname [80]int8 + Syncreads int64 + Asyncreads int64 + Spares1 int16 + Mntfromname [80]int8 + Spares2 int16 + Pad_cgo_1 [4]byte + Spare [2]int64 +} + +type Flock_t struct { + Start int64 + Len int64 + Pid int32 + Type int16 + Whence int16 +} + +type Dirent struct { + Fileno uint64 + Namlen uint16 + Type uint8 + Unused1 uint8 + Unused2 uint32 + Name [256]int8 +} + +type Fsid struct { + Val [2]int32 +} + +type RawSockaddrInet4 struct { + Len uint8 + Family uint8 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]int8 +} + +type RawSockaddrInet6 struct { + Len uint8 + Family uint8 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Len uint8 + Family uint8 + Path [104]int8 +} + +type RawSockaddrDatalink struct { + Len uint8 + Family uint8 + Index uint16 + Type uint8 + Nlen uint8 + Alen uint8 + Slen uint8 + Data [12]int8 + Rcf uint16 + Route [16]uint16 +} + +type RawSockaddr struct { + Len uint8 + Family uint8 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [92]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint64 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Pad_cgo_0 [4]byte + Iov *Iovec + Iovlen int32 + Pad_cgo_1 [4]byte + Control *byte + Controllen uint32 + Flags int32 +} + +type Cmsghdr struct { + Len uint32 + Level int32 + Type int32 +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Filt [8]uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x6c + SizeofSockaddrUnix = 0x6a + SizeofSockaddrDatalink = 0x36 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x30 + SizeofCmsghdr = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 +) + +const ( + PTRACE_TRACEME = 0x0 + PTRACE_CONT = 0x7 + PTRACE_KILL = 0x8 +) + +type Kevent_t struct { + Ident uint64 + Filter int16 + Flags uint16 + Fflags uint32 + Data int64 + Udata *byte +} + +type FdSet struct { + Bits [16]uint64 +} + +const ( + SizeofIfMsghdr = 0xb0 + SizeofIfData = 0xa0 + SizeofIfaMsghdr = 0x14 + SizeofIfmaMsghdr = 0x10 + SizeofIfAnnounceMsghdr = 0x18 + SizeofRtMsghdr = 0x98 + SizeofRtMetrics = 0x70 +) + +type IfMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Data IfData +} + +type IfData struct { + Type uint8 + Physical uint8 + Addrlen uint8 + Hdrlen uint8 + Recvquota uint8 + Xmitquota uint8 + Pad_cgo_0 [2]byte + Mtu uint64 + Metric uint64 + Link_state uint64 + Baudrate uint64 + Ipackets uint64 + Ierrors uint64 + Opackets uint64 + Oerrors uint64 + Collisions uint64 + Ibytes uint64 + Obytes uint64 + Imcasts uint64 + Omcasts uint64 + Iqdrops uint64 + Noproto uint64 + Hwassist uint64 + Unused uint64 + Lastchange Timeval +} + +type IfaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Metric int32 +} + +type IfmaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte +} + +type IfAnnounceMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Index uint16 + Name [16]int8 + What uint16 +} + +type RtMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Index uint16 + Pad_cgo_0 [2]byte + Flags int32 + Addrs int32 + Pid int32 + Seq int32 + Errno int32 + Use int32 + Inits uint64 + Rmx RtMetrics +} + +type RtMetrics struct { + Locks uint64 + Mtu uint64 + Pksent uint64 + Expire uint64 + Sendpipe uint64 + Ssthresh uint64 + Rtt uint64 + Rttvar uint64 + Recvpipe uint64 + Hopcount uint64 + Mssopt uint16 + Pad uint16 + Pad_cgo_0 [4]byte + Msl uint64 + Iwmaxsegs uint64 + Iwcapsegs uint64 +} + +const ( + SizeofBpfVersion = 0x4 + SizeofBpfStat = 0x8 + SizeofBpfProgram = 0x10 + SizeofBpfInsn = 0x8 + SizeofBpfHdr = 0x20 +) + +type BpfVersion struct { + Major uint16 + Minor uint16 +} + +type BpfStat struct { + Recv uint32 + Drop uint32 +} + +type BpfProgram struct { + Len uint32 + Pad_cgo_0 [4]byte + Insns *BpfInsn +} + +type BpfInsn struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type BpfHdr struct { + Tstamp Timeval + Caplen uint32 + Datalen uint32 + Hdrlen uint16 + Pad_cgo_0 [6]byte +} + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Cc [20]uint8 + Ispeed uint32 + Ospeed uint32 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go new file mode 100644 index 0000000000..8cf30947b4 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go @@ -0,0 +1,502 @@ +// +build 386,freebsd +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_freebsd.go + +package unix + +const ( + sizeofPtr = 0x4 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x4 + sizeofLongLong = 0x8 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int32 + _C_long_long int64 +) + +type Timespec struct { + Sec int32 + Nsec int32 +} + +type Timeval struct { + Sec int32 + Usec int32 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int32 + Ixrss int32 + Idrss int32 + Isrss int32 + Minflt int32 + Majflt int32 + Nswap int32 + Inblock int32 + Oublock int32 + Msgsnd int32 + Msgrcv int32 + Nsignals int32 + Nvcsw int32 + Nivcsw int32 +} + +type Rlimit struct { + Cur int64 + Max int64 +} + +type _Gid_t uint32 + +const ( + S_IFMT = 0xf000 + S_IFIFO = 0x1000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFBLK = 0x6000 + S_IFREG = 0x8000 + S_IFLNK = 0xa000 + S_IFSOCK = 0xc000 + S_ISUID = 0x800 + S_ISGID = 0x400 + S_ISVTX = 0x200 + S_IRUSR = 0x100 + S_IWUSR = 0x80 + S_IXUSR = 0x40 +) + +type Stat_t struct { + Dev uint32 + Ino uint32 + Mode uint16 + Nlink uint16 + Uid uint32 + Gid uint32 + Rdev uint32 + Atimespec Timespec + Mtimespec Timespec + Ctimespec Timespec + Size int64 + Blocks int64 + Blksize uint32 + Flags uint32 + Gen uint32 + Lspare int32 + Birthtimespec Timespec + Pad_cgo_0 [8]byte +} + +type Statfs_t struct { + Version uint32 + Type uint32 + Flags uint64 + Bsize uint64 + Iosize uint64 + Blocks uint64 + Bfree uint64 + Bavail int64 + Files uint64 + Ffree int64 + Syncwrites uint64 + Asyncwrites uint64 + Syncreads uint64 + Asyncreads uint64 + Spare [10]uint64 + Namemax uint32 + Owner uint32 + Fsid Fsid + Charspare [80]int8 + Fstypename [16]int8 + Mntfromname [88]int8 + Mntonname [88]int8 +} + +type Flock_t struct { + Start int64 + Len int64 + Pid int32 + Type int16 + Whence int16 + Sysid int32 +} + +type Dirent struct { + Fileno uint32 + Reclen uint16 + Type uint8 + Namlen uint8 + Name [256]int8 +} + +type Fsid struct { + Val [2]int32 +} + +const ( + FADV_NORMAL = 0x0 + FADV_RANDOM = 0x1 + FADV_SEQUENTIAL = 0x2 + FADV_WILLNEED = 0x3 + FADV_DONTNEED = 0x4 + FADV_NOREUSE = 0x5 +) + +type RawSockaddrInet4 struct { + Len uint8 + Family uint8 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]int8 +} + +type RawSockaddrInet6 struct { + Len uint8 + Family uint8 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Len uint8 + Family uint8 + Path [104]int8 +} + +type RawSockaddrDatalink struct { + Len uint8 + Family uint8 + Index uint16 + Type uint8 + Nlen uint8 + Alen uint8 + Slen uint8 + Data [46]int8 +} + +type RawSockaddr struct { + Len uint8 + Family uint8 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [92]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint32 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPMreqn struct { + Multiaddr [4]byte /* in_addr */ + Address [4]byte /* in_addr */ + Ifindex int32 +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Iov *Iovec + Iovlen int32 + Control *byte + Controllen uint32 + Flags int32 +} + +type Cmsghdr struct { + Len uint32 + Level int32 + Type int32 +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Filt [8]uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x6c + SizeofSockaddrUnix = 0x6a + SizeofSockaddrDatalink = 0x36 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPMreqn = 0xc + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x1c + SizeofCmsghdr = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 +) + +const ( + PTRACE_TRACEME = 0x0 + PTRACE_CONT = 0x7 + PTRACE_KILL = 0x8 +) + +type Kevent_t struct { + Ident uint32 + Filter int16 + Flags uint16 + Fflags uint32 + Data int32 + Udata *byte +} + +type FdSet struct { + X__fds_bits [32]uint32 +} + +const ( + sizeofIfMsghdr = 0x64 + SizeofIfMsghdr = 0x60 + sizeofIfData = 0x54 + SizeofIfData = 0x50 + SizeofIfaMsghdr = 0x14 + SizeofIfmaMsghdr = 0x10 + SizeofIfAnnounceMsghdr = 0x18 + SizeofRtMsghdr = 0x5c + SizeofRtMetrics = 0x38 +) + +type ifMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Data ifData +} + +type IfMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Data IfData +} + +type ifData struct { + Type uint8 + Physical uint8 + Addrlen uint8 + Hdrlen uint8 + Link_state uint8 + Vhid uint8 + Baudrate_pf uint8 + Datalen uint8 + Mtu uint32 + Metric uint32 + Baudrate uint32 + Ipackets uint32 + Ierrors uint32 + Opackets uint32 + Oerrors uint32 + Collisions uint32 + Ibytes uint32 + Obytes uint32 + Imcasts uint32 + Omcasts uint32 + Iqdrops uint32 + Noproto uint32 + Hwassist uint64 + Epoch int32 + Lastchange Timeval +} + +type IfData struct { + Type uint8 + Physical uint8 + Addrlen uint8 + Hdrlen uint8 + Link_state uint8 + Spare_char1 uint8 + Spare_char2 uint8 + Datalen uint8 + Mtu uint32 + Metric uint32 + Baudrate uint32 + Ipackets uint32 + Ierrors uint32 + Opackets uint32 + Oerrors uint32 + Collisions uint32 + Ibytes uint32 + Obytes uint32 + Imcasts uint32 + Omcasts uint32 + Iqdrops uint32 + Noproto uint32 + Hwassist uint32 + Epoch int32 + Lastchange Timeval +} + +type IfaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Metric int32 +} + +type IfmaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte +} + +type IfAnnounceMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Index uint16 + Name [16]int8 + What uint16 +} + +type RtMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Index uint16 + Pad_cgo_0 [2]byte + Flags int32 + Addrs int32 + Pid int32 + Seq int32 + Errno int32 + Fmask int32 + Inits uint32 + Rmx RtMetrics +} + +type RtMetrics struct { + Locks uint32 + Mtu uint32 + Hopcount uint32 + Expire uint32 + Recvpipe uint32 + Sendpipe uint32 + Ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Pksent uint32 + Weight uint32 + Filler [3]uint32 +} + +const ( + SizeofBpfVersion = 0x4 + SizeofBpfStat = 0x8 + SizeofBpfZbuf = 0xc + SizeofBpfProgram = 0x8 + SizeofBpfInsn = 0x8 + SizeofBpfHdr = 0x14 + SizeofBpfZbufHeader = 0x20 +) + +type BpfVersion struct { + Major uint16 + Minor uint16 +} + +type BpfStat struct { + Recv uint32 + Drop uint32 +} + +type BpfZbuf struct { + Bufa *byte + Bufb *byte + Buflen uint32 +} + +type BpfProgram struct { + Len uint32 + Insns *BpfInsn +} + +type BpfInsn struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type BpfHdr struct { + Tstamp Timeval + Caplen uint32 + Datalen uint32 + Hdrlen uint16 + Pad_cgo_0 [2]byte +} + +type BpfZbufHeader struct { + Kernel_gen uint32 + Kernel_len uint32 + User_gen uint32 + X_bzh_pad [5]uint32 +} + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Cc [20]uint8 + Ispeed uint32 + Ospeed uint32 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go new file mode 100644 index 0000000000..e5feb207be --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go @@ -0,0 +1,505 @@ +// +build amd64,freebsd +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_freebsd.go + +package unix + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int64 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur int64 + Max int64 +} + +type _Gid_t uint32 + +const ( + S_IFMT = 0xf000 + S_IFIFO = 0x1000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFBLK = 0x6000 + S_IFREG = 0x8000 + S_IFLNK = 0xa000 + S_IFSOCK = 0xc000 + S_ISUID = 0x800 + S_ISGID = 0x400 + S_ISVTX = 0x200 + S_IRUSR = 0x100 + S_IWUSR = 0x80 + S_IXUSR = 0x40 +) + +type Stat_t struct { + Dev uint32 + Ino uint32 + Mode uint16 + Nlink uint16 + Uid uint32 + Gid uint32 + Rdev uint32 + Atimespec Timespec + Mtimespec Timespec + Ctimespec Timespec + Size int64 + Blocks int64 + Blksize uint32 + Flags uint32 + Gen uint32 + Lspare int32 + Birthtimespec Timespec +} + +type Statfs_t struct { + Version uint32 + Type uint32 + Flags uint64 + Bsize uint64 + Iosize uint64 + Blocks uint64 + Bfree uint64 + Bavail int64 + Files uint64 + Ffree int64 + Syncwrites uint64 + Asyncwrites uint64 + Syncreads uint64 + Asyncreads uint64 + Spare [10]uint64 + Namemax uint32 + Owner uint32 + Fsid Fsid + Charspare [80]int8 + Fstypename [16]int8 + Mntfromname [88]int8 + Mntonname [88]int8 +} + +type Flock_t struct { + Start int64 + Len int64 + Pid int32 + Type int16 + Whence int16 + Sysid int32 + Pad_cgo_0 [4]byte +} + +type Dirent struct { + Fileno uint32 + Reclen uint16 + Type uint8 + Namlen uint8 + Name [256]int8 +} + +type Fsid struct { + Val [2]int32 +} + +const ( + FADV_NORMAL = 0x0 + FADV_RANDOM = 0x1 + FADV_SEQUENTIAL = 0x2 + FADV_WILLNEED = 0x3 + FADV_DONTNEED = 0x4 + FADV_NOREUSE = 0x5 +) + +type RawSockaddrInet4 struct { + Len uint8 + Family uint8 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]int8 +} + +type RawSockaddrInet6 struct { + Len uint8 + Family uint8 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Len uint8 + Family uint8 + Path [104]int8 +} + +type RawSockaddrDatalink struct { + Len uint8 + Family uint8 + Index uint16 + Type uint8 + Nlen uint8 + Alen uint8 + Slen uint8 + Data [46]int8 +} + +type RawSockaddr struct { + Len uint8 + Family uint8 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [92]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint64 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPMreqn struct { + Multiaddr [4]byte /* in_addr */ + Address [4]byte /* in_addr */ + Ifindex int32 +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Pad_cgo_0 [4]byte + Iov *Iovec + Iovlen int32 + Pad_cgo_1 [4]byte + Control *byte + Controllen uint32 + Flags int32 +} + +type Cmsghdr struct { + Len uint32 + Level int32 + Type int32 +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Filt [8]uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x6c + SizeofSockaddrUnix = 0x6a + SizeofSockaddrDatalink = 0x36 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPMreqn = 0xc + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x30 + SizeofCmsghdr = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 +) + +const ( + PTRACE_TRACEME = 0x0 + PTRACE_CONT = 0x7 + PTRACE_KILL = 0x8 +) + +type Kevent_t struct { + Ident uint64 + Filter int16 + Flags uint16 + Fflags uint32 + Data int64 + Udata *byte +} + +type FdSet struct { + X__fds_bits [16]uint64 +} + +const ( + sizeofIfMsghdr = 0xa8 + SizeofIfMsghdr = 0xa8 + sizeofIfData = 0x98 + SizeofIfData = 0x98 + SizeofIfaMsghdr = 0x14 + SizeofIfmaMsghdr = 0x10 + SizeofIfAnnounceMsghdr = 0x18 + SizeofRtMsghdr = 0x98 + SizeofRtMetrics = 0x70 +) + +type ifMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Data ifData +} + +type IfMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Data IfData +} + +type ifData struct { + Type uint8 + Physical uint8 + Addrlen uint8 + Hdrlen uint8 + Link_state uint8 + Vhid uint8 + Baudrate_pf uint8 + Datalen uint8 + Mtu uint64 + Metric uint64 + Baudrate uint64 + Ipackets uint64 + Ierrors uint64 + Opackets uint64 + Oerrors uint64 + Collisions uint64 + Ibytes uint64 + Obytes uint64 + Imcasts uint64 + Omcasts uint64 + Iqdrops uint64 + Noproto uint64 + Hwassist uint64 + Epoch int64 + Lastchange Timeval +} + +type IfData struct { + Type uint8 + Physical uint8 + Addrlen uint8 + Hdrlen uint8 + Link_state uint8 + Spare_char1 uint8 + Spare_char2 uint8 + Datalen uint8 + Mtu uint64 + Metric uint64 + Baudrate uint64 + Ipackets uint64 + Ierrors uint64 + Opackets uint64 + Oerrors uint64 + Collisions uint64 + Ibytes uint64 + Obytes uint64 + Imcasts uint64 + Omcasts uint64 + Iqdrops uint64 + Noproto uint64 + Hwassist uint64 + Epoch int64 + Lastchange Timeval +} + +type IfaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Metric int32 +} + +type IfmaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte +} + +type IfAnnounceMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Index uint16 + Name [16]int8 + What uint16 +} + +type RtMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Index uint16 + Pad_cgo_0 [2]byte + Flags int32 + Addrs int32 + Pid int32 + Seq int32 + Errno int32 + Fmask int32 + Inits uint64 + Rmx RtMetrics +} + +type RtMetrics struct { + Locks uint64 + Mtu uint64 + Hopcount uint64 + Expire uint64 + Recvpipe uint64 + Sendpipe uint64 + Ssthresh uint64 + Rtt uint64 + Rttvar uint64 + Pksent uint64 + Weight uint64 + Filler [3]uint64 +} + +const ( + SizeofBpfVersion = 0x4 + SizeofBpfStat = 0x8 + SizeofBpfZbuf = 0x18 + SizeofBpfProgram = 0x10 + SizeofBpfInsn = 0x8 + SizeofBpfHdr = 0x20 + SizeofBpfZbufHeader = 0x20 +) + +type BpfVersion struct { + Major uint16 + Minor uint16 +} + +type BpfStat struct { + Recv uint32 + Drop uint32 +} + +type BpfZbuf struct { + Bufa *byte + Bufb *byte + Buflen uint64 +} + +type BpfProgram struct { + Len uint32 + Pad_cgo_0 [4]byte + Insns *BpfInsn +} + +type BpfInsn struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type BpfHdr struct { + Tstamp Timeval + Caplen uint32 + Datalen uint32 + Hdrlen uint16 + Pad_cgo_0 [6]byte +} + +type BpfZbufHeader struct { + Kernel_gen uint32 + Kernel_len uint32 + User_gen uint32 + X_bzh_pad [5]uint32 +} + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Cc [20]uint8 + Ispeed uint32 + Ospeed uint32 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go new file mode 100644 index 0000000000..5472b54284 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go @@ -0,0 +1,497 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -fsigned-char types_freebsd.go + +// +build arm,freebsd + +package unix + +const ( + sizeofPtr = 0x4 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x4 + sizeofLongLong = 0x8 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int32 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int32 + Pad_cgo_0 [4]byte +} + +type Timeval struct { + Sec int64 + Usec int32 + Pad_cgo_0 [4]byte +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int32 + Ixrss int32 + Idrss int32 + Isrss int32 + Minflt int32 + Majflt int32 + Nswap int32 + Inblock int32 + Oublock int32 + Msgsnd int32 + Msgrcv int32 + Nsignals int32 + Nvcsw int32 + Nivcsw int32 +} + +type Rlimit struct { + Cur int64 + Max int64 +} + +type _Gid_t uint32 + +const ( + S_IFMT = 0xf000 + S_IFIFO = 0x1000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFBLK = 0x6000 + S_IFREG = 0x8000 + S_IFLNK = 0xa000 + S_IFSOCK = 0xc000 + S_ISUID = 0x800 + S_ISGID = 0x400 + S_ISVTX = 0x200 + S_IRUSR = 0x100 + S_IWUSR = 0x80 + S_IXUSR = 0x40 +) + +type Stat_t struct { + Dev uint32 + Ino uint32 + Mode uint16 + Nlink uint16 + Uid uint32 + Gid uint32 + Rdev uint32 + Atimespec Timespec + Mtimespec Timespec + Ctimespec Timespec + Size int64 + Blocks int64 + Blksize uint32 + Flags uint32 + Gen uint32 + Lspare int32 + Birthtimespec Timespec +} + +type Statfs_t struct { + Version uint32 + Type uint32 + Flags uint64 + Bsize uint64 + Iosize uint64 + Blocks uint64 + Bfree uint64 + Bavail int64 + Files uint64 + Ffree int64 + Syncwrites uint64 + Asyncwrites uint64 + Syncreads uint64 + Asyncreads uint64 + Spare [10]uint64 + Namemax uint32 + Owner uint32 + Fsid Fsid + Charspare [80]int8 + Fstypename [16]int8 + Mntfromname [88]int8 + Mntonname [88]int8 +} + +type Flock_t struct { + Start int64 + Len int64 + Pid int32 + Type int16 + Whence int16 + Sysid int32 + Pad_cgo_0 [4]byte +} + +type Dirent struct { + Fileno uint32 + Reclen uint16 + Type uint8 + Namlen uint8 + Name [256]int8 +} + +type Fsid struct { + Val [2]int32 +} + +type RawSockaddrInet4 struct { + Len uint8 + Family uint8 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]int8 +} + +type RawSockaddrInet6 struct { + Len uint8 + Family uint8 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Len uint8 + Family uint8 + Path [104]int8 +} + +type RawSockaddrDatalink struct { + Len uint8 + Family uint8 + Index uint16 + Type uint8 + Nlen uint8 + Alen uint8 + Slen uint8 + Data [46]int8 +} + +type RawSockaddr struct { + Len uint8 + Family uint8 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [92]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint32 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPMreqn struct { + Multiaddr [4]byte /* in_addr */ + Address [4]byte /* in_addr */ + Ifindex int32 +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Iov *Iovec + Iovlen int32 + Control *byte + Controllen uint32 + Flags int32 +} + +type Cmsghdr struct { + Len uint32 + Level int32 + Type int32 +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Filt [8]uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x6c + SizeofSockaddrUnix = 0x6a + SizeofSockaddrDatalink = 0x36 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPMreqn = 0xc + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x1c + SizeofCmsghdr = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 +) + +const ( + PTRACE_TRACEME = 0x0 + PTRACE_CONT = 0x7 + PTRACE_KILL = 0x8 +) + +type Kevent_t struct { + Ident uint32 + Filter int16 + Flags uint16 + Fflags uint32 + Data int32 + Udata *byte +} + +type FdSet struct { + X__fds_bits [32]uint32 +} + +const ( + sizeofIfMsghdr = 0x70 + SizeofIfMsghdr = 0x70 + sizeofIfData = 0x60 + SizeofIfData = 0x60 + SizeofIfaMsghdr = 0x14 + SizeofIfmaMsghdr = 0x10 + SizeofIfAnnounceMsghdr = 0x18 + SizeofRtMsghdr = 0x5c + SizeofRtMetrics = 0x38 +) + +type ifMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Data ifData +} + +type IfMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Data IfData +} + +type ifData struct { + Type uint8 + Physical uint8 + Addrlen uint8 + Hdrlen uint8 + Link_state uint8 + Vhid uint8 + Baudrate_pf uint8 + Datalen uint8 + Mtu uint32 + Metric uint32 + Baudrate uint32 + Ipackets uint32 + Ierrors uint32 + Opackets uint32 + Oerrors uint32 + Collisions uint32 + Ibytes uint32 + Obytes uint32 + Imcasts uint32 + Omcasts uint32 + Iqdrops uint32 + Noproto uint32 + Hwassist uint64 + Epoch int64 + Lastchange Timeval +} + +type IfData struct { + Type uint8 + Physical uint8 + Addrlen uint8 + Hdrlen uint8 + Link_state uint8 + Spare_char1 uint8 + Spare_char2 uint8 + Datalen uint8 + Mtu uint32 + Metric uint32 + Baudrate uint32 + Ipackets uint32 + Ierrors uint32 + Opackets uint32 + Oerrors uint32 + Collisions uint32 + Ibytes uint32 + Obytes uint32 + Imcasts uint32 + Omcasts uint32 + Iqdrops uint32 + Noproto uint32 + Hwassist uint32 + Pad_cgo_0 [4]byte + Epoch int64 + Lastchange Timeval +} + +type IfaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Metric int32 +} + +type IfmaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte +} + +type IfAnnounceMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Index uint16 + Name [16]int8 + What uint16 +} + +type RtMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Index uint16 + Pad_cgo_0 [2]byte + Flags int32 + Addrs int32 + Pid int32 + Seq int32 + Errno int32 + Fmask int32 + Inits uint32 + Rmx RtMetrics +} + +type RtMetrics struct { + Locks uint32 + Mtu uint32 + Hopcount uint32 + Expire uint32 + Recvpipe uint32 + Sendpipe uint32 + Ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Pksent uint32 + Weight uint32 + Filler [3]uint32 +} + +const ( + SizeofBpfVersion = 0x4 + SizeofBpfStat = 0x8 + SizeofBpfZbuf = 0xc + SizeofBpfProgram = 0x8 + SizeofBpfInsn = 0x8 + SizeofBpfHdr = 0x20 + SizeofBpfZbufHeader = 0x20 +) + +type BpfVersion struct { + Major uint16 + Minor uint16 +} + +type BpfStat struct { + Recv uint32 + Drop uint32 +} + +type BpfZbuf struct { + Bufa *byte + Bufb *byte + Buflen uint32 +} + +type BpfProgram struct { + Len uint32 + Insns *BpfInsn +} + +type BpfInsn struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type BpfHdr struct { + Tstamp Timeval + Caplen uint32 + Datalen uint32 + Hdrlen uint16 + Pad_cgo_0 [6]byte +} + +type BpfZbufHeader struct { + Kernel_gen uint32 + Kernel_len uint32 + User_gen uint32 + X_bzh_pad [5]uint32 +} + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Cc [20]uint8 + Ispeed uint32 + Ospeed uint32 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_386.go b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go new file mode 100644 index 0000000000..fb1257ae02 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go @@ -0,0 +1,607 @@ +// +build 386,linux +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_linux.go + +package unix + +const ( + sizeofPtr = 0x4 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x4 + sizeofLongLong = 0x8 + PathMax = 0x1000 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int32 + _C_long_long int64 +) + +type Timespec struct { + Sec int32 + Nsec int32 +} + +type Timeval struct { + Sec int32 + Usec int32 +} + +type Timex struct { + Modes uint32 + Offset int32 + Freq int32 + Maxerror int32 + Esterror int32 + Status int32 + Constant int32 + Precision int32 + Tolerance int32 + Time Timeval + Tick int32 + Ppsfreq int32 + Jitter int32 + Shift int32 + Stabil int32 + Jitcnt int32 + Calcnt int32 + Errcnt int32 + Stbcnt int32 + Tai int32 + Pad_cgo_0 [44]byte +} + +type Time_t int32 + +type Tms struct { + Utime int32 + Stime int32 + Cutime int32 + Cstime int32 +} + +type Utimbuf struct { + Actime int32 + Modtime int32 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int32 + Ixrss int32 + Idrss int32 + Isrss int32 + Minflt int32 + Majflt int32 + Nswap int32 + Inblock int32 + Oublock int32 + Msgsnd int32 + Msgrcv int32 + Nsignals int32 + Nvcsw int32 + Nivcsw int32 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +type Stat_t struct { + Dev uint64 + X__pad1 uint16 + Pad_cgo_0 [2]byte + X__st_ino uint32 + Mode uint32 + Nlink uint32 + Uid uint32 + Gid uint32 + Rdev uint64 + X__pad2 uint16 + Pad_cgo_1 [2]byte + Size int64 + Blksize int32 + Blocks int64 + Atim Timespec + Mtim Timespec + Ctim Timespec + Ino uint64 +} + +type Statfs_t struct { + Type int32 + Bsize int32 + Blocks uint64 + Bfree uint64 + Bavail uint64 + Files uint64 + Ffree uint64 + Fsid Fsid + Namelen int32 + Frsize int32 + Flags int32 + Spare [4]int32 +} + +type Dirent struct { + Ino uint64 + Off int64 + Reclen uint16 + Type uint8 + Name [256]int8 + Pad_cgo_0 [1]byte +} + +type Fsid struct { + X__val [2]int32 +} + +type Flock_t struct { + Type int16 + Whence int16 + Start int64 + Len int64 + Pid int32 +} + +const ( + FADV_NORMAL = 0x0 + FADV_RANDOM = 0x1 + FADV_SEQUENTIAL = 0x2 + FADV_WILLNEED = 0x3 + FADV_DONTNEED = 0x4 + FADV_NOREUSE = 0x5 +) + +type RawSockaddrInet4 struct { + Family uint16 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]uint8 +} + +type RawSockaddrInet6 struct { + Family uint16 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Family uint16 + Path [108]int8 +} + +type RawSockaddrLinklayer struct { + Family uint16 + Protocol uint16 + Ifindex int32 + Hatype uint16 + Pkttype uint8 + Halen uint8 + Addr [8]uint8 +} + +type RawSockaddrNetlink struct { + Family uint16 + Pad uint16 + Pid uint32 + Groups uint32 +} + +type RawSockaddrHCI struct { + Family uint16 + Dev uint16 + Channel uint16 +} + +type RawSockaddr struct { + Family uint16 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [96]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint32 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPMreqn struct { + Multiaddr [4]byte /* in_addr */ + Address [4]byte /* in_addr */ + Ifindex int32 +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Iov *Iovec + Iovlen uint32 + Control *byte + Controllen uint32 + Flags int32 +} + +type Cmsghdr struct { + Len uint32 + Level int32 + Type int32 + X__cmsg_data [0]uint8 +} + +type Inet4Pktinfo struct { + Ifindex int32 + Spec_dst [4]byte /* in_addr */ + Addr [4]byte /* in_addr */ +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Data [8]uint32 +} + +type Ucred struct { + Pid int32 + Uid uint32 + Gid uint32 +} + +type TCPInfo struct { + State uint8 + Ca_state uint8 + Retransmits uint8 + Probes uint8 + Backoff uint8 + Options uint8 + Pad_cgo_0 [2]byte + Rto uint32 + Ato uint32 + Snd_mss uint32 + Rcv_mss uint32 + Unacked uint32 + Sacked uint32 + Lost uint32 + Retrans uint32 + Fackets uint32 + Last_data_sent uint32 + Last_ack_sent uint32 + Last_data_recv uint32 + Last_ack_recv uint32 + Pmtu uint32 + Rcv_ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Snd_ssthresh uint32 + Snd_cwnd uint32 + Advmss uint32 + Reordering uint32 + Rcv_rtt uint32 + Rcv_space uint32 + Total_retrans uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x70 + SizeofSockaddrUnix = 0x6e + SizeofSockaddrLinklayer = 0x14 + SizeofSockaddrNetlink = 0xc + SizeofSockaddrHCI = 0x6 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPMreqn = 0xc + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x1c + SizeofCmsghdr = 0xc + SizeofInet4Pktinfo = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 + SizeofUcred = 0xc + SizeofTCPInfo = 0x68 +) + +const ( + IFA_UNSPEC = 0x0 + IFA_ADDRESS = 0x1 + IFA_LOCAL = 0x2 + IFA_LABEL = 0x3 + IFA_BROADCAST = 0x4 + IFA_ANYCAST = 0x5 + IFA_CACHEINFO = 0x6 + IFA_MULTICAST = 0x7 + IFLA_UNSPEC = 0x0 + IFLA_ADDRESS = 0x1 + IFLA_BROADCAST = 0x2 + IFLA_IFNAME = 0x3 + IFLA_MTU = 0x4 + IFLA_LINK = 0x5 + IFLA_QDISC = 0x6 + IFLA_STATS = 0x7 + IFLA_COST = 0x8 + IFLA_PRIORITY = 0x9 + IFLA_MASTER = 0xa + IFLA_WIRELESS = 0xb + IFLA_PROTINFO = 0xc + IFLA_TXQLEN = 0xd + IFLA_MAP = 0xe + IFLA_WEIGHT = 0xf + IFLA_OPERSTATE = 0x10 + IFLA_LINKMODE = 0x11 + IFLA_LINKINFO = 0x12 + IFLA_NET_NS_PID = 0x13 + IFLA_IFALIAS = 0x14 + IFLA_MAX = 0x1d + RT_SCOPE_UNIVERSE = 0x0 + RT_SCOPE_SITE = 0xc8 + RT_SCOPE_LINK = 0xfd + RT_SCOPE_HOST = 0xfe + RT_SCOPE_NOWHERE = 0xff + RT_TABLE_UNSPEC = 0x0 + RT_TABLE_COMPAT = 0xfc + RT_TABLE_DEFAULT = 0xfd + RT_TABLE_MAIN = 0xfe + RT_TABLE_LOCAL = 0xff + RT_TABLE_MAX = 0xffffffff + RTA_UNSPEC = 0x0 + RTA_DST = 0x1 + RTA_SRC = 0x2 + RTA_IIF = 0x3 + RTA_OIF = 0x4 + RTA_GATEWAY = 0x5 + RTA_PRIORITY = 0x6 + RTA_PREFSRC = 0x7 + RTA_METRICS = 0x8 + RTA_MULTIPATH = 0x9 + RTA_FLOW = 0xb + RTA_CACHEINFO = 0xc + RTA_TABLE = 0xf + RTN_UNSPEC = 0x0 + RTN_UNICAST = 0x1 + RTN_LOCAL = 0x2 + RTN_BROADCAST = 0x3 + RTN_ANYCAST = 0x4 + RTN_MULTICAST = 0x5 + RTN_BLACKHOLE = 0x6 + RTN_UNREACHABLE = 0x7 + RTN_PROHIBIT = 0x8 + RTN_THROW = 0x9 + RTN_NAT = 0xa + RTN_XRESOLVE = 0xb + RTNLGRP_NONE = 0x0 + RTNLGRP_LINK = 0x1 + RTNLGRP_NOTIFY = 0x2 + RTNLGRP_NEIGH = 0x3 + RTNLGRP_TC = 0x4 + RTNLGRP_IPV4_IFADDR = 0x5 + RTNLGRP_IPV4_MROUTE = 0x6 + RTNLGRP_IPV4_ROUTE = 0x7 + RTNLGRP_IPV4_RULE = 0x8 + RTNLGRP_IPV6_IFADDR = 0x9 + RTNLGRP_IPV6_MROUTE = 0xa + RTNLGRP_IPV6_ROUTE = 0xb + RTNLGRP_IPV6_IFINFO = 0xc + RTNLGRP_IPV6_PREFIX = 0x12 + RTNLGRP_IPV6_RULE = 0x13 + RTNLGRP_ND_USEROPT = 0x14 + SizeofNlMsghdr = 0x10 + SizeofNlMsgerr = 0x14 + SizeofRtGenmsg = 0x1 + SizeofNlAttr = 0x4 + SizeofRtAttr = 0x4 + SizeofIfInfomsg = 0x10 + SizeofIfAddrmsg = 0x8 + SizeofRtMsg = 0xc + SizeofRtNexthop = 0x8 +) + +type NlMsghdr struct { + Len uint32 + Type uint16 + Flags uint16 + Seq uint32 + Pid uint32 +} + +type NlMsgerr struct { + Error int32 + Msg NlMsghdr +} + +type RtGenmsg struct { + Family uint8 +} + +type NlAttr struct { + Len uint16 + Type uint16 +} + +type RtAttr struct { + Len uint16 + Type uint16 +} + +type IfInfomsg struct { + Family uint8 + X__ifi_pad uint8 + Type uint16 + Index int32 + Flags uint32 + Change uint32 +} + +type IfAddrmsg struct { + Family uint8 + Prefixlen uint8 + Flags uint8 + Scope uint8 + Index uint32 +} + +type RtMsg struct { + Family uint8 + Dst_len uint8 + Src_len uint8 + Tos uint8 + Table uint8 + Protocol uint8 + Scope uint8 + Type uint8 + Flags uint32 +} + +type RtNexthop struct { + Len uint16 + Flags uint8 + Hops uint8 + Ifindex int32 +} + +const ( + SizeofSockFilter = 0x8 + SizeofSockFprog = 0x8 +) + +type SockFilter struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type SockFprog struct { + Len uint16 + Pad_cgo_0 [2]byte + Filter *SockFilter +} + +type InotifyEvent struct { + Wd int32 + Mask uint32 + Cookie uint32 + Len uint32 + Name [0]int8 +} + +const SizeofInotifyEvent = 0x10 + +type PtraceRegs struct { + Ebx int32 + Ecx int32 + Edx int32 + Esi int32 + Edi int32 + Ebp int32 + Eax int32 + Xds int32 + Xes int32 + Xfs int32 + Xgs int32 + Orig_eax int32 + Eip int32 + Xcs int32 + Eflags int32 + Esp int32 + Xss int32 +} + +type FdSet struct { + Bits [32]int32 +} + +type Sysinfo_t struct { + Uptime int32 + Loads [3]uint32 + Totalram uint32 + Freeram uint32 + Sharedram uint32 + Bufferram uint32 + Totalswap uint32 + Freeswap uint32 + Procs uint16 + Pad uint16 + Totalhigh uint32 + Freehigh uint32 + Unit uint32 + X_f [8]int8 +} + +type Utsname struct { + Sysname [65]int8 + Nodename [65]int8 + Release [65]int8 + Version [65]int8 + Machine [65]int8 + Domainname [65]int8 +} + +type Ustat_t struct { + Tfree int32 + Tinode uint32 + Fname [6]int8 + Fpack [6]int8 +} + +type EpollEvent struct { + Events uint32 + Fd int32 + Pad int32 +} + +const ( + AT_FDCWD = -0x64 + AT_REMOVEDIR = 0x200 + AT_SYMLINK_FOLLOW = 0x400 + AT_SYMLINK_NOFOLLOW = 0x100 +) + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Line uint8 + Cc [19]uint8 + Ispeed uint32 + Ospeed uint32 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go new file mode 100644 index 0000000000..34edb3685f --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go @@ -0,0 +1,625 @@ +// +build amd64,linux +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_linux.go + +package unix + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 + PathMax = 0x1000 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int64 +} + +type Timex struct { + Modes uint32 + Pad_cgo_0 [4]byte + Offset int64 + Freq int64 + Maxerror int64 + Esterror int64 + Status int32 + Pad_cgo_1 [4]byte + Constant int64 + Precision int64 + Tolerance int64 + Time Timeval + Tick int64 + Ppsfreq int64 + Jitter int64 + Shift int32 + Pad_cgo_2 [4]byte + Stabil int64 + Jitcnt int64 + Calcnt int64 + Errcnt int64 + Stbcnt int64 + Tai int32 + Pad_cgo_3 [44]byte +} + +type Time_t int64 + +type Tms struct { + Utime int64 + Stime int64 + Cutime int64 + Cstime int64 +} + +type Utimbuf struct { + Actime int64 + Modtime int64 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +type Stat_t struct { + Dev uint64 + Ino uint64 + Nlink uint64 + Mode uint32 + Uid uint32 + Gid uint32 + X__pad0 int32 + Rdev uint64 + Size int64 + Blksize int64 + Blocks int64 + Atim Timespec + Mtim Timespec + Ctim Timespec + X__unused [3]int64 +} + +type Statfs_t struct { + Type int64 + Bsize int64 + Blocks uint64 + Bfree uint64 + Bavail uint64 + Files uint64 + Ffree uint64 + Fsid Fsid + Namelen int64 + Frsize int64 + Flags int64 + Spare [4]int64 +} + +type Dirent struct { + Ino uint64 + Off int64 + Reclen uint16 + Type uint8 + Name [256]int8 + Pad_cgo_0 [5]byte +} + +type Fsid struct { + X__val [2]int32 +} + +type Flock_t struct { + Type int16 + Whence int16 + Pad_cgo_0 [4]byte + Start int64 + Len int64 + Pid int32 + Pad_cgo_1 [4]byte +} + +const ( + FADV_NORMAL = 0x0 + FADV_RANDOM = 0x1 + FADV_SEQUENTIAL = 0x2 + FADV_WILLNEED = 0x3 + FADV_DONTNEED = 0x4 + FADV_NOREUSE = 0x5 +) + +type RawSockaddrInet4 struct { + Family uint16 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]uint8 +} + +type RawSockaddrInet6 struct { + Family uint16 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Family uint16 + Path [108]int8 +} + +type RawSockaddrLinklayer struct { + Family uint16 + Protocol uint16 + Ifindex int32 + Hatype uint16 + Pkttype uint8 + Halen uint8 + Addr [8]uint8 +} + +type RawSockaddrNetlink struct { + Family uint16 + Pad uint16 + Pid uint32 + Groups uint32 +} + +type RawSockaddrHCI struct { + Family uint16 + Dev uint16 + Channel uint16 +} + +type RawSockaddr struct { + Family uint16 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [96]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint64 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPMreqn struct { + Multiaddr [4]byte /* in_addr */ + Address [4]byte /* in_addr */ + Ifindex int32 +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Pad_cgo_0 [4]byte + Iov *Iovec + Iovlen uint64 + Control *byte + Controllen uint64 + Flags int32 + Pad_cgo_1 [4]byte +} + +type Cmsghdr struct { + Len uint64 + Level int32 + Type int32 + X__cmsg_data [0]uint8 +} + +type Inet4Pktinfo struct { + Ifindex int32 + Spec_dst [4]byte /* in_addr */ + Addr [4]byte /* in_addr */ +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Data [8]uint32 +} + +type Ucred struct { + Pid int32 + Uid uint32 + Gid uint32 +} + +type TCPInfo struct { + State uint8 + Ca_state uint8 + Retransmits uint8 + Probes uint8 + Backoff uint8 + Options uint8 + Pad_cgo_0 [2]byte + Rto uint32 + Ato uint32 + Snd_mss uint32 + Rcv_mss uint32 + Unacked uint32 + Sacked uint32 + Lost uint32 + Retrans uint32 + Fackets uint32 + Last_data_sent uint32 + Last_ack_sent uint32 + Last_data_recv uint32 + Last_ack_recv uint32 + Pmtu uint32 + Rcv_ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Snd_ssthresh uint32 + Snd_cwnd uint32 + Advmss uint32 + Reordering uint32 + Rcv_rtt uint32 + Rcv_space uint32 + Total_retrans uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x70 + SizeofSockaddrUnix = 0x6e + SizeofSockaddrLinklayer = 0x14 + SizeofSockaddrNetlink = 0xc + SizeofSockaddrHCI = 0x6 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPMreqn = 0xc + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x38 + SizeofCmsghdr = 0x10 + SizeofInet4Pktinfo = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 + SizeofUcred = 0xc + SizeofTCPInfo = 0x68 +) + +const ( + IFA_UNSPEC = 0x0 + IFA_ADDRESS = 0x1 + IFA_LOCAL = 0x2 + IFA_LABEL = 0x3 + IFA_BROADCAST = 0x4 + IFA_ANYCAST = 0x5 + IFA_CACHEINFO = 0x6 + IFA_MULTICAST = 0x7 + IFLA_UNSPEC = 0x0 + IFLA_ADDRESS = 0x1 + IFLA_BROADCAST = 0x2 + IFLA_IFNAME = 0x3 + IFLA_MTU = 0x4 + IFLA_LINK = 0x5 + IFLA_QDISC = 0x6 + IFLA_STATS = 0x7 + IFLA_COST = 0x8 + IFLA_PRIORITY = 0x9 + IFLA_MASTER = 0xa + IFLA_WIRELESS = 0xb + IFLA_PROTINFO = 0xc + IFLA_TXQLEN = 0xd + IFLA_MAP = 0xe + IFLA_WEIGHT = 0xf + IFLA_OPERSTATE = 0x10 + IFLA_LINKMODE = 0x11 + IFLA_LINKINFO = 0x12 + IFLA_NET_NS_PID = 0x13 + IFLA_IFALIAS = 0x14 + IFLA_MAX = 0x1d + RT_SCOPE_UNIVERSE = 0x0 + RT_SCOPE_SITE = 0xc8 + RT_SCOPE_LINK = 0xfd + RT_SCOPE_HOST = 0xfe + RT_SCOPE_NOWHERE = 0xff + RT_TABLE_UNSPEC = 0x0 + RT_TABLE_COMPAT = 0xfc + RT_TABLE_DEFAULT = 0xfd + RT_TABLE_MAIN = 0xfe + RT_TABLE_LOCAL = 0xff + RT_TABLE_MAX = 0xffffffff + RTA_UNSPEC = 0x0 + RTA_DST = 0x1 + RTA_SRC = 0x2 + RTA_IIF = 0x3 + RTA_OIF = 0x4 + RTA_GATEWAY = 0x5 + RTA_PRIORITY = 0x6 + RTA_PREFSRC = 0x7 + RTA_METRICS = 0x8 + RTA_MULTIPATH = 0x9 + RTA_FLOW = 0xb + RTA_CACHEINFO = 0xc + RTA_TABLE = 0xf + RTN_UNSPEC = 0x0 + RTN_UNICAST = 0x1 + RTN_LOCAL = 0x2 + RTN_BROADCAST = 0x3 + RTN_ANYCAST = 0x4 + RTN_MULTICAST = 0x5 + RTN_BLACKHOLE = 0x6 + RTN_UNREACHABLE = 0x7 + RTN_PROHIBIT = 0x8 + RTN_THROW = 0x9 + RTN_NAT = 0xa + RTN_XRESOLVE = 0xb + RTNLGRP_NONE = 0x0 + RTNLGRP_LINK = 0x1 + RTNLGRP_NOTIFY = 0x2 + RTNLGRP_NEIGH = 0x3 + RTNLGRP_TC = 0x4 + RTNLGRP_IPV4_IFADDR = 0x5 + RTNLGRP_IPV4_MROUTE = 0x6 + RTNLGRP_IPV4_ROUTE = 0x7 + RTNLGRP_IPV4_RULE = 0x8 + RTNLGRP_IPV6_IFADDR = 0x9 + RTNLGRP_IPV6_MROUTE = 0xa + RTNLGRP_IPV6_ROUTE = 0xb + RTNLGRP_IPV6_IFINFO = 0xc + RTNLGRP_IPV6_PREFIX = 0x12 + RTNLGRP_IPV6_RULE = 0x13 + RTNLGRP_ND_USEROPT = 0x14 + SizeofNlMsghdr = 0x10 + SizeofNlMsgerr = 0x14 + SizeofRtGenmsg = 0x1 + SizeofNlAttr = 0x4 + SizeofRtAttr = 0x4 + SizeofIfInfomsg = 0x10 + SizeofIfAddrmsg = 0x8 + SizeofRtMsg = 0xc + SizeofRtNexthop = 0x8 +) + +type NlMsghdr struct { + Len uint32 + Type uint16 + Flags uint16 + Seq uint32 + Pid uint32 +} + +type NlMsgerr struct { + Error int32 + Msg NlMsghdr +} + +type RtGenmsg struct { + Family uint8 +} + +type NlAttr struct { + Len uint16 + Type uint16 +} + +type RtAttr struct { + Len uint16 + Type uint16 +} + +type IfInfomsg struct { + Family uint8 + X__ifi_pad uint8 + Type uint16 + Index int32 + Flags uint32 + Change uint32 +} + +type IfAddrmsg struct { + Family uint8 + Prefixlen uint8 + Flags uint8 + Scope uint8 + Index uint32 +} + +type RtMsg struct { + Family uint8 + Dst_len uint8 + Src_len uint8 + Tos uint8 + Table uint8 + Protocol uint8 + Scope uint8 + Type uint8 + Flags uint32 +} + +type RtNexthop struct { + Len uint16 + Flags uint8 + Hops uint8 + Ifindex int32 +} + +const ( + SizeofSockFilter = 0x8 + SizeofSockFprog = 0x10 +) + +type SockFilter struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type SockFprog struct { + Len uint16 + Pad_cgo_0 [6]byte + Filter *SockFilter +} + +type InotifyEvent struct { + Wd int32 + Mask uint32 + Cookie uint32 + Len uint32 + Name [0]int8 +} + +const SizeofInotifyEvent = 0x10 + +type PtraceRegs struct { + R15 uint64 + R14 uint64 + R13 uint64 + R12 uint64 + Rbp uint64 + Rbx uint64 + R11 uint64 + R10 uint64 + R9 uint64 + R8 uint64 + Rax uint64 + Rcx uint64 + Rdx uint64 + Rsi uint64 + Rdi uint64 + Orig_rax uint64 + Rip uint64 + Cs uint64 + Eflags uint64 + Rsp uint64 + Ss uint64 + Fs_base uint64 + Gs_base uint64 + Ds uint64 + Es uint64 + Fs uint64 + Gs uint64 +} + +type FdSet struct { + Bits [16]int64 +} + +type Sysinfo_t struct { + Uptime int64 + Loads [3]uint64 + Totalram uint64 + Freeram uint64 + Sharedram uint64 + Bufferram uint64 + Totalswap uint64 + Freeswap uint64 + Procs uint16 + Pad uint16 + Pad_cgo_0 [4]byte + Totalhigh uint64 + Freehigh uint64 + Unit uint32 + X_f [0]int8 + Pad_cgo_1 [4]byte +} + +type Utsname struct { + Sysname [65]int8 + Nodename [65]int8 + Release [65]int8 + Version [65]int8 + Machine [65]int8 + Domainname [65]int8 +} + +type Ustat_t struct { + Tfree int32 + Pad_cgo_0 [4]byte + Tinode uint64 + Fname [6]int8 + Fpack [6]int8 + Pad_cgo_1 [4]byte +} + +type EpollEvent struct { + Events uint32 + Fd int32 + Pad int32 +} + +const ( + AT_FDCWD = -0x64 + AT_REMOVEDIR = 0x200 + AT_SYMLINK_FOLLOW = 0x400 + AT_SYMLINK_NOFOLLOW = 0x100 +) + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Line uint8 + Cc [19]uint8 + Ispeed uint32 + Ospeed uint32 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go new file mode 100644 index 0000000000..0fef350b14 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go @@ -0,0 +1,587 @@ +// +build arm,linux +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_linux.go + +package unix + +const ( + sizeofPtr = 0x4 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x4 + sizeofLongLong = 0x8 + PathMax = 0x1000 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int32 + _C_long_long int64 +) + +type Timespec struct { + Sec int32 + Nsec int32 +} + +type Timeval struct { + Sec int32 + Usec int32 +} + +type Timex struct { + Modes uint32 + Offset int32 + Freq int32 + Maxerror int32 + Esterror int32 + Status int32 + Constant int32 + Precision int32 + Tolerance int32 + Time Timeval + Tick int32 + Ppsfreq int32 + Jitter int32 + Shift int32 + Stabil int32 + Jitcnt int32 + Calcnt int32 + Errcnt int32 + Stbcnt int32 + Tai int32 + Pad_cgo_0 [44]byte +} + +type Time_t int32 + +type Tms struct { + Utime int32 + Stime int32 + Cutime int32 + Cstime int32 +} + +type Utimbuf struct { + Actime int32 + Modtime int32 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int32 + Ixrss int32 + Idrss int32 + Isrss int32 + Minflt int32 + Majflt int32 + Nswap int32 + Inblock int32 + Oublock int32 + Msgsnd int32 + Msgrcv int32 + Nsignals int32 + Nvcsw int32 + Nivcsw int32 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +type Stat_t struct { + Dev uint64 + X__pad1 uint16 + Pad_cgo_0 [2]byte + X__st_ino uint32 + Mode uint32 + Nlink uint32 + Uid uint32 + Gid uint32 + Rdev uint64 + X__pad2 uint16 + Pad_cgo_1 [6]byte + Size int64 + Blksize int32 + Pad_cgo_2 [4]byte + Blocks int64 + Atim Timespec + Mtim Timespec + Ctim Timespec + Ino uint64 +} + +type Statfs_t struct { + Type int32 + Bsize int32 + Blocks uint64 + Bfree uint64 + Bavail uint64 + Files uint64 + Ffree uint64 + Fsid Fsid + Namelen int32 + Frsize int32 + Flags int32 + Spare [4]int32 + Pad_cgo_0 [4]byte +} + +type Dirent struct { + Ino uint64 + Off int64 + Reclen uint16 + Type uint8 + Name [256]uint8 + Pad_cgo_0 [5]byte +} + +type Fsid struct { + X__val [2]int32 +} + +type Flock_t struct { + Type int16 + Whence int16 + Pad_cgo_0 [4]byte + Start int64 + Len int64 + Pid int32 + Pad_cgo_1 [4]byte +} + +type RawSockaddrInet4 struct { + Family uint16 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]uint8 +} + +type RawSockaddrInet6 struct { + Family uint16 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Family uint16 + Path [108]int8 +} + +type RawSockaddrLinklayer struct { + Family uint16 + Protocol uint16 + Ifindex int32 + Hatype uint16 + Pkttype uint8 + Halen uint8 + Addr [8]uint8 +} + +type RawSockaddrNetlink struct { + Family uint16 + Pad uint16 + Pid uint32 + Groups uint32 +} + +type RawSockaddrHCI struct { + Family uint16 + Dev uint16 + Channel uint16 +} + +type RawSockaddr struct { + Family uint16 + Data [14]uint8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [96]uint8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint32 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPMreqn struct { + Multiaddr [4]byte /* in_addr */ + Address [4]byte /* in_addr */ + Ifindex int32 +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Iov *Iovec + Iovlen uint32 + Control *byte + Controllen uint32 + Flags int32 +} + +type Cmsghdr struct { + Len uint32 + Level int32 + Type int32 + X__cmsg_data [0]uint8 +} + +type Inet4Pktinfo struct { + Ifindex int32 + Spec_dst [4]byte /* in_addr */ + Addr [4]byte /* in_addr */ +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Data [8]uint32 +} + +type Ucred struct { + Pid int32 + Uid uint32 + Gid uint32 +} + +type TCPInfo struct { + State uint8 + Ca_state uint8 + Retransmits uint8 + Probes uint8 + Backoff uint8 + Options uint8 + Pad_cgo_0 [2]byte + Rto uint32 + Ato uint32 + Snd_mss uint32 + Rcv_mss uint32 + Unacked uint32 + Sacked uint32 + Lost uint32 + Retrans uint32 + Fackets uint32 + Last_data_sent uint32 + Last_ack_sent uint32 + Last_data_recv uint32 + Last_ack_recv uint32 + Pmtu uint32 + Rcv_ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Snd_ssthresh uint32 + Snd_cwnd uint32 + Advmss uint32 + Reordering uint32 + Rcv_rtt uint32 + Rcv_space uint32 + Total_retrans uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x70 + SizeofSockaddrUnix = 0x6e + SizeofSockaddrLinklayer = 0x14 + SizeofSockaddrNetlink = 0xc + SizeofSockaddrHCI = 0x6 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPMreqn = 0xc + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x1c + SizeofCmsghdr = 0xc + SizeofInet4Pktinfo = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 + SizeofUcred = 0xc + SizeofTCPInfo = 0x68 +) + +const ( + IFA_UNSPEC = 0x0 + IFA_ADDRESS = 0x1 + IFA_LOCAL = 0x2 + IFA_LABEL = 0x3 + IFA_BROADCAST = 0x4 + IFA_ANYCAST = 0x5 + IFA_CACHEINFO = 0x6 + IFA_MULTICAST = 0x7 + IFLA_UNSPEC = 0x0 + IFLA_ADDRESS = 0x1 + IFLA_BROADCAST = 0x2 + IFLA_IFNAME = 0x3 + IFLA_MTU = 0x4 + IFLA_LINK = 0x5 + IFLA_QDISC = 0x6 + IFLA_STATS = 0x7 + IFLA_COST = 0x8 + IFLA_PRIORITY = 0x9 + IFLA_MASTER = 0xa + IFLA_WIRELESS = 0xb + IFLA_PROTINFO = 0xc + IFLA_TXQLEN = 0xd + IFLA_MAP = 0xe + IFLA_WEIGHT = 0xf + IFLA_OPERSTATE = 0x10 + IFLA_LINKMODE = 0x11 + IFLA_LINKINFO = 0x12 + IFLA_NET_NS_PID = 0x13 + IFLA_IFALIAS = 0x14 + IFLA_MAX = 0x1d + RT_SCOPE_UNIVERSE = 0x0 + RT_SCOPE_SITE = 0xc8 + RT_SCOPE_LINK = 0xfd + RT_SCOPE_HOST = 0xfe + RT_SCOPE_NOWHERE = 0xff + RT_TABLE_UNSPEC = 0x0 + RT_TABLE_COMPAT = 0xfc + RT_TABLE_DEFAULT = 0xfd + RT_TABLE_MAIN = 0xfe + RT_TABLE_LOCAL = 0xff + RT_TABLE_MAX = 0xffffffff + RTA_UNSPEC = 0x0 + RTA_DST = 0x1 + RTA_SRC = 0x2 + RTA_IIF = 0x3 + RTA_OIF = 0x4 + RTA_GATEWAY = 0x5 + RTA_PRIORITY = 0x6 + RTA_PREFSRC = 0x7 + RTA_METRICS = 0x8 + RTA_MULTIPATH = 0x9 + RTA_FLOW = 0xb + RTA_CACHEINFO = 0xc + RTA_TABLE = 0xf + RTN_UNSPEC = 0x0 + RTN_UNICAST = 0x1 + RTN_LOCAL = 0x2 + RTN_BROADCAST = 0x3 + RTN_ANYCAST = 0x4 + RTN_MULTICAST = 0x5 + RTN_BLACKHOLE = 0x6 + RTN_UNREACHABLE = 0x7 + RTN_PROHIBIT = 0x8 + RTN_THROW = 0x9 + RTN_NAT = 0xa + RTN_XRESOLVE = 0xb + RTNLGRP_NONE = 0x0 + RTNLGRP_LINK = 0x1 + RTNLGRP_NOTIFY = 0x2 + RTNLGRP_NEIGH = 0x3 + RTNLGRP_TC = 0x4 + RTNLGRP_IPV4_IFADDR = 0x5 + RTNLGRP_IPV4_MROUTE = 0x6 + RTNLGRP_IPV4_ROUTE = 0x7 + RTNLGRP_IPV4_RULE = 0x8 + RTNLGRP_IPV6_IFADDR = 0x9 + RTNLGRP_IPV6_MROUTE = 0xa + RTNLGRP_IPV6_ROUTE = 0xb + RTNLGRP_IPV6_IFINFO = 0xc + RTNLGRP_IPV6_PREFIX = 0x12 + RTNLGRP_IPV6_RULE = 0x13 + RTNLGRP_ND_USEROPT = 0x14 + SizeofNlMsghdr = 0x10 + SizeofNlMsgerr = 0x14 + SizeofRtGenmsg = 0x1 + SizeofNlAttr = 0x4 + SizeofRtAttr = 0x4 + SizeofIfInfomsg = 0x10 + SizeofIfAddrmsg = 0x8 + SizeofRtMsg = 0xc + SizeofRtNexthop = 0x8 +) + +type NlMsghdr struct { + Len uint32 + Type uint16 + Flags uint16 + Seq uint32 + Pid uint32 +} + +type NlMsgerr struct { + Error int32 + Msg NlMsghdr +} + +type RtGenmsg struct { + Family uint8 +} + +type NlAttr struct { + Len uint16 + Type uint16 +} + +type RtAttr struct { + Len uint16 + Type uint16 +} + +type IfInfomsg struct { + Family uint8 + X__ifi_pad uint8 + Type uint16 + Index int32 + Flags uint32 + Change uint32 +} + +type IfAddrmsg struct { + Family uint8 + Prefixlen uint8 + Flags uint8 + Scope uint8 + Index uint32 +} + +type RtMsg struct { + Family uint8 + Dst_len uint8 + Src_len uint8 + Tos uint8 + Table uint8 + Protocol uint8 + Scope uint8 + Type uint8 + Flags uint32 +} + +type RtNexthop struct { + Len uint16 + Flags uint8 + Hops uint8 + Ifindex int32 +} + +const ( + SizeofSockFilter = 0x8 + SizeofSockFprog = 0x8 +) + +type SockFilter struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type SockFprog struct { + Len uint16 + Pad_cgo_0 [2]byte + Filter *SockFilter +} + +type InotifyEvent struct { + Wd int32 + Mask uint32 + Cookie uint32 + Len uint32 + Name [0]uint8 +} + +const SizeofInotifyEvent = 0x10 + +type PtraceRegs struct { + Uregs [18]uint32 +} + +type FdSet struct { + Bits [32]int32 +} + +type Sysinfo_t struct { + Uptime int32 + Loads [3]uint32 + Totalram uint32 + Freeram uint32 + Sharedram uint32 + Bufferram uint32 + Totalswap uint32 + Freeswap uint32 + Procs uint16 + Pad uint16 + Totalhigh uint32 + Freehigh uint32 + Unit uint32 + X_f [8]uint8 +} + +type Utsname struct { + Sysname [65]uint8 + Nodename [65]uint8 + Release [65]uint8 + Version [65]uint8 + Machine [65]uint8 + Domainname [65]uint8 +} + +type Ustat_t struct { + Tfree int32 + Tinode uint32 + Fname [6]uint8 + Fpack [6]uint8 +} + +type EpollEvent struct { + Events uint32 + PadFd int32 + Fd int32 + Pad int32 +} + +const ( + AT_FDCWD = -0x64 + AT_REMOVEDIR = 0x200 + AT_SYMLINK_FOLLOW = 0x400 + AT_SYMLINK_NOFOLLOW = 0x100 +) + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Line uint8 + Cc [19]uint8 + Ispeed uint32 + Ospeed uint32 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go new file mode 100644 index 0000000000..28b7cd43ce --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go @@ -0,0 +1,604 @@ +// +build arm64,linux +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -fsigned-char types_linux.go + +package unix + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 + PathMax = 0x1000 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int64 +} + +type Timex struct { + Modes uint32 + Pad_cgo_0 [4]byte + Offset int64 + Freq int64 + Maxerror int64 + Esterror int64 + Status int32 + Pad_cgo_1 [4]byte + Constant int64 + Precision int64 + Tolerance int64 + Time Timeval + Tick int64 + Ppsfreq int64 + Jitter int64 + Shift int32 + Pad_cgo_2 [4]byte + Stabil int64 + Jitcnt int64 + Calcnt int64 + Errcnt int64 + Stbcnt int64 + Tai int32 + Pad_cgo_3 [44]byte +} + +type Time_t int64 + +type Tms struct { + Utime int64 + Stime int64 + Cutime int64 + Cstime int64 +} + +type Utimbuf struct { + Actime int64 + Modtime int64 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +type Stat_t struct { + Dev uint64 + Ino uint64 + Mode uint32 + Nlink uint32 + Uid uint32 + Gid uint32 + Rdev uint64 + X__pad1 uint64 + Size int64 + Blksize int32 + X__pad2 int32 + Blocks int64 + Atim Timespec + Mtim Timespec + Ctim Timespec + X__glibc_reserved [2]int32 +} + +type Statfs_t struct { + Type int64 + Bsize int64 + Blocks uint64 + Bfree uint64 + Bavail uint64 + Files uint64 + Ffree uint64 + Fsid Fsid + Namelen int64 + Frsize int64 + Flags int64 + Spare [4]int64 +} + +type Dirent struct { + Ino uint64 + Off int64 + Reclen uint16 + Type uint8 + Name [256]int8 + Pad_cgo_0 [5]byte +} + +type Fsid struct { + X__val [2]int32 +} + +type Flock_t struct { + Type int16 + Whence int16 + Pad_cgo_0 [4]byte + Start int64 + Len int64 + Pid int32 + Pad_cgo_1 [4]byte +} + +const ( + FADV_NORMAL = 0x0 + FADV_RANDOM = 0x1 + FADV_SEQUENTIAL = 0x2 + FADV_WILLNEED = 0x3 + FADV_DONTNEED = 0x4 + FADV_NOREUSE = 0x5 +) + +type RawSockaddrInet4 struct { + Family uint16 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]uint8 +} + +type RawSockaddrInet6 struct { + Family uint16 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Family uint16 + Path [108]int8 +} + +type RawSockaddrLinklayer struct { + Family uint16 + Protocol uint16 + Ifindex int32 + Hatype uint16 + Pkttype uint8 + Halen uint8 + Addr [8]uint8 +} + +type RawSockaddrNetlink struct { + Family uint16 + Pad uint16 + Pid uint32 + Groups uint32 +} + +type RawSockaddrHCI struct { + Family uint16 + Dev uint16 + Channel uint16 +} + +type RawSockaddr struct { + Family uint16 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [96]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint64 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPMreqn struct { + Multiaddr [4]byte /* in_addr */ + Address [4]byte /* in_addr */ + Ifindex int32 +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Pad_cgo_0 [4]byte + Iov *Iovec + Iovlen uint64 + Control *byte + Controllen uint64 + Flags int32 + Pad_cgo_1 [4]byte +} + +type Cmsghdr struct { + Len uint64 + Level int32 + Type int32 + X__cmsg_data [0]uint8 +} + +type Inet4Pktinfo struct { + Ifindex int32 + Spec_dst [4]byte /* in_addr */ + Addr [4]byte /* in_addr */ +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Data [8]uint32 +} + +type Ucred struct { + Pid int32 + Uid uint32 + Gid uint32 +} + +type TCPInfo struct { + State uint8 + Ca_state uint8 + Retransmits uint8 + Probes uint8 + Backoff uint8 + Options uint8 + Pad_cgo_0 [2]byte + Rto uint32 + Ato uint32 + Snd_mss uint32 + Rcv_mss uint32 + Unacked uint32 + Sacked uint32 + Lost uint32 + Retrans uint32 + Fackets uint32 + Last_data_sent uint32 + Last_ack_sent uint32 + Last_data_recv uint32 + Last_ack_recv uint32 + Pmtu uint32 + Rcv_ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Snd_ssthresh uint32 + Snd_cwnd uint32 + Advmss uint32 + Reordering uint32 + Rcv_rtt uint32 + Rcv_space uint32 + Total_retrans uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x70 + SizeofSockaddrUnix = 0x6e + SizeofSockaddrLinklayer = 0x14 + SizeofSockaddrNetlink = 0xc + SizeofSockaddrHCI = 0x6 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPMreqn = 0xc + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x38 + SizeofCmsghdr = 0x10 + SizeofInet4Pktinfo = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 + SizeofUcred = 0xc + SizeofTCPInfo = 0x68 +) + +const ( + IFA_UNSPEC = 0x0 + IFA_ADDRESS = 0x1 + IFA_LOCAL = 0x2 + IFA_LABEL = 0x3 + IFA_BROADCAST = 0x4 + IFA_ANYCAST = 0x5 + IFA_CACHEINFO = 0x6 + IFA_MULTICAST = 0x7 + IFLA_UNSPEC = 0x0 + IFLA_ADDRESS = 0x1 + IFLA_BROADCAST = 0x2 + IFLA_IFNAME = 0x3 + IFLA_MTU = 0x4 + IFLA_LINK = 0x5 + IFLA_QDISC = 0x6 + IFLA_STATS = 0x7 + IFLA_COST = 0x8 + IFLA_PRIORITY = 0x9 + IFLA_MASTER = 0xa + IFLA_WIRELESS = 0xb + IFLA_PROTINFO = 0xc + IFLA_TXQLEN = 0xd + IFLA_MAP = 0xe + IFLA_WEIGHT = 0xf + IFLA_OPERSTATE = 0x10 + IFLA_LINKMODE = 0x11 + IFLA_LINKINFO = 0x12 + IFLA_NET_NS_PID = 0x13 + IFLA_IFALIAS = 0x14 + IFLA_MAX = 0x22 + RT_SCOPE_UNIVERSE = 0x0 + RT_SCOPE_SITE = 0xc8 + RT_SCOPE_LINK = 0xfd + RT_SCOPE_HOST = 0xfe + RT_SCOPE_NOWHERE = 0xff + RT_TABLE_UNSPEC = 0x0 + RT_TABLE_COMPAT = 0xfc + RT_TABLE_DEFAULT = 0xfd + RT_TABLE_MAIN = 0xfe + RT_TABLE_LOCAL = 0xff + RT_TABLE_MAX = 0xffffffff + RTA_UNSPEC = 0x0 + RTA_DST = 0x1 + RTA_SRC = 0x2 + RTA_IIF = 0x3 + RTA_OIF = 0x4 + RTA_GATEWAY = 0x5 + RTA_PRIORITY = 0x6 + RTA_PREFSRC = 0x7 + RTA_METRICS = 0x8 + RTA_MULTIPATH = 0x9 + RTA_FLOW = 0xb + RTA_CACHEINFO = 0xc + RTA_TABLE = 0xf + RTN_UNSPEC = 0x0 + RTN_UNICAST = 0x1 + RTN_LOCAL = 0x2 + RTN_BROADCAST = 0x3 + RTN_ANYCAST = 0x4 + RTN_MULTICAST = 0x5 + RTN_BLACKHOLE = 0x6 + RTN_UNREACHABLE = 0x7 + RTN_PROHIBIT = 0x8 + RTN_THROW = 0x9 + RTN_NAT = 0xa + RTN_XRESOLVE = 0xb + RTNLGRP_NONE = 0x0 + RTNLGRP_LINK = 0x1 + RTNLGRP_NOTIFY = 0x2 + RTNLGRP_NEIGH = 0x3 + RTNLGRP_TC = 0x4 + RTNLGRP_IPV4_IFADDR = 0x5 + RTNLGRP_IPV4_MROUTE = 0x6 + RTNLGRP_IPV4_ROUTE = 0x7 + RTNLGRP_IPV4_RULE = 0x8 + RTNLGRP_IPV6_IFADDR = 0x9 + RTNLGRP_IPV6_MROUTE = 0xa + RTNLGRP_IPV6_ROUTE = 0xb + RTNLGRP_IPV6_IFINFO = 0xc + RTNLGRP_IPV6_PREFIX = 0x12 + RTNLGRP_IPV6_RULE = 0x13 + RTNLGRP_ND_USEROPT = 0x14 + SizeofNlMsghdr = 0x10 + SizeofNlMsgerr = 0x14 + SizeofRtGenmsg = 0x1 + SizeofNlAttr = 0x4 + SizeofRtAttr = 0x4 + SizeofIfInfomsg = 0x10 + SizeofIfAddrmsg = 0x8 + SizeofRtMsg = 0xc + SizeofRtNexthop = 0x8 +) + +type NlMsghdr struct { + Len uint32 + Type uint16 + Flags uint16 + Seq uint32 + Pid uint32 +} + +type NlMsgerr struct { + Error int32 + Msg NlMsghdr +} + +type RtGenmsg struct { + Family uint8 +} + +type NlAttr struct { + Len uint16 + Type uint16 +} + +type RtAttr struct { + Len uint16 + Type uint16 +} + +type IfInfomsg struct { + Family uint8 + X__ifi_pad uint8 + Type uint16 + Index int32 + Flags uint32 + Change uint32 +} + +type IfAddrmsg struct { + Family uint8 + Prefixlen uint8 + Flags uint8 + Scope uint8 + Index uint32 +} + +type RtMsg struct { + Family uint8 + Dst_len uint8 + Src_len uint8 + Tos uint8 + Table uint8 + Protocol uint8 + Scope uint8 + Type uint8 + Flags uint32 +} + +type RtNexthop struct { + Len uint16 + Flags uint8 + Hops uint8 + Ifindex int32 +} + +const ( + SizeofSockFilter = 0x8 + SizeofSockFprog = 0x10 +) + +type SockFilter struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type SockFprog struct { + Len uint16 + Pad_cgo_0 [6]byte + Filter *SockFilter +} + +type InotifyEvent struct { + Wd int32 + Mask uint32 + Cookie uint32 + Len uint32 + Name [0]int8 +} + +const SizeofInotifyEvent = 0x10 + +type PtraceRegs struct { + Regs [31]uint64 + Sp uint64 + Pc uint64 + Pstate uint64 +} + +type FdSet struct { + Bits [16]int64 +} + +type Sysinfo_t struct { + Uptime int64 + Loads [3]uint64 + Totalram uint64 + Freeram uint64 + Sharedram uint64 + Bufferram uint64 + Totalswap uint64 + Freeswap uint64 + Procs uint16 + Pad uint16 + Pad_cgo_0 [4]byte + Totalhigh uint64 + Freehigh uint64 + Unit uint32 + X_f [0]int8 + Pad_cgo_1 [4]byte +} + +type Utsname struct { + Sysname [65]int8 + Nodename [65]int8 + Release [65]int8 + Version [65]int8 + Machine [65]int8 + Domainname [65]int8 +} + +type Ustat_t struct { + Tfree int32 + Pad_cgo_0 [4]byte + Tinode uint64 + Fname [6]int8 + Fpack [6]int8 + Pad_cgo_1 [4]byte +} + +type EpollEvent struct { + Events uint32 + PadFd int32 + Fd int32 + Pad int32 +} + +const ( + AT_FDCWD = -0x64 + AT_REMOVEDIR = 0x200 + AT_SYMLINK_FOLLOW = 0x400 + AT_SYMLINK_NOFOLLOW = 0x100 +) + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Line uint8 + Cc [19]uint8 + Ispeed uint32 + Ospeed uint32 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go new file mode 100644 index 0000000000..8fe5af2628 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go @@ -0,0 +1,607 @@ +// +build mips64,linux +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_linux.go + +package unix + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 + PathMax = 0x1000 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int64 +} + +type Timex struct { + Modes uint32 + Pad_cgo_0 [4]byte + Offset int64 + Freq int64 + Maxerror int64 + Esterror int64 + Status int32 + Pad_cgo_1 [4]byte + Constant int64 + Precision int64 + Tolerance int64 + Time Timeval + Tick int64 + Ppsfreq int64 + Jitter int64 + Shift int32 + Pad_cgo_2 [4]byte + Stabil int64 + Jitcnt int64 + Calcnt int64 + Errcnt int64 + Stbcnt int64 + Tai int32 + Pad_cgo_3 [44]byte +} + +type Time_t int64 + +type Tms struct { + Utime int64 + Stime int64 + Cutime int64 + Cstime int64 +} + +type Utimbuf struct { + Actime int64 + Modtime int64 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +type Stat_t struct { + Dev uint32 + Pad1 [3]int32 + Ino uint64 + Mode uint32 + Nlink uint32 + Uid uint32 + Gid uint32 + Rdev uint32 + Pad2 [3]uint32 + Size int64 + Atim Timespec + Mtim Timespec + Ctim Timespec + Blksize uint32 + Pad4 uint32 + Blocks int64 +} + +type Statfs_t struct { + Type int64 + Bsize int64 + Frsize int64 + Blocks uint64 + Bfree uint64 + Files uint64 + Ffree uint64 + Bavail uint64 + Fsid Fsid + Namelen int64 + Flags int64 + Spare [5]int64 +} + +type Dirent struct { + Ino uint64 + Off int64 + Reclen uint16 + Type uint8 + Name [256]int8 + Pad_cgo_0 [5]byte +} + +type Fsid struct { + X__val [2]int32 +} + +type Flock_t struct { + Type int16 + Whence int16 + Pad_cgo_0 [4]byte + Start int64 + Len int64 + Pid int32 + Pad_cgo_1 [4]byte +} + +const ( + FADV_NORMAL = 0x0 + FADV_RANDOM = 0x1 + FADV_SEQUENTIAL = 0x2 + FADV_WILLNEED = 0x3 + FADV_DONTNEED = 0x4 + FADV_NOREUSE = 0x5 +) + +type RawSockaddrInet4 struct { + Family uint16 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]uint8 +} + +type RawSockaddrInet6 struct { + Family uint16 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Family uint16 + Path [108]int8 +} + +type RawSockaddrLinklayer struct { + Family uint16 + Protocol uint16 + Ifindex int32 + Hatype uint16 + Pkttype uint8 + Halen uint8 + Addr [8]uint8 +} + +type RawSockaddrNetlink struct { + Family uint16 + Pad uint16 + Pid uint32 + Groups uint32 +} + +type RawSockaddrHCI struct { + Family uint16 + Dev uint16 + Channel uint16 +} + +type RawSockaddr struct { + Family uint16 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [96]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint64 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPMreqn struct { + Multiaddr [4]byte /* in_addr */ + Address [4]byte /* in_addr */ + Ifindex int32 +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Pad_cgo_0 [4]byte + Iov *Iovec + Iovlen uint64 + Control *byte + Controllen uint64 + Flags int32 + Pad_cgo_1 [4]byte +} + +type Cmsghdr struct { + Len uint64 + Level int32 + Type int32 +} + +type Inet4Pktinfo struct { + Ifindex int32 + Spec_dst [4]byte /* in_addr */ + Addr [4]byte /* in_addr */ +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Data [8]uint32 +} + +type Ucred struct { + Pid int32 + Uid uint32 + Gid uint32 +} + +type TCPInfo struct { + State uint8 + Ca_state uint8 + Retransmits uint8 + Probes uint8 + Backoff uint8 + Options uint8 + Pad_cgo_0 [2]byte + Rto uint32 + Ato uint32 + Snd_mss uint32 + Rcv_mss uint32 + Unacked uint32 + Sacked uint32 + Lost uint32 + Retrans uint32 + Fackets uint32 + Last_data_sent uint32 + Last_ack_sent uint32 + Last_data_recv uint32 + Last_ack_recv uint32 + Pmtu uint32 + Rcv_ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Snd_ssthresh uint32 + Snd_cwnd uint32 + Advmss uint32 + Reordering uint32 + Rcv_rtt uint32 + Rcv_space uint32 + Total_retrans uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x70 + SizeofSockaddrUnix = 0x6e + SizeofSockaddrLinklayer = 0x14 + SizeofSockaddrNetlink = 0xc + SizeofSockaddrHCI = 0x6 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPMreqn = 0xc + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x38 + SizeofCmsghdr = 0x10 + SizeofInet4Pktinfo = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 + SizeofUcred = 0xc + SizeofTCPInfo = 0x68 +) + +const ( + IFA_UNSPEC = 0x0 + IFA_ADDRESS = 0x1 + IFA_LOCAL = 0x2 + IFA_LABEL = 0x3 + IFA_BROADCAST = 0x4 + IFA_ANYCAST = 0x5 + IFA_CACHEINFO = 0x6 + IFA_MULTICAST = 0x7 + IFLA_UNSPEC = 0x0 + IFLA_ADDRESS = 0x1 + IFLA_BROADCAST = 0x2 + IFLA_IFNAME = 0x3 + IFLA_MTU = 0x4 + IFLA_LINK = 0x5 + IFLA_QDISC = 0x6 + IFLA_STATS = 0x7 + IFLA_COST = 0x8 + IFLA_PRIORITY = 0x9 + IFLA_MASTER = 0xa + IFLA_WIRELESS = 0xb + IFLA_PROTINFO = 0xc + IFLA_TXQLEN = 0xd + IFLA_MAP = 0xe + IFLA_WEIGHT = 0xf + IFLA_OPERSTATE = 0x10 + IFLA_LINKMODE = 0x11 + IFLA_LINKINFO = 0x12 + IFLA_NET_NS_PID = 0x13 + IFLA_IFALIAS = 0x14 + IFLA_MAX = 0x27 + RT_SCOPE_UNIVERSE = 0x0 + RT_SCOPE_SITE = 0xc8 + RT_SCOPE_LINK = 0xfd + RT_SCOPE_HOST = 0xfe + RT_SCOPE_NOWHERE = 0xff + RT_TABLE_UNSPEC = 0x0 + RT_TABLE_COMPAT = 0xfc + RT_TABLE_DEFAULT = 0xfd + RT_TABLE_MAIN = 0xfe + RT_TABLE_LOCAL = 0xff + RT_TABLE_MAX = 0xffffffff + RTA_UNSPEC = 0x0 + RTA_DST = 0x1 + RTA_SRC = 0x2 + RTA_IIF = 0x3 + RTA_OIF = 0x4 + RTA_GATEWAY = 0x5 + RTA_PRIORITY = 0x6 + RTA_PREFSRC = 0x7 + RTA_METRICS = 0x8 + RTA_MULTIPATH = 0x9 + RTA_FLOW = 0xb + RTA_CACHEINFO = 0xc + RTA_TABLE = 0xf + RTN_UNSPEC = 0x0 + RTN_UNICAST = 0x1 + RTN_LOCAL = 0x2 + RTN_BROADCAST = 0x3 + RTN_ANYCAST = 0x4 + RTN_MULTICAST = 0x5 + RTN_BLACKHOLE = 0x6 + RTN_UNREACHABLE = 0x7 + RTN_PROHIBIT = 0x8 + RTN_THROW = 0x9 + RTN_NAT = 0xa + RTN_XRESOLVE = 0xb + RTNLGRP_NONE = 0x0 + RTNLGRP_LINK = 0x1 + RTNLGRP_NOTIFY = 0x2 + RTNLGRP_NEIGH = 0x3 + RTNLGRP_TC = 0x4 + RTNLGRP_IPV4_IFADDR = 0x5 + RTNLGRP_IPV4_MROUTE = 0x6 + RTNLGRP_IPV4_ROUTE = 0x7 + RTNLGRP_IPV4_RULE = 0x8 + RTNLGRP_IPV6_IFADDR = 0x9 + RTNLGRP_IPV6_MROUTE = 0xa + RTNLGRP_IPV6_ROUTE = 0xb + RTNLGRP_IPV6_IFINFO = 0xc + RTNLGRP_IPV6_PREFIX = 0x12 + RTNLGRP_IPV6_RULE = 0x13 + RTNLGRP_ND_USEROPT = 0x14 + SizeofNlMsghdr = 0x10 + SizeofNlMsgerr = 0x14 + SizeofRtGenmsg = 0x1 + SizeofNlAttr = 0x4 + SizeofRtAttr = 0x4 + SizeofIfInfomsg = 0x10 + SizeofIfAddrmsg = 0x8 + SizeofRtMsg = 0xc + SizeofRtNexthop = 0x8 +) + +type NlMsghdr struct { + Len uint32 + Type uint16 + Flags uint16 + Seq uint32 + Pid uint32 +} + +type NlMsgerr struct { + Error int32 + Msg NlMsghdr +} + +type RtGenmsg struct { + Family uint8 +} + +type NlAttr struct { + Len uint16 + Type uint16 +} + +type RtAttr struct { + Len uint16 + Type uint16 +} + +type IfInfomsg struct { + Family uint8 + X__ifi_pad uint8 + Type uint16 + Index int32 + Flags uint32 + Change uint32 +} + +type IfAddrmsg struct { + Family uint8 + Prefixlen uint8 + Flags uint8 + Scope uint8 + Index uint32 +} + +type RtMsg struct { + Family uint8 + Dst_len uint8 + Src_len uint8 + Tos uint8 + Table uint8 + Protocol uint8 + Scope uint8 + Type uint8 + Flags uint32 +} + +type RtNexthop struct { + Len uint16 + Flags uint8 + Hops uint8 + Ifindex int32 +} + +const ( + SizeofSockFilter = 0x8 + SizeofSockFprog = 0x10 +) + +type SockFilter struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type SockFprog struct { + Len uint16 + Pad_cgo_0 [6]byte + Filter *SockFilter +} + +type InotifyEvent struct { + Wd int32 + Mask uint32 + Cookie uint32 + Len uint32 +} + +const SizeofInotifyEvent = 0x10 + +type PtraceRegs struct { + Regs [102]uint64 + U_tsize uint64 + U_dsize uint64 + U_ssize uint64 + Start_code uint64 + Start_data uint64 + Start_stack uint64 + Signal int64 + U_ar0 uint64 + Magic uint64 + U_comm [32]int8 +} + +type FdSet struct { + Bits [16]int64 +} + +type Sysinfo_t struct { + Uptime int64 + Loads [3]uint64 + Totalram uint64 + Freeram uint64 + Sharedram uint64 + Bufferram uint64 + Totalswap uint64 + Freeswap uint64 + Procs uint16 + Pad uint16 + Pad_cgo_0 [4]byte + Totalhigh uint64 + Freehigh uint64 + Unit uint32 + X_f [0]int8 + Pad_cgo_1 [4]byte +} + +type Utsname struct { + Sysname [65]int8 + Nodename [65]int8 + Release [65]int8 + Version [65]int8 + Machine [65]int8 + Domainname [65]int8 +} + +type Ustat_t struct { + Tfree int32 + Pad_cgo_0 [4]byte + Tinode uint64 + Fname [6]int8 + Fpack [6]int8 + Pad_cgo_1 [4]byte +} + +type EpollEvent struct { + Events uint32 + Fd int32 + Pad int32 +} + +const ( + AT_FDCWD = -0x64 + AT_REMOVEDIR = 0x200 + AT_SYMLINK_FOLLOW = 0x400 + AT_SYMLINK_NOFOLLOW = 0x100 +) + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Line uint8 + Cc [32]uint8 + Pad_cgo_0 [3]byte +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go new file mode 100644 index 0000000000..df16e83c5b --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go @@ -0,0 +1,607 @@ +// +build mips64le,linux +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_linux.go + +package unix + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 + PathMax = 0x1000 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int64 +} + +type Timex struct { + Modes uint32 + Pad_cgo_0 [4]byte + Offset int64 + Freq int64 + Maxerror int64 + Esterror int64 + Status int32 + Pad_cgo_1 [4]byte + Constant int64 + Precision int64 + Tolerance int64 + Time Timeval + Tick int64 + Ppsfreq int64 + Jitter int64 + Shift int32 + Pad_cgo_2 [4]byte + Stabil int64 + Jitcnt int64 + Calcnt int64 + Errcnt int64 + Stbcnt int64 + Tai int32 + Pad_cgo_3 [44]byte +} + +type Time_t int64 + +type Tms struct { + Utime int64 + Stime int64 + Cutime int64 + Cstime int64 +} + +type Utimbuf struct { + Actime int64 + Modtime int64 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +type Stat_t struct { + Dev uint32 + Pad1 [3]int32 + Ino uint64 + Mode uint32 + Nlink uint32 + Uid uint32 + Gid uint32 + Rdev uint32 + Pad2 [3]uint32 + Size int64 + Atim Timespec + Mtim Timespec + Ctim Timespec + Blksize uint32 + Pad4 uint32 + Blocks int64 +} + +type Statfs_t struct { + Type int64 + Bsize int64 + Frsize int64 + Blocks uint64 + Bfree uint64 + Files uint64 + Ffree uint64 + Bavail uint64 + Fsid Fsid + Namelen int64 + Flags int64 + Spare [5]int64 +} + +type Dirent struct { + Ino uint64 + Off int64 + Reclen uint16 + Type uint8 + Name [256]int8 + Pad_cgo_0 [5]byte +} + +type Fsid struct { + X__val [2]int32 +} + +type Flock_t struct { + Type int16 + Whence int16 + Pad_cgo_0 [4]byte + Start int64 + Len int64 + Pid int32 + Pad_cgo_1 [4]byte +} + +const ( + FADV_NORMAL = 0x0 + FADV_RANDOM = 0x1 + FADV_SEQUENTIAL = 0x2 + FADV_WILLNEED = 0x3 + FADV_DONTNEED = 0x4 + FADV_NOREUSE = 0x5 +) + +type RawSockaddrInet4 struct { + Family uint16 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]uint8 +} + +type RawSockaddrInet6 struct { + Family uint16 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Family uint16 + Path [108]int8 +} + +type RawSockaddrLinklayer struct { + Family uint16 + Protocol uint16 + Ifindex int32 + Hatype uint16 + Pkttype uint8 + Halen uint8 + Addr [8]uint8 +} + +type RawSockaddrNetlink struct { + Family uint16 + Pad uint16 + Pid uint32 + Groups uint32 +} + +type RawSockaddrHCI struct { + Family uint16 + Dev uint16 + Channel uint16 +} + +type RawSockaddr struct { + Family uint16 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [96]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint64 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPMreqn struct { + Multiaddr [4]byte /* in_addr */ + Address [4]byte /* in_addr */ + Ifindex int32 +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Pad_cgo_0 [4]byte + Iov *Iovec + Iovlen uint64 + Control *byte + Controllen uint64 + Flags int32 + Pad_cgo_1 [4]byte +} + +type Cmsghdr struct { + Len uint64 + Level int32 + Type int32 +} + +type Inet4Pktinfo struct { + Ifindex int32 + Spec_dst [4]byte /* in_addr */ + Addr [4]byte /* in_addr */ +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Data [8]uint32 +} + +type Ucred struct { + Pid int32 + Uid uint32 + Gid uint32 +} + +type TCPInfo struct { + State uint8 + Ca_state uint8 + Retransmits uint8 + Probes uint8 + Backoff uint8 + Options uint8 + Pad_cgo_0 [2]byte + Rto uint32 + Ato uint32 + Snd_mss uint32 + Rcv_mss uint32 + Unacked uint32 + Sacked uint32 + Lost uint32 + Retrans uint32 + Fackets uint32 + Last_data_sent uint32 + Last_ack_sent uint32 + Last_data_recv uint32 + Last_ack_recv uint32 + Pmtu uint32 + Rcv_ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Snd_ssthresh uint32 + Snd_cwnd uint32 + Advmss uint32 + Reordering uint32 + Rcv_rtt uint32 + Rcv_space uint32 + Total_retrans uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x70 + SizeofSockaddrUnix = 0x6e + SizeofSockaddrLinklayer = 0x14 + SizeofSockaddrNetlink = 0xc + SizeofSockaddrHCI = 0x6 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPMreqn = 0xc + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x38 + SizeofCmsghdr = 0x10 + SizeofInet4Pktinfo = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 + SizeofUcred = 0xc + SizeofTCPInfo = 0x68 +) + +const ( + IFA_UNSPEC = 0x0 + IFA_ADDRESS = 0x1 + IFA_LOCAL = 0x2 + IFA_LABEL = 0x3 + IFA_BROADCAST = 0x4 + IFA_ANYCAST = 0x5 + IFA_CACHEINFO = 0x6 + IFA_MULTICAST = 0x7 + IFLA_UNSPEC = 0x0 + IFLA_ADDRESS = 0x1 + IFLA_BROADCAST = 0x2 + IFLA_IFNAME = 0x3 + IFLA_MTU = 0x4 + IFLA_LINK = 0x5 + IFLA_QDISC = 0x6 + IFLA_STATS = 0x7 + IFLA_COST = 0x8 + IFLA_PRIORITY = 0x9 + IFLA_MASTER = 0xa + IFLA_WIRELESS = 0xb + IFLA_PROTINFO = 0xc + IFLA_TXQLEN = 0xd + IFLA_MAP = 0xe + IFLA_WEIGHT = 0xf + IFLA_OPERSTATE = 0x10 + IFLA_LINKMODE = 0x11 + IFLA_LINKINFO = 0x12 + IFLA_NET_NS_PID = 0x13 + IFLA_IFALIAS = 0x14 + IFLA_MAX = 0x27 + RT_SCOPE_UNIVERSE = 0x0 + RT_SCOPE_SITE = 0xc8 + RT_SCOPE_LINK = 0xfd + RT_SCOPE_HOST = 0xfe + RT_SCOPE_NOWHERE = 0xff + RT_TABLE_UNSPEC = 0x0 + RT_TABLE_COMPAT = 0xfc + RT_TABLE_DEFAULT = 0xfd + RT_TABLE_MAIN = 0xfe + RT_TABLE_LOCAL = 0xff + RT_TABLE_MAX = 0xffffffff + RTA_UNSPEC = 0x0 + RTA_DST = 0x1 + RTA_SRC = 0x2 + RTA_IIF = 0x3 + RTA_OIF = 0x4 + RTA_GATEWAY = 0x5 + RTA_PRIORITY = 0x6 + RTA_PREFSRC = 0x7 + RTA_METRICS = 0x8 + RTA_MULTIPATH = 0x9 + RTA_FLOW = 0xb + RTA_CACHEINFO = 0xc + RTA_TABLE = 0xf + RTN_UNSPEC = 0x0 + RTN_UNICAST = 0x1 + RTN_LOCAL = 0x2 + RTN_BROADCAST = 0x3 + RTN_ANYCAST = 0x4 + RTN_MULTICAST = 0x5 + RTN_BLACKHOLE = 0x6 + RTN_UNREACHABLE = 0x7 + RTN_PROHIBIT = 0x8 + RTN_THROW = 0x9 + RTN_NAT = 0xa + RTN_XRESOLVE = 0xb + RTNLGRP_NONE = 0x0 + RTNLGRP_LINK = 0x1 + RTNLGRP_NOTIFY = 0x2 + RTNLGRP_NEIGH = 0x3 + RTNLGRP_TC = 0x4 + RTNLGRP_IPV4_IFADDR = 0x5 + RTNLGRP_IPV4_MROUTE = 0x6 + RTNLGRP_IPV4_ROUTE = 0x7 + RTNLGRP_IPV4_RULE = 0x8 + RTNLGRP_IPV6_IFADDR = 0x9 + RTNLGRP_IPV6_MROUTE = 0xa + RTNLGRP_IPV6_ROUTE = 0xb + RTNLGRP_IPV6_IFINFO = 0xc + RTNLGRP_IPV6_PREFIX = 0x12 + RTNLGRP_IPV6_RULE = 0x13 + RTNLGRP_ND_USEROPT = 0x14 + SizeofNlMsghdr = 0x10 + SizeofNlMsgerr = 0x14 + SizeofRtGenmsg = 0x1 + SizeofNlAttr = 0x4 + SizeofRtAttr = 0x4 + SizeofIfInfomsg = 0x10 + SizeofIfAddrmsg = 0x8 + SizeofRtMsg = 0xc + SizeofRtNexthop = 0x8 +) + +type NlMsghdr struct { + Len uint32 + Type uint16 + Flags uint16 + Seq uint32 + Pid uint32 +} + +type NlMsgerr struct { + Error int32 + Msg NlMsghdr +} + +type RtGenmsg struct { + Family uint8 +} + +type NlAttr struct { + Len uint16 + Type uint16 +} + +type RtAttr struct { + Len uint16 + Type uint16 +} + +type IfInfomsg struct { + Family uint8 + X__ifi_pad uint8 + Type uint16 + Index int32 + Flags uint32 + Change uint32 +} + +type IfAddrmsg struct { + Family uint8 + Prefixlen uint8 + Flags uint8 + Scope uint8 + Index uint32 +} + +type RtMsg struct { + Family uint8 + Dst_len uint8 + Src_len uint8 + Tos uint8 + Table uint8 + Protocol uint8 + Scope uint8 + Type uint8 + Flags uint32 +} + +type RtNexthop struct { + Len uint16 + Flags uint8 + Hops uint8 + Ifindex int32 +} + +const ( + SizeofSockFilter = 0x8 + SizeofSockFprog = 0x10 +) + +type SockFilter struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type SockFprog struct { + Len uint16 + Pad_cgo_0 [6]byte + Filter *SockFilter +} + +type InotifyEvent struct { + Wd int32 + Mask uint32 + Cookie uint32 + Len uint32 +} + +const SizeofInotifyEvent = 0x10 + +type PtraceRegs struct { + Regs [102]uint64 + U_tsize uint64 + U_dsize uint64 + U_ssize uint64 + Start_code uint64 + Start_data uint64 + Start_stack uint64 + Signal int64 + U_ar0 uint64 + Magic uint64 + U_comm [32]int8 +} + +type FdSet struct { + Bits [16]int64 +} + +type Sysinfo_t struct { + Uptime int64 + Loads [3]uint64 + Totalram uint64 + Freeram uint64 + Sharedram uint64 + Bufferram uint64 + Totalswap uint64 + Freeswap uint64 + Procs uint16 + Pad uint16 + Pad_cgo_0 [4]byte + Totalhigh uint64 + Freehigh uint64 + Unit uint32 + X_f [0]int8 + Pad_cgo_1 [4]byte +} + +type Utsname struct { + Sysname [65]int8 + Nodename [65]int8 + Release [65]int8 + Version [65]int8 + Machine [65]int8 + Domainname [65]int8 +} + +type Ustat_t struct { + Tfree int32 + Pad_cgo_0 [4]byte + Tinode uint64 + Fname [6]int8 + Fpack [6]int8 + Pad_cgo_1 [4]byte +} + +type EpollEvent struct { + Events uint32 + Fd int32 + Pad int32 +} + +const ( + AT_FDCWD = -0x64 + AT_REMOVEDIR = 0x200 + AT_SYMLINK_FOLLOW = 0x400 + AT_SYMLINK_NOFOLLOW = 0x100 +) + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Line uint8 + Cc [32]uint8 + Pad_cgo_0 [3]byte +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go new file mode 100644 index 0000000000..d1105402ec --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go @@ -0,0 +1,614 @@ +// +build ppc64,linux +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_linux.go + +package unix + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 + PathMax = 0x1000 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int64 +} + +type Timex struct { + Modes uint32 + Pad_cgo_0 [4]byte + Offset int64 + Freq int64 + Maxerror int64 + Esterror int64 + Status int32 + Pad_cgo_1 [4]byte + Constant int64 + Precision int64 + Tolerance int64 + Time Timeval + Tick int64 + Ppsfreq int64 + Jitter int64 + Shift int32 + Pad_cgo_2 [4]byte + Stabil int64 + Jitcnt int64 + Calcnt int64 + Errcnt int64 + Stbcnt int64 + Tai int32 + Pad_cgo_3 [44]byte +} + +type Time_t int64 + +type Tms struct { + Utime int64 + Stime int64 + Cutime int64 + Cstime int64 +} + +type Utimbuf struct { + Actime int64 + Modtime int64 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +type Stat_t struct { + Dev uint64 + Ino uint64 + Nlink uint64 + Mode uint32 + Uid uint32 + Gid uint32 + X__pad2 int32 + Rdev uint64 + Size int64 + Blksize int64 + Blocks int64 + Atim Timespec + Mtim Timespec + Ctim Timespec + X__glibc_reserved4 uint64 + X__glibc_reserved5 uint64 + X__glibc_reserved6 uint64 +} + +type Statfs_t struct { + Type int64 + Bsize int64 + Blocks uint64 + Bfree uint64 + Bavail uint64 + Files uint64 + Ffree uint64 + Fsid Fsid + Namelen int64 + Frsize int64 + Flags int64 + Spare [4]int64 +} + +type Dirent struct { + Ino uint64 + Off int64 + Reclen uint16 + Type uint8 + Name [256]uint8 + Pad_cgo_0 [5]byte +} + +type Fsid struct { + X__val [2]int32 +} + +type Flock_t struct { + Type int16 + Whence int16 + Pad_cgo_0 [4]byte + Start int64 + Len int64 + Pid int32 + Pad_cgo_1 [4]byte +} + +const ( + FADV_NORMAL = 0x0 + FADV_RANDOM = 0x1 + FADV_SEQUENTIAL = 0x2 + FADV_WILLNEED = 0x3 + FADV_DONTNEED = 0x4 + FADV_NOREUSE = 0x5 +) + +type RawSockaddrInet4 struct { + Family uint16 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]uint8 +} + +type RawSockaddrInet6 struct { + Family uint16 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Family uint16 + Path [108]int8 +} + +type RawSockaddrLinklayer struct { + Family uint16 + Protocol uint16 + Ifindex int32 + Hatype uint16 + Pkttype uint8 + Halen uint8 + Addr [8]uint8 +} + +type RawSockaddrNetlink struct { + Family uint16 + Pad uint16 + Pid uint32 + Groups uint32 +} + +type RawSockaddrHCI struct { + Family uint16 + Dev uint16 + Channel uint16 +} + +type RawSockaddr struct { + Family uint16 + Data [14]uint8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [96]uint8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint64 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPMreqn struct { + Multiaddr [4]byte /* in_addr */ + Address [4]byte /* in_addr */ + Ifindex int32 +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Pad_cgo_0 [4]byte + Iov *Iovec + Iovlen uint64 + Control *byte + Controllen uint64 + Flags int32 + Pad_cgo_1 [4]byte +} + +type Cmsghdr struct { + Len uint64 + Level int32 + Type int32 + X__cmsg_data [0]uint8 +} + +type Inet4Pktinfo struct { + Ifindex int32 + Spec_dst [4]byte /* in_addr */ + Addr [4]byte /* in_addr */ +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Data [8]uint32 +} + +type Ucred struct { + Pid int32 + Uid uint32 + Gid uint32 +} + +type TCPInfo struct { + State uint8 + Ca_state uint8 + Retransmits uint8 + Probes uint8 + Backoff uint8 + Options uint8 + Pad_cgo_0 [2]byte + Rto uint32 + Ato uint32 + Snd_mss uint32 + Rcv_mss uint32 + Unacked uint32 + Sacked uint32 + Lost uint32 + Retrans uint32 + Fackets uint32 + Last_data_sent uint32 + Last_ack_sent uint32 + Last_data_recv uint32 + Last_ack_recv uint32 + Pmtu uint32 + Rcv_ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Snd_ssthresh uint32 + Snd_cwnd uint32 + Advmss uint32 + Reordering uint32 + Rcv_rtt uint32 + Rcv_space uint32 + Total_retrans uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x70 + SizeofSockaddrUnix = 0x6e + SizeofSockaddrLinklayer = 0x14 + SizeofSockaddrNetlink = 0xc + SizeofSockaddrHCI = 0x6 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPMreqn = 0xc + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x38 + SizeofCmsghdr = 0x10 + SizeofInet4Pktinfo = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 + SizeofUcred = 0xc + SizeofTCPInfo = 0x68 +) + +const ( + IFA_UNSPEC = 0x0 + IFA_ADDRESS = 0x1 + IFA_LOCAL = 0x2 + IFA_LABEL = 0x3 + IFA_BROADCAST = 0x4 + IFA_ANYCAST = 0x5 + IFA_CACHEINFO = 0x6 + IFA_MULTICAST = 0x7 + IFLA_UNSPEC = 0x0 + IFLA_ADDRESS = 0x1 + IFLA_BROADCAST = 0x2 + IFLA_IFNAME = 0x3 + IFLA_MTU = 0x4 + IFLA_LINK = 0x5 + IFLA_QDISC = 0x6 + IFLA_STATS = 0x7 + IFLA_COST = 0x8 + IFLA_PRIORITY = 0x9 + IFLA_MASTER = 0xa + IFLA_WIRELESS = 0xb + IFLA_PROTINFO = 0xc + IFLA_TXQLEN = 0xd + IFLA_MAP = 0xe + IFLA_WEIGHT = 0xf + IFLA_OPERSTATE = 0x10 + IFLA_LINKMODE = 0x11 + IFLA_LINKINFO = 0x12 + IFLA_NET_NS_PID = 0x13 + IFLA_IFALIAS = 0x14 + IFLA_MAX = 0x23 + RT_SCOPE_UNIVERSE = 0x0 + RT_SCOPE_SITE = 0xc8 + RT_SCOPE_LINK = 0xfd + RT_SCOPE_HOST = 0xfe + RT_SCOPE_NOWHERE = 0xff + RT_TABLE_UNSPEC = 0x0 + RT_TABLE_COMPAT = 0xfc + RT_TABLE_DEFAULT = 0xfd + RT_TABLE_MAIN = 0xfe + RT_TABLE_LOCAL = 0xff + RT_TABLE_MAX = 0xffffffff + RTA_UNSPEC = 0x0 + RTA_DST = 0x1 + RTA_SRC = 0x2 + RTA_IIF = 0x3 + RTA_OIF = 0x4 + RTA_GATEWAY = 0x5 + RTA_PRIORITY = 0x6 + RTA_PREFSRC = 0x7 + RTA_METRICS = 0x8 + RTA_MULTIPATH = 0x9 + RTA_FLOW = 0xb + RTA_CACHEINFO = 0xc + RTA_TABLE = 0xf + RTN_UNSPEC = 0x0 + RTN_UNICAST = 0x1 + RTN_LOCAL = 0x2 + RTN_BROADCAST = 0x3 + RTN_ANYCAST = 0x4 + RTN_MULTICAST = 0x5 + RTN_BLACKHOLE = 0x6 + RTN_UNREACHABLE = 0x7 + RTN_PROHIBIT = 0x8 + RTN_THROW = 0x9 + RTN_NAT = 0xa + RTN_XRESOLVE = 0xb + RTNLGRP_NONE = 0x0 + RTNLGRP_LINK = 0x1 + RTNLGRP_NOTIFY = 0x2 + RTNLGRP_NEIGH = 0x3 + RTNLGRP_TC = 0x4 + RTNLGRP_IPV4_IFADDR = 0x5 + RTNLGRP_IPV4_MROUTE = 0x6 + RTNLGRP_IPV4_ROUTE = 0x7 + RTNLGRP_IPV4_RULE = 0x8 + RTNLGRP_IPV6_IFADDR = 0x9 + RTNLGRP_IPV6_MROUTE = 0xa + RTNLGRP_IPV6_ROUTE = 0xb + RTNLGRP_IPV6_IFINFO = 0xc + RTNLGRP_IPV6_PREFIX = 0x12 + RTNLGRP_IPV6_RULE = 0x13 + RTNLGRP_ND_USEROPT = 0x14 + SizeofNlMsghdr = 0x10 + SizeofNlMsgerr = 0x14 + SizeofRtGenmsg = 0x1 + SizeofNlAttr = 0x4 + SizeofRtAttr = 0x4 + SizeofIfInfomsg = 0x10 + SizeofIfAddrmsg = 0x8 + SizeofRtMsg = 0xc + SizeofRtNexthop = 0x8 +) + +type NlMsghdr struct { + Len uint32 + Type uint16 + Flags uint16 + Seq uint32 + Pid uint32 +} + +type NlMsgerr struct { + Error int32 + Msg NlMsghdr +} + +type RtGenmsg struct { + Family uint8 +} + +type NlAttr struct { + Len uint16 + Type uint16 +} + +type RtAttr struct { + Len uint16 + Type uint16 +} + +type IfInfomsg struct { + Family uint8 + X__ifi_pad uint8 + Type uint16 + Index int32 + Flags uint32 + Change uint32 +} + +type IfAddrmsg struct { + Family uint8 + Prefixlen uint8 + Flags uint8 + Scope uint8 + Index uint32 +} + +type RtMsg struct { + Family uint8 + Dst_len uint8 + Src_len uint8 + Tos uint8 + Table uint8 + Protocol uint8 + Scope uint8 + Type uint8 + Flags uint32 +} + +type RtNexthop struct { + Len uint16 + Flags uint8 + Hops uint8 + Ifindex int32 +} + +const ( + SizeofSockFilter = 0x8 + SizeofSockFprog = 0x10 +) + +type SockFilter struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type SockFprog struct { + Len uint16 + Pad_cgo_0 [6]byte + Filter *SockFilter +} + +type InotifyEvent struct { + Wd int32 + Mask uint32 + Cookie uint32 + Len uint32 + Name [0]uint8 +} + +const SizeofInotifyEvent = 0x10 + +type PtraceRegs struct { + Gpr [32]uint64 + Nip uint64 + Msr uint64 + Orig_gpr3 uint64 + Ctr uint64 + Link uint64 + Xer uint64 + Ccr uint64 + Softe uint64 + Trap uint64 + Dar uint64 + Dsisr uint64 + Result uint64 +} + +type FdSet struct { + Bits [16]int64 +} + +type Sysinfo_t struct { + Uptime int64 + Loads [3]uint64 + Totalram uint64 + Freeram uint64 + Sharedram uint64 + Bufferram uint64 + Totalswap uint64 + Freeswap uint64 + Procs uint16 + Pad uint16 + Pad_cgo_0 [4]byte + Totalhigh uint64 + Freehigh uint64 + Unit uint32 + X_f [0]uint8 + Pad_cgo_1 [4]byte +} + +type Utsname struct { + Sysname [65]uint8 + Nodename [65]uint8 + Release [65]uint8 + Version [65]uint8 + Machine [65]uint8 + Domainname [65]uint8 +} + +type Ustat_t struct { + Tfree int32 + Pad_cgo_0 [4]byte + Tinode uint64 + Fname [6]uint8 + Fpack [6]uint8 + Pad_cgo_1 [4]byte +} + +type EpollEvent struct { + Events uint32 + X_padFd int32 + Fd int32 + Pad int32 +} + +const ( + AT_FDCWD = -0x64 + AT_REMOVEDIR = 0x200 + AT_SYMLINK_FOLLOW = 0x400 + AT_SYMLINK_NOFOLLOW = 0x100 +) + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Cc [19]uint8 + Line uint8 + Ispeed uint32 + Ospeed uint32 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go new file mode 100644 index 0000000000..8e25c9fffc --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go @@ -0,0 +1,614 @@ +// +build ppc64le,linux +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_linux.go + +package unix + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 + PathMax = 0x1000 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int64 +} + +type Timex struct { + Modes uint32 + Pad_cgo_0 [4]byte + Offset int64 + Freq int64 + Maxerror int64 + Esterror int64 + Status int32 + Pad_cgo_1 [4]byte + Constant int64 + Precision int64 + Tolerance int64 + Time Timeval + Tick int64 + Ppsfreq int64 + Jitter int64 + Shift int32 + Pad_cgo_2 [4]byte + Stabil int64 + Jitcnt int64 + Calcnt int64 + Errcnt int64 + Stbcnt int64 + Tai int32 + Pad_cgo_3 [44]byte +} + +type Time_t int64 + +type Tms struct { + Utime int64 + Stime int64 + Cutime int64 + Cstime int64 +} + +type Utimbuf struct { + Actime int64 + Modtime int64 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +type Stat_t struct { + Dev uint64 + Ino uint64 + Nlink uint64 + Mode uint32 + Uid uint32 + Gid uint32 + X__pad2 int32 + Rdev uint64 + Size int64 + Blksize int64 + Blocks int64 + Atim Timespec + Mtim Timespec + Ctim Timespec + X__glibc_reserved4 uint64 + X__glibc_reserved5 uint64 + X__glibc_reserved6 uint64 +} + +type Statfs_t struct { + Type int64 + Bsize int64 + Blocks uint64 + Bfree uint64 + Bavail uint64 + Files uint64 + Ffree uint64 + Fsid Fsid + Namelen int64 + Frsize int64 + Flags int64 + Spare [4]int64 +} + +type Dirent struct { + Ino uint64 + Off int64 + Reclen uint16 + Type uint8 + Name [256]uint8 + Pad_cgo_0 [5]byte +} + +type Fsid struct { + X__val [2]int32 +} + +type Flock_t struct { + Type int16 + Whence int16 + Pad_cgo_0 [4]byte + Start int64 + Len int64 + Pid int32 + Pad_cgo_1 [4]byte +} + +const ( + FADV_NORMAL = 0x0 + FADV_RANDOM = 0x1 + FADV_SEQUENTIAL = 0x2 + FADV_WILLNEED = 0x3 + FADV_DONTNEED = 0x4 + FADV_NOREUSE = 0x5 +) + +type RawSockaddrInet4 struct { + Family uint16 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]uint8 +} + +type RawSockaddrInet6 struct { + Family uint16 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Family uint16 + Path [108]int8 +} + +type RawSockaddrLinklayer struct { + Family uint16 + Protocol uint16 + Ifindex int32 + Hatype uint16 + Pkttype uint8 + Halen uint8 + Addr [8]uint8 +} + +type RawSockaddrNetlink struct { + Family uint16 + Pad uint16 + Pid uint32 + Groups uint32 +} + +type RawSockaddrHCI struct { + Family uint16 + Dev uint16 + Channel uint16 +} + +type RawSockaddr struct { + Family uint16 + Data [14]uint8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [96]uint8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint64 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPMreqn struct { + Multiaddr [4]byte /* in_addr */ + Address [4]byte /* in_addr */ + Ifindex int32 +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Pad_cgo_0 [4]byte + Iov *Iovec + Iovlen uint64 + Control *byte + Controllen uint64 + Flags int32 + Pad_cgo_1 [4]byte +} + +type Cmsghdr struct { + Len uint64 + Level int32 + Type int32 + X__cmsg_data [0]uint8 +} + +type Inet4Pktinfo struct { + Ifindex int32 + Spec_dst [4]byte /* in_addr */ + Addr [4]byte /* in_addr */ +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Data [8]uint32 +} + +type Ucred struct { + Pid int32 + Uid uint32 + Gid uint32 +} + +type TCPInfo struct { + State uint8 + Ca_state uint8 + Retransmits uint8 + Probes uint8 + Backoff uint8 + Options uint8 + Pad_cgo_0 [2]byte + Rto uint32 + Ato uint32 + Snd_mss uint32 + Rcv_mss uint32 + Unacked uint32 + Sacked uint32 + Lost uint32 + Retrans uint32 + Fackets uint32 + Last_data_sent uint32 + Last_ack_sent uint32 + Last_data_recv uint32 + Last_ack_recv uint32 + Pmtu uint32 + Rcv_ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Snd_ssthresh uint32 + Snd_cwnd uint32 + Advmss uint32 + Reordering uint32 + Rcv_rtt uint32 + Rcv_space uint32 + Total_retrans uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x70 + SizeofSockaddrUnix = 0x6e + SizeofSockaddrLinklayer = 0x14 + SizeofSockaddrNetlink = 0xc + SizeofSockaddrHCI = 0x6 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPMreqn = 0xc + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x38 + SizeofCmsghdr = 0x10 + SizeofInet4Pktinfo = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 + SizeofUcred = 0xc + SizeofTCPInfo = 0x68 +) + +const ( + IFA_UNSPEC = 0x0 + IFA_ADDRESS = 0x1 + IFA_LOCAL = 0x2 + IFA_LABEL = 0x3 + IFA_BROADCAST = 0x4 + IFA_ANYCAST = 0x5 + IFA_CACHEINFO = 0x6 + IFA_MULTICAST = 0x7 + IFLA_UNSPEC = 0x0 + IFLA_ADDRESS = 0x1 + IFLA_BROADCAST = 0x2 + IFLA_IFNAME = 0x3 + IFLA_MTU = 0x4 + IFLA_LINK = 0x5 + IFLA_QDISC = 0x6 + IFLA_STATS = 0x7 + IFLA_COST = 0x8 + IFLA_PRIORITY = 0x9 + IFLA_MASTER = 0xa + IFLA_WIRELESS = 0xb + IFLA_PROTINFO = 0xc + IFLA_TXQLEN = 0xd + IFLA_MAP = 0xe + IFLA_WEIGHT = 0xf + IFLA_OPERSTATE = 0x10 + IFLA_LINKMODE = 0x11 + IFLA_LINKINFO = 0x12 + IFLA_NET_NS_PID = 0x13 + IFLA_IFALIAS = 0x14 + IFLA_MAX = 0x22 + RT_SCOPE_UNIVERSE = 0x0 + RT_SCOPE_SITE = 0xc8 + RT_SCOPE_LINK = 0xfd + RT_SCOPE_HOST = 0xfe + RT_SCOPE_NOWHERE = 0xff + RT_TABLE_UNSPEC = 0x0 + RT_TABLE_COMPAT = 0xfc + RT_TABLE_DEFAULT = 0xfd + RT_TABLE_MAIN = 0xfe + RT_TABLE_LOCAL = 0xff + RT_TABLE_MAX = 0xffffffff + RTA_UNSPEC = 0x0 + RTA_DST = 0x1 + RTA_SRC = 0x2 + RTA_IIF = 0x3 + RTA_OIF = 0x4 + RTA_GATEWAY = 0x5 + RTA_PRIORITY = 0x6 + RTA_PREFSRC = 0x7 + RTA_METRICS = 0x8 + RTA_MULTIPATH = 0x9 + RTA_FLOW = 0xb + RTA_CACHEINFO = 0xc + RTA_TABLE = 0xf + RTN_UNSPEC = 0x0 + RTN_UNICAST = 0x1 + RTN_LOCAL = 0x2 + RTN_BROADCAST = 0x3 + RTN_ANYCAST = 0x4 + RTN_MULTICAST = 0x5 + RTN_BLACKHOLE = 0x6 + RTN_UNREACHABLE = 0x7 + RTN_PROHIBIT = 0x8 + RTN_THROW = 0x9 + RTN_NAT = 0xa + RTN_XRESOLVE = 0xb + RTNLGRP_NONE = 0x0 + RTNLGRP_LINK = 0x1 + RTNLGRP_NOTIFY = 0x2 + RTNLGRP_NEIGH = 0x3 + RTNLGRP_TC = 0x4 + RTNLGRP_IPV4_IFADDR = 0x5 + RTNLGRP_IPV4_MROUTE = 0x6 + RTNLGRP_IPV4_ROUTE = 0x7 + RTNLGRP_IPV4_RULE = 0x8 + RTNLGRP_IPV6_IFADDR = 0x9 + RTNLGRP_IPV6_MROUTE = 0xa + RTNLGRP_IPV6_ROUTE = 0xb + RTNLGRP_IPV6_IFINFO = 0xc + RTNLGRP_IPV6_PREFIX = 0x12 + RTNLGRP_IPV6_RULE = 0x13 + RTNLGRP_ND_USEROPT = 0x14 + SizeofNlMsghdr = 0x10 + SizeofNlMsgerr = 0x14 + SizeofRtGenmsg = 0x1 + SizeofNlAttr = 0x4 + SizeofRtAttr = 0x4 + SizeofIfInfomsg = 0x10 + SizeofIfAddrmsg = 0x8 + SizeofRtMsg = 0xc + SizeofRtNexthop = 0x8 +) + +type NlMsghdr struct { + Len uint32 + Type uint16 + Flags uint16 + Seq uint32 + Pid uint32 +} + +type NlMsgerr struct { + Error int32 + Msg NlMsghdr +} + +type RtGenmsg struct { + Family uint8 +} + +type NlAttr struct { + Len uint16 + Type uint16 +} + +type RtAttr struct { + Len uint16 + Type uint16 +} + +type IfInfomsg struct { + Family uint8 + X__ifi_pad uint8 + Type uint16 + Index int32 + Flags uint32 + Change uint32 +} + +type IfAddrmsg struct { + Family uint8 + Prefixlen uint8 + Flags uint8 + Scope uint8 + Index uint32 +} + +type RtMsg struct { + Family uint8 + Dst_len uint8 + Src_len uint8 + Tos uint8 + Table uint8 + Protocol uint8 + Scope uint8 + Type uint8 + Flags uint32 +} + +type RtNexthop struct { + Len uint16 + Flags uint8 + Hops uint8 + Ifindex int32 +} + +const ( + SizeofSockFilter = 0x8 + SizeofSockFprog = 0x10 +) + +type SockFilter struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type SockFprog struct { + Len uint16 + Pad_cgo_0 [6]byte + Filter *SockFilter +} + +type InotifyEvent struct { + Wd int32 + Mask uint32 + Cookie uint32 + Len uint32 + Name [0]uint8 +} + +const SizeofInotifyEvent = 0x10 + +type PtraceRegs struct { + Gpr [32]uint64 + Nip uint64 + Msr uint64 + Orig_gpr3 uint64 + Ctr uint64 + Link uint64 + Xer uint64 + Ccr uint64 + Softe uint64 + Trap uint64 + Dar uint64 + Dsisr uint64 + Result uint64 +} + +type FdSet struct { + Bits [16]int64 +} + +type Sysinfo_t struct { + Uptime int64 + Loads [3]uint64 + Totalram uint64 + Freeram uint64 + Sharedram uint64 + Bufferram uint64 + Totalswap uint64 + Freeswap uint64 + Procs uint16 + Pad uint16 + Pad_cgo_0 [4]byte + Totalhigh uint64 + Freehigh uint64 + Unit uint32 + X_f [0]uint8 + Pad_cgo_1 [4]byte +} + +type Utsname struct { + Sysname [65]uint8 + Nodename [65]uint8 + Release [65]uint8 + Version [65]uint8 + Machine [65]uint8 + Domainname [65]uint8 +} + +type Ustat_t struct { + Tfree int32 + Pad_cgo_0 [4]byte + Tinode uint64 + Fname [6]uint8 + Fpack [6]uint8 + Pad_cgo_1 [4]byte +} + +type EpollEvent struct { + Events uint32 + X_padFd int32 + Fd int32 + Pad int32 +} + +const ( + AT_FDCWD = -0x64 + AT_REMOVEDIR = 0x200 + AT_SYMLINK_FOLLOW = 0x400 + AT_SYMLINK_NOFOLLOW = 0x100 +) + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Cc [19]uint8 + Line uint8 + Ispeed uint32 + Ospeed uint32 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go new file mode 100644 index 0000000000..268e373624 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go @@ -0,0 +1,629 @@ +// +build s390x,linux +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs -- -fsigned-char types_linux.go + +package unix + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 + PathMax = 0x1000 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int64 +} + +type Timex struct { + Modes uint32 + _ [4]byte + Offset int64 + Freq int64 + Maxerror int64 + Esterror int64 + Status int32 + _ [4]byte + Constant int64 + Precision int64 + Tolerance int64 + Time Timeval + Tick int64 + Ppsfreq int64 + Jitter int64 + Shift int32 + _ [4]byte + Stabil int64 + Jitcnt int64 + Calcnt int64 + Errcnt int64 + Stbcnt int64 + Tai int32 + _ [44]byte +} + +type Time_t int64 + +type Tms struct { + Utime int64 + Stime int64 + Cutime int64 + Cstime int64 +} + +type Utimbuf struct { + Actime int64 + Modtime int64 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +type Stat_t struct { + Dev uint64 + Ino uint64 + Nlink uint64 + Mode uint32 + Uid uint32 + Gid uint32 + _ int32 + Rdev uint64 + Size int64 + Atim Timespec + Mtim Timespec + Ctim Timespec + Blksize int64 + Blocks int64 + _ [3]int64 +} + +type Statfs_t struct { + Type uint32 + Bsize uint32 + Blocks uint64 + Bfree uint64 + Bavail uint64 + Files uint64 + Ffree uint64 + Fsid Fsid + Namelen uint32 + Frsize uint32 + Flags uint32 + Spare [4]uint32 + _ [4]byte +} + +type Dirent struct { + Ino uint64 + Off int64 + Reclen uint16 + Type uint8 + Name [256]int8 + _ [5]byte +} + +type Fsid struct { + _ [2]int32 +} + +type Flock_t struct { + Type int16 + Whence int16 + _ [4]byte + Start int64 + Len int64 + Pid int32 + _ [4]byte +} + +const ( + FADV_NORMAL = 0x0 + FADV_RANDOM = 0x1 + FADV_SEQUENTIAL = 0x2 + FADV_WILLNEED = 0x3 + FADV_DONTNEED = 0x6 + FADV_NOREUSE = 0x7 +) + +type RawSockaddrInet4 struct { + Family uint16 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]uint8 +} + +type RawSockaddrInet6 struct { + Family uint16 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Family uint16 + Path [108]int8 +} + +type RawSockaddrLinklayer struct { + Family uint16 + Protocol uint16 + Ifindex int32 + Hatype uint16 + Pkttype uint8 + Halen uint8 + Addr [8]uint8 +} + +type RawSockaddrNetlink struct { + Family uint16 + Pad uint16 + Pid uint32 + Groups uint32 +} + +type RawSockaddrHCI struct { + Family uint16 + Dev uint16 + Channel uint16 +} + +type RawSockaddr struct { + Family uint16 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [96]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint64 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPMreqn struct { + Multiaddr [4]byte /* in_addr */ + Address [4]byte /* in_addr */ + Ifindex int32 +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + _ [4]byte + Iov *Iovec + Iovlen uint64 + Control *byte + Controllen uint64 + Flags int32 + _ [4]byte +} + +type Cmsghdr struct { + Len uint64 + Level int32 + Type int32 +} + +type Inet4Pktinfo struct { + Ifindex int32 + Spec_dst [4]byte /* in_addr */ + Addr [4]byte /* in_addr */ +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Data [8]uint32 +} + +type Ucred struct { + Pid int32 + Uid uint32 + Gid uint32 +} + +type TCPInfo struct { + State uint8 + Ca_state uint8 + Retransmits uint8 + Probes uint8 + Backoff uint8 + Options uint8 + _ [2]byte + Rto uint32 + Ato uint32 + Snd_mss uint32 + Rcv_mss uint32 + Unacked uint32 + Sacked uint32 + Lost uint32 + Retrans uint32 + Fackets uint32 + Last_data_sent uint32 + Last_ack_sent uint32 + Last_data_recv uint32 + Last_ack_recv uint32 + Pmtu uint32 + Rcv_ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Snd_ssthresh uint32 + Snd_cwnd uint32 + Advmss uint32 + Reordering uint32 + Rcv_rtt uint32 + Rcv_space uint32 + Total_retrans uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x70 + SizeofSockaddrUnix = 0x6e + SizeofSockaddrLinklayer = 0x14 + SizeofSockaddrNetlink = 0xc + SizeofSockaddrHCI = 0x6 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPMreqn = 0xc + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x38 + SizeofCmsghdr = 0x10 + SizeofInet4Pktinfo = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 + SizeofUcred = 0xc + SizeofTCPInfo = 0x68 +) + +const ( + IFA_UNSPEC = 0x0 + IFA_ADDRESS = 0x1 + IFA_LOCAL = 0x2 + IFA_LABEL = 0x3 + IFA_BROADCAST = 0x4 + IFA_ANYCAST = 0x5 + IFA_CACHEINFO = 0x6 + IFA_MULTICAST = 0x7 + IFLA_UNSPEC = 0x0 + IFLA_ADDRESS = 0x1 + IFLA_BROADCAST = 0x2 + IFLA_IFNAME = 0x3 + IFLA_MTU = 0x4 + IFLA_LINK = 0x5 + IFLA_QDISC = 0x6 + IFLA_STATS = 0x7 + IFLA_COST = 0x8 + IFLA_PRIORITY = 0x9 + IFLA_MASTER = 0xa + IFLA_WIRELESS = 0xb + IFLA_PROTINFO = 0xc + IFLA_TXQLEN = 0xd + IFLA_MAP = 0xe + IFLA_WEIGHT = 0xf + IFLA_OPERSTATE = 0x10 + IFLA_LINKMODE = 0x11 + IFLA_LINKINFO = 0x12 + IFLA_NET_NS_PID = 0x13 + IFLA_IFALIAS = 0x14 + IFLA_MAX = 0x27 + RT_SCOPE_UNIVERSE = 0x0 + RT_SCOPE_SITE = 0xc8 + RT_SCOPE_LINK = 0xfd + RT_SCOPE_HOST = 0xfe + RT_SCOPE_NOWHERE = 0xff + RT_TABLE_UNSPEC = 0x0 + RT_TABLE_COMPAT = 0xfc + RT_TABLE_DEFAULT = 0xfd + RT_TABLE_MAIN = 0xfe + RT_TABLE_LOCAL = 0xff + RT_TABLE_MAX = 0xffffffff + RTA_UNSPEC = 0x0 + RTA_DST = 0x1 + RTA_SRC = 0x2 + RTA_IIF = 0x3 + RTA_OIF = 0x4 + RTA_GATEWAY = 0x5 + RTA_PRIORITY = 0x6 + RTA_PREFSRC = 0x7 + RTA_METRICS = 0x8 + RTA_MULTIPATH = 0x9 + RTA_FLOW = 0xb + RTA_CACHEINFO = 0xc + RTA_TABLE = 0xf + RTN_UNSPEC = 0x0 + RTN_UNICAST = 0x1 + RTN_LOCAL = 0x2 + RTN_BROADCAST = 0x3 + RTN_ANYCAST = 0x4 + RTN_MULTICAST = 0x5 + RTN_BLACKHOLE = 0x6 + RTN_UNREACHABLE = 0x7 + RTN_PROHIBIT = 0x8 + RTN_THROW = 0x9 + RTN_NAT = 0xa + RTN_XRESOLVE = 0xb + RTNLGRP_NONE = 0x0 + RTNLGRP_LINK = 0x1 + RTNLGRP_NOTIFY = 0x2 + RTNLGRP_NEIGH = 0x3 + RTNLGRP_TC = 0x4 + RTNLGRP_IPV4_IFADDR = 0x5 + RTNLGRP_IPV4_MROUTE = 0x6 + RTNLGRP_IPV4_ROUTE = 0x7 + RTNLGRP_IPV4_RULE = 0x8 + RTNLGRP_IPV6_IFADDR = 0x9 + RTNLGRP_IPV6_MROUTE = 0xa + RTNLGRP_IPV6_ROUTE = 0xb + RTNLGRP_IPV6_IFINFO = 0xc + RTNLGRP_IPV6_PREFIX = 0x12 + RTNLGRP_IPV6_RULE = 0x13 + RTNLGRP_ND_USEROPT = 0x14 + SizeofNlMsghdr = 0x10 + SizeofNlMsgerr = 0x14 + SizeofRtGenmsg = 0x1 + SizeofNlAttr = 0x4 + SizeofRtAttr = 0x4 + SizeofIfInfomsg = 0x10 + SizeofIfAddrmsg = 0x8 + SizeofRtMsg = 0xc + SizeofRtNexthop = 0x8 +) + +type NlMsghdr struct { + Len uint32 + Type uint16 + Flags uint16 + Seq uint32 + Pid uint32 +} + +type NlMsgerr struct { + Error int32 + Msg NlMsghdr +} + +type RtGenmsg struct { + Family uint8 +} + +type NlAttr struct { + Len uint16 + Type uint16 +} + +type RtAttr struct { + Len uint16 + Type uint16 +} + +type IfInfomsg struct { + Family uint8 + _ uint8 + Type uint16 + Index int32 + Flags uint32 + Change uint32 +} + +type IfAddrmsg struct { + Family uint8 + Prefixlen uint8 + Flags uint8 + Scope uint8 + Index uint32 +} + +type RtMsg struct { + Family uint8 + Dst_len uint8 + Src_len uint8 + Tos uint8 + Table uint8 + Protocol uint8 + Scope uint8 + Type uint8 + Flags uint32 +} + +type RtNexthop struct { + Len uint16 + Flags uint8 + Hops uint8 + Ifindex int32 +} + +const ( + SizeofSockFilter = 0x8 + SizeofSockFprog = 0x10 +) + +type SockFilter struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type SockFprog struct { + Len uint16 + _ [6]byte + Filter *SockFilter +} + +type InotifyEvent struct { + Wd int32 + Mask uint32 + Cookie uint32 + Len uint32 +} + +const SizeofInotifyEvent = 0x10 + +type PtraceRegs struct { + Psw PtracePsw + Gprs [16]uint64 + Acrs [16]uint32 + Orig_gpr2 uint64 + Fp_regs PtraceFpregs + Per_info PtracePer + Ieee_instruction_pointer uint64 +} + +type PtracePsw struct { + Mask uint64 + Addr uint64 +} + +type PtraceFpregs struct { + Fpc uint32 + _ [4]byte + Fprs [16]float64 +} + +type PtracePer struct { + _ [0]uint64 + _ [24]byte + _ [8]byte + Starting_addr uint64 + Ending_addr uint64 + Perc_atmid uint16 + _ [6]byte + Address uint64 + Access_id uint8 + _ [7]byte +} + +type FdSet struct { + Bits [16]int64 +} + +type Sysinfo_t struct { + Uptime int64 + Loads [3]uint64 + Totalram uint64 + Freeram uint64 + Sharedram uint64 + Bufferram uint64 + Totalswap uint64 + Freeswap uint64 + Procs uint16 + Pad uint16 + _ [4]byte + Totalhigh uint64 + Freehigh uint64 + Unit uint32 + _ [0]int8 + _ [4]byte +} + +type Utsname struct { + Sysname [65]int8 + Nodename [65]int8 + Release [65]int8 + Version [65]int8 + Machine [65]int8 + Domainname [65]int8 +} + +type Ustat_t struct { + Tfree int32 + _ [4]byte + Tinode uint64 + Fname [6]int8 + Fpack [6]int8 + _ [4]byte +} + +type EpollEvent struct { + Events uint32 + _ int32 + Fd int32 + Pad int32 +} + +const ( + AT_FDCWD = -0x64 + AT_REMOVEDIR = 0x200 + AT_SYMLINK_FOLLOW = 0x400 + AT_SYMLINK_NOFOLLOW = 0x100 +) + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Line uint8 + Cc [19]uint8 + Ispeed uint32 + Ospeed uint32 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go new file mode 100644 index 0000000000..caf755fb86 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go @@ -0,0 +1,396 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_netbsd.go + +// +build 386,netbsd + +package unix + +const ( + sizeofPtr = 0x4 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x4 + sizeofLongLong = 0x8 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int32 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int32 +} + +type Timeval struct { + Sec int64 + Usec int32 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int32 + Ixrss int32 + Idrss int32 + Isrss int32 + Minflt int32 + Majflt int32 + Nswap int32 + Inblock int32 + Oublock int32 + Msgsnd int32 + Msgrcv int32 + Nsignals int32 + Nvcsw int32 + Nivcsw int32 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +type Stat_t struct { + Dev uint64 + Mode uint32 + Ino uint64 + Nlink uint32 + Uid uint32 + Gid uint32 + Rdev uint64 + Atimespec Timespec + Mtimespec Timespec + Ctimespec Timespec + Birthtimespec Timespec + Size int64 + Blocks int64 + Blksize uint32 + Flags uint32 + Gen uint32 + Spare [2]uint32 +} + +type Statfs_t [0]byte + +type Flock_t struct { + Start int64 + Len int64 + Pid int32 + Type int16 + Whence int16 +} + +type Dirent struct { + Fileno uint64 + Reclen uint16 + Namlen uint16 + Type uint8 + Name [512]int8 + Pad_cgo_0 [3]byte +} + +type Fsid struct { + X__fsid_val [2]int32 +} + +type RawSockaddrInet4 struct { + Len uint8 + Family uint8 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]int8 +} + +type RawSockaddrInet6 struct { + Len uint8 + Family uint8 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Len uint8 + Family uint8 + Path [104]int8 +} + +type RawSockaddrDatalink struct { + Len uint8 + Family uint8 + Index uint16 + Type uint8 + Nlen uint8 + Alen uint8 + Slen uint8 + Data [12]int8 +} + +type RawSockaddr struct { + Len uint8 + Family uint8 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [92]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint32 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Iov *Iovec + Iovlen int32 + Control *byte + Controllen uint32 + Flags int32 +} + +type Cmsghdr struct { + Len uint32 + Level int32 + Type int32 +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Filt [8]uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x6c + SizeofSockaddrUnix = 0x6a + SizeofSockaddrDatalink = 0x14 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x1c + SizeofCmsghdr = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 +) + +const ( + PTRACE_TRACEME = 0x0 + PTRACE_CONT = 0x7 + PTRACE_KILL = 0x8 +) + +type Kevent_t struct { + Ident uint32 + Filter uint32 + Flags uint32 + Fflags uint32 + Data int64 + Udata int32 +} + +type FdSet struct { + Bits [8]uint32 +} + +const ( + SizeofIfMsghdr = 0x98 + SizeofIfData = 0x84 + SizeofIfaMsghdr = 0x18 + SizeofIfAnnounceMsghdr = 0x18 + SizeofRtMsghdr = 0x78 + SizeofRtMetrics = 0x50 +) + +type IfMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Data IfData + Pad_cgo_1 [4]byte +} + +type IfData struct { + Type uint8 + Addrlen uint8 + Hdrlen uint8 + Pad_cgo_0 [1]byte + Link_state int32 + Mtu uint64 + Metric uint64 + Baudrate uint64 + Ipackets uint64 + Ierrors uint64 + Opackets uint64 + Oerrors uint64 + Collisions uint64 + Ibytes uint64 + Obytes uint64 + Imcasts uint64 + Omcasts uint64 + Iqdrops uint64 + Noproto uint64 + Lastchange Timespec +} + +type IfaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Metric int32 + Index uint16 + Pad_cgo_0 [6]byte +} + +type IfAnnounceMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Index uint16 + Name [16]int8 + What uint16 +} + +type RtMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Index uint16 + Pad_cgo_0 [2]byte + Flags int32 + Addrs int32 + Pid int32 + Seq int32 + Errno int32 + Use int32 + Inits int32 + Pad_cgo_1 [4]byte + Rmx RtMetrics +} + +type RtMetrics struct { + Locks uint64 + Mtu uint64 + Hopcount uint64 + Recvpipe uint64 + Sendpipe uint64 + Ssthresh uint64 + Rtt uint64 + Rttvar uint64 + Expire int64 + Pksent int64 +} + +type Mclpool [0]byte + +const ( + SizeofBpfVersion = 0x4 + SizeofBpfStat = 0x80 + SizeofBpfProgram = 0x8 + SizeofBpfInsn = 0x8 + SizeofBpfHdr = 0x14 +) + +type BpfVersion struct { + Major uint16 + Minor uint16 +} + +type BpfStat struct { + Recv uint64 + Drop uint64 + Capt uint64 + Padding [13]uint64 +} + +type BpfProgram struct { + Len uint32 + Insns *BpfInsn +} + +type BpfInsn struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type BpfHdr struct { + Tstamp BpfTimeval + Caplen uint32 + Datalen uint32 + Hdrlen uint16 + Pad_cgo_0 [2]byte +} + +type BpfTimeval struct { + Sec int32 + Usec int32 +} + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Cc [20]uint8 + Ispeed int32 + Ospeed int32 +} + +type Sysctlnode struct { + Flags uint32 + Num int32 + Name [32]int8 + Ver uint32 + X__rsvd uint32 + Un [16]byte + X_sysctl_size [8]byte + X_sysctl_func [8]byte + X_sysctl_parent [8]byte + X_sysctl_desc [8]byte +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go new file mode 100644 index 0000000000..91b4a5305a --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go @@ -0,0 +1,403 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_netbsd.go + +// +build amd64,netbsd + +package unix + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int32 + Pad_cgo_0 [4]byte +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +type Stat_t struct { + Dev uint64 + Mode uint32 + Pad_cgo_0 [4]byte + Ino uint64 + Nlink uint32 + Uid uint32 + Gid uint32 + Pad_cgo_1 [4]byte + Rdev uint64 + Atimespec Timespec + Mtimespec Timespec + Ctimespec Timespec + Birthtimespec Timespec + Size int64 + Blocks int64 + Blksize uint32 + Flags uint32 + Gen uint32 + Spare [2]uint32 + Pad_cgo_2 [4]byte +} + +type Statfs_t [0]byte + +type Flock_t struct { + Start int64 + Len int64 + Pid int32 + Type int16 + Whence int16 +} + +type Dirent struct { + Fileno uint64 + Reclen uint16 + Namlen uint16 + Type uint8 + Name [512]int8 + Pad_cgo_0 [3]byte +} + +type Fsid struct { + X__fsid_val [2]int32 +} + +type RawSockaddrInet4 struct { + Len uint8 + Family uint8 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]int8 +} + +type RawSockaddrInet6 struct { + Len uint8 + Family uint8 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Len uint8 + Family uint8 + Path [104]int8 +} + +type RawSockaddrDatalink struct { + Len uint8 + Family uint8 + Index uint16 + Type uint8 + Nlen uint8 + Alen uint8 + Slen uint8 + Data [12]int8 +} + +type RawSockaddr struct { + Len uint8 + Family uint8 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [92]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint64 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Pad_cgo_0 [4]byte + Iov *Iovec + Iovlen int32 + Pad_cgo_1 [4]byte + Control *byte + Controllen uint32 + Flags int32 +} + +type Cmsghdr struct { + Len uint32 + Level int32 + Type int32 +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Filt [8]uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x6c + SizeofSockaddrUnix = 0x6a + SizeofSockaddrDatalink = 0x14 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x30 + SizeofCmsghdr = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 +) + +const ( + PTRACE_TRACEME = 0x0 + PTRACE_CONT = 0x7 + PTRACE_KILL = 0x8 +) + +type Kevent_t struct { + Ident uint64 + Filter uint32 + Flags uint32 + Fflags uint32 + Pad_cgo_0 [4]byte + Data int64 + Udata int64 +} + +type FdSet struct { + Bits [8]uint32 +} + +const ( + SizeofIfMsghdr = 0x98 + SizeofIfData = 0x88 + SizeofIfaMsghdr = 0x18 + SizeofIfAnnounceMsghdr = 0x18 + SizeofRtMsghdr = 0x78 + SizeofRtMetrics = 0x50 +) + +type IfMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Data IfData +} + +type IfData struct { + Type uint8 + Addrlen uint8 + Hdrlen uint8 + Pad_cgo_0 [1]byte + Link_state int32 + Mtu uint64 + Metric uint64 + Baudrate uint64 + Ipackets uint64 + Ierrors uint64 + Opackets uint64 + Oerrors uint64 + Collisions uint64 + Ibytes uint64 + Obytes uint64 + Imcasts uint64 + Omcasts uint64 + Iqdrops uint64 + Noproto uint64 + Lastchange Timespec +} + +type IfaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Metric int32 + Index uint16 + Pad_cgo_0 [6]byte +} + +type IfAnnounceMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Index uint16 + Name [16]int8 + What uint16 +} + +type RtMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Index uint16 + Pad_cgo_0 [2]byte + Flags int32 + Addrs int32 + Pid int32 + Seq int32 + Errno int32 + Use int32 + Inits int32 + Pad_cgo_1 [4]byte + Rmx RtMetrics +} + +type RtMetrics struct { + Locks uint64 + Mtu uint64 + Hopcount uint64 + Recvpipe uint64 + Sendpipe uint64 + Ssthresh uint64 + Rtt uint64 + Rttvar uint64 + Expire int64 + Pksent int64 +} + +type Mclpool [0]byte + +const ( + SizeofBpfVersion = 0x4 + SizeofBpfStat = 0x80 + SizeofBpfProgram = 0x10 + SizeofBpfInsn = 0x8 + SizeofBpfHdr = 0x20 +) + +type BpfVersion struct { + Major uint16 + Minor uint16 +} + +type BpfStat struct { + Recv uint64 + Drop uint64 + Capt uint64 + Padding [13]uint64 +} + +type BpfProgram struct { + Len uint32 + Pad_cgo_0 [4]byte + Insns *BpfInsn +} + +type BpfInsn struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type BpfHdr struct { + Tstamp BpfTimeval + Caplen uint32 + Datalen uint32 + Hdrlen uint16 + Pad_cgo_0 [6]byte +} + +type BpfTimeval struct { + Sec int64 + Usec int64 +} + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Cc [20]uint8 + Ispeed int32 + Ospeed int32 +} + +type Sysctlnode struct { + Flags uint32 + Num int32 + Name [32]int8 + Ver uint32 + X__rsvd uint32 + Un [16]byte + X_sysctl_size [8]byte + X_sysctl_func [8]byte + X_sysctl_parent [8]byte + X_sysctl_desc [8]byte +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go new file mode 100644 index 0000000000..c0758f9d3f --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go @@ -0,0 +1,401 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_netbsd.go + +// +build arm,netbsd + +package unix + +const ( + sizeofPtr = 0x4 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x4 + sizeofLongLong = 0x8 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int32 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int32 + Pad_cgo_0 [4]byte +} + +type Timeval struct { + Sec int64 + Usec int32 + Pad_cgo_0 [4]byte +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int32 + Ixrss int32 + Idrss int32 + Isrss int32 + Minflt int32 + Majflt int32 + Nswap int32 + Inblock int32 + Oublock int32 + Msgsnd int32 + Msgrcv int32 + Nsignals int32 + Nvcsw int32 + Nivcsw int32 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +type Stat_t struct { + Dev uint64 + Mode uint32 + Pad_cgo_0 [4]byte + Ino uint64 + Nlink uint32 + Uid uint32 + Gid uint32 + Pad_cgo_1 [4]byte + Rdev uint64 + Atimespec Timespec + Mtimespec Timespec + Ctimespec Timespec + Birthtimespec Timespec + Size int64 + Blocks int64 + Blksize uint32 + Flags uint32 + Gen uint32 + Spare [2]uint32 + Pad_cgo_2 [4]byte +} + +type Statfs_t [0]byte + +type Flock_t struct { + Start int64 + Len int64 + Pid int32 + Type int16 + Whence int16 +} + +type Dirent struct { + Fileno uint64 + Reclen uint16 + Namlen uint16 + Type uint8 + Name [512]int8 + Pad_cgo_0 [3]byte +} + +type Fsid struct { + X__fsid_val [2]int32 +} + +type RawSockaddrInet4 struct { + Len uint8 + Family uint8 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]int8 +} + +type RawSockaddrInet6 struct { + Len uint8 + Family uint8 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Len uint8 + Family uint8 + Path [104]int8 +} + +type RawSockaddrDatalink struct { + Len uint8 + Family uint8 + Index uint16 + Type uint8 + Nlen uint8 + Alen uint8 + Slen uint8 + Data [12]int8 +} + +type RawSockaddr struct { + Len uint8 + Family uint8 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [92]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint32 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Iov *Iovec + Iovlen int32 + Control *byte + Controllen uint32 + Flags int32 +} + +type Cmsghdr struct { + Len uint32 + Level int32 + Type int32 +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Filt [8]uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x6c + SizeofSockaddrUnix = 0x6a + SizeofSockaddrDatalink = 0x14 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x1c + SizeofCmsghdr = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 +) + +const ( + PTRACE_TRACEME = 0x0 + PTRACE_CONT = 0x7 + PTRACE_KILL = 0x8 +) + +type Kevent_t struct { + Ident uint32 + Filter uint32 + Flags uint32 + Fflags uint32 + Data int64 + Udata int32 + Pad_cgo_0 [4]byte +} + +type FdSet struct { + Bits [8]uint32 +} + +const ( + SizeofIfMsghdr = 0x98 + SizeofIfData = 0x88 + SizeofIfaMsghdr = 0x18 + SizeofIfAnnounceMsghdr = 0x18 + SizeofRtMsghdr = 0x78 + SizeofRtMetrics = 0x50 +) + +type IfMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Data IfData +} + +type IfData struct { + Type uint8 + Addrlen uint8 + Hdrlen uint8 + Pad_cgo_0 [1]byte + Link_state int32 + Mtu uint64 + Metric uint64 + Baudrate uint64 + Ipackets uint64 + Ierrors uint64 + Opackets uint64 + Oerrors uint64 + Collisions uint64 + Ibytes uint64 + Obytes uint64 + Imcasts uint64 + Omcasts uint64 + Iqdrops uint64 + Noproto uint64 + Lastchange Timespec +} + +type IfaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Metric int32 + Index uint16 + Pad_cgo_0 [6]byte +} + +type IfAnnounceMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Index uint16 + Name [16]int8 + What uint16 +} + +type RtMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Index uint16 + Pad_cgo_0 [2]byte + Flags int32 + Addrs int32 + Pid int32 + Seq int32 + Errno int32 + Use int32 + Inits int32 + Pad_cgo_1 [4]byte + Rmx RtMetrics +} + +type RtMetrics struct { + Locks uint64 + Mtu uint64 + Hopcount uint64 + Recvpipe uint64 + Sendpipe uint64 + Ssthresh uint64 + Rtt uint64 + Rttvar uint64 + Expire int64 + Pksent int64 +} + +type Mclpool [0]byte + +const ( + SizeofBpfVersion = 0x4 + SizeofBpfStat = 0x80 + SizeofBpfProgram = 0x8 + SizeofBpfInsn = 0x8 + SizeofBpfHdr = 0x14 +) + +type BpfVersion struct { + Major uint16 + Minor uint16 +} + +type BpfStat struct { + Recv uint64 + Drop uint64 + Capt uint64 + Padding [13]uint64 +} + +type BpfProgram struct { + Len uint32 + Insns *BpfInsn +} + +type BpfInsn struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type BpfHdr struct { + Tstamp BpfTimeval + Caplen uint32 + Datalen uint32 + Hdrlen uint16 + Pad_cgo_0 [2]byte +} + +type BpfTimeval struct { + Sec int32 + Usec int32 +} + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Cc [20]uint8 + Ispeed int32 + Ospeed int32 +} + +type Sysctlnode struct { + Flags uint32 + Num int32 + Name [32]int8 + Ver uint32 + X__rsvd uint32 + Un [16]byte + X_sysctl_size [8]byte + X_sysctl_func [8]byte + X_sysctl_parent [8]byte + X_sysctl_desc [8]byte +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go new file mode 100644 index 0000000000..860a469796 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go @@ -0,0 +1,441 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_openbsd.go + +// +build 386,openbsd + +package unix + +const ( + sizeofPtr = 0x4 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x4 + sizeofLongLong = 0x8 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int32 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int32 +} + +type Timeval struct { + Sec int64 + Usec int32 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int32 + Ixrss int32 + Idrss int32 + Isrss int32 + Minflt int32 + Majflt int32 + Nswap int32 + Inblock int32 + Oublock int32 + Msgsnd int32 + Msgrcv int32 + Nsignals int32 + Nvcsw int32 + Nivcsw int32 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +const ( + S_IFMT = 0xf000 + S_IFIFO = 0x1000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFBLK = 0x6000 + S_IFREG = 0x8000 + S_IFLNK = 0xa000 + S_IFSOCK = 0xc000 + S_ISUID = 0x800 + S_ISGID = 0x400 + S_ISVTX = 0x200 + S_IRUSR = 0x100 + S_IWUSR = 0x80 + S_IXUSR = 0x40 +) + +type Stat_t struct { + Mode uint32 + Dev int32 + Ino uint64 + Nlink uint32 + Uid uint32 + Gid uint32 + Rdev int32 + Atim Timespec + Mtim Timespec + Ctim Timespec + Size int64 + Blocks int64 + Blksize uint32 + Flags uint32 + Gen uint32 + X__st_birthtim Timespec +} + +type Statfs_t struct { + F_flags uint32 + F_bsize uint32 + F_iosize uint32 + F_blocks uint64 + F_bfree uint64 + F_bavail int64 + F_files uint64 + F_ffree uint64 + F_favail int64 + F_syncwrites uint64 + F_syncreads uint64 + F_asyncwrites uint64 + F_asyncreads uint64 + F_fsid Fsid + F_namemax uint32 + F_owner uint32 + F_ctime uint64 + F_fstypename [16]int8 + F_mntonname [90]int8 + F_mntfromname [90]int8 + F_mntfromspec [90]int8 + Pad_cgo_0 [2]byte + Mount_info [160]byte +} + +type Flock_t struct { + Start int64 + Len int64 + Pid int32 + Type int16 + Whence int16 +} + +type Dirent struct { + Fileno uint64 + Off int64 + Reclen uint16 + Type uint8 + Namlen uint8 + X__d_padding [4]uint8 + Name [256]int8 +} + +type Fsid struct { + Val [2]int32 +} + +type RawSockaddrInet4 struct { + Len uint8 + Family uint8 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]int8 +} + +type RawSockaddrInet6 struct { + Len uint8 + Family uint8 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Len uint8 + Family uint8 + Path [104]int8 +} + +type RawSockaddrDatalink struct { + Len uint8 + Family uint8 + Index uint16 + Type uint8 + Nlen uint8 + Alen uint8 + Slen uint8 + Data [24]int8 +} + +type RawSockaddr struct { + Len uint8 + Family uint8 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [92]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint32 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Iov *Iovec + Iovlen uint32 + Control *byte + Controllen uint32 + Flags int32 +} + +type Cmsghdr struct { + Len uint32 + Level int32 + Type int32 +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Filt [8]uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x6c + SizeofSockaddrUnix = 0x6a + SizeofSockaddrDatalink = 0x20 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x1c + SizeofCmsghdr = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 +) + +const ( + PTRACE_TRACEME = 0x0 + PTRACE_CONT = 0x7 + PTRACE_KILL = 0x8 +) + +type Kevent_t struct { + Ident uint32 + Filter int16 + Flags uint16 + Fflags uint32 + Data int64 + Udata *byte +} + +type FdSet struct { + Bits [32]uint32 +} + +const ( + SizeofIfMsghdr = 0xec + SizeofIfData = 0xd4 + SizeofIfaMsghdr = 0x18 + SizeofIfAnnounceMsghdr = 0x1a + SizeofRtMsghdr = 0x60 + SizeofRtMetrics = 0x38 +) + +type IfMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Hdrlen uint16 + Index uint16 + Tableid uint16 + Pad1 uint8 + Pad2 uint8 + Addrs int32 + Flags int32 + Xflags int32 + Data IfData +} + +type IfData struct { + Type uint8 + Addrlen uint8 + Hdrlen uint8 + Link_state uint8 + Mtu uint32 + Metric uint32 + Pad uint32 + Baudrate uint64 + Ipackets uint64 + Ierrors uint64 + Opackets uint64 + Oerrors uint64 + Collisions uint64 + Ibytes uint64 + Obytes uint64 + Imcasts uint64 + Omcasts uint64 + Iqdrops uint64 + Noproto uint64 + Capabilities uint32 + Lastchange Timeval + Mclpool [7]Mclpool +} + +type IfaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Hdrlen uint16 + Index uint16 + Tableid uint16 + Pad1 uint8 + Pad2 uint8 + Addrs int32 + Flags int32 + Metric int32 +} + +type IfAnnounceMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Hdrlen uint16 + Index uint16 + What uint16 + Name [16]int8 +} + +type RtMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Hdrlen uint16 + Index uint16 + Tableid uint16 + Priority uint8 + Mpls uint8 + Addrs int32 + Flags int32 + Fmask int32 + Pid int32 + Seq int32 + Errno int32 + Inits uint32 + Rmx RtMetrics +} + +type RtMetrics struct { + Pksent uint64 + Expire int64 + Locks uint32 + Mtu uint32 + Refcnt uint32 + Hopcount uint32 + Recvpipe uint32 + Sendpipe uint32 + Ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Pad uint32 +} + +type Mclpool struct { + Grown int32 + Alive uint16 + Hwm uint16 + Cwm uint16 + Lwm uint16 +} + +const ( + SizeofBpfVersion = 0x4 + SizeofBpfStat = 0x8 + SizeofBpfProgram = 0x8 + SizeofBpfInsn = 0x8 + SizeofBpfHdr = 0x14 +) + +type BpfVersion struct { + Major uint16 + Minor uint16 +} + +type BpfStat struct { + Recv uint32 + Drop uint32 +} + +type BpfProgram struct { + Len uint32 + Insns *BpfInsn +} + +type BpfInsn struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type BpfHdr struct { + Tstamp BpfTimeval + Caplen uint32 + Datalen uint32 + Hdrlen uint16 + Pad_cgo_0 [2]byte +} + +type BpfTimeval struct { + Sec uint32 + Usec uint32 +} + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Cc [20]uint8 + Ispeed int32 + Ospeed int32 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go new file mode 100644 index 0000000000..23c52727f7 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go @@ -0,0 +1,448 @@ +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_openbsd.go + +// +build amd64,openbsd + +package unix + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int64 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +const ( + S_IFMT = 0xf000 + S_IFIFO = 0x1000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFBLK = 0x6000 + S_IFREG = 0x8000 + S_IFLNK = 0xa000 + S_IFSOCK = 0xc000 + S_ISUID = 0x800 + S_ISGID = 0x400 + S_ISVTX = 0x200 + S_IRUSR = 0x100 + S_IWUSR = 0x80 + S_IXUSR = 0x40 +) + +type Stat_t struct { + Mode uint32 + Dev int32 + Ino uint64 + Nlink uint32 + Uid uint32 + Gid uint32 + Rdev int32 + Atim Timespec + Mtim Timespec + Ctim Timespec + Size int64 + Blocks int64 + Blksize uint32 + Flags uint32 + Gen uint32 + Pad_cgo_0 [4]byte + X__st_birthtim Timespec +} + +type Statfs_t struct { + F_flags uint32 + F_bsize uint32 + F_iosize uint32 + Pad_cgo_0 [4]byte + F_blocks uint64 + F_bfree uint64 + F_bavail int64 + F_files uint64 + F_ffree uint64 + F_favail int64 + F_syncwrites uint64 + F_syncreads uint64 + F_asyncwrites uint64 + F_asyncreads uint64 + F_fsid Fsid + F_namemax uint32 + F_owner uint32 + F_ctime uint64 + F_fstypename [16]int8 + F_mntonname [90]int8 + F_mntfromname [90]int8 + F_mntfromspec [90]int8 + Pad_cgo_1 [2]byte + Mount_info [160]byte +} + +type Flock_t struct { + Start int64 + Len int64 + Pid int32 + Type int16 + Whence int16 +} + +type Dirent struct { + Fileno uint64 + Off int64 + Reclen uint16 + Type uint8 + Namlen uint8 + X__d_padding [4]uint8 + Name [256]int8 +} + +type Fsid struct { + Val [2]int32 +} + +type RawSockaddrInet4 struct { + Len uint8 + Family uint8 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]int8 +} + +type RawSockaddrInet6 struct { + Len uint8 + Family uint8 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Len uint8 + Family uint8 + Path [104]int8 +} + +type RawSockaddrDatalink struct { + Len uint8 + Family uint8 + Index uint16 + Type uint8 + Nlen uint8 + Alen uint8 + Slen uint8 + Data [24]int8 +} + +type RawSockaddr struct { + Len uint8 + Family uint8 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [92]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint64 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Pad_cgo_0 [4]byte + Iov *Iovec + Iovlen uint32 + Pad_cgo_1 [4]byte + Control *byte + Controllen uint32 + Flags int32 +} + +type Cmsghdr struct { + Len uint32 + Level int32 + Type int32 +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Filt [8]uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x6c + SizeofSockaddrUnix = 0x6a + SizeofSockaddrDatalink = 0x20 + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x30 + SizeofCmsghdr = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 +) + +const ( + PTRACE_TRACEME = 0x0 + PTRACE_CONT = 0x7 + PTRACE_KILL = 0x8 +) + +type Kevent_t struct { + Ident uint64 + Filter int16 + Flags uint16 + Fflags uint32 + Data int64 + Udata *byte +} + +type FdSet struct { + Bits [32]uint32 +} + +const ( + SizeofIfMsghdr = 0xf8 + SizeofIfData = 0xe0 + SizeofIfaMsghdr = 0x18 + SizeofIfAnnounceMsghdr = 0x1a + SizeofRtMsghdr = 0x60 + SizeofRtMetrics = 0x38 +) + +type IfMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Hdrlen uint16 + Index uint16 + Tableid uint16 + Pad1 uint8 + Pad2 uint8 + Addrs int32 + Flags int32 + Xflags int32 + Data IfData +} + +type IfData struct { + Type uint8 + Addrlen uint8 + Hdrlen uint8 + Link_state uint8 + Mtu uint32 + Metric uint32 + Pad uint32 + Baudrate uint64 + Ipackets uint64 + Ierrors uint64 + Opackets uint64 + Oerrors uint64 + Collisions uint64 + Ibytes uint64 + Obytes uint64 + Imcasts uint64 + Omcasts uint64 + Iqdrops uint64 + Noproto uint64 + Capabilities uint32 + Pad_cgo_0 [4]byte + Lastchange Timeval + Mclpool [7]Mclpool + Pad_cgo_1 [4]byte +} + +type IfaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Hdrlen uint16 + Index uint16 + Tableid uint16 + Pad1 uint8 + Pad2 uint8 + Addrs int32 + Flags int32 + Metric int32 +} + +type IfAnnounceMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Hdrlen uint16 + Index uint16 + What uint16 + Name [16]int8 +} + +type RtMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Hdrlen uint16 + Index uint16 + Tableid uint16 + Priority uint8 + Mpls uint8 + Addrs int32 + Flags int32 + Fmask int32 + Pid int32 + Seq int32 + Errno int32 + Inits uint32 + Rmx RtMetrics +} + +type RtMetrics struct { + Pksent uint64 + Expire int64 + Locks uint32 + Mtu uint32 + Refcnt uint32 + Hopcount uint32 + Recvpipe uint32 + Sendpipe uint32 + Ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Pad uint32 +} + +type Mclpool struct { + Grown int32 + Alive uint16 + Hwm uint16 + Cwm uint16 + Lwm uint16 +} + +const ( + SizeofBpfVersion = 0x4 + SizeofBpfStat = 0x8 + SizeofBpfProgram = 0x10 + SizeofBpfInsn = 0x8 + SizeofBpfHdr = 0x14 +) + +type BpfVersion struct { + Major uint16 + Minor uint16 +} + +type BpfStat struct { + Recv uint32 + Drop uint32 +} + +type BpfProgram struct { + Len uint32 + Pad_cgo_0 [4]byte + Insns *BpfInsn +} + +type BpfInsn struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type BpfHdr struct { + Tstamp BpfTimeval + Caplen uint32 + Datalen uint32 + Hdrlen uint16 + Pad_cgo_0 [2]byte +} + +type BpfTimeval struct { + Sec uint32 + Usec uint32 +} + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Cc [20]uint8 + Ispeed int32 + Ospeed int32 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go new file mode 100644 index 0000000000..b3b928a51e --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go @@ -0,0 +1,422 @@ +// +build amd64,solaris +// Created by cgo -godefs - DO NOT EDIT +// cgo -godefs types_solaris.go + +package unix + +const ( + sizeofPtr = 0x8 + sizeofShort = 0x2 + sizeofInt = 0x4 + sizeofLong = 0x8 + sizeofLongLong = 0x8 + PathMax = 0x400 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int64 +} + +type Timeval32 struct { + Sec int32 + Usec int32 +} + +type Tms struct { + Utime int64 + Stime int64 + Cutime int64 + Cstime int64 +} + +type Utimbuf struct { + Actime int64 + Modtime int64 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +const ( + S_IFMT = 0xf000 + S_IFIFO = 0x1000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFBLK = 0x6000 + S_IFREG = 0x8000 + S_IFLNK = 0xa000 + S_IFSOCK = 0xc000 + S_ISUID = 0x800 + S_ISGID = 0x400 + S_ISVTX = 0x200 + S_IRUSR = 0x100 + S_IWUSR = 0x80 + S_IXUSR = 0x40 +) + +type Stat_t struct { + Dev uint64 + Ino uint64 + Mode uint32 + Nlink uint32 + Uid uint32 + Gid uint32 + Rdev uint64 + Size int64 + Atim Timespec + Mtim Timespec + Ctim Timespec + Blksize int32 + Pad_cgo_0 [4]byte + Blocks int64 + Fstype [16]int8 +} + +type Flock_t struct { + Type int16 + Whence int16 + Pad_cgo_0 [4]byte + Start int64 + Len int64 + Sysid int32 + Pid int32 + Pad [4]int64 +} + +type Dirent struct { + Ino uint64 + Off int64 + Reclen uint16 + Name [1]int8 + Pad_cgo_0 [5]byte +} + +type RawSockaddrInet4 struct { + Family uint16 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]int8 +} + +type RawSockaddrInet6 struct { + Family uint16 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 + X__sin6_src_id uint32 +} + +type RawSockaddrUnix struct { + Family uint16 + Path [108]int8 +} + +type RawSockaddrDatalink struct { + Family uint16 + Index uint16 + Type uint8 + Nlen uint8 + Alen uint8 + Slen uint8 + Data [244]int8 +} + +type RawSockaddr struct { + Family uint16 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [236]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *int8 + Len uint64 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Pad_cgo_0 [4]byte + Iov *Iovec + Iovlen int32 + Pad_cgo_1 [4]byte + Accrights *int8 + Accrightslen int32 + Pad_cgo_2 [4]byte +} + +type Cmsghdr struct { + Len uint32 + Level int32 + Type int32 +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + X__icmp6_filt [8]uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x20 + SizeofSockaddrAny = 0xfc + SizeofSockaddrUnix = 0x6e + SizeofSockaddrDatalink = 0xfc + SizeofLinger = 0x8 + SizeofIPMreq = 0x8 + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x30 + SizeofCmsghdr = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x24 + SizeofICMPv6Filter = 0x20 +) + +type FdSet struct { + Bits [1024]int64 +} + +type Utsname struct { + Sysname [257]int8 + Nodename [257]int8 + Release [257]int8 + Version [257]int8 + Machine [257]int8 +} + +type Ustat_t struct { + Tfree int64 + Tinode uint64 + Fname [6]int8 + Fpack [6]int8 + Pad_cgo_0 [4]byte +} + +const ( + AT_FDCWD = 0xffd19553 + AT_SYMLINK_NOFOLLOW = 0x1000 + AT_SYMLINK_FOLLOW = 0x2000 + AT_REMOVEDIR = 0x1 + AT_EACCESS = 0x4 +) + +const ( + SizeofIfMsghdr = 0x54 + SizeofIfData = 0x44 + SizeofIfaMsghdr = 0x14 + SizeofRtMsghdr = 0x4c + SizeofRtMetrics = 0x28 +) + +type IfMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Data IfData +} + +type IfData struct { + Type uint8 + Addrlen uint8 + Hdrlen uint8 + Pad_cgo_0 [1]byte + Mtu uint32 + Metric uint32 + Baudrate uint32 + Ipackets uint32 + Ierrors uint32 + Opackets uint32 + Oerrors uint32 + Collisions uint32 + Ibytes uint32 + Obytes uint32 + Imcasts uint32 + Omcasts uint32 + Iqdrops uint32 + Noproto uint32 + Lastchange Timeval32 +} + +type IfaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Addrs int32 + Flags int32 + Index uint16 + Pad_cgo_0 [2]byte + Metric int32 +} + +type RtMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Index uint16 + Pad_cgo_0 [2]byte + Flags int32 + Addrs int32 + Pid int32 + Seq int32 + Errno int32 + Use int32 + Inits uint32 + Rmx RtMetrics +} + +type RtMetrics struct { + Locks uint32 + Mtu uint32 + Hopcount uint32 + Expire uint32 + Recvpipe uint32 + Sendpipe uint32 + Ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Pksent uint32 +} + +const ( + SizeofBpfVersion = 0x4 + SizeofBpfStat = 0x80 + SizeofBpfProgram = 0x10 + SizeofBpfInsn = 0x8 + SizeofBpfHdr = 0x14 +) + +type BpfVersion struct { + Major uint16 + Minor uint16 +} + +type BpfStat struct { + Recv uint64 + Drop uint64 + Capt uint64 + Padding [13]uint64 +} + +type BpfProgram struct { + Len uint32 + Pad_cgo_0 [4]byte + Insns *BpfInsn +} + +type BpfInsn struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type BpfTimeval struct { + Sec int32 + Usec int32 +} + +type BpfHdr struct { + Tstamp BpfTimeval + Caplen uint32 + Datalen uint32 + Hdrlen uint16 + Pad_cgo_0 [2]byte +} + +const _SC_PAGESIZE = 0xb + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Cc [19]uint8 + Pad_cgo_0 [1]byte +} + +type Termio struct { + Iflag uint16 + Oflag uint16 + Cflag uint16 + Lflag uint16 + Line int8 + Cc [8]uint8 + Pad_cgo_0 [1]byte +} + +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} diff --git a/vendor/golang.org/x/tools/LICENSE b/vendor/golang.org/x/tools/LICENSE new file mode 100644 index 0000000000..6a66aea5ea --- /dev/null +++ b/vendor/golang.org/x/tools/LICENSE @@ -0,0 +1,27 @@ +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. diff --git a/vendor/golang.org/x/tools/PATENTS b/vendor/golang.org/x/tools/PATENTS new file mode 100644 index 0000000000..733099041f --- /dev/null +++ b/vendor/golang.org/x/tools/PATENTS @@ -0,0 +1,22 @@ +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. diff --git a/vendor/golang.org/x/tools/go/vcs/discovery.go b/vendor/golang.org/x/tools/go/vcs/discovery.go new file mode 100644 index 0000000000..c4b0e3d142 --- /dev/null +++ b/vendor/golang.org/x/tools/go/vcs/discovery.go @@ -0,0 +1,76 @@ +// 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. + +package vcs + +import ( + "encoding/xml" + "fmt" + "io" + "strings" +) + +// charsetReader returns a reader for the given charset. Currently +// it only supports UTF-8 and ASCII. Otherwise, it returns a meaningful +// error which is printed by go get, so the user can find why the package +// wasn't downloaded if the encoding is not supported. Note that, in +// order to reduce potential errors, ASCII is treated as UTF-8 (i.e. characters +// greater than 0x7f are not rejected). +func charsetReader(charset string, input io.Reader) (io.Reader, error) { + switch strings.ToLower(charset) { + case "ascii": + return input, nil + default: + return nil, fmt.Errorf("can't decode XML document using charset %q", charset) + } +} + +// parseMetaGoImports returns meta imports from the HTML in r. +// Parsing ends at the end of the section or the beginning of the . +func parseMetaGoImports(r io.Reader) (imports []metaImport, err error) { + d := xml.NewDecoder(r) + d.CharsetReader = charsetReader + d.Strict = false + var t xml.Token + for { + t, err = d.Token() + if err != nil { + if err == io.EOF { + err = nil + } + return + } + if e, ok := t.(xml.StartElement); ok && strings.EqualFold(e.Name.Local, "body") { + return + } + if e, ok := t.(xml.EndElement); ok && strings.EqualFold(e.Name.Local, "head") { + return + } + e, ok := t.(xml.StartElement) + if !ok || !strings.EqualFold(e.Name.Local, "meta") { + continue + } + if attrValue(e.Attr, "name") != "go-import" { + continue + } + if f := strings.Fields(attrValue(e.Attr, "content")); len(f) == 3 { + imports = append(imports, metaImport{ + Prefix: f[0], + VCS: f[1], + RepoRoot: f[2], + }) + } + } +} + +// attrValue returns the attribute value for the case-insensitive key +// `name', or the empty string if nothing is found. +func attrValue(attrs []xml.Attr, name string) string { + for _, a := range attrs { + if strings.EqualFold(a.Name.Local, name) { + return a.Value + } + } + return "" +} diff --git a/vendor/golang.org/x/tools/go/vcs/env.go b/vendor/golang.org/x/tools/go/vcs/env.go new file mode 100644 index 0000000000..e846f5b3b8 --- /dev/null +++ b/vendor/golang.org/x/tools/go/vcs/env.go @@ -0,0 +1,39 @@ +// 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. + +package vcs + +import ( + "os" + "strings" +) + +// envForDir returns a copy of the environment +// suitable for running in the given directory. +// The environment is the current process's environment +// but with an updated $PWD, so that an os.Getwd in the +// child will be faster. +func envForDir(dir string) []string { + env := os.Environ() + // Internally we only use rooted paths, so dir is rooted. + // Even if dir is not rooted, no harm done. + return mergeEnvLists([]string{"PWD=" + dir}, env) +} + +// mergeEnvLists merges the two environment lists such that +// variables with the same name in "in" replace those in "out". +func mergeEnvLists(in, out []string) []string { +NextVar: + for _, inkv := range in { + k := strings.SplitAfterN(inkv, "=", 2)[0] + for i, outkv := range out { + if strings.HasPrefix(outkv, k) { + out[i] = inkv + continue NextVar + } + } + out = append(out, inkv) + } + return out +} diff --git a/vendor/golang.org/x/tools/go/vcs/http.go b/vendor/golang.org/x/tools/go/vcs/http.go new file mode 100644 index 0000000000..96188185cb --- /dev/null +++ b/vendor/golang.org/x/tools/go/vcs/http.go @@ -0,0 +1,80 @@ +// 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. + +package vcs + +import ( + "fmt" + "io" + "io/ioutil" + "log" + "net/http" + "net/url" +) + +// httpClient is the default HTTP client, but a variable so it can be +// changed by tests, without modifying http.DefaultClient. +var httpClient = http.DefaultClient + +// httpGET returns the data from an HTTP GET request for the given URL. +func httpGET(url string) ([]byte, error) { + resp, err := httpClient.Get(url) + if err != nil { + return nil, err + } + defer resp.Body.Close() + if resp.StatusCode != 200 { + return nil, fmt.Errorf("%s: %s", url, resp.Status) + } + b, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil, fmt.Errorf("%s: %v", url, err) + } + return b, nil +} + +// httpsOrHTTP returns the body of either the importPath's +// https resource or, if unavailable, the http resource. +func httpsOrHTTP(importPath string) (urlStr string, body io.ReadCloser, err error) { + fetch := func(scheme string) (urlStr string, res *http.Response, err error) { + u, err := url.Parse(scheme + "://" + importPath) + if err != nil { + return "", nil, err + } + u.RawQuery = "go-get=1" + urlStr = u.String() + if Verbose { + log.Printf("Fetching %s", urlStr) + } + res, err = httpClient.Get(urlStr) + return + } + closeBody := func(res *http.Response) { + if res != nil { + res.Body.Close() + } + } + urlStr, res, err := fetch("https") + if err != nil || res.StatusCode != 200 { + if Verbose { + if err != nil { + log.Printf("https fetch failed.") + } else { + log.Printf("ignoring https fetch with status code %d", res.StatusCode) + } + } + closeBody(res) + urlStr, res, err = fetch("http") + } + if err != nil { + closeBody(res) + return "", nil, err + } + // Note: accepting a non-200 OK here, so people can serve a + // meta import in their http 404 page. + if Verbose { + log.Printf("Parsing meta tags from %s (status code %d)", urlStr, res.StatusCode) + } + return urlStr, res.Body, nil +} diff --git a/vendor/golang.org/x/tools/go/vcs/vcs.go b/vendor/golang.org/x/tools/go/vcs/vcs.go new file mode 100644 index 0000000000..2d9b7de3b3 --- /dev/null +++ b/vendor/golang.org/x/tools/go/vcs/vcs.go @@ -0,0 +1,754 @@ +// 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. + +package vcs // import "golang.org/x/tools/go/vcs" + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + "log" + "os" + "os/exec" + "path/filepath" + "regexp" + "strconv" + "strings" +) + +// Verbose enables verbose operation logging. +var Verbose bool + +// ShowCmd controls whether VCS commands are printed. +var ShowCmd bool + +// A Cmd describes how to use a version control system +// like Mercurial, Git, or Subversion. +type Cmd struct { + Name string + Cmd string // name of binary to invoke command + + CreateCmd string // command to download a fresh copy of a repository + DownloadCmd string // command to download updates into an existing repository + + TagCmd []TagCmd // commands to list tags + TagLookupCmd []TagCmd // commands to lookup tags before running tagSyncCmd + TagSyncCmd string // command to sync to specific tag + TagSyncDefault string // command to sync to default tag + + LogCmd string // command to list repository changelogs in an XML format + + Scheme []string + PingCmd string +} + +// A TagCmd describes a command to list available tags +// that can be passed to Cmd.TagSyncCmd. +type TagCmd struct { + Cmd string // command to list tags + Pattern string // regexp to extract tags from list +} + +// vcsList lists the known version control systems +var vcsList = []*Cmd{ + vcsHg, + vcsGit, + vcsSvn, + vcsBzr, +} + +// ByCmd returns the version control system for the given +// command name (hg, git, svn, bzr). +func ByCmd(cmd string) *Cmd { + for _, vcs := range vcsList { + if vcs.Cmd == cmd { + return vcs + } + } + return nil +} + +// vcsHg describes how to use Mercurial. +var vcsHg = &Cmd{ + Name: "Mercurial", + Cmd: "hg", + + CreateCmd: "clone -U {repo} {dir}", + DownloadCmd: "pull", + + // We allow both tag and branch names as 'tags' + // for selecting a version. This lets people have + // a go.release.r60 branch and a go1 branch + // and make changes in both, without constantly + // editing .hgtags. + TagCmd: []TagCmd{ + {"tags", `^(\S+)`}, + {"branches", `^(\S+)`}, + }, + TagSyncCmd: "update -r {tag}", + TagSyncDefault: "update default", + + LogCmd: "log --encoding=utf-8 --limit={limit} --template={template}", + + Scheme: []string{"https", "http", "ssh"}, + PingCmd: "identify {scheme}://{repo}", +} + +// vcsGit describes how to use Git. +var vcsGit = &Cmd{ + Name: "Git", + Cmd: "git", + + CreateCmd: "clone {repo} {dir}", + DownloadCmd: "pull --ff-only", + + TagCmd: []TagCmd{ + // tags/xxx matches a git tag named xxx + // origin/xxx matches a git branch named xxx on the default remote repository + {"show-ref", `(?:tags|origin)/(\S+)$`}, + }, + TagLookupCmd: []TagCmd{ + {"show-ref tags/{tag} origin/{tag}", `((?:tags|origin)/\S+)$`}, + }, + TagSyncCmd: "checkout {tag}", + TagSyncDefault: "checkout master", + + Scheme: []string{"git", "https", "http", "git+ssh"}, + PingCmd: "ls-remote {scheme}://{repo}", +} + +// vcsBzr describes how to use Bazaar. +var vcsBzr = &Cmd{ + Name: "Bazaar", + Cmd: "bzr", + + CreateCmd: "branch {repo} {dir}", + + // Without --overwrite bzr will not pull tags that changed. + // Replace by --overwrite-tags after http://pad.lv/681792 goes in. + DownloadCmd: "pull --overwrite", + + TagCmd: []TagCmd{{"tags", `^(\S+)`}}, + TagSyncCmd: "update -r {tag}", + TagSyncDefault: "update -r revno:-1", + + Scheme: []string{"https", "http", "bzr", "bzr+ssh"}, + PingCmd: "info {scheme}://{repo}", +} + +// vcsSvn describes how to use Subversion. +var vcsSvn = &Cmd{ + Name: "Subversion", + Cmd: "svn", + + CreateCmd: "checkout {repo} {dir}", + DownloadCmd: "update", + + // There is no tag command in subversion. + // The branch information is all in the path names. + + LogCmd: "log --xml --limit={limit}", + + Scheme: []string{"https", "http", "svn", "svn+ssh"}, + PingCmd: "info {scheme}://{repo}", +} + +func (v *Cmd) String() string { + return v.Name +} + +// run runs the command line cmd in the given directory. +// keyval is a list of key, value pairs. run expands +// instances of {key} in cmd into value, but only after +// splitting cmd into individual arguments. +// If an error occurs, run prints the command line and the +// command's combined stdout+stderr to standard error. +// Otherwise run discards the command's output. +func (v *Cmd) run(dir string, cmd string, keyval ...string) error { + _, err := v.run1(dir, cmd, keyval, true) + return err +} + +// runVerboseOnly is like run but only generates error output to standard error in verbose mode. +func (v *Cmd) runVerboseOnly(dir string, cmd string, keyval ...string) error { + _, err := v.run1(dir, cmd, keyval, false) + return err +} + +// runOutput is like run but returns the output of the command. +func (v *Cmd) runOutput(dir string, cmd string, keyval ...string) ([]byte, error) { + return v.run1(dir, cmd, keyval, true) +} + +// run1 is the generalized implementation of run and runOutput. +func (v *Cmd) run1(dir string, cmdline string, keyval []string, verbose bool) ([]byte, error) { + m := make(map[string]string) + for i := 0; i < len(keyval); i += 2 { + m[keyval[i]] = keyval[i+1] + } + args := strings.Fields(cmdline) + for i, arg := range args { + args[i] = expand(m, arg) + } + + _, err := exec.LookPath(v.Cmd) + if err != nil { + fmt.Fprintf(os.Stderr, + "go: missing %s command. See http://golang.org/s/gogetcmd\n", + v.Name) + return nil, err + } + + cmd := exec.Command(v.Cmd, args...) + cmd.Dir = dir + cmd.Env = envForDir(cmd.Dir) + if ShowCmd { + fmt.Printf("cd %s\n", dir) + fmt.Printf("%s %s\n", v.Cmd, strings.Join(args, " ")) + } + var buf bytes.Buffer + cmd.Stdout = &buf + cmd.Stderr = &buf + err = cmd.Run() + out := buf.Bytes() + if err != nil { + if verbose || Verbose { + fmt.Fprintf(os.Stderr, "# cd %s; %s %s\n", dir, v.Cmd, strings.Join(args, " ")) + os.Stderr.Write(out) + } + return nil, err + } + return out, nil +} + +// Ping pings the repo to determine if scheme used is valid. +// This repo must be pingable with this scheme and VCS. +func (v *Cmd) Ping(scheme, repo string) error { + return v.runVerboseOnly(".", v.PingCmd, "scheme", scheme, "repo", repo) +} + +// Create creates a new copy of repo in dir. +// The parent of dir must exist; dir must not. +func (v *Cmd) Create(dir, repo string) error { + return v.run(".", v.CreateCmd, "dir", dir, "repo", repo) +} + +// CreateAtRev creates a new copy of repo in dir at revision rev. +// The parent of dir must exist; dir must not. +// rev must be a valid revision in repo. +func (v *Cmd) CreateAtRev(dir, repo, rev string) error { + if err := v.Create(dir, repo); err != nil { + return err + } + return v.run(dir, v.TagSyncCmd, "tag", rev) +} + +// Download downloads any new changes for the repo in dir. +// dir must be a valid VCS repo compatible with v. +func (v *Cmd) Download(dir string) error { + return v.run(dir, v.DownloadCmd) +} + +// Tags returns the list of available tags for the repo in dir. +// dir must be a valid VCS repo compatible with v. +func (v *Cmd) Tags(dir string) ([]string, error) { + var tags []string + for _, tc := range v.TagCmd { + out, err := v.runOutput(dir, tc.Cmd) + if err != nil { + return nil, err + } + re := regexp.MustCompile(`(?m-s)` + tc.Pattern) + for _, m := range re.FindAllStringSubmatch(string(out), -1) { + tags = append(tags, m[1]) + } + } + return tags, nil +} + +// TagSync syncs the repo in dir to the named tag, +// which either is a tag returned by tags or is v.TagDefault. +// dir must be a valid VCS repo compatible with v and the tag must exist. +func (v *Cmd) TagSync(dir, tag string) error { + if v.TagSyncCmd == "" { + return nil + } + if tag != "" { + for _, tc := range v.TagLookupCmd { + out, err := v.runOutput(dir, tc.Cmd, "tag", tag) + if err != nil { + return err + } + re := regexp.MustCompile(`(?m-s)` + tc.Pattern) + m := re.FindStringSubmatch(string(out)) + if len(m) > 1 { + tag = m[1] + break + } + } + } + if tag == "" && v.TagSyncDefault != "" { + return v.run(dir, v.TagSyncDefault) + } + return v.run(dir, v.TagSyncCmd, "tag", tag) +} + +// Log logs the changes for the repo in dir. +// dir must be a valid VCS repo compatible with v. +func (v *Cmd) Log(dir, logTemplate string) ([]byte, error) { + if err := v.Download(dir); err != nil { + return []byte{}, err + } + + const N = 50 // how many revisions to grab + return v.runOutput(dir, v.LogCmd, "limit", strconv.Itoa(N), "template", logTemplate) +} + +// LogAtRev logs the change for repo in dir at the rev revision. +// dir must be a valid VCS repo compatible with v. +// rev must be a valid revision for the repo in dir. +func (v *Cmd) LogAtRev(dir, rev, logTemplate string) ([]byte, error) { + if err := v.Download(dir); err != nil { + return []byte{}, err + } + + // Append revision flag to LogCmd. + logAtRevCmd := v.LogCmd + " --rev=" + rev + return v.runOutput(dir, logAtRevCmd, "limit", strconv.Itoa(1), "template", logTemplate) +} + +// A vcsPath describes how to convert an import path into a +// version control system and repository name. +type vcsPath struct { + prefix string // prefix this description applies to + re string // pattern for import path + repo string // repository to use (expand with match of re) + vcs string // version control system to use (expand with match of re) + check func(match map[string]string) error // additional checks + ping bool // ping for scheme to use to download repo + + regexp *regexp.Regexp // cached compiled form of re +} + +// FromDir inspects dir and its parents to determine the +// version control system and code repository to use. +// On return, root is the import path +// corresponding to the root of the repository +// (thus root is a prefix of importPath). +func FromDir(dir, srcRoot string) (vcs *Cmd, root string, err error) { + // Clean and double-check that dir is in (a subdirectory of) srcRoot. + dir = filepath.Clean(dir) + srcRoot = filepath.Clean(srcRoot) + if len(dir) <= len(srcRoot) || dir[len(srcRoot)] != filepath.Separator { + return nil, "", fmt.Errorf("directory %q is outside source root %q", dir, srcRoot) + } + + for len(dir) > len(srcRoot) { + for _, vcs := range vcsList { + if fi, err := os.Stat(filepath.Join(dir, "."+vcs.Cmd)); err == nil && fi.IsDir() { + return vcs, dir[len(srcRoot)+1:], nil + } + } + + // Move to parent. + ndir := filepath.Dir(dir) + if len(ndir) >= len(dir) { + // Shouldn't happen, but just in case, stop. + break + } + dir = ndir + } + + return nil, "", fmt.Errorf("directory %q is not using a known version control system", dir) +} + +// RepoRoot represents a version control system, a repo, and a root of +// where to put it on disk. +type RepoRoot struct { + VCS *Cmd + + // repo is the repository URL, including scheme + Repo string + + // root is the import path corresponding to the root of the + // repository + Root string +} + +// RepoRootForImportPath analyzes importPath to determine the +// version control system, and code repository to use. +func RepoRootForImportPath(importPath string, verbose bool) (*RepoRoot, error) { + rr, err := RepoRootForImportPathStatic(importPath, "") + if err == errUnknownSite { + rr, err = RepoRootForImportDynamic(importPath, verbose) + + // RepoRootForImportDynamic returns error detail + // that is irrelevant if the user didn't intend to use a + // dynamic import in the first place. + // Squelch it. + if err != nil { + if Verbose { + log.Printf("import %q: %v", importPath, err) + } + err = fmt.Errorf("unrecognized import path %q", importPath) + } + } + + if err == nil && strings.Contains(importPath, "...") && strings.Contains(rr.Root, "...") { + // Do not allow wildcards in the repo root. + rr = nil + err = fmt.Errorf("cannot expand ... in %q", importPath) + } + return rr, err +} + +var errUnknownSite = errors.New("dynamic lookup required to find mapping") + +// RepoRootForImportPathStatic attempts to map importPath to a +// RepoRoot using the commonly-used VCS hosting sites in vcsPaths +// (github.com/user/dir), or from a fully-qualified importPath already +// containing its VCS type (foo.com/repo.git/dir) +// +// If scheme is non-empty, that scheme is forced. +func RepoRootForImportPathStatic(importPath, scheme string) (*RepoRoot, error) { + if strings.Contains(importPath, "://") { + return nil, fmt.Errorf("invalid import path %q", importPath) + } + for _, srv := range vcsPaths { + if !strings.HasPrefix(importPath, srv.prefix) { + continue + } + m := srv.regexp.FindStringSubmatch(importPath) + if m == nil { + if srv.prefix != "" { + return nil, fmt.Errorf("invalid %s import path %q", srv.prefix, importPath) + } + continue + } + + // Build map of named subexpression matches for expand. + match := map[string]string{ + "prefix": srv.prefix, + "import": importPath, + } + for i, name := range srv.regexp.SubexpNames() { + if name != "" && match[name] == "" { + match[name] = m[i] + } + } + if srv.vcs != "" { + match["vcs"] = expand(match, srv.vcs) + } + if srv.repo != "" { + match["repo"] = expand(match, srv.repo) + } + if srv.check != nil { + if err := srv.check(match); err != nil { + return nil, err + } + } + vcs := ByCmd(match["vcs"]) + if vcs == nil { + return nil, fmt.Errorf("unknown version control system %q", match["vcs"]) + } + if srv.ping { + if scheme != "" { + match["repo"] = scheme + "://" + match["repo"] + } else { + for _, scheme := range vcs.Scheme { + if vcs.Ping(scheme, match["repo"]) == nil { + match["repo"] = scheme + "://" + match["repo"] + break + } + } + } + } + rr := &RepoRoot{ + VCS: vcs, + Repo: match["repo"], + Root: match["root"], + } + return rr, nil + } + return nil, errUnknownSite +} + +// RepoRootForImportDynamic finds a *RepoRoot for a custom domain that's not +// statically known by RepoRootForImportPathStatic. +// +// This handles "vanity import paths" like "name.tld/pkg/foo". +func RepoRootForImportDynamic(importPath string, verbose bool) (*RepoRoot, error) { + slash := strings.Index(importPath, "/") + if slash < 0 { + return nil, errors.New("import path doesn't contain a slash") + } + host := importPath[:slash] + if !strings.Contains(host, ".") { + return nil, errors.New("import path doesn't contain a hostname") + } + urlStr, body, err := httpsOrHTTP(importPath) + if err != nil { + return nil, fmt.Errorf("http/https fetch: %v", err) + } + defer body.Close() + imports, err := parseMetaGoImports(body) + if err != nil { + return nil, fmt.Errorf("parsing %s: %v", importPath, err) + } + metaImport, err := matchGoImport(imports, importPath) + if err != nil { + if err != errNoMatch { + return nil, fmt.Errorf("parse %s: %v", urlStr, err) + } + return nil, fmt.Errorf("parse %s: no go-import meta tags", urlStr) + } + if verbose { + log.Printf("get %q: found meta tag %#v at %s", importPath, metaImport, urlStr) + } + // If the import was "uni.edu/bob/project", which said the + // prefix was "uni.edu" and the RepoRoot was "evilroot.com", + // make sure we don't trust Bob and check out evilroot.com to + // "uni.edu" yet (possibly overwriting/preempting another + // non-evil student). Instead, first verify the root and see + // if it matches Bob's claim. + if metaImport.Prefix != importPath { + if verbose { + log.Printf("get %q: verifying non-authoritative meta tag", importPath) + } + urlStr0 := urlStr + urlStr, body, err = httpsOrHTTP(metaImport.Prefix) + if err != nil { + return nil, fmt.Errorf("fetch %s: %v", urlStr, err) + } + imports, err := parseMetaGoImports(body) + if err != nil { + return nil, fmt.Errorf("parsing %s: %v", importPath, err) + } + if len(imports) == 0 { + return nil, fmt.Errorf("fetch %s: no go-import meta tag", urlStr) + } + metaImport2, err := matchGoImport(imports, importPath) + if err != nil || metaImport != metaImport2 { + return nil, fmt.Errorf("%s and %s disagree about go-import for %s", urlStr0, urlStr, metaImport.Prefix) + } + } + + if !strings.Contains(metaImport.RepoRoot, "://") { + return nil, fmt.Errorf("%s: invalid repo root %q; no scheme", urlStr, metaImport.RepoRoot) + } + rr := &RepoRoot{ + VCS: ByCmd(metaImport.VCS), + Repo: metaImport.RepoRoot, + Root: metaImport.Prefix, + } + if rr.VCS == nil { + return nil, fmt.Errorf("%s: unknown vcs %q", urlStr, metaImport.VCS) + } + return rr, nil +} + +// metaImport represents the parsed tags from HTML files. +type metaImport struct { + Prefix, VCS, RepoRoot string +} + +// errNoMatch is returned from matchGoImport when there's no applicable match. +var errNoMatch = errors.New("no import match") + +// matchGoImport returns the metaImport from imports matching importPath. +// An error is returned if there are multiple matches. +// errNoMatch is returned if none match. +func matchGoImport(imports []metaImport, importPath string) (_ metaImport, err error) { + match := -1 + for i, im := range imports { + if !strings.HasPrefix(importPath, im.Prefix) { + continue + } + if match != -1 { + err = fmt.Errorf("multiple meta tags match import path %q", importPath) + return + } + match = i + } + if match == -1 { + err = errNoMatch + return + } + return imports[match], nil +} + +// expand rewrites s to replace {k} with match[k] for each key k in match. +func expand(match map[string]string, s string) string { + for k, v := range match { + s = strings.Replace(s, "{"+k+"}", v, -1) + } + return s +} + +// vcsPaths lists the known vcs paths. +var vcsPaths = []*vcsPath{ + // go.googlesource.com + { + prefix: "go.googlesource.com", + re: `^(?Pgo\.googlesource\.com/[A-Za-z0-9_.\-]+/?)$`, + vcs: "git", + repo: "https://{root}", + check: noVCSSuffix, + }, + + // Google Code - new syntax + { + prefix: "code.google.com/", + re: `^(?Pcode\.google\.com/[pr]/(?P[a-z0-9\-]+)(\.(?P[a-z0-9\-]+))?)(/[A-Za-z0-9_.\-]+)*$`, + repo: "https://{root}", + check: googleCodeVCS, + }, + + // Google Code - old syntax + { + re: `^(?P[a-z0-9_\-.]+)\.googlecode\.com/(git|hg|svn)(?P/.*)?$`, + check: oldGoogleCode, + }, + + // Github + { + prefix: "github.com/", + re: `^(?Pgithub\.com/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)(/[A-Za-z0-9_.\-]+)*$`, + vcs: "git", + repo: "https://{root}", + check: noVCSSuffix, + }, + + // Bitbucket + { + prefix: "bitbucket.org/", + re: `^(?Pbitbucket\.org/(?P[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+))(/[A-Za-z0-9_.\-]+)*$`, + repo: "https://{root}", + check: bitbucketVCS, + }, + + // Launchpad + { + prefix: "launchpad.net/", + re: `^(?Plaunchpad\.net/((?P[A-Za-z0-9_.\-]+)(?P/[A-Za-z0-9_.\-]+)?|~[A-Za-z0-9_.\-]+/(\+junk|[A-Za-z0-9_.\-]+)/[A-Za-z0-9_.\-]+))(/[A-Za-z0-9_.\-]+)*$`, + vcs: "bzr", + repo: "https://{root}", + check: launchpadVCS, + }, + + // General syntax for any server. + { + re: `^(?P(?P([a-z0-9.\-]+\.)+[a-z0-9.\-]+(:[0-9]+)?/[A-Za-z0-9_.\-/]*?)\.(?Pbzr|git|hg|svn))(/[A-Za-z0-9_.\-]+)*$`, + ping: true, + }, +} + +func init() { + // fill in cached regexps. + // Doing this eagerly discovers invalid regexp syntax + // without having to run a command that needs that regexp. + for _, srv := range vcsPaths { + srv.regexp = regexp.MustCompile(srv.re) + } +} + +// noVCSSuffix checks that the repository name does not +// end in .foo for any version control system foo. +// The usual culprit is ".git". +func noVCSSuffix(match map[string]string) error { + repo := match["repo"] + for _, vcs := range vcsList { + if strings.HasSuffix(repo, "."+vcs.Cmd) { + return fmt.Errorf("invalid version control suffix in %s path", match["prefix"]) + } + } + return nil +} + +var googleCheckout = regexp.MustCompile(`id="checkoutcmd">(hg|git|svn)`) + +// googleCodeVCS determines the version control system for +// a code.google.com repository, by scraping the project's +// /source/checkout page. +func googleCodeVCS(match map[string]string) error { + if err := noVCSSuffix(match); err != nil { + return err + } + data, err := httpGET(expand(match, "https://code.google.com/p/{project}/source/checkout?repo={subrepo}")) + if err != nil { + return err + } + + if m := googleCheckout.FindSubmatch(data); m != nil { + if vcs := ByCmd(string(m[1])); vcs != nil { + // Subversion requires the old URLs. + // TODO: Test. + if vcs == vcsSvn { + if match["subrepo"] != "" { + return fmt.Errorf("sub-repositories not supported in Google Code Subversion projects") + } + match["repo"] = expand(match, "https://{project}.googlecode.com/svn") + } + match["vcs"] = vcs.Cmd + return nil + } + } + + return fmt.Errorf("unable to detect version control system for code.google.com/ path") +} + +// oldGoogleCode is invoked for old-style foo.googlecode.com paths. +// It prints an error giving the equivalent new path. +func oldGoogleCode(match map[string]string) error { + return fmt.Errorf("invalid Google Code import path: use %s instead", + expand(match, "code.google.com/p/{project}{path}")) +} + +// bitbucketVCS determines the version control system for a +// Bitbucket repository, by using the Bitbucket API. +func bitbucketVCS(match map[string]string) error { + if err := noVCSSuffix(match); err != nil { + return err + } + + var resp struct { + SCM string `json:"scm"` + } + url := expand(match, "https://api.bitbucket.org/1.0/repositories/{bitname}") + data, err := httpGET(url) + if err != nil { + return err + } + if err := json.Unmarshal(data, &resp); err != nil { + return fmt.Errorf("decoding %s: %v", url, err) + } + + if ByCmd(resp.SCM) != nil { + match["vcs"] = resp.SCM + if resp.SCM == "git" { + match["repo"] += ".git" + } + return nil + } + + return fmt.Errorf("unable to detect version control system for bitbucket.org/ path") +} + +// launchpadVCS solves the ambiguity for "lp.net/project/foo". In this case, +// "foo" could be a series name registered in Launchpad with its own branch, +// and it could also be the name of a directory within the main project +// branch one level up. +func launchpadVCS(match map[string]string) error { + if match["project"] == "" || match["series"] == "" { + return nil + } + _, err := httpGET(expand(match, "https://code.launchpad.net/{project}{series}/.bzr/branch-format")) + if err != nil { + match["root"] = expand(match, "launchpad.net/{project}") + match["repo"] = expand(match, "https://{root}") + } + return nil +} diff --git a/vendor/google.golang.org/grpc/LICENSE b/vendor/google.golang.org/grpc/LICENSE new file mode 100644 index 0000000000..f4988b4507 --- /dev/null +++ b/vendor/google.golang.org/grpc/LICENSE @@ -0,0 +1,28 @@ +Copyright 2014, Google Inc. +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. diff --git a/vendor/google.golang.org/grpc/PATENTS b/vendor/google.golang.org/grpc/PATENTS new file mode 100644 index 0000000000..619f9dbfe6 --- /dev/null +++ b/vendor/google.golang.org/grpc/PATENTS @@ -0,0 +1,22 @@ +Additional IP Rights Grant (Patents) + +"This implementation" means the copyrightable works distributed by +Google as part of the GRPC 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 GRPC, 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 GRPC. 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 GRPC or any code incorporated within this +implementation of GRPC 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 GRPC +shall terminate as of the date such litigation is filed. diff --git a/vendor/google.golang.org/grpc/call.go b/vendor/google.golang.org/grpc/call.go new file mode 100644 index 0000000000..504a6e18a8 --- /dev/null +++ b/vendor/google.golang.org/grpc/call.go @@ -0,0 +1,190 @@ +/* + * + * Copyright 2014, Google Inc. + * 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. + * + */ + +package grpc + +import ( + "bytes" + "io" + "time" + + "golang.org/x/net/context" + "golang.org/x/net/trace" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/transport" +) + +// recvResponse receives and parses an RPC response. +// On error, it returns the error and indicates whether the call should be retried. +// +// TODO(zhaoq): Check whether the received message sequence is valid. +func recvResponse(dopts dialOptions, t transport.ClientTransport, c *callInfo, stream *transport.Stream, reply interface{}) error { + // Try to acquire header metadata from the server if there is any. + var err error + c.headerMD, err = stream.Header() + if err != nil { + return err + } + p := &parser{r: stream} + for { + if err = recv(p, dopts.codec, stream, dopts.dc, reply); err != nil { + if err == io.EOF { + break + } + return err + } + } + c.trailerMD = stream.Trailer() + return nil +} + +// sendRequest writes out various information of an RPC such as Context and Message. +func sendRequest(ctx context.Context, codec Codec, compressor Compressor, callHdr *transport.CallHdr, t transport.ClientTransport, args interface{}, opts *transport.Options) (_ *transport.Stream, err error) { + stream, err := t.NewStream(ctx, callHdr) + if err != nil { + return nil, err + } + defer func() { + if err != nil { + if _, ok := err.(transport.ConnectionError); !ok { + t.CloseStream(stream, err) + } + } + }() + var cbuf *bytes.Buffer + if compressor != nil { + cbuf = new(bytes.Buffer) + } + outBuf, err := encode(codec, args, compressor, cbuf) + if err != nil { + return nil, transport.StreamErrorf(codes.Internal, "grpc: %v", err) + } + err = t.Write(stream, outBuf, opts) + if err != nil { + return nil, err + } + // Sent successfully. + return stream, nil +} + +// Invoke is called by the generated code. It sends the RPC request on the +// wire and returns after response is received. +func Invoke(ctx context.Context, method string, args, reply interface{}, cc *ClientConn, opts ...CallOption) (err error) { + var c callInfo + for _, o := range opts { + if err := o.before(&c); err != nil { + return toRPCErr(err) + } + } + defer func() { + for _, o := range opts { + o.after(&c) + } + }() + if EnableTracing { + c.traceInfo.tr = trace.New("grpc.Sent."+methodFamily(method), method) + defer c.traceInfo.tr.Finish() + c.traceInfo.firstLine.client = true + if deadline, ok := ctx.Deadline(); ok { + c.traceInfo.firstLine.deadline = deadline.Sub(time.Now()) + } + c.traceInfo.tr.LazyLog(&c.traceInfo.firstLine, false) + // TODO(dsymonds): Arrange for c.traceInfo.firstLine.remoteAddr to be set. + defer func() { + if err != nil { + c.traceInfo.tr.LazyLog(&fmtStringer{"%v", []interface{}{err}}, true) + c.traceInfo.tr.SetError() + } + }() + } + topts := &transport.Options{ + Last: true, + Delay: false, + } + var ( + lastErr error // record the error that happened + ) + for { + var ( + err error + t transport.ClientTransport + stream *transport.Stream + ) + // TODO(zhaoq): Need a formal spec of retry strategy for non-failfast rpcs. + if lastErr != nil && c.failFast { + return toRPCErr(lastErr) + } + callHdr := &transport.CallHdr{ + Host: cc.authority, + Method: method, + } + if cc.dopts.cp != nil { + callHdr.SendCompress = cc.dopts.cp.Type() + } + t, err = cc.dopts.picker.Pick(ctx) + if err != nil { + if lastErr != nil { + // This was a retry; return the error from the last attempt. + return toRPCErr(lastErr) + } + return toRPCErr(err) + } + if c.traceInfo.tr != nil { + c.traceInfo.tr.LazyLog(&payload{sent: true, msg: args}, true) + } + stream, err = sendRequest(ctx, cc.dopts.codec, cc.dopts.cp, callHdr, t, args, topts) + if err != nil { + if _, ok := err.(transport.ConnectionError); ok { + lastErr = err + continue + } + if lastErr != nil { + return toRPCErr(lastErr) + } + return toRPCErr(err) + } + // Receive the response + lastErr = recvResponse(cc.dopts, t, &c, stream, reply) + if _, ok := lastErr.(transport.ConnectionError); ok { + continue + } + if c.traceInfo.tr != nil { + c.traceInfo.tr.LazyLog(&payload{sent: false, msg: reply}, true) + } + t.CloseStream(stream, lastErr) + if lastErr != nil { + return toRPCErr(lastErr) + } + return Errorf(stream.StatusCode(), stream.StatusDesc()) + } +} diff --git a/vendor/google.golang.org/grpc/clientconn.go b/vendor/google.golang.org/grpc/clientconn.go new file mode 100644 index 0000000000..15d7af6c1e --- /dev/null +++ b/vendor/google.golang.org/grpc/clientconn.go @@ -0,0 +1,590 @@ +/* + * + * Copyright 2014, Google Inc. + * 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. + * + */ + +package grpc + +import ( + "errors" + "fmt" + "net" + "strings" + "sync" + "time" + + "golang.org/x/net/context" + "golang.org/x/net/trace" + "google.golang.org/grpc/credentials" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/transport" +) + +var ( + // ErrUnspecTarget indicates that the target address is unspecified. + ErrUnspecTarget = errors.New("grpc: target is unspecified") + // ErrNoTransportSecurity indicates that there is no transport security + // being set for ClientConn. Users should either set one or explicityly + // call WithInsecure DialOption to disable security. + ErrNoTransportSecurity = errors.New("grpc: no transport security set (use grpc.WithInsecure() explicitly or set credentials)") + // ErrCredentialsMisuse indicates that users want to transmit security infomation + // (e.g., oauth2 token) which requires secure connection on an insecure + // connection. + ErrCredentialsMisuse = errors.New("grpc: the credentials require transport level security (use grpc.WithTransportAuthenticator() to set)") + // ErrClientConnClosing indicates that the operation is illegal because + // the session is closing. + ErrClientConnClosing = errors.New("grpc: the client connection is closing") + // ErrClientConnTimeout indicates that the connection could not be + // established or re-established within the specified timeout. + ErrClientConnTimeout = errors.New("grpc: timed out trying to connect") + // minimum time to give a connection to complete + minConnectTimeout = 20 * time.Second +) + +// dialOptions configure a Dial call. dialOptions are set by the DialOption +// values passed to Dial. +type dialOptions struct { + codec Codec + cp Compressor + dc Decompressor + picker Picker + block bool + insecure bool + copts transport.ConnectOptions +} + +// DialOption configures how we set up the connection. +type DialOption func(*dialOptions) + +// WithCodec returns a DialOption which sets a codec for message marshaling and unmarshaling. +func WithCodec(c Codec) DialOption { + return func(o *dialOptions) { + o.codec = c + } +} + +// WithCompressor returns a DialOption which sets a CompressorGenerator for generating message +// compressor. +func WithCompressor(cp Compressor) DialOption { + return func(o *dialOptions) { + o.cp = cp + } +} + +// WithDecompressor returns a DialOption which sets a DecompressorGenerator for generating +// message decompressor. +func WithDecompressor(dc Decompressor) DialOption { + return func(o *dialOptions) { + o.dc = dc + } +} + +// WithPicker returns a DialOption which sets a picker for connection selection. +func WithPicker(p Picker) DialOption { + return func(o *dialOptions) { + o.picker = p + } +} + +// WithBlock returns a DialOption which makes caller of Dial blocks until the underlying +// connection is up. Without this, Dial returns immediately and connecting the server +// happens in background. +func WithBlock() DialOption { + return func(o *dialOptions) { + o.block = true + } +} + +// WithInsecure returns a DialOption which disables transport security for this ClientConn. +// Note that transport security is required unless WithInsecure is set. +func WithInsecure() DialOption { + return func(o *dialOptions) { + o.insecure = true + } +} + +// WithTransportCredentials returns a DialOption which configures a +// connection level security credentials (e.g., TLS/SSL). +func WithTransportCredentials(creds credentials.TransportAuthenticator) DialOption { + return func(o *dialOptions) { + o.copts.AuthOptions = append(o.copts.AuthOptions, creds) + } +} + +// WithPerRPCCredentials returns a DialOption which sets +// credentials which will place auth state on each outbound RPC. +func WithPerRPCCredentials(creds credentials.Credentials) DialOption { + return func(o *dialOptions) { + o.copts.AuthOptions = append(o.copts.AuthOptions, creds) + } +} + +// WithTimeout returns a DialOption that configures a timeout for dialing a client connection. +func WithTimeout(d time.Duration) DialOption { + return func(o *dialOptions) { + o.copts.Timeout = d + } +} + +// WithDialer returns a DialOption that specifies a function to use for dialing network addresses. +func WithDialer(f func(addr string, timeout time.Duration) (net.Conn, error)) DialOption { + return func(o *dialOptions) { + o.copts.Dialer = f + } +} + +// WithUserAgent returns a DialOption that specifies a user agent string for all the RPCs. +func WithUserAgent(s string) DialOption { + return func(o *dialOptions) { + o.copts.UserAgent = s + } +} + +// Dial creates a client connection the given target. +func Dial(target string, opts ...DialOption) (*ClientConn, error) { + cc := &ClientConn{ + target: target, + } + for _, opt := range opts { + opt(&cc.dopts) + } + if cc.dopts.codec == nil { + // Set the default codec. + cc.dopts.codec = protoCodec{} + } + if cc.dopts.picker == nil { + cc.dopts.picker = &unicastPicker{ + target: target, + } + } + if err := cc.dopts.picker.Init(cc); err != nil { + return nil, err + } + colonPos := strings.LastIndex(target, ":") + if colonPos == -1 { + colonPos = len(target) + } + cc.authority = target[:colonPos] + return cc, nil +} + +// ConnectivityState indicates the state of a client connection. +type ConnectivityState int + +const ( + // Idle indicates the ClientConn is idle. + Idle ConnectivityState = iota + // Connecting indicates the ClienConn is connecting. + Connecting + // Ready indicates the ClientConn is ready for work. + Ready + // TransientFailure indicates the ClientConn has seen a failure but expects to recover. + TransientFailure + // Shutdown indicates the ClientConn has started shutting down. + Shutdown +) + +func (s ConnectivityState) String() string { + switch s { + case Idle: + return "IDLE" + case Connecting: + return "CONNECTING" + case Ready: + return "READY" + case TransientFailure: + return "TRANSIENT_FAILURE" + case Shutdown: + return "SHUTDOWN" + default: + panic(fmt.Sprintf("unknown connectivity state: %d", s)) + } +} + +// ClientConn represents a client connection to an RPC service. +type ClientConn struct { + target string + authority string + dopts dialOptions +} + +// State returns the connectivity state of cc. +// This is EXPERIMENTAL API. +func (cc *ClientConn) State() (ConnectivityState, error) { + return cc.dopts.picker.State() +} + +// WaitForStateChange blocks until the state changes to something other than the sourceState. +// It returns the new state or error. +// This is EXPERIMENTAL API. +func (cc *ClientConn) WaitForStateChange(ctx context.Context, sourceState ConnectivityState) (ConnectivityState, error) { + return cc.dopts.picker.WaitForStateChange(ctx, sourceState) +} + +// Close starts to tear down the ClientConn. +func (cc *ClientConn) Close() error { + return cc.dopts.picker.Close() +} + +// Conn is a client connection to a single destination. +type Conn struct { + target string + dopts dialOptions + resetChan chan int + shutdownChan chan struct{} + events trace.EventLog + + mu sync.Mutex + state ConnectivityState + stateCV *sync.Cond + // ready is closed and becomes nil when a new transport is up or failed + // due to timeout. + ready chan struct{} + transport transport.ClientTransport +} + +// NewConn creates a Conn. +func NewConn(cc *ClientConn) (*Conn, error) { + if cc.target == "" { + return nil, ErrUnspecTarget + } + c := &Conn{ + target: cc.target, + dopts: cc.dopts, + resetChan: make(chan int, 1), + shutdownChan: make(chan struct{}), + } + if EnableTracing { + c.events = trace.NewEventLog("grpc.ClientConn", c.target) + } + if !c.dopts.insecure { + var ok bool + for _, cd := range c.dopts.copts.AuthOptions { + if _, ok := cd.(credentials.TransportAuthenticator); !ok { + continue + } + ok = true + } + if !ok { + return nil, ErrNoTransportSecurity + } + } else { + for _, cd := range c.dopts.copts.AuthOptions { + if cd.RequireTransportSecurity() { + return nil, ErrCredentialsMisuse + } + } + } + c.stateCV = sync.NewCond(&c.mu) + if c.dopts.block { + if err := c.resetTransport(false); err != nil { + c.Close() + return nil, err + } + // Start to monitor the error status of transport. + go c.transportMonitor() + } else { + // Start a goroutine connecting to the server asynchronously. + go func() { + if err := c.resetTransport(false); err != nil { + grpclog.Printf("Failed to dial %s: %v; please retry.", c.target, err) + c.Close() + return + } + c.transportMonitor() + }() + } + return c, nil +} + +// printf records an event in cc's event log, unless cc has been closed. +// REQUIRES cc.mu is held. +func (cc *Conn) printf(format string, a ...interface{}) { + if cc.events != nil { + cc.events.Printf(format, a...) + } +} + +// errorf records an error in cc's event log, unless cc has been closed. +// REQUIRES cc.mu is held. +func (cc *Conn) errorf(format string, a ...interface{}) { + if cc.events != nil { + cc.events.Errorf(format, a...) + } +} + +// State returns the connectivity state of the Conn +func (cc *Conn) State() ConnectivityState { + cc.mu.Lock() + defer cc.mu.Unlock() + return cc.state +} + +// WaitForStateChange blocks until the state changes to something other than the sourceState. +func (cc *Conn) WaitForStateChange(ctx context.Context, sourceState ConnectivityState) (ConnectivityState, error) { + cc.mu.Lock() + defer cc.mu.Unlock() + if sourceState != cc.state { + return cc.state, nil + } + done := make(chan struct{}) + var err error + go func() { + select { + case <-ctx.Done(): + cc.mu.Lock() + err = ctx.Err() + cc.stateCV.Broadcast() + cc.mu.Unlock() + case <-done: + } + }() + defer close(done) + for sourceState == cc.state { + cc.stateCV.Wait() + if err != nil { + return cc.state, err + } + } + return cc.state, nil +} + +// NotifyReset tries to signal the underlying transport needs to be reset due to +// for example a name resolution change in flight. +func (cc *Conn) NotifyReset() { + select { + case cc.resetChan <- 0: + default: + } +} + +func (cc *Conn) resetTransport(closeTransport bool) error { + var retries int + start := time.Now() + for { + cc.mu.Lock() + cc.printf("connecting") + if cc.state == Shutdown { + // cc.Close() has been invoked. + cc.mu.Unlock() + return ErrClientConnClosing + } + cc.state = Connecting + cc.stateCV.Broadcast() + cc.mu.Unlock() + if closeTransport { + cc.transport.Close() + } + // Adjust timeout for the current try. + copts := cc.dopts.copts + if copts.Timeout < 0 { + cc.Close() + return ErrClientConnTimeout + } + if copts.Timeout > 0 { + copts.Timeout -= time.Since(start) + if copts.Timeout <= 0 { + cc.Close() + return ErrClientConnTimeout + } + } + sleepTime := backoff(retries) + timeout := sleepTime + if timeout < minConnectTimeout { + timeout = minConnectTimeout + } + if copts.Timeout == 0 || copts.Timeout > timeout { + copts.Timeout = timeout + } + connectTime := time.Now() + addr, err := cc.dopts.picker.PickAddr() + var newTransport transport.ClientTransport + if err == nil { + newTransport, err = transport.NewClientTransport(addr, &copts) + } + if err != nil { + cc.mu.Lock() + if cc.state == Shutdown { + // cc.Close() has been invoked. + cc.mu.Unlock() + return ErrClientConnClosing + } + cc.errorf("transient failure: %v", err) + cc.state = TransientFailure + cc.stateCV.Broadcast() + if cc.ready != nil { + close(cc.ready) + cc.ready = nil + } + cc.mu.Unlock() + sleepTime -= time.Since(connectTime) + if sleepTime < 0 { + sleepTime = 0 + } + // Fail early before falling into sleep. + if cc.dopts.copts.Timeout > 0 && cc.dopts.copts.Timeout < sleepTime+time.Since(start) { + cc.mu.Lock() + cc.errorf("connection timeout") + cc.mu.Unlock() + cc.Close() + return ErrClientConnTimeout + } + closeTransport = false + time.Sleep(sleepTime) + retries++ + grpclog.Printf("grpc: Conn.resetTransport failed to create client transport: %v; Reconnecting to %q", err, cc.target) + continue + } + cc.mu.Lock() + cc.printf("ready") + if cc.state == Shutdown { + // cc.Close() has been invoked. + cc.mu.Unlock() + newTransport.Close() + return ErrClientConnClosing + } + cc.state = Ready + cc.stateCV.Broadcast() + cc.transport = newTransport + if cc.ready != nil { + close(cc.ready) + cc.ready = nil + } + cc.mu.Unlock() + return nil + } +} + +func (cc *Conn) reconnect() bool { + cc.mu.Lock() + if cc.state == Shutdown { + // cc.Close() has been invoked. + cc.mu.Unlock() + return false + } + cc.state = TransientFailure + cc.stateCV.Broadcast() + cc.mu.Unlock() + if err := cc.resetTransport(true); err != nil { + // The ClientConn is closing. + cc.mu.Lock() + cc.printf("transport exiting: %v", err) + cc.mu.Unlock() + grpclog.Printf("grpc: Conn.transportMonitor exits due to: %v", err) + return false + } + return true +} + +// Run in a goroutine to track the error in transport and create the +// new transport if an error happens. It returns when the channel is closing. +func (cc *Conn) transportMonitor() { + for { + select { + // shutdownChan is needed to detect the teardown when + // the ClientConn is idle (i.e., no RPC in flight). + case <-cc.shutdownChan: + return + case <-cc.resetChan: + if !cc.reconnect() { + return + } + case <-cc.transport.Error(): + if !cc.reconnect() { + return + } + // Tries to drain reset signal if there is any since it is out-dated. + select { + case <-cc.resetChan: + default: + } + } + } +} + +// Wait blocks until i) the new transport is up or ii) ctx is done or iii) cc is closed. +func (cc *Conn) Wait(ctx context.Context) (transport.ClientTransport, error) { + for { + cc.mu.Lock() + switch { + case cc.state == Shutdown: + cc.mu.Unlock() + return nil, ErrClientConnClosing + case cc.state == Ready: + ct := cc.transport + cc.mu.Unlock() + return ct, nil + default: + ready := cc.ready + if ready == nil { + ready = make(chan struct{}) + cc.ready = ready + } + cc.mu.Unlock() + select { + case <-ctx.Done(): + return nil, transport.ContextErr(ctx.Err()) + // Wait until the new transport is ready or failed. + case <-ready: + } + } + } +} + +// Close starts to tear down the Conn. Returns ErrClientConnClosing if +// it has been closed (mostly due to dial time-out). +// TODO(zhaoq): Make this synchronous to avoid unbounded memory consumption in +// some edge cases (e.g., the caller opens and closes many ClientConn's in a +// tight loop. +func (cc *Conn) Close() error { + cc.mu.Lock() + defer cc.mu.Unlock() + if cc.state == Shutdown { + return ErrClientConnClosing + } + cc.state = Shutdown + cc.stateCV.Broadcast() + if cc.events != nil { + cc.events.Finish() + cc.events = nil + } + if cc.ready != nil { + close(cc.ready) + cc.ready = nil + } + if cc.transport != nil { + cc.transport.Close() + } + if cc.shutdownChan != nil { + close(cc.shutdownChan) + } + return nil +} diff --git a/vendor/google.golang.org/grpc/codes/code_string.go b/vendor/google.golang.org/grpc/codes/code_string.go new file mode 100644 index 0000000000..e6762d0845 --- /dev/null +++ b/vendor/google.golang.org/grpc/codes/code_string.go @@ -0,0 +1,16 @@ +// generated by stringer -type=Code; DO NOT EDIT + +package codes + +import "fmt" + +const _Code_name = "OKCanceledUnknownInvalidArgumentDeadlineExceededNotFoundAlreadyExistsPermissionDeniedResourceExhaustedFailedPreconditionAbortedOutOfRangeUnimplementedInternalUnavailableDataLossUnauthenticated" + +var _Code_index = [...]uint8{0, 2, 10, 17, 32, 48, 56, 69, 85, 102, 120, 127, 137, 150, 158, 169, 177, 192} + +func (i Code) String() string { + if i+1 >= Code(len(_Code_index)) { + return fmt.Sprintf("Code(%d)", i) + } + return _Code_name[_Code_index[i]:_Code_index[i+1]] +} diff --git a/vendor/google.golang.org/grpc/codes/codes.go b/vendor/google.golang.org/grpc/codes/codes.go new file mode 100644 index 0000000000..e14b464acf --- /dev/null +++ b/vendor/google.golang.org/grpc/codes/codes.go @@ -0,0 +1,159 @@ +/* + * + * Copyright 2014, Google Inc. + * 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. + * + */ + +// Package codes defines the canonical error codes used by gRPC. It is +// consistent across various languages. +package codes // import "google.golang.org/grpc/codes" + +// A Code is an unsigned 32-bit error code as defined in the gRPC spec. +type Code uint32 + +//go:generate stringer -type=Code + +const ( + // OK is returned on success. + OK Code = 0 + + // Canceled indicates the operation was cancelled (typically by the caller). + Canceled Code = 1 + + // Unknown error. An example of where this error may be returned is + // if a Status value received from another address space belongs to + // an error-space that is not known in this address space. Also + // errors raised by APIs that do not return enough error information + // may be converted to this error. + Unknown Code = 2 + + // InvalidArgument indicates client specified an invalid argument. + // Note that this differs from FailedPrecondition. It indicates arguments + // that are problematic regardless of the state of the system + // (e.g., a malformed file name). + InvalidArgument Code = 3 + + // DeadlineExceeded means operation expired before completion. + // For operations that change the state of the system, this error may be + // returned even if the operation has completed successfully. For + // example, a successful response from a server could have been delayed + // long enough for the deadline to expire. + DeadlineExceeded Code = 4 + + // NotFound means some requested entity (e.g., file or directory) was + // not found. + NotFound Code = 5 + + // AlreadyExists means an attempt to create an entity failed because one + // already exists. + AlreadyExists Code = 6 + + // PermissionDenied indicates the caller does not have permission to + // execute the specified operation. It must not be used for rejections + // caused by exhausting some resource (use ResourceExhausted + // instead for those errors). It must not be + // used if the caller cannot be identified (use Unauthenticated + // instead for those errors). + PermissionDenied Code = 7 + + // Unauthenticated indicates the request does not have valid + // authentication credentials for the operation. + Unauthenticated Code = 16 + + // ResourceExhausted indicates some resource has been exhausted, perhaps + // a per-user quota, or perhaps the entire file system is out of space. + ResourceExhausted Code = 8 + + // FailedPrecondition indicates operation was rejected because the + // system is not in a state required for the operation's execution. + // For example, directory to be deleted may be non-empty, an rmdir + // operation is applied to a non-directory, etc. + // + // A litmus test that may help a service implementor in deciding + // between FailedPrecondition, Aborted, and Unavailable: + // (a) Use Unavailable if the client can retry just the failing call. + // (b) Use Aborted if the client should retry at a higher-level + // (e.g., restarting a read-modify-write sequence). + // (c) Use FailedPrecondition if the client should not retry until + // the system state has been explicitly fixed. E.g., if an "rmdir" + // fails because the directory is non-empty, FailedPrecondition + // should be returned since the client should not retry unless + // they have first fixed up the directory by deleting files from it. + // (d) Use FailedPrecondition if the client performs conditional + // REST Get/Update/Delete on a resource and the resource on the + // server does not match the condition. E.g., conflicting + // read-modify-write on the same resource. + FailedPrecondition Code = 9 + + // Aborted indicates the operation was aborted, typically due to a + // concurrency issue like sequencer check failures, transaction aborts, + // etc. + // + // See litmus test above for deciding between FailedPrecondition, + // Aborted, and Unavailable. + Aborted Code = 10 + + // OutOfRange means operation was attempted past the valid range. + // E.g., seeking or reading past end of file. + // + // Unlike InvalidArgument, this error indicates a problem that may + // be fixed if the system state changes. For example, a 32-bit file + // system will generate InvalidArgument if asked to read at an + // offset that is not in the range [0,2^32-1], but it will generate + // OutOfRange if asked to read from an offset past the current + // file size. + // + // There is a fair bit of overlap between FailedPrecondition and + // OutOfRange. We recommend using OutOfRange (the more specific + // error) when it applies so that callers who are iterating through + // a space can easily look for an OutOfRange error to detect when + // they are done. + OutOfRange Code = 11 + + // Unimplemented indicates operation is not implemented or not + // supported/enabled in this service. + Unimplemented Code = 12 + + // Internal errors. Means some invariants expected by underlying + // system has been broken. If you see one of these errors, + // something is very broken. + Internal Code = 13 + + // Unavailable indicates the service is currently unavailable. + // This is a most likely a transient condition and may be corrected + // by retrying with a backoff. + // + // See litmus test above for deciding between FailedPrecondition, + // Aborted, and Unavailable. + Unavailable Code = 14 + + // DataLoss indicates unrecoverable data loss or corruption. + DataLoss Code = 15 +) diff --git a/vendor/google.golang.org/grpc/credentials/credentials.go b/vendor/google.golang.org/grpc/credentials/credentials.go new file mode 100644 index 0000000000..681f64e445 --- /dev/null +++ b/vendor/google.golang.org/grpc/credentials/credentials.go @@ -0,0 +1,226 @@ +/* + * + * Copyright 2014, Google Inc. + * 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. + * + */ + +// Package credentials implements various credentials supported by gRPC library, +// which encapsulate all the state needed by a client to authenticate with a +// server and make various assertions, e.g., about the client's identity, role, +// or whether it is authorized to make a particular call. +package credentials // import "google.golang.org/grpc/credentials" + +import ( + "crypto/tls" + "crypto/x509" + "fmt" + "io/ioutil" + "net" + "strings" + "time" + + "golang.org/x/net/context" +) + +var ( + // alpnProtoStr are the specified application level protocols for gRPC. + alpnProtoStr = []string{"h2"} +) + +// Credentials defines the common interface all supported credentials must +// implement. +type Credentials interface { + // GetRequestMetadata gets the current request metadata, refreshing + // tokens if required. This should be called by the transport layer on + // each request, and the data should be populated in headers or other + // context. uri is the URI of the entry point for the request. When + // supported by the underlying implementation, ctx can be used for + // timeout and cancellation. + // TODO(zhaoq): Define the set of the qualified keys instead of leaving + // it as an arbitrary string. + GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) + // RequireTransportSecurity indicates whether the credentails requires + // transport security. + RequireTransportSecurity() bool +} + +// ProtocolInfo provides information regarding the gRPC wire protocol version, +// security protocol, security protocol version in use, etc. +type ProtocolInfo struct { + // ProtocolVersion is the gRPC wire protocol version. + ProtocolVersion string + // SecurityProtocol is the security protocol in use. + SecurityProtocol string + // SecurityVersion is the security protocol version. + SecurityVersion string +} + +// AuthInfo defines the common interface for the auth information the users are interested in. +type AuthInfo interface { + AuthType() string +} + +// TransportAuthenticator defines the common interface for all the live gRPC wire +// protocols and supported transport security protocols (e.g., TLS, SSL). +type TransportAuthenticator interface { + // ClientHandshake does the authentication handshake specified by the corresponding + // authentication protocol on rawConn for clients. It returns the authenticated + // connection and the corresponding auth information about the connection. + ClientHandshake(addr string, rawConn net.Conn, timeout time.Duration) (net.Conn, AuthInfo, error) + // ServerHandshake does the authentication handshake for servers. It returns + // the authenticated connection and the corresponding auth information about + // the connection. + ServerHandshake(rawConn net.Conn) (net.Conn, AuthInfo, error) + // Info provides the ProtocolInfo of this TransportAuthenticator. + Info() ProtocolInfo + Credentials +} + +// TLSInfo contains the auth information for a TLS authenticated connection. +// It implements the AuthInfo interface. +type TLSInfo struct { + State tls.ConnectionState +} + +func (t TLSInfo) AuthType() string { + return "tls" +} + +// tlsCreds is the credentials required for authenticating a connection using TLS. +type tlsCreds struct { + // TLS configuration + config tls.Config +} + +func (c tlsCreds) Info() ProtocolInfo { + return ProtocolInfo{ + SecurityProtocol: "tls", + SecurityVersion: "1.2", + } +} + +// GetRequestMetadata returns nil, nil since TLS credentials does not have +// metadata. +func (c *tlsCreds) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { + return nil, nil +} + +func (c *tlsCreds) RequireTransportSecurity() bool { + return true +} + +type timeoutError struct{} + +func (timeoutError) Error() string { return "credentials: Dial timed out" } +func (timeoutError) Timeout() bool { return true } +func (timeoutError) Temporary() bool { return true } + +func (c *tlsCreds) ClientHandshake(addr string, rawConn net.Conn, timeout time.Duration) (_ net.Conn, _ AuthInfo, err error) { + // borrow some code from tls.DialWithDialer + var errChannel chan error + if timeout != 0 { + errChannel = make(chan error, 2) + time.AfterFunc(timeout, func() { + errChannel <- timeoutError{} + }) + } + if c.config.ServerName == "" { + colonPos := strings.LastIndex(addr, ":") + if colonPos == -1 { + colonPos = len(addr) + } + c.config.ServerName = addr[:colonPos] + } + conn := tls.Client(rawConn, &c.config) + if timeout == 0 { + err = conn.Handshake() + } else { + go func() { + errChannel <- conn.Handshake() + }() + err = <-errChannel + } + if err != nil { + rawConn.Close() + return nil, nil, err + } + // TODO(zhaoq): Omit the auth info for client now. It is more for + // information than anything else. + return conn, nil, nil +} + +func (c *tlsCreds) ServerHandshake(rawConn net.Conn) (net.Conn, AuthInfo, error) { + conn := tls.Server(rawConn, &c.config) + if err := conn.Handshake(); err != nil { + rawConn.Close() + return nil, nil, err + } + return conn, TLSInfo{conn.ConnectionState()}, nil +} + +// NewTLS uses c to construct a TransportAuthenticator based on TLS. +func NewTLS(c *tls.Config) TransportAuthenticator { + tc := &tlsCreds{*c} + tc.config.NextProtos = alpnProtoStr + return tc +} + +// NewClientTLSFromCert constructs a TLS from the input certificate for client. +func NewClientTLSFromCert(cp *x509.CertPool, serverName string) TransportAuthenticator { + return NewTLS(&tls.Config{ServerName: serverName, RootCAs: cp}) +} + +// NewClientTLSFromFile constructs a TLS from the input certificate file for client. +func NewClientTLSFromFile(certFile, serverName string) (TransportAuthenticator, error) { + b, err := ioutil.ReadFile(certFile) + if err != nil { + return nil, err + } + cp := x509.NewCertPool() + if !cp.AppendCertsFromPEM(b) { + return nil, fmt.Errorf("credentials: failed to append certificates") + } + return NewTLS(&tls.Config{ServerName: serverName, RootCAs: cp}), nil +} + +// NewServerTLSFromCert constructs a TLS from the input certificate for server. +func NewServerTLSFromCert(cert *tls.Certificate) TransportAuthenticator { + return NewTLS(&tls.Config{Certificates: []tls.Certificate{*cert}}) +} + +// NewServerTLSFromFile constructs a TLS from the input certificate file and key +// file for server. +func NewServerTLSFromFile(certFile, keyFile string) (TransportAuthenticator, error) { + cert, err := tls.LoadX509KeyPair(certFile, keyFile) + if err != nil { + return nil, err + } + return NewTLS(&tls.Config{Certificates: []tls.Certificate{cert}}), nil +} diff --git a/vendor/google.golang.org/grpc/doc.go b/vendor/google.golang.org/grpc/doc.go new file mode 100644 index 0000000000..a35f218852 --- /dev/null +++ b/vendor/google.golang.org/grpc/doc.go @@ -0,0 +1,6 @@ +/* +Package grpc implements an RPC system called gRPC. + +See www.grpc.io for more information about gRPC. +*/ +package grpc // import "google.golang.org/grpc" diff --git a/vendor/google.golang.org/grpc/grpclog/logger.go b/vendor/google.golang.org/grpc/grpclog/logger.go new file mode 100644 index 0000000000..3b2933079e --- /dev/null +++ b/vendor/google.golang.org/grpc/grpclog/logger.go @@ -0,0 +1,93 @@ +/* + * + * Copyright 2015, Google Inc. + * 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. + * + */ + +/* +Package grpclog defines logging for grpc. +*/ +package grpclog // import "google.golang.org/grpc/grpclog" + +import ( + "log" + "os" +) + +// Use golang's standard logger by default. +// Access is not mutex-protected: do not modify except in init() +// functions. +var logger Logger = log.New(os.Stderr, "", log.LstdFlags) + +// Logger mimics golang's standard Logger as an interface. +type Logger interface { + Fatal(args ...interface{}) + Fatalf(format string, args ...interface{}) + Fatalln(args ...interface{}) + Print(args ...interface{}) + Printf(format string, args ...interface{}) + Println(args ...interface{}) +} + +// SetLogger sets the logger that is used in grpc. Call only from +// init() functions. +func SetLogger(l Logger) { + logger = l +} + +// Fatal is equivalent to Print() followed by a call to os.Exit() with a non-zero exit code. +func Fatal(args ...interface{}) { + logger.Fatal(args...) +} + +// Fatalf is equivalent to Printf() followed by a call to os.Exit() with a non-zero exit code. +func Fatalf(format string, args ...interface{}) { + logger.Fatalf(format, args...) +} + +// Fatalln is equivalent to Println() followed by a call to os.Exit()) with a non-zero exit code. +func Fatalln(args ...interface{}) { + logger.Fatalln(args...) +} + +// Print prints to the logger. Arguments are handled in the manner of fmt.Print. +func Print(args ...interface{}) { + logger.Print(args...) +} + +// Printf prints to the logger. Arguments are handled in the manner of fmt.Printf. +func Printf(format string, args ...interface{}) { + logger.Printf(format, args...) +} + +// Println prints to the logger. Arguments are handled in the manner of fmt.Println. +func Println(args ...interface{}) { + logger.Println(args...) +} diff --git a/vendor/google.golang.org/grpc/internal/internal.go b/vendor/google.golang.org/grpc/internal/internal.go new file mode 100644 index 0000000000..5489143a85 --- /dev/null +++ b/vendor/google.golang.org/grpc/internal/internal.go @@ -0,0 +1,49 @@ +/* + * Copyright 2016, Google Inc. + * 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. + * + */ + +// Package internal contains gRPC-internal code for testing, to avoid polluting +// the godoc of the top-level grpc package. +package internal + +// TestingCloseConns closes all existing transports but keeps +// grpcServer.lis accepting new connections. +// +// The provided grpcServer must be of type *grpc.Server. It is untyped +// for circular dependency reasons. +var TestingCloseConns func(grpcServer interface{}) + +// TestingUseHandlerImpl enables the http.Handler-based server implementation. +// It must be called before Serve and requires TLS credentials. +// +// The provided grpcServer must be of type *grpc.Server. It is untyped +// for circular dependency reasons. +var TestingUseHandlerImpl func(grpcServer interface{}) diff --git a/vendor/google.golang.org/grpc/metadata/metadata.go b/vendor/google.golang.org/grpc/metadata/metadata.go new file mode 100644 index 0000000000..52070dbeca --- /dev/null +++ b/vendor/google.golang.org/grpc/metadata/metadata.go @@ -0,0 +1,134 @@ +/* + * + * Copyright 2014, Google Inc. + * 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. + * + */ + +// Package metadata define the structure of the metadata supported by gRPC library. +package metadata // import "google.golang.org/grpc/metadata" + +import ( + "encoding/base64" + "fmt" + "strings" + + "golang.org/x/net/context" +) + +const ( + binHdrSuffix = "-bin" +) + +// encodeKeyValue encodes key and value qualified for transmission via gRPC. +// Transmitting binary headers violates HTTP/2 spec. +// TODO(zhaoq): Maybe check if k is ASCII also. +func encodeKeyValue(k, v string) (string, string) { + k = strings.ToLower(k) + if strings.HasSuffix(k, binHdrSuffix) { + val := base64.StdEncoding.EncodeToString([]byte(v)) + v = string(val) + } + return k, v +} + +// DecodeKeyValue returns the original key and value corresponding to the +// encoded data in k, v. +func DecodeKeyValue(k, v string) (string, string, error) { + if !strings.HasSuffix(k, binHdrSuffix) { + return k, v, nil + } + val, err := base64.StdEncoding.DecodeString(v) + if err != nil { + return "", "", err + } + return k, string(val), nil +} + +// MD is a mapping from metadata keys to values. Users should use the following +// two convenience functions New and Pairs to generate MD. +type MD map[string][]string + +// New creates a MD from given key-value map. +func New(m map[string]string) MD { + md := MD{} + for k, v := range m { + key, val := encodeKeyValue(k, v) + md[key] = append(md[key], val) + } + return md +} + +// Pairs returns an MD formed by the mapping of key, value ... +// Pairs panics if len(kv) is odd. +func Pairs(kv ...string) MD { + if len(kv)%2 == 1 { + panic(fmt.Sprintf("metadata: Pairs got the odd number of input pairs for metadata: %d", len(kv))) + } + md := MD{} + var k string + for i, s := range kv { + if i%2 == 0 { + k = s + continue + } + key, val := encodeKeyValue(k, s) + md[key] = append(md[key], val) + } + return md +} + +// Len returns the number of items in md. +func (md MD) Len() int { + return len(md) +} + +// Copy returns a copy of md. +func (md MD) Copy() MD { + out := MD{} + for k, v := range md { + for _, i := range v { + out[k] = append(out[k], i) + } + } + return out +} + +type mdKey struct{} + +// NewContext creates a new context with md attached. +func NewContext(ctx context.Context, md MD) context.Context { + return context.WithValue(ctx, mdKey{}, md) +} + +// FromContext returns the MD in ctx if it exists. +func FromContext(ctx context.Context) (md MD, ok bool) { + md, ok = ctx.Value(mdKey{}).(MD) + return +} diff --git a/vendor/google.golang.org/grpc/naming/naming.go b/vendor/google.golang.org/grpc/naming/naming.go new file mode 100644 index 0000000000..06605607c3 --- /dev/null +++ b/vendor/google.golang.org/grpc/naming/naming.go @@ -0,0 +1,73 @@ +/* + * + * Copyright 2014, Google Inc. + * 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. + * + */ + +// Package naming defines the naming API and related data structures for gRPC. +// The interface is EXPERIMENTAL and may be suject to change. +package naming + +// Operation defines the corresponding operations for a name resolution change. +type Operation uint8 + +const ( + // Add indicates a new address is added. + Add Operation = iota + // Delete indicates an exisiting address is deleted. + Delete +) + +// Update defines a name resolution update. Notice that it is not valid having both +// empty string Addr and nil Metadata in an Update. +type Update struct { + // Op indicates the operation of the update. + Op Operation + // Addr is the updated address. It is empty string if there is no address update. + Addr string + // Metadata is the updated metadata. It is nil if there is no metadata update. + // Metadata is not required for a custom naming implementation. + Metadata interface{} +} + +// Resolver creates a Watcher for a target to track its resolution changes. +type Resolver interface { + // Resolve creates a Watcher for target. + Resolve(target string) (Watcher, error) +} + +// Watcher watches for the updates on the specified target. +type Watcher interface { + // Next blocks until an update or error happens. It may return one or more + // updates. The first call should get the full set of the results. + Next() ([]*Update, error) + // Close closes the Watcher. + Close() +} diff --git a/vendor/google.golang.org/grpc/peer/peer.go b/vendor/google.golang.org/grpc/peer/peer.go new file mode 100644 index 0000000000..bfa6205ba9 --- /dev/null +++ b/vendor/google.golang.org/grpc/peer/peer.go @@ -0,0 +1,65 @@ +/* + * + * Copyright 2014, Google Inc. + * 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. + * + */ + +// Package peer defines various peer information associated with RPCs and +// corresponding utils. +package peer + +import ( + "net" + + "golang.org/x/net/context" + "google.golang.org/grpc/credentials" +) + +// Peer contains the information of the peer for an RPC. +type Peer struct { + // Addr is the peer address. + Addr net.Addr + // AuthInfo is the authentication information of the transport. + // It is nil if there is no transport security being used. + AuthInfo credentials.AuthInfo +} + +type peerKey struct{} + +// NewContext creates a new context with peer information attached. +func NewContext(ctx context.Context, p *Peer) context.Context { + return context.WithValue(ctx, peerKey{}, p) +} + +// FromContext returns the peer information in ctx if it exists. +func FromContext(ctx context.Context) (p *Peer, ok bool) { + p, ok = ctx.Value(peerKey{}).(*Peer) + return +} diff --git a/vendor/google.golang.org/grpc/picker.go b/vendor/google.golang.org/grpc/picker.go new file mode 100644 index 0000000000..50f315b44f --- /dev/null +++ b/vendor/google.golang.org/grpc/picker.go @@ -0,0 +1,243 @@ +/* + * + * Copyright 2014, Google Inc. + * 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. + * + */ + +package grpc + +import ( + "container/list" + "fmt" + "sync" + + "golang.org/x/net/context" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/naming" + "google.golang.org/grpc/transport" +) + +// Picker picks a Conn for RPC requests. +// This is EXPERIMENTAL and please do not implement your own Picker for now. +type Picker interface { + // Init does initial processing for the Picker, e.g., initiate some connections. + Init(cc *ClientConn) error + // Pick blocks until either a transport.ClientTransport is ready for the upcoming RPC + // or some error happens. + Pick(ctx context.Context) (transport.ClientTransport, error) + // PickAddr picks a peer address for connecting. This will be called repeated for + // connecting/reconnecting. + PickAddr() (string, error) + // State returns the connectivity state of the underlying connections. + State() (ConnectivityState, error) + // WaitForStateChange blocks until the state changes to something other than + // the sourceState. It returns the new state or error. + WaitForStateChange(ctx context.Context, sourceState ConnectivityState) (ConnectivityState, error) + // Close closes all the Conn's owned by this Picker. + Close() error +} + +// unicastPicker is the default Picker which is used when there is no custom Picker +// specified by users. It always picks the same Conn. +type unicastPicker struct { + target string + conn *Conn +} + +func (p *unicastPicker) Init(cc *ClientConn) error { + c, err := NewConn(cc) + if err != nil { + return err + } + p.conn = c + return nil +} + +func (p *unicastPicker) Pick(ctx context.Context) (transport.ClientTransport, error) { + return p.conn.Wait(ctx) +} + +func (p *unicastPicker) PickAddr() (string, error) { + return p.target, nil +} + +func (p *unicastPicker) State() (ConnectivityState, error) { + return p.conn.State(), nil +} + +func (p *unicastPicker) WaitForStateChange(ctx context.Context, sourceState ConnectivityState) (ConnectivityState, error) { + return p.conn.WaitForStateChange(ctx, sourceState) +} + +func (p *unicastPicker) Close() error { + if p.conn != nil { + return p.conn.Close() + } + return nil +} + +// unicastNamingPicker picks an address from a name resolver to set up the connection. +type unicastNamingPicker struct { + cc *ClientConn + resolver naming.Resolver + watcher naming.Watcher + mu sync.Mutex + // The list of the addresses are obtained from watcher. + addrs *list.List + // It tracks the current picked addr by PickAddr(). The next PickAddr may + // push it forward on addrs. + pickedAddr *list.Element + conn *Conn +} + +// NewUnicastNamingPicker creates a Picker to pick addresses from a name resolver +// to connect. +func NewUnicastNamingPicker(r naming.Resolver) Picker { + return &unicastNamingPicker{ + resolver: r, + addrs: list.New(), + } +} + +type addrInfo struct { + addr string + // Set to true if this addrInfo needs to be deleted in the next PickAddrr() call. + deleting bool +} + +// processUpdates calls Watcher.Next() once and processes the obtained updates. +func (p *unicastNamingPicker) processUpdates() error { + updates, err := p.watcher.Next() + if err != nil { + return err + } + for _, update := range updates { + switch update.Op { + case naming.Add: + p.mu.Lock() + p.addrs.PushBack(&addrInfo{ + addr: update.Addr, + }) + p.mu.Unlock() + // Initial connection setup + if p.conn == nil { + conn, err := NewConn(p.cc) + if err != nil { + return err + } + p.conn = conn + } + case naming.Delete: + p.mu.Lock() + for e := p.addrs.Front(); e != nil; e = e.Next() { + if update.Addr == e.Value.(*addrInfo).addr { + if e == p.pickedAddr { + // Do not remove the element now if it is the current picked + // one. We leave the deletion to the next PickAddr() call. + e.Value.(*addrInfo).deleting = true + // Notify Conn to close it. All the live RPCs on this connection + // will be aborted. + p.conn.NotifyReset() + } else { + p.addrs.Remove(e) + } + } + } + p.mu.Unlock() + default: + grpclog.Println("Unknown update.Op ", update.Op) + } + } + return nil +} + +// monitor runs in a standalone goroutine to keep watching name resolution updates until the watcher +// is closed. +func (p *unicastNamingPicker) monitor() { + for { + if err := p.processUpdates(); err != nil { + return + } + } +} + +func (p *unicastNamingPicker) Init(cc *ClientConn) error { + w, err := p.resolver.Resolve(cc.target) + if err != nil { + return err + } + p.watcher = w + p.cc = cc + // Get the initial name resolution. + if err := p.processUpdates(); err != nil { + return err + } + go p.monitor() + return nil +} + +func (p *unicastNamingPicker) Pick(ctx context.Context) (transport.ClientTransport, error) { + return p.conn.Wait(ctx) +} + +func (p *unicastNamingPicker) PickAddr() (string, error) { + p.mu.Lock() + defer p.mu.Unlock() + if p.pickedAddr == nil { + p.pickedAddr = p.addrs.Front() + } else { + pa := p.pickedAddr + p.pickedAddr = pa.Next() + if pa.Value.(*addrInfo).deleting { + p.addrs.Remove(pa) + } + if p.pickedAddr == nil { + p.pickedAddr = p.addrs.Front() + } + } + if p.pickedAddr == nil { + return "", fmt.Errorf("there is no address available to pick") + } + return p.pickedAddr.Value.(*addrInfo).addr, nil +} + +func (p *unicastNamingPicker) State() (ConnectivityState, error) { + return 0, fmt.Errorf("State() is not supported for unicastNamingPicker") +} + +func (p *unicastNamingPicker) WaitForStateChange(ctx context.Context, sourceState ConnectivityState) (ConnectivityState, error) { + return 0, fmt.Errorf("WaitForStateChange is not supported for unicastNamingPciker") +} + +func (p *unicastNamingPicker) Close() error { + p.watcher.Close() + p.conn.Close() + return nil +} diff --git a/vendor/google.golang.org/grpc/rpc_util.go b/vendor/google.golang.org/grpc/rpc_util.go new file mode 100644 index 0000000000..66d34eb95a --- /dev/null +++ b/vendor/google.golang.org/grpc/rpc_util.go @@ -0,0 +1,444 @@ +/* + * + * Copyright 2014, Google Inc. + * 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. + * + */ + +package grpc + +import ( + "bytes" + "compress/gzip" + "encoding/binary" + "fmt" + "io" + "io/ioutil" + "math" + "math/rand" + "os" + "time" + + "github.com/golang/protobuf/proto" + "golang.org/x/net/context" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/transport" +) + +// Codec defines the interface gRPC uses to encode and decode messages. +type Codec interface { + // Marshal returns the wire format of v. + Marshal(v interface{}) ([]byte, error) + // Unmarshal parses the wire format into v. + Unmarshal(data []byte, v interface{}) error + // String returns the name of the Codec implementation. The returned + // string will be used as part of content type in transmission. + String() string +} + +// protoCodec is a Codec implemetation with protobuf. It is the default codec for gRPC. +type protoCodec struct{} + +func (protoCodec) Marshal(v interface{}) ([]byte, error) { + return proto.Marshal(v.(proto.Message)) +} + +func (protoCodec) Unmarshal(data []byte, v interface{}) error { + return proto.Unmarshal(data, v.(proto.Message)) +} + +func (protoCodec) String() string { + return "proto" +} + +// Compressor defines the interface gRPC uses to compress a message. +type Compressor interface { + // Do compresses p into w. + Do(w io.Writer, p []byte) error + // Type returns the compression algorithm the Compressor uses. + Type() string +} + +// NewGZIPCompressor creates a Compressor based on GZIP. +func NewGZIPCompressor() Compressor { + return &gzipCompressor{} +} + +type gzipCompressor struct { +} + +func (c *gzipCompressor) Do(w io.Writer, p []byte) error { + z := gzip.NewWriter(w) + if _, err := z.Write(p); err != nil { + return err + } + return z.Close() +} + +func (c *gzipCompressor) Type() string { + return "gzip" +} + +// Decompressor defines the interface gRPC uses to decompress a message. +type Decompressor interface { + // Do reads the data from r and uncompress them. + Do(r io.Reader) ([]byte, error) + // Type returns the compression algorithm the Decompressor uses. + Type() string +} + +type gzipDecompressor struct { +} + +// NewGZIPDecompressor creates a Decompressor based on GZIP. +func NewGZIPDecompressor() Decompressor { + return &gzipDecompressor{} +} + +func (d *gzipDecompressor) Do(r io.Reader) ([]byte, error) { + z, err := gzip.NewReader(r) + if err != nil { + return nil, err + } + defer z.Close() + return ioutil.ReadAll(z) +} + +func (d *gzipDecompressor) Type() string { + return "gzip" +} + +// callInfo contains all related configuration and information about an RPC. +type callInfo struct { + failFast bool + headerMD metadata.MD + trailerMD metadata.MD + traceInfo traceInfo // in trace.go +} + +// CallOption configures a Call before it starts or extracts information from +// a Call after it completes. +type CallOption interface { + // before is called before the call is sent to any server. If before + // returns a non-nil error, the RPC fails with that error. + before(*callInfo) error + + // after is called after the call has completed. after cannot return an + // error, so any failures should be reported via output parameters. + after(*callInfo) +} + +type beforeCall func(c *callInfo) error + +func (o beforeCall) before(c *callInfo) error { return o(c) } +func (o beforeCall) after(c *callInfo) {} + +type afterCall func(c *callInfo) + +func (o afterCall) before(c *callInfo) error { return nil } +func (o afterCall) after(c *callInfo) { o(c) } + +// Header returns a CallOptions that retrieves the header metadata +// for a unary RPC. +func Header(md *metadata.MD) CallOption { + return afterCall(func(c *callInfo) { + *md = c.headerMD + }) +} + +// Trailer returns a CallOptions that retrieves the trailer metadata +// for a unary RPC. +func Trailer(md *metadata.MD) CallOption { + return afterCall(func(c *callInfo) { + *md = c.trailerMD + }) +} + +// The format of the payload: compressed or not? +type payloadFormat uint8 + +const ( + compressionNone payloadFormat = iota // no compression + compressionMade +) + +// parser reads complelete gRPC messages from the underlying reader. +type parser struct { + // r is the underlying reader. + // See the comment on recvMsg for the permissible + // error types. + r io.Reader + + // The header of a gRPC message. Find more detail + // at http://www.grpc.io/docs/guides/wire.html. + header [5]byte +} + +// recvMsg reads a complete gRPC message from the stream. +// +// It returns the message and its payload (compression/encoding) +// format. The caller owns the returned msg memory. +// +// If there is an error, possible values are: +// * io.EOF, when no messages remain +// * io.ErrUnexpectedEOF +// * of type transport.ConnectionError +// * of type transport.StreamError +// No other error values or types must be returned, which also means +// that the underlying io.Reader must not return an incompatible +// error. +func (p *parser) recvMsg() (pf payloadFormat, msg []byte, err error) { + if _, err := io.ReadFull(p.r, p.header[:]); err != nil { + return 0, nil, err + } + + pf = payloadFormat(p.header[0]) + length := binary.BigEndian.Uint32(p.header[1:]) + + if length == 0 { + return pf, nil, nil + } + // TODO(bradfitz,zhaoq): garbage. reuse buffer after proto decoding instead + // of making it for each message: + msg = make([]byte, int(length)) + if _, err := io.ReadFull(p.r, msg); err != nil { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + return 0, nil, err + } + return pf, msg, nil +} + +// encode serializes msg and prepends the message header. If msg is nil, it +// generates the message header of 0 message length. +func encode(c Codec, msg interface{}, cp Compressor, cbuf *bytes.Buffer) ([]byte, error) { + var b []byte + var length uint + if msg != nil { + var err error + // TODO(zhaoq): optimize to reduce memory alloc and copying. + b, err = c.Marshal(msg) + if err != nil { + return nil, err + } + if cp != nil { + if err := cp.Do(cbuf, b); err != nil { + return nil, err + } + b = cbuf.Bytes() + } + length = uint(len(b)) + } + if length > math.MaxUint32 { + return nil, Errorf(codes.InvalidArgument, "grpc: message too large (%d bytes)", length) + } + + const ( + payloadLen = 1 + sizeLen = 4 + ) + + var buf = make([]byte, payloadLen+sizeLen+len(b)) + + // Write payload format + if cp == nil { + buf[0] = byte(compressionNone) + } else { + buf[0] = byte(compressionMade) + } + // Write length of b into buf + binary.BigEndian.PutUint32(buf[1:], uint32(length)) + // Copy encoded msg to buf + copy(buf[5:], b) + + return buf, nil +} + +func checkRecvPayload(pf payloadFormat, recvCompress string, dc Decompressor) error { + switch pf { + case compressionNone: + case compressionMade: + if recvCompress == "" { + return transport.StreamErrorf(codes.InvalidArgument, "grpc: invalid grpc-encoding %q with compression enabled", recvCompress) + } + if dc == nil || recvCompress != dc.Type() { + return transport.StreamErrorf(codes.InvalidArgument, "grpc: Decompressor is not installed for grpc-encoding %q", recvCompress) + } + default: + return transport.StreamErrorf(codes.InvalidArgument, "grpc: received unexpected payload format %d", pf) + } + return nil +} + +func recv(p *parser, c Codec, s *transport.Stream, dc Decompressor, m interface{}) error { + pf, d, err := p.recvMsg() + if err != nil { + return err + } + if err := checkRecvPayload(pf, s.RecvCompress(), dc); err != nil { + return err + } + if pf == compressionMade { + d, err = dc.Do(bytes.NewReader(d)) + if err != nil { + return transport.StreamErrorf(codes.Internal, "grpc: failed to decompress the received message %v", err) + } + } + if err := c.Unmarshal(d, m); err != nil { + return transport.StreamErrorf(codes.Internal, "grpc: failed to unmarshal the received message %v", err) + } + return nil +} + +// rpcError defines the status from an RPC. +type rpcError struct { + code codes.Code + desc string +} + +func (e rpcError) Error() string { + return fmt.Sprintf("rpc error: code = %d desc = %q", e.code, e.desc) +} + +// Code returns the error code for err if it was produced by the rpc system. +// Otherwise, it returns codes.Unknown. +func Code(err error) codes.Code { + if err == nil { + return codes.OK + } + if e, ok := err.(rpcError); ok { + return e.code + } + return codes.Unknown +} + +// ErrorDesc returns the error description of err if it was produced by the rpc system. +// Otherwise, it returns err.Error() or empty string when err is nil. +func ErrorDesc(err error) string { + if err == nil { + return "" + } + if e, ok := err.(rpcError); ok { + return e.desc + } + return err.Error() +} + +// Errorf returns an error containing an error code and a description; +// Errorf returns nil if c is OK. +func Errorf(c codes.Code, format string, a ...interface{}) error { + if c == codes.OK { + return nil + } + return rpcError{ + code: c, + desc: fmt.Sprintf(format, a...), + } +} + +// toRPCErr converts an error into a rpcError. +func toRPCErr(err error) error { + switch e := err.(type) { + case rpcError: + return err + case transport.StreamError: + return rpcError{ + code: e.Code, + desc: e.Desc, + } + case transport.ConnectionError: + return rpcError{ + code: codes.Internal, + desc: e.Desc, + } + } + return Errorf(codes.Unknown, "%v", err) +} + +// convertCode converts a standard Go error into its canonical code. Note that +// this is only used to translate the error returned by the server applications. +func convertCode(err error) codes.Code { + switch err { + case nil: + return codes.OK + case io.EOF: + return codes.OutOfRange + case io.ErrClosedPipe, io.ErrNoProgress, io.ErrShortBuffer, io.ErrShortWrite, io.ErrUnexpectedEOF: + return codes.FailedPrecondition + case os.ErrInvalid: + return codes.InvalidArgument + case context.Canceled: + return codes.Canceled + case context.DeadlineExceeded: + return codes.DeadlineExceeded + } + switch { + case os.IsExist(err): + return codes.AlreadyExists + case os.IsNotExist(err): + return codes.NotFound + case os.IsPermission(err): + return codes.PermissionDenied + } + return codes.Unknown +} + +const ( + // how long to wait after the first failure before retrying + baseDelay = 1.0 * time.Second + // upper bound of backoff delay + maxDelay = 120 * time.Second + // backoff increases by this factor on each retry + backoffFactor = 1.6 + // backoff is randomized downwards by this factor + backoffJitter = 0.2 +) + +func backoff(retries int) (t time.Duration) { + if retries == 0 { + return baseDelay + } + backoff, max := float64(baseDelay), float64(maxDelay) + for backoff < max && retries > 0 { + backoff *= backoffFactor + retries-- + } + if backoff > max { + backoff = max + } + // Randomize backoff delays so that if a cluster of requests start at + // the same time, they won't operate in lockstep. + backoff *= 1 + backoffJitter*(rand.Float64()*2-1) + if backoff < 0 { + return 0 + } + return time.Duration(backoff) +} diff --git a/vendor/google.golang.org/grpc/server.go b/vendor/google.golang.org/grpc/server.go new file mode 100644 index 0000000000..927b1c5e1e --- /dev/null +++ b/vendor/google.golang.org/grpc/server.go @@ -0,0 +1,785 @@ +/* + * + * Copyright 2014, Google Inc. + * 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. + * + */ + +package grpc + +import ( + "bytes" + "errors" + "fmt" + "io" + "net" + "net/http" + "reflect" + "runtime" + "strings" + "sync" + "time" + + "golang.org/x/net/context" + "golang.org/x/net/http2" + "golang.org/x/net/trace" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/credentials" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/internal" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/transport" +) + +type methodHandler func(srv interface{}, ctx context.Context, dec func(interface{}) error) (interface{}, error) + +// MethodDesc represents an RPC service's method specification. +type MethodDesc struct { + MethodName string + Handler methodHandler +} + +// ServiceDesc represents an RPC service's specification. +type ServiceDesc struct { + ServiceName string + // The pointer to the service interface. Used to check whether the user + // provided implementation satisfies the interface requirements. + HandlerType interface{} + Methods []MethodDesc + Streams []StreamDesc +} + +// service consists of the information of the server serving this service and +// the methods in this service. +type service struct { + server interface{} // the server for service methods + md map[string]*MethodDesc + sd map[string]*StreamDesc +} + +// Server is a gRPC server to serve RPC requests. +type Server struct { + opts options + + mu sync.Mutex // guards following + lis map[net.Listener]bool + conns map[io.Closer]bool + m map[string]*service // service name -> service info + events trace.EventLog +} + +type options struct { + creds credentials.Credentials + codec Codec + cp Compressor + dc Decompressor + maxConcurrentStreams uint32 + useHandlerImpl bool // use http.Handler-based server +} + +// A ServerOption sets options. +type ServerOption func(*options) + +// CustomCodec returns a ServerOption that sets a codec for message marshaling and unmarshaling. +func CustomCodec(codec Codec) ServerOption { + return func(o *options) { + o.codec = codec + } +} + +func RPCCompressor(cp Compressor) ServerOption { + return func(o *options) { + o.cp = cp + } +} + +func RPCDecompressor(dc Decompressor) ServerOption { + return func(o *options) { + o.dc = dc + } +} + +// MaxConcurrentStreams returns a ServerOption that will apply a limit on the number +// of concurrent streams to each ServerTransport. +func MaxConcurrentStreams(n uint32) ServerOption { + return func(o *options) { + o.maxConcurrentStreams = n + } +} + +// Creds returns a ServerOption that sets credentials for server connections. +func Creds(c credentials.Credentials) ServerOption { + return func(o *options) { + o.creds = c + } +} + +// NewServer creates a gRPC server which has no service registered and has not +// started to accept requests yet. +func NewServer(opt ...ServerOption) *Server { + var opts options + for _, o := range opt { + o(&opts) + } + if opts.codec == nil { + // Set the default codec. + opts.codec = protoCodec{} + } + s := &Server{ + lis: make(map[net.Listener]bool), + opts: opts, + conns: make(map[io.Closer]bool), + m: make(map[string]*service), + } + if EnableTracing { + _, file, line, _ := runtime.Caller(1) + s.events = trace.NewEventLog("grpc.Server", fmt.Sprintf("%s:%d", file, line)) + } + return s +} + +// printf records an event in s's event log, unless s has been stopped. +// REQUIRES s.mu is held. +func (s *Server) printf(format string, a ...interface{}) { + if s.events != nil { + s.events.Printf(format, a...) + } +} + +// errorf records an error in s's event log, unless s has been stopped. +// REQUIRES s.mu is held. +func (s *Server) errorf(format string, a ...interface{}) { + if s.events != nil { + s.events.Errorf(format, a...) + } +} + +// RegisterService register a service and its implementation to the gRPC +// server. Called from the IDL generated code. This must be called before +// invoking Serve. +func (s *Server) RegisterService(sd *ServiceDesc, ss interface{}) { + ht := reflect.TypeOf(sd.HandlerType).Elem() + st := reflect.TypeOf(ss) + if !st.Implements(ht) { + grpclog.Fatalf("grpc: Server.RegisterService found the handler of type %v that does not satisfy %v", st, ht) + } + s.register(sd, ss) +} + +func (s *Server) register(sd *ServiceDesc, ss interface{}) { + s.mu.Lock() + defer s.mu.Unlock() + s.printf("RegisterService(%q)", sd.ServiceName) + if _, ok := s.m[sd.ServiceName]; ok { + grpclog.Fatalf("grpc: Server.RegisterService found duplicate service registration for %q", sd.ServiceName) + } + srv := &service{ + server: ss, + md: make(map[string]*MethodDesc), + sd: make(map[string]*StreamDesc), + } + for i := range sd.Methods { + d := &sd.Methods[i] + srv.md[d.MethodName] = d + } + for i := range sd.Streams { + d := &sd.Streams[i] + srv.sd[d.StreamName] = d + } + s.m[sd.ServiceName] = srv +} + +var ( + // ErrServerStopped indicates that the operation is now illegal because of + // the server being stopped. + ErrServerStopped = errors.New("grpc: the server has been stopped") +) + +func (s *Server) useTransportAuthenticator(rawConn net.Conn) (net.Conn, credentials.AuthInfo, error) { + creds, ok := s.opts.creds.(credentials.TransportAuthenticator) + if !ok { + return rawConn, nil, nil + } + return creds.ServerHandshake(rawConn) +} + +// Serve accepts incoming connections on the listener lis, creating a new +// ServerTransport and service goroutine for each. The service goroutines +// read gRPC requests and then call the registered handlers to reply to them. +// Service returns when lis.Accept fails. +func (s *Server) Serve(lis net.Listener) error { + s.mu.Lock() + s.printf("serving") + if s.lis == nil { + s.mu.Unlock() + return ErrServerStopped + } + s.lis[lis] = true + s.mu.Unlock() + defer func() { + lis.Close() + s.mu.Lock() + delete(s.lis, lis) + s.mu.Unlock() + }() + listenerAddr := lis.Addr() + for { + rawConn, err := lis.Accept() + if err != nil { + s.mu.Lock() + s.printf("done serving; Accept = %v", err) + s.mu.Unlock() + return err + } + // Start a new goroutine to deal with rawConn + // so we don't stall this Accept loop goroutine. + go s.handleRawConn(listenerAddr, rawConn) + } +} + +// handleRawConn is run in its own goroutine and handles a just-accepted +// connection that has not had any I/O performed on it yet. +func (s *Server) handleRawConn(listenerAddr net.Addr, rawConn net.Conn) { + conn, authInfo, err := s.useTransportAuthenticator(rawConn) + if err != nil { + s.mu.Lock() + s.errorf("ServerHandshake(%q) failed: %v", rawConn.RemoteAddr(), err) + s.mu.Unlock() + grpclog.Printf("grpc: Server.Serve failed to complete security handshake from %q: %v", rawConn.RemoteAddr(), err) + rawConn.Close() + return + } + + s.mu.Lock() + if s.conns == nil { + s.mu.Unlock() + conn.Close() + return + } + s.mu.Unlock() + + if s.opts.useHandlerImpl { + s.serveUsingHandler(listenerAddr, conn) + } else { + s.serveNewHTTP2Transport(conn, authInfo) + } +} + +// serveNewHTTP2Transport sets up a new http/2 transport (using the +// gRPC http2 server transport in transport/http2_server.go) and +// serves streams on it. +// This is run in its own goroutine (it does network I/O in +// transport.NewServerTransport). +func (s *Server) serveNewHTTP2Transport(c net.Conn, authInfo credentials.AuthInfo) { + st, err := transport.NewServerTransport("http2", c, s.opts.maxConcurrentStreams, authInfo) + if err != nil { + s.mu.Lock() + s.errorf("NewServerTransport(%q) failed: %v", c.RemoteAddr(), err) + s.mu.Unlock() + c.Close() + grpclog.Println("grpc: Server.Serve failed to create ServerTransport: ", err) + return + } + if !s.addConn(st) { + st.Close() + return + } + s.serveStreams(st) +} + +func (s *Server) serveStreams(st transport.ServerTransport) { + defer s.removeConn(st) + defer st.Close() + var wg sync.WaitGroup + st.HandleStreams(func(stream *transport.Stream) { + wg.Add(1) + go func() { + defer wg.Done() + s.handleStream(st, stream, s.traceInfo(st, stream)) + }() + }) + wg.Wait() +} + +var _ http.Handler = (*Server)(nil) + +// serveUsingHandler is called from handleRawConn when s is configured +// to handle requests via the http.Handler interface. It sets up a +// net/http.Server to handle the just-accepted conn. The http.Server +// is configured to route all incoming requests (all HTTP/2 streams) +// to ServeHTTP, which creates a new ServerTransport for each stream. +// serveUsingHandler blocks until conn closes. +// +// This codepath is only used when Server.TestingUseHandlerImpl has +// been configured. This lets the end2end tests exercise the ServeHTTP +// method as one of the environment types. +// +// conn is the *tls.Conn that's already been authenticated. +func (s *Server) serveUsingHandler(listenerAddr net.Addr, conn net.Conn) { + if !s.addConn(conn) { + conn.Close() + return + } + defer s.removeConn(conn) + connDone := make(chan struct{}) + hs := &http.Server{ + Handler: s, + ConnState: func(c net.Conn, cs http.ConnState) { + if cs == http.StateClosed { + close(connDone) + } + }, + } + if err := http2.ConfigureServer(hs, &http2.Server{ + MaxConcurrentStreams: s.opts.maxConcurrentStreams, + }); err != nil { + grpclog.Fatalf("grpc: http2.ConfigureServer: %v", err) + return + } + hs.Serve(&singleConnListener{addr: listenerAddr, conn: conn}) + <-connDone +} + +func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { + st, err := transport.NewServerHandlerTransport(w, r) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + if !s.addConn(st) { + st.Close() + return + } + defer s.removeConn(st) + s.serveStreams(st) +} + +// traceInfo returns a traceInfo and associates it with stream, if tracing is enabled. +// If tracing is not enabled, it returns nil. +func (s *Server) traceInfo(st transport.ServerTransport, stream *transport.Stream) (trInfo *traceInfo) { + if !EnableTracing { + return nil + } + trInfo = &traceInfo{ + tr: trace.New("grpc.Recv."+methodFamily(stream.Method()), stream.Method()), + } + trInfo.firstLine.client = false + trInfo.firstLine.remoteAddr = st.RemoteAddr() + stream.TraceContext(trInfo.tr) + if dl, ok := stream.Context().Deadline(); ok { + trInfo.firstLine.deadline = dl.Sub(time.Now()) + } + return trInfo +} + +func (s *Server) addConn(c io.Closer) bool { + s.mu.Lock() + defer s.mu.Unlock() + if s.conns == nil { + return false + } + s.conns[c] = true + return true +} + +func (s *Server) removeConn(c io.Closer) { + s.mu.Lock() + defer s.mu.Unlock() + if s.conns != nil { + delete(s.conns, c) + } +} + +func (s *Server) sendResponse(t transport.ServerTransport, stream *transport.Stream, msg interface{}, cp Compressor, opts *transport.Options) error { + var cbuf *bytes.Buffer + if cp != nil { + cbuf = new(bytes.Buffer) + } + p, err := encode(s.opts.codec, msg, cp, cbuf) + if err != nil { + // This typically indicates a fatal issue (e.g., memory + // corruption or hardware faults) the application program + // cannot handle. + // + // TODO(zhaoq): There exist other options also such as only closing the + // faulty stream locally and remotely (Other streams can keep going). Find + // the optimal option. + grpclog.Fatalf("grpc: Server failed to encode response %v", err) + } + return t.Write(stream, p, opts) +} + +func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport.Stream, srv *service, md *MethodDesc, trInfo *traceInfo) (err error) { + if trInfo != nil { + defer trInfo.tr.Finish() + trInfo.firstLine.client = false + trInfo.tr.LazyLog(&trInfo.firstLine, false) + defer func() { + if err != nil && err != io.EOF { + trInfo.tr.LazyLog(&fmtStringer{"%v", []interface{}{err}}, true) + trInfo.tr.SetError() + } + }() + } + p := &parser{r: stream} + for { + pf, req, err := p.recvMsg() + if err == io.EOF { + // The entire stream is done (for unary RPC only). + return err + } + if err == io.ErrUnexpectedEOF { + err = transport.StreamError{Code: codes.Internal, Desc: "io.ErrUnexpectedEOF"} + } + if err != nil { + switch err := err.(type) { + case transport.ConnectionError: + // Nothing to do here. + case transport.StreamError: + if err := t.WriteStatus(stream, err.Code, err.Desc); err != nil { + grpclog.Printf("grpc: Server.processUnaryRPC failed to write status %v", err) + } + default: + panic(fmt.Sprintf("grpc: Unexpected error (%T) from recvMsg: %v", err, err)) + } + return err + } + + if err := checkRecvPayload(pf, stream.RecvCompress(), s.opts.dc); err != nil { + switch err := err.(type) { + case transport.StreamError: + if err := t.WriteStatus(stream, err.Code, err.Desc); err != nil { + grpclog.Printf("grpc: Server.processUnaryRPC failed to write status %v", err) + } + default: + if err := t.WriteStatus(stream, codes.Internal, err.Error()); err != nil { + grpclog.Printf("grpc: Server.processUnaryRPC failed to write status %v", err) + } + + } + return err + } + statusCode := codes.OK + statusDesc := "" + df := func(v interface{}) error { + if pf == compressionMade { + var err error + req, err = s.opts.dc.Do(bytes.NewReader(req)) + if err != nil { + if err := t.WriteStatus(stream, codes.Internal, err.Error()); err != nil { + grpclog.Printf("grpc: Server.processUnaryRPC failed to write status %v", err) + } + return err + } + } + if err := s.opts.codec.Unmarshal(req, v); err != nil { + return err + } + if trInfo != nil { + trInfo.tr.LazyLog(&payload{sent: false, msg: v}, true) + } + return nil + } + reply, appErr := md.Handler(srv.server, stream.Context(), df) + if appErr != nil { + if err, ok := appErr.(rpcError); ok { + statusCode = err.code + statusDesc = err.desc + } else { + statusCode = convertCode(appErr) + statusDesc = appErr.Error() + } + if trInfo != nil && statusCode != codes.OK { + trInfo.tr.LazyLog(stringer(statusDesc), true) + trInfo.tr.SetError() + } + if err := t.WriteStatus(stream, statusCode, statusDesc); err != nil { + grpclog.Printf("grpc: Server.processUnaryRPC failed to write status: %v", err) + return err + } + return nil + } + if trInfo != nil { + trInfo.tr.LazyLog(stringer("OK"), false) + } + opts := &transport.Options{ + Last: true, + Delay: false, + } + if s.opts.cp != nil { + stream.SetSendCompress(s.opts.cp.Type()) + } + if err := s.sendResponse(t, stream, reply, s.opts.cp, opts); err != nil { + switch err := err.(type) { + case transport.ConnectionError: + // Nothing to do here. + case transport.StreamError: + statusCode = err.Code + statusDesc = err.Desc + default: + statusCode = codes.Unknown + statusDesc = err.Error() + } + return err + } + if trInfo != nil { + trInfo.tr.LazyLog(&payload{sent: true, msg: reply}, true) + } + return t.WriteStatus(stream, statusCode, statusDesc) + } +} + +func (s *Server) processStreamingRPC(t transport.ServerTransport, stream *transport.Stream, srv *service, sd *StreamDesc, trInfo *traceInfo) (err error) { + if s.opts.cp != nil { + stream.SetSendCompress(s.opts.cp.Type()) + } + ss := &serverStream{ + t: t, + s: stream, + p: &parser{r: stream}, + codec: s.opts.codec, + cp: s.opts.cp, + dc: s.opts.dc, + trInfo: trInfo, + } + if ss.cp != nil { + ss.cbuf = new(bytes.Buffer) + } + if trInfo != nil { + trInfo.tr.LazyLog(&trInfo.firstLine, false) + defer func() { + ss.mu.Lock() + if err != nil && err != io.EOF { + ss.trInfo.tr.LazyLog(&fmtStringer{"%v", []interface{}{err}}, true) + ss.trInfo.tr.SetError() + } + ss.trInfo.tr.Finish() + ss.trInfo.tr = nil + ss.mu.Unlock() + }() + } + if appErr := sd.Handler(srv.server, ss); appErr != nil { + if err, ok := appErr.(rpcError); ok { + ss.statusCode = err.code + ss.statusDesc = err.desc + } else if err, ok := appErr.(transport.StreamError); ok { + ss.statusCode = err.Code + ss.statusDesc = err.Desc + } else { + ss.statusCode = convertCode(appErr) + ss.statusDesc = appErr.Error() + } + } + if trInfo != nil { + ss.mu.Lock() + if ss.statusCode != codes.OK { + ss.trInfo.tr.LazyLog(stringer(ss.statusDesc), true) + ss.trInfo.tr.SetError() + } else { + ss.trInfo.tr.LazyLog(stringer("OK"), false) + } + ss.mu.Unlock() + } + return t.WriteStatus(ss.s, ss.statusCode, ss.statusDesc) + +} + +func (s *Server) handleStream(t transport.ServerTransport, stream *transport.Stream, trInfo *traceInfo) { + sm := stream.Method() + if sm != "" && sm[0] == '/' { + sm = sm[1:] + } + pos := strings.LastIndex(sm, "/") + if pos == -1 { + if trInfo != nil { + trInfo.tr.LazyLog(&fmtStringer{"Malformed method name %q", []interface{}{sm}}, true) + trInfo.tr.SetError() + } + if err := t.WriteStatus(stream, codes.InvalidArgument, fmt.Sprintf("malformed method name: %q", stream.Method())); err != nil { + if trInfo != nil { + trInfo.tr.LazyLog(&fmtStringer{"%v", []interface{}{err}}, true) + trInfo.tr.SetError() + } + grpclog.Printf("grpc: Server.handleStream failed to write status: %v", err) + } + if trInfo != nil { + trInfo.tr.Finish() + } + return + } + service := sm[:pos] + method := sm[pos+1:] + srv, ok := s.m[service] + if !ok { + if trInfo != nil { + trInfo.tr.LazyLog(&fmtStringer{"Unknown service %v", []interface{}{service}}, true) + trInfo.tr.SetError() + } + if err := t.WriteStatus(stream, codes.Unimplemented, fmt.Sprintf("unknown service %v", service)); err != nil { + if trInfo != nil { + trInfo.tr.LazyLog(&fmtStringer{"%v", []interface{}{err}}, true) + trInfo.tr.SetError() + } + grpclog.Printf("grpc: Server.handleStream failed to write status: %v", err) + } + if trInfo != nil { + trInfo.tr.Finish() + } + return + } + // Unary RPC or Streaming RPC? + if md, ok := srv.md[method]; ok { + s.processUnaryRPC(t, stream, srv, md, trInfo) + return + } + if sd, ok := srv.sd[method]; ok { + s.processStreamingRPC(t, stream, srv, sd, trInfo) + return + } + if trInfo != nil { + trInfo.tr.LazyLog(&fmtStringer{"Unknown method %v", []interface{}{method}}, true) + trInfo.tr.SetError() + } + if err := t.WriteStatus(stream, codes.Unimplemented, fmt.Sprintf("unknown method %v", method)); err != nil { + if trInfo != nil { + trInfo.tr.LazyLog(&fmtStringer{"%v", []interface{}{err}}, true) + trInfo.tr.SetError() + } + grpclog.Printf("grpc: Server.handleStream failed to write status: %v", err) + } + if trInfo != nil { + trInfo.tr.Finish() + } +} + +// Stop stops the gRPC server. It immediately closes all open +// connections and listeners. +// It cancels all active RPCs on the server side and the corresponding +// pending RPCs on the client side will get notified by connection +// errors. +func (s *Server) Stop() { + s.mu.Lock() + listeners := s.lis + s.lis = nil + cs := s.conns + s.conns = nil + s.mu.Unlock() + + for lis := range listeners { + lis.Close() + } + for c := range cs { + c.Close() + } + + s.mu.Lock() + if s.events != nil { + s.events.Finish() + s.events = nil + } + s.mu.Unlock() +} + +func init() { + internal.TestingCloseConns = func(arg interface{}) { + arg.(*Server).testingCloseConns() + } + internal.TestingUseHandlerImpl = func(arg interface{}) { + arg.(*Server).opts.useHandlerImpl = true + } +} + +// testingCloseConns closes all existing transports but keeps s.lis +// accepting new connections. +func (s *Server) testingCloseConns() { + s.mu.Lock() + for c := range s.conns { + c.Close() + delete(s.conns, c) + } + s.mu.Unlock() +} + +// SendHeader sends header metadata. It may be called at most once from a unary +// RPC handler. The ctx is the RPC handler's Context or one derived from it. +func SendHeader(ctx context.Context, md metadata.MD) error { + if md.Len() == 0 { + return nil + } + stream, ok := transport.StreamFromContext(ctx) + if !ok { + return fmt.Errorf("grpc: failed to fetch the stream from the context %v", ctx) + } + t := stream.ServerTransport() + if t == nil { + grpclog.Fatalf("grpc: SendHeader: %v has no ServerTransport to send header metadata.", stream) + } + return t.WriteHeader(stream, md) +} + +// SetTrailer sets the trailer metadata that will be sent when an RPC returns. +// It may be called at most once from a unary RPC handler. The ctx is the RPC +// handler's Context or one derived from it. +func SetTrailer(ctx context.Context, md metadata.MD) error { + if md.Len() == 0 { + return nil + } + stream, ok := transport.StreamFromContext(ctx) + if !ok { + return fmt.Errorf("grpc: failed to fetch the stream from the context %v", ctx) + } + return stream.SetTrailer(md) +} + +// singleConnListener is a net.Listener that yields a single conn. +type singleConnListener struct { + mu sync.Mutex + addr net.Addr + conn net.Conn // nil if done +} + +func (ln *singleConnListener) Addr() net.Addr { return ln.addr } + +func (ln *singleConnListener) Close() error { + ln.mu.Lock() + defer ln.mu.Unlock() + ln.conn = nil + return nil +} + +func (ln *singleConnListener) Accept() (net.Conn, error) { + ln.mu.Lock() + defer ln.mu.Unlock() + c := ln.conn + if c == nil { + return nil, io.EOF + } + ln.conn = nil + return c, nil +} diff --git a/vendor/google.golang.org/grpc/stream.go b/vendor/google.golang.org/grpc/stream.go new file mode 100644 index 0000000000..dba7f6c420 --- /dev/null +++ b/vendor/google.golang.org/grpc/stream.go @@ -0,0 +1,411 @@ +/* + * + * Copyright 2014, Google Inc. + * 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. + * + */ + +package grpc + +import ( + "bytes" + "errors" + "io" + "sync" + "time" + + "golang.org/x/net/context" + "golang.org/x/net/trace" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/transport" +) + +type streamHandler func(srv interface{}, stream ServerStream) error + +// StreamDesc represents a streaming RPC service's method specification. +type StreamDesc struct { + StreamName string + Handler streamHandler + + // At least one of these is true. + ServerStreams bool + ClientStreams bool +} + +// Stream defines the common interface a client or server stream has to satisfy. +type Stream interface { + // Context returns the context for this stream. + Context() context.Context + // SendMsg blocks until it sends m, the stream is done or the stream + // breaks. + // On error, it aborts the stream and returns an RPC status on client + // side. On server side, it simply returns the error to the caller. + // SendMsg is called by generated code. + SendMsg(m interface{}) error + // RecvMsg blocks until it receives a message or the stream is + // done. On client side, it returns io.EOF when the stream is done. On + // any other error, it aborts the stream and returns an RPC status. On + // server side, it simply returns the error to the caller. + RecvMsg(m interface{}) error +} + +// ClientStream defines the interface a client stream has to satify. +type ClientStream interface { + // Header returns the header metedata received from the server if there + // is any. It blocks if the metadata is not ready to read. + Header() (metadata.MD, error) + // Trailer returns the trailer metadata from the server. It must be called + // after stream.Recv() returns non-nil error (including io.EOF) for + // bi-directional streaming and server streaming or stream.CloseAndRecv() + // returns for client streaming in order to receive trailer metadata if + // present. Otherwise, it could returns an empty MD even though trailer + // is present. + Trailer() metadata.MD + // CloseSend closes the send direction of the stream. It closes the stream + // when non-nil error is met. + CloseSend() error + Stream +} + +// NewClientStream creates a new Stream for the client side. This is called +// by generated code. +func NewClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, opts ...CallOption) (ClientStream, error) { + var ( + t transport.ClientTransport + err error + ) + t, err = cc.dopts.picker.Pick(ctx) + if err != nil { + return nil, toRPCErr(err) + } + // TODO(zhaoq): CallOption is omitted. Add support when it is needed. + callHdr := &transport.CallHdr{ + Host: cc.authority, + Method: method, + Flush: desc.ServerStreams && desc.ClientStreams, + } + if cc.dopts.cp != nil { + callHdr.SendCompress = cc.dopts.cp.Type() + } + cs := &clientStream{ + desc: desc, + codec: cc.dopts.codec, + cp: cc.dopts.cp, + dc: cc.dopts.dc, + tracing: EnableTracing, + } + if cc.dopts.cp != nil { + callHdr.SendCompress = cc.dopts.cp.Type() + cs.cbuf = new(bytes.Buffer) + } + if cs.tracing { + cs.trInfo.tr = trace.New("grpc.Sent."+methodFamily(method), method) + cs.trInfo.firstLine.client = true + if deadline, ok := ctx.Deadline(); ok { + cs.trInfo.firstLine.deadline = deadline.Sub(time.Now()) + } + cs.trInfo.tr.LazyLog(&cs.trInfo.firstLine, false) + ctx = trace.NewContext(ctx, cs.trInfo.tr) + } + s, err := t.NewStream(ctx, callHdr) + if err != nil { + cs.finish(err) + return nil, toRPCErr(err) + } + cs.t = t + cs.s = s + cs.p = &parser{r: s} + // Listen on ctx.Done() to detect cancellation when there is no pending + // I/O operations on this stream. + go func() { + select { + case <-t.Error(): + // Incur transport error, simply exit. + case <-s.Context().Done(): + err := s.Context().Err() + cs.finish(err) + cs.closeTransportStream(transport.ContextErr(err)) + } + }() + return cs, nil +} + +// clientStream implements a client side Stream. +type clientStream struct { + t transport.ClientTransport + s *transport.Stream + p *parser + desc *StreamDesc + codec Codec + cp Compressor + cbuf *bytes.Buffer + dc Decompressor + + tracing bool // set to EnableTracing when the clientStream is created. + + mu sync.Mutex + closed bool + // trInfo.tr is set when the clientStream is created (if EnableTracing is true), + // and is set to nil when the clientStream's finish method is called. + trInfo traceInfo +} + +func (cs *clientStream) Context() context.Context { + return cs.s.Context() +} + +func (cs *clientStream) Header() (metadata.MD, error) { + m, err := cs.s.Header() + if err != nil { + if _, ok := err.(transport.ConnectionError); !ok { + cs.closeTransportStream(err) + } + } + return m, err +} + +func (cs *clientStream) Trailer() metadata.MD { + return cs.s.Trailer() +} + +func (cs *clientStream) SendMsg(m interface{}) (err error) { + if cs.tracing { + cs.mu.Lock() + if cs.trInfo.tr != nil { + cs.trInfo.tr.LazyLog(&payload{sent: true, msg: m}, true) + } + cs.mu.Unlock() + } + defer func() { + if err != nil { + cs.finish(err) + } + if err == nil || err == io.EOF { + return + } + if _, ok := err.(transport.ConnectionError); !ok { + cs.closeTransportStream(err) + } + err = toRPCErr(err) + }() + out, err := encode(cs.codec, m, cs.cp, cs.cbuf) + defer func() { + if cs.cbuf != nil { + cs.cbuf.Reset() + } + }() + if err != nil { + return transport.StreamErrorf(codes.Internal, "grpc: %v", err) + } + return cs.t.Write(cs.s, out, &transport.Options{Last: false}) +} + +func (cs *clientStream) RecvMsg(m interface{}) (err error) { + err = recv(cs.p, cs.codec, cs.s, cs.dc, m) + defer func() { + // err != nil indicates the termination of the stream. + if err != nil { + cs.finish(err) + } + }() + if err == nil { + if cs.tracing { + cs.mu.Lock() + if cs.trInfo.tr != nil { + cs.trInfo.tr.LazyLog(&payload{sent: false, msg: m}, true) + } + cs.mu.Unlock() + } + if !cs.desc.ClientStreams || cs.desc.ServerStreams { + return + } + // Special handling for client streaming rpc. + err = recv(cs.p, cs.codec, cs.s, cs.dc, m) + cs.closeTransportStream(err) + if err == nil { + return toRPCErr(errors.New("grpc: client streaming protocol violation: get , want ")) + } + if err == io.EOF { + if cs.s.StatusCode() == codes.OK { + cs.finish(err) + return nil + } + return Errorf(cs.s.StatusCode(), cs.s.StatusDesc()) + } + return toRPCErr(err) + } + if _, ok := err.(transport.ConnectionError); !ok { + cs.closeTransportStream(err) + } + if err == io.EOF { + if cs.s.StatusCode() == codes.OK { + // Returns io.EOF to indicate the end of the stream. + return + } + return Errorf(cs.s.StatusCode(), cs.s.StatusDesc()) + } + return toRPCErr(err) +} + +func (cs *clientStream) CloseSend() (err error) { + err = cs.t.Write(cs.s, nil, &transport.Options{Last: true}) + defer func() { + if err != nil { + cs.finish(err) + } + }() + if err == nil || err == io.EOF { + return + } + if _, ok := err.(transport.ConnectionError); !ok { + cs.closeTransportStream(err) + } + err = toRPCErr(err) + return +} + +func (cs *clientStream) closeTransportStream(err error) { + cs.mu.Lock() + if cs.closed { + cs.mu.Unlock() + return + } + cs.closed = true + cs.mu.Unlock() + cs.t.CloseStream(cs.s, err) +} + +func (cs *clientStream) finish(err error) { + if !cs.tracing { + return + } + cs.mu.Lock() + defer cs.mu.Unlock() + if cs.trInfo.tr != nil { + if err == nil || err == io.EOF { + cs.trInfo.tr.LazyPrintf("RPC: [OK]") + } else { + cs.trInfo.tr.LazyPrintf("RPC: [%v]", err) + cs.trInfo.tr.SetError() + } + cs.trInfo.tr.Finish() + cs.trInfo.tr = nil + } +} + +// ServerStream defines the interface a server stream has to satisfy. +type ServerStream interface { + // SendHeader sends the header metadata. It should not be called + // after SendProto. It fails if called multiple times or if + // called after SendProto. + SendHeader(metadata.MD) error + // SetTrailer sets the trailer metadata which will be sent with the + // RPC status. + SetTrailer(metadata.MD) + Stream +} + +// serverStream implements a server side Stream. +type serverStream struct { + t transport.ServerTransport + s *transport.Stream + p *parser + codec Codec + cp Compressor + dc Decompressor + cbuf *bytes.Buffer + statusCode codes.Code + statusDesc string + trInfo *traceInfo + + mu sync.Mutex // protects trInfo.tr after the service handler runs. +} + +func (ss *serverStream) Context() context.Context { + return ss.s.Context() +} + +func (ss *serverStream) SendHeader(md metadata.MD) error { + return ss.t.WriteHeader(ss.s, md) +} + +func (ss *serverStream) SetTrailer(md metadata.MD) { + if md.Len() == 0 { + return + } + ss.s.SetTrailer(md) + return +} + +func (ss *serverStream) SendMsg(m interface{}) (err error) { + defer func() { + if ss.trInfo != nil { + ss.mu.Lock() + if ss.trInfo.tr != nil { + if err == nil { + ss.trInfo.tr.LazyLog(&payload{sent: true, msg: m}, true) + } else { + ss.trInfo.tr.LazyLog(&fmtStringer{"%v", []interface{}{err}}, true) + ss.trInfo.tr.SetError() + } + } + ss.mu.Unlock() + } + }() + out, err := encode(ss.codec, m, ss.cp, ss.cbuf) + defer func() { + if ss.cbuf != nil { + ss.cbuf.Reset() + } + }() + if err != nil { + err = transport.StreamErrorf(codes.Internal, "grpc: %v", err) + return err + } + return ss.t.Write(ss.s, out, &transport.Options{Last: false}) +} + +func (ss *serverStream) RecvMsg(m interface{}) (err error) { + defer func() { + if ss.trInfo != nil { + ss.mu.Lock() + if ss.trInfo.tr != nil { + if err == nil { + ss.trInfo.tr.LazyLog(&payload{sent: false, msg: m}, true) + } else if err != io.EOF { + ss.trInfo.tr.LazyLog(&fmtStringer{"%v", []interface{}{err}}, true) + ss.trInfo.tr.SetError() + } + } + ss.mu.Unlock() + } + }() + return recv(ss.p, ss.codec, ss.s, ss.dc, m) +} diff --git a/vendor/google.golang.org/grpc/trace.go b/vendor/google.golang.org/grpc/trace.go new file mode 100644 index 0000000000..cde04fbfc9 --- /dev/null +++ b/vendor/google.golang.org/grpc/trace.go @@ -0,0 +1,120 @@ +/* + * + * Copyright 2015, Google Inc. + * 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. + * + */ + +package grpc + +import ( + "bytes" + "fmt" + "io" + "net" + "strings" + "time" + + "golang.org/x/net/trace" +) + +// EnableTracing controls whether to trace RPCs using the golang.org/x/net/trace package. +// This should only be set before any RPCs are sent or received by this program. +var EnableTracing = true + +// methodFamily returns the trace family for the given method. +// It turns "/pkg.Service/GetFoo" into "pkg.Service". +func methodFamily(m string) string { + m = strings.TrimPrefix(m, "/") // remove leading slash + if i := strings.Index(m, "/"); i >= 0 { + m = m[:i] // remove everything from second slash + } + if i := strings.LastIndex(m, "."); i >= 0 { + m = m[i+1:] // cut down to last dotted component + } + return m +} + +// traceInfo contains tracing information for an RPC. +type traceInfo struct { + tr trace.Trace + firstLine firstLine +} + +// firstLine is the first line of an RPC trace. +type firstLine struct { + client bool // whether this is a client (outgoing) RPC + remoteAddr net.Addr + deadline time.Duration // may be zero +} + +func (f *firstLine) String() string { + var line bytes.Buffer + io.WriteString(&line, "RPC: ") + if f.client { + io.WriteString(&line, "to") + } else { + io.WriteString(&line, "from") + } + fmt.Fprintf(&line, " %v deadline:", f.remoteAddr) + if f.deadline != 0 { + fmt.Fprint(&line, f.deadline) + } else { + io.WriteString(&line, "none") + } + return line.String() +} + +// payload represents an RPC request or response payload. +type payload struct { + sent bool // whether this is an outgoing payload + msg interface{} // e.g. a proto.Message + // TODO(dsymonds): add stringifying info to codec, and limit how much we hold here? +} + +func (p payload) String() string { + if p.sent { + return fmt.Sprintf("sent: %v", p.msg) + } else { + return fmt.Sprintf("recv: %v", p.msg) + } +} + +type fmtStringer struct { + format string + a []interface{} +} + +func (f *fmtStringer) String() string { + return fmt.Sprintf(f.format, f.a...) +} + +type stringer string + +func (s stringer) String() string { return string(s) } diff --git a/vendor/google.golang.org/grpc/transport/control.go b/vendor/google.golang.org/grpc/transport/control.go new file mode 100644 index 0000000000..f6b38a5a6d --- /dev/null +++ b/vendor/google.golang.org/grpc/transport/control.go @@ -0,0 +1,260 @@ +/* + * + * Copyright 2014, Google Inc. + * 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. + * + */ + +package transport + +import ( + "fmt" + "sync" + + "golang.org/x/net/http2" +) + +const ( + // The default value of flow control window size in HTTP2 spec. + defaultWindowSize = 65535 + // The initial window size for flow control. + initialWindowSize = defaultWindowSize // for an RPC + initialConnWindowSize = defaultWindowSize * 16 // for a connection +) + +// The following defines various control items which could flow through +// the control buffer of transport. They represent different aspects of +// control tasks, e.g., flow control, settings, streaming resetting, etc. +type windowUpdate struct { + streamID uint32 + increment uint32 +} + +func (windowUpdate) isItem() bool { + return true +} + +type settings struct { + ack bool + ss []http2.Setting +} + +func (settings) isItem() bool { + return true +} + +type resetStream struct { + streamID uint32 + code http2.ErrCode +} + +func (resetStream) isItem() bool { + return true +} + +type flushIO struct { +} + +func (flushIO) isItem() bool { + return true +} + +type ping struct { + ack bool + data [8]byte +} + +func (ping) isItem() bool { + return true +} + +// quotaPool is a pool which accumulates the quota and sends it to acquire() +// when it is available. +type quotaPool struct { + c chan int + + mu sync.Mutex + quota int +} + +// newQuotaPool creates a quotaPool which has quota q available to consume. +func newQuotaPool(q int) *quotaPool { + qb := "aPool{ + c: make(chan int, 1), + } + if q > 0 { + qb.c <- q + } else { + qb.quota = q + } + return qb +} + +// add adds n to the available quota and tries to send it on acquire. +func (qb *quotaPool) add(n int) { + qb.mu.Lock() + defer qb.mu.Unlock() + qb.quota += n + if qb.quota <= 0 { + return + } + select { + case qb.c <- qb.quota: + qb.quota = 0 + default: + } +} + +// cancel cancels the pending quota sent on acquire, if any. +func (qb *quotaPool) cancel() { + qb.mu.Lock() + defer qb.mu.Unlock() + select { + case n := <-qb.c: + qb.quota += n + default: + } +} + +// reset cancels the pending quota sent on acquired, incremented by v and sends +// it back on acquire. +func (qb *quotaPool) reset(v int) { + qb.mu.Lock() + defer qb.mu.Unlock() + select { + case n := <-qb.c: + qb.quota += n + default: + } + qb.quota += v + if qb.quota <= 0 { + return + } + select { + case qb.c <- qb.quota: + qb.quota = 0 + default: + } +} + +// acquire returns the channel on which available quota amounts are sent. +func (qb *quotaPool) acquire() <-chan int { + return qb.c +} + +// inFlow deals with inbound flow control +type inFlow struct { + // The inbound flow control limit for pending data. + limit uint32 + // conn points to the shared connection-level inFlow that is shared + // by all streams on that conn. It is nil for the inFlow on the conn + // directly. + conn *inFlow + + mu sync.Mutex + // pendingData is the overall data which have been received but not been + // consumed by applications. + pendingData uint32 + // The amount of data the application has consumed but grpc has not sent + // window update for them. Used to reduce window update frequency. + pendingUpdate uint32 +} + +// onData is invoked when some data frame is received. It increments not only its +// own pendingData but also that of the associated connection-level flow. +func (f *inFlow) onData(n uint32) error { + if n == 0 { + return nil + } + f.mu.Lock() + defer f.mu.Unlock() + if f.pendingData+f.pendingUpdate+n > f.limit { + return fmt.Errorf("recieved %d-bytes data exceeding the limit %d bytes", f.pendingData+f.pendingUpdate+n, f.limit) + } + if f.conn != nil { + if err := f.conn.onData(n); err != nil { + return ConnectionErrorf("%v", err) + } + } + f.pendingData += n + return nil +} + +// connOnRead updates the connection level states when the application consumes data. +func (f *inFlow) connOnRead(n uint32) uint32 { + if n == 0 || f.conn != nil { + return 0 + } + f.mu.Lock() + defer f.mu.Unlock() + f.pendingData -= n + f.pendingUpdate += n + if f.pendingUpdate >= f.limit/4 { + ret := f.pendingUpdate + f.pendingUpdate = 0 + return ret + } + return 0 +} + +// onRead is invoked when the application reads the data. It returns the window updates +// for both stream and connection level. +func (f *inFlow) onRead(n uint32) (swu, cwu uint32) { + if n == 0 { + return + } + f.mu.Lock() + defer f.mu.Unlock() + if f.pendingData == 0 { + // pendingData has been adjusted by restoreConn. + return + } + f.pendingData -= n + f.pendingUpdate += n + if f.pendingUpdate >= f.limit/4 { + swu = f.pendingUpdate + f.pendingUpdate = 0 + } + cwu = f.conn.connOnRead(n) + return +} + +// restoreConn is invoked when a stream is terminated. It removes its stake in +// the connection-level flow and resets its own state. +func (f *inFlow) restoreConn() uint32 { + if f.conn == nil { + return 0 + } + f.mu.Lock() + defer f.mu.Unlock() + n := f.pendingData + f.pendingData = 0 + f.pendingUpdate = 0 + return f.conn.connOnRead(n) +} diff --git a/vendor/google.golang.org/grpc/transport/handler_server.go b/vendor/google.golang.org/grpc/transport/handler_server.go new file mode 100644 index 0000000000..63ba0537a1 --- /dev/null +++ b/vendor/google.golang.org/grpc/transport/handler_server.go @@ -0,0 +1,377 @@ +/* + * Copyright 2016, Google Inc. + * 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. + * + */ + +// This file is the implementation of a gRPC server using HTTP/2 which +// uses the standard Go http2 Server implementation (via the +// http.Handler interface), rather than speaking low-level HTTP/2 +// frames itself. It is the implementation of *grpc.Server.ServeHTTP. + +package transport + +import ( + "errors" + "fmt" + "io" + "net" + "net/http" + "strings" + "sync" + "time" + + "golang.org/x/net/context" + "golang.org/x/net/http2" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/credentials" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/peer" +) + +// NewServerHandlerTransport returns a ServerTransport handling gRPC +// from inside an http.Handler. It requires that the http Server +// supports HTTP/2. +func NewServerHandlerTransport(w http.ResponseWriter, r *http.Request) (ServerTransport, error) { + if r.ProtoMajor != 2 { + return nil, errors.New("gRPC requires HTTP/2") + } + if r.Method != "POST" { + return nil, errors.New("invalid gRPC request method") + } + if !strings.Contains(r.Header.Get("Content-Type"), "application/grpc") { + return nil, errors.New("invalid gRPC request content-type") + } + if _, ok := w.(http.Flusher); !ok { + return nil, errors.New("gRPC requires a ResponseWriter supporting http.Flusher") + } + if _, ok := w.(http.CloseNotifier); !ok { + return nil, errors.New("gRPC requires a ResponseWriter supporting http.CloseNotifier") + } + + st := &serverHandlerTransport{ + rw: w, + req: r, + closedCh: make(chan struct{}), + writes: make(chan func()), + } + + if v := r.Header.Get("grpc-timeout"); v != "" { + to, err := timeoutDecode(v) + if err != nil { + return nil, StreamErrorf(codes.Internal, "malformed time-out: %v", err) + } + st.timeoutSet = true + st.timeout = to + } + + var metakv []string + for k, vv := range r.Header { + k = strings.ToLower(k) + if isReservedHeader(k) { + continue + } + for _, v := range vv { + if k == "user-agent" { + // user-agent is special. Copying logic of http_util.go. + if i := strings.LastIndex(v, " "); i == -1 { + // There is no application user agent string being set + continue + } else { + v = v[:i] + } + } + metakv = append(metakv, k, v) + + } + } + st.headerMD = metadata.Pairs(metakv...) + + return st, nil +} + +// serverHandlerTransport is an implementation of ServerTransport +// which replies to exactly one gRPC request (exactly one HTTP request), +// using the net/http.Handler interface. This http.Handler is guranteed +// at this point to be speaking over HTTP/2, so it's able to speak valid +// gRPC. +type serverHandlerTransport struct { + rw http.ResponseWriter + req *http.Request + timeoutSet bool + timeout time.Duration + didCommonHeaders bool + + headerMD metadata.MD + + closeOnce sync.Once + closedCh chan struct{} // closed on Close + + // writes is a channel of code to run serialized in the + // ServeHTTP (HandleStreams) goroutine. The channel is closed + // when WriteStatus is called. + writes chan func() +} + +func (ht *serverHandlerTransport) Close() error { + ht.closeOnce.Do(ht.closeCloseChanOnce) + return nil +} + +func (ht *serverHandlerTransport) closeCloseChanOnce() { close(ht.closedCh) } + +func (ht *serverHandlerTransport) RemoteAddr() net.Addr { return strAddr(ht.req.RemoteAddr) } + +// strAddr is a net.Addr backed by either a TCP "ip:port" string, or +// the empty string if unknown. +type strAddr string + +func (a strAddr) Network() string { + if a != "" { + // Per the documentation on net/http.Request.RemoteAddr, if this is + // set, it's set to the IP:port of the peer (hence, TCP): + // https://golang.org/pkg/net/http/#Request + // + // If we want to support Unix sockets later, we can + // add our own grpc-specific convention within the + // grpc codebase to set RemoteAddr to a different + // format, or probably better: we can attach it to the + // context and use that from serverHandlerTransport.RemoteAddr. + return "tcp" + } + return "" +} + +func (a strAddr) String() string { return string(a) } + +// do runs fn in the ServeHTTP goroutine. +func (ht *serverHandlerTransport) do(fn func()) error { + select { + case ht.writes <- fn: + return nil + case <-ht.closedCh: + return ErrConnClosing + } +} + +func (ht *serverHandlerTransport) WriteStatus(s *Stream, statusCode codes.Code, statusDesc string) error { + err := ht.do(func() { + ht.writeCommonHeaders(s) + + // And flush, in case no header or body has been sent yet. + // This forces a separation of headers and trailers if this is the + // first call (for example, in end2end tests's TestNoService). + ht.rw.(http.Flusher).Flush() + + h := ht.rw.Header() + h.Set("Grpc-Status", fmt.Sprintf("%d", statusCode)) + if statusDesc != "" { + h.Set("Grpc-Message", statusDesc) + } + if md := s.Trailer(); len(md) > 0 { + for k, vv := range md { + for _, v := range vv { + // http2 ResponseWriter mechanism to + // send undeclared Trailers after the + // headers have possibly been written. + h.Add(http2.TrailerPrefix+k, v) + } + } + } + }) + close(ht.writes) + return err +} + +// writeCommonHeaders sets common headers on the first write +// call (Write, WriteHeader, or WriteStatus). +func (ht *serverHandlerTransport) writeCommonHeaders(s *Stream) { + if ht.didCommonHeaders { + return + } + ht.didCommonHeaders = true + + h := ht.rw.Header() + h["Date"] = nil // suppress Date to make tests happy; TODO: restore + h.Set("Content-Type", "application/grpc") + + // Predeclare trailers we'll set later in WriteStatus (after the body). + // This is a SHOULD in the HTTP RFC, and the way you add (known) + // Trailers per the net/http.ResponseWriter contract. + // See https://golang.org/pkg/net/http/#ResponseWriter + // and https://golang.org/pkg/net/http/#example_ResponseWriter_trailers + h.Add("Trailer", "Grpc-Status") + h.Add("Trailer", "Grpc-Message") + + if s.sendCompress != "" { + h.Set("Grpc-Encoding", s.sendCompress) + } +} + +func (ht *serverHandlerTransport) Write(s *Stream, data []byte, opts *Options) error { + return ht.do(func() { + ht.writeCommonHeaders(s) + ht.rw.Write(data) + if !opts.Delay { + ht.rw.(http.Flusher).Flush() + } + }) +} + +func (ht *serverHandlerTransport) WriteHeader(s *Stream, md metadata.MD) error { + return ht.do(func() { + ht.writeCommonHeaders(s) + h := ht.rw.Header() + for k, vv := range md { + for _, v := range vv { + h.Add(k, v) + } + } + ht.rw.WriteHeader(200) + ht.rw.(http.Flusher).Flush() + }) +} + +func (ht *serverHandlerTransport) HandleStreams(startStream func(*Stream)) { + // With this transport type there will be exactly 1 stream: this HTTP request. + + var ctx context.Context + var cancel context.CancelFunc + if ht.timeoutSet { + ctx, cancel = context.WithTimeout(context.Background(), ht.timeout) + } else { + ctx, cancel = context.WithCancel(context.Background()) + } + + // requestOver is closed when either the request's context is done + // or the status has been written via WriteStatus. + requestOver := make(chan struct{}) + + // clientGone receives a single value if peer is gone, either + // because the underlying connection is dead or because the + // peer sends an http2 RST_STREAM. + clientGone := ht.rw.(http.CloseNotifier).CloseNotify() + go func() { + select { + case <-requestOver: + return + case <-ht.closedCh: + case <-clientGone: + } + cancel() + }() + + req := ht.req + + s := &Stream{ + id: 0, // irrelevant + windowHandler: func(int) {}, // nothing + cancel: cancel, + buf: newRecvBuffer(), + st: ht, + method: req.URL.Path, + recvCompress: req.Header.Get("grpc-encoding"), + } + pr := &peer.Peer{ + Addr: ht.RemoteAddr(), + } + if req.TLS != nil { + pr.AuthInfo = credentials.TLSInfo{*req.TLS} + } + ctx = metadata.NewContext(ctx, ht.headerMD) + ctx = peer.NewContext(ctx, pr) + s.ctx = newContextWithStream(ctx, s) + s.dec = &recvBufferReader{ctx: s.ctx, recv: s.buf} + + // readerDone is closed when the Body.Read-ing goroutine exits. + readerDone := make(chan struct{}) + go func() { + defer close(readerDone) + for { + buf := make([]byte, 1024) // TODO: minimize garbage, optimize recvBuffer code/ownership + n, err := req.Body.Read(buf) + if n > 0 { + s.buf.put(&recvMsg{data: buf[:n]}) + } + if err != nil { + s.buf.put(&recvMsg{err: mapRecvMsgError(err)}) + return + } + } + }() + + // startStream is provided by the *grpc.Server's serveStreams. + // It starts a goroutine serving s and exits immediately. + // The goroutine that is started is the one that then calls + // into ht, calling WriteHeader, Write, WriteStatus, Close, etc. + startStream(s) + + ht.runStream() + close(requestOver) + + // Wait for reading goroutine to finish. + req.Body.Close() + <-readerDone +} + +func (ht *serverHandlerTransport) runStream() { + for { + select { + case fn, ok := <-ht.writes: + if !ok { + return + } + fn() + case <-ht.closedCh: + return + } + } +} + +// mapRecvMsgError returns the non-nil err into the appropriate +// error value as expected by callers of *grpc.parser.recvMsg. +// In particular, in can only be: +// * io.EOF +// * io.ErrUnexpectedEOF +// * of type transport.ConnectionError +// * of type transport.StreamError +func mapRecvMsgError(err error) error { + if err == io.EOF || err == io.ErrUnexpectedEOF { + return err + } + if se, ok := err.(http2.StreamError); ok { + if code, ok := http2ErrConvTab[se.Code]; ok { + return StreamError{ + Code: code, + Desc: se.Error(), + } + } + } + return ConnectionError{Desc: err.Error()} +} diff --git a/vendor/google.golang.org/grpc/transport/http2_client.go b/vendor/google.golang.org/grpc/transport/http2_client.go new file mode 100644 index 0000000000..bb72fea3ff --- /dev/null +++ b/vendor/google.golang.org/grpc/transport/http2_client.go @@ -0,0 +1,875 @@ +/* + * + * Copyright 2014, Google Inc. + * 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. + * + */ + +package transport + +import ( + "bytes" + "errors" + "io" + "math" + "net" + "strings" + "sync" + "time" + + "golang.org/x/net/context" + "golang.org/x/net/http2" + "golang.org/x/net/http2/hpack" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/credentials" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/peer" +) + +// http2Client implements the ClientTransport interface with HTTP2. +type http2Client struct { + target string // server name/addr + userAgent string + conn net.Conn // underlying communication channel + authInfo credentials.AuthInfo // auth info about the connection + nextID uint32 // the next stream ID to be used + + // writableChan synchronizes write access to the transport. + // A writer acquires the write lock by sending a value on writableChan + // and releases it by receiving from writableChan. + writableChan chan int + // shutdownChan is closed when Close is called. + // Blocking operations should select on shutdownChan to avoid + // blocking forever after Close. + // TODO(zhaoq): Maybe have a channel context? + shutdownChan chan struct{} + // errorChan is closed to notify the I/O error to the caller. + errorChan chan struct{} + + framer *framer + hBuf *bytes.Buffer // the buffer for HPACK encoding + hEnc *hpack.Encoder // HPACK encoder + + // controlBuf delivers all the control related tasks (e.g., window + // updates, reset streams, and various settings) to the controller. + controlBuf *recvBuffer + fc *inFlow + // sendQuotaPool provides flow control to outbound message. + sendQuotaPool *quotaPool + // streamsQuota limits the max number of concurrent streams. + streamsQuota *quotaPool + + // The scheme used: https if TLS is on, http otherwise. + scheme string + + authCreds []credentials.Credentials + + mu sync.Mutex // guard the following variables + state transportState // the state of underlying connection + activeStreams map[uint32]*Stream + // The max number of concurrent streams + maxStreams int + // the per-stream outbound flow control window size set by the peer. + streamSendQuota uint32 +} + +// newHTTP2Client constructs a connected ClientTransport to addr based on HTTP2 +// and starts to receive messages on it. Non-nil error returns if construction +// fails. +func newHTTP2Client(addr string, opts *ConnectOptions) (_ ClientTransport, err error) { + if opts.Dialer == nil { + // Set the default Dialer. + opts.Dialer = func(addr string, timeout time.Duration) (net.Conn, error) { + return net.DialTimeout("tcp", addr, timeout) + } + } + scheme := "http" + startT := time.Now() + timeout := opts.Timeout + conn, connErr := opts.Dialer(addr, timeout) + if connErr != nil { + return nil, ConnectionErrorf("transport: %v", connErr) + } + var authInfo credentials.AuthInfo + for _, c := range opts.AuthOptions { + if ccreds, ok := c.(credentials.TransportAuthenticator); ok { + scheme = "https" + // TODO(zhaoq): Now the first TransportAuthenticator is used if there are + // multiple ones provided. Revisit this if it is not appropriate. Probably + // place the ClientTransport construction into a separate function to make + // things clear. + if timeout > 0 { + timeout -= time.Since(startT) + } + conn, authInfo, connErr = ccreds.ClientHandshake(addr, conn, timeout) + break + } + } + if connErr != nil { + return nil, ConnectionErrorf("transport: %v", connErr) + } + defer func() { + if err != nil { + conn.Close() + } + }() + // Send connection preface to server. + n, err := conn.Write(clientPreface) + if err != nil { + return nil, ConnectionErrorf("transport: %v", err) + } + if n != len(clientPreface) { + return nil, ConnectionErrorf("transport: preface mismatch, wrote %d bytes; want %d", n, len(clientPreface)) + } + framer := newFramer(conn) + if initialWindowSize != defaultWindowSize { + err = framer.writeSettings(true, http2.Setting{http2.SettingInitialWindowSize, uint32(initialWindowSize)}) + } else { + err = framer.writeSettings(true) + } + if err != nil { + return nil, ConnectionErrorf("transport: %v", err) + } + // Adjust the connection flow control window if needed. + if delta := uint32(initialConnWindowSize - defaultWindowSize); delta > 0 { + if err := framer.writeWindowUpdate(true, 0, delta); err != nil { + return nil, ConnectionErrorf("transport: %v", err) + } + } + ua := primaryUA + if opts.UserAgent != "" { + ua = opts.UserAgent + " " + ua + } + var buf bytes.Buffer + t := &http2Client{ + target: addr, + userAgent: ua, + conn: conn, + authInfo: authInfo, + // The client initiated stream id is odd starting from 1. + nextID: 1, + writableChan: make(chan int, 1), + shutdownChan: make(chan struct{}), + errorChan: make(chan struct{}), + framer: framer, + hBuf: &buf, + hEnc: hpack.NewEncoder(&buf), + controlBuf: newRecvBuffer(), + fc: &inFlow{limit: initialConnWindowSize}, + sendQuotaPool: newQuotaPool(defaultWindowSize), + scheme: scheme, + state: reachable, + activeStreams: make(map[uint32]*Stream), + authCreds: opts.AuthOptions, + maxStreams: math.MaxInt32, + streamSendQuota: defaultWindowSize, + } + go t.controller() + t.writableChan <- 0 + // Start the reader goroutine for incoming message. The threading model + // on receiving is that each transport has a dedicated goroutine which + // reads HTTP2 frame from network. Then it dispatches the frame to the + // corresponding stream entity. + go t.reader() + return t, nil +} + +func (t *http2Client) newStream(ctx context.Context, callHdr *CallHdr) *Stream { + fc := &inFlow{ + limit: initialWindowSize, + conn: t.fc, + } + // TODO(zhaoq): Handle uint32 overflow of Stream.id. + s := &Stream{ + id: t.nextID, + method: callHdr.Method, + sendCompress: callHdr.SendCompress, + buf: newRecvBuffer(), + fc: fc, + sendQuotaPool: newQuotaPool(int(t.streamSendQuota)), + headerChan: make(chan struct{}), + } + t.nextID += 2 + s.windowHandler = func(n int) { + t.updateWindow(s, uint32(n)) + } + // Make a stream be able to cancel the pending operations by itself. + s.ctx, s.cancel = context.WithCancel(ctx) + s.dec = &recvBufferReader{ + ctx: s.ctx, + recv: s.buf, + } + return s +} + +// NewStream creates a stream and register it into the transport as "active" +// streams. +func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (_ *Stream, err error) { + // Record the timeout value on the context. + var timeout time.Duration + if dl, ok := ctx.Deadline(); ok { + timeout = dl.Sub(time.Now()) + if timeout <= 0 { + return nil, ContextErr(context.DeadlineExceeded) + } + } + pr := &peer.Peer{ + Addr: t.conn.RemoteAddr(), + } + // Attach Auth info if there is any. + if t.authInfo != nil { + pr.AuthInfo = t.authInfo + } + ctx = peer.NewContext(ctx, pr) + authData := make(map[string]string) + for _, c := range t.authCreds { + // Construct URI required to get auth request metadata. + var port string + if pos := strings.LastIndex(t.target, ":"); pos != -1 { + // Omit port if it is the default one. + if t.target[pos+1:] != "443" { + port = ":" + t.target[pos+1:] + } + } + pos := strings.LastIndex(callHdr.Method, "/") + if pos == -1 { + return nil, StreamErrorf(codes.InvalidArgument, "transport: malformed method name: %q", callHdr.Method) + } + audience := "https://" + callHdr.Host + port + callHdr.Method[:pos] + data, err := c.GetRequestMetadata(ctx, audience) + if err != nil { + return nil, StreamErrorf(codes.InvalidArgument, "transport: %v", err) + } + for k, v := range data { + authData[k] = v + } + } + t.mu.Lock() + if t.state != reachable { + t.mu.Unlock() + return nil, ErrConnClosing + } + checkStreamsQuota := t.streamsQuota != nil + t.mu.Unlock() + if checkStreamsQuota { + sq, err := wait(ctx, t.shutdownChan, t.streamsQuota.acquire()) + if err != nil { + return nil, err + } + // Returns the quota balance back. + if sq > 1 { + t.streamsQuota.add(sq - 1) + } + } + if _, err := wait(ctx, t.shutdownChan, t.writableChan); err != nil { + // t.streamsQuota will be updated when t.CloseStream is invoked. + return nil, err + } + t.mu.Lock() + if t.state != reachable { + t.mu.Unlock() + return nil, ErrConnClosing + } + s := t.newStream(ctx, callHdr) + t.activeStreams[s.id] = s + + // This stream is not counted when applySetings(...) initialize t.streamsQuota. + // Reset t.streamsQuota to the right value. + var reset bool + if !checkStreamsQuota && t.streamsQuota != nil { + reset = true + } + t.mu.Unlock() + if reset { + t.streamsQuota.reset(-1) + } + + // HPACK encodes various headers. Note that once WriteField(...) is + // called, the corresponding headers/continuation frame has to be sent + // because hpack.Encoder is stateful. + t.hBuf.Reset() + t.hEnc.WriteField(hpack.HeaderField{Name: ":method", Value: "POST"}) + t.hEnc.WriteField(hpack.HeaderField{Name: ":scheme", Value: t.scheme}) + t.hEnc.WriteField(hpack.HeaderField{Name: ":path", Value: callHdr.Method}) + t.hEnc.WriteField(hpack.HeaderField{Name: ":authority", Value: callHdr.Host}) + t.hEnc.WriteField(hpack.HeaderField{Name: "content-type", Value: "application/grpc"}) + t.hEnc.WriteField(hpack.HeaderField{Name: "user-agent", Value: t.userAgent}) + t.hEnc.WriteField(hpack.HeaderField{Name: "te", Value: "trailers"}) + + if callHdr.SendCompress != "" { + t.hEnc.WriteField(hpack.HeaderField{Name: "grpc-encoding", Value: callHdr.SendCompress}) + } + if timeout > 0 { + t.hEnc.WriteField(hpack.HeaderField{Name: "grpc-timeout", Value: timeoutEncode(timeout)}) + } + for k, v := range authData { + t.hEnc.WriteField(hpack.HeaderField{Name: k, Value: v}) + } + var ( + hasMD bool + endHeaders bool + ) + if md, ok := metadata.FromContext(ctx); ok { + hasMD = true + for k, v := range md { + for _, entry := range v { + t.hEnc.WriteField(hpack.HeaderField{Name: k, Value: entry}) + } + } + } + first := true + // Sends the headers in a single batch even when they span multiple frames. + for !endHeaders { + size := t.hBuf.Len() + if size > http2MaxFrameLen { + size = http2MaxFrameLen + } else { + endHeaders = true + } + var flush bool + if endHeaders && (hasMD || callHdr.Flush) { + flush = true + } + if first { + // Sends a HeadersFrame to server to start a new stream. + p := http2.HeadersFrameParam{ + StreamID: s.id, + BlockFragment: t.hBuf.Next(size), + EndStream: false, + EndHeaders: endHeaders, + } + // Do a force flush for the buffered frames iff it is the last headers frame + // and there is header metadata to be sent. Otherwise, there is flushing until + // the corresponding data frame is written. + err = t.framer.writeHeaders(flush, p) + first = false + } else { + // Sends Continuation frames for the leftover headers. + err = t.framer.writeContinuation(flush, s.id, endHeaders, t.hBuf.Next(size)) + } + if err != nil { + t.notifyError(err) + return nil, ConnectionErrorf("transport: %v", err) + } + } + t.writableChan <- 0 + return s, nil +} + +// CloseStream clears the footprint of a stream when the stream is not needed any more. +// This must not be executed in reader's goroutine. +func (t *http2Client) CloseStream(s *Stream, err error) { + var updateStreams bool + t.mu.Lock() + if t.streamsQuota != nil { + updateStreams = true + } + delete(t.activeStreams, s.id) + t.mu.Unlock() + if updateStreams { + t.streamsQuota.add(1) + } + // In case stream sending and receiving are invoked in separate + // goroutines (e.g., bi-directional streaming), the caller needs + // to call cancel on the stream to interrupt the blocking on + // other goroutines. + s.cancel() + s.mu.Lock() + if q := s.fc.restoreConn(); q > 0 { + t.controlBuf.put(&windowUpdate{0, q}) + } + if s.state == streamDone { + s.mu.Unlock() + return + } + if !s.headerDone { + close(s.headerChan) + s.headerDone = true + } + s.state = streamDone + s.mu.Unlock() + if _, ok := err.(StreamError); ok { + t.controlBuf.put(&resetStream{s.id, http2.ErrCodeCancel}) + } +} + +// Close kicks off the shutdown process of the transport. This should be called +// only once on a transport. Once it is called, the transport should not be +// accessed any more. +func (t *http2Client) Close() (err error) { + t.mu.Lock() + if t.state == closing { + t.mu.Unlock() + return errors.New("transport: Close() was already called") + } + t.state = closing + t.mu.Unlock() + close(t.shutdownChan) + err = t.conn.Close() + t.mu.Lock() + streams := t.activeStreams + t.activeStreams = nil + t.mu.Unlock() + // Notify all active streams. + for _, s := range streams { + s.mu.Lock() + if !s.headerDone { + close(s.headerChan) + s.headerDone = true + } + s.mu.Unlock() + s.write(recvMsg{err: ErrConnClosing}) + } + return +} + +// Write formats the data into HTTP2 data frame(s) and sends it out. The caller +// should proceed only if Write returns nil. +// TODO(zhaoq): opts.Delay is ignored in this implementation. Support it later +// if it improves the performance. +func (t *http2Client) Write(s *Stream, data []byte, opts *Options) error { + r := bytes.NewBuffer(data) + for { + var p []byte + if r.Len() > 0 { + size := http2MaxFrameLen + s.sendQuotaPool.add(0) + // Wait until the stream has some quota to send the data. + sq, err := wait(s.ctx, t.shutdownChan, s.sendQuotaPool.acquire()) + if err != nil { + return err + } + t.sendQuotaPool.add(0) + // Wait until the transport has some quota to send the data. + tq, err := wait(s.ctx, t.shutdownChan, t.sendQuotaPool.acquire()) + if err != nil { + if _, ok := err.(StreamError); ok { + t.sendQuotaPool.cancel() + } + return err + } + if sq < size { + size = sq + } + if tq < size { + size = tq + } + p = r.Next(size) + ps := len(p) + if ps < sq { + // Overbooked stream quota. Return it back. + s.sendQuotaPool.add(sq - ps) + } + if ps < tq { + // Overbooked transport quota. Return it back. + t.sendQuotaPool.add(tq - ps) + } + } + var ( + endStream bool + forceFlush bool + ) + if opts.Last && r.Len() == 0 { + endStream = true + } + // Indicate there is a writer who is about to write a data frame. + t.framer.adjustNumWriters(1) + // Got some quota. Try to acquire writing privilege on the transport. + if _, err := wait(s.ctx, t.shutdownChan, t.writableChan); err != nil { + if t.framer.adjustNumWriters(-1) == 0 { + // This writer is the last one in this batch and has the + // responsibility to flush the buffered frames. It queues + // a flush request to controlBuf instead of flushing directly + // in order to avoid the race with other writing or flushing. + t.controlBuf.put(&flushIO{}) + } + return err + } + if r.Len() == 0 && t.framer.adjustNumWriters(0) == 1 { + // Do a force flush iff this is last frame for the entire gRPC message + // and the caller is the only writer at this moment. + forceFlush = true + } + // If WriteData fails, all the pending streams will be handled + // by http2Client.Close(). No explicit CloseStream() needs to be + // invoked. + if err := t.framer.writeData(forceFlush, s.id, endStream, p); err != nil { + t.notifyError(err) + return ConnectionErrorf("transport: %v", err) + } + if t.framer.adjustNumWriters(-1) == 0 { + t.framer.flushWrite() + } + t.writableChan <- 0 + if r.Len() == 0 { + break + } + } + if !opts.Last { + return nil + } + s.mu.Lock() + if s.state != streamDone { + if s.state == streamReadDone { + s.state = streamDone + } else { + s.state = streamWriteDone + } + } + s.mu.Unlock() + return nil +} + +func (t *http2Client) getStream(f http2.Frame) (*Stream, bool) { + t.mu.Lock() + defer t.mu.Unlock() + if t.activeStreams == nil { + // The transport is closing. + return nil, false + } + if s, ok := t.activeStreams[f.Header().StreamID]; ok { + return s, true + } + return nil, false +} + +// updateWindow adjusts the inbound quota for the stream and the transport. +// Window updates will deliver to the controller for sending when +// the cumulative quota exceeds the corresponding threshold. +func (t *http2Client) updateWindow(s *Stream, n uint32) { + swu, cwu := s.fc.onRead(n) + if swu > 0 { + t.controlBuf.put(&windowUpdate{s.id, swu}) + } + if cwu > 0 { + t.controlBuf.put(&windowUpdate{0, cwu}) + } +} + +func (t *http2Client) handleData(f *http2.DataFrame) { + // Select the right stream to dispatch. + s, ok := t.getStream(f) + if !ok { + return + } + size := len(f.Data()) + if size > 0 { + if err := s.fc.onData(uint32(size)); err != nil { + if _, ok := err.(ConnectionError); ok { + t.notifyError(err) + return + } + s.mu.Lock() + if s.state == streamDone { + s.mu.Unlock() + return + } + s.state = streamDone + s.statusCode = codes.Internal + s.statusDesc = err.Error() + s.mu.Unlock() + s.write(recvMsg{err: io.EOF}) + t.controlBuf.put(&resetStream{s.id, http2.ErrCodeFlowControl}) + return + } + // TODO(bradfitz, zhaoq): A copy is required here because there is no + // guarantee f.Data() is consumed before the arrival of next frame. + // Can this copy be eliminated? + data := make([]byte, size) + copy(data, f.Data()) + s.write(recvMsg{data: data}) + } + // The server has closed the stream without sending trailers. Record that + // the read direction is closed, and set the status appropriately. + if f.FrameHeader.Flags.Has(http2.FlagDataEndStream) { + s.mu.Lock() + if s.state == streamWriteDone { + s.state = streamDone + } else { + s.state = streamReadDone + } + s.statusCode = codes.Internal + s.statusDesc = "server closed the stream without sending trailers" + s.mu.Unlock() + s.write(recvMsg{err: io.EOF}) + } +} + +func (t *http2Client) handleRSTStream(f *http2.RSTStreamFrame) { + s, ok := t.getStream(f) + if !ok { + return + } + s.mu.Lock() + if s.state == streamDone { + s.mu.Unlock() + return + } + s.state = streamDone + if !s.headerDone { + close(s.headerChan) + s.headerDone = true + } + s.statusCode, ok = http2ErrConvTab[http2.ErrCode(f.ErrCode)] + if !ok { + grpclog.Println("transport: http2Client.handleRSTStream found no mapped gRPC status for the received http2 error ", f.ErrCode) + } + s.mu.Unlock() + s.write(recvMsg{err: io.EOF}) +} + +func (t *http2Client) handleSettings(f *http2.SettingsFrame) { + if f.IsAck() { + return + } + var ss []http2.Setting + f.ForeachSetting(func(s http2.Setting) error { + ss = append(ss, s) + return nil + }) + // The settings will be applied once the ack is sent. + t.controlBuf.put(&settings{ack: true, ss: ss}) +} + +func (t *http2Client) handlePing(f *http2.PingFrame) { + pingAck := &ping{ack: true} + copy(pingAck.data[:], f.Data[:]) + t.controlBuf.put(pingAck) +} + +func (t *http2Client) handleGoAway(f *http2.GoAwayFrame) { + // TODO(zhaoq): GoAwayFrame handler to be implemented +} + +func (t *http2Client) handleWindowUpdate(f *http2.WindowUpdateFrame) { + id := f.Header().StreamID + incr := f.Increment + if id == 0 { + t.sendQuotaPool.add(int(incr)) + return + } + if s, ok := t.getStream(f); ok { + s.sendQuotaPool.add(int(incr)) + } +} + +// operateHeader takes action on the decoded headers. It returns the current +// stream if there are remaining headers on the wire (in the following +// Continuation frame). +func (t *http2Client) operateHeaders(hDec *hpackDecoder, s *Stream, frame headerFrame, endStream bool) (pendingStream *Stream) { + defer func() { + if pendingStream == nil { + hDec.state = decodeState{} + } + }() + endHeaders, err := hDec.decodeClientHTTP2Headers(frame) + if s == nil { + // s has been closed. + return nil + } + if err != nil { + s.write(recvMsg{err: err}) + // Something wrong. Stops reading even when there is remaining. + return nil + } + if !endHeaders { + return s + } + s.mu.Lock() + if !endStream { + s.recvCompress = hDec.state.encoding + } + if !s.headerDone { + if !endStream && len(hDec.state.mdata) > 0 { + s.header = hDec.state.mdata + } + close(s.headerChan) + s.headerDone = true + } + if !endStream || s.state == streamDone { + s.mu.Unlock() + return nil + } + + if len(hDec.state.mdata) > 0 { + s.trailer = hDec.state.mdata + } + s.state = streamDone + s.statusCode = hDec.state.statusCode + s.statusDesc = hDec.state.statusDesc + s.mu.Unlock() + + s.write(recvMsg{err: io.EOF}) + return nil +} + +// reader runs as a separate goroutine in charge of reading data from network +// connection. +// +// TODO(zhaoq): currently one reader per transport. Investigate whether this is +// optimal. +// TODO(zhaoq): Check the validity of the incoming frame sequence. +func (t *http2Client) reader() { + // Check the validity of server preface. + frame, err := t.framer.readFrame() + if err != nil { + t.notifyError(err) + return + } + sf, ok := frame.(*http2.SettingsFrame) + if !ok { + t.notifyError(err) + return + } + t.handleSettings(sf) + + hDec := newHPACKDecoder() + var curStream *Stream + // loop to keep reading incoming messages on this transport. + for { + frame, err := t.framer.readFrame() + if err != nil { + t.notifyError(err) + return + } + switch frame := frame.(type) { + case *http2.HeadersFrame: + // operateHeaders has to be invoked regardless the value of curStream + // because the HPACK decoder needs to be updated using the received + // headers. + curStream, _ = t.getStream(frame) + endStream := frame.Header().Flags.Has(http2.FlagHeadersEndStream) + curStream = t.operateHeaders(hDec, curStream, frame, endStream) + case *http2.ContinuationFrame: + curStream = t.operateHeaders(hDec, curStream, frame, frame.HeadersEnded()) + case *http2.DataFrame: + t.handleData(frame) + case *http2.RSTStreamFrame: + t.handleRSTStream(frame) + case *http2.SettingsFrame: + t.handleSettings(frame) + case *http2.PingFrame: + t.handlePing(frame) + case *http2.GoAwayFrame: + t.handleGoAway(frame) + case *http2.WindowUpdateFrame: + t.handleWindowUpdate(frame) + default: + grpclog.Printf("transport: http2Client.reader got unhandled frame type %v.", frame) + } + } +} + +func (t *http2Client) applySettings(ss []http2.Setting) { + for _, s := range ss { + switch s.ID { + case http2.SettingMaxConcurrentStreams: + // TODO(zhaoq): This is a hack to avoid significant refactoring of the + // code to deal with the unrealistic int32 overflow. Probably will try + // to find a better way to handle this later. + if s.Val > math.MaxInt32 { + s.Val = math.MaxInt32 + } + t.mu.Lock() + reset := t.streamsQuota != nil + if !reset { + t.streamsQuota = newQuotaPool(int(s.Val) - len(t.activeStreams)) + } + ms := t.maxStreams + t.maxStreams = int(s.Val) + t.mu.Unlock() + if reset { + t.streamsQuota.reset(int(s.Val) - ms) + } + case http2.SettingInitialWindowSize: + t.mu.Lock() + for _, stream := range t.activeStreams { + // Adjust the sending quota for each stream. + stream.sendQuotaPool.reset(int(s.Val - t.streamSendQuota)) + } + t.streamSendQuota = s.Val + t.mu.Unlock() + } + } +} + +// controller running in a separate goroutine takes charge of sending control +// frames (e.g., window update, reset stream, setting, etc.) to the server. +func (t *http2Client) controller() { + for { + select { + case i := <-t.controlBuf.get(): + t.controlBuf.load() + select { + case <-t.writableChan: + switch i := i.(type) { + case *windowUpdate: + t.framer.writeWindowUpdate(true, i.streamID, i.increment) + case *settings: + if i.ack { + t.framer.writeSettingsAck(true) + t.applySettings(i.ss) + } else { + t.framer.writeSettings(true, i.ss...) + } + case *resetStream: + t.framer.writeRSTStream(true, i.streamID, i.code) + case *flushIO: + t.framer.flushWrite() + case *ping: + t.framer.writePing(true, i.ack, i.data) + default: + grpclog.Printf("transport: http2Client.controller got unexpected item type %v\n", i) + } + t.writableChan <- 0 + continue + case <-t.shutdownChan: + return + } + case <-t.shutdownChan: + return + } + } +} + +func (t *http2Client) Error() <-chan struct{} { + return t.errorChan +} + +func (t *http2Client) notifyError(err error) { + t.mu.Lock() + defer t.mu.Unlock() + // make sure t.errorChan is closed only once. + if t.state == reachable { + t.state = unreachable + close(t.errorChan) + grpclog.Printf("transport: http2Client.notifyError got notified that the client transport was broken %v.", err) + } +} diff --git a/vendor/google.golang.org/grpc/transport/http2_server.go b/vendor/google.golang.org/grpc/transport/http2_server.go new file mode 100644 index 0000000000..b9d4959fea --- /dev/null +++ b/vendor/google.golang.org/grpc/transport/http2_server.go @@ -0,0 +1,707 @@ +/* + * + * Copyright 2014, Google Inc. + * 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. + * + */ + +package transport + +import ( + "bytes" + "errors" + "io" + "math" + "net" + "strconv" + "sync" + + "golang.org/x/net/context" + "golang.org/x/net/http2" + "golang.org/x/net/http2/hpack" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/credentials" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/peer" +) + +// ErrIllegalHeaderWrite indicates that setting header is illegal because of +// the stream's state. +var ErrIllegalHeaderWrite = errors.New("transport: the stream is done or WriteHeader was already called") + +// http2Server implements the ServerTransport interface with HTTP2. +type http2Server struct { + conn net.Conn + maxStreamID uint32 // max stream ID ever seen + authInfo credentials.AuthInfo // auth info about the connection + // writableChan synchronizes write access to the transport. + // A writer acquires the write lock by receiving a value on writableChan + // and releases it by sending on writableChan. + writableChan chan int + // shutdownChan is closed when Close is called. + // Blocking operations should select on shutdownChan to avoid + // blocking forever after Close. + shutdownChan chan struct{} + framer *framer + hBuf *bytes.Buffer // the buffer for HPACK encoding + hEnc *hpack.Encoder // HPACK encoder + + // The max number of concurrent streams. + maxStreams uint32 + // controlBuf delivers all the control related tasks (e.g., window + // updates, reset streams, and various settings) to the controller. + controlBuf *recvBuffer + fc *inFlow + // sendQuotaPool provides flow control to outbound message. + sendQuotaPool *quotaPool + + mu sync.Mutex // guard the following + state transportState + activeStreams map[uint32]*Stream + // the per-stream outbound flow control window size set by the peer. + streamSendQuota uint32 +} + +// newHTTP2Server constructs a ServerTransport based on HTTP2. ConnectionError is +// returned if something goes wrong. +func newHTTP2Server(conn net.Conn, maxStreams uint32, authInfo credentials.AuthInfo) (_ ServerTransport, err error) { + framer := newFramer(conn) + // Send initial settings as connection preface to client. + var settings []http2.Setting + // TODO(zhaoq): Have a better way to signal "no limit" because 0 is + // permitted in the HTTP2 spec. + if maxStreams == 0 { + maxStreams = math.MaxUint32 + } else { + settings = append(settings, http2.Setting{http2.SettingMaxConcurrentStreams, maxStreams}) + } + if initialWindowSize != defaultWindowSize { + settings = append(settings, http2.Setting{http2.SettingInitialWindowSize, uint32(initialWindowSize)}) + } + if err := framer.writeSettings(true, settings...); err != nil { + return nil, ConnectionErrorf("transport: %v", err) + } + // Adjust the connection flow control window if needed. + if delta := uint32(initialConnWindowSize - defaultWindowSize); delta > 0 { + if err := framer.writeWindowUpdate(true, 0, delta); err != nil { + return nil, ConnectionErrorf("transport: %v", err) + } + } + var buf bytes.Buffer + t := &http2Server{ + conn: conn, + authInfo: authInfo, + framer: framer, + hBuf: &buf, + hEnc: hpack.NewEncoder(&buf), + maxStreams: maxStreams, + controlBuf: newRecvBuffer(), + fc: &inFlow{limit: initialConnWindowSize}, + sendQuotaPool: newQuotaPool(defaultWindowSize), + state: reachable, + writableChan: make(chan int, 1), + shutdownChan: make(chan struct{}), + activeStreams: make(map[uint32]*Stream), + streamSendQuota: defaultWindowSize, + } + go t.controller() + t.writableChan <- 0 + return t, nil +} + +// operateHeader takes action on the decoded headers. It returns the current +// stream if there are remaining headers on the wire (in the following +// Continuation frame). +func (t *http2Server) operateHeaders(hDec *hpackDecoder, s *Stream, frame headerFrame, endStream bool, handle func(*Stream)) (pendingStream *Stream) { + defer func() { + if pendingStream == nil { + hDec.state = decodeState{} + } + }() + endHeaders, err := hDec.decodeServerHTTP2Headers(frame) + if s == nil { + // s has been closed. + return nil + } + if err != nil { + grpclog.Printf("transport: http2Server.operateHeader found %v", err) + if se, ok := err.(StreamError); ok { + t.controlBuf.put(&resetStream{s.id, statusCodeConvTab[se.Code]}) + } + return nil + } + if endStream { + // s is just created by the caller. No lock needed. + s.state = streamReadDone + } + if !endHeaders { + return s + } + s.recvCompress = hDec.state.encoding + if hDec.state.timeoutSet { + s.ctx, s.cancel = context.WithTimeout(context.TODO(), hDec.state.timeout) + } else { + s.ctx, s.cancel = context.WithCancel(context.TODO()) + } + pr := &peer.Peer{ + Addr: t.conn.RemoteAddr(), + } + // Attach Auth info if there is any. + if t.authInfo != nil { + pr.AuthInfo = t.authInfo + } + s.ctx = peer.NewContext(s.ctx, pr) + // Cache the current stream to the context so that the server application + // can find out. Required when the server wants to send some metadata + // back to the client (unary call only). + s.ctx = newContextWithStream(s.ctx, s) + // Attach the received metadata to the context. + if len(hDec.state.mdata) > 0 { + s.ctx = metadata.NewContext(s.ctx, hDec.state.mdata) + } + + s.dec = &recvBufferReader{ + ctx: s.ctx, + recv: s.buf, + } + s.recvCompress = hDec.state.encoding + s.method = hDec.state.method + t.mu.Lock() + if t.state != reachable { + t.mu.Unlock() + return nil + } + if uint32(len(t.activeStreams)) >= t.maxStreams { + t.mu.Unlock() + t.controlBuf.put(&resetStream{s.id, http2.ErrCodeRefusedStream}) + return nil + } + s.sendQuotaPool = newQuotaPool(int(t.streamSendQuota)) + t.activeStreams[s.id] = s + t.mu.Unlock() + s.windowHandler = func(n int) { + t.updateWindow(s, uint32(n)) + } + handle(s) + return nil +} + +// HandleStreams receives incoming streams using the given handler. This is +// typically run in a separate goroutine. +func (t *http2Server) HandleStreams(handle func(*Stream)) { + // Check the validity of client preface. + preface := make([]byte, len(clientPreface)) + if _, err := io.ReadFull(t.conn, preface); err != nil { + grpclog.Printf("transport: http2Server.HandleStreams failed to receive the preface from client: %v", err) + t.Close() + return + } + if !bytes.Equal(preface, clientPreface) { + grpclog.Printf("transport: http2Server.HandleStreams received bogus greeting from client: %q", preface) + t.Close() + return + } + + frame, err := t.framer.readFrame() + if err != nil { + grpclog.Printf("transport: http2Server.HandleStreams failed to read frame: %v", err) + t.Close() + return + } + sf, ok := frame.(*http2.SettingsFrame) + if !ok { + grpclog.Printf("transport: http2Server.HandleStreams saw invalid preface type %T from client", frame) + t.Close() + return + } + t.handleSettings(sf) + + hDec := newHPACKDecoder() + var curStream *Stream + for { + frame, err := t.framer.readFrame() + if err != nil { + t.Close() + return + } + switch frame := frame.(type) { + case *http2.HeadersFrame: + id := frame.Header().StreamID + if id%2 != 1 || id <= t.maxStreamID { + // illegal gRPC stream id. + grpclog.Println("transport: http2Server.HandleStreams received an illegal stream id: ", id) + t.Close() + break + } + t.maxStreamID = id + buf := newRecvBuffer() + fc := &inFlow{ + limit: initialWindowSize, + conn: t.fc, + } + curStream = &Stream{ + id: frame.Header().StreamID, + st: t, + buf: buf, + fc: fc, + } + endStream := frame.Header().Flags.Has(http2.FlagHeadersEndStream) + curStream = t.operateHeaders(hDec, curStream, frame, endStream, handle) + case *http2.ContinuationFrame: + curStream = t.operateHeaders(hDec, curStream, frame, frame.HeadersEnded(), handle) + case *http2.DataFrame: + t.handleData(frame) + case *http2.RSTStreamFrame: + t.handleRSTStream(frame) + case *http2.SettingsFrame: + t.handleSettings(frame) + case *http2.PingFrame: + t.handlePing(frame) + case *http2.WindowUpdateFrame: + t.handleWindowUpdate(frame) + case *http2.GoAwayFrame: + break + default: + grpclog.Printf("transport: http2Server.HandleStreams found unhandled frame type %v.", frame) + } + } +} + +func (t *http2Server) getStream(f http2.Frame) (*Stream, bool) { + t.mu.Lock() + defer t.mu.Unlock() + if t.activeStreams == nil { + // The transport is closing. + return nil, false + } + s, ok := t.activeStreams[f.Header().StreamID] + if !ok { + // The stream is already done. + return nil, false + } + return s, true +} + +// updateWindow adjusts the inbound quota for the stream and the transport. +// Window updates will deliver to the controller for sending when +// the cumulative quota exceeds the corresponding threshold. +func (t *http2Server) updateWindow(s *Stream, n uint32) { + swu, cwu := s.fc.onRead(n) + if swu > 0 { + t.controlBuf.put(&windowUpdate{s.id, swu}) + } + if cwu > 0 { + t.controlBuf.put(&windowUpdate{0, cwu}) + } +} + +func (t *http2Server) handleData(f *http2.DataFrame) { + // Select the right stream to dispatch. + s, ok := t.getStream(f) + if !ok { + return + } + size := len(f.Data()) + if size > 0 { + if err := s.fc.onData(uint32(size)); err != nil { + if _, ok := err.(ConnectionError); ok { + grpclog.Printf("transport: http2Server %v", err) + t.Close() + return + } + t.closeStream(s) + t.controlBuf.put(&resetStream{s.id, http2.ErrCodeFlowControl}) + return + } + // TODO(bradfitz, zhaoq): A copy is required here because there is no + // guarantee f.Data() is consumed before the arrival of next frame. + // Can this copy be eliminated? + data := make([]byte, size) + copy(data, f.Data()) + s.write(recvMsg{data: data}) + } + if f.Header().Flags.Has(http2.FlagDataEndStream) { + // Received the end of stream from the client. + s.mu.Lock() + if s.state != streamDone { + if s.state == streamWriteDone { + s.state = streamDone + } else { + s.state = streamReadDone + } + } + s.mu.Unlock() + s.write(recvMsg{err: io.EOF}) + } +} + +func (t *http2Server) handleRSTStream(f *http2.RSTStreamFrame) { + s, ok := t.getStream(f) + if !ok { + return + } + t.closeStream(s) +} + +func (t *http2Server) handleSettings(f *http2.SettingsFrame) { + if f.IsAck() { + return + } + var ss []http2.Setting + f.ForeachSetting(func(s http2.Setting) error { + ss = append(ss, s) + return nil + }) + // The settings will be applied once the ack is sent. + t.controlBuf.put(&settings{ack: true, ss: ss}) +} + +func (t *http2Server) handlePing(f *http2.PingFrame) { + pingAck := &ping{ack: true} + copy(pingAck.data[:], f.Data[:]) + t.controlBuf.put(pingAck) +} + +func (t *http2Server) handleWindowUpdate(f *http2.WindowUpdateFrame) { + id := f.Header().StreamID + incr := f.Increment + if id == 0 { + t.sendQuotaPool.add(int(incr)) + return + } + if s, ok := t.getStream(f); ok { + s.sendQuotaPool.add(int(incr)) + } +} + +func (t *http2Server) writeHeaders(s *Stream, b *bytes.Buffer, endStream bool) error { + first := true + endHeaders := false + var err error + // Sends the headers in a single batch. + for !endHeaders { + size := t.hBuf.Len() + if size > http2MaxFrameLen { + size = http2MaxFrameLen + } else { + endHeaders = true + } + if first { + p := http2.HeadersFrameParam{ + StreamID: s.id, + BlockFragment: b.Next(size), + EndStream: endStream, + EndHeaders: endHeaders, + } + err = t.framer.writeHeaders(endHeaders, p) + first = false + } else { + err = t.framer.writeContinuation(endHeaders, s.id, endHeaders, b.Next(size)) + } + if err != nil { + t.Close() + return ConnectionErrorf("transport: %v", err) + } + } + return nil +} + +// WriteHeader sends the header metedata md back to the client. +func (t *http2Server) WriteHeader(s *Stream, md metadata.MD) error { + s.mu.Lock() + if s.headerOk || s.state == streamDone { + s.mu.Unlock() + return ErrIllegalHeaderWrite + } + s.headerOk = true + s.mu.Unlock() + if _, err := wait(s.ctx, t.shutdownChan, t.writableChan); err != nil { + return err + } + t.hBuf.Reset() + t.hEnc.WriteField(hpack.HeaderField{Name: ":status", Value: "200"}) + t.hEnc.WriteField(hpack.HeaderField{Name: "content-type", Value: "application/grpc"}) + if s.sendCompress != "" { + t.hEnc.WriteField(hpack.HeaderField{Name: "grpc-encoding", Value: s.sendCompress}) + } + for k, v := range md { + for _, entry := range v { + t.hEnc.WriteField(hpack.HeaderField{Name: k, Value: entry}) + } + } + if err := t.writeHeaders(s, t.hBuf, false); err != nil { + return err + } + t.writableChan <- 0 + return nil +} + +// WriteStatus sends stream status to the client and terminates the stream. +// There is no further I/O operations being able to perform on this stream. +// TODO(zhaoq): Now it indicates the end of entire stream. Revisit if early +// OK is adopted. +func (t *http2Server) WriteStatus(s *Stream, statusCode codes.Code, statusDesc string) error { + var headersSent bool + s.mu.Lock() + if s.state == streamDone { + s.mu.Unlock() + return nil + } + if s.headerOk { + headersSent = true + } + s.mu.Unlock() + if _, err := wait(s.ctx, t.shutdownChan, t.writableChan); err != nil { + return err + } + t.hBuf.Reset() + if !headersSent { + t.hEnc.WriteField(hpack.HeaderField{Name: ":status", Value: "200"}) + t.hEnc.WriteField(hpack.HeaderField{Name: "content-type", Value: "application/grpc"}) + } + t.hEnc.WriteField( + hpack.HeaderField{ + Name: "grpc-status", + Value: strconv.Itoa(int(statusCode)), + }) + t.hEnc.WriteField(hpack.HeaderField{Name: "grpc-message", Value: statusDesc}) + // Attach the trailer metadata. + for k, v := range s.trailer { + for _, entry := range v { + t.hEnc.WriteField(hpack.HeaderField{Name: k, Value: entry}) + } + } + if err := t.writeHeaders(s, t.hBuf, true); err != nil { + t.Close() + return err + } + t.closeStream(s) + t.writableChan <- 0 + return nil +} + +// Write converts the data into HTTP2 data frame and sends it out. Non-nil error +// is returns if it fails (e.g., framing error, transport error). +func (t *http2Server) Write(s *Stream, data []byte, opts *Options) error { + // TODO(zhaoq): Support multi-writers for a single stream. + var writeHeaderFrame bool + s.mu.Lock() + if !s.headerOk { + writeHeaderFrame = true + s.headerOk = true + } + s.mu.Unlock() + if writeHeaderFrame { + if _, err := wait(s.ctx, t.shutdownChan, t.writableChan); err != nil { + return err + } + t.hBuf.Reset() + t.hEnc.WriteField(hpack.HeaderField{Name: ":status", Value: "200"}) + t.hEnc.WriteField(hpack.HeaderField{Name: "content-type", Value: "application/grpc"}) + if s.sendCompress != "" { + t.hEnc.WriteField(hpack.HeaderField{Name: "grpc-encoding", Value: s.sendCompress}) + } + p := http2.HeadersFrameParam{ + StreamID: s.id, + BlockFragment: t.hBuf.Bytes(), + EndHeaders: true, + } + if err := t.framer.writeHeaders(false, p); err != nil { + t.Close() + return ConnectionErrorf("transport: %v", err) + } + t.writableChan <- 0 + } + r := bytes.NewBuffer(data) + for { + if r.Len() == 0 { + return nil + } + size := http2MaxFrameLen + s.sendQuotaPool.add(0) + // Wait until the stream has some quota to send the data. + sq, err := wait(s.ctx, t.shutdownChan, s.sendQuotaPool.acquire()) + if err != nil { + return err + } + t.sendQuotaPool.add(0) + // Wait until the transport has some quota to send the data. + tq, err := wait(s.ctx, t.shutdownChan, t.sendQuotaPool.acquire()) + if err != nil { + if _, ok := err.(StreamError); ok { + t.sendQuotaPool.cancel() + } + return err + } + if sq < size { + size = sq + } + if tq < size { + size = tq + } + p := r.Next(size) + ps := len(p) + if ps < sq { + // Overbooked stream quota. Return it back. + s.sendQuotaPool.add(sq - ps) + } + if ps < tq { + // Overbooked transport quota. Return it back. + t.sendQuotaPool.add(tq - ps) + } + t.framer.adjustNumWriters(1) + // Got some quota. Try to acquire writing privilege on the + // transport. + if _, err := wait(s.ctx, t.shutdownChan, t.writableChan); err != nil { + if t.framer.adjustNumWriters(-1) == 0 { + // This writer is the last one in this batch and has the + // responsibility to flush the buffered frames. It queues + // a flush request to controlBuf instead of flushing directly + // in order to avoid the race with other writing or flushing. + t.controlBuf.put(&flushIO{}) + } + return err + } + var forceFlush bool + if r.Len() == 0 && t.framer.adjustNumWriters(0) == 1 && !opts.Last { + forceFlush = true + } + if err := t.framer.writeData(forceFlush, s.id, false, p); err != nil { + t.Close() + return ConnectionErrorf("transport: %v", err) + } + if t.framer.adjustNumWriters(-1) == 0 { + t.framer.flushWrite() + } + t.writableChan <- 0 + } + +} + +func (t *http2Server) applySettings(ss []http2.Setting) { + for _, s := range ss { + if s.ID == http2.SettingInitialWindowSize { + t.mu.Lock() + defer t.mu.Unlock() + for _, stream := range t.activeStreams { + stream.sendQuotaPool.reset(int(s.Val - t.streamSendQuota)) + } + t.streamSendQuota = s.Val + } + + } +} + +// controller running in a separate goroutine takes charge of sending control +// frames (e.g., window update, reset stream, setting, etc.) to the server. +func (t *http2Server) controller() { + for { + select { + case i := <-t.controlBuf.get(): + t.controlBuf.load() + select { + case <-t.writableChan: + switch i := i.(type) { + case *windowUpdate: + t.framer.writeWindowUpdate(true, i.streamID, i.increment) + case *settings: + if i.ack { + t.framer.writeSettingsAck(true) + t.applySettings(i.ss) + } else { + t.framer.writeSettings(true, i.ss...) + } + case *resetStream: + t.framer.writeRSTStream(true, i.streamID, i.code) + case *flushIO: + t.framer.flushWrite() + case *ping: + t.framer.writePing(true, i.ack, i.data) + default: + grpclog.Printf("transport: http2Server.controller got unexpected item type %v\n", i) + } + t.writableChan <- 0 + continue + case <-t.shutdownChan: + return + } + case <-t.shutdownChan: + return + } + } +} + +// Close starts shutting down the http2Server transport. +// TODO(zhaoq): Now the destruction is not blocked on any pending streams. This +// could cause some resource issue. Revisit this later. +func (t *http2Server) Close() (err error) { + t.mu.Lock() + if t.state == closing { + t.mu.Unlock() + return errors.New("transport: Close() was already called") + } + t.state = closing + streams := t.activeStreams + t.activeStreams = nil + t.mu.Unlock() + close(t.shutdownChan) + err = t.conn.Close() + // Cancel all active streams. + for _, s := range streams { + s.cancel() + } + return +} + +// closeStream clears the footprint of a stream when the stream is not needed +// any more. +func (t *http2Server) closeStream(s *Stream) { + t.mu.Lock() + delete(t.activeStreams, s.id) + t.mu.Unlock() + if q := s.fc.restoreConn(); q > 0 { + t.controlBuf.put(&windowUpdate{0, q}) + } + s.mu.Lock() + if s.state == streamDone { + s.mu.Unlock() + return + } + s.state = streamDone + s.mu.Unlock() + // In case stream sending and receiving are invoked in separate + // goroutines (e.g., bi-directional streaming), cancel needs to be + // called to interrupt the potential blocking on other goroutines. + s.cancel() +} + +func (t *http2Server) RemoteAddr() net.Addr { + return t.conn.RemoteAddr() +} diff --git a/vendor/google.golang.org/grpc/transport/http_util.go b/vendor/google.golang.org/grpc/transport/http_util.go new file mode 100644 index 0000000000..ea7b39bff9 --- /dev/null +++ b/vendor/google.golang.org/grpc/transport/http_util.go @@ -0,0 +1,455 @@ +/* + * + * Copyright 2014, Google Inc. + * 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. + * + */ + +package transport + +import ( + "bufio" + "fmt" + "io" + "net" + "strconv" + "strings" + "sync/atomic" + "time" + + "golang.org/x/net/http2" + "golang.org/x/net/http2/hpack" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" +) + +const ( + // The primary user agent + primaryUA = "grpc-go/0.11" + // http2MaxFrameLen specifies the max length of a HTTP2 frame. + http2MaxFrameLen = 16384 // 16KB frame + // http://http2.github.io/http2-spec/#SettingValues + http2InitHeaderTableSize = 4096 + // http2IOBufSize specifies the buffer size for sending frames. + http2IOBufSize = 32 * 1024 +) + +var ( + clientPreface = []byte(http2.ClientPreface) + http2ErrConvTab = map[http2.ErrCode]codes.Code{ + http2.ErrCodeNo: codes.Internal, + http2.ErrCodeProtocol: codes.Internal, + http2.ErrCodeInternal: codes.Internal, + http2.ErrCodeFlowControl: codes.ResourceExhausted, + http2.ErrCodeSettingsTimeout: codes.Internal, + http2.ErrCodeFrameSize: codes.Internal, + http2.ErrCodeRefusedStream: codes.Unavailable, + http2.ErrCodeCancel: codes.Canceled, + http2.ErrCodeCompression: codes.Internal, + http2.ErrCodeConnect: codes.Internal, + http2.ErrCodeEnhanceYourCalm: codes.ResourceExhausted, + http2.ErrCodeInadequateSecurity: codes.PermissionDenied, + http2.ErrCodeHTTP11Required: codes.FailedPrecondition, + } + statusCodeConvTab = map[codes.Code]http2.ErrCode{ + codes.Internal: http2.ErrCodeInternal, + codes.Canceled: http2.ErrCodeCancel, + codes.Unavailable: http2.ErrCodeRefusedStream, + codes.ResourceExhausted: http2.ErrCodeEnhanceYourCalm, + codes.PermissionDenied: http2.ErrCodeInadequateSecurity, + } +) + +// Records the states during HPACK decoding. Must be reset once the +// decoding of the entire headers are finished. +type decodeState struct { + encoding string + // statusCode caches the stream status received from the trailer + // the server sent. Client side only. + statusCode codes.Code + statusDesc string + // Server side only fields. + timeoutSet bool + timeout time.Duration + method string + // key-value metadata map from the peer. + mdata map[string][]string +} + +// An hpackDecoder decodes HTTP2 headers which may span multiple frames. +type hpackDecoder struct { + h *hpack.Decoder + state decodeState + err error // The err when decoding +} + +// A headerFrame is either a http2.HeaderFrame or http2.ContinuationFrame. +type headerFrame interface { + Header() http2.FrameHeader + HeaderBlockFragment() []byte + HeadersEnded() bool +} + +// isReservedHeader checks whether hdr belongs to HTTP2 headers +// reserved by gRPC protocol. Any other headers are classified as the +// user-specified metadata. +func isReservedHeader(hdr string) bool { + if hdr != "" && hdr[0] == ':' { + return true + } + switch hdr { + case "content-type", + "grpc-message-type", + "grpc-encoding", + "grpc-message", + "grpc-status", + "grpc-timeout", + "te": + return true + default: + return false + } +} + +func newHPACKDecoder() *hpackDecoder { + d := &hpackDecoder{} + d.h = hpack.NewDecoder(http2InitHeaderTableSize, func(f hpack.HeaderField) { + switch f.Name { + case "content-type": + if !strings.Contains(f.Value, "application/grpc") { + d.err = StreamErrorf(codes.FailedPrecondition, "transport: received the unexpected content-type %q", f.Value) + return + } + case "grpc-encoding": + d.state.encoding = f.Value + case "grpc-status": + code, err := strconv.Atoi(f.Value) + if err != nil { + d.err = StreamErrorf(codes.Internal, "transport: malformed grpc-status: %v", err) + return + } + d.state.statusCode = codes.Code(code) + case "grpc-message": + d.state.statusDesc = f.Value + case "grpc-timeout": + d.state.timeoutSet = true + var err error + d.state.timeout, err = timeoutDecode(f.Value) + if err != nil { + d.err = StreamErrorf(codes.Internal, "transport: malformed time-out: %v", err) + return + } + case ":path": + d.state.method = f.Value + default: + if !isReservedHeader(f.Name) { + if f.Name == "user-agent" { + i := strings.LastIndex(f.Value, " ") + if i == -1 { + // There is no application user agent string being set. + return + } + // Extract the application user agent string. + f.Value = f.Value[:i] + } + if d.state.mdata == nil { + d.state.mdata = make(map[string][]string) + } + k, v, err := metadata.DecodeKeyValue(f.Name, f.Value) + if err != nil { + grpclog.Printf("Failed to decode (%q, %q): %v", f.Name, f.Value, err) + return + } + d.state.mdata[k] = append(d.state.mdata[k], v) + } + } + }) + return d +} + +func (d *hpackDecoder) decodeClientHTTP2Headers(frame headerFrame) (endHeaders bool, err error) { + d.err = nil + _, err = d.h.Write(frame.HeaderBlockFragment()) + if err != nil { + err = StreamErrorf(codes.Internal, "transport: HPACK header decode error: %v", err) + } + + if frame.HeadersEnded() { + if closeErr := d.h.Close(); closeErr != nil && err == nil { + err = StreamErrorf(codes.Internal, "transport: HPACK decoder close error: %v", closeErr) + } + endHeaders = true + } + + if err == nil && d.err != nil { + err = d.err + } + return +} + +func (d *hpackDecoder) decodeServerHTTP2Headers(frame headerFrame) (endHeaders bool, err error) { + d.err = nil + _, err = d.h.Write(frame.HeaderBlockFragment()) + if err != nil { + err = StreamErrorf(codes.Internal, "transport: HPACK header decode error: %v", err) + } + + if frame.HeadersEnded() { + if closeErr := d.h.Close(); closeErr != nil && err == nil { + err = StreamErrorf(codes.Internal, "transport: HPACK decoder close error: %v", closeErr) + } + endHeaders = true + } + + if err == nil && d.err != nil { + err = d.err + } + return +} + +type timeoutUnit uint8 + +const ( + hour timeoutUnit = 'H' + minute timeoutUnit = 'M' + second timeoutUnit = 'S' + millisecond timeoutUnit = 'm' + microsecond timeoutUnit = 'u' + nanosecond timeoutUnit = 'n' +) + +func timeoutUnitToDuration(u timeoutUnit) (d time.Duration, ok bool) { + switch u { + case hour: + return time.Hour, true + case minute: + return time.Minute, true + case second: + return time.Second, true + case millisecond: + return time.Millisecond, true + case microsecond: + return time.Microsecond, true + case nanosecond: + return time.Nanosecond, true + default: + } + return +} + +const maxTimeoutValue int64 = 100000000 - 1 + +// div does integer division and round-up the result. Note that this is +// equivalent to (d+r-1)/r but has less chance to overflow. +func div(d, r time.Duration) int64 { + if m := d % r; m > 0 { + return int64(d/r + 1) + } + return int64(d / r) +} + +// TODO(zhaoq): It is the simplistic and not bandwidth efficient. Improve it. +func timeoutEncode(t time.Duration) string { + if d := div(t, time.Nanosecond); d <= maxTimeoutValue { + return strconv.FormatInt(d, 10) + "n" + } + if d := div(t, time.Microsecond); d <= maxTimeoutValue { + return strconv.FormatInt(d, 10) + "u" + } + if d := div(t, time.Millisecond); d <= maxTimeoutValue { + return strconv.FormatInt(d, 10) + "m" + } + if d := div(t, time.Second); d <= maxTimeoutValue { + return strconv.FormatInt(d, 10) + "S" + } + if d := div(t, time.Minute); d <= maxTimeoutValue { + return strconv.FormatInt(d, 10) + "M" + } + // Note that maxTimeoutValue * time.Hour > MaxInt64. + return strconv.FormatInt(div(t, time.Hour), 10) + "H" +} + +func timeoutDecode(s string) (time.Duration, error) { + size := len(s) + if size < 2 { + return 0, fmt.Errorf("transport: timeout string is too short: %q", s) + } + unit := timeoutUnit(s[size-1]) + d, ok := timeoutUnitToDuration(unit) + if !ok { + return 0, fmt.Errorf("transport: timeout unit is not recognized: %q", s) + } + t, err := strconv.ParseInt(s[:size-1], 10, 64) + if err != nil { + return 0, err + } + return d * time.Duration(t), nil +} + +type framer struct { + numWriters int32 + reader io.Reader + writer *bufio.Writer + fr *http2.Framer +} + +func newFramer(conn net.Conn) *framer { + f := &framer{ + reader: conn, + writer: bufio.NewWriterSize(conn, http2IOBufSize), + } + f.fr = http2.NewFramer(f.writer, f.reader) + return f +} + +func (f *framer) adjustNumWriters(i int32) int32 { + return atomic.AddInt32(&f.numWriters, i) +} + +// The following writeXXX functions can only be called when the caller gets +// unblocked from writableChan channel (i.e., owns the privilege to write). + +func (f *framer) writeContinuation(forceFlush bool, streamID uint32, endHeaders bool, headerBlockFragment []byte) error { + if err := f.fr.WriteContinuation(streamID, endHeaders, headerBlockFragment); err != nil { + return err + } + if forceFlush { + return f.writer.Flush() + } + return nil +} + +func (f *framer) writeData(forceFlush bool, streamID uint32, endStream bool, data []byte) error { + if err := f.fr.WriteData(streamID, endStream, data); err != nil { + return err + } + if forceFlush { + return f.writer.Flush() + } + return nil +} + +func (f *framer) writeGoAway(forceFlush bool, maxStreamID uint32, code http2.ErrCode, debugData []byte) error { + if err := f.fr.WriteGoAway(maxStreamID, code, debugData); err != nil { + return err + } + if forceFlush { + return f.writer.Flush() + } + return nil +} + +func (f *framer) writeHeaders(forceFlush bool, p http2.HeadersFrameParam) error { + if err := f.fr.WriteHeaders(p); err != nil { + return err + } + if forceFlush { + return f.writer.Flush() + } + return nil +} + +func (f *framer) writePing(forceFlush, ack bool, data [8]byte) error { + if err := f.fr.WritePing(ack, data); err != nil { + return err + } + if forceFlush { + return f.writer.Flush() + } + return nil +} + +func (f *framer) writePriority(forceFlush bool, streamID uint32, p http2.PriorityParam) error { + if err := f.fr.WritePriority(streamID, p); err != nil { + return err + } + if forceFlush { + return f.writer.Flush() + } + return nil +} + +func (f *framer) writePushPromise(forceFlush bool, p http2.PushPromiseParam) error { + if err := f.fr.WritePushPromise(p); err != nil { + return err + } + if forceFlush { + return f.writer.Flush() + } + return nil +} + +func (f *framer) writeRSTStream(forceFlush bool, streamID uint32, code http2.ErrCode) error { + if err := f.fr.WriteRSTStream(streamID, code); err != nil { + return err + } + if forceFlush { + return f.writer.Flush() + } + return nil +} + +func (f *framer) writeSettings(forceFlush bool, settings ...http2.Setting) error { + if err := f.fr.WriteSettings(settings...); err != nil { + return err + } + if forceFlush { + return f.writer.Flush() + } + return nil +} + +func (f *framer) writeSettingsAck(forceFlush bool) error { + if err := f.fr.WriteSettingsAck(); err != nil { + return err + } + if forceFlush { + return f.writer.Flush() + } + return nil +} + +func (f *framer) writeWindowUpdate(forceFlush bool, streamID, incr uint32) error { + if err := f.fr.WriteWindowUpdate(streamID, incr); err != nil { + return err + } + if forceFlush { + return f.writer.Flush() + } + return nil +} + +func (f *framer) flushWrite() error { + return f.writer.Flush() +} + +func (f *framer) readFrame() (http2.Frame, error) { + return f.fr.ReadFrame() +} diff --git a/vendor/google.golang.org/grpc/transport/transport.go b/vendor/google.golang.org/grpc/transport/transport.go new file mode 100644 index 0000000000..3b934b4dc0 --- /dev/null +++ b/vendor/google.golang.org/grpc/transport/transport.go @@ -0,0 +1,510 @@ +/* + * + * Copyright 2014, Google Inc. + * 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. + * + */ + +/* +Package transport defines and implements message oriented communication channel +to complete various transactions (e.g., an RPC). +*/ +package transport // import "google.golang.org/grpc/transport" + +import ( + "bytes" + "errors" + "fmt" + "io" + "net" + "sync" + "time" + + "golang.org/x/net/context" + "golang.org/x/net/trace" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/credentials" + "google.golang.org/grpc/metadata" +) + +// recvMsg represents the received msg from the transport. All transport +// protocol specific info has been removed. +type recvMsg struct { + data []byte + // nil: received some data + // io.EOF: stream is completed. data is nil. + // other non-nil error: transport failure. data is nil. + err error +} + +func (recvMsg) isItem() bool { + return true +} + +// All items in an out of a recvBuffer should be the same type. +type item interface { + isItem() bool +} + +// recvBuffer is an unbounded channel of item. +type recvBuffer struct { + c chan item + mu sync.Mutex + backlog []item +} + +func newRecvBuffer() *recvBuffer { + b := &recvBuffer{ + c: make(chan item, 1), + } + return b +} + +func (b *recvBuffer) put(r item) { + b.mu.Lock() + defer b.mu.Unlock() + b.backlog = append(b.backlog, r) + select { + case b.c <- b.backlog[0]: + b.backlog = b.backlog[1:] + default: + } +} + +func (b *recvBuffer) load() { + b.mu.Lock() + defer b.mu.Unlock() + if len(b.backlog) > 0 { + select { + case b.c <- b.backlog[0]: + b.backlog = b.backlog[1:] + default: + } + } +} + +// get returns the channel that receives an item in the buffer. +// +// Upon receipt of an item, the caller should call load to send another +// item onto the channel if there is any. +func (b *recvBuffer) get() <-chan item { + return b.c +} + +// recvBufferReader implements io.Reader interface to read the data from +// recvBuffer. +type recvBufferReader struct { + ctx context.Context + recv *recvBuffer + last *bytes.Reader // Stores the remaining data in the previous calls. + err error +} + +// Read reads the next len(p) bytes from last. If last is drained, it tries to +// read additional data from recv. It blocks if there no additional data available +// in recv. If Read returns any non-nil error, it will continue to return that error. +func (r *recvBufferReader) Read(p []byte) (n int, err error) { + if r.err != nil { + return 0, r.err + } + defer func() { r.err = err }() + if r.last != nil && r.last.Len() > 0 { + // Read remaining data left in last call. + return r.last.Read(p) + } + select { + case <-r.ctx.Done(): + return 0, ContextErr(r.ctx.Err()) + case i := <-r.recv.get(): + r.recv.load() + m := i.(*recvMsg) + if m.err != nil { + return 0, m.err + } + r.last = bytes.NewReader(m.data) + return r.last.Read(p) + } +} + +type streamState uint8 + +const ( + streamActive streamState = iota + streamWriteDone // EndStream sent + streamReadDone // EndStream received + streamDone // sendDone and recvDone or RSTStreamFrame is sent or received. +) + +// Stream represents an RPC in the transport layer. +type Stream struct { + id uint32 + // nil for client side Stream. + st ServerTransport + // ctx is the associated context of the stream. + ctx context.Context + cancel context.CancelFunc + // method records the associated RPC method of the stream. + method string + recvCompress string + sendCompress string + buf *recvBuffer + dec io.Reader + fc *inFlow + recvQuota uint32 + // The accumulated inbound quota pending for window update. + updateQuota uint32 + // The handler to control the window update procedure for both this + // particular stream and the associated transport. + windowHandler func(int) + + sendQuotaPool *quotaPool + // Close headerChan to indicate the end of reception of header metadata. + headerChan chan struct{} + // header caches the received header metadata. + header metadata.MD + // The key-value map of trailer metadata. + trailer metadata.MD + + mu sync.RWMutex // guard the following + // headerOK becomes true from the first header is about to send. + headerOk bool + state streamState + // true iff headerChan is closed. Used to avoid closing headerChan + // multiple times. + headerDone bool + // the status received from the server. + statusCode codes.Code + statusDesc string +} + +// RecvCompress returns the compression algorithm applied to the inbound +// message. It is empty string if there is no compression applied. +func (s *Stream) RecvCompress() string { + return s.recvCompress +} + +// SetSendCompress sets the compression algorithm to the stream. +func (s *Stream) SetSendCompress(str string) { + s.sendCompress = str +} + +// Header acquires the key-value pairs of header metadata once it +// is available. It blocks until i) the metadata is ready or ii) there is no +// header metadata or iii) the stream is cancelled/expired. +func (s *Stream) Header() (metadata.MD, error) { + select { + case <-s.ctx.Done(): + return nil, ContextErr(s.ctx.Err()) + case <-s.headerChan: + return s.header.Copy(), nil + } +} + +// Trailer returns the cached trailer metedata. Note that if it is not called +// after the entire stream is done, it could return an empty MD. Client +// side only. +func (s *Stream) Trailer() metadata.MD { + s.mu.RLock() + defer s.mu.RUnlock() + return s.trailer.Copy() +} + +// ServerTransport returns the underlying ServerTransport for the stream. +// The client side stream always returns nil. +func (s *Stream) ServerTransport() ServerTransport { + return s.st +} + +// Context returns the context of the stream. +func (s *Stream) Context() context.Context { + return s.ctx +} + +// TraceContext recreates the context of s with a trace.Trace. +func (s *Stream) TraceContext(tr trace.Trace) { + s.ctx = trace.NewContext(s.ctx, tr) +} + +// Method returns the method for the stream. +func (s *Stream) Method() string { + return s.method +} + +// StatusCode returns statusCode received from the server. +func (s *Stream) StatusCode() codes.Code { + return s.statusCode +} + +// StatusDesc returns statusDesc received from the server. +func (s *Stream) StatusDesc() string { + return s.statusDesc +} + +// ErrIllegalTrailerSet indicates that the trailer has already been set or it +// is too late to do so. +var ErrIllegalTrailerSet = errors.New("transport: trailer has been set") + +// SetTrailer sets the trailer metadata which will be sent with the RPC status +// by the server. This can only be called at most once. Server side only. +func (s *Stream) SetTrailer(md metadata.MD) error { + s.mu.Lock() + defer s.mu.Unlock() + if s.trailer != nil { + return ErrIllegalTrailerSet + } + s.trailer = md.Copy() + return nil +} + +func (s *Stream) write(m recvMsg) { + s.buf.put(&m) +} + +// Read reads all the data available for this Stream from the transport and +// passes them into the decoder, which converts them into a gRPC message stream. +// The error is io.EOF when the stream is done or another non-nil error if +// the stream broke. +func (s *Stream) Read(p []byte) (n int, err error) { + n, err = s.dec.Read(p) + if err != nil { + return + } + s.windowHandler(n) + return +} + +type key int + +// The key to save transport.Stream in the context. +const streamKey = key(0) + +// newContextWithStream creates a new context from ctx and attaches stream +// to it. +func newContextWithStream(ctx context.Context, stream *Stream) context.Context { + return context.WithValue(ctx, streamKey, stream) +} + +// StreamFromContext returns the stream saved in ctx. +func StreamFromContext(ctx context.Context) (s *Stream, ok bool) { + s, ok = ctx.Value(streamKey).(*Stream) + return +} + +// state of transport +type transportState int + +const ( + reachable transportState = iota + unreachable + closing +) + +// NewServerTransport creates a ServerTransport with conn or non-nil error +// if it fails. +func NewServerTransport(protocol string, conn net.Conn, maxStreams uint32, authInfo credentials.AuthInfo) (ServerTransport, error) { + return newHTTP2Server(conn, maxStreams, authInfo) +} + +// ConnectOptions covers all relevant options for dialing a server. +type ConnectOptions struct { + // UserAgent is the application user agent. + UserAgent string + // Dialer specifies how to dial a network address. + Dialer func(string, time.Duration) (net.Conn, error) + // AuthOptions stores the credentials required to setup a client connection and/or issue RPCs. + AuthOptions []credentials.Credentials + // Timeout specifies the timeout for dialing a client connection. + Timeout time.Duration +} + +// NewClientTransport establishes the transport with the required ConnectOptions +// and returns it to the caller. +func NewClientTransport(target string, opts *ConnectOptions) (ClientTransport, error) { + return newHTTP2Client(target, opts) +} + +// Options provides additional hints and information for message +// transmission. +type Options struct { + // Last indicates whether this write is the last piece for + // this stream. + Last bool + + // Delay is a hint to the transport implementation for whether + // the data could be buffered for a batching write. The + // Transport implementation may ignore the hint. + Delay bool +} + +// CallHdr carries the information of a particular RPC. +type CallHdr struct { + // Host specifies the peer's host. + Host string + + // Method specifies the operation to perform. + Method string + + // RecvCompress specifies the compression algorithm applied on + // inbound messages. + RecvCompress string + + // SendCompress specifies the compression algorithm applied on + // outbound message. + SendCompress string + + // Flush indicates whether a new stream command should be sent + // to the peer without waiting for the first data. This is + // only a hint. The transport may modify the flush decision + // for performance purposes. + Flush bool +} + +// ClientTransport is the common interface for all gRPC client-side transport +// implementations. +type ClientTransport interface { + // Close tears down this transport. Once it returns, the transport + // should not be accessed any more. The caller must make sure this + // is called only once. + Close() error + + // Write sends the data for the given stream. A nil stream indicates + // the write is to be performed on the transport as a whole. + Write(s *Stream, data []byte, opts *Options) error + + // NewStream creates a Stream for an RPC. + NewStream(ctx context.Context, callHdr *CallHdr) (*Stream, error) + + // CloseStream clears the footprint of a stream when the stream is + // not needed any more. The err indicates the error incurred when + // CloseStream is called. Must be called when a stream is finished + // unless the associated transport is closing. + CloseStream(stream *Stream, err error) + + // Error returns a channel that is closed when some I/O error + // happens. Typically the caller should have a goroutine to monitor + // this in order to take action (e.g., close the current transport + // and create a new one) in error case. It should not return nil + // once the transport is initiated. + Error() <-chan struct{} +} + +// ServerTransport is the common interface for all gRPC server-side transport +// implementations. +// +// Methods may be called concurrently from multiple goroutines, but +// Write methods for a given Stream will be called serially. +type ServerTransport interface { + // HandleStreams receives incoming streams using the given handler. + HandleStreams(func(*Stream)) + + // WriteHeader sends the header metadata for the given stream. + // WriteHeader may not be called on all streams. + WriteHeader(s *Stream, md metadata.MD) error + + // Write sends the data for the given stream. + // Write may not be called on all streams. + Write(s *Stream, data []byte, opts *Options) error + + // WriteStatus sends the status of a stream to the client. + // WriteStatus is the final call made on a stream and always + // occurs. + WriteStatus(s *Stream, statusCode codes.Code, statusDesc string) error + + // Close tears down the transport. Once it is called, the transport + // should not be accessed any more. All the pending streams and their + // handlers will be terminated asynchronously. + Close() error + + // RemoteAddr returns the remote network address. + RemoteAddr() net.Addr +} + +// StreamErrorf creates an StreamError with the specified error code and description. +func StreamErrorf(c codes.Code, format string, a ...interface{}) StreamError { + return StreamError{ + Code: c, + Desc: fmt.Sprintf(format, a...), + } +} + +// ConnectionErrorf creates an ConnectionError with the specified error description. +func ConnectionErrorf(format string, a ...interface{}) ConnectionError { + return ConnectionError{ + Desc: fmt.Sprintf(format, a...), + } +} + +// ConnectionError is an error that results in the termination of the +// entire connection and the retry of all the active streams. +type ConnectionError struct { + Desc string +} + +func (e ConnectionError) Error() string { + return fmt.Sprintf("connection error: desc = %q", e.Desc) +} + +// Define some common ConnectionErrors. +var ErrConnClosing = ConnectionError{Desc: "transport is closing"} + +// StreamError is an error that only affects one stream within a connection. +type StreamError struct { + Code codes.Code + Desc string +} + +func (e StreamError) Error() string { + return fmt.Sprintf("stream error: code = %d desc = %q", e.Code, e.Desc) +} + +// ContextErr converts the error from context package into a StreamError. +func ContextErr(err error) StreamError { + switch err { + case context.DeadlineExceeded: + return StreamErrorf(codes.DeadlineExceeded, "%v", err) + case context.Canceled: + return StreamErrorf(codes.Canceled, "%v", err) + } + panic(fmt.Sprintf("Unexpected error from context packet: %v", err)) +} + +// wait blocks until it can receive from ctx.Done, closing, or proceed. +// If it receives from ctx.Done, it returns 0, the StreamError for ctx.Err. +// If it receives from closing, it returns 0, ErrConnClosing. +// If it receives from proceed, it returns the received integer, nil. +func wait(ctx context.Context, closing <-chan struct{}, proceed <-chan int) (int, error) { + select { + case <-ctx.Done(): + return 0, ContextErr(ctx.Err()) + case <-closing: + return 0, ErrConnClosing + case i := <-proceed: + return i, nil + } +} diff --git a/vendor/gopkg.in/inf.v0/LICENSE b/vendor/gopkg.in/inf.v0/LICENSE new file mode 100644 index 0000000000..87a5cede33 --- /dev/null +++ b/vendor/gopkg.in/inf.v0/LICENSE @@ -0,0 +1,28 @@ +Copyright (c) 2012 Péter Surányi. Portions 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. diff --git a/vendor/gopkg.in/inf.v0/dec.go b/vendor/gopkg.in/inf.v0/dec.go new file mode 100644 index 0000000000..3b4afedf1a --- /dev/null +++ b/vendor/gopkg.in/inf.v0/dec.go @@ -0,0 +1,615 @@ +// Package inf (type inf.Dec) implements "infinite-precision" decimal +// arithmetic. +// "Infinite precision" describes two characteristics: practically unlimited +// precision for decimal number representation and no support for calculating +// with any specific fixed precision. +// (Although there is no practical limit on precision, inf.Dec can only +// represent finite decimals.) +// +// This package is currently in experimental stage and the API may change. +// +// This package does NOT support: +// - rounding to specific precisions (as opposed to specific decimal positions) +// - the notion of context (each rounding must be explicit) +// - NaN and Inf values, and distinguishing between positive and negative zero +// - conversions to and from float32/64 types +// +// Features considered for possible addition: +// + formatting options +// + Exp method +// + combined operations such as AddRound/MulAdd etc +// + exchanging data in decimal32/64/128 formats +// +package inf // import "gopkg.in/inf.v0" + +// TODO: +// - avoid excessive deep copying (quo and rounders) + +import ( + "fmt" + "io" + "math/big" + "strings" +) + +// A Dec represents a signed arbitrary-precision decimal. +// It is a combination of a sign, an arbitrary-precision integer coefficient +// value, and a signed fixed-precision exponent value. +// The sign and the coefficient value are handled together as a signed value +// and referred to as the unscaled value. +// (Positive and negative zero values are not distinguished.) +// Since the exponent is most commonly non-positive, it is handled in negated +// form and referred to as scale. +// +// The mathematical value of a Dec equals: +// +// unscaled * 10**(-scale) +// +// Note that different Dec representations may have equal mathematical values. +// +// unscaled scale String() +// ------------------------- +// 0 0 "0" +// 0 2 "0.00" +// 0 -2 "0" +// 1 0 "1" +// 100 2 "1.00" +// 10 0 "10" +// 1 -1 "10" +// +// The zero value for a Dec represents the value 0 with scale 0. +// +// Operations are typically performed through the *Dec type. +// The semantics of the assignment operation "=" for "bare" Dec values is +// undefined and should not be relied on. +// +// Methods are typically of the form: +// +// func (z *Dec) Op(x, y *Dec) *Dec +// +// and implement operations z = x Op y with the result as receiver; if it +// is one of the operands it may be overwritten (and its memory reused). +// To enable chaining of operations, the result is also returned. Methods +// returning a result other than *Dec take one of the operands as the receiver. +// +// A "bare" Quo method (quotient / division operation) is not provided, as the +// result is not always a finite decimal and thus in general cannot be +// represented as a Dec. +// Instead, in the common case when rounding is (potentially) necessary, +// QuoRound should be used with a Scale and a Rounder. +// QuoExact or QuoRound with RoundExact can be used in the special cases when it +// is known that the result is always a finite decimal. +// +type Dec struct { + unscaled big.Int + scale Scale +} + +// Scale represents the type used for the scale of a Dec. +type Scale int32 + +const scaleSize = 4 // bytes in a Scale value + +// Scaler represents a method for obtaining the scale to use for the result of +// an operation on x and y. +type scaler interface { + Scale(x *Dec, y *Dec) Scale +} + +var bigInt = [...]*big.Int{ + big.NewInt(0), big.NewInt(1), big.NewInt(2), big.NewInt(3), big.NewInt(4), + big.NewInt(5), big.NewInt(6), big.NewInt(7), big.NewInt(8), big.NewInt(9), + big.NewInt(10), +} + +var exp10cache [64]big.Int = func() [64]big.Int { + e10, e10i := [64]big.Int{}, bigInt[1] + for i, _ := range e10 { + e10[i].Set(e10i) + e10i = new(big.Int).Mul(e10i, bigInt[10]) + } + return e10 +}() + +// NewDec allocates and returns a new Dec set to the given int64 unscaled value +// and scale. +func NewDec(unscaled int64, scale Scale) *Dec { + return new(Dec).SetUnscaled(unscaled).SetScale(scale) +} + +// NewDecBig allocates and returns a new Dec set to the given *big.Int unscaled +// value and scale. +func NewDecBig(unscaled *big.Int, scale Scale) *Dec { + return new(Dec).SetUnscaledBig(unscaled).SetScale(scale) +} + +// Scale returns the scale of x. +func (x *Dec) Scale() Scale { + return x.scale +} + +// Unscaled returns the unscaled value of x for u and true for ok when the +// unscaled value can be represented as int64; otherwise it returns an undefined +// int64 value for u and false for ok. Use x.UnscaledBig().Int64() to avoid +// checking the validity of the value when the check is known to be redundant. +func (x *Dec) Unscaled() (u int64, ok bool) { + u = x.unscaled.Int64() + var i big.Int + ok = i.SetInt64(u).Cmp(&x.unscaled) == 0 + return +} + +// UnscaledBig returns the unscaled value of x as *big.Int. +func (x *Dec) UnscaledBig() *big.Int { + return &x.unscaled +} + +// SetScale sets the scale of z, with the unscaled value unchanged, and returns +// z. +// The mathematical value of the Dec changes as if it was multiplied by +// 10**(oldscale-scale). +func (z *Dec) SetScale(scale Scale) *Dec { + z.scale = scale + return z +} + +// SetUnscaled sets the unscaled value of z, with the scale unchanged, and +// returns z. +func (z *Dec) SetUnscaled(unscaled int64) *Dec { + z.unscaled.SetInt64(unscaled) + return z +} + +// SetUnscaledBig sets the unscaled value of z, with the scale unchanged, and +// returns z. +func (z *Dec) SetUnscaledBig(unscaled *big.Int) *Dec { + z.unscaled.Set(unscaled) + return z +} + +// Set sets z to the value of x and returns z. +// It does nothing if z == x. +func (z *Dec) Set(x *Dec) *Dec { + if z != x { + z.SetUnscaledBig(x.UnscaledBig()) + z.SetScale(x.Scale()) + } + return z +} + +// Sign returns: +// +// -1 if x < 0 +// 0 if x == 0 +// +1 if x > 0 +// +func (x *Dec) Sign() int { + return x.UnscaledBig().Sign() +} + +// Neg sets z to -x and returns z. +func (z *Dec) Neg(x *Dec) *Dec { + z.SetScale(x.Scale()) + z.UnscaledBig().Neg(x.UnscaledBig()) + return z +} + +// Cmp compares x and y and returns: +// +// -1 if x < y +// 0 if x == y +// +1 if x > y +// +func (x *Dec) Cmp(y *Dec) int { + xx, yy := upscale(x, y) + return xx.UnscaledBig().Cmp(yy.UnscaledBig()) +} + +// Abs sets z to |x| (the absolute value of x) and returns z. +func (z *Dec) Abs(x *Dec) *Dec { + z.SetScale(x.Scale()) + z.UnscaledBig().Abs(x.UnscaledBig()) + return z +} + +// Add sets z to the sum x+y and returns z. +// The scale of z is the greater of the scales of x and y. +func (z *Dec) Add(x, y *Dec) *Dec { + xx, yy := upscale(x, y) + z.SetScale(xx.Scale()) + z.UnscaledBig().Add(xx.UnscaledBig(), yy.UnscaledBig()) + return z +} + +// Sub sets z to the difference x-y and returns z. +// The scale of z is the greater of the scales of x and y. +func (z *Dec) Sub(x, y *Dec) *Dec { + xx, yy := upscale(x, y) + z.SetScale(xx.Scale()) + z.UnscaledBig().Sub(xx.UnscaledBig(), yy.UnscaledBig()) + return z +} + +// Mul sets z to the product x*y and returns z. +// The scale of z is the sum of the scales of x and y. +func (z *Dec) Mul(x, y *Dec) *Dec { + z.SetScale(x.Scale() + y.Scale()) + z.UnscaledBig().Mul(x.UnscaledBig(), y.UnscaledBig()) + return z +} + +// Round sets z to the value of x rounded to Scale s using Rounder r, and +// returns z. +func (z *Dec) Round(x *Dec, s Scale, r Rounder) *Dec { + return z.QuoRound(x, NewDec(1, 0), s, r) +} + +// QuoRound sets z to the quotient x/y, rounded using the given Rounder to the +// specified scale. +// +// If the rounder is RoundExact but the result can not be expressed exactly at +// the specified scale, QuoRound returns nil, and the value of z is undefined. +// +// There is no corresponding Div method; the equivalent can be achieved through +// the choice of Rounder used. +// +func (z *Dec) QuoRound(x, y *Dec, s Scale, r Rounder) *Dec { + return z.quo(x, y, sclr{s}, r) +} + +func (z *Dec) quo(x, y *Dec, s scaler, r Rounder) *Dec { + scl := s.Scale(x, y) + var zzz *Dec + if r.UseRemainder() { + zz, rA, rB := new(Dec).quoRem(x, y, scl, true, new(big.Int), new(big.Int)) + zzz = r.Round(new(Dec), zz, rA, rB) + } else { + zz, _, _ := new(Dec).quoRem(x, y, scl, false, nil, nil) + zzz = r.Round(new(Dec), zz, nil, nil) + } + if zzz == nil { + return nil + } + return z.Set(zzz) +} + +// QuoExact sets z to the quotient x/y and returns z when x/y is a finite +// decimal. Otherwise it returns nil and the value of z is undefined. +// +// The scale of a non-nil result is "x.Scale() - y.Scale()" or greater; it is +// calculated so that the remainder will be zero whenever x/y is a finite +// decimal. +func (z *Dec) QuoExact(x, y *Dec) *Dec { + return z.quo(x, y, scaleQuoExact{}, RoundExact) +} + +// quoRem sets z to the quotient x/y with the scale s, and if useRem is true, +// it sets remNum and remDen to the numerator and denominator of the remainder. +// It returns z, remNum and remDen. +// +// The remainder is normalized to the range -1 < r < 1 to simplify rounding; +// that is, the results satisfy the following equation: +// +// x / y = z + (remNum/remDen) * 10**(-z.Scale()) +// +// See Rounder for more details about rounding. +// +func (z *Dec) quoRem(x, y *Dec, s Scale, useRem bool, + remNum, remDen *big.Int) (*Dec, *big.Int, *big.Int) { + // difference (required adjustment) compared to "canonical" result scale + shift := s - (x.Scale() - y.Scale()) + // pointers to adjusted unscaled dividend and divisor + var ix, iy *big.Int + switch { + case shift > 0: + // increased scale: decimal-shift dividend left + ix = new(big.Int).Mul(x.UnscaledBig(), exp10(shift)) + iy = y.UnscaledBig() + case shift < 0: + // decreased scale: decimal-shift divisor left + ix = x.UnscaledBig() + iy = new(big.Int).Mul(y.UnscaledBig(), exp10(-shift)) + default: + ix = x.UnscaledBig() + iy = y.UnscaledBig() + } + // save a copy of iy in case it to be overwritten with the result + iy2 := iy + if iy == z.UnscaledBig() { + iy2 = new(big.Int).Set(iy) + } + // set scale + z.SetScale(s) + // set unscaled + if useRem { + // Int division + _, intr := z.UnscaledBig().QuoRem(ix, iy, new(big.Int)) + // set remainder + remNum.Set(intr) + remDen.Set(iy2) + } else { + z.UnscaledBig().Quo(ix, iy) + } + return z, remNum, remDen +} + +type sclr struct{ s Scale } + +func (s sclr) Scale(x, y *Dec) Scale { + return s.s +} + +type scaleQuoExact struct{} + +func (sqe scaleQuoExact) Scale(x, y *Dec) Scale { + rem := new(big.Rat).SetFrac(x.UnscaledBig(), y.UnscaledBig()) + f2, f5 := factor2(rem.Denom()), factor(rem.Denom(), bigInt[5]) + var f10 Scale + if f2 > f5 { + f10 = Scale(f2) + } else { + f10 = Scale(f5) + } + return x.Scale() - y.Scale() + f10 +} + +func factor(n *big.Int, p *big.Int) int { + // could be improved for large factors + d, f := n, 0 + for { + dd, dm := new(big.Int).DivMod(d, p, new(big.Int)) + if dm.Sign() == 0 { + f++ + d = dd + } else { + break + } + } + return f +} + +func factor2(n *big.Int) int { + // could be improved for large factors + f := 0 + for ; n.Bit(f) == 0; f++ { + } + return f +} + +func upscale(a, b *Dec) (*Dec, *Dec) { + if a.Scale() == b.Scale() { + return a, b + } + if a.Scale() > b.Scale() { + bb := b.rescale(a.Scale()) + return a, bb + } + aa := a.rescale(b.Scale()) + return aa, b +} + +func exp10(x Scale) *big.Int { + if int(x) < len(exp10cache) { + return &exp10cache[int(x)] + } + return new(big.Int).Exp(bigInt[10], big.NewInt(int64(x)), nil) +} + +func (x *Dec) rescale(newScale Scale) *Dec { + shift := newScale - x.Scale() + switch { + case shift < 0: + e := exp10(-shift) + return NewDecBig(new(big.Int).Quo(x.UnscaledBig(), e), newScale) + case shift > 0: + e := exp10(shift) + return NewDecBig(new(big.Int).Mul(x.UnscaledBig(), e), newScale) + } + return x +} + +var zeros = []byte("00000000000000000000000000000000" + + "00000000000000000000000000000000") +var lzeros = Scale(len(zeros)) + +func appendZeros(s []byte, n Scale) []byte { + for i := Scale(0); i < n; i += lzeros { + if n > i+lzeros { + s = append(s, zeros...) + } else { + s = append(s, zeros[0:n-i]...) + } + } + return s +} + +func (x *Dec) String() string { + if x == nil { + return "" + } + scale := x.Scale() + s := []byte(x.UnscaledBig().String()) + if scale <= 0 { + if scale != 0 && x.unscaled.Sign() != 0 { + s = appendZeros(s, -scale) + } + return string(s) + } + negbit := Scale(-((x.Sign() - 1) / 2)) + // scale > 0 + lens := Scale(len(s)) + if lens-negbit <= scale { + ss := make([]byte, 0, scale+2) + if negbit == 1 { + ss = append(ss, '-') + } + ss = append(ss, '0', '.') + ss = appendZeros(ss, scale-lens+negbit) + ss = append(ss, s[negbit:]...) + return string(ss) + } + // lens > scale + ss := make([]byte, 0, lens+1) + ss = append(ss, s[:lens-scale]...) + ss = append(ss, '.') + ss = append(ss, s[lens-scale:]...) + return string(ss) +} + +// Format is a support routine for fmt.Formatter. It accepts the decimal +// formats 'd' and 'f', and handles both equivalently. +// Width, precision, flags and bases 2, 8, 16 are not supported. +func (x *Dec) Format(s fmt.State, ch rune) { + if ch != 'd' && ch != 'f' && ch != 'v' && ch != 's' { + fmt.Fprintf(s, "%%!%c(dec.Dec=%s)", ch, x.String()) + return + } + fmt.Fprintf(s, x.String()) +} + +func (z *Dec) scan(r io.RuneScanner) (*Dec, error) { + unscaled := make([]byte, 0, 256) // collects chars of unscaled as bytes + dp, dg := -1, -1 // indexes of decimal point, first digit +loop: + for { + ch, _, err := r.ReadRune() + if err == io.EOF { + break loop + } + if err != nil { + return nil, err + } + switch { + case ch == '+' || ch == '-': + if len(unscaled) > 0 || dp >= 0 { // must be first character + r.UnreadRune() + break loop + } + case ch == '.': + if dp >= 0 { + r.UnreadRune() + break loop + } + dp = len(unscaled) + continue // don't add to unscaled + case ch >= '0' && ch <= '9': + if dg == -1 { + dg = len(unscaled) + } + default: + r.UnreadRune() + break loop + } + unscaled = append(unscaled, byte(ch)) + } + if dg == -1 { + return nil, fmt.Errorf("no digits read") + } + if dp >= 0 { + z.SetScale(Scale(len(unscaled) - dp)) + } else { + z.SetScale(0) + } + _, ok := z.UnscaledBig().SetString(string(unscaled), 10) + if !ok { + return nil, fmt.Errorf("invalid decimal: %s", string(unscaled)) + } + return z, nil +} + +// SetString sets z to the value of s, interpreted as a decimal (base 10), +// and returns z and a boolean indicating success. The scale of z is the +// number of digits after the decimal point (including any trailing 0s), +// or 0 if there is no decimal point. If SetString fails, the value of z +// is undefined but the returned value is nil. +func (z *Dec) SetString(s string) (*Dec, bool) { + r := strings.NewReader(s) + _, err := z.scan(r) + if err != nil { + return nil, false + } + _, _, err = r.ReadRune() + if err != io.EOF { + return nil, false + } + // err == io.EOF => scan consumed all of s + return z, true +} + +// Scan is a support routine for fmt.Scanner; it sets z to the value of +// the scanned number. It accepts the decimal formats 'd' and 'f', and +// handles both equivalently. Bases 2, 8, 16 are not supported. +// The scale of z is the number of digits after the decimal point +// (including any trailing 0s), or 0 if there is no decimal point. +func (z *Dec) Scan(s fmt.ScanState, ch rune) error { + if ch != 'd' && ch != 'f' && ch != 's' && ch != 'v' { + return fmt.Errorf("Dec.Scan: invalid verb '%c'", ch) + } + s.SkipSpace() + _, err := z.scan(s) + return err +} + +// Gob encoding version +const decGobVersion byte = 1 + +func scaleBytes(s Scale) []byte { + buf := make([]byte, scaleSize) + i := scaleSize + for j := 0; j < scaleSize; j++ { + i-- + buf[i] = byte(s) + s >>= 8 + } + return buf +} + +func scale(b []byte) (s Scale) { + for j := 0; j < scaleSize; j++ { + s <<= 8 + s |= Scale(b[j]) + } + return +} + +// GobEncode implements the gob.GobEncoder interface. +func (x *Dec) GobEncode() ([]byte, error) { + buf, err := x.UnscaledBig().GobEncode() + if err != nil { + return nil, err + } + buf = append(append(buf, scaleBytes(x.Scale())...), decGobVersion) + return buf, nil +} + +// GobDecode implements the gob.GobDecoder interface. +func (z *Dec) GobDecode(buf []byte) error { + if len(buf) == 0 { + return fmt.Errorf("Dec.GobDecode: no data") + } + b := buf[len(buf)-1] + if b != decGobVersion { + return fmt.Errorf("Dec.GobDecode: encoding version %d not supported", b) + } + l := len(buf) - scaleSize - 1 + err := z.UnscaledBig().GobDecode(buf[:l]) + if err != nil { + return err + } + z.SetScale(scale(buf[l : l+scaleSize])) + return nil +} + +// MarshalText implements the encoding.TextMarshaler interface. +func (x *Dec) MarshalText() ([]byte, error) { + return []byte(x.String()), nil +} + +// UnmarshalText implements the encoding.TextUnmarshaler interface. +func (z *Dec) UnmarshalText(data []byte) error { + _, ok := z.SetString(string(data)) + if !ok { + return fmt.Errorf("invalid inf.Dec") + } + return nil +} diff --git a/vendor/gopkg.in/inf.v0/rounder.go b/vendor/gopkg.in/inf.v0/rounder.go new file mode 100644 index 0000000000..3a97ef529b --- /dev/null +++ b/vendor/gopkg.in/inf.v0/rounder.go @@ -0,0 +1,145 @@ +package inf + +import ( + "math/big" +) + +// Rounder represents a method for rounding the (possibly infinite decimal) +// result of a division to a finite Dec. It is used by Dec.Round() and +// Dec.Quo(). +// +// See the Example for results of using each Rounder with some sample values. +// +type Rounder rounder + +// See http://speleotrove.com/decimal/damodel.html#refround for more detailed +// definitions of these rounding modes. +var ( + RoundDown Rounder // towards 0 + RoundUp Rounder // away from 0 + RoundFloor Rounder // towards -infinity + RoundCeil Rounder // towards +infinity + RoundHalfDown Rounder // to nearest; towards 0 if same distance + RoundHalfUp Rounder // to nearest; away from 0 if same distance + RoundHalfEven Rounder // to nearest; even last digit if same distance +) + +// RoundExact is to be used in the case when rounding is not necessary. +// When used with Quo or Round, it returns the result verbatim when it can be +// expressed exactly with the given precision, and it returns nil otherwise. +// QuoExact is a shorthand for using Quo with RoundExact. +var RoundExact Rounder + +type rounder interface { + + // When UseRemainder() returns true, the Round() method is passed the + // remainder of the division, expressed as the numerator and denominator of + // a rational. + UseRemainder() bool + + // Round sets the rounded value of a quotient to z, and returns z. + // quo is rounded down (truncated towards zero) to the scale obtained from + // the Scaler in Quo(). + // + // When the remainder is not used, remNum and remDen are nil. + // When used, the remainder is normalized between -1 and 1; that is: + // + // -|remDen| < remNum < |remDen| + // + // remDen has the same sign as y, and remNum is zero or has the same sign + // as x. + Round(z, quo *Dec, remNum, remDen *big.Int) *Dec +} + +type rndr struct { + useRem bool + round func(z, quo *Dec, remNum, remDen *big.Int) *Dec +} + +func (r rndr) UseRemainder() bool { + return r.useRem +} + +func (r rndr) Round(z, quo *Dec, remNum, remDen *big.Int) *Dec { + return r.round(z, quo, remNum, remDen) +} + +var intSign = []*big.Int{big.NewInt(-1), big.NewInt(0), big.NewInt(1)} + +func roundHalf(f func(c int, odd uint) (roundUp bool)) func(z, q *Dec, rA, rB *big.Int) *Dec { + return func(z, q *Dec, rA, rB *big.Int) *Dec { + z.Set(q) + brA, brB := rA.BitLen(), rB.BitLen() + if brA < brB-1 { + // brA < brB-1 => |rA| < |rB/2| + return z + } + roundUp := false + srA, srB := rA.Sign(), rB.Sign() + s := srA * srB + if brA == brB-1 { + rA2 := new(big.Int).Lsh(rA, 1) + if s < 0 { + rA2.Neg(rA2) + } + roundUp = f(rA2.Cmp(rB)*srB, z.UnscaledBig().Bit(0)) + } else { + // brA > brB-1 => |rA| > |rB/2| + roundUp = true + } + if roundUp { + z.UnscaledBig().Add(z.UnscaledBig(), intSign[s+1]) + } + return z + } +} + +func init() { + RoundExact = rndr{true, + func(z, q *Dec, rA, rB *big.Int) *Dec { + if rA.Sign() != 0 { + return nil + } + return z.Set(q) + }} + RoundDown = rndr{false, + func(z, q *Dec, rA, rB *big.Int) *Dec { + return z.Set(q) + }} + RoundUp = rndr{true, + func(z, q *Dec, rA, rB *big.Int) *Dec { + z.Set(q) + if rA.Sign() != 0 { + z.UnscaledBig().Add(z.UnscaledBig(), intSign[rA.Sign()*rB.Sign()+1]) + } + return z + }} + RoundFloor = rndr{true, + func(z, q *Dec, rA, rB *big.Int) *Dec { + z.Set(q) + if rA.Sign()*rB.Sign() < 0 { + z.UnscaledBig().Add(z.UnscaledBig(), intSign[0]) + } + return z + }} + RoundCeil = rndr{true, + func(z, q *Dec, rA, rB *big.Int) *Dec { + z.Set(q) + if rA.Sign()*rB.Sign() > 0 { + z.UnscaledBig().Add(z.UnscaledBig(), intSign[2]) + } + return z + }} + RoundHalfDown = rndr{true, roundHalf( + func(c int, odd uint) bool { + return c > 0 + })} + RoundHalfUp = rndr{true, roundHalf( + func(c int, odd uint) bool { + return c >= 0 + })} + RoundHalfEven = rndr{true, roundHalf( + func(c int, odd uint) bool { + return c > 0 || c == 0 && odd == 1 + })} +} diff --git a/vendor/k8s.io/kubernetes/LICENSE b/vendor/k8s.io/kubernetes/LICENSE new file mode 100644 index 0000000000..6b4d837a44 --- /dev/null +++ b/vendor/k8s.io/kubernetes/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor 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, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2014 The Kubernetes Authors All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/k8s.io/kubernetes/pkg/api/resource/deep_copy_generated.go b/vendor/k8s.io/kubernetes/pkg/api/resource/deep_copy_generated.go new file mode 100644 index 0000000000..6a34e2d434 --- /dev/null +++ b/vendor/k8s.io/kubernetes/pkg/api/resource/deep_copy_generated.go @@ -0,0 +1,55 @@ +// +build !ignore_autogenerated + +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// This file was autogenerated by deepcopy-gen. Do not edit it manually! + +package resource + +import ( + inf_v0 "gopkg.in/inf.v0" + conversion "k8s.io/kubernetes/pkg/conversion" +) + +func DeepCopy_resource_Quantity(in Quantity, out *Quantity, c *conversion.Cloner) error { + if in.Amount != nil { + in, out := in.Amount, &out.Amount + *out = new(inf_v0.Dec) + if newVal, err := c.DeepCopy(*in); err != nil { + return err + } else { + **out = newVal.(inf_v0.Dec) + } + } else { + out.Amount = nil + } + out.Format = in.Format + return nil +} + +func DeepCopy_resource_QuantityProto(in QuantityProto, out *QuantityProto, c *conversion.Cloner) error { + out.Format = in.Format + out.Scale = in.Scale + if in.Bigint != nil { + in, out := in.Bigint, &out.Bigint + *out = make([]byte, len(in)) + copy(*out, in) + } else { + out.Bigint = nil + } + return nil +} diff --git a/vendor/k8s.io/kubernetes/pkg/api/resource/generated.pb.go b/vendor/k8s.io/kubernetes/pkg/api/resource/generated.pb.go new file mode 100644 index 0000000000..7484f92761 --- /dev/null +++ b/vendor/k8s.io/kubernetes/pkg/api/resource/generated.pb.go @@ -0,0 +1,371 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by protoc-gen-gogo. +// source: k8s.io/kubernetes/pkg/api/resource/generated.proto +// DO NOT EDIT! + +/* + Package resource is a generated protocol buffer package. + + It is generated from these files: + k8s.io/kubernetes/pkg/api/resource/generated.proto + + It has these top-level messages: + Quantity + QuantityProto +*/ +package resource + +import proto "github.com/gogo/protobuf/proto" +import fmt "fmt" +import math "math" + +import io "io" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +func (m *Quantity) Reset() { *m = Quantity{} } +func (*Quantity) ProtoMessage() {} + +func (m *QuantityProto) Reset() { *m = QuantityProto{} } +func (m *QuantityProto) String() string { return proto.CompactTextString(m) } +func (*QuantityProto) ProtoMessage() {} + +func init() { + proto.RegisterType((*Quantity)(nil), "k8s.io.kubernetes.pkg.api.resource.Quantity") + proto.RegisterType((*QuantityProto)(nil), "k8s.io.kubernetes.pkg.api.resource.QuantityProto") +} +func (m *QuantityProto) Marshal() (data []byte, err error) { + size := m.Size() + data = make([]byte, size) + n, err := m.MarshalTo(data) + if err != nil { + return nil, err + } + return data[:n], nil +} + +func (m *QuantityProto) MarshalTo(data []byte) (int, error) { + var i int + _ = i + var l int + _ = l + data[i] = 0xa + i++ + i = encodeVarintGenerated(data, i, uint64(len(m.Format))) + i += copy(data[i:], m.Format) + data[i] = 0x10 + i++ + i = encodeVarintGenerated(data, i, uint64(m.Scale)) + if m.Bigint != nil { + data[i] = 0x1a + i++ + i = encodeVarintGenerated(data, i, uint64(len(m.Bigint))) + i += copy(data[i:], m.Bigint) + } + return i, nil +} + +func encodeFixed64Generated(data []byte, offset int, v uint64) int { + data[offset] = uint8(v) + data[offset+1] = uint8(v >> 8) + data[offset+2] = uint8(v >> 16) + data[offset+3] = uint8(v >> 24) + data[offset+4] = uint8(v >> 32) + data[offset+5] = uint8(v >> 40) + data[offset+6] = uint8(v >> 48) + data[offset+7] = uint8(v >> 56) + return offset + 8 +} +func encodeFixed32Generated(data []byte, offset int, v uint32) int { + data[offset] = uint8(v) + data[offset+1] = uint8(v >> 8) + data[offset+2] = uint8(v >> 16) + data[offset+3] = uint8(v >> 24) + return offset + 4 +} +func encodeVarintGenerated(data []byte, offset int, v uint64) int { + for v >= 1<<7 { + data[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + data[offset] = uint8(v) + return offset + 1 +} +func (m *QuantityProto) Size() (n int) { + var l int + _ = l + l = len(m.Format) + n += 1 + l + sovGenerated(uint64(l)) + n += 1 + sovGenerated(uint64(m.Scale)) + if m.Bigint != nil { + l = len(m.Bigint) + n += 1 + l + sovGenerated(uint64(l)) + } + return n +} + +func sovGenerated(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +func sozGenerated(x uint64) (n int) { + return sovGenerated(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QuantityProto) Unmarshal(data []byte) error { + l := len(data) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QuantityProto: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuantityProto: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Format", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Format = Format(data[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Scale", wireType) + } + m.Scale = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + m.Scale |= (int32(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bigint", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + byteLen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + byteLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Bigint = append(m.Bigint[:0], data[iNdEx:postIndex]...) + if m.Bigint == nil { + m.Bigint = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(data[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenerated(data []byte) (n int, err error) { + l := len(data) + iNdEx := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenerated + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenerated + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if data[iNdEx-1] < 0x80 { + break + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenerated + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + iNdEx += length + if length < 0 { + return 0, ErrInvalidLengthGenerated + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenerated + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipGenerated(data[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthGenerated = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenerated = fmt.Errorf("proto: integer overflow") +) diff --git a/vendor/k8s.io/kubernetes/pkg/api/resource/quantity.go b/vendor/k8s.io/kubernetes/pkg/api/resource/quantity.go new file mode 100644 index 0000000000..e61c8800ec --- /dev/null +++ b/vendor/k8s.io/kubernetes/pkg/api/resource/quantity.go @@ -0,0 +1,538 @@ +/* +Copyright 2014 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package resource + +import ( + "errors" + "fmt" + "math/big" + "regexp" + "strings" + + flag "github.com/spf13/pflag" + + inf "gopkg.in/inf.v0" +) + +// Quantity is a fixed-point representation of a number. +// It provides convenient marshaling/unmarshaling in JSON and YAML, +// in addition to String() and Int64() accessors. +// +// The serialization format is: +// +// ::= +// (Note that may be empty, from the "" case in .) +// ::= 0 | 1 | ... | 9 +// ::= | +// ::= | . | . | . +// ::= "+" | "-" +// ::= | +// ::= | | +// ::= Ki | Mi | Gi | Ti | Pi | Ei +// (International System of units; See: http://physics.nist.gov/cuu/Units/binary.html) +// ::= m | "" | k | M | G | T | P | E +// (Note that 1024 = 1Ki but 1000 = 1k; I didn't choose the capitalization.) +// ::= "e" | "E" +// +// No matter which of the three exponent forms is used, no quantity may represent +// a number greater than 2^63-1 in magnitude, nor may it have more than 3 decimal +// places. Numbers larger or more precise will be capped or rounded up. +// (E.g.: 0.1m will rounded up to 1m.) +// This may be extended in the future if we require larger or smaller quantities. +// +// When a Quantity is parsed from a string, it will remember the type of suffix +// it had, and will use the same type again when it is serialized. +// +// Before serializing, Quantity will be put in "canonical form". +// This means that Exponent/suffix will be adjusted up or down (with a +// corresponding increase or decrease in Mantissa) such that: +// a. No precision is lost +// b. No fractional digits will be emitted +// c. The exponent (or suffix) is as large as possible. +// The sign will be omitted unless the number is negative. +// +// Examples: +// 1.5 will be serialized as "1500m" +// 1.5Gi will be serialized as "1536Mi" +// +// NOTE: We reserve the right to amend this canonical format, perhaps to +// allow 1.5 to be canonical. +// TODO: Remove above disclaimer after all bikeshedding about format is over, +// or after March 2015. +// +// Note that the quantity will NEVER be internally represented by a +// floating point number. That is the whole point of this exercise. +// +// Non-canonical values will still parse as long as they are well formed, +// but will be re-emitted in their canonical form. (So always use canonical +// form, or don't diff.) +// +// This format is intended to make it difficult to use these numbers without +// writing some sort of special handling code in the hopes that that will +// cause implementors to also use a fixed point implementation. +// +// +protobuf=true +// +protobuf.embed=QuantityProto +// +protobuf.options.marshal=false +// +protobuf.options.(gogoproto.goproto_stringer)=false +type Quantity struct { + // Amount is public, so you can manipulate it if the accessor + // functions are not sufficient. + Amount *inf.Dec + + // Change Format at will. See the comment for Canonicalize for + // more details. + Format +} + +// Format lists the three possible formattings of a quantity. +type Format string + +const ( + DecimalExponent = Format("DecimalExponent") // e.g., 12e6 + BinarySI = Format("BinarySI") // e.g., 12Mi (12 * 2^20) + DecimalSI = Format("DecimalSI") // e.g., 12M (12 * 10^6) +) + +// MustParse turns the given string into a quantity or panics; for tests +// or others cases where you know the string is valid. +func MustParse(str string) Quantity { + q, err := ParseQuantity(str) + if err != nil { + panic(fmt.Errorf("cannot parse '%v': %v", str, err)) + } + return *q +} + +// Scale is used for getting and setting the base-10 scaled value. +// Base-2 scales are omitted for mathematical simplicity. +// See Quantity.ScaledValue for more details. +type Scale int + +const ( + Nano Scale = -9 + Micro Scale = -6 + Milli Scale = -3 + Kilo Scale = 3 + Mega Scale = 6 + Giga Scale = 9 + Tera Scale = 12 + Peta Scale = 15 + Exa Scale = 18 +) + +const ( + // splitREString is used to separate a number from its suffix; as such, + // this is overly permissive, but that's OK-- it will be checked later. + splitREString = "^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$" +) + +var ( + // splitRE is used to get the various parts of a number. + splitRE = regexp.MustCompile(splitREString) + + // Errors that could happen while parsing a string. + ErrFormatWrong = errors.New("quantities must match the regular expression '" + splitREString + "'") + ErrNumeric = errors.New("unable to parse numeric part of quantity") + ErrSuffix = errors.New("unable to parse quantity's suffix") + + // Commonly needed big.Int values-- treat as read only! + bigTen = big.NewInt(10) + bigZero = big.NewInt(0) + bigOne = big.NewInt(1) + bigThousand = big.NewInt(1000) + big1024 = big.NewInt(1024) + + // Commonly needed inf.Dec values-- treat as read only! + decZero = inf.NewDec(0, 0) + decOne = inf.NewDec(1, 0) + decMinusOne = inf.NewDec(-1, 0) + decThousand = inf.NewDec(1000, 0) + dec1024 = inf.NewDec(1024, 0) + decMinus1024 = inf.NewDec(-1024, 0) + + // Largest (in magnitude) number allowed. + maxAllowed = inf.NewDec((1<<63)-1, 0) // == max int64 + + // The maximum value we can represent milli-units for. + // Compare with the return value of Quantity.Value() to + // see if it's safe to use Quantity.MilliValue(). + MaxMilliValue = int64(((1 << 63) - 1) / 1000) +) + +// ParseQuantity turns str into a Quantity, or returns an error. +func ParseQuantity(str string) (*Quantity, error) { + parts := splitRE.FindStringSubmatch(strings.TrimSpace(str)) + // regexp returns are entire match, followed by an entry for each () section. + if len(parts) != 3 { + return nil, ErrFormatWrong + } + + amount := new(inf.Dec) + if _, ok := amount.SetString(parts[1]); !ok { + return nil, ErrNumeric + } + + base, exponent, format, ok := quantitySuffixer.interpret(suffix(parts[2])) + if !ok { + return nil, ErrSuffix + } + + // So that no one but us has to think about suffixes, remove it. + if base == 10 { + amount.SetScale(amount.Scale() + Scale(exponent).infScale()) + } else if base == 2 { + // numericSuffix = 2 ** exponent + numericSuffix := big.NewInt(1).Lsh(bigOne, uint(exponent)) + ub := amount.UnscaledBig() + amount.SetUnscaledBig(ub.Mul(ub, numericSuffix)) + } + + // Cap at min/max bounds. + sign := amount.Sign() + if sign == -1 { + amount.Neg(amount) + } + + // This rounds non-zero values up to the minimum representable value, under the theory that + // if you want some resources, you should get some resources, even if you asked for way too small + // of an amount. Arguably, this should be inf.RoundHalfUp (normal rounding), but that would have + // the side effect of rounding values < .5n to zero. + if v, ok := amount.Unscaled(); v != int64(0) || !ok { + amount.Round(amount, Nano.infScale(), inf.RoundUp) + } + + // The max is just a simple cap. + if amount.Cmp(maxAllowed) > 0 { + amount.Set(maxAllowed) + } + if format == BinarySI && amount.Cmp(decOne) < 0 && amount.Cmp(decZero) > 0 { + // This avoids rounding and hopefully confusion, too. + format = DecimalSI + } + if sign == -1 { + amount.Neg(amount) + } + + return &Quantity{amount, format}, nil +} + +// removeFactors divides in a loop; the return values have the property that +// d == result * factor ^ times +// d may be modified in place. +// If d == 0, then the return values will be (0, 0) +func removeFactors(d, factor *big.Int) (result *big.Int, times int) { + q := big.NewInt(0) + m := big.NewInt(0) + for d.Cmp(bigZero) != 0 { + q.DivMod(d, factor, m) + if m.Cmp(bigZero) != 0 { + break + } + times++ + d, q = q, d + } + return d, times +} + +// Canonicalize returns the canonical form of q and its suffix (see comment on Quantity). +// +// Note about BinarySI: +// * If q.Format is set to BinarySI and q.Amount represents a non-zero value between +// -1 and +1, it will be emitted as if q.Format were DecimalSI. +// * Otherwise, if q.Format is set to BinarySI, frational parts of q.Amount will be +// rounded up. (1.1i becomes 2i.) +func (q *Quantity) Canonicalize() (string, suffix) { + if q.Amount == nil { + return "0", "" + } + + // zero is zero always + if q.Amount.Cmp(&inf.Dec{}) == 0 { + return "0", "" + } + + format := q.Format + switch format { + case DecimalExponent, DecimalSI: + case BinarySI: + if q.Amount.Cmp(decMinus1024) > 0 && q.Amount.Cmp(dec1024) < 0 { + // This avoids rounding and hopefully confusion, too. + format = DecimalSI + } else { + tmp := &inf.Dec{} + tmp.Round(q.Amount, 0, inf.RoundUp) + if tmp.Cmp(q.Amount) != 0 { + // Don't lose precision-- show as DecimalSI + format = DecimalSI + } + } + default: + format = DecimalExponent + } + + // TODO: If BinarySI formatting is requested but would cause rounding, upgrade to + // one of the other formats. + switch format { + case DecimalExponent, DecimalSI: + mantissa := q.Amount.UnscaledBig() + exponent := int(-q.Amount.Scale()) + amount := big.NewInt(0).Set(mantissa) + // move all factors of 10 into the exponent for easy reasoning + amount, times := removeFactors(amount, bigTen) + exponent += times + + // make sure exponent is a multiple of 3 + for exponent%3 != 0 { + amount.Mul(amount, bigTen) + exponent-- + } + + suffix, _ := quantitySuffixer.construct(10, exponent, format) + number := amount.String() + return number, suffix + case BinarySI: + tmp := &inf.Dec{} + tmp.Round(q.Amount, 0, inf.RoundUp) + + amount, exponent := removeFactors(tmp.UnscaledBig(), big1024) + suffix, _ := quantitySuffixer.construct(2, exponent*10, format) + number := amount.String() + return number, suffix + } + return "0", "" +} + +// String formats the Quantity as a string. +func (q *Quantity) String() string { + number, suffix := q.Canonicalize() + return number + string(suffix) +} + +// Cmp compares q and y and returns: +// +// -1 if q < y +// 0 if q == y +// +1 if q > y +// +func (q *Quantity) Cmp(y Quantity) int { + if q.Amount == nil { + if y.Amount == nil { + return 0 + } + return -y.Amount.Sign() + } + if y.Amount == nil { + return q.Amount.Sign() + } + return q.Amount.Cmp(y.Amount) +} + +func (q *Quantity) Add(y Quantity) error { + switch { + case y.Amount == nil: + // Adding 0: do nothing. + case q.Amount == nil: + q.Amount = &inf.Dec{} + return q.Add(y) + default: + // we want to preserve the format of the non-zero value + zero := &inf.Dec{} + if q.Amount.Cmp(zero) == 0 && y.Amount.Cmp(zero) != 0 { + q.Format = y.Format + } + q.Amount.Add(q.Amount, y.Amount) + } + return nil +} + +func (q *Quantity) Sub(y Quantity) error { + switch { + case y.Amount == nil: + // Subtracting 0: do nothing. + case q.Amount == nil: + q.Amount = &inf.Dec{} + return q.Sub(y) + default: + // we want to preserve the format of the non-zero value + zero := &inf.Dec{} + if q.Amount.Cmp(zero) == 0 && y.Amount.Cmp(zero) != 0 { + q.Format = y.Format + } + q.Amount.Sub(q.Amount, y.Amount) + } + return nil +} + +// Neg sets q to the negative value of y. +// It updates the format of q to match y. +func (q *Quantity) Neg(y Quantity) error { + switch { + case y.Amount == nil: + *q = y + case q.Amount == nil: + q.Amount = &inf.Dec{} + fallthrough + default: + q.Amount.Neg(y.Amount) + q.Format = y.Format + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface. +func (q Quantity) MarshalJSON() ([]byte, error) { + return []byte(`"` + q.String() + `"`), nil +} + +// UnmarshalJSON implements the json.Unmarshaller interface. +func (q *Quantity) UnmarshalJSON(value []byte) error { + str := string(value) + parsed, err := ParseQuantity(strings.Trim(str, `"`)) + if err != nil { + return err + } + // This copy is safe because parsed will not be referred to again. + *q = *parsed + return nil +} + +// NewQuantity returns a new Quantity representing the given +// value in the given format. +func NewQuantity(value int64, format Format) *Quantity { + return &Quantity{ + Amount: inf.NewDec(value, 0), + Format: format, + } +} + +// NewMilliQuantity returns a new Quantity representing the given +// value * 1/1000 in the given format. Note that BinarySI formatting +// will round fractional values, and will be changed to DecimalSI for +// values x where (-1 < x < 1) && (x != 0). +func NewMilliQuantity(value int64, format Format) *Quantity { + return &Quantity{ + Amount: inf.NewDec(value, 3), + Format: format, + } +} + +// NewScaledQuantity returns a new Quantity representing the given +// value * 10^scale in DecimalSI format. +func NewScaledQuantity(value int64, scale Scale) *Quantity { + return &Quantity{ + Amount: inf.NewDec(value, scale.infScale()), + Format: DecimalSI, + } +} + +// Value returns the value of q; any fractional part will be lost. +func (q *Quantity) Value() int64 { + return q.ScaledValue(0) +} + +// MilliValue returns the value of ceil(q * 1000); this could overflow an int64; +// if that's a concern, call Value() first to verify the number is small enough. +func (q *Quantity) MilliValue() int64 { + return q.ScaledValue(Milli) +} + +// ScaledValue returns the value of ceil(q * 10^scale); this could overflow an int64. +// To detect overflow, call Value() first and verify the expected magnitude. +func (q *Quantity) ScaledValue(scale Scale) int64 { + if q.Amount == nil { + return 0 + } + return scaledValue(q.Amount.UnscaledBig(), int(q.Amount.Scale()), int(scale.infScale())) +} + +// Set sets q's value to be value. +func (q *Quantity) Set(value int64) { + q.SetScaled(value, 0) +} + +// SetMilli sets q's value to be value * 1/1000. +func (q *Quantity) SetMilli(value int64) { + q.SetScaled(value, Milli) +} + +// SetScaled sets q's value to be value * 10^scale +func (q *Quantity) SetScaled(value int64, scale Scale) { + if q.Amount == nil { + q.Amount = &inf.Dec{} + } + q.Amount.SetUnscaled(value) + q.Amount.SetScale(scale.infScale()) +} + +// Copy is a convenience function that makes a deep copy for you. Non-deep +// copies of quantities share pointers and you will regret that. +func (q *Quantity) Copy() *Quantity { + if q.Amount == nil { + return NewQuantity(0, q.Format) + } + tmp := &inf.Dec{} + return &Quantity{ + Amount: tmp.Set(q.Amount), + Format: q.Format, + } +} + +// qFlag is a helper type for the Flag function +type qFlag struct { + dest *Quantity +} + +// Sets the value of the internal Quantity. (used by flag & pflag) +func (qf qFlag) Set(val string) error { + q, err := ParseQuantity(val) + if err != nil { + return err + } + // This copy is OK because q will not be referenced again. + *qf.dest = *q + return nil +} + +// Converts the value of the internal Quantity to a string. (used by flag & pflag) +func (qf qFlag) String() string { + return qf.dest.String() +} + +// States the type of flag this is (Quantity). (used by pflag) +func (qf qFlag) Type() string { + return "quantity" +} + +// QuantityFlag is a helper that makes a quantity flag (using standard flag package). +// Will panic if defaultValue is not a valid quantity. +func QuantityFlag(flagName, defaultValue, description string) *Quantity { + q := MustParse(defaultValue) + flag.Var(NewQuantityFlagValue(&q), flagName, description) + return &q +} + +// NewQuantityFlagValue returns an object that can be used to back a flag, +// pointing at the given Quantity variable. +func NewQuantityFlagValue(q *Quantity) flag.Value { + return qFlag{q} +} + +// infScale adapts a Scale value to an inf.Scale value. +func (s Scale) infScale() inf.Scale { + return inf.Scale(-s) // inf.Scale is upside-down +} diff --git a/vendor/k8s.io/kubernetes/pkg/api/resource/quantity_proto.go b/vendor/k8s.io/kubernetes/pkg/api/resource/quantity_proto.go new file mode 100644 index 0000000000..01d5c2997e --- /dev/null +++ b/vendor/k8s.io/kubernetes/pkg/api/resource/quantity_proto.go @@ -0,0 +1,78 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package resource + +import ( + "math/big" + + inf "gopkg.in/inf.v0" +) + +// QuantityProto is a struct that is equivalent to Quantity, but intended for +// protobuf marshalling/unmarshalling. It is generated into a serialization +// that matches Quantity. Do not use in Go structs. +// +// +protobuf=true +type QuantityProto struct { + // The format of the quantity + Format Format `protobuf:"bytes,1,opt,name=format,casttype=Format"` + // The scale dimension of the value + Scale int32 `protobuf:"varint,2,opt,name=scale"` + // Bigint is serialized as a raw bytes array + Bigint []byte `protobuf:"bytes,3,opt,name=bigint"` +} + +// ProtoTime returns the Time as a new ProtoTime value. +func (q *Quantity) QuantityProto() *QuantityProto { + if q == nil { + return &QuantityProto{} + } + p := &QuantityProto{ + Format: q.Format, + } + if q.Amount != nil { + p.Scale = int32(q.Amount.Scale()) + p.Bigint = q.Amount.UnscaledBig().Bytes() + } + return p +} + +// Size implements the protobuf marshalling interface. +func (q *Quantity) Size() (n int) { return q.QuantityProto().Size() } + +// Reset implements the protobuf marshalling interface. +func (q *Quantity) Unmarshal(data []byte) error { + p := QuantityProto{} + if err := p.Unmarshal(data); err != nil { + return err + } + q.Format = p.Format + b := big.NewInt(0) + b.SetBytes(p.Bigint) + q.Amount = inf.NewDecBig(b, inf.Scale(p.Scale)) + return nil +} + +// Marshal implements the protobuf marshalling interface. +func (q *Quantity) Marshal() (data []byte, err error) { + return q.QuantityProto().Marshal() +} + +// MarshalTo implements the protobuf marshalling interface. +func (q *Quantity) MarshalTo(data []byte) (int, error) { + return q.QuantityProto().MarshalTo(data) +} diff --git a/vendor/k8s.io/kubernetes/pkg/api/resource/scale_int.go b/vendor/k8s.io/kubernetes/pkg/api/resource/scale_int.go new file mode 100644 index 0000000000..173de1a217 --- /dev/null +++ b/vendor/k8s.io/kubernetes/pkg/api/resource/scale_int.go @@ -0,0 +1,95 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package resource + +import ( + "math" + "math/big" + "sync" +) + +var ( + // A sync pool to reduce allocation. + intPool sync.Pool + maxInt64 = big.NewInt(math.MaxInt64) +) + +func init() { + intPool.New = func() interface{} { + return &big.Int{} + } +} + +// scaledValue scales given unscaled value from scale to new Scale and returns +// an int64. It ALWAYS rounds up the result when scale down. The final result might +// overflow. +// +// scale, newScale represents the scale of the unscaled decimal. +// The mathematical value of the decimal is unscaled * 10**(-scale). +func scaledValue(unscaled *big.Int, scale, newScale int) int64 { + dif := scale - newScale + if dif == 0 { + return unscaled.Int64() + } + + // Handle scale up + // This is an easy case, we do not need to care about rounding and overflow. + // If any intermediate operation causes overflow, the result will overflow. + if dif < 0 { + return unscaled.Int64() * int64(math.Pow10(-dif)) + } + + // Handle scale down + // We have to be careful about the intermediate operations. + + // fast path when unscaled < max.Int64 and exp(10,dif) < max.Int64 + const log10MaxInt64 = 19 + if unscaled.Cmp(maxInt64) < 0 && dif < log10MaxInt64 { + divide := int64(math.Pow10(dif)) + result := unscaled.Int64() / divide + mod := unscaled.Int64() % divide + if mod != 0 { + return result + 1 + } + return result + } + + // We should only convert back to int64 when getting the result. + divisor := intPool.Get().(*big.Int) + exp := intPool.Get().(*big.Int) + result := intPool.Get().(*big.Int) + defer func() { + intPool.Put(divisor) + intPool.Put(exp) + intPool.Put(result) + }() + + // divisor = 10^(dif) + // TODO: create loop up table if exp costs too much. + divisor.Exp(bigTen, exp.SetInt64(int64(dif)), nil) + // reuse exp + remainder := exp + + // result = unscaled / divisor + // remainder = unscaled % divisor + result.DivMod(unscaled, divisor, remainder) + if remainder.Sign() != 0 { + return result.Int64() + 1 + } + + return result.Int64() +} diff --git a/vendor/k8s.io/kubernetes/pkg/api/resource/suffix.go b/vendor/k8s.io/kubernetes/pkg/api/resource/suffix.go new file mode 100644 index 0000000000..529712365d --- /dev/null +++ b/vendor/k8s.io/kubernetes/pkg/api/resource/suffix.go @@ -0,0 +1,136 @@ +/* +Copyright 2014 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package resource + +import ( + "strconv" +) + +type suffix string + +// suffixer can interpret and construct suffixes. +type suffixer interface { + interpret(suffix) (base, exponent int, fmt Format, ok bool) + construct(base, exponent int, fmt Format) (s suffix, ok bool) +} + +// quantitySuffixer handles suffixes for all three formats that quantity +// can handle. +var quantitySuffixer = newSuffixer() + +type bePair struct { + base, exponent int +} + +type listSuffixer struct { + suffixToBE map[suffix]bePair + beToSuffix map[bePair]suffix +} + +func (ls *listSuffixer) addSuffix(s suffix, pair bePair) { + if ls.suffixToBE == nil { + ls.suffixToBE = map[suffix]bePair{} + } + if ls.beToSuffix == nil { + ls.beToSuffix = map[bePair]suffix{} + } + ls.suffixToBE[s] = pair + ls.beToSuffix[pair] = s +} + +func (ls *listSuffixer) lookup(s suffix) (base, exponent int, ok bool) { + pair, ok := ls.suffixToBE[s] + if !ok { + return 0, 0, false + } + return pair.base, pair.exponent, true +} + +func (ls *listSuffixer) construct(base, exponent int) (s suffix, ok bool) { + s, ok = ls.beToSuffix[bePair{base, exponent}] + return +} + +type suffixHandler struct { + decSuffixes listSuffixer + binSuffixes listSuffixer +} + +func newSuffixer() suffixer { + sh := &suffixHandler{} + + sh.binSuffixes.addSuffix("Ki", bePair{2, 10}) + sh.binSuffixes.addSuffix("Mi", bePair{2, 20}) + sh.binSuffixes.addSuffix("Gi", bePair{2, 30}) + sh.binSuffixes.addSuffix("Ti", bePair{2, 40}) + sh.binSuffixes.addSuffix("Pi", bePair{2, 50}) + sh.binSuffixes.addSuffix("Ei", bePair{2, 60}) + // Don't emit an error when trying to produce + // a suffix for 2^0. + sh.decSuffixes.addSuffix("", bePair{2, 0}) + + sh.decSuffixes.addSuffix("n", bePair{10, -9}) + sh.decSuffixes.addSuffix("u", bePair{10, -6}) + sh.decSuffixes.addSuffix("m", bePair{10, -3}) + sh.decSuffixes.addSuffix("", bePair{10, 0}) + sh.decSuffixes.addSuffix("k", bePair{10, 3}) + sh.decSuffixes.addSuffix("M", bePair{10, 6}) + sh.decSuffixes.addSuffix("G", bePair{10, 9}) + sh.decSuffixes.addSuffix("T", bePair{10, 12}) + sh.decSuffixes.addSuffix("P", bePair{10, 15}) + sh.decSuffixes.addSuffix("E", bePair{10, 18}) + + return sh +} + +func (sh *suffixHandler) construct(base, exponent int, fmt Format) (s suffix, ok bool) { + switch fmt { + case DecimalSI: + return sh.decSuffixes.construct(base, exponent) + case BinarySI: + return sh.binSuffixes.construct(base, exponent) + case DecimalExponent: + if base != 10 { + return "", false + } + if exponent == 0 { + return "", true + } + return suffix("e" + strconv.FormatInt(int64(exponent), 10)), true + } + return "", false +} + +func (sh *suffixHandler) interpret(suffix suffix) (base, exponent int, fmt Format, ok bool) { + // Try lookup tables first + if b, e, ok := sh.decSuffixes.lookup(suffix); ok { + return b, e, DecimalSI, true + } + if b, e, ok := sh.binSuffixes.lookup(suffix); ok { + return b, e, BinarySI, true + } + + if len(suffix) > 1 && (suffix[0] == 'E' || suffix[0] == 'e') { + parsed, err := strconv.ParseInt(string(suffix[1:]), 10, 64) + if err != nil { + return 0, 0, DecimalExponent, false + } + return 10, int(parsed), DecimalExponent, true + } + + return 0, 0, DecimalExponent, false +} diff --git a/vendor/k8s.io/kubernetes/pkg/conversion/cloner.go b/vendor/k8s.io/kubernetes/pkg/conversion/cloner.go new file mode 100644 index 0000000000..a8c5747132 --- /dev/null +++ b/vendor/k8s.io/kubernetes/pkg/conversion/cloner.go @@ -0,0 +1,237 @@ +/* +Copyright 2014 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package conversion + +import ( + "fmt" + "reflect" +) + +// Cloner knows how to copy one type to another. +type Cloner struct { + // Map from the type to a function which can do the deep copy. + deepCopyFuncs map[reflect.Type]reflect.Value + generatedDeepCopyFuncs map[reflect.Type]reflect.Value +} + +// NewCloner creates a new Cloner object. +func NewCloner() *Cloner { + c := &Cloner{ + deepCopyFuncs: map[reflect.Type]reflect.Value{}, + generatedDeepCopyFuncs: map[reflect.Type]reflect.Value{}, + } + if err := c.RegisterDeepCopyFunc(byteSliceDeepCopy); err != nil { + // If one of the deep-copy functions is malformed, detect it immediately. + panic(err) + } + return c +} + +// Prevent recursing into every byte... +func byteSliceDeepCopy(in []byte, out *[]byte, c *Cloner) error { + if in != nil { + *out = make([]byte, len(in)) + copy(*out, in) + } else { + *out = nil + } + return nil +} + +// Verifies whether a deep-copy function has a correct signature. +func verifyDeepCopyFunctionSignature(ft reflect.Type) error { + if ft.Kind() != reflect.Func { + return fmt.Errorf("expected func, got: %v", ft) + } + if ft.NumIn() != 3 { + return fmt.Errorf("expected three 'in' params, got %v", ft) + } + if ft.NumOut() != 1 { + return fmt.Errorf("expected one 'out' param, got %v", ft) + } + if ft.In(1).Kind() != reflect.Ptr { + return fmt.Errorf("expected pointer arg for 'in' param 1, got: %v", ft) + } + if ft.In(1).Elem() != ft.In(0) { + return fmt.Errorf("expected 'in' param 0 the same as param 1, got: %v", ft) + } + var forClonerType Cloner + if expected := reflect.TypeOf(&forClonerType); ft.In(2) != expected { + return fmt.Errorf("expected '%v' arg for 'in' param 2, got: '%v'", expected, ft.In(2)) + } + var forErrorType error + // This convolution is necessary, otherwise TypeOf picks up on the fact + // that forErrorType is nil + errorType := reflect.TypeOf(&forErrorType).Elem() + if ft.Out(0) != errorType { + return fmt.Errorf("expected error return, got: %v", ft) + } + return nil +} + +// RegisterGeneratedDeepCopyFunc registers a copying func with the Cloner. +// deepCopyFunc must take three parameters: a type input, a pointer to a +// type output, and a pointer to Cloner. It should return an error. +// +// Example: +// c.RegisterGeneratedDeepCopyFunc( +// func(in Pod, out *Pod, c *Cloner) error { +// // deep copy logic... +// return nil +// }) +func (c *Cloner) RegisterDeepCopyFunc(deepCopyFunc interface{}) error { + fv := reflect.ValueOf(deepCopyFunc) + ft := fv.Type() + if err := verifyDeepCopyFunctionSignature(ft); err != nil { + return err + } + c.deepCopyFuncs[ft.In(0)] = fv + return nil +} + +// Similar to RegisterDeepCopyFunc, but registers deep copy function that were +// automatically generated. +func (c *Cloner) RegisterGeneratedDeepCopyFunc(deepCopyFunc interface{}) error { + fv := reflect.ValueOf(deepCopyFunc) + ft := fv.Type() + if err := verifyDeepCopyFunctionSignature(ft); err != nil { + return err + } + c.generatedDeepCopyFuncs[ft.In(0)] = fv + return nil +} + +// DeepCopy will perform a deep copy of a given object. +func (c *Cloner) DeepCopy(in interface{}) (interface{}, error) { + // Can be invalid if we run DeepCopy(X) where X is a nil interface type. + // For example, we get an invalid value when someone tries to deep-copy + // a nil labels.Selector. + // This does not occur if X is nil and is a pointer to a concrete type. + if in == nil { + return nil, nil + } + inValue := reflect.ValueOf(in) + outValue, err := c.deepCopy(inValue) + if err != nil { + return nil, err + } + return outValue.Interface(), nil +} + +func (c *Cloner) deepCopy(src reflect.Value) (reflect.Value, error) { + inType := src.Type() + + if fv, ok := c.deepCopyFuncs[inType]; ok { + return c.customDeepCopy(src, fv) + } + if fv, ok := c.generatedDeepCopyFuncs[inType]; ok { + return c.customDeepCopy(src, fv) + } + return c.defaultDeepCopy(src) +} + +func (c *Cloner) customDeepCopy(src, fv reflect.Value) (reflect.Value, error) { + outValue := reflect.New(src.Type()) + args := []reflect.Value{src, outValue, reflect.ValueOf(c)} + result := fv.Call(args)[0].Interface() + // This convolution is necessary because nil interfaces won't convert + // to error. + if result == nil { + return outValue.Elem(), nil + } + return outValue.Elem(), result.(error) +} + +func (c *Cloner) defaultDeepCopy(src reflect.Value) (reflect.Value, error) { + switch src.Kind() { + case reflect.Chan, reflect.Func, reflect.UnsafePointer, reflect.Uintptr: + return src, fmt.Errorf("cannot deep copy kind: %s", src.Kind()) + case reflect.Array: + dst := reflect.New(src.Type()) + for i := 0; i < src.Len(); i++ { + copyVal, err := c.deepCopy(src.Index(i)) + if err != nil { + return src, err + } + dst.Elem().Index(i).Set(copyVal) + } + return dst.Elem(), nil + case reflect.Interface: + if src.IsNil() { + return src, nil + } + return c.deepCopy(src.Elem()) + case reflect.Map: + if src.IsNil() { + return src, nil + } + dst := reflect.MakeMap(src.Type()) + for _, k := range src.MapKeys() { + copyVal, err := c.deepCopy(src.MapIndex(k)) + if err != nil { + return src, err + } + dst.SetMapIndex(k, copyVal) + } + return dst, nil + case reflect.Ptr: + if src.IsNil() { + return src, nil + } + dst := reflect.New(src.Type().Elem()) + copyVal, err := c.deepCopy(src.Elem()) + if err != nil { + return src, err + } + dst.Elem().Set(copyVal) + return dst, nil + case reflect.Slice: + if src.IsNil() { + return src, nil + } + dst := reflect.MakeSlice(src.Type(), 0, src.Len()) + for i := 0; i < src.Len(); i++ { + copyVal, err := c.deepCopy(src.Index(i)) + if err != nil { + return src, err + } + dst = reflect.Append(dst, copyVal) + } + return dst, nil + case reflect.Struct: + dst := reflect.New(src.Type()) + for i := 0; i < src.NumField(); i++ { + if !dst.Elem().Field(i).CanSet() { + // Can't set private fields. At this point, the + // best we can do is a shallow copy. For + // example, time.Time is a value type with + // private members that can be shallow copied. + return src, nil + } + copyVal, err := c.deepCopy(src.Field(i)) + if err != nil { + return src, err + } + dst.Elem().Field(i).Set(copyVal) + } + return dst.Elem(), nil + + default: + // Value types like numbers, booleans, and strings. + return src, nil + } +} diff --git a/vendor/k8s.io/kubernetes/pkg/conversion/converter.go b/vendor/k8s.io/kubernetes/pkg/conversion/converter.go new file mode 100644 index 0000000000..e045dcd2f7 --- /dev/null +++ b/vendor/k8s.io/kubernetes/pkg/conversion/converter.go @@ -0,0 +1,951 @@ +/* +Copyright 2014 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package conversion + +import ( + "fmt" + "reflect" +) + +type typePair struct { + source reflect.Type + dest reflect.Type +} + +type typeNamePair struct { + fieldType reflect.Type + fieldName string +} + +// DebugLogger allows you to get debugging messages if necessary. +type DebugLogger interface { + Logf(format string, args ...interface{}) +} + +type NameFunc func(t reflect.Type) string + +var DefaultNameFunc = func(t reflect.Type) string { return t.Name() } + +type GenericConversionFunc func(a, b interface{}, scope Scope) (bool, error) + +// Converter knows how to convert one type to another. +type Converter struct { + // Map from the conversion pair to a function which can + // do the conversion. + conversionFuncs ConversionFuncs + generatedConversionFuncs ConversionFuncs + + // genericConversions are called during normal conversion to offer a "fast-path" + // that avoids all reflection. These methods are not called outside of the .Convert() + // method. + genericConversions []GenericConversionFunc + + // Set of conversions that should be treated as a no-op + ignoredConversions map[typePair]struct{} + + // This is a map from a source field type and name, to a list of destination + // field type and name. + structFieldDests map[typeNamePair][]typeNamePair + + // Allows for the opposite lookup of structFieldDests. So that SourceFromDest + // copy flag also works. So this is a map of destination field name, to potential + // source field name and type to look for. + structFieldSources map[typeNamePair][]typeNamePair + + // Map from a type to a function which applies defaults. + defaultingFuncs map[reflect.Type]reflect.Value + + // Similar to above, but function is stored as interface{}. + defaultingInterfaces map[reflect.Type]interface{} + + // Map from an input type to a function which can apply a key name mapping + inputFieldMappingFuncs map[reflect.Type]FieldMappingFunc + + // Map from an input type to a set of default conversion flags. + inputDefaultFlags map[reflect.Type]FieldMatchingFlags + + // If non-nil, will be called to print helpful debugging info. Quite verbose. + Debug DebugLogger + + // nameFunc is called to retrieve the name of a type; this name is used for the + // purpose of deciding whether two types match or not (i.e., will we attempt to + // do a conversion). The default returns the go type name. + nameFunc func(t reflect.Type) string +} + +// NewConverter creates a new Converter object. +func NewConverter(nameFn NameFunc) *Converter { + c := &Converter{ + conversionFuncs: NewConversionFuncs(), + generatedConversionFuncs: NewConversionFuncs(), + ignoredConversions: make(map[typePair]struct{}), + defaultingFuncs: make(map[reflect.Type]reflect.Value), + defaultingInterfaces: make(map[reflect.Type]interface{}), + nameFunc: nameFn, + structFieldDests: make(map[typeNamePair][]typeNamePair), + structFieldSources: make(map[typeNamePair][]typeNamePair), + + inputFieldMappingFuncs: make(map[reflect.Type]FieldMappingFunc), + inputDefaultFlags: make(map[reflect.Type]FieldMatchingFlags), + } + c.RegisterConversionFunc(Convert_Slice_byte_To_Slice_byte) + return c +} + +// AddGenericConversionFunc adds a function that accepts the ConversionFunc call pattern +// (for two conversion types) to the converter. These functions are checked first during +// a normal conversion, but are otherwise not called. Use AddConversionFuncs when registering +// typed conversions. +func (c *Converter) AddGenericConversionFunc(fn GenericConversionFunc) { + c.genericConversions = append(c.genericConversions, fn) +} + +// WithConversions returns a Converter that is a copy of c but with the additional +// fns merged on top. +func (c *Converter) WithConversions(fns ConversionFuncs) *Converter { + copied := *c + copied.conversionFuncs = c.conversionFuncs.Merge(fns) + return &copied +} + +// DefaultMeta returns the conversion FieldMappingFunc and meta for a given type. +func (c *Converter) DefaultMeta(t reflect.Type) (FieldMatchingFlags, *Meta) { + return c.inputDefaultFlags[t], &Meta{ + KeyNameMapping: c.inputFieldMappingFuncs[t], + } +} + +// Convert_Slice_byte_To_Slice_byte prevents recursing into every byte +func Convert_Slice_byte_To_Slice_byte(in *[]byte, out *[]byte, s Scope) error { + if *in == nil { + *out = nil + return nil + } + *out = make([]byte, len(*in)) + copy(*out, *in) + return nil +} + +// Scope is passed to conversion funcs to allow them to continue an ongoing conversion. +// If multiple converters exist in the system, Scope will allow you to use the correct one +// from a conversion function--that is, the one your conversion function was called by. +type Scope interface { + // Call Convert to convert sub-objects. Note that if you call it with your own exact + // parameters, you'll run out of stack space before anything useful happens. + Convert(src, dest interface{}, flags FieldMatchingFlags) error + + // DefaultConvert performs the default conversion, without calling a conversion func + // on the current stack frame. This makes it safe to call from a conversion func. + DefaultConvert(src, dest interface{}, flags FieldMatchingFlags) error + + // If registered, returns a function applying defaults for objects of a given type. + // Used for automatically generating conversion functions. + DefaultingInterface(inType reflect.Type) (interface{}, bool) + + // SrcTags and DestTags contain the struct tags that src and dest had, respectively. + // If the enclosing object was not a struct, then these will contain no tags, of course. + SrcTag() reflect.StructTag + DestTag() reflect.StructTag + + // Flags returns the flags with which the conversion was started. + Flags() FieldMatchingFlags + + // Meta returns any information originally passed to Convert. + Meta() *Meta +} + +// FieldMappingFunc can convert an input field value into different values, depending on +// the value of the source or destination struct tags. +type FieldMappingFunc func(key string, sourceTag, destTag reflect.StructTag) (source string, dest string) + +func NewConversionFuncs() ConversionFuncs { + return ConversionFuncs{fns: make(map[typePair]reflect.Value)} +} + +type ConversionFuncs struct { + fns map[typePair]reflect.Value +} + +// Add adds the provided conversion functions to the lookup table - they must have the signature +// `func(type1, type2, Scope) error`. Functions are added in the order passed and will override +// previously registered pairs. +func (c ConversionFuncs) Add(fns ...interface{}) error { + for _, fn := range fns { + fv := reflect.ValueOf(fn) + ft := fv.Type() + if err := verifyConversionFunctionSignature(ft); err != nil { + return err + } + c.fns[typePair{ft.In(0).Elem(), ft.In(1).Elem()}] = fv + } + return nil +} + +// Merge returns a new ConversionFuncs that contains all conversions from +// both other and c, with other conversions taking precedence. +func (c ConversionFuncs) Merge(other ConversionFuncs) ConversionFuncs { + merged := NewConversionFuncs() + for k, v := range c.fns { + merged.fns[k] = v + } + for k, v := range other.fns { + merged.fns[k] = v + } + return merged +} + +// Meta is supplied by Scheme, when it calls Convert. +type Meta struct { + // KeyNameMapping is an optional function which may map the listed key (field name) + // into a source and destination value. + KeyNameMapping FieldMappingFunc +} + +// scope contains information about an ongoing conversion. +type scope struct { + converter *Converter + meta *Meta + flags FieldMatchingFlags + + // srcStack & destStack are separate because they may not have a 1:1 + // relationship. + srcStack scopeStack + destStack scopeStack +} + +type scopeStackElem struct { + tag reflect.StructTag + value reflect.Value + key string +} + +type scopeStack []scopeStackElem + +func (s *scopeStack) pop() { + n := len(*s) + *s = (*s)[:n-1] +} + +func (s *scopeStack) push(e scopeStackElem) { + *s = append(*s, e) +} + +func (s *scopeStack) top() *scopeStackElem { + return &(*s)[len(*s)-1] +} + +func (s scopeStack) describe() string { + desc := "" + if len(s) > 1 { + desc = "(" + s[1].value.Type().String() + ")" + } + for i, v := range s { + if i < 2 { + // First layer on stack is not real; second is handled specially above. + continue + } + if v.key == "" { + desc += fmt.Sprintf(".%v", v.value.Type()) + } else { + desc += fmt.Sprintf(".%v", v.key) + } + } + return desc +} + +func (s *scope) DefaultingInterface(inType reflect.Type) (interface{}, bool) { + value, found := s.converter.defaultingInterfaces[inType] + return value, found +} + +// Formats src & dest as indices for printing. +func (s *scope) setIndices(src, dest int) { + s.srcStack.top().key = fmt.Sprintf("[%v]", src) + s.destStack.top().key = fmt.Sprintf("[%v]", dest) +} + +// Formats src & dest as map keys for printing. +func (s *scope) setKeys(src, dest interface{}) { + s.srcStack.top().key = fmt.Sprintf(`["%v"]`, src) + s.destStack.top().key = fmt.Sprintf(`["%v"]`, dest) +} + +// Convert continues a conversion. +func (s *scope) Convert(src, dest interface{}, flags FieldMatchingFlags) error { + return s.converter.Convert(src, dest, flags, s.meta) +} + +// DefaultConvert continues a conversion, performing a default conversion (no conversion func) +// for the current stack frame. +func (s *scope) DefaultConvert(src, dest interface{}, flags FieldMatchingFlags) error { + return s.converter.DefaultConvert(src, dest, flags, s.meta) +} + +// SrcTag returns the tag of the struct containing the current source item, if any. +func (s *scope) SrcTag() reflect.StructTag { + return s.srcStack.top().tag +} + +// DestTag returns the tag of the struct containing the current dest item, if any. +func (s *scope) DestTag() reflect.StructTag { + return s.destStack.top().tag +} + +// Flags returns the flags with which the current conversion was started. +func (s *scope) Flags() FieldMatchingFlags { + return s.flags +} + +// Meta returns the meta object that was originally passed to Convert. +func (s *scope) Meta() *Meta { + return s.meta +} + +// describe prints the path to get to the current (source, dest) values. +func (s *scope) describe() (src, dest string) { + return s.srcStack.describe(), s.destStack.describe() +} + +// error makes an error that includes information about where we were in the objects +// we were asked to convert. +func (s *scope) errorf(message string, args ...interface{}) error { + srcPath, destPath := s.describe() + where := fmt.Sprintf("converting %v to %v: ", srcPath, destPath) + return fmt.Errorf(where+message, args...) +} + +// Verifies whether a conversion function has a correct signature. +func verifyConversionFunctionSignature(ft reflect.Type) error { + if ft.Kind() != reflect.Func { + return fmt.Errorf("expected func, got: %v", ft) + } + if ft.NumIn() != 3 { + return fmt.Errorf("expected three 'in' params, got: %v", ft) + } + if ft.NumOut() != 1 { + return fmt.Errorf("expected one 'out' param, got: %v", ft) + } + if ft.In(0).Kind() != reflect.Ptr { + return fmt.Errorf("expected pointer arg for 'in' param 0, got: %v", ft) + } + if ft.In(1).Kind() != reflect.Ptr { + return fmt.Errorf("expected pointer arg for 'in' param 1, got: %v", ft) + } + scopeType := Scope(nil) + if e, a := reflect.TypeOf(&scopeType).Elem(), ft.In(2); e != a { + return fmt.Errorf("expected '%v' arg for 'in' param 2, got '%v' (%v)", e, a, ft) + } + var forErrorType error + // This convolution is necessary, otherwise TypeOf picks up on the fact + // that forErrorType is nil. + errorType := reflect.TypeOf(&forErrorType).Elem() + if ft.Out(0) != errorType { + return fmt.Errorf("expected error return, got: %v", ft) + } + return nil +} + +// RegisterConversionFunc registers a conversion func with the +// Converter. conversionFunc must take three parameters: a pointer to the input +// type, a pointer to the output type, and a conversion.Scope (which should be +// used if recursive conversion calls are desired). It must return an error. +// +// Example: +// c.RegisterConversionFunc( +// func(in *Pod, out *v1.Pod, s Scope) error { +// // conversion logic... +// return nil +// }) +func (c *Converter) RegisterConversionFunc(conversionFunc interface{}) error { + return c.conversionFuncs.Add(conversionFunc) +} + +// Similar to RegisterConversionFunc, but registers conversion function that were +// automatically generated. +func (c *Converter) RegisterGeneratedConversionFunc(conversionFunc interface{}) error { + return c.generatedConversionFuncs.Add(conversionFunc) +} + +// RegisterIgnoredConversion registers a "no-op" for conversion, where any requested +// conversion between from and to is ignored. +func (c *Converter) RegisterIgnoredConversion(from, to interface{}) error { + typeFrom := reflect.TypeOf(from) + typeTo := reflect.TypeOf(to) + if reflect.TypeOf(from).Kind() != reflect.Ptr { + return fmt.Errorf("expected pointer arg for 'from' param 0, got: %v", typeFrom) + } + if typeTo.Kind() != reflect.Ptr { + return fmt.Errorf("expected pointer arg for 'to' param 1, got: %v", typeTo) + } + c.ignoredConversions[typePair{typeFrom.Elem(), typeTo.Elem()}] = struct{}{} + return nil +} + +// IsConversionIgnored returns true if the specified objects should be dropped during +// conversion. +func (c *Converter) IsConversionIgnored(inType, outType reflect.Type) bool { + _, found := c.ignoredConversions[typePair{inType, outType}] + return found +} + +func (c *Converter) HasConversionFunc(inType, outType reflect.Type) bool { + _, found := c.conversionFuncs.fns[typePair{inType, outType}] + return found +} + +func (c *Converter) ConversionFuncValue(inType, outType reflect.Type) (reflect.Value, bool) { + value, found := c.conversionFuncs.fns[typePair{inType, outType}] + return value, found +} + +// SetStructFieldCopy registers a correspondence. Whenever a struct field is encountered +// which has a type and name matching srcFieldType and srcFieldName, it wil be copied +// into the field in the destination struct matching destFieldType & Name, if such a +// field exists. +// May be called multiple times, even for the same source field & type--all applicable +// copies will be performed. +func (c *Converter) SetStructFieldCopy(srcFieldType interface{}, srcFieldName string, destFieldType interface{}, destFieldName string) error { + st := reflect.TypeOf(srcFieldType) + dt := reflect.TypeOf(destFieldType) + srcKey := typeNamePair{st, srcFieldName} + destKey := typeNamePair{dt, destFieldName} + c.structFieldDests[srcKey] = append(c.structFieldDests[srcKey], destKey) + c.structFieldSources[destKey] = append(c.structFieldSources[destKey], srcKey) + return nil +} + +// RegisterDefaultingFunc registers a value-defaulting func with the Converter. +// defaultingFunc must take one parameters: a pointer to the input type. +// +// Example: +// c.RegisteDefaultingFunc( +// func(in *v1.Pod) { +// // defaulting logic... +// }) +func (c *Converter) RegisterDefaultingFunc(defaultingFunc interface{}) error { + fv := reflect.ValueOf(defaultingFunc) + ft := fv.Type() + if ft.Kind() != reflect.Func { + return fmt.Errorf("expected func, got: %v", ft) + } + if ft.NumIn() != 1 { + return fmt.Errorf("expected one 'in' param, got: %v", ft) + } + if ft.NumOut() != 0 { + return fmt.Errorf("expected zero 'out' params, got: %v", ft) + } + if ft.In(0).Kind() != reflect.Ptr { + return fmt.Errorf("expected pointer arg for 'in' param 0, got: %v", ft) + } + inType := ft.In(0).Elem() + c.defaultingFuncs[inType] = fv + c.defaultingInterfaces[inType] = defaultingFunc + return nil +} + +// RegisterInputDefaults registers a field name mapping function, used when converting +// from maps to structs. Inputs to the conversion methods are checked for this type and a mapping +// applied automatically if the input matches in. A set of default flags for the input conversion +// may also be provided, which will be used when no explicit flags are requested. +func (c *Converter) RegisterInputDefaults(in interface{}, fn FieldMappingFunc, defaultFlags FieldMatchingFlags) error { + fv := reflect.ValueOf(in) + ft := fv.Type() + if ft.Kind() != reflect.Ptr { + return fmt.Errorf("expected pointer 'in' argument, got: %v", ft) + } + c.inputFieldMappingFuncs[ft] = fn + c.inputDefaultFlags[ft] = defaultFlags + return nil +} + +// FieldMatchingFlags contains a list of ways in which struct fields could be +// copied. These constants may be | combined. +type FieldMatchingFlags int + +const ( + // Loop through destination fields, search for matching source + // field to copy it from. Source fields with no corresponding + // destination field will be ignored. If SourceToDest is + // specified, this flag is ignored. If neither is specified, + // or no flags are passed, this flag is the default. + DestFromSource FieldMatchingFlags = 0 + // Loop through source fields, search for matching dest field + // to copy it into. Destination fields with no corresponding + // source field will be ignored. + SourceToDest FieldMatchingFlags = 1 << iota + // Don't treat it as an error if the corresponding source or + // dest field can't be found. + IgnoreMissingFields + // Don't require type names to match. + AllowDifferentFieldTypeNames +) + +// IsSet returns true if the given flag or combination of flags is set. +func (f FieldMatchingFlags) IsSet(flag FieldMatchingFlags) bool { + if flag == DestFromSource { + // The bit logic doesn't work on the default value. + return f&SourceToDest != SourceToDest + } + return f&flag == flag +} + +// Convert will translate src to dest if it knows how. Both must be pointers. +// If no conversion func is registered and the default copying mechanism +// doesn't work on this type pair, an error will be returned. +// Read the comments on the various FieldMatchingFlags constants to understand +// what the 'flags' parameter does. +// 'meta' is given to allow you to pass information to conversion functions, +// it is not used by Convert() other than storing it in the scope. +// Not safe for objects with cyclic references! +func (c *Converter) Convert(src, dest interface{}, flags FieldMatchingFlags, meta *Meta) error { + if len(c.genericConversions) > 0 { + // TODO: avoid scope allocation + s := &scope{converter: c, flags: flags, meta: meta} + for _, fn := range c.genericConversions { + if ok, err := fn(src, dest, s); ok { + return err + } + } + } + return c.doConversion(src, dest, flags, meta, c.convert) +} + +// DefaultConvert will translate src to dest if it knows how. Both must be pointers. +// No conversion func is used. If the default copying mechanism +// doesn't work on this type pair, an error will be returned. +// Read the comments on the various FieldMatchingFlags constants to understand +// what the 'flags' parameter does. +// 'meta' is given to allow you to pass information to conversion functions, +// it is not used by DefaultConvert() other than storing it in the scope. +// Not safe for objects with cyclic references! +func (c *Converter) DefaultConvert(src, dest interface{}, flags FieldMatchingFlags, meta *Meta) error { + return c.doConversion(src, dest, flags, meta, c.defaultConvert) +} + +type conversionFunc func(sv, dv reflect.Value, scope *scope) error + +func (c *Converter) doConversion(src, dest interface{}, flags FieldMatchingFlags, meta *Meta, f conversionFunc) error { + dv, err := EnforcePtr(dest) + if err != nil { + return err + } + if !dv.CanAddr() && !dv.CanSet() { + return fmt.Errorf("can't write to dest") + } + sv, err := EnforcePtr(src) + if err != nil { + return err + } + s := &scope{ + converter: c, + flags: flags, + meta: meta, + } + // Leave something on the stack, so that calls to struct tag getters never fail. + s.srcStack.push(scopeStackElem{}) + s.destStack.push(scopeStackElem{}) + return f(sv, dv, s) +} + +// callCustom calls 'custom' with sv & dv. custom must be a conversion function. +func (c *Converter) callCustom(sv, dv, custom reflect.Value, scope *scope) error { + if !sv.CanAddr() { + sv2 := reflect.New(sv.Type()) + sv2.Elem().Set(sv) + sv = sv2 + } else { + sv = sv.Addr() + } + if !dv.CanAddr() { + if !dv.CanSet() { + return scope.errorf("can't addr or set dest.") + } + dvOrig := dv + dv := reflect.New(dvOrig.Type()) + defer func() { dvOrig.Set(dv) }() + } else { + dv = dv.Addr() + } + args := []reflect.Value{sv, dv, reflect.ValueOf(scope)} + ret := custom.Call(args)[0].Interface() + // This convolution is necessary because nil interfaces won't convert + // to errors. + if ret == nil { + return nil + } + return ret.(error) +} + +// convert recursively copies sv into dv, calling an appropriate conversion function if +// one is registered. +func (c *Converter) convert(sv, dv reflect.Value, scope *scope) error { + dt, st := dv.Type(), sv.Type() + // Apply default values. + if fv, ok := c.defaultingFuncs[st]; ok { + if c.Debug != nil { + c.Debug.Logf("Applying defaults for '%v'", st) + } + args := []reflect.Value{sv.Addr()} + fv.Call(args) + } + + pair := typePair{st, dt} + + // ignore conversions of this type + if _, ok := c.ignoredConversions[pair]; ok { + if c.Debug != nil { + c.Debug.Logf("Ignoring conversion of '%v' to '%v'", st, dt) + } + return nil + } + + // Convert sv to dv. + if fv, ok := c.conversionFuncs.fns[pair]; ok { + if c.Debug != nil { + c.Debug.Logf("Calling custom conversion of '%v' to '%v'", st, dt) + } + return c.callCustom(sv, dv, fv, scope) + } + if fv, ok := c.generatedConversionFuncs.fns[pair]; ok { + if c.Debug != nil { + c.Debug.Logf("Calling generated conversion of '%v' to '%v'", st, dt) + } + return c.callCustom(sv, dv, fv, scope) + } + + return c.defaultConvert(sv, dv, scope) +} + +// defaultConvert recursively copies sv into dv. no conversion function is called +// for the current stack frame (but conversion functions may be called for nested objects) +func (c *Converter) defaultConvert(sv, dv reflect.Value, scope *scope) error { + dt, st := dv.Type(), sv.Type() + + if !dv.CanSet() { + return scope.errorf("Cannot set dest. (Tried to deep copy something with unexported fields?)") + } + + if !scope.flags.IsSet(AllowDifferentFieldTypeNames) && c.nameFunc(dt) != c.nameFunc(st) { + return scope.errorf( + "type names don't match (%v, %v), and no conversion 'func (%v, %v) error' registered.", + c.nameFunc(st), c.nameFunc(dt), st, dt) + } + + switch st.Kind() { + case reflect.Map, reflect.Ptr, reflect.Slice, reflect.Interface, reflect.Struct: + // Don't copy these via assignment/conversion! + default: + // This should handle all simple types. + if st.AssignableTo(dt) { + dv.Set(sv) + return nil + } + if st.ConvertibleTo(dt) { + dv.Set(sv.Convert(dt)) + return nil + } + } + + if c.Debug != nil { + c.Debug.Logf("Trying to convert '%v' to '%v'", st, dt) + } + + scope.srcStack.push(scopeStackElem{value: sv}) + scope.destStack.push(scopeStackElem{value: dv}) + defer scope.srcStack.pop() + defer scope.destStack.pop() + + switch dv.Kind() { + case reflect.Struct: + return c.convertKV(toKVValue(sv), toKVValue(dv), scope) + case reflect.Slice: + if sv.IsNil() { + // Don't make a zero-length slice. + dv.Set(reflect.Zero(dt)) + return nil + } + dv.Set(reflect.MakeSlice(dt, sv.Len(), sv.Cap())) + for i := 0; i < sv.Len(); i++ { + scope.setIndices(i, i) + if err := c.convert(sv.Index(i), dv.Index(i), scope); err != nil { + return err + } + } + case reflect.Ptr: + if sv.IsNil() { + // Don't copy a nil ptr! + dv.Set(reflect.Zero(dt)) + return nil + } + dv.Set(reflect.New(dt.Elem())) + switch st.Kind() { + case reflect.Ptr, reflect.Interface: + return c.convert(sv.Elem(), dv.Elem(), scope) + default: + return c.convert(sv, dv.Elem(), scope) + } + case reflect.Map: + if sv.IsNil() { + // Don't copy a nil ptr! + dv.Set(reflect.Zero(dt)) + return nil + } + dv.Set(reflect.MakeMap(dt)) + for _, sk := range sv.MapKeys() { + dk := reflect.New(dt.Key()).Elem() + if err := c.convert(sk, dk, scope); err != nil { + return err + } + dkv := reflect.New(dt.Elem()).Elem() + scope.setKeys(sk.Interface(), dk.Interface()) + // TODO: sv.MapIndex(sk) may return a value with CanAddr() == false, + // because a map[string]struct{} does not allow a pointer reference. + // Calling a custom conversion function defined for the map value + // will panic. Example is PodInfo map[string]ContainerStatus. + if err := c.convert(sv.MapIndex(sk), dkv, scope); err != nil { + return err + } + dv.SetMapIndex(dk, dkv) + } + case reflect.Interface: + if sv.IsNil() { + // Don't copy a nil interface! + dv.Set(reflect.Zero(dt)) + return nil + } + tmpdv := reflect.New(sv.Elem().Type()).Elem() + if err := c.convert(sv.Elem(), tmpdv, scope); err != nil { + return err + } + dv.Set(reflect.ValueOf(tmpdv.Interface())) + return nil + default: + return scope.errorf("couldn't copy '%v' into '%v'; didn't understand types", st, dt) + } + return nil +} + +var stringType = reflect.TypeOf("") + +func toKVValue(v reflect.Value) kvValue { + switch v.Kind() { + case reflect.Struct: + return structAdaptor(v) + case reflect.Map: + if v.Type().Key().AssignableTo(stringType) { + return stringMapAdaptor(v) + } + } + + return nil +} + +// kvValue lets us write the same conversion logic to work with both maps +// and structs. Only maps with string keys make sense for this. +type kvValue interface { + // returns all keys, as a []string. + keys() []string + // Will just return "" for maps. + tagOf(key string) reflect.StructTag + // Will return the zero Value if the key doesn't exist. + value(key string) reflect.Value + // Maps require explicit setting-- will do nothing for structs. + // Returns false on failure. + confirmSet(key string, v reflect.Value) bool +} + +type stringMapAdaptor reflect.Value + +func (a stringMapAdaptor) len() int { + return reflect.Value(a).Len() +} + +func (a stringMapAdaptor) keys() []string { + v := reflect.Value(a) + keys := make([]string, v.Len()) + for i, v := range v.MapKeys() { + if v.IsNil() { + continue + } + switch t := v.Interface().(type) { + case string: + keys[i] = t + } + } + return keys +} + +func (a stringMapAdaptor) tagOf(key string) reflect.StructTag { + return "" +} + +func (a stringMapAdaptor) value(key string) reflect.Value { + return reflect.Value(a).MapIndex(reflect.ValueOf(key)) +} + +func (a stringMapAdaptor) confirmSet(key string, v reflect.Value) bool { + return true +} + +type structAdaptor reflect.Value + +func (a structAdaptor) len() int { + v := reflect.Value(a) + return v.Type().NumField() +} + +func (a structAdaptor) keys() []string { + v := reflect.Value(a) + t := v.Type() + keys := make([]string, t.NumField()) + for i := range keys { + keys[i] = t.Field(i).Name + } + return keys +} + +func (a structAdaptor) tagOf(key string) reflect.StructTag { + v := reflect.Value(a) + field, ok := v.Type().FieldByName(key) + if ok { + return field.Tag + } + return "" +} + +func (a structAdaptor) value(key string) reflect.Value { + v := reflect.Value(a) + return v.FieldByName(key) +} + +func (a structAdaptor) confirmSet(key string, v reflect.Value) bool { + return true +} + +// convertKV can convert things that consist of key/value pairs, like structs +// and some maps. +func (c *Converter) convertKV(skv, dkv kvValue, scope *scope) error { + if skv == nil || dkv == nil { + // TODO: add keys to stack to support really understandable error messages. + return fmt.Errorf("Unable to convert %#v to %#v", skv, dkv) + } + + lister := dkv + if scope.flags.IsSet(SourceToDest) { + lister = skv + } + + var mapping FieldMappingFunc + if scope.meta != nil && scope.meta.KeyNameMapping != nil { + mapping = scope.meta.KeyNameMapping + } + + for _, key := range lister.keys() { + if found, err := c.checkField(key, skv, dkv, scope); found { + if err != nil { + return err + } + continue + } + stag := skv.tagOf(key) + dtag := dkv.tagOf(key) + skey := key + dkey := key + if mapping != nil { + skey, dkey = scope.meta.KeyNameMapping(key, stag, dtag) + } + + df := dkv.value(dkey) + sf := skv.value(skey) + if !df.IsValid() || !sf.IsValid() { + switch { + case scope.flags.IsSet(IgnoreMissingFields): + // No error. + case scope.flags.IsSet(SourceToDest): + return scope.errorf("%v not present in dest", dkey) + default: + return scope.errorf("%v not present in src", skey) + } + continue + } + scope.srcStack.top().key = skey + scope.srcStack.top().tag = stag + scope.destStack.top().key = dkey + scope.destStack.top().tag = dtag + if err := c.convert(sf, df, scope); err != nil { + return err + } + } + return nil +} + +// checkField returns true if the field name matches any of the struct +// field copying rules. The error should be ignored if it returns false. +func (c *Converter) checkField(fieldName string, skv, dkv kvValue, scope *scope) (bool, error) { + replacementMade := false + if scope.flags.IsSet(DestFromSource) { + df := dkv.value(fieldName) + if !df.IsValid() { + return false, nil + } + destKey := typeNamePair{df.Type(), fieldName} + // Check each of the potential source (type, name) pairs to see if they're + // present in sv. + for _, potentialSourceKey := range c.structFieldSources[destKey] { + sf := skv.value(potentialSourceKey.fieldName) + if !sf.IsValid() { + continue + } + if sf.Type() == potentialSourceKey.fieldType { + // Both the source's name and type matched, so copy. + scope.srcStack.top().key = potentialSourceKey.fieldName + scope.destStack.top().key = fieldName + if err := c.convert(sf, df, scope); err != nil { + return true, err + } + dkv.confirmSet(fieldName, df) + replacementMade = true + } + } + return replacementMade, nil + } + + sf := skv.value(fieldName) + if !sf.IsValid() { + return false, nil + } + srcKey := typeNamePair{sf.Type(), fieldName} + // Check each of the potential dest (type, name) pairs to see if they're + // present in dv. + for _, potentialDestKey := range c.structFieldDests[srcKey] { + df := dkv.value(potentialDestKey.fieldName) + if !df.IsValid() { + continue + } + if df.Type() == potentialDestKey.fieldType { + // Both the dest's name and type matched, so copy. + scope.srcStack.top().key = fieldName + scope.destStack.top().key = potentialDestKey.fieldName + if err := c.convert(sf, df, scope); err != nil { + return true, err + } + dkv.confirmSet(potentialDestKey.fieldName, df) + replacementMade = true + } + } + return replacementMade, nil +} diff --git a/vendor/k8s.io/kubernetes/pkg/conversion/deep_copy_generated.go b/vendor/k8s.io/kubernetes/pkg/conversion/deep_copy_generated.go new file mode 100644 index 0000000000..717feaf18f --- /dev/null +++ b/vendor/k8s.io/kubernetes/pkg/conversion/deep_copy_generated.go @@ -0,0 +1,185 @@ +// +build !ignore_autogenerated + +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// This file was autogenerated by deepcopy-gen. Do not edit it manually! + +package conversion + +import ( + forked_reflect "k8s.io/kubernetes/third_party/forked/reflect" + reflect "reflect" +) + +func DeepCopy_conversion_Cloner(in Cloner, out *Cloner, c *Cloner) error { + if in.deepCopyFuncs != nil { + in, out := in.deepCopyFuncs, &out.deepCopyFuncs + *out = make(map[reflect.Type]reflect.Value) + for range in { + // FIXME: Copying unassignable keys unsupported reflect.Type + } + } else { + out.deepCopyFuncs = nil + } + if in.generatedDeepCopyFuncs != nil { + in, out := in.generatedDeepCopyFuncs, &out.generatedDeepCopyFuncs + *out = make(map[reflect.Type]reflect.Value) + for range in { + // FIXME: Copying unassignable keys unsupported reflect.Type + } + } else { + out.generatedDeepCopyFuncs = nil + } + return nil +} + +func DeepCopy_conversion_ConversionFuncs(in ConversionFuncs, out *ConversionFuncs, c *Cloner) error { + if in.fns != nil { + in, out := in.fns, &out.fns + *out = make(map[typePair]reflect.Value) + for range in { + // FIXME: Copying unassignable keys unsupported typePair + } + } else { + out.fns = nil + } + return nil +} + +func DeepCopy_conversion_Converter(in Converter, out *Converter, c *Cloner) error { + if err := DeepCopy_conversion_ConversionFuncs(in.conversionFuncs, &out.conversionFuncs, c); err != nil { + return err + } + if err := DeepCopy_conversion_ConversionFuncs(in.generatedConversionFuncs, &out.generatedConversionFuncs, c); err != nil { + return err + } + if in.genericConversions != nil { + in, out := in.genericConversions, &out.genericConversions + *out = make([]GenericConversionFunc, len(in)) + for i := range in { + if newVal, err := c.DeepCopy(in[i]); err != nil { + return err + } else { + (*out)[i] = newVal.(GenericConversionFunc) + } + } + } else { + out.genericConversions = nil + } + if in.ignoredConversions != nil { + in, out := in.ignoredConversions, &out.ignoredConversions + *out = make(map[typePair]struct{}) + for range in { + // FIXME: Copying unassignable keys unsupported typePair + } + } else { + out.ignoredConversions = nil + } + if in.structFieldDests != nil { + in, out := in.structFieldDests, &out.structFieldDests + *out = make(map[typeNamePair][]typeNamePair) + for range in { + // FIXME: Copying unassignable keys unsupported typeNamePair + } + } else { + out.structFieldDests = nil + } + if in.structFieldSources != nil { + in, out := in.structFieldSources, &out.structFieldSources + *out = make(map[typeNamePair][]typeNamePair) + for range in { + // FIXME: Copying unassignable keys unsupported typeNamePair + } + } else { + out.structFieldSources = nil + } + if in.defaultingFuncs != nil { + in, out := in.defaultingFuncs, &out.defaultingFuncs + *out = make(map[reflect.Type]reflect.Value) + for range in { + // FIXME: Copying unassignable keys unsupported reflect.Type + } + } else { + out.defaultingFuncs = nil + } + if in.defaultingInterfaces != nil { + in, out := in.defaultingInterfaces, &out.defaultingInterfaces + *out = make(map[reflect.Type]interface{}) + for range in { + // FIXME: Copying unassignable keys unsupported reflect.Type + } + } else { + out.defaultingInterfaces = nil + } + if in.inputFieldMappingFuncs != nil { + in, out := in.inputFieldMappingFuncs, &out.inputFieldMappingFuncs + *out = make(map[reflect.Type]FieldMappingFunc) + for range in { + // FIXME: Copying unassignable keys unsupported reflect.Type + } + } else { + out.inputFieldMappingFuncs = nil + } + if in.inputDefaultFlags != nil { + in, out := in.inputDefaultFlags, &out.inputDefaultFlags + *out = make(map[reflect.Type]FieldMatchingFlags) + for range in { + // FIXME: Copying unassignable keys unsupported reflect.Type + } + } else { + out.inputDefaultFlags = nil + } + if in.Debug == nil { + out.Debug = nil + } else if newVal, err := c.DeepCopy(in.Debug); err != nil { + return err + } else { + out.Debug = newVal.(DebugLogger) + } + if in.nameFunc == nil { + out.nameFunc = nil + } else if newVal, err := c.DeepCopy(in.nameFunc); err != nil { + return err + } else { + out.nameFunc = newVal.(func(reflect.Type) string) + } + return nil +} + +func DeepCopy_conversion_Equalities(in Equalities, out *Equalities, c *Cloner) error { + if in.Equalities != nil { + in, out := in.Equalities, &out.Equalities + *out = make(forked_reflect.Equalities) + for range in { + // FIXME: Copying unassignable keys unsupported reflect.Type + } + } else { + out.Equalities = nil + } + return nil +} + +func DeepCopy_conversion_Meta(in Meta, out *Meta, c *Cloner) error { + if in.KeyNameMapping == nil { + out.KeyNameMapping = nil + } else if newVal, err := c.DeepCopy(in.KeyNameMapping); err != nil { + return err + } else { + out.KeyNameMapping = newVal.(FieldMappingFunc) + } + return nil +} diff --git a/vendor/k8s.io/kubernetes/pkg/conversion/deep_equal.go b/vendor/k8s.io/kubernetes/pkg/conversion/deep_equal.go new file mode 100644 index 0000000000..7c3ed7cda1 --- /dev/null +++ b/vendor/k8s.io/kubernetes/pkg/conversion/deep_equal.go @@ -0,0 +1,36 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package conversion + +import ( + "k8s.io/kubernetes/third_party/forked/reflect" +) + +// The code for this type must be located in third_party, since it forks from +// go std lib. But for convenience, we expose the type here, too. +type Equalities struct { + reflect.Equalities +} + +// For convenience, panics on errrors +func EqualitiesOrDie(funcs ...interface{}) Equalities { + e := Equalities{reflect.Equalities{}} + if err := e.AddFuncs(funcs...); err != nil { + panic(err) + } + return e +} diff --git a/vendor/k8s.io/kubernetes/pkg/conversion/doc.go b/vendor/k8s.io/kubernetes/pkg/conversion/doc.go new file mode 100644 index 0000000000..3ef2eaba45 --- /dev/null +++ b/vendor/k8s.io/kubernetes/pkg/conversion/doc.go @@ -0,0 +1,24 @@ +/* +Copyright 2014 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package conversion provides go object versioning. +// +// Specifically, conversion provides a way for you to define multiple versions +// of the same object. You may write functions which implement conversion logic, +// but for the fields which did not change, copying is automated. This makes it +// easy to modify the structures you use in memory without affecting the format +// you store on disk or respond to in your external API calls. +package conversion diff --git a/vendor/k8s.io/kubernetes/pkg/conversion/helper.go b/vendor/k8s.io/kubernetes/pkg/conversion/helper.go new file mode 100644 index 0000000000..39f7826595 --- /dev/null +++ b/vendor/k8s.io/kubernetes/pkg/conversion/helper.go @@ -0,0 +1,39 @@ +/* +Copyright 2014 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package conversion + +import ( + "fmt" + "reflect" +) + +// EnforcePtr ensures that obj is a pointer of some sort. Returns a reflect.Value +// of the dereferenced pointer, ensuring that it is settable/addressable. +// Returns an error if this is not possible. +func EnforcePtr(obj interface{}) (reflect.Value, error) { + v := reflect.ValueOf(obj) + if v.Kind() != reflect.Ptr { + if v.Kind() == reflect.Invalid { + return reflect.Value{}, fmt.Errorf("expected pointer, but got invalid kind") + } + return reflect.Value{}, fmt.Errorf("expected pointer, but got %v type", v.Type()) + } + if v.IsNil() { + return reflect.Value{}, fmt.Errorf("expected pointer, but got nil") + } + return v.Elem(), nil +} diff --git a/vendor/k8s.io/kubernetes/third_party/forked/reflect/LICENSE b/vendor/k8s.io/kubernetes/third_party/forked/reflect/LICENSE new file mode 100644 index 0000000000..7448756763 --- /dev/null +++ b/vendor/k8s.io/kubernetes/third_party/forked/reflect/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2012 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. diff --git a/vendor/k8s.io/kubernetes/third_party/forked/reflect/deep_equal.go b/vendor/k8s.io/kubernetes/third_party/forked/reflect/deep_equal.go new file mode 100644 index 0000000000..9e45dbe1d2 --- /dev/null +++ b/vendor/k8s.io/kubernetes/third_party/forked/reflect/deep_equal.go @@ -0,0 +1,388 @@ +// 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. + +// Package reflect is a fork of go's standard library reflection package, which +// allows for deep equal with equality functions defined. +package reflect + +import ( + "fmt" + "reflect" + "strings" +) + +// Equalities is a map from type to a function comparing two values of +// that type. +type Equalities map[reflect.Type]reflect.Value + +// For convenience, panics on errrors +func EqualitiesOrDie(funcs ...interface{}) Equalities { + e := Equalities{} + if err := e.AddFuncs(funcs...); err != nil { + panic(err) + } + return e +} + +// AddFuncs is a shortcut for multiple calls to AddFunc. +func (e Equalities) AddFuncs(funcs ...interface{}) error { + for _, f := range funcs { + if err := e.AddFunc(f); err != nil { + return err + } + } + return nil +} + +// AddFunc uses func as an equality function: it must take +// two parameters of the same type, and return a boolean. +func (e Equalities) AddFunc(eqFunc interface{}) error { + fv := reflect.ValueOf(eqFunc) + ft := fv.Type() + if ft.Kind() != reflect.Func { + return fmt.Errorf("expected func, got: %v", ft) + } + if ft.NumIn() != 2 { + return fmt.Errorf("expected three 'in' params, got: %v", ft) + } + if ft.NumOut() != 1 { + return fmt.Errorf("expected one 'out' param, got: %v", ft) + } + if ft.In(0) != ft.In(1) { + return fmt.Errorf("expected arg 1 and 2 to have same type, but got %v", ft) + } + var forReturnType bool + boolType := reflect.TypeOf(forReturnType) + if ft.Out(0) != boolType { + return fmt.Errorf("expected bool return, got: %v", ft) + } + e[ft.In(0)] = fv + return nil +} + +// Below here is forked from go's reflect/deepequal.go + +// During deepValueEqual, must keep track of checks that are +// in progress. The comparison algorithm assumes that all +// checks in progress are true when it reencounters them. +// Visited comparisons are stored in a map indexed by visit. +type visit struct { + a1 uintptr + a2 uintptr + typ reflect.Type +} + +// unexportedTypePanic is thrown when you use this DeepEqual on something that has an +// unexported type. It indicates a programmer error, so should not occur at runtime, +// which is why it's not public and thus impossible to catch. +type unexportedTypePanic []reflect.Type + +func (u unexportedTypePanic) Error() string { return u.String() } +func (u unexportedTypePanic) String() string { + strs := make([]string, len(u)) + for i, t := range u { + strs[i] = fmt.Sprintf("%v", t) + } + return "an unexported field was encountered, nested like this: " + strings.Join(strs, " -> ") +} + +func makeUsefulPanic(v reflect.Value) { + if x := recover(); x != nil { + if u, ok := x.(unexportedTypePanic); ok { + u = append(unexportedTypePanic{v.Type()}, u...) + x = u + } + panic(x) + } +} + +// Tests for deep equality using reflected types. The map argument tracks +// comparisons that have already been seen, which allows short circuiting on +// recursive types. +func (e Equalities) deepValueEqual(v1, v2 reflect.Value, visited map[visit]bool, depth int) bool { + defer makeUsefulPanic(v1) + + if !v1.IsValid() || !v2.IsValid() { + return v1.IsValid() == v2.IsValid() + } + if v1.Type() != v2.Type() { + return false + } + if fv, ok := e[v1.Type()]; ok { + return fv.Call([]reflect.Value{v1, v2})[0].Bool() + } + + hard := func(k reflect.Kind) bool { + switch k { + case reflect.Array, reflect.Map, reflect.Slice, reflect.Struct: + return true + } + return false + } + + if v1.CanAddr() && v2.CanAddr() && hard(v1.Kind()) { + addr1 := v1.UnsafeAddr() + addr2 := v2.UnsafeAddr() + if addr1 > addr2 { + // Canonicalize order to reduce number of entries in visited. + addr1, addr2 = addr2, addr1 + } + + // Short circuit if references are identical ... + if addr1 == addr2 { + return true + } + + // ... or already seen + typ := v1.Type() + v := visit{addr1, addr2, typ} + if visited[v] { + return true + } + + // Remember for later. + visited[v] = true + } + + switch v1.Kind() { + case reflect.Array: + // We don't need to check length here because length is part of + // an array's type, which has already been filtered for. + for i := 0; i < v1.Len(); i++ { + if !e.deepValueEqual(v1.Index(i), v2.Index(i), visited, depth+1) { + return false + } + } + return true + case reflect.Slice: + if (v1.IsNil() || v1.Len() == 0) != (v2.IsNil() || v2.Len() == 0) { + return false + } + if v1.IsNil() || v1.Len() == 0 { + return true + } + if v1.Len() != v2.Len() { + return false + } + if v1.Pointer() == v2.Pointer() { + return true + } + for i := 0; i < v1.Len(); i++ { + if !e.deepValueEqual(v1.Index(i), v2.Index(i), visited, depth+1) { + return false + } + } + return true + case reflect.Interface: + if v1.IsNil() || v2.IsNil() { + return v1.IsNil() == v2.IsNil() + } + return e.deepValueEqual(v1.Elem(), v2.Elem(), visited, depth+1) + case reflect.Ptr: + return e.deepValueEqual(v1.Elem(), v2.Elem(), visited, depth+1) + case reflect.Struct: + for i, n := 0, v1.NumField(); i < n; i++ { + if !e.deepValueEqual(v1.Field(i), v2.Field(i), visited, depth+1) { + return false + } + } + return true + case reflect.Map: + if (v1.IsNil() || v1.Len() == 0) != (v2.IsNil() || v2.Len() == 0) { + return false + } + if v1.IsNil() || v1.Len() == 0 { + return true + } + if v1.Len() != v2.Len() { + return false + } + if v1.Pointer() == v2.Pointer() { + return true + } + for _, k := range v1.MapKeys() { + if !e.deepValueEqual(v1.MapIndex(k), v2.MapIndex(k), visited, depth+1) { + return false + } + } + return true + case reflect.Func: + if v1.IsNil() && v2.IsNil() { + return true + } + // Can't do better than this: + return false + default: + // Normal equality suffices + if !v1.CanInterface() || !v2.CanInterface() { + panic(unexportedTypePanic{}) + } + return v1.Interface() == v2.Interface() + } +} + +// DeepEqual is like reflect.DeepEqual, but focused on semantic equality +// instead of memory equality. +// +// It will use e's equality functions if it finds types that match. +// +// An empty slice *is* equal to a nil slice for our purposes; same for maps. +// +// Unexported field members cannot be compared and will cause an imformative panic; you must add an Equality +// function for these types. +func (e Equalities) DeepEqual(a1, a2 interface{}) bool { + if a1 == nil || a2 == nil { + return a1 == a2 + } + v1 := reflect.ValueOf(a1) + v2 := reflect.ValueOf(a2) + if v1.Type() != v2.Type() { + return false + } + return e.deepValueEqual(v1, v2, make(map[visit]bool), 0) +} + +func (e Equalities) deepValueDerive(v1, v2 reflect.Value, visited map[visit]bool, depth int) bool { + defer makeUsefulPanic(v1) + + if !v1.IsValid() || !v2.IsValid() { + return v1.IsValid() == v2.IsValid() + } + if v1.Type() != v2.Type() { + return false + } + if fv, ok := e[v1.Type()]; ok { + return fv.Call([]reflect.Value{v1, v2})[0].Bool() + } + + hard := func(k reflect.Kind) bool { + switch k { + case reflect.Array, reflect.Map, reflect.Slice, reflect.Struct: + return true + } + return false + } + + if v1.CanAddr() && v2.CanAddr() && hard(v1.Kind()) { + addr1 := v1.UnsafeAddr() + addr2 := v2.UnsafeAddr() + if addr1 > addr2 { + // Canonicalize order to reduce number of entries in visited. + addr1, addr2 = addr2, addr1 + } + + // Short circuit if references are identical ... + if addr1 == addr2 { + return true + } + + // ... or already seen + typ := v1.Type() + v := visit{addr1, addr2, typ} + if visited[v] { + return true + } + + // Remember for later. + visited[v] = true + } + + switch v1.Kind() { + case reflect.Array: + // We don't need to check length here because length is part of + // an array's type, which has already been filtered for. + for i := 0; i < v1.Len(); i++ { + if !e.deepValueDerive(v1.Index(i), v2.Index(i), visited, depth+1) { + return false + } + } + return true + case reflect.Slice: + if v1.IsNil() || v1.Len() == 0 { + return true + } + if v1.Len() > v2.Len() { + return false + } + if v1.Pointer() == v2.Pointer() { + return true + } + for i := 0; i < v1.Len(); i++ { + if !e.deepValueDerive(v1.Index(i), v2.Index(i), visited, depth+1) { + return false + } + } + return true + case reflect.String: + if v1.Len() == 0 { + return true + } + if v1.Len() > v2.Len() { + return false + } + return v1.String() == v2.String() + case reflect.Interface: + if v1.IsNil() { + return true + } + return e.deepValueDerive(v1.Elem(), v2.Elem(), visited, depth+1) + case reflect.Ptr: + if v1.IsNil() { + return true + } + return e.deepValueDerive(v1.Elem(), v2.Elem(), visited, depth+1) + case reflect.Struct: + for i, n := 0, v1.NumField(); i < n; i++ { + if !e.deepValueDerive(v1.Field(i), v2.Field(i), visited, depth+1) { + return false + } + } + return true + case reflect.Map: + if v1.IsNil() || v1.Len() == 0 { + return true + } + if v1.Len() > v2.Len() { + return false + } + if v1.Pointer() == v2.Pointer() { + return true + } + for _, k := range v1.MapKeys() { + if !e.deepValueDerive(v1.MapIndex(k), v2.MapIndex(k), visited, depth+1) { + return false + } + } + return true + case reflect.Func: + if v1.IsNil() && v2.IsNil() { + return true + } + // Can't do better than this: + return false + default: + // Normal equality suffices + if !v1.CanInterface() || !v2.CanInterface() { + panic(unexportedTypePanic{}) + } + return v1.Interface() == v2.Interface() + } +} + +// DeepDerivative is similar to DeepEqual except that unset fields in a1 are +// ignored (not compared). This allows us to focus on the fields that matter to +// the semantic comparison. +// +// The unset fields include a nil pointer and an empty string. +func (e Equalities) DeepDerivative(a1, a2 interface{}) bool { + if a1 == nil { + return true + } + v1 := reflect.ValueOf(a1) + v2 := reflect.ValueOf(a2) + if v1.Type() != v2.Type() { + return false + } + return e.deepValueDerive(v1, v2, make(map[visit]bool), 0) +} From 930c0dc17d559ebd311b6e5101a9a91b4285dea8 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Fri, 10 Jun 2016 09:31:08 +0200 Subject: [PATCH 0459/1304] glide: introduce glide --- .gitignore | 1 + Documentation/hacking.md | 123 ++-------- Documentation/packaging.md | 4 +- Makefile.in | 2 + glide.yaml | 291 +++++++++++++++++++++++ makelib/misc.mk | 1 + makelib/variables.mk | 3 +- makelib/verbosity.mk | 8 +- scripts/bump-release | 2 +- scripts/genproto.sh | 3 +- scripts/glide-update.sh | 23 ++ scripts/godep-save | 34 --- stage1/net-plugins/net-plugins.mk | 2 +- tests/functional.mk | 6 +- tests/rkt-monitor/README.md | 4 +- tests/rkt-monitor/build | 9 - tests/rkt-monitor/build-cpu-stresser.sh | 26 -- tests/rkt-monitor/build-log-stresser.sh | 26 -- tests/rkt-monitor/build-mem-stresser.sh | 26 -- tests/rkt-monitor/build-stresser.sh | 35 +++ tests/rkt-monitor/build-too-many-apps.sh | 14 +- tests/tests.mk | 2 +- tools/actool.mk | 2 +- tools/cpu-stresser.mk | 22 ++ tools/log-stresser.mk | 22 ++ tools/mem-stresser.mk | 22 ++ tools/rkt-monitor.mk | 20 ++ tools/sleeper.mk | 22 ++ tools/tools.mk | 10 +- vendoredApps | 18 -- 30 files changed, 518 insertions(+), 265 deletions(-) create mode 100644 glide.yaml create mode 100755 scripts/glide-update.sh delete mode 100755 scripts/godep-save delete mode 100755 tests/rkt-monitor/build delete mode 100755 tests/rkt-monitor/build-cpu-stresser.sh delete mode 100755 tests/rkt-monitor/build-log-stresser.sh delete mode 100755 tests/rkt-monitor/build-mem-stresser.sh create mode 100755 tests/rkt-monitor/build-stresser.sh create mode 100644 tools/cpu-stresser.mk create mode 100644 tools/log-stresser.mk create mode 100644 tools/mem-stresser.mk create mode 100644 tools/rkt-monitor.mk create mode 100644 tools/sleeper.mk delete mode 100644 vendoredApps diff --git a/.gitignore b/.gitignore index bda6043d3a..2dc183c6d2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *~ +.cache .vagrant /.config.args /Makefile diff --git a/Documentation/hacking.md b/Documentation/hacking.md index 56180eed6a..d9f7358daa 100644 --- a/Documentation/hacking.md +++ b/Documentation/hacking.md @@ -96,13 +96,9 @@ Follow the instructions on [Update coreos flavor stage1](devel/update-coreos-sta ## Managing dependencies -rkt uses [`godep`](https://github.com/tools/godep) to manage third-party dependencies. -The build process is crafted to make this transparent to most users (i.e. if you're just building rkt from source, or modifying any of the codebase without changing dependencies, you should have no need to interact with godep). +rkt uses [`glide`](https://github.com/Masterminds/glide) and [`glide-vc`](https://github.com/sgotti/glide-vc) to manage third-party dependencies. +The build process is crafted to make this transparent to most users (i.e. if you're just building rkt from source, or modifying any of the codebase without changing dependencies, you should have no need to interact with glide). But occasionally the need arises to either a) add a new dependency or b) update/remove an existing dependency. -There are two types of dependencies: - -- libraries - Go code imported by some Go source file in the repository -- applications - Go code that we need to build to get some executable binary; this means that we want to "import" a "main" package. We might want to vendor an application for several reasons: @@ -110,122 +106,49 @@ We might want to vendor an application for several reasons: - it will be a part of a stage1 image (like CNI plugins for networking) - it will be used in functional tests (like ACE validator) -At this point, the ramblings below from an experienced Godep victim^Wenthusiast might prove of use... - -### Update godep - -Step zero is generally to ensure you have the **latest version** of `godep` available in your `PATH`. - -### Having the right directory layout (i.e. `GOPATH`) - -To work with `godep`, you'll need to have the repository (i.e. `github.com/coreos/rkt`) checked out in a valid `GOPATH`. -If you use the [standard Go workflow](https://golang.org/doc/code.html#Organization), with every package in its proper place in a workspace, this should be no problem. -As an example, if one was obtaining the repository for the first time, one would do the following: - -``` -$ export GOPATH=/tmp/foo # or any directory you please -$ go get -d github.com/coreos/rkt/... # or 'git clone https://github.com/coreos/rkt $GOPATH/src/github.com/coreos/rkt' -$ cd $GOPATH/src/github.com/coreos/rkt -``` - -If, however, you instead prefer to manage your source code in directories like `~/src/rkt`, there's a problem: `godep` doesn't like symbolic links (which is what the rkt build process uses by default to create a self-contained GOPATH). -Hence, you'll need to work around this with bind mounts, with something like the following: - -``` -$ export GOPATH=/tmp/foo # or any directory you please -$ mkdir -p $GOPATH/src/github.com/coreos/rkt -# mount --bind ~/src/rkt $GOPATH/src/github.com/coreos/rkt -$ cd $GOPATH/src/github.com/coreos/rkt -``` - -One benefit of this approach over the single-workspace workflow is that checking out different versions of dependencies in the `GOPATH` (as we are about to do) is guaranteed to not affect any other packages in the `GOPATH`. -(Using [gvm](https://github.com/moovweb/gvm) or other such tomfoolery to manage `GOPATH`s is an exercise left for the reader.) - -### Restoring the current state of dependencies - -Now that we have a functional `GOPATH`, use `godep` to restore the full set of vendored dependencies to their correct versions. -(What this command does is essentially just loop over the set of dependencies codified in `Godeps/Godeps.json`, using `go get` to retrieve and then `git checkout` (or equivalent) to set each to their correct revision.) - -``` -$ godep restore # might take a while if it's the first time... -``` +### Update glide/glide-vc -At this stage, your path forks, depending on what exactly you want to do: add, update or remove a dependency, or add, update or remove an application. -But in _all six cases_, the procedure finishes with the [same save command](#saving-the-set-of-dependencies). +Ensure you have the **latest version** of `glide` and `glide-vc` available in your `PATH`. #### Add a new dependency -In this case you'll first need to retrieve the dependency you're working with into `GOPATH`. -As a simple example, assuming we're adding `github.com/fizz/buzz/tazz`: - +Use the glide tool to add a new dependency. In order to add a dependency to a package i.e. `github.com/fizz/buzz` for version `1.2.3`, execute: ``` -$ go get -d github.com/fizz/buzz +$ glide get -u github.com/fizz/buzz#1.2.3 +$ ./scripts/glide-update.sh ``` -##### If it is a library +Note that although glide does support [versions and ranges](https://github.com/Masterminds/glide/blob/master/docs/versions.md) currently it is preferred to pin to concrete versions as described above. -Add the new dependency into `godep`'s purview by simply importing the standard package name in one of your sources: +*Note*: Do *not* use `go get` and `glide update` to add new dependencies. It will cause both `glide.lock` and `glide.yaml` files to diverge. -``` -$ vim $GOPATH/src/github.com/coreos/rkt/some/file.go -... -import "github.com/fizz/buzz/tazz" -... -``` +#### Update existing dependencies -Now, GOTO [saving](#saving-the-set-of-dependencies) +Once in a while new versions of dependencies are available. Entries in the `glide.yaml` file specify the target version. To update a dependency, edit the appropriate entry and specify the updated target version. -##### If it is an application +*Note*: Changing specific entries in `glide.yaml` does not imply that only those will be updated. Glide will pull potential updates for all dependencies. -Add the new application to the `vendoredApps` file in the root of the repository: +To update a vendored dependency to a newer version, first update its target version directly in `glade.yaml`. The glide update script will then take care of pulling all dependencies and refreshing any updated ones, according to version constraints specified in the YAML manifest. -``` -$ vim vendoredApps -... -github.com/fizz/buzz/tazz -... -``` - -Now, GOTO [saving](#saving-the-set-of-dependencies) - -#### Update an existing dependency - -The steps here are the same for both libraries and applications. -In this case, assuming we're updating `github.com/foo/bar`: +*Note*: Glide will pull all dependencies from all referenced repos potentially causing a lot of network traffic. +Once done editing glide.yaml, execute the glide update script: ``` -$ cd $GOPATH/src/github.com/foo/bar -$ git pull # or 'go get -d -u github.com/foo/bar/...' -$ git checkout $DESIRED_REVISION -$ cd $GOPATH/src/github.com/coreos/rkt -$ godep update github.com/foo/bar/... +$ ./scripts/glide-update.sh ``` -Now, GOTO [saving](#saving-the-set-of-dependencies) +#### Resolving transitive dependency conflicts -#### Removing an existing dependency +Glide currently has no deterministic mechanism to resolve transitive dependency conflicts. A transitive dependency conflict exists if package `A` depends on `B`, and a package `C` also depends on `B`, but on a different version. -This is the simplest case of all. +To resolve this conflict on package `C` specify the version directly in the `glide.yaml` file as described above. -##### If it is a library - -Simply remove all references to a dependency from the source files. - -Now, GOTO [saving](#saving-the-set-of-dependencies) - -##### If it is an application - -Simply remove the relevant line from the `vendoredApps` file. - -Now, GOTO [saving](#saving-the-set-of-dependencies) - -### Saving the set of dependencies - -Finally, here we are, the magic command, the holy grail, the ultimate conclusion of all `godep` operations. -Provided you have followed the preceding instructions, regardless of whether you are adding/removing/modifying dependencies, this innocuous script will cast the necessary spells to solve all of your dependency worries: +#### Removing an existing dependency +Execute: ``` -$ ./scripts/godep-save +$ glide rm github.com/fizz/buzz +$ ./scripts/glide-update.sh ``` ## Errors & Output diff --git a/Documentation/packaging.md b/Documentation/packaging.md index 016a5cdde6..d59282b0f0 100644 --- a/Documentation/packaging.md +++ b/Documentation/packaging.md @@ -28,9 +28,9 @@ The `stage1-host.aci` archive generated by this build will not contain bash, sys For more details, see the [configure script parameters documentation][build-config]. -### Godep +### Glide -rkt uses [Godep](https://github.com/tools/godep) to maintain [a copy of dependencies in its source repository](https://github.com/coreos/rkt/tree/master/Godeps). +rkt uses [Glide](https://github.com/Masterminds/glide) to maintain [a copy of dependencies in its source repository](https://github.com/coreos/rkt/tree/master/vendor). ## Run-time dependencies diff --git a/Makefile.in b/Makefile.in index 01c6cd5efc..db5636e386 100644 --- a/Makefile.in +++ b/Makefile.in @@ -77,6 +77,7 @@ TOPLEVEL_CHECK_STAMPS := TOPLEVEL_UNIT_CHECK_STAMPS := TOPLEVEL_FUNCTIONAL_CHECK_STAMPS := TOPLEVEL_SUBDIRS := rkt tests stage1 stage1_fly +RKT_MONITOR_STAMPS := $(call inc-one,tools/tools.mk) $(call inc-many,$(foreach sd,$(TOPLEVEL_SUBDIRS),$(sd)/$(sd).mk)) @@ -92,6 +93,7 @@ $(TOPLEVEL_CHECK_STAMPS): $(TOPLEVEL_STAMPS) check: $(TOPLEVEL_CHECK_STAMPS) unit-check: $(TOPLEVEL_UNIT_CHECK_STAMPS) functional-check: $(TOPLEVEL_FUNCTIONAL_CHECK_STAMPS) +rkt-monitor: $(RKT_MONITOR_STAMPS) include makelib/file-ops-epilog.mk diff --git a/glide.yaml b/glide.yaml new file mode 100644 index 0000000000..78752a8295 --- /dev/null +++ b/glide.yaml @@ -0,0 +1,291 @@ +package: github.com/coreos/rkt +import: +- package: github.com/StackExchange/wmi + version: f3e2bae1e0cb5aef83e319133eabfee30013a4a5 +- package: github.com/appc/docker2aci + version: v0.11.1 + subpackages: + - lib + - lib/common + - lib/internal + - lib/internal/backend/file + - lib/internal/backend/repository + - lib/internal/docker + - lib/internal/tarball + - lib/internal/types + - lib/internal/util + - pkg/log +- package: github.com/appc/goaci + version: v0.1.0 + subpackages: + - proj2aci +- package: github.com/appc/spec + version: v0.8.4 + subpackages: + - ace + - aci + - actool + - discovery + - pkg/acirenderer + - pkg/device + - pkg/tarheader + - schema + - schema/common + - schema/lastditch + - schema/types +- package: github.com/aws/aws-sdk-go + version: v1.1.7 + subpackages: + - aws + - aws/awserr + - aws/awsutil + - aws/client/metadata + - aws/credentials + - aws/request + - private/protocol/rest + - private/signer/v4 +- package: github.com/camlistore/go4 + version: 9ba773eba85ab9e258ff516630f7f6474bc4535b + subpackages: + - lock +- package: github.com/containernetworking/cni + version: v0.3.0 + subpackages: + - pkg/invoke + - pkg/ip + - pkg/ipam + - pkg/ipam + - pkg/ns + - pkg/skel + - pkg/testutils + - pkg/skel + - pkg/testutils + - pkg/types + - pkg/utils + - pkg/utils/sysctl + - plugins/ipam/dhcp + - plugins/ipam/host-local + - plugins/ipam/host-local/backend + - plugins/ipam/host-local/backend/disk + - plugins/main/bridge + - plugins/main/ipvlan + - plugins/main/macvlan + - plugins/main/ptp + - plugins/meta/flannel + - plugins/meta/tuning + - pkg/utils/sysctl + - plugins/ipam/dhcp + - plugins/ipam/host-local + - plugins/ipam/host-local/backend + - plugins/ipam/host-local/backend/disk + - plugins/main/bridge + - plugins/main/ipvlan + - plugins/main/macvlan + - plugins/main/ptp + - plugins/meta/flannel + - plugins/meta/tuning +- package: github.com/coreos/gexpect + version: v0.1.0 +- package: github.com/coreos/go-iptables + version: v0.1.0 + subpackages: + - iptables +- package: github.com/coreos/go-semver + version: v0.1.0 + subpackages: + - semver +- package: github.com/coreos/go-systemd + version: v10 + subpackages: + - activation + - dbus + - sdjournal + - unit + - util +- package: github.com/coreos/go-tspi + version: v0.1.1 + subpackages: + - tpmclient + - tspiconst + - verification +- package: github.com/coreos/ioprogress + version: e7fc03058804de5488baed8df5b89f3924b9ec9a +- package: github.com/coreos/pkg + version: v2 + subpackages: + - dlopen + - progressutil +- package: github.com/cpuguy83/go-md2man + version: v1.0.4 + subpackages: + - md2man +- package: github.com/cznic/b + version: e2e747ce049fb910cff6b1fd7ad8faf3900939d5 +- package: github.com/cznic/bufs + version: 3dcccbd7064a1689f9c093a988ea11ac00e21f51 +- package: github.com/cznic/exp + version: 36265f1914ea00990ff0b73f72350edf9b1850df + subpackages: + - lldb +- package: github.com/cznic/fileutil + version: 21ae57c9dce724a15e88bd9cd46d5668f3e880a5 +- package: github.com/cznic/mathutil + version: 250d0b9d3304c5ea0c4cfc7d9efc7ee528b81f3b +- package: github.com/cznic/ql + version: 77545ff365ff426dfab06c46d70fa77600cd55af + subpackages: + - driver +- package: github.com/cznic/sortutil + version: d4401851b4c370f979b842fa1e45e0b3b718b391 +- package: github.com/cznic/strutil + version: 97bc31f80ac4c9fa9c5dc5fea74c383858988ea2 +- package: github.com/cznic/zappy + version: 47331054e4f96186e3ff772877c0443909368a45 +- package: github.com/d2g/dhcp4 + version: f0e4d29ff0231dce36e250b2ed9ff08412584bca +- package: github.com/d2g/dhcp4client + version: bed07e1bc5b85f69c6f0fd73393aa35ec68ed892 +- package: github.com/docker/distribution + version: v2.3.0 + subpackages: + - digest + - reference +- package: github.com/dustin/go-humanize + version: c20a8bde38c8f5ba06f6600edf473705c96829d1 +- package: github.com/go-ini/ini + version: v1.11.0 +- package: github.com/go-ole/go-ole + version: 572eabb84c424e76a0d39d31510dd7dfd62f70b2 + subpackages: + - oleutil +- package: github.com/godbus/dbus + version: a1b8ba5163b7f041b22761461eabd02b70d1f824 + subpackages: + - introspect +- package: github.com/gogo/protobuf + version: v0.2 + subpackages: + - proto +- package: github.com/golang/protobuf + version: 2402d76f3d41f928c7902a765dfc872356dd3aad + subpackages: + - proto + - protoc-gen-go + - protoc-gen-go/descriptor + - protoc-gen-go/generator + - protoc-gen-go/internal/grpc + - protoc-gen-go/plugin +- package: github.com/google/btree + version: f06e229e679911bb31a04e07ac891115822e37c3 +- package: github.com/gorilla/context + version: 50c25fb3b2b3b3cc724e9b6ac75fb44b3bccd0da +- package: github.com/gorilla/mux + version: e444e69cbd2e2e3e0749a2f3c717cec491552bbf +- package: github.com/hashicorp/errwrap + version: 7554cd9344cec97297fa6649b055a8c98c2a1e55 +- package: github.com/hydrogen18/stoppableListener + version: 2eebd04b47ff393f4bc50b7fcacf8f048994c6fd +- package: github.com/inconshreveable/mousetrap + version: 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75 +- package: github.com/jmespath/go-jmespath + version: 0b12d6b521d83fc7f755e7cfc1b1fbdd35a01a74 +- package: github.com/kballard/go-shellquote + version: e5c918b80c17694cbc49aab32a759f9a40067f5d +- package: github.com/kr/pty + version: f7ee69f31298ecbe5d2b349c711e2547a617d398 +- package: github.com/pborman/uuid + version: cccd189d45f7ac3368a0d127efb7f4d08ae0b655 +- package: github.com/peterbourgon/diskv + version: v2.0.0 +- package: github.com/russross/blackfriday + version: 300106c228d52c8941d4b3de6054a6062a86dda3 +- package: github.com/shirou/gopsutil + version: v2.0.0 + subpackages: + - cpu + - host + - internal/common + - load + - mem + - net + - process +- package: github.com/shirou/w32 + version: 3c9377fc6748f222729a8270fe2775d149a249ad +- package: github.com/shurcooL/sanitized_anchor_name + version: 10ef21a441db47d8b13ebcc5fd2310f636973c77 +- package: github.com/spf13/cobra + version: 4c05eb1145f16d0e6bb4a3e1b6d769f4713cb41f + subpackages: + - doc +- package: github.com/spf13/pflag + version: 08b1a584251b5b62f458943640fc8ebd4d50aaa5 +- package: github.com/syndtr/gocapability + version: 8e4cdcb3c22b40d5e330ade0b68cb2e2a3cf6f98 + subpackages: + - capability +- package: github.com/vishvananda/netlink + version: ecf47fd5739b3d2c3daf7c89c4b9715a2605c21b + subpackages: + - nl +- package: go4.org + version: 03efcb870d84809319ea509714dd6d19a1498483 + subpackages: + - errorutil +- package: golang.org/x/crypto + version: a7ead6ddf06233883deca151dffaef2effbf498f + subpackages: + - cast5 + - openpgp + - openpgp/armor + - openpgp/elgamal + - openpgp/errors + - openpgp/packet + - openpgp/s2k + - ssh/terminal +- package: golang.org/x/net + version: d513e58596cd55e6f47cd1dcbff6b46035baeccb + subpackages: + - context + - html + - html/atom + - http2 + - http2/hpack + - internal/timeseries + - trace +- package: golang.org/x/sys + version: b44883b474ffefa37335017174e397412b633a4f + subpackages: + - unix +- package: golang.org/x/tools + version: 27e692e6ec36d8f48be794f32553e1400c70dbf2 + subpackages: + - go/vcs +- package: google.golang.org/grpc + version: 0f80f5b995e8332b1bdaac1bc37af0482c60147c + subpackages: + - codes + - credentials + - grpclog + - metadata + - naming + - peer + - transport + - internal +- package: gopkg.in/inf.v0 + version: v0.9.0 +- package: k8s.io/kubernetes + version: v1.3.0-alpha.4 + subpackages: + - pkg/api/resource + - pkg/conversion + - third_party/forked/reflect +- package: github.com/klauspost/pgzip + version: v1.0 +- package: github.com/klauspost/compress + version: v1.0 + subpackages: + - flate +- package: github.com/klauspost/crc32 + version: v1.0 +- package: github.com/klauspost/cpuid + version: v1.0 diff --git a/makelib/misc.mk b/makelib/misc.mk index fcd0dfc15f..0b95c23364 100644 --- a/makelib/misc.mk +++ b/makelib/misc.mk @@ -180,6 +180,7 @@ $(strip \ $(eval _MISC_GFD_GO_LIST_ITEMS_ := $(foreach i,$2,{{.$i}})) \ $(eval _MISC_GFD_FILES_ := $(shell $(GO_ENV) "$(GO)" list -f '{{.ImportPath}} $(_MISC_GFD_GO_LIST_ITEMS_)' $1 | \ grep '\[[^]]' | \ + grep -v '/vendor' | \ sed -e 's/.*$(_MISC_GFD_ESCAPED_SRCDIR)\///' -e 's/[[:space:]]*\[.*\]$$//' \ $(if $3,| grep --invert-match '^\($(subst $(_MISC_GFD_SPACE_),\|,$3)\)'))) \ $(_MISC_GFD_FILES_) \ diff --git a/makelib/variables.mk b/makelib/variables.mk index eabc804a02..8408c2ae10 100644 --- a/makelib/variables.mk +++ b/makelib/variables.mk @@ -10,7 +10,7 @@ TARGETDIR := $(BUILDDIR)/target TARGET_BINDIR := $(BUILDDIR)/target/bin TARGET_TOOLSDIR := $(BUILDDIR)/target/tools GOPATH_TO_CREATE := $(BUILDDIR)/gopath -GOPATH := $(GOPATH_TO_CREATE)/src/github.com/coreos/rkt/Godeps/_workspace:$(GOPATH_TO_CREATE) +GOPATH := $(GOPATH_TO_CREATE) DEPSDIR := $(BUILDDIR)/deps FILELISTDIR := $(BUILDDIR)/filelists MAINTEMPDIR := $(BUILDDIR)/tmp @@ -27,6 +27,7 @@ GO_TEST_PACKAGES ?= ./... GO_TEST_FUNC_ARGS ?= GO_ENV := $(strip \ + GO15VENDOREXPERIMENT=1 \ GOARCH="$(GOARCH)" \ CGO_ENABLED=1 \ CC="$(CC)" \ diff --git a/makelib/verbosity.mk b/makelib/verbosity.mk index a288de8581..3e6f49f6e8 100644 --- a/makelib/verbosity.mk +++ b/makelib/verbosity.mk @@ -130,10 +130,10 @@ define vsp $(subst $(MK_TOPLEVEL_ABS_SRCDIR)/,,$1) endef -# This shortens the paths by removing the Godeps workspace part. So it +# This shortens the paths by removing the vendor part. So it # truncates -# github.com/coreos/rkt/Godeps/_workspace/src/github.com/appc/spec/schema -# to /github.com/appc/spec/schema. +# github.com/coreos/rkt/vendor/github.com/appc/spec/schema +# to /github.com/appc/spec/schema. define vsg -$(subst $(REPO_PATH)/Godeps/_workspace/src,,$1) +$(subst $(REPO_PATH)/vendor,,$1) endef diff --git a/scripts/bump-release b/scripts/bump-release index ed51293b29..e9a114ed88 100755 --- a/scripts/bump-release +++ b/scripts/bump-release @@ -34,7 +34,7 @@ function replace_stuff() { } function replace_all() { - replace_stuff $1 $2 $(git ls-files | grep -Ev "(CHANGELOG.md|Godeps|manifest\.d)") + replace_stuff $1 $2 $(git ls-files | grep -Ev "(CHANGELOG.md|vendor|manifest\.d)") } function replace_version() { diff --git a/scripts/genproto.sh b/scripts/genproto.sh index e536b81851..35416a58a5 100755 --- a/scripts/genproto.sh +++ b/scripts/genproto.sh @@ -15,11 +15,10 @@ if ! [[ $(protoc --version) =~ "3.0.0" ]]; then exit 255 fi -export GOPATH=$(godep path) export PATH=.:${PATH} echo "building protoc-gen-go" -go build github.com/golang/protobuf/protoc-gen-go +go build vendor/github.com/golang/protobuf/protoc-gen-go trap 'rm -f "protoc-gen-go"' EXIT echo "generating code" diff --git a/scripts/glide-update.sh b/scripts/glide-update.sh new file mode 100755 index 0000000000..d28a2d500f --- /dev/null +++ b/scripts/glide-update.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# +# Update vendored dedendencies. +# +set -e + +if ! [[ "$0" =~ "scripts/glide-update.sh" ]]; then + echo "must be run from repository root" + exit 255 +fi + +if [ ! $(command -v glide) ]; then + echo "glide: command not found" + exit 255 +fi + +if [ ! $(command -v glide-vc) ]; then + echo "glide-vc: command not found" + exit 255 +fi + +glide update --strip-vcs --strip-vendor --update-vendored --delete +glide-vc --only-code --no-tests --keep="**/*.json.in" diff --git a/scripts/godep-save b/scripts/godep-save deleted file mode 100755 index f488d575a1..0000000000 --- a/scripts/godep-save +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash -set -e - -# make sure we are running in a toplevel directory -if ! [[ "$0" =~ "scripts/godep-save" ]]; then - echo "This script must be run in a toplevel rkt directory" - exit 255 -fi - -# make sure that we have the fixed version of godep, which vendors -# external projects, but does not modify them. -REQGV=41 -GV=$(godep version | sed -e 's/^godep v\([0-9]\+\).*/\1/') -if [[ "${GV}" -lt "${REQGV}" ]]; then - echo "The godep tool is too old (${GV}), must be at least version ${REQGV}" - exit 255 -fi - -VA=vendoredApps -APPS='' -if [[ -r "${VA}" ]]; then - # grep filters all empty lines and all lines with comments - # only, sed removes the comments from the other lines - APPS=$(cat "${VA}" \ - | grep -v '^\([[:space:]]*#.*\)\?$' \ - | sed -e 's/[[:space:]]*#.*//g') -else - echo "No file '${VA}' found" -fi - -CMD="godep save ./... ${APPS}" - -echo Running ${CMD} -exec ${CMD} diff --git a/stage1/net-plugins/net-plugins.mk b/stage1/net-plugins/net-plugins.mk index edff85c2d4..513bbc7d8c 100644 --- a/stage1/net-plugins/net-plugins.mk +++ b/stage1/net-plugins/net-plugins.mk @@ -38,7 +38,7 @@ $$(call setup-stamp-file,NPM_STAMP,$$(NPM_BASE)) # variables for makelib/build_go_bin.mk BGB_STAMP := $$(NPM_STAMP) BGB_BINARY := $$(NPM_PLUGIN) -BGB_PKG_IN_REPO := Godeps/_workspace/src/github.com/containernetworking/cni/plugins/$1 +BGB_PKG_IN_REPO := vendor/github.com/containernetworking/cni/plugins/$1 include makelib/build_go_bin.mk $$(NPM_PLUGIN): $(TARGET_TOOLSDIR) diff --git a/tests/functional.mk b/tests/functional.mk index 7fb9ba7c4a..d22095ba3f 100644 --- a/tests/functional.mk +++ b/tests/functional.mk @@ -10,11 +10,11 @@ FTST_IMAGE_MANIFEST := $(FTST_IMAGE_DIR)/manifest FTST_IMAGE_TEST_DIRS := $(FTST_IMAGE_ROOTFSDIR)/dir1 $(FTST_IMAGE_ROOTFSDIR)/dir2 $(FTST_IMAGE_ROOTFSDIR)/bin $(FTST_IMAGE_ROOTFSDIR)/etc FTST_ACE_MAIN_IMAGE_DIR := $(FTST_TMPDIR)/ace-main FTST_ACE_MAIN_IMAGE := $(FTST_TMPDIR)/rkt-ace-validator-main.aci -FTST_ACE_MAIN_IMAGE_MANIFEST_SRC := Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_main.json.in +FTST_ACE_MAIN_IMAGE_MANIFEST_SRC := vendor/github.com/appc/spec/ace/image_manifest_main.json.in FTST_ACE_MAIN_IMAGE_MANIFEST := $(FTST_ACE_MAIN_IMAGE_DIR)/manifest FTST_ACE_SIDEKICK_IMAGE_DIR := $(FTST_TMPDIR)/ace-sidekick FTST_ACE_SIDEKICK_IMAGE := $(FTST_TMPDIR)/rkt-ace-validator-sidekick.aci -FTST_ACE_SIDEKICK_IMAGE_MANIFEST_SRC := Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_sidekick.json.in +FTST_ACE_SIDEKICK_IMAGE_MANIFEST_SRC := vendor/github.com/appc/spec/ace/image_manifest_sidekick.json.in FTST_ACE_SIDEKICK_IMAGE_MANIFEST := $(FTST_ACE_SIDEKICK_IMAGE_DIR)/manifest FTST_INSPECT_BINARY := $(FTST_TMPDIR)/inspect FTST_ACI_INSPECT := $(FTST_IMAGE_ROOTFSDIR)/inspect @@ -120,7 +120,7 @@ include makelib/build_go_bin.mk BGB_STAMP := $(FTST_FUNCTIONAL_TESTS_STAMP) BGB_BINARY := $(FTST_ACE_BINARY) -BGB_PKG_IN_REPO := Godeps/_workspace/src/github.com/appc/spec/ace +BGB_PKG_IN_REPO := vendor/github.com/appc/spec/ace BGB_GO_FLAGS := -a -installsuffix cgo BGB_ADDITIONAL_GO_ENV := CGO_ENABLED=0 diff --git a/tests/rkt-monitor/README.md b/tests/rkt-monitor/README.md index 1beda661fb..94cbc51575 100644 --- a/tests/rkt-monitor/README.md +++ b/tests/rkt-monitor/README.md @@ -28,7 +28,7 @@ attempt to eat up resources in different ways. An example usage: ``` -derek@rokot ~/go/src/github.com/coreos/rkt/tests/rkt-monitor> ./build-log-stresser.sh +derek@rokot ~/go/src/github.com/coreos/rkt> ./tests/rkt-monitor/build-stresser.sh log Building worker... Beginning build with an empty ACI Setting name of ACI to appc.io/rkt-log-stresser @@ -36,7 +36,7 @@ Copying host:worker-binary to aci:/worker Setting exec command [/worker] Writing ACI to log-stresser.aci Ending the build -derek@rokot ~/go/src/github.com/coreos/rkt/tests/rkt-monitor> sudo ./rkt-monitor log-stresser.aci +derek@rokot ~/go/src/github.com/coreos/rkt> sudo ./build-rkt-1.8.0+git/bin/rkt-monitor log-stresser.aci [sudo] password for derek: rkt(13261): seconds alive: 10 avg CPU: 33.113897% avg Mem: 4 kB peak Mem: 4 kB systemd(13302): seconds alive: 9 avg CPU: 0.000000% avg Mem: 4 mB peak Mem: 4 mB diff --git a/tests/rkt-monitor/build b/tests/rkt-monitor/build deleted file mode 100755 index 5189fc5d44..0000000000 --- a/tests/rkt-monitor/build +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -set -e - -export GOPATH=${PWD}/../../Godeps/_workspace - -eval $(go env) -export GOOS GOARCH - -go build -o rkt-monitor diff --git a/tests/rkt-monitor/build-cpu-stresser.sh b/tests/rkt-monitor/build-cpu-stresser.sh deleted file mode 100755 index a39a3d2d1d..0000000000 --- a/tests/rkt-monitor/build-cpu-stresser.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash -set -e - -echo "Building worker..." -CGO_ENABLED=0 GOOS=linux go build -o worker-binary -a -tags netgo -ldflags '-w' ./cpu-stresser/main.go - -rmWorker() { rm worker-binary; } -acbuildEnd() { - rmWorker - export EXIT=$? - acbuild --debug end && exit $EXIT -} - -trap rmWorker EXIT - -acbuild --debug begin - -trap acbuildEnd EXIT - -acbuild --debug set-name appc.io/rkt-cpu-stresser - -acbuild --debug copy worker-binary /worker - -acbuild --debug set-exec -- /worker - -acbuild --debug write --overwrite cpu-stresser.aci diff --git a/tests/rkt-monitor/build-log-stresser.sh b/tests/rkt-monitor/build-log-stresser.sh deleted file mode 100755 index 692d120052..0000000000 --- a/tests/rkt-monitor/build-log-stresser.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash -set -e - -echo "Building worker..." -CGO_ENABLED=0 GOOS=linux go build -o worker-binary -a -tags netgo -ldflags '-w' ./log-stresser/main.go - -rmWorker() { rm worker-binary; } -acbuildEnd() { - rmWorker - export EXIT=$? - acbuild --debug end && exit $EXIT -} - -trap rmWorker EXIT - -acbuild --debug begin - -trap acbuildEnd EXIT - -acbuild --debug set-name appc.io/rkt-log-stresser - -acbuild --debug copy worker-binary /worker - -acbuild --debug set-exec -- /worker - -acbuild --debug write --overwrite log-stresser.aci diff --git a/tests/rkt-monitor/build-mem-stresser.sh b/tests/rkt-monitor/build-mem-stresser.sh deleted file mode 100755 index fa1cfd4048..0000000000 --- a/tests/rkt-monitor/build-mem-stresser.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash -set -e - -echo "Building worker..." -CGO_ENABLED=0 GOOS=linux go build -o worker-binary -a -tags netgo -ldflags '-w' ./mem-stresser/main.go - -rmWorker() { rm worker-binary; } -acbuildEnd() { - rmWorker - export EXIT=$? - acbuild --debug end && exit $EXIT -} - -trap rmWorker EXIT - -acbuild --debug begin - -trap acbuildEnd EXIT - -acbuild --debug set-name appc.io/rkt-mem-stresser - -acbuild --debug copy worker-binary /worker - -acbuild --debug set-exec -- /worker - -acbuild --debug write --overwrite mem-stresser.aci diff --git a/tests/rkt-monitor/build-stresser.sh b/tests/rkt-monitor/build-stresser.sh new file mode 100755 index 0000000000..1bc66ab2d6 --- /dev/null +++ b/tests/rkt-monitor/build-stresser.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +set -e + +if ! [[ "$0" =~ "tests/rkt-monitor/build-stresser.sh" ]]; then + echo "must be run from repository root" + exit 255 +fi + +stressers=(cpu mem log) + +if [ -z "${1}" ]; then + echo Specify one of \""${stressers[@]}"\" + exit 1 +fi + + +echo "Building worker..." +make rkt-monitor + +acbuildEnd() { + export EXIT=$? + acbuild --debug end && exit $EXIT +} + +acbuild --debug begin + +trap acbuildEnd EXIT + +acbuild --debug set-name appc.io/rkt-"${1}"-stresser + +acbuild --debug copy build-rkt-1.8.0+git/bin/"${1}"-stresser /worker + +acbuild --debug set-exec -- /worker + +acbuild --debug write --overwrite "${1}"-stresser.aci diff --git a/tests/rkt-monitor/build-too-many-apps.sh b/tests/rkt-monitor/build-too-many-apps.sh index 258d7ee51b..97e0a31152 100755 --- a/tests/rkt-monitor/build-too-many-apps.sh +++ b/tests/rkt-monitor/build-too-many-apps.sh @@ -1,19 +1,21 @@ #!/usr/bin/env bash - set -e +if ! [[ "$0" =~ "tests/rkt-monitor/build-too-many-apps.sh" ]]; then + echo "must be run from repository root" + exit 255 +fi + NUM_APPS=100 # Build worker binary echo "Building worker binary" -CGO_ENABLED=0 GOOS=linux go build -o worker-binary -a -tags netgo -ldflags '-w' ./sleeper/main.go +make rkt-monitor # Generate worker images -rmWorker() { rm worker-binary; } acbuildEnd() { - rmWorker export EXIT=$? acbuild --debug end && exit $EXIT } @@ -28,15 +30,13 @@ do echo "Building image ${NAME}" acbuild begin - acbuild copy worker-binary /worker-binary + acbuild copy build-rkt-1.8.0+git/bin/sleeper /worker-binary acbuild set-exec /worker-binary acbuild set-name ${NAME} acbuild write --overwrite too-many-apps-images/${NAME}.aci acbuild end done -trap rmWorker EXIT - # Generate pod manifest echo "Generating pod manifest" diff --git a/tests/tests.mk b/tests/tests.mk index 2eaef12f4d..743da07b6a 100644 --- a/tests/tests.mk +++ b/tests/tests.mk @@ -20,7 +20,7 @@ $(TST_SHORT_TESTS_STAMP): if [ -n "$${res}" ]; then echo -e "govet checking failed:\n$${res}"; exit 1; fi; \ $(call vb,vt,(C) CHECK) \ res=$$( \ - for file in $$(find . -type f -iname '*.go' ! -path './Godeps/*'); do \ + for file in $$(find . -type f -iname '*.go' ! -path './vendor/*'); do \ head -n1 "$${file}" | grep -Eq "(Copyright|generated)" || echo -e " $${file}"; \ done; \ ); \ diff --git a/tools/actool.mk b/tools/actool.mk index 4d341b4d50..26f0bd2057 100644 --- a/tools/actool.mk +++ b/tools/actool.mk @@ -2,7 +2,7 @@ $(call setup-stamp-file,ACTOOL_STAMP) # variables for makelib/build_go_bin.mk BGB_STAMP := $(ACTOOL_STAMP) -BGB_PKG_IN_REPO := Godeps/_workspace/src/github.com/appc/spec/actool +BGB_PKG_IN_REPO := vendor/github.com/appc/spec/actool BGB_BINARY := $(ACTOOL) BGB_ADDITIONAL_GO_ENV := GOARCH=$(GOARCH_FOR_BUILD) CC=$(CC_FOR_BUILD) diff --git a/tools/cpu-stresser.mk b/tools/cpu-stresser.mk new file mode 100644 index 0000000000..f78fbebedd --- /dev/null +++ b/tools/cpu-stresser.mk @@ -0,0 +1,22 @@ +$(call setup-stamp-file,CPU_STRESSER_STAMP) + +# variables for makelib/build_go_bin.mk +CPU_STRESSER := $(BINDIR)/cpu-stresser +BGB_STAMP := $(CPU_STRESSER_STAMP) +BGB_PKG_IN_REPO := tests/rkt-monitor/cpu-stresser +BGB_BINARY := $(CPU_STRESSER) +BGB_ADDITIONAL_GO_ENV := GOARCH=$(GOARCH_FOR_BUILD) +BGB_GO_FLAGS := -tags netgo -ldflags '-w' +BGB_ADDITIONAL_GO_ENV := CGO_ENABLED=0 GOOS=linux + +CLEAN_FILES += $(CPU_STRESSER) + +$(call generate-stamp-rule,$(CPU_STRESSER_STAMP)) + +$(CPU_STRESSER): $(MK_PATH) | $(BINDIR) + +include makelib/build_go_bin.mk + +# CPU_STRESSER_STAMP deliberately not cleared + +RKT_MONITOR_STAMPS += $(CPU_STRESSER_STAMP) diff --git a/tools/log-stresser.mk b/tools/log-stresser.mk new file mode 100644 index 0000000000..21c3b4fa5a --- /dev/null +++ b/tools/log-stresser.mk @@ -0,0 +1,22 @@ +$(call setup-stamp-file,LOG_STRESSER_STAMP) + +# variables for makelib/build_go_bin.mk +LOG_STRESSER := $(BINDIR)/log-stresser +BGB_STAMP := $(LOG_STRESSER_STAMP) +BGB_PKG_IN_REPO := tests/rkt-monitor/log-stresser +BGB_BINARY := $(LOG_STRESSER) +BGB_ADDITIONAL_GO_ENV := GOARCH=$(GOARCH_FOR_BUILD) +BGB_GO_FLAGS := -tags netgo -ldflags '-w' +BGB_ADDITIONAL_GO_ENV := CGO_ENABLED=0 GOOS=linux + +CLEAN_FILES += $(LOG_STRESSER) + +$(call generate-stamp-rule,$(LOG_STRESSER_STAMP)) + +$(LOG_STRESSER): $(MK_PATH) | $(BINDIR) + +include makelib/build_go_bin.mk + +# LOG_STRESSER_STAMP deliberately not cleared + +RKT_MONITOR_STAMPS += $(LOG_STRESSER_STAMP) diff --git a/tools/mem-stresser.mk b/tools/mem-stresser.mk new file mode 100644 index 0000000000..c66331f3d7 --- /dev/null +++ b/tools/mem-stresser.mk @@ -0,0 +1,22 @@ +$(call setup-stamp-file,MEM_STRESSER_STAMP) + +# variables for makelib/build_go_bin.mk +MEM_STRESSER := $(BINDIR)/mem-stresser +BGB_STAMP := $(MEM_STRESSER_STAMP) +BGB_PKG_IN_REPO := tests/rkt-monitor/mem-stresser +BGB_BINARY := $(MEM_STRESSER) +BGB_ADDITIONAL_GO_ENV := GOARCH=$(GOARCH_FOR_BUILD) +BGB_GO_FLAGS := -tags netgo -ldflags '-w' +BGB_ADDITIONAL_GO_ENV := CGO_ENABLED=0 GOOS=linux + +CLEAN_FILES += $(MEM_STRESSER) + +$(call generate-stamp-rule,$(MEM_STRESSER_STAMP)) + +$(MEM_STRESSER): $(MK_PATH) | $(BINDIR) + +include makelib/build_go_bin.mk + +# MEM_STRESSER_STAMP deliberately not cleared + +RKT_MONITOR_STAMPS += $(MEM_STRESSER_STAMP) diff --git a/tools/rkt-monitor.mk b/tools/rkt-monitor.mk new file mode 100644 index 0000000000..d6fa0db1b7 --- /dev/null +++ b/tools/rkt-monitor.mk @@ -0,0 +1,20 @@ +$(call setup-stamp-file,RKT_MONITOR_STAMP) + +# variables for makelib/build_go_bin.mk +RKT_MONITOR := $(BINDIR)/rkt-monitor +BGB_STAMP := $(RKT_MONITOR_STAMP) +BGB_PKG_IN_REPO := tests/rkt-monitor +BGB_BINARY := $(RKT_MONITOR) +BGB_ADDITIONAL_GO_ENV := GOARCH=$(GOARCH_FOR_BUILD) + +CLEAN_FILES += $(RKT_MONITOR) + +$(call generate-stamp-rule,$(RKT_MONITOR_STAMP)) + +$(RKT_MONITOR): $(MK_PATH) | $(BINDIR) + +include makelib/build_go_bin.mk + +# RKT_MONITOR_STAMP deliberately not cleared + +RKT_MONITOR_STAMPS += $(RKT_MONITOR_STAMP) diff --git a/tools/sleeper.mk b/tools/sleeper.mk new file mode 100644 index 0000000000..ae028aaa2c --- /dev/null +++ b/tools/sleeper.mk @@ -0,0 +1,22 @@ +$(call setup-stamp-file,SLEEPER_STAMP) + +# variables for makelib/build_go_bin.mk +SLEEPER := $(BINDIR)/sleeper +BGB_STAMP := $(SLEEPER_STAMP) +BGB_PKG_IN_REPO := tests/rkt-monitor/sleeper +BGB_BINARY := $(SLEEPER) +BGB_ADDITIONAL_GO_ENV := GOARCH=$(GOARCH_FOR_BUILD) +BGB_GO_FLAGS := -tags netgo -ldflags '-w' +BGB_ADDITIONAL_GO_ENV := CGO_ENABLED=0 GOOS=linux + +CLEAN_FILES += $(SLEEPER) + +$(call generate-stamp-rule,$(SLEEPER_STAMP)) + +$(SLEEPER): $(MK_PATH) | $(BINDIR) + +include makelib/build_go_bin.mk + +# SLEEPER_STAMP deliberately not cleared + +RKT_MONITOR_STAMPS += $(SLEEPER_STAMP) diff --git a/tools/tools.mk b/tools/tools.mk index 7e769b54f4..6bcbaa793f 100644 --- a/tools/tools.mk +++ b/tools/tools.mk @@ -1,4 +1,12 @@ # depsgentool is special (building other tools require it), so it has # to be included first $(call inc-one,depsgentool.mk) -$(call inc-many,actool.mk filelistgentool.mk cleangentool.mk quickrmtool.mk) +$(call inc-many,actool.mk \ + filelistgentool.mk \ + cleangentool.mk \ + quickrmtool.mk \ + rkt-monitor.mk \ + log-stresser.mk \ + cpu-stresser.mk \ + mem-stresser.mk \ + sleeper.mk) diff --git a/vendoredApps b/vendoredApps deleted file mode 100644 index c65ebb2343..0000000000 --- a/vendoredApps +++ /dev/null @@ -1,18 +0,0 @@ -# Vendor in actool, which is used in building the stage1 ACI -github.com/appc/spec/actool - -# Vendor in CNI plugins, which will become a part of the stage1 image -github.com/containernetworking/cni/plugins/ipam/dhcp -github.com/containernetworking/cni/plugins/ipam/host-local -github.com/containernetworking/cni/plugins/main/bridge -github.com/containernetworking/cni/plugins/main/ipvlan -github.com/containernetworking/cni/plugins/main/macvlan -github.com/containernetworking/cni/plugins/main/ptp -github.com/containernetworking/cni/plugins/meta/flannel -github.com/containernetworking/cni/plugins/meta/tuning - -# Vendor in ACE, which is used in functional tests -github.com/appc/spec/ace - -# Vendor protobuf go generator -github.com/golang/protobuf/protoc-gen-go From 33232bbbde471a915958bf10b3b5e70e2e29fbd1 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Wed, 29 Jun 2016 10:41:41 +0200 Subject: [PATCH 0460/1304] glide: remove Godeps --- Godeps/Godeps.json | 796 - Godeps/Readme | 5 - Godeps/_workspace/.gitignore | 2 - .../src/github.com/StackExchange/wmi/LICENSE | 20 - .../github.com/StackExchange/wmi/README.md | 4 - .../src/github.com/StackExchange/wmi/wmi.go | 416 - .../src/github.com/appc/docker2aci/LICENSE | 202 - .../appc/docker2aci/lib/common/common.go | 62 - .../appc/docker2aci/lib/conversion_store.go | 126 - .../appc/docker2aci/lib/docker2aci.go | 417 - .../lib/internal/backend/file/file.go | 332 - .../internal/backend/repository/repository.go | 164 - .../backend/repository/repository1.go | 391 - .../backend/repository/repository2.go | 466 - .../lib/internal/docker/docker_functions.go | 161 - .../appc/docker2aci/lib/internal/internal.go | 591 - .../lib/internal/tarball/tarfile.go | 42 - .../docker2aci/lib/internal/tarball/walk.go | 43 - .../lib/internal/types/docker_types.go | 92 - .../docker2aci/lib/internal/types/types.go | 27 - .../appc/docker2aci/lib/internal/util/util.go | 83 - .../github.com/appc/docker2aci/lib/version.go | 20 - .../github.com/appc/docker2aci/pkg/log/log.go | 46 - .../src/github.com/appc/goaci/LICENSE | 202 - .../github.com/appc/goaci/proj2aci/asset.go | 283 - .../github.com/appc/goaci/proj2aci/binary.go | 44 - .../github.com/appc/goaci/proj2aci/builder.go | 365 - .../github.com/appc/goaci/proj2aci/cmake.go | 234 - .../src/github.com/appc/goaci/proj2aci/go.go | 195 - .../src/github.com/appc/goaci/proj2aci/run.go | 65 - .../github.com/appc/goaci/proj2aci/util.go | 68 - .../src/github.com/appc/goaci/proj2aci/vcs.go | 118 - .../src/github.com/appc/spec/LICENSE | 202 - .../src/github.com/appc/spec/ace/build_aci | 48 - .../src/github.com/appc/spec/ace/doc.go | 19 - .../appc/spec/ace/image_manifest_main.json.in | 80 - .../spec/ace/image_manifest_sidekick.json.in | 24 - .../github.com/appc/spec/ace/os_default.go | 26 - .../github.com/appc/spec/ace/os_freebsd.go | 32 - .../src/github.com/appc/spec/ace/os_linux.go | 45 - .../src/github.com/appc/spec/ace/os_shared.go | 35 - .../src/github.com/appc/spec/ace/validator.go | 578 - .../src/github.com/appc/spec/aci/build.go | 110 - .../src/github.com/appc/spec/aci/doc.go | 16 - .../src/github.com/appc/spec/aci/file.go | 246 - .../src/github.com/appc/spec/aci/layout.go | 187 - .../src/github.com/appc/spec/aci/writer.go | 98 - .../src/github.com/appc/spec/actool/actool.go | 118 - .../src/github.com/appc/spec/actool/build.go | 145 - .../github.com/appc/spec/actool/discover.go | 106 - .../src/github.com/appc/spec/actool/doc.go | 17 - .../src/github.com/appc/spec/actool/help.go | 140 - .../github.com/appc/spec/actool/manifest.go | 525 - .../github.com/appc/spec/actool/validate.go | 177 - .../github.com/appc/spec/actool/version.go | 33 - .../appc/spec/discovery/discovery.go | 257 - .../src/github.com/appc/spec/discovery/doc.go | 17 - .../github.com/appc/spec/discovery/http.go | 122 - .../github.com/appc/spec/discovery/parse.go | 130 - .../appc/spec/pkg/acirenderer/acirenderer.go | 253 - .../appc/spec/pkg/acirenderer/resolve.go | 88 - .../appc/spec/pkg/device/device_linux.go | 33 - .../appc/spec/pkg/device/device_posix.go | 57 - .../github.com/appc/spec/pkg/tarheader/doc.go | 17 - .../appc/spec/pkg/tarheader/pop_darwin.go | 39 - .../appc/spec/pkg/tarheader/pop_linux.go | 39 - .../appc/spec/pkg/tarheader/pop_posix.go | 50 - .../appc/spec/pkg/tarheader/tarheader.go | 28 - .../appc/spec/schema/common/common.go | 40 - .../src/github.com/appc/spec/schema/doc.go | 25 - .../src/github.com/appc/spec/schema/image.go | 103 - .../src/github.com/appc/spec/schema/kind.go | 42 - .../appc/spec/schema/lastditch/doc.go | 28 - .../appc/spec/schema/lastditch/image.go | 45 - .../appc/spec/schema/lastditch/labels.go | 38 - .../appc/spec/schema/lastditch/pod.go | 57 - .../src/github.com/appc/spec/schema/pod.go | 168 - .../appc/spec/schema/types/acidentifier.go | 145 - .../appc/spec/schema/types/ackind.go | 67 - .../appc/spec/schema/types/acname.go | 145 - .../appc/spec/schema/types/annotations.go | 106 - .../github.com/appc/spec/schema/types/app.go | 90 - .../github.com/appc/spec/schema/types/date.go | 60 - .../appc/spec/schema/types/dependencies.go | 58 - .../github.com/appc/spec/schema/types/doc.go | 18 - .../appc/spec/schema/types/environment.go | 110 - .../appc/spec/schema/types/errors.go | 49 - .../appc/spec/schema/types/event_handler.go | 61 - .../github.com/appc/spec/schema/types/exec.go | 46 - .../github.com/appc/spec/schema/types/hash.go | 118 - .../appc/spec/schema/types/isolator.go | 129 - .../schema/types/isolator_linux_specific.go | 163 - .../spec/schema/types/isolator_resources.go | 236 - .../appc/spec/schema/types/labels.go | 134 - .../appc/spec/schema/types/mountpoint.go | 91 - .../github.com/appc/spec/schema/types/port.go | 139 - .../appc/spec/schema/types/semver.go | 91 - .../github.com/appc/spec/schema/types/url.go | 71 - .../github.com/appc/spec/schema/types/uuid.go | 92 - .../appc/spec/schema/types/volume.go | 236 - .../github.com/appc/spec/schema/version.go | 39 - .../src/github.com/aws/aws-sdk-go/LICENSE.txt | 202 - .../src/github.com/aws/aws-sdk-go/NOTICE.txt | 3 - .../aws/aws-sdk-go/aws/awserr/error.go | 124 - .../aws/aws-sdk-go/aws/awserr/types.go | 197 - .../aws/aws-sdk-go/aws/awsutil/copy.go | 100 - .../aws/aws-sdk-go/aws/awsutil/equal.go | 27 - .../aws/aws-sdk-go/aws/awsutil/path_value.go | 222 - .../aws/aws-sdk-go/aws/awsutil/prettify.go | 103 - .../aws-sdk-go/aws/awsutil/string_value.go | 89 - .../aws/client/metadata/client_info.go | 12 - .../github.com/aws/aws-sdk-go/aws/config.go | 311 - .../aws/aws-sdk-go/aws/convert_types.go | 357 - .../aws/credentials/chain_provider.go | 100 - .../aws-sdk-go/aws/credentials/credentials.go | 223 - .../aws/credentials/env_provider.go | 77 - .../aws-sdk-go/aws/credentials/example.ini | 12 - .../shared_credentials_provider.go | 151 - .../aws/credentials/static_provider.go | 48 - .../github.com/aws/aws-sdk-go/aws/errors.go | 17 - .../github.com/aws/aws-sdk-go/aws/logger.go | 112 - .../aws/aws-sdk-go/aws/request/handlers.go | 187 - .../aws/aws-sdk-go/aws/request/request.go | 302 - .../aws/request/request_pagination.go | 104 - .../aws/aws-sdk-go/aws/request/retryer.go | 82 - .../github.com/aws/aws-sdk-go/aws/types.go | 88 - .../github.com/aws/aws-sdk-go/aws/version.go | 8 - .../aws-sdk-go/private/protocol/rest/build.go | 257 - .../private/protocol/rest/payload.go | 45 - .../private/protocol/rest/unmarshal.go | 193 - .../private/signer/v4/header_rules.go | 82 - .../aws/aws-sdk-go/private/signer/v4/v4.go | 438 - .../github.com/camlistore/camlistore/COPYING | 202 - .../clients/chrome/clip-it-good/LICENSE | 13 - .../camlistore/camlistore/misc/copyrightifity | 68 - .../camlistore/camlistore/pkg/legal/legal.go | 50 - .../pkg/legal/legalprint/legalprint.go | 42 - .../third_party/bazil.org/fuse/LICENSE | 93 - .../third_party/closure/lib/LICENSE | 176 - .../code.google.com/p/goauth2/LICENSE | 27 - .../code.google.com/p/goauth2/PATENTS | 22 - .../code.google.com/p/leveldb-go/LICENSE | 27 - .../code.google.com/p/snappy-go/LICENSE | 27 - .../code.google.com/p/xsrftoken/COPYING | 202 - .../third_party/fontawesome/LICENSE.txt | 4 - .../github.com/camlistore/lock/COPYING | 202 - .../github.com/cznic/exp/dbm/LICENSE | 27 - .../github.com/cznic/exp/lldb/LICENSE | 27 - .../github.com/cznic/fileutil/LICENSE | 27 - .../github.com/cznic/fileutil/falloc/LICENSE | 27 - .../github.com/cznic/fileutil/hdb/LICENSE | 27 - .../github.com/cznic/fileutil/storage/LICENSE | 27 - .../third_party/github.com/cznic/kv/LICENSE | 27 - .../github.com/cznic/mathutil/LICENSE | 27 - .../cznic/mathutil/mersenne/LICENSE | 27 - .../github.com/cznic/sortutil/LICENSE | 27 - .../github.com/cznic/zappy/LICENSE | 27 - .../github.com/davecgh/go-spew/LICENSE | 13 - .../github.com/go-sql-driver/mysql/LICENSE | 373 - .../github.com/golang/glog/LICENSE | 191 - .../github.com/gorilla/websocket/LICENSE | 23 - .../third_party/github.com/lib/pq/LICENSE.md | 8 - .../russross/blackfriday/LICENSE.txt | 29 - .../github.com/rwcarlsen/goexif/LICENSE | 24 - .../camlistore/third_party/glitch/LICENSE | 19 - .../third_party/golang.org/x/image/LICENSE | 27 - .../third_party/golang.org/x/image/PATENTS | 22 - .../third_party/labix.org/v2/mgo/LICENSE | 25 - .../third_party/labix.org/v2/mgo/bson/LICENSE | 25 - .../camlistore/third_party/react/LICENSE.txt | 201 - .../github.com/hjfreyer/taglib-go/LICENSE | 191 - .../vendor/golang.org/x/oauth2/LICENSE | 27 - .../googleapi/internal/uritemplates/LICENSE | 18 - .../vendor/google.golang.org/cloud/LICENSE | 202 - .../vendor/google.golang.org/grpc/LICENSE | 28 - .../vendor/google.golang.org/grpc/PATENTS | 22 - .../src/github.com/camlistore/go4/LICENSE | 202 - .../github.com/camlistore/go4/legal/legal.go | 32 - .../github.com/camlistore/go4/lock/.gitignore | 1 - .../github.com/camlistore/go4/lock/lock.go | 186 - .../camlistore/go4/lock/lock_appengine.go | 32 - .../camlistore/go4/lock/lock_darwin_amd64.go | 67 - .../camlistore/go4/lock/lock_freebsd.go | 66 - .../camlistore/go4/lock/lock_linux_amd64.go | 67 - .../camlistore/go4/lock/lock_linux_arm.go | 68 - .../camlistore/go4/lock/lock_plan9.go | 41 - .../camlistore/go4/lock/lock_sigzero.go | 26 - .../containernetworking/cni/LICENSE | 202 - .../cni/pkg/invoke/args.go | 76 - .../cni/pkg/invoke/delegate.go | 53 - .../cni/pkg/invoke/exec.go | 75 - .../cni/pkg/invoke/find.go | 47 - .../containernetworking/cni/pkg/ip/cidr.go | 51 - .../cni/pkg/ip/ipforward.go | 31 - .../containernetworking/cni/pkg/ip/ipmasq.go | 66 - .../containernetworking/cni/pkg/ip/link.go | 153 - .../containernetworking/cni/pkg/ip/route.go | 47 - .../containernetworking/cni/pkg/ipam/ipam.go | 68 - .../containernetworking/cni/pkg/ns/README.md | 31 - .../containernetworking/cni/pkg/ns/ns.go | 315 - .../containernetworking/cni/pkg/skel/skel.go | 161 - .../cni/pkg/testutils/cmd.go | 77 - .../containernetworking/cni/pkg/types/args.go | 91 - .../cni/pkg/types/types.go | 191 - .../cni/pkg/utils/sysctl/sysctl_linux.go | 58 - .../cni/pkg/utils/utils.go | 41 - .../cni/plugins/ipam/dhcp/daemon.go | 157 - .../cni/plugins/ipam/dhcp/lease.go | 337 - .../cni/plugins/ipam/dhcp/main.go | 73 - .../cni/plugins/ipam/dhcp/options.go | 139 - .../cni/plugins/ipam/host-local/README.md | 86 - .../cni/plugins/ipam/host-local/allocator.go | 165 - .../ipam/host-local/backend/disk/backend.go | 88 - .../ipam/host-local/backend/disk/lock.go | 50 - .../plugins/ipam/host-local/backend/store.go | 26 - .../cni/plugins/ipam/host-local/config.go | 70 - .../cni/plugins/ipam/host-local/main.go | 74 - .../cni/plugins/main/bridge/bridge.go | 319 - .../cni/plugins/main/ipvlan/ipvlan.go | 175 - .../cni/plugins/main/macvlan/macvlan.go | 193 - .../cni/plugins/main/ptp/ptp.go | 229 - .../cni/plugins/meta/flannel/flannel.go | 253 - .../cni/plugins/meta/tuning/tuning.go | 82 - .../src/github.com/coreos/gexpect/LICENCE | 7 - .../src/github.com/coreos/gexpect/README.md | 64 - .../src/github.com/coreos/gexpect/gexpect.go | 449 - .../src/github.com/coreos/go-iptables/LICENSE | 191 - .../coreos/go-iptables/iptables/iptables.go | 295 - .../coreos/go-iptables/iptables/lock.go | 84 - .../src/github.com/coreos/go-semver/LICENSE | 202 - .../coreos/go-semver/semver/semver.go | 202 - .../coreos/go-semver/semver/sort.go | 24 - .../src/github.com/coreos/go-systemd/LICENSE | 191 - .../coreos/go-systemd/activation/files.go | 52 - .../coreos/go-systemd/activation/listeners.go | 62 - .../go-systemd/activation/packetconns.go | 37 - .../github.com/coreos/go-systemd/dbus/dbus.go | 203 - .../coreos/go-systemd/dbus/methods.go | 484 - .../coreos/go-systemd/dbus/properties.go | 218 - .../github.com/coreos/go-systemd/dbus/set.go | 47 - .../coreos/go-systemd/dbus/subscription.go | 250 - .../go-systemd/dbus/subscription_set.go | 57 - .../coreos/go-systemd/sdjournal/journal.go | 971 - .../coreos/go-systemd/sdjournal/read.go | 252 - .../coreos/go-systemd/unit/deserialize.go | 276 - .../coreos/go-systemd/unit/escape.go | 116 - .../coreos/go-systemd/unit/option.go | 54 - .../coreos/go-systemd/unit/serialize.go | 75 - .../github.com/coreos/go-systemd/util/util.go | 227 - .../src/github.com/coreos/go-tspi/LICENSE | 202 - .../coreos/go-tspi/tpmclient/tpmclient.go | 310 - .../coreos/go-tspi/tspiconst/tspiconst.go | 538 - .../go-tspi/verification/verification.go | 654 - .../src/github.com/coreos/ioprogress/LICENSE | 21 - .../github.com/coreos/ioprogress/README.md | 42 - .../src/github.com/coreos/ioprogress/draw.go | 132 - .../github.com/coreos/ioprogress/reader.go | 107 - .../src/github.com/coreos/pkg/LICENSE | 202 - .../src/github.com/coreos/pkg/NOTICE | 5 - .../github.com/coreos/pkg/dlopen/dlopen.go | 82 - .../coreos/pkg/dlopen/dlopen_example.go | 56 - .../coreos/pkg/progressutil/iocopy.go | 189 - .../coreos/pkg/progressutil/progressbar.go | 256 - .../github.com/cpuguy83/go-md2man/LICENSE.md | 21 - .../cpuguy83/go-md2man/md2man/md2man.go | 19 - .../cpuguy83/go-md2man/md2man/roff.go | 269 - .../_workspace/src/github.com/cznic/b/AUTHORS | 11 - .../src/github.com/cznic/b/CONTRIBUTORS | 11 - .../_workspace/src/github.com/cznic/b/LICENSE | 27 - .../src/github.com/cznic/b/Makefile | 53 - .../src/github.com/cznic/b/README.md | 10 - .../src/github.com/cznic/b/btree.go | 929 - .../_workspace/src/github.com/cznic/b/doc.go | 53 - .../src/github.com/cznic/b/example/Makefile | 35 - .../src/github.com/cznic/b/example/int.go | 929 - .../src/github.com/cznic/bufs/AUTHORS | 11 - .../src/github.com/cznic/bufs/CONTRIBUTORS | 9 - .../src/github.com/cznic/bufs/LICENSE | 27 - .../src/github.com/cznic/bufs/Makefile | 31 - .../src/github.com/cznic/bufs/README.md | 8 - .../src/github.com/cznic/bufs/bufs.go | 391 - .../src/github.com/cznic/exp/dbm/LICENSE | 27 - .../src/github.com/cznic/exp/lldb/2pc.go | 324 - .../src/github.com/cznic/exp/lldb/2pc_docs.go | 44 - .../src/github.com/cznic/exp/lldb/AUTHORS | 11 - .../github.com/cznic/exp/lldb/CONTRIBUTORS | 9 - .../src/github.com/cznic/exp/lldb/LICENSE | 27 - .../src/github.com/cznic/exp/lldb/Makefile | 45 - .../src/github.com/cznic/exp/lldb/README.md | 8 - .../src/github.com/cznic/exp/lldb/btree.go | 2297 --- .../src/github.com/cznic/exp/lldb/errors.go | 170 - .../src/github.com/cznic/exp/lldb/falloc.go | 1981 -- .../src/github.com/cznic/exp/lldb/filer.go | 192 - .../src/github.com/cznic/exp/lldb/gb.go | 812 - .../src/github.com/cznic/exp/lldb/lldb.go | 155 - .../src/github.com/cznic/exp/lldb/memfiler.go | 344 - .../src/github.com/cznic/exp/lldb/osfiler.go | 130 - .../cznic/exp/lldb/simplefilefiler.go | 123 - .../src/github.com/cznic/exp/lldb/xact.go | 629 - .../src/github.com/cznic/fileutil/AUTHORS | 14 - .../github.com/cznic/fileutil/CONTRIBUTORS | 14 - .../src/github.com/cznic/fileutil/LICENSE | 27 - .../src/github.com/cznic/fileutil/Makefile | 27 - .../src/github.com/cznic/fileutil/README | 16 - .../github.com/cznic/fileutil/falloc/LICENSE | 27 - .../github.com/cznic/fileutil/falloc/README | 5 - .../github.com/cznic/fileutil/falloc/docs.go | 251 - .../github.com/cznic/fileutil/falloc/error.go | 130 - .../cznic/fileutil/falloc/falloc.go | 676 - .../cznic/fileutil/falloc/test_deps.go | 15 - .../src/github.com/cznic/fileutil/fileutil.go | 223 - .../github.com/cznic/fileutil/fileutil_arm.go | 25 - .../cznic/fileutil/fileutil_darwin.go | 25 - .../cznic/fileutil/fileutil_freebsd.go | 25 - .../cznic/fileutil/fileutil_linux.go | 96 - .../cznic/fileutil/fileutil_openbsd.go | 25 - .../cznic/fileutil/fileutil_plan9.go | 25 - .../cznic/fileutil/fileutil_solaris.go | 27 - .../cznic/fileutil/fileutil_windows.go | 183 - .../src/github.com/cznic/fileutil/hdb/LICENSE | 27 - .../src/github.com/cznic/fileutil/hdb/README | 5 - .../src/github.com/cznic/fileutil/hdb/hdb.go | 153 - .../cznic/fileutil/hdb/test_deps.go | 13 - .../github.com/cznic/fileutil/storage/LICENSE | 27 - .../github.com/cznic/fileutil/storage/README | 5 - .../cznic/fileutil/storage/cache.go | 322 - .../github.com/cznic/fileutil/storage/file.go | 50 - .../github.com/cznic/fileutil/storage/mem.go | 161 - .../cznic/fileutil/storage/probe.go | 74 - .../cznic/fileutil/storage/storage.go | 141 - .../cznic/fileutil/storage/test_deps.go | 13 - .../github.com/cznic/fileutil/test_deps.go | 13 - .../src/github.com/cznic/mathutil/AUTHORS | 12 - .../github.com/cznic/mathutil/CONTRIBUTORS | 10 - .../src/github.com/cznic/mathutil/LICENSE | 27 - .../src/github.com/cznic/mathutil/Makefile | 31 - .../src/github.com/cznic/mathutil/README | 10 - .../src/github.com/cznic/mathutil/bits.go | 207 - .../src/github.com/cznic/mathutil/envelope.go | 46 - .../cznic/mathutil/example/.gitignore | 2 - .../cznic/mathutil/example/example.go | 48 - .../cznic/mathutil/example2/.gitignore | 2 - .../cznic/mathutil/example2/example2.go | 66 - .../cznic/mathutil/example3/.gitignore | 2 - .../cznic/mathutil/example3/example3.go | 43 - .../cznic/mathutil/example4/main.go | 90 - .../cznic/mathutil/example4/results | 55 - .../src/github.com/cznic/mathutil/ff/main.go | 83 - .../src/github.com/cznic/mathutil/mathutil.go | 829 - .../cznic/mathutil/mersenne/AUTHORS | 11 - .../cznic/mathutil/mersenne/CONTRIBUTORS | 9 - .../cznic/mathutil/mersenne/LICENSE | 27 - .../cznic/mathutil/mersenne/Makefile | 24 - .../github.com/cznic/mathutil/mersenne/README | 2 - .../cznic/mathutil/mersenne/mersenne.go | 296 - .../cznic/mathutil/nist-sts-2-1-1-report | 267 - .../src/github.com/cznic/mathutil/permute.go | 39 - .../src/github.com/cznic/mathutil/primes.go | 342 - .../src/github.com/cznic/mathutil/rat.go | 27 - .../src/github.com/cznic/mathutil/rnd.go | 383 - .../src/github.com/cznic/mathutil/tables.go | 6995 ------- .../github.com/cznic/mathutil/test_deps.go | 11 - .../src/github.com/cznic/ql/AUTHORS | 11 - .../src/github.com/cznic/ql/CONTRIBUTORS | 12 - .../src/github.com/cznic/ql/LICENSE | 27 - .../src/github.com/cznic/ql/Makefile | 74 - .../src/github.com/cznic/ql/README.md | 21 - .../src/github.com/cznic/ql/benchcmp | 1 - .../src/github.com/cznic/ql/blob.go | 155 - .../src/github.com/cznic/ql/btree.go | 725 - .../src/github.com/cznic/ql/builtin.go | 991 - .../src/github.com/cznic/ql/coerce.go | 290 - .../src/github.com/cznic/ql/design/doc.go | 298 - .../_workspace/src/github.com/cznic/ql/doc.go | 2606 --- .../src/github.com/cznic/ql/driver.go | 523 - .../src/github.com/cznic/ql/driver/Makefile | 40 - .../src/github.com/cznic/ql/driver/driver.go | 61 - .../src/github.com/cznic/ql/errors.go | 18 - .../_workspace/src/github.com/cznic/ql/etc.go | 2805 --- .../src/github.com/cznic/ql/expr.go | 4023 ---- .../src/github.com/cznic/ql/file.go | 1279 -- .../src/github.com/cznic/ql/helper/helper.go | 338 - .../src/github.com/cznic/ql/httpfs.go | 302 - .../src/github.com/cznic/ql/introspection.go | 625 - .../_workspace/src/github.com/cznic/ql/mem.go | 1277 -- .../src/github.com/cznic/ql/parser.go | 2637 --- .../src/github.com/cznic/ql/parser.y | 1337 -- .../src/github.com/cznic/ql/plan.go | 2800 --- .../src/github.com/cznic/ql/ql.ebnf | 225 - .../_workspace/src/github.com/cznic/ql/ql.go | 1729 -- .../_workspace/src/github.com/cznic/ql/ql.y | 1687 -- .../src/github.com/cznic/ql/ql/Makefile | 24 - .../src/github.com/cznic/ql/ql/README.md | 10 - .../src/github.com/cznic/ql/ql/main.go | 219 - .../src/github.com/cznic/ql/scanner.go | 4129 ---- .../src/github.com/cznic/ql/scanner.l | 462 - .../src/github.com/cznic/ql/stmt.go | 1268 -- .../src/github.com/cznic/ql/storage.go | 991 - .../src/github.com/cznic/ql/testdata.log | 8382 --------- .../src/github.com/cznic/ql/testdata.ql | 15633 ---------------- .../src/github.com/cznic/sortutil/AUTHORS | 11 - .../github.com/cznic/sortutil/CONTRIBUTORS | 10 - .../src/github.com/cznic/sortutil/LICENSE | 27 - .../src/github.com/cznic/sortutil/Makefile | 35 - .../src/github.com/cznic/sortutil/README | 4 - .../src/github.com/cznic/sortutil/sortutil.go | 227 - .../src/github.com/cznic/strutil/AUTHORS | 12 - .../src/github.com/cznic/strutil/CONTRIBUTORS | 9 - .../src/github.com/cznic/strutil/LICENSE | 27 - .../src/github.com/cznic/strutil/Makefile | 37 - .../src/github.com/cznic/strutil/README | 8 - .../src/github.com/cznic/strutil/strutil.go | 428 - .../src/github.com/cznic/zappy/AUTHORS | 12 - .../src/github.com/cznic/zappy/CONTRIBUTORS | 10 - .../src/github.com/cznic/zappy/LICENSE | 27 - .../src/github.com/cznic/zappy/Makefile | 30 - .../src/github.com/cznic/zappy/README.md | 9 - .../github.com/cznic/zappy/SNAPPY-GO-LICENSE | 27 - .../src/github.com/cznic/zappy/decode.go | 38 - .../src/github.com/cznic/zappy/decode_cgo.go | 121 - .../github.com/cznic/zappy/decode_nocgo.go | 89 - .../src/github.com/cznic/zappy/encode.go | 37 - .../src/github.com/cznic/zappy/encode_cgo.go | 140 - .../github.com/cznic/zappy/encode_nocgo.go | 92 - .../src/github.com/cznic/zappy/purego.sh | 11 - .../src/github.com/cznic/zappy/zappy.go | 241 - .../src/github.com/d2g/dhcp4/LICENSE | 27 - .../src/github.com/d2g/dhcp4/README.md | 5 - .../src/github.com/d2g/dhcp4/constants.go | 121 - .../src/github.com/d2g/dhcp4/helpers.go | 58 - .../src/github.com/d2g/dhcp4/option.go | 40 - .../src/github.com/d2g/dhcp4/packet.go | 149 - .../src/github.com/d2g/dhcp4client/LICENSE | 354 - .../src/github.com/d2g/dhcp4client/README.md | 8 - .../src/github.com/d2g/dhcp4client/client.go | 366 - .../github.com/d2g/dhcp4client/inetsock.go | 75 - .../src/github.com/d2g/dhcp4client/init.go | 10 - .../d2g/dhcp4client/pktsock_linux.go | 147 - .../github.com/docker/distribution/LICENSE | 202 - .../docker/distribution/digest/digest.go | 139 - .../docker/distribution/digest/digester.go | 155 - .../docker/distribution/digest/doc.go | 42 - .../docker/distribution/digest/set.go | 245 - .../docker/distribution/digest/verifiers.go | 44 - .../distribution/reference/reference.go | 334 - .../docker/distribution/reference/regexp.go | 124 - .../github.com/dustin/go-humanize/.gitignore | 6 - .../src/github.com/dustin/go-humanize/LICENSE | 21 - .../dustin/go-humanize/README.markdown | 81 - .../src/github.com/dustin/go-humanize/big.go | 31 - .../github.com/dustin/go-humanize/bigbytes.go | 164 - .../github.com/dustin/go-humanize/bytes.go | 134 - .../github.com/dustin/go-humanize/comma.go | 101 - .../src/github.com/dustin/go-humanize/ftoa.go | 23 - .../github.com/dustin/go-humanize/humanize.go | 8 - .../github.com/dustin/go-humanize/number.go | 192 - .../github.com/dustin/go-humanize/ordinals.go | 25 - .../src/github.com/dustin/go-humanize/si.go | 110 - .../github.com/dustin/go-humanize/times.go | 91 - .../src/github.com/go-ini/ini/.gitignore | 4 - .../src/github.com/go-ini/ini/LICENSE | 191 - .../src/github.com/go-ini/ini/Makefile | 12 - .../src/github.com/go-ini/ini/README.md | 632 - .../src/github.com/go-ini/ini/README_ZH.md | 619 - .../src/github.com/go-ini/ini/ini.go | 465 - .../src/github.com/go-ini/ini/key.go | 616 - .../src/github.com/go-ini/ini/parser.go | 312 - .../src/github.com/go-ini/ini/section.go | 177 - .../src/github.com/go-ini/ini/struct.go | 351 - .../src/github.com/go-ole/go-ole/.travis.yml | 9 - .../src/github.com/go-ole/go-ole/ChangeLog.md | 49 - .../src/github.com/go-ole/go-ole/README.md | 46 - .../src/github.com/go-ole/go-ole/appveyor.yml | 63 - .../src/github.com/go-ole/go-ole/com.go | 329 - .../src/github.com/go-ole/go-ole/com_func.go | 174 - .../src/github.com/go-ole/go-ole/connect.go | 192 - .../src/github.com/go-ole/go-ole/constants.go | 153 - .../src/github.com/go-ole/go-ole/error.go | 51 - .../github.com/go-ole/go-ole/error_func.go | 8 - .../github.com/go-ole/go-ole/error_windows.go | 24 - .../src/github.com/go-ole/go-ole/guid.go | 118 - .../go-ole/go-ole/iconnectionpoint.go | 20 - .../go-ole/go-ole/iconnectionpoint_func.go | 21 - .../go-ole/go-ole/iconnectionpoint_windows.go | 43 - .../go-ole/iconnectionpointcontainer.go | 17 - .../go-ole/iconnectionpointcontainer_func.go | 11 - .../iconnectionpointcontainer_windows.go | 25 - .../src/github.com/go-ole/go-ole/idispatch.go | 94 - .../go-ole/go-ole/idispatch_func.go | 19 - .../go-ole/go-ole/idispatch_windows.go | 193 - .../github.com/go-ole/go-ole/ienumvariant.go | 19 - .../go-ole/go-ole/ienumvariant_func.go | 19 - .../go-ole/go-ole/ienumvariant_windows.go | 63 - .../github.com/go-ole/go-ole/iinspectable.go | 18 - .../go-ole/go-ole/iinspectable_func.go | 15 - .../go-ole/go-ole/iinspectable_windows.go | 72 - .../go-ole/go-ole/iprovideclassinfo.go | 21 - .../go-ole/go-ole/iprovideclassinfo_func.go | 7 - .../go-ole/iprovideclassinfo_windows.go | 21 - .../src/github.com/go-ole/go-ole/itypeinfo.go | 34 - .../go-ole/go-ole/itypeinfo_func.go | 7 - .../go-ole/go-ole/itypeinfo_windows.go | 21 - .../src/github.com/go-ole/go-ole/iunknown.go | 57 - .../github.com/go-ole/go-ole/iunknown_func.go | 19 - .../go-ole/go-ole/iunknown_windows.go | 58 - .../src/github.com/go-ole/go-ole/ole.go | 147 - .../go-ole/go-ole/oleutil/connection.go | 100 - .../go-ole/go-ole/oleutil/connection_func.go | 10 - .../go-ole/oleutil/connection_windows.go | 57 - .../go-ole/go-ole/oleutil/go-get.go | 6 - .../go-ole/go-ole/oleutil/oleutil.go | 89 - .../src/github.com/go-ole/go-ole/safearray.go | 27 - .../go-ole/go-ole/safearray_func.go | 211 - .../go-ole/go-ole/safearray_windows.go | 337 - .../go-ole/go-ole/safearrayconversion.go | 140 - .../go-ole/go-ole/safearrayslices.go | 33 - .../src/github.com/go-ole/go-ole/utility.go | 101 - .../src/github.com/go-ole/go-ole/variables.go | 16 - .../src/github.com/go-ole/go-ole/variant.go | 105 - .../github.com/go-ole/go-ole/variant_386.go | 11 - .../github.com/go-ole/go-ole/variant_amd64.go | 12 - .../src/github.com/go-ole/go-ole/vt_string.go | 58 - .../src/github.com/go-ole/go-ole/winrt.go | 99 - .../src/github.com/go-ole/go-ole/winrt_doc.go | 36 - .../github.com/godbus/dbus/CONTRIBUTING.md | 50 - .../src/github.com/godbus/dbus/LICENSE | 25 - .../src/github.com/godbus/dbus/MAINTAINERS | 2 - .../github.com/godbus/dbus/README.markdown | 41 - .../src/github.com/godbus/dbus/auth.go | 253 - .../github.com/godbus/dbus/auth_external.go | 26 - .../src/github.com/godbus/dbus/auth_sha1.go | 102 - .../src/github.com/godbus/dbus/call.go | 36 - .../src/github.com/godbus/dbus/conn.go | 625 - .../src/github.com/godbus/dbus/conn_darwin.go | 21 - .../src/github.com/godbus/dbus/conn_other.go | 27 - .../src/github.com/godbus/dbus/dbus.go | 258 - .../src/github.com/godbus/dbus/decoder.go | 228 - .../src/github.com/godbus/dbus/doc.go | 63 - .../src/github.com/godbus/dbus/encoder.go | 208 - .../src/github.com/godbus/dbus/export.go | 411 - .../src/github.com/godbus/dbus/homedir.go | 28 - .../github.com/godbus/dbus/homedir_dynamic.go | 15 - .../github.com/godbus/dbus/homedir_static.go | 45 - .../github.com/godbus/dbus/introspect/call.go | 27 - .../godbus/dbus/introspect/introspect.go | 86 - .../godbus/dbus/introspect/introspectable.go | 76 - .../src/github.com/godbus/dbus/message.go | 346 - .../src/github.com/godbus/dbus/object.go | 136 - .../src/github.com/godbus/dbus/prop/prop.go | 264 - .../src/github.com/godbus/dbus/sig.go | 257 - .../godbus/dbus/transport_darwin.go | 6 - .../godbus/dbus/transport_generic.go | 35 - .../github.com/godbus/dbus/transport_unix.go | 196 - .../dbus/transport_unixcred_dragonfly.go | 95 - .../godbus/dbus/transport_unixcred_linux.go | 25 - .../src/github.com/godbus/dbus/variant.go | 139 - .../github.com/godbus/dbus/variant_lexer.go | 284 - .../github.com/godbus/dbus/variant_parser.go | 817 - .../src/github.com/gogo/protobuf/LICENSE | 36 - .../github.com/gogo/protobuf/proto/Makefile | 43 - .../github.com/gogo/protobuf/proto/clone.go | 228 - .../github.com/gogo/protobuf/proto/decode.go | 872 - .../gogo/protobuf/proto/decode_gogo.go | 175 - .../github.com/gogo/protobuf/proto/encode.go | 1325 -- .../gogo/protobuf/proto/encode_gogo.go | 354 - .../github.com/gogo/protobuf/proto/equal.go | 276 - .../gogo/protobuf/proto/extensions.go | 518 - .../gogo/protobuf/proto/extensions_gogo.go | 221 - .../src/github.com/gogo/protobuf/proto/lib.go | 894 - .../gogo/protobuf/proto/lib_gogo.go | 40 - .../gogo/protobuf/proto/message_set.go | 280 - .../gogo/protobuf/proto/pointer_reflect.go | 479 - .../gogo/protobuf/proto/pointer_unsafe.go | 266 - .../protobuf/proto/pointer_unsafe_gogo.go | 108 - .../gogo/protobuf/proto/properties.go | 923 - .../gogo/protobuf/proto/properties_gogo.go | 64 - .../gogo/protobuf/proto/skip_gogo.go | 117 - .../github.com/gogo/protobuf/proto/text.go | 793 - .../gogo/protobuf/proto/text_gogo.go | 55 - .../gogo/protobuf/proto/text_parser.go | 849 - .../src/github.com/golang/protobuf/LICENSE | 31 - .../github.com/golang/protobuf/proto/Makefile | 43 - .../github.com/golang/protobuf/proto/clone.go | 223 - .../golang/protobuf/proto/decode.go | 867 - .../golang/protobuf/proto/encode.go | 1325 -- .../github.com/golang/protobuf/proto/equal.go | 276 - .../golang/protobuf/proto/extensions.go | 399 - .../github.com/golang/protobuf/proto/lib.go | 893 - .../golang/protobuf/proto/message_set.go | 280 - .../golang/protobuf/proto/pointer_reflect.go | 479 - .../golang/protobuf/proto/pointer_unsafe.go | 266 - .../golang/protobuf/proto/properties.go | 842 - .../protobuf/proto/proto3_proto/proto3.pb.go | 122 - .../protobuf/proto/proto3_proto/proto3.proto | 68 - .../github.com/golang/protobuf/proto/text.go | 751 - .../golang/protobuf/proto/text_parser.go | 798 - .../golang/protobuf/protoc-gen-go/Makefile | 33 - .../protoc-gen-go/descriptor/Makefile | 39 - .../protoc-gen-go/descriptor/descriptor.pb.go | 1812 -- .../golang/protobuf/protoc-gen-go/doc.go | 51 - .../protobuf/protoc-gen-go/generator/Makefile | 40 - .../protoc-gen-go/generator/generator.go | 2715 --- .../protoc-gen-go/internal/grpc/grpc.go | 442 - .../protobuf/protoc-gen-go/link_grpc.go | 34 - .../golang/protobuf/protoc-gen-go/main.go | 98 - .../protobuf/protoc-gen-go/plugin/Makefile | 45 - .../protoc-gen-go/plugin/plugin.pb.go | 222 - .../protoc-gen-go/plugin/plugin.pb.golden | 83 - .../src/github.com/google/btree/.travis.yml | 1 - .../src/github.com/google/btree/LICENSE | 202 - .../src/github.com/google/btree/README.md | 12 - .../src/github.com/google/btree/btree.go | 571 - .../src/github.com/google/btree/btree_mem.go | 76 - .../src/github.com/gopherjs/gopherjs/LICENSE | 24 - .../github.com/gorilla/context/.travis.yml | 7 - .../src/github.com/gorilla/context/LICENSE | 27 - .../src/github.com/gorilla/context/README.md | 7 - .../src/github.com/gorilla/context/context.go | 143 - .../src/github.com/gorilla/context/doc.go | 82 - .../src/github.com/gorilla/mux/.travis.yml | 7 - .../src/github.com/gorilla/mux/LICENSE | 27 - .../src/github.com/gorilla/mux/README.md | 7 - .../src/github.com/gorilla/mux/doc.go | 199 - .../src/github.com/gorilla/mux/mux.go | 353 - .../src/github.com/gorilla/mux/regexp.go | 276 - .../src/github.com/gorilla/mux/route.go | 524 - .../src/github.com/hashicorp/errwrap/LICENSE | 354 - .../github.com/hashicorp/errwrap/README.md | 89 - .../github.com/hashicorp/errwrap/errwrap.go | 169 - .../hydrogen18/stoppableListener/LICENSE | 10 - .../hydrogen18/stoppableListener/README.md | 18 - .../stoppableListener/example/example.go | 52 - .../hydrogen18/stoppableListener/listener.go | 62 - .../inconshreveable/mousetrap/LICENSE | 13 - .../inconshreveable/mousetrap/README.md | 23 - .../inconshreveable/mousetrap/trap_others.go | 15 - .../inconshreveable/mousetrap/trap_windows.go | 98 - .../mousetrap/trap_windows_1.4.go | 46 - .../jmespath/go-jmespath/.gitignore | 4 - .../jmespath/go-jmespath/.travis.yml | 9 - .../github.com/jmespath/go-jmespath/LICENSE | 13 - .../github.com/jmespath/go-jmespath/Makefile | 44 - .../github.com/jmespath/go-jmespath/README.md | 7 - .../github.com/jmespath/go-jmespath/api.go | 49 - .../go-jmespath/astnodetype_string.go | 16 - .../jmespath/go-jmespath/functions.go | 842 - .../jmespath/go-jmespath/interpreter.go | 418 - .../github.com/jmespath/go-jmespath/lexer.go | 420 - .../github.com/jmespath/go-jmespath/parser.go | 603 - .../jmespath/go-jmespath/toktype_string.go | 16 - .../github.com/jmespath/go-jmespath/util.go | 185 - .../github.com/kballard/go-shellquote/LICENSE | 19 - .../github.com/kballard/go-shellquote/README | 36 - .../github.com/kballard/go-shellquote/doc.go | 3 - .../kballard/go-shellquote/quote.go | 102 - .../kballard/go-shellquote/unquote.go | 144 - .../src/github.com/klauspost/compress/LICENSE | 27 - .../klauspost/compress/flate/copy.go | 32 - .../klauspost/compress/flate/crc32_amd64.go | 39 - .../klauspost/compress/flate/crc32_amd64.s | 218 - .../klauspost/compress/flate/crc32_noasm.go | 34 - .../klauspost/compress/flate/deflate.go | 1358 -- .../klauspost/compress/flate/fixedhuff.go | 78 - .../klauspost/compress/flate/gen.go | 265 - .../compress/flate/huffman_bit_writer.go | 717 - .../klauspost/compress/flate/huffman_code.go | 363 - .../klauspost/compress/flate/inflate.go | 846 - .../klauspost/compress/flate/reverse_bits.go | 48 - .../klauspost/compress/flate/snappy.go | 768 - .../klauspost/compress/flate/token.go | 105 - .../src/github.com/klauspost/cpuid/.gitignore | 24 - .../github.com/klauspost/cpuid/.travis.yml | 8 - .../src/github.com/klauspost/cpuid/LICENSE | 22 - .../src/github.com/klauspost/cpuid/README.md | 145 - .../src/github.com/klauspost/cpuid/cpuid.go | 1022 - .../github.com/klauspost/cpuid/cpuid_386.s | 42 - .../github.com/klauspost/cpuid/cpuid_amd64.s | 42 - .../klauspost/cpuid/detect_intel.go | 17 - .../github.com/klauspost/cpuid/detect_ref.go | 23 - .../github.com/klauspost/cpuid/generate.go | 3 - .../github.com/klauspost/cpuid/private-gen.go | 476 - .../src/github.com/klauspost/crc32/.gitignore | 24 - .../github.com/klauspost/crc32/.travis.yml | 12 - .../src/github.com/klauspost/crc32/LICENSE | 28 - .../src/github.com/klauspost/crc32/README.md | 84 - .../src/github.com/klauspost/crc32/crc32.go | 186 - .../github.com/klauspost/crc32/crc32_amd64.go | 62 - .../github.com/klauspost/crc32/crc32_amd64.s | 237 - .../klauspost/crc32/crc32_amd64p32.go | 40 - .../klauspost/crc32/crc32_amd64p32.s | 67 - .../klauspost/crc32/crc32_generic.go | 29 - .../src/github.com/klauspost/pgzip/.gitignore | 24 - .../github.com/klauspost/pgzip/.travis.yml | 18 - .../src/github.com/klauspost/pgzip/GO_LICENSE | 27 - .../src/github.com/klauspost/pgzip/LICENSE | 22 - .../src/github.com/klauspost/pgzip/README.md | 115 - .../src/github.com/klauspost/pgzip/circle.yml | 7 - .../src/github.com/klauspost/pgzip/gunzip.go | 564 - .../src/github.com/klauspost/pgzip/gzip.go | 485 - .../src/github.com/kr/pty/.gitignore | 4 - .../_workspace/src/github.com/kr/pty/License | 23 - .../src/github.com/kr/pty/README.md | 36 - .../_workspace/src/github.com/kr/pty/doc.go | 16 - .../_workspace/src/github.com/kr/pty/ioctl.go | 11 - .../src/github.com/kr/pty/ioctl_bsd.go | 39 - .../src/github.com/kr/pty/mktypes.bash | 19 - .../src/github.com/kr/pty/pty_darwin.go | 60 - .../src/github.com/kr/pty/pty_freebsd.go | 73 - .../src/github.com/kr/pty/pty_linux.go | 46 - .../src/github.com/kr/pty/pty_unsupported.go | 11 - .../_workspace/src/github.com/kr/pty/run.go | 32 - .../_workspace/src/github.com/kr/pty/types.go | 10 - .../src/github.com/kr/pty/types_freebsd.go | 15 - .../_workspace/src/github.com/kr/pty/util.go | 35 - .../src/github.com/kr/pty/ztypes_386.go | 9 - .../src/github.com/kr/pty/ztypes_amd64.go | 9 - .../src/github.com/kr/pty/ztypes_arm.go | 9 - .../src/github.com/kr/pty/ztypes_arm64.go | 11 - .../github.com/kr/pty/ztypes_freebsd_386.go | 13 - .../github.com/kr/pty/ztypes_freebsd_amd64.go | 14 - .../github.com/kr/pty/ztypes_freebsd_arm.go | 13 - .../src/github.com/kr/pty/ztypes_ppc64.go | 11 - .../src/github.com/kr/pty/ztypes_ppc64le.go | 11 - .../src/github.com/kr/pty/ztypes_s390x.go | 11 - .../src/github.com/pborman/uuid/CONTRIBUTORS | 1 - .../src/github.com/pborman/uuid/LICENSE | 27 - .../src/github.com/pborman/uuid/dce.go | 84 - .../src/github.com/pborman/uuid/doc.go | 8 - .../src/github.com/pborman/uuid/hash.go | 53 - .../src/github.com/pborman/uuid/json.go | 30 - .../src/github.com/pborman/uuid/node.go | 101 - .../src/github.com/pborman/uuid/sql.go | 40 - .../src/github.com/pborman/uuid/time.go | 132 - .../src/github.com/pborman/uuid/util.go | 43 - .../src/github.com/pborman/uuid/uuid.go | 163 - .../src/github.com/pborman/uuid/version1.go | 41 - .../src/github.com/pborman/uuid/version4.go | 25 - .../src/github.com/petar/GoLLRB/LICENSE | 27 - .../src/github.com/peterbourgon/diskv/LICENSE | 19 - .../github.com/peterbourgon/diskv/README.md | 141 - .../peterbourgon/diskv/compression.go | 64 - .../github.com/peterbourgon/diskv/diskv.go | 578 - .../github.com/peterbourgon/diskv/index.go | 115 - .../russross/blackfriday/.gitignore | 8 - .../russross/blackfriday/.travis.yml | 18 - .../russross/blackfriday/LICENSE.txt | 29 - .../github.com/russross/blackfriday/README.md | 267 - .../github.com/russross/blackfriday/block.go | 1398 -- .../github.com/russross/blackfriday/html.go | 949 - .../github.com/russross/blackfriday/inline.go | 1133 -- .../github.com/russross/blackfriday/latex.go | 332 - .../russross/blackfriday/markdown.go | 926 - .../russross/blackfriday/smartypants.go | 400 - .../src/github.com/shirou/gopsutil/LICENSE | 27 - .../src/github.com/shirou/gopsutil/cpu/cpu.go | 76 - .../shirou/gopsutil/cpu/cpu_darwin.go | 106 - .../shirou/gopsutil/cpu/cpu_darwin_cgo.go | 107 - .../shirou/gopsutil/cpu/cpu_darwin_nocgo.go | 14 - .../shirou/gopsutil/cpu/cpu_freebsd.go | 147 - .../shirou/gopsutil/cpu/cpu_linux.go | 244 - .../shirou/gopsutil/cpu/cpu_unix.go | 59 - .../shirou/gopsutil/cpu/cpu_windows.go | 105 - .../github.com/shirou/gopsutil/host/host.go | 38 - .../shirou/gopsutil/host/host_darwin.go | 152 - .../shirou/gopsutil/host/host_darwin_amd64.go | 19 - .../shirou/gopsutil/host/host_freebsd.go | 196 - .../gopsutil/host/host_freebsd_amd64.go | 41 - .../shirou/gopsutil/host/host_linux.go | 431 - .../shirou/gopsutil/host/host_linux_386.go | 44 - .../shirou/gopsutil/host/host_linux_amd64.go | 42 - .../shirou/gopsutil/host/host_linux_arm.go | 42 - .../shirou/gopsutil/host/host_windows.go | 135 - .../shirou/gopsutil/host/types_darwin.go | 17 - .../shirou/gopsutil/host/types_freebsd.go | 43 - .../shirou/gopsutil/host/types_linux.go | 45 - .../shirou/gopsutil/internal/common/binary.go | 634 - .../shirou/gopsutil/internal/common/common.go | 279 - .../gopsutil/internal/common/common_darwin.go | 70 - .../internal/common/common_freebsd.go | 70 - .../gopsutil/internal/common/common_linux.go | 3 - .../gopsutil/internal/common/common_unix.go | 66 - .../internal/common/common_windows.go | 110 - .../github.com/shirou/gopsutil/load/load.go | 35 - .../shirou/gopsutil/load/load_darwin.go | 67 - .../shirou/gopsutil/load/load_freebsd.go | 65 - .../shirou/gopsutil/load/load_linux.go | 78 - .../shirou/gopsutil/load/load_windows.go | 19 - .../src/github.com/shirou/gopsutil/mem/mem.go | 64 - .../shirou/gopsutil/mem/mem_darwin.go | 69 - .../shirou/gopsutil/mem/mem_darwin_cgo.go | 53 - .../shirou/gopsutil/mem/mem_darwin_nocgo.go | 88 - .../shirou/gopsutil/mem/mem_freebsd.go | 134 - .../shirou/gopsutil/mem/mem_linux.go | 100 - .../shirou/gopsutil/mem/mem_windows.go | 50 - .../src/github.com/shirou/gopsutil/net/net.go | 243 - .../shirou/gopsutil/net/net_darwin.go | 114 - .../shirou/gopsutil/net/net_freebsd.go | 108 - .../shirou/gopsutil/net/net_linux.go | 620 - .../shirou/gopsutil/net/net_unix.go | 68 - .../shirou/gopsutil/net/net_windows.go | 116 - .../shirou/gopsutil/process/process.go | 166 - .../shirou/gopsutil/process/process_darwin.go | 451 - .../gopsutil/process/process_darwin_amd64.go | 234 - .../gopsutil/process/process_freebsd.go | 336 - .../gopsutil/process/process_freebsd_386.go | 141 - .../gopsutil/process/process_freebsd_amd64.go | 192 - .../shirou/gopsutil/process/process_linux.go | 733 - .../gopsutil/process/process_linux_386.go | 9 - .../gopsutil/process/process_linux_amd64.go | 9 - .../gopsutil/process/process_linux_arm.go | 9 - .../shirou/gopsutil/process/process_posix.go | 106 - .../gopsutil/process/process_windows.go | 357 - .../shirou/gopsutil/process/types_darwin.go | 160 - .../shirou/gopsutil/process/types_freebsd.go | 95 - .../src/github.com/shirou/w32/AUTHORS | 16 - .../src/github.com/shirou/w32/LICENSE | 23 - .../src/github.com/shirou/w32/README.md | 33 - .../src/github.com/shirou/w32/advapi32.go | 299 - .../src/github.com/shirou/w32/comctl32.go | 109 - .../src/github.com/shirou/w32/comdlg32.go | 38 - .../src/github.com/shirou/w32/constants.go | 2661 --- .../src/github.com/shirou/w32/dwmapi.go | 254 - .../src/github.com/shirou/w32/gdi32.go | 509 - .../src/github.com/shirou/w32/gdiplus.go | 175 - .../src/github.com/shirou/w32/idispatch.go | 43 - .../src/github.com/shirou/w32/istream.go | 31 - .../src/github.com/shirou/w32/iunknown.go | 27 - .../src/github.com/shirou/w32/kernel32.go | 314 - .../src/github.com/shirou/w32/ole32.go | 63 - .../src/github.com/shirou/w32/oleaut32.go | 48 - .../src/github.com/shirou/w32/opengl32.go | 72 - .../src/github.com/shirou/w32/psapi.go | 25 - .../src/github.com/shirou/w32/shell32.go | 153 - .../src/github.com/shirou/w32/typedef.go | 901 - .../src/github.com/shirou/w32/user32.go | 948 - .../src/github.com/shirou/w32/utils.go | 201 - .../src/github.com/shirou/w32/vars.go | 13 - .../sanitized_anchor_name/.travis.yml | 10 - .../shurcooL/sanitized_anchor_name/LICENSE | 19 - .../shurcooL/sanitized_anchor_name/README.md | 31 - .../shurcooL/sanitized_anchor_name/main.go | 29 - .../src/github.com/spf13/cobra/.gitignore | 24 - .../src/github.com/spf13/cobra/.mailmap | 3 - .../src/github.com/spf13/cobra/.travis.yml | 9 - .../src/github.com/spf13/cobra/LICENSE.txt | 174 - .../src/github.com/spf13/cobra/README.md | 869 - .../spf13/cobra/bash_completions.go | 425 - .../spf13/cobra/bash_completions.md | 149 - .../src/github.com/spf13/cobra/cobra.go | 170 - .../github.com/spf13/cobra/cobra/cmd/add.go | 128 - .../spf13/cobra/cobra/cmd/helpers.go | 347 - .../github.com/spf13/cobra/cobra/cmd/init.go | 226 - .../spf13/cobra/cobra/cmd/licenses.go | 1133 -- .../github.com/spf13/cobra/cobra/cmd/root.go | 84 - .../src/github.com/spf13/cobra/cobra/main.go | 20 - .../src/github.com/spf13/cobra/command.go | 1200 -- .../github.com/spf13/cobra/doc/man_docs.go | 218 - .../github.com/spf13/cobra/doc/man_docs.md | 26 - .../src/github.com/spf13/cobra/doc/md_docs.go | 175 - .../src/github.com/spf13/cobra/doc/md_docs.md | 104 - .../src/github.com/spf13/cobra/doc/util.go | 38 - .../src/github.com/spf13/cobra/doc_util.go | 34 - .../src/github.com/spf13/cobra/man_docs.go | 227 - .../src/github.com/spf13/cobra/man_docs.md | 25 - .../src/github.com/spf13/cobra/md_docs.go | 162 - .../src/github.com/spf13/cobra/md_docs.md | 81 - .../src/github.com/spf13/pflag/.travis.yml | 18 - .../src/github.com/spf13/pflag/LICENSE | 28 - .../src/github.com/spf13/pflag/README.md | 256 - .../src/github.com/spf13/pflag/bool.go | 97 - .../src/github.com/spf13/pflag/count.go | 97 - .../src/github.com/spf13/pflag/duration.go | 86 - .../src/github.com/spf13/pflag/flag.go | 836 - .../src/github.com/spf13/pflag/float32.go | 91 - .../src/github.com/spf13/pflag/float64.go | 87 - .../src/github.com/spf13/pflag/golangflag.go | 97 - .../src/github.com/spf13/pflag/int.go | 87 - .../src/github.com/spf13/pflag/int32.go | 91 - .../src/github.com/spf13/pflag/int64.go | 87 - .../src/github.com/spf13/pflag/int8.go | 91 - .../src/github.com/spf13/pflag/int_slice.go | 128 - .../src/github.com/spf13/pflag/ip.go | 96 - .../src/github.com/spf13/pflag/ipmask.go | 122 - .../src/github.com/spf13/pflag/ipnet.go | 100 - .../src/github.com/spf13/pflag/string.go | 82 - .../github.com/spf13/pflag/string_slice.go | 111 - .../src/github.com/spf13/pflag/uint.go | 91 - .../src/github.com/spf13/pflag/uint16.go | 89 - .../src/github.com/spf13/pflag/uint32.go | 89 - .../src/github.com/spf13/pflag/uint64.go | 91 - .../src/github.com/spf13/pflag/uint8.go | 91 - .../src/github.com/spf13/pflag/verify/all.sh | 69 - .../github.com/spf13/pflag/verify/gofmt.sh | 19 - .../github.com/spf13/pflag/verify/golint.sh | 15 - .../github.com/syndtr/gocapability/LICENSE | 24 - .../gocapability/capability/capability.go | 72 - .../capability/capability_linux.go | 608 - .../capability/capability_noop.go | 19 - .../syndtr/gocapability/capability/enum.go | 345 - .../gocapability/capability/syscall_linux.go | 143 - .../vishvananda/netlink/.travis.yml | 3 - .../github.com/vishvananda/netlink/LICENSE | 192 - .../github.com/vishvananda/netlink/Makefile | 29 - .../github.com/vishvananda/netlink/README.md | 89 - .../github.com/vishvananda/netlink/addr.go | 43 - .../vishvananda/netlink/addr_linux.go | 128 - .../github.com/vishvananda/netlink/class.go | 110 - .../vishvananda/netlink/class_linux.go | 144 - .../github.com/vishvananda/netlink/filter.go | 55 - .../vishvananda/netlink/filter_linux.go | 191 - .../github.com/vishvananda/netlink/link.go | 223 - .../vishvananda/netlink/link_linux.go | 790 - .../github.com/vishvananda/netlink/neigh.go | 22 - .../vishvananda/netlink/neigh_linux.go | 189 - .../github.com/vishvananda/netlink/netlink.go | 39 - .../netlink/netlink_unspecified.go | 143 - .../vishvananda/netlink/nl/addr_linux.go | 47 - .../vishvananda/netlink/nl/link_linux.go | 104 - .../vishvananda/netlink/nl/nl_linux.go | 418 - .../vishvananda/netlink/nl/route_linux.go | 42 - .../vishvananda/netlink/nl/tc_linux.go | 425 - .../vishvananda/netlink/nl/xfrm_linux.go | 258 - .../netlink/nl/xfrm_policy_linux.go | 119 - .../netlink/nl/xfrm_state_linux.go | 221 - .../vishvananda/netlink/protinfo.go | 53 - .../vishvananda/netlink/protinfo_linux.go | 60 - .../github.com/vishvananda/netlink/qdisc.go | 167 - .../vishvananda/netlink/qdisc_linux.go | 316 - .../github.com/vishvananda/netlink/route.go | 41 - .../vishvananda/netlink/route_linux.go | 249 - .../github.com/vishvananda/netlink/xfrm.go | 64 - .../vishvananda/netlink/xfrm_policy.go | 59 - .../vishvananda/netlink/xfrm_policy_linux.go | 127 - .../vishvananda/netlink/xfrm_state.go | 53 - .../vishvananda/netlink/xfrm_state_linux.go | 181 - Godeps/_workspace/src/go4.org/LICENSE | 202 - .../src/go4.org/errorutil/highlight.go | 58 - .../src/golang.org/x/crypto/LICENSE | 27 - .../src/golang.org/x/crypto/PATENTS | 22 - .../src/golang.org/x/crypto/cast5/cast5.go | 526 - .../x/crypto/openpgp/armor/armor.go | 219 - .../x/crypto/openpgp/armor/encode.go | 160 - .../x/crypto/openpgp/canonical_text.go | 59 - .../x/crypto/openpgp/clearsign/clearsign.go | 366 - .../x/crypto/openpgp/elgamal/elgamal.go | 122 - .../x/crypto/openpgp/errors/errors.go | 72 - .../src/golang.org/x/crypto/openpgp/keys.go | 624 - .../x/crypto/openpgp/packet/compressed.go | 123 - .../x/crypto/openpgp/packet/config.go | 88 - .../x/crypto/openpgp/packet/encrypted_key.go | 168 - .../x/crypto/openpgp/packet/literal.go | 89 - .../x/crypto/openpgp/packet/ocfb.go | 143 - .../openpgp/packet/one_pass_signature.go | 73 - .../x/crypto/openpgp/packet/opaque.go | 161 - .../x/crypto/openpgp/packet/packet.go | 538 - .../x/crypto/openpgp/packet/private_key.go | 310 - .../x/crypto/openpgp/packet/public_key.go | 687 - .../x/crypto/openpgp/packet/public_key_v3.go | 275 - .../x/crypto/openpgp/packet/reader.go | 62 - .../x/crypto/openpgp/packet/signature.go | 663 - .../x/crypto/openpgp/packet/signature_v3.go | 146 - .../openpgp/packet/symmetric_key_encrypted.go | 164 - .../openpgp/packet/symmetrically_encrypted.go | 290 - .../x/crypto/openpgp/packet/userattribute.go | 91 - .../x/crypto/openpgp/packet/userid.go | 160 - .../src/golang.org/x/crypto/openpgp/read.go | 423 - .../golang.org/x/crypto/openpgp/s2k/s2k.go | 273 - .../src/golang.org/x/crypto/openpgp/write.go | 374 - .../x/crypto/ssh/terminal/terminal.go | 892 - .../golang.org/x/crypto/ssh/terminal/util.go | 128 - .../x/crypto/ssh/terminal/util_bsd.go | 12 - .../x/crypto/ssh/terminal/util_linux.go | 11 - .../x/crypto/ssh/terminal/util_windows.go | 174 - .../_workspace/src/golang.org/x/net/LICENSE | 27 - .../_workspace/src/golang.org/x/net/PATENTS | 22 - .../src/golang.org/x/net/context/context.go | 447 - .../x/net/context/ctxhttp/cancelreq.go | 18 - .../x/net/context/ctxhttp/cancelreq_go14.go | 23 - .../x/net/context/ctxhttp/ctxhttp.go | 79 - .../src/golang.org/x/net/html/atom/atom.go | 78 - .../src/golang.org/x/net/html/atom/gen.go | 648 - .../src/golang.org/x/net/html/atom/table.go | 713 - .../golang.org/x/net/html/charset/charset.go | 244 - .../src/golang.org/x/net/html/charset/gen.go | 111 - .../golang.org/x/net/html/charset/table.go | 235 - .../src/golang.org/x/net/html/const.go | 102 - .../src/golang.org/x/net/html/doc.go | 106 - .../src/golang.org/x/net/html/doctype.go | 156 - .../src/golang.org/x/net/html/entity.go | 2253 --- .../src/golang.org/x/net/html/escape.go | 258 - .../src/golang.org/x/net/html/foreign.go | 226 - .../src/golang.org/x/net/html/node.go | 193 - .../src/golang.org/x/net/html/parse.go | 2094 --- .../src/golang.org/x/net/html/render.go | 271 - .../src/golang.org/x/net/html/token.go | 1219 -- .../src/golang.org/x/net/http2/.gitignore | 2 - .../src/golang.org/x/net/http2/Dockerfile | 44 - .../src/golang.org/x/net/http2/Makefile | 3 - .../src/golang.org/x/net/http2/README | 20 - .../src/golang.org/x/net/http2/buffer.go | 76 - .../src/golang.org/x/net/http2/errors.go | 78 - .../src/golang.org/x/net/http2/flow.go | 51 - .../src/golang.org/x/net/http2/frame.go | 1113 -- .../src/golang.org/x/net/http2/gotrack.go | 173 - .../golang.org/x/net/http2/h2demo/.gitignore | 5 - .../golang.org/x/net/http2/h2demo/Makefile | 5 - .../src/golang.org/x/net/http2/h2demo/README | 16 - .../golang.org/x/net/http2/h2demo/h2demo.go | 435 - .../golang.org/x/net/http2/h2demo/launch.go | 302 - .../golang.org/x/net/http2/h2demo/rootCA.key | 27 - .../golang.org/x/net/http2/h2demo/rootCA.pem | 26 - .../golang.org/x/net/http2/h2demo/rootCA.srl | 1 - .../golang.org/x/net/http2/h2demo/server.crt | 20 - .../golang.org/x/net/http2/h2demo/server.key | 27 - .../src/golang.org/x/net/http2/h2i/README.md | 97 - .../src/golang.org/x/net/http2/h2i/h2i.go | 489 - .../src/golang.org/x/net/http2/headermap.go | 80 - .../golang.org/x/net/http2/hpack/encode.go | 252 - .../src/golang.org/x/net/http2/hpack/hpack.go | 445 - .../golang.org/x/net/http2/hpack/huffman.go | 159 - .../golang.org/x/net/http2/hpack/tables.go | 353 - .../src/golang.org/x/net/http2/http2.go | 249 - .../src/golang.org/x/net/http2/pipe.go | 43 - .../src/golang.org/x/net/http2/server.go | 1780 -- .../src/golang.org/x/net/http2/transport.go | 553 - .../src/golang.org/x/net/http2/write.go | 204 - .../src/golang.org/x/net/http2/writesched.go | 286 - .../x/net/internal/timeseries/timeseries.go | 525 - .../src/golang.org/x/net/trace/events.go | 524 - .../src/golang.org/x/net/trace/histogram.go | 356 - .../src/golang.org/x/net/trace/trace.go | 1057 -- .../_workspace/src/golang.org/x/sys/LICENSE | 27 - .../_workspace/src/golang.org/x/sys/PATENTS | 22 - .../src/golang.org/x/sys/unix/.gitignore | 1 - .../src/golang.org/x/sys/unix/asm.s | 10 - .../golang.org/x/sys/unix/asm_darwin_386.s | 29 - .../golang.org/x/sys/unix/asm_darwin_amd64.s | 29 - .../golang.org/x/sys/unix/asm_darwin_arm.s | 30 - .../golang.org/x/sys/unix/asm_darwin_arm64.s | 30 - .../x/sys/unix/asm_dragonfly_amd64.s | 29 - .../golang.org/x/sys/unix/asm_freebsd_386.s | 29 - .../golang.org/x/sys/unix/asm_freebsd_amd64.s | 29 - .../golang.org/x/sys/unix/asm_freebsd_arm.s | 29 - .../src/golang.org/x/sys/unix/asm_linux_386.s | 35 - .../golang.org/x/sys/unix/asm_linux_amd64.s | 29 - .../src/golang.org/x/sys/unix/asm_linux_arm.s | 29 - .../golang.org/x/sys/unix/asm_linux_arm64.s | 24 - .../golang.org/x/sys/unix/asm_linux_mips64x.s | 28 - .../golang.org/x/sys/unix/asm_linux_ppc64x.s | 28 - .../golang.org/x/sys/unix/asm_linux_s390x.s | 28 - .../golang.org/x/sys/unix/asm_netbsd_386.s | 29 - .../golang.org/x/sys/unix/asm_netbsd_amd64.s | 29 - .../golang.org/x/sys/unix/asm_netbsd_arm.s | 29 - .../golang.org/x/sys/unix/asm_openbsd_386.s | 29 - .../golang.org/x/sys/unix/asm_openbsd_amd64.s | 29 - .../golang.org/x/sys/unix/asm_solaris_amd64.s | 17 - .../golang.org/x/sys/unix/bluetooth_linux.go | 35 - .../src/golang.org/x/sys/unix/constants.go | 13 - .../src/golang.org/x/sys/unix/env_unix.go | 27 - .../src/golang.org/x/sys/unix/env_unset.go | 14 - .../src/golang.org/x/sys/unix/flock.go | 24 - .../x/sys/unix/flock_linux_32bit.go | 13 - .../src/golang.org/x/sys/unix/gccgo.go | 46 - .../src/golang.org/x/sys/unix/gccgo_c.c | 41 - .../x/sys/unix/gccgo_linux_amd64.go | 20 - .../src/golang.org/x/sys/unix/mkall.sh | 285 - .../src/golang.org/x/sys/unix/mkerrors.sh | 476 - .../src/golang.org/x/sys/unix/mkpost.go | 62 - .../src/golang.org/x/sys/unix/mksyscall.pl | 323 - .../x/sys/unix/mksyscall_solaris.pl | 294 - .../golang.org/x/sys/unix/mksysctl_openbsd.pl | 264 - .../golang.org/x/sys/unix/mksysnum_darwin.pl | 39 - .../x/sys/unix/mksysnum_dragonfly.pl | 50 - .../golang.org/x/sys/unix/mksysnum_freebsd.pl | 63 - .../golang.org/x/sys/unix/mksysnum_linux.pl | 58 - .../golang.org/x/sys/unix/mksysnum_netbsd.pl | 58 - .../golang.org/x/sys/unix/mksysnum_openbsd.pl | 50 - .../src/golang.org/x/sys/unix/race.go | 30 - .../src/golang.org/x/sys/unix/race0.go | 25 - .../golang.org/x/sys/unix/sockcmsg_linux.go | 36 - .../golang.org/x/sys/unix/sockcmsg_unix.go | 103 - .../src/golang.org/x/sys/unix/str.go | 26 - .../src/golang.org/x/sys/unix/syscall.go | 76 - .../src/golang.org/x/sys/unix/syscall_bsd.go | 628 - .../golang.org/x/sys/unix/syscall_darwin.go | 509 - .../x/sys/unix/syscall_darwin_386.go | 77 - .../x/sys/unix/syscall_darwin_amd64.go | 79 - .../x/sys/unix/syscall_darwin_arm.go | 71 - .../x/sys/unix/syscall_darwin_arm64.go | 77 - .../x/sys/unix/syscall_dragonfly.go | 411 - .../x/sys/unix/syscall_dragonfly_amd64.go | 61 - .../golang.org/x/sys/unix/syscall_freebsd.go | 682 - .../x/sys/unix/syscall_freebsd_386.go | 61 - .../x/sys/unix/syscall_freebsd_amd64.go | 61 - .../x/sys/unix/syscall_freebsd_arm.go | 61 - .../golang.org/x/sys/unix/syscall_linux.go | 1108 -- .../x/sys/unix/syscall_linux_386.go | 390 - .../x/sys/unix/syscall_linux_amd64.go | 148 - .../x/sys/unix/syscall_linux_arm.go | 254 - .../x/sys/unix/syscall_linux_arm64.go | 180 - .../x/sys/unix/syscall_linux_mips64x.go | 206 - .../x/sys/unix/syscall_linux_ppc64x.go | 126 - .../x/sys/unix/syscall_linux_s390x.go | 320 - .../golang.org/x/sys/unix/syscall_netbsd.go | 492 - .../x/sys/unix/syscall_netbsd_386.go | 42 - .../x/sys/unix/syscall_netbsd_amd64.go | 42 - .../x/sys/unix/syscall_netbsd_arm.go | 42 - .../golang.org/x/sys/unix/syscall_no_getwd.go | 11 - .../golang.org/x/sys/unix/syscall_openbsd.go | 303 - .../x/sys/unix/syscall_openbsd_386.go | 42 - .../x/sys/unix/syscall_openbsd_amd64.go | 42 - .../golang.org/x/sys/unix/syscall_solaris.go | 713 - .../x/sys/unix/syscall_solaris_amd64.go | 35 - .../src/golang.org/x/sys/unix/syscall_unix.go | 297 - .../src/golang.org/x/sys/unix/types_darwin.go | 250 - .../golang.org/x/sys/unix/types_dragonfly.go | 242 - .../golang.org/x/sys/unix/types_freebsd.go | 353 - .../src/golang.org/x/sys/unix/types_linux.go | 435 - .../src/golang.org/x/sys/unix/types_netbsd.go | 232 - .../golang.org/x/sys/unix/types_openbsd.go | 244 - .../golang.org/x/sys/unix/types_solaris.go | 260 - .../x/sys/unix/zerrors_darwin_386.go | 1576 -- .../x/sys/unix/zerrors_darwin_amd64.go | 1576 -- .../x/sys/unix/zerrors_darwin_arm.go | 1293 -- .../x/sys/unix/zerrors_darwin_arm64.go | 1576 -- .../x/sys/unix/zerrors_dragonfly_amd64.go | 1530 -- .../x/sys/unix/zerrors_freebsd_386.go | 1743 -- .../x/sys/unix/zerrors_freebsd_amd64.go | 1748 -- .../x/sys/unix/zerrors_freebsd_arm.go | 1729 -- .../x/sys/unix/zerrors_linux_386.go | 1819 -- .../x/sys/unix/zerrors_linux_amd64.go | 1820 -- .../x/sys/unix/zerrors_linux_arm.go | 1743 -- .../x/sys/unix/zerrors_linux_arm64.go | 1897 -- .../x/sys/unix/zerrors_linux_mips64.go | 1917 -- .../x/sys/unix/zerrors_linux_mips64le.go | 1917 -- .../x/sys/unix/zerrors_linux_ppc64.go | 1970 -- .../x/sys/unix/zerrors_linux_ppc64le.go | 1969 -- .../x/sys/unix/zerrors_linux_s390x.go | 2027 -- .../x/sys/unix/zerrors_netbsd_386.go | 1712 -- .../x/sys/unix/zerrors_netbsd_amd64.go | 1702 -- .../x/sys/unix/zerrors_netbsd_arm.go | 1688 -- .../x/sys/unix/zerrors_openbsd_386.go | 1584 -- .../x/sys/unix/zerrors_openbsd_amd64.go | 1583 -- .../x/sys/unix/zerrors_solaris_amd64.go | 1436 -- .../x/sys/unix/zsyscall_darwin_386.go | 1427 -- .../x/sys/unix/zsyscall_darwin_amd64.go | 1443 -- .../x/sys/unix/zsyscall_darwin_arm.go | 1427 -- .../x/sys/unix/zsyscall_darwin_arm64.go | 1427 -- .../x/sys/unix/zsyscall_dragonfly_amd64.go | 1413 -- .../x/sys/unix/zsyscall_freebsd_386.go | 1665 -- .../x/sys/unix/zsyscall_freebsd_amd64.go | 1665 -- .../x/sys/unix/zsyscall_freebsd_arm.go | 1665 -- .../x/sys/unix/zsyscall_linux_386.go | 1638 -- .../x/sys/unix/zsyscall_linux_amd64.go | 1832 -- .../x/sys/unix/zsyscall_linux_arm.go | 1739 -- .../x/sys/unix/zsyscall_linux_arm64.go | 1723 -- .../x/sys/unix/zsyscall_linux_mips64.go | 1781 -- .../x/sys/unix/zsyscall_linux_mips64le.go | 1781 -- .../x/sys/unix/zsyscall_linux_ppc64.go | 1843 -- .../x/sys/unix/zsyscall_linux_ppc64le.go | 1843 -- .../x/sys/unix/zsyscall_linux_s390x.go | 1623 -- .../x/sys/unix/zsyscall_netbsd_386.go | 1327 -- .../x/sys/unix/zsyscall_netbsd_amd64.go | 1327 -- .../x/sys/unix/zsyscall_netbsd_arm.go | 1327 -- .../x/sys/unix/zsyscall_openbsd_386.go | 1387 -- .../x/sys/unix/zsyscall_openbsd_amd64.go | 1387 -- .../x/sys/unix/zsyscall_solaris_amd64.go | 1559 -- .../golang.org/x/sys/unix/zsysctl_openbsd.go | 270 - .../x/sys/unix/zsysnum_darwin_386.go | 398 - .../x/sys/unix/zsysnum_darwin_amd64.go | 398 - .../x/sys/unix/zsysnum_darwin_arm.go | 358 - .../x/sys/unix/zsysnum_darwin_arm64.go | 398 - .../x/sys/unix/zsysnum_dragonfly_amd64.go | 304 - .../x/sys/unix/zsysnum_freebsd_386.go | 351 - .../x/sys/unix/zsysnum_freebsd_amd64.go | 351 - .../x/sys/unix/zsysnum_freebsd_arm.go | 351 - .../x/sys/unix/zsysnum_linux_386.go | 355 - .../x/sys/unix/zsysnum_linux_amd64.go | 321 - .../x/sys/unix/zsysnum_linux_arm.go | 356 - .../x/sys/unix/zsysnum_linux_arm64.go | 272 - .../x/sys/unix/zsysnum_linux_mips64.go | 327 - .../x/sys/unix/zsysnum_linux_mips64le.go | 327 - .../x/sys/unix/zsysnum_linux_ppc64.go | 360 - .../x/sys/unix/zsysnum_linux_ppc64le.go | 353 - .../x/sys/unix/zsysnum_linux_s390x.go | 328 - .../x/sys/unix/zsysnum_netbsd_386.go | 273 - .../x/sys/unix/zsysnum_netbsd_amd64.go | 273 - .../x/sys/unix/zsysnum_netbsd_arm.go | 273 - .../x/sys/unix/zsysnum_openbsd_386.go | 207 - .../x/sys/unix/zsysnum_openbsd_amd64.go | 207 - .../x/sys/unix/zsysnum_solaris_amd64.go | 13 - .../x/sys/unix/ztypes_darwin_386.go | 447 - .../x/sys/unix/ztypes_darwin_amd64.go | 462 - .../x/sys/unix/ztypes_darwin_arm.go | 449 - .../x/sys/unix/ztypes_darwin_arm64.go | 457 - .../x/sys/unix/ztypes_dragonfly_amd64.go | 443 - .../x/sys/unix/ztypes_freebsd_386.go | 502 - .../x/sys/unix/ztypes_freebsd_amd64.go | 505 - .../x/sys/unix/ztypes_freebsd_arm.go | 497 - .../golang.org/x/sys/unix/ztypes_linux_386.go | 607 - .../x/sys/unix/ztypes_linux_amd64.go | 625 - .../golang.org/x/sys/unix/ztypes_linux_arm.go | 587 - .../x/sys/unix/ztypes_linux_arm64.go | 604 - .../x/sys/unix/ztypes_linux_mips64.go | 607 - .../x/sys/unix/ztypes_linux_mips64le.go | 607 - .../x/sys/unix/ztypes_linux_ppc64.go | 614 - .../x/sys/unix/ztypes_linux_ppc64le.go | 614 - .../x/sys/unix/ztypes_linux_s390x.go | 629 - .../x/sys/unix/ztypes_netbsd_386.go | 396 - .../x/sys/unix/ztypes_netbsd_amd64.go | 403 - .../x/sys/unix/ztypes_netbsd_arm.go | 401 - .../x/sys/unix/ztypes_openbsd_386.go | 441 - .../x/sys/unix/ztypes_openbsd_amd64.go | 448 - .../x/sys/unix/ztypes_solaris_amd64.go | 422 - .../_workspace/src/golang.org/x/tools/LICENSE | 27 - .../_workspace/src/golang.org/x/tools/PATENTS | 22 - .../golang.org/x/tools/go/vcs/discovery.go | 76 - .../src/golang.org/x/tools/go/vcs/env.go | 39 - .../src/golang.org/x/tools/go/vcs/http.go | 80 - .../src/golang.org/x/tools/go/vcs/vcs.go | 754 - .../src/google.golang.org/grpc/.travis.yml | 14 - .../google.golang.org/grpc/CONTRIBUTING.md | 23 - .../grpc/Documentation/grpc-auth-support.md | 41 - .../src/google.golang.org/grpc/LICENSE | 28 - .../src/google.golang.org/grpc/Makefile | 50 - .../src/google.golang.org/grpc/PATENTS | 22 - .../src/google.golang.org/grpc/README.md | 32 - .../grpc/benchmark/benchmark.go | 147 - .../grpc/benchmark/client/main.go | 162 - .../grpc/benchmark/grpc_testing/test.pb.go | 641 - .../grpc/benchmark/grpc_testing/test.proto | 148 - .../grpc/benchmark/server/main.go | 35 - .../grpc/benchmark/stats/counter.go | 135 - .../grpc/benchmark/stats/histogram.go | 255 - .../grpc/benchmark/stats/stats.go | 116 - .../grpc/benchmark/stats/timeseries.go | 154 - .../grpc/benchmark/stats/tracker.go | 159 - .../grpc/benchmark/stats/util.go | 191 - .../src/google.golang.org/grpc/call.go | 183 - .../src/google.golang.org/grpc/clientconn.go | 571 - .../src/google.golang.org/grpc/codegen.sh | 17 - .../grpc/codes/code_string.go | 16 - .../src/google.golang.org/grpc/codes/codes.go | 159 - .../src/google.golang.org/grpc/coverage.sh | 47 - .../grpc/credentials/credentials.go | 226 - .../src/google.golang.org/grpc/doc.go | 6 - .../google.golang.org/grpc/examples/README.md | 57 - .../grpc/examples/gotutorial.md | 431 - .../helloworld/greeter_client/main.go | 69 - .../helloworld/greeter_server/main.go | 65 - .../helloworld/helloworld/helloworld.pb.go | 109 - .../helloworld/helloworld/helloworld.proto | 51 - .../grpc/examples/route_guide/README.md | 35 - .../examples/route_guide/client/client.go | 202 - .../route_guide/routeguide/route_guide.pb.go | 426 - .../route_guide/routeguide/route_guide.proto | 121 - .../examples/route_guide/server/server.go | 239 - .../google.golang.org/grpc/grpclog/logger.go | 90 - .../health/grpc_health_v1alpha/health.pb.go | 133 - .../health/grpc_health_v1alpha/health.proto | 20 - .../google.golang.org/grpc/health/health.go | 49 - .../grpc/interop/client/client.go | 172 - .../grpc/interop/grpc_testing/test.pb.go | 702 - .../grpc/interop/grpc_testing/test.proto | 140 - .../grpc/interop/server/server.go | 73 - .../grpc/interop/test_utils.go | 607 - .../grpc/metadata/metadata.go | 134 - .../google.golang.org/grpc/naming/naming.go | 73 - .../src/google.golang.org/grpc/peer/peer.go | 65 - .../src/google.golang.org/grpc/picker.go | 243 - .../src/google.golang.org/grpc/rpc_util.go | 345 - .../src/google.golang.org/grpc/server.go | 575 - .../src/google.golang.org/grpc/stream.go | 375 - .../grpc/test/codec_perf/perf.pb.go | 42 - .../grpc/test/codec_perf/perf.proto | 11 - .../grpc/test/grpc_testing/test.pb.go | 702 - .../grpc/test/grpc_testing/test.proto | 140 - .../src/google.golang.org/grpc/trace.go | 120 - .../grpc/transport/control.go | 260 - .../grpc/transport/http2_client.go | 865 - .../grpc/transport/http2_server.go | 699 - .../grpc/transport/http_util.go | 451 - .../grpc/transport/transport.go | 465 - Godeps/_workspace/src/gopkg.in/inf.v0/LICENSE | 28 - Godeps/_workspace/src/gopkg.in/inf.v0/dec.go | 615 - .../_workspace/src/gopkg.in/inf.v0/rounder.go | 145 - .../_workspace/src/k8s.io/kubernetes/LICENSE | 202 - .../update-demo/local/LICENSE.angular | 21 - .../pkg/api/resource/deep_copy_generated.go | 55 - .../pkg/api/resource/generated.pb.go | 371 - .../pkg/api/resource/generated.proto | 109 - .../kubernetes/pkg/api/resource/quantity.go | 538 - .../pkg/api/resource/quantity_proto.go | 78 - .../kubernetes/pkg/api/resource/scale_int.go | 95 - .../kubernetes/pkg/api/resource/suffix.go | 136 - .../k8s.io/kubernetes/pkg/conversion/OWNERS | 5 - .../kubernetes/pkg/conversion/cloner.go | 237 - .../kubernetes/pkg/conversion/converter.go | 951 - .../pkg/conversion/deep_copy_generated.go | 185 - .../kubernetes/pkg/conversion/deep_equal.go | 36 - .../k8s.io/kubernetes/pkg/conversion/doc.go | 24 - .../kubernetes/pkg/conversion/helper.go | 39 - .../third_party/forked/reflect/LICENSE | 27 - .../third_party/forked/reflect/deep_equal.go | 388 - .../kubernetes/third_party/golang/LICENSE | 27 - .../kubernetes/third_party/golang/PATENTS | 22 - .../kubernetes/third_party/htpasswd/COPYING | 28 - .../kubernetes/third_party/pause/LICENSE | 19 - .../kubernetes/third_party/swagger-ui/LICENSE | 11 - 1309 files changed, 363172 deletions(-) delete mode 100644 Godeps/Godeps.json delete mode 100644 Godeps/Readme delete mode 100644 Godeps/_workspace/.gitignore delete mode 100644 Godeps/_workspace/src/github.com/StackExchange/wmi/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/StackExchange/wmi/README.md delete mode 100644 Godeps/_workspace/src/github.com/StackExchange/wmi/wmi.go delete mode 100644 Godeps/_workspace/src/github.com/appc/docker2aci/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/appc/docker2aci/lib/common/common.go delete mode 100644 Godeps/_workspace/src/github.com/appc/docker2aci/lib/conversion_store.go delete mode 100644 Godeps/_workspace/src/github.com/appc/docker2aci/lib/docker2aci.go delete mode 100644 Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/file/file.go delete mode 100644 Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository.go delete mode 100644 Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository1.go delete mode 100644 Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository2.go delete mode 100644 Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/docker/docker_functions.go delete mode 100644 Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/internal.go delete mode 100644 Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/tarball/tarfile.go delete mode 100644 Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/tarball/walk.go delete mode 100644 Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/types/docker_types.go delete mode 100644 Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/types/types.go delete mode 100644 Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/util/util.go delete mode 100644 Godeps/_workspace/src/github.com/appc/docker2aci/lib/version.go delete mode 100644 Godeps/_workspace/src/github.com/appc/docker2aci/pkg/log/log.go delete mode 100644 Godeps/_workspace/src/github.com/appc/goaci/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/appc/goaci/proj2aci/asset.go delete mode 100644 Godeps/_workspace/src/github.com/appc/goaci/proj2aci/binary.go delete mode 100644 Godeps/_workspace/src/github.com/appc/goaci/proj2aci/builder.go delete mode 100644 Godeps/_workspace/src/github.com/appc/goaci/proj2aci/cmake.go delete mode 100644 Godeps/_workspace/src/github.com/appc/goaci/proj2aci/go.go delete mode 100644 Godeps/_workspace/src/github.com/appc/goaci/proj2aci/run.go delete mode 100644 Godeps/_workspace/src/github.com/appc/goaci/proj2aci/util.go delete mode 100644 Godeps/_workspace/src/github.com/appc/goaci/proj2aci/vcs.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/ace/build_aci delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/ace/doc.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_main.json.in delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_sidekick.json.in delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/ace/os_default.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/ace/os_freebsd.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/ace/os_linux.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/ace/os_shared.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/ace/validator.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/aci/build.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/aci/doc.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/aci/file.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/aci/layout.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/aci/writer.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/actool/actool.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/actool/build.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/actool/discover.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/actool/doc.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/actool/help.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/actool/manifest.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/actool/validate.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/actool/version.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/discovery/discovery.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/discovery/doc.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/discovery/http.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/discovery/parse.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/pkg/acirenderer/acirenderer.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/pkg/acirenderer/resolve.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/pkg/device/device_linux.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/pkg/device/device_posix.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/pkg/tarheader/doc.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/pkg/tarheader/pop_darwin.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/pkg/tarheader/pop_linux.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/pkg/tarheader/pop_posix.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/pkg/tarheader/tarheader.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/common/common.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/doc.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/image.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/kind.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/lastditch/doc.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/lastditch/image.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/lastditch/labels.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/lastditch/pod.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/pod.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/types/acidentifier.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/types/ackind.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/types/acname.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/types/annotations.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/types/app.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/types/date.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/types/dependencies.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/types/doc.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/types/environment.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/types/errors.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/types/event_handler.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/types/exec.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/types/hash.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/types/isolator.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/types/isolator_linux_specific.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/types/isolator_resources.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/types/labels.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/types/mountpoint.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/types/port.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/types/semver.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/types/url.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/types/uuid.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/types/volume.go delete mode 100644 Godeps/_workspace/src/github.com/appc/spec/schema/version.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/LICENSE.txt delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/NOTICE.txt delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awserr/error.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awserr/types.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/copy.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/equal.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/path_value.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/prettify.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/string_value.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/client/metadata/client_info.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/config.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/convert_types.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/chain_provider.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/credentials.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/env_provider.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/example.ini delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/shared_credentials_provider.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/static_provider.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/errors.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/logger.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/handlers.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/request.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/request_pagination.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/retryer.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/types.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/version.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/build.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/payload.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/signer/v4/header_rules.go delete mode 100644 Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/signer/v4/v4.go delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/COPYING delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/clients/chrome/clip-it-good/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/misc/copyrightifity delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/pkg/legal/legal.go delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/pkg/legal/legalprint/legalprint.go delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/bazil.org/fuse/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/closure/lib/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/code.google.com/p/goauth2/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/code.google.com/p/goauth2/PATENTS delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/code.google.com/p/leveldb-go/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/code.google.com/p/snappy-go/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/code.google.com/p/xsrftoken/COPYING delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/fontawesome/LICENSE.txt delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/camlistore/lock/COPYING delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/exp/dbm/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/exp/lldb/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/fileutil/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/fileutil/falloc/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/fileutil/hdb/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/fileutil/storage/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/kv/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/mathutil/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/mathutil/mersenne/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/sortutil/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/zappy/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/davecgh/go-spew/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/go-sql-driver/mysql/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/golang/glog/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/gorilla/websocket/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/lib/pq/LICENSE.md delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/russross/blackfriday/LICENSE.txt delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/rwcarlsen/goexif/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/glitch/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/golang.org/x/image/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/golang.org/x/image/PATENTS delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/labix.org/v2/mgo/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/labix.org/v2/mgo/bson/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/react/LICENSE.txt delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/vendor/github.com/hjfreyer/taglib-go/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/vendor/golang.org/x/oauth2/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/vendor/google.golang.org/api/googleapi/internal/uritemplates/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/vendor/google.golang.org/cloud/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/vendor/google.golang.org/grpc/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/camlistore/vendor/google.golang.org/grpc/PATENTS delete mode 100644 Godeps/_workspace/src/github.com/camlistore/go4/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/camlistore/go4/legal/legal.go delete mode 100644 Godeps/_workspace/src/github.com/camlistore/go4/lock/.gitignore delete mode 100644 Godeps/_workspace/src/github.com/camlistore/go4/lock/lock.go delete mode 100644 Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_appengine.go delete mode 100644 Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_darwin_amd64.go delete mode 100644 Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_freebsd.go delete mode 100644 Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_linux_amd64.go delete mode 100644 Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_linux_arm.go delete mode 100644 Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_plan9.go delete mode 100644 Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_sigzero.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/args.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/delegate.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/exec.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/find.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/cidr.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/ipforward.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/ipmasq.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/link.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/route.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ipam/ipam.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ns/README.md delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ns/ns.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/skel/skel.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/testutils/cmd.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/types/args.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/types/types.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/utils/sysctl/sysctl_linux.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/pkg/utils/utils.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/daemon.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/lease.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/main.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/options.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/README.md delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/allocator.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk/backend.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk/lock.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/backend/store.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/config.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/main.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/bridge/bridge.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/ipvlan/ipvlan.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/macvlan/macvlan.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/ptp/ptp.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/meta/flannel/flannel.go delete mode 100644 Godeps/_workspace/src/github.com/containernetworking/cni/plugins/meta/tuning/tuning.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/gexpect/LICENCE delete mode 100644 Godeps/_workspace/src/github.com/coreos/gexpect/README.md delete mode 100644 Godeps/_workspace/src/github.com/coreos/gexpect/gexpect.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-iptables/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-iptables/iptables/iptables.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-iptables/iptables/lock.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-semver/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-semver/semver/semver.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-semver/semver/sort.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-systemd/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-systemd/activation/files.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-systemd/activation/listeners.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-systemd/activation/packetconns.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/dbus.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/methods.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/properties.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/set.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/subscription.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/subscription_set.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/journal.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/read.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-systemd/unit/deserialize.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-systemd/unit/escape.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-systemd/unit/option.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-systemd/unit/serialize.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-systemd/util/util.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-tspi/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-tspi/tpmclient/tpmclient.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-tspi/tspiconst/tspiconst.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/go-tspi/verification/verification.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/ioprogress/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/coreos/ioprogress/README.md delete mode 100644 Godeps/_workspace/src/github.com/coreos/ioprogress/draw.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/ioprogress/reader.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/pkg/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/coreos/pkg/NOTICE delete mode 100644 Godeps/_workspace/src/github.com/coreos/pkg/dlopen/dlopen.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/pkg/dlopen/dlopen_example.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/pkg/progressutil/iocopy.go delete mode 100644 Godeps/_workspace/src/github.com/coreos/pkg/progressutil/progressbar.go delete mode 100644 Godeps/_workspace/src/github.com/cpuguy83/go-md2man/LICENSE.md delete mode 100644 Godeps/_workspace/src/github.com/cpuguy83/go-md2man/md2man/md2man.go delete mode 100644 Godeps/_workspace/src/github.com/cpuguy83/go-md2man/md2man/roff.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/b/AUTHORS delete mode 100644 Godeps/_workspace/src/github.com/cznic/b/CONTRIBUTORS delete mode 100644 Godeps/_workspace/src/github.com/cznic/b/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/cznic/b/Makefile delete mode 100644 Godeps/_workspace/src/github.com/cznic/b/README.md delete mode 100644 Godeps/_workspace/src/github.com/cznic/b/btree.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/b/doc.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/b/example/Makefile delete mode 100644 Godeps/_workspace/src/github.com/cznic/b/example/int.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/bufs/AUTHORS delete mode 100644 Godeps/_workspace/src/github.com/cznic/bufs/CONTRIBUTORS delete mode 100644 Godeps/_workspace/src/github.com/cznic/bufs/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/cznic/bufs/Makefile delete mode 100644 Godeps/_workspace/src/github.com/cznic/bufs/README.md delete mode 100644 Godeps/_workspace/src/github.com/cznic/bufs/bufs.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/exp/dbm/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/cznic/exp/lldb/2pc.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/exp/lldb/2pc_docs.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/exp/lldb/AUTHORS delete mode 100644 Godeps/_workspace/src/github.com/cznic/exp/lldb/CONTRIBUTORS delete mode 100644 Godeps/_workspace/src/github.com/cznic/exp/lldb/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/cznic/exp/lldb/Makefile delete mode 100644 Godeps/_workspace/src/github.com/cznic/exp/lldb/README.md delete mode 100644 Godeps/_workspace/src/github.com/cznic/exp/lldb/btree.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/exp/lldb/errors.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/exp/lldb/falloc.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/exp/lldb/filer.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/exp/lldb/gb.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/exp/lldb/lldb.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/exp/lldb/memfiler.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/exp/lldb/osfiler.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/exp/lldb/simplefilefiler.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/exp/lldb/xact.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/AUTHORS delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/CONTRIBUTORS delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/Makefile delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/README delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/falloc/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/falloc/README delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/falloc/docs.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/falloc/error.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/falloc/falloc.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/falloc/test_deps.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/fileutil.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_arm.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_darwin.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_freebsd.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_linux.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_openbsd.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_plan9.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_solaris.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_windows.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/hdb/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/hdb/README delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/hdb/hdb.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/hdb/test_deps.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/storage/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/storage/README delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/storage/cache.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/storage/file.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/storage/mem.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/storage/probe.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/storage/storage.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/storage/test_deps.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/fileutil/test_deps.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/AUTHORS delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/CONTRIBUTORS delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/Makefile delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/README delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/bits.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/envelope.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/example/.gitignore delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/example/example.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/example2/.gitignore delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/example2/example2.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/example3/.gitignore delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/example3/example3.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/example4/main.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/example4/results delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/ff/main.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/mathutil.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/mersenne/AUTHORS delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/mersenne/CONTRIBUTORS delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/mersenne/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/mersenne/Makefile delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/mersenne/README delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/mersenne/mersenne.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/nist-sts-2-1-1-report delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/permute.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/primes.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/rat.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/rnd.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/tables.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/mathutil/test_deps.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/AUTHORS delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/CONTRIBUTORS delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/Makefile delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/README.md delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/benchcmp delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/blob.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/btree.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/builtin.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/coerce.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/design/doc.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/doc.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/driver.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/driver/Makefile delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/driver/driver.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/errors.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/etc.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/expr.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/file.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/helper/helper.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/httpfs.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/introspection.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/mem.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/parser.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/parser.y delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/plan.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/ql.ebnf delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/ql.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/ql.y delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/ql/Makefile delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/ql/README.md delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/ql/main.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/scanner.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/scanner.l delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/stmt.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/storage.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/testdata.log delete mode 100644 Godeps/_workspace/src/github.com/cznic/ql/testdata.ql delete mode 100644 Godeps/_workspace/src/github.com/cznic/sortutil/AUTHORS delete mode 100644 Godeps/_workspace/src/github.com/cznic/sortutil/CONTRIBUTORS delete mode 100644 Godeps/_workspace/src/github.com/cznic/sortutil/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/cznic/sortutil/Makefile delete mode 100644 Godeps/_workspace/src/github.com/cznic/sortutil/README delete mode 100644 Godeps/_workspace/src/github.com/cznic/sortutil/sortutil.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/strutil/AUTHORS delete mode 100644 Godeps/_workspace/src/github.com/cznic/strutil/CONTRIBUTORS delete mode 100644 Godeps/_workspace/src/github.com/cznic/strutil/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/cznic/strutil/Makefile delete mode 100644 Godeps/_workspace/src/github.com/cznic/strutil/README delete mode 100644 Godeps/_workspace/src/github.com/cznic/strutil/strutil.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/zappy/AUTHORS delete mode 100644 Godeps/_workspace/src/github.com/cznic/zappy/CONTRIBUTORS delete mode 100644 Godeps/_workspace/src/github.com/cznic/zappy/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/cznic/zappy/Makefile delete mode 100644 Godeps/_workspace/src/github.com/cznic/zappy/README.md delete mode 100644 Godeps/_workspace/src/github.com/cznic/zappy/SNAPPY-GO-LICENSE delete mode 100644 Godeps/_workspace/src/github.com/cznic/zappy/decode.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/zappy/decode_cgo.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/zappy/decode_nocgo.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/zappy/encode.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/zappy/encode_cgo.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/zappy/encode_nocgo.go delete mode 100644 Godeps/_workspace/src/github.com/cznic/zappy/purego.sh delete mode 100644 Godeps/_workspace/src/github.com/cznic/zappy/zappy.go delete mode 100644 Godeps/_workspace/src/github.com/d2g/dhcp4/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/d2g/dhcp4/README.md delete mode 100644 Godeps/_workspace/src/github.com/d2g/dhcp4/constants.go delete mode 100644 Godeps/_workspace/src/github.com/d2g/dhcp4/helpers.go delete mode 100644 Godeps/_workspace/src/github.com/d2g/dhcp4/option.go delete mode 100644 Godeps/_workspace/src/github.com/d2g/dhcp4/packet.go delete mode 100644 Godeps/_workspace/src/github.com/d2g/dhcp4client/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/d2g/dhcp4client/README.md delete mode 100644 Godeps/_workspace/src/github.com/d2g/dhcp4client/client.go delete mode 100644 Godeps/_workspace/src/github.com/d2g/dhcp4client/inetsock.go delete mode 100644 Godeps/_workspace/src/github.com/d2g/dhcp4client/init.go delete mode 100644 Godeps/_workspace/src/github.com/d2g/dhcp4client/pktsock_linux.go delete mode 100644 Godeps/_workspace/src/github.com/docker/distribution/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/docker/distribution/digest/digest.go delete mode 100644 Godeps/_workspace/src/github.com/docker/distribution/digest/digester.go delete mode 100644 Godeps/_workspace/src/github.com/docker/distribution/digest/doc.go delete mode 100644 Godeps/_workspace/src/github.com/docker/distribution/digest/set.go delete mode 100644 Godeps/_workspace/src/github.com/docker/distribution/digest/verifiers.go delete mode 100644 Godeps/_workspace/src/github.com/docker/distribution/reference/reference.go delete mode 100644 Godeps/_workspace/src/github.com/docker/distribution/reference/regexp.go delete mode 100644 Godeps/_workspace/src/github.com/dustin/go-humanize/.gitignore delete mode 100644 Godeps/_workspace/src/github.com/dustin/go-humanize/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/dustin/go-humanize/README.markdown delete mode 100644 Godeps/_workspace/src/github.com/dustin/go-humanize/big.go delete mode 100644 Godeps/_workspace/src/github.com/dustin/go-humanize/bigbytes.go delete mode 100644 Godeps/_workspace/src/github.com/dustin/go-humanize/bytes.go delete mode 100644 Godeps/_workspace/src/github.com/dustin/go-humanize/comma.go delete mode 100644 Godeps/_workspace/src/github.com/dustin/go-humanize/ftoa.go delete mode 100644 Godeps/_workspace/src/github.com/dustin/go-humanize/humanize.go delete mode 100644 Godeps/_workspace/src/github.com/dustin/go-humanize/number.go delete mode 100644 Godeps/_workspace/src/github.com/dustin/go-humanize/ordinals.go delete mode 100644 Godeps/_workspace/src/github.com/dustin/go-humanize/si.go delete mode 100644 Godeps/_workspace/src/github.com/dustin/go-humanize/times.go delete mode 100644 Godeps/_workspace/src/github.com/go-ini/ini/.gitignore delete mode 100644 Godeps/_workspace/src/github.com/go-ini/ini/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/go-ini/ini/Makefile delete mode 100644 Godeps/_workspace/src/github.com/go-ini/ini/README.md delete mode 100644 Godeps/_workspace/src/github.com/go-ini/ini/README_ZH.md delete mode 100644 Godeps/_workspace/src/github.com/go-ini/ini/ini.go delete mode 100644 Godeps/_workspace/src/github.com/go-ini/ini/key.go delete mode 100644 Godeps/_workspace/src/github.com/go-ini/ini/parser.go delete mode 100644 Godeps/_workspace/src/github.com/go-ini/ini/section.go delete mode 100644 Godeps/_workspace/src/github.com/go-ini/ini/struct.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/.travis.yml delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/ChangeLog.md delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/README.md delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/appveyor.yml delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/com.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/com_func.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/connect.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/constants.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/error.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/error_func.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/error_windows.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/guid.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpoint.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpoint_func.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpoint_windows.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpointcontainer.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpointcontainer_func.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpointcontainer_windows.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/idispatch.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/idispatch_func.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/idispatch_windows.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/ienumvariant.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/ienumvariant_func.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/ienumvariant_windows.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iinspectable.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iinspectable_func.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iinspectable_windows.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iprovideclassinfo.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iprovideclassinfo_func.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iprovideclassinfo_windows.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/itypeinfo.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/itypeinfo_func.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/itypeinfo_windows.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iunknown.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iunknown_func.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/iunknown_windows.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/ole.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/connection.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/connection_func.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/connection_windows.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/go-get.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/oleutil.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/safearray.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/safearray_func.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/safearray_windows.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/safearrayconversion.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/safearrayslices.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/utility.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/variables.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/variant.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/variant_386.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/variant_amd64.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/vt_string.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/winrt.go delete mode 100644 Godeps/_workspace/src/github.com/go-ole/go-ole/winrt_doc.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/CONTRIBUTING.md delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/MAINTAINERS delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/README.markdown delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/auth.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/auth_external.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/auth_sha1.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/call.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/conn.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/conn_darwin.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/conn_other.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/dbus.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/decoder.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/doc.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/encoder.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/export.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/homedir.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/homedir_dynamic.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/homedir_static.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/introspect/call.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/introspect/introspect.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/introspect/introspectable.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/message.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/object.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/prop/prop.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/sig.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/transport_darwin.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/transport_generic.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/transport_unix.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/transport_unixcred_dragonfly.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/transport_unixcred_linux.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/variant.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/variant_lexer.go delete mode 100644 Godeps/_workspace/src/github.com/godbus/dbus/variant_parser.go delete mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/Makefile delete mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/clone.go delete mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/decode.go delete mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/decode_gogo.go delete mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/encode.go delete mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/encode_gogo.go delete mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/equal.go delete mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/extensions.go delete mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/extensions_gogo.go delete mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/lib.go delete mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/lib_gogo.go delete mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/message_set.go delete mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_reflect.go delete mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_unsafe.go delete mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/pointer_unsafe_gogo.go delete mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/properties.go delete mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/properties_gogo.go delete mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/skip_gogo.go delete mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/text.go delete mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_gogo.go delete mode 100644 Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_parser.go delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/proto/Makefile delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/proto/clone.go delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/proto/decode.go delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/proto/encode.go delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/proto/equal.go delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/proto/extensions.go delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/proto/lib.go delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/proto/message_set.go delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/proto/pointer_reflect.go delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/proto/pointer_unsafe.go delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/proto/properties.go delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/proto/proto3_proto/proto3.pb.go delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/proto/proto3_proto/proto3.proto delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/proto/text.go delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/proto/text_parser.go delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/Makefile delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/descriptor/Makefile delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.pb.go delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/doc.go delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/generator/Makefile delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/generator/generator.go delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/internal/grpc/grpc.go delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/link_grpc.go delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/main.go delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/plugin/Makefile delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/plugin/plugin.pb.go delete mode 100644 Godeps/_workspace/src/github.com/golang/protobuf/protoc-gen-go/plugin/plugin.pb.golden delete mode 100644 Godeps/_workspace/src/github.com/google/btree/.travis.yml delete mode 100644 Godeps/_workspace/src/github.com/google/btree/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/google/btree/README.md delete mode 100644 Godeps/_workspace/src/github.com/google/btree/btree.go delete mode 100644 Godeps/_workspace/src/github.com/google/btree/btree_mem.go delete mode 100644 Godeps/_workspace/src/github.com/gopherjs/gopherjs/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/gorilla/context/.travis.yml delete mode 100644 Godeps/_workspace/src/github.com/gorilla/context/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/gorilla/context/README.md delete mode 100644 Godeps/_workspace/src/github.com/gorilla/context/context.go delete mode 100644 Godeps/_workspace/src/github.com/gorilla/context/doc.go delete mode 100644 Godeps/_workspace/src/github.com/gorilla/mux/.travis.yml delete mode 100644 Godeps/_workspace/src/github.com/gorilla/mux/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/gorilla/mux/README.md delete mode 100644 Godeps/_workspace/src/github.com/gorilla/mux/doc.go delete mode 100644 Godeps/_workspace/src/github.com/gorilla/mux/mux.go delete mode 100644 Godeps/_workspace/src/github.com/gorilla/mux/regexp.go delete mode 100644 Godeps/_workspace/src/github.com/gorilla/mux/route.go delete mode 100644 Godeps/_workspace/src/github.com/hashicorp/errwrap/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/hashicorp/errwrap/README.md delete mode 100644 Godeps/_workspace/src/github.com/hashicorp/errwrap/errwrap.go delete mode 100644 Godeps/_workspace/src/github.com/hydrogen18/stoppableListener/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/hydrogen18/stoppableListener/README.md delete mode 100644 Godeps/_workspace/src/github.com/hydrogen18/stoppableListener/example/example.go delete mode 100644 Godeps/_workspace/src/github.com/hydrogen18/stoppableListener/listener.go delete mode 100644 Godeps/_workspace/src/github.com/inconshreveable/mousetrap/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/inconshreveable/mousetrap/README.md delete mode 100644 Godeps/_workspace/src/github.com/inconshreveable/mousetrap/trap_others.go delete mode 100644 Godeps/_workspace/src/github.com/inconshreveable/mousetrap/trap_windows.go delete mode 100644 Godeps/_workspace/src/github.com/inconshreveable/mousetrap/trap_windows_1.4.go delete mode 100644 Godeps/_workspace/src/github.com/jmespath/go-jmespath/.gitignore delete mode 100644 Godeps/_workspace/src/github.com/jmespath/go-jmespath/.travis.yml delete mode 100644 Godeps/_workspace/src/github.com/jmespath/go-jmespath/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/jmespath/go-jmespath/Makefile delete mode 100644 Godeps/_workspace/src/github.com/jmespath/go-jmespath/README.md delete mode 100644 Godeps/_workspace/src/github.com/jmespath/go-jmespath/api.go delete mode 100644 Godeps/_workspace/src/github.com/jmespath/go-jmespath/astnodetype_string.go delete mode 100644 Godeps/_workspace/src/github.com/jmespath/go-jmespath/functions.go delete mode 100644 Godeps/_workspace/src/github.com/jmespath/go-jmespath/interpreter.go delete mode 100644 Godeps/_workspace/src/github.com/jmespath/go-jmespath/lexer.go delete mode 100644 Godeps/_workspace/src/github.com/jmespath/go-jmespath/parser.go delete mode 100644 Godeps/_workspace/src/github.com/jmespath/go-jmespath/toktype_string.go delete mode 100644 Godeps/_workspace/src/github.com/jmespath/go-jmespath/util.go delete mode 100644 Godeps/_workspace/src/github.com/kballard/go-shellquote/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/kballard/go-shellquote/README delete mode 100644 Godeps/_workspace/src/github.com/kballard/go-shellquote/doc.go delete mode 100644 Godeps/_workspace/src/github.com/kballard/go-shellquote/quote.go delete mode 100644 Godeps/_workspace/src/github.com/kballard/go-shellquote/unquote.go delete mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/flate/copy.go delete mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/flate/crc32_amd64.go delete mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/flate/crc32_amd64.s delete mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/flate/crc32_noasm.go delete mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/flate/deflate.go delete mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/flate/fixedhuff.go delete mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/flate/gen.go delete mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/flate/huffman_bit_writer.go delete mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/flate/huffman_code.go delete mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/flate/inflate.go delete mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/flate/reverse_bits.go delete mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/flate/snappy.go delete mode 100644 Godeps/_workspace/src/github.com/klauspost/compress/flate/token.go delete mode 100644 Godeps/_workspace/src/github.com/klauspost/cpuid/.gitignore delete mode 100644 Godeps/_workspace/src/github.com/klauspost/cpuid/.travis.yml delete mode 100644 Godeps/_workspace/src/github.com/klauspost/cpuid/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/klauspost/cpuid/README.md delete mode 100644 Godeps/_workspace/src/github.com/klauspost/cpuid/cpuid.go delete mode 100644 Godeps/_workspace/src/github.com/klauspost/cpuid/cpuid_386.s delete mode 100644 Godeps/_workspace/src/github.com/klauspost/cpuid/cpuid_amd64.s delete mode 100644 Godeps/_workspace/src/github.com/klauspost/cpuid/detect_intel.go delete mode 100644 Godeps/_workspace/src/github.com/klauspost/cpuid/detect_ref.go delete mode 100644 Godeps/_workspace/src/github.com/klauspost/cpuid/generate.go delete mode 100644 Godeps/_workspace/src/github.com/klauspost/cpuid/private-gen.go delete mode 100644 Godeps/_workspace/src/github.com/klauspost/crc32/.gitignore delete mode 100644 Godeps/_workspace/src/github.com/klauspost/crc32/.travis.yml delete mode 100644 Godeps/_workspace/src/github.com/klauspost/crc32/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/klauspost/crc32/README.md delete mode 100644 Godeps/_workspace/src/github.com/klauspost/crc32/crc32.go delete mode 100644 Godeps/_workspace/src/github.com/klauspost/crc32/crc32_amd64.go delete mode 100644 Godeps/_workspace/src/github.com/klauspost/crc32/crc32_amd64.s delete mode 100644 Godeps/_workspace/src/github.com/klauspost/crc32/crc32_amd64p32.go delete mode 100644 Godeps/_workspace/src/github.com/klauspost/crc32/crc32_amd64p32.s delete mode 100644 Godeps/_workspace/src/github.com/klauspost/crc32/crc32_generic.go delete mode 100644 Godeps/_workspace/src/github.com/klauspost/pgzip/.gitignore delete mode 100644 Godeps/_workspace/src/github.com/klauspost/pgzip/.travis.yml delete mode 100644 Godeps/_workspace/src/github.com/klauspost/pgzip/GO_LICENSE delete mode 100644 Godeps/_workspace/src/github.com/klauspost/pgzip/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/klauspost/pgzip/README.md delete mode 100644 Godeps/_workspace/src/github.com/klauspost/pgzip/circle.yml delete mode 100644 Godeps/_workspace/src/github.com/klauspost/pgzip/gunzip.go delete mode 100644 Godeps/_workspace/src/github.com/klauspost/pgzip/gzip.go delete mode 100644 Godeps/_workspace/src/github.com/kr/pty/.gitignore delete mode 100644 Godeps/_workspace/src/github.com/kr/pty/License delete mode 100644 Godeps/_workspace/src/github.com/kr/pty/README.md delete mode 100644 Godeps/_workspace/src/github.com/kr/pty/doc.go delete mode 100644 Godeps/_workspace/src/github.com/kr/pty/ioctl.go delete mode 100644 Godeps/_workspace/src/github.com/kr/pty/ioctl_bsd.go delete mode 100644 Godeps/_workspace/src/github.com/kr/pty/mktypes.bash delete mode 100644 Godeps/_workspace/src/github.com/kr/pty/pty_darwin.go delete mode 100644 Godeps/_workspace/src/github.com/kr/pty/pty_freebsd.go delete mode 100644 Godeps/_workspace/src/github.com/kr/pty/pty_linux.go delete mode 100644 Godeps/_workspace/src/github.com/kr/pty/pty_unsupported.go delete mode 100644 Godeps/_workspace/src/github.com/kr/pty/run.go delete mode 100644 Godeps/_workspace/src/github.com/kr/pty/types.go delete mode 100644 Godeps/_workspace/src/github.com/kr/pty/types_freebsd.go delete mode 100644 Godeps/_workspace/src/github.com/kr/pty/util.go delete mode 100644 Godeps/_workspace/src/github.com/kr/pty/ztypes_386.go delete mode 100644 Godeps/_workspace/src/github.com/kr/pty/ztypes_amd64.go delete mode 100644 Godeps/_workspace/src/github.com/kr/pty/ztypes_arm.go delete mode 100644 Godeps/_workspace/src/github.com/kr/pty/ztypes_arm64.go delete mode 100644 Godeps/_workspace/src/github.com/kr/pty/ztypes_freebsd_386.go delete mode 100644 Godeps/_workspace/src/github.com/kr/pty/ztypes_freebsd_amd64.go delete mode 100644 Godeps/_workspace/src/github.com/kr/pty/ztypes_freebsd_arm.go delete mode 100644 Godeps/_workspace/src/github.com/kr/pty/ztypes_ppc64.go delete mode 100644 Godeps/_workspace/src/github.com/kr/pty/ztypes_ppc64le.go delete mode 100644 Godeps/_workspace/src/github.com/kr/pty/ztypes_s390x.go delete mode 100644 Godeps/_workspace/src/github.com/pborman/uuid/CONTRIBUTORS delete mode 100644 Godeps/_workspace/src/github.com/pborman/uuid/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/pborman/uuid/dce.go delete mode 100644 Godeps/_workspace/src/github.com/pborman/uuid/doc.go delete mode 100644 Godeps/_workspace/src/github.com/pborman/uuid/hash.go delete mode 100644 Godeps/_workspace/src/github.com/pborman/uuid/json.go delete mode 100644 Godeps/_workspace/src/github.com/pborman/uuid/node.go delete mode 100644 Godeps/_workspace/src/github.com/pborman/uuid/sql.go delete mode 100644 Godeps/_workspace/src/github.com/pborman/uuid/time.go delete mode 100644 Godeps/_workspace/src/github.com/pborman/uuid/util.go delete mode 100644 Godeps/_workspace/src/github.com/pborman/uuid/uuid.go delete mode 100644 Godeps/_workspace/src/github.com/pborman/uuid/version1.go delete mode 100644 Godeps/_workspace/src/github.com/pborman/uuid/version4.go delete mode 100644 Godeps/_workspace/src/github.com/petar/GoLLRB/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/peterbourgon/diskv/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/peterbourgon/diskv/README.md delete mode 100644 Godeps/_workspace/src/github.com/peterbourgon/diskv/compression.go delete mode 100644 Godeps/_workspace/src/github.com/peterbourgon/diskv/diskv.go delete mode 100644 Godeps/_workspace/src/github.com/peterbourgon/diskv/index.go delete mode 100644 Godeps/_workspace/src/github.com/russross/blackfriday/.gitignore delete mode 100644 Godeps/_workspace/src/github.com/russross/blackfriday/.travis.yml delete mode 100644 Godeps/_workspace/src/github.com/russross/blackfriday/LICENSE.txt delete mode 100644 Godeps/_workspace/src/github.com/russross/blackfriday/README.md delete mode 100644 Godeps/_workspace/src/github.com/russross/blackfriday/block.go delete mode 100644 Godeps/_workspace/src/github.com/russross/blackfriday/html.go delete mode 100644 Godeps/_workspace/src/github.com/russross/blackfriday/inline.go delete mode 100644 Godeps/_workspace/src/github.com/russross/blackfriday/latex.go delete mode 100644 Godeps/_workspace/src/github.com/russross/blackfriday/markdown.go delete mode 100644 Godeps/_workspace/src/github.com/russross/blackfriday/smartypants.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_darwin.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_darwin_cgo.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_darwin_nocgo.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_freebsd.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_linux.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_unix.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/cpu/cpu_windows.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/host/host.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_darwin.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_darwin_amd64.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_freebsd.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_freebsd_amd64.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_linux.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_linux_386.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_linux_amd64.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_linux_arm.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/host/host_windows.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/host/types_darwin.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/host/types_freebsd.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/host/types_linux.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/binary.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common_darwin.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common_freebsd.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common_linux.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common_unix.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/internal/common/common_windows.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/load/load.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/load/load_darwin.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/load/load_freebsd.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/load/load_linux.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/load/load_windows.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_darwin.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_darwin_cgo.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_darwin_nocgo.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_freebsd.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_linux.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/mem/mem_windows.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/net/net.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/net/net_darwin.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/net/net_freebsd.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/net/net_linux.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/net/net_unix.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/net/net_windows.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/process.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_darwin.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_darwin_amd64.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_freebsd.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_freebsd_386.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_freebsd_amd64.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_linux.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_linux_386.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_linux_amd64.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_linux_arm.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_posix.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/process_windows.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/types_darwin.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/gopsutil/process/types_freebsd.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/w32/AUTHORS delete mode 100644 Godeps/_workspace/src/github.com/shirou/w32/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/shirou/w32/README.md delete mode 100644 Godeps/_workspace/src/github.com/shirou/w32/advapi32.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/w32/comctl32.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/w32/comdlg32.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/w32/constants.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/w32/dwmapi.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/w32/gdi32.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/w32/gdiplus.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/w32/idispatch.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/w32/istream.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/w32/iunknown.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/w32/kernel32.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/w32/ole32.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/w32/oleaut32.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/w32/opengl32.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/w32/psapi.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/w32/shell32.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/w32/typedef.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/w32/user32.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/w32/utils.go delete mode 100644 Godeps/_workspace/src/github.com/shirou/w32/vars.go delete mode 100644 Godeps/_workspace/src/github.com/shurcooL/sanitized_anchor_name/.travis.yml delete mode 100644 Godeps/_workspace/src/github.com/shurcooL/sanitized_anchor_name/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/shurcooL/sanitized_anchor_name/README.md delete mode 100644 Godeps/_workspace/src/github.com/shurcooL/sanitized_anchor_name/main.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/.gitignore delete mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/.mailmap delete mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/.travis.yml delete mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/LICENSE.txt delete mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/README.md delete mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/bash_completions.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/bash_completions.md delete mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/cobra.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/cobra/cmd/add.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/cobra/cmd/helpers.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/cobra/cmd/init.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/cobra/cmd/licenses.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/cobra/cmd/root.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/cobra/main.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/command.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/doc/man_docs.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/doc/man_docs.md delete mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/doc/md_docs.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/doc/md_docs.md delete mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/doc/util.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/doc_util.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/man_docs.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/man_docs.md delete mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/md_docs.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/cobra/md_docs.md delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/.travis.yml delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/README.md delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/bool.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/count.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/duration.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/flag.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/float32.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/float64.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/golangflag.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/int.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/int32.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/int64.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/int8.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/int_slice.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/ip.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/ipmask.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/ipnet.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/string.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/string_slice.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/uint.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/uint16.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/uint32.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/uint64.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/uint8.go delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/verify/all.sh delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/verify/gofmt.sh delete mode 100644 Godeps/_workspace/src/github.com/spf13/pflag/verify/golint.sh delete mode 100644 Godeps/_workspace/src/github.com/syndtr/gocapability/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/syndtr/gocapability/capability/capability.go delete mode 100644 Godeps/_workspace/src/github.com/syndtr/gocapability/capability/capability_linux.go delete mode 100644 Godeps/_workspace/src/github.com/syndtr/gocapability/capability/capability_noop.go delete mode 100644 Godeps/_workspace/src/github.com/syndtr/gocapability/capability/enum.go delete mode 100644 Godeps/_workspace/src/github.com/syndtr/gocapability/capability/syscall_linux.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/.travis.yml delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/LICENSE delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/Makefile delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/README.md delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/addr.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/addr_linux.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/class.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/class_linux.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/filter.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/filter_linux.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/link.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/link_linux.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/neigh.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/neigh_linux.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/netlink.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/netlink_unspecified.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/nl/addr_linux.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/nl/link_linux.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/nl/nl_linux.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/nl/route_linux.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/nl/tc_linux.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/nl/xfrm_linux.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/nl/xfrm_policy_linux.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/nl/xfrm_state_linux.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/protinfo.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/protinfo_linux.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/qdisc.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/qdisc_linux.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/route.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/route_linux.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/xfrm.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/xfrm_policy.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/xfrm_policy_linux.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/xfrm_state.go delete mode 100644 Godeps/_workspace/src/github.com/vishvananda/netlink/xfrm_state_linux.go delete mode 100644 Godeps/_workspace/src/go4.org/LICENSE delete mode 100644 Godeps/_workspace/src/go4.org/errorutil/highlight.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/LICENSE delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/PATENTS delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/cast5/cast5.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/armor/armor.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/armor/encode.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/canonical_text.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/clearsign/clearsign.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/elgamal/elgamal.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/errors/errors.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/keys.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/packet/compressed.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/packet/config.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/packet/encrypted_key.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/packet/literal.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/packet/ocfb.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/packet/one_pass_signature.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/packet/opaque.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/packet/packet.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/packet/private_key.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/packet/public_key.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/packet/public_key_v3.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/packet/reader.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/packet/signature.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/packet/signature_v3.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/packet/symmetric_key_encrypted.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/packet/symmetrically_encrypted.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/packet/userattribute.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/packet/userid.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/read.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/s2k/s2k.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/openpgp/write.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/terminal.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/util.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/util_bsd.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/util_linux.go delete mode 100644 Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/util_windows.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/LICENSE delete mode 100644 Godeps/_workspace/src/golang.org/x/net/PATENTS delete mode 100644 Godeps/_workspace/src/golang.org/x/net/context/context.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/context/ctxhttp/cancelreq.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/context/ctxhttp/cancelreq_go14.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/context/ctxhttp/ctxhttp.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/html/atom/atom.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/html/atom/gen.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/html/atom/table.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/html/charset/charset.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/html/charset/gen.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/html/charset/table.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/html/const.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/html/doc.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/html/doctype.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/html/entity.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/html/escape.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/html/foreign.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/html/node.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/html/parse.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/html/render.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/html/token.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/.gitignore delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/Dockerfile delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/Makefile delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/README delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/buffer.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/errors.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/flow.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/frame.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/gotrack.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/h2demo/.gitignore delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/h2demo/Makefile delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/h2demo/README delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/h2demo/h2demo.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/h2demo/launch.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/h2demo/rootCA.key delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/h2demo/rootCA.pem delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/h2demo/rootCA.srl delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/h2demo/server.crt delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/h2demo/server.key delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/h2i/README.md delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/h2i/h2i.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/headermap.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/hpack/encode.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/hpack/hpack.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/hpack/huffman.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/hpack/tables.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/http2.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/pipe.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/server.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/transport.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/write.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/http2/writesched.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/internal/timeseries/timeseries.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/trace/events.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/trace/histogram.go delete mode 100644 Godeps/_workspace/src/golang.org/x/net/trace/trace.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/LICENSE delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/PATENTS delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/.gitignore delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm.s delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_386.s delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_amd64.s delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_arm.s delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm_darwin_arm64.s delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm_dragonfly_amd64.s delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm_freebsd_386.s delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm_freebsd_amd64.s delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm_freebsd_arm.s delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_386.s delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_amd64.s delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_arm.s delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_arm64.s delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_mips64x.s delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_ppc64x.s delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm_linux_s390x.s delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm_netbsd_386.s delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm_netbsd_amd64.s delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm_netbsd_arm.s delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm_openbsd_386.s delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm_openbsd_amd64.s delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/asm_solaris_amd64.s delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/bluetooth_linux.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/constants.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/env_unix.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/env_unset.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/flock.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/flock_linux_32bit.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/gccgo.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/gccgo_c.c delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/gccgo_linux_amd64.go delete mode 100755 Godeps/_workspace/src/golang.org/x/sys/unix/mkall.sh delete mode 100755 Godeps/_workspace/src/golang.org/x/sys/unix/mkerrors.sh delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/mkpost.go delete mode 100755 Godeps/_workspace/src/golang.org/x/sys/unix/mksyscall.pl delete mode 100755 Godeps/_workspace/src/golang.org/x/sys/unix/mksyscall_solaris.pl delete mode 100755 Godeps/_workspace/src/golang.org/x/sys/unix/mksysctl_openbsd.pl delete mode 100755 Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_darwin.pl delete mode 100755 Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_dragonfly.pl delete mode 100755 Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_freebsd.pl delete mode 100755 Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_linux.pl delete mode 100755 Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_netbsd.pl delete mode 100755 Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_openbsd.pl delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/race.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/race0.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/sockcmsg_linux.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/sockcmsg_unix.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/str.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_bsd.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_386.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_arm.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_darwin_arm64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_dragonfly.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_dragonfly_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_386.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_freebsd_arm.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_386.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_arm.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_arm64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_mips64x.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_ppc64x.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_linux_s390x.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_386.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_netbsd_arm.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_no_getwd.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_openbsd.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_openbsd_386.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_openbsd_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_solaris.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_solaris_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/syscall_unix.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/types_darwin.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/types_dragonfly.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/types_freebsd.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/types_linux.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/types_netbsd.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/types_openbsd.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/types_solaris.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_darwin_386.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_darwin_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_darwin_arm.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_darwin_arm64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_freebsd_386.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_freebsd_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_freebsd_arm.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_386.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_arm.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_arm64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_mips64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_mips64le.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_ppc64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_ppc64le.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_linux_s390x.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_netbsd_386.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_netbsd_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_netbsd_arm.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_openbsd_386.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_openbsd_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zerrors_solaris_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_darwin_386.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_darwin_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_darwin_arm.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_darwin_arm64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_freebsd_386.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_freebsd_arm.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_386.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_arm.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_arm64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_mips64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_mips64le.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_ppc64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_linux_s390x.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_netbsd_386.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_netbsd_arm.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_openbsd_386.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsyscall_solaris_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysctl_openbsd.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_darwin_386.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_darwin_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_darwin_arm.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_darwin_arm64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_freebsd_386.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_freebsd_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_freebsd_arm.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_386.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_arm.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_arm64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_mips64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_mips64le.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_ppc64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_linux_s390x.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_netbsd_386.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_netbsd_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_netbsd_arm.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_openbsd_386.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_openbsd_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/zsysnum_solaris_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_darwin_386.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_darwin_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_darwin_arm.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_darwin_arm64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_freebsd_386.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_freebsd_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_freebsd_arm.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_386.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_arm.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_arm64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_mips64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_mips64le.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_ppc64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_ppc64le.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_linux_s390x.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_netbsd_386.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_netbsd_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_netbsd_arm.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_openbsd_386.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_openbsd_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/sys/unix/ztypes_solaris_amd64.go delete mode 100644 Godeps/_workspace/src/golang.org/x/tools/LICENSE delete mode 100644 Godeps/_workspace/src/golang.org/x/tools/PATENTS delete mode 100644 Godeps/_workspace/src/golang.org/x/tools/go/vcs/discovery.go delete mode 100644 Godeps/_workspace/src/golang.org/x/tools/go/vcs/env.go delete mode 100644 Godeps/_workspace/src/golang.org/x/tools/go/vcs/http.go delete mode 100644 Godeps/_workspace/src/golang.org/x/tools/go/vcs/vcs.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/.travis.yml delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/CONTRIBUTING.md delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/Documentation/grpc-auth-support.md delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/LICENSE delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/Makefile delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/PATENTS delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/README.md delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/benchmark/benchmark.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/benchmark/client/main.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/benchmark/grpc_testing/test.pb.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/benchmark/grpc_testing/test.proto delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/benchmark/server/main.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/benchmark/stats/counter.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/benchmark/stats/histogram.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/benchmark/stats/stats.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/benchmark/stats/timeseries.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/benchmark/stats/tracker.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/benchmark/stats/util.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/call.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/clientconn.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/codegen.sh delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/codes/code_string.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/codes/codes.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/coverage.sh delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/credentials/credentials.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/doc.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/examples/README.md delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/examples/gotutorial.md delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/examples/helloworld/greeter_client/main.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/examples/helloworld/greeter_server/main.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/examples/helloworld/helloworld/helloworld.pb.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/examples/helloworld/helloworld/helloworld.proto delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/examples/route_guide/README.md delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/examples/route_guide/client/client.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/examples/route_guide/routeguide/route_guide.pb.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/examples/route_guide/routeguide/route_guide.proto delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/examples/route_guide/server/server.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/grpclog/logger.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/health/grpc_health_v1alpha/health.pb.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/health/grpc_health_v1alpha/health.proto delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/health/health.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/interop/client/client.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/interop/grpc_testing/test.pb.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/interop/grpc_testing/test.proto delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/interop/server/server.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/interop/test_utils.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/metadata/metadata.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/naming/naming.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/peer/peer.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/picker.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/rpc_util.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/server.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/stream.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/test/codec_perf/perf.pb.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/test/codec_perf/perf.proto delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/test/grpc_testing/test.pb.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/test/grpc_testing/test.proto delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/trace.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/transport/control.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/transport/http2_client.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/transport/http2_server.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/transport/http_util.go delete mode 100644 Godeps/_workspace/src/google.golang.org/grpc/transport/transport.go delete mode 100644 Godeps/_workspace/src/gopkg.in/inf.v0/LICENSE delete mode 100644 Godeps/_workspace/src/gopkg.in/inf.v0/dec.go delete mode 100644 Godeps/_workspace/src/gopkg.in/inf.v0/rounder.go delete mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/LICENSE delete mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/examples/update-demo/local/LICENSE.angular delete mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/deep_copy_generated.go delete mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/generated.pb.go delete mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/generated.proto delete mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/quantity.go delete mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/quantity_proto.go delete mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/scale_int.go delete mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/pkg/api/resource/suffix.go delete mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/OWNERS delete mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/cloner.go delete mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/converter.go delete mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/deep_copy_generated.go delete mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/deep_equal.go delete mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/doc.go delete mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/pkg/conversion/helper.go delete mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/third_party/forked/reflect/LICENSE delete mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/third_party/forked/reflect/deep_equal.go delete mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/third_party/golang/LICENSE delete mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/third_party/golang/PATENTS delete mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/third_party/htpasswd/COPYING delete mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/third_party/pause/LICENSE delete mode 100644 Godeps/_workspace/src/k8s.io/kubernetes/third_party/swagger-ui/LICENSE diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json deleted file mode 100644 index f0fc34c1db..0000000000 --- a/Godeps/Godeps.json +++ /dev/null @@ -1,796 +0,0 @@ -{ - "ImportPath": "github.com/coreos/rkt", - "GoVersion": "go1.5", - "GodepVersion": "v74", - "Packages": [ - "./...", - "github.com/appc/spec/actool", - "github.com/containernetworking/cni/plugins/ipam/dhcp", - "github.com/containernetworking/cni/plugins/ipam/host-local", - "github.com/containernetworking/cni/plugins/main/bridge", - "github.com/containernetworking/cni/plugins/main/ipvlan", - "github.com/containernetworking/cni/plugins/main/macvlan", - "github.com/containernetworking/cni/plugins/main/ptp", - "github.com/containernetworking/cni/plugins/meta/flannel", - "github.com/containernetworking/cni/plugins/meta/tuning", - "github.com/appc/spec/ace", - "github.com/golang/protobuf/protoc-gen-go" - ], - "Deps": [ - { - "ImportPath": "github.com/StackExchange/wmi", - "Rev": "f3e2bae1e0cb5aef83e319133eabfee30013a4a5" - }, - { - "ImportPath": "github.com/appc/docker2aci/lib", - "Comment": "v0.11.1", - "Rev": "355af275fa8d48b4ecdd361a5feaf173abff81e7" - }, - { - "ImportPath": "github.com/appc/docker2aci/lib/common", - "Comment": "v0.11.1", - "Rev": "355af275fa8d48b4ecdd361a5feaf173abff81e7" - }, - { - "ImportPath": "github.com/appc/docker2aci/lib/internal", - "Comment": "v0.11.1", - "Rev": "355af275fa8d48b4ecdd361a5feaf173abff81e7" - }, - { - "ImportPath": "github.com/appc/docker2aci/lib/internal/backend/file", - "Comment": "v0.11.1", - "Rev": "355af275fa8d48b4ecdd361a5feaf173abff81e7" - }, - { - "ImportPath": "github.com/appc/docker2aci/lib/internal/backend/repository", - "Comment": "v0.11.1", - "Rev": "355af275fa8d48b4ecdd361a5feaf173abff81e7" - }, - { - "ImportPath": "github.com/appc/docker2aci/lib/internal/docker", - "Comment": "v0.11.1", - "Rev": "355af275fa8d48b4ecdd361a5feaf173abff81e7" - }, - { - "ImportPath": "github.com/appc/docker2aci/lib/internal/tarball", - "Comment": "v0.11.1", - "Rev": "355af275fa8d48b4ecdd361a5feaf173abff81e7" - }, - { - "ImportPath": "github.com/appc/docker2aci/lib/internal/types", - "Comment": "v0.11.1", - "Rev": "355af275fa8d48b4ecdd361a5feaf173abff81e7" - }, - { - "ImportPath": "github.com/appc/docker2aci/lib/internal/util", - "Comment": "v0.11.1", - "Rev": "355af275fa8d48b4ecdd361a5feaf173abff81e7" - }, - { - "ImportPath": "github.com/appc/docker2aci/pkg/log", - "Comment": "v0.11.1", - "Rev": "355af275fa8d48b4ecdd361a5feaf173abff81e7" - }, - { - "ImportPath": "github.com/appc/goaci/proj2aci", - "Comment": "v0.1.0", - "Rev": "ba7b591f930783c0ab75f5bbfd6ff65c7bd011bf" - }, - { - "ImportPath": "github.com/appc/spec/ace", - "Comment": "v0.8.4", - "Rev": "f82c741e743001237821b5e0bb9a8ebd324d3117" - }, - { - "ImportPath": "github.com/appc/spec/aci", - "Comment": "v0.8.4", - "Rev": "f82c741e743001237821b5e0bb9a8ebd324d3117" - }, - { - "ImportPath": "github.com/appc/spec/actool", - "Comment": "v0.8.4", - "Rev": "f82c741e743001237821b5e0bb9a8ebd324d3117" - }, - { - "ImportPath": "github.com/appc/spec/discovery", - "Comment": "v0.8.4", - "Rev": "f82c741e743001237821b5e0bb9a8ebd324d3117" - }, - { - "ImportPath": "github.com/appc/spec/pkg/acirenderer", - "Comment": "v0.8.4", - "Rev": "f82c741e743001237821b5e0bb9a8ebd324d3117" - }, - { - "ImportPath": "github.com/appc/spec/pkg/device", - "Comment": "v0.8.4", - "Rev": "f82c741e743001237821b5e0bb9a8ebd324d3117" - }, - { - "ImportPath": "github.com/appc/spec/pkg/tarheader", - "Comment": "v0.8.4", - "Rev": "f82c741e743001237821b5e0bb9a8ebd324d3117" - }, - { - "ImportPath": "github.com/appc/spec/schema", - "Comment": "v0.8.4", - "Rev": "f82c741e743001237821b5e0bb9a8ebd324d3117" - }, - { - "ImportPath": "github.com/appc/spec/schema/common", - "Comment": "v0.8.4", - "Rev": "f82c741e743001237821b5e0bb9a8ebd324d3117" - }, - { - "ImportPath": "github.com/appc/spec/schema/lastditch", - "Comment": "v0.8.4", - "Rev": "f82c741e743001237821b5e0bb9a8ebd324d3117" - }, - { - "ImportPath": "github.com/appc/spec/schema/types", - "Comment": "v0.8.4", - "Rev": "f82c741e743001237821b5e0bb9a8ebd324d3117" - }, - { - "ImportPath": "github.com/aws/aws-sdk-go/aws", - "Comment": "v1.1.7", - "Rev": "13a12060f716145019378a10e2806c174356b857" - }, - { - "ImportPath": "github.com/aws/aws-sdk-go/aws/awserr", - "Comment": "v1.1.7", - "Rev": "13a12060f716145019378a10e2806c174356b857" - }, - { - "ImportPath": "github.com/aws/aws-sdk-go/aws/awsutil", - "Comment": "v1.1.7", - "Rev": "13a12060f716145019378a10e2806c174356b857" - }, - { - "ImportPath": "github.com/aws/aws-sdk-go/aws/client/metadata", - "Comment": "v1.1.7", - "Rev": "13a12060f716145019378a10e2806c174356b857" - }, - { - "ImportPath": "github.com/aws/aws-sdk-go/aws/credentials", - "Comment": "v1.1.7", - "Rev": "13a12060f716145019378a10e2806c174356b857" - }, - { - "ImportPath": "github.com/aws/aws-sdk-go/aws/request", - "Comment": "v1.1.7", - "Rev": "13a12060f716145019378a10e2806c174356b857" - }, - { - "ImportPath": "github.com/aws/aws-sdk-go/private/protocol/rest", - "Comment": "v1.1.7", - "Rev": "13a12060f716145019378a10e2806c174356b857" - }, - { - "ImportPath": "github.com/aws/aws-sdk-go/private/signer/v4", - "Comment": "v1.1.7", - "Rev": "13a12060f716145019378a10e2806c174356b857" - }, - { - "ImportPath": "github.com/camlistore/go4/lock", - "Rev": "9ba773eba85ab9e258ff516630f7f6474bc4535b" - }, - { - "ImportPath": "github.com/containernetworking/cni/pkg/invoke", - "Comment": "v0.3.0-rc3", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/pkg/ip", - "Comment": "v0.3.0-rc3", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/pkg/ipam", - "Comment": "v0.3.0-rc3", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/pkg/ipam", - "Comment": "v0.3.0-rc2-5-g35f3a09", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/pkg/ns", - "Comment": "v0.3.0-rc3", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/pkg/skel", - "Comment": "v0.3.0-rc3", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/pkg/testutils", - "Comment": "v0.3.0-rc3", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/pkg/skel", - "Comment": "v0.3.0-rc2-5-g35f3a09", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/pkg/testutils", - "Comment": "v0.3.0-rc2-5-g35f3a09", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/pkg/types", - "Comment": "v0.3.0-rc3", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/pkg/utils", - "Comment": "v0.3.0-rc3", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/pkg/utils/sysctl", - "Comment": "v0.3.0-rc3", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/plugins/ipam/dhcp", - "Comment": "v0.3.0-rc3", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/plugins/ipam/host-local", - "Comment": "v0.3.0-rc3", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/plugins/ipam/host-local/backend", - "Comment": "v0.3.0-rc3", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk", - "Comment": "v0.3.0-rc3", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/plugins/main/bridge", - "Comment": "v0.3.0-rc3", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/plugins/main/ipvlan", - "Comment": "v0.3.0-rc3", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/plugins/main/macvlan", - "Comment": "v0.3.0-rc3", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/plugins/main/ptp", - "Comment": "v0.3.0-rc3", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/plugins/meta/flannel", - "Comment": "v0.3.0-rc3", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/plugins/meta/tuning", - "Comment": "v0.3.0-rc3", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/pkg/utils/sysctl", - "Comment": "v0.3.0-rc2-5-g35f3a09", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/plugins/ipam/dhcp", - "Comment": "v0.3.0-rc2-5-g35f3a09", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/plugins/ipam/host-local", - "Comment": "v0.3.0-rc2-5-g35f3a09", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/plugins/ipam/host-local/backend", - "Comment": "v0.3.0-rc2-5-g35f3a09", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk", - "Comment": "v0.3.0-rc2-5-g35f3a09", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/plugins/main/bridge", - "Comment": "v0.3.0-rc2-5-g35f3a09", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/plugins/main/ipvlan", - "Comment": "v0.3.0-rc2-5-g35f3a09", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/plugins/main/macvlan", - "Comment": "v0.3.0-rc2-5-g35f3a09", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/plugins/main/ptp", - "Comment": "v0.3.0-rc2-5-g35f3a09", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/plugins/meta/flannel", - "Comment": "v0.3.0-rc2-5-g35f3a09", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/containernetworking/cni/plugins/meta/tuning", - "Comment": "v0.3.0-rc2-5-g35f3a09", - "Rev": "35f3a090b2f7ebe32daf0c6a73eb060c669e2128" - }, - { - "ImportPath": "github.com/coreos/gexpect", - "Comment": "v0.1.0", - "Rev": "ca42424d18c76d0d51a4cccd830d11878e9e5c17" - }, - { - "ImportPath": "github.com/coreos/go-iptables/iptables", - "Comment": "v0.1.0", - "Rev": "fbb73372b87f6e89951c2b6b31470c2c9d5cfae3" - }, - { - "ImportPath": "github.com/coreos/go-semver/semver", - "Rev": "6fe83ccda8fb9b7549c9ab4ba47f47858bc950aa" - }, - { - "ImportPath": "github.com/coreos/go-systemd/activation", - "Comment": "v10", - "Rev": "b32b8467dbea18858bfebf65c1a6a761090f2c31" - }, - { - "ImportPath": "github.com/coreos/go-systemd/dbus", - "Comment": "v10", - "Rev": "b32b8467dbea18858bfebf65c1a6a761090f2c31" - }, - { - "ImportPath": "github.com/coreos/go-systemd/sdjournal", - "Comment": "v10", - "Rev": "b32b8467dbea18858bfebf65c1a6a761090f2c31" - }, - { - "ImportPath": "github.com/coreos/go-systemd/unit", - "Comment": "v10", - "Rev": "b32b8467dbea18858bfebf65c1a6a761090f2c31" - }, - { - "ImportPath": "github.com/coreos/go-systemd/util", - "Comment": "v10", - "Rev": "b32b8467dbea18858bfebf65c1a6a761090f2c31" - }, - { - "ImportPath": "github.com/coreos/go-tspi/tpmclient", - "Comment": "v0.1.1", - "Rev": "03955c59fff97f9e38e7e32c68ac4db21a2aea2b" - }, - { - "ImportPath": "github.com/coreos/go-tspi/tspiconst", - "Comment": "v0.1.1", - "Rev": "03955c59fff97f9e38e7e32c68ac4db21a2aea2b" - }, - { - "ImportPath": "github.com/coreos/go-tspi/verification", - "Comment": "v0.1.1", - "Rev": "03955c59fff97f9e38e7e32c68ac4db21a2aea2b" - }, - { - "ImportPath": "github.com/coreos/ioprogress", - "Rev": "e7fc03058804de5488baed8df5b89f3924b9ec9a" - }, - { - "ImportPath": "github.com/coreos/pkg/dlopen", - "Comment": "v2", - "Rev": "7f080b6c11ac2d2347c3cd7521e810207ea1a041" - }, - { - "ImportPath": "github.com/cpuguy83/go-md2man/md2man", - "Comment": "v1.0.4", - "Rev": "71acacd42f85e5e82f70a55327789582a5200a90" - }, - { - "ImportPath": "github.com/cznic/b", - "Rev": "e2e747ce049fb910cff6b1fd7ad8faf3900939d5" - }, - { - "ImportPath": "github.com/cznic/bufs", - "Rev": "3dcccbd7064a1689f9c093a988ea11ac00e21f51" - }, - { - "ImportPath": "github.com/cznic/exp/lldb", - "Rev": "36265f1914ea00990ff0b73f72350edf9b1850df" - }, - { - "ImportPath": "github.com/cznic/fileutil", - "Rev": "21ae57c9dce724a15e88bd9cd46d5668f3e880a5" - }, - { - "ImportPath": "github.com/cznic/mathutil", - "Rev": "250d0b9d3304c5ea0c4cfc7d9efc7ee528b81f3b" - }, - { - "ImportPath": "github.com/cznic/ql", - "Rev": "77545ff365ff426dfab06c46d70fa77600cd55af" - }, - { - "ImportPath": "github.com/cznic/ql/driver", - "Rev": "77545ff365ff426dfab06c46d70fa77600cd55af" - }, - { - "ImportPath": "github.com/cznic/sortutil", - "Rev": "d4401851b4c370f979b842fa1e45e0b3b718b391" - }, - { - "ImportPath": "github.com/cznic/strutil", - "Rev": "97bc31f80ac4c9fa9c5dc5fea74c383858988ea2" - }, - { - "ImportPath": "github.com/cznic/zappy", - "Rev": "47331054e4f96186e3ff772877c0443909368a45" - }, - { - "ImportPath": "github.com/d2g/dhcp4", - "Rev": "f0e4d29ff0231dce36e250b2ed9ff08412584bca" - }, - { - "ImportPath": "github.com/d2g/dhcp4client", - "Rev": "bed07e1bc5b85f69c6f0fd73393aa35ec68ed892" - }, - { - "ImportPath": "github.com/docker/distribution/digest", - "Comment": "v2.3.0", - "Rev": "099622876197e3b24d627a72053d1bcc8968076a" - }, - { - "ImportPath": "github.com/docker/distribution/reference", - "Comment": "v2.3.0", - "Rev": "099622876197e3b24d627a72053d1bcc8968076a" - }, - { - "ImportPath": "github.com/dustin/go-humanize", - "Rev": "c20a8bde38c8f5ba06f6600edf473705c96829d1" - }, - { - "ImportPath": "github.com/go-ini/ini", - "Comment": "v1.11.0", - "Rev": "12f418cc7edc5a618a51407b7ac1f1f512139df3" - }, - { - "ImportPath": "github.com/go-ole/go-ole", - "Comment": "v1.2.0-10-g572eabb", - "Rev": "572eabb84c424e76a0d39d31510dd7dfd62f70b2" - }, - { - "ImportPath": "github.com/go-ole/go-ole/oleutil", - "Comment": "v1.2.0-10-g572eabb", - "Rev": "572eabb84c424e76a0d39d31510dd7dfd62f70b2" - }, - { - "ImportPath": "github.com/godbus/dbus", - "Comment": "v3-6-ga1b8ba5", - "Rev": "a1b8ba5163b7f041b22761461eabd02b70d1f824" - }, - { - "ImportPath": "github.com/godbus/dbus/introspect", - "Comment": "v3-6-ga1b8ba5163b7", - "Rev": "a1b8ba5163b7f041b22761461eabd02b70d1f824" - }, - { - "ImportPath": "github.com/gogo/protobuf/proto", - "Comment": "v0.2", - "Rev": "4168943e65a2802828518e95310aeeed6d84c4e5" - }, - { - "ImportPath": "github.com/golang/protobuf/proto", - "Rev": "2402d76f3d41f928c7902a765dfc872356dd3aad" - }, - { - "ImportPath": "github.com/golang/protobuf/protoc-gen-go", - "Rev": "2402d76f3d41f928c7902a765dfc872356dd3aad" - }, - { - "ImportPath": "github.com/golang/protobuf/protoc-gen-go/descriptor", - "Rev": "2402d76f3d41f928c7902a765dfc872356dd3aad" - }, - { - "ImportPath": "github.com/golang/protobuf/protoc-gen-go/generator", - "Rev": "2402d76f3d41f928c7902a765dfc872356dd3aad" - }, - { - "ImportPath": "github.com/golang/protobuf/protoc-gen-go/internal/grpc", - "Rev": "2402d76f3d41f928c7902a765dfc872356dd3aad" - }, - { - "ImportPath": "github.com/golang/protobuf/protoc-gen-go/plugin", - "Rev": "2402d76f3d41f928c7902a765dfc872356dd3aad" - }, - { - "ImportPath": "github.com/google/btree", - "Rev": "f06e229e679911bb31a04e07ac891115822e37c3" - }, - { - "ImportPath": "github.com/gorilla/context", - "Rev": "50c25fb3b2b3b3cc724e9b6ac75fb44b3bccd0da" - }, - { - "ImportPath": "github.com/gorilla/mux", - "Rev": "e444e69cbd2e2e3e0749a2f3c717cec491552bbf" - }, - { - "ImportPath": "github.com/hashicorp/errwrap", - "Rev": "7554cd9344cec97297fa6649b055a8c98c2a1e55" - }, - { - "ImportPath": "github.com/hydrogen18/stoppableListener", - "Rev": "2eebd04b47ff393f4bc50b7fcacf8f048994c6fd" - }, - { - "ImportPath": "github.com/inconshreveable/mousetrap", - "Rev": "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" - }, - { - "ImportPath": "github.com/jmespath/go-jmespath", - "Comment": "0.2.2-12-g0b12d6b", - "Rev": "0b12d6b521d83fc7f755e7cfc1b1fbdd35a01a74" - }, - { - "ImportPath": "github.com/kballard/go-shellquote", - "Rev": "e5c918b80c17694cbc49aab32a759f9a40067f5d" - }, - { - "ImportPath": "github.com/kr/pty", - "Comment": "release.r56-29-gf7ee69f31298", - "Rev": "f7ee69f31298ecbe5d2b349c711e2547a617d398" - }, - { - "ImportPath": "github.com/pborman/uuid", - "Rev": "cccd189d45f7ac3368a0d127efb7f4d08ae0b655" - }, - { - "ImportPath": "github.com/peterbourgon/diskv", - "Comment": "v2.0.0", - "Rev": "937c5a91d7fb1477fa6d2bb71410b2ae7a0f2143" - }, - { - "ImportPath": "github.com/russross/blackfriday", - "Comment": "v1.4-2-g300106c", - "Rev": "300106c228d52c8941d4b3de6054a6062a86dda3" - }, - { - "ImportPath": "github.com/shirou/gopsutil/cpu", - "Comment": "v2.0.0", - "Rev": "e8f7a95747d711f34ddfe9dd9b825a84bd059dec" - }, - { - "ImportPath": "github.com/shirou/gopsutil/host", - "Comment": "v2.0.0", - "Rev": "e8f7a95747d711f34ddfe9dd9b825a84bd059dec" - }, - { - "ImportPath": "github.com/shirou/gopsutil/internal/common", - "Comment": "v2.0.0", - "Rev": "e8f7a95747d711f34ddfe9dd9b825a84bd059dec" - }, - { - "ImportPath": "github.com/shirou/gopsutil/load", - "Comment": "v2.0.0", - "Rev": "e8f7a95747d711f34ddfe9dd9b825a84bd059dec" - }, - { - "ImportPath": "github.com/shirou/gopsutil/mem", - "Comment": "v2.0.0", - "Rev": "e8f7a95747d711f34ddfe9dd9b825a84bd059dec" - }, - { - "ImportPath": "github.com/shirou/gopsutil/net", - "Comment": "v2.0.0", - "Rev": "e8f7a95747d711f34ddfe9dd9b825a84bd059dec" - }, - { - "ImportPath": "github.com/shirou/gopsutil/process", - "Comment": "v2.0.0", - "Rev": "e8f7a95747d711f34ddfe9dd9b825a84bd059dec" - }, - { - "ImportPath": "github.com/shirou/w32", - "Rev": "3c9377fc6748f222729a8270fe2775d149a249ad" - }, - { - "ImportPath": "github.com/shurcooL/sanitized_anchor_name", - "Rev": "10ef21a441db47d8b13ebcc5fd2310f636973c77" - }, - { - "ImportPath": "github.com/spf13/cobra", - "Rev": "4c05eb1145f16d0e6bb4a3e1b6d769f4713cb41f" - }, - { - "ImportPath": "github.com/spf13/cobra/doc", - "Rev": "4c05eb1145f16d0e6bb4a3e1b6d769f4713cb41f" - }, - { - "ImportPath": "github.com/spf13/pflag", - "Rev": "08b1a584251b5b62f458943640fc8ebd4d50aaa5" - }, - { - "ImportPath": "github.com/syndtr/gocapability/capability", - "Rev": "8e4cdcb3c22b40d5e330ade0b68cb2e2a3cf6f98" - }, - { - "ImportPath": "github.com/vishvananda/netlink", - "Rev": "ecf47fd5739b3d2c3daf7c89c4b9715a2605c21b" - }, - { - "ImportPath": "github.com/vishvananda/netlink/nl", - "Rev": "ecf47fd5739b3d2c3daf7c89c4b9715a2605c21b" - }, - { - "ImportPath": "go4.org/errorutil", - "Rev": "03efcb870d84809319ea509714dd6d19a1498483" - }, - { - "ImportPath": "golang.org/x/crypto/cast5", - "Rev": "a7ead6ddf06233883deca151dffaef2effbf498f" - }, - { - "ImportPath": "golang.org/x/crypto/openpgp", - "Rev": "a7ead6ddf06233883deca151dffaef2effbf498f" - }, - { - "ImportPath": "golang.org/x/crypto/openpgp/armor", - "Rev": "a7ead6ddf06233883deca151dffaef2effbf498f" - }, - { - "ImportPath": "golang.org/x/crypto/openpgp/elgamal", - "Rev": "a7ead6ddf06233883deca151dffaef2effbf498f" - }, - { - "ImportPath": "golang.org/x/crypto/openpgp/errors", - "Rev": "a7ead6ddf06233883deca151dffaef2effbf498f" - }, - { - "ImportPath": "golang.org/x/crypto/openpgp/packet", - "Rev": "a7ead6ddf06233883deca151dffaef2effbf498f" - }, - { - "ImportPath": "golang.org/x/crypto/openpgp/s2k", - "Rev": "a7ead6ddf06233883deca151dffaef2effbf498f" - }, - { - "ImportPath": "golang.org/x/crypto/ssh/terminal", - "Rev": "a7ead6ddf06233883deca151dffaef2effbf498f" - }, - { - "ImportPath": "golang.org/x/net/context", - "Rev": "c2528b2dd8352441850638a8bb678c2ad056fd3e" - }, - { - "ImportPath": "golang.org/x/net/html", - "Rev": "c2528b2dd8352441850638a8bb678c2ad056fd3e" - }, - { - "ImportPath": "golang.org/x/net/html/atom", - "Rev": "c2528b2dd8352441850638a8bb678c2ad056fd3e" - }, - { - "ImportPath": "golang.org/x/net/http2", - "Rev": "c2528b2dd8352441850638a8bb678c2ad056fd3e" - }, - { - "ImportPath": "golang.org/x/net/http2/hpack", - "Rev": "c2528b2dd8352441850638a8bb678c2ad056fd3e" - }, - { - "ImportPath": "golang.org/x/net/internal/timeseries", - "Rev": "c2528b2dd8352441850638a8bb678c2ad056fd3e" - }, - { - "ImportPath": "golang.org/x/net/trace", - "Rev": "c2528b2dd8352441850638a8bb678c2ad056fd3e" - }, - { - "ImportPath": "golang.org/x/sys/unix", - "Rev": "b44883b474ffefa37335017174e397412b633a4f" - }, - { - "ImportPath": "golang.org/x/tools/go/vcs", - "Rev": "27e692e6ec36d8f48be794f32553e1400c70dbf2" - }, - { - "ImportPath": "google.golang.org/grpc", - "Rev": "5da22b92e9485c15a6b284d52cc54d6580864c99" - }, - { - "ImportPath": "google.golang.org/grpc/codes", - "Rev": "5da22b92e9485c15a6b284d52cc54d6580864c99" - }, - { - "ImportPath": "google.golang.org/grpc/credentials", - "Rev": "5da22b92e9485c15a6b284d52cc54d6580864c99" - }, - { - "ImportPath": "google.golang.org/grpc/grpclog", - "Rev": "5da22b92e9485c15a6b284d52cc54d6580864c99" - }, - { - "ImportPath": "google.golang.org/grpc/metadata", - "Rev": "5da22b92e9485c15a6b284d52cc54d6580864c99" - }, - { - "ImportPath": "google.golang.org/grpc/naming", - "Rev": "5da22b92e9485c15a6b284d52cc54d6580864c99" - }, - { - "ImportPath": "google.golang.org/grpc/peer", - "Rev": "5da22b92e9485c15a6b284d52cc54d6580864c99" - }, - { - "ImportPath": "google.golang.org/grpc/transport", - "Rev": "5da22b92e9485c15a6b284d52cc54d6580864c99" - }, - { - "ImportPath": "gopkg.in/inf.v0", - "Comment": "v0.9.0", - "Rev": "3887ee99ecf07df5b447e9b00d9c0b2adaa9f3e4" - }, - { - "ImportPath": "k8s.io/kubernetes/pkg/api/resource", - "Comment": "v1.3.0-alpha.4", - "Rev": "9990f843cd62caa90445cf76b07d63ba7b5c86fd" - }, - { - "ImportPath": "k8s.io/kubernetes/pkg/conversion", - "Comment": "v1.3.0-alpha.4", - "Rev": "9990f843cd62caa90445cf76b07d63ba7b5c86fd" - }, - { - "ImportPath": "k8s.io/kubernetes/third_party/forked/reflect", - "Comment": "v1.3.0-alpha.4", - "Rev": "9990f843cd62caa90445cf76b07d63ba7b5c86fd" - }, - { - "ImportPath": "github.com/klauspost/pgzip", - "Comment": "v1.0", - "Rev": "95e8170c5d4da28db9c64dfc9ec3138ea4466fd4" - }, - { - "ImportPath": "github.com/coreos/pkg/progressutil", - "Comment": "v2", - "Rev": "7f080b6c11ac2d2347c3cd7521e810207ea1a041" - }, - { - "ImportPath": "github.com/klauspost/compress/flate", - "Comment": "v1.0", - "Rev": "006acde2c5d283d2f8b8aa03d8f0cd2891c680cf" - }, - { - "ImportPath": "github.com/klauspost/crc32", - "Comment": "v1.0", - "Rev": "19b0b332c9e4516a6370a0456e6182c3b5036720" - }, - { - "ImportPath": "github.com/klauspost/cpuid", - "Comment": "v1.0", - "Rev": "09cded8978dc9e80714c4d85b0322337b0a1e5e0" - } - ] -} diff --git a/Godeps/Readme b/Godeps/Readme deleted file mode 100644 index 4cdaa53d56..0000000000 --- a/Godeps/Readme +++ /dev/null @@ -1,5 +0,0 @@ -This directory tree is generated automatically by godep. - -Please do not edit. - -See https://github.com/tools/godep for more information. diff --git a/Godeps/_workspace/.gitignore b/Godeps/_workspace/.gitignore deleted file mode 100644 index f037d684ef..0000000000 --- a/Godeps/_workspace/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/pkg -/bin diff --git a/Godeps/_workspace/src/github.com/StackExchange/wmi/LICENSE b/Godeps/_workspace/src/github.com/StackExchange/wmi/LICENSE deleted file mode 100644 index ae80b67209..0000000000 --- a/Godeps/_workspace/src/github.com/StackExchange/wmi/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2013 Stack Exchange - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Godeps/_workspace/src/github.com/StackExchange/wmi/README.md b/Godeps/_workspace/src/github.com/StackExchange/wmi/README.md deleted file mode 100644 index 3d5f67e149..0000000000 --- a/Godeps/_workspace/src/github.com/StackExchange/wmi/README.md +++ /dev/null @@ -1,4 +0,0 @@ -wmi -=== - -Package wmi provides a WQL interface for WMI on Windows. diff --git a/Godeps/_workspace/src/github.com/StackExchange/wmi/wmi.go b/Godeps/_workspace/src/github.com/StackExchange/wmi/wmi.go deleted file mode 100644 index b931ca57af..0000000000 --- a/Godeps/_workspace/src/github.com/StackExchange/wmi/wmi.go +++ /dev/null @@ -1,416 +0,0 @@ -// +build windows - -/* -Package wmi provides a WQL interface for WMI on Windows. - -Example code to print names of running processes: - - type Win32_Process struct { - Name string - } - - func main() { - var dst []Win32_Process - q := wmi.CreateQuery(&dst, "") - err := wmi.Query(q, &dst) - if err != nil { - log.Fatal(err) - } - for i, v := range dst { - println(i, v.Name) - } - } - -*/ -package wmi - -import ( - "bytes" - "errors" - "fmt" - "log" - "os" - "reflect" - "runtime" - "strconv" - "strings" - "sync" - "time" - - "github.com/go-ole/go-ole" - "github.com/go-ole/go-ole/oleutil" -) - -var l = log.New(os.Stdout, "", log.LstdFlags) - -var ( - ErrInvalidEntityType = errors.New("wmi: invalid entity type") - lock sync.Mutex -) - -// QueryNamespace invokes Query with the given namespace on the local machine. -func QueryNamespace(query string, dst interface{}, namespace string) error { - return Query(query, dst, nil, namespace) -} - -// Query runs the WQL query and appends the values to dst. -// -// dst must have type *[]S or *[]*S, for some struct type S. Fields selected in -// the query must have the same name in dst. Supported types are all signed and -// unsigned integers, time.Time, string, bool, or a pointer to one of those. -// Array types are not supported. -// -// By default, the local machine and default namespace are used. These can be -// changed using connectServerArgs. See -// http://msdn.microsoft.com/en-us/library/aa393720.aspx for details. -// -// Query is a wrapper around DefaultClient.Query. -func Query(query string, dst interface{}, connectServerArgs ...interface{}) error { - return DefaultClient.Query(query, dst, connectServerArgs...) -} - -// A Client is an WMI query client. -// -// Its zero value (DefaultClient) is a usable client. -type Client struct { - // NonePtrZero specifies if nil values for fields which aren't pointers - // should be returned as the field types zero value. - // - // Setting this to true allows stucts without pointer fields to be used - // without the risk failure should a nil value returned from WMI. - NonePtrZero bool - - // PtrNil specifies if nil values for pointer fields should be returned - // as nil. - // - // Setting this to true will set pointer fields to nil where WMI - // returned nil, otherwise the types zero value will be returned. - PtrNil bool - - // AllowMissingFields specifies that struct fields not present in the - // query result should not result in an error. - // - // Setting this to true allows custom queries to be used with full - // struct definitions instead of having to define multiple structs. - AllowMissingFields bool -} - -// DefaultClient is the default Client and is used by Query, QueryNamespace -var DefaultClient = &Client{} - -// Query runs the WQL query and appends the values to dst. -// -// dst must have type *[]S or *[]*S, for some struct type S. Fields selected in -// the query must have the same name in dst. Supported types are all signed and -// unsigned integers, time.Time, string, bool, or a pointer to one of those. -// Array types are not supported. -// -// By default, the local machine and default namespace are used. These can be -// changed using connectServerArgs. See -// http://msdn.microsoft.com/en-us/library/aa393720.aspx for details. -func (c *Client) Query(query string, dst interface{}, connectServerArgs ...interface{}) error { - dv := reflect.ValueOf(dst) - if dv.Kind() != reflect.Ptr || dv.IsNil() { - return ErrInvalidEntityType - } - dv = dv.Elem() - mat, elemType := checkMultiArg(dv) - if mat == multiArgTypeInvalid { - return ErrInvalidEntityType - } - - lock.Lock() - defer lock.Unlock() - runtime.LockOSThread() - defer runtime.UnlockOSThread() - - err := ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED) - if err != nil { - oleerr := err.(*ole.OleError) - // S_FALSE = 0x00000001 // CoInitializeEx was already called on this thread - if oleerr.Code() != ole.S_OK && oleerr.Code() != 0x00000001 { - return err - } - } else { - // Only invoke CoUninitialize if the thread was not initizlied before. - // This will allow other go packages based on go-ole play along - // with this library. - defer ole.CoUninitialize() - } - - unknown, err := oleutil.CreateObject("WbemScripting.SWbemLocator") - if err != nil { - return err - } - defer unknown.Release() - - wmi, err := unknown.QueryInterface(ole.IID_IDispatch) - if err != nil { - return err - } - defer wmi.Release() - - // service is a SWbemServices - serviceRaw, err := oleutil.CallMethod(wmi, "ConnectServer", connectServerArgs...) - if err != nil { - return err - } - service := serviceRaw.ToIDispatch() - defer serviceRaw.Clear() - - // result is a SWBemObjectSet - resultRaw, err := oleutil.CallMethod(service, "ExecQuery", query) - if err != nil { - return err - } - result := resultRaw.ToIDispatch() - defer resultRaw.Clear() - - count, err := oleInt64(result, "Count") - if err != nil { - return err - } - - // Initialize a slice with Count capacity - dv.Set(reflect.MakeSlice(dv.Type(), 0, int(count))) - - var errFieldMismatch error - for i := int64(0); i < count; i++ { - err := func() error { - // item is a SWbemObject, but really a Win32_Process - itemRaw, err := oleutil.CallMethod(result, "ItemIndex", i) - if err != nil { - return err - } - item := itemRaw.ToIDispatch() - defer itemRaw.Clear() - - ev := reflect.New(elemType) - if err = c.loadEntity(ev.Interface(), item); err != nil { - if _, ok := err.(*ErrFieldMismatch); ok { - // We continue loading entities even in the face of field mismatch errors. - // If we encounter any other error, that other error is returned. Otherwise, - // an ErrFieldMismatch is returned. - errFieldMismatch = err - } else { - return err - } - } - if mat != multiArgTypeStructPtr { - ev = ev.Elem() - } - dv.Set(reflect.Append(dv, ev)) - return nil - }() - if err != nil { - return err - } - } - return errFieldMismatch -} - -// ErrFieldMismatch is returned when a field is to be loaded into a different -// type than the one it was stored from, or when a field is missing or -// unexported in the destination struct. -// StructType is the type of the struct pointed to by the destination argument. -type ErrFieldMismatch struct { - StructType reflect.Type - FieldName string - Reason string -} - -func (e *ErrFieldMismatch) Error() string { - return fmt.Sprintf("wmi: cannot load field %q into a %q: %s", - e.FieldName, e.StructType, e.Reason) -} - -var timeType = reflect.TypeOf(time.Time{}) - -// loadEntity loads a SWbemObject into a struct pointer. -func (c *Client) loadEntity(dst interface{}, src *ole.IDispatch) (errFieldMismatch error) { - v := reflect.ValueOf(dst).Elem() - for i := 0; i < v.NumField(); i++ { - f := v.Field(i) - of := f - isPtr := f.Kind() == reflect.Ptr - if isPtr { - ptr := reflect.New(f.Type().Elem()) - f.Set(ptr) - f = f.Elem() - } - n := v.Type().Field(i).Name - if !f.CanSet() { - return &ErrFieldMismatch{ - StructType: of.Type(), - FieldName: n, - Reason: "CanSet() is false", - } - } - prop, err := oleutil.GetProperty(src, n) - if err != nil { - if !c.AllowMissingFields { - errFieldMismatch = &ErrFieldMismatch{ - StructType: of.Type(), - FieldName: n, - Reason: "no such struct field", - } - } - continue - } - defer prop.Clear() - - switch val := prop.Value().(type) { - case int8, int16, int32, int64, int: - v := reflect.ValueOf(val).Int() - switch f.Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - f.SetInt(v) - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - f.SetUint(uint64(v)) - default: - return &ErrFieldMismatch{ - StructType: of.Type(), - FieldName: n, - Reason: "not an integer class", - } - } - case uint8, uint16, uint32, uint64: - v := reflect.ValueOf(val).Uint() - switch f.Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - f.SetInt(int64(v)) - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - f.SetUint(v) - default: - return &ErrFieldMismatch{ - StructType: of.Type(), - FieldName: n, - Reason: "not an integer class", - } - } - case string: - switch f.Kind() { - case reflect.String: - f.SetString(val) - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - iv, err := strconv.ParseInt(val, 10, 64) - if err != nil { - return err - } - f.SetInt(iv) - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - uv, err := strconv.ParseUint(val, 10, 64) - if err != nil { - return err - } - f.SetUint(uv) - case reflect.Struct: - switch f.Type() { - case timeType: - if len(val) == 25 { - mins, err := strconv.Atoi(val[22:]) - if err != nil { - return err - } - val = val[:22] + fmt.Sprintf("%02d%02d", mins/60, mins%60) - } - t, err := time.Parse("20060102150405.000000-0700", val) - if err != nil { - return err - } - f.Set(reflect.ValueOf(t)) - } - } - case bool: - switch f.Kind() { - case reflect.Bool: - f.SetBool(val) - default: - return &ErrFieldMismatch{ - StructType: of.Type(), - FieldName: n, - Reason: "not a bool", - } - } - default: - typeof := reflect.TypeOf(val) - if typeof == nil && (isPtr || c.NonePtrZero) { - if (isPtr && c.PtrNil) || (!isPtr && c.NonePtrZero) { - of.Set(reflect.Zero(of.Type())) - } - break - } - return &ErrFieldMismatch{ - StructType: of.Type(), - FieldName: n, - Reason: fmt.Sprintf("unsupported type (%T)", val), - } - } - } - return errFieldMismatch -} - -type multiArgType int - -const ( - multiArgTypeInvalid multiArgType = iota - multiArgTypeStruct - multiArgTypeStructPtr -) - -// checkMultiArg checks that v has type []S, []*S for some struct type S. -// -// It returns what category the slice's elements are, and the reflect.Type -// that represents S. -func checkMultiArg(v reflect.Value) (m multiArgType, elemType reflect.Type) { - if v.Kind() != reflect.Slice { - return multiArgTypeInvalid, nil - } - elemType = v.Type().Elem() - switch elemType.Kind() { - case reflect.Struct: - return multiArgTypeStruct, elemType - case reflect.Ptr: - elemType = elemType.Elem() - if elemType.Kind() == reflect.Struct { - return multiArgTypeStructPtr, elemType - } - } - return multiArgTypeInvalid, nil -} - -func oleInt64(item *ole.IDispatch, prop string) (int64, error) { - v, err := oleutil.GetProperty(item, prop) - if err != nil { - return 0, err - } - defer v.Clear() - - i := int64(v.Val) - return i, nil -} - -// CreateQuery returns a WQL query string that queries all columns of src. where -// is an optional string that is appended to the query, to be used with WHERE -// clauses. In such a case, the "WHERE" string should appear at the beginning. -func CreateQuery(src interface{}, where string) string { - var b bytes.Buffer - b.WriteString("SELECT ") - s := reflect.Indirect(reflect.ValueOf(src)) - t := s.Type() - if s.Kind() == reflect.Slice { - t = t.Elem() - } - if t.Kind() != reflect.Struct { - return "" - } - var fields []string - for i := 0; i < t.NumField(); i++ { - fields = append(fields, t.Field(i).Name) - } - b.WriteString(strings.Join(fields, ", ")) - b.WriteString(" FROM ") - b.WriteString(t.Name()) - b.WriteString(" " + where) - return b.String() -} diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/LICENSE b/Godeps/_workspace/src/github.com/appc/docker2aci/LICENSE deleted file mode 100644 index e06d208186..0000000000 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor 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, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/common/common.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/common/common.go deleted file mode 100644 index 5fd1d46050..0000000000 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/common/common.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2016 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package common provides misc types and variables. -package common - -import ( - "github.com/appc/docker2aci/lib/internal/docker" - "github.com/appc/docker2aci/lib/internal/types" -) - -type Compression int - -const ( - NoCompression = iota - GzipCompression -) - -type ParsedDockerURL types.ParsedDockerURL - -const ( - AppcDockerRegistryURL = "appc.io/docker/registryurl" - AppcDockerRepository = "appc.io/docker/repository" - AppcDockerTag = "appc.io/docker/tag" - AppcDockerImageID = "appc.io/docker/imageid" - AppcDockerParentImageID = "appc.io/docker/parentimageid" - AppcDockerEntrypoint = "appc.io/docker/entrypoint" - AppcDockerCmd = "appc.io/docker/cmd" -) - -type ErrSeveralImages struct { - Msg string - Images []string -} - -// InsecureConfig represents the different insecure options available -type InsecureConfig struct { - SkipVerify bool - AllowHTTP bool -} - -func (e *ErrSeveralImages) Error() string { - return e.Msg -} - -// ParseDockerURL takes a Docker URL and returns a ParsedDockerURL with its -// index URL, image name, and tag. -func ParseDockerURL(arg string) (*ParsedDockerURL, error) { - p, err := docker.ParseDockerURL(arg) - return (*ParsedDockerURL)(p), err -} diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/conversion_store.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/conversion_store.go deleted file mode 100644 index 4944f1386a..0000000000 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/conversion_store.go +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package docker2aci - -import ( - "crypto/sha512" - "fmt" - "hash" - "io" - "io/ioutil" - "os" - - "github.com/appc/spec/aci" - "github.com/appc/spec/schema" - "github.com/appc/spec/schema/types" -) - -const ( - hashPrefix = "sha512-" -) - -type aciInfo struct { - path string - key string - ImageManifest *schema.ImageManifest -} - -// conversionStore is an simple implementation of the acirenderer.ACIRegistry -// interface. It stores the Docker layers converted to ACI so we can take -// advantage of acirenderer to generate a squashed ACI Image. -type conversionStore struct { - acis map[string]*aciInfo -} - -func newConversionStore() *conversionStore { - return &conversionStore{acis: make(map[string]*aciInfo)} -} - -func (ms *conversionStore) WriteACI(path string) (string, error) { - f, err := os.Open(path) - if err != nil { - return "", err - } - defer f.Close() - - cr, err := aci.NewCompressedReader(f) - if err != nil { - return "", err - } - defer cr.Close() - - h := sha512.New() - r := io.TeeReader(cr, h) - - // read the file so we can get the hash - if _, err := io.Copy(ioutil.Discard, r); err != nil { - return "", fmt.Errorf("error reading ACI: %v", err) - } - - im, err := aci.ManifestFromImage(f) - if err != nil { - return "", err - } - - key := ms.HashToKey(h) - ms.acis[key] = &aciInfo{path: path, key: key, ImageManifest: im} - return key, nil -} - -func (ms *conversionStore) GetImageManifest(key string) (*schema.ImageManifest, error) { - aci, ok := ms.acis[key] - if !ok { - return nil, fmt.Errorf("aci with key: %s not found", key) - } - return aci.ImageManifest, nil -} - -func (ms *conversionStore) GetACI(name types.ACIdentifier, labels types.Labels) (string, error) { - for _, aci := range ms.acis { - // we implement this function to comply with the interface so don't - // bother implementing a proper label check - if aci.ImageManifest.Name.String() == name.String() { - return aci.key, nil - } - } - return "", fmt.Errorf("aci not found") -} - -func (ms *conversionStore) ReadStream(key string) (io.ReadCloser, error) { - img, ok := ms.acis[key] - if !ok { - return nil, fmt.Errorf("stream for key: %s not found", key) - } - f, err := os.Open(img.path) - if err != nil { - return nil, fmt.Errorf("error opening aci: %s", img.path) - } - - tr, err := aci.NewCompressedReader(f) - if err != nil { - return nil, err - } - - return tr, nil -} - -func (ms *conversionStore) ResolveKey(key string) (string, error) { - return key, nil -} - -func (ms *conversionStore) HashToKey(h hash.Hash) string { - s := h.Sum(nil) - return fmt.Sprintf("%s%x", hashPrefix, s) -} diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/docker2aci.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/docker2aci.go deleted file mode 100644 index 4cb0ecc9aa..0000000000 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/docker2aci.go +++ /dev/null @@ -1,417 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package docker2aci implements a simple library for converting docker images to -// App Container Images (ACIs). -package docker2aci - -import ( - "archive/tar" - "fmt" - "io" - "io/ioutil" - "os" - "path/filepath" - "strings" - - "github.com/appc/docker2aci/lib/common" - "github.com/appc/docker2aci/lib/internal" - "github.com/appc/docker2aci/lib/internal/backend/file" - "github.com/appc/docker2aci/lib/internal/backend/repository" - "github.com/appc/docker2aci/lib/internal/docker" - "github.com/appc/docker2aci/lib/internal/tarball" - "github.com/appc/docker2aci/lib/internal/types" - "github.com/appc/docker2aci/lib/internal/util" - "github.com/appc/docker2aci/pkg/log" - "github.com/appc/spec/pkg/acirenderer" - "github.com/appc/spec/schema" - appctypes "github.com/appc/spec/schema/types" - gzip "github.com/klauspost/pgzip" -) - -// CommonConfig represents the shared configuration options for converting -// Docker images. -type CommonConfig struct { - Squash bool // squash the layers in one file - OutputDir string // where to put the resulting ACI - TmpDir string // directory to use for temporary files - Compression common.Compression // which compression to use for the resulting file(s) -} - -// RemoteConfig represents the remote repository specific configuration for -// converting Docker images. -type RemoteConfig struct { - CommonConfig - Username string // username to use if the image to convert needs authentication - Password string // password to use if the image to convert needs authentication - Insecure common.InsecureConfig // Insecure options -} - -// FileConfig represents the saved file specific configuration for converting -// Docker images. -type FileConfig struct { - CommonConfig - DockerURL string // select an image if there are several images/tags in the file, Syntax: "{docker registry URL}/{image name}:{tag}" -} - -// ConvertRemoteRepo generates ACI images from docker registry URLs. It takes -// as input a dockerURL of the form: -// -// {registry URL}/{repository}:{reference[tag|digest]} -// -// It then gets all the layers of the requested image and converts each of -// them to ACI. -// It returns the list of generated ACI paths. -func ConvertRemoteRepo(dockerURL string, config RemoteConfig) ([]string, error) { - repositoryBackend := repository.NewRepositoryBackend(config.Username, config.Password, config.Insecure) - return convertReal(repositoryBackend, dockerURL, config.Squash, config.OutputDir, config.TmpDir, config.Compression) -} - -// ConvertSavedFile generates ACI images from a file generated with "docker -// save". If there are several images/tags in the file, a particular image can -// be chosen via FileConfig.DockerURL. -// -// It returns the list of generated ACI paths. -func ConvertSavedFile(dockerSavedFile string, config FileConfig) ([]string, error) { - f, err := os.Open(dockerSavedFile) - if err != nil { - return nil, fmt.Errorf("error opening file: %v", err) - } - defer f.Close() - - fileBackend := file.NewFileBackend(f) - return convertReal(fileBackend, config.DockerURL, config.Squash, config.OutputDir, config.TmpDir, config.Compression) -} - -// GetIndexName returns the docker index server from a docker URL. -func GetIndexName(dockerURL string) string { - index, _ := docker.SplitReposName(dockerURL) - return index -} - -// GetDockercfgAuth reads a ~/.dockercfg file and returns the username and password -// of the given docker index server. -func GetDockercfgAuth(indexServer string) (string, string, error) { - return docker.GetAuthInfo(indexServer) -} - -func convertReal(backend internal.Docker2ACIBackend, dockerURL string, squash bool, outputDir string, tmpDir string, compression common.Compression) ([]string, error) { - log.Debug("Getting image info...") - ancestry, parsedDockerURL, err := backend.GetImageInfo(dockerURL) - if err != nil { - return nil, err - } - - layersOutputDir := outputDir - if squash { - layersOutputDir, err = ioutil.TempDir(tmpDir, "docker2aci-") - if err != nil { - return nil, fmt.Errorf("error creating dir: %v", err) - } - defer os.RemoveAll(layersOutputDir) - } - - conversionStore := newConversionStore() - - // only compress individual layers if we're not squashing - layerCompression := compression - if squash { - layerCompression = common.NoCompression - } - - aciLayerPaths, aciManifests, err := backend.BuildACI(ancestry, parsedDockerURL, layersOutputDir, tmpDir, layerCompression) - if err != nil { - return nil, err - } - - var images acirenderer.Images - for i, aciLayerPath := range aciLayerPaths { - key, err := conversionStore.WriteACI(aciLayerPath) - if err != nil { - return nil, fmt.Errorf("error inserting in the conversion store: %v", err) - } - - images = append(images, acirenderer.Image{Im: aciManifests[i], Key: key, Level: uint16(len(aciLayerPaths) - 1 - i)}) - } - - // acirenderer expects images in order from upper to base layer - images = util.ReverseImages(images) - if squash { - squashedImagePath, err := squashLayers(images, conversionStore, *parsedDockerURL, outputDir, compression) - if err != nil { - return nil, fmt.Errorf("error squashing image: %v", err) - } - aciLayerPaths = []string{squashedImagePath} - } - - return aciLayerPaths, nil -} - -// squashLayers receives a list of ACI layer file names ordered from base image -// to application image and squashes them into one ACI -func squashLayers(images []acirenderer.Image, aciRegistry acirenderer.ACIRegistry, parsedDockerURL types.ParsedDockerURL, outputDir string, compression common.Compression) (path string, err error) { - log.Debug("Squashing layers...") - log.Debug("Rendering ACI...") - renderedACI, err := acirenderer.GetRenderedACIFromList(images, aciRegistry) - if err != nil { - return "", fmt.Errorf("error rendering squashed image: %v", err) - } - manifests, err := getManifests(renderedACI, aciRegistry) - if err != nil { - return "", fmt.Errorf("error getting manifests: %v", err) - } - - squashedFilename := getSquashedFilename(parsedDockerURL) - squashedImagePath := filepath.Join(outputDir, squashedFilename) - - squashedTempFile, err := ioutil.TempFile(outputDir, "docker2aci-squashedFile-") - if err != nil { - return "", err - } - defer func() { - if err == nil { - err = squashedTempFile.Close() - } else { - // remove temp file on error - // we ignore its error to not mask the real error - os.Remove(squashedTempFile.Name()) - } - }() - - log.Debug("Writing squashed ACI...") - if err := writeSquashedImage(squashedTempFile, renderedACI, aciRegistry, manifests, compression); err != nil { - return "", fmt.Errorf("error writing squashed image: %v", err) - } - - log.Debug("Validating squashed ACI...") - if err := internal.ValidateACI(squashedTempFile.Name()); err != nil { - return "", fmt.Errorf("error validating image: %v", err) - } - - if err := os.Rename(squashedTempFile.Name(), squashedImagePath); err != nil { - return "", err - } - - log.Debug("ACI squashed!") - return squashedImagePath, nil -} - -func getSquashedFilename(parsedDockerURL types.ParsedDockerURL) string { - squashedFilename := strings.Replace(parsedDockerURL.ImageName, "/", "-", -1) - if parsedDockerURL.Tag != "" { - squashedFilename += "-" + parsedDockerURL.Tag - } - squashedFilename += ".aci" - - return squashedFilename -} - -func getManifests(renderedACI acirenderer.RenderedACI, aciRegistry acirenderer.ACIRegistry) ([]schema.ImageManifest, error) { - var manifests []schema.ImageManifest - - for _, aci := range renderedACI { - im, err := aciRegistry.GetImageManifest(aci.Key) - if err != nil { - return nil, err - } - manifests = append(manifests, *im) - } - - return manifests, nil -} - -func writeSquashedImage(outputFile *os.File, renderedACI acirenderer.RenderedACI, aciProvider acirenderer.ACIProvider, manifests []schema.ImageManifest, compression common.Compression) error { - var tarWriterTarget io.WriteCloser = outputFile - - switch compression { - case common.NoCompression: - case common.GzipCompression: - tarWriterTarget = gzip.NewWriter(outputFile) - defer tarWriterTarget.Close() - default: - return fmt.Errorf("unexpected compression enum value: %d", compression) - } - - outputWriter := tar.NewWriter(tarWriterTarget) - defer outputWriter.Close() - - finalManifest := mergeManifests(manifests) - - if err := internal.WriteManifest(outputWriter, finalManifest); err != nil { - return err - } - - if err := internal.WriteRootfsDir(outputWriter); err != nil { - return err - } - - type hardLinkEntry struct { - firstLinkCleanName string - firstLinkHeader tar.Header - keepOriginal bool - walked bool - } - // map aciFileKey -> cleanTarget -> hardLinkEntry - hardLinks := make(map[string]map[string]hardLinkEntry) - - // first pass: read all the entries and build the hardLinks map in memory - // but don't write on disk - for _, aciFile := range renderedACI { - rs, err := aciProvider.ReadStream(aciFile.Key) - if err != nil { - return err - } - defer rs.Close() - - hardLinks[aciFile.Key] = map[string]hardLinkEntry{} - - squashWalker := func(t *tarball.TarFile) error { - cleanName := filepath.Clean(t.Name()) - // the rootfs and the squashed manifest are added separately - if cleanName == "manifest" || cleanName == "rootfs" { - return nil - } - _, keep := aciFile.FileMap[cleanName] - if keep && t.Header.Typeflag == tar.TypeLink { - cleanTarget := filepath.Clean(t.Linkname()) - if _, ok := hardLinks[aciFile.Key][cleanTarget]; !ok { - _, keepOriginal := aciFile.FileMap[cleanTarget] - hardLinks[aciFile.Key][cleanTarget] = hardLinkEntry{cleanName, *t.Header, keepOriginal, false} - } - } - return nil - } - - tr := tar.NewReader(rs) - if err := tarball.Walk(*tr, squashWalker); err != nil { - return err - } - } - - // second pass: write on disk - for _, aciFile := range renderedACI { - rs, err := aciProvider.ReadStream(aciFile.Key) - if err != nil { - return err - } - defer rs.Close() - - squashWalker := func(t *tarball.TarFile) error { - cleanName := filepath.Clean(t.Name()) - // the rootfs and the squashed manifest are added separately - if cleanName == "manifest" || cleanName == "rootfs" { - return nil - } - _, keep := aciFile.FileMap[cleanName] - - if link, ok := hardLinks[aciFile.Key][cleanName]; ok { - if keep != link.keepOriginal { - return fmt.Errorf("logic error: should we keep file %q?", cleanName) - } - if keep { - if err := outputWriter.WriteHeader(t.Header); err != nil { - return fmt.Errorf("error writing header: %v", err) - } - if _, err := io.Copy(outputWriter, t.TarStream); err != nil { - return fmt.Errorf("error copying file into the tar out: %v", err) - } - } else { - // The current file does not remain but there is a hard link pointing to - // it. Write the current file but with the filename of the first hard link - // pointing to it. That first hard link will not be written later, see - // variable "alreadyWritten". - link.firstLinkHeader.Size = t.Header.Size - link.firstLinkHeader.Typeflag = t.Header.Typeflag - link.firstLinkHeader.Linkname = "" - - if err := outputWriter.WriteHeader(&link.firstLinkHeader); err != nil { - return fmt.Errorf("error writing header: %v", err) - } - if _, err := io.Copy(outputWriter, t.TarStream); err != nil { - return fmt.Errorf("error copying file into the tar out: %v", err) - } - } - } else if keep { - alreadyWritten := false - if t.Header.Typeflag == tar.TypeLink { - cleanTarget := filepath.Clean(t.Linkname()) - if link, ok := hardLinks[aciFile.Key][cleanTarget]; ok { - if !link.keepOriginal { - if link.walked { - t.Header.Linkname = link.firstLinkCleanName - } else { - alreadyWritten = true - } - } - link.walked = true - hardLinks[aciFile.Key][cleanTarget] = link - } - } - - if !alreadyWritten { - if err := outputWriter.WriteHeader(t.Header); err != nil { - return fmt.Errorf("error writing header: %v", err) - } - if _, err := io.Copy(outputWriter, t.TarStream); err != nil { - return fmt.Errorf("error copying file into the tar out: %v", err) - } - } - } - return nil - } - - tr := tar.NewReader(rs) - if err := tarball.Walk(*tr, squashWalker); err != nil { - return err - } - } - - return nil -} - -func mergeManifests(manifests []schema.ImageManifest) schema.ImageManifest { - // FIXME(iaguis) we take app layer's manifest as the final manifest for now - manifest := manifests[0] - - manifest.Dependencies = nil - - layerIndex := -1 - for i, l := range manifest.Labels { - if l.Name.String() == "layer" { - layerIndex = i - } - } - - if layerIndex != -1 { - manifest.Labels = append(manifest.Labels[:layerIndex], manifest.Labels[layerIndex+1:]...) - } - - nameWithoutLayerID := appctypes.MustACIdentifier(stripLayerID(manifest.Name.String())) - - manifest.Name = *nameWithoutLayerID - - // once the image is squashed, we don't need a pathWhitelist - manifest.PathWhitelist = nil - - return manifest -} - -// striplayerID strips the layer ID from an app name: -// -// myregistry.com/organization/app-name-85738f8f9a7f1b04b5329c590ebcb9e425925c6d0984089c43a022de4f19c281 -// myregistry.com/organization/app-name -func stripLayerID(layerName string) string { - n := strings.LastIndex(layerName, "-") - return layerName[:n] -} diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/file/file.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/file/file.go deleted file mode 100644 index a83402dfcd..0000000000 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/file/file.go +++ /dev/null @@ -1,332 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package file is an implementation of Docker2ACIBackend for files saved via -// "docker save". -// -// Note: this package is an implementation detail and shouldn't be used outside -// of docker2aci. -package file - -import ( - "archive/tar" - "encoding/json" - "fmt" - "io" - "io/ioutil" - "os" - "path" - "path/filepath" - - "github.com/appc/docker2aci/lib/common" - "github.com/appc/docker2aci/lib/internal" - "github.com/appc/docker2aci/lib/internal/docker" - "github.com/appc/docker2aci/lib/internal/tarball" - "github.com/appc/docker2aci/lib/internal/types" - "github.com/appc/docker2aci/pkg/log" - "github.com/appc/spec/schema" -) - -type FileBackend struct { - file *os.File -} - -func NewFileBackend(file *os.File) *FileBackend { - return &FileBackend{ - file: file, - } -} - -func (lb *FileBackend) GetImageInfo(dockerURL string) ([]string, *types.ParsedDockerURL, error) { - parsedDockerURL, err := docker.ParseDockerURL(dockerURL) - if err != nil { - // a missing Docker URL could mean that the file only contains one - // image, so we ignore the error here, we'll handle it in getImageID - } - - appImageID, parsedDockerURL, err := getImageID(lb.file, parsedDockerURL) - if err != nil { - return nil, nil, err - } - - ancestry, err := getAncestry(lb.file, appImageID) - if err != nil { - return nil, nil, fmt.Errorf("error getting ancestry: %v", err) - } - - return ancestry, parsedDockerURL, nil -} - -func (lb *FileBackend) BuildACI(layerIDs []string, dockerURL *types.ParsedDockerURL, outputDir string, tmpBaseDir string, compression common.Compression) ([]string, []*schema.ImageManifest, error) { - var aciLayerPaths []string - var aciManifests []*schema.ImageManifest - var curPwl []string - for i := len(layerIDs) - 1; i >= 0; i-- { - tmpDir, err := ioutil.TempDir(tmpBaseDir, "docker2aci-") - if err != nil { - return nil, nil, fmt.Errorf("error creating dir: %v", err) - } - defer os.RemoveAll(tmpDir) - - j, err := getJson(lb.file, layerIDs[i]) - if err != nil { - return nil, nil, fmt.Errorf("error getting image json: %v", err) - } - - layerData := types.DockerImageData{} - if err := json.Unmarshal(j, &layerData); err != nil { - return nil, nil, fmt.Errorf("error unmarshaling layer data: %v", err) - } - - tmpLayerPath := path.Join(tmpDir, layerIDs[i]) - tmpLayerPath += ".tar" - - layerFile, err := extractEmbeddedLayer(lb.file, layerIDs[i], tmpLayerPath) - if err != nil { - return nil, nil, fmt.Errorf("error getting layer from file: %v", err) - } - defer layerFile.Close() - - log.Debug("Generating layer ACI...") - aciPath, manifest, err := internal.GenerateACI(i, layerData, dockerURL, outputDir, layerFile, curPwl, compression) - if err != nil { - return nil, nil, fmt.Errorf("error generating ACI: %v", err) - } - - aciLayerPaths = append(aciLayerPaths, aciPath) - aciManifests = append(aciManifests, manifest) - curPwl = manifest.PathWhitelist - } - - return aciLayerPaths, aciManifests, nil -} - -func getImageID(file *os.File, dockerURL *types.ParsedDockerURL) (string, *types.ParsedDockerURL, error) { - type tags map[string]string - type apps map[string]tags - - _, err := file.Seek(0, 0) - if err != nil { - return "", nil, fmt.Errorf("error seeking file: %v", err) - } - - var imageID string - var appName string - reposWalker := func(t *tarball.TarFile) error { - if filepath.Clean(t.Name()) == "repositories" { - repob, err := ioutil.ReadAll(t.TarStream) - if err != nil { - return fmt.Errorf("error reading repositories file: %v", err) - } - - var repositories apps - if err := json.Unmarshal(repob, &repositories); err != nil { - return fmt.Errorf("error unmarshaling repositories file") - } - - if dockerURL == nil { - n := len(repositories) - switch { - case n == 1: - for key, _ := range repositories { - appName = key - } - case n > 1: - var appNames []string - for key, _ := range repositories { - appNames = append(appNames, key) - } - return &common.ErrSeveralImages{ - Msg: "several images found", - Images: appNames, - } - default: - return fmt.Errorf("no images found") - } - } else { - appName = dockerURL.ImageName - } - - tag := "latest" - if dockerURL != nil { - tag = dockerURL.Tag - } - - app, ok := repositories[appName] - if !ok { - return fmt.Errorf("app %q not found", appName) - } - - _, ok = app[tag] - if !ok { - if len(app) == 1 { - for key, _ := range app { - tag = key - } - } else { - return fmt.Errorf("tag %q not found", tag) - } - } - - if dockerURL == nil { - dockerURL = &types.ParsedDockerURL{ - IndexURL: "", - Tag: tag, - ImageName: appName, - } - } - - imageID = string(app[tag]) - } - - return nil - } - - tr := tar.NewReader(file) - if err := tarball.Walk(*tr, reposWalker); err != nil { - return "", nil, err - } - - if imageID == "" { - return "", nil, fmt.Errorf("repositories file not found") - } - - return imageID, dockerURL, nil -} - -func getJson(file *os.File, layerID string) ([]byte, error) { - jsonPath := path.Join(layerID, "json") - return getTarFileBytes(file, jsonPath) -} - -func getTarFileBytes(file *os.File, path string) ([]byte, error) { - _, err := file.Seek(0, 0) - if err != nil { - fmt.Errorf("error seeking file: %v", err) - } - - var fileBytes []byte - fileWalker := func(t *tarball.TarFile) error { - if filepath.Clean(t.Name()) == path { - fileBytes, err = ioutil.ReadAll(t.TarStream) - if err != nil { - return err - } - } - - return nil - } - - tr := tar.NewReader(file) - if err := tarball.Walk(*tr, fileWalker); err != nil { - return nil, err - } - - if fileBytes == nil { - return nil, fmt.Errorf("file %q not found", path) - } - - return fileBytes, nil -} - -func extractEmbeddedLayer(file *os.File, layerID string, outputPath string) (*os.File, error) { - log.Info("Extracting ", layerID[:12], "\n") - - _, err := file.Seek(0, 0) - if err != nil { - fmt.Errorf("error seeking file: %v", err) - } - - layerTarPath := path.Join(layerID, "layer.tar") - - var layerFile *os.File - fileWalker := func(t *tarball.TarFile) error { - if filepath.Clean(t.Name()) == layerTarPath { - layerFile, err = os.Create(outputPath) - if err != nil { - return fmt.Errorf("error creating layer: %v", err) - } - - _, err = io.Copy(layerFile, t.TarStream) - if err != nil { - return fmt.Errorf("error getting layer: %v", err) - } - } - - return nil - } - - tr := tar.NewReader(file) - if err := tarball.Walk(*tr, fileWalker); err != nil { - return nil, err - } - - if layerFile == nil { - return nil, fmt.Errorf("file %q not found", layerTarPath) - } - - return layerFile, nil -} - -func getAncestry(file *os.File, imgID string) ([]string, error) { - var ancestry []string - - curImgID := imgID - - var err error - for curImgID != "" { - ancestry = append(ancestry, curImgID) - curImgID, err = getParent(file, curImgID) - if err != nil { - return nil, err - } - } - - return ancestry, nil -} - -func getParent(file *os.File, imgID string) (string, error) { - var parent string - - _, err := file.Seek(0, 0) - if err != nil { - return "", fmt.Errorf("error seeking file: %v", err) - } - - jsonPath := filepath.Join(imgID, "json") - parentWalker := func(t *tarball.TarFile) error { - if filepath.Clean(t.Name()) == jsonPath { - jsonb, err := ioutil.ReadAll(t.TarStream) - if err != nil { - return fmt.Errorf("error reading layer json: %v", err) - } - - var dockerData types.DockerImageData - if err := json.Unmarshal(jsonb, &dockerData); err != nil { - return fmt.Errorf("error unmarshaling layer data: %v", err) - } - - parent = dockerData.Parent - } - - return nil - } - - tr := tar.NewReader(file) - if err := tarball.Walk(*tr, parentWalker); err != nil { - return "", err - } - - return parent, nil -} diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository.go deleted file mode 100644 index 57533857a1..0000000000 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository.go +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package repository is an implementation of Docker2ACIBackend for Docker -// remote registries. -// -// Note: this package is an implementation detail and shouldn't be used outside -// of docker2aci. -package repository - -import ( - "fmt" - "net/http" - "path" - - "github.com/appc/docker2aci/lib/common" - "github.com/appc/docker2aci/lib/internal/docker" - "github.com/appc/docker2aci/lib/internal/types" - "github.com/appc/docker2aci/lib/internal/util" - "github.com/appc/spec/schema" -) - -type registryVersion int - -const ( - registryV1 registryVersion = iota - registryV2 -) - -type RepositoryBackend struct { - repoData *RepoData - username string - password string - insecure common.InsecureConfig - hostsV2Support map[string]bool - hostsV2AuthTokens map[string]map[string]string - schema string - imageManifests map[types.ParsedDockerURL]v2Manifest -} - -func NewRepositoryBackend(username string, password string, insecure common.InsecureConfig) *RepositoryBackend { - return &RepositoryBackend{ - username: username, - password: password, - insecure: insecure, - hostsV2Support: make(map[string]bool), - hostsV2AuthTokens: make(map[string]map[string]string), - imageManifests: make(map[types.ParsedDockerURL]v2Manifest), - } -} - -func (rb *RepositoryBackend) GetImageInfo(url string) ([]string, *types.ParsedDockerURL, error) { - dockerURL, err := docker.ParseDockerURL(url) - if err != nil { - return nil, nil, err - } - - var supportsV2, ok bool - var URLSchema string - if supportsV2, ok = rb.hostsV2Support[dockerURL.IndexURL]; !ok { - var err error - URLSchema, supportsV2, err = rb.supportsRegistry(dockerURL.IndexURL, registryV2) - if err != nil { - return nil, nil, err - } - rb.schema = URLSchema + "://" - rb.hostsV2Support[dockerURL.IndexURL] = supportsV2 - } - - if supportsV2 { - return rb.getImageInfoV2(dockerURL) - } else { - URLSchema, supportsV1, err := rb.supportsRegistry(dockerURL.IndexURL, registryV1) - if err != nil { - return nil, nil, err - } - if !supportsV1 { - return nil, nil, fmt.Errorf("registry doesn't support API v2 nor v1") - } - rb.schema = URLSchema + "://" - return rb.getImageInfoV1(dockerURL) - } -} - -func (rb *RepositoryBackend) BuildACI(layerIDs []string, dockerURL *types.ParsedDockerURL, outputDir string, tmpBaseDir string, compression common.Compression) ([]string, []*schema.ImageManifest, error) { - if rb.hostsV2Support[dockerURL.IndexURL] { - return rb.buildACIV2(layerIDs, dockerURL, outputDir, tmpBaseDir, compression) - } else { - return rb.buildACIV1(layerIDs, dockerURL, outputDir, tmpBaseDir, compression) - } -} - -func checkRegistryStatus(statusCode int, hdr http.Header, version registryVersion) (bool, error) { - switch statusCode { - case http.StatusOK, http.StatusUnauthorized: - ok := true - if version == registryV2 { - // v2 API requires this check - ok = hdr.Get("Docker-Distribution-API-Version") == "registry/2.0" - } - return ok, nil - case http.StatusNotFound: - return false, nil - } - - return false, fmt.Errorf("unexpected http code: %d", statusCode) -} - -func (rb *RepositoryBackend) supportsRegistry(indexURL string, version registryVersion) (schema string, ok bool, err error) { - var URLPath string - switch version { - case registryV1: - // the v1 API defines this URL to check if the registry's status - URLPath = "v1/_ping" - case registryV2: - URLPath = "v2" - } - URLStr := path.Join(indexURL, URLPath) - - fetch := func(schema string) (res *http.Response, err error) { - url := schema + "://" + URLStr - req, err := http.NewRequest("GET", url, nil) - if err != nil { - return nil, err - } - - rb.setBasicAuth(req) - - client := util.GetTLSClient(rb.insecure.SkipVerify) - res, err = client.Do(req) - return - } - - schema = "https" - res, err := fetch(schema) - if err == nil { - ok, err = checkRegistryStatus(res.StatusCode, res.Header, version) - defer res.Body.Close() - } - if err != nil || !ok { - if rb.insecure.AllowHTTP { - schema = "http" - res, err = fetch(schema) - if err == nil { - ok, err = checkRegistryStatus(res.StatusCode, res.Header, version) - defer res.Body.Close() - } - } - return schema, ok, err - } - - return schema, ok, err -} diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository1.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository1.go deleted file mode 100644 index bc54e47c7b..0000000000 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository1.go +++ /dev/null @@ -1,391 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package repository - -import ( - "encoding/json" - "fmt" - "io" - "io/ioutil" - "net/http" - "os" - "path" - "strconv" - "strings" - "time" - - "github.com/appc/docker2aci/lib/common" - "github.com/appc/docker2aci/lib/internal" - "github.com/appc/docker2aci/lib/internal/types" - "github.com/appc/docker2aci/lib/internal/util" - "github.com/appc/docker2aci/pkg/log" - "github.com/appc/spec/schema" - "github.com/coreos/ioprogress" -) - -type RepoData struct { - Tokens []string - Endpoints []string - Cookie []string -} - -func (rb *RepositoryBackend) getImageInfoV1(dockerURL *types.ParsedDockerURL) ([]string, *types.ParsedDockerURL, error) { - repoData, err := rb.getRepoDataV1(dockerURL.IndexURL, dockerURL.ImageName) - if err != nil { - return nil, nil, fmt.Errorf("error getting repository data: %v", err) - } - - // TODO(iaguis) check more endpoints - appImageID, err := rb.getImageIDFromTagV1(repoData.Endpoints[0], dockerURL.ImageName, dockerURL.Tag, repoData) - if err != nil { - return nil, nil, fmt.Errorf("error getting ImageID from tag %s: %v", dockerURL.Tag, err) - } - - ancestry, err := rb.getAncestryV1(appImageID, repoData.Endpoints[0], repoData) - if err != nil { - return nil, nil, err - } - - rb.repoData = repoData - - return ancestry, dockerURL, nil -} - -func (rb *RepositoryBackend) buildACIV1(layerIDs []string, dockerURL *types.ParsedDockerURL, outputDir string, tmpBaseDir string, compression common.Compression) ([]string, []*schema.ImageManifest, error) { - layerFiles := make([]*os.File, len(layerIDs)) - layerDatas := make([]types.DockerImageData, len(layerIDs)) - - tmpParentDir, err := ioutil.TempDir(tmpBaseDir, "docker2aci-") - if err != nil { - return nil, nil, err - } - defer os.RemoveAll(tmpParentDir) - - var doneChannels []chan error - for i, layerID := range layerIDs { - doneChan := make(chan error) - doneChannels = append(doneChannels, doneChan) - // https://github.com/golang/go/wiki/CommonMistakes - i := i // golang-- - layerID := layerID - go func() { - tmpDir, err := ioutil.TempDir(tmpParentDir, "") - if err != nil { - doneChan <- fmt.Errorf("error creating dir: %v", err) - return - } - - j, size, err := rb.getJsonV1(layerID, rb.repoData.Endpoints[0], rb.repoData) - if err != nil { - doneChan <- fmt.Errorf("error getting image json: %v", err) - return - } - - layerDatas[i] = types.DockerImageData{} - if err := json.Unmarshal(j, &layerDatas[i]); err != nil { - doneChan <- fmt.Errorf("error unmarshaling layer data: %v", err) - return - } - - layerFiles[i], err = rb.getLayerV1(layerID, rb.repoData.Endpoints[0], rb.repoData, size, tmpDir) - if err != nil { - doneChan <- fmt.Errorf("error getting the remote layer: %v", err) - return - } - doneChan <- nil - }() - } - for _, doneChan := range doneChannels { - err := <-doneChan - if err != nil { - return nil, nil, err - } - } - var aciLayerPaths []string - var aciManifests []*schema.ImageManifest - var curPwl []string - - for i := len(layerIDs) - 1; i >= 0; i-- { - log.Debug("Generating layer ACI...") - aciPath, manifest, err := internal.GenerateACI(i, layerDatas[i], dockerURL, outputDir, layerFiles[i], curPwl, compression) - if err != nil { - return nil, nil, fmt.Errorf("error generating ACI: %v", err) - } - aciLayerPaths = append(aciLayerPaths, aciPath) - aciManifests = append(aciManifests, manifest) - curPwl = manifest.PathWhitelist - - layerFiles[i].Close() - } - - return aciLayerPaths, aciManifests, nil -} - -func (rb *RepositoryBackend) getRepoDataV1(indexURL string, remote string) (*RepoData, error) { - client := util.GetTLSClient(rb.insecure.SkipVerify) - repositoryURL := rb.schema + path.Join(indexURL, "v1", "repositories", remote, "images") - - req, err := http.NewRequest("GET", repositoryURL, nil) - if err != nil { - return nil, err - } - - if rb.username != "" && rb.password != "" { - req.SetBasicAuth(rb.username, rb.password) - } - - req.Header.Set("X-Docker-Token", "true") - - res, err := client.Do(req) - if err != nil { - return nil, err - } - defer res.Body.Close() - - if res.StatusCode != 200 { - return nil, fmt.Errorf("HTTP code: %d, URL: %s", res.StatusCode, req.URL) - } - - var tokens []string - if res.Header.Get("X-Docker-Token") != "" { - tokens = res.Header["X-Docker-Token"] - } - - var cookies []string - if res.Header.Get("Set-Cookie") != "" { - cookies = res.Header["Set-Cookie"] - } - - var endpoints []string - if res.Header.Get("X-Docker-Endpoints") != "" { - endpoints = makeEndpointsListV1(res.Header["X-Docker-Endpoints"]) - } else { - // Assume same endpoint - endpoints = append(endpoints, indexURL) - } - - return &RepoData{ - Endpoints: endpoints, - Tokens: tokens, - Cookie: cookies, - }, nil -} - -func (rb *RepositoryBackend) getImageIDFromTagV1(registry string, appName string, tag string, repoData *RepoData) (string, error) { - client := util.GetTLSClient(rb.insecure.SkipVerify) - // we get all the tags instead of directly getting the imageID of the - // requested one (.../tags/TAG) because even though it's specified in the - // Docker API, some registries (e.g. Google Container Registry) don't - // implement it. - req, err := http.NewRequest("GET", rb.schema+path.Join(registry, "repositories", appName, "tags"), nil) - if err != nil { - return "", fmt.Errorf("failed to get Image ID: %s, URL: %s", err, req.URL) - } - - setAuthTokenV1(req, repoData.Tokens) - setCookieV1(req, repoData.Cookie) - res, err := client.Do(req) - if err != nil { - return "", fmt.Errorf("failed to get Image ID: %s, URL: %s", err, req.URL) - } - defer res.Body.Close() - - if res.StatusCode != 200 { - return "", fmt.Errorf("HTTP code: %d. URL: %s", res.StatusCode, req.URL) - } - - j, err := ioutil.ReadAll(res.Body) - - if err != nil { - return "", err - } - - var tags map[string]string - - if err := json.Unmarshal(j, &tags); err != nil { - return "", fmt.Errorf("error unmarshaling: %v", err) - } - - imageID, ok := tags[tag] - if !ok { - return "", fmt.Errorf("tag %s not found", tag) - } - - return imageID, nil -} - -func (rb *RepositoryBackend) getAncestryV1(imgID, registry string, repoData *RepoData) ([]string, error) { - client := util.GetTLSClient(rb.insecure.SkipVerify) - req, err := http.NewRequest("GET", rb.schema+path.Join(registry, "images", imgID, "ancestry"), nil) - if err != nil { - return nil, err - } - - setAuthTokenV1(req, repoData.Tokens) - setCookieV1(req, repoData.Cookie) - res, err := client.Do(req) - if err != nil { - return nil, err - } - defer res.Body.Close() - - if res.StatusCode != 200 { - return nil, fmt.Errorf("HTTP code: %d. URL: %s", res.StatusCode, req.URL) - } - - var ancestry []string - - j, err := ioutil.ReadAll(res.Body) - if err != nil { - return nil, fmt.Errorf("Failed to read downloaded json: %s (%s)", err, j) - } - - if err := json.Unmarshal(j, &ancestry); err != nil { - return nil, fmt.Errorf("error unmarshaling: %v", err) - } - - return ancestry, nil -} - -func (rb *RepositoryBackend) getJsonV1(imgID, registry string, repoData *RepoData) ([]byte, int64, error) { - client := util.GetTLSClient(rb.insecure.SkipVerify) - req, err := http.NewRequest("GET", rb.schema+path.Join(registry, "images", imgID, "json"), nil) - if err != nil { - return nil, -1, err - } - setAuthTokenV1(req, repoData.Tokens) - setCookieV1(req, repoData.Cookie) - res, err := client.Do(req) - if err != nil { - return nil, -1, err - } - defer res.Body.Close() - - if res.StatusCode != 200 { - return nil, -1, fmt.Errorf("HTTP code: %d, URL: %s", res.StatusCode, req.URL) - } - - imageSize := int64(-1) - - if hdr := res.Header.Get("X-Docker-Size"); hdr != "" { - imageSize, err = strconv.ParseInt(hdr, 10, 64) - if err != nil { - return nil, -1, err - } - } - - b, err := ioutil.ReadAll(res.Body) - if err != nil { - return nil, -1, fmt.Errorf("failed to read downloaded json: %v (%s)", err, b) - } - - return b, imageSize, nil -} - -func (rb *RepositoryBackend) getLayerV1(imgID, registry string, repoData *RepoData, imgSize int64, tmpDir string) (*os.File, error) { - client := util.GetTLSClient(rb.insecure.SkipVerify) - req, err := http.NewRequest("GET", rb.schema+path.Join(registry, "images", imgID, "layer"), nil) - if err != nil { - return nil, err - } - - setAuthTokenV1(req, repoData.Tokens) - setCookieV1(req, repoData.Cookie) - - res, err := client.Do(req) - if err != nil { - return nil, err - } - defer res.Body.Close() - - if res.StatusCode != 200 { - res.Body.Close() - return nil, fmt.Errorf("HTTP code: %d. URL: %s", res.StatusCode, req.URL) - } - - // if we didn't receive the size via X-Docker-Size when we retrieved the - // layer's json, try Content-Length - if imgSize == -1 { - if hdr := res.Header.Get("Content-Length"); hdr != "" { - imgSize, err = strconv.ParseInt(hdr, 10, 64) - if err != nil { - return nil, err - } - } - } - - prefix := "Downloading " + imgID[:12] - fmtBytesSize := 18 - barSize := int64(80 - len(prefix) - fmtBytesSize) - bar := ioprogress.DrawTextFormatBarForW(barSize, os.Stderr) - fmtfunc := func(progress, total int64) string { - return fmt.Sprintf( - "%s: %s %s", - prefix, - bar(progress, total), - ioprogress.DrawTextFormatBytes(progress, total), - ) - } - - progressReader := &ioprogress.Reader{ - Reader: res.Body, - Size: imgSize, - DrawFunc: ioprogress.DrawTerminalf(os.Stderr, fmtfunc), - DrawInterval: 500 * time.Millisecond, - } - - layerFile, err := ioutil.TempFile(tmpDir, "dockerlayer-") - if err != nil { - return nil, err - } - - _, err = io.Copy(layerFile, progressReader) - if err != nil { - return nil, err - } - - if err := layerFile.Sync(); err != nil { - return nil, err - } - - return layerFile, nil -} - -func setAuthTokenV1(req *http.Request, token []string) { - if req.Header.Get("Authorization") == "" { - req.Header.Set("Authorization", "Token "+strings.Join(token, ",")) - } -} - -func setCookieV1(req *http.Request, cookie []string) { - if req.Header.Get("Cookie") == "" { - req.Header.Set("Cookie", strings.Join(cookie, "")) - } -} - -func makeEndpointsListV1(headers []string) []string { - var endpoints []string - - for _, ep := range headers { - endpointsList := strings.Split(ep, ",") - for _, endpointEl := range endpointsList { - endpoints = append( - endpoints, - path.Join(strings.TrimSpace(endpointEl), "v1")) - } - } - - return endpoints -} diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository2.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository2.go deleted file mode 100644 index 356d6f9bee..0000000000 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/backend/repository/repository2.go +++ /dev/null @@ -1,466 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package repository - -import ( - "encoding/json" - "errors" - "fmt" - "io" - "io/ioutil" - "net/http" - "os" - "path" - "regexp" - "strconv" - "strings" - "sync" - "time" - - "github.com/appc/docker2aci/lib/common" - "github.com/appc/docker2aci/lib/internal" - "github.com/appc/docker2aci/lib/internal/types" - "github.com/appc/docker2aci/lib/internal/util" - "github.com/appc/docker2aci/pkg/log" - "github.com/appc/spec/schema" - "github.com/coreos/pkg/progressutil" -) - -const ( - defaultIndexURL = "registry-1.docker.io" -) - -var validHex = regexp.MustCompile(`^([a-f0-9]{64})$`) - -type v2Manifest struct { - Name string `json:"name"` - Tag string `json:"tag"` - FSLayers []struct { - BlobSum string `json:"blobSum"` - } `json:"fsLayers"` - History []struct { - V1Compatibility string `json:"v1Compatibility"` - } `json:"history"` - Signature []byte `json:"signature"` -} - -func (rb *RepositoryBackend) getImageInfoV2(dockerURL *types.ParsedDockerURL) ([]string, *types.ParsedDockerURL, error) { - manifest, layers, err := rb.getManifestV2(dockerURL) - if err != nil { - return nil, nil, err - } - - rb.imageManifests[*dockerURL] = *manifest - - return layers, dockerURL, nil -} - -func (rb *RepositoryBackend) buildACIV2(layerIDs []string, dockerURL *types.ParsedDockerURL, outputDir string, tmpBaseDir string, compression common.Compression) ([]string, []*schema.ImageManifest, error) { - layerFiles := make([]*os.File, len(layerIDs)) - layerDatas := make([]types.DockerImageData, len(layerIDs)) - - tmpParentDir, err := ioutil.TempDir(tmpBaseDir, "docker2aci-") - if err != nil { - return nil, nil, err - } - defer os.RemoveAll(tmpParentDir) - - copier := progressutil.NewCopyProgressPrinter() - - var errChannels []chan error - closers := make([]io.ReadCloser, len(layerIDs)) - var wg sync.WaitGroup - for i, layerID := range layerIDs { - wg.Add(1) - errChan := make(chan error, 1) - errChannels = append(errChannels, errChan) - // https://github.com/golang/go/wiki/CommonMistakes - i := i // golang-- - layerID := layerID - go func() { - defer wg.Done() - - manifest := rb.imageManifests[*dockerURL] - - layerIndex, err := getLayerIndex(layerID, manifest) - if err != nil { - errChan <- err - return - } - - if len(manifest.History) <= layerIndex { - errChan <- fmt.Errorf("history not found for layer %s", layerID) - return - } - - layerDatas[i] = types.DockerImageData{} - if err := json.Unmarshal([]byte(manifest.History[layerIndex].V1Compatibility), &layerDatas[i]); err != nil { - errChan <- fmt.Errorf("error unmarshaling layer data: %v", err) - return - } - - tmpDir, err := ioutil.TempDir(tmpParentDir, "") - if err != nil { - errChan <- fmt.Errorf("error creating dir: %v", err) - return - } - - layerFiles[i], closers[i], err = rb.getLayerV2(layerID, dockerURL, tmpDir, copier) - if err != nil { - errChan <- fmt.Errorf("error getting the remote layer: %v", err) - return - } - errChan <- nil - }() - } - // Need to wait for all of the readers to be added to the copier (which happens during rb.getLayerV2) - wg.Wait() - err = copier.PrintAndWait(os.Stderr, 500*time.Millisecond, nil) - if err != nil { - return nil, nil, err - } - for _, closer := range closers { - if closer != nil { - closer.Close() - } - } - for _, errChan := range errChannels { - err := <-errChan - if err != nil { - return nil, nil, err - } - } - for _, layerFile := range layerFiles { - err := layerFile.Sync() - if err != nil { - return nil, nil, err - } - } - var aciLayerPaths []string - var aciManifests []*schema.ImageManifest - var curPwl []string - for i := len(layerIDs) - 1; i >= 0; i-- { - log.Debug("Generating layer ACI...") - aciPath, aciManifest, err := internal.GenerateACI(i, layerDatas[i], dockerURL, outputDir, layerFiles[i], curPwl, compression) - if err != nil { - return nil, nil, fmt.Errorf("error generating ACI: %v", err) - } - aciLayerPaths = append(aciLayerPaths, aciPath) - aciManifests = append(aciManifests, aciManifest) - curPwl = aciManifest.PathWhitelist - - layerFiles[i].Close() - } - - return aciLayerPaths, aciManifests, nil -} - -func (rb *RepositoryBackend) getManifestV2(dockerURL *types.ParsedDockerURL) (*v2Manifest, []string, error) { - url := rb.schema + path.Join(dockerURL.IndexURL, "v2", dockerURL.ImageName, "manifests", dockerURL.Tag) - - req, err := http.NewRequest("GET", url, nil) - if err != nil { - return nil, nil, err - } - - rb.setBasicAuth(req) - - res, err := rb.makeRequest(req, dockerURL.ImageName) - if err != nil { - return nil, nil, err - } - defer res.Body.Close() - - if res.StatusCode != http.StatusOK { - return nil, nil, fmt.Errorf("unexpected http code: %d, URL: %s", res.StatusCode, req.URL) - } - - manblob, err := ioutil.ReadAll(res.Body) - if err != nil { - return nil, nil, err - } - - manifest := &v2Manifest{} - - err = json.Unmarshal(manblob, manifest) - if err != nil { - return nil, nil, err - } - - if manifest.Name != dockerURL.ImageName { - return nil, nil, fmt.Errorf("name doesn't match what was requested, expected: %s, downloaded: %s", dockerURL.ImageName, manifest.Name) - } - - if manifest.Tag != dockerURL.Tag { - return nil, nil, fmt.Errorf("tag doesn't match what was requested, expected: %s, downloaded: %s", dockerURL.Tag, manifest.Tag) - } - - if err := fixManifestLayers(manifest); err != nil { - return nil, nil, err - } - - //TODO: verify signature here - - layers := make([]string, len(manifest.FSLayers)) - - for i, layer := range manifest.FSLayers { - layers[i] = layer.BlobSum - } - - return manifest, layers, nil -} - -func fixManifestLayers(manifest *v2Manifest) error { - type imageV1 struct { - ID string - Parent string - } - imgs := make([]*imageV1, len(manifest.FSLayers)) - for i := range manifest.FSLayers { - img := &imageV1{} - - if err := json.Unmarshal([]byte(manifest.History[i].V1Compatibility), img); err != nil { - return err - } - - imgs[i] = img - if err := validateV1ID(img.ID); err != nil { - return err - } - } - - if imgs[len(imgs)-1].Parent != "" { - return errors.New("Invalid parent ID in the base layer of the image.") - } - - // check general duplicates to error instead of a deadlock - idmap := make(map[string]struct{}) - - var lastID string - for _, img := range imgs { - // skip IDs that appear after each other, we handle those later - if _, exists := idmap[img.ID]; img.ID != lastID && exists { - return fmt.Errorf("ID %+v appears multiple times in manifest", img.ID) - } - lastID = img.ID - idmap[lastID] = struct{}{} - } - - // backwards loop so that we keep the remaining indexes after removing items - for i := len(imgs) - 2; i >= 0; i-- { - if imgs[i].ID == imgs[i+1].ID { // repeated ID. remove and continue - manifest.FSLayers = append(manifest.FSLayers[:i], manifest.FSLayers[i+1:]...) - manifest.History = append(manifest.History[:i], manifest.History[i+1:]...) - } else if imgs[i].Parent != imgs[i+1].ID { - return fmt.Errorf("Invalid parent ID. Expected %v, got %v.", imgs[i+1].ID, imgs[i].Parent) - } - } - - return nil -} - -func validateV1ID(id string) error { - if ok := validHex.MatchString(id); !ok { - return fmt.Errorf("image ID %q is invalid", id) - } - return nil -} - -func getLayerIndex(layerID string, manifest v2Manifest) (int, error) { - for i, layer := range manifest.FSLayers { - if layer.BlobSum == layerID { - return i, nil - } - } - return -1, fmt.Errorf("layer not found in manifest: %s", layerID) -} - -func (rb *RepositoryBackend) getLayerV2(layerID string, dockerURL *types.ParsedDockerURL, tmpDir string, copier *progressutil.CopyProgressPrinter) (*os.File, io.ReadCloser, error) { - url := rb.schema + path.Join(dockerURL.IndexURL, "v2", dockerURL.ImageName, "blobs", layerID) - req, err := http.NewRequest("GET", url, nil) - if err != nil { - return nil, nil, err - } - - rb.setBasicAuth(req) - - res, err := rb.makeRequest(req, dockerURL.ImageName) - if err != nil { - return nil, nil, err - } - - if res.StatusCode == http.StatusTemporaryRedirect || res.StatusCode == http.StatusFound { - location := res.Header.Get("Location") - if location != "" { - req, err = http.NewRequest("GET", location, nil) - if err != nil { - return nil, nil, err - } - res, err = rb.makeRequest(req, dockerURL.ImageName) - if err != nil { - return nil, nil, err - } - defer res.Body.Close() - } - } - - if res.StatusCode != http.StatusOK { - return nil, nil, fmt.Errorf("HTTP code: %d. URL: %s", res.StatusCode, req.URL) - } - - var in io.Reader - in = res.Body - - var size int64 - - if hdr := res.Header.Get("Content-Length"); hdr != "" { - size, err = strconv.ParseInt(hdr, 10, 64) - if err != nil { - return nil, nil, err - } - } - - name := "Downloading " + layerID[:18] - - layerFile, err := ioutil.TempFile(tmpDir, "dockerlayer-") - if err != nil { - return nil, nil, err - } - - err = copier.AddCopy(in, name, size, layerFile) - if err != nil { - return nil, nil, err - } - - return layerFile, res.Body, nil -} - -func (rb *RepositoryBackend) makeRequest(req *http.Request, repo string) (*http.Response, error) { - setBearerHeader := false - hostAuthTokens, ok := rb.hostsV2AuthTokens[req.URL.Host] - if ok { - authToken, ok := hostAuthTokens[repo] - if ok { - req.Header.Set("Authorization", "Bearer "+authToken) - setBearerHeader = true - } - } - - client := util.GetTLSClient(rb.insecure.SkipVerify) - res, err := client.Do(req) - if err != nil { - return nil, err - } - - if res.StatusCode == http.StatusUnauthorized && setBearerHeader { - return res, err - } - - hdr := res.Header.Get("www-authenticate") - if res.StatusCode != http.StatusUnauthorized || hdr == "" { - return res, err - } - - tokens := strings.Split(hdr, ",") - if len(tokens) != 3 || - !strings.HasPrefix(strings.ToLower(tokens[0]), "bearer realm") { - return res, err - } - res.Body.Close() - - var realm, service, scope string - for _, token := range tokens { - if strings.HasPrefix(strings.ToLower(token), "bearer realm") { - realm = strings.Trim(token[len("bearer realm="):], "\"") - } - if strings.HasPrefix(token, "service") { - service = strings.Trim(token[len("service="):], "\"") - } - if strings.HasPrefix(token, "scope") { - scope = strings.Trim(token[len("scope="):], "\"") - } - } - - if realm == "" { - return nil, fmt.Errorf("missing realm in bearer auth challenge") - } - if service == "" { - return nil, fmt.Errorf("missing service in bearer auth challenge") - } - // The scope can be empty if we're not getting a token for a specific repo - if scope == "" && repo != "" { - // If the scope is empty and it shouldn't be, we can infer it based on the repo - scope = fmt.Sprintf("repository:%s:pull", repo) - } - - authReq, err := http.NewRequest("GET", realm, nil) - if err != nil { - return nil, err - } - - getParams := authReq.URL.Query() - getParams.Add("service", service) - if scope != "" { - getParams.Add("scope", scope) - } - authReq.URL.RawQuery = getParams.Encode() - - rb.setBasicAuth(authReq) - - res, err = client.Do(authReq) - if err != nil { - return nil, err - } - defer res.Body.Close() - - switch res.StatusCode { - case http.StatusUnauthorized: - return nil, fmt.Errorf("unable to retrieve auth token: 401 unauthorized") - case http.StatusOK: - break - default: - return nil, fmt.Errorf("unexpected http code: %d, URL: %s", res.StatusCode, authReq.URL) - } - - tokenBlob, err := ioutil.ReadAll(res.Body) - if err != nil { - return nil, err - } - - tokenStruct := struct { - Token string `json:"token"` - }{} - - err = json.Unmarshal(tokenBlob, &tokenStruct) - if err != nil { - return nil, err - } - - hostAuthTokens, ok = rb.hostsV2AuthTokens[req.URL.Host] - if !ok { - hostAuthTokens = make(map[string]string) - rb.hostsV2AuthTokens[req.URL.Host] = hostAuthTokens - } - - hostAuthTokens[repo] = tokenStruct.Token - - return rb.makeRequest(req, repo) -} - -func (rb *RepositoryBackend) setBasicAuth(req *http.Request) { - if rb.username != "" && rb.password != "" { - req.SetBasicAuth(rb.username, rb.password) - } -} diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/docker/docker_functions.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/docker/docker_functions.go deleted file mode 100644 index 70bca8e476..0000000000 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/docker/docker_functions.go +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package docker - -import ( - "encoding/base64" - "encoding/json" - "fmt" - "io/ioutil" - "os" - "path" - "runtime" - "strings" - - "github.com/appc/docker2aci/lib/internal/types" - - "github.com/docker/distribution/reference" -) - -const ( - dockercfgFileName = "config.json" - dockercfgFileNameOld = ".dockercfg" - defaultIndexURL = "registry-1.docker.io" - defaultIndexURLAuth = "https://index.docker.io/v1/" - defaultTag = "latest" - defaultRepoPrefix = "library/" -) - -// SplitReposName breaks a repo name into an index name and remote name. -func SplitReposName(name string) (indexName, remoteName string) { - i := strings.IndexRune(name, '/') - if i == -1 || (!strings.ContainsAny(name[:i], ".:") && name[:i] != "localhost") { - indexName, remoteName = defaultIndexURL, name - } else { - indexName, remoteName = name[:i], name[i+1:] - } - if indexName == defaultIndexURL && !strings.ContainsRune(remoteName, '/') { - remoteName = defaultRepoPrefix + remoteName - } - return -} - -// Get a repos name and returns the right reposName + tag -// The tag can be confusing because of a port in a repository name. -// Ex: localhost.localdomain:5000/samalba/hipache:latest -func parseRepositoryTag(repos string) (string, string) { - n := strings.LastIndex(repos, ":") - if n < 0 { - return repos, "" - } - if tag := repos[n+1:]; !strings.Contains(tag, "/") { - return repos[:n], tag - } - return repos, "" -} - -func decodeDockerAuth(s string) (string, string, error) { - decoded, err := base64.StdEncoding.DecodeString(s) - if err != nil { - return "", "", err - } - parts := strings.SplitN(string(decoded), ":", 2) - if len(parts) != 2 { - return "", "", fmt.Errorf("invalid auth configuration file") - } - user := parts[0] - password := strings.Trim(parts[1], "\x00") - return user, password, nil -} - -func getHomeDir() string { - if runtime.GOOS == "windows" { - return os.Getenv("USERPROFILE") - } - return os.Getenv("HOME") -} - -// GetDockercfgAuth reads a ~/.dockercfg file and returns the username and password -// of the given docker index server. -func GetAuthInfo(indexServer string) (string, string, error) { - // official docker registry - if indexServer == defaultIndexURL { - indexServer = defaultIndexURLAuth - } - dockerCfgPath := path.Join(getHomeDir(), ".docker", dockercfgFileName) - if _, err := os.Stat(dockerCfgPath); err == nil { - j, err := ioutil.ReadFile(dockerCfgPath) - if err != nil { - return "", "", err - } - var dockerAuth types.DockerConfigFile - if err := json.Unmarshal(j, &dockerAuth); err != nil { - return "", "", err - } - // try the normal case - if c, ok := dockerAuth.AuthConfigs[indexServer]; ok { - return decodeDockerAuth(c.Auth) - } - } else if os.IsNotExist(err) { - oldDockerCfgPath := path.Join(getHomeDir(), dockercfgFileNameOld) - if _, err := os.Stat(oldDockerCfgPath); err != nil { - return "", "", nil //missing file is not an error - } - j, err := ioutil.ReadFile(oldDockerCfgPath) - if err != nil { - return "", "", err - } - var dockerAuthOld map[string]types.DockerAuthConfigOld - if err := json.Unmarshal(j, &dockerAuthOld); err != nil { - return "", "", err - } - if c, ok := dockerAuthOld[indexServer]; ok { - return decodeDockerAuth(c.Auth) - } - } else { - // if file is there but we can't stat it for any reason other - // than it doesn't exist then stop - return "", "", fmt.Errorf("%s - %v", dockerCfgPath, err) - } - return "", "", nil -} - -// ParseDockerURL takes a Docker URL and returns a ParsedDockerURL with its -// index URL, image name, and tag. -func ParseDockerURL(arg string) (*types.ParsedDockerURL, error) { - r, err := reference.ParseNamed(arg) - if err != nil { - return nil, err - } - - tag := defaultTag - var digest string - switch x := r.(type) { - case reference.Canonical: - digest = x.Digest().String() - case reference.NamedTagged: - tag = x.Tag() - } - - indexURL, remoteName := SplitReposName(r.Name()) - - p := &types.ParsedDockerURL{ - IndexURL: indexURL, - ImageName: remoteName, - Tag: tag, - Digest: digest, - } - return p, nil -} diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/internal.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/internal.go deleted file mode 100644 index 29cd8c87e4..0000000000 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/internal.go +++ /dev/null @@ -1,591 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package internal provides functions shared by different parts of docker2aci. -// -// Note: this package is an implementation detail and shouldn't be used outside -// of docker2aci. -package internal - -import ( - "archive/tar" - "encoding/json" - "fmt" - "io" - "os" - "path" - "path/filepath" - "sort" - "strconv" - "strings" - "time" - - "github.com/appc/docker2aci/lib/common" - "github.com/appc/docker2aci/lib/internal/tarball" - "github.com/appc/docker2aci/lib/internal/types" - "github.com/appc/docker2aci/lib/internal/util" - "github.com/appc/docker2aci/pkg/log" - "github.com/appc/spec/aci" - "github.com/appc/spec/schema" - appctypes "github.com/appc/spec/schema/types" - gzip "github.com/klauspost/pgzip" -) - -// Docker2ACIBackend is the interface that abstracts converting Docker layers -// to ACI from where they're stored (remote or file). -// -// GetImageInfo takes a Docker URL and returns a list of layers and the parsed -// Docker URL. -// -// BuildACI takes a Docker layer, converts it to ACI and returns its output -// path and its converted ImageManifest. -type Docker2ACIBackend interface { - GetImageInfo(dockerUrl string) ([]string, *types.ParsedDockerURL, error) - BuildACI(layerIDs []string, dockerURL *types.ParsedDockerURL, outputDir string, tmpBaseDir string, compression common.Compression) ([]string, []*schema.ImageManifest, error) -} - -// GenerateACI takes a Docker layer and generates an ACI from it. -func GenerateACI(layerNumber int, layerData types.DockerImageData, dockerURL *types.ParsedDockerURL, outputDir string, layerFile *os.File, curPwl []string, compression common.Compression) (string, *schema.ImageManifest, error) { - manifest, err := GenerateManifest(layerData, dockerURL) - if err != nil { - return "", nil, fmt.Errorf("error generating the manifest: %v", err) - } - - imageName := strings.Replace(dockerURL.ImageName, "/", "-", -1) - aciPath := imageName + "-" + layerData.ID - if dockerURL.Tag != "" { - aciPath += "-" + dockerURL.Tag - } - if layerData.OS != "" { - aciPath += "-" + layerData.OS - if layerData.Architecture != "" { - aciPath += "-" + layerData.Architecture - } - } - aciPath += "-" + strconv.Itoa(layerNumber) - aciPath += ".aci" - - aciPath = path.Join(outputDir, aciPath) - manifest, err = writeACI(layerFile, *manifest, curPwl, aciPath, compression) - if err != nil { - return "", nil, fmt.Errorf("error writing ACI: %v", err) - } - - if err := ValidateACI(aciPath); err != nil { - return "", nil, fmt.Errorf("invalid ACI generated: %v", err) - } - - return aciPath, manifest, nil -} - -// ValidateACI checks whether the ACI in aciPath is valid. -func ValidateACI(aciPath string) error { - aciFile, err := os.Open(aciPath) - if err != nil { - return err - } - defer aciFile.Close() - - tr, err := aci.NewCompressedTarReader(aciFile) - if err != nil { - return err - } - defer tr.Close() - - if err := aci.ValidateArchive(tr.Reader); err != nil { - return err - } - - return nil -} - -// GenerateManifest converts the docker manifest format to an appc -// ImageManifest. -func GenerateManifest(layerData types.DockerImageData, dockerURL *types.ParsedDockerURL) (*schema.ImageManifest, error) { - dockerConfig := layerData.Config - genManifest := &schema.ImageManifest{} - - appURL := "" - appURL = dockerURL.IndexURL + "/" - appURL += dockerURL.ImageName + "-" + layerData.ID - appURL, err := appctypes.SanitizeACIdentifier(appURL) - if err != nil { - return nil, err - } - name := appctypes.MustACIdentifier(appURL) - genManifest.Name = *name - - acVersion, err := appctypes.NewSemVer(schema.AppContainerVersion.String()) - if err != nil { - panic("invalid appc spec version") - } - genManifest.ACVersion = *acVersion - - genManifest.ACKind = appctypes.ACKind(schema.ImageManifestKind) - - var ( - labels appctypes.Labels - parentLabels appctypes.Labels - annotations appctypes.Annotations - ) - - layer := appctypes.MustACIdentifier("layer") - labels = append(labels, appctypes.Label{Name: *layer, Value: layerData.ID}) - - tag := dockerURL.Tag - version := appctypes.MustACIdentifier("version") - labels = append(labels, appctypes.Label{Name: *version, Value: tag}) - - if layerData.OS != "" { - os := appctypes.MustACIdentifier("os") - labels = append(labels, appctypes.Label{Name: *os, Value: layerData.OS}) - parentLabels = append(parentLabels, appctypes.Label{Name: *os, Value: layerData.OS}) - - if layerData.Architecture != "" { - arch := appctypes.MustACIdentifier("arch") - labels = append(labels, appctypes.Label{Name: *arch, Value: layerData.Architecture}) - parentLabels = append(parentLabels, appctypes.Label{Name: *arch, Value: layerData.Architecture}) - } - } - - if layerData.Author != "" { - authorsKey := appctypes.MustACIdentifier("authors") - annotations = append(annotations, appctypes.Annotation{Name: *authorsKey, Value: layerData.Author}) - } - epoch := time.Unix(0, 0) - if !layerData.Created.Equal(epoch) { - createdKey := appctypes.MustACIdentifier("created") - annotations = append(annotations, appctypes.Annotation{Name: *createdKey, Value: layerData.Created.Format(time.RFC3339)}) - } - if layerData.Comment != "" { - commentKey := appctypes.MustACIdentifier("docker-comment") - annotations = append(annotations, appctypes.Annotation{Name: *commentKey, Value: layerData.Comment}) - } - - if dockerURL.IndexURL != "" { - annotations = append(annotations, appctypes.Annotation{Name: *appctypes.MustACIdentifier(common.AppcDockerRegistryURL), Value: dockerURL.IndexURL}) - } - annotations = append(annotations, appctypes.Annotation{Name: *appctypes.MustACIdentifier(common.AppcDockerRepository), Value: dockerURL.ImageName}) - annotations = append(annotations, appctypes.Annotation{Name: *appctypes.MustACIdentifier(common.AppcDockerImageID), Value: layerData.ID}) - annotations = append(annotations, appctypes.Annotation{Name: *appctypes.MustACIdentifier(common.AppcDockerParentImageID), Value: layerData.Parent}) - - if dockerConfig != nil { - if len(dockerConfig.Entrypoint) > 0 { - entry, err := json.Marshal(dockerConfig.Entrypoint) - if err != nil { - return nil, err - } - annotations = append(annotations, appctypes.Annotation{Name: *appctypes.MustACIdentifier(common.AppcDockerEntrypoint), Value: string(entry)}) - } - if len(dockerConfig.Cmd) > 0 { - cmd, err := json.Marshal(dockerConfig.Cmd) - if err != nil { - return nil, err - } - annotations = append(annotations, appctypes.Annotation{Name: *appctypes.MustACIdentifier(common.AppcDockerCmd), Value: string(cmd)}) - } - - exec := getExecCommand(dockerConfig.Entrypoint, dockerConfig.Cmd) - if exec != nil { - user, group := parseDockerUser(dockerConfig.User) - var env appctypes.Environment - for _, v := range dockerConfig.Env { - parts := strings.SplitN(v, "=", 2) - env.Set(parts[0], parts[1]) - } - app := &appctypes.App{ - Exec: exec, - User: user, - Group: group, - Environment: env, - WorkingDirectory: dockerConfig.WorkingDir, - } - - app.MountPoints, err = convertVolumesToMPs(dockerConfig.Volumes) - if err != nil { - return nil, err - } - - app.Ports, err = convertPorts(dockerConfig.ExposedPorts, dockerConfig.PortSpecs) - if err != nil { - return nil, err - } - - genManifest.App = app - } - } - - if layerData.Parent != "" { - indexPrefix := "" - // omit docker hub index URL in app name - indexPrefix = dockerURL.IndexURL + "/" - parentImageNameString := indexPrefix + dockerURL.ImageName + "-" + layerData.Parent - parentImageNameString, err := appctypes.SanitizeACIdentifier(parentImageNameString) - if err != nil { - return nil, err - } - parentImageName := appctypes.MustACIdentifier(parentImageNameString) - - genManifest.Dependencies = append(genManifest.Dependencies, appctypes.Dependency{ImageName: *parentImageName, Labels: parentLabels}) - - annotations = append(annotations, appctypes.Annotation{Name: *appctypes.MustACIdentifier(common.AppcDockerTag), Value: dockerURL.Tag}) - } - - genManifest.Labels = labels - genManifest.Annotations = annotations - - return genManifest, nil -} - -type appcPortSorter []appctypes.Port - -func (s appcPortSorter) Len() int { - return len(s) -} - -func (s appcPortSorter) Swap(i, j int) { - s[i], s[j] = s[j], s[i] -} - -func (s appcPortSorter) Less(i, j int) bool { - return s[i].Name.String() < s[j].Name.String() -} - -func convertPorts(dockerExposedPorts map[string]struct{}, dockerPortSpecs []string) ([]appctypes.Port, error) { - ports := []appctypes.Port{} - - for ep := range dockerExposedPorts { - appcPort, err := parseDockerPort(ep) - if err != nil { - return nil, err - } - ports = append(ports, *appcPort) - } - - if dockerExposedPorts == nil && dockerPortSpecs != nil { - log.Debug("warning: docker image uses deprecated PortSpecs field") - for _, ep := range dockerPortSpecs { - appcPort, err := parseDockerPort(ep) - if err != nil { - return nil, err - } - ports = append(ports, *appcPort) - } - } - - sort.Sort(appcPortSorter(ports)) - - return ports, nil -} - -func parseDockerPort(dockerPort string) (*appctypes.Port, error) { - var portString string - proto := "tcp" - sp := strings.Split(dockerPort, "/") - if len(sp) < 2 { - portString = dockerPort - } else { - proto = sp[1] - portString = sp[0] - } - - port, err := strconv.ParseUint(portString, 10, 0) - if err != nil { - return nil, fmt.Errorf("error parsing port %q: %v", portString, err) - } - - sn, err := appctypes.SanitizeACName(dockerPort) - if err != nil { - return nil, err - } - - appcPort := &appctypes.Port{ - Name: *appctypes.MustACName(sn), - Protocol: proto, - Port: uint(port), - } - - return appcPort, nil -} - -type appcVolSorter []appctypes.MountPoint - -func (s appcVolSorter) Len() int { - return len(s) -} - -func (s appcVolSorter) Swap(i, j int) { - s[i], s[j] = s[j], s[i] -} - -func (s appcVolSorter) Less(i, j int) bool { - return s[i].Name.String() < s[j].Name.String() -} - -func convertVolumesToMPs(dockerVolumes map[string]struct{}) ([]appctypes.MountPoint, error) { - mps := []appctypes.MountPoint{} - dup := make(map[string]int) - - for p := range dockerVolumes { - n := filepath.Join("volume", p) - sn, err := appctypes.SanitizeACName(n) - if err != nil { - return nil, err - } - - // check for duplicate names - if i, ok := dup[sn]; ok { - dup[sn] = i + 1 - sn = fmt.Sprintf("%s-%d", sn, i) - } else { - dup[sn] = 1 - } - - mp := appctypes.MountPoint{ - Name: *appctypes.MustACName(sn), - Path: p, - } - - mps = append(mps, mp) - } - - sort.Sort(appcVolSorter(mps)) - - return mps, nil -} - -func writeACI(layer io.ReadSeeker, manifest schema.ImageManifest, curPwl []string, output string, compression common.Compression) (*schema.ImageManifest, error) { - aciFile, err := os.Create(output) - if err != nil { - return nil, fmt.Errorf("error creating ACI file: %v", err) - } - defer aciFile.Close() - - var w io.WriteCloser = aciFile - if compression == common.GzipCompression { - w = gzip.NewWriter(aciFile) - defer w.Close() - } - trw := tar.NewWriter(w) - defer trw.Close() - - if err := WriteRootfsDir(trw); err != nil { - return nil, fmt.Errorf("error writing rootfs entry: %v", err) - } - - fileMap := make(map[string]struct{}) - var whiteouts []string - convWalker := func(t *tarball.TarFile) error { - name := t.Name() - if name == "./" { - return nil - } - t.Header.Name = path.Join("rootfs", name) - absolutePath := strings.TrimPrefix(t.Header.Name, "rootfs") - - if filepath.Clean(absolutePath) == "/dev" && t.Header.Typeflag != tar.TypeDir { - return fmt.Errorf(`invalid layer: "/dev" is not a directory`) - } - - fileMap[absolutePath] = struct{}{} - if strings.Contains(t.Header.Name, "/.wh.") { - whiteouts = append(whiteouts, strings.Replace(absolutePath, ".wh.", "", 1)) - return nil - } - if t.Header.Typeflag == tar.TypeLink { - t.Header.Linkname = path.Join("rootfs", t.Linkname()) - } - - if err := trw.WriteHeader(t.Header); err != nil { - return err - } - if _, err := io.Copy(trw, t.TarStream); err != nil { - return err - } - - if !util.In(curPwl, absolutePath) { - curPwl = append(curPwl, absolutePath) - } - - return nil - } - tr, err := aci.NewCompressedTarReader(layer) - if err == nil { - defer tr.Close() - // write files in rootfs/ - if err := tarball.Walk(*tr.Reader, convWalker); err != nil { - return nil, err - } - } else { - // ignore errors: empty layers in tars generated by docker save are not - // valid tar files so we ignore errors trying to open them. Converted - // ACIs will have the manifest and an empty rootfs directory in any - // case. - } - newPwl := subtractWhiteouts(curPwl, whiteouts) - - newPwl, err = writeStdioSymlinks(trw, fileMap, newPwl) - if err != nil { - return nil, err - } - // Let's copy the newly generated PathWhitelist to avoid unintended - // side-effects - manifest.PathWhitelist = make([]string, len(newPwl)) - copy(manifest.PathWhitelist, newPwl) - - if err := WriteManifest(trw, manifest); err != nil { - return nil, fmt.Errorf("error writing manifest: %v", err) - } - - return &manifest, nil -} - -func getExecCommand(entrypoint []string, cmd []string) appctypes.Exec { - return append(entrypoint, cmd...) -} - -func parseDockerUser(dockerUser string) (string, string) { - // if the docker user is empty assume root user and group - if dockerUser == "" { - return "0", "0" - } - - dockerUserParts := strings.Split(dockerUser, ":") - - // when only the user is given, the docker spec says that the default and - // supplementary groups of the user in /etc/passwd should be applied. - // Assume root group for now in this case. - if len(dockerUserParts) < 2 { - return dockerUserParts[0], "0" - } - - return dockerUserParts[0], dockerUserParts[1] -} - -func subtractWhiteouts(pathWhitelist []string, whiteouts []string) []string { - matchPaths := []string{} - for _, path := range pathWhitelist { - // If one of the parent dirs of the current path matches the - // whiteout then also this path should be removed - curPath := path - for curPath != "/" { - for _, whiteout := range whiteouts { - if curPath == whiteout { - matchPaths = append(matchPaths, path) - } - } - curPath = filepath.Dir(curPath) - } - } - for _, matchPath := range matchPaths { - idx := util.IndexOf(pathWhitelist, matchPath) - if idx != -1 { - pathWhitelist = append(pathWhitelist[:idx], pathWhitelist[idx+1:]...) - } - } - - sort.Sort(sort.StringSlice(pathWhitelist)) - - return pathWhitelist -} - -// WriteManifest writes a schema.ImageManifest entry on a tar.Writer. -func WriteManifest(outputWriter *tar.Writer, manifest schema.ImageManifest) error { - b, err := json.Marshal(manifest) - if err != nil { - return err - } - - hdr := getGenericTarHeader() - hdr.Name = "manifest" - hdr.Mode = 0644 - hdr.Size = int64(len(b)) - hdr.Typeflag = tar.TypeReg - - if err := outputWriter.WriteHeader(hdr); err != nil { - return err - } - if _, err := outputWriter.Write(b); err != nil { - return err - } - - return nil -} - -// WriteRootfsDir writes a "rootfs" dir entry on a tar.Writer. -func WriteRootfsDir(tarWriter *tar.Writer) error { - hdr := getGenericTarHeader() - hdr.Name = "rootfs" - hdr.Mode = 0755 - hdr.Size = int64(0) - hdr.Typeflag = tar.TypeDir - - return tarWriter.WriteHeader(hdr) -} - -type symlink struct { - linkname string - target string -} - -// writeStdioSymlinks adds the /dev/stdin, /dev/stdout, /dev/stderr, and -// /dev/fd symlinks expected by Docker to the converted ACIs so apps can find -// them as expected -func writeStdioSymlinks(tarWriter *tar.Writer, fileMap map[string]struct{}, pwl []string) ([]string, error) { - stdioSymlinks := []symlink{ - {"/dev/stdin", "/proc/self/fd/0"}, - // Docker makes /dev/{stdout,stderr} point to /proc/self/fd/{1,2} but - // we point to /dev/console instead in order to support the case when - // stdout/stderr is a Unix socket (e.g. for the journal). - {"/dev/stdout", "/dev/console"}, - {"/dev/stderr", "/dev/console"}, - {"/dev/fd", "/proc/self/fd"}, - } - - for _, s := range stdioSymlinks { - name := s.linkname - target := s.target - if _, exists := fileMap[name]; exists { - continue - } - hdr := &tar.Header{ - Name: filepath.Join("rootfs", name), - Mode: 0777, - Typeflag: tar.TypeSymlink, - Linkname: target, - } - if err := tarWriter.WriteHeader(hdr); err != nil { - return nil, err - } - if !util.In(pwl, name) { - pwl = append(pwl, name) - } - } - - return pwl, nil -} - -func getGenericTarHeader() *tar.Header { - // FIXME(iaguis) Use docker image time instead of the Unix Epoch? - hdr := &tar.Header{ - Uid: 0, - Gid: 0, - ModTime: time.Unix(0, 0), - Uname: "0", - Gname: "0", - ChangeTime: time.Unix(0, 0), - } - - return hdr -} diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/tarball/tarfile.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/tarball/tarfile.go deleted file mode 100644 index c72d18d9d9..0000000000 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/tarball/tarfile.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package tarball provides functions to manipulate tar files. -// -// Note: this package is an implementation detail and shouldn't be used outside -// of docker2aci. -package tarball - -import ( - "archive/tar" - "io" -) - -// TarFile is a representation of a file in a tarball. It consists of two parts, -// the Header and the Stream. The Header is a regular tar header, the Stream -// is a byte stream that can be used to read the file's contents. -type TarFile struct { - Header *tar.Header - TarStream io.Reader -} - -// Name returns the name of the file as reported by the header. -func (t *TarFile) Name() string { - return t.Header.Name -} - -// Linkname returns the Linkname of the file as reported by the header. -func (t *TarFile) Linkname() string { - return t.Header.Linkname -} diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/tarball/walk.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/tarball/walk.go deleted file mode 100644 index c12d2e34fb..0000000000 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/tarball/walk.go +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package tarball - -import ( - "archive/tar" - "fmt" - "io" -) - -// WalkFunc is a func for handling each file (header and byte stream) in a tarball -type WalkFunc func(t *TarFile) error - -// Walk walks through the files in the tarball represented by tarstream and -// passes each of them to the WalkFunc provided as an argument -func Walk(tarReader tar.Reader, walkFunc func(t *TarFile) error) error { - for { - hdr, err := tarReader.Next() - if err == io.EOF { - // end of tar archive - break - } - if err != nil { - return fmt.Errorf("Error reading tar entry: %v", err) - } - if err := walkFunc(&TarFile{Header: hdr, TarStream: &tarReader}); err != nil { - return err - } - } - return nil -} diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/types/docker_types.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/types/docker_types.go deleted file mode 100644 index 7af1e17e7a..0000000000 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/types/docker_types.go +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import "time" - -// DockerImageData stores the JSON structure of a Docker image. -// Taken and adapted from upstream Docker. -type DockerImageData struct { - ID string `json:"id"` - Parent string `json:"parent,omitempty"` - Comment string `json:"comment,omitempty"` - Created time.Time `json:"created"` - Container string `json:"container,omitempty"` - ContainerConfig DockerImageConfig `json:"container_config,omitempty"` - DockerVersion string `json:"docker_version,omitempty"` - Author string `json:"author,omitempty"` - Config *DockerImageConfig `json:"config,omitempty"` - Architecture string `json:"architecture,omitempty"` - OS string `json:"os,omitempty"` - Checksum string `json:"checksum"` -} - -// Note: the Config structure should hold only portable information about the container. -// Here, "portable" means "independent from the host we are running on". -// Non-portable information *should* appear in HostConfig. -// Taken and adapted from upstream Docker. -type DockerImageConfig struct { - Hostname string - Domainname string - User string - Memory int64 // Memory limit (in bytes) - MemorySwap int64 // Total memory usage (memory + swap); set `-1' to disable swap - CpuShares int64 // CPU shares (relative weight vs. other containers) - Cpuset string // Cpuset 0-2, 0,1 - AttachStdin bool - AttachStdout bool - AttachStderr bool - PortSpecs []string // Deprecated - Can be in the format of 8080/tcp - ExposedPorts map[string]struct{} - Tty bool // Attach standard streams to a tty, including stdin if it is not closed. - OpenStdin bool // Open stdin - StdinOnce bool // If true, close stdin after the 1 attached client disconnects. - Env []string - Cmd []string - Image string // Name of the image as it was passed by the operator (eg. could be symbolic) - Volumes map[string]struct{} - WorkingDir string - Entrypoint []string - NetworkDisabled bool - MacAddress string - OnBuild []string -} - -// DockerAuthConfigOld represents the deprecated ~/.dockercfg auth -// configuration. -// Taken from upstream Docker. -type DockerAuthConfigOld struct { - Username string `json:"username,omitempty"` - Password string `json:"password,omitempty"` - Auth string `json:"auth"` - Email string `json:"email"` - ServerAddress string `json:"serveraddress,omitempty"` -} - -// DockerAuthConfig represents a config.json auth entry. -// Taken from upstream Docker. -type DockerAuthConfig struct { - Username string `json:"username,omitempty"` - Password string `json:"password,omitempty"` - Auth string `json:"auth,omitempty"` - ServerAddress string `json:"serveraddress,omitempty"` - RegistryToken string `json:"registrytoken,omitempty"` -} - -// DockerConfigFile represents a config.json auth file. -// Taken from upstream docker. -type DockerConfigFile struct { - AuthConfigs map[string]DockerAuthConfig `json:"auths"` -} diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/types/types.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/types/types.go deleted file mode 100644 index cc4fc12ac8..0000000000 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/types/types.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package types defines Docker image, URL and configuration types. -// -// Note: this package is an implementation detail and shouldn't be used outside -// of docker2aci. -package types - -// ParsedDockerURL represents a parsed Docker URL. -type ParsedDockerURL struct { - IndexURL string - ImageName string - Tag string - Digest string -} diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/util/util.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/util/util.go deleted file mode 100644 index ebaafca62c..0000000000 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/internal/util/util.go +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package util defines convenience functions for handling slices and debugging. -// -// Note: this package is an implementation detail and shouldn't be used outside -// of docker2aci. -package util - -import ( - "crypto/tls" - "fmt" - "net/http" - - "github.com/appc/spec/pkg/acirenderer" -) - -// Quote takes a slice of strings and returns another slice with them quoted. -func Quote(l []string) []string { - var quoted []string - - for _, s := range l { - quoted = append(quoted, fmt.Sprintf("%q", s)) - } - - return quoted -} - -// ReverseImages takes an acirenderer.Images and reverses it. -func ReverseImages(s acirenderer.Images) acirenderer.Images { - var o acirenderer.Images - for i := len(s) - 1; i >= 0; i-- { - o = append(o, s[i]) - } - - return o -} - -// In checks whether el is in list. -func In(list []string, el string) bool { - return IndexOf(list, el) != -1 -} - -// IndexOf returns the index of el in list, or -1 if it's not found. -func IndexOf(list []string, el string) int { - for i, x := range list { - if el == x { - return i - } - } - return -1 -} - -// GetTLSClient gets an HTTP client that behaves like the default HTTP -// client, but optionally skips the TLS certificate verification. -func GetTLSClient(skipTLSCheck bool) *http.Client { - if !skipTLSCheck { - return http.DefaultClient - } - client := *http.DefaultClient - // Default transport is hidden behind the RoundTripper - // interface, so we can't easily make a copy of it. If this - // ever panics, we will have to adapt. - realTransport := http.DefaultTransport.(*http.Transport) - tr := *realTransport - if tr.TLSClientConfig == nil { - tr.TLSClientConfig = &tls.Config{} - } - tr.TLSClientConfig.InsecureSkipVerify = true - client.Transport = &tr - return &client -} diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/version.go b/Godeps/_workspace/src/github.com/appc/docker2aci/lib/version.go deleted file mode 100644 index 487c4bc50e..0000000000 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/lib/version.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package docker2aci - -import "github.com/appc/spec/schema" - -var Version = "0.11.1" -var AppcVersion = schema.AppContainerVersion diff --git a/Godeps/_workspace/src/github.com/appc/docker2aci/pkg/log/log.go b/Godeps/_workspace/src/github.com/appc/docker2aci/pkg/log/log.go deleted file mode 100644 index 2a02c47414..0000000000 --- a/Godeps/_workspace/src/github.com/appc/docker2aci/pkg/log/log.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2016 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package log - -import ( - "fmt" - "io" - "os" - "strings" -) - -var debugEnabled bool - -func printTo(w io.Writer, i ...interface{}) { - s := fmt.Sprint(i...) - fmt.Fprintln(w, strings.TrimSuffix(s, "\n")) -} - -// Info prints a message to stderr. -func Info(i ...interface{}) { - printTo(os.Stderr, i...) -} - -// Debug prints a message to stderr if debug is enabled. -func Debug(i ...interface{}) { - if debugEnabled { - printTo(os.Stderr, i...) - } -} - -// InitDebug enables debug output. -func InitDebug() { - debugEnabled = true -} diff --git a/Godeps/_workspace/src/github.com/appc/goaci/LICENSE b/Godeps/_workspace/src/github.com/appc/goaci/LICENSE deleted file mode 100644 index e06d208186..0000000000 --- a/Godeps/_workspace/src/github.com/appc/goaci/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor 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, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - diff --git a/Godeps/_workspace/src/github.com/appc/goaci/proj2aci/asset.go b/Godeps/_workspace/src/github.com/appc/goaci/proj2aci/asset.go deleted file mode 100644 index d90ee5fc8e..0000000000 --- a/Godeps/_workspace/src/github.com/appc/goaci/proj2aci/asset.go +++ /dev/null @@ -1,283 +0,0 @@ -package proj2aci - -import ( - "bytes" - "fmt" - "io" - "os" - "path/filepath" - "regexp" - "strings" -) - -// GetAssetString returns a properly formatted asset string. -func GetAssetString(aciAsset, localAsset string) string { - return getAssetString(aciAsset, localAsset) -} - -// PrepareAssets copies given assets to ACI rootfs directory. It also -// tries to copy required shared libraries if an asset is a -// dynamically linked executable or library. placeholderMapping maps -// placeholders (like "") to actual paths (usually -// something inside temporary directory). -func PrepareAssets(assets []string, rootfs string, placeholderMapping map[string]string) error { - newAssets := assets - processedAssets := make(map[string]struct{}) - for len(newAssets) > 0 { - assetsToProcess := newAssets - newAssets = nil - for _, asset := range assetsToProcess { - splitAsset := filepath.SplitList(asset) - if len(splitAsset) != 2 { - return fmt.Errorf("Malformed asset option: '%v' - expected two absolute paths separated with %v", asset, listSeparator()) - } - evalSrc, srcErr := evalPath(splitAsset[0]) - if srcErr != nil { - return fmt.Errorf("Could not evaluate symlinks in source asset %q: %v", evalSrc, srcErr) - } - evalDest, destErr := evalPath(splitAsset[1]) - asset = getAssetString(evalSrc, evalDest) - Debug("Processing asset:", asset) - if _, ok := processedAssets[asset]; ok { - Debug(" skipped") - continue - } - additionalAssets, err := processAsset(asset, rootfs, placeholderMapping) - if destErr != nil { - evalDest, destErr = evalPath(evalDest) - if destErr != nil { - return fmt.Errorf("Could not evaluate symlinks in destination asset %q, even after it was copied to: %v", evalDest, destErr) - } - asset = getAssetString(evalSrc, evalDest) - } - if err != nil { - return err - } - processedAssets[asset] = struct{}{} - newAssets = append(newAssets, additionalAssets...) - } - } - return nil -} - -func evalPath(path string) (string, error) { - symlinkDir := filepath.Dir(path) - symlinkBase := filepath.Base(path) - realSymlinkDir, err := filepath.EvalSymlinks(symlinkDir) - if err != nil { - return path, err - } - return filepath.Join(realSymlinkDir, symlinkBase), nil -} - -// processAsset validates an asset, replaces placeholders with real -// paths and does the copying. It may return additional assets to be -// processed when asset is an executable or a library. -func processAsset(asset, rootfs string, placeholderMapping map[string]string) ([]string, error) { - splitAsset := filepath.SplitList(asset) - if len(splitAsset) != 2 { - return nil, fmt.Errorf("Malformed asset option: '%v' - expected two absolute paths separated with %v", asset, listSeparator()) - } - ACIAsset := replacePlaceholders(splitAsset[0], placeholderMapping) - localAsset := replacePlaceholders(splitAsset[1], placeholderMapping) - if err := validateAsset(ACIAsset, localAsset); err != nil { - return nil, err - } - ACIAssetSubPath := filepath.Join(rootfs, filepath.Dir(ACIAsset)) - err := os.MkdirAll(ACIAssetSubPath, 0755) - if err != nil { - return nil, fmt.Errorf("Failed to create directory tree for asset '%v': %v", asset, err) - } - err = copyTree(localAsset, filepath.Join(rootfs, ACIAsset)) - if err != nil { - return nil, fmt.Errorf("Failed to copy assets for %q: %v", asset, err) - } - additionalAssets, err := getSoLibs(localAsset) - if err != nil { - return nil, fmt.Errorf("Failed to get dependent assets for %q: %v", localAsset, err) - } - // HACK! if we are copying libc then try to copy libnss_* libs - // (glibc name service switch libs used in networking) - if matched, err := filepath.Match("libc.*", filepath.Base(localAsset)); err == nil && matched { - toGlob := filepath.Join(filepath.Dir(localAsset), "libnss_*") - if matches, err := filepath.Glob(toGlob); err == nil && len(matches) > 0 { - matchesAsAssets := make([]string, 0, len(matches)) - for _, f := range matches { - matchesAsAssets = append(matchesAsAssets, getAssetString(f, f)) - } - additionalAssets = append(additionalAssets, matchesAsAssets...) - } - } - return additionalAssets, nil -} - -func replacePlaceholders(path string, placeholderMapping map[string]string) string { - Debug("Processing path: ", path) - newPath := path - for placeholder, replacement := range placeholderMapping { - newPath = strings.Replace(newPath, placeholder, replacement, -1) - } - Debug("Processed path: ", newPath) - return newPath -} - -func validateAsset(ACIAsset, localAsset string) error { - if !filepath.IsAbs(ACIAsset) { - return fmt.Errorf("Wrong ACI asset: '%v' - ACI asset has to be absolute path", ACIAsset) - } - if !filepath.IsAbs(localAsset) { - return fmt.Errorf("Wrong local asset: '%v' - local asset has to be absolute path", localAsset) - } - fi, err := os.Lstat(localAsset) - if err != nil { - return fmt.Errorf("Error stating %v: %v", localAsset, err) - } - mode := fi.Mode() - if mode.IsDir() || mode.IsRegular() || isSymlink(mode) { - return nil - } - return fmt.Errorf("Can't handle local asset %v - not a file, not a dir, not a symlink", fi.Name()) -} - -func copyTree(src, dest string) error { - return filepath.Walk(src, func(path string, info os.FileInfo, err error) error { - if err != nil { - return err - } - rootLess := path[len(src):] - target := filepath.Join(dest, rootLess) - mode := info.Mode() - switch { - case mode.IsDir(): - err := os.Mkdir(target, mode.Perm()) - if err != nil { - return err - } - case mode.IsRegular(): - if err := copyRegularFile(path, target); err != nil { - return err - } - case isSymlink(mode): - if err := copySymlink(path, target); err != nil { - return err - } - default: - return fmt.Errorf("Unsupported node %q in assets, only regular files, directories and symlinks are supported.", path, mode.String()) - } - return nil - }) -} - -func copyRegularFile(src, dest string) error { - srcFile, err := os.Open(src) - if err != nil { - return err - } - defer srcFile.Close() - destFile, err := os.Create(dest) - if err != nil { - return err - } - defer destFile.Close() - if _, err := io.Copy(destFile, srcFile); err != nil { - return err - } - fi, err := srcFile.Stat() - if err != nil { - return err - } - if err := destFile.Chmod(fi.Mode().Perm()); err != nil { - return err - } - return nil -} - -func copySymlink(src, dest string) error { - symTarget, err := os.Readlink(src) - if err != nil { - return err - } - if err := os.Symlink(symTarget, dest); err != nil { - return err - } - return nil -} - -// getSoLibs tries to run ldd on given path and to process its output -// to get a list of shared libraries to copy. This list is returned as -// an array of assets. -// -// man ldd says that running ldd on untrusted executables is dangerous -// (it might run an executable to get the libraries), so possibly this -// should be replaced with objdump. Problem with objdump is that it -// just gives library names, while ldd gives absolute paths to those -// libraries - to use objdump we need to know the $libdir. -func getSoLibs(path string) ([]string, error) { - assets := []string{} - buf := new(bytes.Buffer) - args := []string{ - "ldd", - path, - } - if err := RunCmdFull("", args, nil, "", buf, nil); err != nil { - if _, ok := err.(CmdFailedError); !ok { - return nil, err - } - } else { - re := regexp.MustCompile(`(?m)^\t(?:\S+\s+=>\s+)?(\/\S+)\s+\([0-9a-fA-Fx]+\)$`) - for _, matches := range re.FindAllStringSubmatch(string(buf.Bytes()), -1) { - lib := matches[1] - if lib == "" { - continue - } - symlinkedAssets, err := getSymlinkedAssets(lib) - if err != nil { - return nil, err - } - assets = append(assets, symlinkedAssets...) - } - } - return assets, nil -} - -// getSymlinkedAssets returns an array of many assets if given path is -// a symlink - useful for getting shared libraries, which are often -// surrounded with a bunch of symlinks. -func getSymlinkedAssets(path string) ([]string, error) { - assets := []string{} - maxLevels := 100 - levels := maxLevels - for { - if levels < 1 { - return nil, fmt.Errorf("Too many levels of symlinks (>$d)", maxLevels) - } - fi, err := os.Lstat(path) - if err != nil { - return nil, err - } - asset := getAssetString(path, path) - assets = append(assets, asset) - if !isSymlink(fi.Mode()) { - break - } - symTarget, err := os.Readlink(path) - if err != nil { - return nil, err - } - if filepath.IsAbs(symTarget) { - path = symTarget - } else { - path = filepath.Join(filepath.Dir(path), symTarget) - } - levels-- - } - return assets, nil -} - -func getAssetString(aciAsset, localAsset string) string { - return fmt.Sprintf("%s%s%s", aciAsset, listSeparator(), localAsset) -} - -func isSymlink(mode os.FileMode) bool { - return mode&os.ModeSymlink == os.ModeSymlink -} diff --git a/Godeps/_workspace/src/github.com/appc/goaci/proj2aci/binary.go b/Godeps/_workspace/src/github.com/appc/goaci/proj2aci/binary.go deleted file mode 100644 index ee54f6c641..0000000000 --- a/Godeps/_workspace/src/github.com/appc/goaci/proj2aci/binary.go +++ /dev/null @@ -1,44 +0,0 @@ -package proj2aci - -import ( - "fmt" - "io/ioutil" - "strings" -) - -// GetBinaryName checks if useBinary is in binDir and returns it. If -// useBinary is empty it returns a binary name if there is only one -// such in binDir. Otherwise it returns an error. -func GetBinaryName(binDir, useBinary string) (string, error) { - fi, err := ioutil.ReadDir(binDir) - if err != nil { - return "", err - } - - switch { - case len(fi) < 1: - return "", fmt.Errorf("No binaries found in %q", binDir) - case len(fi) == 1: - name := fi[0].Name() - if useBinary != "" && name != useBinary { - return "", fmt.Errorf("No such binary found in %q: %q. There is only %q", binDir, useBinary, name) - } - Debug("found binary: ", name) - return name, nil - case len(fi) > 1: - names := []string{} - for _, v := range fi { - names = append(names, v.Name()) - } - if useBinary == "" { - return "", fmt.Errorf("Found multiple binaries in %q, but no specific binary is preferred. Please specify which binary to pick up. Following binaries are available: %q", binDir, strings.Join(names, `", "`)) - } - for _, v := range names { - if v == useBinary { - return v, nil - } - } - return "", fmt.Errorf("No such binary found in %q: %q. There are following binaries available: %q", binDir, useBinary, strings.Join(names, `", "`)) - } - panic("Reaching this point shouldn't be possible.") -} diff --git a/Godeps/_workspace/src/github.com/appc/goaci/proj2aci/builder.go b/Godeps/_workspace/src/github.com/appc/goaci/proj2aci/builder.go deleted file mode 100644 index e512c572af..0000000000 --- a/Godeps/_workspace/src/github.com/appc/goaci/proj2aci/builder.go +++ /dev/null @@ -1,365 +0,0 @@ -package proj2aci - -import ( - "archive/tar" - "compress/gzip" - "fmt" - "io/ioutil" - "os" - "path/filepath" - "runtime" - - "github.com/appc/spec/aci" - "github.com/appc/spec/schema" - "github.com/appc/spec/schema/types" -) - -// CommonConfiguration keeps configuration items common for all the -// builders. Users of a Builder are supposed to create a -// BuilderCustomizations instance, get a CommonConfiguration instance -// via GetCommonConfiguration function and modify it before running -// Builder.Run(). -type CommonConfiguration struct { - Exec []string - UseBinary string - Assets []string - KeepTmpDir bool - TmpDir string - ReuseTmpDir string - Project string -} - -// CommonPaths keeps some paths common for all builders. Implementers -// of new BuilderCustomizations can read those after they are set up. -type CommonPaths struct { - TmpDir string - AciDir string - RootFS string -} - -// BuilderCustomizations is an interface for customizing a build -// process. The order of function roughly describe the build process. -type BuilderCustomizations interface { - Name() string - GetCommonConfiguration() *CommonConfiguration - ValidateConfiguration() error - GetCommonPaths() *CommonPaths - SetupPaths() error - GetDirectoriesToMake() []string - PrepareProject() error - GetPlaceholderMapping() map[string]string - GetAssets(aciBinDir string) ([]string, error) - GetImageName() (*types.ACIdentifier, error) - GetBinaryName() (string, error) - GetRepoPath() (string, error) - GetImageFileName() (string, error) -} - -type Builder struct { - manifest *schema.ImageManifest - aciBinDir string - custom BuilderCustomizations -} - -func NewBuilder(custom BuilderCustomizations) *Builder { - return &Builder{ - manifest: nil, - aciBinDir: "/", - custom: custom, - } -} - -func (cmd *Builder) Name() string { - return cmd.custom.Name() -} - -func (cmd *Builder) Run() error { - Info("Validating builder configuration") - if err := cmd.validateConfiguration(); err != nil { - return err - } - - Info("Setting up paths") - if err := cmd.setupPaths(); err != nil { - return err - } - - config := cmd.custom.GetCommonConfiguration() - paths := cmd.custom.GetCommonPaths() - if config.KeepTmpDir { - Info(fmt.Sprintf("Preserving temporary directory %q", paths.TmpDir)) - } else { - defer os.RemoveAll(paths.TmpDir) - } - - if config.ReuseTmpDir != "" { - Info("Reusing temporary directory") - Info("Deleting old ACI contents") - if err := os.RemoveAll(paths.AciDir); err != nil { - return err - } - - Info("Creating directories") - if err := cmd.makeDirectories(); err != nil { - return err - } - } else { - Info("Creating directories") - if err := cmd.makeDirectories(); err != nil { - return err - } - - Info("Preparing a project") - if err := cmd.prepareProject(); err != nil { - return err - } - } - - Info("Copying assets to ACI directory") - if err := cmd.copyAssets(); err != nil { - return err - } - - Info("Preparing manifest") - if err := cmd.prepareManifest(); err != nil { - return err - } - - Info("Writing ACI") - if name, err := cmd.writeACI(); err != nil { - return err - } else { - Info(fmt.Sprintf("Done, wrote %q", name)) - } - return nil -} - -func (cmd *Builder) validateConfiguration() error { - config := cmd.custom.GetCommonConfiguration() - if config == nil { - panic("common configuration is nil") - } - if config.Project == "" { - fmt.Errorf("Got no project to build") - } - - if config.TmpDir != "" && config.ReuseTmpDir != "" && config.TmpDir != config.ReuseTmpDir { - return fmt.Errorf("Specified both tmp dir to reuse and a tmp dir and they are different. ") - } - if !DirExists(config.ReuseTmpDir) { - return fmt.Errorf("Invalid tmp dir to reuse") - } - - return cmd.custom.ValidateConfiguration() -} - -func (cmd *Builder) setupPaths() error { - config := cmd.custom.GetCommonConfiguration() - paths := cmd.custom.GetCommonPaths() - tmpDir := "" - if config.TmpDir != "" { - tmpDir = config.TmpDir - } else if config.ReuseTmpDir != "" { - tmpDir = config.ReuseTmpDir - } else { - tmpName := fmt.Sprintf("proj2aci-%s-", cmd.custom.Name()) - aTmpDir, err := ioutil.TempDir("", tmpName) - if err != nil { - return fmt.Errorf("Failed to set up temporary directory: %v", err) - } - tmpDir = aTmpDir - } - paths.TmpDir = tmpDir - paths.AciDir = filepath.Join(paths.TmpDir, "aci") - paths.RootFS = filepath.Join(paths.AciDir, "rootfs") - return cmd.custom.SetupPaths() -} - -func (cmd *Builder) makeDirectories() error { - paths := cmd.custom.GetCommonPaths() - config := cmd.custom.GetCommonConfiguration() - - toMake := []string{} - if config.ReuseTmpDir == "" && config.TmpDir != "" { - tmpDirs, err := tmpDirList(paths.TmpDir) - if err != nil { - return err - } - toMake = append(toMake, tmpDirs...) - } - toMake = append(toMake, paths.AciDir, paths.RootFS) - if config.ReuseTmpDir == "" { - toMake = append(toMake, cmd.custom.GetDirectoriesToMake()...) - } - - for _, dir := range toMake { - Debug("mkdir ", dir) - if err := os.Mkdir(dir, 0755); err != nil { - return fmt.Errorf("Failed to make directory %q: %v", dir, err) - } - } - return nil -} - -func tmpDirList(path string) ([]string, error) { - list := []string{} - test := path - for { - if _, err := os.Stat(test); err != nil { - if !os.IsNotExist(err) { - return nil, err - } - // prepend - list = append([]string{test}, list...) - test = filepath.Dir(test) - } else { - break - } - } - return list, nil -} - -func (cmd *Builder) prepareProject() error { - return cmd.custom.PrepareProject() -} - -func (cmd *Builder) copyAssets() error { - paths := cmd.custom.GetCommonPaths() - config := cmd.custom.GetCommonConfiguration() - mapping := cmd.custom.GetPlaceholderMapping() - customAssets, err := cmd.custom.GetAssets(cmd.aciBinDir) - if err != nil { - return err - } - assets := append(config.Assets, customAssets...) - if err := PrepareAssets(assets, paths.RootFS, mapping); err != nil { - return err - } - return nil -} - -func (cmd *Builder) prepareManifest() error { - name, err := cmd.custom.GetImageName() - if err != nil { - return err - } - labels, err := cmd.getLabels() - if err != nil { - return err - } - app, err := cmd.getApp() - if err != nil { - return err - } - - cmd.manifest = schema.BlankImageManifest() - cmd.manifest.Name = *name - cmd.manifest.App = app - cmd.manifest.Labels = labels - return nil -} - -func (cmd *Builder) getApp() (*types.App, error) { - binaryName, err := cmd.custom.GetBinaryName() - if err != nil { - return nil, err - } - exec := []string{filepath.Join(cmd.aciBinDir, binaryName)} - config := cmd.custom.GetCommonConfiguration() - - return &types.App{ - Exec: append(exec, config.Exec...), - User: "0", - Group: "0", - }, nil -} - -func (cmd *Builder) getLabels() (types.Labels, error) { - arch, err := newLabel("arch", runtime.GOARCH) - if err != nil { - return nil, err - } - os, err := newLabel("os", runtime.GOOS) - if err != nil { - return nil, err - } - - labels := types.Labels{ - *arch, - *os, - } - - vcsLabel, err := cmd.getVCSLabel() - if err != nil { - return nil, err - } else if vcsLabel != nil { - labels = append(labels, *vcsLabel) - } - - return labels, nil -} - -func newLabel(name, value string) (*types.Label, error) { - acName, err := types.NewACIdentifier(name) - if err != nil { - return nil, err - } - return &types.Label{ - Name: *acName, - Value: value, - }, nil -} - -func (cmd *Builder) getVCSLabel() (*types.Label, error) { - repoPath, err := cmd.custom.GetRepoPath() - if err != nil { - return nil, err - } - if repoPath == "" { - return nil, nil - } - name, value, err := GetVCSInfo(repoPath) - if err != nil { - return nil, fmt.Errorf("Failed to get VCS info: %v", err) - } - acname, err := types.NewACIdentifier(name) - if err != nil { - return nil, fmt.Errorf("Invalid VCS label: %v", err) - } - return &types.Label{ - Name: *acname, - Value: value, - }, nil -} - -func (cmd *Builder) writeACI() (string, error) { - mode := os.O_CREATE | os.O_WRONLY | os.O_TRUNC - filename, err := cmd.custom.GetImageFileName() - if err != nil { - return "", err - } - of, err := os.OpenFile(filename, mode, 0644) - if err != nil { - return "", fmt.Errorf("Error opening output file: %v", err) - } - defer of.Close() - - gw := gzip.NewWriter(of) - defer gw.Close() - - tr := tar.NewWriter(gw) - defer tr.Close() - - // FIXME: the files in the tar archive are added with the - // wrong uid/gid. The uid/gid of the aci builder leaks in the - // tar archive. See: https://github.com/appc/goaci/issues/16 - iw := aci.NewImageWriter(*cmd.manifest, tr) - paths := cmd.custom.GetCommonPaths() - if err := filepath.Walk(paths.AciDir, aci.BuildWalker(paths.AciDir, iw, nil)); err != nil { - return "", err - } - if err := iw.Close(); err != nil { - return "", err - } - return of.Name(), nil -} diff --git a/Godeps/_workspace/src/github.com/appc/goaci/proj2aci/cmake.go b/Godeps/_workspace/src/github.com/appc/goaci/proj2aci/cmake.go deleted file mode 100644 index e8dea907d0..0000000000 --- a/Godeps/_workspace/src/github.com/appc/goaci/proj2aci/cmake.go +++ /dev/null @@ -1,234 +0,0 @@ -package proj2aci - -import ( - "fmt" - "os" - "path/filepath" - "runtime" - "strings" - - "github.com/appc/spec/schema" - "github.com/appc/spec/schema/types" - - "golang.org/x/tools/go/vcs" -) - -type CmakeConfiguration struct { - CommonConfiguration - BinDir string - ReuseSrcDir string - CmakeParams []string -} - -type CmakePaths struct { - CommonPaths - src string - build string - install string - binDir string -} - -type CmakeCustomizations struct { - Configuration CmakeConfiguration - - paths CmakePaths - fullBinPath string -} - -func (custom *CmakeCustomizations) Name() string { - return "cmake" -} - -func (custom *CmakeCustomizations) GetCommonConfiguration() *CommonConfiguration { - return &custom.Configuration.CommonConfiguration -} - -func (custom *CmakeCustomizations) ValidateConfiguration() error { - if !DirExists(custom.Configuration.ReuseSrcDir) { - return fmt.Errorf("Invalid src dir to reuse") - } - return nil -} - -func (custom *CmakeCustomizations) GetCommonPaths() *CommonPaths { - return &custom.paths.CommonPaths -} - -func (custom *CmakeCustomizations) SetupPaths() error { - setupReusableDir(&custom.paths.src, custom.Configuration.ReuseSrcDir, filepath.Join(custom.paths.TmpDir, "src")) - custom.paths.build = filepath.Join(custom.paths.TmpDir, "build") - custom.paths.install = filepath.Join(custom.paths.TmpDir, "install") - return nil -} - -func setupReusableDir(path *string, reusePath, stockPath string) { - if path == nil { - panic("path in setupReusableDir cannot be nil") - } - if reusePath != "" { - *path = reusePath - } else { - *path = stockPath - } -} - -func (custom *CmakeCustomizations) GetDirectoriesToMake() []string { - dirs := []string{ - custom.paths.build, - custom.paths.install, - } - // not creating custom.paths.src, because go.vcs requires the - // src directory to be nonexistent - return dirs -} - -func (custom *CmakeCustomizations) PrepareProject() error { - if custom.Configuration.ReuseSrcDir == "" { - if err := custom.createRepo(); err != nil { - return err - } - } - - Info("Running cmake") - if err := custom.runCmake(); err != nil { - return err - } - - Info("Running make") - if err := custom.runMake(); err != nil { - return err - } - - Info("Running make install") - if err := custom.runMakeInstall(); err != nil { - return err - } - - return nil -} - -func (custom *CmakeCustomizations) createRepo() error { - Info(fmt.Sprintf("Downloading %s", custom.Configuration.Project)) - repo, err := vcs.RepoRootForImportPath(custom.Configuration.Project, false) - if err != nil { - return err - } - return repo.VCS.Create(custom.paths.src, repo.Repo) -} - -func (custom *CmakeCustomizations) runCmake() error { - args := []string{"cmake"} - args = append(args, custom.Configuration.CmakeParams...) - args = append(args, custom.paths.src) - return RunCmd(args, nil, custom.paths.build) -} - -func (custom *CmakeCustomizations) runMake() error { - args := []string{ - "make", - fmt.Sprintf("-j%d", runtime.NumCPU()), - } - return RunCmd(args, nil, custom.paths.build) -} - -func (custom *CmakeCustomizations) runMakeInstall() error { - args := []string{ - "make", - "install", - } - env := append(os.Environ(), "DESTDIR="+custom.paths.install) - return RunCmd(args, env, custom.paths.build) -} - -func (custom *CmakeCustomizations) GetPlaceholderMapping() map[string]string { - return map[string]string{ - "": custom.paths.src, - "": custom.paths.build, - "": custom.paths.install, - } -} - -func (custom *CmakeCustomizations) GetAssets(aciBinDir string) ([]string, error) { - binaryName, err := custom.GetBinaryName() - if err != nil { - return nil, err - } - rootBinary := filepath.Join(aciBinDir, binaryName) - return []string{GetAssetString(rootBinary, custom.fullBinPath)}, nil -} - -func (custom *CmakeCustomizations) getBinDir() (string, error) { - if custom.Configuration.BinDir != "" { - return filepath.Join(custom.paths.install, custom.Configuration.BinDir), nil - } - dirs := []string{ - "/usr/local/sbin", - "/usr/local/bin", - "/usr/sbin", - "/usr/bin", - "/sbin", - "/bin", - } - for _, dir := range dirs { - path := filepath.Join(custom.paths.install, dir) - _, err := os.Stat(path) - if err != nil { - if os.IsNotExist(err) { - continue - } - return "", err - } - return path, nil - } - return "", fmt.Errorf("Could not find any bin directory") -} - -func (custom *CmakeCustomizations) GetImageName() (*types.ACIdentifier, error) { - imageName := custom.Configuration.Project - if filepath.Base(imageName) == "..." { - imageName = filepath.Dir(imageName) - if custom.Configuration.UseBinary != "" { - imageName += "-" + custom.Configuration.UseBinary - } - } - return types.NewACIdentifier(strings.ToLower(imageName)) -} - -func (custom *CmakeCustomizations) GetBinaryName() (string, error) { - if err := custom.findFullBinPath(); err != nil { - return "", err - } - - return filepath.Base(custom.fullBinPath), nil -} - -func (custom *CmakeCustomizations) findFullBinPath() error { - if custom.fullBinPath != "" { - return nil - } - binDir, err := custom.getBinDir() - if err != nil { - return err - } - binary, err := GetBinaryName(binDir, custom.Configuration.UseBinary) - if err != nil { - return err - } - custom.fullBinPath = filepath.Join(binDir, binary) - return nil -} - -func (custom *CmakeCustomizations) GetRepoPath() (string, error) { - return custom.paths.src, nil -} - -func (custom *CmakeCustomizations) GetImageFileName() (string, error) { - base := filepath.Base(custom.Configuration.Project) - if base == "..." { - base = filepath.Base(filepath.Dir(custom.Configuration.Project)) - if custom.Configuration.UseBinary != "" { - base += "-" + custom.Configuration.UseBinary - } - } - return base + schema.ACIExtension, nil -} diff --git a/Godeps/_workspace/src/github.com/appc/goaci/proj2aci/go.go b/Godeps/_workspace/src/github.com/appc/goaci/proj2aci/go.go deleted file mode 100644 index 2ebed255a4..0000000000 --- a/Godeps/_workspace/src/github.com/appc/goaci/proj2aci/go.go +++ /dev/null @@ -1,195 +0,0 @@ -package proj2aci - -import ( - "fmt" - "os" - "os/exec" - "path/filepath" - "strings" - - "github.com/appc/spec/schema" - "github.com/appc/spec/schema/types" -) - -type GoConfiguration struct { - CommonConfiguration - GoBinary string - GoPath string -} - -type GoPaths struct { - CommonPaths - project string - realGo string - fakeGo string - goRoot string - goBin string -} - -type GoCustomizations struct { - Configuration GoConfiguration - - paths GoPaths - app string -} - -func (custom *GoCustomizations) Name() string { - return "go" -} - -func (custom *GoCustomizations) GetCommonConfiguration() *CommonConfiguration { - return &custom.Configuration.CommonConfiguration -} - -func (custom *GoCustomizations) GetCommonPaths() *CommonPaths { - return &custom.paths.CommonPaths -} - -func (custom *GoCustomizations) ValidateConfiguration() error { - if custom.Configuration.GoBinary == "" { - return fmt.Errorf("Go binary not found") - } - return nil -} - -func (custom *GoCustomizations) SetupPaths() error { - custom.paths.realGo, custom.paths.fakeGo = custom.getGoPath() - - if os.Getenv("GOPATH") != "" { - Warn("GOPATH env var is ignored, use --go-path=\"$GOPATH\" option instead") - } - custom.paths.goRoot = os.Getenv("GOROOT") - if custom.paths.goRoot != "" { - Warn("Overriding GOROOT env var to ", custom.paths.goRoot) - } - - projectName := getProjectName(custom.Configuration.Project) - // Project name is path-like string with slashes, but slash is - // not a file separator on every OS. - custom.paths.project = filepath.Join(custom.paths.realGo, "src", filepath.Join(strings.Split(projectName, "/")...)) - custom.paths.goBin = filepath.Join(custom.paths.fakeGo, "bin") - return nil -} - -// getGoPath returns go path and fake go path. The former is either in -// /tmp (which is a default) or some other path as specified by -// --go-path parameter. The latter is always in /tmp. -func (custom *GoCustomizations) getGoPath() (string, string) { - fakeGoPath := filepath.Join(custom.paths.TmpDir, "gopath") - if custom.Configuration.GoPath == "" { - return fakeGoPath, fakeGoPath - } - return custom.Configuration.GoPath, fakeGoPath -} - -func getProjectName(project string) string { - if filepath.Base(project) != "..." { - return project - } - return filepath.Dir(project) -} - -func (custom *GoCustomizations) GetDirectoriesToMake() []string { - return []string{ - custom.paths.fakeGo, - custom.paths.goBin, - } -} - -func (custom *GoCustomizations) PrepareProject() error { - Info("Running go get") - // Construct args for a go get that does a static build - args := []string{ - "go", - "get", - "-a", - custom.Configuration.Project, - } - - env := []string{ - "GOPATH=" + custom.paths.realGo, - "GOBIN=" + custom.paths.goBin, - "PATH=" + os.Getenv("PATH"), - } - if custom.paths.goRoot != "" { - env = append(env, "GOROOT="+custom.paths.goRoot) - } - - cmd := exec.Cmd{ - Env: env, - Path: custom.Configuration.GoBinary, - Args: args, - Stderr: os.Stderr, - Stdout: os.Stdout, - } - Debug("env: ", cmd.Env) - Debug("running command: ", strings.Join(cmd.Args, " ")) - if err := cmd.Run(); err != nil { - return err - } - return nil -} - -func (custom *GoCustomizations) GetPlaceholderMapping() map[string]string { - return map[string]string{ - "": custom.paths.project, - "": custom.paths.realGo, - } -} - -func (custom *GoCustomizations) GetAssets(aciBinDir string) ([]string, error) { - name, err := custom.GetBinaryName() - if err != nil { - return nil, err - } - aciAsset := filepath.Join(aciBinDir, name) - localAsset := filepath.Join(custom.paths.goBin, name) - - return []string{GetAssetString(aciAsset, localAsset)}, nil -} - -func (custom *GoCustomizations) GetImageName() (*types.ACIdentifier, error) { - imageName := custom.Configuration.Project - if filepath.Base(imageName) == "..." { - imageName = filepath.Dir(imageName) - if custom.Configuration.UseBinary != "" { - imageName += "-" + custom.Configuration.UseBinary - } - } - return types.NewACIdentifier(strings.ToLower(imageName)) -} - -func (custom *GoCustomizations) GetBinaryName() (string, error) { - if err := custom.findBinaryName(); err != nil { - return "", err - } - - return custom.app, nil -} - -func (custom *GoCustomizations) findBinaryName() error { - if custom.app != "" { - return nil - } - binaryName, err := GetBinaryName(custom.paths.goBin, custom.Configuration.UseBinary) - if err != nil { - return err - } - custom.app = binaryName - return nil -} - -func (custom *GoCustomizations) GetRepoPath() (string, error) { - return custom.paths.project, nil -} - -func (custom *GoCustomizations) GetImageFileName() (string, error) { - base := filepath.Base(custom.Configuration.Project) - if base == "..." { - base = filepath.Base(filepath.Dir(custom.Configuration.Project)) - if custom.Configuration.UseBinary != "" { - base += "-" + custom.Configuration.UseBinary - } - } - return base + schema.ACIExtension, nil -} diff --git a/Godeps/_workspace/src/github.com/appc/goaci/proj2aci/run.go b/Godeps/_workspace/src/github.com/appc/goaci/proj2aci/run.go deleted file mode 100644 index 532990f30d..0000000000 --- a/Godeps/_workspace/src/github.com/appc/goaci/proj2aci/run.go +++ /dev/null @@ -1,65 +0,0 @@ -package proj2aci - -import ( - "fmt" - "io" - "os" - "os/exec" - "strings" -) - -type CmdFailedError struct { - Err error -} - -func (e CmdFailedError) Error() string { - return fmt.Sprintf("CmdFailedError: %s", e.Err.Error()) -} - -type CmdNotFoundError struct { - Err error -} - -func (e CmdNotFoundError) Error() string { - return fmt.Sprintf("CmdNotFoundError: %s", e.Err.Error()) -} - -// RunCmdFull runs given execProg. execProg should be an absolute path -// to a program or it can be an empty string. In the latter case first -// string in args is taken and searched for in $PATH. -// -// If execution fails then CmdFailedError is returned. This can be -// useful if we don't care if execution fails or not. CmdNotFoundError -// is returned if executable is not found. -func RunCmdFull(execProg string, args, env []string, cwd string, stdout, stderr io.Writer) error { - if len(args) < 1 { - return fmt.Errorf("No args to execute passed") - } - prog := execProg - if prog == "" { - pathProg, err := exec.LookPath(args[0]) - if err != nil { - return CmdNotFoundError{err} - } - prog = pathProg - } else if _, err := os.Stat(prog); err != nil { - return CmdNotFoundError{err} - } - cmd := exec.Cmd{ - Path: prog, - Args: args, - Env: env, - Dir: cwd, - Stdout: stdout, - Stderr: stderr, - } - Debug(`running command: "`, strings.Join(args, `" "`), `"`) - if err := cmd.Run(); err != nil { - return CmdFailedError{err} - } - return nil -} - -func RunCmd(args, env []string, cwd string) error { - return RunCmdFull("", args, env, cwd, os.Stdout, os.Stderr) -} diff --git a/Godeps/_workspace/src/github.com/appc/goaci/proj2aci/util.go b/Godeps/_workspace/src/github.com/appc/goaci/proj2aci/util.go deleted file mode 100644 index 177c28c805..0000000000 --- a/Godeps/_workspace/src/github.com/appc/goaci/proj2aci/util.go +++ /dev/null @@ -1,68 +0,0 @@ -package proj2aci - -import ( - "fmt" - "io" - "os" - "path/filepath" - "strings" - "unicode/utf8" -) - -var debugEnabled bool -var pathListSep string - -// DirExists checks if directory exists if given path is not empty. -// -// This function is rather specific as it is mostly used for checking -// overrides validity (like overriding temporary directory, where -// empty string means "do not override"). -func DirExists(path string) bool { - if path != "" { - fi, err := os.Stat(path) - if err != nil || !fi.IsDir() { - return false - } - } - return true -} - -func printTo(w io.Writer, i ...interface{}) { - s := fmt.Sprint(i...) - fmt.Fprintln(w, strings.TrimSuffix(s, "\n")) -} - -func Warn(i ...interface{}) { - printTo(os.Stderr, i...) -} - -func Info(i ...interface{}) { - printTo(os.Stdout, i...) -} - -func Debug(i ...interface{}) { - if debugEnabled { - printTo(os.Stdout, i...) - } -} - -func InitDebug() { - if os.Getenv("GOACI_DEBUG") != "" { - debugEnabled = true - } -} - -// listSeparator returns filepath.ListSeparator rune as a string. -func listSeparator() string { - if pathListSep == "" { - len := utf8.RuneLen(filepath.ListSeparator) - if len < 0 { - panic("filepath.ListSeparator is not valid utf8?!") - } - buf := make([]byte, len) - len = utf8.EncodeRune(buf, filepath.ListSeparator) - pathListSep = string(buf[:len]) - } - - return pathListSep -} diff --git a/Godeps/_workspace/src/github.com/appc/goaci/proj2aci/vcs.go b/Godeps/_workspace/src/github.com/appc/goaci/proj2aci/vcs.go deleted file mode 100644 index 8a6d88b860..0000000000 --- a/Godeps/_workspace/src/github.com/appc/goaci/proj2aci/vcs.go +++ /dev/null @@ -1,118 +0,0 @@ -package proj2aci - -import ( - "bytes" - "fmt" - "os" - "os/exec" - "path/filepath" - "strings" -) - -func repoDirExists(projPath, repoDir string) bool { - path := filepath.Join(projPath, repoDir) - info, err := os.Stat(path) - if err != nil { - return false - } - return info.IsDir() -} - -// getId gets first line of commands output which should hold some VCS -// specific id of current code checkout. -func getId(dir, cmd string, params []string) (string, error) { - args := []string{cmd} - args = append(args, params...) - buffer := new(bytes.Buffer) - cmdPath, err := exec.LookPath(cmd) - if err != nil { - return "", nil - } - process := &exec.Cmd{ - Path: cmdPath, - Args: args, - Env: []string{ - "PATH=" + os.Getenv("PATH"), - }, - Dir: dir, - Stdout: buffer, - } - if err := process.Run(); err != nil { - return "", err - } - output := string(buffer.Bytes()) - if newline := strings.Index(output, "\n"); newline < 0 { - return output, nil - } else { - return output[:newline], nil - } -} - -func getLabelAndId(label, path, cmd string, params []string) (string, string, error) { - if info, err := getId(path, cmd, params); err != nil { - return "", "", err - } else { - return label, info, nil - } -} - -type VCSInfo interface { - IsValid(path string) bool - GetLabelAndId(path string) (string, string, error) -} - -type GitInfo struct{} - -func (info GitInfo) IsValid(path string) bool { - return repoDirExists(path, ".git") -} - -func (info GitInfo) GetLabelAndId(path string) (string, string, error) { - return getLabelAndId("git", path, "git", []string{"rev-parse", "HEAD"}) -} - -type HgInfo struct{} - -func (info HgInfo) IsValid(path string) bool { - return repoDirExists(path, ".hg") -} - -func (info HgInfo) GetLabelAndId(path string) (string, string, error) { - return getLabelAndId("hg", path, "hg", []string{"id", "-i"}) -} - -type SvnInfo struct{} - -func (info SvnInfo) IsValid(path string) bool { - return repoDirExists(path, ".svn") -} - -func (info SvnInfo) GetLabelAndId(path string) (string, string, error) { - return getLabelAndId("svn", path, "svnversion", []string{}) -} - -type BzrInfo struct{} - -func (info BzrInfo) IsValid(path string) bool { - return repoDirExists(path, ".bzr") -} - -func (info BzrInfo) GetLabelAndId(path string) (string, string, error) { - return getLabelAndId("bzr", path, "bzr", []string{"revno"}) -} - -func GetVCSInfo(projPath string) (string, string, error) { - vcses := []VCSInfo{ - GitInfo{}, - HgInfo{}, - SvnInfo{}, - BzrInfo{}, - } - - for _, vcs := range vcses { - if vcs.IsValid(projPath) { - return vcs.GetLabelAndId(projPath) - } - } - return "", "", fmt.Errorf("Unknown code repository in %q", projPath) -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/LICENSE b/Godeps/_workspace/src/github.com/appc/spec/LICENSE deleted file mode 100644 index e06d208186..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor 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, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - diff --git a/Godeps/_workspace/src/github.com/appc/spec/ace/build_aci b/Godeps/_workspace/src/github.com/appc/spec/ace/build_aci deleted file mode 100644 index ebfc225661..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/ace/build_aci +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env bash -# -# Builds an ACI containing a go implementation of an ACE validator -# -set -eu - -PREFIX="ace" -: ${NO_SIGNATURE=} -GOOS="$(go env GOOS)" -GOARCH="$(go env GOARCH)" - -if ! [[ $0 =~ "${PREFIX}/build_aci" ]]; then - echo "invoke from repository root" 1>&2 - exit 255 -fi - -if ! [[ -f "bin/ace-validator" ]]; then - ./build -fi - -for typ in main sidekick; do - layoutdir="bin/ace-${typ}-layout" - mkdir -p ${layoutdir}/rootfs/opt/acvalidator - cp bin/ace-validator ${layoutdir}/rootfs/ - sed -e "s/@GOOS@/$GOOS/" -e "s/@GOARCH@/$GOARCH/" < ${PREFIX}/image_manifest_${typ}.json.in > ${layoutdir}/manifest - # now build the tarball, and sign it - pushd ${layoutdir} >/dev/null - # Set a consistent timestamp so we get a consistent hash - # TODO(jonboulle): make this cleaner.. - for path in rootfs rootfs/ace-validator; do - touch -a -m -d 1970-01-01T00:00:00Z ${path} - done - ../actool build --overwrite ./ ../ace-validator-${typ}.aci - # TODO(jonboulle): create uncompressed instead, then gzip? - HASH=sha512-$(gzip -d -f ../ace-validator-${typ}.aci -c | openssl dgst -sha512 -hex -r | awk '{print $1}') - if [ -z "$NO_SIGNATURE" ] ; then - gpg --cipher-algo AES256 --armor --output ace-validator-${typ}.aci.asc --detach-sig ../ace-validator-${typ}.aci - mv ace-validator-${typ}.aci.asc ../ - fi - popd >/dev/null - echo "Wrote ${typ} layout to ${layoutdir}" - echo "Wrote unsigned ${typ} ACI bin/ace-validator-${typ}.aci" - ln -s ${PWD}/bin/ace-validator-${typ}.aci bin/${HASH} - echo "Wrote ${typ} layout hash bin/${HASH}" - if [ -f "bin/ace-validator-${typ}.aci.asc" ]; then - echo "Wrote ${typ} ACI signature bin/ace-validator-${typ}.aci.asc" - fi -done diff --git a/Godeps/_workspace/src/github.com/appc/spec/ace/doc.go b/Godeps/_workspace/src/github.com/appc/spec/ace/doc.go deleted file mode 100644 index 476f2c9557..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/ace/doc.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package ace contains a tool intended to be run within an _Application -// Container Executor_ to validate that the ACE has set up the container -// environment correctly. This tool can be built into an ACI image ready for -// running on an executor by using the `build_aci` script. -package main diff --git a/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_main.json.in b/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_main.json.in deleted file mode 100644 index 33157eeead..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_main.json.in +++ /dev/null @@ -1,80 +0,0 @@ -{ - "acVersion": "0.8.4", - "acKind": "ImageManifest", - "name": "coreos.com/ace-validator-main", - "labels": [ - { "name": "version", "value": "0.8.4" }, - { "name": "os", "value": "@GOOS@" }, - { "name": "arch", "value": "@GOARCH@" } - ], - "app": { - "exec": [ - "/ace-validator", "main" - ], - "eventHandlers": [ - { - "name": "pre-start", - "exec": [ - "/ace-validator", "prestart" - ] - }, - { - "name": "post-stop", - "exec": [ - "/ace-validator", "poststop" - ] - } - ], - "user": "0", - "group": "0", - "workingDirectory": "/opt/acvalidator", - "environment": [ - { - "name": "IN_ACE_VALIDATOR", - "value": "correct" - } - ], - "mountPoints": [ - { - "name": "database", - "path": "/db", - "readOnly": false - } - ], - "ports": [ - { - "name": "www", - "protocol": "tcp", - "port": 80 - } - ], - "isolators": [ - { - "name": "resource/memory", - "value": {"limit": "1G"} - } - ] - }, - "annotations": [ - { - "name": "created", - "value": "2014-10-27T19:32:27.67021798Z" - }, - { - "name": "authors", - "value": "Carly Container , Nat Network " - }, - { - "name": "homepage", - "value": "https://github.com/appc/spec" - }, - { - "name": "documentation", - "value": "https://github.com/appc/spec/blob/master/README.md" - }, - { - "name": "lorem", - "value": "ipsum" - } - ] -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_sidekick.json.in b/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_sidekick.json.in deleted file mode 100644 index a69bbcf66b..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/ace/image_manifest_sidekick.json.in +++ /dev/null @@ -1,24 +0,0 @@ -{ - "acVersion": "0.8.4", - "acKind": "ImageManifest", - "name": "coreos.com/ace-validator-sidekick", - "labels": [ - { "name": "version", "value": "0.8.4" }, - { "name": "os", "value": "@GOOS@" }, - { "name": "arch", "value": "@GOARCH@" } - ], - "app": { - "exec": [ - "/ace-validator", "sidekick" - ], - "user": "0", - "group": "0", - "mountPoints": [ - { - "name": "database", - "path": "/db", - "readOnly": false - } - ] - } -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/ace/os_default.go b/Godeps/_workspace/src/github.com/appc/spec/ace/os_default.go deleted file mode 100644 index 4810d4368f..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/ace/os_default.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// +build !linux -// +build !freebsd - -package main - -import ( - "syscall" -) - -func isSameFilesystem(a, b *syscall.Statfs_t) bool { - return a.Fsid == b.Fsid -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/ace/os_freebsd.go b/Godeps/_workspace/src/github.com/appc/spec/ace/os_freebsd.go deleted file mode 100644 index ec7ad0419f..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/ace/os_freebsd.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// +build freebsd - -package main - -import ( - "syscall" -) - -func isSameFilesystem(a, b *syscall.Statfs_t) bool { - if a.Fsid != (syscall.Fsid{}) || b.Fsid != (syscall.Fsid{}) { - // If Fsid is not empty, we can just compare the IDs - return a.Fsid == b.Fsid - } - // Fsids are zero, this happens in jails, but we can compare the rest - return a.Fstypename == b.Fstypename && - a.Mntfromname == b.Mntfromname && - a.Mntonname == b.Mntonname -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/ace/os_linux.go b/Godeps/_workspace/src/github.com/appc/spec/ace/os_linux.go deleted file mode 100644 index aedfc3ad59..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/ace/os_linux.go +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// +build linux - -package main - -import ( - "fmt" - "os" -) - -func checkMountImpl(d string, readonly bool) error { - mountinfoPath := fmt.Sprintf("/proc/self/mountinfo") - mi, err := os.Open(mountinfoPath) - if err != nil { - return err - } - defer mi.Close() - - isMounted, ro, err := parseMountinfo(mi, d) - if err != nil { - return err - } - if !isMounted { - return fmt.Errorf("%q is not a mount point", d) - } - - if ro == readonly { - return nil - } else { - return fmt.Errorf("%q mounted ro=%t, want %t", d, ro, readonly) - } -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/ace/os_shared.go b/Godeps/_workspace/src/github.com/appc/spec/ace/os_shared.go deleted file mode 100644 index 93964c3b12..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/ace/os_shared.go +++ /dev/null @@ -1,35 +0,0 @@ -// +build !linux - -package main - -import ( - "fmt" - "path/filepath" - "syscall" -) - -func checkMountStatfs(d string, readonly bool) error { - // or.... - // os.Stat(path).Sys().(*syscall.Stat_t).Dev - sfs1 := &syscall.Statfs_t{} - if err := syscall.Statfs(d, sfs1); err != nil { - return fmt.Errorf("error calling statfs on %q: %v", d, err) - } - sfs2 := &syscall.Statfs_t{} - if err := syscall.Statfs(filepath.Dir(d), sfs2); err != nil { - return fmt.Errorf("error calling statfs on %q: %v", d, err) - } - if isSameFilesystem(sfs1, sfs2) { - return fmt.Errorf("%q is not a mount point", d) - } - ro := sfs1.Flags&syscall.O_RDONLY == 1 - if ro != readonly { - return fmt.Errorf("%q mounted ro=%t, want %t", d, ro, readonly) - } - - return nil -} - -func checkMountImpl(d string, readonly bool) error { - return checkMountStatfs(d, readonly) -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/ace/validator.go b/Godeps/_workspace/src/github.com/appc/spec/ace/validator.go deleted file mode 100644 index fdd27ac222..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/ace/validator.go +++ /dev/null @@ -1,578 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -/* - -This validator tool is intended to be run within an App Container Executor -(ACE), and verifies that the ACE has been set up correctly. - -This verifies the _apps perspective_ of the execution environment. - -Changes to the validator need to be reflected in app_manifest.json, and vice-versa - -The App Container Execution spec defines the following expectations within the execution environment: - - Working Directory defaults to the root of the application image, overridden with "workingDirectory" - - PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - - USER, LOGNAME username of the user executing this app - - HOME home directory of the user - - SHELL login shell of the user - - AC_APP_NAME the entrypoint that this process was defined from - -In addition, we validate: - - The expected mount points are mounted - - metadata service reachable at http://169.254.169.255 - -TODO(jonboulle): - - should we validate Isolators? (e.g. MemoryLimit + malloc, or capabilities) - - should we validate ports? (e.g. that they are available to bind to within the network namespace of the pod) - -*/ - -import ( - "bufio" - "bytes" - "encoding/json" - "fmt" - "io" - "io/ioutil" - "net/http" - "net/url" - "os" - "reflect" - "strings" - "time" - - "github.com/appc/spec/schema" - "github.com/appc/spec/schema/types" -) - -const ( - standardPath = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" - appNameEnv = "AC_APP_NAME" - metadataPathBase = "/acMetadata/v1" - - // marker files to validate - prestartFile = "/prestart" - mainFile = "/main" - poststopFile = "/poststop" - - mainVolFile = "/db/main" - sidekickVolFile = "/db/sidekick" - - timeout = 5 * time.Second -) - -var ( - // Expected values must be kept in sync with app_manifest.json - workingDirectory = "/opt/acvalidator" - // "Environment" - env = map[string]string{ - "IN_ACE_VALIDATOR": "correct", - "HOME": "/root", - "USER": "root", - "LOGNAME": "root", - "SHELL": "/bin/sh", - } - // "MountPoints" - mps = map[string]types.MountPoint{ - "database": types.MountPoint{ - Path: "/db", - ReadOnly: false, - }, - } - // "Name" - an = "ace-validator-main" -) - -type results []error - -// main outputs diagnostic information to stderr and exits 1 if validation fails -func main() { - if len(os.Args) != 2 { - stderr("usage: %s [main|sidekick|preStart|postStop]", os.Args[0]) - os.Exit(64) - } - mode := os.Args[1] - var res results - switch strings.ToLower(mode) { - case "main": - res = validateMain() - case "sidekick": - res = validateSidekick() - case "prestart": - res = validatePrestart() - case "poststop": - res = validatePoststop() - default: - stderr("unrecognized mode: %s", mode) - os.Exit(64) - } - if len(res) == 0 { - fmt.Printf("%s OK\n", mode) - os.Exit(0) - } - fmt.Printf("%s FAIL\n", mode) - for _, err := range res { - fmt.Fprintln(os.Stderr, "==>", err) - } - os.Exit(1) -} - -func validateMain() (errs results) { - errs = append(errs, assertExists(prestartFile)...) - errs = append(errs, assertNotExistsAndCreate(mainFile)...) - errs = append(errs, assertNotExists(poststopFile)...) - errs = append(errs, ValidatePath(standardPath)...) - errs = append(errs, ValidateWorkingDirectory(workingDirectory)...) - errs = append(errs, ValidateEnvironment(env)...) - errs = append(errs, ValidateMountpoints(mps)...) - errs = append(errs, ValidateAppNameEnv(an)...) - errs = append(errs, ValidateMetadataSvc()...) - errs = append(errs, waitForFile(sidekickVolFile, timeout)...) - errs = append(errs, assertNotExistsAndCreate(mainVolFile)...) - return -} - -func validateSidekick() (errs results) { - errs = append(errs, assertNotExistsAndCreate(sidekickVolFile)...) - errs = append(errs, waitForFile(mainVolFile, timeout)...) - return -} - -func validatePrestart() (errs results) { - errs = append(errs, assertNotExistsAndCreate(prestartFile)...) - errs = append(errs, assertNotExists(mainFile)...) - errs = append(errs, assertNotExists(poststopFile)...) - return -} - -func validatePoststop() (errs results) { - errs = append(errs, assertExists(prestartFile)...) - errs = append(errs, assertExists(mainFile)...) - errs = append(errs, assertNotExistsAndCreate(poststopFile)...) - return -} - -// ValidatePath ensures that the PATH has been set up correctly within the -// environment in which this process is being run -func ValidatePath(wp string) results { - r := results{} - gp := os.Getenv("PATH") - if wp != gp { - r = append(r, fmt.Errorf("PATH not set appropriately (need %q, got %q)", wp, gp)) - } - return r -} - -// ValidateWorkingDirectory ensures that the process working directory is set -// to the desired path. -func ValidateWorkingDirectory(wwd string) (r results) { - gwd, err := os.Getwd() - if err != nil { - r = append(r, fmt.Errorf("error getting working directory: %v", err)) - return - } - if gwd != wwd { - r = append(r, fmt.Errorf("working directory not set appropriately (need %q, got %v)", wwd, gwd)) - } - return -} - -// ValidateEnvironment ensures that the given environment contains the -// necessary/expected environment variables. -func ValidateEnvironment(wenv map[string]string) (r results) { - for wkey, wval := range wenv { - gval := os.Getenv(wkey) - if gval != wval { - err := fmt.Errorf("environment variable %q not set appropriately (need %q, got %q)", wkey, wval, gval) - r = append(r, err) - } - } - return -} - -// ValidateAppNameEnv ensures that the environment variable specifying the -// entrypoint of this process is set correctly. -func ValidateAppNameEnv(want string) (r results) { - if got := os.Getenv(appNameEnv); got != want { - r = append(r, fmt.Errorf("%s not set appropriately (need %q, got %q)", appNameEnv, want, got)) - } - return -} - -// ValidateMountpoints ensures that the given mount points are present in the -// environment in which this process is running -func ValidateMountpoints(wmp map[string]types.MountPoint) results { - r := results{} - // TODO(jonboulle): verify actual source - for _, mp := range wmp { - if err := checkMount(mp.Path, mp.ReadOnly); err != nil { - r = append(r, err) - } - } - return r -} - -func metadataRequest(req *http.Request, expectedContentType string) ([]byte, error) { - cli := http.Client{ - Timeout: 100 * time.Millisecond, - } - - req.Header["Metadata-Flavor"] = []string{"AppContainer"} - - resp, err := cli.Do(req) - if err != nil { - return nil, err - } - - if resp.StatusCode != 200 { - return nil, fmt.Errorf("Get %s failed with %v", req.URL, resp.StatusCode) - } - - if respContentType := resp.Header.Get("Content-Type"); respContentType != expectedContentType { - return nil, fmt.Errorf("`%v` did not respond with expected Content-Type header. Expected %s, received %s", - req.URL, expectedContentType, respContentType) - } - - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return nil, fmt.Errorf("Get %s failed on body read: %v", req.URL, err) - } - - return body, nil -} - -func metadataGet(metadataURL, path string, expectedContentType string) ([]byte, error) { - uri := metadataURL + metadataPathBase + path - req, err := http.NewRequest("GET", uri, nil) - if err != nil { - panic(err) - } - - return metadataRequest(req, expectedContentType) -} - -func metadataPost(metadataURL, path string, body []byte, expectedContentType string) ([]byte, error) { - uri := metadataURL + metadataPathBase + path - req, err := http.NewRequest("POST", uri, bytes.NewBuffer(body)) - if err != nil { - panic(err) - } - req.Header.Set("Content-Type", "text/plain") - - return metadataRequest(req, expectedContentType) -} - -func metadataPostForm(metadataURL, path string, data url.Values, expectedContentType string) ([]byte, error) { - uri := metadataURL + metadataPathBase + path - req, err := http.NewRequest("POST", uri, strings.NewReader(data.Encode())) - if err != nil { - panic(err) - } - req.Header.Set("Content-Type", "application/x-www-form-urlencoded") - - return metadataRequest(req, expectedContentType) -} - -func validatePodAnnotations(metadataURL string, pm *schema.PodManifest) results { - r := results{} - - var actualAnnots types.Annotations - - annotJson, err := metadataGet(metadataURL, "/pod/annotations", "application/json") - if err != nil { - return append(r, err) - } - - err = json.Unmarshal(annotJson, &actualAnnots) - if err != nil { - return append(r, err) - } - - if !reflect.DeepEqual(actualAnnots, pm.Annotations) { - r = append(r, fmt.Errorf("pod annotations mismatch: %v vs %v", actualAnnots, pm.Annotations)) - } - - return r -} - -func validatePodMetadata(metadataURL string, pm *schema.PodManifest) results { - r := results{} - - uuid, err := metadataGet(metadataURL, "/pod/uuid", "text/plain; charset=us-ascii") - if err != nil { - return append(r, err) - } - - _, err = types.NewUUID(string(uuid)) - if err != nil { - return append(r, fmt.Errorf("malformed UUID returned (%v): %v", string(uuid), err)) - } - - return append(r, validatePodAnnotations(metadataURL, pm)...) -} - -func validateAppAnnotations(metadataURL string, pm *schema.PodManifest, app *schema.RuntimeApp, img *schema.ImageManifest) results { - r := results{} - - // build a map of expected annotations by merging app.Annotations - // with PodManifest overrides - expectedAnnots := app.Annotations - a := pm.Apps.Get(app.Name) - if a == nil { - panic("could not find app in manifest!") - } - for _, annot := range a.Annotations { - expectedAnnots.Set(annot.Name, annot.Value) - } - if len(expectedAnnots) == 0 { - expectedAnnots = nil - } - - var actualAnnots types.Annotations - - annotJson, err := metadataGet(metadataURL, "/apps/"+string(app.Name)+"/annotations", "application/json") - if err != nil { - return append(r, err) - } - - err = json.Unmarshal(annotJson, &actualAnnots) - if err != nil { - return append(r, err) - } - if len(actualAnnots) == 0 { - actualAnnots = nil - } - - if !reflect.DeepEqual(actualAnnots, expectedAnnots) { - err := fmt.Errorf("%v annotations mismatch: %v vs %v", app.Name, actualAnnots, expectedAnnots) - r = append(r, err) - } - - return r -} - -func validateAppMetadata(metadataURL string, pm *schema.PodManifest, app *schema.RuntimeApp) results { - r := results{} - - am, err := metadataGet(metadataURL, "/apps/"+app.Name.String()+"/image/manifest", "application/json") - if err != nil { - return append(r, err) - } - - img := &schema.ImageManifest{} - if err = json.Unmarshal(am, img); err != nil { - return append(r, fmt.Errorf("failed to JSON-decode %q manifest: %v", app.Name.String(), err)) - } - - id, err := metadataGet(metadataURL, "/apps/"+app.Name.String()+"/image/id", "text/plain; charset=us-ascii") - if err != nil { - r = append(r, err) - } - - if string(id) != app.Image.ID.String() { - err = fmt.Errorf("%q's image id mismatch: %v vs %v", app.Name.String(), id, app.Image.ID) - r = append(r, err) - } - - return append(r, validateAppAnnotations(metadataURL, pm, app, img)...) -} - -func validateSigning(metadataURL string, pm *schema.PodManifest) results { - r := results{} - - // Get our UUID - uuid, err := metadataGet(metadataURL, "/pod/uuid", "text/plain; charset=us-ascii") - if err != nil { - return append(r, err) - } - - plaintext := "Old MacDonald Had A Farm" - - // Sign - sig, err := metadataPostForm(metadataURL, "/pod/hmac/sign", url.Values{ - "content": []string{plaintext}, - }, "text/plain; charset=us-ascii") - if err != nil { - return append(r, err) - } - - // Verify - _, err = metadataPostForm(metadataURL, "/pod/hmac/verify", url.Values{ - "content": []string{plaintext}, - "uuid": []string{string(uuid)}, - "signature": []string{string(sig)}, - }, "text/plain; charset=us-ascii") - - if err != nil { - return append(r, err) - } - - return r -} - -func ValidateMetadataSvc() results { - r := results{} - - metadataURL := os.Getenv("AC_METADATA_URL") - if metadataURL == "" { - return append(r, fmt.Errorf("AC_METADATA_URL is not set")) - } - - pod, err := metadataGet(metadataURL, "/pod/manifest", "application/json") - if err != nil { - return append(r, err) - } - - pm := &schema.PodManifest{} - if err = json.Unmarshal(pod, pm); err != nil { - return append(r, fmt.Errorf("failed to JSON-decode pod manifest: %v", err)) - } - - r = append(r, validatePodMetadata(metadataURL, pm)...) - - for _, app := range pm.Apps { - app := app - r = append(r, validateAppMetadata(metadataURL, pm, &app)...) - } - - return append(r, validateSigning(metadataURL, pm)...) -} - -// checkMount checks that the given string is a mount point, and that it is -// mounted appropriately read-only or not according to the given bool -func checkMount(d string, readonly bool) error { - return checkMountImpl(d, readonly) -} - -// parseMountinfo parses a Reader representing a /proc/PID/mountinfo file and -// returns whether dir is mounted and if so, whether it is read-only or not -func parseMountinfo(mountinfo io.Reader, dir string) (isMounted bool, readOnly bool, err error) { - sc := bufio.NewScanner(mountinfo) - for sc.Scan() { - var ( - mountID int - parentID int - majorMinor string - root string - mountPoint string - mountOptions string - ) - - _, err := fmt.Sscanf(sc.Text(), "%d %d %s %s %s %s", - &mountID, &parentID, &majorMinor, &root, &mountPoint, &mountOptions) - if err != nil { - return false, false, err - } - - if mountPoint == dir { - isMounted = true - optionsParts := strings.Split(mountOptions, ",") - for _, o := range optionsParts { - switch o { - case "ro": - readOnly = true - case "rw": - readOnly = false - } - } - } - } - - return -} - -// assertNotExistsAndCreate asserts that a file at the given path does not -// exist, and then proceeds to create (touch) the file. It returns any errors -// encountered at either of these steps. -func assertNotExistsAndCreate(p string) []error { - var errs []error - errs = append(errs, assertNotExists(p)...) - if err := touchFile(p); err != nil { - errs = append(errs, fmt.Errorf("error touching file %q: %v", p, err)) - } - return errs -} - -// assertNotExists asserts that a file at the given path does not exist. A -// non-empty list of errors is returned if the file exists or any error is -// encountered while checking. -func assertNotExists(p string) []error { - var errs []error - e, err := fileExists(p) - if err != nil { - errs = append(errs, fmt.Errorf("error checking %q exists: %v", p, err)) - } - if e { - errs = append(errs, fmt.Errorf("file %q exists unexpectedly", p)) - } - return errs -} - -// assertExists asserts that a file exists at the given path. A non-empty -// list of errors is returned if the file does not exist or any error is -// encountered while checking. -func assertExists(p string) []error { - var errs []error - e, err := fileExists(p) - if err != nil { - errs = append(errs, fmt.Errorf("error checking %q exists: %v", p, err)) - } - if !e { - errs = append(errs, fmt.Errorf("file %q does not exist as expected", p)) - } - return errs -} - -// touchFile creates an empty file, returning any error encountered -func touchFile(p string) error { - _, err := os.Create(p) - return err -} - -// fileExists checks whether a file exists at the given path -func fileExists(p string) (bool, error) { - _, err := os.Stat(p) - if err == nil { - return true, nil - } - if os.IsNotExist(err) { - return false, nil - } - return false, err -} - -// waitForFile waits for the file at the given path to appear -func waitForFile(p string, to time.Duration) []error { - done := time.After(to) - for { - select { - case <-done: - return []error{ - fmt.Errorf("timed out waiting for %s", p), - } - case <-time.After(1): - if ok, _ := fileExists(p); ok { - return nil - } - } - } -} - -func stderr(format string, a ...interface{}) { - out := fmt.Sprintf(format, a...) - fmt.Fprintln(os.Stderr, strings.TrimSuffix(out, "\n")) -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/aci/build.go b/Godeps/_workspace/src/github.com/appc/spec/aci/build.go deleted file mode 100644 index 0d259a27f5..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/aci/build.go +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package aci - -import ( - "archive/tar" - "io" - "os" - "path/filepath" - - "github.com/appc/spec/pkg/tarheader" -) - -// TarHeaderWalkFunc is the type of the function which allows setting tar -// headers or filtering out tar entries when building an ACI. It will be -// applied to every entry in the tar file. -// -// If true is returned, the entry will be included in the final ACI; if false, -// the entry will not be included. -type TarHeaderWalkFunc func(hdr *tar.Header) bool - -// BuildWalker creates a filepath.WalkFunc that walks over the given root -// (which should represent an ACI layout on disk) and adds the files in the -// rootfs/ subdirectory to the given ArchiveWriter -func BuildWalker(root string, aw ArchiveWriter, cb TarHeaderWalkFunc) filepath.WalkFunc { - // cache of inode -> filepath, used to leverage hard links in the archive - inos := map[uint64]string{} - return func(path string, info os.FileInfo, err error) error { - if err != nil { - return err - } - relpath, err := filepath.Rel(root, path) - if err != nil { - return err - } - if relpath == "." { - return nil - } - if relpath == ManifestFile { - // ignore; this will be written by the archive writer - // TODO(jonboulle): does this make sense? maybe just remove from archivewriter? - return nil - } - - link := "" - var r io.Reader - switch info.Mode() & os.ModeType { - case os.ModeSocket: - return nil - case os.ModeNamedPipe: - case os.ModeCharDevice: - case os.ModeDevice: - case os.ModeDir: - case os.ModeSymlink: - target, err := os.Readlink(path) - if err != nil { - return err - } - link = target - default: - file, err := os.Open(path) - if err != nil { - return err - } - defer file.Close() - r = file - } - - hdr, err := tar.FileInfoHeader(info, link) - if err != nil { - panic(err) - } - // Because os.FileInfo's Name method returns only the base - // name of the file it describes, it may be necessary to - // modify the Name field of the returned header to provide the - // full path name of the file. - hdr.Name = relpath - tarheader.Populate(hdr, info, inos) - // If the file is a hard link to a file we've already seen, we - // don't need the contents - if hdr.Typeflag == tar.TypeLink { - hdr.Size = 0 - r = nil - } - - if cb != nil { - if !cb(hdr) { - return nil - } - } - - if err := aw.AddFile(hdr, r); err != nil { - return err - } - - return nil - } -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/aci/doc.go b/Godeps/_workspace/src/github.com/appc/spec/aci/doc.go deleted file mode 100644 index 624d431aff..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/aci/doc.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package aci contains various functions for working with App Container Images. -package aci diff --git a/Godeps/_workspace/src/github.com/appc/spec/aci/file.go b/Godeps/_workspace/src/github.com/appc/spec/aci/file.go deleted file mode 100644 index fe4e1b5bd9..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/aci/file.go +++ /dev/null @@ -1,246 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package aci - -import ( - "archive/tar" - "bytes" - "compress/bzip2" - "compress/gzip" - "encoding/hex" - "errors" - "fmt" - "io" - "io/ioutil" - "log" - "net/http" - "os/exec" - "path/filepath" - - "github.com/appc/spec/schema" -) - -type FileType string - -const ( - TypeGzip = FileType("gz") - TypeBzip2 = FileType("bz2") - TypeXz = FileType("xz") - TypeTar = FileType("tar") - TypeText = FileType("text") - TypeUnknown = FileType("unknown") - - readLen = 512 // max bytes to sniff - - hexHdrGzip = "1f8b" - hexHdrBzip2 = "425a68" - hexHdrXz = "fd377a585a00" - hexSigTar = "7573746172" - - tarOffset = 257 - - textMime = "text/plain; charset=utf-8" -) - -var ( - hdrGzip []byte - hdrBzip2 []byte - hdrXz []byte - sigTar []byte - tarEnd int -) - -func mustDecodeHex(s string) []byte { - b, err := hex.DecodeString(s) - if err != nil { - panic(err) - } - return b -} - -func init() { - hdrGzip = mustDecodeHex(hexHdrGzip) - hdrBzip2 = mustDecodeHex(hexHdrBzip2) - hdrXz = mustDecodeHex(hexHdrXz) - sigTar = mustDecodeHex(hexSigTar) - tarEnd = tarOffset + len(sigTar) -} - -// DetectFileType attempts to detect the type of file that the given reader -// represents by comparing it against known file signatures (magic numbers) -func DetectFileType(r io.Reader) (FileType, error) { - var b bytes.Buffer - n, err := io.CopyN(&b, r, readLen) - if err != nil && err != io.EOF { - return TypeUnknown, err - } - bs := b.Bytes() - switch { - case bytes.HasPrefix(bs, hdrGzip): - return TypeGzip, nil - case bytes.HasPrefix(bs, hdrBzip2): - return TypeBzip2, nil - case bytes.HasPrefix(bs, hdrXz): - return TypeXz, nil - case n > int64(tarEnd) && bytes.Equal(bs[tarOffset:tarEnd], sigTar): - return TypeTar, nil - case http.DetectContentType(bs) == textMime: - return TypeText, nil - default: - return TypeUnknown, nil - } -} - -// XzReader is an io.ReadCloser which decompresses xz compressed data. -type XzReader struct { - io.ReadCloser - cmd *exec.Cmd - closech chan error -} - -// NewXzReader shells out to a command line xz executable (if -// available) to decompress the given io.Reader using the xz -// compression format and returns an *XzReader. -// It is the caller's responsibility to call Close on the XzReader when done. -func NewXzReader(r io.Reader) (*XzReader, error) { - rpipe, wpipe := io.Pipe() - ex, err := exec.LookPath("xz") - if err != nil { - log.Fatalf("couldn't find xz executable: %v", err) - } - cmd := exec.Command(ex, "--decompress", "--stdout") - - closech := make(chan error) - - cmd.Stdin = r - cmd.Stdout = wpipe - - go func() { - err := cmd.Run() - wpipe.CloseWithError(err) - closech <- err - }() - - return &XzReader{rpipe, cmd, closech}, nil -} - -func (r *XzReader) Close() error { - r.ReadCloser.Close() - r.cmd.Process.Kill() - return <-r.closech -} - -// ManifestFromImage extracts a new schema.ImageManifest from the given ACI image. -func ManifestFromImage(rs io.ReadSeeker) (*schema.ImageManifest, error) { - var im schema.ImageManifest - - tr, err := NewCompressedTarReader(rs) - if err != nil { - return nil, err - } - defer tr.Close() - - for { - hdr, err := tr.Next() - switch err { - case io.EOF: - return nil, errors.New("missing manifest") - case nil: - if filepath.Clean(hdr.Name) == ManifestFile { - data, err := ioutil.ReadAll(tr) - if err != nil { - return nil, err - } - if err := im.UnmarshalJSON(data); err != nil { - return nil, err - } - return &im, nil - } - default: - return nil, fmt.Errorf("error extracting tarball: %v", err) - } - } -} - -// TarReadCloser embeds a *tar.Reader and the related io.Closer -// It is the caller's responsibility to call Close on TarReadCloser when -// done. -type TarReadCloser struct { - *tar.Reader - io.Closer -} - -func (r *TarReadCloser) Close() error { - return r.Closer.Close() -} - -// NewCompressedTarReader creates a new TarReadCloser reading from the -// given ACI image. -// It is the caller's responsibility to call Close on the TarReadCloser -// when done. -func NewCompressedTarReader(rs io.ReadSeeker) (*TarReadCloser, error) { - cr, err := NewCompressedReader(rs) - if err != nil { - return nil, err - } - return &TarReadCloser{tar.NewReader(cr), cr}, nil -} - -// NewCompressedReader creates a new io.ReaderCloser from the given ACI image. -// It is the caller's responsibility to call Close on the Reader when done. -func NewCompressedReader(rs io.ReadSeeker) (io.ReadCloser, error) { - - var ( - dr io.ReadCloser - err error - ) - - _, err = rs.Seek(0, 0) - if err != nil { - return nil, err - } - - ftype, err := DetectFileType(rs) - if err != nil { - return nil, err - } - - _, err = rs.Seek(0, 0) - if err != nil { - return nil, err - } - - switch ftype { - case TypeGzip: - dr, err = gzip.NewReader(rs) - if err != nil { - return nil, err - } - case TypeBzip2: - dr = ioutil.NopCloser(bzip2.NewReader(rs)) - case TypeXz: - dr, err = NewXzReader(rs) - if err != nil { - return nil, err - } - case TypeTar: - dr = ioutil.NopCloser(rs) - case TypeUnknown: - return nil, errors.New("error: unknown image filetype") - default: - return nil, errors.New("no type returned from DetectFileType?") - } - return dr, nil -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/aci/layout.go b/Godeps/_workspace/src/github.com/appc/spec/aci/layout.go deleted file mode 100644 index c2cce5635a..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/aci/layout.go +++ /dev/null @@ -1,187 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package aci - -/* - -Image Layout - -The on-disk layout of an app container is straightforward. -It includes a rootfs with all of the files that will exist in the root of the app and a manifest describing the image. -The layout MUST contain an image manifest. - -/manifest -/rootfs/ -/rootfs/usr/bin/mysql - -*/ - -import ( - "archive/tar" - "bytes" - "errors" - "fmt" - "io" - "io/ioutil" - "os" - "path/filepath" - "strings" - - "github.com/appc/spec/schema" - "github.com/appc/spec/schema/types" -) - -const ( - // Path to manifest file inside the layout - ManifestFile = "manifest" - // Path to rootfs directory inside the layout - RootfsDir = "rootfs" -) - -type ErrOldVersion struct { - version types.SemVer -} - -func (e ErrOldVersion) Error() string { - return fmt.Sprintf("ACVersion too old. Found major version %v, expected %v", e.version.Major, schema.AppContainerVersion.Major) -} - -var ( - ErrNoRootFS = errors.New("no rootfs found in layout") - ErrNoManifest = errors.New("no image manifest found in layout") -) - -// ValidateLayout takes a directory and validates that the layout of the directory -// matches that expected by the Application Container Image format. -// If any errors are encountered during the validation, it will abort and -// return the first one. -func ValidateLayout(dir string) error { - fi, err := os.Stat(dir) - if err != nil { - return fmt.Errorf("error accessing layout: %v", err) - } - if !fi.IsDir() { - return fmt.Errorf("given path %q is not a directory", dir) - } - var flist []string - var imOK, rfsOK bool - var im io.Reader - walkLayout := func(fpath string, fi os.FileInfo, err error) error { - rpath, err := filepath.Rel(dir, fpath) - if err != nil { - return err - } - switch rpath { - case ".": - case ManifestFile: - im, err = os.Open(fpath) - if err != nil { - return err - } - imOK = true - case RootfsDir: - if !fi.IsDir() { - return errors.New("rootfs is not a directory") - } - rfsOK = true - default: - flist = append(flist, rpath) - } - return nil - } - if err := filepath.Walk(dir, walkLayout); err != nil { - return err - } - return validate(imOK, im, rfsOK, flist) -} - -// ValidateArchive takes a *tar.Reader and validates that the layout of the -// filesystem the reader encapsulates matches that expected by the -// Application Container Image format. If any errors are encountered during -// the validation, it will abort and return the first one. -func ValidateArchive(tr *tar.Reader) error { - var fseen map[string]bool = make(map[string]bool) - var imOK, rfsOK bool - var im bytes.Buffer -Tar: - for { - hdr, err := tr.Next() - switch { - case err == nil: - case err == io.EOF: - break Tar - default: - return err - } - name := filepath.Clean(hdr.Name) - switch name { - case ".": - case ManifestFile: - _, err := io.Copy(&im, tr) - if err != nil { - return err - } - imOK = true - case RootfsDir: - if !hdr.FileInfo().IsDir() { - return fmt.Errorf("rootfs is not a directory") - } - rfsOK = true - default: - if _, seen := fseen[name]; seen { - return fmt.Errorf("duplicate file entry in archive: %s", name) - } - fseen[name] = true - } - } - var flist []string - for key := range fseen { - flist = append(flist, key) - } - return validate(imOK, &im, rfsOK, flist) -} - -func validate(imOK bool, im io.Reader, rfsOK bool, files []string) error { - defer func() { - if rc, ok := im.(io.Closer); ok { - rc.Close() - } - }() - if !imOK { - return ErrNoManifest - } - if !rfsOK { - return ErrNoRootFS - } - b, err := ioutil.ReadAll(im) - if err != nil { - return fmt.Errorf("error reading image manifest: %v", err) - } - var a schema.ImageManifest - if err := a.UnmarshalJSON(b); err != nil { - return fmt.Errorf("image manifest validation failed: %v", err) - } - if a.ACVersion.LessThanMajor(schema.AppContainerVersion) { - return ErrOldVersion{ - version: a.ACVersion, - } - } - for _, f := range files { - if !strings.HasPrefix(f, "rootfs") { - return fmt.Errorf("unrecognized file path in layout: %q", f) - } - } - return nil -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/aci/writer.go b/Godeps/_workspace/src/github.com/appc/spec/aci/writer.go deleted file mode 100644 index 070b09ba53..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/aci/writer.go +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package aci - -import ( - "archive/tar" - "bytes" - "encoding/json" - "io" - "time" - - "github.com/appc/spec/schema" -) - -// ArchiveWriter writes App Container Images. Users wanting to create an ACI or -// should create an ArchiveWriter and add files to it; the ACI will be written -// to the underlying tar.Writer -type ArchiveWriter interface { - AddFile(hdr *tar.Header, r io.Reader) error - Close() error -} - -type imageArchiveWriter struct { - *tar.Writer - am *schema.ImageManifest -} - -// NewImageWriter creates a new ArchiveWriter which will generate an App -// Container Image based on the given manifest and write it to the given -// tar.Writer -func NewImageWriter(am schema.ImageManifest, w *tar.Writer) ArchiveWriter { - aw := &imageArchiveWriter{ - w, - &am, - } - return aw -} - -func (aw *imageArchiveWriter) AddFile(hdr *tar.Header, r io.Reader) error { - err := aw.Writer.WriteHeader(hdr) - if err != nil { - return err - } - - if r != nil { - _, err := io.Copy(aw.Writer, r) - if err != nil { - return err - } - } - - return nil -} - -func (aw *imageArchiveWriter) addFileNow(path string, contents []byte) error { - buf := bytes.NewBuffer(contents) - now := time.Now() - hdr := tar.Header{ - Name: path, - Mode: 0644, - Uid: 0, - Gid: 0, - Size: int64(buf.Len()), - ModTime: now, - Typeflag: tar.TypeReg, - Uname: "root", - Gname: "root", - ChangeTime: now, - } - return aw.AddFile(&hdr, buf) -} - -func (aw *imageArchiveWriter) addManifest(name string, m json.Marshaler) error { - out, err := m.MarshalJSON() - if err != nil { - return err - } - return aw.addFileNow(name, out) -} - -func (aw *imageArchiveWriter) Close() error { - if err := aw.addManifest(ManifestFile, aw.am); err != nil { - return err - } - return aw.Writer.Close() -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/actool/actool.go b/Godeps/_workspace/src/github.com/appc/spec/actool/actool.go deleted file mode 100644 index 21c5f5fa90..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/actool/actool.go +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "flag" - "fmt" - "os" - "strings" - "text/tabwriter" -) - -const ( - cliName = "actool" - cliDescription = "actool, the application container tool" -) - -var ( - globalFlagset = flag.NewFlagSet(cliName, flag.ExitOnError) - out *tabwriter.Writer - commands []*Command - globalFlags = struct { - Dir string - Debug bool - Help bool - }{} - transportFlags = struct { - Insecure bool - }{} -) - -func init() { - globalFlagset.BoolVar(&globalFlags.Help, "help", false, "Print usage information and exit") - globalFlagset.BoolVar(&globalFlags.Debug, "debug", false, "Print verbose (debug) output") -} - -type Command struct { - Name string // Name of the Command and the string to use to invoke it - Summary string // One-sentence summary of what the Command does - Usage string // Usage options/arguments - Description string // Detailed description of command - Flags flag.FlagSet // Set of flags associated with this command - - Run func(args []string) int // Run a command with the given arguments, return exit status -} - -func init() { - out = new(tabwriter.Writer) - out.Init(os.Stdout, 0, 8, 1, '\t', 0) - commands = []*Command{ - cmdBuild, - cmdCatManifest, - cmdDiscover, - cmdHelp, - cmdPatchManifest, - cmdValidate, - cmdVersion, - } -} - -func main() { - // parse global arguments - globalFlagset.Parse(os.Args[1:]) - args := globalFlagset.Args() - if len(args) < 1 || globalFlags.Help { - args = []string{"help"} - } - - var cmd *Command - - // determine which Command should be run - for _, c := range commands { - if c.Name == args[0] { - cmd = c - if err := c.Flags.Parse(args[1:]); err != nil { - stderr("%v", err) - os.Exit(2) - } - break - } - } - - if cmd == nil { - stderr("%v: unknown subcommand: %q", cliName, args[0]) - stderr("Run '%v help' for usage.", cliName) - os.Exit(2) - } - os.Exit(cmd.Run(cmd.Flags.Args())) -} - -func getAllFlags() (flags []*flag.Flag) { - return getFlags(globalFlagset) -} - -func getFlags(flagset *flag.FlagSet) (flags []*flag.Flag) { - flags = make([]*flag.Flag, 0) - flagset.VisitAll(func(f *flag.Flag) { - flags = append(flags, f) - }) - return -} - -func stderr(format string, a ...interface{}) { - out := fmt.Sprintf(format, a...) - fmt.Fprintln(os.Stderr, strings.TrimSuffix(out, "\n")) -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/actool/build.go b/Godeps/_workspace/src/github.com/appc/spec/actool/build.go deleted file mode 100644 index 1c958eba45..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/actool/build.go +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "archive/tar" - "compress/gzip" - "io" - "io/ioutil" - "os" - "path/filepath" - - "github.com/appc/spec/aci" - "github.com/appc/spec/schema" -) - -var ( - buildNocompress bool - buildOverwrite bool - buildOwnerRoot bool - cmdBuild = &Command{ - Name: "build", - Description: `Build an ACI from a given directory. The directory should -contain an Image Layout. The Image Layout will be validated -before the ACI is created. The produced ACI will be -gzip-compressed by default.`, - Summary: "Build an ACI from an Image Layout (experimental)", - Usage: `[--overwrite] [--no-compression] [--owner-root] DIRECTORY OUTPUT_FILE`, - Run: runBuild, - } -) - -func init() { - cmdBuild.Flags.BoolVar(&buildOverwrite, "overwrite", false, "Overwrite target file if it already exists") - cmdBuild.Flags.BoolVar(&buildOwnerRoot, "owner-root", false, "Force ownership to root:root on all files") - cmdBuild.Flags.BoolVar(&buildNocompress, "no-compression", false, "Do not gzip-compress the produced ACI") -} - -func runBuild(args []string) (exit int) { - if len(args) != 2 { - stderr("build: Must provide directory and output file") - return 1 - } - - root := args[0] - tgt := args[1] - ext := filepath.Ext(tgt) - if ext != schema.ACIExtension { - stderr("build: Extension must be %s (given %s)", schema.ACIExtension, ext) - return 1 - } - - // TODO(jonboulle): stream the validation so we don't have to walk the rootfs twice - if err := aci.ValidateLayout(root); err != nil { - if e, ok := err.(aci.ErrOldVersion); ok { - stderr("build: Warning: %v. Please update your manifest.", e) - } else { - stderr("build: Layout failed validation: %v", err) - return 1 - } - } - - mode := os.O_CREATE | os.O_WRONLY - if buildOverwrite { - mode |= os.O_TRUNC - } else { - mode |= os.O_EXCL - } - fh, err := os.OpenFile(tgt, mode, 0644) - if err != nil { - if os.IsExist(err) { - stderr("build: Target file exists (try --overwrite)") - } else { - stderr("build: Unable to open target %s: %v", tgt, err) - } - return 1 - } - - var gw *gzip.Writer - var r io.WriteCloser = fh - if !buildNocompress { - gw = gzip.NewWriter(fh) - r = gw - } - tr := tar.NewWriter(r) - - defer func() { - tr.Close() - if !buildNocompress { - gw.Close() - } - fh.Close() - if exit != 0 && !buildOverwrite { - os.Remove(tgt) - } - }() - - mpath := filepath.Join(root, aci.ManifestFile) - b, err := ioutil.ReadFile(mpath) - if err != nil { - stderr("build: Unable to read Image Manifest: %v", err) - return 1 - } - var im schema.ImageManifest - if err := im.UnmarshalJSON(b); err != nil { - stderr("build: Unable to load Image Manifest: %v", err) - return 1 - } - iw := aci.NewImageWriter(im, tr) - - var walkerCb aci.TarHeaderWalkFunc - if buildOwnerRoot { - walkerCb = func(hdr *tar.Header) bool { - hdr.Uid, hdr.Gid = 0, 0 - hdr.Uname, hdr.Gname = "root", "root" - return true - } - } - - err = filepath.Walk(root, aci.BuildWalker(root, iw, walkerCb)) - if err != nil { - stderr("build: Error walking rootfs: %v", err) - return 1 - } - - err = iw.Close() - if err != nil { - stderr("build: Unable to close image %s: %v", tgt, err) - return 1 - } - - return -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/actool/discover.go b/Godeps/_workspace/src/github.com/appc/spec/actool/discover.go deleted file mode 100644 index f91f526d7b..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/actool/discover.go +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "encoding/json" - "fmt" - "runtime" - "strings" - - "github.com/appc/spec/discovery" -) - -var ( - outputJson bool - cmdDiscover = &Command{ - Name: "discover", - Description: "Discover the download URLs for an app", - Summary: "Discover the download URLs for one or more app container images", - Usage: "[--json] APP...", - Run: runDiscover, - } -) - -func init() { - cmdDiscover.Flags.BoolVar(&transportFlags.Insecure, "insecure", false, - "Don't check TLS certificates and allow insecure non-TLS downloads over http") - cmdDiscover.Flags.BoolVar(&outputJson, "json", false, - "Output result as JSON") -} - -func runDiscover(args []string) (exit int) { - if len(args) < 1 { - stderr("discover: at least one name required") - } - - for _, name := range args { - app, err := discovery.NewAppFromString(name) - if app.Labels["os"] == "" { - app.Labels["os"] = runtime.GOOS - } - if app.Labels["arch"] == "" { - app.Labels["arch"] = runtime.GOARCH - } - if err != nil { - stderr("%s: %s", name, err) - return 1 - } - insecure := discovery.InsecureNone - if transportFlags.Insecure { - insecure = discovery.InsecureTLS | discovery.InsecureHTTP - } - eps, attempts, err := discovery.DiscoverACIEndpoints(*app, nil, insecure) - if err != nil { - stderr("error fetching endpoints for %s: %s", name, err) - return 1 - } - for _, a := range attempts { - fmt.Printf("discover endpoints walk: prefix: %s error: %v\n", a.Prefix, a.Error) - } - publicKeys, attempts, err := discovery.DiscoverPublicKeys(*app, nil, insecure) - if err != nil { - stderr("error fetching public keys for %s: %s", name, err) - return 1 - } - for _, a := range attempts { - fmt.Printf("discover public keys walk: prefix: %s error: %v\n", a.Prefix, a.Error) - } - - type discoveryData struct { - ACIEndpoints []discovery.ACIEndpoint - PublicKeys []string - } - - if outputJson { - dd := discoveryData{ACIEndpoints: eps, PublicKeys: publicKeys} - jsonBytes, err := json.MarshalIndent(dd, "", " ") - if err != nil { - stderr("error generating JSON: %s", err) - return 1 - } - fmt.Println(string(jsonBytes)) - } else { - for _, aciEndpoint := range eps { - fmt.Printf("ACI: %s, ASC: %s\n", aciEndpoint.ACI, aciEndpoint.ASC) - } - if len(publicKeys) > 0 { - fmt.Println("PublicKeys: " + strings.Join(publicKeys, ",")) - } - } - } - - return -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/actool/doc.go b/Godeps/_workspace/src/github.com/appc/spec/actool/doc.go deleted file mode 100644 index e0e446d203..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/actool/doc.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package main contains a tool for building and validating images and -// manifests that meet the App Container specifications. -package main diff --git a/Godeps/_workspace/src/github.com/appc/spec/actool/help.go b/Godeps/_workspace/src/github.com/appc/spec/actool/help.go deleted file mode 100644 index 25fa5622cc..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/actool/help.go +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "flag" - "fmt" - "strings" - "text/template" - - "github.com/appc/spec/schema" -) - -var ( - cmdHelp = &Command{ - Name: "help", - Summary: "Show a list of commands or help for one command", - Usage: "[COMMAND]", - Description: "Show a list of commands or detailed help for one command", - Run: runHelp, - } - - globalUsageTemplate *template.Template - commandUsageTemplate *template.Template - templFuncs = template.FuncMap{ - "descToLines": func(s string) []string { - // trim leading/trailing whitespace and split into slice of lines - return strings.Split(strings.Trim(s, "\n\t "), "\n") - }, - "printOption": func(name, defvalue, usage string) string { - prefix := "--" - if len(name) == 1 { - prefix = "-" - } - return fmt.Sprintf("\t%s%s=%s\t%s", prefix, name, defvalue, usage) - }, - } -) - -func init() { - globalUsageTemplate = template.Must(template.New("global_usage").Funcs(templFuncs).Parse(` -NAME: -{{printf "\t%s - %s" .Executable .Description}} - -USAGE: -{{printf "\t%s" .Executable}} [global options] [command options] [arguments...] - -VERSION: -{{printf "\t%s" .Version}} - -COMMANDS:{{range .Commands}} -{{printf "\t%s\t%s" .Name .Summary}}{{end}} - -GLOBAL OPTIONS:{{range .Flags}} -{{printOption .Name .DefValue .Usage}}{{end}} - -Run "{{.Executable}} help " for more details on a specific command. -`[1:])) - commandUsageTemplate = template.Must(template.New("command_usage").Funcs(templFuncs).Parse(` -NAME: -{{printf "\t%s - %s" .Cmd.Name .Cmd.Summary}} - -USAGE: -{{printf "\t%s %s %s" .Executable .Cmd.Name .Cmd.Usage}} - -DESCRIPTION: -{{range $line := descToLines .Cmd.Description}}{{printf "\t%s" $line}} -{{end}} -{{if .CmdFlags}}OPTIONS:{{range .CmdFlags}} -{{printOption .Name .DefValue .Usage}}{{end}} - -{{end}}For help on global options run "{{.Executable}} help" -`[1:])) -} - -func runHelp(args []string) (exit int) { - if len(args) < 1 { - printGlobalUsage() - return - } - - var cmd *Command - - for _, c := range commands { - if c.Name == args[0] { - cmd = c - break - } - } - - if cmd == nil { - stderr("Unrecognized command: %s", args[0]) - return 1 - } - - printCommandUsage(cmd) - return -} - -func printGlobalUsage() { - globalUsageTemplate.Execute(out, struct { - Executable string - Commands []*Command - Flags []*flag.Flag - Description string - Version string - }{ - cliName, - commands, - getAllFlags(), - cliDescription, - schema.AppContainerVersion.String(), - }) - out.Flush() -} - -func printCommandUsage(cmd *Command) { - commandUsageTemplate.Execute(out, struct { - Executable string - Cmd *Command - CmdFlags []*flag.Flag - }{ - cliName, - cmd, - getFlags(&cmd.Flags), - }) - out.Flush() -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/actool/manifest.go b/Godeps/_workspace/src/github.com/appc/spec/actool/manifest.go deleted file mode 100644 index 46662167dc..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/actool/manifest.go +++ /dev/null @@ -1,525 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "archive/tar" - "compress/gzip" - "encoding/json" - "fmt" - "io" - "io/ioutil" - "net/url" - "os" - "path" - "path/filepath" - "strconv" - "strings" - - "github.com/appc/spec/aci" - "github.com/appc/spec/schema" - "github.com/appc/spec/schema/types" -) - -var ( - inputFile string - outputFile string - - patchNocompress bool - patchOverwrite bool - patchReplace bool - patchManifestFile string - patchName string - patchExec string - patchUser string - patchGroup string - patchSupplementaryGIDs string - patchCaps string - patchRevokeCaps string - patchMounts string - patchPorts string - patchIsolators string - - catPrettyPrint bool - - cmdPatchManifest = &Command{ - Name: "patch-manifest", - Description: `Copy an ACI and patch its manifest.`, - Summary: "Copy an ACI and patch its manifest (experimental)", - Usage: ` - [--manifest=MANIFEST_FILE] - [--name=example.com/app] - [--exec="/app --debug"] - [--user=uid] [--group=gid] - [--capability=CAP_SYS_ADMIN,CAP_NET_ADMIN] - [--revoke-capability=CAP_SYS_CHROOT,CAP_MKNOD] - [--mounts=work,path=/opt,readOnly=true[:work2,...]] - [--ports=query,protocol=tcp,port=8080[:query2,...]] - [--supplementary-groups=gid1,gid2,...] - [--isolators=resource/cpu,request=50m,limit=100m[:resource/memory,...]] - [--replace] - INPUT_ACI_FILE - [OUTPUT_ACI_FILE]`, - Run: runPatchManifest, - } - cmdCatManifest = &Command{ - Name: "cat-manifest", - Description: `Print the manifest from an ACI.`, - Summary: "Print the manifest from an ACI", - Usage: ` [--pretty-print] ACI_FILE`, - Run: runCatManifest, - } -) - -func init() { - cmdPatchManifest.Flags.BoolVar(&patchOverwrite, "overwrite", false, "Overwrite target file if it already exists") - cmdPatchManifest.Flags.BoolVar(&patchNocompress, "no-compression", false, "Do not gzip-compress the produced ACI") - cmdPatchManifest.Flags.BoolVar(&patchReplace, "replace", false, "Replace the input file") - - cmdPatchManifest.Flags.StringVar(&patchManifestFile, "manifest", "", "Replace image manifest with this file. Incompatible with other replace options.") - cmdPatchManifest.Flags.StringVar(&patchName, "name", "", "Replace name") - cmdPatchManifest.Flags.StringVar(&patchExec, "exec", "", "Replace the command line to launch the executable") - cmdPatchManifest.Flags.StringVar(&patchUser, "user", "", "Replace user") - cmdPatchManifest.Flags.StringVar(&patchGroup, "group", "", "Replace group") - cmdPatchManifest.Flags.StringVar(&patchSupplementaryGIDs, "supplementary-groups", "", "Replace supplementary groups, expects a comma-separated list.") - cmdPatchManifest.Flags.StringVar(&patchCaps, "capability", "", "Set the capability remain set") - cmdPatchManifest.Flags.StringVar(&patchRevokeCaps, "revoke-capability", "", "Set the capability remove set") - cmdPatchManifest.Flags.StringVar(&patchMounts, "mounts", "", "Replace mount points") - cmdPatchManifest.Flags.StringVar(&patchPorts, "ports", "", "Replace ports") - cmdPatchManifest.Flags.StringVar(&patchIsolators, "isolators", "", "Replace isolators") - - cmdCatManifest.Flags.BoolVar(&catPrettyPrint, "pretty-print", false, "Print with better style") -} - -func getIsolatorStr(name, value string) string { - return fmt.Sprintf(` - { - "name": "%s", - "value": { %s } - }`, name, value) -} - -func isolatorStrFromString(is string) (types.ACIdentifier, string, error) { - is = "name=" + is - v, err := url.ParseQuery(strings.Replace(is, ",", "&", -1)) - if err != nil { - return "", "", err - } - - var name string - var values []string - var acn *types.ACIdentifier - - for key, val := range v { - if len(val) > 1 { - return "", "", fmt.Errorf("label %s with multiple values %q", key, val) - } - - switch key { - case "name": - acn, err = types.NewACIdentifier(val[0]) - if err != nil { - return "", "", err - } - name = val[0] - default: - // (TODO)yifan: Not support the default boolean yet. - values = append(values, fmt.Sprintf(`"%s": "%s"`, key, val[0])) - } - } - return *acn, getIsolatorStr(name, strings.Join(values, ", ")), nil -} - -func patchManifest(im *schema.ImageManifest) error { - - if patchName != "" { - name, err := types.NewACIdentifier(patchName) - if err != nil { - return err - } - im.Name = *name - } - - var app *types.App = im.App - if patchExec != "" { - if app == nil { - // if the original manifest was missing an app and - // patchExec is set let's assume the user is trying to - // inject one... - im.App = &types.App{} - app = im.App - } - app.Exec = strings.Split(patchExec, " ") - } - - if patchUser != "" || - patchGroup != "" || - patchSupplementaryGIDs != "" || - patchCaps != "" || - patchRevokeCaps != "" || - patchMounts != "" || - patchPorts != "" || - patchIsolators != "" { - // ...but if we still don't have an app and the user is trying - // to patch one of its other parameters, it's an error - if app == nil { - return fmt.Errorf("no app in the supplied manifest and no exec command provided") - } - } - - if patchUser != "" { - app.User = patchUser - } - - if patchGroup != "" { - app.Group = patchGroup - } - - if patchSupplementaryGIDs != "" { - app.SupplementaryGIDs = []int{} - gids := strings.Split(patchSupplementaryGIDs, ",") - for _, g := range gids { - gid, err := strconv.Atoi(g) - if err != nil { - return fmt.Errorf("invalid supplementary group %q: %v", g, err) - } - app.SupplementaryGIDs = append(app.SupplementaryGIDs, gid) - } - } - - if patchCaps != "" { - isolator := app.Isolators.GetByName(types.LinuxCapabilitiesRetainSetName) - if isolator != nil { - return fmt.Errorf("isolator already exists (os/linux/capabilities-retain-set)") - } - - // Instantiate a Isolator with the content specified by the --capability - // parameter. - caps, err := types.NewLinuxCapabilitiesRetainSet(strings.Split(patchCaps, ",")...) - if err != nil { - return fmt.Errorf("cannot parse capability %q: %v", patchCaps, err) - } - app.Isolators = append(app.Isolators, caps.AsIsolator()) - } - if patchRevokeCaps != "" { - isolator := app.Isolators.GetByName(types.LinuxCapabilitiesRevokeSetName) - if isolator != nil { - return fmt.Errorf("isolator already exists (os/linux/capabilities-remove-set)") - } - - // Instantiate a Isolator with the content specified by the --revoke-capability - // parameter. - caps, err := types.NewLinuxCapabilitiesRevokeSet(strings.Split(patchRevokeCaps, ",")...) - if err != nil { - return fmt.Errorf("cannot parse capability %q: %v", patchRevokeCaps, err) - } - app.Isolators = append(app.Isolators, caps.AsIsolator()) - } - - if patchMounts != "" { - mounts := strings.Split(patchMounts, ":") - for _, m := range mounts { - mountPoint, err := types.MountPointFromString(m) - if err != nil { - return fmt.Errorf("cannot parse mount point %q: %v", m, err) - } - app.MountPoints = append(app.MountPoints, *mountPoint) - } - } - - if patchPorts != "" { - ports := strings.Split(patchPorts, ":") - for _, p := range ports { - port, err := types.PortFromString(p) - if err != nil { - return fmt.Errorf("cannot parse port %q: %v", p, err) - } - app.Ports = append(app.Ports, *port) - } - } - - if patchIsolators != "" { - isolators := strings.Split(patchIsolators, ":") - for _, is := range isolators { - name, isolatorStr, err := isolatorStrFromString(is) - if err != nil { - return fmt.Errorf("cannot parse isolator %q: %v", is, err) - } - - _, ok := types.ResourceIsolatorNames[name] - - if name == types.LinuxNoNewPrivilegesName { - ok = true - kv := strings.Split(is, ",") - if len(kv) != 2 { - return fmt.Errorf("isolator %s: invalid format", name) - } - - isolatorStr = fmt.Sprintf(`{ "name": "%s", "value": %s }`, name, kv[1]) - } - - if !ok { - return fmt.Errorf("isolator %s is not supported for patching", name) - } - - isolator := &types.Isolator{} - if err := isolator.UnmarshalJSON([]byte(isolatorStr)); err != nil { - return fmt.Errorf("cannot unmarshal isolator %v: %v", isolatorStr, err) - } - app.Isolators = append(app.Isolators, *isolator) - } - } - return nil -} - -// extractManifest iterates over the tar reader and locate the manifest. Once -// located, the manifest can be printed, replaced or patched. -func extractManifest(tr *tar.Reader, tw *tar.Writer, printManifest bool, newManifest []byte) error { -Tar: - for { - hdr, err := tr.Next() - switch err { - case io.EOF: - break Tar - case nil: - if filepath.Clean(hdr.Name) == aci.ManifestFile { - var new_bytes []byte - - bytes, err := ioutil.ReadAll(tr) - if err != nil { - return err - } - - if printManifest && !catPrettyPrint { - fmt.Println(string(bytes)) - } - - im := &schema.ImageManifest{} - err = im.UnmarshalJSON(bytes) - if err != nil { - return err - } - - if printManifest && catPrettyPrint { - output, err := json.MarshalIndent(im, "", " ") - if err != nil { - return err - } - fmt.Println(string(output)) - } - - if tw == nil { - return nil - } - - if len(newManifest) == 0 { - err = patchManifest(im) - if err != nil { - return err - } - - new_bytes, err = im.MarshalJSON() - if err != nil { - return err - } - } else { - new_bytes = newManifest - } - - hdr.Size = int64(len(new_bytes)) - err = tw.WriteHeader(hdr) - if err != nil { - return err - } - - _, err = tw.Write(new_bytes) - if err != nil { - return err - } - } else if tw != nil { - err := tw.WriteHeader(hdr) - if err != nil { - return err - } - _, err = io.Copy(tw, tr) - if err != nil { - return err - } - } - default: - return fmt.Errorf("error reading tarball: %v", err) - } - } - - return nil -} - -func runPatchManifest(args []string) (exit int) { - var fh *os.File - var err error - - if patchReplace && patchOverwrite { - stderr("patch-manifest: Cannot use both --replace and --overwrite") - return 1 - } - if !patchReplace && len(args) != 2 { - stderr("patch-manifest: Must provide input and output files (or use --replace)") - return 1 - } - if patchReplace && len(args) != 1 { - stderr("patch-manifest: Must provide one file") - return 1 - } - if patchManifestFile != "" && (patchName != "" || patchExec != "" || patchUser != "" || patchGroup != "" || patchCaps != "" || patchMounts != "") { - stderr("patch-manifest: --manifest is incompatible with other manifest editing options") - return 1 - } - - inputFile = args[0] - - // Prepare output writer - - if patchReplace { - fh, err = ioutil.TempFile(path.Dir(inputFile), ".actool-tmp."+path.Base(inputFile)+"-") - if err != nil { - stderr("patch-manifest: Cannot create temporary file: %v", err) - return 1 - } - } else { - outputFile = args[1] - - ext := filepath.Ext(outputFile) - if ext != schema.ACIExtension { - stderr("patch-manifest: Extension must be %s (given %s)", schema.ACIExtension, ext) - return 1 - } - - mode := os.O_CREATE | os.O_WRONLY - if patchOverwrite { - mode |= os.O_TRUNC - } else { - mode |= os.O_EXCL - } - - fh, err = os.OpenFile(outputFile, mode, 0644) - if err != nil { - if os.IsExist(err) { - stderr("patch-manifest: Output file exists (try --overwrite)") - } else { - stderr("patch-manifest: Unable to open output %s: %v", outputFile, err) - } - return 1 - } - } - - var gw *gzip.Writer - var w io.WriteCloser = fh - if !patchNocompress { - gw = gzip.NewWriter(fh) - w = gw - } - tw := tar.NewWriter(w) - - defer func() { - tw.Close() - if !patchNocompress { - gw.Close() - } - fh.Close() - if exit != 0 && !patchOverwrite { - os.Remove(fh.Name()) - } - }() - - // Prepare input reader - - input, err := os.Open(inputFile) - if err != nil { - stderr("patch-manifest: Cannot open %s: %v", inputFile, err) - return 1 - } - defer input.Close() - - tr, err := aci.NewCompressedTarReader(input) - if err != nil { - stderr("patch-manifest: Cannot extract %s: %v", inputFile, err) - return 1 - } - defer tr.Close() - - var newManifest []byte - - if patchManifestFile != "" { - mr, err := os.Open(patchManifestFile) - if err != nil { - stderr("patch-manifest: Cannot open %s: %v", patchManifestFile, err) - return 1 - } - defer input.Close() - - newManifest, err = ioutil.ReadAll(mr) - if err != nil { - stderr("patch-manifest: Cannot read %s: %v", patchManifestFile, err) - return 1 - } - } - - err = extractManifest(tr.Reader, tw, false, newManifest) - if err != nil { - stderr("patch-manifest: Unable to read %s: %v", inputFile, err) - return 1 - } - - if patchReplace { - err = os.Rename(fh.Name(), inputFile) - if err != nil { - stderr("patch-manifest: Cannot rename %q to %q: %v", fh.Name, inputFile, err) - return 1 - } - } - - return -} - -func runCatManifest(args []string) (exit int) { - if len(args) != 1 { - stderr("cat-manifest: Must provide one file") - return 1 - } - - inputFile = args[0] - - input, err := os.Open(inputFile) - if err != nil { - stderr("cat-manifest: Cannot open %s: %v", inputFile, err) - return 1 - } - defer input.Close() - - tr, err := aci.NewCompressedTarReader(input) - if err != nil { - stderr("cat-manifest: Cannot extract %s: %v", inputFile, err) - return 1 - } - defer tr.Close() - - err = extractManifest(tr.Reader, nil, true, nil) - if err != nil { - stderr("cat-manifest: Unable to read %s: %v", inputFile, err) - return 1 - } - - return -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/actool/validate.go b/Godeps/_workspace/src/github.com/appc/spec/actool/validate.go deleted file mode 100644 index 12a7f19ff9..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/actool/validate.go +++ /dev/null @@ -1,177 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "fmt" - "io/ioutil" - "os" - "strings" - - "github.com/appc/spec/aci" - "github.com/appc/spec/schema" -) - -const ( - typeAppImage = "appimage" - typeImageLayout = "layout" - typeManifest = "manifest" -) - -var ( - valType string - cmdValidate = &Command{ - Name: "validate", - Description: "Validate one or more AppContainer files", - Summary: "Validate that one or more images or manifests meet the AppContainer specification", - Usage: "[--type=TYPE] FILE...", - Run: runValidate, - } - validateTypes = []string{ - typeAppImage, - typeImageLayout, - typeManifest, - } -) - -func init() { - cmdValidate.Flags.StringVar(&valType, "type", "", - fmt.Sprintf(`Type of file to validate. If unset, actool will try to detect the type. One of "%s"`, strings.Join(validateTypes, ","))) -} - -func runValidate(args []string) (exit int) { - if len(args) < 1 { - stderr("must pass one or more files") - return 1 - } - - for _, path := range args { - vt := valType - fi, err := os.Stat(path) - if err != nil { - stderr("unable to access %s: %v", path, err) - return 1 - } - var fh *os.File - if fi.IsDir() { - switch vt { - case typeImageLayout: - case "": - vt = typeImageLayout - case typeManifest, typeAppImage: - stderr("%s is a directory (wrong --type?)", path) - return 1 - default: - // should never happen - panic(fmt.Sprintf("unexpected type: %v", vt)) - } - } else { - fh, err = os.Open(path) - if err != nil { - stderr("%s: unable to open: %v", path, err) - return 1 - } - } - - if vt == "" { - vt, err = detectValType(fh) - if err != nil { - stderr("%s: error detecting file type: %v", path, err) - return 1 - } - } - switch vt { - case typeImageLayout: - err = aci.ValidateLayout(path) - if err != nil { - stderr("%s: invalid image layout: %v", path, err) - exit = 1 - } else if globalFlags.Debug { - stderr("%s: valid image layout", path) - } - case typeAppImage: - tr, err := aci.NewCompressedTarReader(fh) - if err != nil { - stderr("%s: error decompressing file: %v", path, err) - return 1 - } - err = aci.ValidateArchive(tr.Reader) - tr.Close() - fh.Close() - if err != nil { - if e, ok := err.(aci.ErrOldVersion); ok { - stderr("%s: warning: %v", path, e) - } else { - stderr("%s: error validating: %v", path, err) - exit = 1 - } - } else if globalFlags.Debug { - stderr("%s: valid app container image", path) - } - case typeManifest: - b, err := ioutil.ReadAll(fh) - fh.Close() - if err != nil { - stderr("%s: unable to read file %s", path, err) - return 1 - } - k := schema.Kind{} - if err := k.UnmarshalJSON(b); err != nil { - stderr("%s: error unmarshaling manifest: %v", path, err) - return 1 - } - switch k.ACKind { - case "ImageManifest": - m := schema.ImageManifest{} - err = m.UnmarshalJSON(b) - case "PodManifest": - m := schema.PodManifest{} - err = m.UnmarshalJSON(b) - default: - // Should not get here; schema.Kind unmarshal should fail - panic("bad ACKind") - } - if err != nil { - stderr("%s: invalid %s: %v", path, k.ACKind, err) - exit = 1 - } else if globalFlags.Debug { - stderr("%s: valid %s", path, k.ACKind) - } - default: - stderr("%s: unable to detect filetype (try --type)", path) - return 1 - } - } - - return -} - -func detectValType(file *os.File) (string, error) { - typ, err := aci.DetectFileType(file) - if err != nil { - return "", err - } - if _, err := file.Seek(0, 0); err != nil { - return "", err - } - switch typ { - case aci.TypeXz, aci.TypeGzip, aci.TypeBzip2, aci.TypeTar: - return typeAppImage, nil - case aci.TypeText: - return typeManifest, nil - default: - return "", nil - } -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/actool/version.go b/Godeps/_workspace/src/github.com/appc/spec/actool/version.go deleted file mode 100644 index 0191ad7b38..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/actool/version.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "fmt" - - "github.com/appc/spec/schema" -) - -var cmdVersion = &Command{ - Name: "version", - Description: "Print the version and exit", - Summary: "Print the version and exit", - Run: runVersion, -} - -func runVersion(args []string) (exit int) { - fmt.Printf("actool version %s\n", schema.AppContainerVersion.String()) - return -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/discovery/discovery.go b/Godeps/_workspace/src/github.com/appc/spec/discovery/discovery.go deleted file mode 100644 index b2dc659541..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/discovery/discovery.go +++ /dev/null @@ -1,257 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package discovery - -import ( - "errors" - "fmt" - "io" - "net/http" - "regexp" - "strings" - - "golang.org/x/net/html" - "golang.org/x/net/html/atom" -) - -type acMeta struct { - name string - prefix string - uri string -} - -type ACIEndpoint struct { - ACI string - ASC string -} - -// A struct containing both discovered endpoints and keys. Used to avoid -// function duplication (one for endpoints and one for keys, so to avoid two -// doDiscover, two DiscoverWalkFunc) -type discoveryData struct { - ACIEndpoints []ACIEndpoint - PublicKeys []string -} - -type ACIEndpoints []ACIEndpoint - -type PublicKeys []string - -const ( - defaultVersion = "latest" -) - -var ( - templateExpression = regexp.MustCompile(`{.*?}`) - errEnough = errors.New("enough discovery information found") -) - -func appendMeta(meta []acMeta, attrs []html.Attribute) []acMeta { - m := acMeta{} - - for _, a := range attrs { - if a.Namespace != "" { - continue - } - - switch a.Key { - case "name": - m.name = a.Val - - case "content": - parts := strings.SplitN(strings.TrimSpace(a.Val), " ", 2) - if len(parts) < 2 { - break - } - m.prefix = parts[0] - m.uri = strings.TrimSpace(parts[1]) - } - } - - // TODO(eyakubovich): should prefix be optional? - if !strings.HasPrefix(m.name, "ac-") || m.prefix == "" || m.uri == "" { - return meta - } - - return append(meta, m) -} - -func extractACMeta(r io.Reader) []acMeta { - var meta []acMeta - - z := html.NewTokenizer(r) - - for { - switch z.Next() { - case html.ErrorToken: - return meta - - case html.StartTagToken, html.SelfClosingTagToken: - tok := z.Token() - if tok.DataAtom == atom.Meta { - meta = appendMeta(meta, tok.Attr) - } - } - } -} - -func renderTemplate(tpl string, kvs ...string) (string, bool) { - for i := 0; i < len(kvs); i += 2 { - k := kvs[i] - v := kvs[i+1] - tpl = strings.Replace(tpl, k, v, -1) - } - return tpl, !templateExpression.MatchString(tpl) -} - -func createTemplateVars(app App) []string { - tplVars := []string{"{name}", app.Name.String()} - // If a label is called "name", it will be ignored as it appears after - // in the slice - for n, v := range app.Labels { - tplVars = append(tplVars, fmt.Sprintf("{%s}", n), v) - } - return tplVars -} - -func doDiscover(pre string, hostHeaders map[string]http.Header, app App, insecure InsecureOption) (*discoveryData, error) { - app = *app.Copy() - if app.Labels["version"] == "" { - app.Labels["version"] = defaultVersion - } - - _, body, err := httpsOrHTTP(pre, hostHeaders, insecure) - if err != nil { - return nil, err - } - defer body.Close() - - meta := extractACMeta(body) - - tplVars := createTemplateVars(app) - - dd := &discoveryData{} - - for _, m := range meta { - if !strings.HasPrefix(app.Name.String(), m.prefix) { - continue - } - - switch m.name { - case "ac-discovery": - // Ignore not handled variables as {ext} isn't already rendered. - uri, _ := renderTemplate(m.uri, tplVars...) - asc, ok := renderTemplate(uri, "{ext}", "aci.asc") - if !ok { - continue - } - aci, ok := renderTemplate(uri, "{ext}", "aci") - if !ok { - continue - } - dd.ACIEndpoints = append(dd.ACIEndpoints, ACIEndpoint{ACI: aci, ASC: asc}) - - case "ac-discovery-pubkeys": - dd.PublicKeys = append(dd.PublicKeys, m.uri) - } - } - - return dd, nil -} - -// DiscoverWalk will make HTTPS requests to find discovery meta tags and -// optionally will use HTTP if insecure is set. hostHeaders specifies the -// header to apply depending on the host (e.g. authentication). Based on the -// response of the discoverFn it will continue to recurse up the tree. -func DiscoverWalk(app App, hostHeaders map[string]http.Header, insecure InsecureOption, discoverFn DiscoverWalkFunc) (dd *discoveryData, err error) { - parts := strings.Split(string(app.Name), "/") - for i := range parts { - end := len(parts) - i - pre := strings.Join(parts[:end], "/") - - dd, err = doDiscover(pre, hostHeaders, app, insecure) - if derr := discoverFn(pre, dd, err); derr != nil { - return dd, derr - } - } - - return nil, fmt.Errorf("discovery failed") -} - -// DiscoverWalkFunc can stop a DiscoverWalk by returning non-nil error. -type DiscoverWalkFunc func(prefix string, dd *discoveryData, err error) error - -// FailedAttempt represents a failed discovery attempt. This is for debugging -// and user feedback. -type FailedAttempt struct { - Prefix string - Error error -} - -func walker(attempts *[]FailedAttempt, testFn DiscoverWalkFunc) DiscoverWalkFunc { - return func(pre string, dd *discoveryData, err error) error { - if err != nil { - *attempts = append(*attempts, FailedAttempt{pre, err}) - return nil - } - if err := testFn(pre, dd, err); err != nil { - return err - } - return nil - } -} - -// DiscoverACIEndpoints will make HTTPS requests to find the ac-discovery meta -// tags and optionally will use HTTP if insecure is set. hostHeaders -// specifies the header to apply depending on the host (e.g. authentication). -// It will not give up until it has exhausted the path or found an image -// discovery. -func DiscoverACIEndpoints(app App, hostHeaders map[string]http.Header, insecure InsecureOption) (ACIEndpoints, []FailedAttempt, error) { - testFn := func(pre string, dd *discoveryData, err error) error { - if len(dd.ACIEndpoints) != 0 { - return errEnough - } - return nil - } - - attempts := []FailedAttempt{} - dd, err := DiscoverWalk(app, hostHeaders, insecure, walker(&attempts, testFn)) - if err != nil && err != errEnough { - return nil, attempts, err - } - - return dd.ACIEndpoints, attempts, nil -} - -// DiscoverPublicKey will make HTTPS requests to find the ac-public-keys meta -// tags and optionally will use HTTP if insecure is set. hostHeaders -// specifies the header to apply depending on the host (e.g. authentication). -// It will not give up until it has exhausted the path or found an public key. -func DiscoverPublicKeys(app App, hostHeaders map[string]http.Header, insecure InsecureOption) (PublicKeys, []FailedAttempt, error) { - testFn := func(pre string, dd *discoveryData, err error) error { - if len(dd.PublicKeys) != 0 { - return errEnough - } - return nil - } - - attempts := []FailedAttempt{} - dd, err := DiscoverWalk(app, hostHeaders, insecure, walker(&attempts, testFn)) - if err != nil && err != errEnough { - return nil, attempts, err - } - - return dd.PublicKeys, attempts, nil -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/discovery/doc.go b/Godeps/_workspace/src/github.com/appc/spec/discovery/doc.go deleted file mode 100644 index 55bfc3a02a..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/discovery/doc.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package discovery contains an experimental implementation of the Image -// Discovery section of the appc specification. -package discovery diff --git a/Godeps/_workspace/src/github.com/appc/spec/discovery/http.go b/Godeps/_workspace/src/github.com/appc/spec/discovery/http.go deleted file mode 100644 index 430bcc61cf..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/discovery/http.go +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package discovery - -import ( - "crypto/tls" - "fmt" - "io" - "net" - "net/http" - "net/url" - "time" -) - -type InsecureOption int - -const ( - defaultDialTimeout = 5 * time.Second -) - -const ( - InsecureNone InsecureOption = 0 - - InsecureTLS InsecureOption = 1 << iota - InsecureHTTP -) - -var ( - // Client is the default http.Client used for discovery requests. - Client *http.Client - ClientInsecureTLS *http.Client - - // httpDo is the internal object used by discovery to retrieve URLs; it is - // defined here so it can be overridden for testing - httpDo httpDoer - httpDoInsecureTLS httpDoer -) - -// httpDoer is an interface used to wrap http.Client for real requests and -// allow easy mocking in local tests. -type httpDoer interface { - Do(req *http.Request) (resp *http.Response, err error) -} - -func init() { - t := &http.Transport{ - Proxy: http.ProxyFromEnvironment, - Dial: func(n, a string) (net.Conn, error) { - return net.DialTimeout(n, a, defaultDialTimeout) - }, - } - Client = &http.Client{ - Transport: t, - } - httpDo = Client - - // copy for InsecureTLS - tInsecureTLS := *t - tInsecureTLS.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} - ClientInsecureTLS = &http.Client{ - Transport: &tInsecureTLS, - } - httpDoInsecureTLS = ClientInsecureTLS -} - -func httpsOrHTTP(name string, hostHeaders map[string]http.Header, insecure InsecureOption) (urlStr string, body io.ReadCloser, err error) { - fetch := func(scheme string) (urlStr string, res *http.Response, err error) { - u, err := url.Parse(scheme + "://" + name) - if err != nil { - return "", nil, err - } - u.RawQuery = "ac-discovery=1" - urlStr = u.String() - req, err := http.NewRequest("GET", urlStr, nil) - if err != nil { - return "", nil, err - } - if hostHeader, ok := hostHeaders[u.Host]; ok { - req.Header = hostHeader - } - if insecure&InsecureTLS != 0 { - res, err = httpDoInsecureTLS.Do(req) - return - } - res, err = httpDo.Do(req) - return - } - closeBody := func(res *http.Response) { - if res != nil { - res.Body.Close() - } - } - urlStr, res, err := fetch("https") - if err != nil || res.StatusCode != http.StatusOK { - if insecure&InsecureHTTP != 0 { - closeBody(res) - urlStr, res, err = fetch("http") - } - } - - if res != nil && res.StatusCode != http.StatusOK { - err = fmt.Errorf("expected a 200 OK got %d", res.StatusCode) - } - - if err != nil { - closeBody(res) - return "", nil, err - } - return urlStr, res.Body, nil -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/discovery/parse.go b/Godeps/_workspace/src/github.com/appc/spec/discovery/parse.go deleted file mode 100644 index 7b9d574a69..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/discovery/parse.go +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package discovery - -import ( - "fmt" - "net/url" - "strings" - - "github.com/appc/spec/schema/common" - "github.com/appc/spec/schema/types" -) - -type App struct { - Name types.ACIdentifier - Labels map[types.ACIdentifier]string -} - -func NewApp(name string, labels map[types.ACIdentifier]string) (*App, error) { - if labels == nil { - labels = make(map[types.ACIdentifier]string, 0) - } - acn, err := types.NewACIdentifier(name) - if err != nil { - return nil, err - } - return &App{ - Name: *acn, - Labels: labels, - }, nil -} - -// NewAppFromString takes a command line app parameter and returns a map of labels. -// -// Example app parameters: -// example.com/reduce-worker:1.0.0 -// example.com/reduce-worker,channel=alpha,label=value -// example.com/reduce-worker:1.0.0,label=value -// -// As can be seen in above examples - colon, comma and equal sign have -// special meaning. If any of them has to be a part of a label's value -// then consider writing your own string to App parser. -func NewAppFromString(app string) (*App, error) { - var ( - name string - labels map[types.ACIdentifier]string - ) - - preparedApp, err := prepareAppString(app) - if err != nil { - return nil, err - } - v, err := url.ParseQuery(preparedApp) - if err != nil { - return nil, err - } - labels = make(map[types.ACIdentifier]string, 0) - for key, val := range v { - if len(val) > 1 { - return nil, fmt.Errorf("label %s with multiple values %q", key, val) - } - if key == "name" { - name = val[0] - continue - } - labelName, err := types.NewACIdentifier(key) - if err != nil { - return nil, err - } - labels[*labelName] = val[0] - } - a, err := NewApp(name, labels) - if err != nil { - return nil, err - } - return a, nil -} - -func prepareAppString(app string) (string, error) { - if err := checkColon(app); err != nil { - return "", err - } - - app = "name=" + strings.Replace(app, ":", ",version=", 1) - return common.MakeQueryString(app) -} - -func checkColon(app string) error { - firstComma := strings.IndexRune(app, ',') - firstColon := strings.IndexRune(app, ':') - if firstColon > firstComma && firstComma > -1 { - return fmt.Errorf("malformed app string - colon may appear only right after the app name") - } - if strings.Count(app, ":") > 1 { - return fmt.Errorf("malformed app string - colon may appear at most once") - } - return nil -} - -func (a *App) Copy() *App { - ac := &App{ - Name: a.Name, - Labels: make(map[types.ACIdentifier]string, 0), - } - for k, v := range a.Labels { - ac.Labels[k] = v - } - return ac -} - -// String returns the URL-like image name -func (a *App) String() string { - img := a.Name.String() - for n, v := range a.Labels { - img += fmt.Sprintf(",%s=%s", n, v) - } - return img -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/pkg/acirenderer/acirenderer.go b/Godeps/_workspace/src/github.com/appc/spec/pkg/acirenderer/acirenderer.go deleted file mode 100644 index 25a097f056..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/pkg/acirenderer/acirenderer.go +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package acirenderer - -import ( - "archive/tar" - "crypto/sha512" - "fmt" - "hash" - "io" - "io/ioutil" - "path/filepath" - "strings" - - "github.com/appc/spec/schema" - "github.com/appc/spec/schema/types" -) - -// An ACIRegistry provides all functions of an ACIProvider plus functions to -// search for an aci and get its contents -type ACIRegistry interface { - ACIProvider - GetImageManifest(key string) (*schema.ImageManifest, error) - GetACI(name types.ACIdentifier, labels types.Labels) (string, error) -} - -// An ACIProvider provides functions to get an ACI contents, to convert an -// ACI hash to the key under which the ACI is known to the provider and to resolve an -// image ID to the key under which it's known to the provider. -type ACIProvider interface { - // Read the ACI contents stream given the key. Use ResolveKey to - // convert an image ID to the relative provider's key. - ReadStream(key string) (io.ReadCloser, error) - // Converts an image ID to the, if existent, key under which the - // ACI is known to the provider - ResolveKey(key string) (string, error) - // Converts a Hash to the provider's key - HashToKey(h hash.Hash) string -} - -// An Image contains the ImageManifest, the ACIProvider's key and its Level in -// the dependency tree. -type Image struct { - Im *schema.ImageManifest - Key string - Level uint16 -} - -// Images encapsulates an ordered slice of Image structs. It represents a flat -// dependency tree. -// The upper Image should be the first in the slice with a level of 0. -// For example if A is the upper image and has two deps (in order B and C). And C has one dep (D), -// the slice (reporting the app name and excluding im and Hash) should be: -// [{A, Level: 0}, {C, Level:1}, {D, Level: 2}, {B, Level: 1}] -type Images []Image - -// ACIFiles represents which files to extract for every ACI -type ACIFiles struct { - Key string - FileMap map[string]struct{} -} - -// RenderedACI is an (ordered) slice of ACIFiles -type RenderedACI []*ACIFiles - -// GetRenderedACIWithImageID, given an imageID, starts with the matching image -// available in the store, creates the dependencies list and returns the -// RenderedACI list. -func GetRenderedACIWithImageID(imageID types.Hash, ap ACIRegistry) (RenderedACI, error) { - imgs, err := CreateDepListFromImageID(imageID, ap) - if err != nil { - return nil, err - } - return GetRenderedACIFromList(imgs, ap) -} - -// GetRenderedACI, given an image app name and optional labels, starts with the -// best matching image available in the store, creates the dependencies list -// and returns the RenderedACI list. -func GetRenderedACI(name types.ACIdentifier, labels types.Labels, ap ACIRegistry) (RenderedACI, error) { - imgs, err := CreateDepListFromNameLabels(name, labels, ap) - if err != nil { - return nil, err - } - return GetRenderedACIFromList(imgs, ap) -} - -// GetRenderedACIFromList returns the RenderedACI list. All file outside rootfs -// are excluded (at the moment only "manifest"). -func GetRenderedACIFromList(imgs Images, ap ACIProvider) (RenderedACI, error) { - if len(imgs) == 0 { - return nil, fmt.Errorf("image list empty") - } - - allFiles := make(map[string]byte) - renderedACI := RenderedACI{} - - first := true - for i, img := range imgs { - pwlm := getUpperPWLM(imgs, i) - ra, err := getACIFiles(img, ap, allFiles, pwlm) - if err != nil { - return nil, err - } - // Use the manifest from the upper ACI - if first { - ra.FileMap["manifest"] = struct{}{} - first = false - } - renderedACI = append(renderedACI, ra) - } - - return renderedACI, nil -} - -// getUpperPWLM returns the pwl at the lower level for the branch where -// img[pos] lives. -func getUpperPWLM(imgs Images, pos int) map[string]struct{} { - var pwlm map[string]struct{} - curlevel := imgs[pos].Level - // Start from our position and go back ignoring the other leafs. - for i := pos; i >= 0; i-- { - img := imgs[i] - if img.Level < curlevel && len(img.Im.PathWhitelist) > 0 { - pwlm = pwlToMap(img.Im.PathWhitelist) - } - curlevel = img.Level - } - return pwlm -} - -// getACIFiles returns the ACIFiles struct for the given image. All files -// outside rootfs are excluded (at the moment only "manifest"). -func getACIFiles(img Image, ap ACIProvider, allFiles map[string]byte, pwlm map[string]struct{}) (*ACIFiles, error) { - rs, err := ap.ReadStream(img.Key) - if err != nil { - return nil, err - } - defer rs.Close() - - hash := sha512.New() - r := io.TeeReader(rs, hash) - - thispwlm := pwlToMap(img.Im.PathWhitelist) - ra := &ACIFiles{FileMap: make(map[string]struct{})} - if err = Walk(tar.NewReader(r), func(hdr *tar.Header) error { - name := hdr.Name - cleanName := filepath.Clean(name) - - // Add the rootfs directory. - if cleanName == "rootfs" && hdr.Typeflag == tar.TypeDir { - ra.FileMap[cleanName] = struct{}{} - allFiles[cleanName] = hdr.Typeflag - return nil - } - - // Ignore files outside /rootfs/ (at the moment only "manifest"). - if !strings.HasPrefix(cleanName, "rootfs/") { - return nil - } - - // Is the file in our PathWhiteList? - // If the file is a directory continue also if not in PathWhiteList - if hdr.Typeflag != tar.TypeDir { - if len(img.Im.PathWhitelist) > 0 { - if _, ok := thispwlm[cleanName]; !ok { - return nil - } - } - } - // Is the file in the lower level PathWhiteList of this img branch? - if pwlm != nil { - if _, ok := pwlm[cleanName]; !ok { - return nil - } - } - // Is the file already provided by a previous image? - if _, ok := allFiles[cleanName]; ok { - return nil - } - // Check that the parent dirs are also of type dir in the upper - // images - parentDir := filepath.Dir(cleanName) - for parentDir != "." && parentDir != "/" { - if ft, ok := allFiles[parentDir]; ok && ft != tar.TypeDir { - return nil - } - parentDir = filepath.Dir(parentDir) - } - ra.FileMap[cleanName] = struct{}{} - allFiles[cleanName] = hdr.Typeflag - return nil - }); err != nil { - return nil, err - } - - // Tar does not necessarily read the complete file, so ensure we read the entirety into the hash - if _, err := io.Copy(ioutil.Discard, r); err != nil { - return nil, fmt.Errorf("error reading ACI: %v", err) - } - - if g := ap.HashToKey(hash); g != img.Key { - return nil, fmt.Errorf("image hash does not match expected (%s != %s)", g, img.Key) - } - - ra.Key = img.Key - return ra, nil -} - -// pwlToMap converts a pathWhiteList slice to a map for faster search -// It will also prepend "rootfs/" to the provided paths and they will be -// relative to "/" so they can be easily compared with the tar.Header.Name -// If pwl length is 0, a nil map is returned -func pwlToMap(pwl []string) map[string]struct{} { - if len(pwl) == 0 { - return nil - } - m := make(map[string]struct{}, len(pwl)) - for _, name := range pwl { - relpath := filepath.Join("rootfs", name) - m[relpath] = struct{}{} - } - return m -} - -func Walk(tarReader *tar.Reader, walkFunc func(hdr *tar.Header) error) error { - for { - hdr, err := tarReader.Next() - if err == io.EOF { - // end of tar archive - break - } - if err != nil { - return fmt.Errorf("Error reading tar entry: %v", err) - } - if err := walkFunc(hdr); err != nil { - return err - } - } - return nil -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/pkg/acirenderer/resolve.go b/Godeps/_workspace/src/github.com/appc/spec/pkg/acirenderer/resolve.go deleted file mode 100644 index 248bcbf2af..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/pkg/acirenderer/resolve.go +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package acirenderer - -import ( - "container/list" - - "github.com/appc/spec/schema/types" -) - -// CreateDepListFromImageID returns the flat dependency tree of the image with -// the provided imageID -func CreateDepListFromImageID(imageID types.Hash, ap ACIRegistry) (Images, error) { - key, err := ap.ResolveKey(imageID.String()) - if err != nil { - return nil, err - } - return createDepList(key, ap) -} - -// CreateDepListFromNameLabels returns the flat dependency tree of the image -// with the provided app name and optional labels. -func CreateDepListFromNameLabels(name types.ACIdentifier, labels types.Labels, ap ACIRegistry) (Images, error) { - key, err := ap.GetACI(name, labels) - if err != nil { - return nil, err - } - return createDepList(key, ap) -} - -// createDepList returns the flat dependency tree as a list of Image type -func createDepList(key string, ap ACIRegistry) (Images, error) { - imgsl := list.New() - im, err := ap.GetImageManifest(key) - if err != nil { - return nil, err - } - - img := Image{Im: im, Key: key, Level: 0} - imgsl.PushFront(img) - - // Create a flat dependency tree. Use a LinkedList to be able to - // insert elements in the list while working on it. - for el := imgsl.Front(); el != nil; el = el.Next() { - img := el.Value.(Image) - dependencies := img.Im.Dependencies - for _, d := range dependencies { - var depimg Image - var depKey string - if d.ImageID != nil && !d.ImageID.Empty() { - depKey, err = ap.ResolveKey(d.ImageID.String()) - if err != nil { - return nil, err - } - } else { - var err error - depKey, err = ap.GetACI(d.ImageName, d.Labels) - if err != nil { - return nil, err - } - } - im, err := ap.GetImageManifest(depKey) - if err != nil { - return nil, err - } - depimg = Image{Im: im, Key: depKey, Level: img.Level + 1} - imgsl.InsertAfter(depimg, el) - } - } - - imgs := Images{} - for el := imgsl.Front(); el != nil; el = el.Next() { - imgs = append(imgs, el.Value.(Image)) - } - return imgs, nil -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/pkg/device/device_linux.go b/Godeps/_workspace/src/github.com/appc/spec/pkg/device/device_linux.go deleted file mode 100644 index 4f895cd76e..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/pkg/device/device_linux.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2016 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// +build linux - -package device - -// with glibc/sysdeps/unix/sysv/linux/sys/sysmacros.h as reference - -func Major(rdev uint64) uint { - return uint((rdev>>8)&0xfff) | (uint(rdev>>32) & ^uint(0xfff)) -} - -func Minor(rdev uint64) uint { - return uint(rdev&0xff) | uint(uint32(rdev>>12) & ^uint32(0xff)) -} - -func Makedev(maj uint, min uint) uint64 { - return uint64(min&0xff) | (uint64(maj&0xfff) << 8) | - ((uint64(min) & ^uint64(0xff)) << 12) | - ((uint64(maj) & ^uint64(0xfff)) << 32) -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/pkg/device/device_posix.go b/Godeps/_workspace/src/github.com/appc/spec/pkg/device/device_posix.go deleted file mode 100644 index c2e1b31697..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/pkg/device/device_posix.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// +build freebsd netbsd openbsd darwin - -package device - -/* -#define _BSD_SOURCE -#define _DEFAULT_SOURCE -#include - -unsigned int -my_major(dev_t dev) -{ - return major(dev); -} - -unsigned int -my_minor(dev_t dev) -{ - return minor(dev); -} - -dev_t -my_makedev(unsigned int maj, unsigned int min) -{ - return makedev(maj, min); -} -*/ -import "C" - -func Major(rdev uint64) uint { - major := C.my_major(C.dev_t(rdev)) - return uint(major) -} - -func Minor(rdev uint64) uint { - minor := C.my_minor(C.dev_t(rdev)) - return uint(minor) -} - -func Makedev(maj uint, min uint) uint64 { - dev := C.my_makedev(C.uint(maj), C.uint(min)) - return uint64(dev) -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/pkg/tarheader/doc.go b/Godeps/_workspace/src/github.com/appc/spec/pkg/tarheader/doc.go deleted file mode 100644 index 047a0c0fa4..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/pkg/tarheader/doc.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package tarheader contains a simple abstraction to accurately create -// tar.Headers on different operating systems. -package tarheader diff --git a/Godeps/_workspace/src/github.com/appc/spec/pkg/tarheader/pop_darwin.go b/Godeps/_workspace/src/github.com/appc/spec/pkg/tarheader/pop_darwin.go deleted file mode 100644 index 8f68ee77c5..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/pkg/tarheader/pop_darwin.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//+build darwin - -package tarheader - -import ( - "archive/tar" - "os" - "syscall" - "time" -) - -func init() { - populateHeaderStat = append(populateHeaderStat, populateHeaderCtime) -} - -func populateHeaderCtime(h *tar.Header, fi os.FileInfo, _ map[uint64]string) { - st, ok := fi.Sys().(*syscall.Stat_t) - if !ok { - return - } - - sec, nsec := st.Ctimespec.Unix() - ctime := time.Unix(sec, nsec) - h.ChangeTime = ctime -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/pkg/tarheader/pop_linux.go b/Godeps/_workspace/src/github.com/appc/spec/pkg/tarheader/pop_linux.go deleted file mode 100644 index 2055024084..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/pkg/tarheader/pop_linux.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// +build linux - -package tarheader - -import ( - "archive/tar" - "os" - "syscall" - "time" -) - -func init() { - populateHeaderStat = append(populateHeaderStat, populateHeaderCtime) -} - -func populateHeaderCtime(h *tar.Header, fi os.FileInfo, _ map[uint64]string) { - st, ok := fi.Sys().(*syscall.Stat_t) - if !ok { - return - } - - sec, nsec := st.Ctim.Unix() - ctime := time.Unix(sec, nsec) - h.ChangeTime = ctime -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/pkg/tarheader/pop_posix.go b/Godeps/_workspace/src/github.com/appc/spec/pkg/tarheader/pop_posix.go deleted file mode 100644 index 0cc083fee6..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/pkg/tarheader/pop_posix.go +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// +build linux freebsd netbsd openbsd - -package tarheader - -import ( - "archive/tar" - "os" - "syscall" - - "github.com/appc/spec/pkg/device" -) - -func init() { - populateHeaderStat = append(populateHeaderStat, populateHeaderUnix) -} - -func populateHeaderUnix(h *tar.Header, fi os.FileInfo, seen map[uint64]string) { - st, ok := fi.Sys().(*syscall.Stat_t) - if !ok { - return - } - h.Uid = int(st.Uid) - h.Gid = int(st.Gid) - if st.Mode&syscall.S_IFMT == syscall.S_IFBLK || st.Mode&syscall.S_IFMT == syscall.S_IFCHR { - h.Devminor = int64(device.Minor(uint64(st.Rdev))) - h.Devmajor = int64(device.Major(uint64(st.Rdev))) - } - // If we have already seen this inode, generate a hardlink - p, ok := seen[uint64(st.Ino)] - if ok { - h.Linkname = p - h.Typeflag = tar.TypeLink - } else { - seen[uint64(st.Ino)] = h.Name - } -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/pkg/tarheader/tarheader.go b/Godeps/_workspace/src/github.com/appc/spec/pkg/tarheader/tarheader.go deleted file mode 100644 index dc16c33d33..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/pkg/tarheader/tarheader.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package tarheader - -import ( - "archive/tar" - "os" -) - -var populateHeaderStat []func(h *tar.Header, fi os.FileInfo, seen map[uint64]string) - -func Populate(h *tar.Header, fi os.FileInfo, seen map[uint64]string) { - for _, pop := range populateHeaderStat { - pop(h, fi, seen) - } -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/common/common.go b/Godeps/_workspace/src/github.com/appc/spec/schema/common/common.go deleted file mode 100644 index ffc0f6f9b4..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/common/common.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package common - -import ( - "fmt" - "net/url" - "strings" -) - -// MakeQueryString takes a comma-separated LABEL=VALUE string and returns an -// "&"-separated string with URL escaped values. -// -// Examples: -// version=1.0.0,label=v1+v2 -> version=1.0.0&label=v1%2Bv2 -// name=db,source=/tmp$1 -> name=db&source=%2Ftmp%241 -func MakeQueryString(app string) (string, error) { - parts := strings.Split(app, ",") - escapedParts := make([]string, len(parts)) - for i, s := range parts { - p := strings.SplitN(s, "=", 2) - if len(p) != 2 { - return "", fmt.Errorf("malformed string %q - has a label without a value: %s", app, p[0]) - } - escapedParts[i] = fmt.Sprintf("%s=%s", p[0], url.QueryEscape(p[1])) - } - return strings.Join(escapedParts, "&"), nil -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/doc.go b/Godeps/_workspace/src/github.com/appc/spec/schema/doc.go deleted file mode 100644 index ba381543f8..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/doc.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package schema provides definitions for the JSON schema of the different -// manifests in the App Container Specification. The manifests are canonically -// represented in their respective structs: -// - `ImageManifest` -// - `PodManifest` -// -// Validation is performed through serialization: if a blob of JSON data will -// unmarshal to one of the *Manifests, it is considered a valid implementation -// of the standard. Similarly, if a constructed *Manifest struct marshals -// successfully to JSON, it must be valid. -package schema diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/image.go b/Godeps/_workspace/src/github.com/appc/spec/schema/image.go deleted file mode 100644 index fac4c794c3..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/image.go +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package schema - -import ( - "bytes" - "encoding/json" - "errors" - "fmt" - - "github.com/appc/spec/schema/types" - - "go4.org/errorutil" -) - -const ( - ACIExtension = ".aci" - ImageManifestKind = types.ACKind("ImageManifest") -) - -type ImageManifest struct { - ACKind types.ACKind `json:"acKind"` - ACVersion types.SemVer `json:"acVersion"` - Name types.ACIdentifier `json:"name"` - Labels types.Labels `json:"labels,omitempty"` - App *types.App `json:"app,omitempty"` - Annotations types.Annotations `json:"annotations,omitempty"` - Dependencies types.Dependencies `json:"dependencies,omitempty"` - PathWhitelist []string `json:"pathWhitelist,omitempty"` -} - -// imageManifest is a model to facilitate extra validation during the -// unmarshalling of the ImageManifest -type imageManifest ImageManifest - -func BlankImageManifest() *ImageManifest { - return &ImageManifest{ACKind: ImageManifestKind, ACVersion: AppContainerVersion} -} - -func (im *ImageManifest) UnmarshalJSON(data []byte) error { - a := imageManifest(*im) - err := json.Unmarshal(data, &a) - if err != nil { - if serr, ok := err.(*json.SyntaxError); ok { - line, col, highlight := errorutil.HighlightBytePosition(bytes.NewReader(data), serr.Offset) - return fmt.Errorf("\nError at line %d, column %d\n%s%v", line, col, highlight, err) - } - return err - } - nim := ImageManifest(a) - if err := nim.assertValid(); err != nil { - return err - } - *im = nim - return nil -} - -func (im ImageManifest) MarshalJSON() ([]byte, error) { - if err := im.assertValid(); err != nil { - return nil, err - } - return json.Marshal(imageManifest(im)) -} - -var imKindError = types.InvalidACKindError(ImageManifestKind) - -// assertValid performs extra assertions on an ImageManifest to ensure that -// fields are set appropriately, etc. It is used exclusively when marshalling -// and unmarshalling an ImageManifest. Most field-specific validation is -// performed through the individual types being marshalled; assertValid() -// should only deal with higher-level validation. -func (im *ImageManifest) assertValid() error { - if im.ACKind != ImageManifestKind { - return imKindError - } - if im.ACVersion.Empty() { - return errors.New(`acVersion must be set`) - } - if im.Name.Empty() { - return errors.New(`name must be set`) - } - return nil -} - -func (im *ImageManifest) GetLabel(name string) (val string, ok bool) { - return im.Labels.Get(name) -} - -func (im *ImageManifest) GetAnnotation(name string) (val string, ok bool) { - return im.Annotations.Get(name) -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/kind.go b/Godeps/_workspace/src/github.com/appc/spec/schema/kind.go deleted file mode 100644 index 5dc4f957ec..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/kind.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package schema - -import ( - "encoding/json" - - "github.com/appc/spec/schema/types" -) - -type Kind struct { - ACVersion types.SemVer `json:"acVersion"` - ACKind types.ACKind `json:"acKind"` -} - -type kind Kind - -func (k *Kind) UnmarshalJSON(data []byte) error { - nk := kind{} - err := json.Unmarshal(data, &nk) - if err != nil { - return err - } - *k = Kind(nk) - return nil -} - -func (k Kind) MarshalJSON() ([]byte, error) { - return json.Marshal(kind(k)) -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/lastditch/doc.go b/Godeps/_workspace/src/github.com/appc/spec/schema/lastditch/doc.go deleted file mode 100644 index 9cc5734607..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/lastditch/doc.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package lastditch provides fallback redefinitions of parts of -// schemas provided by schema package. -// -// Almost no validation of schemas is done (besides checking if data -// really is `JSON`-encoded and kind is either `ImageManifest` or -// `PodManifest`. This is to get as much data as possible from an -// invalid manifest. The main aim of the package is to be used for the -// better error reporting. The another aim might be to force some -// operation (like removing a pod), which would otherwise fail because -// of an invalid manifest. -// -// To avoid validation during deserialization, types provided by this -// package use plain strings. -package lastditch diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/lastditch/image.go b/Godeps/_workspace/src/github.com/appc/spec/schema/lastditch/image.go deleted file mode 100644 index dc5055a056..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/lastditch/image.go +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package lastditch - -import ( - "encoding/json" - - "github.com/appc/spec/schema" - "github.com/appc/spec/schema/types" -) - -type ImageManifest struct { - ACVersion string `json:"acVersion"` - ACKind string `json:"acKind"` - Name string `json:"name"` - Labels Labels `json:"labels,omitempty"` -} - -// a type just to avoid a recursion during unmarshalling -type imageManifest ImageManifest - -func (im *ImageManifest) UnmarshalJSON(data []byte) error { - i := imageManifest(*im) - err := json.Unmarshal(data, &i) - if err != nil { - return err - } - if i.ACKind != string(schema.ImageManifestKind) { - return types.InvalidACKindError(schema.ImageManifestKind) - } - *im = ImageManifest(i) - return nil -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/lastditch/labels.go b/Godeps/_workspace/src/github.com/appc/spec/schema/lastditch/labels.go deleted file mode 100644 index 5cf93a087c..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/lastditch/labels.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package lastditch - -import ( - "encoding/json" -) - -type Labels []Label - -// a type just to avoid a recursion during unmarshalling -type labels Labels - -type Label struct { - Name string `json:"name"` - Value string `json:"value"` -} - -func (l *Labels) UnmarshalJSON(data []byte) error { - var jl labels - if err := json.Unmarshal(data, &jl); err != nil { - return err - } - *l = Labels(jl) - return nil -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/lastditch/pod.go b/Godeps/_workspace/src/github.com/appc/spec/schema/lastditch/pod.go deleted file mode 100644 index 2e9d8456bb..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/lastditch/pod.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package lastditch - -import ( - "encoding/json" - - "github.com/appc/spec/schema" - "github.com/appc/spec/schema/types" -) - -type PodManifest struct { - ACVersion string `json:"acVersion"` - ACKind string `json:"acKind"` - Apps AppList `json:"apps"` -} - -type AppList []RuntimeApp - -type RuntimeApp struct { - Name string `json:"name"` - Image RuntimeImage `json:"image"` -} - -type RuntimeImage struct { - Name string `json:"name"` - ID string `json:"id"` - Labels Labels `json:"labels,omitempty"` -} - -// a type just to avoid a recursion during unmarshalling -type podManifest PodManifest - -func (pm *PodManifest) UnmarshalJSON(data []byte) error { - p := podManifest(*pm) - err := json.Unmarshal(data, &p) - if err != nil { - return err - } - if p.ACKind != string(schema.PodManifestKind) { - return types.InvalidACKindError(schema.PodManifestKind) - } - *pm = PodManifest(p) - return nil -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/pod.go b/Godeps/_workspace/src/github.com/appc/spec/schema/pod.go deleted file mode 100644 index d4792ff3b4..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/pod.go +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package schema - -import ( - "bytes" - "encoding/json" - "errors" - "fmt" - - "github.com/appc/spec/schema/types" - - "go4.org/errorutil" -) - -const PodManifestKind = types.ACKind("PodManifest") - -type PodManifest struct { - ACVersion types.SemVer `json:"acVersion"` - ACKind types.ACKind `json:"acKind"` - Apps AppList `json:"apps"` - Volumes []types.Volume `json:"volumes"` - Isolators []types.Isolator `json:"isolators"` - Annotations types.Annotations `json:"annotations"` - Ports []types.ExposedPort `json:"ports"` -} - -// podManifest is a model to facilitate extra validation during the -// unmarshalling of the PodManifest -type podManifest PodManifest - -func BlankPodManifest() *PodManifest { - return &PodManifest{ACKind: PodManifestKind, ACVersion: AppContainerVersion} -} - -func (pm *PodManifest) UnmarshalJSON(data []byte) error { - p := podManifest(*pm) - err := json.Unmarshal(data, &p) - if err != nil { - if serr, ok := err.(*json.SyntaxError); ok { - line, col, highlight := errorutil.HighlightBytePosition(bytes.NewReader(data), serr.Offset) - return fmt.Errorf("\nError at line %d, column %d\n%s%v", line, col, highlight, err) - } - return err - } - npm := PodManifest(p) - if err := npm.assertValid(); err != nil { - return err - } - *pm = npm - return nil -} - -func (pm PodManifest) MarshalJSON() ([]byte, error) { - if err := pm.assertValid(); err != nil { - return nil, err - } - return json.Marshal(podManifest(pm)) -} - -var pmKindError = types.InvalidACKindError(PodManifestKind) - -// assertValid performs extra assertions on an PodManifest to -// ensure that fields are set appropriately, etc. It is used exclusively when -// marshalling and unmarshalling an PodManifest. Most -// field-specific validation is performed through the individual types being -// marshalled; assertValid() should only deal with higher-level validation. -func (pm *PodManifest) assertValid() error { - if pm.ACKind != PodManifestKind { - return pmKindError - } - return nil -} - -type AppList []RuntimeApp - -type appList AppList - -func (al *AppList) UnmarshalJSON(data []byte) error { - a := appList{} - err := json.Unmarshal(data, &a) - if err != nil { - return err - } - nal := AppList(a) - if err := nal.assertValid(); err != nil { - return err - } - *al = nal - return nil -} - -func (al AppList) MarshalJSON() ([]byte, error) { - if err := al.assertValid(); err != nil { - return nil, err - } - return json.Marshal(appList(al)) -} - -func (al AppList) assertValid() error { - seen := map[types.ACName]bool{} - for _, a := range al { - if _, ok := seen[a.Name]; ok { - return fmt.Errorf(`duplicate apps of name %q`, a.Name) - } - seen[a.Name] = true - } - return nil -} - -// Get retrieves an app by the specified name from the AppList; if there is -// no such app, nil is returned. The returned *RuntimeApp MUST be considered -// read-only. -func (al AppList) Get(name types.ACName) *RuntimeApp { - for _, a := range al { - if name.Equals(a.Name) { - aa := a - return &aa - } - } - return nil -} - -// Mount describes the mapping between a volume and the path it is mounted -// inside of an app's filesystem. -type Mount struct { - Volume types.ACName `json:"volume"` - Path string `json:"path"` -} - -func (r Mount) assertValid() error { - if r.Volume.Empty() { - return errors.New("volume must be set") - } - if r.Path == "" { - return errors.New("path must be set") - } - return nil -} - -// RuntimeApp describes an application referenced in a PodManifest -type RuntimeApp struct { - Name types.ACName `json:"name"` - Image RuntimeImage `json:"image"` - App *types.App `json:"app,omitempty"` - ReadOnlyRootFS bool `json:"readOnlyRootFS,omitempty"` - Mounts []Mount `json:"mounts,omitempty"` - Annotations types.Annotations `json:"annotations,omitempty"` -} - -// RuntimeImage describes an image referenced in a RuntimeApp -type RuntimeImage struct { - Name *types.ACIdentifier `json:"name,omitempty"` - ID types.Hash `json:"id"` - Labels types.Labels `json:"labels,omitempty"` -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/acidentifier.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/acidentifier.go deleted file mode 100644 index 904eda5cbc..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/acidentifier.go +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "encoding/json" - "errors" - "regexp" - "strings" -) - -var ( - // ValidACIdentifier is a regular expression that defines a valid ACIdentifier - ValidACIdentifier = regexp.MustCompile("^[a-z0-9]+([-._~/][a-z0-9]+)*$") - - invalidACIdentifierChars = regexp.MustCompile("[^a-z0-9-._~/]") - invalidACIdentifierEdges = regexp.MustCompile("(^[-._~/]+)|([-._~/]+$)") - - ErrEmptyACIdentifier = ACIdentifierError("ACIdentifier cannot be empty") - ErrInvalidEdgeInACIdentifier = ACIdentifierError("ACIdentifier must start and end with only lower case " + - "alphanumeric characters") - ErrInvalidCharInACIdentifier = ACIdentifierError("ACIdentifier must contain only lower case " + - `alphanumeric characters plus "-._~/"`) -) - -// ACIdentifier (an App-Container Identifier) is a format used by keys in image names -// and image labels of the App Container Standard. An ACIdentifier is restricted to numeric -// and lowercase URI unreserved characters defined in URI RFC[1]; all alphabetical characters -// must be lowercase only. Furthermore, the first and last character ("edges") must be -// alphanumeric, and an ACIdentifier cannot be empty. Programmatically, an ACIdentifier must -// conform to the regular expression ValidACIdentifier. -// -// [1] http://tools.ietf.org/html/rfc3986#section-2.3 -type ACIdentifier string - -func (n ACIdentifier) String() string { - return string(n) -} - -// Set sets the ACIdentifier to the given value, if it is valid; if not, -// an error is returned. -func (n *ACIdentifier) Set(s string) error { - nn, err := NewACIdentifier(s) - if err == nil { - *n = *nn - } - return err -} - -// Equals checks whether a given ACIdentifier is equal to this one. -func (n ACIdentifier) Equals(o ACIdentifier) bool { - return strings.ToLower(string(n)) == strings.ToLower(string(o)) -} - -// Empty returns a boolean indicating whether this ACIdentifier is empty. -func (n ACIdentifier) Empty() bool { - return n.String() == "" -} - -// NewACIdentifier generates a new ACIdentifier from a string. If the given string is -// not a valid ACIdentifier, nil and an error are returned. -func NewACIdentifier(s string) (*ACIdentifier, error) { - n := ACIdentifier(s) - if err := n.assertValid(); err != nil { - return nil, err - } - return &n, nil -} - -// MustACIdentifier generates a new ACIdentifier from a string, If the given string is -// not a valid ACIdentifier, it panics. -func MustACIdentifier(s string) *ACIdentifier { - n, err := NewACIdentifier(s) - if err != nil { - panic(err) - } - return n -} - -func (n ACIdentifier) assertValid() error { - s := string(n) - if len(s) == 0 { - return ErrEmptyACIdentifier - } - if invalidACIdentifierChars.MatchString(s) { - return ErrInvalidCharInACIdentifier - } - if invalidACIdentifierEdges.MatchString(s) { - return ErrInvalidEdgeInACIdentifier - } - return nil -} - -// UnmarshalJSON implements the json.Unmarshaler interface -func (n *ACIdentifier) UnmarshalJSON(data []byte) error { - var s string - if err := json.Unmarshal(data, &s); err != nil { - return err - } - nn, err := NewACIdentifier(s) - if err != nil { - return err - } - *n = *nn - return nil -} - -// MarshalJSON implements the json.Marshaler interface -func (n ACIdentifier) MarshalJSON() ([]byte, error) { - if err := n.assertValid(); err != nil { - return nil, err - } - return json.Marshal(n.String()) -} - -// SanitizeACIdentifier replaces every invalid ACIdentifier character in s with an underscore -// making it a legal ACIdentifier string. If the character is an upper case letter it -// replaces it with its lower case. It also removes illegal edge characters -// (hyphens, period, underscore, tilde and slash). -// -// This is a helper function and its algorithm is not part of the spec. It -// should not be called without the user explicitly asking for a suggestion. -func SanitizeACIdentifier(s string) (string, error) { - s = strings.ToLower(s) - s = invalidACIdentifierChars.ReplaceAllString(s, "_") - s = invalidACIdentifierEdges.ReplaceAllString(s, "") - - if s == "" { - return "", errors.New("must contain at least one valid character") - } - - return s, nil -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/ackind.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/ackind.go deleted file mode 100644 index 1793ca8de8..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/ackind.go +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "encoding/json" - "fmt" -) - -var ( - ErrNoACKind = ACKindError("ACKind must be set") -) - -// ACKind wraps a string to define a field which must be set with one of -// several ACKind values. If it is unset, or has an invalid value, the field -// will refuse to marshal/unmarshal. -type ACKind string - -func (a ACKind) String() string { - return string(a) -} - -func (a ACKind) assertValid() error { - s := a.String() - switch s { - case "ImageManifest", "PodManifest": - return nil - case "": - return ErrNoACKind - default: - msg := fmt.Sprintf("bad ACKind: %s", s) - return ACKindError(msg) - } -} - -func (a ACKind) MarshalJSON() ([]byte, error) { - if err := a.assertValid(); err != nil { - return nil, err - } - return json.Marshal(a.String()) -} - -func (a *ACKind) UnmarshalJSON(data []byte) error { - var s string - err := json.Unmarshal(data, &s) - if err != nil { - return err - } - na := ACKind(s) - if err := na.assertValid(); err != nil { - return err - } - *a = na - return nil -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/acname.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/acname.go deleted file mode 100644 index 5ececffb7f..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/acname.go +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "encoding/json" - "errors" - "regexp" - "strings" -) - -var ( - // ValidACName is a regular expression that defines a valid ACName - ValidACName = regexp.MustCompile("^[a-z0-9]+([-][a-z0-9]+)*$") - - invalidACNameChars = regexp.MustCompile("[^a-z0-9-]") - invalidACNameEdges = regexp.MustCompile("(^[-]+)|([-]+$)") - - ErrEmptyACName = ACNameError("ACName cannot be empty") - ErrInvalidEdgeInACName = ACNameError("ACName must start and end with only lower case " + - "alphanumeric characters") - ErrInvalidCharInACName = ACNameError("ACName must contain only lower case " + - `alphanumeric characters plus "-"`) -) - -// ACName (an App-Container Name) is a format used by keys in different formats -// of the App Container Standard. An ACName is restricted to numeric and lowercase -// characters accepted by the DNS RFC[1] plus "-"; all alphabetical characters must -// be lowercase only. Furthermore, the first and last character ("edges") must be -// alphanumeric, and an ACName cannot be empty. Programmatically, an ACName must -// conform to the regular expression ValidACName. -// -// [1] http://tools.ietf.org/html/rfc1123#page-13 -type ACName string - -func (n ACName) String() string { - return string(n) -} - -// Set sets the ACName to the given value, if it is valid; if not, -// an error is returned. -func (n *ACName) Set(s string) error { - nn, err := NewACName(s) - if err == nil { - *n = *nn - } - return err -} - -// Equals checks whether a given ACName is equal to this one. -func (n ACName) Equals(o ACName) bool { - return strings.ToLower(string(n)) == strings.ToLower(string(o)) -} - -// Empty returns a boolean indicating whether this ACName is empty. -func (n ACName) Empty() bool { - return n.String() == "" -} - -// NewACName generates a new ACName from a string. If the given string is -// not a valid ACName, nil and an error are returned. -func NewACName(s string) (*ACName, error) { - n := ACName(s) - if err := n.assertValid(); err != nil { - return nil, err - } - return &n, nil -} - -// MustACName generates a new ACName from a string, If the given string is -// not a valid ACName, it panics. -func MustACName(s string) *ACName { - n, err := NewACName(s) - if err != nil { - panic(err) - } - return n -} - -func (n ACName) assertValid() error { - s := string(n) - if len(s) == 0 { - return ErrEmptyACName - } - if invalidACNameChars.MatchString(s) { - return ErrInvalidCharInACName - } - if invalidACNameEdges.MatchString(s) { - return ErrInvalidEdgeInACName - } - return nil -} - -// UnmarshalJSON implements the json.Unmarshaler interface -func (n *ACName) UnmarshalJSON(data []byte) error { - var s string - if err := json.Unmarshal(data, &s); err != nil { - return err - } - nn, err := NewACName(s) - if err != nil { - return err - } - *n = *nn - return nil -} - -// MarshalJSON implements the json.Marshaler interface -func (n ACName) MarshalJSON() ([]byte, error) { - if err := n.assertValid(); err != nil { - return nil, err - } - return json.Marshal(n.String()) -} - -// SanitizeACName replaces every invalid ACName character in s with a dash -// making it a legal ACName string. If the character is an upper case letter it -// replaces it with its lower case. It also removes illegal edge characters -// (hyphens). -// -// This is a helper function and its algorithm is not part of the spec. It -// should not be called without the user explicitly asking for a suggestion. -func SanitizeACName(s string) (string, error) { - s = strings.ToLower(s) - s = invalidACNameChars.ReplaceAllString(s, "-") - s = invalidACNameEdges.ReplaceAllString(s, "") - - if s == "" { - return "", errors.New("must contain at least one valid character") - } - - return s, nil -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/annotations.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/annotations.go deleted file mode 100644 index ce7743bf53..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/annotations.go +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "encoding/json" - "fmt" -) - -type Annotations []Annotation - -type annotations Annotations - -type Annotation struct { - Name ACIdentifier `json:"name"` - Value string `json:"value"` -} - -func (a Annotations) assertValid() error { - seen := map[ACIdentifier]string{} - for _, anno := range a { - _, ok := seen[anno.Name] - if ok { - return fmt.Errorf(`duplicate annotations of name %q`, anno.Name) - } - seen[anno.Name] = anno.Value - } - if c, ok := seen["created"]; ok { - if _, err := NewDate(c); err != nil { - return err - } - } - if h, ok := seen["homepage"]; ok { - if _, err := NewURL(h); err != nil { - return err - } - } - if d, ok := seen["documentation"]; ok { - if _, err := NewURL(d); err != nil { - return err - } - } - - return nil -} - -func (a Annotations) MarshalJSON() ([]byte, error) { - if err := a.assertValid(); err != nil { - return nil, err - } - return json.Marshal(annotations(a)) -} - -func (a *Annotations) UnmarshalJSON(data []byte) error { - var ja annotations - if err := json.Unmarshal(data, &ja); err != nil { - return err - } - na := Annotations(ja) - if err := na.assertValid(); err != nil { - return err - } - *a = na - return nil -} - -// Retrieve the value of an annotation by the given name from Annotations, if -// it exists. -func (a Annotations) Get(name string) (val string, ok bool) { - for _, anno := range a { - if anno.Name.String() == name { - return anno.Value, true - } - } - return "", false -} - -// Set sets the value of an annotation by the given name, overwriting if one already exists. -func (a *Annotations) Set(name ACIdentifier, value string) { - for i, anno := range *a { - if anno.Name.Equals(name) { - (*a)[i] = Annotation{ - Name: name, - Value: value, - } - return - } - } - anno := Annotation{ - Name: name, - Value: value, - } - *a = append(*a, anno) -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/app.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/app.go deleted file mode 100644 index df13bf1c3a..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/app.go +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "encoding/json" - "errors" - "fmt" - "path" -) - -type App struct { - Exec Exec `json:"exec"` - EventHandlers []EventHandler `json:"eventHandlers,omitempty"` - User string `json:"user"` - Group string `json:"group"` - SupplementaryGIDs []int `json:"supplementaryGIDs,omitempty"` - WorkingDirectory string `json:"workingDirectory,omitempty"` - Environment Environment `json:"environment,omitempty"` - MountPoints []MountPoint `json:"mountPoints,omitempty"` - Ports []Port `json:"ports,omitempty"` - Isolators Isolators `json:"isolators,omitempty"` -} - -// app is a model to facilitate extra validation during the -// unmarshalling of the App -type app App - -func (a *App) UnmarshalJSON(data []byte) error { - ja := app(*a) - err := json.Unmarshal(data, &ja) - if err != nil { - return err - } - na := App(ja) - if err := na.assertValid(); err != nil { - return err - } - if na.Environment == nil { - na.Environment = make(Environment, 0) - } - *a = na - return nil -} - -func (a App) MarshalJSON() ([]byte, error) { - if err := a.assertValid(); err != nil { - return nil, err - } - return json.Marshal(app(a)) -} - -func (a *App) assertValid() error { - if err := a.Exec.assertValid(); err != nil { - return err - } - if a.User == "" { - return errors.New(`user is required`) - } - if a.Group == "" { - return errors.New(`group is required`) - } - if !path.IsAbs(a.WorkingDirectory) && a.WorkingDirectory != "" { - return errors.New("workingDirectory must be an absolute path") - } - eh := make(map[string]bool) - for _, e := range a.EventHandlers { - name := e.Name - if eh[name] { - return fmt.Errorf("Only one eventHandler of name %q allowed", name) - } - eh[name] = true - } - if err := a.Environment.assertValid(); err != nil { - return err - } - return nil -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/date.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/date.go deleted file mode 100644 index 4458bf45d9..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/date.go +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "encoding/json" - "fmt" - "time" -) - -// Date wraps time.Time to marshal/unmarshal to/from JSON strings in strict -// accordance with RFC3339 -// TODO(jonboulle): golang's implementation seems slightly buggy here; -// according to http://tools.ietf.org/html/rfc3339#section-5.6 , applications -// may choose to separate the date and time with a space instead of a T -// character (for example, `date --rfc-3339` on GNU coreutils) - but this is -// considered an error by go's parser. File a bug? -type Date time.Time - -func NewDate(s string) (*Date, error) { - t, err := time.Parse(time.RFC3339, s) - if err != nil { - return nil, fmt.Errorf("bad Date: %v", err) - } - d := Date(t) - return &d, nil -} - -func (d Date) String() string { - return time.Time(d).Format(time.RFC3339) -} - -func (d *Date) UnmarshalJSON(data []byte) error { - var s string - if err := json.Unmarshal(data, &s); err != nil { - return err - } - nd, err := NewDate(s) - if err != nil { - return err - } - *d = *nd - return nil -} - -func (d Date) MarshalJSON() ([]byte, error) { - return json.Marshal(d.String()) -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/dependencies.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/dependencies.go deleted file mode 100644 index fb399e4041..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/dependencies.go +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "encoding/json" - "errors" -) - -type Dependencies []Dependency - -type Dependency struct { - ImageName ACIdentifier `json:"imageName"` - ImageID *Hash `json:"imageID,omitempty"` - Labels Labels `json:"labels,omitempty"` - Size uint `json:"size,omitempty"` -} - -type dependency Dependency - -func (d Dependency) assertValid() error { - if len(d.ImageName) < 1 { - return errors.New(`imageName cannot be empty`) - } - return nil -} - -func (d Dependency) MarshalJSON() ([]byte, error) { - if err := d.assertValid(); err != nil { - return nil, err - } - return json.Marshal(dependency(d)) -} - -func (d *Dependency) UnmarshalJSON(data []byte) error { - var jd dependency - if err := json.Unmarshal(data, &jd); err != nil { - return err - } - nd := Dependency(jd) - if err := nd.assertValid(); err != nil { - return err - } - *d = nd - return nil -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/doc.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/doc.go deleted file mode 100644 index 9c540851b0..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/doc.go +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package types contains structs representing the various types in the app -// container specification. It is used by the [schema manifest types](../) -// to enforce validation. -package types diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/environment.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/environment.go deleted file mode 100644 index f152a6b88d..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/environment.go +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "encoding/json" - "fmt" - "regexp" -) - -var ( - envPattern = regexp.MustCompile("^[A-Za-z_][A-Za-z_0-9]*$") -) - -type Environment []EnvironmentVariable - -type environment Environment - -type EnvironmentVariable struct { - Name string `json:"name"` - Value string `json:"value"` -} - -func (ev EnvironmentVariable) assertValid() error { - if len(ev.Name) == 0 { - return fmt.Errorf(`environment variable name must not be empty`) - } - if !envPattern.MatchString(ev.Name) { - return fmt.Errorf(`environment variable does not have valid identifier %q`, ev.Name) - } - return nil -} - -func (e Environment) assertValid() error { - seen := map[string]bool{} - for _, env := range e { - if err := env.assertValid(); err != nil { - return err - } - _, ok := seen[env.Name] - if ok { - return fmt.Errorf(`duplicate environment variable of name %q`, env.Name) - } - seen[env.Name] = true - } - - return nil -} - -func (e Environment) MarshalJSON() ([]byte, error) { - if err := e.assertValid(); err != nil { - return nil, err - } - return json.Marshal(environment(e)) -} - -func (e *Environment) UnmarshalJSON(data []byte) error { - var je environment - if err := json.Unmarshal(data, &je); err != nil { - return err - } - ne := Environment(je) - if err := ne.assertValid(); err != nil { - return err - } - *e = ne - return nil -} - -// Retrieve the value of an environment variable by the given name from -// Environment, if it exists. -func (e Environment) Get(name string) (value string, ok bool) { - for _, env := range e { - if env.Name == name { - return env.Value, true - } - } - return "", false -} - -// Set sets the value of an environment variable by the given name, -// overwriting if one already exists. -func (e *Environment) Set(name string, value string) { - for i, env := range *e { - if env.Name == name { - (*e)[i] = EnvironmentVariable{ - Name: name, - Value: value, - } - return - } - } - env := EnvironmentVariable{ - Name: name, - Value: value, - } - *e = append(*e, env) -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/errors.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/errors.go deleted file mode 100644 index bb46515944..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/errors.go +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import "fmt" - -// An ACKindError is returned when the wrong ACKind is set in a manifest -type ACKindError string - -func (e ACKindError) Error() string { - return string(e) -} - -func InvalidACKindError(kind ACKind) ACKindError { - return ACKindError(fmt.Sprintf("missing or bad ACKind (must be %#v)", kind)) -} - -// An ACVersionError is returned when a bad ACVersion is set in a manifest -type ACVersionError string - -func (e ACVersionError) Error() string { - return string(e) -} - -// An ACIdentifierError is returned when a bad value is used for an ACIdentifier -type ACIdentifierError string - -func (e ACIdentifierError) Error() string { - return string(e) -} - -// An ACNameError is returned when a bad value is used for an ACName -type ACNameError string - -func (e ACNameError) Error() string { - return string(e) -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/event_handler.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/event_handler.go deleted file mode 100644 index f40c642be4..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/event_handler.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "encoding/json" - "errors" - "fmt" -) - -type EventHandler struct { - Name string `json:"name"` - Exec Exec `json:"exec"` -} - -type eventHandler EventHandler - -func (e EventHandler) assertValid() error { - s := e.Name - switch s { - case "pre-start", "post-stop": - return nil - case "": - return errors.New(`eventHandler "name" cannot be empty`) - default: - return fmt.Errorf(`bad eventHandler "name": %q`, s) - } -} - -func (e EventHandler) MarshalJSON() ([]byte, error) { - if err := e.assertValid(); err != nil { - return nil, err - } - return json.Marshal(eventHandler(e)) -} - -func (e *EventHandler) UnmarshalJSON(data []byte) error { - var je eventHandler - err := json.Unmarshal(data, &je) - if err != nil { - return err - } - ne := EventHandler(je) - if err := ne.assertValid(); err != nil { - return err - } - *e = ne - return nil -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/exec.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/exec.go deleted file mode 100644 index fa8b156cfb..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/exec.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import "encoding/json" - -type Exec []string - -type exec Exec - -func (e Exec) assertValid() error { - return nil -} - -func (e Exec) MarshalJSON() ([]byte, error) { - if err := e.assertValid(); err != nil { - return nil, err - } - return json.Marshal(exec(e)) -} - -func (e *Exec) UnmarshalJSON(data []byte) error { - var je exec - err := json.Unmarshal(data, &je) - if err != nil { - return err - } - ne := Exec(je) - if err := ne.assertValid(); err != nil { - return err - } - *e = ne - return nil -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/hash.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/hash.go deleted file mode 100644 index 1c060a47a0..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/hash.go +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "crypto/sha512" - "encoding/json" - "errors" - "fmt" - "reflect" - "strings" -) - -const ( - maxHashSize = (sha512.Size / 2) + len("sha512-") -) - -// Hash encodes a hash specified in a string of the form: -// "-" -// for example -// "sha512-06c733b1838136838e6d2d3e8fa5aea4c7905e92[...]" -// Valid types are currently: -// * sha512 -type Hash struct { - typ string - Val string -} - -func NewHash(s string) (*Hash, error) { - elems := strings.Split(s, "-") - if len(elems) != 2 { - return nil, errors.New("badly formatted hash string") - } - nh := Hash{ - typ: elems[0], - Val: elems[1], - } - if err := nh.assertValid(); err != nil { - return nil, err - } - return &nh, nil -} - -func (h Hash) String() string { - return fmt.Sprintf("%s-%s", h.typ, h.Val) -} - -func (h *Hash) Set(s string) error { - nh, err := NewHash(s) - if err == nil { - *h = *nh - } - return err -} - -func (h Hash) Empty() bool { - return reflect.DeepEqual(h, Hash{}) -} - -func (h Hash) assertValid() error { - switch h.typ { - case "sha512": - case "": - return fmt.Errorf("unexpected empty hash type") - default: - return fmt.Errorf("unrecognized hash type: %v", h.typ) - } - if h.Val == "" { - return fmt.Errorf("unexpected empty hash value") - } - return nil -} - -func (h *Hash) UnmarshalJSON(data []byte) error { - var s string - if err := json.Unmarshal(data, &s); err != nil { - return err - } - nh, err := NewHash(s) - if err != nil { - return err - } - *h = *nh - return nil -} - -func (h Hash) MarshalJSON() ([]byte, error) { - if err := h.assertValid(); err != nil { - return nil, err - } - return json.Marshal(h.String()) -} - -func NewHashSHA512(b []byte) *Hash { - h := sha512.New() - h.Write(b) - nh, _ := NewHash(fmt.Sprintf("sha512-%x", h.Sum(nil))) - return nh -} - -func ShortHash(hash string) string { - if len(hash) > maxHashSize { - return hash[:maxHashSize] - } - return hash -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/isolator.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/isolator.go deleted file mode 100644 index ecdab0088b..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/isolator.go +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "encoding/json" -) - -var ( - isolatorMap map[ACIdentifier]IsolatorValueConstructor -) - -func init() { - isolatorMap = make(map[ACIdentifier]IsolatorValueConstructor) -} - -type IsolatorValueConstructor func() IsolatorValue - -func AddIsolatorValueConstructor(n ACIdentifier, i IsolatorValueConstructor) { - isolatorMap[n] = i -} - -func AddIsolatorName(n ACIdentifier, ns map[ACIdentifier]struct{}) { - ns[n] = struct{}{} -} - -// Isolators encapsulates a list of individual Isolators for the ImageManifest -// and PodManifest schemas. -type Isolators []Isolator - -// GetByName returns the last isolator in the list by the given name. -func (is *Isolators) GetByName(name ACIdentifier) *Isolator { - var i Isolator - for j := len(*is) - 1; j >= 0; j-- { - i = []Isolator(*is)[j] - if i.Name == name { - return &i - } - } - return nil -} - -// Unrecognized returns a set of isolators that are not recognized. -// An isolator is not recognized if it has not had an associated -// constructor registered with AddIsolatorValueConstructor. -func (is *Isolators) Unrecognized() Isolators { - u := Isolators{} - for _, i := range *is { - if i.value == nil { - u = append(u, i) - } - } - return u -} - -// IsolatorValue encapsulates the actual value of an Isolator which may be -// serialized as any arbitrary JSON blob. Specific Isolator types should -// implement this interface to facilitate unmarshalling and validation. -type IsolatorValue interface { - UnmarshalJSON(b []byte) error - AssertValid() error -} - -// Isolator is a model for unmarshalling isolator types from their JSON-encoded -// representation. -type Isolator struct { - // Name is the name of the Isolator type as defined in the specification. - Name ACIdentifier `json:"name"` - // ValueRaw captures the raw JSON value of an Isolator that was - // unmarshalled. This field is used for unmarshalling only. It MUST NOT - // be referenced by external users of the Isolator struct. It is - // exported only to satisfy Go's unfortunate requirement that fields - // must be capitalized to be unmarshalled successfully. - ValueRaw *json.RawMessage `json:"value"` - // value captures the "true" value of the isolator. - value IsolatorValue -} - -// isolator is a shadow type used for unmarshalling. -type isolator Isolator - -// Value returns the raw Value of this Isolator. Users should perform a type -// switch/assertion on this value to extract the underlying isolator type. -func (i *Isolator) Value() IsolatorValue { - return i.value -} - -// UnmarshalJSON populates this Isolator from a JSON-encoded representation. To -// unmarshal the Value of the Isolator, it will use the appropriate constructor -// as registered by AddIsolatorValueConstructor. -func (i *Isolator) UnmarshalJSON(b []byte) error { - var ii isolator - err := json.Unmarshal(b, &ii) - if err != nil { - return err - } - - var dst IsolatorValue - con, ok := isolatorMap[ii.Name] - if ok { - dst = con() - err = dst.UnmarshalJSON(*ii.ValueRaw) - if err != nil { - return err - } - err = dst.AssertValid() - if err != nil { - return err - } - } - - i.value = dst - i.ValueRaw = ii.ValueRaw - i.Name = ii.Name - - return nil -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/isolator_linux_specific.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/isolator_linux_specific.go deleted file mode 100644 index 678e0bf1f4..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/isolator_linux_specific.go +++ /dev/null @@ -1,163 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "encoding/json" - "errors" -) - -const ( - LinuxCapabilitiesRetainSetName = "os/linux/capabilities-retain-set" - LinuxCapabilitiesRevokeSetName = "os/linux/capabilities-remove-set" - LinuxNoNewPrivilegesName = "os/linux/no-new-privileges" -) - -var LinuxIsolatorNames = make(map[ACIdentifier]struct{}) - -func init() { - for name, con := range map[ACIdentifier]IsolatorValueConstructor{ - LinuxCapabilitiesRevokeSetName: func() IsolatorValue { return &LinuxCapabilitiesRevokeSet{} }, - LinuxCapabilitiesRetainSetName: func() IsolatorValue { return &LinuxCapabilitiesRetainSet{} }, - LinuxNoNewPrivilegesName: func() IsolatorValue { v := LinuxNoNewPrivileges(false); return &v }, - } { - AddIsolatorName(name, LinuxIsolatorNames) - AddIsolatorValueConstructor(name, con) - } -} - -type LinuxNoNewPrivileges bool - -func (l LinuxNoNewPrivileges) AssertValid() error { - return nil -} - -func (l *LinuxNoNewPrivileges) UnmarshalJSON(b []byte) error { - var v bool - err := json.Unmarshal(b, &v) - if err != nil { - return err - } - - *l = LinuxNoNewPrivileges(v) - - return nil -} - -type LinuxCapabilitiesSet interface { - Set() []LinuxCapability - AssertValid() error -} - -type LinuxCapability string - -type linuxCapabilitiesSetValue struct { - Set []LinuxCapability `json:"set"` -} - -type linuxCapabilitiesSetBase struct { - val linuxCapabilitiesSetValue -} - -func (l linuxCapabilitiesSetBase) AssertValid() error { - if len(l.val.Set) == 0 { - return errors.New("set must be non-empty") - } - return nil -} - -func (l *linuxCapabilitiesSetBase) UnmarshalJSON(b []byte) error { - var v linuxCapabilitiesSetValue - err := json.Unmarshal(b, &v) - if err != nil { - return err - } - - l.val = v - - return err -} - -func (l linuxCapabilitiesSetBase) Set() []LinuxCapability { - return l.val.Set -} - -type LinuxCapabilitiesRetainSet struct { - linuxCapabilitiesSetBase -} - -func NewLinuxCapabilitiesRetainSet(caps ...string) (*LinuxCapabilitiesRetainSet, error) { - l := LinuxCapabilitiesRetainSet{ - linuxCapabilitiesSetBase{ - linuxCapabilitiesSetValue{ - make([]LinuxCapability, len(caps)), - }, - }, - } - for i, c := range caps { - l.linuxCapabilitiesSetBase.val.Set[i] = LinuxCapability(c) - } - if err := l.AssertValid(); err != nil { - return nil, err - } - return &l, nil -} - -func (l LinuxCapabilitiesRetainSet) AsIsolator() Isolator { - b, err := json.Marshal(l.linuxCapabilitiesSetBase.val) - if err != nil { - panic(err) - } - rm := json.RawMessage(b) - return Isolator{ - Name: LinuxCapabilitiesRetainSetName, - ValueRaw: &rm, - value: &l, - } -} - -type LinuxCapabilitiesRevokeSet struct { - linuxCapabilitiesSetBase -} - -func NewLinuxCapabilitiesRevokeSet(caps ...string) (*LinuxCapabilitiesRevokeSet, error) { - l := LinuxCapabilitiesRevokeSet{ - linuxCapabilitiesSetBase{ - linuxCapabilitiesSetValue{ - make([]LinuxCapability, len(caps)), - }, - }, - } - for i, c := range caps { - l.linuxCapabilitiesSetBase.val.Set[i] = LinuxCapability(c) - } - if err := l.AssertValid(); err != nil { - return nil, err - } - return &l, nil -} - -func (l LinuxCapabilitiesRevokeSet) AsIsolator() Isolator { - b, err := json.Marshal(l.linuxCapabilitiesSetBase.val) - if err != nil { - panic(err) - } - rm := json.RawMessage(b) - return Isolator{ - Name: LinuxCapabilitiesRevokeSetName, - ValueRaw: &rm, - value: &l, - } -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/isolator_resources.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/isolator_resources.go deleted file mode 100644 index 2ac5130d1c..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/isolator_resources.go +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "encoding/json" - "errors" - "fmt" - - "k8s.io/kubernetes/pkg/api/resource" -) - -var ( - ErrDefaultTrue = errors.New("default must be false") - ErrDefaultRequired = errors.New("default must be true") - ErrRequestNonEmpty = errors.New("request not supported by this resource, must be empty") - - ResourceIsolatorNames = make(map[ACIdentifier]struct{}) -) - -const ( - ResourceBlockBandwidthName = "resource/block-bandwidth" - ResourceBlockIOPSName = "resource/block-iops" - ResourceCPUName = "resource/cpu" - ResourceMemoryName = "resource/memory" - ResourceNetworkBandwidthName = "resource/network-bandwidth" -) - -func init() { - for name, con := range map[ACIdentifier]IsolatorValueConstructor{ - ResourceBlockBandwidthName: func() IsolatorValue { return &ResourceBlockBandwidth{} }, - ResourceBlockIOPSName: func() IsolatorValue { return &ResourceBlockIOPS{} }, - ResourceCPUName: func() IsolatorValue { return &ResourceCPU{} }, - ResourceMemoryName: func() IsolatorValue { return &ResourceMemory{} }, - ResourceNetworkBandwidthName: func() IsolatorValue { return &ResourceNetworkBandwidth{} }, - } { - AddIsolatorName(name, ResourceIsolatorNames) - AddIsolatorValueConstructor(name, con) - } -} - -type Resource interface { - Limit() *resource.Quantity - Request() *resource.Quantity - Default() bool -} - -type ResourceBase struct { - val resourceValue -} - -type resourceValue struct { - Default bool `json:"default"` - Request *resource.Quantity `json:"request"` - Limit *resource.Quantity `json:"limit"` -} - -func (r ResourceBase) Limit() *resource.Quantity { - return r.val.Limit -} -func (r ResourceBase) Request() *resource.Quantity { - return r.val.Request -} -func (r ResourceBase) Default() bool { - return r.val.Default -} - -func (r *ResourceBase) UnmarshalJSON(b []byte) error { - return json.Unmarshal(b, &r.val) -} - -func (r ResourceBase) AssertValid() error { - return nil -} - -type ResourceBlockBandwidth struct { - ResourceBase -} - -func (r ResourceBlockBandwidth) AssertValid() error { - if r.Default() != true { - return ErrDefaultRequired - } - if r.Request() != nil { - return ErrRequestNonEmpty - } - return nil -} - -type ResourceBlockIOPS struct { - ResourceBase -} - -func (r ResourceBlockIOPS) AssertValid() error { - if r.Default() != true { - return ErrDefaultRequired - } - if r.Request() != nil { - return ErrRequestNonEmpty - } - return nil -} - -type ResourceCPU struct { - ResourceBase -} - -func (r ResourceCPU) String() string { - return fmt.Sprintf("ResourceCPU(request=%s, limit=%s)", r.Request(), r.Limit()) -} - -func (r ResourceCPU) AssertValid() error { - if r.Default() != false { - return ErrDefaultTrue - } - return nil -} - -func (r ResourceCPU) AsIsolator() Isolator { - isol := isolatorMap[ResourceCPUName]() - - b, err := json.Marshal(r.val) - if err != nil { - panic(err) - } - valRaw := json.RawMessage(b) - return Isolator{ - Name: ResourceCPUName, - ValueRaw: &valRaw, - value: isol, - } -} - -func NewResourceCPUIsolator(request, limit string) (*ResourceCPU, error) { - req, err := resource.ParseQuantity(request) - if err != nil { - return nil, fmt.Errorf("error parsing request: %v", err) - } - lim, err := resource.ParseQuantity(limit) - if err != nil { - return nil, fmt.Errorf("error parsing limit: %v", err) - } - res := &ResourceCPU{ - ResourceBase{ - resourceValue{ - Request: req, - Limit: lim, - }, - }, - } - if err := res.AssertValid(); err != nil { - // should never happen - return nil, err - } - return res, nil -} - -type ResourceMemory struct { - ResourceBase -} - -func (r ResourceMemory) String() string { - return fmt.Sprintf("ResourceMemory(request=%s, limit=%s)", r.Request(), r.Limit()) -} - -func (r ResourceMemory) AssertValid() error { - if r.Default() != false { - return ErrDefaultTrue - } - return nil -} - -func (r ResourceMemory) AsIsolator() Isolator { - isol := isolatorMap[ResourceMemoryName]() - - b, err := json.Marshal(r.val) - if err != nil { - panic(err) - } - valRaw := json.RawMessage(b) - return Isolator{ - Name: ResourceMemoryName, - ValueRaw: &valRaw, - value: isol, - } -} - -func NewResourceMemoryIsolator(request, limit string) (*ResourceMemory, error) { - req, err := resource.ParseQuantity(request) - if err != nil { - return nil, fmt.Errorf("error parsing request: %v", err) - } - lim, err := resource.ParseQuantity(limit) - if err != nil { - return nil, fmt.Errorf("error parsing limit: %v", err) - } - res := &ResourceMemory{ - ResourceBase{ - resourceValue{ - Request: req, - Limit: lim, - }, - }, - } - if err := res.AssertValid(); err != nil { - // should never happen - return nil, err - } - return res, nil -} - -type ResourceNetworkBandwidth struct { - ResourceBase -} - -func (r ResourceNetworkBandwidth) AssertValid() error { - if r.Default() != true { - return ErrDefaultRequired - } - if r.Request() != nil { - return ErrRequestNonEmpty - } - return nil -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/labels.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/labels.go deleted file mode 100644 index ebd2bb1a98..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/labels.go +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "encoding/json" - "fmt" - "sort" -) - -var ValidOSArch = map[string][]string{ - "linux": {"amd64", "i386", "aarch64", "aarch64_be", "armv6l", "armv7l", "armv7b"}, - "freebsd": {"amd64", "i386", "arm"}, - "darwin": {"x86_64", "i386"}, -} - -type Labels []Label - -type labels Labels - -type Label struct { - Name ACIdentifier `json:"name"` - Value string `json:"value"` -} - -// IsValidOsArch checks if a OS-architecture combination is valid given a map -// of valid OS-architectures -func IsValidOSArch(labels map[ACIdentifier]string, validOSArch map[string][]string) error { - if os, ok := labels["os"]; ok { - if validArchs, ok := validOSArch[os]; !ok { - // Not a whitelisted OS. TODO: how to warn rather than fail? - validOses := make([]string, 0, len(validOSArch)) - for validOs := range validOSArch { - validOses = append(validOses, validOs) - } - sort.Strings(validOses) - return fmt.Errorf(`bad os %#v (must be one of: %v)`, os, validOses) - } else { - // Whitelisted OS. We check arch here, as arch makes sense only - // when os is defined. - if arch, ok := labels["arch"]; ok { - found := false - for _, validArch := range validArchs { - if arch == validArch { - found = true - break - } - } - if !found { - return fmt.Errorf(`bad arch %#v for %v (must be one of: %v)`, arch, os, validArchs) - } - } - } - } - return nil -} - -func (l Labels) assertValid() error { - seen := map[ACIdentifier]string{} - for _, lbl := range l { - if lbl.Name == "name" { - return fmt.Errorf(`invalid label name: "name"`) - } - _, ok := seen[lbl.Name] - if ok { - return fmt.Errorf(`duplicate labels of name %q`, lbl.Name) - } - seen[lbl.Name] = lbl.Value - } - return IsValidOSArch(seen, ValidOSArch) -} - -func (l Labels) MarshalJSON() ([]byte, error) { - if err := l.assertValid(); err != nil { - return nil, err - } - return json.Marshal(labels(l)) -} - -func (l *Labels) UnmarshalJSON(data []byte) error { - var jl labels - if err := json.Unmarshal(data, &jl); err != nil { - return err - } - nl := Labels(jl) - if err := nl.assertValid(); err != nil { - return err - } - *l = nl - return nil -} - -// Get retrieves the value of the label by the given name from Labels, if it exists -func (l Labels) Get(name string) (val string, ok bool) { - for _, lbl := range l { - if lbl.Name.String() == name { - return lbl.Value, true - } - } - return "", false -} - -// ToMap creates a map[ACIdentifier]string. -func (l Labels) ToMap() map[ACIdentifier]string { - labelsMap := make(map[ACIdentifier]string) - for _, lbl := range l { - labelsMap[lbl.Name] = lbl.Value - } - return labelsMap -} - -// LabelsFromMap creates Labels from a map[ACIdentifier]string -func LabelsFromMap(labelsMap map[ACIdentifier]string) (Labels, error) { - labels := Labels{} - for n, v := range labelsMap { - labels = append(labels, Label{Name: n, Value: v}) - } - if err := labels.assertValid(); err != nil { - return nil, err - } - return labels, nil -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/mountpoint.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/mountpoint.go deleted file mode 100644 index 80eab94563..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/mountpoint.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "errors" - "fmt" - "net/url" - "strconv" - - "github.com/appc/spec/schema/common" -) - -type MountPoint struct { - Name ACName `json:"name"` - Path string `json:"path"` - ReadOnly bool `json:"readOnly,omitempty"` -} - -func (mount MountPoint) assertValid() error { - if mount.Name.Empty() { - return errors.New("name must be set") - } - if len(mount.Path) == 0 { - return errors.New("path must be set") - } - return nil -} - -// MountPointFromString takes a command line mountpoint parameter and returns a mountpoint -// -// It is useful for actool patch-manifest --mounts -// -// Example mountpoint parameters: -// database,path=/tmp,readOnly=true -func MountPointFromString(mp string) (*MountPoint, error) { - var mount MountPoint - - mp = "name=" + mp - mpQuery, err := common.MakeQueryString(mp) - if err != nil { - return nil, err - } - - v, err := url.ParseQuery(mpQuery) - if err != nil { - return nil, err - } - for key, val := range v { - if len(val) > 1 { - return nil, fmt.Errorf("label %s with multiple values %q", key, val) - } - - switch key { - case "name": - acn, err := NewACName(val[0]) - if err != nil { - return nil, err - } - mount.Name = *acn - case "path": - mount.Path = val[0] - case "readOnly": - ro, err := strconv.ParseBool(val[0]) - if err != nil { - return nil, err - } - mount.ReadOnly = ro - default: - return nil, fmt.Errorf("unknown mountpoint parameter %q", key) - } - } - err = mount.assertValid() - if err != nil { - return nil, err - } - - return &mount, nil -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/port.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/port.go deleted file mode 100644 index 78d6de4ce1..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/port.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "encoding/json" - "errors" - "fmt" - "net/url" - "strconv" - - "github.com/appc/spec/schema/common" -) - -type Port struct { - Name ACName `json:"name"` - Protocol string `json:"protocol"` - Port uint `json:"port"` - Count uint `json:"count"` - SocketActivated bool `json:"socketActivated"` -} - -type ExposedPort struct { - Name ACName `json:"name"` - HostPort uint `json:"hostPort"` -} - -type port Port - -func (p *Port) UnmarshalJSON(data []byte) error { - var pp port - if err := json.Unmarshal(data, &pp); err != nil { - return err - } - np := Port(pp) - if err := np.assertValid(); err != nil { - return err - } - if np.Count == 0 { - np.Count = 1 - } - *p = np - return nil -} - -func (p Port) MarshalJSON() ([]byte, error) { - if err := p.assertValid(); err != nil { - return nil, err - } - return json.Marshal(port(p)) -} - -func (p Port) assertValid() error { - // Although there are no guarantees, most (if not all) - // transport protocols use 16 bit ports - if p.Port > 65535 || p.Port < 1 { - return errors.New("port must be in 1-65535 range") - } - if p.Port+p.Count > 65536 { - return errors.New("end of port range must be in 1-65535 range") - } - return nil -} - -// PortFromString takes a command line port parameter and returns a port -// -// It is useful for actool patch-manifest --ports -// -// Example port parameters: -// health-check,protocol=udp,port=8000 -// query,protocol=tcp,port=8080,count=1,socketActivated=true -func PortFromString(pt string) (*Port, error) { - var port Port - - pt = "name=" + pt - ptQuery, err := common.MakeQueryString(pt) - if err != nil { - return nil, err - } - - v, err := url.ParseQuery(ptQuery) - if err != nil { - return nil, err - } - for key, val := range v { - if len(val) > 1 { - return nil, fmt.Errorf("label %s with multiple values %q", key, val) - } - - switch key { - case "name": - acn, err := NewACName(val[0]) - if err != nil { - return nil, err - } - port.Name = *acn - case "protocol": - port.Protocol = val[0] - case "port": - p, err := strconv.ParseUint(val[0], 10, 16) - if err != nil { - return nil, err - } - port.Port = uint(p) - case "count": - cnt, err := strconv.ParseUint(val[0], 10, 16) - if err != nil { - return nil, err - } - port.Count = uint(cnt) - case "socketActivated": - sa, err := strconv.ParseBool(val[0]) - if err != nil { - return nil, err - } - port.SocketActivated = sa - default: - return nil, fmt.Errorf("unknown port parameter %q", key) - } - } - err = port.assertValid() - if err != nil { - return nil, err - } - - return &port, nil -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/semver.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/semver.go deleted file mode 100644 index 0008181a5e..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/semver.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "encoding/json" - - "github.com/coreos/go-semver/semver" -) - -var ( - ErrNoZeroSemVer = ACVersionError("SemVer cannot be zero") - ErrBadSemVer = ACVersionError("SemVer is bad") -) - -// SemVer implements the Unmarshaler interface to define a field that must be -// a semantic version string -// TODO(jonboulle): extend upstream instead of wrapping? -type SemVer semver.Version - -// NewSemVer generates a new SemVer from a string. If the given string does -// not represent a valid SemVer, nil and an error are returned. -func NewSemVer(s string) (*SemVer, error) { - nsv, err := semver.NewVersion(s) - if err != nil { - return nil, ErrBadSemVer - } - v := SemVer(*nsv) - if v.Empty() { - return nil, ErrNoZeroSemVer - } - return &v, nil -} - -func (sv SemVer) LessThanMajor(versionB SemVer) bool { - majorA := semver.Version(sv).Major - majorB := semver.Version(versionB).Major - if majorA < majorB { - return true - } - return false -} - -func (sv SemVer) LessThanExact(versionB SemVer) bool { - vA := semver.Version(sv) - vB := semver.Version(versionB) - return vA.LessThan(vB) -} - -func (sv SemVer) String() string { - s := semver.Version(sv) - return s.String() -} - -func (sv SemVer) Empty() bool { - return semver.Version(sv) == semver.Version{} -} - -// UnmarshalJSON implements the json.Unmarshaler interface -func (sv *SemVer) UnmarshalJSON(data []byte) error { - var s string - if err := json.Unmarshal(data, &s); err != nil { - return err - } - v, err := NewSemVer(s) - if err != nil { - return err - } - *sv = *v - return nil -} - -// MarshalJSON implements the json.Marshaler interface -func (sv SemVer) MarshalJSON() ([]byte, error) { - if sv.Empty() { - return nil, ErrNoZeroSemVer - } - return json.Marshal(sv.String()) -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/url.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/url.go deleted file mode 100644 index d4f8f337da..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/url.go +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "encoding/json" - "fmt" - "net/url" -) - -// URL wraps url.URL to marshal/unmarshal to/from JSON strings and enforce -// that the scheme is HTTP/HTTPS only -type URL url.URL - -func NewURL(s string) (*URL, error) { - uu, err := url.Parse(s) - if err != nil { - return nil, fmt.Errorf("bad URL: %v", err) - } - nu := URL(*uu) - if err := nu.assertValidScheme(); err != nil { - return nil, err - } - return &nu, nil -} - -func (u URL) String() string { - uu := url.URL(u) - return uu.String() -} - -func (u URL) assertValidScheme() error { - switch u.Scheme { - case "http", "https": - return nil - default: - return fmt.Errorf("bad URL scheme, must be http/https") - } -} - -func (u *URL) UnmarshalJSON(data []byte) error { - var s string - if err := json.Unmarshal(data, &s); err != nil { - return err - } - nu, err := NewURL(s) - if err != nil { - return err - } - *u = *nu - return nil -} - -func (u URL) MarshalJSON() ([]byte, error) { - if err := u.assertValidScheme(); err != nil { - return nil, err - } - return json.Marshal(u.String()) -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/uuid.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/uuid.go deleted file mode 100644 index 4925b7606d..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/uuid.go +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "encoding/hex" - "encoding/json" - "errors" - "fmt" - "reflect" - "strings" -) - -var ( - ErrNoEmptyUUID = errors.New("UUID cannot be empty") -) - -// UUID encodes an RFC4122-compliant UUID, marshaled to/from a string -// TODO(jonboulle): vendor a package for this? -// TODO(jonboulle): consider more flexibility in input string formats. -// Right now, we only accept: -// "6733C088-A507-4694-AABF-EDBE4FC5266F" -// "6733C088A5074694AABFEDBE4FC5266F" -type UUID [16]byte - -func (u UUID) String() string { - return fmt.Sprintf("%x-%x-%x-%x-%x", u[0:4], u[4:6], u[6:8], u[8:10], u[10:16]) -} - -func (u *UUID) Set(s string) error { - nu, err := NewUUID(s) - if err == nil { - *u = *nu - } - return err -} - -// NewUUID generates a new UUID from the given string. If the string does not -// represent a valid UUID, nil and an error are returned. -func NewUUID(s string) (*UUID, error) { - s = strings.Replace(s, "-", "", -1) - if len(s) != 32 { - return nil, errors.New("bad UUID length != 32") - } - dec, err := hex.DecodeString(s) - if err != nil { - return nil, err - } - var u UUID - for i, b := range dec { - u[i] = b - } - return &u, nil -} - -func (u UUID) Empty() bool { - return reflect.DeepEqual(u, UUID{}) -} - -func (u *UUID) UnmarshalJSON(data []byte) error { - var s string - if err := json.Unmarshal(data, &s); err != nil { - return err - } - uu, err := NewUUID(s) - if uu.Empty() { - return ErrNoEmptyUUID - } - if err == nil { - *u = *uu - } - return err -} - -func (u UUID) MarshalJSON() ([]byte, error) { - if u.Empty() { - return nil, ErrNoEmptyUUID - } - return json.Marshal(u.String()) -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/types/volume.go b/Godeps/_workspace/src/github.com/appc/spec/schema/types/volume.go deleted file mode 100644 index c5ae59180f..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/types/volume.go +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "encoding/json" - "errors" - "fmt" - "net/url" - "path/filepath" - "strconv" - "strings" - - "github.com/appc/spec/schema/common" -) - -const ( - emptyVolumeDefaultMode = "0755" - emptyVolumeDefaultUID = 0 - emptyVolumeDefaultGID = 0 -) - -// Volume encapsulates a volume which should be mounted into the filesystem -// of all apps in a PodManifest -type Volume struct { - Name ACName `json:"name"` - Kind string `json:"kind"` - - // currently used only by "host" - // TODO(jonboulle): factor out? - Source string `json:"source,omitempty"` - ReadOnly *bool `json:"readOnly,omitempty"` - - // currently used only by "empty" - Mode *string `json:"mode,omitempty"` - UID *int `json:"uid,omitempty"` - GID *int `json:"gid,omitempty"` -} - -type volume Volume - -func (v Volume) assertValid() error { - if v.Name.Empty() { - return errors.New("name must be set") - } - - switch v.Kind { - case "empty": - if v.Source != "" { - return errors.New("source for empty volume must be empty") - } - if v.Mode == nil { - return errors.New("mode for empty volume must be set") - } - if v.UID == nil { - return errors.New("uid for empty volume must be set") - } - if v.GID == nil { - return errors.New("gid for empty volume must be set") - } - return nil - case "host": - if v.Source == "" { - return errors.New("source for host volume cannot be empty") - } - if v.Mode != nil { - return errors.New("mode for host volume cannot be set") - } - if v.UID != nil { - return errors.New("uid for host volume cannot be set") - } - if v.GID != nil { - return errors.New("gid for host volume cannot be set") - } - if !filepath.IsAbs(v.Source) { - return errors.New("source for host volume must be absolute path") - } - return nil - default: - return errors.New(`unrecognized volume kind: should be one of "empty", "host"`) - } -} - -func (v *Volume) UnmarshalJSON(data []byte) error { - var vv volume - if err := json.Unmarshal(data, &vv); err != nil { - return err - } - nv := Volume(vv) - maybeSetDefaults(&nv) - if err := nv.assertValid(); err != nil { - return err - } - *v = nv - return nil -} - -func (v Volume) MarshalJSON() ([]byte, error) { - if err := v.assertValid(); err != nil { - return nil, err - } - return json.Marshal(volume(v)) -} - -func (v Volume) String() string { - s := []string{ - v.Name.String(), - ",kind=", - v.Kind, - } - if v.Source != "" { - s = append(s, ",source=") - s = append(s, v.Source) - } - if v.ReadOnly != nil { - s = append(s, ",readOnly=") - s = append(s, strconv.FormatBool(*v.ReadOnly)) - } - switch v.Kind { - case "empty": - if *v.Mode != emptyVolumeDefaultMode { - s = append(s, ",mode=") - s = append(s, *v.Mode) - } - if *v.UID != emptyVolumeDefaultUID { - s = append(s, ",uid=") - s = append(s, strconv.Itoa(*v.UID)) - } - if *v.GID != emptyVolumeDefaultGID { - s = append(s, ",gid=") - s = append(s, strconv.Itoa(*v.GID)) - } - } - return strings.Join(s, "") -} - -// VolumeFromString takes a command line volume parameter and returns a volume -// -// Example volume parameters: -// database,kind=host,source=/tmp,readOnly=true -func VolumeFromString(vp string) (*Volume, error) { - var vol Volume - - vp = "name=" + vp - vpQuery, err := common.MakeQueryString(vp) - if err != nil { - return nil, err - } - - v, err := url.ParseQuery(vpQuery) - if err != nil { - return nil, err - } - for key, val := range v { - val := val - if len(val) > 1 { - return nil, fmt.Errorf("label %s with multiple values %q", key, val) - } - - switch key { - case "name": - acn, err := NewACName(val[0]) - if err != nil { - return nil, err - } - vol.Name = *acn - case "kind": - vol.Kind = val[0] - case "source": - vol.Source = val[0] - case "readOnly": - ro, err := strconv.ParseBool(val[0]) - if err != nil { - return nil, err - } - vol.ReadOnly = &ro - case "mode": - vol.Mode = &val[0] - case "uid": - u, err := strconv.Atoi(val[0]) - if err != nil { - return nil, err - } - vol.UID = &u - case "gid": - g, err := strconv.Atoi(val[0]) - if err != nil { - return nil, err - } - vol.GID = &g - default: - return nil, fmt.Errorf("unknown volume parameter %q", key) - } - } - - maybeSetDefaults(&vol) - - err = vol.assertValid() - if err != nil { - return nil, err - } - - return &vol, nil -} - -// maybeSetDefaults sets the correct default values for certain fields on a -// Volume if they are not already been set. These fields are not -// pre-populated on all Volumes as the Volume type is polymorphic. -func maybeSetDefaults(vol *Volume) { - if vol.Kind == "empty" { - if vol.Mode == nil { - m := emptyVolumeDefaultMode - vol.Mode = &m - } - if vol.UID == nil { - u := emptyVolumeDefaultUID - vol.UID = &u - } - if vol.GID == nil { - g := emptyVolumeDefaultGID - vol.GID = &g - } - } -} diff --git a/Godeps/_workspace/src/github.com/appc/spec/schema/version.go b/Godeps/_workspace/src/github.com/appc/spec/schema/version.go deleted file mode 100644 index 029ebfac35..0000000000 --- a/Godeps/_workspace/src/github.com/appc/spec/schema/version.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2015 The appc Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package schema - -import ( - "github.com/appc/spec/schema/types" -) - -const ( - // version represents the canonical version of the appc spec and tooling. - // For now, the schema and tooling is coupled with the spec itself, so - // this must be kept in sync with the VERSION file in the root of the repo. - version string = "0.8.4" -) - -var ( - // AppContainerVersion is the SemVer representation of version - AppContainerVersion types.SemVer -) - -func init() { - v, err := types.NewSemVer(version) - if err != nil { - panic(err) - } - AppContainerVersion = *v -} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/LICENSE.txt b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/LICENSE.txt deleted file mode 100644 index d645695673..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/LICENSE.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor 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, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/NOTICE.txt b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/NOTICE.txt deleted file mode 100644 index 5f14d1162e..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/NOTICE.txt +++ /dev/null @@ -1,3 +0,0 @@ -AWS SDK for Go -Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. -Copyright 2014-2015 Stripe, Inc. diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awserr/error.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awserr/error.go deleted file mode 100644 index cbc6bb1c0b..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awserr/error.go +++ /dev/null @@ -1,124 +0,0 @@ -// Package awserr represents API error interface accessors for the SDK. -package awserr - -// An Error wraps lower level errors with code, message and an original error. -// The underlying concrete error type may also satisfy other interfaces which -// can be to used to obtain more specific information about the error. -// -// Calling Error() or String() will always include the full information about -// an error based on its underlying type. -// -// Example: -// -// output, err := s3manage.Upload(svc, input, opts) -// if err != nil { -// if awsErr, ok := err.(awserr.Error); ok { -// // Get error details -// log.Println("Error:", awsErr.Code(), awsErr.Message()) -// -// // Prints out full error message, including original error if there was one. -// log.Println("Error:", awsErr.Error()) -// -// // Get original error -// if origErr := awsErr.OrigErr(); origErr != nil { -// // operate on original error. -// } -// } else { -// fmt.Println(err.Error()) -// } -// } -// -type Error interface { - // Satisfy the generic error interface. - error - - // Returns the short phrase depicting the classification of the error. - Code() string - - // Returns the error details message. - Message() string - - // Returns the original error if one was set. Nil is returned if not set. - OrigErr() error -} - -// BatchError is a batch of errors which also wraps lower level errors with code, message, -// and original errors. Calling Error() will only return the error that is at the end -// of the list. -type BatchError interface { - // Satisfy the generic error interface. - error - - // Returns the short phrase depicting the classification of the error. - Code() string - - // Returns the error details message. - Message() string - - // Returns the original error if one was set. Nil is returned if not set. - OrigErrs() []error -} - -// New returns an Error object described by the code, message, and origErr. -// -// If origErr satisfies the Error interface it will not be wrapped within a new -// Error object and will instead be returned. -func New(code, message string, origErr error) Error { - return newBaseError(code, message, origErr) -} - -// NewBatchError returns an baseError with an expectation of an array of errors -func NewBatchError(code, message string, errs []error) BatchError { - return newBaseErrors(code, message, errs) -} - -// A RequestFailure is an interface to extract request failure information from -// an Error such as the request ID of the failed request returned by a service. -// RequestFailures may not always have a requestID value if the request failed -// prior to reaching the service such as a connection error. -// -// Example: -// -// output, err := s3manage.Upload(svc, input, opts) -// if err != nil { -// if reqerr, ok := err.(RequestFailure); ok { -// log.Println("Request failed", reqerr.Code(), reqerr.Message(), reqerr.RequestID()) -// } else { -// log.Println("Error:", err.Error()) -// } -// } -// -// Combined with awserr.Error: -// -// output, err := s3manage.Upload(svc, input, opts) -// if err != nil { -// if awsErr, ok := err.(awserr.Error); ok { -// // Generic AWS Error with Code, Message, and original error (if any) -// fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr()) -// -// if reqErr, ok := err.(awserr.RequestFailure); ok { -// // A service error occurred -// fmt.Println(reqErr.StatusCode(), reqErr.RequestID()) -// } -// } else { -// fmt.Println(err.Error()) -// } -// } -// -type RequestFailure interface { - Error - - // The status code of the HTTP response. - StatusCode() int - - // The request ID returned by the service for a request failure. This will - // be empty if no request ID is available such as the request failed due - // to a connection error. - RequestID() string -} - -// NewRequestFailure returns a new request error wrapper for the given Error -// provided. -func NewRequestFailure(err Error, statusCode int, reqID string) RequestFailure { - return newRequestError(err, statusCode, reqID) -} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awserr/types.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awserr/types.go deleted file mode 100644 index 605f73c5d6..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awserr/types.go +++ /dev/null @@ -1,197 +0,0 @@ -package awserr - -import "fmt" - -// SprintError returns a string of the formatted error code. -// -// Both extra and origErr are optional. If they are included their lines -// will be added, but if they are not included their lines will be ignored. -func SprintError(code, message, extra string, origErr error) string { - msg := fmt.Sprintf("%s: %s", code, message) - if extra != "" { - msg = fmt.Sprintf("%s\n\t%s", msg, extra) - } - if origErr != nil { - msg = fmt.Sprintf("%s\ncaused by: %s", msg, origErr.Error()) - } - return msg -} - -// A baseError wraps the code and message which defines an error. It also -// can be used to wrap an original error object. -// -// Should be used as the root for errors satisfying the awserr.Error. Also -// for any error which does not fit into a specific error wrapper type. -type baseError struct { - // Classification of error - code string - - // Detailed information about error - message string - - // Optional original error this error is based off of. Allows building - // chained errors. - errs []error -} - -// newBaseError returns an error object for the code, message, and err. -// -// code is a short no whitespace phrase depicting the classification of -// the error that is being created. -// -// message is the free flow string containing detailed information about the error. -// -// origErr is the error object which will be nested under the new error to be returned. -func newBaseError(code, message string, origErr error) *baseError { - b := &baseError{ - code: code, - message: message, - } - - if origErr != nil { - b.errs = append(b.errs, origErr) - } - - return b -} - -// newBaseErrors returns an error object for the code, message, and errors. -// -// code is a short no whitespace phrase depicting the classification of -// the error that is being created. -// -// message is the free flow string containing detailed information about the error. -// -// origErrs is the error objects which will be nested under the new errors to be returned. -func newBaseErrors(code, message string, origErrs []error) *baseError { - b := &baseError{ - code: code, - message: message, - errs: origErrs, - } - - return b -} - -// Error returns the string representation of the error. -// -// See ErrorWithExtra for formatting. -// -// Satisfies the error interface. -func (b baseError) Error() string { - size := len(b.errs) - if size > 0 { - return SprintError(b.code, b.message, "", errorList(b.errs)) - } - - return SprintError(b.code, b.message, "", nil) -} - -// String returns the string representation of the error. -// Alias for Error to satisfy the stringer interface. -func (b baseError) String() string { - return b.Error() -} - -// Code returns the short phrase depicting the classification of the error. -func (b baseError) Code() string { - return b.code -} - -// Message returns the error details message. -func (b baseError) Message() string { - return b.message -} - -// OrigErr returns the original error if one was set. Nil is returned if no error -// was set. This only returns the first element in the list. If the full list is -// needed, use BatchError -func (b baseError) OrigErr() error { - if size := len(b.errs); size > 0 { - return b.errs[0] - } - - return nil -} - -// OrigErrs returns the original errors if one was set. An empty slice is returned if -// no error was set:w -func (b baseError) OrigErrs() []error { - return b.errs -} - -// So that the Error interface type can be included as an anonymous field -// in the requestError struct and not conflict with the error.Error() method. -type awsError Error - -// A requestError wraps a request or service error. -// -// Composed of baseError for code, message, and original error. -type requestError struct { - awsError - statusCode int - requestID string -} - -// newRequestError returns a wrapped error with additional information for request -// status code, and service requestID. -// -// Should be used to wrap all request which involve service requests. Even if -// the request failed without a service response, but had an HTTP status code -// that may be meaningful. -// -// Also wraps original errors via the baseError. -func newRequestError(err Error, statusCode int, requestID string) *requestError { - return &requestError{ - awsError: err, - statusCode: statusCode, - requestID: requestID, - } -} - -// Error returns the string representation of the error. -// Satisfies the error interface. -func (r requestError) Error() string { - extra := fmt.Sprintf("status code: %d, request id: %s", - r.statusCode, r.requestID) - return SprintError(r.Code(), r.Message(), extra, r.OrigErr()) -} - -// String returns the string representation of the error. -// Alias for Error to satisfy the stringer interface. -func (r requestError) String() string { - return r.Error() -} - -// StatusCode returns the wrapped status code for the error -func (r requestError) StatusCode() int { - return r.statusCode -} - -// RequestID returns the wrapped requestID -func (r requestError) RequestID() string { - return r.requestID -} - -// An error list that satisfies the golang interface -type errorList []error - -// Error returns the string representation of the error. -// -// Satisfies the error interface. -func (e errorList) Error() string { - msg := "" - // How do we want to handle the array size being zero - if size := len(e); size > 0 { - for i := 0; i < size; i++ { - msg += fmt.Sprintf("%s", e[i].Error()) - // We check the next index to see if it is within the slice. - // If it is, then we append a newline. We do this, because unit tests - // could be broken with the additional '\n' - if i+1 < size { - msg += "\n" - } - } - } - return msg -} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/copy.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/copy.go deleted file mode 100644 index 8429470b9d..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/copy.go +++ /dev/null @@ -1,100 +0,0 @@ -package awsutil - -import ( - "io" - "reflect" -) - -// Copy deeply copies a src structure to dst. Useful for copying request and -// response structures. -// -// Can copy between structs of different type, but will only copy fields which -// are assignable, and exist in both structs. Fields which are not assignable, -// or do not exist in both structs are ignored. -func Copy(dst, src interface{}) { - dstval := reflect.ValueOf(dst) - if !dstval.IsValid() { - panic("Copy dst cannot be nil") - } - - rcopy(dstval, reflect.ValueOf(src), true) -} - -// CopyOf returns a copy of src while also allocating the memory for dst. -// src must be a pointer type or this operation will fail. -func CopyOf(src interface{}) (dst interface{}) { - dsti := reflect.New(reflect.TypeOf(src).Elem()) - dst = dsti.Interface() - rcopy(dsti, reflect.ValueOf(src), true) - return -} - -// rcopy performs a recursive copy of values from the source to destination. -// -// root is used to skip certain aspects of the copy which are not valid -// for the root node of a object. -func rcopy(dst, src reflect.Value, root bool) { - if !src.IsValid() { - return - } - - switch src.Kind() { - case reflect.Ptr: - if _, ok := src.Interface().(io.Reader); ok { - if dst.Kind() == reflect.Ptr && dst.Elem().CanSet() { - dst.Elem().Set(src) - } else if dst.CanSet() { - dst.Set(src) - } - } else { - e := src.Type().Elem() - if dst.CanSet() && !src.IsNil() { - dst.Set(reflect.New(e)) - } - if src.Elem().IsValid() { - // Keep the current root state since the depth hasn't changed - rcopy(dst.Elem(), src.Elem(), root) - } - } - case reflect.Struct: - t := dst.Type() - for i := 0; i < t.NumField(); i++ { - name := t.Field(i).Name - srcVal := src.FieldByName(name) - dstVal := dst.FieldByName(name) - if srcVal.IsValid() && dstVal.CanSet() { - rcopy(dstVal, srcVal, false) - } - } - case reflect.Slice: - if src.IsNil() { - break - } - - s := reflect.MakeSlice(src.Type(), src.Len(), src.Cap()) - dst.Set(s) - for i := 0; i < src.Len(); i++ { - rcopy(dst.Index(i), src.Index(i), false) - } - case reflect.Map: - if src.IsNil() { - break - } - - s := reflect.MakeMap(src.Type()) - dst.Set(s) - for _, k := range src.MapKeys() { - v := src.MapIndex(k) - v2 := reflect.New(v.Type()).Elem() - rcopy(v2, v, false) - dst.SetMapIndex(k, v2) - } - default: - // Assign the value if possible. If its not assignable, the value would - // need to be converted and the impact of that may be unexpected, or is - // not compatible with the dst type. - if src.Type().AssignableTo(dst.Type()) { - dst.Set(src) - } - } -} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/equal.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/equal.go deleted file mode 100644 index 59fa4a558a..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/equal.go +++ /dev/null @@ -1,27 +0,0 @@ -package awsutil - -import ( - "reflect" -) - -// DeepEqual returns if the two values are deeply equal like reflect.DeepEqual. -// In addition to this, this method will also dereference the input values if -// possible so the DeepEqual performed will not fail if one parameter is a -// pointer and the other is not. -// -// DeepEqual will not perform indirection of nested values of the input parameters. -func DeepEqual(a, b interface{}) bool { - ra := reflect.Indirect(reflect.ValueOf(a)) - rb := reflect.Indirect(reflect.ValueOf(b)) - - if raValid, rbValid := ra.IsValid(), rb.IsValid(); !raValid && !rbValid { - // If the elements are both nil, and of the same type the are equal - // If they are of different types they are not equal - return reflect.TypeOf(a) == reflect.TypeOf(b) - } else if raValid != rbValid { - // Both values must be valid to be equal - return false - } - - return reflect.DeepEqual(ra.Interface(), rb.Interface()) -} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/path_value.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/path_value.go deleted file mode 100644 index 4d2a01e8c4..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/path_value.go +++ /dev/null @@ -1,222 +0,0 @@ -package awsutil - -import ( - "reflect" - "regexp" - "strconv" - "strings" - - "github.com/jmespath/go-jmespath" -) - -var indexRe = regexp.MustCompile(`(.+)\[(-?\d+)?\]$`) - -// rValuesAtPath returns a slice of values found in value v. The values -// in v are explored recursively so all nested values are collected. -func rValuesAtPath(v interface{}, path string, createPath, caseSensitive, nilTerm bool) []reflect.Value { - pathparts := strings.Split(path, "||") - if len(pathparts) > 1 { - for _, pathpart := range pathparts { - vals := rValuesAtPath(v, pathpart, createPath, caseSensitive, nilTerm) - if len(vals) > 0 { - return vals - } - } - return nil - } - - values := []reflect.Value{reflect.Indirect(reflect.ValueOf(v))} - components := strings.Split(path, ".") - for len(values) > 0 && len(components) > 0 { - var index *int64 - var indexStar bool - c := strings.TrimSpace(components[0]) - if c == "" { // no actual component, illegal syntax - return nil - } else if caseSensitive && c != "*" && strings.ToLower(c[0:1]) == c[0:1] { - // TODO normalize case for user - return nil // don't support unexported fields - } - - // parse this component - if m := indexRe.FindStringSubmatch(c); m != nil { - c = m[1] - if m[2] == "" { - index = nil - indexStar = true - } else { - i, _ := strconv.ParseInt(m[2], 10, 32) - index = &i - indexStar = false - } - } - - nextvals := []reflect.Value{} - for _, value := range values { - // pull component name out of struct member - if value.Kind() != reflect.Struct { - continue - } - - if c == "*" { // pull all members - for i := 0; i < value.NumField(); i++ { - if f := reflect.Indirect(value.Field(i)); f.IsValid() { - nextvals = append(nextvals, f) - } - } - continue - } - - value = value.FieldByNameFunc(func(name string) bool { - if c == name { - return true - } else if !caseSensitive && strings.ToLower(name) == strings.ToLower(c) { - return true - } - return false - }) - - if nilTerm && value.Kind() == reflect.Ptr && len(components[1:]) == 0 { - if !value.IsNil() { - value.Set(reflect.Zero(value.Type())) - } - return []reflect.Value{value} - } - - if createPath && value.Kind() == reflect.Ptr && value.IsNil() { - // TODO if the value is the terminus it should not be created - // if the value to be set to its position is nil. - value.Set(reflect.New(value.Type().Elem())) - value = value.Elem() - } else { - value = reflect.Indirect(value) - } - - if value.Kind() == reflect.Slice || value.Kind() == reflect.Map { - if !createPath && value.IsNil() { - value = reflect.ValueOf(nil) - } - } - - if value.IsValid() { - nextvals = append(nextvals, value) - } - } - values = nextvals - - if indexStar || index != nil { - nextvals = []reflect.Value{} - for _, value := range values { - value := reflect.Indirect(value) - if value.Kind() != reflect.Slice { - continue - } - - if indexStar { // grab all indices - for i := 0; i < value.Len(); i++ { - idx := reflect.Indirect(value.Index(i)) - if idx.IsValid() { - nextvals = append(nextvals, idx) - } - } - continue - } - - // pull out index - i := int(*index) - if i >= value.Len() { // check out of bounds - if createPath { - // TODO resize slice - } else { - continue - } - } else if i < 0 { // support negative indexing - i = value.Len() + i - } - value = reflect.Indirect(value.Index(i)) - - if value.Kind() == reflect.Slice || value.Kind() == reflect.Map { - if !createPath && value.IsNil() { - value = reflect.ValueOf(nil) - } - } - - if value.IsValid() { - nextvals = append(nextvals, value) - } - } - values = nextvals - } - - components = components[1:] - } - return values -} - -// ValuesAtPath returns a list of values at the case insensitive lexical -// path inside of a structure. -func ValuesAtPath(i interface{}, path string) ([]interface{}, error) { - result, err := jmespath.Search(path, i) - if err != nil { - return nil, err - } - - v := reflect.ValueOf(result) - if !v.IsValid() || (v.Kind() == reflect.Ptr && v.IsNil()) { - return nil, nil - } - if s, ok := result.([]interface{}); ok { - return s, err - } - if v.Kind() == reflect.Map && v.Len() == 0 { - return nil, nil - } - if v.Kind() == reflect.Slice { - out := make([]interface{}, v.Len()) - for i := 0; i < v.Len(); i++ { - out[i] = v.Index(i).Interface() - } - return out, nil - } - - return []interface{}{result}, nil -} - -// SetValueAtPath sets a value at the case insensitive lexical path inside -// of a structure. -func SetValueAtPath(i interface{}, path string, v interface{}) { - if rvals := rValuesAtPath(i, path, true, false, v == nil); rvals != nil { - for _, rval := range rvals { - if rval.Kind() == reflect.Ptr && rval.IsNil() { - continue - } - setValue(rval, v) - } - } -} - -func setValue(dstVal reflect.Value, src interface{}) { - if dstVal.Kind() == reflect.Ptr { - dstVal = reflect.Indirect(dstVal) - } - srcVal := reflect.ValueOf(src) - - if !srcVal.IsValid() { // src is literal nil - if dstVal.CanAddr() { - // Convert to pointer so that pointer's value can be nil'ed - // dstVal = dstVal.Addr() - } - dstVal.Set(reflect.Zero(dstVal.Type())) - - } else if srcVal.Kind() == reflect.Ptr { - if srcVal.IsNil() { - srcVal = reflect.Zero(dstVal.Type()) - } else { - srcVal = reflect.ValueOf(src).Elem() - } - dstVal.Set(srcVal) - } else { - dstVal.Set(srcVal) - } - -} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/prettify.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/prettify.go deleted file mode 100644 index 0de3eaa0f6..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/prettify.go +++ /dev/null @@ -1,103 +0,0 @@ -package awsutil - -import ( - "bytes" - "fmt" - "io" - "reflect" - "strings" -) - -// Prettify returns the string representation of a value. -func Prettify(i interface{}) string { - var buf bytes.Buffer - prettify(reflect.ValueOf(i), 0, &buf) - return buf.String() -} - -// prettify will recursively walk value v to build a textual -// representation of the value. -func prettify(v reflect.Value, indent int, buf *bytes.Buffer) { - for v.Kind() == reflect.Ptr { - v = v.Elem() - } - - switch v.Kind() { - case reflect.Struct: - strtype := v.Type().String() - if strtype == "time.Time" { - fmt.Fprintf(buf, "%s", v.Interface()) - break - } else if strings.HasPrefix(strtype, "io.") { - buf.WriteString("") - break - } - - buf.WriteString("{\n") - - names := []string{} - for i := 0; i < v.Type().NumField(); i++ { - name := v.Type().Field(i).Name - f := v.Field(i) - if name[0:1] == strings.ToLower(name[0:1]) { - continue // ignore unexported fields - } - if (f.Kind() == reflect.Ptr || f.Kind() == reflect.Slice || f.Kind() == reflect.Map) && f.IsNil() { - continue // ignore unset fields - } - names = append(names, name) - } - - for i, n := range names { - val := v.FieldByName(n) - buf.WriteString(strings.Repeat(" ", indent+2)) - buf.WriteString(n + ": ") - prettify(val, indent+2, buf) - - if i < len(names)-1 { - buf.WriteString(",\n") - } - } - - buf.WriteString("\n" + strings.Repeat(" ", indent) + "}") - case reflect.Slice: - nl, id, id2 := "", "", "" - if v.Len() > 3 { - nl, id, id2 = "\n", strings.Repeat(" ", indent), strings.Repeat(" ", indent+2) - } - buf.WriteString("[" + nl) - for i := 0; i < v.Len(); i++ { - buf.WriteString(id2) - prettify(v.Index(i), indent+2, buf) - - if i < v.Len()-1 { - buf.WriteString("," + nl) - } - } - - buf.WriteString(nl + id + "]") - case reflect.Map: - buf.WriteString("{\n") - - for i, k := range v.MapKeys() { - buf.WriteString(strings.Repeat(" ", indent+2)) - buf.WriteString(k.String() + ": ") - prettify(v.MapIndex(k), indent+2, buf) - - if i < v.Len()-1 { - buf.WriteString(",\n") - } - } - - buf.WriteString("\n" + strings.Repeat(" ", indent) + "}") - default: - format := "%v" - switch v.Interface().(type) { - case string: - format = "%q" - case io.ReadSeeker, io.Reader: - format = "buffer(%p)" - } - fmt.Fprintf(buf, format, v.Interface()) - } -} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/string_value.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/string_value.go deleted file mode 100644 index b6432f1a11..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/awsutil/string_value.go +++ /dev/null @@ -1,89 +0,0 @@ -package awsutil - -import ( - "bytes" - "fmt" - "reflect" - "strings" -) - -// StringValue returns the string representation of a value. -func StringValue(i interface{}) string { - var buf bytes.Buffer - stringValue(reflect.ValueOf(i), 0, &buf) - return buf.String() -} - -func stringValue(v reflect.Value, indent int, buf *bytes.Buffer) { - for v.Kind() == reflect.Ptr { - v = v.Elem() - } - - switch v.Kind() { - case reflect.Struct: - buf.WriteString("{\n") - - names := []string{} - for i := 0; i < v.Type().NumField(); i++ { - name := v.Type().Field(i).Name - f := v.Field(i) - if name[0:1] == strings.ToLower(name[0:1]) { - continue // ignore unexported fields - } - if (f.Kind() == reflect.Ptr || f.Kind() == reflect.Slice) && f.IsNil() { - continue // ignore unset fields - } - names = append(names, name) - } - - for i, n := range names { - val := v.FieldByName(n) - buf.WriteString(strings.Repeat(" ", indent+2)) - buf.WriteString(n + ": ") - stringValue(val, indent+2, buf) - - if i < len(names)-1 { - buf.WriteString(",\n") - } - } - - buf.WriteString("\n" + strings.Repeat(" ", indent) + "}") - case reflect.Slice: - nl, id, id2 := "", "", "" - if v.Len() > 3 { - nl, id, id2 = "\n", strings.Repeat(" ", indent), strings.Repeat(" ", indent+2) - } - buf.WriteString("[" + nl) - for i := 0; i < v.Len(); i++ { - buf.WriteString(id2) - stringValue(v.Index(i), indent+2, buf) - - if i < v.Len()-1 { - buf.WriteString("," + nl) - } - } - - buf.WriteString(nl + id + "]") - case reflect.Map: - buf.WriteString("{\n") - - for i, k := range v.MapKeys() { - buf.WriteString(strings.Repeat(" ", indent+2)) - buf.WriteString(k.String() + ": ") - stringValue(v.MapIndex(k), indent+2, buf) - - if i < v.Len()-1 { - buf.WriteString(",\n") - } - } - - buf.WriteString("\n" + strings.Repeat(" ", indent) + "}") - default: - format := "%v" - switch v.Interface().(type) { - case string: - format = "%q" - } - fmt.Fprintf(buf, format, v.Interface()) - } -} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/client/metadata/client_info.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/client/metadata/client_info.go deleted file mode 100644 index 4778056ddf..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/client/metadata/client_info.go +++ /dev/null @@ -1,12 +0,0 @@ -package metadata - -// ClientInfo wraps immutable data from the client.Client structure. -type ClientInfo struct { - ServiceName string - APIVersion string - Endpoint string - SigningName string - SigningRegion string - JSONVersion string - TargetPrefix string -} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/config.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/config.go deleted file mode 100644 index 9e83e9260a..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/config.go +++ /dev/null @@ -1,311 +0,0 @@ -package aws - -import ( - "net/http" - "time" - - "github.com/aws/aws-sdk-go/aws/credentials" -) - -// UseServiceDefaultRetries instructs the config to use the service's own default -// number of retries. This will be the default action if Config.MaxRetries -// is nil also. -const UseServiceDefaultRetries = -1 - -// RequestRetryer is an alias for a type that implements the request.Retryer interface. -type RequestRetryer interface{} - -// A Config provides service configuration for service clients. By default, -// all clients will use the {defaults.DefaultConfig} structure. -type Config struct { - // Enables verbose error printing of all credential chain errors. - // Should be used when wanting to see all errors while attempting to retreive - // credentials. - CredentialsChainVerboseErrors *bool - - // The credentials object to use when signing requests. Defaults to - // a chain of credential providers to search for credentials in environment - // variables, shared credential file, and EC2 Instance Roles. - Credentials *credentials.Credentials - - // An optional endpoint URL (hostname only or fully qualified URI) - // that overrides the default generated endpoint for a client. Set this - // to `""` to use the default generated endpoint. - // - // @note You must still provide a `Region` value when specifying an - // endpoint for a client. - Endpoint *string - - // The region to send requests to. This parameter is required and must - // be configured globally or on a per-client basis unless otherwise - // noted. A full list of regions is found in the "Regions and Endpoints" - // document. - // - // @see http://docs.aws.amazon.com/general/latest/gr/rande.html - // AWS Regions and Endpoints - Region *string - - // Set this to `true` to disable SSL when sending requests. Defaults - // to `false`. - DisableSSL *bool - - // The HTTP client to use when sending requests. Defaults to - // `http.DefaultClient`. - HTTPClient *http.Client - - // An integer value representing the logging level. The default log level - // is zero (LogOff), which represents no logging. To enable logging set - // to a LogLevel Value. - LogLevel *LogLevelType - - // The logger writer interface to write logging messages to. Defaults to - // standard out. - Logger Logger - - // The maximum number of times that a request will be retried for failures. - // Defaults to -1, which defers the max retry setting to the service specific - // configuration. - MaxRetries *int - - // Retryer guides how HTTP requests should be retried in case of recoverable failures. - // - // When nil or the value does not implement the request.Retryer interface, - // the request.DefaultRetryer will be used. - // - // When both Retryer and MaxRetries are non-nil, the former is used and - // the latter ignored. - // - // To set the Retryer field in a type-safe manner and with chaining, use - // the request.WithRetryer helper function: - // - // cfg := request.WithRetryer(aws.NewConfig(), myRetryer) - // - Retryer RequestRetryer - - // Disables semantic parameter validation, which validates input for missing - // required fields and/or other semantic request input errors. - DisableParamValidation *bool - - // Disables the computation of request and response checksums, e.g., - // CRC32 checksums in Amazon DynamoDB. - DisableComputeChecksums *bool - - // Set this to `true` to force the request to use path-style addressing, - // i.e., `http://s3.amazonaws.com/BUCKET/KEY`. By default, the S3 client will - // use virtual hosted bucket addressing when possible - // (`http://BUCKET.s3.amazonaws.com/KEY`). - // - // @note This configuration option is specific to the Amazon S3 service. - // @see http://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html - // Amazon S3: Virtual Hosting of Buckets - S3ForcePathStyle *bool - - // Set this to `true` to disable the EC2Metadata client from overriding the - // default http.Client's Timeout. This is helpful if you do not want the EC2Metadata - // client to create a new http.Client. This options is only meaningful if you're not - // already using a custom HTTP client with the SDK. Enabled by default. - // - // Must be set and provided to the session.New() in order to disable the EC2Metadata - // overriding the timeout for default credentials chain. - // - // Example: - // sess := session.New(aws.NewConfig().WithEC2MetadataDiableTimeoutOverride(true)) - // svc := s3.New(sess) - // - EC2MetadataDisableTimeoutOverride *bool - - SleepDelay func(time.Duration) -} - -// NewConfig returns a new Config pointer that can be chained with builder methods to -// set multiple configuration values inline without using pointers. -// -// svc := s3.New(aws.NewConfig().WithRegion("us-west-2").WithMaxRetries(10)) -// -func NewConfig() *Config { - return &Config{} -} - -// WithCredentialsChainVerboseErrors sets a config verbose errors boolean and returning -// a Config pointer. -func (c *Config) WithCredentialsChainVerboseErrors(verboseErrs bool) *Config { - c.CredentialsChainVerboseErrors = &verboseErrs - return c -} - -// WithCredentials sets a config Credentials value returning a Config pointer -// for chaining. -func (c *Config) WithCredentials(creds *credentials.Credentials) *Config { - c.Credentials = creds - return c -} - -// WithEndpoint sets a config Endpoint value returning a Config pointer for -// chaining. -func (c *Config) WithEndpoint(endpoint string) *Config { - c.Endpoint = &endpoint - return c -} - -// WithRegion sets a config Region value returning a Config pointer for -// chaining. -func (c *Config) WithRegion(region string) *Config { - c.Region = ®ion - return c -} - -// WithDisableSSL sets a config DisableSSL value returning a Config pointer -// for chaining. -func (c *Config) WithDisableSSL(disable bool) *Config { - c.DisableSSL = &disable - return c -} - -// WithHTTPClient sets a config HTTPClient value returning a Config pointer -// for chaining. -func (c *Config) WithHTTPClient(client *http.Client) *Config { - c.HTTPClient = client - return c -} - -// WithMaxRetries sets a config MaxRetries value returning a Config pointer -// for chaining. -func (c *Config) WithMaxRetries(max int) *Config { - c.MaxRetries = &max - return c -} - -// WithDisableParamValidation sets a config DisableParamValidation value -// returning a Config pointer for chaining. -func (c *Config) WithDisableParamValidation(disable bool) *Config { - c.DisableParamValidation = &disable - return c -} - -// WithDisableComputeChecksums sets a config DisableComputeChecksums value -// returning a Config pointer for chaining. -func (c *Config) WithDisableComputeChecksums(disable bool) *Config { - c.DisableComputeChecksums = &disable - return c -} - -// WithLogLevel sets a config LogLevel value returning a Config pointer for -// chaining. -func (c *Config) WithLogLevel(level LogLevelType) *Config { - c.LogLevel = &level - return c -} - -// WithLogger sets a config Logger value returning a Config pointer for -// chaining. -func (c *Config) WithLogger(logger Logger) *Config { - c.Logger = logger - return c -} - -// WithS3ForcePathStyle sets a config S3ForcePathStyle value returning a Config -// pointer for chaining. -func (c *Config) WithS3ForcePathStyle(force bool) *Config { - c.S3ForcePathStyle = &force - return c -} - -// WithEC2MetadataDisableTimeoutOverride sets a config EC2MetadataDisableTimeoutOverride value -// returning a Config pointer for chaining. -func (c *Config) WithEC2MetadataDisableTimeoutOverride(enable bool) *Config { - c.EC2MetadataDisableTimeoutOverride = &enable - return c -} - -// WithSleepDelay overrides the function used to sleep while waiting for the -// next retry. Defaults to time.Sleep. -func (c *Config) WithSleepDelay(fn func(time.Duration)) *Config { - c.SleepDelay = fn - return c -} - -// MergeIn merges the passed in configs into the existing config object. -func (c *Config) MergeIn(cfgs ...*Config) { - for _, other := range cfgs { - mergeInConfig(c, other) - } -} - -func mergeInConfig(dst *Config, other *Config) { - if other == nil { - return - } - - if other.CredentialsChainVerboseErrors != nil { - dst.CredentialsChainVerboseErrors = other.CredentialsChainVerboseErrors - } - - if other.Credentials != nil { - dst.Credentials = other.Credentials - } - - if other.Endpoint != nil { - dst.Endpoint = other.Endpoint - } - - if other.Region != nil { - dst.Region = other.Region - } - - if other.DisableSSL != nil { - dst.DisableSSL = other.DisableSSL - } - - if other.HTTPClient != nil { - dst.HTTPClient = other.HTTPClient - } - - if other.LogLevel != nil { - dst.LogLevel = other.LogLevel - } - - if other.Logger != nil { - dst.Logger = other.Logger - } - - if other.MaxRetries != nil { - dst.MaxRetries = other.MaxRetries - } - - if other.Retryer != nil { - dst.Retryer = other.Retryer - } - - if other.DisableParamValidation != nil { - dst.DisableParamValidation = other.DisableParamValidation - } - - if other.DisableComputeChecksums != nil { - dst.DisableComputeChecksums = other.DisableComputeChecksums - } - - if other.S3ForcePathStyle != nil { - dst.S3ForcePathStyle = other.S3ForcePathStyle - } - - if other.EC2MetadataDisableTimeoutOverride != nil { - dst.EC2MetadataDisableTimeoutOverride = other.EC2MetadataDisableTimeoutOverride - } - - if other.SleepDelay != nil { - dst.SleepDelay = other.SleepDelay - } -} - -// Copy will return a shallow copy of the Config object. If any additional -// configurations are provided they will be merged into the new config returned. -func (c *Config) Copy(cfgs ...*Config) *Config { - dst := &Config{} - dst.MergeIn(c) - - for _, cfg := range cfgs { - dst.MergeIn(cfg) - } - - return dst -} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/convert_types.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/convert_types.go deleted file mode 100644 index d6a7b08dff..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/convert_types.go +++ /dev/null @@ -1,357 +0,0 @@ -package aws - -import "time" - -// String returns a pointer to of the string value passed in. -func String(v string) *string { - return &v -} - -// StringValue returns the value of the string pointer passed in or -// "" if the pointer is nil. -func StringValue(v *string) string { - if v != nil { - return *v - } - return "" -} - -// StringSlice converts a slice of string values into a slice of -// string pointers -func StringSlice(src []string) []*string { - dst := make([]*string, len(src)) - for i := 0; i < len(src); i++ { - dst[i] = &(src[i]) - } - return dst -} - -// StringValueSlice converts a slice of string pointers into a slice of -// string values -func StringValueSlice(src []*string) []string { - dst := make([]string, len(src)) - for i := 0; i < len(src); i++ { - if src[i] != nil { - dst[i] = *(src[i]) - } - } - return dst -} - -// StringMap converts a string map of string values into a string -// map of string pointers -func StringMap(src map[string]string) map[string]*string { - dst := make(map[string]*string) - for k, val := range src { - v := val - dst[k] = &v - } - return dst -} - -// StringValueMap converts a string map of string pointers into a string -// map of string values -func StringValueMap(src map[string]*string) map[string]string { - dst := make(map[string]string) - for k, val := range src { - if val != nil { - dst[k] = *val - } - } - return dst -} - -// Bool returns a pointer to of the bool value passed in. -func Bool(v bool) *bool { - return &v -} - -// BoolValue returns the value of the bool pointer passed in or -// false if the pointer is nil. -func BoolValue(v *bool) bool { - if v != nil { - return *v - } - return false -} - -// BoolSlice converts a slice of bool values into a slice of -// bool pointers -func BoolSlice(src []bool) []*bool { - dst := make([]*bool, len(src)) - for i := 0; i < len(src); i++ { - dst[i] = &(src[i]) - } - return dst -} - -// BoolValueSlice converts a slice of bool pointers into a slice of -// bool values -func BoolValueSlice(src []*bool) []bool { - dst := make([]bool, len(src)) - for i := 0; i < len(src); i++ { - if src[i] != nil { - dst[i] = *(src[i]) - } - } - return dst -} - -// BoolMap converts a string map of bool values into a string -// map of bool pointers -func BoolMap(src map[string]bool) map[string]*bool { - dst := make(map[string]*bool) - for k, val := range src { - v := val - dst[k] = &v - } - return dst -} - -// BoolValueMap converts a string map of bool pointers into a string -// map of bool values -func BoolValueMap(src map[string]*bool) map[string]bool { - dst := make(map[string]bool) - for k, val := range src { - if val != nil { - dst[k] = *val - } - } - return dst -} - -// Int returns a pointer to of the int value passed in. -func Int(v int) *int { - return &v -} - -// IntValue returns the value of the int pointer passed in or -// 0 if the pointer is nil. -func IntValue(v *int) int { - if v != nil { - return *v - } - return 0 -} - -// IntSlice converts a slice of int values into a slice of -// int pointers -func IntSlice(src []int) []*int { - dst := make([]*int, len(src)) - for i := 0; i < len(src); i++ { - dst[i] = &(src[i]) - } - return dst -} - -// IntValueSlice converts a slice of int pointers into a slice of -// int values -func IntValueSlice(src []*int) []int { - dst := make([]int, len(src)) - for i := 0; i < len(src); i++ { - if src[i] != nil { - dst[i] = *(src[i]) - } - } - return dst -} - -// IntMap converts a string map of int values into a string -// map of int pointers -func IntMap(src map[string]int) map[string]*int { - dst := make(map[string]*int) - for k, val := range src { - v := val - dst[k] = &v - } - return dst -} - -// IntValueMap converts a string map of int pointers into a string -// map of int values -func IntValueMap(src map[string]*int) map[string]int { - dst := make(map[string]int) - for k, val := range src { - if val != nil { - dst[k] = *val - } - } - return dst -} - -// Int64 returns a pointer to of the int64 value passed in. -func Int64(v int64) *int64 { - return &v -} - -// Int64Value returns the value of the int64 pointer passed in or -// 0 if the pointer is nil. -func Int64Value(v *int64) int64 { - if v != nil { - return *v - } - return 0 -} - -// Int64Slice converts a slice of int64 values into a slice of -// int64 pointers -func Int64Slice(src []int64) []*int64 { - dst := make([]*int64, len(src)) - for i := 0; i < len(src); i++ { - dst[i] = &(src[i]) - } - return dst -} - -// Int64ValueSlice converts a slice of int64 pointers into a slice of -// int64 values -func Int64ValueSlice(src []*int64) []int64 { - dst := make([]int64, len(src)) - for i := 0; i < len(src); i++ { - if src[i] != nil { - dst[i] = *(src[i]) - } - } - return dst -} - -// Int64Map converts a string map of int64 values into a string -// map of int64 pointers -func Int64Map(src map[string]int64) map[string]*int64 { - dst := make(map[string]*int64) - for k, val := range src { - v := val - dst[k] = &v - } - return dst -} - -// Int64ValueMap converts a string map of int64 pointers into a string -// map of int64 values -func Int64ValueMap(src map[string]*int64) map[string]int64 { - dst := make(map[string]int64) - for k, val := range src { - if val != nil { - dst[k] = *val - } - } - return dst -} - -// Float64 returns a pointer to of the float64 value passed in. -func Float64(v float64) *float64 { - return &v -} - -// Float64Value returns the value of the float64 pointer passed in or -// 0 if the pointer is nil. -func Float64Value(v *float64) float64 { - if v != nil { - return *v - } - return 0 -} - -// Float64Slice converts a slice of float64 values into a slice of -// float64 pointers -func Float64Slice(src []float64) []*float64 { - dst := make([]*float64, len(src)) - for i := 0; i < len(src); i++ { - dst[i] = &(src[i]) - } - return dst -} - -// Float64ValueSlice converts a slice of float64 pointers into a slice of -// float64 values -func Float64ValueSlice(src []*float64) []float64 { - dst := make([]float64, len(src)) - for i := 0; i < len(src); i++ { - if src[i] != nil { - dst[i] = *(src[i]) - } - } - return dst -} - -// Float64Map converts a string map of float64 values into a string -// map of float64 pointers -func Float64Map(src map[string]float64) map[string]*float64 { - dst := make(map[string]*float64) - for k, val := range src { - v := val - dst[k] = &v - } - return dst -} - -// Float64ValueMap converts a string map of float64 pointers into a string -// map of float64 values -func Float64ValueMap(src map[string]*float64) map[string]float64 { - dst := make(map[string]float64) - for k, val := range src { - if val != nil { - dst[k] = *val - } - } - return dst -} - -// Time returns a pointer to of the time.Time value passed in. -func Time(v time.Time) *time.Time { - return &v -} - -// TimeValue returns the value of the time.Time pointer passed in or -// time.Time{} if the pointer is nil. -func TimeValue(v *time.Time) time.Time { - if v != nil { - return *v - } - return time.Time{} -} - -// TimeSlice converts a slice of time.Time values into a slice of -// time.Time pointers -func TimeSlice(src []time.Time) []*time.Time { - dst := make([]*time.Time, len(src)) - for i := 0; i < len(src); i++ { - dst[i] = &(src[i]) - } - return dst -} - -// TimeValueSlice converts a slice of time.Time pointers into a slice of -// time.Time values -func TimeValueSlice(src []*time.Time) []time.Time { - dst := make([]time.Time, len(src)) - for i := 0; i < len(src); i++ { - if src[i] != nil { - dst[i] = *(src[i]) - } - } - return dst -} - -// TimeMap converts a string map of time.Time values into a string -// map of time.Time pointers -func TimeMap(src map[string]time.Time) map[string]*time.Time { - dst := make(map[string]*time.Time) - for k, val := range src { - v := val - dst[k] = &v - } - return dst -} - -// TimeValueMap converts a string map of time.Time pointers into a string -// map of time.Time values -func TimeValueMap(src map[string]*time.Time) map[string]time.Time { - dst := make(map[string]time.Time) - for k, val := range src { - if val != nil { - dst[k] = *val - } - } - return dst -} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/chain_provider.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/chain_provider.go deleted file mode 100644 index 857311f64c..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/chain_provider.go +++ /dev/null @@ -1,100 +0,0 @@ -package credentials - -import ( - "github.com/aws/aws-sdk-go/aws/awserr" -) - -var ( - // ErrNoValidProvidersFoundInChain Is returned when there are no valid - // providers in the ChainProvider. - // - // This has been deprecated. For verbose error messaging set - // aws.Config.CredentialsChainVerboseErrors to true - // - // @readonly - ErrNoValidProvidersFoundInChain = awserr.New("NoCredentialProviders", - `no valid providers in chain. Deprecated. - For verbose messaging see aws.Config.CredentialsChainVerboseErrors`, - nil) -) - -// A ChainProvider will search for a provider which returns credentials -// and cache that provider until Retrieve is called again. -// -// The ChainProvider provides a way of chaining multiple providers together -// which will pick the first available using priority order of the Providers -// in the list. -// -// If none of the Providers retrieve valid credentials Value, ChainProvider's -// Retrieve() will return the error ErrNoValidProvidersFoundInChain. -// -// If a Provider is found which returns valid credentials Value ChainProvider -// will cache that Provider for all calls to IsExpired(), until Retrieve is -// called again. -// -// Example of ChainProvider to be used with an EnvProvider and EC2RoleProvider. -// In this example EnvProvider will first check if any credentials are available -// vai the environment variables. If there are none ChainProvider will check -// the next Provider in the list, EC2RoleProvider in this case. If EC2RoleProvider -// does not return any credentials ChainProvider will return the error -// ErrNoValidProvidersFoundInChain -// -// creds := NewChainCredentials( -// []Provider{ -// &EnvProvider{}, -// &EC2RoleProvider{ -// Client: ec2metadata.New(sess), -// }, -// }) -// -// // Usage of ChainCredentials with aws.Config -// svc := ec2.New(&aws.Config{Credentials: creds}) -// -type ChainProvider struct { - Providers []Provider - curr Provider - VerboseErrors bool -} - -// NewChainCredentials returns a pointer to a new Credentials object -// wrapping a chain of providers. -func NewChainCredentials(providers []Provider) *Credentials { - return NewCredentials(&ChainProvider{ - Providers: append([]Provider{}, providers...), - }) -} - -// Retrieve returns the credentials value or error if no provider returned -// without error. -// -// If a provider is found it will be cached and any calls to IsExpired() -// will return the expired state of the cached provider. -func (c *ChainProvider) Retrieve() (Value, error) { - var errs []error - for _, p := range c.Providers { - creds, err := p.Retrieve() - if err == nil { - c.curr = p - return creds, nil - } - errs = append(errs, err) - } - c.curr = nil - - var err error - err = ErrNoValidProvidersFoundInChain - if c.VerboseErrors { - err = awserr.NewBatchError("NoCredentialProviders", "no valid providers in chain", errs) - } - return Value{}, err -} - -// IsExpired will returned the expired state of the currently cached provider -// if there is one. If there is no current provider, true will be returned. -func (c *ChainProvider) IsExpired() bool { - if c.curr != nil { - return c.curr.IsExpired() - } - - return true -} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/credentials.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/credentials.go deleted file mode 100644 index 7b8ebf5f9d..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/credentials.go +++ /dev/null @@ -1,223 +0,0 @@ -// Package credentials provides credential retrieval and management -// -// The Credentials is the primary method of getting access to and managing -// credentials Values. Using dependency injection retrieval of the credential -// values is handled by a object which satisfies the Provider interface. -// -// By default the Credentials.Get() will cache the successful result of a -// Provider's Retrieve() until Provider.IsExpired() returns true. At which -// point Credentials will call Provider's Retrieve() to get new credential Value. -// -// The Provider is responsible for determining when credentials Value have expired. -// It is also important to note that Credentials will always call Retrieve the -// first time Credentials.Get() is called. -// -// Example of using the environment variable credentials. -// -// creds := NewEnvCredentials() -// -// // Retrieve the credentials value -// credValue, err := creds.Get() -// if err != nil { -// // handle error -// } -// -// Example of forcing credentials to expire and be refreshed on the next Get(). -// This may be helpful to proactively expire credentials and refresh them sooner -// than they would naturally expire on their own. -// -// creds := NewCredentials(&EC2RoleProvider{}) -// creds.Expire() -// credsValue, err := creds.Get() -// // New credentials will be retrieved instead of from cache. -// -// -// Custom Provider -// -// Each Provider built into this package also provides a helper method to generate -// a Credentials pointer setup with the provider. To use a custom Provider just -// create a type which satisfies the Provider interface and pass it to the -// NewCredentials method. -// -// type MyProvider struct{} -// func (m *MyProvider) Retrieve() (Value, error) {...} -// func (m *MyProvider) IsExpired() bool {...} -// -// creds := NewCredentials(&MyProvider{}) -// credValue, err := creds.Get() -// -package credentials - -import ( - "sync" - "time" -) - -// AnonymousCredentials is an empty Credential object that can be used as -// dummy placeholder credentials for requests that do not need signed. -// -// This Credentials can be used to configure a service to not sign requests -// when making service API calls. For example, when accessing public -// s3 buckets. -// -// svc := s3.New(&aws.Config{Credentials: AnonymousCredentials}) -// // Access public S3 buckets. -// -// @readonly -var AnonymousCredentials = NewStaticCredentials("", "", "") - -// A Value is the AWS credentials value for individual credential fields. -type Value struct { - // AWS Access key ID - AccessKeyID string - - // AWS Secret Access Key - SecretAccessKey string - - // AWS Session Token - SessionToken string - - // Provider used to get credentials - ProviderName string -} - -// A Provider is the interface for any component which will provide credentials -// Value. A provider is required to manage its own Expired state, and what to -// be expired means. -// -// The Provider should not need to implement its own mutexes, because -// that will be managed by Credentials. -type Provider interface { - // Refresh returns nil if it successfully retrieved the value. - // Error is returned if the value were not obtainable, or empty. - Retrieve() (Value, error) - - // IsExpired returns if the credentials are no longer valid, and need - // to be retrieved. - IsExpired() bool -} - -// A Expiry provides shared expiration logic to be used by credentials -// providers to implement expiry functionality. -// -// The best method to use this struct is as an anonymous field within the -// provider's struct. -// -// Example: -// type EC2RoleProvider struct { -// Expiry -// ... -// } -type Expiry struct { - // The date/time when to expire on - expiration time.Time - - // If set will be used by IsExpired to determine the current time. - // Defaults to time.Now if CurrentTime is not set. Available for testing - // to be able to mock out the current time. - CurrentTime func() time.Time -} - -// SetExpiration sets the expiration IsExpired will check when called. -// -// If window is greater than 0 the expiration time will be reduced by the -// window value. -// -// Using a window is helpful to trigger credentials to expire sooner than -// the expiration time given to ensure no requests are made with expired -// tokens. -func (e *Expiry) SetExpiration(expiration time.Time, window time.Duration) { - e.expiration = expiration - if window > 0 { - e.expiration = e.expiration.Add(-window) - } -} - -// IsExpired returns if the credentials are expired. -func (e *Expiry) IsExpired() bool { - if e.CurrentTime == nil { - e.CurrentTime = time.Now - } - return e.expiration.Before(e.CurrentTime()) -} - -// A Credentials provides synchronous safe retrieval of AWS credentials Value. -// Credentials will cache the credentials value until they expire. Once the value -// expires the next Get will attempt to retrieve valid credentials. -// -// Credentials is safe to use across multiple goroutines and will manage the -// synchronous state so the Providers do not need to implement their own -// synchronization. -// -// The first Credentials.Get() will always call Provider.Retrieve() to get the -// first instance of the credentials Value. All calls to Get() after that -// will return the cached credentials Value until IsExpired() returns true. -type Credentials struct { - creds Value - forceRefresh bool - m sync.Mutex - - provider Provider -} - -// NewCredentials returns a pointer to a new Credentials with the provider set. -func NewCredentials(provider Provider) *Credentials { - return &Credentials{ - provider: provider, - forceRefresh: true, - } -} - -// Get returns the credentials value, or error if the credentials Value failed -// to be retrieved. -// -// Will return the cached credentials Value if it has not expired. If the -// credentials Value has expired the Provider's Retrieve() will be called -// to refresh the credentials. -// -// If Credentials.Expire() was called the credentials Value will be force -// expired, and the next call to Get() will cause them to be refreshed. -func (c *Credentials) Get() (Value, error) { - c.m.Lock() - defer c.m.Unlock() - - if c.isExpired() { - creds, err := c.provider.Retrieve() - if err != nil { - return Value{}, err - } - c.creds = creds - c.forceRefresh = false - } - - return c.creds, nil -} - -// Expire expires the credentials and forces them to be retrieved on the -// next call to Get(). -// -// This will override the Provider's expired state, and force Credentials -// to call the Provider's Retrieve(). -func (c *Credentials) Expire() { - c.m.Lock() - defer c.m.Unlock() - - c.forceRefresh = true -} - -// IsExpired returns if the credentials are no longer valid, and need -// to be retrieved. -// -// If the Credentials were forced to be expired with Expire() this will -// reflect that override. -func (c *Credentials) IsExpired() bool { - c.m.Lock() - defer c.m.Unlock() - - return c.isExpired() -} - -// isExpired helper method wrapping the definition of expired credentials. -func (c *Credentials) isExpired() bool { - return c.forceRefresh || c.provider.IsExpired() -} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/env_provider.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/env_provider.go deleted file mode 100644 index 96655bc46a..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/env_provider.go +++ /dev/null @@ -1,77 +0,0 @@ -package credentials - -import ( - "os" - - "github.com/aws/aws-sdk-go/aws/awserr" -) - -// EnvProviderName provides a name of Env provider -const EnvProviderName = "EnvProvider" - -var ( - // ErrAccessKeyIDNotFound is returned when the AWS Access Key ID can't be - // found in the process's environment. - // - // @readonly - ErrAccessKeyIDNotFound = awserr.New("EnvAccessKeyNotFound", "AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY not found in environment", nil) - - // ErrSecretAccessKeyNotFound is returned when the AWS Secret Access Key - // can't be found in the process's environment. - // - // @readonly - ErrSecretAccessKeyNotFound = awserr.New("EnvSecretNotFound", "AWS_SECRET_ACCESS_KEY or AWS_SECRET_KEY not found in environment", nil) -) - -// A EnvProvider retrieves credentials from the environment variables of the -// running process. Environment credentials never expire. -// -// Environment variables used: -// -// * Access Key ID: AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY -// * Secret Access Key: AWS_SECRET_ACCESS_KEY or AWS_SECRET_KEY -type EnvProvider struct { - retrieved bool -} - -// NewEnvCredentials returns a pointer to a new Credentials object -// wrapping the environment variable provider. -func NewEnvCredentials() *Credentials { - return NewCredentials(&EnvProvider{}) -} - -// Retrieve retrieves the keys from the environment. -func (e *EnvProvider) Retrieve() (Value, error) { - e.retrieved = false - - id := os.Getenv("AWS_ACCESS_KEY_ID") - if id == "" { - id = os.Getenv("AWS_ACCESS_KEY") - } - - secret := os.Getenv("AWS_SECRET_ACCESS_KEY") - if secret == "" { - secret = os.Getenv("AWS_SECRET_KEY") - } - - if id == "" { - return Value{ProviderName: EnvProviderName}, ErrAccessKeyIDNotFound - } - - if secret == "" { - return Value{ProviderName: EnvProviderName}, ErrSecretAccessKeyNotFound - } - - e.retrieved = true - return Value{ - AccessKeyID: id, - SecretAccessKey: secret, - SessionToken: os.Getenv("AWS_SESSION_TOKEN"), - ProviderName: EnvProviderName, - }, nil -} - -// IsExpired returns if the credentials have been retrieved. -func (e *EnvProvider) IsExpired() bool { - return !e.retrieved -} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/example.ini b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/example.ini deleted file mode 100644 index 7fc91d9d20..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/example.ini +++ /dev/null @@ -1,12 +0,0 @@ -[default] -aws_access_key_id = accessKey -aws_secret_access_key = secret -aws_session_token = token - -[no_token] -aws_access_key_id = accessKey -aws_secret_access_key = secret - -[with_colon] -aws_access_key_id: accessKey -aws_secret_access_key: secret diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/shared_credentials_provider.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/shared_credentials_provider.go deleted file mode 100644 index 7fb7cbf0db..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/shared_credentials_provider.go +++ /dev/null @@ -1,151 +0,0 @@ -package credentials - -import ( - "fmt" - "os" - "path/filepath" - - "github.com/go-ini/ini" - - "github.com/aws/aws-sdk-go/aws/awserr" -) - -// SharedCredsProviderName provides a name of SharedCreds provider -const SharedCredsProviderName = "SharedCredentialsProvider" - -var ( - // ErrSharedCredentialsHomeNotFound is emitted when the user directory cannot be found. - // - // @readonly - ErrSharedCredentialsHomeNotFound = awserr.New("UserHomeNotFound", "user home directory not found.", nil) -) - -// A SharedCredentialsProvider retrieves credentials from the current user's home -// directory, and keeps track if those credentials are expired. -// -// Profile ini file example: $HOME/.aws/credentials -type SharedCredentialsProvider struct { - // Path to the shared credentials file. - // - // If empty will look for "AWS_SHARED_CREDENTIALS_FILE" env variable. If the - // env value is empty will default to current user's home directory. - // Linux/OSX: "$HOME/.aws/credentials" - // Windows: "%USERPROFILE%\.aws\credentials" - Filename string - - // AWS Profile to extract credentials from the shared credentials file. If empty - // will default to environment variable "AWS_PROFILE" or "default" if - // environment variable is also not set. - Profile string - - // retrieved states if the credentials have been successfully retrieved. - retrieved bool -} - -// NewSharedCredentials returns a pointer to a new Credentials object -// wrapping the Profile file provider. -func NewSharedCredentials(filename, profile string) *Credentials { - return NewCredentials(&SharedCredentialsProvider{ - Filename: filename, - Profile: profile, - }) -} - -// Retrieve reads and extracts the shared credentials from the current -// users home directory. -func (p *SharedCredentialsProvider) Retrieve() (Value, error) { - p.retrieved = false - - filename, err := p.filename() - if err != nil { - return Value{ProviderName: SharedCredsProviderName}, err - } - - creds, err := loadProfile(filename, p.profile()) - if err != nil { - return Value{ProviderName: SharedCredsProviderName}, err - } - - p.retrieved = true - return creds, nil -} - -// IsExpired returns if the shared credentials have expired. -func (p *SharedCredentialsProvider) IsExpired() bool { - return !p.retrieved -} - -// loadProfiles loads from the file pointed to by shared credentials filename for profile. -// The credentials retrieved from the profile will be returned or error. Error will be -// returned if it fails to read from the file, or the data is invalid. -func loadProfile(filename, profile string) (Value, error) { - config, err := ini.Load(filename) - if err != nil { - return Value{ProviderName: SharedCredsProviderName}, awserr.New("SharedCredsLoad", "failed to load shared credentials file", err) - } - iniProfile, err := config.GetSection(profile) - if err != nil { - return Value{ProviderName: SharedCredsProviderName}, awserr.New("SharedCredsLoad", "failed to get profile", err) - } - - id, err := iniProfile.GetKey("aws_access_key_id") - if err != nil { - return Value{ProviderName: SharedCredsProviderName}, awserr.New("SharedCredsAccessKey", - fmt.Sprintf("shared credentials %s in %s did not contain aws_access_key_id", profile, filename), - err) - } - - secret, err := iniProfile.GetKey("aws_secret_access_key") - if err != nil { - return Value{ProviderName: SharedCredsProviderName}, awserr.New("SharedCredsSecret", - fmt.Sprintf("shared credentials %s in %s did not contain aws_secret_access_key", profile, filename), - nil) - } - - // Default to empty string if not found - token := iniProfile.Key("aws_session_token") - - return Value{ - AccessKeyID: id.String(), - SecretAccessKey: secret.String(), - SessionToken: token.String(), - ProviderName: SharedCredsProviderName, - }, nil -} - -// filename returns the filename to use to read AWS shared credentials. -// -// Will return an error if the user's home directory path cannot be found. -func (p *SharedCredentialsProvider) filename() (string, error) { - if p.Filename == "" { - if p.Filename = os.Getenv("AWS_SHARED_CREDENTIALS_FILE"); p.Filename != "" { - return p.Filename, nil - } - - homeDir := os.Getenv("HOME") // *nix - if homeDir == "" { // Windows - homeDir = os.Getenv("USERPROFILE") - } - if homeDir == "" { - return "", ErrSharedCredentialsHomeNotFound - } - - p.Filename = filepath.Join(homeDir, ".aws", "credentials") - } - - return p.Filename, nil -} - -// profile returns the AWS shared credentials profile. If empty will read -// environment variable "AWS_PROFILE". If that is not set profile will -// return "default". -func (p *SharedCredentialsProvider) profile() string { - if p.Profile == "" { - p.Profile = os.Getenv("AWS_PROFILE") - } - if p.Profile == "" { - p.Profile = "default" - } - - return p.Profile -} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/static_provider.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/static_provider.go deleted file mode 100644 index 71189e733d..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/credentials/static_provider.go +++ /dev/null @@ -1,48 +0,0 @@ -package credentials - -import ( - "github.com/aws/aws-sdk-go/aws/awserr" -) - -// StaticProviderName provides a name of Static provider -const StaticProviderName = "StaticProvider" - -var ( - // ErrStaticCredentialsEmpty is emitted when static credentials are empty. - // - // @readonly - ErrStaticCredentialsEmpty = awserr.New("EmptyStaticCreds", "static credentials are empty", nil) -) - -// A StaticProvider is a set of credentials which are set pragmatically, -// and will never expire. -type StaticProvider struct { - Value -} - -// NewStaticCredentials returns a pointer to a new Credentials object -// wrapping a static credentials value provider. -func NewStaticCredentials(id, secret, token string) *Credentials { - return NewCredentials(&StaticProvider{Value: Value{ - AccessKeyID: id, - SecretAccessKey: secret, - SessionToken: token, - }}) -} - -// Retrieve returns the credentials or error if the credentials are invalid. -func (s *StaticProvider) Retrieve() (Value, error) { - if s.AccessKeyID == "" || s.SecretAccessKey == "" { - return Value{ProviderName: StaticProviderName}, ErrStaticCredentialsEmpty - } - - s.Value.ProviderName = StaticProviderName - return s.Value, nil -} - -// IsExpired returns if the credentials are expired. -// -// For StaticProvider, the credentials never expired. -func (s *StaticProvider) IsExpired() bool { - return false -} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/errors.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/errors.go deleted file mode 100644 index 5766361686..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/errors.go +++ /dev/null @@ -1,17 +0,0 @@ -package aws - -import "github.com/aws/aws-sdk-go/aws/awserr" - -var ( - // ErrMissingRegion is an error that is returned if region configuration is - // not found. - // - // @readonly - ErrMissingRegion = awserr.New("MissingRegion", "could not find region configuration", nil) - - // ErrMissingEndpoint is an error that is returned if an endpoint cannot be - // resolved for a service. - // - // @readonly - ErrMissingEndpoint = awserr.New("MissingEndpoint", "'Endpoint' configuration is required for this service", nil) -) diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/logger.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/logger.go deleted file mode 100644 index db87188e20..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/logger.go +++ /dev/null @@ -1,112 +0,0 @@ -package aws - -import ( - "log" - "os" -) - -// A LogLevelType defines the level logging should be performed at. Used to instruct -// the SDK which statements should be logged. -type LogLevelType uint - -// LogLevel returns the pointer to a LogLevel. Should be used to workaround -// not being able to take the address of a non-composite literal. -func LogLevel(l LogLevelType) *LogLevelType { - return &l -} - -// Value returns the LogLevel value or the default value LogOff if the LogLevel -// is nil. Safe to use on nil value LogLevelTypes. -func (l *LogLevelType) Value() LogLevelType { - if l != nil { - return *l - } - return LogOff -} - -// Matches returns true if the v LogLevel is enabled by this LogLevel. Should be -// used with logging sub levels. Is safe to use on nil value LogLevelTypes. If -// LogLevel is nill, will default to LogOff comparison. -func (l *LogLevelType) Matches(v LogLevelType) bool { - c := l.Value() - return c&v == v -} - -// AtLeast returns true if this LogLevel is at least high enough to satisfies v. -// Is safe to use on nil value LogLevelTypes. If LogLevel is nill, will default -// to LogOff comparison. -func (l *LogLevelType) AtLeast(v LogLevelType) bool { - c := l.Value() - return c >= v -} - -const ( - // LogOff states that no logging should be performed by the SDK. This is the - // default state of the SDK, and should be use to disable all logging. - LogOff LogLevelType = iota * 0x1000 - - // LogDebug state that debug output should be logged by the SDK. This should - // be used to inspect request made and responses received. - LogDebug -) - -// Debug Logging Sub Levels -const ( - // LogDebugWithSigning states that the SDK should log request signing and - // presigning events. This should be used to log the signing details of - // requests for debugging. Will also enable LogDebug. - LogDebugWithSigning LogLevelType = LogDebug | (1 << iota) - - // LogDebugWithHTTPBody states the SDK should log HTTP request and response - // HTTP bodys in addition to the headers and path. This should be used to - // see the body content of requests and responses made while using the SDK - // Will also enable LogDebug. - LogDebugWithHTTPBody - - // LogDebugWithRequestRetries states the SDK should log when service requests will - // be retried. This should be used to log when you want to log when service - // requests are being retried. Will also enable LogDebug. - LogDebugWithRequestRetries - - // LogDebugWithRequestErrors states the SDK should log when service requests fail - // to build, send, validate, or unmarshal. - LogDebugWithRequestErrors -) - -// A Logger is a minimalistic interface for the SDK to log messages to. Should -// be used to provide custom logging writers for the SDK to use. -type Logger interface { - Log(...interface{}) -} - -// A LoggerFunc is a convenience type to convert a function taking a variadic -// list of arguments and wrap it so the Logger interface can be used. -// -// Example: -// s3.New(sess, &aws.Config{Logger: aws.LoggerFunc(func(args ...interface{}) { -// fmt.Fprintln(os.Stdout, args...) -// })}) -type LoggerFunc func(...interface{}) - -// Log calls the wrapped function with the arguments provided -func (f LoggerFunc) Log(args ...interface{}) { - f(args...) -} - -// NewDefaultLogger returns a Logger which will write log messages to stdout, and -// use same formatting runes as the stdlib log.Logger -func NewDefaultLogger() Logger { - return &defaultLogger{ - logger: log.New(os.Stdout, "", log.LstdFlags), - } -} - -// A defaultLogger provides a minimalistic logger satisfying the Logger interface. -type defaultLogger struct { - logger *log.Logger -} - -// Log logs the parameters to the stdlib logger. See log.Println. -func (l defaultLogger) Log(args ...interface{}) { - l.logger.Println(args...) -} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/handlers.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/handlers.go deleted file mode 100644 index 5279c19c09..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/handlers.go +++ /dev/null @@ -1,187 +0,0 @@ -package request - -import ( - "fmt" - "strings" -) - -// A Handlers provides a collection of request handlers for various -// stages of handling requests. -type Handlers struct { - Validate HandlerList - Build HandlerList - Sign HandlerList - Send HandlerList - ValidateResponse HandlerList - Unmarshal HandlerList - UnmarshalMeta HandlerList - UnmarshalError HandlerList - Retry HandlerList - AfterRetry HandlerList -} - -// Copy returns of this handler's lists. -func (h *Handlers) Copy() Handlers { - return Handlers{ - Validate: h.Validate.copy(), - Build: h.Build.copy(), - Sign: h.Sign.copy(), - Send: h.Send.copy(), - ValidateResponse: h.ValidateResponse.copy(), - Unmarshal: h.Unmarshal.copy(), - UnmarshalError: h.UnmarshalError.copy(), - UnmarshalMeta: h.UnmarshalMeta.copy(), - Retry: h.Retry.copy(), - AfterRetry: h.AfterRetry.copy(), - } -} - -// Clear removes callback functions for all handlers -func (h *Handlers) Clear() { - h.Validate.Clear() - h.Build.Clear() - h.Send.Clear() - h.Sign.Clear() - h.Unmarshal.Clear() - h.UnmarshalMeta.Clear() - h.UnmarshalError.Clear() - h.ValidateResponse.Clear() - h.Retry.Clear() - h.AfterRetry.Clear() -} - -// A HandlerListRunItem represents an entry in the HandlerList which -// is being run. -type HandlerListRunItem struct { - Index int - Handler NamedHandler - Request *Request -} - -// A HandlerList manages zero or more handlers in a list. -type HandlerList struct { - list []NamedHandler - - // Called after each request handler in the list is called. If set - // and the func returns true the HandlerList will continue to iterate - // over the request handlers. If false is returned the HandlerList - // will stop iterating. - // - // Should be used if extra logic to be performed between each handler - // in the list. This can be used to terminate a list's iteration - // based on a condition such as error like, HandlerListStopOnError. - // Or for logging like HandlerListLogItem. - AfterEachFn func(item HandlerListRunItem) bool -} - -// A NamedHandler is a struct that contains a name and function callback. -type NamedHandler struct { - Name string - Fn func(*Request) -} - -// copy creates a copy of the handler list. -func (l *HandlerList) copy() HandlerList { - n := HandlerList{ - AfterEachFn: l.AfterEachFn, - } - n.list = append([]NamedHandler{}, l.list...) - return n -} - -// Clear clears the handler list. -func (l *HandlerList) Clear() { - l.list = []NamedHandler{} -} - -// Len returns the number of handlers in the list. -func (l *HandlerList) Len() int { - return len(l.list) -} - -// PushBack pushes handler f to the back of the handler list. -func (l *HandlerList) PushBack(f func(*Request)) { - l.list = append(l.list, NamedHandler{"__anonymous", f}) -} - -// PushFront pushes handler f to the front of the handler list. -func (l *HandlerList) PushFront(f func(*Request)) { - l.list = append([]NamedHandler{{"__anonymous", f}}, l.list...) -} - -// PushBackNamed pushes named handler f to the back of the handler list. -func (l *HandlerList) PushBackNamed(n NamedHandler) { - l.list = append(l.list, n) -} - -// PushFrontNamed pushes named handler f to the front of the handler list. -func (l *HandlerList) PushFrontNamed(n NamedHandler) { - l.list = append([]NamedHandler{n}, l.list...) -} - -// Remove removes a NamedHandler n -func (l *HandlerList) Remove(n NamedHandler) { - newlist := []NamedHandler{} - for _, m := range l.list { - if m.Name != n.Name { - newlist = append(newlist, m) - } - } - l.list = newlist -} - -// Run executes all handlers in the list with a given request object. -func (l *HandlerList) Run(r *Request) { - for i, h := range l.list { - h.Fn(r) - item := HandlerListRunItem{ - Index: i, Handler: h, Request: r, - } - if l.AfterEachFn != nil && !l.AfterEachFn(item) { - return - } - } -} - -// HandlerListLogItem logs the request handler and the state of the -// request's Error value. Always returns true to continue iterating -// request handlers in a HandlerList. -func HandlerListLogItem(item HandlerListRunItem) bool { - if item.Request.Config.Logger == nil { - return true - } - item.Request.Config.Logger.Log("DEBUG: RequestHandler", - item.Index, item.Handler.Name, item.Request.Error) - - return true -} - -// HandlerListStopOnError returns false to stop the HandlerList iterating -// over request handlers if Request.Error is not nil. True otherwise -// to continue iterating. -func HandlerListStopOnError(item HandlerListRunItem) bool { - return item.Request.Error == nil -} - -// MakeAddToUserAgentHandler will add the name/version pair to the User-Agent request -// header. If the extra parameters are provided they will be added as metadata to the -// name/version pair resulting in the following format. -// "name/version (extra0; extra1; ...)" -// The user agent part will be concatenated with this current request's user agent string. -func MakeAddToUserAgentHandler(name, version string, extra ...string) func(*Request) { - ua := fmt.Sprintf("%s/%s", name, version) - if len(extra) > 0 { - ua += fmt.Sprintf(" (%s)", strings.Join(extra, "; ")) - } - return func(r *Request) { - AddToUserAgent(r, ua) - } -} - -// MakeAddToUserAgentFreeFormHandler adds the input to the User-Agent request header. -// The input string will be concatenated with the current request's user agent string. -func MakeAddToUserAgentFreeFormHandler(s string) func(*Request) { - return func(r *Request) { - AddToUserAgent(r, s) - } -} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/request.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/request.go deleted file mode 100644 index 85eead3d51..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/request.go +++ /dev/null @@ -1,302 +0,0 @@ -package request - -import ( - "bytes" - "fmt" - "io" - "io/ioutil" - "net/http" - "net/url" - "reflect" - "strings" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/client/metadata" -) - -// A Request is the service request to be made. -type Request struct { - Config aws.Config - ClientInfo metadata.ClientInfo - Handlers Handlers - - Retryer - Time time.Time - ExpireTime time.Duration - Operation *Operation - HTTPRequest *http.Request - HTTPResponse *http.Response - Body io.ReadSeeker - BodyStart int64 // offset from beginning of Body that the request body starts - Params interface{} - Error error - Data interface{} - RequestID string - RetryCount int - Retryable *bool - RetryDelay time.Duration - NotHoist bool - SignedHeaderVals http.Header - - built bool -} - -// An Operation is the service API operation to be made. -type Operation struct { - Name string - HTTPMethod string - HTTPPath string - *Paginator -} - -// Paginator keeps track of pagination configuration for an API operation. -type Paginator struct { - InputTokens []string - OutputTokens []string - LimitToken string - TruncationToken string -} - -// New returns a new Request pointer for the service API -// operation and parameters. -// -// Params is any value of input parameters to be the request payload. -// Data is pointer value to an object which the request's response -// payload will be deserialized to. -func New(cfg aws.Config, clientInfo metadata.ClientInfo, handlers Handlers, - retryer Retryer, operation *Operation, params interface{}, data interface{}) *Request { - - method := operation.HTTPMethod - if method == "" { - method = "POST" - } - p := operation.HTTPPath - if p == "" { - p = "/" - } - - httpReq, _ := http.NewRequest(method, "", nil) - httpReq.URL, _ = url.Parse(clientInfo.Endpoint + p) - - r := &Request{ - Config: cfg, - ClientInfo: clientInfo, - Handlers: handlers.Copy(), - - Retryer: retryer, - Time: time.Now(), - ExpireTime: 0, - Operation: operation, - HTTPRequest: httpReq, - Body: nil, - Params: params, - Error: nil, - Data: data, - } - r.SetBufferBody([]byte{}) - - return r -} - -// WillRetry returns if the request's can be retried. -func (r *Request) WillRetry() bool { - return r.Error != nil && aws.BoolValue(r.Retryable) && r.RetryCount < r.MaxRetries() -} - -// ParamsFilled returns if the request's parameters have been populated -// and the parameters are valid. False is returned if no parameters are -// provided or invalid. -func (r *Request) ParamsFilled() bool { - return r.Params != nil && reflect.ValueOf(r.Params).Elem().IsValid() -} - -// DataFilled returns true if the request's data for response deserialization -// target has been set and is a valid. False is returned if data is not -// set, or is invalid. -func (r *Request) DataFilled() bool { - return r.Data != nil && reflect.ValueOf(r.Data).Elem().IsValid() -} - -// SetBufferBody will set the request's body bytes that will be sent to -// the service API. -func (r *Request) SetBufferBody(buf []byte) { - r.SetReaderBody(bytes.NewReader(buf)) -} - -// SetStringBody sets the body of the request to be backed by a string. -func (r *Request) SetStringBody(s string) { - r.SetReaderBody(strings.NewReader(s)) -} - -// SetReaderBody will set the request's body reader. -func (r *Request) SetReaderBody(reader io.ReadSeeker) { - r.HTTPRequest.Body = ioutil.NopCloser(reader) - r.Body = reader -} - -// Presign returns the request's signed URL. Error will be returned -// if the signing fails. -func (r *Request) Presign(expireTime time.Duration) (string, error) { - r.ExpireTime = expireTime - r.NotHoist = false - r.Sign() - if r.Error != nil { - return "", r.Error - } - return r.HTTPRequest.URL.String(), nil -} - -// PresignRequest behaves just like presign, but hoists all headers and signs them. -// Also returns the signed hash back to the user -func (r *Request) PresignRequest(expireTime time.Duration) (string, http.Header, error) { - r.ExpireTime = expireTime - r.NotHoist = true - r.Sign() - if r.Error != nil { - return "", nil, r.Error - } - return r.HTTPRequest.URL.String(), r.SignedHeaderVals, nil -} - -func debugLogReqError(r *Request, stage string, retrying bool, err error) { - if !r.Config.LogLevel.Matches(aws.LogDebugWithRequestErrors) { - return - } - - retryStr := "not retrying" - if retrying { - retryStr = "will retry" - } - - r.Config.Logger.Log(fmt.Sprintf("DEBUG: %s %s/%s failed, %s, error %v", - stage, r.ClientInfo.ServiceName, r.Operation.Name, retryStr, err)) -} - -// Build will build the request's object so it can be signed and sent -// to the service. Build will also validate all the request's parameters. -// Anny additional build Handlers set on this request will be run -// in the order they were set. -// -// The request will only be built once. Multiple calls to build will have -// no effect. -// -// If any Validate or Build errors occur the build will stop and the error -// which occurred will be returned. -func (r *Request) Build() error { - if !r.built { - r.Error = nil - r.Handlers.Validate.Run(r) - if r.Error != nil { - debugLogReqError(r, "Validate Request", false, r.Error) - return r.Error - } - r.Handlers.Build.Run(r) - if r.Error != nil { - debugLogReqError(r, "Build Request", false, r.Error) - return r.Error - } - r.built = true - } - - return r.Error -} - -// Sign will sign the request retuning error if errors are encountered. -// -// Send will build the request prior to signing. All Sign Handlers will -// be executed in the order they were set. -func (r *Request) Sign() error { - r.Build() - if r.Error != nil { - debugLogReqError(r, "Build Request", false, r.Error) - return r.Error - } - - r.Handlers.Sign.Run(r) - return r.Error -} - -// Send will send the request returning error if errors are encountered. -// -// Send will sign the request prior to sending. All Send Handlers will -// be executed in the order they were set. -func (r *Request) Send() error { - for { - r.Sign() - if r.Error != nil { - return r.Error - } - - if aws.BoolValue(r.Retryable) { - if r.Config.LogLevel.Matches(aws.LogDebugWithRequestRetries) { - r.Config.Logger.Log(fmt.Sprintf("DEBUG: Retrying Request %s/%s, attempt %d", - r.ClientInfo.ServiceName, r.Operation.Name, r.RetryCount)) - } - - // Closing response body. Since we are setting a new request to send off, this - // response will get squashed and leaked. - r.HTTPResponse.Body.Close() - - // Re-seek the body back to the original point in for a retry so that - // send will send the body's contents again in the upcoming request. - r.Body.Seek(r.BodyStart, 0) - r.HTTPRequest.Body = ioutil.NopCloser(r.Body) - } - r.Retryable = nil - - r.Handlers.Send.Run(r) - if r.Error != nil { - err := r.Error - r.Handlers.Retry.Run(r) - r.Handlers.AfterRetry.Run(r) - if r.Error != nil { - debugLogReqError(r, "Send Request", false, r.Error) - return r.Error - } - debugLogReqError(r, "Send Request", true, err) - continue - } - - r.Handlers.UnmarshalMeta.Run(r) - r.Handlers.ValidateResponse.Run(r) - if r.Error != nil { - err := r.Error - r.Handlers.UnmarshalError.Run(r) - r.Handlers.Retry.Run(r) - r.Handlers.AfterRetry.Run(r) - if r.Error != nil { - debugLogReqError(r, "Validate Response", false, r.Error) - return r.Error - } - debugLogReqError(r, "Validate Response", true, err) - continue - } - - r.Handlers.Unmarshal.Run(r) - if r.Error != nil { - err := r.Error - r.Handlers.Retry.Run(r) - r.Handlers.AfterRetry.Run(r) - if r.Error != nil { - debugLogReqError(r, "Unmarshal Response", false, r.Error) - return r.Error - } - debugLogReqError(r, "Unmarshal Response", true, err) - continue - } - - break - } - - return nil -} - -// AddToUserAgent adds the string to the end of the request's current user agent. -func AddToUserAgent(r *Request, s string) { - curUA := r.HTTPRequest.Header.Get("User-Agent") - if len(curUA) > 0 { - s = curUA + " " + s - } - r.HTTPRequest.Header.Set("User-Agent", s) -} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/request_pagination.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/request_pagination.go deleted file mode 100644 index 2939ec473f..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/request_pagination.go +++ /dev/null @@ -1,104 +0,0 @@ -package request - -import ( - "reflect" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/awsutil" -) - -//type Paginater interface { -// HasNextPage() bool -// NextPage() *Request -// EachPage(fn func(data interface{}, isLastPage bool) (shouldContinue bool)) error -//} - -// HasNextPage returns true if this request has more pages of data available. -func (r *Request) HasNextPage() bool { - return len(r.nextPageTokens()) > 0 -} - -// nextPageTokens returns the tokens to use when asking for the next page of -// data. -func (r *Request) nextPageTokens() []interface{} { - if r.Operation.Paginator == nil { - return nil - } - - if r.Operation.TruncationToken != "" { - tr, _ := awsutil.ValuesAtPath(r.Data, r.Operation.TruncationToken) - if len(tr) == 0 { - return nil - } - - switch v := tr[0].(type) { - case *bool: - if !aws.BoolValue(v) { - return nil - } - case bool: - if v == false { - return nil - } - } - } - - tokens := []interface{}{} - tokenAdded := false - for _, outToken := range r.Operation.OutputTokens { - v, _ := awsutil.ValuesAtPath(r.Data, outToken) - if len(v) > 0 { - tokens = append(tokens, v[0]) - tokenAdded = true - } else { - tokens = append(tokens, nil) - } - } - if !tokenAdded { - return nil - } - - return tokens -} - -// NextPage returns a new Request that can be executed to return the next -// page of result data. Call .Send() on this request to execute it. -func (r *Request) NextPage() *Request { - tokens := r.nextPageTokens() - if len(tokens) == 0 { - return nil - } - - data := reflect.New(reflect.TypeOf(r.Data).Elem()).Interface() - nr := New(r.Config, r.ClientInfo, r.Handlers, r.Retryer, r.Operation, awsutil.CopyOf(r.Params), data) - for i, intok := range nr.Operation.InputTokens { - awsutil.SetValueAtPath(nr.Params, intok, tokens[i]) - } - return nr -} - -// EachPage iterates over each page of a paginated request object. The fn -// parameter should be a function with the following sample signature: -// -// func(page *T, lastPage bool) bool { -// return true // return false to stop iterating -// } -// -// Where "T" is the structure type matching the output structure of the given -// operation. For example, a request object generated by -// DynamoDB.ListTablesRequest() would expect to see dynamodb.ListTablesOutput -// as the structure "T". The lastPage value represents whether the page is -// the last page of data or not. The return value of this function should -// return true to keep iterating or false to stop. -func (r *Request) EachPage(fn func(data interface{}, isLastPage bool) (shouldContinue bool)) error { - for page := r; page != nil; page = page.NextPage() { - if err := page.Send(); err != nil { - return err - } - if getNextPage := fn(page.Data, !page.HasNextPage()); !getNextPage { - return page.Error - } - } - - return nil -} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/retryer.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/retryer.go deleted file mode 100644 index ab6fff5ac8..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/request/retryer.go +++ /dev/null @@ -1,82 +0,0 @@ -package request - -import ( - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/awserr" -) - -// Retryer is an interface to control retry logic for a given service. -// The default implementation used by most services is the service.DefaultRetryer -// structure, which contains basic retry logic using exponential backoff. -type Retryer interface { - RetryRules(*Request) time.Duration - ShouldRetry(*Request) bool - MaxRetries() int -} - -// WithRetryer sets a config Retryer value to the given Config returning it -// for chaining. -func WithRetryer(cfg *aws.Config, retryer Retryer) *aws.Config { - cfg.Retryer = retryer - return cfg -} - -// retryableCodes is a collection of service response codes which are retry-able -// without any further action. -var retryableCodes = map[string]struct{}{ - "RequestError": {}, - "RequestTimeout": {}, - "ProvisionedThroughputExceededException": {}, - "Throttling": {}, - "ThrottlingException": {}, - "RequestLimitExceeded": {}, - "RequestThrottled": {}, - "LimitExceededException": {}, // Deleting 10+ DynamoDb tables at once - "TooManyRequestsException": {}, // Lambda functions -} - -// credsExpiredCodes is a collection of error codes which signify the credentials -// need to be refreshed. Expired tokens require refreshing of credentials, and -// resigning before the request can be retried. -var credsExpiredCodes = map[string]struct{}{ - "ExpiredToken": {}, - "ExpiredTokenException": {}, - "RequestExpired": {}, // EC2 Only -} - -func isCodeRetryable(code string) bool { - if _, ok := retryableCodes[code]; ok { - return true - } - - return isCodeExpiredCreds(code) -} - -func isCodeExpiredCreds(code string) bool { - _, ok := credsExpiredCodes[code] - return ok -} - -// IsErrorRetryable returns whether the error is retryable, based on its Code. -// Returns false if the request has no Error set. -func (r *Request) IsErrorRetryable() bool { - if r.Error != nil { - if err, ok := r.Error.(awserr.Error); ok { - return isCodeRetryable(err.Code()) - } - } - return false -} - -// IsErrorExpired returns whether the error code is a credential expiry error. -// Returns false if the request has no Error set. -func (r *Request) IsErrorExpired() bool { - if r.Error != nil { - if err, ok := r.Error.(awserr.Error); ok { - return isCodeExpiredCreds(err.Code()) - } - } - return false -} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/types.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/types.go deleted file mode 100644 index 0f067c57f4..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/types.go +++ /dev/null @@ -1,88 +0,0 @@ -package aws - -import ( - "io" - "sync" -) - -// ReadSeekCloser wraps a io.Reader returning a ReaderSeekerCloser -func ReadSeekCloser(r io.Reader) ReaderSeekerCloser { - return ReaderSeekerCloser{r} -} - -// ReaderSeekerCloser represents a reader that can also delegate io.Seeker and -// io.Closer interfaces to the underlying object if they are available. -type ReaderSeekerCloser struct { - r io.Reader -} - -// Read reads from the reader up to size of p. The number of bytes read, and -// error if it occurred will be returned. -// -// If the reader is not an io.Reader zero bytes read, and nil error will be returned. -// -// Performs the same functionality as io.Reader Read -func (r ReaderSeekerCloser) Read(p []byte) (int, error) { - switch t := r.r.(type) { - case io.Reader: - return t.Read(p) - } - return 0, nil -} - -// Seek sets the offset for the next Read to offset, interpreted according to -// whence: 0 means relative to the origin of the file, 1 means relative to the -// current offset, and 2 means relative to the end. Seek returns the new offset -// and an error, if any. -// -// If the ReaderSeekerCloser is not an io.Seeker nothing will be done. -func (r ReaderSeekerCloser) Seek(offset int64, whence int) (int64, error) { - switch t := r.r.(type) { - case io.Seeker: - return t.Seek(offset, whence) - } - return int64(0), nil -} - -// Close closes the ReaderSeekerCloser. -// -// If the ReaderSeekerCloser is not an io.Closer nothing will be done. -func (r ReaderSeekerCloser) Close() error { - switch t := r.r.(type) { - case io.Closer: - return t.Close() - } - return nil -} - -// A WriteAtBuffer provides a in memory buffer supporting the io.WriterAt interface -// Can be used with the s3manager.Downloader to download content to a buffer -// in memory. Safe to use concurrently. -type WriteAtBuffer struct { - buf []byte - m sync.Mutex -} - -// WriteAt writes a slice of bytes to a buffer starting at the position provided -// The number of bytes written will be returned, or error. Can overwrite previous -// written slices if the write ats overlap. -func (b *WriteAtBuffer) WriteAt(p []byte, pos int64) (n int, err error) { - b.m.Lock() - defer b.m.Unlock() - - expLen := pos + int64(len(p)) - if int64(len(b.buf)) < expLen { - newBuf := make([]byte, expLen) - copy(newBuf, b.buf) - b.buf = newBuf - } - copy(b.buf[pos:], p) - return len(p), nil -} - -// Bytes returns a slice of bytes written to the buffer. -func (b *WriteAtBuffer) Bytes() []byte { - b.m.Lock() - defer b.m.Unlock() - return b.buf[:len(b.buf):len(b.buf)] -} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/version.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/version.go deleted file mode 100644 index 669da2d695..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/aws/version.go +++ /dev/null @@ -1,8 +0,0 @@ -// Package aws provides core functionality for making requests to AWS services. -package aws - -// SDKName is the name of this AWS SDK -const SDKName = "aws-sdk-go" - -// SDKVersion is the version of this SDK -const SDKVersion = "1.1.7" diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/build.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/build.go deleted file mode 100644 index 5469edb60b..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/build.go +++ /dev/null @@ -1,257 +0,0 @@ -// Package rest provides RESTful serialization of AWS requests and responses. -package rest - -import ( - "bytes" - "encoding/base64" - "fmt" - "io" - "net/http" - "net/url" - "path" - "reflect" - "strconv" - "strings" - "time" - - "github.com/aws/aws-sdk-go/aws/awserr" - "github.com/aws/aws-sdk-go/aws/request" -) - -// RFC822 returns an RFC822 formatted timestamp for AWS protocols -const RFC822 = "Mon, 2 Jan 2006 15:04:05 GMT" - -// Whether the byte value can be sent without escaping in AWS URLs -var noEscape [256]bool - -var errValueNotSet = fmt.Errorf("value not set") - -func init() { - for i := 0; i < len(noEscape); i++ { - // AWS expects every character except these to be escaped - noEscape[i] = (i >= 'A' && i <= 'Z') || - (i >= 'a' && i <= 'z') || - (i >= '0' && i <= '9') || - i == '-' || - i == '.' || - i == '_' || - i == '~' - } -} - -// BuildHandler is a named request handler for building rest protocol requests -var BuildHandler = request.NamedHandler{Name: "awssdk.rest.Build", Fn: Build} - -// Build builds the REST component of a service request. -func Build(r *request.Request) { - if r.ParamsFilled() { - v := reflect.ValueOf(r.Params).Elem() - buildLocationElements(r, v) - buildBody(r, v) - } -} - -func buildLocationElements(r *request.Request, v reflect.Value) { - query := r.HTTPRequest.URL.Query() - - for i := 0; i < v.NumField(); i++ { - m := v.Field(i) - if n := v.Type().Field(i).Name; n[0:1] == strings.ToLower(n[0:1]) { - continue - } - - if m.IsValid() { - field := v.Type().Field(i) - name := field.Tag.Get("locationName") - if name == "" { - name = field.Name - } - if m.Kind() == reflect.Ptr { - m = m.Elem() - } - if !m.IsValid() { - continue - } - - var err error - switch field.Tag.Get("location") { - case "headers": // header maps - err = buildHeaderMap(&r.HTTPRequest.Header, m, field.Tag.Get("locationName")) - case "header": - err = buildHeader(&r.HTTPRequest.Header, m, name) - case "uri": - err = buildURI(r.HTTPRequest.URL, m, name) - case "querystring": - err = buildQueryString(query, m, name) - } - r.Error = err - } - if r.Error != nil { - return - } - } - - r.HTTPRequest.URL.RawQuery = query.Encode() - updatePath(r.HTTPRequest.URL, r.HTTPRequest.URL.Path) -} - -func buildBody(r *request.Request, v reflect.Value) { - if field, ok := v.Type().FieldByName("_"); ok { - if payloadName := field.Tag.Get("payload"); payloadName != "" { - pfield, _ := v.Type().FieldByName(payloadName) - if ptag := pfield.Tag.Get("type"); ptag != "" && ptag != "structure" { - payload := reflect.Indirect(v.FieldByName(payloadName)) - if payload.IsValid() && payload.Interface() != nil { - switch reader := payload.Interface().(type) { - case io.ReadSeeker: - r.SetReaderBody(reader) - case []byte: - r.SetBufferBody(reader) - case string: - r.SetStringBody(reader) - default: - r.Error = awserr.New("SerializationError", - "failed to encode REST request", - fmt.Errorf("unknown payload type %s", payload.Type())) - } - } - } - } - } -} - -func buildHeader(header *http.Header, v reflect.Value, name string) error { - str, err := convertType(v) - if err == errValueNotSet { - return nil - } else if err != nil { - return awserr.New("SerializationError", "failed to encode REST request", err) - } - - header.Add(name, str) - - return nil -} - -func buildHeaderMap(header *http.Header, v reflect.Value, prefix string) error { - for _, key := range v.MapKeys() { - str, err := convertType(v.MapIndex(key)) - if err == errValueNotSet { - continue - } else if err != nil { - return awserr.New("SerializationError", "failed to encode REST request", err) - - } - - header.Add(prefix+key.String(), str) - } - return nil -} - -func buildURI(u *url.URL, v reflect.Value, name string) error { - value, err := convertType(v) - if err == errValueNotSet { - return nil - } else if err != nil { - return awserr.New("SerializationError", "failed to encode REST request", err) - } - - uri := u.Path - uri = strings.Replace(uri, "{"+name+"}", EscapePath(value, true), -1) - uri = strings.Replace(uri, "{"+name+"+}", EscapePath(value, false), -1) - u.Path = uri - - return nil -} - -func buildQueryString(query url.Values, v reflect.Value, name string) error { - switch value := v.Interface().(type) { - case []*string: - for _, item := range value { - query.Add(name, *item) - } - case map[string]*string: - for key, item := range value { - query.Add(key, *item) - } - case map[string][]*string: - for key, items := range value { - for _, item := range items { - query.Add(key, *item) - } - } - default: - str, err := convertType(v) - if err == errValueNotSet { - return nil - } else if err != nil { - return awserr.New("SerializationError", "failed to encode REST request", err) - } - query.Set(name, str) - } - - return nil -} - -func updatePath(url *url.URL, urlPath string) { - scheme, query := url.Scheme, url.RawQuery - - hasSlash := strings.HasSuffix(urlPath, "/") - - // clean up path - urlPath = path.Clean(urlPath) - if hasSlash && !strings.HasSuffix(urlPath, "/") { - urlPath += "/" - } - - // get formatted URL minus scheme so we can build this into Opaque - url.Scheme, url.Path, url.RawQuery = "", "", "" - s := url.String() - url.Scheme = scheme - url.RawQuery = query - - // build opaque URI - url.Opaque = s + urlPath -} - -// EscapePath escapes part of a URL path in Amazon style -func EscapePath(path string, encodeSep bool) string { - var buf bytes.Buffer - for i := 0; i < len(path); i++ { - c := path[i] - if noEscape[c] || (c == '/' && !encodeSep) { - buf.WriteByte(c) - } else { - buf.WriteByte('%') - buf.WriteString(strings.ToUpper(strconv.FormatUint(uint64(c), 16))) - } - } - return buf.String() -} - -func convertType(v reflect.Value) (string, error) { - v = reflect.Indirect(v) - if !v.IsValid() { - return "", errValueNotSet - } - - var str string - switch value := v.Interface().(type) { - case string: - str = value - case []byte: - str = base64.StdEncoding.EncodeToString(value) - case bool: - str = strconv.FormatBool(value) - case int64: - str = strconv.FormatInt(value, 10) - case float64: - str = strconv.FormatFloat(value, 'f', -1, 64) - case time.Time: - str = value.UTC().Format(RFC822) - default: - err := fmt.Errorf("Unsupported value for param %v (%s)", v.Interface(), v.Type()) - return "", err - } - return str, nil -} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/payload.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/payload.go deleted file mode 100644 index 4366de2e1e..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/payload.go +++ /dev/null @@ -1,45 +0,0 @@ -package rest - -import "reflect" - -// PayloadMember returns the payload field member of i if there is one, or nil. -func PayloadMember(i interface{}) interface{} { - if i == nil { - return nil - } - - v := reflect.ValueOf(i).Elem() - if !v.IsValid() { - return nil - } - if field, ok := v.Type().FieldByName("_"); ok { - if payloadName := field.Tag.Get("payload"); payloadName != "" { - field, _ := v.Type().FieldByName(payloadName) - if field.Tag.Get("type") != "structure" { - return nil - } - - payload := v.FieldByName(payloadName) - if payload.IsValid() || (payload.Kind() == reflect.Ptr && !payload.IsNil()) { - return payload.Interface() - } - } - } - return nil -} - -// PayloadType returns the type of a payload field member of i if there is one, or "". -func PayloadType(i interface{}) string { - v := reflect.Indirect(reflect.ValueOf(i)) - if !v.IsValid() { - return "" - } - if field, ok := v.Type().FieldByName("_"); ok { - if payloadName := field.Tag.Get("payload"); payloadName != "" { - if member, ok := v.Type().FieldByName(payloadName); ok { - return member.Tag.Get("type") - } - } - } - return "" -} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go deleted file mode 100644 index ba46f5bc9f..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go +++ /dev/null @@ -1,193 +0,0 @@ -package rest - -import ( - "encoding/base64" - "fmt" - "io/ioutil" - "net/http" - "reflect" - "strconv" - "strings" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/awserr" - "github.com/aws/aws-sdk-go/aws/request" -) - -// UnmarshalHandler is a named request handler for unmarshaling rest protocol requests -var UnmarshalHandler = request.NamedHandler{Name: "awssdk.rest.Unmarshal", Fn: Unmarshal} - -// UnmarshalMetaHandler is a named request handler for unmarshaling rest protocol request metadata -var UnmarshalMetaHandler = request.NamedHandler{Name: "awssdk.rest.UnmarshalMeta", Fn: UnmarshalMeta} - -// Unmarshal unmarshals the REST component of a response in a REST service. -func Unmarshal(r *request.Request) { - if r.DataFilled() { - v := reflect.Indirect(reflect.ValueOf(r.Data)) - unmarshalBody(r, v) - } -} - -// UnmarshalMeta unmarshals the REST metadata of a response in a REST service -func UnmarshalMeta(r *request.Request) { - r.RequestID = r.HTTPResponse.Header.Get("X-Amzn-Requestid") - if r.RequestID == "" { - // Alternative version of request id in the header - r.RequestID = r.HTTPResponse.Header.Get("X-Amz-Request-Id") - } - if r.DataFilled() { - v := reflect.Indirect(reflect.ValueOf(r.Data)) - unmarshalLocationElements(r, v) - } -} - -func unmarshalBody(r *request.Request, v reflect.Value) { - if field, ok := v.Type().FieldByName("_"); ok { - if payloadName := field.Tag.Get("payload"); payloadName != "" { - pfield, _ := v.Type().FieldByName(payloadName) - if ptag := pfield.Tag.Get("type"); ptag != "" && ptag != "structure" { - payload := v.FieldByName(payloadName) - if payload.IsValid() { - switch payload.Interface().(type) { - case []byte: - b, err := ioutil.ReadAll(r.HTTPResponse.Body) - if err != nil { - r.Error = awserr.New("SerializationError", "failed to decode REST response", err) - } else { - payload.Set(reflect.ValueOf(b)) - } - case *string: - b, err := ioutil.ReadAll(r.HTTPResponse.Body) - if err != nil { - r.Error = awserr.New("SerializationError", "failed to decode REST response", err) - } else { - str := string(b) - payload.Set(reflect.ValueOf(&str)) - } - default: - switch payload.Type().String() { - case "io.ReadSeeker": - payload.Set(reflect.ValueOf(aws.ReadSeekCloser(r.HTTPResponse.Body))) - case "aws.ReadSeekCloser", "io.ReadCloser": - payload.Set(reflect.ValueOf(r.HTTPResponse.Body)) - default: - r.Error = awserr.New("SerializationError", - "failed to decode REST response", - fmt.Errorf("unknown payload type %s", payload.Type())) - } - } - } - } - } - } -} - -func unmarshalLocationElements(r *request.Request, v reflect.Value) { - for i := 0; i < v.NumField(); i++ { - m, field := v.Field(i), v.Type().Field(i) - if n := field.Name; n[0:1] == strings.ToLower(n[0:1]) { - continue - } - - if m.IsValid() { - name := field.Tag.Get("locationName") - if name == "" { - name = field.Name - } - - switch field.Tag.Get("location") { - case "statusCode": - unmarshalStatusCode(m, r.HTTPResponse.StatusCode) - case "header": - err := unmarshalHeader(m, r.HTTPResponse.Header.Get(name)) - if err != nil { - r.Error = awserr.New("SerializationError", "failed to decode REST response", err) - break - } - case "headers": - prefix := field.Tag.Get("locationName") - err := unmarshalHeaderMap(m, r.HTTPResponse.Header, prefix) - if err != nil { - r.Error = awserr.New("SerializationError", "failed to decode REST response", err) - break - } - } - } - if r.Error != nil { - return - } - } -} - -func unmarshalStatusCode(v reflect.Value, statusCode int) { - if !v.IsValid() { - return - } - - switch v.Interface().(type) { - case *int64: - s := int64(statusCode) - v.Set(reflect.ValueOf(&s)) - } -} - -func unmarshalHeaderMap(r reflect.Value, headers http.Header, prefix string) error { - switch r.Interface().(type) { - case map[string]*string: // we only support string map value types - out := map[string]*string{} - for k, v := range headers { - k = http.CanonicalHeaderKey(k) - if strings.HasPrefix(strings.ToLower(k), strings.ToLower(prefix)) { - out[k[len(prefix):]] = &v[0] - } - } - r.Set(reflect.ValueOf(out)) - } - return nil -} - -func unmarshalHeader(v reflect.Value, header string) error { - if !v.IsValid() || (header == "" && v.Elem().Kind() != reflect.String) { - return nil - } - - switch v.Interface().(type) { - case *string: - v.Set(reflect.ValueOf(&header)) - case []byte: - b, err := base64.StdEncoding.DecodeString(header) - if err != nil { - return err - } - v.Set(reflect.ValueOf(&b)) - case *bool: - b, err := strconv.ParseBool(header) - if err != nil { - return err - } - v.Set(reflect.ValueOf(&b)) - case *int64: - i, err := strconv.ParseInt(header, 10, 64) - if err != nil { - return err - } - v.Set(reflect.ValueOf(&i)) - case *float64: - f, err := strconv.ParseFloat(header, 64) - if err != nil { - return err - } - v.Set(reflect.ValueOf(&f)) - case *time.Time: - t, err := time.Parse(RFC822, header) - if err != nil { - return err - } - v.Set(reflect.ValueOf(&t)) - default: - err := fmt.Errorf("Unsupported value for param %v (%s)", v.Interface(), v.Type()) - return err - } - return nil -} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/signer/v4/header_rules.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/signer/v4/header_rules.go deleted file mode 100644 index 244c86da05..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/signer/v4/header_rules.go +++ /dev/null @@ -1,82 +0,0 @@ -package v4 - -import ( - "net/http" - "strings" -) - -// validator houses a set of rule needed for validation of a -// string value -type rules []rule - -// rule interface allows for more flexible rules and just simply -// checks whether or not a value adheres to that rule -type rule interface { - IsValid(value string) bool -} - -// IsValid will iterate through all rules and see if any rules -// apply to the value and supports nested rules -func (r rules) IsValid(value string) bool { - for _, rule := range r { - if rule.IsValid(value) { - return true - } - } - return false -} - -// mapRule generic rule for maps -type mapRule map[string]struct{} - -// IsValid for the map rule satisfies whether it exists in the map -func (m mapRule) IsValid(value string) bool { - _, ok := m[value] - return ok -} - -// whitelist is a generic rule for whitelisting -type whitelist struct { - rule -} - -// IsValid for whitelist checks if the value is within the whitelist -func (w whitelist) IsValid(value string) bool { - return w.rule.IsValid(value) -} - -// blacklist is a generic rule for blacklisting -type blacklist struct { - rule -} - -// IsValid for whitelist checks if the value is within the whitelist -func (b blacklist) IsValid(value string) bool { - return !b.rule.IsValid(value) -} - -type patterns []string - -// IsValid for patterns checks each pattern and returns if a match has -// been found -func (p patterns) IsValid(value string) bool { - for _, pattern := range p { - if strings.HasPrefix(http.CanonicalHeaderKey(value), pattern) { - return true - } - } - return false -} - -// inclusiveRules rules allow for rules to depend on one another -type inclusiveRules []rule - -// IsValid will return true if all rules are true -func (r inclusiveRules) IsValid(value string) bool { - for _, rule := range r { - if !rule.IsValid(value) { - return false - } - } - return true -} diff --git a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/signer/v4/v4.go b/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/signer/v4/v4.go deleted file mode 100644 index 14b0c66161..0000000000 --- a/Godeps/_workspace/src/github.com/aws/aws-sdk-go/private/signer/v4/v4.go +++ /dev/null @@ -1,438 +0,0 @@ -// Package v4 implements signing for AWS V4 signer -package v4 - -import ( - "crypto/hmac" - "crypto/sha256" - "encoding/hex" - "fmt" - "io" - "net/http" - "net/url" - "sort" - "strconv" - "strings" - "time" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/credentials" - "github.com/aws/aws-sdk-go/aws/request" - "github.com/aws/aws-sdk-go/private/protocol/rest" -) - -const ( - authHeaderPrefix = "AWS4-HMAC-SHA256" - timeFormat = "20060102T150405Z" - shortTimeFormat = "20060102" -) - -var ignoredHeaders = rules{ - blacklist{ - mapRule{ - "Content-Length": struct{}{}, - "User-Agent": struct{}{}, - }, - }, -} - -// requiredSignedHeaders is a whitelist for build canonical headers. -var requiredSignedHeaders = rules{ - whitelist{ - mapRule{ - "Cache-Control": struct{}{}, - "Content-Disposition": struct{}{}, - "Content-Encoding": struct{}{}, - "Content-Language": struct{}{}, - "Content-Md5": struct{}{}, - "Content-Type": struct{}{}, - "Expires": struct{}{}, - "If-Match": struct{}{}, - "If-Modified-Since": struct{}{}, - "If-None-Match": struct{}{}, - "If-Unmodified-Since": struct{}{}, - "Range": struct{}{}, - "X-Amz-Acl": struct{}{}, - "X-Amz-Copy-Source": struct{}{}, - "X-Amz-Copy-Source-If-Match": struct{}{}, - "X-Amz-Copy-Source-If-Modified-Since": struct{}{}, - "X-Amz-Copy-Source-If-None-Match": struct{}{}, - "X-Amz-Copy-Source-If-Unmodified-Since": struct{}{}, - "X-Amz-Copy-Source-Range": struct{}{}, - "X-Amz-Copy-Source-Server-Side-Encryption-Customer-Algorithm": struct{}{}, - "X-Amz-Copy-Source-Server-Side-Encryption-Customer-Key": struct{}{}, - "X-Amz-Copy-Source-Server-Side-Encryption-Customer-Key-Md5": struct{}{}, - "X-Amz-Grant-Full-control": struct{}{}, - "X-Amz-Grant-Read": struct{}{}, - "X-Amz-Grant-Read-Acp": struct{}{}, - "X-Amz-Grant-Write": struct{}{}, - "X-Amz-Grant-Write-Acp": struct{}{}, - "X-Amz-Metadata-Directive": struct{}{}, - "X-Amz-Mfa": struct{}{}, - "X-Amz-Request-Payer": struct{}{}, - "X-Amz-Server-Side-Encryption": struct{}{}, - "X-Amz-Server-Side-Encryption-Aws-Kms-Key-Id": struct{}{}, - "X-Amz-Server-Side-Encryption-Customer-Algorithm": struct{}{}, - "X-Amz-Server-Side-Encryption-Customer-Key": struct{}{}, - "X-Amz-Server-Side-Encryption-Customer-Key-Md5": struct{}{}, - "X-Amz-Storage-Class": struct{}{}, - "X-Amz-Website-Redirect-Location": struct{}{}, - }, - }, - patterns{"X-Amz-Meta-"}, -} - -// allowedHoisting is a whitelist for build query headers. The boolean value -// represents whether or not it is a pattern. -var allowedQueryHoisting = inclusiveRules{ - blacklist{requiredSignedHeaders}, - patterns{"X-Amz-"}, -} - -type signer struct { - Request *http.Request - Time time.Time - ExpireTime time.Duration - ServiceName string - Region string - CredValues credentials.Value - Credentials *credentials.Credentials - Query url.Values - Body io.ReadSeeker - Debug aws.LogLevelType - Logger aws.Logger - - isPresign bool - formattedTime string - formattedShortTime string - - signedHeaders string - canonicalHeaders string - canonicalString string - credentialString string - stringToSign string - signature string - authorization string - notHoist bool - signedHeaderVals http.Header -} - -// Sign requests with signature version 4. -// -// Will sign the requests with the service config's Credentials object -// Signing is skipped if the credentials is the credentials.AnonymousCredentials -// object. -func Sign(req *request.Request) { - // If the request does not need to be signed ignore the signing of the - // request if the AnonymousCredentials object is used. - if req.Config.Credentials == credentials.AnonymousCredentials { - return - } - - region := req.ClientInfo.SigningRegion - if region == "" { - region = aws.StringValue(req.Config.Region) - } - - name := req.ClientInfo.SigningName - if name == "" { - name = req.ClientInfo.ServiceName - } - - s := signer{ - Request: req.HTTPRequest, - Time: req.Time, - ExpireTime: req.ExpireTime, - Query: req.HTTPRequest.URL.Query(), - Body: req.Body, - ServiceName: name, - Region: region, - Credentials: req.Config.Credentials, - Debug: req.Config.LogLevel.Value(), - Logger: req.Config.Logger, - notHoist: req.NotHoist, - } - - req.Error = s.sign() - req.SignedHeaderVals = s.signedHeaderVals -} - -func (v4 *signer) sign() error { - if v4.ExpireTime != 0 { - v4.isPresign = true - } - - if v4.isRequestSigned() { - if !v4.Credentials.IsExpired() { - // If the request is already signed, and the credentials have not - // expired yet ignore the signing request. - return nil - } - - // The credentials have expired for this request. The current signing - // is invalid, and needs to be request because the request will fail. - if v4.isPresign { - v4.removePresign() - // Update the request's query string to ensure the values stays in - // sync in the case retrieving the new credentials fails. - v4.Request.URL.RawQuery = v4.Query.Encode() - } - } - - var err error - v4.CredValues, err = v4.Credentials.Get() - if err != nil { - return err - } - - if v4.isPresign { - v4.Query.Set("X-Amz-Algorithm", authHeaderPrefix) - if v4.CredValues.SessionToken != "" { - v4.Query.Set("X-Amz-Security-Token", v4.CredValues.SessionToken) - } else { - v4.Query.Del("X-Amz-Security-Token") - } - } else if v4.CredValues.SessionToken != "" { - v4.Request.Header.Set("X-Amz-Security-Token", v4.CredValues.SessionToken) - } - - v4.build() - - if v4.Debug.Matches(aws.LogDebugWithSigning) { - v4.logSigningInfo() - } - - return nil -} - -const logSignInfoMsg = `DEBUG: Request Signiture: ----[ CANONICAL STRING ]----------------------------- -%s ----[ STRING TO SIGN ]-------------------------------- -%s%s ------------------------------------------------------` -const logSignedURLMsg = ` ----[ SIGNED URL ]------------------------------------ -%s` - -func (v4 *signer) logSigningInfo() { - signedURLMsg := "" - if v4.isPresign { - signedURLMsg = fmt.Sprintf(logSignedURLMsg, v4.Request.URL.String()) - } - msg := fmt.Sprintf(logSignInfoMsg, v4.canonicalString, v4.stringToSign, signedURLMsg) - v4.Logger.Log(msg) -} - -func (v4 *signer) build() { - - v4.buildTime() // no depends - v4.buildCredentialString() // no depends - - unsignedHeaders := v4.Request.Header - if v4.isPresign { - if !v4.notHoist { - urlValues := url.Values{} - urlValues, unsignedHeaders = buildQuery(allowedQueryHoisting, unsignedHeaders) // no depends - for k := range urlValues { - v4.Query[k] = urlValues[k] - } - } - } - - v4.buildCanonicalHeaders(ignoredHeaders, unsignedHeaders) - v4.buildCanonicalString() // depends on canon headers / signed headers - v4.buildStringToSign() // depends on canon string - v4.buildSignature() // depends on string to sign - - if v4.isPresign { - v4.Request.URL.RawQuery += "&X-Amz-Signature=" + v4.signature - } else { - parts := []string{ - authHeaderPrefix + " Credential=" + v4.CredValues.AccessKeyID + "/" + v4.credentialString, - "SignedHeaders=" + v4.signedHeaders, - "Signature=" + v4.signature, - } - v4.Request.Header.Set("Authorization", strings.Join(parts, ", ")) - } -} - -func (v4 *signer) buildTime() { - v4.formattedTime = v4.Time.UTC().Format(timeFormat) - v4.formattedShortTime = v4.Time.UTC().Format(shortTimeFormat) - - if v4.isPresign { - duration := int64(v4.ExpireTime / time.Second) - v4.Query.Set("X-Amz-Date", v4.formattedTime) - v4.Query.Set("X-Amz-Expires", strconv.FormatInt(duration, 10)) - } else { - v4.Request.Header.Set("X-Amz-Date", v4.formattedTime) - } -} - -func (v4 *signer) buildCredentialString() { - v4.credentialString = strings.Join([]string{ - v4.formattedShortTime, - v4.Region, - v4.ServiceName, - "aws4_request", - }, "/") - - if v4.isPresign { - v4.Query.Set("X-Amz-Credential", v4.CredValues.AccessKeyID+"/"+v4.credentialString) - } -} - -func buildQuery(r rule, header http.Header) (url.Values, http.Header) { - query := url.Values{} - unsignedHeaders := http.Header{} - for k, h := range header { - if r.IsValid(k) { - query[k] = h - } else { - unsignedHeaders[k] = h - } - } - - return query, unsignedHeaders -} -func (v4 *signer) buildCanonicalHeaders(r rule, header http.Header) { - var headers []string - headers = append(headers, "host") - for k, v := range header { - canonicalKey := http.CanonicalHeaderKey(k) - if !r.IsValid(canonicalKey) { - continue // ignored header - } - - lowerCaseKey := strings.ToLower(k) - headers = append(headers, lowerCaseKey) - - if v4.signedHeaderVals == nil { - v4.signedHeaderVals = make(http.Header) - } - v4.signedHeaderVals[lowerCaseKey] = v - } - sort.Strings(headers) - - v4.signedHeaders = strings.Join(headers, ";") - - if v4.isPresign { - v4.Query.Set("X-Amz-SignedHeaders", v4.signedHeaders) - } - - headerValues := make([]string, len(headers)) - for i, k := range headers { - if k == "host" { - headerValues[i] = "host:" + v4.Request.URL.Host - } else { - headerValues[i] = k + ":" + - strings.Join(v4.Request.Header[http.CanonicalHeaderKey(k)], ",") - } - } - - v4.canonicalHeaders = strings.Join(headerValues, "\n") -} - -func (v4 *signer) buildCanonicalString() { - v4.Request.URL.RawQuery = strings.Replace(v4.Query.Encode(), "+", "%20", -1) - uri := v4.Request.URL.Opaque - if uri != "" { - uri = "/" + strings.Join(strings.Split(uri, "/")[3:], "/") - } else { - uri = v4.Request.URL.Path - } - if uri == "" { - uri = "/" - } - - if v4.ServiceName != "s3" { - uri = rest.EscapePath(uri, false) - } - - v4.canonicalString = strings.Join([]string{ - v4.Request.Method, - uri, - v4.Request.URL.RawQuery, - v4.canonicalHeaders + "\n", - v4.signedHeaders, - v4.bodyDigest(), - }, "\n") -} - -func (v4 *signer) buildStringToSign() { - v4.stringToSign = strings.Join([]string{ - authHeaderPrefix, - v4.formattedTime, - v4.credentialString, - hex.EncodeToString(makeSha256([]byte(v4.canonicalString))), - }, "\n") -} - -func (v4 *signer) buildSignature() { - secret := v4.CredValues.SecretAccessKey - date := makeHmac([]byte("AWS4"+secret), []byte(v4.formattedShortTime)) - region := makeHmac(date, []byte(v4.Region)) - service := makeHmac(region, []byte(v4.ServiceName)) - credentials := makeHmac(service, []byte("aws4_request")) - signature := makeHmac(credentials, []byte(v4.stringToSign)) - v4.signature = hex.EncodeToString(signature) -} - -func (v4 *signer) bodyDigest() string { - hash := v4.Request.Header.Get("X-Amz-Content-Sha256") - if hash == "" { - if v4.isPresign && v4.ServiceName == "s3" { - hash = "UNSIGNED-PAYLOAD" - } else if v4.Body == nil { - hash = hex.EncodeToString(makeSha256([]byte{})) - } else { - hash = hex.EncodeToString(makeSha256Reader(v4.Body)) - } - v4.Request.Header.Add("X-Amz-Content-Sha256", hash) - } - return hash -} - -// isRequestSigned returns if the request is currently signed or presigned -func (v4 *signer) isRequestSigned() bool { - if v4.isPresign && v4.Query.Get("X-Amz-Signature") != "" { - return true - } - if v4.Request.Header.Get("Authorization") != "" { - return true - } - - return false -} - -// unsign removes signing flags for both signed and presigned requests. -func (v4 *signer) removePresign() { - v4.Query.Del("X-Amz-Algorithm") - v4.Query.Del("X-Amz-Signature") - v4.Query.Del("X-Amz-Security-Token") - v4.Query.Del("X-Amz-Date") - v4.Query.Del("X-Amz-Expires") - v4.Query.Del("X-Amz-Credential") - v4.Query.Del("X-Amz-SignedHeaders") -} - -func makeHmac(key []byte, data []byte) []byte { - hash := hmac.New(sha256.New, key) - hash.Write(data) - return hash.Sum(nil) -} - -func makeSha256(data []byte) []byte { - hash := sha256.New() - hash.Write(data) - return hash.Sum(nil) -} - -func makeSha256Reader(reader io.ReadSeeker) []byte { - hash := sha256.New() - start, _ := reader.Seek(0, 1) - defer reader.Seek(start, 0) - - io.Copy(hash, reader) - return hash.Sum(nil) -} diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/COPYING b/Godeps/_workspace/src/github.com/camlistore/camlistore/COPYING deleted file mode 100644 index d645695673..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/COPYING +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor 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, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/clients/chrome/clip-it-good/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/clients/chrome/clip-it-good/LICENSE deleted file mode 100644 index 055361b34f..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/clients/chrome/clip-it-good/LICENSE +++ /dev/null @@ -1,13 +0,0 @@ -Copyright 2010 Brett Slatkin - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/misc/copyrightifity b/Godeps/_workspace/src/github.com/camlistore/camlistore/misc/copyrightifity deleted file mode 100644 index 14db513c88..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/misc/copyrightifity +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/perl -# -# Copyright 2010 Google Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# -# This script adds copyright headers to files. - -use strict; -my $header = do { local $/; }; -$header =~ s!\s+$!\n!; -my $yyyy = (localtime())[5] + 1900; -$header =~ s/YYYY/$yyyy/ or die; - -unless (@ARGV == 1) { - die "Usage: copyrightify \n"; -} - -my $file = shift; -open(my $fh, $file) or die "Open $file error: $!\n"; -my $source = do { local $/; <$fh> }; -close($fh); -if ($source =~ /Copyright \d\d\d\d/) { - print STDERR "# $file - OK\n"; - exit; -} - -my $newsource = $source; -if ($file =~ /\.(go|java|aidl)$/) { - $header = "/*\n$header*/\n\n"; - $newsource = $header . $source; -} elsif ($file =~ /\.py$/) { - $header = join("", map { "# $_\n" } split(/\n/, $header)); - $newsource = $header . $source; -} else { - die "File type not supported."; -} - - -open(my $fh, ">$file") or die "Open $file error: $!\n"; -print $fh $newsource; -close($fh) or die; - -__END__ -Copyright YYYY The Camlistore Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/pkg/legal/legal.go b/Godeps/_workspace/src/github.com/camlistore/camlistore/pkg/legal/legal.go deleted file mode 100644 index a75283fd6b..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/pkg/legal/legal.go +++ /dev/null @@ -1,50 +0,0 @@ -/* -Copyright 2014 The Camlistore Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package legal provides project-wide storage for compiled-in licenses. -package legal - -var licenses []string - -func init() { - RegisterLicense(` -Copyright 2014 The Camlistore Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -`) -} - -// RegisterLicense stores the license text. -// It doesn't check whether the text was already present. -func RegisterLicense(text string) { - licenses = append(licenses, text) - return -} - -// Licenses returns a slice of the licenses. -func Licenses() []string { - return licenses -} diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/pkg/legal/legalprint/legalprint.go b/Godeps/_workspace/src/github.com/camlistore/camlistore/pkg/legal/legalprint/legalprint.go deleted file mode 100644 index e4a3205a6a..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/pkg/legal/legalprint/legalprint.go +++ /dev/null @@ -1,42 +0,0 @@ -/* -Copyright 2014 The Camlistore Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package legalprint provides a printing helper for the legal package. -package legalprint - -import ( - "flag" - "fmt" - "io" - - "camlistore.org/pkg/legal" -) - -var ( - flagLegal = flag.Bool("legal", false, "show licenses") -) - -// MaybePrint will print the licenses if flagLegal has been set. -// It will return the value of the flagLegal. -func MaybePrint(out io.Writer) bool { - if !*flagLegal { - return false - } - for _, text := range legal.Licenses() { - fmt.Fprintln(out, text) - } - return true -} diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/bazil.org/fuse/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/bazil.org/fuse/LICENSE deleted file mode 100644 index d369cb822a..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/bazil.org/fuse/LICENSE +++ /dev/null @@ -1,93 +0,0 @@ -Copyright (c) 2013, 2014 Tommi Virtanen. -Copyright (c) 2009, 2011, 2012 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. - - - -The following included software components have additional copyright -notices and license terms that may differ from the above. - - -File fuse.go: - -// Adapted from Plan 9 from User Space's src/cmd/9pfuse/fuse.c, -// which carries this notice: -// -// The files in this directory are subject to the following license. -// -// The author of this software is Russ Cox. -// -// Copyright (c) 2006 Russ Cox -// -// Permission to use, copy, modify, and distribute this software for any -// purpose without fee is hereby granted, provided that this entire notice -// is included in all copies of any software which is or includes a copy -// or modification of this software and in all copies of the supporting -// documentation for such software. -// -// THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED -// WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION OR WARRANTY -// OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS SOFTWARE OR ITS -// FITNESS FOR ANY PARTICULAR PURPOSE. - - -File fuse_kernel.go: - -// Derived from FUSE's fuse_kernel.h -/* - This file defines the kernel interface of FUSE - Copyright (C) 2001-2007 Miklos Szeredi - - - This -- and only this -- header file may also be distributed under - the terms of the BSD Licence as follows: - - Copyright (C) 2001-2007 Miklos Szeredi. 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. - - THIS SOFTWARE IS PROVIDED BY AUTHOR 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 AUTHOR 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. -*/ diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/closure/lib/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/closure/lib/LICENSE deleted file mode 100644 index d9a10c0d8e..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/closure/lib/LICENSE +++ /dev/null @@ -1,176 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor 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, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/code.google.com/p/goauth2/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/code.google.com/p/goauth2/LICENSE deleted file mode 100644 index 6765f090b4..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/code.google.com/p/goauth2/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2009 The goauth2 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. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/code.google.com/p/goauth2/PATENTS b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/code.google.com/p/goauth2/PATENTS deleted file mode 100644 index 9e8716353d..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/code.google.com/p/goauth2/PATENTS +++ /dev/null @@ -1,22 +0,0 @@ -Additional IP Rights Grant (Patents) - -"This implementation" means the copyrightable works distributed by -Google as part of the goauth2 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. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/code.google.com/p/leveldb-go/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/code.google.com/p/leveldb-go/LICENSE deleted file mode 100644 index fec05ce129..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/code.google.com/p/leveldb-go/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2011 The LevelDB-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. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/code.google.com/p/snappy-go/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/code.google.com/p/snappy-go/LICENSE deleted file mode 100644 index 6050c10f4c..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/code.google.com/p/snappy-go/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2011 The Snappy-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. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/code.google.com/p/xsrftoken/COPYING b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/code.google.com/p/xsrftoken/COPYING deleted file mode 100644 index d645695673..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/code.google.com/p/xsrftoken/COPYING +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor 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, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/fontawesome/LICENSE.txt b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/fontawesome/LICENSE.txt deleted file mode 100644 index 1066d2f825..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/fontawesome/LICENSE.txt +++ /dev/null @@ -1,4 +0,0 @@ -fonts/*: SIL OFL 1.1 (http://scripts.sil.org/OFL) -css/*: MIT (http://opensource.org/licenses/mit-license.html) - -Details at http://fortawesome.github.io/Font-Awesome/license/ diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/camlistore/lock/COPYING b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/camlistore/lock/COPYING deleted file mode 100644 index d645695673..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/camlistore/lock/COPYING +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor 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, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/exp/dbm/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/exp/dbm/LICENSE deleted file mode 100644 index 65d761bc9f..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/exp/dbm/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2013 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. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/exp/lldb/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/exp/lldb/LICENSE deleted file mode 100644 index 65d761bc9f..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/exp/lldb/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2013 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. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/fileutil/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/fileutil/LICENSE deleted file mode 100644 index 50bbdd2410..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/fileutil/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2014 The fileutil 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 names of the authors nor the names of the -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. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/fileutil/falloc/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/fileutil/falloc/LICENSE deleted file mode 100644 index 1e92e33dd7..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/fileutil/falloc/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2011 CZ.NIC z.s.p.o. 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 CZ.NIC 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. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/fileutil/hdb/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/fileutil/hdb/LICENSE deleted file mode 100644 index 1e92e33dd7..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/fileutil/hdb/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2011 CZ.NIC z.s.p.o. 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 CZ.NIC 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. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/fileutil/storage/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/fileutil/storage/LICENSE deleted file mode 100644 index 1e92e33dd7..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/fileutil/storage/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2011 CZ.NIC z.s.p.o. 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 CZ.NIC 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. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/kv/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/kv/LICENSE deleted file mode 100644 index 65d761bc9f..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/kv/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2013 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. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/mathutil/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/mathutil/LICENSE deleted file mode 100644 index 1e92e33dd7..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/mathutil/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2011 CZ.NIC z.s.p.o. 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 CZ.NIC 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. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/mathutil/mersenne/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/mathutil/mersenne/LICENSE deleted file mode 100644 index 7150ce3e43..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/mathutil/mersenne/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2011 jnml. 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 jnml nor the names of his -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. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/sortutil/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/sortutil/LICENSE deleted file mode 100644 index 6a66aea5ea..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/sortutil/LICENSE +++ /dev/null @@ -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. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/zappy/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/zappy/LICENSE deleted file mode 100644 index 65d761bc9f..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/cznic/zappy/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2013 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. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/davecgh/go-spew/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/davecgh/go-spew/LICENSE deleted file mode 100644 index 2a7cfd2bf6..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/davecgh/go-spew/LICENSE +++ /dev/null @@ -1,13 +0,0 @@ -Copyright (c) 2012-2013 Dave Collins - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/go-sql-driver/mysql/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/go-sql-driver/mysql/LICENSE deleted file mode 100644 index 14e2f777f6..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/go-sql-driver/mysql/LICENSE +++ /dev/null @@ -1,373 +0,0 @@ -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/golang/glog/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/golang/glog/LICENSE deleted file mode 100644 index 37ec93a14f..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/golang/glog/LICENSE +++ /dev/null @@ -1,191 +0,0 @@ -Apache License -Version 2.0, January 2004 -http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, and -distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by the copyright -owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and all other entities -that control, are controlled by, or are under common control with that entity. -For the purposes of this definition, "control" means (i) the power, direct or -indirect, to cause the direction or management of such entity, whether by -contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the -outstanding shares, or (iii) beneficial ownership of such entity. - -"You" (or "Your") shall mean an individual or Legal Entity exercising -permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, including -but not limited to software source code, documentation source, and configuration -files. - -"Object" form shall mean any form resulting from mechanical transformation or -translation of a Source form, including but not limited to compiled object code, -generated documentation, and conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object form, made -available under the License, as indicated by a copyright notice that is included -in or attached to the work (an example is provided in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object form, that -is based on (or derived from) the Work and for which the editorial revisions, -annotations, elaborations, or other modifications represent, as a whole, an -original work of authorship. For the purposes of this License, Derivative Works -shall not include works that remain separable from, or merely link (or bind by -name) to the interfaces of, the Work and Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original version -of the Work and any modifications or additions to that Work or Derivative Works -thereof, that is intentionally submitted to Licensor for inclusion in the Work -by the copyright owner or by an individual or Legal Entity authorized to submit -on behalf of the copyright owner. For the purposes of this definition, -"submitted" means any form of electronic, verbal, or written communication sent -to the Licensor or its representatives, including but not limited to -communication on electronic mailing lists, source code control systems, and -issue tracking systems that are managed by, or on behalf of, the Licensor for -the purpose of discussing and improving the Work, but excluding communication -that is conspicuously marked or otherwise designated in writing by the copyright -owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf -of whom a Contribution has been received by Licensor and subsequently -incorporated within the Work. - -2. Grant of Copyright License. - -Subject to the terms and conditions of this License, each Contributor hereby -grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, -irrevocable copyright license to reproduce, prepare Derivative Works of, -publicly display, publicly perform, sublicense, and distribute the Work and such -Derivative Works in Source or Object form. - -3. Grant of Patent License. - -Subject to the terms and conditions of this License, each Contributor 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, and otherwise transfer the Work, where -such license applies only to those patent claims licensable by such Contributor -that are necessarily infringed by their Contribution(s) alone or by combination -of their Contribution(s) with the Work to which such Contribution(s) was -submitted. If You institute patent litigation against any entity (including a -cross-claim or counterclaim in a lawsuit) alleging that the Work or a -Contribution incorporated within the Work constitutes direct or contributory -patent infringement, then any patent licenses granted to You under this License -for that Work shall terminate as of the date such litigation is filed. - -4. Redistribution. - -You may reproduce and distribute copies of the Work or Derivative Works thereof -in any medium, with or without modifications, and in Source or Object form, -provided that You meet the following conditions: - -You must give any other recipients of the Work or Derivative Works a copy of -this License; and -You must cause any modified files to carry prominent notices stating that You -changed the files; and -You must retain, in the Source form of any Derivative Works that You distribute, -all copyright, patent, trademark, and attribution notices from the Source form -of the Work, excluding those notices that do not pertain to any part of the -Derivative Works; and -If the Work includes a "NOTICE" text file as part of its distribution, then any -Derivative Works that You distribute must include a readable copy of the -attribution notices contained within such NOTICE file, excluding those notices -that do not pertain to any part of the Derivative Works, in at least one of the -following places: within a NOTICE text file distributed as part of the -Derivative Works; within the Source form or documentation, if provided along -with the Derivative Works; or, within a display generated by the Derivative -Works, if and wherever such third-party notices normally appear. The contents of -the NOTICE file are for informational purposes only and do not modify the -License. You may add Your own attribution notices within Derivative Works that -You distribute, alongside or as an addendum to the NOTICE text from the Work, -provided that such additional attribution notices cannot be construed as -modifying the License. -You may add Your own copyright statement to Your modifications and may provide -additional or different license terms and conditions for use, reproduction, or -distribution of Your modifications, or for any such Derivative Works as a whole, -provided Your use, reproduction, and distribution of the Work otherwise complies -with the conditions stated in this License. - -5. Submission of Contributions. - -Unless You explicitly state otherwise, any Contribution intentionally submitted -for inclusion in the Work by You to the Licensor shall be under the terms and -conditions of this License, without any additional terms or conditions. -Notwithstanding the above, nothing herein shall supersede or modify the terms of -any separate license agreement you may have executed with Licensor regarding -such Contributions. - -6. Trademarks. - -This License does not grant permission to use the trade names, trademarks, -service marks, or product names of the Licensor, except as required for -reasonable and customary use in describing the origin of the Work and -reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. - -Unless required by applicable law or agreed to in writing, Licensor provides the -Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, -including, without limitation, any warranties or conditions of TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are -solely responsible for determining the appropriateness of using or -redistributing the Work and assume any risks associated with Your exercise of -permissions under this License. - -8. Limitation of Liability. - -In no event and under no legal theory, whether in tort (including negligence), -contract, or otherwise, unless required by applicable law (such as deliberate -and grossly negligent acts) or agreed to in writing, shall any Contributor be -liable to You for damages, including any direct, indirect, special, incidental, -or consequential damages of any character arising as a result of this License or -out of the use or inability to use the Work (including but not limited to -damages for loss of goodwill, work stoppage, computer failure or malfunction, or -any and all other commercial damages or losses), even if such Contributor has -been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. - -While redistributing the Work or Derivative Works thereof, You may choose to -offer, and charge a fee for, acceptance of support, warranty, indemnity, or -other liability obligations and/or rights consistent with this License. However, -in accepting such obligations, You may act only on Your own behalf and on Your -sole responsibility, not on behalf of any other Contributor, and only if You -agree to indemnify, defend, and hold each Contributor harmless for any liability -incurred by, or claims asserted against, such Contributor by reason of your -accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work - -To apply the Apache License to your work, attach the following boilerplate -notice, with the fields enclosed by brackets "[]" replaced with your own -identifying information. (Don't include the brackets!) The text should be -enclosed in the appropriate comment syntax for the file format. We also -recommend that a file or class name and description of purpose be included on -the same "printed page" as the copyright notice for easier identification within -third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/gorilla/websocket/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/gorilla/websocket/LICENSE deleted file mode 100644 index 09e5be61d7..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/gorilla/websocket/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright (c) 2013, Gorilla web toolkit -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. - -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. \ No newline at end of file diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/lib/pq/LICENSE.md b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/lib/pq/LICENSE.md deleted file mode 100644 index 5773904a30..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/lib/pq/LICENSE.md +++ /dev/null @@ -1,8 +0,0 @@ -Copyright (c) 2011-2013, 'pq' Contributors -Portions Copyright (C) 2011 Blake Mizerany - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/russross/blackfriday/LICENSE.txt b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/russross/blackfriday/LICENSE.txt deleted file mode 100644 index 2885af3602..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/russross/blackfriday/LICENSE.txt +++ /dev/null @@ -1,29 +0,0 @@ -Blackfriday is distributed under the Simplified BSD License: - -> Copyright © 2011 Russ Ross -> 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. -> -> 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. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/rwcarlsen/goexif/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/rwcarlsen/goexif/LICENSE deleted file mode 100644 index aa6250465f..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/github.com/rwcarlsen/goexif/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ - -Copyright (c) 2012, Robert Carlsen & Contributors -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. - -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. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/glitch/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/glitch/LICENSE deleted file mode 100644 index 7efba3b1c6..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/glitch/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -The files in here come from www.glitchthegame.com. - -License here: http://www.glitchthegame.com/public-domain-game-art/#licensing - -All files are provided by Tiny Speck under the Creative Commons CC0 1.0 -Universal License. This is a broadly permissive "No Rights Reserved" license — -you may do what you please with what we've provided. Our intention is to -dedicate these works to the public domain and make them freely available to all, -without restriction. All files are provided AS-IS. Tiny Speck cannot provide any -support to help you bring these assets into your own projects. - -Note: the Glitch logo and trademark are not among the things we are making -available under this license. Only items in the files explicitly included herein -are covered. - -There is no obligation to link or credit the works, but if you do, please link -to glitchthegame.com, our permanent "retirement" site for the game and these -assets. Of course, links/shoutouts to Tiny Speck (tinyspeck.com) and/or Slack -(slack.com) are appreciated. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/golang.org/x/image/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/golang.org/x/image/LICENSE deleted file mode 100644 index 6a66aea5ea..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/golang.org/x/image/LICENSE +++ /dev/null @@ -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. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/golang.org/x/image/PATENTS b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/golang.org/x/image/PATENTS deleted file mode 100644 index 733099041f..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/golang.org/x/image/PATENTS +++ /dev/null @@ -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. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/labix.org/v2/mgo/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/labix.org/v2/mgo/LICENSE deleted file mode 100644 index 770c7672b4..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/labix.org/v2/mgo/LICENSE +++ /dev/null @@ -1,25 +0,0 @@ -mgo - MongoDB driver for Go - -Copyright (c) 2010-2013 - Gustavo Niemeyer - -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. - -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. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/labix.org/v2/mgo/bson/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/labix.org/v2/mgo/bson/LICENSE deleted file mode 100644 index 890326017b..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/labix.org/v2/mgo/bson/LICENSE +++ /dev/null @@ -1,25 +0,0 @@ -BSON library for Go - -Copyright (c) 2010-2012 - Gustavo Niemeyer - -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. - -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. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/react/LICENSE.txt b/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/react/LICENSE.txt deleted file mode 100644 index 261eeb9e9f..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/third_party/react/LICENSE.txt +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor 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, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/vendor/github.com/hjfreyer/taglib-go/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/vendor/github.com/hjfreyer/taglib-go/LICENSE deleted file mode 100644 index 37ec93a14f..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/vendor/github.com/hjfreyer/taglib-go/LICENSE +++ /dev/null @@ -1,191 +0,0 @@ -Apache License -Version 2.0, January 2004 -http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, and -distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by the copyright -owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and all other entities -that control, are controlled by, or are under common control with that entity. -For the purposes of this definition, "control" means (i) the power, direct or -indirect, to cause the direction or management of such entity, whether by -contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the -outstanding shares, or (iii) beneficial ownership of such entity. - -"You" (or "Your") shall mean an individual or Legal Entity exercising -permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, including -but not limited to software source code, documentation source, and configuration -files. - -"Object" form shall mean any form resulting from mechanical transformation or -translation of a Source form, including but not limited to compiled object code, -generated documentation, and conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object form, made -available under the License, as indicated by a copyright notice that is included -in or attached to the work (an example is provided in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object form, that -is based on (or derived from) the Work and for which the editorial revisions, -annotations, elaborations, or other modifications represent, as a whole, an -original work of authorship. For the purposes of this License, Derivative Works -shall not include works that remain separable from, or merely link (or bind by -name) to the interfaces of, the Work and Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original version -of the Work and any modifications or additions to that Work or Derivative Works -thereof, that is intentionally submitted to Licensor for inclusion in the Work -by the copyright owner or by an individual or Legal Entity authorized to submit -on behalf of the copyright owner. For the purposes of this definition, -"submitted" means any form of electronic, verbal, or written communication sent -to the Licensor or its representatives, including but not limited to -communication on electronic mailing lists, source code control systems, and -issue tracking systems that are managed by, or on behalf of, the Licensor for -the purpose of discussing and improving the Work, but excluding communication -that is conspicuously marked or otherwise designated in writing by the copyright -owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf -of whom a Contribution has been received by Licensor and subsequently -incorporated within the Work. - -2. Grant of Copyright License. - -Subject to the terms and conditions of this License, each Contributor hereby -grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, -irrevocable copyright license to reproduce, prepare Derivative Works of, -publicly display, publicly perform, sublicense, and distribute the Work and such -Derivative Works in Source or Object form. - -3. Grant of Patent License. - -Subject to the terms and conditions of this License, each Contributor 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, and otherwise transfer the Work, where -such license applies only to those patent claims licensable by such Contributor -that are necessarily infringed by their Contribution(s) alone or by combination -of their Contribution(s) with the Work to which such Contribution(s) was -submitted. If You institute patent litigation against any entity (including a -cross-claim or counterclaim in a lawsuit) alleging that the Work or a -Contribution incorporated within the Work constitutes direct or contributory -patent infringement, then any patent licenses granted to You under this License -for that Work shall terminate as of the date such litigation is filed. - -4. Redistribution. - -You may reproduce and distribute copies of the Work or Derivative Works thereof -in any medium, with or without modifications, and in Source or Object form, -provided that You meet the following conditions: - -You must give any other recipients of the Work or Derivative Works a copy of -this License; and -You must cause any modified files to carry prominent notices stating that You -changed the files; and -You must retain, in the Source form of any Derivative Works that You distribute, -all copyright, patent, trademark, and attribution notices from the Source form -of the Work, excluding those notices that do not pertain to any part of the -Derivative Works; and -If the Work includes a "NOTICE" text file as part of its distribution, then any -Derivative Works that You distribute must include a readable copy of the -attribution notices contained within such NOTICE file, excluding those notices -that do not pertain to any part of the Derivative Works, in at least one of the -following places: within a NOTICE text file distributed as part of the -Derivative Works; within the Source form or documentation, if provided along -with the Derivative Works; or, within a display generated by the Derivative -Works, if and wherever such third-party notices normally appear. The contents of -the NOTICE file are for informational purposes only and do not modify the -License. You may add Your own attribution notices within Derivative Works that -You distribute, alongside or as an addendum to the NOTICE text from the Work, -provided that such additional attribution notices cannot be construed as -modifying the License. -You may add Your own copyright statement to Your modifications and may provide -additional or different license terms and conditions for use, reproduction, or -distribution of Your modifications, or for any such Derivative Works as a whole, -provided Your use, reproduction, and distribution of the Work otherwise complies -with the conditions stated in this License. - -5. Submission of Contributions. - -Unless You explicitly state otherwise, any Contribution intentionally submitted -for inclusion in the Work by You to the Licensor shall be under the terms and -conditions of this License, without any additional terms or conditions. -Notwithstanding the above, nothing herein shall supersede or modify the terms of -any separate license agreement you may have executed with Licensor regarding -such Contributions. - -6. Trademarks. - -This License does not grant permission to use the trade names, trademarks, -service marks, or product names of the Licensor, except as required for -reasonable and customary use in describing the origin of the Work and -reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. - -Unless required by applicable law or agreed to in writing, Licensor provides the -Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, -including, without limitation, any warranties or conditions of TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are -solely responsible for determining the appropriateness of using or -redistributing the Work and assume any risks associated with Your exercise of -permissions under this License. - -8. Limitation of Liability. - -In no event and under no legal theory, whether in tort (including negligence), -contract, or otherwise, unless required by applicable law (such as deliberate -and grossly negligent acts) or agreed to in writing, shall any Contributor be -liable to You for damages, including any direct, indirect, special, incidental, -or consequential damages of any character arising as a result of this License or -out of the use or inability to use the Work (including but not limited to -damages for loss of goodwill, work stoppage, computer failure or malfunction, or -any and all other commercial damages or losses), even if such Contributor has -been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. - -While redistributing the Work or Derivative Works thereof, You may choose to -offer, and charge a fee for, acceptance of support, warranty, indemnity, or -other liability obligations and/or rights consistent with this License. However, -in accepting such obligations, You may act only on Your own behalf and on Your -sole responsibility, not on behalf of any other Contributor, and only if You -agree to indemnify, defend, and hold each Contributor harmless for any liability -incurred by, or claims asserted against, such Contributor by reason of your -accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work - -To apply the Apache License to your work, attach the following boilerplate -notice, with the fields enclosed by brackets "[]" replaced with your own -identifying information. (Don't include the brackets!) The text should be -enclosed in the appropriate comment syntax for the file format. We also -recommend that a file or class name and description of purpose be included on -the same "printed page" as the copyright notice for easier identification within -third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/vendor/golang.org/x/oauth2/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/vendor/golang.org/x/oauth2/LICENSE deleted file mode 100644 index d02f24fd52..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/vendor/golang.org/x/oauth2/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2009 The oauth2 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. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/vendor/google.golang.org/api/googleapi/internal/uritemplates/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/vendor/google.golang.org/api/googleapi/internal/uritemplates/LICENSE deleted file mode 100644 index de9c88cb65..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/vendor/google.golang.org/api/googleapi/internal/uritemplates/LICENSE +++ /dev/null @@ -1,18 +0,0 @@ -Copyright (c) 2013 Joshua Tacoma - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/vendor/google.golang.org/cloud/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/vendor/google.golang.org/cloud/LICENSE deleted file mode 100644 index a4c5efd822..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/vendor/google.golang.org/cloud/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor 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, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2014 Google Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/vendor/google.golang.org/grpc/LICENSE b/Godeps/_workspace/src/github.com/camlistore/camlistore/vendor/google.golang.org/grpc/LICENSE deleted file mode 100644 index f4988b4507..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/vendor/google.golang.org/grpc/LICENSE +++ /dev/null @@ -1,28 +0,0 @@ -Copyright 2014, Google Inc. -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. diff --git a/Godeps/_workspace/src/github.com/camlistore/camlistore/vendor/google.golang.org/grpc/PATENTS b/Godeps/_workspace/src/github.com/camlistore/camlistore/vendor/google.golang.org/grpc/PATENTS deleted file mode 100644 index 619f9dbfe6..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/camlistore/vendor/google.golang.org/grpc/PATENTS +++ /dev/null @@ -1,22 +0,0 @@ -Additional IP Rights Grant (Patents) - -"This implementation" means the copyrightable works distributed by -Google as part of the GRPC 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 GRPC, 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 GRPC. 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 GRPC or any code incorporated within this -implementation of GRPC 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 GRPC -shall terminate as of the date such litigation is filed. diff --git a/Godeps/_workspace/src/github.com/camlistore/go4/LICENSE b/Godeps/_workspace/src/github.com/camlistore/go4/LICENSE deleted file mode 100644 index 8f71f43fee..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/go4/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor 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, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - diff --git a/Godeps/_workspace/src/github.com/camlistore/go4/legal/legal.go b/Godeps/_workspace/src/github.com/camlistore/go4/legal/legal.go deleted file mode 100644 index de9ae9c858..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/go4/legal/legal.go +++ /dev/null @@ -1,32 +0,0 @@ -/* -Copyright 2014 The Go4 Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package legal provides in-process storage for compiled-in licenses. -package legal - -var licenses []string - -// RegisterLicense stores the license text. -// It doesn't check whether the text was already present. -func RegisterLicense(text string) { - licenses = append(licenses, text) - return -} - -// Licenses returns a slice of the licenses. -func Licenses() []string { - return licenses -} diff --git a/Godeps/_workspace/src/github.com/camlistore/go4/lock/.gitignore b/Godeps/_workspace/src/github.com/camlistore/go4/lock/.gitignore deleted file mode 100644 index b25c15b81f..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/go4/lock/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*~ diff --git a/Godeps/_workspace/src/github.com/camlistore/go4/lock/lock.go b/Godeps/_workspace/src/github.com/camlistore/go4/lock/lock.go deleted file mode 100644 index a9fb802de6..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/go4/lock/lock.go +++ /dev/null @@ -1,186 +0,0 @@ -/* -Copyright 2013 The Go Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package lock is a file locking library. -package lock - -import ( - "encoding/json" - "fmt" - "io" - "os" - "path/filepath" - "sync" -) - -// Lock locks the given file, creating the file if necessary. If the -// file already exists, it must have zero size or an error is returned. -// The lock is an exclusive lock (a write lock), but locked files -// should neither be read from nor written to. Such files should have -// zero size and only exist to co-ordinate ownership across processes. -// -// A nil Closer is returned if an error occurred. Otherwise, close that -// Closer to release the lock. -// -// On Linux, FreeBSD and OSX, a lock has the same semantics as fcntl(2)'s -// advisory locks. In particular, closing any other file descriptor for the -// same file will release the lock prematurely. -// -// Attempting to lock a file that is already locked by the current process -// has undefined behavior. -// -// On other operating systems, lock will fallback to using the presence and -// content of a file named name + '.lock' to implement locking behavior. -func Lock(name string) (io.Closer, error) { - abs, err := filepath.Abs(name) - if err != nil { - return nil, err - } - lockmu.Lock() - defer lockmu.Unlock() - if locked[abs] { - return nil, fmt.Errorf("file %q already locked", abs) - } - - c, err := lockFn(abs) - if err != nil { - return nil, fmt.Errorf("cannot acquire lock: %v", err) - } - locked[abs] = true - return c, nil -} - -var lockFn = lockPortable - -// lockPortable is a portable version not using fcntl. Doesn't handle crashes as gracefully, -// since it can leave stale lock files. -func lockPortable(name string) (io.Closer, error) { - fi, err := os.Stat(name) - if err == nil && fi.Size() > 0 { - st := portableLockStatus(name) - switch st { - case statusLocked: - return nil, fmt.Errorf("file %q already locked", name) - case statusStale: - os.Remove(name) - case statusInvalid: - return nil, fmt.Errorf("can't Lock file %q: has invalid contents", name) - } - } - f, err := os.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_EXCL, 0666) - if err != nil { - return nil, fmt.Errorf("failed to create lock file %s %v", name, err) - } - if err := json.NewEncoder(f).Encode(&pidLockMeta{OwnerPID: os.Getpid()}); err != nil { - return nil, fmt.Errorf("cannot write owner pid: %v", err) - } - return &unlocker{ - f: f, - abs: name, - portable: true, - }, nil -} - -type lockStatus int - -const ( - statusInvalid lockStatus = iota - statusLocked - statusUnlocked - statusStale -) - -type pidLockMeta struct { - OwnerPID int -} - -func portableLockStatus(path string) lockStatus { - f, err := os.Open(path) - if err != nil { - return statusUnlocked - } - defer f.Close() - var meta pidLockMeta - if json.NewDecoder(f).Decode(&meta) != nil { - return statusInvalid - } - if meta.OwnerPID == 0 { - return statusInvalid - } - p, err := os.FindProcess(meta.OwnerPID) - if err != nil { - // e.g. on Windows - return statusStale - } - // On unix, os.FindProcess always is true, so we have to send - // it a signal to see if it's alive. - if signalZero != nil { - if p.Signal(signalZero) != nil { - return statusStale - } - } - return statusLocked -} - -var signalZero os.Signal // nil or set by lock_sigzero.go - -var ( - lockmu sync.Mutex - locked = map[string]bool{} // abs path -> true -) - -type unlocker struct { - portable bool - f *os.File - abs string - // once guards the close method call. - once sync.Once - // err holds the error returned by Close. - err error -} - -func (u *unlocker) Close() error { - u.once.Do(u.close) - return u.err -} - -func (u *unlocker) close() { - lockmu.Lock() - defer lockmu.Unlock() - delete(locked, u.abs) - - if u.portable { - // In the portable lock implementation, it's - // important to close before removing because - // Windows won't allow us to remove an open - // file. - if err := u.f.Close(); err != nil { - u.err = err - } - if err := os.Remove(u.abs); err != nil { - // Note that if both Close and Remove fail, - // we care more about the latter than the former - // so we'll return that error. - u.err = err - } - return - } - // In other implementatioons, it's nice for us to clean up. - // If we do do this, though, it needs to be before the - // u.f.Close below. - os.Remove(u.abs) - u.err = u.f.Close() -} diff --git a/Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_appengine.go b/Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_appengine.go deleted file mode 100644 index ab4cad6ab6..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_appengine.go +++ /dev/null @@ -1,32 +0,0 @@ -// +build appengine - -/* -Copyright 2013 The Go Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package lock - -import ( - "errors" - "io" -) - -func init() { - lockFn = lockAppEngine -} - -func lockAppEngine(name string) (io.Closer, error) { - return nil, errors.New("Lock not available on App Engine") -} diff --git a/Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_darwin_amd64.go b/Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_darwin_amd64.go deleted file mode 100644 index 35f5787bae..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_darwin_amd64.go +++ /dev/null @@ -1,67 +0,0 @@ -// +build darwin,amd64 -// +build !appengine - -/* -Copyright 2013 The Go Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package lock - -import ( - "fmt" - "io" - "os" - "syscall" - "unsafe" -) - -func init() { - lockFn = lockFcntl -} - -func lockFcntl(name string) (io.Closer, error) { - fi, err := os.Stat(name) - if err == nil && fi.Size() > 0 { - return nil, fmt.Errorf("can't Lock file %q: has non-zero size", name) - } - - f, err := os.Create(name) - if err != nil { - return nil, fmt.Errorf("Lock Create of %s failed: %v", name, err) - } - - // This type matches C's "struct flock" defined in /usr/include/sys/fcntl.h. - // TODO: move this into the standard syscall package. - k := struct { - Start uint64 // sizeof(off_t): 8 - Len uint64 // sizeof(off_t): 8 - Pid uint32 // sizeof(pid_t): 4 - Type uint16 // sizeof(short): 2 - Whence uint16 // sizeof(short): 2 - }{ - Type: syscall.F_WRLCK, - Whence: uint16(os.SEEK_SET), - Start: 0, - Len: 0, // 0 means to lock the entire file. - Pid: uint32(os.Getpid()), - } - - _, _, errno := syscall.Syscall(syscall.SYS_FCNTL, f.Fd(), uintptr(syscall.F_SETLK), uintptr(unsafe.Pointer(&k))) - if errno != 0 { - f.Close() - return nil, errno - } - return &unlocker{f: f, abs: name}, nil -} diff --git a/Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_freebsd.go b/Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_freebsd.go deleted file mode 100644 index ee2767a0a6..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_freebsd.go +++ /dev/null @@ -1,66 +0,0 @@ -/* -Copyright 2013 The Go Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package lock - -import ( - "fmt" - "io" - "os" - "syscall" - "unsafe" -) - -func init() { - lockFn = lockFcntl -} - -func lockFcntl(name string) (io.Closer, error) { - fi, err := os.Stat(name) - if err == nil && fi.Size() > 0 { - return nil, fmt.Errorf("can't Lock file %q: has non-zero size", name) - } - - f, err := os.Create(name) - if err != nil { - return nil, err - } - - // This type matches C's "struct flock" defined in /usr/include/fcntl.h. - // TODO: move this into the standard syscall package. - k := struct { - Start int64 /* off_t starting offset */ - Len int64 /* off_t len = 0 means until end of file */ - Pid int32 /* pid_t lock owner */ - Type int16 /* short lock type: read/write, etc. */ - Whence int16 /* short type of l_start */ - Sysid int32 /* int remote system id or zero for local */ - }{ - Start: 0, - Len: 0, // 0 means to lock the entire file. - Pid: int32(os.Getpid()), - Type: syscall.F_WRLCK, - Whence: int16(os.SEEK_SET), - Sysid: 0, - } - - _, _, errno := syscall.Syscall(syscall.SYS_FCNTL, f.Fd(), uintptr(syscall.F_SETLK), uintptr(unsafe.Pointer(&k))) - if errno != 0 { - f.Close() - return nil, errno - } - return &unlocker{f: f, abs: name}, nil -} diff --git a/Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_linux_amd64.go b/Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_linux_amd64.go deleted file mode 100644 index 08b3aae921..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_linux_amd64.go +++ /dev/null @@ -1,67 +0,0 @@ -// +build linux,amd64 -// +build !appengine - -/* -Copyright 2013 The Go Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package lock - -import ( - "fmt" - "io" - "os" - "syscall" - "unsafe" -) - -func init() { - lockFn = lockFcntl -} - -func lockFcntl(name string) (io.Closer, error) { - fi, err := os.Stat(name) - if err == nil && fi.Size() > 0 { - return nil, fmt.Errorf("can't Lock file %q: has non-zero size", name) - } - - f, err := os.Create(name) - if err != nil { - return nil, err - } - - // This type matches C's "struct flock" defined in /usr/include/bits/fcntl.h. - // TODO: move this into the standard syscall package. - k := struct { - Type uint32 - Whence uint32 - Start uint64 - Len uint64 - Pid uint32 - }{ - Type: syscall.F_WRLCK, - Whence: uint32(os.SEEK_SET), - Start: 0, - Len: 0, // 0 means to lock the entire file. - Pid: uint32(os.Getpid()), - } - - _, _, errno := syscall.Syscall(syscall.SYS_FCNTL, f.Fd(), uintptr(syscall.F_SETLK), uintptr(unsafe.Pointer(&k))) - if errno != 0 { - f.Close() - return nil, errno - } - return &unlocker{f: f, abs: name}, nil -} diff --git a/Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_linux_arm.go b/Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_linux_arm.go deleted file mode 100644 index ebf87bd3e7..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_linux_arm.go +++ /dev/null @@ -1,68 +0,0 @@ -// +build linux,arm -// +build !appengine - -/* -Copyright 2013 The Go Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package lock - -import ( - "fmt" - "io" - "os" - "syscall" - "unsafe" -) - -func init() { - lockFn = lockFcntl -} - -func lockFcntl(name string) (io.Closer, error) { - fi, err := os.Stat(name) - if err == nil && fi.Size() > 0 { - return nil, fmt.Errorf("can't Lock file %q: has non-zero size", name) - } - - f, err := os.Create(name) - if err != nil { - return nil, err - } - - // This type matches C's "struct flock" defined in /usr/include/bits/fcntl.h. - // TODO: move this into the standard syscall package. - k := struct { - Type uint16 - Whence uint16 - Start uint32 - Len uint32 - Pid uint32 - }{ - Type: syscall.F_WRLCK, - Whence: uint16(os.SEEK_SET), - Start: 0, - Len: 0, // 0 means to lock the entire file. - Pid: uint32(os.Getpid()), - } - - const F_SETLK = 6 // actual value. syscall package is wrong: golang.org/issue/7059 - _, _, errno := syscall.Syscall(syscall.SYS_FCNTL, f.Fd(), uintptr(F_SETLK), uintptr(unsafe.Pointer(&k))) - if errno != 0 { - f.Close() - return nil, errno - } - return &unlocker{f: f, abs: name}, nil -} diff --git a/Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_plan9.go b/Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_plan9.go deleted file mode 100644 index d841c27d70..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_plan9.go +++ /dev/null @@ -1,41 +0,0 @@ -/* -Copyright 2013 The Go Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package lock - -import ( - "fmt" - "io" - "os" -) - -func init() { - lockFn = lockPlan9 -} - -func lockPlan9(name string) (io.Closer, error) { - fi, err := os.Stat(name) - if err == nil && fi.Size() > 0 { - return nil, fmt.Errorf("can't Lock file %q: has non-zero size", name) - } - - f, err := os.OpenFile(name, os.O_RDWR|os.O_CREATE, os.ModeExclusive|0644) - if err != nil { - return nil, fmt.Errorf("Lock Create of %s failed: %v", name, err) - } - - return &unlocker{f: f, abs: name}, nil -} diff --git a/Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_sigzero.go b/Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_sigzero.go deleted file mode 100644 index fd3ba2db19..0000000000 --- a/Godeps/_workspace/src/github.com/camlistore/go4/lock/lock_sigzero.go +++ /dev/null @@ -1,26 +0,0 @@ -// +build !appengine -// +build linux darwin freebsd openbsd netbsd dragonfly - -/* -Copyright 2013 The Go Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package lock - -import "syscall" - -func init() { - signalZero = syscall.Signal(0) -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/LICENSE b/Godeps/_workspace/src/github.com/containernetworking/cni/LICENSE deleted file mode 100644 index 8f71f43fee..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor 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, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/args.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/args.go deleted file mode 100644 index be28ba621f..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/args.go +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package invoke - -import ( - "os" - "strings" -) - -type CNIArgs interface { - // For use with os/exec; i.e., return nil to inherit the - // environment from this process - AsEnv() []string -} - -type inherited struct{} - -var inheritArgsFromEnv inherited - -func (_ *inherited) AsEnv() []string { - return nil -} - -func ArgsFromEnv() CNIArgs { - return &inheritArgsFromEnv -} - -type Args struct { - Command string - ContainerID string - NetNS string - PluginArgs [][2]string - PluginArgsStr string - IfName string - Path string -} - -func (args *Args) AsEnv() []string { - env := os.Environ() - pluginArgsStr := args.PluginArgsStr - if pluginArgsStr == "" { - pluginArgsStr = stringify(args.PluginArgs) - } - - env = append(env, - "CNI_COMMAND="+args.Command, - "CNI_CONTAINERID="+args.ContainerID, - "CNI_NETNS="+args.NetNS, - "CNI_ARGS="+pluginArgsStr, - "CNI_IFNAME="+args.IfName, - "CNI_PATH="+args.Path) - return env -} - -// taken from rkt/networking/net_plugin.go -func stringify(pluginArgs [][2]string) string { - entries := make([]string, len(pluginArgs)) - - for i, kv := range pluginArgs { - entries[i] = strings.Join(kv[:], "=") - } - - return strings.Join(entries, ";") -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/delegate.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/delegate.go deleted file mode 100644 index ddf1d17274..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/delegate.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2016 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package invoke - -import ( - "fmt" - "os" - "strings" - - "github.com/containernetworking/cni/pkg/types" -) - -func DelegateAdd(delegatePlugin string, netconf []byte) (*types.Result, error) { - if os.Getenv("CNI_COMMAND") != "ADD" { - return nil, fmt.Errorf("CNI_COMMAND is not ADD") - } - - paths := strings.Split(os.Getenv("CNI_PATH"), ":") - - pluginPath, err := FindInPath(delegatePlugin, paths) - if err != nil { - return nil, err - } - - return ExecPluginWithResult(pluginPath, netconf, ArgsFromEnv()) -} - -func DelegateDel(delegatePlugin string, netconf []byte) error { - if os.Getenv("CNI_COMMAND") != "DEL" { - return fmt.Errorf("CNI_COMMAND is not DEL") - } - - paths := strings.Split(os.Getenv("CNI_PATH"), ":") - - pluginPath, err := FindInPath(delegatePlugin, paths) - if err != nil { - return err - } - - return ExecPluginWithoutResult(pluginPath, netconf, ArgsFromEnv()) -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/exec.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/exec.go deleted file mode 100644 index a85eede66a..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/exec.go +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package invoke - -import ( - "bytes" - "encoding/json" - "fmt" - "os" - "os/exec" - - "github.com/containernetworking/cni/pkg/types" -) - -func pluginErr(err error, output []byte) error { - if _, ok := err.(*exec.ExitError); ok { - emsg := types.Error{} - if perr := json.Unmarshal(output, &emsg); perr != nil { - return fmt.Errorf("netplugin failed but error parsing its diagnostic message %q: %v", string(output), perr) - } - details := "" - if emsg.Details != "" { - details = fmt.Sprintf("; %v", emsg.Details) - } - return fmt.Errorf("%v%v", emsg.Msg, details) - } - - return err -} - -func ExecPluginWithResult(pluginPath string, netconf []byte, args CNIArgs) (*types.Result, error) { - stdoutBytes, err := execPlugin(pluginPath, netconf, args) - if err != nil { - return nil, err - } - - res := &types.Result{} - err = json.Unmarshal(stdoutBytes, res) - return res, err -} - -func ExecPluginWithoutResult(pluginPath string, netconf []byte, args CNIArgs) error { - _, err := execPlugin(pluginPath, netconf, args) - return err -} - -func execPlugin(pluginPath string, netconf []byte, args CNIArgs) ([]byte, error) { - stdout := &bytes.Buffer{} - - c := exec.Cmd{ - Env: args.AsEnv(), - Path: pluginPath, - Args: []string{pluginPath}, - Stdin: bytes.NewBuffer(netconf), - Stdout: stdout, - Stderr: os.Stderr, - } - if err := c.Run(); err != nil { - return nil, pluginErr(err, stdout.Bytes()) - } - - return stdout.Bytes(), nil -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/find.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/find.go deleted file mode 100644 index 3b03790711..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/invoke/find.go +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package invoke - -import ( - "fmt" - "os" - "path/filepath" -) - -// FindInPath returns the full path of the plugin by searching in the provided path -func FindInPath(plugin string, paths []string) (string, error) { - if plugin == "" { - return "", fmt.Errorf("no plugin name provided") - } - - if len(paths) == 0 { - return "", fmt.Errorf("no paths provided") - } - - var fullpath string - for _, path := range paths { - full := filepath.Join(path, plugin) - if fi, err := os.Stat(full); err == nil && fi.Mode().IsRegular() { - fullpath = full - break - } - } - - if fullpath == "" { - return "", fmt.Errorf("failed to find plugin %q in path %s", plugin, paths) - } - - return fullpath, nil -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/cidr.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/cidr.go deleted file mode 100644 index dae2c4d0e4..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/cidr.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ip - -import ( - "math/big" - "net" -) - -// NextIP returns IP incremented by 1 -func NextIP(ip net.IP) net.IP { - i := ipToInt(ip) - return intToIP(i.Add(i, big.NewInt(1))) -} - -// PrevIP returns IP decremented by 1 -func PrevIP(ip net.IP) net.IP { - i := ipToInt(ip) - return intToIP(i.Sub(i, big.NewInt(1))) -} - -func ipToInt(ip net.IP) *big.Int { - if v := ip.To4(); v != nil { - return big.NewInt(0).SetBytes(v) - } - return big.NewInt(0).SetBytes(ip.To16()) -} - -func intToIP(i *big.Int) net.IP { - return net.IP(i.Bytes()) -} - -// Network masks off the host portion of the IP -func Network(ipn *net.IPNet) *net.IPNet { - return &net.IPNet{ - IP: ipn.IP.Mask(ipn.Mask), - Mask: ipn.Mask, - } -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/ipforward.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/ipforward.go deleted file mode 100644 index 77ee74632a..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/ipforward.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ip - -import ( - "io/ioutil" -) - -func EnableIP4Forward() error { - return echo1("/proc/sys/net/ipv4/ip_forward") -} - -func EnableIP6Forward() error { - return echo1("/proc/sys/net/ipv6/conf/all/forwarding") -} - -func echo1(f string) error { - return ioutil.WriteFile(f, []byte("1"), 0644) -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/ipmasq.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/ipmasq.go deleted file mode 100644 index 8ee279717a..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/ipmasq.go +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ip - -import ( - "fmt" - "net" - - "github.com/coreos/go-iptables/iptables" -) - -// SetupIPMasq installs iptables rules to masquerade traffic -// coming from ipn and going outside of it -func SetupIPMasq(ipn *net.IPNet, chain string, comment string) error { - ipt, err := iptables.New() - if err != nil { - return fmt.Errorf("failed to locate iptables: %v", err) - } - - if err = ipt.NewChain("nat", chain); err != nil { - if err.(*iptables.Error).ExitStatus() != 1 { - // TODO(eyakubovich): assumes exit status 1 implies chain exists - return err - } - } - - if err = ipt.AppendUnique("nat", chain, "-d", ipn.String(), "-j", "ACCEPT", "-m", "comment", "--comment", comment); err != nil { - return err - } - - if err = ipt.AppendUnique("nat", chain, "!", "-d", "224.0.0.0/4", "-j", "MASQUERADE", "-m", "comment", "--comment", comment); err != nil { - return err - } - - return ipt.AppendUnique("nat", "POSTROUTING", "-s", ipn.String(), "-j", chain, "-m", "comment", "--comment", comment) -} - -// TeardownIPMasq undoes the effects of SetupIPMasq -func TeardownIPMasq(ipn *net.IPNet, chain string, comment string) error { - ipt, err := iptables.New() - if err != nil { - return fmt.Errorf("failed to locate iptables: %v", err) - } - - if err = ipt.Delete("nat", "POSTROUTING", "-s", ipn.String(), "-j", chain, "-m", "comment", "--comment", comment); err != nil { - return err - } - - if err = ipt.ClearChain("nat", chain); err != nil { - return err - } - - return ipt.DeleteChain("nat", chain) -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/link.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/link.go deleted file mode 100644 index 1b78567201..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/link.go +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ip - -import ( - "crypto/rand" - "fmt" - "net" - "os" - - "github.com/containernetworking/cni/pkg/ns" - "github.com/vishvananda/netlink" -) - -func makeVethPair(name, peer string, mtu int) (netlink.Link, error) { - veth := &netlink.Veth{ - LinkAttrs: netlink.LinkAttrs{ - Name: name, - Flags: net.FlagUp, - MTU: mtu, - }, - PeerName: peer, - } - if err := netlink.LinkAdd(veth); err != nil { - return nil, err - } - - return veth, nil -} - -func makeVeth(name string, mtu int) (peerName string, veth netlink.Link, err error) { - for i := 0; i < 10; i++ { - peerName, err = RandomVethName() - if err != nil { - return - } - - veth, err = makeVethPair(name, peerName, mtu) - switch { - case err == nil: - return - - case os.IsExist(err): - continue - - default: - err = fmt.Errorf("failed to make veth pair: %v", err) - return - } - } - - // should really never be hit - err = fmt.Errorf("failed to find a unique veth name") - return -} - -// RandomVethName returns string "veth" with random prefix (hashed from entropy) -func RandomVethName() (string, error) { - entropy := make([]byte, 4) - _, err := rand.Reader.Read(entropy) - if err != nil { - return "", fmt.Errorf("failed to generate random veth name: %v", err) - } - - // NetworkManager (recent versions) will ignore veth devices that start with "veth" - return fmt.Sprintf("veth%x", entropy), nil -} - -// SetupVeth sets up a virtual ethernet link. -// Should be in container netns, and will switch back to hostNS to set the host -// veth end up. -func SetupVeth(contVethName string, mtu int, hostNS ns.NetNS) (hostVeth, contVeth netlink.Link, err error) { - var hostVethName string - hostVethName, contVeth, err = makeVeth(contVethName, mtu) - if err != nil { - return - } - - if err = netlink.LinkSetUp(contVeth); err != nil { - err = fmt.Errorf("failed to set %q up: %v", contVethName, err) - return - } - - hostVeth, err = netlink.LinkByName(hostVethName) - if err != nil { - err = fmt.Errorf("failed to lookup %q: %v", hostVethName, err) - return - } - - if err = netlink.LinkSetNsFd(hostVeth, int(hostNS.Fd())); err != nil { - err = fmt.Errorf("failed to move veth to host netns: %v", err) - return - } - - err = hostNS.Do(func(_ ns.NetNS) error { - hostVeth, err := netlink.LinkByName(hostVethName) - if err != nil { - return fmt.Errorf("failed to lookup %q in %q: %v", hostVethName, hostNS.Path(), err) - } - - if err = netlink.LinkSetUp(hostVeth); err != nil { - return fmt.Errorf("failed to set %q up: %v", hostVethName, err) - } - return nil - }) - return -} - -// DelLinkByName removes an interface link. -func DelLinkByName(ifName string) error { - iface, err := netlink.LinkByName(ifName) - if err != nil { - return fmt.Errorf("failed to lookup %q: %v", ifName, err) - } - - if err = netlink.LinkDel(iface); err != nil { - return fmt.Errorf("failed to delete %q: %v", ifName, err) - } - - return nil -} - -// DelLinkByNameAddr remove an interface returns its IP address -// of the specified family -func DelLinkByNameAddr(ifName string, family int) (*net.IPNet, error) { - iface, err := netlink.LinkByName(ifName) - if err != nil { - return nil, fmt.Errorf("failed to lookup %q: %v", ifName, err) - } - - addrs, err := netlink.AddrList(iface, family) - if err != nil || len(addrs) == 0 { - return nil, fmt.Errorf("failed to get IP addresses for %q: %v", ifName, err) - } - - if err = netlink.LinkDel(iface); err != nil { - return nil, fmt.Errorf("failed to delete %q: %v", ifName, err) - } - - return addrs[0].IPNet, nil -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/route.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/route.go deleted file mode 100644 index 6c8658b2a2..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ip/route.go +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ip - -import ( - "net" - - "github.com/vishvananda/netlink" -) - -// AddDefaultRoute sets the default route on the given gateway. -func AddDefaultRoute(gw net.IP, dev netlink.Link) error { - _, defNet, _ := net.ParseCIDR("0.0.0.0/0") - return AddRoute(defNet, gw, dev) -} - -// AddRoute adds a universally-scoped route to a device. -func AddRoute(ipn *net.IPNet, gw net.IP, dev netlink.Link) error { - return netlink.RouteAdd(&netlink.Route{ - LinkIndex: dev.Attrs().Index, - Scope: netlink.SCOPE_UNIVERSE, - Dst: ipn, - Gw: gw, - }) -} - -// AddHostRoute adds a host-scoped route to a device. -func AddHostRoute(ipn *net.IPNet, gw net.IP, dev netlink.Link) error { - return netlink.RouteAdd(&netlink.Route{ - LinkIndex: dev.Attrs().Index, - Scope: netlink.SCOPE_HOST, - Dst: ipn, - Gw: gw, - }) -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ipam/ipam.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ipam/ipam.go deleted file mode 100644 index d9fbff74c7..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ipam/ipam.go +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ipam - -import ( - "fmt" - "os" - - "github.com/containernetworking/cni/pkg/invoke" - "github.com/containernetworking/cni/pkg/ip" - "github.com/containernetworking/cni/pkg/types" - - "github.com/vishvananda/netlink" -) - -func ExecAdd(plugin string, netconf []byte) (*types.Result, error) { - return invoke.DelegateAdd(plugin, netconf) -} - -func ExecDel(plugin string, netconf []byte) error { - return invoke.DelegateDel(plugin, netconf) -} - -// ConfigureIface takes the result of IPAM plugin and -// applies to the ifName interface -func ConfigureIface(ifName string, res *types.Result) error { - link, err := netlink.LinkByName(ifName) - if err != nil { - return fmt.Errorf("failed to lookup %q: %v", ifName, err) - } - - if err := netlink.LinkSetUp(link); err != nil { - return fmt.Errorf("failed to set %q UP: %v", ifName, err) - } - - // TODO(eyakubovich): IPv6 - addr := &netlink.Addr{IPNet: &res.IP4.IP, Label: ""} - if err = netlink.AddrAdd(link, addr); err != nil { - return fmt.Errorf("failed to add IP addr to %q: %v", ifName, err) - } - - for _, r := range res.IP4.Routes { - gw := r.GW - if gw == nil { - gw = res.IP4.Gateway - } - if err = ip.AddRoute(&r.Dst, gw, link); err != nil { - // we skip over duplicate routes as we assume the first one wins - if !os.IsExist(err) { - return fmt.Errorf("failed to add route '%v via %v dev %v': %v", r.Dst, gw, ifName, err) - } - } - } - - return nil -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ns/README.md b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ns/README.md deleted file mode 100644 index e7b20c2f9b..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ns/README.md +++ /dev/null @@ -1,31 +0,0 @@ -### Namespaces, Threads, and Go -On Linux each OS thread can have a different network namespace. Go's thread scheduling model switches goroutines between OS threads based on OS thread load and whether the goroutine would block other goroutines. This can result in a goroutine switching network namespaces without notice and lead to errors in your code. - -### Namespace Switching -Switching namespaces with the `ns.Set()` method is not recommended without additional strategies to prevent unexpected namespace changes when your goroutines switch OS threads. - -Go provides the `runtime.LockOSThread()` function to ensure a specific goroutine executes on its current OS thread and prevents any other goroutine from running in that thread until the locked one exits. Careful usage of `LockOSThread()` and goroutines can provide good control over which network namespace a given goroutine executes in. - -For example, you cannot rely on the `ns.Set()` namespace being the current namespace after the `Set()` call unless you do two things. First, the goroutine calling `Set()` must have previously called `LockOSThread()`. Second, you must ensure `runtime.UnlockOSThread()` is not called somewhere in-between. You also cannot rely on the initial network namespace remaining the current network namespace if any other code in your program switches namespaces, unless you have already called `LockOSThread()` in that goroutine. Note that `LockOSThread()` prevents the Go scheduler from optimally scheduling goroutines for best performance, so `LockOSThread()` should only be used in small, isolated goroutines that release the lock quickly. - -### Do() The Recommended Thing -The `ns.Do()` method provides control over network namespaces for you by implementing these strategies. All code dependent on a particular network namespace should be wrapped in the `ns.Do()` method to ensure the correct namespace is selected for the duration of your code. For example: - -```go -targetNs, err := ns.NewNS() -if err != nil { - return err -} -err = targetNs.Do(func(hostNs ns.NetNS) error { - dummy := &netlink.Dummy{ - LinkAttrs: netlink.LinkAttrs{ - Name: "dummy0", - }, - } - return netlink.LinkAdd(dummy) -}) -``` - -### Further Reading - - https://github.com/golang/go/wiki/LockOSThread - - http://morsmachine.dk/go-scheduler diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ns/ns.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ns/ns.go deleted file mode 100644 index e29f712ce1..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/ns/ns.go +++ /dev/null @@ -1,315 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package ns - -import ( - "crypto/rand" - "fmt" - "os" - "path" - "runtime" - "strings" - "sync" - "syscall" - - "golang.org/x/sys/unix" -) - -type NetNS interface { - // Executes the passed closure in this object's network namespace, - // attemtping to restore the original namespace before returning. - // However, since each OS thread can have a different network namespace, - // and Go's thread scheduling is highly variable, callers cannot - // guarantee any specific namespace is set unless operations that - // require that namespace are wrapped with Do(). Also, no code called - // from Do() should call runtime.UnlockOSThread(), or the risk - // of executing code in an incorrect namespace will be greater. See - // https://github.com/golang/go/wiki/LockOSThread for further details. - Do(toRun func(NetNS) error) error - - // Sets the current network namespace to this object's network namespace. - // Note that since Go's thread scheduling is highly variable, callers - // cannot guarantee the requested namespace will be the current namespace - // after this function is called; to ensure this wrap operations that - // require the namespace with Do() instead. - Set() error - - // Returns the filesystem path representing this object's network namespace - Path() string - - // Returns a file descriptor representing this object's network namespace - Fd() uintptr - - // Cleans up this instance of the network namespace; if this instance - // is the last user the namespace will be destroyed - Close() error -} - -type netNS struct { - file *os.File - mounted bool - closed bool -} - -func getCurrentThreadNetNSPath() string { - // /proc/self/ns/net returns the namespace of the main thread, not - // of whatever thread this goroutine is running on. Make sure we - // use the thread's net namespace since the thread is switching around - return fmt.Sprintf("/proc/%d/task/%d/ns/net", os.Getpid(), unix.Gettid()) -} - -// Returns an object representing the current OS thread's network namespace -func GetCurrentNS() (NetNS, error) { - return GetNS(getCurrentThreadNetNSPath()) -} - -const ( - // https://github.com/torvalds/linux/blob/master/include/uapi/linux/magic.h - NSFS_MAGIC = 0x6e736673 - PROCFS_MAGIC = 0x9fa0 -) - -type NSPathNotExistErr struct{ msg string } - -func (e NSPathNotExistErr) Error() string { return e.msg } - -type NSPathNotNSErr struct{ msg string } - -func (e NSPathNotNSErr) Error() string { return e.msg } - -func IsNSorErr(nspath string) error { - stat := syscall.Statfs_t{} - if err := syscall.Statfs(nspath, &stat); err != nil { - if os.IsNotExist(err) { - err = NSPathNotExistErr{msg: fmt.Sprintf("failed to Statfs %q: %v", nspath, err)} - } else { - err = fmt.Errorf("failed to Statfs %q: %v", nspath, err) - } - return err - } - - switch stat.Type { - case PROCFS_MAGIC: - // Kernel < 3.19 - - validPathContent := "ns/" - validName := strings.Contains(nspath, validPathContent) - if !validName { - return NSPathNotNSErr{msg: fmt.Sprintf("path %q doesn't contain %q", nspath, validPathContent)} - } - - return nil - case NSFS_MAGIC: - // Kernel >= 3.19 - - return nil - default: - return NSPathNotNSErr{msg: fmt.Sprintf("unknown FS magic on %q: %x", nspath, stat.Type)} - } -} - -// Returns an object representing the namespace referred to by @path -func GetNS(nspath string) (NetNS, error) { - err := IsNSorErr(nspath) - if err != nil { - return nil, err - } - - fd, err := os.Open(nspath) - if err != nil { - return nil, err - } - - return &netNS{file: fd}, nil -} - -// Creates a new persistent network namespace and returns an object -// representing that namespace, without switching to it -func NewNS() (NetNS, error) { - const nsRunDir = "/var/run/netns" - - b := make([]byte, 16) - _, err := rand.Reader.Read(b) - if err != nil { - return nil, fmt.Errorf("failed to generate random netns name: %v", err) - } - - err = os.MkdirAll(nsRunDir, 0755) - if err != nil { - return nil, err - } - - // create an empty file at the mount point - nsName := fmt.Sprintf("cni-%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:]) - nsPath := path.Join(nsRunDir, nsName) - mountPointFd, err := os.Create(nsPath) - if err != nil { - return nil, err - } - mountPointFd.Close() - - // Ensure the mount point is cleaned up on errors; if the namespace - // was successfully mounted this will have no effect because the file - // is in-use - defer os.RemoveAll(nsPath) - - var wg sync.WaitGroup - wg.Add(1) - - // do namespace work in a dedicated goroutine, so that we can safely - // Lock/Unlock OSThread without upsetting the lock/unlock state of - // the caller of this function - var fd *os.File - go (func() { - defer wg.Done() - runtime.LockOSThread() - - var origNS NetNS - origNS, err = GetNS(getCurrentThreadNetNSPath()) - if err != nil { - return - } - defer origNS.Close() - - // create a new netns on the current thread - err = unix.Unshare(unix.CLONE_NEWNET) - if err != nil { - return - } - defer origNS.Set() - - // bind mount the new netns from the current thread onto the mount point - err = unix.Mount(getCurrentThreadNetNSPath(), nsPath, "none", unix.MS_BIND, "") - if err != nil { - return - } - - fd, err = os.Open(nsPath) - if err != nil { - return - } - })() - wg.Wait() - - if err != nil { - unix.Unmount(nsPath, unix.MNT_DETACH) - return nil, fmt.Errorf("failed to create namespace: %v", err) - } - - return &netNS{file: fd, mounted: true}, nil -} - -func (ns *netNS) Path() string { - return ns.file.Name() -} - -func (ns *netNS) Fd() uintptr { - return ns.file.Fd() -} - -func (ns *netNS) errorIfClosed() error { - if ns.closed { - return fmt.Errorf("%q has already been closed", ns.file.Name()) - } - return nil -} - -func (ns *netNS) Close() error { - if err := ns.errorIfClosed(); err != nil { - return err - } - - if err := ns.file.Close(); err != nil { - return fmt.Errorf("Failed to close %q: %v", ns.file.Name(), err) - } - ns.closed = true - - if ns.mounted { - if err := unix.Unmount(ns.file.Name(), unix.MNT_DETACH); err != nil { - return fmt.Errorf("Failed to unmount namespace %s: %v", ns.file.Name(), err) - } - if err := os.RemoveAll(ns.file.Name()); err != nil { - return fmt.Errorf("Failed to clean up namespace %s: %v", ns.file.Name(), err) - } - ns.mounted = false - } - - return nil -} - -func (ns *netNS) Do(toRun func(NetNS) error) error { - if err := ns.errorIfClosed(); err != nil { - return err - } - - containedCall := func(hostNS NetNS) error { - threadNS, err := GetNS(getCurrentThreadNetNSPath()) - if err != nil { - return fmt.Errorf("failed to open current netns: %v", err) - } - defer threadNS.Close() - - // switch to target namespace - if err = ns.Set(); err != nil { - return fmt.Errorf("error switching to ns %v: %v", ns.file.Name(), err) - } - defer threadNS.Set() // switch back - - return toRun(hostNS) - } - - // save a handle to current network namespace - hostNS, err := GetNS(getCurrentThreadNetNSPath()) - if err != nil { - return fmt.Errorf("Failed to open current namespace: %v", err) - } - defer hostNS.Close() - - var wg sync.WaitGroup - wg.Add(1) - - var innerError error - go func() { - defer wg.Done() - runtime.LockOSThread() - innerError = containedCall(hostNS) - }() - wg.Wait() - - return innerError -} - -func (ns *netNS) Set() error { - if err := ns.errorIfClosed(); err != nil { - return err - } - - if _, _, err := unix.Syscall(unix.SYS_SETNS, ns.Fd(), uintptr(unix.CLONE_NEWNET), 0); err != 0 { - return fmt.Errorf("Error switching to ns %v: %v", ns.file.Name(), err) - } - - return nil -} - -// WithNetNSPath executes the passed closure under the given network -// namespace, restoring the original namespace afterwards. -func WithNetNSPath(nspath string, toRun func(NetNS) error) error { - ns, err := GetNS(nspath) - if err != nil { - return err - } - defer ns.Close() - return ns.Do(toRun) -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/skel/skel.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/skel/skel.go deleted file mode 100644 index 9cf03917b4..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/skel/skel.go +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright 2014 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package skel provides skeleton code for a CNI plugin. -// In particular, it implements argument parsing and validation. -package skel - -import ( - "fmt" - "io/ioutil" - "log" - "os" - - "github.com/containernetworking/cni/pkg/types" -) - -// CmdArgs captures all the arguments passed in to the plugin -// via both env vars and stdin -type CmdArgs struct { - ContainerID string - Netns string - IfName string - Args string - Path string - StdinData []byte -} - -type reqForCmdEntry map[string]bool - -// PluginMain is the "main" for a plugin. It accepts -// two callback functions for add and del commands. -func PluginMain(cmdAdd, cmdDel func(_ *CmdArgs) error) { - var cmd, contID, netns, ifName, args, path string - - vars := []struct { - name string - val *string - reqForCmd reqForCmdEntry - }{ - { - "CNI_COMMAND", - &cmd, - reqForCmdEntry{ - "ADD": true, - "DEL": true, - }, - }, - { - "CNI_CONTAINERID", - &contID, - reqForCmdEntry{ - "ADD": false, - "DEL": false, - }, - }, - { - "CNI_NETNS", - &netns, - reqForCmdEntry{ - "ADD": true, - "DEL": false, - }, - }, - { - "CNI_IFNAME", - &ifName, - reqForCmdEntry{ - "ADD": true, - "DEL": true, - }, - }, - { - "CNI_ARGS", - &args, - reqForCmdEntry{ - "ADD": false, - "DEL": false, - }, - }, - { - "CNI_PATH", - &path, - reqForCmdEntry{ - "ADD": true, - "DEL": true, - }, - }, - } - - argsMissing := false - for _, v := range vars { - *v.val = os.Getenv(v.name) - if v.reqForCmd[cmd] && *v.val == "" { - log.Printf("%v env variable missing", v.name) - argsMissing = true - } - } - - if argsMissing { - dieMsg("required env variables missing") - } - - stdinData, err := ioutil.ReadAll(os.Stdin) - if err != nil { - dieMsg("error reading from stdin: %v", err) - } - - cmdArgs := &CmdArgs{ - ContainerID: contID, - Netns: netns, - IfName: ifName, - Args: args, - Path: path, - StdinData: stdinData, - } - - switch cmd { - case "ADD": - err = cmdAdd(cmdArgs) - - case "DEL": - err = cmdDel(cmdArgs) - - default: - dieMsg("unknown CNI_COMMAND: %v", cmd) - } - - if err != nil { - if e, ok := err.(*types.Error); ok { - // don't wrap Error in Error - dieErr(e) - } - dieMsg(err.Error()) - } -} - -func dieMsg(f string, args ...interface{}) { - e := &types.Error{ - Code: 100, - Msg: fmt.Sprintf(f, args...), - } - dieErr(e) -} - -func dieErr(e *types.Error) { - if err := e.Print(); err != nil { - log.Print("Error writing error JSON to stdout: ", err) - } - os.Exit(1) -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/testutils/cmd.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/testutils/cmd.go deleted file mode 100644 index 201b935f40..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/testutils/cmd.go +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2016 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package testutils - -import ( - "encoding/json" - "io/ioutil" - "os" - - "github.com/containernetworking/cni/pkg/types" -) - -func envCleanup() { - os.Unsetenv("CNI_COMMAND") - os.Unsetenv("CNI_PATH") - os.Unsetenv("CNI_NETNS") - os.Unsetenv("CNI_IFNAME") -} - -func CmdAddWithResult(cniNetns, cniIfname string, f func() error) (*types.Result, error) { - os.Setenv("CNI_COMMAND", "ADD") - os.Setenv("CNI_PATH", os.Getenv("PATH")) - os.Setenv("CNI_NETNS", cniNetns) - os.Setenv("CNI_IFNAME", cniIfname) - defer envCleanup() - - // Redirect stdout to capture plugin result - oldStdout := os.Stdout - r, w, err := os.Pipe() - if err != nil { - return nil, err - } - - os.Stdout = w - err = f() - w.Close() - if err != nil { - return nil, err - } - - // parse the result - out, err := ioutil.ReadAll(r) - os.Stdout = oldStdout - if err != nil { - return nil, err - } - - result := types.Result{} - err = json.Unmarshal(out, &result) - if err != nil { - return nil, err - } - - return &result, nil -} - -func CmdDelWithResult(cniNetns, cniIfname string, f func() error) error { - os.Setenv("CNI_COMMAND", "DEL") - os.Setenv("CNI_PATH", os.Getenv("PATH")) - os.Setenv("CNI_NETNS", cniNetns) - os.Setenv("CNI_IFNAME", cniIfname) - defer envCleanup() - - return f() -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/types/args.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/types/args.go deleted file mode 100644 index 3b667b0f20..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/types/args.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "encoding" - "fmt" - "reflect" - "strings" -) - -// UnmarshallableBool typedef for builtin bool -// because builtin type's methods can't be declared -type UnmarshallableBool bool - -// UnmarshalText implements the encoding.TextUnmarshaler interface. -// Returns boolean true if the string is "1" or "[Tt]rue" -// Returns boolean false if the string is "0" or "[Ff]alse" -func (b *UnmarshallableBool) UnmarshalText(data []byte) error { - s := strings.ToLower(string(data)) - switch s { - case "1", "true": - *b = true - case "0", "false": - *b = false - default: - return fmt.Errorf("Boolean unmarshal error: invalid input %s", s) - } - return nil -} - -// CommonArgs contains the IgnoreUnknown argument -// and must be embedded by all Arg structs -type CommonArgs struct { - IgnoreUnknown UnmarshallableBool `json:"ignoreunknown,omitempty"` -} - -// GetKeyField is a helper function to receive Values -// Values that represent a pointer to a struct -func GetKeyField(keyString string, v reflect.Value) reflect.Value { - return v.Elem().FieldByName(keyString) -} - -// LoadArgs parses args from a string in the form "K=V;K2=V2;..." -func LoadArgs(args string, container interface{}) error { - if args == "" { - return nil - } - - containerValue := reflect.ValueOf(container) - - pairs := strings.Split(args, ";") - unknownArgs := []string{} - for _, pair := range pairs { - kv := strings.Split(pair, "=") - if len(kv) != 2 { - return fmt.Errorf("ARGS: invalid pair %q", pair) - } - keyString := kv[0] - valueString := kv[1] - keyField := GetKeyField(keyString, containerValue) - if !keyField.IsValid() { - unknownArgs = append(unknownArgs, pair) - continue - } - - u := keyField.Addr().Interface().(encoding.TextUnmarshaler) - err := u.UnmarshalText([]byte(valueString)) - if err != nil { - return fmt.Errorf("ARGS: error parsing value of pair %q: %v)", pair, err) - } - } - - isIgnoreUnknown := GetKeyField("IgnoreUnknown", containerValue).Bool() - if len(unknownArgs) > 0 && !isIgnoreUnknown { - return fmt.Errorf("ARGS: unknown args %q", unknownArgs) - } - return nil -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/types/types.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/types/types.go deleted file mode 100644 index 6948dcb1fb..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/types/types.go +++ /dev/null @@ -1,191 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package types - -import ( - "encoding/json" - "fmt" - "net" - "os" -) - -// like net.IPNet but adds JSON marshalling and unmarshalling -type IPNet net.IPNet - -// ParseCIDR takes a string like "10.2.3.1/24" and -// return IPNet with "10.2.3.1" and /24 mask -func ParseCIDR(s string) (*net.IPNet, error) { - ip, ipn, err := net.ParseCIDR(s) - if err != nil { - return nil, err - } - - ipn.IP = ip - return ipn, nil -} - -func (n IPNet) MarshalJSON() ([]byte, error) { - return json.Marshal((*net.IPNet)(&n).String()) -} - -func (n *IPNet) UnmarshalJSON(data []byte) error { - var s string - if err := json.Unmarshal(data, &s); err != nil { - return err - } - - tmp, err := ParseCIDR(s) - if err != nil { - return err - } - - *n = IPNet(*tmp) - return nil -} - -// NetConf describes a network. -type NetConf struct { - Name string `json:"name,omitempty"` - Type string `json:"type,omitempty"` - IPAM struct { - Type string `json:"type,omitempty"` - } `json:"ipam,omitempty"` - DNS DNS `json:"dns"` -} - -// Result is what gets returned from the plugin (via stdout) to the caller -type Result struct { - IP4 *IPConfig `json:"ip4,omitempty"` - IP6 *IPConfig `json:"ip6,omitempty"` - DNS DNS `json:"dns,omitempty"` -} - -func (r *Result) Print() error { - return prettyPrint(r) -} - -// String returns a formatted string in the form of "[IP4: $1,][ IP6: $2,] DNS: $3" where -// $1 represents the receiver's IPv4, $2 represents the receiver's IPv6 and $3 the -// receiver's DNS. If $1 or $2 are nil, they won't be present in the returned string. -func (r *Result) String() string { - var str string - if r.IP4 != nil { - str = fmt.Sprintf("IP4:%+v, ", *r.IP4) - } - if r.IP6 != nil { - str += fmt.Sprintf("IP6:%+v, ", *r.IP6) - } - return fmt.Sprintf("%sDNS:%+v", str, r.DNS) -} - -// IPConfig contains values necessary to configure an interface -type IPConfig struct { - IP net.IPNet - Gateway net.IP - Routes []Route -} - -// DNS contains values interesting for DNS resolvers -type DNS struct { - Nameservers []string `json:"nameservers,omitempty"` - Domain string `json:"domain,omitempty"` - Search []string `json:"search,omitempty"` - Options []string `json:"options,omitempty"` -} - -type Route struct { - Dst net.IPNet - GW net.IP -} - -type Error struct { - Code uint `json:"code"` - Msg string `json:"msg"` - Details string `json:"details,omitempty"` -} - -func (e *Error) Error() string { - return e.Msg -} - -func (e *Error) Print() error { - return prettyPrint(e) -} - -// net.IPNet is not JSON (un)marshallable so this duality is needed -// for our custom IPNet type - -// JSON (un)marshallable types -type ipConfig struct { - IP IPNet `json:"ip"` - Gateway net.IP `json:"gateway,omitempty"` - Routes []Route `json:"routes,omitempty"` -} - -type route struct { - Dst IPNet `json:"dst"` - GW net.IP `json:"gw,omitempty"` -} - -func (c *IPConfig) MarshalJSON() ([]byte, error) { - ipc := ipConfig{ - IP: IPNet(c.IP), - Gateway: c.Gateway, - Routes: c.Routes, - } - - return json.Marshal(ipc) -} - -func (c *IPConfig) UnmarshalJSON(data []byte) error { - ipc := ipConfig{} - if err := json.Unmarshal(data, &ipc); err != nil { - return err - } - - c.IP = net.IPNet(ipc.IP) - c.Gateway = ipc.Gateway - c.Routes = ipc.Routes - return nil -} - -func (r *Route) UnmarshalJSON(data []byte) error { - rt := route{} - if err := json.Unmarshal(data, &rt); err != nil { - return err - } - - r.Dst = net.IPNet(rt.Dst) - r.GW = rt.GW - return nil -} - -func (r *Route) MarshalJSON() ([]byte, error) { - rt := route{ - Dst: IPNet(r.Dst), - GW: r.GW, - } - - return json.Marshal(rt) -} - -func prettyPrint(obj interface{}) error { - data, err := json.MarshalIndent(obj, "", " ") - if err != nil { - return err - } - _, err = os.Stdout.Write(data) - return err -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/utils/sysctl/sysctl_linux.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/utils/sysctl/sysctl_linux.go deleted file mode 100644 index c0fba38290..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/utils/sysctl/sysctl_linux.go +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2016 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// build +linux - -package sysctl - -import ( - "fmt" - "io/ioutil" - "path/filepath" - "strings" -) - -// Sysctl provides a method to set/get values from /proc/sys - in linux systems -// new interface to set/get values of variables formerly handled by sysctl syscall -// If optional `params` have only one string value - this function will -// set this value into coresponding sysctl variable -func Sysctl(name string, params ...string) (string, error) { - if len(params) > 1 { - return "", fmt.Errorf("unexcepted additional parameters") - } else if len(params) == 1 { - return setSysctl(name, params[0]) - } - return getSysctl(name) -} - -func getSysctl(name string) (string, error) { - fullName := filepath.Join("/proc/sys", strings.Replace(name, ".", "/", -1)) - fullName = filepath.Clean(fullName) - data, err := ioutil.ReadFile(fullName) - if err != nil { - return "", err - } - - return string(data[:len(data)-1]), nil -} - -func setSysctl(name, value string) (string, error) { - fullName := filepath.Join("/proc/sys", strings.Replace(name, ".", "/", -1)) - fullName = filepath.Clean(fullName) - if err := ioutil.WriteFile(fullName, []byte(value), 0644); err != nil { - return "", err - } - - return getSysctl(name) -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/utils/utils.go b/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/utils/utils.go deleted file mode 100644 index 33a2aa7960..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/pkg/utils/utils.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2016 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package utils - -import ( - "crypto/sha512" - "fmt" -) - -const ( - maxChainLength = 28 - chainPrefix = "CNI-" - prefixLength = len(chainPrefix) -) - -// Generates a chain name to be used with iptables. -// Ensures that the generated chain name is exactly -// maxChainLength chars in length -func FormatChainName(name string, id string) string { - chainBytes := sha512.Sum512([]byte(name + id)) - chain := fmt.Sprintf("%s%x", chainPrefix, chainBytes) - return chain[:maxChainLength] -} - -// FormatComment returns a comment used for easier -// rule identification within iptables. -func FormatComment(name string, id string) string { - return fmt.Sprintf("name: %q id: %q", name, id) -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/daemon.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/daemon.go deleted file mode 100644 index 2386f9a9f4..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/daemon.go +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "encoding/json" - "errors" - "fmt" - "log" - "net" - "net/http" - "net/rpc" - "os" - "path/filepath" - "runtime" - "sync" - - "github.com/containernetworking/cni/pkg/skel" - "github.com/containernetworking/cni/pkg/types" - "github.com/coreos/go-systemd/activation" -) - -const listenFdsStart = 3 -const resendCount = 3 - -var errNoMoreTries = errors.New("no more tries") - -type DHCP struct { - mux sync.Mutex - leases map[string]*DHCPLease -} - -func newDHCP() *DHCP { - return &DHCP{ - leases: make(map[string]*DHCPLease), - } -} - -// Allocate acquires an IP from a DHCP server for a specified container. -// The acquired lease will be maintained until Release() is called. -func (d *DHCP) Allocate(args *skel.CmdArgs, result *types.Result) error { - conf := types.NetConf{} - if err := json.Unmarshal(args.StdinData, &conf); err != nil { - return fmt.Errorf("error parsing netconf: %v", err) - } - - clientID := args.ContainerID + "/" + conf.Name - l, err := AcquireLease(clientID, args.Netns, args.IfName) - if err != nil { - return err - } - - ipn, err := l.IPNet() - if err != nil { - l.Stop() - return err - } - - d.setLease(args.ContainerID, conf.Name, l) - - result.IP4 = &types.IPConfig{ - IP: *ipn, - Gateway: l.Gateway(), - Routes: l.Routes(), - } - - return nil -} - -// Release stops maintenance of the lease acquired in Allocate() -// and sends a release msg to the DHCP server. -func (d *DHCP) Release(args *skel.CmdArgs, reply *struct{}) error { - conf := types.NetConf{} - if err := json.Unmarshal(args.StdinData, &conf); err != nil { - return fmt.Errorf("error parsing netconf: %v", err) - } - - if l := d.getLease(args.ContainerID, conf.Name); l != nil { - l.Stop() - return nil - } - - return fmt.Errorf("lease not found: %v/%v", args.ContainerID, conf.Name) -} - -func (d *DHCP) getLease(contID, netName string) *DHCPLease { - d.mux.Lock() - defer d.mux.Unlock() - - // TODO(eyakubovich): hash it to avoid collisions - l, ok := d.leases[contID+netName] - if !ok { - return nil - } - return l -} - -func (d *DHCP) setLease(contID, netName string, l *DHCPLease) { - d.mux.Lock() - defer d.mux.Unlock() - - // TODO(eyakubovich): hash it to avoid collisions - d.leases[contID+netName] = l -} - -func getListener() (net.Listener, error) { - l, err := activation.Listeners(true) - if err != nil { - return nil, err - } - - switch { - case len(l) == 0: - if err := os.MkdirAll(filepath.Dir(socketPath), 0700); err != nil { - return nil, err - } - return net.Listen("unix", socketPath) - - case len(l) == 1: - if l[0] == nil { - return nil, fmt.Errorf("LISTEN_FDS=1 but no FD found") - } - return l[0], nil - - default: - return nil, fmt.Errorf("Too many (%v) FDs passed through socket activation", len(l)) - } -} - -func runDaemon() { - // since other goroutines (on separate threads) will change namespaces, - // ensure the RPC server does not get scheduled onto those - runtime.LockOSThread() - - l, err := getListener() - if err != nil { - log.Printf("Error getting listener: %v", err) - return - } - - dhcp := newDHCP() - rpc.Register(dhcp) - rpc.HandleHTTP() - http.Serve(l, nil) -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/lease.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/lease.go deleted file mode 100644 index eb2b403130..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/lease.go +++ /dev/null @@ -1,337 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "fmt" - "log" - "math/rand" - "net" - "sync" - "time" - - "github.com/d2g/dhcp4" - "github.com/d2g/dhcp4client" - "github.com/vishvananda/netlink" - - "github.com/containernetworking/cni/pkg/ns" - "github.com/containernetworking/cni/pkg/types" -) - -// RFC 2131 suggests using exponential backoff, starting with 4sec -// and randomized to +/- 1sec -const resendDelay0 = 4 * time.Second -const resendDelayMax = 32 * time.Second - -const ( - leaseStateBound = iota - leaseStateRenewing - leaseStateRebinding -) - -// This implementation uses 1 OS thread per lease. This is because -// all the network operations have to be done in network namespace -// of the interface. This can be improved by switching to the proper -// namespace for network ops and using fewer threads. However, this -// needs to be done carefully as dhcp4client ops are blocking. - -type DHCPLease struct { - clientID string - ack *dhcp4.Packet - opts dhcp4.Options - link netlink.Link - renewalTime time.Time - rebindingTime time.Time - expireTime time.Time - stop chan struct{} - wg sync.WaitGroup -} - -// AcquireLease gets an DHCP lease and then maintains it in the background -// by periodically renewing it. The acquired lease can be released by -// calling DHCPLease.Stop() -func AcquireLease(clientID, netns, ifName string) (*DHCPLease, error) { - errCh := make(chan error, 1) - l := &DHCPLease{ - clientID: clientID, - stop: make(chan struct{}), - } - - log.Printf("%v: acquiring lease", clientID) - - l.wg.Add(1) - go func() { - errCh <- ns.WithNetNSPath(netns, func(_ ns.NetNS) error { - defer l.wg.Done() - - link, err := netlink.LinkByName(ifName) - if err != nil { - return fmt.Errorf("error looking up %q: %v", ifName, err) - } - - l.link = link - - if err = l.acquire(); err != nil { - return err - } - - log.Printf("%v: lease acquired, expiration is %v", l.clientID, l.expireTime) - - errCh <- nil - - l.maintain() - return nil - }) - }() - - if err := <-errCh; err != nil { - return nil, err - } - - return l, nil -} - -// Stop terminates the background task that maintains the lease -// and issues a DHCP Release -func (l *DHCPLease) Stop() { - close(l.stop) - l.wg.Wait() -} - -func (l *DHCPLease) acquire() error { - c, err := newDHCPClient(l.link) - if err != nil { - return err - } - defer c.Close() - - if (l.link.Attrs().Flags & net.FlagUp) != net.FlagUp { - log.Printf("Link %q down. Attempting to set up", l.link.Attrs().Name) - if err = netlink.LinkSetUp(l.link); err != nil { - return err - } - } - - pkt, err := backoffRetry(func() (*dhcp4.Packet, error) { - ok, ack, err := c.Request() - switch { - case err != nil: - return nil, err - case !ok: - return nil, fmt.Errorf("DHCP server NACK'd own offer") - default: - return &ack, nil - } - }) - if err != nil { - return err - } - - return l.commit(pkt) -} - -func (l *DHCPLease) commit(ack *dhcp4.Packet) error { - opts := ack.ParseOptions() - - leaseTime, err := parseLeaseTime(opts) - if err != nil { - return err - } - - rebindingTime, err := parseRebindingTime(opts) - if err != nil || rebindingTime > leaseTime { - // Per RFC 2131 Section 4.4.5, it should default to 85% of lease time - rebindingTime = leaseTime * 85 / 100 - } - - renewalTime, err := parseRenewalTime(opts) - if err != nil || renewalTime > rebindingTime { - // Per RFC 2131 Section 4.4.5, it should default to 50% of lease time - renewalTime = leaseTime / 2 - } - - now := time.Now() - l.expireTime = now.Add(leaseTime) - l.renewalTime = now.Add(renewalTime) - l.rebindingTime = now.Add(rebindingTime) - l.ack = ack - l.opts = opts - - return nil -} - -func (l *DHCPLease) maintain() { - state := leaseStateBound - - for { - var sleepDur time.Duration - - switch state { - case leaseStateBound: - sleepDur = l.renewalTime.Sub(time.Now()) - if sleepDur <= 0 { - log.Printf("%v: renewing lease", l.clientID) - state = leaseStateRenewing - continue - } - - case leaseStateRenewing: - if err := l.renew(); err != nil { - log.Printf("%v: %v", l.clientID, err) - - if time.Now().After(l.rebindingTime) { - log.Printf("%v: renawal time expired, rebinding", l.clientID) - state = leaseStateRebinding - } - } else { - log.Printf("%v: lease renewed, expiration is %v", l.clientID, l.expireTime) - state = leaseStateBound - } - - case leaseStateRebinding: - if err := l.acquire(); err != nil { - log.Printf("%v: %v", l.clientID, err) - - if time.Now().After(l.expireTime) { - log.Printf("%v: lease expired, bringing interface DOWN", l.clientID) - l.downIface() - return - } - } else { - log.Printf("%v: lease rebound, expiration is %v", l.clientID, l.expireTime) - state = leaseStateBound - } - } - - select { - case <-time.After(sleepDur): - - case <-l.stop: - if err := l.release(); err != nil { - log.Printf("%v: failed to release DHCP lease: %v", l.clientID, err) - } - return - } - } -} - -func (l *DHCPLease) downIface() { - if err := netlink.LinkSetDown(l.link); err != nil { - log.Printf("%v: failed to bring %v interface DOWN: %v", l.clientID, l.link.Attrs().Name, err) - } -} - -func (l *DHCPLease) renew() error { - c, err := newDHCPClient(l.link) - if err != nil { - return err - } - defer c.Close() - - pkt, err := backoffRetry(func() (*dhcp4.Packet, error) { - ok, ack, err := c.Renew(*l.ack) - switch { - case err != nil: - return nil, err - case !ok: - return nil, fmt.Errorf("DHCP server did not renew lease") - default: - return &ack, nil - } - }) - if err != nil { - return err - } - - l.commit(pkt) - return nil -} - -func (l *DHCPLease) release() error { - log.Printf("%v: releasing lease", l.clientID) - - c, err := newDHCPClient(l.link) - if err != nil { - return err - } - defer c.Close() - - if err = c.Release(*l.ack); err != nil { - return fmt.Errorf("failed to send DHCPRELEASE") - } - - return nil -} - -func (l *DHCPLease) IPNet() (*net.IPNet, error) { - mask := parseSubnetMask(l.opts) - if mask == nil { - return nil, fmt.Errorf("DHCP option Subnet Mask not found in DHCPACK") - } - - return &net.IPNet{ - IP: l.ack.YIAddr(), - Mask: mask, - }, nil -} - -func (l *DHCPLease) Gateway() net.IP { - return parseRouter(l.opts) -} - -func (l *DHCPLease) Routes() []types.Route { - routes := parseRoutes(l.opts) - return append(routes, parseCIDRRoutes(l.opts)...) -} - -// jitter returns a random value within [-span, span) range -func jitter(span time.Duration) time.Duration { - return time.Duration(float64(span) * (2.0*rand.Float64() - 1.0)) -} - -func backoffRetry(f func() (*dhcp4.Packet, error)) (*dhcp4.Packet, error) { - var baseDelay time.Duration = resendDelay0 - - for i := 0; i < resendCount; i++ { - pkt, err := f() - if err == nil { - return pkt, nil - } - - log.Print(err) - - time.Sleep(baseDelay + jitter(time.Second)) - - if baseDelay < resendDelayMax { - baseDelay *= 2 - } - } - - return nil, errNoMoreTries -} - -func newDHCPClient(link netlink.Link) (*dhcp4client.Client, error) { - pktsock, err := dhcp4client.NewPacketSock(link.Attrs().Index) - if err != nil { - return nil, err - } - - return dhcp4client.New( - dhcp4client.HardwareAddr(link.Attrs().HardwareAddr), - dhcp4client.Timeout(5*time.Second), - dhcp4client.Broadcast(false), - dhcp4client.Connection(pktsock), - ) -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/main.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/main.go deleted file mode 100644 index b537831506..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/main.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "fmt" - "net/rpc" - "os" - "path/filepath" - - "github.com/containernetworking/cni/pkg/skel" - "github.com/containernetworking/cni/pkg/types" -) - -const socketPath = "/run/cni/dhcp.sock" - -func main() { - if len(os.Args) > 1 && os.Args[1] == "daemon" { - runDaemon() - } else { - skel.PluginMain(cmdAdd, cmdDel) - } -} - -func cmdAdd(args *skel.CmdArgs) error { - result := types.Result{} - if err := rpcCall("DHCP.Allocate", args, &result); err != nil { - return err - } - return result.Print() -} - -func cmdDel(args *skel.CmdArgs) error { - result := struct{}{} - if err := rpcCall("DHCP.Release", args, &result); err != nil { - return fmt.Errorf("error dialing DHCP daemon: %v", err) - } - return nil -} - -func rpcCall(method string, args *skel.CmdArgs, result interface{}) error { - client, err := rpc.DialHTTP("unix", socketPath) - if err != nil { - return fmt.Errorf("error dialing DHCP daemon: %v", err) - } - - // The daemon may be running under a different working dir - // so make sure the netns path is absolute. - netns, err := filepath.Abs(args.Netns) - if err != nil { - return fmt.Errorf("failed to make %q an absolute path: %v", args.Netns, err) - } - args.Netns = netns - - err = client.Call(method, args, result) - if err != nil { - return fmt.Errorf("error calling %v: %v", method, err) - } - - return nil -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/options.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/options.go deleted file mode 100644 index b11ec21d55..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/dhcp/options.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "encoding/binary" - "fmt" - "net" - "time" - - "github.com/containernetworking/cni/pkg/types" - "github.com/d2g/dhcp4" -) - -func parseRouter(opts dhcp4.Options) net.IP { - if opts, ok := opts[dhcp4.OptionRouter]; ok { - if len(opts) == 4 { - return net.IP(opts) - } - } - return nil -} - -func classfulSubnet(sn net.IP) net.IPNet { - return net.IPNet{ - IP: sn, - Mask: sn.DefaultMask(), - } -} - -func parseRoutes(opts dhcp4.Options) []types.Route { - // StaticRoutes format: pairs of: - // Dest = 4 bytes; Classful IP subnet - // Router = 4 bytes; IP address of router - - routes := []types.Route{} - if opt, ok := opts[dhcp4.OptionStaticRoute]; ok { - for len(opt) >= 8 { - sn := opt[0:4] - r := opt[4:8] - rt := types.Route{ - Dst: classfulSubnet(sn), - GW: r, - } - routes = append(routes, rt) - opt = opt[8:] - } - } - - return routes -} - -func parseCIDRRoutes(opts dhcp4.Options) []types.Route { - // See RFC4332 for format (http://tools.ietf.org/html/rfc3442) - - routes := []types.Route{} - if opt, ok := opts[dhcp4.OptionClasslessRouteFormat]; ok { - for len(opt) >= 5 { - width := int(opt[0]) - if width > 32 { - // error: can't have more than /32 - return nil - } - // network bits are compacted to avoid zeros - octets := 0 - if width > 0 { - octets = (width-1)/8 + 1 - } - - if len(opt) < 1+octets+4 { - // error: too short - return nil - } - - sn := make([]byte, 4) - copy(sn, opt[1:octets+1]) - - gw := net.IP(opt[octets+1 : octets+5]) - - rt := types.Route{ - Dst: net.IPNet{ - IP: net.IP(sn), - Mask: net.CIDRMask(width, 32), - }, - GW: gw, - } - routes = append(routes, rt) - - opt = opt[octets+5 : len(opt)] - } - } - return routes -} - -func parseSubnetMask(opts dhcp4.Options) net.IPMask { - mask, ok := opts[dhcp4.OptionSubnetMask] - if !ok { - return nil - } - - return net.IPMask(mask) -} - -func parseDuration(opts dhcp4.Options, code dhcp4.OptionCode, optName string) (time.Duration, error) { - val, ok := opts[code] - if !ok { - return 0, fmt.Errorf("option %v not found", optName) - } - if len(val) != 4 { - return 0, fmt.Errorf("option %v is not 4 bytes", optName) - } - - secs := binary.BigEndian.Uint32(val) - return time.Duration(secs) * time.Second, nil -} - -func parseLeaseTime(opts dhcp4.Options) (time.Duration, error) { - return parseDuration(opts, dhcp4.OptionIPAddressLeaseTime, "LeaseTime") -} - -func parseRenewalTime(opts dhcp4.Options) (time.Duration, error) { - return parseDuration(opts, dhcp4.OptionRenewalTimeValue, "RenewalTime") -} - -func parseRebindingTime(opts dhcp4.Options) (time.Duration, error) { - return parseDuration(opts, dhcp4.OptionRebindingTimeValue, "RebindingTime") -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/README.md b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/README.md deleted file mode 100644 index 39e9ede217..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/README.md +++ /dev/null @@ -1,86 +0,0 @@ -# host-local IP address manager - -host-local IPAM allocates IPv4 and IPv6 addresses out of a specified address range. - -## Usage - -### Obtain an IP - -Given the following network configuration: - -``` -{ - "name": "default", - "ipam": { - "type": "host-local", - "subnet": "203.0.113.0/24" - } -} -``` - -#### Using the command line interface - -``` -$ export CNI_COMMAND=ADD -$ export CNI_CONTAINERID=f81d4fae-7dec-11d0-a765-00a0c91e6bf6 -$ ./host-local < $conf -``` - -``` -{ - "ip4": { - "ip": "203.0.113.1/24" - } -} -``` - -## Backends - -By default ipmanager stores IP allocations on the local filesystem using the IP address as the file name and the ID as contents. For example: - -``` -$ ls /var/lib/cni/networks/default -``` -``` -203.0.113.1 203.0.113.2 -``` - -``` -$ cat /var/lib/cni/networks/default/203.0.113.1 -``` -``` -f81d4fae-7dec-11d0-a765-00a0c91e6bf6 -``` - -## Configuration Files - - -``` -{ - "name": "ipv6", - "ipam": { - "type": "host-local", - "subnet": "3ffe:ffff:0:01ff::/64", - "range-start": "3ffe:ffff:0:01ff::0010", - "range-end": "3ffe:ffff:0:01ff::0020", - "routes": [ - { "dst": "3ffe:ffff:0:01ff::1/64" } - ] - } -} -``` - -``` -{ - "name": "ipv4", - "ipam": { - "type": "host-local", - "subnet": "203.0.113.1/24", - "range-start": "203.0.113.10", - "range-end": "203.0.113.20", - "routes": [ - { "dst": "203.0.113.0/24" } - ] - } -} -``` diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/allocator.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/allocator.go deleted file mode 100644 index 55a3ae6fa4..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/allocator.go +++ /dev/null @@ -1,165 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "fmt" - "net" - - "github.com/containernetworking/cni/pkg/ip" - "github.com/containernetworking/cni/pkg/types" - "github.com/containernetworking/cni/plugins/ipam/host-local/backend" -) - -type IPAllocator struct { - start net.IP - end net.IP - conf *IPAMConfig - store backend.Store -} - -func NewIPAllocator(conf *IPAMConfig, store backend.Store) (*IPAllocator, error) { - var ( - start net.IP - end net.IP - err error - ) - start, end, err = networkRange((*net.IPNet)(&conf.Subnet)) - if err != nil { - return nil, err - } - - // skip the .0 address - start = ip.NextIP(start) - - if conf.RangeStart != nil { - if err := validateRangeIP(conf.RangeStart, (*net.IPNet)(&conf.Subnet)); err != nil { - return nil, err - } - start = conf.RangeStart - } - if conf.RangeEnd != nil { - if err := validateRangeIP(conf.RangeEnd, (*net.IPNet)(&conf.Subnet)); err != nil { - return nil, err - } - // RangeEnd is inclusive - end = ip.NextIP(conf.RangeEnd) - } - - return &IPAllocator{start, end, conf, store}, nil -} - -func validateRangeIP(ip net.IP, ipnet *net.IPNet) error { - if !ipnet.Contains(ip) { - return fmt.Errorf("%s not in network: %s", ip, ipnet) - } - return nil -} - -// Returns newly allocated IP along with its config -func (a *IPAllocator) Get(id string) (*types.IPConfig, error) { - a.store.Lock() - defer a.store.Unlock() - - gw := a.conf.Gateway - if gw == nil { - gw = ip.NextIP(a.conf.Subnet.IP) - } - - var requestedIP net.IP - if a.conf.Args != nil { - requestedIP = a.conf.Args.IP - } - - if requestedIP != nil { - if gw != nil && gw.Equal(a.conf.Args.IP) { - return nil, fmt.Errorf("requested IP must differ gateway IP") - } - - subnet := net.IPNet{ - IP: a.conf.Subnet.IP, - Mask: a.conf.Subnet.Mask, - } - err := validateRangeIP(requestedIP, &subnet) - if err != nil { - return nil, err - } - - reserved, err := a.store.Reserve(id, requestedIP) - if err != nil { - return nil, err - } - - if reserved { - return &types.IPConfig{ - IP: net.IPNet{IP: requestedIP, Mask: a.conf.Subnet.Mask}, - Gateway: gw, - Routes: a.conf.Routes, - }, nil - } - return nil, fmt.Errorf("requested IP address %q is not available in network: %s", requestedIP, a.conf.Name) - } - - for cur := a.start; !cur.Equal(a.end); cur = ip.NextIP(cur) { - // don't allocate gateway IP - if gw != nil && cur.Equal(gw) { - continue - } - - reserved, err := a.store.Reserve(id, cur) - if err != nil { - return nil, err - } - if reserved { - return &types.IPConfig{ - IP: net.IPNet{IP: cur, Mask: a.conf.Subnet.Mask}, - Gateway: gw, - Routes: a.conf.Routes, - }, nil - } - } - return nil, fmt.Errorf("no IP addresses available in network: %s", a.conf.Name) -} - -// Releases all IPs allocated for the container with given ID -func (a *IPAllocator) Release(id string) error { - a.store.Lock() - defer a.store.Unlock() - - return a.store.ReleaseByID(id) -} - -func networkRange(ipnet *net.IPNet) (net.IP, net.IP, error) { - if ipnet.IP == nil { - return nil, nil, fmt.Errorf("missing field %q in IPAM configuration", "subnet") - } - ip := ipnet.IP.To4() - if ip == nil { - ip = ipnet.IP.To16() - if ip == nil { - return nil, nil, fmt.Errorf("IP not v4 nor v6") - } - } - - if len(ip) != len(ipnet.Mask) { - return nil, nil, fmt.Errorf("IPNet IP and Mask version mismatch") - } - - var end net.IP - for i := 0; i < len(ip); i++ { - end = append(end, ip[i]|^ipnet.Mask[i]) - } - return ipnet.IP, end, nil -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk/backend.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk/backend.go deleted file mode 100644 index 88dc5e92bc..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk/backend.go +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package disk - -import ( - "io/ioutil" - "net" - "os" - "path/filepath" -) - -var defaultDataDir = "/var/lib/cni/networks" - -type Store struct { - FileLock - dataDir string -} - -func New(network string) (*Store, error) { - dir := filepath.Join(defaultDataDir, network) - if err := os.MkdirAll(dir, 0644); err != nil { - return nil, err - } - - lk, err := NewFileLock(dir) - if err != nil { - return nil, err - } - return &Store{*lk, dir}, nil -} - -func (s *Store) Reserve(id string, ip net.IP) (bool, error) { - fname := filepath.Join(s.dataDir, ip.String()) - f, err := os.OpenFile(fname, os.O_RDWR|os.O_EXCL|os.O_CREATE, 0644) - if os.IsExist(err) { - return false, nil - } - if err != nil { - return false, err - } - if _, err := f.WriteString(id); err != nil { - f.Close() - os.Remove(f.Name()) - return false, err - } - if err := f.Close(); err != nil { - os.Remove(f.Name()) - return false, err - } - return true, nil -} - -func (s *Store) Release(ip net.IP) error { - return os.Remove(filepath.Join(s.dataDir, ip.String())) -} - -// N.B. This function eats errors to be tolerant and -// release as much as possible -func (s *Store) ReleaseByID(id string) error { - err := filepath.Walk(s.dataDir, func(path string, info os.FileInfo, err error) error { - if err != nil || info.IsDir() { - return nil - } - data, err := ioutil.ReadFile(path) - if err != nil { - return nil - } - if string(data) == id { - if err := os.Remove(path); err != nil { - return nil - } - } - return nil - }) - return err -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk/lock.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk/lock.go deleted file mode 100644 index 7241482515..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk/lock.go +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package disk - -import ( - "os" - "syscall" -) - -// FileLock wraps os.File to be used as a lock using flock -type FileLock struct { - f *os.File -} - -// NewFileLock opens file/dir at path and returns unlocked FileLock object -func NewFileLock(path string) (*FileLock, error) { - f, err := os.Open(path) - if err != nil { - return nil, err - } - - return &FileLock{f}, nil -} - -// Close closes underlying file -func (l *FileLock) Close() error { - return l.f.Close() -} - -// Lock acquires an exclusive lock -func (l *FileLock) Lock() error { - return syscall.Flock(int(l.f.Fd()), syscall.LOCK_EX) -} - -// Unlock releases the lock -func (l *FileLock) Unlock() error { - return syscall.Flock(int(l.f.Fd()), syscall.LOCK_UN) -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/backend/store.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/backend/store.go deleted file mode 100644 index 45a89b109c..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/backend/store.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package backend - -import "net" - -type Store interface { - Lock() error - Unlock() error - Close() error - Reserve(id string, ip net.IP) (bool, error) - Release(ip net.IP) error - ReleaseByID(id string) error -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/config.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/config.go deleted file mode 100644 index a0e493cd84..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/config.go +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "encoding/json" - "fmt" - "net" - - "github.com/containernetworking/cni/pkg/types" -) - -// IPAMConfig represents the IP related network configuration. -type IPAMConfig struct { - Name string - Type string `json:"type"` - RangeStart net.IP `json:"rangeStart"` - RangeEnd net.IP `json:"rangeEnd"` - Subnet types.IPNet `json:"subnet"` - Gateway net.IP `json:"gateway"` - Routes []types.Route `json:"routes"` - Args *IPAMArgs `json:"-"` -} - -type IPAMArgs struct { - types.CommonArgs - IP net.IP `json:"ip,omitempty"` -} - -type Net struct { - Name string `json:"name"` - IPAM *IPAMConfig `json:"ipam"` -} - -// NewIPAMConfig creates a NetworkConfig from the given network name. -func LoadIPAMConfig(bytes []byte, args string) (*IPAMConfig, error) { - n := Net{} - if err := json.Unmarshal(bytes, &n); err != nil { - return nil, err - } - - if args != "" { - n.IPAM.Args = &IPAMArgs{} - err := types.LoadArgs(args, n.IPAM.Args) - if err != nil { - return nil, err - } - } - - if n.IPAM == nil { - return nil, fmt.Errorf("%q missing 'ipam' key") - } - - // Copy net name into IPAM so not to drag Net struct around - n.IPAM.Name = n.Name - - return n.IPAM, nil -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/main.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/main.go deleted file mode 100644 index d2f3c305a5..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/ipam/host-local/main.go +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "github.com/containernetworking/cni/plugins/ipam/host-local/backend/disk" - - "github.com/containernetworking/cni/pkg/skel" - "github.com/containernetworking/cni/pkg/types" -) - -func main() { - skel.PluginMain(cmdAdd, cmdDel) -} - -func cmdAdd(args *skel.CmdArgs) error { - ipamConf, err := LoadIPAMConfig(args.StdinData, args.Args) - if err != nil { - return err - } - - store, err := disk.New(ipamConf.Name) - if err != nil { - return err - } - defer store.Close() - - allocator, err := NewIPAllocator(ipamConf, store) - if err != nil { - return err - } - - ipConf, err := allocator.Get(args.ContainerID) - if err != nil { - return err - } - - r := &types.Result{ - IP4: ipConf, - } - return r.Print() -} - -func cmdDel(args *skel.CmdArgs) error { - ipamConf, err := LoadIPAMConfig(args.StdinData, args.Args) - if err != nil { - return err - } - - store, err := disk.New(ipamConf.Name) - if err != nil { - return err - } - defer store.Close() - - allocator, err := NewIPAllocator(ipamConf, store) - if err != nil { - return err - } - - return allocator.Release(args.ContainerID) -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/bridge/bridge.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/bridge/bridge.go deleted file mode 100644 index d4fc89c3aa..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/bridge/bridge.go +++ /dev/null @@ -1,319 +0,0 @@ -// Copyright 2014 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "encoding/json" - "errors" - "fmt" - "net" - "runtime" - "syscall" - - "github.com/containernetworking/cni/pkg/ip" - "github.com/containernetworking/cni/pkg/ipam" - "github.com/containernetworking/cni/pkg/ns" - "github.com/containernetworking/cni/pkg/skel" - "github.com/containernetworking/cni/pkg/types" - "github.com/containernetworking/cni/pkg/utils" - "github.com/vishvananda/netlink" -) - -const defaultBrName = "cni0" - -type NetConf struct { - types.NetConf - BrName string `json:"bridge"` - IsGW bool `json:"isGateway"` - IsDefaultGW bool `json:"isDefaultGateway"` - IPMasq bool `json:"ipMasq"` - MTU int `json:"mtu"` - HairpinMode bool `json:"hairpinMode"` -} - -func init() { - // this ensures that main runs only on main thread (thread group leader). - // since namespace ops (unshare, setns) are done for a single thread, we - // must ensure that the goroutine does not jump from OS thread to thread - runtime.LockOSThread() -} - -func loadNetConf(bytes []byte) (*NetConf, error) { - n := &NetConf{ - BrName: defaultBrName, - } - if err := json.Unmarshal(bytes, n); err != nil { - return nil, fmt.Errorf("failed to load netconf: %v", err) - } - return n, nil -} - -func ensureBridgeAddr(br *netlink.Bridge, ipn *net.IPNet) error { - addrs, err := netlink.AddrList(br, syscall.AF_INET) - if err != nil && err != syscall.ENOENT { - return fmt.Errorf("could not get list of IP addresses: %v", err) - } - - // if there're no addresses on the bridge, it's ok -- we'll add one - if len(addrs) > 0 { - ipnStr := ipn.String() - for _, a := range addrs { - // string comp is actually easiest for doing IPNet comps - if a.IPNet.String() == ipnStr { - return nil - } - } - return fmt.Errorf("%q already has an IP address different from %v", br.Name, ipn.String()) - } - - addr := &netlink.Addr{IPNet: ipn, Label: ""} - if err := netlink.AddrAdd(br, addr); err != nil { - return fmt.Errorf("could not add IP address to %q: %v", br.Name, err) - } - return nil -} - -func bridgeByName(name string) (*netlink.Bridge, error) { - l, err := netlink.LinkByName(name) - if err != nil { - return nil, fmt.Errorf("could not lookup %q: %v", name, err) - } - br, ok := l.(*netlink.Bridge) - if !ok { - return nil, fmt.Errorf("%q already exists but is not a bridge", name) - } - return br, nil -} - -func ensureBridge(brName string, mtu int) (*netlink.Bridge, error) { - br := &netlink.Bridge{ - LinkAttrs: netlink.LinkAttrs{ - Name: brName, - MTU: mtu, - // Let kernel use default txqueuelen; leaving it unset - // means 0, and a zero-length TX queue messes up FIFO - // traffic shapers which use TX queue length as the - // default packet limit - TxQLen: -1, - }, - } - - if err := netlink.LinkAdd(br); err != nil { - if err != syscall.EEXIST { - return nil, fmt.Errorf("could not add %q: %v", brName, err) - } - - // it's ok if the device already exists as long as config is similar - br, err = bridgeByName(brName) - if err != nil { - return nil, err - } - } - - if err := netlink.LinkSetUp(br); err != nil { - return nil, err - } - - return br, nil -} - -func setupVeth(netns ns.NetNS, br *netlink.Bridge, ifName string, mtu int, hairpinMode bool) error { - var hostVethName string - - err := netns.Do(func(hostNS ns.NetNS) error { - // create the veth pair in the container and move host end into host netns - hostVeth, _, err := ip.SetupVeth(ifName, mtu, hostNS) - if err != nil { - return err - } - - hostVethName = hostVeth.Attrs().Name - return nil - }) - if err != nil { - return err - } - - // need to lookup hostVeth again as its index has changed during ns move - hostVeth, err := netlink.LinkByName(hostVethName) - if err != nil { - return fmt.Errorf("failed to lookup %q: %v", hostVethName, err) - } - - // connect host veth end to the bridge - if err = netlink.LinkSetMaster(hostVeth, br); err != nil { - return fmt.Errorf("failed to connect %q to bridge %v: %v", hostVethName, br.Attrs().Name, err) - } - - // set hairpin mode - if err = netlink.LinkSetHairpin(hostVeth, hairpinMode); err != nil { - return fmt.Errorf("failed to setup hairpin mode for %v: %v", hostVethName, err) - } - - return nil -} - -func calcGatewayIP(ipn *net.IPNet) net.IP { - nid := ipn.IP.Mask(ipn.Mask) - return ip.NextIP(nid) -} - -func setupBridge(n *NetConf) (*netlink.Bridge, error) { - // create bridge if necessary - br, err := ensureBridge(n.BrName, n.MTU) - if err != nil { - return nil, fmt.Errorf("failed to create bridge %q: %v", n.BrName, err) - } - - return br, nil -} - -func cmdAdd(args *skel.CmdArgs) error { - n, err := loadNetConf(args.StdinData) - if err != nil { - return err - } - - if n.IsDefaultGW { - n.IsGW = true - } - - br, err := setupBridge(n) - if err != nil { - return err - } - - netns, err := ns.GetNS(args.Netns) - if err != nil { - return fmt.Errorf("failed to open netns %q: %v", args.Netns, err) - } - defer netns.Close() - - if err = setupVeth(netns, br, args.IfName, n.MTU, n.HairpinMode); err != nil { - return err - } - - // run the IPAM plugin and get back the config to apply - result, err := ipam.ExecAdd(n.IPAM.Type, args.StdinData) - if err != nil { - return err - } - - // TODO: make this optional when IPv6 is supported - if result.IP4 == nil { - return errors.New("IPAM plugin returned missing IPv4 config") - } - - if result.IP4.Gateway == nil && n.IsGW { - result.IP4.Gateway = calcGatewayIP(&result.IP4.IP) - } - - if err := netns.Do(func(_ ns.NetNS) error { - // set the default gateway if requested - if n.IsDefaultGW { - _, defaultNet, err := net.ParseCIDR("0.0.0.0/0") - if err != nil { - return err - } - - for _, route := range result.IP4.Routes { - if defaultNet.String() == route.Dst.String() { - if route.GW != nil && !route.GW.Equal(result.IP4.Gateway) { - return fmt.Errorf( - "isDefaultGateway ineffective because IPAM sets default route via %q", - route.GW, - ) - } - } - } - - result.IP4.Routes = append( - result.IP4.Routes, - types.Route{Dst: *defaultNet, GW: result.IP4.Gateway}, - ) - - // TODO: IPV6 - } - - return ipam.ConfigureIface(args.IfName, result) - }); err != nil { - return err - } - - if n.IsGW { - gwn := &net.IPNet{ - IP: result.IP4.Gateway, - Mask: result.IP4.IP.Mask, - } - - if err = ensureBridgeAddr(br, gwn); err != nil { - return err - } - - if err := ip.EnableIP4Forward(); err != nil { - return fmt.Errorf("failed to enable forwarding: %v", err) - } - } - - if n.IPMasq { - chain := utils.FormatChainName(n.Name, args.ContainerID) - comment := utils.FormatComment(n.Name, args.ContainerID) - if err = ip.SetupIPMasq(ip.Network(&result.IP4.IP), chain, comment); err != nil { - return err - } - } - - result.DNS = n.DNS - return result.Print() -} - -func cmdDel(args *skel.CmdArgs) error { - n, err := loadNetConf(args.StdinData) - if err != nil { - return err - } - - if err := ipam.ExecDel(n.IPAM.Type, args.StdinData); err != nil { - return err - } - - if args.Netns == "" { - return nil - } - - var ipn *net.IPNet - err = ns.WithNetNSPath(args.Netns, func(_ ns.NetNS) error { - var err error - ipn, err = ip.DelLinkByNameAddr(args.IfName, netlink.FAMILY_V4) - return err - }) - if err != nil { - return err - } - - if n.IPMasq { - chain := utils.FormatChainName(n.Name, args.ContainerID) - comment := utils.FormatComment(n.Name, args.ContainerID) - if err = ip.TeardownIPMasq(ipn, chain, comment); err != nil { - return err - } - } - - return nil -} - -func main() { - skel.PluginMain(cmdAdd, cmdDel) -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/ipvlan/ipvlan.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/ipvlan/ipvlan.go deleted file mode 100644 index d7cfc39f4e..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/ipvlan/ipvlan.go +++ /dev/null @@ -1,175 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "encoding/json" - "errors" - "fmt" - "runtime" - - "github.com/containernetworking/cni/pkg/ip" - "github.com/containernetworking/cni/pkg/ipam" - "github.com/containernetworking/cni/pkg/ns" - "github.com/containernetworking/cni/pkg/skel" - "github.com/containernetworking/cni/pkg/types" - "github.com/vishvananda/netlink" -) - -type NetConf struct { - types.NetConf - Master string `json:"master"` - Mode string `json:"mode"` - MTU int `json:"mtu"` -} - -func init() { - // this ensures that main runs only on main thread (thread group leader). - // since namespace ops (unshare, setns) are done for a single thread, we - // must ensure that the goroutine does not jump from OS thread to thread - runtime.LockOSThread() -} - -func loadConf(bytes []byte) (*NetConf, error) { - n := &NetConf{} - if err := json.Unmarshal(bytes, n); err != nil { - return nil, fmt.Errorf("failed to load netconf: %v", err) - } - if n.Master == "" { - return nil, fmt.Errorf(`"master" field is required. It specifies the host interface name to virtualize`) - } - return n, nil -} - -func modeFromString(s string) (netlink.IPVlanMode, error) { - switch s { - case "", "l2": - return netlink.IPVLAN_MODE_L2, nil - case "l3": - return netlink.IPVLAN_MODE_L3, nil - default: - return 0, fmt.Errorf("unknown ipvlan mode: %q", s) - } -} - -func createIpvlan(conf *NetConf, ifName string, netns ns.NetNS) error { - mode, err := modeFromString(conf.Mode) - if err != nil { - return err - } - - m, err := netlink.LinkByName(conf.Master) - if err != nil { - return fmt.Errorf("failed to lookup master %q: %v", conf.Master, err) - } - - // due to kernel bug we have to create with tmpname or it might - // collide with the name on the host and error out - tmpName, err := ip.RandomVethName() - if err != nil { - return err - } - - mv := &netlink.IPVlan{ - LinkAttrs: netlink.LinkAttrs{ - MTU: conf.MTU, - Name: tmpName, - ParentIndex: m.Attrs().Index, - Namespace: netlink.NsFd(int(netns.Fd())), - }, - Mode: mode, - } - - if err := netlink.LinkAdd(mv); err != nil { - return fmt.Errorf("failed to create ipvlan: %v", err) - } - - return netns.Do(func(_ ns.NetNS) error { - err := renameLink(tmpName, ifName) - if err != nil { - return fmt.Errorf("failed to rename ipvlan to %q: %v", ifName, err) - } - return nil - }) -} - -func cmdAdd(args *skel.CmdArgs) error { - n, err := loadConf(args.StdinData) - if err != nil { - return err - } - - netns, err := ns.GetNS(args.Netns) - if err != nil { - return fmt.Errorf("failed to open netns %q: %v", args.Netns, err) - } - defer netns.Close() - - if err = createIpvlan(n, args.IfName, netns); err != nil { - return err - } - - // run the IPAM plugin and get back the config to apply - result, err := ipam.ExecAdd(n.IPAM.Type, args.StdinData) - if err != nil { - return err - } - if result.IP4 == nil { - return errors.New("IPAM plugin returned missing IPv4 config") - } - - err = netns.Do(func(_ ns.NetNS) error { - return ipam.ConfigureIface(args.IfName, result) - }) - if err != nil { - return err - } - - result.DNS = n.DNS - return result.Print() -} - -func cmdDel(args *skel.CmdArgs) error { - n, err := loadConf(args.StdinData) - if err != nil { - return err - } - - err = ipam.ExecDel(n.IPAM.Type, args.StdinData) - if err != nil { - return err - } - - if args.Netns == "" { - return nil - } - - return ns.WithNetNSPath(args.Netns, func(_ ns.NetNS) error { - return ip.DelLinkByName(args.IfName) - }) -} - -func renameLink(curName, newName string) error { - link, err := netlink.LinkByName(curName) - if err != nil { - return err - } - - return netlink.LinkSetName(link, newName) -} - -func main() { - skel.PluginMain(cmdAdd, cmdDel) -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/macvlan/macvlan.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/macvlan/macvlan.go deleted file mode 100644 index 7739d7b8eb..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/macvlan/macvlan.go +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "encoding/json" - "errors" - "fmt" - "runtime" - - "github.com/containernetworking/cni/pkg/ip" - "github.com/containernetworking/cni/pkg/ipam" - "github.com/containernetworking/cni/pkg/ns" - "github.com/containernetworking/cni/pkg/skel" - "github.com/containernetworking/cni/pkg/types" - "github.com/containernetworking/cni/pkg/utils/sysctl" - "github.com/vishvananda/netlink" -) - -const ( - IPv4InterfaceArpProxySysctlTemplate = "net.ipv4.conf.%s.proxy_arp" -) - -type NetConf struct { - types.NetConf - Master string `json:"master"` - Mode string `json:"mode"` - MTU int `json:"mtu"` -} - -func init() { - // this ensures that main runs only on main thread (thread group leader). - // since namespace ops (unshare, setns) are done for a single thread, we - // must ensure that the goroutine does not jump from OS thread to thread - runtime.LockOSThread() -} - -func loadConf(bytes []byte) (*NetConf, error) { - n := &NetConf{} - if err := json.Unmarshal(bytes, n); err != nil { - return nil, fmt.Errorf("failed to load netconf: %v", err) - } - if n.Master == "" { - return nil, fmt.Errorf(`"master" field is required. It specifies the host interface name to virtualize`) - } - return n, nil -} - -func modeFromString(s string) (netlink.MacvlanMode, error) { - switch s { - case "", "bridge": - return netlink.MACVLAN_MODE_BRIDGE, nil - case "private": - return netlink.MACVLAN_MODE_PRIVATE, nil - case "vepa": - return netlink.MACVLAN_MODE_VEPA, nil - case "passthru": - return netlink.MACVLAN_MODE_PASSTHRU, nil - default: - return 0, fmt.Errorf("unknown macvlan mode: %q", s) - } -} - -func createMacvlan(conf *NetConf, ifName string, netns ns.NetNS) error { - mode, err := modeFromString(conf.Mode) - if err != nil { - return err - } - - m, err := netlink.LinkByName(conf.Master) - if err != nil { - return fmt.Errorf("failed to lookup master %q: %v", conf.Master, err) - } - - // due to kernel bug we have to create with tmpName or it might - // collide with the name on the host and error out - tmpName, err := ip.RandomVethName() - if err != nil { - return err - } - - mv := &netlink.Macvlan{ - LinkAttrs: netlink.LinkAttrs{ - MTU: conf.MTU, - Name: tmpName, - ParentIndex: m.Attrs().Index, - Namespace: netlink.NsFd(int(netns.Fd())), - }, - Mode: mode, - } - - if err := netlink.LinkAdd(mv); err != nil { - return fmt.Errorf("failed to create macvlan: %v", err) - } - - return netns.Do(func(_ ns.NetNS) error { - // TODO: duplicate following lines for ipv6 support, when it will be added in other places - ipv4SysctlValueName := fmt.Sprintf(IPv4InterfaceArpProxySysctlTemplate, tmpName) - if _, err := sysctl.Sysctl(ipv4SysctlValueName, "1"); err != nil { - // remove the newly added link and ignore errors, because we already are in a failed state - _ = netlink.LinkDel(mv) - return fmt.Errorf("failed to set proxy_arp on newly added interface %q: %v", tmpName, err) - } - - err := renameLink(tmpName, ifName) - if err != nil { - _ = netlink.LinkDel(mv) - return fmt.Errorf("failed to rename macvlan to %q: %v", ifName, err) - } - return nil - }) -} - -func cmdAdd(args *skel.CmdArgs) error { - n, err := loadConf(args.StdinData) - if err != nil { - return err - } - - netns, err := ns.GetNS(args.Netns) - if err != nil { - return fmt.Errorf("failed to open netns %q: %v", netns, err) - } - defer netns.Close() - - if err = createMacvlan(n, args.IfName, netns); err != nil { - return err - } - - // run the IPAM plugin and get back the config to apply - result, err := ipam.ExecAdd(n.IPAM.Type, args.StdinData) - if err != nil { - return err - } - if result.IP4 == nil { - return errors.New("IPAM plugin returned missing IPv4 config") - } - - err = netns.Do(func(_ ns.NetNS) error { - return ipam.ConfigureIface(args.IfName, result) - }) - if err != nil { - return err - } - - result.DNS = n.DNS - return result.Print() -} - -func cmdDel(args *skel.CmdArgs) error { - n, err := loadConf(args.StdinData) - if err != nil { - return err - } - - err = ipam.ExecDel(n.IPAM.Type, args.StdinData) - if err != nil { - return err - } - - if args.Netns == "" { - return nil - } - - return ns.WithNetNSPath(args.Netns, func(_ ns.NetNS) error { - return ip.DelLinkByName(args.IfName) - }) -} - -func renameLink(curName, newName string) error { - link, err := netlink.LinkByName(curName) - if err != nil { - return err - } - - return netlink.LinkSetName(link, newName) -} - -func main() { - skel.PluginMain(cmdAdd, cmdDel) -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/ptp/ptp.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/ptp/ptp.go deleted file mode 100644 index aa695e39e2..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/main/ptp/ptp.go +++ /dev/null @@ -1,229 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "encoding/json" - "errors" - "fmt" - "net" - "os" - "runtime" - - "github.com/vishvananda/netlink" - - "github.com/containernetworking/cni/pkg/ip" - "github.com/containernetworking/cni/pkg/ipam" - "github.com/containernetworking/cni/pkg/ns" - "github.com/containernetworking/cni/pkg/skel" - "github.com/containernetworking/cni/pkg/types" - "github.com/containernetworking/cni/pkg/utils" -) - -func init() { - // this ensures that main runs only on main thread (thread group leader). - // since namespace ops (unshare, setns) are done for a single thread, we - // must ensure that the goroutine does not jump from OS thread to thread - runtime.LockOSThread() -} - -type NetConf struct { - types.NetConf - IPMasq bool `json:"ipMasq"` - MTU int `json:"mtu"` -} - -func setupContainerVeth(netns, ifName string, mtu int, pr *types.Result) (string, error) { - // The IPAM result will be something like IP=192.168.3.5/24, GW=192.168.3.1. - // What we want is really a point-to-point link but veth does not support IFF_POINTOPONT. - // Next best thing would be to let it ARP but set interface to 192.168.3.5/32 and - // add a route like "192.168.3.0/24 via 192.168.3.1 dev $ifName". - // Unfortunately that won't work as the GW will be outside the interface's subnet. - - // Our solution is to configure the interface with 192.168.3.5/24, then delete the - // "192.168.3.0/24 dev $ifName" route that was automatically added. Then we add - // "192.168.3.1/32 dev $ifName" and "192.168.3.0/24 via 192.168.3.1 dev $ifName". - // In other words we force all traffic to ARP via the gateway except for GW itself. - - var hostVethName string - err := ns.WithNetNSPath(netns, func(hostNS ns.NetNS) error { - hostVeth, _, err := ip.SetupVeth(ifName, mtu, hostNS) - if err != nil { - return err - } - - if err = ipam.ConfigureIface(ifName, pr); err != nil { - return err - } - - contVeth, err := netlink.LinkByName(ifName) - if err != nil { - return fmt.Errorf("failed to look up %q: %v", ifName, err) - } - - // Delete the route that was automatically added - route := netlink.Route{ - LinkIndex: contVeth.Attrs().Index, - Dst: &net.IPNet{ - IP: pr.IP4.IP.IP.Mask(pr.IP4.IP.Mask), - Mask: pr.IP4.IP.Mask, - }, - Scope: netlink.SCOPE_NOWHERE, - } - - if err := netlink.RouteDel(&route); err != nil { - return fmt.Errorf("failed to delete route %v: %v", route, err) - } - - for _, r := range []netlink.Route{ - netlink.Route{ - LinkIndex: contVeth.Attrs().Index, - Dst: &net.IPNet{ - IP: pr.IP4.Gateway, - Mask: net.CIDRMask(32, 32), - }, - Scope: netlink.SCOPE_LINK, - Src: pr.IP4.IP.IP, - }, - netlink.Route{ - LinkIndex: contVeth.Attrs().Index, - Dst: &net.IPNet{ - IP: pr.IP4.IP.IP.Mask(pr.IP4.IP.Mask), - Mask: pr.IP4.IP.Mask, - }, - Scope: netlink.SCOPE_UNIVERSE, - Gw: pr.IP4.Gateway, - Src: pr.IP4.IP.IP, - }, - } { - if err := netlink.RouteAdd(&r); err != nil { - return fmt.Errorf("failed to add route %v: %v", r, err) - } - } - - hostVethName = hostVeth.Attrs().Name - - return nil - }) - return hostVethName, err -} - -func setupHostVeth(vethName string, ipConf *types.IPConfig) error { - // hostVeth moved namespaces and may have a new ifindex - veth, err := netlink.LinkByName(vethName) - if err != nil { - return fmt.Errorf("failed to lookup %q: %v", vethName, err) - } - - // TODO(eyakubovich): IPv6 - ipn := &net.IPNet{ - IP: ipConf.Gateway, - Mask: net.CIDRMask(32, 32), - } - addr := &netlink.Addr{IPNet: ipn, Label: ""} - if err = netlink.AddrAdd(veth, addr); err != nil { - return fmt.Errorf("failed to add IP addr (%#v) to veth: %v", ipn, err) - } - - ipn = &net.IPNet{ - IP: ipConf.IP.IP, - Mask: net.CIDRMask(32, 32), - } - // dst happens to be the same as IP/net of host veth - if err = ip.AddHostRoute(ipn, nil, veth); err != nil && !os.IsExist(err) { - return fmt.Errorf("failed to add route on host: %v", err) - } - - return nil -} - -func cmdAdd(args *skel.CmdArgs) error { - conf := NetConf{} - if err := json.Unmarshal(args.StdinData, &conf); err != nil { - return fmt.Errorf("failed to load netconf: %v", err) - } - - if err := ip.EnableIP4Forward(); err != nil { - return fmt.Errorf("failed to enable forwarding: %v", err) - } - - // run the IPAM plugin and get back the config to apply - result, err := ipam.ExecAdd(conf.IPAM.Type, args.StdinData) - if err != nil { - return err - } - if result.IP4 == nil { - return errors.New("IPAM plugin returned missing IPv4 config") - } - - hostVethName, err := setupContainerVeth(args.Netns, args.IfName, conf.MTU, result) - if err != nil { - return err - } - - if err = setupHostVeth(hostVethName, result.IP4); err != nil { - return err - } - - if conf.IPMasq { - chain := utils.FormatChainName(conf.Name, args.ContainerID) - comment := utils.FormatComment(conf.Name, args.ContainerID) - if err = ip.SetupIPMasq(&result.IP4.IP, chain, comment); err != nil { - return err - } - } - - result.DNS = conf.DNS - return result.Print() -} - -func cmdDel(args *skel.CmdArgs) error { - conf := NetConf{} - if err := json.Unmarshal(args.StdinData, &conf); err != nil { - return fmt.Errorf("failed to load netconf: %v", err) - } - - if err := ipam.ExecDel(conf.IPAM.Type, args.StdinData); err != nil { - return err - } - - if args.Netns == "" { - return nil - } - - var ipn *net.IPNet - err := ns.WithNetNSPath(args.Netns, func(_ ns.NetNS) error { - var err error - ipn, err = ip.DelLinkByNameAddr(args.IfName, netlink.FAMILY_V4) - return err - }) - if err != nil { - return err - } - - if conf.IPMasq { - chain := utils.FormatChainName(conf.Name, args.ContainerID) - comment := utils.FormatComment(conf.Name, args.ContainerID) - if err = ip.TeardownIPMasq(ipn, chain, comment); err != nil { - return err - } - } - - return nil -} - -func main() { - skel.PluginMain(cmdAdd, cmdDel) -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/meta/flannel/flannel.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/meta/flannel/flannel.go deleted file mode 100644 index 096fe6d677..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/meta/flannel/flannel.go +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright 2015 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// This is a "meta-plugin". It reads in its own netconf, combines it with -// the data from flannel generated subnet file and then invokes a plugin -// like bridge or ipvlan to do the real work. - -package main - -import ( - "bufio" - "encoding/json" - "fmt" - "io/ioutil" - "net" - "os" - "path/filepath" - "strconv" - "strings" - - "github.com/containernetworking/cni/pkg/invoke" - "github.com/containernetworking/cni/pkg/skel" - "github.com/containernetworking/cni/pkg/types" -) - -const ( - defaultSubnetFile = "/run/flannel/subnet.env" - stateDir = "/var/lib/cni/flannel" -) - -type NetConf struct { - types.NetConf - SubnetFile string `json:"subnetFile"` - Delegate map[string]interface{} `json:"delegate"` -} - -type subnetEnv struct { - nw *net.IPNet - sn *net.IPNet - mtu *uint - ipmasq *bool -} - -func (se *subnetEnv) missing() string { - m := []string{} - - if se.nw == nil { - m = append(m, "FLANNEL_NETWORK") - } - if se.sn == nil { - m = append(m, "FLANNEL_SUBNET") - } - if se.mtu == nil { - m = append(m, "FLANNEL_MTU") - } - if se.ipmasq == nil { - m = append(m, "FLANNEL_IPMASQ") - } - return strings.Join(m, ", ") -} - -func loadFlannelNetConf(bytes []byte) (*NetConf, error) { - n := &NetConf{ - SubnetFile: defaultSubnetFile, - } - if err := json.Unmarshal(bytes, n); err != nil { - return nil, fmt.Errorf("failed to load netconf: %v", err) - } - return n, nil -} - -func loadFlannelSubnetEnv(fn string) (*subnetEnv, error) { - f, err := os.Open(fn) - if err != nil { - return nil, err - } - defer f.Close() - - se := &subnetEnv{} - - s := bufio.NewScanner(f) - for s.Scan() { - parts := strings.SplitN(s.Text(), "=", 2) - switch parts[0] { - case "FLANNEL_NETWORK": - _, se.nw, err = net.ParseCIDR(parts[1]) - if err != nil { - return nil, err - } - - case "FLANNEL_SUBNET": - _, se.sn, err = net.ParseCIDR(parts[1]) - if err != nil { - return nil, err - } - - case "FLANNEL_MTU": - mtu, err := strconv.ParseUint(parts[1], 10, 32) - if err != nil { - return nil, err - } - se.mtu = new(uint) - *se.mtu = uint(mtu) - - case "FLANNEL_IPMASQ": - ipmasq := parts[1] == "true" - se.ipmasq = &ipmasq - } - } - if err := s.Err(); err != nil { - return nil, err - } - - if m := se.missing(); m != "" { - return nil, fmt.Errorf("%v is missing %v", fn, m) - } - - return se, nil -} - -func saveScratchNetConf(containerID string, netconf []byte) error { - if err := os.MkdirAll(stateDir, 0700); err != nil { - return err - } - path := filepath.Join(stateDir, containerID) - return ioutil.WriteFile(path, netconf, 0600) -} - -func consumeScratchNetConf(containerID string) ([]byte, error) { - path := filepath.Join(stateDir, containerID) - defer os.Remove(path) - - return ioutil.ReadFile(path) -} - -func delegateAdd(cid string, netconf map[string]interface{}) error { - netconfBytes, err := json.Marshal(netconf) - if err != nil { - return fmt.Errorf("error serializing delegate netconf: %v", err) - } - - // save the rendered netconf for cmdDel - if err = saveScratchNetConf(cid, netconfBytes); err != nil { - return err - } - - result, err := invoke.DelegateAdd(netconf["type"].(string), netconfBytes) - if err != nil { - return err - } - - return result.Print() -} - -func hasKey(m map[string]interface{}, k string) bool { - _, ok := m[k] - return ok -} - -func isString(i interface{}) bool { - _, ok := i.(string) - return ok -} - -func cmdAdd(args *skel.CmdArgs) error { - n, err := loadFlannelNetConf(args.StdinData) - if err != nil { - return err - } - - fenv, err := loadFlannelSubnetEnv(n.SubnetFile) - if err != nil { - return err - } - - if n.Delegate == nil { - n.Delegate = make(map[string]interface{}) - } else { - if hasKey(n.Delegate, "type") && !isString(n.Delegate["type"]) { - return fmt.Errorf("'delegate' dictionary, if present, must have (string) 'type' field") - } - if hasKey(n.Delegate, "name") { - return fmt.Errorf("'delegate' dictionary must not have 'name' field, it'll be set by flannel") - } - if hasKey(n.Delegate, "ipam") { - return fmt.Errorf("'delegate' dictionary must not have 'ipam' field, it'll be set by flannel") - } - } - - n.Delegate["name"] = n.Name - - if !hasKey(n.Delegate, "type") { - n.Delegate["type"] = "bridge" - } - - if !hasKey(n.Delegate, "ipMasq") { - // if flannel is not doing ipmasq, we should - ipmasq := !*fenv.ipmasq - n.Delegate["ipMasq"] = ipmasq - } - - if !hasKey(n.Delegate, "mtu") { - mtu := fenv.mtu - n.Delegate["mtu"] = mtu - } - - if n.Delegate["type"].(string) == "bridge" { - if !hasKey(n.Delegate, "isGateway") { - n.Delegate["isGateway"] = true - } - } - - n.Delegate["ipam"] = map[string]interface{}{ - "type": "host-local", - "subnet": fenv.sn.String(), - "routes": []types.Route{ - types.Route{ - Dst: *fenv.nw, - }, - }, - } - - return delegateAdd(args.ContainerID, n.Delegate) -} - -func cmdDel(args *skel.CmdArgs) error { - netconfBytes, err := consumeScratchNetConf(args.ContainerID) - if err != nil { - return err - } - - n := &types.NetConf{} - if err = json.Unmarshal(netconfBytes, n); err != nil { - return fmt.Errorf("failed to parse netconf: %v", err) - } - - return invoke.DelegateDel(n.Type, netconfBytes) -} - -func main() { - skel.PluginMain(cmdAdd, cmdDel) -} diff --git a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/meta/tuning/tuning.go b/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/meta/tuning/tuning.go deleted file mode 100644 index 75ba852c00..0000000000 --- a/Godeps/_workspace/src/github.com/containernetworking/cni/plugins/meta/tuning/tuning.go +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2016 CNI authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// This is a "meta-plugin". It reads in its own netconf, it does not create -// any network interface but just changes the network sysctl. - -package main - -import ( - "encoding/json" - "fmt" - "io/ioutil" - "path/filepath" - "strings" - - "github.com/containernetworking/cni/pkg/ns" - "github.com/containernetworking/cni/pkg/skel" - "github.com/containernetworking/cni/pkg/types" -) - -// TuningConf represents the network tuning configuration. -type TuningConf struct { - types.NetConf - SysCtl map[string]string `json:"sysctl"` -} - -func cmdAdd(args *skel.CmdArgs) error { - tuningConf := TuningConf{} - if err := json.Unmarshal(args.StdinData, &tuningConf); err != nil { - return fmt.Errorf("failed to load netconf: %v", err) - } - - // The directory /proc/sys/net is per network namespace. Enter in the - // network namespace before writing on it. - - err := ns.WithNetNSPath(args.Netns, func(_ ns.NetNS) error { - for key, value := range tuningConf.SysCtl { - fileName := filepath.Join("/proc/sys", strings.Replace(key, ".", "/", -1)) - fileName = filepath.Clean(fileName) - - // Refuse to modify sysctl parameters that don't belong - // to the network subsystem. - if !strings.HasPrefix(fileName, "/proc/sys/net/") { - return fmt.Errorf("invalid net sysctl key: %q", key) - } - content := []byte(value) - err := ioutil.WriteFile(fileName, content, 0644) - if err != nil { - return err - } - } - return nil - }) - if err != nil { - return err - } - - result := types.Result{} - return result.Print() -} - -func cmdDel(args *skel.CmdArgs) error { - // TODO: the settings are not reverted to the previous values. Reverting the - // settings is not useful when the whole container goes away but it could be - // useful in scenarios where plugins are added and removed at runtime. - return nil -} - -func main() { - skel.PluginMain(cmdAdd, cmdDel) -} diff --git a/Godeps/_workspace/src/github.com/coreos/gexpect/LICENCE b/Godeps/_workspace/src/github.com/coreos/gexpect/LICENCE deleted file mode 100644 index 50adb0f19c..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/gexpect/LICENCE +++ /dev/null @@ -1,7 +0,0 @@ -Copyright (C) 2014 Thomas Rooney - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/Godeps/_workspace/src/github.com/coreos/gexpect/README.md b/Godeps/_workspace/src/github.com/coreos/gexpect/README.md deleted file mode 100644 index 2f9a8b7ee4..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/gexpect/README.md +++ /dev/null @@ -1,64 +0,0 @@ -# Gexpect - -Gexpect is a pure golang expect-like module. - -It makes it simpler to create and control other terminal applications. - - child, err := gexpect.Spawn("python") - if err != nil { - panic(err) - } - child.Expect(">>>") - child.SendLine("print 'Hello World'") - child.Interact() - child.Close() - -## Examples - -`Spawn` handles the argument parsing from a string - - child.Spawn("/bin/sh -c 'echo \"my complicated command\" | tee log | cat > log2'") - child.ReadLine() // ReadLine() (string, error) - child.ReadUntil(' ') // ReadUntil(delim byte) ([]byte, error) - -`ReadLine`, `ReadUntil` and `SendLine` send strings from/to `stdout/stdin` respectively - - child := gexpect.Spawn("cat") - child.SendLine("echoing process_stdin") // SendLine(command string) (error) - msg, _ := child.ReadLine() // msg = echoing process_stdin - -`Wait` and `Close` allow for graceful and ungraceful termination. - - child.Wait() // Waits until the child terminates naturally. - child.Close() // Sends a kill command - -`AsyncInteractChannels` spawns two go routines to pipe into and from `stdout`/`stdin`, allowing for some usecases to be a little simpler. - - child := gexpect.spawn("sh") - sender, receiver := child.AsyncInteractChannels() - sender <- "echo Hello World\n" // Send to stdin - line, open := <- receiver // Recieve a line from stdout/stderr - // When the subprocess stops (e.g. with child.Close()) , receiver is closed - if open { - fmt.Printf("Received %s", line)] - } - -`ExpectRegex` uses golang's internal regex engine to wait until a match from the process with the given regular expression (or an error on process termination with no match). - - child := gexpect.Spawn("echo accb") - match, _ := child.ExpectRegex("a..b") - // (match=true) - -`ExpectRegexFind` allows for groups to be extracted from process stdout. The first element is an array of containing the total matched text, followed by each subexpression group match. - - child := gexpect.Spawn("echo 123 456 789") - result, _ := child.ExpectRegexFind("\d+ (\d+) (\d+)") - // result = []string{"123 456 789", "456", "789"} - -See `gexpect_test.go` and the `examples` folder for full syntax - -## Credits - - github.com/kballard/go-shellquote - github.com/kr/pty - KMP Algorithm: "http://blog.databigbang.com/searching-for-substrings-in-streams-a-slight-modification-of-the-knuth-morris-pratt-algorithm-in-haxe/" \ No newline at end of file diff --git a/Godeps/_workspace/src/github.com/coreos/gexpect/gexpect.go b/Godeps/_workspace/src/github.com/coreos/gexpect/gexpect.go deleted file mode 100644 index 4ea620ef6e..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/gexpect/gexpect.go +++ /dev/null @@ -1,449 +0,0 @@ -// +build !windows - -package gexpect - -import ( - "bytes" - "errors" - "fmt" - "io" - "os" - "os/exec" - "regexp" - "time" - "unicode/utf8" - - shell "github.com/kballard/go-shellquote" - "github.com/kr/pty" -) - -var ( - ErrEmptySearch = errors.New("empty search string") -) - -type ExpectSubprocess struct { - Cmd *exec.Cmd - buf *buffer - outputBuffer []byte -} - -type buffer struct { - f *os.File - b bytes.Buffer - collect bool - - collection bytes.Buffer -} - -func (buf *buffer) StartCollecting() { - buf.collect = true -} - -func (buf *buffer) StopCollecting() (result string) { - result = string(buf.collection.Bytes()) - buf.collect = false - buf.collection.Reset() - return result -} - -func (buf *buffer) Read(chunk []byte) (int, error) { - nread := 0 - if buf.b.Len() > 0 { - n, err := buf.b.Read(chunk) - if err != nil { - return n, err - } - if n == len(chunk) { - return n, nil - } - nread = n - } - fn, err := buf.f.Read(chunk[nread:]) - return fn + nread, err -} - -func (buf *buffer) ReadRune() (r rune, size int, err error) { - l := buf.b.Len() - - chunk := make([]byte, utf8.UTFMax) - if l > 0 { - n, err := buf.b.Read(chunk) - if err != nil { - return 0, 0, err - } - if utf8.FullRune(chunk[:n]) { - r, rL := utf8.DecodeRune(chunk) - if n > rL { - buf.PutBack(chunk[rL:n]) - } - if buf.collect { - buf.collection.WriteRune(r) - } - return r, rL, nil - } - } - // else add bytes from the file, then try that - for l < utf8.UTFMax { - fn, err := buf.f.Read(chunk[l : l+1]) - if err != nil { - return 0, 0, err - } - l = l + fn - - if utf8.FullRune(chunk[:l]) { - r, rL := utf8.DecodeRune(chunk) - if buf.collect { - buf.collection.WriteRune(r) - } - return r, rL, nil - } - } - return 0, 0, errors.New("File is not a valid UTF=8 encoding") -} - -func (buf *buffer) PutBack(chunk []byte) { - if len(chunk) == 0 { - return - } - if buf.b.Len() == 0 { - buf.b.Write(chunk) - return - } - d := make([]byte, 0, len(chunk)+buf.b.Len()) - d = append(d, chunk...) - d = append(d, buf.b.Bytes()...) - buf.b.Reset() - buf.b.Write(d) -} - -func SpawnAtDirectory(command string, directory string) (*ExpectSubprocess, error) { - expect, err := _spawn(command) - if err != nil { - return nil, err - } - expect.Cmd.Dir = directory - return _start(expect) -} - -func Command(command string) (*ExpectSubprocess, error) { - expect, err := _spawn(command) - if err != nil { - return nil, err - } - return expect, nil -} - -func (expect *ExpectSubprocess) Start() error { - _, err := _start(expect) - return err -} - -func Spawn(command string) (*ExpectSubprocess, error) { - expect, err := _spawn(command) - if err != nil { - return nil, err - } - return _start(expect) -} - -func (expect *ExpectSubprocess) Close() error { - if err := expect.Cmd.Process.Kill(); err != nil { - return err - } - if err := expect.buf.f.Close(); err != nil { - return err - } - return nil -} - -func (expect *ExpectSubprocess) AsyncInteractChannels() (send chan string, receive chan string) { - receive = make(chan string) - send = make(chan string) - - go func() { - for { - str, err := expect.ReadLine() - if err != nil { - close(receive) - return - } - receive <- str - } - }() - - go func() { - for { - select { - case sendCommand, exists := <-send: - { - if !exists { - return - } - err := expect.Send(sendCommand) - if err != nil { - receive <- "gexpect Error: " + err.Error() - return - } - } - } - } - }() - - return -} - -func (expect *ExpectSubprocess) ExpectRegex(regex string) (bool, error) { - return regexp.MatchReader(regex, expect.buf) -} - -func (expect *ExpectSubprocess) expectRegexFind(regex string, output bool) ([]string, string, error) { - re, err := regexp.Compile(regex) - if err != nil { - return nil, "", err - } - expect.buf.StartCollecting() - pairs := re.FindReaderSubmatchIndex(expect.buf) - stringIndexedInto := expect.buf.StopCollecting() - l := len(pairs) - numPairs := l / 2 - result := make([]string, numPairs) - for i := 0; i < numPairs; i += 1 { - result[i] = stringIndexedInto[pairs[i*2]:pairs[i*2+1]] - } - // convert indexes to strings - - if len(result) == 0 { - err = fmt.Errorf("ExpectRegex didn't find regex '%v'.", regex) - } else { - // The number in pairs[1] is an index of a first - // character outside the whole match - putBackIdx := pairs[1] - if len(stringIndexedInto) > putBackIdx { - stringToPutBack := stringIndexedInto[putBackIdx:] - stringIndexedInto = stringIndexedInto[:putBackIdx] - expect.buf.PutBack([]byte(stringToPutBack)) - } - } - return result, stringIndexedInto, err -} - -func (expect *ExpectSubprocess) expectTimeoutRegexFind(regex string, timeout time.Duration) (result []string, out string, err error) { - t := make(chan bool) - go func() { - result, out, err = expect.ExpectRegexFindWithOutput(regex) - t <- false - }() - go func() { - time.Sleep(timeout) - err = fmt.Errorf("ExpectRegex timed out after %v finding '%v'.\nOutput:\n%s", timeout, regex, expect.Collect()) - t <- true - }() - <-t - return result, out, err -} - -func (expect *ExpectSubprocess) ExpectRegexFind(regex string) ([]string, error) { - result, _, err := expect.expectRegexFind(regex, false) - return result, err -} - -func (expect *ExpectSubprocess) ExpectTimeoutRegexFind(regex string, timeout time.Duration) ([]string, error) { - result, _, err := expect.expectTimeoutRegexFind(regex, timeout) - return result, err -} - -func (expect *ExpectSubprocess) ExpectRegexFindWithOutput(regex string) ([]string, string, error) { - return expect.expectRegexFind(regex, true) -} - -func (expect *ExpectSubprocess) ExpectTimeoutRegexFindWithOutput(regex string, timeout time.Duration) ([]string, string, error) { - return expect.expectTimeoutRegexFind(regex, timeout) -} - -func buildKMPTable(searchString string) []int { - pos := 2 - cnd := 0 - length := len(searchString) - - var table []int - if length < 2 { - length = 2 - } - - table = make([]int, length) - table[0] = -1 - table[1] = 0 - - for pos < len(searchString) { - if searchString[pos-1] == searchString[cnd] { - cnd += 1 - table[pos] = cnd - pos += 1 - } else if cnd > 0 { - cnd = table[cnd] - } else { - table[pos] = 0 - pos += 1 - } - } - return table -} - -func (expect *ExpectSubprocess) ExpectTimeout(searchString string, timeout time.Duration) (e error) { - result := make(chan error) - go func() { - result <- expect.Expect(searchString) - }() - select { - case e = <-result: - case <-time.After(timeout): - e = fmt.Errorf("Expect timed out after %v waiting for '%v'.\nOutput:\n%s", timeout, searchString, expect.Collect()) - } - return e -} - -func (expect *ExpectSubprocess) Expect(searchString string) (e error) { - target := len(searchString) - if target < 1 { - return ErrEmptySearch - } - chunk := make([]byte, target*2) - if expect.outputBuffer != nil { - expect.outputBuffer = expect.outputBuffer[0:] - } - m := 0 - i := 0 - // Build KMP Table - table := buildKMPTable(searchString) - - for { - n, err := expect.buf.Read(chunk) - if err != nil { - return err - } - if expect.outputBuffer != nil { - expect.outputBuffer = append(expect.outputBuffer, chunk[:n]...) - } - offset := m + i - for m+i-offset < n { - if searchString[i] == chunk[m+i-offset] { - i += 1 - if i == target { - unreadIndex := m + i - offset - if len(chunk) > unreadIndex { - expect.buf.PutBack(chunk[unreadIndex:n]) - } - return nil - } - } else { - m += i - table[i] - if table[i] > -1 { - i = table[i] - } else { - i = 0 - } - } - } - } -} - -func (expect *ExpectSubprocess) Send(command string) error { - _, err := io.WriteString(expect.buf.f, command) - return err -} - -func (expect *ExpectSubprocess) Capture() { - if expect.outputBuffer == nil { - expect.outputBuffer = make([]byte, 0) - } -} - -func (expect *ExpectSubprocess) Collect() []byte { - collectOutput := make([]byte, len(expect.outputBuffer)) - copy(collectOutput, expect.outputBuffer) - expect.outputBuffer = nil - return collectOutput -} - -func (expect *ExpectSubprocess) SendLine(command string) error { - _, err := io.WriteString(expect.buf.f, command+"\r\n") - return err -} - -func (expect *ExpectSubprocess) Interact() { - defer expect.Cmd.Wait() - io.Copy(os.Stdout, &expect.buf.b) - go io.Copy(os.Stdout, expect.buf.f) - go io.Copy(expect.buf.f, os.Stdin) -} - -func (expect *ExpectSubprocess) ReadUntil(delim byte) ([]byte, error) { - join := make([]byte, 0, 512) - chunk := make([]byte, 255) - - for { - n, err := expect.buf.Read(chunk) - - for i := 0; i < n; i++ { - if chunk[i] == delim { - if len(chunk) > i+1 { - expect.buf.PutBack(chunk[i+1:n]) - } - return join, nil - } else { - join = append(join, chunk[i]) - } - } - - if err != nil { - return join, err - } - } -} - -func (expect *ExpectSubprocess) Wait() error { - return expect.Cmd.Wait() -} - -func (expect *ExpectSubprocess) ReadLine() (string, error) { - str, err := expect.ReadUntil('\n') - return string(str), err -} - -func _start(expect *ExpectSubprocess) (*ExpectSubprocess, error) { - f, err := pty.Start(expect.Cmd) - if err != nil { - return nil, err - } - expect.buf.f = f - - return expect, nil -} - -func _spawn(command string) (*ExpectSubprocess, error) { - wrapper := new(ExpectSubprocess) - - wrapper.outputBuffer = nil - - splitArgs, err := shell.Split(command) - if err != nil { - return nil, err - } - numArguments := len(splitArgs) - 1 - if numArguments < 0 { - return nil, errors.New("gexpect: No command given to spawn") - } - path, err := exec.LookPath(splitArgs[0]) - if err != nil { - return nil, err - } - - if numArguments >= 1 { - wrapper.Cmd = exec.Command(path, splitArgs[1:]...) - } else { - wrapper.Cmd = exec.Command(path) - } - wrapper.buf = new(buffer) - - return wrapper, nil -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-iptables/LICENSE b/Godeps/_workspace/src/github.com/coreos/go-iptables/LICENSE deleted file mode 100644 index 37ec93a14f..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-iptables/LICENSE +++ /dev/null @@ -1,191 +0,0 @@ -Apache License -Version 2.0, January 2004 -http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, and -distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by the copyright -owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and all other entities -that control, are controlled by, or are under common control with that entity. -For the purposes of this definition, "control" means (i) the power, direct or -indirect, to cause the direction or management of such entity, whether by -contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the -outstanding shares, or (iii) beneficial ownership of such entity. - -"You" (or "Your") shall mean an individual or Legal Entity exercising -permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, including -but not limited to software source code, documentation source, and configuration -files. - -"Object" form shall mean any form resulting from mechanical transformation or -translation of a Source form, including but not limited to compiled object code, -generated documentation, and conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object form, made -available under the License, as indicated by a copyright notice that is included -in or attached to the work (an example is provided in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object form, that -is based on (or derived from) the Work and for which the editorial revisions, -annotations, elaborations, or other modifications represent, as a whole, an -original work of authorship. For the purposes of this License, Derivative Works -shall not include works that remain separable from, or merely link (or bind by -name) to the interfaces of, the Work and Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original version -of the Work and any modifications or additions to that Work or Derivative Works -thereof, that is intentionally submitted to Licensor for inclusion in the Work -by the copyright owner or by an individual or Legal Entity authorized to submit -on behalf of the copyright owner. For the purposes of this definition, -"submitted" means any form of electronic, verbal, or written communication sent -to the Licensor or its representatives, including but not limited to -communication on electronic mailing lists, source code control systems, and -issue tracking systems that are managed by, or on behalf of, the Licensor for -the purpose of discussing and improving the Work, but excluding communication -that is conspicuously marked or otherwise designated in writing by the copyright -owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf -of whom a Contribution has been received by Licensor and subsequently -incorporated within the Work. - -2. Grant of Copyright License. - -Subject to the terms and conditions of this License, each Contributor hereby -grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, -irrevocable copyright license to reproduce, prepare Derivative Works of, -publicly display, publicly perform, sublicense, and distribute the Work and such -Derivative Works in Source or Object form. - -3. Grant of Patent License. - -Subject to the terms and conditions of this License, each Contributor 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, and otherwise transfer the Work, where -such license applies only to those patent claims licensable by such Contributor -that are necessarily infringed by their Contribution(s) alone or by combination -of their Contribution(s) with the Work to which such Contribution(s) was -submitted. If You institute patent litigation against any entity (including a -cross-claim or counterclaim in a lawsuit) alleging that the Work or a -Contribution incorporated within the Work constitutes direct or contributory -patent infringement, then any patent licenses granted to You under this License -for that Work shall terminate as of the date such litigation is filed. - -4. Redistribution. - -You may reproduce and distribute copies of the Work or Derivative Works thereof -in any medium, with or without modifications, and in Source or Object form, -provided that You meet the following conditions: - -You must give any other recipients of the Work or Derivative Works a copy of -this License; and -You must cause any modified files to carry prominent notices stating that You -changed the files; and -You must retain, in the Source form of any Derivative Works that You distribute, -all copyright, patent, trademark, and attribution notices from the Source form -of the Work, excluding those notices that do not pertain to any part of the -Derivative Works; and -If the Work includes a "NOTICE" text file as part of its distribution, then any -Derivative Works that You distribute must include a readable copy of the -attribution notices contained within such NOTICE file, excluding those notices -that do not pertain to any part of the Derivative Works, in at least one of the -following places: within a NOTICE text file distributed as part of the -Derivative Works; within the Source form or documentation, if provided along -with the Derivative Works; or, within a display generated by the Derivative -Works, if and wherever such third-party notices normally appear. The contents of -the NOTICE file are for informational purposes only and do not modify the -License. You may add Your own attribution notices within Derivative Works that -You distribute, alongside or as an addendum to the NOTICE text from the Work, -provided that such additional attribution notices cannot be construed as -modifying the License. -You may add Your own copyright statement to Your modifications and may provide -additional or different license terms and conditions for use, reproduction, or -distribution of Your modifications, or for any such Derivative Works as a whole, -provided Your use, reproduction, and distribution of the Work otherwise complies -with the conditions stated in this License. - -5. Submission of Contributions. - -Unless You explicitly state otherwise, any Contribution intentionally submitted -for inclusion in the Work by You to the Licensor shall be under the terms and -conditions of this License, without any additional terms or conditions. -Notwithstanding the above, nothing herein shall supersede or modify the terms of -any separate license agreement you may have executed with Licensor regarding -such Contributions. - -6. Trademarks. - -This License does not grant permission to use the trade names, trademarks, -service marks, or product names of the Licensor, except as required for -reasonable and customary use in describing the origin of the Work and -reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. - -Unless required by applicable law or agreed to in writing, Licensor provides the -Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, -including, without limitation, any warranties or conditions of TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are -solely responsible for determining the appropriateness of using or -redistributing the Work and assume any risks associated with Your exercise of -permissions under this License. - -8. Limitation of Liability. - -In no event and under no legal theory, whether in tort (including negligence), -contract, or otherwise, unless required by applicable law (such as deliberate -and grossly negligent acts) or agreed to in writing, shall any Contributor be -liable to You for damages, including any direct, indirect, special, incidental, -or consequential damages of any character arising as a result of this License or -out of the use or inability to use the Work (including but not limited to -damages for loss of goodwill, work stoppage, computer failure or malfunction, or -any and all other commercial damages or losses), even if such Contributor has -been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. - -While redistributing the Work or Derivative Works thereof, You may choose to -offer, and charge a fee for, acceptance of support, warranty, indemnity, or -other liability obligations and/or rights consistent with this License. However, -in accepting such obligations, You may act only on Your own behalf and on Your -sole responsibility, not on behalf of any other Contributor, and only if You -agree to indemnify, defend, and hold each Contributor harmless for any liability -incurred by, or claims asserted against, such Contributor by reason of your -accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work - -To apply the Apache License to your work, attach the following boilerplate -notice, with the fields enclosed by brackets "[]" replaced with your own -identifying information. (Don't include the brackets!) The text should be -enclosed in the appropriate comment syntax for the file format. We also -recommend that a file or class name and description of purpose be included on -the same "printed page" as the copyright notice for easier identification within -third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/Godeps/_workspace/src/github.com/coreos/go-iptables/iptables/iptables.go b/Godeps/_workspace/src/github.com/coreos/go-iptables/iptables/iptables.go deleted file mode 100644 index 4b2f2f2f4b..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-iptables/iptables/iptables.go +++ /dev/null @@ -1,295 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package iptables - -import ( - "bytes" - "fmt" - "io" - "os/exec" - "regexp" - "strconv" - "strings" - "syscall" -) - -// Adds the output of stderr to exec.ExitError -type Error struct { - exec.ExitError - msg string -} - -func (e *Error) ExitStatus() int { - return e.Sys().(syscall.WaitStatus).ExitStatus() -} - -func (e *Error) Error() string { - return fmt.Sprintf("exit status %v: %v", e.ExitStatus(), e.msg) -} - -type IPTables struct { - path string - hasCheck bool - hasWait bool -} - -func New() (*IPTables, error) { - path, err := exec.LookPath("iptables") - if err != nil { - return nil, err - } - checkPresent, waitPresent, err := getIptablesCommandSupport() - if err != nil { - return nil, fmt.Errorf("error checking iptables version: %v", err) - } - ipt := IPTables{ - path: path, - hasCheck: checkPresent, - hasWait: waitPresent, - } - return &ipt, nil -} - -// Exists checks if given rulespec in specified table/chain exists -func (ipt *IPTables) Exists(table, chain string, rulespec ...string) (bool, error) { - if !ipt.hasCheck { - return ipt.existsForOldIptables(table, chain, rulespec) - - } - cmd := append([]string{"-t", table, "-C", chain}, rulespec...) - err := ipt.run(cmd...) - eerr, eok := err.(*Error) - switch { - case err == nil: - return true, nil - case eok && eerr.ExitStatus() == 1: - return false, nil - default: - return false, err - } -} - -// Insert inserts rulespec to specified table/chain (in specified pos) -func (ipt *IPTables) Insert(table, chain string, pos int, rulespec ...string) error { - cmd := append([]string{"-t", table, "-I", chain, strconv.Itoa(pos)}, rulespec...) - return ipt.run(cmd...) -} - -// Append appends rulespec to specified table/chain -func (ipt *IPTables) Append(table, chain string, rulespec ...string) error { - cmd := append([]string{"-t", table, "-A", chain}, rulespec...) - return ipt.run(cmd...) -} - -// AppendUnique acts like Append except that it won't add a duplicate -func (ipt *IPTables) AppendUnique(table, chain string, rulespec ...string) error { - exists, err := ipt.Exists(table, chain, rulespec...) - if err != nil { - return err - } - - if !exists { - return ipt.Append(table, chain, rulespec...) - } - - return nil -} - -// Delete removes rulespec in specified table/chain -func (ipt *IPTables) Delete(table, chain string, rulespec ...string) error { - cmd := append([]string{"-t", table, "-D", chain}, rulespec...) - return ipt.run(cmd...) -} - -// List rules in specified table/chain -func (ipt *IPTables) List(table, chain string) ([]string, error) { - args := []string{"-t", table, "-S", chain} - var stdout bytes.Buffer - if err := ipt.runWithOutput(args, &stdout); err != nil { - return nil, err - } - - rules := strings.Split(stdout.String(), "\n") - if len(rules) > 0 && rules[len(rules)-1] == "" { - rules = rules[:len(rules)-1] - } - - return rules, nil -} - -func (ipt *IPTables) NewChain(table, chain string) error { - return ipt.run("-t", table, "-N", chain) -} - -// ClearChain flushed (deletes all rules) in the specified table/chain. -// If the chain does not exist, a new one will be created -func (ipt *IPTables) ClearChain(table, chain string) error { - err := ipt.NewChain(table, chain) - - eerr, eok := err.(*Error) - switch { - case err == nil: - return nil - case eok && eerr.ExitStatus() == 1: - // chain already exists. Flush (clear) it. - return ipt.run("-t", table, "-F", chain) - default: - return err - } -} - -// RenameChain renames the old chain to the new one. -func (ipt *IPTables) RenameChain(table, oldChain, newChain string) error { - return ipt.run("-t", table, "-E", oldChain, newChain) -} - -// DeleteChain deletes the chain in the specified table. -// The chain must be empty -func (ipt *IPTables) DeleteChain(table, chain string) error { - return ipt.run("-t", table, "-X", chain) -} - -// run runs an iptables command with the given arguments, ignoring -// any stdout output -func (ipt *IPTables) run(args ...string) error { - return ipt.runWithOutput(args, nil) -} - -// runWithOutput runs an iptables command with the given arguments, -// writing any stdout output to the given writer -func (ipt *IPTables) runWithOutput(args []string, stdout io.Writer) error { - args = append([]string{ipt.path}, args...) - if ipt.hasWait { - args = append(args, "--wait") - } else { - fmu, err := newXtablesFileLock() - if err != nil { - return err - } - ul, err := fmu.tryLock() - if err != nil { - return err - } - defer ul.Unlock() - } - - var stderr bytes.Buffer - cmd := exec.Cmd{ - Path: ipt.path, - Args: args, - Stdout: stdout, - Stderr: &stderr, - } - - if err := cmd.Run(); err != nil { - return &Error{*(err.(*exec.ExitError)), stderr.String()} - } - - return nil -} - -// Checks if iptables has the "-C" and "--wait" flag -func getIptablesCommandSupport() (bool, bool, error) { - vstring, err := getIptablesVersionString() - if err != nil { - return false, false, err - } - - v1, v2, v3, err := extractIptablesVersion(vstring) - if err != nil { - return false, false, err - } - - return iptablesHasCheckCommand(v1, v2, v3), iptablesHasWaitCommand(v1, v2, v3), nil -} - -// getIptablesVersion returns the first three components of the iptables version. -// e.g. "iptables v1.3.66" would return (1, 3, 66, nil) -func extractIptablesVersion(str string) (int, int, int, error) { - versionMatcher := regexp.MustCompile("v([0-9]+)\\.([0-9]+)\\.([0-9]+)") - result := versionMatcher.FindStringSubmatch(str) - if result == nil { - return 0, 0, 0, fmt.Errorf("no iptables version found in string: %s", str) - } - - v1, err := strconv.Atoi(result[1]) - if err != nil { - return 0, 0, 0, err - } - - v2, err := strconv.Atoi(result[2]) - if err != nil { - return 0, 0, 0, err - } - - v3, err := strconv.Atoi(result[3]) - if err != nil { - return 0, 0, 0, err - } - - return v1, v2, v3, nil -} - -// Runs "iptables --version" to get the version string -func getIptablesVersionString() (string, error) { - cmd := exec.Command("iptables", "--version") - var out bytes.Buffer - cmd.Stdout = &out - err := cmd.Run() - if err != nil { - return "", err - } - return out.String(), nil -} - -// Checks if an iptables version is after 1.4.11, when --check was added -func iptablesHasCheckCommand(v1 int, v2 int, v3 int) bool { - if v1 > 1 { - return true - } - if v1 == 1 && v2 > 4 { - return true - } - if v1 == 1 && v2 == 4 && v3 >= 11 { - return true - } - return false -} - -// Checks if an iptables version is after 1.4.20, when --wait was added -func iptablesHasWaitCommand(v1 int, v2 int, v3 int) bool { - if v1 > 1 { - return true - } - if v1 == 1 && v2 > 4 { - return true - } - if v1 == 1 && v2 == 4 && v3 >= 20 { - return true - } - return false -} - -// Checks if a rule specification exists for a table -func (ipt *IPTables) existsForOldIptables(table, chain string, rulespec []string) (bool, error) { - rs := strings.Join(append([]string{"-A", chain}, rulespec...), " ") - args := []string{"-t", table, "-S"} - var stdout bytes.Buffer - err := ipt.runWithOutput(args, &stdout) - if err != nil { - return false, err - } - return strings.Contains(stdout.String(), rs), nil -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-iptables/iptables/lock.go b/Godeps/_workspace/src/github.com/coreos/go-iptables/iptables/lock.go deleted file mode 100644 index a88e92b4e4..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-iptables/iptables/lock.go +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package iptables - -import ( - "os" - "sync" - "syscall" -) - -const ( - // In earlier versions of iptables, the xtables lock was implemented - // via a Unix socket, but now flock is used via this lockfile: - // http://git.netfilter.org/iptables/commit/?id=aa562a660d1555b13cffbac1e744033e91f82707 - // Note the LSB-conforming "/run" directory does not exist on old - // distributions, so assume "/var" is symlinked - xtablesLockFilePath = "/var/run/xtables.lock" - - defaultFilePerm = 0600 -) - -type Unlocker interface { - Unlock() error -} - -type nopUnlocker struct{} - -func (_ nopUnlocker) Unlock() error { return nil } - -type fileLock struct { - // mu is used to protect against concurrent invocations from within this process - mu sync.Mutex - fd int -} - -// tryLock takes an exclusive lock on the xtables lock file without blocking. -// This is best-effort only: if the exclusive lock would block (i.e. because -// another process already holds it), no error is returned. Otherwise, any -// error encountered during the locking operation is returned. -// The returned Unlocker should be used to release the lock when the caller is -// done invoking iptables commands. -func (l *fileLock) tryLock() (Unlocker, error) { - l.mu.Lock() - err := syscall.Flock(l.fd, syscall.LOCK_EX|syscall.LOCK_NB) - switch err { - case syscall.EWOULDBLOCK: - l.mu.Unlock() - return nopUnlocker{}, nil - case nil: - return l, nil - default: - l.mu.Unlock() - return nil, err - } -} - -// Unlock closes the underlying file, which implicitly unlocks it as well. It -// also unlocks the associated mutex. -func (l *fileLock) Unlock() error { - defer l.mu.Unlock() - return syscall.Close(l.fd) -} - -// newXtablesFileLock opens a new lock on the xtables lockfile without -// acquiring the lock -func newXtablesFileLock() (*fileLock, error) { - fd, err := syscall.Open(xtablesLockFilePath, os.O_CREATE, defaultFilePerm) - if err != nil { - return nil, err - } - return &fileLock{fd: fd}, nil -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-semver/LICENSE b/Godeps/_workspace/src/github.com/coreos/go-semver/LICENSE deleted file mode 100644 index d645695673..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-semver/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor 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, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/Godeps/_workspace/src/github.com/coreos/go-semver/semver/semver.go b/Godeps/_workspace/src/github.com/coreos/go-semver/semver/semver.go deleted file mode 100644 index 4e10221a18..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-semver/semver/semver.go +++ /dev/null @@ -1,202 +0,0 @@ -package semver - -import ( - "bytes" - "errors" - "fmt" - "strconv" - "strings" -) - -type Version struct { - Major int64 - Minor int64 - Patch int64 - PreRelease PreRelease - Metadata string -} - -type PreRelease string - -func splitOff(input *string, delim string) (val string) { - parts := strings.SplitN(*input, delim, 2) - - if len(parts) == 2 { - *input = parts[0] - val = parts[1] - } - - return val -} - -func NewVersion(version string) (*Version, error) { - v := Version{} - - dotParts := strings.SplitN(version, ".", 3) - - if len(dotParts) != 3 { - return nil, errors.New(fmt.Sprintf("%s is not in dotted-tri format", version)) - } - - v.Metadata = splitOff(&dotParts[2], "+") - v.PreRelease = PreRelease(splitOff(&dotParts[2], "-")) - - parsed := make([]int64, 3, 3) - - for i, v := range dotParts[:3] { - val, err := strconv.ParseInt(v, 10, 64) - parsed[i] = val - if err != nil { - return nil, err - } - } - - v.Major = parsed[0] - v.Minor = parsed[1] - v.Patch = parsed[2] - - return &v, nil -} - -func (v *Version) String() string { - var buffer bytes.Buffer - - base := fmt.Sprintf("%d.%d.%d", v.Major, v.Minor, v.Patch) - buffer.WriteString(base) - - if v.PreRelease != "" { - buffer.WriteString(fmt.Sprintf("-%s", v.PreRelease)) - } - - if v.Metadata != "" { - buffer.WriteString(fmt.Sprintf("+%s", v.Metadata)) - } - - return buffer.String() -} - -func (v *Version) LessThan(versionB Version) bool { - versionA := *v - cmp := recursiveCompare(versionA.Slice(), versionB.Slice()) - - if cmp == 0 { - cmp = preReleaseCompare(versionA, versionB) - } - - if cmp == -1 { - return true - } - - return false -} - -/* Slice converts the comparable parts of the semver into a slice of strings */ -func (v *Version) Slice() []int64 { - return []int64{v.Major, v.Minor, v.Patch} -} - -func (p *PreRelease) Slice() []string { - preRelease := string(*p) - return strings.Split(preRelease, ".") -} - -func preReleaseCompare(versionA Version, versionB Version) int { - a := versionA.PreRelease - b := versionB.PreRelease - - /* Handle the case where if two versions are otherwise equal it is the - * one without a PreRelease that is greater */ - if len(a) == 0 && (len(b) > 0) { - return 1 - } else if len(b) == 0 && (len(a) > 0) { - return -1 - } - - // If there is a prelease, check and compare each part. - return recursivePreReleaseCompare(a.Slice(), b.Slice()) -} - -func recursiveCompare(versionA []int64, versionB []int64) int { - if len(versionA) == 0 { - return 0 - } - - a := versionA[0] - b := versionB[0] - - if a > b { - return 1 - } else if a < b { - return -1 - } - - return recursiveCompare(versionA[1:], versionB[1:]) -} - -func recursivePreReleaseCompare(versionA []string, versionB []string) int { - // Handle slice length disparity. - if len(versionA) == 0 { - // Nothing to compare too, so we return 0 - return 0 - } else if len(versionB) == 0 { - // We're longer than versionB so return 1. - return 1 - } - - a := versionA[0] - b := versionB[0] - - aInt := false; bInt := false - - aI, err := strconv.Atoi(versionA[0]) - if err == nil { - aInt = true - } - - bI, err := strconv.Atoi(versionB[0]) - if err == nil { - bInt = true - } - - // Handle Integer Comparison - if aInt && bInt { - if aI > bI { - return 1 - } else if aI < bI { - return -1 - } - } - - // Handle String Comparison - if a > b { - return 1 - } else if a < b { - return -1 - } - - return recursivePreReleaseCompare(versionA[1:], versionB[1:]) -} - -// BumpMajor increments the Major field by 1 and resets all other fields to their default values -func (v *Version) BumpMajor() { - v.Major += 1 - v.Minor = 0 - v.Patch = 0 - v.PreRelease = PreRelease("") - v.Metadata = "" -} - -// BumpMinor increments the Minor field by 1 and resets all other fields to their default values -func (v *Version) BumpMinor() { - v.Minor += 1 - v.Patch = 0 - v.PreRelease = PreRelease("") - v.Metadata = "" -} - -// BumpPatch increments the Patch field by 1 and resets all other fields to their default values -func (v *Version) BumpPatch() { - v.Patch += 1 - v.PreRelease = PreRelease("") - v.Metadata = "" -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-semver/semver/sort.go b/Godeps/_workspace/src/github.com/coreos/go-semver/semver/sort.go deleted file mode 100644 index 86203007ae..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-semver/semver/sort.go +++ /dev/null @@ -1,24 +0,0 @@ -package semver - -import ( - "sort" -) - -type Versions []*Version - -func (s Versions) Len() int { - return len(s) -} - -func (s Versions) Swap(i, j int) { - s[i], s[j] = s[j], s[i] -} - -func (s Versions) Less(i, j int) bool { - return s[i].LessThan(*s[j]) -} - -// Sort sorts the given slice of Version -func Sort(versions []*Version) { - sort.Sort(Versions(versions)) -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/LICENSE b/Godeps/_workspace/src/github.com/coreos/go-systemd/LICENSE deleted file mode 100644 index 37ec93a14f..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-systemd/LICENSE +++ /dev/null @@ -1,191 +0,0 @@ -Apache License -Version 2.0, January 2004 -http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, and -distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by the copyright -owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and all other entities -that control, are controlled by, or are under common control with that entity. -For the purposes of this definition, "control" means (i) the power, direct or -indirect, to cause the direction or management of such entity, whether by -contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the -outstanding shares, or (iii) beneficial ownership of such entity. - -"You" (or "Your") shall mean an individual or Legal Entity exercising -permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, including -but not limited to software source code, documentation source, and configuration -files. - -"Object" form shall mean any form resulting from mechanical transformation or -translation of a Source form, including but not limited to compiled object code, -generated documentation, and conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object form, made -available under the License, as indicated by a copyright notice that is included -in or attached to the work (an example is provided in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object form, that -is based on (or derived from) the Work and for which the editorial revisions, -annotations, elaborations, or other modifications represent, as a whole, an -original work of authorship. For the purposes of this License, Derivative Works -shall not include works that remain separable from, or merely link (or bind by -name) to the interfaces of, the Work and Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original version -of the Work and any modifications or additions to that Work or Derivative Works -thereof, that is intentionally submitted to Licensor for inclusion in the Work -by the copyright owner or by an individual or Legal Entity authorized to submit -on behalf of the copyright owner. For the purposes of this definition, -"submitted" means any form of electronic, verbal, or written communication sent -to the Licensor or its representatives, including but not limited to -communication on electronic mailing lists, source code control systems, and -issue tracking systems that are managed by, or on behalf of, the Licensor for -the purpose of discussing and improving the Work, but excluding communication -that is conspicuously marked or otherwise designated in writing by the copyright -owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf -of whom a Contribution has been received by Licensor and subsequently -incorporated within the Work. - -2. Grant of Copyright License. - -Subject to the terms and conditions of this License, each Contributor hereby -grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, -irrevocable copyright license to reproduce, prepare Derivative Works of, -publicly display, publicly perform, sublicense, and distribute the Work and such -Derivative Works in Source or Object form. - -3. Grant of Patent License. - -Subject to the terms and conditions of this License, each Contributor 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, and otherwise transfer the Work, where -such license applies only to those patent claims licensable by such Contributor -that are necessarily infringed by their Contribution(s) alone or by combination -of their Contribution(s) with the Work to which such Contribution(s) was -submitted. If You institute patent litigation against any entity (including a -cross-claim or counterclaim in a lawsuit) alleging that the Work or a -Contribution incorporated within the Work constitutes direct or contributory -patent infringement, then any patent licenses granted to You under this License -for that Work shall terminate as of the date such litigation is filed. - -4. Redistribution. - -You may reproduce and distribute copies of the Work or Derivative Works thereof -in any medium, with or without modifications, and in Source or Object form, -provided that You meet the following conditions: - -You must give any other recipients of the Work or Derivative Works a copy of -this License; and -You must cause any modified files to carry prominent notices stating that You -changed the files; and -You must retain, in the Source form of any Derivative Works that You distribute, -all copyright, patent, trademark, and attribution notices from the Source form -of the Work, excluding those notices that do not pertain to any part of the -Derivative Works; and -If the Work includes a "NOTICE" text file as part of its distribution, then any -Derivative Works that You distribute must include a readable copy of the -attribution notices contained within such NOTICE file, excluding those notices -that do not pertain to any part of the Derivative Works, in at least one of the -following places: within a NOTICE text file distributed as part of the -Derivative Works; within the Source form or documentation, if provided along -with the Derivative Works; or, within a display generated by the Derivative -Works, if and wherever such third-party notices normally appear. The contents of -the NOTICE file are for informational purposes only and do not modify the -License. You may add Your own attribution notices within Derivative Works that -You distribute, alongside or as an addendum to the NOTICE text from the Work, -provided that such additional attribution notices cannot be construed as -modifying the License. -You may add Your own copyright statement to Your modifications and may provide -additional or different license terms and conditions for use, reproduction, or -distribution of Your modifications, or for any such Derivative Works as a whole, -provided Your use, reproduction, and distribution of the Work otherwise complies -with the conditions stated in this License. - -5. Submission of Contributions. - -Unless You explicitly state otherwise, any Contribution intentionally submitted -for inclusion in the Work by You to the Licensor shall be under the terms and -conditions of this License, without any additional terms or conditions. -Notwithstanding the above, nothing herein shall supersede or modify the terms of -any separate license agreement you may have executed with Licensor regarding -such Contributions. - -6. Trademarks. - -This License does not grant permission to use the trade names, trademarks, -service marks, or product names of the Licensor, except as required for -reasonable and customary use in describing the origin of the Work and -reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. - -Unless required by applicable law or agreed to in writing, Licensor provides the -Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, -including, without limitation, any warranties or conditions of TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are -solely responsible for determining the appropriateness of using or -redistributing the Work and assume any risks associated with Your exercise of -permissions under this License. - -8. Limitation of Liability. - -In no event and under no legal theory, whether in tort (including negligence), -contract, or otherwise, unless required by applicable law (such as deliberate -and grossly negligent acts) or agreed to in writing, shall any Contributor be -liable to You for damages, including any direct, indirect, special, incidental, -or consequential damages of any character arising as a result of this License or -out of the use or inability to use the Work (including but not limited to -damages for loss of goodwill, work stoppage, computer failure or malfunction, or -any and all other commercial damages or losses), even if such Contributor has -been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. - -While redistributing the Work or Derivative Works thereof, You may choose to -offer, and charge a fee for, acceptance of support, warranty, indemnity, or -other liability obligations and/or rights consistent with this License. However, -in accepting such obligations, You may act only on Your own behalf and on Your -sole responsibility, not on behalf of any other Contributor, and only if You -agree to indemnify, defend, and hold each Contributor harmless for any liability -incurred by, or claims asserted against, such Contributor by reason of your -accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work - -To apply the Apache License to your work, attach the following boilerplate -notice, with the fields enclosed by brackets "[]" replaced with your own -identifying information. (Don't include the brackets!) The text should be -enclosed in the appropriate comment syntax for the file format. We also -recommend that a file or class name and description of purpose be included on -the same "printed page" as the copyright notice for easier identification within -third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/activation/files.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/activation/files.go deleted file mode 100644 index c8e85fcd58..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-systemd/activation/files.go +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package activation implements primitives for systemd socket activation. -package activation - -import ( - "os" - "strconv" - "syscall" -) - -// based on: https://gist.github.com/alberts/4640792 -const ( - listenFdsStart = 3 -) - -func Files(unsetEnv bool) []*os.File { - if unsetEnv { - defer os.Unsetenv("LISTEN_PID") - defer os.Unsetenv("LISTEN_FDS") - } - - pid, err := strconv.Atoi(os.Getenv("LISTEN_PID")) - if err != nil || pid != os.Getpid() { - return nil - } - - nfds, err := strconv.Atoi(os.Getenv("LISTEN_FDS")) - if err != nil || nfds == 0 { - return nil - } - - files := make([]*os.File, 0, nfds) - for fd := listenFdsStart; fd < listenFdsStart+nfds; fd++ { - syscall.CloseOnExec(fd) - files = append(files, os.NewFile(uintptr(fd), "LISTEN_FD_"+strconv.Itoa(fd))) - } - - return files -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/activation/listeners.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/activation/listeners.go deleted file mode 100644 index df27c29e9e..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-systemd/activation/listeners.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package activation - -import ( - "crypto/tls" - "net" -) - -// Listeners returns a slice containing a net.Listener for each matching socket type -// passed to this process. -// -// The order of the file descriptors is preserved in the returned slice. -// Nil values are used to fill any gaps. For example if systemd were to return file descriptors -// corresponding with "udp, tcp, tcp", then the slice would contain {nil, net.Listener, net.Listener} -func Listeners(unsetEnv bool) ([]net.Listener, error) { - files := Files(unsetEnv) - listeners := make([]net.Listener, len(files)) - - for i, f := range files { - if pc, err := net.FileListener(f); err == nil { - listeners[i] = pc - } - } - return listeners, nil -} - -// TLSListeners returns a slice containing a net.listener for each matching TCP socket type -// passed to this process. -// It uses default Listeners func and forces TCP sockets handlers to use TLS based on tlsConfig. -func TLSListeners(unsetEnv bool, tlsConfig *tls.Config) ([]net.Listener, error) { - listeners, err := Listeners(unsetEnv) - - if listeners == nil || err != nil { - return nil, err - } - - if tlsConfig != nil && err == nil { - tlsConfig.NextProtos = []string{"http/1.1"} - - for i, l := range listeners { - // Activate TLS only for TCP sockets - if l.Addr().Network() == "tcp" { - listeners[i] = tls.NewListener(l, tlsConfig) - } - } - } - - return listeners, err -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/activation/packetconns.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/activation/packetconns.go deleted file mode 100644 index 48b2ca029d..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-systemd/activation/packetconns.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package activation - -import ( - "net" -) - -// PacketConns returns a slice containing a net.PacketConn for each matching socket type -// passed to this process. -// -// The order of the file descriptors is preserved in the returned slice. -// Nil values are used to fill any gaps. For example if systemd were to return file descriptors -// corresponding with "udp, tcp, udp", then the slice would contain {net.PacketConn, nil, net.PacketConn} -func PacketConns(unsetEnv bool) ([]net.PacketConn, error) { - files := Files(unsetEnv) - conns := make([]net.PacketConn, len(files)) - - for i, f := range files { - if pc, err := net.FilePacketConn(f); err == nil { - conns[i] = pc - } - } - return conns, nil -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/dbus.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/dbus.go deleted file mode 100644 index 1699b90332..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/dbus.go +++ /dev/null @@ -1,203 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Integration with the systemd D-Bus API. See http://www.freedesktop.org/wiki/Software/systemd/dbus/ -package dbus - -import ( - "fmt" - "os" - "strconv" - "strings" - "sync" - - "github.com/godbus/dbus" -) - -const ( - alpha = `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ` - num = `0123456789` - alphanum = alpha + num - signalBuffer = 100 -) - -// needsEscape checks whether a byte in a potential dbus ObjectPath needs to be escaped -func needsEscape(i int, b byte) bool { - // Escape everything that is not a-z-A-Z-0-9 - // Also escape 0-9 if it's the first character - return strings.IndexByte(alphanum, b) == -1 || - (i == 0 && strings.IndexByte(num, b) != -1) -} - -// PathBusEscape sanitizes a constituent string of a dbus ObjectPath using the -// rules that systemd uses for serializing special characters. -func PathBusEscape(path string) string { - // Special case the empty string - if len(path) == 0 { - return "_" - } - n := []byte{} - for i := 0; i < len(path); i++ { - c := path[i] - if needsEscape(i, c) { - e := fmt.Sprintf("_%x", c) - n = append(n, []byte(e)...) - } else { - n = append(n, c) - } - } - return string(n) -} - -// Conn is a connection to systemd's dbus endpoint. -type Conn struct { - // sysconn/sysobj are only used to call dbus methods - sysconn *dbus.Conn - sysobj dbus.BusObject - - // sigconn/sigobj are only used to receive dbus signals - sigconn *dbus.Conn - sigobj dbus.BusObject - - jobListener struct { - jobs map[dbus.ObjectPath]chan<- string - sync.Mutex - } - subscriber struct { - updateCh chan<- *SubStateUpdate - errCh chan<- error - sync.Mutex - ignore map[dbus.ObjectPath]int64 - cleanIgnore int64 - } -} - -// New establishes a connection to the system bus and authenticates. -// Callers should call Close() when done with the connection. -func New() (*Conn, error) { - return NewConnection(func() (*dbus.Conn, error) { - return dbusAuthHelloConnection(dbus.SystemBusPrivate) - }) -} - -// NewUserConnection establishes a connection to the session bus and -// authenticates. This can be used to connect to systemd user instances. -// Callers should call Close() when done with the connection. -func NewUserConnection() (*Conn, error) { - return NewConnection(func() (*dbus.Conn, error) { - return dbusAuthHelloConnection(dbus.SessionBusPrivate) - }) -} - -// NewSystemdConnection establishes a private, direct connection to systemd. -// This can be used for communicating with systemd without a dbus daemon. -// Callers should call Close() when done with the connection. -func NewSystemdConnection() (*Conn, error) { - return NewConnection(func() (*dbus.Conn, error) { - // We skip Hello when talking directly to systemd. - return dbusAuthConnection(func() (*dbus.Conn, error) { - return dbus.Dial("unix:path=/run/systemd/private") - }) - }) -} - -// Close closes an established connection -func (c *Conn) Close() { - c.sysconn.Close() - c.sigconn.Close() -} - -// NewConnection establishes a connection to a bus using a caller-supplied function. -// This allows connecting to remote buses through a user-supplied mechanism. -// The supplied function may be called multiple times, and should return independent connections. -// The returned connection must be fully initialised: the org.freedesktop.DBus.Hello call must have succeeded, -// and any authentication should be handled by the function. -func NewConnection(dialBus func() (*dbus.Conn, error)) (*Conn, error) { - sysconn, err := dialBus() - if err != nil { - return nil, err - } - - sigconn, err := dialBus() - if err != nil { - sysconn.Close() - return nil, err - } - - c := &Conn{ - sysconn: sysconn, - sysobj: systemdObject(sysconn), - sigconn: sigconn, - sigobj: systemdObject(sigconn), - } - - c.subscriber.ignore = make(map[dbus.ObjectPath]int64) - c.jobListener.jobs = make(map[dbus.ObjectPath]chan<- string) - - // Setup the listeners on jobs so that we can get completions - c.sigconn.BusObject().Call("org.freedesktop.DBus.AddMatch", 0, - "type='signal', interface='org.freedesktop.systemd1.Manager', member='JobRemoved'") - - c.dispatch() - return c, nil -} - -// GetManagerProperty returns the value of a property on the org.freedesktop.systemd1.Manager -// interface. The value is returned in its string representation, as defined at -// https://developer.gnome.org/glib/unstable/gvariant-text.html -func (c *Conn) GetManagerProperty(prop string) (string, error) { - variant, err := c.sysobj.GetProperty("org.freedesktop.systemd1.Manager." + prop) - if err != nil { - return "", err - } - return variant.String(), nil -} - -func dbusAuthConnection(createBus func() (*dbus.Conn, error)) (*dbus.Conn, error) { - conn, err := createBus() - if err != nil { - return nil, err - } - - // Only use EXTERNAL method, and hardcode the uid (not username) - // to avoid a username lookup (which requires a dynamically linked - // libc) - methods := []dbus.Auth{dbus.AuthExternal(strconv.Itoa(os.Getuid()))} - - err = conn.Auth(methods) - if err != nil { - conn.Close() - return nil, err - } - - return conn, nil -} - -func dbusAuthHelloConnection(createBus func() (*dbus.Conn, error)) (*dbus.Conn, error) { - conn, err := dbusAuthConnection(createBus) - if err != nil { - return nil, err - } - - if err = conn.Hello(); err != nil { - conn.Close() - return nil, err - } - - return conn, nil -} - -func systemdObject(conn *dbus.Conn) dbus.BusObject { - return conn.Object("org.freedesktop.systemd1", dbus.ObjectPath("/org/freedesktop/systemd1")) -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/methods.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/methods.go deleted file mode 100644 index 8f32fe8a7d..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/methods.go +++ /dev/null @@ -1,484 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package dbus - -import ( - "errors" - "path" - "strconv" - - "github.com/godbus/dbus" -) - -func (c *Conn) jobComplete(signal *dbus.Signal) { - var id uint32 - var job dbus.ObjectPath - var unit string - var result string - dbus.Store(signal.Body, &id, &job, &unit, &result) - c.jobListener.Lock() - out, ok := c.jobListener.jobs[job] - if ok { - out <- result - delete(c.jobListener.jobs, job) - } - c.jobListener.Unlock() -} - -func (c *Conn) startJob(ch chan<- string, job string, args ...interface{}) (int, error) { - if ch != nil { - c.jobListener.Lock() - defer c.jobListener.Unlock() - } - - var p dbus.ObjectPath - err := c.sysobj.Call(job, 0, args...).Store(&p) - if err != nil { - return 0, err - } - - if ch != nil { - c.jobListener.jobs[p] = ch - } - - // ignore error since 0 is fine if conversion fails - jobID, _ := strconv.Atoi(path.Base(string(p))) - - return jobID, nil -} - -// StartUnit enqueues a start job and depending jobs, if any (unless otherwise -// specified by the mode string). -// -// Takes the unit to activate, plus a mode string. The mode needs to be one of -// replace, fail, isolate, ignore-dependencies, ignore-requirements. If -// "replace" the call will start the unit and its dependencies, possibly -// replacing already queued jobs that conflict with this. If "fail" the call -// will start the unit and its dependencies, but will fail if this would change -// an already queued job. If "isolate" the call will start the unit in question -// and terminate all units that aren't dependencies of it. If -// "ignore-dependencies" it will start a unit but ignore all its dependencies. -// If "ignore-requirements" it will start a unit but only ignore the -// requirement dependencies. It is not recommended to make use of the latter -// two options. -// -// If the provided channel is non-nil, a result string will be sent to it upon -// job completion: one of done, canceled, timeout, failed, dependency, skipped. -// done indicates successful execution of a job. canceled indicates that a job -// has been canceled before it finished execution. timeout indicates that the -// job timeout was reached. failed indicates that the job failed. dependency -// indicates that a job this job has been depending on failed and the job hence -// has been removed too. skipped indicates that a job was skipped because it -// didn't apply to the units current state. -// -// If no error occurs, the ID of the underlying systemd job will be returned. There -// does exist the possibility for no error to be returned, but for the returned job -// ID to be 0. In this case, the actual underlying ID is not 0 and this datapoint -// should not be considered authoritative. -// -// If an error does occur, it will be returned to the user alongside a job ID of 0. -func (c *Conn) StartUnit(name string, mode string, ch chan<- string) (int, error) { - return c.startJob(ch, "org.freedesktop.systemd1.Manager.StartUnit", name, mode) -} - -// StopUnit is similar to StartUnit but stops the specified unit rather -// than starting it. -func (c *Conn) StopUnit(name string, mode string, ch chan<- string) (int, error) { - return c.startJob(ch, "org.freedesktop.systemd1.Manager.StopUnit", name, mode) -} - -// ReloadUnit reloads a unit. Reloading is done only if the unit is already running and fails otherwise. -func (c *Conn) ReloadUnit(name string, mode string, ch chan<- string) (int, error) { - return c.startJob(ch, "org.freedesktop.systemd1.Manager.ReloadUnit", name, mode) -} - -// RestartUnit restarts a service. If a service is restarted that isn't -// running it will be started. -func (c *Conn) RestartUnit(name string, mode string, ch chan<- string) (int, error) { - return c.startJob(ch, "org.freedesktop.systemd1.Manager.RestartUnit", name, mode) -} - -// TryRestartUnit is like RestartUnit, except that a service that isn't running -// is not affected by the restart. -func (c *Conn) TryRestartUnit(name string, mode string, ch chan<- string) (int, error) { - return c.startJob(ch, "org.freedesktop.systemd1.Manager.TryRestartUnit", name, mode) -} - -// ReloadOrRestart attempts a reload if the unit supports it and use a restart -// otherwise. -func (c *Conn) ReloadOrRestartUnit(name string, mode string, ch chan<- string) (int, error) { - return c.startJob(ch, "org.freedesktop.systemd1.Manager.ReloadOrRestartUnit", name, mode) -} - -// ReloadOrTryRestart attempts a reload if the unit supports it and use a "Try" -// flavored restart otherwise. -func (c *Conn) ReloadOrTryRestartUnit(name string, mode string, ch chan<- string) (int, error) { - return c.startJob(ch, "org.freedesktop.systemd1.Manager.ReloadOrTryRestartUnit", name, mode) -} - -// StartTransientUnit() may be used to create and start a transient unit, which -// will be released as soon as it is not running or referenced anymore or the -// system is rebooted. name is the unit name including suffix, and must be -// unique. mode is the same as in StartUnit(), properties contains properties -// of the unit. -func (c *Conn) StartTransientUnit(name string, mode string, properties []Property, ch chan<- string) (int, error) { - return c.startJob(ch, "org.freedesktop.systemd1.Manager.StartTransientUnit", name, mode, properties, make([]PropertyCollection, 0)) -} - -// KillUnit takes the unit name and a UNIX signal number to send. All of the unit's -// processes are killed. -func (c *Conn) KillUnit(name string, signal int32) { - c.sysobj.Call("org.freedesktop.systemd1.Manager.KillUnit", 0, name, "all", signal).Store() -} - -// ResetFailedUnit resets the "failed" state of a specific unit. -func (c *Conn) ResetFailedUnit(name string) error { - return c.sysobj.Call("org.freedesktop.systemd1.Manager.ResetFailedUnit", 0, name).Store() -} - -// getProperties takes the unit name and returns all of its dbus object properties, for the given dbus interface -func (c *Conn) getProperties(unit string, dbusInterface string) (map[string]interface{}, error) { - var err error - var props map[string]dbus.Variant - - path := unitPath(unit) - if !path.IsValid() { - return nil, errors.New("invalid unit name: " + unit) - } - - obj := c.sysconn.Object("org.freedesktop.systemd1", path) - err = obj.Call("org.freedesktop.DBus.Properties.GetAll", 0, dbusInterface).Store(&props) - if err != nil { - return nil, err - } - - out := make(map[string]interface{}, len(props)) - for k, v := range props { - out[k] = v.Value() - } - - return out, nil -} - -// GetUnitProperties takes the unit name and returns all of its dbus object properties. -func (c *Conn) GetUnitProperties(unit string) (map[string]interface{}, error) { - return c.getProperties(unit, "org.freedesktop.systemd1.Unit") -} - -func (c *Conn) getProperty(unit string, dbusInterface string, propertyName string) (*Property, error) { - var err error - var prop dbus.Variant - - path := unitPath(unit) - if !path.IsValid() { - return nil, errors.New("invalid unit name: " + unit) - } - - obj := c.sysconn.Object("org.freedesktop.systemd1", path) - err = obj.Call("org.freedesktop.DBus.Properties.Get", 0, dbusInterface, propertyName).Store(&prop) - if err != nil { - return nil, err - } - - return &Property{Name: propertyName, Value: prop}, nil -} - -func (c *Conn) GetUnitProperty(unit string, propertyName string) (*Property, error) { - return c.getProperty(unit, "org.freedesktop.systemd1.Unit", propertyName) -} - -// GetServiceProperty returns property for given service name and property name -func (c *Conn) GetServiceProperty(service string, propertyName string) (*Property, error) { - return c.getProperty(service, "org.freedesktop.systemd1.Service", propertyName) -} - -// GetUnitTypeProperties returns the extra properties for a unit, specific to the unit type. -// Valid values for unitType: Service, Socket, Target, Device, Mount, Automount, Snapshot, Timer, Swap, Path, Slice, Scope -// return "dbus.Error: Unknown interface" if the unitType is not the correct type of the unit -func (c *Conn) GetUnitTypeProperties(unit string, unitType string) (map[string]interface{}, error) { - return c.getProperties(unit, "org.freedesktop.systemd1."+unitType) -} - -// SetUnitProperties() may be used to modify certain unit properties at runtime. -// Not all properties may be changed at runtime, but many resource management -// settings (primarily those in systemd.cgroup(5)) may. The changes are applied -// instantly, and stored on disk for future boots, unless runtime is true, in which -// case the settings only apply until the next reboot. name is the name of the unit -// to modify. properties are the settings to set, encoded as an array of property -// name and value pairs. -func (c *Conn) SetUnitProperties(name string, runtime bool, properties ...Property) error { - return c.sysobj.Call("org.freedesktop.systemd1.Manager.SetUnitProperties", 0, name, runtime, properties).Store() -} - -func (c *Conn) GetUnitTypeProperty(unit string, unitType string, propertyName string) (*Property, error) { - return c.getProperty(unit, "org.freedesktop.systemd1."+unitType, propertyName) -} - -type UnitStatus struct { - Name string // The primary unit name as string - Description string // The human readable description string - LoadState string // The load state (i.e. whether the unit file has been loaded successfully) - ActiveState string // The active state (i.e. whether the unit is currently started or not) - SubState string // The sub state (a more fine-grained version of the active state that is specific to the unit type, which the active state is not) - Followed string // A unit that is being followed in its state by this unit, if there is any, otherwise the empty string. - Path dbus.ObjectPath // The unit object path - JobId uint32 // If there is a job queued for the job unit the numeric job id, 0 otherwise - JobType string // The job type as string - JobPath dbus.ObjectPath // The job object path -} - -type storeFunc func(retvalues ...interface{}) error - -func (c *Conn) listUnitsInternal(f storeFunc) ([]UnitStatus, error) { - result := make([][]interface{}, 0) - err := f(&result) - if err != nil { - return nil, err - } - - resultInterface := make([]interface{}, len(result)) - for i := range result { - resultInterface[i] = result[i] - } - - status := make([]UnitStatus, len(result)) - statusInterface := make([]interface{}, len(status)) - for i := range status { - statusInterface[i] = &status[i] - } - - err = dbus.Store(resultInterface, statusInterface...) - if err != nil { - return nil, err - } - - return status, nil -} - -// ListUnits returns an array with all currently loaded units. Note that -// units may be known by multiple names at the same time, and hence there might -// be more unit names loaded than actual units behind them. -func (c *Conn) ListUnits() ([]UnitStatus, error) { - return c.listUnitsInternal(c.sysobj.Call("org.freedesktop.systemd1.Manager.ListUnits", 0).Store) -} - -// ListUnitsFiltered returns an array with units filtered by state. -// It takes a list of units' statuses to filter. -func (c *Conn) ListUnitsFiltered(states []string) ([]UnitStatus, error) { - return c.listUnitsInternal(c.sysobj.Call("org.freedesktop.systemd1.Manager.ListUnitsFiltered", 0, states).Store) -} - -// ListUnitsByPatterns returns an array with units. -// It takes a list of units' statuses and names to filter. -// Note that units may be known by multiple names at the same time, -// and hence there might be more unit names loaded than actual units behind them. -func (c *Conn) ListUnitsByPatterns(states []string, patterns []string) ([]UnitStatus, error) { - return c.listUnitsInternal(c.sysobj.Call("org.freedesktop.systemd1.Manager.ListUnitsByPatterns", 0, states, patterns).Store) -} - -// ListUnitsByNames returns an array with units. It takes a list of units' -// names and returns an UnitStatus array. Comparing to ListUnitsByPatterns -// method, this method returns statuses even for inactive or non-existing -// units. Input array should contain exact unit names, but not patterns. -func (c *Conn) ListUnitsByNames(units []string) ([]UnitStatus, error) { - return c.listUnitsInternal(c.sysobj.Call("org.freedesktop.systemd1.Manager.ListUnitsByNames", 0, units).Store) -} - -type UnitFile struct { - Path string - Type string -} - -func (c *Conn) listUnitFilesInternal(f storeFunc) ([]UnitFile, error) { - result := make([][]interface{}, 0) - err := f(&result) - if err != nil { - return nil, err - } - - resultInterface := make([]interface{}, len(result)) - for i := range result { - resultInterface[i] = result[i] - } - - files := make([]UnitFile, len(result)) - fileInterface := make([]interface{}, len(files)) - for i := range files { - fileInterface[i] = &files[i] - } - - err = dbus.Store(resultInterface, fileInterface...) - if err != nil { - return nil, err - } - - return files, nil -} - -// ListUnitFiles returns an array of all available units on disk. -func (c *Conn) ListUnitFiles() ([]UnitFile, error) { - return c.listUnitFilesInternal(c.sysobj.Call("org.freedesktop.systemd1.Manager.ListUnitFiles", 0).Store) -} - -// ListUnitFilesByPatterns returns an array of all available units on disk matched the patterns. -func (c *Conn) ListUnitFilesByPatterns(states []string, patterns []string) ([]UnitFile, error) { - return c.listUnitFilesInternal(c.sysobj.Call("org.freedesktop.systemd1.Manager.ListUnitFilesByPatterns", 0, states, patterns).Store) -} - -type LinkUnitFileChange EnableUnitFileChange - -// LinkUnitFiles() links unit files (that are located outside of the -// usual unit search paths) into the unit search path. -// -// It takes a list of absolute paths to unit files to link and two -// booleans. The first boolean controls whether the unit shall be -// enabled for runtime only (true, /run), or persistently (false, -// /etc). -// The second controls whether symlinks pointing to other units shall -// be replaced if necessary. -// -// This call returns a list of the changes made. The list consists of -// structures with three strings: the type of the change (one of symlink -// or unlink), the file name of the symlink and the destination of the -// symlink. -func (c *Conn) LinkUnitFiles(files []string, runtime bool, force bool) ([]LinkUnitFileChange, error) { - result := make([][]interface{}, 0) - err := c.sysobj.Call("org.freedesktop.systemd1.Manager.LinkUnitFiles", 0, files, runtime, force).Store(&result) - if err != nil { - return nil, err - } - - resultInterface := make([]interface{}, len(result)) - for i := range result { - resultInterface[i] = result[i] - } - - changes := make([]LinkUnitFileChange, len(result)) - changesInterface := make([]interface{}, len(changes)) - for i := range changes { - changesInterface[i] = &changes[i] - } - - err = dbus.Store(resultInterface, changesInterface...) - if err != nil { - return nil, err - } - - return changes, nil -} - -// EnableUnitFiles() may be used to enable one or more units in the system (by -// creating symlinks to them in /etc or /run). -// -// It takes a list of unit files to enable (either just file names or full -// absolute paths if the unit files are residing outside the usual unit -// search paths), and two booleans: the first controls whether the unit shall -// be enabled for runtime only (true, /run), or persistently (false, /etc). -// The second one controls whether symlinks pointing to other units shall -// be replaced if necessary. -// -// This call returns one boolean and an array with the changes made. The -// boolean signals whether the unit files contained any enablement -// information (i.e. an [Install]) section. The changes list consists of -// structures with three strings: the type of the change (one of symlink -// or unlink), the file name of the symlink and the destination of the -// symlink. -func (c *Conn) EnableUnitFiles(files []string, runtime bool, force bool) (bool, []EnableUnitFileChange, error) { - var carries_install_info bool - - result := make([][]interface{}, 0) - err := c.sysobj.Call("org.freedesktop.systemd1.Manager.EnableUnitFiles", 0, files, runtime, force).Store(&carries_install_info, &result) - if err != nil { - return false, nil, err - } - - resultInterface := make([]interface{}, len(result)) - for i := range result { - resultInterface[i] = result[i] - } - - changes := make([]EnableUnitFileChange, len(result)) - changesInterface := make([]interface{}, len(changes)) - for i := range changes { - changesInterface[i] = &changes[i] - } - - err = dbus.Store(resultInterface, changesInterface...) - if err != nil { - return false, nil, err - } - - return carries_install_info, changes, nil -} - -type EnableUnitFileChange struct { - Type string // Type of the change (one of symlink or unlink) - Filename string // File name of the symlink - Destination string // Destination of the symlink -} - -// DisableUnitFiles() may be used to disable one or more units in the system (by -// removing symlinks to them from /etc or /run). -// -// It takes a list of unit files to disable (either just file names or full -// absolute paths if the unit files are residing outside the usual unit -// search paths), and one boolean: whether the unit was enabled for runtime -// only (true, /run), or persistently (false, /etc). -// -// This call returns an array with the changes made. The changes list -// consists of structures with three strings: the type of the change (one of -// symlink or unlink), the file name of the symlink and the destination of the -// symlink. -func (c *Conn) DisableUnitFiles(files []string, runtime bool) ([]DisableUnitFileChange, error) { - result := make([][]interface{}, 0) - err := c.sysobj.Call("org.freedesktop.systemd1.Manager.DisableUnitFiles", 0, files, runtime).Store(&result) - if err != nil { - return nil, err - } - - resultInterface := make([]interface{}, len(result)) - for i := range result { - resultInterface[i] = result[i] - } - - changes := make([]DisableUnitFileChange, len(result)) - changesInterface := make([]interface{}, len(changes)) - for i := range changes { - changesInterface[i] = &changes[i] - } - - err = dbus.Store(resultInterface, changesInterface...) - if err != nil { - return nil, err - } - - return changes, nil -} - -type DisableUnitFileChange struct { - Type string // Type of the change (one of symlink or unlink) - Filename string // File name of the symlink - Destination string // Destination of the symlink -} - -// Reload instructs systemd to scan for and reload unit files. This is -// equivalent to a 'systemctl daemon-reload'. -func (c *Conn) Reload() error { - return c.sysobj.Call("org.freedesktop.systemd1.Manager.Reload", 0).Store() -} - -func unitPath(name string) dbus.ObjectPath { - return dbus.ObjectPath("/org/freedesktop/systemd1/unit/" + PathBusEscape(name)) -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/properties.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/properties.go deleted file mode 100644 index 7520011564..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/properties.go +++ /dev/null @@ -1,218 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package dbus - -import ( - "github.com/godbus/dbus" -) - -// From the systemd docs: -// -// The properties array of StartTransientUnit() may take many of the settings -// that may also be configured in unit files. Not all parameters are currently -// accepted though, but we plan to cover more properties with future release. -// Currently you may set the Description, Slice and all dependency types of -// units, as well as RemainAfterExit, ExecStart for service units, -// TimeoutStopUSec and PIDs for scope units, and CPUAccounting, CPUShares, -// BlockIOAccounting, BlockIOWeight, BlockIOReadBandwidth, -// BlockIOWriteBandwidth, BlockIODeviceWeight, MemoryAccounting, MemoryLimit, -// DevicePolicy, DeviceAllow for services/scopes/slices. These fields map -// directly to their counterparts in unit files and as normal D-Bus object -// properties. The exception here is the PIDs field of scope units which is -// used for construction of the scope only and specifies the initial PIDs to -// add to the scope object. - -type Property struct { - Name string - Value dbus.Variant -} - -type PropertyCollection struct { - Name string - Properties []Property -} - -type execStart struct { - Path string // the binary path to execute - Args []string // an array with all arguments to pass to the executed command, starting with argument 0 - UncleanIsFailure bool // a boolean whether it should be considered a failure if the process exits uncleanly -} - -// PropExecStart sets the ExecStart service property. The first argument is a -// slice with the binary path to execute followed by the arguments to pass to -// the executed command. See -// http://www.freedesktop.org/software/systemd/man/systemd.service.html#ExecStart= -func PropExecStart(command []string, uncleanIsFailure bool) Property { - execStarts := []execStart{ - execStart{ - Path: command[0], - Args: command, - UncleanIsFailure: uncleanIsFailure, - }, - } - - return Property{ - Name: "ExecStart", - Value: dbus.MakeVariant(execStarts), - } -} - -// PropRemainAfterExit sets the RemainAfterExit service property. See -// http://www.freedesktop.org/software/systemd/man/systemd.service.html#RemainAfterExit= -func PropRemainAfterExit(b bool) Property { - return Property{ - Name: "RemainAfterExit", - Value: dbus.MakeVariant(b), - } -} - -// PropDescription sets the Description unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit#Description= -func PropDescription(desc string) Property { - return Property{ - Name: "Description", - Value: dbus.MakeVariant(desc), - } -} - -func propDependency(name string, units []string) Property { - return Property{ - Name: name, - Value: dbus.MakeVariant(units), - } -} - -// PropRequires sets the Requires unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Requires= -func PropRequires(units ...string) Property { - return propDependency("Requires", units) -} - -// PropRequiresOverridable sets the RequiresOverridable unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#RequiresOverridable= -func PropRequiresOverridable(units ...string) Property { - return propDependency("RequiresOverridable", units) -} - -// PropRequisite sets the Requisite unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Requisite= -func PropRequisite(units ...string) Property { - return propDependency("Requisite", units) -} - -// PropRequisiteOverridable sets the RequisiteOverridable unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#RequisiteOverridable= -func PropRequisiteOverridable(units ...string) Property { - return propDependency("RequisiteOverridable", units) -} - -// PropWants sets the Wants unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Wants= -func PropWants(units ...string) Property { - return propDependency("Wants", units) -} - -// PropBindsTo sets the BindsTo unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#BindsTo= -func PropBindsTo(units ...string) Property { - return propDependency("BindsTo", units) -} - -// PropRequiredBy sets the RequiredBy unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#RequiredBy= -func PropRequiredBy(units ...string) Property { - return propDependency("RequiredBy", units) -} - -// PropRequiredByOverridable sets the RequiredByOverridable unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#RequiredByOverridable= -func PropRequiredByOverridable(units ...string) Property { - return propDependency("RequiredByOverridable", units) -} - -// PropWantedBy sets the WantedBy unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#WantedBy= -func PropWantedBy(units ...string) Property { - return propDependency("WantedBy", units) -} - -// PropBoundBy sets the BoundBy unit property. See -// http://www.freedesktop.org/software/systemd/main/systemd.unit.html#BoundBy= -func PropBoundBy(units ...string) Property { - return propDependency("BoundBy", units) -} - -// PropConflicts sets the Conflicts unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Conflicts= -func PropConflicts(units ...string) Property { - return propDependency("Conflicts", units) -} - -// PropConflictedBy sets the ConflictedBy unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#ConflictedBy= -func PropConflictedBy(units ...string) Property { - return propDependency("ConflictedBy", units) -} - -// PropBefore sets the Before unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Before= -func PropBefore(units ...string) Property { - return propDependency("Before", units) -} - -// PropAfter sets the After unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#After= -func PropAfter(units ...string) Property { - return propDependency("After", units) -} - -// PropOnFailure sets the OnFailure unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#OnFailure= -func PropOnFailure(units ...string) Property { - return propDependency("OnFailure", units) -} - -// PropTriggers sets the Triggers unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Triggers= -func PropTriggers(units ...string) Property { - return propDependency("Triggers", units) -} - -// PropTriggeredBy sets the TriggeredBy unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#TriggeredBy= -func PropTriggeredBy(units ...string) Property { - return propDependency("TriggeredBy", units) -} - -// PropPropagatesReloadTo sets the PropagatesReloadTo unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#PropagatesReloadTo= -func PropPropagatesReloadTo(units ...string) Property { - return propDependency("PropagatesReloadTo", units) -} - -// PropRequiresMountsFor sets the RequiresMountsFor unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#RequiresMountsFor= -func PropRequiresMountsFor(units ...string) Property { - return propDependency("RequiresMountsFor", units) -} - -// PropSlice sets the Slice unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.resource-control.html#Slice= -func PropSlice(slice string) Property { - return Property{ - Name: "Slice", - Value: dbus.MakeVariant(slice), - } -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/set.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/set.go deleted file mode 100644 index f92e6fbed1..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/set.go +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package dbus - -type set struct { - data map[string]bool -} - -func (s *set) Add(value string) { - s.data[value] = true -} - -func (s *set) Remove(value string) { - delete(s.data, value) -} - -func (s *set) Contains(value string) (exists bool) { - _, exists = s.data[value] - return -} - -func (s *set) Length() int { - return len(s.data) -} - -func (s *set) Values() (values []string) { - for val, _ := range s.data { - values = append(values, val) - } - return -} - -func newSet() *set { - return &set{make(map[string]bool)} -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/subscription.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/subscription.go deleted file mode 100644 index 996451445c..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/subscription.go +++ /dev/null @@ -1,250 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package dbus - -import ( - "errors" - "time" - - "github.com/godbus/dbus" -) - -const ( - cleanIgnoreInterval = int64(10 * time.Second) - ignoreInterval = int64(30 * time.Millisecond) -) - -// Subscribe sets up this connection to subscribe to all systemd dbus events. -// This is required before calling SubscribeUnits. When the connection closes -// systemd will automatically stop sending signals so there is no need to -// explicitly call Unsubscribe(). -func (c *Conn) Subscribe() error { - c.sigconn.BusObject().Call("org.freedesktop.DBus.AddMatch", 0, - "type='signal',interface='org.freedesktop.systemd1.Manager',member='UnitNew'") - c.sigconn.BusObject().Call("org.freedesktop.DBus.AddMatch", 0, - "type='signal',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged'") - - err := c.sigobj.Call("org.freedesktop.systemd1.Manager.Subscribe", 0).Store() - if err != nil { - return err - } - - return nil -} - -// Unsubscribe this connection from systemd dbus events. -func (c *Conn) Unsubscribe() error { - err := c.sigobj.Call("org.freedesktop.systemd1.Manager.Unsubscribe", 0).Store() - if err != nil { - return err - } - - return nil -} - -func (c *Conn) dispatch() { - ch := make(chan *dbus.Signal, signalBuffer) - - c.sigconn.Signal(ch) - - go func() { - for { - signal, ok := <-ch - if !ok { - return - } - - if signal.Name == "org.freedesktop.systemd1.Manager.JobRemoved" { - c.jobComplete(signal) - } - - if c.subscriber.updateCh == nil { - continue - } - - var unitPath dbus.ObjectPath - switch signal.Name { - case "org.freedesktop.systemd1.Manager.JobRemoved": - unitName := signal.Body[2].(string) - c.sysobj.Call("org.freedesktop.systemd1.Manager.GetUnit", 0, unitName).Store(&unitPath) - case "org.freedesktop.systemd1.Manager.UnitNew": - unitPath = signal.Body[1].(dbus.ObjectPath) - case "org.freedesktop.DBus.Properties.PropertiesChanged": - if signal.Body[0].(string) == "org.freedesktop.systemd1.Unit" { - unitPath = signal.Path - } - } - - if unitPath == dbus.ObjectPath("") { - continue - } - - c.sendSubStateUpdate(unitPath) - } - }() -} - -// Returns two unbuffered channels which will receive all changed units every -// interval. Deleted units are sent as nil. -func (c *Conn) SubscribeUnits(interval time.Duration) (<-chan map[string]*UnitStatus, <-chan error) { - return c.SubscribeUnitsCustom(interval, 0, func(u1, u2 *UnitStatus) bool { return *u1 != *u2 }, nil) -} - -// SubscribeUnitsCustom is like SubscribeUnits but lets you specify the buffer -// size of the channels, the comparison function for detecting changes and a filter -// function for cutting down on the noise that your channel receives. -func (c *Conn) SubscribeUnitsCustom(interval time.Duration, buffer int, isChanged func(*UnitStatus, *UnitStatus) bool, filterUnit func(string) bool) (<-chan map[string]*UnitStatus, <-chan error) { - old := make(map[string]*UnitStatus) - statusChan := make(chan map[string]*UnitStatus, buffer) - errChan := make(chan error, buffer) - - go func() { - for { - timerChan := time.After(interval) - - units, err := c.ListUnits() - if err == nil { - cur := make(map[string]*UnitStatus) - for i := range units { - if filterUnit != nil && filterUnit(units[i].Name) { - continue - } - cur[units[i].Name] = &units[i] - } - - // add all new or changed units - changed := make(map[string]*UnitStatus) - for n, u := range cur { - if oldU, ok := old[n]; !ok || isChanged(oldU, u) { - changed[n] = u - } - delete(old, n) - } - - // add all deleted units - for oldN := range old { - changed[oldN] = nil - } - - old = cur - - if len(changed) != 0 { - statusChan <- changed - } - } else { - errChan <- err - } - - <-timerChan - } - }() - - return statusChan, errChan -} - -type SubStateUpdate struct { - UnitName string - SubState string -} - -// SetSubStateSubscriber writes to updateCh when any unit's substate changes. -// Although this writes to updateCh on every state change, the reported state -// may be more recent than the change that generated it (due to an unavoidable -// race in the systemd dbus interface). That is, this method provides a good -// way to keep a current view of all units' states, but is not guaranteed to -// show every state transition they go through. Furthermore, state changes -// will only be written to the channel with non-blocking writes. If updateCh -// is full, it attempts to write an error to errCh; if errCh is full, the error -// passes silently. -func (c *Conn) SetSubStateSubscriber(updateCh chan<- *SubStateUpdate, errCh chan<- error) { - c.subscriber.Lock() - defer c.subscriber.Unlock() - c.subscriber.updateCh = updateCh - c.subscriber.errCh = errCh -} - -func (c *Conn) sendSubStateUpdate(path dbus.ObjectPath) { - c.subscriber.Lock() - defer c.subscriber.Unlock() - - if c.shouldIgnore(path) { - return - } - - info, err := c.GetUnitProperties(string(path)) - if err != nil { - select { - case c.subscriber.errCh <- err: - default: - } - } - - name := info["Id"].(string) - substate := info["SubState"].(string) - - update := &SubStateUpdate{name, substate} - select { - case c.subscriber.updateCh <- update: - default: - select { - case c.subscriber.errCh <- errors.New("update channel full!"): - default: - } - } - - c.updateIgnore(path, info) -} - -// The ignore functions work around a wart in the systemd dbus interface. -// Requesting the properties of an unloaded unit will cause systemd to send a -// pair of UnitNew/UnitRemoved signals. Because we need to get a unit's -// properties on UnitNew (as that's the only indication of a new unit coming up -// for the first time), we would enter an infinite loop if we did not attempt -// to detect and ignore these spurious signals. The signal themselves are -// indistinguishable from relevant ones, so we (somewhat hackishly) ignore an -// unloaded unit's signals for a short time after requesting its properties. -// This means that we will miss e.g. a transient unit being restarted -// *immediately* upon failure and also a transient unit being started -// immediately after requesting its status (with systemctl status, for example, -// because this causes a UnitNew signal to be sent which then causes us to fetch -// the properties). - -func (c *Conn) shouldIgnore(path dbus.ObjectPath) bool { - t, ok := c.subscriber.ignore[path] - return ok && t >= time.Now().UnixNano() -} - -func (c *Conn) updateIgnore(path dbus.ObjectPath, info map[string]interface{}) { - c.cleanIgnore() - - // unit is unloaded - it will trigger bad systemd dbus behavior - if info["LoadState"].(string) == "not-found" { - c.subscriber.ignore[path] = time.Now().UnixNano() + ignoreInterval - } -} - -// without this, ignore would grow unboundedly over time -func (c *Conn) cleanIgnore() { - now := time.Now().UnixNano() - if c.subscriber.cleanIgnore < now { - c.subscriber.cleanIgnore = now + cleanIgnoreInterval - - for p, t := range c.subscriber.ignore { - if t < now { - delete(c.subscriber.ignore, p) - } - } - } -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/subscription_set.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/subscription_set.go deleted file mode 100644 index 5b408d5847..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/subscription_set.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package dbus - -import ( - "time" -) - -// SubscriptionSet returns a subscription set which is like conn.Subscribe but -// can filter to only return events for a set of units. -type SubscriptionSet struct { - *set - conn *Conn -} - -func (s *SubscriptionSet) filter(unit string) bool { - return !s.Contains(unit) -} - -// Subscribe starts listening for dbus events for all of the units in the set. -// Returns channels identical to conn.SubscribeUnits. -func (s *SubscriptionSet) Subscribe() (<-chan map[string]*UnitStatus, <-chan error) { - // TODO: Make fully evented by using systemd 209 with properties changed values - return s.conn.SubscribeUnitsCustom(time.Second, 0, - mismatchUnitStatus, - func(unit string) bool { return s.filter(unit) }, - ) -} - -// NewSubscriptionSet returns a new subscription set. -func (conn *Conn) NewSubscriptionSet() *SubscriptionSet { - return &SubscriptionSet{newSet(), conn} -} - -// mismatchUnitStatus returns true if the provided UnitStatus objects -// are not equivalent. false is returned if the objects are equivalent. -// Only the Name, Description and state-related fields are used in -// the comparison. -func mismatchUnitStatus(u1, u2 *UnitStatus) bool { - return u1.Name != u2.Name || - u1.Description != u2.Description || - u1.LoadState != u2.LoadState || - u1.ActiveState != u2.ActiveState || - u1.SubState != u2.SubState -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/journal.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/journal.go deleted file mode 100644 index 4fd29c66f1..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/journal.go +++ /dev/null @@ -1,971 +0,0 @@ -// Copyright 2015 RedHat, Inc. -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package sdjournal provides a low-level Go interface to the -// systemd journal wrapped around the sd-journal C API. -// -// All public read methods map closely to the sd-journal API functions. See the -// sd-journal.h documentation[1] for information about each function. -// -// To write to the journal, see the pure-Go "journal" package -// -// [1] http://www.freedesktop.org/software/systemd/man/sd-journal.html -package sdjournal - -// #include -// #include -// #include -// #include -// -// int -// my_sd_journal_open(void *f, sd_journal **ret, int flags) -// { -// int (*sd_journal_open)(sd_journal **, int); -// -// sd_journal_open = f; -// return sd_journal_open(ret, flags); -// } -// -// int -// my_sd_journal_open_directory(void *f, sd_journal **ret, const char *path, int flags) -// { -// int (*sd_journal_open_directory)(sd_journal **, const char *, int); -// -// sd_journal_open_directory = f; -// return sd_journal_open_directory(ret, path, flags); -// } -// -// void -// my_sd_journal_close(void *f, sd_journal *j) -// { -// int (*sd_journal_close)(sd_journal *); -// -// sd_journal_close = f; -// sd_journal_close(j); -// } -// -// int -// my_sd_journal_get_usage(void *f, sd_journal *j, uint64_t *bytes) -// { -// int (*sd_journal_get_usage)(sd_journal *, uint64_t *); -// -// sd_journal_get_usage = f; -// return sd_journal_get_usage(j, bytes); -// } -// -// int -// my_sd_journal_add_match(void *f, sd_journal *j, const void *data, size_t size) -// { -// int (*sd_journal_add_match)(sd_journal *, const void *, size_t); -// -// sd_journal_add_match = f; -// return sd_journal_add_match(j, data, size); -// } -// -// int -// my_sd_journal_add_disjunction(void *f, sd_journal *j) -// { -// int (*sd_journal_add_disjunction)(sd_journal *); -// -// sd_journal_add_disjunction = f; -// return sd_journal_add_disjunction(j); -// } -// -// int -// my_sd_journal_add_conjunction(void *f, sd_journal *j) -// { -// int (*sd_journal_add_conjunction)(sd_journal *); -// -// sd_journal_add_conjunction = f; -// return sd_journal_add_conjunction(j); -// } -// -// void -// my_sd_journal_flush_matches(void *f, sd_journal *j) -// { -// int (*sd_journal_flush_matches)(sd_journal *); -// -// sd_journal_flush_matches = f; -// sd_journal_flush_matches(j); -// } -// -// int -// my_sd_journal_next(void *f, sd_journal *j) -// { -// int (*sd_journal_next)(sd_journal *); -// -// sd_journal_next = f; -// return sd_journal_next(j); -// } -// -// int -// my_sd_journal_next_skip(void *f, sd_journal *j, uint64_t skip) -// { -// int (*sd_journal_next_skip)(sd_journal *, uint64_t); -// -// sd_journal_next_skip = f; -// return sd_journal_next_skip(j, skip); -// } -// -// int -// my_sd_journal_previous(void *f, sd_journal *j) -// { -// int (*sd_journal_previous)(sd_journal *); -// -// sd_journal_previous = f; -// return sd_journal_previous(j); -// } -// -// int -// my_sd_journal_previous_skip(void *f, sd_journal *j, uint64_t skip) -// { -// int (*sd_journal_previous_skip)(sd_journal *, uint64_t); -// -// sd_journal_previous_skip = f; -// return sd_journal_previous_skip(j, skip); -// } -// -// int -// my_sd_journal_get_data(void *f, sd_journal *j, const char *field, const void **data, size_t *length) -// { -// int (*sd_journal_get_data)(sd_journal *, const char *, const void **, size_t *); -// -// sd_journal_get_data = f; -// return sd_journal_get_data(j, field, data, length); -// } -// -// int -// my_sd_journal_set_data_threshold(void *f, sd_journal *j, size_t sz) -// { -// int (*sd_journal_set_data_threshold)(sd_journal *, size_t); -// -// sd_journal_set_data_threshold = f; -// return sd_journal_set_data_threshold(j, sz); -// } -// -// int -// my_sd_journal_get_cursor(void *f, sd_journal *j, char **cursor) -// { -// int (*sd_journal_get_cursor)(sd_journal *, char **); -// -// sd_journal_get_cursor = f; -// return sd_journal_get_cursor(j, cursor); -// } -// -// int -// my_sd_journal_test_cursor(void *f, sd_journal *j, const char *cursor) -// { -// int (*sd_journal_test_cursor)(sd_journal *, const char *); -// -// sd_journal_test_cursor = f; -// return sd_journal_test_cursor(j, cursor); -// } -// -// int -// my_sd_journal_get_realtime_usec(void *f, sd_journal *j, uint64_t *usec) -// { -// int (*sd_journal_get_realtime_usec)(sd_journal *, uint64_t *); -// -// sd_journal_get_realtime_usec = f; -// return sd_journal_get_realtime_usec(j, usec); -// } -// -// int -// my_sd_journal_get_monotonic_usec(void *f, sd_journal *j, uint64_t *usec, sd_id128_t *boot_id) -// { -// int (*sd_journal_get_monotonic_usec)(sd_journal *, uint64_t *, sd_id128_t *); -// -// sd_journal_get_monotonic_usec = f; -// return sd_journal_get_monotonic_usec(j, usec, boot_id); -// } -// -// int -// my_sd_journal_seek_head(void *f, sd_journal *j) -// { -// int (*sd_journal_seek_head)(sd_journal *); -// -// sd_journal_seek_head = f; -// return sd_journal_seek_head(j); -// } -// -// int -// my_sd_journal_seek_tail(void *f, sd_journal *j) -// { -// int (*sd_journal_seek_tail)(sd_journal *); -// -// sd_journal_seek_tail = f; -// return sd_journal_seek_tail(j); -// } -// -// -// int -// my_sd_journal_seek_cursor(void *f, sd_journal *j, const char *cursor) -// { -// int (*sd_journal_seek_cursor)(sd_journal *, const char *); -// -// sd_journal_seek_cursor = f; -// return sd_journal_seek_cursor(j, cursor); -// } -// -// int -// my_sd_journal_seek_realtime_usec(void *f, sd_journal *j, uint64_t usec) -// { -// int (*sd_journal_seek_realtime_usec)(sd_journal *, uint64_t); -// -// sd_journal_seek_realtime_usec = f; -// return sd_journal_seek_realtime_usec(j, usec); -// } -// -// int -// my_sd_journal_wait(void *f, sd_journal *j, uint64_t timeout_usec) -// { -// int (*sd_journal_wait)(sd_journal *, uint64_t); -// -// sd_journal_wait = f; -// return sd_journal_wait(j, timeout_usec); -// } -// -// void -// my_sd_journal_restart_data(void *f, sd_journal *j) -// { -// void (*sd_journal_restart_data)(sd_journal *); -// -// sd_journal_restart_data = f; -// sd_journal_restart_data(j); -// } -// -// int -// my_sd_journal_enumerate_data(void *f, sd_journal *j, const void **data, size_t *length) -// { -// int (*sd_journal_enumerate_data)(sd_journal *, const void **, size_t *); -// -// sd_journal_enumerate_data = f; -// return sd_journal_enumerate_data(j, data, length); -// } -// -import "C" -import ( - "fmt" - "path/filepath" - "strings" - "sync" - "syscall" - "time" - "unsafe" - - "github.com/coreos/pkg/dlopen" -) - -var libsystemdFunctions = map[string]unsafe.Pointer{} - -// Journal entry field strings which correspond to: -// http://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html -const ( - // User Journal Fields - SD_JOURNAL_FIELD_MESSAGE = "MESSAGE" - SD_JOURNAL_FIELD_MESSAGE_ID = "MESSAGE_ID" - SD_JOURNAL_FIELD_PRIORITY = "PRIORITY" - SD_JOURNAL_FIELD_CODE_FILE = "CODE_FILE" - SD_JOURNAL_FIELD_CODE_LINE = "CODE_LINE" - SD_JOURNAL_FIELD_CODE_FUNC = "CODE_FUNC" - SD_JOURNAL_FIELD_ERRNO = "ERRNO" - SD_JOURNAL_FIELD_SYSLOG_FACILITY = "SYSLOG_FACILITY" - SD_JOURNAL_FIELD_SYSLOG_IDENTIFIER = "SYSLOG_IDENTIFIER" - SD_JOURNAL_FIELD_SYSLOG_PID = "SYSLOG_PID" - - // Trusted Journal Fields - SD_JOURNAL_FIELD_PID = "_PID" - SD_JOURNAL_FIELD_UID = "_UID" - SD_JOURNAL_FIELD_GID = "_GID" - SD_JOURNAL_FIELD_COMM = "_COMM" - SD_JOURNAL_FIELD_EXE = "_EXE" - SD_JOURNAL_FIELD_CMDLINE = "_CMDLINE" - SD_JOURNAL_FIELD_CAP_EFFECTIVE = "_CAP_EFFECTIVE" - SD_JOURNAL_FIELD_AUDIT_SESSION = "_AUDIT_SESSION" - SD_JOURNAL_FIELD_AUDIT_LOGINUID = "_AUDIT_LOGINUID" - SD_JOURNAL_FIELD_SYSTEMD_CGROUP = "_SYSTEMD_CGROUP" - SD_JOURNAL_FIELD_SYSTEMD_SESSION = "_SYSTEMD_SESSION" - SD_JOURNAL_FIELD_SYSTEMD_UNIT = "_SYSTEMD_UNIT" - SD_JOURNAL_FIELD_SYSTEMD_USER_UNIT = "_SYSTEMD_USER_UNIT" - SD_JOURNAL_FIELD_SYSTEMD_OWNER_UID = "_SYSTEMD_OWNER_UID" - SD_JOURNAL_FIELD_SYSTEMD_SLICE = "_SYSTEMD_SLICE" - SD_JOURNAL_FIELD_SELINUX_CONTEXT = "_SELINUX_CONTEXT" - SD_JOURNAL_FIELD_SOURCE_REALTIME_TIMESTAMP = "_SOURCE_REALTIME_TIMESTAMP" - SD_JOURNAL_FIELD_BOOT_ID = "_BOOT_ID" - SD_JOURNAL_FIELD_MACHINE_ID = "_MACHINE_ID" - SD_JOURNAL_FIELD_HOSTNAME = "_HOSTNAME" - SD_JOURNAL_FIELD_TRANSPORT = "_TRANSPORT" - - // Address Fields - SD_JOURNAL_FIELD_CURSOR = "__CURSOR" - SD_JOURNAL_FIELD_REALTIME_TIMESTAMP = "__REALTIME_TIMESTAMP" - SD_JOURNAL_FIELD_MONOTONIC_TIMESTAMP = "__MONOTONIC_TIMESTAMP" -) - -// Journal event constants -const ( - SD_JOURNAL_NOP = int(C.SD_JOURNAL_NOP) - SD_JOURNAL_APPEND = int(C.SD_JOURNAL_APPEND) - SD_JOURNAL_INVALIDATE = int(C.SD_JOURNAL_INVALIDATE) -) - -const ( - // IndefiniteWait is a sentinel value that can be passed to - // sdjournal.Wait() to signal an indefinite wait for new journal - // events. It is implemented as the maximum value for a time.Duration: - // https://github.com/golang/go/blob/e4dcf5c8c22d98ac9eac7b9b226596229624cb1d/src/time/time.go#L434 - IndefiniteWait time.Duration = 1<<63 - 1 -) - -var libsystemdNames = []string{ - // systemd < 209 - "libsystemd-journal.so.0", - "libsystemd-journal.so", - - // systemd >= 209 merged libsystemd-journal into libsystemd proper - "libsystemd.so.0", - "libsystemd.so", -} - -// Journal is a Go wrapper of an sd_journal structure. -type Journal struct { - cjournal *C.sd_journal - mu sync.Mutex - lib *dlopen.LibHandle -} - -// JournalEntry represents all fields of a journal entry plus address fields. -type JournalEntry struct { - Fields map[string]string - Cursor string - RealtimeTimestamp uint64 - MonotonicTimestamp uint64 -} - -// Match is a convenience wrapper to describe filters supplied to AddMatch. -type Match struct { - Field string - Value string -} - -// String returns a string representation of a Match suitable for use with AddMatch. -func (m *Match) String() string { - return m.Field + "=" + m.Value -} - -func (j *Journal) getFunction(name string) (unsafe.Pointer, error) { - j.mu.Lock() - defer j.mu.Unlock() - f, ok := libsystemdFunctions[name] - if !ok { - var err error - f, err = j.lib.GetSymbolPointer(name) - if err != nil { - return nil, err - } - - libsystemdFunctions[name] = f - } - - return f, nil -} - -// NewJournal returns a new Journal instance pointing to the local journal -func NewJournal() (j *Journal, err error) { - h, err := dlopen.GetHandle(libsystemdNames) - if err != nil { - return nil, err - } - defer func() { - if err == nil { - return - } - err2 := h.Close() - if err2 != nil { - err = fmt.Errorf(`%q and "error closing handle: %v"`, err, err2) - } - }() - - j = &Journal{lib: h} - - sd_journal_open, err := j.getFunction("sd_journal_open") - if err != nil { - return nil, err - } - - r := C.my_sd_journal_open(sd_journal_open, &j.cjournal, C.SD_JOURNAL_LOCAL_ONLY) - - if r < 0 { - return nil, fmt.Errorf("failed to open journal: %d", syscall.Errno(-r)) - } - - return j, nil -} - -// NewJournalFromDir returns a new Journal instance pointing to a journal residing -// in a given directory. The supplied path may be relative or absolute; if -// relative, it will be converted to an absolute path before being opened. -func NewJournalFromDir(path string) (j *Journal, err error) { - h, err := dlopen.GetHandle(libsystemdNames) - if err != nil { - return nil, err - } - defer func() { - if err == nil { - return - } - err2 := h.Close() - if err2 != nil { - err = fmt.Errorf(`%q and "error closing handle: %v"`, err, err2) - } - }() - - path, err = filepath.Abs(path) - if err != nil { - return nil, err - } - - j = &Journal{lib: h} - - sd_journal_open_directory, err := j.getFunction("sd_journal_open_directory") - if err != nil { - return nil, err - } - - p := C.CString(path) - defer C.free(unsafe.Pointer(p)) - - r := C.my_sd_journal_open_directory(sd_journal_open_directory, &j.cjournal, p, 0) - if r < 0 { - return nil, fmt.Errorf("failed to open journal in directory %q: %d", path, syscall.Errno(-r)) - } - - return j, nil -} - -// Close closes a journal opened with NewJournal. -func (j *Journal) Close() error { - sd_journal_close, err := j.getFunction("sd_journal_close") - if err != nil { - return err - } - - j.mu.Lock() - C.my_sd_journal_close(sd_journal_close, j.cjournal) - j.mu.Unlock() - - // we don't close the handle to reuse the symbol cache between Journal - // instances. It will go away when the process exits. - return nil -} - -// AddMatch adds a match by which to filter the entries of the journal. -func (j *Journal) AddMatch(match string) error { - sd_journal_add_match, err := j.getFunction("sd_journal_add_match") - if err != nil { - return err - } - - m := C.CString(match) - defer C.free(unsafe.Pointer(m)) - - j.mu.Lock() - r := C.my_sd_journal_add_match(sd_journal_add_match, j.cjournal, unsafe.Pointer(m), C.size_t(len(match))) - j.mu.Unlock() - - if r < 0 { - return fmt.Errorf("failed to add match: %d", syscall.Errno(-r)) - } - - return nil -} - -// AddDisjunction inserts a logical OR in the match list. -func (j *Journal) AddDisjunction() error { - sd_journal_add_disjunction, err := j.getFunction("sd_journal_add_disjunction") - if err != nil { - return err - } - - j.mu.Lock() - r := C.my_sd_journal_add_disjunction(sd_journal_add_disjunction, j.cjournal) - j.mu.Unlock() - - if r < 0 { - return fmt.Errorf("failed to add a disjunction in the match list: %d", syscall.Errno(-r)) - } - - return nil -} - -// AddConjunction inserts a logical AND in the match list. -func (j *Journal) AddConjunction() error { - sd_journal_add_conjunction, err := j.getFunction("sd_journal_add_conjunction") - if err != nil { - return err - } - - j.mu.Lock() - r := C.my_sd_journal_add_conjunction(sd_journal_add_conjunction, j.cjournal) - j.mu.Unlock() - - if r < 0 { - return fmt.Errorf("failed to add a conjunction in the match list: %d", syscall.Errno(-r)) - } - - return nil -} - -// FlushMatches flushes all matches, disjunctions and conjunctions. -func (j *Journal) FlushMatches() { - sd_journal_flush_matches, err := j.getFunction("sd_journal_flush_matches") - if err != nil { - return - } - - j.mu.Lock() - C.my_sd_journal_flush_matches(sd_journal_flush_matches, j.cjournal) - j.mu.Unlock() -} - -// Next advances the read pointer into the journal by one entry. -func (j *Journal) Next() (int, error) { - sd_journal_next, err := j.getFunction("sd_journal_next") - if err != nil { - return -1, err - } - - j.mu.Lock() - r := C.my_sd_journal_next(sd_journal_next, j.cjournal) - j.mu.Unlock() - - if r < 0 { - return int(r), fmt.Errorf("failed to iterate journal: %d", syscall.Errno(-r)) - } - - return int(r), nil -} - -// NextSkip advances the read pointer by multiple entries at once, -// as specified by the skip parameter. -func (j *Journal) NextSkip(skip uint64) (uint64, error) { - sd_journal_next_skip, err := j.getFunction("sd_journal_next_skip") - if err != nil { - return 0, err - } - - j.mu.Lock() - r := C.my_sd_journal_next_skip(sd_journal_next_skip, j.cjournal, C.uint64_t(skip)) - j.mu.Unlock() - - if r < 0 { - return uint64(r), fmt.Errorf("failed to iterate journal: %d", syscall.Errno(-r)) - } - - return uint64(r), nil -} - -// Previous sets the read pointer into the journal back by one entry. -func (j *Journal) Previous() (uint64, error) { - sd_journal_previous, err := j.getFunction("sd_journal_previous") - if err != nil { - return 0, err - } - - j.mu.Lock() - r := C.my_sd_journal_previous(sd_journal_previous, j.cjournal) - j.mu.Unlock() - - if r < 0 { - return uint64(r), fmt.Errorf("failed to iterate journal: %d", syscall.Errno(-r)) - } - - return uint64(r), nil -} - -// PreviousSkip sets back the read pointer by multiple entries at once, -// as specified by the skip parameter. -func (j *Journal) PreviousSkip(skip uint64) (uint64, error) { - sd_journal_previous_skip, err := j.getFunction("sd_journal_previous_skip") - if err != nil { - return 0, err - } - - j.mu.Lock() - r := C.my_sd_journal_previous_skip(sd_journal_previous_skip, j.cjournal, C.uint64_t(skip)) - j.mu.Unlock() - - if r < 0 { - return uint64(r), fmt.Errorf("failed to iterate journal: %d", syscall.Errno(-r)) - } - - return uint64(r), nil -} - -// GetData gets the data object associated with a specific field from the -// current journal entry. -func (j *Journal) GetData(field string) (string, error) { - sd_journal_get_data, err := j.getFunction("sd_journal_get_data") - if err != nil { - return "", err - } - - f := C.CString(field) - defer C.free(unsafe.Pointer(f)) - - var d unsafe.Pointer - var l C.size_t - - j.mu.Lock() - r := C.my_sd_journal_get_data(sd_journal_get_data, j.cjournal, f, &d, &l) - j.mu.Unlock() - - if r < 0 { - return "", fmt.Errorf("failed to read message: %d", syscall.Errno(-r)) - } - - msg := C.GoStringN((*C.char)(d), C.int(l)) - - return msg, nil -} - -// GetDataValue gets the data object associated with a specific field from the -// current journal entry, returning only the value of the object. -func (j *Journal) GetDataValue(field string) (string, error) { - val, err := j.GetData(field) - if err != nil { - return "", err - } - return strings.SplitN(val, "=", 2)[1], nil -} - -// GetEntry returns a full representation of a journal entry with -// all key-value pairs of data as well as address fields (cursor, realtime -// timestamp and monotonic timestamp) -func (j *Journal) GetEntry() (*JournalEntry, error) { - sd_journal_get_realtime_usec, err := j.getFunction("sd_journal_get_realtime_usec") - if err != nil { - return nil, err - } - - sd_journal_get_monotonic_usec, err := j.getFunction("sd_journal_get_monotonic_usec") - if err != nil { - return nil, err - } - - sd_journal_get_cursor, err := j.getFunction("sd_journal_get_cursor") - if err != nil { - return nil, err - } - - sd_journal_restart_data, err := j.getFunction("sd_journal_restart_data") - if err != nil { - return nil, err - } - - sd_journal_enumerate_data, err := j.getFunction("sd_journal_enumerate_data") - if err != nil { - return nil, err - } - - j.mu.Lock() - defer j.mu.Unlock() - - var r C.int - entry := &JournalEntry{Fields: make(map[string]string)} - - var realtimeUsec C.uint64_t - r = C.my_sd_journal_get_realtime_usec(sd_journal_get_realtime_usec, j.cjournal, &realtimeUsec) - if r < 0 { - return nil, fmt.Errorf("failed to get realtime timestamp: %d", syscall.Errno(-r)) - } - - entry.RealtimeTimestamp = uint64(realtimeUsec) - - var monotonicUsec C.uint64_t - var boot_id C.sd_id128_t - - r = C.my_sd_journal_get_monotonic_usec(sd_journal_get_monotonic_usec, j.cjournal, &monotonicUsec, &boot_id) - if r < 0 { - return nil, fmt.Errorf("failed to get monotonic timestamp: %d", syscall.Errno(-r)) - } - - entry.MonotonicTimestamp = uint64(monotonicUsec) - - var c *C.char - r = C.my_sd_journal_get_cursor(sd_journal_get_cursor, j.cjournal, &c) - if r < 0 { - return nil, fmt.Errorf("failed to get cursor: %d", syscall.Errno(-r)) - } - - entry.Cursor = C.GoString(c) - - // Implements the JOURNAL_FOREACH_DATA_RETVAL macro from journal-internal.h - var d unsafe.Pointer - var l C.size_t - C.my_sd_journal_restart_data(sd_journal_restart_data, j.cjournal) - for { - r = C.my_sd_journal_enumerate_data(sd_journal_enumerate_data, j.cjournal, &d, &l) - if r == 0 { - break - } - - if r < 0 { - return nil, fmt.Errorf("failed to read message field: %d", syscall.Errno(-r)) - } - - msg := C.GoStringN((*C.char)(d), C.int(l)) - kv := strings.SplitN(msg, "=", 2) - if len(kv) < 2 { - return nil, fmt.Errorf("failed to parse field") - } - - entry.Fields[kv[0]] = kv[1] - } - - return entry, nil -} - -// SetDataThresold sets the data field size threshold for data returned by -// GetData. To retrieve the complete data fields this threshold should be -// turned off by setting it to 0, so that the library always returns the -// complete data objects. -func (j *Journal) SetDataThreshold(threshold uint64) error { - sd_journal_set_data_threshold, err := j.getFunction("sd_journal_set_data_threshold") - if err != nil { - return err - } - - j.mu.Lock() - r := C.my_sd_journal_set_data_threshold(sd_journal_set_data_threshold, j.cjournal, C.size_t(threshold)) - j.mu.Unlock() - - if r < 0 { - return fmt.Errorf("failed to set data threshold: %d", syscall.Errno(-r)) - } - - return nil -} - -// GetRealtimeUsec gets the realtime (wallclock) timestamp of the current -// journal entry. -func (j *Journal) GetRealtimeUsec() (uint64, error) { - var usec C.uint64_t - - sd_journal_get_realtime_usec, err := j.getFunction("sd_journal_get_realtime_usec") - if err != nil { - return 0, err - } - - j.mu.Lock() - r := C.my_sd_journal_get_realtime_usec(sd_journal_get_realtime_usec, j.cjournal, &usec) - j.mu.Unlock() - - if r < 0 { - return 0, fmt.Errorf("failed to get realtime timestamp: %d", syscall.Errno(-r)) - } - - return uint64(usec), nil -} - -// GetMonotonicUsec gets the monotonic timestamp of the current journal entry. -func (j *Journal) GetMonotonicUsec() (uint64, error) { - var usec C.uint64_t - var boot_id C.sd_id128_t - - sd_journal_get_monotonic_usec, err := j.getFunction("sd_journal_get_monotonic_usec") - if err != nil { - return 0, err - } - - j.mu.Lock() - r := C.my_sd_journal_get_monotonic_usec(sd_journal_get_monotonic_usec, j.cjournal, &usec, &boot_id) - j.mu.Unlock() - - if r < 0 { - return 0, fmt.Errorf("failed to get monotonic timestamp: %d", syscall.Errno(-r)) - } - - return uint64(usec), nil -} - -// GetCursor gets the cursor of the current journal entry. -func (j *Journal) GetCursor() (string, error) { - var d *C.char - - sd_journal_get_cursor, err := j.getFunction("sd_journal_get_cursor") - if err != nil { - return "", err - } - - j.mu.Lock() - r := C.my_sd_journal_get_cursor(sd_journal_get_cursor, j.cjournal, &d) - j.mu.Unlock() - - if r < 0 { - return "", fmt.Errorf("failed to get cursor: %d", syscall.Errno(-r)) - } - - cursor := C.GoString(d) - - return cursor, nil -} - -// TestCursor checks whether the current position in the journal matches the -// specified cursor -func (j *Journal) TestCursor(cursor string) error { - sd_journal_test_cursor, err := j.getFunction("sd_journal_test_cursor") - if err != nil { - return err - } - - c := C.CString(cursor) - defer C.free(unsafe.Pointer(c)) - - j.mu.Lock() - r := C.my_sd_journal_test_cursor(sd_journal_test_cursor, j.cjournal, c) - j.mu.Unlock() - - if r < 0 { - return fmt.Errorf("failed to test to cursor %q: %d", cursor, syscall.Errno(-r)) - } - - return nil -} - -// SeekHead seeks to the beginning of the journal, i.e. the oldest available -// entry. -func (j *Journal) SeekHead() error { - sd_journal_seek_head, err := j.getFunction("sd_journal_seek_head") - if err != nil { - return err - } - - j.mu.Lock() - r := C.my_sd_journal_seek_head(sd_journal_seek_head, j.cjournal) - j.mu.Unlock() - - if r < 0 { - return fmt.Errorf("failed to seek to head of journal: %d", syscall.Errno(-r)) - } - - return nil -} - -// SeekTail may be used to seek to the end of the journal, i.e. the most recent -// available entry. -func (j *Journal) SeekTail() error { - sd_journal_seek_tail, err := j.getFunction("sd_journal_seek_tail") - if err != nil { - return err - } - - j.mu.Lock() - r := C.my_sd_journal_seek_tail(sd_journal_seek_tail, j.cjournal) - j.mu.Unlock() - - if r < 0 { - return fmt.Errorf("failed to seek to tail of journal: %d", syscall.Errno(-r)) - } - - return nil -} - -// SeekRealtimeUsec seeks to the entry with the specified realtime (wallclock) -// timestamp, i.e. CLOCK_REALTIME. -func (j *Journal) SeekRealtimeUsec(usec uint64) error { - sd_journal_seek_realtime_usec, err := j.getFunction("sd_journal_seek_realtime_usec") - if err != nil { - return err - } - - j.mu.Lock() - r := C.my_sd_journal_seek_realtime_usec(sd_journal_seek_realtime_usec, j.cjournal, C.uint64_t(usec)) - j.mu.Unlock() - - if r < 0 { - return fmt.Errorf("failed to seek to %d: %d", usec, syscall.Errno(-r)) - } - - return nil -} - -// SeekCursor seeks to a concrete journal cursor. -func (j *Journal) SeekCursor(cursor string) error { - sd_journal_seek_cursor, err := j.getFunction("sd_journal_seek_cursor") - if err != nil { - return err - } - - c := C.CString(cursor) - defer C.free(unsafe.Pointer(c)) - - j.mu.Lock() - r := C.my_sd_journal_seek_cursor(sd_journal_seek_cursor, j.cjournal, c) - j.mu.Unlock() - - if r < 0 { - return fmt.Errorf("failed to seek to cursor %q: %d", cursor, syscall.Errno(-r)) - } - - return nil -} - -// Wait will synchronously wait until the journal gets changed. The maximum time -// this call sleeps may be controlled with the timeout parameter. If -// sdjournal.IndefiniteWait is passed as the timeout parameter, Wait will -// wait indefinitely for a journal change. -func (j *Journal) Wait(timeout time.Duration) int { - var to uint64 - - sd_journal_wait, err := j.getFunction("sd_journal_wait") - if err != nil { - return -1 - } - - if timeout == IndefiniteWait { - // sd_journal_wait(3) calls for a (uint64_t) -1 to be passed to signify - // indefinite wait, but using a -1 overflows our C.uint64_t, so we use an - // equivalent hex value. - to = 0xffffffffffffffff - } else { - to = uint64(time.Now().Add(timeout).Unix() / 1000) - } - j.mu.Lock() - r := C.my_sd_journal_wait(sd_journal_wait, j.cjournal, C.uint64_t(to)) - j.mu.Unlock() - - return int(r) -} - -// GetUsage returns the journal disk space usage, in bytes. -func (j *Journal) GetUsage() (uint64, error) { - var out C.uint64_t - - sd_journal_get_usage, err := j.getFunction("sd_journal_get_usage") - if err != nil { - return 0, err - } - - j.mu.Lock() - r := C.my_sd_journal_get_usage(sd_journal_get_usage, j.cjournal, &out) - j.mu.Unlock() - - if r < 0 { - return 0, fmt.Errorf("failed to get journal disk space usage: %d", syscall.Errno(-r)) - } - - return uint64(out), nil -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/read.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/read.go deleted file mode 100644 index 71ee806a96..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-systemd/sdjournal/read.go +++ /dev/null @@ -1,252 +0,0 @@ -// Copyright 2015 RedHat, Inc. -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package sdjournal - -import ( - "errors" - "fmt" - "io" - "log" - "strings" - "time" -) - -var ( - ErrExpired = errors.New("Timeout expired") -) - -// JournalReaderConfig represents options to drive the behavior of a JournalReader. -type JournalReaderConfig struct { - // The Since, NumFromTail and Cursor options are mutually exclusive and - // determine where the reading begins within the journal. The order in which - // options are written is exactly the order of precedence. - Since time.Duration // start relative to a Duration from now - NumFromTail uint64 // start relative to the tail - Cursor string // start relative to the cursor - - // Show only journal entries whose fields match the supplied values. If - // the array is empty, entries will not be filtered. - Matches []Match - - // If not empty, the journal instance will point to a journal residing - // in this directory. The supplied path may be relative or absolute. - Path string -} - -// JournalReader is an io.ReadCloser which provides a simple interface for iterating through the -// systemd journal. A JournalReader is not safe for concurrent use by multiple goroutines. -type JournalReader struct { - journal *Journal - msgReader *strings.Reader -} - -// NewJournalReader creates a new JournalReader with configuration options that are similar to the -// systemd journalctl tool's iteration and filtering features. -func NewJournalReader(config JournalReaderConfig) (*JournalReader, error) { - r := &JournalReader{} - - // Open the journal - var err error - if config.Path != "" { - r.journal, err = NewJournalFromDir(config.Path) - } else { - r.journal, err = NewJournal() - } - if err != nil { - return nil, err - } - - // Add any supplied matches - for _, m := range config.Matches { - r.journal.AddMatch(m.String()) - } - - // Set the start position based on options - if config.Since != 0 { - // Start based on a relative time - start := time.Now().Add(config.Since) - if err := r.journal.SeekRealtimeUsec(uint64(start.UnixNano() / 1000)); err != nil { - return nil, err - } - } else if config.NumFromTail != 0 { - // Start based on a number of lines before the tail - if err := r.journal.SeekTail(); err != nil { - return nil, err - } - - // Move the read pointer into position near the tail. Go one further than - // the option so that the initial cursor advancement positions us at the - // correct starting point. - if _, err := r.journal.PreviousSkip(config.NumFromTail + 1); err != nil { - return nil, err - } - } else if config.Cursor != "" { - // Start based on a custom cursor - if err := r.journal.SeekCursor(config.Cursor); err != nil { - return nil, err - } - } - - return r, nil -} - -// Read reads entries from the journal. Read follows the Reader interface so -// it must be able to read a specific amount of bytes. Journald on the other -// hand only allows us to read full entries of arbitrary size (without byte -// granularity). JournalReader is therefore internally buffering entries that -// don't fit in the read buffer. Callers should keep calling until 0 and/or an -// error is returned. -func (r *JournalReader) Read(b []byte) (int, error) { - var err error - - if r.msgReader == nil { - var c int - - // Advance the journal cursor. It has to be called at least one time - // before reading - c, err = r.journal.Next() - - // An unexpected error - if err != nil { - return 0, err - } - - // EOF detection - if c == 0 { - return 0, io.EOF - } - - // Build a message - var msg string - msg, err = r.buildMessage() - - if err != nil { - return 0, err - } - r.msgReader = strings.NewReader(msg) - } - - // Copy and return the message - var sz int - sz, err = r.msgReader.Read(b) - if err == io.EOF { - // The current entry has been fully read. Don't propagate this - // EOF, so the next entry can be read at the next Read() - // iteration. - r.msgReader = nil - return sz, nil - } - if err != nil { - return sz, err - } - if r.msgReader.Len() == 0 { - r.msgReader = nil - } - - return sz, nil -} - -// Close closes the JournalReader's handle to the journal. -func (r *JournalReader) Close() error { - return r.journal.Close() -} - -// Rewind attempts to rewind the JournalReader to the first entry. -func (r *JournalReader) Rewind() error { - r.msgReader = nil - return r.journal.SeekHead() -} - -// Follow synchronously follows the JournalReader, writing each new journal entry to writer. The -// follow will continue until a single time.Time is received on the until channel. -func (r *JournalReader) Follow(until <-chan time.Time, writer io.Writer) (err error) { - - // Process journal entries and events. Entries are flushed until the tail or - // timeout is reached, and then we wait for new events or the timeout. - var msg = make([]byte, 64*1<<(10)) -process: - for { - c, err := r.Read(msg) - if err != nil && err != io.EOF { - break process - } - - select { - case <-until: - return ErrExpired - default: - if c > 0 { - if _, err = writer.Write(msg[:c]); err != nil { - break process - } - continue process - } - } - - // We're at the tail, so wait for new events or time out. - // Holds journal events to process. Tightly bounded for now unless there's a - // reason to unblock the journal watch routine more quickly. - events := make(chan int, 1) - pollDone := make(chan bool, 1) - go func() { - for { - select { - case <-pollDone: - return - default: - events <- r.journal.Wait(time.Duration(1) * time.Second) - } - } - }() - - select { - case <-until: - pollDone <- true - return ErrExpired - case e := <-events: - pollDone <- true - switch e { - case SD_JOURNAL_NOP, SD_JOURNAL_APPEND, SD_JOURNAL_INVALIDATE: - // TODO: need to account for any of these? - default: - log.Printf("Received unknown event: %d\n", e) - } - continue process - } - } - - return -} - -// buildMessage returns a string representing the current journal entry in a simple format which -// includes the entry timestamp and MESSAGE field. -func (r *JournalReader) buildMessage() (string, error) { - var msg string - var usec uint64 - var err error - - if msg, err = r.journal.GetData("MESSAGE"); err != nil { - return "", err - } - - if usec, err = r.journal.GetRealtimeUsec(); err != nil { - return "", err - } - - timestamp := time.Unix(0, int64(usec)*int64(time.Microsecond)) - - return fmt.Sprintf("%s %s\n", timestamp, msg), nil -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/unit/deserialize.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/unit/deserialize.go deleted file mode 100644 index 8a88162f98..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-systemd/unit/deserialize.go +++ /dev/null @@ -1,276 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package unit - -import ( - "bufio" - "bytes" - "errors" - "fmt" - "io" - "strings" - "unicode" -) - -const ( - // SYSTEMD_LINE_MAX mimics the maximum line length that systemd can use. - // On typical systemd platforms (i.e. modern Linux), this will most - // commonly be 2048, so let's use that as a sanity check. - // Technically, we should probably pull this at runtime: - // SYSTEMD_LINE_MAX = int(C.sysconf(C.__SC_LINE_MAX)) - // but this would introduce an (unfortunate) dependency on cgo - SYSTEMD_LINE_MAX = 2048 - - // characters that systemd considers indicate a newline - SYSTEMD_NEWLINE = "\r\n" -) - -var ( - ErrLineTooLong = fmt.Errorf("line too long (max %d bytes)", SYSTEMD_LINE_MAX) -) - -// Deserialize parses a systemd unit file into a list of UnitOption objects. -func Deserialize(f io.Reader) (opts []*UnitOption, err error) { - lexer, optchan, errchan := newLexer(f) - go lexer.lex() - - for opt := range optchan { - opts = append(opts, &(*opt)) - } - - err = <-errchan - return opts, err -} - -func newLexer(f io.Reader) (*lexer, <-chan *UnitOption, <-chan error) { - optchan := make(chan *UnitOption) - errchan := make(chan error, 1) - buf := bufio.NewReader(f) - - return &lexer{buf, optchan, errchan, ""}, optchan, errchan -} - -type lexer struct { - buf *bufio.Reader - optchan chan *UnitOption - errchan chan error - section string -} - -func (l *lexer) lex() { - var err error - defer func() { - close(l.optchan) - close(l.errchan) - }() - next := l.lexNextSection - for next != nil { - if l.buf.Buffered() >= SYSTEMD_LINE_MAX { - // systemd truncates lines longer than LINE_MAX - // https://bugs.freedesktop.org/show_bug.cgi?id=85308 - // Rather than allowing this to pass silently, let's - // explicitly gate people from encountering this - line, err := l.buf.Peek(SYSTEMD_LINE_MAX) - if err != nil { - l.errchan <- err - return - } - if bytes.IndexAny(line, SYSTEMD_NEWLINE) == -1 { - l.errchan <- ErrLineTooLong - return - } - } - - next, err = next() - if err != nil { - l.errchan <- err - return - } - } -} - -type lexStep func() (lexStep, error) - -func (l *lexer) lexSectionName() (lexStep, error) { - sec, err := l.buf.ReadBytes(']') - if err != nil { - return nil, errors.New("unable to find end of section") - } - - return l.lexSectionSuffixFunc(string(sec[:len(sec)-1])), nil -} - -func (l *lexer) lexSectionSuffixFunc(section string) lexStep { - return func() (lexStep, error) { - garbage, _, err := l.toEOL() - if err != nil { - return nil, err - } - - garbage = bytes.TrimSpace(garbage) - if len(garbage) > 0 { - return nil, fmt.Errorf("found garbage after section name %s: %v", l.section, garbage) - } - - return l.lexNextSectionOrOptionFunc(section), nil - } -} - -func (l *lexer) ignoreLineFunc(next lexStep) lexStep { - return func() (lexStep, error) { - for { - line, _, err := l.toEOL() - if err != nil { - return nil, err - } - - line = bytes.TrimSuffix(line, []byte{' '}) - - // lack of continuation means this line has been exhausted - if !bytes.HasSuffix(line, []byte{'\\'}) { - break - } - } - - // reached end of buffer, safe to exit - return next, nil - } -} - -func (l *lexer) lexNextSection() (lexStep, error) { - r, _, err := l.buf.ReadRune() - if err != nil { - if err == io.EOF { - err = nil - } - return nil, err - } - - if r == '[' { - return l.lexSectionName, nil - } else if isComment(r) { - return l.ignoreLineFunc(l.lexNextSection), nil - } - - return l.lexNextSection, nil -} - -func (l *lexer) lexNextSectionOrOptionFunc(section string) lexStep { - return func() (lexStep, error) { - r, _, err := l.buf.ReadRune() - if err != nil { - if err == io.EOF { - err = nil - } - return nil, err - } - - if unicode.IsSpace(r) { - return l.lexNextSectionOrOptionFunc(section), nil - } else if r == '[' { - return l.lexSectionName, nil - } else if isComment(r) { - return l.ignoreLineFunc(l.lexNextSectionOrOptionFunc(section)), nil - } - - l.buf.UnreadRune() - return l.lexOptionNameFunc(section), nil - } -} - -func (l *lexer) lexOptionNameFunc(section string) lexStep { - return func() (lexStep, error) { - var partial bytes.Buffer - for { - r, _, err := l.buf.ReadRune() - if err != nil { - return nil, err - } - - if r == '\n' || r == '\r' { - return nil, errors.New("unexpected newline encountered while parsing option name") - } - - if r == '=' { - break - } - - partial.WriteRune(r) - } - - name := strings.TrimSpace(partial.String()) - return l.lexOptionValueFunc(section, name, bytes.Buffer{}), nil - } -} - -func (l *lexer) lexOptionValueFunc(section, name string, partial bytes.Buffer) lexStep { - return func() (lexStep, error) { - for { - line, eof, err := l.toEOL() - if err != nil { - return nil, err - } - - if len(bytes.TrimSpace(line)) == 0 { - break - } - - partial.Write(line) - - // lack of continuation means this value has been exhausted - idx := bytes.LastIndex(line, []byte{'\\'}) - if idx == -1 || idx != (len(line)-1) { - break - } - - if !eof { - partial.WriteRune('\n') - } - - return l.lexOptionValueFunc(section, name, partial), nil - } - - val := partial.String() - if strings.HasSuffix(val, "\n") { - // A newline was added to the end, so the file didn't end with a backslash. - // => Keep the newline - val = strings.TrimSpace(val) + "\n" - } else { - val = strings.TrimSpace(val) - } - l.optchan <- &UnitOption{Section: section, Name: name, Value: val} - - return l.lexNextSectionOrOptionFunc(section), nil - } -} - -// toEOL reads until the end-of-line or end-of-file. -// Returns (data, EOFfound, error) -func (l *lexer) toEOL() ([]byte, bool, error) { - line, err := l.buf.ReadBytes('\n') - // ignore EOF here since it's roughly equivalent to EOL - if err != nil && err != io.EOF { - return nil, false, err - } - - line = bytes.TrimSuffix(line, []byte{'\r'}) - line = bytes.TrimSuffix(line, []byte{'\n'}) - - return line, err == io.EOF, nil -} - -func isComment(r rune) bool { - return r == '#' || r == ';' -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/unit/escape.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/unit/escape.go deleted file mode 100644 index 63b11726db..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-systemd/unit/escape.go +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Implements systemd-escape [--unescape] [--path] - -package unit - -import ( - "fmt" - "strconv" - "strings" -) - -const ( - allowed = `:_.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789` -) - -// If isPath is true: -// We remove redundant '/'s, the leading '/', and trailing '/'. -// If the result is empty, a '/' is inserted. -// -// We always: -// Replace the following characters with `\x%x`: -// Leading `.` -// `-`, `\`, and anything not in this set: `:-_.\[0-9a-zA-Z]` -// Replace '/' with '-'. -func escape(unescaped string, isPath bool) string { - e := []byte{} - inSlashes := false - start := true - for i := 0; i < len(unescaped); i++ { - c := unescaped[i] - if isPath { - if c == '/' { - inSlashes = true - continue - } else if inSlashes { - inSlashes = false - if !start { - e = append(e, '-') - } - } - } - - if c == '/' { - e = append(e, '-') - } else if start && c == '.' || strings.IndexByte(allowed, c) == -1 { - e = append(e, []byte(fmt.Sprintf(`\x%x`, c))...) - } else { - e = append(e, c) - } - start = false - } - if isPath && len(e) == 0 { - e = append(e, '-') - } - return string(e) -} - -// If isPath is true: -// We always return a string beginning with '/'. -// -// We always: -// Replace '-' with '/'. -// Replace `\x%x` with the value represented in hex. -func unescape(escaped string, isPath bool) string { - u := []byte{} - for i := 0; i < len(escaped); i++ { - c := escaped[i] - if c == '-' { - c = '/' - } else if c == '\\' && len(escaped)-i >= 4 && escaped[i+1] == 'x' { - n, err := strconv.ParseInt(escaped[i+2:i+4], 16, 8) - if err == nil { - c = byte(n) - i += 3 - } - } - u = append(u, c) - } - if isPath && (len(u) == 0 || u[0] != '/') { - u = append([]byte("/"), u...) - } - return string(u) -} - -// UnitNameEscape escapes a string as `systemd-escape` would -func UnitNameEscape(unescaped string) string { - return escape(unescaped, false) -} - -// UnitNameUnescape unescapes a string as `systemd-escape --unescape` would -func UnitNameUnescape(escaped string) string { - return unescape(escaped, false) -} - -// UnitNamePathEscape escapes a string as `systemd-escape --path` would -func UnitNamePathEscape(unescaped string) string { - return escape(unescaped, true) -} - -// UnitNamePathUnescape unescapes a string as `systemd-escape --path --unescape` would -func UnitNamePathUnescape(escaped string) string { - return unescape(escaped, true) -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/unit/option.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/unit/option.go deleted file mode 100644 index e5d21e19d9..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-systemd/unit/option.go +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package unit - -import ( - "fmt" -) - -type UnitOption struct { - Section string - Name string - Value string -} - -func NewUnitOption(section, name, value string) *UnitOption { - return &UnitOption{Section: section, Name: name, Value: value} -} - -func (uo *UnitOption) String() string { - return fmt.Sprintf("{Section: %q, Name: %q, Value: %q}", uo.Section, uo.Name, uo.Value) -} - -func (uo *UnitOption) Match(other *UnitOption) bool { - return uo.Section == other.Section && - uo.Name == other.Name && - uo.Value == other.Value -} - -func AllMatch(u1 []*UnitOption, u2 []*UnitOption) bool { - length := len(u1) - if length != len(u2) { - return false - } - - for i := 0; i < length; i++ { - if !u1[i].Match(u2[i]) { - return false - } - } - - return true -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/unit/serialize.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/unit/serialize.go deleted file mode 100644 index e07799cad6..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-systemd/unit/serialize.go +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package unit - -import ( - "bytes" - "io" -) - -// Serialize encodes all of the given UnitOption objects into a -// unit file. When serialized the options are sorted in their -// supplied order but grouped by section. -func Serialize(opts []*UnitOption) io.Reader { - var buf bytes.Buffer - - if len(opts) == 0 { - return &buf - } - - // Index of sections -> ordered options - idx := map[string][]*UnitOption{} - // Separately preserve order in which sections were seen - sections := []string{} - for _, opt := range opts { - sec := opt.Section - if _, ok := idx[sec]; !ok { - sections = append(sections, sec) - } - idx[sec] = append(idx[sec], opt) - } - - for i, sect := range sections { - writeSectionHeader(&buf, sect) - writeNewline(&buf) - - opts := idx[sect] - for _, opt := range opts { - writeOption(&buf, opt) - writeNewline(&buf) - } - if i < len(sections)-1 { - writeNewline(&buf) - } - } - - return &buf -} - -func writeNewline(buf *bytes.Buffer) { - buf.WriteRune('\n') -} - -func writeSectionHeader(buf *bytes.Buffer, section string) { - buf.WriteRune('[') - buf.WriteString(section) - buf.WriteRune(']') -} - -func writeOption(buf *bytes.Buffer, opt *UnitOption) { - buf.WriteString(opt.Name) - buf.WriteRune('=') - buf.WriteString(opt.Value) -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-systemd/util/util.go b/Godeps/_workspace/src/github.com/coreos/go-systemd/util/util.go deleted file mode 100644 index e4ed8b2639..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-systemd/util/util.go +++ /dev/null @@ -1,227 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package util contains utility functions related to systemd that applications -// can use to check things like whether systemd is running. Note that some of -// these functions attempt to manually load systemd libraries at runtime rather -// than linking against them. -package util - -// #include -// #include -// #include -// -// int -// my_sd_pid_get_owner_uid(void *f, pid_t pid, uid_t *uid) -// { -// int (*sd_pid_get_owner_uid)(pid_t, uid_t *); -// -// sd_pid_get_owner_uid = (int (*)(pid_t, uid_t *))f; -// return sd_pid_get_owner_uid(pid, uid); -// } -// -// int -// my_sd_pid_get_unit(void *f, pid_t pid, char **unit) -// { -// int (*sd_pid_get_unit)(pid_t, char **); -// -// sd_pid_get_unit = (int (*)(pid_t, char **))f; -// return sd_pid_get_unit(pid, unit); -// } -// -// int -// my_sd_pid_get_slice(void *f, pid_t pid, char **slice) -// { -// int (*sd_pid_get_slice)(pid_t, char **); -// -// sd_pid_get_slice = (int (*)(pid_t, char **))f; -// return sd_pid_get_slice(pid, slice); -// } -// -// int -// am_session_leader() -// { -// return (getsid(0) == getpid()); -// } -import "C" -import ( - "fmt" - "io/ioutil" - "os" - "strings" - "syscall" - "unsafe" - - "github.com/coreos/pkg/dlopen" -) - -var libsystemdNames = []string{ - // systemd < 209 - "libsystemd-login.so.0", - "libsystemd-login.so", - - // systemd >= 209 merged libsystemd-login into libsystemd proper - "libsystemd.so.0", - "libsystemd.so", -} - -// GetRunningSlice attempts to retrieve the name of the systemd slice in which -// the current process is running. -// This function is a wrapper around the libsystemd C library; if it cannot be -// opened, an error is returned. -func GetRunningSlice() (slice string, err error) { - var h *dlopen.LibHandle - h, err = dlopen.GetHandle(libsystemdNames) - if err != nil { - return - } - defer func() { - if err1 := h.Close(); err1 != nil { - err = err1 - } - }() - - sd_pid_get_slice, err := h.GetSymbolPointer("sd_pid_get_slice") - if err != nil { - return - } - - var s string - sl := C.CString(s) - defer C.free(unsafe.Pointer(sl)) - - ret := C.my_sd_pid_get_slice(sd_pid_get_slice, 0, &sl) - if ret < 0 { - err = fmt.Errorf("error calling sd_pid_get_slice: %v", syscall.Errno(-ret)) - return - } - - return C.GoString(sl), nil -} - -// RunningFromSystemService tries to detect whether the current process has -// been invoked from a system service. The condition for this is whether the -// process is _not_ a user process. User processes are those running in session -// scopes or under per-user `systemd --user` instances. -// -// To avoid false positives on systems without `pam_systemd` (which is -// responsible for creating user sessions), this function also uses a heuristic -// to detect whether it's being invoked from a session leader process. This is -// the case if the current process is executed directly from a service file -// (e.g. with `ExecStart=/this/cmd`). Note that this heuristic will fail if the -// command is instead launched in a subshell or similar so that it is not -// session leader (e.g. `ExecStart=/bin/bash -c "/this/cmd"`) -// -// This function is a wrapper around the libsystemd C library; if this is -// unable to successfully open a handle to the library for any reason (e.g. it -// cannot be found), an errr will be returned -func RunningFromSystemService() (ret bool, err error) { - var h *dlopen.LibHandle - h, err = dlopen.GetHandle(libsystemdNames) - if err != nil { - return - } - defer func() { - if err1 := h.Close(); err1 != nil { - err = err1 - } - }() - - sd_pid_get_owner_uid, err := h.GetSymbolPointer("sd_pid_get_owner_uid") - if err != nil { - return - } - - var uid C.uid_t - errno := C.my_sd_pid_get_owner_uid(sd_pid_get_owner_uid, 0, &uid) - serrno := syscall.Errno(-errno) - // when we're running from a unit file, sd_pid_get_owner_uid returns - // ENOENT (systemd <220) or ENXIO (systemd >=220) - switch { - case errno >= 0: - ret = false - case serrno == syscall.ENOENT, serrno == syscall.ENXIO: - // Since the implementation of sessions in systemd relies on - // the `pam_systemd` module, using the sd_pid_get_owner_uid - // heuristic alone can result in false positives if that module - // (or PAM itself) is not present or properly configured on the - // system. As such, we also check if we're the session leader, - // which should be the case if we're invoked from a unit file, - // but not if e.g. we're invoked from the command line from a - // user's login session - ret = C.am_session_leader() == 1 - default: - err = fmt.Errorf("error calling sd_pid_get_owner_uid: %v", syscall.Errno(-errno)) - } - return -} - -// CurrentUnitName attempts to retrieve the name of the systemd system unit -// from which the calling process has been invoked. It wraps the systemd -// `sd_pid_get_unit` call, with the same caveat: for processes not part of a -// systemd system unit, this function will return an error. -func CurrentUnitName() (unit string, err error) { - var h *dlopen.LibHandle - h, err = dlopen.GetHandle(libsystemdNames) - if err != nil { - return - } - defer func() { - if err1 := h.Close(); err1 != nil { - err = err1 - } - }() - - sd_pid_get_unit, err := h.GetSymbolPointer("sd_pid_get_unit") - if err != nil { - return - } - - var s string - u := C.CString(s) - defer C.free(unsafe.Pointer(u)) - - ret := C.my_sd_pid_get_unit(sd_pid_get_unit, 0, &u) - if ret < 0 { - err = fmt.Errorf("error calling sd_pid_get_unit: %v", syscall.Errno(-ret)) - return - } - - unit = C.GoString(u) - return -} - -// IsRunningSystemd checks whether the host was booted with systemd as its init -// system. This functions similarly to systemd's `sd_booted(3)`: internally, it -// checks whether /run/systemd/system/ exists and is a directory. -// http://www.freedesktop.org/software/systemd/man/sd_booted.html -func IsRunningSystemd() bool { - fi, err := os.Lstat("/run/systemd/system") - if err != nil { - return false - } - return fi.IsDir() -} - -// GetMachineID returns a host's 128-bit machine ID as a string. This functions -// similarly to systemd's `sd_id128_get_machine`: internally, it simply reads -// the contents of /etc/machine-id -// http://www.freedesktop.org/software/systemd/man/sd_id128_get_machine.html -func GetMachineID() (string, error) { - machineID, err := ioutil.ReadFile("/etc/machine-id") - if err != nil { - return "", fmt.Errorf("failed to read /etc/machine-id: %v", err) - } - return strings.TrimSpace(string(machineID)), nil -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-tspi/LICENSE b/Godeps/_workspace/src/github.com/coreos/go-tspi/LICENSE deleted file mode 100644 index e06d208186..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-tspi/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor 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, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - diff --git a/Godeps/_workspace/src/github.com/coreos/go-tspi/tpmclient/tpmclient.go b/Godeps/_workspace/src/github.com/coreos/go-tspi/tpmclient/tpmclient.go deleted file mode 100644 index fb5279b2a1..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-tspi/tpmclient/tpmclient.go +++ /dev/null @@ -1,310 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package tpmclient - -import ( - "bytes" - "crypto/rand" - "encoding/json" - "fmt" - "io" - "io/ioutil" - "net/http" - "time" - - "github.com/coreos/go-tspi/tspiconst" - "github.com/coreos/go-tspi/verification" -) - -// TPMClient represents a connection to a system running a daemon providing -// access to TPM functionality -type TPMClient struct { - host string - timeout time.Duration -} - -const ( - GetEKCertURL = "/v1/getEkcert" - ExtendURL = "/v1/extend" - QuoteURL = "/v1/quote" - GenerateAikURL = "/v1/generateAik" - GenerateKeyURL = "/v1/generateKey" - AikChallengeURL = "/v1/aikChallenge" -) - -func (client *TPMClient) get(endpoint string) (*http.Response, error) { - url := fmt.Sprintf("http://%s%s", client.host, endpoint) - httpClient := &http.Client{ - Timeout: client.timeout, - } - resp, err := httpClient.Get(url) - return resp, err -} - -func (client *TPMClient) post(endpoint string, data io.Reader) (*http.Response, error) { - url := fmt.Sprintf("http://%s%s", client.host, endpoint) - httpClient := &http.Client{ - Timeout: client.timeout, - } - resp, err := httpClient.Post(url, "application/json", data) - return resp, err -} - -type EkcertResponse struct { - EKCert []byte -} - -// GetEKCert obtains the Endorsement Key certificate from the client TPM. This -// is an X509 certificate containing the public half of the Endorsement Key -// and a signature chain chaining back to a vendor-issued signing certificate. -func (client *TPMClient) GetEKCert() (ekcert []byte, err error) { - var ekcertData EkcertResponse - - ekresp, err := client.get(GetEKCertURL) - if err != nil { - return nil, fmt.Errorf("Can't obtain ekcert: %s", err) - } - defer ekresp.Body.Close() - body, err := ioutil.ReadAll(ekresp.Body) - if err != nil { - return nil, fmt.Errorf("Can't read ekcert response: %s", err) - } - - err = json.Unmarshal(body, &ekcertData) - if err != nil { - return nil, fmt.Errorf("Can't parse ekcert response: %s", err) - } - - return ekcertData.EKCert, nil -} - -type AikResponse struct { - AIKBlob []byte - AIKPub []byte -} - -// GenerateAIK requests that the TPM generate a new Attestation Identity Key. -// It returns an unencrypted copy of the public half of the AIK, along with -// a TSPI key blob encrypted by the TPM. -func (client *TPMClient) GenerateAIK() (aikpub []byte, aikblob []byte, err error) { - var aikData AikResponse - - aikresp, err := client.post(GenerateAikURL, nil) - if err != nil { - return nil, nil, fmt.Errorf("Can't generate AIK: %s", err) - } - defer aikresp.Body.Close() - body, err := ioutil.ReadAll(aikresp.Body) - if err != nil { - return nil, nil, fmt.Errorf("Can't read AIK response: %s", err) - } - - err = json.Unmarshal(body, &aikData) - if err != nil { - return nil, nil, fmt.Errorf("Can't parse AIK response: %s (%s)", err, body) - } - - aikpub = aikData.AIKPub - aikblob = aikData.AIKBlob - - return aikpub, aikblob, nil -} - -type KeyData struct { - KeyFlags int -} - -type KeyResponse struct { - KeyBlob []byte - KeyPub []byte -} - -// GenerateKey requests that the TPM generate a new keypair -func (client *TPMClient) GenerateKey(flags int) (keypub []byte, keyblob []byte, err error) { - var keyData KeyData - var keyResponse KeyResponse - - keyData.KeyFlags = flags - request, err := json.Marshal(keyData) - if err != nil { - return nil, nil, fmt.Errorf("Can't construct request JSON: %s", err) - } - - keyresp, err := client.post(GenerateKeyURL, bytes.NewBuffer(request)) - if err != nil { - return nil, nil, fmt.Errorf("Can't generate key: %s", err) - } - defer keyresp.Body.Close() - body, err := ioutil.ReadAll(keyresp.Body) - if err != nil { - return nil, nil, fmt.Errorf("Can't read key response: %s", err) - } - - err = json.Unmarshal(body, &keyResponse) - if err != nil { - return nil, nil, fmt.Errorf("Can't parse key response: %s (%s)", err, body) - } - - keypub = keyResponse.KeyPub - keyblob = keyResponse.KeyBlob - - return keypub, keyblob, nil -} - -type ChallengeData struct { - AIK []byte - Asymenc []byte - Symenc []byte -} - -type ChallengeResponse struct { - Response []byte -} - -// ValidateAIK challenges the TPM to validate an AIK by using the provided -// key blob to decrypt a secret encrypted with the public half of the -// AIK. This will only be possible if the TPM is able to decrypt the -// encrypted key blob. The AIK is used to decrypt asymenc, which then -// provides the AES key used to encrypt symenc. Decrypting symenc provides -// the original secret, which is then returned. -func (client *TPMClient) ValidateAIK(aikblob []byte, asymenc []byte, symenc []byte) (secret []byte, err error) { - var challenge ChallengeData - var response ChallengeResponse - - challenge.AIK = aikblob - challenge.Asymenc = asymenc - challenge.Symenc = symenc - - request, err := json.Marshal(challenge) - if err != nil { - return nil, fmt.Errorf("Can't construct challenge JSON: %s", err) - } - chalresp, err := client.post(AikChallengeURL, bytes.NewBuffer(request)) - if err != nil { - return nil, fmt.Errorf("Can't perform AIK challenge: %s", err) - } - defer chalresp.Body.Close() - body, err := ioutil.ReadAll(chalresp.Body) - if err != nil { - return nil, fmt.Errorf("Can't read AIK challenge response: %s", err) - } - - err = json.Unmarshal(body, &response) - if err != nil { - return nil, fmt.Errorf("Can't parse AIK challenge response: %s", err) - } - return response.Response, nil -} - -type ExtendInput struct { - Pcr int - Eventtype int - Data []byte - Event string -} - -// Extend extends a TPM PCR with the provided data. If event is nil, data must -// be pre-hashed with SHA1 and will be used to extend the PCR directly. If -// event is not nil, data and event will be hashed to generate the extension -// value. Event will then be stored in the TPM event log. -func (client *TPMClient) Extend(pcr int, eventtype int, data []byte, event string) error { - var extendData ExtendInput - - extendData.Pcr = pcr - extendData.Eventtype = eventtype - extendData.Data = data - extendData.Event = event - - request, err := json.Marshal(extendData) - if err != nil { - return fmt.Errorf("Can't construct extension JSON: %s", err) - } - chalresp, err := client.post(ExtendURL, bytes.NewBuffer(request)) - if err != nil { - return fmt.Errorf("Can't perform PCR extension: %s", err) - } - defer chalresp.Body.Close() - - return nil -} - -type QuoteData struct { - AIK []byte - PCRs []int - Nonce []byte -} - -type QuoteResponse struct { - Data []byte - Validation []byte - PCRValues [][]byte - Events []tspiconst.Log -} - -// GetQuote obtains a PCR quote from the TPM. It takes the aikpub Tspi Key, the -// encrypted AIK blob and a list of PCRs as arguments. The response will -// contain an array of PCR values, an array of log entries and any error. -func (client *TPMClient) GetQuote(aikpub []byte, aikblob []byte, pcrs []int) (pcrvals [][]byte, log []tspiconst.Log, err error) { - var quoteRequest QuoteData - var response QuoteResponse - - nonce := make([]byte, 20) - _, err = rand.Read(nonce) - if err != nil { - return nil, nil, fmt.Errorf("Unable to generate nonce: %s", err) - } - - quoteRequest.AIK = aikblob - quoteRequest.PCRs = pcrs - quoteRequest.Nonce = nonce - - request, err := json.Marshal(quoteRequest) - if err != nil { - return nil, nil, fmt.Errorf("Can't construct quote request JSON: %s", err) - } - chalresp, err := client.post(QuoteURL, bytes.NewBuffer(request)) - if err != nil { - return nil, nil, fmt.Errorf("Can't perform obtain quote: %s", err) - } - defer chalresp.Body.Close() - body, err := ioutil.ReadAll(chalresp.Body) - if err != nil { - return nil, nil, fmt.Errorf("Can't read quote response: %s", err) - } - - err = json.Unmarshal(body, &response) - if err != nil { - return nil, nil, fmt.Errorf("Can't parse quote response: %s", err) - } - - aikmod := aikpub[28:] - - err = verification.QuoteVerify(response.Data, response.Validation, aikmod, response.PCRValues, nonce) - - if err != nil { - return nil, nil, fmt.Errorf("Can't verify quote: %s", err) - } - - return response.PCRValues, response.Events, nil -} - -// New returns a TPMClient structure configured to connect to the provided -// host with the provided timeout. -func New(host string, timeout time.Duration) *TPMClient { - return &TPMClient{ - host: host, - timeout: timeout, - } -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-tspi/tspiconst/tspiconst.go b/Godeps/_workspace/src/github.com/coreos/go-tspi/tspiconst/tspiconst.go deleted file mode 100644 index f2446db76b..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-tspi/tspiconst/tspiconst.go +++ /dev/null @@ -1,538 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package tspiconst - -const ( - TSS_OBJECT_TYPE_POLICY = 0x01 - TSS_OBJECT_TYPE_RSAKEY = 0x02 - TSS_OBJECT_TYPE_ENCDATA = 0x03 - TSS_OBJECT_TYPE_PCRS = 0x04 - TSS_OBJECT_TYPE_HASH = 0x05 - TSS_OBJECT_TYPE_DELFAMILY = 0x06 - TSS_OBJECT_TYPE_NV = 0x07 - TSS_OBJECT_TYPE_MIGDATA = 0x08 - TSS_OBJECT_TYPE_DAA_CERTIFICATE = 0x09 - TSS_OBJECT_TYPE_DAA_ISSUER_KEY = 0x0a - TSS_OBJECT_TYPE_DAA_ARA_KEY = 0x0b - TSS_KEY_NO_AUTHORIZATION = 0x00000000 - TSS_KEY_AUTHORIZATION = 0x00000001 - TSS_KEY_AUTHORIZATION_PRIV_USE_ONLY = 0x00000002 - TSS_KEY_NON_VOLATILE = 0x00000000 - TSS_KEY_VOLATILE = 0x00000004 - TSS_KEY_NOT_MIGRATABLE = 0x00000000 - TSS_KEY_MIGRATABLE = 0x00000008 - TSS_KEY_TYPE_DEFAULT = 0x00000000 - TSS_KEY_TYPE_SIGNING = 0x00000010 - TSS_KEY_TYPE_STORAGE = 0x00000020 - TSS_KEY_TYPE_IDENTITY = 0x00000030 - TSS_KEY_TYPE_AUTHCHANGE = 0x00000040 - TSS_KEY_TYPE_BIND = 0x00000050 - TSS_KEY_TYPE_LEGACY = 0x00000060 - TSS_KEY_TYPE_MIGRATE = 0x00000070 - TSS_KEY_TYPE_BITMASK = 0x000000F0 - TSS_KEY_SIZE_DEFAULT = 0x00000000 - TSS_KEY_SIZE_512 = 0x00000100 - TSS_KEY_SIZE_1024 = 0x00000200 - TSS_KEY_SIZE_2048 = 0x00000300 - TSS_KEY_SIZE_4096 = 0x00000400 - TSS_KEY_SIZE_8192 = 0x00000500 - TSS_KEY_SIZE_16384 = 0x00000600 - TSS_KEY_SIZE_BITMASK = 0x00000F00 - TSS_KEY_NOT_CERTIFIED_MIGRATABLE = 0x00000000 - TSS_KEY_CERTIFIED_MIGRATABLE = 0x00001000 - TSS_KEY_STRUCT_DEFAULT = 0x00000000 - TSS_KEY_STRUCT_KEY = 0x00004000 - TSS_KEY_STRUCT_KEY12 = 0x00008000 - TSS_KEY_STRUCT_BITMASK = 0x0001C000 - TSS_KEY_EMPTY_KEY = 0x00000000 - TSS_KEY_TSP_SRK = 0x04000000 - TSS_KEY_TEMPLATE_BITMASK = 0xFC000000 - TSS_ENCDATA_SEAL = 0x00000001 - TSS_ENCDATA_BIND = 0x00000002 - TSS_ENCDATA_LEGACY = 0x00000003 - TSS_HASH_DEFAULT = 0x00000000 - TSS_HASH_SHA1 = 0x00000001 - TSS_HASH_OTHER = 0xFFFFFFFF - TSS_POLICY_USAGE = 0x00000001 - TSS_POLICY_MIGRATION = 0x00000002 - TSS_POLICY_OPERATOR = 0x00000003 - TSS_PCRS_STRUCT_DEFAULT = 0x00000000 - TSS_PCRS_STRUCT_INFO = 0x00000001 - TSS_PCRS_STRUCT_INFO_LONG = 0x00000002 - TSS_PCRS_STRUCT_INFO_SHORT = 0x00000003 - TSS_TSPATTRIB_CONTEXT_SILENT_MODE = 0x00000001 - TSS_TSPATTRIB_CONTEXT_MACHINE_NAME = 0x00000002 - TSS_TSPATTRIB_CONTEXT_VERSION_MODE = 0x00000003 - TSS_TSPATTRIB_CONTEXT_TRANSPORT = 0x00000004 - TSS_TSPATTRIB_CONTEXT_CONNECTION_VERSION = 0x00000005 - TSS_TSPATTRIB_SECRET_HASH_MODE = 0x00000006 - TSS_TSPATTRIB_CONTEXTTRANS_CONTROL = 0x00000008 - TSS_TSPATTRIB_CONTEXTTRANS_MODE = 0x00000010 - TSS_TSPATTRIB_CONTEXT_NOT_SILENT = 0x00000000 - TSS_TSPATTRIB_CONTEXT_SILENT = 0x00000001 - TSS_TSPATTRIB_CONTEXT_VERSION_AUTO = 0x00000001 - TSS_TSPATTRIB_CONTEXT_VERSION_V1_1 = 0x00000002 - TSS_TSPATTRIB_CONTEXT_VERSION_V1_2 = 0x00000003 - TSS_TSPATTRIB_DISABLE_TRANSPORT = 0x00000016 - TSS_TSPATTRIB_ENABLE_TRANSPORT = 0x00000032 - TSS_TSPATTRIB_TRANSPORT_NO_DEFAULT_ENCRYPTION = 0x00000000 - TSS_TSPATTRIB_TRANSPORT_DEFAULT_ENCRYPTION = 0x00000001 - TSS_TSPATTRIB_TRANSPORT_AUTHENTIC_CHANNEL = 0x00000002 - TSS_TSPATTRIB_TRANSPORT_EXCLUSIVE = 0x00000004 - TSS_TSPATTRIB_TRANSPORT_STATIC_AUTH = 0x00000008 - TSS_CONNECTION_VERSION_1_1 = 0x00000001 - TSS_CONNECTION_VERSION_1_2 = 0x00000002 - TSS_TSPATTRIB_SECRET_HASH_MODE_POPUP = 0x00000001 - TSS_TSPATTRIB_HASH_MODE_NOT_NULL = 0x00000000 - TSS_TSPATTRIB_HASH_MODE_NULL = 0x00000001 - TSS_TSPATTRIB_TPM_CALLBACK_COLLATEIDENTITY = 0x00000001 - TSS_TSPATTRIB_TPM_CALLBACK_ACTIVATEIDENTITY = 0x00000002 - TSS_TSPATTRIB_TPM_ORDINAL_AUDIT_STATUS = 0x00000003 - TSS_TSPATTRIB_TPM_CREDENTIAL = 0x00001000 - TPM_CAP_PROP_TPM_CLEAR_ORDINAL_AUDIT = 0x00000000 - TPM_CAP_PROP_TPM_SET_ORDINAL_AUDIT = 0x00000001 - TSS_TPMATTRIB_EKCERT = 0x00000001 - TSS_TPMATTRIB_TPM_CC = 0x00000002 - TSS_TPMATTRIB_PLATFORMCERT = 0x00000003 - TSS_TPMATTRIB_PLATFORM_CC = 0x00000004 - TSS_TSPATTRIB_POLICY_CALLBACK_HMAC = 0x00000080 - TSS_TSPATTRIB_POLICY_CALLBACK_XOR_ENC = 0x00000100 - TSS_TSPATTRIB_POLICY_CALLBACK_TAKEOWNERSHIP = 0x00000180 - TSS_TSPATTRIB_POLICY_CALLBACK_CHANGEAUTHASYM = 0x00000200 - TSS_TSPATTRIB_POLICY_SECRET_LIFETIME = 0x00000280 - TSS_TSPATTRIB_POLICY_POPUPSTRING = 0x00000300 - TSS_TSPATTRIB_POLICY_CALLBACK_SEALX_MASK = 0x00000380 - TSS_TSPATTRIB_POLICY_DELEGATION_INFO = 0x00000001 - TSS_TSPATTRIB_POLICY_DELEGATION_PCR = 0x00000002 - TSS_SECRET_LIFETIME_ALWAYS = 0x00000001 - TSS_SECRET_LIFETIME_COUNTER = 0x00000002 - TSS_SECRET_LIFETIME_TIMER = 0x00000003 - TSS_TSPATTRIB_POLSECRET_LIFETIME_ALWAYS = TSS_SECRET_LIFETIME_ALWAYS - TSS_TSPATTRIB_POLSECRET_LIFETIME_COUNTER = TSS_SECRET_LIFETIME_COUNTER - TSS_TSPATTRIB_POLSECRET_LIFETIME_TIMER = TSS_SECRET_LIFETIME_TIMER - TSS_TSPATTRIB_POLICYSECRET_LIFETIME_ALWAYS = TSS_SECRET_LIFETIME_ALWAYS - TSS_TSPATTRIB_POLICYSECRET_LIFETIME_COUNTER = TSS_SECRET_LIFETIME_COUNTER - TSS_TSPATTRIB_POLICYSECRET_LIFETIME_TIMER = TSS_SECRET_LIFETIME_TIMER - TSS_TSPATTRIB_POLDEL_TYPE = 0x00000001 - TSS_TSPATTRIB_POLDEL_INDEX = 0x00000002 - TSS_TSPATTRIB_POLDEL_PER1 = 0x00000003 - TSS_TSPATTRIB_POLDEL_PER2 = 0x00000004 - TSS_TSPATTRIB_POLDEL_LABEL = 0x00000005 - TSS_TSPATTRIB_POLDEL_FAMILYID = 0x00000006 - TSS_TSPATTRIB_POLDEL_VERCOUNT = 0x00000007 - TSS_TSPATTRIB_POLDEL_OWNERBLOB = 0x00000008 - TSS_TSPATTRIB_POLDEL_KEYBLOB = 0x00000009 - TSS_TSPATTRIB_POLDELPCR_LOCALITY = 0x00000001 - TSS_TSPATTRIB_POLDELPCR_DIGESTATRELEASE = 0x00000002 - TSS_TSPATTRIB_POLDELPCR_SELECTION = 0x00000003 - TSS_DELEGATIONTYPE_NONE = 0x00000001 - TSS_DELEGATIONTYPE_OWNER = 0x00000002 - TSS_DELEGATIONTYPE_KEY = 0x00000003 - TSS_SECRET_MODE_NONE = 0x00000800 - TSS_SECRET_MODE_SHA1 = 0x00001000 - TSS_SECRET_MODE_PLAIN = 0x00001800 - TSS_SECRET_MODE_POPUP = 0x00002000 - TSS_SECRET_MODE_CALLBACK = 0x00002800 - TSS_TSPATTRIB_ENCDATA_BLOB = 0x00000008 - TSS_TSPATTRIB_ENCDATA_PCR = 0x00000010 - TSS_TSPATTRIB_ENCDATA_PCR_LONG = 0x00000018 - TSS_TSPATTRIB_ENCDATA_SEAL = 0x00000020 - TSS_TSPATTRIB_ENCDATABLOB_BLOB = 0x00000001 - TSS_TSPATTRIB_ENCDATAPCR_DIGEST_ATCREATION = 0x00000002 - TSS_TSPATTRIB_ENCDATAPCR_DIGEST_ATRELEASE = 0x00000003 - TSS_TSPATTRIB_ENCDATAPCR_SELECTION = 0x00000004 - TSS_TSPATTRIB_ENCDATAPCR_DIGEST_RELEASE = TSS_TSPATTRIB_ENCDATAPCR_DIGEST_ATRELEASE - TSS_TSPATTRIB_ENCDATAPCRLONG_LOCALITY_ATCREATION = 0x00000005 - TSS_TSPATTRIB_ENCDATAPCRLONG_LOCALITY_ATRELEASE = 0x00000006 - TSS_TSPATTRIB_ENCDATAPCRLONG_CREATION_SELECTION = 0x00000007 - TSS_TSPATTRIB_ENCDATAPCRLONG_RELEASE_SELECTION = 0x00000008 - TSS_TSPATTRIB_ENCDATAPCRLONG_DIGEST_ATCREATION = 0x00000009 - TSS_TSPATTRIB_ENCDATAPCRLONG_DIGEST_ATRELEASE = 0x0000000A - TSS_TSPATTRIB_ENCDATASEAL_PROTECT_MODE = 0x00000001 - TSS_TSPATTRIB_ENCDATASEAL_NOPROTECT = 0x00000000 - TSS_TSPATTRIB_ENCDATASEAL_PROTECT = 0x00000001 - TSS_TSPATTRIB_ENCDATASEAL_NO_PROTECT = TSS_TSPATTRIB_ENCDATASEAL_NOPROTECT - TSS_TSPATTRIB_NV_INDEX = 0x00000001 - TSS_TSPATTRIB_NV_PERMISSIONS = 0x00000002 - TSS_TSPATTRIB_NV_STATE = 0x00000003 - TSS_TSPATTRIB_NV_DATASIZE = 0x00000004 - TSS_TSPATTRIB_NV_PCR = 0x00000005 - TSS_TSPATTRIB_NVSTATE_READSTCLEAR = 0x00100000 - TSS_TSPATTRIB_NVSTATE_WRITESTCLEAR = 0x00200000 - TSS_TSPATTRIB_NVSTATE_WRITEDEFINE = 0x00300000 - TSS_TSPATTRIB_NVPCR_READPCRSELECTION = 0x01000000 - TSS_TSPATTRIB_NVPCR_READDIGESTATRELEASE = 0x02000000 - TSS_TSPATTRIB_NVPCR_READLOCALITYATRELEASE = 0x03000000 - TSS_TSPATTRIB_NVPCR_WRITEPCRSELECTION = 0x04000000 - TSS_TSPATTRIB_NVPCR_WRITEDIGESTATRELEASE = 0x05000000 - TSS_TSPATTRIB_NVPCR_WRITELOCALITYATRELEASE = 0x06000000 - TSS_NV_TPM = 0x80000000 - TSS_NV_PLATFORM = 0x40000000 - TSS_NV_USER = 0x20000000 - TSS_NV_DEFINED = 0x10000000 - TSS_NV_MASK_TPM = 0x80000000 - TSS_NV_MASK_PLATFORM = 0x40000000 - TSS_NV_MASK_USER = 0x20000000 - TSS_NV_MASK_DEFINED = 0x10000000 - TSS_NV_MASK_RESERVED = 0x0f000000 - TSS_NV_MASK_PURVIEW = 0x00ff0000 - TSS_NV_MASK_INDEX = 0x0000ffff - TSS_NV_INDEX_SESSIONS = 0x00011101 - TSS_MIGATTRIB_MIGRATIONBLOB = 0x00000010 - TSS_MIGATTRIB_MIGRATIONTICKET = 0x00000020 - TSS_MIGATTRIB_AUTHORITY_DATA = 0x00000030 - TSS_MIGATTRIB_MIG_AUTH_DATA = 0x00000040 - TSS_MIGATTRIB_TICKET_DATA = 0x00000050 - TSS_MIGATTRIB_PAYLOAD_TYPE = 0x00000060 - TSS_MIGATTRIB_MIGRATION_XOR_BLOB = 0x00000101 - TSS_MIGATTRIB_MIGRATION_REWRAPPED_BLOB = 0x00000102 - TSS_MIGATTRIB_MIG_MSALIST_PUBKEY_BLOB = 0x00000103 - TSS_MIGATTRIB_MIG_AUTHORITY_PUBKEY_BLOB = 0x00000104 - TSS_MIGATTRIB_MIG_DESTINATION_PUBKEY_BLOB = 0x00000105 - TSS_MIGATTRIB_MIG_SOURCE_PUBKEY_BLOB = 0x00000106 - TSS_MIGATTRIB_MIG_REWRAPPED_BLOB = TSS_MIGATTRIB_MIGRATION_REWRAPPED_BLOB - TSS_MIGATTRIB_MIG_XOR_BLOB = TSS_MIGATTRIB_MIGRATION_XOR_BLOB - TSS_MIGATTRIB_AUTHORITY_DIGEST = 0x00000301 - TSS_MIGATTRIB_AUTHORITY_APPROVAL_HMAC = 0x00000302 - TSS_MIGATTRIB_AUTHORITY_MSALIST = 0x00000303 - TSS_MIGATTRIB_MIG_AUTH_AUTHORITY_DIGEST = 0x00000401 - TSS_MIGATTRIB_MIG_AUTH_DESTINATION_DIGEST = 0x00000402 - TSS_MIGATTRIB_MIG_AUTH_SOURCE_DIGEST = 0x00000403 - TSS_MIGATTRIB_TICKET_SIG_DIGEST = 0x00000501 - TSS_MIGATTRIB_TICKET_SIG_VALUE = 0x00000502 - TSS_MIGATTRIB_TICKET_SIG_TICKET = 0x00000503 - TSS_MIGATTRIB_TICKET_RESTRICT_TICKET = 0x00000504 - TSS_MIGATTRIB_PT_MIGRATE_RESTRICTED = 0x00000601 - TSS_MIGATTRIB_PT_MIGRATE_EXTERNAL = 0x00000602 - TSS_TSPATTRIB_HASH_IDENTIFIER = 0x00001000 - TSS_TSPATTRIB_ALG_IDENTIFIER = 0x00002000 - TSS_TSPATTRIB_PCRS_INFO = 0x00000001 - TSS_TSPATTRIB_PCRSINFO_PCRSTRUCT = 0x00000001 - TSS_TSPATTRIB_DELFAMILY_STATE = 0x00000001 - TSS_TSPATTRIB_DELFAMILY_INFO = 0x00000002 - TSS_TSPATTRIB_DELFAMILYSTATE_LOCKED = 0x00000001 - TSS_TSPATTRIB_DELFAMILYSTATE_ENABLED = 0x00000002 - TSS_TSPATTRIB_DELFAMILYINFO_LABEL = 0x00000003 - TSS_TSPATTRIB_DELFAMILYINFO_VERCOUNT = 0x00000004 - TSS_TSPATTRIB_DELFAMILYINFO_FAMILYID = 0x00000005 - TSS_DELEGATE_INCREMENTVERIFICATIONCOUNT = 1 - TSS_DELEGATE_CACHEOWNERDELEGATION_OVERWRITEEXISTING = 1 - TSS_TSPATTRIB_DAACRED_COMMIT = 0x00000001 - TSS_TSPATTRIB_DAACRED_ATTRIB_GAMMAS = 0x00000002 - TSS_TSPATTRIB_DAACRED_CREDENTIAL_BLOB = 0x00000003 - TSS_TSPATTRIB_DAACRED_CALLBACK_SIGN = 0x00000004 - TSS_TSPATTRIB_DAACRED_CALLBACK_VERIFYSIGNATURE = 0x00000005 - TSS_TSPATTRIB_DAACOMMIT_NUMBER = 0x00000001 - TSS_TSPATTRIB_DAACOMMIT_SELECTION = 0x00000002 - TSS_TSPATTRIB_DAACOMMIT_COMMITMENTS = 0x00000003 - TSS_TSPATTRIB_DAAATTRIBGAMMAS_BLOB = 0xffffffff - TSS_TSPATTRIB_DAAISSUERKEY_BLOB = 0x00000001 - TSS_TSPATTRIB_DAAISSUERKEY_PUBKEY = 0x00000002 - TSS_TSPATTRIB_DAAISSUERKEYBLOB_PUBLIC_KEY = 0x00000001 - TSS_TSPATTRIB_DAAISSUERKEYBLOB_SECRET_KEY = 0x00000002 - TSS_TSPATTRIB_DAAISSUERKEYBLOB_KEYBLOB = 0x00000003 - TSS_TSPATTRIB_DAAISSUERKEYBLOB_PROOF = 0x00000004 - TSS_TSPATTRIB_DAAISSUERKEYPUBKEY_NUM_ATTRIBS = 0x00000001 - TSS_TSPATTRIB_DAAISSUERKEYPUBKEY_NUM_PLATFORM_ATTRIBS = 0x00000002 - TSS_TSPATTRIB_DAAISSUERKEYPUBKEY_NUM_ISSUER_ATTRIBS = 0x00000003 - TSS_TSPATTRIB_DAAARAKEY_BLOB = 0x00000001 - TSS_TSPATTRIB_DAAARAKEYBLOB_PUBLIC_KEY = 0x00000001 - TSS_TSPATTRIB_DAAARAKEYBLOB_SECRET_KEY = 0x00000002 - TSS_TSPATTRIB_DAAARAKEYBLOB_KEYBLOB = 0x00000003 - TSS_FLAG_DAA_PSEUDONYM_PLAIN = 0x00000000 - TSS_FLAG_DAA_PSEUDONYM_ENCRYPTED = 0x00000001 - TSS_TSPATTRIB_KEY_BLOB = 0x00000040 - TSS_TSPATTRIB_KEY_INFO = 0x00000080 - TSS_TSPATTRIB_KEY_UUID = 0x000000C0 - TSS_TSPATTRIB_KEY_PCR = 0x00000100 - TSS_TSPATTRIB_RSAKEY_INFO = 0x00000140 - TSS_TSPATTRIB_KEY_REGISTER = 0x00000180 - TSS_TSPATTRIB_KEY_PCR_LONG = 0x000001c0 - TSS_TSPATTRIB_KEY_CONTROLBIT = 0x00000200 - TSS_TSPATTRIB_KEY_CMKINFO = 0x00000400 - TSS_TSPATTRIB_KEYBLOB_BLOB = 0x00000008 - TSS_TSPATTRIB_KEYBLOB_PUBLIC_KEY = 0x00000010 - TSS_TSPATTRIB_KEYBLOB_PRIVATE_KEY = 0x00000028 - TSS_TSPATTRIB_KEYINFO_SIZE = 0x00000080 - TSS_TSPATTRIB_KEYINFO_USAGE = 0x00000100 - TSS_TSPATTRIB_KEYINFO_KEYFLAGS = 0x00000180 - TSS_TSPATTRIB_KEYINFO_AUTHUSAGE = 0x00000200 - TSS_TSPATTRIB_KEYINFO_ALGORITHM = 0x00000280 - TSS_TSPATTRIB_KEYINFO_SIGSCHEME = 0x00000300 - TSS_TSPATTRIB_KEYINFO_ENCSCHEME = 0x00000380 - TSS_TSPATTRIB_KEYINFO_MIGRATABLE = 0x00000400 - TSS_TSPATTRIB_KEYINFO_REDIRECTED = 0x00000480 - TSS_TSPATTRIB_KEYINFO_VOLATILE = 0x00000500 - TSS_TSPATTRIB_KEYINFO_AUTHDATAUSAGE = 0x00000580 - TSS_TSPATTRIB_KEYINFO_VERSION = 0x00000600 - TSS_TSPATTRIB_KEYINFO_CMK = 0x00000680 - TSS_TSPATTRIB_KEYINFO_KEYSTRUCT = 0x00000700 - TSS_TSPATTRIB_KEYCONTROL_OWNEREVICT = 0x00000780 - TSS_TSPATTRIB_KEYINFO_RSA_EXPONENT = 0x00001000 - TSS_TSPATTRIB_KEYINFO_RSA_MODULUS = 0x00002000 - TSS_TSPATTRIB_KEYINFO_RSA_KEYSIZE = 0x00003000 - TSS_TSPATTRIB_KEYINFO_RSA_PRIMES = 0x00004000 - TSS_TSPATTRIB_KEYPCR_DIGEST_ATCREATION = 0x00008000 - TSS_TSPATTRIB_KEYPCR_DIGEST_ATRELEASE = 0x00010000 - TSS_TSPATTRIB_KEYPCR_SELECTION = 0x00018000 - TSS_TSPATTRIB_KEYREGISTER_USER = 0x02000000 - TSS_TSPATTRIB_KEYREGISTER_SYSTEM = 0x04000000 - TSS_TSPATTRIB_KEYREGISTER_NO = 0x06000000 - TSS_TSPATTRIB_KEYPCRLONG_LOCALITY_ATCREATION = 0x00040000 - TSS_TSPATTRIB_KEYPCRLONG_LOCALITY_ATRELEASE = 0x00080000 - TSS_TSPATTRIB_KEYPCRLONG_CREATION_SELECTION = 0x000C0000 - TSS_TSPATTRIB_KEYPCRLONG_RELEASE_SELECTION = 0x00100000 - TSS_TSPATTRIB_KEYPCRLONG_DIGEST_ATCREATION = 0x00140000 - TSS_TSPATTRIB_KEYPCRLONG_DIGEST_ATRELEASE = 0x00180000 - TSS_TSPATTRIB_KEYINFO_CMK_MA_APPROVAL = 0x00000010 - TSS_TSPATTRIB_KEYINFO_CMK_MA_DIGEST = 0x00000020 - TSS_KEY_SIZEVAL_512BIT = 0x0200 - TSS_KEY_SIZEVAL_1024BIT = 0x0400 - TSS_KEY_SIZEVAL_2048BIT = 0x0800 - TSS_KEY_SIZEVAL_4096BIT = 0x1000 - TSS_KEY_SIZEVAL_8192BIT = 0x2000 - TSS_KEY_SIZEVAL_16384BIT = 0x4000 - TSS_KEYUSAGE_BIND = 0x00 - TSS_KEYUSAGE_IDENTITY = 0x01 - TSS_KEYUSAGE_LEGACY = 0x02 - TSS_KEYUSAGE_SIGN = 0x03 - TSS_KEYUSAGE_STORAGE = 0x04 - TSS_KEYUSAGE_AUTHCHANGE = 0x05 - TSS_KEYUSAGE_MIGRATE = 0x06 - TSS_KEYFLAG_REDIRECTION = 0x00000001 - TSS_KEYFLAG_MIGRATABLE = 0x00000002 - TSS_KEYFLAG_VOLATILEKEY = 0x00000004 - TSS_KEYFLAG_CERTIFIED_MIGRATABLE = 0x00000008 - TSS_ALG_RSA = 0x20 - TSS_ALG_DES = 0x21 - TSS_ALG_3DES = 0x22 - TSS_ALG_SHA = 0x23 - TSS_ALG_HMAC = 0x24 - TSS_ALG_AES128 = 0x25 - TSS_ALG_AES192 = 0x26 - TSS_ALG_AES256 = 0x27 - TSS_ALG_XOR = 0x28 - TSS_ALG_MGF1 = 0x29 - TSS_ALG_AES = TSS_ALG_AES128 - TSS_ALG_DEFAULT = 0xfe - TSS_ALG_DEFAULT_SIZE = 0xff - TSS_SS_NONE = 0x10 - TSS_SS_RSASSAPKCS1V15_SHA1 = 0x11 - TSS_SS_RSASSAPKCS1V15_DER = 0x12 - TSS_SS_RSASSAPKCS1V15_INFO = 0x13 - TSS_ES_NONE = 0x10 - TSS_ES_RSAESPKCSV15 = 0x11 - TSS_ES_RSAESOAEP_SHA1_MGF1 = 0x12 - TSS_ES_SYM_CNT = 0x13 - TSS_ES_SYM_OFB = 0x14 - TSS_ES_SYM_CBC_PKCS5PAD = 0x15 - TSS_PS_TYPE_USER = 1 - TSS_PS_TYPE_SYSTEM = 2 - TSS_MS_MIGRATE = 0x20 - TSS_MS_REWRAP = 0x21 - TSS_MS_MAINT = 0x22 - TSS_MS_RESTRICT_MIGRATE = 0x23 - TSS_MS_RESTRICT_APPROVE_DOUBLE = 0x24 - TSS_MS_RESTRICT_MIGRATE_EXTERNAL = 0x25 - TSS_KEYAUTH_AUTH_NEVER = 0x10 - TSS_KEYAUTH_AUTH_ALWAYS = 0x11 - TSS_KEYAUTH_AUTH_PRIV_USE_ONLY = 0x12 - TSS_TPMSTATUS_DISABLEOWNERCLEAR = 0x00000001 - TSS_TPMSTATUS_DISABLEFORCECLEAR = 0x00000002 - TSS_TPMSTATUS_DISABLED = 0x00000003 - TSS_TPMSTATUS_DEACTIVATED = 0x00000004 - TSS_TPMSTATUS_OWNERSETDISABLE = 0x00000005 - TSS_TPMSTATUS_SETOWNERINSTALL = 0x00000006 - TSS_TPMSTATUS_DISABLEPUBEKREAD = 0x00000007 - TSS_TPMSTATUS_ALLOWMAINTENANCE = 0x00000008 - TSS_TPMSTATUS_PHYSPRES_LIFETIMELOCK = 0x00000009 - TSS_TPMSTATUS_PHYSPRES_HWENABLE = 0x0000000A - TSS_TPMSTATUS_PHYSPRES_CMDENABLE = 0x0000000B - TSS_TPMSTATUS_PHYSPRES_LOCK = 0x0000000C - TSS_TPMSTATUS_PHYSPRESENCE = 0x0000000D - TSS_TPMSTATUS_PHYSICALDISABLE = 0x0000000E - TSS_TPMSTATUS_CEKP_USED = 0x0000000F - TSS_TPMSTATUS_PHYSICALSETDEACTIVATED = 0x00000010 - TSS_TPMSTATUS_SETTEMPDEACTIVATED = 0x00000011 - TSS_TPMSTATUS_POSTINITIALISE = 0x00000012 - TSS_TPMSTATUS_TPMPOST = 0x00000013 - TSS_TPMSTATUS_TPMPOSTLOCK = 0x00000014 - TSS_TPMSTATUS_DISABLEPUBSRKREAD = 0x00000016 - TSS_TPMSTATUS_MAINTENANCEUSED = 0x00000017 - TSS_TPMSTATUS_OPERATORINSTALLED = 0x00000018 - TSS_TPMSTATUS_OPERATOR_INSTALLED = TSS_TPMSTATUS_OPERATORINSTALLED - TSS_TPMSTATUS_FIPS = 0x00000019 - TSS_TPMSTATUS_ENABLEREVOKEEK = 0x0000001A - TSS_TPMSTATUS_ENABLE_REVOKEEK = TSS_TPMSTATUS_ENABLEREVOKEEK - TSS_TPMSTATUS_NV_LOCK = 0x0000001B - TSS_TPMSTATUS_TPM_ESTABLISHED = 0x0000001C - TSS_TPMSTATUS_RESETLOCK = 0x0000001D - TSS_TPMSTATUS_DISABLE_FULL_DA_LOGIC_INFO = 0x0000001D - TSS_TPMCAP_ORD = 0x10 - TSS_TPMCAP_ALG = 0x11 - TSS_TPMCAP_FLAG = 0x12 - TSS_TPMCAP_PROPERTY = 0x13 - TSS_TPMCAP_VERSION = 0x14 - TSS_TPMCAP_VERSION_VAL = 0x15 - TSS_TPMCAP_NV_LIST = 0x16 - TSS_TPMCAP_NV_INDEX = 0x17 - TSS_TPMCAP_MFR = 0x18 - TSS_TPMCAP_SYM_MODE = 0x19 - TSS_TPMCAP_HANDLE = 0x1a - TSS_TPMCAP_TRANS_ES = 0x1b - TSS_TPMCAP_AUTH_ENCRYPT = 0x1c - TSS_TPMCAP_SET_PERM_FLAGS = 0x1d - TSS_TPMCAP_SET_VENDOR = 0x1e - TSS_TPMCAP_DA_LOGIC = 0x1f - TSS_TPMCAP_PROP_PCR = 0x10 - TSS_TPMCAP_PROP_DIR = 0x11 - TSS_TPMCAP_PROP_MANUFACTURER = 0x12 - TSS_TPMCAP_PROP_SLOTS = 0x13 - TSS_TPMCAP_PROP_KEYS = TSS_TPMCAP_PROP_SLOTS - TSS_TPMCAP_PROP_FAMILYROWS = 0x14 - TSS_TPMCAP_PROP_DELEGATEROWS = 0x15 - TSS_TPMCAP_PROP_OWNER = 0x16 - TSS_TPMCAP_PROP_MAXKEYS = 0x18 - TSS_TPMCAP_PROP_AUTHSESSIONS = 0x19 - TSS_TPMCAP_PROP_MAXAUTHSESSIONS = 0x1a - TSS_TPMCAP_PROP_TRANSESSIONS = 0x1b - TSS_TPMCAP_PROP_MAXTRANSESSIONS = 0x1c - TSS_TPMCAP_PROP_SESSIONS = 0x1d - TSS_TPMCAP_PROP_MAXSESSIONS = 0x1e - TSS_TPMCAP_PROP_CONTEXTS = 0x1f - TSS_TPMCAP_PROP_MAXCONTEXTS = 0x20 - TSS_TPMCAP_PROP_DAASESSIONS = 0x21 - TSS_TPMCAP_PROP_MAXDAASESSIONS = 0x22 - TSS_TPMCAP_PROP_DAA_INTERRUPT = 0x23 - TSS_TPMCAP_PROP_COUNTERS = 0x24 - TSS_TPMCAP_PROP_MAXCOUNTERS = 0x25 - TSS_TPMCAP_PROP_ACTIVECOUNTER = 0x26 - TSS_TPMCAP_PROP_MIN_COUNTER = 0x27 - TSS_TPMCAP_PROP_TISTIMEOUTS = 0x28 - TSS_TPMCAP_PROP_STARTUPEFFECTS = 0x29 - TSS_TPMCAP_PROP_MAXCONTEXTCOUNTDIST = 0x2a - TSS_TPMCAP_PROP_CMKRESTRICTION = 0x2b - TSS_TPMCAP_PROP_DURATION = 0x2c - TSS_TPMCAP_PROP_MAXNVAVAILABLE = 0x2d - TSS_TPMCAP_PROP_INPUTBUFFERSIZE = 0x2e - TSS_TPMCAP_PROP_REVISION = 0x2f - TSS_TPMCAP_PROP_LOCALITIES_AVAIL = 0x32 - TSS_RT_KEY = 0x00000010 - TSS_RT_AUTH = 0x00000020 - TSS_RT_TRANS = 0x00000030 - TSS_RT_COUNTER = 0x00000040 - TSS_TCSCAP_ALG = 0x00000001 - TSS_TCSCAP_VERSION = 0x00000002 - TSS_TCSCAP_CACHING = 0x00000003 - TSS_TCSCAP_PERSSTORAGE = 0x00000004 - TSS_TCSCAP_MANUFACTURER = 0x00000005 - TSS_TCSCAP_PLATFORM_CLASS = 0x00000006 - TSS_TCSCAP_TRANSPORT = 0x00000007 - TSS_TCSCAP_PLATFORM_INFO = 0x00000008 - TSS_TCSCAP_PROP_KEYCACHE = 0x00000100 - TSS_TCSCAP_PROP_AUTHCACHE = 0x00000101 - TSS_TCSCAP_PROP_MANUFACTURER_STR = 0x00000102 - TSS_TCSCAP_PROP_MANUFACTURER_ID = 0x00000103 - TSS_TCSCAP_PLATFORM_VERSION = 0x00001100 - TSS_TCSCAP_PLATFORM_TYPE = 0x00001101 - TSS_TCSCAP_TRANS_EXCLUSIVE = 0x00002100 - TSS_TCSCAP_PROP_HOST_PLATFORM = 0x00003001 - TSS_TCSCAP_PROP_ALL_PLATFORMS = 0x00003002 - TSS_TSPCAP_ALG = 0x00000010 - TSS_TSPCAP_VERSION = 0x00000011 - TSS_TSPCAP_PERSSTORAGE = 0x00000012 - TSS_TSPCAP_MANUFACTURER = 0x00000013 - TSS_TSPCAP_RETURNVALUE_INFO = 0x00000015 - TSS_TSPCAP_PLATFORM_INFO = 0x00000016 - TSS_TSPCAP_PROP_MANUFACTURER_STR = 0x00000102 - TSS_TSPCAP_PROP_MANUFACTURER_ID = 0x00000103 - TSS_TSPCAP_PLATFORM_TYPE = 0x00000201 - TSS_TSPCAP_PLATFORM_VERSION = 0x00000202 - TSS_TSPCAP_PROP_RETURNVALUE_INFO = 0x00000201 - TSS_EV_CODE_CERT = 0x00000001 - TSS_EV_CODE_NOCERT = 0x00000002 - TSS_EV_XML_CONFIG = 0x00000003 - TSS_EV_NO_ACTION = 0x00000004 - TSS_EV_SEPARATOR = 0x00000005 - TSS_EV_ACTION = 0x00000006 - TSS_EV_PLATFORM_SPECIFIC = 0x00000007 - TSS_TSPCAP_RANDOMLIMIT = 0x00001000 - TSS_PCRS_DIRECTION_CREATION = 1 - TSS_PCRS_DIRECTION_RELEASE = 2 - TSS_BLOB_STRUCT_VERSION = 0x01 - TSS_BLOB_TYPE_KEY = 0x01 - TSS_BLOB_TYPE_PUBKEY = 0x02 - TSS_BLOB_TYPE_MIGKEY = 0x03 - TSS_BLOB_TYPE_SEALEDDATA = 0x04 - TSS_BLOB_TYPE_BOUNDDATA = 0x05 - TSS_BLOB_TYPE_MIGTICKET = 0x06 - TSS_BLOB_TYPE_PRIVATEKEY = 0x07 - TSS_BLOB_TYPE_PRIVATEKEY_MOD1 = 0x08 - TSS_BLOB_TYPE_RANDOM_XOR = 0x09 - TSS_BLOB_TYPE_CERTIFY_INFO = 0x0A - TSS_BLOB_TYPE_KEY_1_2 = 0x0B - TSS_BLOB_TYPE_CERTIFY_INFO_2 = 0x0C - TSS_BLOB_TYPE_CMK_MIG_KEY = 0x0D - TSS_BLOB_TYPE_CMK_BYTE_STREAM = 0x0E - TSS_CMK_DELEGATE_SIGNING = 1 << 31 - TSS_CMK_DELEGATE_STORAGE = 1 << 30 - TSS_CMK_DELEGATE_BIND = 1 << 29 - TSS_CMK_DELEGATE_LEGACY = 1 << 28 - TSS_CMK_DELEGATE_MIGRATE = 1 << 27 - TSS_DAA_LENGTH_N = 256 - TSS_DAA_LENGTH_F = 13 - TSS_DAA_LENGTH_E = 46 - TSS_DAA_LENGTH_E_PRIME = 15 - TSS_DAA_LENGTH_V = 317 - TSS_DAA_LENGTH_SAFETY = 10 - TSS_DAA_LENGTH_HASH = 20 - TSS_DAA_LENGTH_S = 128 - TSS_DAA_LENGTH_GAMMA = 204 - TSS_DAA_LENGTH_RHO = 26 - TSS_DAA_LENGTH_MFG1_GAMMA = 214 - TSS_DAA_LENGTH_MGF1_AR = 25 - TPM_ALG_RSA = 0x00000001 - TPM_ALG_DES = 0x00000002 - TPM_ALG_3DES = 0x00000003 - TPM_ALG_SHA = 0x00000004 - TPM_ALG_HMAC = 0x00000005 - TPM_ALG_AES = 0x00000006 - TPM_ALG_AES128 = TPM_ALG_AES - TPM_ALG_MGF1 = 0x00000007 - TPM_ALG_AES192 = 0x00000008 - TPM_ALG_AES256 = 0x00000009 - TPM_ALG_XOR = 0x0000000A - TPM_SS_NONE = 0x0001 - TPM_SS_RSASSAPKCS1v15_SHA1 = 0x0002 - TPM_SS_RSASSAPKCS1v15_DER = 0x0003 - TPM_SS_RSASSAPKCS1v15_INFO = 0x0004 - TPM_ES_NONE = 0x0001 - TPM_ES_RSAESPKCSv15 = 0x0002 - TPM_ES_RSAESOAEP_SHA1_MGF1 = 0x0003 - TPM_ES_SYM_CNT = 0x0004 - TPM_ES_SYM_CTR = TPM_ES_SYM_CNT - TPM_ES_SYM_OFB = 0x0005 - TPM_ES_SYM_CBC_PKCS5PAD = 0x00FF -) - -// Log represents an entry from the TSS event log. Pcr is the register that -// was extended by the event. Eventtype is the type of the event. PcrValue -// is the value that was hashed into the TPM. Event is the raw event data. -type Log struct { - Pcr int32 - Eventtype int32 - PcrValue [20]byte - Event []byte -} diff --git a/Godeps/_workspace/src/github.com/coreos/go-tspi/verification/verification.go b/Godeps/_workspace/src/github.com/coreos/go-tspi/verification/verification.go deleted file mode 100644 index 15e06e2103..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/go-tspi/verification/verification.go +++ /dev/null @@ -1,654 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package verification - -import ( - "bytes" - "crypto" - "crypto/aes" - "crypto/cipher" - "crypto/rand" - "crypto/rsa" - "crypto/sha1" - "crypto/x509" - "encoding/binary" - "encoding/pem" - "errors" - "fmt" - "math/big" - - "github.com/coreos/go-tspi/tspiconst" -) - -func pad(plaintext []byte, bsize int) ([]byte, error) { - if bsize >= 256 { - return nil, errors.New("bsize must be < 256") - } - pad := bsize - (len(plaintext) % bsize) - if pad == 0 { - pad = bsize - } - for i := 0; i < pad; i++ { - plaintext = append(plaintext, byte(pad)) - } - return plaintext, nil -} - -// GenerateChallenge takes a copy of the EK certificate, the public half of -// the AIK to be challenged and a secret. It then symmetrically encrypts the -// secret with a randomly generated AES key and Asymmetrically encrypts the -// AES key with the public half of the EK. These can then be provided to the -// TPM in order to ensure that the AIK is under the control of the TPM. It -// returns the asymmetrically and symmetrically encrypted data, along with -// any error. -func GenerateChallenge(ekcert []byte, aikpub []byte, secret []byte) (asymenc []byte, symenc []byte, err error) { - aeskey := make([]byte, 16) - iv := make([]byte, 16) - - _, err = rand.Read(aeskey) - if err != nil { - return nil, nil, err - } - - _, err = rand.Read(iv) - if err != nil { - return nil, nil, err - } - - /* - * The EK certificate has an OID for rsaesOaep which will break - * parsing. Replace it with rsaEncryption instead. - */ - ekcert = bytes.Replace(ekcert, []byte{0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x07}, []byte{0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01}, 1) - cert, err := x509.ParseCertificate(ekcert) - pubkey := cert.PublicKey.(*rsa.PublicKey) - - asymplain := []byte{0x00, 0x00, 0x00, 0x06, 0x00, 0xff, 0x00, 0x10} - asymplain = append(asymplain, aeskey...) - hash := sha1.Sum(aikpub) - asymplain = append(asymplain, hash[:]...) - - label := []byte{'T', 'C', 'P', 'A'} - asymenc, err = rsa.EncryptOAEP(sha1.New(), rand.Reader, pubkey, asymplain, label) - block, err := aes.NewCipher(aeskey) - if err != nil { - return nil, nil, err - } - cbc := cipher.NewCBCEncrypter(block, iv) - secret, err = pad(secret, len(iv)) - if err != nil { - return nil, nil, err - } - symenc = make([]byte, len(secret)) - cbc.CryptBlocks(symenc, secret) - - symheader := new(bytes.Buffer) - err = binary.Write(symheader, binary.BigEndian, (uint32)(len(symenc)+len(iv))) - if err != nil { - return nil, nil, err - } - err = binary.Write(symheader, binary.BigEndian, (uint32)(tspiconst.TPM_ALG_AES)) - if err != nil { - return nil, nil, err - } - err = binary.Write(symheader, binary.BigEndian, (uint16)(tspiconst.TPM_ES_SYM_CBC_PKCS5PAD)) - if err != nil { - return nil, nil, err - } - err = binary.Write(symheader, binary.BigEndian, (uint16)(tspiconst.TPM_SS_NONE)) - if err != nil { - return nil, nil, err - } - err = binary.Write(symheader, binary.BigEndian, (uint32)(12)) - if err != nil { - return nil, nil, err - } - err = binary.Write(symheader, binary.BigEndian, (uint32)(128)) - if err != nil { - return nil, nil, err - } - err = binary.Write(symheader, binary.BigEndian, (uint32)(len(iv))) - if err != nil { - return nil, nil, err - } - err = binary.Write(symheader, binary.BigEndian, (uint32)(0)) - if err != nil { - return nil, nil, err - } - header := make([]byte, 28) - err = binary.Read(symheader, binary.BigEndian, &header) - header = append(header, iv...) - header = append(header, symenc...) - symenc = header - - return asymenc, symenc, nil -} - -// VerifyEKCert verifies that the provided EK certificate is signed by a -// trusted manufacturer. -func VerifyEKCert(ekcert []byte) error { - trustedCerts := map[string]string{ - "STM1": `-----BEGIN CERTIFICATE----- -MIIDzDCCArSgAwIBAgIEAAAAATANBgkqhkiG9w0BAQsFADBKMQswCQYDVQQGEwJD -SDEeMBwGA1UEChMVU1RNaWNyb2VsZWN0cm9uaWNzIE5WMRswGQYDVQQDExJTVE0g -VFBNIEVLIFJvb3QgQ0EwHhcNMDkwNzI4MDAwMDAwWhcNMjkxMjMxMDAwMDAwWjBV -MQswCQYDVQQGEwJDSDEeMBwGA1UEChMVU1RNaWNyb2VsZWN0cm9uaWNzIE5WMSYw -JAYDVQQDEx1TVE0gVFBNIEVLIEludGVybWVkaWF0ZSBDQSAwMTCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAJQYnWO8iw955vWqakWNr3YyazQnNzqV97+l -Qa+wUKMVY+lsyhAyOyXO31j4+clvsj6+JhNEwQtcnpkSc+TX60eZvLhgZPUgRVuK -B9w4GUVyg/db593QUmP8K41Is8E+l32CQdcVh9go0toqf/oS/za1TDFHEHLlB4dC -joKkfr3/hkGA9XJaoUopO2ELt4Otop12aw1BknoiTh1+YbzrZtAlIwK2TX99GW3S -IjaCi+fLoXyK2Fmx8vKnr9JfNL888xK9BQfhZzKmbKm/eLD1e1CFRs1B3z2gd3ax -pW5j1OIkSBMOIUeip5+7xvYo2gor5mxatB+rzSvrWup9AwIcymMCAwEAAaOBrjCB -qzAdBgNVHQ4EFgQU88kVdKbnc/8TvwxrrXp7Zc8ceCAwHwYDVR0jBBgwFoAUb+bF -bAe3bIsKgZKDXMtBHva00ScwRQYDVR0gAQH/BDswOTA3BgRVHSAAMC8wLQYIKwYB -BQUHAgEWIWh0dHA6Ly93d3cuc3QuY29tL1RQTS9yZXBvc2l0b3J5LzAOBgNVHQ8B -Af8EBAMCAAQwEgYDVR0TAQH/BAgwBgEB/wIBADANBgkqhkiG9w0BAQsFAAOCAQEA -uZqViou3aZDGvaAn29gghOkj04SkEWViZR3dU3DGrA+5ZX+zr6kZduus3Hf0bVHT -I318PZGTml1wm6faDRomE8bI5xADWhPiCQ1Gf7cFPiqaPkq7mgdC6SGlQtRAfoP8 -ISUJlih0UtsqBWGql4lpk5G6YmvAezguWmMR0/O5Cx5w8YKfXkwAhegGmMGIoJFO -oSzJrS7jK2GnGCuRG65OQVC5HiQY2fFF0JePLWG/D56djNxMbPNGTHF3+yBWg0DU -0xJKYKGFdjFcw0Wi0m2j49Pv3JD1f78c2Z3I/65pkklZGu4awnKQcHeGIbdYF0hQ -LtDSBV4DR9q5GVxSR9JPgQ== ------END CERTIFICATE-----`, - "STM2": `-----BEGIN CERTIFICATE----- -MIIDzDCCArSgAwIBAgIEAAAAAzANBgkqhkiG9w0BAQsFADBKMQswCQYDVQQGEwJD -SDEeMBwGA1UEChMVU1RNaWNyb2VsZWN0cm9uaWNzIE5WMRswGQYDVQQDExJTVE0g -VFBNIEVLIFJvb3QgQ0EwHhcNMTEwMTIxMDAwMDAwWhcNMjkxMjMxMDAwMDAwWjBV -MQswCQYDVQQGEwJDSDEeMBwGA1UEChMVU1RNaWNyb2VsZWN0cm9uaWNzIE5WMSYw -JAYDVQQDEx1TVE0gVFBNIEVLIEludGVybWVkaWF0ZSBDQSAwMjCCASIwDQYJKoZI -hvcNAQEBBQADggEPADCCAQoCggEBAJO3ihn/uHgV3HrlPZpv8+1+xg9ccLf3pVXJ -oT5n8PHHixN6ZRBmf/Ng85/ODZzxnotC64WD8GHMLyQ0Cna3MJF+MGJZ5R5JkuJR -B4CtgTPwcTVZIsCuup0aDWnPzYqHwvfaiD2FD0aaxCnTKIjWU9OztTD2I61xW2LK -EY4Vde+W3C7WZgS5TpqkbhJzy2NJj6oSMDKklfI3X8jVf7bngMcCR3X3NcIo349I -Dt1r1GfwB+oWrhogZVnMFJKAoSYP8aQrLDVl7SQOAgTXz2IDD6bo1jga/8Kb72dD -h8D2qrkqWh7Hwdas3jqqbb9uiq6O2dJJY86FjffjXPo3jGlFjTsCAwEAAaOBrjCB -qzAdBgNVHQ4EFgQUVx+Aa0fM55v6NZR87Yi40QBa4J4wHwYDVR0jBBgwFoAUb+bF -bAe3bIsKgZKDXMtBHvaO0ScwRQYDVR0gAQH/BDswOTA3BgRVHSAAMC8wLQYIKwYB -BQUHAgEWIWh0dHA6Ly93d3cuc3QuY29tL1RQTS9yZXBvc2l0b3J5LzAOBgNVHQ8B -Af8EBAMCAAQwEgYDVR0TAQH/BAgwBgEB/wIBATANBgkqhkiG9w0BAQsFAAOCAQEA -4gllWq44PFWcv0JgMPOtyXDQx30YB5vBpjS0in7f/Y/r+1Dd8q3EZwNOwYApe+Lp -/ldNqCXw4XzmO8ZCVWOdQdVOqHZuSOhe++Jn0S7M4z2/1PQ6EbRczGfw3dlX63Ec -cEnrn6YMcgPC63Q+ID53vbTS3gpeX/SGpngtVwnzpuJ5rBajqSQUo5jBTBtuGQpO -Ko6Eu7U6Ouz7BVgOSn0mLbfSRb77PjOLZ3+97gSiMmV0iofS7ufemYqA8sF7ZFv/ -lM2eOe/eeS56Jw+IPsnEU0Tf8Tn9hnEig1KP8VByRTWAJgiEOgX2nTs5iJbyZeIZ -RUjDHQQ5onqhgjpfRsC95g== ------END CERTIFICATE-----`, - "NTC1": `-----BEGIN CERTIFICATE----- -MIIDSjCCAjKgAwIBAgIGAK3jXfbVMA0GCSqGSIb3DQEBBQUAMFIxUDAcBgNVBAMT -FU5UQyBUUE0gRUsgUm9vdCBDQSAwMTAlBgNVBAoTHk51dm90b24gVGVjaG5vbG9n -eSBDb3Jwb3JhdGlvbjAJBgNVBAYTAlRXMB4XDTEyMDcxMTE2MjkzMFoXDTMyMDcx -MTE2MjkzMFowUjFQMBwGA1UEAxMVTlRDIFRQTSBFSyBSb290IENBIDAxMCUGA1UE -ChMeTnV2b3RvbiBUZWNobm9sb2d5IENvcnBvcmF0aW9uMAkGA1UEBhMCVFcwggEi -MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDoNqxhtD4yUtXhqKQGGZemoKJy -uj1RnWvmNgzItLeejNU8B6fOnpMQyoS4K72tMhhFRK2jV9RYzyJMSjEwyX0ASTO1 -2yMti2UJQS60d36eGwk8WLgrFnnITlemshi01h9t1MOmay3TO1LLH/3/VDKJ+jbd -cbfIO2bBquN8r3/ojYUaNSPj6pK1mmsMoJXF4dGRSEwb/4ozBIw5dugm1MEq4Zj3 -GZ0YPg5wyLRugQbt7DkUOX4FGuK5p/C0u5zX8u33EGTrDrRz3ye3zO+aAY1xXF/m -qwEqgxX5M8f0/DXTTO/CfeIksuPeOzujFtXfi5Cy64eeIZ0nAUG3jbtnGjoFAgMB -AAGjJjAkMA4GA1UdDwEB/wQEAwICBDASBgNVHRMBAf8ECDAGAQH/AgEAMA0GCSqG -SIb3DQEBBQUAA4IBAQBBQznOPJAsD4Yvyt/hXtVJSgBX/+rRfoaqbdt3UMbUPJYi -pUoTUgaTx02DVRwommO+hLx7CS++1F2zorWC8qQyvNbg7iffQbbjWitt8NPE6kCr -q0Y5g7M/LkQDd5N3cFfC15uFJOtlj+A2DGzir8dlXU/0qNq9dBFbi+y+Y3rAT+wK -fktmN82UT861wTUzDvnXO+v7H5DYXjUU8kejPW6q+GgsccIbVTOdHNNWbMrcD9yf -oS91nMZ/+/n7IfFWXNN82qERsrvOFCDsbIzUOR30N0IP++oqGfwAbKFfCOCFUz6j -jpXUdJlh22tp12UMsreibmi5bsWYBgybwSbRgvzE ------END CERTIFICATE-----`, - "NTC2": `-----BEGIN CERTIFICATE----- -MIIDSjCCAjKgAwIBAgIGAPadBmPZMA0GCSqGSIb3DQEBBQUAMFIxUDAcBgNVBAMT -FU5UQyBUUE0gRUsgUm9vdCBDQSAwMjAlBgNVBAoTHk51dm90b24gVGVjaG5vbG9n -eSBDb3Jwb3JhdGlvbjAJBgNVBAYTAlRXMB4XDTEyMDcxMTE2MzMyNFoXDTMyMDcx -MTE2MzMyNFowUjFQMBwGA1UEAxMVTlRDIFRQTSBFSyBSb290IENBIDAyMCUGA1UE -ChMeTnV2b3RvbiBUZWNobm9sb2d5IENvcnBvcmF0aW9uMAkGA1UEBhMCVFcwggEi -MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDSagWxaANT1YA2YUSN7sq7yzOT -1ymbIM+WijhE5AGcLwLFoJ9fmaQrYL6fAW2EW/Q3yu97Q9Ysr8yYZ2XCCfxfseEr -Vs80an8Nk6LkTDz8+0Hm0Cct0klvNUAZEIvWpmgHZMvGijXyOcp4z494d8B28Ynb -I7x0JMXZZQQKQi+WfuHtntF+2osYScweocipPrGeONLKU9sngWZ2vnnvw1SBneTa -irxq0Q0SD6Bx9jtxvdf87euk8JzfPhX8jp8GEeAjmLwGR+tnOQrDmczGNmp7YYNN -R+Q7NZVoYWHw5jaoZnNxbouWUXZZxFqDsB/ndCKWtsIzRYPuWcqrFcmUN4SVAgMB -AAGjJjAkMA4GA1UdDwEB/wQEAwICBDASBgNVHRMBAf8ECDAGAQH/AgEAMA0GCSqG -SIb3DQEBBQUAA4IBAQAIkdDSErzPLPYrVthw4lKjW4tRYelUicMPEHKjQeVUAAS5 -y9XTzB4DWISDAFsgtQjqHJj0xCG+vpY0Rmn2FCO/0YpP+YBQkdbJOsiyXCdFy9e4 -gGjQ24gw1B+rr84+pkI51y952NYBdoQDeb7diPe+24U94f//DYt/JQ8cJua4alr3 -2Pohhh5TxCXXfU2EHt67KyqBSxCSy9m4OkCOGLHL2X5nQIdXVj178mw6DSAwyhwR -n3uJo5MvUEoQTFZJKGSXfab619mIgzEr+YHsIQToqf44VfDMDdM+MFiXQ3a5fLii -hEKQ9DhBPtpHAbhFA4jhCiG9HA8FdEplJ+M4uxNz ------END CERTIFICATE-----`, - "IFX1": `-----BEGIN CERTIFICATE----- -MIIEnzCCA4egAwIBAgIEMV64bDANBgkqhkiG9w0BAQUFADBtMQswCQYDVQQGEwJE -RTEQMA4GA1UECBMHQmF2YXJpYTEhMB8GA1UEChMYSW5maW5lb24gVGVjaG5vbG9n -aWVzIEFHMQwwCgYDVQQLEwNBSU0xGzAZBgNVBAMTEklGWCBUUE0gRUsgUm9vdCBD -QTAeFw0wNTEwMjAxMzQ3NDNaFw0yNTEwMjAxMzQ3NDNaMHcxCzAJBgNVBAYTAkRF -MQ8wDQYDVQQIEwZTYXhvbnkxITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2ll -cyBBRzEMMAoGA1UECxMDQUlNMSYwJAYDVQQDEx1JRlggVFBNIEVLIEludGVybWVk -aWF0ZSBDQSAwMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALftPhYN -t4rE+JnU/XOPICbOBLvfo6iA7nuq7zf4DzsAWBdsZEdFJQfaK331ihG3IpQnlQ2i -YtDim289265f0J4OkPFpKeFU27CsfozVaNUm6UR/uzwA8ncxFc3iZLRMRNLru/Al -VG053ULVDQMVx2iwwbBSAYO9pGiGbk1iMmuZaSErMdb9v0KRUyZM7yABiyDlM3cz -UQX5vLWV0uWqxdGoHwNva5u3ynP9UxPTZWHZOHE6+14rMzpobs6Ww2RR8BgF96rh -4rRAZEl8BXhwiQq4STvUXkfvdpWH4lzsGcDDtrB6Nt3KvVNvsKz+b07Dk+Xzt+EH -NTf3Byk2HlvX+scCAwEAAaOCATswggE3MB0GA1UdDgQWBBQ4k8292HPEIzMV4bE7 -qWoNI8wQxzAOBgNVHQ8BAf8EBAMCAgQwEgYDVR0TAQH/BAgwBgEB/wIBADBYBgNV -HSABAf8ETjBMMEoGC2CGSAGG+EUBBy8BMDswOQYIKwYBBQUHAgEWLWh0dHA6Ly93 -d3cudmVyaXNpZ24uY29tL3JlcG9zaXRvcnkvaW5kZXguaHRtbDCBlwYDVR0jBIGP -MIGMgBRW65FEhWPWcrOu1EWWC/eUDlRCpqFxpG8wbTELMAkGA1UEBhMCREUxEDAO -BgNVBAgTB0JhdmFyaWExITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2llcyBB -RzEMMAoGA1UECxMDQUlNMRswGQYDVQQDExJJRlggVFBNIEVLIFJvb3QgQ0GCAQMw -DQYJKoZIhvcNAQEFBQADggEBABJ1+Ap3rNlxZ0FW0aIgdzktbNHlvXWNxFdYIBbM -OKjmbOos0Y4O60eKPu259XmMItCUmtbzF3oKYXq6ybARUT2Lm+JsseMF5VgikSlU -BJALqpKVjwAds81OtmnIQe2LSu4xcTSavpsL4f52cUAu/maMhtSgN9mq5roYptq9 -DnSSDZrX4uYiMPl//rBaNDBflhJ727j8xo9CCohF3yQUoQm7coUgbRMzyO64yMIO -3fhb+Vuc7sNwrMOz3VJN14C3JMoGgXy0c57IP/kD5zGRvljKEvrRC2I147+fPeLS -DueRMS6lblvRKiZgmGAg7YaKOkOaEmVDMQ+fTo2Po7hI5wc= ------END CERTIFICATE-----`, - "IFX2": `-----BEGIN CERTIFICATE----- -MIIEnzCCA4egAwIBAgIEaItIgTANBgkqhkiG9w0BAQUFADBtMQswCQYDVQQGEwJE -RTEQMA4GA1UECBMHQmF2YXJpYTEhMB8GA1UEChMYSW5maW5lb24gVGVjaG5vbG9n -aWVzIEFHMQwwCgYDVQQLEwNBSU0xGzAZBgNVBAMTEklGWCBUUE0gRUsgUm9vdCBD -QTAeFw0wNjEyMjExMDM0MDBaFw0yNjEyMjExMDM0MDBaMHcxCzAJBgNVBAYTAkRF -MQ8wDQYDVQQIEwZTYXhvbnkxITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2ll -cyBBRzEMMAoGA1UECxMDQUlNMSYwJAYDVQQDEx1JRlggVFBNIEVLIEludGVybWVk -aWF0ZSBDQSAwMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK6KnP5R -8ppq9TtPu3mAs3AFxdWhzK5ks+BixGR6mpzyXG64Bjl4xzBXeBIVtlBZXYvIAJ5s -eCTEEsnZc9eKNJeFLdmXQ/siRrTeonyxoS4aL1mVEQebLUz2gN9J6j1ewly+OvGk -jEYouGCzA+fARzLeRIrhuhBI0kUChbH7VM8FngJsbT4xKB3EJ6Wttma25VSimkAr -SPS6dzUDRS1OFCWtAtHJW6YjBnA4wgR8WfpXsnjeNpwEEB+JciWu1VAueLNI+Kis -RiferCfsgWRvHkR6RQf04h+FlhnYHJnf1ktqcEi1oYAjLsbYOAwqyoU1Pev9cS28 -EA6FTJcxjuHhH9ECAwEAAaOCATswggE3MB0GA1UdDgQWBBRDMlr1UAQGVIkwzamm -fceAZ7l4ATAOBgNVHQ8BAf8EBAMCAgQwEgYDVR0TAQH/BAgwBgEB/wIBADBYBgNV -HSABAf8ETjBMMEoGC2CGSAGG+EUBBy8BMDswOQYIKwYBBQUHAgEWLWh0dHA6Ly93 -d3cudmVyaXNpZ24uY29tL3JlcG9zaXRvcnkvaW5kZXguaHRtbDCBlwYDVR0jBIGP -MIGMgBRW65FEhWPWcrOu1EWWC/eUDlRCpqFxpG8wbTELMAkGA1UEBhMCREUxEDAO -BgNVBAgTB0JhdmFyaWExITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2llcyBB -RzEMMAoGA1UECxMDQUlNMRswGQYDVQQDExJJRlggVFBNIEVLIFJvb3QgQ0GCAQMw -DQYJKoZIhvcNAQEFBQADggEBAIZAaYGzf9AYv6DqoUNx6wdpayhCeX75/IHuFQ/d -gLzat9Vd6qNKdAByskpOjpE0KRauEzD/BhTtkEJDazPSmVP1QxAPjqGaD+JjqhS/ -Q6aY+1PSDi2zRIDA66V2yFJDcUBTtShbdTg144YSkVSY5UCKhQrsdg8yAbs7saAB -LHzVebTXffjmkTk5GZk26d/AZQRjfssta1N/TWhWTfuZtwYvjZmgDPeCfr6AOPLr -pVJz+ntzUKGpQ+5mwDJXMZ0qeiFIgXUlU0D+lfuajc/x9rgix9cM+o7amgDlRi1T -55Uu2vzUQ9jLUaISFaTTMag+quBDhx8BDVu+igLp5hvBtxQ= ------END CERTIFICATE-----`, - "IFX3": `-----BEGIN CERTIFICATE----- -MIIEnzCCA4egAwIBAgIEH7fYljANBgkqhkiG9w0BAQUFADBtMQswCQYDVQQGEwJE -RTEQMA4GA1UECBMHQmF2YXJpYTEhMB8GA1UEChMYSW5maW5lb24gVGVjaG5vbG9n -aWVzIEFHMQwwCgYDVQQLEwNBSU0xGzAZBgNVBAMTEklGWCBUUE0gRUsgUm9vdCBD -QTAeFw0wNzA0MTMxNjQ0MjRaFw0yNzA0MTMxNjQ0MjRaMHcxCzAJBgNVBAYTAkRF -MQ8wDQYDVQQIEwZTYXhvbnkxITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2ll -cyBBRzEMMAoGA1UECxMDQUlNMSYwJAYDVQQDEx1JRlggVFBNIEVLIEludGVybWVk -aWF0ZSBDQSAwMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJWdPAuH -z/p1tIwB1QXlPD/PjedZ4uBZdwPH5tI3Uve0TzbR/mO5clx/loWn7nZ5cHkH1nhB -R67JEFY0a9GithPfITh0XRxPcisLBE/SoqZ90KHFaS+N6SwOpdCP0GlUg1OesKCF -79Z6fXrkTZsVpPqdawdZK+oUsDO9z9U6xqV7bwsS75Y+QiHsm6UTgAkSNQnuFMP3 -NqQyDi/BaWaYRGQ6K8pM7Y7e1h21z/+5X7LncZXU8hgpYpu2zQPg96IkYboVUKL4 -00snaPcOvfagsBUGlBltNfz7geaSuWTCdwEiwlkCYZqCtbkAj5FiStajrzP72BfT -2fshIv+5eF7Qp5ECAwEAAaOCATswggE3MB0GA1UdDgQWBBTGyypNtylL6RFyT1BB -MQtMQvibsjAOBgNVHQ8BAf8EBAMCAgQwEgYDVR0TAQH/BAgwBgEB/wIBADBYBgNV -HSABAf8ETjBMMEoGC2CGSAGG+EUBBy8BMDswOQYIKwYBBQUHAgEWLWh0dHA6Ly93 -d3cudmVyaXNpZ24uY29tL3JlcG9zaXRvcnkvaW5kZXguaHRtbDCBlwYDVR0jBIGP -MIGMgBRW65FEhWPWcrOu1EWWC/eUDlRCpqFxpG8wbTELMAkGA1UEBhMCREUxEDAO -BgNVBAgTB0JhdmFyaWExITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2llcyBB -RzEMMAoGA1UECxMDQUlNMRswGQYDVQQDExJJRlggVFBNIEVLIFJvb3QgQ0GCAQMw -DQYJKoZIhvcNAQEFBQADggEBAGN1bkh4J90DGcOPP2BlwE6ejJ0iDKf1zF+7CLu5 -WS5K4dvuzsWUoQ5eplUt1LrIlorLr46mLokZD0RTG8t49Rcw4AvxMgWk7oYk69q2 -0MGwXwgZ5OQypHaPwslmddLcX+RyEvjrdGpQx3E/87ZrQP8OKnmqI3pBlB8QwCGL -SV9AERaGDpzIHoObLlUjgHuD6aFekPfeIu1xbN25oZCWmqFVIhkKxWE1Xu+qqHIA -dnCFhoIWH3ie9OsJh/iDRaANYYGyplIibDx1FJA8fqiBiBBKUlPoJvbqmZs4meMd -OoeOuCvQ7op28UtaoV6H6BSYmN5dOgW7r1lX2Re0nd84NGE= ------END CERTIFICATE-----`, - "IFX4": `-----BEGIN CERTIFICATE----- -MIIEnzCCA4egAwIBAgIEDhD4wDANBgkqhkiG9w0BAQUFADBtMQswCQYDVQQGEwJE -RTEQMA4GA1UECBMHQmF2YXJpYTEhMB8GA1UEChMYSW5maW5lb24gVGVjaG5vbG9n -aWVzIEFHMQwwCgYDVQQLEwNBSU0xGzAZBgNVBAMTEklGWCBUUE0gRUsgUm9vdCBD -QTAeFw0wNzEyMDMxMzA3NTVaFw0yNzEyMDMxMzA3NTVaMHcxCzAJBgNVBAYTAkRF -MQ8wDQYDVQQIEwZTYXhvbnkxITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2ll -cyBBRzEMMAoGA1UECxMDQUlNMSYwJAYDVQQDEx1JRlggVFBNIEVLIEludGVybWVk -aWF0ZSBDQSAwNDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAN3UBmDk -jJzzJ+WCgrq4tILtE9KJPMGHwvCsbJOlo7eHiEb8JQzGK1prkPQ3dowFRXPnqONP -WUa36/J3R32xgvuZHqAdliZCt8IUb9qYhDenuXo1SSqJ8LWp30QIJ0vnkaQ2TCkO -bveZZR3hK2OZKRTkFaV/iy2RH+Qs4JAe3diD8mlIu2gXAXnKJSkrzW6gbMzrlTOi -RCuGcatpy7Hfmodbz/0Trbuwtc3dyJZ3Ko1z9bz2Oirjh93RrmYjbtL0HhkAjMOR -83GLrzwUddSqmxtXXX8j5i+/gmE3AO71swOIESdGugxaKUzJ1jTqWKMZcx0E6BFI -lDIfKk0fJlSxHfECAwEAAaOCATswggE3MB0GA1UdDgQWBBSIs8E/YQXRBCKfWsDr -SZVkrNRzvTAOBgNVHQ8BAf8EBAMCAgQwEgYDVR0TAQH/BAgwBgEB/wIBADBYBgNV -HSABAf8ETjBMMEoGC2CGSAGG+EUBBy8BMDswOQYIKwYBBQUHAgEWLWh0dHA6Ly93 -d3cudmVyaXNpZ24uY29tL3JlcG9zaXRvcnkvaW5kZXguaHRtbDCBlwYDVR0jBIGP -MIGMgBRW65FEhWPWcrOu1EWWC/eUDlRCpqFxpG8wbTELMAkGA1UEBhMCREUxEDAO -BgNVBAgTB0JhdmFyaWExITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2llcyBB -RzEMMAoGA1UECxMDQUlNMRswGQYDVQQDExJJRlggVFBNIEVLIFJvb3QgQ0GCAQMw -DQYJKoZIhvcNAQEFBQADggEBAFtqClQNBLOzcGZUpsBqlz3frzM45iiBpxosG1Re -IgoAgtIBEtl609TG51tmpm294KqpfKZVO+xNzovm8k/heGb0jmYf+q1ggrk2qT4v -Qy2jgE0jbP/P8WWq8NHC13uMcBUGPaka7yofEDDwz7TcduQyJVfG2pd1vflnzP0+ -iiJpfCk3CAQQnb+B7zsOp7jHNwpvHP+FhNwZaikaa0OdR/ML9da1sOOW3oJSTEjW -SMLuhaZHtcVgitvtOVvCI/aq47rNJku3xQ7c/s8FHnFzQQ+Q4TExbP20SrqQIlL/ -9sFAb7/nKYNauusakiF3pfvMrJOJigNfJyIcWaGfyyQtVVI= ------END CERTIFICATE-----`, - "IFX5": `-----BEGIN CERTIFICATE----- -MIIEnzCCA4egAwIBAgIEVuRoqzANBgkqhkiG9w0BAQUFADBtMQswCQYDVQQGEwJE -RTEQMA4GA1UECBMHQmF2YXJpYTEhMB8GA1UEChMYSW5maW5lb24gVGVjaG5vbG9n -aWVzIEFHMQwwCgYDVQQLEwNBSU0xGzAZBgNVBAMTEklGWCBUUE0gRUsgUm9vdCBD -QTAeFw0wOTEyMTExMDM4NDJaFw0yOTEyMTExMDM4NDJaMHcxCzAJBgNVBAYTAkRF -MQ8wDQYDVQQIEwZTYXhvbnkxITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2ll -cyBBRzEMMAoGA1UECxMDQUlNMSYwJAYDVQQDEx1JRlggVFBNIEVLIEludGVybWVk -aWF0ZSBDQSAwNTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL79zMCO -bjkg7gCWEuyGO49CisF/QrGoz9adW1FBuSW8U9IOlvWXNsvoasC1mhrsfkRRojuU -mWifxxxcVfOI9v1SbRfJ+i6lG21IcVe6ywLJdDliT+3vzvrb/2hU/XjCCMDWb/Pw -aZslV5iL4QEiKxvRIiWMYHW0MkkL7mzRBDVN/Vz3ZiL5Lpq7awiKuX9OXpS2a1wf -qSGAlm2TxjU884q9Ky85JJugn0Q/C3dc8aaFPKLHlRs6rIvN1l0LwB1b5EWPzTPJ -d9EhRPFJOAbJS66nSgX06Fl7eWB71ow6w/25otLQCbpy6OrF8wBVMtPMHqFb1c32 -PaaNzpCBnIU7vaMCAwEAAaOCATswggE3MB0GA1UdDgQWBBS7z3zBhCExZtq1vlOo -cBTd00jYzDAOBgNVHQ8BAf8EBAMCAgQwEgYDVR0TAQH/BAgwBgEB/wIBADBYBgNV -HSABAf8ETjBMMEoGC2CGSAGG+EUBBy8BMDswOQYIKwYBBQUHAgEWLWh0dHA6Ly93 -d3cudmVyaXNpZ24uY29tL3JlcG9zaXRvcnkvaW5kZXguaHRtbDCBlwYDVR0jBIGP -MIGMgBRW65FEhWPWcrOu1EWWC/eUDlRCpqFxpG8wbTELMAkGA1UEBhMCREUxEDAO -BgNVBAgTB0JhdmFyaWExITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2llcyBB -RzEMMAoGA1UECxMDQUlNMRswGQYDVQQDExJJRlggVFBNIEVLIFJvb3QgQ0GCAQMw -DQYJKoZIhvcNAQEFBQADggEBAHomNJtmFNtRJI2+s6ZwdzCTHXXIcR/T+N/lfPbE -hIUG4Kg+3uQMP7zBi22m3I3Kk9SXsjLqV5mnsQUGMGlF7jw5W5Q+d6NSJz4taw9D -2DsiUxE/i5vrjWiUaWxv2Eckd4MUexe5Qz8YSh4FPqLB8FZnAlgx2kfdzRIUjkMq -EgFK8ZRSUjXdczvsud68YPVMIZTxK0L8POGJ6RYiDrjTelprfZ4pKKZ79XwxwAIo -pG6emUEf+doRT0KoHoCHr9vvWCWKhojqlQ6jflPZcEsNBMbq5KHVN77vOU58OKx1 -56v3EaqrZenVFt8+n6h2NzhOmg2quQXIr0V9jEg8GAMehDs= ------END CERTIFICATE-----`, - "IFX8": `-----BEGIN CERTIFICATE----- -MIIEnzCCA4egAwIBAgIEfGoY6jANBgkqhkiG9w0BAQUFADBtMQswCQYDVQQGEwJE -RTEQMA4GA1UECBMHQmF2YXJpYTEhMB8GA1UEChMYSW5maW5lb24gVGVjaG5vbG9n -aWVzIEFHMQwwCgYDVQQLEwNBSU0xGzAZBgNVBAMTEklGWCBUUE0gRUsgUm9vdCBD -QTAeFw0xMjA3MTcwOTI0NTJaFw0zMDEwMTgyMzU5NTlaMHcxCzAJBgNVBAYTAkRF -MQ8wDQYDVQQIEwZTYXhvbnkxITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2ll -cyBBRzEMMAoGA1UECxMDQUlNMSYwJAYDVQQDEx1JRlggVFBNIEVLIEludGVybWVk -aWF0ZSBDQSAwODCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOJaIJu6 -r/betrMgWJ/JZ5j8ytoAA9RWq0cw7+W0e5L2kDLJMM288wYT+iEbfwx6sWSLAl7q -okXYDtTB9MFNhQ5ZWFLslFXbYigtXJxwANcSdPISTF1Czn6LLi1fu1EHddwCXFC8 -xaX0iGgQ9pZklvAy2ijK9BPHquWisisEiWZNRT9dCVylzOR3+p2YOC3ZrRmg7Bj+ -DkC7dltTTO6dPR+LNOFe01pJlpZdF4YHcu4EC10gRu0quZz1LtDZWFKezK7rg5Rj -LSAJbKOsGXjl6hQXMtADEX9Vlz1vItD21OYCNRsu6VdipiL0bl0aAio4BV3GMyjk -0gHnQwCk9k/YPU8CAwEAAaOCATswggE3MB0GA1UdDgQWBBRMS01kiQjkW/5aENNj -h6aIrsHPeDAOBgNVHQ8BAf8EBAMCAgQwEgYDVR0TAQH/BAgwBgEB/wIBADBYBgNV -HSABAf8ETjBMMEoGC2CGSAGG+EUBBy8BMDswOQYIKwYBBQUHAgEWLWh0dHA6Ly93 -d3cudmVyaXNpZ24uY29tL3JlcG9zaXRvcnkvaW5kZXguaHRtbDCBlwYDVR0jBIGP -MIGMgBRW65FEhWPWcrOu1EWWC/eUDlRCpqFxpG8wbTELMAkGA1UEBhMCREUxEDAO -BgNVBAgTB0JhdmFyaWExITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2llcyBB -RzEMMAoGA1UECxMDQUlNMRswGQYDVQQDExJJRlggVFBNIEVLIFJvb3QgQ0GCAQMw -DQYJKoZIhvcNAQEFBQADggEBALMiDyQ9WKH/eTI84Mk8KYk+TXXEwf+fhgeCvxOQ -G0FTSmOpJaNIzxWXr/gDbY3dO0ODjWRKYvhimZUuV+ckMA+wZX2C6o8g5njpWIOH -pSAa+W35ijArh0Zt3MASJ46avd+fnQGTdzT0hK46gx6n2KixLvaZsR3JtuwUFYlQ -wzmz/UsbBNEoPiR8p5E0Zf5GEGiTqkmBVYyS6XA34axpMMRHy0wI7AGs0gVihwUM -rr0iWOu+GAcrm11lcYzqJvuEkfenAF62ufA2Ktv+Ut2xiRC0jUIp73CeplAJsqBr -camV3pJn3qYPI5c1njMRYnoRFWQbrOR5ADWDQLFQPYRrJmg= ------END CERTIFICATE-----`, - "IFX15": `-----BEGIN CERTIFICATE----- -MIIEnzCCA4egAwIBAgIER3V5aDANBgkqhkiG9w0BAQUFADBtMQswCQYDVQQGEwJE -RTEQMA4GA1UECBMHQmF2YXJpYTEhMB8GA1UEChMYSW5maW5lb24gVGVjaG5vbG9n -aWVzIEFHMQwwCgYDVQQLEwNBSU0xGzAZBgNVBAMTEklGWCBUUE0gRUsgUm9vdCBD -QTAeFw0xMjExMTQxNDQzMzRaFw0zMDEwMTgyMzU5NTlaMHcxCzAJBgNVBAYTAkRF -MQ8wDQYDVQQIEwZTYXhvbnkxITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2ll -cyBBRzEMMAoGA1UECxMDQUlNMSYwJAYDVQQDEx1JRlggVFBNIEVLIEludGVybWVk -aWF0ZSBDQSAxNTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKS6pgcg -OQWSozVbMkdf9jZkpGdT4U735zs0skfpjoKK2CgpLMO/+oGKbObm/DQPRQO/oxvq -jJNBKz55QBgKd+MoQ6t+2J8mcQ91Nfwqnm1C4r+c4zezJ1Utk/KIYNqpFDAzefBA -/lK8IxQ6kmzxcIFE4skaFsSgkearSZGG6sA9A51yxwvs8yUrQF51ICEUM7wDb4cM -53utaFdm6p6m9UZGSmmrdTiemOkuuwtl8IUQXfuk9lFyQsACBTM95Hrts0IzI6hX -QeTwSL4JqyEnKP9vbtT4eXzWNycqSYBf0+Uo/HHZo9WuVDUaA4I9zcmD0qCvSOT0 -NAj4ifJ7SPGInU0CAwEAAaOCATswggE3MB0GA1UdDgQWBBR4pAnEV95pJvbfQsYR -TrflaptW5zAOBgNVHQ8BAf8EBAMCAgQwEgYDVR0TAQH/BAgwBgEB/wIBADBYBgNV -HSABAf8ETjBMMEoGC2CGSAGG+EUBBy8BMDswOQYIKwYBBQUHAgEWLWh0dHA6Ly93 -d3cudmVyaXNpZ24uY29tL3JlcG9zaXRvcnkvaW5kZXguaHRtbDCBlwYDVR0jBIGP -MIGMgBRW65FEhWPWcrOu1EWWC/eUDlRCpqFxpG8wbTELMAkGA1UEBhMCREUxEDAO -BgNVBAgTB0JhdmFyaWExITAfBgNVBAoTGEluZmluZW9uIFRlY2hub2xvZ2llcyBB -RzEMMAoGA1UECxMDQUlNMRswGQYDVQQDExJJRlggVFBNIEVLIFJvb3QgQ0GCAQMw -DQYJKoZIhvcNAQEFBQADggEBAAnZDdJZs5QgAXnl0Jo5sCqktZcwcK+V1+uhsqrT -Z7OJ9Ze1YJ9XB14KxRfmck7Erl5HVc6PtUcLnR0tuJKKKqm7dTe4sQEFYd5usjrW -KSG6y7BOH7AdonocILY9OIxuNwxMAqhK8LIjkkRCeOWSvCqLnaLtrP52C0fBkTTM -SWX7YnsutXEpwhro3Qsnm9hL9s3s/WoIuNKUcLFH/qWKztpxXnF0zip73gcZbwEy -1GPQQpYnxFJ2R2ab2RHlO+3Uf3FDxn+eRLXNl95ZZ6GE4OIIpKEg2urIiig0HmGA -ijO6JfJxT30H9QNsx78sjYs7pOfMw6DfiqJ8Fx82GcCUOyM= ------END CERTIFICATE-----`, - } - - trustedKeys := map[string]string{ - "ATM1": `-----BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5a+4yXtubUnGJPz7ZVjW -spGhe5Tr9BhrWQ9QOfDoVlkmi+tg2Gqc9qA9R39WhiiEmKuQ3+4XIvO+XFFrVCv+ -8YuEnBIIu46FEX1LBG7LnUJbkgAV0pzHMWOghLhDIGcGg/6kO9fH+7KcwfwNah+Z -Lkfbfis3cm09RlOG8RSq8LyK8Zc07QH2M7L/8PFnRRQ5MnAgW7vuk8h/M62TTy+y -DVuWl/jnh3vrKgVMoOyL/iM3EdFHIV+r/lJOI/HRAlkieCRGiJ1kJI4tQpUXiL+t -K2iB1yAxnqcSQzWWxlNuu6sAUV2tI+qMVM2o6eT1f/MM7+b4nmyuBrdOIO5dvTek -7wIDAQAB ------END PUBLIC KEY-----`, - "ATM10": `-----BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1HEeCn82r8Vrg64howvt -s/2Yj5yuXhEv7FwUaISo7rYFnAbstyMVGNsL24reRW7aiyj65iHEojx1Car3Jlu8 -hYfTqiagFmEK/qe8erEatwg5jFQ0GdK3a9Tw7nhYZjjpe98sRjL/DQlI5NiKClPF -4ZNqI418MGmzmPN/QNxRnKJAr5LTE8FZCMShm5V9ege72oLj4VfPuz29fQLBZWJA -2+NUy6gCpcUShejGfm9DTGBk0m3wruqyXuzKzJ4U0Xo5nTqp7ZV/JLbSWnTJxs72 -hZ4D1nbi0paPQgcK5FYbIwQ1WuEpN5QMfilsAZFbokQnQa+jX2Rzleoa0mURVEnG -TQIDAQAB ------END PUBLIC KEY-----`, - "ATM11": `-----BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqrS1Ei1VvLxVYWNv/s35 -aYmHa5MOnvQybgW/i1XuINZuPQqYNw02wrWRA5eft2ts+FkJDvbz6edtqH30Cjx+ -pmE9OvotY7O7rboruz2W2PpcQ0/inLUixNiq/A8giKRWJaTNsiF6VLNEWEe5sf3r -e6+C/ZQUfwupM56bU0JrIMxEgp8SCFguQsNwcq2txtr1ujgX4PN6DOet6BcrTpsY -vxKhQPbL/Tfl/kMqYVzqqyrBGgkg8+2FRxO6bVSJCwryrA37ZwkgJl3k/qibTFzw -JVfJnGaT57L/TUVJRwADtVN+oJFcQamR7N6VIuohx7fp7U8t8nrKhZpIwK405hLE -1wIDAQAB ------END PUBLIC KEY-----`, - "ATM12": `-----BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1R4fVBbUI7tsaRuS0VvH -TiouZ7L/HAokHIsozeLKamistnoCNKMyz40pwGenK8l0XnvJveoAlT+3tbKmmeo7 -iR1QP28shN8ggnObHZpBN2cPiySh0A8uYIEXY3sJMrNZ/h2MMbjYD2nUyreVpuj+ -mytSbvmB1eqcj9p4JBY1aqwXBrm0DqxZXJsVNBkjJ7c9kFy3ze8yccTFKx/wXe7v -PHgoWKA7RLtM2i/ppJdQgT/IubOrhZTyWPpvLQDpNf0p/SDmByw3/RzinPFlxUmA -eBzvTDwM7jEsZIUQGDZIBhifK45VLLrQiDTTOL8eVw9D8H0zn8AJu7cF9w9oYQj6 -fQIDAQAB ------END PUBLIC KEY-----`, - "ATM13": `-----BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwSvUzUQRjD3KyZMJu5CZ -sHVLqAN0mBT86nivjCV+RhHsR0uSU110NKjb2IHXM3fYaJlgvZRTAQJ3c8jPc0bV -tC0+521QKKt86OLi0+nrNT2QzLtrJgx6eRoYiu9se2F0u/zB+PHQ0R8qVOI1xw0W -FVK2w2+mRT3WN4Udp0Rn6LKPRXCq59JPfuD7hNBVmwp9uzj2TLp8ljMRSbChRjek -u9H4G+b2qa4wf2g9R5/Eqq5cMwYsD4357cuhlfqWQxD61J93ro2Hf5+30JrZF2yo -/TX5ocdQqnvLeape1KZGTDrikNXD9eIhR53yT4aBAK/RB8scsbwjn5tnoIBO0GAE -wwIDAQAB ------END PUBLIC KEY-----`, - "ATM2": `-----BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6e/oMMyv7NPlNKo9A7ls -wJDkE14LZGSsKiRyzyJe2qHCoBwsZEq3QV2w4ducngcOysRaczDd8Cku9Z332dbi -9Tq6RZapk/eL7mcBF/XBNu7Wft3PDRTzs8gpM3xFHo59+OAjeax3TE8yR6Phiipp -42uI9f184vQsgwzEWNz6kMUP5mwe3Hm9y8RlTzrpJAtVtW9w7LmoSeOHHgzsEGG9 -q5F2PkY6X0Ft9eDQaIOlTofkSHzvG2VLv8MJINMjnXrPnvF8dqG38lzAIvDfJKKx -E5MjY2aoFc1dfISQDv4sYx02b6jwfDl8pFCrwCzH7cWmIE0hD2BV2LpurURTi+kk -MQIDAQAB ------END PUBLIC KEY-----`, - "ATM3": `-----BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmFAUATJ/8xIeuFW0aKNZ -cwCtDLDOQoGIez+sg64EmJ+rEKNHfPQj7ee3UxiARWoLvmrMwMZFHXVuHb6Q6QUB -H2OmUZfhcBXm94ZbXrFQyDxosR3lU+JZu5JK0X76kZAQtiBI2/UkJMt0xRUm1P7p -InKnqk9HYw2HpwrCYZII78R2N8bfGJAXOpz1oOpI7jVHewtJY/gun1jgXuOwNW+1 -ouDaUrB/8t9m0lvsoeqduq0Nhvl4AL6kxVFp4sSX3gFuSORcbFP4hu7UMJy6g59d -bsgpulbltd2+HDqxEa4VPOe3IlC4iUso091vq+V49ThYOZ0TXFjk1dNdcTFuK2O8 -kQIDAQAB ------END PUBLIC KEY-----`, - "ATM4": `-----BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxtl1salu/2SXeqCGMtac -0GMCqx6Qeh4KtrviPfGVdObksuyGRPPuaW25/oYNGLlf2x/kDlknB2eZFMiW8otK -XV+xO50uFcxoTHXZ1wnMD8x6CgM0z0j3DQ5d0eu5sRRDd7GHYEpuvMj0x8pgkZk+ -C+Ux2hWlj8xEiEDH8q5wyP5AX92GkpoUAL0e4vUV7/cCEBcsLOs8Oq6rKzmig82k -sDiL/Tn/8TtsSmUAwT/FzM/gi79x0D1hHtXyLOFPDIrOy3d3cz5QMOSSLDHGjmoa -DBF0+rcBRJCCU2iBtfIMBevJO1IBUmj/EgerHWWaf5pNNJAL62eAeeaWKm5OaX6b -VQIDAQAB ------END PUBLIC KEY-----`, - "ATM5": `-----BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqg1FjhOQ/GsqgUL+WSBc -fYr3hkxxl1EBaCIqiolc1R5TmZabaHoCUIJmhwXfFGhFvhZrI0AcEqIYANLgY0ri -vn4h6vV+rrwtxM1X7X8hmT+AdvxL2p9lOCp7XNpQ2Rw+o/2JhuBSUv+opW7K6wPu -mwUpy4gL+dAozZyBjan5Co9sP5Yh3kdG3+ezRsfxf3CnS76NhjHglK9AWUdM1c6m -FGqTP+fU9ySTpoabrnDUzIcedu5OsMZa5L1LeLKHrqrbM3b995aU9RPrIQoO3x+B -Sau9Ab0d614zpD0TeWwjBT7Y5rIg14bIx7DiA+4kGRE5fHZtpdSWpgJmlkcObSSd -vQIDAQAB ------END PUBLIC KEY-----`, - "ATM6": `-----BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw9s9ykpgzH1Birz8JVmH -c/jXNSaFsDQYM9hcS3513P7arS+r/musmUqfdybY/GQ8+YqAA6IZq+xlGZ7WUEmx -vo/Hlnm/FQj3epZGD3ruApm+8dLV4Hvs4RjZCS8cfpkRZygh+nRdrZ3aAwZRjQbh -vl8mAJOQ2Rp9ANaZMzYjre7adkuqIFDa83nKgn4XkMIft+MthOvcMYmZtSL64gvA -NZ7PiryB2cMhS+0yAMGK/Oqm0ELIRk8wqAR/l3txRVxoQEqA9fBk2bvGNiWva92c -hxCLpEX9+CcZWvUeH6Up5a2EDxw8BgxE0L6sqjINWn2uN0x7jlKysg+XEyo7qUpM -RQIDAQAB ------END PUBLIC KEY-----`, - "ATM7": `-----BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlYRfDD3bMJB7w6Fl+Kez -oIaEkzz+2VCeF8v3ohsNnSKCgcx8uk7Seyp50bEtLB6vOzwgcM5WjFItKyYLZaHt -P43q3iHsvISjAGNcYGcQ3NrM4ia6pc2geVraupldPTdQFOQjwd+0P/Q2/RMbWY6g -+sbjIDtItEc1vhf6bI3TinT+bGxxXdR9B6qWgLNc/H31wsBNN2nPv1K4wE8MWfAV -7hcK2NoIc1zGEY+IiWPtXSu48zmvS2lxKWWYuiHBwCt5ns/U7M8XSjkaj7SbhD02 -yKwiMavu7SMAceSWWMBuhjgm9/zfMAPKO9weQixVCeuXspByefsekPuk5ohbWOS/ -bwIDAQAB ------END PUBLIC KEY-----`, - "ATM8": `-----BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAylXag4JmzoqaTK8eCcSj -DSOGRcrX8IK/fBawgEWKAgPy/yu+8FGXXK10XDeI1fmlAefDr7349Cn+v9/y+Mff -XIduKCqR5ZP9M1+fBk7k5l4x2SeC9NfIMG+c0yJ6m1kEmsSN04nlKk8foo54L7DY -+Kkjfh6EPxyzxsMDqqTrMifBThF2kqo5KUBDdBjIkOUH1dbLWGjEgUpKocCu2M41 -U7jmjToatkA+d3V+PyQRF4/lJkTYiv6Jy1Zl1qpEkLvR0qKrzoHkOij7zBpQ/46B -2BW1pARjU7AIp3NtfS5THL59mpXxpuyj6y2h0wxNVRkPZpnVA0ZWHgz9J4TcIgAN -PwIDAQAB ------END PUBLIC KEY-----`, - "ATM9": `-----BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxa0XBIlBj9t5bYB81Cea -mlV3I3rTathgyUn2VL7/wng2vK5x7BB3a1wjXt5k/uwR/M5tfIDOSjug/SdDfTWk -ZRe82Ij/oYJOytcrFzEzouIZVA7t/uKdXzRwz7dZ6LPnNVkp8GiWUDCDpTNNmnvi -eZcjqofajDcc0EC720NT+NqmkAJd0qYMs+i4TA2om2C2Lxpkq+YdJp2pJOCCQquC -wmLXB8OxrddjX4QW5mHzigx4fanC/GJcXuRQPXqLruHZlWmUqU7Sl6yZEluItHbB -ri4BxD3Q7eXH0sM3rZGUCLr3lMPXjGsfpogZT4zLr075QIxtwe5OUpnslU61c34X -BwIDAQAB ------END PUBLIC KEY-----`, - } - - cert, err := x509.ParseCertificate(ekcert) - if err != nil { - return fmt.Errorf("Unable to parse EKCert: %s", err) - } - - for vendor, certificate := range trustedCerts { - block, _ := pem.Decode([]byte(certificate)) - testcert, err := x509.ParseCertificate(block.Bytes) - if err != nil { - return fmt.Errorf("Unable to parse %s: %s", vendor, err) - } - err = testcert.CheckSignature(cert.SignatureAlgorithm, cert.RawTBSCertificate, cert.Signature) - if err == nil { - return nil - } - } - - for vendor, key := range trustedKeys { - block, _ := pem.Decode([]byte(key)) - pubkey, err := x509.ParsePKIXPublicKey(block.Bytes) - if err != nil { - return fmt.Errorf("Unable to parse %s: %s", vendor, err) - } - hashdata := sha1.Sum(cert.RawTBSCertificate[:]) - err = rsa.VerifyPKCS1v15(pubkey.(*rsa.PublicKey), crypto.SHA1, hashdata[:], cert.Signature) - if err == nil { - return nil - } - } - - return fmt.Errorf("No matching certificate found") -} - -// QuoteVerify verifies that a quote was genuinely provided by the TPM. It -// takes the quote data, quote validation blob, public half of the AIK, -// current PCR values and the nonce used in the original quote request. It -// then verifies that the validation block is a valid signature for the -// quote data, that the secrets are the same (in order to avoid replay -// attacks), and that the PCR values are the same. It returns an error if -// any stage of the validation fails. -func QuoteVerify(data []byte, validation []byte, aikpub []byte, pcrvalues [][]byte, secret []byte) error { - n := big.NewInt(0) - n.SetBytes(aikpub) - e := 65537 - - pKey := rsa.PublicKey{N: n, E: int(e)} - - dataHash := sha1.Sum(data[:]) - - err := rsa.VerifyPKCS1v15(&pKey, crypto.SHA1, dataHash[:], validation) - if err != nil { - return err - } - - pcrHash := data[8:28] - nonceHash := data[28:48] - - secretHash := sha1.Sum(secret[:]) - - if bytes.Equal(secretHash[:], nonceHash) == false { - return fmt.Errorf("Secret doesn't match") - } - - pcrComposite := []byte{0x00, 0x02, 0xff, 0xff, 0x00, 0x00, 0x01, 0x40} - for i := 0; i < 16; i++ { - pcrComposite = append(pcrComposite, pcrvalues[i]...) - } - pcrCompositeHash := sha1.Sum(pcrComposite[:]) - - if bytes.Equal(pcrCompositeHash[:], pcrHash) == false { - return fmt.Errorf("PCR values don't match") - } - - return nil -} - -// KeyVerify verifies that a key certification request was genuinely -// provided by the TPM. It takes the certification data, certification -// validation blob, the public half of the AIK, the public half of the key -// to be certified and the nonce used in the original quote request. It then -// verifies that the validation block is a valid signature for the -// certification data, that the certification data matches the certified key -// and that the secrets are the same (in order to avoid replay attacks). It -// returns an error if any stage of the validation fails. -func KeyVerify(data []byte, validation []byte, aikpub []byte, keypub []byte, secret []byte) error { - n := big.NewInt(0) - n.SetBytes(aikpub) - e := 65537 - - pKey := rsa.PublicKey{N: n, E: int(e)} - - dataHash := sha1.Sum(data[:]) - - err := rsa.VerifyPKCS1v15(&pKey, crypto.SHA1, dataHash[:], validation) - if err != nil { - return err - } - - keyHash := data[43:63] - nonceHash := data[63:83] - - secretHash := sha1.Sum(secret[:]) - - if bytes.Equal(secretHash[:], nonceHash) == false { - return fmt.Errorf("Secret doesn't match") - } - - certHash := sha1.Sum(keypub[:]) - - if bytes.Equal(certHash[:], keyHash) == false { - return fmt.Errorf("Key doesn't match") - } - - return nil -} diff --git a/Godeps/_workspace/src/github.com/coreos/ioprogress/LICENSE b/Godeps/_workspace/src/github.com/coreos/ioprogress/LICENSE deleted file mode 100644 index 2298515904..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/ioprogress/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 Mitchell Hashimoto - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/Godeps/_workspace/src/github.com/coreos/ioprogress/README.md b/Godeps/_workspace/src/github.com/coreos/ioprogress/README.md deleted file mode 100644 index 3d291e9d14..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/ioprogress/README.md +++ /dev/null @@ -1,42 +0,0 @@ -# ioprogress - -ioprogress is a Go (golang) library with implementations of `io.Reader` -and `io.Writer` that draws progress bars. The primary use case for these -are for CLI applications but alternate progress bar writers can be supplied -for alternate environments. - -## Example - -![Progress](http://g.recordit.co/GO5HxT16QH.gif) - -## Installation - -Standard `go get`: - -``` -$ go get github.com/mitchellh/ioprogress -``` - -## Usage - -Here is an example of outputting a basic progress bar to the CLI as -we're "downloading" from some other `io.Reader` (perhaps from a network -connection): - -```go -// Imagine this came from some external source, such as a network connection, -// and that we have the full size of it, such as from a Content-Length HTTP -// header. -var r io.Reader - -// Create the progress reader -progressR := &ioprogress.Reader{ - Reader: r, - Size: rSize, -} - -// Copy all of the reader to some local file f. As it copies, the -// progressR will write progress to the terminal on os.Stdout. This is -// customizable. -io.Copy(f, progressR) -``` diff --git a/Godeps/_workspace/src/github.com/coreos/ioprogress/draw.go b/Godeps/_workspace/src/github.com/coreos/ioprogress/draw.go deleted file mode 100644 index b659be5b67..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/ioprogress/draw.go +++ /dev/null @@ -1,132 +0,0 @@ -package ioprogress - -import ( - "fmt" - "io" - "os" - "strings" - - "golang.org/x/crypto/ssh/terminal" -) - -// DrawFunc is the callback type for drawing progress. -type DrawFunc func(int64, int64) error - -// DrawTextFormatFunc is a callback used by DrawFuncs that draw text in -// order to format the text into some more human friendly format. -type DrawTextFormatFunc func(int64, int64) string - -var defaultDrawFunc DrawFunc - -func init() { - defaultDrawFunc = DrawTerminal(os.Stdout) -} - -// isTerminal returns True when w is going to a tty, and false otherwise. -func isTerminal(w io.Writer) bool { - if f, ok := w.(*os.File); ok { - return terminal.IsTerminal(int(f.Fd())) - } - return false -} - -// DrawTerminal returns a DrawFunc that draws a progress bar to an io.Writer -// that is assumed to be a terminal (and therefore respects carriage returns). -func DrawTerminal(w io.Writer) DrawFunc { - return DrawTerminalf(w, func(progress, total int64) string { - return fmt.Sprintf("%d/%d", progress, total) - }) -} - -// DrawTerminalf returns a DrawFunc that draws a progress bar to an io.Writer -// that is formatted with the given formatting function. -func DrawTerminalf(w io.Writer, f DrawTextFormatFunc) DrawFunc { - var maxLength int - - return func(progress, total int64) error { - if progress == -1 && total == -1 { - _, err := fmt.Fprintf(w, "\n") - return err - } - - // Make sure we pad it to the max length we've ever drawn so that - // we don't have trailing characters. - line := f(progress, total) - if len(line) < maxLength { - line = fmt.Sprintf( - "%s%s", - line, - strings.Repeat(" ", maxLength-len(line))) - } - maxLength = len(line) - - terminate := "\r" - if !isTerminal(w) { - terminate = "\n" - } - _, err := fmt.Fprint(w, line+terminate) - return err - } -} - -var byteUnits = []string{"B", "KB", "MB", "GB", "TB", "PB"} - -// DrawTextFormatBytes is a DrawTextFormatFunc that formats the progress -// and total into human-friendly byte formats. -func DrawTextFormatBytes(progress, total int64) string { - return fmt.Sprintf("%s/%s", ByteUnitStr(progress), ByteUnitStr(total)) -} - -// DrawTextFormatBar returns a DrawTextFormatFunc that draws a progress -// bar with the given width (in characters). This can be used in conjunction -// with another DrawTextFormatFunc to create a progress bar with bytes, for -// example: -// -// bar := DrawTextFormatBar(20) -// func(progress, total int64) string { -// return fmt.Sprintf( -// "%s %s", -// bar(progress, total), -// DrawTextFormatBytes(progress, total)) -// } -// -func DrawTextFormatBar(width int64) DrawTextFormatFunc { - return DrawTextFormatBarForW(width, nil) -} - -// DrawTextFormatBarForW returns a DrawTextFormatFunc as described in the docs -// for DrawTextFormatBar, however if the io.Writer passed in is not a tty then -// the returned function will always return "". -func DrawTextFormatBarForW(width int64, w io.Writer) DrawTextFormatFunc { - if w != nil && !isTerminal(w) { - return func(progress, total int64) string { - return "" - } - } - - width -= 2 - - return func(progress, total int64) string { - current := int64((float64(progress) / float64(total)) * float64(width)) - return fmt.Sprintf( - "[%s%s]", - strings.Repeat("=", int(current)), - strings.Repeat(" ", int(width-current))) - } -} - -// ByteUnitStr pretty prints a number of bytes. -func ByteUnitStr(n int64) string { - var unit string - size := float64(n) - for i := 1; i < len(byteUnits); i++ { - if size < 1000 { - unit = byteUnits[i-1] - break - } - - size = size / 1000 - } - - return fmt.Sprintf("%.3g %s", size, unit) -} diff --git a/Godeps/_workspace/src/github.com/coreos/ioprogress/reader.go b/Godeps/_workspace/src/github.com/coreos/ioprogress/reader.go deleted file mode 100644 index 7d52731e2d..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/ioprogress/reader.go +++ /dev/null @@ -1,107 +0,0 @@ -package ioprogress - -import ( - "io" - "time" -) - -// Reader is an implementation of io.Reader that draws the progress of -// reading some data. -type Reader struct { - // Reader is the underlying reader to read from - Reader io.Reader - - // Size is the total size of the data coming out of the reader. - Size int64 - - // DrawFunc is the callback to invoke to draw the progress bar. By - // default, this will be DrawTerminal(os.Stdout). - // - // DrawInterval is the minimum time to wait between reads to update the - // progress bar. - DrawFunc DrawFunc - DrawInterval time.Duration - - progress int64 - lastDraw time.Time -} - -// Read reads from the underlying reader and invokes the DrawFunc if -// appropriate. The DrawFunc is executed when there is data that is -// read (progress is made) and at least DrawInterval time has passed. -func (r *Reader) Read(p []byte) (int, error) { - // If we haven't drawn before, initialize the progress bar - if r.lastDraw.IsZero() { - r.initProgress() - } - - // Read from the underlying source - n, err := r.Reader.Read(p) - - // Always increment the progress even if there was an error - r.progress += int64(n) - - // If we don't have any errors, then draw the progress. If we are - // at the end of the data, then finish the progress. - if err == nil { - // Only draw if we read data or we've never read data before (to - // initialize the progress bar). - if n > 0 { - r.drawProgress() - } - } - if err == io.EOF { - r.finishProgress() - } - - return n, err -} - -func (r *Reader) drawProgress() { - // If we've drawn before, then make sure that the draw interval - // has passed before we draw again. - interval := r.DrawInterval - if interval == 0 { - interval = time.Second - } - if !r.lastDraw.IsZero() { - nextDraw := r.lastDraw.Add(interval) - if time.Now().Before(nextDraw) { - return - } - } - - // Draw - f := r.drawFunc() - f(r.progress, r.Size) - - // Record this draw so that we don't draw again really quickly - r.lastDraw = time.Now() -} - -func (r *Reader) finishProgress() { - f := r.drawFunc() - f(r.progress, r.Size) - - // Print a newline - f(-1, -1) - - // Reset lastDraw so we don't finish again - var zeroDraw time.Time - r.lastDraw = zeroDraw -} - -func (r *Reader) initProgress() { - var zeroDraw time.Time - r.lastDraw = zeroDraw - r.drawProgress() - r.lastDraw = zeroDraw -} - -func (r *Reader) drawFunc() DrawFunc { - if r.DrawFunc == nil { - return defaultDrawFunc - } - - return r.DrawFunc -} diff --git a/Godeps/_workspace/src/github.com/coreos/pkg/LICENSE b/Godeps/_workspace/src/github.com/coreos/pkg/LICENSE deleted file mode 100644 index e06d208186..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/pkg/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor 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, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - diff --git a/Godeps/_workspace/src/github.com/coreos/pkg/NOTICE b/Godeps/_workspace/src/github.com/coreos/pkg/NOTICE deleted file mode 100644 index b39ddfa5cb..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/pkg/NOTICE +++ /dev/null @@ -1,5 +0,0 @@ -CoreOS Project -Copyright 2014 CoreOS, Inc - -This product includes software developed at CoreOS, Inc. -(http://www.coreos.com/). diff --git a/Godeps/_workspace/src/github.com/coreos/pkg/dlopen/dlopen.go b/Godeps/_workspace/src/github.com/coreos/pkg/dlopen/dlopen.go deleted file mode 100644 index 23774f612e..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/pkg/dlopen/dlopen.go +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package dlopen provides some convenience functions to dlopen a library and -// get its symbols. -package dlopen - -// #cgo LDFLAGS: -ldl -// #include -// #include -import "C" -import ( - "errors" - "fmt" - "unsafe" -) - -var ErrSoNotFound = errors.New("unable to open a handle to the library") - -// LibHandle represents an open handle to a library (.so) -type LibHandle struct { - Handle unsafe.Pointer - Libname string -} - -// GetHandle tries to get a handle to a library (.so), attempting to access it -// by the names specified in libs and returning the first that is successfully -// opened. Callers are responsible for closing the handler. If no library can -// be successfully opened, an error is returned. -func GetHandle(libs []string) (*LibHandle, error) { - for _, name := range libs { - libname := C.CString(name) - defer C.free(unsafe.Pointer(libname)) - handle := C.dlopen(libname, C.RTLD_LAZY) - if handle != nil { - h := &LibHandle{ - Handle: handle, - Libname: name, - } - return h, nil - } - } - return nil, ErrSoNotFound -} - -// GetSymbolPointer takes a symbol name and returns a pointer to the symbol. -func (l *LibHandle) GetSymbolPointer(symbol string) (unsafe.Pointer, error) { - sym := C.CString(symbol) - defer C.free(unsafe.Pointer(sym)) - - C.dlerror() - p := C.dlsym(l.Handle, sym) - e := C.dlerror() - if e != nil { - return nil, fmt.Errorf("error resolving symbol %q: %v", symbol, errors.New(C.GoString(e))) - } - - return p, nil -} - -// Close closes a LibHandle. -func (l *LibHandle) Close() error { - C.dlerror() - C.dlclose(l.Handle) - e := C.dlerror() - if e != nil { - return fmt.Errorf("error closing %v: %v", l.Libname, errors.New(C.GoString(e))) - } - - return nil -} diff --git a/Godeps/_workspace/src/github.com/coreos/pkg/dlopen/dlopen_example.go b/Godeps/_workspace/src/github.com/coreos/pkg/dlopen/dlopen_example.go deleted file mode 100644 index 48a660104f..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/pkg/dlopen/dlopen_example.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2015 CoreOS, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// +build linux - -package dlopen - -// #include -// #include -// -// int -// my_strlen(void *f, const char *s) -// { -// size_t (*strlen)(const char *); -// -// strlen = (size_t (*)(const char *))f; -// return strlen(s); -// } -import "C" - -import ( - "fmt" - "unsafe" -) - -func strlen(libs []string, s string) (int, error) { - h, err := GetHandle(libs) - if err != nil { - return -1, fmt.Errorf(`couldn't get a handle to the library: %v`, err) - } - defer h.Close() - - f := "strlen" - cs := C.CString(s) - defer C.free(unsafe.Pointer(cs)) - - strlen, err := h.GetSymbolPointer(f) - if err != nil { - return -1, fmt.Errorf(`couldn't get symbol %q: %v`, f, err) - } - - len := C.my_strlen(strlen, cs) - - return int(len), nil -} diff --git a/Godeps/_workspace/src/github.com/coreos/pkg/progressutil/iocopy.go b/Godeps/_workspace/src/github.com/coreos/pkg/progressutil/iocopy.go deleted file mode 100644 index 04cd0dfa30..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/pkg/progressutil/iocopy.go +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright 2016 CoreOS Inc -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package progressutil - -import ( - "errors" - "fmt" - "io" - "sync" - "time" -) - -var ( - ErrAlreadyStarted = errors.New("cannot add copies after PrintAndWait has been called") -) - -type copyReader struct { - reader io.Reader - current int64 - total int64 - pb *ProgressBar -} - -func (cr *copyReader) Read(p []byte) (int, error) { - n, err := cr.reader.Read(p) - cr.current += int64(n) - err1 := cr.updateProgressBar() - if err == nil { - err = err1 - } - return n, err -} - -func (cr *copyReader) updateProgressBar() error { - cr.pb.SetPrintAfter(cr.formattedProgress()) - - progress := float64(cr.current) / float64(cr.total) - if progress > 1 { - progress = 1 - } - return cr.pb.SetCurrentProgress(progress) -} - -// NewCopyProgressPrinter returns a new CopyProgressPrinter -func NewCopyProgressPrinter() *CopyProgressPrinter { - return &CopyProgressPrinter{results: make(chan error), cancel: make(chan struct{})} -} - -// CopyProgressPrinter will perform an arbitrary number of io.Copy calls, while -// continually printing the progress of each copy. -type CopyProgressPrinter struct { - results chan error - cancel chan struct{} - - // `lock` mutex protects all fields below it in CopyProgressPrinter struct - lock sync.Mutex - readers []*copyReader - started bool - pbp *ProgressBarPrinter -} - -// AddCopy adds a copy for this CopyProgressPrinter to perform. An io.Copy call -// will be made to copy bytes from reader to dest, and name and size will be -// used to label the progress bar and display how much progress has been made. -// If size is 0, the total size of the reader is assumed to be unknown. -// AddCopy can only be called before PrintAndWait; otherwise, ErrAlreadyStarted -// will be returned. -func (cpp *CopyProgressPrinter) AddCopy(reader io.Reader, name string, size int64, dest io.Writer) error { - cpp.lock.Lock() - defer cpp.lock.Unlock() - - if cpp.started { - return ErrAlreadyStarted - } - if cpp.pbp == nil { - cpp.pbp = &ProgressBarPrinter{} - cpp.pbp.PadToBeEven = true - } - - cr := ©Reader{ - reader: reader, - current: 0, - total: size, - pb: cpp.pbp.AddProgressBar(), - } - cr.pb.SetPrintBefore(name) - cr.pb.SetPrintAfter(cr.formattedProgress()) - - cpp.readers = append(cpp.readers, cr) - - go func() { - _, err := io.Copy(dest, cr) - select { - case <-cpp.cancel: - return - case cpp.results <- err: - return - } - }() - return nil -} - -// PrintAndWait will print the progress for each copy operation added with -// AddCopy to printTo every printInterval. This will continue until every added -// copy is finished, or until cancel is written to. -// PrintAndWait may only be called once; any subsequent calls will immediately -// return ErrAlreadyStarted. After PrintAndWait has been called, no more -// copies may be added to the CopyProgressPrinter. -func (cpp *CopyProgressPrinter) PrintAndWait(printTo io.Writer, printInterval time.Duration, cancel chan struct{}) error { - cpp.lock.Lock() - if cpp.started { - cpp.lock.Unlock() - return ErrAlreadyStarted - } - cpp.started = true - cpp.lock.Unlock() - - n := len(cpp.readers) - if n == 0 { - // Nothing to do. - return nil - } - - defer close(cpp.cancel) - t := time.NewTicker(printInterval) - allDone := false - for i := 0; i < n; { - select { - case <-cancel: - return nil - case <-t.C: - _, err := cpp.pbp.Print(printTo) - if err != nil { - return err - } - case err := <-cpp.results: - i++ - // Once completion is signaled, further on this just drains - // (unlikely) errors from the channel. - if err == nil && !allDone { - allDone, err = cpp.pbp.Print(printTo) - } - if err != nil { - return err - } - } - } - return nil -} - -func (cr *copyReader) formattedProgress() string { - var totalStr string - if cr.total == 0 { - totalStr = "?" - } else { - totalStr = ByteUnitStr(cr.total) - } - return fmt.Sprintf("%s / %s", ByteUnitStr(cr.current), totalStr) -} - -var byteUnits = []string{"B", "KB", "MB", "GB", "TB", "PB"} - -// ByteUnitStr pretty prints a number of bytes. -func ByteUnitStr(n int64) string { - var unit string - size := float64(n) - for i := 1; i < len(byteUnits); i++ { - if size < 1000 { - unit = byteUnits[i-1] - break - } - - size = size / 1000 - } - - return fmt.Sprintf("%.3g %s", size, unit) -} diff --git a/Godeps/_workspace/src/github.com/coreos/pkg/progressutil/progressbar.go b/Godeps/_workspace/src/github.com/coreos/pkg/progressutil/progressbar.go deleted file mode 100644 index 224c124acd..0000000000 --- a/Godeps/_workspace/src/github.com/coreos/pkg/progressutil/progressbar.go +++ /dev/null @@ -1,256 +0,0 @@ -// Copyright 2016 CoreOS Inc -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package progressutil - -import ( - "fmt" - "io" - "os" - "strings" - "sync" - - "golang.org/x/crypto/ssh/terminal" -) - -var ( - // ErrorProgressOutOfBounds is returned if the progress is set to a value - // not between 0 and 1. - ErrorProgressOutOfBounds = fmt.Errorf("progress is out of bounds (0 to 1)") - - // ErrorNoBarsAdded is returned when no progress bars have been added to a - // ProgressBarPrinter before PrintAndWait is called. - ErrorNoBarsAdded = fmt.Errorf("AddProgressBar hasn't been called yet") -) - -// ProgressBar represents one progress bar in a ProgressBarPrinter. Should not -// be created directly, use the AddProgressBar on a ProgressBarPrinter to -// create these. -type ProgressBar struct { - lock sync.Mutex - - currentProgress float64 - printBefore string - printAfter string - done bool -} - -func (pb *ProgressBar) clone() *ProgressBar { - pb.lock.Lock() - pbClone := &ProgressBar{ - currentProgress: pb.currentProgress, - printBefore: pb.printBefore, - printAfter: pb.printAfter, - done: pb.done, - } - pb.lock.Unlock() - return pbClone -} - -func (pb *ProgressBar) GetCurrentProgress() float64 { - pb.lock.Lock() - val := pb.currentProgress - pb.lock.Unlock() - return val -} - -// SetCurrentProgress sets the progress of this ProgressBar. The progress must -// be between 0 and 1 inclusive. -func (pb *ProgressBar) SetCurrentProgress(progress float64) error { - if progress < 0 || progress > 1 { - return ErrorProgressOutOfBounds - } - pb.lock.Lock() - pb.currentProgress = progress - pb.lock.Unlock() - return nil -} - -// GetDone returns whether or not this progress bar is done -func (pb *ProgressBar) GetDone() bool { - pb.lock.Lock() - val := pb.done - pb.lock.Unlock() - return val -} - -// SetDone sets whether or not this progress bar is done -func (pb *ProgressBar) SetDone(val bool) { - pb.lock.Lock() - pb.done = val - pb.lock.Unlock() -} - -// GetPrintBefore gets the text printed on the line before the progress bar. -func (pb *ProgressBar) GetPrintBefore() string { - pb.lock.Lock() - val := pb.printBefore - pb.lock.Unlock() - return val -} - -// SetPrintBefore sets the text printed on the line before the progress bar. -func (pb *ProgressBar) SetPrintBefore(before string) { - pb.lock.Lock() - pb.printBefore = before - pb.lock.Unlock() -} - -// GetPrintAfter gets the text printed on the line after the progress bar. -func (pb *ProgressBar) GetPrintAfter() string { - pb.lock.Lock() - val := pb.printAfter - pb.lock.Unlock() - return val -} - -// SetPrintAfter sets the text printed on the line after the progress bar. -func (pb *ProgressBar) SetPrintAfter(after string) { - pb.lock.Lock() - pb.printAfter = after - pb.lock.Unlock() -} - -// ProgressBarPrinter will print out the progress of some number of -// ProgressBars. -type ProgressBarPrinter struct { - lock sync.Mutex - - // DisplayWidth can be set to influence how large the progress bars are. - // The bars will be scaled to attempt to produce lines of this number of - // characters, but lines of different lengths may still be printed. When - // this value is 0 (aka unset), 80 character columns are assumed. - DisplayWidth int - // PadToBeEven, when set to true, will make Print pad the printBefore text - // with trailing spaces and the printAfter text with leading spaces to make - // the progress bars the same length. - PadToBeEven bool - numLinesInLastPrint int - progressBars []*ProgressBar - maxBefore int - maxAfter int -} - -// AddProgressBar will create a new ProgressBar, register it with this -// ProgressBarPrinter, and return it. This must be called at least once before -// PrintAndWait is called. -func (pbp *ProgressBarPrinter) AddProgressBar() *ProgressBar { - pb := &ProgressBar{} - pbp.lock.Lock() - pbp.progressBars = append(pbp.progressBars, pb) - pbp.lock.Unlock() - return pb -} - -// Print will print out progress information for each ProgressBar that has been -// added to this ProgressBarPrinter. The progress will be written to printTo, -// and if printTo is a terminal it will draw progress bars. AddProgressBar -// must be called at least once before Print is called. If printing to a -// terminal, all draws after the first one will move the cursor up to draw over -// the previously printed bars. -func (pbp *ProgressBarPrinter) Print(printTo io.Writer) (bool, error) { - pbp.lock.Lock() - var bars []*ProgressBar - for _, bar := range pbp.progressBars { - bars = append(bars, bar.clone()) - } - numColumns := pbp.DisplayWidth - pbp.lock.Unlock() - - if len(bars) == 0 { - return false, ErrorNoBarsAdded - } - - if numColumns == 0 { - numColumns = 80 - } - - if isTerminal(printTo) { - moveCursorUp(printTo, pbp.numLinesInLastPrint) - } - - for _, bar := range bars { - beforeSize := len(bar.GetPrintBefore()) - afterSize := len(bar.GetPrintAfter()) - if beforeSize > pbp.maxBefore { - pbp.maxBefore = beforeSize - } - if afterSize > pbp.maxAfter { - pbp.maxAfter = afterSize - } - } - - allDone := true - for _, bar := range bars { - if isTerminal(printTo) { - bar.printToTerminal(printTo, numColumns, pbp.PadToBeEven, pbp.maxBefore, pbp.maxAfter) - } else { - bar.printToNonTerminal(printTo) - } - allDone = allDone && bar.GetCurrentProgress() == 1 - } - - pbp.numLinesInLastPrint = len(bars) - - return allDone, nil -} - -// moveCursorUp moves the cursor up numLines in the terminal -func moveCursorUp(printTo io.Writer, numLines int) { - if numLines > 0 { - fmt.Fprintf(printTo, "\033[%dA", numLines) - } -} - -func (pb *ProgressBar) printToTerminal(printTo io.Writer, numColumns int, padding bool, maxBefore, maxAfter int) { - before := pb.GetPrintBefore() - after := pb.GetPrintAfter() - - if padding { - before = before + strings.Repeat(" ", maxBefore-len(before)) - after = strings.Repeat(" ", maxAfter-len(after)) + after - } - - progressBarSize := numColumns - (len(fmt.Sprintf("%s [] %s", before, after))) - progressBar := "" - if progressBarSize > 0 { - currentProgress := int(pb.GetCurrentProgress() * float64(progressBarSize)) - progressBar = fmt.Sprintf("[%s%s] ", - strings.Repeat("=", currentProgress), - strings.Repeat(" ", progressBarSize-currentProgress)) - } else { - // If we can't fit the progress bar, better to not pad the before/after. - before = pb.GetPrintBefore() - after = pb.GetPrintAfter() - } - - fmt.Fprintf(printTo, "%s %s%s\n", before, progressBar, after) -} - -func (pb *ProgressBar) printToNonTerminal(printTo io.Writer) { - if !pb.GetDone() { - fmt.Fprintf(printTo, "%s %s\n", pb.printBefore, pb.printAfter) - if pb.GetCurrentProgress() == 1 { - pb.SetDone(true) - } - } -} - -// isTerminal returns True when w is going to a tty, and false otherwise. -func isTerminal(w io.Writer) bool { - if f, ok := w.(*os.File); ok { - return terminal.IsTerminal(int(f.Fd())) - } - return false -} diff --git a/Godeps/_workspace/src/github.com/cpuguy83/go-md2man/LICENSE.md b/Godeps/_workspace/src/github.com/cpuguy83/go-md2man/LICENSE.md deleted file mode 100644 index 1cade6cef6..0000000000 --- a/Godeps/_workspace/src/github.com/cpuguy83/go-md2man/LICENSE.md +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 Brian Goff - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/Godeps/_workspace/src/github.com/cpuguy83/go-md2man/md2man/md2man.go b/Godeps/_workspace/src/github.com/cpuguy83/go-md2man/md2man/md2man.go deleted file mode 100644 index 8f44fa1550..0000000000 --- a/Godeps/_workspace/src/github.com/cpuguy83/go-md2man/md2man/md2man.go +++ /dev/null @@ -1,19 +0,0 @@ -package md2man - -import ( - "github.com/russross/blackfriday" -) - -func Render(doc []byte) []byte { - renderer := RoffRenderer(0) - extensions := 0 - extensions |= blackfriday.EXTENSION_NO_INTRA_EMPHASIS - extensions |= blackfriday.EXTENSION_TABLES - extensions |= blackfriday.EXTENSION_FENCED_CODE - extensions |= blackfriday.EXTENSION_AUTOLINK - extensions |= blackfriday.EXTENSION_SPACE_HEADERS - extensions |= blackfriday.EXTENSION_FOOTNOTES - extensions |= blackfriday.EXTENSION_TITLEBLOCK - - return blackfriday.Markdown(doc, renderer, extensions) -} diff --git a/Godeps/_workspace/src/github.com/cpuguy83/go-md2man/md2man/roff.go b/Godeps/_workspace/src/github.com/cpuguy83/go-md2man/md2man/roff.go deleted file mode 100644 index 4478786b7b..0000000000 --- a/Godeps/_workspace/src/github.com/cpuguy83/go-md2man/md2man/roff.go +++ /dev/null @@ -1,269 +0,0 @@ -package md2man - -import ( - "bytes" - "fmt" - "html" - "strings" - - "github.com/russross/blackfriday" -) - -type roffRenderer struct{} - -func RoffRenderer(flags int) blackfriday.Renderer { - return &roffRenderer{} -} - -func (r *roffRenderer) GetFlags() int { - return 0 -} - -func (r *roffRenderer) TitleBlock(out *bytes.Buffer, text []byte) { - out.WriteString(".TH ") - - splitText := bytes.Split(text, []byte("\n")) - for i, line := range splitText { - line = bytes.TrimPrefix(line, []byte("% ")) - if i == 0 { - line = bytes.Replace(line, []byte("("), []byte("\" \""), 1) - line = bytes.Replace(line, []byte(")"), []byte("\" \""), 1) - } - line = append([]byte("\""), line...) - line = append(line, []byte("\" ")...) - out.Write(line) - } - - out.WriteString(" \"\"\n") -} - -func (r *roffRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string) { - out.WriteString("\n.PP\n.RS\n\n.nf\n") - escapeSpecialChars(out, text) - out.WriteString("\n.fi\n.RE\n") -} - -func (r *roffRenderer) BlockQuote(out *bytes.Buffer, text []byte) { - out.WriteString("\n.PP\n.RS\n") - out.Write(text) - out.WriteString("\n.RE\n") -} - -func (r *roffRenderer) BlockHtml(out *bytes.Buffer, text []byte) { - out.Write(text) -} - -func (r *roffRenderer) Header(out *bytes.Buffer, text func() bool, level int, id string) { - marker := out.Len() - - switch { - case marker == 0: - // This is the doc header - out.WriteString(".TH ") - case level == 1: - out.WriteString("\n\n.SH ") - case level == 2: - out.WriteString("\n.SH ") - default: - out.WriteString("\n.SS ") - } - - if !text() { - out.Truncate(marker) - return - } -} - -func (r *roffRenderer) HRule(out *bytes.Buffer) { - out.WriteString("\n.ti 0\n\\l'\\n(.lu'\n") -} - -func (r *roffRenderer) List(out *bytes.Buffer, text func() bool, flags int) { - marker := out.Len() - out.WriteString(".IP ") - if flags&blackfriday.LIST_TYPE_ORDERED != 0 { - out.WriteString("\\(bu 2") - } else { - out.WriteString("\\n+[step" + string(flags) + "]") - } - out.WriteString("\n") - if !text() { - out.Truncate(marker) - return - } - -} - -func (r *roffRenderer) ListItem(out *bytes.Buffer, text []byte, flags int) { - out.WriteString("\n\\item ") - out.Write(text) -} - -func (r *roffRenderer) Paragraph(out *bytes.Buffer, text func() bool) { - marker := out.Len() - out.WriteString("\n.PP\n") - if !text() { - out.Truncate(marker) - return - } - if marker != 0 { - out.WriteString("\n") - } -} - -// TODO: This might now work -func (r *roffRenderer) Table(out *bytes.Buffer, header []byte, body []byte, columnData []int) { - out.WriteString(".TS\nallbox;\n") - - out.Write(header) - out.Write(body) - out.WriteString("\n.TE\n") -} - -func (r *roffRenderer) TableRow(out *bytes.Buffer, text []byte) { - if out.Len() > 0 { - out.WriteString("\n") - } - out.Write(text) - out.WriteString("\n") -} - -func (r *roffRenderer) TableHeaderCell(out *bytes.Buffer, text []byte, align int) { - if out.Len() > 0 { - out.WriteString(" ") - } - out.Write(text) - out.WriteString(" ") -} - -// TODO: This is probably broken -func (r *roffRenderer) TableCell(out *bytes.Buffer, text []byte, align int) { - if out.Len() > 0 { - out.WriteString("\t") - } - out.Write(text) - out.WriteString("\t") -} - -func (r *roffRenderer) Footnotes(out *bytes.Buffer, text func() bool) { - -} - -func (r *roffRenderer) FootnoteItem(out *bytes.Buffer, name, text []byte, flags int) { - -} - -func (r *roffRenderer) AutoLink(out *bytes.Buffer, link []byte, kind int) { - out.WriteString("\n\\[la]") - out.Write(link) - out.WriteString("\\[ra]") -} - -func (r *roffRenderer) CodeSpan(out *bytes.Buffer, text []byte) { - out.WriteString("\\fB\\fC") - escapeSpecialChars(out, text) - out.WriteString("\\fR") -} - -func (r *roffRenderer) DoubleEmphasis(out *bytes.Buffer, text []byte) { - out.WriteString("\\fB") - out.Write(text) - out.WriteString("\\fP") -} - -func (r *roffRenderer) Emphasis(out *bytes.Buffer, text []byte) { - out.WriteString("\\fI") - out.Write(text) - out.WriteString("\\fP") -} - -func (r *roffRenderer) Image(out *bytes.Buffer, link []byte, title []byte, alt []byte) { -} - -func (r *roffRenderer) LineBreak(out *bytes.Buffer) { - out.WriteString("\n.br\n") -} - -func (r *roffRenderer) Link(out *bytes.Buffer, link []byte, title []byte, content []byte) { - r.AutoLink(out, link, 0) -} - -func (r *roffRenderer) RawHtmlTag(out *bytes.Buffer, tag []byte) { - out.Write(tag) -} - -func (r *roffRenderer) TripleEmphasis(out *bytes.Buffer, text []byte) { - out.WriteString("\\s+2") - out.Write(text) - out.WriteString("\\s-2") -} - -func (r *roffRenderer) StrikeThrough(out *bytes.Buffer, text []byte) { -} - -func (r *roffRenderer) FootnoteRef(out *bytes.Buffer, ref []byte, id int) { - -} - -func (r *roffRenderer) Entity(out *bytes.Buffer, entity []byte) { - out.WriteString(html.UnescapeString(string(entity))) -} - -func processFooterText(text []byte) []byte { - text = bytes.TrimPrefix(text, []byte("% ")) - newText := []byte{} - textArr := strings.Split(string(text), ") ") - - for i, w := range textArr { - if i == 0 { - w = strings.Replace(w, "(", "\" \"", 1) - w = fmt.Sprintf("\"%s\"", w) - } else { - w = fmt.Sprintf(" \"%s\"", w) - } - newText = append(newText, []byte(w)...) - } - newText = append(newText, []byte(" \"\"")...) - - return newText -} - -func (r *roffRenderer) NormalText(out *bytes.Buffer, text []byte) { - escapeSpecialChars(out, text) -} - -func (r *roffRenderer) DocumentHeader(out *bytes.Buffer) { -} - -func (r *roffRenderer) DocumentFooter(out *bytes.Buffer) { -} - -func needsBackslash(c byte) bool { - for _, r := range []byte("-_&\\~") { - if c == r { - return true - } - } - return false -} - -func escapeSpecialChars(out *bytes.Buffer, text []byte) { - for i := 0; i < len(text); i++ { - // directly copy normal characters - org := i - - for i < len(text) && !needsBackslash(text[i]) { - i++ - } - if i > org { - out.Write(text[org:i]) - } - - // escape a character - if i >= len(text) { - break - } - out.WriteByte('\\') - out.WriteByte(text[i]) - } -} diff --git a/Godeps/_workspace/src/github.com/cznic/b/AUTHORS b/Godeps/_workspace/src/github.com/cznic/b/AUTHORS deleted file mode 100644 index 0078f5f5b6..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/b/AUTHORS +++ /dev/null @@ -1,11 +0,0 @@ -# This file lists authors for copyright purposes. This file is distinct from -# the CONTRIBUTORS files. See the latter for an explanation. -# -# Names should be added to this file as: -# Name or Organization -# -# The email address is not required for organizations. -# -# Please keep the list sorted. - -Jan Mercl <0xjnml@gmail.com> diff --git a/Godeps/_workspace/src/github.com/cznic/b/CONTRIBUTORS b/Godeps/_workspace/src/github.com/cznic/b/CONTRIBUTORS deleted file mode 100644 index 094c323ef2..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/b/CONTRIBUTORS +++ /dev/null @@ -1,11 +0,0 @@ -# This file lists people who contributed code to this repository. The AUTHORS -# file lists the copyright holders; this file lists people. -# -# Names should be added to this file like so: -# Name -# -# Please keep the list sorted. - -Brian Fallik -Dan Kortschak -Jan Mercl <0xjnml@gmail.com> diff --git a/Godeps/_workspace/src/github.com/cznic/b/LICENSE b/Godeps/_workspace/src/github.com/cznic/b/LICENSE deleted file mode 100644 index 54c6e90872..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/b/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2014 The b 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 names of the authors nor the names of the -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. diff --git a/Godeps/_workspace/src/github.com/cznic/b/Makefile b/Godeps/_workspace/src/github.com/cznic/b/Makefile deleted file mode 100644 index b02c86dbef..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/b/Makefile +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright 2014 The b Authors. All rights reserved. -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file. - -.PHONY: all todo clean cover generic mem nuke cpu - -testbin=b.test - -all: editor - go build - go vet - golint . - go install - make todo - -editor: - gofmt -l -s -w . - go test -i - go test - -clean: - @go clean - rm -f *~ *.out $(testbin) - -cover: - t=$(shell tempfile) ; go test -coverprofile $$t && go tool cover -html $$t && unlink $$t - -cpu: - go test -c - ./$(testbin) -test.cpuprofile cpu.out - go tool pprof --lines $(testbin) cpu.out - -generic: - @# writes to stdout a version where the type of key is KEY and the type - @# of value is VALUE. - @# - @# Intended use is to replace all textual occurrences of KEY or VALUE in - @# the output with your desired types. - @sed -e 's|interface{}[^{]*/\*K\*/|KEY|g' -e 's|interface{}[^{]*/\*V\*/|VALUE|g' btree.go - -mem: - go test -c - ./$(testbin) -test.bench . -test.memprofile mem.out -test.memprofilerate 1 - go tool pprof --lines --web --alloc_space $(testbin) mem.out - -nuke: clean - rm -f *.test *.out - -todo: - @grep -n ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* *.go || true - @grep -n TODO *.go || true - @grep -n BUG *.go || true - @grep -n println *.go || true diff --git a/Godeps/_workspace/src/github.com/cznic/b/README.md b/Godeps/_workspace/src/github.com/cznic/b/README.md deleted file mode 100644 index 5a2d803026..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/b/README.md +++ /dev/null @@ -1,10 +0,0 @@ -b -= - -Package b implements a B+tree. - -Installation: - - $ go get github.com/cznic/b - -Documentation: [godoc.org/github.com/cznic/b](http://godoc.org/github.com/cznic/b) diff --git a/Godeps/_workspace/src/github.com/cznic/b/btree.go b/Godeps/_workspace/src/github.com/cznic/b/btree.go deleted file mode 100644 index 18cbeb8b05..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/b/btree.go +++ /dev/null @@ -1,929 +0,0 @@ -// Copyright 2014 The b 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 b - -import ( - "fmt" - "io" - "sync" -) - -const ( - kx = 32 //TODO benchmark tune this number if using custom key/value type(s). - kd = 32 //TODO benchmark tune this number if using custom key/value type(s). -) - -func init() { - if kd < 1 { - panic(fmt.Errorf("kd %d: out of range", kd)) - } - - if kx < 2 { - panic(fmt.Errorf("kx %d: out of range", kx)) - } -} - -var ( - btDPool = sync.Pool{New: func() interface{} { return &d{} }} - btEPool = btEpool{sync.Pool{New: func() interface{} { return &Enumerator{} }}} - btTPool = btTpool{sync.Pool{New: func() interface{} { return &Tree{} }}} - btXPool = sync.Pool{New: func() interface{} { return &x{} }} -) - -type btTpool struct{ sync.Pool } - -func (p *btTpool) get(cmp Cmp) *Tree { - x := p.Get().(*Tree) - x.cmp = cmp - return x -} - -type btEpool struct{ sync.Pool } - -func (p *btEpool) get(err error, hit bool, i int, k interface{} /*K*/, q *d, t *Tree, ver int64) *Enumerator { - x := p.Get().(*Enumerator) - x.err, x.hit, x.i, x.k, x.q, x.t, x.ver = err, hit, i, k, q, t, ver - return x -} - -type ( - // Cmp compares a and b. Return value is: - // - // < 0 if a < b - // 0 if a == b - // > 0 if a > b - // - Cmp func(a, b interface{} /*K*/) int - - d struct { // data page - c int - d [2*kd + 1]de - n *d - p *d - } - - de struct { // d element - k interface{} /*K*/ - v interface{} /*V*/ - } - - // Enumerator captures the state of enumerating a tree. It is returned - // from the Seek* methods. The enumerator is aware of any mutations - // made to the tree in the process of enumerating it and automatically - // resumes the enumeration at the proper key, if possible. - // - // However, once an Enumerator returns io.EOF to signal "no more - // items", it does no more attempt to "resync" on tree mutation(s). In - // other words, io.EOF from an Enumaretor is "sticky" (idempotent). - Enumerator struct { - err error - hit bool - i int - k interface{} /*K*/ - q *d - t *Tree - ver int64 - } - - // Tree is a B+tree. - Tree struct { - c int - cmp Cmp - first *d - last *d - r interface{} - ver int64 - } - - xe struct { // x element - ch interface{} - k interface{} /*K*/ - } - - x struct { // index page - c int - x [2*kx + 2]xe - } -) - -var ( // R/O zero values - zd d - zde de - ze Enumerator - zk interface{} /*K*/ - zt Tree - zx x - zxe xe -) - -func clr(q interface{}) { - switch x := q.(type) { - case *x: - for i := 0; i <= x.c; i++ { // Ch0 Sep0 ... Chn-1 Sepn-1 Chn - clr(x.x[i].ch) - } - *x = zx - btXPool.Put(x) - case *d: - *x = zd - btDPool.Put(x) - } -} - -// -------------------------------------------------------------------------- x - -func newX(ch0 interface{}) *x { - r := btXPool.Get().(*x) - r.x[0].ch = ch0 - return r -} - -func (q *x) extract(i int) { - q.c-- - if i < q.c { - copy(q.x[i:], q.x[i+1:q.c+1]) - q.x[q.c].ch = q.x[q.c+1].ch - q.x[q.c].k = zk // GC - q.x[q.c+1] = zxe // GC - } -} - -func (q *x) insert(i int, k interface{} /*K*/, ch interface{}) *x { - c := q.c - if i < c { - q.x[c+1].ch = q.x[c].ch - copy(q.x[i+2:], q.x[i+1:c]) - q.x[i+1].k = q.x[i].k - } - c++ - q.c = c - q.x[i].k = k - q.x[i+1].ch = ch - return q -} - -func (q *x) siblings(i int) (l, r *d) { - if i >= 0 { - if i > 0 { - l = q.x[i-1].ch.(*d) - } - if i < q.c { - r = q.x[i+1].ch.(*d) - } - } - return -} - -// -------------------------------------------------------------------------- d - -func (l *d) mvL(r *d, c int) { - copy(l.d[l.c:], r.d[:c]) - copy(r.d[:], r.d[c:r.c]) - l.c += c - r.c -= c -} - -func (l *d) mvR(r *d, c int) { - copy(r.d[c:], r.d[:r.c]) - copy(r.d[:c], l.d[l.c-c:]) - r.c += c - l.c -= c -} - -// ----------------------------------------------------------------------- Tree - -// TreeNew returns a newly created, empty Tree. The compare function is used -// for key collation. -func TreeNew(cmp Cmp) *Tree { - return btTPool.get(cmp) -} - -// Clear removes all K/V pairs from the tree. -func (t *Tree) Clear() { - if t.r == nil { - return - } - - clr(t.r) - t.c, t.first, t.last, t.r = 0, nil, nil, nil - t.ver++ -} - -// Close performs Clear and recycles t to a pool for possible later reuse. No -// references to t should exist or such references must not be used afterwards. -func (t *Tree) Close() { - t.Clear() - *t = zt - btTPool.Put(t) -} - -func (t *Tree) cat(p *x, q, r *d, pi int) { - t.ver++ - q.mvL(r, r.c) - if r.n != nil { - r.n.p = q - } else { - t.last = q - } - q.n = r.n - *r = zd - btDPool.Put(r) - if p.c > 1 { - p.extract(pi) - p.x[pi].ch = q - return - } - - switch x := t.r.(type) { - case *x: - *x = zx - btXPool.Put(x) - case *d: - *x = zd - btDPool.Put(x) - } - t.r = q -} - -func (t *Tree) catX(p, q, r *x, pi int) { - t.ver++ - q.x[q.c].k = p.x[pi].k - copy(q.x[q.c+1:], r.x[:r.c]) - q.c += r.c + 1 - q.x[q.c].ch = r.x[r.c].ch - *r = zx - btXPool.Put(r) - if p.c > 1 { - p.c-- - pc := p.c - if pi < pc { - p.x[pi].k = p.x[pi+1].k - copy(p.x[pi+1:], p.x[pi+2:pc+1]) - p.x[pc].ch = p.x[pc+1].ch - p.x[pc].k = zk // GC - p.x[pc+1].ch = nil // GC - } - return - } - - switch x := t.r.(type) { - case *x: - *x = zx - btXPool.Put(x) - case *d: - *x = zd - btDPool.Put(x) - } - t.r = q -} - -// Delete removes the k's KV pair, if it exists, in which case Delete returns -// true. -func (t *Tree) Delete(k interface{} /*K*/) (ok bool) { - pi := -1 - var p *x - q := t.r - if q == nil { - return false - } - - for { - var i int - i, ok = t.find(q, k) - if ok { - switch x := q.(type) { - case *x: - if x.c < kx && q != t.r { - x, i = t.underflowX(p, x, pi, i) - } - pi = i + 1 - p = x - q = x.x[pi].ch - ok = false - continue - case *d: - t.extract(x, i) - if x.c >= kd { - return true - } - - if q != t.r { - t.underflow(p, x, pi) - } else if t.c == 0 { - t.Clear() - } - return true - } - } - - switch x := q.(type) { - case *x: - if x.c < kx && q != t.r { - x, i = t.underflowX(p, x, pi, i) - } - pi = i - p = x - q = x.x[i].ch - case *d: - return false - } - } -} - -func (t *Tree) extract(q *d, i int) { // (r interface{} /*V*/) { - t.ver++ - //r = q.d[i].v // prepared for Extract - q.c-- - if i < q.c { - copy(q.d[i:], q.d[i+1:q.c+1]) - } - q.d[q.c] = zde // GC - t.c-- - return -} - -func (t *Tree) find(q interface{}, k interface{} /*K*/) (i int, ok bool) { - var mk interface{} /*K*/ - l := 0 - switch x := q.(type) { - case *x: - h := x.c - 1 - for l <= h { - m := (l + h) >> 1 - mk = x.x[m].k - switch cmp := t.cmp(k, mk); { - case cmp > 0: - l = m + 1 - case cmp == 0: - return m, true - default: - h = m - 1 - } - } - case *d: - h := x.c - 1 - for l <= h { - m := (l + h) >> 1 - mk = x.d[m].k - switch cmp := t.cmp(k, mk); { - case cmp > 0: - l = m + 1 - case cmp == 0: - return m, true - default: - h = m - 1 - } - } - } - return l, false -} - -// First returns the first item of the tree in the key collating order, or -// (zero-value, zero-value) if the tree is empty. -func (t *Tree) First() (k interface{} /*K*/, v interface{} /*V*/) { - if q := t.first; q != nil { - q := &q.d[0] - k, v = q.k, q.v - } - return -} - -// Get returns the value associated with k and true if it exists. Otherwise Get -// returns (zero-value, false). -func (t *Tree) Get(k interface{} /*K*/) (v interface{} /*V*/, ok bool) { - q := t.r - if q == nil { - return - } - - for { - var i int - if i, ok = t.find(q, k); ok { - switch x := q.(type) { - case *x: - q = x.x[i+1].ch - continue - case *d: - return x.d[i].v, true - } - } - switch x := q.(type) { - case *x: - q = x.x[i].ch - default: - return - } - } -} - -func (t *Tree) insert(q *d, i int, k interface{} /*K*/, v interface{} /*V*/) *d { - t.ver++ - c := q.c - if i < c { - copy(q.d[i+1:], q.d[i:c]) - } - c++ - q.c = c - q.d[i].k, q.d[i].v = k, v - t.c++ - return q -} - -// Last returns the last item of the tree in the key collating order, or -// (zero-value, zero-value) if the tree is empty. -func (t *Tree) Last() (k interface{} /*K*/, v interface{} /*V*/) { - if q := t.last; q != nil { - q := &q.d[q.c-1] - k, v = q.k, q.v - } - return -} - -// Len returns the number of items in the tree. -func (t *Tree) Len() int { - return t.c -} - -func (t *Tree) overflow(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{} /*V*/) { - t.ver++ - l, r := p.siblings(pi) - - if l != nil && l.c < 2*kd { - l.mvL(q, 1) - t.insert(q, i-1, k, v) - p.x[pi-1].k = q.d[0].k - return - } - - if r != nil && r.c < 2*kd { - if i < 2*kd { - q.mvR(r, 1) - t.insert(q, i, k, v) - p.x[pi].k = r.d[0].k - return - } - - t.insert(r, 0, k, v) - p.x[pi].k = k - return - } - - t.split(p, q, pi, i, k, v) -} - -// Seek returns an Enumerator positioned on a an item such that k >= item's -// key. ok reports if k == item.key The Enumerator's position is possibly -// after the last item in the tree. -func (t *Tree) Seek(k interface{} /*K*/) (e *Enumerator, ok bool) { - q := t.r - if q == nil { - e = btEPool.get(nil, false, 0, k, nil, t, t.ver) - return - } - - for { - var i int - if i, ok = t.find(q, k); ok { - switch x := q.(type) { - case *x: - q = x.x[i+1].ch - continue - case *d: - return btEPool.get(nil, ok, i, k, x, t, t.ver), true - } - } - - switch x := q.(type) { - case *x: - q = x.x[i].ch - case *d: - return btEPool.get(nil, ok, i, k, x, t, t.ver), false - } - } -} - -// SeekFirst returns an enumerator positioned on the first KV pair in the tree, -// if any. For an empty tree, err == io.EOF is returned and e will be nil. -func (t *Tree) SeekFirst() (e *Enumerator, err error) { - q := t.first - if q == nil { - return nil, io.EOF - } - - return btEPool.get(nil, true, 0, q.d[0].k, q, t, t.ver), nil -} - -// SeekLast returns an enumerator positioned on the last KV pair in the tree, -// if any. For an empty tree, err == io.EOF is returned and e will be nil. -func (t *Tree) SeekLast() (e *Enumerator, err error) { - q := t.last - if q == nil { - return nil, io.EOF - } - - return btEPool.get(nil, true, q.c-1, q.d[q.c-1].k, q, t, t.ver), nil -} - -// Set sets the value associated with k. -func (t *Tree) Set(k interface{} /*K*/, v interface{} /*V*/) { - //dbg("--- PRE Set(%v, %v)\n%s", k, v, t.dump()) - //defer func() { - // dbg("--- POST\n%s\n====\n", t.dump()) - //}() - - pi := -1 - var p *x - q := t.r - if q == nil { - z := t.insert(btDPool.Get().(*d), 0, k, v) - t.r, t.first, t.last = z, z, z - return - } - - for { - i, ok := t.find(q, k) - if ok { - switch x := q.(type) { - case *x: - if x.c > 2*kx { - x, i = t.splitX(p, x, pi, i) - } - pi = i + 1 - p = x - q = x.x[i+1].ch - continue - case *d: - x.d[i].v = v - } - return - } - - switch x := q.(type) { - case *x: - if x.c > 2*kx { - x, i = t.splitX(p, x, pi, i) - } - pi = i - p = x - q = x.x[i].ch - case *d: - switch { - case x.c < 2*kd: - t.insert(x, i, k, v) - default: - t.overflow(p, x, pi, i, k, v) - } - return - } - } -} - -// Put combines Get and Set in a more efficient way where the tree is walked -// only once. The upd(ater) receives (old-value, true) if a KV pair for k -// exists or (zero-value, false) otherwise. It can then return a (new-value, -// true) to create or overwrite the existing value in the KV pair, or -// (whatever, false) if it decides not to create or not to update the value of -// the KV pair. -// -// tree.Set(k, v) call conceptually equals calling -// -// tree.Put(k, func(interface{} /*K*/, bool){ return v, true }) -// -// modulo the differing return values. -func (t *Tree) Put(k interface{} /*K*/, upd func(oldV interface{} /*V*/, exists bool) (newV interface{} /*V*/, write bool)) (oldV interface{} /*V*/, written bool) { - pi := -1 - var p *x - q := t.r - var newV interface{} /*V*/ - if q == nil { - // new KV pair in empty tree - newV, written = upd(newV, false) - if !written { - return - } - - z := t.insert(btDPool.Get().(*d), 0, k, newV) - t.r, t.first, t.last = z, z, z - return - } - - for { - i, ok := t.find(q, k) - if ok { - switch x := q.(type) { - case *x: - if x.c > 2*kx { - x, i = t.splitX(p, x, pi, i) - } - pi = i + 1 - p = x - q = x.x[i+1].ch - continue - case *d: - oldV = x.d[i].v - newV, written = upd(oldV, true) - if !written { - return - } - - x.d[i].v = newV - } - return - } - - switch x := q.(type) { - case *x: - if x.c > 2*kx { - x, i = t.splitX(p, x, pi, i) - } - pi = i - p = x - q = x.x[i].ch - case *d: // new KV pair - newV, written = upd(newV, false) - if !written { - return - } - - switch { - case x.c < 2*kd: - t.insert(x, i, k, newV) - default: - t.overflow(p, x, pi, i, k, newV) - } - return - } - } -} - -func (t *Tree) split(p *x, q *d, pi, i int, k interface{} /*K*/, v interface{} /*V*/) { - t.ver++ - r := btDPool.Get().(*d) - if q.n != nil { - r.n = q.n - r.n.p = r - } else { - t.last = r - } - q.n = r - r.p = q - - copy(r.d[:], q.d[kd:2*kd]) - for i := range q.d[kd:] { - q.d[kd+i] = zde - } - q.c = kd - r.c = kd - var done bool - if i > kd { - done = true - t.insert(r, i-kd, k, v) - } - if pi >= 0 { - p.insert(pi, r.d[0].k, r) - } else { - t.r = newX(q).insert(0, r.d[0].k, r) - } - if done { - return - } - - t.insert(q, i, k, v) -} - -func (t *Tree) splitX(p *x, q *x, pi int, i int) (*x, int) { - t.ver++ - r := btXPool.Get().(*x) - copy(r.x[:], q.x[kx+1:]) - q.c = kx - r.c = kx - if pi >= 0 { - p.insert(pi, q.x[kx].k, r) - q.x[kx].k = zk - for i := range q.x[kx+1:] { - q.x[kx+i+1] = zxe - } - - switch { - case i < kx: - return q, i - case i == kx: - return p, pi - default: // i > kx - return r, i - kx - 1 - } - } - - nr := newX(q).insert(0, q.x[kx].k, r) - t.r = nr - q.x[kx].k = zk - for i := range q.x[kx+1:] { - q.x[kx+i+1] = zxe - } - - switch { - case i < kx: - return q, i - case i == kx: - return nr, 0 - default: // i > kx - return r, i - kx - 1 - } -} - -func (t *Tree) underflow(p *x, q *d, pi int) { - t.ver++ - l, r := p.siblings(pi) - - if l != nil && l.c+q.c >= 2*kd { - l.mvR(q, 1) - p.x[pi-1].k = q.d[0].k - return - } - - if r != nil && q.c+r.c >= 2*kd { - q.mvL(r, 1) - p.x[pi].k = r.d[0].k - r.d[r.c] = zde // GC - return - } - - if l != nil { - t.cat(p, l, q, pi-1) - return - } - - t.cat(p, q, r, pi) -} - -func (t *Tree) underflowX(p *x, q *x, pi int, i int) (*x, int) { - t.ver++ - var l, r *x - - if pi >= 0 { - if pi > 0 { - l = p.x[pi-1].ch.(*x) - } - if pi < p.c { - r = p.x[pi+1].ch.(*x) - } - } - - if l != nil && l.c > kx { - q.x[q.c+1].ch = q.x[q.c].ch - copy(q.x[1:], q.x[:q.c]) - q.x[0].ch = l.x[l.c].ch - q.x[0].k = p.x[pi-1].k - q.c++ - i++ - l.c-- - p.x[pi-1].k = l.x[l.c].k - return q, i - } - - if r != nil && r.c > kx { - q.x[q.c].k = p.x[pi].k - q.c++ - q.x[q.c].ch = r.x[0].ch - p.x[pi].k = r.x[0].k - copy(r.x[:], r.x[1:r.c]) - r.c-- - rc := r.c - r.x[rc].ch = r.x[rc+1].ch - r.x[rc].k = zk - r.x[rc+1].ch = nil - return q, i - } - - if l != nil { - i += l.c + 1 - t.catX(p, l, q, pi-1) - q = l - return q, i - } - - t.catX(p, q, r, pi) - return q, i -} - -// ----------------------------------------------------------------- Enumerator - -// Close recycles e to a pool for possible later reuse. No references to e -// should exist or such references must not be used afterwards. -func (e *Enumerator) Close() { - *e = ze - btEPool.Put(e) -} - -// Next returns the currently enumerated item, if it exists and moves to the -// next item in the key collation order. If there is no item to return, err == -// io.EOF is returned. -func (e *Enumerator) Next() (k interface{} /*K*/, v interface{} /*V*/, err error) { - if err = e.err; err != nil { - return - } - - if e.ver != e.t.ver { - f, hit := e.t.Seek(e.k) - if !e.hit && hit { - if err = f.next(); err != nil { - return - } - } - - *e = *f - f.Close() - } - if e.q == nil { - e.err, err = io.EOF, io.EOF - return - } - - if e.i >= e.q.c { - if err = e.next(); err != nil { - return - } - } - - i := e.q.d[e.i] - k, v = i.k, i.v - e.k, e.hit = k, false - e.next() - return -} - -func (e *Enumerator) next() error { - if e.q == nil { - e.err = io.EOF - return io.EOF - } - - switch { - case e.i < e.q.c-1: - e.i++ - default: - if e.q, e.i = e.q.n, 0; e.q == nil { - e.err = io.EOF - } - } - return e.err -} - -// Prev returns the currently enumerated item, if it exists and moves to the -// previous item in the key collation order. If there is no item to return, err -// == io.EOF is returned. -func (e *Enumerator) Prev() (k interface{} /*K*/, v interface{} /*V*/, err error) { - if err = e.err; err != nil { - return - } - - if e.ver != e.t.ver { - f, hit := e.t.Seek(e.k) - if !e.hit && hit { - if err = f.prev(); err != nil { - return - } - } - - *e = *f - f.Close() - } - if e.q == nil { - e.err, err = io.EOF, io.EOF - return - } - - if e.i >= e.q.c { - if err = e.next(); err != nil { - return - } - } - - i := e.q.d[e.i] - k, v = i.k, i.v - e.k, e.hit = k, false - e.prev() - return -} - -func (e *Enumerator) prev() error { - if e.q == nil { - e.err = io.EOF - return io.EOF - } - - switch { - case e.i > 0: - e.i-- - default: - if e.q = e.q.p; e.q == nil { - e.err = io.EOF - break - } - - e.i = e.q.c - 1 - } - return e.err -} diff --git a/Godeps/_workspace/src/github.com/cznic/b/doc.go b/Godeps/_workspace/src/github.com/cznic/b/doc.go deleted file mode 100644 index ddcf73704f..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/b/doc.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2014 The b 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 b implements the B+tree flavor of a BTree. -// -// Changelog -// -// 2014-06-26: Lower GC presure by recycling things. -// -// 2014-04-18: Added new method Put. -// -// Generic types -// -// Keys and their associated values are interface{} typed, similar to all of -// the containers in the standard library. -// -// Semiautomatic production of a type specific variant of this package is -// supported via -// -// $ make generic -// -// This command will write to stdout a version of the btree.go file where every -// key type occurrence is replaced by the word 'KEY' and every value type -// occurrence is replaced by the word 'VALUE'. Then you have to replace these -// tokens with your desired type(s), using any technique you're comfortable -// with. -// -// This is how, for example, 'example/int.go' was created: -// -// $ mkdir example -// $ make generic | sed -e 's/KEY/int/g' -e 's/VALUE/int/g' > example/int.go -// -// No other changes to int.go are necessary, it compiles just fine. -// -// Running the benchmarks for 1000 keys on a machine with Intel i5-4670 CPU @ -// 3.4GHz, Go release 1.4.2. -// -// $ go test -bench 1e3 example/all_test.go example/int.go -// PASS -// BenchmarkSetSeq1e3 10000 151620 ns/op -// BenchmarkGetSeq1e3 10000 115354 ns/op -// BenchmarkSetRnd1e3 5000 255865 ns/op -// BenchmarkGetRnd1e3 10000 140466 ns/op -// BenchmarkDelSeq1e3 10000 143860 ns/op -// BenchmarkDelRnd1e3 10000 188228 ns/op -// BenchmarkSeekSeq1e3 10000 156448 ns/op -// BenchmarkSeekRnd1e3 10000 190587 ns/op -// BenchmarkNext1e3 200000 9407 ns/op -// BenchmarkPrev1e3 200000 9306 ns/op -// ok command-line-arguments 26.369s -// $ -package b diff --git a/Godeps/_workspace/src/github.com/cznic/b/example/Makefile b/Godeps/_workspace/src/github.com/cznic/b/example/Makefile deleted file mode 100644 index 6c0f1856d9..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/b/example/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2014 The b Authors. All rights reserved. -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file. - -.PHONY: all todo clean cover mem - -testbin=b.test - -all: editor - go build - go vet - make todo - -editor: - go fmt - go test -i - go test - -mem: - go test -c - ./$(testbin) -test.bench . -test.memprofile mem.out -test.memprofilerate 1 - go tool pprof --lines --web --alloc_space $(testbin) mem.out - -todo: - @grep -n ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* *.go || true - @grep -n TODO *.go || true - @grep -n BUG *.go || true - @grep -n println *.go || true - -clean: - @go clean - rm -f *~ - -cover: - t=$(shell tempfile) ; go test -coverprofile $$t && go tool cover -html $$t && unlink $$t diff --git a/Godeps/_workspace/src/github.com/cznic/b/example/int.go b/Godeps/_workspace/src/github.com/cznic/b/example/int.go deleted file mode 100644 index 54f7fdffdd..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/b/example/int.go +++ /dev/null @@ -1,929 +0,0 @@ -// Copyright 2014 The b 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 b - -import ( - "fmt" - "io" - "sync" -) - -const ( - kx = 32 //TODO benchmark tune this number if using custom key/value type(s). - kd = 32 //TODO benchmark tune this number if using custom key/value type(s). -) - -func init() { - if kd < 1 { - panic(fmt.Errorf("kd %d: out of range", kd)) - } - - if kx < 2 { - panic(fmt.Errorf("kx %d: out of range", kx)) - } -} - -var ( - btDPool = sync.Pool{New: func() interface{} { return &d{} }} - btEPool = btEpool{sync.Pool{New: func() interface{} { return &Enumerator{} }}} - btTPool = btTpool{sync.Pool{New: func() interface{} { return &Tree{} }}} - btXPool = sync.Pool{New: func() interface{} { return &x{} }} -) - -type btTpool struct{ sync.Pool } - -func (p *btTpool) get(cmp Cmp) *Tree { - x := p.Get().(*Tree) - x.cmp = cmp - return x -} - -type btEpool struct{ sync.Pool } - -func (p *btEpool) get(err error, hit bool, i int, k int, q *d, t *Tree, ver int64) *Enumerator { - x := p.Get().(*Enumerator) - x.err, x.hit, x.i, x.k, x.q, x.t, x.ver = err, hit, i, k, q, t, ver - return x -} - -type ( - // Cmp compares a and b. Return value is: - // - // < 0 if a < b - // 0 if a == b - // > 0 if a > b - // - Cmp func(a, b int) int - - d struct { // data page - c int - d [2*kd + 1]de - n *d - p *d - } - - de struct { // d element - k int - v int - } - - // Enumerator captures the state of enumerating a tree. It is returned - // from the Seek* methods. The enumerator is aware of any mutations - // made to the tree in the process of enumerating it and automatically - // resumes the enumeration at the proper key, if possible. - // - // However, once an Enumerator returns io.EOF to signal "no more - // items", it does no more attempt to "resync" on tree mutation(s). In - // other words, io.EOF from an Enumaretor is "sticky" (idempotent). - Enumerator struct { - err error - hit bool - i int - k int - q *d - t *Tree - ver int64 - } - - // Tree is a B+tree. - Tree struct { - c int - cmp Cmp - first *d - last *d - r interface{} - ver int64 - } - - xe struct { // x element - ch interface{} - k int - } - - x struct { // index page - c int - x [2*kx + 2]xe - } -) - -var ( // R/O zero values - zd d - zde de - ze Enumerator - zk int - zt Tree - zx x - zxe xe -) - -func clr(q interface{}) { - switch x := q.(type) { - case *x: - for i := 0; i <= x.c; i++ { // Ch0 Sep0 ... Chn-1 Sepn-1 Chn - clr(x.x[i].ch) - } - *x = zx - btXPool.Put(x) - case *d: - *x = zd - btDPool.Put(x) - } -} - -// -------------------------------------------------------------------------- x - -func newX(ch0 interface{}) *x { - r := btXPool.Get().(*x) - r.x[0].ch = ch0 - return r -} - -func (q *x) extract(i int) { - q.c-- - if i < q.c { - copy(q.x[i:], q.x[i+1:q.c+1]) - q.x[q.c].ch = q.x[q.c+1].ch - q.x[q.c].k = zk // GC - q.x[q.c+1] = zxe // GC - } -} - -func (q *x) insert(i int, k int, ch interface{}) *x { - c := q.c - if i < c { - q.x[c+1].ch = q.x[c].ch - copy(q.x[i+2:], q.x[i+1:c]) - q.x[i+1].k = q.x[i].k - } - c++ - q.c = c - q.x[i].k = k - q.x[i+1].ch = ch - return q -} - -func (q *x) siblings(i int) (l, r *d) { - if i >= 0 { - if i > 0 { - l = q.x[i-1].ch.(*d) - } - if i < q.c { - r = q.x[i+1].ch.(*d) - } - } - return -} - -// -------------------------------------------------------------------------- d - -func (l *d) mvL(r *d, c int) { - copy(l.d[l.c:], r.d[:c]) - copy(r.d[:], r.d[c:r.c]) - l.c += c - r.c -= c -} - -func (l *d) mvR(r *d, c int) { - copy(r.d[c:], r.d[:r.c]) - copy(r.d[:c], l.d[l.c-c:]) - r.c += c - l.c -= c -} - -// ----------------------------------------------------------------------- Tree - -// TreeNew returns a newly created, empty Tree. The compare function is used -// for key collation. -func TreeNew(cmp Cmp) *Tree { - return btTPool.get(cmp) -} - -// Clear removes all K/V pairs from the tree. -func (t *Tree) Clear() { - if t.r == nil { - return - } - - clr(t.r) - t.c, t.first, t.last, t.r = 0, nil, nil, nil - t.ver++ -} - -// Close performs Clear and recycles t to a pool for possible later reuse. No -// references to t should exist or such references must not be used afterwards. -func (t *Tree) Close() { - t.Clear() - *t = zt - btTPool.Put(t) -} - -func (t *Tree) cat(p *x, q, r *d, pi int) { - t.ver++ - q.mvL(r, r.c) - if r.n != nil { - r.n.p = q - } else { - t.last = q - } - q.n = r.n - *r = zd - btDPool.Put(r) - if p.c > 1 { - p.extract(pi) - p.x[pi].ch = q - return - } - - switch x := t.r.(type) { - case *x: - *x = zx - btXPool.Put(x) - case *d: - *x = zd - btDPool.Put(x) - } - t.r = q -} - -func (t *Tree) catX(p, q, r *x, pi int) { - t.ver++ - q.x[q.c].k = p.x[pi].k - copy(q.x[q.c+1:], r.x[:r.c]) - q.c += r.c + 1 - q.x[q.c].ch = r.x[r.c].ch - *r = zx - btXPool.Put(r) - if p.c > 1 { - p.c-- - pc := p.c - if pi < pc { - p.x[pi].k = p.x[pi+1].k - copy(p.x[pi+1:], p.x[pi+2:pc+1]) - p.x[pc].ch = p.x[pc+1].ch - p.x[pc].k = zk // GC - p.x[pc+1].ch = nil // GC - } - return - } - - switch x := t.r.(type) { - case *x: - *x = zx - btXPool.Put(x) - case *d: - *x = zd - btDPool.Put(x) - } - t.r = q -} - -// Delete removes the k's KV pair, if it exists, in which case Delete returns -// true. -func (t *Tree) Delete(k int) (ok bool) { - pi := -1 - var p *x - q := t.r - if q == nil { - return false - } - - for { - var i int - i, ok = t.find(q, k) - if ok { - switch x := q.(type) { - case *x: - if x.c < kx && q != t.r { - x, i = t.underflowX(p, x, pi, i) - } - pi = i + 1 - p = x - q = x.x[pi].ch - ok = false - continue - case *d: - t.extract(x, i) - if x.c >= kd { - return true - } - - if q != t.r { - t.underflow(p, x, pi) - } else if t.c == 0 { - t.Clear() - } - return true - } - } - - switch x := q.(type) { - case *x: - if x.c < kx && q != t.r { - x, i = t.underflowX(p, x, pi, i) - } - pi = i - p = x - q = x.x[i].ch - case *d: - return false - } - } -} - -func (t *Tree) extract(q *d, i int) { // (r int) { - t.ver++ - //r = q.d[i].v // prepared for Extract - q.c-- - if i < q.c { - copy(q.d[i:], q.d[i+1:q.c+1]) - } - q.d[q.c] = zde // GC - t.c-- - return -} - -func (t *Tree) find(q interface{}, k int) (i int, ok bool) { - var mk int - l := 0 - switch x := q.(type) { - case *x: - h := x.c - 1 - for l <= h { - m := (l + h) >> 1 - mk = x.x[m].k - switch cmp := t.cmp(k, mk); { - case cmp > 0: - l = m + 1 - case cmp == 0: - return m, true - default: - h = m - 1 - } - } - case *d: - h := x.c - 1 - for l <= h { - m := (l + h) >> 1 - mk = x.d[m].k - switch cmp := t.cmp(k, mk); { - case cmp > 0: - l = m + 1 - case cmp == 0: - return m, true - default: - h = m - 1 - } - } - } - return l, false -} - -// First returns the first item of the tree in the key collating order, or -// (zero-value, zero-value) if the tree is empty. -func (t *Tree) First() (k int, v int) { - if q := t.first; q != nil { - q := &q.d[0] - k, v = q.k, q.v - } - return -} - -// Get returns the value associated with k and true if it exists. Otherwise Get -// returns (zero-value, false). -func (t *Tree) Get(k int) (v int, ok bool) { - q := t.r - if q == nil { - return - } - - for { - var i int - if i, ok = t.find(q, k); ok { - switch x := q.(type) { - case *x: - q = x.x[i+1].ch - continue - case *d: - return x.d[i].v, true - } - } - switch x := q.(type) { - case *x: - q = x.x[i].ch - default: - return - } - } -} - -func (t *Tree) insert(q *d, i int, k int, v int) *d { - t.ver++ - c := q.c - if i < c { - copy(q.d[i+1:], q.d[i:c]) - } - c++ - q.c = c - q.d[i].k, q.d[i].v = k, v - t.c++ - return q -} - -// Last returns the last item of the tree in the key collating order, or -// (zero-value, zero-value) if the tree is empty. -func (t *Tree) Last() (k int, v int) { - if q := t.last; q != nil { - q := &q.d[q.c-1] - k, v = q.k, q.v - } - return -} - -// Len returns the number of items in the tree. -func (t *Tree) Len() int { - return t.c -} - -func (t *Tree) overflow(p *x, q *d, pi, i int, k int, v int) { - t.ver++ - l, r := p.siblings(pi) - - if l != nil && l.c < 2*kd { - l.mvL(q, 1) - t.insert(q, i-1, k, v) - p.x[pi-1].k = q.d[0].k - return - } - - if r != nil && r.c < 2*kd { - if i < 2*kd { - q.mvR(r, 1) - t.insert(q, i, k, v) - p.x[pi].k = r.d[0].k - return - } - - t.insert(r, 0, k, v) - p.x[pi].k = k - return - } - - t.split(p, q, pi, i, k, v) -} - -// Seek returns an Enumerator positioned on a an item such that k >= item's -// key. ok reports if k == item.key The Enumerator's position is possibly -// after the last item in the tree. -func (t *Tree) Seek(k int) (e *Enumerator, ok bool) { - q := t.r - if q == nil { - e = btEPool.get(nil, false, 0, k, nil, t, t.ver) - return - } - - for { - var i int - if i, ok = t.find(q, k); ok { - switch x := q.(type) { - case *x: - q = x.x[i+1].ch - continue - case *d: - return btEPool.get(nil, ok, i, k, x, t, t.ver), true - } - } - - switch x := q.(type) { - case *x: - q = x.x[i].ch - case *d: - return btEPool.get(nil, ok, i, k, x, t, t.ver), false - } - } -} - -// SeekFirst returns an enumerator positioned on the first KV pair in the tree, -// if any. For an empty tree, err == io.EOF is returned and e will be nil. -func (t *Tree) SeekFirst() (e *Enumerator, err error) { - q := t.first - if q == nil { - return nil, io.EOF - } - - return btEPool.get(nil, true, 0, q.d[0].k, q, t, t.ver), nil -} - -// SeekLast returns an enumerator positioned on the last KV pair in the tree, -// if any. For an empty tree, err == io.EOF is returned and e will be nil. -func (t *Tree) SeekLast() (e *Enumerator, err error) { - q := t.last - if q == nil { - return nil, io.EOF - } - - return btEPool.get(nil, true, q.c-1, q.d[q.c-1].k, q, t, t.ver), nil -} - -// Set sets the value associated with k. -func (t *Tree) Set(k int, v int) { - //dbg("--- PRE Set(%v, %v)\n%s", k, v, t.dump()) - //defer func() { - // dbg("--- POST\n%s\n====\n", t.dump()) - //}() - - pi := -1 - var p *x - q := t.r - if q == nil { - z := t.insert(btDPool.Get().(*d), 0, k, v) - t.r, t.first, t.last = z, z, z - return - } - - for { - i, ok := t.find(q, k) - if ok { - switch x := q.(type) { - case *x: - if x.c > 2*kx { - x, i = t.splitX(p, x, pi, i) - } - pi = i + 1 - p = x - q = x.x[i+1].ch - continue - case *d: - x.d[i].v = v - } - return - } - - switch x := q.(type) { - case *x: - if x.c > 2*kx { - x, i = t.splitX(p, x, pi, i) - } - pi = i - p = x - q = x.x[i].ch - case *d: - switch { - case x.c < 2*kd: - t.insert(x, i, k, v) - default: - t.overflow(p, x, pi, i, k, v) - } - return - } - } -} - -// Put combines Get and Set in a more efficient way where the tree is walked -// only once. The upd(ater) receives (old-value, true) if a KV pair for k -// exists or (zero-value, false) otherwise. It can then return a (new-value, -// true) to create or overwrite the existing value in the KV pair, or -// (whatever, false) if it decides not to create or not to update the value of -// the KV pair. -// -// tree.Set(k, v) call conceptually equals calling -// -// tree.Put(k, func(int, bool){ return v, true }) -// -// modulo the differing return values. -func (t *Tree) Put(k int, upd func(oldV int, exists bool) (newV int, write bool)) (oldV int, written bool) { - pi := -1 - var p *x - q := t.r - var newV int - if q == nil { - // new KV pair in empty tree - newV, written = upd(newV, false) - if !written { - return - } - - z := t.insert(btDPool.Get().(*d), 0, k, newV) - t.r, t.first, t.last = z, z, z - return - } - - for { - i, ok := t.find(q, k) - if ok { - switch x := q.(type) { - case *x: - if x.c > 2*kx { - x, i = t.splitX(p, x, pi, i) - } - pi = i + 1 - p = x - q = x.x[i+1].ch - continue - case *d: - oldV = x.d[i].v - newV, written = upd(oldV, true) - if !written { - return - } - - x.d[i].v = newV - } - return - } - - switch x := q.(type) { - case *x: - if x.c > 2*kx { - x, i = t.splitX(p, x, pi, i) - } - pi = i - p = x - q = x.x[i].ch - case *d: // new KV pair - newV, written = upd(newV, false) - if !written { - return - } - - switch { - case x.c < 2*kd: - t.insert(x, i, k, newV) - default: - t.overflow(p, x, pi, i, k, newV) - } - return - } - } -} - -func (t *Tree) split(p *x, q *d, pi, i int, k int, v int) { - t.ver++ - r := btDPool.Get().(*d) - if q.n != nil { - r.n = q.n - r.n.p = r - } else { - t.last = r - } - q.n = r - r.p = q - - copy(r.d[:], q.d[kd:2*kd]) - for i := range q.d[kd:] { - q.d[kd+i] = zde - } - q.c = kd - r.c = kd - var done bool - if i > kd { - done = true - t.insert(r, i-kd, k, v) - } - if pi >= 0 { - p.insert(pi, r.d[0].k, r) - } else { - t.r = newX(q).insert(0, r.d[0].k, r) - } - if done { - return - } - - t.insert(q, i, k, v) -} - -func (t *Tree) splitX(p *x, q *x, pi int, i int) (*x, int) { - t.ver++ - r := btXPool.Get().(*x) - copy(r.x[:], q.x[kx+1:]) - q.c = kx - r.c = kx - if pi >= 0 { - p.insert(pi, q.x[kx].k, r) - q.x[kx].k = zk - for i := range q.x[kx+1:] { - q.x[kx+i+1] = zxe - } - - switch { - case i < kx: - return q, i - case i == kx: - return p, pi - default: // i > kx - return r, i - kx - 1 - } - } - - nr := newX(q).insert(0, q.x[kx].k, r) - t.r = nr - q.x[kx].k = zk - for i := range q.x[kx+1:] { - q.x[kx+i+1] = zxe - } - - switch { - case i < kx: - return q, i - case i == kx: - return nr, 0 - default: // i > kx - return r, i - kx - 1 - } -} - -func (t *Tree) underflow(p *x, q *d, pi int) { - t.ver++ - l, r := p.siblings(pi) - - if l != nil && l.c+q.c >= 2*kd { - l.mvR(q, 1) - p.x[pi-1].k = q.d[0].k - return - } - - if r != nil && q.c+r.c >= 2*kd { - q.mvL(r, 1) - p.x[pi].k = r.d[0].k - r.d[r.c] = zde // GC - return - } - - if l != nil { - t.cat(p, l, q, pi-1) - return - } - - t.cat(p, q, r, pi) -} - -func (t *Tree) underflowX(p *x, q *x, pi int, i int) (*x, int) { - t.ver++ - var l, r *x - - if pi >= 0 { - if pi > 0 { - l = p.x[pi-1].ch.(*x) - } - if pi < p.c { - r = p.x[pi+1].ch.(*x) - } - } - - if l != nil && l.c > kx { - q.x[q.c+1].ch = q.x[q.c].ch - copy(q.x[1:], q.x[:q.c]) - q.x[0].ch = l.x[l.c].ch - q.x[0].k = p.x[pi-1].k - q.c++ - i++ - l.c-- - p.x[pi-1].k = l.x[l.c].k - return q, i - } - - if r != nil && r.c > kx { - q.x[q.c].k = p.x[pi].k - q.c++ - q.x[q.c].ch = r.x[0].ch - p.x[pi].k = r.x[0].k - copy(r.x[:], r.x[1:r.c]) - r.c-- - rc := r.c - r.x[rc].ch = r.x[rc+1].ch - r.x[rc].k = zk - r.x[rc+1].ch = nil - return q, i - } - - if l != nil { - i += l.c + 1 - t.catX(p, l, q, pi-1) - q = l - return q, i - } - - t.catX(p, q, r, pi) - return q, i -} - -// ----------------------------------------------------------------- Enumerator - -// Close recycles e to a pool for possible later reuse. No references to e -// should exist or such references must not be used afterwards. -func (e *Enumerator) Close() { - *e = ze - btEPool.Put(e) -} - -// Next returns the currently enumerated item, if it exists and moves to the -// next item in the key collation order. If there is no item to return, err == -// io.EOF is returned. -func (e *Enumerator) Next() (k int, v int, err error) { - if err = e.err; err != nil { - return - } - - if e.ver != e.t.ver { - f, hit := e.t.Seek(e.k) - if !e.hit && hit { - if err = f.next(); err != nil { - return - } - } - - *e = *f - f.Close() - } - if e.q == nil { - e.err, err = io.EOF, io.EOF - return - } - - if e.i >= e.q.c { - if err = e.next(); err != nil { - return - } - } - - i := e.q.d[e.i] - k, v = i.k, i.v - e.k, e.hit = k, false - e.next() - return -} - -func (e *Enumerator) next() error { - if e.q == nil { - e.err = io.EOF - return io.EOF - } - - switch { - case e.i < e.q.c-1: - e.i++ - default: - if e.q, e.i = e.q.n, 0; e.q == nil { - e.err = io.EOF - } - } - return e.err -} - -// Prev returns the currently enumerated item, if it exists and moves to the -// previous item in the key collation order. If there is no item to return, err -// == io.EOF is returned. -func (e *Enumerator) Prev() (k int, v int, err error) { - if err = e.err; err != nil { - return - } - - if e.ver != e.t.ver { - f, hit := e.t.Seek(e.k) - if !e.hit && hit { - if err = f.prev(); err != nil { - return - } - } - - *e = *f - f.Close() - } - if e.q == nil { - e.err, err = io.EOF, io.EOF - return - } - - if e.i >= e.q.c { - if err = e.next(); err != nil { - return - } - } - - i := e.q.d[e.i] - k, v = i.k, i.v - e.k, e.hit = k, false - e.prev() - return -} - -func (e *Enumerator) prev() error { - if e.q == nil { - e.err = io.EOF - return io.EOF - } - - switch { - case e.i > 0: - e.i-- - default: - if e.q = e.q.p; e.q == nil { - e.err = io.EOF - break - } - - e.i = e.q.c - 1 - } - return e.err -} diff --git a/Godeps/_workspace/src/github.com/cznic/bufs/AUTHORS b/Godeps/_workspace/src/github.com/cznic/bufs/AUTHORS deleted file mode 100644 index 0078f5f5b6..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/bufs/AUTHORS +++ /dev/null @@ -1,11 +0,0 @@ -# This file lists authors for copyright purposes. This file is distinct from -# the CONTRIBUTORS files. See the latter for an explanation. -# -# Names should be added to this file as: -# Name or Organization -# -# The email address is not required for organizations. -# -# Please keep the list sorted. - -Jan Mercl <0xjnml@gmail.com> diff --git a/Godeps/_workspace/src/github.com/cznic/bufs/CONTRIBUTORS b/Godeps/_workspace/src/github.com/cznic/bufs/CONTRIBUTORS deleted file mode 100644 index 5e86f0607c..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/bufs/CONTRIBUTORS +++ /dev/null @@ -1,9 +0,0 @@ -# This file lists people who contributed code to this repository. The AUTHORS -# file lists the copyright holders; this file lists people. -# -# Names should be added to this file like so: -# Name -# -# Please keep the list sorted. - -Jan Mercl <0xjnml@gmail.com> diff --git a/Godeps/_workspace/src/github.com/cznic/bufs/LICENSE b/Godeps/_workspace/src/github.com/cznic/bufs/LICENSE deleted file mode 100644 index 7d80fe28eb..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/bufs/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2014 The bufs 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 names of the authors nor the names of the -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. diff --git a/Godeps/_workspace/src/github.com/cznic/bufs/Makefile b/Godeps/_workspace/src/github.com/cznic/bufs/Makefile deleted file mode 100644 index c98c23d6df..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/bufs/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 2014 The bufs Authors. All rights reserved. -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file. - -all: clean - go fmt - go test -i - go test - go build - go vet - golint . - go install - make todo - -todo: - @grep -n ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alnum:]] *.go || true - @grep -n TODO *.go || true - @grep -n FIXME *.go || true - @grep -n BUG *.go || true - -clean: - rm -f bufs.test mem.out *~ - -demo: - go test -bench . -benchmem - go test -c - ./bufs.test -test.v -test.run Foo -test.memprofile mem.out \ - -test.memprofilerate 1 - go tool pprof bufs.test mem.out --alloc_space --nodefraction 0.0001 \ - --edgefraction 0 -web - @echo "Note: Foo vs FooBufs allocated memory is in hundreds of MBs vs 8 kB." diff --git a/Godeps/_workspace/src/github.com/cznic/bufs/README.md b/Godeps/_workspace/src/github.com/cznic/bufs/README.md deleted file mode 100644 index 3f3d56f19d..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/bufs/README.md +++ /dev/null @@ -1,8 +0,0 @@ -bufs -==== - -Package bufs implements a simple buffer cache. - - installation: go get github.com/cznic/bufs - -documentation: http://godoc.org/github.com/cznic/bufs diff --git a/Godeps/_workspace/src/github.com/cznic/bufs/bufs.go b/Godeps/_workspace/src/github.com/cznic/bufs/bufs.go deleted file mode 100644 index f4e0eee2a6..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/bufs/bufs.go +++ /dev/null @@ -1,391 +0,0 @@ -// Copyright 2014 The bufs 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 bufs implements a simple buffer cache. -// -// The intended use scheme is like: -// -// type Foo struct { -// buffers bufs.Buffers -// ... -// } -// -// // Bar can call Qux, but not the other way around (in this example). -// const maxFooDepth = 2 -// -// func NewFoo() *Foo { -// return &Foo{buffers: bufs.New(maxFooDepth), ...} -// } -// -// func (f *Foo) Bar(n int) { -// buf := f.buffers.Alloc(n) // needed locally for computation and/or I/O -// defer f.buffers.Free() -// ... -// f.Qux(whatever) -// } -// -// func (f *Foo) Qux(n int) { -// buf := f.buffers.Alloc(n) // needed locally for computation and/or I/O -// defer f.buffers.Free() -// ... -// } -// -// The whole idea behind 'bufs' is that when calling e.g. Foo.Bar N times, then -// normally, without using 'bufs', there will be 2*N (in this example) []byte -// buffers allocated. While using 'bufs', only 2 buffers (in this example) -// will ever be created. For large N it can be a substantial difference. -// -// It's not a good idea to use Buffers to cache too big buffers. The cost of -// having a cached buffer is that the buffer is naturally not eligible for -// garbage collection. Of course, that holds only while the Foo instance is -// reachable, in the above example. -// -// The buffer count limit is intentionally "hard" (read panicking), although -// configurable in New(). The rationale is to prevent recursive calls, using -// Alloc, to cause excessive, "static" memory consumption. Tune the limit -// carefully or do not use Buffers from within [mutually] recursive functions -// where the nesting depth is not realistically bounded to some rather small -// number. -// -// Buffers cannot guarantee improvements to you program performance. There may -// be a gain in case where they fit well. Firm grasp on what your code is -// actually doing, when and in what order is essential to proper use of -// Buffers. It's _highly_ recommended to first do profiling and memory -// profiling before even thinking about using 'bufs'. The real world example, -// and cause for this package, was a first correct, yet no optimizations done -// version of a program; producing few MB of useful data while allocating 20+GB -// of memory. Of course the garbage collector properly kicked in, yet the -// memory abuse caused ~80+% of run time to be spent memory management. The -// program _was_ expected to be slow in its still development phase, but the -// bottleneck was guessed to be in I/O. Actually the hard disk was waiting for -// the billions bytes being allocated and zeroed. Garbage collect on low -// memory, rinse and repeat. -// -// In the provided tests, TestFoo and TestFooBufs do the same simulated work, -// except the later uses Buffers while the former does not. Suggested test runs -// which show the differences: -// -// $ go test -bench . -benchmem -// -// or -// -// $ go test -c -// $ ./bufs.test -test.v -test.run Foo -test.memprofile mem.out -test.memprofilerate 1 -// $ go tool pprof bufs.test mem.out --alloc_space --nodefraction 0.0001 --edgefraction 0 -web -// $ # Note: Foo vs FooBufs allocated memory is in hundreds of MBs vs 8 kB. -// -// or -// -// $ make demo # same as all of the above -// -// -// NOTE: Alloc/Free calls must be properly nested in the same way as in for -// example BeginTransaction/EndTransaction pairs. If your code can panic then -// the pairing should be enforced by deferred calls. -// -// NOTE: Buffers objects do not allocate any space until requested by Alloc, -// the mechanism works on demand only. -// -// FAQ: Why the 'bufs' package name? -// -// Package name 'bufs' was intentionally chosen instead of the perhaps more -// conventional 'buf'. There are already too many 'buf' named things in the -// code out there and that'll be a source of a lot of trouble. It's a bit -// similar situation as in the case of package "strings" (not "string"). -package bufs - -import ( - "errors" - "sort" - "sync" -) - -// Buffers type represents a buffer ([]byte) cache. -// -// NOTE: Do not modify Buffers directly, use only its methods. Do not create -// additional values (copies) of Buffers, that'll break its functionality. Use -// a pointer instead to refer to a single instance from different -// places/scopes. -type Buffers [][]byte - -// New returns a newly created instance of Buffers with a maximum capacity of n -// buffers. -// -// NOTE: 'bufs.New(n)' is the same as 'make(bufs.Buffers, n)'. -func New(n int) Buffers { - return make(Buffers, n) -} - -// Alloc will return a buffer such that len(r) == n. It will firstly try to -// find an existing and unused buffer of big enough size. Only when there is no -// such, then one of the buffer slots is reallocated to a bigger size. -// -// It's okay to use append with buffers returned by Alloc. But it can cause -// allocation in that case and will again be producing load for the garbage -// collector. The best use of Alloc is for I/O buffers where the needed size of -// the buffer is figured out at some point of the code path in a 'final size' -// sense. Another real world example are compression/decompression buffers. -// -// NOTE: The buffer returned by Alloc _is not_ zeroed. That's okay for e.g. -// passing a buffer to io.Reader. If you need a zeroed buffer use Calloc. -// -// NOTE: Buffers returned from Alloc _must not_ be exposed/returned to your -// clients. Those buffers are intended to be used strictly internally, within -// the methods of some "object". -// -// NOTE: Alloc will panic if there are no buffers (buffer slots) left. -func (p *Buffers) Alloc(n int) (r []byte) { - b := *p - if len(b) == 0 { - panic(errors.New("Buffers.Alloc: out of buffers")) - } - - biggest, best, biggestI, bestI := -1, -1, -1, -1 - for i, v := range b { - //ln := len(v) - // The above was correct, buts it's just confusing. It worked - // because not the buffers, but slices of them are returned in - // the 'if best >= n' code path. - ln := cap(v) - - if ln >= biggest { - biggest, biggestI = ln, i - } - - if ln >= n && (bestI < 0 || best > ln) { - best, bestI = ln, i - if ln == n { - break - } - } - } - - last := len(b) - 1 - if best >= n { - r = b[bestI] - b[last], b[bestI] = b[bestI], b[last] - *p = b[:last] - return r[:n] - } - - r = make([]byte, n, overCommit(n)) - b[biggestI] = r - b[last], b[biggestI] = b[biggestI], b[last] - *p = b[:last] - return -} - -// Calloc will acquire a buffer using Alloc and then clears it to zeros. The -// zeroing goes up to n, not cap(r). -func (p *Buffers) Calloc(n int) (r []byte) { - r = p.Alloc(n) - for i := range r { - r[i] = 0 - } - return -} - -// Free makes the lastly allocated by Alloc buffer free (available) again for -// Alloc. -// -// NOTE: Improper Free invocations, like in the sequence {New, Alloc, Free, -// Free}, will panic. -func (p *Buffers) Free() { - b := *p - b = b[:len(b)+1] - *p = b -} - -// Stats reports memory consumed by Buffers, without accounting for some -// (smallish) additional overhead. -func (p *Buffers) Stats() (bytes int) { - b := *p - b = b[:cap(b)] - for _, v := range b { - bytes += cap(v) - } - return -} - -// Cache caches buffers ([]byte). A zero value of Cache is ready for use. -// -// NOTE: Do not modify a Cache directly, use only its methods. Do not create -// additional values (copies) of a Cache, that'll break its functionality. Use -// a pointer instead to refer to a single instance from different -// places/scopes. -type Cache [][]byte - -// Get returns a buffer ([]byte) of length n. If no such buffer is cached then -// a biggest cached buffer is resized to have length n and returned. If there -// are no cached items at all, Get returns a newly allocated buffer. -// -// In other words the cache policy is: -// -// - If the cache is empty, the buffer must be newly created and returned. -// Cache remains empty. -// -// - If a buffer of sufficient size is found in the cache, remove it from the -// cache and return it. -// -// - Otherwise the cache is non empty, but no cached buffer is big enough. -// Enlarge the biggest cached buffer, remove it from the cache and return it. -// This provide cached buffers size adjustment based on demand. -// -// In short, if the cache is not empty, Get guarantees to make it always one -// item less. This rules prevent uncontrolled cache grow in some scenarios. -// The older policy was not preventing that. Another advantage is better cached -// buffers sizes "auto tuning", although not in every possible use case. -// -// NOTE: The buffer returned by Get _is not guaranteed_ to be zeroed. That's -// okay for e.g. passing a buffer to io.Reader. If you need a zeroed buffer -// use Cget. -func (c *Cache) Get(n int) []byte { - r, _ := c.get(n) - return r -} - -func (c *Cache) get(n int) (r []byte, isZeroed bool) { - s := *c - lens := len(s) - if lens == 0 { - r, isZeroed = make([]byte, n, overCommit(n)), true - return - } - - i := sort.Search(lens, func(x int) bool { return len(s[x]) >= n }) - if i == lens { - i-- - s[i] = make([]byte, n, overCommit(n)) - } - r = s[i][:n] - copy(s[i:], s[i+1:]) - s[lens-1] = nil - s = s[:lens-1] - *c = s - return r, false -} - -// Cget will acquire a buffer using Get and then clears it to zeros. The -// zeroing goes up to n, not cap(r). -func (c *Cache) Cget(n int) (r []byte) { - r, ok := c.get(n) - if ok { - return - } - - for i := range r { - r[i] = 0 - } - return -} - -// Put caches b for possible later reuse (via Get). No other references to b's -// backing array may exist. Otherwise a big mess is sooner or later inevitable. -func (c *Cache) Put(b []byte) { - b = b[:cap(b)] - lenb := len(b) - if lenb == 0 { - return - } - - s := *c - lens := len(s) - i := sort.Search(lens, func(x int) bool { return len(s[x]) >= lenb }) - s = append(s, nil) - copy(s[i+1:], s[i:]) - s[i] = b - *c = s - return -} - -// Stats reports memory consumed by a Cache, without accounting for some -// (smallish) additional overhead. 'n' is the number of cached buffers, bytes -// is their combined capacity. -func (c Cache) Stats() (n, bytes int) { - n = len(c) - for _, v := range c { - bytes += cap(v) - } - return -} - -// CCache is a Cache which is safe for concurrent use by multiple goroutines. -type CCache struct { - c Cache - mu sync.Mutex -} - -// Get returns a buffer ([]byte) of length n. If no such buffer is cached then -// a biggest cached buffer is resized to have length n and returned. If there -// are no cached items at all, Get returns a newly allocated buffer. -// -// In other words the cache policy is: -// -// - If the cache is empty, the buffer must be newly created and returned. -// Cache remains empty. -// -// - If a buffer of sufficient size is found in the cache, remove it from the -// cache and return it. -// -// - Otherwise the cache is non empty, but no cached buffer is big enough. -// Enlarge the biggest cached buffer, remove it from the cache and return it. -// This provide cached buffers size adjustment based on demand. -// -// In short, if the cache is not empty, Get guarantees to make it always one -// item less. This rules prevent uncontrolled cache grow in some scenarios. -// The older policy was not preventing that. Another advantage is better cached -// buffers sizes "auto tuning", although not in every possible use case. -// -// NOTE: The buffer returned by Get _is not guaranteed_ to be zeroed. That's -// okay for e.g. passing a buffer to io.Reader. If you need a zeroed buffer -// use Cget. -func (c *CCache) Get(n int) []byte { - c.mu.Lock() - r, _ := c.c.get(n) - c.mu.Unlock() - return r -} - -// Cget will acquire a buffer using Get and then clears it to zeros. The -// zeroing goes up to n, not cap(r). -func (c *CCache) Cget(n int) (r []byte) { - c.mu.Lock() - r = c.c.Cget(n) - c.mu.Unlock() - return -} - -// Put caches b for possible later reuse (via Get). No other references to b's -// backing array may exist. Otherwise a big mess is sooner or later inevitable. -func (c *CCache) Put(b []byte) { - c.mu.Lock() - c.c.Put(b) - c.mu.Unlock() -} - -// Stats reports memory consumed by a Cache, without accounting for some -// (smallish) additional overhead. 'n' is the number of cached buffers, bytes -// is their combined capacity. -func (c *CCache) Stats() (n, bytes int) { - c.mu.Lock() - n, bytes = c.c.Stats() - c.mu.Unlock() - return -} - -// GCache is a ready to use global instance of a CCache. -var GCache CCache - -func overCommit(n int) int { - switch { - case n < 8: - return 8 - case n < 1e5: - return 2 * n - case n < 1e6: - return 3 * n / 2 - default: - return n - } -} diff --git a/Godeps/_workspace/src/github.com/cznic/exp/dbm/LICENSE b/Godeps/_workspace/src/github.com/cznic/exp/dbm/LICENSE deleted file mode 100644 index 80c7ae7fa6..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/exp/dbm/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2014 The dbm 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 names of the authors nor the names of the -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. diff --git a/Godeps/_workspace/src/github.com/cznic/exp/lldb/2pc.go b/Godeps/_workspace/src/github.com/cznic/exp/lldb/2pc.go deleted file mode 100644 index 887604def2..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/exp/lldb/2pc.go +++ /dev/null @@ -1,324 +0,0 @@ -// Copyright 2014 The lldb Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Two Phase Commit & Structural ACID - -package lldb - -import ( - "bufio" - "encoding/binary" - "fmt" - "io" - "os" - - "github.com/cznic/fileutil" - "github.com/cznic/mathutil" -) - -var _ Filer = &ACIDFiler0{} // Ensure ACIDFiler0 is a Filer - -type acidWrite struct { - b []byte - off int64 -} - -type acidWriter0 ACIDFiler0 - -func (a *acidWriter0) WriteAt(b []byte, off int64) (n int, err error) { - f := (*ACIDFiler0)(a) - if f.bwal == nil { // new epoch - f.data = f.data[:0] - f.bwal = bufio.NewWriter(f.wal) - if err = a.writePacket([]interface{}{wpt00Header, walTypeACIDFiler0, ""}); err != nil { - return - } - } - - if err = a.writePacket([]interface{}{wpt00WriteData, b, off}); err != nil { - return - } - - f.data = append(f.data, acidWrite{b, off}) - return len(b), nil -} - -func (a *acidWriter0) writePacket(items []interface{}) (err error) { - f := (*ACIDFiler0)(a) - b, err := EncodeScalars(items...) - if err != nil { - return - } - - var b4 [4]byte - binary.BigEndian.PutUint32(b4[:], uint32(len(b))) - if _, err = f.bwal.Write(b4[:]); err != nil { - return - } - - if _, err = f.bwal.Write(b); err != nil { - return - } - - if m := (4 + len(b)) % 16; m != 0 { - var pad [15]byte - _, err = f.bwal.Write(pad[:16-m]) - } - return -} - -// WAL Packet Tags -const ( - wpt00Header = iota - wpt00WriteData - wpt00Checkpoint -) - -const ( - walTypeACIDFiler0 = iota -) - -// ACIDFiler0 is a very simple, synchronous implementation of 2PC. It uses a -// single write ahead log file to provide the structural atomicity -// (BeginUpdate/EndUpdate/Rollback) and durability (DB can be recovered from -// WAL if a crash occurred). -// -// ACIDFiler0 is a Filer. -// -// NOTE: Durable synchronous 2PC involves three fsyncs in this implementation -// (WAL, DB, zero truncated WAL). Where possible, it's recommended to collect -// transactions for, say one second before performing the two phase commit as -// the typical performance for rotational hard disks is about few tens of -// fsyncs per second atmost. For an example of such collective transaction -// approach please see the colecting FSM STT in Dbm's documentation[1]. -// -// [1]: http://godoc.org/github.com/cznic/exp/dbm -type ACIDFiler0 struct { - *RollbackFiler - wal *os.File - bwal *bufio.Writer - data []acidWrite - testHook bool // keeps WAL untruncated (once) - peakWal int64 // tracks WAL maximum used size - peakBitFilerPages int // track maximum transaction memory -} - -// NewACIDFiler0 returns a newly created ACIDFiler0 with WAL in wal. -// -// If the WAL is zero sized then a previous clean shutdown of db is taken for -// granted and no recovery procedure is taken. -// -// If the WAL is of non zero size then it is checked for having a -// commited/fully finished transaction not yet been reflected in db. If such -// transaction exists it's committed to db. If the recovery process finishes -// successfully, the WAL is truncated to zero size and fsync'ed prior to return -// from NewACIDFiler0. -func NewACIDFiler(db Filer, wal *os.File) (r *ACIDFiler0, err error) { - fi, err := wal.Stat() - if err != nil { - return - } - - r = &ACIDFiler0{wal: wal} - - if fi.Size() != 0 { - if err = r.recoverDb(db); err != nil { - return - } - } - - acidWriter := (*acidWriter0)(r) - - if r.RollbackFiler, err = NewRollbackFiler( - db, - func(sz int64) (err error) { - // Checkpoint - if err = acidWriter.writePacket([]interface{}{wpt00Checkpoint, sz}); err != nil { - return - } - - if err = r.bwal.Flush(); err != nil { - return - } - - r.bwal = nil - - if err = r.wal.Sync(); err != nil { - return - } - - wfi, err := r.wal.Stat() - switch err != nil { - case true: - // unexpected, but ignored - case false: - r.peakWal = mathutil.MaxInt64(wfi.Size(), r.peakWal) - } - - // Phase 1 commit complete - - for _, v := range r.data { - if _, err := db.WriteAt(v.b, v.off); err != nil { - return err - } - } - - if err = db.Truncate(sz); err != nil { - return - } - - if err = db.Sync(); err != nil { - return - } - - // Phase 2 commit complete - - if !r.testHook { - if err = r.wal.Truncate(0); err != nil { - return - } - - if _, err = r.wal.Seek(0, 0); err != nil { - return - } - } - - r.testHook = false - return r.wal.Sync() - - }, - acidWriter, - ); err != nil { - return - } - - return r, nil -} - -// PeakWALSize reports the maximum size WAL has ever used. -func (a ACIDFiler0) PeakWALSize() int64 { - return a.peakWal -} - -func (a *ACIDFiler0) readPacket(f *bufio.Reader) (items []interface{}, err error) { - var b4 [4]byte - n, err := io.ReadAtLeast(f, b4[:], 4) - if n != 4 { - return - } - - ln := int(binary.BigEndian.Uint32(b4[:])) - m := (4 + ln) % 16 - padd := (16 - m) % 16 - b := make([]byte, ln+padd) - if n, err = io.ReadAtLeast(f, b, len(b)); n != len(b) { - return - } - - return DecodeScalars(b[:ln]) -} - -func (a *ACIDFiler0) recoverDb(db Filer) (err error) { - fi, err := a.wal.Stat() - if err != nil { - return &ErrILSEQ{Type: ErrInvalidWAL, Name: a.wal.Name(), More: err} - } - - if sz := fi.Size(); sz%16 != 0 { - return &ErrILSEQ{Type: ErrFileSize, Name: a.wal.Name(), Arg: sz} - } - - f := bufio.NewReader(a.wal) - items, err := a.readPacket(f) - if err != nil { - return - } - - if len(items) != 3 || items[0] != int64(wpt00Header) || items[1] != int64(walTypeACIDFiler0) { - return &ErrILSEQ{Type: ErrInvalidWAL, Name: a.wal.Name(), More: fmt.Sprintf("invalid packet items %#v", items)} - } - - tr := NewBTree(nil) - - for { - items, err = a.readPacket(f) - if err != nil { - return - } - - if len(items) < 2 { - return &ErrILSEQ{Type: ErrInvalidWAL, Name: a.wal.Name(), More: fmt.Sprintf("too few packet items %#v", items)} - } - - switch items[0] { - case int64(wpt00WriteData): - if len(items) != 3 { - return &ErrILSEQ{Type: ErrInvalidWAL, Name: a.wal.Name(), More: fmt.Sprintf("invalid data packet items %#v", items)} - } - - b, off := items[1].([]byte), items[2].(int64) - var key [8]byte - binary.BigEndian.PutUint64(key[:], uint64(off)) - if err = tr.Set(key[:], b); err != nil { - return - } - case int64(wpt00Checkpoint): - var b1 [1]byte - if n, err := f.Read(b1[:]); n != 0 || err == nil { - return &ErrILSEQ{Type: ErrInvalidWAL, Name: a.wal.Name(), More: fmt.Sprintf("checkpoint n %d, err %v", n, err)} - } - - if len(items) != 2 { - return &ErrILSEQ{Type: ErrInvalidWAL, Name: a.wal.Name(), More: fmt.Sprintf("checkpoint packet invalid items %#v", items)} - } - - sz := items[1].(int64) - enum, err := tr.seekFirst() - if err != nil { - return err - } - - for { - k, v, err := enum.current() - if err != nil { - if fileutil.IsEOF(err) { - break - } - - return err - } - - if _, err = db.WriteAt(v, int64(binary.BigEndian.Uint64(k))); err != nil { - return err - } - - if err = enum.next(); err != nil { - if fileutil.IsEOF(err) { - break - } - - return err - } - } - - if err = db.Truncate(sz); err != nil { - return err - } - - if err = db.Sync(); err != nil { - return err - } - - // Recovery complete - - if err = a.wal.Truncate(0); err != nil { - return err - } - - return a.wal.Sync() - default: - return &ErrILSEQ{Type: ErrInvalidWAL, Name: a.wal.Name(), More: fmt.Sprintf("packet tag %v", items[0])} - } - } -} diff --git a/Godeps/_workspace/src/github.com/cznic/exp/lldb/2pc_docs.go b/Godeps/_workspace/src/github.com/cznic/exp/lldb/2pc_docs.go deleted file mode 100644 index 02c993b8ba..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/exp/lldb/2pc_docs.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2014 The lldb Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -/* - -Anatomy of a WAL file - -WAL file - A sequence of packets - -WAL packet, parts in slice notation - [0:4], 4 bytes: N uint32 // network byte order - [4:4+N], N bytes: payload []byte // gb encoded scalars - -Packets, including the 4 byte 'size' prefix, MUST BE padded to size == 0 (mod -16). The values of the padding bytes MUST BE zero. - -Encoded scalars first item is a packet type number (packet tag). The meaning of -any other item(s) of the payload depends on the packet tag. - -Packet definitions - - {wpt00Header int, typ int, s string} - typ: Must be zero (ACIDFiler0 file). - s: Any comment string, empty string is okay. - - This packet must be present only once - as the first packet of - a WAL file. - - {wpt00WriteData int, b []byte, off int64} - Write data (WriteAt(b, off)). - - {wpt00Checkpoint int, sz int64} - Checkpoint (Truncate(sz)). - - This packet must be present only once - as the last packet of - a WAL file. - -*/ - -package lldb - -//TODO optimize bitfiler/wal/2pc data above final size diff --git a/Godeps/_workspace/src/github.com/cznic/exp/lldb/AUTHORS b/Godeps/_workspace/src/github.com/cznic/exp/lldb/AUTHORS deleted file mode 100644 index 0078f5f5b6..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/exp/lldb/AUTHORS +++ /dev/null @@ -1,11 +0,0 @@ -# This file lists authors for copyright purposes. This file is distinct from -# the CONTRIBUTORS files. See the latter for an explanation. -# -# Names should be added to this file as: -# Name or Organization -# -# The email address is not required for organizations. -# -# Please keep the list sorted. - -Jan Mercl <0xjnml@gmail.com> diff --git a/Godeps/_workspace/src/github.com/cznic/exp/lldb/CONTRIBUTORS b/Godeps/_workspace/src/github.com/cznic/exp/lldb/CONTRIBUTORS deleted file mode 100644 index 5e86f0607c..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/exp/lldb/CONTRIBUTORS +++ /dev/null @@ -1,9 +0,0 @@ -# This file lists people who contributed code to this repository. The AUTHORS -# file lists the copyright holders; this file lists people. -# -# Names should be added to this file like so: -# Name -# -# Please keep the list sorted. - -Jan Mercl <0xjnml@gmail.com> diff --git a/Godeps/_workspace/src/github.com/cznic/exp/lldb/LICENSE b/Godeps/_workspace/src/github.com/cznic/exp/lldb/LICENSE deleted file mode 100644 index 27e4447a49..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/exp/lldb/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2014 The lldb 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 names of the authors nor the names of the -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. diff --git a/Godeps/_workspace/src/github.com/cznic/exp/lldb/Makefile b/Godeps/_workspace/src/github.com/cznic/exp/lldb/Makefile deleted file mode 100644 index cd8248a8e5..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/exp/lldb/Makefile +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2014 The lldb Authors. All rights reserved. -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file. - -.PHONY: all editor clean cover nuke - -testbin=lldb.test -grep=--include=*.go - -all: editor - go build - go vet - golint . - go install - make todo - -clean: - go clean - rm -f *~ cov cov.html bad-dump good-dump lldb.test old.txt new.txt \ - test-acidfiler0-* _test.db _wal - -cover: - t=$(shell tempfile) ; go test -coverprofile $$t && go tool cover -html $$t && unlink $$t - -editor: - go fmt - go test -i - go test -timeout 1h - -mem: - go test -c - ./$(testbin) -test.bench . -test.memprofile mem.out -test.memprofilerate 1 -test.timeout 24h - go tool pprof --lines --web --alloc_space $(testbin) mem.out - -nuke: clean - go clean -i - -todo: - @grep -nr $(grep) BUG * || true - @grep -nr $(grep) LATER * || true - @grep -nr $(grep) MAYBE * || true - @grep -nr $(grep) TODO * || true - @grep -nr $(grep) FIXME * || true - @grep -nr $(grep) ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* * || true - @grep -nr $(grep) println * || true diff --git a/Godeps/_workspace/src/github.com/cznic/exp/lldb/README.md b/Godeps/_workspace/src/github.com/cznic/exp/lldb/README.md deleted file mode 100644 index 470bf541d0..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/exp/lldb/README.md +++ /dev/null @@ -1,8 +0,0 @@ -lldb -==== - -Package lldb (WIP) implements a low level database engine. - -Installation: $ go get github.com/cznic/exp/lldb - -Documentation: [godoc.org/github.com/cznic/exp/lldb](http://godoc.org/github.com/cznic/exp/lldb) diff --git a/Godeps/_workspace/src/github.com/cznic/exp/lldb/btree.go b/Godeps/_workspace/src/github.com/cznic/exp/lldb/btree.go deleted file mode 100644 index 57b0f39c62..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/exp/lldb/btree.go +++ /dev/null @@ -1,2297 +0,0 @@ -// Copyright 2014 The lldb 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 lldb - -import ( - "bytes" - "errors" - "fmt" - "io" - "sort" - "strings" - - "github.com/cznic/bufs" - "github.com/cznic/fileutil" - "github.com/cznic/sortutil" -) - -const ( - kData = 256 // [1, 512] - kIndex = 256 // [2, 2048] - kKV = 19 // Size of the key/value field in btreeDataPage - kSz = kKV - 1 - 7 // Content prefix size - kH = kKV - 7 // Content field offset for handle - tagBTreeDataPage = 1 - tagBTreeIndexPage = 0 -) - -// BTree is a B+tree[1][2], i.e. a variant which speeds up -// enumeration/iteration of the BTree. According to its origin it can be -// volatile (backed only by memory) or non-volatile (backed by a non-volatile -// Allocator). -// -// The specific implementation of BTrees in this package are B+trees with -// delayed split/concatenation (discussed in e.g. [3]). -// -// Note: No BTree methods returns io.EOF for physical Filer reads/writes. The -// io.EOF is returned only by bTreeEnumerator methods to indicate "no more K-V -// pair". -// -// [1]: http://en.wikipedia.org/wiki/B+tree -// [2]: http://zgking.com:8080/home/donghui/publications/books/dshandbook_BTree.pdf -// [3]: http://people.cs.aau.dk/~simas/aalg06/UbiquitBtree.pdf -type BTree struct { - store btreeStore - root btree - collate func(a, b []byte) int - serial uint64 -} - -// NewBTree returns a new, memory-only BTree. -func NewBTree(collate func(a, b []byte) int) *BTree { - store := newMemBTreeStore() - root, err := newBTree(store) - if err != nil { // should not happen - panic(err.Error()) - } - - return &BTree{store, root, collate, 0} -} - -// IsMem reports if t is a memory only BTree. -func (t *BTree) IsMem() (r bool) { - _, r = t.store.(*memBTreeStore) - return -} - -// Clear empties the tree. -func (t *BTree) Clear() (err error) { - if t == nil { - err = errors.New("BTree method invoked on nil receiver") - return - } - - t.serial++ - return t.root.clear(t.store) -} - -// Delete deletes key and its associated value from the tree. -func (t *BTree) Delete(key []byte) (err error) { - if t == nil { - err = errors.New("BTree method invoked on nil receiver") - return - } - - t.serial++ - _, err = t.root.extract(t.store, nil, t.collate, key) - return -} - -// DeleteAny deletes one key and its associated value from the tree. If the -// tree is empty on return then empty is true. -func (t *BTree) DeleteAny() (empty bool, err error) { - if t == nil { - err = errors.New("BTree method invoked on nil receiver") - return - } - - t.serial++ - return t.root.deleteAny(t.store) -} - -func elem(v interface{}) string { - switch x := v.(type) { - default: - panic("internal error") - case nil: - return "nil" - case bool: - if x { - return "true" - } - - return "false" - case int64: - return fmt.Sprint(x) - case uint64: - return fmt.Sprint(x) - case float64: - s := fmt.Sprintf("%g", x) - if !strings.Contains(s, ".") { - s += "." - } - return s - case complex128: - s := fmt.Sprint(x) - return s[1 : len(s)-1] - case []byte: - return fmt.Sprintf("[]byte{% 02x}", x) - case string: - return fmt.Sprintf("%q", x) - } -} - -// Dump outputs a human readable dump of t to w. It is usable iff t keys and -// values are encoded scalars (see EncodeScalars). Intended use is only for -// examples or debugging. Some type information is lost in the rendering, for -// example a float value '17.' and an integer value '17' may both output as -// '17'. -func (t *BTree) Dump(w io.Writer) (err error) { - enum, err := t.seekFirst() - if err != nil { - return - } - - for { - bkey, bval, err := enum.current() - if err != nil { - return err - } - - key, err := DecodeScalars(bkey) - if err != nil { - return err - } - - val, err := DecodeScalars(bval) - if err != nil { - return err - } - - kk := []string{} - if key == nil { - kk = []string{"null"} - } - for _, v := range key { - kk = append(kk, elem(v)) - } - vv := []string{} - if val == nil { - vv = []string{"null"} - } - for _, v := range val { - vv = append(vv, elem(v)) - } - skey := strings.Join(kk, ", ") - sval := strings.Join(vv, ", ") - if len(vv) > 1 { - sval = fmt.Sprintf("[]interface{%s}", sval) - } - if _, err = fmt.Fprintf(w, "%s → %s\n", skey, sval); err != nil { - return err - } - - err = enum.next() - if err != nil { - if fileutil.IsEOF(err) { - err = nil - break - } - - return err - } - } - return -} - -// Extract is a combination of Get and Delete. If the key exists in the tree, -// it is returned (like Get) and also deleted from a tree in a more efficient -// way which doesn't walk it twice. The returned slice may be a sub-slice of -// buf if buf was large enough to hold the entire content. Otherwise, a newly -// allocated slice will be returned. It is valid to pass a nil buf. -func (t *BTree) Extract(buf, key []byte) (value []byte, err error) { - if t == nil { - err = errors.New("BTree method invoked on nil receiver") - return - } - - t.serial++ - return t.root.extract(t.store, buf, t.collate, key) -} - -// First returns the first KV pair of the tree, if it exists. Otherwise key == nil -// and value == nil. -func (t *BTree) First() (key, value []byte, err error) { - if t == nil { - err = errors.New("BTree method invoked on nil receiver") - return - } - - var p btreeDataPage - if _, p, err = t.root.first(t.store); err != nil || p == nil { - return - } - - if key, err = p.key(t.store, 0); err != nil { - return - } - - value, err = p.value(t.store, 0) - return -} - -// Get returns the value associated with key, or nil if no such value exists. -// The returned slice may be a sub-slice of buf if buf was large enough to hold -// the entire content. Otherwise, a newly allocated slice will be returned. -// It is valid to pass a nil buf. -// -// Get is safe for concurrent access by multiple goroutines iff no other -// goroutine mutates the tree. -func (t *BTree) Get(buf, key []byte) (value []byte, err error) { - if t == nil { - err = errors.New("BTree method invoked on nil receiver") - return - } - - buffer := bufs.GCache.Get(maxBuf) - defer bufs.GCache.Put(buffer) - if buffer, err = t.root.get(t.store, buffer, t.collate, key); buffer == nil || err != nil { - return - } - - value = need(len(buffer), buf) - copy(value, buffer) - return -} - -// Handle reports t's handle. -func (t *BTree) Handle() int64 { - return int64(t.root) -} - -// Last returns the last KV pair of the tree, if it exists. Otherwise key == nil -// and value == nil. -func (t *BTree) Last() (key, value []byte, err error) { - if t == nil { - err = errors.New("BTree method invoked on nil receiver") - return - } - - var p btreeDataPage - if _, p, err = t.root.last(t.store); err != nil || p == nil { - return - } - - index := p.len() - 1 - if key, err = p.key(t.store, index); err != nil { - return - } - - value, err = p.value(t.store, index) - return -} - -// Put combines Get and Set in a more efficient way where the tree is walked -// only once. The upd(ater) receives the current (key, old-value), if that -// exists or (key, nil) otherwise. It can then return a (new-value, true, nil) -// to create or overwrite the existing value in the KV pair, or (whatever, -// false, nil) if it decides not to create or not to update the value of the KV -// pair. -// -// tree.Set(k, v) -// -// conceptually equals -// -// tree.Put(k, func(k, v []byte){ return v, true }([]byte, bool)) -// -// modulo the differing return values. -// -// The returned slice may be a sub-slice of buf if buf was large enough to hold -// the entire content. Otherwise, a newly allocated slice will be returned. -// It is valid to pass a nil buf. -func (t *BTree) Put(buf, key []byte, upd func(key, old []byte) (new []byte, write bool, err error)) (old []byte, written bool, err error) { - if t == nil { - err = errors.New("BTree method invoked on nil receiver") - return - } - - t.serial++ - return t.root.put2(buf, t.store, t.collate, key, upd) -} - -// Seek returns an Enumerator with "position" or an error of any. Normally the -// position is on a KV pair such that key >= KV.key. Then hit is key == KV.key. -// The position is possibly "after" the last KV pair, but that is not an error. -// -// Seek is safe for concurrent access by multiple goroutines iff no other -// goroutine mutates the tree. -func (t *BTree) Seek(key []byte) (enum *BTreeEnumerator, hit bool, err error) { - enum0, hit, err := t.seek(key) - if err != nil { - return - } - - enum = &BTreeEnumerator{ - enum: enum0, - firstHit: hit, - key: append([]byte(nil), key...), - } - return -} - -func (t *BTree) seek(key []byte) (enum *bTreeEnumerator, hit bool, err error) { - if t == nil { - err = errors.New("BTree method invoked on nil receiver") - return - } - - r := &bTreeEnumerator{t: t, collate: t.collate, serial: t.serial} - if r.p, r.index, hit, err = t.root.seek(t.store, r.collate, key); err != nil { - return - } - - enum = r - return -} - -// IndexSeek returns an Enumerator with "position" or an error of any. Normally -// the position is on a KV pair such that key >= KV.key. Then hit is key == -// KV.key. The position is possibly "after" the last KV pair, but that is not -// an error. The collate function originally passed to CreateBTree is used for -// enumerating the tree but a custom collate function c is used for IndexSeek. -// -// IndexSeek is safe for concurrent access by multiple goroutines iff no other -// goroutine mutates the tree. -func (t *BTree) IndexSeek(key []byte, c func(a, b []byte) int) (enum *BTreeEnumerator, hit bool, err error) { //TODO +test - enum0, hit, err := t.indexSeek(key, c) - if err != nil { - return - } - - enum = &BTreeEnumerator{ - enum: enum0, - firstHit: hit, - key: append([]byte(nil), key...), - } - return -} - -func (t *BTree) indexSeek(key []byte, c func(a, b []byte) int) (enum *bTreeEnumerator, hit bool, err error) { - if t == nil { - err = errors.New("BTree method invoked on nil receiver") - return - } - - r := &bTreeEnumerator{t: t, collate: t.collate, serial: t.serial} - if r.p, r.index, hit, err = t.root.seek(t.store, c, key); err != nil { - return - } - - enum = r - return -} - -// seekFirst returns an enumerator positioned on the first KV pair in the tree, -// if any. For an empty tree, err == io.EOF is returend. -// -// SeekFirst is safe for concurrent access by multiple goroutines iff no other -// goroutine mutates the tree. -func (t *BTree) SeekFirst() (enum *BTreeEnumerator, err error) { - enum0, err := t.seekFirst() - if err != nil { - return - } - - var key []byte - if key, _, err = enum0.current(); err != nil { - return - } - - enum = &BTreeEnumerator{ - enum: enum0, - firstHit: true, - key: append([]byte(nil), key...), - } - return -} - -func (t *BTree) seekFirst() (enum *bTreeEnumerator, err error) { - if t == nil { - err = errors.New("BTree method invoked on nil receiver") - return - } - - var p btreeDataPage - if _, p, err = t.root.first(t.store); err == nil && p == nil { - err = io.EOF - } - if err != nil { - return - } - - return &bTreeEnumerator{t: t, collate: t.collate, p: p, index: 0, serial: t.serial}, nil -} - -// seekLast returns an enumerator positioned on the last KV pair in the tree, -// if any. For an empty tree, err == io.EOF is returend. -// -// SeekLast is safe for concurrent access by multiple goroutines iff no other -// goroutine mutates the tree. -func (t *BTree) SeekLast() (enum *BTreeEnumerator, err error) { - enum0, err := t.seekLast() - if err != nil { - return - } - - var key []byte - if key, _, err = enum0.current(); err != nil { - return - } - - enum = &BTreeEnumerator{ - enum: enum0, - firstHit: true, - key: append([]byte(nil), key...), - } - return -} - -func (t *BTree) seekLast() (enum *bTreeEnumerator, err error) { - if t == nil { - err = errors.New("BTree method invoked on nil receiver") - return - } - - var p btreeDataPage - if _, p, err = t.root.last(t.store); err == nil && p == nil { - err = io.EOF - } - if err != nil { - return - } - - return &bTreeEnumerator{t: t, collate: t.collate, p: p, index: p.len() - 1, serial: t.serial}, nil -} - -// Set sets the value associated with key. Any previous value, if existed, is -// overwritten by the new one. -func (t *BTree) Set(key, value []byte) (err error) { - if t == nil { - err = errors.New("BTree method invoked on nil receiver") - return - } - - t.serial++ - dst := bufs.GCache.Get(maxBuf) - _, err = t.root.put(dst, t.store, t.collate, key, value, true) - bufs.GCache.Put(dst) - return -} - -// bTreeEnumerator is a closure of a BTree and a position. It is returned from -// BTree.seek. -// -// NOTE: bTreeEnumerator cannot be used after its BTree was mutated after the -// bTreeEnumerator was acquired from any of the seek, seekFirst, seekLast -// methods. -type bTreeEnumerator struct { - t *BTree - collate func(a, b []byte) int - p btreeDataPage - index int - serial uint64 -} - -// Current returns the KV pair the enumerator is currently positioned on. If -// the position is before the first KV pair in the tree or after the last KV -// pair in the tree then err == io.EOF is returned. -// -// If the enumerator has been invalidated by updating the tree, ErrINVAL is -// returned. -func (e *bTreeEnumerator) current() (key, value []byte, err error) { - if e == nil { - err = errors.New("bTreeEnumerator method invoked on nil receiver") - return - } - - if e.serial != e.t.serial { - err = &ErrINVAL{Src: "bTreeEnumerator invalidated by updating the tree"} - return - } - - if e.p == nil || e.index == e.p.len() { - return nil, nil, io.EOF - } - - if key, err = e.p.key(e.t.store, e.index); err != nil { - return - } - - value, err = e.p.value(e.t.store, e.index) - return -} - -// Next attempts to position the enumerator onto the next KV pair wrt the -// current position. If there is no "next" KV pair, io.EOF is returned. -// -// If the enumerator has been invalidated by updating the tree, ErrINVAL is -// returned. -func (e *bTreeEnumerator) next() (err error) { - if e == nil { - err = errors.New("bTreeEnumerator method invoked on nil receiver") - return - } - - if e.serial != e.t.serial { - err = &ErrINVAL{Src: "bTreeEnumerator invalidated by updating the tree"} - return - } - - if e.p == nil { - return io.EOF - } - - switch { - case e.index < e.p.len()-1: - e.index++ - default: - ph := e.p.next() - if ph == 0 { - err = io.EOF - break - } - - if e.p, err = e.t.store.Get(e.p, ph); err != nil { - e.p = nil - return - } - e.index = 0 - } - return -} - -// Prev attempts to position the enumerator onto the previous KV pair wrt the -// current position. If there is no "previous" KV pair, io.EOF is returned. -// -// If the enumerator has been invalidated by updating the tree, ErrINVAL is -// returned. -func (e *bTreeEnumerator) prev() (err error) { - if e == nil { - err = errors.New("bTreeEnumerator method invoked on nil receiver") - return - } - - if e.serial != e.t.serial { - err = &ErrINVAL{Src: "bTreeEnumerator invalidated by updating the tree"} - return - } - - if e.p == nil { - return io.EOF - } - - switch { - case e.index > 0: - e.index-- - default: - ph := e.p.prev() - if ph == 0 { - err = io.EOF - break - } - - if e.p, err = e.t.store.Get(e.p, ph); err != nil { - e.p = nil - return - } - e.index = e.p.len() - 1 - } - return -} - -// BTreeEnumerator captures the state of enumerating a tree. It is returned -// from the Seek* methods. The enumerator is aware of any mutations made to -// the tree in the process of enumerating it and automatically resumes the -// enumeration. -type BTreeEnumerator struct { - enum *bTreeEnumerator - err error - key []byte - firstHit bool -} - -// Next returns the currently enumerated KV pair, if it exists and moves to the -// next KV in the key collation order. If there is no KV pair to return, err == -// io.EOF is returned. -// -// Next is safe for concurrent access by multiple goroutines iff no other -// goroutine mutates the tree. -func (e *BTreeEnumerator) Next() (key, value []byte, err error) { - if err = e.err; err != nil { - return - } - - canRetry := true -retry: - if key, value, err = e.enum.current(); err != nil { - if _, ok := err.(*ErrINVAL); !ok || !canRetry { - e.err = err - return - } - - canRetry = false - var hit bool - if e.enum, hit, err = e.enum.t.seek(e.key); err != nil { - e.err = err - return - } - - if !e.firstHit && hit { - err = e.enum.next() - if err != nil { - e.err = err - return - } - } - - goto retry - } - - e.firstHit = false - e.key = append([]byte(nil), key...) - e.err = e.enum.next() - return -} - -// Prev returns the currently enumerated KV pair, if it exists and moves to the -// previous KV in the key collation order. If there is no KV pair to return, -// err == io.EOF is returned. -// -// Prev is safe for concurrent access by multiple goroutines iff no other -// goroutine mutates the tree. -func (e *BTreeEnumerator) Prev() (key, value []byte, err error) { - if err = e.err; err != nil { - return - } - - canRetry := true -retry: - if key, value, err = e.enum.current(); err != nil { - if _, ok := err.(*ErrINVAL); !ok || !canRetry { - e.err = err - return - } - - canRetry = false - var hit bool - if e.enum, hit, err = e.enum.t.seek(e.key); err != nil { - e.err = err - return - } - - if !e.firstHit && hit { - err = e.enum.prev() - if err != nil { - e.err = err - return - } - } - - goto retry - } - - e.firstHit = false - e.key = append([]byte(nil), key...) - e.err = e.enum.prev() - return -} - -// CreateBTree creates a new BTree in store. It returns the tree, its (freshly -// assigned) handle (for OpenBTree or RemoveBTree) or an error, if any. -func CreateBTree(store *Allocator, collate func(a, b []byte) int) (bt *BTree, handle int64, err error) { - r := &BTree{store: store, collate: collate} - if r.root, err = newBTree(store); err != nil { - return - } - - return r, int64(r.root), nil -} - -// OpenBTree opens a store's BTree using handle. It returns the tree or an -// error, if any. The same tree may be opened more than once, but operations on -// the separate instances should not ever overlap or void the other instances. -// However, the intended API usage is to open the same tree handle only once -// (handled by some upper layer "dispatcher"). -func OpenBTree(store *Allocator, collate func(a, b []byte) int, handle int64) (bt *BTree, err error) { - r := &BTree{store: store, root: btree(handle), collate: collate} - b := bufs.GCache.Get(7) - defer bufs.GCache.Put(b) - if b, err = store.Get(b, handle); err != nil { - return - } - - if len(b) != 7 { - return nil, &ErrILSEQ{Off: h2off(handle), More: "btree.go:671"} - } - - return r, nil -} - -// RemoveBTree removes tree, represented by handle from store. Empty trees are -// cheap, each uses only few bytes of the store. If there's a chance that a -// tree will eventually get reused (non empty again), it's recommended to -// not/never remove it. One advantage of such approach is a stable handle of -// such tree. -func RemoveBTree(store *Allocator, handle int64) (err error) { - tree, err := OpenBTree(store, nil, handle) - if err != nil { - return - } - - if err = tree.Clear(); err != nil { - return - } - - return store.Free(handle) -} - -type btreeStore interface { - Alloc(b []byte) (handle int64, err error) - Free(handle int64) (err error) - Get(dst []byte, handle int64) (b []byte, err error) - Realloc(handle int64, b []byte) (err error) -} - -// Read only zero bytes -var zeros [2 * kKV]byte - -func init() { - if kData < 1 || kData > 512 { - panic(fmt.Errorf("kData %d: out of limits", kData)) - } - - if kIndex < 2 || kIndex > 2048 { - panic(fmt.Errorf("kIndex %d: out of limits", kIndex)) - } - - if kKV < 8 || kKV > 23 { - panic(fmt.Errorf("kKV %d: out of limits", kKV)) - } - - if n := len(zeros); n < 15 { - panic(fmt.Errorf("not enough zeros: %d", n)) - } -} - -type memBTreeStore struct { - h int64 - m map[int64][]byte -} - -func newMemBTreeStore() *memBTreeStore { - return &memBTreeStore{h: 0, m: map[int64][]byte{}} -} - -func (s *memBTreeStore) String() string { - var a sortutil.Int64Slice - for k := range s.m { - a = append(a, k) - } - sort.Sort(a) - var sa []string - for _, k := range a { - sa = append(sa, fmt.Sprintf("%#x:|% x|", k, s.m[k])) - } - return strings.Join(sa, "\n") -} - -func (s *memBTreeStore) Alloc(b []byte) (handle int64, err error) { - s.h++ - handle = s.h - s.m[handle] = bpack(b) - return -} - -func (s *memBTreeStore) Free(handle int64) (err error) { - if _, ok := s.m[handle]; !ok { - return &ErrILSEQ{Type: ErrOther, Off: h2off(handle), More: "btree.go:754"} - } - - delete(s.m, handle) - return -} - -func (s *memBTreeStore) Get(dst []byte, handle int64) (b []byte, err error) { - r, ok := s.m[handle] - if !ok { - return nil, &ErrILSEQ{Type: ErrOther, Off: h2off(handle), More: "btree.go:764"} - } - - b = need(len(r), dst) - copy(b, r) - return -} - -func (s *memBTreeStore) Realloc(handle int64, b []byte) (err error) { - if _, ok := s.m[handle]; !ok { - return &ErrILSEQ{Type: ErrOther, Off: h2off(handle), More: "btree.go:774"} - } - - s.m[handle] = bpack(b) - return -} - -/* - -0...0 (1 bytes): -Flag - - 0 - +---+ - | 0 | - +---+ - -0 indicates an index page - -1...count*14-1 -"array" of items, 14 bytes each. Count of items in kIndex-1..2*kIndex+2 - - Count = (len(raw) - 8) / 14 - - 0..6 7..13 - +-------+----------+ - | Child | DataPage | - +-------+----------+ - - Child == handle of a child index page - DataPage == handle of a data page - -Offsets into the raw []byte: -Child[X] == 1+14*X -DataPage[X] == 8+14*X - -*/ -type btreeIndexPage []byte - -func newBTreeIndexPage(leftmostChild int64) (p btreeIndexPage) { - p = bufs.GCache.Get(1 + (kIndex+1)*2*7)[:8] - p[0] = tagBTreeIndexPage - h2b(p[1:], leftmostChild) - return -} - -func (p btreeIndexPage) len() int { - return (len(p) - 8) / 14 -} - -func (p btreeIndexPage) child(index int) int64 { - return b2h(p[1+14*index:]) -} - -func (p btreeIndexPage) setChild(index int, dp int64) { - h2b(p[1+14*index:], dp) -} - -func (p btreeIndexPage) dataPage(index int) int64 { - return b2h(p[8+14*index:]) -} - -func (p btreeIndexPage) setDataPage(index int, dp int64) { - h2b(p[8+14*index:], dp) -} - -func (q btreeIndexPage) insert(index int) btreeIndexPage { - switch len0 := q.len(); { - case index < len0: - has := len(q) - need := has + 14 - switch { - case cap(q) >= need: - q = q[:need] - default: - q = append(q, zeros[:14]...) - } - copy(q[8+14*(index+1):8+14*(index+1)+2*(len0-index)*7], q[8+14*index:]) - case index == len0: - has := len(q) - need := has + 14 - switch { - case cap(q) >= need: - q = q[:need] - default: - q = append(q, zeros[:14]...) - } - } - return q -} - -func (p btreeIndexPage) insert3(index int, dataPage, child int64) btreeIndexPage { - p = p.insert(index) - p.setDataPage(index, dataPage) - p.setChild(index+1, child) - return p -} - -func (p btreeIndexPage) cmp(a btreeStore, c func(a, b []byte) int, keyA []byte, keyBIndex int) (int, error) { - b := bufs.GCache.Get(maxBuf) - defer bufs.GCache.Put(b) - dp, err := a.Get(b, p.dataPage(keyBIndex)) - if err != nil { - return 0, err - } - - return btreeDataPage(dp).cmp(a, c, keyA, 0) -} - -func (q btreeIndexPage) setLen(n int) btreeIndexPage { - q = q[:cap(q)] - need := 8 + 14*n - if need < len(q) { - return q[:need] - } - return append(q, make([]byte, need-len(q))...) -} - -func (p btreeIndexPage) split(a btreeStore, root btree, ph *int64, parent int64, parentIndex int, index *int) (btreeIndexPage, error) { - right := newBTreeIndexPage(0) - canRecycle := true - defer func() { - if canRecycle { - bufs.GCache.Put(right) - } - }() - right = right.setLen(kIndex) - copy(right[1:1+(2*kIndex+1)*7], p[1+14*(kIndex+1):]) - p = p.setLen(kIndex) - if err := a.Realloc(*ph, p); err != nil { - return nil, err - } - - rh, err := a.Alloc(right) - if err != nil { - return nil, err - } - - if parentIndex >= 0 { - var pp btreeIndexPage = bufs.GCache.Get(maxBuf) - defer bufs.GCache.Put(pp) - if pp, err = a.Get(pp, parent); err != nil { - return nil, err - } - pp = pp.insert3(parentIndex, p.dataPage(kIndex), rh) - if err = a.Realloc(parent, pp); err != nil { - return nil, err - } - - } else { - nr := newBTreeIndexPage(*ph) - defer bufs.GCache.Put(nr) - nr = nr.insert3(0, p.dataPage(kIndex), rh) - nrh, err := a.Alloc(nr) - if err != nil { - return nil, err - } - - if err = a.Realloc(int64(root), h2b(make([]byte, 7), nrh)); err != nil { - return nil, err - } - } - if *index > kIndex { - p = right - canRecycle = false - *ph = rh - *index -= kIndex + 1 - } - return p, nil -} - -// p is dirty on return -func (p btreeIndexPage) extract(index int) btreeIndexPage { - n := p.len() - 1 - if index < n { - sz := (n-index)*14 + 7 - copy(p[1+14*index:1+14*index+sz], p[1+14*(index+1):]) - } - return p.setLen(n) -} - -// must persist all changes made -func (p btreeIndexPage) underflow(a btreeStore, root, iroot, parent int64, ph *int64, parentIndex int, index *int) (btreeIndexPage, error) { - lh, rh, err := checkSiblings(a, parent, parentIndex) - if err != nil { - return nil, err - } - - var left btreeIndexPage = bufs.GCache.Get(maxBuf) - defer bufs.GCache.Put(left) - - if lh != 0 { - if left, err = a.Get(left, lh); err != nil { - return nil, err - } - - if lc := btreeIndexPage(left).len(); lc > kIndex { - var pp = bufs.GCache.Get(maxBuf) - defer bufs.GCache.Put(pp) - if pp, err = a.Get(pp, parent); err != nil { - return nil, err - } - - pc := p.len() - p = p.setLen(pc + 1) - di, si, sz := 1+1*14, 1+0*14, (2*pc+1)*7 - copy(p[di:di+sz], p[si:]) - p.setChild(0, btreeIndexPage(left).child(lc)) - p.setDataPage(0, btreeIndexPage(pp).dataPage(parentIndex-1)) - *index++ - btreeIndexPage(pp).setDataPage(parentIndex-1, btreeIndexPage(left).dataPage(lc-1)) - left = left.setLen(lc - 1) - if err = a.Realloc(parent, pp); err != nil { - return nil, err - } - - if err = a.Realloc(*ph, p); err != nil { - return nil, err - } - - return p, a.Realloc(lh, left) - } - } - - if rh != 0 { - right := bufs.GCache.Get(maxBuf) - defer bufs.GCache.Put(right) - if right, err = a.Get(right, rh); err != nil { - return nil, err - } - - if rc := btreeIndexPage(right).len(); rc > kIndex { - pp := bufs.GCache.Get(maxBuf) - defer bufs.GCache.Put(pp) - if pp, err = a.Get(pp, parent); err != nil { - return nil, err - } - - pc := p.len() - p = p.setLen(pc + 1) - p.setDataPage(pc, btreeIndexPage(pp).dataPage(parentIndex)) - pc++ - p.setChild(pc, btreeIndexPage(right).child(0)) - btreeIndexPage(pp).setDataPage(parentIndex, btreeIndexPage(right).dataPage(0)) - di, si, sz := 1+0*14, 1+1*14, (2*rc+1)*7 - copy(right[di:di+sz], right[si:]) - right = btreeIndexPage(right).setLen(rc - 1) - if err = a.Realloc(parent, pp); err != nil { - return nil, err - } - - if err = a.Realloc(*ph, p); err != nil { - return nil, err - } - - return p, a.Realloc(rh, right) - } - } - - if lh != 0 { - *index += left.len() + 1 - if left, err = left.concat(a, root, iroot, parent, lh, *ph, parentIndex-1); err != nil { - return p, err - } - - p, *ph = left, lh - return p, nil - } - - return p.concat(a, root, iroot, parent, *ph, rh, parentIndex) -} - -// must persist all changes made -func (p btreeIndexPage) concat(a btreeStore, root, iroot, parent, ph, rh int64, parentIndex int) (btreeIndexPage, error) { - pp := bufs.GCache.Get(maxBuf) - defer bufs.GCache.Put(pp) - pp, err := a.Get(pp, parent) - if err != nil { - return nil, err - } - - right := bufs.GCache.Get(maxBuf) - defer bufs.GCache.Put(right) - if right, err = a.Get(right, rh); err != nil { - return nil, err - } - - pc := p.len() - rc := btreeIndexPage(right).len() - p = p.setLen(pc + rc + 1) - p.setDataPage(pc, btreeIndexPage(pp).dataPage(parentIndex)) - di, si, sz := 1+14*(pc+1), 1+0*14, (2*rc+1)*7 - copy(p[di:di+sz], right[si:]) - if err := a.Realloc(ph, p); err != nil { - return nil, err - } - - if err := a.Free(rh); err != nil { - return nil, err - } - - if pc := btreeIndexPage(pp).len(); pc > 1 { - if parentIndex < pc-1 { - di, si, sz := 8+parentIndex*14, 8+(parentIndex+1)*14, 2*(pc-1-parentIndex)*7 - copy(pp[di:si+sz], pp[si:]) - } - pp = btreeIndexPage(pp).setLen(pc - 1) - return p, a.Realloc(parent, pp) - } - - if err := a.Free(iroot); err != nil { - return nil, err - } - - b7 := bufs.GCache.Get(7) - defer bufs.GCache.Put(b7) - return p, a.Realloc(root, h2b(b7[:7], ph)) -} - -/* - -0...0 (1 bytes): -Flag - - 0 - +---+ - | 1 | - +---+ - -1 indicates a data page - -1...14 (14 bytes) - - 1..7 8..14 - +------+------+ - | Prev | Next | - +------+------+ - - Prev, Next == Handles of the data pages doubly linked list - - Count = (len(raw) - 15) / (2*kKV) - -15...count*2*kKV-1 -"array" of items, 2*kKV bytes each. Count of items in kData-1..2*kData - -Item - 0..kKV-1 kKV..2*kKV-1 - +----------+--------------+ - | Key | Value | - +----------+--------------+ - -Key/Value encoding - -Length 0...kKV-1 - - 0 1...N N+1...kKV-1 - +---+---------+-------------+ - | N | Data | Padding | - +---+---------+-------------+ - - N == content length - Data == Key or Value content - Padding == MUST be zero bytes - -Length >= kKV - - 0 1...kkV-8 kKV-7...kkV-1 - +------+-----------+--------------+ - | 0xFF | Data | H | - +------+-----------+--------------+ - - Data == Key or Value content, first kKV-7 bytes - H == Handle to THE REST of the content, w/o the first bytes in Data. - -Offsets into the raw []byte: -Key[X] == 15+2*kKV*X -Value[X] == 15+kKV+2*kKV*X -*/ -type btreeDataPage []byte - -func newBTreeDataPage() (p btreeDataPage) { - p = bufs.GCache.Cget(1 + 2*7 + (kData+1)*2*kKV)[:1+2*7] - p[0] = tagBTreeDataPage - return -} - -func newBTreeDataPageAlloc(a btreeStore) (p btreeDataPage, h int64, err error) { - p = newBTreeDataPage() - h, err = a.Alloc(p) - return -} - -func (p btreeDataPage) len() int { - return (len(p) - 15) / (2 * kKV) -} - -func (q btreeDataPage) setLen(n int) btreeDataPage { - q = q[:cap(q)] - need := 15 + 2*kKV*n - if need < len(q) { - return q[:need] - } - return append(q, make([]byte, need-len(q))...) -} - -func (p btreeDataPage) prev() int64 { - return b2h(p[1:]) -} - -func (p btreeDataPage) next() int64 { - return b2h(p[8:]) -} - -func (p btreeDataPage) setPrev(h int64) { - h2b(p[1:], h) -} - -func (p btreeDataPage) setNext(h int64) { - h2b(p[8:], h) -} - -func (q btreeDataPage) insert(index int) btreeDataPage { - switch len0 := q.len(); { - case index < len0: - has := len(q) - need := has + 2*kKV - switch { - case cap(q) >= need: - q = q[:need] - default: - q = append(q, zeros[:2*kKV]...) - } - q.copy(q, index+1, index, len0-index) - return q - case index == len0: - has := len(q) - need := has + 2*kKV - switch { - case cap(q) >= need: - return q[:need] - default: - return append(q, zeros[:2*kKV]...) - } - } - panic("internal error") -} - -func (p btreeDataPage) contentField(off int) (b []byte, h int64) { - p = p[off:] - switch n := int(p[0]); { - case n >= kKV: // content has a handle - b = append([]byte(nil), p[1:1+kSz]...) - h = b2h(p[kH:]) - default: // content is embedded - b, h = append([]byte(nil), p[1:1+n]...), 0 - } - return -} - -func (p btreeDataPage) content(a btreeStore, off int) (b []byte, err error) { - b, h := p.contentField(off) - if h == 0 { - return - } - - // content has a handle - b2, err := a.Get(nil, h) //TODO buffers: Later, not a public API - if err != nil { - return nil, err - } - - return append(b, b2...), nil -} - -func (p btreeDataPage) setContent(a btreeStore, off int, b []byte) (err error) { - p = p[off:] - switch { - case p[0] >= kKV: // existing content has a handle - switch n := len(b); { - case n < kKV: - p[0] = byte(n) - if err = a.Free(b2h(p[kH:])); err != nil { - return - } - copy(p[1:], b) - default: - // reuse handle - copy(p[1:1+kSz], b) - return a.Realloc(b2h(p[kH:]), b[kSz:]) - } - default: // existing content is embedded - switch n := len(b); { - case n < kKV: - p[0] = byte(n) - copy(p[1:], b) - default: - p[0] = 0xff - copy(p[1:1+kSz], b) - h, err := a.Alloc(b[kSz:]) - if err != nil { - return err - } - - h2b(p[kH:], h) - } - } - return -} - -func (p btreeDataPage) keyField(index int) (b []byte, h int64) { - return p.contentField(15 + 2*kKV*index) -} - -func (p btreeDataPage) key(a btreeStore, index int) (b []byte, err error) { - return p.content(a, 15+2*kKV*index) -} - -func (p btreeDataPage) valueField(index int) (b []byte, h int64) { - return p.contentField(15 + kKV + 2*kKV*index) -} - -func (p btreeDataPage) value(a btreeStore, index int) (b []byte, err error) { - return p.content(a, 15+kKV+2*kKV*index) -} - -func (p btreeDataPage) valueCopy(a btreeStore, index int) (b []byte, err error) { - if b, err = p.content(a, 15+kKV+2*kKV*index); err != nil { - return - } - - return append([]byte(nil), b...), nil -} - -func (p btreeDataPage) setKey(a btreeStore, index int, key []byte) (err error) { - return p.setContent(a, 15+2*kKV*index, key) -} - -func (p btreeDataPage) setValue(a btreeStore, index int, value []byte) (err error) { - return p.setContent(a, 15+kKV+2*kKV*index, value) -} - -func (p btreeDataPage) cmp(a btreeStore, c func(a, b []byte) int, keyA []byte, keyBIndex int) (y int, err error) { - var keyB []byte - if keyB, err = p.content(a, 15+2*kKV*keyBIndex); err != nil { - return - } - - return c(keyA, keyB), nil -} - -func (p btreeDataPage) copy(src btreeDataPage, di, si, n int) { - do, so := 15+2*kKV*di, 15+2*kKV*si - copy(p[do:do+2*kKV*n], src[so:]) -} - -// {p,left} dirty on exit -func (p btreeDataPage) moveLeft(left btreeDataPage, n int) (btreeDataPage, btreeDataPage) { - nl, np := left.len(), p.len() - left = left.setLen(nl + n) - left.copy(p, nl, 0, n) - p.copy(p, 0, n, np-n) - return p.setLen(np - n), left -} - -func (p btreeDataPage) moveRight(right btreeDataPage, n int) (btreeDataPage, btreeDataPage) { - nr, np := right.len(), p.len() - right = right.setLen(nr + n) - right.copy(right, n, 0, nr) - right.copy(p, 0, np-n, n) - return p.setLen(np - n), right -} - -func (p btreeDataPage) insertItem(a btreeStore, index int, key, value []byte) (btreeDataPage, error) { - p = p.insert(index) - di, sz := 15+2*kKV*index, 2*kKV - copy(p[di:di+sz], zeros[:sz]) - if err := p.setKey(a, index, key); err != nil { - return nil, err - } - return p, p.setValue(a, index, value) -} - -func (p btreeDataPage) split(a btreeStore, root, ph, parent int64, parentIndex, index int, key, value []byte) (btreeDataPage, error) { - right, rh, err := newBTreeDataPageAlloc(a) - // fails defer bufs.GCache.Put(right) - if err != nil { - return nil, err - } - - if next := p.next(); next != 0 { - right.setNext(p.next()) - nxh := right.next() - nx := bufs.GCache.Get(maxBuf) - defer bufs.GCache.Put(nx) - if nx, err = a.Get(nx, nxh); err != nil { - return nil, err - } - - btreeDataPage(nx).setPrev(rh) - if err = a.Realloc(nxh, nx); err != nil { - return nil, err - } - } - - p.setNext(rh) - right.setPrev(ph) - right = right.setLen(kData) - right.copy(p, 0, kData, kData) - p = p.setLen(kData) - - if parentIndex >= 0 { - var pp btreeIndexPage = bufs.GCache.Get(maxBuf) - defer bufs.GCache.Put(pp) - if pp, err = a.Get(pp, parent); err != nil { - return nil, err - } - - pp = pp.insert3(parentIndex, rh, rh) - if err = a.Realloc(parent, pp); err != nil { - return nil, err - } - - } else { - nr := newBTreeIndexPage(ph) - defer bufs.GCache.Put(nr) - nr = nr.insert3(0, rh, rh) - nrh, err := a.Alloc(nr) - if err != nil { - return nil, err - } - - if err = a.Realloc(root, h2b(make([]byte, 7), nrh)); err != nil { - return nil, err - } - - } - if index > kData { - if right, err = right.insertItem(a, index-kData, key, value); err != nil { - return nil, err - } - } else { - if p, err = p.insertItem(a, index, key, value); err != nil { - return nil, err - } - } - if err = a.Realloc(ph, p); err != nil { - return nil, err - } - - return p, a.Realloc(rh, right) -} - -func (p btreeDataPage) overflow(a btreeStore, root, ph, parent int64, parentIndex, index int, key, value []byte) (btreeDataPage, error) { - leftH, rightH, err := checkSiblings(a, parent, parentIndex) - if err != nil { - return nil, err - } - - if leftH != 0 { - left := btreeDataPage(bufs.GCache.Get(maxBuf)) - defer bufs.GCache.Put(left) - if left, err = a.Get(left, leftH); err != nil { - return nil, err - } - - if left.len() < 2*kData { - - p, left = p.moveLeft(left, 1) - if err = a.Realloc(leftH, left); err != nil { - return nil, err - } - - if p, err = p.insertItem(a, index-1, key, value); err != nil { - return nil, err - } - - return p, a.Realloc(ph, p) - } - } - - if rightH != 0 { - right := btreeDataPage(bufs.GCache.Get(maxBuf)) - defer bufs.GCache.Put(right) - if right, err = a.Get(right, rightH); err != nil { - return nil, err - } - - if right.len() < 2*kData { - if index < 2*kData { - p, right = p.moveRight(right, 1) - if err = a.Realloc(rightH, right); err != nil { - return nil, err - } - - if p, err = p.insertItem(a, index, key, value); err != nil { - return nil, err - } - - return p, a.Realloc(ph, p) - } else { - if right, err = right.insertItem(a, 0, key, value); err != nil { - return nil, err - } - - return p, a.Realloc(rightH, right) - } - } - } - return p.split(a, root, ph, parent, parentIndex, index, key, value) -} - -func (p btreeDataPage) swap(a btreeStore, di int, value []byte, canOverwrite bool) (oldValue []byte, err error) { - if oldValue, err = p.value(a, di); err != nil { - return - } - - if !canOverwrite { - return - } - - oldValue = append([]byte(nil), oldValue...) - err = p.setValue(a, di, value) - return -} - -type btreePage []byte - -func (p btreePage) isIndex() bool { - return p[0] == tagBTreeIndexPage -} - -func (p btreePage) len() int { - if p.isIndex() { - return btreeIndexPage(p).len() - } - - return btreeDataPage(p).len() -} - -func (p btreePage) find(a btreeStore, c func(a, b []byte) int, key []byte) (index int, ok bool, err error) { - l := 0 - h := p.len() - 1 - isIndex := p.isIndex() - if c == nil { - c = bytes.Compare - } - for l <= h { - index = (l + h) >> 1 - var cmp int - if isIndex { - if cmp, err = btreeIndexPage(p).cmp(a, c, key, index); err != nil { - return - } - } else { - if cmp, err = btreeDataPage(p).cmp(a, c, key, index); err != nil { - return - } - } - switch ok = cmp == 0; { - case cmp > 0: - l = index + 1 - case ok: - return - default: - h = index - 1 - } - } - return l, false, nil -} - -// p is dirty after extract! -func (p btreeDataPage) extract(a btreeStore, index int) (btreeDataPage, []byte, error) { - value, err := p.valueCopy(a, index) - if err != nil { - return nil, nil, err - } - - if _, h := p.keyField(index); h != 0 { - if err = a.Free(h); err != nil { - return nil, nil, err - } - } - - if _, h := p.valueField(index); h != 0 { - if err = a.Free(h); err != nil { - return nil, nil, err - } - } - - n := p.len() - 1 - if index < n { - p.copy(p, index, index+1, n-index) - } - return p.setLen(n), value, nil -} - -func checkSiblings(a btreeStore, parent int64, parentIndex int) (left, right int64, err error) { - if parentIndex >= 0 { - var p btreeIndexPage = bufs.GCache.Get(maxBuf) - defer bufs.GCache.Put(p) - if p, err = a.Get(p, parent); err != nil { - return - } - - if parentIndex > 0 { - left = p.child(parentIndex - 1) - } - if parentIndex < p.len() { - right = p.child(parentIndex + 1) - } - } - return -} - -// underflow must persist all changes made. -func (p btreeDataPage) underflow(a btreeStore, root, iroot, parent, ph int64, parentIndex int) (err error) { - lh, rh, err := checkSiblings(a, parent, parentIndex) - if err != nil { - return err - } - - if lh != 0 { - left := bufs.GCache.Get(maxBuf) - defer bufs.GCache.Put(left) - if left, err = a.Get(left, lh); err != nil { - return err - } - - if btreeDataPage(left).len()+p.len() >= 2*kData { - left, p = btreeDataPage(left).moveRight(p, 1) - if err = a.Realloc(lh, left); err != nil { - return err - } - - return a.Realloc(ph, p) - } - } - - if rh != 0 { - right := bufs.GCache.Get(maxBuf) - defer bufs.GCache.Put(right) - if right, err = a.Get(right, rh); err != nil { - return err - } - - if p.len()+btreeDataPage(right).len() > 2*kData { - right, p = btreeDataPage(right).moveLeft(p, 1) - if err = a.Realloc(rh, right); err != nil { - return err - } - - return a.Realloc(ph, p) - } - } - - if lh != 0 { - left := bufs.GCache.Get(maxBuf) - defer bufs.GCache.Put(left) - if left, err = a.Get(left, lh); err != nil { - return err - } - - if err = a.Realloc(ph, p); err != nil { - return err - } - - return btreeDataPage(left).concat(a, root, iroot, parent, lh, ph, parentIndex-1) - } - - return p.concat(a, root, iroot, parent, ph, rh, parentIndex) -} - -// concat must persist all changes made. -func (p btreeDataPage) concat(a btreeStore, root, iroot, parent, ph, rh int64, parentIndex int) (err error) { - right := bufs.GCache.Get(maxBuf) - defer bufs.GCache.Put(right) - if right, err = a.Get(right, rh); err != nil { - return err - } - - right, p = btreeDataPage(right).moveLeft(p, btreeDataPage(right).len()) - nxh := btreeDataPage(right).next() - if nxh != 0 { - nx := bufs.GCache.Get(maxBuf) - defer bufs.GCache.Put(nx) - if nx, err = a.Get(nx, nxh); err != nil { - return err - } - - btreeDataPage(nx).setPrev(ph) - if err = a.Realloc(nxh, nx); err != nil { - return err - } - } - p.setNext(nxh) - if err = a.Free(rh); err != nil { - return err - } - - pp := bufs.GCache.Get(maxBuf) - defer bufs.GCache.Put(pp) - if pp, err = a.Get(pp, parent); err != nil { - return err - } - - if btreeIndexPage(pp).len() > 1 { - pp = btreeIndexPage(pp).extract(parentIndex) - btreeIndexPage(pp).setChild(parentIndex, ph) - if err = a.Realloc(parent, pp); err != nil { - return err - } - - return a.Realloc(ph, p) - } - - if err = a.Free(iroot); err != nil { - return err - } - - if err = a.Realloc(ph, p); err != nil { - return err - } - - var b7 [7]byte - return a.Realloc(root, h2b(b7[:], ph)) -} - -// external "root" is stable and contains the real root. -type btree int64 - -func newBTree(a btreeStore) (btree, error) { - r, err := a.Alloc(zeros[:7]) - return btree(r), err -} - -func (root btree) String(a btreeStore) string { - r := bufs.GCache.Get(16) - defer bufs.GCache.Put(r) - r, err := a.Get(r, int64(root)) - if err != nil { - panic(err) - } - - iroot := b2h(r) - m := map[int64]bool{int64(root): true} - - s := []string{fmt.Sprintf("tree %#x -> %#x\n====", root, iroot)} - if iroot == 0 { - return s[0] - } - - var f func(int64, string) - f = func(h int64, ind string) { - if m[h] { - return - } - - m[h] = true - var b btreePage = bufs.GCache.Get(maxBuf) - defer bufs.GCache.Put(b) - var err error - if b, err = a.Get(b, h); err != nil { - panic(err) - } - - s = append(s, fmt.Sprintf("%s@%#x", ind, h)) - switch b.isIndex() { - case true: - da := []int64{} - b := btreeIndexPage(b) - for i := 0; i < b.len(); i++ { - c, d := b.child(i), b.dataPage(i) - s = append(s, fmt.Sprintf("%schild[%d] %#x dataPage[%d] %#x", ind, i, c, i, d)) - da = append(da, c) - da = append(da, d) - } - i := b.len() - c := b.child(i) - s = append(s, fmt.Sprintf("%schild[%d] %#x", ind, i, c)) - for _, c := range da { - f(c, ind+" ") - } - f(c, ind+" ") - case false: - b := btreeDataPage(b) - s = append(s, fmt.Sprintf("%sprev %#x next %#x", ind, b.prev(), b.next())) - for i := 0; i < b.len(); i++ { - k, err := b.key(a, i) - if err != nil { - panic(err) - } - - v, err := b.value(a, i) - if err != nil { - panic(err) - } - - s = append(s, fmt.Sprintf("%sK[%d]|% x| V[%d]|% x|", ind, i, k, i, v)) - } - } - } - - f(int64(iroot), "") - return strings.Join(s, "\n") -} - -func (root btree) put(dst []byte, a btreeStore, c func(a, b []byte) int, key, value []byte, canOverwrite bool) (prev []byte, err error) { - prev, _, err = root.put2(dst, a, c, key, func(key, old []byte) (new []byte, write bool, err error) { - new, write = value, true - return - }) - return -} - -func (root btree) put2(dst []byte, a btreeStore, c func(a, b []byte) int, key []byte, upd func(key, old []byte) (new []byte, write bool, err error)) (old []byte, written bool, err error) { - var r, value []byte - if r, err = a.Get(dst, int64(root)); err != nil { - return - } - - iroot := b2h(r) - var h int64 - if iroot == 0 { - p := newBTreeDataPage() - defer bufs.GCache.Put(p) - if value, written, err = upd(key, nil); err != nil || !written { - return - } - - if p, err = p.insertItem(a, 0, key, value); err != nil { - return - } - - h, err = a.Alloc(p) - if err != nil { - return nil, true, err - } - - err = a.Realloc(int64(root), h2b(r, h)[:7]) - return - } - - parentIndex := -1 - var parent int64 - ph := iroot - - p := bufs.GCache.Get(maxBuf) - defer bufs.GCache.Put(p) - - for { - if p, err = a.Get(p[:cap(p)], ph); err != nil { - return - } - - var index int - var ok bool - - if index, ok, err = btreePage(p).find(a, c, key); err != nil { - return - } - - switch { - case ok: // Key found - if btreePage(p).isIndex() { - ph = btreeIndexPage(p).dataPage(index) - if p, err = a.Get(p, ph); err != nil { - return - } - - if old, err = btreeDataPage(p).valueCopy(a, 0); err != nil { - return - } - - if value, written, err = upd(key, old); err != nil || !written { - return - } - - if _, err = btreeDataPage(p).swap(a, 0, value, true); err != nil { - return - } - - err = a.Realloc(ph, p) - return - } - - if old, err = btreeDataPage(p).valueCopy(a, index); err != nil { - return - } - - if value, written, err = upd(key, old); err != nil || !written { - return - } - - if _, err = btreeDataPage(p).swap(a, index, value, true); err != nil { - return - } - - err = a.Realloc(ph, p) - return - case btreePage(p).isIndex(): - if btreePage(p).len() > 2*kIndex { - if p, err = btreeIndexPage(p).split(a, root, &ph, parent, parentIndex, &index); err != nil { - return - } - } - parentIndex = index - parent = ph - ph = btreeIndexPage(p).child(index) - default: - if value, written, err = upd(key, nil); err != nil || !written { - return - } - - if btreePage(p).len() < 2*kData { // page is not full - if p, err = btreeDataPage(p).insertItem(a, index, key, value); err != nil { - return - } - - err = a.Realloc(ph, p) - return - } - - // page is full - p, err = btreeDataPage(p).overflow(a, int64(root), ph, parent, parentIndex, index, key, value) - return - } - } -} - -//TODO actually use 'dst' to return 'value' -func (root btree) get(a btreeStore, dst []byte, c func(a, b []byte) int, key []byte) (b []byte, err error) { - var r []byte - if r, err = a.Get(dst, int64(root)); err != nil { - return - } - - iroot := b2h(r) - if iroot == 0 { - return - } - - ph := iroot - - for { - var p btreePage - if p, err = a.Get(p, ph); err != nil { - return - } - - var index int - var ok bool - if index, ok, err = p.find(a, c, key); err != nil { - return - } - - switch { - case ok: - if p.isIndex() { - dh := btreeIndexPage(p).dataPage(index) - dp, err := a.Get(dst, dh) - if err != nil { - return nil, err - } - - return btreeDataPage(dp).value(a, 0) - } - - return btreeDataPage(p).value(a, index) - case p.isIndex(): - ph = btreeIndexPage(p).child(index) - default: - return - } - } -} - -//TODO actually use 'dst' to return 'value' -func (root btree) extract(a btreeStore, dst []byte, c func(a, b []byte) int, key []byte) (value []byte, err error) { - var r []byte - if r, err = a.Get(dst, int64(root)); err != nil { - return - } - - iroot := b2h(r) - if iroot == 0 { - return - } - - ph := iroot - parentIndex := -1 - var parent int64 - - p := bufs.GCache.Get(maxBuf) - defer bufs.GCache.Put(p) - - for { - if p, err = a.Get(p[:cap(p)], ph); err != nil { - return - } - - var index int - var ok bool - if index, ok, err = btreePage(p).find(a, c, key); err != nil { - return - } - - if ok { - if btreePage(p).isIndex() { - dph := btreeIndexPage(p).dataPage(index) - dp, err := a.Get(dst, dph) - if err != nil { - return nil, err - } - - if btreeDataPage(dp).len() > kData { - if dp, value, err = btreeDataPage(dp).extract(a, 0); err != nil { - return nil, err - } - - return value, a.Realloc(dph, dp) - } - - if btreeIndexPage(p).len() < kIndex && ph != iroot { - var err error - if p, err = btreeIndexPage(p).underflow(a, int64(root), iroot, parent, &ph, parentIndex, &index); err != nil { - return nil, err - } - } - parentIndex = index + 1 - parent = ph - ph = btreeIndexPage(p).child(parentIndex) - continue - } - - p, value, err = btreeDataPage(p).extract(a, index) - if btreePage(p).len() >= kData { - err = a.Realloc(ph, p) - return - } - - if ph != iroot { - err = btreeDataPage(p).underflow(a, int64(root), iroot, parent, ph, parentIndex) - return - } - - if btreePage(p).len() == 0 { - if err = a.Free(ph); err != nil { - return - } - - err = a.Realloc(int64(root), zeros[:7]) - return - } - err = a.Realloc(ph, p) - return - } - - if !btreePage(p).isIndex() { - return - } - - if btreePage(p).len() < kIndex && ph != iroot { - if p, err = btreeIndexPage(p).underflow(a, int64(root), iroot, parent, &ph, parentIndex, &index); err != nil { - return nil, err - } - } - parentIndex = index - parent = ph - ph = btreeIndexPage(p).child(index) - } -} - -func (root btree) deleteAny(a btreeStore) (bool, error) { - r := bufs.GCache.Get(7) - defer bufs.GCache.Put(r) - var err error - if r, err = a.Get(r, int64(root)); err != nil { - return false, err - } - - iroot := b2h(r) - if iroot == 0 { - return true, nil - } - - ph := iroot - parentIndex := -1 - var parent int64 - p := bufs.GCache.Get(maxBuf) - defer bufs.GCache.Put(p) - - for { - if p, err = a.Get(p, ph); err != nil { - return false, err - } - - index := btreePage(p).len() / 2 - if btreePage(p).isIndex() { - dph := btreeIndexPage(p).dataPage(index) - dp := bufs.GCache.Get(maxBuf) - defer bufs.GCache.Put(dp) - if dp, err = a.Get(dp, dph); err != nil { - return false, err - } - - if btreeDataPage(dp).len() > kData { - if dp, _, err = btreeDataPage(dp).extract(a, 0); err != nil { - return false, err - } - - return false, a.Realloc(dph, dp) - } - - if btreeIndexPage(p).len() < kIndex && ph != iroot { - if p, err = btreeIndexPage(p).underflow(a, int64(root), iroot, parent, &ph, parentIndex, &index); err != nil { - return false, err - } - } - parentIndex = index + 1 - parent = ph - ph = btreeIndexPage(p).child(parentIndex) - continue - } - - p, _, err = btreeDataPage(p).extract(a, index) - if btreePage(p).len() >= kData { - err = a.Realloc(ph, p) - return false, err - } - - if ph != iroot { - err = btreeDataPage(p).underflow(a, int64(root), iroot, parent, ph, parentIndex) - return false, err - } - - if btreePage(p).len() == 0 { - if err = a.Free(ph); err != nil { - return true, err - } - - return true, a.Realloc(int64(root), zeros[:7]) - } - - return false, a.Realloc(ph, p) - } -} - -func (root btree) first(a btreeStore) (ph int64, p btreeDataPage, err error) { - r := bufs.GCache.Get(7) - defer bufs.GCache.Put(r) - if r, err = a.Get(r, int64(root)); err != nil { - return - } - - for ph = b2h(r); ph != 0; ph = btreeIndexPage(p).child(0) { - if p, err = a.Get(p, ph); err != nil { - return - } - - if !btreePage(p).isIndex() { - break - } - } - - return -} - -func (root btree) last(a btreeStore) (ph int64, p btreeDataPage, err error) { - r := bufs.GCache.Get(7) - defer bufs.GCache.Put(r) - if r, err = a.Get(r, int64(root)); err != nil { - return - } - - for ph = b2h(r); ph != 0; ph = btreeIndexPage(p).child(btreeIndexPage(p).len()) { - if p, err = a.Get(p, ph); err != nil { - return - } - - if !btreePage(p).isIndex() { - break - } - } - - return -} - -// key >= p[index].key -func (root btree) seek(a btreeStore, c func(a, b []byte) int, key []byte) (p btreeDataPage, index int, equal bool, err error) { - r := bufs.GCache.Get(7) - defer bufs.GCache.Put(r) - if r, err = a.Get(r, int64(root)); err != nil { - return - } - - for ph := b2h(r); ph != 0; ph = btreeIndexPage(p).child(index) { - if p, err = a.Get(p, ph); err != nil { - break - } - - if index, equal, err = btreePage(p).find(a, c, key); err != nil { - break - } - - if equal { - if !btreePage(p).isIndex() { - break - } - - p, err = a.Get(p, btreeIndexPage(p).dataPage(index)) - index = 0 - break - } - - if !btreePage(p).isIndex() { - break - } - } - return -} - -func (root btree) clear(a btreeStore) (err error) { - r := bufs.GCache.Get(7) - defer bufs.GCache.Put(r) - if r, err = a.Get(r, int64(root)); err != nil { - return - } - - iroot := b2h(r) - if iroot == 0 { - return - } - - if err = root.clear2(a, iroot); err != nil { - return - } - - var b [7]byte - return a.Realloc(int64(root), b[:]) -} - -func (root btree) clear2(a btreeStore, ph int64) (err error) { - var p = bufs.GCache.Get(maxBuf) - defer bufs.GCache.Put(p) - if p, err = a.Get(p, ph); err != nil { - return - } - - switch btreePage(p).isIndex() { - case true: - ip := btreeIndexPage(p) - for i := 0; i <= ip.len(); i++ { - root.clear2(a, ip.child(i)) - - } - case false: - dp := btreeDataPage(p) - for i := 0; i < dp.len(); i++ { - if err = dp.setKey(a, i, nil); err != nil { - return - } - - if err = dp.setValue(a, i, nil); err != nil { - return - } - } - } - return a.Free(ph) -} diff --git a/Godeps/_workspace/src/github.com/cznic/exp/lldb/errors.go b/Godeps/_workspace/src/github.com/cznic/exp/lldb/errors.go deleted file mode 100644 index 7dffe7f10c..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/exp/lldb/errors.go +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright 2014 The lldb Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Some errors returned by this package. -// -// Note that this package can return more errors than declared here, for -// example io.EOF from Filer.ReadAt(). - -package lldb - -import ( - "fmt" -) - -// ErrDecodeScalars is possibly returned from DecodeScalars -type ErrDecodeScalars struct { - B []byte // Data being decoded - I int // offending offset -} - -// Error implements the built in error type. -func (e *ErrDecodeScalars) Error() string { - return fmt.Sprintf("DecodeScalars: corrupted data @ %d/%d", e.I, len(e.B)) -} - -// ErrINVAL reports invalid values passed as parameters, for example negative -// offsets where only non-negative ones are allowed or read from the DB. -type ErrINVAL struct { - Src string - Val interface{} -} - -// Error implements the built in error type. -func (e *ErrINVAL) Error() string { - return fmt.Sprintf("%s: %+v", e.Src, e.Val) -} - -// ErrPERM is for example reported when a Filer is closed while BeginUpdate(s) -// are not balanced with EndUpdate(s)/Rollback(s) or when EndUpdate or Rollback -// is invoked which is not paired with a BeginUpdate. -type ErrPERM struct { - Src string -} - -// Error implements the built in error type. -func (e *ErrPERM) Error() string { - return fmt.Sprintf("%s: Operation not permitted", string(e.Src)) -} - -// ErrTag represents an ErrILSEQ kind. -type ErrType int - -// ErrILSEQ types -const ( - ErrOther ErrType = iota - - ErrAdjacentFree // Adjacent free blocks (.Off and .Arg) - ErrDecompress // Used compressed block: corrupted compression - ErrExpFreeTag // Expected a free block tag, got .Arg - ErrExpUsedTag // Expected a used block tag, got .Arg - ErrFLT // Free block is invalid or referenced multiple times - ErrFLTLoad // FLT truncated to .Off, need size >= .Arg - ErrFLTSize // Free block size (.Arg) doesn't belong to its list min size: .Arg2 - ErrFileSize // File .Name size (.Arg) != 0 (mod 16) - ErrFreeChaining // Free block, .prev.next doesn't point back to this block - ErrFreeTailBlock // Last block is free - ErrHead // Head of a free block list has non zero Prev (.Arg) - ErrInvalidRelocTarget // Reloc doesn't target (.Arg) a short or long used block - ErrInvalidWAL // Corrupted write ahead log. .Name: file name, .More: more - ErrLongFreeBlkTooLong // Long free block spans beyond EOF, size .Arg - ErrLongFreeBlkTooShort // Long free block must have at least 2 atoms, got only .Arg - ErrLongFreeNextBeyondEOF // Long free block .Next (.Arg) spans beyond EOF - ErrLongFreePrevBeyondEOF // Long free block .Prev (.Arg) spans beyond EOF - ErrLongFreeTailTag // Expected a long free block tail tag, got .Arg - ErrLostFreeBlock // Free block is not in any FLT list - ErrNullReloc // Used reloc block with nil target - ErrRelocBeyondEOF // Used reloc points (.Arg) beyond EOF - ErrShortFreeTailTag // Expected a short free block tail tag, got .Arg - ErrSmall // Request for a free block (.Arg) returned a too small one (.Arg2) at .Off - ErrTailTag // Block at .Off has invalid tail CC (compression code) tag, got .Arg - ErrUnexpReloc // Unexpected reloc block referred to from reloc block .Arg - ErrVerifyPadding // Used block has nonzero padding - ErrVerifyTailSize // Long free block size .Arg but tail size .Arg2 - ErrVerifyUsedSpan // Used block size (.Arg) spans beyond EOF -) - -// ErrILSEQ reports a corrupted file format. Details in fields according to Type. -type ErrILSEQ struct { - Type ErrType - Off int64 - Arg int64 - Arg2 int64 - Arg3 int64 - Name string - More interface{} -} - -// Error implements the built in error type. -func (e *ErrILSEQ) Error() string { - switch e.Type { - case ErrAdjacentFree: - return fmt.Sprintf("Adjacent free blocks at offset %#x and %#x", e.Off, e.Arg) - case ErrDecompress: - return fmt.Sprintf("Compressed block at offset %#x: Corrupted compressed content", e.Off) - case ErrExpFreeTag: - return fmt.Sprintf("Block at offset %#x: Expected a free block tag, got %#2x", e.Off, e.Arg) - case ErrExpUsedTag: - return fmt.Sprintf("Block at ofset %#x: Expected a used block tag, got %#2x", e.Off, e.Arg) - case ErrFLT: - return fmt.Sprintf("Free block at offset %#x is invalid or referenced multiple times", e.Off) - case ErrFLTLoad: - return fmt.Sprintf("FLT truncated to size %d, expected at least %d", e.Off, e.Arg) - case ErrFLTSize: - return fmt.Sprintf("Free block at offset %#x has size (%#x) should be at least (%#x)", e.Off, e.Arg, e.Arg2) - case ErrFileSize: - return fmt.Sprintf("File %q size (%#x) != 0 (mod 16)", e.Name, e.Arg) - case ErrFreeChaining: - return fmt.Sprintf("Free block at offset %#x: .prev.next doesn point back here.", e.Off) - case ErrFreeTailBlock: - return fmt.Sprintf("Free block at offset %#x: Cannot be last file block", e.Off) - case ErrHead: - return fmt.Sprintf("Block at offset %#x: Head of free block list has non zero .prev %#x", e.Off, e.Arg) - case ErrInvalidRelocTarget: - return fmt.Sprintf("Used reloc block at offset %#x: Target (%#x) is not a short or long used block", e.Off, e.Arg) - case ErrInvalidWAL: - return fmt.Sprintf("Corrupted write ahead log file: %q %v", e.Name, e.More) - case ErrLongFreeBlkTooLong: - return fmt.Sprintf("Long free block at offset %#x: Size (%#x) beyond EOF", e.Off, e.Arg) - case ErrLongFreeBlkTooShort: - return fmt.Sprintf("Long free block at offset %#x: Size (%#x) too small", e.Off, e.Arg) - case ErrLongFreeNextBeyondEOF: - return fmt.Sprintf("Long free block at offset %#x: Next (%#x) points beyond EOF", e.Off, e.Arg) - case ErrLongFreePrevBeyondEOF: - return fmt.Sprintf("Long free block at offset %#x: Prev (%#x) points beyond EOF", e.Off, e.Arg) - case ErrLongFreeTailTag: - return fmt.Sprintf("Block at offset %#x: Expected long free tail tag, got %#2x", e.Off, e.Arg) - case ErrLostFreeBlock: - return fmt.Sprintf("Free block at offset %#x: not in any FLT list", e.Off) - case ErrNullReloc: - return fmt.Sprintf("Used reloc block at offset %#x: Nil target", e.Off) - case ErrRelocBeyondEOF: - return fmt.Sprintf("Used reloc block at offset %#x: Link (%#x) points beyond EOF", e.Off, e.Arg) - case ErrShortFreeTailTag: - return fmt.Sprintf("Block at offset %#x: Expected short free tail tag, got %#2x", e.Off, e.Arg) - case ErrSmall: - return fmt.Sprintf("Request for of free block of size %d returned a too small (%d) one at offset %#x", e.Arg, e.Arg2, e.Off) - case ErrTailTag: - return fmt.Sprintf("Block at offset %#x: Invalid tail CC tag, got %#2x", e.Off, e.Arg) - case ErrUnexpReloc: - return fmt.Sprintf("Block at offset %#x: Unexpected reloc block. Referred to from reloc block at offset %#x", e.Off, e.Arg) - case ErrVerifyPadding: - return fmt.Sprintf("Used block at offset %#x: Nonzero padding", e.Off) - case ErrVerifyTailSize: - return fmt.Sprintf("Long free block at offset %#x: Size %#x, but tail size %#x", e.Off, e.Arg, e.Arg2) - case ErrVerifyUsedSpan: - return fmt.Sprintf("Used block at offset %#x: Size %#x spans beyond EOF", e.Off, e.Arg) - } - - more := "" - if e.More != nil { - more = fmt.Sprintf(", %v", e.More) - } - off := "" - if e.Off != 0 { - off = fmt.Sprintf(", off: %#x", e.Off) - } - - return fmt.Sprintf("Error%s%s", off, more) -} diff --git a/Godeps/_workspace/src/github.com/cznic/exp/lldb/falloc.go b/Godeps/_workspace/src/github.com/cznic/exp/lldb/falloc.go deleted file mode 100644 index 2969036e24..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/exp/lldb/falloc.go +++ /dev/null @@ -1,1981 +0,0 @@ -// Copyright 2014 The lldb Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// The storage space management. - -package lldb - -import ( - "bytes" - "errors" - "fmt" - "io" - "sort" - "strings" - "sync" - - "github.com/cznic/bufs" - "github.com/cznic/mathutil" - "github.com/cznic/zappy" -) - -const ( - maxBuf = maxRq + 20 // bufs,Buffers.Alloc -) - -// Options are passed to the NewAllocator to amend some configuration. The -// compatibility promise is the same as of struct types in the Go standard -// library - introducing changes can be made only by adding new exported -// fields, which is backward compatible as long as client code uses field names -// to assign values of imported struct types literals. -// -// NOTE: No options are currently defined. -type Options struct{} - -// AllocStats record statistics about a Filer. It can be optionally filled by -// Allocator.Verify, if successful. -type AllocStats struct { - Handles int64 // total valid handles in use - Compression int64 // number of compressed blocks - TotalAtoms int64 // total number of atoms == AllocAtoms + FreeAtoms - AllocBytes int64 // bytes allocated (after decompression, if/where used) - AllocAtoms int64 // atoms allocated/used, including relocation atoms - Relocations int64 // number of relocated used blocks - FreeAtoms int64 // atoms unused - AllocMap map[int64]int64 // allocated block size in atoms -> count of such blocks - FreeMap map[int64]int64 // free block size in atoms -> count of such blocks -} - -/* - -Allocator implements "raw" storage space management (allocation and -deallocation) for a low level of a DB engine. The storage is an abstraction -provided by a Filer. - -The terms MUST or MUST NOT, if/where used in the documentation of Allocator, -written in all caps as seen here, are a requirement for any possible -alternative implementations aiming for compatibility with this one. - -Filer file - -A Filer file, or simply 'file', is a linear, contiguous sequence of blocks. -Blocks may be either free (currently unused) or allocated (currently used). -Some blocks may eventually become virtual in a sense as they may not be -realized in the storage (sparse files). - -Free Lists Table - -File starts with a FLT. This table records heads of 14 doubly linked free -lists. The zero based index (I) vs minimal size of free blocks in that list, -except the last one which registers free blocks of size 4112+ atoms: - - MinSize == 2^I - - For example 0 -> 1, 1 -> 2, ... 12 -> 4096. - -Each entry in the FLT is 8 bytes in netwtork order, MSB MUST be zero, ie. the -slot value is effectively only 7 bytes. The value is the handle of the head of -the respective doubly linked free list. The FLT size is 14*8 == 112(0x70) -bytes. If the free blocks list for any particular size is empty, the respective -FLT slot is zero. Sizes of free blocks in one list MUST NOT overlap with sizes -of free lists in other list. For example, even though a free block of size 2 -technically is of minimal size >= 1, it MUST NOT be put to the list for slot 0 -(minimal size 1), but in slot 1( minimal size 2). - - slot 0: sizes [1, 2) - slot 1: sizes [2, 4) - slot 2: sizes [4, 8) - ... - slot 11: sizes [2048, 4096) - slot 12: sizes [4096, 4112) - slot 13: sizes [4112, inf) - -The last FLT slot collects all free blocks bigger than its minimal size. That -still respects the 'no overlap' invariant. - -File blocks - -A block is a linear, contiguous sequence of atoms. The first and last atoms of -a block provide information about, for example, whether the block is free or -used, what is the size of the block, etc. Details are discussed elsewhere. The -first block of a file starts immediately after FLT, ie. at file offset -112(0x70). - -Block atoms - -An atom is a fixed size piece of a block (and thus of a file too); it is 16 -bytes long. A consequence is that for a valid file: - - filesize == 0 (mod 16) - -The first atom of the first block is considered to be atom #1. - -Block handles - -A handle is an integer referring to a block. The reference is the number of the -atom the block starts with. Put in other way: - - handle == offset/16 - 6 - offset == 16 * (handle + 6) - -`offset` is the offset of the first byte of the block, measured in bytes -- as in fseek(3). Handle has type `int64`, but only the lower 7 bytes may be -nonzero while referring to a block, both in code as well as when persisted in -the the file's internal bookkeeping structures - see 'Block types' bellow. So a -handle is effectively only `uint56`. This also means that the maximum usable -size of a file is 2^56 atoms. That is 2^60 bytes == 1 exabyte (10^18 bytes). - -Nil handles - -A handle with numeric value of '0' refers to no block. - -Zero padding - -A padding is used to round-up a block size to be a whole number of atoms. Any -padding, if present, MUST be all zero bytes. Note that the size of padding is -in [0, 15]. - -Content wiping - -When a block is deallocated, its data content is not wiped as the added -overhead may be substantial while not necessarily needed. Client code should -however overwrite the content of any block having sensitive data with eg. zeros -(good compression) - before deallocating the block. - -Block tags - -Every block is tagged in its first byte (a head tag) and last byte (tail tag). -Block types are: - - 1. Short content used block (head tags 0x00-0xFB) - 2. Long content used block (head tag 0xFC) - 3. Relocated used block (head tag 0xFD) - 4. Short, single atom, free block (head tag 0xFE) - 5. Long free block (head tag 0xFF) - -Note: Relocated used block, 3. above (head tag 0xFD) MUST NOT refer to blocks -other then 1. or 2. above (head tags 0x00-0xFC). - -Content blocks - -Used blocks (head tags 0x00-0xFC) tail tag distinguish used/unused block and if -content is compressed or not. - -Content compression - -The tail flag of an used block is one of - - CC == 0 // Content is not compressed. - CC == 1 // Content is in zappy compression format. - -If compression of written content is enabled, there are two cases: If -compressed size < original size then the compressed content should be written -if it will save at least one atom of the block. If compressed size >= original -size then the compressed content should not be used. - -It's recommended to use compression. For example the BTrees implementation -assumes compression is used. Using compression may cause a slowdown in some -cases while it may as well cause a speedup. - -Short content block - -Short content block carries content of length between N == 0(0x00) and N == -251(0xFB) bytes. - - |<-first atom start ... last atom end->| - +---++-- ... --+-- ... --++------+ - | 0 || 1... | 0x*...0x*E || 0x*F | - +---++-- ... --+-- ... --++------+ - | N || content | padding || CC | - +---++-- ... --+-- ... --++------+ - - A == (N+1)/16 + 1 // The number of atoms in the block [1, 16] - padding == 15 - (N+1)%16 // Length of the zero padding - -Long content block - -Long content block carries content of length between N == 252(0xFC) and N == -65787(0x100FB) bytes. - - |<-first atom start ... last atom end->| - +------++------+-- ... --+-- ... --++------+ - | 0 || 1..2 | 3... | 0x*...0x*E || 0x*F | - +------++------+-- ... --+-- ... --++------+ - | 0xFC || M | content | padding || CC | - +------++------+-- ... --+-- ... --++------+ - - A == (N+3)/16 + 1 // The number of atoms in the block [16, 4112] - M == N % 0x10000 // Stored as 2 bytes in network byte order - padding == 15 - (N+3)%16 // Length of the zero padding - -Relocated used block - -Relocated block allows to permanently assign a handle to some content and -resize the content anytime afterwards without having to update all the possible -existing references; the handle can be constant while the content size may be -dynamic. When relocating a block, any space left by the original block content, -above this single atom block, MUST be reclaimed. - -Relocations MUST point only to a used short or long block == blocks with tags -0x00...0xFC. - - +------++------+---------++----+ - | 0 || 1..7 | 8...14 || 15 | - +------++------+---------++----+ - | 0xFD || H | padding || 0 | - +------++------+---------++----+ - -H is the handle of the relocated block in network byte order. - -Free blocks - -Free blocks are the result of space deallocation. Free blocks are organized in -one or more doubly linked lists, abstracted by the FLT interface. Free blocks -MUST be "registered" by putting them in such list. Allocator MUST reuse a big -enough free block, if such exists, before growing the file size. When a free -block is created by deallocation or reallocation it MUST be joined with any -adjacently existing free blocks before "registering". If the resulting free -block is now a last block of a file, the free block MUST be discarded and the -file size MUST be truncated accordingly instead. Put differently, there MUST -NOT ever be a free block at the file end. - -A single free atom - -Is an unused block of size 1 atom. - - +------++------+--------++------+ - | 0 || 1..7 | 8...14 || 15 | - +------++------+--------++------+ - | 0xFE || P | N || 0xFE | - +------++------+--------++------+ - -P and N, stored in network byte order, are the previous and next free block -handles in the doubly linked list to which this free block belongs. - -A long unused block - -Is an unused block of size > 1 atom. - - +------++------+-------+---------+- ... -+----------++------+ - | 0 || 1..7 | 8..14 | 15...21 | | Z-7..Z-1 || Z | - +------++------+-------+---------+- ... -+----------++------+ - | 0xFF || S | P | N | Leak | S || 0xFF | - +------++------+-------+---------+- ... -+----------++------+ - - Z == 16 * S - 1 - -S is the size of this unused block in atoms. P and N are the previous and next -free block handles in the doubly linked list to which this free block belongs. -Leak contains any data the block had before deallocating this block. See also -the subtitle 'Content wiping' above. S, P and N are stored in network byte -order. Large free blocks may trigger a consideration of file hole punching of -the Leak field - for some value of 'large'. - -Note: Allocator methods vs CRUD[1]: - - Alloc [C]reate - Get [R]ead - Realloc [U]pdate - Free [D]elete - -Note: No Allocator method returns io.EOF. - - [1]: http://en.wikipedia.org/wiki/Create,_read,_update_and_delete - -*/ -type Allocator struct { - f Filer - flt flt - Compress bool // enables content compression - cache cache - m map[int64]*node - lru lst - expHit int64 - expMiss int64 - cacheSz int - hit uint16 - miss uint16 - mu sync.Mutex -} - -// NewAllocator returns a new Allocator. To open an existing file, pass its -// Filer. To create a "new" file, pass a Filer which file is of zero size. -func NewAllocator(f Filer, opts *Options) (a *Allocator, err error) { - if opts == nil { // Enforce *Options is always passed - return nil, errors.New("NewAllocator: nil opts passed") - } - - a = &Allocator{ - f: f, - cacheSz: 10, - } - - a.cinit() - switch x := f.(type) { - case *RollbackFiler: - x.afterRollback = func() error { - a.cinit() - return a.flt.load(a.f, 0) - } - case *ACIDFiler0: - x.RollbackFiler.afterRollback = func() error { - a.cinit() - return a.flt.load(a.f, 0) - } - } - - sz, err := f.Size() - if err != nil { - return - } - - a.flt.init() - if sz == 0 { - var b [fltSz]byte - if err = a.f.BeginUpdate(); err != nil { - return - } - - if _, err = f.WriteAt(b[:], 0); err != nil { - a.f.Rollback() - return - } - - return a, a.f.EndUpdate() - } - - return a, a.flt.load(f, 0) -} - -// CacheStats reports cache statistics. -// -//TODO return a struct perhaps. -func (a *Allocator) CacheStats() (buffersUsed, buffersTotal int, bytesUsed, bytesTotal, hits, misses int64) { - buffersUsed = len(a.m) - buffersTotal = buffersUsed + len(a.cache) - bytesUsed = a.lru.size() - bytesTotal = bytesUsed + a.cache.size() - hits = a.expHit - misses = a.expMiss - return -} - -func (a *Allocator) cinit() { - for h, n := range a.m { - a.cache.put(a.lru.remove(n)) - delete(a.m, h) - } - if a.m == nil { - a.m = map[int64]*node{} - } -} - -func (a *Allocator) cadd(b []byte, h int64) { - if len(a.m) < a.cacheSz { - n := a.cache.get(len(b)) - n.h = h - copy(n.b, b) - a.m[h] = a.lru.pushFront(n) - return - } - - // cache full - delete(a.m, a.cache.put(a.lru.removeBack()).h) - n := a.cache.get(len(b)) - n.h = h - copy(n.b, b) - a.m[h] = a.lru.pushFront(n) - return -} - -func (a *Allocator) cfree(h int64) { - n, ok := a.m[h] - if !ok { // must have been evicted - return - } - - a.cache.put(a.lru.remove(n)) - delete(a.m, h) -} - -// Alloc allocates storage space for b and returns the handle of the new block -// with content set to b or an error, if any. The returned handle is valid only -// while the block is used - until the block is deallocated. No two valid -// handles share the same value within the same Filer, but any value of a -// handle not referring to any used block may become valid any time as a result -// of Alloc. -// -// Invoking Alloc on an empty Allocator is guaranteed to return handle with -// value 1. The intended use of content of handle 1 is a root "directory" of -// other data held by an Allocator. -// -// Passing handles not obtained initially from Alloc or not anymore valid to -// any other Allocator methods can result in an irreparably corrupted database. -func (a *Allocator) Alloc(b []byte) (handle int64, err error) { - buf := bufs.GCache.Get(zappy.MaxEncodedLen(len(b))) - defer bufs.GCache.Put(buf) - buf, _, cc, err := a.makeUsedBlock(buf, b) - if err != nil { - return - } - - if handle, err = a.alloc(buf, cc); err == nil { - a.cadd(b, handle) - } - return -} - -func (a *Allocator) alloc(b []byte, cc byte) (h int64, err error) { - rqAtoms := n2atoms(len(b)) - if h = a.flt.find(rqAtoms); h == 0 { // must grow - var sz int64 - if sz, err = a.f.Size(); err != nil { - return - } - - h = off2h(sz) - err = a.writeUsedBlock(h, cc, b) - return - } - - // Handle is the first item of a free blocks list. - tag, s, prev, next, err := a.nfo(h) - if err != nil { - return - } - - if tag != tagFreeShort && tag != tagFreeLong { - err = &ErrILSEQ{Type: ErrExpFreeTag, Off: h2off(h), Arg: int64(tag)} - return - } - - if prev != 0 { - err = &ErrILSEQ{Type: ErrHead, Off: h2off(h), Arg: prev} - return - } - - if s < int64(rqAtoms) { - err = &ErrILSEQ{Type: ErrSmall, Arg: int64(rqAtoms), Arg2: s, Off: h2off(h)} - return - } - - if err = a.unlink(h, s, prev, next); err != nil { - return - } - - if s > int64(rqAtoms) { - freeH := h + int64(rqAtoms) - freeAtoms := s - int64(rqAtoms) - if err = a.link(freeH, freeAtoms); err != nil { - return - } - } - return h, a.writeUsedBlock(h, cc, b) -} - -// Free deallocates the block referred to by handle or returns an error, if -// any. -// -// After Free succeeds, handle is invalid and must not be used. -// -// Handle must have been obtained initially from Alloc and must be still valid, -// otherwise a database may get irreparably corrupted. -func (a *Allocator) Free(handle int64) (err error) { - if handle <= 0 || handle > maxHandle { - return &ErrINVAL{"Allocator.Free: handle out of limits", handle} - } - - a.cfree(handle) - return a.free(handle, 0, true) -} - -func (a *Allocator) free(h, from int64, acceptRelocs bool) (err error) { - tag, atoms, _, n, err := a.nfo(h) - if err != nil { - return - } - - switch tag { - default: - // nop - case tagUsedLong: - // nop - case tagUsedRelocated: - if !acceptRelocs { - return &ErrILSEQ{Type: ErrUnexpReloc, Off: h2off(h), Arg: h2off(from)} - } - - if err = a.free(n, h, false); err != nil { - return - } - case tagFreeShort, tagFreeLong: - return &ErrINVAL{"Allocator.Free: attempt to free a free block at off", h2off(h)} - } - - return a.free2(h, atoms) -} - -func (a *Allocator) free2(h, atoms int64) (err error) { - sz, err := a.f.Size() - if err != nil { - return - } - - ltag, latoms, lp, ln, err := a.leftNfo(h) - if err != nil { - return - } - - if ltag != tagFreeShort && ltag != tagFreeLong { - latoms = 0 - } - - var rtag byte - var ratoms, rp, rn int64 - - isTail := h2off(h)+atoms*16 == sz - if !isTail { - if rtag, ratoms, rp, rn, err = a.nfo(h + atoms); err != nil { - return - } - } - - if rtag != tagFreeShort && rtag != tagFreeLong { - ratoms = 0 - } - - switch { - case latoms == 0 && ratoms == 0: - // -> isolated <- - if isTail { // cut tail - return a.f.Truncate(h2off(h)) - } - - return a.link(h, atoms) - case latoms == 0 && ratoms != 0: - // right join -> - if err = a.unlink(h+atoms, ratoms, rp, rn); err != nil { - return - } - - return a.link(h, atoms+ratoms) - case latoms != 0 && ratoms == 0: - // <- left join - if err = a.unlink(h-latoms, latoms, lp, ln); err != nil { - return - } - - if isTail { - return a.f.Truncate(h2off(h - latoms)) - } - - return a.link(h-latoms, latoms+atoms) - } - - // case latoms != 0 && ratoms != 0: - // <- middle join -> - lh, rh := h-latoms, h+atoms - if err = a.unlink(lh, latoms, lp, ln); err != nil { - return - } - - // Prev unlink may have invalidated rp or rn - if _, _, rp, rn, err = a.nfo(rh); err != nil { - return - } - - if err = a.unlink(rh, ratoms, rp, rn); err != nil { - return - } - - return a.link(h-latoms, latoms+atoms+ratoms) -} - -// Add a free block h to the appropriate free list -func (a *Allocator) link(h, atoms int64) (err error) { - if err = a.makeFree(h, atoms, 0, a.flt.head(atoms)); err != nil { - return - } - - return a.flt.setHead(h, atoms, a.f) -} - -// Remove free block h from the free list -func (a *Allocator) unlink(h, atoms, p, n int64) (err error) { - switch { - case p == 0 && n == 0: - // single item list, must be head - return a.flt.setHead(0, atoms, a.f) - case p == 0 && n != 0: - // head of list (has next item[s]) - if err = a.prev(n, 0); err != nil { - return - } - - // new head - return a.flt.setHead(n, atoms, a.f) - case p != 0 && n == 0: - // last item in list - return a.next(p, 0) - } - // case p != 0 && n != 0: - // intermediate item in a list - if err = a.next(p, n); err != nil { - return - } - - return a.prev(n, p) -} - -//TODO remove ? -// Return len(slice) == n, reuse src if possible. -func need(n int, src []byte) []byte { - if cap(src) < n { - bufs.GCache.Put(src) - return bufs.GCache.Get(n) - } - - return src[:n] -} - -// Get returns the data content of a block referred to by handle or an error if -// any. The returned slice may be a sub-slice of buf if buf was large enough -// to hold the entire content. Otherwise, a newly allocated slice will be -// returned. It is valid to pass a nil buf. -// -// If the content was stored using compression then it is transparently -// returned decompressed. -// -// Handle must have been obtained initially from Alloc and must be still valid, -// otherwise invalid data may be returned without detecting the error. -// -// Get is safe for concurrent access by multiple goroutines iff no other -// goroutine mutates the DB. -func (a *Allocator) Get(buf []byte, handle int64) (b []byte, err error) { - buf = buf[:cap(buf)] - a.mu.Lock() // X1+ - if n, ok := a.m[handle]; ok { - a.lru.moveToFront(n) - b = need(len(n.b), buf) - copy(b, n.b) - a.expHit++ - a.hit++ - a.mu.Unlock() // X1- - return - } - - a.expMiss++ - a.miss++ - if a.miss > 10 && len(a.m) < 500 { - if 100*a.hit/a.miss < 95 { - a.cacheSz++ - } - a.hit, a.miss = 0, 0 - } - a.mu.Unlock() // X1- - - defer func(h int64) { - if err == nil { - a.mu.Lock() // X2+ - a.cadd(b, h) - a.mu.Unlock() // X2- - } - }(handle) - - first := bufs.GCache.Get(16) - defer bufs.GCache.Put(first) - relocated := false - relocSrc := handle -reloc: - if handle <= 0 || handle > maxHandle { - return nil, &ErrINVAL{"Allocator.Get: handle out of limits", handle} - } - - off := h2off(handle) - if err = a.read(first, off); err != nil { - return - } - - switch tag := first[0]; tag { - default: - dlen := int(tag) - atoms := n2atoms(dlen) - switch atoms { - case 1: - switch tag := first[15]; tag { - default: - return nil, &ErrILSEQ{Type: ErrTailTag, Off: off, Arg: int64(tag)} - case tagNotCompressed: - b = need(dlen, buf) - copy(b, first[1:]) - return - case tagCompressed: - return zappy.Decode(buf, first[1:dlen+1]) - } - default: - cc := bufs.GCache.Get(1) - defer bufs.GCache.Put(cc) - dlen := int(tag) - atoms := n2atoms(dlen) - tailOff := off + 16*int64(atoms) - 1 - if err = a.read(cc, tailOff); err != nil { - return - } - - switch tag := cc[0]; tag { - default: - return nil, &ErrILSEQ{Type: ErrTailTag, Off: off, Arg: int64(tag)} - case tagNotCompressed: - b = need(dlen, buf) - off += 1 - if err = a.read(b, off); err != nil { - b = buf[:0] - } - return - case tagCompressed: - zbuf := bufs.GCache.Get(dlen) - defer bufs.GCache.Put(zbuf) - off += 1 - if err = a.read(zbuf, off); err != nil { - return buf[:0], err - } - - return zappy.Decode(buf, zbuf) - } - } - case 0: - return buf[:0], nil - case tagUsedLong: - cc := bufs.GCache.Get(1) - defer bufs.GCache.Put(cc) - dlen := m2n(int(first[1])<<8 | int(first[2])) - atoms := n2atoms(dlen) - tailOff := off + 16*int64(atoms) - 1 - if err = a.read(cc, tailOff); err != nil { - return - } - - switch tag := cc[0]; tag { - default: - return nil, &ErrILSEQ{Type: ErrTailTag, Off: off, Arg: int64(tag)} - case tagNotCompressed: - b = need(dlen, buf) - off += 3 - if err = a.read(b, off); err != nil { - b = buf[:0] - } - return - case tagCompressed: - zbuf := bufs.GCache.Get(dlen) - defer bufs.GCache.Put(zbuf) - off += 3 - if err = a.read(zbuf, off); err != nil { - return buf[:0], err - } - - return zappy.Decode(buf, zbuf) - } - case tagFreeShort, tagFreeLong: - return nil, &ErrILSEQ{Type: ErrExpUsedTag, Off: off, Arg: int64(tag)} - case tagUsedRelocated: - if relocated { - return nil, &ErrILSEQ{Type: ErrUnexpReloc, Off: off, Arg: relocSrc} - } - - handle = b2h(first[1:]) - relocated = true - goto reloc - } -} - -var reallocTestHook bool - -// Realloc sets the content of a block referred to by handle or returns an -// error, if any. -// -// Handle must have been obtained initially from Alloc and must be still valid, -// otherwise a database may get irreparably corrupted. -func (a *Allocator) Realloc(handle int64, b []byte) (err error) { - if handle <= 0 || handle > maxHandle { - return &ErrINVAL{"Realloc: handle out of limits", handle} - } - - a.cfree(handle) - if err = a.realloc(handle, b); err != nil { - return - } - - if reallocTestHook { - if err = cacheAudit(a.m, &a.lru); err != nil { - return - } - } - - a.cadd(b, handle) - return -} - -func (a *Allocator) realloc(handle int64, b []byte) (err error) { - var dlen, needAtoms0 int - - b8 := bufs.GCache.Get(8) - defer bufs.GCache.Put(b8) - dst := bufs.GCache.Get(zappy.MaxEncodedLen(len(b))) - defer bufs.GCache.Put(dst) - b, needAtoms0, cc, err := a.makeUsedBlock(dst, b) - if err != nil { - return - } - - needAtoms := int64(needAtoms0) - off := h2off(handle) - if err = a.read(b8[:], off); err != nil { - return - } - - switch tag := b8[0]; tag { - default: - dlen = int(b8[0]) - case tagUsedLong: - dlen = m2n(int(b8[1])<<8 | int(b8[2])) - case tagUsedRelocated: - if err = a.free(b2h(b8[1:]), handle, false); err != nil { - return err - } - - dlen = 0 - case tagFreeShort, tagFreeLong: - return &ErrINVAL{"Allocator.Realloc: invalid handle", handle} - } - - atoms := int64(n2atoms(dlen)) -retry: - switch { - case needAtoms < atoms: - // in place shrink - if err = a.writeUsedBlock(handle, cc, b); err != nil { - return - } - - fh, fa := handle+needAtoms, atoms-needAtoms - sz, err := a.f.Size() - if err != nil { - return err - } - - if h2off(fh)+16*fa == sz { - return a.f.Truncate(h2off(fh)) - } - - return a.free2(fh, fa) - case needAtoms == atoms: - // in place replace - return a.writeUsedBlock(handle, cc, b) - } - - // case needAtoms > atoms: - // in place extend or relocate - var sz int64 - if sz, err = a.f.Size(); err != nil { - return - } - - off = h2off(handle) - switch { - case off+atoms*16 == sz: - // relocating tail block - shortcut - return a.writeUsedBlock(handle, cc, b) - default: - if off+atoms*16 < sz { - // handle is not a tail block, check right neighbour - rh := handle + atoms - rtag, ratoms, p, n, e := a.nfo(rh) - if e != nil { - return e - } - - if rtag == tagFreeShort || rtag == tagFreeLong { - // Right neighbour is a free block - if needAtoms <= atoms+ratoms { - // can expand in place - if err = a.unlink(rh, ratoms, p, n); err != nil { - return - } - - atoms += ratoms - goto retry - - } - } - } - } - - if atoms > 1 { - if err = a.realloc(handle, nil); err != nil { - return - } - } - - var newH int64 - if newH, err = a.alloc(b, cc); err != nil { - return err - } - - rb := bufs.GCache.Cget(16) - defer bufs.GCache.Put(rb) - rb[0] = tagUsedRelocated - h2b(rb[1:], newH) - if err = a.writeAt(rb[:], h2off(handle)); err != nil { - return - } - - return a.writeUsedBlock(newH, cc, b) -} - -func (a *Allocator) writeAt(b []byte, off int64) (err error) { - var n int - if n, err = a.f.WriteAt(b, off); err != nil { - return - } - - if n != len(b) { - err = io.ErrShortWrite - } - return -} - -func (a *Allocator) write(off int64, b ...[]byte) (err error) { - rq := 0 - for _, part := range b { - rq += len(part) - } - buf := bufs.GCache.Get(rq) - defer bufs.GCache.Put(buf) - buf = buf[:0] - for _, part := range b { - buf = append(buf, part...) - } - return a.writeAt(buf, off) -} - -func (a *Allocator) read(b []byte, off int64) (err error) { - var rn int - if rn, err = a.f.ReadAt(b, off); rn != len(b) { - return &ErrILSEQ{Type: ErrOther, Off: off, More: err} - } - - return nil -} - -// nfo returns h's tag. If it's a free block then return also (s)ize (in -// atoms), (p)rev and (n)ext. If it's a used block then only (s)ize is returned -// (again in atoms). If it's a used relocate block then (n)ext is set to the -// relocation target handle. -func (a *Allocator) nfo(h int64) (tag byte, s, p, n int64, err error) { - off := h2off(h) - rq := int64(22) - sz, err := a.f.Size() - if err != nil { - return - } - - if off+rq >= sz { - if rq = sz - off; rq < 15 { - err = io.ErrUnexpectedEOF - return - } - } - - buf := bufs.GCache.Get(22) - defer bufs.GCache.Put(buf) - if err = a.read(buf[:rq], off); err != nil { - return - } - - switch tag = buf[0]; tag { - default: - s = int64(n2atoms(int(tag))) - case tagUsedLong: - s = int64(n2atoms(m2n(int(buf[1])<<8 | int(buf[2])))) - case tagFreeLong: - if rq < 22 { - err = io.ErrUnexpectedEOF - return - } - - s, p, n = b2h(buf[1:]), b2h(buf[8:]), b2h(buf[15:]) - case tagUsedRelocated: - s, n = 1, b2h(buf[1:]) - case tagFreeShort: - s, p, n = 1, b2h(buf[1:]), b2h(buf[8:]) - } - return -} - -// leftNfo returns nfo for h's left neighbor if h > 1 and the left neighbor is -// a free block. Otherwise all zero values are returned instead. -func (a *Allocator) leftNfo(h int64) (tag byte, s, p, n int64, err error) { - if !(h > 1) { - return - } - - buf := bufs.GCache.Get(8) - defer bufs.GCache.Put(buf) - off := h2off(h) - if err = a.read(buf[:], off-8); err != nil { - return - } - - switch tag := buf[7]; tag { - case tagFreeShort: - return a.nfo(h - 1) - case tagFreeLong: - return a.nfo(h - b2h(buf[:])) - } - return -} - -// Set h.prev = p -func (a *Allocator) prev(h, p int64) (err error) { - b := bufs.GCache.Get(7) - defer bufs.GCache.Put(b) - off := h2off(h) - if err = a.read(b[:1], off); err != nil { - return - } - - switch tag := b[0]; tag { - default: - return &ErrILSEQ{Type: ErrExpFreeTag, Off: off, Arg: int64(tag)} - case tagFreeShort: - off += 1 - case tagFreeLong: - off += 8 - } - return a.writeAt(h2b(b[:7], p), off) -} - -// Set h.next = n -func (a *Allocator) next(h, n int64) (err error) { - b := bufs.GCache.Get(7) - defer bufs.GCache.Put(b) - off := h2off(h) - if err = a.read(b[:1], off); err != nil { - return - } - - switch tag := b[0]; tag { - default: - return &ErrILSEQ{Type: ErrExpFreeTag, Off: off, Arg: int64(tag)} - case tagFreeShort: - off += 8 - case tagFreeLong: - off += 15 - } - return a.writeAt(h2b(b[:7], n), off) -} - -// Make the filer image @h a free block. -func (a *Allocator) makeFree(h, atoms, prev, next int64) (err error) { - buf := bufs.GCache.Get(22) - defer bufs.GCache.Put(buf) - switch { - case atoms == 1: - buf[0], buf[15] = tagFreeShort, tagFreeShort - h2b(buf[1:], prev) - h2b(buf[8:], next) - if err = a.write(h2off(h), buf[:16]); err != nil { - return - } - default: - - buf[0] = tagFreeLong - h2b(buf[1:], atoms) - h2b(buf[8:], prev) - h2b(buf[15:], next) - if err = a.write(h2off(h), buf[:22]); err != nil { - return - } - - h2b(buf[:], atoms) - buf[7] = tagFreeLong - if err = a.write(h2off(h+atoms)-8, buf[:8]); err != nil { - return - } - } - if prev != 0 { - if err = a.next(prev, h); err != nil { - return - } - } - - if next != 0 { - err = a.prev(next, h) - } - return -} - -func (a *Allocator) makeUsedBlock(dst []byte, b []byte) (w []byte, rqAtoms int, cc byte, err error) { - cc = tagNotCompressed - w = b - - var n int - if n = len(b); n > maxRq { - return nil, 0, 0, &ErrINVAL{"Allocator.makeUsedBlock: content size out of limits", n} - } - - rqAtoms = n2atoms(n) - if a.Compress && n > 14 { // attempt compression - if dst, err = zappy.Encode(dst, b); err != nil { - return - } - - n2 := len(dst) - if rqAtoms2 := n2atoms(n2); rqAtoms2 < rqAtoms { // compression saved at least a single atom - w, n, rqAtoms, cc = dst, n2, rqAtoms2, tagCompressed - } - } - return -} - -func (a *Allocator) writeUsedBlock(h int64, cc byte, b []byte) (err error) { - n := len(b) - rq := n2atoms(n) << 4 - buf := bufs.GCache.Get(rq) - defer bufs.GCache.Put(buf) - switch n <= maxShort { - case true: - buf[0] = byte(n) - copy(buf[1:], b) - case false: - m := n2m(n) - buf[0], buf[1], buf[2] = tagUsedLong, byte(m>>8), byte(m) - copy(buf[3:], b) - } - if p := n2padding(n); p != 0 { - copy(buf[rq-1-p:], zeros[:]) - } - buf[rq-1] = cc - return a.writeAt(buf, h2off(h)) -} - -func (a *Allocator) verifyUnused(h, totalAtoms int64, tag byte, log func(error) bool, fast bool) (atoms, prev, next int64, err error) { - switch tag { - default: - panic("internal error") - case tagFreeShort: - var b [16]byte - off := h2off(h) - if err = a.read(b[:], off); err != nil { - return - } - - if b[15] != tagFreeShort { - err = &ErrILSEQ{Type: ErrShortFreeTailTag, Off: off, Arg: int64(b[15])} - log(err) - return - } - - atoms, prev, next = 1, b2h(b[1:]), b2h(b[8:]) - case tagFreeLong: - var b [22]byte - off := h2off(h) - if err = a.read(b[:], off); err != nil { - return - } - - atoms, prev, next = b2h(b[1:]), b2h(b[8:]), b2h(b[15:]) - if fast { - return - } - - if atoms < 2 { - err = &ErrILSEQ{Type: ErrLongFreeBlkTooShort, Off: off, Arg: int64(atoms)} - break - } - - if h+atoms-1 > totalAtoms { - err = &ErrILSEQ{Type: ErrLongFreeBlkTooLong, Off: off, Arg: atoms} - break - } - - if prev > totalAtoms { - err = &ErrILSEQ{Type: ErrLongFreePrevBeyondEOF, Off: off, Arg: next} - break - } - - if next > totalAtoms { - err = &ErrILSEQ{Type: ErrLongFreeNextBeyondEOF, Off: off, Arg: next} - break - } - - toff := h2off(h+atoms) - 8 - if err = a.read(b[:8], toff); err != nil { - return - } - - if b[7] != tag { - err = &ErrILSEQ{Type: ErrLongFreeTailTag, Off: off, Arg: int64(b[7])} - break - } - - if s2 := b2h(b[:]); s2 != atoms { - err = &ErrILSEQ{Type: ErrVerifyTailSize, Off: off, Arg: atoms, Arg2: s2} - break - } - - } - if err != nil { - log(err) - } - return -} - -func (a *Allocator) verifyUsed(h, totalAtoms int64, tag byte, buf, ubuf []byte, log func(error) bool, fast bool) (compressed bool, dlen int, atoms, link int64, err error) { - var ( - padding int - doff int64 - padZeros [15]byte - tailBuf [16]byte - ) - - switch tag { - default: // Short used - dlen = int(tag) - atoms = int64((dlen+1)/16) + 1 - padding = 15 - (dlen+1)%16 - doff = h2off(h) + 1 - case tagUsedLong: - off := h2off(h) + 1 - var b2 [2]byte - if err = a.read(b2[:], off); err != nil { - return - } - - dlen = m2n(int(b2[0])<<8 | int(b2[1])) - atoms = int64((dlen+3)/16) + 1 - padding = 15 - (dlen+3)%16 - doff = h2off(h) + 3 - case tagUsedRelocated: - dlen = 7 - atoms = 1 - padding = 7 - doff = h2off(h) + 1 - case tagFreeShort, tagFreeLong: - panic("internal error") - } - - if fast { - if tag == tagUsedRelocated { - dlen = 0 - if err = a.read(buf[:7], doff); err != nil { - return - } - - link = b2h(buf) - } - - return false, dlen, atoms, link, nil - } - - if ok := h+atoms-1 <= totalAtoms; !ok { // invalid last block - err = &ErrILSEQ{Type: ErrVerifyUsedSpan, Off: h2off(h), Arg: atoms} - log(err) - return - } - - tailsz := 1 + padding - off := h2off(h) + 16*atoms - int64(tailsz) - if err = a.read(tailBuf[:tailsz], off); err != nil { - return false, 0, 0, 0, err - } - - if ok := bytes.Equal(padZeros[:padding], tailBuf[:padding]); !ok { - err = &ErrILSEQ{Type: ErrVerifyPadding, Off: h2off(h)} - log(err) - return - } - - var cc byte - switch cc = tailBuf[padding]; cc { - default: - err = &ErrILSEQ{Type: ErrTailTag, Off: h2off(h)} - log(err) - return - case tagCompressed: - compressed = true - if tag == tagUsedRelocated { - err = &ErrILSEQ{Type: ErrTailTag, Off: h2off(h)} - log(err) - return - } - - fallthrough - case tagNotCompressed: - if err = a.read(buf[:dlen], doff); err != nil { - return false, 0, 0, 0, err - } - } - - if cc == tagCompressed { - if ubuf, err = zappy.Decode(ubuf, buf[:dlen]); err != nil || len(ubuf) > maxRq { - err = &ErrILSEQ{Type: ErrDecompress, Off: h2off(h)} - log(err) - return - } - - dlen = len(ubuf) - } - - if tag == tagUsedRelocated { - link = b2h(buf) - if link == 0 { - err = &ErrILSEQ{Type: ErrNullReloc, Off: h2off(h)} - log(err) - return - } - - if link > totalAtoms { // invalid last block - err = &ErrILSEQ{Type: ErrRelocBeyondEOF, Off: h2off(h), Arg: link} - log(err) - return - } - } - - return -} - -var nolog = func(error) bool { return false } - -// Verify attempts to find any structural errors in a Filer wrt the -// organization of it as defined by Allocator. 'bitmap' is a scratch pad for -// necessary bookkeeping and will grow to at most to Allocator's -// Filer.Size()/128 (0,78%). Any problems found are reported to 'log' except -// non verify related errors like disk read fails etc. If 'log' returns false -// or the error doesn't allow to (reliably) continue, the verification process -// is stopped and an error is returned from the Verify function. Passing a nil -// log works like providing a log function always returning false. Any -// non-structural errors, like for instance Filer read errors, are NOT reported -// to 'log', but returned as the Verify's return value, because Verify cannot -// proceed in such cases. Verify returns nil only if it fully completed -// verifying Allocator's Filer without detecting any error. -// -// It is recommended to limit the number reported problems by returning false -// from 'log' after reaching some limit. Huge and corrupted DB can produce an -// overwhelming error report dataset. -// -// The verifying process will scan the whole DB at least 3 times (a trade -// between processing space and time consumed). It doesn't read the content of -// free blocks above the head/tail info bytes. If the 3rd phase detects lost -// free space, then a 4th scan (a faster one) is performed to precisely report -// all of them. -// -// If the DB/Filer to be verified is reasonably small, respective if its -// size/128 can comfortably fit within process's free memory, then it is -// recommended to consider using a MemFiler for the bit map. -// -// Statistics are returned via 'stats' if non nil. The statistics are valid -// only if Verify succeeded, ie. it didn't reported anything to log and it -// returned a nil error. -func (a *Allocator) Verify(bitmap Filer, log func(error) bool, stats *AllocStats) (err error) { - if log == nil { - log = nolog - } - - n, err := bitmap.Size() - if err != nil { - return - } - - if n != 0 { - return &ErrINVAL{"Allocator.Verify: bit map initial size non zero (%d)", n} - } - - var bits int64 - bitMask := [8]byte{1, 2, 4, 8, 16, 32, 64, 128} - byteBuf := []byte{0} - - //DONE - // +performance, this implementation is hopefully correct but _very_ - // naive, probably good as a prototype only. Use maybe a MemFiler - // "cache" etc. - // ---- - // Turns out the OS caching is as effective as it can probably get. - bit := func(on bool, h int64) (wasOn bool, err error) { - m := bitMask[h&7] - off := h >> 3 - var v byte - sz, err := bitmap.Size() - if err != nil { - return - } - - if off < sz { - if n, err := bitmap.ReadAt(byteBuf, off); n != 1 { - return false, &ErrILSEQ{Type: ErrOther, Off: off, More: fmt.Errorf("Allocator.Verify - reading bitmap: %s", err)} - } - - v = byteBuf[0] - } - switch wasOn = v&m != 0; on { - case true: - if !wasOn { - v |= m - bits++ - } - case false: - if wasOn { - v ^= m - bits-- - } - } - byteBuf[0] = v - if n, err := bitmap.WriteAt(byteBuf, off); n != 1 || err != nil { - return false, &ErrILSEQ{Type: ErrOther, Off: off, More: fmt.Errorf("Allocator.Verify - writing bitmap: %s", err)} - } - - return - } - - // Phase 1 - sequentially scan a.f to reliably determine block - // boundaries. Set a bit for every block start. - var ( - buf, ubuf [maxRq]byte - prevH, h, atoms int64 - wasOn bool - tag byte - st = AllocStats{ - AllocMap: map[int64]int64{}, - FreeMap: map[int64]int64{}, - } - dlen int - ) - - fsz, err := a.f.Size() - if err != nil { - return - } - - ok := fsz%16 == 0 - totalAtoms := (fsz - fltSz) / atomLen - if !ok { - err = &ErrILSEQ{Type: ErrFileSize, Name: a.f.Name(), Arg: fsz} - log(err) - return - } - - st.TotalAtoms = totalAtoms - prevTag := -1 - lastH := int64(-1) - - for h = 1; h <= totalAtoms; h += atoms { - prevH = h // For checking last block == used - - off := h2off(h) - if err = a.read(buf[:1], off); err != nil { - return - } - - switch tag = buf[0]; tag { - default: // Short used - fallthrough - case tagUsedLong, tagUsedRelocated: - var compressed bool - if compressed, dlen, atoms, _, err = a.verifyUsed(h, totalAtoms, tag, buf[:], ubuf[:], log, false); err != nil { - return - } - - if compressed { - st.Compression++ - } - st.AllocAtoms += atoms - switch { - case tag == tagUsedRelocated: - st.AllocMap[1]++ - st.Relocations++ - default: - st.AllocMap[atoms]++ - st.AllocBytes += int64(dlen) - st.Handles++ - } - case tagFreeShort, tagFreeLong: - if prevTag == tagFreeShort || prevTag == tagFreeLong { - err = &ErrILSEQ{Type: ErrAdjacentFree, Off: h2off(lastH), Arg: off} - log(err) - return - } - - if atoms, _, _, err = a.verifyUnused(h, totalAtoms, tag, log, false); err != nil { - return - } - - st.FreeMap[atoms]++ - st.FreeAtoms += atoms - } - - if wasOn, err = bit(true, h); err != nil { - return - } - - if wasOn { - panic("internal error") - } - - prevTag = int(tag) - lastH = h - } - - if totalAtoms != 0 && (tag == tagFreeShort || tag == tagFreeLong) { - err = &ErrILSEQ{Type: ErrFreeTailBlock, Off: h2off(prevH)} - log(err) - return - } - - // Phase 2 - check used blocks, turn off the map bit for every used - // block. - for h = 1; h <= totalAtoms; h += atoms { - off := h2off(h) - if err = a.read(buf[:1], off); err != nil { - return - } - - var link int64 - switch tag = buf[0]; tag { - default: // Short used - fallthrough - case tagUsedLong, tagUsedRelocated: - if _, _, atoms, link, err = a.verifyUsed(h, totalAtoms, tag, buf[:], ubuf[:], log, true); err != nil { - return - } - case tagFreeShort, tagFreeLong: - if atoms, _, _, err = a.verifyUnused(h, totalAtoms, tag, log, true); err != nil { - return - } - } - - turnoff := true - switch tag { - case tagUsedRelocated: - if err = a.read(buf[:1], h2off(link)); err != nil { - return - } - - switch linkedTag := buf[0]; linkedTag { - case tagFreeShort, tagFreeLong, tagUsedRelocated: - err = &ErrILSEQ{Type: ErrInvalidRelocTarget, Off: off, Arg: link} - log(err) - return - } - - case tagFreeShort, tagFreeLong: - turnoff = false - } - - if !turnoff { - continue - } - - if wasOn, err = bit(false, h); err != nil { - return - } - - if !wasOn { - panic("internal error") - } - - } - - // Phase 3 - using the flt check heads link to proper free blocks. For - // every free block, walk the list, verify the {next, prev} links and - // turn the respective map bit off. After processing all free lists, - // the map bits count should be zero. Otherwise there are "lost" free - // blocks. - - var prev, next, fprev, fnext int64 - rep := a.flt - - for _, list := range rep { - prev, next = 0, list.head - for ; next != 0; prev, next = next, fnext { - if wasOn, err = bit(false, next); err != nil { - return - } - - if !wasOn { - err = &ErrILSEQ{Type: ErrFLT, Off: h2off(next), Arg: h} - log(err) - return - } - - off := h2off(next) - if err = a.read(buf[:1], off); err != nil { - return - } - - switch tag = buf[0]; tag { - default: - panic("internal error") - case tagFreeShort, tagFreeLong: - if atoms, fprev, fnext, err = a.verifyUnused(next, totalAtoms, tag, log, true); err != nil { - return - } - - if min := list.minSize; atoms < min { - err = &ErrILSEQ{Type: ErrFLTSize, Off: h2off(next), Arg: atoms, Arg2: min} - log(err) - return - } - - if fprev != prev { - err = &ErrILSEQ{Type: ErrFreeChaining, Off: h2off(next)} - log(err) - return - } - } - } - - } - - if bits == 0 { // Verify succeeded - if stats != nil { - *stats = st - } - return - } - - // Phase 4 - if after phase 3 there are lost free blocks, report all of - // them to 'log' - for i := range ubuf { // setup zeros for compares - ubuf[i] = 0 - } - - var off, lh int64 - rem, err := bitmap.Size() - if err != nil { - return err - } - - for rem != 0 { - rq := int(mathutil.MinInt64(64*1024, rem)) - var n int - if n, err = bitmap.ReadAt(buf[:rq], off); n != rq { - return &ErrILSEQ{Type: ErrOther, Off: off, More: fmt.Errorf("bitmap ReadAt(size %d, off %#x): %s", rq, off, err)} - } - - if !bytes.Equal(buf[:rq], ubuf[:rq]) { - for d, v := range buf[:rq] { - if v != 0 { - for i, m := range bitMask { - if v&m != 0 { - lh = 8*(off+int64(d)) + int64(i) - err = &ErrILSEQ{Type: ErrLostFreeBlock, Off: h2off(lh)} - log(err) - return - } - } - } - } - } - - off += int64(rq) - rem -= int64(rq) - } - - return -} - -type fltSlot struct { - head int64 - minSize int64 -} - -func (f fltSlot) String() string { - return fmt.Sprintf("head %#x, minSize %#x\n", f.head, f.minSize) -} - -type flt [14]fltSlot - -func (f *flt) init() { - sz := 1 - for i := range *f { - f[i].minSize, f[i].head = int64(sz), 0 - sz <<= 1 - } - f[13].minSize = 4112 -} - -func (f *flt) load(fi Filer, off int64) (err error) { - b := bufs.GCache.Get(fltSz) - defer bufs.GCache.Put(b) - if _, err = fi.ReadAt(b[:], off); err != nil { - return - } - - for i := range *f { - off := 8*i + 1 - f[i].head = b2h(b[off:]) - } - return -} - -func (f *flt) find(rq int) (h int64) { - switch { - case rq < 1: - panic(rq) - case rq >= maxFLTRq: - h, f[13].head = f[13].head, 0 - return - default: - g := f[mathutil.Log2Uint16(uint16(rq)):] - for i := range g { - p := &g[i] - if rq <= int(p.minSize) { - if h = p.head; h != 0 { - p.head = 0 - return - } - } - } - return - } -} - -func (f *flt) head(atoms int64) (h int64) { - switch { - case atoms < 1: - panic(atoms) - case atoms >= maxFLTRq: - return f[13].head - default: - lg := mathutil.Log2Uint16(uint16(atoms)) - g := f[lg:] - for i := range g { - if atoms < g[i+1].minSize { - return g[i].head - } - } - panic("internal error") - } -} - -func (f *flt) setHead(h, atoms int64, fi Filer) (err error) { - switch { - case atoms < 1: - panic(atoms) - case atoms >= maxFLTRq: - b := bufs.GCache.Get(7) - defer bufs.GCache.Put(b) - if _, err = fi.WriteAt(h2b(b[:], h), 8*13+1); err != nil { - return - } - - f[13].head = h - return - default: - lg := mathutil.Log2Uint16(uint16(atoms)) - g := f[lg:] - for i := range f { - if atoms < g[i+1].minSize { - b := bufs.GCache.Get(7) - defer bufs.GCache.Put(b) - if _, err = fi.WriteAt(h2b(b[:], h), 8*int64(i+lg)+1); err != nil { - return - } - - g[i].head = h - return - } - } - panic("internal error") - } -} - -func (f *flt) String() string { - a := []string{} - for i, v := range *f { - a = append(a, fmt.Sprintf("[%2d] %s", i, v)) - } - return strings.Join(a, "") -} - -type node struct { - b []byte - h int64 - prev, next *node -} - -type cache []*node - -func (c *cache) get(n int) *node { - r, _ := c.get2(n) - return r -} - -func (c *cache) get2(n int) (r *node, isZeroed bool) { - s := *c - lens := len(s) - if lens == 0 { - return &node{b: make([]byte, n, mathutil.Min(2*n, maxBuf))}, true - } - - i := sort.Search(lens, func(x int) bool { return len(s[x].b) >= n }) - if i == lens { - i-- - s[i].b, isZeroed = make([]byte, n, mathutil.Min(2*n, maxBuf)), true - } - - r = s[i] - r.b = r.b[:n] - copy(s[i:], s[i+1:]) - s = s[:lens-1] - *c = s - return -} - -func (c *cache) cget(n int) (r *node) { - r, ok := c.get2(n) - if ok { - return - } - - for i := range r.b { - r.b[i] = 0 - } - return -} - -func (c *cache) size() (sz int64) { - for _, n := range *c { - sz += int64(cap(n.b)) - } - return -} - -func (c *cache) put(n *node) *node { - s := *c - n.b = n.b[:cap(n.b)] - lenb := len(n.b) - lens := len(s) - i := sort.Search(lens, func(x int) bool { return len(s[x].b) >= lenb }) - s = append(s, nil) - copy(s[i+1:], s[i:]) - s[i] = n - *c = s - return n -} - -type lst struct { - front, back *node -} - -func (l *lst) pushFront(n *node) *node { - if l.front == nil { - l.front, l.back, n.prev, n.next = n, n, nil, nil - return n - } - - n.prev, n.next, l.front.prev, l.front = nil, l.front, n, n - return n -} - -func (l *lst) remove(n *node) *node { - if n.prev == nil { - l.front = n.next - } else { - n.prev.next = n.next - } - if n.next == nil { - l.back = n.prev - } else { - n.next.prev = n.prev - } - n.prev, n.next = nil, nil - return n -} - -func (l *lst) removeBack() *node { - return l.remove(l.back) -} - -func (l *lst) moveToFront(n *node) *node { - return l.pushFront(l.remove(n)) -} - -func (l *lst) size() (sz int64) { - for n := l.front; n != nil; n = n.next { - sz += int64(cap(n.b)) - } - return -} - -func cacheAudit(m map[int64]*node, l *lst) (err error) { - cnt := 0 - for h, n := range m { - if g, e := n.h, h; g != e { - return fmt.Errorf("cacheAudit: invalid node handle %d != %d", g, e) - } - - if cnt, err = l.audit(n, true); err != nil { - return - } - } - - if g, e := cnt, len(m); g != e { - return fmt.Errorf("cacheAudit: invalid cache size %d != %d", g, e) - } - - return -} - -func (l *lst) audit(n *node, onList bool) (cnt int, err error) { - if !onList && (n.prev != nil || n.next != nil) { - return -1, fmt.Errorf("lst.audit: free node with non nil linkage") - } - - if l.front == nil && l.back != nil || l.back == nil && l.front != nil { - return -1, fmt.Errorf("lst.audit: one of .front/.back is nil while the other is non nil") - } - - if l.front == l.back && l.front != nil { - x := l.front - if x.prev != nil || x.next != nil { - return -1, fmt.Errorf("lst.audit: single node has non nil linkage") - } - - if onList && x != n { - return -1, fmt.Errorf("lst.audit: single node is alien") - } - } - - seen := false - var prev *node - x := l.front - for x != nil { - cnt++ - if x.prev != prev { - return -1, fmt.Errorf("lst.audit: broken .prev linkage") - } - - if x == n { - seen = true - } - - prev = x - x = x.next - } - - if prev != l.back { - return -1, fmt.Errorf("lst.audit: broken .back linkage") - } - - if onList && !seen { - return -1, fmt.Errorf("lst.audit: node missing in list") - } - - if !onList && seen { - return -1, fmt.Errorf("lst.audit: node should not be on the list") - } - - return -} diff --git a/Godeps/_workspace/src/github.com/cznic/exp/lldb/filer.go b/Godeps/_workspace/src/github.com/cznic/exp/lldb/filer.go deleted file mode 100644 index 38b389387a..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/exp/lldb/filer.go +++ /dev/null @@ -1,192 +0,0 @@ -// Copyright 2014 The lldb Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// An abstraction of file like (persistent) storage with optional (abstracted) -// support for structural integrity. - -package lldb - -import ( - "fmt" - - "github.com/cznic/mathutil" -) - -func doubleTrouble(first, second error) error { - return fmt.Errorf("%q. Additionally, while attempting to recover (rollback): %q", first, second) -} - -// A Filer is a []byte-like model of a file or similar entity. It may -// optionally implement support for structural transaction safety. In contrast -// to a file stream, a Filer is not sequentially accessible. ReadAt and WriteAt -// are always "addressed" by an offset and are assumed to perform atomically. -// A Filer is not safe for concurrent access, it's designed for consumption by -// the other objects in package, which should use a Filer from one goroutine -// only or via a mutex. BeginUpdate, EndUpdate and Rollback must be either all -// implemented by a Filer for structural integrity - or they should be all -// no-ops; where/if that requirement is relaxed. -// -// If a Filer wraps another Filer implementation, it usually invokes the same -// methods on the "inner" one, after some possible argument translations etc. -// If a Filer implements the structural transactions handling methods -// (BeginUpdate, EndUpdate and Rollback) as no-ops _and_ wraps another Filer: -// it then still MUST invoke those methods on the inner Filer. This is -// important for the case where a RollbackFiler exists somewhere down the -// chain. It's also important for an Allocator - to know when it must -// invalidate its FLT cache. -type Filer interface { - // BeginUpdate increments the "nesting" counter (initially zero). Every - // call to BeginUpdate must be eventually "balanced" by exactly one of - // EndUpdate or Rollback. Calls to BeginUpdate may nest. - BeginUpdate() error - - // Analogous to os.File.Close(). - Close() error - - // EndUpdate decrements the "nesting" counter. If it's zero after that - // then assume the "storage" has reached structural integrity (after a - // batch of partial updates). If a Filer implements some support for - // that (write ahead log, journal, etc.) then the appropriate actions - // are to be taken for nesting == 0. Invocation of an unbalanced - // EndUpdate is an error. - EndUpdate() error - - // Analogous to os.File.Name(). - Name() string - - // PunchHole deallocates space inside a "file" in the byte range - // starting at off and continuing for size bytes. The actual hole - // created by PunchHole may be smaller than requested. The Filer size - // (as reported by `Size()` does not change when hole punching, even - // when punching the end of a file off. In contrast to the Linux - // implementation of FALLOC_FL_PUNCH_HOLE in `fallocate`(2); a Filer is - // free not only to ignore `PunchHole()` (implement it as a nop), but - // additionally no guarantees about the content of the hole, when - // eventually read back, are required, i.e. any data, not only zeros, - // can be read from the "hole", including just anything what was left - // there - with all of the possible security problems. - PunchHole(off, size int64) error - - // As os.File.ReadAt. Note: `off` is an absolute "file pointer" - // address and cannot be negative even when a Filer is a InnerFiler. - ReadAt(b []byte, off int64) (n int, err error) - - // Rollback cancels and undoes the innermost pending update level. - // Rollback decrements the "nesting" counter. If a Filer implements - // some support for keeping structural integrity (write ahead log, - // journal, etc.) then the appropriate actions are to be taken. - // Invocation of an unbalanced Rollback is an error. - Rollback() error - - // Analogous to os.File.FileInfo().Size(). - Size() (int64, error) - - // Analogous to os.Sync(). - Sync() (err error) - - // Analogous to os.File.Truncate(). - Truncate(size int64) error - - // Analogous to os.File.WriteAt(). Note: `off` is an absolute "file - // pointer" address and cannot be negative even when a Filer is a - // InnerFiler. - WriteAt(b []byte, off int64) (n int, err error) -} - -var _ Filer = &InnerFiler{} // Ensure InnerFiler is a Filer. - -// A InnerFiler is a Filer with added addressing/size translation. -type InnerFiler struct { - outer Filer - off int64 -} - -// NewInnerFiler returns a new InnerFiler wrapped by `outer` in a way which -// adds `off` to every access. -// -// For example, considering: -// -// inner := NewInnerFiler(outer, 10) -// -// then -// -// inner.WriteAt([]byte{42}, 4) -// -// translates to -// -// outer.WriteAt([]byte{42}, 14) -// -// But an attempt to emulate -// -// outer.WriteAt([]byte{17}, 9) -// -// by -// -// inner.WriteAt([]byte{17}, -1) -// -// will fail as the `off` parameter can never be < 0. Also note that -// -// inner.Size() == outer.Size() - off, -// -// i.e. `inner` pretends no `outer` exists. Finally, after e.g. -// -// inner.Truncate(7) -// outer.Size() == 17 -// -// will be true. -func NewInnerFiler(outer Filer, off int64) *InnerFiler { return &InnerFiler{outer, off} } - -// BeginUpdate implements Filer. -func (f *InnerFiler) BeginUpdate() error { return f.outer.BeginUpdate() } - -// Close implements Filer. -func (f *InnerFiler) Close() (err error) { return f.outer.Close() } - -// EndUpdate implements Filer. -func (f *InnerFiler) EndUpdate() error { return f.outer.EndUpdate() } - -// Name implements Filer. -func (f *InnerFiler) Name() string { return f.outer.Name() } - -// PunchHole implements Filer. `off`, `size` must be >= 0. -func (f *InnerFiler) PunchHole(off, size int64) error { return f.outer.PunchHole(f.off+off, size) } - -// ReadAt implements Filer. `off` must be >= 0. -func (f *InnerFiler) ReadAt(b []byte, off int64) (n int, err error) { - if off < 0 { - return 0, &ErrINVAL{f.outer.Name() + ":ReadAt invalid off", off} - } - - return f.outer.ReadAt(b, f.off+off) -} - -// Rollback implements Filer. -func (f *InnerFiler) Rollback() error { return f.outer.Rollback() } - -// Size implements Filer. -func (f *InnerFiler) Size() (int64, error) { - sz, err := f.outer.Size() - if err != nil { - return 0, err - } - - return mathutil.MaxInt64(sz-f.off, 0), nil -} - -// Sync() implements Filer. -func (f *InnerFiler) Sync() (err error) { - return f.outer.Sync() -} - -// Truncate implements Filer. -func (f *InnerFiler) Truncate(size int64) error { return f.outer.Truncate(size + f.off) } - -// WriteAt implements Filer. `off` must be >= 0. -func (f *InnerFiler) WriteAt(b []byte, off int64) (n int, err error) { - if off < 0 { - return 0, &ErrINVAL{f.outer.Name() + ":WriteAt invalid off", off} - } - - return f.outer.WriteAt(b, f.off+off) -} diff --git a/Godeps/_workspace/src/github.com/cznic/exp/lldb/gb.go b/Godeps/_workspace/src/github.com/cznic/exp/lldb/gb.go deleted file mode 100644 index e9090a5473..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/exp/lldb/gb.go +++ /dev/null @@ -1,812 +0,0 @@ -// Copyright 2014 The lldb Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Utilities to encode/decode and collate Go predeclared scalar types (and the -// typeless nil and []byte). The encoding format is a variation of the one -// used by the "encoding/gob" package. - -package lldb - -import ( - "bytes" - "fmt" - "math" - - "github.com/cznic/mathutil" -) - -const ( - gbNull = iota // 0x00 - gbFalse // 0x01 - gbTrue // 0x02 - gbFloat0 // 0x03 - gbFloat1 // 0x04 - gbFloat2 // 0x05 - gbFloat3 // 0x06 - gbFloat4 // 0x07 - gbFloat5 // 0x08 - gbFloat6 // 0x09 - gbFloat7 // 0x0a - gbFloat8 // 0x0b - gbComplex0 // 0x0c - gbComplex1 // 0x0d - gbComplex2 // 0x0e - gbComplex3 // 0x0f - gbComplex4 // 0x10 - gbComplex5 // 0x11 - gbComplex6 // 0x12 - gbComplex7 // 0x13 - gbComplex8 // 0x14 - gbBytes00 // 0x15 - gbBytes01 // 0x16 - gbBytes02 // 0x17 - gbBytes03 // 0x18 - gbBytes04 // 0x19 - gbBytes05 // 0x1a - gbBytes06 // 0x1b - gbBytes07 // 0x1c - gbBytes08 // 0x1d - gbBytes09 // 0x1e - gbBytes10 // 0x1f - gbBytes11 // 0x20 - gbBytes12 // 0x21 - gbBytes13 // 0x22 - gbBytes14 // 0x23 - gbBytes15 // 0x24 - gbBytes16 // 0x25 - gbBytes17 // Ox26 - gbBytes1 // 0x27 - gbBytes2 // 0x28: Offset by one to allow 64kB sized []byte. - gbString00 // 0x29 - gbString01 // 0x2a - gbString02 // 0x2b - gbString03 // 0x2c - gbString04 // 0x2d - gbString05 // 0x2e - gbString06 // 0x2f - gbString07 // 0x30 - gbString08 // 0x31 - gbString09 // 0x32 - gbString10 // 0x33 - gbString11 // 0x34 - gbString12 // 0x35 - gbString13 // 0x36 - gbString14 // 0x37 - gbString15 // 0x38 - gbString16 // 0x39 - gbString17 // 0x3a - gbString1 // 0x3b - gbString2 // 0x3c - gbUintP1 // 0x3d - gbUintP2 // 0x3e - gbUintP3 // 0x3f - gbUintP4 // 0x40 - gbUintP5 // 0x41 - gbUintP6 // 0x42 - gbUintP7 // 0x43 - gbUintP8 // 0x44 - gbIntM8 // 0x45 - gbIntM7 // 0x46 - gbIntM6 // 0x47 - gbIntM5 // 0x48 - gbIntM4 // 0x49 - gbIntM3 // 0x4a - gbIntM2 // 0x4b - gbIntM1 // 0x4c - gbIntP1 // 0x4d - gbIntP2 // 0x4e - gbIntP3 // 0x4f - gbIntP4 // 0x50 - gbIntP5 // 0x51 - gbIntP6 // 0x52 - gbIntP7 // 0x53 - gbIntP8 // 0x54 - gbInt0 // 0x55 - - gbIntMax = 255 - gbInt0 // 0xff == 170 -) - -// EncodeScalars encodes a vector of predeclared scalar type values to a -// []byte, making it suitable to store it as a "record" in a DB or to use it as -// a key of a BTree. -func EncodeScalars(scalars ...interface{}) (b []byte, err error) { - for _, scalar := range scalars { - switch x := scalar.(type) { - default: - return nil, &ErrINVAL{"EncodeScalars: unsupported type", fmt.Sprintf("%T in `%#v`", x, scalars)} - - case nil: - b = append(b, gbNull) - - case bool: - switch x { - case false: - b = append(b, gbFalse) - case true: - b = append(b, gbTrue) - } - - case float32: - encFloat(float64(x), &b) - case float64: - encFloat(x, &b) - - case complex64: - encComplex(complex128(x), &b) - case complex128: - encComplex(x, &b) - - case string: - n := len(x) - if n <= 17 { - b = append(b, byte(gbString00+n)) - b = append(b, []byte(x)...) - break - } - - if n > 65535 { - return nil, fmt.Errorf("EncodeScalars: cannot encode string of length %d (limit 65536)", n) - } - - pref := byte(gbString1) - if n > 255 { - pref++ - } - b = append(b, pref) - encUint0(uint64(n), &b) - b = append(b, []byte(x)...) - - case int8: - encInt(int64(x), &b) - case int16: - encInt(int64(x), &b) - case int32: - encInt(int64(x), &b) - case int64: - encInt(x, &b) - case int: - encInt(int64(x), &b) - - case uint8: - encUint(uint64(x), &b) - case uint16: - encUint(uint64(x), &b) - case uint32: - encUint(uint64(x), &b) - case uint64: - encUint(x, &b) - case uint: - encUint(uint64(x), &b) - case []byte: - n := len(x) - if n <= 17 { - b = append(b, byte(gbBytes00+n)) - b = append(b, []byte(x)...) - break - } - - if n > 655356 { - return nil, fmt.Errorf("EncodeScalars: cannot encode []byte of length %d (limit 65536)", n) - } - - pref := byte(gbBytes1) - if n > 255 { - pref++ - } - b = append(b, pref) - if n <= 255 { - b = append(b, byte(n)) - } else { - n-- - b = append(b, byte(n>>8), byte(n)) - } - b = append(b, x...) - } - } - return -} - -func encComplex(f complex128, b *[]byte) { - encFloatPrefix(gbComplex0, real(f), b) - encFloatPrefix(gbComplex0, imag(f), b) -} - -func encFloatPrefix(prefix byte, f float64, b *[]byte) { - u := math.Float64bits(f) - var n uint64 - for i := 0; i < 8; i++ { - n <<= 8 - n |= u & 0xFF - u >>= 8 - } - bits := mathutil.BitLenUint64(n) - if bits == 0 { - *b = append(*b, prefix) - return - } - - // 0 1 2 3 4 5 6 7 8 9 - // . 1 1 1 1 1 1 1 1 2 - encUintPrefix(prefix+1+byte((bits-1)>>3), n, b) -} - -func encFloat(f float64, b *[]byte) { - encFloatPrefix(gbFloat0, f, b) -} - -func encUint0(n uint64, b *[]byte) { - switch { - case n <= 0xff: - *b = append(*b, byte(n)) - case n <= 0xffff: - *b = append(*b, byte(n>>8), byte(n)) - case n <= 0xffffff: - *b = append(*b, byte(n>>16), byte(n>>8), byte(n)) - case n <= 0xffffffff: - *b = append(*b, byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) - case n <= 0xffffffffff: - *b = append(*b, byte(n>>32), byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) - case n <= 0xffffffffffff: - *b = append(*b, byte(n>>40), byte(n>>32), byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) - case n <= 0xffffffffffffff: - *b = append(*b, byte(n>>48), byte(n>>40), byte(n>>32), byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) - case n <= math.MaxUint64: - *b = append(*b, byte(n>>56), byte(n>>48), byte(n>>40), byte(n>>32), byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) - } -} - -func encUintPrefix(prefix byte, n uint64, b *[]byte) { - *b = append(*b, prefix) - encUint0(n, b) -} - -func encUint(n uint64, b *[]byte) { - bits := mathutil.Max(1, mathutil.BitLenUint64(n)) - encUintPrefix(gbUintP1+byte((bits-1)>>3), n, b) -} - -func encInt(n int64, b *[]byte) { - switch { - case n < -0x100000000000000: - *b = append(*b, byte(gbIntM8), byte(n>>56), byte(n>>48), byte(n>>40), byte(n>>32), byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) - case n < -0x1000000000000: - *b = append(*b, byte(gbIntM7), byte(n>>48), byte(n>>40), byte(n>>32), byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) - case n < -0x10000000000: - *b = append(*b, byte(gbIntM6), byte(n>>40), byte(n>>32), byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) - case n < -0x100000000: - *b = append(*b, byte(gbIntM5), byte(n>>32), byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) - case n < -0x1000000: - *b = append(*b, byte(gbIntM4), byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) - case n < -0x10000: - *b = append(*b, byte(gbIntM3), byte(n>>16), byte(n>>8), byte(n)) - case n < -0x100: - *b = append(*b, byte(gbIntM2), byte(n>>8), byte(n)) - case n < 0: - *b = append(*b, byte(gbIntM1), byte(n)) - case n <= gbIntMax: - *b = append(*b, byte(gbInt0+n)) - case n <= 0xff: - *b = append(*b, gbIntP1, byte(n)) - case n <= 0xffff: - *b = append(*b, gbIntP2, byte(n>>8), byte(n)) - case n <= 0xffffff: - *b = append(*b, gbIntP3, byte(n>>16), byte(n>>8), byte(n)) - case n <= 0xffffffff: - *b = append(*b, gbIntP4, byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) - case n <= 0xffffffffff: - *b = append(*b, gbIntP5, byte(n>>32), byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) - case n <= 0xffffffffffff: - *b = append(*b, gbIntP6, byte(n>>40), byte(n>>32), byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) - case n <= 0xffffffffffffff: - *b = append(*b, gbIntP7, byte(n>>48), byte(n>>40), byte(n>>32), byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) - case n <= 0x7fffffffffffffff: - *b = append(*b, gbIntP8, byte(n>>56), byte(n>>48), byte(n>>40), byte(n>>32), byte(n>>24), byte(n>>16), byte(n>>8), byte(n)) - } -} - -func decodeFloat(b []byte) float64 { - var u uint64 - for i, v := range b { - u |= uint64(v) << uint((i+8-len(b))*8) - } - return math.Float64frombits(u) -} - -// DecodeScalars decodes a []byte produced by EncodeScalars. -func DecodeScalars(b []byte) (scalars []interface{}, err error) { - b0 := b - for len(b) != 0 { - switch tag := b[0]; tag { - //default: - //return nil, fmt.Errorf("tag %d(%#x) not supported", b[0], b[0]) - case gbNull: - scalars = append(scalars, nil) - b = b[1:] - case gbFalse: - scalars = append(scalars, false) - b = b[1:] - case gbTrue: - scalars = append(scalars, true) - b = b[1:] - case gbFloat0: - scalars = append(scalars, 0.0) - b = b[1:] - case gbFloat1, gbFloat2, gbFloat3, gbFloat4, gbFloat5, gbFloat6, gbFloat7, gbFloat8: - n := 1 + int(tag) - gbFloat0 - if len(b) < n-1 { - goto corrupted - } - - scalars = append(scalars, decodeFloat(b[1:n])) - b = b[n:] - case gbComplex0, gbComplex1, gbComplex2, gbComplex3, gbComplex4, gbComplex5, gbComplex6, gbComplex7, gbComplex8: - n := 1 + int(tag) - gbComplex0 - if len(b) < n-1 { - goto corrupted - } - - re := decodeFloat(b[1:n]) - b = b[n:] - - if len(b) == 0 { - goto corrupted - } - - tag = b[0] - if tag < gbComplex0 || tag > gbComplex8 { - goto corrupted - } - - n = 1 + int(tag) - gbComplex0 - if len(b) < n-1 { - goto corrupted - } - - scalars = append(scalars, complex(re, decodeFloat(b[1:n]))) - b = b[n:] - case gbBytes00, gbBytes01, gbBytes02, gbBytes03, gbBytes04, - gbBytes05, gbBytes06, gbBytes07, gbBytes08, gbBytes09, - gbBytes10, gbBytes11, gbBytes12, gbBytes13, gbBytes14, - gbBytes15, gbBytes16, gbBytes17: - n := int(tag - gbBytes00) - if len(b) < n+1 { - goto corrupted - } - - scalars = append(scalars, append([]byte(nil), b[1:n+1]...)) - b = b[n+1:] - case gbBytes1: - if len(b) < 2 { - goto corrupted - } - - n := int(b[1]) - b = b[2:] - if len(b) < n { - goto corrupted - } - - scalars = append(scalars, append([]byte(nil), b[:n]...)) - b = b[n:] - case gbBytes2: - if len(b) < 3 { - goto corrupted - } - - n := int(b[1])<<8 | int(b[2]) + 1 - b = b[3:] - if len(b) < n { - goto corrupted - } - - scalars = append(scalars, append([]byte(nil), b[:n]...)) - b = b[n:] - case gbString00, gbString01, gbString02, gbString03, gbString04, - gbString05, gbString06, gbString07, gbString08, gbString09, - gbString10, gbString11, gbString12, gbString13, gbString14, - gbString15, gbString16, gbString17: - n := int(tag - gbString00) - if len(b) < n+1 { - goto corrupted - } - - scalars = append(scalars, string(b[1:n+1])) - b = b[n+1:] - case gbString1: - if len(b) < 2 { - goto corrupted - } - - n := int(b[1]) - b = b[2:] - if len(b) < n { - goto corrupted - } - - scalars = append(scalars, string(b[:n])) - b = b[n:] - case gbString2: - if len(b) < 3 { - goto corrupted - } - - n := int(b[1])<<8 | int(b[2]) - b = b[3:] - if len(b) < n { - goto corrupted - } - - scalars = append(scalars, string(b[:n])) - b = b[n:] - case gbUintP1, gbUintP2, gbUintP3, gbUintP4, gbUintP5, gbUintP6, gbUintP7, gbUintP8: - b = b[1:] - n := 1 + int(tag) - gbUintP1 - if len(b) < n { - goto corrupted - } - - var u uint64 - for _, v := range b[:n] { - u = u<<8 | uint64(v) - } - scalars = append(scalars, u) - b = b[n:] - case gbIntM8, gbIntM7, gbIntM6, gbIntM5, gbIntM4, gbIntM3, gbIntM2, gbIntM1: - b = b[1:] - n := 8 - (int(tag) - gbIntM8) - if len(b) < n { - goto corrupted - } - u := uint64(math.MaxUint64) - for _, v := range b[:n] { - u = u<<8 | uint64(v) - } - scalars = append(scalars, int64(u)) - b = b[n:] - case gbIntP1, gbIntP2, gbIntP3, gbIntP4, gbIntP5, gbIntP6, gbIntP7, gbIntP8: - b = b[1:] - n := 1 + int(tag) - gbIntP1 - if len(b) < n { - goto corrupted - } - - i := int64(0) - for _, v := range b[:n] { - i = i<<8 | int64(v) - } - scalars = append(scalars, i) - b = b[n:] - default: - scalars = append(scalars, int64(b[0])-gbInt0) - b = b[1:] - } - } - return append([]interface{}(nil), scalars...), nil - -corrupted: - return nil, &ErrDecodeScalars{append([]byte(nil), b0...), len(b0) - len(b)} -} - -func collateComplex(x, y complex128) int { - switch rx, ry := real(x), real(y); { - case rx < ry: - return -1 - case rx == ry: - switch ix, iy := imag(x), imag(y); { - case ix < iy: - return -1 - case ix == iy: - return 0 - case ix > iy: - return 1 - } - } - //case rx > ry: - return 1 -} - -func collateFloat(x, y float64) int { - switch { - case x < y: - return -1 - case x == y: - return 0 - } - //case x > y: - return 1 -} - -func collateInt(x, y int64) int { - switch { - case x < y: - return -1 - case x == y: - return 0 - } - //case x > y: - return 1 -} - -func collateUint(x, y uint64) int { - switch { - case x < y: - return -1 - case x == y: - return 0 - } - //case x > y: - return 1 -} - -func collateIntUint(x int64, y uint64) int { - if y > math.MaxInt64 { - return -1 - } - - return collateInt(x, int64(y)) -} - -func collateUintInt(x uint64, y int64) int { - return -collateIntUint(y, x) -} - -func collateType(i interface{}) (r interface{}, err error) { - switch x := i.(type) { - default: - return nil, fmt.Errorf("invalid collate type %T", x) - case nil: - return i, nil - case bool: - return i, nil - case int8: - return int64(x), nil - case int16: - return int64(x), nil - case int32: - return int64(x), nil - case int64: - return i, nil - case int: - return int64(x), nil - case uint8: - return uint64(x), nil - case uint16: - return uint64(x), nil - case uint32: - return uint64(x), nil - case uint64: - return i, nil - case uint: - return uint64(x), nil - case float32: - return float64(x), nil - case float64: - return i, nil - case complex64: - return complex128(x), nil - case complex128: - return i, nil - case []byte: - return i, nil - case string: - return i, nil - } -} - -// Collate collates two arrays of Go predeclared scalar types (and the typeless -// nil or []byte). If any other type appears in x or y, Collate will return a -// non nil error. String items are collated using strCollate or lexically -// byte-wise (as when using Go comparison operators) when strCollate is nil. -// []byte items are collated using bytes.Compare. -// -// Collate returns: -// -// -1 if x < y -// 0 if x == y -// +1 if x > y -// -// The same value as defined above must be returned from strCollate. -// -// The "outer" ordering is: nil, bool, number, []byte, string. IOW, nil is -// "smaller" than anything else except other nil, numbers collate before -// []byte, []byte collate before strings, etc. -// -// Integers and real numbers collate as expected in math. However, complex -// numbers are not ordered in Go. Here the ordering is defined: Complex numbers -// are in comparison considered first only by their real part. Iff the result -// is equality then the imaginary part is used to determine the ordering. In -// this "second order" comparing, integers and real numbers are considered as -// complex numbers with a zero imaginary part. -func Collate(x, y []interface{}, strCollate func(string, string) int) (r int, err error) { - nx, ny := len(x), len(y) - - switch { - case nx == 0 && ny != 0: - return -1, nil - case nx == 0 && ny == 0: - return 0, nil - case nx != 0 && ny == 0: - return 1, nil - } - - r = 1 - if nx > ny { - x, y, r = y, x, -r - } - - var c int - for i, xi0 := range x { - yi0 := y[i] - xi, err := collateType(xi0) - if err != nil { - return 0, err - } - - yi, err := collateType(yi0) - if err != nil { - return 0, err - } - - switch x := xi.(type) { - default: - panic(fmt.Errorf("internal error: %T", x)) - - case nil: - switch yi.(type) { - case nil: - // nop - default: - return -r, nil - } - - case bool: - switch y := yi.(type) { - case nil: - return r, nil - case bool: - switch { - case !x && y: - return -r, nil - case x == y: - // nop - case x && !y: - return r, nil - } - default: - return -r, nil - } - - case int64: - switch y := yi.(type) { - case nil, bool: - return r, nil - case int64: - c = collateInt(x, y) - case uint64: - c = collateIntUint(x, y) - case float64: - c = collateFloat(float64(x), y) - case complex128: - c = collateComplex(complex(float64(x), 0), y) - case []byte: - return -r, nil - case string: - return -r, nil - } - - if c != 0 { - return c * r, nil - } - - case uint64: - switch y := yi.(type) { - case nil, bool: - return r, nil - case int64: - c = collateUintInt(x, y) - case uint64: - c = collateUint(x, y) - case float64: - c = collateFloat(float64(x), y) - case complex128: - c = collateComplex(complex(float64(x), 0), y) - case []byte: - return -r, nil - case string: - return -r, nil - } - - if c != 0 { - return c * r, nil - } - - case float64: - switch y := yi.(type) { - case nil, bool: - return r, nil - case int64: - c = collateFloat(x, float64(y)) - case uint64: - c = collateFloat(x, float64(y)) - case float64: - c = collateFloat(x, y) - case complex128: - c = collateComplex(complex(x, 0), y) - case []byte: - return -r, nil - case string: - return -r, nil - } - - if c != 0 { - return c * r, nil - } - - case complex128: - switch y := yi.(type) { - case nil, bool: - return r, nil - case int64: - c = collateComplex(x, complex(float64(y), 0)) - case uint64: - c = collateComplex(x, complex(float64(y), 0)) - case float64: - c = collateComplex(x, complex(y, 0)) - case complex128: - c = collateComplex(x, y) - case []byte: - return -r, nil - case string: - return -r, nil - } - - if c != 0 { - return c * r, nil - } - - case []byte: - switch y := yi.(type) { - case nil, bool, int64, uint64, float64, complex128: - return r, nil - case []byte: - c = bytes.Compare(x, y) - case string: - return -r, nil - } - - if c != 0 { - return c * r, nil - } - - case string: - switch y := yi.(type) { - case nil, bool, int64, uint64, float64, complex128: - return r, nil - case []byte: - return r, nil - case string: - switch { - case strCollate != nil: - c = strCollate(x, y) - case x < y: - return -r, nil - case x == y: - c = 0 - case x > y: - return r, nil - } - } - - if c != 0 { - return c * r, nil - } - } - } - - if nx == ny { - return 0, nil - } - - return -r, nil -} diff --git a/Godeps/_workspace/src/github.com/cznic/exp/lldb/lldb.go b/Godeps/_workspace/src/github.com/cznic/exp/lldb/lldb.go deleted file mode 100644 index 8f77ec8add..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/exp/lldb/lldb.go +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright 2014 The lldb 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 lldb (WIP) implements a low level database engine. The database -// model used could be considered a specific implementation of some small(est) -// intersection of models listed in [1]. As a settled term is lacking, it'll be -// called here a 'Virtual memory model' (VMM). -// -// Experimental release notes -// -// This is an experimental release. Don't open a DB from two applications or -// two instances of an application - it will get corrupted (no file locking is -// implemented and this task is delegated to lldb's clients). -// -// WARNING: THE LLDB API IS SUBJECT TO CHANGE. -// -// Filers -// -// A Filer is an abstraction of storage. A Filer may be a part of some process' -// virtual address space, an OS file, a networked, remote file etc. Persistence -// of the storage is optional, opaque to VMM and it is specific to a concrete -// Filer implementation. -// -// Space management -// -// Mechanism to allocate, reallocate (resize), deallocate (and later reclaim -// the unused) contiguous parts of a Filer, called blocks. Blocks are -// identified and referred to by a handle, an int64. -// -// BTrees -// -// In addition to the VMM like services, lldb provides volatile and -// non-volatile BTrees. Keys and values of a BTree are limited in size to 64kB -// each (a bit more actually). Support for larger keys/values, if desired, can -// be built atop a BTree to certain limits. -// -// Handles vs pointers -// -// A handle is the abstracted storage counterpart of a memory address. There -// is one fundamental difference, though. Resizing a block never results in a -// change to the handle which refers to the resized block, so a handle is more -// akin to an unique numeric id/key. Yet it shares one property of pointers - -// handles can be associated again with blocks after the original handle block -// was deallocated. In other words, a handle uniqueness domain is the state of -// the database and is not something comparable to e.g. an ever growing -// numbering sequence. -// -// Also, as with memory pointers, dangling handles can be created and blocks -// overwritten when such handles are used. Using a zero handle to refer to a -// block will not panic; however, the resulting error is effectively the same -// exceptional situation as dereferencing a nil pointer. -// -// Blocks -// -// Allocated/used blocks, are limited in size to only a little bit more than -// 64kB. Bigger semantic entities/structures must be built in lldb's client -// code. The content of a block has no semantics attached, it's only a fully -// opaque `[]byte`. -// -// Scalars -// -// Use of "scalars" applies to EncodeScalars, DecodeScalars and Collate. Those -// first two "to bytes" and "from bytes" functions are suggested for handling -// multi-valued Allocator content items and/or keys/values of BTrees (using -// Collate for keys). Types called "scalar" are: -// -// nil (the typeless one) -// bool -// all integral types: [u]int8, [u]int16, [u]int32, [u]int, [u]int64 -// all floating point types: float32, float64 -// all complex types: complex64, complex128 -// []byte (64kB max) -// string (64kb max) -// -// Specific implementations -// -// Included are concrete implementations of some of the VMM interfaces included -// to ease serving simple client code or for testing and possibly as an -// example. More details in the documentation of such implementations. -// -// [1]: http://en.wikipedia.org/wiki/Database_model -package lldb - -const ( - fltSz = 0x70 // size of the FLT - maxShort = 251 - maxRq = 65787 - maxFLTRq = 4112 - maxHandle = 1<<56 - 1 - atomLen = 16 - tagUsedLong = 0xfc - tagUsedRelocated = 0xfd - tagFreeShort = 0xfe - tagFreeLong = 0xff - tagNotCompressed = 0 - tagCompressed = 1 -) - -// Content size n -> blocksize in atoms. -func n2atoms(n int) int { - if n > maxShort { - n += 2 - } - return (n+1)/16 + 1 -} - -// Content size n -> number of padding zeros. -func n2padding(n int) int { - if n > maxShort { - n += 2 - } - return 15 - (n+1)&15 -} - -// Handle <-> offset -func h2off(h int64) int64 { return (h + 6) * 16 } -func off2h(off int64) int64 { return off/16 - 6 } - -// Get a 7B int64 from b -func b2h(b []byte) (h int64) { - for _, v := range b[:7] { - h = h<<8 | int64(v) - } - return -} - -// Put a 7B int64 into b -func h2b(b []byte, h int64) []byte { - for i := range b[:7] { - b[i], h = byte(h>>48), h<<8 - } - return b -} - -// Content length N (must be in [252, 65787]) to long used block M field. -func n2m(n int) (m int) { - return n % 0x10000 -} - -// Long used block M (must be in [0, 65535]) field to content length N. -func m2n(m int) (n int) { - if m <= maxShort { - m += 0x10000 - } - return m -} - -func bpack(a []byte) []byte { - if cap(a) > len(a) { - return append([]byte(nil), a...) - } - - return a -} diff --git a/Godeps/_workspace/src/github.com/cznic/exp/lldb/memfiler.go b/Godeps/_workspace/src/github.com/cznic/exp/lldb/memfiler.go deleted file mode 100644 index 417e92f3aa..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/exp/lldb/memfiler.go +++ /dev/null @@ -1,344 +0,0 @@ -// Copyright 2014 The lldb Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// A memory-only implementation of Filer. - -/* - -pgBits: 8 -BenchmarkMemFilerWrSeq 100000 19430 ns/op 1646.93 MB/s -BenchmarkMemFilerRdSeq 100000 17390 ns/op 1840.13 MB/s -BenchmarkMemFilerWrRand 1000000 1903 ns/op 133.94 MB/s -BenchmarkMemFilerRdRand 1000000 1153 ns/op 221.16 MB/s - -pgBits: 9 -BenchmarkMemFilerWrSeq 100000 16195 ns/op 1975.80 MB/s -BenchmarkMemFilerRdSeq 200000 13011 ns/op 2459.39 MB/s -BenchmarkMemFilerWrRand 1000000 2248 ns/op 227.28 MB/s -BenchmarkMemFilerRdRand 1000000 1177 ns/op 433.94 MB/s - -pgBits: 10 -BenchmarkMemFilerWrSeq 100000 16169 ns/op 1979.04 MB/s -BenchmarkMemFilerRdSeq 200000 12673 ns/op 2524.91 MB/s -BenchmarkMemFilerWrRand 1000000 5550 ns/op 184.30 MB/s -BenchmarkMemFilerRdRand 1000000 1699 ns/op 601.79 MB/s - -pgBits: 11 -BenchmarkMemFilerWrSeq 100000 13449 ns/op 2379.31 MB/s -BenchmarkMemFilerRdSeq 200000 12058 ns/op 2653.80 MB/s -BenchmarkMemFilerWrRand 500000 4335 ns/op 471.47 MB/s -BenchmarkMemFilerRdRand 1000000 2843 ns/op 719.47 MB/s - -pgBits: 12 -BenchmarkMemFilerWrSeq 200000 11976 ns/op 2672.00 MB/s -BenchmarkMemFilerRdSeq 200000 12255 ns/op 2611.06 MB/s -BenchmarkMemFilerWrRand 200000 8058 ns/op 507.14 MB/s -BenchmarkMemFilerRdRand 500000 4365 ns/op 936.15 MB/s - -pgBits: 13 -BenchmarkMemFilerWrSeq 200000 10852 ns/op 2948.69 MB/s -BenchmarkMemFilerRdSeq 200000 11561 ns/op 2767.77 MB/s -BenchmarkMemFilerWrRand 200000 9748 ns/op 840.15 MB/s -BenchmarkMemFilerRdRand 500000 7236 ns/op 1131.59 MB/s - -pgBits: 14 -BenchmarkMemFilerWrSeq 200000 10328 ns/op 3098.12 MB/s -BenchmarkMemFilerRdSeq 200000 11292 ns/op 2833.66 MB/s -BenchmarkMemFilerWrRand 100000 16768 ns/op 978.75 MB/s -BenchmarkMemFilerRdRand 200000 13033 ns/op 1258.43 MB/s - -pgBits: 15 -BenchmarkMemFilerWrSeq 200000 10309 ns/op 3103.93 MB/s -BenchmarkMemFilerRdSeq 200000 11126 ns/op 2876.12 MB/s -BenchmarkMemFilerWrRand 50000 31985 ns/op 1021.74 MB/s -BenchmarkMemFilerRdRand 100000 25217 ns/op 1297.65 MB/s - -pgBits: 16 -BenchmarkMemFilerWrSeq 200000 10324 ns/op 3099.45 MB/s -BenchmarkMemFilerRdSeq 200000 11201 ns/op 2856.80 MB/s -BenchmarkMemFilerWrRand 20000 55226 ns/op 1184.76 MB/s -BenchmarkMemFilerRdRand 50000 48316 ns/op 1355.16 MB/s - -pgBits: 17 -BenchmarkMemFilerWrSeq 200000 10377 ns/op 3083.53 MB/s -BenchmarkMemFilerRdSeq 200000 11018 ns/op 2904.18 MB/s -BenchmarkMemFilerWrRand 10000 143425 ns/op 913.12 MB/s -BenchmarkMemFilerRdRand 20000 95267 ns/op 1376.99 MB/s - -pgBits: 18 -BenchmarkMemFilerWrSeq 200000 10312 ns/op 3102.96 MB/s -BenchmarkMemFilerRdSeq 200000 11069 ns/op 2890.84 MB/s -BenchmarkMemFilerWrRand 5000 280910 ns/op 934.14 MB/s -BenchmarkMemFilerRdRand 10000 188500 ns/op 1388.17 MB/s - -*/ - -package lldb - -import ( - "bytes" - "fmt" - "io" - - "github.com/cznic/fileutil" - "github.com/cznic/mathutil" -) - -const ( - pgBits = 16 - pgSize = 1 << pgBits - pgMask = pgSize - 1 -) - -var _ Filer = &MemFiler{} // Ensure MemFiler is a Filer. - -type memFilerMap map[int64]*[pgSize]byte - -// MemFiler is a memory backed Filer. It implements BeginUpdate, EndUpdate and -// Rollback as no-ops. MemFiler is not automatically persistent, but it has -// ReadFrom and WriteTo methods. -type MemFiler struct { - m memFilerMap - nest int - size int64 -} - -// NewMemFiler returns a new MemFiler. -func NewMemFiler() *MemFiler { - return &MemFiler{m: memFilerMap{}} -} - -// BeginUpdate implements Filer. -func (f *MemFiler) BeginUpdate() error { - f.nest++ - return nil -} - -// Close implements Filer. -func (f *MemFiler) Close() (err error) { - if f.nest != 0 { - return &ErrPERM{(f.Name() + ":Close")} - } - - return -} - -// EndUpdate implements Filer. -func (f *MemFiler) EndUpdate() (err error) { - if f.nest == 0 { - return &ErrPERM{(f.Name() + ": EndUpdate")} - } - - f.nest-- - return -} - -// Name implements Filer. -func (f *MemFiler) Name() string { - return fmt.Sprintf("%p.memfiler", f) -} - -// PunchHole implements Filer. -func (f *MemFiler) PunchHole(off, size int64) (err error) { - if off < 0 { - return &ErrINVAL{f.Name() + ": PunchHole off", off} - } - - if size < 0 || off+size > f.size { - return &ErrINVAL{f.Name() + ": PunchHole size", size} - } - - first := off >> pgBits - if off&pgMask != 0 { - first++ - } - off += size - 1 - last := off >> pgBits - if off&pgMask != 0 { - last-- - } - if limit := f.size >> pgBits; last > limit { - last = limit - } - for pg := first; pg <= last; pg++ { - delete(f.m, pg) - } - return -} - -var zeroPage [pgSize]byte - -// ReadAt implements Filer. -func (f *MemFiler) ReadAt(b []byte, off int64) (n int, err error) { - avail := f.size - off - pgI := off >> pgBits - pgO := int(off & pgMask) - rem := len(b) - if int64(rem) >= avail { - rem = int(avail) - err = io.EOF - } - for rem != 0 && avail > 0 { - pg := f.m[pgI] - if pg == nil { - pg = &zeroPage - } - nc := copy(b[:mathutil.Min(rem, pgSize)], pg[pgO:]) - pgI++ - pgO = 0 - rem -= nc - n += nc - b = b[nc:] - } - return -} - -// ReadFrom is a helper to populate MemFiler's content from r. 'n' reports the -// number of bytes read from 'r'. -func (f *MemFiler) ReadFrom(r io.Reader) (n int64, err error) { - if err = f.Truncate(0); err != nil { - return - } - - var ( - b [pgSize]byte - rn int - off int64 - ) - - var rerr error - for rerr == nil { - if rn, rerr = r.Read(b[:]); rn != 0 { - f.WriteAt(b[:rn], off) - off += int64(rn) - n += int64(rn) - } - } - if !fileutil.IsEOF(rerr) { - err = rerr - } - return -} - -// Rollback implements Filer. -func (f *MemFiler) Rollback() (err error) { return } - -// Size implements Filer. -func (f *MemFiler) Size() (int64, error) { - return f.size, nil -} - -// Sync implements Filer. -func (f *MemFiler) Sync() error { - return nil -} - -// Truncate implements Filer. -func (f *MemFiler) Truncate(size int64) (err error) { - switch { - case size < 0: - return &ErrINVAL{"Truncate size", size} - case size == 0: - f.m = memFilerMap{} - f.size = 0 - return - } - - first := size >> pgBits - if size&pgMask != 0 { - first++ - } - last := f.size >> pgBits - if f.size&pgMask != 0 { - last++ - } - for ; first < last; first++ { - delete(f.m, first) - } - - f.size = size - return -} - -// WriteAt implements Filer. -func (f *MemFiler) WriteAt(b []byte, off int64) (n int, err error) { - pgI := off >> pgBits - pgO := int(off & pgMask) - n = len(b) - rem := n - var nc int - for rem != 0 { - if pgO == 0 && rem >= pgSize && bytes.Equal(b[:pgSize], zeroPage[:]) { - delete(f.m, pgI) - nc = pgSize - } else { - pg := f.m[pgI] - if pg == nil { - pg = new([pgSize]byte) - f.m[pgI] = pg - } - nc = copy((*pg)[pgO:], b) - } - pgI++ - pgO = 0 - rem -= nc - b = b[nc:] - } - f.size = mathutil.MaxInt64(f.size, off+int64(n)) - return -} - -// WriteTo is a helper to copy/persist MemFiler's content to w. If w is also -// an io.WriterAt then WriteTo may attempt to _not_ write any big, for some -// value of big, runs of zeros, i.e. it will attempt to punch holes, where -// possible, in `w` if that happens to be a freshly created or to zero length -// truncated OS file. 'n' reports the number of bytes written to 'w'. -func (f *MemFiler) WriteTo(w io.Writer) (n int64, err error) { - var ( - b [pgSize]byte - wn, rn int - off int64 - rerr error - ) - - if wa, ok := w.(io.WriterAt); ok { - lastPgI := f.size >> pgBits - for pgI := int64(0); pgI <= lastPgI; pgI++ { - sz := pgSize - if pgI == lastPgI { - sz = int(f.size & pgMask) - } - pg := f.m[pgI] - if pg != nil { - wn, err = wa.WriteAt(pg[:sz], off) - if err != nil { - return - } - - n += int64(wn) - off += int64(sz) - if wn != sz { - return n, io.ErrShortWrite - } - } - } - return - } - - var werr error - for rerr == nil { - if rn, rerr = f.ReadAt(b[:], off); rn != 0 { - off += int64(rn) - if wn, werr = w.Write(b[:rn]); werr != nil { - return n, werr - } - - n += int64(wn) - } - } - if !fileutil.IsEOF(rerr) { - err = rerr - } - return -} diff --git a/Godeps/_workspace/src/github.com/cznic/exp/lldb/osfiler.go b/Godeps/_workspace/src/github.com/cznic/exp/lldb/osfiler.go deleted file mode 100644 index d6e189a18f..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/exp/lldb/osfiler.go +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright 2014 The lldb 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 lldb - -import ( - "io" - "os" - - "github.com/cznic/mathutil" -) - -var _ Filer = (*OSFiler)(nil) - -// OSFile is an os.File like minimal set of methods allowing to construct a -// Filer. -type OSFile interface { - Name() string - Stat() (fi os.FileInfo, err error) - Sync() (err error) - Truncate(size int64) (err error) - io.Closer - io.Reader - io.ReaderAt - io.Seeker - io.Writer - io.WriterAt -} - -// OSFiler is like a SimpleFileFiler but based on an OSFile. -type OSFiler struct { - f OSFile - nest int - size int64 // not set if < 0 -} - -// NewOSFiler returns a Filer from an OSFile. This Filer is like the -// SimpleFileFiler, it does not implement the transaction related methods. -func NewOSFiler(f OSFile) (r *OSFiler) { - return &OSFiler{ - f: f, - size: -1, - } -} - -// BeginUpdate implements Filer. -func (f *OSFiler) BeginUpdate() (err error) { - f.nest++ - return nil -} - -// Close implements Filer. -func (f *OSFiler) Close() (err error) { - if f.nest != 0 { - return &ErrPERM{(f.Name() + ":Close")} - } - - return f.f.Close() -} - -// EndUpdate implements Filer. -func (f *OSFiler) EndUpdate() (err error) { - if f.nest == 0 { - return &ErrPERM{(f.Name() + ":EndUpdate")} - } - - f.nest-- - return -} - -// Name implements Filer. -func (f *OSFiler) Name() string { - return f.f.Name() -} - -// PunchHole implements Filer. -func (f *OSFiler) PunchHole(off, size int64) (err error) { - return -} - -// ReadAt implements Filer. -func (f *OSFiler) ReadAt(b []byte, off int64) (n int, err error) { - return f.f.ReadAt(b, off) -} - -// Rollback implements Filer. -func (f *OSFiler) Rollback() (err error) { return } - -// Size implements Filer. -func (f *OSFiler) Size() (n int64, err error) { - if f.size < 0 { // boot - fi, err := f.f.Stat() - if err != nil { - return 0, err - } - - f.size = fi.Size() - } - return f.size, nil -} - -// Sync implements Filer. -func (f *OSFiler) Sync() (err error) { - return f.f.Sync() -} - -// Truncate implements Filer. -func (f *OSFiler) Truncate(size int64) (err error) { - if size < 0 { - return &ErrINVAL{"Truncate size", size} - } - - f.size = size - return f.f.Truncate(size) -} - -// WriteAt implements Filer. -func (f *OSFiler) WriteAt(b []byte, off int64) (n int, err error) { - if f.size < 0 { // boot - fi, err := os.Stat(f.f.Name()) - if err != nil { - return 0, err - } - - f.size = fi.Size() - } - f.size = mathutil.MaxInt64(f.size, int64(len(b))+off) - return f.f.WriteAt(b, off) -} diff --git a/Godeps/_workspace/src/github.com/cznic/exp/lldb/simplefilefiler.go b/Godeps/_workspace/src/github.com/cznic/exp/lldb/simplefilefiler.go deleted file mode 100644 index de32e64916..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/exp/lldb/simplefilefiler.go +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright 2014 The lldb Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// A basic os.File backed Filer. - -package lldb - -import ( - "os" - - "github.com/cznic/fileutil" - "github.com/cznic/mathutil" -) - -var _ Filer = &SimpleFileFiler{} // Ensure SimpleFileFiler is a Filer. - -// SimpleFileFiler is an os.File backed Filer intended for use where structural -// consistency can be reached by other means (SimpleFileFiler is for example -// wrapped in eg. an RollbackFiler or ACIDFiler0) or where persistence is not -// required (temporary/working data sets). -// -// SimpleFileFiler is the most simple os.File backed Filer implementation as it -// does not really implement BeginUpdate and EndUpdate/Rollback in any way -// which would protect the structural integrity of data. If misused e.g. as a -// real database storage w/o other measures, it can easily cause data loss -// when, for example, a power outage occurs or the updating process terminates -// abruptly. -type SimpleFileFiler struct { - file *os.File - nest int - size int64 // not set if < 0 -} - -// NewSimpleFileFiler returns a new SimpleFileFiler. -func NewSimpleFileFiler(f *os.File) *SimpleFileFiler { - return &SimpleFileFiler{file: f, size: -1} -} - -// BeginUpdate implements Filer. -func (f *SimpleFileFiler) BeginUpdate() error { - f.nest++ - return nil -} - -// Close implements Filer. -func (f *SimpleFileFiler) Close() (err error) { - if f.nest != 0 { - return &ErrPERM{(f.Name() + ":Close")} - } - - return f.file.Close() -} - -// EndUpdate implements Filer. -func (f *SimpleFileFiler) EndUpdate() (err error) { - if f.nest == 0 { - return &ErrPERM{(f.Name() + ":EndUpdate")} - } - - f.nest-- - return -} - -// Name implements Filer. -func (f *SimpleFileFiler) Name() string { - return f.file.Name() -} - -// PunchHole implements Filer. -func (f *SimpleFileFiler) PunchHole(off, size int64) (err error) { - return fileutil.PunchHole(f.file, off, size) -} - -// ReadAt implements Filer. -func (f *SimpleFileFiler) ReadAt(b []byte, off int64) (n int, err error) { - return f.file.ReadAt(b, off) -} - -// Rollback implements Filer. -func (f *SimpleFileFiler) Rollback() (err error) { return } - -// Size implements Filer. -func (f *SimpleFileFiler) Size() (int64, error) { - if f.size < 0 { // boot - fi, err := os.Stat(f.file.Name()) - if err != nil { - return 0, err - } - - f.size = fi.Size() - } - return f.size, nil -} - -// Sync implements Filer. -func (f *SimpleFileFiler) Sync() error { - return f.file.Sync() -} - -// Truncate implements Filer. -func (f *SimpleFileFiler) Truncate(size int64) (err error) { - if size < 0 { - return &ErrINVAL{"Truncate size", size} - } - - f.size = size - return f.file.Truncate(size) -} - -// WriteAt implements Filer. -func (f *SimpleFileFiler) WriteAt(b []byte, off int64) (n int, err error) { - if f.size < 0 { // boot - fi, err := os.Stat(f.file.Name()) - if err != nil { - return 0, err - } - - f.size = fi.Size() - } - f.size = mathutil.MaxInt64(f.size, int64(len(b))+off) - return f.file.WriteAt(b, off) -} diff --git a/Godeps/_workspace/src/github.com/cznic/exp/lldb/xact.go b/Godeps/_workspace/src/github.com/cznic/exp/lldb/xact.go deleted file mode 100644 index f9ad1cbfb7..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/exp/lldb/xact.go +++ /dev/null @@ -1,629 +0,0 @@ -// Copyright 2014 The lldb Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Structural transactions. - -package lldb - -//DONE+ TransactionalMemoryFiler -// ---- -// Use NewRollbackFiler(myMemFiler, ...) - -/* - -bfBits: 3 -BenchmarkRollbackFiler 20000000 102 ns/op 9.73 MB/s - -bfBits: 4 -BenchmarkRollbackFiler 50000000 55.7 ns/op 17.95 MB/s - -bfBits: 5 -BenchmarkRollbackFiler 100000000 32.2 ns/op 31.06 MB/s - -bfBits: 6 -BenchmarkRollbackFiler 100000000 20.6 ns/op 48.46 MB/s - -bfBits: 7 -BenchmarkRollbackFiler 100000000 15.1 ns/op 66.12 MB/s - -bfBits: 8 -BenchmarkRollbackFiler 100000000 10.5 ns/op 95.66 MB/s - -bfBits: 9 -BenchmarkRollbackFiler 200000000 8.02 ns/op 124.74 MB/s - -bfBits: 10 -BenchmarkRollbackFiler 200000000 9.25 ns/op 108.09 MB/s - -bfBits: 11 -BenchmarkRollbackFiler 100000000 11.7 ns/op 85.47 MB/s - -bfBits: 12 -BenchmarkRollbackFiler 100000000 17.2 ns/op 57.99 MB/s - -bfBits: 13 -BenchmarkRollbackFiler 100000000 32.7 ns/op 30.58 MB/s - -bfBits: 14 -BenchmarkRollbackFiler 50000000 39.6 ns/op 25.27 MB/s - -*/ - -import ( - "fmt" - "io" - "sync" - - "github.com/cznic/fileutil" - "github.com/cznic/mathutil" -) - -var ( - _ Filer = &bitFiler{} // Ensure bitFiler is a Filer. - _ Filer = &RollbackFiler{} // ditto -) - -const ( - bfBits = 9 - bfSize = 1 << bfBits - bfMask = bfSize - 1 -) - -var ( - bitmask = [8]byte{1, 2, 4, 8, 16, 32, 64, 128} - bitZeroPage bitPage - allDirtyFlags [bfSize >> 3]byte -) - -func init() { - for i := range allDirtyFlags { - allDirtyFlags[i] = 0xff - } -} - -type ( - bitPage struct { - prev, next *bitPage - data [bfSize]byte - flags [bfSize >> 3]byte - dirty bool - } - - bitFilerMap map[int64]*bitPage - - bitFiler struct { - parent Filer - m bitFilerMap - size int64 - } -) - -func newBitFiler(parent Filer) (f *bitFiler, err error) { - sz, err := parent.Size() - if err != nil { - return - } - - return &bitFiler{parent: parent, m: bitFilerMap{}, size: sz}, nil -} - -func (f *bitFiler) BeginUpdate() error { panic("internal error") } -func (f *bitFiler) EndUpdate() error { panic("internal error") } -func (f *bitFiler) Rollback() error { panic("internal error") } -func (f *bitFiler) Sync() error { panic("internal error") } - -func (f *bitFiler) Close() (err error) { return } -func (f *bitFiler) Name() string { return fmt.Sprintf("%p.bitfiler", f) } -func (f *bitFiler) Size() (int64, error) { return f.size, nil } - -func (f *bitFiler) PunchHole(off, size int64) (err error) { - first := off >> bfBits - if off&bfMask != 0 { - first++ - } - off += size - 1 - last := off >> bfBits - if off&bfMask != 0 { - last-- - } - if limit := f.size >> bfBits; last > limit { - last = limit - } - for pgI := first; pgI <= last; pgI++ { - pg := &bitPage{} - pg.flags = allDirtyFlags - f.m[pgI] = pg - } - return -} - -func (f *bitFiler) ReadAt(b []byte, off int64) (n int, err error) { - avail := f.size - off - pgI := off >> bfBits - pgO := int(off & bfMask) - rem := len(b) - if int64(rem) >= avail { - rem = int(avail) - err = io.EOF - } - for rem != 0 && avail > 0 { - pg := f.m[pgI] - if pg == nil { - pg = &bitPage{} - if f.parent != nil { - _, err = f.parent.ReadAt(pg.data[:], off&^bfMask) - if err != nil && !fileutil.IsEOF(err) { - return - } - - err = nil - } - f.m[pgI] = pg - } - nc := copy(b[:mathutil.Min(rem, bfSize)], pg.data[pgO:]) - pgI++ - pgO = 0 - rem -= nc - n += nc - b = b[nc:] - off += int64(nc) - } - return -} - -func (f *bitFiler) Truncate(size int64) (err error) { - switch { - case size < 0: - return &ErrINVAL{"Truncate size", size} - case size == 0: - f.m = bitFilerMap{} - f.size = 0 - return - } - - first := size >> bfBits - if size&bfMask != 0 { - first++ - } - last := f.size >> bfBits - if f.size&bfMask != 0 { - last++ - } - for ; first < last; first++ { - delete(f.m, first) - } - - f.size = size - return -} - -func (f *bitFiler) WriteAt(b []byte, off int64) (n int, err error) { - off0 := off - pgI := off >> bfBits - pgO := int(off & bfMask) - n = len(b) - rem := n - var nc int - for rem != 0 { - pg := f.m[pgI] - if pg == nil { - pg = &bitPage{} - if f.parent != nil { - _, err = f.parent.ReadAt(pg.data[:], off&^bfMask) - if err != nil && !fileutil.IsEOF(err) { - return - } - - err = nil - } - f.m[pgI] = pg - } - nc = copy(pg.data[pgO:], b) - pgI++ - pg.dirty = true - for i := pgO; i < pgO+nc; i++ { - pg.flags[i>>3] |= bitmask[i&7] - } - pgO = 0 - rem -= nc - b = b[nc:] - off += int64(nc) - } - f.size = mathutil.MaxInt64(f.size, off0+int64(n)) - return -} - -func (f *bitFiler) link() { - for pgI, pg := range f.m { - nx, ok := f.m[pgI+1] - if !ok || !nx.dirty { - continue - } - - nx.prev, pg.next = pg, nx - } -} - -func (f *bitFiler) dumpDirty(w io.WriterAt) (nwr int, err error) { - f.link() - for pgI, pg := range f.m { - if !pg.dirty { - continue - } - - for pg.prev != nil && pg.prev.dirty { - pg = pg.prev - pgI-- - } - - for pg != nil && pg.dirty { - last := false - var off int64 - first := -1 - for i := 0; i < bfSize; i++ { - flag := pg.flags[i>>3]&bitmask[i&7] != 0 - switch { - case flag && !last: // Leading edge detected - off = pgI<= 0 { - i := bfSize - n, err := w.WriteAt(pg.data[first:i], off) - if n != i-first { - return 0, err - } - - nwr++ - } - - pg.dirty = false - pg = pg.next - pgI++ - } - } - return -} - -// RollbackFiler is a Filer implementing structural transaction handling. -// Structural transactions should be small and short lived because all non -// committed data are held in memory until committed or discarded by a -// Rollback. -// -// While using RollbackFiler, every intended update of the wrapped Filler, by -// WriteAt, Truncate or PunchHole, _must_ be made within a transaction. -// Attempts to do it outside of a transaction will return ErrPERM. OTOH, -// invoking ReadAt outside of a transaction is not a problem. -// -// No nested transactions: All updates within a transaction are held in memory. -// On a matching EndUpdate the updates held in memory are actually written to -// the wrapped Filer. -// -// Nested transactions: Correct data will be seen from RollbackFiler when any -// level of a nested transaction is rollbacked. The actual writing to the -// wrapped Filer happens only when the outer most transaction nesting level is -// closed. -// -// Invoking Rollback is an alternative to EndUpdate. It discards all changes -// made at the current transaction level and returns the "state" (possibly not -// yet persisted) of the Filer to what it was before the corresponding -// BeginUpdate. -// -// During an open transaction, all reads (using ReadAt) are "dirty" reads, -// seeing the uncommitted changes made to the Filer's data. -// -// Lldb databases should be based upon a RollbackFiler. -// -// With a wrapped MemFiler one gets transactional memory. With, for example a -// wrapped disk based SimpleFileFiler it protects against at least some HW -// errors - if Rollback is properly invoked on such failures and/or if there's -// some WAL or 2PC or whatever other safe mechanism based recovery procedure -// used by the client. -// -// The "real" writes to the wrapped Filer (or WAL instead) go through the -// writerAt supplied to NewRollbackFiler. -// -// List of functions/methods which are recommended to be wrapped in a -// BeginUpdate/EndUpdate structural transaction: -// -// Allocator.Alloc -// Allocator.Free -// Allocator.Realloc -// -// CreateBTree -// RemoveBTree -// BTree.Clear -// BTree.Delete -// BTree.DeleteAny -// BTree.Clear -// BTree.Extract -// BTree.Get (it can mutate the DB) -// BTree.Put -// BTree.Set -// -// NOTE: RollbackFiler is a generic solution intended to wrap Filers provided -// by this package which do not implement any of the transactional methods. -// RollbackFiler thus _does not_ invoke any of the transactional methods of its -// wrapped Filer. -// -// RollbackFiler is safe for concurrent use by multiple goroutines. -type RollbackFiler struct { - mu sync.RWMutex - inCallback bool - inCallbackMu sync.RWMutex - bitFiler *bitFiler - checkpoint func(int64) error - closed bool - f Filer - parent Filer - tlevel int // transaction nesting level, 0 == not in transaction - writerAt io.WriterAt - - // afterRollback, if not nil, is called after performing Rollback - // without errros. - afterRollback func() error -} - -// NewRollbackFiler returns a RollbackFiler wrapping f. -// -// The checkpoint parameter -// -// The checkpoint function is called after closing (by EndUpdate) the upper -// most level open transaction if all calls of writerAt were successful and the -// DB (or eg. a WAL) is thus now in a consistent state (virtually, in the ideal -// world with no write caches, no HW failures, no process crashes, ...). -// -// NOTE: In, for example, a 2PC it is necessary to reflect also the sz -// parameter as the new file size (as in the parameter to Truncate). All -// changes were successfully written already by writerAt before invoking -// checkpoint. -// -// The writerAt parameter -// -// The writerAt interface is used to commit the updates of the wrapped Filer. -// If any invocation of writerAt fails then a non nil error will be returned -// from EndUpdate and checkpoint will _not_ ne called. Neither is necessary to -// call Rollback. The rule of thumb: The [structural] transaction [level] is -// closed by invoking exactly once one of EndUpdate _or_ Rollback. -// -// It is presumed that writerAt uses WAL or 2PC or whatever other safe -// mechanism to physically commit the updates. -// -// Updates performed by invocations of writerAt are byte-precise, but not -// necessarily maximum possible length precise. IOW, for example an update -// crossing page boundaries may be performed by more than one writerAt -// invocation. No offset sorting is performed. This may change if it proves -// to be a problem. Such change would be considered backward compatible. -// -// NOTE: Using RollbackFiler, but failing to ever invoke a matching "closing" -// EndUpdate after an "opening" BeginUpdate means neither writerAt or -// checkpoint will ever get called - with all the possible data loss -// consequences. -func NewRollbackFiler(f Filer, checkpoint func(sz int64) error, writerAt io.WriterAt) (r *RollbackFiler, err error) { - if f == nil || checkpoint == nil || writerAt == nil { - return nil, &ErrINVAL{Src: "lldb.NewRollbackFiler, nil argument"} - } - - return &RollbackFiler{ - checkpoint: checkpoint, - f: f, - writerAt: writerAt, - }, nil -} - -// Implements Filer. -func (r *RollbackFiler) BeginUpdate() (err error) { - r.mu.Lock() - defer r.mu.Unlock() - - parent := r.f - if r.tlevel != 0 { - parent = r.bitFiler - } - r.bitFiler, err = newBitFiler(parent) - if err != nil { - return - } - - r.tlevel++ - return -} - -// Implements Filer. -// -// Close will return an error if not invoked at nesting level 0. However, to -// allow emergency closing from eg. a signal handler; if Close is invoked -// within an open transaction(s), it rollbacks any non committed open -// transactions and performs the Close operation. -// -// IOW: Regardless of the transaction nesting level the Close is always -// performed but any uncommitted transaction data are lost. -func (r *RollbackFiler) Close() (err error) { - r.mu.Lock() - defer r.mu.Unlock() - - if r.closed { - return &ErrPERM{r.f.Name() + ": Already closed"} - } - - r.closed = true - if err = r.f.Close(); err != nil { - return - } - - if r.tlevel != 0 { - err = &ErrPERM{r.f.Name() + ": Close inside an open transaction"} - } - - return -} - -// Implements Filer. -func (r *RollbackFiler) EndUpdate() (err error) { - r.mu.Lock() - defer r.mu.Unlock() - - if r.tlevel == 0 { - return &ErrPERM{r.f.Name() + " : EndUpdate outside of a transaction"} - } - - sz, err := r.size() // Cannot call .Size() -> deadlock - if err != nil { - return - } - - r.tlevel-- - bf := r.bitFiler - parent := bf.parent - w := r.writerAt - if r.tlevel != 0 { - w = parent - } - nwr, err := bf.dumpDirty(w) - if err != nil { - return - } - - switch { - case r.tlevel == 0: - r.bitFiler = nil - if nwr == 0 { - return - } - - return r.checkpoint(sz) - default: - r.bitFiler = parent.(*bitFiler) - sz, _ := bf.Size() // bitFiler.Size() never returns err != nil - return parent.Truncate(sz) - } -} - -// Implements Filer. -func (r *RollbackFiler) Name() string { - r.mu.RLock() - defer r.mu.RUnlock() - - return r.f.Name() -} - -// Implements Filer. -func (r *RollbackFiler) PunchHole(off, size int64) error { - r.mu.Lock() - defer r.mu.Unlock() - - if r.tlevel == 0 { - return &ErrPERM{r.f.Name() + ": PunchHole outside of a transaction"} - } - - if off < 0 { - return &ErrINVAL{r.f.Name() + ": PunchHole off", off} - } - - if size < 0 || off+size > r.bitFiler.size { - return &ErrINVAL{r.f.Name() + ": PunchHole size", size} - } - - return r.bitFiler.PunchHole(off, size) -} - -// Implements Filer. -func (r *RollbackFiler) ReadAt(b []byte, off int64) (n int, err error) { - r.inCallbackMu.RLock() - defer r.inCallbackMu.RUnlock() - if !r.inCallback { - r.mu.RLock() - defer r.mu.RUnlock() - } - if r.tlevel == 0 { - return r.f.ReadAt(b, off) - } - - return r.bitFiler.ReadAt(b, off) -} - -// Implements Filer. -func (r *RollbackFiler) Rollback() (err error) { - r.mu.Lock() - defer r.mu.Unlock() - - if r.tlevel == 0 { - return &ErrPERM{r.f.Name() + ": Rollback outside of a transaction"} - } - - if r.tlevel > 1 { - r.bitFiler = r.bitFiler.parent.(*bitFiler) - } - r.tlevel-- - if f := r.afterRollback; f != nil { - r.inCallbackMu.Lock() - r.inCallback = true - r.inCallbackMu.Unlock() - defer func() { - r.inCallbackMu.Lock() - r.inCallback = false - r.inCallbackMu.Unlock() - }() - return f() - } - return -} - -func (r *RollbackFiler) size() (sz int64, err error) { - if r.tlevel == 0 { - return r.f.Size() - } - - return r.bitFiler.Size() -} - -// Implements Filer. -func (r *RollbackFiler) Size() (sz int64, err error) { - r.mu.Lock() - defer r.mu.Unlock() - - return r.size() -} - -// Implements Filer. -func (r *RollbackFiler) Sync() error { - r.mu.Lock() - defer r.mu.Unlock() - - return r.f.Sync() -} - -// Implements Filer. -func (r *RollbackFiler) Truncate(size int64) error { - r.mu.Lock() - defer r.mu.Unlock() - - if r.tlevel == 0 { - return &ErrPERM{r.f.Name() + ": Truncate outside of a transaction"} - } - - return r.bitFiler.Truncate(size) -} - -// Implements Filer. -func (r *RollbackFiler) WriteAt(b []byte, off int64) (n int, err error) { - r.mu.Lock() - defer r.mu.Unlock() - - if r.tlevel == 0 { - return 0, &ErrPERM{r.f.Name() + ": WriteAt outside of a transaction"} - } - - return r.bitFiler.WriteAt(b, off) -} diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/AUTHORS b/Godeps/_workspace/src/github.com/cznic/fileutil/AUTHORS deleted file mode 100644 index 288ea0b1e7..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/AUTHORS +++ /dev/null @@ -1,14 +0,0 @@ -# This file lists authors for copyright purposes. This file is distinct from -# the CONTRIBUTORS files. See the latter for an explanation. -# -# Names should be added to this file as: -# Name or Organization -# -# The email address is not required for organizations. -# -# Please keep the list sorted. - -CZ.NIC z.s.p.o. -Jan Mercl <0xjnml@gmail.com> -Aaron Bieber - diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/CONTRIBUTORS b/Godeps/_workspace/src/github.com/cznic/fileutil/CONTRIBUTORS deleted file mode 100644 index 223b21a307..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/CONTRIBUTORS +++ /dev/null @@ -1,14 +0,0 @@ -# This file lists people who contributed code to this repository. The AUTHORS -# file lists the copyright holders; this file lists people. -# -# Names should be added to this file like so: -# Name -# -# Please keep the list sorted. - -Bill Thiede -Gary Burd -Jan Mercl <0xjnml@gmail.com> -Nick Owens -Tamás Gulácsi -Aaron Bieber diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/LICENSE b/Godeps/_workspace/src/github.com/cznic/fileutil/LICENSE deleted file mode 100644 index 50bbdd2410..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2014 The fileutil 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 names of the authors nor the names of the -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. diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/Makefile b/Godeps/_workspace/src/github.com/cznic/fileutil/Makefile deleted file mode 100644 index 5849cc20a2..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) 2014 The fileutil authors. All rights reserved. -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file. - -.PHONY: all clean editor todo - -all: editor - go vet - golint . - go install - make todo - -editor: - go fmt - go test -i - go test - go build - -todo: - @grep -n ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* *.go || true - @grep -n TODO *.go || true - @grep -n BUG *.go || true - @grep -n println *.go || true - -clean: - @go clean - rm -f y.output diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/README b/Godeps/_workspace/src/github.com/cznic/fileutil/README deleted file mode 100644 index f43d5f0047..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/README +++ /dev/null @@ -1,16 +0,0 @@ -This is a goinstall-able mirror of modified code already published at: -http://git.nic.cz/redmine/projects/gofileutil/repository - -Packages in this repository: - -Install: $go get github.com/cznic/fileutil -Godocs: http://godoc.org/github.com/cznic/fileutil - -Install: $go get github.com/cznic/fileutil/storage -Godocs: http://godoc.org/github.com/cznic/fileutil/storage - -Install: $go get github.com/cznic/fileutil/falloc -Godocs: http://godoc.org/github.com/cznic/fileutil/falloc - -Install: $go get github.com/cznic/fileutil/hdb -Godocs: http://godoc.org/github.com/cznic/fileutil/hdb diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/falloc/LICENSE b/Godeps/_workspace/src/github.com/cznic/fileutil/falloc/LICENSE deleted file mode 100644 index 1e92e33dd7..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/falloc/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2011 CZ.NIC z.s.p.o. 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 CZ.NIC 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. diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/falloc/README b/Godeps/_workspace/src/github.com/cznic/fileutil/falloc/README deleted file mode 100644 index 23313fc505..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/falloc/README +++ /dev/null @@ -1,5 +0,0 @@ -This is a goinstall-able mirror of modified code already published at: -https://git.nic.cz/redmine/projects/gofileutil/repository/show/falloc - -Install: $go get github.com/cznic/fileutil/falloc -Godocs: http://gopkgdoc.appspot.com/pkg/github.com/cznic/fileutil/falloc diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/falloc/docs.go b/Godeps/_workspace/src/github.com/cznic/fileutil/falloc/docs.go deleted file mode 100644 index 21772fcd06..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/falloc/docs.go +++ /dev/null @@ -1,251 +0,0 @@ -// Copyright (c) 2011 CZ.NIC z.s.p.o. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// blame: jnml, labs.nic.cz - -/* - -WIP: Package falloc provides allocation/deallocation of space within a -file/store (WIP, unstable API). - -Overall structure: - File == n blocks. - Block == n atoms. - Atom == 16 bytes. - -x6..x0 == least significant 7 bytes of a 64 bit integer, highest (7th) byte is -0 and is not stored in the file. - -Block first byte - -Aka block type tag. - ------------------------------------------------------------------------------- - -0xFF: Free atom (free block of size 1). - +------++---------++---------++------+ - | 0 || 1...7 || 8...14 || 15 | - +------++---------++---------++------+ - | 0xFF || p6...p0 || n6...n0 || 0xFF | - +------++---------++---------++------+ - -Link to the previous free block (atom addressed) is p6...p0, next dtto in -n6...n0. Doubly linked lists of "compatible" free blocks allows for free space -reclaiming and merging. "Compatible" == of size at least some K. Heads of all -such lists are organized per K or intervals of Ks elsewhere. - ------------------------------------------------------------------------------- - -0xFE: Free block, size == s6...s0 atoms. - +------++---------++---------++---------++-- - | +0 || 1...7 || 8...14 || 15...21 || 22...16*size-1 - +------++---------++---------++---------++-- - | 0xFE || p6...p0 || n6...n0 || s6...s0 || ... - +------++---------++---------++---------++-- - -Prev and next links as in the 0xFF first byte case. End of this block - see -"Block last byte": 0xFE bellow. Data between == undefined. - ------------------------------------------------------------------------------- - -0xFD: Relocated block. - +------++---------++-----------++------+ - | 0 || 1...7 || 8...14 || 15 | - +------++---------++-----------++------+ - | 0xFD || r6...r0 || undefined || 0x00 | // == used block - +------++---------++-----------++------+ - -Relocation link is r6..r0 == atom address. Relocations MUST NOT chain and MUST -point to a "content" block, i.e. one with the first byte in 0x00...0xFC. - -Relocated block allows to permanently assign a handle/file pointer ("atom" -address) to some content and resize the content anytime afterwards w/o having -to update all the possible existing references to the original handle. - ------------------------------------------------------------------------------- - -0xFC: Used long block. - +------++---------++--------------------++---------+---+ - | 0 || 1...2 || 3...N+2 || | | - +------++---------++--------------------++---------+---+ - | 0xFC || n1...n0 || N bytes of content || padding | Z | - +------++---------++--------------------++---------+---+ - -This block type is used for content of length in N == 238...61680 bytes. N is -encoded as a 2 byte unsigned integer n1..n0 in network byte order. Values -bellow 238 are reserved, those content lengths are to be carried by the -0x00..0xFB block types. - - 1. n in 0x00EE...0xF0F0 is used for content under the same rules - as in the 0x01..0xED type. - - 2. If the last byte of the content is not the last byte of an atom then - the last byte of the block is 0x00. - - 3. If the last byte of the content IS the last byte of an atom: - - 3.1 If the last byte of content is in 0x00..0xFD then everything is OK. - - 3.2 If the last byte of content is 0xFE or 0xFF then the escape - via n > 0xF0F0 MUST be used AND the block's last byte is 0x00 or 0x01, - meaning value 0xFE and 0xFF respectively. - - 4. n in 0xF0F1...0xFFFF is like the escaped 0xEE..0xFB block. - N == 13 + 16(n - 0xF0F1). - -Discussion of the padding and Z fields - see the 0x01..0xED block type. - ------------------------------------------------------------------------------- - -0xEE...0xFB: Used escaped short block. - +---++----------------------++---+ - | 0 || 1...N-1 || | - +---++----------------------++---+ - | X || N-1 bytes of content || Z | - +---++----------------------++---+ - -N == 15 + 16(X - 0xEE). Z is the content last byte encoded as follows. - -case Z == 0x00: The last byte of content is 0xFE - -case Z == 0x01: The last byte of content is 0xFF - ------------------------------------------------------------------------------- - -0x01...0xED: Used short block. - +---++--------------------++---------+---+ - | 0 || 1...N || | | - +---++--------------------++---------+---+ - | N || N bytes of content || padding | Z | - +---++--------------------++---------+---+ - -This block type is used for content of length in 1...237 bytes. The value of -the "padding" field, if of non zero length, is undefined. - -If the last byte of content is the last byte of an atom (== its file byte -offset & 0xF == 0xF) then such last byte MUST be in 0x00...0xFD. - -If the last byte of content is the last byte of an atom AND the last byte of -content is 0xFE or 0xFF then the short escape block type (0xEE...0xFB) MUST be -used. - -If the last byte of content is not the last byte of an atom, then the last byte -of such block, i.e. the Z field, which is also a last byte of some atom, MUST -be 0x00 (i.e. the used block marker). Other "tail" values are reserved. - ------------------------------------------------------------------------------- - -0x00: Used empty block. - +------++-----------++------+ - | 0 || 1...14 || 15 | - +------++-----------++------+ - | 0x00 || undefined || 0x00 | // == used block, other "tail" values reserved. - +------++-----------++------+ - -All of the rules for 0x01..0xED applies. Depicted only for its different -semantics (e.g. an allocated [existing] string but with length of zero). - -============================================================================== - -Block last byte - ------------------------------------------------------------------------------- - -0xFF: Free atom. Layout - see "Block first byte": FF. - ------------------------------------------------------------------------------- - -0xFE: Free block, size n atoms. Preceding 7 bytes == size (s6...s0) of the free -block in atoms, network byte order - --++---------++------+ - || -8...-2 || -1 | - --++---------++------+ - ... || s6...s0 || 0xFE | <- block's last byte - --++---------++------+ - -Layout at start of this block - see "Block first byte": FE. - ------------------------------------------------------------------------------- - -0x00...0xFD: Used (non free) block. - -============================================================================== - -Free lists table - -The free lists table content is stored in the standard layout of a used block. - -A table item is a 7 byte size field followed by a 7 byte atom address field -(both in network byte order), thus every item is 14 contiguous bytes. The -item's address field is pointing to a free block. The size field determines -the minimal size (in atoms) of free blocks on that list. - -The free list table is n above items, thus the content has 14n bytes. Note that -the largest block content is 61680 bytes and as there are 14 bytes per table -item, so the table is limited to at most 4405 entries. - -Items in the table do not have to be sorted according to their size field values. - -No two items can have the same value of the size field. - -When freeing blocks, the block MUST be linked into an item list with the -highest possible size field, which is less or equal to the number of atoms in -the new free block. - -When freeing a block, the block MUST be first merged with any adjacent free -blocks (thus possibly creating a bigger free block) using information derived -from the adjacent blocks first and last bytes. Such merged free blocks MUST be -removed from their original doubly linked lists. Afterwards the new bigger free -block is put to the free list table in the appropriate item. - -Items with address field == 0 are legal. Such item is a placeholder for a empty -list of free blocks of the item's size. - -Items with size field == 0 are legal. Such item is a placeholder, used e.g. to -avoid further reallocations/redirecting of the free lists table. - -The largest possible allocation request (for content length 61680 bytes) is -0xF10 (3856) atoms. All free blocks of this or bigger size are presumably put -into a single table item with the size 3856. It may be useful to additionally -have a free lists table item which links free blocks of some bigger size (say -1M+) and then use the OS sparse file support (if present) to save the physical -space used by such free blocks. - -Smaller (<3856 atoms) free blocks can be organized exactly (every distinct size -has its table item) or the sizes can run using other schema like e.g. "1, 2, -4, 8, ..." (powers of 2) or "1, 2, 3, 5, 8, 13, ..." (the Fibonacci sequence) -or they may be fine tuned to a specific usage pattern. - -============================================================================== - -Header - -The first block of a file (atom address == file offset == 0) is the file header. -The header block has the standard layout of a used short non escaped block. - -Special conditions apply: The header block and its content MUST be like this: - - +------+---------+---------+------+ - | 0 | 1...7 | 8...14 | 15 | - +------+---------+---------+------+ - | 0x0F | m6...m0 | f6...f0 | FLTT | - +------+---------+---------+------+ - -m6..m0 is a "magic" value 0xF1C1A1FE51B1E. - -f6...f0 is the atom address of the free lists table (discussed elsewhere). -If f6...f0 == 0x00 the there is no free lists table (yet). - -FLTT describes the type of the Free List Table. Currently defined values: - ------------------------------------------------------------------------------- - -FLTT == 0: Free List Table is fixed at atom address 2. It has a fixed size for 3856 entries -for free list of size 1..3855 atoms and the last is for the list of free block >= 3856 atoms. -*/ -package falloc - -const ( - INVALID_HANDLE = Handle(-1) -) diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/falloc/error.go b/Godeps/_workspace/src/github.com/cznic/fileutil/falloc/error.go deleted file mode 100644 index dad3d29e68..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/falloc/error.go +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (c) 2011 CZ.NIC z.s.p.o. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// blame: jnml, labs.nic.cz - -package falloc - -import "fmt" - -// EBadRequest is an error produced for invalid operation, e.g. for data of more than maximum allowed. -type EBadRequest struct { - Name string - Size int -} - -func (e *EBadRequest) Error() string { - return fmt.Sprintf("%s: size %d", e.Name, e.Size) -} - -// EClose is a file/store close error. -type EClose struct { - Name string - Err error -} - -func (e *EClose) Error() string { - return fmt.Sprintf("%sx: %s", e.Name, e.Err) -} - -// ECorrupted is a file/store format error. -type ECorrupted struct { - Name string - Ofs int64 -} - -func (e *ECorrupted) Error() string { - return fmt.Sprintf("%s: corrupted data @%#x", e.Name, e.Ofs) -} - -// ECreate is a file/store create error. -type ECreate struct { - Name string - Err error -} - -func (e *ECreate) Error() string { - return fmt.Sprintf("%s: %s", e.Name, e.Err) -} - -// EFreeList is a file/store format error. -type EFreeList struct { - Name string - Size int64 - Block int64 -} - -func (e *EFreeList) Error() string { - return fmt.Sprintf("%s: invalid free list item, size %#x, block %#x", e.Name, e.Size, e.Block) -} - -// EHandle is an error type reported for invalid Handles. -type EHandle struct { - Name string - Handle Handle -} - -func (e EHandle) Error() string { - return fmt.Sprintf("%s: invalid handle %#x", e.Name, e.Handle) -} - -// EHeader is a file/store format error. -type EHeader struct { - Name string - Header []byte - Expected []byte -} - -func (e *EHeader) Error() string { - return fmt.Sprintf("%s: invalid header, got [% x], expected [% x]", e.Name, e.Header, e.Expected) -} - -// ENullHandle is a file/store access error via a null handle. -type ENullHandle string - -func (e ENullHandle) Error() string { - return fmt.Sprintf("%s: access via null handle", e) -} - -// EOpen is a file/store open error. -type EOpen struct { - Name string - Err error -} - -func (e *EOpen) Error() string { - return fmt.Sprintf("%s: %s", e.Name, e.Err) -} - -// ERead is a file/store read error. -type ERead struct { - Name string - Ofs int64 - Err error -} - -func (e *ERead) Error() string { - return fmt.Sprintf("%s, %#x: %s", e.Name, e.Ofs, e.Err) -} - -// ESize is a file/store size error. -type ESize struct { - Name string - Size int64 -} - -func (e *ESize) Error() string { - return fmt.Sprintf("%s: invalid size %#x(%d), size %%16 != 0", e.Name, e.Size, e.Size) -} - -// EWrite is a file/store write error. -type EWrite struct { - Name string - Ofs int64 - Err error -} - -func (e *EWrite) Error() string { - return fmt.Sprintf("%s, %#x: %s", e.Name, e.Ofs, e.Err) -} diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/falloc/falloc.go b/Godeps/_workspace/src/github.com/cznic/fileutil/falloc/falloc.go deleted file mode 100644 index 066a7047f3..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/falloc/falloc.go +++ /dev/null @@ -1,676 +0,0 @@ -// Copyright (c) 2011 CZ.NIC z.s.p.o. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// blame: jnml, labs.nic.cz - -/* - -This is an mostly (WIP) conforming implementation of the "specs" in docs.go. - -The main incompletness is support for only one kind of FTL, though this table kind is still per "specs". - -*/ - -package falloc - -import ( - "bytes" - "github.com/cznic/fileutil/storage" - "sync" -) - -// Handle is a reference to a block in a file/store. -// Handle is an uint56 wrapped in an in64, i.e. the most significant byte must be always zero. -type Handle int64 - -// Put puts the 7 least significant bytes of h into b. The MSB of h should be zero. -func (h Handle) Put(b []byte) { - for ofs := 6; ofs >= 0; ofs-- { - b[ofs] = byte(h) - h >>= 8 - } -} - -// Get gets the 7 least significant bytes of h from b. The MSB of h is zeroed. -func (h *Handle) Get(b []byte) { - var x Handle - for ofs := 0; ofs <= 6; ofs++ { - x = x<<8 | Handle(b[ofs]) - } - *h = x -} - -// File is a file/store with space allocation/deallocation support. -type File struct { - f storage.Accessor - atoms int64 // current file size in atom units - canfree int64 // only blocks >= canfree can be subject to Free() - freetab [3857]int64 // freetab[0] is unused, freetab[1] is size 1 ptr, freetab[2] is size 2 ptr, ... - rwm sync.RWMutex -} - -func (f *File) read(b []byte, off int64) { - if n, err := f.f.ReadAt(b, off); n != len(b) { - panic(&ERead{f.f.Name(), off, err}) - } -} - -func (f *File) write(b []byte, off int64) { - if n, err := f.f.WriteAt(b, off); n != len(b) { - panic(&EWrite{f.f.Name(), off, err}) - } -} - -var ( // R/O - hdr = []byte{0x0f, 0xf1, 0xc1, 0xa1, 0xfe, 0xa5, 0x1b, 0x1e, 0, 0, 0, 0, 0, 0, 2, 0} // free lists table @2 - empty = make([]byte, 16) - zero = []byte{0} - zero7 = make([]byte, 7) -) - -// New returns a new File backed by store or an error if any. -// Any existing data in store are discarded. -func New(store storage.Accessor) (f *File, err error) { - f = &File{f: store} - return f, storage.Mutate(store, func() (err error) { - if err = f.f.Truncate(0); err != nil { - return &ECreate{f.f.Name(), err} - } - - if _, err = f.Alloc(hdr[1:]); err != nil { //TODO internal panicking versions of the exported fns. - return - } - - if _, err = f.Alloc(nil); err != nil { // (empty) root @1 - return - } - - b := make([]byte, 3856*14) - for i := 1; i <= 3856; i++ { - Handle(i).Put(b[(i-1)*14:]) - } - if _, err = f.Alloc(b); err != nil { - return - } - - f.canfree = f.atoms - return - }) -} - -// Open returns a new File backed by store or an error if any. -// Store already has to be in a valid format. -func Open(store storage.Accessor) (f *File, err error) { - defer func() { - if e := recover(); e != nil { - f = nil - err = e.(error) - } - }() - - fi, err := store.Stat() - if err != nil { - panic(&EOpen{store.Name(), err}) - } - - fs := fi.Size() - if fs&0xf != 0 { - panic(&ESize{store.Name(), fi.Size()}) - } - - f = &File{f: store, atoms: fs >> 4} - b := make([]byte, len(hdr)) - f.read(b, 0) - if !bytes.Equal(b, hdr) { - panic(&EHeader{store.Name(), b, append([]byte{}, hdr...)}) - } - - var atoms int64 - b, atoms = f.readUsed(2) - f.canfree = atoms + 2 - ofs := 0 - var size, p Handle - for ofs < len(b) { - size.Get(b[ofs:]) - ofs += 7 - p.Get(b[ofs:]) - ofs += 7 - if sz, pp := int64(size), int64(p); size == 0 || size > 3856 || (pp != 0 && pp < f.canfree) || pp<<4 > fs-16 { - panic(&EFreeList{store.Name(), sz, pp}) - } - - f.freetab[size] = int64(p) - } - return -} - -// Accessor returns the File's underlying Accessor. -func (f *File) Accessor() storage.Accessor { - return f.f -} - -// Close closes f and returns an error if any. -func (f *File) Close() (err error) { - return storage.Mutate(f.Accessor(), func() (err error) { - if err = f.f.Close(); err != nil { - err = &EClose{f.f.Name(), err} - } - return - }) -} - -// Root returns the handle of the DB root (top level directory, ...). -func (f *File) Root() Handle { - return 1 -} - -func (f *File) readUsed(atom int64) (content []byte, atoms int64) { - b, redirected := make([]byte, 7), false -redir: - ofs := atom << 4 - f.read(b[:1], ofs) - switch pre := b[0]; { - default: - panic(&ECorrupted{f.f.Name(), ofs}) - case pre == 0x00: // Empty block - case pre >= 1 && pre <= 237: // Short - content = make([]byte, pre) - f.read(content, ofs+1) - case pre >= 0xee && pre <= 0xfb: // Short esc - content = make([]byte, 15+16*(pre-0xee)) - f.read(content, ofs+1) - content[len(content)-1] += 0xfe - case pre == 0xfc: // Long - f.read(b[:2], ofs+1) - n := int(b[0])<<8 + int(b[1]) - switch { - default: - panic(&ECorrupted{f.f.Name(), ofs + 1}) - case n >= 238 && n <= 61680: // Long non esc - content = make([]byte, n) - f.read(content, ofs+3) - case n >= 61681: // Long esc - content = make([]byte, 13+16*(n-0xf0f1)) - f.read(content, ofs+3) - content[len(content)-1] += 0xfe - } - case pre == 0xfd: // redir - if redirected { - panic(&ECorrupted{f.f.Name(), ofs}) - } - - f.read(b[:7], ofs+1) - (*Handle)(&atom).Get(b) - redirected = true - goto redir - } - return content, rq2Atoms(len(content)) -} - -func (f *File) writeUsed(b []byte, atom int64) { - n := len(b) - switch ofs, atoms, endmark := atom<<4, rq2Atoms(n), true; { - default: - panic("internal error") - case n == 0: - f.write(empty, ofs) - case n <= 237: - if (n+1)&0xf == 0 { // content end == atom end - if v := b[n-1]; v >= 0xfe { // escape - pre := []byte{byte((16*0xee + n - 15) >> 4)} - f.write(pre, ofs) - f.write(b[:n-1], ofs+1) - f.write([]byte{v - 0xfe}, ofs+atoms<<4-1) - return - } - endmark = false - } - // non esacpe - pre := []byte{byte(n)} - f.write(pre, ofs) - f.write(b, ofs+1) - if endmark { - f.write(zero, ofs+atoms<<4-1) // last block byte <- used block - } - case n > 237 && n <= 61680: - if (n+3)&0xf == 0 { // content end == atom end - if v := b[n-1]; v >= 0xfe { // escape - x := (16*0xf0f1 + n - 13) >> 4 - pre := []byte{0xFC, byte(x >> 8), byte(x)} - f.write(pre, ofs) - f.write(b[:n-1], ofs+3) - f.write([]byte{v - 0xfe}, ofs+atoms<<4-1) - return - } - endmark = false - } - // non esacpe - pre := []byte{0xfc, byte(n >> 8), byte(n)} - f.write(pre, ofs) - f.write(b, ofs+3) - if endmark { - f.write(zero, ofs+atoms<<4-1) // last block byte <- used block - } - } -} - -func rq2Atoms(rqbytes int) (rqatoms int64) { - if rqbytes > 237 { - rqbytes += 2 - } - return int64(rqbytes>>4 + 1) -} - -func (f *File) extend(b []byte) (handle int64) { - handle = f.atoms - f.writeUsed(b, handle) - f.atoms += rq2Atoms(len(b)) - return -} - -// Alloc stores b in a newly allocated space and returns its handle and an error if any. -func (f *File) Alloc(b []byte) (handle Handle, err error) { - err = storage.Mutate(f.Accessor(), func() (err error) { - rqAtoms := rq2Atoms(len(b)) - if rqAtoms > 3856 { - return &EBadRequest{f.f.Name(), len(b)} - } - - for foundsize, foundp := range f.freetab[rqAtoms:] { - if foundp != 0 { - // this works only for the current unique sizes list (except the last item!) - size := int64(foundsize) + rqAtoms - handle = Handle(foundp) - if size == 3856 { - buf := make([]byte, 7) - f.read(buf, int64(handle)<<4+15) - (*Handle)(&size).Get(buf) - } - f.delFree(int64(handle), size) - if rqAtoms < size { - f.addFree(int64(handle)+rqAtoms, size-rqAtoms) - } - f.writeUsed(b, int64(handle)) - return - } - } - - handle = Handle(f.extend(b)) - return - }) - return -} - -// checkLeft returns the atom size of a free bleck left adjacent to block @atom. -// If that block is not free the returned size is 0. -func (f *File) checkLeft(atom int64) (size int64) { - if atom <= f.canfree { - return - } - - b := make([]byte, 7) - fp := atom << 4 - f.read(b[:1], fp-1) - switch last := b[0]; { - case last <= 0xfd: - // used block - case last == 0xfe: - f.read(b, fp-8) - (*Handle)(&size).Get(b) - case last == 0xff: - size = 1 - } - return -} - -// getInfo returns the block @atom type and size. -func (f *File) getInfo(atom int64) (pref byte, size int64) { - b := make([]byte, 7) - fp := atom << 4 - f.read(b[:1], fp) - switch pref = b[0]; { - case pref == 0: // Empty used - size = 1 - case pref >= 1 && pref <= 237: // Short - size = rq2Atoms(int(pref)) - case pref >= 0xee && pref <= 0xfb: // Short esc - size = rq2Atoms(15 + 16*int(pref-0xee)) - case pref == 0xfc: // Long - f.read(b[:2], fp+1) - n := int(b[0])<<8 + int(b[1]) - switch { - default: - panic(&ECorrupted{f.f.Name(), fp + 1}) - case n >= 238 && n <= 61680: // Long non esc - size = rq2Atoms(n) - case n >= 61681: // Long esc - size = rq2Atoms(13 + 16*(n-0xf0f1)) - } - case pref == 0xfd: // reloc - size = 1 - case pref == 0xfe: - f.read(b, fp+15) - (*Handle)(&size).Get(b) - case pref == 0xff: - size = 1 - } - return -} - -// getSize returns the atom size of the block @atom and wheter it is free. -func (f *File) getSize(atom int64) (size int64, isFree bool) { - var typ byte - typ, size = f.getInfo(atom) - isFree = typ >= 0xfe - return -} - -// checkRight returns the atom size of a free bleck right adjacent to block @atom,atoms. -// If that block is not free the returned size is 0. -func (f *File) checkRight(atom, atoms int64) (size int64) { - if atom+atoms >= f.atoms { - return - } - - if sz, free := f.getSize(atom + atoms); free { - size = sz - } - return -} - -// delFree removes the atoms@atom free block from the free block list -func (f *File) delFree(atom, atoms int64) { - b := make([]byte, 15) - size := int(atoms) - if n := len(f.freetab); atoms >= int64(n) { - size = n - 1 - } - fp := atom << 4 - f.read(b[1:], fp+1) - var prev, next Handle - prev.Get(b[1:]) - next.Get(b[8:]) - - switch { - case prev == 0 && next != 0: - next.Put(b) - f.write(b[:7], int64(32+3+7+(size-1)*14)) - f.write(zero7, int64(next)<<4+1) - f.freetab[size] = int64(next) - case prev != 0 && next == 0: - f.write(zero7, int64(prev)<<4+8) - case prev != 0 && next != 0: - prev.Put(b) - f.write(b[:7], int64(next)<<4+1) - next.Put(b) - f.write(b[:7], int64(prev)<<4+8) - default: // prev == 0 && next == 0: - f.write(zero7, int64(32+3+7+(size-1)*14)) - f.freetab[size] = 0 - } -} - -// addFree adds atoms@atom to the free block lists and marks it free. -func (f *File) addFree(atom, atoms int64) { - b := make([]byte, 7) - size := int(atoms) - if n := len(f.freetab); atoms >= int64(n) { - size = n - 1 - } - head := f.freetab[size] - if head == 0 { // empty list - f.makeFree(0, atom, atoms, 0) - Handle(atom).Put(b) - f.write(b, int64(32+3+7+(size-1)*14)) - f.freetab[size] = atom - return - } - - Handle(atom).Put(b) - f.write(b, head<<4+1) // head.prev = atom - f.makeFree(0, atom, atoms, head) // atom.next = head - f.write(b, int64(32+3+7+(size-1)*14)) - f.freetab[size] = atom -} - -// makeFree sets up the content of a free block atoms@atom, fills the prev and next links. -func (f *File) makeFree(prev, atom, atoms, next int64) { - b := make([]byte, 23) - fp := atom << 4 - if atoms == 1 { - b[0] = 0xff - Handle(prev).Put(b[1:]) - Handle(next).Put(b[8:]) - b[15] = 0xff - f.write(b[:16], fp) - return - } - - b[0] = 0xfe - Handle(prev).Put(b[1:]) - Handle(next).Put(b[8:]) - Handle(atoms).Put(b[15:]) - f.write(b[:22], fp) - b[22] = 0xfe - f.write(b[15:], fp+atoms<<4-8) -} - -// Read reads and return the data associated with handle and an error if any. -// Passing an invalid handle to Read may return invalid data without error. -// It's like getting garbage via passing an invalid pointer to C.memcopy(). -func (f *File) Read(handle Handle) (b []byte, err error) { - defer func() { - if e := recover(); e != nil { - b = nil - err = e.(error) - } - }() - - switch handle { - case 0: - panic(ENullHandle(f.f.Name())) - case 2: - panic(&EHandle{f.f.Name(), handle}) - default: - b, _ = f.readUsed(int64(handle)) - } - return -} - -// Free frees space associated with handle and returns an error if any. Passing an invalid -// handle to Free or reusing handle afterwards will probably corrupt the database or provide -// invalid data on Read. It's like corrupting memory via passing an invalid pointer to C.free() -// or reusing that pointer. -func (f *File) Free(handle Handle) (err error) { - return storage.Mutate(f.Accessor(), func() (err error) { - atom := int64(handle) - atoms, isFree := f.getSize(atom) - if isFree || atom < f.canfree { - return &EHandle{f.f.Name(), handle} - } - - leftFree, rightFree := f.checkLeft(atom), f.checkRight(atom, atoms) - switch { - case leftFree != 0 && rightFree != 0: - f.delFree(atom-leftFree, leftFree) - f.delFree(atom+atoms, rightFree) - f.addFree(atom-leftFree, leftFree+atoms+rightFree) - case leftFree != 0 && rightFree == 0: - f.delFree(atom-leftFree, leftFree) - if atom+atoms == f.atoms { // the left free neighbour and this block together are an empy tail - f.atoms = atom - leftFree - f.f.Truncate(f.atoms << 4) - return - } - - f.addFree(atom-leftFree, leftFree+atoms) - case leftFree == 0 && rightFree != 0: - f.delFree(atom+atoms, rightFree) - f.addFree(atom, atoms+rightFree) - default: // leftFree == 0 && rightFree == 0 - if atom+atoms < f.atoms { // isolated inner block - f.addFree(atom, atoms) - return - } - - f.f.Truncate(atom << 4) // isolated tail block, shrink file - f.atoms = atom - } - return - }) -} - -// Realloc reallocates space associted with handle to acomodate b, returns the newhandle -// newly associated with b and an error if any. If keepHandle == true then Realloc guarantees -// newhandle == handle even if the new data are larger then the previous content associated -// with handle. If !keepHandle && newhandle != handle then reusing handle will probably corrupt -// the database. -// The above effects are like corrupting memory/data via passing an invalid pointer to C.realloc(). -func (f *File) Realloc(handle Handle, b []byte, keepHandle bool) (newhandle Handle, err error) { - err = storage.Mutate(f.Accessor(), func() (err error) { - switch handle { - case 0, 2: - return &EHandle{f.f.Name(), handle} - case 1: - keepHandle = true - } - newhandle = handle - atom, newatoms := int64(handle), rq2Atoms(len(b)) - if newatoms > 3856 { - return &EBadRequest{f.f.Name(), len(b)} - } - - typ, oldatoms := f.getInfo(atom) - switch { - default: - return &ECorrupted{f.f.Name(), atom << 4} - case typ <= 0xfc: // non relocated used block - switch { - case newatoms == oldatoms: // in place replace - f.writeUsed(b, atom) - case newatoms < oldatoms: // in place shrink - rightFree := f.checkRight(atom, oldatoms) - if rightFree > 0 { // right join - f.delFree(atom+oldatoms, rightFree) - } - f.addFree(atom+newatoms, oldatoms+rightFree-newatoms) - f.writeUsed(b, atom) - case newatoms > oldatoms: - if rightFree := f.checkRight(atom, oldatoms); rightFree > 0 && newatoms <= oldatoms+rightFree { - f.delFree(atom+oldatoms, rightFree) - if newatoms < oldatoms+rightFree { - f.addFree(atom+newatoms, oldatoms+rightFree-newatoms) - } - f.writeUsed(b, atom) - return - } - - if !keepHandle { - f.Free(Handle(atom)) - newhandle, err = f.Alloc(b) - return - } - - // reloc - newatom, e := f.Alloc(b) - if e != nil { - return e - } - - buf := make([]byte, 16) - buf[0] = 0xfd - Handle(newatom).Put(buf[1:]) - f.Realloc(Handle(atom), buf[1:], true) - f.write(buf[:1], atom<<4) - } - case typ == 0xfd: // reloc - var target Handle - buf := make([]byte, 7) - f.read(buf, atom<<4+1) - target.Get(buf) - switch { - case newatoms == 1: - f.writeUsed(b, atom) - f.Free(target) - default: - if rightFree := f.checkRight(atom, 1); rightFree > 0 && newatoms <= 1+rightFree { - f.delFree(atom+1, rightFree) - if newatoms < 1+rightFree { - f.addFree(atom+newatoms, 1+rightFree-newatoms) - } - f.writeUsed(b, atom) - f.Free(target) - return - } - - newtarget, e := f.Realloc(Handle(target), b, false) - if e != nil { - return e - } - - if newtarget != target { - Handle(newtarget).Put(buf) - f.write(buf, atom<<4+1) - } - } - } - return - }) - return -} - -// Lock locks f for writing. If the lock is already locked for reading or writing, -// Lock blocks until the lock is available. To ensure that the lock eventually becomes available, -// a blocked Lock call excludes new readers from acquiring the lock. -func (f *File) Lock() { - f.rwm.Lock() -} - -// RLock locks f for reading. If the lock is already locked for writing or there is a writer -// already waiting to release the lock, RLock blocks until the writer has released the lock. -func (f *File) RLock() { - f.rwm.RLock() -} - -// Unlock unlocks f for writing. It is a run-time error if f is not locked for writing on entry to Unlock. -// -// As with Mutexes, a locked RWMutex is not associated with a particular goroutine. -// One goroutine may RLock (Lock) f and then arrange for another goroutine to RUnlock (Unlock) it. -func (f *File) Unlock() { - f.rwm.Unlock() -} - -// RUnlock undoes a single RLock call; it does not affect other simultaneous readers. -// It is a run-time error if f is not locked for reading on entry to RUnlock. -func (f *File) RUnlock() { - f.rwm.RUnlock() -} - -// LockedAlloc wraps Alloc in a Lock/Unlock pair. -func (f *File) LockedAlloc(b []byte) (handle Handle, err error) { - f.Lock() - defer f.Unlock() - return f.Alloc(b) -} - -// LockedFree wraps Free in a Lock/Unlock pair. -func (f *File) LockedFree(handle Handle) (err error) { - f.Lock() - defer f.Unlock() - return f.Free(handle) -} - -// LockedRead wraps Read in a RLock/RUnlock pair. -func (f *File) LockedRead(handle Handle) (b []byte, err error) { - f.RLock() - defer f.RUnlock() - return f.Read(handle) -} - -// LockedRealloc wraps Realloc in a Lock/Unlock pair. -func (f *File) LockedRealloc(handle Handle, b []byte, keepHandle bool) (newhandle Handle, err error) { - f.Lock() - defer f.Unlock() - return f.Realloc(handle, b, keepHandle) -} diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/falloc/test_deps.go b/Godeps/_workspace/src/github.com/cznic/fileutil/falloc/test_deps.go deleted file mode 100644 index 3bdd39f2b5..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/falloc/test_deps.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2011 CZ.NIC z.s.p.o. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// blame: jnml, labs.nic.cz - -package falloc - -// Pull test dependencies too. -// Enables easy 'go test X' after 'go get X' -import ( - _ "github.com/cznic/fileutil" - _ "github.com/cznic/fileutil/storage" - _ "github.com/cznic/mathutil" -) diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil.go b/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil.go deleted file mode 100644 index 2f0f7ab155..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil.go +++ /dev/null @@ -1,223 +0,0 @@ -// Copyright (c) 2014 The fileutil 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 fileutil collects some file utility functions. -package fileutil - -import ( - "fmt" - "io" - "os" - "path/filepath" - "runtime" - "strconv" - "sync" - "time" -) - -// GoMFile is a concurrent access safe version of MFile. -type GoMFile struct { - mfile *MFile - mutex sync.Mutex -} - -// NewGoMFile return a newly created GoMFile. -func NewGoMFile(fname string, flag int, perm os.FileMode, delta_ns int64) (m *GoMFile, err error) { - m = &GoMFile{} - if m.mfile, err = NewMFile(fname, flag, perm, delta_ns); err != nil { - m = nil - } - return -} - -func (m *GoMFile) File() (file *os.File, err error) { - m.mutex.Lock() - defer m.mutex.Unlock() - return m.mfile.File() -} - -func (m *GoMFile) SetChanged() { - m.mutex.Lock() - defer m.mutex.Unlock() - m.mfile.SetChanged() -} - -func (m *GoMFile) SetHandler(h MFileHandler) { - m.mutex.Lock() - defer m.mutex.Unlock() - m.mfile.SetHandler(h) -} - -// MFileHandler resolves modifications of File. -// Possible File context is expected to be a part of the handler's closure. -type MFileHandler func(*os.File) error - -// MFile represents an os.File with a guard/handler on change/modification. -// Example use case is an app with a configuration file which can be modified at any time -// and have to be reloaded in such event prior to performing something configurable by that -// file. The checks are made only on access to the MFile file by -// File() and a time threshold/hysteresis value can be chosen on creating a new MFile. -type MFile struct { - file *os.File - handler MFileHandler - t0 int64 - delta int64 - ctime int64 -} - -// NewMFile returns a newly created MFile or Error if any. -// The fname, flag and perm parameters have the same meaning as in os.Open. -// For meaning of the delta_ns parameter please see the (m *MFile) File() docs. -func NewMFile(fname string, flag int, perm os.FileMode, delta_ns int64) (m *MFile, err error) { - m = &MFile{} - m.t0 = time.Now().UnixNano() - if m.file, err = os.OpenFile(fname, flag, perm); err != nil { - return - } - - var fi os.FileInfo - if fi, err = m.file.Stat(); err != nil { - return - } - - m.ctime = fi.ModTime().UnixNano() - m.delta = delta_ns - runtime.SetFinalizer(m, func(m *MFile) { - m.file.Close() - }) - return -} - -// SetChanged forces next File() to unconditionally handle modification of the wrapped os.File. -func (m *MFile) SetChanged() { - m.ctime = -1 -} - -// SetHandler sets a function to be invoked when modification of MFile is to be processed. -func (m *MFile) SetHandler(h MFileHandler) { - m.handler = h -} - -// File returns an os.File from MFile. If time elapsed between the last invocation of this function -// and now is at least delta_ns ns (a parameter of NewMFile) then the file is checked for -// change/modification. For delta_ns == 0 the modification is checked w/o getting os.Time(). -// If a change is detected a handler is invoked on the MFile file. -// Any of these steps can produce an Error. If that happens the function returns nil, Error. -func (m *MFile) File() (file *os.File, err error) { - var now int64 - - mustCheck := m.delta == 0 - if !mustCheck { - now = time.Now().UnixNano() - mustCheck = now-m.t0 > m.delta - } - - if mustCheck { // check interval reached - var fi os.FileInfo - if fi, err = m.file.Stat(); err != nil { - return - } - - if fi.ModTime().UnixNano() != m.ctime { // modification detected - if m.handler == nil { - return nil, fmt.Errorf("no handler set for modified file %q", m.file.Name()) - } - if err = m.handler(m.file); err != nil { - return - } - - m.ctime = fi.ModTime().UnixNano() - } - m.t0 = now - } - - return m.file, nil -} - -// Read reads buf from r. It will either fill the full buf or fail. -// It wraps the functionality of an io.Reader which may return less bytes than requested, -// but may block if not all data are ready for the io.Reader. -func Read(r io.Reader, buf []byte) (err error) { - have := 0 - remain := len(buf) - got := 0 - for remain > 0 { - if got, err = r.Read(buf[have:]); err != nil { - return - } - - remain -= got - have += got - } - return -} - -// "os" and/or "syscall" extensions - -// FadviseAdvice is used by Fadvise. -type FadviseAdvice int - -// FAdviseAdvice values. -const ( - // $ grep FADV /usr/include/bits/fcntl.h - POSIX_FADV_NORMAL FadviseAdvice = iota // No further special treatment. - POSIX_FADV_RANDOM // Expect random page references. - POSIX_FADV_SEQUENTIAL // Expect sequential page references. - POSIX_FADV_WILLNEED // Will need these pages. - POSIX_FADV_DONTNEED // Don't need these pages. - POSIX_FADV_NOREUSE // Data will be accessed once. -) - -// TempFile creates a new temporary file in the directory dir with a name -// ending with suffix, basename starting with prefix, opens the file for -// reading and writing, and returns the resulting *os.File. If dir is the -// empty string, TempFile uses the default directory for temporary files (see -// os.TempDir). Multiple programs calling TempFile simultaneously will not -// choose the same file. The caller can use f.Name() to find the pathname of -// the file. It is the caller's responsibility to remove the file when no -// longer needed. -// -// NOTE: This function differs from ioutil.TempFile. -func TempFile(dir, prefix, suffix string) (f *os.File, err error) { - if dir == "" { - dir = os.TempDir() - } - - nconflict := 0 - for i := 0; i < 10000; i++ { - name := filepath.Join(dir, prefix+nextInfix()+suffix) - f, err = os.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600) - if os.IsExist(err) { - if nconflict++; nconflict > 10 { - rand = reseed() - } - continue - } - break - } - return -} - -// Random number state. -// We generate random temporary file names so that there's a good -// chance the file doesn't exist yet - keeps the number of tries in -// TempFile to a minimum. -var rand uint32 -var randmu sync.Mutex - -func reseed() uint32 { - return uint32(time.Now().UnixNano() + int64(os.Getpid())) -} - -func nextInfix() string { - randmu.Lock() - r := rand - if r == 0 { - r = reseed() - } - r = r*1664525 + 1013904223 // constants from Numerical Recipes - rand = r - randmu.Unlock() - return strconv.Itoa(int(1e9 + r%1e9))[1:] -} diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_arm.go b/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_arm.go deleted file mode 100644 index 9410d1bb26..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_arm.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2014 The fileutil 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 fileutil - -import ( - "io" - "os" -) - -// PunchHole deallocates space inside a file in the byte range starting at -// offset and continuing for len bytes. Not supported on ARM. -func PunchHole(f *os.File, off, len int64) error { - return nil -} - -// Fadvise predeclares an access pattern for file data. See also 'man 2 -// posix_fadvise'. Not supported on ARM. -func Fadvise(f *os.File, off, len int64, advice FadviseAdvice) error { - return nil -} - -// IsEOF reports whether err is an EOF condition. -func IsEOF(err error) bool { return err == io.EOF } diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_darwin.go b/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_darwin.go deleted file mode 100644 index a19723fc78..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_darwin.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2014 The fileutil 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 fileutil - -import ( - "io" - "os" -) - -// PunchHole deallocates space inside a file in the byte range starting at -// offset and continuing for len bytes. Not supported on OSX. -func PunchHole(f *os.File, off, len int64) error { - return nil -} - -// Fadvise predeclares an access pattern for file data. See also 'man 2 -// posix_fadvise'. Not supported on OSX. -func Fadvise(f *os.File, off, len int64, advice FadviseAdvice) error { - return nil -} - -// IsEOF reports whether err is an EOF condition. -func IsEOF(err error) bool { return err == io.EOF } diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_freebsd.go b/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_freebsd.go deleted file mode 100644 index 0865093e2b..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_freebsd.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2014 The fileutil 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 fileutil - -import ( - "io" - "os" -) - -// PunchHole deallocates space inside a file in the byte range starting at -// offset and continuing for len bytes. Unimplemented on FreeBSD. -func PunchHole(f *os.File, off, len int64) error { - return nil -} - -// Fadvise predeclares an access pattern for file data. See also 'man 2 -// posix_fadvise'. Unimplemented on FreeBSD. -func Fadvise(f *os.File, off, len int64, advice FadviseAdvice) error { - return nil -} - -// IsEOF reports whether err is an EOF condition. -func IsEOF(err error) bool { return err == io.EOF } diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_linux.go b/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_linux.go deleted file mode 100644 index 8babfc5533..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_linux.go +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) 2014 The fileutil 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 !arm - -package fileutil - -import ( - "bytes" - "io" - "io/ioutil" - "os" - "strconv" - "syscall" -) - -func n(s []byte) byte { - for i, c := range s { - if c < '0' || c > '9' { - s = s[:i] - break - } - } - v, _ := strconv.Atoi(string(s)) - return byte(v) -} - -func init() { - b, err := ioutil.ReadFile("/proc/sys/kernel/osrelease") - if err != nil { - panic(err) - } - - tokens := bytes.Split(b, []byte(".")) - if len(tokens) > 3 { - tokens = tokens[:3] - } - switch len(tokens) { - case 3: - // Supported since kernel 2.6.38 - if bytes.Compare([]byte{n(tokens[0]), n(tokens[1]), n(tokens[2])}, []byte{2, 6, 38}) < 0 { - puncher = func(*os.File, int64, int64) error { return nil } - } - case 2: - if bytes.Compare([]byte{n(tokens[0]), n(tokens[1])}, []byte{2, 7}) < 0 { - puncher = func(*os.File, int64, int64) error { return nil } - } - default: - puncher = func(*os.File, int64, int64) error { return nil } - } -} - -var puncher = func(f *os.File, off, len int64) error { - const ( - /* - /usr/include/linux$ grep FL_ falloc.h - */ - _FALLOC_FL_KEEP_SIZE = 0x01 // default is extend size - _FALLOC_FL_PUNCH_HOLE = 0x02 // de-allocates range - ) - - _, _, errno := syscall.Syscall6( - syscall.SYS_FALLOCATE, - uintptr(f.Fd()), - uintptr(_FALLOC_FL_KEEP_SIZE|_FALLOC_FL_PUNCH_HOLE), - uintptr(off), - uintptr(len), - 0, 0) - if errno != 0 { - return os.NewSyscallError("SYS_FALLOCATE", errno) - } - return nil -} - -// PunchHole deallocates space inside a file in the byte range starting at -// offset and continuing for len bytes. No-op for kernels < 2.6.38 (or < 2.7). -func PunchHole(f *os.File, off, len int64) error { - return puncher(f, off, len) -} - -// Fadvise predeclares an access pattern for file data. See also 'man 2 -// posix_fadvise'. -func Fadvise(f *os.File, off, len int64, advice FadviseAdvice) error { - _, _, errno := syscall.Syscall6( - syscall.SYS_FADVISE64, - uintptr(f.Fd()), - uintptr(off), - uintptr(len), - uintptr(advice), - 0, 0) - return os.NewSyscallError("SYS_FADVISE64", errno) -} - -// IsEOF reports whether err is an EOF condition. -func IsEOF(err error) bool { return err == io.EOF } diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_openbsd.go b/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_openbsd.go deleted file mode 100644 index 428171bdfe..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_openbsd.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2014 The fileutil 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 fileutil - -import ( - "io" - "os" -) - -// PunchHole deallocates space inside a file in the byte range starting at -// offset and continuing for len bytes. Similar to FreeBSD, this is -// unimplemented. -func PunchHole(f *os.File, off, len int64) error { - return nil -} - -// Unimplemented on OpenBSD. -func Fadvise(f *os.File, off, len int64, advice FadviseAdvice) error { - return nil -} - -// IsEOF reports whether err is an EOF condition. -func IsEOF(err error) bool { return err == io.EOF } diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_plan9.go b/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_plan9.go deleted file mode 100644 index a2db64e2d3..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_plan9.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2014 The fileutil 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 fileutil - -import ( - "io" - "os" -) - -// PunchHole deallocates space inside a file in the byte range starting at -// offset and continuing for len bytes. Unimplemented on Plan 9. -func PunchHole(f *os.File, off, len int64) error { - return nil -} - -// Fadvise predeclares an access pattern for file data. See also 'man 2 -// posix_fadvise'. Unimplemented on Plan 9. -func Fadvise(f *os.File, off, len int64, advice FadviseAdvice) error { - return nil -} - -// IsEOF reports whether err is an EOF condition. -func IsEOF(err error) bool { return err == io.EOF } diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_solaris.go b/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_solaris.go deleted file mode 100644 index 61dfcde38f..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_solaris.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2013 jnml. 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.3 - -package fileutil - -import ( - "io" - "os" -) - -// PunchHole deallocates space inside a file in the byte range starting at -// offset and continuing for len bytes. Not supported on Solaris. -func PunchHole(f *os.File, off, len int64) error { - return nil -} - -// Fadvise predeclares an access pattern for file data. See also 'man 2 -// posix_fadvise'. Not supported on Solaris. -func Fadvise(f *os.File, off, len int64, advice FadviseAdvice) error { - return nil -} - -// IsEOF reports whether err is an EOF condition. -func IsEOF(err error) bool { return err == io.EOF } diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_windows.go b/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_windows.go deleted file mode 100644 index 3a81f2fc87..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/fileutil_windows.go +++ /dev/null @@ -1,183 +0,0 @@ -// Copyright (c) 2014 The fileutil 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 fileutil - -import ( - "io" - "os" - "sync" - "syscall" - "unsafe" -) - -// PunchHole deallocates space inside a file in the byte range starting at -// offset and continuing for len bytes. Not supported on Windows. -func PunchHole(f *os.File, off, len int64) error { - return puncher(f, off, len) -} - -// Fadvise predeclares an access pattern for file data. See also 'man 2 -// posix_fadvise'. Not supported on Windows. -func Fadvise(f *os.File, off, len int64, advice FadviseAdvice) error { - return nil -} - -// IsEOF reports whether err is an EOF condition. -func IsEOF(err error) bool { - if err == io.EOF { - return true - } - - // http://social.technet.microsoft.com/Forums/windowsserver/en-US/1a16311b-c625-46cf-830b-6a26af488435/how-to-solve-error-38-0x26-errorhandleeof-using-fsctlgetretrievalpointers - x, ok := err.(*os.PathError) - return ok && x.Op == "read" && x.Err.(syscall.Errno) == 0x26 -} - -var ( - modkernel32 = syscall.NewLazyDLL("kernel32.dll") - - procDeviceIOControl = modkernel32.NewProc("DeviceIoControl") - - sparseFilesMu sync.Mutex - sparseFiles map[uintptr]struct{} -) - -func init() { - // sparseFiles is an fd set for already "sparsed" files - according to - // msdn.microsoft.com/en-us/library/windows/desktop/aa364225(v=vs.85).aspx - // the file handles are unique per process. - sparseFiles = make(map[uintptr]struct{}) -} - -// puncHoleWindows punches a hole into the given file starting at offset, -// measuring "size" bytes -// (http://msdn.microsoft.com/en-us/library/windows/desktop/aa364597%28v=vs.85%29.aspx) -func puncher(file *os.File, offset, size int64) error { - if err := ensureFileSparse(file); err != nil { - return err - } - - // http://msdn.microsoft.com/en-us/library/windows/desktop/aa364411%28v=vs.85%29.aspx - // typedef struct _FILE_ZERO_DATA_INFORMATION { - // LARGE_INTEGER FileOffset; - // LARGE_INTEGER BeyondFinalZero; - //} FILE_ZERO_DATA_INFORMATION, *PFILE_ZERO_DATA_INFORMATION; - type fileZeroDataInformation struct { - FileOffset, BeyondFinalZero int64 - } - - lpInBuffer := fileZeroDataInformation{ - FileOffset: offset, - BeyondFinalZero: offset + size} - return deviceIOControl(false, file.Fd(), uintptr(unsafe.Pointer(&lpInBuffer)), 16) -} - -// // http://msdn.microsoft.com/en-us/library/windows/desktop/cc948908%28v=vs.85%29.aspx -// type fileSetSparseBuffer struct { -// SetSparse bool -// } - -func ensureFileSparse(file *os.File) (err error) { - fd := file.Fd() - sparseFilesMu.Lock() - if _, ok := sparseFiles[fd]; ok { - sparseFilesMu.Unlock() - return nil - } - - if err = deviceIOControl(true, fd, 0, 0); err == nil { - sparseFiles[fd] = struct{}{} - } - sparseFilesMu.Unlock() - return err -} - -func deviceIOControl(setSparse bool, fd, inBuf, inBufLen uintptr) (err error) { - const ( - //http://source.winehq.org/source/include/winnt.h#L4605 - file_read_data = 1 - file_write_data = 2 - - // METHOD_BUFFERED 0 - method_buffered = 0 - // FILE_ANY_ACCESS 0 - file_any_access = 0 - // FILE_DEVICE_FILE_SYSTEM 0x00000009 - file_device_file_system = 0x00000009 - // FILE_SPECIAL_ACCESS (FILE_ANY_ACCESS) - file_special_access = file_any_access - file_read_access = file_read_data - file_write_access = file_write_data - - // http://source.winehq.org/source/include/winioctl.h - // #define CTL_CODE ( DeviceType, - // Function, - // Method, - // Access ) - // ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) - - // FSCTL_SET_COMPRESSION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 16, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA) - fsctl_set_compression = (file_device_file_system << 16) | ((file_read_access | file_write_access) << 14) | (16 << 2) | method_buffered - // FSCTL_SET_SPARSE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 49, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) - fsctl_set_sparse = (file_device_file_system << 16) | (file_special_access << 14) | (49 << 2) | method_buffered - // FSCTL_SET_ZERO_DATA CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 50, METHOD_BUFFERED, FILE_WRITE_DATA) - fsctl_set_zero_data = (file_device_file_system << 16) | (file_write_data << 14) | (50 << 2) | method_buffered - ) - retPtr := uintptr(unsafe.Pointer(&(make([]byte, 8)[0]))) - var r1 uintptr - var e1 syscall.Errno - if setSparse { - // BOOL - // WINAPI - // DeviceIoControl( (HANDLE) hDevice, // handle to a file - // FSCTL_SET_SPARSE, // dwIoControlCode - // (PFILE_SET_SPARSE_BUFFER) lpInBuffer, // input buffer - // (DWORD) nInBufferSize, // size of input buffer - // NULL, // lpOutBuffer - // 0, // nOutBufferSize - // (LPDWORD) lpBytesReturned, // number of bytes returned - // (LPOVERLAPPED) lpOverlapped ); // OVERLAPPED structure - r1, _, e1 = syscall.Syscall9(procDeviceIOControl.Addr(), 8, - fd, - uintptr(fsctl_set_sparse), - // If the lpInBuffer parameter is NULL, the operation will behave the same as if the SetSparse member of the FILE_SET_SPARSE_BUFFER structure were TRUE. In other words, the operation sets the file to a sparse file. - 0, // uintptr(unsafe.Pointer(&lpInBuffer)), - 0, // 1, - 0, - 0, - retPtr, - 0, - 0) - } else { - // BOOL - // WINAPI - // DeviceIoControl( (HANDLE) hDevice, // handle to a file - // FSCTL_SET_ZERO_DATA, // dwIoControlCode - // (LPVOID) lpInBuffer, // input buffer - // (DWORD) nInBufferSize, // size of input buffer - // NULL, // lpOutBuffer - // 0, // nOutBufferSize - // (LPDWORD) lpBytesReturned, // number of bytes returned - // (LPOVERLAPPED) lpOverlapped ); // OVERLAPPED structure - r1, _, e1 = syscall.Syscall9(procDeviceIOControl.Addr(), 8, - fd, - uintptr(fsctl_set_zero_data), - inBuf, - inBufLen, - 0, - 0, - retPtr, - 0, - 0) - } - if r1 == 0 { - if e1 != 0 { - err = error(e1) - } else { - err = syscall.EINVAL - } - } - return err -} diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/hdb/LICENSE b/Godeps/_workspace/src/github.com/cznic/fileutil/hdb/LICENSE deleted file mode 100644 index 1e92e33dd7..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/hdb/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2011 CZ.NIC z.s.p.o. 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 CZ.NIC 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. diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/hdb/README b/Godeps/_workspace/src/github.com/cznic/fileutil/hdb/README deleted file mode 100644 index 05ce89f92e..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/hdb/README +++ /dev/null @@ -1,5 +0,0 @@ -This is a goinstall-able mirror of modified code already published at: -https://git.nic.cz/redmine/projects/gofileutil/repository/show/hdb - -Install: $go get github.com/cznic/fileutil/hdb -Godocs: http://gopkgdoc.appspot.com/pkg/github.com/cznic/fileutil/hdb diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/hdb/hdb.go b/Godeps/_workspace/src/github.com/cznic/fileutil/hdb/hdb.go deleted file mode 100644 index 7c7113d9d3..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/hdb/hdb.go +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright (c) 2011 CZ.NIC z.s.p.o. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// blame: jnml, labs.nic.cz - -/* -WIP: Package hdb provides a "handle"/value DB like store, but actually it's -closer to the model of a process's virtual memory and its alloc, free and move -methods. - -The hdb package is a thin layer around falloc.File providing stable-only -handles and the basic synchronizing primitives. The central functionality of -hdb are the New, Set, Get and Delete methods of Store. - -Conceptual analogy: - New alloc(sizeof(content)), return new "memory" pointer (a handle). - - Get memmove() from "memory" "pointed to" by handle to the result content. - Note: Handle "knows" the size of its content. - - Set memmove() from content to "memory" pointed to by handle. - In contrast to real memory, the new content may have different - size than the previously stored one w/o additional handling - and the "pointer" handle remains the same. - - Delete free() the "memory" "pointed to" by handle. -*/ -package hdb - -import ( - "github.com/cznic/fileutil/falloc" - "github.com/cznic/fileutil/storage" -) - -type Store struct { - f *falloc.File -} - -// New returns a newly created Store backed by accessor, discarding its conents if any. -// If successful, methods on the returned Store can be used for I/O. -// It returns the Store and an error, if any. -func New(accessor storage.Accessor) (store *Store, err error) { - s := &Store{} - if s.f, err = falloc.New(accessor); err == nil { - store = s - } - return -} - -// Open opens the Store from accessor. -// If successful, methods on the returned Store can be used for data exchange. -// It returns the Store and an error, if any. -func Open(accessor storage.Accessor) (store *Store, err error) { - s := &Store{} - if s.f, err = falloc.Open(accessor); err == nil { - store = s - } - return -} - -// Close closes the store. Further access to the store has undefined behavior and may panic. -// It returns an error, if any. -func (s *Store) Close() (err error) { - defer func() { - s.f = nil - }() - - return s.f.Close() -} - -// Delete deletes the data associated with handle. -// It returns an error if any. -func (s *Store) Delete(handle falloc.Handle) (err error) { - return s.f.Free(handle) -} - -// Get gets the data associated with handle. -// It returns the data and an error, if any. -func (s *Store) Get(handle falloc.Handle) (b []byte, err error) { - return s.f.Read(handle) -} - -// New associates data with a new handle. -// It returns the handle and an error, if any. -func (s *Store) New(b []byte) (handle falloc.Handle, err error) { - return s.f.Alloc(b) -} - -// Set associates data with an existing handle. -// It returns an error, if any. -func (s *Store) Set(handle falloc.Handle, b []byte) (err error) { - _, err = s.f.Realloc(handle, b, true) - return -} - -// Root returns the handle of the DB root (top level directory, ...). -func (s *Store) Root() falloc.Handle { - return s.f.Root() -} - -// File returns the underlying falloc.File of 's'. -func (s *Store) File() *falloc.File { - return s.f -} - -// Lock locks 's' for writing. If the lock is already locked for reading or writing, -// Lock blocks until the lock is available. To ensure that the lock eventually becomes available, -// a blocked Lock call excludes new readers from acquiring the lock. -func (s *Store) Lock() { - s.f.Lock() -} - -// RLock locks 's' for reading. If the lock is already locked for writing or there is a writer -// already waiting to release the lock, RLock blocks until the writer has released the lock. -func (s *Store) RLock() { - s.f.RLock() -} - -// Unlock unlocks 's' for writing. It's a run-time error if 's' is not locked for writing on entry to Unlock. -// -// As with Mutexes, a locked RWMutex is not associated with a particular goroutine. -// One goroutine may RLock (Lock) 's' and then arrange for another goroutine to RUnlock (Unlock) it. -func (s *Store) Unlock() { - s.f.Unlock() -} - -// RUnlock undoes a single RLock call; it does not affect other simultaneous readers. -// It's a run-time error if 's' is not locked for reading on entry to RUnlock. -func (s *Store) RUnlock() { - s.f.RUnlock() -} - -// LockedNew wraps New in a Lock/Unlock pair. -func (s *Store) LockedNew(b []byte) (handle falloc.Handle, err error) { - return s.f.LockedAlloc(b) -} - -// LockedDelete wraps Delete in a Lock/Unlock pair. -func (s *Store) LockedDelete(handle falloc.Handle) (err error) { - return s.f.LockedFree(handle) -} - -// LockedGet wraps Get in a RLock/RUnlock pair. -func (s *Store) LockedGet(handle falloc.Handle) (b []byte, err error) { - return s.f.LockedRead(handle) -} - -// LockedSet wraps Set in a Lock/Unlock pair. -func (s *Store) LockedSet(handle falloc.Handle, b []byte) (err error) { - _, err = s.f.Realloc(handle, b, true) - return -} diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/hdb/test_deps.go b/Godeps/_workspace/src/github.com/cznic/fileutil/hdb/test_deps.go deleted file mode 100644 index 3164f63ae1..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/hdb/test_deps.go +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) 2011 CZ.NIC z.s.p.o. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// blame: jnml, labs.nic.cz - -package hdb - -// Pull test dependencies too. -// Enables easy 'go test X' after 'go get X' -import ( -// nothing yet -) diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/storage/LICENSE b/Godeps/_workspace/src/github.com/cznic/fileutil/storage/LICENSE deleted file mode 100644 index 1e92e33dd7..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/storage/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2011 CZ.NIC z.s.p.o. 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 CZ.NIC 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. diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/storage/README b/Godeps/_workspace/src/github.com/cznic/fileutil/storage/README deleted file mode 100644 index 2a400fced6..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/storage/README +++ /dev/null @@ -1,5 +0,0 @@ -This is a goinstall-able mirror of modified code already published at: -https://git.nic.cz/redmine/projects/gofileutil/repository/show/storage - -Install: $go get github.com/cznic/fileutil/storage -Godocs: http://gopkgdoc.appspot.com/pkg/github.com/cznic/fileutil/storage diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/storage/cache.go b/Godeps/_workspace/src/github.com/cznic/fileutil/storage/cache.go deleted file mode 100644 index 3a6115a71a..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/storage/cache.go +++ /dev/null @@ -1,322 +0,0 @@ -// Copyright (c) 2011 CZ.NIC z.s.p.o. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// blame: jnml, labs.nic.cz - -package storage - -import ( - "container/list" - "io" - "math" - "os" - "sync" - "sync/atomic" -) - -type cachepage struct { - b [512]byte - dirty bool - lru *list.Element - pi int64 - valid int // page content is b[:valid] -} - -func (p *cachepage) wr(b []byte, off int) (wasDirty bool) { - copy(p.b[off:], b) - if n := off + len(b); n > p.valid { - p.valid = n - } - wasDirty = p.dirty - p.dirty = true - return -} - -func (c *Cache) rd(off int64, read bool) (p *cachepage, ok bool) { - c.Rq++ - pi := off >> 9 - if p, ok = c.m[pi]; ok { - c.lru.MoveToBack(p.lru) - return - } - - if !read { - return - } - - fp := off &^ 511 - if fp >= c.size { - return - } - - rq := 512 - if fp+512 > c.size { - rq = int(c.size - fp) - } - p = &cachepage{pi: pi, valid: rq} - p.lru = c.lru.PushBack(p) - if n, err := c.f.ReadAt(p.b[:p.valid], fp); n != rq { - panic(err) - } - - c.Load++ - if c.advise != nil { - c.advise(fp, 512, false) - } - c.m[pi], ok = p, true - return -} - -func (c *Cache) wr(off int64) (p *cachepage) { - var ok bool - if p, ok = c.rd(off, false); ok { - return - } - - pi := off >> 9 - p = &cachepage{pi: pi} - p.lru = c.lru.PushBack(p) - c.m[pi] = p - return -} - -// Cache provides caching support for another store Accessor. -type Cache struct { - advise func(int64, int, bool) - clean chan bool - cleaning int32 - close chan bool - f Accessor - fi *FileInfo - lock sync.Mutex - lru *list.List - m map[int64]*cachepage - maxpages int - size int64 - sync chan bool - wlist *list.List - write chan bool - writing int32 - Rq int64 // Pages requested from cache - Load int64 // Pages loaded (cache miss) - Purge int64 // Pages purged - Top int // "High water" pages -} - -// Implementation of Accessor. -func (c *Cache) BeginUpdate() error { return nil } - -// Implementation of Accessor. -func (c *Cache) EndUpdate() error { return nil } - -// NewCache creates a caching Accessor from store with total of maxcache bytes. -// NewCache returns the new Cache, implementing Accessor or an error if any. -// -// The LRU mechanism is used, so the cache tries to keep often accessed pages cached. -// -func NewCache(store Accessor, maxcache int64, advise func(int64, int, bool)) (c *Cache, err error) { - var fi os.FileInfo - if fi, err = store.Stat(); err != nil { - return - } - - x := maxcache >> 9 - if x > math.MaxInt32/2 { - x = math.MaxInt32 / 2 - } - c = &Cache{ - advise: advise, - clean: make(chan bool, 1), - close: make(chan bool), - f: store, - lru: list.New(), // front == oldest used, back == last recently used - m: make(map[int64]*cachepage), - maxpages: int(x), - size: fi.Size(), - sync: make(chan bool), - wlist: list.New(), - write: make(chan bool, 1), - } - c.fi = NewFileInfo(fi, c) - go c.writer() - go c.cleaner(int((int64(c.maxpages) * 95) / 100)) // hysteresis - return -} - -func (c *Cache) Accessor() Accessor { - return c.f -} - -func (c *Cache) Close() (err error) { - close(c.write) - <-c.close - close(c.clean) - <-c.close - return c.f.Close() -} - -func (c *Cache) Name() (s string) { - return c.f.Name() -} - -func (c *Cache) ReadAt(b []byte, off int64) (n int, err error) { - po := int(off) & 0x1ff - bp := 0 - rem := len(b) - m := 0 - for rem != 0 { - c.lock.Lock() // X1+ - p, ok := c.rd(off, true) - if !ok { - c.lock.Unlock() // X1- - return -1, io.EOF - } - - rq := rem - if po+rq > 512 { - rq = 512 - po - } - if n := copy(b[bp:bp+rq], p.b[po:p.valid]); n != rq { - c.lock.Unlock() // X1- - return -1, io.EOF - } - - m = len(c.m) - c.lock.Unlock() // X1- - po = 0 - bp += rq - off += int64(rq) - rem -= rq - n += rq - } - if m > c.maxpages && atomic.CompareAndSwapInt32(&c.cleaning, 0, 1) { - if m > c.Top { - c.Top = m - } - c.clean <- true - } - return -} - -func (c *Cache) Stat() (fi os.FileInfo, err error) { - c.lock.Lock() - defer c.lock.Unlock() - return c.fi, nil -} - -func (c *Cache) Sync() (err error) { - c.write <- false - <-c.sync - return -} - -func (c *Cache) Truncate(size int64) (err error) { - c.Sync() //TODO improve (discard pages, the writer goroutine should also be aware, ...) - c.lock.Lock() - defer c.lock.Unlock() - c.size = size - return c.f.Truncate(size) -} - -func (c *Cache) WriteAt(b []byte, off int64) (n int, err error) { - po := int(off) & 0x1ff - bp := 0 - rem := len(b) - m := 0 - for rem != 0 { - c.lock.Lock() // X+ - p := c.wr(off) - rq := rem - if po+rq > 512 { - rq = 512 - po - } - if wasDirty := p.wr(b[bp:bp+rq], po); !wasDirty { - c.wlist.PushBack(p) - } - m = len(c.m) - po = 0 - bp += rq - off += int64(rq) - if off > c.size { - c.size = off - } - c.lock.Unlock() // X- - rem -= rq - n += rq - } - if atomic.CompareAndSwapInt32(&c.writing, 0, 1) { - c.write <- true - } - if m > c.maxpages && atomic.CompareAndSwapInt32(&c.cleaning, 0, 1) { - if m > c.Top { - c.Top = m - } - c.clean <- true - } - return -} - -func (c *Cache) writer() { - for ok := true; ok; { - var wr bool - var off int64 - wr, ok = <-c.write - for { - c.lock.Lock() // X1+ - item := c.wlist.Front() - if item == nil { - c.lock.Unlock() // X1- - break - } - - p := item.Value.(*cachepage) - off = p.pi << 9 - if n, err := c.f.WriteAt(p.b[:p.valid], off); n != p.valid { - c.lock.Unlock() // X1- - panic("TODO Cache.writer errchan") //TODO +errchan - panic(err) - } - - p.dirty = false - c.wlist.Remove(item) - if c.advise != nil { - c.advise(off, 512, true) - } - c.lock.Unlock() // X1- - } - switch { - case wr: - atomic.AddInt32(&c.writing, -1) - case ok: - c.sync <- true - } - } - c.close <- true -} - -func (c *Cache) cleaner(limit int) { - for _ = range c.clean { - var item *list.Element - for { - c.lock.Lock() // X1+ - if len(c.m) < limit { - c.lock.Unlock() // X1- - break - } - - if item == nil { - item = c.lru.Front() - } - if p := item.Value.(*cachepage); !p.dirty { - delete(c.m, p.pi) - c.lru.Remove(item) - c.Purge++ - } - item = item.Next() - c.lock.Unlock() // X1- - } - atomic.AddInt32(&c.cleaning, -1) - } - c.close <- true -} diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/storage/file.go b/Godeps/_workspace/src/github.com/cznic/fileutil/storage/file.go deleted file mode 100644 index 94feda5efb..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/storage/file.go +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2011 CZ.NIC z.s.p.o. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// blame: jnml, labs.nic.cz - -package storage - -import ( - "os" -) - -// FileAccessor is the concrete type returned by NewFile and OpenFile. -type FileAccessor struct { - *os.File -} - -// Implementation of Accessor. -func (f *FileAccessor) BeginUpdate() error { return nil } - -// Implementation of Accessor. -func (f *FileAccessor) EndUpdate() error { return nil } - -// NewFile returns an Accessor backed by an os.File named name, It opens the -// named file with specified flag (os.O_RDWR etc.) and perm, (0666 etc.) if -// applicable. If successful, methods on the returned Accessor can be used for -// I/O. It returns the Accessor and an Error, if any. -// -// NOTE: The returned Accessor implements BeginUpdate and EndUpdate as a no op. -func NewFile(name string, flag int, perm os.FileMode) (store Accessor, err error) { - var f FileAccessor - if f.File, err = os.OpenFile(name, flag, perm); err == nil { - store = &f - } - return -} - -// OpenFile returns an Accessor backed by an existing os.File named name, It -// opens the named file with specified flag (os.O_RDWR etc.) and perm, (0666 -// etc.) if applicable. If successful, methods on the returned Accessor can be -// used for I/O. It returns the Accessor and an Error, if any. -// -// NOTE: The returned Accessor implements BeginUpdate and EndUpdate as a no op. -func OpenFile(name string, flag int, perm os.FileMode) (store Accessor, err error) { - var f FileAccessor - if f.File, err = os.OpenFile(name, flag, perm); err == nil { - store = &f - } - return -} diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/storage/mem.go b/Godeps/_workspace/src/github.com/cznic/fileutil/storage/mem.go deleted file mode 100644 index 7cda0b667e..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/storage/mem.go +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright (c) 2011 CZ.NIC z.s.p.o. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// blame: jnml, labs.nic.cz - -package storage - -import ( - "errors" - "fmt" - "io/ioutil" - "math" - "os" -) - -//TODO -> exported type w/ exported fields -type memaccessor struct { - f *os.File - fi *FileInfo - b []byte -} - -// Implementation of Accessor. -func (m *memaccessor) BeginUpdate() error { return nil } - -// Implementation of Accessor. -func (f *memaccessor) EndUpdate() error { return nil } - -// NewMem returns a new Accessor backed by an os.File. The returned Accessor -// keeps all of the store content in memory. The memory and file images are -// synced only by Sync and Close. Recomended for small amounts of data only -// and content which may be lost on process kill/crash. NewMem return the -// Accessor or an error of any. -// -// NOTE: The returned Accessor implements BeginUpdate and EndUpdate as a no op. -func NewMem(f *os.File) (store Accessor, err error) { - a := &memaccessor{f: f} - if err = f.Truncate(0); err != nil { - return - } - - var fi os.FileInfo - if fi, err = a.f.Stat(); err != nil { - return - } - - a.fi = NewFileInfo(fi, a) - store = a - return -} - -// OpenMem return a new Accessor backed by an os.File. The store content is -// loaded from f. The returned Accessor keeps all of the store content in -// memory. The memory and file images are synced only Sync and Close. -// Recomended for small amounts of data only and content which may be lost on -// process kill/crash. OpenMem return the Accessor or an error of any. -// -// NOTE: The returned Accessor implements BeginUpdate and EndUpdate as a no op. -func OpenMem(f *os.File) (store Accessor, err error) { - a := &memaccessor{f: f} - if a.b, err = ioutil.ReadAll(a.f); err != nil { - a.f.Close() - return - } - - var fi os.FileInfo - if fi, err = a.f.Stat(); err != nil { - a.f.Close() - return - } - - a.fi = NewFileInfo(fi, a) - store = a - return -} - -// Close implements Accessor. Specifically it synchronizes the memory and file images. -func (a *memaccessor) Close() (err error) { - defer func() { - a.b = nil - if a.f != nil { - if e := a.f.Close(); e != nil && err == nil { - err = e - } - } - a.f = nil - }() - - return a.Sync() -} - -func (a *memaccessor) Name() string { - return a.f.Name() -} - -func (a *memaccessor) ReadAt(b []byte, off int64) (n int, err error) { - if off < 0 || off > math.MaxInt32 { - return -1, fmt.Errorf("ReadAt: illegal offset %#x", off) - } - - rq, fp := len(b), int(off) - if fp+rq > len(a.b) { - return -1, fmt.Errorf("ReadAt: illegal rq %#x @ offset %#x, len %#x", rq, fp, len(a.b)) - } - - copy(b, a.b[fp:]) - return -} - -func (a *memaccessor) Stat() (fi os.FileInfo, err error) { - i := a.fi - i.FSize = int64(len(a.b)) - fi = i - return -} - -// Sync implements Accessor. Specifically it synchronizes the memory and file images. -func (a *memaccessor) Sync() (err error) { - var n int - if n, err = a.f.WriteAt(a.b, 0); n != len(a.b) { - return - } - - return a.f.Truncate(int64(len(a.b))) -} - -func (a *memaccessor) Truncate(size int64) (err error) { - defer func() { - if e := recover(); e != nil { - err = e.(error) - } - }() - - if size > math.MaxInt32 { - panic(errors.New("truncate: illegal size")) - } - - a.b = a.b[:int(size)] - return -} - -func (a *memaccessor) WriteAt(b []byte, off int64) (n int, err error) { - if off < 0 || off > math.MaxInt32 { - return -1, errors.New("WriteAt: illegal offset") - } - - rq, fp, size := len(b), int(off), len(a.b) - if need := rq + fp; need > size { - if need <= cap(a.b) { - a.b = a.b[:need] - } else { - nb := make([]byte, need, 2*need) - copy(nb, a.b) - a.b = nb - } - } - - copy(a.b[int(off):], b) - return -} diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/storage/probe.go b/Godeps/_workspace/src/github.com/cznic/fileutil/storage/probe.go deleted file mode 100644 index 53b146a6eb..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/storage/probe.go +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) 2011 CZ.NIC z.s.p.o. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// blame: jnml, labs.nic.cz - -package storage - -import "sync/atomic" - -// Probe collects usage statistics of the embeded Accessor. -// Probe itself IS an Accessor. -type Probe struct { - Accessor - Chain *Probe - OpsRd int64 - OpsWr int64 - BytesRd int64 - BytesWr int64 - SectorsRd int64 // Assuming 512 byte sector size - SectorsWr int64 -} - -// NewProbe returns a newly created probe which embedes the src Accessor. -// The retuned *Probe satisfies Accessor. if chain != nil then Reset() -// is cascaded down the chained Probes. -func NewProbe(src Accessor, chain *Probe) *Probe { - return &Probe{Accessor: src, Chain: chain} -} - -func reset(n *int64) { - atomic.AddInt64(n, -atomic.AddInt64(n, 0)) -} - -// Reset zeroes the collected statistics of p. -func (p *Probe) Reset() { - if p.Chain != nil { - p.Chain.Reset() - } - reset(&p.OpsRd) - reset(&p.OpsWr) - reset(&p.BytesRd) - reset(&p.BytesWr) - reset(&p.SectorsRd) - reset(&p.SectorsWr) -} - -func (p *Probe) ReadAt(b []byte, off int64) (n int, err error) { - n, err = p.Accessor.ReadAt(b, off) - atomic.AddInt64(&p.OpsRd, 1) - atomic.AddInt64(&p.BytesRd, int64(n)) - if n <= 0 { - return - } - - sectorFirst := off >> 9 - sectorLast := (off + int64(n) - 1) >> 9 - atomic.AddInt64(&p.SectorsRd, sectorLast-sectorFirst+1) - return -} - -func (p *Probe) WriteAt(b []byte, off int64) (n int, err error) { - n, err = p.Accessor.WriteAt(b, off) - atomic.AddInt64(&p.OpsWr, 1) - atomic.AddInt64(&p.BytesWr, int64(n)) - if n <= 0 { - return - } - - sectorFirst := off >> 9 - sectorLast := (off + int64(n) - 1) >> 9 - atomic.AddInt64(&p.SectorsWr, sectorLast-sectorFirst+1) - return -} diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/storage/storage.go b/Godeps/_workspace/src/github.com/cznic/fileutil/storage/storage.go deleted file mode 100644 index 4956053a0c..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/storage/storage.go +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright (c) 2011 CZ.NIC z.s.p.o. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// blame: jnml, labs.nic.cz - -// WIP: Package storage defines and implements storage providers and store accessors. -package storage - -import ( - "os" - "sync" - "time" -) - -// FileInfo is a type implementing os.FileInfo which has setable fields, like -// the older os.FileInfo used to have. It is used wehere e.g. the Size is -// needed to be faked (encapsulated/memory only file, file cache, etc.). -type FileInfo struct { - FName string // base name of the file - FSize int64 // length in bytes - FMode os.FileMode // file mode bits - FModTime time.Time // modification time - FIsDir bool // abbreviation for Mode().IsDir() - sys interface{} // underlying data source (can be nil) -} - -// NewFileInfo creates FileInfo from os.FileInfo fi. -func NewFileInfo(fi os.FileInfo, sys interface{}) *FileInfo { - return &FileInfo{fi.Name(), fi.Size(), fi.Mode(), fi.ModTime(), fi.IsDir(), sys} -} - -// Implementation of os.FileInfo -func (fi *FileInfo) Name() string { - return fi.FName -} - -// Implementation of os.FileInfo -func (fi *FileInfo) Size() int64 { - return fi.FSize -} - -// Implementation of os.FileInfo -func (fi *FileInfo) Mode() os.FileMode { - return fi.FMode -} - -// Implementation of os.FileInfo -func (fi *FileInfo) ModTime() time.Time { - return fi.FModTime -} - -// Implementation of os.FileInfo -func (fi *FileInfo) IsDir() bool { - return fi.FIsDir -} - -func (fi *FileInfo) Sys() interface{} { - return fi.sys -} - -// Accessor provides I/O methods to access a store. -type Accessor interface { - - // Close closes the store, rendering it unusable for I/O. It returns an - // error, if any. - Close() error - - // Name returns the name of the file as presented to Open. - Name() string - - // ReadAt reads len(b) bytes from the store starting at byte offset off. - // It returns the number of bytes read and the error, if any. - // EOF is signaled by a zero count with err set to os.EOF. - // ReadAt always returns a non-nil Error when n != len(b). - ReadAt(b []byte, off int64) (n int, err error) - - // Stat returns the FileInfo structure describing the store. It returns - // the os.FileInfo and an error, if any. - Stat() (fi os.FileInfo, err error) - - // Sync commits the current contents of the store to stable storage. - // Typically, this means flushing the file system's in-memory copy of - // recently written data to disk. - Sync() (err error) - - // Truncate changes the size of the store. It does not change the I/O - // offset. - Truncate(size int64) error - - // WriteAt writes len(b) bytes to the store starting at byte offset off. - // It returns the number of bytes written and an error, if any. - // WriteAt returns a non-nil Error when n != len(b). - WriteAt(b []byte, off int64) (n int, err error) - - // Before every [structural] change of a store the BeginUpdate is to be - // called and paired with EndUpdate after the change makes the store's - // state consistent again. Invocations of BeginUpdate may nest. On - // invoking the last non nested EndUpdate an implicit "commit" should - // be performed by the store/provider. The concrete mechanism is - // unspecified. It could be for example a write-ahead log. Stores may - // implement BeginUpdate and EndUpdate as a (documented) no op. - BeginUpdate() error - EndUpdate() error -} - -// Mutate is a helper/wrapper for executing f in between a.BeginUpdate and -// a.EndUpdate. Any parameters and/or return values except an error should be -// captured by a function literal passed as f. The returned err is either nil -// or the first non nil error returned from the sequence of execution: -// BeginUpdate, [f,] EndUpdate. The pair BeginUpdate/EndUpdate *is* invoked -// always regardles of any possible errors produced. Mutate doesn't handle -// panic, it should be used only with a function [literal] which doesn't panic. -// Otherwise the pairing of BeginUpdate/EndUpdate is not guaranteed. -// -// NOTE: If BeginUpdate, which is invoked before f, returns a non-nil error, -// then f is not invoked at all (but EndUpdate still is). -func Mutate(a Accessor, f func() error) (err error) { - defer func() { - if e := a.EndUpdate(); e != nil && err == nil { - err = e - } - }() - - if err = a.BeginUpdate(); err != nil { - return - } - - return f() -} - -// LockedMutate wraps Mutate in yet another layer consisting of a -// l.Lock/l.Unlock pair. All other limitations apply as in Mutate, e.g. no -// panics are allowed to happen - otherwise no guarantees can be made about -// Unlock matching the Lock. -func LockedMutate(a Accessor, l sync.Locker, f func() error) (err error) { - l.Lock() - defer l.Unlock() - - return Mutate(a, f) -} diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/storage/test_deps.go b/Godeps/_workspace/src/github.com/cznic/fileutil/storage/test_deps.go deleted file mode 100644 index 92ac44a5bf..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/storage/test_deps.go +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) 2011 CZ.NIC z.s.p.o. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// blame: jnml, labs.nic.cz - -package storage - -// Pull test dependencies too. -// Enables easy 'go test X' after 'go get X' -import ( -// nothing yet -) diff --git a/Godeps/_workspace/src/github.com/cznic/fileutil/test_deps.go b/Godeps/_workspace/src/github.com/cznic/fileutil/test_deps.go deleted file mode 100644 index eec608ab3a..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/fileutil/test_deps.go +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) 2014 The fileutil Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// blame: jnml, labs.nic.cz - -package fileutil - -// Pull test dependencies too. -// Enables easy 'go test X' after 'go get X' -import ( -// nothing yet -) diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/AUTHORS b/Godeps/_workspace/src/github.com/cznic/mathutil/AUTHORS deleted file mode 100644 index d04c450118..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/AUTHORS +++ /dev/null @@ -1,12 +0,0 @@ -# This file lists authors for copyright purposes. This file is distinct from -# the CONTRIBUTORS files. See the latter for an explanation. -# -# Names should be added to this file as: -# Name or Organization -# -# The email address is not required for organizations. -# -# Please keep the list sorted. - -CZ.NIC z.s.p.o. -Jan Mercl <0xjnml@gmail.com> diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/CONTRIBUTORS b/Godeps/_workspace/src/github.com/cznic/mathutil/CONTRIBUTORS deleted file mode 100644 index 9c9a5dd84c..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/CONTRIBUTORS +++ /dev/null @@ -1,10 +0,0 @@ -# This file lists people who contributed code to this repository. The AUTHORS -# file lists the copyright holders; this file lists people. -# -# Names should be added to this file like so: -# Name -# -# Please keep the list sorted. - -Gary Burd -Jan Mercl <0xjnml@gmail.com> diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/LICENSE b/Godeps/_workspace/src/github.com/cznic/mathutil/LICENSE deleted file mode 100644 index 128a1b64a4..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2014 The mathutil 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 names of the authors nor the names of the -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. diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/Makefile b/Godeps/_workspace/src/github.com/cznic/mathutil/Makefile deleted file mode 100644 index b99ba9adf2..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (c) 2014 The mathutil Authors. All rights reserved. -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file. - -.PHONY: all todo clean nuke - -grep=--include=*.go --include=*.run --include=*.y - -all: editor - go build - go vet || true - golint . - go install - make todo - -clean: - go clean - -editor: - go fmt - go test -i - go test - -todo: - @grep -nr $(grep) ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* * || true - @grep -nr $(grep) TODO * || true - @grep -nr $(grep) BUG * || true - @grep -nr $(grep) println * || true - -nuke: clean - go clean -i diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/README b/Godeps/_workspace/src/github.com/cznic/mathutil/README deleted file mode 100644 index a9ee59c401..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/README +++ /dev/null @@ -1,10 +0,0 @@ -This is a goinstall-able mirror of modified code already published at: -http://git.nic.cz/redmine/projects/gornd/repository - -Packages in this repository: - -Install: $ go get github.com/cznic/mathutil -Godocs: http://godoc.org/github.com/cznic/mathutil - -Install: $ go get github.com/cznic/mathutil/mersenne -Godocs: http://godoc.org/github.com/cznic/mathutil/mersenne diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/bits.go b/Godeps/_workspace/src/github.com/cznic/mathutil/bits.go deleted file mode 100644 index 6eaa4e3054..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/bits.go +++ /dev/null @@ -1,207 +0,0 @@ -// Copyright (c) 2014 The mathutil 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 mathutil - -import ( - "math/big" -) - -// BitLenByte returns the bit width of the non zero part of n. -func BitLenByte(n byte) int { - return log2[n] + 1 -} - -// BitLenUint16 returns the bit width of the non zero part of n. -func BitLenUint16(n uint16) int { - if b := n >> 8; b != 0 { - return log2[b] + 8 + 1 - } - - return log2[n] + 1 -} - -// BitLenUint32 returns the bit width of the non zero part of n. -func BitLenUint32(n uint32) int { - if b := n >> 24; b != 0 { - return log2[b] + 24 + 1 - } - - if b := n >> 16; b != 0 { - return log2[b] + 16 + 1 - } - - if b := n >> 8; b != 0 { - return log2[b] + 8 + 1 - } - - return log2[n] + 1 -} - -// BitLen returns the bit width of the non zero part of n. -func BitLen(n int) int { // Should handle correctly [future] 64 bit Go ints - if IntBits == 64 { - return BitLenUint64(uint64(n)) - } - - if b := byte(n >> 24); b != 0 { - return log2[b] + 24 + 1 - } - - if b := byte(n >> 16); b != 0 { - return log2[b] + 16 + 1 - } - - if b := byte(n >> 8); b != 0 { - return log2[b] + 8 + 1 - } - - return log2[byte(n)] + 1 -} - -// BitLenUint returns the bit width of the non zero part of n. -func BitLenUint(n uint) int { // Should handle correctly [future] 64 bit Go uints - if IntBits == 64 { - return BitLenUint64(uint64(n)) - } - - if b := n >> 24; b != 0 { - return log2[b] + 24 + 1 - } - - if b := n >> 16; b != 0 { - return log2[b] + 16 + 1 - } - - if b := n >> 8; b != 0 { - return log2[b] + 8 + 1 - } - - return log2[n] + 1 -} - -// BitLenUint64 returns the bit width of the non zero part of n. -func BitLenUint64(n uint64) int { - if b := n >> 56; b != 0 { - return log2[b] + 56 + 1 - } - - if b := n >> 48; b != 0 { - return log2[b] + 48 + 1 - } - - if b := n >> 40; b != 0 { - return log2[b] + 40 + 1 - } - - if b := n >> 32; b != 0 { - return log2[b] + 32 + 1 - } - - if b := n >> 24; b != 0 { - return log2[b] + 24 + 1 - } - - if b := n >> 16; b != 0 { - return log2[b] + 16 + 1 - } - - if b := n >> 8; b != 0 { - return log2[b] + 8 + 1 - } - - return log2[n] + 1 -} - -// BitLenUintptr returns the bit width of the non zero part of n. -func BitLenUintptr(n uintptr) int { - if b := n >> 56; b != 0 { - return log2[b] + 56 + 1 - } - - if b := n >> 48; b != 0 { - return log2[b] + 48 + 1 - } - - if b := n >> 40; b != 0 { - return log2[b] + 40 + 1 - } - - if b := n >> 32; b != 0 { - return log2[b] + 32 + 1 - } - - if b := n >> 24; b != 0 { - return log2[b] + 24 + 1 - } - - if b := n >> 16; b != 0 { - return log2[b] + 16 + 1 - } - - if b := n >> 8; b != 0 { - return log2[b] + 8 + 1 - } - - return log2[n] + 1 -} - -// PopCountByte returns population count of n (number of bits set in n). -func PopCountByte(n byte) int { - return int(popcnt[byte(n)]) -} - -// PopCountUint16 returns population count of n (number of bits set in n). -func PopCountUint16(n uint16) int { - return int(popcnt[byte(n>>8)]) + int(popcnt[byte(n)]) -} - -// PopCountUint32 returns population count of n (number of bits set in n). -func PopCountUint32(n uint32) int { - return int(popcnt[byte(n>>24)]) + int(popcnt[byte(n>>16)]) + - int(popcnt[byte(n>>8)]) + int(popcnt[byte(n)]) -} - -// PopCount returns population count of n (number of bits set in n). -func PopCount(n int) int { // Should handle correctly [future] 64 bit Go ints - if IntBits == 64 { - return PopCountUint64(uint64(n)) - } - - return PopCountUint32(uint32(n)) -} - -// PopCountUint returns population count of n (number of bits set in n). -func PopCountUint(n uint) int { // Should handle correctly [future] 64 bit Go uints - if IntBits == 64 { - return PopCountUint64(uint64(n)) - } - - return PopCountUint32(uint32(n)) -} - -// PopCountUintptr returns population count of n (number of bits set in n). -func PopCountUintptr(n uintptr) int { - if UintPtrBits == 64 { - return PopCountUint64(uint64(n)) - } - - return PopCountUint32(uint32(n)) -} - -// PopCountUint64 returns population count of n (number of bits set in n). -func PopCountUint64(n uint64) int { - return int(popcnt[byte(n>>56)]) + int(popcnt[byte(n>>48)]) + - int(popcnt[byte(n>>40)]) + int(popcnt[byte(n>>32)]) + - int(popcnt[byte(n>>24)]) + int(popcnt[byte(n>>16)]) + - int(popcnt[byte(n>>8)]) + int(popcnt[byte(n)]) -} - -// PopCountBigInt returns population count of |n| (number of bits set in |n|). -func PopCountBigInt(n *big.Int) (r int) { - for _, v := range n.Bits() { - r += PopCountUintptr(uintptr(v)) - } - return -} diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/envelope.go b/Godeps/_workspace/src/github.com/cznic/mathutil/envelope.go deleted file mode 100644 index ff8e6012a6..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/envelope.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) 2014 The mathutil 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 mathutil - -import ( - "math" -) - -// Approximation type determines approximation methods used by e.g. Envelope. -type Approximation int - -// Specific approximation method tags -const ( - _ Approximation = iota - Linear // As named - Sinusoidal // Smooth for all derivations -) - -// Envelope is an utility for defining simple curves using a small (usually) -// set of data points. Envelope returns a value defined by x, points and -// approximation. The value of x must be in [0,1) otherwise the result is -// undefined or the function may panic. Points are interpreted as dividing the -// [0,1) interval in len(points)-1 sections, so len(points) must be > 1 or the -// function may panic. According to the left and right points closing/adjacent -// to the section the resulting value is interpolated using the chosen -// approximation method. Unsupported values of approximation are silently -// interpreted as 'Linear'. -func Envelope(x float64, points []float64, approximation Approximation) float64 { - step := 1 / float64(len(points)-1) - fslot := math.Floor(x / step) - mod := x - fslot*step - slot := int(fslot) - l, r := points[slot], points[slot+1] - rmod := mod / step - switch approximation { - case Sinusoidal: - k := (math.Sin(math.Pi*(rmod-0.5)) + 1) / 2 - return l + (r-l)*k - case Linear: - fallthrough - default: - return l + (r-l)*rmod - } -} diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/example/.gitignore b/Godeps/_workspace/src/github.com/cznic/mathutil/example/.gitignore deleted file mode 100644 index ae251f36fc..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/example/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -example -Makefile diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/example/example.go b/Godeps/_workspace/src/github.com/cznic/mathutil/example/example.go deleted file mode 100644 index 30a2d11580..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/example/example.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) 2011 CZ.NIC z.s.p.o. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// blame: jnml, labs.nic.cz - -// +build ignore - -package main - -import ( - "bufio" - "flag" - "github.com/cznic/mathutil" - "log" - "math" - "os" -) - -/* - -$ # Usage e.g.: -$ go run example.go -max 1024 > mathutil.dat # generate 1kB of "random" data - -*/ -func main() { - r, err := mathutil.NewFC32(math.MinInt32, math.MaxInt32, true) - if err != nil { - log.Fatal(err) - } - - var mflag uint64 - flag.Uint64Var(&mflag, "max", 0, "limit output to max bytes") - flag.Parse() - stdout := bufio.NewWriter(os.Stdout) - if mflag != 0 { - for i := uint64(0); i < mflag; i++ { - if err := stdout.WriteByte(byte(r.Next())); err != nil { - log.Fatal(err) - } - } - stdout.Flush() - return - } - - for stdout.WriteByte(byte(r.Next())) == nil { - } -} diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/example2/.gitignore b/Godeps/_workspace/src/github.com/cznic/mathutil/example2/.gitignore deleted file mode 100644 index 85c399941f..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/example2/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -example2 -Makefile diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/example2/example2.go b/Godeps/_workspace/src/github.com/cznic/mathutil/example2/example2.go deleted file mode 100644 index 409aeef3e2..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/example2/example2.go +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2011 CZ.NIC z.s.p.o. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// blame: jnml, labs.nic.cz - -// +build ignore - -package main - -import ( - "bytes" - "github.com/cznic/mathutil" - "image" - "image/png" - "io/ioutil" - "log" - "math" - "math/rand" -) - -// $ go run example2.go # view rand.png and rnd.png by your favorite pic viewer -// -// see http://www.boallen.com/random-numbers.html -func main() { - sqr := image.Rect(0, 0, 511, 511) - r, err := mathutil.NewFC32(math.MinInt32, math.MaxInt32, true) - if err != nil { - log.Fatal("NewFC32", err) - } - - img := image.NewGray(sqr) - for y := 0; y < 512; y++ { - for x := 0; x < 512; x++ { - if r.Next()&1 != 0 { - img.Set(x, y, image.White) - } - } - } - buf := bytes.NewBuffer(nil) - if err := png.Encode(buf, img); err != nil { - log.Fatal("Encode rnd.png ", err) - } - - if err := ioutil.WriteFile("rnd.png", buf.Bytes(), 0666); err != nil { - log.Fatal("ioutil.WriteFile/rnd.png ", err) - } - - r2 := rand.New(rand.NewSource(0)) - img = image.NewGray(sqr) - for y := 0; y < 512; y++ { - for x := 0; x < 512; x++ { - if r2.Int()&1 != 0 { - img.Set(x, y, image.White) - } - } - } - buf = bytes.NewBuffer(nil) - if err := png.Encode(buf, img); err != nil { - log.Fatal("Encode rand.png ", err) - } - - if err := ioutil.WriteFile("rand.png", buf.Bytes(), 0666); err != nil { - log.Fatal("ioutil.WriteFile/rand.png ", err) - } -} diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/example3/.gitignore b/Godeps/_workspace/src/github.com/cznic/mathutil/example3/.gitignore deleted file mode 100644 index 474f23a049..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/example3/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -example3 -Makefile diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/example3/example3.go b/Godeps/_workspace/src/github.com/cznic/mathutil/example3/example3.go deleted file mode 100644 index 572d108b61..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/example3/example3.go +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2011 CZ.NIC z.s.p.o. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// blame: jnml, labs.nic.cz - -// +build ignore - -package main - -import ( - "bufio" - "flag" - "log" - "math/rand" - "os" -) - -/* - -$ # Usage e.g.: -$ go run example3.go -max 1024 > rand.dat # generate 1kB of "random" data - -*/ -func main() { - r := rand.New(rand.NewSource(1)) - var mflag uint64 - flag.Uint64Var(&mflag, "max", 0, "limit output to max bytes") - flag.Parse() - stdout := bufio.NewWriter(os.Stdout) - if mflag != 0 { - for i := uint64(0); i < mflag; i++ { - if err := stdout.WriteByte(byte(r.Int())); err != nil { - log.Fatal(err) - } - } - stdout.Flush() - return - } - - for stdout.WriteByte(byte(r.Int())) == nil { - } -} diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/example4/main.go b/Godeps/_workspace/src/github.com/cznic/mathutil/example4/main.go deleted file mode 100644 index 52b35655ce..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/example4/main.go +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) 2011 jnml. 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 - -// Let QRN be the number of quadratic residues of N. Let Q be QRN/N. From a -// sorted list of primorial products < 2^32 find "record breakers". "Record -// breaker" is N with new lowest Q. -// -// There are only 49 "record breakers" < 2^32. -// -// To run the example $ go run main.go -package main - -import ( - "fmt" - "math" - "sort" - "time" - - "github.com/cznic/mathutil" - "github.com/cznic/sortutil" -) - -func main() { - pp := mathutil.PrimorialProductsUint32(0, math.MaxUint32, 32) - sort.Sort(sortutil.Uint32Slice(pp)) - var bestN, bestD uint32 = 1, 1 - order, checks := 0, 0 - var ixDirty uint32 - m := make([]byte, math.MaxUint32>>3) - for _, n := range pp { - for i := range m[:ixDirty+1] { - m[i] = 0 - } - ixDirty = 0 - checks++ - limit0 := mathutil.QScaleUint32(n, bestN, bestD) - if limit0 > math.MaxUint32 { - panic(0) - } - limit := uint32(limit0) - n64 := uint64(n) - hi := n64 >> 1 - hits := uint32(0) - check := true - fmt.Printf("\r%10d %d/%d", n, checks, len(pp)) - t0 := time.Now() - for i := uint64(0); i < hi; i++ { - sq := uint32(i * i % n64) - ix := sq >> 3 - msk := byte(1 << (sq & 7)) - if m[ix]&msk == 0 { - hits++ - if hits >= limit { - check = false - break - } - } - m[ix] |= msk - if ix > ixDirty { - ixDirty = ix - } - } - - adjPrime := ".." // Composite before - if mathutil.IsPrime(n - 1) { - adjPrime = "P." // Prime before - } - switch mathutil.IsPrime(n + 1) { - case true: - adjPrime += "P" // Prime after - case false: - adjPrime += "." // Composite after - } - - if check && mathutil.QCmpUint32(hits, n, bestN, bestD) < 0 { - order++ - d := time.Since(t0) - bestN, bestD = hits, n - q := float64(hits) / float64(n) - fmt.Printf( - "\r%2s #%03d %d %d %.2f %.2E %s %s %v\n", - adjPrime, order, n, hits, - 1/q, q, d, time.Now().Format("15:04:05"), mathutil.FactorInt(n), - ) - } - } -} diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/example4/results b/Godeps/_workspace/src/github.com/cznic/mathutil/example4/results deleted file mode 100644 index 1642c9d85c..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/example4/results +++ /dev/null @@ -1,55 +0,0 @@ -$ time go run main.go -..P #001 2 1 2.00 5.00E-01 3us 11:13:37 -P.. #002 8 3 2.67 3.75E-01 1us 11:13:37 -P.P #003 12 4 3.00 3.33E-01 1us 11:13:37 -..P #004 16 4 4.00 2.50E-01 1us 11:13:37 -P.. #005 32 7 4.57 2.19E-01 1us 11:13:37 -P.. #006 48 8 6.00 1.67E-01 1us 11:13:37 -..P #007 96 14 6.86 1.46E-01 2us 11:13:37 -... #008 144 16 9.00 1.11E-01 2us 11:13:37 -P.P #009 240 24 10.00 1.00E-01 3us 11:13:37 -... #010 288 28 10.29 9.72E-02 4us 11:13:37 -P.. #011 480 42 11.43 8.75E-02 6us 11:13:37 -..P #012 576 48 12.00 8.33E-02 7us 11:13:37 -P.. #013 720 48 15.00 6.67E-02 8us 11:13:37 -P.. #014 1440 84 17.14 5.83E-02 15us 11:13:37 -... #015 1680 96 17.50 5.71E-02 17us 11:13:37 -P.. #016 2880 144 20.00 5.00E-02 28us 11:13:37 -... #017 3600 176 20.45 4.89E-02 35us 11:13:37 -P.. #018 5040 192 26.25 3.81E-02 50us 11:13:37 -P.. #019 10080 336 30.00 3.33E-02 96us 11:13:37 -..P #020 18480 576 32.08 3.12E-02 174us 11:13:37 -..P #021 20160 576 35.00 2.86E-02 190us 11:13:37 -... #022 25200 704 35.80 2.79E-02 237us 11:13:37 -... #023 36960 1008 36.67 2.73E-02 348us 11:13:37 -... #024 50400 1232 40.91 2.44E-02 473us 11:13:37 -P.P #025 55440 1152 48.12 2.08E-02 518us 11:13:37 -P.P #026 110880 2016 55.00 1.82E-02 1.039ms 11:13:37 -... #027 221760 3456 64.17 1.56E-02 2.056ms 11:13:37 -... #028 277200 4224 65.62 1.52E-02 2.82ms 11:13:37 -... #029 443520 6624 66.96 1.49E-02 4.179ms 11:13:37 -... #030 480480 7056 68.10 1.47E-02 4.536ms 11:13:37 -... #031 554400 7392 75.00 1.33E-02 5.217ms 11:13:37 -... #032 720720 8064 89.38 1.12E-02 6.919ms 11:13:37 -P.. #033 1441440 14112 102.14 9.79E-03 14.767ms 11:13:38 -... #034 2882880 24192 119.17 8.39E-03 28.661ms 11:13:38 -... #035 3603600 29568 121.88 8.21E-03 35.55ms 11:13:38 -... #036 5765760 46368 124.35 8.04E-03 57.798ms 11:13:38 -... #037 7207200 51744 139.29 7.18E-03 75.157ms 11:13:38 -... #038 12252240 72576 168.82 5.92E-03 147.179ms 11:13:38 -P.. #039 24504480 127008 192.94 5.18E-03 507.174ms 11:13:40 -... #040 49008960 217728 225.09 4.44E-03 1.334847s 11:13:43 -P.. #041 61261200 266112 230.21 4.34E-03 1.739597s 11:13:45 -... #042 98017920 417312 234.88 4.26E-03 2.971988s 11:13:51 -... #043 122522400 465696 263.10 3.80E-03 3.767685s 11:13:57 -P.P #044 232792560 725760 320.76 3.12E-03 7.425308s 11:14:15 -P.. #045 465585120 1270080 366.58 2.73E-03 15.18066s 11:14:50 -P.. #046 931170240 2177280 427.68 2.34E-03 34.22548s 11:16:06 -..P #047 1163962800 2661120 437.40 2.29E-03 45.038331s 11:17:10 -..P #048 1862340480 4173120 446.27 2.24E-03 1m10.288676s 11:19:26 -... #049 2327925600 4656960 499.88 2.00E-03 1m31.882756s 11:21:44 -4257792000 1679/1679 -real 11m36.548s -user 11m30.530s -sys 0m1.700s -$ diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/ff/main.go b/Godeps/_workspace/src/github.com/cznic/mathutil/ff/main.go deleted file mode 100644 index 6cec57afb8..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/ff/main.go +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) jnml. 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 - -// Factor Finder - searches for Mersenne number factors of one specific special -// form. -package main - -import ( - "flag" - "fmt" - "math/big" - "runtime" - "time" - - "github.com/cznic/mathutil" -) - -const ( - pp = 1 - pp2 = 10 -) - -var ( - _1 = big.NewInt(1) - _2 = big.NewInt(2) -) - -func main() { - runtime.GOMAXPROCS(2) - oClass := flag.Uint64("c", 2, `factor "class" number`) - oDuration := flag.Duration("d", time.Second, "duration to spend on one class") - flag.Parse() - class := *oClass - for class&1 != 0 { - class >>= 1 - } - class = mathutil.MaxUint64(class, 2) - - for { - c := time.After(*oDuration) - factor := big.NewInt(0) - factor.SetUint64(class) - exp := big.NewInt(0) - oneClass: - for { - select { - case <-c: - break oneClass - default: - } - - exp.Set(factor) - factor.Lsh(factor, 1) - factor.Add(factor, _1) - if !factor.ProbablyPrime(pp) { - continue - } - - if !exp.ProbablyPrime(pp) { - continue - } - - if mathutil.ModPowBigInt(_2, exp, factor).Cmp(_1) != 0 { - continue - } - - if !factor.ProbablyPrime(pp2) { - continue - } - - if !exp.ProbablyPrime(pp2) { - continue - } - - fmt.Printf("%d: %s | M%s (%d bits)\n", class, factor, exp, factor.BitLen()) - } - - class += 2 - } -} diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/mathutil.go b/Godeps/_workspace/src/github.com/cznic/mathutil/mathutil.go deleted file mode 100644 index e8f3f5622c..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/mathutil.go +++ /dev/null @@ -1,829 +0,0 @@ -// Copyright (c) 2014 The mathutil 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 mathutil provides utilities supplementing the standard 'math' and -// 'math/rand' packages. -// -// Compatibility issues -// -// 2013-12-13: The following functions have been REMOVED -// -// func Uint64ToBigInt(n uint64) *big.Int -// func Uint64FromBigInt(n *big.Int) (uint64, bool) -// -// 2013-05-13: The following functions are now DEPRECATED -// -// func Uint64ToBigInt(n uint64) *big.Int -// func Uint64FromBigInt(n *big.Int) (uint64, bool) -// -// These functions will be REMOVED with Go release 1.1+1. -// -// 2013-01-21: The following functions have been REMOVED -// -// func MaxInt() int -// func MinInt() int -// func MaxUint() uint -// func UintPtrBits() int -// -// They are now replaced by untyped constants -// -// MaxInt -// MinInt -// MaxUint -// UintPtrBits -// -// Additionally one more untyped constant was added -// -// IntBits -// -// This change breaks any existing code depending on the above removed -// functions. They should have not been published in the first place, that was -// unfortunate. Instead, defining such architecture and/or implementation -// specific integer limits and bit widths as untyped constants improves -// performance and allows for static dead code elimination if it depends on -// these values. Thanks to minux for pointing it out in the mail list -// (https://groups.google.com/d/msg/golang-nuts/tlPpLW6aJw8/NT3mpToH-a4J). -// -// 2012-12-12: The following functions will be DEPRECATED with Go release -// 1.0.3+1 and REMOVED with Go release 1.0.3+2, b/c of -// http://code.google.com/p/go/source/detail?r=954a79ee3ea8 -// -// func Uint64ToBigInt(n uint64) *big.Int -// func Uint64FromBigInt(n *big.Int) (uint64, bool) -package mathutil - -import ( - "math" - "math/big" -) - -// Architecture and/or implementation specific integer limits and bit widths. -const ( - MaxInt = 1<<(IntBits-1) - 1 - MinInt = -MaxInt - 1 - MaxUint = 1<>32&1 + ^uint(0)>>16&1 + ^uint(0)>>8&1 + 3) - UintPtrBits = 1 << (^uintptr(0)>>32&1 + ^uintptr(0)>>16&1 + ^uintptr(0)>>8&1 + 3) -) - -var ( - _1 = big.NewInt(1) - _2 = big.NewInt(2) -) - -// GCDByte returns the greatest common divisor of a and b. Based on: -// http://en.wikipedia.org/wiki/Euclidean_algorithm#Implementations -func GCDByte(a, b byte) byte { - for b != 0 { - a, b = b, a%b - } - return a -} - -// GCDUint16 returns the greatest common divisor of a and b. -func GCDUint16(a, b uint16) uint16 { - for b != 0 { - a, b = b, a%b - } - return a -} - -// GCD returns the greatest common divisor of a and b. -func GCDUint32(a, b uint32) uint32 { - for b != 0 { - a, b = b, a%b - } - return a -} - -// GCD64 returns the greatest common divisor of a and b. -func GCDUint64(a, b uint64) uint64 { - for b != 0 { - a, b = b, a%b - } - return a -} - -// ISqrt returns floor(sqrt(n)). Typical run time is few hundreds of ns. -func ISqrt(n uint32) (x uint32) { - if n == 0 { - return - } - - if n >= math.MaxUint16*math.MaxUint16 { - return math.MaxUint16 - } - - var px, nx uint32 - for x = n; ; px, x = x, nx { - nx = (x + n/x) / 2 - if nx == x || nx == px { - break - } - } - return -} - -// SqrtUint64 returns floor(sqrt(n)). Typical run time is about 0.5 µs. -func SqrtUint64(n uint64) (x uint64) { - if n == 0 { - return - } - - if n >= math.MaxUint32*math.MaxUint32 { - return math.MaxUint32 - } - - var px, nx uint64 - for x = n; ; px, x = x, nx { - nx = (x + n/x) / 2 - if nx == x || nx == px { - break - } - } - return -} - -// SqrtBig returns floor(sqrt(n)). It panics on n < 0. -func SqrtBig(n *big.Int) (x *big.Int) { - switch n.Sign() { - case -1: - panic(-1) - case 0: - return big.NewInt(0) - } - - var px, nx big.Int - x = big.NewInt(0) - x.SetBit(x, n.BitLen()/2+1, 1) - for { - nx.Rsh(nx.Add(x, nx.Div(n, x)), 1) - if nx.Cmp(x) == 0 || nx.Cmp(&px) == 0 { - break - } - px.Set(x) - x.Set(&nx) - } - return -} - -// Log2Byte returns log base 2 of n. It's the same as index of the highest -// bit set in n. For n == 0 -1 is returned. -func Log2Byte(n byte) int { - return log2[n] -} - -// Log2Uint16 returns log base 2 of n. It's the same as index of the highest -// bit set in n. For n == 0 -1 is returned. -func Log2Uint16(n uint16) int { - if b := n >> 8; b != 0 { - return log2[b] + 8 - } - - return log2[n] -} - -// Log2Uint32 returns log base 2 of n. It's the same as index of the highest -// bit set in n. For n == 0 -1 is returned. -func Log2Uint32(n uint32) int { - if b := n >> 24; b != 0 { - return log2[b] + 24 - } - - if b := n >> 16; b != 0 { - return log2[b] + 16 - } - - if b := n >> 8; b != 0 { - return log2[b] + 8 - } - - return log2[n] -} - -// Log2Uint64 returns log base 2 of n. It's the same as index of the highest -// bit set in n. For n == 0 -1 is returned. -func Log2Uint64(n uint64) int { - if b := n >> 56; b != 0 { - return log2[b] + 56 - } - - if b := n >> 48; b != 0 { - return log2[b] + 48 - } - - if b := n >> 40; b != 0 { - return log2[b] + 40 - } - - if b := n >> 32; b != 0 { - return log2[b] + 32 - } - - if b := n >> 24; b != 0 { - return log2[b] + 24 - } - - if b := n >> 16; b != 0 { - return log2[b] + 16 - } - - if b := n >> 8; b != 0 { - return log2[b] + 8 - } - - return log2[n] -} - -// ModPowByte computes (b^e)%m. It panics for m == 0 || b == e == 0. -// -// See also: http://en.wikipedia.org/wiki/Modular_exponentiation#Right-to-left_binary_method -func ModPowByte(b, e, m byte) byte { - if b == 0 && e == 0 { - panic(0) - } - - if m == 1 { - return 0 - } - - r := uint16(1) - for b, m := uint16(b), uint16(m); e > 0; b, e = b*b%m, e>>1 { - if e&1 == 1 { - r = r * b % m - } - } - return byte(r) -} - -// ModPowByte computes (b^e)%m. It panics for m == 0 || b == e == 0. -func ModPowUint16(b, e, m uint16) uint16 { - if b == 0 && e == 0 { - panic(0) - } - - if m == 1 { - return 0 - } - - r := uint32(1) - for b, m := uint32(b), uint32(m); e > 0; b, e = b*b%m, e>>1 { - if e&1 == 1 { - r = r * b % m - } - } - return uint16(r) -} - -// ModPowUint32 computes (b^e)%m. It panics for m == 0 || b == e == 0. -func ModPowUint32(b, e, m uint32) uint32 { - if b == 0 && e == 0 { - panic(0) - } - - if m == 1 { - return 0 - } - - r := uint64(1) - for b, m := uint64(b), uint64(m); e > 0; b, e = b*b%m, e>>1 { - if e&1 == 1 { - r = r * b % m - } - } - return uint32(r) -} - -// ModPowUint64 computes (b^e)%m. It panics for m == 0 || b == e == 0. -func ModPowUint64(b, e, m uint64) (r uint64) { - if b == 0 && e == 0 { - panic(0) - } - - if m == 1 { - return 0 - } - - return modPowBigInt(big.NewInt(0).SetUint64(b), big.NewInt(0).SetUint64(e), big.NewInt(0).SetUint64(m)).Uint64() -} - -func modPowBigInt(b, e, m *big.Int) (r *big.Int) { - r = big.NewInt(1) - for i, n := 0, e.BitLen(); i < n; i++ { - if e.Bit(i) != 0 { - r.Mod(r.Mul(r, b), m) - } - b.Mod(b.Mul(b, b), m) - } - return -} - -// ModPowBigInt computes (b^e)%m. Returns nil for e < 0. It panics for m == 0 || b == e == 0. -func ModPowBigInt(b, e, m *big.Int) (r *big.Int) { - if b.Sign() == 0 && e.Sign() == 0 { - panic(0) - } - - if m.Cmp(_1) == 0 { - return big.NewInt(0) - } - - if e.Sign() < 0 { - return - } - - return modPowBigInt(big.NewInt(0).Set(b), big.NewInt(0).Set(e), m) -} - -var uint64ToBigIntDelta big.Int - -func init() { - uint64ToBigIntDelta.SetBit(&uint64ToBigIntDelta, 63, 1) -} - -var uintptrBits int - -func init() { - x := uint64(math.MaxUint64) - uintptrBits = BitLenUintptr(uintptr(x)) -} - -// UintptrBits returns the bit width of an uintptr at the executing machine. -func UintptrBits() int { - return uintptrBits -} - -// AddUint128_64 returns the uint128 sum of uint64 a and b. -func AddUint128_64(a, b uint64) (hi uint64, lo uint64) { - lo = a + b - if lo < a { - hi = 1 - } - return -} - -// MulUint128_64 returns the uint128 bit product of uint64 a and b. -func MulUint128_64(a, b uint64) (hi, lo uint64) { - /* - 2^(2 W) ahi bhi + 2^W alo bhi + 2^W ahi blo + alo blo - - FEDCBA98 76543210 FEDCBA98 76543210 - ---- alo*blo ---- - ---- alo*bhi ---- - ---- ahi*blo ---- - ---- ahi*bhi ---- - */ - const w = 32 - const m = 1<>w, b>>w, a&m, b&m - lo = alo * blo - mid1 := alo * bhi - mid2 := ahi * blo - c1, lo := AddUint128_64(lo, mid1<>w+mid2>>w+uint64(c1+c2)) - return -} - -// PowerizeBigInt returns (e, p) such that e is the smallest number for which p -// == b^e is greater or equal n. For n < 0 or b < 2 (0, nil) is returned. -// -// NOTE: Run time for large values of n (above about 2^1e6 ~= 1e300000) can be -// significant and/or unacceptabe. For any smaller values of n the function -// typically performs in sub second time. For "small" values of n (cca bellow -// 2^1e3 ~= 1e300) the same can be easily below 10 µs. -// -// A special (and trivial) case of b == 2 is handled separately and performs -// much faster. -func PowerizeBigInt(b, n *big.Int) (e uint32, p *big.Int) { - switch { - case b.Cmp(_2) < 0 || n.Sign() < 0: - return - case n.Sign() == 0 || n.Cmp(_1) == 0: - return 0, big.NewInt(1) - case b.Cmp(_2) == 0: - p = big.NewInt(0) - e = uint32(n.BitLen() - 1) - p.SetBit(p, int(e), 1) - if p.Cmp(n) < 0 { - p.Mul(p, _2) - e++ - } - return - } - - bw := b.BitLen() - nw := n.BitLen() - p = big.NewInt(1) - var bb, r big.Int - for { - switch p.Cmp(n) { - case -1: - x := uint32((nw - p.BitLen()) / bw) - if x == 0 { - x = 1 - } - e += x - switch x { - case 1: - p.Mul(p, b) - default: - r.Set(_1) - bb.Set(b) - e := x - for { - if e&1 != 0 { - r.Mul(&r, &bb) - } - if e >>= 1; e == 0 { - break - } - - bb.Mul(&bb, &bb) - } - p.Mul(p, &r) - } - case 0, 1: - return - } - } -} - -// PowerizeUint32BigInt returns (e, p) such that e is the smallest number for -// which p == b^e is greater or equal n. For n < 0 or b < 2 (0, nil) is -// returned. -// -// More info: see PowerizeBigInt. -func PowerizeUint32BigInt(b uint32, n *big.Int) (e uint32, p *big.Int) { - switch { - case b < 2 || n.Sign() < 0: - return - case n.Sign() == 0 || n.Cmp(_1) == 0: - return 0, big.NewInt(1) - case b == 2: - p = big.NewInt(0) - e = uint32(n.BitLen() - 1) - p.SetBit(p, int(e), 1) - if p.Cmp(n) < 0 { - p.Mul(p, _2) - e++ - } - return - } - - var bb big.Int - bb.SetInt64(int64(b)) - return PowerizeBigInt(&bb, n) -} - -/* -ProbablyPrimeUint32 returns true if n is prime or n is a pseudoprime to base a. -It implements the Miller-Rabin primality test for one specific value of 'a' and -k == 1. - -Wrt pseudocode shown at -http://en.wikipedia.org/wiki/Miller-Rabin_primality_test#Algorithm_and_running_time - - Input: n > 3, an odd integer to be tested for primality; - Input: k, a parameter that determines the accuracy of the test - Output: composite if n is composite, otherwise probably prime - write n − 1 as 2^s·d with d odd by factoring powers of 2 from n − 1 - LOOP: repeat k times: - pick a random integer a in the range [2, n − 2] - x ← a^d mod n - if x = 1 or x = n − 1 then do next LOOP - for r = 1 .. s − 1 - x ← x^2 mod n - if x = 1 then return composite - if x = n − 1 then do next LOOP - return composite - return probably prime - -... this function behaves like passing 1 for 'k' and additionaly a -fixed/non-random 'a'. Otherwise it's the same algorithm. - -See also: http://mathworld.wolfram.com/Rabin-MillerStrongPseudoprimeTest.html -*/ -func ProbablyPrimeUint32(n, a uint32) bool { - d, s := n-1, 0 - for ; d&1 == 0; d, s = d>>1, s+1 { - } - x := uint64(ModPowUint32(a, d, n)) - if x == 1 || uint32(x) == n-1 { - return true - } - - for ; s > 1; s-- { - if x = x * x % uint64(n); x == 1 { - return false - } - - if uint32(x) == n-1 { - return true - } - } - return false -} - -// ProbablyPrimeUint64_32 returns true if n is prime or n is a pseudoprime to -// base a. It implements the Miller-Rabin primality test for one specific value -// of 'a' and k == 1. See also ProbablyPrimeUint32. -func ProbablyPrimeUint64_32(n uint64, a uint32) bool { - d, s := n-1, 0 - for ; d&1 == 0; d, s = d>>1, s+1 { - } - x := ModPowUint64(uint64(a), d, n) - if x == 1 || x == n-1 { - return true - } - - bx, bn := big.NewInt(0).SetUint64(x), big.NewInt(0).SetUint64(n) - for ; s > 1; s-- { - if x = bx.Mod(bx.Mul(bx, bx), bn).Uint64(); x == 1 { - return false - } - - if x == n-1 { - return true - } - } - return false -} - -// ProbablyPrimeBigInt_32 returns true if n is prime or n is a pseudoprime to -// base a. It implements the Miller-Rabin primality test for one specific value -// of 'a' and k == 1. See also ProbablyPrimeUint32. -func ProbablyPrimeBigInt_32(n *big.Int, a uint32) bool { - var d big.Int - d.Set(n) - d.Sub(&d, _1) // d <- n-1 - s := 0 - for ; d.Bit(s) == 0; s++ { - } - nMinus1 := big.NewInt(0).Set(&d) - d.Rsh(&d, uint(s)) - - x := ModPowBigInt(big.NewInt(int64(a)), &d, n) - if x.Cmp(_1) == 0 || x.Cmp(nMinus1) == 0 { - return true - } - - for ; s > 1; s-- { - if x = x.Mod(x.Mul(x, x), n); x.Cmp(_1) == 0 { - return false - } - - if x.Cmp(nMinus1) == 0 { - return true - } - } - return false -} - -// ProbablyPrimeBigInt returns true if n is prime or n is a pseudoprime to base -// a. It implements the Miller-Rabin primality test for one specific value of -// 'a' and k == 1. See also ProbablyPrimeUint32. -func ProbablyPrimeBigInt(n, a *big.Int) bool { - var d big.Int - d.Set(n) - d.Sub(&d, _1) // d <- n-1 - s := 0 - for ; d.Bit(s) == 0; s++ { - } - nMinus1 := big.NewInt(0).Set(&d) - d.Rsh(&d, uint(s)) - - x := ModPowBigInt(a, &d, n) - if x.Cmp(_1) == 0 || x.Cmp(nMinus1) == 0 { - return true - } - - for ; s > 1; s-- { - if x = x.Mod(x.Mul(x, x), n); x.Cmp(_1) == 0 { - return false - } - - if x.Cmp(nMinus1) == 0 { - return true - } - } - return false -} - -// Max returns the larger of a and b. -func Max(a, b int) int { - if a > b { - return a - } - - return b -} - -// Min returns the smaller of a and b. -func Min(a, b int) int { - if a < b { - return a - } - - return b -} - -// UMax returns the larger of a and b. -func UMax(a, b uint) uint { - if a > b { - return a - } - - return b -} - -// UMin returns the smaller of a and b. -func UMin(a, b uint) uint { - if a < b { - return a - } - - return b -} - -// MaxByte returns the larger of a and b. -func MaxByte(a, b byte) byte { - if a > b { - return a - } - - return b -} - -// MinByte returns the smaller of a and b. -func MinByte(a, b byte) byte { - if a < b { - return a - } - - return b -} - -// MaxInt8 returns the larger of a and b. -func MaxInt8(a, b int8) int8 { - if a > b { - return a - } - - return b -} - -// MinInt8 returns the smaller of a and b. -func MinInt8(a, b int8) int8 { - if a < b { - return a - } - - return b -} - -// MaxUint16 returns the larger of a and b. -func MaxUint16(a, b uint16) uint16 { - if a > b { - return a - } - - return b -} - -// MinUint16 returns the smaller of a and b. -func MinUint16(a, b uint16) uint16 { - if a < b { - return a - } - - return b -} - -// MaxInt16 returns the larger of a and b. -func MaxInt16(a, b int16) int16 { - if a > b { - return a - } - - return b -} - -// MinInt16 returns the smaller of a and b. -func MinInt16(a, b int16) int16 { - if a < b { - return a - } - - return b -} - -// MaxUint32 returns the larger of a and b. -func MaxUint32(a, b uint32) uint32 { - if a > b { - return a - } - - return b -} - -// MinUint32 returns the smaller of a and b. -func MinUint32(a, b uint32) uint32 { - if a < b { - return a - } - - return b -} - -// MaxInt32 returns the larger of a and b. -func MaxInt32(a, b int32) int32 { - if a > b { - return a - } - - return b -} - -// MinInt32 returns the smaller of a and b. -func MinInt32(a, b int32) int32 { - if a < b { - return a - } - - return b -} - -// MaxUint64 returns the larger of a and b. -func MaxUint64(a, b uint64) uint64 { - if a > b { - return a - } - - return b -} - -// MinUint64 returns the smaller of a and b. -func MinUint64(a, b uint64) uint64 { - if a < b { - return a - } - - return b -} - -// MaxInt64 returns the larger of a and b. -func MaxInt64(a, b int64) int64 { - if a > b { - return a - } - - return b -} - -// MinInt64 returns the smaller of a and b. -func MinInt64(a, b int64) int64 { - if a < b { - return a - } - - return b -} - -// ToBase produces n in base b. For example -// -// ToBase(2047, 22) -> [1, 5, 4] -// -// 1 * 22^0 1 -// 5 * 22^1 110 -// 4 * 22^2 1936 -// ---- -// 2047 -// -// ToBase panics for bases < 2. -func ToBase(n *big.Int, b int) []int { - var nn big.Int - nn.Set(n) - if b < 2 { - panic("invalid base") - } - - k := 1 - switch nn.Sign() { - case -1: - nn.Neg(&nn) - k = -1 - case 0: - return []int{0} - } - - bb := big.NewInt(int64(b)) - var r []int - rem := big.NewInt(0) - for nn.Sign() != 0 { - nn.QuoRem(&nn, bb, rem) - r = append(r, k*int(rem.Int64())) - } - return r -} diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/mersenne/AUTHORS b/Godeps/_workspace/src/github.com/cznic/mathutil/mersenne/AUTHORS deleted file mode 100644 index 0078f5f5b6..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/mersenne/AUTHORS +++ /dev/null @@ -1,11 +0,0 @@ -# This file lists authors for copyright purposes. This file is distinct from -# the CONTRIBUTORS files. See the latter for an explanation. -# -# Names should be added to this file as: -# Name or Organization -# -# The email address is not required for organizations. -# -# Please keep the list sorted. - -Jan Mercl <0xjnml@gmail.com> diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/mersenne/CONTRIBUTORS b/Godeps/_workspace/src/github.com/cznic/mathutil/mersenne/CONTRIBUTORS deleted file mode 100644 index 5e86f0607c..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/mersenne/CONTRIBUTORS +++ /dev/null @@ -1,9 +0,0 @@ -# This file lists people who contributed code to this repository. The AUTHORS -# file lists the copyright holders; this file lists people. -# -# Names should be added to this file like so: -# Name -# -# Please keep the list sorted. - -Jan Mercl <0xjnml@gmail.com> diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/mersenne/LICENSE b/Godeps/_workspace/src/github.com/cznic/mathutil/mersenne/LICENSE deleted file mode 100644 index 4fa2a1f4fd..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/mersenne/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2014 The mersenne 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 names of the authors nor the names of the -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. diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/mersenne/Makefile b/Godeps/_workspace/src/github.com/cznic/mathutil/mersenne/Makefile deleted file mode 100644 index a12fc5750c..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/mersenne/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (c) 2014 The mersenne Authors. All rights reserved. -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file. - -all: editor - go build - go vet - golint . - go install - make todo - -editor: - go fmt - go test -i - go test - -todo: - @grep -n ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alnum:]] *.go || true - @grep -n TODO *.go || true - @grep -n FIXME *.go || true - @grep -n BUG *.go || true - -clean: - rm -f *~ diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/mersenne/README b/Godeps/_workspace/src/github.com/cznic/mathutil/mersenne/README deleted file mode 100644 index afa401c717..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/mersenne/README +++ /dev/null @@ -1,2 +0,0 @@ -Install: $ go get github.com/cznic/mathutil/mersenne -Godocs: http://gopkgdoc.appspot.com/pkg/github.com/cznic/mathutil/mersenne diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/mersenne/mersenne.go b/Godeps/_workspace/src/github.com/cznic/mathutil/mersenne/mersenne.go deleted file mode 100644 index 21b6f396cf..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/mersenne/mersenne.go +++ /dev/null @@ -1,296 +0,0 @@ -// Copyright (c) 2014 The mersenne 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 mersenne collects utilities related to Mersenne numbers[1] and/or some -of their properties. - -Exponent - -In this documentation the term 'exponent' refers to 'n' of a Mersenne number Mn -equal to 2^n-1. This package supports only uint32 sized exponents. New() -currently supports exponents only up to math.MaxInt32 (31 bits, up to 256 MB -required to represent such Mn in memory as a big.Int). - -Links - -Referenced from above: - [1] http://en.wikipedia.org/wiki/Mersenne_number -*/ -package mersenne - -import ( - "math" - "math/big" - - "github.com/cznic/mathutil" - "github.com/remyoudompheng/bigfft" -) - -var ( - _0 = big.NewInt(0) - _1 = big.NewInt(1) - _2 = big.NewInt(2) -) - -// Knowns list the exponent of currently (March 2012) known Mersenne primes -// exponents in order. See also: http://oeis.org/A000043 for a partial list. -var Knowns = []uint32{ - 2, // #1 - 3, // #2 - 5, // #3 - 7, // #4 - 13, // #5 - 17, // #6 - 19, // #7 - 31, // #8 - 61, // #9 - 89, // #10 - - 107, // #11 - 127, // #12 - 521, // #13 - 607, // #14 - 1279, // #15 - 2203, // #16 - 2281, // #17 - 3217, // #18 - 4253, // #19 - 4423, // #20 - - 9689, // #21 - 9941, // #22 - 11213, // #23 - 19937, // #24 - 21701, // #25 - 23209, // #26 - 44497, // #27 - 86243, // #28 - 110503, // #29 - 132049, // #30 - - 216091, // #31 - 756839, // #32 - 859433, // #33 - 1257787, // #34 - 1398269, // #35 - 2976221, // #36 - 3021377, // #37 - 6972593, // #38 - 13466917, // #39 - 20996011, // #40 - - 24036583, // #41 - 25964951, // #42 - 30402457, // #43 - 32582657, // #44 - 37156667, // #45 - 42643801, // #46 - 43112609, // #47 - 57885161, // #48 -} - -// Known maps the exponent of known Mersenne primes its ordinal number/rank. -// Ranks > 41 are currently provisional. -var Known map[uint32]int - -func init() { - Known = map[uint32]int{} - for i, v := range Knowns { - Known[v] = i + 1 - } -} - -// New returns Mn == 2^n-1 for n <= math.MaxInt32 or nil otherwise. -func New(n uint32) (m *big.Int) { - if n > math.MaxInt32 { - return - } - - m = big.NewInt(0) - return m.Sub(m.SetBit(m, int(n), 1), _1) -} - -// HasFactorUint32 returns true if d | Mn. Typical run time for a 32 bit factor -// and a 32 bit exponent is < 1 µs. -func HasFactorUint32(d, n uint32) bool { - return d == 1 || d&1 != 0 && mathutil.ModPowUint32(2, n, d) == 1 -} - -// HasFactorUint64 returns true if d | Mn. Typical run time for a 64 bit factor -// and a 32 bit exponent is < 30 µs. -func HasFactorUint64(d uint64, n uint32) bool { - return d == 1 || d&1 != 0 && mathutil.ModPowUint64(2, uint64(n), d) == 1 -} - -// HasFactorBigInt returns true if d | Mn, d > 0. Typical run time for a 128 -// bit factor and a 32 bit exponent is < 75 µs. -func HasFactorBigInt(d *big.Int, n uint32) bool { - return d.Cmp(_1) == 0 || d.Sign() > 0 && d.Bit(0) == 1 && - mathutil.ModPowBigInt(_2, big.NewInt(int64(n)), d).Cmp(_1) == 0 -} - -// HasFactorBigInt2 returns true if d | Mn, d > 0 -func HasFactorBigInt2(d, n *big.Int) bool { - return d.Cmp(_1) == 0 || d.Sign() > 0 && d.Bit(0) == 1 && - mathutil.ModPowBigInt(_2, n, d).Cmp(_1) == 0 -} - -/* -FromFactorBigInt returns n such that d | Mn if n <= max and d is odd. In other -cases zero is returned. - -It is conjectured that every odd d ∊ N divides infinitely many Mersenne numbers. -The returned n should be the exponent of smallest such Mn. - -NOTE: The computation of n from a given d performs roughly in O(n). It is -thus highly recomended to use the 'max' argument to limit the "searched" -exponent upper bound as appropriate. Otherwise the computation can take a long -time as a large factor can be a divisor of a Mn with exponent above the uint32 -limits. - -The FromFactorBigInt function is a modification of the original Will -Edgington's "reverse method", discussed here: -http://tech.groups.yahoo.com/group/primenumbers/message/15061 -*/ -func FromFactorBigInt(d *big.Int, max uint32) (n uint32) { - if d.Bit(0) == 0 { - return - } - - var m big.Int - for n < max { - m.Add(&m, d) - i := 0 - for ; m.Bit(i) == 1; i++ { - if n == math.MaxUint32 { - return 0 - } - - n++ - } - m.Rsh(&m, uint(i)) - if m.Sign() == 0 { - if n > max { - n = 0 - } - return - } - } - return 0 -} - -// Mod sets mod to n % Mexp and returns mod. It panics for exp == 0 || exp >= -// math.MaxInt32 || n < 0. -func Mod(mod, n *big.Int, exp uint32) *big.Int { - if exp == 0 || exp >= math.MaxInt32 || n.Sign() < 0 { - panic(0) - } - - m := New(exp) - mod.Set(n) - var x big.Int - for mod.BitLen() > int(exp) { - x.Set(mod) - x.Rsh(&x, uint(exp)) - mod.And(mod, m) - mod.Add(mod, &x) - } - if mod.BitLen() == int(exp) && mod.Cmp(m) == 0 { - mod.SetInt64(0) - } - return mod -} - -// ModPow2 returns x such that 2^Me % Mm == 2^x. It panics for m < 2. Typical -// run time is < 1 µs. Use instead of ModPow(2, e, m) wherever possible. -func ModPow2(e, m uint32) (x uint32) { - /* - m < 2 -> panic - e == 0 -> x == 0 - e == 1 -> x == 1 - - 2^M1 % M2 == 2^1 % 3 == 2^1 10 // 2^1, 3, 5, 7 ... +2k - 2^M1 % M3 == 2^1 % 7 == 2^1 010 // 2^1, 4, 7, ... +3k - 2^M1 % M4 == 2^1 % 15 == 2^1 0010 // 2^1, 5, 9, 13... +4k - 2^M1 % M5 == 2^1 % 31 == 2^1 00010 // 2^1, 6, 11, 16... +5k - - 2^M2 % M2 == 2^3 % 3 == 2^1 10.. // 2^3, 5, 7, 9, 11, ... +2k - 2^M2 % M3 == 2^3 % 7 == 2^0 001... // 2^3, 6, 9, 12, 15, ... +3k - 2^M2 % M4 == 2^3 % 15 == 2^3 1000 // 2^3, 7, 11, 15, 19, ... +4k - 2^M2 % M5 == 2^3 % 31 == 2^3 01000 // 2^3, 8, 13, 18, 23, ... +5k - - 2^M3 % M2 == 2^7 % 3 == 2^1 10..--.. // 2^3, 5, 7... +2k - 2^M3 % M3 == 2^7 % 7 == 2^1 010...--- // 2^1, 4, 7... +3k - 2^M3 % M4 == 2^7 % 15 == 2^3 1000.... // +4k - 2^M3 % M5 == 2^7 % 31 == 2^2 00100..... // +5k - 2^M3 % M6 == 2^7 % 63 == 2^1 000010...... // +6k - 2^M3 % M7 == 2^7 % 127 == 2^0 0000001....... - 2^M3 % M8 == 2^7 % 255 == 2^7 10000000 - 2^M3 % M9 == 2^7 % 511 == 2^7 010000000 - - 2^M4 % M2 == 2^15 % 3 == 2^1 10..--..--..--.. - 2^M4 % M3 == 2^15 % 7 == 2^0 1...---...---... - 2^M4 % M4 == 2^15 % 15 == 2^3 1000....----.... - 2^M4 % M5 == 2^15 % 31 == 2^0 1.....-----..... - 2^M4 % M6 == 2^15 % 63 == 2^3 1000......------ - 2^M4 % M7 == 2^15 % 127 == 2^1 10.......------- - 2^M4 % M8 == 2^15 % 255 == 2^7 10000000........ - 2^M4 % M9 == 2^15 % 511 == 2^6 1000000......... - */ - switch { - case m < 2: - panic(0) - case e < 2: - return e - } - - if x = mathutil.ModPowUint32(2, e, m); x == 0 { - return m - 1 - } - - return x - 1 -} - -// ModPow returns b^Me % Mm. Run time grows quickly with 'e' and/or 'm' when b -// != 2 (then ModPow2 is used). -func ModPow(b, e, m uint32) (r *big.Int) { - if m == 1 { - return big.NewInt(0) - } - - if b == 2 { - x := ModPow2(e, m) - r = big.NewInt(0) - r.SetBit(r, int(x), 1) - return - } - - bb := big.NewInt(int64(b)) - r = big.NewInt(1) - for ; e != 0; e-- { - r = bigfft.Mul(r, bb) - Mod(r, r, m) - bb = bigfft.Mul(bb, bb) - Mod(bb, bb, m) - } - return -} - -// ProbablyPrime returns true if Mn is prime or is a pseudoprime to base a. -// Note: Every Mp, prime p, is a prime or is a pseudoprime to base 2, actually -// to every base 2^i, i ∊ [1, p). In contrast - it is conjectured (w/o any -// known counterexamples) that no composite Mp, prime p, is a pseudoprime to -// base 3. -func ProbablyPrime(n, a uint32) bool { - //TODO +test, +bench - if a == 2 { - return ModPow2(n-1, n) == 0 - } - - nMinus1 := New(n) - nMinus1.Sub(nMinus1, _1) - x := ModPow(a, n-1, n) - return x.Cmp(_1) == 0 || x.Cmp(nMinus1) == 0 -} diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/nist-sts-2-1-1-report b/Godeps/_workspace/src/github.com/cznic/mathutil/nist-sts-2-1-1-report deleted file mode 100644 index 20e686c61b..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/nist-sts-2-1-1-report +++ /dev/null @@ -1,267 +0,0 @@ -$ ./example -max 100000000 > rnd.dat -$ ./assess 1000000 - G E N E R A T O R S E L E C T I O N - ______________________________________ - - [0] Input File [1] Linear Congruential - [2] Quadratic Congruential I [3] Quadratic Congruential II - [4] Cubic Congruential [5] XOR - [6] Modular Exponentiation [7] Blum-Blum-Shub - [8] Micali-Schnorr [9] G Using SHA-1 - - Enter Choice: 0 - - - User Prescribed Input File: rnd.dat - - S T A T I S T I C A L T E S T S - _________________________________ - - [01] Frequency [02] Block Frequency - [03] Cumulative Sums [04] Runs - [05] Longest Run of Ones [06] Rank - [07] Discrete Fourier Transform [08] Nonperiodic Template Matchings - [09] Overlapping Template Matchings [10] Universal Statistical - [11] Approximate Entropy [12] Random Excursions - [13] Random Excursions Variant [14] Serial - [15] Linear Complexity - - INSTRUCTIONS - Enter 0 if you DO NOT want to apply all of the - statistical tests to each sequence and 1 if you DO. - - Enter Choice: 1 - - P a r a m e t e r A d j u s t m e n t s - ----------------------------------------- - [1] Block Frequency Test - block length(M): 128 - [2] NonOverlapping Template Test - block length(m): 9 - [3] Overlapping Template Test - block length(m): 9 - [4] Approximate Entropy Test - block length(m): 10 - [5] Serial Test - block length(m): 16 - [6] Linear Complexity Test - block length(M): 500 - - Select Test (0 to continue): 0 - - How many bitstreams? 200 - - Input File Format: - [0] ASCII - A sequence of ASCII 0's and 1's - [1] Binary - Each byte in data file contains 8 bits of data - - Select input mode: 1 - - Statistical Testing In Progress......... - - Statistical Testing Complete!!!!!!!!!!!! - -$ cat experiments/AlgorithmTesting/finalAnalysisReport.txt ------------------------------------------------------------------------------- -RESULTS FOR THE UNIFORMITY OF P-VALUES AND THE PROPORTION OF PASSING SEQUENCES ------------------------------------------------------------------------------- - generator is ------------------------------------------------------------------------------- - C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 P-VALUE PROPORTION STATISTICAL TEST ------------------------------------------------------------------------------- - 28 22 17 19 15 8 24 23 19 25 0.093720 198/200 Frequency - 20 18 24 14 18 17 16 28 21 24 0.504219 199/200 BlockFrequency - 25 22 17 24 19 21 22 15 16 19 0.825505 197/200 CumulativeSums - 27 17 16 22 14 26 14 25 19 20 0.304126 199/200 CumulativeSums - 22 19 14 23 22 22 13 28 13 24 0.224821 199/200 Runs - 20 24 18 21 15 13 22 23 24 20 0.719747 197/200 LongestRun - 22 26 18 22 26 15 17 22 20 12 0.410055 199/200 Rank - 25 22 26 22 20 16 20 20 16 13 0.585209 195/200 FFT - 22 11 15 26 33 24 21 13 14 21 0.013102 197/200 NonOverlappingTemplate - 17 11 16 27 19 24 19 20 28 19 0.219006 200/200 NonOverlappingTemplate - 23 27 24 15 21 11 18 27 15 19 0.162606 197/200 NonOverlappingTemplate - 21 18 13 20 19 23 20 17 26 23 0.749884 197/200 NonOverlappingTemplate - 24 22 24 24 24 21 13 15 17 16 0.494392 196/200 NonOverlappingTemplate - 24 16 23 15 23 18 25 16 18 22 0.699313 199/200 NonOverlappingTemplate - 19 23 21 16 27 18 17 20 18 21 0.859637 198/200 NonOverlappingTemplate - 12 20 16 19 26 14 30 20 24 19 0.141256 198/200 NonOverlappingTemplate - 18 21 17 21 20 14 25 19 24 21 0.859637 198/200 NonOverlappingTemplate - 24 25 21 18 23 15 23 17 16 18 0.749884 199/200 NonOverlappingTemplate - 20 22 22 18 16 22 28 16 14 22 0.574903 198/200 NonOverlappingTemplate - 18 23 22 17 24 25 19 16 23 13 0.626709 199/200 NonOverlappingTemplate - 17 22 14 19 21 21 18 19 24 25 0.842937 198/200 NonOverlappingTemplate - 18 17 26 21 22 15 22 18 21 20 0.883171 197/200 NonOverlappingTemplate - 19 25 16 32 15 19 20 18 16 20 0.236810 199/200 NonOverlappingTemplate - 19 18 15 21 24 22 18 21 20 22 0.964295 200/200 NonOverlappingTemplate - 21 14 17 23 26 19 20 22 20 18 0.834308 196/200 NonOverlappingTemplate - 15 21 17 27 26 23 21 17 24 9 0.129620 198/200 NonOverlappingTemplate - 25 17 19 19 18 22 21 22 21 16 0.951205 196/200 NonOverlappingTemplate - 20 19 24 21 19 24 16 18 17 22 0.946308 197/200 NonOverlappingTemplate - 27 16 19 18 23 19 22 17 22 17 0.807412 197/200 NonOverlappingTemplate - 14 18 21 23 23 20 14 22 20 25 0.719747 198/200 NonOverlappingTemplate - 18 22 19 12 24 25 25 22 18 15 0.474986 198/200 NonOverlappingTemplate - 21 18 23 17 19 18 28 19 20 17 0.825505 198/200 NonOverlappingTemplate - 20 19 15 16 27 20 26 17 20 20 0.657933 198/200 NonOverlappingTemplate - 17 25 21 21 11 19 22 16 27 21 0.401199 198/200 NonOverlappingTemplate - 19 16 15 18 24 19 25 25 19 20 0.769527 199/200 NonOverlappingTemplate - 18 20 20 26 20 12 24 25 19 16 0.524101 198/200 NonOverlappingTemplate - 14 16 18 23 21 21 19 19 28 21 0.668321 197/200 NonOverlappingTemplate - 21 20 23 25 21 22 19 17 14 18 0.875539 197/200 NonOverlappingTemplate - 14 16 29 22 23 13 20 29 17 17 0.099513 197/200 NonOverlappingTemplate - 14 19 27 19 17 23 18 24 20 19 0.709558 199/200 NonOverlappingTemplate - 18 15 21 19 27 22 21 23 17 17 0.779188 198/200 NonOverlappingTemplate - 13 23 13 22 22 23 22 21 21 20 0.689019 199/200 NonOverlappingTemplate - 17 14 26 26 16 21 30 15 21 14 0.096578 199/200 NonOverlappingTemplate - 18 21 24 23 21 13 23 23 19 15 0.719747 197/200 NonOverlappingTemplate - 19 21 14 32 20 15 16 18 24 21 0.202268 199/200 NonOverlappingTemplate - 27 22 20 21 21 14 15 22 14 24 0.474986 196/200 NonOverlappingTemplate - 31 12 25 11 21 18 19 16 24 23 0.050305 197/200 NonOverlappingTemplate - 17 26 20 22 15 27 22 19 12 20 0.383827 199/200 NonOverlappingTemplate - 15 22 14 14 31 15 27 18 23 21 0.078086 194/200 NonOverlappingTemplate - 19 19 14 15 24 21 25 21 20 22 0.788728 197/200 NonOverlappingTemplate - 20 21 19 22 25 18 13 24 28 10 0.153763 195/200 NonOverlappingTemplate - 23 17 21 25 21 20 13 30 14 16 0.196920 196/200 NonOverlappingTemplate - 17 31 17 22 16 15 28 23 11 20 0.050305 197/200 NonOverlappingTemplate - 15 21 26 27 15 18 19 21 18 20 0.605916 198/200 NonOverlappingTemplate - 23 18 15 14 20 21 20 20 20 29 0.554420 200/200 NonOverlappingTemplate - 22 19 19 18 19 17 22 21 31 12 0.311542 199/200 NonOverlappingTemplate - 16 22 23 21 19 19 18 24 21 17 0.960198 197/200 NonOverlappingTemplate - 21 21 17 20 16 23 25 22 18 17 0.917870 200/200 NonOverlappingTemplate - 27 17 17 16 21 20 22 18 21 21 0.859637 197/200 NonOverlappingTemplate - 18 24 15 27 18 21 18 16 24 19 0.657933 199/200 NonOverlappingTemplate - 13 16 21 21 15 25 18 22 29 20 0.326749 198/200 NonOverlappingTemplate - 18 17 23 23 15 19 26 30 11 18 0.125927 198/200 NonOverlappingTemplate - 30 21 18 22 17 21 15 17 21 18 0.544254 195/200 NonOverlappingTemplate - 12 18 19 24 16 24 18 24 28 17 0.311542 199/200 NonOverlappingTemplate - 20 15 23 15 18 30 23 18 17 21 0.410055 196/200 NonOverlappingTemplate - 15 18 23 16 29 21 22 16 19 21 0.544254 200/200 NonOverlappingTemplate - 18 16 27 13 21 22 22 21 16 24 0.534146 199/200 NonOverlappingTemplate - 20 25 18 21 16 21 17 28 21 13 0.484646 200/200 NonOverlappingTemplate - 23 22 13 22 14 20 26 18 19 23 0.574903 197/200 NonOverlappingTemplate - 21 24 25 13 19 22 18 13 24 21 0.504219 199/200 NonOverlappingTemplate - 19 13 18 25 22 15 23 28 19 18 0.410055 195/200 NonOverlappingTemplate - 20 15 27 22 26 26 14 13 21 16 0.181557 198/200 NonOverlappingTemplate - 18 18 19 23 18 20 19 21 24 20 0.991468 200/200 NonOverlappingTemplate - 18 23 17 14 20 25 22 22 22 17 0.816537 198/200 NonOverlappingTemplate - 26 15 15 11 23 21 21 16 36 16 0.005557 196/200 NonOverlappingTemplate - 27 13 21 23 21 16 19 20 16 24 0.544254 198/200 NonOverlappingTemplate - 16 15 32 17 20 23 22 19 20 16 0.262249 200/200 NonOverlappingTemplate - 26 19 24 13 24 16 18 18 13 29 0.137282 199/200 NonOverlappingTemplate - 15 18 14 27 32 21 15 20 19 19 0.112047 198/200 NonOverlappingTemplate - 22 23 22 18 20 23 19 22 16 15 0.924076 196/200 NonOverlappingTemplate - 18 17 21 22 14 17 22 24 20 25 0.798139 199/200 NonOverlappingTemplate - 15 17 19 24 21 23 17 25 23 16 0.739918 196/200 NonOverlappingTemplate - 22 11 15 26 32 25 21 13 14 21 0.017305 197/200 NonOverlappingTemplate - 22 16 19 23 22 21 21 19 17 20 0.985788 200/200 NonOverlappingTemplate - 22 28 18 24 14 20 23 21 20 10 0.230755 198/200 NonOverlappingTemplate - 14 13 22 28 14 28 17 22 23 19 0.129620 197/200 NonOverlappingTemplate - 22 16 22 20 21 21 16 19 18 25 0.935716 198/200 NonOverlappingTemplate - 15 20 23 17 19 22 21 23 18 22 0.951205 200/200 NonOverlappingTemplate - 20 24 21 19 17 19 19 24 15 22 0.930026 198/200 NonOverlappingTemplate - 18 21 15 21 17 28 24 22 20 14 0.534146 200/200 NonOverlappingTemplate - 19 15 19 19 20 20 15 25 23 25 0.779188 198/200 NonOverlappingTemplate - 17 24 25 16 15 21 18 19 23 22 0.788728 198/200 NonOverlappingTemplate - 15 20 18 25 24 15 21 31 18 13 0.141256 200/200 NonOverlappingTemplate - 24 17 19 20 18 21 15 22 24 20 0.924076 196/200 NonOverlappingTemplate - 23 18 17 21 17 28 23 21 18 14 0.605916 197/200 NonOverlappingTemplate - 21 19 22 23 16 17 20 21 22 19 0.985788 200/200 NonOverlappingTemplate - 27 17 21 27 24 15 15 17 15 22 0.304126 199/200 NonOverlappingTemplate - 25 28 20 24 13 14 16 22 19 19 0.304126 197/200 NonOverlappingTemplate - 27 16 14 24 22 18 24 20 18 17 0.564639 196/200 NonOverlappingTemplate - 18 18 24 19 19 19 26 11 27 19 0.375313 195/200 NonOverlappingTemplate - 20 15 29 19 26 16 21 11 18 25 0.141256 197/200 NonOverlappingTemplate - 19 14 21 25 11 23 22 25 26 14 0.176657 199/200 NonOverlappingTemplate - 18 23 20 17 19 18 29 22 26 8 0.102526 199/200 NonOverlappingTemplate - 22 17 18 16 18 20 19 19 25 26 0.834308 198/200 NonOverlappingTemplate - 25 18 14 16 16 24 18 18 30 21 0.268917 198/200 NonOverlappingTemplate - 24 21 23 13 12 22 20 23 20 22 0.554420 196/200 NonOverlappingTemplate - 18 21 21 30 22 17 19 14 18 20 0.534146 197/200 NonOverlappingTemplate - 25 20 22 21 15 18 17 20 17 25 0.825505 199/200 NonOverlappingTemplate - 18 21 22 21 18 20 26 16 20 18 0.941144 197/200 NonOverlappingTemplate - 23 18 22 25 12 16 17 19 26 22 0.474986 198/200 NonOverlappingTemplate - 22 18 29 23 19 23 17 17 15 17 0.534146 198/200 NonOverlappingTemplate - 19 21 17 26 18 15 22 26 15 21 0.626709 197/200 NonOverlappingTemplate - 16 20 20 23 18 21 18 18 25 21 0.955835 199/200 NonOverlappingTemplate - 23 21 20 21 22 10 15 27 15 26 0.186566 198/200 NonOverlappingTemplate - 18 26 20 26 26 18 17 17 20 12 0.358641 198/200 NonOverlappingTemplate - 24 20 21 18 24 12 19 27 14 21 0.401199 195/200 NonOverlappingTemplate - 16 25 15 21 24 18 18 25 22 16 0.657933 199/200 NonOverlappingTemplate - 24 14 17 26 15 17 17 25 21 24 0.428095 200/200 NonOverlappingTemplate - 22 24 11 20 22 24 19 18 12 28 0.176657 196/200 NonOverlappingTemplate - 27 16 27 18 27 14 13 16 21 21 0.141256 197/200 NonOverlappingTemplate - 23 25 20 18 23 17 15 23 19 17 0.834308 196/200 NonOverlappingTemplate - 19 21 20 27 16 16 18 25 16 22 0.678686 199/200 NonOverlappingTemplate - 25 22 21 19 15 19 22 19 25 13 0.657933 197/200 NonOverlappingTemplate - 19 28 21 25 20 12 18 13 29 15 0.073417 198/200 NonOverlappingTemplate - 20 24 21 19 21 15 17 24 20 19 0.941144 198/200 NonOverlappingTemplate - 18 29 23 17 24 19 17 18 16 19 0.585209 200/200 NonOverlappingTemplate - 18 28 18 16 25 21 18 20 14 22 0.544254 198/200 NonOverlappingTemplate - 22 19 23 22 22 21 21 26 12 12 0.401199 199/200 NonOverlappingTemplate - 22 15 25 16 21 27 14 22 21 17 0.484646 199/200 NonOverlappingTemplate - 18 25 20 23 30 17 13 22 18 14 0.213309 200/200 NonOverlappingTemplate - 20 23 21 21 23 29 16 13 16 18 0.410055 199/200 NonOverlappingTemplate - 21 19 16 22 31 18 20 17 18 18 0.514124 198/200 NonOverlappingTemplate - 26 22 12 14 23 17 21 24 21 20 0.455937 197/200 NonOverlappingTemplate - 21 17 18 17 14 32 21 26 18 16 0.162606 197/200 NonOverlappingTemplate - 22 24 22 23 11 15 17 18 29 19 0.230755 198/200 NonOverlappingTemplate - 19 27 20 19 23 15 24 15 21 17 0.657933 198/200 NonOverlappingTemplate - 20 25 16 10 24 13 23 21 21 27 0.149495 200/200 NonOverlappingTemplate - 19 21 21 27 17 17 19 21 21 17 0.904708 200/200 NonOverlappingTemplate - 18 23 15 19 24 21 23 21 13 23 0.719747 198/200 NonOverlappingTemplate - 26 16 28 19 19 18 17 17 16 24 0.474986 199/200 NonOverlappingTemplate - 24 32 17 18 20 13 18 18 19 21 0.236810 195/200 NonOverlappingTemplate - 26 25 18 17 12 19 20 23 21 19 0.585209 196/200 NonOverlappingTemplate - 18 26 25 12 18 16 24 19 18 24 0.410055 199/200 NonOverlappingTemplate - 27 21 22 27 21 14 18 14 23 13 0.219006 197/200 NonOverlappingTemplate - 18 23 24 16 19 21 16 26 20 17 0.798139 199/200 NonOverlappingTemplate - 19 30 15 27 14 19 24 11 22 19 0.073417 198/200 NonOverlappingTemplate - 20 23 22 20 22 15 22 21 18 17 0.964295 198/200 NonOverlappingTemplate - 22 31 16 26 13 19 17 22 24 10 0.037566 197/200 NonOverlappingTemplate - 18 24 22 14 23 19 16 18 19 27 0.637119 197/200 NonOverlappingTemplate - 19 20 21 22 21 18 19 22 20 18 0.999438 198/200 NonOverlappingTemplate - 27 15 21 18 28 18 15 23 18 17 0.375313 195/200 NonOverlappingTemplate - 26 23 20 20 23 19 20 23 14 12 0.514124 199/200 NonOverlappingTemplate - 18 19 11 15 21 24 20 26 23 23 0.428095 198/200 NonOverlappingTemplate - 19 16 21 25 19 21 15 24 24 16 0.749884 197/200 NonOverlappingTemplate - 17 26 23 18 20 26 23 14 18 15 0.494392 198/200 NonOverlappingTemplate - 15 17 19 24 21 23 17 25 23 16 0.739918 196/200 NonOverlappingTemplate - 26 19 20 20 24 22 22 13 14 20 0.605916 198/200 OverlappingTemplate - 29 24 17 21 18 13 18 21 17 22 0.446556 196/200 Universal - 22 18 22 20 20 21 22 21 18 16 0.992952 198/200 ApproximateEntropy - 14 8 13 9 11 13 13 8 7 10 0.719747 106/106 RandomExcursions - 13 18 9 7 12 12 9 6 12 8 0.236810 104/106 RandomExcursions - 11 15 10 7 11 14 9 6 12 11 0.595549 106/106 RandomExcursions - 15 7 12 12 9 11 16 8 10 6 0.350485 106/106 RandomExcursions - 10 10 12 16 10 12 10 7 13 6 0.554420 106/106 RandomExcursions - 8 7 12 10 11 16 11 13 10 8 0.657933 106/106 RandomExcursions - 9 6 12 12 14 9 11 13 10 10 0.816537 104/106 RandomExcursions - 10 10 7 12 11 9 10 13 14 10 0.911413 105/106 RandomExcursions - 8 8 12 9 10 5 13 12 17 12 0.319084 104/106 RandomExcursionsVariant - 5 11 10 11 7 11 10 15 11 15 0.455937 104/106 RandomExcursionsVariant - 6 12 11 8 12 12 12 13 13 7 0.699313 104/106 RandomExcursionsVariant - 14 10 11 6 12 9 8 12 11 13 0.779188 104/106 RandomExcursionsVariant - 12 12 10 7 17 6 6 12 13 11 0.262249 103/106 RandomExcursionsVariant - 13 8 14 13 7 6 6 13 15 11 0.249284 102/106 RandomExcursionsVariant - 12 12 12 13 7 9 6 13 12 10 0.739918 105/106 RandomExcursionsVariant - 13 15 12 8 9 10 6 9 14 10 0.574903 106/106 RandomExcursionsVariant - 10 15 9 12 14 10 8 11 7 10 0.739918 105/106 RandomExcursionsVariant - 13 12 8 11 12 11 9 10 11 9 0.978072 103/106 RandomExcursionsVariant - 10 13 12 12 8 13 8 9 14 7 0.739918 104/106 RandomExcursionsVariant - 12 10 10 14 7 8 7 13 14 11 0.657933 106/106 RandomExcursionsVariant - 10 13 10 10 13 10 12 6 10 12 0.897763 106/106 RandomExcursionsVariant - 9 12 15 8 13 8 12 8 11 10 0.779188 106/106 RandomExcursionsVariant - 9 13 15 10 10 10 8 14 6 11 0.616305 106/106 RandomExcursionsVariant - 7 17 9 12 9 11 10 16 4 11 0.129620 106/106 RandomExcursionsVariant - 10 9 10 15 7 12 7 8 12 16 0.419021 106/106 RandomExcursionsVariant - 9 12 11 8 8 9 15 12 9 13 0.798139 106/106 RandomExcursionsVariant - 17 34 11 22 22 17 19 20 13 25 0.026057 199/200 Serial - 22 20 16 22 20 18 20 18 23 21 0.989786 199/200 Serial - 12 33 25 29 21 11 21 15 14 19 0.003996 199/200 LinearComplexity - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -The minimum pass rate for each statistical test with the exception of the -random excursion (variant) test is approximately = 193 for a -sample size = 200 binary sequences. - -The minimum pass rate for the random excursion (variant) test -is approximately = 101 for a sample size = 106 binary sequences. - -For further guidelines construct a probability table using the MAPLE program -provided in the addendum section of the documentation. -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -$ diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/permute.go b/Godeps/_workspace/src/github.com/cznic/mathutil/permute.go deleted file mode 100644 index bf828b694f..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/permute.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2014 The mathutil 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 mathutil - -import ( - "sort" -) - -// Generate the first permutation of data. -func PermutationFirst(data sort.Interface) { - sort.Sort(data) -} - -// Generate the next permutation of data if possible and return true. -// Return false if there is no more permutation left. -// Based on the algorithm described here: -// http://en.wikipedia.org/wiki/Permutation#Generation_in_lexicographic_order -func PermutationNext(data sort.Interface) bool { - var k, l int - for k = data.Len() - 2; ; k-- { // 1. - if k < 0 { - return false - } - - if data.Less(k, k+1) { - break - } - } - for l = data.Len() - 1; !data.Less(k, l); l-- { // 2. - } - data.Swap(k, l) // 3. - for i, j := k+1, data.Len()-1; i < j; i++ { // 4. - data.Swap(i, j) - j-- - } - return true -} diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/primes.go b/Godeps/_workspace/src/github.com/cznic/mathutil/primes.go deleted file mode 100644 index 2c82eb033e..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/primes.go +++ /dev/null @@ -1,342 +0,0 @@ -// Copyright (c) 2014 The mathutil 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 mathutil - -import ( - "math" -) - -// IsPrimeUint16 returns true if n is prime. Typical run time is few ns. -func IsPrimeUint16(n uint16) bool { - return n > 0 && primes16[n-1] == 1 -} - -// NextPrimeUint16 returns first prime > n and true if successful or an -// undefined value and false if there is no next prime in the uint16 limits. -// Typical run time is few ns. -func NextPrimeUint16(n uint16) (p uint16, ok bool) { - return n + uint16(primes16[n]), n < 65521 -} - -// IsPrime returns true if n is prime. Typical run time is about 100 ns. -// -//TODO rename to IsPrimeUint32 -func IsPrime(n uint32) bool { - switch { - case n&1 == 0: - return n == 2 - case n%3 == 0: - return n == 3 - case n%5 == 0: - return n == 5 - case n%7 == 0: - return n == 7 - case n%11 == 0: - return n == 11 - case n%13 == 0: - return n == 13 - case n%17 == 0: - return n == 17 - case n%19 == 0: - return n == 19 - case n%23 == 0: - return n == 23 - case n%29 == 0: - return n == 29 - case n%31 == 0: - return n == 31 - case n%37 == 0: - return n == 37 - case n%41 == 0: - return n == 41 - case n%43 == 0: - return n == 43 - case n%47 == 0: - return n == 47 - case n%53 == 0: - return n == 53 // Benchmarked optimum - case n < 65536: - // use table data - return IsPrimeUint16(uint16(n)) - default: - mod := ModPowUint32(2, (n+1)/2, n) - if mod != 2 && mod != n-2 { - return false - } - blk := &lohi[n>>24] - lo, hi := blk.lo, blk.hi - for lo <= hi { - index := (lo + hi) >> 1 - liar := liars[index] - switch { - case n > liar: - lo = index + 1 - case n < liar: - hi = index - 1 - default: - return false - } - } - return true - } -} - -// IsPrimeUint64 returns true if n is prime. Typical run time is few tens of µs. -// -// SPRP bases: http://miller-rabin.appspot.com -func IsPrimeUint64(n uint64) bool { - switch { - case n%2 == 0: - return n == 2 - case n%3 == 0: - return n == 3 - case n%5 == 0: - return n == 5 - case n%7 == 0: - return n == 7 - case n%11 == 0: - return n == 11 - case n%13 == 0: - return n == 13 - case n%17 == 0: - return n == 17 - case n%19 == 0: - return n == 19 - case n%23 == 0: - return n == 23 - case n%29 == 0: - return n == 29 - case n%31 == 0: - return n == 31 - case n%37 == 0: - return n == 37 - case n%41 == 0: - return n == 41 - case n%43 == 0: - return n == 43 - case n%47 == 0: - return n == 47 - case n%53 == 0: - return n == 53 - case n%59 == 0: - return n == 59 - case n%61 == 0: - return n == 61 - case n%67 == 0: - return n == 67 - case n%71 == 0: - return n == 71 - case n%73 == 0: - return n == 73 - case n%79 == 0: - return n == 79 - case n%83 == 0: - return n == 83 - case n%89 == 0: - return n == 89 // Benchmarked optimum - case n <= math.MaxUint16: - return IsPrimeUint16(uint16(n)) - case n <= math.MaxUint32: - return ProbablyPrimeUint32(uint32(n), 11000544) && - ProbablyPrimeUint32(uint32(n), 31481107) - case n < 105936894253: - return ProbablyPrimeUint64_32(n, 2) && - ProbablyPrimeUint64_32(n, 1005905886) && - ProbablyPrimeUint64_32(n, 1340600841) - case n < 31858317218647: - return ProbablyPrimeUint64_32(n, 2) && - ProbablyPrimeUint64_32(n, 642735) && - ProbablyPrimeUint64_32(n, 553174392) && - ProbablyPrimeUint64_32(n, 3046413974) - case n < 3071837692357849: - return ProbablyPrimeUint64_32(n, 2) && - ProbablyPrimeUint64_32(n, 75088) && - ProbablyPrimeUint64_32(n, 642735) && - ProbablyPrimeUint64_32(n, 203659041) && - ProbablyPrimeUint64_32(n, 3613982119) - default: - return ProbablyPrimeUint64_32(n, 2) && - ProbablyPrimeUint64_32(n, 325) && - ProbablyPrimeUint64_32(n, 9375) && - ProbablyPrimeUint64_32(n, 28178) && - ProbablyPrimeUint64_32(n, 450775) && - ProbablyPrimeUint64_32(n, 9780504) && - ProbablyPrimeUint64_32(n, 1795265022) - } -} - -// NextPrime returns first prime > n and true if successful or an undefined value and false if there -// is no next prime in the uint32 limits. Typical run time is about 2 µs. -// -//TODO rename to NextPrimeUint32 -func NextPrime(n uint32) (p uint32, ok bool) { - switch { - case n < 65521: - p16, _ := NextPrimeUint16(uint16(n)) - return uint32(p16), true - case n >= math.MaxUint32-4: - return - } - - n++ - var d0, d uint32 - switch mod := n % 6; mod { - case 0: - d0, d = 1, 4 - case 1: - d = 4 - case 2, 3, 4: - d0, d = 5-mod, 2 - case 5: - d = 2 - } - - p = n + d0 - if p < n { // overflow - return - } - - for { - if IsPrime(p) { - return p, true - } - - p0 := p - p += d - if p < p0 { // overflow - break - } - - d ^= 6 - } - return -} - -// NextPrimeUint64 returns first prime > n and true if successful or an undefined value and false if there -// is no next prime in the uint64 limits. Typical run time is in hundreds of µs. -func NextPrimeUint64(n uint64) (p uint64, ok bool) { - switch { - case n < 65521: - p16, _ := NextPrimeUint16(uint16(n)) - return uint64(p16), true - case n >= 18446744073709551557: // last uint64 prime - return - } - - n++ - var d0, d uint64 - switch mod := n % 6; mod { - case 0: - d0, d = 1, 4 - case 1: - d = 4 - case 2, 3, 4: - d0, d = 5-mod, 2 - case 5: - d = 2 - } - - p = n + d0 - if p < n { // overflow - return - } - - for { - if ok = IsPrimeUint64(p); ok { - break - } - - p0 := p - p += d - if p < p0 { // overflow - break - } - - d ^= 6 - } - return -} - -// FactorTerm is one term of an integer factorization. -type FactorTerm struct { - Prime uint32 // The divisor - Power uint32 // Term == Prime^Power -} - -// FactorTerms represent a factorization of an integer -type FactorTerms []FactorTerm - -// FactorInt returns prime factorization of n > 1 or nil otherwise. -// Resulting factors are ordered by Prime. Typical run time is few µs. -func FactorInt(n uint32) (f FactorTerms) { - switch { - case n < 2: - return - case IsPrime(n): - return []FactorTerm{{n, 1}} - } - - f, w := make([]FactorTerm, 9), 0 - prime16 := uint16(0) - for { - var ok bool - if prime16, ok = NextPrimeUint16(prime16); !ok { - break - } - - prime := uint32(prime16) - if prime*prime > n { - break - } - - power := uint32(0) - for n%prime == 0 { - n /= prime - power++ - } - if power != 0 { - f[w] = FactorTerm{prime, power} - w++ - } - if n == 1 { - break - } - } - if n != 1 { - f[w] = FactorTerm{n, 1} - w++ - } - return f[:w] -} - -// PrimorialProductsUint32 returns a slice of numbers in [lo, hi] which are a -// product of max 'max' primorials. The slice is not sorted. -// -// See also: http://en.wikipedia.org/wiki/Primorial -func PrimorialProductsUint32(lo, hi, max uint32) (r []uint32) { - lo64, hi64 := int64(lo), int64(hi) - if max > 31 { // N/A - max = 31 - } - - var f func(int64, int64, uint32) - f = func(n, p int64, emax uint32) { - e := uint32(1) - for n <= hi64 && e <= emax { - n *= p - if n >= lo64 && n <= hi64 { - r = append(r, uint32(n)) - } - if n < hi64 { - p, _ := NextPrime(uint32(p)) - f(n, int64(p), e) - } - e++ - } - } - - f(1, 2, max) - return -} diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/rat.go b/Godeps/_workspace/src/github.com/cznic/mathutil/rat.go deleted file mode 100644 index 91b1c6fb1e..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/rat.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2014 The mathutil 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 mathutil - -// QCmpUint32 compares a/b and c/d and returns: -// -// -1 if a/b < c/d -// 0 if a/b == c/d -// +1 if a/b > c/d -// -func QCmpUint32(a, b, c, d uint32) int { - switch x, y := uint64(a)*uint64(d), uint64(b)*uint64(c); { - case x < y: - return -1 - case x == y: - return 0 - default: // x > y - return 1 - } -} - -// QScaleUint32 returns a such that a/b >= c/d. -func QScaleUint32(b, c, d uint32) (a uint64) { - return 1 + (uint64(b)*uint64(c))/uint64(d) -} diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/rnd.go b/Godeps/_workspace/src/github.com/cznic/mathutil/rnd.go deleted file mode 100644 index 9132dc0d55..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/rnd.go +++ /dev/null @@ -1,383 +0,0 @@ -// Copyright (c) 2014 The mathutil 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 mathutil - -import ( - "fmt" - "math" - "math/big" -) - -// FC32 is a full cycle PRNG covering the 32 bit signed integer range. -// In contrast to full cycle generators shown at e.g. http://en.wikipedia.org/wiki/Full_cycle, -// this code doesn't produce values at constant delta (mod cycle length). -// The 32 bit limit is per this implementation, the algorithm used has no intrinsic limit on the cycle size. -// Properties include: -// - Adjustable limits on creation (hi, lo). -// - Positionable/randomly accessible (Pos, Seek). -// - Repeatable (deterministic). -// - Can run forward or backward (Next, Prev). -// - For a billion numbers cycle the Next/Prev PRN can be produced in cca 100-150ns. -// That's like 5-10 times slower compared to PRNs generated using the (non FC) rand package. -type FC32 struct { - cycle int64 // On average: 3 * delta / 2, (HQ: 2 * delta) - delta int64 // hi - lo - factors [][]int64 // This trades some space for hopefully a bit of speed (multiple adding vs multiplying). - lo int - mods []int // pos % set - pos int64 // Within cycle. - primes []int64 // Ordered. ∏ primes == cycle. - set []int64 // Reordered primes (magnitude order bases) according to seed. -} - -// NewFC32 returns a newly created FC32 adjusted for the closed interval [lo, hi] or an Error if any. -// If hq == true then trade some generation time for improved (pseudo)randomness. -func NewFC32(lo, hi int, hq bool) (r *FC32, err error) { - if lo > hi { - return nil, fmt.Errorf("invalid range %d > %d", lo, hi) - } - - if uint64(hi)-uint64(lo) > math.MaxUint32 { - return nil, fmt.Errorf("range out of int32 limits %d, %d", lo, hi) - } - - delta := int64(hi) - int64(lo) - // Find the primorial covering whole delta - n, set, p := int64(1), []int64{}, uint32(2) - if hq { - p++ - } - for { - set = append(set, int64(p)) - n *= int64(p) - if n > delta { - break - } - p, _ = NextPrime(p) - } - - // Adjust the set so n ∊ [delta, 2 * delta] (HQ: [delta, 3 * delta]) - // while keeping the cardinality of the set (correlates with the statistic "randomness quality") - // at max, i.e. discard atmost one member. - i := -1 // no candidate prime - if n > 2*(delta+1) { - for j, p := range set { - q := n / p - if q < delta+1 { - break - } - - i = j // mark the highest candidate prime set index - } - } - if i >= 0 { // shrink the inner cycle - n = n / set[i] - set = delete(set, i) - } - r = &FC32{ - cycle: n, - delta: delta, - factors: make([][]int64, len(set)), - lo: lo, - mods: make([]int, len(set)), - primes: set, - } - r.Seed(1) // the default seed should be always non zero - return -} - -// Cycle reports the length of the inner FCPRNG cycle. -// Cycle is atmost the double (HQ: triple) of the generator period (hi - lo + 1). -func (r *FC32) Cycle() int64 { - return r.cycle -} - -// Next returns the first PRN after Pos. -func (r *FC32) Next() int { - return r.step(1) -} - -// Pos reports the current position within the inner cycle. -func (r *FC32) Pos() int64 { - return r.pos -} - -// Prev return the first PRN before Pos. -func (r *FC32) Prev() int { - return r.step(-1) -} - -// Seed uses the provided seed value to initialize the generator to a deterministic state. -// A zero seed produces a "canonical" generator with worse randomness than for most non zero seeds. -// Still, the FC property holds for any seed value. -func (r *FC32) Seed(seed int64) { - u := uint64(seed) - r.set = mix(r.primes, &u) - n := int64(1) - for i, p := range r.set { - k := make([]int64, p) - v := int64(0) - for j := range k { - k[j] = v - v += n - } - n *= p - r.factors[i] = mix(k, &u) - } -} - -// Seek sets Pos to |pos| % Cycle. -func (r *FC32) Seek(pos int64) { //vet:ignore - if pos < 0 { - pos = -pos - } - pos %= r.cycle - r.pos = pos - for i, p := range r.set { - r.mods[i] = int(pos % p) - } -} - -func (r *FC32) step(dir int) int { - for { // avg loops per step: 3/2 (HQ: 2) - y := int64(0) - pos := r.pos - pos += int64(dir) - switch { - case pos < 0: - pos = r.cycle - 1 - case pos >= r.cycle: - pos = 0 - } - r.pos = pos - for i, mod := range r.mods { - mod += dir - p := int(r.set[i]) - switch { - case mod < 0: - mod = p - 1 - case mod >= p: - mod = 0 - } - r.mods[i] = mod - y += r.factors[i][mod] - } - if y <= r.delta { - return int(y) + r.lo - } - } -} - -func delete(set []int64, i int) (y []int64) { - for j, v := range set { - if j != i { - y = append(y, v) - } - } - return -} - -func mix(set []int64, seed *uint64) (y []int64) { - for len(set) != 0 { - *seed = rol(*seed) - i := int(*seed % uint64(len(set))) - y = append(y, set[i]) - set = delete(set, i) - } - return -} - -func rol(u uint64) (y uint64) { - y = u << 1 - if int64(u) < 0 { - y |= 1 - } - return -} - -// FCBig is a full cycle PRNG covering ranges outside of the int32 limits. -// For more info see the FC32 docs. -// Next/Prev PRN on a 1e15 cycle can be produced in about 2 µsec. -type FCBig struct { - cycle *big.Int // On average: 3 * delta / 2, (HQ: 2 * delta) - delta *big.Int // hi - lo - factors [][]*big.Int // This trades some space for hopefully a bit of speed (multiple adding vs multiplying). - lo *big.Int - mods []int // pos % set - pos *big.Int // Within cycle. - primes []int64 // Ordered. ∏ primes == cycle. - set []int64 // Reordered primes (magnitude order bases) according to seed. -} - -// NewFCBig returns a newly created FCBig adjusted for the closed interval [lo, hi] or an Error if any. -// If hq == true then trade some generation time for improved (pseudo)randomness. -func NewFCBig(lo, hi *big.Int, hq bool) (r *FCBig, err error) { - if lo.Cmp(hi) > 0 { - return nil, fmt.Errorf("invalid range %d > %d", lo, hi) - } - - delta := big.NewInt(0) - delta.Add(delta, hi).Sub(delta, lo) - - // Find the primorial covering whole delta - n, set, pp, p := big.NewInt(1), []int64{}, big.NewInt(0), uint32(2) - if hq { - p++ - } - for { - set = append(set, int64(p)) - pp.SetInt64(int64(p)) - n.Mul(n, pp) - if n.Cmp(delta) > 0 { - break - } - p, _ = NextPrime(p) - } - - // Adjust the set so n ∊ [delta, 2 * delta] (HQ: [delta, 3 * delta]) - // while keeping the cardinality of the set (correlates with the statistic "randomness quality") - // at max, i.e. discard atmost one member. - dd1 := big.NewInt(1) - dd1.Add(dd1, delta) - dd2 := big.NewInt(0) - dd2.Lsh(dd1, 1) - i := -1 // no candidate prime - if n.Cmp(dd2) > 0 { - q := big.NewInt(0) - for j, p := range set { - pp.SetInt64(p) - q.Set(n) - q.Div(q, pp) - if q.Cmp(dd1) < 0 { - break - } - - i = j // mark the highest candidate prime set index - } - } - if i >= 0 { // shrink the inner cycle - pp.SetInt64(set[i]) - n.Div(n, pp) - set = delete(set, i) - } - r = &FCBig{ - cycle: n, - delta: delta, - factors: make([][]*big.Int, len(set)), - lo: lo, - mods: make([]int, len(set)), - pos: big.NewInt(0), - primes: set, - } - r.Seed(1) // the default seed should be always non zero - return -} - -// Cycle reports the length of the inner FCPRNG cycle. -// Cycle is atmost the double (HQ: triple) of the generator period (hi - lo + 1). -func (r *FCBig) Cycle() *big.Int { - return r.cycle -} - -// Next returns the first PRN after Pos. -func (r *FCBig) Next() *big.Int { - return r.step(1) -} - -// Pos reports the current position within the inner cycle. -func (r *FCBig) Pos() *big.Int { - return r.pos -} - -// Prev return the first PRN before Pos. -func (r *FCBig) Prev() *big.Int { - return r.step(-1) -} - -// Seed uses the provided seed value to initialize the generator to a deterministic state. -// A zero seed produces a "canonical" generator with worse randomness than for most non zero seeds. -// Still, the FC property holds for any seed value. -func (r *FCBig) Seed(seed int64) { - u := uint64(seed) - r.set = mix(r.primes, &u) - n := big.NewInt(1) - v := big.NewInt(0) - pp := big.NewInt(0) - for i, p := range r.set { - k := make([]*big.Int, p) - v.SetInt64(0) - for j := range k { - k[j] = big.NewInt(0) - k[j].Set(v) - v.Add(v, n) - } - pp.SetInt64(p) - n.Mul(n, pp) - r.factors[i] = mixBig(k, &u) - } -} - -// Seek sets Pos to |pos| % Cycle. -func (r *FCBig) Seek(pos *big.Int) { - r.pos.Set(pos) - r.pos.Abs(r.pos) - r.pos.Mod(r.pos, r.cycle) - mod := big.NewInt(0) - pp := big.NewInt(0) - for i, p := range r.set { - pp.SetInt64(p) - r.mods[i] = int(mod.Mod(r.pos, pp).Int64()) - } -} - -func (r *FCBig) step(dir int) (y *big.Int) { - y = big.NewInt(0) - d := big.NewInt(int64(dir)) - for { // avg loops per step: 3/2 (HQ: 2) - r.pos.Add(r.pos, d) - switch { - case r.pos.Sign() < 0: - r.pos.Add(r.pos, r.cycle) - case r.pos.Cmp(r.cycle) >= 0: - r.pos.SetInt64(0) - } - for i, mod := range r.mods { - mod += dir - p := int(r.set[i]) - switch { - case mod < 0: - mod = p - 1 - case mod >= p: - mod = 0 - } - r.mods[i] = mod - y.Add(y, r.factors[i][mod]) - } - if y.Cmp(r.delta) <= 0 { - y.Add(y, r.lo) - return - } - y.SetInt64(0) - } -} - -func deleteBig(set []*big.Int, i int) (y []*big.Int) { - for j, v := range set { - if j != i { - y = append(y, v) - } - } - return -} - -func mixBig(set []*big.Int, seed *uint64) (y []*big.Int) { - for len(set) != 0 { - *seed = rol(*seed) - i := int(*seed % uint64(len(set))) - y = append(y, set[i]) - set = deleteBig(set, i) - } - return -} diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/tables.go b/Godeps/_workspace/src/github.com/cznic/mathutil/tables.go deleted file mode 100644 index f32952c007..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/tables.go +++ /dev/null @@ -1,6995 +0,0 @@ -// Copyright (c) 2014 The mathutil Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// "Static" data - -package mathutil - -var ( - // Set bits count in a byte - popcnt = [256]byte{ - 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, // 0 - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, // 1 - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, // 2 - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, // 3 - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, // 4 - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, // 5 - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, // 6 - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, // 7 - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, // 8 - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, // 9 - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, // 10 - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, // 11 - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, // 12 - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, // 13 - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, // 14 - 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8, // 15 - } - - // Highest set bit index in a byte - log2 = [256]int{ - -1, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, // 0 - - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, // 1 - - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, // 2 - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, // 3 - - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, // 4 - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, // 5 - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, // 6 - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, // 7 - - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 8 - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 9 - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 10 - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 11 - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 12 - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 13 - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 14 - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 15 - } - - // "Predivisors": 2-53 - liars = [3660]uint32{ - 31621, 42799, 49141, 49981, 65077, 65281, 80581, 83333, 88357, 90751, - 104653, 130561, 164737, 188057, 194221, 196093, 215749, 219781, 220729, 253241, - 256999, 271951, 280601, 282133, 357761, 390937, 458989, 486737, 489997, 514447, - 580337, 587861, 611701, 647089, 653333, 657901, 665281, 665333, 688213, 710533, - 721801, 722261, 738541, 741751, 742813, 745889, 769757, 818201, 838861, 873181, - 877099, 916327, 976873, 983401, 1016801, 1018921, 1053761, 1064053, 1073021, 1082401, - 1109461, 1132657, 1145257, 1168513, 1194649, 1207361, 1251949, 1252697, 1302451, 1325843, - 1357441, 1373653, 1397419, 1441091, 1493857, 1507963, 1509709, 1530787, 1584133, 1678541, - 1690501, 1730977, 1735841, 1811573, 1876393, 1969417, 1987021, 2004403, 2081713, 2163001, - 2181961, 2205967, 2261953, 2264369, 2269093, 2284453, 2304167, 2387797, 2487941, 2510569, - 2670361, 2746477, 2748023, 2757241, 2811271, 2909197, 2944261, 2976487, 3048841, 3090091, - 3116107, 3125281, 3225601, 3363121, 3375041, 3400013, 3413533, 3429037, 3539101, 3542533, - 3567481, 3568661, 3605429, 3656449, 3763801, 3828001, 3898129, 3911197, 3985921, 4072729, - 4181921, 4188889, 4209661, 4360621, 4469471, 4480477, 4513841, 4835209, 4863127, 4869313, - 4877641, 4922413, 5016191, 5044033, 5095177, 5173169, 5173601, 5176153, 5256091, 5271841, - 5284333, 5351537, 5489641, 5590621, 5672041, 5919187, 6027193, 6118141, 6140161, 6159301, - 6189121, 6226193, 6233977, 6236257, 6278533, 6334351, 6368689, 6386993, 6631549, 6658669, - 6779137, 6787327, 6836233, 6952037, 6955541, 6998881, 7017193, 7232321, 7306261, 7306561, - 7429117, 7462001, 7674967, 7725901, 7759937, 7820201, 7883731, 8036033, 8095447, 8239477, - 8384513, 8534233, 8725753, 8727391, 8902741, 9006401, 9056501, 9073513, 9131401, 9345541, - 9371251, 9439201, 9480461, 9533701, 9564169, 9567673, 9588151, 9591661, 9729301, 9774181, - 9863461, 10024561, 10084177, 10323769, 10331141, 10386241, 10425511, 10610063, 10700761, 10712857, - 10763653, 10974881, 11081459, 11115037, 11335501, 11541307, 11585293, 11592397, 11777599, 12032021, - 12096613, 12263131, 12322133, 12327121, 12599233, 12854437, 13057787, 13338371, 13446253, 13500313, - 13635289, 13694761, 13747361, 13773061, 14026897, 14154337, 14179537, 14324473, 14469841, 14671801, - 14676481, 14709241, 14794081, 14796289, 14865121, 15101893, 15139199, 15162941, 15188557, 15220951, - 15247621, 15479777, 15525241, 15603391, 15621409, 15700301, 15802681, 15976747, 15978007, 16070429, - 16132321, 16149169, 16153633, 16324001, 16349477, 16360381, 16705021, 16773121, 16822081, 16843009, - 16853077, 16879501, 16973393, 17098369, 17116837, 17134043, 17208601, 17236801, 17327773, 17375249, - 17405537, 17585969, 17870561, 18067501, 18073817, 18366937, 18443701, 18454921, 18535177, 18653353, - 18740971, 19328653, 19384289, 19404139, 19471033, 19607561, 20261251, 20417311, 20647621, 20968501, - 21042001, 21303343, 21306157, 21359521, 21397381, 21400481, 21623659, 21654533, 22075579, 22087477, - 22369621, 22591301, 22669501, 22711873, 22849481, 22953673, 23247901, 23382529, 23464033, 23577497, - 23634181, 23734901, 23828017, 23872213, 23963869, 24214051, 24356377, 25080101, 25150501, 25276421, - 25326001, 25457833, 25629913, 25696133, 25768261, 25909453, 26280073, 26377921, 26821601, 26840269, - 26877421, 26886817, 27108397, 27118601, 27219697, 27271151, 27279409, 27331921, 27380831, 27392041, - 27409541, 27491237, 27509653, 27664033, 27798461, 27808463, 28325881, 28527049, 28572961, 29111881, - 29214541, 29581501, 30022129, 30090817, 30185569, 30219757, 30295141, 30338593, 30388753, 30418957, - 30576151, 30662497, 30740417, 30881551, 30894307, 31040833, 31166803, 31436123, 31735621, 31759121, - 32091781, 32095057, 32168117, 32285041, 32497921, 32676481, 33146717, 33298337, 33600533, 33627301, - 33704101, 33872593, 34003061, 34043101, 34124641, 34540801, 34856167, 34944001, 35576599, 35703361, - 35820937, 35851037, 36291193, 36307981, 36861901, 36919681, 36974341, 37109467, 37376509, 37439201, - 37964809, 37988497, 38010307, 38046817, 38118763, 38210323, 39465091, 39512773, 39655153, 39684157, - 40165093, 40238797, 40315441, 40361197, 40629601, 40782589, 40827473, 40987201, 41121433, 41568101, - 41604109, 41642681, 41662297, 41840809, 42009217, 42485119, 42623017, 42984589, 43224397, 43363601, - 43661257, 44070841, 44314129, 44465221, 44482901, 45100177, 45175201, 45219329, 45414433, 45819541, - 45879941, 46094401, 46325029, 46386589, 46469809, 46517857, 46679761, 46860001, 47220367, 47903701, - 47918581, 48064021, 48191653, 48269761, 48316969, 48400753, 48448661, 48551161, 48563089, 49075417, - 49303801, 49411801, 49459801, 50155733, 50201089, 50443201, 50523661, 51030601, 51129781, 51302353, - 51500521, 52072021, 52119289, 52204237, 53283169, 53399449, 53656021, 53675623, 53695721, 53711113, - 54029741, 54449431, 55109401, 55176097, 55318957, 55729957, 56052361, 56420033, 56479897, 56810137, - 57762433, 58003213, 58422409, 58449847, 58509977, 58679941, 58755877, 59631211, 59840537, 59913157, - 59953741, 60155201, 60352921, 60547831, 60566431, 60581401, 60696661, 60738257, 60957361, 61201009, - 61219789, 61377109, 61832377, 62756641, 63001801, 63002501, 63065281, 63167743, 63318169, 63328469, - 63346999, 63388033, 64148717, 64605041, 64735897, 65144501, 65254393, 65301013, 65350801, 65359477, - 66096253, 67194401, 67642513, 67928221, 68102641, 68154001, 68165761, 68512867, 68621701, 68839597, - 69030901, 69128641, 69176647, 69228967, 69231061, 69485281, 69612061, 69885649, 70149631, 70463489, - 70593931, 70728121, 71079661, 71734417, 72498253, 72543547, 73562833, 73645001, 74411131, 74927161, - 75140137, 75565873, 76725091, 76745101, 77533123, 77648941, 77812153, 77817979, 78939089, 79398901, - 79411201, 79417801, 79464533, 79786523, 80142761, 80146909, 80375707, 80556337, 80687881, 80891009, - 81433591, 81954133, 82273201, 82506439, 82870517, 82929001, 83083001, 83103329, 83204801, 84164033, - 84350561, 84421081, 84487457, 84998503, 85328717, 85519337, 85823401, 86027329, 86438857, 86530621, - 86999837, 87499651, 87694261, 88256449, 88368853, 88661861, 89308771, 89784581, 90270613, 90278161, - 90341197, 90665789, 90698401, 91433281, 91659283, 92438581, 92625121, 93431521, 93541537, 93571633, - 93643201, 93677761, 93926197, 94316401, 94502701, 95451361, 95452781, 96135601, 96618397, 96791881, - 96888641, 96895441, 96904081, 96925921, 97255801, 97496449, 97796953, 97863529, 97924217, 99036001, - 99115297, 99486889, 99789673, 99898801, 100463443, 100618933, 100943201, 101152133, 101218921, 101270251, - 101276579, 101649241, 102004421, 102678031, 102690677, 102690901, 103301633, 104078857, 104524421, 104988673, - 105305443, 105919633, 106485121, 106622353, 106743073, 107360641, 107543333, 108596953, 109231229, 109437751, - 109541461, 109879837, 110135821, 110139499, 110312773, 110413333, 110717861, 111370141, 111654401, 112032001, - 112402981, 112828801, 113589601, 113605201, 113730481, 113892589, 114305441, 114329881, 114701341, 114842677, - 114910489, 115039081, 115174681, 115497901, 115804501, 115873801, 116090081, 116321617, 116617289, 116682721, - 116696161, 116998669, 117987841, 118466401, 118901521, 119092801, 119204809, 119261113, 119327041, 119558011, - 119743537, 119940853, 120296677, 120517021, 120838609, 121062001, 121374241, 121472359, 121609489, 122166307, - 122396737, 122941981, 123481777, 123671671, 123877081, 123987793, 124145473, 124630273, 124818601, 125284141, - 125686241, 125848577, 126132553, 127050067, 128079409, 128124151, 128396921, 128468957, 128665319, 128987429, - 129205781, 129256273, 129357061, 129461617, 129524669, 130556329, 130693393, 130944133, 131023201, 131567929, - 131938561, 132332201, 132338881, 132440521, 132575071, 133216381, 133302781, 133467517, 133800661, 134696801, - 134767153, 134868029, 135263269, 135296053, 135308881, 135945853, 135969401, 136043641, 136661201, 136722433, - 137415821, 137763037, 138030721, 138403981, 138828821, 139295701, 139487041, 140197051, 142525333, 142922413, - 143106133, 143168581, 145348529, 146156617, 146272901, 146659801, 146843929, 146884393, 147028001, 147287141, - 148109473, 148171769, 148910653, 149389633, 150379693, 150960239, 150988753, 151533377, 151589881, 152716537, - 152922001, 152991841, 153369061, 153589801, 153754873, 153928133, 154287451, 154513633, 154944533, 155203361, - 156114061, 156532799, 157069189, 157368661, 157405249, 157725829, 158068153, 158192317, 158397247, 158496911, - 158544401, 158895281, 160348189, 160378861, 160491329, 160587841, 160672201, 160730389, 161184013, 161216021, - 161289649, 161304001, 161423377, 162026869, 162067441, 162690481, 162771337, 162776041, 163442551, 163954561, - 164111281, 165061909, 165224321, 165938653, 166082309, 166339057, 166406561, 166827943, 167579497, 167582377, - 167692141, 167881121, 168566501, 169655641, 170640961, 170782921, 170856533, 171454321, 172116181, 172436713, - 172947529, 173401621, 174479729, 176030977, 176597821, 176609441, 176977921, 177167233, 177254533, 177693521, - 177927641, 177951973, 178837201, 178956971, 179083601, 179285137, 179820257, 180115489, 180497633, 180703451, - 181285001, 181285537, 181542601, 181647497, 182383111, 183677341, 184411567, 185653333, 186183469, 186393481, - 186983521, 187050529, 187667969, 187761241, 188516329, 188985961, 189714193, 189738361, 189941761, 190212181, - 190382161, 190913297, 191233813, 191648161, 191981609, 192346153, 192857761, 193330237, 193638337, 193949641, - 194556451, 196035001, 196049701, 196231393, 198982759, 199674721, 200143351, 200753281, 201261061, 202130197, - 202156813, 202538857, 203505697, 204280501, 204582457, 204766381, 205057561, 206304961, 206453509, 206504033, - 206529737, 207008569, 207030541, 207132481, 207477001, 207618781, 208051201, 208969223, 209246701, 209404369, - 209990881, 210592873, 210842113, 213035761, 214038533, 214110541, 214852609, 214858717, 215436241, 216821881, - 217123069, 217875571, 218603617, 218642029, 218947121, 219621781, 220531501, 220883521, 221368153, 221415781, - 221884001, 222010721, 222630193, 223449463, 223625851, 223782263, 224074369, 224136013, 224769241, 224957893, - 225853633, 226359547, 226450297, 227132641, 227444101, 227475481, 228652201, 228842209, 228988033, 229589413, - 230357761, 231383461, 231405701, 231927781, 232114433, 232460821, 232771501, 233110081, 234869009, 235426913, - 235928071, 237791143, 238001653, 238833421, 240068041, 240371713, 240694513, 240785047, 241505377, 242067841, - 242650717, 242860069, 243583201, 243955141, 244883981, 245006623, 245950561, 246099317, 246282511, 246434761, - 246658441, 247318957, 247321301, 247416101, 249582481, 250436033, 250958401, 250988173, 251528401, 251663837, - 251855893, 252853921, 253610281, 253893397, 255416897, 256831433, 257590661, 258020473, 258043229, 258234401, - 258944401, 259763093, 259765747, 260156101, 260518801, 260736341, 260963389, 261186001, 261703417, 262979501, - 263428181, 264269449, 264384469, 265020001, 265584133, 265735969, 265836161, 266790481, 266925601, 270525737, - 271272569, 271763467, 271826629, 271950829, 273361789, 273480637, 274701913, 274810241, 274919401, 275283401, - 275619961, 276018913, 276131137, 276542401, 276638321, 277787141, 278943061, 279377281, 280885153, 282253141, - 282471853, 282769771, 283900961, 284166877, 284301751, 284736091, 284834299, 285820501, 286316801, 287160301, - 287449091, 287715121, 288099001, 288117721, 288735277, 290643601, 290706781, 290953921, 291088513, 291461633, - 292153681, 292290181, 292433321, 292902481, 293346637, 293847721, 293938261, 295419097, 295743017, 297624961, - 297798961, 298212601, 299367877, 299736181, 301413001, 302635351, 304080001, 307629401, 307694323, 307972801, - 308483209, 309666361, 310474249, 310978027, 311177213, 311411629, 311655829, 311671361, 312408113, 312614021, - 314184487, 315034513, 315351521, 317137969, 317365933, 317641171, 317796119, 319053281, 319374577, 319440769, - 319726177, 320326003, 321324589, 321850849, 322469701, 322941881, 324477697, 325028089, 325352101, 325546873, - 326266051, 326405713, 326469137, 326628721, 326694301, 326695141, 327073601, 327093409, 327398009, 328302901, - 329153653, 329769721, 330198331, 330759617, 331658081, 331934989, 337135501, 337420679, 337665901, 337783981, - 338125537, 338458807, 338914369, 339195097, 339492169, 339794641, 341958121, 341994131, 343017529, 343052833, - 344201441, 344255551, 344776301, 346080391, 348989101, 349752913, 350031973, 350244577, 351058753, 351177769, - 352802803, 352932337, 353815801, 353932801, 354062809, 356604421, 356836819, 357348601, 357872971, 358416577, - 359394751, 359727073, 360145633, 360375181, 360787771, 361307521, 361312337, 362569201, 363170837, 363430637, - 364550761, 365077373, 365231401, 366487201, 366532321, 366652201, 367559501, 367632301, 368016949, 368476501, - 369667561, 371011801, 371611153, 372167101, 373012777, 373533617, 373669453, 373906513, 374346361, 374988661, - 376957153, 377192353, 377334497, 377458849, 377806687, 377869031, 378792649, 379732501, 380137633, 382304161, - 384100001, 385175113, 385319089, 387072661, 388695301, 390609941, 390612221, 391014937, 392679737, 393611653, - 394723177, 396864469, 399156661, 399302581, 399647221, 400385701, 400557109, 401100881, 403095967, 403293313, - 405739681, 405782623, 407737201, 407889161, 409302001, 409458241, 410613809, 410680357, 411618241, 411851389, - 412836689, 413138881, 413429801, 413778817, 414216461, 414368641, 415200361, 415204501, 415476343, 416964241, - 417767201, 417779909, 418044563, 418226581, 418616161, 418617281, 418667401, 419184481, 420607441, 421942951, - 422429041, 422928101, 423384001, 423465001, 424175761, 424411501, 424431541, 425967301, 426174101, 426219649, - 426770437, 426783811, 427294141, 428180191, 428758201, 429135841, 429509837, 430046857, 430381921, 430646401, - 430733701, 432227449, 434042801, 435016187, 435358657, 435993301, 436465501, 437247841, 437462101, 437597101, - 437866087, 439309261, 441354497, 441650591, 441758461, 442050577, 442181291, 442543553, 444660421, 445429693, - 446414621, 446619617, 449501761, 450807481, 450866021, 450872573, 452990401, 453366029, 453967739, 454745773, - 455198563, 457274161, 457320533, 459785089, 460251733, 460585861, 461151121, 461272267, 461329601, 462587329, - 462639409, 462701513, 464012033, 464955857, 465505633, 466290949, 466758181, 467100937, 468410113, 468950021, - 470120257, 470268137, 470644021, 471535373, 471664513, 472814413, 473581057, 474892741, 474970501, 474983881, - 475723849, 478614067, 479962009, 480668347, 481153501, 481239361, 482488393, 482824669, 482921297, 483006889, - 483029821, 483945601, 484200289, 486063001, 486902929, 487896601, 488104681, 488169289, 488585521, 488656981, - 489994201, 490950461, 491738801, 493108481, 494288677, 495909871, 496109729, 496560349, 497148599, 497285713, - 498662561, 498706651, 498905189, 500747293, 501172241, 501472333, 502686713, 504870241, 505473263, 505532773, - 505798213, 506349421, 507142567, 507323521, 508606771, 509302873, 509551201, 510925609, 511098521, 511215521, - 511611673, 512330281, 514738981, 516045197, 516259657, 516764063, 517662001, 518216201, 518548801, 521501473, - 522390109, 522758233, 523756711, 526067821, 526359289, 526686889, 528013333, 528043753, 528220117, 530630701, - 531095029, 531681281, 532126801, 532758241, 532800133, 533429881, 534782293, 535252867, 535428577, 535517581, - 536003333, 536114197, 536342419, 536870911, 540207097, 540621181, 540654409, 540680141, 542497201, 542536457, - 544861633, 545550433, 545622401, 546102481, 546117301, 546322201, 548080513, 548989561, 549308761, 550132741, - 550230409, 550635373, 550853137, 551313001, 552573793, 553027201, 554487121, 554599051, 554964001, 555321007, - 555465601, 556001377, 556069849, 556095433, 556114609, 557165209, 558235109, 558900821, 558977761, 561448487, - 562367821, 563298061, 563947141, 564298489, 564689381, 565664761, 565707061, 567358513, 567596401, 568902001, - 568967221, 569332177, 569495809, 570941881, 572123521, 572228929, 572430769, 572567353, 572936869, 573817861, - 573862021, 574998841, 575326033, 576724219, 577210181, 577352641, 577613261, 579606301, 579956653, 581618143, - 582389641, 582799951, 585261637, 586706821, 587343541, 588049001, 591242653, 591822001, 592467451, 592468777, - 593682169, 593728489, 595405201, 595590841, 597537361, 597717121, 599135767, 599945293, 600893921, 601606487, - 602379181, 604584221, 605454917, 605961049, 606872449, 607148653, 607750681, 608421637, 608917753, 609361567, - 609813781, 611097401, 611374453, 611770513, 611812321, 611817421, 612006253, 613849601, 614742241, 615361183, - 615760133, 615895897, 616280897, 617087701, 619239457, 619365121, 619480601, 620169409, 620544961, 620755537, - 621769669, 622137601, 623735953, 624303241, 624732421, 625060801, 625482001, 626717471, 627886657, 628868467, - 629134081, 630496621, 630622753, 630811513, 631767943, 631974613, 633289807, 635155291, 635291077, 635319361, - 636287653, 636337073, 636936697, 638502913, 638837761, 639305921, 639807781, 640650931, 640977373, 643036321, - 643316461, 643552909, 644004817, 644453633, 644457551, 644731357, 644900257, 645556481, 648056449, 648328801, - 651011329, 651064681, 651151801, 651514753, 652469641, 653235841, 653260633, 655264369, 657732349, 659526601, - 659846021, 660095641, 660754117, 661122881, 661207177, 662134201, 663760681, 665462081, 668498321, 670976641, - 670987021, 671716921, 672103001, 672108193, 673778827, 675260477, 676359391, 678481693, 680983817, 681019921, - 681124207, 681303241, 682528687, 683316001, 683362681, 684350833, 686059921, 687741401, 689537441, 690035713, - 690562601, 691131349, 692535637, 693456521, 694116893, 696042901, 696321949, 696998251, 697821857, 698192041, - 698819711, 702683101, 705303457, 705351583, 706728377, 707691601, 709409993, 710382401, 710617861, 710721001, - 714490481, 717096641, 717653129, 717831211, 720767521, 722955773, 724160251, 724969087, 725508241, 731276521, - 732805681, 734166217, 736668013, 739444021, 739576801, 740988151, 741182401, 741214237, 742017181, 742550401, - 744500641, 745493761, 745745461, 746331041, 747406801, 748638001, 749172821, 749640161, 750632137, 751226401, - 751705597, 752186593, 753233717, 753574537, 753594001, 754020361, 754874257, 756205633, 756271909, 756980137, - 758581651, 758687581, 758901701, 759252367, 759266621, 759638881, 762699649, 763907741, 764033999, 764240611, - 765378241, 766303693, 766823797, 770201221, 770909107, 770937931, 771043201, 771337891, 772495777, 773131927, - 773807401, 775368901, 775896181, 776443769, 777218989, 781471001, 782823281, 784450393, 784777393, 784783477, - 784966297, 787085857, 787209277, 788046901, 788931361, 789082001, 790453049, 791118043, 792144161, 792145729, - 794201333, 794399041, 794937601, 795064909, 796072003, 796200901, 796560703, 797418997, 797834017, 799162561, - 799630753, 799898833, 799916101, 801093011, 801227269, 801866647, 804978721, 805505957, 805771501, 807115753, - 807218413, 808214161, 809790881, 810023881, 810455101, 811110301, 811478533, 811607777, 811730923, 815430533, - 815796413, 816024161, 816215401, 816549121, 817832329, 818401321, 819466201, 819743233, 822018961, 822531841, - 824389441, 826004467, 829512001, 830664451, 831933901, 832048447, 832127489, 832169857, 833610751, 837766217, - 839268139, 839280691, 839908217, 840749761, 841217653, 841660961, 842785841, 842824981, 842960981, 843161887, - 844545271, 845376533, 846961321, 848090377, 848755969, 849548671, 852432769, 854094781, 854868257, 855734401, - 857100421, 857902861, 858687103, 859096477, 860334301, 862082677, 862678081, 863196181, 863609113, 863984881, - 865242841, 867022747, 867110501, 867638201, 868088341, 868111597, 868691401, 870985223, 871157233, 871195561, - 871908481, 876850801, 877542481, 878492941, 878940833, 879995689, 880870513, 880922657, 883276549, 884304037, - 884952001, 886180429, 887795221, 888868441, 892740853, 893692819, 894264337, 896901461, 897087361, 897283213, - 899019353, 900736411, 901848301, 902566501, 903108821, 903390643, 905040953, 907378669, 907670501, 907711561, - 908005249, 910202509, 910867481, 911484421, 914348737, 914906539, 920375821, 920696653, 921858631, 922845241, - 923437213, 926756881, 927106561, 927877001, 929159941, 930530701, 932148253, 933729421, 935794081, 936421141, - 937675393, 938376181, 939947009, 940123801, 941056273, 941734657, 943271569, 944832533, 946034057, 946787377, - 947878081, 949317217, 949697233, 952893881, 954924013, 957600541, 957631249, 958131157, 958735681, 960269377, - 960946321, 962442001, 962489557, 962523169, 964412837, 965501857, 967266451, 967287751, 967790401, 968283247, - 968413217, 968751241, 969528337, 970586713, 971975071, 974113601, 974471243, 974774401, 975576281, 976396961, - 977483449, 979363153, 980056507, 980725201, 981484561, 983456377, 984133441, 984252001, 985052881, 985075681, - 987842101, 994133479, 995586373, 995650921, 997836841, 998489017, 998590601, 998596741, 998724481, 999828727, - 1002261781, 1003062061, 1005402133, 1005833971, 1006800829, 1008777001, 1008839999, 1009025263, 1009140161, 1011319501, - 1011333061, 1011570457, 1011909271, 1012438391, 1013833153, 1015339441, 1015626151, 1017748057, 1020515761, 1021281301, - 1022336611, 1024041853, 1024123501, 1024605121, 1025035129, 1026738161, 1027744453, 1028494429, 1034252929, 1034958601, - 1040234231, 1049584313, 1050102901, 1050535501, 1054999441, 1055009117, 1056121453, 1057426651, 1063212481, 1065508321, - 1065602281, 1066972301, 1069388497, 1070639389, 1070941987, 1071512749, 1071643249, 1072898711, 1073159281, 1073288581, - 1073484823, 1075100041, 1077133397, 1078467589, 1081798061, 1082472553, 1084241341, 1084444481, 1090858081, 1093150081, - 1093352833, 1093526353, 1094042321, 1097416321, 1098743563, 1100624857, 1101623381, 1101673501, 1102573501, 1102750013, - 1104194521, 1105038871, 1106529761, 1106580817, 1106595493, 1107138961, 1108135381, 1109304913, 1110582947, 1111205873, - 1111939201, 1112671603, 1114277221, 1116379301, 1117202557, 1117785881, 1117828001, 1117890019, 1119412321, 1120076281, - 1120981021, 1121176981, 1123406047, 1123625501, 1123727617, 1124396521, 1125038377, 1127040769, 1130933429, 1134367777, - 1138289041, 1138607233, 1139137057, 1140573601, 1142466151, 1147434289, 1148578201, 1150229761, 1151670001, 1153164097, - 1153440289, 1154343961, 1154691409, 1154987209, 1155939709, 1156761911, 1156993373, 1157839381, 1159421509, 1160844821, - 1163098249, 1163227759, 1164218641, 1165717129, 1166475601, 1166598217, 1168221121, 1168256953, 1168492417, 1173229201, - 1173545533, 1174300093, 1180970407, 1181566219, 1183338241, 1184554801, 1186325981, 1187235193, 1191153937, 1191216133, - 1192314817, 1192412033, 1192903531, 1193229577, 1193557093, 1195524181, 1196852273, 1198650961, 1198880261, 1200456577, - 1200778753, 1202142061, 1204205449, 1205606533, 1205772499, 1209998077, 1210393801, 1210562701, 1210653541, 1213619761, - 1217181061, 1217823517, 1217924159, 1219816261, 1219858921, 1220114377, 1221127013, 1222861271, 1223531677, 1223941657, - 1225128829, 1226230297, 1226855293, 1227220801, 1229491063, 1229751667, 1230446653, 1231362793, 1232445677, 1234125721, - 1234646533, 1235188597, 1235864033, 1236313501, 1236442421, 1238825569, 1242171349, 1242858317, 1249166881, 1249785941, - 1250656621, 1252236421, 1254277909, 1255665613, 1257102001, 1258903981, 1260332137, 1263293281, 1264145401, 1265477791, - 1266003461, 1266273793, 1266425101, 1267345081, 1269295201, 1269835201, 1270193401, 1270489621, 1270667353, 1272558739, - 1272866167, 1282447477, 1282568741, 1285636801, 1286298133, 1286298263, 1296613501, 1297443913, 1299072721, 1299784141, - 1299963601, 1301509249, 1301926081, 1302745481, 1306836001, 1307004641, 1307520469, 1307823661, 1308758533, 1308998741, - 1309723213, 1309983901, 1310329567, 1311255661, 1311616153, 1312332001, 1312573123, 1313396221, 1315858381, 1316169541, - 1318126321, 1318717531, 1319978701, 1319992181, 1320793813, 1321058213, 1323668917, 1325172421, 1325329297, 1328256247, - 1329174601, 1329431689, 1331973329, 1341010577, 1341926401, 1343575381, 1344597577, 1344975721, 1345514101, 1345523401, - 1347387361, 1348964401, 1350685001, 1351126261, 1352453257, 1353051517, 1356241321, 1356328121, 1357459183, 1362463807, - 1362515701, 1362742561, 1365662917, 1366587661, 1366608377, 1368769681, 1371908137, 1372681861, 1375322101, 1376799577, - 1378646179, 1379464633, 1382453333, 1383283129, 1385656829, 1386705433, 1388972353, 1389353941, 1389975149, 1391890033, - 1393851553, 1394640941, 1394746081, 1394942473, 1397357851, 1398883201, 1400859847, 1401840833, 1404008369, 1404253369, - 1406826241, 1406851249, 1409372779, 1413803197, 1414154827, 1414529533, 1415969101, 1417986901, 1421475031, 1424503849, - 1425860101, 1426319563, 1426534201, 1427771089, 1428966001, 1432354901, 1435091377, 1438648993, 1440231941, 1440922891, - 1441139641, 1441678411, 1442945689, 1443388481, 1443742273, 1446298309, 1446434677, 1446818651, 1448921633, 1451635201, - 1454282449, 1454445413, 1456527461, 1457378449, 1461307717, 1463065501, 1463178817, 1463992661, 1464568381, 1465908193, - 1465945417, 1468540477, 1468824787, 1469059481, 1469960377, 1470080501, 1470650851, 1471628401, 1472221921, 1473580001, - 1477289941, 1481626513, 1482274513, 1482876673, 1483873861, 1483918801, 1485061471, 1486564301, 1493114149, 1495190699, - 1497221281, 1497965713, 1499971457, 1499989177, 1500142001, 1501165097, 1502171117, 1502403121, 1503240559, 1503705601, - 1504139521, 1504832033, 1507746241, 1509156013, 1510870241, 1511558533, 1515175087, 1515785041, 1517039371, 1518014689, - 1518290707, 1520190341, 1521221473, 1522302121, 1526732803, 1529648231, 1529819971, 1530495289, 1532419099, 1532569681, - 1532755369, 1533343261, 1534063081, 1535020133, 1536112001, 1536251047, 1536883357, 1537433899, 1537641691, 1538012449, - 1539583921, 1539804001, 1540454761, 1540550413, 1541047813, 1541849761, 1541955409, 1544145121, 1545019813, 1545177581, - 1546106773, 1546340401, 1546508057, 1547140841, 1547543161, 1547712601, 1550924873, 1554270481, 1557118081, 1560312001, - 1560620041, 1561800833, 1565893201, 1566594551, 1567830241, 1568916311, 1574362441, 1574601601, 1577983489, 1578009401, - 1580449201, 1581576641, 1581714481, 1582783777, 1583230241, 1583658649, 1586436193, 1587650401, 1590394313, 1593706201, - 1595647351, 1595887921, 1598197201, 1602517949, 1603765021, 1603810561, 1603994701, 1609916491, 1609935913, 1612121473, - 1614508267, 1617795181, 1617921667, 1619447741, 1620646177, 1627103521, 1627898401, 1628692201, 1630062253, 1630307617, - 1631314609, 1632286673, 1632513601, 1633044241, 1636185601, 1637434657, 1637436457, 1637930893, 1638294661, 1639351981, - 1639846391, 1641971701, 1642814653, 1644637051, 1645413001, 1647225529, 1648076041, 1649430889, 1650265549, 1650682153, - 1654940509, 1655660761, 1656229921, 1656280033, 1656917377, 1659009601, 1661202113, 1668037621, 1668926629, 1669893661, - 1671603667, 1671714241, 1672125131, 1674091141, 1674658133, 1675978193, 1678274581, 1679130641, 1680901381, 1683174533, - 1685433413, 1686001861, 1687248001, 1691745821, 1692605041, 1694128129, 1695158921, 1696893101, 1698707377, 1699279441, - 1700250049, 1709909293, 1710753001, 1712392321, 1714322377, 1716160321, 1716714793, 1716774481, 1718013133, 1718088301, - 1719197621, 1721061497, 1721986313, 1722007169, 1722685777, 1725675451, 1726372441, 1731048937, 1731995497, 1732924001, - 1734059291, 1734285601, 1735071913, 1736481601, 1738687469, 1740214841, 1742288881, 1742815621, 1743166441, 1744605097, - 1746692641, 1746721681, 1749124829, 1750412161, 1754818561, 1757148121, 1760014561, 1766984389, 1767234613, 1769091241, - 1769267761, 1770236893, 1771303801, 1772267281, 1773582977, 1776439261, 1776820033, 1779649381, 1779892577, 1784306273, - 1784638309, 1785843547, 1786005521, 1787934881, 1790023861, 1791426787, 1792442737, 1792588813, 1794814103, 1801558201, - 1801774081, 1802510669, 1803768091, 1804906517, 1805947313, 1809888967, 1816408273, 1817067169, 1819829749, 1820306953, - 1821514633, 1828682101, 1828887061, 1831258601, 1835114401, 1837156049, 1837599769, 1839568981, 1841034961, 1841099261, - 1841479501, 1844028961, 1846171781, 1847811673, 1849964117, 1850233897, 1850598961, 1852496761, 1853926777, 1854084649, - 1854940231, 1856689453, 1857221281, 1858098497, 1858197961, 1860373241, 1861026133, 1861880689, 1862880401, 1866409861, - 1867906721, 1868682241, 1871987041, 1872937057, 1873177693, 1874634721, 1874849929, 1878691753, 1879111697, 1879623157, - 1879775501, 1883509633, 1883785681, 1885915841, 1894909141, 1894955311, 1897700113, 1899081757, 1899525601, 1900687381, - 1903447841, 1904658913, 1905958891, 1908088001, 1909566073, 1910134309, 1911197947, 1912950241, 1914303841, 1915391521, - 1916987593, 1917397637, 1920301951, 1921309633, 1922092567, 1922687293, 1923224689, 1923311317, 1923845801, 1924201501, - 1925042737, 1928903971, 1929862849, 1930403333, 1930447501, 1930534453, 1930915169, 1934350351, 1938264241, 1940048881, - 1943951041, 1944125633, 1945042181, 1950987193, 1952513369, 1952968753, 1957705177, 1959659857, 1960708261, 1963149553, - 1965007601, 1968002149, 1970065681, 1974474049, 1977257441, 1982123893, 1982826961, 1988071801, 1988713189, 1988835713, - 1988965861, 1989192277, 1991063449, 1995784961, 1995830761, 1996231189, 1996339649, 1997844157, 1998780001, 1999053601, - 1999111801, 1999743661, 2004299641, 2007646961, 2013554869, 2013834961, 2016481477, 2017021333, 2017509601, 2019564769, - 2021392369, 2021884343, 2027675701, 2028279793, 2028631361, 2028812399, 2029830409, 2030600833, 2036224321, 2043173273, - 2049293401, 2050617713, 2052149221, 2054711381, 2055634561, 2057267941, 2057835781, 2058072041, 2059739221, 2062612033, - 2068867841, 2070739441, 2072624761, 2076192007, 2081039297, 2081551753, 2082146617, 2083034113, 2083997441, 2085453649, - 2085882661, 2086645009, 2093300401, 2095627153, 2096046457, 2097317377, 2100292841, 2101470541, 2101744837, 2104994449, - 2106147457, 2107148761, 2114643217, 2115769633, 2115986557, 2116483027, 2116541221, 2117031263, 2117555641, 2118621097, - 2120096161, 2123601751, 2124078653, 2124691213, 2127197489, 2128104001, 2129304997, 2130134533, 2131004737, 2131811501, - 2140699681, 2140771609, 2141340833, 2144961253, 2147418113, 2147429509, 2152627801, 2154446641, 2155416251, 2156151313, - 2164282177, 2168431201, 2170282969, 2172155819, 2173499329, 2173540951, 2173579801, 2175126601, 2175406201, 2175646177, - 2177374321, 2177645557, 2178082901, 2178939221, 2180221201, 2182281601, 2182802689, 2185362233, 2187717761, 2193980881, - 2199617701, 2200115713, 2201924341, 2202101761, 2202205897, 2203649197, 2203856497, 2206095589, 2210578759, 2213431729, - 2216960929, 2217879901, 2219072017, 2224252801, 2229468697, 2231332357, 2233031701, 2240507821, 2241880033, 2241982009, - 2244932281, 2245519981, 2246762899, 2248354153, 2251732033, 2254314241, 2254757077, 2256197761, 2256748777, 2256751837, - 2262861901, 2269307587, 2274584089, 2283289681, 2284416181, 2289251669, 2289624793, 2290316377, 2290910257, 2291205461, - 2292068143, 2295209281, 2296995121, 2299190401, 2300628601, 2300795353, 2301745249, 2304120001, 2308966661, 2309241601, - 2309405617, 2311558021, 2311575001, 2315137261, 2320527613, 2323147201, 2324867399, 2329584217, 2330569541, 2331181621, - 2335341601, 2338157597, 2338728001, 2340460487, 2345907961, 2347597981, 2352371251, 2354453561, 2355230749, 2355320101, - 2355622721, 2355649921, 2355735089, 2358534361, 2360261989, 2370771181, 2370928337, 2371350101, 2372976563, 2374232977, - 2375415841, 2377166401, 2378309041, 2381782597, 2382678101, 2383164577, 2385574201, 2389072321, 2389544977, 2393708761, - 2394311233, 2398393661, 2404912501, 2411128441, 2412172153, 2412675721, 2413973071, 2422296241, 2423401681, 2425249601, - 2428648967, 2428870753, 2428986913, 2429407961, 2430697513, 2431136401, 2431144801, 2432761633, 2432860273, 2433791593, - 2434964321, 2434974433, 2435091221, 2436691321, 2437907779, 2438778413, 2442050353, 2442454561, 2443708961, 2444950561, - 2448039497, 2448374689, 2453473049, 2454285751, 2456536681, 2457846161, 2463713281, 2471205361, 2473120961, 2473189441, - 2473823353, 2474308069, 2474676949, 2476283239, 2477814193, 2478643907, 2480147521, 2480343553, 2482435981, 2482682131, - 2484408301, 2486017249, 2488420801, 2488591117, 2492480233, 2494660033, 2494984321, 2495834329, 2499327041, 2501012599, - 2501771329, 2502525637, 2504008609, 2506529257, 2506733189, 2507121037, 2508178843, 2513230891, 2516684801, 2519297089, - 2525070241, 2526566041, 2528291341, 2529410281, 2529827821, 2529854713, 2530351561, 2532630787, 2533465661, 2533797017, - 2535516173, 2537105761, 2539406281, 2539736257, 2540469901, 2541660367, 2542479481, 2544590161, 2545934077, 2548051801, - 2550139253, 2550780277, 2551365769, 2552418761, 2553272929, 2555391481, 2561945401, 2564536201, 2565186137, 2570087521, - 2571180247, 2575060949, 2575737361, 2577345541, 2582092189, 2582246701, 2582952769, 2583322381, 2584460701, 2588054401, - 2588582089, 2590663681, 2593065721, 2595276353, 2597289241, 2597294701, 2598933481, 2600611861, 2602343521, 2602378721, - 2604465013, 2604803701, 2611122229, 2611461529, 2613382201, 2614688801, 2616180821, 2617563031, 2621080741, 2621977627, - 2622993661, 2624549929, 2625903601, 2626783921, 2627284987, 2630643401, 2632605049, 2634284801, 2634804481, 2634820813, - 2638067881, 2639099233, 2642159809, 2642582251, 2646751249, 2646790033, 2648662777, 2649907201, 2650820329, 2651507713, - 2654716321, 2656494271, 2658630913, 2658696301, 2659265701, 2668095181, 2668469431, 2670972949, 2672605657, 2672651521, - 2676053333, 2677147201, 2677821121, 2678785621, 2681041843, 2682823681, 2683742491, 2684284441, 2687655169, 2688124001, - 2689427281, 2690408533, 2690867401, 2693739751, 2695115473, 2700818017, 2700891839, 2701878941, 2704957909, 2706863833, - 2707661501, 2716157989, 2716275007, 2717428033, 2719319513, 2721666817, 2721721939, 2723859001, 2725357249, 2733156029, - 2736316301, 2738184697, 2740336561, 2744329909, 2746021741, 2753333227, 2753538001, 2759392633, 2765323397, 2766006253, - 2767672189, 2769080161, 2769602333, 2774295577, 2777887297, 2778304273, 2779477741, 2781117721, 2781226477, 2786028337, - 2787998641, 2789218909, 2800352011, 2805762961, 2809635901, 2812672981, 2814748201, 2823570433, 2824256377, 2824804693, - 2824854913, 2828205397, 2832384133, 2832743713, 2837697773, 2837917633, 2840634109, 2840871041, 2841190381, 2847894377, - 2848466281, 2848722131, 2855046421, 2855071801, 2855512909, 2862066481, 2865483601, 2866005139, 2866527841, 2870377309, - 2871536561, 2872527733, 2872948321, 2874382853, 2877769501, 2881429741, 2882370481, 2885594497, 2887955533, 2890316801, - 2890414873, 2892426029, 2894667781, 2895004927, 2899294889, 2903776129, 2915953633, 2916247819, 2918295451, 2920691161, - 2923042141, 2924158001, 2929062533, 2929106753, 2930831641, 2931708097, 2932327549, 2936227603, 2936958181, 2941174897, - 2941343633, 2944555681, 2944677961, 2945208001, 2945549881, 2951136343, 2956724317, 2957320351, 2965700233, 2967053953, - 2968206601, 2974506841, 2975377429, 2976930001, 2978766341, 2980689601, 2986025677, 2987414977, 2990152901, 2993462713, - 2993495041, 2994098281, 2994415201, 2998202353, 2998919873, 3000688381, 3001561441, 3002647829, 3004443679, 3009628301, - 3011421841, 3014101261, 3015502181, 3016957381, 3017444761, 3018147217, 3018576689, 3019916461, 3025350343, 3026575553, - 3028586471, 3030393901, 3033332641, 3034402681, 3034817209, 3035375047, 3036079729, 3037295801, 3037781251, 3038880473, - 3039681457, 3041984353, 3042630533, 3048159841, 3050190163, 3056100623, 3056160929, 3057886591, 3058670677, 3059397793, - 3063685633, 3065998717, 3076505209, 3077122133, 3079496551, 3082054697, 3082068013, 3083053387, 3083537689, 3083884651, - 3088408429, 3089013313, 3091019777, 3094763851, 3099670657, 3103800701, 3112974481, 3114125071, 3115667521, 3120445697, - 3122287981, 3129914881, 3133899409, 3135040133, 3143282221, 3145410761, 3150972917, 3156599161, 3156643141, 3157579861, - 3163106953, 3166504273, 3167442721, 3170262409, 3172658653, 3175204531, 3175255717, 3178375201, 3181356263, 3181391641, - 3182606857, 3182655361, 3182891401, 3185472001, 3187035113, 3187421077, 3187939921, 3196397821, 3196431829, 3197565001, - 3197632441, 3197911001, 3197911741, 3199164901, 3205663921, 3207297773, 3208902491, 3212465437, 3215031751, 3217412881, - 3219808411, 3221580281, 3222693421, 3224143441, 3225081473, 3227082823, 3227209057, 3229131137, 3233558021, 3237992101, - 3242533897, 3248236309, 3250348417, 3250700737, 3252148621, 3257334541, 3258647809, 3258892801, 3261114601, 3263097641, - 3263568901, 3263626957, 3264820001, 3265122451, 3267417677, 3268506541, 3268841941, 3270933121, 3271999249, 3272030401, - 3272702497, 3274264033, 3275671969, 3276075709, 3277047649, 3278640289, 3280067129, 3282974857, 3287174129, 3288757249, - 3295362727, 3296403601, 3299246833, 3302322241, 3304307341, 3305829073, 3306686659, 3306957593, 3310858777, 3312489577, - 3312536569, 3313196881, 3315139717, 3320669437, 3323308501, 3323590463, 3323829169, 3328354801, 3332800021, 3334350781, - 3340214413, 3342005633, 3344191241, 3346172189, 3347908801, 3349218881, 3350993969, 3352091557, 3355382857, 3355953001, - 3357417181, 3359737921, 3360511981, 3369139201, 3371024521, 3371452921, 3371693063, 3372667121, 3373086601, 3381052177, - 3381901921, 3385842877, 3386603221, 3387014401, 3387487351, 3389030261, 3395091311, 3399205591, 3399890413, 3402234749, - 3407609221, 3407772817, 3407952169, 3408135121, 3409339393, 3411250081, 3411574801, 3411829693, 3412575097, 3415379701, - 3415832137, 3417522841, 3420143941, 3421845001, 3423222757, 3423580481, 3427050673, 3428133103, 3429457921, 3429982081, - 3430804297, 3432695921, 3432997537, 3433458073, 3434575327, 3435973837, 3440195713, 3443704261, 3449768513, 3450717901, - 3453900913, 3458257741, 3461861761, 3463907761, 3464236901, 3466158361, 3470716657, 3474335437, 3480174001, 3482161261, - 3485747521, 3489958697, 3491763493, 3492178873, 3492883081, 3493262761, 3497607433, 3504132113, 3512030497, 3512291021, - 3512369857, 3513604657, 3516565057, 3519318721, 3524086333, 3525088961, 3529119361, 3529864391, 3532687201, 3533662129, - 3533856913, 3538213381, 3542303047, 3543203333, 3548378341, 3549286001, 3549988261, 3552158521, 3553567057, 3557646401, - 3562963973, 3563340457, 3566428301, 3574891757, 3582711841, 3583249921, 3583604161, 3584800801, 3586833253, 3587553971, - 3589937261, 3590409439, 3593276353, 3594110081, 3596491907, 3596815169, 3598772761, 3602006101, 3605151241, 3611571121, - 3612298321, 3612825221, 3614770573, 3616574081, 3620631169, 3628526287, 3630596257, 3631828481, 3632452741, 3635993089, - 3649116277, 3649965281, 3650158849, 3651572609, 3656355841, 3658730893, 3662387977, 3662503093, 3663084541, 3668926801, - 3669587533, 3672754633, 3677180797, 3679657997, 3682471321, 3685647701, 3685775741, 3692307161, 3695628133, 3697278427, - 3700801861, 3705582073, 3705623281, 3708123301, 3708905341, 3709626961, 3712887289, 3713287801, 3713448769, 3718226401, - 3721486081, 3723410161, 3723699373, 3725016749, 3727828501, 3729097633, 3733761739, 3736293461, 3745192001, 3746101189, - 3749383681, 3751554581, 3751782737, 3754680403, 3756668401, 3759781369, 3760622689, 3760896133, 3762110881, 3767640601, - 3773061337, 3774337201, 3784123501, 3787491457, 3798040471, 3798626833, 3799111681, 3800084401, 3805699501, 3807112123, - 3807308269, 3807749821, 3809018947, 3813919453, 3817561777, 3817706621, 3821233121, 3827035237, 3832807681, 3833208961, - 3842941741, 3846174151, 3846532801, 3847106803, 3850058689, 3852800033, 3863326897, 3865604023, 3867183937, 3874471147, - 3874523017, 3875096893, 3875965417, 3886515361, 3886643801, 3887423437, 3887635753, 3891892421, 3891919417, 3894053311, - 3896079281, 3897241129, 3897869201, 3898906129, 3900327241, 3903711841, 3905533721, 3905876501, 3907577521, 3907752241, - 3912174421, 3914880337, 3914923211, 3915467341, 3915604421, 3915921241, 3918227437, 3922321561, 3926912669, 3929293061, - 3934940833, 3935864017, 3936123601, 3945165841, 3947233201, 3947383201, 3953408801, 3953949421, 3955572001, 3958597301, - 3958930441, 3959578801, 3960728641, 3962037061, 3966350203, 3967343161, 3971095301, 3973556837, 3979485931, 3982017601, - 3987528793, 3987960913, 3991124341, 3992697997, 3997536427, 4005660961, 4007365741, 4011996871, 4015548769, 4017684529, - 4018283501, 4020144133, 4026822577, 4027012021, 4027518961, 4028465873, 4028771849, 4031223841, 4034969401, 4034993269, - 4035498409, 4036395581, 4042538497, 4044601751, 4044884689, 4048493983, 4053267217, 4054039841, 4057195309, 4058433931, - 4059776533, 4060942381, 4061009971, 4064633821, 4067039461, 4067887501, 4068671881, 4071644893, 4075241633, 4075721921, - 4076009857, 4079665633, 4079682361, 4083376067, 4085074909, 4088147617, 4088838913, 4092929149, 4098258707, 4099180801, - 4100934241, 4103745689, 4105691393, 4108970251, 4109461709, 4109711581, 4110320663, 4113013141, 4115891893, 4117058221, - 4117447441, 4121286907, 4127050621, 4129914673, 4133928761, 4135847101, 4136916001, 4137262541, 4138838401, 4139015987, - 4150174393, 4155375349, 4157008813, 4162880401, 4166032873, 4183664101, 4185636781, 4186561633, 4187360341, 4191864013, - 4192060699, 4195843037, 4196323561, 4204344601, 4206006229, 4206295433, 4212105409, 4215885697, 4218900001, 4220122321, - 4232966251, 4234224601, 4237212061, 4243744201, 4244022301, 4244663651, 4247990917, 4250920459, 4251904273, 4255695013, - 4257003353, 4261352869, 4271267333, 4275011401, 4277526901, 4278305651, 4282867213, 4285148981, 4293088801, 4294901761, - } - - primes16 = [65536]byte{ - 2, 1, 1, 2, 1, 2, 1, 4, 3, 2, // 0-9 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 10-19 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 20-29 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 30-39 - 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 40-49 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 50-59 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 60-69 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 70-79 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 80-89 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 90-99 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 100-109 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 110-119 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 120-129 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 130-139 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 140-149 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 150-159 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 160-169 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 170-179 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 180-189 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 190-199 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 200-209 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 210-219 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 220-229 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 230-239 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 240-249 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 250-259 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 260-269 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 270-279 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 280-289 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 290-299 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 300-309 - 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 310-319 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 320-329 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 330-339 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 340-349 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 350-359 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 360-369 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 370-379 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 380-389 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 390-399 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 400-409 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 410-419 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 420-429 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 430-439 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 440-449 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 450-459 - 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 460-469 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 470-479 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 480-489 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 490-499 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 500-509 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 510-519 - 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 520-529 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 530-539 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 540-549 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 550-559 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 560-569 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 570-579 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 580-589 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 590-599 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 600-609 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 610-619 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 620-629 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 630-639 - 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 640-649 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 650-659 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 660-669 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 670-679 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 680-689 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 690-699 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 700-709 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 710-719 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 720-729 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 730-739 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 740-749 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 750-759 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 760-769 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 770-779 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 780-789 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 790-799 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 800-809 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 810-819 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 820-829 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 830-839 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 840-849 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 850-859 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 860-869 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 870-879 - 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 880-889 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 890-899 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 900-909 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 910-919 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 920-929 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 930-939 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 940-949 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 950-959 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 960-969 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 970-979 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 980-989 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 990-999 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 1000-1009 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 1010-1019 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1020-1029 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 1030-1039 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 1040-1049 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1050-1059 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 1060-1069 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 1070-1079 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 1080-1089 - 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 1090-1099 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 1100-1109 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 1110-1119 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 1120-1129 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 1130-1139 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1140-1149 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 1150-1159 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 1160-1169 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1170-1179 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 1180-1189 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 1190-1199 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 1200-1209 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 1210-1219 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 1220-1229 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 1230-1239 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 1240-1249 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 1250-1259 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 1260-1269 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 1270-1279 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 1280-1289 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 1290-1299 - 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 1300-1309 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 1310-1319 - 1, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 1320-1329 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 1330-1339 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 1340-1349 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1350-1359 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 1360-1369 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 1370-1379 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 1380-1389 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 1390-1399 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 1400-1409 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 1410-1419 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 1420-1429 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 1430-1439 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 1440-1449 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 1450-1459 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1460-1469 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1470-1479 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 1480-1489 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 1490-1499 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1500-1509 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 1510-1519 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 1520-1529 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 1530-1539 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 1540-1549 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 1550-1559 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 1560-1569 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 1570-1579 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 1580-1589 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 1590-1599 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 1600-1609 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 1610-1619 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 1620-1629 - 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 1630-1639 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 1640-1649 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 1650-1659 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 24, // 1660-1669 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 1670-1679 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 1680-1689 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 1690-1699 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 1700-1709 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1710-1719 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 1720-1729 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 1730-1739 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 1740-1749 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 1750-1759 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 1760-1769 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 1770-1779 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 1780-1789 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1790-1799 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1800-1809 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 1810-1819 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 1820-1829 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 1830-1839 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 1840-1849 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1850-1859 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 1860-1869 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 1870-1879 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 1880-1889 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1890-1899 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 1900-1909 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 1910-1919 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 1920-1929 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 1930-1939 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 1940-1949 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 1950-1959 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 1960-1969 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 1970-1979 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 1980-1989 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 1990-1999 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 2000-2009 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 2010-2019 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 2020-2029 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 2030-2039 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 2040-2049 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 2050-2059 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 2060-2069 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 2070-2079 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 2080-2089 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 2090-2099 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 2100-2109 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 2110-2119 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 2120-2129 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 2130-2139 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 2140-2149 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 2150-2159 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 2160-2169 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 2170-2179 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 2180-2189 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 2190-2199 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 2200-2209 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 2210-2219 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 2220-2229 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 2230-2239 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 2240-2249 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 2250-2259 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 2260-2269 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 2270-2279 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 2280-2289 - 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 2290-2299 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 2300-2309 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 2310-2319 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 2320-2329 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 2330-2339 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 2340-2349 - 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 2350-2359 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 2360-2369 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 2370-2379 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 2380-2389 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 2390-2399 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 2400-2409 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 2410-2419 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 2420-2429 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 2430-2439 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 2440-2449 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 2450-2459 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 2460-2469 - 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 2470-2479 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 2480-2489 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 2490-2499 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 2500-2509 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 2510-2519 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 2520-2529 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 2530-2539 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 2540-2549 - 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 2550-2559 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 2560-2569 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 2570-2579 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 2580-2589 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 2590-2599 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 2600-2609 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 2610-2619 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 2620-2629 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 2630-2639 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 2640-2649 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 2650-2659 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 2660-2669 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 2670-2679 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 2680-2689 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 2690-2699 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 2700-2709 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 2710-2719 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 2720-2729 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 2730-2739 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 2740-2749 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 2750-2759 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 2760-2769 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 2770-2779 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 2780-2789 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 2790-2799 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 2800-2809 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 2810-2819 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 2820-2829 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 2830-2839 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 2840-2849 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 2850-2859 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 2860-2869 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 2870-2879 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 2880-2889 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 2890-2899 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 2900-2909 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 2910-2919 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 2920-2929 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 2930-2939 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 2940-2949 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 2950-2959 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 2960-2969 - 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 2970-2979 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 2980-2989 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 2990-2999 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3000-3009 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 3010-3019 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 3020-3029 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 3030-3039 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 3040-3049 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3050-3059 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 3060-3069 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 3070-3079 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 20, // 3080-3089 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 3090-3099 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 3100-3109 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 3110-3119 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 3120-3129 - 7, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 3130-3139 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 3140-3149 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 3150-3159 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 3160-3169 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3170-3179 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 3180-3189 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 3190-3199 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 3200-3209 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 3210-3219 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 3220-3229 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 3230-3239 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3240-3249 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 3250-3259 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3260-3269 - 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 3270-3279 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 3280-3289 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 3290-3299 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 3300-3309 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 3310-3319 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 3320-3329 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 3330-3339 - 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 3340-3349 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 3350-3359 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3360-3369 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 3370-3379 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 3380-3389 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 3390-3399 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 3400-3409 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 3410-3419 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 3420-3429 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 3430-3439 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 3440-3449 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 3450-3459 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 22, // 3460-3469 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 3470-3479 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3480-3489 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 3490-3499 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3500-3509 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 3510-3519 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 3520-3529 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 3530-3539 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 3540-3549 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 3550-3559 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3560-3569 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3570-3579 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 3580-3589 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 3590-3599 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 3600-3609 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 3610-3619 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 3620-3629 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 3630-3639 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 3640-3649 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 3650-3659 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3660-3669 - 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 3670-3679 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3680-3689 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 3690-3699 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 3700-3709 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 3710-3719 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 3720-3729 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 3730-3739 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 3740-3749 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3750-3759 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 3760-3769 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 3770-3779 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 3780-3789 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 3790-3799 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 3800-3809 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3810-3819 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 3820-3829 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 3830-3839 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 3840-3849 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 3850-3859 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 3860-3869 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 3870-3879 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 3880-3889 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 3890-3899 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 3900-3909 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 3910-3919 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 3920-3929 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 3930-3939 - 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 3940-3949 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 3950-3959 - 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 3960-3969 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 3970-3979 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 3980-3989 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 3990-3999 - 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 4000-4009 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 4010-4019 - 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 4020-4029 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 4030-4039 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 4040-4049 - 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 4050-4059 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 4060-4069 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 4070-4079 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4080-4089 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 4090-4099 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4100-4109 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 4110-4119 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 4120-4129 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 4130-4139 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 4140-4149 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 18, // 4150-4159 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 4160-4169 - 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 4170-4179 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 4180-4189 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4190-4199 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4200-4209 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 4210-4219 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 4220-4229 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4230-4239 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 4240-4249 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 4250-4259 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4260-4269 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 4270-4279 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 4280-4289 - 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 4290-4299 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 4300-4309 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 4310-4319 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 4320-4329 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 4330-4339 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 4340-4349 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 4350-4359 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 4360-4369 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 4370-4379 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4380-4389 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 4390-4399 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 4400-4409 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4410-4419 - 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 4420-4429 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4430-4439 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 4440-4449 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 4450-4459 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 4460-4469 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4470-4479 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 4480-4489 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 4490-4499 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 4500-4509 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 4510-4519 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 4520-4529 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 4530-4539 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 4540-4549 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4550-4559 - 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 4560-4569 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 4570-4579 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 4580-4589 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 4590-4599 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 4600-4609 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4610-4619 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 4620-4629 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 4630-4639 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 4640-4649 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 4650-4659 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 4660-4669 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 4670-4679 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4680-4689 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 4690-4699 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 4700-4709 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4710-4719 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 4720-4729 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 4730-4739 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4740-4749 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 4750-4759 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 4760-4769 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 4770-4779 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 4780-4789 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 4790-4799 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 4800-4809 - 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 4810-4819 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4820-4829 - 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 4830-4839 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 4840-4849 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4850-4859 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4860-4869 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 4870-4879 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 4880-4889 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 4890-4899 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 4900-4909 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 4910-4919 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 4920-4929 - 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 4930-4939 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 4940-4949 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 4950-4959 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 4960-4969 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 4970-4979 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 4980-4989 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 4990-4999 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 5000-5009 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5010-5019 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 5020-5029 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 5030-5039 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5040-5049 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 5050-5059 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 5060-5069 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5070-5079 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 5080-5089 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 5090-5099 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 5100-5109 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 28, // 5110-5119 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 5120-5129 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 5130-5139 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 5140-5149 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 5150-5159 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5160-5169 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 5170-5179 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 5180-5189 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 5190-5199 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 5200-5209 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 5210-5219 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5220-5229 - 1, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 5230-5239 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 5240-5249 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5250-5259 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 5260-5269 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 5270-5279 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 5280-5289 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 5290-5299 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 5300-5309 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 5310-5319 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 5320-5329 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 5330-5339 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5340-5349 - 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 5350-5359 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 5360-5369 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5370-5379 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 5380-5389 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 5390-5399 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 5400-5409 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 5410-5419 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5420-5429 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5430-5439 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 5440-5449 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 5450-5459 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5460-5469 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 5470-5479 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 5480-5489 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5490-5499 - 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 5500-5509 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 5510-5519 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5520-5529 - 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 5530-5539 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 5540-5549 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 5550-5559 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 5560-5569 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 5570-5579 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5580-5589 - 1, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 5590-5599 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 5600-5609 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 5610-5619 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 5620-5629 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 5630-5639 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5640-5649 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 5650-5659 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 5660-5669 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 5670-5679 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 5680-5689 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 5690-5699 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5700-5709 - 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 5710-5719 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 5720-5729 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5730-5739 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 30, // 5740-5749 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 5750-5759 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 5760-5769 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 5770-5779 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 5780-5789 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5790-5799 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 5800-5809 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 5810-5819 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 5820-5829 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 5830-5839 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 5840-5849 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 5850-5859 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 5860-5869 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 5870-5879 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 5880-5889 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 5890-5899 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 5900-5909 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 5910-5919 - 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 5920-5929 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 5930-5939 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 5940-5949 - 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 5950-5959 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 5960-5969 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 5970-5979 - 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 5980-5989 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 5990-5999 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 6000-6009 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 6010-6019 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 6020-6029 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 6030-6039 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 6040-6049 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 6050-6059 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 6060-6069 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 6070-6079 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 6080-6089 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6090-6099 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 6100-6109 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 6110-6119 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6120-6129 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 6130-6139 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 6140-6149 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 6150-6159 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 6160-6169 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 6170-6179 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 6180-6189 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 6190-6199 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 6200-6209 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 6210-6219 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 6220-6229 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 6230-6239 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 6240-6249 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 6250-6259 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 6260-6269 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 6270-6279 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 6280-6289 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 6290-6299 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6300-6309 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 6310-6319 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 6320-6329 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 6330-6339 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 6340-6349 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 6350-6359 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 6360-6369 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 6370-6379 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 6380-6389 - 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 6390-6399 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 6400-6409 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6410-6419 - 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 6420-6429 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 6430-6439 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 6440-6449 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 6450-6459 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 6460-6469 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 6470-6479 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6480-6489 - 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 6490-6499 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 6500-6509 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6510-6519 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 6520-6529 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 6530-6539 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 6540-6549 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 6550-6559 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 6560-6569 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 6570-6579 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 6580-6589 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 6590-6599 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 6600-6609 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 6610-6619 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 6620-6629 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 6630-6639 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 6640-6649 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 6650-6659 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 6660-6669 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 6670-6679 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 6680-6689 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6690-6699 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 6700-6709 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 6710-6719 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 6720-6729 - 3, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 6730-6739 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 6740-6749 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6750-6759 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 6760-6769 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 6770-6779 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 6780-6789 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 6790-6799 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 6800-6809 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 6810-6819 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 6820-6829 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 6830-6839 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 6840-6849 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 6850-6859 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 6860-6869 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 6870-6879 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 6880-6889 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 6890-6899 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 6900-6909 - 1, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 6910-6919 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 6920-6929 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 6930-6939 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 6940-6949 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 6950-6959 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 6960-6969 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 6970-6979 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 6980-6989 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 6990-6999 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7000-7009 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 7010-7019 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 7020-7029 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 7030-7039 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 7040-7049 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 7050-7059 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 7060-7069 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 7070-7079 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 7080-7089 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7090-7099 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 7100-7109 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7110-7119 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 7120-7129 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 7130-7139 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7140-7149 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 7150-7159 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 7160-7169 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 7170-7179 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 7180-7189 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 7190-7199 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 7200-7209 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 7210-7219 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 7220-7229 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 7230-7239 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 7240-7249 - 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 7250-7259 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 7260-7269 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7270-7279 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 7280-7289 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 7290-7299 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 7300-7309 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7310-7319 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7320-7329 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 7330-7339 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 7340-7349 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 7350-7359 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 7360-7369 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 7370-7379 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7380-7389 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 7390-7399 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7400-7409 - 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 7410-7419 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7420-7429 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 7430-7439 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7440-7449 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 7450-7459 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 7460-7469 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 7470-7479 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 7480-7489 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 7490-7499 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 7500-7509 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 7510-7519 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 7520-7529 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 7530-7539 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 7540-7549 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 7550-7559 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7560-7569 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 7570-7579 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 7580-7589 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7590-7599 - 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 7600-7609 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7610-7619 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 7620-7629 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 7630-7639 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 20, // 7640-7649 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 7650-7659 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 7660-7669 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 7670-7679 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 7680-7689 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 7690-7699 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 7700-7709 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 7710-7719 - 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 7720-7729 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7730-7739 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7740-7749 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 30, // 7750-7759 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 7760-7769 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 7770-7779 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 7780-7789 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 7790-7799 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 7800-7809 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 7810-7819 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 7820-7829 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7830-7839 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7840-7849 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 7850-7859 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 7860-7869 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 7870-7879 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 7880-7889 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 7890-7899 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 7900-7909 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 7910-7919 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 7920-7929 - 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 7930-7939 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 7940-7949 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7950-7959 - 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 7960-7969 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 7970-7979 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 7980-7989 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 7990-7999 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 8000-8009 - 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 8010-8019 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 8020-8029 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 8030-8039 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8040-8049 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 8050-8059 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 8060-8069 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8070-8079 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 8080-8089 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 8090-8099 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8100-8109 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 8110-8119 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 8120-8129 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 8130-8139 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 8140-8149 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8150-8159 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 8160-8169 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 8170-8179 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8180-8189 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 8190-8199 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 8200-8209 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 8210-8219 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8220-8229 - 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 8230-8239 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 8240-8249 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8250-8259 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 8260-8269 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 8270-8279 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 8280-8289 - 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 8290-8299 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8300-8309 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 8310-8319 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 8320-8329 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 8330-8339 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8340-8349 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 8350-8359 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 8360-8369 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 8370-8379 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 30, // 8380-8389 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 8390-8399 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 8400-8409 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 8410-8419 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 8420-8429 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8430-8439 - 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 8440-8449 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8450-8459 - 1, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 8460-8469 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 8470-8479 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 8480-8489 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8490-8499 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8500-8509 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 8510-8519 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 8520-8529 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 8530-8539 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 8540-8549 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8550-8559 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 8560-8569 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 8570-8579 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 8580-8589 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 8590-8599 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 8600-8609 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8610-8619 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 8620-8629 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8630-8639 - 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 8640-8649 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8650-8659 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 8660-8669 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 8670-8679 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 8680-8689 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 8690-8699 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 8700-8709 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 8710-8719 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8720-8729 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 8730-8739 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 8740-8749 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 8750-8759 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 8760-8769 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 8770-8779 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 8780-8789 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8790-8799 - 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 8800-8809 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 8810-8819 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8820-8829 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 8830-8839 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 8840-8849 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8850-8859 - 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 8860-8869 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 8870-8879 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 8880-8889 - 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 8890-8899 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 8900-8909 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8910-8919 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 8920-8929 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 8930-8939 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 8940-8949 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 8950-8959 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 8960-8969 - 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 8970-8979 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 8980-8989 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 8990-8999 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 9000-9009 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 9010-9019 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 9020-9029 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9030-9039 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 9040-9049 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 9050-9059 - 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 9060-9069 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 9070-9079 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9080-9089 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9090-9099 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 9100-9109 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 9110-9119 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 9120-9129 - 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 9130-9139 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9140-9149 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 9150-9159 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9160-9169 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 9170-9179 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 9180-9189 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 9190-9199 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 9200-9209 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9210-9219 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 9220-9229 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 9230-9239 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 9240-9249 - 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 9250-9259 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 9260-9269 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 9270-9279 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 9280-9289 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 9290-9299 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9300-9309 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 9310-9319 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 9320-9329 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 9330-9339 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 9340-9349 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 9350-9359 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9360-9369 - 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 9370-9379 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9380-9389 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 9390-9399 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 9400-9409 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 9410-9419 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9420-9429 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 22, // 9430-9439 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 9440-9449 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9450-9459 - 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 9460-9469 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 9470-9479 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9480-9489 - 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 9490-9499 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9500-9509 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9510-9519 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9520-9529 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 9530-9539 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 9540-9549 - 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 9550-9559 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 9560-9569 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 9570-9579 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 9580-9589 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9590-9599 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9600-9609 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 9610-9619 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 9620-9629 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9630-9639 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 9640-9649 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9650-9659 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 9660-9669 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 9670-9679 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 9680-9689 - 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 9690-9699 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 9700-9709 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 9710-9719 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9720-9729 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 9730-9739 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 9740-9749 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 9750-9759 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 9760-9769 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9770-9779 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 9780-9789 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9790-9799 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 9800-9809 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 9810-9819 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 9820-9829 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 9830-9839 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9840-9849 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 9850-9859 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9860-9869 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9870-9879 - 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 9880-9889 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9890-9899 - 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 9900-9909 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 9910-9919 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 9920-9929 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 9930-9939 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 9940-9949 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 9950-9959 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 9960-9969 - 3, 2, 1, 34, 33, 32, 31, 30, 29, 28, // 9970-9979 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 9980-9989 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 9990-9999 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 28, // 10000-10009 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 10010-10019 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 10020-10029 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 10030-10039 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 10040-10049 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10050-10059 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 10060-10069 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 10070-10079 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10080-10089 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 10090-10099 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 10100-10109 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 10110-10119 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10120-10129 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 10130-10139 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10140-10149 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 10150-10159 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 10160-10169 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 10170-10179 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10180-10189 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 10190-10199 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10200-10209 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10210-10219 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 10220-10229 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10230-10239 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 10240-10249 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 10250-10259 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 10260-10269 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 10270-10279 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 10280-10289 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10290-10299 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 10300-10309 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 10310-10319 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10320-10329 - 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 10330-10339 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 10340-10349 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 10350-10359 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 10360-10369 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 10370-10379 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10380-10389 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 28, // 10390-10399 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 10400-10409 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 10410-10419 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 10420-10429 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 10430-10439 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10440-10449 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 10450-10459 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 10460-10469 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 10470-10479 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 10480-10489 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 10490-10499 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10500-10509 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 10510-10519 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 10520-10529 - 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 10530-10539 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 10540-10549 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 10550-10559 - 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 10560-10569 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 10570-10579 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 10580-10589 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 10590-10599 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 10600-10609 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 10610-10619 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 10620-10629 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 10630-10639 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10640-10649 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 10650-10659 - 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 10660-10669 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 10670-10679 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 10680-10689 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 10690-10699 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 10700-10709 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10710-10719 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 10720-10729 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 10730-10739 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10740-10749 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 10750-10759 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10760-10769 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10770-10779 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 10780-10789 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 32, // 10790-10799 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 10800-10809 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 10810-10819 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 10820-10829 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 10830-10839 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 10840-10849 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 10850-10859 - 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 10860-10869 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10870-10879 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 10880-10889 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10890-10899 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 28, // 10900-10909 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 10910-10919 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 10920-10929 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 10930-10939 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 10940-10949 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 10950-10959 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 10960-10969 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 10970-10979 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 10980-10989 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 10990-10999 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 11000-11009 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11010-11019 - 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 11020-11029 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11030-11039 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 11040-11049 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 11050-11059 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 11060-11069 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11070-11079 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 11080-11089 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 11090-11099 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11100-11109 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 11110-11119 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 11120-11129 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 11130-11139 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 11140-11149 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 11150-11159 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 11160-11169 - 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 11170-11179 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11180-11189 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 11190-11199 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11200-11209 - 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 11210-11219 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 11220-11229 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 11230-11239 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 11240-11249 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 11250-11259 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11260-11269 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 11270-11279 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 11280-11289 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 11290-11299 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 11300-11309 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 11310-11319 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 11320-11329 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 11330-11339 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 11340-11349 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 11350-11359 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 11360-11369 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11370-11379 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 11380-11389 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 11390-11399 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 11400-11409 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11410-11419 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 11420-11429 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 11430-11439 - 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 11440-11449 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11450-11459 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 11460-11469 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11470-11479 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 11480-11489 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 11490-11499 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 11500-11509 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 11510-11519 - 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 11520-11529 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 11530-11539 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 11540-11549 - 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 11550-11559 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 11560-11569 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 11570-11579 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 11580-11589 - 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 11590-11599 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11600-11609 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 11610-11619 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11620-11629 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 11630-11639 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11640-11649 - 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 11650-11659 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11660-11669 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 11670-11679 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 11680-11689 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 11690-11699 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11700-11709 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 11710-11719 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 11720-11729 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11730-11739 - 3, 2, 1, 34, 33, 32, 31, 30, 29, 28, // 11740-11749 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 11750-11759 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11760-11769 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 11770-11779 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 11780-11789 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 11790-11799 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 11800-11809 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 11810-11819 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 11820-11829 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 24, // 11830-11839 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 11840-11849 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11850-11859 - 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 11860-11869 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11870-11879 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 11880-11889 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 11890-11899 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 11900-11909 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11910-11919 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 11920-11929 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 11930-11939 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 11940-11949 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 11950-11959 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 11960-11969 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 11970-11979 - 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 11980-11989 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 11990-11999 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 12000-12009 - 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 12010-12019 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 12020-12029 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 12030-12039 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 12040-12049 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 12050-12059 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12060-12069 - 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 12070-12079 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 12080-12089 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 12090-12099 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 12100-12109 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 24, // 12110-12119 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 12120-12129 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 12130-12139 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 12140-12149 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 12150-12159 - 1, 2, 1, 34, 33, 32, 31, 30, 29, 28, // 12160-12169 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 12170-12179 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 12180-12189 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 12190-12199 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 12200-12209 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 12210-12219 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 12220-12229 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 12230-12239 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12240-12249 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 12250-12259 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 12260-12269 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 12270-12279 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 12280-12289 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12290-12299 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 12300-12309 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 12310-12319 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 12320-12329 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 12330-12339 - 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 12340-12349 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 12350-12359 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 12360-12369 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 12370-12379 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12380-12389 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12390-12399 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 12400-12409 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 12410-12419 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 12420-12429 - 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 12430-12439 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12440-12449 - 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 12450-12459 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 12460-12469 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 12470-12479 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 12480-12489 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 12490-12499 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 12500-12509 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 12510-12519 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 12520-12529 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 12530-12539 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 12540-12549 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 12550-12559 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 12560-12569 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 12570-12579 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 12580-12589 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12590-12599 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12600-12609 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 12610-12619 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 12620-12629 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 12630-12639 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 12640-12649 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 12650-12659 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12660-12669 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 12670-12679 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 12680-12689 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 12690-12699 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 12700-12709 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 12710-12719 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 12720-12729 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 12730-12739 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 12740-12749 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 12750-12759 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 12760-12769 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12770-12779 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12780-12789 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 12790-12799 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 12800-12809 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12810-12819 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 12820-12829 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12830-12839 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 12840-12849 - 3, 2, 1, 36, 35, 34, 33, 32, 31, 30, // 12850-12859 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 12860-12869 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 12870-12879 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 12880-12889 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 12890-12899 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 12900-12909 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 12910-12919 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 12920-12929 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12930-12939 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 12940-12949 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 12950-12959 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 12960-12969 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 12970-12979 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 12980-12989 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 12990-12999 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 24, // 13000-13009 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 13010-13019 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 13020-13029 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 13030-13039 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 13040-13049 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 13050-13059 - 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 13060-13069 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 13070-13079 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 13080-13089 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 13090-13099 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 13100-13109 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13110-13119 - 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 13120-13129 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 13130-13139 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 13140-13149 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 13150-13159 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 13160-13169 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 13170-13179 - 3, 2, 1, 4, 3, 2, 1, 30, 29, 28, // 13180-13189 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 13190-13199 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 13200-13209 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 13210-13219 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 13220-13229 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13230-13239 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 13240-13249 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 13250-13259 - 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 13260-13269 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 13270-13279 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13280-13289 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 13290-13299 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 13300-13309 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 13310-13319 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 13320-13329 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 28, // 13330-13339 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 13340-13349 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 13350-13359 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 13360-13369 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13370-13379 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 13380-13389 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 13390-13399 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13400-13409 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 13410-13419 - 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 13420-13429 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13430-13439 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13440-13449 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 13450-13459 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 13460-13469 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 13470-13479 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 13480-13489 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 13490-13499 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 13500-13509 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 13510-13519 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 13520-13529 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 13530-13539 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 13540-13549 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 13550-13559 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 13560-13569 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 13570-13579 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13580-13589 - 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 13590-13599 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 13600-13609 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 13610-13619 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 13620-13629 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 13630-13639 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 13640-13649 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 13650-13659 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 13660-13669 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 13670-13679 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 13680-13689 - 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 13690-13699 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 13700-13709 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13710-13719 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 13720-13729 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 13730-13739 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13740-13749 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 13750-13759 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 13760-13769 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13770-13779 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 13780-13789 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 13790-13799 - 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 13800-13809 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 13810-13819 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 13820-13829 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13830-13839 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 13840-13849 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 13850-13859 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 13860-13869 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 13870-13879 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 13880-13889 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13890-13899 - 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 13900-13909 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 13910-13919 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 13920-13929 - 1, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 13930-13939 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 13940-13949 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 13950-13959 - 3, 2, 1, 4, 3, 2, 1, 30, 29, 28, // 13960-13969 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 13970-13979 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 13980-13989 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 13990-13999 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 14000-14009 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 14010-14019 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 14020-14029 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 14030-14039 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14040-14049 - 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 14050-14059 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14060-14069 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14070-14079 - 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 14080-14089 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 14090-14099 - 7, 6, 5, 4, 3, 2, 1, 36, 35, 34, // 14100-14109 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 14110-14119 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 14120-14129 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14130-14139 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 14140-14149 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 14150-14159 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14160-14169 - 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 14170-14179 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 14180-14189 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 14190-14199 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 14200-14209 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14210-14219 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 14220-14229 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14230-14239 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 14240-14249 - 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 14250-14259 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 14260-14269 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14270-14279 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14280-14289 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 14290-14299 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 14300-14309 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14310-14319 - 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 14320-14329 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14330-14339 - 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 14340-14349 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 14350-14359 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 14360-14369 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 14370-14379 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 14380-14389 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14390-14399 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 14400-14409 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 14410-14419 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 14420-14429 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 14430-14439 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 14440-14449 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14450-14459 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 14460-14469 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 14470-14479 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 14480-14489 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14490-14499 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 14500-14509 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 14510-14519 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14520-14529 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 14530-14539 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 14540-14549 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 14550-14559 - 1, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 14560-14569 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 14570-14579 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14580-14589 - 1, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 14590-14599 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 14600-14609 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 14610-14619 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 14620-14629 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 14630-14639 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14640-14649 - 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 14650-14659 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 14660-14669 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14670-14679 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 14680-14689 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 14690-14699 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14700-14709 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 14710-14719 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 14720-14729 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 14730-14739 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 14740-14749 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 14750-14759 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 14760-14769 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 14770-14779 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 14780-14789 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 14790-14799 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14800-14809 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 14810-14819 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 14820-14829 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14830-14839 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 14840-14849 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 14850-14859 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 14860-14869 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 14870-14879 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 14880-14889 - 1, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 14890-14899 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 14900-14909 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14910-14919 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 14920-14929 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 14930-14939 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 14940-14949 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 14950-14959 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 14960-14969 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 14970-14979 - 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 14980-14989 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 14990-14999 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 15000-15009 - 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 15010-15019 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15020-15029 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 15030-15039 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 15040-15049 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 15050-15059 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 15060-15069 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 15070-15079 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 15080-15089 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15090-15099 - 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 15100-15109 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15110-15119 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15120-15129 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 15130-15139 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 15140-15149 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15150-15159 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 15160-15169 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 15170-15179 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 15180-15189 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 15190-15199 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 15200-15209 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 15210-15219 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 15220-15229 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 15230-15239 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 15240-15249 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 15250-15259 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 15260-15269 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 15270-15279 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 15280-15289 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 15290-15299 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 15300-15309 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 15310-15319 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 15320-15329 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 15330-15339 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 15340-15349 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 15350-15359 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 15360-15369 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 15370-15379 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 15380-15389 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15390-15399 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 15400-15409 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 15410-15419 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 15420-15429 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 15430-15439 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 15440-15449 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15450-15459 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 15460-15469 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 15470-15479 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 15480-15489 - 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 15490-15499 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15500-15509 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 15510-15519 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 15520-15529 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15530-15539 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15540-15549 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 15550-15559 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 15560-15569 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15570-15579 - 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 15580-15589 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15590-15599 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 15600-15609 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 15610-15619 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 15620-15629 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15630-15639 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 15640-15649 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15650-15659 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 15660-15669 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 15670-15679 - 3, 2, 1, 44, 43, 42, 41, 40, 39, 38, // 15680-15689 - 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 15690-15699 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 15700-15709 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 15710-15719 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 15720-15729 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 15730-15739 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 15740-15749 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15750-15759 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 15760-15769 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 15770-15779 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 15780-15789 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 15790-15799 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 15800-15809 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 15810-15819 - 3, 2, 1, 36, 35, 34, 33, 32, 31, 30, // 15820-15829 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 15830-15839 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 15840-15849 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 15850-15859 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 15860-15869 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 15870-15879 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 15880-15889 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15890-15899 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 15900-15909 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 15910-15919 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 15920-15929 - 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 15930-15939 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 15940-15949 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 15950-15959 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15960-15969 - 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 15970-15979 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15980-15989 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 15990-15999 - 1, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 16000-16009 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 16010-16019 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 16020-16029 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 16030-16039 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 16040-16049 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 16050-16059 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 16060-16069 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 16070-16079 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 16080-16089 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16090-16099 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 16100-16109 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 16110-16119 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 16120-16129 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 16130-16139 - 1, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 16140-16149 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 16150-16159 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 16160-16169 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 16170-16179 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 16180-16189 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 16190-16199 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 16200-16209 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16210-16219 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 16220-16229 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 16230-16239 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 16240-16249 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 16250-16259 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16260-16269 - 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 16270-16279 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 16280-16289 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16290-16299 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 16300-16309 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 16310-16319 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 16320-16329 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 16330-16339 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 16340-16349 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16350-16359 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 16360-16369 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16370-16379 - 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 16380-16389 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 16390-16399 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16400-16409 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 16410-16419 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16420-16429 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 16430-16439 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 16440-16449 - 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 16450-16459 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 16460-16469 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 16470-16479 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16480-16489 - 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 16490-16499 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 16500-16509 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 16510-16519 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 16520-16529 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 16530-16539 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16540-16549 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 16550-16559 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16560-16569 - 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 16570-16579 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 16580-16589 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 16590-16599 - 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 16600-16609 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 16610-16619 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16620-16629 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 16630-16639 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 16640-16649 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 16650-16659 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 16660-16669 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 16670-16679 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16680-16689 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 16690-16699 - 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 16700-16709 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 16710-16719 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 16720-16729 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16730-16739 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 16740-16749 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 16750-16759 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 16760-16769 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 16770-16779 - 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 16780-16789 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 16790-16799 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16800-16809 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 16810-16819 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 16820-16829 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 16830-16839 - 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 16840-16849 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 16850-16859 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16860-16869 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 16870-16879 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 16880-16889 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16890-16899 - 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 16900-16909 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 16910-16919 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 16920-16929 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16930-16939 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 16940-16949 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 16950-16959 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 16960-16969 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 16970-16979 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 16980-16989 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 16990-16999 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17000-17009 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17010-17019 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 17020-17029 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 17030-17039 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 17040-17049 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 17050-17059 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17060-17069 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 17070-17079 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 17080-17089 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 17090-17099 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 17100-17109 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 17110-17119 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 17120-17129 - 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 17130-17139 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 17140-17149 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 17150-17159 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 17160-17169 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 17170-17179 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 17180-17189 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 17190-17199 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 22, // 17200-17209 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 17210-17219 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17220-17229 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 17230-17239 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17240-17249 - 7, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 17250-17259 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 17260-17269 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 17270-17279 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17280-17289 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 17290-17299 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17300-17309 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 17310-17319 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 17320-17329 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 17330-17339 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17340-17349 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 17350-17359 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17360-17369 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 17370-17379 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 17380-17389 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 17390-17399 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17400-17409 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 17410-17419 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17420-17429 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 17430-17439 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 17440-17449 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17450-17459 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 17460-17469 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 17470-17479 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 17480-17489 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 17490-17499 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 17500-17509 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 17510-17519 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 17520-17529 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 17530-17539 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17540-17549 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 17550-17559 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 17560-17569 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 17570-17579 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17580-17589 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 17590-17599 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 17600-17609 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 17610-17619 - 3, 2, 1, 4, 3, 2, 1, 30, 29, 28, // 17620-17629 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 17630-17639 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17640-17649 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 17650-17659 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 17660-17669 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17670-17679 - 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 17680-17689 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17690-17699 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 17700-17709 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 17710-17719 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 17720-17729 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 17730-17739 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 17740-17749 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17750-17759 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 17760-17769 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 17770-17779 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 17780-17789 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17790-17799 - 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 17800-17809 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17810-17819 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 17820-17829 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 17830-17839 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17840-17849 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 17850-17859 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 17860-17869 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17870-17879 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17880-17889 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 17890-17899 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 17900-17909 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17910-17919 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 17920-17929 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 17930-17939 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 17940-17949 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 17950-17959 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 17960-17969 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 17970-17979 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 24, // 17980-17989 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 17990-17999 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18000-18009 - 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 18010-18019 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 18020-18029 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18030-18039 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 18040-18049 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 18050-18059 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 18060-18069 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 18070-18079 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 18080-18089 - 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 18090-18099 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 18100-18109 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 18110-18119 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 18120-18129 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 18130-18139 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 20, // 18140-18149 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 18150-18159 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 18160-18169 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18170-18179 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18180-18189 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 18190-18199 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18200-18209 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 18210-18219 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 18220-18229 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 18230-18239 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18240-18249 - 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 18250-18259 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 18260-18269 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 18270-18279 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 18280-18289 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18290-18299 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 18300-18309 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 18310-18319 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 18320-18329 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18330-18339 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18340-18349 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 18350-18359 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 18360-18369 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 18370-18379 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 18380-18389 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 18390-18399 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18400-18409 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 18410-18419 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 18420-18429 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 18430-18439 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 18440-18449 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 18450-18459 - 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 18460-18469 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18470-18479 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18480-18489 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 18490-18499 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 18500-18509 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 18510-18519 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 18520-18529 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 18530-18539 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18540-18549 - 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 18550-18559 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 18560-18569 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18570-18579 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 18580-18589 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 18590-18599 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 18600-18609 - 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 18610-18619 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 18620-18629 - 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 18630-18639 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 18640-18649 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18650-18659 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18660-18669 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 18670-18679 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18680-18689 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18690-18699 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18700-18709 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 18710-18719 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18720-18729 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18730-18739 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 18740-18749 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 18750-18759 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18760-18769 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 18770-18779 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 18780-18789 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 18790-18799 - 3, 2, 1, 36, 35, 34, 33, 32, 31, 30, // 18800-18809 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 18810-18819 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 18820-18829 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 18830-18839 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 18840-18849 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 18850-18859 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 18860-18869 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 18870-18879 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 18880-18889 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 18890-18899 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18900-18909 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 28, // 18910-18919 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 18920-18929 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 18930-18939 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 18940-18949 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 18950-18959 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 18960-18969 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 18970-18979 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 18980-18989 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 18990-18999 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 19000-19009 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 19010-19019 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19020-19029 - 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 19030-19039 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19040-19049 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 19050-19059 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 19060-19069 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 19070-19079 - 1, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 19080-19089 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 19090-19099 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 19100-19109 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19110-19119 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 19120-19129 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 19130-19139 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 19140-19149 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 19150-19159 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 19160-19169 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19170-19179 - 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 19180-19189 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 19190-19199 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 19200-19209 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 19210-19219 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19220-19229 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 19230-19239 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 19240-19249 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 19250-19259 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 19260-19269 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 19270-19279 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 19280-19289 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19290-19299 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 19300-19309 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 19310-19319 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 19320-19329 - 3, 2, 1, 40, 39, 38, 37, 36, 35, 34, // 19330-19339 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 19340-19349 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 19350-19359 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 19360-19369 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 19370-19379 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 19380-19389 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 19390-19399 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 19400-19409 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 19410-19419 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 19420-19429 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 19430-19439 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 19440-19449 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 19450-19459 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 19460-19469 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 19470-19479 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 19480-19489 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19490-19499 - 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 19500-19509 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 19510-19519 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19520-19529 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19530-19539 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 19540-19549 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 19550-19559 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19560-19569 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 19570-19579 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 19580-19589 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 19590-19599 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 52, // 19600-19609 - 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, // 19610-19619 - 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 19620-19629 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 19630-19639 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 19640-19649 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19650-19659 - 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 19660-19669 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19670-19679 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 19680-19689 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 19690-19699 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 19700-19709 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 19710-19719 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 19720-19729 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 19730-19739 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19740-19749 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 19750-19759 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 19760-19769 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 19770-19779 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 19780-19789 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 19790-19799 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 19800-19809 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 19810-19819 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 19820-19829 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19830-19839 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 19840-19849 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 19850-19859 - 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 19860-19869 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 19870-19879 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 19880-19889 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 19890-19899 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 19900-19909 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 19910-19919 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 19920-19929 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 19930-19939 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 19940-19949 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19950-19959 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 19960-19969 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 19970-19979 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 19980-19989 - 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 19990-19999 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20000-20009 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20010-20019 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 20020-20029 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 20030-20039 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 20040-20049 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20050-20059 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 20060-20069 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 20070-20079 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 20080-20089 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20090-20099 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 20100-20109 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 20110-20119 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 20120-20129 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20130-20139 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 20140-20149 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20150-20159 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20160-20169 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 20170-20179 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 20180-20189 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20190-20199 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 20200-20209 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 20210-20219 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20220-20229 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 20230-20239 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 20240-20249 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20250-20259 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 20260-20269 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 20270-20279 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 20280-20289 - 7, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 20290-20299 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 20300-20309 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20310-20319 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 20320-20329 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 20330-20339 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 20340-20349 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 20350-20359 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 20360-20369 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 20370-20379 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 20380-20389 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 20390-20399 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 20400-20409 - 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 20410-20419 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20420-20429 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20430-20439 - 1, 2, 1, 34, 33, 32, 31, 30, 29, 28, // 20440-20449 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 20450-20459 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 20460-20469 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 20470-20479 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 20480-20489 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 20490-20499 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 20500-20509 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20510-20519 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20520-20529 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 20530-20539 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 20540-20549 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20550-20559 - 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 20560-20569 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 20570-20579 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20580-20589 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 20590-20599 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20600-20609 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 20610-20619 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 20620-20629 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 20630-20639 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 20640-20649 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20650-20659 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 20660-20669 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20670-20679 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20680-20689 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 20690-20699 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 20700-20709 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 20710-20719 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20720-20729 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20730-20739 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 20740-20749 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 20750-20759 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20760-20769 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 20770-20779 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 20780-20789 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 20790-20799 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 40, // 20800-20809 - 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 20810-20819 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 20820-20829 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 20830-20839 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 20840-20849 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 20850-20859 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 20860-20869 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 20870-20879 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 20880-20889 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 20890-20899 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 20900-20909 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20910-20919 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 20920-20929 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 20930-20939 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 20940-20949 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 20950-20959 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 20960-20969 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20970-20979 - 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 20980-20989 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 20990-20999 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21000-21009 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 21010-21019 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 21020-21029 - 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 21030-21039 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 21040-21049 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 21050-21059 - 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 21060-21069 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 21070-21079 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 21080-21089 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21090-21099 - 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 21100-21109 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21110-21119 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 21120-21129 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 21130-21139 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 21140-21149 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 21150-21159 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 21160-21169 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 21170-21179 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 21180-21189 - 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 21190-21199 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21200-21209 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21210-21219 - 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 21220-21229 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 21230-21239 - 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 21240-21249 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 21250-21259 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 21260-21269 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 21270-21279 - 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 21280-21289 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 21290-21299 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 21300-21309 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 21310-21319 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 21320-21329 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21330-21339 - 1, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 21340-21349 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 21350-21359 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 21360-21369 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 21370-21379 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 21380-21389 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 21390-21399 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 21400-21409 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 21410-21419 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 21420-21429 - 3, 2, 1, 34, 33, 32, 31, 30, 29, 28, // 21430-21439 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 21440-21449 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 21450-21459 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 21460-21469 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21470-21479 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 21480-21489 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 21490-21499 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 21500-21509 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 21510-21519 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 28, // 21520-21529 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 21530-21539 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 21540-21549 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 21550-21559 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 21560-21569 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 21570-21579 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 21580-21589 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 21590-21599 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21600-21609 - 1, 2, 1, 4, 3, 2, 1, 30, 29, 28, // 21610-21619 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 21620-21629 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 21630-21639 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 21640-21649 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21650-21659 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 21660-21669 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 21670-21679 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 21680-21689 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21690-21699 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 21700-21709 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 21710-21719 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 21720-21729 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 21730-21739 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21740-21749 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 21750-21759 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 21760-21769 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 21770-21779 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 21780-21789 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 21790-21799 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 21800-21809 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 21810-21819 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 21820-21829 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 21830-21839 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21840-21849 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 21850-21859 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 21860-21869 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21870-21879 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 21880-21889 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 21890-21899 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21900-21909 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 21910-21919 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 21920-21929 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 21930-21939 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 21940-21949 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21950-21959 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 21960-21969 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 21970-21979 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 21980-21989 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 21990-21999 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 22000-22009 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 22010-22019 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 22020-22029 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 22030-22039 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22040-22049 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 22050-22059 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 22060-22069 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 22070-22079 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22080-22089 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 22090-22099 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 22100-22109 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 22110-22119 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 22120-22129 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 22130-22139 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 22140-22149 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 22150-22159 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22160-22169 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 22170-22179 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 22180-22189 - 3, 2, 1, 36, 35, 34, 33, 32, 31, 30, // 22190-22199 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 22200-22209 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 22210-22219 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 22220-22229 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 22230-22239 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 22240-22249 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 22250-22259 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22260-22269 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 22270-22279 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 22280-22289 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 22290-22299 - 3, 2, 1, 4, 3, 2, 1, 36, 35, 34, // 22300-22309 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 22310-22319 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 22320-22329 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 22330-22339 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 22340-22349 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 22350-22359 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 22360-22369 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22370-22379 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22380-22389 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 22390-22399 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 22400-22409 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 22410-22419 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 22420-22429 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 22430-22439 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 22440-22449 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 22450-22459 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 22460-22469 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22470-22479 - 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 22480-22489 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22490-22499 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22500-22509 - 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 22510-22519 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22520-22529 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22530-22539 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 22540-22549 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 22550-22559 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 22560-22569 - 1, 2, 1, 40, 39, 38, 37, 36, 35, 34, // 22570-22579 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 22580-22589 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 22590-22599 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 22600-22609 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 22610-22619 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 22620-22629 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 22630-22639 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 22640-22649 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 22650-22659 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 22660-22669 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 22670-22679 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22680-22689 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 22690-22699 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 22700-22709 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 22710-22719 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 22720-22729 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 22730-22739 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22740-22749 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 22750-22759 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 22760-22769 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 22770-22779 - 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 22780-22789 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 22790-22799 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 22800-22809 - 1, 6, 5, 4, 3, 2, 1, 36, 35, 34, // 22810-22819 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 22820-22829 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 22830-22839 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 22840-22849 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 22850-22859 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22860-22869 - 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 22870-22879 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 22880-22889 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22890-22899 - 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 22900-22909 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22910-22919 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 22920-22929 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 22930-22939 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 22940-22949 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 22950-22959 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 22960-22969 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 22970-22979 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 22980-22989 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 22990-22999 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 23000-23009 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 23010-23019 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 23020-23029 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 23030-23039 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 23040-23049 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 23050-23059 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 23060-23069 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23070-23079 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 23080-23089 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 23090-23099 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 23100-23109 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 23110-23119 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23120-23129 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 23130-23139 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 23140-23149 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 23150-23159 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 23160-23169 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 23170-23179 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 23180-23189 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 23190-23199 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 23200-23209 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 23210-23219 - 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 23220-23229 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 23230-23239 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23240-23249 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 23250-23259 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 23260-23269 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 23270-23279 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23280-23289 - 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 23290-23299 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23300-23309 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23310-23319 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 23320-23329 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 23330-23339 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 23340-23349 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 23350-23359 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 23360-23369 - 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 23370-23379 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 23380-23389 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 23390-23399 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 23400-23409 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 23410-23419 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23420-23429 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 23430-23439 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 23440-23449 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 23450-23459 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 23460-23469 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 23470-23479 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 23480-23489 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 23490-23499 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 23500-23509 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 23510-23519 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23520-23529 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 23530-23539 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 23540-23549 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 23550-23559 - 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 23560-23569 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23570-23579 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 23580-23589 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 23590-23599 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 23600-23609 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 23610-23619 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 23620-23629 - 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 23630-23639 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 23640-23649 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 23650-23659 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 23660-23669 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 23670-23679 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 30, // 23680-23689 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 23690-23699 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 23700-23709 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 23710-23719 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 23720-23729 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23730-23739 - 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 23740-23749 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 23750-23759 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 23760-23769 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 23770-23779 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 23780-23789 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23790-23799 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 23800-23809 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 23810-23819 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 23820-23829 - 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 23830-23839 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 23840-23849 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 23850-23859 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 23860-23869 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 23870-23879 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 23880-23889 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 23890-23899 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 23900-23909 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 23910-23919 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 28, // 23920-23929 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 23930-23939 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 23940-23949 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 23950-23959 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 23960-23969 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 23970-23979 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 23980-23989 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 23990-23999 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 24000-24009 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 24010-24019 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 24020-24029 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24030-24039 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 24040-24049 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24050-24059 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24060-24069 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 24070-24079 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 24080-24089 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 24090-24099 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 24100-24109 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 24110-24119 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24120-24129 - 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 24130-24139 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24140-24149 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 24150-24159 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 24160-24169 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 24170-24179 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 24180-24189 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 24190-24199 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 24200-24209 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24210-24219 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 24220-24229 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 24230-24239 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 24240-24249 - 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 24250-24259 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 24260-24269 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24270-24279 - 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 24280-24289 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 24290-24299 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 24300-24309 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 24310-24319 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 24320-24329 - 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 24330-24339 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 24340-24349 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 24350-24359 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24360-24369 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 24370-24379 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24380-24389 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 24390-24399 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 24400-24409 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 24410-24419 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 24420-24429 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 24430-24439 - 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 24440-24449 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 24450-24459 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 24460-24469 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 24470-24479 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 24480-24489 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 24490-24499 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 24500-24509 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 24510-24519 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 24520-24529 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 24530-24539 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 24540-24549 - 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 24550-24559 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24560-24569 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 24570-24579 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24580-24589 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 24590-24599 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24600-24609 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24610-24619 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 24620-24629 - 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 24630-24639 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 24640-24649 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 24650-24659 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24660-24669 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 24670-24679 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 24680-24689 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 24690-24699 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 24700-24709 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 24710-24719 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24720-24729 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 24730-24739 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 24740-24749 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24750-24759 - 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 24760-24769 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24770-24779 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24780-24789 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 24790-24799 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 24800-24809 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24810-24819 - 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 24820-24829 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 24830-24839 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 24840-24849 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 24850-24859 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 24860-24869 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 24870-24879 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 24880-24889 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 24890-24899 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 24900-24909 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 24910-24919 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 24920-24929 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 24930-24939 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 24940-24949 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 24950-24959 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 24960-24969 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 24970-24979 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 24980-24989 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 24990-24999 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25000-25009 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 25010-25019 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25020-25029 - 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 25030-25039 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 25040-25049 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 25050-25059 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25060-25069 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 25070-25079 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 25080-25089 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 25090-25099 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25100-25109 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 25110-25119 - 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 25120-25129 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 25130-25139 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 25140-25149 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 25150-25159 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 25160-25169 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25170-25179 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 30, // 25180-25189 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 25190-25199 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 25200-25209 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 25210-25219 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 25220-25229 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 25230-25239 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 25240-25249 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 25250-25259 - 1, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 25260-25269 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 25270-25279 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 25280-25289 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25290-25299 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 25300-25309 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25310-25319 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 25320-25329 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 25330-25339 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 25340-25349 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 25350-25359 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 25360-25369 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 25370-25379 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25380-25389 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 25390-25399 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 25400-25409 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25410-25419 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 25420-25429 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 25430-25439 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 25440-25449 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 25450-25459 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 25460-25469 - 1, 52, 51, 50, 49, 48, 47, 46, 45, 44, // 25470-25479 - 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 25480-25489 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 25490-25499 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 25500-25509 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25510-25519 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 25520-25529 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 25530-25539 - 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 25540-25549 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25550-25559 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 25560-25569 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 25570-25579 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 25580-25589 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25590-25599 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 25600-25609 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25610-25619 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25620-25629 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 25630-25639 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 25640-25649 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 25650-25659 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 25660-25669 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 25670-25679 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25680-25689 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 25690-25699 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 25700-25709 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 25710-25719 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25720-25729 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 25730-25739 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 25740-25749 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 25750-25759 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 25760-25769 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 25770-25779 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25780-25789 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 25790-25799 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 25800-25809 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 25810-25819 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 25820-25829 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25830-25839 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 25840-25849 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 25850-25859 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 25860-25869 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 25870-25879 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 25880-25889 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 25890-25899 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 25900-25909 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 25910-25919 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25920-25929 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 25930-25939 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 25940-25949 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 25950-25959 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 25960-25969 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 25970-25979 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 25980-25989 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 25990-25999 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 26000-26009 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 26010-26019 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 26020-26029 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26030-26039 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26040-26049 - 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 26050-26059 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 26060-26069 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26070-26079 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 26080-26089 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 26090-26099 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 26100-26109 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 26110-26119 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 26120-26129 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26130-26139 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26140-26149 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 26150-26159 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26160-26169 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 26170-26179 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 26180-26189 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26190-26199 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 26200-26209 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 26210-26219 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 26220-26229 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 26230-26239 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 26240-26249 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26250-26259 - 1, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 26260-26269 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 26270-26279 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26280-26289 - 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 26290-26299 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 26300-26309 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 26310-26319 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 26320-26329 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 26330-26339 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 26340-26349 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 26350-26359 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26360-26369 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 26370-26379 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 26380-26389 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 26390-26399 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 26400-26409 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 26410-26419 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 26420-26429 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 26430-26439 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 26440-26449 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 26450-26459 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 26460-26469 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 26470-26479 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 26480-26489 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 26490-26499 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26500-26509 - 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 26510-26519 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 26520-26529 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 26530-26539 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 26540-26549 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 26550-26559 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26560-26569 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 26570-26579 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26580-26589 - 1, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 26590-26599 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 26600-26609 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 26610-26619 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 26620-26629 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 26630-26639 - 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 26640-26649 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 26650-26659 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 26660-26669 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26670-26679 - 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 26680-26689 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 26690-26699 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26700-26709 - 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 26710-26719 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 26720-26729 - 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 26730-26739 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 26740-26749 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 26750-26759 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 26760-26769 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 26770-26779 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 26780-26789 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26790-26799 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26800-26809 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 26810-26819 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 26820-26829 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 26830-26839 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 26840-26849 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26850-26859 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 26860-26869 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 26870-26879 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26880-26889 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 26890-26899 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 26900-26909 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26910-26919 - 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 26920-26929 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 26930-26939 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 26940-26949 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 26950-26959 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 26960-26969 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 26970-26979 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 26980-26989 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 26990-26999 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27000-27009 - 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 27010-27019 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27020-27029 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27030-27039 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 27040-27049 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 27050-27059 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 27060-27069 - 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 27070-27079 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27080-27089 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27090-27099 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 18, // 27100-27109 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 27110-27119 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 27120-27129 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27130-27139 - 3, 2, 1, 36, 35, 34, 33, 32, 31, 30, // 27140-27149 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 27150-27159 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 27160-27169 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 27170-27179 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27180-27189 - 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 27190-27199 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27200-27209 - 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 27210-27219 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 27220-27229 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 27230-27239 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27240-27249 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 27250-27259 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27260-27269 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 27270-27279 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 27280-27289 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 27290-27299 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 27300-27309 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 27310-27319 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 27320-27329 - 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 27330-27339 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 27340-27349 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27350-27359 - 1, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 27360-27369 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 27370-27379 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 27380-27389 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 27390-27399 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 27400-27409 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 27410-27419 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 27420-27429 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 27430-27439 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 27440-27449 - 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 27450-27459 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 27460-27469 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 27470-27479 - 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 27480-27489 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 27490-27499 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 27500-27509 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 27510-27519 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 27520-27529 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 27530-27539 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27540-27549 - 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 27550-27559 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 27560-27569 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27570-27579 - 1, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 27580-27589 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 27590-27599 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27600-27609 - 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 27610-27619 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27620-27629 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 27630-27639 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 27640-27649 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 27650-27659 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27660-27669 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 27670-27679 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 27680-27689 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 27690-27699 - 1, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 27700-27709 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 27710-27719 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27720-27729 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 27730-27739 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 27740-27749 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27750-27759 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 27760-27769 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 27770-27779 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27780-27789 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 27790-27799 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 27800-27809 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 27810-27819 - 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 27820-27829 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 27830-27839 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 27840-27849 - 1, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 27850-27859 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 27860-27869 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27870-27879 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 27880-27889 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 27890-27899 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 27900-27909 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 27910-27919 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 27920-27929 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 27930-27939 - 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 27940-27949 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 27950-27959 - 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 27960-27969 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 27970-27979 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 27980-27989 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 27990-27999 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 28000-28009 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 28010-28019 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 28020-28029 - 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 28030-28039 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28040-28049 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 28050-28059 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 28060-28069 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28070-28079 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 28080-28089 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 28090-28099 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 28100-28109 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 28110-28119 - 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 28120-28129 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 28130-28139 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28140-28149 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 28150-28159 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 28160-28169 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28170-28179 - 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 28180-28189 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28190-28199 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28200-28209 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 28210-28219 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 48, // 28220-28229 - 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, // 28230-28239 - 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 28240-28249 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 28250-28259 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 28260-28269 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 28270-28279 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 28280-28289 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 28290-28299 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 28300-28309 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 28310-28319 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 28320-28329 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 28330-28339 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 28340-28349 - 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 28350-28359 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 28360-28369 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 28370-28379 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 28380-28389 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 28390-28399 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 28400-28409 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 28410-28419 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 28420-28429 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 28430-28439 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 28440-28449 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 28450-28459 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 28460-28469 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 28470-28479 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 28480-28489 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 28490-28499 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 28500-28509 - 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 28510-28519 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 28520-28529 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 28530-28539 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 28540-28549 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 28550-28559 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28560-28569 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 28570-28579 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28580-28589 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 28590-28599 - 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 28600-28609 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 28610-28619 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 28620-28629 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 28630-28639 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 28640-28649 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 28650-28659 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 28660-28669 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 28670-28679 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 28680-28689 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 28690-28699 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 28700-28709 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 28710-28719 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 28720-28729 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 28730-28739 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28740-28749 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 28750-28759 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28760-28769 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 28770-28779 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 28780-28789 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 28790-28799 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 28800-28809 - 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 28810-28819 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 28820-28829 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 28830-28839 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 28840-28849 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 28850-28859 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 28860-28869 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 28870-28879 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 28880-28889 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28890-28899 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 28900-28909 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28910-28919 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 28920-28929 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 28930-28939 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 28940-28949 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 28950-28959 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 28960-28969 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 28970-28979 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 28980-28989 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 28990-28999 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 29000-29009 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 29010-29019 - 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 29020-29029 - 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 29030-29039 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 29040-29049 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 29050-29059 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 29060-29069 - 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 29070-29079 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 29080-29089 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29090-29099 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 29100-29109 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29110-29119 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 29120-29129 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 29130-29139 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 29140-29149 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 29150-29159 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 29160-29169 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 29170-29179 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29180-29189 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29190-29199 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 29200-29209 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29210-29219 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29220-29229 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29230-29239 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 29240-29249 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 29250-29259 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 29260-29269 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 29270-29279 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 29280-29289 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 29290-29299 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 29300-29309 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 29310-29319 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 29320-29329 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 29330-29339 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 29340-29349 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29350-29359 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 29360-29369 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29370-29379 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 29380-29389 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 29390-29399 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29400-29409 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29410-29419 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 29420-29429 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 29430-29439 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 29440-29449 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 29450-29459 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29460-29469 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 29470-29479 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 29480-29489 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29490-29499 - 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 29500-29509 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 29510-29519 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 29520-29529 - 1, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 29530-29539 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 29540-29549 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 29550-29559 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 29560-29569 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 29570-29579 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 29580-29589 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 29590-29599 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29600-29609 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 29610-29619 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 29620-29629 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 29630-29639 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 29640-29649 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29650-29659 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 29660-29669 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29670-29679 - 3, 2, 1, 34, 33, 32, 31, 30, 29, 28, // 29680-29689 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 29690-29699 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 29700-29709 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 29710-29719 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 29720-29729 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29730-29739 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29740-29749 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 29750-29759 - 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 29760-29769 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 29770-29779 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 29780-29789 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29790-29799 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 29800-29809 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 29810-29819 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29820-29829 - 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 29830-29839 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 29840-29849 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29850-29859 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 29860-29869 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 29870-29879 - 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 29880-29889 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 29890-29899 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 29900-29909 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 29910-29919 - 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 29920-29929 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 29930-29939 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 29940-29949 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 29950-29959 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 29960-29969 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 29970-29979 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 29980-29989 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 29990-29999 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30000-30009 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 30010-30019 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 30020-30029 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 30030-30039 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 30040-30049 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 30050-30059 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30060-30069 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 30070-30079 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 30080-30089 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 30090-30099 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 30100-30109 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 30110-30119 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30120-30129 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 22, // 30130-30139 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 30140-30149 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30150-30159 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 30160-30169 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30170-30179 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 30180-30189 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 30190-30199 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 30200-30209 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30210-30219 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 30220-30229 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30230-30239 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30240-30249 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 30250-30259 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 30260-30269 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 30270-30279 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30280-30289 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 30290-30299 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 30300-30309 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 30310-30319 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 30320-30329 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30330-30339 - 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 30340-30349 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 30350-30359 - 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 30360-30369 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 30370-30379 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 30380-30389 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30390-30399 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 30400-30409 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 30410-30419 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 30420-30429 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 30430-30439 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 30440-30449 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 30450-30459 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 30460-30469 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 30470-30479 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30480-30489 - 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 30490-30499 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 30500-30509 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 30510-30519 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 30520-30529 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 30530-30539 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30540-30549 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 18, // 30550-30559 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 30560-30569 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 30570-30579 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30580-30589 - 3, 2, 1, 38, 37, 36, 35, 34, 33, 32, // 30590-30599 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 30600-30609 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 30610-30619 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30620-30629 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 30630-30639 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 30640-30649 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30650-30659 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30660-30669 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 30670-30679 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 30680-30689 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 30690-30699 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 30700-30709 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 30710-30719 - 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 30720-30729 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 30730-30739 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 30740-30749 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 30750-30759 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 30760-30769 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 30770-30779 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 30780-30789 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30790-30799 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 30800-30809 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 30810-30819 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 30820-30829 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 30830-30839 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30840-30849 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 30850-30859 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 30860-30869 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30870-30879 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 30880-30889 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 30890-30899 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30900-30909 - 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 30910-30919 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30920-30929 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 30930-30939 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 30940-30949 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 30950-30959 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 30960-30969 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 30970-30979 - 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 30980-30989 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 30990-30999 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 31000-31009 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 31010-31019 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 31020-31029 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 31030-31039 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31040-31049 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 31050-31059 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 31060-31069 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 31070-31079 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31080-31089 - 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 31090-31099 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 31100-31109 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31110-31119 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 31120-31129 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 31130-31139 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 31140-31149 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 31150-31159 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31160-31169 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 31170-31179 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 31180-31189 - 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 31190-31199 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 31200-31209 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 31210-31219 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 31220-31229 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 31230-31239 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 31240-31249 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 31250-31259 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 31260-31269 - 1, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 31270-31279 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 31280-31289 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31290-31299 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 31300-31309 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 31310-31319 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 31320-31329 - 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 31330-31339 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31340-31349 - 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 31350-31359 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 31360-31369 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 31370-31379 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 31380-31389 - 1, 2, 1, 4, 3, 2, 1, 72, 71, 70, // 31390-31399 - 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, // 31400-31409 - 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, // 31410-31419 - 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, // 31420-31429 - 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 31430-31439 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 31440-31449 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 31450-31459 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 31460-31469 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 31470-31479 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 31480-31489 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 31490-31499 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31500-31509 - 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 31510-31519 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31520-31529 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31530-31539 - 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 31540-31549 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31550-31559 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 31560-31569 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 31570-31579 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 31580-31589 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31590-31599 - 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 31600-31609 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31610-31619 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 31620-31629 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 31630-31639 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 31640-31649 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 31650-31659 - 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 31660-31669 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31670-31679 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 31680-31689 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 31690-31699 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 31700-31709 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31710-31719 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 31720-31729 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31730-31739 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31740-31749 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 31750-31759 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 31760-31769 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 31770-31779 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 31780-31789 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 31790-31799 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31800-31809 - 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 31810-31819 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 31820-31829 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31830-31839 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 31840-31849 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 31850-31859 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 31860-31869 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 31870-31879 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 31880-31889 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31890-31899 - 7, 6, 5, 4, 3, 2, 1, 50, 49, 48, // 31900-31909 - 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, // 31910-31919 - 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 31920-31929 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 31930-31939 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 31940-31949 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 31950-31959 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 31960-31969 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 31970-31979 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 31980-31989 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 31990-31999 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 32000-32009 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 32010-32019 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 32020-32029 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 32030-32039 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32040-32049 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 32050-32059 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 32060-32069 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 32070-32079 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 32080-32089 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 32090-32099 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 32100-32109 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 32110-32119 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 32120-32129 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32130-32139 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 32140-32149 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 32150-32159 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 32160-32169 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 32170-32179 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 32180-32189 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 32190-32199 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 32200-32209 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 32210-32219 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 32220-32229 - 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 32230-32239 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32240-32249 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 32250-32259 - 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 32260-32269 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 32270-32279 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 32280-32289 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 32290-32299 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 32300-32309 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32310-32319 - 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 32320-32329 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32330-32339 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 32340-32349 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 32350-32359 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 32360-32369 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 32370-32379 - 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 32380-32389 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32390-32399 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32400-32409 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 32410-32419 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 32420-32429 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32430-32439 - 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 32440-32449 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 32450-32459 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 32460-32469 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 32470-32479 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32480-32489 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 32490-32499 - 3, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 32500-32509 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 32510-32519 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32520-32529 - 1, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 32530-32539 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 32540-32549 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32550-32559 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 32560-32569 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 32570-32579 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 32580-32589 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 32590-32599 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 32600-32609 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32610-32619 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 32620-32629 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 32630-32639 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 32640-32649 - 3, 2, 1, 34, 33, 32, 31, 30, 29, 28, // 32650-32659 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 32660-32669 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 32670-32679 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 32680-32689 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 32690-32699 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 32700-32709 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 30, // 32710-32719 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 32720-32729 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 32730-32739 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 32740-32749 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 32750-32759 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32760-32769 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 32770-32779 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 32780-32789 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 32790-32799 - 1, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 32800-32809 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 32810-32819 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 32820-32829 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 32830-32839 - 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 32840-32849 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 32850-32859 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 32860-32869 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 32870-32879 - 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 32880-32889 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 32890-32899 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 32900-32909 - 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 32910-32919 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 32920-32929 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 32930-32939 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 32940-32949 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 32950-32959 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 32960-32969 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 32970-32979 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 32980-32989 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 32990-32999 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 33000-33009 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 33010-33019 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 33020-33029 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 33030-33039 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 33040-33049 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 33050-33059 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33060-33069 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 33070-33079 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 33080-33089 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 33090-33099 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 33100-33109 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 30, // 33110-33119 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 33120-33129 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 33130-33139 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 33140-33149 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33150-33159 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 33160-33169 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 33170-33179 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33180-33189 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 33190-33199 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 33200-33209 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 33210-33219 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 33220-33229 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 33230-33239 - 7, 6, 5, 4, 3, 2, 1, 40, 39, 38, // 33240-33249 - 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 33250-33259 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 33260-33269 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 33270-33279 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 33280-33289 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33290-33299 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33300-33309 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 33310-33319 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 33320-33329 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 33330-33339 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 33340-33349 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 33350-33359 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 33360-33369 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 33370-33379 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33380-33389 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 33390-33399 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 33400-33409 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 33410-33419 - 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 33420-33429 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 33430-33439 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 33440-33449 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 33450-33459 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 33460-33469 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 33470-33479 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 33480-33489 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 33490-33499 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 33500-33509 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33510-33519 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 33520-33529 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 33530-33539 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 33540-33549 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 33550-33559 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 33560-33569 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 33570-33579 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 33580-33589 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 33590-33599 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 33600-33609 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 33610-33619 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 33620-33629 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 33630-33639 - 1, 6, 5, 4, 3, 2, 1, 32, 31, 30, // 33640-33649 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 33650-33659 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 33660-33669 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 33670-33679 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 33680-33689 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 33690-33699 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 33700-33709 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 33710-33719 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 33720-33729 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 33730-33739 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 33740-33749 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 33750-33759 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 33760-33769 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 33770-33779 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33780-33789 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 33790-33799 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 33800-33809 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 33810-33819 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 33820-33829 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 33830-33839 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33840-33849 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 33850-33859 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 33860-33869 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 33870-33879 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 33880-33889 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 33890-33899 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33900-33909 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 33910-33919 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 33920-33929 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 33930-33939 - 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 33940-33949 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 33950-33959 - 1, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 33960-33969 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 33970-33979 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 33980-33989 - 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 33990-33999 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 34000-34009 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 34010-34019 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34020-34029 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 34030-34039 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 34040-34049 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 34050-34059 - 1, 62, 61, 60, 59, 58, 57, 56, 55, 54, // 34060-34069 - 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, // 34070-34079 - 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 34080-34089 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 34090-34099 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 34100-34109 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 34110-34119 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 34120-34129 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34130-34139 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 34140-34149 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 34150-34159 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34160-34169 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 34170-34179 - 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 34180-34189 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 34190-34199 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34200-34209 - 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 34210-34219 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34220-34229 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 34230-34239 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 34240-34249 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 34250-34259 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 34260-34269 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 34270-34279 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 34280-34289 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 34290-34299 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 34300-34309 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 34310-34319 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 34320-34329 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 34330-34339 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34340-34349 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34350-34359 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 34360-34369 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34370-34379 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 34380-34389 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 34390-34399 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 34400-34409 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34410-34419 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 34420-34429 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 34430-34439 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 34440-34449 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 34450-34459 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 34460-34469 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 34470-34479 - 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 34480-34489 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 34490-34499 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34500-34509 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 34510-34519 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 34520-34529 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 34530-34539 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 34, // 34540-34549 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 34550-34559 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 34560-34569 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 34570-34579 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 34580-34589 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 34590-34599 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 34600-34609 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 34610-34619 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34620-34629 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 34630-34639 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 34640-34649 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 34650-34659 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 34660-34669 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 34670-34679 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 34680-34689 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 34690-34699 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 34700-34709 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34710-34719 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 34720-34729 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 34730-34739 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 34740-34749 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 34750-34759 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 34760-34769 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34770-34779 - 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 34780-34789 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 34790-34799 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 34800-34809 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 34810-34819 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 34820-34829 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34830-34839 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 22, // 34840-34849 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 34850-34859 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34860-34869 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 34870-34879 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 34880-34889 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 34890-34899 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 34900-34909 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 20, // 34910-34919 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 34920-34929 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 34930-34939 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 34940-34949 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34950-34959 - 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 34960-34969 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 34970-34979 - 1, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 34980-34989 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 34990-34999 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 35000-35009 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 35010-35019 - 3, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 35020-35029 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 35030-35039 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35040-35049 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 35050-35059 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 35060-35069 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35070-35079 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 35080-35089 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 35090-35099 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 35100-35109 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 35110-35119 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 35120-35129 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35130-35139 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 35140-35149 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 35150-35159 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35160-35169 - 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 35170-35179 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 35180-35189 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35190-35199 - 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 35200-35209 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35210-35219 - 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 35220-35229 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 35230-35239 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35240-35249 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 35250-35259 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 35260-35269 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 35270-35279 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35280-35289 - 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 35290-35299 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35300-35309 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 35310-35319 - 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 35320-35329 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 35330-35339 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 35340-35349 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 35350-35359 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 35360-35369 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35370-35379 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 35380-35389 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 35390-35399 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 35400-35409 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 35410-35419 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 35420-35429 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 35430-35439 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 35440-35449 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35450-35459 - 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 35460-35469 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 35470-35479 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35480-35489 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 35490-35499 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 35500-35509 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35510-35519 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 35520-35529 - 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 35530-35539 - 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 35540-35549 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 35550-35559 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 35560-35569 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 35570-35579 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35580-35589 - 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 35590-35599 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 35600-35609 - 7, 6, 5, 4, 3, 2, 1, 54, 53, 52, // 35610-35619 - 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, // 35620-35629 - 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 35630-35639 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 35640-35649 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 35650-35659 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35660-35669 - 1, 6, 5, 4, 3, 2, 1, 52, 51, 50, // 35670-35679 - 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, // 35680-35689 - 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 35690-35699 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 35700-35709 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 35710-35719 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 35720-35729 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 35730-35739 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 35740-35749 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 35750-35759 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35760-35769 - 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 35770-35779 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 35780-35789 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 35790-35799 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 35800-35809 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 35810-35819 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35820-35829 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 35830-35839 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35840-35849 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 35850-35859 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 35860-35869 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 35870-35879 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 35880-35889 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 35890-35899 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35900-35909 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 35910-35919 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 35920-35929 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 35930-35939 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 35940-35949 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 35950-35959 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 35960-35969 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 35970-35979 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 35980-35989 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 35990-35999 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 36000-36009 - 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 36010-36019 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 36020-36029 - 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 36030-36039 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 36040-36049 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36050-36059 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 36060-36069 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 36070-36079 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 36080-36089 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 36090-36099 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 36100-36109 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 36110-36119 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36120-36129 - 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 36130-36139 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36140-36149 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36150-36159 - 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 36160-36169 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 36170-36179 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 36180-36189 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 36190-36199 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 36200-36209 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 36210-36219 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 36220-36229 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36230-36239 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36240-36249 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36250-36259 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 36260-36269 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 36270-36279 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36280-36289 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 36290-36299 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 36300-36309 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 36310-36319 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 36320-36329 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36330-36339 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 36340-36349 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 36350-36359 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36360-36369 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 36370-36379 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 44, // 36380-36389 - 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 36390-36399 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 36400-36409 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 36410-36419 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36420-36429 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 36430-36439 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36440-36449 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 36450-36459 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 36460-36469 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 36470-36479 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36480-36489 - 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 36490-36499 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 36500-36509 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36510-36519 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 36520-36529 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36530-36539 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36540-36549 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 36550-36559 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 36560-36569 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36570-36579 - 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 36580-36589 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 36590-36599 - 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 36600-36609 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 36610-36619 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 36620-36629 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 36630-36639 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 36640-36649 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 36650-36659 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36660-36669 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 36670-36679 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 36680-36689 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 36690-36699 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 36700-36709 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 36710-36719 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 36720-36729 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 36730-36739 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 36740-36749 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36750-36759 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 36760-36769 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 36770-36779 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 36780-36789 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 36790-36799 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 36800-36809 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36810-36819 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36820-36829 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 36830-36839 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 36840-36849 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 36850-36859 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 36860-36869 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 36870-36879 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 36880-36889 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 36890-36899 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36900-36909 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 36910-36919 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 36920-36929 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36930-36939 - 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 36940-36949 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 36950-36959 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 36960-36969 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 36970-36979 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 36980-36989 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 36990-36999 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 37000-37009 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 37010-37019 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 37020-37029 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 37030-37039 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 37040-37049 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 37050-37059 - 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 37060-37069 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37070-37079 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 37080-37089 - 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 37090-37099 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37100-37109 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 37110-37119 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 37120-37129 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 37130-37139 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 37140-37149 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 37150-37159 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37160-37169 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37170-37179 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 37180-37189 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 37190-37199 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37200-37209 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 37210-37219 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 37220-37229 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 37230-37239 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 37240-37249 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 37250-37259 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 37260-37269 - 3, 2, 1, 4, 3, 2, 1, 30, 29, 28, // 37270-37279 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 37280-37289 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37290-37299 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 37300-37309 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 37310-37319 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37320-37329 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 37330-37339 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37340-37349 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 37350-37359 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 37360-37369 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 37370-37379 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37380-37389 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 37390-37399 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 37400-37409 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 37410-37419 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 37420-37429 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37430-37439 - 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 37440-37449 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 37450-37459 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 37460-37469 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 37470-37479 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 37480-37489 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 37490-37499 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 37500-37509 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 37510-37519 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 37520-37529 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 37530-37539 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 37540-37549 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37550-37559 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 37560-37569 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 37570-37579 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 37580-37589 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37590-37599 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 37600-37609 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 37610-37619 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 37620-37629 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 37630-37639 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 37640-37649 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 37650-37659 - 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 37660-37669 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 37670-37679 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37680-37689 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 37690-37699 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37700-37709 - 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 37710-37719 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 37720-37729 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37730-37739 - 7, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 37740-37749 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 37750-37759 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 37760-37769 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37770-37779 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 37780-37789 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 37790-37799 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37800-37809 - 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 37810-37819 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37820-37829 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37830-37839 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 37840-37849 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 37850-37859 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37860-37869 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 37870-37879 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 37880-37889 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 37890-37899 - 7, 6, 5, 4, 3, 2, 1, 44, 43, 42, // 37900-37909 - 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 37910-37919 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 37920-37929 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 37930-37939 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 37940-37949 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 37950-37959 - 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 37960-37969 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 37970-37979 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 37980-37989 - 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 37990-37999 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38000-38009 - 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 38010-38019 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 38020-38029 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 38030-38039 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 38040-38049 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 38050-38059 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 38060-38069 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38070-38079 - 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 38080-38089 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 38090-38099 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38100-38109 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 30, // 38110-38119 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 38120-38129 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 38130-38139 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 38140-38149 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 38150-38159 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 38160-38169 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 38170-38179 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 38180-38189 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 38190-38199 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 38200-38209 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 38210-38219 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38220-38229 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 38230-38239 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 38240-38249 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38250-38259 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38260-38269 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 38270-38279 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 38280-38289 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 38290-38299 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 38300-38309 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 38310-38319 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 38320-38329 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 38330-38339 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38340-38349 - 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 38350-38359 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38360-38369 - 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 38370-38379 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38380-38389 - 3, 2, 1, 38, 37, 36, 35, 34, 33, 32, // 38390-38399 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 38400-38409 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 38410-38419 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38420-38429 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 38430-38439 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 38440-38449 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 38450-38459 - 1, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 38460-38469 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 38470-38479 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 38480-38489 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38490-38499 - 1, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 38500-38509 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 38510-38519 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 38520-38529 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38530-38539 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 38540-38549 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 38550-38559 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 24, // 38560-38569 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 38570-38579 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38580-38589 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 38590-38599 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 38600-38609 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 38610-38619 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 38620-38629 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 38630-38639 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38640-38649 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 38650-38659 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 38660-38669 - 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 38670-38679 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38680-38689 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 38690-38699 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 38700-38709 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 38710-38719 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 38720-38729 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 38730-38739 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 38740-38749 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 38750-38759 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 38760-38769 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38770-38779 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 38780-38789 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38790-38799 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 38800-38809 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38810-38819 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38820-38829 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 38830-38839 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38840-38849 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38850-38859 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 38860-38869 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 38870-38879 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38880-38889 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38890-38899 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 38900-38909 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 38910-38919 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 38920-38929 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 38930-38939 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38940-38949 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 38950-38959 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 38960-38969 - 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 38970-38979 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 38980-38989 - 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 38990-38999 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 39000-39009 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 39010-39019 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 39020-39029 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39030-39039 - 1, 2, 1, 4, 3, 2, 1, 32, 31, 30, // 39040-39049 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 39050-39059 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 39060-39069 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 39070-39079 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 39080-39089 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 39090-39099 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 39100-39109 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 39110-39119 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 39120-39129 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 39130-39139 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 39140-39149 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 39150-39159 - 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 39160-39169 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39170-39179 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39180-39189 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 39190-39199 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 39200-39209 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 39210-39219 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 39220-39229 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 39230-39239 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39240-39249 - 1, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 39250-39259 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 39260-39269 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 39270-39279 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 39280-39289 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 39290-39299 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 39300-39309 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 39310-39319 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 39320-39329 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39330-39339 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 39340-39349 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 39350-39359 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 39360-39369 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 39370-39379 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 39380-39389 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 39390-39399 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 39400-39409 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 39410-39419 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 39420-39429 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 39430-39439 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 39440-39449 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39450-39459 - 1, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 39460-39469 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 39470-39479 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 39480-39489 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 39490-39499 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 39500-39509 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39510-39519 - 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 39520-39529 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39530-39539 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39540-39549 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 39550-39559 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 39560-39569 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39570-39579 - 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 39580-39589 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 39590-39599 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 39600-39609 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 39610-39619 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 39620-39629 - 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 39630-39639 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 39640-39649 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 39650-39659 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 39660-39669 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 39670-39679 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 39680-39689 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 39690-39699 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 39700-39709 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 39710-39719 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 39720-39729 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 39730-39739 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 39740-39749 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39750-39759 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 39760-39769 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 39770-39779 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39780-39789 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 39790-39799 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 39800-39809 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39810-39819 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 39820-39829 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 39830-39839 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 39840-39849 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 39850-39859 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 39860-39869 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 39870-39879 - 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 39880-39889 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39890-39899 - 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 39900-39909 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 39910-39919 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 39920-39929 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 39930-39939 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 39940-39949 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 39950-39959 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 39960-39969 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 39970-39979 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 20, // 39980-39989 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 39990-39999 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 40000-40009 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 40010-40019 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40020-40029 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 24, // 40030-40039 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 40040-40049 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40050-40059 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 40060-40069 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 40070-40079 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 40080-40089 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 40090-40099 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40100-40109 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40110-40119 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 22, // 40120-40129 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 40130-40139 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40140-40149 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 40150-40159 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 40160-40169 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 40170-40179 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 40180-40189 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 40190-40199 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40200-40209 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 40210-40219 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40220-40229 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 40230-40239 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40240-40249 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 40250-40259 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 40260-40269 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 40270-40279 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 54, // 40280-40289 - 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, // 40290-40299 - 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 40300-40309 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 40310-40319 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 40320-40329 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40330-40339 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 40340-40349 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 40350-40359 - 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 40360-40369 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 40370-40379 - 7, 6, 5, 4, 3, 2, 1, 36, 35, 34, // 40380-40389 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 40390-40399 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 40400-40409 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40410-40419 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 40420-40429 - 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 40430-40439 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 40440-40449 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 40450-40459 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40460-40469 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40470-40479 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 40480-40489 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 40490-40499 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 40500-40509 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 40510-40519 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 40520-40529 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40530-40539 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 40540-40549 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 40550-40559 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 40560-40569 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 40570-40579 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 40580-40589 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 40590-40599 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 40600-40609 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 40610-40619 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 40620-40629 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 54, // 40630-40639 - 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, // 40640-40649 - 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 40650-40659 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 40660-40669 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 40670-40679 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40680-40689 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 40690-40699 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 40700-40709 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 40710-40719 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 40720-40729 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 40730-40739 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40740-40749 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 40750-40759 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 40760-40769 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 40770-40779 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 40780-40789 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40790-40799 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40800-40809 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 40810-40819 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 40820-40829 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40830-40839 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 40840-40849 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 40850-40859 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 40860-40869 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 40870-40879 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 40880-40889 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 40890-40899 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 40900-40909 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 40910-40919 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 40920-40929 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 40930-40939 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 40940-40949 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 40950-40959 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40960-40969 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 40970-40979 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 40980-40989 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 40990-40999 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41000-41009 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 41010-41019 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 41020-41029 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 41030-41039 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 41040-41049 - 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 41050-41059 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 41060-41069 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 41070-41079 - 1, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 41080-41089 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 41090-41099 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 41100-41109 - 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 41110-41119 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41120-41129 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41130-41139 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 41140-41149 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41150-41159 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 41160-41169 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 41170-41179 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 41180-41189 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41190-41199 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 41200-41209 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 41210-41219 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 41220-41229 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 41230-41239 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 41240-41249 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 41250-41259 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 41260-41269 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41270-41279 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 41280-41289 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 34, // 41290-41299 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 41300-41309 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 41310-41319 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 41320-41329 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 41330-41339 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41340-41349 - 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 41350-41359 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 41360-41369 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41370-41379 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 41380-41389 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 41390-41399 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41400-41409 - 1, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 41410-41419 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 41420-41429 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 41430-41439 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 41440-41449 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 41450-41459 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 41460-41469 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 41470-41479 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41480-41489 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 41490-41499 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 41500-41509 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 41510-41519 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 41520-41529 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 41530-41539 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 30, // 41540-41549 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 41550-41559 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 41560-41569 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 41570-41579 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 41580-41589 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 41590-41599 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 41600-41609 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 41610-41619 - 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 41620-41629 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41630-41639 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 41640-41649 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 41650-41659 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 41660-41669 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41670-41679 - 1, 6, 5, 4, 3, 2, 1, 32, 31, 30, // 41680-41689 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 41690-41699 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 41700-41709 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 41710-41719 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 41720-41729 - 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 41730-41739 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 41740-41749 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 41750-41759 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41760-41769 - 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 41770-41779 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 41780-41789 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41790-41799 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 41800-41809 - 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 41810-41819 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 41820-41829 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 41830-41839 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 41840-41849 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 41850-41859 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 41860-41869 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 41870-41879 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 41880-41889 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 41890-41899 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 41900-41909 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 41910-41919 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 41920-41929 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41930-41939 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 41940-41949 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 41950-41959 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 41960-41969 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 41970-41979 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 41980-41989 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 41990-41999 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42000-42009 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 42010-42019 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 42020-42029 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42030-42039 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 42040-42049 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42050-42059 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42060-42069 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 42070-42079 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 42080-42089 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42090-42099 - 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 42100-42109 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 42110-42119 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42120-42129 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 42130-42139 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 42140-42149 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 42150-42159 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 42160-42169 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 42170-42179 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 42180-42189 - 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 42190-42199 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 42200-42209 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42210-42219 - 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 42220-42229 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 42230-42239 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 42240-42249 - 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 42250-42259 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 42260-42269 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42270-42279 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 42280-42289 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 42290-42299 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 42300-42309 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42310-42319 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 42320-42329 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 42330-42339 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 42340-42349 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 42350-42359 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42360-42369 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 42370-42379 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42380-42389 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 42390-42399 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 24, // 42400-42409 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 42410-42419 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42420-42429 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 42430-42439 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 42440-42449 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 42450-42459 - 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 42460-42469 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 42470-42479 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 42480-42489 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 42490-42499 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 42500-42509 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 42510-42519 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42520-42529 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 42530-42539 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 42540-42549 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 42550-42559 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 42560-42569 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 42570-42579 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 42580-42589 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 42590-42599 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42600-42609 - 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 42610-42619 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 42620-42629 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42630-42639 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 42640-42649 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 42650-42659 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 42660-42669 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 42670-42679 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 42680-42689 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 42690-42699 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 42700-42709 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 42710-42719 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 42720-42729 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 42730-42739 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 42740-42749 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 42750-42759 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 42760-42769 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 42770-42779 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 42780-42789 - 3, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 42790-42799 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 42800-42809 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 42810-42819 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 42820-42829 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 42830-42839 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42840-42849 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 42850-42859 - 3, 2, 1, 36, 35, 34, 33, 32, 31, 30, // 42860-42869 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 42870-42879 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 42880-42889 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 42890-42899 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 42900-42909 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42910-42919 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 42920-42929 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 42930-42939 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 42940-42949 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 42950-42959 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 42960-42969 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 42970-42979 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 42980-42989 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 42990-42999 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 43000-43009 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 43010-43019 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 43020-43029 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 43030-43039 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 43040-43049 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43050-43059 - 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 43060-43069 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 43070-43079 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43080-43089 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 43090-43099 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 43100-43109 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 43110-43119 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43120-43129 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 43130-43139 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43140-43149 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 43150-43159 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 43160-43169 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 43170-43179 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 43180-43189 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43190-43199 - 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 43200-43209 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43210-43219 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 43220-43229 - 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 43230-43239 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 43240-43249 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43250-43259 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43260-43269 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43270-43279 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 43280-43289 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 43290-43299 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43300-43309 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 43310-43319 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43320-43329 - 1, 60, 59, 58, 57, 56, 55, 54, 53, 52, // 43330-43339 - 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, // 43340-43349 - 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 43350-43359 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 43360-43369 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 43370-43379 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43380-43389 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 43390-43399 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 43400-43409 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 43410-43419 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 43420-43429 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43430-43439 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43440-43449 - 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 43450-43459 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 43460-43469 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43470-43479 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 43480-43489 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 43490-43499 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 43500-43509 - 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 43510-43519 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 43520-43529 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43530-43539 - 1, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 43540-43549 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 43550-43559 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43560-43569 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 43570-43579 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43580-43589 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 43590-43599 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 43600-43609 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 43610-43619 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 43620-43629 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 43630-43639 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 43640-43649 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43650-43659 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 43660-43669 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 43670-43679 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43680-43689 - 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 43690-43699 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43700-43709 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 43710-43719 - 1, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 43720-43729 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 43730-43739 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43740-43749 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 43750-43759 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 43760-43769 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 43770-43779 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 43780-43789 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 43790-43799 - 1, 52, 51, 50, 49, 48, 47, 46, 45, 44, // 43800-43809 - 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 43810-43819 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 43820-43829 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 43830-43839 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43840-43849 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 43850-43859 - 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 43860-43869 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 43870-43879 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 43880-43889 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 43890-43899 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43900-43909 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 43910-43919 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 43920-43929 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 43930-43939 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 43940-43949 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 43950-43959 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 43960-43969 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 43970-43979 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 43980-43989 - 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 43990-43999 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 44000-44009 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 44010-44019 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 44020-44029 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44030-44039 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 44040-44049 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 44050-44059 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44060-44069 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 44070-44079 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 44080-44089 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44090-44099 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44100-44109 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 44110-44119 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 44120-44129 - 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 44130-44139 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 44140-44149 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 44150-44159 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44160-44169 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 44170-44179 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 44180-44189 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44190-44199 - 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 44200-44209 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44210-44219 - 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 44220-44229 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 44230-44239 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 44240-44249 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 44250-44259 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 44260-44269 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 44270-44279 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 44280-44289 - 3, 2, 1, 58, 57, 56, 55, 54, 53, 52, // 44290-44299 - 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, // 44300-44309 - 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 44310-44319 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 44320-44329 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 44330-44339 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44340-44349 - 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 44350-44359 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44360-44369 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44370-44379 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 28, // 44380-44389 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 44390-44399 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 44400-44409 - 7, 6, 5, 4, 3, 2, 1, 32, 31, 30, // 44410-44419 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 44420-44429 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 44430-44439 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 44440-44449 - 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 44450-44459 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 44460-44469 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 44470-44479 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 44480-44489 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 44490-44499 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 44500-44509 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 44510-44519 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44520-44529 - 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 44530-44539 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 44540-44549 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 44550-44559 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 44560-44569 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 44570-44579 - 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 44580-44589 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 44590-44599 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 44600-44609 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 44610-44619 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 44620-44629 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 44630-44639 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 44640-44649 - 1, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 44650-44659 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 44660-44669 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 44670-44679 - 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 44680-44689 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 44690-44699 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44700-44709 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 44710-44719 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 44720-44729 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44730-44739 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 44740-44749 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 44750-44759 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 44760-44769 - 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 44770-44779 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 44780-44789 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 44790-44799 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 44800-44809 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 44810-44819 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 44820-44829 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 44830-44839 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 44840-44849 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 44850-44859 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 44860-44869 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 44870-44879 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 44880-44889 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 44890-44899 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 44900-44909 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 44910-44919 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 44920-44929 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 44930-44939 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 44940-44949 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 44950-44959 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 44960-44969 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 44970-44979 - 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 44980-44989 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 44990-44999 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 45000-45009 - 3, 2, 1, 40, 39, 38, 37, 36, 35, 34, // 45010-45019 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 45020-45029 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 45030-45039 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 45040-45049 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 45050-45059 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 45060-45069 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 45070-45079 - 3, 2, 1, 36, 35, 34, 33, 32, 31, 30, // 45080-45089 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 45090-45099 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 45100-45109 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 45110-45119 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 45120-45129 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 45130-45139 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 45140-45149 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45150-45159 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 45160-45169 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 45170-45179 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45180-45189 - 1, 6, 5, 4, 3, 2, 1, 36, 35, 34, // 45190-45199 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 45200-45209 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 45210-45219 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 45220-45229 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 45230-45239 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 45240-45249 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 45250-45259 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 45260-45269 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45270-45279 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 45280-45289 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 45290-45299 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 45300-45309 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 45310-45319 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 45320-45329 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 45330-45339 - 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 45340-45349 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45350-45359 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 45360-45369 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 45370-45379 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 45380-45389 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 45390-45399 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 45400-45409 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 45410-45419 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 45420-45429 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 42, // 45430-45439 - 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 45440-45449 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 45450-45459 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 45460-45469 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45470-45479 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45480-45489 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 45490-45499 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 45500-45509 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 45510-45519 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 45520-45529 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 45530-45539 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 45540-45549 - 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 45550-45559 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 45560-45569 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 45570-45579 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 45580-45589 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 45590-45599 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 45600-45609 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 45610-45619 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45620-45629 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45630-45639 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 45640-45649 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 45650-45659 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 45660-45669 - 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 45670-45679 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45680-45689 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 45690-45699 - 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 45700-45709 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 45710-45719 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 45720-45729 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 45730-45739 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45740-45749 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 45750-45759 - 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 45760-45769 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 38, // 45770-45779 - 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 45780-45789 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 45790-45799 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 45800-45809 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 45810-45819 - 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 45820-45829 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 45830-45839 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 45840-45849 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 45850-45859 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 45860-45869 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 45870-45879 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 45880-45889 - 3, 2, 1, 50, 49, 48, 47, 46, 45, 44, // 45890-45899 - 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 45900-45909 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 45910-45919 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 45920-45929 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 45930-45939 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 45940-45949 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 45950-45959 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 45960-45969 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 45970-45979 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 32, // 45980-45989 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 45990-45999 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 46000-46009 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46010-46019 - 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 46020-46029 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 46030-46039 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 46040-46049 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46050-46059 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46060-46069 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 46070-46079 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46080-46089 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 46090-46099 - 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 46100-46109 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 46110-46119 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46120-46129 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 46130-46139 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 46140-46149 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 46150-46159 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46160-46169 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46170-46179 - 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 46180-46189 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 46190-46199 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 46200-46209 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 46210-46219 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 46220-46229 - 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 46230-46239 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 46240-46249 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46250-46259 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46260-46269 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 46270-46279 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 46280-46289 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46290-46299 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 46300-46309 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 46310-46319 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 46320-46329 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 46330-46339 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 46340-46349 - 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 46350-46359 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 46360-46369 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46370-46379 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 46380-46389 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 46390-46399 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46400-46409 - 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 46410-46419 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 46420-46429 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 46430-46439 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 46440-46449 - 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 46450-46459 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46460-46469 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 46470-46479 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 46480-46489 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 46490-46499 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 46500-46509 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46510-46519 - 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 46520-46529 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 46530-46539 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 46540-46549 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 46550-46559 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 46560-46569 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 46570-46579 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 46580-46589 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46590-46599 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 46600-46609 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 46610-46619 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46620-46629 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 46630-46639 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 46640-46649 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46650-46659 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 46660-46669 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 46670-46679 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 46680-46689 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46690-46699 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 46700-46709 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46710-46719 - 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 46720-46729 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 46730-46739 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 46740-46749 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 46750-46759 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 46760-46769 - 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 46770-46779 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 46780-46789 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 46790-46799 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 46800-46809 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 46810-46819 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 46820-46829 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 46830-46839 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46840-46849 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 46850-46859 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 46860-46869 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 46870-46879 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 46880-46889 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 46890-46899 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 46900-46909 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 46910-46919 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46920-46929 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 46930-46939 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 46940-46949 - 7, 6, 5, 4, 3, 2, 1, 36, 35, 34, // 46950-46959 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 46960-46969 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 46970-46979 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 46980-46989 - 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 46990-46999 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 47000-47009 - 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 47010-47019 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 47020-47029 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47030-47039 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47040-47049 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 28, // 47050-47059 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 47060-47069 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 47070-47079 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 47080-47089 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 47090-47099 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47100-47109 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 47110-47119 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 47120-47129 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 47130-47139 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 47140-47149 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47150-47159 - 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 47160-47169 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 47170-47179 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 47180-47189 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 47190-47199 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 47200-47209 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47210-47219 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 47220-47229 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 47230-47239 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47240-47249 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 47250-47259 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 47260-47269 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 47270-47279 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 47280-47289 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 47290-47299 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 47300-47309 - 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 47310-47319 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 47320-47329 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 47330-47339 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47340-47349 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 47350-47359 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 47360-47369 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47370-47379 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 47380-47389 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 47390-47399 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 47400-47409 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 47410-47419 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47420-47429 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47430-47439 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 47440-47449 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 32, // 47450-47459 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 47460-47469 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 47470-47479 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47480-47489 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 47490-47499 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 47500-47509 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 47510-47519 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 47520-47529 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 47530-47539 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 47540-47549 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 47550-47559 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 47560-47569 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47570-47579 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47580-47589 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 47590-47599 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 47600-47609 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 47610-47619 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 47620-47629 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 47630-47639 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 47640-47649 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 22, // 47650-47659 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 47660-47669 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47670-47679 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 47680-47689 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 47690-47699 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47700-47709 - 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 47710-47719 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 47720-47729 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 47730-47739 - 1, 2, 1, 34, 33, 32, 31, 30, 29, 28, // 47740-47749 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 47750-47759 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 47760-47769 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 47770-47779 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47780-47789 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 47790-47799 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 47800-47809 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 47810-47819 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 47820-47829 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 47830-47839 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 47840-47849 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 47850-47859 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 47860-47869 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 47870-47879 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 47880-47889 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 47890-47899 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 47900-47909 - 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 47910-47919 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 47920-47929 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 47930-47939 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 47940-47949 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 47950-47959 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 47960-47969 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 47970-47979 - 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 47980-47989 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 47990-47999 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 48000-48009 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 48010-48019 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 20, // 48020-48029 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 48030-48039 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 48040-48049 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 48050-48059 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48060-48069 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 48070-48079 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48080-48089 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 48090-48099 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 48100-48109 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 48110-48119 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48120-48129 - 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 48130-48139 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 48140-48149 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 48150-48159 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 48160-48169 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 48170-48179 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 48180-48189 - 3, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 48190-48199 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 48200-48209 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48210-48219 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 48220-48229 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 48230-48239 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 48240-48249 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 48250-48259 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48260-48269 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48270-48279 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 48280-48289 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 48290-48299 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48300-48309 - 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 48310-48319 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 48320-48329 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 48330-48339 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48340-48349 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 48350-48359 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48360-48369 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48370-48379 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 48380-48389 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 48390-48399 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 48400-48409 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 48410-48419 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 48420-48429 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 48430-48439 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 48440-48449 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48450-48459 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 48460-48469 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 48470-48479 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 48480-48489 - 1, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 48490-48499 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 48500-48509 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48510-48519 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 48520-48529 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 48530-48539 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 48540-48549 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48550-48559 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 48560-48569 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 48570-48579 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 48580-48589 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 48590-48599 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48600-48609 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 48610-48619 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 48620-48629 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 48630-48639 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 48640-48649 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48650-48659 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48660-48669 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 52, // 48670-48679 - 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, // 48680-48689 - 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 48690-48699 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 48700-48709 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 48710-48719 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48720-48729 - 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 48730-48739 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 48740-48749 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 48750-48759 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 48760-48769 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 48770-48779 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 48780-48789 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 48790-48799 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 48800-48809 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 48810-48819 - 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 48820-48829 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 48830-48839 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 48840-48849 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 48850-48859 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 48860-48869 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48870-48879 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 48880-48889 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 48890-48899 - 7, 6, 5, 4, 3, 2, 1, 40, 39, 38, // 48900-48909 - 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 48910-48919 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 48920-48929 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 48930-48939 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 48940-48949 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 48950-48959 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48960-48969 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 48970-48979 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 48980-48989 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 48990-48999 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 49000-49009 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 49010-49019 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49020-49029 - 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 49030-49039 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 49040-49049 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 49050-49059 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 49060-49069 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49070-49079 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 49080-49089 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49090-49099 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 49100-49109 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 49110-49119 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 49120-49129 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 49130-49139 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 49140-49149 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 49150-49159 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 49160-49169 - 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 49170-49179 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49180-49189 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 49190-49199 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 49200-49209 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49210-49219 - 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 49220-49229 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 49230-49239 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49240-49249 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 49250-49259 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 49260-49269 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 49270-49279 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 49280-49289 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 49290-49299 - 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 49300-49309 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 49310-49319 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49320-49329 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 24, // 49330-49339 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 49340-49349 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49350-49359 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 22, // 49360-49369 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 49370-49379 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49380-49389 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 49390-49399 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 49400-49409 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 49410-49419 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 49420-49429 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 49430-49439 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49440-49449 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 49450-49459 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 49460-49469 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 49470-49479 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 49480-49489 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 49490-49499 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 49500-49509 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49510-49519 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 49520-49529 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 49530-49539 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 49540-49549 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 38, // 49550-49559 - 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 49560-49569 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 49570-49579 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 49580-49589 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 49590-49599 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 49600-49609 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 49610-49619 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 49620-49629 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 24, // 49630-49639 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 49640-49649 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49650-49659 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 49660-49669 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49670-49679 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 49680-49689 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 49690-49699 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49700-49709 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 49710-49719 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 49720-49729 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 49730-49739 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 49740-49749 - 7, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 49750-49759 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 49760-49769 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49770-49779 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 49780-49789 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49790-49799 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 49800-49809 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49810-49819 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 49820-49829 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 49830-49839 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 49840-49849 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 49850-49859 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49860-49869 - 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 49870-49879 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49880-49889 - 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 49890-49899 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 49900-49909 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 49910-49919 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 49920-49929 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 49930-49939 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 49940-49949 - 7, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 49950-49959 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 49960-49969 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 49970-49979 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 49980-49989 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 49990-49999 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 50000-50009 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50010-50019 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 50020-50029 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 50030-50039 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 50040-50049 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 50050-50059 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 50060-50069 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 50070-50079 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 50080-50089 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 50090-50099 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50100-50109 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 50110-50119 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 50120-50129 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 50130-50139 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 50140-50149 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 50150-50159 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 50160-50169 - 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 50170-50179 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 50180-50189 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 50190-50199 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 50200-50209 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50210-50219 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 50220-50229 - 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 50230-50239 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 50240-50249 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50250-50259 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 50260-50269 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 50270-50279 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 50280-50289 - 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 50290-50299 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50300-50309 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50310-50319 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 50320-50329 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 50330-50339 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 50340-50349 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 50350-50359 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 50360-50369 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 50370-50379 - 3, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 50380-50389 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 50390-50399 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50400-50409 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 50410-50419 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 50420-50429 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50430-50439 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 50440-50449 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 50450-50459 - 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 50460-50469 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 50470-50479 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 50480-50489 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 50490-50499 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 50500-50509 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 50510-50519 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 50520-50529 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 50530-50539 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 50540-50549 - 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 50550-50559 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 50560-50569 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50570-50579 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 50580-50589 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 28, // 50590-50599 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 50600-50609 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 50610-50619 - 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 50620-50629 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 50630-50639 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 50640-50649 - 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 50650-50659 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50660-50669 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 50670-50679 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 50680-50689 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 50690-50699 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 50700-50709 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 50710-50719 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 50720-50729 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50730-50739 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 50740-50749 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 50750-50759 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 50760-50769 - 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 50770-50779 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 32, // 50780-50789 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 50790-50799 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 50800-50809 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50810-50819 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 50820-50829 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 50830-50839 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 50840-50849 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 50850-50859 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 50860-50869 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 50870-50879 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50880-50889 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 50890-50899 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 50900-50909 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 50910-50919 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 50920-50929 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 50930-50939 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 50940-50949 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 50950-50959 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 50960-50969 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 50970-50979 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 50980-50989 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 50990-50999 - 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 51000-51009 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 51010-51019 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51020-51029 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51030-51039 - 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 51040-51049 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 51050-51059 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51060-51069 - 1, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 51070-51079 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 51080-51089 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 51090-51099 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 51100-51109 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 51110-51119 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51120-51129 - 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 51130-51139 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51140-51149 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 51150-51159 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 51160-51169 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 51170-51179 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51180-51189 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 51190-51199 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 51200-51209 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 51210-51219 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 51220-51229 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 51230-51239 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 51240-51249 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 51250-51259 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 51260-51269 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51270-51279 - 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 51280-51289 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 51290-51299 - 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 51300-51309 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 51310-51319 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 51320-51329 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51330-51339 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 12, // 51340-51349 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51350-51359 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 51360-51369 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51370-51379 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 51380-51389 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 51390-51399 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 51400-51409 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 51410-51419 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 51420-51429 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 51430-51439 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 51440-51449 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51450-51459 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51460-51469 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 51470-51479 - 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 51480-51489 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51490-51499 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 51500-51509 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 51510-51519 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 51520-51529 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 51530-51539 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51540-51549 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51550-51559 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 51560-51569 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 51570-51579 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51580-51589 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 51590-51599 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 51600-51609 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 51610-51619 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51620-51629 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 51630-51639 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 51640-51649 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 51650-51659 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51660-51669 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 51670-51679 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 51680-51689 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 51690-51699 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51700-51709 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 51710-51719 - 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 51720-51729 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 51730-51739 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 51740-51749 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 51750-51759 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 51760-51769 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 51770-51779 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 51780-51789 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 51790-51799 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 51800-51809 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 51810-51819 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 51820-51829 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 51830-51839 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51840-51849 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 51850-51859 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 51860-51869 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 51870-51879 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 51880-51889 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 51890-51899 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 51900-51909 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 51910-51919 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 51920-51929 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51930-51939 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 51940-51949 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 51950-51959 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51960-51969 - 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 51970-51979 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 51980-51989 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 51990-51999 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 52000-52009 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52010-52019 - 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 52020-52029 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 52030-52039 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52040-52049 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 52050-52059 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 52060-52069 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52070-52079 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 52080-52089 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 52090-52099 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 52100-52109 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52110-52119 - 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 52120-52129 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 52130-52139 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 52140-52149 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 52150-52159 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 52160-52169 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 52170-52179 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 52180-52189 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52190-52199 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 52200-52209 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 52210-52219 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 52220-52229 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 52230-52239 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 52240-52249 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 52250-52259 - 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 52260-52269 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 52270-52279 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 52280-52289 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52290-52299 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 52300-52309 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 52310-52319 - 1, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 52320-52329 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 52330-52339 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 52340-52349 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52350-52359 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 52360-52369 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 52370-52379 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 52380-52389 - 1, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 52390-52399 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 52400-52409 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 52410-52419 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 52420-52429 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 52430-52439 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 52440-52449 - 3, 2, 1, 4, 3, 2, 1, 32, 31, 30, // 52450-52459 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 52460-52469 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 52470-52479 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 52480-52489 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52490-52499 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52500-52509 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 52510-52519 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 52520-52529 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52530-52539 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 52540-52549 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 52550-52559 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 52560-52569 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 52570-52579 - 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 52580-52589 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 52590-52599 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 52600-52609 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 52610-52619 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 52620-52629 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 28, // 52630-52639 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 52640-52649 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 52650-52659 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 52660-52669 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 52670-52679 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52680-52689 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 52690-52699 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 52700-52709 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52710-52719 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 52720-52729 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 52730-52739 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 52740-52749 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 52750-52759 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 52760-52769 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 52770-52779 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 52780-52789 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 52790-52799 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 52800-52809 - 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 52810-52819 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 52820-52829 - 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 52830-52839 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 52840-52849 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 52850-52859 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 52860-52869 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 52870-52879 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 52880-52889 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52890-52899 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 52900-52909 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 52910-52919 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 52920-52929 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 52930-52939 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 52940-52949 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 52950-52959 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 52960-52969 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 52970-52979 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 52980-52989 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 52990-52999 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 53000-53009 - 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 53010-53019 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 53020-53029 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53030-53039 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 53040-53049 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 53050-53059 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 53060-53069 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 53070-53079 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 53080-53089 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 53090-53099 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53100-53109 - 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 53110-53119 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 53120-53129 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53130-53139 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 53140-53149 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53150-53159 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53160-53169 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 53170-53179 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 53180-53189 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 53190-53199 - 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 53200-53209 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 53210-53219 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53220-53229 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 28, // 53230-53239 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 53240-53249 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53250-53259 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 53260-53269 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 53270-53279 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 53280-53289 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 53290-53299 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 53300-53309 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53310-53319 - 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 53320-53329 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 53330-53339 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53340-53349 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 53350-53359 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53360-53369 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 53370-53379 - 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 53380-53389 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53390-53399 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 53400-53409 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 53410-53419 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53420-53429 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 53430-53439 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53440-53449 - 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 53450-53459 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 53460-53469 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 53470-53479 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 53480-53489 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53490-53499 - 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 53500-53509 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53510-53519 - 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 53520-53529 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 53530-53539 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 53540-53549 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 53550-53559 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 53560-53569 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 53570-53579 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53580-53589 - 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 53590-53599 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 53600-53609 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 53610-53619 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 53620-53629 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 53630-53639 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53640-53649 - 3, 2, 1, 4, 3, 2, 1, 24, 23, 22, // 53650-53659 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 53660-53669 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53670-53679 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53680-53689 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 53690-53699 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53700-53709 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 53710-53719 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53720-53729 - 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 53730-53739 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 53740-53749 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 53750-53759 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53760-53769 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 53770-53779 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 53780-53789 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 53790-53799 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 53800-53809 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 53810-53819 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53820-53829 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 53830-53839 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 53840-53849 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 53850-53859 - 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 53860-53869 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53870-53879 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 53880-53889 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 53890-53899 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53900-53909 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 53910-53919 - 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 53920-53929 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 53930-53939 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 53940-53949 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 28, // 53950-53959 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 53960-53969 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 53970-53979 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 53980-53989 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 53990-53999 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54000-54009 - 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 54010-54019 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54020-54029 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 54030-54039 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 54040-54049 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 54050-54059 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 54060-54069 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 54070-54079 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 54080-54089 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54090-54099 - 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 54100-54109 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54110-54119 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 54120-54129 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 54130-54139 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54140-54149 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 54150-54159 - 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 54160-54169 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54170-54179 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 54180-54189 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 54190-54199 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54200-54209 - 7, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 54210-54219 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 54220-54229 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 54230-54239 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54240-54249 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 54250-54259 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 54260-54269 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 54270-54279 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 54280-54289 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 54290-54299 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54300-54309 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 54310-54319 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 54320-54329 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54330-54339 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 54340-54349 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54350-54359 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 54360-54369 - 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 54370-54379 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 54380-54389 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54390-54399 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 54400-54409 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 54410-54419 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54420-54429 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 54430-54439 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 20, // 54440-54449 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 54450-54459 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 54460-54469 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 54470-54479 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 54480-54489 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 54490-54499 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 54500-54509 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 54510-54519 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 54520-54529 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 54530-54539 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 54540-54549 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 54550-54559 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 54560-54569 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 54570-54579 - 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 54580-54589 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54590-54599 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54600-54609 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 54610-54619 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 54620-54629 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54630-54639 - 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 54640-54649 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54650-54659 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 54660-54669 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 30, // 54670-54679 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 54680-54689 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 54690-54699 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 54700-54709 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 54710-54719 - 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 54720-54729 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 54730-54739 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54740-54749 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54750-54759 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 54760-54769 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 54770-54779 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 54780-54789 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 54790-54799 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 54800-54809 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 54810-54819 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 54820-54829 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 54830-54839 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54840-54849 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 54850-54859 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 54860-54869 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 54870-54879 - 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 54880-54889 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 54890-54899 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 54900-54909 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 54910-54919 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 54920-54929 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54930-54939 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 54940-54949 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 54950-54959 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 54960-54969 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 54970-54979 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 54980-54989 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 54990-54999 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 55000-55009 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55010-55019 - 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 55020-55029 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 55030-55039 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 55040-55049 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 55050-55059 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55060-55069 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 24, // 55070-55079 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 55080-55089 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55090-55099 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 55100-55109 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 55110-55119 - 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 55120-55129 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 55130-55139 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 55140-55149 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55150-55159 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 55160-55169 - 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 55170-55179 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 55180-55189 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55190-55199 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 55200-55209 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 55210-55219 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 55220-55229 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55230-55239 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 55240-55249 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 32, // 55250-55259 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 55260-55269 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 55270-55279 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55280-55289 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 55290-55299 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55300-55309 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 55310-55319 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55320-55329 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 55330-55339 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 55340-55349 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 55350-55359 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55360-55369 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 55370-55379 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 55380-55389 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 55390-55399 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55400-55409 - 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 55410-55419 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 55420-55429 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 55430-55439 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 55440-55449 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 55450-55459 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 55460-55469 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 55470-55479 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 55480-55489 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55490-55499 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55500-55509 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 55510-55519 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 55520-55529 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55530-55539 - 1, 6, 5, 4, 3, 2, 1, 32, 31, 30, // 55540-55549 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 55550-55559 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 55560-55569 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 55570-55579 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 55580-55589 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55590-55599 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 55600-55609 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 55610-55619 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55620-55629 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 55630-55639 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 55640-55649 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55650-55659 - 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 55660-55669 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 55670-55679 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55680-55689 - 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 55690-55699 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55700-55709 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 55710-55719 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55720-55729 - 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 55730-55739 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 55740-55749 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 55750-55759 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 55760-55769 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 55770-55779 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 55780-55789 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 55790-55799 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 55800-55809 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 55810-55819 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 55820-55829 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 55830-55839 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 55840-55849 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 55850-55859 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55860-55869 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 55870-55879 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 55880-55889 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 55890-55899 - 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 55900-55909 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 55910-55919 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 55920-55929 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 55930-55939 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 55940-55949 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 55950-55959 - 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 55960-55969 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 55970-55979 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 55980-55989 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 55990-55999 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 30, // 56000-56009 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 56010-56019 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 56020-56029 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 56030-56039 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 56040-56049 - 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 56050-56059 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 56060-56069 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56070-56079 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 56080-56089 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 56090-56099 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 56100-56109 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 56110-56119 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 56120-56129 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 56130-56139 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 56140-56149 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 56150-56159 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 56160-56169 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 56170-56179 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 56180-56189 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 56190-56199 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 28, // 56200-56209 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 56210-56219 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 56220-56229 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 56230-56239 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 56240-56249 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 56250-56259 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 30, // 56260-56269 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 56270-56279 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 56280-56289 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 56290-56299 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56300-56309 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 56310-56319 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 56320-56329 - 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 56330-56339 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 56340-56349 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 56350-56359 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 56360-56369 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 56370-56379 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 56380-56389 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 56390-56399 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 56400-56409 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 56410-56419 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56420-56429 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 56430-56439 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 56440-56449 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 56450-56459 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 56460-56469 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 56470-56479 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 56480-56489 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56490-56499 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 56500-56509 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 56510-56519 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 56520-56529 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 56530-56539 - 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 56540-56549 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 56550-56559 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 56560-56569 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 56570-56579 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56580-56589 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 56590-56599 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56600-56609 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 56610-56619 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 56620-56629 - 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 56630-56639 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 56640-56649 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 56650-56659 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 56660-56669 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56670-56679 - 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 56680-56689 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56690-56699 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56700-56709 - 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 56710-56719 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56720-56729 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 56730-56739 - 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 56740-56749 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 56750-56759 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 56760-56769 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 56770-56779 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 56780-56789 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 56790-56799 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 56800-56809 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 56810-56819 - 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 56820-56829 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 56830-56839 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 56840-56849 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 56850-56859 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 56860-56869 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 56870-56879 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56880-56889 - 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 56890-56899 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 56900-56909 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56910-56919 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 56920-56929 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56930-56939 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 56940-56949 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 56950-56959 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 56960-56969 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 56970-56979 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 56980-56989 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 38, // 56990-56999 - 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 57000-57009 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 57010-57019 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57020-57029 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 57030-57039 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 57040-57049 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 57050-57059 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 57060-57069 - 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 57070-57079 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 57080-57089 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 57090-57099 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 57100-57109 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 57110-57119 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57120-57129 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 57130-57139 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 57140-57149 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 57150-57159 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 57160-57169 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 57170-57179 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57180-57189 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 57190-57199 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 57200-57209 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57210-57219 - 1, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 57220-57229 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57230-57239 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57240-57249 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 57250-57259 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 57260-57269 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 57270-57279 - 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 57280-57289 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57290-57299 - 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 57300-57309 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 57310-57319 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 57320-57329 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57330-57339 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 57340-57349 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57350-57359 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 57360-57369 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 57370-57379 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 57380-57389 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 57390-57399 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 57400-57409 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 57410-57419 - 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 57420-57429 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 57430-57439 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57440-57449 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 57450-57459 - 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 57460-57469 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57470-57479 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 57480-57489 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 57490-57499 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 57500-57509 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57510-57519 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 28, // 57520-57529 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 57530-57539 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57540-57549 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 57550-57559 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57560-57569 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57570-57579 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 57580-57589 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 57590-57599 - 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 57600-57609 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 57610-57619 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57620-57629 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 57630-57639 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 57640-57649 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 57650-57659 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 57660-57669 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 57670-57679 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 57680-57689 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 57690-57699 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 57700-57709 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 57710-57719 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 57720-57729 - 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 57730-57739 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57740-57749 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 57750-57759 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 57760-57769 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 57770-57779 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 57780-57789 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 57790-57799 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 20, // 57800-57809 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 57810-57819 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 57820-57829 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 57830-57839 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 57840-57849 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 57850-57859 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 57860-57869 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57870-57879 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 57880-57889 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 57890-57899 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 57900-57909 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 57910-57919 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 57920-57929 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 57930-57939 - 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 57940-57949 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 57950-57959 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 57960-57969 - 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 57970-57979 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 57980-57989 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 57990-57999 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 58000-58009 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 58010-58019 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 58020-58029 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 58030-58039 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 58040-58049 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 58050-58059 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 58060-58069 - 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 58070-58079 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 58080-58089 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 58090-58099 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 58100-58109 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 58110-58119 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 58120-58129 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58130-58139 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 58140-58149 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 58150-58159 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 58160-58169 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 58170-58179 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 58180-58189 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 58190-58199 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 58200-58209 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 58210-58219 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 58220-58229 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 58230-58239 - 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 58240-58249 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 58250-58259 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58260-58269 - 1, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 58270-58279 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 58280-58289 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 58290-58299 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 58300-58309 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 58310-58319 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58320-58329 - 7, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 58330-58339 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 58340-58349 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 58350-58359 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 10, // 58360-58369 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 58370-58379 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58380-58389 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 58390-58399 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 58400-58409 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 58410-58419 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 58420-58429 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 58430-58439 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58440-58449 - 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 58450-58459 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58460-58469 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 58470-58479 - 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 58480-58489 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 58490-58499 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58500-58509 - 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 58510-58519 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58520-58529 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 58530-58539 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 58540-58549 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58550-58559 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 58560-58569 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 58570-58579 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 58580-58589 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58590-58599 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 58600-58609 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 58610-58619 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58620-58629 - 1, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 58630-58639 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58640-58649 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 58650-58659 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 58660-58669 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 58670-58679 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 58680-58689 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 58690-58699 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58700-58709 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58710-58719 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 58720-58729 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 58730-58739 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58740-58749 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 58750-58759 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 58760-58769 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58770-58779 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 42, // 58780-58789 - 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 58790-58799 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 58800-58809 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 58810-58819 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58820-58829 - 1, 58, 57, 56, 55, 54, 53, 52, 51, 50, // 58830-58839 - 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, // 58840-58849 - 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 58850-58859 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 58860-58869 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 58870-58879 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 58880-58889 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 58890-58899 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 58900-58909 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 58910-58919 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 58920-58929 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 58930-58939 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 58940-58949 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 58950-58959 - 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 58960-58969 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 58970-58979 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 58980-58989 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 58990-58999 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 59000-59009 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59010-59019 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 59020-59029 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 59030-59039 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59040-59049 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 59050-59059 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 59060-59069 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 59070-59079 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 59080-59089 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 59090-59099 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 59100-59109 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 59110-59119 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 59120-59129 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59130-59139 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 59140-59149 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 59150-59159 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 59160-59169 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59170-59179 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 59180-59189 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 59190-59199 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 59200-59209 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 59210-59219 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59220-59229 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 59230-59239 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 59240-59249 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59250-59259 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 59260-59269 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 59270-59279 - 1, 52, 51, 50, 49, 48, 47, 46, 45, 44, // 59280-59289 - 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, // 59290-59299 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 59300-59309 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 59310-59319 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59320-59329 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 59330-59339 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59340-59349 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 59350-59359 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 59360-59369 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 59370-59379 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 59380-59389 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 59390-59399 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 59400-59409 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 59410-59419 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 59420-59429 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59430-59439 - 1, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 59440-59449 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 59450-59459 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 59460-59469 - 1, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 59470-59479 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 59480-59489 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 59490-59499 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 59500-59509 - 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 59510-59519 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 59520-59529 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 59530-59539 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 59540-59549 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 59550-59559 - 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 59560-59569 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59570-59579 - 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 59580-59589 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 59590-59599 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59600-59609 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 59610-59619 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 22, // 59620-59629 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 59630-59639 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59640-59649 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 59650-59659 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 59660-59669 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 59670-59679 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59680-59689 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 59690-59699 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 59700-59709 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59710-59719 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 59720-59729 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59730-59739 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 59740-59749 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 59750-59759 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59760-59769 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 59770-59779 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59780-59789 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 59790-59799 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 59800-59809 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 59810-59819 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59820-59829 - 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 59830-59839 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 59840-59849 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 59850-59859 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 59860-59869 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 59870-59879 - 7, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 59880-59889 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 59890-59899 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 59900-59909 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59910-59919 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 59920-59929 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 59930-59939 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59940-59949 - 1, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 59950-59959 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59960-59969 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 59970-59979 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 59980-59989 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 59990-59999 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 60000-60009 - 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 60010-60019 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 60020-60029 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 60030-60039 - 1, 36, 35, 34, 33, 32, 31, 30, 29, 28, // 60040-60049 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 60050-60059 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 60060-60069 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 60070-60079 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 60080-60089 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60090-60099 - 1, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 60100-60109 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 60110-60119 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 60120-60129 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 60130-60139 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 60140-60149 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60150-60159 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 40, // 60160-60169 - 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 60170-60179 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 60180-60189 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 60190-60199 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 60200-60209 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 60210-60219 - 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 60220-60229 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 60230-60239 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60240-60249 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 60250-60259 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60260-60269 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 60270-60279 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 60280-60289 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 60290-60299 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 60300-60309 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 60310-60319 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60320-60329 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 60330-60339 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 60340-60349 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 60350-60359 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 60360-60369 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 60370-60379 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 60380-60389 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 60390-60399 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 60400-60409 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 60410-60419 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 60420-60429 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 60430-60439 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 60440-60449 - 7, 6, 5, 4, 3, 2, 1, 36, 35, 34, // 60450-60459 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 60460-60469 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 60470-60479 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 60480-60489 - 3, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 60490-60499 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 60500-60509 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60510-60519 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 60520-60529 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 50, // 60530-60539 - 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, // 60540-60549 - 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 60550-60559 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 60560-60569 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 60570-60579 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 60580-60589 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60590-60599 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 60600-60609 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 60610-60619 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 60620-60629 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 60630-60639 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 60640-60649 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 60650-60659 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 60660-60669 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 60670-60679 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 60680-60689 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 60690-60699 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 60700-60709 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 60710-60719 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 60720-60729 - 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 60730-60739 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 60740-60749 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 60750-60759 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 60760-60769 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 60770-60779 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 60780-60789 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 60790-60799 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60800-60809 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60810-60819 - 1, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 60820-60829 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 60830-60839 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 60840-60849 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 60850-60859 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 60860-60869 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 60870-60879 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 60880-60889 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 60890-60899 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 60900-60909 - 3, 2, 1, 4, 3, 2, 1, 2, 1, 4, // 60910-60919 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 60920-60929 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 60930-60939 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 60940-60949 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 60950-60959 - 1, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 60960-60969 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 60970-60979 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 60980-60989 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 60990-60999 - 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 61000-61009 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 61010-61019 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 61020-61029 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61030-61039 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 61040-61049 - 1, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 61050-61059 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 61060-61069 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 61070-61079 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61080-61089 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 22, // 61090-61099 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 61100-61109 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61110-61119 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 61120-61129 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61130-61139 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61140-61149 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 61150-61159 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 42, // 61160-61169 - 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, // 61170-61179 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 61180-61189 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 61190-61199 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61200-61209 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61210-61219 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 61220-61229 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 61230-61239 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61240-61249 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 61250-61259 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 61260-61269 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61270-61279 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 61280-61289 - 1, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 61290-61299 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 61300-61309 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 61310-61319 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61320-61329 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 61330-61339 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 61340-61349 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 61350-61359 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 61360-61369 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 61370-61379 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 61380-61389 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61390-61399 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 8, // 61400-61409 - 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 61410-61419 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 61420-61429 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61430-61439 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 61440-61449 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61450-61459 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 61460-61469 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61470-61479 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 61480-61489 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 61490-61499 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 61500-61509 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 24, // 61510-61519 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 61520-61529 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61530-61539 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 61540-61549 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 2, // 61550-61559 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 61560-61569 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61570-61579 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 61580-61589 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61590-61599 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 61600-61609 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 61610-61619 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 61620-61629 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 61630-61639 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 61640-61649 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 61650-61659 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 61660-61669 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 61670-61679 - 1, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 61680-61689 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61690-61699 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 61700-61709 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 61710-61719 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 61720-61729 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 61730-61739 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61740-61749 - 1, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 61750-61759 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 61760-61769 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61770-61779 - 1, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 61780-61789 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 61790-61799 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61800-61809 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 61810-61819 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 61820-61829 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 61830-61839 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 61840-61849 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61850-61859 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61860-61869 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 61870-61879 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 61880-61889 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 61890-61899 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 61900-61909 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 61910-61919 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 61920-61929 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 61930-61939 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 61940-61949 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 61950-61959 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 61960-61969 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 61970-61979 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 61980-61989 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 61990-61999 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 62000-62009 - 1, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 62010-62019 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 62020-62029 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 62030-62039 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 62040-62049 - 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 62050-62059 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62060-62069 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62070-62079 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 62080-62089 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 62090-62099 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 62100-62109 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 62110-62119 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 62120-62129 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 62130-62139 - 1, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 62140-62149 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 62150-62159 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62160-62169 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 62170-62179 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 62180-62189 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62190-62199 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 62200-62209 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 62210-62219 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62220-62229 - 3, 2, 1, 40, 39, 38, 37, 36, 35, 34, // 62230-62239 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 62240-62249 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 62250-62259 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62260-62269 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 62270-62279 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 62280-62289 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 62290-62299 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 62300-62309 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62310-62319 - 3, 2, 1, 4, 3, 2, 1, 20, 19, 18, // 62320-62329 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 62330-62339 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 62340-62349 - 1, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 62350-62359 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 62360-62369 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62370-62379 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 62380-62389 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62390-62399 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 62400-62409 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 62410-62419 - 3, 2, 1, 36, 35, 34, 33, 32, 31, 30, // 62420-62429 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 62430-62439 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 62440-62449 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 62450-62459 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 62460-62469 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 62470-62479 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 62480-62489 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 62490-62499 - 1, 6, 5, 4, 3, 2, 1, 26, 25, 24, // 62500-62509 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 62510-62519 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62520-62529 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 62530-62539 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 62540-62549 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62550-62559 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 62560-62569 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62570-62579 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62580-62589 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 62590-62599 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 62600-62609 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 62610-62619 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 62620-62629 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 62630-62639 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62640-62649 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 24, // 62650-62659 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 62660-62669 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62670-62679 - 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 62680-62689 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62690-62699 - 1, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 62700-62709 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62710-62719 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 62720-62729 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62730-62739 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 62740-62749 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 62750-62759 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 62760-62769 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 62770-62779 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62780-62789 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62790-62799 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 62800-62809 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 62810-62819 - 7, 6, 5, 4, 3, 2, 1, 24, 23, 22, // 62820-62829 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 62830-62839 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62840-62849 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62850-62859 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 62860-62869 - 3, 2, 1, 24, 23, 22, 21, 20, 19, 18, // 62870-62879 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 62880-62889 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 62890-62899 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 62900-62909 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62910-62919 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 62920-62929 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 62930-62939 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 62940-62949 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 62950-62959 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 62960-62969 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 62970-62979 - 1, 2, 1, 4, 3, 2, 1, 2, 1, 40, // 62980-62989 - 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, // 62990-62999 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 63000-63009 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63010-63019 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 63020-63029 - 1, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 63030-63039 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63040-63049 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 63050-63059 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 63060-63069 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 18, // 63070-63079 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 63080-63089 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 63090-63099 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 63100-63109 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 63110-63119 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 63120-63129 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63130-63139 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, // 63140-63149 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 63150-63159 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63160-63169 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 63170-63179 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 63180-63189 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 63190-63199 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 63200-63209 - 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 63210-63219 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 63220-63229 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 63230-63239 - 1, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 63240-63249 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 63250-63259 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 63260-63269 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 63270-63279 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63280-63289 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, // 63290-63299 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 63300-63309 - 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 63310-63319 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 63320-63329 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 63330-63339 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 63340-63349 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 63350-63359 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 63360-63369 - 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 63370-63379 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 63380-63389 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 63390-63399 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 63400-63409 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 63410-63419 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63420-63429 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 63430-63439 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 63440-63449 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 63450-63459 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 63460-63469 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 63470-63479 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 63480-63489 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 22, // 63490-63499 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 63500-63509 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 63510-63519 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 63520-63529 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 63530-63539 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63540-63549 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 63550-63559 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 63560-63569 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 63570-63579 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 63580-63589 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 63590-63599 - 1, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 63600-63609 - 1, 6, 5, 4, 3, 2, 1, 12, 11, 10, // 63610-63619 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 63620-63629 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 63630-63639 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 10, // 63640-63649 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 63650-63659 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 63660-63669 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63670-63679 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 63680-63689 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 63690-63699 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 63700-63709 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 63710-63719 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 63720-63729 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 63730-63739 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 63740-63749 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 63750-63759 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 63760-63769 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 63770-63779 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 63780-63789 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 63790-63799 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 63800-63809 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 63810-63819 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 63820-63829 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 63830-63839 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 63840-63849 - 3, 2, 1, 4, 3, 2, 1, 6, 5, 4, // 63850-63859 - 3, 2, 1, 38, 37, 36, 35, 34, 33, 32, // 63860-63869 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 63870-63879 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 63880-63889 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 63890-63899 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 63900-63909 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 63910-63919 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, // 63920-63929 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 63930-63939 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 28, // 63940-63949 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 63950-63959 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 63960-63969 - 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 63970-63979 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 63980-63989 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 63990-63999 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 64000-64009 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 14, // 64010-64019 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64020-64029 - 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 64030-64039 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 64040-64049 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64050-64059 - 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 64060-64069 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64070-64079 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64080-64089 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 64090-64099 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 64100-64109 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64110-64119 - 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 64120-64129 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 64130-64139 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64140-64149 - 1, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 64150-64159 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64160-64169 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 64170-64179 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 28, // 64180-64189 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 64190-64199 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 64200-64209 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 64210-64219 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 64220-64229 - 1, 6, 5, 4, 3, 2, 1, 34, 33, 32, // 64230-64239 - 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, // 64240-64249 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 64250-64259 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64260-64269 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 64270-64279 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 64280-64289 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64290-64299 - 1, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 64300-64309 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 64310-64319 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 64320-64329 - 3, 2, 1, 40, 39, 38, 37, 36, 35, 34, // 64330-64339 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 64340-64349 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 64350-64359 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64360-64369 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 64370-64379 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 64380-64389 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 64390-64399 - 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 64400-64409 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 64410-64419 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64420-64429 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 64430-64439 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64440-64449 - 1, 2, 1, 30, 29, 28, 27, 26, 25, 24, // 64450-64459 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 64460-64469 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64470-64479 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 10, // 64480-64489 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 64490-64499 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64500-64509 - 3, 2, 1, 40, 39, 38, 37, 36, 35, 34, // 64510-64519 - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, // 64520-64529 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 64530-64539 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64540-64549 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 64550-64559 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 64560-64569 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 64570-64579 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64580-64589 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64590-64599 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 64600-64609 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 64610-64619 - 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 64620-64629 - 3, 2, 1, 28, 27, 26, 25, 24, 23, 22, // 64630-64639 - 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, // 64640-64649 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64650-64659 - 1, 2, 1, 4, 3, 2, 1, 12, 11, 10, // 64660-64669 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 64670-64679 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64680-64689 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 64690-64699 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 8, // 64700-64709 - 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, // 64710-64719 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 64720-64729 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 64730-64739 - 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, // 64740-64749 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 64750-64759 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 64760-64769 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64770-64779 - 1, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 64780-64789 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 64790-64799 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64800-64809 - 1, 6, 5, 4, 3, 2, 1, 32, 31, 30, // 64810-64819 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 64820-64829 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 64830-64839 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 64840-64849 - 3, 2, 1, 18, 17, 16, 15, 14, 13, 12, // 64850-64859 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64860-64869 - 1, 6, 5, 4, 3, 2, 1, 2, 1, 12, // 64870-64879 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64880-64889 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64890-64899 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 64900-64909 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 64910-64919 - 1, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 64920-64929 - 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, // 64930-64939 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 64940-64949 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 64950-64959 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 28, // 64960-64969 - 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, // 64970-64979 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 64980-64989 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 64990-64999 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 65000-65009 - 1, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 65010-65019 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 4, // 65020-65029 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 65030-65039 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 65040-65049 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 65050-65059 - 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, // 65060-65069 - 1, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 65070-65079 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, // 65080-65089 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 65090-65099 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 65100-65109 - 1, 8, 7, 6, 5, 4, 3, 2, 1, 4, // 65110-65119 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 12, // 65120-65129 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 65130-65139 - 1, 6, 5, 4, 3, 2, 1, 20, 19, 18, // 65140-65149 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 65150-65159 - 7, 6, 5, 4, 3, 2, 1, 4, 3, 2, // 65160-65169 - 1, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 65170-65179 - 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, // 65180-65189 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 65190-65199 - 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, // 65200-65209 - 3, 2, 1, 26, 25, 24, 23, 22, 21, 20, // 65210-65219 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 65220-65229 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 65230-65239 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 65240-65249 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 65250-65259 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 18, // 65260-65269 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 65270-65279 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 65280-65289 - 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, // 65290-65299 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, // 65300-65309 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 65310-65319 - 3, 2, 1, 4, 3, 2, 1, 26, 25, 24, // 65320-65329 - 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, // 65330-65339 - 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 65340-65349 - 3, 2, 1, 4, 3, 2, 1, 14, 13, 12, // 65350-65359 - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 65360-65369 - 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, // 65370-65379 - 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, // 65380-65389 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 65390-65399 - 7, 6, 5, 4, 3, 2, 1, 6, 5, 4, // 65400-65409 - 3, 2, 1, 6, 5, 4, 3, 2, 1, 4, // 65410-65419 - 3, 2, 1, 14, 13, 12, 11, 10, 9, 8, // 65420-65429 - 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, // 65430-65439 - 7, 6, 5, 4, 3, 2, 1, 2, 1, 30, // 65440-65449 - 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, // 65450-65459 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 65460-65469 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 18, // 65470-65479 - 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, // 65480-65489 - 7, 6, 5, 4, 3, 2, 1, 22, 21, 20, // 65490-65499 - 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, // 65500-65509 - 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, // 65510-65519 - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 65520-65529 - 0, 0, 0, 0, 0, 0, - } - - lohi [256]struct{ lo, hi int } -) - -func init() { - for i, v := range liars { - blk := v >> 24 - x := &lohi[blk] - if x.lo == 0 || i < x.lo { - x.lo = i - } - if i > x.hi { - x.hi = i - } - } -} diff --git a/Godeps/_workspace/src/github.com/cznic/mathutil/test_deps.go b/Godeps/_workspace/src/github.com/cznic/mathutil/test_deps.go deleted file mode 100644 index 40054dcad2..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/mathutil/test_deps.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) 2014 The mathutil 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 mathutil - -// Pull test dependencies too. -// Enables easy 'go test X' after 'go get X' -import ( -// nothing yet -) diff --git a/Godeps/_workspace/src/github.com/cznic/ql/AUTHORS b/Godeps/_workspace/src/github.com/cznic/ql/AUTHORS deleted file mode 100644 index 0078f5f5b6..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/AUTHORS +++ /dev/null @@ -1,11 +0,0 @@ -# This file lists authors for copyright purposes. This file is distinct from -# the CONTRIBUTORS files. See the latter for an explanation. -# -# Names should be added to this file as: -# Name or Organization -# -# The email address is not required for organizations. -# -# Please keep the list sorted. - -Jan Mercl <0xjnml@gmail.com> diff --git a/Godeps/_workspace/src/github.com/cznic/ql/CONTRIBUTORS b/Godeps/_workspace/src/github.com/cznic/ql/CONTRIBUTORS deleted file mode 100644 index 6b6aed2dd8..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/CONTRIBUTORS +++ /dev/null @@ -1,12 +0,0 @@ -# This file lists people who contributed code to this repository. The AUTHORS -# file lists the copyright holders; this file lists people. -# -# Names should be added to this file like so: -# Name -# -# Please keep the list sorted. - -Dan Kortschak -Jan Mercl <0xjnml@gmail.com> -OpenNota -Viktor Kojouharov diff --git a/Godeps/_workspace/src/github.com/cznic/ql/LICENSE b/Godeps/_workspace/src/github.com/cznic/ql/LICENSE deleted file mode 100644 index 0d10c02b92..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2014 The ql 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 names of the authors nor the names of the -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. diff --git a/Godeps/_workspace/src/github.com/cznic/ql/Makefile b/Godeps/_workspace/src/github.com/cznic/ql/Makefile deleted file mode 100644 index 5fb8c0841f..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/Makefile +++ /dev/null @@ -1,74 +0,0 @@ -# Copyright (c) 2014 The ql Authors. All rights reserved. -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file. - -.PHONY: all clean nuke - -all: editor scanner.go parser.go - go build - go vet || true - golint - make todo - go install ./... - -bench: all - go test -run NONE -bench . - -clean: - go clean - rm -f *~ y.go y.tab.c *.out ql.test - -coerce.go: helper/helper.go - if [ -f coerce.go ] ; then rm coerce.go ; fi - go run helper/helper.go | gofmt > $@ - -cover: - t=$(shell tempfile) ; go test -coverprofile $$t && go tool cover -html $$t && unlink $$t - -cpu: ql.test - go test -c - ./$< -test.bench . -test.cpuprofile cpu.out - go tool pprof --lines $< cpu.out - -editor: ql.y scanner.go parser.go coerce.go - gofmt -s -l -w *.go - go test -i - go test - -internalError: - egrep -ho '"internal error.*"' *.go | sort | cat -n - -mem: ql.test - go test -c - ./$< -test.bench . -test.memprofile mem.out - go tool pprof --lines --web --alloc_space $< mem.out - -nuke: - go clean -i - -parser.go: parser.y - a=$(shell tempfile) ; \ - goyacc -o /dev/null -xegen $$a $< ; \ - goyacc -cr -o $@ -xe $$a $< ; \ - rm -f $$a - sed -i -e 's|//line.*||' -e 's/yyEofCode/yyEOFCode/' $@ - -ql.test: all - -ql.y: doc.go - sed -n '1,/^package/ s/^\/\/ //p' < $< \ - | ebnf2y -o $@ -oe $*.ebnf -start StatementList -pkg $* -p _ - goyacc -cr -o /dev/null $@ - -scanner.go: scanner.l parser.go - golex -o $@ $< - -todo: - @grep -n ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* *.go *.l parser.y || true - @grep -n TODO *.go *.l parser.y testdata.ql || true - @grep -n BUG *.go *.l parser.y || true - @grep -n println *.go *.l parser.y || true - -later: - @grep -n LATER *.go *.l parser.y || true - @grep -n MAYBE *.go *.l parser.y || true diff --git a/Godeps/_workspace/src/github.com/cznic/ql/README.md b/Godeps/_workspace/src/github.com/cznic/ql/README.md deleted file mode 100644 index c7a453a32b..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/README.md +++ /dev/null @@ -1,21 +0,0 @@ -ql -== - -Package ql is a pure Go embedded (S)QL database. - -Installation - - $ go get github.com/cznic/ql - -Documentation: [godoc.org/github.com/cznic/ql](http://godoc.org/github.com/cznic/ql) - ----- - -Accompanying tool to play with a DB - -Installation - - $ go get github.com/cznic/ql/ql - -Documentation: [godoc.org/github.com/cznic/ql/ql](http://godoc.org/github.com/cznic/ql/ql) - diff --git a/Godeps/_workspace/src/github.com/cznic/ql/benchcmp b/Godeps/_workspace/src/github.com/cznic/ql/benchcmp deleted file mode 100644 index a0f7a50c08..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/benchcmp +++ /dev/null @@ -1 +0,0 @@ -go test -test.run NONE -test.bench . -test.benchmem -timeout 1h | tee $1 diff --git a/Godeps/_workspace/src/github.com/cznic/ql/blob.go b/Godeps/_workspace/src/github.com/cznic/ql/blob.go deleted file mode 100644 index 2005b52c7e..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/blob.go +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright 2014 The ql 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 ql - -import ( - "bytes" - "encoding/gob" - "math/big" - "sync" - "time" -) - -const shortBlob = 256 // bytes - -var ( - gobInitDuration = time.Duration(278) - gobInitInt = big.NewInt(42) - gobInitRat = big.NewRat(355, 113) - gobInitTime time.Time -) - -func init() { - var err error - if gobInitTime, err = time.ParseInLocation( - "Jan 2, 2006 at 3:04pm (MST)", - "Jul 9, 2012 at 5:02am (CEST)", - time.FixedZone("XYZ", 1234), - ); err != nil { - panic(err) - } - newGobCoder() -} - -type gobCoder struct { - buf bytes.Buffer - dec *gob.Decoder - enc *gob.Encoder - mu sync.Mutex -} - -func newGobCoder() (g *gobCoder) { - g = &gobCoder{} - g.enc = gob.NewEncoder(&g.buf) - if err := g.enc.Encode(gobInitInt); err != nil { - panic(err) - } - - if err := g.enc.Encode(gobInitRat); err != nil { - panic(err) - } - - if err := g.enc.Encode(gobInitTime); err != nil { - panic(err) - } - - if err := g.enc.Encode(gobInitDuration); err != nil { - panic(err) - } - - g.dec = gob.NewDecoder(&g.buf) - i := big.NewInt(0) - if err := g.dec.Decode(i); err != nil { - panic(err) - } - - r := big.NewRat(3, 5) - if err := g.dec.Decode(r); err != nil { - panic(err) - } - - t := time.Now() - if err := g.dec.Decode(&t); err != nil { - panic(err) - } - - var d time.Duration - if err := g.dec.Decode(&d); err != nil { - panic(err) - } - - return -} - -func isBlobType(v interface{}) (bool, Type) { - switch v.(type) { - case []byte: - return true, Blob - case *big.Int: - return true, BigInt - case *big.Rat: - return true, BigRat - case time.Time: - return true, Time - case time.Duration: - return true, Duration - default: - return false, -1 - } -} - -func (g *gobCoder) encode(v interface{}) (b []byte, err error) { - g.mu.Lock() - defer g.mu.Unlock() - - g.buf.Reset() - switch x := v.(type) { - case []byte: - return x, nil - case *big.Int: - err = g.enc.Encode(x) - case *big.Rat: - err = g.enc.Encode(x) - case time.Time: - err = g.enc.Encode(x) - case time.Duration: - err = g.enc.Encode(int64(x)) - default: - panic("internal error 002") - } - b = g.buf.Bytes() - return -} - -func (g *gobCoder) decode(b []byte, typ int) (v interface{}, err error) { - g.mu.Lock() - defer g.mu.Unlock() - - g.buf.Reset() - g.buf.Write(b) - switch typ { - case qBlob: - return b, nil - case qBigInt: - x := big.NewInt(0) - err = g.dec.Decode(&x) - v = x - case qBigRat: - x := big.NewRat(1, 1) - err = g.dec.Decode(&x) - v = x - case qTime: - var x time.Time - err = g.dec.Decode(&x) - v = x - case qDuration: - var x int64 - err = g.dec.Decode(&x) - v = time.Duration(x) - default: - panic("internal error 003") - } - return -} diff --git a/Godeps/_workspace/src/github.com/cznic/ql/btree.go b/Godeps/_workspace/src/github.com/cznic/ql/btree.go deleted file mode 100644 index 2b588b70d8..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/btree.go +++ /dev/null @@ -1,725 +0,0 @@ -// Copyright 2014 The ql 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 ql - -import ( - "io" -) - -const ( - kx = 128 //DONE benchmark tune this number if using custom key/value type(s). - kd = 64 //DONE benchmark tune this number if using custom key/value type(s). -) - -type ( - // cmp compares a and b. Return value is: - // - // < 0 if a < b - // 0 if a == b - // > 0 if a > b - // - cmp func(a, b []interface{}) int - - d struct { // data page - c int - d [2*kd + 1]de - n *d - p *d - } - - de struct { // d element - k []interface{} - v []interface{} - } - - enumerator struct { - err error - hit bool - i int - k []interface{} - q *d - t *tree - ver int64 - } - - // tree is a B+tree. - tree struct { - c int - cmp cmp - first *d - last *d - r interface{} - ver int64 - } - - xe struct { // x element - ch interface{} - sep *d - } - - x struct { // index page - c int - x [2*kx + 2]xe - } -) - -var ( // R/O zero values - zd d - zde de - zx x - zxe xe -) - -func clr(q interface{}) { - switch z := q.(type) { - case *x: - for i := 0; i <= z.c; i++ { // Ch0 Sep0 ... Chn-1 Sepn-1 Chn - clr(z.x[i].ch) - } - *z = zx // GC - case *d: - *z = zd // GC - } -} - -// -------------------------------------------------------------------------- x - -func newX(ch0 interface{}) *x { - r := &x{} - r.x[0].ch = ch0 - return r -} - -func (q *x) extract(i int) { - q.c-- - if i < q.c { - copy(q.x[i:], q.x[i+1:q.c+1]) - q.x[q.c].ch = q.x[q.c+1].ch - q.x[q.c].sep = nil // GC - q.x[q.c+1] = zxe // GC - } -} - -func (q *x) insert(i int, d *d, ch interface{}) *x { - c := q.c - if i < c { - q.x[c+1].ch = q.x[c].ch - copy(q.x[i+2:], q.x[i+1:c]) - q.x[i+1].sep = q.x[i].sep - } - c++ - q.c = c - q.x[i].sep = d - q.x[i+1].ch = ch - return q -} - -func (q *x) siblings(i int) (l, r *d) { - if i >= 0 { - if i > 0 { - l = q.x[i-1].ch.(*d) - } - if i < q.c { - r = q.x[i+1].ch.(*d) - } - } - return -} - -// -------------------------------------------------------------------------- d - -func (l *d) mvL(r *d, c int) { - copy(l.d[l.c:], r.d[:c]) - copy(r.d[:], r.d[c:r.c]) - l.c += c - r.c -= c -} - -func (l *d) mvR(r *d, c int) { - copy(r.d[c:], r.d[:r.c]) - copy(r.d[:c], l.d[l.c-c:]) - r.c += c - l.c -= c -} - -// ----------------------------------------------------------------------- tree - -// treeNew returns a newly created, empty tree. The compare function is used -// for key collation. -func treeNew(cmp cmp) *tree { - return &tree{cmp: cmp} -} - -// Clear removes all K/V pairs from the tree. -func (t *tree) Clear() { - if t.r == nil { - return - } - - clr(t.r) - t.c, t.first, t.last, t.r = 0, nil, nil, nil - t.ver++ -} - -func (t *tree) cat(p *x, q, r *d, pi int) { - t.ver++ - q.mvL(r, r.c) - if r.n != nil { - r.n.p = q - } else { - t.last = q - } - q.n = r.n - if p.c > 1 { - p.extract(pi) - p.x[pi].ch = q - } else { - t.r = q - } -} - -func (t *tree) catX(p, q, r *x, pi int) { - t.ver++ - q.x[q.c].sep = p.x[pi].sep - copy(q.x[q.c+1:], r.x[:r.c]) - q.c += r.c + 1 - q.x[q.c].ch = r.x[r.c].ch - if p.c > 1 { - p.c-- - pc := p.c - if pi < pc { - p.x[pi].sep = p.x[pi+1].sep - copy(p.x[pi+1:], p.x[pi+2:pc+1]) - p.x[pc].ch = p.x[pc+1].ch - p.x[pc].sep = nil // GC - p.x[pc+1].ch = nil // GC - } - return - } - - t.r = q -} - -//Delete removes the k's KV pair, if it exists, in which case Delete returns -//true. -func (t *tree) Delete(k []interface{}) (ok bool) { - pi := -1 - var p *x - q := t.r - if q == nil { - return - } - - for { - var i int - i, ok = t.find(q, k) - if ok { - switch z := q.(type) { - case *x: - dp := z.x[i].sep - switch { - case dp.c > kd: - t.extract(dp, 0) - default: - if z.c < kx && q != t.r { - t.underflowX(p, &z, pi, &i) - } - pi = i + 1 - p = z - q = z.x[pi].ch - ok = false - continue - } - case *d: - t.extract(z, i) - if z.c >= kd { - return - } - - if q != t.r { - t.underflow(p, z, pi) - } else if t.c == 0 { - t.Clear() - } - } - return - } - - switch z := q.(type) { - case *x: - if z.c < kx && q != t.r { - t.underflowX(p, &z, pi, &i) - } - pi = i - p = z - q = z.x[i].ch - case *d: - return - } - } -} - -func (t *tree) extract(q *d, i int) { // (r []interface{}) { - t.ver++ - //r = q.d[i].v // prepared for Extract - q.c-- - if i < q.c { - copy(q.d[i:], q.d[i+1:q.c+1]) - } - q.d[q.c] = zde // GC - t.c-- - return -} - -func (t *tree) find(q interface{}, k []interface{}) (i int, ok bool) { - var mk []interface{} - l := 0 - switch z := q.(type) { - case *x: - h := z.c - 1 - for l <= h { - m := (l + h) >> 1 - mk = z.x[m].sep.d[0].k - switch cmp := t.cmp(k, mk); { - case cmp > 0: - l = m + 1 - case cmp == 0: - return m, true - default: - h = m - 1 - } - } - case *d: - h := z.c - 1 - for l <= h { - m := (l + h) >> 1 - mk = z.d[m].k - switch cmp := t.cmp(k, mk); { - case cmp > 0: - l = m + 1 - case cmp == 0: - return m, true - default: - h = m - 1 - } - } - } - return l, false -} - -// First returns the first item of the tree in the key collating order, or -// (nil, nil) if the tree is empty. -func (t *tree) First() (k []interface{}, v []interface{}) { - if q := t.first; q != nil { - q := &q.d[0] - k, v = q.k, q.v - } - return -} - -// Get returns the value associated with k and true if it exists. Otherwise Get -// returns (nil, false). -func (t *tree) Get(k []interface{}) (v []interface{}, ok bool) { - q := t.r - if q == nil { - return - } - - for { - var i int - if i, ok = t.find(q, k); ok { - switch z := q.(type) { - case *x: - return z.x[i].sep.d[0].v, true - case *d: - return z.d[i].v, true - } - } - switch z := q.(type) { - case *x: - q = z.x[i].ch - default: - return - } - } -} - -func (t *tree) insert(q *d, i int, k []interface{}, v []interface{}) *d { - t.ver++ - c := q.c - if i < c { - copy(q.d[i+1:], q.d[i:c]) - } - c++ - q.c = c - q.d[i].k, q.d[i].v = k, v - t.c++ - return q -} - -// Last returns the last item of the tree in the key collating order, or (nil, -// nil) if the tree is empty. -func (t *tree) Last() (k []interface{}, v []interface{}) { - if q := t.last; q != nil { - q := &q.d[q.c-1] - k, v = q.k, q.v - } - return -} - -// Len returns the number of items in the tree. -func (t *tree) Len() int { - return t.c -} - -func (t *tree) overflow(p *x, q *d, pi, i int, k []interface{}, v []interface{}) { - t.ver++ - l, r := p.siblings(pi) - - if l != nil && l.c < 2*kd && i > 0 { - l.mvL(q, 1) - t.insert(q, i-1, k, v) - return - } - - if r != nil && r.c < 2*kd { - if i < 2*kd { - q.mvR(r, 1) - t.insert(q, i, k, v) - } else { - t.insert(r, 0, k, v) - } - return - } - - t.split(p, q, pi, i, k, v) -} - -// Seek returns an enumerator positioned on a an item such that k >= item's -// key. ok reports if k == item.key The enumerator's position is possibly -// after the last item in the tree. -func (t *tree) Seek(k []interface{}) (e *enumerator, ok bool) { - q := t.r - if q == nil { - e = &enumerator{nil, false, 0, k, nil, t, t.ver} - return - } - - for { - var i int - if i, ok = t.find(q, k); ok { - switch z := q.(type) { - case *x: - e = &enumerator{nil, ok, 0, k, z.x[i].sep, t, t.ver} - return - case *d: - e = &enumerator{nil, ok, i, k, z, t, t.ver} - return - } - } - switch z := q.(type) { - case *x: - q = z.x[i].ch - case *d: - e = &enumerator{nil, ok, i, k, z, t, t.ver} - return - } - } -} - -// SeekFirst returns an enumerator positioned on the first KV pair in the tree, -// if any. For an empty tree, err == io.EOF is returned and e will be nil. -func (t *tree) SeekFirst() (e *enumerator, err error) { - q := t.first - if q == nil { - return nil, io.EOF - } - - return &enumerator{nil, true, 0, q.d[0].k, q, t, t.ver}, nil -} - -// SeekLast returns an enumerator positioned on the last KV pair in the tree, -// if any. For an empty tree, err == io.EOF is returned and e will be nil. -func (t *tree) SeekLast() (e *enumerator, err error) { - q := t.last - if q == nil { - return nil, io.EOF - } - - return &enumerator{nil, true, q.c - 1, q.d[q.c-1].k, q, t, t.ver}, nil -} - -// Set sets the value associated with k. -func (t *tree) Set(k []interface{}, v []interface{}) { - pi := -1 - var p *x - q := t.r - if q != nil { - for { - i, ok := t.find(q, k) - if ok { - switch z := q.(type) { - case *x: - z.x[i].sep.d[0].v = v - case *d: - z.d[i].v = v - } - return - } - - switch z := q.(type) { - case *x: - if z.c > 2*kx { - t.splitX(p, &z, pi, &i) - } - pi = i - p = z - q = z.x[i].ch - case *d: - switch { - case z.c < 2*kd: - t.insert(z, i, k, v) - default: - t.overflow(p, z, pi, i, k, v) - } - return - } - } - } - - z := t.insert(&d{}, 0, k, v) - t.r, t.first, t.last = z, z, z - return -} - -func (t *tree) split(p *x, q *d, pi, i int, k []interface{}, v []interface{}) { - t.ver++ - r := &d{} - if q.n != nil { - r.n = q.n - r.n.p = r - } else { - t.last = r - } - q.n = r - r.p = q - - copy(r.d[:], q.d[kd:2*kd]) - for i := range q.d[kd:] { - q.d[kd+i] = zde - } - q.c = kd - r.c = kd - if pi >= 0 { - p.insert(pi, r, r) - } else { - t.r = newX(q).insert(0, r, r) - } - if i > kd { - t.insert(r, i-kd, k, v) - return - } - - t.insert(q, i, k, v) -} - -func (t *tree) splitX(p *x, pp **x, pi int, i *int) { - t.ver++ - q := *pp - r := &x{} - copy(r.x[:], q.x[kx+1:]) - q.c = kx - r.c = kx - if pi >= 0 { - p.insert(pi, q.x[kx].sep, r) - } else { - t.r = newX(q).insert(0, q.x[kx].sep, r) - } - q.x[kx].sep = nil - for i := range q.x[kx+1:] { - q.x[kx+i+1] = zxe - } - if *i > kx { - *pp = r - *i -= kx + 1 - } -} - -func (t *tree) underflow(p *x, q *d, pi int) { - t.ver++ - l, r := p.siblings(pi) - - if l != nil && l.c+q.c >= 2*kd { - l.mvR(q, 1) - } else if r != nil && q.c+r.c >= 2*kd { - q.mvL(r, 1) - r.d[r.c] = zde // GC - } else if l != nil { - t.cat(p, l, q, pi-1) - } else { - t.cat(p, q, r, pi) - } -} - -func (t *tree) underflowX(p *x, pp **x, pi int, i *int) { - t.ver++ - var l, r *x - q := *pp - - if pi >= 0 { - if pi > 0 { - l = p.x[pi-1].ch.(*x) - } - if pi < p.c { - r = p.x[pi+1].ch.(*x) - } - } - - if l != nil && l.c > kx { - q.x[q.c+1].ch = q.x[q.c].ch - copy(q.x[1:], q.x[:q.c]) - q.x[0].ch = l.x[l.c].ch - q.x[0].sep = p.x[pi-1].sep - q.c++ - *i++ - l.c-- - p.x[pi-1].sep = l.x[l.c].sep - return - } - - if r != nil && r.c > kx { - q.x[q.c].sep = p.x[pi].sep - q.c++ - q.x[q.c].ch = r.x[0].ch - p.x[pi].sep = r.x[0].sep - copy(r.x[:], r.x[1:r.c]) - r.c-- - rc := r.c - r.x[rc].ch = r.x[rc+1].ch - r.x[rc].sep = nil - r.x[rc+1].ch = nil - return - } - - if l != nil { - *i += l.c + 1 - t.catX(p, l, q, pi-1) - *pp = l - return - } - - t.catX(p, q, r, pi) -} - -// ----------------------------------------------------------------- enumerator - -// Next returns the currently enumerated item, if it exists and moves to the -// next item in the key collation order. If there is no item to return, err == -// io.EOF is returned. -func (e *enumerator) Next() (k []interface{}, v []interface{}, err error) { - if err = e.err; err != nil { - return - } - - if e.ver != e.t.ver { - f, hit := e.t.Seek(e.k) - if !e.hit && hit { - if err = f.next(); err != nil { - return - } - } - - *e = *f - } - if e.q == nil { - e.err, err = io.EOF, io.EOF - return - } - - if e.i >= e.q.c { - if err = e.next(); err != nil { - return - } - } - - i := e.q.d[e.i] - k, v = i.k, i.v - e.k, e.hit = k, false - e.next() - return -} - -func (e *enumerator) next() error { - if e.q == nil { - e.err = io.EOF - return io.EOF - } - - switch { - case e.i < e.q.c-1: - e.i++ - default: - if e.q, e.i = e.q.n, 0; e.q == nil { - e.err = io.EOF - } - } - return e.err -} - -// Prev returns the currently enumerated item, if it exists and moves to the -// previous item in the key collation order. If there is no item to return, err -// == io.EOF is returned. -func (e *enumerator) Prev() (k []interface{}, v []interface{}, err error) { - if err = e.err; err != nil { - return - } - - if e.ver != e.t.ver { - f, hit := e.t.Seek(e.k) - if !e.hit && hit { - if err = f.prev(); err != nil { - return - } - } - - *e = *f - } - if e.q == nil { - e.err, err = io.EOF, io.EOF - return - } - - if e.i >= e.q.c { - if err = e.next(); err != nil { - return - } - } - - i := e.q.d[e.i] - k, v = i.k, i.v - e.k, e.hit = k, false - e.prev() - return -} - -func (e *enumerator) prev() error { - if e.q == nil { - e.err = io.EOF - return io.EOF - } - - switch { - case e.i > 0: - e.i-- - default: - if e.q = e.q.p; e.q == nil { - e.err = io.EOF - break - } - - e.i = e.q.c - 1 - } - return e.err -} diff --git a/Godeps/_workspace/src/github.com/cznic/ql/builtin.go b/Godeps/_workspace/src/github.com/cznic/ql/builtin.go deleted file mode 100644 index 1c4bc1c1af..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/builtin.go +++ /dev/null @@ -1,991 +0,0 @@ -// Copyright 2014 The ql 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 ql - -import ( - "fmt" - "math/rand" - "reflect" - "strconv" - "strings" - "time" -) - -//TODO agg bigint, bigrat, time, duration - -var builtin = map[string]struct { - f func([]interface{}, map[interface{}]interface{}) (interface{}, error) - minArgs int - maxArgs int - isStatic bool - isAggregate bool -}{ - "__testBlob": {builtinTestBlob, 1, 1, true, false}, - "__testString": {builtinTestString, 1, 1, true, false}, - "avg": {builtinAvg, 1, 1, false, true}, - "complex": {builtinComplex, 2, 2, true, false}, - "contains": {builtinContains, 2, 2, true, false}, - "count": {builtinCount, 0, 1, false, true}, - "date": {builtinDate, 8, 8, true, false}, - "day": {builtinDay, 1, 1, true, false}, - "formatTime": {builtinFormatTime, 2, 2, true, false}, - "formatFloat": {builtinFormatFloat, 1, 4, true, false}, - "formatInt": {builtinFormatInt, 1, 2, true, false}, - "hasPrefix": {builtinHasPrefix, 2, 2, true, false}, - "hasSuffix": {builtinHasSuffix, 2, 2, true, false}, - "hour": {builtinHour, 1, 1, true, false}, - "hours": {builtinHours, 1, 1, true, false}, - "id": {builtinID, 0, 1, false, false}, - "imag": {builtinImag, 1, 1, true, false}, - "len": {builtinLen, 1, 1, true, false}, - "max": {builtinMax, 1, 1, false, true}, - "min": {builtinMin, 1, 1, false, true}, - "minute": {builtinMinute, 1, 1, true, false}, - "minutes": {builtinMinutes, 1, 1, true, false}, - "month": {builtinMonth, 1, 1, true, false}, - "nanosecond": {builtinNanosecond, 1, 1, true, false}, - "nanoseconds": {builtinNanoseconds, 1, 1, true, false}, - "now": {builtinNow, 0, 0, false, false}, - "parseTime": {builtinParseTime, 2, 2, true, false}, - "real": {builtinReal, 1, 1, true, false}, - "second": {builtinSecond, 1, 1, true, false}, - "seconds": {builtinSeconds, 1, 1, true, false}, - "since": {builtinSince, 1, 1, false, false}, - "sum": {builtinSum, 1, 1, false, true}, - "timeIn": {builtinTimeIn, 2, 2, true, false}, - "weekday": {builtinWeekday, 1, 1, true, false}, - "year": {builtinYear, 1, 1, true, false}, - "yearDay": {builtinYearday, 1, 1, true, false}, -} - -func badNArgs(min int, s string, arg []interface{}) error { - a := []string{} - for _, v := range arg { - a = append(a, fmt.Sprintf("%v", v)) - } - switch len(arg) < min { - case true: - return fmt.Errorf("missing argument to %s(%s)", s, strings.Join(a, ", ")) - default: //case false: - return fmt.Errorf("too many arguments to %s(%s)", s, strings.Join(a, ", ")) - } -} - -func invArg(arg interface{}, s string) error { - return fmt.Errorf("invalid argument %v (type %T) for %s", arg, arg, s) -} - -func builtinTestBlob(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - n, err := intExpr(arg[0]) - if err != nil { - return nil, err - } - - rng := rand.New(rand.NewSource(n)) - b := make([]byte, n) - for i := range b { - b[i] = byte(rng.Int()) - } - return b, nil -} - -func builtinTestString(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - n, err := intExpr(arg[0]) - if err != nil { - return nil, err - } - - rng := rand.New(rand.NewSource(n)) - b := make([]byte, n) - for i := range b { - b[i] = byte(rng.Int()) - } - return string(b), nil -} - -func builtinAvg(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - type avg struct { - sum interface{} - n uint64 - } - - if _, ok := ctx["$agg0"]; ok { - return - } - - fn := ctx["$fn"] - if _, ok := ctx["$agg"]; ok { - data, ok := ctx[fn].(avg) - if !ok { - return - } - - switch x := data.sum.(type) { - case complex64: - return complex64(complex128(x) / complex(float64(data.n), 0)), nil - case complex128: - return complex64(complex128(x) / complex(float64(data.n), 0)), nil - case float32: - return float32(float64(x) / float64(data.n)), nil - case float64: - return float64(x) / float64(data.n), nil - case int8: - return int8(int64(x) / int64(data.n)), nil - case int16: - return int16(int64(x) / int64(data.n)), nil - case int32: - return int32(int64(x) / int64(data.n)), nil - case int64: - return int64(int64(x) / int64(data.n)), nil - case uint8: - return uint8(uint64(x) / data.n), nil - case uint16: - return uint16(uint64(x) / data.n), nil - case uint32: - return uint32(uint64(x) / data.n), nil - case uint64: - return uint64(uint64(x) / data.n), nil - } - - } - - data, _ := ctx[fn].(avg) - y := arg[0] - if y == nil { - return - } - - switch x := data.sum.(type) { - case nil: - switch y := y.(type) { - case float32, float64, int8, int16, int32, int64, uint8, uint16, uint32, uint64: - data = avg{y, 0} - default: - return nil, fmt.Errorf("avg: cannot accept %v (value if type %T)", y, y) - } - case complex64: - data.sum = x + y.(complex64) - case complex128: - data.sum = x + y.(complex128) - case float32: - data.sum = x + y.(float32) - case float64: - data.sum = x + y.(float64) - case int8: - data.sum = x + y.(int8) - case int16: - data.sum = x + y.(int16) - case int32: - data.sum = x + y.(int32) - case int64: - data.sum = x + y.(int64) - case uint8: - data.sum = x + y.(uint8) - case uint16: - data.sum = x + y.(uint16) - case uint32: - data.sum = x + y.(uint32) - case uint64: - data.sum = x + y.(uint64) - } - data.n++ - ctx[fn] = data - return -} - -func builtinComplex(arg []interface{}, _ map[interface{}]interface{}) (v interface{}, err error) { - re, im := arg[0], arg[1] - if re == nil || im == nil { - return nil, nil - } - - re, im = coerce(re, im) - if reflect.TypeOf(re) != reflect.TypeOf(im) { - return nil, fmt.Errorf("complex(%T(%#v), %T(%#v)): invalid types", re, re, im, im) - } - - switch re := re.(type) { - case idealFloat: - return idealComplex(complex(float64(re), float64(im.(idealFloat)))), nil - case idealInt: - return idealComplex(complex(float64(re), float64(im.(idealInt)))), nil - case idealRune: - return idealComplex(complex(float64(re), float64(im.(idealRune)))), nil - case idealUint: - return idealComplex(complex(float64(re), float64(im.(idealUint)))), nil - case float32: - return complex(float32(re), im.(float32)), nil - case float64: - return complex(float64(re), im.(float64)), nil - case int8: - return complex(float64(re), float64(im.(int8))), nil - case int16: - return complex(float64(re), float64(im.(int16))), nil - case int32: - return complex(float64(re), float64(im.(int32))), nil - case int64: - return complex(float64(re), float64(im.(int64))), nil - case uint8: - return complex(float64(re), float64(im.(uint8))), nil - case uint16: - return complex(float64(re), float64(im.(uint16))), nil - case uint32: - return complex(float64(re), float64(im.(uint32))), nil - case uint64: - return complex(float64(re), float64(im.(uint64))), nil - default: - return nil, invArg(re, "complex") - } -} - -func builtinContains(arg []interface{}, _ map[interface{}]interface{}) (v interface{}, err error) { - switch s := arg[0].(type) { - case nil: - return nil, nil - case string: - switch chars := arg[1].(type) { - case nil: - return nil, nil - case string: - return strings.Contains(s, chars), nil - default: - return nil, invArg(chars, "string") - } - default: - return nil, invArg(s, "string") - } -} - -func builtinCount(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - if _, ok := ctx["$agg0"]; ok { - return int64(0), nil - } - - fn := ctx["$fn"] - if _, ok := ctx["$agg"]; ok { - return ctx[fn].(int64), nil - } - - n, _ := ctx[fn].(int64) - switch len(arg) { - case 0: - n++ - case 1: - if arg[0] != nil { - n++ - } - default: - panic("internal error 067") - } - ctx[fn] = n - return -} - -func builtinDate(arg []interface{}, _ map[interface{}]interface{}) (v interface{}, err error) { - for i, v := range arg { - switch i { - case 7: - switch x := v.(type) { - case string: - default: - return nil, invArg(x, "date") - } - default: - switch x := v.(type) { - case int64: - case idealInt: - arg[i] = int64(x) - default: - return nil, invArg(x, "date") - } - } - } - - sloc := arg[7].(string) - loc := time.Local - switch sloc { - case "local": - default: - loc, err = time.LoadLocation(sloc) - if err != nil { - return - } - } - - return time.Date( - int(arg[0].(int64)), - time.Month(arg[1].(int64)), - int(arg[2].(int64)), - int(arg[3].(int64)), - int(arg[4].(int64)), - int(arg[5].(int64)), - int(arg[6].(int64)), - loc, - ), nil -} - -func builtinLen(arg []interface{}, _ map[interface{}]interface{}) (v interface{}, err error) { - switch x := arg[0].(type) { - case nil: - return nil, nil - case string: - return int64(len(x)), nil - default: - return nil, invArg(x, "len") - } -} - -func builtinDay(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - switch x := arg[0].(type) { - case nil: - return nil, nil - case time.Time: - return int64(x.Day()), nil - default: - return nil, invArg(x, "day") - } -} - -func builtinFormatTime(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - switch x := arg[0].(type) { - case nil: - return nil, nil - case time.Time: - switch y := arg[1].(type) { - case nil: - return nil, nil - case string: - return x.Format(y), nil - default: - return nil, invArg(y, "formatTime") - } - default: - return nil, invArg(x, "formatTime") - } -} - -func builtinFormatFloat(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - var val float64 - var fmt byte = 'g' - - prec := -1 - bitSize := 64 - - switch x := arg[0].(type) { - case nil: - return nil, nil - case float32: - val = float64(x) - bitSize = 32 - case float64: - val = x - default: - return nil, invArg(x, "formatFloat") - } - - switch len(arg) { - case 4: - arg3 := coerce1(arg[3], int64(0)) - switch y := arg3.(type) { - case nil: - return nil, nil - case int64: - bitSize = int(y) - default: - return nil, invArg(y, "formatFloat") - } - fallthrough - case 3: - arg2 := coerce1(arg[2], int64(0)) - switch y := arg2.(type) { - case nil: - return nil, nil - case int64: - prec = int(y) - default: - return nil, invArg(y, "formatFloat") - } - fallthrough - case 2: - arg1 := coerce1(arg[1], byte(0)) - switch y := arg1.(type) { - case nil: - return nil, nil - case byte: - fmt = y - default: - return nil, invArg(y, "formatFloat") - } - } - - return strconv.FormatFloat(val, fmt, prec, bitSize), nil -} - -func builtinFormatInt(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - var intVal int64 - var uintVal uint64 - - uintType := false - base := 10 - - switch x := arg[0].(type) { - case nil: - return nil, nil - case int8: - intVal = int64(x) - case int16: - intVal = int64(x) - case int32: - intVal = int64(x) - case int64: - intVal = x - case uint8: - uintType = true - uintVal = uint64(x) - case uint16: - uintType = true - uintVal = uint64(x) - case uint32: - uintType = true - uintVal = uint64(x) - case uint64: - uintType = true - uintVal = x - default: - return nil, invArg(x, "formatInt") - } - - switch len(arg) { - case 2: - arg1 := coerce1(arg[1], int64(0)) - switch y := arg1.(type) { - case nil: - return nil, nil - case int64: - base = int(y) - default: - return nil, invArg(y, "formatInt") - } - } - - if uintType { - return strconv.FormatUint(uintVal, base), nil - } - - return strconv.FormatInt(intVal, base), nil -} - -func builtinHasPrefix(arg []interface{}, _ map[interface{}]interface{}) (v interface{}, err error) { - switch s := arg[0].(type) { - case nil: - return nil, nil - case string: - switch prefix := arg[1].(type) { - case nil: - return nil, nil - case string: - return strings.HasPrefix(s, prefix), nil - default: - return nil, invArg(prefix, "string") - } - default: - return nil, invArg(s, "string") - } -} - -func builtinHasSuffix(arg []interface{}, _ map[interface{}]interface{}) (v interface{}, err error) { - switch s := arg[0].(type) { - case nil: - return nil, nil - case string: - switch suffix := arg[1].(type) { - case nil: - return nil, nil - case string: - return strings.HasSuffix(s, suffix), nil - default: - return nil, invArg(suffix, "string") - } - default: - return nil, invArg(s, "string") - } -} - -func builtinHour(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - switch x := arg[0].(type) { - case nil: - return nil, nil - case time.Time: - return int64(x.Hour()), nil - default: - return nil, invArg(x, "hour") - } -} - -func builtinHours(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - switch x := arg[0].(type) { - case nil: - return nil, nil - case time.Duration: - return x.Hours(), nil - default: - return nil, invArg(x, "hours") - } -} - -func builtinID(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - switch x := ctx["$id"].(type) { - case map[string]interface{}: - if len(arg) == 0 { - return nil, nil - } - - tab := arg[0].(*ident) - id, ok := x[tab.s] - if !ok { - return nil, fmt.Errorf("value not available: id(%s)", tab) - } - - if _, ok := id.(int64); ok { - return id, nil - } - - return nil, fmt.Errorf("value not available: id(%s)", tab) - case int64: - return x, nil - default: - return nil, nil - } -} - -func builtinImag(arg []interface{}, _ map[interface{}]interface{}) (v interface{}, err error) { - switch x := arg[0].(type) { - case nil: - return nil, nil - case idealComplex: - return imag(x), nil - case complex64: - return imag(x), nil - case complex128: - return imag(x), nil - default: - return nil, invArg(x, "imag") - } -} - -func builtinMax(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - if _, ok := ctx["$agg0"]; ok { - return - } - - fn := ctx["$fn"] - if _, ok := ctx["$agg"]; ok { - if v, ok = ctx[fn]; ok { - return - } - - return nil, nil - } - - max := ctx[fn] - y := arg[0] - if y == nil { - return - } - switch x := max.(type) { - case nil: - switch y := y.(type) { - case float32, float64, string, int8, int16, int32, int64, uint8, uint16, uint32, uint64, time.Time: - max = y - default: - return nil, fmt.Errorf("max: cannot accept %v (value if type %T)", y, y) - } - case float32: - if y := y.(float32); y > x { - max = y - } - case float64: - if y := y.(float64); y > x { - max = y - } - case string: - if y := y.(string); y > x { - max = y - } - case int8: - if y := y.(int8); y > x { - max = y - } - case int16: - if y := y.(int16); y > x { - max = y - } - case int32: - if y := y.(int32); y > x { - max = y - } - case int64: - if y := y.(int64); y > x { - max = y - } - case uint8: - if y := y.(uint8); y > x { - max = y - } - case uint16: - if y := y.(uint16); y > x { - max = y - } - case uint32: - if y := y.(uint32); y > x { - max = y - } - case uint64: - if y := y.(uint64); y > x { - max = y - } - case time.Time: - if y := y.(time.Time); y.After(x) { - max = y - } - } - ctx[fn] = max - return -} - -func builtinMin(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - if _, ok := ctx["$agg0"]; ok { - return - } - - fn := ctx["$fn"] - if _, ok := ctx["$agg"]; ok { - if v, ok = ctx[fn]; ok { - return - } - - return nil, nil - } - - min := ctx[fn] - y := arg[0] - if y == nil { - return - } - switch x := min.(type) { - case nil: - switch y := y.(type) { - case float32, float64, string, int8, int16, int32, int64, uint8, uint16, uint32, uint64, time.Time: - min = y - default: - return nil, fmt.Errorf("min: cannot accept %v (value if type %T)", y, y) - } - case float32: - if y := y.(float32); y < x { - min = y - } - case float64: - if y := y.(float64); y < x { - min = y - } - case string: - if y := y.(string); y < x { - min = y - } - case int8: - if y := y.(int8); y < x { - min = y - } - case int16: - if y := y.(int16); y < x { - min = y - } - case int32: - if y := y.(int32); y < x { - min = y - } - case int64: - if y := y.(int64); y < x { - min = y - } - case uint8: - if y := y.(uint8); y < x { - min = y - } - case uint16: - if y := y.(uint16); y < x { - min = y - } - case uint32: - if y := y.(uint32); y < x { - min = y - } - case uint64: - if y := y.(uint64); y < x { - min = y - } - case time.Time: - if y := y.(time.Time); y.Before(x) { - min = y - } - } - ctx[fn] = min - return -} - -func builtinMinute(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - switch x := arg[0].(type) { - case nil: - return nil, nil - case time.Time: - return int64(x.Minute()), nil - default: - return nil, invArg(x, "minute") - } -} - -func builtinMinutes(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - switch x := arg[0].(type) { - case nil: - return nil, nil - case time.Duration: - return x.Minutes(), nil - default: - return nil, invArg(x, "minutes") - } -} - -func builtinMonth(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - switch x := arg[0].(type) { - case nil: - return nil, nil - case time.Time: - return int64(x.Month()), nil - default: - return nil, invArg(x, "month") - } -} - -func builtinNanosecond(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - switch x := arg[0].(type) { - case nil: - return nil, nil - case time.Time: - return int64(x.Nanosecond()), nil - default: - return nil, invArg(x, "nanosecond") - } -} - -func builtinNanoseconds(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - switch x := arg[0].(type) { - case nil: - return nil, nil - case time.Duration: - return x.Nanoseconds(), nil - default: - return nil, invArg(x, "nanoseconds") - } -} - -func builtinNow(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - return time.Now(), nil -} - -func builtinParseTime(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - var a [2]string - for i, v := range arg { - switch x := v.(type) { - case nil: - return nil, nil - case string: - a[i] = x - default: - return nil, invArg(x, "parseTime") - } - } - - t, err := time.Parse(a[0], a[1]) - if err != nil { - return nil, err - } - - ls := t.Location().String() - if ls == "UTC" { - return t, nil - } - - l, err := time.LoadLocation(ls) - if err != nil { - return t, nil - } - - return time.ParseInLocation(a[0], a[1], l) -} - -func builtinReal(arg []interface{}, _ map[interface{}]interface{}) (v interface{}, err error) { - switch x := arg[0].(type) { - case nil: - return nil, nil - case idealComplex: - return real(x), nil - case complex64: - return real(x), nil - case complex128: - return real(x), nil - default: - return nil, invArg(x, "real") - } -} - -func builtinSecond(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - switch x := arg[0].(type) { - case nil: - return nil, nil - case time.Time: - return int64(x.Second()), nil - default: - return nil, invArg(x, "second") - } -} - -func builtinSeconds(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - switch x := arg[0].(type) { - case nil: - return nil, nil - case time.Duration: - return x.Seconds(), nil - default: - return nil, invArg(x, "seconds") - } -} - -func builtinSince(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - switch x := arg[0].(type) { - case nil: - return nil, nil - case time.Time: - return time.Since(x), nil - default: - return nil, invArg(x, "since") - } -} - -func builtinSum(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - if _, ok := ctx["$agg0"]; ok { - return - } - - fn := ctx["$fn"] - if _, ok := ctx["$agg"]; ok { - if v, ok = ctx[fn]; ok { - return - } - - return nil, nil - } - - sum := ctx[fn] - y := arg[0] - if y == nil { - return - } - switch x := sum.(type) { - case nil: - switch y := y.(type) { - case complex64, complex128, float32, float64, int8, int16, int32, int64, uint8, uint16, uint32, uint64: - sum = y - default: - return nil, fmt.Errorf("sum: cannot accept %v (value if type %T)", y, y) - } - case complex64: - sum = x + y.(complex64) - case complex128: - sum = x + y.(complex128) - case float32: - sum = x + y.(float32) - case float64: - sum = x + y.(float64) - case int8: - sum = x + y.(int8) - case int16: - sum = x + y.(int16) - case int32: - sum = x + y.(int32) - case int64: - sum = x + y.(int64) - case uint8: - sum = x + y.(uint8) - case uint16: - sum = x + y.(uint16) - case uint32: - sum = x + y.(uint32) - case uint64: - sum = x + y.(uint64) - } - ctx[fn] = sum - return -} - -func builtinTimeIn(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - switch x := arg[0].(type) { - case nil: - return nil, nil - case time.Time: - switch y := arg[1].(type) { - case nil: - return nil, nil - case string: - loc := time.Local - switch y { - case "local": - default: - loc, err = time.LoadLocation(y) - if err != nil { - return - } - } - - return x.In(loc), nil - default: - return nil, invArg(x, "timeIn") - } - default: - return nil, invArg(x, "timeIn") - } -} - -func builtinWeekday(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - switch x := arg[0].(type) { - case nil: - return nil, nil - case time.Time: - return int64(x.Weekday()), nil - default: - return nil, invArg(x, "weekday") - } -} - -func builtinYear(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - switch x := arg[0].(type) { - case nil: - return nil, nil - case time.Time: - return int64(x.Year()), nil - default: - return nil, invArg(x, "year") - } -} - -func builtinYearday(arg []interface{}, ctx map[interface{}]interface{}) (v interface{}, err error) { - switch x := arg[0].(type) { - case nil: - return nil, nil - case time.Time: - return int64(x.YearDay()), nil - default: - return nil, invArg(x, "yearDay") - } -} diff --git a/Godeps/_workspace/src/github.com/cznic/ql/coerce.go b/Godeps/_workspace/src/github.com/cznic/ql/coerce.go deleted file mode 100644 index bd384f93e6..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/coerce.go +++ /dev/null @@ -1,290 +0,0 @@ -// Copyright 2013 The ql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// CAUTION: This file was generated automatically by -// -// $ go run helper/helper.go -o coerce.go -// -// DO NOT EDIT! - -package ql - -import ( - "math" - "math/big" - "reflect" - "time" -) - -func coerce(a, b interface{}) (x, y interface{}) { - if reflect.TypeOf(a) == reflect.TypeOf(b) { - return a, b - } - - switch a.(type) { - case idealComplex, idealFloat, idealInt, idealRune, idealUint: - switch b.(type) { - case idealComplex, idealFloat, idealInt, idealRune, idealUint: - x, y = coerce1(a, b), b - if reflect.TypeOf(x) == reflect.TypeOf(y) { - return - } - - return a, coerce1(b, a) - default: - return coerce1(a, b), b - } - default: - switch b.(type) { - case idealComplex, idealFloat, idealInt, idealRune, idealUint: - return a, coerce1(b, a) - default: - return a, b - } - } -} - -func coerce1(inVal, otherVal interface{}) (coercedInVal interface{}) { - coercedInVal = inVal - if otherVal == nil { - return - } - - switch x := inVal.(type) { - case nil: - return - case idealComplex: - switch otherVal.(type) { - //case idealComplex: - //case idealFloat: - //case idealInt: - //case idealRune: - //case idealUint: - //case bool: - case complex64: - return complex64(x) - case complex128: - return complex128(x) - //case float32: - //case float64: - //case int8: - //case int16: - //case int32: - //case int64: - //case string: - //case uint8: - //case uint16: - //case uint32: - //case uint64: - //case *big.Int: - //case *big.Rat: - //case time.Time: - //case time.Duration: - } - case idealFloat: - switch otherVal.(type) { - case idealComplex: - return idealComplex(complex(float64(x), 0)) - case idealFloat: - return idealFloat(float64(x)) - //case idealInt: - //case idealRune: - //case idealUint: - //case bool: - case complex64: - return complex64(complex(float32(x), 0)) - case complex128: - return complex128(complex(float64(x), 0)) - case float32: - return float32(float64(x)) - case float64: - return float64(float64(x)) - //case int8: - //case int16: - //case int32: - //case int64: - //case string: - //case uint8: - //case uint16: - //case uint32: - //case uint64: - //case *big.Int: - case *big.Rat: - return big.NewRat(1, 1).SetFloat64(float64(x)) - //case time.Time: - //case time.Duration: - } - case idealInt: - switch otherVal.(type) { - case idealComplex: - return idealComplex(complex(float64(x), 0)) - case idealFloat: - return idealFloat(int64(x)) - case idealInt: - return idealInt(int64(x)) - //case idealRune: - case idealUint: - if x >= 0 { - return idealUint(int64(x)) - } - //case bool: - case complex64: - return complex64(complex(float32(x), 0)) - case complex128: - return complex128(complex(float64(x), 0)) - case float32: - return float32(int64(x)) - case float64: - return float64(int64(x)) - case int8: - if x >= math.MinInt8 && x <= math.MaxInt8 { - return int8(int64(x)) - } - case int16: - if x >= math.MinInt16 && x <= math.MaxInt16 { - return int16(int64(x)) - } - case int32: - if x >= math.MinInt32 && x <= math.MaxInt32 { - return int32(int64(x)) - } - case int64: - return int64(int64(x)) - //case string: - case uint8: - if x >= 0 && x <= math.MaxUint8 { - return uint8(int64(x)) - } - case uint16: - if x >= 0 && x <= math.MaxUint16 { - return uint16(int64(x)) - } - case uint32: - if x >= 0 && x <= math.MaxUint32 { - return uint32(int64(x)) - } - case uint64: - if x >= 0 { - return uint64(int64(x)) - } - case *big.Int: - return big.NewInt(int64(x)) - case *big.Rat: - return big.NewRat(1, 1).SetInt64(int64(x)) - //case time.Time: - case time.Duration: - return time.Duration(int64(x)) - } - case idealRune: - switch otherVal.(type) { - case idealComplex: - return idealComplex(complex(float64(x), 0)) - case idealFloat: - return idealFloat(int64(x)) - case idealInt: - return idealInt(int64(x)) - case idealRune: - return idealRune(int64(x)) - case idealUint: - return idealUint(int64(x)) - //case bool: - case complex64: - return complex64(complex(float32(x), 0)) - case complex128: - return complex128(complex(float64(x), 0)) - case float32: - return float32(int64(x)) - case float64: - return float64(int64(x)) - case int8: - return int8(int64(x)) - case int16: - return int16(int64(x)) - case int32: - return int32(int64(x)) - case int64: - return int64(int64(x)) - //case string: - case uint8: - return uint8(int64(x)) - case uint16: - return uint16(int64(x)) - case uint32: - return uint32(int64(x)) - case uint64: - return uint64(int64(x)) - case *big.Int: - return big.NewInt(int64(x)) - case *big.Rat: - return big.NewRat(1, 1).SetInt64(int64(x)) - //case time.Time: - case time.Duration: - return time.Duration(int64(x)) - } - case idealUint: - switch otherVal.(type) { - case idealComplex: - return idealComplex(complex(float64(x), 0)) - case idealFloat: - return idealFloat(uint64(x)) - case idealInt: - if x <= math.MaxInt64 { - return idealInt(int64(x)) - } - //case idealRune: - case idealUint: - return idealUint(uint64(x)) - //case bool: - case complex64: - return complex64(complex(float32(x), 0)) - case complex128: - return complex128(complex(float64(x), 0)) - case float32: - return float32(uint64(x)) - case float64: - return float64(uint64(x)) - case int8: - if x <= math.MaxInt8 { - return int8(int64(x)) - } - case int16: - if x <= math.MaxInt16 { - return int16(int64(x)) - } - case int32: - if x <= math.MaxInt32 { - return int32(int64(x)) - } - case int64: - if x <= math.MaxInt64 { - return int64(int64(x)) - } - //case string: - case uint8: - if x >= 0 && x <= math.MaxUint8 { - return uint8(int64(x)) - } - case uint16: - if x >= 0 && x <= math.MaxUint16 { - return uint16(int64(x)) - } - case uint32: - if x >= 0 && x <= math.MaxUint32 { - return uint32(int64(x)) - } - case uint64: - return uint64(uint64(x)) - case *big.Int: - return big.NewInt(0).SetUint64(uint64(x)) - case *big.Rat: - return big.NewRat(1, 1).SetInt(big.NewInt(0).SetUint64(uint64(x))) - //case time.Time: - case time.Duration: - if x <= math.MaxInt64 { - return time.Duration(int64(x)) - } - } - } - return -} diff --git a/Godeps/_workspace/src/github.com/cznic/ql/design/doc.go b/Godeps/_workspace/src/github.com/cznic/ql/design/doc.go deleted file mode 100644 index 7e6718cfdf..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/design/doc.go +++ /dev/null @@ -1,298 +0,0 @@ -// Copyright 2014 The ql 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 design describes some of the data structures used in QL. - -Handles - -A handle is a 7 byte "pointer" to a block in the DB[0]. - -Scalar encoding - -Encoding of so called "scalars" provided by [1]. Unless specified otherwise, -all values discussed below are scalars, encoded scalars or encoding of scalar -arrays. - -Database root - -DB root is a 1-scalar found at a fixed handle (#1). - - +---+------+--------+-----------------------+ - | # | Name | Type | Description | - +---+------+--------+-----------------------+ - | 0 | head | handle | First table meta data | - +---+------+--------+-----------------------+ - -Head is the head of a single linked list of table of meta data. It's zero if -there are no tables in the DB. - -Table meta data - -Table meta data are a 6-scalar. - - +---+---------+--------+--------------------------+ - | # | Name | Type | Description | - +---+---------+--------+--------------------------+ - | 0 | next | handle | Next table meta data. | - | 1 | scols | string | Column defintitions | - | 2 | hhead | handle | -> head -> first record | - | 3 | name | string | Table name | - | 4 | indices | string | Index definitions | - | 5 | hxroots | handle | Index B+Trees roots list | - +---+---------+--------+--------------------------+ - -Fields #4 and #5 are optional for backward compatibility with existing -databases. OTOH, forward compatibility will not work. Once any indices are -created using a newer QL version the older versions of QL, expecting only 4 -fields of meta data will not be able to use the DB. That's the intended -behavior because the older versions of QL cannot update the indexes, which can -break queries runned by the newer QL version which expect indices to be always -actualized on any table-with-indices mutation. - -The handle of the next table meta data is in the field #0 (next). If there is -no next table meta data, the field is zero. Names and types of table columns -are stored in field #1 (scols). A single field is described by concatenating a -type tag and the column name. The type tags are - - bool 'b' - complex64 'c' - complex128 'd' - float32 'f' - float64 'g', alias float - int8 'i' - int16 'j' - int32 'k' - int64 'l', alias int - string 's' - uint8 'u', alias byte - uint16 'v' - uint32 'w' - uint64 'x', alias uint - bigInt 'I' - bigRat 'R' - blob 'B' - duration 'D' - time 'T' - -The scols value is the above described encoded fields joined using "|". For -example - - CREATE TABLE t (Foo bool, Bar string, Baz float); - -This statement adds a table meta data with scols - - "bFool|sBar|gBaz" - -Columns can be dropped from a table - - ALTER TABLE t DROP COLUMN Bar; - -This "erases" the field info in scols, so the value becomes - - "bFool||gBaz" - -Colums can be added to a table - - ALTER TABLE t ADD Count uint; - -New fields are always added to the end of scols - - "bFool||gBaz|xCount" - -Index of a field in strings.Split(scols, "|") is the index of the field in a -table record. The above discussed rules for column dropping and column adding -allow for schema evolution without a need to reshape any existing table data. -Dropped columns are left where they are and new records insert nil in their -place. The encoded nil is one byte. Added columns, when not present in -preexisting records are returned as nil values. If the overhead of dropped -columns becomes an issue and there's time/space and memory enough to move the -records of a table around: - - BEGIN TRANSACTION; - CREATE TABLE new (column definitions); - INSERT INTO new SELECT * FROM old; - DROP TABLE old; - CREATE TABLE old (column definitions); - INSERT INTO old SELECT * FROM new; - DROP TABLE new; - END TRANSACTION; - -This is not very time/space effective and for Big Data it can cause an OOM -because transactions are limited by memory resources available to the process. -Perhaps a method and/or QL statement to do this in-place should be added -(MAYBE consider adopting MySQL's OPTIMIZE TABLE syntax). - -Field #2 (hhead) is a handle to a head of table records, i.e. not a handle to -the first record in the table. It is thus always non zero even for a table -having no records. The reason for this "double pointer" schema is to enable -adding (linking) a new record by updating a single value of the (hhead pointing -to) head. - - tableMeta.hhead -> head -> firstTableRecord - -The table name is stored in field #3 (name). - -Indices - -Consider an index named N, indexing column named C. The encoding of this -particular index is a string "N". is a string "n" for non unique -indices and "u" for unique indices. There is this index information for the -index possibly indexing the record id() and for all other columns of scols. -Where the column is not indexed, the index info is an empty string. Infos for -all indexes are joined with "|". For example - - BEGIN TRANSACTION; - CREATE TABLE t (Foo int, Bar bool, Baz string); - CREATE INDEX X ON t (Baz); - CREATE UNIQUE INDEX Y ON t (Foo); - COMMIT; - -The values of fields #1 and #4 for the above are - - scols: "lFoo|bBar|sBaz" - indices: "|uY||nX" - -Aligning properly the "|" split parts - - id col #0 col#1 col#2 - +----------+----+--------+--------+--------+ - | scols: | | "lFoo" | "bBar" | "sBaz" | - +----------+----+--------+--------+--------+ - | indices: | "" | "uY" | "" | "nX" | - +----------+----+--------+--------+--------+ - -shows that the record id() is not indexed for this table while the columns Foo -and Baz are. - -Note that there cannot be two differently named indexes for the same column and -it's intended. The indices are B+Trees[2]. The list of handles to their roots -is pointed to by hxroots with zeros for non indexed columns. For the previous -example - - tableMeta.hxroots -> {0, y, 0, x} - -where x is the root of the B+Tree for the X index and y is the root of the -B+Tree for the Y index. If there would be an index for id(), its B+Tree root -will be present where the first zero is. Similarly to hhead, hxroots is never -zero, even when there are no indices for a table. - -Table record - -A table record is an N-scalar. - - +-----+------------+--------+-------------------------------+ - | # | Name | Type | Description | - +-----+------------+--------+-------------------------------+ - | 0 | next | handle | Next record or zero. | - | 1 | id | int64 | Automatically assigned unique | - | | | | value obtainable by id(). | - | 2 | field #0 | scalar | First field of the record. | - | 3 | field #1 | scalar | Second field of the record. | - ... - | N-1 | field #N-2 | scalar | Last field of the record. | - +-----+------------+--------+-------------------------------+ - -The linked "ordering" of table records has no semantics and it doesn't have to -correlate to the order of how the records were added to the table. In fact, an -efficient way of the linking leads to "ordering" which is actually reversed wrt -the insertion order. - -Non unique index - -The composite key of the B+Tree is {indexed values, record handle}. The B+Tree -value is not used. - - B+Tree key B+Tree value - +----------------+---------------+ +--------------+ - | Indexed Values | Record Handle | -> | not used | - +----------------+---------------+ +--------------+ - -Unique index - -If the indexed values are all NULL then the composite B+Tree key is {nil, -record handle} and the B+Tree value is not used. - - B+Tree key B+Tree value - +------+-----------------+ +--------------+ - | NULL | Record Handle | -> | not used | - +------+-----------------+ +--------------+ - -If the indexed values are not all NULL then key of the B+Tree key are the indexed -values and the B+Tree value is the record handle. - - B+Tree key B+Tree value - +----------------+ +---------------+ - | Indexed Values | -> | Record Handle | - +----------------+ +---------------+ - -Non scalar types - -Scalar types of [1] are bool, complex*, float*, int*, uint*, string and []byte -types. All other types are "blob-like". - - QL type Go type - ----------------------------- - blob []byte - bigint big.Int - bigrat big.Rat - time time.Time - duration time.Duration - -Memory back-end stores the Go type directly. File back-end must resort to -encode all of the above as (tagged) []byte due to the lack of more types -supported natively by lldb. NULL values of blob-like types are encoded as nil -(gbNull in lldb/gb.go), exactly the same as the already existing QL types are. - -Blob encoding - -The values of the blob-like types are first encoded into a []byte slice: - - +-----------------------+-------------------+ - | blob | raw | - | bigint, bigrat, time | gob encoded | - | duration | gob encoded int64 | - +-----------------------+-------------------+ - -The gob encoding is "differential" wrt an initial encoding of all of the -blob-like type. IOW, the initial type descriptors which gob encoding must write -out are stripped off and "resupplied" on decoding transparently. See also -blob.go. If the length of the resulting slice is <= shortBlob, the first and -only chunk is the scalar encoding of - - - []interface{}{typeTag, slice}. // initial (and last) chunk - -The length of slice can be zero (for blob("")). If the resulting slice is long -(> shortBlob), the first chunk comes from encoding - - []interface{}{typeTag, nextHandle, firstPart}. // initial, but not final chunk - -In this case len(firstPart) <= shortBlob. Second and other chunks: If the chunk -is the last one, src is - - []interface{lastPart}. // overflow chunk (last) - -In this case len(lastPart) <= 64kB. If the chunk is not the last one, src is - - []interface{}{nextHandle, part}. // overflow chunk (not last) - -In this case len(part) == 64kB. - -Links - -Referenced from above: - - [0]: http://godoc.org/github.com/cznic/exp/lldb#hdr-Block_handles - [1]: http://godoc.org/github.com/cznic/exp/lldb#EncodeScalars - [2]: http://godoc.org/github.com/cznic/exp/lldb#BTree - -Rationale - -While these notes might be useful to anyone looking at QL sources, the -specifically intended reader is my future self. - -*/ -package design diff --git a/Godeps/_workspace/src/github.com/cznic/ql/doc.go b/Godeps/_workspace/src/github.com/cznic/ql/doc.go deleted file mode 100644 index 7a8baf10eb..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/doc.go +++ /dev/null @@ -1,2606 +0,0 @@ -// Copyright 2014 The ql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//MAYBE set operations -//MAYBE +=, -=, ... - -//TODO verify there's a graceful failure for a 2G+ blob on a 32 bit machine. - -// Package ql implements a pure Go embedded SQL database engine. -// -// QL is a member of the SQL family of languages. It is less complex and less -// powerful than SQL (whichever specification SQL is considered to be). -// -// Change list -// -// 2015-06-15: To improve compatibility with other SQL implementations, the -// count built-in aggregate function now accepts * as its argument. -// -// 2015-05-29: The execution planner was rewritten from scratch. It should use -// indices in all places where they were used before plus in some additional -// situations. It is possible to investigate the plan using the newly added -// EXPLAIN statement. The QL tool is handy for such analysis. If the planner -// would have used an index, but no such exists, the plan includes hints in -// form of copy/paste ready CREATE INDEX statements. -// -// The planner is still quite simple and a lot of work on it is yet ahead. You -// can help this process by filling an issue with a schema and query which -// fails to use an index or indices when it should, in your opinion. Bonus -// points for including output of `ql 'explain '`. -// -// 2015-05-09: The grammar of the CREATE INDEX statement now accepts an -// expression list instead of a single expression, which was further limited to -// just a column name or the built-in id(). As a side effect, composite -// indices are now functional. However, the values in the expression-list style -// index are not yet used by other statements or the statement/query planner. -// The composite index is useful while having UNIQUE clause to check for -// semantically duplicate rows before they get added to the table or when such -// a row is mutated using the UPDATE statement and the expression-list style -// index tuple of the row is thus recomputed. -// -// 2015-05-02: The Schema field of table __Table now correctly reflects any -// column constraints and/or defaults. Also, the (*DB).Info method now has that -// information provided in new ColumInfo fields NotNull, Constraint and -// Default. -// -// 2015-04-20: Added support for {LEFT,RIGHT,FULL} [OUTER] JOIN. -// -// 2015-04-18: Column definitions can now have constraints and defaults. -// Details are discussed in the "Constraints and defaults" chapter below the -// CREATE TABLE statement documentation. -// -// 2015-03-06: New built-in functions formatFloat and formatInt. Thanks -// urandom! (https://github.com/urandom) -// -// 2015-02-16: IN predicate now accepts a SELECT statement. See the updated -// "Predicates" section. -// -// 2015-01-17: Logical operators || and && have now alternative spellings: OR -// and AND (case insensitive). AND was a keyword before, but OR is a new one. -// This can possibly break existing queries. For the record, it's a good idea -// to not use any name appearing in, for example, [7] in your queries as the -// list of QL's keywords may expand for gaining better compatibility with -// existing SQL "standards". -// -// 2015-01-12: ACID guarantees were tightened at the cost of performance in -// some cases. The write collecting window mechanism, a formerly used -// implementation detail, was removed. Inserting rows one by one in a -// transaction is now slow. I mean very slow. Try to avoid inserting single -// rows in a transaction. Instead, whenever possible, perform batch updates of -// tens to, say thousands of rows in a single transaction. See also: -// http://www.sqlite.org/faq.html#q19, the discussed synchronization principles -// involved are the same as for QL, modulo minor details. -// -// Note: A side effect is that closing a DB before exiting an application, both -// for the Go API and through database/sql driver, is no more required, -// strictly speaking. Beware that exiting an application while there is an open -// (uncommitted) transaction in progress means losing the transaction data. -// However, the DB will not become corrupted because of not closing it. Nor -// that was the case before, but formerly failing to close a DB could have -// resulted in losing the data of the last transaction. -// -// 2014-09-21: id() now optionally accepts a single argument - a table name. -// -// 2014-09-01: Added the DB.Flush() method and the LIKE pattern matching -// predicate. -// -// 2014-08-08: The built in functions max and min now accept also time values. -// Thanks opennota! (https://github.com/opennota) -// -// 2014-06-05: RecordSet interface extended by new methods FirstRow and Rows. -// -// 2014-06-02: Indices on id() are now used by SELECT statements. -// -// 2014-05-07: Introduction of Marshal, Schema, Unmarshal. -// -// 2014-04-15: -// -// Added optional IF NOT EXISTS clause to CREATE INDEX and optional IF EXISTS -// clause to DROP INDEX. -// -// 2014-04-12: -// -// The column Unique in the virtual table __Index was renamed to IsUnique -// because the old name is a keyword. Unfortunately, this is a breaking change, -// sorry. -// -// 2014-04-11: Introduction of LIMIT, OFFSET. -// -// 2014-04-10: Introduction of query rewriting. -// -// 2014-04-07: Introduction of indices. -// -// Building non CGO QL -// -// QL imports zappy[8], a block-based compressor, which speeds up its -// performance by using a C version of the compression/decompression -// algorithms. If a CGO-free (pure Go) version of QL, or an app using QL, is -// required, please include 'purego' in the -tags option of go -// {build,get,install}. For example: -// -// $ go get -tags purego github.com/cznic/ql -// -// If zappy was installed before installing QL, it might be necessary to -// rebuild zappy first (or rebuild QL with all its dependencies using the -a -// option): -// -// $ touch "$GOPATH"/src/github.com/cznic/zappy/*.go -// $ go install -tags purego github.com/cznic/zappy -// $ go install github.com/cznic/ql -// -// Notation -// -// The syntax is specified using Extended Backus-Naur Form (EBNF) -// -// Production = production_name "=" [ Expression ] "." . -// Expression = Alternative { "|" Alternative } . -// Alternative = Term { Term } . -// Term = production_name | token [ "…" token ] | Group | Option | Repetition . -// Group = "(" Expression ")" . -// Option = "[" Expression "]" . -// Repetition = "{" Expression "}" . -// Productions are expressions constructed from terms and the following operators, in increasing precedence -// -// | alternation -// () grouping -// [] option (0 or 1 times) -// {} repetition (0 to n times) -// -// Lower-case production names are used to identify lexical tokens. -// Non-terminals are in CamelCase. Lexical tokens are enclosed in double quotes -// "" or back quotes ``. -// -// The form a … b represents the set of characters from a through b as -// alternatives. The horizontal ellipsis … is also used elsewhere in the spec -// to informally denote various enumerations or code snippets that are not -// further specified. -// -// QL source code representation -// -// QL source code is Unicode text encoded in UTF-8. The text is not -// canonicalized, so a single accented code point is distinct from the same -// character constructed from combining an accent and a letter; those are -// treated as two code points. For simplicity, this document will use the -// unqualified term character to refer to a Unicode code point in the source -// text. -// -// Each code point is distinct; for instance, upper and lower case letters are -// different characters. -// -// Implementation restriction: For compatibility with other tools, the parser -// may disallow the NUL character (U+0000) in the statement. -// -// Implementation restriction: A byte order mark is disallowed anywhere in QL -// statements. -// -// Characters -// -// The following terms are used to denote specific character classes -// -// newline = . // the Unicode code point U+000A -// unicode_char = . // an arbitrary Unicode code point except newline -// ascii_letter = "a" … "z" | "A" … "Z" . -// -// Letters and digits -// -// The underscore character _ (U+005F) is considered a letter. -// -// letter = ascii_letter | "_" . -// decimal_digit = "0" … "9" . -// octal_digit = "0" … "7" . -// hex_digit = "0" … "9" | "A" … "F" | "a" … "f" . -// -// Lexical elements -// -// Lexical elements are comments, tokens, identifiers, keywords, operators and -// delimiters, integer, floating-point, imaginary, rune and string literals and -// QL parameters. -// -// Comments -// -// There are three forms of comments -// -// Line comments start with the character sequence // or -- and stop at the end -// of the line. A line comment acts like a space. -// -// General comments start with the character sequence /* and continue through -// the character sequence */. A general comment acts like a space. -// -// Comments do not nest. -// -// Tokens -// -// Tokens form the vocabulary of QL. There are four classes: identifiers, -// keywords, operators and delimiters, and literals. White space, formed from -// spaces (U+0020), horizontal tabs (U+0009), carriage returns (U+000D), and -// newlines (U+000A), is ignored except as it separates tokens that would -// otherwise combine into a single token. -// -// Semicolons -// -// The formal grammar uses semicolons ";" as separators of QL statements. A -// single QL statement or the last QL statement in a list of statements can -// have an optional semicolon terminator. (Actually a separator from the -// following empty statement.) -// -// Identifiers -// -// Identifiers name entities such as tables or record set columns. An -// identifier is a sequence of one or more letters and digits. The first -// character in an identifier must be a letter. -// -// identifier = letter { letter | decimal_digit } . -// -// For example -// -// price -// _tmp42 -// Sales -// -// No identifiers are predeclared, however note that no keyword can be used as -// an identifier. Identifiers starting with two underscores are used for meta -// data virtual tables names. For forward compatibility, users should generally -// avoid using any identifiers starting with two underscores. For example -// -// __Column -// __Column2 -// __Index -// __Table -// -// Keywords -// -// The following keywords are reserved and may not be used as identifiers. -// -// ADD COLUMN false int32 ORDER uint16 -// ALTER complex128 float int64 OUTER uint32 -// AND complex64 float32 int8 RIGHT uint64 -// AS CREATE float64 INTO SELECT uint8 -// ASC DEFAULT FROM JOIN SET UNIQUE -// BETWEEN DELETE GROUP LEFT string UPDATE -// bigint DESC IF LIMIT TABLE VALUES -// bigrat DISTINCT IN LIKE time WHERE -// blob DROP INDEX NOT true -// bool duration INSERT NULL OR -// BY EXISTS int OFFSET TRUNCATE -// byte EXPLAIN int16 ON uint -// -// Keywords are not case sensitive. -// -// Operators and Delimiters -// -// The following character sequences represent operators, delimiters, and other -// special tokens -// -// + & && == != ( ) -// - | || < <= [ ] -// * ^ > >= , ; -// / << = . -// % >> ! -// &^ -// -// Operators consisting of more than one character are referred to by names in -// the rest of the documentation -// -// andand = "&&" . -// andnot = "&^" . -// lsh = "<<" . -// le = "<=" . -// eq = "==" . -// ge = ">=" . -// neq = "!=" . -// oror = "||" . -// rsh = ">>" . -// -// Integer literals -// -// An integer literal is a sequence of digits representing an integer constant. -// An optional prefix sets a non-decimal base: 0 for octal, 0x or 0X for -// hexadecimal. In hexadecimal literals, letters a-f and A-F represent values -// 10 through 15. -// -// int_lit = decimal_lit | octal_lit | hex_lit . -// decimal_lit = ( "1" … "9" ) { decimal_digit } . -// octal_lit = "0" { octal_digit } . -// hex_lit = "0" ( "x" | "X" ) hex_digit { hex_digit } . -// -// For example -// -// 42 -// 0600 -// 0xBadFace -// 1701411834604692 -// -// Floating-point literals -// -// A floating-point literal is a decimal representation of a floating-point -// constant. It has an integer part, a decimal point, a fractional part, and an -// exponent part. The integer and fractional part comprise decimal digits; the -// exponent part is an e or E followed by an optionally signed decimal -// exponent. One of the integer part or the fractional part may be elided; one -// of the decimal point or the exponent may be elided. -// -// float_lit = decimals "." [ decimals ] [ exponent ] | -// decimals exponent | -// "." decimals [ exponent ] . -// decimals = decimal_digit { decimal_digit } . -// exponent = ( "e" | "E" ) [ "+" | "-" ] decimals . -// -// For example -// -// 0. -// 72.40 -// 072.40 // == 72.40 -// 2.71828 -// 1.e+0 -// 6.67428e-11 -// 1E6 -// .25 -// .12345E+5 -// -// Imaginary literals -// -// An imaginary literal is a decimal representation of the imaginary part of a -// complex constant. It consists of a floating-point literal or decimal integer -// followed by the lower-case letter i. -// -// imaginary_lit = (decimals | float_lit) "i" . -// -// For example -// -// 0i -// 011i // == 11i -// 0.i -// 2.71828i -// 1.e+0i -// 6.67428e-11i -// 1E6i -// .25i -// .12345E+5i -// -// Rune literals -// -// A rune literal represents a rune constant, an integer value identifying a -// Unicode code point. A rune literal is expressed as one or more characters -// enclosed in single quotes. Within the quotes, any character may appear -// except single quote and newline. A single quoted character represents the -// Unicode value of the character itself, while multi-character sequences -// beginning with a backslash encode values in various formats. -// -// The simplest form represents the single character within the quotes; since -// QL statements are Unicode characters encoded in UTF-8, multiple -// UTF-8-encoded bytes may represent a single integer value. For instance, the -// literal 'a' holds a single byte representing a literal a, Unicode U+0061, -// value 0x61, while 'ä' holds two bytes (0xc3 0xa4) representing a literal -// a-dieresis, U+00E4, value 0xe4. -// -// Several backslash escapes allow arbitrary values to be encoded as ASCII -// text. There are four ways to represent the integer value as a numeric -// constant: \x followed by exactly two hexadecimal digits; \u followed by -// exactly four hexadecimal digits; \U followed by exactly eight hexadecimal -// digits, and a plain backslash \ followed by exactly three octal digits. In -// each case the value of the literal is the value represented by the digits in -// the corresponding base. -// -// Although these representations all result in an integer, they have different -// valid ranges. Octal escapes must represent a value between 0 and 255 -// inclusive. Hexadecimal escapes satisfy this condition by construction. The -// escapes \u and \U represent Unicode code points so within them some values -// are illegal, in particular those above 0x10FFFF and surrogate halves. -// -// After a backslash, certain single-character escapes represent special -// values -// -// \a U+0007 alert or bell -// \b U+0008 backspace -// \f U+000C form feed -// \n U+000A line feed or newline -// \r U+000D carriage return -// \t U+0009 horizontal tab -// \v U+000b vertical tab -// \\ U+005c backslash -// \' U+0027 single quote (valid escape only within rune literals) -// \" U+0022 double quote (valid escape only within string literals) -// -// All other sequences starting with a backslash are illegal inside rune -// literals. -// -// rune_lit = "'" ( unicode_value | byte_value ) "'" . -// unicode_value = unicode_char | little_u_value | big_u_value | escaped_char . -// byte_value = octal_byte_value | hex_byte_value . -// octal_byte_value = `\` octal_digit octal_digit octal_digit . -// hex_byte_value = `\` "x" hex_digit hex_digit . -// little_u_value = `\` "u" hex_digit hex_digit hex_digit hex_digit . -// big_u_value = `\` "U" hex_digit hex_digit hex_digit hex_digit -// hex_digit hex_digit hex_digit hex_digit . -// escaped_char = `\` ( "a" | "b" | "f" | "n" | "r" | "t" | "v" | `\` | "'" | `"` ) . -// -// For example -// -// 'a' -// 'ä' -// '本' -// '\t' -// '\000' -// '\007' -// '\377' -// '\x07' -// '\xff' -// '\u12e4' -// '\U00101234' -// 'aa' // illegal: too many characters -// '\xa' // illegal: too few hexadecimal digits -// '\0' // illegal: too few octal digits -// '\uDFFF' // illegal: surrogate half -// '\U00110000' // illegal: invalid Unicode code point -// -// String literals -// -// A string literal represents a string constant obtained from concatenating a -// sequence of characters. There are two forms: raw string literals and -// interpreted string literals. -// -// Raw string literals are character sequences between back quotes ``. Within -// the quotes, any character is legal except back quote. The value of a raw -// string literal is the string composed of the uninterpreted (implicitly -// UTF-8-encoded) characters between the quotes; in particular, backslashes -// have no special meaning and the string may contain newlines. Carriage -// returns inside raw string literals are discarded from the raw string value. -// -// Interpreted string literals are character sequences between double quotes -// "". The text between the quotes, which may not contain newlines, forms the -// value of the literal, with backslash escapes interpreted as they are in rune -// literals (except that \' is illegal and \" is legal), with the same -// restrictions. The three-digit octal (\nnn) and two-digit hexadecimal (\xnn) -// escapes represent individual bytes of the resulting string; all other -// escapes represent the (possibly multi-byte) UTF-8 encoding of individual -// characters. Thus inside a string literal \377 and \xFF represent a single -// byte of value 0xFF=255, while ÿ, \u00FF, \U000000FF and \xc3\xbf represent -// the two bytes 0xc3 0xbf of the UTF-8 encoding of character U+00FF. -// -// string_lit = raw_string_lit | interpreted_string_lit . -// raw_string_lit = "`" { unicode_char | newline } "`" . -// interpreted_string_lit = `"` { unicode_value | byte_value } `"` . -// -// For example -// -// `abc` // same as "abc" -// `\n -// \n` // same as "\\n\n\\n" -// "\n" -// "" -// "Hello, world!\n" -// "日本語" -// "\u65e5本\U00008a9e" -// "\xff\u00FF" -// "\uD800" // illegal: surrogate half -// "\U00110000" // illegal: invalid Unicode code point -// -// These examples all represent the same string -// -// "日本語" // UTF-8 input text -// `日本語` // UTF-8 input text as a raw literal -// "\u65e5\u672c\u8a9e" // the explicit Unicode code points -// "\U000065e5\U0000672c\U00008a9e" // the explicit Unicode code points -// "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e" // the explicit UTF-8 bytes -// -// If the statement source represents a character as two code points, such as a -// combining form involving an accent and a letter, the result will be an error -// if placed in a rune literal (it is not a single code point), and will appear -// as two code points if placed in a string literal. -// -// QL parameters -// -// Literals are assigned their values from the respective text representation -// at "compile" (parse) time. QL parameters provide the same functionality as -// literals, but their value is assigned at execution time from an expression -// list passed to DB.Run or DB.Execute. Using '?' or '$' is completely -// equivalent. -// -// ql_parameter = ( "?" | "$" ) "1" … "9" { "0" … "9" } . -// -// For example -// -// SELECT DepartmentID -// FROM department -// WHERE DepartmentID == ?1 -// ORDER BY DepartmentName; -// -// SELECT employee.LastName -// FROM department, employee -// WHERE department.DepartmentID == $1 && employee.LastName > $2 -// ORDER BY DepartmentID; -// -// Constants -// -// Keywords 'false' and 'true' (not case sensitive) represent the two possible -// constant values of type bool (also not case sensitive). -// -// Keyword 'NULL' (not case sensitive) represents an untyped constant which is -// assignable to any type. NULL is distinct from any other value of any type. -// -// Types -// -// A type determines the set of values and operations specific to values of -// that type. A type is specified by a type name. -// -// Type = "bigint" // http://golang.org/pkg/math/big/#Int -// | "bigrat" // http://golang.org/pkg/math/big/#Rat -// | "blob" // []byte -// | "bool" -// | "byte" // alias for uint8 -// | "complex128" -// | "complex64" -// | "duration" // http://golang.org/pkg/time/#Duration -// | "float" // alias for float64 -// | "float32" -// | "float64" -// | "int" // alias for int64 -// | "int16" -// | "int32" -// | "int64" -// | "int8" -// | "rune" // alias for int32 -// | "string" -// | "time" // http://golang.org/pkg/time/#Time -// | "uint" // alias for uint64 -// | "uint16" -// | "uint32" -// | "uint64" -// | "uint8" . -// -// Named instances of the boolean, numeric, and string types are keywords. The -// names are not case sensitive. -// -// Note: The blob type is exchanged between the back end and the API as []byte. -// On 32 bit platforms this limits the size which the implementation can handle -// to 2G. -// -// Boolean types -// -// A boolean type represents the set of Boolean truth values denoted by the -// predeclared constants true and false. The predeclared boolean type is bool. -// -// Duration type -// -// A duration type represents the elapsed time between two instants as an int64 -// nanosecond count. The representation limits the largest representable -// duration to approximately 290 years. -// -// Numeric types -// -// A numeric type represents sets of integer or floating-point values. The -// predeclared architecture-independent numeric types are -// -// uint8 the set of all unsigned 8-bit integers (0 to 255) -// uint16 the set of all unsigned 16-bit integers (0 to 65535) -// uint32 the set of all unsigned 32-bit integers (0 to 4294967295) -// uint64 the set of all unsigned 64-bit integers (0 to 18446744073709551615) -// -// int8 the set of all signed 8-bit integers (-128 to 127) -// int16 the set of all signed 16-bit integers (-32768 to 32767) -// int32 the set of all signed 32-bit integers (-2147483648 to 2147483647) -// int64 the set of all signed 64-bit integers (-9223372036854775808 to 9223372036854775807) -// duration the set of all signed 64-bit integers (-9223372036854775808 to 9223372036854775807) -// bigint the set of all integers -// -// bigrat the set of all rational numbers -// -// float32 the set of all IEEE-754 32-bit floating-point numbers -// float64 the set of all IEEE-754 64-bit floating-point numbers -// -// complex64 the set of all complex numbers with float32 real and imaginary parts -// complex128 the set of all complex numbers with float64 real and imaginary parts -// -// byte alias for uint8 -// float alias for float64 -// int alias for int64 -// rune alias for int32 -// uint alias for uint64 -// -// The value of an n-bit integer is n bits wide and represented using two's -// complement arithmetic. -// -// Conversions are required when different numeric types are mixed in an -// expression or assignment. -// -// String types -// -// A string type represents the set of string values. A string value is a -// (possibly empty) sequence of bytes. The case insensitive keyword for the -// string type is 'string'. -// -// The length of a string (its size in bytes) can be discovered using the -// built-in function len. -// -// Time types -// -// A time type represents an instant in time with nanosecond precision. Each -// time has associated with it a location, consulted when computing the -// presentation form of the time. -// -// Predeclared functions -// -// The following functions are implicitly declared -// -// avg complex contains count date -// day formatTime formatFloat formatInt -// hasPrefix hasSuffix hour hours id -// imag len max min minute -// minutes month nanosecond nanoseconds now -// parseTime real second seconds since -// sum timeIn weekday year yearDay -// -// Expressions -// -// An expression specifies the computation of a value by applying operators and -// functions to operands. -// -// Operands -// -// Operands denote the elementary values in an expression. An operand may be a -// literal, a (possibly qualified) identifier denoting a constant or a function -// or a table/record set column, or a parenthesized expression. -// -// Operand = Literal | QualifiedIdent | "(" Expression ")" . -// Literal = "FALSE" | "NULL" | "TRUE" -// | float_lit | imaginary_lit | int_lit | rune_lit | string_lit -// | ql_parameter . -// -// Qualified identifiers -// -// A qualified identifier is an identifier qualified with a table/record set -// name prefix. -// -// QualifiedIdent = identifier [ "." identifier ] . -// -// For example -// -// invoice.Num // might denote column 'Num' from table 'invoice' -// -// Primary expressions -// -// Primary expression are the operands for unary and binary expressions. -// -// PrimaryExpression = Operand -// | Conversion -// | PrimaryExpression Index -// | PrimaryExpression Slice -// | PrimaryExpression Call . -// -// Call = "(" [ "*" | ExpressionList ] ")" . // * only in count(*). -// Index = "[" Expression "]" . -// Slice = "[" [ Expression ] ":" [ Expression ] "]" . -// -// For example -// -// x -// 2 -// (s + ".txt") -// f(3.1415, true) -// s[i : j + 1] -// -// Index expressions -// -// A primary expression of the form -// -// s[x] -// -// denotes the element of a string indexed by x. Its type is byte. The value x -// is called the index. The following rules apply -// -// - The index x must be of integer type except bigint or duration; it is in -// range if 0 <= x < len(s), otherwise it is out of range. -// -// - A constant index must be non-negative and representable by a value of type -// int. -// -// - A constant index must be in range if the string a is a literal. -// -// - If x is out of range at run time, a run-time error occurs. -// -// - s[x] is the byte at index x and the type of s[x] is byte. -// -// If s is NULL or x is NULL then the result is NULL. -// -// Otherwise s[x] is illegal. -// -// Slices -// -// For a string, the primary expression -// -// s[low : high] -// -// constructs a substring. The indices low and high select which elements -// appear in the result. The result has indices starting at 0 and length equal -// to high - low. -// -// For convenience, any of the indices may be omitted. A missing low index -// defaults to zero; a missing high index defaults to the length of the sliced -// operand -// -// s[2:] // same s[2 : len(s)] -// s[:3] // same as s[0 : 3] -// s[:] // same as s[0 : len(s)] -// -// The indices low and high are in range if 0 <= low <= high <= len(a), -// otherwise they are out of range. A constant index must be non-negative and -// representable by a value of type int. If both indices are constant, they -// must satisfy low <= high. If the indices are out of range at run time, a -// run-time error occurs. -// -// Integer values of type bigint or duration cannot be used as indices. -// -// If s is NULL the result is NULL. If low or high is not omitted and is NULL -// then the result is NULL. -// -// Calls -// -// Given an identifier f denoting a predeclared function, -// -// f(a1, a2, … an) -// -// calls f with arguments a1, a2, … an. Arguments are evaluated before the -// function is called. The type of the expression is the result type of f. -// -// complex(x, y) -// len(name) -// -// In a function call, the function value and arguments are evaluated in the -// usual order. After they are evaluated, the parameters of the call are passed -// by value to the function and the called function begins execution. The -// return value of the function is passed by value when the function returns. -// -// Calling an undefined function causes a compile-time error. -// -// Operators -// -// Operators combine operands into expressions. -// -// Expression = Term { ( oror | "OR" ) Term } . -// -// ExpressionList = Expression { "," Expression } [ "," ]. -// Factor = PrimaryFactor { ( ge | ">" | le | "<" | neq | eq | "LIKE" ) PrimaryFactor } [ Predicate ] . -// PrimaryFactor = PrimaryTerm { ( "^" | "|" | "-" | "+" ) PrimaryTerm } . -// PrimaryTerm = UnaryExpr { ( andnot | "&" | lsh | rsh | "%" | "/" | "*" ) UnaryExpr } . -// Term = Factor { ( andand | "AND" ) Factor } . -// UnaryExpr = [ "^" | "!" | "-" | "+" ] PrimaryExpression . -// -// Comparisons are discussed elsewhere. For other binary operators, the operand -// types must be identical unless the operation involves shifts or untyped -// constants. For operations involving constants only, see the section on -// constant expressions. -// -// Except for shift operations, if one operand is an untyped constant and the -// other operand is not, the constant is converted to the type of the other -// operand. -// -// The right operand in a shift expression must have unsigned integer type or -// be an untyped constant that can be converted to unsigned integer type. If -// the left operand of a non-constant shift expression is an untyped constant, -// the type of the constant is what it would be if the shift expression were -// replaced by its left operand alone. -// -// Pattern matching -// -// Expressions of the form -// -// expr1 LIKE expr2 -// -// yeild a boolean value true if expr2, a regular expression, matches expr1 -// (see also [6]). Both expression must be of type string. If any one of the -// expressions is NULL the result is NULL. -// -// Predicates -// -// Predicates are special form expressions having a boolean result type. -// -// Expressions of the form -// -// expr IN ( expr1, expr2, expr3, ... ) // case A -// -// expr NOT IN ( expr1, expr2, expr3, ... ) // case B -// -// are equivalent, including NULL handling, to -// -// expr == expr1 || expr == expr2 || expr == expr3 || ... // case A -// -// expr != expr1 && expr != expr2 && expr != expr3 && ... // case B -// -// The types of involved expressions must be comparable as defined in -// "Comparison operators". -// -// Another form of the IN predicate creates the expression list from a result -// of a SelectStmt. -// -// DELETE FROM t WHERE id() IN (SELECT id_t FROM u WHERE inactive_days > 365) -// -// The SelectStmt must select only one column. The produced expression list is -// resource limited by the memory available to the process. NULL values -// produced by the SelectStmt are ignored, but if all records of the SelectStmt -// are NULL the predicate yields NULL. The select statement is evaluated only -// once. If the type of expr is not the same as the type of the field returned -// by the SelectStmt then the set operation yields false. The type of the -// column returned by the SelectStmt must be one of the simple (non blob-like) -// types: -// -// bool -// byte // alias uint8 -// complex128 -// complex64 -// float // alias float64 -// float32 -// float64 -// int // alias int64 -// int16 -// int32 -// int64 -// int8 -// rune // alias int32 -// string -// uint // alias uint64 -// uint16 -// uint32 -// uint64 -// uint8 -// -// Expressions of the form -// -// expr BETWEEN low AND high // case A -// -// expr NOT BETWEEN low AND high // case B -// -// are equivalent, including NULL handling, to -// -// expr >= low && expr <= high // case A -// -// expr < low || expr > high // case B -// -// The types of involved expressions must be ordered as defined in "Comparison -// operators". -// -// Predicate = ( -// [ "NOT" ] ( -// "IN" "(" ExpressionList ")" -// | "IN" "(" SelectStmt [ ";" ] ")" -// | "BETWEEN" PrimaryFactor "AND" PrimaryFactor -// ) -// | "IS" [ "NOT" ] "NULL" -// ). -// -// Expressions of the form -// -// expr IS NULL // case A -// -// expr IS NOT NULL // case B -// -// yeild a boolean value true if expr does not have a specific type (case A) or -// if expr has a specific type (case B). In other cases the result is a boolean -// value false. -// -// Operator precedence -// -// Unary operators have the highest precedence. -// -// There are five precedence levels for binary operators. Multiplication -// operators bind strongest, followed by addition operators, comparison -// operators, && (logical AND), and finally || (logical OR) -// -// Precedence Operator -// 5 * / % << >> & &^ -// 4 + - | ^ -// 3 == != < <= > >= -// 2 && -// 1 || -// -// Binary operators of the same precedence associate from left to right. For -// instance, x / y * z is the same as (x / y) * z. -// -// +x -// 23 + 3*x[i] -// x <= f() -// ^a >> b -// f() || g() -// x == y+1 && z > 0 -// -// Note that the operator precedence is reflected explicitly by the grammar. -// -// Arithmetic operators -// -// Arithmetic operators apply to numeric values and yield a result of the same -// type as the first operand. The four standard arithmetic operators (+, -, *, -// /) apply to integer, rational, floating-point, and complex types; + also -// applies to strings; +,- also applies to times. All other arithmetic -// operators apply to integers only. -// -// + sum integers, rationals, floats, complex values, strings -// - difference integers, rationals, floats, complex values, times -// * product integers, rationals, floats, complex values -// / quotient integers, rationals, floats, complex values -// % remainder integers -// -// & bitwise AND integers -// | bitwise OR integers -// ^ bitwise XOR integers -// &^ bit clear (AND NOT) integers -// -// << left shift integer << unsigned integer -// >> right shift integer >> unsigned integer -// -// Strings can be concatenated using the + operator -// -// "hi" + string(c) + " and good bye" -// -// String addition creates a new string by concatenating the operands. -// -// A value of type duration can be added to or subtracted from a value of type time. -// -// now() + duration("1h") // time after 1 hour from now -// duration("1h") + now() // time after 1 hour from now -// now() - duration("1h") // time before 1 hour from now -// duration("1h") - now() // illegal, negative times do not exist -// -// Times can subtracted from each other producing a value of type duration. -// -// now() - t0 // elapsed time since t0 -// now() + now() // illegal, operator + not defined for times -// -// For two integer values x and y, the integer quotient q = x / y and remainder -// r = x % y satisfy the following relationships -// -// x = q*y + r and |r| < |y| -// -// with x / y truncated towards zero ("truncated division"). -// -// x y x / y x % y -// 5 3 1 2 -// -5 3 -1 -2 -// 5 -3 -1 2 -// -5 -3 1 -2 -// -// As an exception to this rule, if the dividend x is the most negative value -// for the int type of x, the quotient q = x / -1 is equal to x (and r = 0). -// -// x, q -// int8 -128 -// int16 -32768 -// int32 -2147483648 -// int64 -9223372036854775808 -// -// If the divisor is a constant expression, it must not be zero. If the divisor -// is zero at run time, a run-time error occurs. If the dividend is -// non-negative and the divisor is a constant power of 2, the division may be -// replaced by a right shift, and computing the remainder may be replaced by a -// bitwise AND operation -// -// x x / 4 x % 4 x >> 2 x & 3 -// 11 2 3 2 3 -// -11 -2 -3 -3 1 -// -// The shift operators shift the left operand by the shift count specified by -// the right operand. They implement arithmetic shifts if the left operand is a -// signed integer and logical shifts if it is an unsigned integer. There is no -// upper limit on the shift count. Shifts behave as if the left operand is -// shifted n times by 1 for a shift count of n. As a result, x << 1 is the same -// as x*2 and x >> 1 is the same as x/2 but truncated towards negative -// infinity. -// -// For integer operands, the unary operators +, -, and ^ are defined as follows -// -// +x is 0 + x -// -x negation is 0 - x -// ^x bitwise complement is m ^ x with m = "all bits set to 1" for unsigned x -// and m = -1 for signed x -// -// For floating-point and complex numbers, +x is the same as x, while -x is the -// negation of x. The result of a floating-point or complex division by zero is -// not specified beyond the IEEE-754 standard; whether a run-time error occurs -// is implementation-specific. -// -// Whenever any operand of any arithmetic operation, unary or binary, is NULL, -// as well as in the case of the string concatenating operation, the result is -// NULL. -// -// 42*NULL // the result is NULL -// NULL/x // the result is NULL -// "foo"+NULL // the result is NULL -// -// Integer overflow -// -// For unsigned integer values, the operations +, -, *, and << are computed -// modulo 2n, where n is the bit width of the unsigned integer's type. Loosely -// speaking, these unsigned integer operations discard high bits upon overflow, -// and expressions may rely on ``wrap around''. -// -// For signed integers with a finite bit width, the operations +, -, *, and << -// may legally overflow and the resulting value exists and is deterministically -// defined by the signed integer representation, the operation, and its -// operands. No exception is raised as a result of overflow. An evaluator may -// not optimize an expression under the assumption that overflow does not -// occur. For instance, it may not assume that x < x + 1 is always true. -// -// Integers of type bigint and rationals do not overflow but their handling is -// limited by the memory resources available to the program. -// -// Comparison operators -// -// Comparison operators compare two operands and yield a boolean value. -// -// == equal -// != not equal -// < less -// <= less or equal -// > greater -// >= greater or equal -// -// In any comparison, the first operand must be of same type as is the second -// operand, or vice versa. -// -// The equality operators == and != apply to operands that are comparable. The -// ordering operators <, <=, >, and >= apply to operands that are ordered. -// These terms and the result of the comparisons are defined as follows -// -// - Boolean values are comparable. Two boolean values are equal if they are -// either both true or both false. -// -// - Complex values are comparable. Two complex values u and v are equal if -// both real(u) == real(v) and imag(u) == imag(v). -// -// - Integer values are comparable and ordered, in the usual way. Note that -// durations are integers. -// -// - Floating point values are comparable and ordered, as defined by the -// IEEE-754 standard. -// -// - Rational values are comparable and ordered, in the usual way. -// -// - String values are comparable and ordered, lexically byte-wise. -// -// - Time values are comparable and ordered. -// -// Whenever any operand of any comparison operation is NULL, the result is -// NULL. -// -// Note that slices are always of type string. -// -// Logical operators -// -// Logical operators apply to boolean values and yield a boolean result. The -// right operand is evaluated conditionally. -// -// && conditional AND p && q is "if p then q else false" -// || conditional OR p || q is "if p then true else q" -// ! NOT !p is "not p" -// -// The truth tables for logical operations with NULL values -// -// +-------+-------+---------+---------+ -// | p | q | p || q | p && q | -// +-------+-------+---------+---------+ -// | true | true | *true | true | -// | true | false | *true | false | -// | true | NULL | *true | NULL | -// | false | true | true | *false | -// | false | false | false | *false | -// | false | NULL | NULL | *false | -// | NULL | true | true | NULL | -// | NULL | false | NULL | false | -// | NULL | NULL | NULL | NULL | -// +-------+-------+---------+---------+ -// * indicates q is not evaluated. -// -// +-------+-------+ -// | p | !p | -// +-------+-------+ -// | true | false | -// | false | true | -// | NULL | NULL | -// +-------+-------+ -// -// Conversions -// -// Conversions are expressions of the form T(x) where T is a type and x is an -// expression that can be converted to type T. -// -// Conversion = Type "(" Expression ")" . -// -// A constant value x can be converted to type T in any of these cases: -// -// - x is representable by a value of type T. -// -// - x is a floating-point constant, T is a floating-point type, and x is -// representable by a value of type T after rounding using IEEE 754 -// round-to-even rules. The constant T(x) is the rounded value. -// -// - x is an integer constant and T is a string type. The same rule as for -// non-constant x applies in this case. -// -// Converting a constant yields a typed constant as result. -// -// float32(2.718281828) // 2.718281828 of type float32 -// complex128(1) // 1.0 + 0.0i of type complex128 -// float32(0.49999999) // 0.5 of type float32 -// string('x') // "x" of type string -// string(0x266c) // "♬" of type string -// "foo" + "bar" // "foobar" -// int(1.2) // illegal: 1.2 cannot be represented as an int -// string(65.0) // illegal: 65.0 is not an integer constant -// -// A non-constant value x can be converted to type T in any of these cases: -// -// - x has type T. -// -// - x's type and T are both integer or floating point types. -// -// - x's type and T are both complex types. -// -// - x is an integer, except bigint or duration, and T is a string type. -// -// Specific rules apply to (non-constant) conversions between numeric types or -// to and from a string type. These conversions may change the representation -// of x and incur a run-time cost. All other conversions only change the type -// but not the representation of x. -// -// A conversion of NULL to any type yields NULL. -// -// Conversions between numeric types -// -// For the conversion of non-constant numeric values, the following rules -// apply -// -// 1. When converting between integer types, if the value is a signed integer, -// it is sign extended to implicit infinite precision; otherwise it is zero -// extended. It is then truncated to fit in the result type's size. For -// example, if v == uint16(0x10F0), then uint32(int8(v)) == 0xFFFFFFF0. The -// conversion always yields a valid value; there is no indication of overflow. -// -// 2. When converting a floating-point number to an integer, the fraction is -// discarded (truncation towards zero). -// -// 3. When converting an integer or floating-point number to a floating-point -// type, or a complex number to another complex type, the result value is -// rounded to the precision specified by the destination type. For instance, -// the value of a variable x of type float32 may be stored using additional -// precision beyond that of an IEEE-754 32-bit number, but float32(x) -// represents the result of rounding x's value to 32-bit precision. Similarly, -// x + 0.1 may use more than 32 bits of precision, but float32(x + 0.1) does -// not. -// -// In all non-constant conversions involving floating-point or complex values, -// if the result type cannot represent the value the conversion succeeds but -// the result value is implementation-dependent. -// -// Conversions to and from a string type -// -// 1. Converting a signed or unsigned integer value to a string type yields a -// string containing the UTF-8 representation of the integer. Values outside -// the range of valid Unicode code points are converted to "\uFFFD". -// -// string('a') // "a" -// string(-1) // "\ufffd" == "\xef\xbf\xbd" -// string(0xf8) // "\u00f8" == "ø" == "\xc3\xb8" -// string(0x65e5) // "\u65e5" == "日" == "\xe6\x97\xa5" -// -// 2. Converting a blob to a string type yields a string whose successive bytes -// are the elements of the blob. -// -// string(b /* []byte{'h', 'e', 'l', 'l', '\xc3', '\xb8'} */) // "hellø" -// string(b /* []byte{} */) // "" -// string(b /* []byte(nil) */) // "" -// -// 3. Converting a value of a string type to a blob yields a blob whose -// successive elements are the bytes of the string. -// -// blob("hellø") // []byte{'h', 'e', 'l', 'l', '\xc3', '\xb8'} -// blob("") // []byte{} -// -// 4. Converting a value of a bigint type to a string yields a string -// containing the decimal decimal representation of the integer. -// -// string(M9) // "2305843009213693951" -// -// 5. Converting a value of a string type to a bigint yields a bigint value -// containing the integer represented by the string value. A prefix of “0x” or -// “0X” selects base 16; the “0” prefix selects base 8, and a “0b” or “0B” -// prefix selects base 2. Otherwise the value is interpreted in base 10. An -// error occurs if the string value is not in any valid format. -// -// bigint("2305843009213693951") // M9 -// bigint("0x1ffffffffffffffffffffff") // M10 == 2^89-1 -// -// 6. Converting a value of a rational type to a string yields a string -// containing the decimal decimal representation of the rational in the form -// "a/b" (even if b == 1). -// -// string(bigrat(355)/bigrat(113)) // "355/113" -// -// 7. Converting a value of a string type to a bigrat yields a bigrat value -// containing the rational represented by the string value. The string can be -// given as a fraction "a/b" or as a floating-point number optionally followed -// by an exponent. An error occurs if the string value is not in any valid -// format. -// -// bigrat("1.2e-34") -// bigrat("355/113") -// -// 8. Converting a value of a duration type to a string returns a string -// representing the duration in the form "72h3m0.5s". Leading zero units are -// omitted. As a special case, durations less than one second format using a -// smaller unit (milli-, micro-, or nanoseconds) to ensure that the leading -// digit is non-zero. The zero duration formats as 0, with no unit. -// -// string(elapsed) // "1h", for example -// -// 9. Converting a string value to a duration yields a duration represented by -// the string. A duration string is a possibly signed sequence of decimal -// numbers, each with optional fraction and a unit suffix, such as "300ms", -// "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", -// "m", "h". -// -// duration("1m") // http://golang.org/pkg/time/#Minute -// -// 10. Converting a time value to a string returns the time formatted using the -// format string -// -// "2006-01-02 15:04:05.999999999 -0700 MST" -// -// Order of evaluation -// -// When evaluating the operands of an expression or of function calls, -// operations are evaluated in lexical left-to-right order. -// -// For example, in the evaluation of -// -// g(h(), i()+x[j()], c) -// -// the function calls and evaluation of c happen in the order h(), i(), j(), c. -// -// Floating-point operations within a single expression are evaluated according -// to the associativity of the operators. Explicit parentheses affect the -// evaluation by overriding the default associativity. In the expression x + (y -// + z) the addition y + z is performed before adding x. -// -// Statements -// -// Statements control execution. -// -// Statement = EmptyStmt | AlterTableStmt | BeginTransactionStmt | CommitStmt -// | CreateIndexStmt | CreateTableStmt | DeleteFromStmt | DropIndexStmt -// | DropTableStmt | InsertIntoStmt | RollbackStmt | SelectStmt -// | TruncateTableStmt | UpdateStmt | ExplainStmt. -// -// StatementList = Statement { ";" Statement } . -// -// Empty statements -// -// The empty statement does nothing. -// -// EmptyStmt = . -// -// ALTER TABLE -// -// Alter table statements modify existing tables. With the ADD clause it adds -// a new column to the table. The column must not exist. With the DROP clause -// it removes an existing column from a table. The column must exist and it -// must be not the only (last) column of the table. IOW, there cannot be a -// table with no columns. -// -// AlterTableStmt = "ALTER" "TABLE" TableName ( "ADD" ColumnDef | "DROP" "COLUMN" ColumnName ) . -// -// For example -// -// BEGIN TRANSACTION; -// ALTER TABLE Stock ADD Qty int; -// ALTER TABLE Income DROP COLUMN Taxes; -// COMMIT; -// -// When adding a column to a table with existing data, the constraint clause of -// the ColumnDef cannot be used. Adding a constrained column to an empty table -// is fine. -// -// BEGIN TRANSACTION -// -// Begin transactions statements introduce a new transaction level. Every -// transaction level must be eventually balanced by exactly one of COMMIT or -// ROLLBACK statements. Note that when a transaction is roll-backed because of -// a statement failure then no explicit balancing of the respective BEGIN -// TRANSACTION is statement is required nor permitted. -// -// Failure to properly balance any opened transaction level may cause dead -// locks and/or lose of data updated in the uppermost opened but never properly -// closed transaction level. -// -// BeginTransactionStmt = "BEGIN" "TRANSACTION" . -// -// For example -// -// BEGIN TRANSACTION; -// INSERT INTO foo VALUES (42, 3.14); -// INSERT INTO foo VALUES (-1, 2.78); -// COMMIT; -// -// Mandatory transactions -// -// A database cannot be updated (mutated) outside of a transaction. Statements -// requiring a transaction -// -// ALTER TABLE -// COMMIT -// CREATE INDEX -// CREATE TABLE -// DELETE FROM -// DROP INDEX -// DROP TABLE -// INSERT INTO -// ROLLBACK -// TRUNCATE TABLE -// UPDATE -// -// A database is effectively read only outside of a transaction. Statements not -// requiring a transaction -// -// BEGIN TRANSACTION -// SELECT FROM -// -// COMMIT -// -// The commit statement closes the innermost transaction nesting level. If -// that's the outermost level then the updates to the DB made by the -// transaction are atomically made persistent. -// -// CommitStmt = "COMMIT" . -// -// For example -// -// BEGIN TRANSACTION; -// INSERT INTO AccountA (Amount) VALUES ($1); -// INSERT INTO AccountB (Amount) VALUES (-$1); -// COMMIT; -// -// CREATE INDEX -// -// Create index statements create new indices. Index is a named projection of -// ordered values of a table column to the respective records. As a special -// case the id() of the record can be indexed. Index name must not be the same -// as any of the existing tables and it also cannot be the same as of any -// column name of the table the index is on. -// -// CreateIndexStmt = "CREATE" [ "UNIQUE" ] "INDEX" [ "IF" "NOT" "EXISTS" ] -// IndexName "ON" TableName "(" ExpressionList ")" . -// -// For example -// -// BEGIN TRANSACTION; -// CREATE TABLE Orders (CustomerID int, Date time); -// CREATE INDEX OrdersID ON Orders (id()); -// CREATE INDEX OrdersDate ON Orders (Date); -// CREATE TABLE Items (OrderID int, ProductID int, Qty int); -// CREATE INDEX ItemsOrderID ON Items (OrderID); -// COMMIT; -// -// Now certain SELECT statements may use the indices to speed up joins and/or -// to speed up record set filtering when the WHERE clause is used; or the -// indices might be used to improve the performance when the ORDER BY clause is -// present. -// -// The UNIQUE modifier requires the indexed values tuple to be index-wise -// unique or have all values NULL. -// -// The optional IF NOT EXISTS clause makes the statement a no operation if the -// index already exists. -// -// Simple index -// -// A simple index consists of only one expression which must be either a column -// name or the built-in id(). -// -// Expression list index -// -// A more complex and more general index is one that consists of more than one -// expression or its single expression does not qualify as a simple index. In -// this case the type of all expressions in the list must be one of the non -// blob-like types. -// -// Note: Blob-like types are blob, bigint, bigrat, time and duration. -// -// CREATE TABLE -// -// Create table statements create new tables. A column definition declares the -// column name and type. Table names and column names are case sensitive. -// Neither a table or an index of the same name may exist in the DB. -// -// CreateTableStmt = "CREATE" "TABLE" [ "IF" "NOT" "EXISTS" ] TableName -// "(" ColumnDef { "," ColumnDef } [ "," ] ")" . -// -// ColumnDef = ColumnName Type [ "NOT" "NULL" | Expression ] [ "DEFAULT" Expression ] . -// ColumnName = identifier . -// TableName = identifier . -// -// For example -// -// BEGIN TRANSACTION; -// CREATE TABLE department ( -// DepartmentID int, -// DepartmentName string, -// ); -// CREATE TABLE employee ( -// LastName string, -// DepartmentID int, -// ); -// COMMIT; -// -// The optional IF NOT EXISTS clause makes the statement a no operation if the -// table already exists. -// -// The optional constraint clause has two forms. The first one is found in many -// SQL dialects. -// -// BEGIN TRANSACTION; -// CREATE TABLE department ( -// DepartmentID int, -// DepartmentName string NOT NULL, -// ); -// COMMIT; -// -// This form prevents the data in column DepartmentName to be NULL. -// -// The second form allows an arbitrary boolean expression to be used to -// validate the column. If the value of the expression is true then the -// validation succeeded. If the value of the expression is false or NULL then -// the validation fails. If the value of the expression is not of type bool an -// error occurs. -// -// BEGIN TRANSACTION; -// CREATE TABLE department ( -// DepartmentID int, -// DepartmentName string DepartmentName IN ("HQ", "R/D", "Lab", "HR"), -// ); -// COMMIT; -// -// BEGIN TRANSACTION; -// CREATE TABLE t ( -// TimeStamp time TimeStamp < now() && since(TimeStamp) < duration("10s"), -// Event string Event != "" && Event like "[0-9]+:[ \t]+.*", -// ); -// COMMIT; -// -// The optional DEFAULT clause is an expression which, if present, is -// substituted instead of a NULL value when the colum is assigned a value. -// -// BEGIN TRANSACTION; -// CREATE TABLE department ( -// DepartmentID int, -// DepartmentName string DepartmentName IN ("HQ", "R/D", "Lab", "HR") DEFAULT "HQ", -// ); -// COMMIT; -// -// Note that the constraint and/or default expressions may refer to other -// columns by name: -// -// BEGIN TRANSACTION; -// CREATE TABLE t ( -// a int, -// b int b > a && b < c DEFAULT (a+c)/2, -// c int, -// ); -// COMMIT; -// -// -// Constraints and defaults -// -// When a table row is inserted by the INSERT INTO statement or when a table -// row is updated by the UPDATE statement, the order of operations is as -// follows: -// -// 1. The new values of the affected columns are set and the values of all the -// row columns become the named values which can be referred to in default -// expressions evaluated in step 2. -// -// 2. If any row column value is NULL and the DEFAULT clause is present in the -// column's definition, the default expression is evaluated and its value is -// set as the respective column value. -// -// 3. The values, potentially updated, of row columns become the named values -// which can be referred to in constraint expressions evaluated during step 4. -// -// 4. All row columns which definition has the constraint clause present will -// have that constraint checked. If any constraint violation is detected, the -// overall operation fails and no changes to the table are made. -// -// DELETE FROM -// -// Delete from statements remove rows from a table, which must exist. -// -// DeleteFromStmt = "DELETE" "FROM" TableName [ WhereClause ] . -// -// For example -// -// BEGIN TRANSACTION; -// DELETE FROM DepartmentID -// WHERE DepartmentName == "Ponies"; -// COMMIT; -// -// If the WHERE clause is not present then all rows are removed and the -// statement is equivalent to the TRUNCATE TABLE statement. -// -// DROP INDEX -// -// Drop index statements remove indices from the DB. The index must exist. -// -// DropIndexStmt = "DROP" "INDEX" [ "IF" "EXISTS" ] IndexName . -// IndexName = identifier . -// -// For example -// -// BEGIN TRANSACTION; -// DROP INDEX ItemsOrderID; -// COMMIT; -// -// The optional IF EXISTS clause makes the statement a no operation if the -// index does not exist. -// -// DROP TABLE -// -// Drop table statements remove tables from the DB. The table must exist. -// -// DropTableStmt = "DROP" "TABLE" [ "IF" "EXISTS" ] TableName . -// -// For example -// -// BEGIN TRANSACTION; -// DROP TABLE Inventory; -// COMMIT; -// -// The optional IF EXISTS clause makes the statement a no operation if the -// table does not exist. -// -// INSERT INTO -// -// Insert into statements insert new rows into tables. New rows come from -// literal data, if using the VALUES clause, or are a result of select -// statement. In the later case the select statement is fully evaluated before -// the insertion of any rows is performed, allowing to insert values calculated -// from the same table rows are to be inserted into. If the ColumnNameList part -// is omitted then the number of values inserted in the row must be the same as -// are columns in the table. If the ColumnNameList part is present then the -// number of values per row must be same as the same number of column names. -// All other columns of the record are set to NULL. The type of the value -// assigned to a column must be the same as is the column's type or the value -// must be NULL. -// -// InsertIntoStmt = "INSERT" "INTO" TableName [ "(" ColumnNameList ")" ] ( Values | SelectStmt ) . -// -// ColumnNameList = ColumnName { "," ColumnName } [ "," ] . -// Values = "VALUES" "(" ExpressionList ")" { "," "(" ExpressionList ")" } [ "," ] . -// -// For example -// -// BEGIN TRANSACTION; -// INSERT INTO department (DepartmentID) VALUES (42); -// -// INSERT INTO department ( -// DepartmentName, -// DepartmentID, -// ) -// VALUES ( -// "R&D", -// 42, -// ); -// -// INSERT INTO department VALUES -// (42, "R&D"), -// (17, "Sales"), -// ; -// COMMIT; -// -// BEGIN TRANSACTION; -// INSERT INTO department (DepartmentName, DepartmentID) -// SELECT DepartmentName+"/headquarters", DepartmentID+1000 -// FROM department; -// COMMIT; -// -// If any of the columns of the table were defined using the optional -// constraints clause or the optional defaults clause then those are processed -// on a per row basis. The details are discussed in the "Constraints and -// defaults" chapter below the CREATE TABLE statement documentation. -// -// Explain statement -// -// Explain statement produces a recordset consisting of lines of text which -// describe the execution plan of a statement, if any. -// -// ExplainStmt = "EXPLAIN" Statement . -// -// For example, the QL tool treats the explain statement specially and outputs -// the joined lines: -// -// $ ql 'create table t(i int); create table u(j int)' -// $ ql 'explain select * from t, u where t.i > 42 && u.j < 314' -// ┌Compute Cartesian product of -// │ ┌Iterate all rows of table "t" -// │ └Output field names ["i"] -// │ ┌Iterate all rows of table "u" -// │ └Output field names ["j"] -// └Output field names ["t.i" "u.j"] -// ┌Filter on t.i > 42 && u.j < 314 -// │Possibly useful indices -// │CREATE INDEX xt_i ON t(i); -// │CREATE INDEX xu_j ON u(j); -// └Output field names ["t.i" "u.j"] -// $ ql 'CREATE INDEX xt_i ON t(i); CREATE INDEX xu_j ON u(j);' -// $ ql 'explain select * from t, u where t.i > 42 && u.j < 314' -// ┌Compute Cartesian product of -// │ ┌Iterate all rows of table "t" using index "xt_i" where i > 42 -// │ └Output field names ["i"] -// │ ┌Iterate all rows of table "u" using index "xu_j" where j < 314 -// │ └Output field names ["j"] -// └Output field names ["t.i" "u.j"] -// $ ql 'explain select * from t where i > 12 and i between 10 and 20 and i < 42' -// ┌Iterate all rows of table "t" using index "xt_i" where i > 12 && i <= 20 -// └Output field names ["i"] -// $ -// -// The explanation may aid in uderstanding how a statement/query would be -// executed and if indices are used as expected - or which indices may possibly -// improve the statement performance. The create index statements above were -// directly copy/pasted in the terminal from the suggestions provided by the -// filter recordset pipeline part returned by the explain statement. -// -// If the statement has nothing special in its plan, the result is the original -// statement. -// -// $ ql 'explain delete from t where 42 < i' -// DELETE FROM t WHERE i > 42; -// $ -// -// To get an explanation of the select statement of the IN predicate, use the EXPLAIN -// statement with that particular select statement. -// -// $ ql 'explain select * from t where i in (select j from u where j > 0)' -// ┌Iterate all rows of table "t" -// └Output field names ["i"] -// ┌Filter on i IN (SELECT j FROM u WHERE j > 0;) -// └Output field names ["i"] -// $ ql 'explain select j from u where j > 0' -// ┌Iterate all rows of table "u" using index "xu_j" where j > 0 -// └Output field names ["j"] -// $ -// -// ROLLBACK -// -// The rollback statement closes the innermost transaction nesting level -// discarding any updates to the DB made by it. If that's the outermost level -// then the effects on the DB are as if the transaction never happened. -// -// RollbackStmt = "ROLLBACK" . -// -// For example -// -// // First statement list -// BEGIN TRANSACTION -// SELECT * INTO tmp FROM foo; -// INSERT INTO tmp SELECT * from bar; -// SELECT * from tmp; -// -// The (temporary) record set from the last statement is returned and can be -// processed by the client. -// -// // Second statement list -// ROLLBACK; -// -// In this case the rollback is the same as 'DROP TABLE tmp;' but it can be a -// more complex operation. -// -// SELECT FROM -// -// Select from statements produce recordsets. The optional DISTINCT modifier -// ensures all rows in the result recordset are unique. Either all of the -// resulting fields are returned ('*') or only those named in FieldList. -// -// RecordSetList is a list of table names or parenthesized select statements, -// optionally (re)named using the AS clause. -// -// The result can be filtered using a WhereClause and orderd by the OrderBy -// clause. -// -// SelectStmt = "SELECT" [ "DISTINCT" ] ( "*" | FieldList ) "FROM" RecordSetList -// [ JoinClause ] [ WhereClause ] [ GroupByClause ] [ OrderBy ] [ Limit ] [ Offset ]. -// -// JoinClause = ( "LEFT" | "RIGHT" | "FULL" ) [ "OUTER" ] "JOIN" RecordSet "ON" Expression . -// -// RecordSet = ( TableName | "(" SelectStmt [ ";" ] ")" ) [ "AS" identifier ] . -// RecordSetList = RecordSet { "," RecordSet } [ "," ] . -// -// For example -// -// SELECT * FROM Stock; -// -// SELECT DepartmentID -// FROM department -// WHERE DepartmentID == 42 -// ORDER BY DepartmentName; -// -// SELECT employee.LastName -// FROM department, employee -// WHERE department.DepartmentID == employee.DepartmentID -// ORDER BY DepartmentID; -// -// If Recordset is a nested, parenthesized SelectStmt then it must be given a -// name using the AS clause if its field are to be accessible in expressions. -// -// SELECT a.b, c.d -// FROM -// x AS a, -// ( -// SELECT * FROM y; -// ) AS c -// WHERE a.e > c.e; -// -// Fields naming rules -// -// A field is an named expression. Identifiers, not used as a type in -// conversion or a function name in the Call clause, denote names of (other) -// fields, values of which should be used in the expression. -// -// Field = Expression [ "AS" identifier ] . -// -// The expression can be named using the AS clause. If the AS clause is not -// present and the expression consists solely of a field name, then that field -// name is used as the name of the resulting field. Otherwise the field is -// unnamed. -// -// For example -// -// SELECT 314, 42 as AUQLUE, DepartmentID, DepartmentID+1000, LastName as Name from employee; -// // Fields are []string{"", "AUQLUE", "DepartmentID", "", "Name"} -// -// The SELECT statement can optionally enumerate the desired/resulting fields -// in a list. -// -// FieldList = Field { "," Field } [ "," ] . -// -// No two identical field names can appear in the list. -// -// SELECT DepartmentID, LastName, DepartmentID from employee; -// // duplicate field name "DepartmentID" -// -// SELECT DepartmentID, LastName, DepartmentID as ID2 from employee; -// // works -// -// When more than one record set is used in the FROM clause record set list, -// the result record set field names are rewritten to be qualified using -// the record set names. -// -// SELECT * FROM employee, department; -// // Fields are []string{"employee.LastName", "employee.DepartmentID", "department.DepartmentID", "department.DepartmentName" -// -// If a particular record set doesn't have a name, its respective fields became -// unnamed. -// -// SELECT * FROM employee as e, ( SELECT * FROM department); -// // Fields are []string{"e.LastName", "e.DepartmentID", "", "" -// -// SELECT * FROM employee AS e, ( SELECT * FROM department) AS d; -// // Fields are []string{"e.LastName", "e.DepartmentID", "d.DepartmentID", "d.DepartmentName" -// -// Outer joins -// -// The optional JOIN clause, for example -// -// SELECT * -// FROM a -// LEFT OUTER JOIN b ON expr; -// -// is mostly equal to -// -// SELECT * -// FROM a, b -// WHERE expr; -// -// except that the rows from a which, when they appear in the cross join, never -// made expr to evaluate to true, are combined with a virtual row from b, -// containing all nulls, and added to the result set. For the RIGHT JOIN -// variant the discussed rules are used for rows from b not satisfying expr == -// true and the virtual, all-null row "comes" from a. The FULL JOIN adds the -// respective rows which would be otherwise provided by the separate executions -// of the LEFT JOIN and RIGHT JOIN variants. For more thorough OUTER JOIN -// discussion please see the Wikipedia article at [10]. -// -// Recordset ordering -// -// Resultins rows of a SELECT statement can be optionally ordered by the ORDER -// BY clause. Collating proceeds by considering the expressions in the -// expression list left to right until a collating order is determined. Any -// possibly remaining expressions are not evaluated. -// -// OrderBy = "ORDER" "BY" ExpressionList [ "ASC" | "DESC" ] . -// -// All of the expression values must yield an ordered type or NULL. Ordered -// types are defined in "Comparison operators". Collating of elements having a -// NULL value is different compared to what the comparison operators yield in -// expression evaluation (NULL result instead of a boolean value). -// -// Below, T denotes a non NULL value of any QL type. -// -// NULL < T -// -// NULL collates before any non NULL value (is considered smaller than T). -// -// NULL == NULL -// -// Two NULLs have no collating order (are considered equal). -// -// Recordset filtering -// -// The WHERE clause restricts records considered by some statements, like -// SELECT FROM, DELETE FROM, or UPDATE. -// -// expression value consider the record -// ---------------- ------------------- -// true yes -// false or NULL no -// -// It is an error if the expression evaluates to a non null value of non bool -// type. -// -// WhereClause = "WHERE" Expression . -// -// Recordset grouping -// -// The GROUP BY clause is used to project rows having common values into a -// smaller set of rows. -// -// For example -// -// SELECT Country, sum(Qty) FROM Sales GROUP BY Country; -// -// SELECT Country, Product FROM Sales GROUP BY Country, Product; -// -// SELECT DISTINCT Country, Product FROM Sales; -// -// Using the GROUP BY without any aggregate functions in the selected fields is -// in certain cases equal to using the DISTINCT modifier. The last two examples -// above produce the same resultsets. -// -// GroupByClause = "GROUP BY" ColumnNameList . -// -// Skipping records -// -// The optional OFFSET clause allows to ignore first N records. For example -// -// SELECT * FROM t OFFSET 10; -// -// The above will produce only rows 11, 12, ... of the record set, if they -// exist. The value of the expression must a non negative integer, but not -// bigint or duration. -// -// Offset = "OFFSET" Expression . -// -// Limiting the result set size -// -// The optional LIMIT clause allows to ignore all but first N records. For -// example -// -// SELECT * FROM t LIMIT 10; -// -// The above will return at most the first 10 records of the record set. The -// value of the expression must a non negative integer, but not bigint or -// duration. -// -// Limit = "Limit" Expression . -// -// The LIMIT and OFFSET clauses can be combined. For example -// -// SELECT * FROM t LIMIT 5 OFFSET 3; -// -// Considering table t has, say 10 records, the above will produce only records -// 4 - 8. -// -// #1: Ignore 1/3 -// #2: Ignore 2/3 -// #3: Ignore 3/3 -// #4: Return 1/5 -// #5: Return 2/5 -// #6: Return 3/5 -// #7: Return 4/5 -// #8: Return 5/5 -// -// After returning record #8, no more result rows/records are computed. -// -// Select statement evaluation order -// -// 1. The FROM clause is evaluated, producing a Cartesian product of its source -// record sets (tables or nested SELECT statements). -// -// 2. If present, the JOIN cluase is evaluated on the result set of the -// previous evaluation and the recordset specified by the JOIN clause. (... -// JOIN Recordset ON ...) -// -// 3. If present, the WHERE clause is evaluated on the result set of the -// previous evaluation. -// -// 4. If present, the GROUP BY clause is evaluated on the result set of the -// previous evaluation(s). -// -// 5. The SELECT field expressions are evaluated on the result set of the -// previous evaluation(s). -// -// 6. If present, the DISTINCT modifier is evaluated on the result set of the -// previous evaluation(s). -// -// 7. If present, the ORDER BY clause is evaluated on the result set of the -// previous evaluation(s). -// -// 8. If present, the OFFSET clause is evaluated on the result set of the -// previous evaluation(s). The offset expression is evaluated once for the -// first record produced by the previous evaluations. -// -// 9. If present, the LIMIT clause is evaluated on the result set of the -// previous evaluation(s). The limit expression is evaluated once for the first -// record produced by the previous evaluations. -// -// -// TRUNCATE TABLE -// -// Truncate table statements remove all records from a table. The table must -// exist. -// -// TruncateTableStmt = "TRUNCATE" "TABLE" TableName . -// -// For example -// -// BEGIN TRANSACTION -// TRUNCATE TABLE department; -// COMMIT; -// -// UPDATE -// -// Update statements change values of fields in rows of a table. -// -// UpdateStmt = "UPDATE" TableName [ "SET" ] AssignmentList [ WhereClause ] . -// -// AssignmentList = Assignment { "," Assignment } [ "," ] . -// Assignment = ColumnName "=" Expression . -// -// For example -// -// BEGIN TRANSACTION -// UPDATE department -// DepartmentName = DepartmentName + " dpt.", -// DepartmentID = 1000+DepartmentID, -// WHERE DepartmentID < 1000; -// COMMIT; -// -// Note: The SET clause is optional. -// -// If any of the columns of the table were defined using the optional -// constraints clause or the optional defaults clause then those are processed -// on a per row basis. The details are discussed in the "Constraints and -// defaults" chapter below the CREATE TABLE statement documentation. -// -// System Tables -// -// To allow to query for DB meta data, there exist specially named tables, some -// of them being virtual. -// -// Note: Virtual system tables may have fake table-wise unique but meaningless -// and unstable record IDs. Do not apply the built-in id() to any system table. -// -// Tables Table -// -// The table __Table lists all tables in the DB. The schema is -// -// CREATE TABLE __Table (Name string, Schema string); -// -// The Schema column returns the statement to (re)create table Name. This table -// is virtual. -// -// Columns Table -// -// The table __Colum lists all columns of all tables in the DB. The schema is -// -// CREATE TABLE __Column (TableName string, Ordinal int, Name string, Type string); -// -// The Ordinal column defines the 1-based index of the column in the record. -// This table is virtual. -// -// Columns2 Table -// -// The table __Colum2 lists all columns of all tables in the DB which have the -// constraint NOT NULL or which have a constraint expression defined or which -// have a default expression defined. The schema is -// -// CREATE TABLE __Column2 (TableName string, Name string, NotNull bool, ConstraintExpr string, DefaultExpr string) -// -// It's possible to obtain a consolidated recordset for all properties of all -// DB columns using -// -// SELECT -// __Column.TableName, __Column.Ordinal, __Column.Name, __Column.Type, -// __Column2.NotNull, __Column2.ConstraintExpr, __Column2.DefaultExpr, -// FROM __Column -// LEFT JOIN __Column2 -// ON __Column.TableName == __Column2.TableName && __Column.Name == __Column2.Name -// ORDER BY __Column.TableName, __Column.Ordinal; -// -// The Name column is the column name in TableName. -// -// Indices table -// -// The table __Index lists all indices in the DB. The schema is -// -// CREATE TABLE __Index (TableName string, ColumnName string, Name string, IsUnique bool); -// -// The IsUnique columns reflects if the index was created using the optional -// UNIQUE clause. This table is virtual. -// -// Built-in functions -// -// Built-in functions are predeclared. -// -// Average -// -// The built-in aggregate function avg returns the average of values of an -// expression. Avg ignores NULL values, but returns NULL if all values of a -// column are NULL or if avg is applied to an empty record set. -// -// func avg(e numeric) typeof(e) -// -// The column values must be of a numeric type. -// -// SELECT salesperson, avg(sales) FROM salesforce GROUP BY salesperson; -// -// Contains -// -// The built-in function contains returns true if substr is within s. -// -// func contains(s, substr string) bool -// -// If any argument to contains is NULL the result is NULL. -// -// Count -// -// The built-in aggregate function count returns how many times an expression -// has a non NULL values or the number of rows in a record set. Note: count() -// returns 0 for an empty record set. -// -// func count() int // The number of rows in a record set. -// func count(*) int // Equivalent to count(). -// func count(e expression) int // The number of cases where the expression value is not NULL. -// -// For example -// -// SELECT count() FROM department; // # of rows -// -// SELECT count(*) FROM department; // # of rows -// -// SELECT count(DepartmentID) FROM department; // # of records with non NULL field DepartmentID -// -// SELECT count()-count(DepartmentID) FROM department; // # of records with NULL field DepartmentID -// -// SELECT count(foo+bar*3) AS y FROM t; // # of cases where 'foo+bar*3' is non NULL -// -// Date -// -// Date returns the time corresponding to -// -// yyyy-mm-dd hh:mm:ss + nsec nanoseconds -// -// in the appropriate zone for that time in the given location. -// -// The month, day, hour, min, sec, and nsec values may be outside their usual -// ranges and will be normalized during the conversion. For example, October 32 -// converts to November 1. -// -// A daylight savings time transition skips or repeats times. For example, in -// the United States, March 13, 2011 2:15am never occurred, while November 6, -// 2011 1:15am occurred twice. In such cases, the choice of time zone, and -// therefore the time, is not well-defined. Date returns a time that is correct -// in one of the two zones involved in the transition, but it does not -// guarantee which. -// -// func date(year, month, day, hour, min, sec, nsec int, loc string) time -// -// A location maps time instants to the zone in use at that time. Typically, -// the location represents the collection of time offsets in use in a -// geographical area, such as "CEST" and "CET" for central Europe. "local" -// represents the system's local time zone. "UTC" represents Universal -// Coordinated Time (UTC). -// -// The month specifies a month of the year (January = 1, ...). -// -// If any argument to date is NULL the result is NULL. -// -// Day -// -// The built-in function day returns the day of the month specified by t. -// -// func day(t time) int -// -// If the argument to day is NULL the result is NULL. -// -// Format time -// -// The built-in function formatTime returns a textual representation of the -// time value formatted according to layout, which defines the format by -// showing how the reference time, -// -// Mon Jan 2 15:04:05 -0700 MST 2006 -// -// would be displayed if it were the value; it serves as an example of the -// desired output. The same display rules will then be applied to the time -// value. -// -// func formatTime(t time, layout string) string -// -// If any argument to formatTime is NULL the result is NULL. -// -// NOTE: The string value of the time zone, like "CET" or "ACDT", is dependent -// on the time zone of the machine the function is run on. For example, if the -// t value is in "CET", but the machine is in "ACDT", instead of "CET" the -// result is "+0100". This is the same what Go (time.Time).String() returns and -// in fact formatTime directly calls t.String(). -// -// formatTime(date(2006, 1, 2, 15, 4, 5, 999999999, "CET")) -// -// returns -// -// 2006-01-02 15:04:05.999999999 +0100 CET -// -// on a machine in the CET time zone, but may return -// -// 2006-01-02 15:04:05.999999999 +0100 +0100 -// -// on a machine in the ACDT zone. The time value is in both cases the same so -// its ordering and comparing is correct. Only the display value can differ. -// -// Format numbers -// -// The built-in functions formatFloat and formatInt format numbers -// to strings using go's number format functions in the `strconv` package. For -// all three functions, only the first argument is mandatory. The default values -// of the rest are shown in the examples. If the first argument is NULL, the -// result is NULL. -// -// formatFloat(43.2[, 'g', -1, 64]) string -// -// returns -// -// "43.2" -// -// formatInt(-42[, 10]) string -// -// returns -// -// "-42" -// -// formatInt(uint32(42)[, 10]) string -// -// returns -// -// "42" -// -// Unlike the `strconv` equivalent, the formatInt function handles all integer -// types, both signed and unsigned. -// -// HasPrefix -// -// The built-in function hasPrefix tests whether the string s begins with prefix. -// -// func hasPrefix(s, prefix string) bool -// -// If any argument to hasPrefix is NULL the result is NULL. -// -// HasSuffix -// -// The built-in function hasSuffix tests whether the string s ends with suffix. -// -// func hasSuffix(s, suffix string) bool -// -// If any argument to hasSuffix is NULL the result is NULL. -// -// Hour -// -// The built-in function hour returns the hour within the day specified by t, -// in the range [0, 23]. -// -// func hour(t time) int -// -// If the argument to hour is NULL the result is NULL. -// -// Hours -// -// The built-in function hours returns the duration as a floating point number -// of hours. -// -// func hours(d duration) float -// -// If the argument to hours is NULL the result is NULL. -// -// Record id -// -// The built-in function id takes zero or one arguments. If no argument is -// provided, id() returns a table-unique automatically assigned numeric -// identifier of type int. Ids of deleted records are not reused unless the DB -// becomes completely empty (has no tables). -// -// func id() int -// -// For example -// -// SELECT id(), LastName -// FROM employee; -// -// If id() without arguments is called for a row which is not a table record -// then the result value is NULL. -// -// For example -// -// SELECT id(), e.LastName, e.DepartmentID, d.DepartmentID -// FROM -// employee AS e, -// department AS d, -// WHERE e.DepartmentID == d.DepartmentID; -// // Will always return NULL in first field. -// -// SELECT e.ID, e.LastName, e.DepartmentID, d.DepartmentID -// FROM -// (SELECT id() AS ID, LastName, DepartmentID FROM employee) AS e, -// department as d, -// WHERE e.DepartmentID == d.DepartmentID; -// // Will work. -// -// If id() has one argument it must be a table name of a table in a cross join. -// -// For example -// -// SELECT * -// FROM foo, bar -// WHERE bar.fooID == id(foo) -// ORDER BY id(foo); -// -// Length -// -// The built-in function len takes a string argument and returns the lentgh of -// the string in bytes. -// -// func len(s string) int -// -// The expression len(s) is constant if s is a string constant. -// -// If the argument to len is NULL the result is NULL. -// -// Maximum -// -// The built-in aggregate function max returns the largest value of an -// expression in a record set. Max ignores NULL values, but returns NULL if -// all values of a column are NULL or if max is applied to an empty record set. -// -// func max(e expression) typeof(e) // The largest value of the expression. -// -// The expression values must be of an ordered type. -// -// For example -// -// SELECT department, max(sales) FROM t GROUP BY department; -// -// Minimum -// -// The built-in aggregate function min returns the smallest value of an -// expression in a record set. Min ignores NULL values, but returns NULL if -// all values of a column are NULL or if min is applied to an empty record set. -// -// func min(e expression) typeof(e) // The smallest value of the expression. -// -// For example -// -// SELECT a, min(b) FROM t GROUP BY a; -// -// The column values must be of an ordered type. -// -// Minute -// -// The built-in function minute returns the minute offset within the hour -// specified by t, in the range [0, 59]. -// -// func minute(t time) int -// -// If the argument to minute is NULL the result is NULL. -// -// Minutes -// -// The built-in function minutes returns the duration as a floating point -// number of minutes. -// -// func minutes(d duration) float -// -// If the argument to minutes is NULL the result is NULL. -// -// Month -// -// The built-in function month returns the month of the year specified by t -// (January = 1, ...). -// -// func month(t time) int -// -// If the argument to month is NULL the result is NULL. -// -// Nanosecond -// -// The built-in function nanosecond returns the nanosecond offset within the -// second specified by t, in the range [0, 999999999]. -// -// func nanosecond(t time) int -// -// If the argument to nanosecond is NULL the result is NULL. -// -// Nanoseconds -// -// The built-in function nanoseconds returns the duration as an integer -// nanosecond count. -// -// func nanoseconds(d duration) float -// -// If the argument to nanoseconds is NULL the result is NULL. -// -// Now -// -// The built-in function now returns the current local time. -// -// func now() time -// -// Parse time -// -// The built-in function parseTime parses a formatted string and returns the -// time value it represents. The layout defines the format by showing how the -// reference time, -// -// Mon Jan 2 15:04:05 -0700 MST 2006 -// -// would be interpreted if it were the value; it serves as an example of the -// input format. The same interpretation will then be made to the input string. -// -// Elements omitted from the value are assumed to be zero or, when zero is -// impossible, one, so parsing "3:04pm" returns the time corresponding to Jan -// 1, year 0, 15:04:00 UTC (note that because the year is 0, this time is -// before the zero Time). Years must be in the range 0000..9999. The day of the -// week is checked for syntax but it is otherwise ignored. -// -// In the absence of a time zone indicator, parseTime returns a time in UTC. -// -// When parsing a time with a zone offset like -0700, if the offset corresponds -// to a time zone used by the current location, then parseTime uses that -// location and zone in the returned time. Otherwise it records the time as -// being in a fabricated location with time fixed at the given zone offset. -// -// When parsing a time with a zone abbreviation like MST, if the zone -// abbreviation has a defined offset in the current location, then that offset -// is used. The zone abbreviation "UTC" is recognized as UTC regardless of -// location. If the zone abbreviation is unknown, Parse records the time as -// being in a fabricated location with the given zone abbreviation and a zero -// offset. This choice means that such a time can be parses and reformatted -// with the same layout losslessly, but the exact instant used in the -// representation will differ by the actual zone offset. To avoid such -// problems, prefer time layouts that use a numeric zone offset. -// -// func parseTime(layout, value string) time -// -// If any argument to parseTime is NULL the result is NULL. -// -// Second -// -// The built-in function second returns the second offset within the minute -// specified by t, in the range [0, 59]. -// -// func second(t time) int -// -// If the argument to second is NULL the result is NULL. -// -// Seconds -// -// The built-in function seconds returns the duration as a floating point -// number of seconds. -// -// func seconds(d duration) float -// -// If the argument to seconds is NULL the result is NULL. -// -// Since -// -// The built-in function since returns the time elapsed since t. It is -// shorthand for now()-t. -// -// func since(t time) duration -// -// If the argument to since is NULL the result is NULL. -// -// Sum -// -// The built-in aggregate function sum returns the sum of values of an -// expression for all rows of a record set. Sum ignores NULL values, but -// returns NULL if all values of a column are NULL or if sum is applied to an -// empty record set. -// -// func sum(e expression) typeof(e) // The sum of the values of the expression. -// -// The column values must be of a numeric type. -// -// SELECT salesperson, sum(sales) FROM salesforce GROUP BY salesperson; -// -// Time in a specific zone -// -// The built-in function timeIn returns t with the location information set to -// loc. For discussion of the loc argument please see date(). -// -// func timeIn(t time, loc string) time -// -// If any argument to timeIn is NULL the result is NULL. -// -// Weekday -// -// The built-in function weekday returns the day of the week specified by t. -// Sunday == 0, Monday == 1, ... -// -// func weekday(t time) int -// -// If the argument to weekday is NULL the result is NULL. -// -// Year -// -// The built-in function year returns the year in which t occurs. -// -// func year(t time) int -// -// If the argument to year is NULL the result is NULL. -// -// Year day -// -// The built-in function yearDay returns the day of the year specified by t, in -// the range [1,365] for non-leap years, and [1,366] in leap years. -// -// func yearDay(t time) int -// -// If the argument to yearDay is NULL the result is NULL. -// -// Manipulating complex numbers -// -// Three functions assemble and disassemble complex numbers. The built-in -// function complex constructs a complex value from a floating-point real and -// imaginary part, while real and imag extract the real and imaginary parts of -// a complex value. -// -// complex(realPart, imaginaryPart floatT) complexT -// real(complexT) floatT -// imag(complexT) floatT -// -// The type of the arguments and return value correspond. For complex, the two -// arguments must be of the same floating-point type and the return type is the -// complex type with the corresponding floating-point constituents: complex64 -// for float32, complex128 for float64. The real and imag functions together -// form the inverse, so for a complex value z, z == complex(real(z), imag(z)). -// -// If the operands of these functions are all constants, the return value is a -// constant. -// -// complex(2, -2) // complex128 -// complex(1.0, -1.4) // complex128 -// float32(math.Cos(math.Pi/2)) // float32 -// complex(5, float32(-x)) // complex64 -// imag(b) // float64 -// real(complex(5, float32(-x))) // float32 -// -// If any argument to any of complex, real, imag functions is NULL the result -// is NULL. -// -// Size guarantees -// -// For the numeric types, the following sizes are guaranteed -// -// type size in bytes -// -// byte, uint8, int8 1 -// uint16, int16 2 -// uint32, int32, float32 4 -// uint, uint64, int, int64, float64, complex64 8 -// complex128 16 -// -// License -// -// Portions of this specification page are modifications based on work[2] -// created and shared by Google[3] and used according to terms described in the -// Creative Commons 3.0 Attribution License[4]. -// -// This specification is licensed under the Creative Commons Attribution 3.0 -// License, and code is licensed under a BSD license[5]. -// -// References -// -// Links from the above documentation -// -// [1]: http://golang.org/ref/spec#Notation -// [2]: http://golang.org/ref/spec -// [3]: http://code.google.com/policies.html -// [4]: http://creativecommons.org/licenses/by/3.0/ -// [5]: http://golang.org/LICENSE -// [6]: http://golang.org/pkg/regexp/#Regexp.MatchString -// [7]: http://developer.mimer.com/validator/sql-reserved-words.tml -// [8]: http://godoc.org/github.com/cznic/zappy -// [9]: http://www.w3schools.com/sql/sql_default.asp -// [10]: http://en.wikipedia.org/wiki/Join_(SQL)#Outer_join -// -// Implementation details -// -// This section is not part of the specification. -// -// Indices -// -// WARNING: The implementation of indices is new and it surely needs more time -// to become mature. -// -// Indices are used currently used only by the WHERE clause. The following -// expression patterns of 'WHERE expression' are recognized and trigger index -// use. -// -// - WHERE c // For bool typed indexed column c -// - WHERE !c // For bool typed indexed column c -// - WHERE c relOp constExpr // For indexed column c -// - WHERE c relOp parameter // For indexed column c -// - WHERE parameter relOp c // For indexed column c -// - WHERE constExpr relOp c // For indexed column c -// -// The relOp is one of the relation operators <, <=, ==, >=, >. For the -// equality operator both operands must be of comparable types. For all other -// operators both operands must be of ordered types. The constant expression is -// a compile time constant expression. Some constant folding is still a TODO. -// Parameter is a QL parameter ($1 etc.). -// -// Query rewriting -// -// Consider tables t and u, both with an indexed field f. The WHERE expression -// doesn't comply with the above simple detected cases. -// -// SELECT * FROM t, u WHERE t.f < x && u.f < y; -// -// However, such query is now automatically rewritten to -// -// SELECT * FROM -// (SELECT * FROM t WHERE f < x), -// (SELECT * FROM u WHERE f < y); -// -// which will use both of the indices. The impact of using the indices can be -// substantial (cf. BenchmarkCrossJoin*) if the resulting rows have low -// "selectivity", ie. only few rows from both tables are selected by the -// respective WHERE filtering. -// -// Note: Existing QL DBs can be used and indices can be added to them. However, -// once any indices are present in the DB, the old QL versions cannot work with -// such DB anymore. -// -// Benchmarks -// -// Running a benchmark with -v (-test.v) outputs information about the scale -// used to report records/s and a brief description of the benchmark. For -// example -// -// $ go test -run NONE -bench 'SelectMem.*1e[23]' -v -// PASS -// BenchmarkSelectMem1kBx1e2 50000 67680 ns/op 1477537.05 MB/s -// --- BENCH: BenchmarkSelectMem1kBx1e2 -// all_test.go:310: -// ============================================================= -// NOTE: All benchmarks report records/s as 1000000 bytes/s. -// ============================================================= -// all_test.go:321: Having a table of 100 records, each of size 1kB, measure the performance of -// SELECT * FROM t; -// -// BenchmarkSelectMem1kBx1e3 5000 634819 ns/op 1575251.01 MB/s -// --- BENCH: BenchmarkSelectMem1kBx1e3 -// all_test.go:321: Having a table of 1000 records, each of size 1kB, measure the performance of -// SELECT * FROM t; -// -// ok github.com/cznic/ql 7.496s -// $ -// -// Running the full suite of benchmarks takes a lot of time. Use the -timeout -// flag to avoid them being killed after the default time limit (10 minutes). -package ql diff --git a/Godeps/_workspace/src/github.com/cznic/ql/driver.go b/Godeps/_workspace/src/github.com/cznic/ql/driver.go deleted file mode 100644 index b660e4cb65..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/driver.go +++ /dev/null @@ -1,523 +0,0 @@ -// Copyright 2014 The ql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// database/sql/driver - -package ql - -import ( - "bytes" - "database/sql" - "database/sql/driver" - "errors" - "fmt" - "io" - "math/big" - "os" - "path/filepath" - "strings" - "sync" - "time" -) - -var ( - _ driver.Conn = (*driverConn)(nil) - _ driver.Driver = (*sqlDriver)(nil) - _ driver.Execer = (*driverConn)(nil) - _ driver.Queryer = (*driverConn)(nil) - _ driver.Result = (*driverResult)(nil) - _ driver.Rows = (*driverRows)(nil) - _ driver.Stmt = (*driverStmt)(nil) - _ driver.Tx = (*driverConn)(nil) - - txBegin = MustCompile("BEGIN TRANSACTION;") - txCommit = MustCompile("COMMIT;") - txRollback = MustCompile("ROLLBACK;") - - errNoResult = errors.New("query statement does not produce a result set (no top level SELECT)") -) - -type errList []error - -func (e *errList) append(err error) { - if err != nil { - *e = append(*e, err) - } -} - -func (e errList) error() error { - if len(e) == 0 { - return nil - } - - return e -} - -func (e errList) Error() string { - a := make([]string, len(e)) - for i, v := range e { - a[i] = v.Error() - } - return strings.Join(a, "\n") -} - -func params(args []driver.Value) []interface{} { - r := make([]interface{}, len(args)) - for i, v := range args { - r[i] = interface{}(v) - } - return r -} - -var ( - fileDriver = &sqlDriver{dbs: map[string]*driverDB{}} - fileDriverOnce sync.Once - memDriver = &sqlDriver{isMem: true, dbs: map[string]*driverDB{}} - memDriverOnce sync.Once -) - -// RegisterDriver registers a QL database/sql/driver[0] named "ql". The name -// parameter of -// -// sql.Open("ql", name) -// -// is interpreted as a path name to a named DB file which will be created if -// not present. The underlying QL database data are persisted on db.Close(). -// RegisterDriver can be safely called multiple times, it'll register the -// driver only once. -// -// The name argument can be optionally prefixed by "file://". In that case the -// prefix is stripped before interpreting it as a file name. -// -// The name argument can be optionally prefixed by "memory://". In that case -// the prefix is stripped before interpreting it as a name of a memory-only, -// volatile DB. -// -// [0]: http://golang.org/pkg/database/sql/driver/ -func RegisterDriver() { - fileDriverOnce.Do(func() { sql.Register("ql", fileDriver) }) -} - -// RegisterMemDriver registers a QL memory database/sql/driver[0] named -// "ql-mem". The name parameter of -// -// sql.Open("ql-mem", name) -// -// is interpreted as an unique memory DB name which will be created if not -// present. The underlying QL memory database data are not persisted on -// db.Close(). RegisterMemDriver can be safely called multiple times, it'll -// register the driver only once. -// -// [0]: http://golang.org/pkg/database/sql/driver/ -func RegisterMemDriver() { - memDriverOnce.Do(func() { sql.Register("ql-mem", memDriver) }) -} - -type driverDB struct { - db *DB - name string - refcount int -} - -func newDriverDB(db *DB, name string) *driverDB { - return &driverDB{db: db, name: name, refcount: 1} -} - -// sqlDriver implements the interface required by database/sql/driver. -type sqlDriver struct { - dbs map[string]*driverDB - isMem bool - mu sync.Mutex -} - -func (d *sqlDriver) lock() func() { - d.mu.Lock() - return d.mu.Unlock -} - -// Open returns a new connection to the database. The name is a string in a -// driver-specific format. -// -// Open may return a cached connection (one previously closed), but doing so is -// unnecessary; the sql package maintains a pool of idle connections for -// efficient re-use. -// -// The returned connection is only used by one goroutine at a time. -func (d *sqlDriver) Open(name string) (driver.Conn, error) { - if d != fileDriver && d != memDriver { - return nil, fmt.Errorf("open: unexpected/unsupported instance of driver.Driver: %p", d) - } - - switch { - case d == fileDriver && strings.HasPrefix(name, "file://"): - name = name[len("file://"):] - case d == fileDriver && strings.HasPrefix(name, "memory://"): - d = memDriver - name = name[len("memory://"):] - } - name = filepath.Clean(name) - if name == "" || name == "." || name == string(os.PathSeparator) { - return nil, fmt.Errorf("invalid DB name %q", name) - } - - defer d.lock()() - db := d.dbs[name] - if db == nil { - var err error - var db0 *DB - switch d.isMem { - case true: - db0, err = OpenMem() - default: - db0, err = OpenFile(name, &Options{CanCreate: true}) - } - if err != nil { - return nil, err - } - - db = newDriverDB(db0, name) - d.dbs[name] = db - return newDriverConn(d, db), nil - } - - db.refcount++ - return newDriverConn(d, db), nil -} - -// driverConn is a connection to a database. It is not used concurrently by -// multiple goroutines. -// -// Conn is assumed to be stateful. -type driverConn struct { - ctx *TCtx - db *driverDB - driver *sqlDriver - stop map[*driverStmt]struct{} - tnl int -} - -func newDriverConn(d *sqlDriver, ddb *driverDB) driver.Conn { - r := &driverConn{ - db: ddb, - driver: d, - stop: map[*driverStmt]struct{}{}, - } - return r -} - -// Prepare returns a prepared statement, bound to this connection. -func (c *driverConn) Prepare(query string) (driver.Stmt, error) { - list, err := Compile(query) - if err != nil { - return nil, err - } - - s := &driverStmt{conn: c, stmt: list} - c.stop[s] = struct{}{} - return s, nil -} - -// Close invalidates and potentially stops any current prepared statements and -// transactions, marking this connection as no longer in use. -// -// Because the sql package maintains a free pool of connections and only calls -// Close when there's a surplus of idle connections, it shouldn't be necessary -// for drivers to do their own connection caching. -func (c *driverConn) Close() error { - var err errList - for s := range c.stop { - err.append(s.Close()) - } - defer c.driver.lock()() - dbs, name := c.driver.dbs, c.db.name - v := dbs[name] - v.refcount-- - if v.refcount == 0 { - err.append(c.db.db.Close()) - delete(dbs, name) - } - return err.error() -} - -// Begin starts and returns a new transaction. -func (c *driverConn) Begin() (driver.Tx, error) { - if c.ctx == nil { - c.ctx = NewRWCtx() - } - - if _, _, err := c.db.db.Execute(c.ctx, txBegin); err != nil { - return nil, err - } - - c.tnl++ - return c, nil -} - -func (c *driverConn) Commit() error { - if c.tnl == 0 || c.ctx == nil { - return errCommitNotInTransaction - } - - if _, _, err := c.db.db.Execute(c.ctx, txCommit); err != nil { - return err - } - - c.tnl-- - if c.tnl == 0 { - c.ctx = nil - } - return nil -} - -func (c *driverConn) Rollback() error { - if c.tnl == 0 || c.ctx == nil { - return errRollbackNotInTransaction - } - - if _, _, err := c.db.db.Execute(c.ctx, txRollback); err != nil { - return err - } - - c.tnl-- - if c.tnl == 0 { - c.ctx = nil - } - return nil -} - -// Execer is an optional interface that may be implemented by a Conn. -// -// If a Conn does not implement Execer, the sql package's DB.Exec will first -// prepare a query, execute the statement, and then close the statement. -// -// Exec may return driver.ErrSkip. -func (c *driverConn) Exec(query string, args []driver.Value) (driver.Result, error) { - list, err := Compile(query) - if err != nil { - return nil, err - } - - return driverExec(c.db, c.ctx, list, args) -} - -func driverExec(db *driverDB, ctx *TCtx, list List, args []driver.Value) (driver.Result, error) { - if _, _, err := db.db.Execute(ctx, list, params(args)...); err != nil { - return nil, err - } - - if len(list.l) == 1 { - switch list.l[0].(type) { - case *createTableStmt, *dropTableStmt, *alterTableAddStmt, - *alterTableDropColumnStmt, *truncateTableStmt: - return driver.ResultNoRows, nil - } - } - - r := &driverResult{} - if ctx != nil { - r.lastInsertID, r.rowsAffected = ctx.LastInsertID, ctx.RowsAffected - } - return r, nil -} - -// Queryer is an optional interface that may be implemented by a Conn. -// -// If a Conn does not implement Queryer, the sql package's DB.Query will first -// prepare a query, execute the statement, and then close the statement. -// -// Query may return driver.ErrSkip. -func (c *driverConn) Query(query string, args []driver.Value) (driver.Rows, error) { - list, err := Compile(query) - if err != nil { - return nil, err - } - - return driverQuery(c.db, c.ctx, list, args) -} - -func driverQuery(db *driverDB, ctx *TCtx, list List, args []driver.Value) (driver.Rows, error) { - rss, _, err := db.db.Execute(ctx, list, params(args)...) - if err != nil { - return nil, err - } - - switch n := len(rss); n { - case 0: - return nil, errNoResult - case 1: - return newdriverRows(rss[len(rss)-1]), nil - default: - return nil, fmt.Errorf("query produced %d result sets, expected only one", n) - } -} - -// driverResult is the result of a query execution. -type driverResult struct { - lastInsertID int64 - rowsAffected int64 -} - -// LastInsertId returns the database's auto-generated ID after, for example, an -// INSERT into a table with primary key. -func (r *driverResult) LastInsertId() (int64, error) { // -golint - return r.lastInsertID, nil -} - -// RowsAffected returns the number of rows affected by the query. -func (r *driverResult) RowsAffected() (int64, error) { - return r.rowsAffected, nil -} - -// driverRows is an iterator over an executed query's results. -type driverRows struct { - rs Recordset - done chan int - rows chan interface{} -} - -func newdriverRows(rs Recordset) *driverRows { - r := &driverRows{ - rs: rs, - done: make(chan int), - rows: make(chan interface{}, 500), - } - go func() { - err := io.EOF - if e := r.rs.Do(false, func(data []interface{}) (bool, error) { - select { - case r.rows <- data: - return true, nil - case <-r.done: - return false, nil - } - }); e != nil { - err = e - } - - select { - case r.rows <- err: - case <-r.done: - } - }() - return r -} - -// Columns returns the names of the columns. The number of columns of the -// result is inferred from the length of the slice. If a particular column -// name isn't known, an empty string should be returned for that entry. -func (r *driverRows) Columns() []string { - f, _ := r.rs.Fields() - return f -} - -// Close closes the rows iterator. -func (r *driverRows) Close() error { - close(r.done) - return nil -} - -// Next is called to populate the next row of data into the provided slice. The -// provided slice will be the same size as the Columns() are wide. -// -// The dest slice may be populated only with a driver Value type, but excluding -// string. All string values must be converted to []byte. -// -// Next should return io.EOF when there are no more rows. -func (r *driverRows) Next(dest []driver.Value) error { - select { - case rx := <-r.rows: - switch x := rx.(type) { - case error: - return x - case []interface{}: - if g, e := len(x), len(dest); g != e { - return fmt.Errorf("field count mismatch: got %d, need %d", g, e) - } - - for i, xi := range x { - switch v := xi.(type) { - case nil, int64, float64, bool, []byte, time.Time: - dest[i] = v - case complex64, complex128, *big.Int, *big.Rat: - var buf bytes.Buffer - fmt.Fprintf(&buf, "%v", v) - dest[i] = buf.Bytes() - case int8: - dest[i] = int64(v) - case int16: - dest[i] = int64(v) - case int32: - dest[i] = int64(v) - case int: - dest[i] = int64(v) - case uint8: - dest[i] = int64(v) - case uint16: - dest[i] = int64(v) - case uint32: - dest[i] = int64(v) - case uint64: - dest[i] = int64(v) - case uint: - dest[i] = int64(v) - case time.Duration: - dest[i] = int64(v) - case string: - dest[i] = []byte(v) - default: - return fmt.Errorf("internal error 004") - } - } - return nil - default: - return fmt.Errorf("internal error 005") - } - case <-r.done: - return io.EOF - } -} - -// driverStmt is a prepared statement. It is bound to a driverConn and not used -// by multiple goroutines concurrently. -type driverStmt struct { - conn *driverConn - stmt List -} - -// Close closes the statement. -// -// As of Go 1.1, a Stmt will not be closed if it's in use by any queries. -func (s *driverStmt) Close() error { - delete(s.conn.stop, s) - return nil -} - -// NumInput returns the number of placeholder parameters. -// -// If NumInput returns >= 0, the sql package will sanity check argument counts -// from callers and return errors to the caller before the statement's Exec or -// Query methods are called. -// -// NumInput may also return -1, if the driver doesn't know its number of -// placeholders. In that case, the sql package will not sanity check Exec or -// Query argument counts. -func (s *driverStmt) NumInput() int { - if x := s.stmt; len(x.l) == 1 { - return x.params - } - - return -1 -} - -// Exec executes a query that doesn't return rows, such as an INSERT or UPDATE. -func (s *driverStmt) Exec(args []driver.Value) (driver.Result, error) { - c := s.conn - return driverExec(c.db, c.ctx, s.stmt, args) -} - -// Exec executes a query that may return rows, such as a SELECT. -func (s *driverStmt) Query(args []driver.Value) (driver.Rows, error) { - c := s.conn - return driverQuery(c.db, c.ctx, s.stmt, args) -} diff --git a/Godeps/_workspace/src/github.com/cznic/ql/driver/Makefile b/Godeps/_workspace/src/github.com/cznic/ql/driver/Makefile deleted file mode 100644 index f1b64ee663..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/driver/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright (c) 2014 The ql Authors. All rights reserved. -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file. - -.PHONY: all clean nuke - -all: editor - go install - go vet - golint . - make todo - -bench: all - go test -run NONE -bench . - -clean: - go clean - rm -f *~ - -cover: - t=$(shell tempfile) ; go test -coverprofile $$t && go tool cover -html $$t && unlink $$t - -editor: - go fmt - go test -i - go test - go build - -nuke: - go clean -i - -todo: - @grep -n ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* *.go || true - @grep -n TODO *.go || true - @grep -n BUG *.go || true - @grep -n println *.go || true - -later: - @grep -n LATER *.go || true - @grep -n MAYBE *.go || true diff --git a/Godeps/_workspace/src/github.com/cznic/ql/driver/driver.go b/Godeps/_workspace/src/github.com/cznic/ql/driver/driver.go deleted file mode 100644 index 557c70d828..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/driver/driver.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2014 The ql 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 driver registers a QL sql/driver named "ql" and a memory driver named "ql-mem". - -See also [0], [1] and [3]. - -Usage - -A skeleton program using ql/driver. - - package main - - import ( - "database/sql" - - _ "github.com/cznic/ql/driver" - ) - - func main() { - ... - // Disk file DB - db, err := sql.Open("ql", "ql.db") // [2] - // alternatively - db, err := sql.Open("ql", "file://ql.db") - - // and/or - - // RAM DB - mdb, err := sql.Open("ql-mem", "mem.db") - // alternatively - mdb, err := sql.Open("ql", "memory://mem.db") - if err != nil { - log.Fatal(err) - } - - // Use db/mdb here - ... - } - -This package exports nothing. - -Links - -Referenced from above: - - [0]: http://godoc.org/github.com/cznic/ql - [1]: http://golang.org/pkg/database/sql/ - [2]: http://golang.org/pkg/database/sql/#Open - [3]: http://golang.org/pkg/database/sql/driver -*/ -package driver - -import "github.com/cznic/ql" - -func init() { - ql.RegisterDriver() - ql.RegisterMemDriver() -} diff --git a/Godeps/_workspace/src/github.com/cznic/ql/errors.go b/Godeps/_workspace/src/github.com/cznic/ql/errors.go deleted file mode 100644 index 305414f4a9..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/errors.go +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 The ql 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 ql - -import ( - "errors" -) - -var ( - errBeginTransNoCtx = errors.New("BEGIN TRANSACTION: Must use R/W context, have nil") - errCommitNotInTransaction = errors.New("COMMIT: Not in transaction") - errDivByZero = errors.New("division by zero") - errIncompatibleDBFormat = errors.New("incompatible DB format") - errNoDataForHandle = errors.New("read: no data for handle") - errRollbackNotInTransaction = errors.New("ROLLBACK: Not in transaction") -) diff --git a/Godeps/_workspace/src/github.com/cznic/ql/etc.go b/Godeps/_workspace/src/github.com/cznic/ql/etc.go deleted file mode 100644 index c2e1524af0..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/etc.go +++ /dev/null @@ -1,2805 +0,0 @@ -// Copyright 2014 The ql 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 ql - -import ( - "bytes" - "fmt" - "io" - "math" - "math/big" - "strings" - "time" -) - -// QL types. -const ( - qBool = 0x62 // 'b' - qComplex64 = 0x63 // 'c' - qComplex128 = 0x64 // 'd' - qFloat32 = 0x66 // 'f' - qFloat64 = 0x67 // 'g', alias float - qInt8 = 0x69 // 'i' - qInt16 = 0x6a // 'j' - qInt32 = 0x6b // 'k' - qInt64 = 0x6c // 'l', alias int - qString = 0x73 // 's' - qUint8 = 0x75 // 'u', alias byte - qUint16 = 0x76 // 'v' - qUint32 = 0x77 // 'w' - qUint64 = 0x78 // 'x', alias uint - - qBigInt = 0x49 // 'I' - qBigRat = 0x52 // 'R' - qBlob = 0x42 // 'B' - qDuration = 0x44 // 'D' - qTime = 0x54 // 'T' -) - -var ( - type2Str = map[int]string{ - qBigInt: "bigint", - qBigRat: "bigrat", - qBlob: "blob", - qBool: "bool", - qComplex128: "complex128", - qComplex64: "complex64", - qDuration: "duration", - qFloat32: "float32", - qFloat64: "float64", - qInt16: "int16", - qInt32: "int32", - qInt64: "int64", - qInt8: "int8", - qString: "string", - qTime: "time", - qUint16: "uint16", - qUint32: "uint32", - qUint64: "uint64", - qUint8: "uint8", - } -) - -func typeStr(typ int) (r string) { - return type2Str[typ] -} - -func noEOF(err error) error { - if err == io.EOF { - err = nil - } - return err -} - -func runErr(err error) error { return fmt.Errorf("run time error: %s", err) } - -func invXOp(s, x interface{}) error { - return fmt.Errorf("invalid operation: %v[%v] (index of type %T)", s, x, x) -} - -func invSOp(s interface{}) error { - return fmt.Errorf("cannot slice %s (type %T)", s, s) -} - -func invNegX(x interface{}) error { - return fmt.Errorf("invalid string index %v (index must be non-negative)", x) -} - -func invNegLO(x interface{}) error { - return fmt.Errorf("invalid LIMIT or OFFSET value %v (must be non-negative)", x) -} - -func invSliceNegX(x interface{}) error { - return fmt.Errorf("invalid slice index %v (index must be non-negative)", x) -} - -func invBoundX(s string, x uint64) error { - return fmt.Errorf("invalid string index %d (out of bounds for %d-byte string)", x, len(s)) -} - -func invSliceBoundX(s string, x uint64) error { - return fmt.Errorf("invalid slice index %d (out of bounds for %d-byte string)", x, len(s)) -} - -func intExpr(x interface{}) (i int64, err error) { - switch x := x.(type) { - case idealInt: - if x < 0 { - return 0, invNegLO(x) - } - - return int64(x), nil - case idealRune: - if x < 0 { - return 0, invNegLO(x) - } - - return int64(x), nil - case idealUint: - if x < 0 { - return 0, invNegLO(x) - } - - return int64(x), nil - case int8: - if x < 0 { - return 0, invNegLO(x) - } - - return int64(x), nil - case int16: - if x < 0 { - return 0, invNegLO(x) - } - - return int64(x), nil - case int32: - if x < 0 { - return 0, invNegLO(x) - } - - return int64(x), nil - case int64: - if x < 0 { - return 0, invNegLO(x) - } - - return int64(x), nil - case uint8: - return int64(x), nil - case uint16: - return int64(x), nil - case uint32: - return int64(x), nil - case uint64: - return int64(x), nil - default: - return 0, fmt.Errorf("non-integer expression: %v (value of type %T)", x, x) - } -} - -func limOffExpr(x interface{}) (i uint64, err error) { - switch x := x.(type) { - case idealInt: - if x < 0 { - return 0, invNegLO(x) - } - - return uint64(x), nil - case idealRune: - if x < 0 { - return 0, invNegLO(x) - } - - return uint64(x), nil - case idealUint: - if x < 0 { - return 0, invNegLO(x) - } - - return uint64(x), nil - case int8: - if x < 0 { - return 0, invNegLO(x) - } - - return uint64(x), nil - case int16: - if x < 0 { - return 0, invNegLO(x) - } - - return uint64(x), nil - case int32: - if x < 0 { - return 0, invNegLO(x) - } - - return uint64(x), nil - case int64: - if x < 0 { - return 0, invNegLO(x) - } - - return uint64(x), nil - case uint8: - return uint64(x), nil - case uint16: - return uint64(x), nil - case uint32: - return uint64(x), nil - case uint64: - return uint64(x), nil - default: - return 0, fmt.Errorf("non-integer used in LIMIT or OFFSET: %v (value of type %T)", x, x) - } -} - -func indexExpr(s *string, x interface{}) (i uint64, err error) { - switch x := x.(type) { - case idealFloat: - if x < 0 { - return 0, invNegX(x) - } - - if s != nil && int(x) >= len(*s) { - return 0, invBoundX(*s, uint64(x)) - } - - return uint64(x), nil - case idealInt: - if x < 0 { - return 0, invNegX(x) - } - - if s != nil && int64(x) >= int64(len(*s)) { - return 0, invBoundX(*s, uint64(x)) - } - - return uint64(x), nil - case idealRune: - if x < 0 { - return 0, invNegX(x) - } - - if s != nil && int32(x) >= int32(len(*s)) { - return 0, invBoundX(*s, uint64(x)) - } - - return uint64(x), nil - case idealUint: - if x < 0 { - return 0, invNegX(x) - } - - if s != nil && uint64(x) >= uint64(len(*s)) { - return 0, invBoundX(*s, uint64(x)) - } - - return uint64(x), nil - case int8: - if x < 0 { - return 0, invNegX(x) - } - - if s != nil && int(x) >= len(*s) { - return 0, invBoundX(*s, uint64(x)) - } - - return uint64(x), nil - case int16: - if x < 0 { - return 0, invNegX(x) - } - - if s != nil && int(x) >= len(*s) { - return 0, invBoundX(*s, uint64(x)) - } - - return uint64(x), nil - case int32: - if x < 0 { - return 0, invNegX(x) - } - - if s != nil && int(x) >= len(*s) { - return 0, invBoundX(*s, uint64(x)) - } - - return uint64(x), nil - case int64: - if x < 0 { - return 0, invNegX(x) - } - - if s != nil && x >= int64(len(*s)) { - return 0, invBoundX(*s, uint64(x)) - } - - return uint64(x), nil - case uint8: - if s != nil && int(x) >= len(*s) { - return 0, invBoundX(*s, uint64(x)) - } - - return uint64(x), nil - case uint16: - if s != nil && int(x) >= len(*s) { - return 0, invBoundX(*s, uint64(x)) - } - - return uint64(x), nil - case uint32: - if s != nil && x >= uint32(len(*s)) { - return 0, invBoundX(*s, uint64(x)) - } - - return uint64(x), nil - case uint64: - if s != nil && x >= uint64(len(*s)) { - return 0, invBoundX(*s, uint64(x)) - } - - return uint64(x), nil - default: - return 0, fmt.Errorf("non-integer string index %v (value of type %T)", x, x) - } -} - -func sliceExpr(s *string, x interface{}, mod int) (i uint64, err error) { - switch x := x.(type) { - case idealFloat: - if x < 0 { - return 0, invSliceNegX(x) - } - - if s != nil && int(x) >= len(*s)+mod { - return 0, invSliceBoundX(*s, uint64(x)) - } - - return uint64(x), nil - case idealInt: - if x < 0 { - return 0, invSliceNegX(x) - } - - if s != nil && int64(x) >= int64(len(*s)+mod) { - return 0, invSliceBoundX(*s, uint64(x)) - } - - return uint64(x), nil - case idealRune: - if x < 0 { - return 0, invSliceNegX(x) - } - - if s != nil && int32(x) >= int32(len(*s)+mod) { - return 0, invSliceBoundX(*s, uint64(x)) - } - - return uint64(x), nil - case idealUint: - if x < 0 { - return 0, invSliceNegX(x) - } - - if s != nil && uint64(x) >= uint64(len(*s)+mod) { - return 0, invSliceBoundX(*s, uint64(x)) - } - - return uint64(x), nil - case int8: - if x < 0 { - return 0, invSliceNegX(x) - } - - if s != nil && int(x) >= len(*s)+mod { - return 0, invSliceBoundX(*s, uint64(x)) - } - - return uint64(x), nil - case int16: - if x < 0 { - return 0, invSliceNegX(x) - } - - if s != nil && int(x) >= len(*s)+mod { - return 0, invSliceBoundX(*s, uint64(x)) - } - - return uint64(x), nil - case int32: - if x < 0 { - return 0, invSliceNegX(x) - } - - if s != nil && int(x) >= len(*s)+mod { - return 0, invSliceBoundX(*s, uint64(x)) - } - - return uint64(x), nil - case int64: - if x < 0 { - return 0, invSliceNegX(x) - } - - if s != nil && x >= int64(len(*s)+mod) { - return 0, invSliceBoundX(*s, uint64(x)) - } - - return uint64(x), nil - case uint8: - if s != nil && int(x) >= len(*s)+mod { - return 0, invSliceBoundX(*s, uint64(x)) - } - - return uint64(x), nil - case uint16: - if s != nil && int(x) >= len(*s)+mod { - return 0, invSliceBoundX(*s, uint64(x)) - } - - return uint64(x), nil - case uint32: - if s != nil && x >= uint32(len(*s)+mod) { - return 0, invSliceBoundX(*s, uint64(x)) - } - - return uint64(x), nil - case uint64: - if s != nil && x >= uint64(len(*s)+mod) { - return 0, invSliceBoundX(*s, uint64(x)) - } - - return uint64(x), nil - default: - return 0, fmt.Errorf("invalid slice index %s (type %T)", x, x) - } -} - -type iop int - -func (o iop) String() string { - switch i := int(o); i { - case andand: - return "&&" - case andnot: - return "&^" - case lsh: - return "<<" - case le: - return "<=" - case eq: - return "==" - case ge: - return ">=" - case neq: - return "!=" - case oror: - return "||" - case rsh: - return ">>" - default: - return string(i) - } -} - -func ideal(v interface{}) interface{} { - switch x := v.(type) { - case idealComplex: - return complex128(x) - case idealFloat: - return float64(x) - case idealInt: - return int64(x) - case idealRune: - return int64(x) - case idealUint: - return uint64(x) - default: - return v - } -} - -func eval(v expression, execCtx *execCtx, ctx map[interface{}]interface{}) (y interface{}) { - y, err := expand1(v.eval(execCtx, ctx)) - if err != nil { - panic(err) // panic ok here - } - return -} - -func eval2(a, b expression, execCtx *execCtx, ctx map[interface{}]interface{}) (x, y interface{}) { - return eval(a, execCtx, ctx), eval(b, execCtx, ctx) -} - -func invOp2(x, y interface{}, o int) (interface{}, error) { - return nil, fmt.Errorf("invalid operation: %v %v %v (mismatched types %T and %T)", x, iop(o), y, ideal(x), ideal(y)) -} - -func undOp(x interface{}, o int) (interface{}, error) { - return nil, fmt.Errorf("invalid operation: %v%v (operator %v not defined on %T)", iop(o), x, iop(o), x) -} - -func undOp2(x, y interface{}, o int) (interface{}, error) { - return nil, fmt.Errorf("invalid operation: %v %v %v (operator %v not defined on %T)", x, iop(o), y, iop(o), x) -} - -func invConv(val interface{}, typ int) (interface{}, error) { - return nil, fmt.Errorf("cannot convert %v (type %T) to type %s", val, val, typeStr(typ)) -} - -func truncConv(val interface{}) (interface{}, error) { - return nil, fmt.Errorf("constant %v truncated to integer", val) -} - -func convert(val interface{}, typ int) (v interface{}, err error) { //NTYPE - if val == nil { - return nil, nil - } - - switch typ { - case qBool: - switch x := val.(type) { - //case nil: - //case idealComplex: - //case idealFloat: - //case idealInt: - //case idealRune: - //case idealUint: - case bool: - return bool(x), nil - //case complex64: - //case complex128: - //case float32: - //case float64: - //case int8: - //case int16: - //case int32: - //case int64: - //case string: - //case uint8: - //case uint16: - //case uint32: - //case uint64: - default: - return invConv(val, typ) - } - case qComplex64: - switch x := val.(type) { - //case nil: - case idealComplex: - return complex64(x), nil - case idealFloat: - return complex(float32(x), 0), nil - case idealInt: - return complex(float32(x), 0), nil - case idealRune: - return complex(float32(x), 0), nil - case idealUint: - return complex(float32(x), 0), nil - //case bool: - case complex64: - return complex64(x), nil - case complex128: - return complex64(x), nil - //case float32: - //case float64: - //case int8: - //case int16: - //case int32: - //case int64: - //case string: - //case uint8: - //case uint16: - //case uint32: - //case uint64: - default: - return invConv(val, typ) - } - case qComplex128: - switch x := val.(type) { - //case nil: - case idealComplex: - return complex128(x), nil - case idealFloat: - return complex(float64(x), 0), nil - case idealInt: - return complex(float64(x), 0), nil - case idealRune: - return complex(float64(x), 0), nil - case idealUint: - return complex(float64(x), 0), nil - //case bool: - case complex64: - return complex128(x), nil - case complex128: - return complex128(x), nil - //case float32: - //case float64: - //case int8: - //case int16: - //case int32: - //case int64: - //case string: - //case uint8: - //case uint16: - //case uint32: - //case uint64: - default: - return invConv(val, typ) - } - case qFloat32: - switch x := val.(type) { - //case nil: - //case idealComplex: - case idealFloat: - return float32(x), nil - case idealInt: - return float32(x), nil - case idealRune: - return float32(x), nil - case idealUint: - return float32(x), nil - //case bool: - //case complex64: - //case complex128: - case float32: - return float32(x), nil - case float64: - return float32(x), nil - case int8: - return float32(x), nil - case int16: - return float32(x), nil - case int32: - return float32(x), nil - case int64: - return float32(x), nil - //case string: - case uint8: - return float32(x), nil - case uint16: - return float32(x), nil - case uint32: - return float32(x), nil - case uint64: - return float32(x), nil - case *big.Int: - v, _ := big.NewRat(1, 1).SetInt(x).Float64() - return float32(v), nil - case *big.Rat: - v, _ := x.Float64() - return float32(v), nil - case time.Duration: - return float32(x), nil - default: - return invConv(val, typ) - } - case qFloat64: - switch x := val.(type) { - //case nil: - //case idealComplex: - case idealFloat: - return float64(x), nil - case idealInt: - return float64(x), nil - case idealRune: - return float64(x), nil - case idealUint: - return float64(x), nil - //case bool: - //case complex64: - //case complex128: - case float32: - return float64(x), nil - case float64: - return float64(x), nil - case int8: - return float64(x), nil - case int16: - return float64(x), nil - case int32: - return float64(x), nil - case int64: - return float64(x), nil - //case string: - case uint8: - return float64(x), nil - case uint16: - return float64(x), nil - case uint32: - return float64(x), nil - case uint64: - return float64(x), nil - case *big.Int: - v, _ := big.NewRat(1, 1).SetInt(x).Float64() - return v, nil - case *big.Rat: - v, _ := x.Float64() - return v, nil - case time.Duration: - return float64(x), nil - default: - return invConv(val, typ) - } - case qInt8: - switch x := val.(type) { - //case nil: - //case idealComplex: - case idealFloat: - if _, frac := math.Modf(float64(x)); frac != 0 { - return truncConv(x) - } - - return int8(x), nil - case idealInt: - return int8(x), nil - case idealRune: - return int8(x), nil - case idealUint: - return int8(x), nil - //case bool: - //case complex64: - //case complex128: - case float32: - return int8(x), nil - case float64: - return int8(x), nil - case int8: - return int8(x), nil - case int16: - return int8(x), nil - case int32: - return int8(x), nil - case int64: - return int8(x), nil - //case string: - case uint8: - return int8(x), nil - case uint16: - return int8(x), nil - case uint32: - return int8(x), nil - case uint64: - return int8(x), nil - case *big.Int: - return int8(x.Int64()), nil - case time.Duration: - return int8(x), nil - default: - return invConv(val, typ) - } - case qInt16: - switch x := val.(type) { - //case nil: - //case idealComplex: - case idealFloat: - if _, frac := math.Modf(float64(x)); frac != 0 { - return truncConv(x) - } - - return int16(x), nil - case idealInt: - return int16(x), nil - case idealRune: - return int16(x), nil - case idealUint: - return int16(x), nil - //case bool: - //case complex64: - //case complex128: - case float32: - return int16(x), nil - case float64: - return int16(x), nil - case int8: - return int16(x), nil - case int16: - return int16(x), nil - case int32: - return int16(x), nil - case int64: - return int16(x), nil - //case string: - case uint8: - return int16(x), nil - case uint16: - return int16(x), nil - case uint32: - return int16(x), nil - case uint64: - return int16(x), nil - case *big.Int: - return int16(x.Int64()), nil - case time.Duration: - return int16(x), nil - default: - return invConv(val, typ) - } - case qInt32: - switch x := val.(type) { - //case nil: - //case idealComplex: - case idealFloat: - if _, frac := math.Modf(float64(x)); frac != 0 { - return truncConv(x) - } - - return int32(x), nil - case idealInt: - return int32(x), nil - case idealRune: - return int32(x), nil - case idealUint: - return int32(x), nil - //case bool: - //case complex64: - //case complex128: - case float32: - return int32(x), nil - case float64: - return int32(x), nil - case int8: - return int32(x), nil - case int16: - return int32(x), nil - case int32: - return int32(x), nil - case int64: - return int32(x), nil - //case string: - case uint8: - return int32(x), nil - case uint16: - return int32(x), nil - case uint32: - return int32(x), nil - case uint64: - return int32(x), nil - case *big.Int: - return int32(x.Int64()), nil - case time.Duration: - return int32(x), nil - default: - return invConv(val, typ) - } - case qInt64: - switch x := val.(type) { - //case nil: - //case idealComplex: - case idealFloat: - if _, frac := math.Modf(float64(x)); frac != 0 { - return truncConv(x) - } - - return int64(x), nil - case idealInt: - return int64(x), nil - case idealRune: - return int64(x), nil - case idealUint: - return int64(x), nil - //case bool: - //case complex64: - //case complex128: - case float32: - return int64(x), nil - case float64: - return int64(x), nil - case int8: - return int64(x), nil - case int16: - return int64(x), nil - case int32: - return int64(x), nil - case int64: - return int64(x), nil - //case string: - case uint8: - return int64(x), nil - case uint16: - return int64(x), nil - case uint32: - return int64(x), nil - case uint64: - return int64(x), nil - case *big.Int: - return x.Int64(), nil - case time.Duration: - return int64(x), nil - default: - return invConv(val, typ) - } - case qString: - switch x := val.(type) { - //case nil: - //case idealComplex: - //case idealFloat: - case idealInt: - return string(x), nil - case idealRune: - return string(x), nil - case idealUint: - return string(x), nil - //case bool: - //case complex64: - //case complex128: - //case float32: - //case float64: - case int8: - return string(x), nil - case int16: - return string(x), nil - case int32: - return string(x), nil - case int64: - return string(x), nil - case string: - return string(x), nil - case uint8: - return string(x), nil - case uint16: - return string(x), nil - case uint32: - return string(x), nil - case uint64: - return string(x), nil - case []byte: - return string(x), nil - case *big.Int: - return x.String(), nil - case time.Time: - return x.String(), nil - case time.Duration: - return x.String(), nil - default: - return invConv(val, typ) - } - case qUint8: - switch x := val.(type) { - //case nil: - //case idealComplex: - case idealFloat: - if _, frac := math.Modf(float64(x)); frac != 0 { - return truncConv(x) - } - - return uint8(x), nil - case idealInt: - return uint8(x), nil - case idealRune: - return uint8(x), nil - case idealUint: - return uint8(x), nil - //case bool: - //case complex64: - //case complex128: - case float32: - return uint8(x), nil - case float64: - return uint8(x), nil - case int8: - return uint8(x), nil - case int16: - return uint8(x), nil - case int32: - return uint8(x), nil - case int64: - return uint8(x), nil - //case string: - case uint8: - return uint8(x), nil - case uint16: - return uint8(x), nil - case uint32: - return uint8(x), nil - case uint64: - return uint8(x), nil - case *big.Int: - return uint8(x.Int64()), nil - case time.Duration: - return uint8(x), nil - default: - return invConv(val, typ) - } - case qUint16: - switch x := val.(type) { - //case nil: - //case idealComplex: - case idealFloat: - if _, frac := math.Modf(float64(x)); frac != 0 { - return truncConv(x) - } - - return uint16(x), nil - case idealInt: - return uint16(x), nil - case idealRune: - return uint16(x), nil - case idealUint: - return uint16(x), nil - //case bool: - //case complex64: - //case complex128: - case float32: - return uint16(x), nil - case float64: - return uint16(x), nil - case int8: - return uint16(x), nil - case int16: - return uint16(x), nil - case int32: - return uint16(x), nil - case int64: - return uint16(x), nil - //case string: - case uint8: - return uint16(x), nil - case uint16: - return uint16(x), nil - case uint32: - return uint16(x), nil - case uint64: - return uint16(x), nil - case *big.Int: - return uint16(x.Int64()), nil - case time.Duration: - return uint16(x), nil - default: - return invConv(val, typ) - } - case qUint32: - switch x := val.(type) { - //case nil: - //case idealComplex: - case idealFloat: - if _, frac := math.Modf(float64(x)); frac != 0 { - return truncConv(x) - } - - return uint32(x), nil - case idealInt: - return uint32(x), nil - case idealRune: - return uint32(x), nil - case idealUint: - return uint32(x), nil - //case bool: - //case complex64: - //case complex128: - case float32: - return uint32(x), nil - case float64: - return uint32(x), nil - case int8: - return uint32(x), nil - case int16: - return uint32(x), nil - case int32: - return uint32(x), nil - case int64: - return uint32(x), nil - //case string: - case uint8: - return uint32(x), nil - case uint16: - return uint32(x), nil - case uint32: - return uint32(x), nil - case uint64: - return uint32(x), nil - case *big.Int: - return uint32(x.Int64()), nil - case time.Duration: - return uint32(x), nil - default: - return invConv(val, typ) - } - case qUint64: - switch x := val.(type) { - //case nil: - //case idealComplex: - case idealFloat: - if _, frac := math.Modf(float64(x)); frac != 0 { - return truncConv(x) - } - - return uint64(x), nil - case idealInt: - return uint64(x), nil - case idealRune: - return uint64(x), nil - case idealUint: - return uint64(x), nil - //case bool: - //case complex64: - //case complex128: - case float32: - return uint64(x), nil - case float64: - return uint64(x), nil - case int8: - return uint64(x), nil - case int16: - return uint64(x), nil - case int32: - return uint64(x), nil - case int64: - return uint64(x), nil - //case string: - case uint8: - return uint64(x), nil - case uint16: - return uint64(x), nil - case uint32: - return uint64(x), nil - case uint64: - return uint64(x), nil - case *big.Int: - return x.Uint64(), nil - case time.Duration: - return uint64(x), nil - default: - return invConv(val, typ) - } - case qBlob: - switch x := val.(type) { - case string: - return []byte(x), nil - case []byte: - return x, nil - default: - return invConv(val, typ) - } - case qBigInt: - switch x := val.(type) { - // case blob - // case bool - //case idealComplex: - case idealFloat: - if _, frac := math.Modf(float64(x)); frac != 0 { - return truncConv(x) - } - - rr := big.NewRat(1, 1).SetFloat64(float64(x)) - ii := big.NewInt(0).Set(rr.Num()) - ii.Quo(ii, rr.Denom()) - return ii, nil - case idealInt: - return big.NewInt(0).SetInt64(int64(x)), nil - case idealRune: - return big.NewInt(0).SetInt64(int64(x)), nil - case idealUint: - return big.NewInt(0).SetUint64(uint64(x)), nil - //case complex64 - //case complex128 - case float32: - rr := big.NewRat(1, 1).SetFloat64(float64(x)) - ii := big.NewInt(0).Set(rr.Num()) - ii.Quo(ii, rr.Denom()) - return ii, nil - case float64: - rr := big.NewRat(1, 1).SetFloat64(float64(x)) - ii := big.NewInt(0).Set(rr.Num()) - ii.Quo(ii, rr.Denom()) - return ii, nil - case int8: - return big.NewInt(0).SetInt64(int64(x)), nil - case int16: - return big.NewInt(0).SetInt64(int64(x)), nil - case int32: - return big.NewInt(0).SetInt64(int64(x)), nil - case int64: - return big.NewInt(0).SetInt64(x), nil - case string: - y := big.NewInt(0) - if _, ok := y.SetString(x, 0); !ok { - return invConv(val, typ) - } - - return y, nil - case uint8: - return big.NewInt(0).SetUint64(uint64(x)), nil - case uint16: - return big.NewInt(0).SetUint64(uint64(x)), nil - case uint32: - return big.NewInt(0).SetUint64(uint64(x)), nil - case uint64: - return big.NewInt(0).SetUint64(x), nil - case *big.Int: - return x, nil - case *big.Rat: - ii := big.NewInt(0).Set(x.Num()) - ii.Div(ii, x.Denom()) - return ii, nil - default: - return invConv(val, typ) - } - case qBigRat: - switch x := val.(type) { - // case blob - // case bool - //case idealComplex: - case idealFloat: - return big.NewRat(1, 1).SetFloat64(float64(x)), nil - case idealInt: - return big.NewRat(1, 1).SetInt64(int64(x)), nil - case idealRune: - return big.NewRat(1, 1).SetInt64(int64(x)), nil - case idealUint: - return big.NewRat(1, 1).SetInt(big.NewInt(0).SetUint64(uint64(x))), nil - //case complex64 - //case complex128 - case float32: - return big.NewRat(1, 1).SetFloat64(float64(x)), nil - case float64: - return big.NewRat(1, 1).SetFloat64(x), nil - case int8: - return big.NewRat(1, 1).SetInt64(int64(x)), nil - case int16: - return big.NewRat(1, 1).SetInt64(int64(x)), nil - case int32: - return big.NewRat(1, 1).SetInt64(int64(x)), nil - case int64: - return big.NewRat(1, 1).SetInt64(x), nil - case string: - y := big.NewRat(1, 1) - if _, ok := y.SetString(x); !ok { - return invConv(val, typ) - } - - return y, nil - case uint8: - return big.NewRat(1, 1).SetInt64(int64(x)), nil - case uint16: - return big.NewRat(1, 1).SetInt64(int64(x)), nil - case uint32: - return big.NewRat(1, 1).SetInt64(int64(x)), nil - case uint64: - return big.NewRat(1, 1).SetInt(big.NewInt(0).SetUint64(x)), nil - case *big.Int: - return big.NewRat(1, 1).SetInt(x), nil - case *big.Rat: - return x, nil - default: - return invConv(val, typ) - } - case qDuration: - switch x := val.(type) { - // case blob - // case bool - //case idealComplex: - case idealFloat: - return time.Duration(x), nil - case idealInt: - return time.Duration(x), nil - case idealRune: - return time.Duration(x), nil - case idealUint: - return time.Duration(x), nil - //case complex64 - //case complex128 - case float32: - return time.Duration(x), nil - case float64: - return time.Duration(x), nil - case int8: - return time.Duration(x), nil - case int16: - return time.Duration(x), nil - case int32: - return time.Duration(x), nil - case int64: - return time.Duration(x), nil - case string: - return time.ParseDuration(x) - case uint8: - return time.Duration(x), nil - case uint16: - return time.Duration(x), nil - case uint32: - return time.Duration(x), nil - case uint64: - return time.Duration(x), nil - case *big.Int: - return time.Duration(x.Int64()), nil - case *big.Rat: - f, _ := x.Float64() - return time.Duration(f), nil - case time.Duration: - return x, nil - default: - return invConv(val, typ) - } - case qTime: - switch x := val.(type) { - // case blob - // case bool - //case idealComplex: - //case idealFloat: - //case idealInt: - //case idealRune: - //case idealUint: - //case complex64 - //case complex128 - //case float32: - //case float64: - //case int8: - //case int16: - //case int32: - //case int64: - //case string: - //case uint8: - //case uint16: - //case uint32: - //case uint64: - //case *big.Int: - //case *big.Rat: - //case time.Duration: - case time.Time: - return x, nil - default: - return invConv(val, typ) - } - default: - panic("internal error 006") - } -} - -func invShiftRHS(lhs, rhs interface{}) (interface{}, error) { - return nil, fmt.Errorf("invalid operation: %v << %v (shift count type %T, must be unsigned integer)", lhs, rhs, rhs) -} - -func invTruncInt(v interface{}) error { - return fmt.Errorf("constant %v truncated to integer", v) -} - -func overflow(v interface{}, typ int) error { - return fmt.Errorf("constant %v overflows %s", v, typeStr(typ)) -} - -func typeCheck1(val interface{}, c *col) (interface{}, error) { - rec := []interface{}{val} - c = c.clone() - c.index = 0 - if err := typeCheck(rec, []*col{c}); err != nil { - return nil, err - } - - return rec[0], nil -} - -func typeCheck(rec []interface{}, cols []*col) (err error) { - for _, c := range cols { - i := c.index - if v := rec[i]; !c.typeCheck(v) { - switch v.(type) { - case idealComplex: - y := complex128(v.(idealComplex)) - switch c.typ { - case qBool: - case qComplex64: - rec[i] = complex64(y) - continue - case qComplex128: - rec[i] = complex128(y) - continue - case qFloat32, qFloat64, qInt8, qInt16, qInt32, qInt64, qUint8, qUint16, qUint32, qUint64: - return fmt.Errorf("constant %v truncated to real", y) - } - case idealFloat: - y := float64(v.(idealFloat)) - switch c.typ { - case qBool: - case qComplex64: - rec[i] = complex(float32(y), 0) - continue - case qComplex128: - rec[i] = complex(float64(y), 0) - continue - case qFloat32: - rec[i] = float32(y) - continue - case qFloat64: - rec[i] = float64(y) - continue - case qInt8: - if math.Floor(y) != y { - return invTruncInt(y) - } - - if y < math.MinInt8 || y > math.MaxInt8 { - return overflow(y, c.typ) - } - - rec[i] = int8(y) - continue - case qInt16: - if math.Floor(y) != y { - return invTruncInt(y) - } - - if y < math.MinInt16 || y > math.MaxInt16 { - return overflow(y, c.typ) - } - - rec[i] = int16(y) - continue - case qInt32: - if math.Floor(y) != y { - return invTruncInt(y) - } - - if y < math.MinInt32 || y > math.MaxInt32 { - return overflow(y, c.typ) - } - - rec[i] = int32(y) - continue - case qInt64: - if math.Floor(y) != y { - return invTruncInt(y) - } - - if y < math.MinInt64 || y > math.MaxInt64 { - return overflow(y, c.typ) - } - - rec[i] = int64(y) - continue - case qString: - case qUint8: - if math.Floor(y) != y { - return invTruncInt(y) - } - - if y < 0 || y > math.MaxUint8 { - return overflow(y, c.typ) - } - - rec[i] = uint8(y) - continue - case qUint16: - if math.Floor(y) != y { - return invTruncInt(y) - } - - if y < 0 || y > math.MaxUint16 { - return overflow(y, c.typ) - } - - rec[i] = uint16(y) - continue - case qUint32: - if math.Floor(y) != y { - return invTruncInt(y) - } - - if y < 0 || y > math.MaxUint32 { - return overflow(y, c.typ) - } - - rec[i] = uint32(y) - continue - case qUint64: - if math.Floor(y) != y { - return invTruncInt(y) - } - - if y < 0 || y > math.MaxUint64 { - return overflow(y, c.typ) - } - - rec[i] = uint64(y) - continue - case qBigInt: - if math.Floor(y) != y { - return invTruncInt(y) - } - - rr := big.NewRat(1, 1).SetFloat64(y) - ii := big.NewInt(0) - ii.Set(rr.Num()) - ii.Quo(ii, rr.Denom()) - rec[i] = ii - continue - case qBigRat: - rec[i] = big.NewRat(1, 1).SetFloat64(y) - continue - } - case idealInt: - y := int64(v.(idealInt)) - switch c.typ { - case qBool: - case qComplex64: - rec[i] = complex(float32(y), 0) - continue - case qComplex128: - rec[i] = complex(float64(y), 0) - continue - case qFloat32: - rec[i] = float32(y) - continue - case qFloat64: - rec[i] = float64(y) - continue - case qInt8: - if y < math.MinInt8 || y > math.MaxInt8 { - return overflow(y, c.typ) - } - - rec[i] = int8(y) - continue - case qInt16: - if y < math.MinInt16 || y > math.MaxInt16 { - return overflow(y, c.typ) - } - - rec[i] = int16(y) - continue - case qInt32: - if y < math.MinInt32 || y > math.MaxInt32 { - return overflow(y, c.typ) - } - - rec[i] = int32(y) - continue - case qInt64: - if y < math.MinInt64 || y > math.MaxInt64 { - return overflow(y, c.typ) - } - - rec[i] = int64(y) - continue - case qString: - case qUint8: - if y < 0 || y > math.MaxUint8 { - return overflow(y, c.typ) - } - - rec[i] = uint8(y) - continue - case qUint16: - if y < 0 || y > math.MaxUint16 { - return overflow(y, c.typ) - } - - rec[i] = uint16(y) - continue - case qUint32: - if y < 0 || y > math.MaxUint32 { - return overflow(y, c.typ) - } - - rec[i] = uint32(y) - continue - case qUint64: - if y < 0 { - return overflow(y, c.typ) - } - - rec[i] = uint64(y) - continue - case qBigInt: - rec[i] = big.NewInt(y) - continue - case qBigRat: - rec[i] = big.NewRat(1, 1).SetInt64(y) - continue - } - case idealRune: - y := int64(v.(idealRune)) - switch c.typ { - case qBool: - case qComplex64: - rec[i] = complex(float32(y), 0) - continue - case qComplex128: - rec[i] = complex(float64(y), 0) - continue - case qFloat32: - rec[i] = float32(y) - continue - case qFloat64: - rec[i] = float64(y) - continue - case qInt8: - if y < math.MinInt8 || y > math.MaxInt8 { - return overflow(y, c.typ) - } - - rec[i] = int8(y) - continue - case qInt16: - if y < math.MinInt16 || y > math.MaxInt16 { - return overflow(y, c.typ) - } - - rec[i] = int16(y) - continue - case qInt32: - if y < math.MinInt32 || y > math.MaxInt32 { - return overflow(y, c.typ) - } - - rec[i] = int32(y) - continue - case qInt64: - if y < math.MinInt64 || y > math.MaxInt64 { - return overflow(y, c.typ) - } - - rec[i] = int64(y) - continue - case qString: - case qUint8: - if y < 0 || y > math.MaxUint8 { - return overflow(y, c.typ) - } - - rec[i] = uint8(y) - continue - case qUint16: - if y < 0 || y > math.MaxUint16 { - return overflow(y, c.typ) - } - - rec[i] = uint16(y) - continue - case qUint32: - if y < 0 { - return overflow(y, c.typ) - } - - rec[i] = uint32(y) - continue - case qUint64: - if y < 0 { - return overflow(y, c.typ) - } - - rec[i] = uint64(y) - continue - case qBigInt: - rec[i] = big.NewInt(y) - continue - case qBigRat: - rec[i] = big.NewRat(1, 1).SetInt64(y) - continue - } - case idealUint: - y := uint64(v.(idealUint)) - switch c.typ { - case qBool: - case qComplex64: - rec[i] = complex(float32(y), 0) - continue - case qComplex128: - rec[i] = complex(float64(y), 0) - continue - case qFloat32: - rec[i] = float32(y) - continue - case qFloat64: - rec[i] = float64(y) - continue - case qInt8: - if y > math.MaxInt8 { - return overflow(y, c.typ) - } - - rec[i] = int8(y) - continue - case qInt16: - if y > math.MaxInt16 { - return overflow(y, c.typ) - } - - rec[i] = int16(y) - continue - case qInt32: - if y > math.MaxInt32 { - return overflow(y, c.typ) - } - - rec[i] = int32(y) - continue - case qInt64: - if y > math.MaxInt64 { - return overflow(y, c.typ) - } - - rec[i] = int64(y) - continue - case qString: - rec[i] = string(y) - continue - case qUint8: - if y > math.MaxUint8 { - return overflow(y, c.typ) - } - - rec[i] = uint8(y) - continue - case qUint16: - if y > math.MaxUint16 { - return overflow(y, c.typ) - } - - rec[i] = uint16(y) - continue - case qUint32: - if y > math.MaxUint32 { - return overflow(y, c.typ) - } - - rec[i] = uint32(y) - continue - case qUint64: - rec[i] = uint64(y) - continue - case qBigInt: - rec[i] = big.NewInt(0).SetUint64(y) - continue - case qBigRat: - ii := big.NewInt(0).SetUint64(y) - rec[i] = big.NewRat(1, 1).SetInt(ii) - continue - } - } - return fmt.Errorf("cannot use %v (type %T) in assignment to, or comparison with, column %s (type %s)", v, ideal(v), c.name, typeStr(c.typ)) - } - } - return -} - -//TODO collate1 should return errors instead of panicing -func collate1(a, b interface{}) int { - switch x := a.(type) { - case nil: - if b != nil { - return -1 - } - - return 0 - case bool: - switch y := b.(type) { - case nil: - return 1 - case bool: - if !x && y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - default: - // Make bool collate before anything except nil and - // other bool for index seeking first non NULL value. - return -1 - } - case idealComplex: - switch y := b.(type) { - case nil: - return 1 - case idealComplex: - if x == y { - return 0 - } - - if real(x) < real(y) { - return -1 - } - - if real(x) > real(y) { - return 1 - } - - if imag(x) < imag(y) { - return -1 - } - - return 1 - case complex64: - { - x, y := complex64(x), complex64(y) - if x == y { - return 0 - } - - if real(x) < real(y) { - return -1 - } - - if real(x) > real(y) { - return 1 - } - - if imag(x) < imag(y) { - return -1 - } - - return 1 - } - case complex128: - { - x := complex128(x) - if x == y { - return 0 - } - - if real(x) < real(y) { - return -1 - } - - if real(x) > real(y) { - return 1 - } - - if imag(x) < imag(y) { - return -1 - } - - return 1 - } - default: - panic("internal error 012") - } - case idealUint: - switch y := b.(type) { - case nil: - return 1 - case idealUint: - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - case uint8: - { - x, y := uint64(x), uint64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - case uint16: - { - x, y := uint64(x), uint64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - case uint32: - { - x, y := uint64(x), uint64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - case uint64: - { - x, y := uint64(x), uint64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - case uint: - { - x, y := uint64(x), uint64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - default: - panic("internal error 013") - } - case idealRune: - switch y := b.(type) { - case nil: - return 1 - case idealRune: - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - case int8: - { - x, y := int64(x), int64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - case int16: - { - x, y := int64(x), int64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - case int32: - { - x, y := int64(x), int64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - case int64: - { - x, y := int64(x), int64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - case int: - { - x, y := int64(x), int64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - default: - panic("internal error 014") - } - case idealInt: - switch y := b.(type) { - case nil: - return 1 - case idealInt: - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - case int8: - { - x, y := int64(x), int64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - case int16: - { - x, y := int64(x), int64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - case int32: - { - x, y := int64(x), int64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - case int64: - { - x, y := int64(x), int64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - case int: - { - x, y := int64(x), int64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - default: - panic("internal error 015") - } - case idealFloat: - switch y := b.(type) { - case nil: - return 1 - case idealFloat: - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - case float32: - { - x, y := float64(x), float64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - case float64: - { - x, y := float64(x), float64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - default: - panic("internal error 016") - } - case complex64: - switch y := b.(type) { - case nil: - return 1 - case complex64: - if x == y { - return 0 - } - - if real(x) < real(y) { - return -1 - } - - if real(x) > real(y) { - return 1 - } - - if imag(x) < imag(y) { - return -1 - } - - return 1 - case idealComplex: - { - x, y := complex64(x), complex64(y) - if x == y { - return 0 - } - - if real(x) < real(y) { - return -1 - } - - if real(x) > real(y) { - return 1 - } - - if imag(x) < imag(y) { - return -1 - } - - return 1 - } - default: - panic("internal error 017") - } - case complex128: - switch y := b.(type) { - case nil: - return 1 - case complex128: - if x == y { - return 0 - } - - if real(x) < real(y) { - return -1 - } - - if real(x) > real(y) { - return 1 - } - - if imag(x) < imag(y) { - return -1 - } - - return 1 - case idealComplex: - { - x, y := complex128(x), complex128(y) - if x == y { - return 0 - } - - if real(x) < real(y) { - return -1 - } - - if real(x) > real(y) { - return 1 - } - - if imag(x) < imag(y) { - return -1 - } - - return 1 - } - default: - panic("internal error 018") - } - case float32: - switch y := b.(type) { - case nil: - return 1 - case float32: - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - case idealFloat: - { - x, y := float32(x), float32(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - default: - panic("internal error 019") - } - case float64: - switch y := b.(type) { - case nil: - return 1 - case float64: - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - case idealFloat: - { - x, y := float64(x), float64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - default: - panic("internal error 020") - } - case int8: - switch y := b.(type) { - case nil: - return 1 - case int8: - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - case idealInt: - { - x, y := int64(x), int64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - default: - panic("internal error 021") - } - case int16: - switch y := b.(type) { - case nil: - return 1 - case int16: - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - case idealInt: - { - x, y := int64(x), int64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - default: - panic("internal error 022") - } - case int32: - switch y := b.(type) { - case nil: - return 1 - case int32: - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - case idealInt: - { - x, y := int64(x), int64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - default: - panic("internal error 023") - } - case int64: - switch y := b.(type) { - case nil: - return 1 - case int64: - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - case idealInt: - { - x, y := int64(x), int64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - default: - panic("internal error 024") - } - case uint8: - switch y := b.(type) { - case nil: - return 1 - case uint8: - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - case idealInt: - { - x, y := uint64(x), uint64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - case idealUint: - { - x, y := uint64(x), uint64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - default: - panic("internal error 025") - } - case uint16: - switch y := b.(type) { - case nil: - return 1 - case uint16: - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - case idealInt: - { - x, y := uint64(x), uint64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - case idealUint: - { - x, y := uint64(x), uint64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - default: - panic("internal error 026") - } - case uint32: - switch y := b.(type) { - case nil: - return 1 - case uint32: - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - case idealInt: - { - x, y := uint64(x), uint64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - case idealUint: - { - x, y := uint64(x), uint64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - default: - panic("internal error 027") - } - case uint64: - switch y := b.(type) { - case nil: - return 1 - case uint64: - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - case idealInt: - { - x, y := uint64(x), uint64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - case idealUint: - { - x, y := uint64(x), uint64(y) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - } - default: - panic("internal error 028") - } - case string: - switch y := b.(type) { - case nil: - return 1 - case string: - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - default: - panic("internal error 029") - } - case []byte: - switch y := b.(type) { - case nil: - return 1 - case []byte: - return bytes.Compare(x, y) - default: - panic("internal error 030") - } - case *big.Int: - switch y := b.(type) { - case nil: - return 1 - case *big.Int: - return x.Cmp(y) - case idealInt: - { - y := big.NewInt(int64(y)) - return x.Cmp(y) - } - case idealUint: - { - u := big.NewInt(0) - u.SetUint64(uint64(y)) - return x.Cmp(u) - } - default: - panic("internal error 031") - } - case *big.Rat: - switch y := b.(type) { - case nil: - return 1 - case *big.Rat: - return x.Cmp(y) - case idealInt: - { - y := big.NewRat(int64(y), 1) - return x.Cmp(y) - } - case idealUint: - { - u := big.NewInt(0) - u.SetUint64(uint64(y)) - var y big.Rat - y.SetInt(u) - return x.Cmp(&y) - } - default: - panic("internal error 032") - } - case time.Time: - switch y := b.(type) { - case nil: - return 1 - case time.Time: - if x.Before(y) { - return -1 - } - - if x.Equal(y) { - return 0 - } - - return 1 - default: - panic("internal error 033") - } - case time.Duration: - switch y := b.(type) { - case nil: - return 1 - case time.Duration: - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - default: - panic("internal error 034") - } - case chunk: - switch y := b.(type) { - case nil: - return 1 - case chunk: - a, err := x.expand() - if err != nil { - panic(err) - } - - b, err := y.expand() - if err != nil { - panic(err) - } - - return collate1(a, b) - default: - panic("internal error 035") - } - default: - //dbg("%T(%v) %T(%v)", a, a, b, b) - panic("internal error 036") - } -} - -//TODO collate should return errors from collate1 -func collate(x, y []interface{}) (r int) { - //defer func() { dbg("%v %v -> %v", x, y, r) }() - nx, ny := len(x), len(y) - - switch { - case nx == 0 && ny != 0: - return -1 - case nx == 0 && ny == 0: - return 0 - case nx != 0 && ny == 0: - return 1 - } - - r = 1 - if nx > ny { - x, y, r = y, x, -r - } - - for i, xi := range x { - if c := collate1(xi, y[i]); c != 0 { - return c * r - } - } - - if nx == ny { - return 0 - } - - return -r -} - -var collators = map[bool]func(a, b []interface{}) int{false: collateDesc, true: collate} - -func collateDesc(a, b []interface{}) int { - return -collate(a, b) -} - -func isOrderedType(v interface{}) (y interface{}, r bool, err error) { - //dbg("====") - //dbg("%T(%v)", v, v) - //defer func() { dbg("%T(%v)", y, y) }() - switch x := v.(type) { - case idealFloat, idealInt, idealRune, idealUint, - float32, float64, - int8, int16, int32, int64, - uint8, uint16, uint32, uint64, - string: - return v, true, nil - case *big.Int, *big.Rat, time.Time, time.Duration: - return x, true, nil - case chunk: - if y, err = x.expand(); err != nil { - return - } - - return isOrderedType(y) - } - - return v, false, nil -} - -var isSystemName = map[string]bool{ - "__Column": true, - "__Column2": true, - "__Index": true, - "__Index2": true, - "__Index2_Column": true, - "__Index2_Expr": true, - "__Table": true, -} - -func qualifier(s string) string { - if pos := strings.IndexByte(s, '.'); pos >= 0 { - s = s[:pos] - } - return s -} - -func mustQualifier(s string) string { - q := qualifier(s) - if q == s { - panic("internal error 068") - } - - return q -} - -func selector(s string) string { - if pos := strings.IndexByte(s, '.'); pos >= 0 { - s = s[pos+1:] - } - return s -} - -func mustSelector(s string) string { - q := selector(s) - if q == s { - panic("internal error 053") - } - - return q -} - -func qnames(l []string) []string { - r := make([]string, len(l)) - for i, v := range l { - r[i] = fmt.Sprintf("%q", v) - } - return r -} diff --git a/Godeps/_workspace/src/github.com/cznic/ql/expr.go b/Godeps/_workspace/src/github.com/cznic/ql/expr.go deleted file mode 100644 index 3e6954fbe6..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/expr.go +++ /dev/null @@ -1,4023 +0,0 @@ -// Copyright 2014 The ql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found pIn the LICENSE file. - -package ql - -import ( - "fmt" - "math/big" - "regexp" - "strings" - "time" -) - -var ( - _ expression = (*binaryOperation)(nil) - _ expression = (*call)(nil) - _ expression = (*conversion)(nil) - _ expression = (*ident)(nil) - _ expression = (*indexOp)(nil) - _ expression = (*isNull)(nil) - _ expression = (*pIn)(nil) - _ expression = (*pLike)(nil) - _ expression = (*parameter)(nil) - _ expression = (*pexpr)(nil) - _ expression = (*slice)(nil) - _ expression = (*unaryOperation)(nil) - _ expression = value{} -) - -type expression interface { - clone(arg []interface{}, unqualify ...string) (expression, error) - eval(execCtx *execCtx, ctx map[interface{}]interface{}) (v interface{}, err error) - isStatic() bool - String() string -} - -func cloneExpressionList(arg []interface{}, list []expression, unqualify ...string) ([]expression, error) { - r := make([]expression, len(list)) - var err error - for i, v := range list { - if r[i], err = v.clone(arg, unqualify...); err != nil { - return nil, err - } - } - return r, nil -} - -func isConstValue(v interface{}) interface{} { - switch x := v.(type) { - case value: - return x.val - case - idealComplex, - idealFloat, - idealInt, - idealRune, - idealUint: - return v - default: - return nil - } -} - -func isColumnExpression(v expression) (bool, string) { - x, ok := v.(*ident) - if ok { - return true, x.s - } - - c, ok := v.(*call) - if !ok || c.f != "id" || len(c.arg) != 0 { - return false, "" - } - - return true, "id()" -} - -func mentionedColumns0(e expression, q, nq bool, m map[string]struct{}) { - switch x := e.(type) { - case parameter, - value: - // nop - case *binaryOperation: - mentionedColumns0(x.l, q, nq, m) - mentionedColumns0(x.r, q, nq, m) - case *call: - if x.f != "id" { - for _, e := range x.arg { - mentionedColumns0(e, q, nq, m) - } - } - case *conversion: - mentionedColumns0(x.val, q, nq, m) - case *ident: - if q && x.isQualified() { - m[x.s] = struct{}{} - } - if nq && !x.isQualified() { - m[x.s] = struct{}{} - } - case *indexOp: - mentionedColumns0(x.expr, q, nq, m) - mentionedColumns0(x.x, q, nq, m) - case *isNull: - mentionedColumns0(x.expr, q, nq, m) - case *pexpr: - mentionedColumns0(x.expr, q, nq, m) - case *pIn: - mentionedColumns0(x.expr, q, nq, m) - for _, e := range x.list { - mentionedColumns0(e, q, nq, m) - } - case *pLike: - mentionedColumns0(x.expr, q, nq, m) - mentionedColumns0(x.pattern, q, nq, m) - case *slice: - mentionedColumns0(x.expr, q, nq, m) - if y := x.lo; y != nil { - mentionedColumns0(*y, q, nq, m) - } - if y := x.hi; y != nil { - mentionedColumns0(*y, q, nq, m) - } - case *unaryOperation: - mentionedColumns0(x.v, q, nq, m) - default: - panic("internal error 052") - } -} - -func mentionedColumns(e expression) map[string]struct{} { - m := map[string]struct{}{} - mentionedColumns0(e, false, true, m) - return m -} - -func mentionedQColumns(e expression) map[string]struct{} { - m := map[string]struct{}{} - mentionedColumns0(e, true, false, m) - return m -} - -func staticExpr(e expression) (expression, error) { - if e.isStatic() { - v, err := e.eval(nil, nil) - if err != nil { - return nil, err - } - - if v == nil { - return value{nil}, nil - } - - return value{v}, nil - } - - return e, nil -} - -type ( - idealComplex complex128 - idealFloat float64 - idealInt int64 - idealRune int32 - idealUint uint64 -) - -type exprTab struct { - expr expression - table string -} - -type pexpr struct { - expr expression -} - -func (p *pexpr) clone(arg []interface{}, unqualify ...string) (expression, error) { - expr, err := p.expr.clone(arg, unqualify...) - if err != nil { - return nil, err - } - - return &pexpr{expr: expr}, nil -} - -func (p *pexpr) isStatic() bool { return p.expr.isStatic() } - -func (p *pexpr) String() string { - return fmt.Sprintf("(%s)", p.expr) -} - -func (p *pexpr) eval(execCtx *execCtx, ctx map[interface{}]interface{}) (v interface{}, err error) { - return p.expr.eval(execCtx, ctx) -} - -//DONE newBetween -//LATER like newBetween, check all others have and use new* - -func newBetween(expr, lo, hi interface{}, not bool) (expression, error) { - e, err := staticExpr(expr.(expression)) - if err != nil { - return nil, err - } - - l, err := staticExpr(lo.(expression)) - if err != nil { - return nil, err - } - - h, err := staticExpr(hi.(expression)) - if err != nil { - return nil, err - } - - var a, b expression - op := andand - switch { - case not: // e < l || e > h - op = oror - if a, err = newBinaryOperation('<', e, l); err != nil { - return nil, err - } - - if b, err = newBinaryOperation('>', e, h); err != nil { - return nil, err - } - default: // e >= l && e <= h - if a, err = newBinaryOperation(ge, e, l); err != nil { - return nil, err - } - - if b, err = newBinaryOperation(le, e, h); err != nil { - return nil, err - } - } - - if a, err = staticExpr(a); err != nil { - return nil, err - } - - if b, err = staticExpr(b); err != nil { - return nil, err - } - - ret, err := newBinaryOperation(op, a, b) - if err != nil { - return nil, err - } - - return staticExpr(ret) -} - -type pLike struct { - expr expression - pattern expression - re *regexp.Regexp - sexpr *string -} - -func (p *pLike) clone(arg []interface{}, unqualify ...string) (expression, error) { - expr, err := p.expr.clone(arg, unqualify...) - if err != nil { - return nil, err - } - - pattern, err := p.pattern.clone(arg, unqualify...) - if err != nil { - return nil, err - } - - return &pLike{ - expr: expr, - pattern: pattern, - re: p.re, - sexpr: p.sexpr, - }, nil -} - -func (p *pLike) isStatic() bool { return p.expr.isStatic() && p.pattern.isStatic() } -func (p *pLike) String() string { return fmt.Sprintf("%s LIKE %s", p.expr, p.pattern) } - -func (p *pLike) eval(execCtx *execCtx, ctx map[interface{}]interface{}) (v interface{}, err error) { - var sexpr string - var ok bool - switch { - case p.sexpr != nil: - sexpr = *p.sexpr - default: - expr, err := expand1(p.expr.eval(execCtx, ctx)) - if err != nil { - return nil, err - } - - if expr == nil { - return nil, nil - } - - sexpr, ok = expr.(string) - if !ok { - return nil, fmt.Errorf("non-string expression in LIKE: %v (value of type %T)", expr, expr) - } - - if p.expr.isStatic() { - p.sexpr = new(string) - *p.sexpr = sexpr - } - } - - re := p.re - if re == nil { - pattern, err := expand1(p.pattern.eval(execCtx, ctx)) - if err != nil { - return nil, err - } - - if pattern == nil { - return nil, nil - } - - spattern, ok := pattern.(string) - if !ok { - return nil, fmt.Errorf("non-string pattern in LIKE: %v (value of type %T)", pattern, pattern) - } - - if re, err = regexp.Compile(spattern); err != nil { - return nil, err - } - - if p.pattern.isStatic() { - p.re = re - } - } - - return re.MatchString(sexpr), nil -} - -type binaryOperation struct { - op int - l, r expression -} - -func newBinaryOperation0(op int, x, y interface{}) (v expression, err error) { - if op == eq { - if l, ok := x.(value); ok { - if b, ok := l.val.(bool); ok { - if b { // true == y: y - return y.(expression), nil - } - - // false == y: !y - return newUnaryOperation('!', y) - } - } - - if r, ok := y.(value); ok { - if b, ok := r.val.(bool); ok { - if b { // x == true: x - return x.(expression), nil - } - - // x == false: !x - return newUnaryOperation('!', x) - } - } - } - - if op == neq { - if l, ok := x.(value); ok { - if b, ok := l.val.(bool); ok { - if b { // true != y: !y - return newUnaryOperation('!', y) - } - - // false != y: y - return y.(expression), nil - } - } - - if r, ok := y.(value); ok { - if b, ok := r.val.(bool); ok { - if b { // x != true: !x - return newUnaryOperation('!', x) - } - - // x != false: x - return x.(expression), nil - } - } - } - - b := binaryOperation{op, x.(expression), y.(expression)} - var lv interface{} - if e := b.l; e.isStatic() { - if lv, err = e.eval(nil, nil); err != nil { - return nil, err - } - - b.l = value{lv} - } - - if e := b.r; e.isStatic() { - v, err := e.eval(nil, nil) - if err != nil { - return nil, err - } - - if v == nil { - return value{nil}, nil - } - - if op == '/' || op == '%' { - rb := binaryOperation{eq, e, value{idealInt(0)}} - val, err := rb.eval(nil, nil) - if err != nil { - return nil, err - } - - if val.(bool) { - return nil, errDivByZero - } - } - - if b.l.isStatic() && lv == nil { - return value{nil}, nil - } - - b.r = value{v} - } - - if !b.isStatic() { - return &b, nil - } - - val, err := b.eval(nil, nil) - return value{val}, err -} - -func newBinaryOperation(op int, x, y interface{}) (v expression, err error) { - expr, err := newBinaryOperation0(op, x, y) - if err != nil { - return nil, err - } - - b, ok := expr.(*binaryOperation) - if !ok { - return expr, nil - } - - if _, ok := b.l.(*ident); ok { - return expr, nil - } - - if c, ok := b.l.(*call); ok && c.f == "id" { - return expr, nil - } - - var r expression - if r, ok = b.r.(*ident); !ok { - r1, ok := b.r.(*call) - if !ok || r1.f != "id" || len(r1.arg) != 0 { - return expr, nil - } - - r = r1 - } - - // Normalize expr relOp indent: ident invRelOp expr - switch b.op { - case '<': - return &binaryOperation{'>', r, b.l}, nil - case le: - return &binaryOperation{ge, r, b.l}, nil - case '>': - return &binaryOperation{'<', r, b.l}, nil - case ge: - return &binaryOperation{le, r, b.l}, nil - case eq, neq: - return &binaryOperation{b.op, r, b.l}, nil - default: - return expr, nil - } -} - -func (o *binaryOperation) isIdentRelOpVal() (bool, string, interface{}, error) { - sid := "" - id, ok := o.l.(*ident) - if !ok { - f, ok := o.l.(*call) - if !ok || f.f != "id" || len(f.arg) != 0 { - return false, "", nil, nil - } - - sid = "id()" - } else { - if id.isQualified() { - return false, "", nil, nil - } - - sid = id.s - } - - if v, ok := o.r.(value); ok { - switch o.op { - case '<', - le, - '>', - ge, - eq, - neq: - return true, sid, v.val, nil - default: - return false, "", nil, nil - } - } - - return false, "", nil, nil -} - -func (o *binaryOperation) clone(arg []interface{}, unqualify ...string) (expression, error) { - l, err := o.l.clone(arg, unqualify...) - if err != nil { - return nil, err - } - - r, err := o.r.clone(arg, unqualify...) - if err != nil { - return nil, err - } - - return newBinaryOperation(o.op, l, r) -} - -func (o *binaryOperation) isStatic() bool { return o.l.isStatic() && o.r.isStatic() } - -func (o *binaryOperation) String() string { - return fmt.Sprintf("%s %s %s", o.l, iop(o.op), o.r) -} - -func (o *binaryOperation) eval(execCtx *execCtx, ctx map[interface{}]interface{}) (r interface{}, err error) { - defer func() { - if e := recover(); e != nil { - switch x := e.(type) { - case error: - r, err = nil, x - default: - r, err = nil, fmt.Errorf("%v", x) - } - } - }() - - switch op := o.op; op { - case andand: - a, err := expand1(o.l.eval(execCtx, ctx)) - if err != nil { - return nil, err - } - - switch x := a.(type) { - case nil: - b, err := expand1(o.r.eval(execCtx, ctx)) - if err != nil { - return nil, err - } - - switch y := b.(type) { - case nil: - return nil, nil - case bool: - if !y { - return false, nil - } - - return nil, nil - default: - return invOp2(x, y, op) - } - case bool: - if !x { - return false, nil - } - - b, err := expand1(o.r.eval(execCtx, ctx)) - if err != nil { - return nil, err - } - - switch y := b.(type) { - case nil: - return nil, nil - case bool: - return y, nil - default: - return invOp2(x, y, op) - } - default: - return undOp(x, op) - } - case oror: - a, err := expand1(o.l.eval(execCtx, ctx)) - if err != nil { - return nil, err - } - - switch x := a.(type) { - case nil: - b, err := expand1(o.r.eval(execCtx, ctx)) - if err != nil { - return nil, err - } - - switch y := b.(type) { - case nil: - return nil, nil - case bool: - if y { - return y, nil - } - - return nil, nil - default: - return invOp2(x, y, op) - } - case bool: - if x { - return x, nil - } - - b, err := expand1(o.r.eval(execCtx, ctx)) - if err != nil { - return nil, err - } - - switch y := b.(type) { - case nil: - return nil, nil - case bool: - return y, nil - default: - return invOp2(x, y, op) - } - default: - return undOp(x, op) - } - case '>': - a, b := o.get2(execCtx, ctx) - if a == nil || b == nil { - return - } - switch x := a.(type) { - //case nil: - case idealComplex: - return undOp2(a, b, op) - case idealFloat: - switch y := b.(type) { - case idealFloat: - return x > y, nil - default: - return invOp2(x, y, op) - } - case idealInt: - switch y := b.(type) { - case idealInt: - return x > y, nil - default: - return invOp2(x, y, op) - } - case idealRune: - switch y := b.(type) { - case idealRune: - return x > y, nil - default: - return invOp2(x, y, op) - } - case idealUint: - switch y := b.(type) { - case idealUint: - return x > y, nil - default: - return invOp2(x, y, op) - } - case bool: - return undOp2(a, b, op) - case complex64: - return undOp2(a, b, op) - case complex128: - return undOp2(a, b, op) - case float32: - switch y := b.(type) { - case float32: - return x > y, nil - default: - return invOp2(x, y, op) - } - case float64: - switch y := b.(type) { - case float64: - return x > y, nil - default: - return invOp2(x, y, op) - } - case int8: - switch y := b.(type) { - case int8: - return x > y, nil - default: - return invOp2(x, y, op) - } - case int16: - switch y := b.(type) { - case int16: - return x > y, nil - default: - return invOp2(x, y, op) - } - case int32: - switch y := b.(type) { - case int32: - return x > y, nil - default: - return invOp2(x, y, op) - } - case int64: - switch y := b.(type) { - case int64: - return x > y, nil - default: - return invOp2(x, y, op) - } - case string: - switch y := b.(type) { - case string: - return x > y, nil - default: - return invOp2(x, y, op) - } - case uint8: - switch y := b.(type) { - case uint8: - return x > y, nil - default: - return invOp2(x, y, op) - } - case uint16: - switch y := b.(type) { - case uint16: - return x > y, nil - default: - return invOp2(x, y, op) - } - case uint32: - switch y := b.(type) { - case uint32: - return x > y, nil - default: - return invOp2(x, y, op) - } - case uint64: - switch y := b.(type) { - case uint64: - return x > y, nil - default: - return invOp2(x, y, op) - } - case *big.Int: - switch y := b.(type) { - case *big.Int: - return x.Cmp(y) > 0, nil - default: - return invOp2(x, y, op) - } - case *big.Rat: - switch y := b.(type) { - case *big.Rat: - return x.Cmp(y) > 0, nil - default: - return invOp2(x, y, op) - } - case time.Duration: - switch y := b.(type) { - case time.Duration: - return x > y, nil - default: - return invOp2(x, y, op) - } - case time.Time: - switch y := b.(type) { - case time.Time: - return x.After(y), nil - default: - return invOp2(x, y, op) - } - default: - return invOp2(a, b, op) - } - case '<': - a, b := o.get2(execCtx, ctx) - if a == nil || b == nil { - return - } - switch x := a.(type) { - //case nil: - case idealComplex: - return undOp2(a, b, op) - case idealFloat: - switch y := b.(type) { - case idealFloat: - return x < y, nil - default: - return invOp2(x, y, op) - } - case idealInt: - switch y := b.(type) { - case idealInt: - return x < y, nil - default: - return invOp2(x, y, op) - } - case idealRune: - switch y := b.(type) { - case idealRune: - return x < y, nil - default: - return invOp2(x, y, op) - } - case idealUint: - switch y := b.(type) { - case idealUint: - return x < y, nil - default: - return invOp2(x, y, op) - } - case bool: - return undOp2(a, b, op) - case complex64: - return undOp2(a, b, op) - case complex128: - return undOp2(a, b, op) - case float32: - switch y := b.(type) { - case float32: - return x < y, nil - default: - return invOp2(x, y, op) - } - case float64: - switch y := b.(type) { - case float64: - return x < y, nil - default: - return invOp2(x, y, op) - } - case int8: - switch y := b.(type) { - case int8: - return x < y, nil - default: - return invOp2(x, y, op) - } - case int16: - switch y := b.(type) { - case int16: - return x < y, nil - default: - return invOp2(x, y, op) - } - case int32: - switch y := b.(type) { - case int32: - return x < y, nil - default: - return invOp2(x, y, op) - } - case int64: - switch y := b.(type) { - case int64: - return x < y, nil - default: - return invOp2(x, y, op) - } - case string: - switch y := b.(type) { - case string: - return x < y, nil - default: - return invOp2(x, y, op) - } - case uint8: - switch y := b.(type) { - case uint8: - return x < y, nil - default: - return invOp2(x, y, op) - } - case uint16: - switch y := b.(type) { - case uint16: - return x < y, nil - default: - return invOp2(x, y, op) - } - case uint32: - switch y := b.(type) { - case uint32: - return x < y, nil - default: - return invOp2(x, y, op) - } - case uint64: - switch y := b.(type) { - case uint64: - return x < y, nil - default: - return invOp2(x, y, op) - } - case *big.Int: - switch y := b.(type) { - case *big.Int: - return x.Cmp(y) < 0, nil - default: - return invOp2(x, y, op) - } - case *big.Rat: - switch y := b.(type) { - case *big.Rat: - return x.Cmp(y) < 0, nil - default: - return invOp2(x, y, op) - } - case time.Duration: - switch y := b.(type) { - case time.Duration: - return x < y, nil - default: - return invOp2(x, y, op) - } - case time.Time: - switch y := b.(type) { - case time.Time: - return x.Before(y), nil - default: - return invOp2(x, y, op) - } - default: - return invOp2(a, b, op) - } - case le: - a, b := o.get2(execCtx, ctx) - if a == nil || b == nil { - return - } - switch x := a.(type) { - //case nil: - case idealComplex: - return undOp2(a, b, op) - case idealFloat: - switch y := b.(type) { - case idealFloat: - return x <= y, nil - default: - return invOp2(x, y, op) - } - case idealInt: - switch y := b.(type) { - case idealInt: - return x <= y, nil - default: - return invOp2(x, y, op) - } - case idealRune: - switch y := b.(type) { - case idealRune: - return x <= y, nil - default: - return invOp2(x, y, op) - } - case idealUint: - switch y := b.(type) { - case idealUint: - return x <= y, nil - default: - return invOp2(x, y, op) - } - case bool: - return undOp2(a, b, op) - case complex64: - return undOp2(a, b, op) - case complex128: - return undOp2(a, b, op) - case float32: - switch y := b.(type) { - case float32: - return x <= y, nil - default: - return invOp2(x, y, op) - } - case float64: - switch y := b.(type) { - case float64: - return x <= y, nil - default: - return invOp2(x, y, op) - } - case int8: - switch y := b.(type) { - case int8: - return x <= y, nil - default: - return invOp2(x, y, op) - } - case int16: - switch y := b.(type) { - case int16: - return x <= y, nil - default: - return invOp2(x, y, op) - } - case int32: - switch y := b.(type) { - case int32: - return x <= y, nil - default: - return invOp2(x, y, op) - } - case int64: - switch y := b.(type) { - case int64: - return x <= y, nil - default: - return invOp2(x, y, op) - } - case string: - switch y := b.(type) { - case string: - return x <= y, nil - default: - return invOp2(x, y, op) - } - case uint8: - switch y := b.(type) { - case uint8: - return x <= y, nil - default: - return invOp2(x, y, op) - } - case uint16: - switch y := b.(type) { - case uint16: - return x <= y, nil - default: - return invOp2(x, y, op) - } - case uint32: - switch y := b.(type) { - case uint32: - return x <= y, nil - default: - return invOp2(x, y, op) - } - case uint64: - switch y := b.(type) { - case uint64: - return x <= y, nil - default: - return invOp2(x, y, op) - } - case *big.Int: - switch y := b.(type) { - case *big.Int: - return x.Cmp(y) <= 0, nil - default: - return invOp2(x, y, op) - } - case *big.Rat: - switch y := b.(type) { - case *big.Rat: - return x.Cmp(y) <= 0, nil - default: - return invOp2(x, y, op) - } - case time.Duration: - switch y := b.(type) { - case time.Duration: - return x <= y, nil - default: - return invOp2(x, y, op) - } - case time.Time: - switch y := b.(type) { - case time.Time: - return x.Before(y) || x.Equal(y), nil - default: - return invOp2(x, y, op) - } - default: - return invOp2(a, b, op) - } - case ge: - a, b := o.get2(execCtx, ctx) - if a == nil || b == nil { - return - } - switch x := a.(type) { - //case nil: - case idealComplex: - return undOp2(a, b, op) - case idealFloat: - switch y := b.(type) { - case idealFloat: - return x >= y, nil - default: - return invOp2(x, y, op) - } - case idealInt: - switch y := b.(type) { - case idealInt: - return x >= y, nil - default: - return invOp2(x, y, op) - } - case idealRune: - switch y := b.(type) { - case idealRune: - return x >= y, nil - default: - return invOp2(x, y, op) - } - case idealUint: - switch y := b.(type) { - case idealUint: - return x >= y, nil - default: - return invOp2(x, y, op) - } - case bool: - return undOp2(a, b, op) - case complex64: - return undOp2(a, b, op) - case complex128: - return undOp2(a, b, op) - case float32: - switch y := b.(type) { - case float32: - return x >= y, nil - default: - return invOp2(x, y, op) - } - case float64: - switch y := b.(type) { - case float64: - return x >= y, nil - default: - return invOp2(x, y, op) - } - case int8: - switch y := b.(type) { - case int8: - return x >= y, nil - default: - return invOp2(x, y, op) - } - case int16: - switch y := b.(type) { - case int16: - return x >= y, nil - default: - return invOp2(x, y, op) - } - case int32: - switch y := b.(type) { - case int32: - return x >= y, nil - default: - return invOp2(x, y, op) - } - case int64: - switch y := b.(type) { - case int64: - return x >= y, nil - default: - return invOp2(x, y, op) - } - case string: - switch y := b.(type) { - case string: - return x >= y, nil - default: - return invOp2(x, y, op) - } - case uint8: - switch y := b.(type) { - case uint8: - return x >= y, nil - default: - return invOp2(x, y, op) - } - case uint16: - switch y := b.(type) { - case uint16: - return x >= y, nil - default: - return invOp2(x, y, op) - } - case uint32: - switch y := b.(type) { - case uint32: - return x >= y, nil - default: - return invOp2(x, y, op) - } - case uint64: - switch y := b.(type) { - case uint64: - return x >= y, nil - default: - return invOp2(x, y, op) - } - case *big.Int: - switch y := b.(type) { - case *big.Int: - return x.Cmp(y) >= 0, nil - default: - return invOp2(x, y, op) - } - case *big.Rat: - switch y := b.(type) { - case *big.Rat: - return x.Cmp(y) >= 0, nil - default: - return invOp2(x, y, op) - } - case time.Duration: - switch y := b.(type) { - case time.Duration: - return x >= y, nil - default: - return invOp2(x, y, op) - } - case time.Time: - switch y := b.(type) { - case time.Time: - return x.After(y) || x.Equal(y), nil - default: - return invOp2(x, y, op) - } - default: - return invOp2(a, b, op) - } - case neq: - a, b := o.get2(execCtx, ctx) - if a == nil || b == nil { - return - } - switch x := a.(type) { - //case nil: - case idealComplex: - switch y := b.(type) { - case idealComplex: - return x != y, nil - default: - return invOp2(x, y, op) - } - case idealFloat: - switch y := b.(type) { - case idealFloat: - return x != y, nil - default: - return invOp2(x, y, op) - } - case idealInt: - switch y := b.(type) { - case idealInt: - return x != y, nil - default: - return invOp2(x, y, op) - } - case idealRune: - switch y := b.(type) { - case idealRune: - return x != y, nil - default: - return invOp2(x, y, op) - } - case idealUint: - switch y := b.(type) { - case idealUint: - return x != y, nil - default: - return invOp2(x, y, op) - } - case bool: - switch y := b.(type) { - case bool: - return x != y, nil - default: - return invOp2(x, y, op) - } - case complex64: - switch y := b.(type) { - case complex64: - return x != y, nil - default: - return invOp2(x, y, op) - } - case complex128: - switch y := b.(type) { - case complex128: - return x != y, nil - default: - return invOp2(x, y, op) - } - case float32: - switch y := b.(type) { - case float32: - return x != y, nil - default: - return invOp2(x, y, op) - } - case float64: - switch y := b.(type) { - case float64: - return x != y, nil - default: - return invOp2(x, y, op) - } - case int8: - switch y := b.(type) { - case int8: - return x != y, nil - default: - return invOp2(x, y, op) - } - case int16: - switch y := b.(type) { - case int16: - return x != y, nil - default: - return invOp2(x, y, op) - } - case int32: - switch y := b.(type) { - case int32: - return x != y, nil - default: - return invOp2(x, y, op) - } - case int64: - switch y := b.(type) { - case int64: - return x != y, nil - default: - return invOp2(x, y, op) - } - case string: - switch y := b.(type) { - case string: - return x != y, nil - default: - return invOp2(x, y, op) - } - case uint8: - switch y := b.(type) { - case uint8: - return x != y, nil - default: - return invOp2(x, y, op) - } - case uint16: - switch y := b.(type) { - case uint16: - return x != y, nil - default: - return invOp2(x, y, op) - } - case uint32: - switch y := b.(type) { - case uint32: - return x != y, nil - default: - return invOp2(x, y, op) - } - case uint64: - switch y := b.(type) { - case uint64: - return x != y, nil - default: - return invOp2(x, y, op) - } - case *big.Int: - switch y := b.(type) { - case *big.Int: - return x.Cmp(y) != 0, nil - default: - return invOp2(x, y, op) - } - case *big.Rat: - switch y := b.(type) { - case *big.Rat: - return x.Cmp(y) != 0, nil - default: - return invOp2(x, y, op) - } - case time.Duration: - switch y := b.(type) { - case time.Duration: - return x != y, nil - default: - return invOp2(x, y, op) - } - case time.Time: - switch y := b.(type) { - case time.Time: - return !x.Equal(y), nil - default: - return invOp2(x, y, op) - } - default: - return invOp2(a, b, op) - } - case eq: - a, b := o.get2(execCtx, ctx) - if a == nil || b == nil { - return - } - switch x := a.(type) { - //case nil: - case idealComplex: - switch y := b.(type) { - case idealComplex: - return x == y, nil - default: - return invOp2(x, y, op) - } - case idealFloat: - switch y := b.(type) { - case idealFloat: - return x == y, nil - default: - return invOp2(x, y, op) - } - case idealInt: - switch y := b.(type) { - case idealInt: - return x == y, nil - default: - return invOp2(x, y, op) - } - case idealRune: - switch y := b.(type) { - case idealRune: - return x == y, nil - default: - return invOp2(x, y, op) - } - case idealUint: - switch y := b.(type) { - case idealUint: - return x == y, nil - default: - return invOp2(x, y, op) - } - case bool: - switch y := b.(type) { - case bool: - return x == y, nil - default: - return invOp2(x, y, op) - } - case complex64: - switch y := b.(type) { - case complex64: - return x == y, nil - default: - return invOp2(x, y, op) - } - case complex128: - switch y := b.(type) { - case complex128: - return x == y, nil - default: - return invOp2(x, y, op) - } - case float32: - switch y := b.(type) { - case float32: - return x == y, nil - default: - return invOp2(x, y, op) - } - case float64: - switch y := b.(type) { - case float64: - return x == y, nil - default: - return invOp2(x, y, op) - } - case int8: - switch y := b.(type) { - case int8: - return x == y, nil - default: - return invOp2(x, y, op) - } - case int16: - switch y := b.(type) { - case int16: - return x == y, nil - default: - return invOp2(x, y, op) - } - case int32: - switch y := b.(type) { - case int32: - return x == y, nil - default: - return invOp2(x, y, op) - } - case int64: - switch y := b.(type) { - case int64: - return x == y, nil - default: - return invOp2(x, y, op) - } - case string: - switch y := b.(type) { - case string: - return x == y, nil - default: - return invOp2(x, y, op) - } - case uint8: - switch y := b.(type) { - case uint8: - return x == y, nil - default: - return invOp2(x, y, op) - } - case uint16: - switch y := b.(type) { - case uint16: - return x == y, nil - default: - return invOp2(x, y, op) - } - case uint32: - switch y := b.(type) { - case uint32: - return x == y, nil - default: - return invOp2(x, y, op) - } - case uint64: - switch y := b.(type) { - case uint64: - return x == y, nil - default: - return invOp2(x, y, op) - } - case *big.Int: - switch y := b.(type) { - case *big.Int: - return x.Cmp(y) == 0, nil - default: - return invOp2(x, y, op) - } - case *big.Rat: - switch y := b.(type) { - case *big.Rat: - return x.Cmp(y) == 0, nil - default: - return invOp2(x, y, op) - } - case time.Duration: - switch y := b.(type) { - case time.Duration: - return x == y, nil - default: - return invOp2(x, y, op) - } - case time.Time: - switch y := b.(type) { - case time.Time: - return x.Equal(y), nil - default: - return invOp2(x, y, op) - } - default: - return invOp2(a, b, op) - } - case '+': - a, b := o.get2(execCtx, ctx) - if a == nil || b == nil { - return - } - switch x := a.(type) { - //case nil: - case idealComplex: - switch y := b.(type) { - case idealComplex: - return idealComplex(complex64(x) + complex64(y)), nil - default: - return invOp2(x, y, op) - } - case idealFloat: - switch y := b.(type) { - case idealFloat: - return idealFloat(float64(x) + float64(y)), nil - default: - return invOp2(x, y, op) - } - case idealInt: - switch y := b.(type) { - case idealInt: - return idealInt(int64(x) + int64(y)), nil - default: - return invOp2(x, y, op) - } - case idealRune: - switch y := b.(type) { - case idealRune: - return idealRune(int64(x) + int64(y)), nil - default: - return invOp2(x, y, op) - } - case idealUint: - switch y := b.(type) { - case idealUint: - return idealUint(uint64(x) + uint64(y)), nil - default: - return invOp2(x, y, op) - } - case bool: - return undOp2(a, b, op) - case complex64: - switch y := b.(type) { - case complex64: - return x + y, nil - default: - return invOp2(x, y, op) - } - case complex128: - switch y := b.(type) { - case complex128: - return x + y, nil - default: - return invOp2(x, y, op) - } - case float32: - switch y := b.(type) { - case float32: - return x + y, nil - default: - return invOp2(x, y, op) - } - case float64: - switch y := b.(type) { - case float64: - return x + y, nil - default: - return invOp2(x, y, op) - } - case int8: - switch y := b.(type) { - case int8: - return x + y, nil - default: - return invOp2(x, y, op) - } - case int16: - switch y := b.(type) { - case int16: - return x + y, nil - default: - return invOp2(x, y, op) - } - case int32: - switch y := b.(type) { - case int32: - return x + y, nil - default: - return invOp2(x, y, op) - } - case int64: - switch y := b.(type) { - case int64: - return x + y, nil - default: - return invOp2(x, y, op) - } - case string: - switch y := b.(type) { - case string: - return x + y, nil - default: - return invOp2(x, y, op) - } - case uint8: - switch y := b.(type) { - case uint8: - return x + y, nil - default: - return invOp2(x, y, op) - } - case uint16: - switch y := b.(type) { - case uint16: - return x + y, nil - default: - return invOp2(x, y, op) - } - case uint32: - switch y := b.(type) { - case uint32: - return x + y, nil - default: - return invOp2(x, y, op) - } - case uint64: - switch y := b.(type) { - case uint64: - return x + y, nil - default: - return invOp2(x, y, op) - } - case *big.Int: - switch y := b.(type) { - case *big.Int: - var z big.Int - return z.Add(x, y), nil - default: - return invOp2(x, y, op) - } - case *big.Rat: - switch y := b.(type) { - case *big.Rat: - var z big.Rat - return z.Add(x, y), nil - default: - return invOp2(x, y, op) - } - case time.Duration: - switch y := b.(type) { - case time.Duration: - return x + y, nil - case time.Time: - return y.Add(x), nil - default: - return invOp2(x, y, op) - } - case time.Time: - switch y := b.(type) { - case time.Duration: - return x.Add(y), nil - default: - return invOp2(x, y, op) - } - default: - return invOp2(a, b, op) - } - case '-': - a, b := o.get2(execCtx, ctx) - if a == nil || b == nil { - return - } - switch x := a.(type) { - //case nil: - case idealComplex: - switch y := b.(type) { - case idealComplex: - return idealComplex(complex64(x) - complex64(y)), nil - default: - return invOp2(x, y, op) - } - case idealFloat: - switch y := b.(type) { - case idealFloat: - return idealFloat(float64(x) - float64(y)), nil - default: - return invOp2(x, y, op) - } - case idealInt: - switch y := b.(type) { - case idealInt: - return idealInt(int64(x) - int64(y)), nil - default: - return invOp2(x, y, op) - } - case idealRune: - switch y := b.(type) { - case idealRune: - return idealRune(int64(x) - int64(y)), nil - default: - return invOp2(x, y, op) - } - case idealUint: - switch y := b.(type) { - case idealUint: - return idealUint(uint64(x) - uint64(y)), nil - default: - return invOp2(x, y, op) - } - case bool: - return undOp2(a, b, op) - case complex64: - switch y := b.(type) { - case complex64: - return x - y, nil - default: - return invOp2(x, y, op) - } - case complex128: - switch y := b.(type) { - case complex128: - return x - y, nil - default: - return invOp2(x, y, op) - } - case float32: - switch y := b.(type) { - case float32: - return x - y, nil - default: - return invOp2(x, y, op) - } - case float64: - switch y := b.(type) { - case float64: - return x - y, nil - default: - return invOp2(x, y, op) - } - case int8: - switch y := b.(type) { - case int8: - return x - y, nil - default: - return invOp2(x, y, op) - } - case int16: - switch y := b.(type) { - case int16: - return x - y, nil - default: - return invOp2(x, y, op) - } - case int32: - switch y := b.(type) { - case int32: - return x - y, nil - default: - return invOp2(x, y, op) - } - case int64: - switch y := b.(type) { - case int64: - return x - y, nil - default: - return invOp2(x, y, op) - } - case string: - return undOp2(a, b, op) - case uint8: - switch y := b.(type) { - case uint8: - return x - y, nil - default: - return invOp2(x, y, op) - } - case uint16: - switch y := b.(type) { - case uint16: - return x - y, nil - default: - return invOp2(x, y, op) - } - case uint32: - switch y := b.(type) { - case uint32: - return x - y, nil - default: - return invOp2(x, y, op) - } - case uint64: - switch y := b.(type) { - case uint64: - return x - y, nil - default: - return invOp2(x, y, op) - } - case *big.Int: - switch y := b.(type) { - case *big.Int: - var z big.Int - return z.Sub(x, y), nil - default: - return invOp2(x, y, op) - } - case *big.Rat: - switch y := b.(type) { - case *big.Rat: - var z big.Rat - return z.Sub(x, y), nil - default: - return invOp2(x, y, op) - } - case time.Duration: - switch y := b.(type) { - case time.Duration: - return x - y, nil - default: - return invOp2(x, y, op) - } - case time.Time: - switch y := b.(type) { - case time.Duration: - return x.Add(-y), nil - case time.Time: - return x.Sub(y), nil - default: - return invOp2(x, y, op) - } - default: - return invOp2(a, b, op) - } - case rsh: - a, b := eval2(o.l, o.r, execCtx, ctx) - if a == nil || b == nil { - return - } - - var cnt uint64 - switch y := b.(type) { - //case nil: - case idealComplex: - return invShiftRHS(a, b) - case idealFloat: - return invShiftRHS(a, b) - case idealInt: - cnt = uint64(y) - case idealRune: - cnt = uint64(y) - case idealUint: - cnt = uint64(y) - case bool: - return invShiftRHS(a, b) - case complex64: - return invShiftRHS(a, b) - case complex128: - return invShiftRHS(a, b) - case float32: - return invShiftRHS(a, b) - case float64: - return invShiftRHS(a, b) - case int8: - return invShiftRHS(a, b) - case int16: - return invShiftRHS(a, b) - case int32: - return invShiftRHS(a, b) - case int64: - return invShiftRHS(a, b) - case string: - return invShiftRHS(a, b) - case uint8: - cnt = uint64(y) - case uint16: - cnt = uint64(y) - case uint32: - cnt = uint64(y) - case uint64: - cnt = uint64(y) - default: - return invOp2(a, b, op) - } - - switch x := a.(type) { - //case nil: - case idealComplex: - return undOp2(a, b, op) - case idealFloat: - return undOp2(a, b, op) - case idealInt: - return idealInt(int64(x) >> cnt), nil - case idealRune: - return idealRune(int64(x) >> cnt), nil - case idealUint: - return idealUint(uint64(x) >> cnt), nil - case bool: - return undOp2(a, b, op) - case complex64: - return undOp2(a, b, op) - case complex128: - return undOp2(a, b, op) - case float32: - return undOp2(a, b, op) - case float64: - return undOp2(a, b, op) - case int8: - return x >> cnt, nil - case int16: - return x >> cnt, nil - case int32: - return x >> cnt, nil - case int64: - return x >> cnt, nil - case string: - return undOp2(a, b, op) - case uint8: - return x >> cnt, nil - case uint16: - return x >> cnt, nil - case uint32: - return x >> cnt, nil - case uint64: - return x >> cnt, nil - case *big.Int: - var z big.Int - return z.Rsh(x, uint(cnt)), nil - case time.Duration: - return x >> cnt, nil - default: - return invOp2(a, b, op) - } - case lsh: - a, b := eval2(o.l, o.r, execCtx, ctx) - if a == nil || b == nil { - return - } - - var cnt uint64 - switch y := b.(type) { - //case nil: - case idealComplex: - return invShiftRHS(a, b) - case idealFloat: - return invShiftRHS(a, b) - case idealInt: - cnt = uint64(y) - case idealRune: - cnt = uint64(y) - case idealUint: - cnt = uint64(y) - case bool: - return invShiftRHS(a, b) - case complex64: - return invShiftRHS(a, b) - case complex128: - return invShiftRHS(a, b) - case float32: - return invShiftRHS(a, b) - case float64: - return invShiftRHS(a, b) - case int8: - return invShiftRHS(a, b) - case int16: - return invShiftRHS(a, b) - case int32: - return invShiftRHS(a, b) - case int64: - return invShiftRHS(a, b) - case string: - return invShiftRHS(a, b) - case uint8: - cnt = uint64(y) - case uint16: - cnt = uint64(y) - case uint32: - cnt = uint64(y) - case uint64: - cnt = uint64(y) - default: - return invOp2(a, b, op) - } - - switch x := a.(type) { - //case nil: - case idealComplex: - return undOp2(a, b, op) - case idealFloat: - return undOp2(a, b, op) - case idealInt: - return idealInt(int64(x) << cnt), nil - case idealRune: - return idealRune(int64(x) << cnt), nil - case idealUint: - return idealUint(uint64(x) << cnt), nil - case bool: - return undOp2(a, b, op) - case complex64: - return undOp2(a, b, op) - case complex128: - return undOp2(a, b, op) - case float32: - return undOp2(a, b, op) - case float64: - return undOp2(a, b, op) - case int8: - return x << cnt, nil - case int16: - return x << cnt, nil - case int32: - return x << cnt, nil - case int64: - return x << cnt, nil - case string: - return undOp2(a, b, op) - case uint8: - return x << cnt, nil - case uint16: - return x << cnt, nil - case uint32: - return x << cnt, nil - case uint64: - return x << cnt, nil - case *big.Int: - var z big.Int - return z.Lsh(x, uint(cnt)), nil - case time.Duration: - return x << cnt, nil - default: - return invOp2(a, b, op) - } - case '&': - a, b := o.get2(execCtx, ctx) - if a == nil || b == nil { - return - } - switch x := a.(type) { - //case nil: - case idealComplex: - return undOp2(a, b, op) - case idealFloat: - return undOp2(a, b, op) - case idealInt: - switch y := b.(type) { - case idealInt: - return idealInt(int64(x) & int64(y)), nil - default: - return invOp2(x, y, op) - } - case idealRune: - switch y := b.(type) { - case idealRune: - return idealRune(int64(x) & int64(y)), nil - default: - return invOp2(x, y, op) - } - case idealUint: - switch y := b.(type) { - case idealUint: - return idealUint(uint64(x) & uint64(y)), nil - default: - return invOp2(x, y, op) - } - case bool: - return undOp2(a, b, op) - case complex64: - return undOp2(a, b, op) - case complex128: - return undOp2(a, b, op) - case float32: - return undOp2(a, b, op) - case float64: - return undOp2(a, b, op) - case int8: - switch y := b.(type) { - case int8: - return x & y, nil - default: - return invOp2(x, y, op) - } - case int16: - switch y := b.(type) { - case int16: - return x & y, nil - default: - return invOp2(x, y, op) - } - case int32: - switch y := b.(type) { - case int32: - return x & y, nil - default: - return invOp2(x, y, op) - } - case int64: - switch y := b.(type) { - case int64: - return x & y, nil - default: - return invOp2(x, y, op) - } - case string: - return undOp2(a, b, op) - case uint8: - switch y := b.(type) { - case uint8: - return x & y, nil - default: - return invOp2(x, y, op) - } - case uint16: - switch y := b.(type) { - case uint16: - return x & y, nil - default: - return invOp2(x, y, op) - } - case uint32: - switch y := b.(type) { - case uint32: - return x & y, nil - default: - return invOp2(x, y, op) - } - case uint64: - switch y := b.(type) { - case uint64: - return x & y, nil - default: - return invOp2(x, y, op) - } - case *big.Int: - switch y := b.(type) { - case *big.Int: - var z big.Int - return z.And(x, y), nil - default: - return invOp2(x, y, op) - } - case time.Duration: - switch y := b.(type) { - case time.Duration: - return x & y, nil - default: - return invOp2(x, y, op) - } - default: - return invOp2(a, b, op) - } - case '|': - a, b := o.get2(execCtx, ctx) - if a == nil || b == nil { - return - } - switch x := a.(type) { - //case nil: - case idealComplex: - return undOp2(a, b, op) - case idealFloat: - return undOp2(a, b, op) - case idealInt: - switch y := b.(type) { - case idealInt: - return idealInt(int64(x) | int64(y)), nil - default: - return invOp2(x, y, op) - } - case idealRune: - switch y := b.(type) { - case idealRune: - return idealRune(int64(x) | int64(y)), nil - default: - return invOp2(x, y, op) - } - case idealUint: - switch y := b.(type) { - case idealUint: - return idealUint(uint64(x) | uint64(y)), nil - default: - return invOp2(x, y, op) - } - case bool: - return undOp2(a, b, op) - case complex64: - return undOp2(a, b, op) - case complex128: - return undOp2(a, b, op) - case float32: - return undOp2(a, b, op) - case float64: - return undOp2(a, b, op) - case int8: - switch y := b.(type) { - case int8: - return x | y, nil - default: - return invOp2(x, y, op) - } - case int16: - switch y := b.(type) { - case int16: - return x | y, nil - default: - return invOp2(x, y, op) - } - case int32: - switch y := b.(type) { - case int32: - return x | y, nil - default: - return invOp2(x, y, op) - } - case int64: - switch y := b.(type) { - case int64: - return x | y, nil - default: - return invOp2(x, y, op) - } - case string: - return undOp2(a, b, op) - case uint8: - switch y := b.(type) { - case uint8: - return x | y, nil - default: - return invOp2(x, y, op) - } - case uint16: - switch y := b.(type) { - case uint16: - return x | y, nil - default: - return invOp2(x, y, op) - } - case uint32: - switch y := b.(type) { - case uint32: - return x | y, nil - default: - return invOp2(x, y, op) - } - case uint64: - switch y := b.(type) { - case uint64: - return x | y, nil - default: - return invOp2(x, y, op) - } - case *big.Int: - switch y := b.(type) { - case *big.Int: - var z big.Int - return z.Or(x, y), nil - default: - return invOp2(x, y, op) - } - case time.Duration: - switch y := b.(type) { - case time.Duration: - return x | y, nil - default: - return invOp2(x, y, op) - } - default: - return invOp2(a, b, op) - } - case andnot: - a, b := o.get2(execCtx, ctx) - if a == nil || b == nil { - return - } - switch x := a.(type) { - //case nil: - case idealComplex: - return undOp2(a, b, op) - case idealFloat: - return undOp2(a, b, op) - case idealInt: - switch y := b.(type) { - case idealInt: - return idealInt(int64(x) &^ int64(y)), nil - default: - return invOp2(x, y, op) - } - case idealRune: - switch y := b.(type) { - case idealRune: - return idealRune(int64(x) &^ int64(y)), nil - default: - return invOp2(x, y, op) - } - case idealUint: - switch y := b.(type) { - case idealUint: - return idealUint(uint64(x) &^ uint64(y)), nil - default: - return invOp2(x, y, op) - } - case bool: - return undOp2(a, b, op) - case complex64: - return undOp2(a, b, op) - case complex128: - return undOp2(a, b, op) - case float32: - return undOp2(a, b, op) - case float64: - return undOp2(a, b, op) - case int8: - switch y := b.(type) { - case int8: - return x &^ y, nil - default: - return invOp2(x, y, op) - } - case int16: - switch y := b.(type) { - case int16: - return x &^ y, nil - default: - return invOp2(x, y, op) - } - case int32: - switch y := b.(type) { - case int32: - return x &^ y, nil - default: - return invOp2(x, y, op) - } - case int64: - switch y := b.(type) { - case int64: - return x &^ y, nil - default: - return invOp2(x, y, op) - } - case string: - return undOp2(a, b, op) - case uint8: - switch y := b.(type) { - case uint8: - return x &^ y, nil - default: - return invOp2(x, y, op) - } - case uint16: - switch y := b.(type) { - case uint16: - return x &^ y, nil - default: - return invOp2(x, y, op) - } - case uint32: - switch y := b.(type) { - case uint32: - return x &^ y, nil - default: - return invOp2(x, y, op) - } - case uint64: - switch y := b.(type) { - case uint64: - return x &^ y, nil - default: - return invOp2(x, y, op) - } - case *big.Int: - switch y := b.(type) { - case *big.Int: - var z big.Int - return z.AndNot(x, y), nil - default: - return invOp2(x, y, op) - } - case time.Duration: - switch y := b.(type) { - case time.Duration: - return x &^ y, nil - default: - return invOp2(x, y, op) - } - default: - return invOp2(a, b, op) - } - case '^': - a, b := o.get2(execCtx, ctx) - if a == nil || b == nil { - return - } - switch x := a.(type) { - //case nil: - case idealComplex: - return undOp2(a, b, op) - case idealFloat: - return undOp2(a, b, op) - case idealInt: - switch y := b.(type) { - case idealInt: - return idealInt(int64(x) ^ int64(y)), nil - default: - return invOp2(x, y, op) - } - case idealRune: - switch y := b.(type) { - case idealRune: - return idealRune(int64(x) ^ int64(y)), nil - default: - return invOp2(x, y, op) - } - case idealUint: - switch y := b.(type) { - case idealUint: - return idealUint(uint64(x) ^ uint64(y)), nil - default: - return invOp2(x, y, op) - } - case bool: - return undOp2(a, b, op) - case complex64: - return undOp2(a, b, op) - case complex128: - return undOp2(a, b, op) - case float32: - return undOp2(a, b, op) - case float64: - return undOp2(a, b, op) - case int8: - switch y := b.(type) { - case int8: - return x ^ y, nil - default: - return invOp2(x, y, op) - } - case int16: - switch y := b.(type) { - case int16: - return x ^ y, nil - default: - return invOp2(x, y, op) - } - case int32: - switch y := b.(type) { - case int32: - return x ^ y, nil - default: - return invOp2(x, y, op) - } - case int64: - switch y := b.(type) { - case int64: - return x ^ y, nil - default: - return invOp2(x, y, op) - } - case string: - return undOp2(a, b, op) - case uint8: - switch y := b.(type) { - case uint8: - return x ^ y, nil - default: - return invOp2(x, y, op) - } - case uint16: - switch y := b.(type) { - case uint16: - return x ^ y, nil - default: - return invOp2(x, y, op) - } - case uint32: - switch y := b.(type) { - case uint32: - return x ^ y, nil - default: - return invOp2(x, y, op) - } - case uint64: - switch y := b.(type) { - case uint64: - return x ^ y, nil - default: - return invOp2(x, y, op) - } - case *big.Int: - switch y := b.(type) { - case *big.Int: - var z big.Int - return z.Xor(x, y), nil - default: - return invOp2(x, y, op) - } - case time.Duration: - switch y := b.(type) { - case time.Duration: - return x ^ y, nil - default: - return invOp2(x, y, op) - } - default: - return invOp2(a, b, op) - } - case '%': - a, b := o.get2(execCtx, ctx) - if a == nil || b == nil { - return - } - switch x := a.(type) { - //case nil: - case idealComplex: - return undOp2(a, b, op) - case idealFloat: - return undOp2(a, b, op) - case idealInt: - switch y := b.(type) { - case idealInt: - return idealInt(int64(x) % int64(y)), nil - default: - return invOp2(x, y, op) - } - case idealRune: - switch y := b.(type) { - case idealRune: - return idealRune(int64(x) % int64(y)), nil - default: - return invOp2(x, y, op) - } - case idealUint: - switch y := b.(type) { - case idealUint: - return idealUint(uint64(x) % uint64(y)), nil - default: - return invOp2(x, y, op) - } - case bool: - return undOp2(a, b, op) - case complex64: - return undOp2(a, b, op) - case complex128: - return undOp2(a, b, op) - case float32: - return undOp2(a, b, op) - case float64: - return undOp2(a, b, op) - case int8: - switch y := b.(type) { - case int8: - return x % y, nil - default: - return invOp2(x, y, op) - } - case int16: - switch y := b.(type) { - case int16: - return x % y, nil - default: - return invOp2(x, y, op) - } - case int32: - switch y := b.(type) { - case int32: - return x % y, nil - default: - return invOp2(x, y, op) - } - case int64: - switch y := b.(type) { - case int64: - return x % y, nil - default: - return invOp2(x, y, op) - } - case string: - return undOp2(a, b, op) - case uint8: - switch y := b.(type) { - case uint8: - return x % y, nil - default: - return invOp2(x, y, op) - } - case uint16: - switch y := b.(type) { - case uint16: - return x % y, nil - default: - return invOp2(x, y, op) - } - case uint32: - switch y := b.(type) { - case uint32: - return x % y, nil - default: - return invOp2(x, y, op) - } - case uint64: - switch y := b.(type) { - case uint64: - return x % y, nil - default: - return invOp2(x, y, op) - } - case *big.Int: - switch y := b.(type) { - case *big.Int: - if y.Sign() == 0 { - return nil, errDivByZero - } - - var z big.Int - return z.Mod(x, y), nil - default: - return invOp2(x, y, op) - } - case time.Duration: - switch y := b.(type) { - case time.Duration: - return x % y, nil - default: - return invOp2(x, y, op) - } - default: - return invOp2(a, b, op) - } - case '/': - a, b := o.get2(execCtx, ctx) - if a == nil || b == nil { - return - } - switch x := a.(type) { - //case nil: - case idealComplex: - switch y := b.(type) { - case idealComplex: - return idealComplex(complex64(x) / complex64(y)), nil - default: - return invOp2(x, y, op) - } - case idealFloat: - switch y := b.(type) { - case idealFloat: - return idealFloat(float64(x) / float64(y)), nil - default: - return invOp2(x, y, op) - } - case idealInt: - switch y := b.(type) { - case idealInt: - return idealInt(int64(x) / int64(y)), nil - default: - return invOp2(x, y, op) - } - case idealRune: - switch y := b.(type) { - case idealRune: - return idealRune(int64(x) / int64(y)), nil - default: - return invOp2(x, y, op) - } - case idealUint: - switch y := b.(type) { - case idealUint: - return idealUint(uint64(x) / uint64(y)), nil - default: - return invOp2(x, y, op) - } - case bool: - return undOp2(a, b, op) - case complex64: - switch y := b.(type) { - case complex64: - return x / y, nil - default: - return invOp2(x, y, op) - } - case complex128: - switch y := b.(type) { - case complex128: - return x / y, nil - default: - return invOp2(x, y, op) - } - case float32: - switch y := b.(type) { - case float32: - return x / y, nil - default: - return invOp2(x, y, op) - } - case float64: - switch y := b.(type) { - case float64: - return x / y, nil - default: - return invOp2(x, y, op) - } - case int8: - switch y := b.(type) { - case int8: - return x / y, nil - default: - return invOp2(x, y, op) - } - case int16: - switch y := b.(type) { - case int16: - return x / y, nil - default: - return invOp2(x, y, op) - } - case int32: - switch y := b.(type) { - case int32: - return x / y, nil - default: - return invOp2(x, y, op) - } - case int64: - switch y := b.(type) { - case int64: - return x / y, nil - default: - return invOp2(x, y, op) - } - case string: - return undOp2(a, b, op) - case uint8: - switch y := b.(type) { - case uint8: - return x / y, nil - default: - return invOp2(x, y, op) - } - case uint16: - switch y := b.(type) { - case uint16: - return x / y, nil - default: - return invOp2(x, y, op) - } - case uint32: - switch y := b.(type) { - case uint32: - return x / y, nil - default: - return invOp2(x, y, op) - } - case uint64: - switch y := b.(type) { - case uint64: - return x / y, nil - default: - return invOp2(x, y, op) - } - case *big.Int: - switch y := b.(type) { - case *big.Int: - if y.Sign() == 0 { - return nil, errDivByZero - } - - var z big.Int - return z.Quo(x, y), nil - default: - return invOp2(x, y, op) - } - case *big.Rat: - switch y := b.(type) { - case *big.Rat: - if y.Sign() == 0 { - return nil, errDivByZero - } - - var z big.Rat - return z.Quo(x, y), nil - default: - return invOp2(x, y, op) - } - case time.Duration: - switch y := b.(type) { - case time.Duration: - return x / y, nil - default: - return invOp2(x, y, op) - } - default: - return invOp2(a, b, op) - } - case '*': - a, b := o.get2(execCtx, ctx) - if a == nil || b == nil { - return - } - switch x := a.(type) { - //case nil: - case idealComplex: - switch y := b.(type) { - case idealComplex: - return idealComplex(complex64(x) * complex64(y)), nil - default: - return invOp2(x, y, op) - } - case idealFloat: - switch y := b.(type) { - case idealFloat: - return idealFloat(float64(x) * float64(y)), nil - default: - return invOp2(x, y, op) - } - case idealInt: - switch y := b.(type) { - case idealInt: - return idealInt(int64(x) * int64(y)), nil - default: - return invOp2(x, y, op) - } - case idealRune: - switch y := b.(type) { - case idealRune: - return idealRune(int64(x) * int64(y)), nil - default: - return invOp2(x, y, op) - } - case idealUint: - switch y := b.(type) { - case idealUint: - return idealUint(uint64(x) * uint64(y)), nil - default: - return invOp2(x, y, op) - } - case bool: - return undOp2(a, b, op) - case complex64: - switch y := b.(type) { - case complex64: - return x * y, nil - default: - return invOp2(x, y, op) - } - case complex128: - switch y := b.(type) { - case complex128: - return x * y, nil - default: - return invOp2(x, y, op) - } - case float32: - switch y := b.(type) { - case float32: - return x * y, nil - default: - return invOp2(x, y, op) - } - case float64: - switch y := b.(type) { - case float64: - return x * y, nil - default: - return invOp2(x, y, op) - } - case int8: - switch y := b.(type) { - case int8: - return x * y, nil - default: - return invOp2(x, y, op) - } - case int16: - switch y := b.(type) { - case int16: - return x * y, nil - default: - return invOp2(x, y, op) - } - case int32: - switch y := b.(type) { - case int32: - return x * y, nil - default: - return invOp2(x, y, op) - } - case int64: - switch y := b.(type) { - case int64: - return x * y, nil - default: - return invOp2(x, y, op) - } - case string: - return undOp2(a, b, op) - case uint8: - switch y := b.(type) { - case uint8: - return x * y, nil - default: - return invOp2(x, y, op) - } - case uint16: - switch y := b.(type) { - case uint16: - return x * y, nil - default: - return invOp2(x, y, op) - } - case uint32: - switch y := b.(type) { - case uint32: - return x * y, nil - default: - return invOp2(x, y, op) - } - case uint64: - switch y := b.(type) { - case uint64: - return x * y, nil - default: - return invOp2(x, y, op) - } - case *big.Int: - switch y := b.(type) { - case *big.Int: - var z big.Int - return z.Mul(x, y), nil - default: - return invOp2(x, y, op) - } - case *big.Rat: - switch y := b.(type) { - case *big.Rat: - var z big.Rat - return z.Mul(x, y), nil - default: - return invOp2(x, y, op) - } - case time.Duration: - switch y := b.(type) { - case time.Duration: - return x * y, nil - default: - return invOp2(x, y, op) - } - default: - return invOp2(a, b, op) - } - default: - panic("internal error 037") - } -} - -func (o *binaryOperation) get2(execCtx *execCtx, ctx map[interface{}]interface{}) (x, y interface{}) { - x, y = eval2(o.l, o.r, execCtx, ctx) - //dbg("get2 pIn - ", x, y) - //defer func() {dbg("get2 coerced ", x, y)}() - return coerce(x, y) -} - -type ident struct { - s string -} - -func (i *ident) clone(arg []interface{}, unqualify ...string) (expression, error) { - x := strings.IndexByte(i.s, '.') - if x < 0 { - return &ident{s: i.s}, nil - } - - q := i.s[:x] - for _, v := range unqualify { - if q == v { - return &ident{i.s[x+1:]}, nil - } - } - return &ident{s: i.s}, nil -} - -func (i *ident) isQualified() bool { return strings.Contains(i.s, ".") } - -func (i *ident) isStatic() bool { return false } - -func (i *ident) String() string { return i.s } - -func (i *ident) eval(execCtx *execCtx, ctx map[interface{}]interface{}) (v interface{}, err error) { - if _, ok := ctx["$agg0"]; ok { - return int64(0), nil - } - - //defer func() { dbg("ident %q -> %v %v", i.s, v, err) }() - v, ok := ctx[i.s] - if !ok { - err = fmt.Errorf("unknown field %s", i.s) - } - return -} - -type pInEval struct { - m map[interface{}]struct{} // IN (SELECT...) results - sample interface{} -} - -type pIn struct { - expr expression - list []expression - not bool - sel *selectStmt -} - -func (n *pIn) clone(arg []interface{}, unqualify ...string) (expression, error) { - expr, err := n.expr.clone(arg, unqualify...) - if err != nil { - return nil, err - } - - list, err := cloneExpressionList(arg, n.list) - if err != nil { - return nil, err - } - - return &pIn{ - expr: expr, - list: list, - not: n.not, - sel: n.sel, - }, nil -} - -func (n *pIn) isStatic() bool { - if !n.expr.isStatic() || n.sel != nil { - return false - } - - for _, v := range n.list { - if !v.isStatic() { - return false - } - } - return true -} - -//LATER newIn - -func (n *pIn) String() string { - if n.sel == nil { - a := []string{} - for _, v := range n.list { - a = append(a, v.String()) - } - if n.not { - return fmt.Sprintf("%s NOT IN (%s)", n.expr, strings.Join(a, ",")) - } - - return fmt.Sprintf("%s IN (%s)", n.expr, strings.Join(a, ",")) - } - - if n.not { - return fmt.Sprintf("%s NOT IN (%s)", n.expr, n.sel) - } - - return fmt.Sprintf("%s IN (%s)", n.expr, n.sel) -} - -func (n *pIn) eval(execCtx *execCtx, ctx map[interface{}]interface{}) (v interface{}, err error) { - lhs, err := expand1(n.expr.eval(execCtx, ctx)) - if err != nil { - return nil, err - } - - if lhs == nil { - return nil, nil //TODO Add test for NULL LHS. - } - - if n.sel == nil { - for _, v := range n.list { - b, err := newBinaryOperation(eq, value{lhs}, v) - if err != nil { - return nil, err - } - - eval, err := b.eval(execCtx, ctx) - if err != nil { - return nil, err - } - - if x, ok := eval.(bool); ok && x { - return !n.not, nil - } - } - return n.not, nil - } - - var ev *pInEval - ev0 := ctx[n] - if ev0 == nil { // SELECT not yet evaluated. - r, err := n.sel.plan(execCtx) - if err != nil { - return nil, err - } - - if g, e := len(r.fieldNames()), 1; g != e { - return false, fmt.Errorf("IN (%s): mismatched field count, have %d, need %d", n.sel, g, e) - } - - ev = &pInEval{m: map[interface{}]struct{}{}} - ctx[n] = ev - m := ev.m - typechecked := false - if err := r.do(execCtx, func(id interface{}, data []interface{}) (more bool, err error) { - if typechecked { - if data[0] == nil { - return true, nil - } - - m[data[0]] = struct{}{} - } - - if data[0] == nil { - return true, nil - } - - ev.sample = data[0] - switch ev.sample.(type) { - case bool, byte, complex128, complex64, float32, - float64, int16, int32, int64, int8, - string, uint16, uint32, uint64: - typechecked = true - m[ev.sample] = struct{}{} - return true, nil - default: - return false, fmt.Errorf("IN (%s): invalid field type: %T", n.sel, data[0]) - } - - }); err != nil { - return nil, err - } - } else { - ev = ev0.(*pInEval) - } - - if ev.sample == nil { - return nil, nil - } - - _, ok := ev.m[coerce1(lhs, ev.sample)] - return ok != n.not, nil -} - -type value struct { - val interface{} -} - -func (l value) clone(arg []interface{}, unqualify ...string) (expression, error) { - return value{val: l.val}, nil -} - -func (l value) isStatic() bool { return true } - -func (l value) String() string { - switch x := l.val.(type) { - case nil: - return "NULL" - case idealComplex: - s := fmt.Sprint(x) - return s[1 : len(s)-1] - case complex64: - s := fmt.Sprint(x) - return s[1 : len(s)-1] - case complex128: - s := fmt.Sprint(x) - return s[1 : len(s)-1] - case string: - return fmt.Sprintf("%q", x) - case time.Duration: - return fmt.Sprintf("duration(%q)", l.val) - case time.Time: - return fmt.Sprintf("time(%q)", l.val) - case *big.Rat: - return fmt.Sprintf("bigrat(%q)", l.val) - case *big.Int: - return fmt.Sprintf(`bigint("%v")`, l.val) - default: - return fmt.Sprintf("%v", l.val) - } -} - -func (l value) eval(execCtx *execCtx, ctx map[interface{}]interface{}) (interface{}, error) { - return l.val, nil -} - -type conversion struct { - typ int - val expression -} - -func (c *conversion) clone(arg []interface{}, unqualify ...string) (expression, error) { - val, err := c.val.clone(arg, unqualify...) - if err != nil { - return nil, err - } - - return &conversion{typ: c.typ, val: val}, nil -} - -func (c *conversion) isStatic() bool { - return c.val.isStatic() -} - -//LATER newConversion or fake unary op - -func (c *conversion) String() string { - return fmt.Sprintf("%s(%s)", typeStr(c.typ), c.val) -} - -func (c *conversion) eval(execCtx *execCtx, ctx map[interface{}]interface{}) (v interface{}, err error) { - val, err := expand1(c.val.eval(execCtx, ctx)) - if err != nil { - return - } - - return convert(val, c.typ) -} - -type unaryOperation struct { - op int - v expression -} - -func newUnaryOperation(op int, x interface{}) (v expression, err error) { - l, ok := x.(expression) - if !ok { - panic("internal error 038") - } - - for { - pe, ok := l.(*pexpr) - if ok { - l = pe.expr - continue - } - - break - } - - if l.isStatic() { - val, err := l.eval(nil, nil) - if err != nil { - return nil, err - } - - l = value{val} - } - - if op == '!' { - b, ok := l.(*binaryOperation) - if ok { - switch b.op { - case eq: - b.op = neq - return b, nil - case neq: - b.op = eq - return b, nil - case '>': - b.op = le - return b, nil - case ge: - b.op = '<' - return b, nil - case '<': - b.op = ge - return b, nil - case le: - b.op = '>' - return b, nil - } - } - - u, ok := l.(*unaryOperation) - if ok && u.op == '!' { // !!x: x - return u.v, nil - } - } - - return &unaryOperation{op, l}, nil -} - -func (u *unaryOperation) clone(arg []interface{}, unqualify ...string) (expression, error) { - v, err := u.v.clone(arg, unqualify...) - if err != nil { - return nil, err - } - - return &unaryOperation{op: u.op, v: v}, nil -} - -func (u *unaryOperation) isStatic() bool { return u.v.isStatic() } - -func (u *unaryOperation) String() string { - switch u.v.(type) { - case *binaryOperation: - return fmt.Sprintf("%s(%s)", iop(u.op), u.v) - default: - return fmt.Sprintf("%s%s", iop(u.op), u.v) - } -} - -// !ident -func (u *unaryOperation) isNotQIdent() (bool, string, expression) { - if u.op != '!' { - return false, "", nil - } - - id, ok := u.v.(*ident) - if ok && id.isQualified() { - return true, mustQualifier(id.s), &unaryOperation{'!', &ident{mustSelector(id.s)}} - } - - return false, "", nil -} - -func (u *unaryOperation) eval(execCtx *execCtx, ctx map[interface{}]interface{}) (r interface{}, err error) { - defer func() { - if e := recover(); e != nil { - switch x := e.(type) { - case error: - r, err = nil, x - default: - r, err = nil, fmt.Errorf("%v", x) - } - } - }() - - switch op := u.op; op { - case '!': - a := eval(u.v, execCtx, ctx) - if a == nil { - return - } - - switch x := a.(type) { - case bool: - return !x, nil - default: - return undOp(a, op) - } - case '^': - a := eval(u.v, execCtx, ctx) - if a == nil { - return - } - - switch x := a.(type) { - //case nil: - case idealComplex: - return undOp(a, op) - case idealFloat: - return undOp(a, op) - case idealInt: - return ^x, nil - case idealRune: - return ^x, nil - case idealUint: - return ^x, nil - case bool: - return undOp(a, op) - case complex64: - return undOp(a, op) - case complex128: - return undOp(a, op) - case float32: - return undOp(a, op) - case float64: - return undOp(a, op) - case int8: - return ^x, nil - case int16: - return ^x, nil - case int32: - return ^x, nil - case int64: - return ^x, nil - case string: - return undOp(a, op) - case uint8: - return ^x, nil - case uint16: - return ^x, nil - case uint32: - return ^x, nil - case uint64: - return ^x, nil - case *big.Int: - var z big.Int - return z.Not(x), nil - case time.Duration: - return ^x, nil - default: - return undOp(a, op) - } - case '+': - a := eval(u.v, execCtx, ctx) - if a == nil { - return - } - - switch x := a.(type) { - //case nil: - case idealComplex: - return +x, nil - case idealFloat: - return +x, nil - case idealInt: - return +x, nil - case idealRune: - return +x, nil - case idealUint: - return +x, nil - case bool: - return undOp(a, op) - case complex64: - return +x, nil - case complex128: - return +x, nil - case float32: - return +x, nil - case float64: - return +x, nil - case int8: - return +x, nil - case int16: - return +x, nil - case int32: - return +x, nil - case int64: - return +x, nil - case string: - return undOp(a, op) - case uint8: - return +x, nil - case uint16: - return +x, nil - case uint32: - return +x, nil - case uint64: - return +x, nil - case *big.Int: - var z big.Int - return z.Set(x), nil - case *big.Rat: - var z big.Rat - return z.Set(x), nil - case time.Duration: - return x, nil - default: - return undOp(a, op) - } - case '-': - a := eval(u.v, execCtx, ctx) - if a == nil { - return - } - - switch x := a.(type) { - //case nil: - case idealComplex: - return -x, nil - case idealFloat: - return -x, nil - case idealInt: - return -x, nil - case idealRune: - return -x, nil - case idealUint: - return -x, nil - case bool: - return undOp(a, op) - case complex64: - return -x, nil - case complex128: - return -x, nil - case float32: - return -x, nil - case float64: - return -x, nil - case int8: - return -x, nil - case int16: - return -x, nil - case int32: - return -x, nil - case int64: - return -x, nil - case string: - return undOp(a, op) - case uint8: - return -x, nil - case uint16: - return -x, nil - case uint32: - return -x, nil - case uint64: - return -x, nil - case *big.Int: - var z big.Int - return z.Neg(x), nil - case *big.Rat: - var z big.Rat - return z.Neg(x), nil - case time.Duration: - return -x, nil - default: - return undOp(a, op) - } - default: - panic("internal error 039") - } -} - -type call struct { - f string - arg []expression -} - -func newCall(f string, arg []expression) (v expression, isAgg bool, err error) { - x := builtin[f] - if x.f == nil { - return nil, false, fmt.Errorf("undefined: %s", f) - } - - isAgg = x.isAggregate - if g, min, max := len(arg), x.minArgs, x.maxArgs; g < min || g > max { - a := []interface{}{} - for _, v := range arg { - a = append(a, v) - } - return nil, false, badNArgs(min, f, a) - } - - c := call{f: f} - for _, val := range arg { - if !val.isStatic() { - c.arg = append(c.arg, val) - continue - } - - eval, err := val.eval(nil, nil) - if err != nil { - return nil, isAgg, err - } - - c.arg = append(c.arg, value{eval}) - } - - return &c, isAgg, nil -} - -func (c *call) clone(arg []interface{}, unqualify ...string) (expression, error) { - list, err := cloneExpressionList(arg, c.arg) - if err != nil { - return nil, err - } - - return &call{f: c.f, arg: list}, nil -} - -func (c *call) isStatic() bool { - v := builtin[c.f] - if v.f == nil || !v.isStatic { - return false - } - - for _, v := range c.arg { - if !v.isStatic() { - return false - } - } - return true -} - -func (c *call) String() string { - a := []string{} - for _, v := range c.arg { - a = append(a, v.String()) - } - return fmt.Sprintf("%s(%s)", c.f, strings.Join(a, ", ")) -} - -func (c *call) eval(execCtx *execCtx, ctx map[interface{}]interface{}) (v interface{}, err error) { - f, ok := builtin[c.f] - if !ok { - return nil, fmt.Errorf("unknown function %s", c.f) - } - - isID := c.f == "id" - a := make([]interface{}, len(c.arg)) - for i, arg := range c.arg { - if v, err = expand1(arg.eval(execCtx, ctx)); err != nil { - if !isID { - return nil, err - } - - if _, ok := arg.(*ident); !ok { - return nil, err - } - - a[i] = arg - continue - } - - a[i] = v - } - - if ctx != nil { - ctx["$fn"] = c - } - return f.f(a, ctx) -} - -type parameter struct { - n int -} - -func (p parameter) clone(arg []interface{}, unqualify ...string) (expression, error) { - i := p.n - 1 - if i < len(arg) { - return value{val: arg[i]}, nil - } - - return nil, fmt.Errorf("missing %s", p) -} - -func (parameter) isStatic() bool { return false } - -func (p parameter) String() string { return fmt.Sprintf("$%d", p.n) } - -func (p parameter) eval(execCtx *execCtx, ctx map[interface{}]interface{}) (v interface{}, err error) { - i := p.n - 1 - if i < len(execCtx.arg) { - return execCtx.arg[i], nil - } - - return nil, fmt.Errorf("missing %s", p) -} - -//MAYBE make it an unary operation -type isNull struct { - expr expression - not bool -} - -//LATER newIsNull - -func (is *isNull) clone(arg []interface{}, unqualify ...string) (expression, error) { - expr, err := is.expr.clone(arg, unqualify...) - if err != nil { - return nil, err - } - - return &isNull{expr: expr, not: is.not}, nil -} - -func (is *isNull) isStatic() bool { return is.expr.isStatic() } - -func (is *isNull) String() string { - if is.not { - return fmt.Sprintf("%s IS NOT NULL", is.expr) - } - - return fmt.Sprintf("%s IS NULL", is.expr) -} - -func (is *isNull) eval(execCtx *execCtx, ctx map[interface{}]interface{}) (v interface{}, err error) { - val, err := is.expr.eval(execCtx, ctx) - if err != nil { - return - } - - return val == nil != is.not, nil -} - -type indexOp struct { - expr, x expression -} - -func newIndex(sv, xv expression) (v expression, err error) { - s, fs, i := "", false, uint64(0) - x := indexOp{sv, xv} - if x.expr.isStatic() { - v, err := x.expr.eval(nil, nil) - if err != nil { - return nil, err - } - - if v == nil { - return value{nil}, nil - } - - if s, fs = v.(string); !fs { - return nil, invXOp(sv, xv) - } - - x.expr = value{s} - } - - if x.x.isStatic() { - v, err := x.x.eval(nil, nil) - if err != nil { - return nil, err - } - - if v == nil { - return value{nil}, nil - } - - var p *string - if fs { - p = &s - } - if i, err = indexExpr(p, v); err != nil { - return nil, err - } - - x.x = value{i} - } - - return &x, nil -} - -func (x *indexOp) clone(arg []interface{}, unqualify ...string) (expression, error) { - expr, err := x.expr.clone(arg, unqualify...) - if err != nil { - return nil, err - } - - x2, err := x.x.clone(arg, unqualify...) - if err != nil { - return nil, err - } - - return &indexOp{expr: expr, x: x2}, nil -} - -func (x *indexOp) isStatic() bool { - return x.expr.isStatic() && x.x.isStatic() -} - -func (x *indexOp) String() string { return fmt.Sprintf("%s[%s]", x.expr, x.x) } - -func (x *indexOp) eval(execCtx *execCtx, ctx map[interface{}]interface{}) (v interface{}, err error) { - s0, err := x.expr.eval(execCtx, ctx) - if err != nil { - return nil, runErr(err) - } - - s, ok := s0.(string) - if !ok { - return nil, runErr(invXOp(s0, x.x)) - } - - i0, err := x.x.eval(execCtx, ctx) - if err != nil { - return nil, runErr(err) - } - - if i0 == nil { - return nil, nil - } - - i, err := indexExpr(&s, i0) - if err != nil { - return nil, runErr(err) - } - - return s[i], nil -} - -type slice struct { - expr expression - lo, hi *expression -} - -func newSlice(e expression, lo, hi *expression) (v expression, err error) { - y := slice{e, lo, hi} - var val interface{} - if e := y.expr; e.isStatic() { - if val, err = e.eval(nil, nil); err != nil { - return nil, err - } - - if val == nil { - return value{nil}, nil - } - - y.expr = value{val} - } - - if p := y.lo; p != nil { - if e := expr(*p); e.isStatic() { - if val, err = e.eval(nil, nil); err != nil { - return nil, err - } - - if val == nil { - return value{nil}, nil - } - - v := expression(value{val}) - y.lo = &v - } - } - - if p := y.hi; p != nil { - if e := expr(*p); e.isStatic() { - if val, err = e.eval(nil, nil); err != nil { - return nil, err - } - - if val == nil { - return value{nil}, nil - } - - v := expression(value{val}) - y.hi = &v - } - } - return &y, nil -} - -func (s *slice) clone(arg []interface{}, unqualify ...string) (expression, error) { - expr, err := s.expr.clone(arg, unqualify...) - if err != nil { - return nil, err - } - - r := &slice{expr: expr, lo: s.lo, hi: s.hi} - if s.lo != nil { - e, err := (*s.lo).clone(arg, unqualify...) - if err != nil { - return nil, err - } - - r.lo = &e - } - if s.hi != nil { - e, err := (*s.hi).clone(arg, unqualify...) - if err != nil { - return nil, err - } - - r.hi = &e - } - return r, nil -} - -func (s *slice) eval(execCtx *execCtx, ctx map[interface{}]interface{}) (v interface{}, err error) { - s0, err := s.expr.eval(execCtx, ctx) - if err != nil { - return - } - - if s0 == nil { - return - } - - ss, ok := s0.(string) - if !ok { - return nil, runErr(invSOp(s0)) - } - - var iLo, iHi uint64 - if s.lo != nil { - i, err := (*s.lo).eval(execCtx, ctx) - if err != nil { - return nil, err - } - - if i == nil { - return nil, err - } - - if iLo, err = sliceExpr(&ss, i, 0); err != nil { - return nil, err - } - } - - iHi = uint64(len(ss)) - if s.hi != nil { - i, err := (*s.hi).eval(execCtx, ctx) - if err != nil { - return nil, err - } - - if i == nil { - return nil, err - } - - if iHi, err = sliceExpr(&ss, i, 1); err != nil { - return nil, err - } - } - - return ss[iLo:iHi], nil -} - -func (s *slice) isStatic() bool { - if !s.expr.isStatic() { - return false - } - - if p := s.lo; p != nil && !(*p).isStatic() { - return false - } - - if p := s.hi; p != nil && !(*p).isStatic() { - return false - } - - return false -} - -func (s *slice) String() string { - switch { - case s.lo == nil && s.hi == nil: - return fmt.Sprintf("%v[:]", s.expr) - case s.lo == nil && s.hi != nil: - return fmt.Sprintf("%v[:%v]", s.expr, *s.hi) - case s.lo != nil && s.hi == nil: - return fmt.Sprintf("%v[%v:]", s.expr, *s.lo) - default: //case s.lo != nil && s.hi != nil: - return fmt.Sprintf("%v[%v:%v]", s.expr, *s.lo, *s.hi) - } -} diff --git a/Godeps/_workspace/src/github.com/cznic/ql/file.go b/Godeps/_workspace/src/github.com/cznic/ql/file.go deleted file mode 100644 index c7fb7c95ed..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/file.go +++ /dev/null @@ -1,1279 +0,0 @@ -// Copyright 2014 The ql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Well known handles -// 1: root -// 2: id - -package ql - -import ( - "crypto/sha1" - "fmt" - "io" - "io/ioutil" - "math/big" - "os" - "path/filepath" - "sync" - "time" - - "github.com/camlistore/go4/lock" - "github.com/cznic/exp/lldb" - "github.com/cznic/mathutil" -) - -const ( - magic = "\x60\xdbql" -) - -var ( - _ btreeIndex = (*fileIndex)(nil) - _ btreeIterator = (*fileBTreeIterator)(nil) - _ indexIterator = (*fileIndexIterator)(nil) - _ storage = (*file)(nil) - _ temp = (*fileTemp)(nil) -) - -type chunk struct { // expanded to blob types lazily - f *file - b []byte -} - -func (c chunk) expand() (v interface{}, err error) { - return c.f.loadChunks(c.b) -} - -func expand1(data interface{}, e error) (v interface{}, err error) { - if e != nil { - return nil, e - } - - c, ok := data.(chunk) - if !ok { - return data, nil - } - - return c.expand() -} - -func expand(data []interface{}) (err error) { - for i, v := range data { - if data[i], err = expand1(v, nil); err != nil { - return - } - } - return -} - -// OpenFile returns a DB backed by a named file. The back end limits the size -// of a record to about 64 kB. -func OpenFile(name string, opt *Options) (db *DB, err error) { - var f lldb.OSFile - if f = opt.OSFile; f == nil { - f, err = os.OpenFile(name, os.O_RDWR, 0666) - if err != nil { - if !os.IsNotExist(err) { - return nil, err - } - - if !opt.CanCreate { - return nil, err - } - - f, err = os.OpenFile(name, os.O_CREATE|os.O_EXCL|os.O_RDWR, 0666) - if err != nil { - return nil, err - } - } - } - - fi, err := newFileFromOSFile(f) // always ACID - if err != nil { - return - } - - if fi.tempFile = opt.TempFile; fi.tempFile == nil { - fi.tempFile = func(dir, prefix string) (f lldb.OSFile, err error) { - f0, err := ioutil.TempFile(dir, prefix) - return f0, err - } - } - - return newDB(fi) -} - -// Options amend the behavior of OpenFile. -// -// CanCreate -// -// The CanCreate option enables OpenFile to create the DB file if it does not -// exists. -// -// OSFile -// -// OSFile allows to pass an os.File like back end providing, for example, -// encrypted storage. If this field is nil then OpenFile uses the file named by -// the 'name' parameter instead. -// -// TempFile -// -// TempFile provides a temporary file used for evaluating the GROUP BY, ORDER -// BY, ... clauses. The hook is intended to be used by encrypted DB back ends -// to avoid leaks of unecrypted data to such temp files by providing temp files -// which are encrypted as well. Note that *os.File satisfies the lldb.OSFile -// interface. -// -// If TempFile is nil it defaults to ioutil.TempFile. -type Options struct { - CanCreate bool - OSFile lldb.OSFile - TempFile func(dir, prefix string) (f lldb.OSFile, err error) -} - -type fileBTreeIterator struct { - en *lldb.BTreeEnumerator - t *fileTemp -} - -func (it *fileBTreeIterator) Next() (k, v []interface{}, err error) { - bk, bv, err := it.en.Next() - if err != nil { - return - } - - if k, err = lldb.DecodeScalars(bk); err != nil { - return - } - - for i, val := range k { - b, ok := val.([]byte) - if !ok { - continue - } - - c := chunk{it.t.file, b} - if k[i], err = c.expand(); err != nil { - return nil, nil, err - } - } - - if err = enforce(k, it.t.colsK); err != nil { - return - } - - if v, err = lldb.DecodeScalars(bv); err != nil { - return - } - - for i, val := range v { - b, ok := val.([]byte) - if !ok { - continue - } - - c := chunk{it.t.file, b} - if v[i], err = c.expand(); err != nil { - return nil, nil, err - } - } - - err = enforce(v, it.t.colsV) - return -} - -func enforce(val []interface{}, cols []*col) (err error) { - for i, v := range val { - if val[i], err = convert(v, cols[i].typ); err != nil { - return - } - } - return -} - -//NTYPE -func infer(from []interface{}, to *[]*col) { - if len(*to) == 0 { - *to = make([]*col, len(from)) - for i := range *to { - (*to)[i] = &col{} - } - } - for i, c := range *to { - if f := from[i]; f != nil { - switch x := f.(type) { - //case nil: - case idealComplex: - c.typ = qComplex128 - from[i] = complex128(x) - case idealFloat: - c.typ = qFloat64 - from[i] = float64(x) - case idealInt: - c.typ = qInt64 - from[i] = int64(x) - case idealRune: - c.typ = qInt32 - from[i] = int32(x) - case idealUint: - c.typ = qUint64 - from[i] = uint64(x) - case bool: - c.typ = qBool - case complex128: - c.typ = qComplex128 - case complex64: - c.typ = qComplex64 - case float64: - c.typ = qFloat64 - case float32: - c.typ = qFloat32 - case int8: - c.typ = qInt8 - case int16: - c.typ = qInt16 - case int32: - c.typ = qInt32 - case int64: - c.typ = qInt64 - case string: - c.typ = qString - case uint8: - c.typ = qUint8 - case uint16: - c.typ = qUint16 - case uint32: - c.typ = qUint32 - case uint64: - c.typ = qUint64 - case []byte: - c.typ = qBlob - case *big.Int: - c.typ = qBigInt - case *big.Rat: - c.typ = qBigRat - case time.Time: - c.typ = qTime - case time.Duration: - c.typ = qDuration - case chunk: - vals, err := lldb.DecodeScalars([]byte(x.b)) - if err != nil { - panic(err) - } - - if len(vals) == 0 { - panic("internal error 040") - } - - i, ok := vals[0].(int64) - if !ok { - panic("internal error 041") - } - - c.typ = int(i) - case map[string]interface{}: // map of ids of a cross join - default: - panic("internal error 042") - } - } - } -} - -type fileTemp struct { - *file - colsK []*col - colsV []*col - t *lldb.BTree -} - -func (t *fileTemp) BeginTransaction() error { - return nil -} - -func (t *fileTemp) Get(k []interface{}) (v []interface{}, err error) { - if err = expand(k); err != nil { - return - } - - if err = t.flatten(k); err != nil { - return nil, err - } - - bk, err := lldb.EncodeScalars(k...) - if err != nil { - return - } - - bv, err := t.t.Get(nil, bk) - if err != nil { - return - } - - return lldb.DecodeScalars(bv) -} - -func (t *fileTemp) Drop() (err error) { - if t.f0 == nil { - return - } - - fn := t.f0.Name() - if err = t.f0.Close(); err != nil { - return - } - - if fn == "" { - return - } - - return os.Remove(fn) -} - -func (t *fileTemp) SeekFirst() (it btreeIterator, err error) { - en, err := t.t.SeekFirst() - if err != nil { - return - } - - return &fileBTreeIterator{t: t, en: en}, nil -} - -func (t *fileTemp) Set(k, v []interface{}) (err error) { - if err = expand(k); err != nil { - return - } - - if err = expand(v); err != nil { - return - } - - infer(k, &t.colsK) - infer(v, &t.colsV) - - if err = t.flatten(k); err != nil { - return - } - - bk, err := lldb.EncodeScalars(k...) - if err != nil { - return - } - - if err = t.flatten(v); err != nil { - return - } - - bv, err := lldb.EncodeScalars(v...) - if err != nil { - return - } - - return t.t.Set(bk, bv) -} - -type file struct { - a *lldb.Allocator - codec *gobCoder - f lldb.Filer - f0 lldb.OSFile - id int64 - lck io.Closer - mu sync.Mutex - name string - tempFile func(dir, prefix string) (f lldb.OSFile, err error) - wal *os.File -} - -func newFileFromOSFile(f lldb.OSFile) (fi *file, err error) { - nm := lockName(f.Name()) - lck, err := lock.Lock(nm) - if err != nil { - if lck != nil { - lck.Close() - } - return nil, err - } - - close := true - defer func() { - if close && lck != nil { - lck.Close() - } - }() - - var w *os.File - closew := false - wn := walName(f.Name()) - w, err = os.OpenFile(wn, os.O_CREATE|os.O_EXCL|os.O_RDWR, 0666) - closew = true - defer func() { - if closew { - nm := w.Name() - w.Close() - os.Remove(nm) - w = nil - } - }() - - if err != nil { - if !os.IsExist(err) { - return nil, err - } - - closew = false - w, err = os.OpenFile(wn, os.O_RDWR, 0666) - if err != nil { - return nil, err - } - - closew = true - st, err := w.Stat() - if err != nil { - return nil, err - } - - if st.Size() != 0 { - return nil, fmt.Errorf("(file-001) non empty WAL file %s exists", wn) - } - } - - info, err := f.Stat() - if err != nil { - return nil, err - } - - switch sz := info.Size(); { - case sz == 0: - b := make([]byte, 16) - copy(b, []byte(magic)) - if _, err := f.Write(b); err != nil { - return nil, err - } - - filer := lldb.Filer(lldb.NewOSFiler(f)) - filer = lldb.NewInnerFiler(filer, 16) - if filer, err = lldb.NewACIDFiler(filer, w); err != nil { - return nil, err - } - - a, err := lldb.NewAllocator(filer, &lldb.Options{}) - if err != nil { - return nil, err - } - - a.Compress = true - s := &file{ - a: a, - codec: newGobCoder(), - f0: f, - f: filer, - lck: lck, - name: f.Name(), - wal: w, - } - if err = s.BeginTransaction(); err != nil { - return nil, err - } - - h, err := s.Create() - if err != nil { - return nil, err - } - - if h != 1 { // root - panic("internal error 043") - } - - if h, err = s.a.Alloc(make([]byte, 8)); err != nil { - return nil, err - } - - if h != 2 { // id - panic("internal error 044") - } - - close, closew = false, false - return s, s.Commit() - default: - b := make([]byte, 16) - if _, err := f.Read(b); err != nil { - return nil, err - } - - if string(b[:len(magic)]) != magic { - return nil, fmt.Errorf("(file-002) unknown file format") - } - - filer := lldb.Filer(lldb.NewOSFiler(f)) - filer = lldb.NewInnerFiler(filer, 16) - if filer, err = lldb.NewACIDFiler(filer, w); err != nil { - return nil, err - } - - a, err := lldb.NewAllocator(filer, &lldb.Options{}) - if err != nil { - return nil, err - } - - bid, err := a.Get(nil, 2) // id - if err != nil { - return nil, err - } - - if len(bid) != 8 { - return nil, fmt.Errorf("(file-003) corrupted DB: id |% x|", bid) - } - - id := int64(0) - for _, v := range bid { - id = (id << 8) | int64(v) - } - - a.Compress = true - s := &file{ - a: a, - codec: newGobCoder(), - f0: f, - f: filer, - id: id, - lck: lck, - name: f.Name(), - wal: w, - } - - close, closew = false, false - return s, nil - } -} - -func (s *file) OpenIndex(unique bool, handle int64) (btreeIndex, error) { - t, err := lldb.OpenBTree(s.a, s.collate, handle) - if err != nil { - return nil, err - } - - return &fileIndex{s, handle, t, unique}, nil -} - -func (s *file) CreateIndex(unique bool) ( /* handle */ int64, btreeIndex, error) { - t, h, err := lldb.CreateBTree(s.a, s.collate) - if err != nil { - return -1, nil, err - } - - return h, &fileIndex{s, h, t, unique}, nil -} - -func (s *file) Acid() bool { return s.wal != nil } - -func errSet(p *error, errs ...error) (err error) { - err = *p - for _, e := range errs { - if err != nil { - return - } - *p, err = e, e - } - return -} - -func (s *file) lock() func() { - s.mu.Lock() - return s.mu.Unlock -} - -func (s *file) Close() (err error) { - defer s.lock()() - - es := s.f0.Sync() - ef := s.f0.Close() - var ew error - if s.wal != nil { - ew = s.wal.Close() - } - el := s.lck.Close() - return errSet(&err, es, ef, ew, el) -} - -func (s *file) Name() string { return s.name } - -func (s *file) Verify() (allocs int64, err error) { - defer s.lock()() - var stat lldb.AllocStats - if err = s.a.Verify(lldb.NewMemFiler(), nil, &stat); err != nil { - return - } - - allocs = stat.AllocAtoms - return -} - -func (s *file) expandBytes(d []interface{}) (err error) { - for i, v := range d { - b, ok := v.([]byte) - if !ok { - continue - } - - d[i], err = s.loadChunks(b) - if err != nil { - return - } - } - return -} - -func (s *file) collate(a, b []byte) int { //TODO w/ error return - da, err := lldb.DecodeScalars(a) - if err != nil { - panic(err) - } - - if err = s.expandBytes(da); err != nil { - panic(err) - } - - db, err := lldb.DecodeScalars(b) - if err != nil { - panic(err) - } - - if err = s.expandBytes(db); err != nil { - panic(err) - } - - //dbg("da: %v, db: %v", da, db) - return collate(da, db) -} - -func (s *file) CreateTemp(asc bool) (bt temp, err error) { - f, err := s.tempFile("", "ql-tmp-") - if err != nil { - return nil, err - } - - fn := f.Name() - filer := lldb.NewOSFiler(f) - a, err := lldb.NewAllocator(filer, &lldb.Options{}) - if err != nil { - f.Close() - os.Remove(fn) - return nil, err - } - - k := 1 - if !asc { - k = -1 - } - - t, _, err := lldb.CreateBTree(a, func(a, b []byte) int { //TODO w/ error return - return k * s.collate(a, b) - }) - if err != nil { - f.Close() - if fn != "" { - os.Remove(fn) - } - return nil, err - } - - x := &fileTemp{file: &file{ - a: a, - codec: newGobCoder(), - f0: f, - }, - t: t} - return x, nil -} - -func (s *file) BeginTransaction() (err error) { - defer s.lock()() - return s.f.BeginUpdate() -} - -func (s *file) Rollback() (err error) { - defer s.lock()() - return s.f.Rollback() -} - -func (s *file) Commit() (err error) { - defer s.lock()() - return s.f.EndUpdate() -} - -func (s *file) Create(data ...interface{}) (h int64, err error) { - if err = expand(data); err != nil { - return - } - - if err = s.flatten(data); err != nil { - return - } - - b, err := lldb.EncodeScalars(data...) - if err != nil { - return - } - - defer s.lock()() - return s.a.Alloc(b) -} - -func (s *file) Delete(h int64, blobCols ...*col) (err error) { - switch len(blobCols) { - case 0: - defer s.lock()() - return s.a.Free(h) - default: - return s.free(h, blobCols) - } -} - -func (s *file) ResetID() (err error) { - s.id = 0 - return -} - -func (s *file) ID() (int64, error) { - defer s.lock()() - - s.id++ - b := make([]byte, 8) - id := s.id - for i := 7; i >= 0; i-- { - b[i] = byte(id) - id >>= 8 - } - - return s.id, s.a.Realloc(2, b) -} - -func (s *file) free(h int64, blobCols []*col) (err error) { - b, err := s.a.Get(nil, h) //LATER +bufs - if err != nil { - return - } - - rec, err := lldb.DecodeScalars(b) - if err != nil { - return - } - - for _, col := range blobCols { - if col.index >= len(rec) { - return fmt.Errorf("(file-004) file.free: corrupted DB (record len)") - } - if col.index+2 >= len(rec) { - continue - } - - switch x := rec[col.index+2].(type) { - case nil: - // nop - case []byte: - if err = s.freeChunks(x); err != nil { - return - } - } - } - defer s.lock()() - return s.a.Free(h) -} - -func (s *file) Read(dst []interface{}, h int64, cols ...*col) (data []interface{}, err error) { //NTYPE - b, err := s.a.Get(nil, h) //LATER +bufs - if err != nil { - return - } - - rec, err := lldb.DecodeScalars(b) - if err != nil { - return - } - - for _, col := range cols { - i := col.index + 2 - if i >= len(rec) || rec[i] == nil { - continue - } - - switch col.typ { - case 0: - case qBool: - case qComplex64: - rec[i] = complex64(rec[i].(complex128)) - case qComplex128: - case qFloat32: - rec[i] = float32(rec[i].(float64)) - case qFloat64: - case qInt8: - rec[i] = int8(rec[i].(int64)) - case qInt16: - rec[i] = int16(rec[i].(int64)) - case qInt32: - rec[i] = int32(rec[i].(int64)) - case qInt64: - case qString: - case qUint8: - rec[i] = uint8(rec[i].(uint64)) - case qUint16: - rec[i] = uint16(rec[i].(uint64)) - case qUint32: - rec[i] = uint32(rec[i].(uint64)) - case qUint64: - case qBlob, qBigInt, qBigRat, qTime, qDuration: - switch x := rec[i].(type) { - case []byte: - rec[i] = chunk{f: s, b: x} - default: - return nil, fmt.Errorf("(file-006) corrupted DB: non nil chunk type is not []byte") - } - default: - panic("internal error 045") - } - } - - if cols != nil { - for n, dn := len(cols)+2, len(rec); dn < n; dn++ { - rec = append(rec, nil) - } - } - - return rec, nil -} - -func (s *file) freeChunks(enc []byte) (err error) { - items, err := lldb.DecodeScalars(enc) - if err != nil { - return - } - - var ok bool - var next int64 - switch len(items) { - case 2: - return - case 3: - if next, ok = items[1].(int64); !ok || next == 0 { - return fmt.Errorf("(file-007) corrupted DB: first chunk link") - } - default: - return fmt.Errorf("(file-008) corrupted DB: first chunk") - } - - for next != 0 { - b, err := s.a.Get(nil, next) - if err != nil { - return err - } - - if items, err = lldb.DecodeScalars(b); err != nil { - return err - } - - var h int64 - switch len(items) { - case 1: - // nop - case 2: - if h, ok = items[0].(int64); !ok { - return fmt.Errorf("(file-009) corrupted DB: chunk link") - } - - default: - return fmt.Errorf("(file-010) corrupted DB: chunk items %d (%v)", len(items), items) - } - - s.mu.Lock() - if err = s.a.Free(next); err != nil { - s.mu.Unlock() - return err - } - - s.mu.Unlock() - next = h - } - return -} - -func (s *file) loadChunks(enc []byte) (v interface{}, err error) { - items, err := lldb.DecodeScalars(enc) - if err != nil { - return - } - - var ok bool - var next int64 - switch len(items) { - case 2: - // nop - case 3: - if next, ok = items[1].(int64); !ok || next == 0 { - return nil, fmt.Errorf("(file-011) corrupted DB: first chunk link") - } - default: - //fmt.Printf("%d: %#v\n", len(items), items) - return nil, fmt.Errorf("(file-012) corrupted DB: first chunk") - } - - typ, ok := items[0].(int64) - if !ok { - return nil, fmt.Errorf("(file-013) corrupted DB: first chunk tag") - } - - buf, ok := items[len(items)-1].([]byte) - if !ok { - return nil, fmt.Errorf("(file-014) corrupted DB: first chunk data") - } - - for next != 0 { - b, err := s.a.Get(nil, next) - if err != nil { - return nil, err - } - - if items, err = lldb.DecodeScalars(b); err != nil { - return nil, err - } - - switch len(items) { - case 1: - next = 0 - case 2: - if next, ok = items[0].(int64); !ok { - return nil, fmt.Errorf("(file-015) corrupted DB: chunk link") - } - - items = items[1:] - default: - return nil, fmt.Errorf("(file-016) corrupted DB: chunk items %d (%v)", len(items), items) - } - - if b, ok = items[0].([]byte); !ok { - return nil, fmt.Errorf("(file-017) corrupted DB: chunk data") - } - - buf = append(buf, b...) - } - return s.codec.decode(buf, int(typ)) -} - -func (s *file) Update(h int64, data ...interface{}) (err error) { - b, err := lldb.EncodeScalars(data...) - if err != nil { - return - } - - defer s.lock()() - return s.a.Realloc(h, b) -} - -func (s *file) UpdateRow(h int64, blobCols []*col, data ...interface{}) (err error) { - if len(blobCols) == 0 { - return s.Update(h, data...) - } - - if err = expand(data); err != nil { - return - } - - data0, err := s.Read(nil, h, blobCols...) - if err != nil { - return - } - - for _, c := range blobCols { - if c.index+2 >= len(data0) { - continue - } - - if x := data0[c.index+2]; x != nil { - if err = s.freeChunks(x.(chunk).b); err != nil { - return - } - } - } - - if err = s.flatten(data); err != nil { - return - } - - return s.Update(h, data...) -} - -// []interface{}{qltype, ...}->[]interface{}{lldb scalar type, ...} -// + long blobs are (pre)written to a chain of chunks. -func (s *file) flatten(data []interface{}) (err error) { - for i, v := range data { - tag := 0 - var b []byte - switch x := v.(type) { - case []byte: - tag = qBlob - b = x - case *big.Int: - tag = qBigInt - b, err = s.codec.encode(x) - case *big.Rat: - tag = qBigRat - b, err = s.codec.encode(x) - case time.Time: - tag = qTime - b, err = s.codec.encode(x) - case time.Duration: - tag = qDuration - b, err = s.codec.encode(x) - default: - continue - } - if err != nil { - return - } - - const chunk = 1 << 16 - chunks := 0 - var next int64 - var buf []byte - for rem := len(b); rem > shortBlob; { - n := mathutil.Min(rem, chunk) - part := b[rem-n:] - b = b[:rem-n] - rem -= n - switch next { - case 0: // last chunk - buf, err = lldb.EncodeScalars([]interface{}{part}...) - default: // middle chunk - buf, err = lldb.EncodeScalars([]interface{}{next, part}...) - } - if err != nil { - return - } - - s.mu.Lock() - h, err := s.a.Alloc(buf) - s.mu.Unlock() - if err != nil { - return err - } - - next = h - chunks++ - } - - switch next { - case 0: // single chunk - buf, err = lldb.EncodeScalars([]interface{}{tag, b}...) - default: // multi chunks - buf, err = lldb.EncodeScalars([]interface{}{tag, next, b}...) - } - if err != nil { - return - } - - data[i] = buf - } - return -} - -func lockName(dbname string) string { - base := filepath.Base(filepath.Clean(dbname)) + "lockfile" - h := sha1.New() - io.WriteString(h, base) - return filepath.Join(filepath.Dir(dbname), fmt.Sprintf(".%x", h.Sum(nil))) -} - -func walName(dbname string) (r string) { - base := filepath.Base(filepath.Clean(dbname)) - h := sha1.New() - io.WriteString(h, base) - return filepath.Join(filepath.Dir(dbname), fmt.Sprintf(".%x", h.Sum(nil))) -} - -type fileIndex struct { - f *file - h int64 - t *lldb.BTree - unique bool -} - -func (x *fileIndex) Clear() error { - return x.t.Clear() -} - -var gbZeroInt64 []byte - -func init() { - var err error - if gbZeroInt64, err = lldb.EncodeScalars(int64(0)); err != nil { - panic(err) - } -} - -func isIndexNull(data []interface{}) bool { - for _, v := range data { - if v != nil { - return false - } - } - return true -} - -// The []byte version of the key in the BTree shares chunks, if any, with -// the value stored in the record. -func (x *fileIndex) Create(indexedValues []interface{}, h int64) error { - for i, indexedValue := range indexedValues { - chunk, ok := indexedValue.(chunk) - if ok { - indexedValues[i] = chunk.b - } - } - - t := x.t - switch { - case !x.unique: - k, err := lldb.EncodeScalars(append(indexedValues, h)...) - if err != nil { - return err - } - - return t.Set(k, gbZeroInt64) - case isIndexNull(indexedValues): // unique, NULL - k, err := lldb.EncodeScalars(nil, h) - if err != nil { - return err - } - - return t.Set(k, gbZeroInt64) - default: // unique, non NULL - k, err := lldb.EncodeScalars(append(indexedValues, int64(0))...) - if err != nil { - return err - } - - v, err := lldb.EncodeScalars(h) - if err != nil { - return err - } - - _, _, err = t.Put(nil, k, func(key, old []byte) (new []byte, write bool, err error) { - if old == nil { - return v, true, nil - } - - return nil, false, fmt.Errorf("(file-018) cannot insert into unique index: duplicate value(s): %v", indexedValues) - }) - return err - } -} - -func (x *fileIndex) Delete(indexedValues []interface{}, h int64) error { - for i, indexedValue := range indexedValues { - chunk, ok := indexedValue.(chunk) - if ok { - indexedValues[i] = chunk.b - } - } - - t := x.t - var k []byte - var err error - switch { - case !x.unique: - k, err = lldb.EncodeScalars(append(indexedValues, h)...) - case isIndexNull(indexedValues): // unique, NULL - k, err = lldb.EncodeScalars(nil, h) - default: // unique, non NULL - k, err = lldb.EncodeScalars(append(indexedValues, int64(0))...) - } - if err != nil { - return err - } - - return t.Delete(k) -} - -func (x *fileIndex) Drop() error { - if err := x.Clear(); err != nil { - return err - } - - return x.f.a.Free(x.h) -} - -func (x *fileIndex) Seek(indexedValues []interface{}) (indexIterator, bool, error) { //TODO(indices) blobs: +test - k, err := lldb.EncodeScalars(append(indexedValues, 0)...) - if err != nil { - return nil, false, err - } - - en, hit, err := x.t.Seek(k) - if err != nil { - return nil, false, err - } - - return &fileIndexIterator{x.f, en, x.unique}, hit, nil -} - -func (x *fileIndex) SeekFirst() (iter indexIterator, err error) { - en, err := x.t.SeekFirst() - return &fileIndexIterator{x.f, en, x.unique}, err -} - -func (x *fileIndex) SeekLast() (iter indexIterator, err error) { - en, err := x.t.SeekLast() - return &fileIndexIterator{x.f, en, x.unique}, err -} - -type fileIndexIterator struct { - f *file - en *lldb.BTreeEnumerator - unique bool -} - -func (i *fileIndexIterator) nextPrev(f func() ([]byte, []byte, error)) ([]interface{}, int64, error) { //TODO(indices) blobs: +test - bk, bv, err := f() - if err != nil { - return nil, -1, err - } - - dk, err := lldb.DecodeScalars(bk) - if err != nil { - return nil, -1, err - } - - b, ok := dk[0].([]byte) - if ok { - dk[0] = chunk{i.f, b} - if expand(dk[:1]); err != nil { - return nil, -1, err - } - } - - var k indexKey - k.value = dk[:len(dk)-1] - switch i.unique { - case true: - if isIndexNull(k.value) { - return nil, dk[len(dk)-1].(int64), nil - } - - dv, err := lldb.DecodeScalars(bv) - if err != nil { - return nil, -1, err - } - - return k.value, dv[0].(int64), nil - default: - return k.value, dk[len(dk)-1].(int64), nil - } -} - -func (i *fileIndexIterator) Next() ([]interface{}, int64, error) { //TODO(indices) blobs: +test - return i.nextPrev(i.en.Next) -} - -func (i *fileIndexIterator) Prev() ([]interface{}, int64, error) { //TODO(indices) blobs: +test - return i.nextPrev(i.en.Prev) -} diff --git a/Godeps/_workspace/src/github.com/cznic/ql/helper/helper.go b/Godeps/_workspace/src/github.com/cznic/ql/helper/helper.go deleted file mode 100644 index 7ce3015391..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/helper/helper.go +++ /dev/null @@ -1,338 +0,0 @@ -// +build ignore - -// Copyright 2014 The ql 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 main - -import ( - "bufio" - "flag" - "fmt" - "io" - "log" - "os" -) - -type t int - -const ( - qNil t = iota - idealComplex - idealFloat - idealInt - idealRune - idealUint - qBool - qComplex64 - qComplex128 - qFloat32 - qFloat64 - qInt8 - qInt16 - qInt32 - qInt64 - qString - qUint8 - qUint16 - qUint32 - qUint64 - qBigInt - qBigRat - qTime - qDuration - - qEnd -) - -func (n t) String() string { - switch n { - case qNil: - return "nil" - case idealComplex: - return "idealComplex" - case idealFloat: - return "idealFloat" - case idealInt: - return "idealInt" - case idealRune: - return "idealRune" - case idealUint: - return "idealUint" - case qBool: - return "bool" - case qComplex64: - return "complex64" - case qComplex128: - return "complex128" - case qFloat32: - return "float32" - case qFloat64: - return "float64" - case qInt8: - return "int8" - case qInt16: - return "int16" - case qInt32: - return "int32" - case qInt64: - return "int64" - case qString: - return "string" - case qUint8: - return "uint8" - case qUint16: - return "uint16" - case qUint32: - return "uint32" - case qUint64: - return "uint64" - case qBigInt: - return "*big.Int" - case qBigRat: - return "*big.Rat" - case qTime: - return "time.Time" - case qDuration: - return "time.Duration" - default: - panic("internal error 046") - } -} - -func coerceIdealComplex(typ t) string { - switch typ { - case qComplex64, qComplex128: - return fmt.Sprintf("return %s(x)\n", typ) - default: - return "" - } -} - -func coerceIdealFloat(typ t) string { - switch typ { - case idealComplex: - return fmt.Sprintf("return %s(complex(float64(x), 0))\n", typ) - case qComplex64: - return fmt.Sprintf("return %s(complex(float32(x), 0))\n", typ) - case qComplex128: - return fmt.Sprintf("return %s(complex(float64(x), 0))\n", typ) - case idealFloat, qFloat32, qFloat64: - return fmt.Sprintf("return %s(float64(x))\n", typ) - case qBigRat: - return fmt.Sprintf("return big.NewRat(1, 1).SetFloat64(float64(x))\n") - default: - return "" - } - return "" -} - -func coerceIdealInt(typ t) string { - switch typ { - case idealComplex: - return fmt.Sprintf("return %s(complex(float64(x), 0))\n", typ) - case qComplex64: - return fmt.Sprintf("return %s(complex(float32(x), 0))\n", typ) - case qComplex128: - return fmt.Sprintf("return %s(complex(float64(x), 0))\n", typ) - case idealFloat, idealInt, qFloat32, qFloat64, qInt64: - return fmt.Sprintf("return %s(int64(x))\n", typ) - case idealUint: - return fmt.Sprintf("if x >= 0 { return %s(int64(x)) }\n", typ) - case qInt8: - return fmt.Sprintf("if x >= math.MinInt8 && x<= math.MaxInt8 { return %s(int64(x)) }\n", typ) - case qInt16: - return fmt.Sprintf("if x >= math.MinInt16 && x<= math.MaxInt16 { return %s(int64(x)) }\n", typ) - case qInt32: - return fmt.Sprintf("if x >= math.MinInt32 && x<= math.MaxInt32 { return %s(int64(x)) }\n", typ) - case qUint8: - return fmt.Sprintf("if x >= 0 && x<= math.MaxUint8 { return %s(int64(x)) }\n", typ) - case qUint16: - return fmt.Sprintf("if x >= 0 && x<= math.MaxUint16 { return %s(int64(x)) }\n", typ) - case qUint32: - return fmt.Sprintf("if x >= 0 && x<= math.MaxUint32 { return %s(int64(x)) }\n", typ) - case qUint64: - return fmt.Sprintf("if x >= 0 { return %s(int64(x)) }\n", typ) - case qBigInt: - return fmt.Sprintf("return big.NewInt(int64(x))\n") - case qBigRat: - return fmt.Sprintf("return big.NewRat(1, 1).SetInt64(int64(x))\n") - case qDuration: - return fmt.Sprintf("return time.Duration(int64(x))\n") - default: - return "" - } - return "" -} - -func coerceIdealRune(typ t) string { - switch typ { - case idealComplex: - return fmt.Sprintf("return %s(complex(float64(x), 0))\n", typ) - case qComplex64: - return fmt.Sprintf("return %s(complex(float32(x), 0))\n", typ) - case qComplex128: - return fmt.Sprintf("return %s(complex(float64(x), 0))\n", typ) - case idealFloat, idealInt, idealRune, idealUint, qFloat32, qFloat64, qInt8, qInt16, qInt32, qInt64, qUint8, qUint16, qUint32, qUint64: - return fmt.Sprintf("return %s(int64(x))\n", typ) - case qBigInt: - return fmt.Sprintf("return big.NewInt(int64(x))\n") - case qBigRat: - return fmt.Sprintf("return big.NewRat(1, 1).SetInt64(int64(x))\n") - case qDuration: - return fmt.Sprintf("return time.Duration(int64(x))\n") - default: - return "" - } - return "" -} - -func coerceIdealUint(typ t) string { - switch typ { - case idealComplex: - return fmt.Sprintf("return %s(complex(float64(x), 0))\n", typ) - case qComplex64: - return fmt.Sprintf("return %s(complex(float32(x), 0))\n", typ) - case qComplex128: - return fmt.Sprintf("return %s(complex(float64(x), 0))\n", typ) - case idealFloat, idealUint, qFloat32, qFloat64, qUint64: - return fmt.Sprintf("return %s(uint64(x))\n", typ) - case idealInt: - return fmt.Sprintf("if x <= math.MaxInt64 { return %s(int64(x)) }\n", typ) - case qInt8: - return fmt.Sprintf("if x <= math.MaxInt8 { return %s(int64(x)) }\n", typ) - case qInt16: - return fmt.Sprintf("if x<= math.MaxInt16 { return %s(int64(x)) }\n", typ) - case qInt32: - return fmt.Sprintf("if x<= math.MaxInt32 { return %s(int64(x)) }\n", typ) - case qInt64: - return fmt.Sprintf("if x<= math.MaxInt64 { return %s(int64(x)) }\n", typ) - case qUint8: - return fmt.Sprintf("if x >= 0 && x<= math.MaxUint8 { return %s(int64(x)) }\n", typ) - case qUint16: - return fmt.Sprintf("if x >= 0 && x<= math.MaxUint16 { return %s(int64(x)) }\n", typ) - case qUint32: - return fmt.Sprintf("if x >= 0 && x<= math.MaxUint32 { return %s(int64(x)) }\n", typ) - case qBigInt: - return fmt.Sprintf("return big.NewInt(0).SetUint64(uint64(x))\n") - case qBigRat: - return fmt.Sprintf("return big.NewRat(1, 1).SetInt(big.NewInt(0).SetUint64(uint64(x)))\n") - case qDuration: - return fmt.Sprintf("if x <= math.MaxInt64 { return time.Duration(int64(x)) }\n") - default: - return "" - } - return "" -} - -func genCoerce1(w io.Writer, in t, f func(out t) string) { - fmt.Fprintf(w, "\tcase %s:\n", in) - fmt.Fprintf(w, "\t\tswitch otherVal.(type) {\n") - - for i := idealComplex; i < qEnd; i++ { - s := f(i) - switch s { - case "": - fmt.Fprintf(w, "\t\t//case %s:\n", i) - default: - fmt.Fprintf(w, "\t\tcase %s:\n", i) - fmt.Fprintf(w, "\t\t\t%s", s) - } - } - - fmt.Fprintf(w, "\t\t}\n") // switch -} - -func genCoerce(w io.Writer) { - fmt.Fprintf(w, - ` -func coerce1(inVal, otherVal interface{}) (coercedInVal interface{}) { - coercedInVal = inVal - if otherVal == nil { - return - } - - switch x := inVal.(type) { - case nil: - return -`) - genCoerce1(w, idealComplex, coerceIdealComplex) - genCoerce1(w, idealFloat, coerceIdealFloat) - genCoerce1(w, idealInt, coerceIdealInt) - genCoerce1(w, idealRune, coerceIdealRune) - genCoerce1(w, idealUint, coerceIdealUint) - fmt.Fprintf(w, "\t}\n") // switch - - fmt.Fprintf(w, "\treturn\n}\n") // func -} - -func main() { - ofn := flag.String("o", "", "") - flag.Parse() - _, err := os.Stat(*ofn) - if err == nil { - log.Fatalf("%s exists", *ofn) - } - - w := bufio.NewWriter(os.Stdout) - if s := *ofn; s != "" { - f, err := os.Create(s) - if err != nil { - log.Fatal(err) - } - - defer f.Close() - w = bufio.NewWriter(f) - } - defer w.Flush() - - fmt.Fprintf(w, `// Copyright 2013 The ql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// CAUTION: This file was generated automatically by -// -// $ go run helper/helper.go -o coerce.go -// -// DO NOT EDIT! - - package ql - -import ( - "math" - "math/big" - "reflect" - "time" -) - -func coerce(a, b interface{}) (x, y interface{}) { - if reflect.TypeOf(a) == reflect.TypeOf(b) { - return a, b - } - - switch a.(type) { - case idealComplex, idealFloat, idealInt, idealRune, idealUint: - switch b.(type) { - case idealComplex, idealFloat, idealInt, idealRune, idealUint: - x, y = coerce1(a, b), b - if reflect.TypeOf(x) == reflect.TypeOf(y) { - return - } - - return a, coerce1(b, a) - default: - return coerce1(a, b), b - } - default: - switch b.(type) { - case idealComplex, idealFloat, idealInt, idealRune, idealUint: - return a, coerce1(b, a) - default: - return a, b - } - } -} -`) - genCoerce(w) -} diff --git a/Godeps/_workspace/src/github.com/cznic/ql/httpfs.go b/Godeps/_workspace/src/github.com/cznic/ql/httpfs.go deleted file mode 100644 index 89c6f89c52..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/httpfs.go +++ /dev/null @@ -1,302 +0,0 @@ -// Copyright (c) 2014 ql 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 ql - -import ( - "fmt" - "io" - "net/http" - "os" - "path" - "path/filepath" - "strings" - "time" - - "github.com/cznic/mathutil" -) - -var ( - _ http.FileSystem = (*HTTPFS)(nil) - _ http.File = (*HTTPFile)(nil) - _ os.FileInfo = (*HTTPFile)(nil) - _ os.FileInfo = (*dirEntry)(nil) -) - -type dirEntry string - -func (d dirEntry) Name() string { return string(d) } -func (d dirEntry) Size() int64 { return -1 } -func (d dirEntry) Mode() os.FileMode { return os.ModeDir } -func (d dirEntry) ModTime() time.Time { return time.Time{} } -func (d dirEntry) IsDir() bool { return true } -func (d dirEntry) Sys() interface{} { return interface{}(nil) } - -// A HTTPFile is returned by the HTTPFS's Open method and can be served by the -// http.FileServer implementation. -type HTTPFile struct { - closed bool - content []byte - dirEntries []os.FileInfo - isFile bool - name string - off int - sz int -} - -// Close implements http.File. -func (f *HTTPFile) Close() error { - if f.closed { - return os.ErrInvalid - } - - f.closed = true - return nil -} - -// IsDir implements os.FileInfo -func (f *HTTPFile) IsDir() bool { return !f.isFile } - -// Mode implements os.FileInfo -func (f *HTTPFile) Mode() os.FileMode { - switch f.isFile { - case false: - return os.FileMode(0444) - default: - return os.ModeDir - } -} - -// ModTime implements os.FileInfo -func (f *HTTPFile) ModTime() time.Time { - return time.Time{} -} - -// Name implements os.FileInfo -func (f *HTTPFile) Name() string { return path.Base(f.name) } - -// Size implements os.FileInfo -func (f *HTTPFile) Size() int64 { - switch f.isFile { - case false: - return -1 - default: - return int64(len(f.content)) - } -} - -// Stat implements http.File. -func (f *HTTPFile) Stat() (os.FileInfo, error) { return f, nil } - -// Sys implements os.FileInfo -func (f *HTTPFile) Sys() interface{} { return interface{}(nil) } - -// Readdir implements http.File. -func (f *HTTPFile) Readdir(count int) ([]os.FileInfo, error) { - if f.isFile { - return nil, fmt.Errorf("not a directory: %s", f.name) - } - - if count <= 0 { - r := f.dirEntries - f.dirEntries = f.dirEntries[:0] - return r, nil - } - - rq := mathutil.Min(count, len(f.dirEntries)) - r := f.dirEntries[:rq] - f.dirEntries = f.dirEntries[rq:] - if len(r) != 0 { - return r, nil - } - - return nil, io.EOF -} - -// Read implements http.File. -func (f *HTTPFile) Read(b []byte) (int, error) { - if f.closed { - return 0, os.ErrInvalid - } - - n := copy(b, f.content[f.off:]) - f.off += n - if n != 0 { - return n, nil - } - - return 0, io.EOF -} - -// Seek implements http.File. -func (f *HTTPFile) Seek(offset int64, whence int) (int64, error) { - if f.closed { - return 0, os.ErrInvalid - } - - if offset < 0 { - return int64(f.off), fmt.Errorf("cannot seek before start of file") - } - - switch whence { - case 0: - noff := int64(f.off) + offset - if noff > mathutil.MaxInt { - return int64(f.off), fmt.Errorf("seek target overflows int: %d", noff) - } - - f.off = mathutil.Min(int(offset), len(f.content)) - if f.off == int(offset) { - return offset, nil - } - - return int64(f.off), io.EOF - case 1: - noff := int64(f.off) + offset - if noff > mathutil.MaxInt { - return int64(f.off), fmt.Errorf("seek target overflows int: %d", noff) - } - - off := mathutil.Min(f.off+int(offset), len(f.content)) - if off == f.off+int(offset) { - f.off = off - return int64(off), nil - } - - f.off = off - return int64(off), io.EOF - case 2: - noff := int64(f.off) - offset - if noff < 0 { - return int64(f.off), fmt.Errorf("cannot seek before start of file") - } - - f.off = len(f.content) - int(offset) - return int64(f.off), nil - default: - return int64(f.off), fmt.Errorf("seek: invalid whence %d", whence) - } -} - -// HTTPFS implements a http.FileSystem backed by data in a DB. -type HTTPFS struct { - db *DB - dir, get List -} - -// NewHTTPFS returns a http.FileSystem backed by a result record set of query. -// The record set provides two mandatory fields: path and content (the field -// names are case sensitive). Type of name must be string and type of content -// must be blob (ie. []byte). Field 'path' value is the "file" pathname, which -// must be rooted; and field 'content' value is its "data". -func (db *DB) NewHTTPFS(query string) (*HTTPFS, error) { - if _, err := Compile(query); err != nil { - return nil, err - } - - dir, err := Compile(fmt.Sprintf("SELECT path FROM (%s) WHERE hasPrefix(path, $1)", query)) - if err != nil { - return nil, err - } - - get, err := Compile(fmt.Sprintf("SELECT content FROM (%s) WHERE path == $1", query)) - if err != nil { - return nil, err - } - - return &HTTPFS{db: db, dir: dir, get: get}, nil -} - -// Open implements http.FileSystem. The name parameter represents a file path. -// The elements in a file path are separated by slash ('/', U+002F) characters, -// regardless of host operating system convention. -func (f *HTTPFS) Open(name string) (http.File, error) { - if filepath.Separator != '/' && strings.IndexRune(name, filepath.Separator) >= 0 || - strings.Contains(name, "\x00") { - return nil, fmt.Errorf("invalid character in file path: %q", name) - } - - name = path.Clean("/" + name) - rs, _, err := f.db.Execute(nil, f.get, name) - if err != nil { - return nil, err - } - - n := 0 - var fdata []byte - if err = rs[0].Do(false, func(data []interface{}) (more bool, err error) { - switch n { - case 0: - var ok bool - fdata, ok = data[0].([]byte) - if !ok { - return false, fmt.Errorf("open: expected blob, got %T", data[0]) - } - n++ - return true, nil - default: - return false, fmt.Errorf("open: more than one result was returned for %s", name) - } - }); err != nil { - return nil, err - } - - if n == 1 { // file found - return &HTTPFile{name: name, isFile: true, content: fdata}, nil - } - - dirName := name - if dirName[len(dirName)-1] != filepath.Separator { - dirName += string(filepath.Separator) - } - // Open("/a/b"): {/a/b/c.x,/a/b/d.x,/a/e.x,/a/b/f/g.x} -> {c.x,d.x,f} - rs, _, err = f.db.Execute(nil, f.dir, dirName) - if err != nil { - return nil, err - } - - n = 0 - r := &HTTPFile{name: dirName} - m := map[string]bool{} - x := len(dirName) - if err = rs[0].Do(false, func(data []interface{}) (more bool, err error) { - n++ - switch name := data[0].(type) { - case string: - if filepath.Separator != '/' && strings.IndexRune(name, filepath.Separator) >= 0 || - strings.Contains(name, "\x00") { - return false, fmt.Errorf("invalid character in file path: %q", name) - } - - name = path.Clean("/" + name) - rest := name[x:] - parts := strings.Split(rest, "/") - if len(parts) == 0 { - return true, nil - } - - nm := parts[0] - switch len(parts) { - case 1: // file - r.dirEntries = append(r.dirEntries, &HTTPFile{isFile: true, name: nm}) - default: // directory - if !m[nm] { - r.dirEntries = append(r.dirEntries, dirEntry(nm)) - } - m[nm] = true - } - return true, nil - default: - return false, fmt.Errorf("expected string path, got %T(%v)", name, name) - } - }); err != nil { - return nil, err - } - - if n != 0 { - return r, nil - } - - return nil, os.ErrNotExist -} diff --git a/Godeps/_workspace/src/github.com/cznic/ql/introspection.go b/Godeps/_workspace/src/github.com/cznic/ql/introspection.go deleted file mode 100644 index 61ac9a928d..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/introspection.go +++ /dev/null @@ -1,625 +0,0 @@ -// Copyright 2014 The ql 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 ql - -import ( - "bytes" - "fmt" - "go/ast" - "reflect" - "strings" - "sync" -) - -var ( - schemaCache = map[reflect.Type]*StructInfo{} - schemaMu sync.RWMutex -) - -// StructInfo describes a struct type. An instance of StructInfo obtained from -// StructSchema is shared and must not be mutated. That includes the values -// pointed to by the elements of Fields and Indices. -type StructInfo struct { - Fields []*StructField // Fields describe the considered fields of a struct type. - HasID bool // Whether the struct has a considered field named ID of type int64. - Indices []*StructIndex // Indices describe indices defined by the index or uindex ql tags. - IsPtr bool // Whether the StructInfo was derived from a pointer to a struct. -} - -// StructIndex describes an index defined by the ql tag index or uindex. -type StructIndex struct { - ColumnName string // Name of the column the index is on. - Name string // Name of the index. - Unique bool // Whether the index is unique. -} - -// StructField describes a considered field of a struct type. -type StructField struct { - Index int // Index is the index of the field for reflect.Value.Field. - IsID bool // Whether the field corresponds to record id(). - IsPtr bool // Whether the field is a pointer type. - MarshalType reflect.Type // The reflect.Type a field must be converted to when marshaling or nil when it is assignable directly. (Field->value) - Name string // Field name or value of the name tag (like in `ql:"name foo"`). - ReflectType reflect.Type // The reflect.Type of the field. - Tags map[string]string // QL tags of this field. (`ql:"a, b c, d"` -> {"a": "", "b": "c", "d": ""}) - Type Type // QL type of the field. - UnmarshalType reflect.Type // The reflect.Type a value must be converted to when unmarshaling or nil when it is assignable directly. (Field<-value) - ZeroPtr reflect.Value // The reflect.Zero value of the field if it's a pointer type. -} - -func (s *StructField) check(v interface{}) error { - t := reflect.TypeOf(v) - if !s.ReflectType.AssignableTo(t) { - if !s.ReflectType.ConvertibleTo(t) { - return fmt.Errorf("type %s (%v) cannot be converted to %T", s.ReflectType.Name(), s.ReflectType.Kind(), t.Name()) - } - - s.MarshalType = t - } - - if !t.AssignableTo(s.ReflectType) { - if !t.ConvertibleTo(s.ReflectType) { - return fmt.Errorf("type %s (%v) cannot be converted to %T", t.Name(), t.Kind(), s.ReflectType.Name()) - } - - s.UnmarshalType = s.ReflectType - } - return nil -} - -func parseTag(s string) map[string]string { - m := map[string]string{} - for _, v := range strings.Split(s, ",") { - v = strings.TrimSpace(v) - switch n := strings.IndexRune(v, ' '); { - case n < 0: - m[v] = "" - default: - m[v[:n]] = v[n+1:] - } - } - return m -} - -// StructSchema returns StructInfo for v which must be a struct instance or a -// pointer to a struct. The info is computed only once for every type. -// Subsequent calls to StructSchema for the same type return a cached -// StructInfo. -// -// Note: The returned StructSchema is shared and must be not mutated, including -// any other data structures it may point to. -func StructSchema(v interface{}) (*StructInfo, error) { - if v == nil { - return nil, fmt.Errorf("cannot derive schema for %T(%v)", v, v) - } - - typ := reflect.TypeOf(v) - schemaMu.RLock() - if r, ok := schemaCache[typ]; ok { - schemaMu.RUnlock() - return r, nil - } - - schemaMu.RUnlock() - var schemaPtr bool - t := typ - if t.Kind() == reflect.Ptr { - t = t.Elem() - schemaPtr = true - } - if k := t.Kind(); k != reflect.Struct { - return nil, fmt.Errorf("cannot derive schema for type %T (%v)", v, k) - } - - r := &StructInfo{IsPtr: schemaPtr} - for i := 0; i < t.NumField(); i++ { - f := t.Field(i) - fn := f.Name - if !ast.IsExported(fn) { - continue - } - - tags := parseTag(f.Tag.Get("ql")) - if _, ok := tags["-"]; ok { - continue - } - - if s := tags["name"]; s != "" { - fn = s - } - - if fn == "ID" && f.Type.Kind() == reflect.Int64 { - r.HasID = true - } - var ix, unique bool - var xn string - xfn := fn - if s := tags["index"]; s != "" { - if _, ok := tags["uindex"]; ok { - return nil, fmt.Errorf("both index and uindex in QL struct tag") - } - - ix, xn = true, s - } else if s := tags["uindex"]; s != "" { - if _, ok := tags["index"]; ok { - return nil, fmt.Errorf("both index and uindex in QL struct tag") - } - - ix, unique, xn = true, true, s - } - if ix { - if fn == "ID" && r.HasID { - xfn = "id()" - } - r.Indices = append(r.Indices, &StructIndex{Name: xn, ColumnName: xfn, Unique: unique}) - } - - sf := &StructField{Index: i, Name: fn, Tags: tags, Type: Type(-1), ReflectType: f.Type} - fk := sf.ReflectType.Kind() - if fk == reflect.Ptr { - sf.IsPtr = true - sf.ZeroPtr = reflect.Zero(sf.ReflectType) - sf.ReflectType = sf.ReflectType.Elem() - fk = sf.ReflectType.Kind() - } - - switch fk { - case reflect.Bool: - sf.Type = Bool - if err := sf.check(false); err != nil { - return nil, err - } - case reflect.Int, reflect.Uint: - return nil, fmt.Errorf("only integers of fixed size can be used to derive a schema: %v", fk) - case reflect.Int8: - sf.Type = Int8 - if err := sf.check(int8(0)); err != nil { - return nil, err - } - case reflect.Int16: - if err := sf.check(int16(0)); err != nil { - return nil, err - } - sf.Type = Int16 - case reflect.Int32: - if err := sf.check(int32(0)); err != nil { - return nil, err - } - sf.Type = Int32 - case reflect.Int64: - if sf.ReflectType.Name() == "Duration" && sf.ReflectType.PkgPath() == "time" { - sf.Type = Duration - break - } - - sf.Type = Int64 - if err := sf.check(int64(0)); err != nil { - return nil, err - } - case reflect.Uint8: - sf.Type = Uint8 - if err := sf.check(uint8(0)); err != nil { - return nil, err - } - case reflect.Uint16: - sf.Type = Uint16 - if err := sf.check(uint16(0)); err != nil { - return nil, err - } - case reflect.Uint32: - sf.Type = Uint32 - if err := sf.check(uint32(0)); err != nil { - return nil, err - } - case reflect.Uint64: - sf.Type = Uint64 - if err := sf.check(uint64(0)); err != nil { - return nil, err - } - case reflect.Float32: - sf.Type = Float32 - if err := sf.check(float32(0)); err != nil { - return nil, err - } - case reflect.Float64: - sf.Type = Float64 - if err := sf.check(float64(0)); err != nil { - return nil, err - } - case reflect.Complex64: - sf.Type = Complex64 - if err := sf.check(complex64(0)); err != nil { - return nil, err - } - case reflect.Complex128: - sf.Type = Complex128 - if err := sf.check(complex128(0)); err != nil { - return nil, err - } - case reflect.Slice: - sf.Type = Blob - if err := sf.check([]byte(nil)); err != nil { - return nil, err - } - case reflect.Struct: - switch sf.ReflectType.PkgPath() { - case "math/big": - switch sf.ReflectType.Name() { - case "Int": - sf.Type = BigInt - case "Rat": - sf.Type = BigRat - } - case "time": - switch sf.ReflectType.Name() { - case "Time": - sf.Type = Time - } - } - case reflect.String: - sf.Type = String - if err := sf.check(""); err != nil { - return nil, err - } - } - - if sf.Type < 0 { - return nil, fmt.Errorf("cannot derive schema for type %s (%v)", sf.ReflectType.Name(), fk) - } - - sf.IsID = fn == "ID" && r.HasID - r.Fields = append(r.Fields, sf) - } - - schemaMu.Lock() - schemaCache[typ] = r - if t != typ { - r2 := *r - r2.IsPtr = false - schemaCache[t] = &r2 - } - schemaMu.Unlock() - return r, nil -} - -// MustStructSchema is like StructSchema but panics on error. It simplifies -// safe initialization of global variables holding StructInfo. -// -// MustStructSchema is safe for concurrent use by multiple goroutines. -func MustStructSchema(v interface{}) *StructInfo { - s, err := StructSchema(v) - if err != nil { - panic(err) - } - - return s -} - -// SchemaOptions amend the result of Schema. -type SchemaOptions struct { - // Don't wrap the CREATE statement(s) in a transaction. - NoTransaction bool - - // Don't insert the IF NOT EXISTS clause in the CREATE statement(s). - NoIfNotExists bool - - // Do not strip the "pkg." part from type name "pkg.Type", produce - // "pkg_Type" table name instead. Applies only when no name is passed - // to Schema(). - KeepPrefix bool -} - -var zeroSchemaOptions SchemaOptions - -// Schema returns a CREATE TABLE/INDEX statement(s) for a table derived from a -// struct or an error, if any. The table is named using the name parameter. If -// name is an empty string then the type name of the struct is used while non -// conforming characters are replaced by underscores. Value v can be also a -// pointer to a struct. -// -// Every considered struct field type must be one of the QL types or a type -// convertible to string, bool, int*, uint*, float* or complex* type or pointer -// to such type. Integers with a width dependent on the architecture can not be -// used. Only exported fields are considered. If an exported field QL tag -// contains "-" (`ql:"-"`) then such field is not considered. A field with name -// ID, having type int64, corresponds to id() - and is thus not a part of the -// CREATE statement. A field QL tag containing "index name" or "uindex name" -// triggers additionally creating an index or unique index on the respective -// field. Fields can be renamed using a QL tag "name newName". Fields are -// considered in the order of appearance. A QL tag is a struct tag part -// prefixed by "ql:". Tags can be combined, for example: -// -// type T struct { -// Foo string `ql:"index xFoo, name Bar"` -// } -// -// If opts.NoTransaction == true then the statement(s) are not wrapped in a -// transaction. If opt.NoIfNotExists == true then the CREATE statement(s) omits -// the IF NOT EXISTS clause. Passing nil opts is equal to passing -// &SchemaOptions{} -// -// Schema is safe for concurrent use by multiple goroutines. -func Schema(v interface{}, name string, opt *SchemaOptions) (List, error) { - if opt == nil { - opt = &zeroSchemaOptions - } - s, err := StructSchema(v) - if err != nil { - return List{}, err - } - - var buf bytes.Buffer - if !opt.NoTransaction { - buf.WriteString("BEGIN TRANSACTION; ") - } - buf.WriteString("CREATE TABLE ") - if !opt.NoIfNotExists { - buf.WriteString("IF NOT EXISTS ") - } - if name == "" { - name = fmt.Sprintf("%T", v) - if !opt.KeepPrefix { - a := strings.Split(name, ".") - if l := len(a); l > 1 { - name = a[l-1] - } - } - nm := []rune{} - for _, v := range name { - switch { - case v >= '0' && v <= '9' || v == '_' || v >= 'a' && v <= 'z' || v >= 'A' && v <= 'Z': - // ok - default: - v = '_' - } - nm = append(nm, v) - } - name = string(nm) - } - buf.WriteString(name + " (") - for _, v := range s.Fields { - if v.IsID { - continue - } - - buf.WriteString(fmt.Sprintf("%s %s, ", v.Name, v.Type)) - } - buf.WriteString("); ") - for _, v := range s.Indices { - buf.WriteString("CREATE ") - if v.Unique { - buf.WriteString("UNIQUE ") - } - buf.WriteString("INDEX ") - if !opt.NoIfNotExists { - buf.WriteString("IF NOT EXISTS ") - } - buf.WriteString(fmt.Sprintf("%s ON %s (%s); ", v.Name, name, v.ColumnName)) - } - if !opt.NoTransaction { - buf.WriteString("COMMIT; ") - } - l, err := Compile(buf.String()) - if err != nil { - return List{}, fmt.Errorf("%s: %v", buf.String(), err) - } - - return l, nil -} - -// MustSchema is like Schema but panics on error. It simplifies safe -// initialization of global variables holding compiled schemas. -// -// MustSchema is safe for concurrent use by multiple goroutines. -func MustSchema(v interface{}, name string, opt *SchemaOptions) List { - l, err := Schema(v, name, opt) - if err != nil { - panic(err) - } - - return l -} - -// Marshal converts, in the order of appearance, fields of a struct instance v -// to []interface{} or an error, if any. Value v can be also a pointer to a -// struct. -// -// Every considered struct field type must be one of the QL types or a type -// convertible to string, bool, int*, uint*, float* or complex* type or pointer -// to such type. Integers with a width dependent on the architecture can not be -// used. Only exported fields are considered. If an exported field QL tag -// contains "-" then such field is not considered. A QL tag is a struct tag -// part prefixed by "ql:". Field with name ID, having type int64, corresponds -// to id() - and is thus not part of the result. -// -// Marshal is safe for concurrent use by multiple goroutines. -func Marshal(v interface{}) ([]interface{}, error) { - s, err := StructSchema(v) - if err != nil { - return nil, err - } - - val := reflect.ValueOf(v) - if s.IsPtr { - val = val.Elem() - } - n := len(s.Fields) - if s.HasID { - n-- - } - r := make([]interface{}, n) - j := 0 - for _, v := range s.Fields { - if v.IsID { - continue - } - - f := val.Field(v.Index) - if v.IsPtr { - if f.IsNil() { - r[j] = nil - j++ - continue - } - - f = f.Elem() - } - if m := v.MarshalType; m != nil { - f = f.Convert(m) - } - r[j] = f.Interface() - j++ - } - return r, nil -} - -// MustMarshal is like Marshal but panics on error. It simplifies marshaling of -// "safe" types, like eg. those which were already verified by Schema or -// MustSchema. When the underlying Marshal returns an error, MustMarshal -// panics. -// -// MustMarshal is safe for concurrent use by multiple goroutines. -func MustMarshal(v interface{}) []interface{} { - r, err := Marshal(v) - if err != nil { - panic(err) - } - - return r -} - -// Unmarshal stores data from []interface{} in the struct value pointed to by -// v. -// -// Every considered struct field type must be one of the QL types or a type -// convertible to string, bool, int*, uint*, float* or complex* type or pointer -// to such type. Integers with a width dependent on the architecture can not be -// used. Only exported fields are considered. If an exported field QL tag -// contains "-" then such field is not considered. A QL tag is a struct tag -// part prefixed by "ql:". Fields are considered in the order of appearance. -// Types of values in data must be compatible with the corresponding considered -// field of v. -// -// If the struct has no ID field then the number of values in data must be equal -// to the number of considered fields of v. -// -// type T struct { -// A bool -// B string -// } -// -// Assuming the schema is -// -// CREATE TABLE T (A bool, B string); -// -// Data might be a result of queries like -// -// SELECT * FROM T; -// SELECT A, B FROM T; -// -// If the struct has a considered ID field then the number of values in data -// must be equal to the number of considered fields in v - or one less. In the -// later case the ID field is not set. -// -// type U struct { -// ID int64 -// A bool -// B string -// } -// -// Assuming the schema is -// -// CREATE TABLE T (A bool, B string); -// -// Data might be a result of queries like -// -// SELECT * FROM T; // ID not set -// SELECT A, B FROM T; // ID not set -// SELECT id(), A, B FROM T; // ID is set -// -// To unmarshal a value from data into a pointer field of v, Unmarshal first -// handles the case of the value being nil. In that case, Unmarshal sets the -// pointer to nil. Otherwise, Unmarshal unmarshals the data value into value -// pointed at by the pointer. If the pointer is nil, Unmarshal allocates a new -// value for it to point to. -// -// Unmarshal is safe for concurrent use by multiple goroutines. -func Unmarshal(v interface{}, data []interface{}) (err error) { - defer func() { - if r := recover(); r != nil { - var ok bool - if err, ok = r.(error); !ok { - err = fmt.Errorf("%v", r) - } - err = fmt.Errorf("unmarshal: %v", err) - } - }() - - s, err := StructSchema(v) - if err != nil { - return err - } - - if !s.IsPtr { - return fmt.Errorf("unmarshal: need a pointer to a struct") - } - - id := false - nv, nf := len(data), len(s.Fields) - switch s.HasID { - case true: - switch { - case nv == nf: - id = true - case nv == nf-1: - // ok - default: - return fmt.Errorf("unmarshal: got %d values, need %d or %d", nv, nf-1, nf) - } - default: - switch { - case nv == nf: - // ok - default: - return fmt.Errorf("unmarshal: got %d values, need %d", nv, nf) - } - } - - j := 0 - vVal := reflect.ValueOf(v) - if s.IsPtr { - vVal = vVal.Elem() - } - for _, sf := range s.Fields { - if sf.IsID && !id { - continue - } - - d := data[j] - val := reflect.ValueOf(d) - j++ - - fVal := vVal.Field(sf.Index) - if u := sf.UnmarshalType; u != nil { - val = val.Convert(u) - } - if !sf.IsPtr { - fVal.Set(val) - continue - } - - if d == nil { - fVal.Set(sf.ZeroPtr) - continue - } - - if fVal.IsNil() { - fVal.Set(reflect.New(sf.ReflectType)) - } - - fVal.Elem().Set(val) - } - return nil -} diff --git a/Godeps/_workspace/src/github.com/cznic/ql/mem.go b/Godeps/_workspace/src/github.com/cznic/ql/mem.go deleted file mode 100644 index bd2a2dd269..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/mem.go +++ /dev/null @@ -1,1277 +0,0 @@ -// Copyright (c) 2014 ql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Plain memory storage back end. - -package ql - -import ( - "bytes" - "fmt" - "io" - "math/big" - "time" -) - -var ( - _ btreeIndex = (*memIndex)(nil) - _ btreeIterator = (*memBTreeIterator)(nil) - _ indexIterator = (*xenumerator2)(nil) - _ storage = (*mem)(nil) - _ temp = (*memTemp)(nil) -) - -type memIndex struct { - m *mem - t *xtree - unique bool -} - -func newMemIndex(m *mem, unique bool) *memIndex { - r := &memIndex{t: xtreeNew(), unique: unique, m: m} - //dbg("newMemIndex %p, %p", r, m) - return r -} - -func (x *memIndex) Clear() error { - //dbg("memIndex(%p, %p).Clear", x, x.m) - x.m.newUndo(undoClearX, 0, []interface{}{x, x.t}) - x.t = xtreeNew() - return nil -} - -func (x *memIndex) Create(indexedValues []interface{}, h int64) error { - //dbg("memIndex(%p, %p).Create %v, %v", x, x.m, indexedValues, h) - t := x.t - switch { - case !x.unique: - k := indexKey{indexedValues, h} - x.m.newUndo(undoCreateX, 0, []interface{}{x, k}) //TODO why is old value, if any, not saved? - t.Set(k, 0) - case isIndexNull(indexedValues): // unique, NULL - k := indexKey{nil, h} - x.m.newUndo(undoCreateX, 0, []interface{}{x, k}) //TODO why is old value, if any, not saved? - t.Set(k, 0) - default: // unique, non NULL - k := indexKey{indexedValues, 0} - if _, ok := t.Get(k); ok { //LATER need .Put - return fmt.Errorf("cannot insert into unique index: duplicate value(s): %v", indexedValues) - } - - x.m.newUndo(undoCreateX, 0, []interface{}{x, k}) //TODO why is old value, if any, not saved? - t.Set(k, int(h)) - } - return nil -} - -func (x *memIndex) Delete(indexedValues []interface{}, h int64) error { - //dbg("memIndex(%p, %p).Delete %v, %v", x, x.m, indexedValues, h) - t := x.t - var k indexKey - var v interface{} - var ok, okv bool - switch { - case !x.unique: - k = indexKey{indexedValues, h} - v, okv = t.Get(k) - ok = t.delete(k) - case isIndexNull(indexedValues): // unique, NULL - k = indexKey{nil, h} - v, okv = t.Get(k) - ok = t.delete(k) - default: // unique, non NULL - k = indexKey{indexedValues, 0} - v, okv = t.Get(k) - ok = t.delete(k) - } - if ok { - if okv { - x.m.newUndo(undoDeleteX, int64(v.(int)), []interface{}{x, k}) - } - return nil - } - - return fmt.Errorf("internal error 047") -} - -func (x *memIndex) Drop() error { - x.m.newUndo(undoDropX, 0, []interface{}{x, *x}) - *x = memIndex{} - return nil -} - -func (x *memIndex) Seek(indexedValues []interface{}) (indexIterator, bool, error) { - it, hit := x.t.Seek(indexKey{indexedValues, 0}) - return &xenumerator2{*it, x.unique}, hit, nil -} - -func (x *memIndex) SeekFirst() (iter indexIterator, err error) { - it, err := x.t.SeekFirst() - if err != nil { - return nil, err - } - - return &xenumerator2{*it, x.unique}, nil -} - -func (x *memIndex) SeekLast() (iter indexIterator, err error) { - it, err := x.t.SeekLast() - if err != nil { - return nil, err - } - - return &xenumerator2{*it, x.unique}, nil -} - -type xenumerator2 struct { - it xenumerator - unique bool -} - -func (it *xenumerator2) Next() ([]interface{}, int64, error) { - k, h, err := it.it.Next() - if err != nil { - return nil, -1, err - } - - switch it.unique { - case true: - if k.value == nil { - return nil, k.h, nil - } - - return k.value, h, nil - default: - return k.value, k.h, nil - } -} - -func (it *xenumerator2) Prev() ([]interface{}, int64, error) { - k, h, err := it.it.Prev() - if err != nil { - return nil, -1, err - } - - switch it.unique { - case true: - if k.value == nil { - return nil, k.h, nil - } - - return k.value, h, nil - default: - return k.value, k.h, nil - } -} - -type memBTreeIterator enumerator - -func (it *memBTreeIterator) Next() (k, v []interface{}, err error) { - return (*enumerator)(it).Next() -} - -type memTemp struct { - tree *tree - store *mem -} - -func (t *memTemp) BeginTransaction() (err error) { - return nil -} - -func (t *memTemp) Get(k []interface{}) (v []interface{}, err error) { - v, _ = t.tree.Get(k) - return -} - -func (t *memTemp) Create(data ...interface{}) (h int64, err error) { - s := t.store - switch n := len(s.recycler); { - case n != 0: - h = int64(s.recycler[n-1]) - s.recycler = s.recycler[:n-1] - s.data[h] = s.clone(data...) - default: - h = int64(len(s.data)) - s.data = append(s.data, s.clone(data...)) - } - return -} - -func (t *memTemp) Read(dst []interface{}, h int64, cols ...*col) (data []interface{}, err error) { - return t.store.Read(dst, h, cols...) -} - -func (*memTemp) Drop() (err error) { return } - -func (t *memTemp) Set(k, v []interface{}) (err error) { - t.tree.Set(append([]interface{}(nil), k...), t.store.clone(v...)) - return -} - -func (t *memTemp) SeekFirst() (e btreeIterator, err error) { - en, err := t.tree.SeekFirst() - if err != nil { - return - } - - return (*memBTreeIterator)(en), nil -} - -const ( - undoCreateNewHandle = iota - undoCreateRecycledHandle - undoUpdate - undoDelete - undoClearX // {0: *memIndex, 1: *xtree} - undoCreateX // {0: *memIndex, 1: indexKey} - undoDeleteX // {0: *memIndex, 1: indexKey} - undoDropX // {0: *memIndex, 1: memIndex} -) - -type undo struct { - tag int - h int64 - data []interface{} -} - -type undos struct { - list []undo - parent *undos -} - -type mem struct { - data [][]interface{} - id int64 - recycler []int - tnl int - rollback *undos -} - -func newMemStorage() (s *mem, err error) { - s = &mem{data: [][]interface{}{nil}} - if err = s.BeginTransaction(); err != nil { - return nil, err - } - - h, err := s.Create() - if h != 1 { - panic("internal error 048") - } - - if err = s.Commit(); err != nil { - return nil, err - } - - return -} - -func (s *mem) OpenIndex(unique bool, handle int64) (btreeIndex, error) { // Never called on the memory backend. - panic("internal error 049") -} - -func (s *mem) newUndo(tag int, h int64, data []interface{}) { - s.rollback.list = append(s.rollback.list, undo{tag, h, data}) -} - -func (s *mem) Acid() bool { return false } - -func (s *mem) Close() (err error) { - if s.tnl != 0 { - return fmt.Errorf("cannot close DB while open transaction exist") - } - *s = mem{} - return -} - -func (s *mem) CreateIndex(unique bool) ( /* handle */ int64, btreeIndex, error) { - return -1, newMemIndex(s, unique), nil // handle of memIndex should never be used -} - -func (s *mem) Name() string { return fmt.Sprintf("/proc/self/mem/%p", s) } // fake, non existing name - -// OpenMem returns a new, empty DB backed by the process' memory. The back end -// has no limits on field/record/table/DB size other than memory available to -// the process. -func OpenMem() (db *DB, err error) { - s, err := newMemStorage() - if err != nil { - return - } - - if db, err = newDB(s); err != nil { - return nil, err - } - - db.isMem = true - return db, nil -} - -func (s *mem) Verify() (allocs int64, err error) { - for _, v := range s.recycler { - if s.data[v] != nil { - return 0, fmt.Errorf("corrupted: non nil free handle %d", s.data[v]) - } - } - - for _, v := range s.data { - if v != nil { - allocs++ - } - } - - if allocs != int64(len(s.data))-1-int64(len(s.recycler)) { - return 0, fmt.Errorf("corrupted: len(data) %d, len(recycler) %d, allocs %d", len(s.data), len(s.recycler), allocs) - } - - return -} - -func (s *mem) String() string { - var b bytes.Buffer - for i, v := range s.data { - b.WriteString(fmt.Sprintf("s.data[%d] %#v\n", i, v)) - } - for i, v := range s.recycler { - b.WriteString(fmt.Sprintf("s.recycler[%d] %v\n", i, v)) - } - return b.String() -} - -func (s *mem) CreateTemp(asc bool) (_ temp, err error) { - st, err := newMemStorage() - if err != nil { - return - } - - return &memTemp{ - tree: treeNew(collators[asc]), - store: st, - }, nil -} - -func (s *mem) ResetID() (err error) { - s.id = 0 - return -} - -func (s *mem) ID() (id int64, err error) { - s.id++ - return s.id, nil -} - -func (s *mem) clone(data ...interface{}) []interface{} { - r := make([]interface{}, len(data)) - for i, v := range data { - switch x := v.(type) { - case nil: - // nop - case idealComplex: - r[i] = complex128(x) - case idealFloat: - r[i] = float64(x) - case idealInt: - r[i] = int64(x) - case idealRune: - r[i] = int32(x) - case idealUint: - r[i] = uint64(x) - case bool: - r[i] = x - case complex64: - r[i] = x - case complex128: - r[i] = x - case float32: - r[i] = x - case float64: - r[i] = x - case int: - r[i] = int64(x) - case int8: - r[i] = x - case int16: - r[i] = x - case int32: - r[i] = x - case int64: - r[i] = x - case string: - r[i] = x - case uint: - r[i] = uint64(x) - case uint8: - r[i] = x - case uint16: - r[i] = x - case uint32: - r[i] = x - case uint64: - r[i] = x - case []byte: - r[i] = append([]byte(nil), x...) - case *big.Int: - r[i] = big.NewInt(0).Set(x) - case *big.Rat: - r[i] = big.NewRat(1, 2).Set(x) - case time.Time: - t := x - r[i] = t - case time.Duration: - r[i] = x - case map[string]interface{}: // map of ids of a cross join - r[i] = x - default: - panic("internal error 050") - } - } - return r -} - -func (s *mem) Create(data ...interface{}) (h int64, err error) { - switch n := len(s.recycler); { - case n != 0: - h = int64(s.recycler[n-1]) - s.recycler = s.recycler[:n-1] - s.data[h] = s.clone(data...) - r := s.rollback - r.list = append(r.list, undo{ - tag: undoCreateRecycledHandle, - h: h, - }) - default: - h = int64(len(s.data)) - s.data = append(s.data, s.clone(data...)) - r := s.rollback - r.list = append(r.list, undo{ - tag: undoCreateNewHandle, - h: h, - }) - } - return -} - -func (s *mem) Read(dst []interface{}, h int64, cols ...*col) (data []interface{}, err error) { - if i := int(h); i != 0 && i < len(s.data) { - d := s.clone(s.data[h]...) - if cols == nil { - return d, nil - } - - for n, dn := len(cols)+2, len(d); dn < n; dn++ { - d = append(d, nil) - } - return d, nil - } - - return nil, errNoDataForHandle -} - -func (s *mem) UpdateRow(h int64, _ []*col, data ...interface{}) (err error) { - return s.Update(h, data...) -} - -func (s *mem) Update(h int64, data ...interface{}) (err error) { - r := s.rollback - r.list = append(r.list, undo{ - tag: undoUpdate, - h: h, - data: s.data[h], - }) - s.data[h] = s.clone(data...) - return -} - -func (s *mem) Delete(h int64, _ ...*col) (err error) { - r := s.rollback - r.list = append(r.list, undo{ - tag: undoDelete, - h: h, - data: s.data[h], - }) - s.recycler = append(s.recycler, int(h)) - s.data[h] = nil - return -} - -func (s *mem) BeginTransaction() (err error) { - s.rollback = &undos{parent: s.rollback} - s.tnl++ - return nil -} - -func (s *mem) Rollback() (err error) { - if s.tnl == 0 { - return errRollbackNotInTransaction - } - - list := s.rollback.list - for i := len(list) - 1; i >= 0; i-- { - undo := list[i] - switch h, data := int(undo.h), undo.data; undo.tag { - case undoCreateNewHandle: - d := s.data - s.data = d[:len(d)-1] - case undoCreateRecycledHandle: - s.data[h] = nil - r := s.recycler - s.recycler = append(r, h) - case undoUpdate: - s.data[h] = data - case undoDelete: - s.data[h] = data - s.recycler = s.recycler[:len(s.recycler)-1] - case undoClearX: - x, t := data[0].(*memIndex), data[1].(*xtree) - x.t = t - case undoCreateX: - x, k := data[0].(*memIndex), data[1].(indexKey) - x.t.delete(k) - case undoDeleteX: - x, k := data[0].(*memIndex), data[1].(indexKey) - x.t.Set(k, h) - case undoDropX: - x, v := data[0].(*memIndex), data[1].(memIndex) - *x = v - default: - panic("internal error 051") - } - } - - s.tnl-- - s.rollback = s.rollback.parent - return nil -} - -func (s *mem) Commit() (err error) { - if s.tnl == 0 { - return errCommitNotInTransaction - } - - s.tnl-- - s.rollback = s.rollback.parent - return nil -} - -// Transaction index B+Tree -//LATER make it just a wrapper of the implementation in btree.go. - -type ( - xd struct { // data page - c int - xd [2*kd + 1]xde - n *xd - p *xd - } - - xde struct { // xd element - k indexKey - v int - } - - // xenumerator captures the state of enumerating a tree. It is returned - // from the Seek* methods. The enumerator is aware of any mutations - // made to the tree in the process of enumerating it and automatically - // resumes the enumeration at the proper key, if possible. - // - // However, once an xenumerator returns io.EOF to signal "no more - // items", it does no more attempt to "resync" on tree mutation(s). In - // other words, io.EOF from an Enumaretor is "sticky" (idempotent). - xenumerator struct { - err error - hit bool - i int - k indexKey - q *xd - t *xtree - ver int64 - } - - // xtree is a B+tree. - xtree struct { - c int - first *xd - last *xd - r interface{} - ver int64 - } - - xxe struct { // xx element - ch interface{} - sep *xd - } - - xx struct { // index page - c int - xx [2*kx + 2]xxe - } -) - -func (a *indexKey) cmp(b *indexKey) int { - r := collate(a.value, b.value) - if r != 0 { - return r - } - - return int(a.h) - int(b.h) -} - -var ( // R/O zero values - zxd xd - zxde xde - zxx xx - zxxe xxe -) - -func xclr(q interface{}) { - switch xx := q.(type) { - case *xx: - for i := 0; i <= xx.c; i++ { // Ch0 Sep0 ... Chn-1 Sepn-1 Chn - xclr(xx.xx[i].ch) - } - *xx = zxx // GC - case *xd: - *xx = zxd // GC - } -} - -// -------------------------------------------------------------------------- xx - -func xnewX(ch0 interface{}) *xx { - r := &xx{} - r.xx[0].ch = ch0 - return r -} - -func (q *xx) extract(i int) { - q.c-- - if i < q.c { - copy(q.xx[i:], q.xx[i+1:q.c+1]) - q.xx[q.c].ch = q.xx[q.c+1].ch - q.xx[q.c].sep = nil // GC - q.xx[q.c+1] = zxxe // GC - } -} - -func (q *xx) insert(i int, xd *xd, ch interface{}) *xx { - c := q.c - if i < c { - q.xx[c+1].ch = q.xx[c].ch - copy(q.xx[i+2:], q.xx[i+1:c]) - q.xx[i+1].sep = q.xx[i].sep - } - c++ - q.c = c - q.xx[i].sep = xd - q.xx[i+1].ch = ch - return q -} - -func (q *xx) siblings(i int) (l, r *xd) { - if i >= 0 { - if i > 0 { - l = q.xx[i-1].ch.(*xd) - } - if i < q.c { - r = q.xx[i+1].ch.(*xd) - } - } - return -} - -// -------------------------------------------------------------------------- xd - -func (l *xd) mvL(r *xd, c int) { - copy(l.xd[l.c:], r.xd[:c]) - copy(r.xd[:], r.xd[c:r.c]) - l.c += c - r.c -= c -} - -func (l *xd) mvR(r *xd, c int) { - copy(r.xd[c:], r.xd[:r.c]) - copy(r.xd[:c], l.xd[l.c-c:]) - r.c += c - l.c -= c -} - -// ----------------------------------------------------------------------- xtree - -// xtreeNew returns a newly created, empty xtree. The compare function is used -// for key collation. -func xtreeNew() *xtree { - return &xtree{} -} - -// Clear removes all K/V pairs from the tree. -func (t *xtree) Clear() { - if t.r == nil { - return - } - - xclr(t.r) - t.c, t.first, t.last, t.r = 0, nil, nil, nil - t.ver++ -} - -func (t *xtree) cat(p *xx, q, r *xd, pi int) { - t.ver++ - q.mvL(r, r.c) - if r.n != nil { - r.n.p = q - } else { - t.last = q - } - q.n = r.n - if p.c > 1 { - p.extract(pi) - p.xx[pi].ch = q - } else { - t.r = q - } -} - -func (t *xtree) catX(p, q, r *xx, pi int) { - t.ver++ - q.xx[q.c].sep = p.xx[pi].sep - copy(q.xx[q.c+1:], r.xx[:r.c]) - q.c += r.c + 1 - q.xx[q.c].ch = r.xx[r.c].ch - if p.c > 1 { - p.c-- - pc := p.c - if pi < pc { - p.xx[pi].sep = p.xx[pi+1].sep - copy(p.xx[pi+1:], p.xx[pi+2:pc+1]) - p.xx[pc].ch = p.xx[pc+1].ch - p.xx[pc].sep = nil // GC - p.xx[pc+1].ch = nil // GC - } - return - } - - t.r = q -} - -//Delete removes the k's KV pair, if it exists, in which case Delete returns -//true. -func (t *xtree) delete(k indexKey) (ok bool) { - pi := -1 - var p *xx - q := t.r - if q == nil { - return - } - - for { - var i int - i, ok = t.find(q, k) - if ok { - switch xx := q.(type) { - case *xx: - dp := xx.xx[i].sep - switch { - case dp.c > kd: - t.extract(dp, 0) - default: - if xx.c < kx && q != t.r { - t.underflowX(p, &xx, pi, &i) - } - pi = i + 1 - p = xx - q = xx.xx[pi].ch - ok = false - continue - } - case *xd: - t.extract(xx, i) - if xx.c >= kd { - return - } - - if q != t.r { - t.underflow(p, xx, pi) - } else if t.c == 0 { - t.Clear() - } - } - return - } - - switch xx := q.(type) { - case *xx: - if xx.c < kx && q != t.r { - t.underflowX(p, &xx, pi, &i) - } - pi = i - p = xx - q = xx.xx[i].ch - case *xd: - return - } - } -} - -func (t *xtree) extract(q *xd, i int) { // (r int64) { - t.ver++ - //r = q.xd[i].v // prepared for Extract - q.c-- - if i < q.c { - copy(q.xd[i:], q.xd[i+1:q.c+1]) - } - q.xd[q.c] = zxde // GC - t.c-- - return -} - -func (t *xtree) find(q interface{}, k indexKey) (i int, ok bool) { - var mk indexKey - l := 0 - switch xx := q.(type) { - case *xx: - h := xx.c - 1 - for l <= h { - m := (l + h) >> 1 - mk = xx.xx[m].sep.xd[0].k - switch cmp := k.cmp(&mk); { - case cmp > 0: - l = m + 1 - case cmp == 0: - return m, true - default: - h = m - 1 - } - } - case *xd: - h := xx.c - 1 - for l <= h { - m := (l + h) >> 1 - mk = xx.xd[m].k - switch cmp := k.cmp(&mk); { - case cmp > 0: - l = m + 1 - case cmp == 0: - return m, true - default: - h = m - 1 - } - } - } - return l, false -} - -// First returns the first item of the tree in the key collating order, or -// (nil, nil) if the tree is empty. -func (t *xtree) First() (k indexKey, v int) { - if q := t.first; q != nil { - q := &q.xd[0] - k, v = q.k, q.v - } - return -} - -// Get returns the value associated with k and true if it exists. Otherwise Get -// returns (nil, false). -func (t *xtree) Get(k indexKey) (v int, ok bool) { - q := t.r - if q == nil { - return - } - - for { - var i int - if i, ok = t.find(q, k); ok { - switch xx := q.(type) { - case *xx: - return xx.xx[i].sep.xd[0].v, true - case *xd: - return xx.xd[i].v, true - } - } - switch xx := q.(type) { - case *xx: - q = xx.xx[i].ch - default: - return - } - } -} - -func (t *xtree) insert(q *xd, i int, k indexKey, v int) *xd { - t.ver++ - c := q.c - if i < c { - copy(q.xd[i+1:], q.xd[i:c]) - } - c++ - q.c = c - q.xd[i].k, q.xd[i].v = k, v - t.c++ - return q -} - -// Last returns the last item of the tree in the key collating order, or (nil, -// nil) if the tree is empty. -func (t *xtree) Last() (k indexKey, v int) { - if q := t.last; q != nil { - q := &q.xd[q.c-1] - k, v = q.k, q.v - } - return -} - -// Len returns the number of items in the tree. -func (t *xtree) Len() int { - return t.c -} - -func (t *xtree) overflow(p *xx, q *xd, pi, i int, k indexKey, v int) { - t.ver++ - l, r := p.siblings(pi) - - if l != nil && l.c < 2*kd { - l.mvL(q, 1) - t.insert(q, i-1, k, v) - return - } - - if r != nil && r.c < 2*kd { - if i < 2*kd { - q.mvR(r, 1) - t.insert(q, i, k, v) - } else { - t.insert(r, 0, k, v) - } - return - } - - t.split(p, q, pi, i, k, v) -} - -// Seek returns an xenumerator positioned on a an item such that k >= item's -// key. ok reports if k == item.key The xenumerator's position is possibly -// after the last item in the tree. -func (t *xtree) Seek(k indexKey) (e *xenumerator, ok bool) { - q := t.r - if q == nil { - e = &xenumerator{nil, false, 0, k, nil, t, t.ver} - return - } - - for { - var i int - if i, ok = t.find(q, k); ok { - switch xx := q.(type) { - case *xx: - e = &xenumerator{nil, ok, 0, k, xx.xx[i].sep, t, t.ver} - return - case *xd: - e = &xenumerator{nil, ok, i, k, xx, t, t.ver} - return - } - } - switch xx := q.(type) { - case *xx: - q = xx.xx[i].ch - case *xd: - e = &xenumerator{nil, ok, i, k, xx, t, t.ver} - return - } - } -} - -// SeekFirst returns an enumerator positioned on the first KV pair in the tree, -// if any. For an empty tree, err == io.EOF is returned and e will be nil. -func (t *xtree) SeekFirst() (e *xenumerator, err error) { - q := t.first - if q == nil { - return nil, io.EOF - } - - return &xenumerator{nil, true, 0, q.xd[0].k, q, t, t.ver}, nil -} - -// SeekLast returns an enumerator positioned on the last KV pair in the tree, -// if any. For an empty tree, err == io.EOF is returned and e will be nil. -func (t *xtree) SeekLast() (e *xenumerator, err error) { - q := t.last - if q == nil { - return nil, io.EOF - } - - return &xenumerator{nil, true, q.c - 1, q.xd[q.c-1].k, q, t, t.ver}, nil -} - -// Set sets the value associated with k. -func (t *xtree) Set(k indexKey, v int) { - pi := -1 - var p *xx - q := t.r - if q != nil { - for { - i, ok := t.find(q, k) - if ok { - switch xx := q.(type) { - case *xx: - xx.xx[i].sep.xd[0].v = v - case *xd: - xx.xd[i].v = v - } - return - } - - switch xx := q.(type) { - case *xx: - if xx.c > 2*kx { - t.splitX(p, &xx, pi, &i) - } - pi = i - p = xx - q = xx.xx[i].ch - case *xd: - switch { - case xx.c < 2*kd: - t.insert(xx, i, k, v) - default: - t.overflow(p, xx, pi, i, k, v) - } - return - } - } - } - - z := t.insert(&xd{}, 0, k, v) - t.r, t.first, t.last = z, z, z - return -} - -func (t *xtree) split(p *xx, q *xd, pi, i int, k indexKey, v int) { - t.ver++ - r := &xd{} - if q.n != nil { - r.n = q.n - r.n.p = r - } else { - t.last = r - } - q.n = r - r.p = q - - copy(r.xd[:], q.xd[kd:2*kd]) - for i := range q.xd[kd:] { - q.xd[kd+i] = zxde - } - q.c = kd - r.c = kd - if pi >= 0 { - p.insert(pi, r, r) - } else { - t.r = xnewX(q).insert(0, r, r) - } - if i > kd { - t.insert(r, i-kd, k, v) - return - } - - t.insert(q, i, k, v) -} - -func (t *xtree) splitX(p *xx, pp **xx, pi int, i *int) { - t.ver++ - q := *pp - r := &xx{} - copy(r.xx[:], q.xx[kx+1:]) - q.c = kx - r.c = kx - if pi >= 0 { - p.insert(pi, q.xx[kx].sep, r) - } else { - t.r = xnewX(q).insert(0, q.xx[kx].sep, r) - } - q.xx[kx].sep = nil - for i := range q.xx[kx+1:] { - q.xx[kx+i+1] = zxxe - } - if *i > kx { - *pp = r - *i -= kx + 1 - } -} - -func (t *xtree) underflow(p *xx, q *xd, pi int) { - t.ver++ - l, r := p.siblings(pi) - - if l != nil && l.c+q.c >= 2*kd { - l.mvR(q, 1) - } else if r != nil && q.c+r.c >= 2*kd { - q.mvL(r, 1) - r.xd[r.c] = zxde // GC - } else if l != nil { - t.cat(p, l, q, pi-1) - } else { - t.cat(p, q, r, pi) - } -} - -func (t *xtree) underflowX(p *xx, pp **xx, pi int, i *int) { - t.ver++ - var l, r *xx - q := *pp - - if pi >= 0 { - if pi > 0 { - l = p.xx[pi-1].ch.(*xx) - } - if pi < p.c { - r = p.xx[pi+1].ch.(*xx) - } - } - - if l != nil && l.c > kx { - q.xx[q.c+1].ch = q.xx[q.c].ch - copy(q.xx[1:], q.xx[:q.c]) - q.xx[0].ch = l.xx[l.c].ch - q.xx[0].sep = p.xx[pi-1].sep - q.c++ - *i++ - l.c-- - p.xx[pi-1].sep = l.xx[l.c].sep - return - } - - if r != nil && r.c > kx { - q.xx[q.c].sep = p.xx[pi].sep - q.c++ - q.xx[q.c].ch = r.xx[0].ch - p.xx[pi].sep = r.xx[0].sep - copy(r.xx[:], r.xx[1:r.c]) - r.c-- - rc := r.c - r.xx[rc].ch = r.xx[rc+1].ch - r.xx[rc].sep = nil - r.xx[rc+1].ch = nil - return - } - - if l != nil { - *i += l.c + 1 - t.catX(p, l, q, pi-1) - *pp = l - return - } - - t.catX(p, q, r, pi) -} - -// ----------------------------------------------------------------- xenumerator - -// Next returns the currently enumerated item, if it exists and moves to the -// next item in the key collation order. If there is no item to return, err == -// io.EOF is returned. -func (e *xenumerator) Next() (k indexKey, v int64, err error) { - if err = e.err; err != nil { - return - } - - if e.ver != e.t.ver { - f, hit := e.t.Seek(e.k) - if !e.hit && hit { - if err = f.next(); err != nil { - return - } - } - - *e = *f - } - if e.q == nil { - e.err, err = io.EOF, io.EOF - return - } - - if e.i >= e.q.c { - if err = e.next(); err != nil { - return - } - } - - i := e.q.xd[e.i] - k, v = i.k, int64(i.v) - e.k, e.hit = k, false - e.next() - return -} - -func (e *xenumerator) next() error { - if e.q == nil { - e.err = io.EOF - return io.EOF - } - - switch { - case e.i < e.q.c-1: - e.i++ - default: - if e.q, e.i = e.q.n, 0; e.q == nil { - e.err = io.EOF - } - } - return e.err -} - -// Prev returns the currently enumerated item, if it exists and moves to the -// previous item in the key collation order. If there is no item to return, err -// == io.EOF is returned. -func (e *xenumerator) Prev() (k indexKey, v int64, err error) { - if err = e.err; err != nil { - return - } - - if e.ver != e.t.ver { - f, hit := e.t.Seek(e.k) - if !e.hit && hit { - if err = f.prev(); err != nil { - return - } - } - - *e = *f - } - if e.q == nil { - e.err, err = io.EOF, io.EOF - return - } - - if e.i >= e.q.c { - if err = e.next(); err != nil { - return - } - } - - i := e.q.xd[e.i] - k, v = i.k, int64(i.v) - e.k, e.hit = k, false - e.prev() - return -} - -func (e *xenumerator) prev() error { - if e.q == nil { - e.err = io.EOF - return io.EOF - } - - switch { - case e.i > 0: - e.i-- - default: - if e.q = e.q.p; e.q == nil { - e.err = io.EOF - break - } - - e.i = e.q.c - 1 - } - return e.err -} diff --git a/Godeps/_workspace/src/github.com/cznic/ql/parser.go b/Godeps/_workspace/src/github.com/cznic/ql/parser.go deleted file mode 100644 index 1fb6e04a54..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/parser.go +++ /dev/null @@ -1,2637 +0,0 @@ -// CAUTION: Generated file - DO NOT EDIT. - -// Copyright (c) 2014 The ql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Inital yacc source generated by ebnf2y[1] -// at 2013-10-04 23:10:47.861401015 +0200 CEST -// -// $ ebnf2y -o ql.y -oe ql.ebnf -start StatementList -pkg ql -p _ -// -// [1]: http://github.com/cznic/ebnf2y - -package ql - -import __yyfmt__ "fmt" - -import ( - "fmt" - - "github.com/cznic/mathutil" -) - -type yySymType struct { - yys int - line int - col int - item interface{} - list []interface{} -} - -type yyXError struct { - state, xsym int -} - -const ( - yyDefault = 57437 - yyEOFCode = 57344 - add = 57352 - alter = 57353 - and = 57354 - andand = 57355 - andnot = 57356 - as = 57357 - asc = 57358 - begin = 57359 - between = 57360 - bigIntType = 57361 - bigRatType = 57362 - blobType = 57363 - boolType = 57364 - by = 57365 - byteType = 57366 - column = 57367 - commit = 57368 - complex128Type = 57369 - complex64Type = 57370 - create = 57371 - defaultKwd = 57372 - deleteKwd = 57373 - desc = 57374 - distinct = 57375 - drop = 57376 - durationType = 57377 - eq = 57378 - yyErrCode = 57345 - exists = 57379 - explain = 57380 - falseKwd = 57381 - float32Type = 57383 - float64Type = 57384 - floatLit = 57346 - floatType = 57382 - from = 57385 - full = 57386 - ge = 57387 - group = 57388 - identifier = 57347 - ifKwd = 57389 - imaginaryLit = 57348 - in = 57390 - index = 57391 - insert = 57392 - int16Type = 57394 - int32Type = 57395 - int64Type = 57396 - int8Type = 57397 - intLit = 57349 - intType = 57393 - into = 57398 - is = 57399 - join = 57400 - le = 57401 - left = 57402 - like = 57403 - limit = 57404 - lsh = 57405 - neq = 57406 - not = 57407 - null = 57408 - offset = 57409 - on = 57410 - or = 57411 - order = 57412 - oror = 57413 - outer = 57414 - parseExpression = 57436 - qlParam = 57350 - right = 57415 - rollback = 57416 - rsh = 57417 - runeType = 57418 - selectKwd = 57419 - set = 57420 - stringLit = 57351 - stringType = 57421 - tableKwd = 57422 - timeType = 57423 - transaction = 57424 - trueKwd = 57425 - truncate = 57426 - uint16Type = 57428 - uint32Type = 57429 - uint64Type = 57430 - uint8Type = 57431 - uintType = 57427 - unique = 57432 - update = 57433 - values = 57434 - where = 57435 - - yyMaxDepth = 200 - yyTabOfs = -216 -) - -var ( - yyXLAT = map[int]int{ - 59: 0, // ';' (192x) - 57344: 1, // $end (191x) - 41: 2, // ')' (164x) - 43: 3, // '+' (133x) - 45: 4, // '-' (133x) - 94: 5, // '^' (133x) - 44: 6, // ',' (130x) - 40: 7, // '(' (125x) - 57347: 8, // identifier (116x) - 57409: 9, // offset (103x) - 57404: 10, // limit (101x) - 57372: 11, // defaultKwd (94x) - 57412: 12, // order (90x) - 57435: 13, // where (87x) - 57408: 14, // null (84x) - 57361: 15, // bigIntType (83x) - 57362: 16, // bigRatType (83x) - 57363: 17, // blobType (83x) - 57364: 18, // boolType (83x) - 57366: 19, // byteType (83x) - 57369: 20, // complex128Type (83x) - 57370: 21, // complex64Type (83x) - 57377: 22, // durationType (83x) - 57383: 23, // float32Type (83x) - 57384: 24, // float64Type (83x) - 57382: 25, // floatType (83x) - 57394: 26, // int16Type (83x) - 57395: 27, // int32Type (83x) - 57396: 28, // int64Type (83x) - 57397: 29, // int8Type (83x) - 57393: 30, // intType (83x) - 57418: 31, // runeType (83x) - 57421: 32, // stringType (83x) - 57423: 33, // timeType (83x) - 57428: 34, // uint16Type (83x) - 57429: 35, // uint32Type (83x) - 57430: 36, // uint64Type (83x) - 57431: 37, // uint8Type (83x) - 57427: 38, // uintType (83x) - 57381: 39, // falseKwd (81x) - 57346: 40, // floatLit (81x) - 57388: 41, // group (81x) - 57348: 42, // imaginaryLit (81x) - 57349: 43, // intLit (81x) - 57407: 44, // not (81x) - 57411: 45, // or (81x) - 57413: 46, // oror (81x) - 57350: 47, // qlParam (81x) - 57351: 48, // stringLit (81x) - 57425: 49, // trueKwd (81x) - 33: 50, // '!' (77x) - 57385: 51, // from (75x) - 57358: 52, // asc (71x) - 57374: 53, // desc (71x) - 93: 54, // ']' (70x) - 57357: 55, // as (69x) - 58: 56, // ':' (67x) - 57354: 57, // and (67x) - 57355: 58, // andand (65x) - 124: 59, // '|' (56x) - 57360: 60, // between (54x) - 57390: 61, // in (54x) - 60: 62, // '<' (53x) - 62: 63, // '>' (53x) - 57378: 64, // eq (53x) - 57387: 65, // ge (53x) - 57399: 66, // is (53x) - 57401: 67, // le (53x) - 57403: 68, // like (53x) - 57406: 69, // neq (53x) - 57513: 70, // Type (52x) - 57453: 71, // Conversion (51x) - 57483: 72, // Literal (51x) - 57484: 73, // Operand (51x) - 57488: 74, // PrimaryExpression (51x) - 57491: 75, // QualifiedIdent (51x) - 42: 76, // '*' (48x) - 57514: 77, // UnaryExpr (47x) - 37: 78, // '%' (44x) - 38: 79, // '&' (44x) - 47: 80, // '/' (44x) - 57356: 81, // andnot (44x) - 57405: 82, // lsh (44x) - 57417: 83, // rsh (44x) - 57490: 84, // PrimaryTerm (40x) - 57489: 85, // PrimaryFactor (36x) - 91: 86, // '[' (31x) - 57470: 87, // Factor (25x) - 57471: 88, // Factor1 (25x) - 57511: 89, // Term (24x) - 57467: 90, // Expression (23x) - 57519: 91, // logOr (16x) - 57446: 92, // ColumnName (10x) - 57386: 93, // full (10x) - 57402: 94, // left (10x) - 57415: 95, // right (10x) - 57419: 96, // selectKwd (10x) - 57510: 97, // TableName (9x) - 57449: 98, // CommaOpt (7x) - 57468: 99, // ExpressionList (7x) - 57410: 100, // on (7x) - 57497: 101, // SelectStmt (7x) - 57400: 102, // join (6x) - 57443: 103, // Call (5x) - 57376: 104, // drop (5x) - 57476: 105, // Index (5x) - 57506: 106, // Slice (5x) - 57445: 107, // ColumnDef (4x) - 57379: 108, // exists (4x) - 57389: 109, // ifKwd (4x) - 57391: 110, // index (4x) - 57414: 111, // outer (4x) - 57422: 112, // tableKwd (4x) - 57434: 113, // values (4x) - 57353: 114, // alter (3x) - 57438: 115, // AlterTableStmt (3x) - 57359: 116, // begin (3x) - 57442: 117, // BeginTransactionStmt (3x) - 57368: 118, // commit (3x) - 57450: 119, // CommitStmt (3x) - 57371: 120, // create (3x) - 57455: 121, // CreateIndexStmt (3x) - 57457: 122, // CreateTableStmt (3x) - 57461: 123, // DeleteFromStmt (3x) - 57373: 124, // deleteKwd (3x) - 57463: 125, // DropIndexStmt (3x) - 57464: 126, // DropTableStmt (3x) - 57465: 127, // EmptyStmt (3x) - 57380: 128, // explain (3x) - 57466: 129, // ExplainStmt (3x) - 57392: 130, // insert (3x) - 57477: 131, // InsertIntoStmt (3x) - 57492: 132, // RecordSet (3x) - 57493: 133, // RecordSet1 (3x) - 57416: 134, // rollback (3x) - 57496: 135, // RollbackStmt (3x) - 57520: 136, // semiOpt (3x) - 57508: 137, // Statement (3x) - 57426: 138, // truncate (3x) - 57512: 139, // TruncateTableStmt (3x) - 57433: 140, // update (3x) - 57515: 141, // UpdateStmt (3x) - 57517: 142, // WhereClause (3x) - 61: 143, // '=' (2x) - 57352: 144, // add (2x) - 57439: 145, // Assignment (2x) - 57365: 146, // by (2x) - 57447: 147, // ColumnNameList (2x) - 57458: 148, // CreateTableStmt1 (2x) - 57472: 149, // Field (2x) - 57518: 150, // logAnd (2x) - 57420: 151, // set (2x) - 46: 152, // '.' (1x) - 57440: 153, // AssignmentList (1x) - 57441: 154, // AssignmentList1 (1x) - 57444: 155, // Call1 (1x) - 57367: 156, // column (1x) - 57448: 157, // ColumnNameList1 (1x) - 57451: 158, // Constraint (1x) - 57452: 159, // ConstraintOpt (1x) - 57454: 160, // CreateIndexIfNotExists (1x) - 57456: 161, // CreateIndexStmtUnique (1x) - 57459: 162, // Default (1x) - 57460: 163, // DefaultOpt (1x) - 57375: 164, // distinct (1x) - 57462: 165, // DropIndexIfExists (1x) - 57469: 166, // ExpressionList1 (1x) - 57473: 167, // Field1 (1x) - 57474: 168, // FieldList (1x) - 57475: 169, // GroupByClause (1x) - 57478: 170, // InsertIntoStmt1 (1x) - 57479: 171, // InsertIntoStmt2 (1x) - 57398: 172, // into (1x) - 57480: 173, // JoinClause (1x) - 57481: 174, // JoinClauseOpt (1x) - 57482: 175, // JoinType (1x) - 57485: 176, // OrderBy (1x) - 57486: 177, // OrderBy1 (1x) - 57487: 178, // OuterOpt (1x) - 57436: 179, // parseExpression (1x) - 57494: 180, // RecordSet2 (1x) - 57495: 181, // RecordSetList (1x) - 57498: 182, // SelectStmtDistinct (1x) - 57499: 183, // SelectStmtFieldList (1x) - 57500: 184, // SelectStmtGroup (1x) - 57501: 185, // SelectStmtLimit (1x) - 57502: 186, // SelectStmtOffset (1x) - 57503: 187, // SelectStmtOrder (1x) - 57504: 188, // SelectStmtWhere (1x) - 57505: 189, // SetOpt (1x) - 57507: 190, // Start (1x) - 57509: 191, // StatementList (1x) - 57424: 192, // transaction (1x) - 57432: 193, // unique (1x) - 57516: 194, // UpdateStmt1 (1x) - 57437: 195, // $default (0x) - 57345: 196, // error (0x) - } - - yySymNames = []string{ - "';'", - "$end", - "')'", - "'+'", - "'-'", - "'^'", - "','", - "'('", - "identifier", - "offset", - "limit", - "defaultKwd", - "order", - "where", - "null", - "bigIntType", - "bigRatType", - "blobType", - "boolType", - "byteType", - "complex128Type", - "complex64Type", - "durationType", - "float32Type", - "float64Type", - "floatType", - "int16Type", - "int32Type", - "int64Type", - "int8Type", - "intType", - "runeType", - "stringType", - "timeType", - "uint16Type", - "uint32Type", - "uint64Type", - "uint8Type", - "uintType", - "falseKwd", - "floatLit", - "group", - "imaginaryLit", - "intLit", - "not", - "or", - "oror", - "qlParam", - "stringLit", - "trueKwd", - "'!'", - "from", - "asc", - "desc", - "']'", - "as", - "':'", - "and", - "andand", - "'|'", - "between", - "in", - "'<'", - "'>'", - "eq", - "ge", - "is", - "le", - "like", - "neq", - "Type", - "Conversion", - "Literal", - "Operand", - "PrimaryExpression", - "QualifiedIdent", - "'*'", - "UnaryExpr", - "'%'", - "'&'", - "'/'", - "andnot", - "lsh", - "rsh", - "PrimaryTerm", - "PrimaryFactor", - "'['", - "Factor", - "Factor1", - "Term", - "Expression", - "logOr", - "ColumnName", - "full", - "left", - "right", - "selectKwd", - "TableName", - "CommaOpt", - "ExpressionList", - "on", - "SelectStmt", - "join", - "Call", - "drop", - "Index", - "Slice", - "ColumnDef", - "exists", - "ifKwd", - "index", - "outer", - "tableKwd", - "values", - "alter", - "AlterTableStmt", - "begin", - "BeginTransactionStmt", - "commit", - "CommitStmt", - "create", - "CreateIndexStmt", - "CreateTableStmt", - "DeleteFromStmt", - "deleteKwd", - "DropIndexStmt", - "DropTableStmt", - "EmptyStmt", - "explain", - "ExplainStmt", - "insert", - "InsertIntoStmt", - "RecordSet", - "RecordSet1", - "rollback", - "RollbackStmt", - "semiOpt", - "Statement", - "truncate", - "TruncateTableStmt", - "update", - "UpdateStmt", - "WhereClause", - "'='", - "add", - "Assignment", - "by", - "ColumnNameList", - "CreateTableStmt1", - "Field", - "logAnd", - "set", - "'.'", - "AssignmentList", - "AssignmentList1", - "Call1", - "column", - "ColumnNameList1", - "Constraint", - "ConstraintOpt", - "CreateIndexIfNotExists", - "CreateIndexStmtUnique", - "Default", - "DefaultOpt", - "distinct", - "DropIndexIfExists", - "ExpressionList1", - "Field1", - "FieldList", - "GroupByClause", - "InsertIntoStmt1", - "InsertIntoStmt2", - "into", - "JoinClause", - "JoinClauseOpt", - "JoinType", - "OrderBy", - "OrderBy1", - "OuterOpt", - "parseExpression", - "RecordSet2", - "RecordSetList", - "SelectStmtDistinct", - "SelectStmtFieldList", - "SelectStmtGroup", - "SelectStmtLimit", - "SelectStmtOffset", - "SelectStmtOrder", - "SelectStmtWhere", - "SetOpt", - "Start", - "StatementList", - "transaction", - "unique", - "UpdateStmt1", - "$default", - "error", - } - - yyReductions = map[int]struct{ xsym, components int }{ - 0: {0, 1}, - 1: {190, 1}, - 2: {190, 2}, - 3: {115, 5}, - 4: {115, 6}, - 5: {145, 3}, - 6: {153, 3}, - 7: {154, 0}, - 8: {154, 3}, - 9: {117, 2}, - 10: {103, 3}, - 11: {103, 3}, - 12: {155, 0}, - 13: {155, 1}, - 14: {107, 4}, - 15: {92, 1}, - 16: {147, 3}, - 17: {157, 0}, - 18: {157, 3}, - 19: {119, 1}, - 20: {158, 2}, - 21: {158, 1}, - 22: {159, 0}, - 23: {159, 1}, - 24: {71, 4}, - 25: {121, 10}, - 26: {160, 0}, - 27: {160, 3}, - 28: {161, 0}, - 29: {161, 1}, - 30: {122, 8}, - 31: {122, 11}, - 32: {148, 0}, - 33: {148, 3}, - 34: {162, 2}, - 35: {163, 0}, - 36: {163, 1}, - 37: {123, 3}, - 38: {123, 4}, - 39: {125, 4}, - 40: {165, 0}, - 41: {165, 2}, - 42: {126, 3}, - 43: {126, 5}, - 44: {127, 0}, - 45: {129, 2}, - 46: {90, 1}, - 47: {90, 3}, - 48: {91, 1}, - 49: {91, 1}, - 50: {99, 3}, - 51: {166, 0}, - 52: {166, 3}, - 53: {87, 1}, - 54: {87, 5}, - 55: {87, 6}, - 56: {87, 6}, - 57: {87, 7}, - 58: {87, 5}, - 59: {87, 6}, - 60: {87, 3}, - 61: {87, 4}, - 62: {88, 1}, - 63: {88, 3}, - 64: {88, 3}, - 65: {88, 3}, - 66: {88, 3}, - 67: {88, 3}, - 68: {88, 3}, - 69: {88, 3}, - 70: {149, 2}, - 71: {167, 0}, - 72: {167, 2}, - 73: {168, 1}, - 74: {168, 3}, - 75: {169, 3}, - 76: {105, 3}, - 77: {131, 10}, - 78: {131, 5}, - 79: {170, 0}, - 80: {170, 3}, - 81: {171, 0}, - 82: {171, 5}, - 83: {72, 1}, - 84: {72, 1}, - 85: {72, 1}, - 86: {72, 1}, - 87: {72, 1}, - 88: {72, 1}, - 89: {72, 1}, - 90: {73, 1}, - 91: {73, 1}, - 92: {73, 1}, - 93: {73, 3}, - 94: {176, 4}, - 95: {177, 0}, - 96: {177, 1}, - 97: {177, 1}, - 98: {74, 1}, - 99: {74, 1}, - 100: {74, 2}, - 101: {74, 2}, - 102: {74, 2}, - 103: {85, 1}, - 104: {85, 3}, - 105: {85, 3}, - 106: {85, 3}, - 107: {85, 3}, - 108: {84, 1}, - 109: {84, 3}, - 110: {84, 3}, - 111: {84, 3}, - 112: {84, 3}, - 113: {84, 3}, - 114: {84, 3}, - 115: {84, 3}, - 116: {75, 1}, - 117: {75, 3}, - 118: {132, 2}, - 119: {133, 1}, - 120: {133, 4}, - 121: {136, 0}, - 122: {136, 1}, - 123: {180, 0}, - 124: {180, 2}, - 125: {181, 1}, - 126: {181, 3}, - 127: {135, 1}, - 128: {175, 1}, - 129: {175, 1}, - 130: {175, 1}, - 131: {178, 0}, - 132: {178, 1}, - 133: {173, 6}, - 134: {174, 0}, - 135: {174, 1}, - 136: {101, 12}, - 137: {185, 0}, - 138: {185, 2}, - 139: {186, 0}, - 140: {186, 2}, - 141: {182, 0}, - 142: {182, 1}, - 143: {183, 1}, - 144: {183, 1}, - 145: {183, 2}, - 146: {188, 0}, - 147: {188, 1}, - 148: {184, 0}, - 149: {184, 1}, - 150: {187, 0}, - 151: {187, 1}, - 152: {106, 3}, - 153: {106, 4}, - 154: {106, 4}, - 155: {106, 5}, - 156: {137, 1}, - 157: {137, 1}, - 158: {137, 1}, - 159: {137, 1}, - 160: {137, 1}, - 161: {137, 1}, - 162: {137, 1}, - 163: {137, 1}, - 164: {137, 1}, - 165: {137, 1}, - 166: {137, 1}, - 167: {137, 1}, - 168: {137, 1}, - 169: {137, 1}, - 170: {137, 1}, - 171: {191, 1}, - 172: {191, 3}, - 173: {97, 1}, - 174: {89, 1}, - 175: {89, 3}, - 176: {150, 1}, - 177: {150, 1}, - 178: {139, 3}, - 179: {70, 1}, - 180: {70, 1}, - 181: {70, 1}, - 182: {70, 1}, - 183: {70, 1}, - 184: {70, 1}, - 185: {70, 1}, - 186: {70, 1}, - 187: {70, 1}, - 188: {70, 1}, - 189: {70, 1}, - 190: {70, 1}, - 191: {70, 1}, - 192: {70, 1}, - 193: {70, 1}, - 194: {70, 1}, - 195: {70, 1}, - 196: {70, 1}, - 197: {70, 1}, - 198: {70, 1}, - 199: {70, 1}, - 200: {70, 1}, - 201: {70, 1}, - 202: {70, 1}, - 203: {141, 5}, - 204: {194, 0}, - 205: {194, 1}, - 206: {77, 1}, - 207: {77, 2}, - 208: {77, 2}, - 209: {77, 2}, - 210: {77, 2}, - 211: {142, 2}, - 212: {189, 0}, - 213: {189, 1}, - 214: {98, 0}, - 215: {98, 1}, - } - - yyXErrors = map[yyXError]string{ - yyXError{1, -1}: "expected $end", - yyXError{43, -1}: "expected '('", - yyXError{157, -1}: "expected '('", - yyXError{181, -1}: "expected '('", - yyXError{281, -1}: "expected '('", - yyXError{309, -1}: "expected '('", - yyXError{313, -1}: "expected '('", - yyXError{344, -1}: "expected '('", - yyXError{118, -1}: "expected ')'", - yyXError{119, -1}: "expected ')'", - yyXError{120, -1}: "expected ')'", - yyXError{187, -1}: "expected ')'", - yyXError{189, -1}: "expected ')'", - yyXError{190, -1}: "expected ')'", - yyXError{194, -1}: "expected ')'", - yyXError{196, -1}: "expected ')'", - yyXError{265, -1}: "expected ')'", - yyXError{279, -1}: "expected ')'", - yyXError{284, -1}: "expected ')'", - yyXError{290, -1}: "expected ')'", - yyXError{318, -1}: "expected ')'", - yyXError{335, -1}: "expected ')'", - yyXError{346, -1}: "expected ')'", - yyXError{36, -1}: "expected '='", - yyXError{233, -1}: "expected BY", - yyXError{236, -1}: "expected BY", - yyXError{352, -1}: "expected COLUMN", - yyXError{7, -1}: "expected CREATE INDEX optional UNIQUE clause or one of [INDEX, TABLE, UNIQUE]", - yyXError{337, -1}: "expected CREATE INDEX statement optional IF NOT EXISTS cluse or one of [IF, identifier]", - yyXError{316, -1}: "expected CREATE TABLE statement colum definition list or optional comma or one of [')', ',']", - yyXError{333, -1}: "expected CREATE TABLE statement colum definition list or optional comma or one of [')', ',']", - yyXError{293, -1}: "expected DROP INDEX statement optional IF EXISTS clause or one of [IF, identifier]", - yyXError{296, -1}: "expected EXISTS", - yyXError{300, -1}: "expected EXISTS", - yyXError{311, -1}: "expected EXISTS", - yyXError{340, -1}: "expected EXISTS", - yyXError{8, -1}: "expected FROM", - yyXError{215, -1}: "expected FROM", - yyXError{216, -1}: "expected FROM", - yyXError{306, -1}: "expected INDEX", - yyXError{307, -1}: "expected INDEX", - yyXError{276, -1}: "expected INSERT INTO statement optional column list clause or SELECT statement or one of ['(', SELECT, VALUES]", - yyXError{285, -1}: "expected INSERT INTO statement optional values list or optional comma or one of [$end, ',', ';']", - yyXError{11, -1}: "expected INTO", - yyXError{257, -1}: "expected JOIN", - yyXError{258, -1}: "expected JOIN", - yyXError{310, -1}: "expected NOT", - yyXError{339, -1}: "expected NOT", - yyXError{176, -1}: "expected NULL", - yyXError{324, -1}: "expected NULL", - yyXError{260, -1}: "expected ON", - yyXError{342, -1}: "expected ON", - yyXError{246, -1}: "expected ORDER BY clause optional collation specification or one of [$end, ')', ';', ASC, DESC, LIMIT, OFFSET]", - yyXError{217, -1}: "expected RecordSetList or one of ['(', identifier]", - yyXError{13, -1}: "expected SELECT statement field list or SELECT statement optional DISTINCT clause or one of ['!', '(', '*', '+', '-', '^', DISTINCT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{210, -1}: "expected SELECT statement field list or one of ['!', '(', '*', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{224, -1}: "expected SELECT statement optional GROUP BY clause or SELECT statement optional JOIN clause or SELECT statement optional LIMIT clause or SELECT statement optional OFFSET clause or SELECT statement optional ORDER BY clause or SELECT statement optional WHERE clause or one of [$end, ')', ';', FULL, GROUP, LEFT, LIMIT, OFFSET, ORDER, RIGHT, WHERE]", - yyXError{222, -1}: "expected SELECT statement optional GROUP BY clause or SELECT statement optional JOIN clause or SELECT statement optional LIMIT clause or SELECT statement optional OFFSET clause or SELECT statement optional ORDER BY clause or SELECT statement optional WHERE clause or optional comma or one of [$end, ')', ',', ';', FULL, GROUP, LEFT, LIMIT, OFFSET, ORDER, RIGHT, WHERE]", - yyXError{230, -1}: "expected SELECT statement optional GROUP BY clause or SELECT statement optional LIMIT clause or SELECT statement optional OFFSET clause or SELECT statement optional ORDER BY clause or SELECT statement optional WHERE clause or one of [$end, ')', ';', GROUP, LIMIT, OFFSET, ORDER, WHERE]", - yyXError{231, -1}: "expected SELECT statement optional GROUP BY clause or SELECT statement optional LIMIT clause or SELECT statement optional OFFSET clause or SELECT statement optional ORDER BY clause or one of [$end, ')', ';', GROUP, LIMIT, OFFSET, ORDER]", - yyXError{234, -1}: "expected SELECT statement optional LIMIT clause or SELECT statement optional OFFSET clause or SELECT statement optional ORDER BY clause or one of [$end, ')', ';', LIMIT, OFFSET, ORDER]", - yyXError{237, -1}: "expected SELECT statement optional LIMIT clause or SELECT statement optional OFFSET clause or one of [$end, ')', ';', LIMIT, OFFSET]", - yyXError{239, -1}: "expected SELECT statement optional OFFSET clause or one of [$end, ')', ';', OFFSET]", - yyXError{220, -1}: "expected SELECT statement or SELECT", - yyXError{186, -1}: "expected SELECT statement or expression list or one of ['!', '(', '+', '-', '^', NULL, QL parameter, SELECT, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{193, -1}: "expected SELECT statement or expression list or one of ['!', '(', '+', '-', '^', NULL, QL parameter, SELECT, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{277, -1}: "expected SELECT statement or one of [SELECT, VALUES]", - yyXError{33, -1}: "expected SetOpt or assignment list or one of [SET, identifier]", - yyXError{0, -1}: "expected Start or one of [$end, ';', ALTER, BEGIN, COMMIT, CREATE, DELETE, DROP, EXPLAIN, INSERT, ROLLBACK, SELECT, TRUNCATE, UPDATE, parse expression prefix]", - yyXError{4, -1}: "expected TABLE", - yyXError{30, -1}: "expected TABLE", - yyXError{5, -1}: "expected TRANSACTION", - yyXError{39, -1}: "expected UPDATE statement optional WHERE clause or one of [$end, ';', WHERE]", - yyXError{304, -1}: "expected WHERE clause or one of [$end, ';', WHERE]", - yyXError{37, -1}: "expected assignment list optional trailing comma or optional comma or one of [$end, ',', ';', WHERE]", - yyXError{34, -1}: "expected assignment list or identifier", - yyXError{204, -1}: "expected assignment or one of [$end, ';', WHERE, identifier]", - yyXError{250, -1}: "expected column name list or identifier", - yyXError{278, -1}: "expected column name list or identifier", - yyXError{251, -1}: "expected column name list with optional trailing comma or optional comma or one of [$end, ')', ',', ';', LIMIT, OFFSET, ORDER]", - yyXError{353, -1}: "expected column name or identifier", - yyXError{255, -1}: "expected column name or one of [$end, ')', ';', LIMIT, OFFSET, ORDER, identifier]", - yyXError{109, -1}: "expected expression factor or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{121, -1}: "expected expression list expression or logical or operator or optional comma or one of [$end, ')', ',', ';', ASC, DESC, LIMIT, OFFSET, OR, ||]", - yyXError{245, -1}: "expected expression list or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{283, -1}: "expected expression list or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{289, -1}: "expected expression list or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{345, -1}: "expected expression list or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{124, -1}: "expected expression or one of [$end, '!', '(', ')', '+', '-', ';', '^', ASC, DESC, LIMIT, NULL, OFFSET, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{96, -1}: "expected expression or one of ['!', '(', '+', '-', ':', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{101, -1}: "expected expression or one of ['!', '(', '+', '-', ']', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{114, -1}: "expected expression or one of ['!', '(', '+', '-', ']', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{3, -1}: "expected expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{42, -1}: "expected expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{58, -1}: "expected expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{199, -1}: "expected expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{206, -1}: "expected expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{240, -1}: "expected expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{243, -1}: "expected expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{261, -1}: "expected expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{329, -1}: "expected expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{104, -1}: "expected expression term or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{212, -1}: "expected field expression optional AS clause or logical or operator or one of [',', AS, FROM, OR, ||]", - yyXError{270, -1}: "expected field expression or one of ['!', '(', '+', '-', '^', FROM, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{95, -1}: "expected function call optional argument list or one of ['!', '(', ')', '*', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{61, -1}: "expected function call or string index or string slice or one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{94, -1}: "expected function call or string index or string slice or one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{128, -1}: "expected function call or string index or string slice or one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{129, -1}: "expected function call or string index or string slice or one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{130, -1}: "expected function call or string index or string slice or one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{35, -1}: "expected identifier", - yyXError{131, -1}: "expected identifier", - yyXError{268, -1}: "expected identifier", - yyXError{273, -1}: "expected identifier", - yyXError{299, -1}: "expected identifier", - yyXError{301, -1}: "expected identifier", - yyXError{338, -1}: "expected identifier", - yyXError{341, -1}: "expected identifier", - yyXError{343, -1}: "expected identifier", - yyXError{44, -1}: "expected logical and operator or one of [$end, &&, ')', ',', ':', ';', ']', AND, AS, ASC, DEFAULT, DESC, FROM, GROUP, LIMIT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{108, -1}: "expected logical and operator or one of [$end, &&, ')', ',', ':', ';', ']', AND, AS, ASC, DEFAULT, DESC, FROM, GROUP, LIMIT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{125, -1}: "expected logical or operator or one of [$end, ')', ',', ';', ASC, DESC, LIMIT, OFFSET, OR, ||]", - yyXError{325, -1}: "expected logical or operator or one of [$end, ')', ',', ';', DEFAULT, OR, ||]", - yyXError{331, -1}: "expected logical or operator or one of [$end, ')', ',', ';', OR, ||]", - yyXError{262, -1}: "expected logical or operator or one of [$end, ')', ';', GROUP, LIMIT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{45, -1}: "expected logical or operator or one of [$end, ')', ';', GROUP, LIMIT, OFFSET, OR, ORDER, ||]", - yyXError{241, -1}: "expected logical or operator or one of [$end, ')', ';', OFFSET, OR, ||]", - yyXError{244, -1}: "expected logical or operator or one of [$end, ')', ';', OR, ||]", - yyXError{207, -1}: "expected logical or operator or one of [$end, ',', ';', OR, WHERE, ||]", - yyXError{356, -1}: "expected logical or operator or one of [$end, OR, ||]", - yyXError{147, -1}: "expected logical or operator or one of [')', OR, ||]", - yyXError{200, -1}: "expected logical or operator or one of [')', OR, ||]", - yyXError{100, -1}: "expected logical or operator or one of [':', ']', OR, ||]", - yyXError{102, -1}: "expected logical or operator or one of [']', OR, ||]", - yyXError{115, -1}: "expected logical or operator or one of [']', OR, ||]", - yyXError{64, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{48, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{49, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{50, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{51, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{52, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{53, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{54, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{55, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{56, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{57, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{59, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{60, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{97, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{98, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{99, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{103, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{107, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{113, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{116, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{117, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{126, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{127, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{132, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{148, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{201, -1}: "expected one of [!=, $end, &&, &^, '%', '&', '(', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', '[', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{62, -1}: "expected one of [!=, $end, &&, &^, '%', '&', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{63, -1}: "expected one of [!=, $end, &&, &^, '%', '&', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{140, -1}: "expected one of [!=, $end, &&, &^, '%', '&', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{141, -1}: "expected one of [!=, $end, &&, &^, '%', '&', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{142, -1}: "expected one of [!=, $end, &&, &^, '%', '&', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{143, -1}: "expected one of [!=, $end, &&, &^, '%', '&', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{144, -1}: "expected one of [!=, $end, &&, &^, '%', '&', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{145, -1}: "expected one of [!=, $end, &&, &^, '%', '&', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{146, -1}: "expected one of [!=, $end, &&, &^, '%', '&', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{153, -1}: "expected one of [!=, $end, &&, &^, '%', '&', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{154, -1}: "expected one of [!=, $end, &&, &^, '%', '&', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{155, -1}: "expected one of [!=, $end, &&, &^, '%', '&', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{156, -1}: "expected one of [!=, $end, &&, &^, '%', '&', ')', '*', '+', ',', '-', '/', ':', ';', '<', '>', ']', '^', '|', <<, <=, ==, >=, >>, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{47, -1}: "expected one of [!=, $end, &&, ')', '+', ',', '-', ':', ';', '<', '>', ']', '^', '|', <=, ==, >=, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{168, -1}: "expected one of [!=, $end, &&, ')', '+', ',', '-', ':', ';', '<', '>', ']', '^', '|', <=, ==, >=, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{169, -1}: "expected one of [!=, $end, &&, ')', '+', ',', '-', ':', ';', '<', '>', ']', '^', '|', <=, ==, >=, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{170, -1}: "expected one of [!=, $end, &&, ')', '+', ',', '-', ':', ';', '<', '>', ']', '^', '|', <=, ==, >=, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{171, -1}: "expected one of [!=, $end, &&, ')', '+', ',', '-', ':', ';', '<', '>', ']', '^', '|', <=, ==, >=, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{172, -1}: "expected one of [!=, $end, &&, ')', '+', ',', '-', ':', ';', '<', '>', ']', '^', '|', <=, ==, >=, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{173, -1}: "expected one of [!=, $end, &&, ')', '+', ',', '-', ':', ';', '<', '>', ']', '^', '|', <=, ==, >=, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{174, -1}: "expected one of [!=, $end, &&, ')', '+', ',', '-', ':', ';', '<', '>', ']', '^', '|', <=, ==, >=, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{46, -1}: "expected one of [!=, $end, &&, ')', ',', ':', ';', '<', '>', ']', <=, ==, >=, AND, AS, ASC, BETWEEN, DEFAULT, DESC, FROM, GROUP, IN, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{180, -1}: "expected one of [$end, &&, ')', '+', ',', '-', ':', ';', ']', '^', '|', AND, AS, ASC, DEFAULT, DESC, FROM, GROUP, LIMIT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{185, -1}: "expected one of [$end, &&, ')', '+', ',', '-', ':', ';', ']', '^', '|', AND, AS, ASC, DEFAULT, DESC, FROM, GROUP, LIMIT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{65, -1}: "expected one of [$end, &&, ')', ',', ':', ';', ']', AND, AS, ASC, DEFAULT, DESC, FROM, GROUP, LIMIT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{112, -1}: "expected one of [$end, &&, ')', ',', ':', ';', ']', AND, AS, ASC, DEFAULT, DESC, FROM, GROUP, LIMIT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{175, -1}: "expected one of [$end, &&, ')', ',', ':', ';', ']', AND, AS, ASC, DEFAULT, DESC, FROM, GROUP, LIMIT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{177, -1}: "expected one of [$end, &&, ')', ',', ':', ';', ']', AND, AS, ASC, DEFAULT, DESC, FROM, GROUP, LIMIT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{191, -1}: "expected one of [$end, &&, ')', ',', ':', ';', ']', AND, AS, ASC, DEFAULT, DESC, FROM, GROUP, LIMIT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{192, -1}: "expected one of [$end, &&, ')', ',', ':', ';', ']', AND, AS, ASC, DEFAULT, DESC, FROM, GROUP, LIMIT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{197, -1}: "expected one of [$end, &&, ')', ',', ':', ';', ']', AND, AS, ASC, DEFAULT, DESC, FROM, GROUP, LIMIT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{198, -1}: "expected one of [$end, &&, ')', ',', ':', ';', ']', AND, AS, ASC, DEFAULT, DESC, FROM, GROUP, LIMIT, OFFSET, OR, ORDER, WHERE, ||]", - yyXError{66, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{67, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{68, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{69, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{70, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{71, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{72, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{73, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{74, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{75, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{76, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{77, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{78, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{79, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{80, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{81, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{82, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{83, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{84, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{85, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{86, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{87, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{88, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{89, -1}: "expected one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{32, -1}: "expected one of [$end, '(', ';', ADD, DROP, SELECT, SET, VALUES, WHERE, identifier]", - yyXError{288, -1}: "expected one of [$end, '(', ';']", - yyXError{38, -1}: "expected one of [$end, ')', ',', ';', '=', LIMIT, OFFSET, ORDER, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, float, float32, float64, int, int16, int32, int64, int8, rune, string, time, uint, uint16, uint32, uint64, uint8]", - yyXError{219, -1}: "expected one of [$end, ')', ',', ';', AS, FULL, GROUP, LEFT, LIMIT, OFFSET, ON, ORDER, RIGHT, WHERE]", - yyXError{266, -1}: "expected one of [$end, ')', ',', ';', AS, FULL, GROUP, LEFT, LIMIT, OFFSET, ON, ORDER, RIGHT, WHERE]", - yyXError{326, -1}: "expected one of [$end, ')', ',', ';', DEFAULT]", - yyXError{327, -1}: "expected one of [$end, ')', ',', ';', DEFAULT]", - yyXError{267, -1}: "expected one of [$end, ')', ',', ';', FULL, GROUP, LEFT, LIMIT, OFFSET, ON, ORDER, RIGHT, WHERE]", - yyXError{269, -1}: "expected one of [$end, ')', ',', ';', FULL, GROUP, LEFT, LIMIT, OFFSET, ON, ORDER, RIGHT, WHERE]", - yyXError{221, -1}: "expected one of [$end, ')', ',', ';', FULL, GROUP, LEFT, LIMIT, OFFSET, ORDER, RIGHT, WHERE]", - yyXError{263, -1}: "expected one of [$end, ')', ',', ';', FULL, GROUP, LEFT, LIMIT, OFFSET, ORDER, RIGHT, WHERE]", - yyXError{256, -1}: "expected one of [$end, ')', ',', ';', LIMIT, OFFSET, ORDER]", - yyXError{328, -1}: "expected one of [$end, ')', ',', ';']", - yyXError{330, -1}: "expected one of [$end, ')', ',', ';']", - yyXError{123, -1}: "expected one of [$end, ')', ';', ASC, DESC, LIMIT, OFFSET]", - yyXError{229, -1}: "expected one of [$end, ')', ';', GROUP, LIMIT, OFFSET, ORDER, WHERE]", - yyXError{232, -1}: "expected one of [$end, ')', ';', GROUP, LIMIT, OFFSET, ORDER]", - yyXError{235, -1}: "expected one of [$end, ')', ';', LIMIT, OFFSET, ORDER]", - yyXError{252, -1}: "expected one of [$end, ')', ';', LIMIT, OFFSET, ORDER]", - yyXError{254, -1}: "expected one of [$end, ')', ';', LIMIT, OFFSET, ORDER]", - yyXError{238, -1}: "expected one of [$end, ')', ';', LIMIT, OFFSET]", - yyXError{247, -1}: "expected one of [$end, ')', ';', LIMIT, OFFSET]", - yyXError{248, -1}: "expected one of [$end, ')', ';', LIMIT, OFFSET]", - yyXError{249, -1}: "expected one of [$end, ')', ';', LIMIT, OFFSET]", - yyXError{242, -1}: "expected one of [$end, ')', ';']", - yyXError{205, -1}: "expected one of [$end, ',', ';', WHERE]", - yyXError{291, -1}: "expected one of [$end, ',', ';']", - yyXError{203, -1}: "expected one of [$end, ';', WHERE]", - yyXError{2, -1}: "expected one of [$end, ';']", - yyXError{6, -1}: "expected one of [$end, ';']", - yyXError{12, -1}: "expected one of [$end, ';']", - yyXError{14, -1}: "expected one of [$end, ';']", - yyXError{15, -1}: "expected one of [$end, ';']", - yyXError{16, -1}: "expected one of [$end, ';']", - yyXError{17, -1}: "expected one of [$end, ';']", - yyXError{18, -1}: "expected one of [$end, ';']", - yyXError{19, -1}: "expected one of [$end, ';']", - yyXError{20, -1}: "expected one of [$end, ';']", - yyXError{21, -1}: "expected one of [$end, ';']", - yyXError{22, -1}: "expected one of [$end, ';']", - yyXError{23, -1}: "expected one of [$end, ';']", - yyXError{24, -1}: "expected one of [$end, ';']", - yyXError{25, -1}: "expected one of [$end, ';']", - yyXError{26, -1}: "expected one of [$end, ';']", - yyXError{27, -1}: "expected one of [$end, ';']", - yyXError{28, -1}: "expected one of [$end, ';']", - yyXError{29, -1}: "expected one of [$end, ';']", - yyXError{40, -1}: "expected one of [$end, ';']", - yyXError{41, -1}: "expected one of [$end, ';']", - yyXError{209, -1}: "expected one of [$end, ';']", - yyXError{282, -1}: "expected one of [$end, ';']", - yyXError{287, -1}: "expected one of [$end, ';']", - yyXError{292, -1}: "expected one of [$end, ';']", - yyXError{295, -1}: "expected one of [$end, ';']", - yyXError{298, -1}: "expected one of [$end, ';']", - yyXError{302, -1}: "expected one of [$end, ';']", - yyXError{305, -1}: "expected one of [$end, ';']", - yyXError{321, -1}: "expected one of [$end, ';']", - yyXError{336, -1}: "expected one of [$end, ';']", - yyXError{347, -1}: "expected one of [$end, ';']", - yyXError{348, -1}: "expected one of [$end, ';']", - yyXError{354, -1}: "expected one of [$end, ';']", - yyXError{355, -1}: "expected one of [$end, ';']", - yyXError{358, -1}: "expected one of [$end, ';']", - yyXError{211, -1}: "expected one of ['!', '(', '*', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{105, -1}: "expected one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{106, -1}: "expected one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{110, -1}: "expected one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{111, -1}: "expected one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{320, -1}: "expected one of [')', ',']", - yyXError{178, -1}: "expected one of ['+', '-', '^', '|', AND]", - yyXError{183, -1}: "expected one of ['+', '-', '^', '|', AND]", - yyXError{213, -1}: "expected one of [',', FROM]", - yyXError{214, -1}: "expected one of [',', FROM]", - yyXError{271, -1}: "expected one of [',', FROM]", - yyXError{272, -1}: "expected one of [',', FROM]", - yyXError{274, -1}: "expected one of [',', FROM]", - yyXError{350, -1}: "expected one of [ADD, DROP]", - yyXError{158, -1}: "expected one of [BETWEEN, IN]", - yyXError{9, -1}: "expected one of [INDEX, TABLE]", - yyXError{225, -1}: "expected one of [JOIN, OUTER]", - yyXError{226, -1}: "expected one of [JOIN, OUTER]", - yyXError{227, -1}: "expected one of [JOIN, OUTER]", - yyXError{160, -1}: "expected one of [NOT, NULL]", - yyXError{280, -1}: "expected one of [SELECT, VALUES]", - yyXError{323, -1}: "expected optional DEFAULT clause or one of [$end, ')', ',', ';', DEFAULT]", - yyXError{322, -1}: "expected optional DEFAULT clause or optional column value constraint or one of [$end, '!', '(', ')', '+', ',', '-', ';', '^', DEFAULT, NOT, NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{228, -1}: "expected optional OUTER clause or one of [JOIN, OUTER]", - yyXError{122, -1}: "expected optional comma or one of [$end, ')', ',', ';', ASC, DESC, LIMIT, OFFSET]", - yyXError{253, -1}: "expected optional comma or one of [$end, ')', ',', ';', LIMIT, OFFSET, ORDER]", - yyXError{202, -1}: "expected optional comma or one of [$end, ',', ';', WHERE]", - yyXError{286, -1}: "expected optional comma or one of [$end, ',', ';']", - yyXError{317, -1}: "expected optional comma or one of [')', ',']", - yyXError{334, -1}: "expected optional comma or one of [')', ',']", - yyXError{159, -1}: "expected primary expression factor or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{161, -1}: "expected primary expression factor or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{162, -1}: "expected primary expression factor or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{163, -1}: "expected primary expression factor or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{164, -1}: "expected primary expression factor or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{165, -1}: "expected primary expression factor or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{166, -1}: "expected primary expression factor or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{167, -1}: "expected primary expression factor or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{179, -1}: "expected primary expression factor or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{182, -1}: "expected primary expression factor or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{184, -1}: "expected primary expression factor or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{90, -1}: "expected primary expression or one of ['(', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{91, -1}: "expected primary expression or one of ['(', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{92, -1}: "expected primary expression or one of ['(', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{93, -1}: "expected primary expression or one of ['(', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{149, -1}: "expected primary expression term or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{150, -1}: "expected primary expression term or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{151, -1}: "expected primary expression term or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{152, -1}: "expected primary expression term or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{218, -1}: "expected record set optional AS clause or one of [$end, ')', ',', ';', AS, FULL, GROUP, LEFT, LIMIT, OFFSET, ON, ORDER, RIGHT, WHERE]", - yyXError{223, -1}: "expected record set or one of [$end, '(', ')', ';', FULL, GROUP, LEFT, LIMIT, OFFSET, ORDER, RIGHT, WHERE, identifier]", - yyXError{259, -1}: "expected record set or one of ['(', identifier]", - yyXError{188, -1}: "expected semiOpt or one of [')', ';']", - yyXError{195, -1}: "expected semiOpt or one of [')', ';']", - yyXError{264, -1}: "expected semiOpt or one of [')', ';']", - yyXError{10, -1}: "expected statement or one of [$end, ';', ALTER, BEGIN, COMMIT, CREATE, DELETE, DROP, EXPLAIN, INSERT, ROLLBACK, SELECT, TRUNCATE, UPDATE]", - yyXError{357, -1}: "expected statement or one of [$end, ';', ALTER, BEGIN, COMMIT, CREATE, DELETE, DROP, EXPLAIN, INSERT, ROLLBACK, SELECT, TRUNCATE, UPDATE]", - yyXError{314, -1}: "expected table column definition or identifier", - yyXError{332, -1}: "expected table column definition or identifier", - yyXError{351, -1}: "expected table column definition or identifier", - yyXError{319, -1}: "expected table column definition or one of [')', identifier]", - yyXError{31, -1}: "expected table name or identifier", - yyXError{208, -1}: "expected table name or identifier", - yyXError{275, -1}: "expected table name or identifier", - yyXError{297, -1}: "expected table name or identifier", - yyXError{303, -1}: "expected table name or identifier", - yyXError{312, -1}: "expected table name or identifier", - yyXError{349, -1}: "expected table name or identifier", - yyXError{294, -1}: "expected table name or one of [IF, identifier]", - yyXError{308, -1}: "expected table name or one of [IF, identifier]", - yyXError{315, -1}: "expected type or one of [bigint, bigrat, blob, bool, byte, complex128, complex64, duration, float, float32, float64, int, int16, int32, int64, int8, rune, string, time, uint, uint16, uint32, uint64, uint8]", - yyXError{133, -1}: "expected unary expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{134, -1}: "expected unary expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{135, -1}: "expected unary expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{136, -1}: "expected unary expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{137, -1}: "expected unary expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{138, -1}: "expected unary expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - yyXError{139, -1}: "expected unary expression or one of ['!', '(', '+', '-', '^', NULL, QL parameter, bigint, bigrat, blob, bool, byte, complex128, complex64, duration, false, float, float32, float64, floating-point literal, identifier, imaginary literal, int, int16, int32, int64, int8, integer literal, rune, string, string literal, time, true, uint, uint16, uint32, uint64, uint8]", - } - - yyParseTab = [359][]uint16{ - // 0 - {172, 172, 96: 229, 101: 242, 104: 225, 114: 220, 231, 221, 232, 222, 233, 223, 234, 235, 236, 224, 237, 238, 230, 226, 239, 227, 240, 134: 228, 241, 137: 245, 246, 243, 247, 244, 179: 219, 190: 217, 218}, - {1: 216}, - {573, 215}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 572}, - {112: 565}, - // 5 - {192: 564}, - {197, 197}, - {110: 188, 112: 524, 161: 522, 193: 523}, - {51: 519}, - {110: 509, 112: 510}, - // 10 - {172, 172, 96: 229, 101: 242, 104: 225, 114: 220, 231, 221, 232, 222, 233, 223, 234, 235, 236, 224, 237, 238, 230, 226, 239, 227, 240, 134: 228, 241, 137: 508, 246, 243, 247, 244}, - {172: 491}, - {89, 89}, - {3: 75, 75, 75, 7: 75, 75, 14: 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 42: 75, 75, 47: 75, 75, 75, 75, 76: 75, 164: 427, 182: 426}, - {60, 60}, - // 15 - {59, 59}, - {58, 58}, - {57, 57}, - {56, 56}, - {55, 55}, - // 20 - {54, 54}, - {53, 53}, - {52, 52}, - {51, 51}, - {50, 50}, - // 25 - {49, 49}, - {48, 48}, - {47, 47}, - {46, 46}, - {45, 45}, - // 30 - {112: 424}, - {8: 248, 97: 249}, - {43, 43, 7: 43, 43, 13: 43, 96: 43, 104: 43, 113: 43, 144: 43, 151: 43}, - {8: 4, 151: 251, 189: 250}, - {8: 254, 92: 252, 145: 253, 153: 255}, - // 35 - {8: 3}, - {143: 422}, - {209, 209, 6: 209, 13: 209, 154: 418}, - {201, 201, 201, 6: 201, 9: 201, 201, 12: 201, 15: 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 143: 201}, - {12, 12, 13: 258, 142: 257, 194: 256}, - // 40 - {13, 13}, - {11, 11}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 261}, - {7: 415}, - {170, 170, 170, 6: 170, 9: 170, 170, 170, 170, 170, 41: 170, 45: 170, 170, 51: 170, 170, 170, 170, 170, 170, 327, 326, 150: 325}, - // 45 - {5, 5, 5, 9: 5, 5, 12: 5, 41: 5, 45: 322, 321, 91: 320}, - {163, 163, 163, 6: 163, 9: 163, 163, 163, 163, 163, 41: 163, 44: 374, 163, 163, 51: 163, 163, 163, 163, 163, 163, 163, 163, 60: 375, 373, 380, 378, 382, 377, 376, 379, 383, 381}, - {154, 154, 154, 368, 367, 365, 154, 9: 154, 154, 154, 154, 154, 41: 154, 44: 154, 154, 154, 51: 154, 154, 154, 154, 154, 154, 154, 154, 366, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154}, - {133, 133, 133, 133, 133, 133, 133, 133, 9: 133, 133, 133, 133, 133, 41: 133, 44: 133, 133, 133, 51: 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 76: 133, 78: 133, 133, 133, 133, 133, 133, 86: 133}, - {132, 132, 132, 132, 132, 132, 132, 132, 9: 132, 132, 132, 132, 132, 41: 132, 44: 132, 132, 132, 51: 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 76: 132, 78: 132, 132, 132, 132, 132, 132, 86: 132}, - // 50 - {131, 131, 131, 131, 131, 131, 131, 131, 9: 131, 131, 131, 131, 131, 41: 131, 44: 131, 131, 131, 51: 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 76: 131, 78: 131, 131, 131, 131, 131, 131, 86: 131}, - {130, 130, 130, 130, 130, 130, 130, 130, 9: 130, 130, 130, 130, 130, 41: 130, 44: 130, 130, 130, 51: 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 76: 130, 78: 130, 130, 130, 130, 130, 130, 86: 130}, - {129, 129, 129, 129, 129, 129, 129, 129, 9: 129, 129, 129, 129, 129, 41: 129, 44: 129, 129, 129, 51: 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 76: 129, 78: 129, 129, 129, 129, 129, 129, 86: 129}, - {128, 128, 128, 128, 128, 128, 128, 128, 9: 128, 128, 128, 128, 128, 41: 128, 44: 128, 128, 128, 51: 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 76: 128, 78: 128, 128, 128, 128, 128, 128, 86: 128}, - {127, 127, 127, 127, 127, 127, 127, 127, 9: 127, 127, 127, 127, 127, 41: 127, 44: 127, 127, 127, 51: 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 76: 127, 78: 127, 127, 127, 127, 127, 127, 86: 127}, - // 55 - {126, 126, 126, 126, 126, 126, 126, 126, 9: 126, 126, 126, 126, 126, 41: 126, 44: 126, 126, 126, 51: 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 76: 126, 78: 126, 126, 126, 126, 126, 126, 86: 126}, - {125, 125, 125, 125, 125, 125, 125, 125, 9: 125, 125, 125, 125, 125, 41: 125, 44: 125, 125, 125, 51: 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 76: 125, 78: 125, 125, 125, 125, 125, 125, 86: 125}, - {124, 124, 124, 124, 124, 124, 124, 124, 9: 124, 124, 124, 124, 124, 41: 124, 44: 124, 124, 124, 51: 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 76: 124, 78: 124, 124, 124, 124, 124, 124, 86: 124}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 363}, - {118, 118, 118, 118, 118, 118, 118, 118, 9: 118, 118, 118, 118, 118, 41: 118, 44: 118, 118, 118, 51: 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 76: 118, 78: 118, 118, 118, 118, 118, 118, 86: 118}, - // 60 - {117, 117, 117, 117, 117, 117, 117, 117, 9: 117, 117, 117, 117, 117, 41: 117, 44: 117, 117, 117, 51: 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, 76: 117, 78: 117, 117, 117, 117, 117, 117, 86: 117}, - {10, 10, 10, 10, 10, 10, 10, 311, 9: 10, 10, 10, 10, 10, 41: 10, 44: 10, 10, 10, 51: 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 76: 10, 78: 10, 10, 10, 10, 10, 10, 86: 312, 103: 315, 105: 313, 314}, - {113, 113, 113, 113, 113, 113, 113, 9: 113, 113, 113, 113, 113, 41: 113, 44: 113, 113, 113, 51: 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 76: 355, 78: 353, 350, 354, 349, 351, 352}, - {108, 108, 108, 108, 108, 108, 108, 9: 108, 108, 108, 108, 108, 41: 108, 44: 108, 108, 108, 51: 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 76: 108, 78: 108, 108, 108, 108, 108, 108}, - {100, 100, 100, 100, 100, 100, 100, 100, 9: 100, 100, 100, 100, 100, 41: 100, 44: 100, 100, 100, 51: 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 76: 100, 78: 100, 100, 100, 100, 100, 100, 86: 100, 152: 347}, - // 65 - {42, 42, 42, 6: 42, 9: 42, 42, 42, 42, 42, 41: 42, 45: 42, 42, 51: 42, 42, 42, 42, 42, 42, 42, 42}, - {37, 37, 37, 37, 37, 37, 37, 37, 37, 11: 37, 14: 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 42: 37, 37, 37, 47: 37, 37, 37, 37}, - {36, 36, 36, 36, 36, 36, 36, 36, 36, 11: 36, 14: 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 42: 36, 36, 36, 47: 36, 36, 36, 36}, - {35, 35, 35, 35, 35, 35, 35, 35, 35, 11: 35, 14: 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 42: 35, 35, 35, 47: 35, 35, 35, 35}, - {34, 34, 34, 34, 34, 34, 34, 34, 34, 11: 34, 14: 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 42: 34, 34, 34, 47: 34, 34, 34, 34}, - // 70 - {33, 33, 33, 33, 33, 33, 33, 33, 33, 11: 33, 14: 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 42: 33, 33, 33, 47: 33, 33, 33, 33}, - {32, 32, 32, 32, 32, 32, 32, 32, 32, 11: 32, 14: 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 42: 32, 32, 32, 47: 32, 32, 32, 32}, - {31, 31, 31, 31, 31, 31, 31, 31, 31, 11: 31, 14: 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 42: 31, 31, 31, 47: 31, 31, 31, 31}, - {30, 30, 30, 30, 30, 30, 30, 30, 30, 11: 30, 14: 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 42: 30, 30, 30, 47: 30, 30, 30, 30}, - {29, 29, 29, 29, 29, 29, 29, 29, 29, 11: 29, 14: 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 42: 29, 29, 29, 47: 29, 29, 29, 29}, - // 75 - {28, 28, 28, 28, 28, 28, 28, 28, 28, 11: 28, 14: 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 42: 28, 28, 28, 47: 28, 28, 28, 28}, - {27, 27, 27, 27, 27, 27, 27, 27, 27, 11: 27, 14: 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 42: 27, 27, 27, 47: 27, 27, 27, 27}, - {26, 26, 26, 26, 26, 26, 26, 26, 26, 11: 26, 14: 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 42: 26, 26, 26, 47: 26, 26, 26, 26}, - {25, 25, 25, 25, 25, 25, 25, 25, 25, 11: 25, 14: 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 42: 25, 25, 25, 47: 25, 25, 25, 25}, - {24, 24, 24, 24, 24, 24, 24, 24, 24, 11: 24, 14: 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 42: 24, 24, 24, 47: 24, 24, 24, 24}, - // 80 - {23, 23, 23, 23, 23, 23, 23, 23, 23, 11: 23, 14: 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 42: 23, 23, 23, 47: 23, 23, 23, 23}, - {22, 22, 22, 22, 22, 22, 22, 22, 22, 11: 22, 14: 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 42: 22, 22, 22, 47: 22, 22, 22, 22}, - {21, 21, 21, 21, 21, 21, 21, 21, 21, 11: 21, 14: 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 42: 21, 21, 21, 47: 21, 21, 21, 21}, - {20, 20, 20, 20, 20, 20, 20, 20, 20, 11: 20, 14: 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 42: 20, 20, 20, 47: 20, 20, 20, 20}, - {19, 19, 19, 19, 19, 19, 19, 19, 19, 11: 19, 14: 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 42: 19, 19, 19, 47: 19, 19, 19, 19}, - // 85 - {18, 18, 18, 18, 18, 18, 18, 18, 18, 11: 18, 14: 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 42: 18, 18, 18, 47: 18, 18, 18, 18}, - {17, 17, 17, 17, 17, 17, 17, 17, 17, 11: 17, 14: 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 42: 17, 17, 17, 47: 17, 17, 17, 17}, - {16, 16, 16, 16, 16, 16, 16, 16, 16, 11: 16, 14: 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 42: 16, 16, 16, 47: 16, 16, 16, 16}, - {15, 15, 15, 15, 15, 15, 15, 15, 15, 11: 15, 14: 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 42: 15, 15, 15, 47: 15, 15, 15, 15}, - {14, 14, 14, 14, 14, 14, 14, 14, 14, 11: 14, 14: 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 42: 14, 14, 14, 47: 14, 14, 14, 14}, - // 90 - {7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 70: 259, 276, 271, 275, 346, 273}, - {7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 70: 259, 276, 271, 275, 345, 273}, - {7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 70: 259, 276, 271, 275, 344, 273}, - {7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 70: 259, 276, 271, 275, 310, 273}, - {6, 6, 6, 6, 6, 6, 6, 311, 9: 6, 6, 6, 6, 6, 41: 6, 44: 6, 6, 6, 51: 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 76: 6, 78: 6, 6, 6, 6, 6, 6, 86: 312, 103: 315, 105: 313, 314}, - // 95 - {2: 204, 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 335, 279, 84: 278, 263, 87: 281, 262, 260, 337, 99: 336, 155: 334}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 56: 317, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 316}, - {116, 116, 116, 116, 116, 116, 116, 116, 9: 116, 116, 116, 116, 116, 41: 116, 44: 116, 116, 116, 51: 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 76: 116, 78: 116, 116, 116, 116, 116, 116, 86: 116}, - {115, 115, 115, 115, 115, 115, 115, 115, 9: 115, 115, 115, 115, 115, 41: 115, 44: 115, 115, 115, 51: 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 76: 115, 78: 115, 115, 115, 115, 115, 115, 86: 115}, - {114, 114, 114, 114, 114, 114, 114, 114, 9: 114, 114, 114, 114, 114, 41: 114, 44: 114, 114, 114, 51: 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 76: 114, 78: 114, 114, 114, 114, 114, 114, 86: 114}, - // 100 - {45: 322, 321, 54: 329, 56: 330, 91: 320}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 54: 319, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 318}, - {45: 322, 321, 54: 323, 91: 320}, - {64, 64, 64, 64, 64, 64, 64, 64, 9: 64, 64, 64, 64, 64, 41: 64, 44: 64, 64, 64, 51: 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 76: 64, 78: 64, 64, 64, 64, 64, 64, 86: 64}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 324}, - // 105 - {3: 168, 168, 168, 7: 168, 168, 14: 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 42: 168, 168, 47: 168, 168, 168, 168}, - {3: 167, 167, 167, 7: 167, 167, 14: 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 42: 167, 167, 47: 167, 167, 167, 167}, - {63, 63, 63, 63, 63, 63, 63, 63, 9: 63, 63, 63, 63, 63, 41: 63, 44: 63, 63, 63, 51: 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 76: 63, 78: 63, 63, 63, 63, 63, 63, 86: 63}, - {169, 169, 169, 6: 169, 9: 169, 169, 169, 169, 169, 41: 169, 45: 169, 169, 51: 169, 169, 169, 169, 169, 169, 327, 326, 150: 325}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 328, 262}, - // 110 - {3: 40, 40, 40, 7: 40, 40, 14: 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 42: 40, 40, 47: 40, 40, 40, 40}, - {3: 39, 39, 39, 7: 39, 39, 14: 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 42: 39, 39, 47: 39, 39, 39, 39}, - {41, 41, 41, 6: 41, 9: 41, 41, 41, 41, 41, 41: 41, 45: 41, 41, 51: 41, 41, 41, 41, 41, 41, 41, 41}, - {140, 140, 140, 140, 140, 140, 140, 140, 9: 140, 140, 140, 140, 140, 41: 140, 44: 140, 140, 140, 51: 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 76: 140, 78: 140, 140, 140, 140, 140, 140, 86: 140}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 54: 332, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 331}, - // 115 - {45: 322, 321, 54: 333, 91: 320}, - {62, 62, 62, 62, 62, 62, 62, 62, 9: 62, 62, 62, 62, 62, 41: 62, 44: 62, 62, 62, 51: 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 76: 62, 78: 62, 62, 62, 62, 62, 62, 86: 62}, - {61, 61, 61, 61, 61, 61, 61, 61, 9: 61, 61, 61, 61, 61, 41: 61, 44: 61, 61, 61, 51: 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 76: 61, 78: 61, 61, 61, 61, 61, 61, 86: 61}, - {2: 343}, - {2: 342}, - // 120 - {2: 203}, - {165, 165, 165, 6: 165, 9: 165, 165, 45: 322, 321, 52: 165, 165, 91: 320, 166: 338}, - {2, 2, 2, 6: 340, 9: 2, 2, 52: 2, 2, 98: 339}, - {166, 166, 166, 9: 166, 166, 52: 166, 166}, - {1, 1, 1, 309, 308, 306, 7: 274, 280, 1, 1, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 52: 1, 1, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 341}, - // 125 - {164, 164, 164, 6: 164, 9: 164, 164, 45: 322, 321, 52: 164, 164, 91: 320}, - {205, 205, 205, 205, 205, 205, 205, 205, 9: 205, 205, 205, 205, 205, 41: 205, 44: 205, 205, 205, 51: 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 76: 205, 78: 205, 205, 205, 205, 205, 205, 86: 205}, - {206, 206, 206, 206, 206, 206, 206, 206, 9: 206, 206, 206, 206, 206, 41: 206, 44: 206, 206, 206, 51: 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 76: 206, 78: 206, 206, 206, 206, 206, 206, 86: 206}, - {7, 7, 7, 7, 7, 7, 7, 311, 9: 7, 7, 7, 7, 7, 41: 7, 44: 7, 7, 7, 51: 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 76: 7, 78: 7, 7, 7, 7, 7, 7, 86: 312, 103: 315, 105: 313, 314}, - {8, 8, 8, 8, 8, 8, 8, 311, 9: 8, 8, 8, 8, 8, 41: 8, 44: 8, 8, 8, 51: 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 76: 8, 78: 8, 8, 8, 8, 8, 8, 86: 312, 103: 315, 105: 313, 314}, - // 130 - {9, 9, 9, 9, 9, 9, 9, 311, 9: 9, 9, 9, 9, 9, 41: 9, 44: 9, 9, 9, 51: 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 76: 9, 78: 9, 9, 9, 9, 9, 9, 86: 312, 103: 315, 105: 313, 314}, - {8: 348}, - {99, 99, 99, 99, 99, 99, 99, 99, 9: 99, 99, 99, 99, 99, 41: 99, 44: 99, 99, 99, 51: 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 76: 99, 78: 99, 99, 99, 99, 99, 99, 86: 99}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 362}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 361}, - // 135 - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 360}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 359}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 358}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 357}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 356}, - // 140 - {101, 101, 101, 101, 101, 101, 101, 9: 101, 101, 101, 101, 101, 41: 101, 44: 101, 101, 101, 51: 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 76: 101, 78: 101, 101, 101, 101, 101, 101}, - {102, 102, 102, 102, 102, 102, 102, 9: 102, 102, 102, 102, 102, 41: 102, 44: 102, 102, 102, 51: 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 76: 102, 78: 102, 102, 102, 102, 102, 102}, - {103, 103, 103, 103, 103, 103, 103, 9: 103, 103, 103, 103, 103, 41: 103, 44: 103, 103, 103, 51: 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 76: 103, 78: 103, 103, 103, 103, 103, 103}, - {104, 104, 104, 104, 104, 104, 104, 9: 104, 104, 104, 104, 104, 41: 104, 44: 104, 104, 104, 51: 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 76: 104, 78: 104, 104, 104, 104, 104, 104}, - {105, 105, 105, 105, 105, 105, 105, 9: 105, 105, 105, 105, 105, 41: 105, 44: 105, 105, 105, 51: 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 76: 105, 78: 105, 105, 105, 105, 105, 105}, - // 145 - {106, 106, 106, 106, 106, 106, 106, 9: 106, 106, 106, 106, 106, 41: 106, 44: 106, 106, 106, 51: 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 76: 106, 78: 106, 106, 106, 106, 106, 106}, - {107, 107, 107, 107, 107, 107, 107, 9: 107, 107, 107, 107, 107, 41: 107, 44: 107, 107, 107, 51: 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 76: 107, 78: 107, 107, 107, 107, 107, 107}, - {2: 364, 45: 322, 321, 91: 320}, - {123, 123, 123, 123, 123, 123, 123, 123, 9: 123, 123, 123, 123, 123, 41: 123, 44: 123, 123, 123, 51: 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 76: 123, 78: 123, 123, 123, 123, 123, 123, 86: 123}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 372}, - // 150 - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 371}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 370}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 369}, - {109, 109, 109, 109, 109, 109, 109, 9: 109, 109, 109, 109, 109, 41: 109, 44: 109, 109, 109, 51: 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 76: 355, 78: 353, 350, 354, 349, 351, 352}, - {110, 110, 110, 110, 110, 110, 110, 9: 110, 110, 110, 110, 110, 41: 110, 44: 110, 110, 110, 51: 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 76: 355, 78: 353, 350, 354, 349, 351, 352}, - // 155 - {111, 111, 111, 111, 111, 111, 111, 9: 111, 111, 111, 111, 111, 41: 111, 44: 111, 111, 111, 51: 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 76: 355, 78: 353, 350, 354, 349, 351, 352}, - {112, 112, 112, 112, 112, 112, 112, 9: 112, 112, 112, 112, 112, 41: 112, 44: 112, 112, 112, 51: 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 76: 355, 78: 353, 350, 354, 349, 351, 352}, - {7: 409}, - {60: 398, 397}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 394}, - // 160 - {14: 391, 44: 392}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 390}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 389}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 388}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 387}, - // 165 - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 386}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 385}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 384}, - {147, 147, 147, 368, 367, 365, 147, 9: 147, 147, 147, 147, 147, 41: 147, 44: 147, 147, 147, 51: 147, 147, 147, 147, 147, 147, 147, 147, 366, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147}, - {148, 148, 148, 368, 367, 365, 148, 9: 148, 148, 148, 148, 148, 41: 148, 44: 148, 148, 148, 51: 148, 148, 148, 148, 148, 148, 148, 148, 366, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148}, - // 170 - {149, 149, 149, 368, 367, 365, 149, 9: 149, 149, 149, 149, 149, 41: 149, 44: 149, 149, 149, 51: 149, 149, 149, 149, 149, 149, 149, 149, 366, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149}, - {150, 150, 150, 368, 367, 365, 150, 9: 150, 150, 150, 150, 150, 41: 150, 44: 150, 150, 150, 51: 150, 150, 150, 150, 150, 150, 150, 150, 366, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150}, - {151, 151, 151, 368, 367, 365, 151, 9: 151, 151, 151, 151, 151, 41: 151, 44: 151, 151, 151, 51: 151, 151, 151, 151, 151, 151, 151, 151, 366, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151}, - {152, 152, 152, 368, 367, 365, 152, 9: 152, 152, 152, 152, 152, 41: 152, 44: 152, 152, 152, 51: 152, 152, 152, 152, 152, 152, 152, 152, 366, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152}, - {153, 153, 153, 368, 367, 365, 153, 9: 153, 153, 153, 153, 153, 41: 153, 44: 153, 153, 153, 51: 153, 153, 153, 153, 153, 153, 153, 153, 366, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153}, - // 175 - {156, 156, 156, 6: 156, 9: 156, 156, 156, 156, 156, 41: 156, 45: 156, 156, 51: 156, 156, 156, 156, 156, 156, 156, 156}, - {14: 393}, - {155, 155, 155, 6: 155, 9: 155, 155, 155, 155, 155, 41: 155, 45: 155, 155, 51: 155, 155, 155, 155, 155, 155, 155, 155}, - {3: 368, 367, 365, 57: 395, 59: 366}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 396}, - // 180 - {158, 158, 158, 368, 367, 365, 158, 9: 158, 158, 158, 158, 158, 41: 158, 45: 158, 158, 51: 158, 158, 158, 158, 158, 158, 158, 158, 366}, - {7: 402}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 399}, - {3: 368, 367, 365, 57: 400, 59: 366}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 401}, - // 185 - {157, 157, 157, 368, 367, 365, 157, 9: 157, 157, 157, 157, 157, 41: 157, 45: 157, 157, 51: 157, 157, 157, 157, 157, 157, 157, 157, 366}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 337, 96: 229, 99: 403, 101: 404}, - {2: 408}, - {406, 2: 95, 136: 405}, - {2: 407}, - // 190 - {2: 94}, - {159, 159, 159, 6: 159, 9: 159, 159, 159, 159, 159, 41: 159, 45: 159, 159, 51: 159, 159, 159, 159, 159, 159, 159, 159}, - {161, 161, 161, 6: 161, 9: 161, 161, 161, 161, 161, 41: 161, 45: 161, 161, 51: 161, 161, 161, 161, 161, 161, 161, 161}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 337, 96: 229, 99: 410, 101: 411}, - {2: 414}, - // 195 - {406, 2: 95, 136: 412}, - {2: 413}, - {160, 160, 160, 6: 160, 9: 160, 160, 160, 160, 160, 41: 160, 45: 160, 160, 51: 160, 160, 160, 160, 160, 160, 160, 160}, - {162, 162, 162, 6: 162, 9: 162, 162, 162, 162, 162, 41: 162, 45: 162, 162, 51: 162, 162, 162, 162, 162, 162, 162, 162}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 416}, - // 200 - {2: 417, 45: 322, 321, 91: 320}, - {192, 192, 192, 192, 192, 192, 192, 192, 9: 192, 192, 192, 192, 192, 41: 192, 44: 192, 192, 192, 51: 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 76: 192, 78: 192, 192, 192, 192, 192, 192, 86: 192}, - {2, 2, 6: 420, 13: 2, 98: 419}, - {210, 210, 13: 210}, - {1, 1, 8: 254, 13: 1, 92: 252, 145: 421}, - // 205 - {208, 208, 6: 208, 13: 208}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 423}, - {211, 211, 6: 211, 13: 211, 45: 322, 321, 91: 320}, - {8: 248, 97: 425}, - {38, 38}, - // 210 - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 432, 279, 84: 278, 263, 87: 281, 262, 260, 428, 149: 429, 168: 430, 183: 431}, - {3: 74, 74, 74, 7: 74, 74, 14: 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, 42: 74, 74, 47: 74, 74, 74, 74, 76: 74}, - {6: 145, 45: 322, 321, 51: 145, 55: 489, 91: 320, 167: 488}, - {6: 143, 51: 143}, - {6: 486, 51: 72}, - // 215 - {51: 433}, - {51: 73}, - {7: 436, 435, 132: 437, 434, 181: 438}, - {93, 93, 93, 6: 93, 9: 93, 93, 12: 93, 93, 41: 93, 55: 484, 93: 93, 93, 93, 100: 93, 180: 483}, - {97, 97, 97, 6: 97, 9: 97, 97, 12: 97, 97, 41: 97, 55: 97, 93: 97, 97, 97, 100: 97}, - // 220 - {96: 229, 101: 480}, - {91, 91, 91, 6: 91, 9: 91, 91, 12: 91, 91, 41: 91, 93: 91, 91, 91}, - {2, 2, 2, 6: 439, 9: 2, 2, 12: 2, 2, 41: 2, 93: 2, 2, 2, 98: 440}, - {1, 1, 1, 7: 436, 435, 1, 1, 12: 1, 1, 41: 1, 93: 1, 1, 1, 132: 479, 434}, - {82, 82, 82, 9: 82, 82, 12: 82, 82, 41: 82, 93: 443, 441, 442, 173: 445, 446, 444}, - // 225 - {102: 88, 111: 88}, - {102: 87, 111: 87}, - {102: 86, 111: 86}, - {102: 85, 111: 473, 178: 474}, - {81, 81, 81, 9: 81, 81, 12: 81, 81, 41: 81}, - // 230 - {70, 70, 70, 9: 70, 70, 12: 70, 258, 41: 70, 142: 448, 188: 447}, - {68, 68, 68, 9: 68, 68, 12: 68, 41: 449, 169: 451, 184: 450}, - {69, 69, 69, 9: 69, 69, 12: 69, 41: 69}, - {146: 466}, - {66, 66, 66, 9: 66, 66, 12: 452, 176: 454, 187: 453}, - // 235 - {67, 67, 67, 9: 67, 67, 12: 67}, - {146: 461}, - {79, 79, 79, 9: 79, 456, 185: 455}, - {65, 65, 65, 9: 65, 65}, - {77, 77, 77, 9: 459, 186: 458}, - // 240 - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 457}, - {78, 78, 78, 9: 78, 45: 322, 321, 91: 320}, - {80, 80, 80}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 460}, - {76, 76, 76, 45: 322, 321, 91: 320}, - // 245 - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 337, 99: 462}, - {121, 121, 121, 9: 121, 121, 52: 464, 465, 177: 463}, - {122, 122, 122, 9: 122, 122}, - {120, 120, 120, 9: 120, 120}, - {119, 119, 119, 9: 119, 119}, - // 250 - {8: 254, 92: 467, 147: 468}, - {199, 199, 199, 6: 199, 9: 199, 199, 12: 199, 157: 469}, - {141, 141, 141, 9: 141, 141, 12: 141}, - {2, 2, 2, 6: 471, 9: 2, 2, 12: 2, 98: 470}, - {200, 200, 200, 9: 200, 200, 12: 200}, - // 255 - {1, 1, 1, 8: 254, 1, 1, 12: 1, 92: 472}, - {198, 198, 198, 6: 198, 9: 198, 198, 12: 198}, - {102: 84}, - {102: 475}, - {7: 436, 435, 132: 476, 434}, - // 260 - {100: 477}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 478}, - {83, 83, 83, 9: 83, 83, 12: 83, 83, 41: 83, 45: 322, 321, 91: 320}, - {90, 90, 90, 6: 90, 9: 90, 90, 12: 90, 90, 41: 90, 93: 90, 90, 90}, - {406, 2: 95, 136: 481}, - // 265 - {2: 482}, - {96, 96, 96, 6: 96, 9: 96, 96, 12: 96, 96, 41: 96, 55: 96, 93: 96, 96, 96, 100: 96}, - {98, 98, 98, 6: 98, 9: 98, 98, 12: 98, 98, 41: 98, 93: 98, 98, 98, 100: 98}, - {8: 485}, - {92, 92, 92, 6: 92, 9: 92, 92, 12: 92, 92, 41: 92, 93: 92, 92, 92, 100: 92}, - // 270 - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 71, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 428, 149: 487}, - {6: 142, 51: 142}, - {6: 146, 51: 146}, - {8: 490}, - {6: 144, 51: 144}, - // 275 - {8: 248, 97: 492}, - {7: 494, 96: 137, 113: 137, 170: 493}, - {96: 229, 101: 498, 113: 497}, - {8: 254, 92: 467, 147: 495}, - {2: 496}, - // 280 - {96: 136, 113: 136}, - {7: 499}, - {138, 138}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 337, 99: 500}, - {2: 501}, - // 285 - {135, 135, 6: 135, 171: 502}, - {2, 2, 6: 504, 98: 503}, - {139, 139}, - {1, 1, 7: 505}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 337, 99: 506}, - // 290 - {2: 507}, - {134, 134, 6: 134}, - {171, 171}, - {8: 176, 109: 516, 165: 515}, - {8: 248, 97: 511, 109: 512}, - // 295 - {174, 174}, - {108: 513}, - {8: 248, 97: 514}, - {173, 173}, - {8: 518}, - // 300 - {108: 517}, - {8: 175}, - {177, 177}, - {8: 248, 97: 520}, - {179, 179, 13: 258, 142: 521}, - // 305 - {178, 178}, - {110: 553}, - {110: 187}, - {8: 248, 97: 525, 109: 526}, - {7: 548}, - // 310 - {44: 527}, - {108: 528}, - {8: 248, 97: 529}, - {7: 530}, - {8: 254, 92: 531, 107: 532}, - // 315 - {15: 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 70: 538}, - {2: 184, 6: 184, 148: 533}, - {2: 2, 6: 535, 98: 534}, - {2: 537}, - {2: 1, 8: 254, 92: 531, 107: 536}, - // 320 - {2: 183, 6: 183}, - {185, 185}, - {194, 194, 194, 309, 308, 306, 194, 274, 280, 11: 194, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 540, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 541, 158: 542, 539}, - {181, 181, 181, 6: 181, 11: 545, 162: 546, 544}, - {14: 543}, - // 325 - {195, 195, 195, 6: 195, 11: 195, 45: 322, 321, 91: 320}, - {193, 193, 193, 6: 193, 11: 193}, - {196, 196, 196, 6: 196, 11: 196}, - {202, 202, 202, 6: 202}, - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 547}, - // 330 - {180, 180, 180, 6: 180}, - {182, 182, 182, 6: 182, 45: 322, 321, 91: 320}, - {8: 254, 92: 531, 107: 549}, - {2: 184, 6: 184, 148: 550}, - {2: 2, 6: 535, 98: 551}, - // 335 - {2: 552}, - {186, 186}, - {8: 190, 109: 555, 160: 554}, - {8: 558}, - {44: 556}, - // 340 - {108: 557}, - {8: 189}, - {100: 559}, - {8: 560}, - {7: 561}, - // 345 - {3: 309, 308, 306, 7: 274, 280, 14: 265, 282, 283, 284, 285, 286, 287, 288, 289, 291, 292, 290, 294, 295, 296, 297, 293, 298, 299, 300, 302, 303, 304, 305, 301, 264, 267, 42: 268, 269, 47: 272, 270, 266, 307, 70: 259, 276, 271, 275, 277, 273, 77: 279, 84: 278, 263, 87: 281, 262, 260, 337, 99: 562}, - {2: 563}, - {191, 191}, - {207, 207}, - {8: 248, 97: 566}, - // 350 - {104: 568, 144: 567}, - {8: 254, 92: 531, 107: 571}, - {156: 569}, - {8: 254, 92: 570}, - {212, 212}, - // 355 - {213, 213}, - {1: 214, 45: 322, 321, 91: 320}, - {172, 172, 96: 229, 101: 242, 104: 225, 114: 220, 231, 221, 232, 222, 233, 223, 234, 235, 236, 224, 237, 238, 230, 226, 239, 227, 240, 134: 228, 241, 137: 574, 246, 243, 247, 244}, - {44, 44}, - } -) - -var yyDebug = 0 - -type yyLexer interface { - Lex(lval *yySymType) int - Error(s string) -} - -type yyLexerEx interface { - yyLexer - Reduced(rule, state int, lval *yySymType) bool -} - -func yySymName(c int) (s string) { - x, ok := yyXLAT[c] - if ok { - return yySymNames[x] - } - - return __yyfmt__.Sprintf("%d", c) -} - -func yylex1(yylex yyLexer, lval *yySymType) (n int) { - n = yylex.Lex(lval) - if n <= 0 { - n = yyEOFCode - } - if yyDebug >= 3 { - __yyfmt__.Printf("\nlex %s(%#x %d), lval: %+v\n", yySymName(n), n, n, lval) - } - return n -} - -func yyParse(yylex yyLexer) int { - const yyError = 196 - - yyEx, _ := yylex.(yyLexerEx) - var yyn int - var yylval yySymType - var yyVAL yySymType - yyS := make([]yySymType, 200) - - Nerrs := 0 /* number of errors */ - Errflag := 0 /* error recovery flag */ - yyerrok := func() { - if yyDebug >= 2 { - __yyfmt__.Printf("yyerrok()\n") - } - Errflag = 0 - } - _ = yyerrok - yystate := 0 - yychar := -1 - var yyxchar int - var yyshift int - yyp := -1 - goto yystack - -ret0: - return 0 - -ret1: - return 1 - -yystack: - /* put a state and value onto the stack */ - yyp++ - if yyp >= len(yyS) { - nyys := make([]yySymType, len(yyS)*2) - copy(nyys, yyS) - yyS = nyys - } - yyS[yyp] = yyVAL - yyS[yyp].yys = yystate - -yynewstate: - if yychar < 0 { - yychar = yylex1(yylex, &yylval) - var ok bool - if yyxchar, ok = yyXLAT[yychar]; !ok { - yyxchar = len(yySymNames) // > tab width - } - } - if yyDebug >= 4 { - var a []int - for _, v := range yyS[:yyp+1] { - a = append(a, v.yys) - } - __yyfmt__.Printf("state stack %v\n", a) - } - row := yyParseTab[yystate] - yyn = 0 - if yyxchar < len(row) { - if yyn = int(row[yyxchar]); yyn != 0 { - yyn += yyTabOfs - } - } - switch { - case yyn > 0: // shift - yychar = -1 - yyVAL = yylval - yystate = yyn - yyshift = yyn - if yyDebug >= 2 { - __yyfmt__.Printf("shift, and goto state %d\n", yystate) - } - if Errflag > 0 { - Errflag-- - } - goto yystack - case yyn < 0: // reduce - case yystate == 1: // accept - if yyDebug >= 2 { - __yyfmt__.Println("accept") - } - goto ret0 - } - - if yyn == 0 { - /* error ... attempt to resume parsing */ - switch Errflag { - case 0: /* brand new error */ - if yyDebug >= 1 { - __yyfmt__.Printf("no action for %s in state %d\n", yySymName(yychar), yystate) - } - msg, ok := yyXErrors[yyXError{yystate, yyxchar}] - if !ok { - msg, ok = yyXErrors[yyXError{yystate, -1}] - } - if !ok && yyshift != 0 { - msg, ok = yyXErrors[yyXError{yyshift, yyxchar}] - } - if !ok { - msg, ok = yyXErrors[yyXError{yyshift, -1}] - } - if !ok || msg == "" { - msg = "syntax error" - } - yylex.Error(msg) - Nerrs++ - fallthrough - - case 1, 2: /* incompletely recovered error ... try again */ - Errflag = 3 - - /* find a state where "error" is a legal shift action */ - for yyp >= 0 { - row := yyParseTab[yyS[yyp].yys] - if yyError < len(row) { - yyn = int(row[yyError]) + yyTabOfs - if yyn > 0 { // hit - if yyDebug >= 2 { - __yyfmt__.Printf("error recovery found error shift in state %d\n", yyS[yyp].yys) - } - yystate = yyn /* simulate a shift of "error" */ - goto yystack - } - } - - /* the current p has no shift on "error", pop stack */ - if yyDebug >= 2 { - __yyfmt__.Printf("error recovery pops state %d\n", yyS[yyp].yys) - } - yyp-- - } - /* there is no state on the stack with an error shift ... abort */ - if yyDebug >= 2 { - __yyfmt__.Printf("error recovery failed\n") - } - goto ret1 - - case 3: /* no shift yet; clobber input char */ - if yyDebug >= 2 { - __yyfmt__.Printf("error recovery discards %s\n", yySymName(yychar)) - } - if yychar == yyEOFCode { - goto ret1 - } - - yychar = -1 - goto yynewstate /* try again in the same state */ - } - } - - r := -yyn - x0 := yyReductions[r] - x, n := x0.xsym, x0.components - yypt := yyp - _ = yypt // guard against "declared and not used" - - yyp -= n - if yyp+1 >= len(yyS) { - nyys := make([]yySymType, len(yyS)*2) - copy(nyys, yyS) - yyS = nyys - } - yyVAL = yyS[yyp+1] - - /* consult goto table to find next state */ - exState := yystate - yystate = int(yyParseTab[yyS[yyp].yys][x]) + yyTabOfs - /* reduction by production r */ - if yyDebug >= 2 { - __yyfmt__.Printf("reduce using rule %v (%s), and goto state %d\n", r, yySymNames[x], yystate) - } - - switch r { - case 2: - { - yylex.(*lexer).expr = expr(yyS[yypt-0].item) - } - case 3: - { - yyVAL.item = &alterTableAddStmt{tableName: yyS[yypt-2].item.(string), c: yyS[yypt-0].item.(*col)} - } - case 4: - { - yyVAL.item = &alterTableDropColumnStmt{tableName: yyS[yypt-3].item.(string), colName: yyS[yypt-0].item.(string)} - } - case 5: - { - yyVAL.item = assignment{colName: yyS[yypt-2].item.(string), expr: expr(yyS[yypt-0].item)} - } - case 6: - { - yyVAL.item = append([]assignment{yyS[yypt-2].item.(assignment)}, yyS[yypt-1].item.([]assignment)...) - } - case 7: - { - yyVAL.item = []assignment{} - } - case 8: - { - yyVAL.item = append(yyS[yypt-2].item.([]assignment), yyS[yypt-0].item.(assignment)) - } - case 9: - { - yyVAL.item = beginTransactionStmt{} - } - case 10: - { - yyVAL.item = yyS[yypt-1].item - } - case 11: - { - yyVAL.item = '*' - } - case 12: - { - yyVAL.item = []expression{} - } - case 14: - { - x := &col{name: yyS[yypt-3].item.(string), typ: yyS[yypt-2].item.(int), constraint: yyS[yypt-1].item.(*constraint)} - if yyS[yypt-0].item != nil { - x.dflt = expr(yyS[yypt-0].item) - } - yyVAL.item = x - } - case 16: - { - yyVAL.item = append([]string{yyS[yypt-2].item.(string)}, yyS[yypt-1].item.([]string)...) - } - case 17: - { - yyVAL.item = []string{} - } - case 18: - { - yyVAL.item = append(yyS[yypt-2].item.([]string), yyS[yypt-0].item.(string)) - } - case 19: - { - yyVAL.item = commitStmt{} - } - case 20: - { - yyVAL.item = &constraint{} - } - case 21: - { - yyVAL.item = &constraint{expr(yyS[yypt-0].item)} - } - case 22: - { - yyVAL.item = (*constraint)(nil) - } - case 24: - { - yyVAL.item = &conversion{typ: yyS[yypt-3].item.(int), val: expr(yyS[yypt-1].item)} - } - case 25: - { - indexName, tableName, exprList := yyS[yypt-5].item.(string), yyS[yypt-3].item.(string), yyS[yypt-1].item.([]expression) - simpleIndex := len(exprList) == 1 - var columnName string - if simpleIndex { - expr := exprList[0] - switch x := expr.(type) { - case *ident: - columnName = x.s - case *call: - if x.f == "id" && len(x.arg) == 0 { - columnName = "id()" - break - } - - simpleIndex = false - default: - simpleIndex = false - } - } - - if !simpleIndex { - columnName = "" - } - yyVAL.item = &createIndexStmt{unique: yyS[yypt-8].item.(bool), ifNotExists: yyS[yypt-6].item.(bool), indexName: indexName, tableName: tableName, colName: columnName, exprList: exprList} - - if indexName == tableName || indexName == columnName { - yylex.(*lexer).err("index name collision: %s", indexName) - return 1 - } - - if yylex.(*lexer).root { - break - } - - if isSystemName[indexName] || isSystemName[tableName] { - yylex.(*lexer).err("name is used for system tables: %s", indexName) - return 1 - } - } - case 26: - { - yyVAL.item = false - } - case 27: - { - yyVAL.item = true - } - case 28: - { - yyVAL.item = false - } - case 29: - { - yyVAL.item = true - } - case 30: - { - nm := yyS[yypt-5].item.(string) - yyVAL.item = &createTableStmt{tableName: nm, cols: append([]*col{yyS[yypt-3].item.(*col)}, yyS[yypt-2].item.([]*col)...)} - - if yylex.(*lexer).root { - break - } - - if isSystemName[nm] { - yylex.(*lexer).err("name is used for system tables: %s", nm) - return 1 - } - } - case 31: - { - nm := yyS[yypt-5].item.(string) - yyVAL.item = &createTableStmt{ifNotExists: true, tableName: nm, cols: append([]*col{yyS[yypt-3].item.(*col)}, yyS[yypt-2].item.([]*col)...)} - - if yylex.(*lexer).root { - break - } - - if isSystemName[nm] { - yylex.(*lexer).err("name is used for system tables: %s", nm) - return 1 - } - } - case 32: - { - yyVAL.item = []*col{} - } - case 33: - { - yyVAL.item = append(yyS[yypt-2].item.([]*col), yyS[yypt-0].item.(*col)) - } - case 34: - { - yyVAL.item = yyS[yypt-0].item - } - case 35: - { - yyVAL.item = nil - } - case 37: - { - yyVAL.item = &truncateTableStmt{yyS[yypt-0].item.(string)} - - if yylex.(*lexer).root { - break - } - - if isSystemName[yyS[yypt-0].item.(string)] { - yylex.(*lexer).err("name is used for system tables: %s", yyS[yypt-0].item.(string)) - return 1 - } - } - case 38: - { - yyVAL.item = &deleteStmt{tableName: yyS[yypt-1].item.(string), where: yyS[yypt-0].item.(*whereRset).expr} - - if yylex.(*lexer).root { - break - } - - if isSystemName[yyS[yypt-1].item.(string)] { - yylex.(*lexer).err("name is used for system tables: %s", yyS[yypt-1].item.(string)) - return 1 - } - } - case 39: - { - yyVAL.item = &dropIndexStmt{ifExists: yyS[yypt-1].item.(bool), indexName: yyS[yypt-0].item.(string)} - } - case 40: - { - yyVAL.item = false - } - case 41: - { - yyVAL.item = true - } - case 42: - { - nm := yyS[yypt-0].item.(string) - yyVAL.item = &dropTableStmt{tableName: nm} - - if yylex.(*lexer).root { - break - } - - if isSystemName[nm] { - yylex.(*lexer).err("name is used for system tables: %s", nm) - return 1 - } - } - case 43: - { - nm := yyS[yypt-0].item.(string) - yyVAL.item = &dropTableStmt{ifExists: true, tableName: nm} - - if yylex.(*lexer).root { - break - } - - if isSystemName[nm] { - yylex.(*lexer).err("name is used for system tables: %s", nm) - return 1 - } - } - case 44: - { - yyVAL.item = nil - } - case 45: - { - yyVAL.item = &explainStmt{yyS[yypt-0].item.(stmt)} - } - case 47: - { - var err error - if yyVAL.item, err = newBinaryOperation(oror, yyS[yypt-2].item, yyS[yypt-0].item); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 50: - { - yyVAL.item = append([]expression{expr(yyS[yypt-2].item)}, yyS[yypt-1].item.([]expression)...) - } - case 51: - { - yyVAL.item = []expression(nil) - } - case 52: - { - yyVAL.item = append(yyS[yypt-2].item.([]expression), expr(yyS[yypt-0].item)) - } - case 54: - { - yyVAL.item = &pIn{expr: yyS[yypt-4].item.(expression), list: yyS[yypt-1].item.([]expression)} - } - case 55: - { - yyVAL.item = &pIn{expr: yyS[yypt-5].item.(expression), not: true, list: yyS[yypt-1].item.([]expression)} - } - case 56: - { - yyVAL.item = &pIn{expr: yyS[yypt-5].item.(expression), sel: yyS[yypt-2].item.(*selectStmt)} - } - case 57: - { - yyVAL.item = &pIn{expr: yyS[yypt-6].item.(expression), not: true, sel: yyS[yypt-2].item.(*selectStmt)} - } - case 58: - { - var err error - if yyVAL.item, err = newBetween(yyS[yypt-4].item, yyS[yypt-2].item, yyS[yypt-0].item, false); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 59: - { - var err error - if yyVAL.item, err = newBetween(yyS[yypt-5].item, yyS[yypt-2].item, yyS[yypt-0].item, true); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 60: - { - yyVAL.item = &isNull{expr: yyS[yypt-2].item.(expression)} - } - case 61: - { - yyVAL.item = &isNull{expr: yyS[yypt-3].item.(expression), not: true} - } - case 63: - { - var err error - if yyVAL.item, err = newBinaryOperation(ge, yyS[yypt-2].item, yyS[yypt-0].item); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 64: - { - var err error - if yyVAL.item, err = newBinaryOperation('>', yyS[yypt-2].item, yyS[yypt-0].item); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 65: - { - var err error - if yyVAL.item, err = newBinaryOperation(le, yyS[yypt-2].item, yyS[yypt-0].item); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 66: - { - var err error - if yyVAL.item, err = newBinaryOperation('<', yyS[yypt-2].item, yyS[yypt-0].item); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 67: - { - var err error - if yyVAL.item, err = newBinaryOperation(neq, yyS[yypt-2].item, yyS[yypt-0].item); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 68: - { - var err error - if yyVAL.item, err = newBinaryOperation(eq, yyS[yypt-2].item, yyS[yypt-0].item); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 69: - { - yyVAL.item = &pLike{expr: yyS[yypt-2].item.(expression), pattern: yyS[yypt-0].item.(expression)} - } - case 70: - { - expr, name := expr(yyS[yypt-1].item), yyS[yypt-0].item.(string) - if name == "" { - s, ok := expr.(*ident) - if ok { - name = s.s - } - } - yyVAL.item = &fld{expr: expr, name: name} - } - case 71: - { - yyVAL.item = "" - } - case 72: - { - yyVAL.item = yyS[yypt-0].item - } - case 73: - { - yyVAL.item = []*fld{yyS[yypt-0].item.(*fld)} - } - case 74: - { - l, f := yyS[yypt-2].item.([]*fld), yyS[yypt-0].item.(*fld) - if f.name != "" { - if f := findFld(l, f.name); f != nil { - yylex.(*lexer).err("duplicate field name %q", f.name) - return 1 - } - } - - yyVAL.item = append(yyS[yypt-2].item.([]*fld), yyS[yypt-0].item.(*fld)) - } - case 75: - { - yyVAL.item = &groupByRset{colNames: yyS[yypt-0].item.([]string)} - } - case 76: - { - yyVAL.item = yyS[yypt-1].item - } - case 77: - { - yyVAL.item = &insertIntoStmt{tableName: yyS[yypt-7].item.(string), colNames: yyS[yypt-6].item.([]string), lists: append([][]expression{yyS[yypt-3].item.([]expression)}, yyS[yypt-1].item.([][]expression)...)} - - if yylex.(*lexer).root { - break - } - - if isSystemName[yyS[yypt-7].item.(string)] { - yylex.(*lexer).err("name is used for system tables: %s", yyS[yypt-7].item.(string)) - return 1 - } - } - case 78: - { - yyVAL.item = &insertIntoStmt{tableName: yyS[yypt-2].item.(string), colNames: yyS[yypt-1].item.([]string), sel: yyS[yypt-0].item.(*selectStmt)} - } - case 79: - { - yyVAL.item = []string{} - } - case 80: - { - yyVAL.item = yyS[yypt-1].item - } - case 81: - { - yyVAL.item = [][]expression{} - } - case 82: - { - yyVAL.item = append(yyS[yypt-4].item.([][]expression), yyS[yypt-1].item.([]expression)) - } - case 90: - { - yyVAL.item = value{yyS[yypt-0].item} - } - case 91: - { - n := yyS[yypt-0].item.(int) - yyVAL.item = parameter{n} - l := yylex.(*lexer) - l.params = mathutil.Max(l.params, n) - if n == 0 { - l.err("parameter number must be non zero") - return 1 - } - } - case 92: - { - yyVAL.item = &ident{yyS[yypt-0].item.(string)} - } - case 93: - { - yyVAL.item = &pexpr{expr: expr(yyS[yypt-1].item)} - } - case 94: - { - yyVAL.item = &orderByRset{by: yyS[yypt-1].item.([]expression), asc: yyS[yypt-0].item.(bool)} - } - case 95: - { - yyVAL.item = true // ASC by default - } - case 96: - { - yyVAL.item = true - } - case 97: - { - yyVAL.item = false - } - case 100: - { - var err error - if yyVAL.item, err = newIndex(yyS[yypt-1].item.(expression), expr(yyS[yypt-0].item)); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 101: - { - var err error - s := yyS[yypt-0].item.([2]*expression) - if yyVAL.item, err = newSlice(yyS[yypt-1].item.(expression), s[0], s[1]); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 102: - { - x := yylex.(*lexer) - f, ok := yyS[yypt-1].item.(*ident) - if !ok { - x.err("expected identifier or qualified identifier") - return 1 - } - - if r, ok := yyS[yypt-0].item.(rune); ok { - if f.isQualified() || f.s != "count" || r != '*' { - x.err(fmt.Sprintf("invalid expression %s(%c)", f, r)) - return 1 - } - - yyS[yypt-0].item = []expression(nil) - } - - var err error - var agg bool - if yyVAL.item, agg, err = newCall(f.s, yyS[yypt-0].item.([]expression)); err != nil { - x.err("%v", err) - return 1 - } - if n := len(x.agg); n > 0 { - x.agg[n-1] = x.agg[n-1] || agg - } - } - case 104: - { - var err error - if yyVAL.item, err = newBinaryOperation('^', yyS[yypt-2].item, yyS[yypt-0].item); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 105: - { - var err error - if yyVAL.item, err = newBinaryOperation('|', yyS[yypt-2].item, yyS[yypt-0].item); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 106: - { - var err error - if yyVAL.item, err = newBinaryOperation('-', yyS[yypt-2].item, yyS[yypt-0].item); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 107: - { - var err error - yyVAL.item, err = newBinaryOperation('+', yyS[yypt-2].item, yyS[yypt-0].item) - if err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 109: - { - var err error - yyVAL.item, err = newBinaryOperation(andnot, yyS[yypt-2].item, yyS[yypt-0].item) - if err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 110: - { - var err error - yyVAL.item, err = newBinaryOperation('&', yyS[yypt-2].item, yyS[yypt-0].item) - if err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 111: - { - var err error - yyVAL.item, err = newBinaryOperation(lsh, yyS[yypt-2].item, yyS[yypt-0].item) - if err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 112: - { - var err error - yyVAL.item, err = newBinaryOperation(rsh, yyS[yypt-2].item, yyS[yypt-0].item) - if err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 113: - { - var err error - yyVAL.item, err = newBinaryOperation('%', yyS[yypt-2].item, yyS[yypt-0].item) - if err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 114: - { - var err error - yyVAL.item, err = newBinaryOperation('/', yyS[yypt-2].item, yyS[yypt-0].item) - if err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 115: - { - var err error - yyVAL.item, err = newBinaryOperation('*', yyS[yypt-2].item, yyS[yypt-0].item) - if err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 117: - { - yyVAL.item = fmt.Sprintf("%s.%s", yyS[yypt-2].item.(string), yyS[yypt-0].item.(string)) - } - case 118: - { - yyVAL.item = []interface{}{yyS[yypt-1].item, yyS[yypt-0].item} - } - case 120: - { - yyVAL.item = yyS[yypt-2].item - } - case 123: - { - yyVAL.item = "" - } - case 124: - { - yyVAL.item = yyS[yypt-0].item - } - case 125: - { - yyVAL.list = []interface{}{yyS[yypt-0].item} - } - case 126: - { - yyVAL.list = append(yyS[yypt-2].list, yyS[yypt-0].item) - } - case 127: - { - yyVAL.item = rollbackStmt{} - } - case 128: - { - yyVAL.item = leftJoin - } - case 129: - { - yyVAL.item = rightJoin - } - case 130: - { - yyVAL.item = fullJoin - } - case 131: - { - yyVAL.item = nil - } - case 133: - { - yyVAL.item = []interface{}{yyS[yypt-5].item, yyS[yypt-2].item, yyS[yypt-0].item} - } - case 134: - { - yyVAL.item = nil - } - case 136: - { - x := yylex.(*lexer) - n := len(x.agg) - join := &joinRset{sources: yyS[yypt-7].list} - if o := yyS[yypt-5].item; o != nil { - o := o.([]interface{}) - join.typ = o[0].(int) - join.sources = append(join.sources, o[1].([]interface{})) - join.on = o[2].(expression) - } - yyVAL.item = &selectStmt{ - distinct: yyS[yypt-10].item.(bool), - flds: yyS[yypt-9].item.([]*fld), - from: join, - hasAggregates: x.agg[n-1], - where: yyS[yypt-4].item.(*whereRset), - group: yyS[yypt-3].item.(*groupByRset), - order: yyS[yypt-2].item.(*orderByRset), - limit: yyS[yypt-1].item.(*limitRset), - offset: yyS[yypt-0].item.(*offsetRset), - } - x.agg = x.agg[:n-1] - } - case 137: - { - yyVAL.item = (*limitRset)(nil) - } - case 138: - { - yyVAL.item = &limitRset{expr: expr(yyS[yypt-0].item)} - } - case 139: - { - yyVAL.item = (*offsetRset)(nil) - } - case 140: - { - yyVAL.item = &offsetRset{expr: expr(yyS[yypt-0].item)} - } - case 141: - { - yyVAL.item = false - } - case 142: - { - yyVAL.item = true - } - case 143: - { - yyVAL.item = []*fld{} - } - case 144: - { - yyVAL.item = yyS[yypt-0].item - } - case 145: - { - yyVAL.item = yyS[yypt-1].item - } - case 146: - { - yyVAL.item = (*whereRset)(nil) - } - case 148: - { - yyVAL.item = (*groupByRset)(nil) - } - case 150: - { - yyVAL.item = (*orderByRset)(nil) - } - case 152: - { - yyVAL.item = [2]*expression{nil, nil} - } - case 153: - { - hi := expr(yyS[yypt-1].item) - yyVAL.item = [2]*expression{nil, &hi} - } - case 154: - { - lo := expr(yyS[yypt-2].item) - yyVAL.item = [2]*expression{&lo, nil} - } - case 155: - { - lo := expr(yyS[yypt-3].item) - hi := expr(yyS[yypt-1].item) - yyVAL.item = [2]*expression{&lo, &hi} - } - case 171: - { - if yyS[yypt-0].item != nil { - yylex.(*lexer).list = []stmt{yyS[yypt-0].item.(stmt)} - } - } - case 172: - { - if yyS[yypt-0].item != nil { - yylex.(*lexer).list = append(yylex.(*lexer).list, yyS[yypt-0].item.(stmt)) - } - } - case 175: - { - var err error - if yyVAL.item, err = newBinaryOperation(andand, yyS[yypt-2].item, yyS[yypt-0].item); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 178: - { - yyVAL.item = &truncateTableStmt{tableName: yyS[yypt-0].item.(string)} - } - case 203: - { - var expr expression - if w := yyS[yypt-0].item; w != nil { - expr = w.(*whereRset).expr - } - yyVAL.item = &updateStmt{tableName: yyS[yypt-3].item.(string), list: yyS[yypt-1].item.([]assignment), where: expr} - - if yylex.(*lexer).root { - break - } - - if isSystemName[yyS[yypt-3].item.(string)] { - yylex.(*lexer).err("name is used for system tables: %s", yyS[yypt-3].item.(string)) - return 1 - } - } - case 204: - { - yyVAL.item = nil - } - case 207: - { - var err error - yyVAL.item, err = newUnaryOperation('^', yyS[yypt-0].item) - if err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 208: - { - var err error - yyVAL.item, err = newUnaryOperation('!', yyS[yypt-0].item) - if err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 209: - { - var err error - yyVAL.item, err = newUnaryOperation('-', yyS[yypt-0].item) - if err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 210: - { - var err error - yyVAL.item, err = newUnaryOperation('+', yyS[yypt-0].item) - if err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - case 211: - { - yyVAL.item = &whereRset{expr: expr(yyS[yypt-0].item)} - } - - } - - if yyEx != nil && yyEx.Reduced(r, exState, &yyVAL) { - return -1 - } - goto yystack /* stack new state and value */ -} - -func expr(v interface{}) expression { - e := v.(expression) - for { - x, ok := e.(*pexpr) - if !ok { - return e - } - e = x.expr - } -} diff --git a/Godeps/_workspace/src/github.com/cznic/ql/parser.y b/Godeps/_workspace/src/github.com/cznic/ql/parser.y deleted file mode 100644 index 979c3289aa..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/parser.y +++ /dev/null @@ -1,1337 +0,0 @@ -%{ -// Copyright (c) 2014 The ql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Inital yacc source generated by ebnf2y[1] -// at 2013-10-04 23:10:47.861401015 +0200 CEST -// -// $ ebnf2y -o ql.y -oe ql.ebnf -start StatementList -pkg ql -p _ -// -// [1]: http://github.com/cznic/ebnf2y - -package ql - -import ( - "fmt" - - "github.com/cznic/mathutil" -) - -%} - -%union { - line int - col int - item interface{} - list []interface{} -} - -%token - - /*yy:token "1.%d" */ floatLit "floating-point literal" - /*yy:token "%c" */ identifier "identifier" - /*yy:token "%di" */ imaginaryLit "imaginary literal" - /*yy:token "%d" */ intLit "integer literal" - /*yy:token "$%d" */ qlParam "QL parameter" - /*yy:token "\"%c\"" */ stringLit "string literal" - - add "ADD" - alter "ALTER" - and "AND" - andand "&&" - andnot "&^" - as "AS" - asc "ASC" - begin "BEGIN" - between "BETWEEN" - bigIntType "bigint" - bigRatType "bigrat" - blobType "blob" - boolType "bool" - by "BY" - byteType "byte" - column "COLUMN" - commit "COMMIT" - complex128Type "complex128" - complex64Type "complex64" - create "CREATE" - defaultKwd "DEFAULT" - deleteKwd "DELETE" - desc "DESC" - distinct "DISTINCT" - drop "DROP" - durationType "duration" - eq "==" - exists "EXISTS" - explain "EXPLAIN" - falseKwd "false" - floatType "float" - float32Type "float32" - float64Type "float64" - from "FROM" - full "FULL" - ge ">=" - group "GROUP" - ifKwd "IF" - in "IN" - index "INDEX" - insert "INSERT" - intType "int" - int16Type "int16" - int32Type "int32" - int64Type "int64" - int8Type "int8" - into "INTO" - is "IS" - join "JOIN" - le "<=" - left "LEFT" - like "LIKE" - limit "LIMIT" - lsh "<<" - neq "!=" - not "NOT" - null "NULL" - offset "OFFSET" - on "ON" - or "OR" - order "ORDER" - oror "||" - outer "OUTER" - right "RIGHT" - rollback "ROLLBACK" - rsh ">>" - runeType "rune" - selectKwd "SELECT" - set "SET" - stringType "string" - tableKwd "TABLE" - timeType "time" - transaction "TRANSACTION" - trueKwd "true" - truncate "TRUNCATE" - uintType "uint" - uint16Type "uint16" - uint32Type "uint32" - uint64Type "uint64" - uint8Type "uint8", - unique "UNIQUE" - update "UPDATE" - values "VALUES" - where "WHERE" - - parseExpression "parse expression prefix" - -%type - AlterTableStmt "ALTER TABLE statement" - Assignment "assignment" - AssignmentList "assignment list" - AssignmentList1 "assignment list optional trailing comma" - BeginTransactionStmt "BEGIN TRANSACTION statement" - Call "function call" - Call1 "function call optional argument list" - ColumnDef "table column definition" - ColumnName "column name" - ColumnNameList "column name list" - ColumnNameList1 "column name list with optional trailing comma" - CommaOpt "optional comma" - CommitStmt "COMMIT statement" - Constraint "column value constraint" - ConstraintOpt "optional column value constraint" - Conversion "conversion" - CreateIndexStmt "CREATE INDEX statement" - CreateIndexIfNotExists "CREATE INDEX statement optional IF NOT EXISTS cluse" - CreateIndexStmtUnique "CREATE INDEX optional UNIQUE clause" - CreateTableStmt "CREATE TABLE statement" - CreateTableStmt1 "CREATE TABLE statement colum definition list" - Default "DEFAULT clause" - DefaultOpt "optional DEFAULT clause" - DeleteFromStmt "DELETE FROM statement" - DropIndexStmt "DROP INDEX statement" - DropIndexIfExists "DROP INDEX statement optional IF EXISTS clause" - DropTableStmt "DROP TABLE statement" - EmptyStmt "empty statement" - ExplainStmt "EXPLAIN statement" - Expression "expression" - ExpressionList "expression list" - ExpressionList1 "expression list expression" - Factor "expression factor" - Factor1 "binary expression factor" - Field "field expression" - Field1 "field expression optional AS clause" - FieldList "field expression list" - GroupByClause "GROUP BY clause" - Index "string index" - InsertIntoStmt "INSERT INTO statement" - InsertIntoStmt1 "INSERT INTO statement optional column list clause" - InsertIntoStmt2 "INSERT INTO statement optional values list" - JoinClause "SELECT statement JOIN clause" - JoinClauseOpt "SELECT statement optional JOIN clause" - JoinType "join type" - Literal "literal value" - logAnd "logical and operator" - logOr "logical or operator" - Operand "operand" - OrderBy "ORDER BY clause" - OrderBy1 "ORDER BY clause optional collation specification" - OuterOpt "optional OUTER clause" - QualifiedIdent "qualified identifier" - PrimaryExpression "primary expression" - PrimaryFactor "primary expression factor" - PrimaryTerm "primary expression term" - RecordSet "record set" - RecordSet1 "record set name or parenthesized SELECTECT statement" - RecordSet2 "record set optional AS clause" - RollbackStmt "ROLLBACK statement" - SelectStmt "SELECT statement" - SelectStmtDistinct "SELECT statement optional DISTINCT clause" - SelectStmtFieldList "SELECT statement field list" - SelectStmtLimit "SELECT statement optional LIMIT clause" - SelectStmtWhere "SELECT statement optional WHERE clause" - SelectStmtGroup "SELECT statement optional GROUP BY clause" - SelectStmtOffset "SELECT statement optional OFFSET clause" - SelectStmtOrder "SELECT statement optional ORDER BY clause" - Slice "string slice" - Statement "statement" - StatementList "statement list" - TableName "table name" - Term "expression term" - TruncateTableStmt "TRANSACTION TABLE statement" - Type "type" - UnaryExpr "unary expression" - UpdateStmt "UPDATE statement" - UpdateStmt1 "UPDATE statement optional WHERE clause" - WhereClause "WHERE clause" - -%type RecordSetList - -%start Start - -%% - -Start: - StatementList -| parseExpression Expression - { - yylex.(*lexer).expr = expr($2) - } - -AlterTableStmt: - "ALTER" "TABLE" TableName "ADD" ColumnDef - { - $$ = &alterTableAddStmt{tableName: $3.(string), c: $5.(*col)} - } -| "ALTER" "TABLE" TableName "DROP" "COLUMN" ColumnName - { - $$ = &alterTableDropColumnStmt{tableName: $3.(string), colName: $6.(string)} - } - -Assignment: - ColumnName '=' Expression - { - $$ = assignment{colName: $1.(string), expr: expr($3)} - } - -AssignmentList: - Assignment AssignmentList1 CommaOpt - { - $$ = append([]assignment{$1.(assignment)}, $2.([]assignment)...) - } - -AssignmentList1: - /* EMPTY */ - { - $$ = []assignment{} - } -| AssignmentList1 ',' Assignment - { - $$ = append($1.([]assignment), $3.(assignment)) - } - -BeginTransactionStmt: - "BEGIN" "TRANSACTION" - { - $$ = beginTransactionStmt{} - } - -Call: - '(' Call1 ')' - { - $$ = $2 - } -| '(' '*' ')' - { - $$ = '*' - } - -Call1: - /* EMPTY */ - { - $$ = []expression{} - } -| ExpressionList - -ColumnDef: - ColumnName Type ConstraintOpt DefaultOpt - { - x := &col{name: $1.(string), typ: $2.(int), constraint: $3.(*constraint)} - if $4 != nil { - x.dflt = expr($4) - } - $$ = x - } - -ColumnName: - identifier - -ColumnNameList: - ColumnName ColumnNameList1 CommaOpt - { - $$ = append([]string{$1.(string)}, $2.([]string)...) - } - -ColumnNameList1: - /* EMPTY */ - { - $$ = []string{} - } -| ColumnNameList1 ',' ColumnName - { - $$ = append($1.([]string), $3.(string)) - } - -CommitStmt: - "COMMIT" - { - $$ = commitStmt{} - } - -Constraint: - "NOT" "NULL" - { - $$ = &constraint{} - } -| Expression - { - $$ = &constraint{expr($1)} - } - -ConstraintOpt: - { - $$ = (*constraint)(nil) - } -| Constraint - -Conversion: - Type '(' Expression ')' - { - $$ = &conversion{typ: $1.(int), val: expr($3)} - } - -CreateIndexStmt: - "CREATE" CreateIndexStmtUnique "INDEX" CreateIndexIfNotExists identifier "ON" identifier '(' ExpressionList ')' - { - indexName, tableName, exprList := $5.(string), $7.(string), $9.([]expression) - simpleIndex := len(exprList) == 1 - var columnName string - if simpleIndex { - expr := exprList[0] - switch x := expr.(type) { - case *ident: - columnName = x.s - case *call: - if x.f == "id" && len(x.arg) == 0 { - columnName = "id()" - break - } - - simpleIndex = false - default: - simpleIndex = false - } - } - - if !simpleIndex { - columnName = "" - } - $$ = &createIndexStmt{unique: $2.(bool), ifNotExists: $4.(bool), indexName: indexName, tableName: tableName, colName: columnName, exprList: exprList} - - if indexName == tableName || indexName == columnName { - yylex.(*lexer).err("index name collision: %s", indexName) - return 1 - } - - if yylex.(*lexer).root { - break - } - - if isSystemName[indexName] || isSystemName[tableName] { - yylex.(*lexer).err("name is used for system tables: %s", indexName) - return 1 - } - } - -CreateIndexIfNotExists: - { - $$ = false - } -| "IF" "NOT" "EXISTS" - { - $$ = true - } - -CreateIndexStmtUnique: - { - $$ = false - } -| "UNIQUE" - { - $$ = true - } - -CreateTableStmt: - "CREATE" "TABLE" TableName '(' ColumnDef CreateTableStmt1 CommaOpt ')' - { - nm := $3.(string) - $$ = &createTableStmt{tableName: nm, cols: append([]*col{$5.(*col)}, $6.([]*col)...)} - - if yylex.(*lexer).root { - break - } - - if isSystemName[nm] { - yylex.(*lexer).err("name is used for system tables: %s", nm) - return 1 - } - } -| "CREATE" "TABLE" "IF" "NOT" "EXISTS" TableName '(' ColumnDef CreateTableStmt1 CommaOpt ')' - { - nm := $6.(string) - $$ = &createTableStmt{ifNotExists: true, tableName: nm, cols: append([]*col{$8.(*col)}, $9.([]*col)...)} - - if yylex.(*lexer).root { - break - } - - if isSystemName[nm] { - yylex.(*lexer).err("name is used for system tables: %s", nm) - return 1 - } - } - -CreateTableStmt1: - /* EMPTY */ - { - $$ = []*col{} - } -| CreateTableStmt1 ',' ColumnDef - { - $$ = append($1.([]*col), $3.(*col)) - } - -Default: - "DEFAULT" Expression - { - $$ = $2 - } - -DefaultOpt: - { - $$ = nil - } -| Default - -DeleteFromStmt: - "DELETE" "FROM" TableName - { - $$ = &truncateTableStmt{$3.(string)} - - if yylex.(*lexer).root { - break - } - - if isSystemName[$3.(string)] { - yylex.(*lexer).err("name is used for system tables: %s", $3.(string)) - return 1 - } - } -| "DELETE" "FROM" TableName WhereClause - { - $$ = &deleteStmt{tableName: $3.(string), where: $4.(*whereRset).expr} - - if yylex.(*lexer).root { - break - } - - if isSystemName[$3.(string)] { - yylex.(*lexer).err("name is used for system tables: %s", $3.(string)) - return 1 - } - } - -DropIndexStmt: - "DROP" "INDEX" DropIndexIfExists identifier - { - $$ = &dropIndexStmt{ifExists: $3.(bool), indexName: $4.(string)} - } - -DropIndexIfExists: - { - $$ = false - } -| "IF" "EXISTS" - { - $$ = true - } - -DropTableStmt: - "DROP" "TABLE" TableName - { - nm := $3.(string) - $$ = &dropTableStmt{tableName: nm} - - if yylex.(*lexer).root { - break - } - - if isSystemName[nm] { - yylex.(*lexer).err("name is used for system tables: %s", nm) - return 1 - } - } -| "DROP" "TABLE" "IF" "EXISTS" TableName - { - nm := $5.(string) - $$ = &dropTableStmt{ifExists: true, tableName: nm} - - if yylex.(*lexer).root { - break - } - - if isSystemName[nm] { - yylex.(*lexer).err("name is used for system tables: %s", nm) - return 1 - } - } - -EmptyStmt: - /* EMPTY */ - { - $$ = nil - } - -ExplainStmt: - "EXPLAIN" Statement - { - $$ = &explainStmt{$2.(stmt)} - } - -Expression: - Term -| Expression logOr Term - { - var err error - if $$, err = newBinaryOperation(oror, $1, $3); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - -logOr: - "||" - { - } -| "OR" - { - } - -ExpressionList: - Expression ExpressionList1 CommaOpt - { - $$ = append([]expression{expr($1)}, $2.([]expression)...) - } - -ExpressionList1: - /* EMPTY */ - { - $$ = []expression(nil) - } -| ExpressionList1 ',' Expression - { - $$ = append($1.([]expression), expr($3)) - } - -Factor: - Factor1 -| Factor1 "IN" '(' ExpressionList ')' - { - $$ = &pIn{expr: $1.(expression), list: $4.([]expression)} - } -| Factor1 "NOT" "IN" '(' ExpressionList ')' - { - $$ = &pIn{expr: $1.(expression), not: true, list: $5.([]expression)} - } -| Factor1 "IN" '(' SelectStmt semiOpt ')' - { - $$ = &pIn{expr: $1.(expression), sel: $4.(*selectStmt)} - } -| Factor1 "NOT" "IN" '(' SelectStmt semiOpt ')' - { - $$ = &pIn{expr: $1.(expression), not: true, sel: $5.(*selectStmt)} - } -| Factor1 "BETWEEN" PrimaryFactor "AND" PrimaryFactor - { - var err error - if $$, err = newBetween($1, $3, $5, false); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } -| Factor1 "NOT" "BETWEEN" PrimaryFactor "AND" PrimaryFactor - { - var err error - if $$, err = newBetween($1, $4, $6, true); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } -| Factor1 "IS" "NULL" - { - $$ = &isNull{expr: $1.(expression)} - } -| Factor1 "IS" "NOT" "NULL" - { - $$ = &isNull{expr: $1.(expression), not: true} - } - -Factor1: - PrimaryFactor -| Factor1 ">=" PrimaryFactor - { - var err error - if $$, err = newBinaryOperation(ge, $1, $3); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } -| Factor1 '>' PrimaryFactor - { - var err error - if $$, err = newBinaryOperation('>', $1, $3); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } -| Factor1 "<=" PrimaryFactor - { - var err error - if $$, err = newBinaryOperation(le, $1, $3); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } -| Factor1 '<' PrimaryFactor - { - var err error - if $$, err = newBinaryOperation('<', $1, $3); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } -| Factor1 "!=" PrimaryFactor - { - var err error - if $$, err = newBinaryOperation(neq, $1, $3); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } -| Factor1 "==" PrimaryFactor - { - var err error - if $$, err = newBinaryOperation(eq, $1, $3); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } -| Factor1 "LIKE" PrimaryFactor - { - $$ = &pLike{expr: $1.(expression), pattern: $3.(expression)} - } - -Field: - Expression Field1 - { - expr, name := expr($1), $2.(string) - if name == "" { - s, ok := expr.(*ident) - if ok { - name = s.s - } - } - $$ = &fld{expr: expr, name: name} - } - -Field1: - /* EMPTY */ - { - $$ = "" - } -| "AS" identifier - { - $$ = $2 - } - -FieldList: - Field - { - $$ = []*fld{$1.(*fld)} - } -| FieldList ',' Field - { - l, f := $1.([]*fld), $3.(*fld) - if f.name != "" { - if f := findFld(l, f.name); f != nil { - yylex.(*lexer).err("duplicate field name %q", f.name) - return 1 - } - } - - $$ = append($1.([]*fld), $3.(*fld)) - } - -GroupByClause: - "GROUP" "BY" ColumnNameList - { - $$ = &groupByRset{colNames: $3.([]string)} - } - -Index: - '[' Expression ']' - { - $$ = $2 - } - -InsertIntoStmt: - "INSERT" "INTO" TableName InsertIntoStmt1 "VALUES" '(' ExpressionList ')' InsertIntoStmt2 CommaOpt - { - $$ = &insertIntoStmt{tableName: $3.(string), colNames: $4.([]string), lists: append([][]expression{$7.([]expression)}, $9.([][]expression)...)} - - if yylex.(*lexer).root { - break - } - - if isSystemName[$3.(string)] { - yylex.(*lexer).err("name is used for system tables: %s", $3.(string)) - return 1 - } - } -| "INSERT" "INTO" TableName InsertIntoStmt1 SelectStmt - { - $$ = &insertIntoStmt{tableName: $3.(string), colNames: $4.([]string), sel: $5.(*selectStmt)} - } - -InsertIntoStmt1: - /* EMPTY */ - { - $$ = []string{} - } -| '(' ColumnNameList ')' - { - $$ = $2 - } - -InsertIntoStmt2: - /* EMPTY */ - { - $$ = [][]expression{} - } -| InsertIntoStmt2 ',' '(' ExpressionList ')' - { - $$ = append($1.([][]expression), $4.([]expression)) - } - -Literal: - "false" -| "NULL" -| "true" -| floatLit -| imaginaryLit -| intLit -| stringLit - -Operand: - Literal - { - $$ = value{$1} - } -| qlParam - { - n := $1.(int) - $$ = parameter{n} - l := yylex.(*lexer) - l.params = mathutil.Max(l.params, n) - if n == 0 { - l.err("parameter number must be non zero") - return 1 - } - } -| QualifiedIdent - { - $$ = &ident{$1.(string)} - } -| '(' Expression ')' - { - $$ = &pexpr{expr: expr($2)} - } - -OrderBy: - "ORDER" "BY" ExpressionList OrderBy1 - { - $$ = &orderByRset{by: $3.([]expression), asc: $4.(bool)} - } - -OrderBy1: - /* EMPTY */ - { - $$ = true // ASC by default - } -| "ASC" - { - $$ = true - } -| "DESC" - { - $$ = false - } - -PrimaryExpression: - Operand -| Conversion -| PrimaryExpression Index - { - var err error - if $$, err = newIndex($1.(expression), expr($2)); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } -| PrimaryExpression Slice - { - var err error - s := $2.([2]*expression) - if $$, err = newSlice($1.(expression), s[0], s[1]); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } -| PrimaryExpression Call - { - x := yylex.(*lexer) - f, ok := $1.(*ident) - if !ok { - x.err("expected identifier or qualified identifier") - return 1 - } - - if r, ok := $2.(rune); ok { - if f.isQualified() || f.s != "count" || r != '*' { - x.err(fmt.Sprintf("invalid expression %s(%c)", f, r)) - return 1 - } - - $2 = []expression(nil) - } - - var err error - var agg bool - if $$, agg, err = newCall(f.s, $2.([]expression)); err != nil { - x.err("%v", err) - return 1 - } - if n := len(x.agg); n > 0 { - x.agg[n-1] = x.agg[n-1] || agg - } - } - -PrimaryFactor: - PrimaryTerm -| PrimaryFactor '^' PrimaryTerm - { - var err error - if $$, err = newBinaryOperation('^', $1, $3); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } -| PrimaryFactor '|' PrimaryTerm - { - var err error - if $$, err = newBinaryOperation('|', $1, $3); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } -| PrimaryFactor '-' PrimaryTerm - { - var err error - if $$, err = newBinaryOperation('-', $1, $3); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } -| PrimaryFactor '+' PrimaryTerm - { - var err error - $$, err = newBinaryOperation('+', $1, $3) - if err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - -PrimaryTerm: - UnaryExpr -| PrimaryTerm "&^" UnaryExpr - { - var err error - $$, err = newBinaryOperation(andnot, $1, $3) - if err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } -| PrimaryTerm '&' UnaryExpr - { - var err error - $$, err = newBinaryOperation('&', $1, $3) - if err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } -| PrimaryTerm "<<" UnaryExpr - { - var err error - $$, err = newBinaryOperation(lsh, $1, $3) - if err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } -| PrimaryTerm ">>" UnaryExpr - { - var err error - $$, err = newBinaryOperation(rsh, $1, $3) - if err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } -| PrimaryTerm '%' UnaryExpr - { - var err error - $$, err = newBinaryOperation('%', $1, $3) - if err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } -| PrimaryTerm '/' UnaryExpr - { - var err error - $$, err = newBinaryOperation('/', $1, $3) - if err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } -| PrimaryTerm '*' UnaryExpr - { - var err error - $$, err = newBinaryOperation('*', $1, $3) - if err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - -QualifiedIdent: - identifier -| identifier '.' identifier - { - $$ = fmt.Sprintf("%s.%s", $1.(string), $3.(string)) - } - -RecordSet: - RecordSet1 RecordSet2 - { - $$ = []interface{}{$1, $2} - } - -RecordSet1: - identifier -| '(' SelectStmt semiOpt ')' - { - $$ = $2 - } - -semiOpt: - /* EMPTY */ -| ';' - -RecordSet2: - /* EMPTY */ - { - $$ = "" - } -| "AS" identifier - { - $$ = $2 - } - -RecordSetList: - RecordSet - { - $$ = []interface{}{$1} - } -| RecordSetList ',' RecordSet - { - $$ = append($1, $3) - } - -RollbackStmt: - "ROLLBACK" - { - $$ = rollbackStmt{} - } - -JoinType: - "LEFT" - { - $$ = leftJoin - } -| "RIGHT" - { - $$ = rightJoin - } -| "FULL" - { - $$ = fullJoin - } - -OuterOpt: - { - $$ = nil - } -| "OUTER" - -JoinClause: - JoinType OuterOpt "JOIN" RecordSet "ON" Expression - { - $$ = []interface{}{$1, $4, $6} - } - -JoinClauseOpt: - { - $$ = nil - } -| JoinClause - -SelectStmt: - "SELECT" SelectStmtDistinct SelectStmtFieldList "FROM" RecordSetList - CommaOpt JoinClauseOpt SelectStmtWhere SelectStmtGroup SelectStmtOrder - SelectStmtLimit SelectStmtOffset - { - x := yylex.(*lexer) - n := len(x.agg) - join := &joinRset{sources: $5} - if o := $7; o != nil { - o := o.([]interface{}) - join.typ = o[0].(int) - join.sources = append(join.sources, o[1].([]interface{})) - join.on = o[2].(expression) - } - $$ = &selectStmt{ - distinct: $2.(bool), - flds: $3.([]*fld), - from: join, - hasAggregates: x.agg[n-1], - where: $8.(*whereRset), - group: $9.(*groupByRset), - order: $10.(*orderByRset), - limit: $11.(*limitRset), - offset: $12.(*offsetRset), - } - x.agg = x.agg[:n-1] - } - -SelectStmtLimit: - { - $$ = (*limitRset)(nil) - } -| "LIMIT" Expression - { - $$ = &limitRset{expr: expr($2)} - } - -SelectStmtOffset: - { - $$ = (*offsetRset)(nil) - } -| "OFFSET" Expression - { - $$ = &offsetRset{expr: expr($2)} - } - -SelectStmtDistinct: - /* EMPTY */ - { - $$ = false - } -| "DISTINCT" - { - $$ = true - } - -SelectStmtFieldList: - '*' - { - $$ = []*fld{} - } -| FieldList - { - $$ = $1 - } -| FieldList ',' - { - $$ = $1 - } - -SelectStmtWhere: - /* EMPTY */ - { - $$ = (*whereRset)(nil) - } -| WhereClause - -SelectStmtGroup: - /* EMPTY */ - { - $$ = (*groupByRset)(nil) - } -| GroupByClause - -SelectStmtOrder: - /* EMPTY */ - { - $$ = (*orderByRset)(nil) - } -| OrderBy - -Slice: - '[' ':' ']' - { - $$ = [2]*expression{nil, nil} - } -| '[' ':' Expression ']' - { - hi := expr($3) - $$ = [2]*expression{nil, &hi} - } -| '[' Expression ':' ']' - { - lo := expr($2) - $$ = [2]*expression{&lo, nil} - } -| '[' Expression ':' Expression ']' - { - lo := expr($2) - hi := expr($4) - $$ = [2]*expression{&lo, &hi} - } - -Statement: - EmptyStmt -| AlterTableStmt -| BeginTransactionStmt -| CommitStmt -| CreateIndexStmt -| CreateTableStmt -| DeleteFromStmt -| DropIndexStmt -| DropTableStmt -| ExplainStmt -| InsertIntoStmt -| RollbackStmt -| SelectStmt -| TruncateTableStmt -| UpdateStmt - -StatementList: - Statement - { - if $1 != nil { - yylex.(*lexer).list = []stmt{$1.(stmt)} - } - } -| StatementList ';' Statement - { - if $3 != nil { - yylex.(*lexer).list = append(yylex.(*lexer).list, $3.(stmt)) - } - } - -TableName: - identifier - -Term: - Factor -| Term logAnd Factor - { - var err error - if $$, err = newBinaryOperation(andand, $1, $3); err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - -logAnd: - "&&" - { - } -| "AND" - { - } - -TruncateTableStmt: - "TRUNCATE" "TABLE" TableName - { - $$ = &truncateTableStmt{tableName: $3.(string)} - } - -Type: - "bigint" -| "bigrat" -| "blob" -| "bool" -| "byte" -| "complex128" -| "complex64" -| "duration" -| "float" -| "float32" -| "float64" -| "int" -| "int16" -| "int32" -| "int64" -| "int8" -| "rune" -| "string" -| "time" -| "uint" -| "uint16" -| "uint32" -| "uint64" -| "uint8" - -UpdateStmt: - "UPDATE" TableName SetOpt AssignmentList UpdateStmt1 - { - var expr expression - if w := $5; w != nil { - expr = w.(*whereRset).expr - } - $$ = &updateStmt{tableName: $2.(string), list: $4.([]assignment), where: expr} - - if yylex.(*lexer).root { - break - } - - if isSystemName[$2.(string)] { - yylex.(*lexer).err("name is used for system tables: %s", $2.(string)) - return 1 - } - } - -UpdateStmt1: - /* EMPTY */ - { - $$ = nil - } -| WhereClause - -UnaryExpr: - PrimaryExpression -| '^' PrimaryExpression - { - var err error - $$, err = newUnaryOperation('^', $2) - if err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } -| '!' PrimaryExpression - { - var err error - $$, err = newUnaryOperation('!', $2) - if err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } -| '-' PrimaryExpression - { - var err error - $$, err = newUnaryOperation('-', $2) - if err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } -| '+' PrimaryExpression - { - var err error - $$, err = newUnaryOperation('+', $2) - if err != nil { - yylex.(*lexer).err("%v", err) - return 1 - } - } - -WhereClause: - "WHERE" Expression - { - $$ = &whereRset{expr: expr($2)} - } - - -SetOpt: - { - } -| "SET" - { - } - -CommaOpt: - { - } -| ',' - { - } - -%% - -func expr(v interface{}) expression { - e := v.(expression) - for { - x, ok := e.(*pexpr) - if !ok { - return e - } - e = x.expr - } -} diff --git a/Godeps/_workspace/src/github.com/cznic/ql/plan.go b/Godeps/_workspace/src/github.com/cznic/ql/plan.go deleted file mode 100644 index be52b72c6a..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/plan.go +++ /dev/null @@ -1,2800 +0,0 @@ -// Copyright 2015 The ql 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 ql - -import ( - "bytes" - "fmt" - "strings" - - "github.com/cznic/b" - "github.com/cznic/strutil" -) - -const ( - _ = iota - indexEq // [L] - indexFalse // [false] - indexGe // [L, ...) - indexGt // (L, ...) - indexIsNotNull // (NULL, ...) - indexIsNull // [NULL] - indexIntervalCC // [L, H] - indexIntervalCO // [L, H) - indexIntervalOC // (L, H] - indexIntervalOO // (L, H) - indexLe // (..., H] - indexLt // (..., H) - indexNe // (L) - indexTrue // [true] -) - -// Note: All plans must have a pointer receiver. Enables planA == planB operation. -var ( - _ plan = (*crossJoinDefaultPlan)(nil) - _ plan = (*distinctDefaultPlan)(nil) - _ plan = (*explainDefaultPlan)(nil) - _ plan = (*filterDefaultPlan)(nil) - _ plan = (*fullJoinDefaultPlan)(nil) - _ plan = (*groupByDefaultPlan)(nil) - _ plan = (*indexPlan)(nil) - _ plan = (*leftJoinDefaultPlan)(nil) - _ plan = (*limitDefaultPlan)(nil) - _ plan = (*nullPlan)(nil) - _ plan = (*offsetDefaultPlan)(nil) - _ plan = (*orderByDefaultPlan)(nil) - _ plan = (*rightJoinDefaultPlan)(nil) - _ plan = (*selectFieldsDefaultPlan)(nil) - _ plan = (*selectFieldsGroupPlan)(nil) - _ plan = (*selectIndexDefaultPlan)(nil) - _ plan = (*sysColumnDefaultPlan)(nil) - _ plan = (*sysIndexDefaultPlan)(nil) - _ plan = (*sysTableDefaultPlan)(nil) - _ plan = (*tableDefaultPlan)(nil) - _ plan = (*tableNilPlan)(nil) -) - -type plan interface { - do(ctx *execCtx, f func(id interface{}, data []interface{}) (more bool, err error)) error - explain(w strutil.Formatter) - fieldNames() []string - filter(expr expression) (p plan, indicesSought []string, err error) - hasID() bool -} - -func isTableOrIndex(p plan) bool { - switch p.(type) { - case - *indexPlan, - *sysColumnDefaultPlan, - *sysIndexDefaultPlan, - *sysTableDefaultPlan, - *tableDefaultPlan: - return true - default: - return false - } -} - -// Invariants -// - All interval plans produce rows in ascending index value collating order. -// - L <= H -type indexPlan struct { - src *table - cname string - xname string - x btreeIndex - kind int // See interval* consts. - lval interface{} // L, H: Ordered and comparable (lldb perspective). - hval interface{} -} - -func (r *indexPlan) doGe(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { - // nil, nil, ..., L-1, L-1, L, L, L+1, L+1, ... - // --- --- --- --- --- + + +++ +++ +++ - t := r.src - it, _, err := r.x.Seek([]interface{}{r.lval}) - if err != nil { - return noEOF(err) - } - - for { - _, h, err := it.Next() - if err != nil { - return noEOF(err) - } - - id, data, err := t.row(ctx, h) - if err != nil { - return err - } - - if more, err := f(id, data); err != nil || !more { - return err - } - } -} - -func (r *indexPlan) doGt(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { - // nil, nil, ..., L-1, L-1, L, L, L+1, L+1, ... - // --- --- --- --- --- - - +++ +++ +++ - t := r.src - it, _, err := r.x.Seek([]interface{}{r.lval}) - if err != nil { - return noEOF(err) - } - - var ok bool - for { - k, h, err := it.Next() - if err != nil { - return noEOF(err) - } - - if !ok { - val, err := expand1(k[0], nil) - if err != nil { - return err - } - - if collate1(val, r.lval) == 0 { - continue - } - - ok = true - } - - id, data, err := t.row(ctx, h) - if err != nil { - return err - } - - if more, err := f(id, data); err != nil || !more { - return err - } - } -} - -func (r *indexPlan) doInterval00(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { - // nil, nil, ..., L-1, L-1, L, L, L+1, L+1, ..., H-1, H-1, H, H, H+1, H+1, ... - // --- --- --- --- --- - - +++ +++ +++ +++ +++ - - --- --- --- - t := r.src - it, _, err := r.x.Seek([]interface{}{r.lval}) - if err != nil { - return noEOF(err) - } - - var ok bool - for { - k, h, err := it.Next() - if err != nil { - return noEOF(err) - } - - if !ok { - val, err := expand1(k[0], nil) - if err != nil { - return err - } - - if collate1(val, r.lval) == 0 { - continue - } - - ok = true - } - - val, err := expand1(k[0], nil) - if err != nil { - return err - } - - if collate1(val, r.hval) == 0 { - return nil - } - - id, data, err := t.row(ctx, h) - if err != nil { - return err - } - - if more, err := f(id, data); err != nil || !more { - return err - } - } -} - -func (r *indexPlan) doIntervalOC(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { - // nil, nil, ..., L-1, L-1, L, L, L+1, L+1, ..., H-1, H-1, H, H, H+1, H+1, ... - // --- --- --- --- --- - - +++ +++ +++ +++ +++ + + --- --- --- - t := r.src - it, _, err := r.x.Seek([]interface{}{r.lval}) - if err != nil { - return noEOF(err) - } - - var ok bool - for { - k, h, err := it.Next() - if err != nil { - return noEOF(err) - } - - if !ok { - val, err := expand1(k[0], nil) - if err != nil { - return err - } - - if collate1(val, r.lval) == 0 { - continue - } - - ok = true - } - - val, err := expand1(k[0], nil) - if err != nil { - return err - } - - if collate1(val, r.hval) > 0 { - return nil - } - - id, data, err := t.row(ctx, h) - if err != nil { - return err - } - - if more, err := f(id, data); err != nil || !more { - return err - } - } -} - -func (r *indexPlan) doIntervalCC(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { - // nil, nil, ..., L-1, L-1, L, L, L+1, L+1, ..., H-1, H-1, H, H, H+1, H+1, ... - // --- --- --- --- --- + + +++ +++ +++ +++ +++ + + --- --- --- - t := r.src - it, _, err := r.x.Seek([]interface{}{r.lval}) - if err != nil { - return noEOF(err) - } - - for { - k, h, err := it.Next() - if err != nil { - return noEOF(err) - } - - val, err := expand1(k[0], nil) - if err != nil { - return err - } - - if collate1(val, r.hval) > 0 { - return nil - } - - id, data, err := t.row(ctx, h) - if err != nil { - return err - } - - if more, err := f(id, data); err != nil || !more { - return err - } - } -} - -func (r *indexPlan) doIntervalCO(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { - // nil, nil, ..., L-1, L-1, L, L, L+1, L+1, ..., H-1, H-1, H, H, H+1, H+1, ... - // --- --- --- --- --- + + +++ +++ +++ +++ +++ - - --- --- --- - t := r.src - it, _, err := r.x.Seek([]interface{}{r.lval}) - if err != nil { - return noEOF(err) - } - - for { - k, h, err := it.Next() - if err != nil { - return noEOF(err) - } - - val, err := expand1(k[0], nil) - if err != nil { - return err - } - - if collate1(val, r.hval) >= 0 { - return nil - } - - id, data, err := t.row(ctx, h) - if err != nil { - return err - } - - if more, err := f(id, data); err != nil || !more { - return err - } - } -} - -func (r *indexPlan) doLe(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { - // nil, nil, ..., H-1, H-1, H, H, H+1, H+1, ... - // --- --- +++ +++ +++ + + --- --- - t := r.src - it, err := r.x.SeekFirst() - if err != nil { - return noEOF(err) - } - - for { - k, h, err := it.Next() - if err != nil { - return noEOF(err) - } - - if k == nil || k[0] == nil { - continue - } - - val, err := expand1(k[0], nil) - if err != nil { - return err - } - - if collate1(val, r.hval) > 0 { - return nil - } - - id, data, err := t.row(ctx, h) - if err != nil { - return err - } - - if more, err := f(id, data); err != nil || !more { - return err - } - } -} - -func (r *indexPlan) doLt(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { - // nil, nil, ..., H-1, H-1, H, H, H+1, H+1, ... - // --- --- +++ +++ +++ - - --- --- - t := r.src - it, err := r.x.SeekFirst() - if err != nil { - return noEOF(err) - } - - for { - k, h, err := it.Next() - if err != nil { - return noEOF(err) - } - - if k == nil || k[0] == nil { - continue - } - - val, err := expand1(k[0], nil) - if err != nil { - return err - } - - if collate1(val, r.hval) >= 0 { - return nil - } - - id, data, err := t.row(ctx, h) - if err != nil { - return err - } - - if more, err := f(id, data); err != nil || !more { - return err - } - } -} - -func (r *indexPlan) doEq(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { - // nil, nil, ..., L-1, L-1, L, L, L+1, L+1, ... - // --- --- --- --- --- + + --- --- --- - t := r.src - it, _, err := r.x.Seek([]interface{}{r.lval}) - if err != nil { - return noEOF(err) - } - - for { - k, h, err := it.Next() - if err != nil { - return noEOF(err) - } - - val, err := expand1(k[0], nil) - if err != nil { - return err - } - - if collate1(val, r.lval) != 0 { - return nil - } - - id, data, err := t.row(ctx, h) - if err != nil { - return err - } - - if more, err := f(id, data); err != nil || !more { - return err - } - } -} - -func (r *indexPlan) doNe(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { - // nil, nil, ..., L-1, L-1, L, L, L+1, L+1, ... - // --- --- +++ +++ +++ - - +++ +++ +++ - t := r.src - it, err := r.x.SeekFirst() - if err != nil { - return noEOF(err) - } - - for { - k, h, err := it.Next() - if err != nil { - return noEOF(err) - } - - if k == nil || k[0] == nil { - continue - } - - val, err := expand1(k[0], nil) - if err != nil { - return err - } - - if collate1(val, r.hval) == 0 { - continue - } - - id, data, err := t.row(ctx, h) - if err != nil { - return err - } - - if more, err := f(id, data); err != nil || !more { - return err - } - } -} - -func (r *indexPlan) doIsNull(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { - // nil, nil, ... - // +++ +++ --- - t := r.src - it, err := r.x.SeekFirst() - if err != nil { - return noEOF(err) - } - - for { - k, h, err := it.Next() - if err != nil { - return noEOF(err) - } - - if k != nil && k[0] != nil { - return nil - } - - id, data, err := t.row(ctx, h) - if err != nil { - return err - } - - if more, err := f(id, data); err != nil || !more { - return err - } - } -} - -func (r *indexPlan) doIsNotNull(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { - // nil, nil, ... - // --- --- +++ - t := r.src - it, _, err := r.x.Seek([]interface{}{false}) // lldb collates false right after NULL. - if err != nil { - return noEOF(err) - } - - for { - _, h, err := it.Next() - if err != nil { - return noEOF(err) - } - - id, data, err := t.row(ctx, h) - if err != nil { - return err - } - - if more, err := f(id, data); err != nil || !more { - return err - } - } -} - -func (r *indexPlan) doFalse(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { - t := r.src - it, _, err := r.x.Seek([]interface{}{false}) - if err != nil { - return noEOF(err) - } - - for { - k, h, err := it.Next() - if err != nil { - return noEOF(err) - } - - b, ok := k[0].(bool) - if !ok || b { - return nil - } - - id, data, err := t.row(ctx, h) - if err != nil { - return err - } - - if more, err := f(id, data); err != nil || !more { - return err - } - } -} - -func (r *indexPlan) doTrue(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { - t := r.src - it, _, err := r.x.Seek([]interface{}{true}) - if err != nil { - return noEOF(err) - } - - for { - k, h, err := it.Next() - if err != nil { - return noEOF(err) - } - - if _, ok := k[0].(bool); !ok { - return nil - } - - id, data, err := t.row(ctx, h) - if err != nil { - return err - } - - if more, err := f(id, data); err != nil || !more { - return err - } - } -} - -func (r *indexPlan) do(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) error { - switch r.kind { - case indexEq: - return r.doEq(ctx, f) - case indexGe: - return r.doGe(ctx, f) - case indexGt: - return r.doGt(ctx, f) - case indexLe: - return r.doLe(ctx, f) - case indexLt: - return r.doLt(ctx, f) - case indexNe: - return r.doNe(ctx, f) - case indexIsNull: - return r.doIsNull(ctx, f) - case indexIsNotNull: - return r.doIsNotNull(ctx, f) - case indexFalse: - return r.doFalse(ctx, f) - case indexTrue: - return r.doTrue(ctx, f) - case indexIntervalOO: - return r.doInterval00(ctx, f) - case indexIntervalCC: - return r.doIntervalCC(ctx, f) - case indexIntervalOC: - return r.doIntervalOC(ctx, f) - case indexIntervalCO: - return r.doIntervalCO(ctx, f) - default: - //dbg("", r.kind) - panic("internal error 072") - } -} - -func (r *indexPlan) explain(w strutil.Formatter) { - s := "" - if r.kind == indexFalse { - s = "!" - } - w.Format("┌Iterate all rows of table %q using index %q where %s%s", r.src.name, r.xname, s, r.cname) - switch r.kind { - case indexEq: - w.Format(" == %v", value{r.lval}) - case indexGe: - w.Format(" >= %v", value{r.lval}) - case indexGt: - w.Format(" > %v", value{r.lval}) - case indexLe: - w.Format(" <= %v", value{r.hval}) - case indexLt: - w.Format(" < %v", value{r.hval}) - case indexNe: - w.Format(" != %v", value{r.lval}) - case indexIsNull: - w.Format(" IS NULL") - case indexIsNotNull: - w.Format(" IS NOT NULL") - case indexFalse, indexTrue: - // nop - case indexIntervalOO: - w.Format(" > %v && %s < %v", value{r.lval}, r.cname, value{r.hval}) - case indexIntervalCC: - w.Format(" >= %v && %s <= %v", value{r.lval}, r.cname, value{r.hval}) - case indexIntervalCO: - w.Format(" >= %v && %s < %v", value{r.lval}, r.cname, value{r.hval}) - case indexIntervalOC: - w.Format(" > %v && %s <= %v", value{r.lval}, r.cname, value{r.hval}) - default: - //dbg("", r.kind) - panic("internal error 073") - } - w.Format("\n└Output field names %v\n", qnames(r.fieldNames())) -} - -func (r *indexPlan) fieldNames() []string { return r.src.fieldNames() } - -func (r *indexPlan) filterEq(binOp2 int, val interface{}) (plan, []string, error) { - switch binOp2 { - case eq: - if collate1(r.lval, val) == 0 { - return r, nil, nil - } - - return &nullPlan{r.fieldNames()}, nil, nil - case ge: - if collate1(r.lval, val) >= 0 { - return r, nil, nil - } - - return &nullPlan{r.fieldNames()}, nil, nil - case '>': - if collate1(r.lval, val) > 0 { - return r, nil, nil - } - - return &nullPlan{r.fieldNames()}, nil, nil - case le: - if collate1(r.lval, val) <= 0 { - return r, nil, nil - } - - return &nullPlan{r.fieldNames()}, nil, nil - case '<': - if collate1(r.lval, val) < 0 { - return r, nil, nil - } - - return &nullPlan{r.fieldNames()}, nil, nil - case neq: - if collate1(r.lval, val) != 0 { - return r, nil, nil - } - - return &nullPlan{r.fieldNames()}, nil, nil - } - return nil, nil, nil -} - -func (r *indexPlan) filterGe(binOp2 int, val interface{}) (plan, []string, error) { - switch binOp2 { - case eq: - if collate1(r.lval, val) <= 0 { - r.lval = val - r.kind = indexEq - return r, nil, nil - } - - return &nullPlan{r.fieldNames()}, nil, nil - case ge: - if collate1(r.lval, val) < 0 { - r.lval = val - } - return r, nil, nil - case '>': - if collate1(r.lval, val) <= 0 { - r.lval = val - r.kind = indexGt - } - return r, nil, nil - case le: - switch c := collate1(r.lval, val); { - case c < 0: - r.hval = val - r.kind = indexIntervalCC - return r, nil, nil - case c == 0: - r.kind = indexEq - return r, nil, nil - default: // c > 0 - return &nullPlan{r.fieldNames()}, nil, nil - } - case '<': - if collate1(r.lval, val) < 0 { - r.hval = val - r.kind = indexIntervalCO - return r, nil, nil - } - - return &nullPlan{r.fieldNames()}, nil, nil - case neq: - switch c := collate1(r.lval, val); { - case c < 0: - //MAYBE ORed intervals - case c == 0: - r.kind = indexGt - return r, nil, nil - default: // c > 0 - return r, nil, nil - } - } - return nil, nil, nil -} - -func (r *indexPlan) filterGt(binOp2 int, val interface{}) (plan, []string, error) { - switch binOp2 { - case eq: - if collate1(r.lval, val) < 0 { - r.lval = val - r.kind = indexEq - return r, nil, nil - } - - return &nullPlan{r.fieldNames()}, nil, nil - case ge: - if collate1(r.lval, val) < 0 { - r.lval = val - r.kind = indexGe - } - return r, nil, nil - case '>': - if collate1(r.lval, val) < 0 { - r.lval = val - } - return r, nil, nil - case le: - if collate1(r.lval, val) < 0 { - r.hval = val - r.kind = indexIntervalOC - return r, nil, nil - } - - return &nullPlan{r.fieldNames()}, nil, nil - case '<': - if collate1(r.lval, val) < 0 { - r.hval = val - r.kind = indexIntervalOO - return r, nil, nil - } - - return &nullPlan{r.fieldNames()}, nil, nil - case neq: - if collate1(r.lval, val) >= 0 { - return r, nil, nil - } - } - return nil, nil, nil -} - -func (r *indexPlan) filterLe(binOp2 int, val interface{}) (plan, []string, error) { - switch binOp2 { - case eq: - if collate1(r.hval, val) >= 0 { - r.lval = val - r.kind = indexEq - return r, nil, nil - } - - return &nullPlan{r.fieldNames()}, nil, nil - case ge: - switch c := collate1(r.hval, val); { - case c < 0: - return &nullPlan{r.fieldNames()}, nil, nil - case c == 0: - r.lval = val - r.kind = indexEq - return r, nil, nil - default: // c > 0 - r.lval = val - r.kind = indexIntervalCC - return r, nil, nil - } - case '>': - if collate1(r.hval, val) > 0 { - r.lval = val - r.kind = indexIntervalOC - return r, nil, nil - } - - return &nullPlan{r.fieldNames()}, nil, nil - case le: - if collate1(r.hval, val) > 0 { - r.hval = val - } - return r, nil, nil - case '<': - if collate1(r.hval, val) >= 0 { - r.hval = val - r.kind = indexLt - } - return r, nil, nil - case neq: - switch c := collate1(r.hval, val); { - case c < 0: - return r, nil, nil - case c == 0: - r.kind = indexLt - return r, nil, nil - default: // c > 0 - //bop - } - } - return nil, nil, nil -} - -func (r *indexPlan) filterLt(binOp2 int, val interface{}) (plan, []string, error) { - switch binOp2 { - case eq: - if collate1(r.hval, val) > 0 { - r.lval = val - r.kind = indexEq - return r, nil, nil - } - - return &nullPlan{r.fieldNames()}, nil, nil - case ge: - if collate1(r.hval, val) > 0 { - r.lval = val - r.kind = indexIntervalCO - return r, nil, nil - } - - return &nullPlan{r.fieldNames()}, nil, nil - case '>': - if collate1(r.hval, val) > 0 { - r.lval = val - r.kind = indexIntervalOO - return r, nil, nil - } - - return &nullPlan{r.fieldNames()}, nil, nil - case le: - if collate1(r.hval, val) > 0 { - r.hval = val - r.kind = indexLe - } - return r, nil, nil - case '<': - if collate1(r.hval, val) > 0 { - r.hval = val - } - return r, nil, nil - case neq: - if collate1(r.hval, val) > 0 { - return nil, nil, nil - } - - return r, nil, nil - } - return nil, nil, nil -} - -func (r *indexPlan) filterCC(binOp2 int, val interface{}) (plan, []string, error) { - switch binOp2 { - case eq: - if collate1(val, r.lval) < 0 || collate1(val, r.hval) > 0 { - return &nullPlan{r.fieldNames()}, nil, nil - } - - r.lval = val - r.kind = indexEq - return r, nil, nil - case ge: - if collate1(val, r.lval) <= 0 { - return r, nil, nil - } - - switch c := collate1(val, r.hval); { - case c < 0: - r.lval = val - return r, nil, nil - case c == 0: - r.lval = val - r.kind = indexEq - return r, nil, nil - default: - return &nullPlan{r.fieldNames()}, nil, nil - } - case '>': - switch c := collate1(val, r.lval); { - case c < 0: - return r, nil, nil - case c == 0: - r.kind = indexIntervalOC - return r, nil, nil - default: - if collate1(val, r.hval) < 0 { - r.lval = val - r.kind = indexIntervalOC - return r, nil, nil - } - - return &nullPlan{r.fieldNames()}, nil, nil - } - case le: - switch c := collate1(val, r.lval); { - case c < 0: - return &nullPlan{r.fieldNames()}, nil, nil - case c == 0: - r.kind = indexEq - return r, nil, nil - default: - if collate1(val, r.hval) < 0 { - r.hval = val - } - return r, nil, nil - } - case '<': - if collate1(val, r.lval) <= 0 { - return &nullPlan{r.fieldNames()}, nil, nil - } - - if collate1(val, r.hval) <= 0 { - r.hval = val - r.kind = indexIntervalCO - } - return r, nil, nil - case neq: - switch c := collate1(val, r.lval); { - case c < 0: - return r, nil, nil - case c == 0: - r.kind = indexIntervalOC - return r, nil, nil - default: - switch c := collate1(val, r.hval); { - case c == 0: - r.kind = indexIntervalCO - return r, nil, nil - case c > 0: - return r, nil, nil - default: - return nil, nil, nil - } - } - } - return nil, nil, nil -} - -func (r *indexPlan) filterOC(binOp2 int, val interface{}) (plan, []string, error) { - switch binOp2 { - case eq: - if collate1(val, r.lval) <= 0 || collate1(val, r.hval) > 0 { - return &nullPlan{r.fieldNames()}, nil, nil - } - - r.lval = val - r.kind = indexEq - return r, nil, nil - case ge: - if collate1(val, r.lval) <= 0 { - return r, nil, nil - } - - switch c := collate1(val, r.hval); { - case c < 0: - r.lval = val - r.kind = indexIntervalCC - return r, nil, nil - case c == 0: - r.lval = val - r.kind = indexEq - return r, nil, nil - default: - return &nullPlan{r.fieldNames()}, nil, nil - } - case '>': - if collate1(val, r.lval) <= 0 { - return r, nil, nil - } - - if collate1(val, r.hval) < 0 { - r.lval = val - return r, nil, nil - } - - return &nullPlan{r.fieldNames()}, nil, nil - case le: - if collate1(val, r.lval) <= 0 { - return &nullPlan{r.fieldNames()}, nil, nil - } - - if collate1(val, r.hval) < 0 { - r.hval = val - } - return r, nil, nil - case '<': - if collate1(val, r.lval) <= 0 { - return &nullPlan{r.fieldNames()}, nil, nil - } - - switch c := collate1(val, r.hval); { - case c < 0: - r.hval = val - r.kind = indexIntervalOO - case c == 0: - r.kind = indexIntervalOO - } - return r, nil, nil - case neq: - if collate1(val, r.lval) <= 0 { - return r, nil, nil - } - - switch c := collate1(val, r.hval); { - case c < 0: - return nil, nil, nil - case c == 0: - r.kind = indexIntervalOO - return r, nil, nil - default: - return r, nil, nil - } - } - return nil, nil, nil -} - -func (r *indexPlan) filterOO(binOp2 int, val interface{}) (plan, []string, error) { - switch binOp2 { - case eq: - if collate1(val, r.lval) <= 0 || collate1(val, r.hval) >= 0 { - return &nullPlan{r.fieldNames()}, nil, nil - } - - r.lval = val - r.kind = indexEq - return r, nil, nil - case ge: - if collate1(val, r.lval) <= 0 { - return r, nil, nil - } - - if collate1(val, r.hval) < 0 { - r.lval = val - r.kind = indexIntervalCO - return r, nil, nil - } - - return &nullPlan{r.fieldNames()}, nil, nil - case '>': - if collate1(val, r.lval) <= 0 { - return r, nil, nil - } - - if collate1(val, r.hval) < 0 { - r.lval = val - return r, nil, nil - } - - return &nullPlan{r.fieldNames()}, nil, nil - case le: - if collate1(val, r.lval) <= 0 { - return &nullPlan{r.fieldNames()}, nil, nil - } - - if collate1(val, r.hval) < 0 { - r.hval = val - r.kind = indexIntervalOC - } - return r, nil, nil - case '<': - if collate1(val, r.lval) <= 0 { - return &nullPlan{r.fieldNames()}, nil, nil - } - - if collate1(val, r.hval) < 0 { - r.hval = val - } - return r, nil, nil - case neq: - if collate1(val, r.lval) <= 0 || collate1(val, r.hval) >= 0 { - return r, nil, nil - } - - return nil, nil, nil - } - return nil, nil, nil -} - -func (r *indexPlan) filterCO(binOp2 int, val interface{}) (plan, []string, error) { - switch binOp2 { - case eq: - if collate1(val, r.lval) < 0 || collate1(val, r.hval) >= 0 { - return &nullPlan{r.fieldNames()}, nil, nil - } - - r.lval = val - r.kind = indexEq - return r, nil, nil - case ge: - if collate1(val, r.lval) <= 0 { - return r, nil, nil - } - - if collate1(val, r.hval) < 0 { - r.lval = val - return r, nil, nil - } - - return &nullPlan{r.fieldNames()}, nil, nil - case '>': - switch c := collate1(val, r.lval); { - case c < 0: - return r, nil, nil - case c == 0: - r.kind = indexIntervalOO - return r, nil, nil - default: - if collate1(val, r.hval) < 0 { - r.lval = val - r.kind = indexIntervalOO - return r, nil, nil - } - - return &nullPlan{r.fieldNames()}, nil, nil - } - case le: - switch c := collate1(val, r.lval); { - case c < 0: - return &nullPlan{r.fieldNames()}, nil, nil - case c == 0: - r.kind = indexEq - return r, nil, nil - default: - if collate1(val, r.hval) < 0 { - r.hval = val - r.kind = indexIntervalCC - } - return r, nil, nil - } - case '<': - if collate1(val, r.lval) <= 0 { - return &nullPlan{r.fieldNames()}, nil, nil - } - - if collate1(val, r.hval) < 0 { - r.hval = val - } - return r, nil, nil - case neq: - switch c := collate1(val, r.lval); { - case c < 0: - return r, nil, nil - case c == 0: - r.kind = indexIntervalOO - return r, nil, nil - default: - if collate1(val, r.hval) < 0 { - return nil, nil, nil - } - - return r, nil, nil - } - } - return nil, nil, nil -} - -func (r *indexPlan) filterNe(binOp2 int, val interface{}) (plan, []string, error) { - switch binOp2 { - case eq: - if collate1(val, r.lval) != 0 { - r.lval = val - r.kind = indexEq - return r, nil, nil - } - - return &nullPlan{r.fieldNames()}, nil, nil - case ge: - switch c := collate1(val, r.lval); { - case c < 0: - return nil, nil, nil //TODO - case c == 0: - r.kind = indexGt - return r, nil, nil - default: - r.lval = val - r.kind = indexGe - return r, nil, nil - } - case '>': - if collate1(val, r.lval) < 0 { - return nil, nil, nil //TODO - } - - r.lval = val - r.kind = indexGt - return r, nil, nil - case le: - switch c := collate1(val, r.lval); { - case c < 0: - r.hval = val - r.kind = indexLe - return r, nil, nil - case c == 0: - r.kind = indexLt - return r, nil, nil - default: - return nil, nil, nil //TODO - } - case '<': - if collate1(val, r.lval) <= 0 { - r.hval = val - r.kind = indexLt - return r, nil, nil - } - - return nil, nil, nil //TODO - case neq: - if collate1(val, r.lval) == 0 { - return r, nil, nil - } - - return nil, nil, nil - } - return nil, nil, nil -} - -func (r *indexPlan) filter(expr expression) (plan, []string, error) { - switch x := expr.(type) { - case *binaryOperation: - ok, cname, val, err := x.isIdentRelOpVal() - if err != nil { - return nil, nil, err - } - - if !ok || r.cname != cname { - break - } - - if val, err = typeCheck1(val, findCol(r.src.cols, cname)); err != nil { - return nil, nil, err - } - - switch r.kind { - case indexEq: // [L] - return r.filterEq(x.op, val) - case indexGe: // [L, ...) - return r.filterGe(x.op, val) - case indexGt: // (L, ...) - return r.filterGt(x.op, val) - case indexIntervalCC: // [L, H] - return r.filterCC(x.op, val) - case indexIntervalCO: // [L, H) - return r.filterCO(x.op, val) - case indexIntervalOC: // (L, H] - return r.filterOC(x.op, val) - case indexIntervalOO: // (L, H) - return r.filterOO(x.op, val) - case indexLe: // (..., H] - return r.filterLe(x.op, val) - case indexLt: // (..., H) - return r.filterLt(x.op, val) - case indexNe: // (L) - return r.filterNe(x.op, val) - } - case *ident: - cname := x.s - if r.cname != cname { - break - } - - switch r.kind { - case indexFalse: // [false] - return &nullPlan{r.fieldNames()}, nil, nil - case indexTrue: // [true] - return r, nil, nil - } - case *unaryOperation: - if x.op != '!' { - break - } - - operand, ok := x.v.(*ident) - if !ok { - break - } - - cname := operand.s - if r.cname != cname { - break - } - - switch r.kind { - case indexFalse: // [false] - return r, nil, nil - case indexTrue: // [true] - return &nullPlan{r.fieldNames()}, nil, nil - } - } - - return nil, nil, nil -} - -func (r *indexPlan) hasID() bool { return true } - -type explainDefaultPlan struct { - s stmt -} - -func (r *explainDefaultPlan) hasID() bool { return false } - -func (r *explainDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (more bool, err error)) error { - var buf bytes.Buffer - switch x := r.s.(type) { - default: - w := strutil.IndentFormatter(&buf, "│ ") - x.explain(ctx, w) - } - - a := bytes.Split(buf.Bytes(), []byte{'\n'}) - for _, v := range a[:len(a)-1] { - if more, err := f(nil, []interface{}{string(v)}); !more || err != nil { - return err - } - } - return nil -} - -func (r *explainDefaultPlan) explain(w strutil.Formatter) { - return -} - -func (r *explainDefaultPlan) fieldNames() []string { - return []string{""} -} - -func (r *explainDefaultPlan) filter(expr expression) (plan, []string, error) { - return nil, nil, nil -} - -type filterDefaultPlan struct { - plan - expr expression - is []string -} - -func (r *filterDefaultPlan) hasID() bool { return r.plan.hasID() } - -func (r *filterDefaultPlan) explain(w strutil.Formatter) { - r.plan.explain(w) - w.Format("┌Filter on %v\n", r.expr) - if len(r.is) != 0 { - w.Format("│Possibly useful indices\n") - m := map[string]bool{} - for _, v := range r.is { - if !m[v] { - m[v] = true - n := "" - for _, r := range v { - if r >= '0' && r <= '9' || r >= 'a' && r <= 'z' || r >= 'A' && r <= 'Z' || r == '_' { - n += string(r) - continue - } - - n += "_" - } - for strings.Contains(n, "__") { - n = strings.Replace(n, "__", "_", -1) - } - for strings.HasSuffix(n, "_") { - n = n[:len(n)-1] - } - w.Format("│CREATE INDEX x%s ON %s;\n", n, v) - } - } - } - w.Format("└Output field names %v\n", qnames(r.plan.fieldNames())) -} - -func (r *filterDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (bool, error)) (err error) { - m := map[interface{}]interface{}{} - fields := r.plan.fieldNames() - return r.plan.do(ctx, func(rid interface{}, data []interface{}) (bool, error) { - for i, v := range fields { - m[v] = data[i] - } - m["$id"] = rid - val, err := r.expr.eval(ctx, m) - if err != nil { - return false, err - } - - if val == nil { - return true, nil - } - - x, ok := val.(bool) - if !ok { - return false, fmt.Errorf("invalid boolean expression %s (value of type %T)", val, val) - } - - if !x { - return true, nil - } - - return f(rid, data) - }) -} - -type crossJoinDefaultPlan struct { - rsets []plan - names []string - fields []string -} - -func (r *crossJoinDefaultPlan) hasID() bool { return false } - -func (r *crossJoinDefaultPlan) explain(w strutil.Formatter) { - w.Format("┌Compute Cartesian product of%i\n") - for i, v := range r.rsets { - sel := !isTableOrIndex(v) - if sel { - w.Format("┌Iterate all rows of virtual table %q%i\n", r.names[i]) - } - v.explain(w) - if sel { - w.Format("%u└Output field names %v\n", qnames(v.fieldNames())) - } - } - w.Format("%u└Output field names %v\n", qnames(r.fields)) -} - -func (r *crossJoinDefaultPlan) filter(expr expression) (plan, []string, error) { - var is []string - for i, v := range r.names { - e2, err := expr.clone(nil, v) - if err != nil { - return nil, nil, err - } - - p2, is2, err := r.rsets[i].filter(e2) - is = append(is, is2...) - if err != nil { - return nil, nil, err - } - - if p2 != nil { - r.rsets[i] = p2 - return r, is, nil - } - } - return nil, is, nil -} - -func (r *crossJoinDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (bool, error)) error { - if len(r.rsets) == 1 { - return r.rsets[0].do(ctx, f) - } - - ids := map[string]interface{}{} - var g func([]interface{}, []plan, int) error - g = func(prefix []interface{}, rsets []plan, x int) (err error) { - return rsets[0].do(ctx, func(id interface{}, in []interface{}) (bool, error) { - ids[r.names[x]] = id - if len(rsets) > 1 { - return true, g(append(prefix, in...), rsets[1:], x+1) - } - - return f(ids, append(prefix, in...)) - }) - } - return g(nil, r.rsets, 0) -} - -func (r *crossJoinDefaultPlan) fieldNames() []string { return r.fields } - -type distinctDefaultPlan struct { - src plan - fields []string -} - -func (r *distinctDefaultPlan) hasID() bool { return false } - -func (r *distinctDefaultPlan) explain(w strutil.Formatter) { - r.src.explain(w) - w.Format("┌Compute distinct rows\n└Output field names %v\n", r.fields) -} - -func (r *distinctDefaultPlan) filter(expr expression) (plan, []string, error) { - return nil, nil, nil -} - -func (r *distinctDefaultPlan) fieldNames() []string { return r.fields } - -func (r *distinctDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (bool, error)) (err error) { - t, err := ctx.db.store.CreateTemp(true) - if err != nil { - return - } - - defer func() { - if derr := t.Drop(); derr != nil && err == nil { - err = derr - } - }() - - if err = r.src.do(ctx, func(id interface{}, in []interface{}) (bool, error) { - if err = t.Set(in, nil); err != nil { - return false, err - } - - return true, nil - }); err != nil { - return - } - - var data []interface{} - more := true - it, err := t.SeekFirst() - for more && err == nil { - data, _, err = it.Next() - if err != nil { - break - } - - more, err = f(nil, data) - } - return noEOF(err) -} - -type groupByDefaultPlan struct { - colNames []string - src plan - fields []string -} - -func (r *groupByDefaultPlan) hasID() bool { return false } - -func (r *groupByDefaultPlan) explain(w strutil.Formatter) { - r.src.explain(w) - switch { - case len(r.colNames) == 0: //TODO this case should not exist for this plan, should become tableDefaultPlan - w.Format("┌Group by distinct rows") - default: - w.Format("┌Group by") - for _, v := range r.colNames { - w.Format(" %s,", v) - } - } - w.Format("\n└Output field names %v\n", qnames(r.fields)) -} - -func (r *groupByDefaultPlan) filter(expr expression) (plan, []string, error) { - return nil, nil, nil -} - -func (r *groupByDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (bool, error)) (err error) { - t, err := ctx.db.store.CreateTemp(true) - if err != nil { - return - } - - defer func() { - if derr := t.Drop(); derr != nil && err == nil { - err = derr - } - }() - - var gcols []*col - var cols []*col - m := map[string]int{} - for i, v := range r.src.fieldNames() { - m[v] = i - } - for _, c := range r.colNames { - i, ok := m[c] - if !ok { - return fmt.Errorf("unknown field %s", c) - } - - gcols = append(gcols, &col{name: c, index: i}) - } - k := make([]interface{}, len(r.colNames)) //TODO optimize when len(r.cols) == 0, should become tableDefaultPlan - if err = r.src.do(ctx, func(rid interface{}, in []interface{}) (more bool, err error) { - infer(in, &cols) - for i, c := range gcols { - k[i] = in[c.index] - } - h0, err := t.Get(k) - if err != nil { - return false, err - } - - var h int64 - if len(h0) != 0 { - h, _ = h0[0].(int64) - } - nh, err := t.Create(append([]interface{}{h, nil}, in...)...) - if err != nil { - return false, err - } - - for i, c := range gcols { - k[i] = in[c.index] - } - err = t.Set(k, []interface{}{nh}) - if err != nil { - return false, err - } - - return true, nil - }); err != nil { - return - } - - for i, v := range r.src.fieldNames()[:len(cols)] { - cols[i].name = v - cols[i].index = i - } - if more, err := f(nil, []interface{}{t, cols}); !more || err != nil { - return err - } - - it, err := t.SeekFirst() - more := true - var data []interface{} - for more && err == nil { - if _, data, err = it.Next(); err != nil { - break - } - - more, err = f(nil, data) - } - return noEOF(err) -} - -func (r *groupByDefaultPlan) fieldNames() []string { return r.fields } - -type selectIndexDefaultPlan struct { - nm string - x interface{} -} - -func (r *selectIndexDefaultPlan) hasID() bool { return false } - -func (r *selectIndexDefaultPlan) explain(w strutil.Formatter) { - w.Format("┌Iterate all values of index %q\n└Output field names N/A\n", r.nm) -} - -func (r *selectIndexDefaultPlan) filter(expr expression) (plan, []string, error) { - return nil, nil, nil -} - -func (r *selectIndexDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (bool, error)) (err error) { - var x btreeIndex - switch ix := r.x.(type) { - case *indexedCol: - x = ix.x - case *index2: - x = ix.x - default: - panic("internal error 007") - } - - en, err := x.SeekFirst() - if err != nil { - return noEOF(err) - } - - var id int64 - for { - k, _, err := en.Next() - if err != nil { - return noEOF(err) - } - - id++ - if more, err := f(id, k); !more || err != nil { - return err - } - } -} - -func (r *selectIndexDefaultPlan) fieldNames() []string { - return []string{r.nm} -} - -type limitDefaultPlan struct { - expr expression - src plan - fields []string -} - -func (r *limitDefaultPlan) hasID() bool { return r.src.hasID() } - -func (r *limitDefaultPlan) explain(w strutil.Formatter) { - r.src.explain(w) - w.Format("┌Pass first %v records\n└Output field names %v\n", r.expr, r.fields) -} - -func (r *limitDefaultPlan) filter(expr expression) (plan, []string, error) { - return nil, nil, nil -} - -func (r *limitDefaultPlan) fieldNames() []string { return r.fields } - -func (r *limitDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (more bool, err error)) (err error) { - m := map[interface{}]interface{}{} - var eval bool - var lim uint64 - return r.src.do(ctx, func(rid interface{}, in []interface{}) (more bool, err error) { - if !eval { - for i, fld := range r.fields { - if fld != "" { - m[fld] = in[i] - } - } - m["$id"] = rid - val, err := r.expr.eval(ctx, m) - if err != nil { - return false, err - } - - if val == nil { - return true, nil - } - - if lim, err = limOffExpr(val); err != nil { - return false, err - } - - eval = true - } - switch lim { - case 0: - return false, nil - default: - lim-- - return f(rid, in) - } - }) -} - -type offsetDefaultPlan struct { - expr expression - src plan - fields []string -} - -func (r *offsetDefaultPlan) hasID() bool { return r.src.hasID() } - -func (r *offsetDefaultPlan) explain(w strutil.Formatter) { - r.src.explain(w) - w.Format("┌Skip first %v records\n└Output field names %v\n", r.expr, qnames(r.fields)) -} - -func (r *offsetDefaultPlan) filter(expr expression) (plan, []string, error) { - return nil, nil, nil -} - -func (r *offsetDefaultPlan) fieldNames() []string { return r.fields } - -func (r *offsetDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (bool, error)) error { - m := map[interface{}]interface{}{} - var eval bool - var off uint64 - return r.src.do(ctx, func(rid interface{}, in []interface{}) (bool, error) { - if !eval { - for i, fld := range r.fields { - if fld != "" { - m[fld] = in[i] - } - } - m["$id"] = rid - val, err := r.expr.eval(ctx, m) - if err != nil { - return false, err - } - - if val == nil { - return true, nil - } - - if off, err = limOffExpr(val); err != nil { - return false, err - } - - eval = true - } - if off > 0 { - off-- - return true, nil - } - - return f(rid, in) - }) -} - -type orderByDefaultPlan struct { - asc bool - by []expression - src plan - fields []string -} - -func (r *orderByDefaultPlan) hasID() bool { return r.src.hasID() } - -func (r *orderByDefaultPlan) explain(w strutil.Formatter) { - r.src.explain(w) - w.Format("┌Order%s by", map[bool]string{false: " descending"}[r.asc]) - for _, v := range r.by { - w.Format(" %s,", v) - } - w.Format("\n└Output field names %v\n", qnames(r.fields)) -} - -func (r *orderByDefaultPlan) filter(expr expression) (plan, []string, error) { - return nil, nil, nil -} - -func (r *orderByDefaultPlan) fieldNames() []string { return r.fields } - -func (r *orderByDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (bool, error)) (err error) { - t, err := ctx.db.store.CreateTemp(r.asc) - if err != nil { - return - } - - defer func() { - if derr := t.Drop(); derr != nil && err == nil { - err = derr - } - }() - - m := map[interface{}]interface{}{} - flds := r.fields - k := make([]interface{}, len(r.by)+1) - id := int64(-1) - if err = r.src.do(ctx, func(rid interface{}, in []interface{}) (bool, error) { - id++ - for i, fld := range flds { - if fld != "" { - m[fld] = in[i] - } - } - m["$id"] = rid - for i, expr := range r.by { - val, err := expr.eval(ctx, m) - if err != nil { - return false, err - } - - if val != nil { - val, ordered, err := isOrderedType(val) - if err != nil { - return false, err - } - - if !ordered { - return false, fmt.Errorf("cannot order by %v (type %T)", val, val) - - } - } - - k[i] = val - } - k[len(r.by)] = id - if err = t.Set(k, in); err != nil { - return false, err - } - - return true, nil - }); err != nil { - return - } - - it, err := t.SeekFirst() - if err != nil { - return noEOF(err) - } - - var data []interface{} - more := true - for more && err == nil { - if _, data, err = it.Next(); err != nil { - break - } - - more, err = f(nil, data) - } - return noEOF(err) -} - -type selectFieldsDefaultPlan struct { - flds []*fld - src plan - fields []string -} - -func (r *selectFieldsDefaultPlan) hasID() bool { return r.src.hasID() } - -func (r *selectFieldsDefaultPlan) explain(w strutil.Formatter) { - //TODO check for non existing fields - r.src.explain(w) - w.Format("┌Evaluate") - for _, v := range r.flds { - w.Format(" %s as %s,", v.expr, fmt.Sprintf("%q", v.name)) - } - w.Format("\n└Output field names %v\n", qnames(r.fields)) -} - -func (r *selectFieldsDefaultPlan) filter(expr expression) (plan, []string, error) { - return nil, nil, nil -} - -func (r *selectFieldsDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (bool, error)) error { - fields := r.src.fieldNames() - m := map[interface{}]interface{}{} - return r.src.do(ctx, func(rid interface{}, in []interface{}) (bool, error) { - for i, nm := range fields { - if nm != "" { - m[nm] = in[i] - } - } - m["$id"] = rid - out := make([]interface{}, len(r.flds)) - for i, fld := range r.flds { - var err error - if out[i], err = fld.expr.eval(ctx, m); err != nil { - return false, err - } - } - return f(rid, out) - }) -} - -func (r *selectFieldsDefaultPlan) fieldNames() []string { return r.fields } - -type selectFieldsGroupPlan struct { - flds []*fld - src *groupByDefaultPlan - fields []string -} - -func (r *selectFieldsGroupPlan) hasID() bool { return false } - -func (r *selectFieldsGroupPlan) explain(w strutil.Formatter) { - //TODO check for non existing fields - r.src.explain(w) - w.Format("┌Evaluate") - for _, v := range r.flds { - w.Format(" %s as %s,", v.expr, fmt.Sprintf("%q", v.name)) - } - w.Format("\n└Output field names %v\n", qnames(r.fields)) -} - -func (r *selectFieldsGroupPlan) fieldNames() []string { return r.fields } - -func (r *selectFieldsGroupPlan) filter(expr expression) (plan, []string, error) { - return nil, nil, nil -} - -func (r *selectFieldsGroupPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (bool, error)) error { - var t temp - var cols []*col - var err error - out := make([]interface{}, len(r.flds)) - ok := false - rows := false - if err = r.src.do(ctx, func(rid interface{}, in []interface{}) (bool, error) { - if ok { - h := in[0].(int64) - m := map[interface{}]interface{}{} - for h != 0 { - in, err = t.Read(nil, h, cols...) - if err != nil { - return false, err - } - - rec := in[2:] - for i, c := range cols { - if nm := c.name; nm != "" { - m[nm] = rec[i] - } - } - m["$id"] = rid - for _, fld := range r.flds { - if _, err = fld.expr.eval(ctx, m); err != nil { - return false, err - } - } - - h = in[0].(int64) - } - m["$agg"] = true - for i, fld := range r.flds { - if out[i], err = fld.expr.eval(ctx, m); err != nil { - return false, err - } - } - rows = true - return f(nil, out) - } - - ok = true - t = in[0].(temp) - cols = in[1].([]*col) - if len(r.flds) == 0 { // SELECT * - r.flds = make([]*fld, len(cols)) - for i, v := range cols { - r.flds[i] = &fld{expr: &ident{v.name}, name: v.name} - } - out = make([]interface{}, len(r.flds)) - } - return true, nil - }); err != nil { - return err - } - - if rows { - return nil - } - - m := map[interface{}]interface{}{"$agg0": true} // aggregate empty record set - for i, fld := range r.flds { - if out[i], err = fld.expr.eval(ctx, m); err != nil { - return err - } - } - _, err = f(nil, out) - - return err -} - -type sysColumnDefaultPlan struct{} - -func (r *sysColumnDefaultPlan) hasID() bool { return false } - -func (r *sysColumnDefaultPlan) explain(w strutil.Formatter) { - w.Format("┌Iterate all rows of table \"__Column\"\n└Output field names %v\n", qnames(r.fieldNames())) -} - -func (r *sysColumnDefaultPlan) filter(expr expression) (plan, []string, error) { - return nil, nil, nil -} - -func (r *sysColumnDefaultPlan) fieldNames() []string { - return []string{"TableName", "Ordinal", "Name", "Type"} -} - -func (r *sysColumnDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (bool, error)) error { - rec := make([]interface{}, 4) - di, err := ctx.db.info() - if err != nil { - return err - } - - var id int64 - for _, ti := range di.Tables { - rec[0] = ti.Name - var ix int64 - for _, ci := range ti.Columns { - ix++ - rec[1] = ix - rec[2] = ci.Name - rec[3] = ci.Type.String() - id++ - if more, err := f(id, rec); !more || err != nil { - return err - } - } - } - return nil -} - -type sysIndexDefaultPlan struct{} - -func (r *sysIndexDefaultPlan) hasID() bool { return false } - -func (r *sysIndexDefaultPlan) explain(w strutil.Formatter) { - w.Format("┌Iterate all rows of table \"__Index\"\n└Output field names %v\n", qnames(r.fieldNames())) -} - -func (r *sysIndexDefaultPlan) filter(expr expression) (plan, []string, error) { - return nil, nil, nil -} - -func (r *sysIndexDefaultPlan) fieldNames() []string { - return []string{"TableName", "ColumnName", "Name", "IsUnique"} -} - -func (r *sysIndexDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (bool, error)) error { - rec := make([]interface{}, 4) - di, err := ctx.db.info() - if err != nil { - return err - } - - var id int64 - for _, xi := range di.Indices { - rec[0] = xi.Table - rec[1] = xi.Column - rec[2] = xi.Name - rec[3] = xi.Unique - id++ - if more, err := f(id, rec); !more || err != nil { - return err - } - } - return nil -} - -type sysTableDefaultPlan struct{} - -func (r *sysTableDefaultPlan) hasID() bool { return false } - -func (r *sysTableDefaultPlan) explain(w strutil.Formatter) { - w.Format("┌Iterate all rows of table \"__Table\"\n└Output field names %v\n", qnames(r.fieldNames())) -} - -func (r *sysTableDefaultPlan) filter(expr expression) (plan, []string, error) { - return nil, nil, nil -} - -func (r *sysTableDefaultPlan) fieldNames() []string { return []string{"Name", "Schema"} } - -func (r *sysTableDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (bool, error)) error { - rec := make([]interface{}, 2) - di, err := ctx.db.info() - if err != nil { - return err - } - - var id int64 - for _, ti := range di.Tables { - rec[0] = ti.Name - a := []string{} - for _, ci := range ti.Columns { - s := "" - if ci.NotNull { - s += " NOT NULL" - } - if c := ci.Constraint; c != "" { - s += " " + c - } - if d := ci.Default; d != "" { - s += " DEFAULT " + d - } - a = append(a, fmt.Sprintf("%s %s%s", ci.Name, ci.Type, s)) - } - rec[1] = fmt.Sprintf("CREATE TABLE %s (%s);", ti.Name, strings.Join(a, ", ")) - id++ - if more, err := f(id, rec); !more || err != nil { - return err - } - } - return nil -} - -type tableNilPlan struct { - t *table -} - -func (r *tableNilPlan) hasID() bool { return true } - -func (r *tableNilPlan) explain(w strutil.Formatter) { - w.Format("┌Iterate all rows of table %q\n└Output field names %v\n", r.t.name, qnames(r.fieldNames())) -} - -func (r *tableNilPlan) fieldNames() []string { return []string{} } - -func (r *tableNilPlan) filter(expr expression) (plan, []string, error) { - return nil, nil, nil -} - -func (r *tableNilPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (bool, error)) (err error) { - t := r.t - h := t.head - cols := t.cols - for h > 0 { - rec, err := t.store.Read(nil, h, cols...) // 0:next, 1:id, 2...: data - if err != nil { - return err - } - - if m, err := f(rec[1], nil); !m || err != nil { - return err - } - - h = rec[0].(int64) // next - } - return nil -} - -type tableDefaultPlan struct { - t *table - fields []string -} - -func (r *tableDefaultPlan) hasID() bool { return true } - -func (r *tableDefaultPlan) explain(w strutil.Formatter) { - w.Format("┌Iterate all rows of table %q\n└Output field names %v\n", r.t.name, qnames(r.fields)) -} - -func (r *tableDefaultPlan) filterBinOp(x *binaryOperation) (plan, []string, error) { - ok, cn, rval, err := x.isIdentRelOpVal() - if err != nil { - return nil, nil, err - } - - if !ok { - return nil, nil, nil - } - - t := r.t - c, ix := t.findIndexByColName(cn) - if ix == nil { // Column cn has no index. - return nil, []string{fmt.Sprintf("%s(%s)", t.name, cn)}, nil - } - - if rval, err = typeCheck1(rval, c); err != nil { - return nil, nil, err - } - - switch x.op { - case eq: - return &indexPlan{t, cn, ix.name, ix.x, indexEq, rval, rval}, nil, nil - case '<': - return &indexPlan{t, cn, ix.name, ix.x, indexLt, nil, rval}, nil, nil - case le: - return &indexPlan{t, cn, ix.name, ix.x, indexLe, nil, rval}, nil, nil - case ge: - return &indexPlan{t, cn, ix.name, ix.x, indexGe, rval, nil}, nil, nil - case '>': - return &indexPlan{t, cn, ix.name, ix.x, indexGt, rval, nil}, nil, nil - case neq: - return &indexPlan{t, cn, ix.name, ix.x, indexNe, rval, rval}, nil, nil - default: - panic("internal error 069") - } -} - -func (r *tableDefaultPlan) filterIdent(x *ident, trueValue bool) (plan, []string, error) { - cn := x.s - t := r.t - for _, v := range t.cols { - if v.name != cn { - continue - } - - if v.typ != qBool { - return nil, nil, nil - } - - xi := v.index + 1 // 0: id() - if xi >= len(t.indices) { - return nil, nil, nil - } - - ix := t.indices[xi] - if ix == nil { // Column cn has no index. - return nil, []string{fmt.Sprintf("%s(%s)", t.name, cn)}, nil - } - - kind := indexFalse - if trueValue { - kind = indexTrue - } - return &indexPlan{t, cn, ix.name, ix.x, kind, nil, nil}, nil, nil - } - return nil, nil, nil -} - -func (r *tableDefaultPlan) filterIsNull(x *isNull) (plan, []string, error) { - ok, cn := isColumnExpression(x.expr) - if !ok { - return nil, nil, nil - } - - t := r.t - _, ix := t.findIndexByColName(cn) - if ix == nil { // Column cn has no index. - return nil, []string{fmt.Sprintf("%s(%s)", t.name, cn)}, nil - } - - switch { - case x.not: - return &indexPlan{t, cn, ix.name, ix.x, indexIsNotNull, nil, nil}, nil, nil - default: - return &indexPlan{t, cn, ix.name, ix.x, indexIsNull, nil, nil}, nil, nil - } -} - -func (r *tableDefaultPlan) filter(expr expression) (plan, []string, error) { - cols := mentionedColumns(expr) - for _, v := range r.fields { - delete(cols, v) - } - for k := range cols { - return nil, nil, fmt.Errorf("unknown field %s", k) - } - - var is []string - - //TODO var sexpr string - //TODO for _, ix := range t.indices2 { - //TODO if len(ix.exprList) != 1 { - //TODO continue - //TODO } - - //TODO if sexpr == "" { - //TODO sexpr = expr.String() - //TODO } - //TODO if ix.sources[0] != sexpr { - //TODO continue - //TODO } - - //TODO } - - switch x := expr.(type) { - case *binaryOperation: - return r.filterBinOp(x) - case *ident: - return r.filterIdent(x, true) - case *isNull: - return r.filterIsNull(x) - case *unaryOperation: - if x.op != '!' { - break - } - - if operand, ok := x.v.(*ident); ok { - return r.filterIdent(operand, false) - } - default: - //dbg("", expr) - return nil, is, nil //TODO - } - - return nil, is, nil -} - -func (r *tableDefaultPlan) do(ctx *execCtx, f func(interface{}, []interface{}) (bool, error)) (err error) { - t := r.t - cols := t.cols - h := t.head - for h > 0 { - rec, err := t.row0(ctx, h) - if err != nil { - return err - } - - h = rec[0].(int64) - id := rec[1].(int64) - for i, c := range cols { - rec[i] = rec[c.index+2] - } - if m, err := f(id, rec[:len(cols)]); !m || err != nil { - return err - } - } - return nil -} - -func (r *tableDefaultPlan) fieldNames() []string { return r.fields } - -type nullPlan struct { - fields []string -} - -func (r *nullPlan) hasID() bool { return false } - -func (r *nullPlan) fieldNames() []string { return r.fields } - -func (r *nullPlan) explain(w strutil.Formatter) { - w.Format("┌Iterate no rows\n└Output field names %v\n", qnames(r.fields)) -} - -func (r *nullPlan) do(*execCtx, func(interface{}, []interface{}) (bool, error)) error { - return nil -} - -func (r *nullPlan) filter(expr expression) (plan, []string, error) { - return r, nil, nil -} - -type leftJoinDefaultPlan struct { - on expression - rsets []plan - names []string - right int - fields []string -} - -func (r *leftJoinDefaultPlan) hasID() bool { return false } - -func (r *leftJoinDefaultPlan) explain(w strutil.Formatter) { - w.Format("┌Compute Cartesian product of%i\n") - for i, v := range r.rsets { - sel := !isTableOrIndex(v) - if sel { - w.Format("┌Iterate all rows of virtual table %q%i\n", r.names[i]) - } - v.explain(w) - if sel { - w.Format("%u└Output field names %v\n", qnames(v.fieldNames())) - } - } - w.Format("Extend the product with all NULL rows of %q when no match for %v%u\n", r.names[len(r.names)-1], r.on) - w.Format("└Output field names %v\n", qnames(r.fields)) -} - -func (r *leftJoinDefaultPlan) filter(expr expression) (plan, []string, error) { - var is []string - for i, v := range r.names { - e2, err := expr.clone(nil, v) - if err != nil { - return nil, nil, err - } - - p2, is2, err := r.rsets[i].filter(e2) - is = append(is, is2...) - if err != nil { - return nil, nil, err - } - - if p2 != nil { - r.rsets[i] = p2 - return r, is, nil - } - } - return nil, is, nil -} - -type rightJoinDefaultPlan struct { - leftJoinDefaultPlan -} - -func (r *rightJoinDefaultPlan) hasID() bool { return false } - -func (r *rightJoinDefaultPlan) explain(w strutil.Formatter) { - w.Format("┌Compute Cartesian product of%i\n") - for i, v := range r.rsets { - sel := !isTableOrIndex(v) - if sel { - w.Format("┌Iterate all rows of virtual table %q%i\n", r.names[i]) - } - v.explain(w) - if sel { - w.Format("%u└Output field names %v\n", qnames(v.fieldNames())) - } - } - w.Format("Extend the product with all NULL rows of all but %q when no match for %v%u\n", r.names[len(r.names)-1], r.on) - w.Format("└Output field names %v\n", qnames(r.fields)) -} - -func (r *rightJoinDefaultPlan) filter(expr expression) (plan, []string, error) { - var is []string - for i, v := range r.names { - e2, err := expr.clone(nil, v) - if err != nil { - return nil, nil, err - } - - p2, is2, err := r.rsets[i].filter(e2) - is = append(is, is2...) - if err != nil { - return nil, nil, err - } - - if p2 != nil { - r.rsets[i] = p2 - return r, is, nil - } - } - return nil, is, nil -} - -type fullJoinDefaultPlan struct { - leftJoinDefaultPlan -} - -func (r *fullJoinDefaultPlan) hasID() bool { return false } - -func (r *fullJoinDefaultPlan) explain(w strutil.Formatter) { - w.Format("┌Compute Cartesian product of%i\n") - for i, v := range r.rsets { - sel := !isTableOrIndex(v) - if sel { - w.Format("┌Iterate all rows of virtual table %q%i\n", r.names[i]) - } - v.explain(w) - if sel { - w.Format("%u└Output field names %v\n", qnames(v.fieldNames())) - } - } - w.Format("Extend the product with all NULL rows of %q when no match for %v\n", r.names[len(r.names)-1], r.on) - w.Format("Extend the product with all NULL rows of all but %q when no match for %v%u\n", r.names[len(r.names)-1], r.on) - w.Format("└Output field names %v\n", qnames(r.fields)) -} - -func (r *fullJoinDefaultPlan) filter(expr expression) (plan, []string, error) { - var is []string - for i, v := range r.names { - e2, err := expr.clone(nil, v) - if err != nil { - return nil, nil, err - } - - p2, is2, err := r.rsets[i].filter(e2) - is = append(is, is2...) - if err != nil { - return nil, nil, err - } - - if p2 != nil { - r.rsets[i] = p2 - return r, is, nil - } - } - return nil, is, nil -} - -func (r *leftJoinDefaultPlan) fieldNames() []string { return r.fields } - -func (r *leftJoinDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (more bool, err error)) error { - m := map[interface{}]interface{}{} - ids := map[string]interface{}{} - var g func([]interface{}, []plan, int) error - var match bool - g = func(prefix []interface{}, rsets []plan, x int) (err error) { - return rsets[0].do(ctx, func(id interface{}, in []interface{}) (bool, error) { - ids[r.names[x]] = id - row := append(prefix, in...) - if len(rsets) > 1 { - if len(rsets) == 2 { - match = false - } - if err = g(row, rsets[1:], x+1); err != nil { - return false, err - } - - if len(rsets) != 2 || match { - return true, nil - } - - ids[r.names[x+1]] = nil - return f(ids, append(row, make([]interface{}, r.right)...)) - } - - for i, fld := range r.fields { - if fld != "" { - m[fld] = row[i] - } - } - - val, err := r.on.eval(ctx, m) - if err != nil { - return false, err - } - - if val == nil { - return true, nil - } - - x, ok := val.(bool) - if !ok { - return false, fmt.Errorf("invalid ON expression %s (value of type %T)", val, val) - } - - if !x { - return true, nil - } - - match = true - return f(ids, row) - }) - } - return g(nil, r.rsets, 0) -} - -func (r *rightJoinDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (more bool, err error)) error { - right := r.right - left := len(r.fields) - right - n := len(r.rsets) - m := map[interface{}]interface{}{} - ids := map[string]interface{}{} - var g func([]interface{}, []plan, int) error - var match bool - nf := len(r.fields) - fields := append(append([]string(nil), r.fields[nf-right:]...), r.fields[:nf-right]...) - g = func(prefix []interface{}, rsets []plan, x int) (err error) { - return rsets[0].do(ctx, func(id interface{}, in []interface{}) (bool, error) { - ids[r.names[x]] = id - row := append(prefix, in...) - if len(rsets) > 1 { - if len(rsets) == n { - match = false - } - if err = g(row, rsets[1:], x+1); err != nil { - return false, err - } - - if len(rsets) != n || match { - return true, nil - } - - for i := 0; i < n-1; i++ { - ids[r.names[i]] = nil - } - - // rigth, left -> left, right - return f(ids, append(make([]interface{}, left), row[:right]...)) - } - - for i, fld := range fields { - if fld != "" { - m[fld] = row[i] - } - } - - val, err := r.on.eval(ctx, m) - if err != nil { - return false, err - } - - if val == nil { - return true, nil - } - - x, ok := val.(bool) - if !ok { - return false, fmt.Errorf("invalid ON expression %s (value of type %T)", val, val) - } - - if !x { - return true, nil - } - - match = true - // rigth, left -> left, right - return f(ids, append(append([]interface{}(nil), row[right:]...), row[:right]...)) - }) - } - return g(nil, append([]plan{r.rsets[n-1]}, r.rsets[:n-1]...), 0) -} - -func (r *fullJoinDefaultPlan) do(ctx *execCtx, f func(id interface{}, data []interface{}) (more bool, err error)) error { - b3 := b.TreeNew(func(a, b interface{}) int { - x := a.(int64) - y := b.(int64) - if x < y { - return -1 - } - - if x == y { - return 0 - } - - return 1 - }) - m := map[interface{}]interface{}{} - ids := map[string]interface{}{} - var g func([]interface{}, []plan, int) error - var match bool - var rid int64 - firstR := true - g = func(prefix []interface{}, rsets []plan, x int) (err error) { - return rsets[0].do(ctx, func(id interface{}, in []interface{}) (bool, error) { - ids[r.names[x]] = id - row := append(prefix, in...) - if len(rsets) > 1 { - if len(rsets) == 2 { - match = false - rid = 0 - } - if err = g(row, rsets[1:], x+1); err != nil { - return false, err - } - - if len(rsets) == 2 { - firstR = false - } - if len(rsets) != 2 || match { - return true, nil - } - - ids[r.names[x+1]] = nil - return f(ids, append(row, make([]interface{}, r.right)...)) - } - - rid++ - if firstR { - b3.Set(rid, in) - } - for i, fld := range r.fields { - if fld != "" { - m[fld] = row[i] - } - } - - val, err := r.on.eval(ctx, m) - if err != nil { - return false, err - } - - if val == nil { - return true, nil - } - - x, ok := val.(bool) - if !ok { - return false, fmt.Errorf("invalid ON expression %s (value of type %T)", val, val) - } - - if !x { - return true, nil - } - - match = true - b3.Delete(rid) - return f(ids, row) - }) - } - if err := g(nil, r.rsets, 0); err != nil { - return err - } - - it, err := b3.SeekFirst() - if err != nil { - return noEOF(err) - } - - pref := make([]interface{}, len(r.fields)-r.right) - for { - _, v, err := it.Next() - if err != nil { - return noEOF(err) - } - - more, err := f(nil, append(pref, v.([]interface{})...)) - if err != nil || !more { - return err - } - } -} diff --git a/Godeps/_workspace/src/github.com/cznic/ql/ql.ebnf b/Godeps/_workspace/src/github.com/cznic/ql/ql.ebnf deleted file mode 100644 index f8b418d8cf..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/ql.ebnf +++ /dev/null @@ -1,225 +0,0 @@ -andand = "&&" . -andnot = "&^" . -ascii_letter = "a" … "z" | "A" … "Z" . -big_u_value = "\\" "U" hex_digit hex_digit hex_digit hex_digit hex_digit hex_digit hex_digit hex_digit . -byte_value = octal_byte_value | hex_byte_value . -decimal_digit = "0" … "9" . -decimal_lit = ( "1" … "9" ) { decimal_digit } . -decimals = decimal_digit { decimal_digit } . -eq = "==" . -escaped_char = "\\" ( - "a" - | "b" - | "f" - | "n" - | "r" - | "t" - | "v" - | "\\" - | "'" - | "\"" - ) . -exponent = ( "e" | "E" ) [ "+" | "-" ] decimals . -float_lit = decimals "." [ decimals ] [ exponent ] - | decimals exponent - | "." decimals [ exponent ] . -ge = ">=" . -hex_byte_value = "\\" "x" hex_digit hex_digit . -hex_digit = "0" … "9" - | "A" … "F" - | "a" … "f" . -hex_lit = "0" ( "x" | "X" ) hex_digit { hex_digit } . -identifier = letter { letter | decimal_digit } . -imaginary_lit = ( decimals | float_lit ) "i" . -int_lit = decimal_lit - | octal_lit - | hex_lit . -interpreted_string_lit = "\"" { unicode_value | byte_value } "\"" . -le = "<=" . -letter = ascii_letter | "_" . -little_u_value = "\\" "u" hex_digit hex_digit hex_digit hex_digit . -lsh = "<<" . -neq = "!=" . -newline = . -octal_byte_value = "\\" octal_digit octal_digit octal_digit . -octal_digit = "0" … "7" . -octal_lit = "0" { octal_digit } . -oror = "||" . -ql_parameter = ( "?" | "$" ) "1" … "9" { "0" … "9" } . -raw_string_lit = "`" { unicode_char | newline } "`" . -rsh = ">>" . -rune_lit = "'" ( unicode_value | byte_value ) "'" . -string_lit = raw_string_lit | interpreted_string_lit . -unicode_char = . -unicode_value = unicode_char - | little_u_value - | big_u_value - | escaped_char . - -AlterTableStmt = "ALTER" "TABLE" TableName ( - "ADD" ColumnDef - | "DROP" "COLUMN" ColumnName - ) . -Assignment = ColumnName "=" Expression . -AssignmentList = Assignment { "," Assignment } [ "," ] . -BeginTransactionStmt = "BEGIN" "TRANSACTION" . -Call = "(" [ "*" | ExpressionList ] ")" . -ColumnDef = ColumnName Type [ - "NOT" "NULL" - | Expression - ] [ "DEFAULT" Expression ] . -ColumnName = identifier . -ColumnNameList = ColumnName { "," ColumnName } [ "," ] . -CommitStmt = "COMMIT" . -Conversion = Type "(" Expression ")" . -CreateIndexStmt = "CREATE" [ "UNIQUE" ] "INDEX" [ - "IF" "NOT" "EXISTS" - ] IndexName "ON" TableName "(" ExpressionList ")" . -CreateTableStmt = "CREATE" "TABLE" [ - "IF" "NOT" "EXISTS" - ] TableName "(" ColumnDef { "," ColumnDef } [ "," ] ")" . -DeleteFromStmt = "DELETE" "FROM" TableName [ WhereClause ] . -DropIndexStmt = "DROP" "INDEX" [ "IF" "EXISTS" ] IndexName . -DropTableStmt = "DROP" "TABLE" [ "IF" "EXISTS" ] TableName . -EmptyStmt = . -ExplainStmt = "EXPLAIN" Statement . -Expression = Term { - ( oror | "OR" ) Term - } . -ExpressionList = Expression { "," Expression } [ "," ] . -Factor = PrimaryFactor { - ( - ge - | ">" - | le - | "<" - | neq - | eq - | "LIKE" - ) PrimaryFactor - } [ Predicate ] . -Field = Expression [ "AS" identifier ] . -FieldList = Field { "," Field } [ "," ] . -GroupByClause = "GROUP BY" ColumnNameList . -Index = "[" Expression "]" . -IndexName = identifier . -InsertIntoStmt = "INSERT" "INTO" TableName [ - "(" ColumnNameList ")" - ] ( Values | SelectStmt ) . -JoinClause = ( - "LEFT" - | "RIGHT" - | "FULL" - ) [ "OUTER" ] "JOIN" RecordSet "ON" Expression . -Limit = "Limit" Expression . -Literal = "FALSE" - | "NULL" - | "TRUE" - | float_lit - | imaginary_lit - | int_lit - | rune_lit - | string_lit - | ql_parameter . -Offset = "OFFSET" Expression . -Operand = Literal - | QualifiedIdent - | "(" Expression ")" . -OrderBy = "ORDER" "BY" ExpressionList [ "ASC" | "DESC" ] . -Predicate = ( - [ "NOT" ] ( - "IN" "(" ExpressionList ")" - | "IN" "(" SelectStmt [ ";" ] ")" - | "BETWEEN" PrimaryFactor "AND" PrimaryFactor - ) - | "IS" [ "NOT" ] "NULL" - ) . -PrimaryExpression = Operand - | Conversion - | PrimaryExpression Index - | PrimaryExpression Slice - | PrimaryExpression Call . -PrimaryFactor = PrimaryTerm { - ( - "^" - | "|" - | "-" - | "+" - ) PrimaryTerm - } . -PrimaryTerm = UnaryExpr { - ( - andnot - | "&" - | lsh - | rsh - | "%" - | "/" - | "*" - ) UnaryExpr - } . -QualifiedIdent = identifier [ "." identifier ] . -RecordSet = ( - TableName - | "(" SelectStmt [ ";" ] ")" - ) [ "AS" identifier ] . -RecordSetList = RecordSet { "," RecordSet } [ "," ] . -RollbackStmt = "ROLLBACK" . -SelectStmt = "SELECT" [ "DISTINCT" ] ( "*" | FieldList ) "FROM" RecordSetList [ JoinClause ] [ WhereClause ] [ GroupByClause ] [ OrderBy ] [ Limit ] [ Offset ] . -Slice = "[" [ Expression ] ":" [ Expression ] "]" . -Statement = EmptyStmt - | AlterTableStmt - | BeginTransactionStmt - | CommitStmt - | CreateIndexStmt - | CreateTableStmt - | DeleteFromStmt - | DropIndexStmt - | DropTableStmt - | InsertIntoStmt - | RollbackStmt - | SelectStmt - | TruncateTableStmt - | UpdateStmt - | ExplainStmt . -StatementList = Statement { ";" Statement } . -TableName = identifier . -Term = Factor { - ( andand | "AND" ) Factor - } . -TruncateTableStmt = "TRUNCATE" "TABLE" TableName . -Type = "bigint" - | "bigrat" - | "blob" - | "bool" - | "byte" - | "complex128" - | "complex64" - | "duration" - | "float" - | "float32" - | "float64" - | "int" - | "int16" - | "int32" - | "int64" - | "int8" - | "rune" - | "string" - | "time" - | "uint" - | "uint16" - | "uint32" - | "uint64" - | "uint8" . -UnaryExpr = [ - "^" - | "!" - | "-" - | "+" - ] PrimaryExpression . -UpdateStmt = "UPDATE" TableName [ "SET" ] AssignmentList [ WhereClause ] . -Values = "VALUES" "(" ExpressionList ")" { - "," "(" ExpressionList ")" - } [ "," ] . -WhereClause = "WHERE" Expression . diff --git a/Godeps/_workspace/src/github.com/cznic/ql/ql.go b/Godeps/_workspace/src/github.com/cznic/ql/ql.go deleted file mode 100644 index 82c3c5fa58..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/ql.go +++ /dev/null @@ -1,1729 +0,0 @@ -// Copyright 2014 The ql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//LATER profile mem -//LATER profile cpu -//LATER coverage - -package ql - -import ( - "bytes" - "errors" - "fmt" - "math/big" - "strconv" - "strings" - "sync" - "time" - - "github.com/cznic/strutil" -) - -const ( - crossJoin = iota - leftJoin - rightJoin - fullJoin -) - -// NOTE: all rset implementations must be safe for concurrent use by multiple -// goroutines. If the do method requires any execution domain local data, they -// must be held out of the implementing instance. -var ( - _ rset = (*distinctRset)(nil) - _ rset = (*groupByRset)(nil) - _ rset = (*joinRset)(nil) - _ rset = (*limitRset)(nil) - _ rset = (*offsetRset)(nil) - _ rset = (*orderByRset)(nil) - _ rset = (*selectRset)(nil) - _ rset = (*selectStmt)(nil) - _ rset = (*tableRset)(nil) - _ rset = (*whereRset)(nil) - - isTesting bool // enables test hook: select from an index -) - -type rset interface { - plan(ctx *execCtx) (plan, error) -} - -type recordset struct { - ctx *execCtx - plan - tx *TCtx -} - -func (r recordset) fieldNames() []interface{} { - f := r.plan.fieldNames() - a := make([]interface{}, len(f)) - for i, v := range f { - a[i] = v - } - return a -} - -// Do implements Recordset. -func (r recordset) Do(names bool, f func(data []interface{}) (bool, error)) error { - if names { - if more, err := f(r.fieldNames()); err != nil || !more { - return err - } - } - return r.ctx.db.do(r, f) -} - -// Fields implements Recordset. -func (r recordset) Fields() (names []string, err error) { - return r.plan.fieldNames(), nil -} - -// FirstRow implements Recordset. -func (r recordset) FirstRow() (row []interface{}, err error) { - rows, err := r.Rows(1, 0) - if err != nil { - return nil, err - } - - if len(rows) != 0 { - return rows[0], nil - } - - return nil, nil -} - -// Rows implements Recordset. -func (r recordset) Rows(limit, offset int) ([][]interface{}, error) { - var rows [][]interface{} - if err := r.Do(false, func(row []interface{}) (bool, error) { - if offset > 0 { - offset-- - return true, nil - } - - switch { - case limit < 0: - rows = append(rows, row) - return true, nil - case limit == 0: - return false, nil - default: // limit > 0 - rows = append(rows, row) - limit-- - return limit > 0, nil - } - }); err != nil { - return nil, err - } - - return rows, nil -} - -// List represents a group of compiled statements. -type List struct { - l []stmt - params int -} - -// String implements fmt.Stringer -func (l List) String() string { - var b bytes.Buffer - f := strutil.IndentFormatter(&b, "\t") - for _, s := range l.l { - switch s.(type) { - case beginTransactionStmt: - f.Format("%s\n%i", s) - case commitStmt, rollbackStmt: - f.Format("%u%s\n", s) - default: - f.Format("%s\n", s) - } - } - return b.String() -} - -// IsExplainStmt reports whether l is a single EXPLAIN statment or a single EXPLAIN -// statment enclosed in a transaction. -func (l List) IsExplainStmt() bool { - switch len(l.l) { - case 1: - _, ok := l.l[0].(*explainStmt) - return ok - case 3: - if _, ok := l.l[0].(beginTransactionStmt); !ok { - return false - } - if _, ok := l.l[1].(*explainStmt); !ok { - return false - } - _, ok := l.l[2].(commitStmt) - return ok - default: - return false - } -} - -type groupByRset struct { - colNames []string - src plan -} - -func (r *groupByRset) plan(ctx *execCtx) (plan, error) { - fields := r.src.fieldNames() - for _, v := range r.colNames { - found := false - for _, v2 := range fields { - if v == v2 { - found = true - break - } - } - if !found { - return nil, fmt.Errorf("unknown field %s", v) - } - } - return &groupByDefaultPlan{colNames: r.colNames, src: r.src, fields: fields}, nil -} - -// TCtx represents transaction context. It enables to execute multiple -// statement lists in the same context. The same context guarantees the state -// of the DB cannot change in between the separated executions. -// -// LastInsertID -// -// LastInsertID is updated by INSERT INTO statements. The value considers -// performed ROLLBACK statements, if any, even though roll backed IDs are not -// reused. QL clients should treat the field as read only. -// -// RowsAffected -// -// RowsAffected is updated by INSERT INTO, DELETE FROM and UPDATE statements. -// The value does not (yet) consider any ROLLBACK statements involved. QL -// clients should treat the field as read only. -type TCtx struct { - LastInsertID int64 - RowsAffected int64 -} - -// NewRWCtx returns a new read/write transaction context. NewRWCtx is safe for -// concurrent use by multiple goroutines, every one of them will get a new, -// unique conext. -func NewRWCtx() *TCtx { return &TCtx{} } - -// Recordset is a result of a select statment. It can call a user function for -// every row (record) in the set using the Do method. -// -// Recordsets can be safely reused. Evaluation of the rows is performed lazily. -// Every invocation of Do will see the current, potentially actualized data. -// -// Do -// -// Do will call f for every row (record) in the Recordset. -// -// If f returns more == false or err != nil then f will not be called for any -// remaining rows in the set and the err value is returned from Do. -// -// If names == true then f is firstly called with a virtual row -// consisting of field (column) names of the RecordSet. -// -// Do is executed in a read only context and performs a RLock of the -// database. -// -// Do is safe for concurrent use by multiple goroutines. -// -// Fields -// -// Fields return a slice of field names of the recordset. The result is computed -// without actually computing the recordset rows. -// -// FirstRow -// -// FirstRow will return the first row of the RecordSet or an error, if any. If -// the Recordset has no rows the result is (nil, nil). -// -// Rows -// -// Rows will return rows in Recordset or an error, if any. The semantics of -// limit and offset are the same as of the LIMIT and OFFSET clauses of the -// SELECT statement. To get all rows pass limit < 0. If there are no rows to -// return the result is (nil, nil). -type Recordset interface { - Do(names bool, f func(data []interface{}) (more bool, err error)) error - Fields() (names []string, err error) - FirstRow() (row []interface{}, err error) - Rows(limit, offset int) (rows [][]interface{}, err error) -} - -type assignment struct { - colName string - expr expression -} - -func (a *assignment) String() string { - return fmt.Sprintf("%s=%s", a.colName, a.expr) -} - -type distinctRset struct { - src plan -} - -func (r *distinctRset) plan(ctx *execCtx) (plan, error) { - return &distinctDefaultPlan{src: r.src, fields: r.src.fieldNames()}, nil -} - -type orderByRset struct { - asc bool - by []expression - src plan -} - -func (r *orderByRset) String() string { - a := make([]string, len(r.by)) - for i, v := range r.by { - a[i] = v.String() - } - s := strings.Join(a, ", ") - if !r.asc { - s += " DESC" - } - return s -} - -func (r *orderByRset) plan(ctx *execCtx) (plan, error) { - if _, ok := r.src.(*nullPlan); ok { - return r.src, nil - } - - var by []expression - fields := r.src.fieldNames() - for _, e := range r.by { - cols := mentionedColumns(e) - for k := range cols { - found := false - for _, v := range fields { - if k == v { - found = true - break - } - } - if !found { - return nil, fmt.Errorf("unknown field %s", k) - } - } - if len(cols) == 0 { - v, err := e.eval(ctx, nil) - if err != nil { - by = append(by, e) - continue - } - - if isConstValue(v) != nil { - continue - } - } - - by = append(by, e) - } - return &orderByDefaultPlan{asc: r.asc, by: by, src: r.src, fields: fields}, nil -} - -type whereRset struct { - expr expression - src plan -} - -func (r *whereRset) planBinOp(x *binaryOperation) (plan, error) { - p := r.src - ok, cn := isColumnExpression(x.l) - if ok && cn == "id()" { - if v := isConstValue(x.r); v != nil { - v, err := typeCheck1(v, idCol) - if err != nil { - return nil, err - } - - rv := v.(int64) - switch { - case p.hasID(): - switch x.op { - case '<': - if rv <= 1 { - return &nullPlan{p.fieldNames()}, nil - } - case '>': - if rv <= 0 { - return p, nil - } - case ge: - if rv >= 1 { - return p, nil - } - case neq: - if rv <= 0 { - return p, nil - } - case eq: - if rv <= 0 { - return &nullPlan{p.fieldNames()}, nil - } - case le: - if rv <= 0 { - return &nullPlan{p.fieldNames()}, nil - } - } - } - } - } - - var err error - var p2 plan - var is []string - switch x.op { - case eq, ge, '>', le, '<', neq: - if p2, is, err = p.filter(x); err != nil { - return nil, err - } - - if p2 != nil { - return p2, nil - } - case andand: - var in []expression - var f func(expression) - f = func(e expression) { - b, ok := e.(*binaryOperation) - if !ok || b.op != andand { - in = append(in, e) - return - } - - f(b.l) - f(b.r) - } - f(x) - out := []expression{} - p := r.src - isNewPlan := false - for _, e := range in { - p2, is2, err := p.filter(e) - if err != nil { - return nil, err - } - - if p2 == nil { - is = append(is, is2...) - out = append(out, e) - continue - } - - p = p2 - isNewPlan = true - } - - if !isNewPlan { - break - } - - if len(out) == 0 { - return p, nil - } - - for len(out) > 1 { - n := len(out) - e, err := newBinaryOperation(andand, out[n-2], out[n-1]) - if err != nil { - return nil, err - } - - out = out[:n-1] - out[n-2] = e - } - - return &filterDefaultPlan{p, out[0], is}, nil - } - - return &filterDefaultPlan{p, x, is}, nil -} - -func (r *whereRset) planIdent(x *ident) (plan, error) { - p := r.src - p2, is, err := p.filter(x) - if err != nil { - return nil, err - } - - if p2 != nil { - return p2, nil - } - - return &filterDefaultPlan{p, x, is}, nil -} - -func (r *whereRset) planIsNull(x *isNull) (plan, error) { - p := r.src - ok, cn := isColumnExpression(x.expr) - if !ok { - return &filterDefaultPlan{p, x, nil}, nil - } - - if cn == "id()" { - switch { - case p.hasID(): - switch { - case x.not: // IS NOT NULL - return p, nil - default: // IS NULL - return &nullPlan{p.fieldNames()}, nil - } - default: - switch { - case x.not: // IS NOT NULL - return &nullPlan{p.fieldNames()}, nil - default: // IS NULL - return p, nil - } - } - } - - p2, is, err := p.filter(x) - if err != nil { - return nil, err - } - - if p2 != nil { - return p2, nil - } - - return &filterDefaultPlan{p, x, is}, nil -} - -func (r *whereRset) planUnaryOp(x *unaryOperation) (plan, error) { - p := r.src - p2, is, err := p.filter(x) - if err != nil { - return nil, err - } - - if p2 != nil { - return p2, nil - } - - return &filterDefaultPlan{p, x, is}, nil -} - -func (r *whereRset) plan(ctx *execCtx) (plan, error) { - expr, err := r.expr.clone(ctx.arg) - if err != nil { - return nil, err - } - - switch r.src.(type) { - case *leftJoinDefaultPlan, *rightJoinDefaultPlan, *fullJoinDefaultPlan: - return &filterDefaultPlan{r.src, expr, nil}, nil - } - - switch x := expr.(type) { - case *binaryOperation: - return r.planBinOp(x) - case *ident: - return r.planIdent(x) - case *isNull: - return r.planIsNull(x) - case *pIn: - //TODO optimize - //TODO show plan - case *pLike: - //TODO optimize - case *unaryOperation: - return r.planUnaryOp(x) - } - - return &filterDefaultPlan{r.src, expr, nil}, nil -} - -type offsetRset struct { - expr expression - src plan -} - -func (r *offsetRset) plan(ctx *execCtx) (plan, error) { - return &offsetDefaultPlan{expr: r.expr, src: r.src, fields: r.src.fieldNames()}, nil -} - -type limitRset struct { - expr expression - src plan -} - -func (r *limitRset) plan(ctx *execCtx) (plan, error) { - return &limitDefaultPlan{expr: r.expr, src: r.src, fields: r.src.fieldNames()}, nil -} - -type selectRset struct { - flds []*fld - src plan -} - -func (r *selectRset) plan(ctx *execCtx) (plan, error) { - var flds2 []*fld - if len(r.flds) != 0 { - m := map[string]struct{}{} - for _, v := range r.flds { - mentionedColumns0(v.expr, true, true, m) - } - for _, v := range r.src.fieldNames() { - delete(m, v) - } - for k := range m { - return nil, fmt.Errorf("unknown field %s", k) - } - - flds2 = append(flds2, r.flds...) - } - - if x, ok := r.src.(*groupByDefaultPlan); ok { - if len(r.flds) == 0 { - fields := x.fieldNames() - flds := make([]*fld, len(fields)) - for i, v := range fields { - flds[i] = &fld{&ident{v}, v} - } - return &selectFieldsGroupPlan{flds: flds, src: x, fields: fields}, nil - } - - p := &selectFieldsGroupPlan{flds: flds2, src: x} - for _, v := range r.flds { - p.fields = append(p.fields, v.name) - } - return p, nil - } - - if len(r.flds) == 0 { - return r.src, nil - } - - f0 := r.src.fieldNames() - if len(f0) == len(flds2) { - match := true - for i, v := range flds2 { - if x, ok := v.expr.(*ident); ok && x.s == f0[i] && v.name == f0[i] { - continue - } - - match = false - break - } - - if match { - return r.src, nil - } - } - - src := r.src - if x, ok := src.(*tableDefaultPlan); ok { - isconst := true - for _, v := range flds2 { - if isConstValue(v.expr) == nil { - isconst = false - break - } - } - if isconst { // #250 - src = &tableNilPlan{x.t} - } - } - - p := &selectFieldsDefaultPlan{flds: flds2, src: src} - for _, v := range r.flds { - p.fields = append(p.fields, v.name) - } - return p, nil -} - -type tableRset string - -func (r tableRset) plan(ctx *execCtx) (plan, error) { - switch r { - case "__Table": - return &sysTableDefaultPlan{}, nil - case "__Column": - return &sysColumnDefaultPlan{}, nil - case "__Index": - return &sysIndexDefaultPlan{}, nil - } - - t, ok := ctx.db.root.tables[string(r)] - if !ok && isTesting { - if _, x0 := ctx.db.root.findIndexByName(string(r)); x0 != nil { - return &selectIndexDefaultPlan{nm: string(r), x: x0}, nil - } - } - - if !ok { - return nil, fmt.Errorf("table %s does not exist", r) - } - - rs := &tableDefaultPlan{t: t} - for _, col := range t.cols { - rs.fields = append(rs.fields, col.name) - } - return rs, nil -} - -func findFldIndex(fields []*fld, name string) int { - for i, f := range fields { - if f.name == name { - return i - } - } - - return -1 -} - -func findFld(fields []*fld, name string) (f *fld) { - for _, f = range fields { - if f.name == name { - return - } - } - - return nil -} - -type col struct { - index int - name string - typ int - constraint *constraint - dflt expression -} - -var idCol = &col{name: "id()", typ: qInt64} - -func findCol(cols []*col, name string) (c *col) { - for _, c = range cols { - if c.name == name { - return - } - } - - return nil -} - -func (f *col) clone() *col { - var r col - r = *f - r.constraint = f.constraint.clone() - if f.dflt != nil { - r.dflt, _ = r.dflt.clone(nil) - } - return &r -} - -func (f *col) typeCheck(x interface{}) (ok bool) { //NTYPE - switch x.(type) { - case nil: - return true - case bool: - return f.typ == qBool - case complex64: - return f.typ == qComplex64 - case complex128: - return f.typ == qComplex128 - case float32: - return f.typ == qFloat32 - case float64: - return f.typ == qFloat64 - case int8: - return f.typ == qInt8 - case int16: - return f.typ == qInt16 - case int32: - return f.typ == qInt32 - case int64: - return f.typ == qInt64 - case string: - return f.typ == qString - case uint8: - return f.typ == qUint8 - case uint16: - return f.typ == qUint16 - case uint32: - return f.typ == qUint32 - case uint64: - return f.typ == qUint64 - case []byte: - return f.typ == qBlob - case *big.Int: - return f.typ == qBigInt - case *big.Rat: - return f.typ == qBigRat - case time.Time: - return f.typ == qTime - case time.Duration: - return f.typ == qDuration - case chunk: - return true // was checked earlier - } - return -} - -func cols2meta(f []*col) (s string) { - a := []string{} - for _, f := range f { - a = append(a, string(f.typ)+f.name) - } - return strings.Join(a, "|") -} - -// DB represent the database capable of executing QL statements. -type DB struct { - cc *TCtx // Current transaction context - isMem bool - mu sync.Mutex - root *root - rw bool // DB FSM - rwmu sync.RWMutex - store storage - tnl int // Transaction nesting level - exprCache map[string]expression - exprCacheMu sync.Mutex - hasIndex2 int // 0: nope, 1: in progress, 2: yes. -} - -var selIndex2Expr = MustCompile("select Expr from __Index2_Expr where Index2_ID == $1") - -func newDB(store storage) (db *DB, err error) { - db0 := &DB{ - exprCache: map[string]expression{}, - store: store, - } - if db0.root, err = newRoot(store); err != nil { - return - } - - ctx := &execCtx{db: db0} - for _, t := range db0.root.tables { - if err := t.constraintsAndDefaults(ctx); err != nil { - return nil, err - } - } - - if !db0.hasAllIndex2() { - return db0, nil - } - - db0.hasIndex2 = 2 - rss, _, err := db0.Run(nil, "select id(), TableName, IndexName, IsUnique, Root from __Index2 where !IsSimple") - if err != nil { - return nil, err - } - - rows, err := rss[0].Rows(-1, 0) - if err != nil { - return nil, err - } - - for _, row := range rows { - defer func() { - if e := recover(); e != nil { - err = fmt.Errorf("error loading DB indices: %v", e) - } - }() - - id := row[0].(int64) - tn := row[1].(string) - xn := row[2].(string) - unique := row[3].(bool) - xroot := row[4].(int64) - - t := db0.root.tables[tn] - if t == nil { - return nil, fmt.Errorf("DB index refers to nonexistent table: %s", tn) - } - - x, err := store.OpenIndex(unique, xroot) - if err != nil { - return nil, err - } - - if v := t.indices2[xn]; v != nil { - return nil, fmt.Errorf("duplicate DB index: %s", xn) - } - - ix := &index2{ - unique: unique, - x: x, - xroot: xroot, - } - - rss, _, err := db0.Execute(nil, selIndex2Expr, id) - if err != nil { - return nil, err - } - - rows, err := rss[0].Rows(-1, 0) - if err != nil { - return nil, err - } - - if len(rows) == 0 { - return nil, fmt.Errorf("index has no expression: %s", xn) - } - - var sources []string - var list []expression - for _, row := range rows { - src, ok := row[0].(string) - if !ok { - return nil, fmt.Errorf("index %s: expression of type %T", xn, row[0]) - } - - expr, err := db0.str2expr(src) - if err != nil { - return nil, fmt.Errorf("index %s: expression error: %v", xn, err) - } - - sources = append(sources, src) - list = append(list, expr) - } - - ix.sources = sources - ix.exprList = list - if t.indices2 == nil { - t.indices2 = map[string]*index2{} - } - t.indices2[xn] = ix - } - return db0, nil -} - -func (db *DB) deleteIndex2ByIndexName(nm string) error { - for _, s := range deleteIndex2ByIndexName.l { - if _, err := s.exec(&execCtx{db: db, arg: []interface{}{nm}}); err != nil { - return err - } - } - return nil -} - -func (db *DB) deleteIndex2ByTableName(nm string) error { - for _, s := range deleteIndex2ByTableName.l { - if _, err := s.exec(&execCtx{db: db, arg: []interface{}{nm}}); err != nil { - return err - } - } - return nil -} - -func (db *DB) createIndex2() error { - if db.hasIndex2 != 0 { - return nil - } - - db.hasIndex2 = 1 - ctx := execCtx{db: db} - for _, s := range createIndex2.l { - if _, err := s.exec(&ctx); err != nil { - db.hasIndex2 = 0 - return err - } - } - - for t := db.root.thead; t != nil; t = t.tnext { - for i, index := range t.indices { - if index == nil { - continue - } - - expr := "id()" - if i != 0 { - expr = t.cols[i-1].name - } - - if err := db.insertIndex2(t.name, index.name, []string{expr}, index.unique, true, index.xroot); err != nil { - db.hasIndex2 = 0 - return err - } - } - } - - db.hasIndex2 = 2 - return nil -} - -func (db *DB) insertIndex2(tableName, indexName string, expr []string, unique, isSimple bool, h int64) error { - ctx := execCtx{db: db} - ctx.arg = []interface{}{ - tableName, - indexName, - unique, - isSimple, - h, - } - if _, err := insertIndex2.l[0].exec(&ctx); err != nil { - return err - } - - id := db.root.lastInsertID - for _, e := range expr { - ctx.arg = []interface{}{id, e} - if _, err := insertIndex2Expr.l[0].exec(&ctx); err != nil { - return err - } - } - return nil -} - -func (db *DB) hasAllIndex2() bool { - t := db.root.tables - if _, ok := t["__Index2"]; !ok { - return false - } - - _, ok := t["__Index2_Expr"] - return ok -} - -func (db *DB) str2expr(expr string) (expression, error) { - db.exprCacheMu.Lock() - e := db.exprCache[expr] - db.exprCacheMu.Unlock() - if e != nil { - return e, nil - } - - e, err := compileExpr(expr) - if err != nil { - return nil, err - } - - db.exprCacheMu.Lock() - for k := range db.exprCache { - if len(db.exprCache) < 1000 { - break - } - - delete(db.exprCache, k) - } - db.exprCache[expr] = e - db.exprCacheMu.Unlock() - return e, nil -} - -// Name returns the name of the DB. -func (db *DB) Name() string { return db.store.Name() } - -// Run compiles and executes a statement list. It returns, if applicable, a -// RecordSet slice and/or an index and error. -// -// For more details please see DB.Execute -// -// Run is safe for concurrent use by multiple goroutines. -func (db *DB) Run(ctx *TCtx, ql string, arg ...interface{}) (rs []Recordset, index int, err error) { - l, err := Compile(ql) - if err != nil { - return nil, -1, err - } - - return db.Execute(ctx, l, arg...) -} - -func (db *DB) run(ctx *TCtx, ql string, arg ...interface{}) (rs []Recordset, index int, err error) { - l, err := compile(ql) - if err != nil { - return nil, -1, err - } - - return db.Execute(ctx, l, arg...) -} - -// Compile parses the ql statements from src and returns a compiled list for -// DB.Execute or an error if any. -// -// Compile is safe for concurrent use by multiple goroutines. -func Compile(src string) (List, error) { - l := newLexer(src) - if yyParse(l) != 0 { - return List{}, l.errs[0] - } - - return List{l.list, l.params}, nil -} - -func compileExpr(src string) (expression, error) { - l := newLexer(src) - l.inj = parseExpression - if yyParse(l) != 0 { - return nil, l.errs[0] - } - - return l.expr, nil -} - -func compile(src string) (List, error) { - l := newLexer(src) - l.root = true - if yyParse(l) != 0 { - return List{}, l.errs[0] - } - - return List{l.list, l.params}, nil -} - -// MustCompile is like Compile but panics if the ql statements in src cannot be -// compiled. It simplifies safe initialization of global variables holding -// compiled statement lists for DB.Execute. -// -// MustCompile is safe for concurrent use by multiple goroutines. -func MustCompile(src string) List { - list, err := Compile(src) - if err != nil { - panic("ql: Compile(" + strconv.Quote(src) + "): " + err.Error()) // panic ok here - } - - return list -} - -func mustCompile(src string) List { - list, err := compile(src) - if err != nil { - panic("ql: compile(" + strconv.Quote(src) + "): " + err.Error()) // panic ok here - } - - return list -} - -// Execute executes statements in a list while substituting QL paramaters from -// arg. -// -// The resulting []Recordset corresponds to the SELECT FROM statements in the -// list. -// -// If err != nil then index is the zero based index of the failed QL statement. -// Empty statements do not count. -// -// The FSM STT describing the relations between DB states, statements and the -// ctx parameter. -// -// +-----------+---------------------+------------------+------------------+------------------+ -// |\ Event | | | | | -// | \-------\ | BEGIN | | | Other | -// | State \| TRANSACTION | COMMIT | ROLLBACK | statement | -// +-----------+---------------------+------------------+------------------+------------------+ -// | RD | if PC == nil | return error | return error | DB.RLock | -// | | return error | | | Execute(1) | -// | CC == nil | | | | DB.RUnlock | -// | TNL == 0 | DB.Lock | | | | -// | | CC = PC | | | | -// | | TNL++ | | | | -// | | DB.BeginTransaction | | | | -// | | State = WR | | | | -// +-----------+---------------------+------------------+------------------+------------------+ -// | WR | if PC == nil | if PC != CC | if PC != CC | if PC == nil | -// | | return error | return error | return error | DB.Rlock | -// | CC != nil | | | | Execute(1) | -// | TNL != 0 | if PC != CC | DB.Commit | DB.Rollback | RUnlock | -// | | DB.Lock | TNL-- | TNL-- | else if PC != CC | -// | | CC = PC | if TNL == 0 | if TNL == 0 | return error | -// | | | CC = nil | CC = nil | else | -// | | TNL++ | State = RD | State = RD | Execute(2) | -// | | DB.BeginTransaction | DB.Unlock | DB.Unlock | | -// +-----------+---------------------+------------------+------------------+------------------+ -// CC: Curent transaction context -// PC: Passed transaction context -// TNL: Transaction nesting level -// -// Lock, Unlock, RLock, RUnlock semantics above are the same as in -// sync.RWMutex. -// -// (1): Statement list is executed outside of a transaction. Attempts to update -// the DB will fail, the execution context is read-only. Other statements with -// read only context will execute concurrently. If any statement fails, the -// execution of the statement list is aborted. -// -// Note that the RLock/RUnlock surrounds every single "other" statement when it -// is executed outside of a transaction. If read consistency is required by a -// list of more than one statement then an explicit BEGIN TRANSACTION / COMMIT -// or ROLLBACK wrapper must be provided. Otherwise the state of the DB may -// change in between executing any two out-of-transaction statements. -// -// (2): Statement list is executed inside an isolated transaction. Execution of -// statements can update the DB, the execution context is read-write. If any -// statement fails, the execution of the statement list is aborted and the DB -// is automatically rolled back to the TNL which was active before the start of -// execution of the statement list. -// -// Execute is safe for concurrent use by multiple goroutines, but one must -// consider the blocking issues as discussed above. -// -// ACID -// -// Atomicity: Transactions are atomic. Transactions can be nested. Commit or -// rollbacks work on the current transaction level. Transactions are made -// persistent only on the top level commit. Reads made from within an open -// transaction are dirty reads. -// -// Consistency: Transactions bring the DB from one structurally consistent -// state to other structurally consistent state. -// -// Isolation: Transactions are isolated. Isolation is implemented by -// serialization. -// -// Durability: Transactions are durable. A two phase commit protocol and a -// write ahead log is used. Database is recovered after a crash from the write -// ahead log automatically on open. -func (db *DB) Execute(ctx *TCtx, l List, arg ...interface{}) (rs []Recordset, index int, err error) { - // Sanitize args - for i, v := range arg { - switch x := v.(type) { - case nil, bool, complex64, complex128, float32, float64, string, - int8, int16, int32, int64, int, - uint8, uint16, uint32, uint64, uint, - *big.Int, *big.Rat, []byte, time.Duration, time.Time: - case big.Int: - arg[i] = &x - case big.Rat: - arg[i] = &x - default: - return nil, 0, fmt.Errorf("cannot use arg[%d] (type %T):unsupported type", i, v) - } - } - - tnl0 := -1 - if ctx != nil { - ctx.LastInsertID, ctx.RowsAffected = 0, 0 - } - - list := l.l - for _, s := range list { - r, tnla, tnl, err := db.run1(ctx, s, arg...) - if tnl0 < 0 { - tnl0 = tnla - } - if err != nil { - for tnl > tnl0 { - var e2 error - if _, _, tnl, e2 = db.run1(ctx, rollbackStmt{}); e2 != nil { - err = e2 - } - } - return rs, index, err - } - - if r != nil { - if x, ok := r.(recordset); ok { - x.tx = ctx - r = x - } - rs = append(rs, r) - } - } - return -} - -func (db *DB) run1(pc *TCtx, s stmt, arg ...interface{}) (rs Recordset, tnla, tnlb int, err error) { - db.mu.Lock() - tnla = db.tnl - tnlb = db.tnl - switch db.rw { - case false: - switch s.(type) { - case beginTransactionStmt: - defer db.mu.Unlock() - if pc == nil { - return nil, tnla, tnlb, errors.New("BEGIN TRANSACTION: cannot start a transaction in nil TransactionCtx") - } - - if err = db.store.BeginTransaction(); err != nil { - return - } - - db.beginTransaction() - db.rwmu.Lock() - db.cc = pc - db.tnl++ - tnlb = db.tnl - db.rw = true - return - case commitStmt: - defer db.mu.Unlock() - return nil, tnla, tnlb, errCommitNotInTransaction - case rollbackStmt: - defer db.mu.Unlock() - return nil, tnla, tnlb, errRollbackNotInTransaction - default: - if s.isUpdating() { - db.mu.Unlock() - return nil, tnla, tnlb, fmt.Errorf("attempt to update the DB outside of a transaction") - } - - db.rwmu.RLock() // can safely grab before Unlock - db.mu.Unlock() - defer db.rwmu.RUnlock() - rs, err = s.exec(&execCtx{db, arg}) // R/O tctx - return rs, tnla, tnlb, err - } - default: // case true: - switch s.(type) { - case beginTransactionStmt: - defer db.mu.Unlock() - - if pc == nil { - return nil, tnla, tnlb, errBeginTransNoCtx - } - - if pc != db.cc { - for db.rw == true { - db.mu.Unlock() // Transaction isolation - db.mu.Lock() - } - - db.rw = true - db.rwmu.Lock() - } - - if err = db.store.BeginTransaction(); err != nil { - return - } - - db.beginTransaction() - db.cc = pc - db.tnl++ - tnlb = db.tnl - return - case commitStmt: - defer db.mu.Unlock() - if pc != db.cc { - return nil, tnla, tnlb, fmt.Errorf("invalid passed transaction context") - } - - db.commit() - err = db.store.Commit() - db.tnl-- - tnlb = db.tnl - if db.tnl != 0 { - return - } - - db.cc = nil - db.rw = false - db.rwmu.Unlock() - return - case rollbackStmt: - defer db.mu.Unlock() - defer func() { pc.LastInsertID = db.root.lastInsertID }() - if pc != db.cc { - return nil, tnla, tnlb, fmt.Errorf("invalid passed transaction context") - } - - db.rollback() - err = db.store.Rollback() - db.tnl-- - tnlb = db.tnl - if db.tnl != 0 { - return - } - - db.cc = nil - db.rw = false - db.rwmu.Unlock() - return - default: - if pc == nil { - if s.isUpdating() { - db.mu.Unlock() - return nil, tnla, tnlb, fmt.Errorf("attempt to update the DB outside of a transaction") - } - - db.mu.Unlock() // must Unlock before RLock - db.rwmu.RLock() - defer db.rwmu.RUnlock() - rs, err = s.exec(&execCtx{db, arg}) - return rs, tnla, tnlb, err - } - - defer db.mu.Unlock() - defer func() { pc.LastInsertID = db.root.lastInsertID }() - if pc != db.cc { - return nil, tnla, tnlb, fmt.Errorf("invalid passed transaction context") - } - - rs, err = s.exec(&execCtx{db, arg}) - return rs, tnla, tnlb, err - } - } -} - -// Flush ends the transaction collecting window, if applicable. IOW, if the DB -// is dirty, it schedules a 2PC (WAL + DB file) commit on the next outer most -// DB.Commit or performs it synchronously if there's currently no open -// transaction. -// -// The collecting window is an implementation detail and future versions of -// Flush may become a no operation while keeping the operation semantics. -func (db *DB) Flush() (err error) { - return nil -} - -// Close will close the DB. Successful Close is idempotent. -func (db *DB) Close() error { - db.mu.Lock() - defer db.mu.Unlock() - if db.store == nil { - return nil - } - - if db.tnl != 0 { - return fmt.Errorf("cannot close DB while open transaction exist") - } - - err := db.store.Close() - db.root, db.store = nil, nil - return err -} - -func (db *DB) do(r recordset, f func(data []interface{}) (bool, error)) (err error) { - db.mu.Lock() - switch db.rw { - case false: - db.rwmu.RLock() // can safely grab before Unlock - db.mu.Unlock() - defer db.rwmu.RUnlock() - default: // case true: - if r.tx == nil { - db.mu.Unlock() // must Unlock before RLock - db.rwmu.RLock() - defer db.rwmu.RUnlock() - break - } - - defer db.mu.Unlock() - if r.tx != db.cc { - return fmt.Errorf("invalid passed transaction context") - } - } - - return r.do(r.ctx, func(id interface{}, data []interface{}) (bool, error) { - if err = expand(data); err != nil { - return false, err - } - - return f(data) - }) -} - -func (db *DB) beginTransaction() { //TODO Rewrite, must use much smaller undo info! - root := *db.root - root.parent = db.root - root.tables = make(map[string]*table, len(db.root.tables)) - var tprev *table - for t := db.root.thead; t != nil; t = t.tnext { - t2 := t.clone() - root.tables[t2.name] = t2 - t2.tprev = tprev - switch { - case tprev == nil: - root.thead = t2 - default: - tprev.tnext = t2 - } - tprev = t2 - } - db.root = &root -} - -func (db *DB) rollback() { - db.root = db.root.parent -} - -func (db *DB) commit() { - db.root.parent = db.root.parent.parent -} - -// Type represents a QL type (bigint, int, string, ...) -type Type int - -// Values of ColumnInfo.Type. -const ( - BigInt Type = qBigInt - BigRat = qBigRat - Blob = qBlob - Bool = qBool - Complex128 = qComplex128 - Complex64 = qComplex64 - Duration = qDuration - Float32 = qFloat32 - Float64 = qFloat64 - Int16 = qInt16 - Int32 = qInt32 - Int64 = qInt64 - Int8 = qInt8 - String = qString - Time = qTime - Uint16 = qUint16 - Uint32 = qUint32 - Uint64 = qUint64 - Uint8 = qUint8 -) - -// String implements fmt.Stringer. -func (t Type) String() string { - return typeStr(int(t)) -} - -// ColumnInfo provides meta data describing a table column. -type ColumnInfo struct { - Name string // Column name. - Type Type // Column type (BigInt, BigRat, ...). - NotNull bool // Column cannot be NULL. - Constraint string // Constraint expression, if any. - Default string // Default expression, if any. -} - -// TableInfo provides meta data describing a DB table. -type TableInfo struct { - // Table name. - Name string - - // Table schema. Columns are listed in the order in which they appear - // in the schema. - Columns []ColumnInfo -} - -// IndexInfo provides meta data describing a DB index. It corresponds to the -// statement -// -// CREATE INDEX Name ON Table (Column); -type IndexInfo struct { - Name string // Index name - Table string // Table name. - Column string // Column name. - Unique bool // Wheter the index is unique. - ExpressionList []string // Index expression list. -} - -// DbInfo provides meta data describing a DB. -type DbInfo struct { - Name string // DB name. - Tables []TableInfo // Tables in the DB. - Indices []IndexInfo // Indices in the DB. -} - -func (db *DB) info() (r *DbInfo, err error) { - _, hasColumn2 := db.root.tables["__Column2"] - r = &DbInfo{Name: db.Name()} - for nm, t := range db.root.tables { - ti := TableInfo{Name: nm} - m := map[string]*ColumnInfo{} - if hasColumn2 { - rs, err := selectColumn2.l[0].exec(&execCtx{db: db, arg: []interface{}{nm}}) - if err != nil { - return nil, err - } - - if err := rs.(recordset).do( - &execCtx{db: db, arg: []interface{}{nm}}, - func(id interface{}, data []interface{}) (bool, error) { - ci := &ColumnInfo{NotNull: data[1].(bool), Constraint: data[2].(string), Default: data[3].(string)} - m[data[0].(string)] = ci - return true, nil - }, - ); err != nil { - return nil, err - } - } - for _, c := range t.cols { - ci := ColumnInfo{Name: c.name, Type: Type(c.typ)} - if c2 := m[c.name]; c2 != nil { - ci.NotNull = c2.NotNull - ci.Constraint = c2.Constraint - ci.Default = c2.Default - } - ti.Columns = append(ti.Columns, ci) - } - r.Tables = append(r.Tables, ti) - for i, x := range t.indices { - if x == nil { - continue - } - - var cn string - switch { - case i == 0: - cn = "id()" - default: - cn = t.cols0[i-1].name - } - r.Indices = append(r.Indices, IndexInfo{x.name, nm, cn, x.unique, []string{cn}}) - } - var a []string - for k := range t.indices2 { - a = append(a, k) - } - for _, k := range a { - x := t.indices2[k] - a = a[:0] - for _, e := range x.exprList { - a = append(a, e.String()) - } - r.Indices = append(r.Indices, IndexInfo{k, nm, "", x.unique, a}) - } - } - return -} - -// Info provides meta data describing a DB or an error if any. It locks the DB -// to obtain the result. -func (db *DB) Info() (r *DbInfo, err error) { - db.mu.Lock() - defer db.mu.Unlock() - return db.info() -} - -type constraint struct { - expr expression // If expr == nil: constraint is 'NOT NULL' -} - -func (c *constraint) clone() *constraint { - if c == nil { - return nil - } - - var e expression - if c.expr != nil { - e, _ = c.expr.clone(nil) - } - return &constraint{e} -} - -type joinRset struct { - sources []interface{} - typ int - on expression -} - -func (r *joinRset) String() string { - a := make([]string, len(r.sources)) - for i, pair0 := range r.sources { - pair := pair0.([]interface{}) - altName := pair[1].(string) - switch x := pair[0].(type) { - case string: // table name - switch { - case altName == "": - a[i] = x - default: - a[i] = fmt.Sprintf("%s AS %s", x, altName) - } - case *selectStmt: - switch { - case altName == "": - a[i] = fmt.Sprintf("(%s)", x) - default: - a[i] = fmt.Sprintf("(%s) AS %s", x, altName) - } - default: - panic("internal error 054") - } - } - n := len(a) - a2 := a[:n-1] - j := a[n-1] - var s string - switch r.typ { - case crossJoin: - return strings.Join(a, ", ") - case leftJoin: - s = strings.Join(a2, ",") + " LEFT" - case rightJoin: - s = strings.Join(a2, ",") + " RIGHT" - case fullJoin: - s = strings.Join(a2, ",") + " FULL" - } - s += " OUTER JOIN " + j + " ON " + r.on.String() - return s -} - -func (r *joinRset) plan(ctx *execCtx) (plan, error) { - rsets := make([]plan, len(r.sources)) - names := make([]string, len(r.sources)) - var err error - m := map[string]bool{} - var fields []string - for i, v := range r.sources { - pair := v.([]interface{}) - src := pair[0] - nm := pair[1].(string) - if s, ok := src.(string); ok { - src = tableRset(s) - if nm == "" { - nm = s - } - } - if m[nm] { - return nil, fmt.Errorf("%s: duplicate name %s", r.String(), nm) - } - - if nm != "" { - m[nm] = true - } - names[i] = nm - var q plan - switch x := src.(type) { - case rset: - if q, err = x.plan(ctx); err != nil { - return nil, err - } - case plan: - q = x - default: - panic("internal error 008") - } - - switch { - case len(r.sources) == 1: - fields = q.fieldNames() - default: - for _, f := range q.fieldNames() { - if strings.Contains(f, ".") { - return nil, fmt.Errorf("cannot join on recordset with already qualified field names (use the AS clause): %s", f) - } - - if f != "" && nm != "" { - f = fmt.Sprintf("%s.%s", nm, f) - } - if nm == "" { - f = "" - } - fields = append(fields, f) - } - } - rsets[i] = q - } - - if len(rsets) == 1 { - return rsets[0], nil - } - - right := len(rsets[len(rsets)-1].fieldNames()) - switch r.typ { - case crossJoin: - return &crossJoinDefaultPlan{rsets: rsets, names: names, fields: fields}, nil - case leftJoin: - return &leftJoinDefaultPlan{rsets: rsets, names: names, fields: fields, on: r.on, right: right}, nil - case rightJoin: - return &rightJoinDefaultPlan{leftJoinDefaultPlan{rsets: rsets, names: names, fields: fields, on: r.on, right: right}}, nil - case fullJoin: - return &fullJoinDefaultPlan{leftJoinDefaultPlan{rsets: rsets, names: names, fields: fields, on: r.on, right: right}}, nil - default: - panic("internal error 010") - } -} - -type fld struct { - expr expression - name string -} diff --git a/Godeps/_workspace/src/github.com/cznic/ql/ql.y b/Godeps/_workspace/src/github.com/cznic/ql/ql.y deleted file mode 100644 index ffe4d50c56..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/ql.y +++ /dev/null @@ -1,1687 +0,0 @@ -%{ - -//TODO Put your favorite license here - -// yacc source generated by ebnf2y[1] -// at 2015-12-07 11:13:21.828981967 +0100 CET -// -// $ ebnf2y -o ql.y -oe ql.ebnf -start StatementList -pkg ql -p _ -// -// CAUTION: If this file is a Go source file (*.go), it was generated -// automatically by '$ go tool yacc' from a *.y file - DO NOT EDIT in that case! -// -// [1]: http://github.com/cznic/ebnf2y - -package ql //TODO real package name - -//TODO required only be the demo _dump function -import ( - "bytes" - "fmt" - "strings" - - "github.com/cznic/strutil" -) - -%} - -%union { - item interface{} //TODO insert real field(s) -} - -%token _ANDAND -%token _ANDNOT -%token _EQ -%token _FLOAT_LIT -%token _GE -%token _IDENTIFIER -%token _IMAGINARY_LIT -%token _INT_LIT -%token _LE -%token _LSH -%token _NEQ -%token _OROR -%token _QL_PARAMETER -%token _RSH -%token _RUNE_LIT -%token _STRING_LIT - -%type /*TODO real type(s), if/where applicable */ - _ANDAND - _ANDNOT - _EQ - _FLOAT_LIT - _GE - _IDENTIFIER - _IMAGINARY_LIT - _INT_LIT - _LE - _LSH - _NEQ - _OROR - _QL_PARAMETER - _RSH - _RUNE_LIT - _STRING_LIT - -%token _ADD -%token _ALTER -%token _AND -%token _AS -%token _ASC -%token _BEGIN -%token _BETWEEN -%token _BIGINT -%token _BIGRAT -%token _BLOB -%token _BOOL -%token _BY -%token _BYTE -%token _COLUMN -%token _COMMIT -%token _COMPLEX128 -%token _COMPLEX64 -%token _CREATE -%token _DEFAULT -%token _DELETE -%token _DESC -%token _DISTINCT -%token _DROP -%token _DURATION -%token _EXISTS -%token _EXPLAIN -%token _FALSE -%token _FLOAT -%token _FLOAT32 -%token _FLOAT64 -%token _FROM -%token _FULL -%token _GROUPBY -%token _IF -%token _IN -%token _INDEX -%token _INSERT -%token _INT -%token _INT16 -%token _INT32 -%token _INT64 -%token _INT8 -%token _INTO -%token _IS -%token _JOIN -%token _LEFT -%token _LIKE -%token _LIMIT -%token _NOT -%token _NULL -%token _OFFSET -%token _ON -%token _OR -%token _ORDER -%token _OUTER -%token _RIGHT -%token _ROLLBACK -%token _RUNE -%token _SELECT -%token _SET -%token _STRING -%token _TABLE -%token _TIME -%token _TRANSACTION -%token _TRUE -%token _TRUNCATE -%token _UINT -%token _UINT16 -%token _UINT32 -%token _UINT64 -%token _UINT8 -%token _UNIQUE -%token _UPDATE -%token _VALUES -%token _WHERE - -%type /*TODO real type(s), if/where applicable */ - AlterTableStmt - AlterTableStmt1 - Assignment - AssignmentList - AssignmentList1 - AssignmentList2 - BeginTransactionStmt - Call - Call1 - Call11 - ColumnDef - ColumnDef1 - ColumnDef11 - ColumnDef2 - ColumnName - ColumnNameList - ColumnNameList1 - ColumnNameList2 - CommitStmt - Conversion - CreateIndexStmt - CreateIndexStmt1 - CreateIndexStmt2 - CreateTableStmt - CreateTableStmt1 - CreateTableStmt2 - CreateTableStmt3 - DeleteFromStmt - DeleteFromStmt1 - DropIndexStmt - DropIndexStmt1 - DropTableStmt - DropTableStmt1 - EmptyStmt - ExplainStmt - Expression - Expression1 - Expression11 - ExpressionList - ExpressionList1 - ExpressionList2 - Factor - Factor1 - Factor11 - Factor2 - Field - Field1 - FieldList - FieldList1 - FieldList2 - GroupByClause - Index - IndexName - InsertIntoStmt - InsertIntoStmt1 - InsertIntoStmt2 - JoinClause - JoinClause1 - JoinClause2 - Limit - Literal - Offset - Operand - OrderBy - OrderBy1 - OrderBy11 - Predicate - Predicate1 - Predicate11 - Predicate12 - Predicate121 - Predicate13 - PrimaryExpression - PrimaryFactor - PrimaryFactor1 - PrimaryFactor11 - PrimaryTerm - PrimaryTerm1 - PrimaryTerm11 - QualifiedIdent - QualifiedIdent1 - RecordSet - RecordSet1 - RecordSet11 - RecordSet2 - RecordSetList - RecordSetList1 - RecordSetList2 - RollbackStmt - SelectStmt - SelectStmt1 - SelectStmt2 - SelectStmt3 - SelectStmt4 - SelectStmt5 - SelectStmt6 - SelectStmt7 - SelectStmt8 - Slice - Slice1 - Slice2 - Start - Statement - StatementList - StatementList1 - TableName - Term - Term1 - Term11 - TruncateTableStmt - Type - UnaryExpr - UnaryExpr1 - UnaryExpr11 - UpdateStmt - UpdateStmt1 - UpdateStmt2 - Values - Values1 - Values2 - WhereClause - -/*TODO %left, %right, ... declarations */ - -%start Start - -%% - -AlterTableStmt: - _ALTER _TABLE TableName AlterTableStmt1 - { - $$ = []AlterTableStmt{"ALTER", "TABLE", $3, $4} //TODO 1 - } - -AlterTableStmt1: - _ADD ColumnDef - { - $$ = []AlterTableStmt1{"ADD", $2} //TODO 2 - } -| _DROP _COLUMN ColumnName - { - $$ = []AlterTableStmt1{"DROP", "COLUMN", $3} //TODO 3 - } - -Assignment: - ColumnName '=' Expression - { - $$ = []Assignment{$1, "=", $3} //TODO 4 - } - -AssignmentList: - Assignment AssignmentList1 AssignmentList2 - { - $$ = []AssignmentList{$1, $2, $3} //TODO 5 - } - -AssignmentList1: - /* EMPTY */ - { - $$ = []AssignmentList1(nil) //TODO 6 - } -| AssignmentList1 ',' Assignment - { - $$ = append($1.([]AssignmentList1), ",", $3) //TODO 7 - } - -AssignmentList2: - /* EMPTY */ - { - $$ = nil //TODO 8 - } -| ',' - { - $$ = "," //TODO 9 - } - -BeginTransactionStmt: - _BEGIN _TRANSACTION - { - $$ = []BeginTransactionStmt{"BEGIN", "TRANSACTION"} //TODO 10 - } - -Call: - '(' Call1 ')' - { - $$ = []Call{"(", $2, ")"} //TODO 11 - } - -Call1: - /* EMPTY */ - { - $$ = nil //TODO 12 - } -| Call11 - { - $$ = $1 //TODO 13 - } - -Call11: - '*' - { - $$ = "*" //TODO 14 - } -| ExpressionList - { - $$ = $1 //TODO 15 - } - -ColumnDef: - ColumnName Type ColumnDef1 ColumnDef2 - { - $$ = []ColumnDef{$1, $2, $3, $4} //TODO 16 - } - -ColumnDef1: - /* EMPTY */ - { - $$ = nil //TODO 17 - } -| ColumnDef11 - { - $$ = $1 //TODO 18 - } - -ColumnDef11: - _NOT _NULL - { - $$ = []ColumnDef11{"NOT", "NULL"} //TODO 19 - } -| Expression - { - $$ = $1 //TODO 20 - } - -ColumnDef2: - /* EMPTY */ - { - $$ = nil //TODO 21 - } -| _DEFAULT Expression - { - $$ = []ColumnDef2{"DEFAULT", $2} //TODO 22 - } - -ColumnName: - _IDENTIFIER - { - $$ = $1 //TODO 23 - } - -ColumnNameList: - ColumnName ColumnNameList1 ColumnNameList2 - { - $$ = []ColumnNameList{$1, $2, $3} //TODO 24 - } - -ColumnNameList1: - /* EMPTY */ - { - $$ = []ColumnNameList1(nil) //TODO 25 - } -| ColumnNameList1 ',' ColumnName - { - $$ = append($1.([]ColumnNameList1), ",", $3) //TODO 26 - } - -ColumnNameList2: - /* EMPTY */ - { - $$ = nil //TODO 27 - } -| ',' - { - $$ = "," //TODO 28 - } - -CommitStmt: - _COMMIT - { - $$ = "COMMIT" //TODO 29 - } - -Conversion: - Type '(' Expression ')' - { - $$ = []Conversion{$1, "(", $3, ")"} //TODO 30 - } - -CreateIndexStmt: - _CREATE CreateIndexStmt1 _INDEX CreateIndexStmt2 IndexName _ON TableName '(' ExpressionList ')' - { - $$ = []CreateIndexStmt{"CREATE", $2, "INDEX", $4, $5, "ON", $7, "(", $9, ")"} //TODO 31 - } - -CreateIndexStmt1: - /* EMPTY */ - { - $$ = nil //TODO 32 - } -| _UNIQUE - { - $$ = "UNIQUE" //TODO 33 - } - -CreateIndexStmt2: - /* EMPTY */ - { - $$ = nil //TODO 34 - } -| _IF _NOT _EXISTS - { - $$ = []CreateIndexStmt2{"IF", "NOT", "EXISTS"} //TODO 35 - } - -CreateTableStmt: - _CREATE _TABLE CreateTableStmt1 TableName '(' ColumnDef CreateTableStmt2 CreateTableStmt3 ')' - { - $$ = []CreateTableStmt{"CREATE", "TABLE", $3, $4, "(", $6, $7, $8, ")"} //TODO 36 - } - -CreateTableStmt1: - /* EMPTY */ - { - $$ = nil //TODO 37 - } -| _IF _NOT _EXISTS - { - $$ = []CreateTableStmt1{"IF", "NOT", "EXISTS"} //TODO 38 - } - -CreateTableStmt2: - /* EMPTY */ - { - $$ = []CreateTableStmt2(nil) //TODO 39 - } -| CreateTableStmt2 ',' ColumnDef - { - $$ = append($1.([]CreateTableStmt2), ",", $3) //TODO 40 - } - -CreateTableStmt3: - /* EMPTY */ - { - $$ = nil //TODO 41 - } -| ',' - { - $$ = "," //TODO 42 - } - -DeleteFromStmt: - _DELETE _FROM TableName DeleteFromStmt1 - { - $$ = []DeleteFromStmt{"DELETE", "FROM", $3, $4} //TODO 43 - } - -DeleteFromStmt1: - /* EMPTY */ - { - $$ = nil //TODO 44 - } -| WhereClause - { - $$ = $1 //TODO 45 - } - -DropIndexStmt: - _DROP _INDEX DropIndexStmt1 IndexName - { - $$ = []DropIndexStmt{"DROP", "INDEX", $3, $4} //TODO 46 - } - -DropIndexStmt1: - /* EMPTY */ - { - $$ = nil //TODO 47 - } -| _IF _EXISTS - { - $$ = []DropIndexStmt1{"IF", "EXISTS"} //TODO 48 - } - -DropTableStmt: - _DROP _TABLE DropTableStmt1 TableName - { - $$ = []DropTableStmt{"DROP", "TABLE", $3, $4} //TODO 49 - } - -DropTableStmt1: - /* EMPTY */ - { - $$ = nil //TODO 50 - } -| _IF _EXISTS - { - $$ = []DropTableStmt1{"IF", "EXISTS"} //TODO 51 - } - -EmptyStmt: - /* EMPTY */ - { - $$ = nil //TODO 52 - } - -ExplainStmt: - _EXPLAIN Statement - { - $$ = []ExplainStmt{"EXPLAIN", $2} //TODO 53 - } - -Expression: - Term Expression1 - { - $$ = []Expression{$1, $2} //TODO 54 - } - -Expression1: - /* EMPTY */ - { - $$ = []Expression1(nil) //TODO 55 - } -| Expression1 Expression11 Term - { - $$ = append($1.([]Expression1), $2, $3) //TODO 56 - } - -Expression11: - _OROR - { - $$ = $1 //TODO 57 - } -| _OR - { - $$ = "OR" //TODO 58 - } - -ExpressionList: - Expression ExpressionList1 ExpressionList2 - { - $$ = []ExpressionList{$1, $2, $3} //TODO 59 - } - -ExpressionList1: - /* EMPTY */ - { - $$ = []ExpressionList1(nil) //TODO 60 - } -| ExpressionList1 ',' Expression - { - $$ = append($1.([]ExpressionList1), ",", $3) //TODO 61 - } - -ExpressionList2: - /* EMPTY */ - { - $$ = nil //TODO 62 - } -| ',' - { - $$ = "," //TODO 63 - } - -Factor: - PrimaryFactor Factor1 Factor2 - { - $$ = []Factor{$1, $2, $3} //TODO 64 - } - -Factor1: - /* EMPTY */ - { - $$ = []Factor1(nil) //TODO 65 - } -| Factor1 Factor11 PrimaryFactor - { - $$ = append($1.([]Factor1), $2, $3) //TODO 66 - } - -Factor11: - _GE - { - $$ = $1 //TODO 67 - } -| '>' - { - $$ = ">" //TODO 68 - } -| _LE - { - $$ = $1 //TODO 69 - } -| '<' - { - $$ = "<" //TODO 70 - } -| _NEQ - { - $$ = $1 //TODO 71 - } -| _EQ - { - $$ = $1 //TODO 72 - } -| _LIKE - { - $$ = "LIKE" //TODO 73 - } - -Factor2: - /* EMPTY */ - { - $$ = nil //TODO 74 - } -| Predicate - { - $$ = $1 //TODO 75 - } - -Field: - Expression Field1 - { - $$ = []Field{$1, $2} //TODO 76 - } - -Field1: - /* EMPTY */ - { - $$ = nil //TODO 77 - } -| _AS _IDENTIFIER - { - $$ = []Field1{"AS", $2} //TODO 78 - } - -FieldList: - Field FieldList1 FieldList2 - { - $$ = []FieldList{$1, $2, $3} //TODO 79 - } - -FieldList1: - /* EMPTY */ - { - $$ = []FieldList1(nil) //TODO 80 - } -| FieldList1 ',' Field - { - $$ = append($1.([]FieldList1), ",", $3) //TODO 81 - } - -FieldList2: - /* EMPTY */ - { - $$ = nil //TODO 82 - } -| ',' - { - $$ = "," //TODO 83 - } - -GroupByClause: - _GROUPBY ColumnNameList - { - $$ = []GroupByClause{"GROUP BY", $2} //TODO 84 - } - -Index: - '[' Expression ']' - { - $$ = []Index{"[", $2, "]"} //TODO 85 - } - -IndexName: - _IDENTIFIER - { - $$ = $1 //TODO 86 - } - -InsertIntoStmt: - _INSERT _INTO TableName InsertIntoStmt1 InsertIntoStmt2 - { - $$ = []InsertIntoStmt{"INSERT", "INTO", $3, $4, $5} //TODO 87 - } - -InsertIntoStmt1: - /* EMPTY */ - { - $$ = nil //TODO 88 - } -| '(' ColumnNameList ')' - { - $$ = []InsertIntoStmt1{"(", $2, ")"} //TODO 89 - } - -InsertIntoStmt2: - Values - { - $$ = $1 //TODO 90 - } -| SelectStmt - { - $$ = $1 //TODO 91 - } - -JoinClause: - JoinClause1 JoinClause2 _JOIN RecordSet _ON Expression - { - $$ = []JoinClause{$1, $2, "JOIN", $4, "ON", $6} //TODO 92 - } - -JoinClause1: - _LEFT - { - $$ = "LEFT" //TODO 93 - } -| _RIGHT - { - $$ = "RIGHT" //TODO 94 - } -| _FULL - { - $$ = "FULL" //TODO 95 - } - -JoinClause2: - /* EMPTY */ - { - $$ = nil //TODO 96 - } -| _OUTER - { - $$ = "OUTER" //TODO 97 - } - -Limit: - _LIMIT Expression - { - $$ = []Limit{"Limit", $2} //TODO 98 - } - -Literal: - _FALSE - { - $$ = "FALSE" //TODO 99 - } -| _NULL - { - $$ = "NULL" //TODO 100 - } -| _TRUE - { - $$ = "TRUE" //TODO 101 - } -| _FLOAT_LIT - { - $$ = $1 //TODO 102 - } -| _IMAGINARY_LIT - { - $$ = $1 //TODO 103 - } -| _INT_LIT - { - $$ = $1 //TODO 104 - } -| _RUNE_LIT - { - $$ = $1 //TODO 105 - } -| _STRING_LIT - { - $$ = $1 //TODO 106 - } -| _QL_PARAMETER - { - $$ = $1 //TODO 107 - } - -Offset: - _OFFSET Expression - { - $$ = []Offset{"OFFSET", $2} //TODO 108 - } - -Operand: - Literal - { - $$ = $1 //TODO 109 - } -| QualifiedIdent - { - $$ = $1 //TODO 110 - } -| '(' Expression ')' - { - $$ = []Operand{"(", $2, ")"} //TODO 111 - } - -OrderBy: - _ORDER _BY ExpressionList OrderBy1 - { - $$ = []OrderBy{"ORDER", "BY", $3, $4} //TODO 112 - } - -OrderBy1: - /* EMPTY */ - { - $$ = nil //TODO 113 - } -| OrderBy11 - { - $$ = $1 //TODO 114 - } - -OrderBy11: - _ASC - { - $$ = "ASC" //TODO 115 - } -| _DESC - { - $$ = "DESC" //TODO 116 - } - -Predicate: - Predicate1 - { - $$ = $1 //TODO 117 - } - -Predicate1: - Predicate11 Predicate12 - { - $$ = []Predicate1{$1, $2} //TODO 118 - } -| _IS Predicate13 _NULL - { - $$ = []Predicate1{"IS", $2, "NULL"} //TODO 119 - } - -Predicate11: - /* EMPTY */ - { - $$ = nil //TODO 120 - } -| _NOT - { - $$ = "NOT" //TODO 121 - } - -Predicate12: - _IN '(' ExpressionList ')' - { - $$ = []Predicate12{"IN", "(", $3, ")"} //TODO 122 - } -| _IN '(' SelectStmt Predicate121 ')' - { - $$ = []Predicate12{"IN", "(", $3, $4, ")"} //TODO 123 - } -| _BETWEEN PrimaryFactor _AND PrimaryFactor - { - $$ = []Predicate12{"BETWEEN", $2, "AND", $4} //TODO 124 - } - -Predicate121: - /* EMPTY */ - { - $$ = nil //TODO 125 - } -| ';' - { - $$ = ";" //TODO 126 - } - -Predicate13: - /* EMPTY */ - { - $$ = nil //TODO 127 - } -| _NOT - { - $$ = "NOT" //TODO 128 - } - -PrimaryExpression: - Operand - { - $$ = $1 //TODO 129 - } -| Conversion - { - $$ = $1 //TODO 130 - } -| PrimaryExpression Index - { - $$ = []PrimaryExpression{$1, $2} //TODO 131 - } -| PrimaryExpression Slice - { - $$ = []PrimaryExpression{$1, $2} //TODO 132 - } -| PrimaryExpression Call - { - $$ = []PrimaryExpression{$1, $2} //TODO 133 - } - -PrimaryFactor: - PrimaryTerm PrimaryFactor1 - { - $$ = []PrimaryFactor{$1, $2} //TODO 134 - } - -PrimaryFactor1: - /* EMPTY */ - { - $$ = []PrimaryFactor1(nil) //TODO 135 - } -| PrimaryFactor1 PrimaryFactor11 PrimaryTerm - { - $$ = append($1.([]PrimaryFactor1), $2, $3) //TODO 136 - } - -PrimaryFactor11: - '^' - { - $$ = "^" //TODO 137 - } -| '|' - { - $$ = "|" //TODO 138 - } -| '-' - { - $$ = "-" //TODO 139 - } -| '+' - { - $$ = "+" //TODO 140 - } - -PrimaryTerm: - UnaryExpr PrimaryTerm1 - { - $$ = []PrimaryTerm{$1, $2} //TODO 141 - } - -PrimaryTerm1: - /* EMPTY */ - { - $$ = []PrimaryTerm1(nil) //TODO 142 - } -| PrimaryTerm1 PrimaryTerm11 UnaryExpr - { - $$ = append($1.([]PrimaryTerm1), $2, $3) //TODO 143 - } - -PrimaryTerm11: - _ANDNOT - { - $$ = $1 //TODO 144 - } -| '&' - { - $$ = "&" //TODO 145 - } -| _LSH - { - $$ = $1 //TODO 146 - } -| _RSH - { - $$ = $1 //TODO 147 - } -| '%' - { - $$ = "%" //TODO 148 - } -| '/' - { - $$ = "/" //TODO 149 - } -| '*' - { - $$ = "*" //TODO 150 - } - -QualifiedIdent: - _IDENTIFIER QualifiedIdent1 - { - $$ = []QualifiedIdent{$1, $2} //TODO 151 - } - -QualifiedIdent1: - /* EMPTY */ - { - $$ = nil //TODO 152 - } -| '.' _IDENTIFIER - { - $$ = []QualifiedIdent1{".", $2} //TODO 153 - } - -RecordSet: - RecordSet1 RecordSet2 - { - $$ = []RecordSet{$1, $2} //TODO 154 - } - -RecordSet1: - TableName - { - $$ = $1 //TODO 155 - } -| '(' SelectStmt RecordSet11 ')' - { - $$ = []RecordSet1{"(", $2, $3, ")"} //TODO 156 - } - -RecordSet11: - /* EMPTY */ - { - $$ = nil //TODO 157 - } -| ';' - { - $$ = ";" //TODO 158 - } - -RecordSet2: - /* EMPTY */ - { - $$ = nil //TODO 159 - } -| _AS _IDENTIFIER - { - $$ = []RecordSet2{"AS", $2} //TODO 160 - } - -RecordSetList: - RecordSet RecordSetList1 RecordSetList2 - { - $$ = []RecordSetList{$1, $2, $3} //TODO 161 - } - -RecordSetList1: - /* EMPTY */ - { - $$ = []RecordSetList1(nil) //TODO 162 - } -| RecordSetList1 ',' RecordSet - { - $$ = append($1.([]RecordSetList1), ",", $3) //TODO 163 - } - -RecordSetList2: - /* EMPTY */ - { - $$ = nil //TODO 164 - } -| ',' - { - $$ = "," //TODO 165 - } - -RollbackStmt: - _ROLLBACK - { - $$ = "ROLLBACK" //TODO 166 - } - -SelectStmt: - _SELECT SelectStmt1 SelectStmt2 _FROM RecordSetList SelectStmt3 SelectStmt4 SelectStmt5 SelectStmt6 SelectStmt7 SelectStmt8 - { - $$ = []SelectStmt{"SELECT", $2, $3, "FROM", $5, $6, $7, $8, $9, $10, $11} //TODO 167 - } - -SelectStmt1: - /* EMPTY */ - { - $$ = nil //TODO 168 - } -| _DISTINCT - { - $$ = "DISTINCT" //TODO 169 - } - -SelectStmt2: - '*' - { - $$ = "*" //TODO 170 - } -| FieldList - { - $$ = $1 //TODO 171 - } - -SelectStmt3: - /* EMPTY */ - { - $$ = nil //TODO 172 - } -| JoinClause - { - $$ = $1 //TODO 173 - } - -SelectStmt4: - /* EMPTY */ - { - $$ = nil //TODO 174 - } -| WhereClause - { - $$ = $1 //TODO 175 - } - -SelectStmt5: - /* EMPTY */ - { - $$ = nil //TODO 176 - } -| GroupByClause - { - $$ = $1 //TODO 177 - } - -SelectStmt6: - /* EMPTY */ - { - $$ = nil //TODO 178 - } -| OrderBy - { - $$ = $1 //TODO 179 - } - -SelectStmt7: - /* EMPTY */ - { - $$ = nil //TODO 180 - } -| Limit - { - $$ = $1 //TODO 181 - } - -SelectStmt8: - /* EMPTY */ - { - $$ = nil //TODO 182 - } -| Offset - { - $$ = $1 //TODO 183 - } - -Slice: - '[' Slice1 ':' Slice2 ']' - { - $$ = []Slice{"[", $2, ":", $4, "]"} //TODO 184 - } - -Slice1: - /* EMPTY */ - { - $$ = nil //TODO 185 - } -| Expression - { - $$ = $1 //TODO 186 - } - -Slice2: - /* EMPTY */ - { - $$ = nil //TODO 187 - } -| Expression - { - $$ = $1 //TODO 188 - } - -Start: - StatementList - { - _parserResult = $1 //TODO 189 - } - -Statement: - EmptyStmt - { - $$ = $1 //TODO 190 - } -| AlterTableStmt - { - $$ = $1 //TODO 191 - } -| BeginTransactionStmt - { - $$ = $1 //TODO 192 - } -| CommitStmt - { - $$ = $1 //TODO 193 - } -| CreateIndexStmt - { - $$ = $1 //TODO 194 - } -| CreateTableStmt - { - $$ = $1 //TODO 195 - } -| DeleteFromStmt - { - $$ = $1 //TODO 196 - } -| DropIndexStmt - { - $$ = $1 //TODO 197 - } -| DropTableStmt - { - $$ = $1 //TODO 198 - } -| InsertIntoStmt - { - $$ = $1 //TODO 199 - } -| RollbackStmt - { - $$ = $1 //TODO 200 - } -| SelectStmt - { - $$ = $1 //TODO 201 - } -| TruncateTableStmt - { - $$ = $1 //TODO 202 - } -| UpdateStmt - { - $$ = $1 //TODO 203 - } -| ExplainStmt - { - $$ = $1 //TODO 204 - } - -StatementList: - Statement StatementList1 - { - $$ = []StatementList{$1, $2} //TODO 205 - } - -StatementList1: - /* EMPTY */ - { - $$ = []StatementList1(nil) //TODO 206 - } -| StatementList1 ';' Statement - { - $$ = append($1.([]StatementList1), ";", $3) //TODO 207 - } - -TableName: - _IDENTIFIER - { - $$ = $1 //TODO 208 - } - -Term: - Factor Term1 - { - $$ = []Term{$1, $2} //TODO 209 - } - -Term1: - /* EMPTY */ - { - $$ = []Term1(nil) //TODO 210 - } -| Term1 Term11 Factor - { - $$ = append($1.([]Term1), $2, $3) //TODO 211 - } - -Term11: - _ANDAND - { - $$ = $1 //TODO 212 - } -| _AND - { - $$ = "AND" //TODO 213 - } - -TruncateTableStmt: - _TRUNCATE _TABLE TableName - { - $$ = []TruncateTableStmt{"TRUNCATE", "TABLE", $3} //TODO 214 - } - -Type: - _BIGINT - { - $$ = "bigint" //TODO 215 - } -| _BIGRAT - { - $$ = "bigrat" //TODO 216 - } -| _BLOB - { - $$ = "blob" //TODO 217 - } -| _BOOL - { - $$ = "bool" //TODO 218 - } -| _BYTE - { - $$ = "byte" //TODO 219 - } -| _COMPLEX128 - { - $$ = "complex128" //TODO 220 - } -| _COMPLEX64 - { - $$ = "complex64" //TODO 221 - } -| _DURATION - { - $$ = "duration" //TODO 222 - } -| _FLOAT - { - $$ = "float" //TODO 223 - } -| _FLOAT32 - { - $$ = "float32" //TODO 224 - } -| _FLOAT64 - { - $$ = "float64" //TODO 225 - } -| _INT - { - $$ = "int" //TODO 226 - } -| _INT16 - { - $$ = "int16" //TODO 227 - } -| _INT32 - { - $$ = "int32" //TODO 228 - } -| _INT64 - { - $$ = "int64" //TODO 229 - } -| _INT8 - { - $$ = "int8" //TODO 230 - } -| _RUNE - { - $$ = "rune" //TODO 231 - } -| _STRING - { - $$ = "string" //TODO 232 - } -| _TIME - { - $$ = "time" //TODO 233 - } -| _UINT - { - $$ = "uint" //TODO 234 - } -| _UINT16 - { - $$ = "uint16" //TODO 235 - } -| _UINT32 - { - $$ = "uint32" //TODO 236 - } -| _UINT64 - { - $$ = "uint64" //TODO 237 - } -| _UINT8 - { - $$ = "uint8" //TODO 238 - } - -UnaryExpr: - UnaryExpr1 PrimaryExpression - { - $$ = []UnaryExpr{$1, $2} //TODO 239 - } - -UnaryExpr1: - /* EMPTY */ - { - $$ = nil //TODO 240 - } -| UnaryExpr11 - { - $$ = $1 //TODO 241 - } - -UnaryExpr11: - '^' - { - $$ = "^" //TODO 242 - } -| '!' - { - $$ = "!" //TODO 243 - } -| '-' - { - $$ = "-" //TODO 244 - } -| '+' - { - $$ = "+" //TODO 245 - } - -UpdateStmt: - _UPDATE TableName UpdateStmt1 AssignmentList UpdateStmt2 - { - $$ = []UpdateStmt{"UPDATE", $2, $3, $4, $5} //TODO 246 - } - -UpdateStmt1: - /* EMPTY */ - { - $$ = nil //TODO 247 - } -| _SET - { - $$ = "SET" //TODO 248 - } - -UpdateStmt2: - /* EMPTY */ - { - $$ = nil //TODO 249 - } -| WhereClause - { - $$ = $1 //TODO 250 - } - -Values: - _VALUES '(' ExpressionList ')' Values1 Values2 - { - $$ = []Values{"VALUES", "(", $3, ")", $5, $6} //TODO 251 - } - -Values1: - /* EMPTY */ - { - $$ = []Values1(nil) //TODO 252 - } -| Values1 ',' '(' ExpressionList ')' - { - $$ = append($1.([]Values1), ",", "(", $4, ")") //TODO 253 - } - -Values2: - /* EMPTY */ - { - $$ = nil //TODO 254 - } -| ',' - { - $$ = "," //TODO 255 - } - -WhereClause: - _WHERE Expression - { - $$ = []WhereClause{"WHERE", $2} //TODO 256 - } - -%% - -//TODO remove demo stuff below - -var _parserResult interface{} - -type ( - AlterTableStmt interface{} - AlterTableStmt1 interface{} - Assignment interface{} - AssignmentList interface{} - AssignmentList1 interface{} - AssignmentList2 interface{} - BeginTransactionStmt interface{} - Call interface{} - Call1 interface{} - Call11 interface{} - ColumnDef interface{} - ColumnDef1 interface{} - ColumnDef11 interface{} - ColumnDef2 interface{} - ColumnName interface{} - ColumnNameList interface{} - ColumnNameList1 interface{} - ColumnNameList2 interface{} - CommitStmt interface{} - Conversion interface{} - CreateIndexStmt interface{} - CreateIndexStmt1 interface{} - CreateIndexStmt2 interface{} - CreateTableStmt interface{} - CreateTableStmt1 interface{} - CreateTableStmt2 interface{} - CreateTableStmt3 interface{} - DeleteFromStmt interface{} - DeleteFromStmt1 interface{} - DropIndexStmt interface{} - DropIndexStmt1 interface{} - DropTableStmt interface{} - DropTableStmt1 interface{} - EmptyStmt interface{} - ExplainStmt interface{} - Expression interface{} - Expression1 interface{} - Expression11 interface{} - ExpressionList interface{} - ExpressionList1 interface{} - ExpressionList2 interface{} - Factor interface{} - Factor1 interface{} - Factor11 interface{} - Factor2 interface{} - Field interface{} - Field1 interface{} - FieldList interface{} - FieldList1 interface{} - FieldList2 interface{} - GroupByClause interface{} - Index interface{} - IndexName interface{} - InsertIntoStmt interface{} - InsertIntoStmt1 interface{} - InsertIntoStmt2 interface{} - JoinClause interface{} - JoinClause1 interface{} - JoinClause2 interface{} - Limit interface{} - Literal interface{} - Offset interface{} - Operand interface{} - OrderBy interface{} - OrderBy1 interface{} - OrderBy11 interface{} - Predicate interface{} - Predicate1 interface{} - Predicate11 interface{} - Predicate12 interface{} - Predicate121 interface{} - Predicate13 interface{} - PrimaryExpression interface{} - PrimaryFactor interface{} - PrimaryFactor1 interface{} - PrimaryFactor11 interface{} - PrimaryTerm interface{} - PrimaryTerm1 interface{} - PrimaryTerm11 interface{} - QualifiedIdent interface{} - QualifiedIdent1 interface{} - RecordSet interface{} - RecordSet1 interface{} - RecordSet11 interface{} - RecordSet2 interface{} - RecordSetList interface{} - RecordSetList1 interface{} - RecordSetList2 interface{} - RollbackStmt interface{} - SelectStmt interface{} - SelectStmt1 interface{} - SelectStmt2 interface{} - SelectStmt3 interface{} - SelectStmt4 interface{} - SelectStmt5 interface{} - SelectStmt6 interface{} - SelectStmt7 interface{} - SelectStmt8 interface{} - Slice interface{} - Slice1 interface{} - Slice2 interface{} - Start interface{} - Statement interface{} - StatementList interface{} - StatementList1 interface{} - TableName interface{} - Term interface{} - Term1 interface{} - Term11 interface{} - TruncateTableStmt interface{} - Type interface{} - UnaryExpr interface{} - UnaryExpr1 interface{} - UnaryExpr11 interface{} - UpdateStmt interface{} - UpdateStmt1 interface{} - UpdateStmt2 interface{} - Values interface{} - Values1 interface{} - Values2 interface{} - WhereClause interface{} -) - -func _dump() { - s := fmt.Sprintf("%#v", _parserResult) - s = strings.Replace(s, "%", "%%", -1) - s = strings.Replace(s, "{", "{%i\n", -1) - s = strings.Replace(s, "}", "%u\n}", -1) - s = strings.Replace(s, ", ", ",\n", -1) - var buf bytes.Buffer - strutil.IndentFormatter(&buf, ". ").Format(s) - buf.WriteString("\n") - a := strings.Split(buf.String(), "\n") - for _, v := range a { - if strings.HasSuffix(v, "(nil)") || strings.HasSuffix(v, "(nil),") { - continue - } - - fmt.Println(v) - } -} - -// End of demo stuff diff --git a/Godeps/_workspace/src/github.com/cznic/ql/ql/Makefile b/Godeps/_workspace/src/github.com/cznic/ql/ql/Makefile deleted file mode 100644 index e795538a76..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/ql/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2014 The ql Authors. All rights reserved. -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file. - -.PHONY: all clean nuke - -all: editor - go vet - go install - make todo - -clean: - go clean - rm -f *~ ql - -editor: - go fmt - go install - -todo: - @grep -n ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* *.go || true - @grep -n TODO *.go || true - @grep -n BUG *.go || true - @grep -n println *.go || true diff --git a/Godeps/_workspace/src/github.com/cznic/ql/ql/README.md b/Godeps/_workspace/src/github.com/cznic/ql/ql/README.md deleted file mode 100644 index 07139fd617..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/ql/README.md +++ /dev/null @@ -1,10 +0,0 @@ -ql -== - -Command ql is a utility to explore a database, prototype a schema or test drive a query, etc. - -Installation - - $ go get github.com/cznic/ql/ql - -Documentation: [godoc.org/github.com/cznic/ql/ql](http://godoc.org/github.com/cznic/ql/ql) diff --git a/Godeps/_workspace/src/github.com/cznic/ql/ql/main.go b/Godeps/_workspace/src/github.com/cznic/ql/ql/main.go deleted file mode 100644 index 568fd706e2..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/ql/main.go +++ /dev/null @@ -1,219 +0,0 @@ -// Copyright 2014 The ql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Command ql is a utility to explore a database, prototype a schema or test -// drive a query, etc. -// -// Installation: -// -// $ go get github.com/cznic/ql/ql -// -// Usage: -// -// ql [-db name] [-schema regexp] [-tables regexp] [-fld] statement_list -// -// Options: -// -// -db name Name of the database to use. Defaults to "ql.db". -// If the DB file does not exists it is created automatically. -// -// -schema re If re != "" show the CREATE statements of matching tables and exit. -// -// -tables re If re != "" show the matching table names and exit. -// -// -fld First row of a query result set will show field names. -// -// statement_list QL statements to execute. -// If no non flag arguments are present, ql reads from stdin. -// The list is wrapped into an automatic transaction. -// -// -t Report and measure time to execute, including creating/opening and closing the DB. -// -// Example: -// -// $ ql 'create table t (i int, s string)' -// $ ql << EOF -// > insert into t values -// > (1, "a"), -// > (2, "b"), -// > (3, "c"), -// > EOF -// $ ql 'select * from t' -// 3, "c" -// 2, "b" -// 1, "a" -// $ ql -fld 'select * from t where i != 2 order by s' -// "i", "s" -// 1, "a" -// 3, "c" -// $ -package main - -import ( - "bufio" - "flag" - "fmt" - "io/ioutil" - "log" - "os" - "regexp" - "sort" - "strings" - "time" - - "github.com/cznic/ql" -) - -func str(data []interface{}) string { - a := make([]string, len(data)) - for i, v := range data { - switch x := v.(type) { - case string: - a[i] = fmt.Sprintf("%q", x) - default: - a[i] = fmt.Sprint(x) - } - } - return strings.Join(a, ", ") -} - -func main() { - if err := do(); err != nil { - log.Fatal(err) - } -} - -func do() (err error) { - oDB := flag.String("db", "ql.db", "The DB file to open. It'll be created if missing.") - oFlds := flag.Bool("fld", false, "Show recordset's field names.") - oSchema := flag.String("schema", "", "If non empty, show the CREATE statements of matching tables and exit.") - oTables := flag.String("tables", "", "If non empty, list matching table names and exit.") - oTime := flag.Bool("t", false, "Measure and report time to execute the statement(s) including DB create/open/close.") - flag.Parse() - - t0 := time.Now() - if *oTime { - defer func() { - fmt.Fprintf(os.Stderr, "%s\n", time.Since(t0)) - }() - } - - db, err := ql.OpenFile(*oDB, &ql.Options{CanCreate: true}) - if err != nil { - return err - } - - defer func() { - ec := db.Close() - switch { - case ec != nil && err != nil: - log.Println(ec) - case ec != nil: - err = ec - } - }() - - if pat := *oSchema; pat != "" { - re, err := regexp.Compile(pat) - if err != nil { - return err - } - - nfo, err := db.Info() - if err != nil { - return err - } - - r := []string{} - for _, ti := range nfo.Tables { - if !re.MatchString(ti.Name) { - continue - } - - a := []string{} - for _, ci := range ti.Columns { - a = append(a, fmt.Sprintf("%s %s", ci.Name, ci.Type)) - } - r = append(r, fmt.Sprintf("CREATE TABLE %s (%s);", ti.Name, strings.Join(a, ", "))) - } - sort.Strings(r) - if len(r) != 0 { - fmt.Println(strings.Join(r, "\n")) - } - return nil - } - - if pat := *oTables; pat != "" { - re, err := regexp.Compile(pat) - if err != nil { - return err - } - - nfo, err := db.Info() - if err != nil { - return err - } - - r := []string{} - for _, ti := range nfo.Tables { - if !re.MatchString(ti.Name) { - continue - } - - r = append(r, ti.Name) - } - sort.Strings(r) - if len(r) != 0 { - fmt.Println(strings.Join(r, "\n")) - } - return nil - } - - var src string - switch n := flag.NArg(); n { - case 0: - b, err := ioutil.ReadAll(bufio.NewReader(os.Stdin)) - if err != nil { - return err - } - - src = string(b) - default: - a := make([]string, n) - for i := range a { - a[i] = flag.Arg(i) - } - src = strings.Join(a, " ") - } - - src = "BEGIN TRANSACTION; " + src + "; COMMIT;" - l, err := ql.Compile(src) - if err != nil { - log.Println(src) - return err - } - - rs, i, err := db.Execute(ql.NewRWCtx(), l) - if err != nil { - a := strings.Split(strings.TrimSpace(fmt.Sprint(l)), "\n") - return fmt.Errorf("%v: %s", err, a[i]) - } - - if len(rs) == 0 { - return - } - - switch { - case l.IsExplainStmt(): - return rs[len(rs)-1].Do(*oFlds, func(data []interface{}) (bool, error) { - fmt.Println(data[0]) - return true, nil - }) - default: - return rs[len(rs)-1].Do(*oFlds, func(data []interface{}) (bool, error) { - fmt.Println(str(data)) - return true, nil - }) - } -} diff --git a/Godeps/_workspace/src/github.com/cznic/ql/scanner.go b/Godeps/_workspace/src/github.com/cznic/ql/scanner.go deleted file mode 100644 index aafa3cf8fa..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/scanner.go +++ /dev/null @@ -1,4129 +0,0 @@ -// CAUTION: Generated file - DO NOT EDIT. - -/* -Copyright (c) 2014 The ql 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 ql - -import ( - "fmt" - "math" - "strconv" - "unicode" -) - -type lexer struct { - agg []bool - c int - col int - errs []error - expr expression - i int - inj int - lcol int - line int - list []stmt - ncol int - nline int - params int - sc int - src string - val []byte - root bool -} - -func newLexer(src string) (l *lexer) { - l = &lexer{ - src: src, - nline: 1, - ncol: 0, - } - l.next() - return -} - -func (l *lexer) next() int { - if l.c != 0 { - l.val = append(l.val, byte(l.c)) - } - l.c = 0 - if l.i < len(l.src) { - l.c = int(l.src[l.i]) - l.i++ - } - switch l.c { - case '\n': - l.lcol = l.ncol - l.nline++ - l.ncol = 0 - default: - l.ncol++ - } - return l.c -} - -func (l *lexer) err0(ln, c int, s string, arg ...interface{}) { - err := fmt.Errorf(fmt.Sprintf("%d:%d ", ln, c)+s, arg...) - l.errs = append(l.errs, err) -} - -func (l *lexer) err(s string, arg ...interface{}) { - l.err0(l.line, l.col, s, arg...) -} - -func (l *lexer) Error(s string) { - l.err(s) -} - -func (l *lexer) Lex(lval *yySymType) (r int) { - //defer func() { dbg("Lex -> %d(%#x)", r, r) }() - defer func() { - lval.line, lval.col = l.line, l.col - }() - const ( - INITIAL = iota - S1 - S2 - ) - - if n := l.inj; n != 0 { - l.inj = 0 - return n - } - - c0, c := 0, l.c - -yystate0: - - l.val = l.val[:0] - c0, l.line, l.col = l.c, l.nline, l.ncol - - switch yyt := l.sc; yyt { - default: - panic(fmt.Errorf(`invalid start condition %d`, yyt)) - case 0: // start condition: INITIAL - goto yystart1 - case 1: // start condition: S1 - goto yystart319 - case 2: // start condition: S2 - goto yystart324 - } - - goto yystate0 // silence unused label error - goto yystate1 // silence unused label error -yystate1: - c = l.next() -yystart1: - switch { - default: - goto yystate3 // c >= '\x01' && c <= '\b' || c == '\v' || c == '\f' || c >= '\x0e' && c <= '\x1f' || c == '#' || c == '%%' || c >= '(' && c <= ',' || c == ':' || c == ';' || c == '@' || c >= '[' && c <= '^' || c == '{' || c >= '}' && c <= 'ÿ' - case c == '!': - goto yystate6 - case c == '"': - goto yystate8 - case c == '$' || c == '?': - goto yystate9 - case c == '&': - goto yystate11 - case c == '-': - goto yystate19 - case c == '.': - goto yystate21 - case c == '/': - goto yystate27 - case c == '0': - goto yystate32 - case c == '<': - goto yystate40 - case c == '=': - goto yystate43 - case c == '>': - goto yystate45 - case c == 'A' || c == 'a': - goto yystate48 - case c == 'B' || c == 'b': - goto yystate60 - case c == 'C' || c == 'c': - goto yystate87 - case c == 'D' || c == 'd': - goto yystate111 - case c == 'E' || c == 'e': - goto yystate141 - case c == 'F' || c == 'f': - goto yystate152 - case c == 'G' || c == 'g': - goto yystate171 - case c == 'H' || c == 'K' || c == 'M' || c == 'P' || c == 'Q' || c >= 'X' && c <= 'Z' || c == '_' || c == 'h' || c == 'k' || c == 'm' || c == 'p' || c == 'q' || c >= 'x' && c <= 'z': - goto yystate176 - case c == 'I' || c == 'i': - goto yystate177 - case c == 'J' || c == 'j': - goto yystate197 - case c == 'L' || c == 'l': - goto yystate201 - case c == 'N' || c == 'n': - goto yystate211 - case c == 'O' || c == 'o': - goto yystate217 - case c == 'R' || c == 'r': - goto yystate232 - case c == 'S' || c == 's': - goto yystate247 - case c == 'T' || c == 't': - goto yystate259 - case c == 'U' || c == 'u': - goto yystate284 - case c == 'V' || c == 'v': - goto yystate305 - case c == 'W' || c == 'w': - goto yystate311 - case c == '\'': - goto yystate14 - case c == '\n': - goto yystate5 - case c == '\t' || c == '\r' || c == ' ': - goto yystate4 - case c == '\x00': - goto yystate2 - case c == '`': - goto yystate316 - case c == '|': - goto yystate317 - case c >= '1' && c <= '9': - goto yystate38 - } - -yystate2: - c = l.next() - goto yyrule1 - -yystate3: - c = l.next() - goto yyrule101 - -yystate4: - c = l.next() - switch { - default: - goto yyrule2 - case c == '\t' || c == '\n' || c == '\r' || c == ' ': - goto yystate5 - } - -yystate5: - c = l.next() - switch { - default: - goto yyrule2 - case c == '\t' || c == '\n' || c == '\r' || c == ' ': - goto yystate5 - } - -yystate6: - c = l.next() - switch { - default: - goto yyrule101 - case c == '=': - goto yystate7 - } - -yystate7: - c = l.next() - goto yyrule21 - -yystate8: - c = l.next() - goto yyrule10 - -yystate9: - c = l.next() - switch { - default: - goto yyrule101 - case c >= '0' && c <= '9': - goto yystate10 - } - -yystate10: - c = l.next() - switch { - default: - goto yyrule100 - case c >= '0' && c <= '9': - goto yystate10 - } - -yystate11: - c = l.next() - switch { - default: - goto yyrule101 - case c == '&': - goto yystate12 - case c == '^': - goto yystate13 - } - -yystate12: - c = l.next() - goto yyrule15 - -yystate13: - c = l.next() - goto yyrule16 - -yystate14: - c = l.next() - switch { - default: - goto yyrule101 - case c == '\'': - goto yystate16 - case c == '\\': - goto yystate17 - case c >= '\x01' && c <= '&' || c >= '(' && c <= '[' || c >= ']' && c <= 'ÿ': - goto yystate15 - } - -yystate15: - c = l.next() - switch { - default: - goto yyabort - case c == '\'': - goto yystate16 - case c == '\\': - goto yystate17 - case c >= '\x01' && c <= '&' || c >= '(' && c <= '[' || c >= ']' && c <= 'ÿ': - goto yystate15 - } - -yystate16: - c = l.next() - goto yyrule12 - -yystate17: - c = l.next() - switch { - default: - goto yyabort - case c == '\'': - goto yystate18 - case c == '\\': - goto yystate17 - case c >= '\x01' && c <= '&' || c >= '(' && c <= '[' || c >= ']' && c <= 'ÿ': - goto yystate15 - } - -yystate18: - c = l.next() - switch { - default: - goto yyrule12 - case c == '\'': - goto yystate16 - case c == '\\': - goto yystate17 - case c >= '\x01' && c <= '&' || c >= '(' && c <= '[' || c >= ']' && c <= 'ÿ': - goto yystate15 - } - -yystate19: - c = l.next() - switch { - default: - goto yyrule101 - case c == '-': - goto yystate20 - } - -yystate20: - c = l.next() - switch { - default: - goto yyrule3 - case c >= '\x01' && c <= '\t' || c >= '\v' && c <= 'ÿ': - goto yystate20 - } - -yystate21: - c = l.next() - switch { - default: - goto yyrule101 - case c >= '0' && c <= '9': - goto yystate22 - } - -yystate22: - c = l.next() - switch { - default: - goto yyrule9 - case c == 'E' || c == 'e': - goto yystate23 - case c == 'i': - goto yystate26 - case c >= '0' && c <= '9': - goto yystate22 - } - -yystate23: - c = l.next() - switch { - default: - goto yyabort - case c == '+' || c == '-': - goto yystate24 - case c >= '0' && c <= '9': - goto yystate25 - } - -yystate24: - c = l.next() - switch { - default: - goto yyabort - case c >= '0' && c <= '9': - goto yystate25 - } - -yystate25: - c = l.next() - switch { - default: - goto yyrule9 - case c == 'i': - goto yystate26 - case c >= '0' && c <= '9': - goto yystate25 - } - -yystate26: - c = l.next() - goto yyrule7 - -yystate27: - c = l.next() - switch { - default: - goto yyrule101 - case c == '*': - goto yystate28 - case c == '/': - goto yystate31 - } - -yystate28: - c = l.next() - switch { - default: - goto yyabort - case c == '*': - goto yystate29 - case c >= '\x01' && c <= ')' || c >= '+' && c <= 'ÿ': - goto yystate28 - } - -yystate29: - c = l.next() - switch { - default: - goto yyabort - case c == '*': - goto yystate29 - case c == '/': - goto yystate30 - case c >= '\x01' && c <= ')' || c >= '+' && c <= '.' || c >= '0' && c <= 'ÿ': - goto yystate28 - } - -yystate30: - c = l.next() - goto yyrule5 - -yystate31: - c = l.next() - switch { - default: - goto yyrule4 - case c >= '\x01' && c <= '\t' || c >= '\v' && c <= 'ÿ': - goto yystate31 - } - -yystate32: - c = l.next() - switch { - default: - goto yyrule8 - case c == '.': - goto yystate22 - case c == '8' || c == '9': - goto yystate34 - case c == 'E' || c == 'e': - goto yystate23 - case c == 'X' || c == 'x': - goto yystate36 - case c == 'i': - goto yystate35 - case c >= '0' && c <= '7': - goto yystate33 - } - -yystate33: - c = l.next() - switch { - default: - goto yyrule8 - case c == '.': - goto yystate22 - case c == '8' || c == '9': - goto yystate34 - case c == 'E' || c == 'e': - goto yystate23 - case c == 'i': - goto yystate35 - case c >= '0' && c <= '7': - goto yystate33 - } - -yystate34: - c = l.next() - switch { - default: - goto yyabort - case c == '.': - goto yystate22 - case c == 'E' || c == 'e': - goto yystate23 - case c == 'i': - goto yystate35 - case c >= '0' && c <= '9': - goto yystate34 - } - -yystate35: - c = l.next() - goto yyrule6 - -yystate36: - c = l.next() - switch { - default: - goto yyabort - case c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f': - goto yystate37 - } - -yystate37: - c = l.next() - switch { - default: - goto yyrule8 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f': - goto yystate37 - } - -yystate38: - c = l.next() - switch { - default: - goto yyrule8 - case c == '.': - goto yystate22 - case c == 'E' || c == 'e': - goto yystate23 - case c == 'i': - goto yystate35 - case c >= '0' && c <= '9': - goto yystate39 - } - -yystate39: - c = l.next() - switch { - default: - goto yyrule8 - case c == '.': - goto yystate22 - case c == 'E' || c == 'e': - goto yystate23 - case c == 'i': - goto yystate35 - case c >= '0' && c <= '9': - goto yystate39 - } - -yystate40: - c = l.next() - switch { - default: - goto yyrule101 - case c == '<': - goto yystate41 - case c == '=': - goto yystate42 - } - -yystate41: - c = l.next() - goto yyrule17 - -yystate42: - c = l.next() - goto yyrule18 - -yystate43: - c = l.next() - switch { - default: - goto yyrule101 - case c == '=': - goto yystate44 - } - -yystate44: - c = l.next() - goto yyrule19 - -yystate45: - c = l.next() - switch { - default: - goto yyrule101 - case c == '=': - goto yystate46 - case c == '>': - goto yystate47 - } - -yystate46: - c = l.next() - goto yyrule20 - -yystate47: - c = l.next() - goto yyrule23 - -yystate48: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'D' || c == 'd': - goto yystate50 - case c == 'L' || c == 'l': - goto yystate52 - case c == 'N' || c == 'n': - goto yystate56 - case c == 'S' || c == 's': - goto yystate58 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'C' || c >= 'E' && c <= 'K' || c == 'M' || c >= 'O' && c <= 'R' || c >= 'T' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'c' || c >= 'e' && c <= 'k' || c == 'm' || c >= 'o' && c <= 'r' || c >= 't' && c <= 'z': - goto yystate49 - } - -yystate49: - c = l.next() - switch { - default: - goto yyrule99 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate50: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'D' || c == 'd': - goto yystate51 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'C' || c >= 'E' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'c' || c >= 'e' && c <= 'z': - goto yystate49 - } - -yystate51: - c = l.next() - switch { - default: - goto yyrule24 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate52: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'T' || c == 't': - goto yystate53 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate53: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate54 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': - goto yystate49 - } - -yystate54: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'R' || c == 'r': - goto yystate55 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'q' || c >= 's' && c <= 'z': - goto yystate49 - } - -yystate55: - c = l.next() - switch { - default: - goto yyrule25 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate56: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'D' || c == 'd': - goto yystate57 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'C' || c >= 'E' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'c' || c >= 'e' && c <= 'z': - goto yystate49 - } - -yystate57: - c = l.next() - switch { - default: - goto yyrule26 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate58: - c = l.next() - switch { - default: - goto yyrule28 - case c == 'C' || c == 'c': - goto yystate59 - case c >= '0' && c <= '9' || c == 'A' || c == 'B' || c >= 'D' && c <= 'Z' || c == '_' || c == 'a' || c == 'b' || c >= 'd' && c <= 'z': - goto yystate49 - } - -yystate59: - c = l.next() - switch { - default: - goto yyrule27 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate60: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate61 - case c == 'I' || c == 'i': - goto yystate70 - case c == 'L' || c == 'l': - goto yystate78 - case c == 'O' || c == 'o': - goto yystate81 - case c == 'Y' || c == 'y': - goto yystate84 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'H' || c == 'J' || c == 'K' || c == 'M' || c == 'N' || c >= 'P' && c <= 'X' || c == 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'h' || c == 'j' || c == 'k' || c == 'm' || c == 'n' || c >= 'p' && c <= 'x' || c == 'z': - goto yystate49 - } - -yystate61: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'G' || c == 'g': - goto yystate62 - case c == 'T' || c == 't': - goto yystate65 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'H' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'f' || c >= 'h' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate62: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'I' || c == 'i': - goto yystate63 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z': - goto yystate49 - } - -yystate63: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'N' || c == 'n': - goto yystate64 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z': - goto yystate49 - } - -yystate64: - c = l.next() - switch { - default: - goto yyrule29 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate65: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'W' || c == 'w': - goto yystate66 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'V' || c >= 'X' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'v' || c >= 'x' && c <= 'z': - goto yystate49 - } - -yystate66: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate67 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': - goto yystate49 - } - -yystate67: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate68 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': - goto yystate49 - } - -yystate68: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'N' || c == 'n': - goto yystate69 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z': - goto yystate49 - } - -yystate69: - c = l.next() - switch { - default: - goto yyrule30 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate70: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'G' || c == 'g': - goto yystate71 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'H' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'f' || c >= 'h' && c <= 'z': - goto yystate49 - } - -yystate71: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'I' || c == 'i': - goto yystate72 - case c == 'R' || c == 'r': - goto yystate75 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'q' || c >= 's' && c <= 'z': - goto yystate49 - } - -yystate72: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'N' || c == 'n': - goto yystate73 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z': - goto yystate49 - } - -yystate73: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'T' || c == 't': - goto yystate74 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate74: - c = l.next() - switch { - default: - goto yyrule75 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate75: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'A' || c == 'a': - goto yystate76 - case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z': - goto yystate49 - } - -yystate76: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'T' || c == 't': - goto yystate77 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate77: - c = l.next() - switch { - default: - goto yyrule76 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate78: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'O' || c == 'o': - goto yystate79 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z': - goto yystate49 - } - -yystate79: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'B' || c == 'b': - goto yystate80 - case c >= '0' && c <= '9' || c == 'A' || c >= 'C' && c <= 'Z' || c == '_' || c == 'a' || c >= 'c' && c <= 'z': - goto yystate49 - } - -yystate80: - c = l.next() - switch { - default: - goto yyrule77 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate81: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'O' || c == 'o': - goto yystate82 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z': - goto yystate49 - } - -yystate82: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'L' || c == 'l': - goto yystate83 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z': - goto yystate49 - } - -yystate83: - c = l.next() - switch { - default: - goto yyrule78 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate84: - c = l.next() - switch { - default: - goto yyrule31 - case c == 'T' || c == 't': - goto yystate85 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate85: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate86 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': - goto yystate49 - } - -yystate86: - c = l.next() - switch { - default: - goto yyrule79 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate87: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'O' || c == 'o': - goto yystate88 - case c == 'R' || c == 'r': - goto yystate106 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c == 'P' || c == 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c == 'p' || c == 'q' || c >= 's' && c <= 'z': - goto yystate49 - } - -yystate88: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'L' || c == 'l': - goto yystate89 - case c == 'M' || c == 'm': - goto yystate93 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'N' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'n' && c <= 'z': - goto yystate49 - } - -yystate89: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'U' || c == 'u': - goto yystate90 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'a' && c <= 't' || c >= 'v' && c <= 'z': - goto yystate49 - } - -yystate90: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'M' || c == 'm': - goto yystate91 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'L' || c >= 'N' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'l' || c >= 'n' && c <= 'z': - goto yystate49 - } - -yystate91: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'N' || c == 'n': - goto yystate92 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z': - goto yystate49 - } - -yystate92: - c = l.next() - switch { - default: - goto yyrule32 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate93: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'M' || c == 'm': - goto yystate94 - case c == 'P' || c == 'p': - goto yystate97 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'L' || c == 'N' || c == 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'l' || c == 'n' || c == 'o' || c >= 'q' && c <= 'z': - goto yystate49 - } - -yystate94: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'I' || c == 'i': - goto yystate95 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z': - goto yystate49 - } - -yystate95: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'T' || c == 't': - goto yystate96 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate96: - c = l.next() - switch { - default: - goto yyrule33 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate97: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'L' || c == 'l': - goto yystate98 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z': - goto yystate49 - } - -yystate98: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate99 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': - goto yystate49 - } - -yystate99: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'X' || c == 'x': - goto yystate100 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'W' || c == 'Y' || c == 'Z' || c == '_' || c >= 'a' && c <= 'w' || c == 'y' || c == 'z': - goto yystate49 - } - -yystate100: - c = l.next() - switch { - default: - goto yyrule99 - case c == '0' || c >= '2' && c <= '5' || c >= '7' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - case c == '1': - goto yystate101 - case c == '6': - goto yystate104 - } - -yystate101: - c = l.next() - switch { - default: - goto yyrule99 - case c == '0' || c == '1' || c >= '3' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - case c == '2': - goto yystate102 - } - -yystate102: - c = l.next() - switch { - default: - goto yyrule99 - case c == '8': - goto yystate103 - case c >= '0' && c <= '7' || c == '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate103: - c = l.next() - switch { - default: - goto yyrule80 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate104: - c = l.next() - switch { - default: - goto yyrule99 - case c == '4': - goto yystate105 - case c >= '0' && c <= '3' || c >= '5' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate105: - c = l.next() - switch { - default: - goto yyrule81 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate106: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate107 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': - goto yystate49 - } - -yystate107: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'A' || c == 'a': - goto yystate108 - case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z': - goto yystate49 - } - -yystate108: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'T' || c == 't': - goto yystate109 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate109: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate110 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': - goto yystate49 - } - -yystate110: - c = l.next() - switch { - default: - goto yyrule34 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate111: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate112 - case c == 'I' || c == 'i': - goto yystate124 - case c == 'R' || c == 'r': - goto yystate131 - case c == 'U' || c == 'u': - goto yystate134 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'H' || c >= 'J' && c <= 'Q' || c == 'S' || c == 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'h' || c >= 'j' && c <= 'q' || c == 's' || c == 't' || c >= 'v' && c <= 'z': - goto yystate49 - } - -yystate112: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'F' || c == 'f': - goto yystate113 - case c == 'L' || c == 'l': - goto yystate118 - case c == 'S' || c == 's': - goto yystate122 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'E' || c >= 'G' && c <= 'K' || c >= 'M' && c <= 'R' || c >= 'T' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'e' || c >= 'g' && c <= 'k' || c >= 'm' && c <= 'r' || c >= 't' && c <= 'z': - goto yystate49 - } - -yystate113: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'A' || c == 'a': - goto yystate114 - case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z': - goto yystate49 - } - -yystate114: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'U' || c == 'u': - goto yystate115 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'a' && c <= 't' || c >= 'v' && c <= 'z': - goto yystate49 - } - -yystate115: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'L' || c == 'l': - goto yystate116 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z': - goto yystate49 - } - -yystate116: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'T' || c == 't': - goto yystate117 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate117: - c = l.next() - switch { - default: - goto yyrule35 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate118: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate119 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': - goto yystate49 - } - -yystate119: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'T' || c == 't': - goto yystate120 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate120: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate121 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': - goto yystate49 - } - -yystate121: - c = l.next() - switch { - default: - goto yyrule36 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate122: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'C' || c == 'c': - goto yystate123 - case c >= '0' && c <= '9' || c == 'A' || c == 'B' || c >= 'D' && c <= 'Z' || c == '_' || c == 'a' || c == 'b' || c >= 'd' && c <= 'z': - goto yystate49 - } - -yystate123: - c = l.next() - switch { - default: - goto yyrule37 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate124: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'S' || c == 's': - goto yystate125 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'R' || c >= 'T' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'r' || c >= 't' && c <= 'z': - goto yystate49 - } - -yystate125: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'T' || c == 't': - goto yystate126 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate126: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'I' || c == 'i': - goto yystate127 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z': - goto yystate49 - } - -yystate127: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'N' || c == 'n': - goto yystate128 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z': - goto yystate49 - } - -yystate128: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'C' || c == 'c': - goto yystate129 - case c >= '0' && c <= '9' || c == 'A' || c == 'B' || c >= 'D' && c <= 'Z' || c == '_' || c == 'a' || c == 'b' || c >= 'd' && c <= 'z': - goto yystate49 - } - -yystate129: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'T' || c == 't': - goto yystate130 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate130: - c = l.next() - switch { - default: - goto yyrule38 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate131: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'O' || c == 'o': - goto yystate132 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z': - goto yystate49 - } - -yystate132: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'P' || c == 'p': - goto yystate133 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'o' || c >= 'q' && c <= 'z': - goto yystate49 - } - -yystate133: - c = l.next() - switch { - default: - goto yyrule39 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate134: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'R' || c == 'r': - goto yystate135 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'q' || c >= 's' && c <= 'z': - goto yystate49 - } - -yystate135: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'A' || c == 'a': - goto yystate136 - case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z': - goto yystate49 - } - -yystate136: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'T' || c == 't': - goto yystate137 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate137: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'I' || c == 'i': - goto yystate138 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z': - goto yystate49 - } - -yystate138: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'O' || c == 'o': - goto yystate139 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z': - goto yystate49 - } - -yystate139: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'N' || c == 'n': - goto yystate140 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z': - goto yystate49 - } - -yystate140: - c = l.next() - switch { - default: - goto yyrule82 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate141: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'X' || c == 'x': - goto yystate142 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'W' || c == 'Y' || c == 'Z' || c == '_' || c >= 'a' && c <= 'w' || c == 'y' || c == 'z': - goto yystate49 - } - -yystate142: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'I' || c == 'i': - goto yystate143 - case c == 'P' || c == 'p': - goto yystate147 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'o' || c >= 'q' && c <= 'z': - goto yystate49 - } - -yystate143: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'S' || c == 's': - goto yystate144 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'R' || c >= 'T' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'r' || c >= 't' && c <= 'z': - goto yystate49 - } - -yystate144: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'T' || c == 't': - goto yystate145 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate145: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'S' || c == 's': - goto yystate146 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'R' || c >= 'T' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'r' || c >= 't' && c <= 'z': - goto yystate49 - } - -yystate146: - c = l.next() - switch { - default: - goto yyrule40 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate147: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'L' || c == 'l': - goto yystate148 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z': - goto yystate49 - } - -yystate148: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'A' || c == 'a': - goto yystate149 - case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z': - goto yystate49 - } - -yystate149: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'I' || c == 'i': - goto yystate150 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z': - goto yystate49 - } - -yystate150: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'N' || c == 'n': - goto yystate151 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z': - goto yystate49 - } - -yystate151: - c = l.next() - switch { - default: - goto yyrule41 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate152: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'A' || c == 'a': - goto yystate153 - case c == 'L' || c == 'l': - goto yystate157 - case c == 'R' || c == 'r': - goto yystate165 - case c == 'U' || c == 'u': - goto yystate168 - case c >= '0' && c <= '9' || c >= 'B' && c <= 'K' || c >= 'M' && c <= 'Q' || c == 'S' || c == 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'k' || c >= 'm' && c <= 'q' || c == 's' || c == 't' || c >= 'v' && c <= 'z': - goto yystate49 - } - -yystate153: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'L' || c == 'l': - goto yystate154 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z': - goto yystate49 - } - -yystate154: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'S' || c == 's': - goto yystate155 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'R' || c >= 'T' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'r' || c >= 't' && c <= 'z': - goto yystate49 - } - -yystate155: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate156 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': - goto yystate49 - } - -yystate156: - c = l.next() - switch { - default: - goto yyrule73 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate157: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'O' || c == 'o': - goto yystate158 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z': - goto yystate49 - } - -yystate158: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'A' || c == 'a': - goto yystate159 - case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z': - goto yystate49 - } - -yystate159: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'T' || c == 't': - goto yystate160 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate160: - c = l.next() - switch { - default: - goto yyrule83 - case c == '3': - goto yystate161 - case c == '6': - goto yystate163 - case c >= '0' && c <= '2' || c == '4' || c == '5' || c >= '7' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate161: - c = l.next() - switch { - default: - goto yyrule99 - case c == '0' || c == '1' || c >= '3' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - case c == '2': - goto yystate162 - } - -yystate162: - c = l.next() - switch { - default: - goto yyrule84 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate163: - c = l.next() - switch { - default: - goto yyrule99 - case c == '4': - goto yystate164 - case c >= '0' && c <= '3' || c >= '5' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate164: - c = l.next() - switch { - default: - goto yyrule85 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate165: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'O' || c == 'o': - goto yystate166 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z': - goto yystate49 - } - -yystate166: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'M' || c == 'm': - goto yystate167 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'L' || c >= 'N' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'l' || c >= 'n' && c <= 'z': - goto yystate49 - } - -yystate167: - c = l.next() - switch { - default: - goto yyrule42 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate168: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'L' || c == 'l': - goto yystate169 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z': - goto yystate49 - } - -yystate169: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'L' || c == 'l': - goto yystate170 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z': - goto yystate49 - } - -yystate170: - c = l.next() - switch { - default: - goto yyrule43 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate171: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'R' || c == 'r': - goto yystate172 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'q' || c >= 's' && c <= 'z': - goto yystate49 - } - -yystate172: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'O' || c == 'o': - goto yystate173 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z': - goto yystate49 - } - -yystate173: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'U' || c == 'u': - goto yystate174 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'a' && c <= 't' || c >= 'v' && c <= 'z': - goto yystate49 - } - -yystate174: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'P' || c == 'p': - goto yystate175 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'o' || c >= 'q' && c <= 'z': - goto yystate49 - } - -yystate175: - c = l.next() - switch { - default: - goto yyrule44 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate176: - c = l.next() - switch { - default: - goto yyrule99 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate177: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'F' || c == 'f': - goto yystate178 - case c == 'N' || c == 'n': - goto yystate179 - case c == 'S' || c == 's': - goto yystate196 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'E' || c >= 'G' && c <= 'M' || c >= 'O' && c <= 'R' || c >= 'T' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'e' || c >= 'g' && c <= 'm' || c >= 'o' && c <= 'r' || c >= 't' && c <= 'z': - goto yystate49 - } - -yystate178: - c = l.next() - switch { - default: - goto yyrule45 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate179: - c = l.next() - switch { - default: - goto yyrule49 - case c == 'D' || c == 'd': - goto yystate180 - case c == 'S' || c == 's': - goto yystate183 - case c == 'T' || c == 't': - goto yystate187 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'C' || c >= 'E' && c <= 'R' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'c' || c >= 'e' && c <= 'r' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate180: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate181 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': - goto yystate49 - } - -yystate181: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'X' || c == 'x': - goto yystate182 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'W' || c == 'Y' || c == 'Z' || c == '_' || c >= 'a' && c <= 'w' || c == 'y' || c == 'z': - goto yystate49 - } - -yystate182: - c = l.next() - switch { - default: - goto yyrule46 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate183: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate184 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': - goto yystate49 - } - -yystate184: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'R' || c == 'r': - goto yystate185 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'q' || c >= 's' && c <= 'z': - goto yystate49 - } - -yystate185: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'T' || c == 't': - goto yystate186 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate186: - c = l.next() - switch { - default: - goto yyrule47 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate187: - c = l.next() - switch { - default: - goto yyrule86 - case c == '0' || c == '2' || c == '4' || c == '5' || c == '7' || c == '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z': - goto yystate49 - case c == '1': - goto yystate188 - case c == '3': - goto yystate190 - case c == '6': - goto yystate192 - case c == '8': - goto yystate194 - case c == 'O' || c == 'o': - goto yystate195 - } - -yystate188: - c = l.next() - switch { - default: - goto yyrule99 - case c == '6': - goto yystate189 - case c >= '0' && c <= '5' || c >= '7' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate189: - c = l.next() - switch { - default: - goto yyrule87 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate190: - c = l.next() - switch { - default: - goto yyrule99 - case c == '0' || c == '1' || c >= '3' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - case c == '2': - goto yystate191 - } - -yystate191: - c = l.next() - switch { - default: - goto yyrule88 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate192: - c = l.next() - switch { - default: - goto yyrule99 - case c == '4': - goto yystate193 - case c >= '0' && c <= '3' || c >= '5' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate193: - c = l.next() - switch { - default: - goto yyrule89 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate194: - c = l.next() - switch { - default: - goto yyrule90 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate195: - c = l.next() - switch { - default: - goto yyrule48 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate196: - c = l.next() - switch { - default: - goto yyrule50 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate197: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'O' || c == 'o': - goto yystate198 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z': - goto yystate49 - } - -yystate198: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'I' || c == 'i': - goto yystate199 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z': - goto yystate49 - } - -yystate199: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'N' || c == 'n': - goto yystate200 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z': - goto yystate49 - } - -yystate200: - c = l.next() - switch { - default: - goto yyrule51 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate201: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate202 - case c == 'I' || c == 'i': - goto yystate205 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'h' || c >= 'j' && c <= 'z': - goto yystate49 - } - -yystate202: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'F' || c == 'f': - goto yystate203 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'E' || c >= 'G' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'e' || c >= 'g' && c <= 'z': - goto yystate49 - } - -yystate203: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'T' || c == 't': - goto yystate204 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate204: - c = l.next() - switch { - default: - goto yyrule52 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate205: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'K' || c == 'k': - goto yystate206 - case c == 'M' || c == 'm': - goto yystate208 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'J' || c == 'L' || c >= 'N' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'j' || c == 'l' || c >= 'n' && c <= 'z': - goto yystate49 - } - -yystate206: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate207 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': - goto yystate49 - } - -yystate207: - c = l.next() - switch { - default: - goto yyrule53 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate208: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'I' || c == 'i': - goto yystate209 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z': - goto yystate49 - } - -yystate209: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'T' || c == 't': - goto yystate210 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate210: - c = l.next() - switch { - default: - goto yyrule54 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate211: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'O' || c == 'o': - goto yystate212 - case c == 'U' || c == 'u': - goto yystate214 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 't' || c >= 'v' && c <= 'z': - goto yystate49 - } - -yystate212: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'T' || c == 't': - goto yystate213 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate213: - c = l.next() - switch { - default: - goto yyrule55 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate214: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'L' || c == 'l': - goto yystate215 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z': - goto yystate49 - } - -yystate215: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'L' || c == 'l': - goto yystate216 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z': - goto yystate49 - } - -yystate216: - c = l.next() - switch { - default: - goto yyrule72 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate217: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'F' || c == 'f': - goto yystate218 - case c == 'N' || c == 'n': - goto yystate223 - case c == 'R' || c == 'r': - goto yystate224 - case c == 'U' || c == 'u': - goto yystate228 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'E' || c >= 'G' && c <= 'M' || c >= 'O' && c <= 'Q' || c == 'S' || c == 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'e' || c >= 'g' && c <= 'm' || c >= 'o' && c <= 'q' || c == 's' || c == 't' || c >= 'v' && c <= 'z': - goto yystate49 - } - -yystate218: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'F' || c == 'f': - goto yystate219 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'E' || c >= 'G' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'e' || c >= 'g' && c <= 'z': - goto yystate49 - } - -yystate219: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'S' || c == 's': - goto yystate220 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'R' || c >= 'T' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'r' || c >= 't' && c <= 'z': - goto yystate49 - } - -yystate220: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate221 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': - goto yystate49 - } - -yystate221: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'T' || c == 't': - goto yystate222 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate222: - c = l.next() - switch { - default: - goto yyrule56 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate223: - c = l.next() - switch { - default: - goto yyrule57 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate224: - c = l.next() - switch { - default: - goto yyrule59 - case c == 'D' || c == 'd': - goto yystate225 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'C' || c >= 'E' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'c' || c >= 'e' && c <= 'z': - goto yystate49 - } - -yystate225: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate226 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': - goto yystate49 - } - -yystate226: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'R' || c == 'r': - goto yystate227 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'q' || c >= 's' && c <= 'z': - goto yystate49 - } - -yystate227: - c = l.next() - switch { - default: - goto yyrule58 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate228: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'T' || c == 't': - goto yystate229 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate229: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate230 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': - goto yystate49 - } - -yystate230: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'R' || c == 'r': - goto yystate231 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'q' || c >= 's' && c <= 'z': - goto yystate49 - } - -yystate231: - c = l.next() - switch { - default: - goto yyrule60 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate232: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'I' || c == 'i': - goto yystate233 - case c == 'O' || c == 'o': - goto yystate237 - case c == 'U' || c == 'u': - goto yystate244 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'N' || c >= 'P' && c <= 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'n' || c >= 'p' && c <= 't' || c >= 'v' && c <= 'z': - goto yystate49 - } - -yystate233: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'G' || c == 'g': - goto yystate234 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'H' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'f' || c >= 'h' && c <= 'z': - goto yystate49 - } - -yystate234: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'H' || c == 'h': - goto yystate235 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'G' || c >= 'I' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'g' || c >= 'i' && c <= 'z': - goto yystate49 - } - -yystate235: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'T' || c == 't': - goto yystate236 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate236: - c = l.next() - switch { - default: - goto yyrule61 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate237: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'L' || c == 'l': - goto yystate238 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z': - goto yystate49 - } - -yystate238: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'L' || c == 'l': - goto yystate239 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z': - goto yystate49 - } - -yystate239: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'B' || c == 'b': - goto yystate240 - case c >= '0' && c <= '9' || c == 'A' || c >= 'C' && c <= 'Z' || c == '_' || c == 'a' || c >= 'c' && c <= 'z': - goto yystate49 - } - -yystate240: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'A' || c == 'a': - goto yystate241 - case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z': - goto yystate49 - } - -yystate241: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'C' || c == 'c': - goto yystate242 - case c >= '0' && c <= '9' || c == 'A' || c == 'B' || c >= 'D' && c <= 'Z' || c == '_' || c == 'a' || c == 'b' || c >= 'd' && c <= 'z': - goto yystate49 - } - -yystate242: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'K' || c == 'k': - goto yystate243 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'J' || c >= 'L' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'j' || c >= 'l' && c <= 'z': - goto yystate49 - } - -yystate243: - c = l.next() - switch { - default: - goto yyrule62 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate244: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'N' || c == 'n': - goto yystate245 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z': - goto yystate49 - } - -yystate245: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate246 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': - goto yystate49 - } - -yystate246: - c = l.next() - switch { - default: - goto yyrule91 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate247: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate248 - case c == 'T' || c == 't': - goto yystate254 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate248: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'L' || c == 'l': - goto yystate249 - case c == 'T' || c == 't': - goto yystate253 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate249: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate250 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': - goto yystate49 - } - -yystate250: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'C' || c == 'c': - goto yystate251 - case c >= '0' && c <= '9' || c == 'A' || c == 'B' || c >= 'D' && c <= 'Z' || c == '_' || c == 'a' || c == 'b' || c >= 'd' && c <= 'z': - goto yystate49 - } - -yystate251: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'T' || c == 't': - goto yystate252 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate252: - c = l.next() - switch { - default: - goto yyrule63 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate253: - c = l.next() - switch { - default: - goto yyrule64 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate254: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'R' || c == 'r': - goto yystate255 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'q' || c >= 's' && c <= 'z': - goto yystate49 - } - -yystate255: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'I' || c == 'i': - goto yystate256 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z': - goto yystate49 - } - -yystate256: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'N' || c == 'n': - goto yystate257 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z': - goto yystate49 - } - -yystate257: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'G' || c == 'g': - goto yystate258 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'H' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'f' || c >= 'h' && c <= 'z': - goto yystate49 - } - -yystate258: - c = l.next() - switch { - default: - goto yyrule92 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate259: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'A' || c == 'a': - goto yystate260 - case c == 'I' || c == 'i': - goto yystate264 - case c == 'R' || c == 'r': - goto yystate267 - case c >= '0' && c <= '9' || c >= 'B' && c <= 'H' || c >= 'J' && c <= 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'h' || c >= 'j' && c <= 'q' || c >= 's' && c <= 'z': - goto yystate49 - } - -yystate260: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'B' || c == 'b': - goto yystate261 - case c >= '0' && c <= '9' || c == 'A' || c >= 'C' && c <= 'Z' || c == '_' || c == 'a' || c >= 'c' && c <= 'z': - goto yystate49 - } - -yystate261: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'L' || c == 'l': - goto yystate262 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z': - goto yystate49 - } - -yystate262: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate263 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': - goto yystate49 - } - -yystate263: - c = l.next() - switch { - default: - goto yyrule65 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate264: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'M' || c == 'm': - goto yystate265 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'L' || c >= 'N' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'l' || c >= 'n' && c <= 'z': - goto yystate49 - } - -yystate265: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate266 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': - goto yystate49 - } - -yystate266: - c = l.next() - switch { - default: - goto yyrule93 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate267: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'A' || c == 'a': - goto yystate268 - case c == 'U' || c == 'u': - goto yystate277 - case c >= '0' && c <= '9' || c >= 'B' && c <= 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'b' && c <= 't' || c >= 'v' && c <= 'z': - goto yystate49 - } - -yystate268: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'N' || c == 'n': - goto yystate269 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z': - goto yystate49 - } - -yystate269: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'S' || c == 's': - goto yystate270 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'R' || c >= 'T' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'r' || c >= 't' && c <= 'z': - goto yystate49 - } - -yystate270: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'A' || c == 'a': - goto yystate271 - case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z': - goto yystate49 - } - -yystate271: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'C' || c == 'c': - goto yystate272 - case c >= '0' && c <= '9' || c == 'A' || c == 'B' || c >= 'D' && c <= 'Z' || c == '_' || c == 'a' || c == 'b' || c >= 'd' && c <= 'z': - goto yystate49 - } - -yystate272: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'T' || c == 't': - goto yystate273 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate273: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'I' || c == 'i': - goto yystate274 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z': - goto yystate49 - } - -yystate274: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'O' || c == 'o': - goto yystate275 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'N' || c >= 'P' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z': - goto yystate49 - } - -yystate275: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'N' || c == 'n': - goto yystate276 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z': - goto yystate49 - } - -yystate276: - c = l.next() - switch { - default: - goto yyrule66 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate277: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate278 - case c == 'N' || c == 'n': - goto yystate279 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'm' || c >= 'o' && c <= 'z': - goto yystate49 - } - -yystate278: - c = l.next() - switch { - default: - goto yyrule74 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate279: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'C' || c == 'c': - goto yystate280 - case c >= '0' && c <= '9' || c == 'A' || c == 'B' || c >= 'D' && c <= 'Z' || c == '_' || c == 'a' || c == 'b' || c >= 'd' && c <= 'z': - goto yystate49 - } - -yystate280: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'A' || c == 'a': - goto yystate281 - case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z': - goto yystate49 - } - -yystate281: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'T' || c == 't': - goto yystate282 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate282: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate283 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': - goto yystate49 - } - -yystate283: - c = l.next() - switch { - default: - goto yyrule67 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate284: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'I' || c == 'i': - goto yystate285 - case c == 'N' || c == 'n': - goto yystate295 - case c == 'P' || c == 'p': - goto yystate300 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'M' || c == 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'm' || c == 'o' || c >= 'q' && c <= 'z': - goto yystate49 - } - -yystate285: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'N' || c == 'n': - goto yystate286 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'M' || c >= 'O' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z': - goto yystate49 - } - -yystate286: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'T' || c == 't': - goto yystate287 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate287: - c = l.next() - switch { - default: - goto yyrule94 - case c == '0' || c == '2' || c == '4' || c == '5' || c == '7' || c == '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - case c == '1': - goto yystate288 - case c == '3': - goto yystate290 - case c == '6': - goto yystate292 - case c == '8': - goto yystate294 - } - -yystate288: - c = l.next() - switch { - default: - goto yyrule99 - case c == '6': - goto yystate289 - case c >= '0' && c <= '5' || c >= '7' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate289: - c = l.next() - switch { - default: - goto yyrule95 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate290: - c = l.next() - switch { - default: - goto yyrule99 - case c == '0' || c == '1' || c >= '3' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - case c == '2': - goto yystate291 - } - -yystate291: - c = l.next() - switch { - default: - goto yyrule96 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate292: - c = l.next() - switch { - default: - goto yyrule99 - case c == '4': - goto yystate293 - case c >= '0' && c <= '3' || c >= '5' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate293: - c = l.next() - switch { - default: - goto yyrule97 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate294: - c = l.next() - switch { - default: - goto yyrule98 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate295: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'I' || c == 'i': - goto yystate296 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'H' || c >= 'J' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z': - goto yystate49 - } - -yystate296: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'Q' || c == 'q': - goto yystate297 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'P' || c >= 'R' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'p' || c >= 'r' && c <= 'z': - goto yystate49 - } - -yystate297: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'U' || c == 'u': - goto yystate298 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'a' && c <= 't' || c >= 'v' && c <= 'z': - goto yystate49 - } - -yystate298: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate299 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': - goto yystate49 - } - -yystate299: - c = l.next() - switch { - default: - goto yyrule69 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate300: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'D' || c == 'd': - goto yystate301 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'C' || c >= 'E' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'c' || c >= 'e' && c <= 'z': - goto yystate49 - } - -yystate301: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'A' || c == 'a': - goto yystate302 - case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z': - goto yystate49 - } - -yystate302: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'T' || c == 't': - goto yystate303 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'S' || c >= 'U' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z': - goto yystate49 - } - -yystate303: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate304 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': - goto yystate49 - } - -yystate304: - c = l.next() - switch { - default: - goto yyrule68 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate305: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'A' || c == 'a': - goto yystate306 - case c >= '0' && c <= '9' || c >= 'B' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z': - goto yystate49 - } - -yystate306: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'L' || c == 'l': - goto yystate307 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z': - goto yystate49 - } - -yystate307: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'U' || c == 'u': - goto yystate308 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'a' && c <= 't' || c >= 'v' && c <= 'z': - goto yystate49 - } - -yystate308: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate309 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': - goto yystate49 - } - -yystate309: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'S' || c == 's': - goto yystate310 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'R' || c >= 'T' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'r' || c >= 't' && c <= 'z': - goto yystate49 - } - -yystate310: - c = l.next() - switch { - default: - goto yyrule70 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate311: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'H' || c == 'h': - goto yystate312 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'G' || c >= 'I' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'g' || c >= 'i' && c <= 'z': - goto yystate49 - } - -yystate312: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate313 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': - goto yystate49 - } - -yystate313: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'R' || c == 'r': - goto yystate314 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Q' || c >= 'S' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'q' || c >= 's' && c <= 'z': - goto yystate49 - } - -yystate314: - c = l.next() - switch { - default: - goto yyrule99 - case c == 'E' || c == 'e': - goto yystate315 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z': - goto yystate49 - } - -yystate315: - c = l.next() - switch { - default: - goto yyrule71 - case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z': - goto yystate49 - } - -yystate316: - c = l.next() - goto yyrule11 - -yystate317: - c = l.next() - switch { - default: - goto yyrule101 - case c == '|': - goto yystate318 - } - -yystate318: - c = l.next() - goto yyrule22 - - goto yystate319 // silence unused label error -yystate319: - c = l.next() -yystart319: - switch { - default: - goto yystate320 // c >= '\x01' && c <= '!' || c >= '#' && c <= '[' || c >= ']' && c <= 'ÿ' - case c == '"': - goto yystate321 - case c == '\\': - goto yystate322 - case c == '\x00': - goto yystate2 - } - -yystate320: - c = l.next() - switch { - default: - goto yyabort - case c == '"': - goto yystate321 - case c == '\\': - goto yystate322 - case c >= '\x01' && c <= '!' || c >= '#' && c <= '[' || c >= ']' && c <= 'ÿ': - goto yystate320 - } - -yystate321: - c = l.next() - goto yyrule13 - -yystate322: - c = l.next() - switch { - default: - goto yyabort - case c == '"': - goto yystate323 - case c == '\\': - goto yystate322 - case c >= '\x01' && c <= '!' || c >= '#' && c <= '[' || c >= ']' && c <= 'ÿ': - goto yystate320 - } - -yystate323: - c = l.next() - switch { - default: - goto yyrule13 - case c == '"': - goto yystate321 - case c == '\\': - goto yystate322 - case c >= '\x01' && c <= '!' || c >= '#' && c <= '[' || c >= ']' && c <= 'ÿ': - goto yystate320 - } - - goto yystate324 // silence unused label error -yystate324: - c = l.next() -yystart324: - switch { - default: - goto yystate325 // c >= '\x01' && c <= '_' || c >= 'a' && c <= 'ÿ' - case c == '\x00': - goto yystate2 - case c == '`': - goto yystate326 - } - -yystate325: - c = l.next() - switch { - default: - goto yyabort - case c == '`': - goto yystate326 - case c >= '\x01' && c <= '_' || c >= 'a' && c <= 'ÿ': - goto yystate325 - } - -yystate326: - c = l.next() - goto yyrule14 - -yyrule1: // \0 - { - return 0 - } -yyrule2: // [ \t\n\r]+ - - goto yystate0 -yyrule3: // --.* - - goto yystate0 -yyrule4: // \/\/.* - - goto yystate0 -yyrule5: // \/\*([^*]|\*+[^*/])*\*+\/ - - goto yystate0 -yyrule6: // {imaginary_ilit} - { - return l.int(lval, true) - } -yyrule7: // {imaginary_lit} - { - return l.float(lval, true) - } -yyrule8: // {int_lit} - { - return l.int(lval, false) - } -yyrule9: // {float_lit} - { - return l.float(lval, false) - } -yyrule10: // \" - { - l.sc = S1 - goto yystate0 - } -yyrule11: // ` - { - l.sc = S2 - goto yystate0 - } -yyrule12: // '(\\.|[^'])*' - { - if ret := l.str(lval, ""); ret != stringLit { - return ret - } - lval.item = idealRune(lval.item.(string)[0]) - return intLit - } -yyrule13: // (\\.|[^\"])*\" - { - return l.str(lval, "\"") - } -yyrule14: // ([^`]|\n)*` - { - return l.str(lval, "`") - } -yyrule15: // "&&" - { - return andand - } -yyrule16: // "&^" - { - return andnot - } -yyrule17: // "<<" - { - return lsh - } -yyrule18: // "<=" - { - return le - } -yyrule19: // "==" - { - return eq - } -yyrule20: // ">=" - { - return ge - } -yyrule21: // "!=" - { - return neq - } -yyrule22: // "||" - { - return oror - } -yyrule23: // ">>" - { - return rsh - } -yyrule24: // {add} - { - return add - } -yyrule25: // {alter} - { - return alter - } -yyrule26: // {and} - { - return and - } -yyrule27: // {asc} - { - return asc - } -yyrule28: // {as} - { - return as - } -yyrule29: // {begin} - { - return begin - } -yyrule30: // {between} - { - return between - } -yyrule31: // {by} - { - return by - } -yyrule32: // {column} - { - return column - } -yyrule33: // {commit} - { - return commit - } -yyrule34: // {create} - { - return create - } -yyrule35: // {default} - { - return defaultKwd - } -yyrule36: // {delete} - { - return deleteKwd - } -yyrule37: // {desc} - { - return desc - } -yyrule38: // {distinct} - { - return distinct - } -yyrule39: // {drop} - { - return drop - } -yyrule40: // {exists} - { - return exists - } -yyrule41: // {explain} - { - return explain - } -yyrule42: // {from} - { - return from - } -yyrule43: // {full} - { - return full - } -yyrule44: // {group} - { - return group - } -yyrule45: // {if} - { - return ifKwd - } -yyrule46: // {index} - { - return index - } -yyrule47: // {insert} - { - return insert - } -yyrule48: // {into} - { - return into - } -yyrule49: // {in} - { - return in - } -yyrule50: // {is} - { - return is - } -yyrule51: // {join} - { - return join - } -yyrule52: // {left} - { - return left - } -yyrule53: // {like} - { - return like - } -yyrule54: // {limit} - { - return limit - } -yyrule55: // {not} - { - return not - } -yyrule56: // {offset} - { - return offset - } -yyrule57: // {on} - { - return on - } -yyrule58: // {order} - { - return order - } -yyrule59: // {or} - { - return or - } -yyrule60: // {outer} - { - return outer - } -yyrule61: // {right} - { - return right - } -yyrule62: // {rollback} - { - return rollback - } -yyrule63: // {select} - { - l.agg = append(l.agg, false) - return selectKwd - } -yyrule64: // {set} - { - return set - } -yyrule65: // {table} - { - return tableKwd - } -yyrule66: // {transaction} - { - return transaction - } -yyrule67: // {truncate} - { - return truncate - } -yyrule68: // {update} - { - return update - } -yyrule69: // {unique} - { - return unique - } -yyrule70: // {values} - { - return values - } -yyrule71: // {where} - { - return where - } -yyrule72: // {null} - { - lval.item = nil - return null - } -yyrule73: // {false} - { - lval.item = false - return falseKwd - } -yyrule74: // {true} - { - lval.item = true - return trueKwd - } -yyrule75: // {bigint} - { - lval.item = qBigInt - return bigIntType - } -yyrule76: // {bigrat} - { - lval.item = qBigRat - return bigRatType - } -yyrule77: // {blob} - { - lval.item = qBlob - return blobType - } -yyrule78: // {bool} - { - lval.item = qBool - return boolType - } -yyrule79: // {byte} - { - lval.item = qUint8 - return byteType - } -yyrule80: // {complex}128 - { - lval.item = qComplex128 - return complex128Type - } -yyrule81: // {complex}64 - { - lval.item = qComplex64 - return complex64Type - } -yyrule82: // {duration} - { - lval.item = qDuration - return durationType - } -yyrule83: // {float} - { - lval.item = qFloat64 - return floatType - } -yyrule84: // {float}32 - { - lval.item = qFloat32 - return float32Type - } -yyrule85: // {float}64 - { - lval.item = qFloat64 - return float64Type - } -yyrule86: // {int} - { - lval.item = qInt64 - return intType - } -yyrule87: // {int}16 - { - lval.item = qInt16 - return int16Type - } -yyrule88: // {int}32 - { - lval.item = qInt32 - return int32Type - } -yyrule89: // {int}64 - { - lval.item = qInt64 - return int64Type - } -yyrule90: // {int}8 - { - lval.item = qInt8 - return int8Type - } -yyrule91: // {rune} - { - lval.item = qInt32 - return runeType - } -yyrule92: // {string} - { - lval.item = qString - return stringType - } -yyrule93: // {time} - { - lval.item = qTime - return timeType - } -yyrule94: // {uint} - { - lval.item = qUint64 - return uintType - } -yyrule95: // {uint}16 - { - lval.item = qUint16 - return uint16Type - } -yyrule96: // {uint}32 - { - lval.item = qUint32 - return uint32Type - } -yyrule97: // {uint}64 - { - lval.item = qUint64 - return uint64Type - } -yyrule98: // {uint}8 - { - lval.item = qUint8 - return uint8Type - } -yyrule99: // {ident} - { - lval.item = string(l.val) - return identifier - } -yyrule100: // ($|\?){D} - { - lval.item, _ = strconv.Atoi(string(l.val[1:])) - return qlParam - } -yyrule101: // . - { - return c0 - } - panic("unreachable") - - goto yyabort // silence unused label error - -yyabort: // no lexem recognized - return int(unicode.ReplacementChar) -} - -func (l *lexer) npos() (line, col int) { - if line, col = l.nline, l.ncol; col == 0 { - line-- - col = l.lcol + 1 - } - return -} - -func (l *lexer) str(lval *yySymType, pref string) int { - l.sc = 0 - s := pref + string(l.val) - s, err := strconv.Unquote(s) - if err != nil { - l.err("string literal: %v", err) - return int(unicode.ReplacementChar) - } - - lval.item = s - return stringLit -} - -func (l *lexer) int(lval *yySymType, im bool) int { - if im { - l.val = l.val[:len(l.val)-1] - } - n, err := strconv.ParseUint(string(l.val), 0, 64) - if err != nil { - l.err("integer literal: %v", err) - return int(unicode.ReplacementChar) - } - - if im { - lval.item = idealComplex(complex(0, float64(n))) - return imaginaryLit - } - - switch { - case n < math.MaxInt64: - lval.item = idealInt(n) - default: - lval.item = idealUint(n) - } - return intLit -} - -func (l *lexer) float(lval *yySymType, im bool) int { - if im { - l.val = l.val[:len(l.val)-1] - } - n, err := strconv.ParseFloat(string(l.val), 64) - if err != nil { - l.err("float literal: %v", err) - return int(unicode.ReplacementChar) - } - - if im { - lval.item = idealComplex(complex(0, n)) - return imaginaryLit - } - - lval.item = idealFloat(n) - return floatLit -} diff --git a/Godeps/_workspace/src/github.com/cznic/ql/scanner.l b/Godeps/_workspace/src/github.com/cznic/ql/scanner.l deleted file mode 100644 index 1f28714189..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/scanner.l +++ /dev/null @@ -1,462 +0,0 @@ -/* -Copyright (c) 2014 The ql 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 ql - -import ( - "fmt" - "math" - "strconv" - "unicode" -) - -type lexer struct { - agg []bool - c int - col int - errs []error - expr expression - i int - inj int - lcol int - line int - list []stmt - ncol int - nline int - params int - sc int - src string - val []byte - root bool -} - -func newLexer(src string) (l *lexer) { - l = &lexer{ - src: src, - nline: 1, - ncol: 0, - } - l.next() - return -} - -func (l *lexer) next() int { - if l.c != 0 { - l.val = append(l.val, byte(l.c)) - } - l.c = 0 - if l.i < len(l.src) { - l.c = int(l.src[l.i]) - l.i++ - } - switch l.c { - case '\n': - l.lcol = l.ncol - l.nline++ - l.ncol = 0 - default: - l.ncol++ - } - return l.c -} - -func (l *lexer) err0(ln, c int, s string, arg ...interface{}) { - err := fmt.Errorf(fmt.Sprintf("%d:%d ", ln, c)+s, arg...) - l.errs = append(l.errs, err) -} - -func (l *lexer) err(s string, arg ...interface{}) { - l.err0(l.line, l.col, s, arg...) -} - -func (l *lexer) Error(s string) { - l.err(s) -} - -func (l *lexer) Lex(lval *yySymType) (r int) { - //defer func() { dbg("Lex -> %d(%#x)", r, r) }() - defer func() { - lval.line, lval.col = l.line, l.col - }() - const ( - INITIAL = iota - S1 - S2 - ) - - if n := l.inj; n != 0 { - l.inj = 0 - return n - } - - c0, c := 0, l.c -%} - -int_lit {decimal_lit}|{octal_lit}|{hex_lit} -decimal_lit [1-9][0-9]* -octal_lit 0[0-7]* -hex_lit 0[xX][0-9a-fA-F]+ - -float_lit {D}"."{D}?{E}?|{D}{E}|"."{D}{E}? -D [0-9]+ -E [eE][-+]?[0-9]+ - -imaginary_ilit {D}i -imaginary_lit {float_lit}i - -a [aA] -b [bB] -c [cC] -d [dD] -e [eE] -f [fF] -g [gG] -h [hH] -i [iI] -j [jJ] -k [kK] -l [lL] -m [mM] -n [nN] -o [oO] -p [pP] -q [qQ] -r [rR] -s [sS] -t [tT] -u [uU] -v [vV] -w [wW] -x [xX] -y [yY] -z [zZ] - -add {a}{d}{d} -alter {a}{l}{t}{e}{r} -and {a}{n}{d} -as {a}{s} -asc {a}{s}{c} -begin {b}{e}{g}{i}{n} -between {b}{e}{t}{w}{e}{e}{n} -by {b}{y} -column {c}{o}{l}{u}{m}{n} -commit {c}{o}{m}{m}{i}{t} -create {c}{r}{e}{a}{t}{e} -default {d}{e}{f}{a}{u}{l}{t} -delete {d}{e}{l}{e}{t}{e} -desc {d}{e}{s}{c} -distinct {d}{i}{s}{t}{i}{n}{c}{t} -drop {d}{r}{o}{p} -exists {e}{x}{i}{s}{t}{s} -explain {e}{x}{p}{l}{a}{i}{n} -from {f}{r}{o}{m} -full {f}{u}{l}{l} -group {g}{r}{o}{u}{p} -if {i}{f} -in {i}{n} -index {i}{n}{d}{e}{x} -insert {i}{n}{s}{e}{r}{t} -into {i}{n}{t}{o} -is {i}{s} -join {j}{o}{i}{n} -left {l}{e}{f}{t} -like {l}{i}{k}{e} -limit {l}{i}{m}{i}{t} -not {n}{o}{t} -offset {o}{f}{f}{s}{e}{t} -on {o}{n} -or {o}{r} -order {o}{r}{d}{e}{r} -outer {o}{u}{t}{e}{r} -right {r}{i}{g}{h}{t} -rollback {r}{o}{l}{l}{b}{a}{c}{k} -select {s}{e}{l}{e}{c}{t} -set {s}{e}{t} -table {t}{a}{b}{l}{e} -transaction {t}{r}{a}{n}{s}{a}{c}{t}{i}{o}{n} -truncate {t}{r}{u}{n}{c}{a}{t}{e} -unique {u}{n}{i}{q}{u}{e} -update {u}{p}{d}{a}{t}{e} -values {v}{a}{l}{u}{e}{s} -where {w}{h}{e}{r}{e} - -null {n}{u}{l}{l} -false {f}{a}{l}{s}{e} -true {t}{r}{u}{e} - -bigint {b}{i}{g}{i}{n}{t} -bigrat {b}{i}{g}{r}{a}{t} -blob {b}{l}{o}{b} -bool {b}{o}{o}{l} -byte {b}{y}{t}{e} -complex {c}{o}{m}{p}{l}{e}{x} -duration {d}{u}{r}{a}{t}{i}{o}{n} -float {f}{l}{o}{a}{t} -int {i}{n}{t} -rune {r}{u}{n}{e} -string {s}{t}{r}{i}{n}{g} -time {t}{i}{m}{e} -uint {u}{i}{n}{t} - -idchar0 [a-zA-Z_] -idchars {idchar0}|[0-9] -ident {idchar0}{idchars}* - -%yyc c -%yyn c = l.next() -%yyt l.sc - -%x S1 S2 - -%% - l.val = l.val[:0] - c0, l.line, l.col = l.c, l.nline, l.ncol - -<*>\0 return 0 - -[ \t\n\r]+ ---.* -\/\/.* -\/\*([^*]|\*+[^*/])*\*+\/ - -{imaginary_ilit} return l.int(lval, true) -{imaginary_lit} return l.float(lval, true) -{int_lit} return l.int(lval, false) -{float_lit} return l.float(lval, false) - -\" l.sc = S1 -` l.sc = S2 - -'(\\.|[^'])*' if ret := l.str(lval, ""); ret != stringLit { - return ret - } - lval.item = idealRune(lval.item.(string)[0]) - return intLit - -(\\.|[^\"])*\" return l.str(lval, "\"") -([^`]|\n)*` return l.str(lval, "`") - -"&&" return andand -"&^" return andnot -"<<" return lsh -"<=" return le -"==" return eq -">=" return ge -"!=" return neq -"||" return oror -">>" return rsh - -{add} return add -{alter} return alter -{and} return and -{asc} return asc -{as} return as -{begin} return begin -{between} return between -{by} return by -{column} return column -{commit} return commit -{create} return create -{default} return defaultKwd -{delete} return deleteKwd -{desc} return desc -{distinct} return distinct -{drop} return drop -{exists} return exists -{explain} return explain -{from} return from -{full} return full -{group} return group -{if} return ifKwd -{index} return index -{insert} return insert -{into} return into -{in} return in -{is} return is -{join} return join -{left} return left -{like} return like -{limit} return limit -{not} return not -{offset} return offset -{on} return on -{order} return order -{or} return or -{outer} return outer -{right} return right - -{rollback} return rollback - -{select} l.agg = append(l.agg, false) - return selectKwd - -{set} return set -{table} return tableKwd -{transaction} return transaction -{truncate} return truncate -{update} return update -{unique} return unique -{values} return values -{where} return where - -{null} lval.item = nil - return null - -{false} lval.item = false - return falseKwd - -{true} lval.item = true - return trueKwd - -{bigint} lval.item = qBigInt - return bigIntType - -{bigrat} lval.item = qBigRat - return bigRatType - -{blob} lval.item = qBlob - return blobType - -{bool} lval.item = qBool - return boolType - -{byte} lval.item = qUint8 - return byteType - -{complex}128 lval.item = qComplex128 - return complex128Type - -{complex}64 lval.item = qComplex64 - return complex64Type - -{duration} lval.item = qDuration - return durationType - -{float} lval.item = qFloat64 - return floatType - -{float}32 lval.item = qFloat32 - return float32Type - -{float}64 lval.item = qFloat64 - return float64Type - -{int} lval.item = qInt64 - return intType - -{int}16 lval.item = qInt16 - return int16Type - -{int}32 lval.item = qInt32 - return int32Type - -{int}64 lval.item = qInt64 - return int64Type - -{int}8 lval.item = qInt8 - return int8Type - -{rune} lval.item = qInt32 - return runeType - -{string} lval.item = qString - return stringType - -{time} lval.item = qTime - return timeType - -{uint} lval.item = qUint64 - return uintType - -{uint}16 lval.item = qUint16 - return uint16Type - -{uint}32 lval.item = qUint32 - return uint32Type - -{uint}64 lval.item = qUint64 - return uint64Type - -{uint}8 lval.item = qUint8 - return uint8Type - -{ident} lval.item = string(l.val) - return identifier - -($|\?){D} lval.item, _ = strconv.Atoi(string(l.val[1:])) - return qlParam - -. return c0 - -%% - return int(unicode.ReplacementChar) -} - -func (l *lexer) npos() (line, col int) { - if line, col = l.nline, l.ncol; col == 0 { - line-- - col = l.lcol+1 - } - return -} - -func (l *lexer) str(lval *yySymType, pref string) int { - l.sc = 0 - s := pref + string(l.val) - s, err := strconv.Unquote(s) - if err != nil { - l.err("string literal: %v", err) - return int(unicode.ReplacementChar) - } - - lval.item = s - return stringLit -} - -func (l *lexer) int(lval *yySymType, im bool) int { - if im { - l.val = l.val[:len(l.val)-1] - } - n, err := strconv.ParseUint(string(l.val), 0, 64) - if err != nil { - l.err("integer literal: %v", err) - return int(unicode.ReplacementChar) - } - - if im { - lval.item = idealComplex(complex(0, float64(n))) - return imaginaryLit - } - - switch { - case n < math.MaxInt64: - lval.item = idealInt(n) - default: - lval.item = idealUint(n) - } - return intLit -} - -func (l *lexer) float(lval *yySymType, im bool) int { - if im { - l.val = l.val[:len(l.val)-1] - } - n, err := strconv.ParseFloat(string(l.val), 64) - if err != nil { - l.err("float literal: %v", err) - return int(unicode.ReplacementChar) - } - - if im { - lval.item = idealComplex(complex(0, n)) - return imaginaryLit - } - - lval.item = idealFloat(n) - return floatLit -} diff --git a/Godeps/_workspace/src/github.com/cznic/ql/stmt.go b/Godeps/_workspace/src/github.com/cznic/ql/stmt.go deleted file mode 100644 index 8de367d4c9..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/stmt.go +++ /dev/null @@ -1,1268 +0,0 @@ -// Copyright (c) 2014 ql 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 ql - -import ( - "bytes" - "fmt" - "strings" - "sync" - - "github.com/cznic/strutil" -) - -// NOTE: all stmt implementations must be safe for concurrent use by multiple -// goroutines. If the exec method requires any execution domain local data, -// they must be held out of the implementing instance. -var ( - _ stmt = (*alterTableAddStmt)(nil) - _ stmt = (*alterTableDropColumnStmt)(nil) - _ stmt = (*createIndexStmt)(nil) - _ stmt = (*createTableStmt)(nil) - _ stmt = (*deleteStmt)(nil) //TODO optimizer plan - _ stmt = (*dropIndexStmt)(nil) - _ stmt = (*dropTableStmt)(nil) - _ stmt = (*explainStmt)(nil) - _ stmt = (*insertIntoStmt)(nil) - _ stmt = (*selectStmt)(nil) - _ stmt = (*truncateTableStmt)(nil) - _ stmt = (*updateStmt)(nil) //TODO optimizer plan - _ stmt = beginTransactionStmt{} - _ stmt = commitStmt{} - _ stmt = rollbackStmt{} -) - -var ( - createColumn2 = mustCompile(` - create table if not exists __Column2 ( - TableName string, - Name string, - NotNull bool, - ConstraintExpr string, - DefaultExpr string, - ); - create index if not exists __Column2TableName on __Column2(TableName); - `) - - insertColumn2 = mustCompile(`insert into __Column2 values($1, $2, $3, $4, $5)`) - - selectColumn2 = MustCompile(` - select Name, NotNull, ConstraintExpr, DefaultExpr - from __Column2 - where TableName == $1 - `) - - deleteColumn2 = mustCompile(` - delete from __Column2 - where TableName == $1 && Name == $2 - `) - - createIndex2 = mustCompile(` - // Index register 2. - create table if not exists __Index2( - TableName string, - IndexName string, - IsUnique bool, - IsSimple bool, // Just a column name or id(). - Root int64, // BTree handle - ); - - // Expressions for given index. Compared in order of id(__Index2_Expr). - create table if not exists __Index2_Expr( - Index2_ID int, - Expr string, - ); - - create index if not exists __xIndex2_TableName on __Index2(TableName); - create unique index if not exists __xIndex2_IndexName on __Index2(IndexName); - create index if not exists __xIndex2_ID on __Index2(id()); - create index if not exists __xIndex2_Expr_Index2_ID on __Index2_Expr(Index2_ID); -`) - - insertIndex2 = mustCompile("insert into __Index2 values($1, $2, $3, $4, $5)") - insertIndex2Expr = mustCompile("insert into __Index2_Expr values($1, $2)") - - deleteIndex2ByIndexName = mustCompile(` - delete from __Index2_Expr - where Index2_ID in ( - select id() from __Index2 where IndexName == $1; - ); - - delete from __Index2 - where IndexName == $1; -`) - deleteIndex2ByTableName = mustCompile(` - delete from __Index2_Expr - where Index2_ID in ( - select id() from __Index2 where TableName == $1; - ); - - delete from __Index2 - where TableName == $1; -`) -) - -type stmt interface { - // never invoked for - // - beginTransactionStmt - // - commitStmt - // - rollbackStmt - exec(ctx *execCtx) (Recordset, error) - - explain(ctx *execCtx, w strutil.Formatter) - - // return value ignored for - // - beginTransactionStmt - // - commitStmt - // - rollbackStmt - isUpdating() bool - String() string -} - -type execCtx struct { //LATER +shared temp - db *DB - arg []interface{} -} - -type explainStmt struct { - s stmt -} - -func (s *explainStmt) explain(ctx *execCtx, w strutil.Formatter) { - for { - x, ok := s.s.(*explainStmt) - if !ok { - s.s.explain(ctx, w) - return - } - - s = x - } -} - -func (s *explainStmt) String() string { - return "EXPLAIN " + s.s.String() -} - -func (*explainStmt) isUpdating() bool { return false } - -func (s *explainStmt) exec(ctx *execCtx) (_ Recordset, err error) { - return recordset{ctx, &explainDefaultPlan{s.s}, ctx.db.cc}, nil -} - -type updateStmt struct { - tableName string - list []assignment - where expression -} - -func (s *updateStmt) explain(ctx *execCtx, w strutil.Formatter) { - w.Format("%s\n", s) -} - -func (s *updateStmt) String() string { - u := fmt.Sprintf("UPDATE %s", s.tableName) - a := make([]string, len(s.list)) - for i, v := range s.list { - a[i] = v.String() - } - w := "" - if s.where != nil { - w = fmt.Sprintf(" WHERE %s", s.where) - } - return fmt.Sprintf("%s %s%s;", u, strings.Join(a, ", "), w) -} - -func (s *updateStmt) exec(ctx *execCtx) (_ Recordset, err error) { - t, ok := ctx.db.root.tables[s.tableName] - if !ok { - return nil, fmt.Errorf("UPDATE: table %s does not exist", s.tableName) - } - - tcols := make([]*col, len(s.list)) - for i, asgn := range s.list { - col := findCol(t.cols, asgn.colName) - if col == nil { - return nil, fmt.Errorf("UPDATE: unknown column %s", asgn.colName) - } - tcols[i] = col - } - - m := map[interface{}]interface{}{} - var nh int64 - expr := s.where - blobCols := t.blobCols() - cc := ctx.db.cc - var old []interface{} - var touched []bool - if t.hasIndices() { - old = make([]interface{}, len(t.cols0)) - touched = make([]bool, len(t.cols0)) - } - for h := t.head; h != 0; h = nh { - // Read can return lazily expanded chunks - data, err := t.store.Read(nil, h, t.cols...) - if err != nil { - return nil, err - } - - nh = data[0].(int64) - for _, col := range t.cols { - m[col.name] = data[2+col.index] - } - id := data[1].(int64) - m["$id"] = id - if expr != nil { - val, err := s.where.eval(ctx, m) - if err != nil { - return nil, err - } - - if val == nil { - continue - } - - x, ok := val.(bool) - if !ok { - return nil, fmt.Errorf("invalid WHERE expression %s (value of type %T)", val, val) - } - - if !x { - continue - } - } - - // hit - for _, ix := range t.indices2 { - vlist, err := ix.eval(ctx, t.cols, id, data[2:]) - if err != nil { - return nil, err - } - - if err := ix.x.Delete(vlist, h); err != nil { - return nil, err - } - } - for i, asgn := range s.list { - val, err := asgn.expr.eval(ctx, m) - if err != nil { - return nil, err - } - - colIndex := tcols[i].index - if t.hasIndices() { - old[colIndex] = data[2+colIndex] - touched[colIndex] = true - } - data[2+colIndex] = val - } - if err = typeCheck(data[2:], t.cols); err != nil { - return nil, err - } - - if err = t.checkConstraintsAndDefaults(ctx, data[2:], m); err != nil { - return nil, err - } - - for i, v := range t.indices { - if i == 0 { // id() N/A - continue - } - - if v == nil || !touched[i-1] { - continue - } - - if err = v.x.Delete([]interface{}{old[i-1]}, h); err != nil { - return nil, err - } - } - - if err = t.store.UpdateRow(h, blobCols, data...); err != nil { //LATER detect which blobs are actually affected - return nil, err - } - - for i, v := range t.indices { - if i == 0 { // id() N/A - continue - } - - if v == nil || !touched[i-1] { - continue - } - - if err = v.x.Create([]interface{}{data[2+i-1]}, h); err != nil { - return nil, err - } - } - for _, ix := range t.indices2 { - vlist, err := ix.eval(ctx, t.cols, id, data[2:]) - if err != nil { - return nil, err - } - - if err := ix.x.Create(vlist, h); err != nil { - return nil, err - } - } - - cc.RowsAffected++ - } - return -} - -func (s *updateStmt) isUpdating() bool { return true } - -type deleteStmt struct { - tableName string - where expression -} - -func (s *deleteStmt) explain(ctx *execCtx, w strutil.Formatter) { - w.Format("%s\n", s) -} - -func (s *deleteStmt) String() string { - switch { - case s.where == nil: - return fmt.Sprintf("DELETE FROM %s;", s.tableName) - default: - return fmt.Sprintf("DELETE FROM %s WHERE %s;", s.tableName, s.where) - } -} - -func (s *deleteStmt) exec(ctx *execCtx) (_ Recordset, err error) { - t, ok := ctx.db.root.tables[s.tableName] - if !ok { - return nil, fmt.Errorf("DELETE FROM: table %s does not exist", s.tableName) - } - - m := map[interface{}]interface{}{} - var ph, h, nh int64 - var data []interface{} - blobCols := t.blobCols() - cc := ctx.db.cc - for h = t.head; h != 0; ph, h = h, nh { - for i, v := range data { - c, ok := v.(chunk) - if !ok { - continue - } - - data[i] = c.b - } - // Read can return lazily expanded chunks - data, err = t.store.Read(nil, h, t.cols...) - if err != nil { - return nil, err - } - - nh = data[0].(int64) - for _, col := range t.cols { - m[col.name] = data[2+col.index] - } - id := data[1].(int64) - m["$id"] = id - val, err := s.where.eval(ctx, m) - if err != nil { - return nil, err - } - - if val == nil { - continue - } - - x, ok := val.(bool) - if !ok { - return nil, fmt.Errorf("invalid WHERE expression %s (value of type %T)", val, val) - } - - if !x { - continue - } - - // hit - for i, v := range t.indices { - if v == nil { - continue - } - - // overflow chunks left in place - if err = v.x.Delete([]interface{}{data[i+1]}, h); err != nil { - return nil, err - } - } - for _, ix := range t.indices2 { - vlist, err := ix.eval(ctx, t.cols, id, data[2:]) - if err != nil { - return nil, err - } - - if err := ix.x.Delete(vlist, h); err != nil { - return nil, err - } - } - - // overflow chunks freed here - if err = t.store.Delete(h, blobCols...); err != nil { - return nil, err - } - - cc.RowsAffected++ - switch { - case ph == 0 && nh == 0: // "only" - fallthrough - case ph == 0 && nh != 0: // "first" - if err = t.store.Update(t.hhead, nh); err != nil { - return nil, err - } - - t.head, h = nh, 0 - case ph != 0 && nh == 0: // "last" - fallthrough - case ph != 0 && nh != 0: // "inner" - pdata, err := t.store.Read(nil, ph, t.cols...) - if err != nil { - return nil, err - } - - for i, v := range pdata { - if x, ok := v.(chunk); ok { - pdata[i] = x.b - } - } - pdata[0] = nh - if err = t.store.Update(ph, pdata...); err != nil { - return nil, err - } - - h = ph - } - } - - return -} - -func (s *deleteStmt) isUpdating() bool { return true } - -type truncateTableStmt struct { - tableName string -} - -func (s *truncateTableStmt) explain(ctx *execCtx, w strutil.Formatter) { - w.Format("%s\n", s) -} - -func (s *truncateTableStmt) String() string { return fmt.Sprintf("TRUNCATE TABLE %s;", s.tableName) } - -func (s *truncateTableStmt) exec(ctx *execCtx) (Recordset, error) { - t, ok := ctx.db.root.tables[s.tableName] - if !ok { - return nil, fmt.Errorf("TRUNCATE TABLE: table %s does not exist", s.tableName) - } - - return nil, t.truncate() -} - -func (s *truncateTableStmt) isUpdating() bool { return true } - -type dropIndexStmt struct { - ifExists bool - indexName string -} - -func (s *dropIndexStmt) explain(ctx *execCtx, w strutil.Formatter) { - w.Format("%s\n", s) -} - -func (s *dropIndexStmt) String() string { return fmt.Sprintf("DROP INDEX %s;", s.indexName) } - -func (s *dropIndexStmt) exec(ctx *execCtx) (Recordset, error) { - t, x := ctx.db.root.findIndexByName(s.indexName) - if x == nil { - if s.ifExists { - return nil, nil - } - - return nil, fmt.Errorf("DROP INDEX: index %s does not exist", s.indexName) - } - - if ctx.db.hasAllIndex2() { - if err := ctx.db.deleteIndex2ByIndexName(s.indexName); err != nil { - return nil, err - } - } - - switch ix := x.(type) { - case *indexedCol: - for i, v := range t.indices { - if v == nil || v.name != s.indexName { - continue - } - - return nil, t.dropIndex(i) - } - case *index2: - delete(t.indices2, s.indexName) - return nil, ix.x.Drop() - } - - panic("internal error 058") -} - -func (s *dropIndexStmt) isUpdating() bool { return true } - -type dropTableStmt struct { - ifExists bool - tableName string -} - -func (s *dropTableStmt) explain(ctx *execCtx, w strutil.Formatter) { - w.Format("%s\n", s) -} - -func (s *dropTableStmt) String() string { return fmt.Sprintf("DROP TABLE %s;", s.tableName) } - -func (s *dropTableStmt) exec(ctx *execCtx) (Recordset, error) { - t, ok := ctx.db.root.tables[s.tableName] - if !ok { - if s.ifExists { - return nil, nil - } - - return nil, fmt.Errorf("DROP TABLE: table %s does not exist", s.tableName) - } - - if ctx.db.hasAllIndex2() { - if err := ctx.db.deleteIndex2ByTableName(s.tableName); err != nil { - return nil, err - } - } - - return nil, ctx.db.root.dropTable(t) -} - -func (s *dropTableStmt) isUpdating() bool { return true } - -type alterTableDropColumnStmt struct { - tableName, colName string -} - -func (s *alterTableDropColumnStmt) explain(ctx *execCtx, w strutil.Formatter) { - w.Format("%s\n", s) -} - -func (s *alterTableDropColumnStmt) String() string { - return fmt.Sprintf("ALTER TABLE %s DROP COLUMN %s;", s.tableName, s.colName) -} - -func (s *alterTableDropColumnStmt) exec(ctx *execCtx) (Recordset, error) { - t, ok := ctx.db.root.tables[s.tableName] - if !ok { - return nil, fmt.Errorf("ALTER TABLE: table %s does not exist", s.tableName) - } - - cols := t.cols - for _, c := range cols { - if c.name == s.colName { - if len(cols) == 1 { - return nil, fmt.Errorf("ALTER TABLE %s DROP COLUMN: cannot drop the only column: %s", s.tableName, s.colName) - } - - if _, ok := ctx.db.root.tables["__Column2"]; ok { - if _, err := deleteColumn2.l[0].exec(&execCtx{db: ctx.db, arg: []interface{}{s.tableName, c.name}}); err != nil { - return nil, err - } - } - - c.name = "" - t.cols0[c.index].name = "" - if t.hasIndices() { - if len(t.indices) != 0 { - if v := t.indices[c.index+1]; v != nil { - if err := t.dropIndex(c.index + 1); err != nil { - return nil, err - } - - if ctx.db.hasAllIndex2() { - if err := ctx.db.deleteIndex2ByIndexName(v.name); err != nil { - return nil, err - } - } - } - } - - for nm, ix := range t.indices2 { - for _, e := range ix.exprList { - m := mentionedColumns(e) - if _, ok := m[s.colName]; ok { - if err := ctx.db.deleteIndex2ByIndexName(nm); err != nil { - return nil, err - } - - if err := ix.x.Drop(); err != nil { - return nil, err - } - - delete(t.indices2, nm) - break - } - } - } - } - if err := t.constraintsAndDefaults(ctx); err != nil { - return nil, err - } - - return nil, t.updated() - } - } - - return nil, fmt.Errorf("ALTER TABLE %s DROP COLUMN: column %s does not exist", s.tableName, s.colName) -} - -func (s *alterTableDropColumnStmt) isUpdating() bool { return true } - -type alterTableAddStmt struct { - tableName string - c *col -} - -func (s *alterTableAddStmt) explain(ctx *execCtx, w strutil.Formatter) { - w.Format("%s\n", s) -} - -func (s *alterTableAddStmt) String() string { - r := fmt.Sprintf("ALTER TABLE %s ADD %s %s", s.tableName, s.c.name, typeStr(s.c.typ)) - c := s.c - if x := c.constraint; x != nil { //TODO add (*col).String() - switch e := x.expr; { - case e != nil: - r += " " + e.String() - default: - r += " NOT NULL" - } - } - if x := c.dflt; x != nil { - r += " DEFAULT " + x.String() - } - return r + ";" -} - -func (s *alterTableAddStmt) exec(ctx *execCtx) (Recordset, error) { - t, ok := ctx.db.root.tables[s.tableName] - if !ok { - return nil, fmt.Errorf("ALTER TABLE: table %s does not exist", s.tableName) - } - - hasRecords := t.head != 0 - c := s.c - if c.constraint != nil && hasRecords { - return nil, fmt.Errorf("ALTER TABLE %s ADD %s: cannot add constrained column to table with existing data", s.tableName, c.name) - } - - cols := t.cols - for _, c := range cols { - nm := c.name - if nm == s.c.name { - return nil, fmt.Errorf("ALTER TABLE %s ADD: column %s exists", s.tableName, nm) - } - } - - if len(t.indices) != 0 { - t.indices = append(t.indices, nil) - t.xroots = append(t.xroots, 0) - if err := t.store.Update(t.hxroots, t.xroots...); err != nil { - return nil, err - } - } - - if c.constraint != nil || c.dflt != nil { - for _, s := range createColumn2.l { - _, err := s.exec(&execCtx{db: ctx.db}) - if err != nil { - return nil, err - } - } - notNull := c.constraint != nil && c.constraint.expr == nil - var co, d string - if c.constraint != nil && c.constraint.expr != nil { - co = c.constraint.expr.String() - } - if e := c.dflt; e != nil { - d = e.String() - } - if _, err := insertColumn2.l[0].exec(&execCtx{db: ctx.db, arg: []interface{}{s.tableName, c.name, notNull, co, d}}); err != nil { - return nil, err - } - } - - t.cols0 = append(t.cols0, s.c) - if err := t.constraintsAndDefaults(ctx); err != nil { - return nil, err - } - - return nil, t.updated() -} - -func (s *alterTableAddStmt) isUpdating() bool { return true } - -type selectStmt struct { - distinct bool - flds []*fld - from *joinRset - group *groupByRset - hasAggregates bool - limit *limitRset - mu sync.Mutex - offset *offsetRset - order *orderByRset - where *whereRset -} - -func (s *selectStmt) explain(ctx *execCtx, w strutil.Formatter) { - p, err := s.plan(ctx) - if err != nil { - w.Format("ERROR: %v\n", err) - return - } - - p.explain(w) -} - -func (s *selectStmt) String() string { - var b bytes.Buffer - b.WriteString("SELECT") - if s.distinct { - b.WriteString(" DISTINCT") - } - switch { - case len(s.flds) == 0: - b.WriteString(" *") - default: - a := make([]string, len(s.flds)) - for i, v := range s.flds { - s := v.expr.String() - if v.name != "" && v.name != s { - s += " AS " + v.name - } - a[i] = s - } - b.WriteString(" " + strings.Join(a, ", ")) - } - b.WriteString(" FROM ") - b.WriteString(s.from.String()) - if s.where != nil { - b.WriteString(" WHERE ") - b.WriteString(s.where.expr.String()) - } - if s.group != nil { - b.WriteString(" GROUP BY ") - b.WriteString(strings.Join(s.group.colNames, ", ")) - } - if s.order != nil { - b.WriteString(" ORDER BY ") - b.WriteString(s.order.String()) - } - if s.limit != nil { - b.WriteString(" LIMIT ") - b.WriteString(s.limit.expr.String()) - } - if s.offset != nil { - b.WriteString(" OFFSET ") - b.WriteString(s.offset.expr.String()) - } - b.WriteRune(';') - return b.String() -} - -func (s *selectStmt) plan(ctx *execCtx) (plan, error) { //LATER overlapping goroutines/pipelines - r, err := s.from.plan(ctx) - if err != nil { - return nil, err - } - - if w := s.where; w != nil { - if r, err = (&whereRset{expr: w.expr, src: r}).plan(ctx); err != nil { - return nil, err - } - } - switch { - case !s.hasAggregates && s.group == nil: // nop - case !s.hasAggregates && s.group != nil: - if r, err = (&groupByRset{colNames: s.group.colNames, src: r}).plan(ctx); err != nil { - return nil, err - } - case s.hasAggregates && s.group == nil: - if r, err = (&groupByRset{src: r}).plan(ctx); err != nil { - return nil, err - } - case s.hasAggregates && s.group != nil: - if r, err = (&groupByRset{colNames: s.group.colNames, src: r}).plan(ctx); err != nil { - return nil, err - } - } - if r, err = (&selectRset{flds: s.flds, src: r}).plan(ctx); err != nil { - return nil, err - } - - if s.distinct { - if r, err = (&distinctRset{src: r}).plan(ctx); err != nil { - return nil, err - } - } - if s := s.order; s != nil { - if r, err = (&orderByRset{asc: s.asc, by: s.by, src: r}).plan(ctx); err != nil { - return nil, err - } - } - if s := s.offset; s != nil { - if r, err = (&offsetRset{s.expr, r}).plan(ctx); err != nil { - return nil, err - } - } - if s := s.limit; s != nil { - if r, err = (&limitRset{s.expr, r}).plan(ctx); err != nil { - return nil, err - } - } - return r, nil -} - -func (s *selectStmt) exec(ctx *execCtx) (rs Recordset, err error) { - r, err := s.plan(ctx) - if err != nil { - return nil, err - } - - return recordset{ctx, r, nil}, nil -} - -func (s *selectStmt) isUpdating() bool { return false } - -type insertIntoStmt struct { - colNames []string - lists [][]expression - sel *selectStmt - tableName string -} - -func (s *insertIntoStmt) explain(ctx *execCtx, w strutil.Formatter) { - w.Format("%s\n", s) -} - -func (s *insertIntoStmt) String() string { - cn := "" - if len(s.colNames) != 0 { - cn = fmt.Sprintf(" (%s)", strings.Join(s.colNames, ", ")) - } - switch { - case s.sel != nil: - return fmt.Sprintf("INSERT INTO %s%s %s;", s.tableName, cn, s.sel) - default: - a := make([]string, len(s.lists)) - for i, v := range s.lists { - b := make([]string, len(v)) - for i, v := range v { - b[i] = v.String() - } - a[i] = fmt.Sprintf("(%s)", strings.Join(b, ", ")) - } - return fmt.Sprintf("INSERT INTO %s%s VALUES %s;", s.tableName, cn, strings.Join(a, ", ")) - } -} - -func (s *insertIntoStmt) execSelect(t *table, cols []*col, ctx *execCtx) (_ Recordset, err error) { - //TODO missing rs column number eq check - r, err := s.sel.plan(ctx) - if err != nil { - return nil, err - } - - h := t.head - data0 := make([]interface{}, len(t.cols0)+2) - cc := ctx.db.cc - m := map[interface{}]interface{}{} - if err = r.do(ctx, func(_ interface{}, data []interface{}) (more bool, err error) { - for i, d := range data { - data0[cols[i].index+2] = d - } - if err = typeCheck(data0[2:], cols); err != nil { - return - } - - if err = t.checkConstraintsAndDefaults(ctx, data0[2:], m); err != nil { - return false, err - } - - id, err := t.store.ID() - if err != nil { - return false, err - } - - data0[0] = h - data0[1] = id - - // Any overflow chunks are written here. - if h, err = t.store.Create(data0...); err != nil { - return false, err - } - - for i, v := range t.indices { - if v == nil { - continue - } - - // Any overflow chunks are shared with the BTree key - if err = v.x.Create([]interface{}{data0[i+1]}, h); err != nil { - return false, err - } - } - for _, ix := range t.indices2 { - vlist, err := ix.eval(ctx, t.cols, id, data0[2:]) - if err != nil { - return false, err - } - - if err := ix.x.Create(vlist, h); err != nil { - return false, err - } - } - - cc.RowsAffected++ - ctx.db.root.lastInsertID = id - return true, nil - }); err != nil { - return nil, err - } - - t.head = h - return nil, t.store.Update(t.hhead, h) -} - -func (s *insertIntoStmt) exec(ctx *execCtx) (_ Recordset, err error) { - root := ctx.db.root - t, ok := root.tables[s.tableName] - if !ok { - return nil, fmt.Errorf("INSERT INTO %s: table does not exist", s.tableName) - } - - var cols []*col - switch len(s.colNames) { - case 0: - cols = t.cols - default: - for _, colName := range s.colNames { - if col := findCol(t.cols, colName); col != nil { - cols = append(cols, col) - continue - } - - return nil, fmt.Errorf("INSERT INTO %s: unknown column %s", s.tableName, colName) - } - } - - if s.sel != nil { - return s.execSelect(t, cols, ctx) - } - - for _, list := range s.lists { - if g, e := len(list), len(cols); g != e { - return nil, fmt.Errorf("INSERT INTO %s: expected %d value(s), have %d", s.tableName, e, g) - } - } - - cc := ctx.db.cc - r := make([]interface{}, len(t.cols0)) - m := map[interface{}]interface{}{} - for _, list := range s.lists { - for i, expr := range list { - val, err := expr.eval(ctx, m) - if err != nil { - return nil, err - } - - r[cols[i].index] = val - } - if err = typeCheck(r, cols); err != nil { - return nil, err - } - - if err = t.checkConstraintsAndDefaults(ctx, r, m); err != nil { - return nil, err - } - - id, err := t.addRecord(ctx, r) - if err != nil { - return nil, err - } - - cc.RowsAffected++ - root.lastInsertID = id - } - return nil, nil -} - -func (s *insertIntoStmt) isUpdating() bool { return true } - -type beginTransactionStmt struct{} - -func (s beginTransactionStmt) explain(ctx *execCtx, w strutil.Formatter) { - w.Format("%s\n", s) -} - -func (beginTransactionStmt) String() string { return "BEGIN TRANSACTION;" } -func (beginTransactionStmt) exec(*execCtx) (Recordset, error) { - panic("internal error 059") -} -func (beginTransactionStmt) isUpdating() bool { - panic("internal error 060") -} - -type commitStmt struct{} - -func (s commitStmt) explain(ctx *execCtx, w strutil.Formatter) { - w.Format("%s\n", s) -} - -func (commitStmt) String() string { return "COMMIT;" } -func (commitStmt) exec(*execCtx) (Recordset, error) { - panic("internal error 061") -} -func (commitStmt) isUpdating() bool { - panic("internal error 062") -} - -type rollbackStmt struct{} - -func (s rollbackStmt) explain(ctx *execCtx, w strutil.Formatter) { - w.Format("%s\n", s) -} - -func (rollbackStmt) String() string { return "ROLLBACK;" } -func (rollbackStmt) exec(*execCtx) (Recordset, error) { - panic("internal error 063") -} -func (rollbackStmt) isUpdating() bool { - panic("internal error 064") -} - -type createIndexStmt struct { - colName string // alt. "id()" for simple index on id() - ifNotExists bool - indexName string - tableName string - unique bool - exprList []expression -} - -func (s *createIndexStmt) explain(ctx *execCtx, w strutil.Formatter) { - w.Format("%s\n", s) -} - -func (s *createIndexStmt) isSimpleIndex() bool { return s.colName != "" } - -func (s *createIndexStmt) String() string { - u := "" - if s.unique { - u = "UNIQUE " - } - e := "" - if s.ifNotExists { - e = "IF NOT EXISTS " - } - expr := s.colName - if !s.isSimpleIndex() { - var a []string - for _, v := range s.exprList { - a = append(a, v.String()) - } - expr = strings.Join(a, ", ") - } - return fmt.Sprintf("CREATE %sINDEX %s%s ON %s (%s);", u, e, s.indexName, s.tableName, expr) -} - -func (s *createIndexStmt) exec(ctx *execCtx) (Recordset, error) { - root := ctx.db.root - if t, i := root.findIndexByName(s.indexName); i != nil { - if s.ifNotExists { - return nil, nil - } - - return nil, fmt.Errorf("CREATE INDEX: table %s already has an index named %s", t.name, s.indexName) - } - - if root.tables[s.indexName] != nil { - return nil, fmt.Errorf("CREATE INDEX: index name collision with existing table: %s", s.indexName) - } - - t, ok := root.tables[s.tableName] - if !ok { - return nil, fmt.Errorf("CREATE INDEX: table does not exist %s", s.tableName) - } - - if findCol(t.cols, s.indexName) != nil { - return nil, fmt.Errorf("CREATE INDEX: index name collision with existing column: %s", s.indexName) - } - - var h int64 - var err error - switch { - case s.isSimpleIndex(): - colIndex := -1 - if s.colName != "id()" { - c := findCol(t.cols, s.colName) - if c == nil { - return nil, fmt.Errorf("CREATE INDEX: column does not exist: %s", s.colName) - } - - colIndex = c.index - } - - if h, err = t.addIndex(s.unique, s.indexName, colIndex); err != nil { - return nil, fmt.Errorf("CREATE INDEX: %v", err) - } - - if err = t.updated(); err != nil { - return nil, err - } - default: - for _, e := range s.exprList { - m := mentionedColumns(e) - for colName := range m { - c := findCol(t.cols, colName) - if c == nil { - return nil, fmt.Errorf("CREATE INDEX: column does not exist: %s", colName) - } - } - } - if h, err = t.addIndex2(ctx, s.unique, s.indexName, s.exprList); err != nil { - return nil, fmt.Errorf("CREATE INDEX: %v", err) - } - } - - switch ctx.db.hasIndex2 { - case 0: - if err := ctx.db.createIndex2(); err != nil { - return nil, err - } - - if s.isSimpleIndex() { - return nil, nil - } - case 1: - return nil, nil - case 2: - if s.isSimpleIndex() { - return nil, ctx.db.insertIndex2(s.tableName, s.indexName, []string{s.colName}, s.unique, true, h) - } - default: - panic("internal error 011") - } - - exprList := make([]string, 0, len(s.exprList)) - for _, e := range s.exprList { - exprList = append(exprList, e.String()) - } - return nil, ctx.db.insertIndex2(s.tableName, s.indexName, exprList, s.unique, false, h) -} - -func (s *createIndexStmt) isUpdating() bool { return true } - -type createTableStmt struct { - ifNotExists bool - tableName string - cols []*col -} - -func (s *createTableStmt) explain(ctx *execCtx, w strutil.Formatter) { - w.Format("%s\n", s) -} - -func (s *createTableStmt) String() string { - a := make([]string, len(s.cols)) - for i, v := range s.cols { - var c, d string - if x := v.constraint; x != nil { - switch e := x.expr; { - case e != nil: - c = " " + e.String() - default: - c = " NOT NULL" - } - } - if x := v.dflt; x != nil { - d = " DEFAULT " + x.String() - } - a[i] = fmt.Sprintf("%s %s%s%s", v.name, typeStr(v.typ), c, d) - } - e := "" - if s.ifNotExists { - e = "IF NOT EXISTS " - } - return fmt.Sprintf("CREATE TABLE %s%s (%s);", e, s.tableName, strings.Join(a, ", ")) -} - -func (s *createTableStmt) exec(ctx *execCtx) (_ Recordset, err error) { - var cols []*col - for _, v := range s.cols { - cols = append(cols, v.clone()) - } - root := ctx.db.root - if _, ok := root.tables[s.tableName]; ok { - if s.ifNotExists { - return nil, nil - } - - return nil, fmt.Errorf("CREATE TABLE: table exists %s", s.tableName) - } - - if t, x := root.findIndexByName(s.tableName); x != nil { - return nil, fmt.Errorf("CREATE TABLE: table %s has index %s", t.name, s.tableName) - } - - m := map[string]bool{} - mustCreateColumn2 := true - for i, c := range cols { - nm := c.name - if m[nm] { - return nil, fmt.Errorf("CREATE TABLE: duplicate column %s", nm) - } - - m[nm] = true - c.index = i - if c.constraint != nil || c.dflt != nil { - if mustCreateColumn2 { - for _, stmt := range createColumn2.l { - _, err := stmt.exec(&execCtx{db: ctx.db}) - if err != nil { - return nil, err - } - } - } - - mustCreateColumn2 = false - notNull := c.constraint != nil && c.constraint.expr == nil - var co, d string - if c.constraint != nil && c.constraint.expr != nil { - co = c.constraint.expr.String() - } - if e := c.dflt; e != nil { - d = e.String() - } - if _, err := insertColumn2.l[0].exec(&execCtx{db: ctx.db, arg: []interface{}{s.tableName, c.name, notNull, co, d}}); err != nil { - return nil, err - } - } - } - t, err := root.createTable(s.tableName, cols) - if err != nil { - return nil, err - } - - return nil, t.constraintsAndDefaults(ctx) -} - -func (s *createTableStmt) isUpdating() bool { return true } diff --git a/Godeps/_workspace/src/github.com/cznic/ql/storage.go b/Godeps/_workspace/src/github.com/cznic/ql/storage.go deleted file mode 100644 index fa7a4bf0c6..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/storage.go +++ /dev/null @@ -1,991 +0,0 @@ -// Copyright (c) 2014 ql 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 ql - -import ( - "fmt" - "strings" -) - -type storage interface { - Acid() bool - BeginTransaction() error - Close() error - Commit() error - Create(data ...interface{}) (h int64, err error) - CreateIndex(unique bool) (handle int64, x btreeIndex, err error) - CreateTemp(asc bool) (bt temp, err error) - Delete(h int64, blobCols ...*col) error //LATER split the nil blobCols case - ID() (id int64, err error) - Name() string - OpenIndex(unique bool, handle int64) (btreeIndex, error) // Never called on the memory backend. - Read(dst []interface{}, h int64, cols ...*col) (data []interface{}, err error) - ResetID() (err error) - Rollback() error - Update(h int64, data ...interface{}) error - UpdateRow(h int64, blobCols []*col, data ...interface{}) error - Verify() (allocs int64, err error) -} - -type btreeIterator interface { - Next() (k, v []interface{}, err error) -} - -type temp interface { - BeginTransaction() error - Create(data ...interface{}) (h int64, err error) - Drop() (err error) - Get(k []interface{}) (v []interface{}, err error) - Read(dst []interface{}, h int64, cols ...*col) (data []interface{}, err error) - SeekFirst() (e btreeIterator, err error) - Set(k, v []interface{}) (err error) -} - -type indexIterator interface { - Next() (k []interface{}, h int64, err error) - Prev() (k []interface{}, h int64, err error) -} - -type btreeIndex interface { - Clear() error // supports truncate table statement - Create(indexedValues []interface{}, h int64) error // supports insert into statement - Delete(indexedValues []interface{}, h int64) error // supports delete from statement - Drop() error // supports drop table, drop index statements - Seek(indexedValues []interface{}) (iter indexIterator, hit bool, err error) // supports where clause - SeekFirst() (iter indexIterator, err error) // supports aggregate min / ascending order by - SeekLast() (iter indexIterator, err error) // supports aggregate max / descending order by -} - -type indexedCol struct { // Column name or id() index. - name string - unique bool - x btreeIndex - xroot int64 -} - -type index2 struct { // Expression list index. - unique bool - x btreeIndex - xroot int64 - sources []string - exprList []expression -} - -func (x *index2) eval(ctx *execCtx, cols []*col, id int64, r []interface{}) ([]interface{}, error) { - f, isFile := ctx.db.store.(*file) - vlist := make([]interface{}, len(x.exprList)) - m := map[interface{}]interface{}{"$id": id} - for _, col := range cols { - ci := col.index - v := interface{}(nil) - if ci < len(r) { - v = r[ci] - } - if b, ok := v.([]byte); ok && isFile { - var err error - if v, err = expand1(chunk{f: f, b: b}, nil); err != nil { - return nil, err - } - } - m[col.name] = v - } - for i, e := range x.exprList { - v, err := e.eval(ctx, m) - if err != nil { - return nil, err - } - - if ok, typ := isBlobType(v); ok { - return nil, fmt.Errorf("value of a complex index cannot be of blob-like type: %v", typ) - } - - vlist[i] = v - } - return vlist, nil -} - -type indexKey struct { - value []interface{} - h int64 -} - -// storage fields -// 0: next int64 -// 1: scols string -// 2: hhead int64 -// 3: name string -// 4: indices string - optional -// 5: hxroots int64 - optional -type table struct { - cols []*col // logical - cols0 []*col // physical - h int64 // - head int64 // head of the single linked record list - hhead int64 // handle of the head of the single linked record list - hxroots int64 - indices []*indexedCol - indices2 map[string]*index2 - name string - next int64 // single linked table list - store storage - tnext *table - tprev *table - xroots []interface{} - constraints []*constraint - defaults []expression -} - -func (t *table) hasIndices() bool { return len(t.indices) != 0 || len(t.indices2) != 0 } -func (t *table) hasIndices2() bool { return len(t.indices2) != 0 } - -func (t *table) constraintsAndDefaults(ctx *execCtx) error { - if isSystemName[t.name] { - return nil - } - - _, ok := ctx.db.root.tables["__Column2"] - if !ok { - return nil - } - - cols := t.cols - constraints := make([]*constraint, len(cols)) - defaults := make([]expression, len(cols)) - arg := []interface{}{t.name} - rs, err := selectColumn2.l[0].exec(&execCtx{db: ctx.db, arg: arg}) - if err != nil { - return err - } - - var rows [][]interface{} - ok = false - if err := rs.(recordset).do( - &execCtx{db: ctx.db, arg: arg}, - func(id interface{}, data []interface{}) (more bool, err error) { - rows = append(rows, data) - return true, nil - }, - ); err != nil { - return err - } - - for _, row := range rows { - nm := row[0].(string) - nonNull := row[1].(bool) - cexpr := row[2].(string) - dexpr := row[3].(string) - for i, c := range cols { - if c.name == nm { - var co *constraint - if nonNull || cexpr != "" { - co = &constraint{} - constraints[i] = co - if cexpr != "" { - if co.expr, err = ctx.db.str2expr(cexpr); err != nil { - return fmt.Errorf("constraint %q: %v", cexpr, err) - } - } - - t.constraints = constraints - } - if dexpr != "" { - if defaults[i], err = ctx.db.str2expr(dexpr); err != nil { - return fmt.Errorf("constraint %q: %v", dexpr, err) - } - - t.defaults = defaults - } - } - } - } - return nil -} - -func (t *table) checkConstraintsAndDefaults(ctx *execCtx, row []interface{}, m map[interface{}]interface{}) error { - cols := t.cols - - if len(t.defaults) != 0 { - // 1. - for _, c := range cols { - m[c.name] = row[c.index] - } - - // 2. - for i, c := range cols { - val := row[c.index] - expr := t.defaults[i] - if val != nil || expr == nil { - continue - } - - dval, err := expr.eval(ctx, m) - if err != nil { - return err - } - - row[c.index] = dval - if err = typeCheck(row, []*col{c}); err != nil { - return err - } - } - } - - if len(t.constraints) != 0 { - // 3. - for _, c := range cols { - m[c.name] = row[c.index] - } - - // 4. - for i, c := range cols { - constraint := t.constraints[i] - if constraint == nil { - continue - } - - val := row[c.index] - expr := constraint.expr - if expr == nil { // Constraint: NOT NULL - if val == nil { - return fmt.Errorf("column %s: constraint violation: NOT NULL", c.name) - } - - continue - } - - // Constraint is an expression - cval, err := expr.eval(ctx, m) - if err != nil { - return err - } - - if cval == nil { - return fmt.Errorf("column %s: constraint violation: %s", c.name, expr) - } - - bval, ok := cval.(bool) - if !ok { - return fmt.Errorf("column %s: non bool constraint expression: %s", c.name, expr) - } - - if !bval { - return fmt.Errorf("column %s: constraint violation: %s", c.name, expr) - } - } - } - - return nil -} - -func (t *table) clone() *table { - r := &table{} - *r = *t - r.constraints = append([]*constraint(nil), t.constraints...) - r.defaults = append([]expression(nil), t.defaults...) - r.indices2 = nil - if n := len(t.indices2); n != 0 { - r.indices2 = make(map[string]*index2, n) - for k, v := range t.indices2 { - r.indices2[k] = v - } - } - r.cols = make([]*col, len(t.cols)) - for i, v := range t.cols { - c := &col{} - *c = *v - r.cols[i] = c - } - r.cols0 = make([]*col, len(t.cols0)) - for i, v := range t.cols0 { - c := &col{} - *c = *v - r.cols0[i] = c - } - r.indices = make([]*indexedCol, len(t.indices)) - for i, v := range t.indices { - if v != nil { - c := &indexedCol{} - *c = *v - r.indices[i] = c - } - } - r.xroots = make([]interface{}, len(t.xroots)) - copy(r.xroots, t.xroots) - r.tnext, r.tprev = nil, nil - return r -} - -func (t *table) findIndexByColName(name string) (*col, *indexedCol) { - for i, v := range t.indices { - if v == nil { - continue - } - - if i == 0 { - if name == "id()" { - return idCol, v - } - - continue - } - - if c := t.cols[i-1]; c.name == name { - return c, v - } - } - - return nil, nil -} - -func (t *table) findIndexByName(name string) interface{} { - for _, v := range t.indices { - if v != nil && v.name == name { - return v - } - } - for k, v := range t.indices2 { - if k == name { - return v - } - } - return nil -} - -func (t *table) load() (err error) { - data, err := t.store.Read(nil, t.h) - if err != nil { - return - } - - var hasIndices bool - switch n := len(data); n { - case 4: - case 6: - hasIndices = true - default: - return fmt.Errorf("corrupted DB: table data len %d", n) - } - - var ok bool - if t.next, ok = data[0].(int64); !ok { - return fmt.Errorf("corrupted DB: table data[0] of type %T", data[0]) - } - - scols, ok := data[1].(string) - if !ok { - return fmt.Errorf("corrupted DB: table data[1] of type %T", data[1]) - } - - if t.hhead, ok = data[2].(int64); !ok { - return fmt.Errorf("corrupted DB: table data[2] of type %T", data[2]) - } - - if t.name, ok = data[3].(string); !ok { - return fmt.Errorf("corrupted DB: table data[3] of type %T", data[3]) - } - - var head []interface{} - if head, err = t.store.Read(nil, t.hhead); err != nil { - return err - } - - if len(head) != 1 { - return fmt.Errorf("corrupted DB: table head data len %d", len(head)) - } - - if t.head, ok = head[0].(int64); !ok { - return fmt.Errorf("corrupted DB: table head data[0] of type %T", head[0]) - } - - a := strings.Split(scols, "|") - t.cols0 = make([]*col, len(a)) - for i, v := range a { - if len(v) < 1 { - return fmt.Errorf("corrupted DB: field info %q", v) - } - - col := &col{name: v[1:], typ: int(v[0]), index: i} - t.cols0[i] = col - if col.name != "" { - t.cols = append(t.cols, col) - } - } - - if !hasIndices { - return - } - - if t.hxroots, ok = data[5].(int64); !ok { - return fmt.Errorf("corrupted DB: table data[5] of type %T", data[5]) - } - - xroots, err := t.store.Read(nil, t.hxroots) - if err != nil { - return err - } - - if g, e := len(xroots), len(t.cols0)+1; g != e { - return fmt.Errorf("corrupted DB: got %d index roots, expected %d", g, e) - } - - indices, ok := data[4].(string) - if !ok { - return fmt.Errorf("corrupted DB: table data[4] of type %T", data[4]) - } - - a = strings.Split(indices, "|") - if g, e := len(a), len(t.cols0)+1; g != e { - return fmt.Errorf("corrupted DB: got %d index definitions, expected %d", g, e) - } - - t.indices = make([]*indexedCol, len(a)) - for i, v := range a { - if v == "" { - continue - } - - if len(v) < 2 { - return fmt.Errorf("corrupted DB: invalid index definition %q", v) - } - - nm := v[1:] - h, ok := xroots[i].(int64) - if !ok { - return fmt.Errorf("corrupted DB: table index root of type %T", xroots[i]) - } - - if h == 0 { - return fmt.Errorf("corrupted DB: missing root for index %s", nm) - } - - unique := v[0] == 'u' - x, err := t.store.OpenIndex(unique, h) - if err != nil { - return err - } - - t.indices[i] = &indexedCol{nm, unique, x, h} - } - t.xroots = xroots - - return -} - -func newTable(store storage, name string, next int64, cols []*col, tprev, tnext *table) (t *table, err error) { - hhead, err := store.Create(int64(0)) - if err != nil { - return - } - - scols := cols2meta(cols) - h, err := store.Create(next, scols, hhead, name) - if err != nil { - return - } - - t = &table{ - cols0: cols, - h: h, - hhead: hhead, - name: name, - next: next, - store: store, - tnext: tnext, - tprev: tprev, - } - return t.updateCols(), nil -} - -func (t *table) blobCols() (r []*col) { - for _, c := range t.cols0 { - switch c.typ { - case qBlob, qBigInt, qBigRat, qTime, qDuration: - r = append(r, c) - } - } - return -} - -func (t *table) truncate() (err error) { - h := t.head - var rec []interface{} - blobCols := t.blobCols() - for h != 0 { - rec, err := t.store.Read(rec, h) - if err != nil { - return err - } - nh := rec[0].(int64) - - if err = t.store.Delete(h, blobCols...); err != nil { //LATER remove double read for len(blobCols) != 0 - return err - } - - h = nh - } - if err = t.store.Update(t.hhead, 0); err != nil { - return - } - - for _, v := range t.indices { - if v == nil { - continue - } - - if err := v.x.Clear(); err != nil { - return err - } - } - for _, ix := range t.indices2 { - if err := ix.x.Clear(); err != nil { - return err - } - } - t.head = 0 - return t.updated() -} - -func (t *table) addIndex0(unique bool, indexName string, colIndex int) (int64, btreeIndex, error) { - switch len(t.indices) { - case 0: - indices := make([]*indexedCol, len(t.cols0)+1) - h, x, err := t.store.CreateIndex(unique) - if err != nil { - return -1, nil, err - } - - indices[colIndex+1] = &indexedCol{indexName, unique, x, h} - xroots := make([]interface{}, len(indices)) - xroots[colIndex+1] = h - hx, err := t.store.Create(xroots...) - if err != nil { - return -1, nil, err - } - - t.hxroots, t.xroots, t.indices = hx, xroots, indices - return h, x, t.updated() - default: - ex := t.indices[colIndex+1] - if ex != nil && ex.name != "" { - colName := "id()" - if colIndex >= 0 { - colName = t.cols0[colIndex].name - } - return -1, nil, fmt.Errorf("column %s already has an index: %s", colName, ex.name) - } - - h, x, err := t.store.CreateIndex(unique) - if err != nil { - return -1, nil, err - } - - t.xroots[colIndex+1] = h - if err := t.store.Update(t.hxroots, t.xroots...); err != nil { - return -1, nil, err - } - - t.indices[colIndex+1] = &indexedCol{indexName, unique, x, h} - return h, x, t.updated() - } -} - -func (t *table) addIndex(unique bool, indexName string, colIndex int) (int64, error) { - hx, x, err := t.addIndex0(unique, indexName, colIndex) - if err != nil { - return -1, err - } - - // Must fill the new index. - ncols := len(t.cols0) - h, store := t.head, t.store - for h != 0 { - rec, err := store.Read(nil, h, t.cols...) - if err != nil { - return -1, err - } - - if n := ncols + 2 - len(rec); n > 0 { - rec = append(rec, make([]interface{}, n)...) - } - - if err = x.Create([]interface{}{rec[colIndex+2]}, h); err != nil { - return -1, err - } - - h = rec[0].(int64) - } - return hx, nil -} - -func (t *table) addIndex2(execCtx *execCtx, unique bool, indexName string, exprList []expression) (int64, error) { - if _, ok := t.indices2[indexName]; ok { - panic("internal error 009") - } - - hx, x, err := t.store.CreateIndex(unique) - if err != nil { - return -1, err - } - var a []string - for _, v := range exprList { - a = append(a, v.String()) - } - x2 := &index2{unique, x, hx, a, exprList} - if t.indices2 == nil { - t.indices2 = map[string]*index2{} - } - t.indices2[indexName] = x2 - - // Must fill the new index. - m := map[interface{}]interface{}{} - h, store := t.head, t.store - for h != 0 { - rec, err := store.Read(nil, h, t.cols...) - if err != nil { - return -1, err - } - - for _, col := range t.cols { - ci := col.index - v := interface{}(nil) - if ci < len(rec) { - v = rec[ci+2] - } - m[col.name] = v - } - - id := rec[1].(int64) - vlist, err := x2.eval(execCtx, t.cols, id, rec[2:]) - if err != nil { - return -1, err - } - - if err := x2.x.Create(vlist, h); err != nil { - return -1, err - } - - h = rec[0].(int64) - } - return hx, nil -} - -func (t *table) dropIndex(xIndex int) error { - t.xroots[xIndex] = 0 - if err := t.indices[xIndex].x.Drop(); err != nil { - return err - } - - t.indices[xIndex] = nil - return t.updated() -} - -func (t *table) updated() (err error) { - switch { - case len(t.indices) != 0: - a := []string{} - for _, v := range t.indices { - if v == nil { - a = append(a, "") - continue - } - - s := "n" - if v.unique { - s = "u" - } - a = append(a, s+v.name) - } - return t.store.Update(t.h, t.next, cols2meta(t.updateCols().cols0), t.hhead, t.name, strings.Join(a, "|"), t.hxroots) - default: - return t.store.Update(t.h, t.next, cols2meta(t.updateCols().cols0), t.hhead, t.name) - } -} - -// storage fields -// 0: next record handle int64 -// 1: record id int64 -// 2...: data row -func (t *table) addRecord(execCtx *execCtx, r []interface{}) (id int64, err error) { - if id, err = t.store.ID(); err != nil { - return - } - - r = append([]interface{}{t.head, id}, r...) - h, err := t.store.Create(r...) - if err != nil { - return - } - - for i, v := range t.indices { - if v == nil { - continue - } - - if err = v.x.Create([]interface{}{r[i+1]}, h); err != nil { - return - } - } - - for _, ix := range t.indices2 { - vlist, err := ix.eval(execCtx, t.cols, id, r[2:]) - if err != nil { - return -1, err - } - - if err := ix.x.Create(vlist, h); err != nil { - return -1, err - } - } - - if err = t.store.Update(t.hhead, h); err != nil { - return - } - - t.head = h - return -} - -func (t *table) flds() (r []*fld) { - r = make([]*fld, len(t.cols)) - for i, v := range t.cols { - r[i] = &fld{expr: &ident{v.name}, name: v.name} - } - return -} - -func (t *table) fieldNames() []string { - r := make([]string, len(t.cols)) - for i, v := range t.cols { - r[i] = v.name - } - return r -} - -func (t *table) updateCols() *table { - t.cols = t.cols[:0] - for i, c := range t.cols0 { - if c.name != "" { - c.index = i - t.cols = append(t.cols, c) - } - } - return t -} - -func (t *table) row0(ctx *execCtx, h int64) ([]interface{}, error) { - rec, err := ctx.db.store.Read(nil, h, t.cols...) - if err != nil { - return nil, err - } - - if d := len(t.cols) - (len(rec) - 2); d > 0 { - rec = append(rec, make([]interface{}, d)...) - } - - return rec, nil -} - -func (t *table) row(ctx *execCtx, h int64) (int64, []interface{}, error) { - rec, err := t.row0(ctx, h) - if err != nil { - return -1, nil, err - } - - return rec[1].(int64), rec[2:], nil -} - -// storage fields -// 0: handle of first table in DB int64 -type root struct { - head int64 // Single linked table list - lastInsertID int64 - parent *root - rowsAffected int64 //LATER implement - store storage - tables map[string]*table - thead *table -} - -func newRoot(store storage) (r *root, err error) { - data, err := store.Read(nil, 1) - if err != nil { - return - } - - switch len(data) { - case 0: // new empty DB, create empty table list - if err = store.BeginTransaction(); err != nil { - return - } - - if err = store.Update(1, int64(0)); err != nil { - store.Rollback() - return - } - - if err = store.Commit(); err != nil { - return - } - - return &root{ - store: store, - tables: map[string]*table{}, - }, nil - case 1: // existing DB, load tables - if len(data) != 1 { - return nil, fmt.Errorf("corrupted DB: root is an %d-scalar", len(data)) - } - - p, ok := data[0].(int64) - if !ok { - return nil, fmt.Errorf("corrupted DB: root head has type %T", data[0]) - } - - r := &root{ - head: p, - store: store, - tables: map[string]*table{}, - } - - var tprev *table - for p != 0 { - t := &table{ - h: p, - store: store, - tprev: tprev, - } - - if r.thead == nil { - r.thead = t - } - if tprev != nil { - tprev.tnext = t - } - tprev = t - - if err = t.load(); err != nil { - return nil, err - } - - if r.tables[t.name] != nil { // duplicate - return nil, fmt.Errorf("corrupted DB: duplicate table metadata for table %s", t.name) - } - - r.tables[t.name] = t - p = t.next - } - return r, nil - default: - return nil, errIncompatibleDBFormat - } -} - -func (r *root) findIndexByName(name string) (*table, interface{}) { - for _, t := range r.tables { - if i := t.findIndexByName(name); i != nil { - return t, i - } - } - - return nil, nil -} - -func (r *root) updated() (err error) { - return r.store.Update(1, r.head) -} - -func (r *root) createTable(name string, cols []*col) (t *table, err error) { - if _, ok := r.tables[name]; ok { - panic("internal error 065") - } - - if t, err = newTable(r.store, name, r.head, cols, nil, r.thead); err != nil { - return nil, err - } - - if err = r.store.Update(1, t.h); err != nil { - return nil, err - } - - if p := r.thead; p != nil { - p.tprev = t - } - r.tables[name], r.head, r.thead = t, t.h, t - return -} - -func (r *root) dropTable(t *table) (err error) { - defer func() { - if err != nil { - return - } - - delete(r.tables, t.name) - }() - - if err = t.truncate(); err != nil { - return - } - - if err = t.store.Delete(t.hhead); err != nil { - return - } - - if err = t.store.Delete(t.h); err != nil { - return - } - - for _, v := range t.indices { - if v != nil && v.x != nil { - if err = v.x.Drop(); err != nil { - return - } - } - } - for _, v := range t.indices2 { - if err = v.x.Drop(); err != nil { - return - } - } - - if h := t.hxroots; h != 0 { - if err = t.store.Delete(h); err != nil { - return - } - } - - switch { - case t.tprev == nil && t.tnext == nil: - r.head = 0 - r.thead = nil - err = r.updated() - return errSet(&err, r.store.ResetID()) - case t.tprev == nil && t.tnext != nil: - next := t.tnext - next.tprev = nil - r.head = next.h - r.thead = next - if err = r.updated(); err != nil { - return - } - - return next.updated() - case t.tprev != nil && t.tnext == nil: // last in list - prev := t.tprev - prev.next = 0 - prev.tnext = nil - return prev.updated() - default: //case t.tprev != nil && t.tnext != nil: - prev, next := t.tprev, t.tnext - prev.next = next.h - prev.tnext = next - next.tprev = prev - if err = prev.updated(); err != nil { - return - } - - return next.updated() - } -} diff --git a/Godeps/_workspace/src/github.com/cznic/ql/testdata.log b/Godeps/_workspace/src/github.com/cznic/ql/testdata.log deleted file mode 100644 index 0e13dcfbba..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/testdata.log +++ /dev/null @@ -1,8382 +0,0 @@ ----- 0 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1" "c2" "c3"] - ----- 3 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1" "c2" "c3" "c4"] - ----- 8 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1" "c3"] - ----- 15 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1" "c2"] - ----- 19 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1" "c2" "c3" "c4"] - ----- 20 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1" "c2" "c4"] - ----- 22 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1"] - ----- 24 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1" "c2"] - ----- 28 -SELECT 3 * c1 AS v FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1" "c2"] -┌Evaluate 3 * c1 as "v", -└Output field names ["v"] - ----- 29 -SELECT c2 FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1" "c2"] -┌Evaluate c2 as "c2", -└Output field names ["c2"] - ----- 30 -SELECT c1 AS X, c2 FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1" "c2"] -┌Evaluate c1 as "X", c2 as "c2", -└Output field names ["X" "c2"] - ----- 31 -SELECT c2, c1 AS Y FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1" "c2"] -┌Evaluate c2 as "c2", c1 as "Y", -└Output field names ["c2" "Y"] - ----- 33 -SELECT * FROM t WHERE c1 == 1; -┌Iterate all rows of table "t" -└Output field names ["c1" "c2"] -┌Filter on c1 == 1 -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1" "c2"] - ----- 35 -SELECT * FROM t ORDER BY c1; -┌Iterate all rows of table "t" -└Output field names ["c1" "c2"] -┌Order by c1, -└Output field names ["c1" "c2"] - ----- 36 -SELECT * FROM t ORDER BY c1; -┌Iterate all rows of table "t" -└Output field names ["c1" "c2"] -┌Order by c1, -└Output field names ["c1" "c2"] - ----- 37 -SELECT * FROM t ORDER BY c1 DESC; -┌Iterate all rows of table "t" -└Output field names ["c1" "c2"] -┌Order descending by c1, -└Output field names ["c1" "c2"] - ----- 38 -SELECT * FROM t WHERE c1 % 2 == 0 ORDER BY c2 DESC; -┌Iterate all rows of table "t" -└Output field names ["c1" "c2"] -┌Filter on c1 % 2 == 0 -└Output field names ["c1" "c2"] -┌Order descending by c2, -└Output field names ["c1" "c2"] - ----- 39 -SELECT * FROM t ORDER BY c1, c2; -┌Iterate all rows of table "t" -└Output field names ["c1" "c2"] -┌Order by c1, c2, -└Output field names ["c1" "c2"] - ----- 40 -SELECT * FROM t ORDER BY c2, c1; -┌Iterate all rows of table "t" -└Output field names ["c1" "c2"] -┌Order by c2, c1, -└Output field names ["c1" "c2"] - ----- 44 -SELECT employee.LastName FROM employee, department; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Evaluate employee.LastName as "employee.LastName", -└Output field names ["employee.LastName"] - ----- 45 -SELECT * FROM employee, department ORDER BY employee.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Order by employee.LastName, -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] - ----- 46 -SELECT * FROM employee, department WHERE employee.DepartmentID == department.DepartmentID; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Filter on employee.DepartmentID == department.DepartmentID -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] - ----- 47 -SELECT department.DepartmentName, department.DepartmentID, employee.LastName, employee.DepartmentID FROM employee, department WHERE employee.DepartmentID == department.DepartmentID ORDER BY department.DepartmentName, employee.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Filter on employee.DepartmentID == department.DepartmentID -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Evaluate department.DepartmentName as "department.DepartmentName", department.DepartmentID as "department.DepartmentID", employee.LastName as "employee.LastName", employee.DepartmentID as "employee.DepartmentID", -└Output field names ["department.DepartmentName" "department.DepartmentID" "employee.LastName" "employee.DepartmentID"] -┌Order by department.DepartmentName, employee.LastName, -└Output field names ["department.DepartmentName" "department.DepartmentID" "employee.LastName" "employee.DepartmentID"] - ----- 48 -SELECT department.DepartmentName, department.DepartmentID, employee.LastName, employee.DepartmentID FROM employee, department WHERE department.DepartmentName IN ("Sales","Engineering","HR","Clerical") ORDER BY employee.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Filter on department.DepartmentName IN ("Sales","Engineering","HR","Clerical") -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Evaluate department.DepartmentName as "department.DepartmentName", department.DepartmentID as "department.DepartmentID", employee.LastName as "employee.LastName", employee.DepartmentID as "employee.DepartmentID", -└Output field names ["department.DepartmentName" "department.DepartmentID" "employee.LastName" "employee.DepartmentID"] -┌Order by employee.LastName, -└Output field names ["department.DepartmentName" "department.DepartmentID" "employee.LastName" "employee.DepartmentID"] - ----- 49 -SELECT department.DepartmentName, department.DepartmentID, employee.LastName, employee.DepartmentID FROM employee, department WHERE (department.DepartmentID + 1000) IN (1031,1035,1036) ORDER BY employee.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Filter on (department.DepartmentID + 1000) IN (1031,1035,1036) -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Evaluate department.DepartmentName as "department.DepartmentName", department.DepartmentID as "department.DepartmentID", employee.LastName as "employee.LastName", employee.DepartmentID as "employee.DepartmentID", -└Output field names ["department.DepartmentName" "department.DepartmentID" "employee.LastName" "employee.DepartmentID"] -┌Order by employee.LastName, -└Output field names ["department.DepartmentName" "department.DepartmentID" "employee.LastName" "employee.DepartmentID"] - ----- 50 -SELECT department.DepartmentName, department.DepartmentID, employee.LastName, employee.DepartmentID FROM employee, department WHERE department.DepartmentName NOT IN ("Engineering","HR","Clerical"); -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Filter on department.DepartmentName NOT IN ("Engineering","HR","Clerical") -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Evaluate department.DepartmentName as "department.DepartmentName", department.DepartmentID as "department.DepartmentID", employee.LastName as "employee.LastName", employee.DepartmentID as "employee.DepartmentID", -└Output field names ["department.DepartmentName" "department.DepartmentID" "employee.LastName" "employee.DepartmentID"] - ----- 51 -SELECT department.DepartmentName, department.DepartmentID, employee.LastName, employee.DepartmentID FROM employee, department WHERE department.DepartmentID >= 34 && department.DepartmentID <= 36 ORDER BY employee.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Filter on department.DepartmentID >= 34 && department.DepartmentID <= 36 -│Possibly useful indices -│CREATE INDEX xdepartment_DepartmentID ON department(DepartmentID); -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Evaluate department.DepartmentName as "department.DepartmentName", department.DepartmentID as "department.DepartmentID", employee.LastName as "employee.LastName", employee.DepartmentID as "employee.DepartmentID", -└Output field names ["department.DepartmentName" "department.DepartmentID" "employee.LastName" "employee.DepartmentID"] -┌Order by employee.LastName, -└Output field names ["department.DepartmentName" "department.DepartmentID" "employee.LastName" "employee.DepartmentID"] - ----- 52 -SELECT department.DepartmentName, department.DepartmentID, employee.LastName, employee.DepartmentID FROM employee, department WHERE department.DepartmentID >= 34 && department.DepartmentID <= 36 ORDER BY employee.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Filter on department.DepartmentID >= 34 && department.DepartmentID <= 36 -│Possibly useful indices -│CREATE INDEX xdepartment_DepartmentID ON department(DepartmentID); -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Evaluate department.DepartmentName as "department.DepartmentName", department.DepartmentID as "department.DepartmentID", employee.LastName as "employee.LastName", employee.DepartmentID as "employee.DepartmentID", -└Output field names ["department.DepartmentName" "department.DepartmentID" "employee.LastName" "employee.DepartmentID"] -┌Order by employee.LastName, -└Output field names ["department.DepartmentName" "department.DepartmentID" "employee.LastName" "employee.DepartmentID"] - ----- 53 -SELECT department.DepartmentName, department.DepartmentID, employee.LastName, employee.DepartmentID FROM employee, department WHERE department.DepartmentID < 33 || department.DepartmentID > 34 ORDER BY employee.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Filter on department.DepartmentID < 33 || department.DepartmentID > 34 -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Evaluate department.DepartmentName as "department.DepartmentName", department.DepartmentID as "department.DepartmentID", employee.LastName as "employee.LastName", employee.DepartmentID as "employee.DepartmentID", -└Output field names ["department.DepartmentName" "department.DepartmentID" "employee.LastName" "employee.DepartmentID"] -┌Order by employee.LastName, -└Output field names ["department.DepartmentName" "department.DepartmentID" "employee.LastName" "employee.DepartmentID"] - ----- 56 -SELECT LastName AS a, LastName AS b FROM employee ORDER BY a, b; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Evaluate LastName as "a", LastName as "b", -└Output field names ["a" "b"] -┌Order by a, b, -└Output field names ["a" "b"] - ----- 57 -SELECT employee.LastName AS name, employee.DepartmentID AS id, department.DepartmentName AS department, department.DepartmentID AS id2 FROM employee, department WHERE employee.DepartmentID == department.DepartmentID ORDER BY name, id, department, id2; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Filter on employee.DepartmentID == department.DepartmentID -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Evaluate employee.LastName as "name", employee.DepartmentID as "id", department.DepartmentName as "department", department.DepartmentID as "id2", -└Output field names ["name" "id" "department" "id2"] -┌Order by name, id, department, id2, -└Output field names ["name" "id" "department" "id2"] - ----- 59 -SELECT * FROM employee ORDER BY LastName; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Order by LastName, -└Output field names ["LastName" "DepartmentID"] - ----- 60 -SELECT * FROM employee AS e ORDER BY LastName; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Order by LastName, -└Output field names ["LastName" "DepartmentID"] - ----- 65 -SELECT * FROM (SELECT * FROM employee;) ORDER BY LastName; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Order by LastName, -└Output field names ["LastName" "DepartmentID"] - ----- 66 -SELECT * FROM (SELECT LastName AS Name FROM employee;) ORDER BY Name; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Evaluate LastName as "Name", -└Output field names ["Name"] -┌Order by Name, -└Output field names ["Name"] - ----- 68 -SELECT name AS Name FROM (SELECT LastName AS name FROM employee AS e;) ORDER BY Name; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Evaluate LastName as "name", -└Output field names ["name"] -┌Evaluate name as "Name", -└Output field names ["Name"] -┌Order by Name, -└Output field names ["Name"] - ----- 69 -SELECT name AS Name FROM (SELECT LastName AS name FROM employee;) ORDER BY Name; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Evaluate LastName as "name", -└Output field names ["name"] -┌Evaluate name as "Name", -└Output field names ["Name"] -┌Order by Name, -└Output field names ["Name"] - ----- 70 -SELECT employee.LastName, department.DepartmentName, department.DepartmentID FROM (SELECT * FROM employee, department WHERE employee.DepartmentID == department.DepartmentID;) ORDER BY department.DepartmentName, employee.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Filter on employee.DepartmentID == department.DepartmentID -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Evaluate employee.LastName as "employee.LastName", department.DepartmentName as "department.DepartmentName", department.DepartmentID as "department.DepartmentID", -└Output field names ["employee.LastName" "department.DepartmentName" "department.DepartmentID"] -┌Order by department.DepartmentName, employee.LastName, -└Output field names ["employee.LastName" "department.DepartmentName" "department.DepartmentID"] - ----- 71 -SELECT e.LastName, d.DepartmentName, d.DepartmentID FROM (SELECT * FROM employee AS e, department AS d WHERE e.DepartmentID == d.DepartmentID;) ORDER BY d.DepartmentName, e.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] -┌Filter on e.DepartmentID == d.DepartmentID -└Output field names ["e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] -┌Evaluate e.LastName as "e.LastName", d.DepartmentName as "d.DepartmentName", d.DepartmentID as "d.DepartmentID", -└Output field names ["e.LastName" "d.DepartmentName" "d.DepartmentID"] -┌Order by d.DepartmentName, e.LastName, -└Output field names ["e.LastName" "d.DepartmentName" "d.DepartmentID"] - ----- 72 -SELECT e.LastName AS name, d.DepartmentName AS department, d.DepartmentID AS id FROM (SELECT * FROM employee AS e, department AS d WHERE e.DepartmentID == d.DepartmentID;) ORDER BY department, name; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] -┌Filter on e.DepartmentID == d.DepartmentID -└Output field names ["e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] -┌Evaluate e.LastName as "name", d.DepartmentName as "department", d.DepartmentID as "id", -└Output field names ["name" "department" "id"] -┌Order by department, name, -└Output field names ["name" "department" "id"] - ----- 73 -SELECT name, department, id FROM (SELECT e.LastName AS name, e.DepartmentID AS id, d.DepartmentName AS department, d.DepartmentID AS fid FROM employee AS e, department AS d WHERE e.DepartmentID == d.DepartmentID;) ORDER BY department, name; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] -┌Filter on e.DepartmentID == d.DepartmentID -└Output field names ["e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] -┌Evaluate e.LastName as "name", e.DepartmentID as "id", d.DepartmentName as "department", d.DepartmentID as "fid", -└Output field names ["name" "id" "department" "fid"] -┌Evaluate name as "name", department as "department", id as "id", -└Output field names ["name" "department" "id"] -┌Order by department, name, -└Output field names ["name" "department" "id"] - ----- 74 -SELECT * FROM (SELECT * FROM employee;), (SELECT * FROM department;); -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["" "" "" ""] - ----- 75 -SELECT * FROM (SELECT * FROM employee;) AS e, (SELECT * FROM department;) ORDER BY e.LastName, e.DepartmentID; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["e.LastName" "e.DepartmentID" "" ""] -┌Order by e.LastName, e.DepartmentID, -└Output field names ["e.LastName" "e.DepartmentID" "" ""] - ----- 76 -SELECT * FROM (SELECT * FROM employee;), (SELECT * FROM department;) AS d ORDER BY d.DepartmentID DESC; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["" "" "d.DepartmentID" "d.DepartmentName"] -┌Order descending by d.DepartmentID, -└Output field names ["" "" "d.DepartmentID" "d.DepartmentName"] - ----- 77 -SELECT * FROM employee, (SELECT * FROM department;) ORDER BY employee.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["employee.LastName" "employee.DepartmentID" "" ""] -┌Order by employee.LastName, -└Output field names ["employee.LastName" "employee.DepartmentID" "" ""] - ----- 78 -SELECT * FROM (SELECT * FROM employee;) AS e, (SELECT * FROM department;) AS d WHERE e.DepartmentID == d.DepartmentID ORDER BY d.DepartmentName, e.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] -┌Filter on e.DepartmentID == d.DepartmentID -└Output field names ["e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] -┌Order by d.DepartmentName, e.LastName, -└Output field names ["e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] - ----- 79 -SELECT * FROM employee, (SELECT * FROM department;) AS d WHERE employee.DepartmentID == d.DepartmentID ORDER BY d.DepartmentName, employee.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["employee.LastName" "employee.DepartmentID" "d.DepartmentID" "d.DepartmentName"] -┌Filter on employee.DepartmentID == d.DepartmentID -└Output field names ["employee.LastName" "employee.DepartmentID" "d.DepartmentID" "d.DepartmentName"] -┌Order by d.DepartmentName, employee.LastName, -└Output field names ["employee.LastName" "employee.DepartmentID" "d.DepartmentID" "d.DepartmentName"] - ----- 80 -SELECT * FROM employee AS e, (SELECT * FROM department;) AS d WHERE e.DepartmentID == d.DepartmentID ORDER BY d.DepartmentName, e.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] -┌Filter on e.DepartmentID == d.DepartmentID -└Output field names ["e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] -┌Order by d.DepartmentName, e.LastName, -└Output field names ["e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] - ----- 81 -SELECT * FROM employee AS e, (SELECT * FROM department;) AS d WHERE e.DepartmentID == d.DepartmentID ORDER BY e.DepartmentID, e.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] -┌Filter on e.DepartmentID == d.DepartmentID -└Output field names ["e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] -┌Order by e.DepartmentID, e.LastName, -└Output field names ["e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] - ----- 82 -SELECT * FROM employee AS e, (SELECT * FROM department;) AS d WHERE e.DepartmentID == d.DepartmentID ORDER BY e.DepartmentID, e.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] -┌Filter on e.DepartmentID == d.DepartmentID -└Output field names ["e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] -┌Order by e.DepartmentID, e.LastName, -└Output field names ["e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] - ----- 84 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1"] - ----- 87 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1"] - ----- 88 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1"] - ----- 92 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1"] - ----- 94 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1"] - ----- 95 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1"] - ----- 96 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1"] - ----- 98 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1"] - ----- 102 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1"] - ----- 104 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1"] - ----- 106 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1"] - ----- 107 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1"] - ----- 109 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1"] - ----- 110 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1"] - ----- 111 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1"] - ----- 112 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1"] - ----- 113 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1"] - ----- 115 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1"] - ----- 116 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1"] - ----- 118 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1"] - ----- 119 -SELECT * FROM t WHERE c1 > 3; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 > 3 -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 120 -SELECT * FROM t WHERE c1; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 -└Output field names ["c1"] - ----- 122 -SELECT * FROM t WHERE c1 == 1; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == 1 -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 123 -SELECT * FROM t WHERE c1 == 8; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == 8 -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 124 -SELECT * FROM t WHERE c1 == 1; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == 1 -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 125 -SELECT * FROM t WHERE c1 == 8; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == 8 -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 126 -SELECT * FROM t WHERE c1 == 1; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == 1 -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 127 -SELECT * FROM t WHERE c1 == 8; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == 8 -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 128 -SELECT * FROM t WHERE c1 == 1; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == 1 -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 129 -SELECT * FROM t WHERE c1 == 1; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == 1 -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 130 -SELECT * FROM t WHERE c1 == 8; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == 8 -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 131 -SELECT * FROM t WHERE c1 == 1; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == 1 -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 132 -SELECT * FROM t WHERE c1 == 8; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == 8 -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 133 -SELECT * FROM t WHERE c1 == 1; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == 1 -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 134 -SELECT * FROM t WHERE c1 == 1; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == 1 -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 135 -SELECT * FROM t WHERE c1 == 8; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == 8 -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 136 -SELECT * FROM t WHERE c1 == 1; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == 1 -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 137 -SELECT * FROM t WHERE c1 == 1; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == 1 -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 138 -SELECT * FROM t WHERE c1 == 8; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == 8 -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 139 -SELECT * FROM t WHERE c1 == 8; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == 8 -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 140 -SELECT * FROM t WHERE c1 == 2; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == 2 -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 141 -SELECT * FROM t WHERE c1 == 2; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == 2 -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 142 -SELECT * FROM t WHERE c1 == 2; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == 2 -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 143 -SELECT * FROM t WHERE c1 == "foo"; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == "foo" -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 144 -SELECT * FROM t WHERE c1 == 2+5i; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == 2+5i -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 145 -SELECT * FROM t WHERE c1 == "2"; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == "2" -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 146 -SELECT * FROM t WHERE c1 == 2+5i; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == 2+5i -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 147 -SELECT * FROM t WHERE c1 == 2; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == 2 -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 148 -SELECT * FROM t WHERE c1 == "foo"; -┌Iterate all rows of table "t" -└Output field names ["c1"] -┌Filter on c1 == "foo" -│Possibly useful indices -│CREATE INDEX xt_c1 ON t(c1); -└Output field names ["c1"] - ----- 153 -SELECT 314, 42 AS AUQLUE, DepartmentID, DepartmentID + 1000, LastName AS Name FROM employee ORDER BY Name; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Evaluate 314 as "", 42 as "AUQLUE", DepartmentID as "DepartmentID", DepartmentID + 1000 as "", LastName as "Name", -└Output field names ["" "AUQLUE" "DepartmentID" "" "Name"] -┌Order by Name, -└Output field names ["" "AUQLUE" "DepartmentID" "" "Name"] - ----- 154 -SELECT * FROM employee AS e, (SELECT * FROM department;) ORDER BY e.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["e.LastName" "e.DepartmentID" "" ""] -┌Order by e.LastName, -└Output field names ["e.LastName" "e.DepartmentID" "" ""] - ----- 155 -SELECT * FROM employee AS e, (SELECT * FROM department;) AS d ORDER BY e.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] -┌Order by e.LastName, -└Output field names ["e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] - ----- 157 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c1"] - ----- 158 -SELECT * FROM p; -┌Iterate all rows of table "p" -└Output field names ["p"] - ----- 159 -SELECT p.p AS p, q.p AS q, p.p || q.p AS p_or_q, p.p && q.p AS p_and_q FROM p, p AS q; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "p" -│ └Output field names ["p"] -│ ┌Iterate all rows of table "p" -│ └Output field names ["p"] -└Output field names ["p.p" "q.p"] -┌Evaluate p.p as "p", q.p as "q", p.p || q.p as "p_or_q", p.p && q.p as "p_and_q", -└Output field names ["p" "q" "p_or_q" "p_and_q"] - ----- 160 -SELECT p, !p AS not_p FROM p; -┌Iterate all rows of table "p" -└Output field names ["p"] -┌Evaluate p as "p", !p as "not_p", -└Output field names ["p" "not_p"] - ----- 161 -SELECT * FROM department WHERE DepartmentID >= 33 ORDER BY DepartmentID; -┌Iterate all rows of table "department" -└Output field names ["DepartmentID" "DepartmentName"] -┌Filter on DepartmentID >= 33 -│Possibly useful indices -│CREATE INDEX xdepartment_DepartmentID ON department(DepartmentID); -└Output field names ["DepartmentID" "DepartmentName"] -┌Order by DepartmentID, -└Output field names ["DepartmentID" "DepartmentName"] - ----- 162 -SELECT * FROM department WHERE DepartmentID <= 34 ORDER BY DepartmentID; -┌Iterate all rows of table "department" -└Output field names ["DepartmentID" "DepartmentName"] -┌Filter on DepartmentID <= 34 -│Possibly useful indices -│CREATE INDEX xdepartment_DepartmentID ON department(DepartmentID); -└Output field names ["DepartmentID" "DepartmentName"] -┌Order by DepartmentID, -└Output field names ["DepartmentID" "DepartmentName"] - ----- 163 -SELECT * FROM department WHERE DepartmentID < 34 ORDER BY DepartmentID; -┌Iterate all rows of table "department" -└Output field names ["DepartmentID" "DepartmentName"] -┌Filter on DepartmentID < 34 -│Possibly useful indices -│CREATE INDEX xdepartment_DepartmentID ON department(DepartmentID); -└Output field names ["DepartmentID" "DepartmentName"] -┌Order by DepartmentID, -└Output field names ["DepartmentID" "DepartmentName"] - ----- 164 -SELECT +DepartmentID FROM employee; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Evaluate +DepartmentID as "", -└Output field names [""] - ----- 165 -SELECT * FROM employee ORDER BY LastName; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Order by LastName, -└Output field names ["LastName" "DepartmentID"] - ----- 166 -SELECT * FROM employee ORDER BY LastName DESC; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Order descending by LastName, -└Output field names ["LastName" "DepartmentID"] - ----- 167 -SELECT 1023 + DepartmentID AS y FROM employee ORDER BY y DESC; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Evaluate 1023 + DepartmentID as "y", -└Output field names ["y"] -┌Order descending by y, -└Output field names ["y"] - ----- 168 -SELECT +DepartmentID AS y FROM employee ORDER BY y DESC; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Evaluate +DepartmentID as "y", -└Output field names ["y"] -┌Order descending by y, -└Output field names ["y"] - ----- 169 -SELECT * FROM employee ORDER BY DepartmentID, LastName DESC; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Order descending by DepartmentID, LastName, -└Output field names ["LastName" "DepartmentID"] - ----- 170 -SELECT * FROM employee ORDER BY 0 + DepartmentID DESC; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Order descending by 0 + DepartmentID, -└Output field names ["LastName" "DepartmentID"] - ----- 171 -SELECT * FROM employee ORDER BY +DepartmentID DESC; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Order descending by +DepartmentID, -└Output field names ["LastName" "DepartmentID"] - ----- 172 -SELECT ^DepartmentID AS y FROM employee ORDER BY y DESC; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Evaluate ^DepartmentID as "y", -└Output field names ["y"] -┌Order descending by y, -└Output field names ["y"] - ----- 173 -SELECT ^uint8(DepartmentID) AS y FROM employee ORDER BY y DESC; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Evaluate ^uint8(DepartmentID) as "y", -└Output field names ["y"] -┌Order descending by y, -└Output field names ["y"] - ----- 174 -SELECT * FROM t ORDER BY r; -┌Iterate all rows of table "t" -└Output field names ["r"] -┌Order by r, -└Output field names ["r"] - ----- 175 -SELECT i ^ 1 AS y FROM t ORDER BY y; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Evaluate i ^ 1 as "y", -└Output field names ["y"] -┌Order by y, -└Output field names ["y"] - ----- 176 -SELECT i | 1 AS y FROM t ORDER BY y; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Evaluate i | 1 as "y", -└Output field names ["y"] -┌Order by y, -└Output field names ["y"] - ----- 177 -SELECT i & 1 FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Evaluate i & 1 as "", -└Output field names [""] - ----- 178 -SELECT i &^ 1 AS y FROM t ORDER BY y; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Evaluate i &^ 1 as "y", -└Output field names ["y"] -┌Order by y, -└Output field names ["y"] - ----- 179 -SELECT * FROM employee WHERE LastName == "Jones" || DepartmentID IS NULL ORDER BY LastName DESC; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Filter on LastName == "Jones" || DepartmentID IS NULL -└Output field names ["LastName" "DepartmentID"] -┌Order descending by LastName, -└Output field names ["LastName" "DepartmentID"] - ----- 180 -SELECT * FROM employee WHERE LastName != "Jones" && DepartmentID IS NOT NULL ORDER BY LastName; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Filter on LastName != "Jones" && DepartmentID IS NOT NULL -│Possibly useful indices -│CREATE INDEX xemployee_LastName ON employee(LastName); -│CREATE INDEX xemployee_DepartmentID ON employee(DepartmentID); -└Output field names ["LastName" "DepartmentID"] -┌Order by LastName, -└Output field names ["LastName" "DepartmentID"] - ----- 185 -SELECT DepartmentID[0] FROM employee; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Evaluate DepartmentID[0] as "", -└Output field names [""] - ----- 186 -SELECT "foo"[-DepartmentID] FROM employee; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Evaluate "foo"[-DepartmentID] as "", -└Output field names [""] - ----- 187 -SELECT LastName[100] FROM employee; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Evaluate LastName[100] as "", -└Output field names [""] - ----- 188 -SELECT LastName[0], LastName FROM employee ORDER BY LastName; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Evaluate LastName[0] as "", LastName as "LastName", -└Output field names ["" "LastName"] -┌Order by LastName, -└Output field names ["" "LastName"] - ----- 189 -SELECT LastName, string(LastName[0]), string(LastName[1]), string(LastName[2]), string(LastName[3]) FROM employee ORDER BY LastName; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Evaluate LastName as "LastName", string(LastName[0]) as "", string(LastName[1]) as "", string(LastName[2]) as "", string(LastName[3]) as "", -└Output field names ["LastName" "" "" "" ""] -┌Order by LastName, -└Output field names ["LastName" "" "" "" ""] - ----- 190 -SELECT LastName, LastName[:], LastName[:2], LastName[2:], LastName[1:3] FROM employee ORDER BY LastName; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Evaluate LastName as "LastName", LastName[:] as "", LastName[:2] as "", LastName[2:] as "", LastName[1:3] as "", -└Output field names ["LastName" "" "" "" ""] -┌Order by LastName, -└Output field names ["LastName" "" "" "" ""] - ----- 192 -SELECT DepartmentID, LastName, LastName[:4], LastName[:0 * DepartmentID], LastName[0 * DepartmentID:0], LastName[0 * DepartmentID:0 * DepartmentID] FROM employee ORDER BY LastName DESC; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Evaluate DepartmentID as "DepartmentID", LastName as "LastName", LastName[:4] as "", LastName[:0 * DepartmentID] as "", LastName[0 * DepartmentID:0] as "", LastName[0 * DepartmentID:0 * DepartmentID] as "", -└Output field names ["DepartmentID" "LastName" "" "" "" ""] -┌Order descending by LastName, -└Output field names ["DepartmentID" "LastName" "" "" "" ""] - ----- 193 -SELECT DepartmentID AS x, DepartmentID << 1 AS a, 1 << uint64(DepartmentID) AS b FROM employee WHERE DepartmentID IS NOT NULL ORDER BY x; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Filter on DepartmentID IS NOT NULL -│Possibly useful indices -│CREATE INDEX xemployee_DepartmentID ON employee(DepartmentID); -└Output field names ["LastName" "DepartmentID"] -┌Evaluate DepartmentID as "x", DepartmentID << 1 as "a", 1 << uint64(DepartmentID) as "b", -└Output field names ["x" "a" "b"] -┌Order by x, -└Output field names ["x" "a" "b"] - ----- 194 -SELECT DepartmentID AS x, DepartmentID >> 1 AS a, 9223372036854775808 >> uint64(DepartmentID) AS b FROM employee WHERE DepartmentID IS NOT NULL ORDER BY x; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Filter on DepartmentID IS NOT NULL -│Possibly useful indices -│CREATE INDEX xemployee_DepartmentID ON employee(DepartmentID); -└Output field names ["LastName" "DepartmentID"] -┌Evaluate DepartmentID as "x", DepartmentID >> 1 as "a", 9223372036854775808 >> uint64(DepartmentID) as "b", -└Output field names ["x" "a" "b"] -┌Order by x, -└Output field names ["x" "a" "b"] - ----- 195 -SELECT DISTINCT DepartmentID FROM employee WHERE DepartmentID IS NOT NULL; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Filter on DepartmentID IS NOT NULL -│Possibly useful indices -│CREATE INDEX xemployee_DepartmentID ON employee(DepartmentID); -└Output field names ["LastName" "DepartmentID"] -┌Evaluate DepartmentID as "DepartmentID", -└Output field names ["DepartmentID"] -┌Compute distinct rows -└Output field names [DepartmentID] - ----- 196 -SELECT DISTINCT e.DepartmentID, d.DepartmentID, e.LastName FROM employee AS e, department AS d WHERE e.DepartmentID == d.DepartmentID; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] -┌Filter on e.DepartmentID == d.DepartmentID -└Output field names ["e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] -┌Evaluate e.DepartmentID as "e.DepartmentID", d.DepartmentID as "d.DepartmentID", e.LastName as "e.LastName", -└Output field names ["e.DepartmentID" "d.DepartmentID" "e.LastName"] -┌Compute distinct rows -└Output field names [e.DepartmentID d.DepartmentID e.LastName] - ----- 197 -SELECT DISTINCT e.DepartmentID, d.DepartmentID, e.LastName FROM employee AS e, department AS d WHERE e.DepartmentID == d.DepartmentID ORDER BY e.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] -┌Filter on e.DepartmentID == d.DepartmentID -└Output field names ["e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] -┌Evaluate e.DepartmentID as "e.DepartmentID", d.DepartmentID as "d.DepartmentID", e.LastName as "e.LastName", -└Output field names ["e.DepartmentID" "d.DepartmentID" "e.LastName"] -┌Compute distinct rows -└Output field names [e.DepartmentID d.DepartmentID e.LastName] -┌Order by e.LastName, -└Output field names ["e.DepartmentID" "d.DepartmentID" "e.LastName"] - ----- 198 -SELECT * FROM employee, department ORDER BY employee.LastName, department.DepartmentID; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Order by employee.LastName, department.DepartmentID, -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] - ----- 199 -SELECT * FROM employee, department WHERE employee.DepartmentID == department.DepartmentID ORDER BY employee.LastName, department.DepartmentID; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Filter on employee.DepartmentID == department.DepartmentID -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Order by employee.LastName, department.DepartmentID, -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] - ----- 200 -SELECT * FROM department ORDER BY DepartmentID; -┌Iterate all rows of table "department" -└Output field names ["DepartmentID" "DepartmentName"] -┌Order by DepartmentID, -└Output field names ["DepartmentID" "DepartmentName"] - ----- 201 -SELECT * FROM department ORDER BY DepartmentID; -┌Iterate all rows of table "department" -└Output field names ["DepartmentID" "DepartmentName"] -┌Order by DepartmentID, -└Output field names ["DepartmentID" "DepartmentName"] - ----- 202 -SELECT * FROM department; -┌Iterate all rows of table "department" -└Output field names ["DepartmentID" "DepartmentName"] - ----- 203 -SELECT * FROM department ORDER BY DepartmentID; -┌Iterate all rows of table "department" -└Output field names ["DepartmentID" "DepartmentName"] -┌Order by DepartmentID, -└Output field names ["DepartmentID" "DepartmentName"] - ----- 204 -SELECT id(), LastName FROM employee ORDER BY id(); -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Evaluate id() as "", LastName as "LastName", -└Output field names ["" "LastName"] -┌Order by id(), -└Output field names ["" "LastName"] - ----- 205 -SELECT id(), LastName FROM employee ORDER BY id(); -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Evaluate id() as "", LastName as "LastName", -└Output field names ["" "LastName"] -┌Order by id(), -└Output field names ["" "LastName"] - ----- 206 -SELECT id(), LastName FROM employee ORDER BY id(); -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Evaluate id() as "", LastName as "LastName", -└Output field names ["" "LastName"] -┌Order by id(), -└Output field names ["" "LastName"] - ----- 207 -SELECT id(), e.LastName, e.DepartmentID, d.DepartmentID FROM employee AS e, department AS d WHERE e.DepartmentID == d.DepartmentID ORDER BY e.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] -┌Filter on e.DepartmentID == d.DepartmentID -└Output field names ["e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] -┌Evaluate id() as "", e.LastName as "e.LastName", e.DepartmentID as "e.DepartmentID", d.DepartmentID as "d.DepartmentID", -└Output field names ["" "e.LastName" "e.DepartmentID" "d.DepartmentID"] -┌Order by e.LastName, -└Output field names ["" "e.LastName" "e.DepartmentID" "d.DepartmentID"] - ----- 208 -SELECT e.ID, e.LastName, e.DepartmentID, d.DepartmentID FROM (SELECT id() AS ID, LastName, DepartmentID FROM employee;) AS e, department AS d WHERE e.DepartmentID == d.DepartmentID ORDER BY e.ID; -┌Compute Cartesian product of -│ ┌Iterate all rows of virtual table "e" -│ │ ┌Iterate all rows of table "employee" -│ │ └Output field names ["LastName" "DepartmentID"] -│ │ ┌Evaluate id() as "ID", LastName as "LastName", DepartmentID as "DepartmentID", -│ │ └Output field names ["ID" "LastName" "DepartmentID"] -│ └Output field names ["ID" "LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -└Output field names ["e.ID" "e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] -┌Filter on e.DepartmentID == d.DepartmentID -└Output field names ["e.ID" "e.LastName" "e.DepartmentID" "d.DepartmentID" "d.DepartmentName"] -┌Evaluate e.ID as "e.ID", e.LastName as "e.LastName", e.DepartmentID as "e.DepartmentID", d.DepartmentID as "d.DepartmentID", -└Output field names ["e.ID" "e.LastName" "e.DepartmentID" "d.DepartmentID"] -┌Order by e.ID, -└Output field names ["e.ID" "e.LastName" "e.DepartmentID" "d.DepartmentID"] - ----- 209 -SELECT * FROM employee; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] - ----- 210 -SELECT * FROM employee; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] - ----- 211 -SELECT * FROM employee ORDER BY LastName; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Order by LastName, -└Output field names ["LastName" "DepartmentID"] - ----- 212 -SELECT * FROM employee ORDER BY LastName DESC; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Order descending by LastName, -└Output field names ["LastName" "DepartmentID"] - ----- 213 -SELECT * FROM employee ORDER BY LastName DESC; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Order descending by LastName, -└Output field names ["LastName" "DepartmentID"] - ----- 214 -SELECT * FROM employee ORDER BY LastName; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Order by LastName, -└Output field names ["LastName" "DepartmentID"] - ----- 215 -SELECT * FROM employee; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] - ----- 216 -SELECT * FROM employee; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] - ----- 217 -SELECT * FROM employee; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] - ----- 223 -SELECT LastName[:len(LastName) - 3] AS y FROM employee ORDER BY y; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Evaluate LastName[:len(LastName) - 3] as "y", -└Output field names ["y"] -┌Order by y, -└Output field names ["y"] - ----- 224 -SELECT complex(float32(DepartmentID + int64(id())), 0) AS x, complex(DepartmentID + int64(id()), 0) FROM employee ORDER BY real(x) DESC; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Evaluate complex(float32(DepartmentID + int64(id())), 0) as "x", complex(DepartmentID + int64(id()), 0) as "", -└Output field names ["x" ""] -┌Order descending by real(x), -└Output field names ["x" ""] - ----- 225 -SELECT real(complex(float32(DepartmentID + int64(id())), 0)) AS x, real(complex(DepartmentID + int64(id()), 0)) FROM employee ORDER BY x DESC; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Evaluate real(complex(float32(DepartmentID + int64(id())), 0)) as "x", real(complex(DepartmentID + int64(id()), 0)) as "", -└Output field names ["x" ""] -┌Order descending by x, -└Output field names ["x" ""] - ----- 226 -SELECT imag(complex(0, float32(DepartmentID + int64(id())))) AS x, imag(complex(0, DepartmentID + int64(id()))) FROM employee ORDER BY x DESC; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Evaluate imag(complex(0, float32(DepartmentID + int64(id())))) as "x", imag(complex(0, DepartmentID + int64(id()))) as "", -└Output field names ["x" ""] -┌Order descending by x, -└Output field names ["x" ""] - ----- 227 -SELECT 100 * id(), c FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate 100 * id() as "", c as "c", -└Output field names ["" "c"] - ----- 229 -SELECT * FROM b; -┌Iterate all rows of table "b" -└Output field names ["b"] - ----- 230 -SELECT * FROM c; -┌Iterate all rows of table "c" -└Output field names ["c"] - ----- 231 -SELECT * FROM a; -┌Iterate all rows of table "a" -└Output field names ["a"] - ----- 233 -SELECT * FROM c; -┌Iterate all rows of table "c" -└Output field names ["c"] - ----- 234 -SELECT * FROM a; -┌Iterate all rows of table "a" -└Output field names ["a"] - ----- 235 -SELECT * FROM b; -┌Iterate all rows of table "b" -└Output field names ["b"] - ----- 237 -SELECT * FROM a, b; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "a" -│ └Output field names ["c"] -│ ┌Iterate all rows of table "b" -│ └Output field names ["d"] -└Output field names ["a.c" "b.d"] - ----- 238 -SELECT 9 * x2.c AS x2, 3 * x1.c AS x1, 1 * x0.c AS x0, 9 * x2.c + 3 * x1.c + x0.c AS y FROM a AS x2, a AS x1, a AS x0 ORDER BY y; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "a" -│ └Output field names ["c"] -│ ┌Iterate all rows of table "a" -│ └Output field names ["c"] -│ ┌Iterate all rows of table "a" -│ └Output field names ["c"] -└Output field names ["x2.c" "x1.c" "x0.c"] -┌Evaluate 9 * x2.c as "x2", 3 * x1.c as "x1", 1 * x0.c as "x0", 9 * x2.c + 3 * x1.c + x0.c as "y", -└Output field names ["x2" "x1" "x0" "y"] -┌Order by y, -└Output field names ["x2" "x1" "x0" "y"] - ----- 239 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] - ----- 243 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 244 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 247 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["s"] - ----- 248 -SELECT i == 4294967280 FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Evaluate i == 4294967280 as "", -└Output field names [""] - ----- 249 -SELECT id() == 1 && s == "a" || id() == 2 && s == "�" && s == "�" || id() == 3 && s == "ø" && s == "ø" && s == "ø" || id() == 4 && s == "日" && s == "日" && s == "日" FROM t; -┌Iterate all rows of table "t" -└Output field names ["s"] -┌Evaluate id() == 1 && s == "a" || id() == 2 && s == "�" && s == "�" || id() == 3 && s == "ø" && s == "ø" && s == "ø" || id() == 4 && s == "日" && s == "日" && s == "日" as "", -└Output field names [""] - ----- 250 -SELECT 3.3, 3.3 FROM t; -┌Iterate all rows of table "t" -└Output field names [] -┌Evaluate 3.3 as "", 3.3 as "", -└Output field names ["" ""] - ----- 252 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 253 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 255 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 257 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 260 -SELECT count() FROM employee; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Group by distinct rows -└Output field names ["LastName" "DepartmentID"] -┌Evaluate count() as "", -└Output field names [""] - ----- 261 -SELECT count() AS y FROM employee; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Group by distinct rows -└Output field names ["LastName" "DepartmentID"] -┌Evaluate count() as "y", -└Output field names ["y"] - ----- 262 -SELECT 3 * count() AS y FROM employee; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Group by distinct rows -└Output field names ["LastName" "DepartmentID"] -┌Evaluate 3 * count() as "y", -└Output field names ["y"] - ----- 263 -SELECT count(LastName) FROM employee; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Group by distinct rows -└Output field names ["LastName" "DepartmentID"] -┌Evaluate count(LastName) as "", -└Output field names [""] - ----- 264 -SELECT count(DepartmentID) FROM employee; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Group by distinct rows -└Output field names ["LastName" "DepartmentID"] -┌Evaluate count(DepartmentID) as "", -└Output field names [""] - ----- 265 -SELECT count() - count(DepartmentID) FROM employee; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Group by distinct rows -└Output field names ["LastName" "DepartmentID"] -┌Evaluate count() - count(DepartmentID) as "", -└Output field names [""] - ----- 266 -SELECT min(LastName), min(DepartmentID) FROM employee; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Group by distinct rows -└Output field names ["LastName" "DepartmentID"] -┌Evaluate min(LastName) as "", min(DepartmentID) as "", -└Output field names ["" ""] - ----- 267 -SELECT max(LastName), max(DepartmentID) FROM employee; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Group by distinct rows -└Output field names ["LastName" "DepartmentID"] -┌Evaluate max(LastName) as "", max(DepartmentID) as "", -└Output field names ["" ""] - ----- 268 -SELECT sum(LastName), sum(DepartmentID) FROM employee; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Group by distinct rows -└Output field names ["LastName" "DepartmentID"] -┌Evaluate sum(LastName) as "", sum(DepartmentID) as "", -└Output field names ["" ""] - ----- 269 -SELECT sum(DepartmentID) FROM employee; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Group by distinct rows -└Output field names ["LastName" "DepartmentID"] -┌Evaluate sum(DepartmentID) as "", -└Output field names [""] - ----- 270 -SELECT avg(DepartmentID) FROM employee; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Group by distinct rows -└Output field names ["LastName" "DepartmentID"] -┌Evaluate avg(DepartmentID) as "", -└Output field names [""] - ----- 272 -SELECT DepartmentID, sum(DepartmentID) AS s FROM employee GROUP BY DepartmentID ORDER BY s DESC; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Group by DepartmentID, -└Output field names ["LastName" "DepartmentID"] -┌Evaluate DepartmentID as "DepartmentID", sum(DepartmentID) as "s", -└Output field names ["DepartmentID" "s"] -┌Order descending by s, -└Output field names ["DepartmentID" "s"] - ----- 273 -SELECT DepartmentID, count(LastName + string(DepartmentID)) AS y FROM employee GROUP BY DepartmentID ORDER BY y DESC; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Group by DepartmentID, -└Output field names ["LastName" "DepartmentID"] -┌Evaluate DepartmentID as "DepartmentID", count(LastName + string(DepartmentID)) as "y", -└Output field names ["DepartmentID" "y"] -┌Order descending by y, -└Output field names ["DepartmentID" "y"] - ----- 274 -SELECT DepartmentID, sum(2 * DepartmentID) AS s FROM employee GROUP BY DepartmentID ORDER BY s DESC; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Group by DepartmentID, -└Output field names ["LastName" "DepartmentID"] -┌Evaluate DepartmentID as "DepartmentID", sum(2 * DepartmentID) as "s", -└Output field names ["DepartmentID" "s"] -┌Order descending by s, -└Output field names ["DepartmentID" "s"] - ----- 275 -SELECT min(2 * DepartmentID) FROM employee; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Group by distinct rows -└Output field names ["LastName" "DepartmentID"] -┌Evaluate min(2 * DepartmentID) as "", -└Output field names [""] - ----- 276 -SELECT max(2 * DepartmentID) FROM employee; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Group by distinct rows -└Output field names ["LastName" "DepartmentID"] -┌Evaluate max(2 * DepartmentID) as "", -└Output field names [""] - ----- 277 -SELECT avg(2 * DepartmentID) FROM employee; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Group by distinct rows -└Output field names ["LastName" "DepartmentID"] -┌Evaluate avg(2 * DepartmentID) as "", -└Output field names [""] - ----- 278 -SELECT * FROM employee GROUP BY DepartmentID; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Group by DepartmentID, -└Output field names ["LastName" "DepartmentID"] -┌Evaluate LastName as "LastName", DepartmentID as "DepartmentID", -└Output field names ["LastName" "DepartmentID"] - ----- 279 -SELECT * FROM employee GROUP BY DepartmentID ORDER BY LastName DESC; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Group by DepartmentID, -└Output field names ["LastName" "DepartmentID"] -┌Evaluate LastName as "LastName", DepartmentID as "DepartmentID", -└Output field names ["LastName" "DepartmentID"] -┌Order descending by LastName, -└Output field names ["LastName" "DepartmentID"] - ----- 280 -SELECT * FROM employee GROUP BY DepartmentID, LastName ORDER BY LastName DESC; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Group by DepartmentID, LastName, -└Output field names ["LastName" "DepartmentID"] -┌Evaluate LastName as "LastName", DepartmentID as "DepartmentID", -└Output field names ["LastName" "DepartmentID"] -┌Order descending by LastName, -└Output field names ["LastName" "DepartmentID"] - ----- 281 -SELECT * FROM employee GROUP BY LastName, DepartmentID ORDER BY LastName DESC; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Group by LastName, DepartmentID, -└Output field names ["LastName" "DepartmentID"] -┌Evaluate LastName as "LastName", DepartmentID as "DepartmentID", -└Output field names ["LastName" "DepartmentID"] -┌Order descending by LastName, -└Output field names ["LastName" "DepartmentID"] - ----- 282 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 283 -SELECT count() FROM t; -┌Iterate all rows of table "t" -└Output field names ["n"] -┌Group by distinct rows -└Output field names ["n"] -┌Evaluate count() as "", -└Output field names [""] - ----- 284 -SELECT count() FROM t; -┌Iterate all rows of table "t" -└Output field names ["n"] -┌Group by distinct rows -└Output field names ["n"] -┌Evaluate count() as "", -└Output field names [""] - ----- 285 -SELECT count() FROM t WHERE n < 2; -┌Iterate all rows of table "t" -└Output field names ["n"] -┌Filter on n < 2 -│Possibly useful indices -│CREATE INDEX xt_n ON t(n); -└Output field names ["n"] -┌Group by distinct rows -└Output field names ["n"] -┌Evaluate count() as "", -└Output field names [""] - ----- 286 -SELECT count() FROM t WHERE n < 1; -┌Iterate all rows of table "t" -└Output field names ["n"] -┌Filter on n < 1 -│Possibly useful indices -│CREATE INDEX xt_n ON t(n); -└Output field names ["n"] -┌Group by distinct rows -└Output field names ["n"] -┌Evaluate count() as "", -└Output field names [""] - ----- 287 -SELECT count() FROM t WHERE n < 0; -┌Iterate all rows of table "t" -└Output field names ["n"] -┌Filter on n < 0 -│Possibly useful indices -│CREATE INDEX xt_n ON t(n); -└Output field names ["n"] -┌Group by distinct rows -└Output field names ["n"] -┌Evaluate count() as "", -└Output field names [""] - ----- 288 -SELECT s + 10 FROM (SELECT sum(n) AS s FROM t WHERE n < 2;); -┌Iterate all rows of table "t" -└Output field names ["n"] -┌Filter on n < 2 -│Possibly useful indices -│CREATE INDEX xt_n ON t(n); -└Output field names ["n"] -┌Group by distinct rows -└Output field names ["n"] -┌Evaluate sum(n) as "s", -└Output field names ["s"] -┌Evaluate s + 10 as "", -└Output field names [""] - ----- 289 -SELECT s + 10 FROM (SELECT sum(n) AS s FROM t WHERE n < 1;); -┌Iterate all rows of table "t" -└Output field names ["n"] -┌Filter on n < 1 -│Possibly useful indices -│CREATE INDEX xt_n ON t(n); -└Output field names ["n"] -┌Group by distinct rows -└Output field names ["n"] -┌Evaluate sum(n) as "s", -└Output field names ["s"] -┌Evaluate s + 10 as "", -└Output field names [""] - ----- 290 -SELECT s + 10 FROM (SELECT sum(n) AS s FROM t WHERE n < 0;); -┌Iterate all rows of table "t" -└Output field names ["n"] -┌Filter on n < 0 -│Possibly useful indices -│CREATE INDEX xt_n ON t(n); -└Output field names ["n"] -┌Group by distinct rows -└Output field names ["n"] -┌Evaluate sum(n) as "s", -└Output field names ["s"] -┌Evaluate s + 10 as "", -└Output field names [""] - ----- 291 -SELECT sum(n) AS s FROM t WHERE n < 2; -┌Iterate all rows of table "t" -└Output field names ["n"] -┌Filter on n < 2 -│Possibly useful indices -│CREATE INDEX xt_n ON t(n); -└Output field names ["n"] -┌Group by distinct rows -└Output field names ["n"] -┌Evaluate sum(n) as "s", -└Output field names ["s"] - ----- 292 -SELECT sum(n) AS s FROM t WHERE n < 1; -┌Iterate all rows of table "t" -└Output field names ["n"] -┌Filter on n < 1 -│Possibly useful indices -│CREATE INDEX xt_n ON t(n); -└Output field names ["n"] -┌Group by distinct rows -└Output field names ["n"] -┌Evaluate sum(n) as "s", -└Output field names ["s"] - ----- 293 -SELECT sum(n) AS s FROM t WHERE n < 0; -┌Iterate all rows of table "t" -└Output field names ["n"] -┌Filter on n < 0 -│Possibly useful indices -│CREATE INDEX xt_n ON t(n); -└Output field names ["n"] -┌Group by distinct rows -└Output field names ["n"] -┌Evaluate sum(n) as "s", -└Output field names ["s"] - ----- 294 -SELECT count() FROM t; -┌Iterate all rows of table "t" -└Output field names ["n"] -┌Group by distinct rows -└Output field names ["n"] -┌Evaluate count() as "", -└Output field names [""] - ----- 295 -SELECT count() FROM t; -┌Iterate all rows of table "t" -└Output field names ["n"] -┌Group by distinct rows -└Output field names ["n"] -┌Evaluate count() as "", -└Output field names [""] - ----- 296 -SELECT count() FROM t; -┌Iterate all rows of table "t" -└Output field names ["n"] -┌Group by distinct rows -└Output field names ["n"] -┌Evaluate count() as "", -└Output field names [""] - ----- 297 -SELECT count() FROM t; -┌Iterate all rows of table "t" -└Output field names ["S"] -┌Group by distinct rows -└Output field names ["S"] -┌Evaluate count() as "", -└Output field names [""] - ----- 298 -SELECT count() FROM t; -┌Iterate all rows of table "t" -└Output field names ["S"] -┌Group by distinct rows -└Output field names ["S"] -┌Evaluate count() as "", -└Output field names [""] - ----- 299 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] - ----- 300 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] - ----- 301 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] - ----- 302 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] - ----- 303 -SELECT string(c) FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate string(c) as "", -└Output field names [""] - ----- 304 -SELECT string(c) FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate string(c) as "", -└Output field names [""] - ----- 305 -SELECT string(c) FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate string(c) as "", -└Output field names [""] - ----- 306 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] - ----- 307 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] - ----- 308 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i" "b"] - ----- 309 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i" "b"] - ----- 310 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i" "b"] - ----- 311 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i" "b"] - ----- 312 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i" "b"] - ----- 313 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i" "b"] - ----- 314 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i" "b"] - ----- 315 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i" "b"] - ----- 316 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i" "b"] - ----- 317 -SELECT i, string(b) FROM t; -┌Iterate all rows of table "t" -└Output field names ["i" "b"] -┌Evaluate i as "i", string(b) as "", -└Output field names ["i" ""] - ----- 318 -SELECT i, string(b) FROM t; -┌Iterate all rows of table "t" -└Output field names ["i" "b"] -┌Evaluate i as "i", string(b) as "", -└Output field names ["i" ""] - ----- 319 -SELECT i, string(b) FROM t; -┌Iterate all rows of table "t" -└Output field names ["i" "b"] -┌Evaluate i as "i", string(b) as "", -└Output field names ["i" ""] - ----- 320 -SELECT i, string(b) FROM t; -┌Iterate all rows of table "t" -└Output field names ["i" "b"] -┌Evaluate i as "i", string(b) as "", -└Output field names ["i" ""] - ----- 321 -SELECT i, string(b) FROM t; -┌Iterate all rows of table "t" -└Output field names ["i" "b"] -┌Evaluate i as "i", string(b) as "", -└Output field names ["i" ""] - ----- 322 -SELECT i, string(b) FROM t; -┌Iterate all rows of table "t" -└Output field names ["i" "b"] -┌Evaluate i as "i", string(b) as "", -└Output field names ["i" ""] - ----- 323 -SELECT * FROM t ORDER BY true, c, false; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Order by true, c, false, -└Output field names ["c"] - ----- 324 -SELECT c, sum(i) FROM t GROUP BY c; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] -┌Group by c, -└Output field names ["c" "i"] -┌Evaluate c as "c", sum(i) as "", -└Output field names ["c" ""] - ----- 325 -SELECT * FROM t ORDER BY 42, c, 24; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 326 -SELECT c, sum(i) FROM t GROUP BY c; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] -┌Group by c, -└Output field names ["c" "i"] -┌Evaluate c as "c", sum(i) as "", -└Output field names ["c" ""] - ----- 327 -SELECT * FROM t ORDER BY 42, c, 24; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 328 -SELECT c, sum(i) FROM t GROUP BY c; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] -┌Group by c, -└Output field names ["c" "i"] -┌Evaluate c as "c", sum(i) as "", -└Output field names ["c" ""] - ----- 329 -SELECT c, sum(i) FROM t GROUP BY c; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] -┌Group by c, -└Output field names ["c" "i"] -┌Evaluate c as "c", sum(i) as "", -└Output field names ["c" ""] - ----- 330 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] - ----- 331 -SELECT c, sum(i) FROM t GROUP BY c; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] -┌Group by c, -└Output field names ["c" "i"] -┌Evaluate c as "c", sum(i) as "", -└Output field names ["c" ""] - ----- 332 -SELECT c, sum(i) FROM t GROUP BY c; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] -┌Group by c, -└Output field names ["c" "i"] -┌Evaluate c as "c", sum(i) as "", -└Output field names ["c" ""] - ----- 334 -SELECT * FROM t ORDER BY 15, c, 16; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 335 -SELECT c, sum(i) FROM t GROUP BY c; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] -┌Group by c, -└Output field names ["c" "i"] -┌Evaluate c as "c", sum(i) as "", -└Output field names ["c" ""] - ----- 337 -SELECT * FROM t ORDER BY 15, c, 16; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 338 -SELECT c, sum(i) FROM t GROUP BY c; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] -┌Group by c, -└Output field names ["c" "i"] -┌Evaluate c as "c", sum(i) as "", -└Output field names ["c" ""] - ----- 339 -SELECT * FROM t ORDER BY 15, c, 16; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 340 -SELECT c, sum(i) FROM t GROUP BY c; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] -┌Group by c, -└Output field names ["c" "i"] -┌Evaluate c as "c", sum(i) as "", -└Output field names ["c" ""] - ----- 341 -SELECT * FROM t ORDER BY 15, c, 16; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 342 -SELECT c, sum(i) FROM t GROUP BY c; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] -┌Group by c, -└Output field names ["c" "i"] -┌Evaluate c as "c", sum(i) as "", -└Output field names ["c" ""] - ----- 343 -SELECT * FROM t ORDER BY 15, c, 16; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 344 -SELECT c, sum(i) FROM t GROUP BY c; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] -┌Group by c, -└Output field names ["c" "i"] -┌Evaluate c as "c", sum(i) as "", -└Output field names ["c" ""] - ----- 345 -SELECT * FROM t ORDER BY 15, c, 16; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 346 -SELECT c, sum(i) FROM t GROUP BY c; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] -┌Group by c, -└Output field names ["c" "i"] -┌Evaluate c as "c", sum(i) as "", -└Output field names ["c" ""] - ----- 347 -SELECT * FROM t ORDER BY 15, c, 16; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 348 -SELECT c, sum(i) FROM t GROUP BY c; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] -┌Group by c, -└Output field names ["c" "i"] -┌Evaluate c as "c", sum(i) as "", -└Output field names ["c" ""] - ----- 349 -SELECT * FROM t ORDER BY 15, c, 16; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 350 -SELECT c, sum(i) FROM t GROUP BY c; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] -┌Group by c, -└Output field names ["c" "i"] -┌Evaluate c as "c", sum(i) as "", -└Output field names ["c" ""] - ----- 351 -SELECT * FROM t ORDER BY 15, c, 16; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 352 -SELECT c, sum(i) FROM t GROUP BY c; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] -┌Group by c, -└Output field names ["c" "i"] -┌Evaluate c as "c", sum(i) as "", -└Output field names ["c" ""] - ----- 353 -SELECT * FROM t ORDER BY 15, c, 16; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 354 -SELECT c, sum(i) FROM t GROUP BY c; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] -┌Group by c, -└Output field names ["c" "i"] -┌Evaluate c as "c", sum(i) as "", -└Output field names ["c" ""] - ----- 355 -SELECT * FROM t ORDER BY 15, c, 16; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 356 -SELECT c, sum(i) FROM t GROUP BY c; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] -┌Group by c, -└Output field names ["c" "i"] -┌Evaluate c as "c", sum(i) as "", -└Output field names ["c" ""] - ----- 357 -SELECT * FROM t ORDER BY 15, c, 16; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 358 -SELECT c, sum(i) FROM t GROUP BY c; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] -┌Group by c, -└Output field names ["c" "i"] -┌Evaluate c as "c", sum(i) as "", -└Output field names ["c" ""] - ----- 359 -SELECT * FROM t ORDER BY 15, c, 16; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 360 -SELECT c, sum(i) FROM t GROUP BY c; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] -┌Group by c, -└Output field names ["c" "i"] -┌Evaluate c as "c", sum(i) as "", -└Output field names ["c" ""] - ----- 361 -SELECT * FROM t ORDER BY 15, c, 16; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 362 -SELECT c, sum(i) FROM t GROUP BY c; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] -┌Group by c, -└Output field names ["c" "i"] -┌Evaluate c as "c", sum(i) as "", -└Output field names ["c" ""] - ----- 363 -SELECT * FROM t ORDER BY 15, c, 16; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 364 -SELECT c, sum(i) FROM t GROUP BY c; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] -┌Group by c, -└Output field names ["c" "i"] -┌Evaluate c as "c", sum(i) as "", -└Output field names ["c" ""] - ----- 365 -SELECT * FROM t ORDER BY 15, c, 16; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 366 -SELECT c, sum(i) FROM t GROUP BY c; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] -┌Group by c, -└Output field names ["c" "i"] -┌Evaluate c as "c", sum(i) as "", -└Output field names ["c" ""] - ----- 367 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] - ----- 368 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] - ----- 369 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] - ----- 370 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 371 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 372 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 373 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 374 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 375 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 376 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 377 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 378 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 379 -SELECT * FROM t ORDER BY 15, c, 16; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 380 -SELECT c, sum(i) FROM t GROUP BY c; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] -┌Group by c, -└Output field names ["c" "i"] -┌Evaluate c as "c", sum(i) as "", -└Output field names ["c" ""] - ----- 381 -SELECT * FROM t WHERE c > 100 ORDER BY c DESC; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Filter on c > 100 -│Possibly useful indices -│CREATE INDEX xt_c ON t(c); -└Output field names ["c"] -┌Order descending by c, -└Output field names ["c"] - ----- 382 -SELECT * FROM t WHERE c < 110 ORDER BY c; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Filter on c < 110 -│Possibly useful indices -│CREATE INDEX xt_c ON t(c); -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 383 -SELECT * FROM t WHERE c <= 110 ORDER BY c; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Filter on c <= 110 -│Possibly useful indices -│CREATE INDEX xt_c ON t(c); -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 384 -SELECT * FROM t WHERE c >= 110 ORDER BY c; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Filter on c >= 110 -│Possibly useful indices -│CREATE INDEX xt_c ON t(c); -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 385 -SELECT * FROM t WHERE c != 110 ORDER BY c; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Filter on c != 110 -│Possibly useful indices -│CREATE INDEX xt_c ON t(c); -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 386 -SELECT * FROM t WHERE c == 110 ORDER BY c; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Filter on c == 110 -│Possibly useful indices -│CREATE INDEX xt_c ON t(c); -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 387 -SELECT c + 1000 AS s FROM t ORDER BY s; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate c + 1000 as "s", -└Output field names ["s"] -┌Order by s, -└Output field names ["s"] - ----- 388 -SELECT 1000 - c AS s FROM t ORDER BY s; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate 1000 - c as "s", -└Output field names ["s"] -┌Order by s, -└Output field names ["s"] - ----- 389 -SELECT c >> 1 AS s FROM t ORDER BY s; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate c >> 1 as "s", -└Output field names ["s"] -┌Order by s, -└Output field names ["s"] - ----- 390 -SELECT c << 1 AS s FROM t ORDER BY s; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate c << 1 as "s", -└Output field names ["s"] -┌Order by s, -└Output field names ["s"] - ----- 391 -SELECT * FROM t WHERE c & 349525 == 70992; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Filter on c & 349525 == 70992 -└Output field names ["c"] - ----- 392 -SELECT * FROM t WHERE c | 349525 == 358389; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Filter on c | 349525 == 358389 -└Output field names ["c"] - ----- 393 -SELECT * FROM t WHERE c &^ 349525 == 8864; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Filter on c &^ 349525 == 8864 -└Output field names ["c"] - ----- 394 -SELECT * FROM t WHERE c ^ 349525 == 287397; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Filter on c ^ 349525 == 287397 -└Output field names ["c"] - ----- 395 -SELECT * FROM t WHERE c % 256 == 240; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Filter on c % 256 == 240 -└Output field names ["c"] - ----- 396 -SELECT * FROM t WHERE c * 16 == 1277696; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Filter on c * 16 == 1277696 -└Output field names ["c"] - ----- 397 -SELECT * FROM t WHERE ^c == -79857; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Filter on ^c == -79857 -└Output field names ["c"] - ----- 398 -SELECT * FROM t WHERE +c == 79856; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Filter on +c == 79856 -└Output field names ["c"] - ----- 399 -SELECT * FROM t WHERE -c == -79856; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Filter on -c == -79856 -└Output field names ["c"] - ----- 400 -SELECT * FROM t ORDER BY 15, c, 16; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 401 -SELECT c, sum(i) FROM t GROUP BY c; -┌Iterate all rows of table "t" -└Output field names ["c" "i"] -┌Group by c, -└Output field names ["c" "i"] -┌Evaluate c as "c", sum(i) as "", -└Output field names ["c" ""] - ----- 402 -SELECT * FROM t ORDER BY 15, c, 16; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 403 -SELECT * FROM t ORDER BY 15, c, 16; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 404 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] - ----- 405 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] - ----- 406 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] - ----- 407 -SELECT c / d FROM t; -┌Iterate all rows of table "t" -└Output field names ["c" "d"] -┌Evaluate c / d as "", -└Output field names [""] - ----- 408 -SELECT c % d FROM t; -┌Iterate all rows of table "t" -└Output field names ["c" "d"] -┌Evaluate c % d as "", -└Output field names [""] - ----- 409 -SELECT c == d FROM t; -┌Iterate all rows of table "t" -└Output field names ["c" "d"] -┌Evaluate c == d as "", -└Output field names [""] - ----- 410 -SELECT c == d FROM t; -┌Iterate all rows of table "t" -└Output field names ["c" "d"] -┌Evaluate c == d as "", -└Output field names [""] - ----- 411 -SELECT c != d FROM t; -┌Iterate all rows of table "t" -└Output field names ["c" "d"] -┌Evaluate c != d as "", -└Output field names [""] - ----- 412 -SELECT c != d FROM t; -┌Iterate all rows of table "t" -└Output field names ["c" "d"] -┌Evaluate c != d as "", -└Output field names [""] - ----- 413 -SELECT c < d FROM t; -┌Iterate all rows of table "t" -└Output field names ["c" "d"] -┌Evaluate c < d as "", -└Output field names [""] - ----- 414 -SELECT c < d FROM t; -┌Iterate all rows of table "t" -└Output field names ["c" "d"] -┌Evaluate c < d as "", -└Output field names [""] - ----- 415 -SELECT c <= d FROM t; -┌Iterate all rows of table "t" -└Output field names ["c" "d"] -┌Evaluate c <= d as "", -└Output field names [""] - ----- 416 -SELECT c <= d FROM t; -┌Iterate all rows of table "t" -└Output field names ["c" "d"] -┌Evaluate c <= d as "", -└Output field names [""] - ----- 417 -SELECT c > d FROM t; -┌Iterate all rows of table "t" -└Output field names ["c" "d"] -┌Evaluate c > d as "", -└Output field names [""] - ----- 418 -SELECT c > d FROM t; -┌Iterate all rows of table "t" -└Output field names ["c" "d"] -┌Evaluate c > d as "", -└Output field names [""] - ----- 419 -SELECT c >= d FROM t; -┌Iterate all rows of table "t" -└Output field names ["c" "d"] -┌Evaluate c >= d as "", -└Output field names [""] - ----- 420 -SELECT c >= d FROM t; -┌Iterate all rows of table "t" -└Output field names ["c" "d"] -┌Evaluate c >= d as "", -└Output field names [""] - ----- 421 -SELECT c / d FROM t; -┌Iterate all rows of table "t" -└Output field names ["c" "d"] -┌Evaluate c / d as "", -└Output field names [""] - ----- 422 -SELECT c / d FROM t; -┌Iterate all rows of table "t" -└Output field names ["c" "d"] -┌Evaluate c / d as "", -└Output field names [""] - ----- 424 -SELECT +c, -d FROM t; -┌Iterate all rows of table "t" -└Output field names ["c" "d"] -┌Evaluate +c as "", -d as "", -└Output field names ["" ""] - ----- 425 -SELECT 1 + c, d + 1, 1.5 + c, d + 1.5 FROM t; -┌Iterate all rows of table "t" -└Output field names ["c" "d"] -┌Evaluate 1 + c as "", d + 1 as "", 1.5 + c as "", d + 1.5 as "", -└Output field names ["" "" "" ""] - ----- 426 -SELECT float64(c) FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate float64(c) as "", -└Output field names [""] - ----- 427 -SELECT formatTime(timeIn(c, "UTC"), "2006-01-02 15:04:05.999999999 -0700") FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate formatTime(timeIn(c, "UTC"), "2006-01-02 15:04:05.999999999 -0700") as "", -└Output field names [""] - ----- 428 -SELECT c, string(c) FROM t ORDER BY c; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate c as "c", string(c) as "", -└Output field names ["c" ""] -┌Order by c, -└Output field names ["c" ""] - ----- 429 -SELECT since(c) > duration("24h0m0s") FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate since(c) > duration("24h0m0s") as "", -└Output field names [""] - ----- 430 -SELECT since(c) >= duration("24h0m0s") FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate since(c) >= duration("24h0m0s") as "", -└Output field names [""] - ----- 431 -SELECT a > a, a > b, a > c, b > a, b > b, b > c, c > a, c > b, c > c FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] -┌Evaluate a > a as "", a > b as "", a > c as "", b > a as "", b > b as "", b > c as "", c > a as "", c > b as "", c > c as "", -└Output field names ["" "" "" "" "" "" "" "" ""] - ----- 432 -SELECT a < a, a < b, a < c, b < a, b < b, b < c, c < a, c < b, c < c FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] -┌Evaluate a < a as "", a < b as "", a < c as "", b < a as "", b < b as "", b < c as "", c < a as "", c < b as "", c < c as "", -└Output field names ["" "" "" "" "" "" "" "" ""] - ----- 433 -SELECT a <= a, a <= b, a <= c, b <= a, b <= b, b <= c, c <= a, c <= b, c <= c FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] -┌Evaluate a <= a as "", a <= b as "", a <= c as "", b <= a as "", b <= b as "", b <= c as "", c <= a as "", c <= b as "", c <= c as "", -└Output field names ["" "" "" "" "" "" "" "" ""] - ----- 434 -SELECT a >= a, a >= b, a >= c, b >= a, b >= b, b >= c, c >= a, c >= b, c >= c FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] -┌Evaluate a >= a as "", a >= b as "", a >= c as "", b >= a as "", b >= b as "", b >= c as "", c >= a as "", c >= b as "", c >= c as "", -└Output field names ["" "" "" "" "" "" "" "" ""] - ----- 435 -SELECT a != a, a != b, a != c, b != a, b != b, b != c, c != a, c != b, c != c FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] -┌Evaluate a != a as "", a != b as "", a != c as "", b != a as "", b != b as "", b != c as "", c != a as "", c != b as "", c != c as "", -└Output field names ["" "" "" "" "" "" "" "" ""] - ----- 436 -SELECT a == a, a == b, a == c, b == a, b == b, b == c, c == a, c == b, c == c FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] -┌Evaluate a == a as "", a == b as "", a == c as "", b == a as "", b == b as "", b == c as "", c == a as "", c == b as "", c == c as "", -└Output field names ["" "" "" "" "" "" "" "" ""] - ----- 437 -SELECT b + c, a + c, a + b, a + b + c FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] -┌Evaluate b + c as "", a + c as "", a + b as "", a + b + c as "", -└Output field names ["" "" "" ""] - ----- 438 -SELECT b - c, a - c, a - b, a - b - c FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] -┌Evaluate b - c as "", a - c as "", a - b as "", a - b - c as "", -└Output field names ["" "" "" ""] - ----- 439 -SELECT a >> 1, b >> 1, c >> 1 FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] -┌Evaluate a >> 1 as "", b >> 1 as "", c >> 1 as "", -└Output field names ["" "" ""] - ----- 440 -SELECT a << 1, b << 1, c << 1 FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] -┌Evaluate a << 1 as "", b << 1 as "", c << 1 as "", -└Output field names ["" "" ""] - ----- 441 -SELECT a & 255 FROM t; -┌Iterate all rows of table "t" -└Output field names ["a"] -┌Evaluate a & 255 as "", -└Output field names [""] - ----- 442 -SELECT a | 256 FROM t; -┌Iterate all rows of table "t" -└Output field names ["a"] -┌Evaluate a | 256 as "", -└Output field names [""] - ----- 443 -SELECT a &^ 3376 FROM t; -┌Iterate all rows of table "t" -└Output field names ["a"] -┌Evaluate a &^ 3376 as "", -└Output field names [""] - ----- 444 -SELECT a % duration("2h0m0s"), a % duration("1m0s") FROM t; -┌Iterate all rows of table "t" -└Output field names ["a"] -┌Evaluate a % duration("2h0m0s") as "", a % duration("1m0s") as "", -└Output field names ["" ""] - ----- 445 -SELECT a / 2, b / 2, c / 2 FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] -┌Evaluate a / 2 as "", b / 2 as "", c / 2 as "", -└Output field names ["" "" ""] - ----- 446 -SELECT a * 2, 2 * b, c * 2 FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] -┌Evaluate a * 2 as "", 2 * b as "", c * 2 as "", -└Output field names ["" "" ""] - ----- 447 -SELECT ^a, ^b, ^c FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] -┌Evaluate ^a as "", ^b as "", ^c as "", -└Output field names ["" "" ""] - ----- 448 -SELECT +a, +b, +c FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] -┌Evaluate +a as "", +b as "", +c as "", -└Output field names ["" "" ""] - ----- 449 -SELECT -a, -b, -c FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] -┌Evaluate -a as "", -b as "", -c as "", -└Output field names ["" "" ""] - ----- 450 -SELECT a > a, a > b, a > c, b > a, b > b, b > c, c > a, c > b, c > c FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] -┌Evaluate a > a as "", a > b as "", a > c as "", b > a as "", b > b as "", b > c as "", c > a as "", c > b as "", c > c as "", -└Output field names ["" "" "" "" "" "" "" "" ""] - ----- 451 -SELECT a < a, a < b, a < c, b < a, b < b, b < c, c < a, c < b, c < c FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] -┌Evaluate a < a as "", a < b as "", a < c as "", b < a as "", b < b as "", b < c as "", c < a as "", c < b as "", c < c as "", -└Output field names ["" "" "" "" "" "" "" "" ""] - ----- 452 -SELECT a <= a, a <= b, a <= c, b <= a, b <= b, b <= c, c <= a, c <= b, c <= c FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] -┌Evaluate a <= a as "", a <= b as "", a <= c as "", b <= a as "", b <= b as "", b <= c as "", c <= a as "", c <= b as "", c <= c as "", -└Output field names ["" "" "" "" "" "" "" "" ""] - ----- 453 -SELECT a >= a, a >= b, a >= c, b >= a, b >= b, b >= c, c >= a, c >= b, c >= c FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] -┌Evaluate a >= a as "", a >= b as "", a >= c as "", b >= a as "", b >= b as "", b >= c as "", c >= a as "", c >= b as "", c >= c as "", -└Output field names ["" "" "" "" "" "" "" "" ""] - ----- 454 -SELECT a != a, a != b, a != c, b != a, b != b, b != c, c != a, c != b, c != c FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] -┌Evaluate a != a as "", a != b as "", a != c as "", b != a as "", b != b as "", b != c as "", c != a as "", c != b as "", c != c as "", -└Output field names ["" "" "" "" "" "" "" "" ""] - ----- 455 -SELECT a == a, a == b, a == c, b == a, b == b, b == c, c == a, c == b, c == c FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] -┌Evaluate a == a as "", a == b as "", a == c as "", b == a as "", b == b as "", b == c as "", c == a as "", c == b as "", c == c as "", -└Output field names ["" "" "" "" "" "" "" "" ""] - ----- 456 -SELECT formatTime(timeIn(a + b, "UTC"), "2006-01-02 15:04:05.999999999 -0700") FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b"] -┌Evaluate formatTime(timeIn(a + b, "UTC"), "2006-01-02 15:04:05.999999999 -0700") as "", -└Output field names [""] - ----- 457 -SELECT formatTime(timeIn(b + a, "UTC"), "2006-01-02 15:04:05.999999999 -0700") FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b"] -┌Evaluate formatTime(timeIn(b + a, "UTC"), "2006-01-02 15:04:05.999999999 -0700") as "", -└Output field names [""] - ----- 458 -SELECT a + a FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b"] -┌Evaluate a + a as "", -└Output field names [""] - ----- 459 -SELECT a - b FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b"] -┌Evaluate a - b as "", -└Output field names [""] - ----- 460 -SELECT formatTime(timeIn(a - b, "UTC"), "2006-01-02 15:04:05.999999999 -0700") FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b"] -┌Evaluate formatTime(timeIn(a - b, "UTC"), "2006-01-02 15:04:05.999999999 -0700") as "", -└Output field names [""] - ----- 461 -SELECT b - a FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b"] -┌Evaluate b - a as "", -└Output field names [""] - ----- 462 -SELECT hours(a), minutes(a), seconds(a), nanoseconds(a) FROM t; -┌Iterate all rows of table "t" -└Output field names ["a"] -┌Evaluate hours(a) as "", minutes(a) as "", seconds(a) as "", nanoseconds(a) as "", -└Output field names ["" "" "" ""] - ----- 463 -SELECT a < now(), a < now(), a >= now(), a >= now() FROM t; -┌Iterate all rows of table "t" -└Output field names ["a"] -┌Evaluate a < now() as "", a < now() as "", a >= now() as "", a >= now() as "", -└Output field names ["" "" "" ""] - ----- 464 -SELECT formatTime(timeIn(a, "UTC"), "2006-01-02 15:04:05.999999999 -0700") AS a FROM t ORDER BY a; -┌Iterate all rows of table "t" -└Output field names ["a"] -┌Evaluate formatTime(timeIn(a, "UTC"), "2006-01-02 15:04:05.999999999 -0700") as "a", -└Output field names ["a"] -┌Order by a, -└Output field names ["a"] - ----- 465 -SELECT hour(timeIn(a, "UTC")) AS y FROM t ORDER BY y; -┌Iterate all rows of table "t" -└Output field names ["a"] -┌Evaluate hour(timeIn(a, "UTC")) as "y", -└Output field names ["y"] -┌Order by y, -└Output field names ["y"] - ----- 466 -SELECT minute(a) AS y FROM t ORDER BY y; -┌Iterate all rows of table "t" -└Output field names ["a"] -┌Evaluate minute(a) as "y", -└Output field names ["y"] -┌Order by y, -└Output field names ["y"] - ----- 467 -SELECT second(a) AS y FROM t ORDER BY y; -┌Iterate all rows of table "t" -└Output field names ["a"] -┌Evaluate second(a) as "y", -└Output field names ["y"] -┌Order by y, -└Output field names ["y"] - ----- 468 -SELECT nanosecond(a) AS y FROM t ORDER BY y; -┌Iterate all rows of table "t" -└Output field names ["a"] -┌Evaluate nanosecond(a) as "y", -└Output field names ["y"] -┌Order by y, -└Output field names ["y"] - ----- 469 -SELECT year(a) AS y FROM t ORDER BY y; -┌Iterate all rows of table "t" -└Output field names ["a"] -┌Evaluate year(a) as "y", -└Output field names ["y"] -┌Order by y, -└Output field names ["y"] - ----- 470 -SELECT day(a) AS y FROM t ORDER BY y; -┌Iterate all rows of table "t" -└Output field names ["a"] -┌Evaluate day(a) as "y", -└Output field names ["y"] -┌Order by y, -└Output field names ["y"] - ----- 471 -SELECT month(a) AS y FROM t ORDER BY y; -┌Iterate all rows of table "t" -└Output field names ["a"] -┌Evaluate month(a) as "y", -└Output field names ["y"] -┌Order by y, -└Output field names ["y"] - ----- 472 -SELECT weekday(a) AS y FROM t ORDER BY y; -┌Iterate all rows of table "t" -└Output field names ["a"] -┌Evaluate weekday(a) as "y", -└Output field names ["y"] -┌Order by y, -└Output field names ["y"] - ----- 473 -SELECT yearDay(a) AS y FROM t ORDER BY y; -┌Iterate all rows of table "t" -└Output field names ["a"] -┌Evaluate yearDay(a) as "y", -└Output field names ["y"] -┌Order by y, -└Output field names ["y"] - ----- 474 -SELECT timeIn(a, ""), timeIn(a, "UTC") AS y FROM t ORDER BY y; -┌Iterate all rows of table "t" -└Output field names ["a"] -┌Evaluate timeIn(a, "") as "", timeIn(a, "UTC") as "y", -└Output field names ["" "y"] -┌Order by y, -└Output field names ["" "y"] - ----- 475 -SELECT formatTime(timeIn(a, "UTC"), "Jan 2, 2006 at 3:04pm (UTC)") AS y FROM t ORDER BY y; -┌Iterate all rows of table "t" -└Output field names ["a"] -┌Evaluate formatTime(timeIn(a, "UTC"), "Jan 2, 2006 at 3:04pm (UTC)") as "y", -└Output field names ["y"] -┌Order by y, -└Output field names ["y"] - ----- 478 -SELECT a, b, formatTime(timeIn(t, "UTC"), "2006-01-02 15:04:05.999999999 -0700") AS t FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "t"] -┌Evaluate a as "a", b as "b", formatTime(timeIn(t, "UTC"), "2006-01-02 15:04:05.999999999 -0700") as "t", -└Output field names ["a" "b" "t"] - ----- 479 -SELECT a, b, formatTime(timeIn(t, "UTC"), "2006-01-02 15:04:05.999999999 -0700") AS t FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "t"] -┌Evaluate a as "a", b as "b", formatTime(timeIn(t, "UTC"), "2006-01-02 15:04:05.999999999 -0700") as "t", -└Output field names ["a" "b" "t"] - ----- 480 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "d"] - ----- 481 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "d"] - ----- 482 -SELECT * FROM t ORDER BY real(c); -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Order by real(c), -└Output field names ["c"] - ----- 483 -SELECT id() AS i, contains(42, substr) FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["s" "substr"] -┌Evaluate id() as "i", contains(42, substr) as "", -└Output field names ["i" ""] -┌Order by i, -└Output field names ["i" ""] - ----- 484 -SELECT id() AS i, contains(s, true) FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["s" "substr"] -┌Evaluate id() as "i", contains(s, true) as "", -└Output field names ["i" ""] -┌Order by i, -└Output field names ["i" ""] - ----- 485 -SELECT id() AS i, contains(s, substr) FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["s" "substr"] -┌Evaluate id() as "i", contains(s, substr) as "", -└Output field names ["i" ""] -┌Order by i, -└Output field names ["i" ""] - ----- 486 -SELECT id() AS i, hasPrefix(42, prefix) FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["s" "prefix"] -┌Evaluate id() as "i", hasPrefix(42, prefix) as "", -└Output field names ["i" ""] -┌Order by i, -└Output field names ["i" ""] - ----- 487 -SELECT id() AS i, hasPrefix(s, false) FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["s" "prefix"] -┌Evaluate id() as "i", hasPrefix(s, false) as "", -└Output field names ["i" ""] -┌Order by i, -└Output field names ["i" ""] - ----- 488 -SELECT id() AS i, hasPrefix(s, prefix) FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["s" "prefix"] -┌Evaluate id() as "i", hasPrefix(s, prefix) as "", -└Output field names ["i" ""] -┌Order by i, -└Output field names ["i" ""] - ----- 489 -SELECT id() AS i, hasSuffix(42, suffix) FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["s" "suffix"] -┌Evaluate id() as "i", hasSuffix(42, suffix) as "", -└Output field names ["i" ""] -┌Order by i, -└Output field names ["i" ""] - ----- 490 -SELECT id() AS i, hasSuffix(s, true) FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["s" "suffix"] -┌Evaluate id() as "i", hasSuffix(s, true) as "", -└Output field names ["i" ""] -┌Order by i, -└Output field names ["i" ""] - ----- 491 -SELECT id() AS i, hasSuffix(s, suffix) FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["s" "suffix"] -┌Evaluate id() as "i", hasSuffix(s, suffix) as "", -└Output field names ["i" ""] -┌Order by i, -└Output field names ["i" ""] - ----- 493 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 495 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 496 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i" "s"] - ----- 497 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 498 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 499 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["s"] - ----- 500 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 501 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] - ----- 502 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c" "s"] - ----- 503 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c" "s"] - ----- 504 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c" "s"] - ----- 508 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] - ----- 509 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] - ----- 512 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] - ----- 513 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] - ----- 514 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] - ----- 515 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] - ----- 516 -SELECT * FROM t ORDER BY id(); -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Order by id(), -└Output field names ["c"] - ----- 517 -SELECT * FROM t ORDER BY c; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Order by c, -└Output field names ["c"] - ----- 518 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 526 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 528 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 529 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 530 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 531 -SELECT * FROM t ORDER BY s; -┌Iterate all rows of table "t" -└Output field names ["s"] -┌Order by s, -└Output field names ["s"] - ----- 532 -SELECT * FROM t ORDER BY s; -┌Iterate all rows of table "t" -└Output field names ["s"] -┌Order by s, -└Output field names ["s"] - ----- 533 -SELECT * FROM t ORDER BY s; -┌Iterate all rows of table "t" -└Output field names ["s"] -┌Order by s, -└Output field names ["s"] - ----- 534 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 535 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 536 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 537 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["s"] - ----- 538 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 539 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["s"] - ----- 540 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 541 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 542 -SELECT * FROM t ORDER BY s; -┌Iterate all rows of table "t" -└Output field names ["s"] -┌Order by s, -└Output field names ["s"] - ----- 543 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 545 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 546 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 547 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i" "s"] - ----- 548 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i" "s"] -┌Order by i, -└Output field names ["i" "s"] - ----- 549 -SELECT * FROM t ORDER BY s; -┌Iterate all rows of table "t" -└Output field names ["i" "s"] -┌Order by s, -└Output field names ["i" "s"] - ----- 550 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 551 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 552 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 553 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 554 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 555 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 556 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 557 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 558 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 559 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 560 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 561 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 562 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 563 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 564 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 565 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 566 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 569 -SELECT len(string(b)) AS n FROM t; -┌Iterate all rows of table "t" -└Output field names ["b"] -┌Evaluate len(string(b)) as "n", -└Output field names ["n"] - ----- 570 -SELECT len(string(b)) AS n FROM t; -┌Iterate all rows of table "t" -└Output field names ["b"] -┌Evaluate len(string(b)) as "n", -└Output field names ["n"] - ----- 571 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i" "s"] - ----- 572 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i" "s"] - ----- 574 -SELECT * FROM t AS u; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 577 -SELECT i FROM t AS u; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 578 -SELECT i FROM t WHERE b ORDER BY i; -┌Iterate all rows of table "t" using index "x" where b -└Output field names ["i" "b"] -┌Evaluate i as "i", -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 580 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 581 -SELECT i FROM t WHERE i < 30; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Filter on i < 30 -│Possibly useful indices -│CREATE INDEX xt_i ON t(i); -└Output field names ["i"] - ----- 582 -SELECT i FROM t WHERE i < 30; -┌Iterate all rows of table "t" using index "x" where i < 30 -└Output field names ["i"] - ----- 583 -SELECT * FROM t WHERE i <= 30; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Filter on i <= 30 -│Possibly useful indices -│CREATE INDEX xt_i ON t(i); -└Output field names ["i"] - ----- 584 -SELECT * FROM t WHERE i <= 30; -┌Iterate all rows of table "t" using index "x" where i <= 30 -└Output field names ["i"] - ----- 585 -SELECT i FROM t WHERE i == 30; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Filter on i == 30 -│Possibly useful indices -│CREATE INDEX xt_i ON t(i); -└Output field names ["i"] - ----- 586 -SELECT i FROM t WHERE i == 30; -┌Iterate all rows of table "t" using index "x" where i == 30 -└Output field names ["i"] - ----- 587 -SELECT * FROM t WHERE i >= 30; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Filter on i >= 30 -│Possibly useful indices -│CREATE INDEX xt_i ON t(i); -└Output field names ["i"] - ----- 588 -SELECT * FROM t WHERE i >= 30; -┌Iterate all rows of table "t" using index "x" where i >= 30 -└Output field names ["i"] - ----- 589 -SELECT * FROM t WHERE i > 30; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Filter on i > 30 -│Possibly useful indices -│CREATE INDEX xt_i ON t(i); -└Output field names ["i"] - ----- 590 -SELECT * FROM t WHERE i > 30; -┌Iterate all rows of table "t" using index "x" where i > 30 -└Output field names ["i"] - ----- 591 -SELECT i FROM t WHERE !b ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i" "b"] -┌Filter on !b -└Output field names ["i" "b"] -┌Evaluate i as "i", -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 592 -SELECT i FROM t WHERE !b ORDER BY i; -┌Iterate all rows of table "t" using index "x" where !b -└Output field names ["i" "b"] -┌Evaluate i as "i", -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 593 -SELECT i FROM t WHERE i < $1; -┌Iterate all rows of table "t" using index "x" where i < 30 -└Output field names ["i"] - ----- 594 -SELECT * FROM t WHERE i <= $1; -┌Iterate all rows of table "t" using index "x" where i <= 30 -└Output field names ["i"] - ----- 595 -SELECT i FROM t WHERE i == $1; -┌Iterate all rows of table "t" using index "x" where i == 30 -└Output field names ["i"] - ----- 596 -SELECT * FROM t WHERE i >= $1; -┌Iterate all rows of table "t" using index "x" where i >= 30 -└Output field names ["i"] - ----- 597 -SELECT * FROM t WHERE i > $1; -┌Iterate all rows of table "t" using index "x" where i > 30 -└Output field names ["i"] - ----- 598 -SELECT i FROM t WHERE i < $1; -┌Iterate all rows of table "t" using index "x" where i < 30 -└Output field names ["i"] - ----- 599 -SELECT * FROM t WHERE i <= $1; -┌Iterate all rows of table "t" using index "x" where i <= 30 -└Output field names ["i"] - ----- 600 -SELECT i FROM t WHERE i == $1; -┌Iterate all rows of table "t" using index "x" where i == 30 -└Output field names ["i"] - ----- 601 -SELECT * FROM t WHERE i >= $1; -┌Iterate all rows of table "t" using index "x" where i >= 30 -└Output field names ["i"] - ----- 602 -SELECT * FROM t WHERE i > $1; -┌Iterate all rows of table "t" using index "x" where i > 30 -└Output field names ["i"] - ----- 603 -SELECT i FROM t WHERE i < 30; -┌Iterate all rows of table "t" using index "x" where i < 30 -└Output field names ["i"] - ----- 604 -SELECT * FROM t WHERE i <= 30; -┌Iterate all rows of table "t" using index "x" where i <= 30 -└Output field names ["i"] - ----- 605 -SELECT i FROM t WHERE i == 30; -┌Iterate all rows of table "t" using index "x" where i == 30 -└Output field names ["i"] - ----- 606 -SELECT * FROM t WHERE i >= 30; -┌Iterate all rows of table "t" using index "x" where i >= 30 -└Output field names ["i"] - ----- 607 -SELECT * FROM t WHERE i > 30; -┌Iterate all rows of table "t" using index "x" where i > 30 -└Output field names ["i"] - ----- 608 -SELECT * FROM t WHERE i < 30; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Filter on i < 30 -│Possibly useful indices -│CREATE INDEX xt_i ON t(i); -└Output field names ["i"] - ----- 609 -SELECT * FROM t WHERE i < 30; -┌Iterate all rows of table "t" using index "x" where i < 30 -└Output field names ["i"] - ----- 624 -SELECT * FROM __Table; -┌Iterate all rows of table "__Table" -└Output field names ["Name" "Schema"] - ----- 625 -SELECT * FROM __Table ORDER BY Name; -┌Iterate all rows of table "__Table" -└Output field names ["Name" "Schema"] -┌Order by Name, -└Output field names ["Name" "Schema"] - ----- 626 -SELECT * FROM __Table ORDER BY Name; -┌Iterate all rows of table "__Table" -└Output field names ["Name" "Schema"] -┌Order by Name, -└Output field names ["Name" "Schema"] - ----- 627 -SELECT * FROM __Column; -┌Iterate all rows of table "__Column" -└Output field names ["TableName" "Ordinal" "Name" "Type"] - ----- 628 -SELECT * FROM __Column ORDER BY TableName, Name; -┌Iterate all rows of table "__Column" -└Output field names ["TableName" "Ordinal" "Name" "Type"] -┌Order by TableName, Name, -└Output field names ["TableName" "Ordinal" "Name" "Type"] - ----- 629 -SELECT * FROM __Column ORDER BY TableName, Ordinal; -┌Iterate all rows of table "__Column" -└Output field names ["TableName" "Ordinal" "Name" "Type"] -┌Order by TableName, Ordinal, -└Output field names ["TableName" "Ordinal" "Name" "Type"] - ----- 630 -SELECT * FROM __Index; -┌Iterate all rows of table "__Index" -└Output field names ["TableName" "ColumnName" "Name" "IsUnique"] - ----- 631 -SELECT * FROM __Index ORDER BY TableName, Name; -┌Iterate all rows of table "__Index" -└Output field names ["TableName" "ColumnName" "Name" "IsUnique"] -┌Order by TableName, Name, -└Output field names ["TableName" "ColumnName" "Name" "IsUnique"] - ----- 632 -SELECT * FROM __Index WHERE !hasPrefix(TableName, "__") ORDER BY TableName, ColumnName, Name; -┌Iterate all rows of table "__Index" -└Output field names ["TableName" "ColumnName" "Name" "IsUnique"] -┌Filter on !hasPrefix(TableName, "__") -└Output field names ["TableName" "ColumnName" "Name" "IsUnique"] -┌Order by TableName, ColumnName, Name, -└Output field names ["TableName" "ColumnName" "Name" "IsUnique"] - ----- 633 -SELECT * FROM __Index WHERE !hasPrefix(TableName, "__") ORDER BY TableName, ColumnName, Name; -┌Iterate all rows of table "__Index" -└Output field names ["TableName" "ColumnName" "Name" "IsUnique"] -┌Filter on !hasPrefix(TableName, "__") -└Output field names ["TableName" "ColumnName" "Name" "IsUnique"] -┌Order by TableName, ColumnName, Name, -└Output field names ["TableName" "ColumnName" "Name" "IsUnique"] - ----- 634 -SELECT * FROM __Index WHERE !hasPrefix(TableName, "__") ORDER BY TableName, ColumnName, Name; -┌Iterate all rows of table "__Index" -└Output field names ["TableName" "ColumnName" "Name" "IsUnique"] -┌Filter on !hasPrefix(TableName, "__") -└Output field names ["TableName" "ColumnName" "Name" "IsUnique"] -┌Order by TableName, ColumnName, Name, -└Output field names ["TableName" "ColumnName" "Name" "IsUnique"] - ----- 635 -SELECT c.TableName, c.Ordinal, c.Name FROM __Table AS t, __Column AS c WHERE t.Name == "u" && t.Name == c.TableName ORDER BY c.Ordinal; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "__Table" -│ └Output field names ["Name" "Schema"] -│ ┌Iterate all rows of table "__Column" -│ └Output field names ["TableName" "Ordinal" "Name" "Type"] -└Output field names ["t.Name" "t.Schema" "c.TableName" "c.Ordinal" "c.Name" "c.Type"] -┌Filter on t.Name == "u" && t.Name == c.TableName -└Output field names ["t.Name" "t.Schema" "c.TableName" "c.Ordinal" "c.Name" "c.Type"] -┌Evaluate c.TableName as "c.TableName", c.Ordinal as "c.Ordinal", c.Name as "c.Name", -└Output field names ["c.TableName" "c.Ordinal" "c.Name"] -┌Order by c.Ordinal, -└Output field names ["c.TableName" "c.Ordinal" "c.Name"] - ----- 636 -SELECT * FROM t WHERE s == "test"; -┌Iterate all rows of table "t" -└Output field names ["i" "s"] -┌Filter on s == "test" -│Possibly useful indices -│CREATE INDEX xt_s ON t(s); -└Output field names ["i" "s"] - ----- 637 -SELECT * FROM t WHERE s == "test"; -┌Iterate all rows of table "t" using index "idx_s" where s == "test" -└Output field names ["i" "s"] - ----- 638 -SELECT * FROM __Table ORDER BY Name; -┌Iterate all rows of table "__Table" -└Output field names ["Name" "Schema"] -┌Order by Name, -└Output field names ["Name" "Schema"] - ----- 639 -SELECT * FROM __Table WHERE Name == "artist"; -┌Iterate all rows of table "__Table" -└Output field names ["Name" "Schema"] -┌Filter on Name == "artist" -└Output field names ["Name" "Schema"] - ----- 640 -SELECT * FROM __Column ORDER BY TableName, Ordinal; -┌Iterate all rows of table "__Column" -└Output field names ["TableName" "Ordinal" "Name" "Type"] -┌Order by TableName, Ordinal, -└Output field names ["TableName" "Ordinal" "Name" "Type"] - ----- 641 -SELECT * FROM __Column WHERE TableName == "artist" ORDER BY TableName, Ordinal; -┌Iterate all rows of table "__Column" -└Output field names ["TableName" "Ordinal" "Name" "Type"] -┌Filter on TableName == "artist" -└Output field names ["TableName" "Ordinal" "Name" "Type"] -┌Order by TableName, Ordinal, -└Output field names ["TableName" "Ordinal" "Name" "Type"] - ----- 642 -SELECT * FROM t, u WHERE u.y < 60 && t.k < 7; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "t" -│ └Output field names ["i" "j" "k"] -│ ┌Iterate all rows of table "u" -│ └Output field names ["x" "y" "z"] -└Output field names ["t.i" "t.j" "t.k" "u.x" "u.y" "u.z"] -┌Filter on u.y < 60 && t.k < 7 -│Possibly useful indices -│CREATE INDEX xu_y ON u(y); -│CREATE INDEX xt_k ON t(k); -└Output field names ["t.i" "t.j" "t.k" "u.x" "u.y" "u.z"] - ----- 643 -SELECT * FROM t, u WHERE u.y < 60 && t.k < 7; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "t" using index "xk" where k < 7 -│ └Output field names ["i" "j" "k"] -│ ┌Iterate all rows of table "u" -│ └Output field names ["x" "y" "z"] -└Output field names ["t.i" "t.j" "t.k" "u.x" "u.y" "u.z"] -┌Filter on u.y < 60 -│Possibly useful indices -│CREATE INDEX xu_y ON u(y); -└Output field names ["t.i" "t.j" "t.k" "u.x" "u.y" "u.z"] - ----- 644 -SELECT * FROM t, u WHERE u.y < 60 && t.k < 7; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "t" -│ └Output field names ["i" "j" "k"] -│ ┌Iterate all rows of table "u" using index "xy" where y < 60 -│ └Output field names ["x" "y" "z"] -└Output field names ["t.i" "t.j" "t.k" "u.x" "u.y" "u.z"] -┌Filter on t.k < 7 -│Possibly useful indices -│CREATE INDEX xt_k ON t(k); -└Output field names ["t.i" "t.j" "t.k" "u.x" "u.y" "u.z"] - ----- 645 -SELECT * FROM t, u WHERE u.y < 60 && t.k < 7; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "t" using index "xk" where k < 7 -│ └Output field names ["i" "j" "k"] -│ ┌Iterate all rows of table "u" using index "xy" where y < 60 -│ └Output field names ["x" "y" "z"] -└Output field names ["t.i" "t.j" "t.k" "u.x" "u.y" "u.z"] - ----- 646 -SELECT * FROM t OFFSET -1; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Skip first -1 records -└Output field names ["i"] - ----- 647 -SELECT * FROM t OFFSET 0; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Skip first 0 records -└Output field names ["i"] - ----- 648 -SELECT * FROM t OFFSET 1; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Skip first 1 records -└Output field names ["i"] - ----- 649 -SELECT * FROM t ORDER BY id() OFFSET -1; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Skip first -1 records -└Output field names ["i"] - ----- 650 -SELECT * FROM t ORDER BY id() OFFSET 0; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Skip first 0 records -└Output field names ["i"] - ----- 651 -SELECT * FROM t ORDER BY id() OFFSET 1; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Skip first 1 records -└Output field names ["i"] - ----- 652 -SELECT * FROM t ORDER BY id() OFFSET 2; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Skip first 2 records -└Output field names ["i"] - ----- 653 -SELECT * FROM t ORDER BY id() LIMIT -1; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Pass first -1 records -└Output field names [i] - ----- 654 -SELECT * FROM t ORDER BY id() LIMIT 0; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Pass first 0 records -└Output field names [i] - ----- 655 -SELECT * FROM t ORDER BY id() LIMIT 1; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Pass first 1 records -└Output field names [i] - ----- 656 -SELECT * FROM t ORDER BY id() LIMIT -1; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Pass first -1 records -└Output field names [i] - ----- 657 -SELECT * FROM t ORDER BY id() LIMIT 0; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Pass first 0 records -└Output field names [i] - ----- 658 -SELECT * FROM t ORDER BY id() LIMIT 1; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Pass first 1 records -└Output field names [i] - ----- 659 -SELECT * FROM t ORDER BY id() LIMIT 2; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Pass first 2 records -└Output field names [i] - ----- 660 -SELECT * FROM t ORDER BY id() LIMIT 3; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Pass first 3 records -└Output field names [i] - ----- 661 -SELECT * FROM t ORDER BY id() LIMIT 0 OFFSET 0; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Skip first 0 records -└Output field names ["i"] -┌Pass first 0 records -└Output field names [i] - ----- 662 -SELECT * FROM t ORDER BY id() LIMIT 0 OFFSET 1; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Skip first 1 records -└Output field names ["i"] -┌Pass first 0 records -└Output field names [i] - ----- 663 -SELECT * FROM t ORDER BY id() LIMIT 0 OFFSET 2; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Skip first 2 records -└Output field names ["i"] -┌Pass first 0 records -└Output field names [i] - ----- 664 -SELECT * FROM t ORDER BY id() LIMIT 0 OFFSET 3; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Skip first 3 records -└Output field names ["i"] -┌Pass first 0 records -└Output field names [i] - ----- 665 -SELECT * FROM t ORDER BY id() LIMIT 1 OFFSET 0; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Skip first 0 records -└Output field names ["i"] -┌Pass first 1 records -└Output field names [i] - ----- 666 -SELECT * FROM t ORDER BY id() LIMIT 1 OFFSET 1; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Skip first 1 records -└Output field names ["i"] -┌Pass first 1 records -└Output field names [i] - ----- 667 -SELECT * FROM t ORDER BY id() LIMIT 1 OFFSET 2; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Skip first 2 records -└Output field names ["i"] -┌Pass first 1 records -└Output field names [i] - ----- 668 -SELECT * FROM t ORDER BY id() LIMIT 1 OFFSET 3; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Skip first 3 records -└Output field names ["i"] -┌Pass first 1 records -└Output field names [i] - ----- 669 -SELECT * FROM t ORDER BY id() LIMIT 2 OFFSET 0; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Skip first 0 records -└Output field names ["i"] -┌Pass first 2 records -└Output field names [i] - ----- 670 -SELECT * FROM t ORDER BY id() LIMIT 2 OFFSET 1; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Skip first 1 records -└Output field names ["i"] -┌Pass first 2 records -└Output field names [i] - ----- 671 -SELECT * FROM t ORDER BY id() LIMIT 2 OFFSET 2; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Skip first 2 records -└Output field names ["i"] -┌Pass first 2 records -└Output field names [i] - ----- 672 -SELECT * FROM t ORDER BY id() LIMIT 2 OFFSET 3; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Skip first 3 records -└Output field names ["i"] -┌Pass first 2 records -└Output field names [i] - ----- 673 -SELECT * FROM t ORDER BY id() LIMIT 3 OFFSET 0; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Skip first 0 records -└Output field names ["i"] -┌Pass first 3 records -└Output field names [i] - ----- 674 -SELECT * FROM t ORDER BY id() LIMIT 3 OFFSET 1; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Skip first 1 records -└Output field names ["i"] -┌Pass first 3 records -└Output field names [i] - ----- 675 -SELECT * FROM t ORDER BY id() LIMIT 3 OFFSET 2; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Skip first 2 records -└Output field names ["i"] -┌Pass first 3 records -└Output field names [i] - ----- 676 -SELECT * FROM t ORDER BY id() LIMIT 3 OFFSET 3; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] -┌Skip first 3 records -└Output field names ["i"] -┌Pass first 3 records -└Output field names [i] - ----- 677 -SELECT * FROM (SELECT * FROM t ORDER BY i LIMIT 2 OFFSET 1;) AS a, (SELECT * FROM u ORDER BY i;) AS b ORDER BY a.i, b.i; -┌Compute Cartesian product of -│ ┌Iterate all rows of virtual table "a" -│ │ ┌Iterate all rows of table "t" -│ │ └Output field names ["i"] -│ │ ┌Order by i, -│ │ └Output field names ["i"] -│ │ ┌Skip first 1 records -│ │ └Output field names ["i"] -│ │ ┌Pass first 2 records -│ │ └Output field names [i] -│ └Output field names ["i"] -│ ┌Iterate all rows of virtual table "b" -│ │ ┌Iterate all rows of table "u" -│ │ └Output field names ["i"] -│ │ ┌Order by i, -│ │ └Output field names ["i"] -│ └Output field names ["i"] -└Output field names ["a.i" "b.i"] -┌Order by a.i, b.i, -└Output field names ["a.i" "b.i"] - ----- 678 -SELECT * FROM (SELECT * FROM t ORDER BY i LIMIT 2 OFFSET 1;) AS a, (SELECT * FROM u ORDER BY i OFFSET 1;) AS b ORDER BY a.i, b.i; -┌Compute Cartesian product of -│ ┌Iterate all rows of virtual table "a" -│ │ ┌Iterate all rows of table "t" -│ │ └Output field names ["i"] -│ │ ┌Order by i, -│ │ └Output field names ["i"] -│ │ ┌Skip first 1 records -│ │ └Output field names ["i"] -│ │ ┌Pass first 2 records -│ │ └Output field names [i] -│ └Output field names ["i"] -│ ┌Iterate all rows of virtual table "b" -│ │ ┌Iterate all rows of table "u" -│ │ └Output field names ["i"] -│ │ ┌Order by i, -│ │ └Output field names ["i"] -│ │ ┌Skip first 1 records -│ │ └Output field names ["i"] -│ └Output field names ["i"] -└Output field names ["a.i" "b.i"] -┌Order by a.i, b.i, -└Output field names ["a.i" "b.i"] - ----- 679 -SELECT * FROM (SELECT * FROM t ORDER BY i LIMIT 2 OFFSET 1;) AS a, (SELECT * FROM u ORDER BY i LIMIT 1;) AS b ORDER BY a.i, b.i; -┌Compute Cartesian product of -│ ┌Iterate all rows of virtual table "a" -│ │ ┌Iterate all rows of table "t" -│ │ └Output field names ["i"] -│ │ ┌Order by i, -│ │ └Output field names ["i"] -│ │ ┌Skip first 1 records -│ │ └Output field names ["i"] -│ │ ┌Pass first 2 records -│ │ └Output field names [i] -│ └Output field names ["i"] -│ ┌Iterate all rows of virtual table "b" -│ │ ┌Iterate all rows of table "u" -│ │ └Output field names ["i"] -│ │ ┌Order by i, -│ │ └Output field names ["i"] -│ │ ┌Pass first 1 records -│ │ └Output field names [i] -│ └Output field names ["i"] -└Output field names ["a.i" "b.i"] -┌Order by a.i, b.i, -└Output field names ["a.i" "b.i"] - ----- 680 -SELECT * FROM (SELECT * FROM t ORDER BY i LIMIT 2 OFFSET 1;) AS a, (SELECT * FROM u ORDER BY i LIMIT 1 OFFSET 1;) AS b ORDER BY a.i, b.i; -┌Compute Cartesian product of -│ ┌Iterate all rows of virtual table "a" -│ │ ┌Iterate all rows of table "t" -│ │ └Output field names ["i"] -│ │ ┌Order by i, -│ │ └Output field names ["i"] -│ │ ┌Skip first 1 records -│ │ └Output field names ["i"] -│ │ ┌Pass first 2 records -│ │ └Output field names [i] -│ └Output field names ["i"] -│ ┌Iterate all rows of virtual table "b" -│ │ ┌Iterate all rows of table "u" -│ │ └Output field names ["i"] -│ │ ┌Order by i, -│ │ └Output field names ["i"] -│ │ ┌Skip first 1 records -│ │ └Output field names ["i"] -│ │ ┌Pass first 1 records -│ │ └Output field names [i] -│ └Output field names ["i"] -└Output field names ["a.i" "b.i"] -┌Order by a.i, b.i, -└Output field names ["a.i" "b.i"] - ----- 681 -SELECT * FROM (SELECT * FROM t ORDER BY i LIMIT 2 OFFSET 1;) AS a, (SELECT * FROM u ORDER BY i LIMIT 1 OFFSET 1;) AS b ORDER BY a.i, b.i LIMIT 1; -┌Compute Cartesian product of -│ ┌Iterate all rows of virtual table "a" -│ │ ┌Iterate all rows of table "t" -│ │ └Output field names ["i"] -│ │ ┌Order by i, -│ │ └Output field names ["i"] -│ │ ┌Skip first 1 records -│ │ └Output field names ["i"] -│ │ ┌Pass first 2 records -│ │ └Output field names [i] -│ └Output field names ["i"] -│ ┌Iterate all rows of virtual table "b" -│ │ ┌Iterate all rows of table "u" -│ │ └Output field names ["i"] -│ │ ┌Order by i, -│ │ └Output field names ["i"] -│ │ ┌Skip first 1 records -│ │ └Output field names ["i"] -│ │ ┌Pass first 1 records -│ │ └Output field names [i] -│ └Output field names ["i"] -└Output field names ["a.i" "b.i"] -┌Order by a.i, b.i, -└Output field names ["a.i" "b.i"] -┌Pass first 1 records -└Output field names [a.i b.i] - ----- 682 -SELECT count(1) AS total FROM fibonacci WHERE input >= 5 && input <= 7 || input == 3; -┌Iterate all rows of table "fibonacci" -└Output field names ["input" "output"] -┌Filter on input >= 5 && input <= 7 || input == 3 -└Output field names ["input" "output"] -┌Group by distinct rows -└Output field names ["input" "output"] -┌Evaluate count(1) as "total", -└Output field names ["total"] - ----- 683 -SELECT * FROM fibonacci WHERE input >= 5 && input <= 7 || input == 3 ORDER BY input DESC LIMIT 2 OFFSET 1; -┌Iterate all rows of table "fibonacci" -└Output field names ["input" "output"] -┌Filter on input >= 5 && input <= 7 || input == 3 -└Output field names ["input" "output"] -┌Order descending by input, -└Output field names ["input" "output"] -┌Skip first 1 records -└Output field names ["input" "output"] -┌Pass first 2 records -└Output field names [input output] - ----- 684 -SELECT * FROM fibonacci ORDER BY input; -┌Iterate all rows of table "fibonacci" -└Output field names ["input" "output"] -┌Order by input, -└Output field names ["input" "output"] - ----- 685 -SELECT * FROM fibonacci ORDER BY input; -┌Iterate all rows of table "fibonacci" -└Output field names ["input" "output"] -┌Order by input, -└Output field names ["input" "output"] - ----- 686 -SELECT count() AS total FROM fibonacci WHERE input >= 5 && input <= 7 || input == 3; -┌Iterate all rows of table "fibonacci" -└Output field names ["input" "output"] -┌Filter on input >= 5 && input <= 7 || input == 3 -└Output field names ["input" "output"] -┌Group by distinct rows -└Output field names ["input" "output"] -┌Evaluate count() as "total", -└Output field names ["total"] - ----- 687 -SELECT count() AS total FROM fibonacci WHERE input >= 5 && input <= 7 || input == 3; -┌Iterate all rows of table "fibonacci" -└Output field names ["input" "output"] -┌Filter on input >= 5 && input <= 7 || input == 3 -└Output field names ["input" "output"] -┌Group by distinct rows -└Output field names ["input" "output"] -┌Evaluate count() as "total", -└Output field names ["total"] - ----- 688 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 689 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 690 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 691 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 692 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 693 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 694 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 695 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 696 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 697 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 698 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 699 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 700 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 701 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 702 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 703 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 704 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 705 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 706 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 707 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 708 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 709 -SELECT * FROM t ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 711 -SELECT s FROM t; -┌Iterate all rows of table "t" -└Output field names ["i" "s"] -┌Evaluate s as "s", -└Output field names ["s"] - ----- 712 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 714 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 715 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 716 -SELECT s FROM t WHERE s != "z"; -┌Iterate all rows of table "t" using index "x" where s != "z" -└Output field names ["i" "s"] -┌Evaluate s as "s", -└Output field names ["s"] - ----- 717 -SELECT s FROM t WHERE s < "z"; -┌Iterate all rows of table "t" using index "x" where s < "z" -└Output field names ["i" "s"] -┌Evaluate s as "s", -└Output field names ["s"] - ----- 718 -SELECT s FROM t WHERE s < "z"; -┌Iterate all rows of table "t" -└Output field names ["i" "s"] -┌Filter on s < "z" -│Possibly useful indices -│CREATE INDEX xt_s ON t(s); -└Output field names ["i" "s"] -┌Evaluate s as "s", -└Output field names ["s"] - ----- 721 -SELECT s FROM t WHERE s < "z"; -┌Iterate all rows of table "t" -└Output field names ["i" "s"] -┌Filter on s < "z" -│Possibly useful indices -│CREATE INDEX xt_s ON t(s); -└Output field names ["i" "s"] -┌Evaluate s as "s", -└Output field names ["s"] - ----- 722 -SELECT p, string(c) FROM t; -┌Iterate all rows of table "t" -└Output field names ["p" "c"] -┌Evaluate p as "p", string(c) as "", -└Output field names ["p" ""] - ----- 723 -SELECT p, string(c) FROM t; -┌Iterate all rows of table "t" -└Output field names ["p" "c"] -┌Evaluate p as "p", string(c) as "", -└Output field names ["p" ""] - ----- 724 -SELECT p, string(c) FROM t; -┌Iterate all rows of table "t" -└Output field names ["p" "c"] -┌Evaluate p as "p", string(c) as "", -└Output field names ["p" ""] - ----- 725 -SELECT * FROM employee; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] - ----- 726 -SELECT * FROM employee; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] - ----- 727 -SELECT * FROM employee ORDER BY LastName; -┌Iterate all rows of table "employee" -└Output field names ["LastName" "DepartmentID"] -┌Order by LastName, -└Output field names ["LastName" "DepartmentID"] - ----- 728 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["username" "departname" "created" "detail_id" "height" "avatar" "is_man"] - ----- 729 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["username" "departname" "created" "detail_id" "height" "avatar" "is_man"] - ----- 730 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["username" "departname" "created" "detail_id" "height" "avatar" "is_man"] - ----- 731 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["username" "departname" "created" "detail_id" "height" "avatar" "is_man"] - ----- 732 -SELECT id() IN (SELECT id() FROM t WHERE username == "2xiaolunwen";), username == "2xiaolunwen", len(string(avatar)) == 2097152 FROM t; -┌Iterate all rows of table "t" -└Output field names ["username" "departname" "created" "detail_id" "height" "avatar" "is_man"] -┌Evaluate id() IN (SELECT id() FROM t WHERE username == "2xiaolunwen";) as "", username == "2xiaolunwen" as "", len(string(avatar)) == 2097152 as "", -└Output field names ["" "" ""] - ----- 733 -SELECT id() IN (SELECT id() FROM t WHERE username == "xiaolunwen";), username == "xiaolunwen", len(string(avatar)) == 1048576 FROM t; -┌Iterate all rows of table "t" -└Output field names ["username" "departname" "created" "detail_id" "height" "avatar" "is_man"] -┌Evaluate id() IN (SELECT id() FROM t WHERE username == "xiaolunwen";) as "", username == "xiaolunwen" as "", len(string(avatar)) == 1048576 as "", -└Output field names ["" "" ""] - ----- 734 -SELECT user, remain, total FROM no_id_user WHERE user == "xlw" LIMIT 1; -┌Iterate all rows of table "no_id_user" using index "UQE_no_id_user_user" where user == "xlw" -└Output field names ["user" "remain" "total"] -┌Pass first 1 records -└Output field names [user remain total] - ----- 735 -SELECT * FROM t WHERE id() < 4; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Filter on id() < 4 -│Possibly useful indices -│CREATE INDEX xt_id ON t(id()); -└Output field names ["i"] - ----- 736 -SELECT * FROM t WHERE i < 4; -┌Iterate all rows of table "t" using index "x" where i < 4 -└Output field names ["i"] - ----- 737 -SELECT * FROM t WHERE i <= 4; -┌Iterate all rows of table "t" using index "x" where i <= 4 -└Output field names ["i"] - ----- 738 -SELECT * FROM t WHERE i == 4; -┌Iterate all rows of table "t" using index "x" where i == 4 -└Output field names ["i"] - ----- 739 -SELECT * FROM t WHERE i >= 4; -┌Iterate all rows of table "t" using index "x" where i >= 4 -└Output field names ["i"] - ----- 740 -SELECT * FROM t WHERE i > 4; -┌Iterate all rows of table "t" using index "x" where i > 4 -└Output field names ["i"] - ----- 741 -SELECT * FROM (SELECT i FROM t WHERE i < 4;) AS t, (SELECT * FROM u WHERE i < 40;) AS u; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "t" using index "x" where i < 4 -│ └Output field names ["i"] -│ ┌Iterate all rows of table "u" using index "y" where i < 40 -│ └Output field names ["i"] -└Output field names ["t.i" "u.i"] - ----- 742 -SELECT max(t) AS T FROM t; -┌Iterate all rows of table "t" -└Output field names ["t"] -┌Group by distinct rows -└Output field names ["t"] -┌Evaluate max(t) as "T", -└Output field names ["T"] - ----- 743 -SELECT max(t) AS T FROM t; -┌Iterate all rows of table "t" -└Output field names ["t"] -┌Group by distinct rows -└Output field names ["t"] -┌Evaluate max(t) as "T", -└Output field names ["T"] - ----- 744 -SELECT max(t) AS T FROM t; -┌Iterate all rows of table "t" -└Output field names ["t"] -┌Group by distinct rows -└Output field names ["t"] -┌Evaluate max(t) as "T", -└Output field names ["T"] - ----- 745 -SELECT max(t) AS T FROM t; -┌Iterate all rows of table "t" -└Output field names ["t"] -┌Group by distinct rows -└Output field names ["t"] -┌Evaluate max(t) as "T", -└Output field names ["T"] - ----- 746 -SELECT max(t) AS T FROM t; -┌Iterate all rows of table "t" -└Output field names ["t"] -┌Group by distinct rows -└Output field names ["t"] -┌Evaluate max(t) as "T", -└Output field names ["T"] - ----- 747 -SELECT max(t) AS T FROM t; -┌Iterate all rows of table "t" -└Output field names ["t"] -┌Group by distinct rows -└Output field names ["t"] -┌Evaluate max(t) as "T", -└Output field names ["T"] - ----- 748 -SELECT min(t) AS T FROM t; -┌Iterate all rows of table "t" -└Output field names ["t"] -┌Group by distinct rows -└Output field names ["t"] -┌Evaluate min(t) as "T", -└Output field names ["T"] - ----- 749 -SELECT min(t) AS T FROM t; -┌Iterate all rows of table "t" -└Output field names ["t"] -┌Group by distinct rows -└Output field names ["t"] -┌Evaluate min(t) as "T", -└Output field names ["T"] - ----- 750 -SELECT min(t) AS T FROM t; -┌Iterate all rows of table "t" -└Output field names ["t"] -┌Group by distinct rows -└Output field names ["t"] -┌Evaluate min(t) as "T", -└Output field names ["T"] - ----- 751 -SELECT min(t) AS T FROM t; -┌Iterate all rows of table "t" -└Output field names ["t"] -┌Group by distinct rows -└Output field names ["t"] -┌Evaluate min(t) as "T", -└Output field names ["T"] - ----- 752 -SELECT min(t) AS T FROM t; -┌Iterate all rows of table "t" -└Output field names ["t"] -┌Group by distinct rows -└Output field names ["t"] -┌Evaluate min(t) as "T", -└Output field names ["T"] - ----- 753 -SELECT min(t) AS T FROM t; -┌Iterate all rows of table "t" -└Output field names ["t"] -┌Group by distinct rows -└Output field names ["t"] -┌Evaluate min(t) as "T", -└Output field names ["T"] - ----- 754 -SELECT * FROM department; -┌Iterate all rows of table "department" -└Output field names ["Name" "score"] - -SELECT * FROM department; -┌Iterate all rows of table "department" -└Output field names ["Name" "score"] - -SELECT * FROM department ORDER BY Name; -┌Iterate all rows of table "department" -└Output field names ["Name" "score"] -┌Order by Name, -└Output field names ["Name" "score"] - ----- 755 -SELECT id(), s FROM t WHERE s LIKE "foo" ORDER BY id(); -┌Iterate all rows of table "t" -└Output field names ["s"] -┌Filter on s LIKE "foo" -└Output field names ["s"] -┌Evaluate id() as "", s as "s", -└Output field names ["" "s"] -┌Order by id(), -└Output field names ["" "s"] - ----- 756 -SELECT id(), s FROM t WHERE !s LIKE "foo" ORDER BY id(); -┌Iterate all rows of table "t" -└Output field names ["s"] -┌Filter on !s LIKE "foo" -└Output field names ["s"] -┌Evaluate id() as "", s as "s", -└Output field names ["" "s"] -┌Order by id(), -└Output field names ["" "s"] - ----- 757 -SELECT id(), s FROM t WHERE s LIKE "foo" IS NULL ORDER BY id(); -┌Iterate all rows of table "t" -└Output field names ["s"] -┌Filter on s LIKE "foo" IS NULL -└Output field names ["s"] -┌Evaluate id() as "", s as "s", -└Output field names ["" "s"] -┌Order by id(), -└Output field names ["" "s"] - ----- 758 -SELECT id(), s FROM t WHERE s LIKE "foo" IS NOT NULL ORDER BY id(); -┌Iterate all rows of table "t" -└Output field names ["s"] -┌Filter on s LIKE "foo" IS NOT NULL -└Output field names ["s"] -┌Evaluate id() as "", s as "s", -└Output field names ["" "s"] -┌Order by id(), -└Output field names ["" "s"] - ----- 759 -SELECT id(), s FROM t WHERE s LIKE "bar" ORDER BY id(); -┌Iterate all rows of table "t" -└Output field names ["s"] -┌Filter on s LIKE "bar" -└Output field names ["s"] -┌Evaluate id() as "", s as "s", -└Output field names ["" "s"] -┌Order by id(), -└Output field names ["" "s"] - ----- 760 -SELECT id(), s FROM t WHERE s LIKE "^bar" ORDER BY id(); -┌Iterate all rows of table "t" -└Output field names ["s"] -┌Filter on s LIKE "^bar" -└Output field names ["s"] -┌Evaluate id() as "", s as "s", -└Output field names ["" "s"] -┌Order by id(), -└Output field names ["" "s"] - ----- 761 -SELECT id(), s FROM t WHERE s LIKE "bar$" ORDER BY id(); -┌Iterate all rows of table "t" -└Output field names ["s"] -┌Filter on s LIKE "bar$" -└Output field names ["s"] -┌Evaluate id() as "", s as "s", -└Output field names ["" "s"] -┌Order by id(), -└Output field names ["" "s"] - ----- 762 -SELECT id(), s FROM t WHERE s LIKE "bar$" ORDER BY id(); -┌Iterate all rows of table "t" -└Output field names ["s"] -┌Filter on s LIKE "bar$" -└Output field names ["s"] -┌Evaluate id() as "", s as "s", -└Output field names ["" "s"] -┌Order by id(), -└Output field names ["" "s"] - ----- 763 -SELECT id(), s FROM t WHERE s + "qux" LIKE "qux$" ORDER BY id(); -┌Iterate all rows of table "t" -└Output field names ["s"] -┌Filter on s + "qux" LIKE "qux$" -└Output field names ["s"] -┌Evaluate id() as "", s as "s", -└Output field names ["" "s"] -┌Order by id(), -└Output field names ["" "s"] - ----- 764 -SELECT id(), s FROM t WHERE s + "quxx" LIKE "qux$" ORDER BY id(); -┌Iterate all rows of table "t" -└Output field names ["s"] -┌Filter on s + "quxx" LIKE "qux$" -└Output field names ["s"] -┌Evaluate id() as "", s as "s", -└Output field names ["" "s"] -┌Order by id(), -└Output field names ["" "s"] - ----- 765 -SELECT * FROM (SELECT id() AS ID, i FROM foo;) AS foo, bar WHERE bar.fooID == foo.ID ORDER BY foo.ID; -┌Compute Cartesian product of -│ ┌Iterate all rows of virtual table "foo" -│ │ ┌Iterate all rows of table "foo" -│ │ └Output field names ["i"] -│ │ ┌Evaluate id() as "ID", i as "i", -│ │ └Output field names ["ID" "i"] -│ └Output field names ["ID" "i"] -│ ┌Iterate all rows of table "bar" -│ └Output field names ["fooID" "s"] -└Output field names ["foo.ID" "foo.i" "bar.fooID" "bar.s"] -┌Filter on bar.fooID == foo.ID -└Output field names ["foo.ID" "foo.i" "bar.fooID" "bar.s"] -┌Order by foo.ID, -└Output field names ["foo.ID" "foo.i" "bar.fooID" "bar.s"] - ----- 766 -SELECT * FROM foo, bar WHERE bar.fooID == id(foo) ORDER BY id(foo); -┌Compute Cartesian product of -│ ┌Iterate all rows of table "foo" -│ └Output field names ["i"] -│ ┌Iterate all rows of table "bar" -│ └Output field names ["fooID" "s"] -└Output field names ["foo.i" "bar.fooID" "bar.s"] -┌Filter on bar.fooID == id(foo) -└Output field names ["foo.i" "bar.fooID" "bar.s"] -┌Order by id(foo), -└Output field names ["foo.i" "bar.fooID" "bar.s"] - ----- 767 -SELECT * FROM t WHERE name == "b" && mail == "bar@example.com"; -┌Iterate all rows of table "t" -└Output field names ["name" "mail"] -┌Filter on name == "b" && mail == "bar@example.com" -│Possibly useful indices -│CREATE INDEX xt_name ON t(name); -│CREATE INDEX xt_mail ON t(mail); -└Output field names ["name" "mail"] - ----- 768 -SELECT * FROM t WHERE name == "b" && mail == "bar@example.com"; -┌Iterate all rows of table "t" -└Output field names ["name" "mail"] -┌Filter on name == "b" && mail == "bar@example.com" -│Possibly useful indices -│CREATE INDEX xt_name ON t(name); -│CREATE INDEX xt_mail ON t(mail); -└Output field names ["name" "mail"] - ----- 769 -SELECT * FROM t WHERE name == "b" || mail == "bar@example.com" ORDER BY name; -┌Iterate all rows of table "t" -└Output field names ["name" "mail"] -┌Filter on name == "b" || mail == "bar@example.com" -└Output field names ["name" "mail"] -┌Order by name, -└Output field names ["name" "mail"] - ----- 770 -SELECT * FROM t WHERE name == "b" || mail == "bar@example.com" ORDER BY name; -┌Iterate all rows of table "t" -└Output field names ["name" "mail"] -┌Filter on name == "b" || mail == "bar@example.com" -└Output field names ["name" "mail"] -┌Order by name, -└Output field names ["name" "mail"] - ----- 771 -SELECT id(), i FROM tableA WHERE id() IN (SELECT idA FROM tableB;) ORDER BY id(); -┌Iterate all rows of table "tableA" -└Output field names ["i"] -┌Filter on id() IN (SELECT idA FROM tableB;) -└Output field names ["i"] -┌Evaluate id() as "", i as "i", -└Output field names ["" "i"] -┌Order by id(), -└Output field names ["" "i"] - ----- 772 -SELECT id(), i FROM tableA WHERE id() NOT IN (SELECT idA FROM tableB;) ORDER BY id(); -┌Iterate all rows of table "tableA" -└Output field names ["i"] -┌Filter on id() NOT IN (SELECT idA FROM tableB;) -└Output field names ["i"] -┌Evaluate id() as "", i as "i", -└Output field names ["" "i"] -┌Order by id(), -└Output field names ["" "i"] - ----- 773 -SELECT id(), i FROM tableA ORDER BY id(); -┌Iterate all rows of table "tableA" -└Output field names ["i"] -┌Evaluate id() as "", i as "i", -└Output field names ["" "i"] -┌Order by id(), -└Output field names ["" "i"] - ----- 774 -SELECT id(), i FROM tableA ORDER BY id(); -┌Iterate all rows of table "tableA" -└Output field names ["i"] -┌Evaluate id() as "", i as "i", -└Output field names ["" "i"] -┌Order by id(), -└Output field names ["" "i"] - ----- 775 -SELECT id(), i FROM tableA ORDER BY id(); -┌Iterate all rows of table "tableA" -└Output field names ["i"] -┌Evaluate id() as "", i as "i", -└Output field names ["" "i"] -┌Order by id(), -└Output field names ["" "i"] - ----- 776 -SELECT id(), i FROM tableA ORDER BY id(); -┌Iterate all rows of table "tableA" -└Output field names ["i"] -┌Evaluate id() as "", i as "i", -└Output field names ["" "i"] -┌Order by id(), -└Output field names ["" "i"] - ----- 777 -SELECT id(), i FROM tableA ORDER BY id(); -┌Iterate all rows of table "tableA" -└Output field names ["i"] -┌Evaluate id() as "", i as "i", -└Output field names ["" "i"] -┌Order by id(), -└Output field names ["" "i"] - ----- 778 -SELECT id(), i FROM tableA ORDER BY id(); -┌Iterate all rows of table "tableA" -└Output field names ["i"] -┌Evaluate id() as "", i as "i", -└Output field names ["" "i"] -┌Order by id(), -└Output field names ["" "i"] - ----- 781 -SELECT i FROM tableA WHERE id() IN (SELECT idA FROM tableB;) ORDER BY id(); -┌Iterate all rows of table "tableA" -└Output field names ["i"] -┌Filter on id() IN (SELECT idA FROM tableB;) -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] - ----- 782 -SELECT i FROM tableA WHERE id() IN (SELECT idA FROM tableB;) ORDER BY id(); -┌Iterate all rows of table "tableA" -└Output field names ["i"] -┌Filter on id() IN (SELECT idA FROM tableB;) -└Output field names ["i"] -┌Order by id(), -└Output field names ["i"] - ----- 783 -SELECT * FROM testA; -┌Iterate all rows of table "testA" -└Output field names ["comment" "data"] - ----- 784 -SELECT * FROM testA; -┌Iterate all rows of table "testA" -└Output field names ["comment" "data"] - ----- 785 -SELECT * FROM testA ORDER BY comment; -┌Iterate all rows of table "testA" -└Output field names ["comment" "data"] -┌Order by comment, -└Output field names ["comment" "data"] - ----- 786 -SELECT * FROM testA ORDER BY comment; -┌Iterate all rows of table "testA" -└Output field names ["comment" "data"] -┌Order by comment, -└Output field names ["comment" "data"] - ----- 787 -SELECT * FROM testA ORDER BY comment; -┌Iterate all rows of table "testA" -└Output field names ["comment" "data"] -┌Order by comment, -└Output field names ["comment" "data"] - ----- 788 -SELECT * FROM testA ORDER BY comment; -┌Iterate all rows of table "testA" -└Output field names ["comment" "data"] -┌Order by comment, -└Output field names ["comment" "data"] - ----- 789 -SELECT * FROM testA ORDER BY comment; -┌Iterate all rows of table "testA" -└Output field names ["comment" "data"] -┌Order by comment, -└Output field names ["comment" "data"] - ----- 790 -SELECT * FROM testA ORDER BY comment; -┌Iterate all rows of table "testA" -└Output field names ["comment" "data"] -┌Order by comment, -└Output field names ["comment" "data"] - ----- 791 -SELECT formatFloat(c) FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate formatFloat(c) as "", -└Output field names [""] - ----- 792 -SELECT formatFloat(c) FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate formatFloat(c) as "", -└Output field names [""] - ----- 793 -SELECT formatFloat(c, 98) FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate formatFloat(c, 98) as "", -└Output field names [""] - ----- 794 -SELECT formatFloat(c, 101, 5) FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate formatFloat(c, 101, 5) as "", -└Output field names [""] - ----- 795 -SELECT formatFloat(c, 98, 7, 32) FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate formatFloat(c, 98, 7, 32) as "", -└Output field names [""] - ----- 796 -SELECT formatInt(c) FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate formatInt(c) as "", -└Output field names [""] - ----- 797 -SELECT formatInt(c) FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate formatInt(c) as "", -└Output field names [""] - ----- 798 -SELECT formatInt(c, 18) FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate formatInt(c, 18) as "", -└Output field names [""] - ----- 799 -SELECT formatInt(c) FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate formatInt(c) as "", -└Output field names [""] - ----- 800 -SELECT formatInt(c) FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate formatInt(c) as "", -└Output field names [""] - ----- 801 -SELECT formatInt(c, 18) FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate formatInt(c, 18) as "", -└Output field names [""] - ----- 802 -SELECT formatInt(c, 18) FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate formatInt(c, 18) as "", -└Output field names [""] - ----- 803 -SELECT formatInt(c, 18) FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate formatInt(c, 18) as "", -└Output field names [""] - ----- 804 -SELECT formatInt(c, 18) FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate formatInt(c, 18) as "", -└Output field names [""] - ----- 805 -SELECT formatInt(c, 18) FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate formatInt(c, 18) as "", -└Output field names [""] - ----- 806 -SELECT formatInt(c, 18) FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate formatInt(c, 18) as "", -└Output field names [""] - ----- 807 -SELECT formatInt(c, 18) FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] -┌Evaluate formatInt(c, 18) as "", -└Output field names [""] - ----- 808 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i" "b"] - ----- 809 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i" "b"] - ----- 815 -SELECT * FROM __Column2; -┌Iterate all rows of table "__Column2" -└Output field names ["TableName" "Name" "NotNull" "ConstraintExpr" "DefaultExpr"] - ----- 816 -SELECT * FROM __Column2; -┌Iterate all rows of table "__Column2" -└Output field names ["TableName" "Name" "NotNull" "ConstraintExpr" "DefaultExpr"] - ----- 817 -SELECT * FROM __Column2; -┌Iterate all rows of table "__Column2" -└Output field names ["TableName" "Name" "NotNull" "ConstraintExpr" "DefaultExpr"] - ----- 818 -SELECT * FROM __Column2; -┌Iterate all rows of table "__Column2" -└Output field names ["TableName" "Name" "NotNull" "ConstraintExpr" "DefaultExpr"] - ----- 819 -SELECT * FROM __Column2; -┌Iterate all rows of table "__Column2" -└Output field names ["TableName" "Name" "NotNull" "ConstraintExpr" "DefaultExpr"] - ----- 822 -SELECT * FROM __Column2; -┌Iterate all rows of table "__Column2" -└Output field names ["TableName" "Name" "NotNull" "ConstraintExpr" "DefaultExpr"] - ----- 823 -SELECT * FROM __Column2; -┌Iterate all rows of table "__Column2" -└Output field names ["TableName" "Name" "NotNull" "ConstraintExpr" "DefaultExpr"] - ----- 824 -SELECT * FROM __Column2; -┌Iterate all rows of table "__Column2" -└Output field names ["TableName" "Name" "NotNull" "ConstraintExpr" "DefaultExpr"] - ----- 825 -SELECT * FROM __Column2; -┌Iterate all rows of table "__Column2" -└Output field names ["TableName" "Name" "NotNull" "ConstraintExpr" "DefaultExpr"] - ----- 830 -SELECT * FROM __Column2 ORDER BY Name; -┌Iterate all rows of table "__Column2" -└Output field names ["TableName" "Name" "NotNull" "ConstraintExpr" "DefaultExpr"] -┌Order by Name, -└Output field names ["TableName" "Name" "NotNull" "ConstraintExpr" "DefaultExpr"] - ----- 831 -SELECT * FROM __Column2 ORDER BY Name; -┌Iterate all rows of table "__Column2" -└Output field names ["TableName" "Name" "NotNull" "ConstraintExpr" "DefaultExpr"] -┌Order by Name, -└Output field names ["TableName" "Name" "NotNull" "ConstraintExpr" "DefaultExpr"] - ----- 832 -SELECT * FROM __Column2 ORDER BY Name; -┌Iterate all rows of table "__Column2" -└Output field names ["TableName" "Name" "NotNull" "ConstraintExpr" "DefaultExpr"] -┌Order by Name, -└Output field names ["TableName" "Name" "NotNull" "ConstraintExpr" "DefaultExpr"] - ----- 833 -SELECT * FROM __Column2 ORDER BY Name; -┌Iterate all rows of table "__Column2" -└Output field names ["TableName" "Name" "NotNull" "ConstraintExpr" "DefaultExpr"] -┌Order by Name, -└Output field names ["TableName" "Name" "NotNull" "ConstraintExpr" "DefaultExpr"] - ----- 834 -SELECT * FROM __Column2 ORDER BY Name; -┌Iterate all rows of table "__Column2" -└Output field names ["TableName" "Name" "NotNull" "ConstraintExpr" "DefaultExpr"] -┌Order by Name, -└Output field names ["TableName" "Name" "NotNull" "ConstraintExpr" "DefaultExpr"] - ----- 835 -SELECT * FROM __Column2 ORDER BY Name; -┌Iterate all rows of table "__Column2" -└Output field names ["TableName" "Name" "NotNull" "ConstraintExpr" "DefaultExpr"] -┌Order by Name, -└Output field names ["TableName" "Name" "NotNull" "ConstraintExpr" "DefaultExpr"] - ----- 836 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] - ----- 837 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] - ----- 839 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] - ----- 842 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] - ----- 844 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] - ----- 846 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] - ----- 847 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] - ----- 850 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] - ----- 854 -SELECT * FROM department; -┌Iterate all rows of table "department" -└Output field names ["DepartmentName"] - ----- 855 -SELECT * FROM department; -┌Iterate all rows of table "department" -└Output field names ["DepartmentName"] - ----- 857 -SELECT * FROM department; -┌Iterate all rows of table "department" -└Output field names ["DepartmentName"] - ----- 858 -SELECT TimeStamp IS NOT NULL FROM t; -┌Iterate all rows of table "t" -└Output field names ["TimeStamp"] -┌Evaluate TimeStamp IS NOT NULL as "", -└Output field names [""] - ----- 861 -SELECT TimeStamp IS NOT NULL FROM t; -┌Iterate all rows of table "t" -└Output field names ["TimeStamp"] -┌Evaluate TimeStamp IS NOT NULL as "", -└Output field names [""] - ----- 862 -SELECT TimeStamp IS NOT NULL FROM t; -┌Iterate all rows of table "t" -└Output field names ["TimeStamp"] -┌Evaluate TimeStamp IS NOT NULL as "", -└Output field names [""] - ----- 864 -SELECT Event FROM t; -┌Iterate all rows of table "t" -└Output field names ["Event"] - ----- 865 -SELECT b FROM t ORDER BY b DESC; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] -┌Evaluate b as "b", -└Output field names ["b"] -┌Order descending by b, -└Output field names ["b"] - ----- 866 -SELECT b FROM t ORDER BY b DESC; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] -┌Evaluate b as "b", -└Output field names ["b"] -┌Order descending by b, -└Output field names ["b"] - ----- 868 -SELECT b FROM t ORDER BY b DESC; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] -┌Evaluate b as "b", -└Output field names ["b"] -┌Order descending by b, -└Output field names ["b"] - ----- 870 -SELECT b FROM t ORDER BY b DESC; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] -┌Evaluate b as "b", -└Output field names ["b"] -┌Order descending by b, -└Output field names ["b"] - ----- 871 -SELECT * FROM employee LEFT OUTER JOIN department ON employee.DepartmentID == department.DepartmentID ORDER BY employee.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -│ Extend the product with all NULL rows of "department" when no match for employee.DepartmentID == department.DepartmentID -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Order by employee.LastName, -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] - ----- 872 -SELECT * FROM employee LEFT OUTER JOIN department ON employee.DepartmentID == department.DepartmentID ORDER BY employee.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -│ Extend the product with all NULL rows of "department" when no match for employee.DepartmentID == department.DepartmentID -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Order by employee.LastName, -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] - ----- 873 -SELECT * FROM employee RIGHT OUTER JOIN department ON employee.DepartmentID == department.DepartmentID ORDER BY employee.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -│ Extend the product with all NULL rows of all but "department" when no match for employee.DepartmentID == department.DepartmentID -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Order by employee.LastName, -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] - ----- 874 -SELECT * FROM employee RIGHT OUTER JOIN department ON employee.DepartmentID == department.DepartmentID ORDER BY employee.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -│ Extend the product with all NULL rows of all but "department" when no match for employee.DepartmentID == department.DepartmentID -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Order by employee.LastName, -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] - ----- 875 -SELECT * FROM employee FULL OUTER JOIN department ON employee.DepartmentID == none; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -│ Extend the product with all NULL rows of "department" when no match for employee.DepartmentID == none -│ Extend the product with all NULL rows of all but "department" when no match for employee.DepartmentID == none -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] - ----- 876 -SELECT * FROM employee FULL OUTER JOIN department ON employee.DepartmentID == none; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -│ Extend the product with all NULL rows of "department" when no match for employee.DepartmentID == none -│ Extend the product with all NULL rows of all but "department" when no match for employee.DepartmentID == none -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] - ----- 877 -SELECT * FROM t1 LEFT OUTER JOIN t2 ON t1.s1 == t2.s1; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "t1" -│ └Output field names ["s1"] -│ ┌Iterate all rows of table "t2" -│ └Output field names ["s1"] -│ Extend the product with all NULL rows of "t2" when no match for t1.s1 == t2.s1 -└Output field names ["t1.s1" "t2.s1"] - ----- 878 -SELECT * FROM a LEFT OUTER JOIN b ON a.i == b.i ORDER BY a.s, a.i, b.s, b.i; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "a" -│ └Output field names ["i" "s"] -│ ┌Iterate all rows of table "b" -│ └Output field names ["i" "s"] -│ Extend the product with all NULL rows of "b" when no match for a.i == b.i -└Output field names ["a.i" "a.s" "b.i" "b.s"] -┌Order by a.s, a.i, b.s, b.i, -└Output field names ["a.i" "a.s" "b.i" "b.s"] - ----- 879 -SELECT * FROM a RIGHT OUTER JOIN b ON a.i == b.i ORDER BY a.s, a.i, b.s, b.i; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "a" -│ └Output field names ["i" "s"] -│ ┌Iterate all rows of table "b" -│ └Output field names ["i" "s"] -│ Extend the product with all NULL rows of all but "b" when no match for a.i == b.i -└Output field names ["a.i" "a.s" "b.i" "b.s"] -┌Order by a.s, a.i, b.s, b.i, -└Output field names ["a.i" "a.s" "b.i" "b.s"] - ----- 880 -SELECT * FROM b LEFT OUTER JOIN a ON a.i == b.i ORDER BY a.s, a.i, b.s, b.i; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "b" -│ └Output field names ["i" "s"] -│ ┌Iterate all rows of table "a" -│ └Output field names ["i" "s"] -│ Extend the product with all NULL rows of "a" when no match for a.i == b.i -└Output field names ["b.i" "b.s" "a.i" "a.s"] -┌Order by a.s, a.i, b.s, b.i, -└Output field names ["b.i" "b.s" "a.i" "a.s"] - ----- 881 -SELECT * FROM b RIGHT OUTER JOIN a ON a.i == b.i ORDER BY a.s, a.i, b.s, b.i; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "b" -│ └Output field names ["i" "s"] -│ ┌Iterate all rows of table "a" -│ └Output field names ["i" "s"] -│ Extend the product with all NULL rows of all but "a" when no match for a.i == b.i -└Output field names ["b.i" "b.s" "a.i" "a.s"] -┌Order by a.s, a.i, b.s, b.i, -└Output field names ["b.i" "b.s" "a.i" "a.s"] - ----- 882 -SELECT * FROM a FULL OUTER JOIN b ON a.i == b.i ORDER BY a.s, a.i, b.s, b.i; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "a" -│ └Output field names ["i" "s"] -│ ┌Iterate all rows of table "b" -│ └Output field names ["i" "s"] -│ Extend the product with all NULL rows of "b" when no match for a.i == b.i -│ Extend the product with all NULL rows of all but "b" when no match for a.i == b.i -└Output field names ["a.i" "a.s" "b.i" "b.s"] -┌Order by a.s, a.i, b.s, b.i, -└Output field names ["a.i" "a.s" "b.i" "b.s"] - ----- 883 -SELECT * FROM a FULL OUTER JOIN b ON a.i == b.i ORDER BY a.s, a.i, b.s, b.i; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "a" -│ └Output field names ["i" "s"] -│ ┌Iterate all rows of table "b" -│ └Output field names ["i" "s"] -│ Extend the product with all NULL rows of "b" when no match for a.i == b.i -│ Extend the product with all NULL rows of all but "b" when no match for a.i == b.i -└Output field names ["a.i" "a.s" "b.i" "b.s"] -┌Order by a.s, a.i, b.s, b.i, -└Output field names ["a.i" "a.s" "b.i" "b.s"] - ----- 884 -SELECT * FROM employee FULL OUTER JOIN department ON employee.DepartmentID == department.DepartmentID ORDER BY employee.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -│ Extend the product with all NULL rows of "department" when no match for employee.DepartmentID == department.DepartmentID -│ Extend the product with all NULL rows of all but "department" when no match for employee.DepartmentID == department.DepartmentID -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Order by employee.LastName, -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] - ----- 885 -SELECT * FROM employee FULL OUTER JOIN department ON employee.DepartmentID == department.DepartmentID ORDER BY employee.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -│ Extend the product with all NULL rows of "department" when no match for employee.DepartmentID == department.DepartmentID -│ Extend the product with all NULL rows of all but "department" when no match for employee.DepartmentID == department.DepartmentID -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Order by employee.LastName, -└Output field names ["employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] - ----- 886 -SELECT * FROM t,employee LEFT OUTER JOIN department ON employee.DepartmentID == department.DepartmentID ORDER BY t.s, employee.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "t" -│ └Output field names ["s"] -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -│ Extend the product with all NULL rows of "department" when no match for employee.DepartmentID == department.DepartmentID -└Output field names ["t.s" "employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Order by t.s, employee.LastName, -└Output field names ["t.s" "employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] - ----- 887 -SELECT * FROM t,employee RIGHT OUTER JOIN department ON employee.DepartmentID == department.DepartmentID ORDER BY t.s, employee.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "t" -│ └Output field names ["s"] -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -│ Extend the product with all NULL rows of all but "department" when no match for employee.DepartmentID == department.DepartmentID -└Output field names ["t.s" "employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Order by t.s, employee.LastName, -└Output field names ["t.s" "employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] - ----- 888 -SELECT * FROM t,employee FULL OUTER JOIN department ON employee.DepartmentID == department.DepartmentID ORDER BY t.s, employee.LastName; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "t" -│ └Output field names ["s"] -│ ┌Iterate all rows of table "employee" -│ └Output field names ["LastName" "DepartmentID"] -│ ┌Iterate all rows of table "department" -│ └Output field names ["DepartmentID" "DepartmentName"] -│ Extend the product with all NULL rows of "department" when no match for employee.DepartmentID == department.DepartmentID -│ Extend the product with all NULL rows of all but "department" when no match for employee.DepartmentID == department.DepartmentID -└Output field names ["t.s" "employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] -┌Order by t.s, employee.LastName, -└Output field names ["t.s" "employee.LastName" "employee.DepartmentID" "department.DepartmentID" "department.DepartmentName"] - ----- 889 -SELECT * FROM __Table WHERE !hasPrefix(Name, "__") ORDER BY Name; -┌Iterate all rows of table "__Table" -└Output field names ["Name" "Schema"] -┌Filter on !hasPrefix(Name, "__") -└Output field names ["Name" "Schema"] -┌Order by Name, -└Output field names ["Name" "Schema"] - ----- 890 -SELECT * FROM __Column2 ORDER BY TableName, Name; -┌Iterate all rows of table "__Column2" -└Output field names ["TableName" "Name" "NotNull" "ConstraintExpr" "DefaultExpr"] -┌Order by TableName, Name, -└Output field names ["TableName" "Name" "NotNull" "ConstraintExpr" "DefaultExpr"] - ----- 891 -SELECT __Column.TableName, __Column.Ordinal, __Column.Name, __Column.Type, __Column2.NotNull, __Column2.ConstraintExpr, __Column2.DefaultExpr FROM __Column LEFT OUTER JOIN __Column2 ON __Column.TableName == __Column2.TableName && __Column.Name == __Column2.Name WHERE !hasPrefix(__Column.TableName, "__") ORDER BY __Column.TableName, __Column.Ordinal; -┌Compute Cartesian product of -│ ┌Iterate all rows of table "__Column" -│ └Output field names ["TableName" "Ordinal" "Name" "Type"] -│ ┌Iterate all rows of table "__Column2" -│ └Output field names ["TableName" "Name" "NotNull" "ConstraintExpr" "DefaultExpr"] -│ Extend the product with all NULL rows of "__Column2" when no match for __Column.TableName == __Column2.TableName && __Column.Name == __Column2.Name -└Output field names ["__Column.TableName" "__Column.Ordinal" "__Column.Name" "__Column.Type" "__Column2.TableName" "__Column2.Name" "__Column2.NotNull" "__Column2.ConstraintExpr" "__Column2.DefaultExpr"] -┌Filter on !hasPrefix(__Column.TableName, "__") -└Output field names ["__Column.TableName" "__Column.Ordinal" "__Column.Name" "__Column.Type" "__Column2.TableName" "__Column2.Name" "__Column2.NotNull" "__Column2.ConstraintExpr" "__Column2.DefaultExpr"] -┌Evaluate __Column.TableName as "__Column.TableName", __Column.Ordinal as "__Column.Ordinal", __Column.Name as "__Column.Name", __Column.Type as "__Column.Type", __Column2.NotNull as "__Column2.NotNull", __Column2.ConstraintExpr as "__Column2.ConstraintExpr", __Column2.DefaultExpr as "__Column2.DefaultExpr", -└Output field names ["__Column.TableName" "__Column.Ordinal" "__Column.Name" "__Column.Type" "__Column2.NotNull" "__Column2.ConstraintExpr" "__Column2.DefaultExpr"] -┌Order by __Column.TableName, __Column.Ordinal, -└Output field names ["__Column.TableName" "__Column.Ordinal" "__Column.Name" "__Column.Type" "__Column2.NotNull" "__Column2.ConstraintExpr" "__Column2.DefaultExpr"] - ----- 902 -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 || Root == -1 FROM __Index2 WHERE !hasPrefix(TableName, "__"); -┌Iterate all rows of table "__Index2" -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Filter on !hasPrefix(TableName, "__") -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Evaluate TableName as "TableName", IndexName as "IndexName", IsUnique as "IsUnique", IsSimple as "IsSimple", Root > 0 || Root == -1 as "", -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] - ----- 903 -SELECT Expr FROM __Index2_Expr WHERE Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x";); -┌Iterate all rows of table "__Index2_Expr" -└Output field names ["Index2_ID" "Expr"] -┌Filter on Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x";) -└Output field names ["Index2_ID" "Expr"] -┌Evaluate Expr as "Expr", -└Output field names ["Expr"] - ----- 904 -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 || Root == -1 FROM __Index2 WHERE !hasPrefix(TableName, "__"); -┌Iterate all rows of table "__Index2" -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Filter on !hasPrefix(TableName, "__") -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Evaluate TableName as "TableName", IndexName as "IndexName", IsUnique as "IsUnique", IsSimple as "IsSimple", Root > 0 || Root == -1 as "", -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] - ----- 905 -SELECT Expr FROM __Index2_Expr WHERE Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x";); -┌Iterate all rows of table "__Index2_Expr" -└Output field names ["Index2_ID" "Expr"] -┌Filter on Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x";) -└Output field names ["Index2_ID" "Expr"] -┌Evaluate Expr as "Expr", -└Output field names ["Expr"] - ----- 906 -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 || Root == -1 FROM __Index2 WHERE !hasPrefix(TableName, "__") ORDER BY IndexName; -┌Iterate all rows of table "__Index2" -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Filter on !hasPrefix(TableName, "__") -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Evaluate TableName as "TableName", IndexName as "IndexName", IsUnique as "IsUnique", IsSimple as "IsSimple", Root > 0 || Root == -1 as "", -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] -┌Order by IndexName, -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] - ----- 907 -SELECT Expr FROM __Index2_Expr WHERE Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) ORDER BY Expr; -┌Iterate all rows of table "__Index2_Expr" -└Output field names ["Index2_ID" "Expr"] -┌Filter on Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) -└Output field names ["Index2_ID" "Expr"] -┌Evaluate Expr as "Expr", -└Output field names ["Expr"] -┌Order by Expr, -└Output field names ["Expr"] - ----- 908 -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 || Root == -1 FROM __Index2 WHERE !hasPrefix(TableName, "__") ORDER BY IndexName; -┌Iterate all rows of table "__Index2" -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Filter on !hasPrefix(TableName, "__") -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Evaluate TableName as "TableName", IndexName as "IndexName", IsUnique as "IsUnique", IsSimple as "IsSimple", Root > 0 || Root == -1 as "", -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] -┌Order by IndexName, -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] - ----- 909 -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 || Root == -1 FROM __Index2 WHERE !hasPrefix(TableName, "__") ORDER BY IndexName; -┌Iterate all rows of table "__Index2" -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Filter on !hasPrefix(TableName, "__") -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Evaluate TableName as "TableName", IndexName as "IndexName", IsUnique as "IsUnique", IsSimple as "IsSimple", Root > 0 || Root == -1 as "", -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] -┌Order by IndexName, -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] - ----- 910 -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 || Root == -1 FROM __Index2 WHERE !hasPrefix(TableName, "__") ORDER BY IndexName; -┌Iterate all rows of table "__Index2" -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Filter on !hasPrefix(TableName, "__") -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Evaluate TableName as "TableName", IndexName as "IndexName", IsUnique as "IsUnique", IsSimple as "IsSimple", Root > 0 || Root == -1 as "", -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] -┌Order by IndexName, -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] - ----- 911 -SELECT Expr FROM __Index2_Expr WHERE Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) ORDER BY Expr; -┌Iterate all rows of table "__Index2_Expr" -└Output field names ["Index2_ID" "Expr"] -┌Filter on Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) -└Output field names ["Index2_ID" "Expr"] -┌Evaluate Expr as "Expr", -└Output field names ["Expr"] -┌Order by Expr, -└Output field names ["Expr"] - ----- 912 -SELECT Expr FROM __Index2_Expr WHERE Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) ORDER BY Expr; -┌Iterate all rows of table "__Index2_Expr" -└Output field names ["Index2_ID" "Expr"] -┌Filter on Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) -└Output field names ["Index2_ID" "Expr"] -┌Evaluate Expr as "Expr", -└Output field names ["Expr"] -┌Order by Expr, -└Output field names ["Expr"] - ----- 913 -SELECT Expr FROM __Index2_Expr WHERE Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) ORDER BY Expr; -┌Iterate all rows of table "__Index2_Expr" -└Output field names ["Index2_ID" "Expr"] -┌Filter on Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) -└Output field names ["Index2_ID" "Expr"] -┌Evaluate Expr as "Expr", -└Output field names ["Expr"] -┌Order by Expr, -└Output field names ["Expr"] - ----- 914 -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 || Root == -1 FROM __Index2 WHERE !hasPrefix(TableName, "__") ORDER BY IndexName; -┌Iterate all rows of table "__Index2" -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Filter on !hasPrefix(TableName, "__") -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Evaluate TableName as "TableName", IndexName as "IndexName", IsUnique as "IsUnique", IsSimple as "IsSimple", Root > 0 || Root == -1 as "", -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] -┌Order by IndexName, -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] - ----- 915 -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 || Root == -1 FROM __Index2 WHERE !hasPrefix(TableName, "__") ORDER BY IndexName; -┌Iterate all rows of table "__Index2" -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Filter on !hasPrefix(TableName, "__") -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Evaluate TableName as "TableName", IndexName as "IndexName", IsUnique as "IsUnique", IsSimple as "IsSimple", Root > 0 || Root == -1 as "", -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] -┌Order by IndexName, -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] - ----- 916 -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 || Root == -1 FROM __Index2 WHERE !hasPrefix(TableName, "__") ORDER BY IndexName; -┌Iterate all rows of table "__Index2" -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Filter on !hasPrefix(TableName, "__") -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Evaluate TableName as "TableName", IndexName as "IndexName", IsUnique as "IsUnique", IsSimple as "IsSimple", Root > 0 || Root == -1 as "", -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] -┌Order by IndexName, -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] - ----- 917 -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 || Root == -1 FROM __Index2 WHERE !hasPrefix(TableName, "__") ORDER BY IndexName; -┌Iterate all rows of table "__Index2" -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Filter on !hasPrefix(TableName, "__") -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Evaluate TableName as "TableName", IndexName as "IndexName", IsUnique as "IsUnique", IsSimple as "IsSimple", Root > 0 || Root == -1 as "", -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] -┌Order by IndexName, -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] - ----- 918 -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 || Root == -1 FROM __Index2 WHERE !hasPrefix(TableName, "__") ORDER BY IndexName; -┌Iterate all rows of table "__Index2" -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Filter on !hasPrefix(TableName, "__") -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Evaluate TableName as "TableName", IndexName as "IndexName", IsUnique as "IsUnique", IsSimple as "IsSimple", Root > 0 || Root == -1 as "", -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] -┌Order by IndexName, -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] - ----- 919 -SELECT Expr FROM __Index2_Expr WHERE Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) ORDER BY Expr; -┌Iterate all rows of table "__Index2_Expr" -└Output field names ["Index2_ID" "Expr"] -┌Filter on Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) -└Output field names ["Index2_ID" "Expr"] -┌Evaluate Expr as "Expr", -└Output field names ["Expr"] -┌Order by Expr, -└Output field names ["Expr"] - ----- 920 -SELECT Expr FROM __Index2_Expr WHERE Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) ORDER BY Expr; -┌Iterate all rows of table "__Index2_Expr" -└Output field names ["Index2_ID" "Expr"] -┌Filter on Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) -└Output field names ["Index2_ID" "Expr"] -┌Evaluate Expr as "Expr", -└Output field names ["Expr"] -┌Order by Expr, -└Output field names ["Expr"] - ----- 921 -SELECT Expr FROM __Index2_Expr WHERE Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) ORDER BY Expr; -┌Iterate all rows of table "__Index2_Expr" -└Output field names ["Index2_ID" "Expr"] -┌Filter on Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) -└Output field names ["Index2_ID" "Expr"] -┌Evaluate Expr as "Expr", -└Output field names ["Expr"] -┌Order by Expr, -└Output field names ["Expr"] - ----- 922 -SELECT Expr FROM __Index2_Expr WHERE Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) ORDER BY Expr; -┌Iterate all rows of table "__Index2_Expr" -└Output field names ["Index2_ID" "Expr"] -┌Filter on Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) -└Output field names ["Index2_ID" "Expr"] -┌Evaluate Expr as "Expr", -└Output field names ["Expr"] -┌Order by Expr, -└Output field names ["Expr"] - ----- 923 -SELECT Expr FROM __Index2_Expr WHERE Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) ORDER BY Expr; -┌Iterate all rows of table "__Index2_Expr" -└Output field names ["Index2_ID" "Expr"] -┌Filter on Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) -└Output field names ["Index2_ID" "Expr"] -┌Evaluate Expr as "Expr", -└Output field names ["Expr"] -┌Order by Expr, -└Output field names ["Expr"] - ----- 924 -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 || Root == -1 FROM __Index2 WHERE !hasPrefix(TableName, "__") ORDER BY IndexName; -┌Iterate all rows of table "__Index2" -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Filter on !hasPrefix(TableName, "__") -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Evaluate TableName as "TableName", IndexName as "IndexName", IsUnique as "IsUnique", IsSimple as "IsSimple", Root > 0 || Root == -1 as "", -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] -┌Order by IndexName, -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] - ----- 925 -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 || Root == -1 FROM __Index2 WHERE !hasPrefix(TableName, "__") ORDER BY IndexName; -┌Iterate all rows of table "__Index2" -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Filter on !hasPrefix(TableName, "__") -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Evaluate TableName as "TableName", IndexName as "IndexName", IsUnique as "IsUnique", IsSimple as "IsSimple", Root > 0 || Root == -1 as "", -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] -┌Order by IndexName, -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] - ----- 926 -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 || Root == -1 FROM __Index2 WHERE !hasPrefix(TableName, "__") ORDER BY IndexName; -┌Iterate all rows of table "__Index2" -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Filter on !hasPrefix(TableName, "__") -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Evaluate TableName as "TableName", IndexName as "IndexName", IsUnique as "IsUnique", IsSimple as "IsSimple", Root > 0 || Root == -1 as "", -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] -┌Order by IndexName, -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] - ----- 927 -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 || Root == -1 FROM __Index2 WHERE !hasPrefix(TableName, "__") ORDER BY IndexName; -┌Iterate all rows of table "__Index2" -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Filter on !hasPrefix(TableName, "__") -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Evaluate TableName as "TableName", IndexName as "IndexName", IsUnique as "IsUnique", IsSimple as "IsSimple", Root > 0 || Root == -1 as "", -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] -┌Order by IndexName, -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] - ----- 928 -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 || Root == -1 FROM __Index2 WHERE !hasPrefix(TableName, "__") ORDER BY IndexName; -┌Iterate all rows of table "__Index2" -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Filter on !hasPrefix(TableName, "__") -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Evaluate TableName as "TableName", IndexName as "IndexName", IsUnique as "IsUnique", IsSimple as "IsSimple", Root > 0 || Root == -1 as "", -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] -┌Order by IndexName, -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] - ----- 929 -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 || Root == -1 FROM __Index2 WHERE !hasPrefix(TableName, "__") ORDER BY IndexName; -┌Iterate all rows of table "__Index2" -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Filter on !hasPrefix(TableName, "__") -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Evaluate TableName as "TableName", IndexName as "IndexName", IsUnique as "IsUnique", IsSimple as "IsSimple", Root > 0 || Root == -1 as "", -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] -┌Order by IndexName, -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] - ----- 930 -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 || Root == -1 FROM __Index2 WHERE !hasPrefix(TableName, "__") ORDER BY IndexName; -┌Iterate all rows of table "__Index2" -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Filter on !hasPrefix(TableName, "__") -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Evaluate TableName as "TableName", IndexName as "IndexName", IsUnique as "IsUnique", IsSimple as "IsSimple", Root > 0 || Root == -1 as "", -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] -┌Order by IndexName, -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] - ----- 931 -SELECT Expr FROM __Index2_Expr WHERE Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) ORDER BY Expr; -┌Iterate all rows of table "__Index2_Expr" -└Output field names ["Index2_ID" "Expr"] -┌Filter on Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) -└Output field names ["Index2_ID" "Expr"] -┌Evaluate Expr as "Expr", -└Output field names ["Expr"] -┌Order by Expr, -└Output field names ["Expr"] - ----- 932 -SELECT Expr FROM __Index2_Expr WHERE Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) ORDER BY Expr; -┌Iterate all rows of table "__Index2_Expr" -└Output field names ["Index2_ID" "Expr"] -┌Filter on Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) -└Output field names ["Index2_ID" "Expr"] -┌Evaluate Expr as "Expr", -└Output field names ["Expr"] -┌Order by Expr, -└Output field names ["Expr"] - ----- 933 -SELECT Expr FROM __Index2_Expr WHERE Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) ORDER BY Expr; -┌Iterate all rows of table "__Index2_Expr" -└Output field names ["Index2_ID" "Expr"] -┌Filter on Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) -└Output field names ["Index2_ID" "Expr"] -┌Evaluate Expr as "Expr", -└Output field names ["Expr"] -┌Order by Expr, -└Output field names ["Expr"] - ----- 934 -SELECT Expr FROM __Index2_Expr WHERE Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) ORDER BY Expr; -┌Iterate all rows of table "__Index2_Expr" -└Output field names ["Index2_ID" "Expr"] -┌Filter on Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) -└Output field names ["Index2_ID" "Expr"] -┌Evaluate Expr as "Expr", -└Output field names ["Expr"] -┌Order by Expr, -└Output field names ["Expr"] - ----- 935 -SELECT Expr FROM __Index2_Expr WHERE Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) ORDER BY Expr; -┌Iterate all rows of table "__Index2_Expr" -└Output field names ["Index2_ID" "Expr"] -┌Filter on Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) -└Output field names ["Index2_ID" "Expr"] -┌Evaluate Expr as "Expr", -└Output field names ["Expr"] -┌Order by Expr, -└Output field names ["Expr"] - ----- 936 -SELECT Expr FROM __Index2_Expr WHERE Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) ORDER BY Expr; -┌Iterate all rows of table "__Index2_Expr" -└Output field names ["Index2_ID" "Expr"] -┌Filter on Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) -└Output field names ["Index2_ID" "Expr"] -┌Evaluate Expr as "Expr", -└Output field names ["Expr"] -┌Order by Expr, -└Output field names ["Expr"] - ----- 937 -SELECT Expr FROM __Index2_Expr WHERE Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) ORDER BY Expr; -┌Iterate all rows of table "__Index2_Expr" -└Output field names ["Index2_ID" "Expr"] -┌Filter on Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x" || IndexName == "y";) -└Output field names ["Index2_ID" "Expr"] -┌Evaluate Expr as "Expr", -└Output field names ["Expr"] -┌Order by Expr, -└Output field names ["Expr"] - ----- 938 -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 || Root == -1 FROM __Index2 WHERE TableName == "t"; -┌Iterate all rows of table "__Index2" using index "__xIndex2_TableName" where TableName == "t" -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" "Root"] -┌Evaluate TableName as "TableName", IndexName as "IndexName", IsUnique as "IsUnique", IsSimple as "IsSimple", Root > 0 || Root == -1 as "", -└Output field names ["TableName" "IndexName" "IsUnique" "IsSimple" ""] - ----- 939 -SELECT Expr FROM __Index2_Expr WHERE Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x";) ORDER BY Expr; -┌Iterate all rows of table "__Index2_Expr" -└Output field names ["Index2_ID" "Expr"] -┌Filter on Index2_ID IN (SELECT id() FROM __Index2 WHERE IndexName == "x";) -└Output field names ["Index2_ID" "Expr"] -┌Evaluate Expr as "Expr", -└Output field names ["Expr"] -┌Order by Expr, -└Output field names ["Expr"] - ----- 940 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] - ----- 941 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 942 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["a" "b" "c"] - ----- 943 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 950 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 952 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 953 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 954 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 955 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 956 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 957 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 959 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 963 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] - ----- 964 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["c"] - ----- 966 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 967 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 968 -SELECT * FROM y; -┌Iterate all values of index "y" -└Output field names N/A - ----- 970 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 971 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 972 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 974 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 975 -SELECT * FROM x; -┌Iterate all values of index "x" -└Output field names N/A - ----- 981 -EXPLAIN SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 982 -EXPLAIN EXPLAIN SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 983 -SELECT * FROM t WHERE i != 42; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Filter on i != 42 -│Possibly useful indices -│CREATE INDEX xt_i ON t(i); -└Output field names ["i"] - ----- 984 -SELECT * FROM t WHERE i != 42; -┌Iterate all rows of table "t" using index "x" where i != 42 -└Output field names ["i"] - ----- 985 -SELECT * FROM t WHERE i != 42; -┌Iterate all rows of table "t" using index "x" where i != 42 -└Output field names ["i"] - ----- 986 -SELECT * FROM t WHERE id() > 0; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 987 -SELECT * FROM t WHERE id() > 0; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 988 -SELECT * FROM t WHERE i IS NULL; -┌Iterate all rows of table "t" -└Output field names ["i" "j"] -┌Filter on i IS NULL -│Possibly useful indices -│CREATE INDEX xt_i ON t(i); -└Output field names ["i" "j"] - ----- 989 -SELECT * FROM t WHERE i IS NULL; -┌Iterate all rows of table "t" using index "x" where i IS NULL -└Output field names ["i" "j"] - ----- 990 -SELECT * FROM t WHERE i IS NOT NULL; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Filter on i IS NOT NULL -│Possibly useful indices -│CREATE INDEX xt_i ON t(i); -└Output field names ["i"] - ----- 991 -SELECT * FROM t WHERE i IS NOT NULL; -┌Iterate all rows of table "t" using index "x" where i IS NOT NULL -└Output field names ["i"] - ----- 992 -SELECT * FROM t WHERE id() IS NULL; -┌Iterate no rows -└Output field names ["i"] - ----- 993 -SELECT * FROM t WHERE id() IS NOT NULL; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 994 -SELECT * FROM t WHERE id() IS NULL; -┌Iterate no rows -└Output field names ["i"] - ----- 995 -SELECT * FROM t WHERE id() IS NOT NULL; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 996 -SELECT * FROM t WHERE id() == 0; -┌Iterate no rows -└Output field names ["i"] - ----- 997 -SELECT * FROM t WHERE id() == 0; -┌Iterate no rows -└Output field names ["i"] - ----- 998 -SELECT * FROM t WHERE id() < 1; -┌Iterate no rows -└Output field names ["i"] - ----- 999 -SELECT * FROM t WHERE id() < 1; -┌Iterate no rows -└Output field names ["i"] - ----- 1000 -SELECT * FROM t WHERE id() <= 0; -┌Iterate no rows -└Output field names ["i"] - ----- 1001 -SELECT * FROM t WHERE id() <= 0; -┌Iterate no rows -└Output field names ["i"] - ----- 1002 -SELECT * FROM t WHERE id() > 0; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 1003 -SELECT * FROM t WHERE id() > 0; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 1004 -SELECT * FROM t WHERE id() >= 1; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 1005 -SELECT * FROM t WHERE id() >= 1; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 1006 -SELECT * FROM t WHERE id() != 0; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 1007 -SELECT * FROM t WHERE id() != 0; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 1008 -SELECT * FROM t WHERE i > -1 && i < 314 || i > 1000 && i < 2000; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Filter on i > -1 && i < 314 || i > 1000 && i < 2000 -└Output field names ["i"] - ----- 1009 -SELECT i FROM t WHERE !b ORDER BY i; -┌Iterate all rows of table "t" using index "x" where !b -└Output field names ["i" "b"] -┌Evaluate i as "i", -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 1010 -SELECT i FROM t WHERE i == 0 && i == -2; -┌Iterate no rows -└Output field names ["i"] - ----- 1011 -SELECT i FROM t WHERE i == 0 && i == -1; -┌Iterate no rows -└Output field names ["i"] - ----- 1012 -SELECT i FROM t WHERE i == 0 && i == 0; -┌Iterate all rows of table "t" using index "x" where i == 0 -└Output field names ["i"] - ----- 1013 -SELECT i FROM t WHERE i == 0 && i == 1; -┌Iterate no rows -└Output field names ["i"] - ----- 1014 -SELECT i FROM t WHERE i == 0 && i == 2; -┌Iterate no rows -└Output field names ["i"] - ----- 1015 -SELECT i FROM t WHERE i == 0 && i >= -2; -┌Iterate all rows of table "t" using index "x" where i == 0 -└Output field names ["i"] - ----- 1016 -SELECT i FROM t WHERE i == 0 && i >= -1; -┌Iterate all rows of table "t" using index "x" where i == 0 -└Output field names ["i"] - ----- 1017 -SELECT i FROM t WHERE i == 0 && i >= 0; -┌Iterate all rows of table "t" using index "x" where i == 0 -└Output field names ["i"] - ----- 1018 -SELECT i FROM t WHERE i == 0 && i >= 1; -┌Iterate no rows -└Output field names ["i"] - ----- 1019 -SELECT i FROM t WHERE i == 0 && i >= 2; -┌Iterate no rows -└Output field names ["i"] - ----- 1020 -SELECT i FROM t WHERE i == 0 && i > -2; -┌Iterate all rows of table "t" using index "x" where i == 0 -└Output field names ["i"] - ----- 1021 -SELECT i FROM t WHERE i == 0 && i > -1; -┌Iterate all rows of table "t" using index "x" where i == 0 -└Output field names ["i"] - ----- 1022 -SELECT i FROM t WHERE i == 0 && i > 0; -┌Iterate no rows -└Output field names ["i"] - ----- 1023 -SELECT i FROM t WHERE i == 0 && i > 1; -┌Iterate no rows -└Output field names ["i"] - ----- 1024 -SELECT i FROM t WHERE i == 0 && i > 2; -┌Iterate no rows -└Output field names ["i"] - ----- 1025 -SELECT i FROM t WHERE i == 0 && i <= -2; -┌Iterate no rows -└Output field names ["i"] - ----- 1026 -SELECT i FROM t WHERE i == 0 && i <= -1; -┌Iterate no rows -└Output field names ["i"] - ----- 1027 -SELECT i FROM t WHERE i == 0 && i <= 0; -┌Iterate all rows of table "t" using index "x" where i == 0 -└Output field names ["i"] - ----- 1028 -SELECT i FROM t WHERE i == 0 && i <= 1; -┌Iterate all rows of table "t" using index "x" where i == 0 -└Output field names ["i"] - ----- 1029 -SELECT i FROM t WHERE i == 0 && i <= 2; -┌Iterate all rows of table "t" using index "x" where i == 0 -└Output field names ["i"] - ----- 1030 -SELECT i FROM t WHERE i == 0 && i < -2; -┌Iterate no rows -└Output field names ["i"] - ----- 1031 -SELECT i FROM t WHERE i == 0 && i < -1; -┌Iterate no rows -└Output field names ["i"] - ----- 1032 -SELECT i FROM t WHERE i == 0 && i < 0; -┌Iterate no rows -└Output field names ["i"] - ----- 1033 -SELECT i FROM t WHERE i == 0 && i < 1; -┌Iterate all rows of table "t" using index "x" where i == 0 -└Output field names ["i"] - ----- 1034 -SELECT i FROM t WHERE i == 0 && i < 2; -┌Iterate all rows of table "t" using index "x" where i == 0 -└Output field names ["i"] - ----- 1035 -SELECT i FROM t WHERE i == 0 && i != -2; -┌Iterate all rows of table "t" using index "x" where i == 0 -└Output field names ["i"] - ----- 1036 -SELECT i FROM t WHERE i == 0 && i != -1; -┌Iterate all rows of table "t" using index "x" where i == 0 -└Output field names ["i"] - ----- 1037 -SELECT i FROM t WHERE i == 0 && i != 0; -┌Iterate no rows -└Output field names ["i"] - ----- 1038 -SELECT i FROM t WHERE i == 0 && i != 1; -┌Iterate all rows of table "t" using index "x" where i == 0 -└Output field names ["i"] - ----- 1039 -SELECT i FROM t WHERE i == 0 && i != 2; -┌Iterate all rows of table "t" using index "x" where i == 0 -└Output field names ["i"] - ----- 1040 -SELECT * FROM t WHERE !b && b ORDER BY i; -┌Iterate no rows -└Output field names ["i" "b"] - ----- 1041 -SELECT * FROM t WHERE !b && !b ORDER BY i; -┌Iterate all rows of table "t" using index "x" where !b -└Output field names ["i" "b"] -┌Order by i, -└Output field names ["i" "b"] - ----- 1042 -SELECT * FROM t WHERE b && !b ORDER BY i; -┌Iterate no rows -└Output field names ["i" "b"] - ----- 1043 -SELECT * FROM t WHERE b && b ORDER BY i; -┌Iterate all rows of table "t" using index "x" where b -└Output field names ["i" "b"] -┌Order by i, -└Output field names ["i" "b"] - ----- 1045 -SELECT i FROM t WHERE i >= 0 && i == -2; -┌Iterate no rows -└Output field names ["i"] - ----- 1046 -SELECT i FROM t WHERE i >= 0 && i == -1; -┌Iterate no rows -└Output field names ["i"] - ----- 1047 -SELECT i FROM t WHERE i >= 0 && i == 0; -┌Iterate all rows of table "t" using index "x" where i == 0 -└Output field names ["i"] - ----- 1048 -SELECT i FROM t WHERE i >= 0 && i == 1; -┌Iterate all rows of table "t" using index "x" where i == 1 -└Output field names ["i"] - ----- 1049 -SELECT i FROM t WHERE i >= 0 && i == 2; -┌Iterate all rows of table "t" using index "x" where i == 2 -└Output field names ["i"] - ----- 1050 -SELECT i FROM t WHERE i >= 0 && i >= -2; -┌Iterate all rows of table "t" using index "x" where i >= 0 -└Output field names ["i"] - ----- 1051 -SELECT i FROM t WHERE i >= 0 && i >= -1; -┌Iterate all rows of table "t" using index "x" where i >= 0 -└Output field names ["i"] - ----- 1052 -SELECT i FROM t WHERE i >= 0 && i >= 0; -┌Iterate all rows of table "t" using index "x" where i >= 0 -└Output field names ["i"] - ----- 1053 -SELECT i FROM t WHERE i >= 0 && i >= 1; -┌Iterate all rows of table "t" using index "x" where i >= 1 -└Output field names ["i"] - ----- 1054 -SELECT i FROM t WHERE i >= 0 && i >= 2; -┌Iterate all rows of table "t" using index "x" where i >= 2 -└Output field names ["i"] - ----- 1055 -SELECT i FROM t WHERE i >= 0 && i > -2; -┌Iterate all rows of table "t" using index "x" where i >= 0 -└Output field names ["i"] - ----- 1056 -SELECT i FROM t WHERE i >= 0 && i > -1; -┌Iterate all rows of table "t" using index "x" where i >= 0 -└Output field names ["i"] - ----- 1057 -SELECT i FROM t WHERE i >= 0 && i > 0; -┌Iterate all rows of table "t" using index "x" where i > 0 -└Output field names ["i"] - ----- 1058 -SELECT i FROM t WHERE i >= 0 && i > 1; -┌Iterate all rows of table "t" using index "x" where i > 1 -└Output field names ["i"] - ----- 1059 -SELECT i FROM t WHERE i >= 0 && i > 2; -┌Iterate all rows of table "t" using index "x" where i > 2 -└Output field names ["i"] - ----- 1060 -SELECT i FROM t WHERE i >= 0 && i <= -2; -┌Iterate no rows -└Output field names ["i"] - ----- 1061 -SELECT i FROM t WHERE i >= 0 && i <= -1; -┌Iterate no rows -└Output field names ["i"] - ----- 1062 -SELECT i FROM t WHERE i >= 0 && i <= 0; -┌Iterate all rows of table "t" using index "x" where i == 0 -└Output field names ["i"] - ----- 1063 -SELECT i FROM t WHERE i >= 0 && i <= 1; -┌Iterate all rows of table "t" using index "x" where i >= 0 && i <= 1 -└Output field names ["i"] - ----- 1064 -SELECT i FROM t WHERE i >= 0 && i <= 2; -┌Iterate all rows of table "t" using index "x" where i >= 0 && i <= 2 -└Output field names ["i"] - ----- 1065 -SELECT i FROM t WHERE i >= 0 && i < -2; -┌Iterate no rows -└Output field names ["i"] - ----- 1066 -SELECT i FROM t WHERE i >= 0 && i < -1; -┌Iterate no rows -└Output field names ["i"] - ----- 1067 -SELECT i FROM t WHERE i >= 0 && i < 0; -┌Iterate no rows -└Output field names ["i"] - ----- 1068 -SELECT i FROM t WHERE i >= 0 && i < 1; -┌Iterate all rows of table "t" using index "x" where i >= 0 && i < 1 -└Output field names ["i"] - ----- 1069 -SELECT i FROM t WHERE i >= 0 && i < 2; -┌Iterate all rows of table "t" using index "x" where i >= 0 && i < 2 -└Output field names ["i"] - ----- 1070 -SELECT i FROM t WHERE i >= 0 && i != -2; -┌Iterate all rows of table "t" using index "x" where i >= 0 -└Output field names ["i"] - ----- 1071 -SELECT i FROM t WHERE i >= 0 && i != -1; -┌Iterate all rows of table "t" using index "x" where i >= 0 -└Output field names ["i"] - ----- 1072 -SELECT i FROM t WHERE i >= 0 && i != 0; -┌Iterate all rows of table "t" using index "x" where i > 0 -└Output field names ["i"] - ----- 1073 -SELECT i FROM t WHERE i >= 0 && i != 1; -┌Iterate all rows of table "t" using index "x" where i >= 0 -└Output field names ["i"] -┌Filter on i != 1 -└Output field names ["i"] - ----- 1074 -SELECT i FROM t WHERE i >= 0 && i != 2; -┌Iterate all rows of table "t" using index "x" where i >= 0 -└Output field names ["i"] -┌Filter on i != 2 -└Output field names ["i"] - ----- 1075 -SELECT i FROM t WHERE i > 0 && i == -2; -┌Iterate no rows -└Output field names ["i"] - ----- 1076 -SELECT i FROM t WHERE i > 0 && i == -1; -┌Iterate no rows -└Output field names ["i"] - ----- 1077 -SELECT i FROM t WHERE i > 0 && i == 0; -┌Iterate no rows -└Output field names ["i"] - ----- 1078 -SELECT i FROM t WHERE i > 0 && i == 1; -┌Iterate all rows of table "t" using index "x" where i == 1 -└Output field names ["i"] - ----- 1079 -SELECT i FROM t WHERE i > 0 && i == 2; -┌Iterate all rows of table "t" using index "x" where i == 2 -└Output field names ["i"] - ----- 1080 -SELECT i FROM t WHERE i > 0 && i >= -2; -┌Iterate all rows of table "t" using index "x" where i > 0 -└Output field names ["i"] - ----- 1081 -SELECT i FROM t WHERE i > 0 && i >= -1; -┌Iterate all rows of table "t" using index "x" where i > 0 -└Output field names ["i"] - ----- 1082 -SELECT i FROM t WHERE i > 0 && i >= 0; -┌Iterate all rows of table "t" using index "x" where i > 0 -└Output field names ["i"] - ----- 1083 -SELECT i FROM t WHERE i > 0 && i >= 1; -┌Iterate all rows of table "t" using index "x" where i >= 1 -└Output field names ["i"] - ----- 1084 -SELECT i FROM t WHERE i > 0 && i >= 2; -┌Iterate all rows of table "t" using index "x" where i >= 2 -└Output field names ["i"] - ----- 1085 -SELECT i FROM t WHERE i > 0 && i > -2; -┌Iterate all rows of table "t" using index "x" where i > 0 -└Output field names ["i"] - ----- 1086 -SELECT i FROM t WHERE i > 0 && i > -1; -┌Iterate all rows of table "t" using index "x" where i > 0 -└Output field names ["i"] - ----- 1087 -SELECT i FROM t WHERE i > 0 && i > 0; -┌Iterate all rows of table "t" using index "x" where i > 0 -└Output field names ["i"] - ----- 1088 -SELECT i FROM t WHERE i > 0 && i > 1; -┌Iterate all rows of table "t" using index "x" where i > 1 -└Output field names ["i"] - ----- 1089 -SELECT i FROM t WHERE i > 0 && i > 2; -┌Iterate all rows of table "t" using index "x" where i > 2 -└Output field names ["i"] - ----- 1090 -SELECT i FROM t WHERE i > 0 && i <= -2; -┌Iterate no rows -└Output field names ["i"] - ----- 1091 -SELECT i FROM t WHERE i > 0 && i <= -1; -┌Iterate no rows -└Output field names ["i"] - ----- 1092 -SELECT i FROM t WHERE i > 0 && i <= 0; -┌Iterate no rows -└Output field names ["i"] - ----- 1093 -SELECT i FROM t WHERE i > 0 && i <= 1; -┌Iterate all rows of table "t" using index "x" where i > 0 && i <= 1 -└Output field names ["i"] - ----- 1094 -SELECT i FROM t WHERE i > 0 && i <= 2; -┌Iterate all rows of table "t" using index "x" where i > 0 && i <= 2 -└Output field names ["i"] - ----- 1095 -SELECT i FROM t WHERE i > 0 && i < -2; -┌Iterate no rows -└Output field names ["i"] - ----- 1096 -SELECT i FROM t WHERE i > 0 && i < -1; -┌Iterate no rows -└Output field names ["i"] - ----- 1097 -SELECT i FROM t WHERE i > 0 && i < 0; -┌Iterate no rows -└Output field names ["i"] - ----- 1098 -SELECT i FROM t WHERE i > 0 && i < 1; -┌Iterate all rows of table "t" using index "x" where i > 0 && i < 1 -└Output field names ["i"] - ----- 1099 -SELECT i FROM t WHERE i > 0 && i < 2; -┌Iterate all rows of table "t" using index "x" where i > 0 && i < 2 -└Output field names ["i"] - ----- 1100 -SELECT i FROM t WHERE i > 0 && i != -2; -┌Iterate all rows of table "t" using index "x" where i > 0 -└Output field names ["i"] - ----- 1101 -SELECT i FROM t WHERE i > 0 && i != -1; -┌Iterate all rows of table "t" using index "x" where i > 0 -└Output field names ["i"] - ----- 1102 -SELECT i FROM t WHERE i > 0 && i != 0; -┌Iterate all rows of table "t" using index "x" where i > 0 -└Output field names ["i"] - ----- 1103 -SELECT i FROM t WHERE i > 0 && i != 1; -┌Iterate all rows of table "t" using index "x" where i > 0 -└Output field names ["i"] -┌Filter on i != 1 -└Output field names ["i"] - ----- 1104 -SELECT i FROM t WHERE i > 0 && i != 2; -┌Iterate all rows of table "t" using index "x" where i > 0 -└Output field names ["i"] -┌Filter on i != 2 -└Output field names ["i"] - ----- 1105 -SELECT i FROM t WHERE i <= 0 && i == -2; -┌Iterate all rows of table "t" using index "x" where i == -2 -└Output field names ["i"] - ----- 1106 -SELECT i FROM t WHERE i <= 0 && i == -1; -┌Iterate all rows of table "t" using index "x" where i == -1 -└Output field names ["i"] - ----- 1107 -SELECT i FROM t WHERE i <= 0 && i == 0; -┌Iterate all rows of table "t" using index "x" where i == 0 -└Output field names ["i"] - ----- 1108 -SELECT i FROM t WHERE i <= 0 && i == 1; -┌Iterate no rows -└Output field names ["i"] - ----- 1109 -SELECT i FROM t WHERE i <= 0 && i == 2; -┌Iterate no rows -└Output field names ["i"] - ----- 1110 -SELECT i FROM t WHERE i <= 0 && i >= -2; -┌Iterate all rows of table "t" using index "x" where i >= -2 && i <= 0 -└Output field names ["i"] - ----- 1111 -SELECT i FROM t WHERE i <= 0 && i >= -1; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i <= 0 -└Output field names ["i"] - ----- 1112 -SELECT i FROM t WHERE i <= 0 && i >= 0; -┌Iterate all rows of table "t" using index "x" where i == 0 -└Output field names ["i"] - ----- 1113 -SELECT i FROM t WHERE i <= 0 && i >= 1; -┌Iterate no rows -└Output field names ["i"] - ----- 1114 -SELECT i FROM t WHERE i <= 0 && i >= 2; -┌Iterate no rows -└Output field names ["i"] - ----- 1115 -SELECT i FROM t WHERE i <= 0 && i > -2; -┌Iterate all rows of table "t" using index "x" where i > -2 && i <= 0 -└Output field names ["i"] - ----- 1116 -SELECT i FROM t WHERE i <= 0 && i > -1; -┌Iterate all rows of table "t" using index "x" where i > -1 && i <= 0 -└Output field names ["i"] - ----- 1117 -SELECT i FROM t WHERE i <= 0 && i > 0; -┌Iterate no rows -└Output field names ["i"] - ----- 1118 -SELECT i FROM t WHERE i <= 0 && i > 1; -┌Iterate no rows -└Output field names ["i"] - ----- 1119 -SELECT i FROM t WHERE i <= 0 && i > 2; -┌Iterate no rows -└Output field names ["i"] - ----- 1120 -SELECT i FROM t WHERE i <= 0 && i <= -2; -┌Iterate all rows of table "t" using index "x" where i <= -2 -└Output field names ["i"] - ----- 1121 -SELECT i FROM t WHERE i <= 0 && i <= -1; -┌Iterate all rows of table "t" using index "x" where i <= -1 -└Output field names ["i"] - ----- 1122 -SELECT i FROM t WHERE i <= 0 && i <= 0; -┌Iterate all rows of table "t" using index "x" where i <= 0 -└Output field names ["i"] - ----- 1123 -SELECT i FROM t WHERE i <= 0 && i <= 1; -┌Iterate all rows of table "t" using index "x" where i <= 0 -└Output field names ["i"] - ----- 1124 -SELECT i FROM t WHERE i <= 0 && i <= 2; -┌Iterate all rows of table "t" using index "x" where i <= 0 -└Output field names ["i"] - ----- 1125 -SELECT i FROM t WHERE i <= 0 && i < -2; -┌Iterate all rows of table "t" using index "x" where i < -2 -└Output field names ["i"] - ----- 1126 -SELECT i FROM t WHERE i <= 0 && i < -1; -┌Iterate all rows of table "t" using index "x" where i < -1 -└Output field names ["i"] - ----- 1127 -SELECT i FROM t WHERE i <= 0 && i < 0; -┌Iterate all rows of table "t" using index "x" where i < 0 -└Output field names ["i"] - ----- 1128 -SELECT i FROM t WHERE i <= 0 && i < 1; -┌Iterate all rows of table "t" using index "x" where i <= 0 -└Output field names ["i"] - ----- 1129 -SELECT i FROM t WHERE i <= 0 && i < 2; -┌Iterate all rows of table "t" using index "x" where i <= 0 -└Output field names ["i"] - ----- 1130 -SELECT i FROM t WHERE i <= 0 && i != -2; -┌Iterate all rows of table "t" using index "x" where i <= 0 -└Output field names ["i"] -┌Filter on i != -2 -└Output field names ["i"] - ----- 1131 -SELECT i FROM t WHERE i <= 0 && i != -1; -┌Iterate all rows of table "t" using index "x" where i <= 0 -└Output field names ["i"] -┌Filter on i != -1 -└Output field names ["i"] - ----- 1132 -SELECT i FROM t WHERE i <= 0 && i != 0; -┌Iterate all rows of table "t" using index "x" where i < 0 -└Output field names ["i"] - ----- 1133 -SELECT i FROM t WHERE i <= 0 && i != 1; -┌Iterate all rows of table "t" using index "x" where i <= 0 -└Output field names ["i"] - ----- 1134 -SELECT i FROM t WHERE i <= 0 && i != 2; -┌Iterate all rows of table "t" using index "x" where i <= 0 -└Output field names ["i"] - ----- 1135 -SELECT i FROM t WHERE i < 0 && i == -2; -┌Iterate all rows of table "t" using index "x" where i == -2 -└Output field names ["i"] - ----- 1136 -SELECT i FROM t WHERE i < 0 && i == -1; -┌Iterate all rows of table "t" using index "x" where i == -1 -└Output field names ["i"] - ----- 1137 -SELECT i FROM t WHERE i < 0 && i == 0; -┌Iterate no rows -└Output field names ["i"] - ----- 1138 -SELECT i FROM t WHERE i < 0 && i == 1; -┌Iterate no rows -└Output field names ["i"] - ----- 1139 -SELECT i FROM t WHERE i < 0 && i == 2; -┌Iterate no rows -└Output field names ["i"] - ----- 1140 -SELECT i FROM t WHERE i < 0 && i >= -2; -┌Iterate all rows of table "t" using index "x" where i >= -2 && i < 0 -└Output field names ["i"] - ----- 1141 -SELECT i FROM t WHERE i < 0 && i >= -1; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i < 0 -└Output field names ["i"] - ----- 1142 -SELECT i FROM t WHERE i < 0 && i >= 0; -┌Iterate no rows -└Output field names ["i"] - ----- 1143 -SELECT i FROM t WHERE i < 0 && i >= 1; -┌Iterate no rows -└Output field names ["i"] - ----- 1144 -SELECT i FROM t WHERE i < 0 && i >= 2; -┌Iterate no rows -└Output field names ["i"] - ----- 1145 -SELECT i FROM t WHERE i < 0 && i > -2; -┌Iterate all rows of table "t" using index "x" where i > -2 && i < 0 -└Output field names ["i"] - ----- 1146 -SELECT i FROM t WHERE i < 0 && i > -1; -┌Iterate all rows of table "t" using index "x" where i > -1 && i < 0 -└Output field names ["i"] - ----- 1147 -SELECT i FROM t WHERE i < 0 && i > 0; -┌Iterate no rows -└Output field names ["i"] - ----- 1148 -SELECT i FROM t WHERE i < 0 && i > 1; -┌Iterate no rows -└Output field names ["i"] - ----- 1149 -SELECT i FROM t WHERE i < 0 && i > 2; -┌Iterate no rows -└Output field names ["i"] - ----- 1150 -SELECT i FROM t WHERE i < 0 && i <= -2; -┌Iterate all rows of table "t" using index "x" where i <= -2 -└Output field names ["i"] - ----- 1151 -SELECT i FROM t WHERE i < 0 && i <= -1; -┌Iterate all rows of table "t" using index "x" where i <= -1 -└Output field names ["i"] - ----- 1152 -SELECT i FROM t WHERE i < 0 && i <= 0; -┌Iterate all rows of table "t" using index "x" where i < 0 -└Output field names ["i"] - ----- 1153 -SELECT i FROM t WHERE i < 0 && i <= 1; -┌Iterate all rows of table "t" using index "x" where i < 0 -└Output field names ["i"] - ----- 1154 -SELECT i FROM t WHERE i < 0 && i <= 2; -┌Iterate all rows of table "t" using index "x" where i < 0 -└Output field names ["i"] - ----- 1155 -SELECT i FROM t WHERE i < 0 && i < -2; -┌Iterate all rows of table "t" using index "x" where i < -2 -└Output field names ["i"] - ----- 1156 -SELECT i FROM t WHERE i < 0 && i < -1; -┌Iterate all rows of table "t" using index "x" where i < -1 -└Output field names ["i"] - ----- 1157 -SELECT i FROM t WHERE i < 0 && i < 0; -┌Iterate all rows of table "t" using index "x" where i < 0 -└Output field names ["i"] - ----- 1158 -SELECT i FROM t WHERE i < 0 && i < 1; -┌Iterate all rows of table "t" using index "x" where i < 0 -└Output field names ["i"] - ----- 1159 -SELECT i FROM t WHERE i < 0 && i < 2; -┌Iterate all rows of table "t" using index "x" where i < 0 -└Output field names ["i"] - ----- 1160 -SELECT i FROM t WHERE i < 0 && i != -2; -┌Iterate all rows of table "t" using index "x" where i < 0 -└Output field names ["i"] -┌Filter on i != -2 -└Output field names ["i"] - ----- 1161 -SELECT i FROM t WHERE i < 0 && i != -1; -┌Iterate all rows of table "t" using index "x" where i < 0 -└Output field names ["i"] -┌Filter on i != -1 -└Output field names ["i"] - ----- 1162 -SELECT i FROM t WHERE i < 0 && i != 0; -┌Iterate all rows of table "t" using index "x" where i < 0 -└Output field names ["i"] - ----- 1163 -SELECT i FROM t WHERE i < 0 && i != 1; -┌Iterate all rows of table "t" using index "x" where i < 0 -└Output field names ["i"] - ----- 1164 -SELECT i FROM t WHERE i < 0 && i != 2; -┌Iterate all rows of table "t" using index "x" where i < 0 -└Output field names ["i"] - ----- 1165 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i == -2; -┌Iterate no rows -└Output field names ["i"] - ----- 1166 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i == -1; -┌Iterate all rows of table "t" using index "x" where i == -1 -└Output field names ["i"] - ----- 1167 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i == 0; -┌Iterate all rows of table "t" using index "x" where i == 0 -└Output field names ["i"] - ----- 1168 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i == 1; -┌Iterate all rows of table "t" using index "x" where i == 1 -└Output field names ["i"] - ----- 1169 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i == 2; -┌Iterate no rows -└Output field names ["i"] - ----- 1170 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i >= -2; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i <= 1 -└Output field names ["i"] - ----- 1171 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i >= -1; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i <= 1 -└Output field names ["i"] - ----- 1172 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i >= 0; -┌Iterate all rows of table "t" using index "x" where i >= 0 && i <= 1 -└Output field names ["i"] - ----- 1173 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i >= 1; -┌Iterate all rows of table "t" using index "x" where i == 1 -└Output field names ["i"] - ----- 1174 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i >= 2; -┌Iterate no rows -└Output field names ["i"] - ----- 1175 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i > -2; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i <= 1 -└Output field names ["i"] - ----- 1176 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i > -1; -┌Iterate all rows of table "t" using index "x" where i > -1 && i <= 1 -└Output field names ["i"] - ----- 1177 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i > 0; -┌Iterate all rows of table "t" using index "x" where i > 0 && i <= 1 -└Output field names ["i"] - ----- 1178 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i > 1; -┌Iterate no rows -└Output field names ["i"] - ----- 1179 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i > 2; -┌Iterate no rows -└Output field names ["i"] - ----- 1180 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i <= -2; -┌Iterate no rows -└Output field names ["i"] - ----- 1181 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i <= -1; -┌Iterate all rows of table "t" using index "x" where i == -1 -└Output field names ["i"] - ----- 1182 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i <= 0; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i <= 0 -└Output field names ["i"] - ----- 1183 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i <= 1; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i <= 1 -└Output field names ["i"] - ----- 1184 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i <= 2; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i <= 1 -└Output field names ["i"] - ----- 1185 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i < -2; -┌Iterate no rows -└Output field names ["i"] - ----- 1186 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i < -1; -┌Iterate no rows -└Output field names ["i"] - ----- 1187 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i < 0; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i < 0 -└Output field names ["i"] - ----- 1188 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i < 1; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i < 1 -└Output field names ["i"] - ----- 1189 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i < 2; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i <= 1 -└Output field names ["i"] - ----- 1190 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i != -2; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i <= 1 -└Output field names ["i"] - ----- 1191 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i != -1; -┌Iterate all rows of table "t" using index "x" where i > -1 && i <= 1 -└Output field names ["i"] - ----- 1192 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i != 0; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i <= 1 -└Output field names ["i"] -┌Filter on i != 0 -└Output field names ["i"] - ----- 1193 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i != 1; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i < 1 -└Output field names ["i"] - ----- 1194 -SELECT i FROM t WHERE i >= -1 && i <= 1 && i != 2; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i <= 1 -└Output field names ["i"] - ----- 1195 -SELECT i FROM t WHERE i > -1 && i <= 1 && i == -2; -┌Iterate no rows -└Output field names ["i"] - ----- 1196 -SELECT i FROM t WHERE i > -1 && i <= 1 && i == -1; -┌Iterate no rows -└Output field names ["i"] - ----- 1197 -SELECT i FROM t WHERE i > -1 && i <= 1 && i == 0; -┌Iterate all rows of table "t" using index "x" where i == 0 -└Output field names ["i"] - ----- 1198 -SELECT i FROM t WHERE i > -1 && i <= 1 && i == 1; -┌Iterate all rows of table "t" using index "x" where i == 1 -└Output field names ["i"] - ----- 1199 -SELECT i FROM t WHERE i > -1 && i <= 1 && i == 2; -┌Iterate no rows -└Output field names ["i"] - ----- 1200 -SELECT i FROM t WHERE i > -1 && i <= 1 && i >= -2; -┌Iterate all rows of table "t" using index "x" where i > -1 && i <= 1 -└Output field names ["i"] - ----- 1201 -SELECT i FROM t WHERE i > -1 && i <= 1 && i >= -1; -┌Iterate all rows of table "t" using index "x" where i > -1 && i <= 1 -└Output field names ["i"] - ----- 1202 -SELECT i FROM t WHERE i > -1 && i <= 1 && i >= 0; -┌Iterate all rows of table "t" using index "x" where i >= 0 && i <= 1 -└Output field names ["i"] - ----- 1203 -SELECT i FROM t WHERE i > -1 && i <= 1 && i >= 1; -┌Iterate all rows of table "t" using index "x" where i == 1 -└Output field names ["i"] - ----- 1204 -SELECT i FROM t WHERE i > -1 && i <= 1 && i >= 2; -┌Iterate no rows -└Output field names ["i"] - ----- 1205 -SELECT i FROM t WHERE i > -1 && i <= 1 && i > -2; -┌Iterate all rows of table "t" using index "x" where i > -1 && i <= 1 -└Output field names ["i"] - ----- 1206 -SELECT i FROM t WHERE i > -1 && i <= 1 && i > -1; -┌Iterate all rows of table "t" using index "x" where i > -1 && i <= 1 -└Output field names ["i"] - ----- 1207 -SELECT i FROM t WHERE i > -1 && i <= 1 && i > 0; -┌Iterate all rows of table "t" using index "x" where i > 0 && i <= 1 -└Output field names ["i"] - ----- 1208 -SELECT i FROM t WHERE i > -1 && i <= 1 && i > 1; -┌Iterate no rows -└Output field names ["i"] - ----- 1209 -SELECT i FROM t WHERE i > -1 && i <= 1 && i > 2; -┌Iterate no rows -└Output field names ["i"] - ----- 1210 -SELECT i FROM t WHERE i > -1 && i <= 1 && i <= -2; -┌Iterate no rows -└Output field names ["i"] - ----- 1211 -SELECT i FROM t WHERE i > -1 && i <= 1 && i <= -1; -┌Iterate no rows -└Output field names ["i"] - ----- 1212 -SELECT i FROM t WHERE i > -1 && i <= 1 && i <= 0; -┌Iterate all rows of table "t" using index "x" where i > -1 && i <= 0 -└Output field names ["i"] - ----- 1213 -SELECT i FROM t WHERE i > -1 && i <= 1 && i <= 1; -┌Iterate all rows of table "t" using index "x" where i > -1 && i <= 1 -└Output field names ["i"] - ----- 1214 -SELECT i FROM t WHERE i > -1 && i <= 1 && i <= 2; -┌Iterate all rows of table "t" using index "x" where i > -1 && i <= 1 -└Output field names ["i"] - ----- 1215 -SELECT i FROM t WHERE i > -1 && i <= 1 && i < -2; -┌Iterate no rows -└Output field names ["i"] - ----- 1216 -SELECT i FROM t WHERE i > -1 && i <= 1 && i < -1; -┌Iterate no rows -└Output field names ["i"] - ----- 1217 -SELECT i FROM t WHERE i > -1 && i <= 1 && i < 0; -┌Iterate all rows of table "t" using index "x" where i > -1 && i < 0 -└Output field names ["i"] - ----- 1218 -SELECT i FROM t WHERE i > -1 && i <= 1 && i < 1; -┌Iterate all rows of table "t" using index "x" where i > -1 && i < 1 -└Output field names ["i"] - ----- 1219 -SELECT i FROM t WHERE i > -1 && i <= 1 && i < 2; -┌Iterate all rows of table "t" using index "x" where i > -1 && i <= 1 -└Output field names ["i"] - ----- 1220 -SELECT i FROM t WHERE i > -1 && i <= 1 && i != -2; -┌Iterate all rows of table "t" using index "x" where i > -1 && i <= 1 -└Output field names ["i"] - ----- 1221 -SELECT i FROM t WHERE i > -1 && i <= 1 && i != -1; -┌Iterate all rows of table "t" using index "x" where i > -1 && i <= 1 -└Output field names ["i"] - ----- 1222 -SELECT i FROM t WHERE i > -1 && i <= 1 && i != 0; -┌Iterate all rows of table "t" using index "x" where i > -1 && i <= 1 -└Output field names ["i"] -┌Filter on i != 0 -└Output field names ["i"] - ----- 1223 -SELECT i FROM t WHERE i > -1 && i <= 1 && i != 1; -┌Iterate all rows of table "t" using index "x" where i > -1 && i < 1 -└Output field names ["i"] - ----- 1224 -SELECT i FROM t WHERE i > -1 && i <= 1 && i != 2; -┌Iterate all rows of table "t" using index "x" where i > -1 && i <= 1 -└Output field names ["i"] - ----- 1225 -SELECT i FROM t WHERE i > -1 && i < 1 && i == -2; -┌Iterate no rows -└Output field names ["i"] - ----- 1226 -SELECT i FROM t WHERE i > -1 && i < 1 && i == -1; -┌Iterate no rows -└Output field names ["i"] - ----- 1227 -SELECT i FROM t WHERE i > -1 && i < 1 && i == 0; -┌Iterate all rows of table "t" using index "x" where i == 0 -└Output field names ["i"] - ----- 1228 -SELECT i FROM t WHERE i > -1 && i < 1 && i == 1; -┌Iterate no rows -└Output field names ["i"] - ----- 1229 -SELECT i FROM t WHERE i > -1 && i < 1 && i == 2; -┌Iterate no rows -└Output field names ["i"] - ----- 1230 -SELECT i FROM t WHERE i > -1 && i < 1 && i >= -2; -┌Iterate all rows of table "t" using index "x" where i > -1 && i < 1 -└Output field names ["i"] - ----- 1231 -SELECT i FROM t WHERE i > -1 && i < 1 && i >= -1; -┌Iterate all rows of table "t" using index "x" where i > -1 && i < 1 -└Output field names ["i"] - ----- 1232 -SELECT i FROM t WHERE i > -1 && i < 1 && i >= 0; -┌Iterate all rows of table "t" using index "x" where i >= 0 && i < 1 -└Output field names ["i"] - ----- 1233 -SELECT i FROM t WHERE i > -1 && i < 1 && i >= 1; -┌Iterate no rows -└Output field names ["i"] - ----- 1234 -SELECT i FROM t WHERE i > -1 && i < 1 && i >= 2; -┌Iterate no rows -└Output field names ["i"] - ----- 1235 -SELECT i FROM t WHERE i > -1 && i < 1 && i > -2; -┌Iterate all rows of table "t" using index "x" where i > -1 && i < 1 -└Output field names ["i"] - ----- 1236 -SELECT i FROM t WHERE i > -1 && i < 1 && i > -1; -┌Iterate all rows of table "t" using index "x" where i > -1 && i < 1 -└Output field names ["i"] - ----- 1237 -SELECT i FROM t WHERE i > -1 && i < 1 && i > 0; -┌Iterate all rows of table "t" using index "x" where i > 0 && i < 1 -└Output field names ["i"] - ----- 1238 -SELECT i FROM t WHERE i > -1 && i < 1 && i > 1; -┌Iterate no rows -└Output field names ["i"] - ----- 1239 -SELECT i FROM t WHERE i > -1 && i < 1 && i > 2; -┌Iterate no rows -└Output field names ["i"] - ----- 1240 -SELECT i FROM t WHERE i > -1 && i < 1 && i <= -2; -┌Iterate no rows -└Output field names ["i"] - ----- 1241 -SELECT i FROM t WHERE i > -1 && i < 1 && i <= -1; -┌Iterate no rows -└Output field names ["i"] - ----- 1242 -SELECT i FROM t WHERE i > -1 && i < 1 && i <= 0; -┌Iterate all rows of table "t" using index "x" where i > -1 && i <= 0 -└Output field names ["i"] - ----- 1243 -SELECT i FROM t WHERE i > -1 && i < 1 && i <= 1; -┌Iterate all rows of table "t" using index "x" where i > -1 && i < 1 -└Output field names ["i"] - ----- 1244 -SELECT i FROM t WHERE i > -1 && i < 1 && i <= 2; -┌Iterate all rows of table "t" using index "x" where i > -1 && i < 1 -└Output field names ["i"] - ----- 1245 -SELECT i FROM t WHERE i > -1 && i < 1 && i < -2; -┌Iterate no rows -└Output field names ["i"] - ----- 1246 -SELECT i FROM t WHERE i > -1 && i < 1 && i < -1; -┌Iterate no rows -└Output field names ["i"] - ----- 1247 -SELECT i FROM t WHERE i > -1 && i < 1 && i < 0; -┌Iterate all rows of table "t" using index "x" where i > -1 && i < 0 -└Output field names ["i"] - ----- 1248 -SELECT i FROM t WHERE i > -1 && i < 1 && i < 1; -┌Iterate all rows of table "t" using index "x" where i > -1 && i < 1 -└Output field names ["i"] - ----- 1249 -SELECT i FROM t WHERE i > -1 && i < 1 && i < 2; -┌Iterate all rows of table "t" using index "x" where i > -1 && i < 1 -└Output field names ["i"] - ----- 1250 -SELECT i FROM t WHERE i > -1 && i < 1 && i != -2; -┌Iterate all rows of table "t" using index "x" where i > -1 && i < 1 -└Output field names ["i"] - ----- 1251 -SELECT i FROM t WHERE i > -1 && i < 1 && i != -1; -┌Iterate all rows of table "t" using index "x" where i > -1 && i < 1 -└Output field names ["i"] - ----- 1252 -SELECT i FROM t WHERE i > -1 && i < 1 && i != 0; -┌Iterate all rows of table "t" using index "x" where i > -1 && i < 1 -└Output field names ["i"] -┌Filter on i != 0 -└Output field names ["i"] - ----- 1253 -SELECT i FROM t WHERE i > -1 && i < 1 && i != 1; -┌Iterate all rows of table "t" using index "x" where i > -1 && i < 1 -└Output field names ["i"] - ----- 1254 -SELECT i FROM t WHERE i > -1 && i < 1 && i != 2; -┌Iterate all rows of table "t" using index "x" where i > -1 && i < 1 -└Output field names ["i"] - ----- 1255 -SELECT i FROM t WHERE i >= -1 && i < 1 && i == -2; -┌Iterate no rows -└Output field names ["i"] - ----- 1256 -SELECT i FROM t WHERE i >= -1 && i < 1 && i == -1; -┌Iterate all rows of table "t" using index "x" where i == -1 -└Output field names ["i"] - ----- 1257 -SELECT i FROM t WHERE i >= -1 && i < 1 && i == 0; -┌Iterate all rows of table "t" using index "x" where i == 0 -└Output field names ["i"] - ----- 1258 -SELECT i FROM t WHERE i >= -1 && i < 1 && i == 1; -┌Iterate no rows -└Output field names ["i"] - ----- 1259 -SELECT i FROM t WHERE i >= -1 && i < 1 && i == 2; -┌Iterate no rows -└Output field names ["i"] - ----- 1260 -SELECT i FROM t WHERE i >= -1 && i < 1 && i == -2; -┌Iterate no rows -└Output field names ["i"] - ----- 1261 -SELECT i FROM t WHERE i >= -1 && i < 1 && i == -1; -┌Iterate all rows of table "t" using index "x" where i == -1 -└Output field names ["i"] - ----- 1262 -SELECT i FROM t WHERE i >= -1 && i < 1 && i == 0; -┌Iterate all rows of table "t" using index "x" where i == 0 -└Output field names ["i"] - ----- 1263 -SELECT i FROM t WHERE i >= -1 && i < 1 && i == 1; -┌Iterate no rows -└Output field names ["i"] - ----- 1264 -SELECT i FROM t WHERE i >= -1 && i < 1 && i == 2; -┌Iterate no rows -└Output field names ["i"] - ----- 1265 -SELECT i FROM t WHERE i >= -1 && i < 1 && i >= -2; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i < 1 -└Output field names ["i"] - ----- 1266 -SELECT i FROM t WHERE i >= -1 && i < 1 && i >= -1; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i < 1 -└Output field names ["i"] - ----- 1267 -SELECT i FROM t WHERE i >= -1 && i < 1 && i >= 0; -┌Iterate all rows of table "t" using index "x" where i >= 0 && i < 1 -└Output field names ["i"] - ----- 1268 -SELECT i FROM t WHERE i >= -1 && i < 1 && i >= 1; -┌Iterate no rows -└Output field names ["i"] - ----- 1269 -SELECT i FROM t WHERE i >= -1 && i < 1 && i >= 2; -┌Iterate no rows -└Output field names ["i"] - ----- 1270 -SELECT i FROM t WHERE i >= -1 && i < 1 && i > -2; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i < 1 -└Output field names ["i"] - ----- 1271 -SELECT i FROM t WHERE i >= -1 && i < 1 && i > -1; -┌Iterate all rows of table "t" using index "x" where i > -1 && i < 1 -└Output field names ["i"] - ----- 1272 -SELECT i FROM t WHERE i >= -1 && i < 1 && i > 0; -┌Iterate all rows of table "t" using index "x" where i > 0 && i < 1 -└Output field names ["i"] - ----- 1273 -SELECT i FROM t WHERE i >= -1 && i < 1 && i > 1; -┌Iterate no rows -└Output field names ["i"] - ----- 1274 -SELECT i FROM t WHERE i >= -1 && i < 1 && i > 2; -┌Iterate no rows -└Output field names ["i"] - ----- 1275 -SELECT i FROM t WHERE i >= -1 && i < 1 && i <= -2; -┌Iterate no rows -└Output field names ["i"] - ----- 1276 -SELECT i FROM t WHERE i >= -1 && i < 1 && i <= -1; -┌Iterate all rows of table "t" using index "x" where i == -1 -└Output field names ["i"] - ----- 1277 -SELECT i FROM t WHERE i >= -1 && i < 1 && i <= 0; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i <= 0 -└Output field names ["i"] - ----- 1278 -SELECT i FROM t WHERE i >= -1 && i < 1 && i <= 1; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i < 1 -└Output field names ["i"] - ----- 1279 -SELECT i FROM t WHERE i >= -1 && i < 1 && i <= 2; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i < 1 -└Output field names ["i"] - ----- 1280 -SELECT i FROM t WHERE i >= -1 && i < 1 && i < -2; -┌Iterate no rows -└Output field names ["i"] - ----- 1281 -SELECT i FROM t WHERE i >= -1 && i < 1 && i < -1; -┌Iterate no rows -└Output field names ["i"] - ----- 1282 -SELECT i FROM t WHERE i >= -1 && i < 1 && i < 0; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i < 0 -└Output field names ["i"] - ----- 1283 -SELECT i FROM t WHERE i >= -1 && i < 1 && i < 1; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i < 1 -└Output field names ["i"] - ----- 1284 -SELECT i FROM t WHERE i >= -1 && i < 1 && i < 2; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i < 1 -└Output field names ["i"] - ----- 1285 -SELECT i FROM t WHERE i >= -1 && i < 1 && i != -2; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i < 1 -└Output field names ["i"] - ----- 1286 -SELECT i FROM t WHERE i >= -1 && i < 1 && i != -1; -┌Iterate all rows of table "t" using index "x" where i > -1 && i < 1 -└Output field names ["i"] - ----- 1287 -SELECT i FROM t WHERE i >= -1 && i < 1 && i != 0; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i < 1 -└Output field names ["i"] -┌Filter on i != 0 -└Output field names ["i"] - ----- 1288 -SELECT i FROM t WHERE i >= -1 && i < 1 && i != 1; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i < 1 -└Output field names ["i"] - ----- 1289 -SELECT i FROM t WHERE i >= -1 && i < 1 && i != 2; -┌Iterate all rows of table "t" using index "x" where i >= -1 && i < 1 -└Output field names ["i"] - ----- 1290 -SELECT i FROM t WHERE i != 0 && i == -2; -┌Iterate all rows of table "t" using index "x" where i == -2 -└Output field names ["i"] - ----- 1291 -SELECT i FROM t WHERE i != 0 && i == -1; -┌Iterate all rows of table "t" using index "x" where i == -1 -└Output field names ["i"] - ----- 1292 -SELECT i FROM t WHERE i != 0 && i == 0; -┌Iterate no rows -└Output field names ["i"] - ----- 1293 -SELECT i FROM t WHERE i != 0 && i == 1; -┌Iterate all rows of table "t" using index "x" where i == 1 -└Output field names ["i"] - ----- 1294 -SELECT i FROM t WHERE i != 0 && i == 2; -┌Iterate all rows of table "t" using index "x" where i == 2 -└Output field names ["i"] - ----- 1295 -SELECT i FROM t WHERE i != 0 && i >= -2; -┌Iterate all rows of table "t" using index "x" where i != 0 -└Output field names ["i"] -┌Filter on i >= -2 -└Output field names ["i"] - ----- 1296 -SELECT i FROM t WHERE i != 0 && i >= -1; -┌Iterate all rows of table "t" using index "x" where i != 0 -└Output field names ["i"] -┌Filter on i >= -1 -└Output field names ["i"] - ----- 1297 -SELECT i FROM t WHERE i != 0 && i >= 0; -┌Iterate all rows of table "t" using index "x" where i > 0 -└Output field names ["i"] - ----- 1298 -SELECT i FROM t WHERE i != 0 && i >= 1; -┌Iterate all rows of table "t" using index "x" where i >= 1 -└Output field names ["i"] - ----- 1299 -SELECT i FROM t WHERE i != 0 && i >= 2; -┌Iterate all rows of table "t" using index "x" where i >= 2 -└Output field names ["i"] - ----- 1300 -SELECT i FROM t WHERE i != 0 && i > -2; -┌Iterate all rows of table "t" using index "x" where i != 0 -└Output field names ["i"] -┌Filter on i > -2 -└Output field names ["i"] - ----- 1301 -SELECT i FROM t WHERE i != 0 && i > -1; -┌Iterate all rows of table "t" using index "x" where i != 0 -└Output field names ["i"] -┌Filter on i > -1 -└Output field names ["i"] - ----- 1302 -SELECT i FROM t WHERE i != 0 && i > 0; -┌Iterate all rows of table "t" using index "x" where i > 0 -└Output field names ["i"] - ----- 1303 -SELECT i FROM t WHERE i != 0 && i > 1; -┌Iterate all rows of table "t" using index "x" where i > 1 -└Output field names ["i"] - ----- 1304 -SELECT i FROM t WHERE i != 0 && i > 2; -┌Iterate all rows of table "t" using index "x" where i > 2 -└Output field names ["i"] - ----- 1305 -SELECT i FROM t WHERE i != 0 && i <= -2; -┌Iterate all rows of table "t" using index "x" where i <= -2 -└Output field names ["i"] - ----- 1306 -SELECT i FROM t WHERE i != 0 && i <= -1; -┌Iterate all rows of table "t" using index "x" where i <= -1 -└Output field names ["i"] - ----- 1307 -SELECT i FROM t WHERE i != 0 && i <= 0; -┌Iterate all rows of table "t" using index "x" where i < 0 -└Output field names ["i"] - ----- 1308 -SELECT i FROM t WHERE i != 0 && i <= 1; -┌Iterate all rows of table "t" using index "x" where i != 0 -└Output field names ["i"] -┌Filter on i <= 1 -└Output field names ["i"] - ----- 1309 -SELECT i FROM t WHERE i != 0 && i <= 2; -┌Iterate all rows of table "t" using index "x" where i != 0 -└Output field names ["i"] -┌Filter on i <= 2 -└Output field names ["i"] - ----- 1310 -SELECT i FROM t WHERE i != 0 && i < -2; -┌Iterate all rows of table "t" using index "x" where i < -2 -└Output field names ["i"] - ----- 1311 -SELECT i FROM t WHERE i != 0 && i < -1; -┌Iterate all rows of table "t" using index "x" where i < -1 -└Output field names ["i"] - ----- 1312 -SELECT i FROM t WHERE i != 0 && i < 0; -┌Iterate all rows of table "t" using index "x" where i < 0 -└Output field names ["i"] - ----- 1313 -SELECT i FROM t WHERE i != 0 && i < 1; -┌Iterate all rows of table "t" using index "x" where i != 0 -└Output field names ["i"] -┌Filter on i < 1 -└Output field names ["i"] - ----- 1314 -SELECT i FROM t WHERE i != 0 && i < 2; -┌Iterate all rows of table "t" using index "x" where i != 0 -└Output field names ["i"] -┌Filter on i < 2 -└Output field names ["i"] - ----- 1315 -SELECT i FROM t WHERE i != 0 && i != -2; -┌Iterate all rows of table "t" using index "x" where i != 0 -└Output field names ["i"] -┌Filter on i != -2 -└Output field names ["i"] - ----- 1316 -SELECT i FROM t WHERE i != 0 && i != -1; -┌Iterate all rows of table "t" using index "x" where i != 0 -└Output field names ["i"] -┌Filter on i != -1 -└Output field names ["i"] - ----- 1317 -SELECT i FROM t WHERE i != 0 && i != 0; -┌Iterate all rows of table "t" using index "x" where i != 0 -└Output field names ["i"] - ----- 1318 -SELECT i FROM t WHERE i != 0 && i != 1; -┌Iterate all rows of table "t" using index "x" where i != 0 -└Output field names ["i"] -┌Filter on i != 1 -└Output field names ["i"] - ----- 1319 -SELECT i FROM t WHERE i != 0 && i != 2; -┌Iterate all rows of table "t" using index "x" where i != 0 -└Output field names ["i"] -┌Filter on i != 2 -└Output field names ["i"] - ----- 1320 -SELECT * FROM t WHERE i > 0 && j > 0 ORDER BY i, j; -┌Iterate all rows of table "t" -└Output field names ["i" "j" "k"] -┌Filter on i > 0 && j > 0 -│Possibly useful indices -│CREATE INDEX xt_i ON t(i); -│CREATE INDEX xt_j ON t(j); -└Output field names ["i" "j" "k"] -┌Order by i, j, -└Output field names ["i" "j" "k"] - ----- 1321 -SELECT * FROM t WHERE i > 0 && j > 0 ORDER BY i, j; -┌Iterate all rows of table "t" using index "xi" where i > 0 -└Output field names ["i" "j" "k"] -┌Filter on j > 0 -└Output field names ["i" "j" "k"] -┌Order by i, j, -└Output field names ["i" "j" "k"] - ----- 1322 -SELECT * FROM t WHERE i > 0 && j > 0 ORDER BY i, j; -┌Iterate all rows of table "t" using index "xj" where j > 0 -└Output field names ["i" "j" "k"] -┌Filter on i > 0 -│Possibly useful indices -│CREATE INDEX xt_i ON t(i); -└Output field names ["i" "j" "k"] -┌Order by i, j, -└Output field names ["i" "j" "k"] - ----- 1323 -SELECT * FROM t WHERE i > 0 && j > 0 ORDER BY i, j; -┌Iterate all rows of table "t" using index "xi" where i > 0 -└Output field names ["i" "j" "k"] -┌Filter on j > 0 -└Output field names ["i" "j" "k"] -┌Order by i, j, -└Output field names ["i" "j" "k"] - ----- 1324 -SELECT * FROM t WHERE j > 0 && i > 0 ORDER BY i, j; -┌Iterate all rows of table "t" using index "xj" where j > 0 -└Output field names ["i" "j" "k"] -┌Filter on i > 0 -└Output field names ["i" "j" "k"] -┌Order by i, j, -└Output field names ["i" "j" "k"] - ----- 1325 -SELECT * FROM t WHERE i > 0 && j > 0 && k > 0; -┌Iterate all rows of table "t" -└Output field names ["i" "j" "k"] -┌Filter on i > 0 && j > 0 && k > 0 -│Possibly useful indices -│CREATE INDEX xt_i ON t(i); -│CREATE INDEX xt_j ON t(j); -│CREATE INDEX xt_k ON t(k); -└Output field names ["i" "j" "k"] - ----- 1326 -SELECT * FROM t WHERE i > 0 && j > 0 && k > 0; -┌Iterate all rows of table "t" using index "xi" where i > 0 -└Output field names ["i" "j" "k"] -┌Filter on j > 0 && k > 0 -└Output field names ["i" "j" "k"] - ----- 1327 -SELECT * FROM t WHERE i > 0 && j > 0 && k > 0; -┌Iterate all rows of table "t" using index "xj" where j > 0 -└Output field names ["i" "j" "k"] -┌Filter on i > 0 && k > 0 -│Possibly useful indices -│CREATE INDEX xt_i ON t(i); -└Output field names ["i" "j" "k"] - ----- 1328 -SELECT * FROM t WHERE i > 0 && j > 0 && k > 0; -┌Iterate all rows of table "t" using index "xk" where k > 0 -└Output field names ["i" "j" "k"] -┌Filter on i > 0 && j > 0 -│Possibly useful indices -│CREATE INDEX xt_i ON t(i); -│CREATE INDEX xt_j ON t(j); -└Output field names ["i" "j" "k"] - ----- 1329 -SELECT * FROM t WHERE i > 0 && j > 0 && k > 0 && l > 0; -┌Iterate all rows of table "t" -└Output field names ["i" "j" "k" "l"] -┌Filter on i > 0 && j > 0 && k > 0 && l > 0 -│Possibly useful indices -│CREATE INDEX xt_i ON t(i); -│CREATE INDEX xt_j ON t(j); -│CREATE INDEX xt_k ON t(k); -│CREATE INDEX xt_l ON t(l); -└Output field names ["i" "j" "k" "l"] - ----- 1330 -SELECT * FROM t WHERE i > 0 && j > 0 && k > 0 && l > 0; -┌Iterate all rows of table "t" using index "xi" where i > 0 -└Output field names ["i" "j" "k" "l"] -┌Filter on j > 0 && k > 0 && l > 0 -└Output field names ["i" "j" "k" "l"] - ----- 1331 -SELECT * FROM t WHERE i > 0 && j > 0 && k > 0 && l > 0; -┌Iterate all rows of table "t" using index "xj" where j > 0 -└Output field names ["i" "j" "k" "l"] -┌Filter on i > 0 && k > 0 && l > 0 -│Possibly useful indices -│CREATE INDEX xt_i ON t(i); -└Output field names ["i" "j" "k" "l"] - ----- 1332 -SELECT * FROM t WHERE i > 0 && j > 0 && k > 0 && l > 0; -┌Iterate all rows of table "t" using index "xk" where k > 0 -└Output field names ["i" "j" "k" "l"] -┌Filter on i > 0 && j > 0 && l > 0 -│Possibly useful indices -│CREATE INDEX xt_i ON t(i); -│CREATE INDEX xt_j ON t(j); -└Output field names ["i" "j" "k" "l"] - ----- 1333 -SELECT * FROM t WHERE i > 0 && j > 0 && k > 0 && l > 0; -┌Iterate all rows of table "t" using index "xl" where l > 0 -└Output field names ["i" "j" "k" "l"] -┌Filter on i > 0 && j > 0 && k > 0 -│Possibly useful indices -│CREATE INDEX xt_i ON t(i); -│CREATE INDEX xt_j ON t(j); -│CREATE INDEX xt_k ON t(k); -└Output field names ["i" "j" "k" "l"] - ----- 1334 -SELECT * FROM t WHERE i > 12 && i >= 10 && i <= 20 && i < 15 ORDER BY i; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Filter on i > 12 && i >= 10 && i <= 20 && i < 15 -│Possibly useful indices -│CREATE INDEX xt_i ON t(i); -└Output field names ["i"] -┌Order by i, -└Output field names ["i"] - ----- 1335 -SELECT * FROM t WHERE i > 12 && i >= 10 && i <= 20 && i < 42; -┌Iterate all rows of table "t" using index "xt_i" where i > 12 && i <= 20 -└Output field names ["i"] - ----- 1336 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] - ----- 1337 -SELECT * FROM t; -┌Iterate all rows of table "t" -└Output field names ["t"] - ----- 1340 -SELECT count() FROM t; -┌Iterate all rows of table "t" -└Output field names ["t"] -┌Group by distinct rows -└Output field names ["t"] -┌Evaluate count() as "", -└Output field names [""] - ----- 1341 -SELECT count() FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Group by distinct rows -└Output field names ["i"] -┌Evaluate count() as "", -└Output field names [""] - ----- 1342 -SELECT count() FROM t; -┌Iterate all rows of table "t" -└Output field names ["i"] -┌Group by distinct rows -└Output field names ["i"] -┌Evaluate count() as "", -└Output field names [""] - diff --git a/Godeps/_workspace/src/github.com/cznic/ql/testdata.ql b/Godeps/_workspace/src/github.com/cznic/ql/testdata.ql deleted file mode 100644 index 2272a66239..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/ql/testdata.ql +++ /dev/null @@ -1,15633 +0,0 @@ -// Copyright (c) 2014 The ql Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// vi:filetype=sql - --- 0 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 int, c3 int); - INSERT INTO t VALUES(11, 22, 33); -COMMIT; -SELECT * FROM t; -|"c1", "c2", "c3" -[11 22 33] - --- 1 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int); - CREATE TABLE t (c1 int); -COMMIT; -||table.*exists - --- 2 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 int, c1 int, c4 int); -COMMIT; -||duplicate column - --- 3 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 int, c3 int); - ALTER TABLE t ADD c4 string; - INSERT INTO t VALUES (1, 2, 3, "foo"); -COMMIT; -SELECT * FROM t; -|"c1", "c2", "c3", "c4" -[1 2 3 foo] - --- 4 -BEGIN TRANSACTION; - ALTER TABLE none ADD c1 int; -COMMIT; -||table .* not exist - --- 5 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 int, c3 int); - ALTER TABLE t ADD c2 int; -COMMIT; -||column .* exists - --- 6 -BEGIN TRANSACTION; - ALTER TABLE none DROP COLUMN c1; -COMMIT; -||table .* not exist - --- 7 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 int, c3 int); - ALTER TABLE t DROP COLUMN c4; -COMMIT; -||column .* not exist - --- 8 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 int, c3 int); - ALTER TABLE t DROP COLUMN c2; - INSERT INTO t VALUES (1, 2); -COMMIT; -SELECT * FROM t; -|"c1", "c3" -[1 2] - --- 9 -BEGIN TRANSACTION; - DROP TABLE none; -COMMIT; -||table .* not exist - --- 10 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 int, c3 int); - DROP TABLE t; -COMMIT; -SELECT * FROM t; -||table .* not exist - --- 11 -BEGIN TRANSACTION; - INSERT INTO none VALUES (1, 2); -COMMIT; -||table .* not exist - --- 12 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 int); - INSERT INTO t VALUES (1); -COMMIT; -||expect - --- 13 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 int); - INSERT INTO t VALUES (1, 2, 3); -COMMIT; -||expect - --- 14 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 int); - INSERT INTO t VALUES (1, 2/(3*5-15)); -COMMIT; -||division by zero - --- 15 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 int); - INSERT INTO t VALUES (2+3*4, 2*3+4); -COMMIT; -SELECT * FROM t; -|"c1", "c2" -[14 10] - --- 16 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 int, c3 int, c4 int); - INSERT INTO t (c2, c4) VALUES (1); -COMMIT; -||expect - --- 17 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 int, c3 int, c4 int); - INSERT INTO t (c2, c4) VALUES (1, 2, 3); -COMMIT; -||expect - --- 18 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 int, c3 int, c4 int); - INSERT INTO t (c2, none) VALUES (1, 2); -COMMIT; -||unknown - --- 19 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 int, c3 int, c4 int); - INSERT INTO t (c2, c3) VALUES (2+3*4, 2*3+4); - INSERT INTO t VALUES (1, 2, 3, 4, ); -COMMIT; -SELECT * FROM t; -|"c1", "c2", "c3", "c4" -[1 2 3 4] -[ 14 10 ] - --- 20 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 int, c3 int, c4 int); - ALTER TABLE t DROP COLUMN c3; - INSERT INTO t (c1, c4) VALUES (42, 314); - INSERT INTO t (c1, c2) VALUES (2+3*4, 2*3+4); - INSERT INTO t VALUES (1, 2, 3); -COMMIT; -SELECT * FROM t; -|"c1", "c2", "c4" -[1 2 3] -[14 10 ] -[42 314] - --- 21 -BEGIN TRANSACTION; - TRUNCATE TABLE none; -COMMIT; -||table .* not exist - --- 22 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int); - INSERT INTO t VALUES(278); - TRUNCATE TABLE t; - INSERT INTO t VALUES(314); -COMMIT; -SELECT * FROM t; -|"c1" -[314] - --- 23 -SELECT * FROM none; -||table .* not exist - --- 24 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 string); - INSERT INTO t VALUES (2, "b"); - INSERT INTO t VALUES (1, "a"); -COMMIT; -SELECT * FROM t; -|"c1", "c2" -[1 a] -[2 b] - --- 25 -SELECT c1 FROM none; -||table .* not exist - --- 26 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 string); - INSERT INTO t VALUES (1, "a"); - INSERT INTO t VALUES (2, "b"); -COMMIT; -SELECT none FROM t; -||unknown - --- 27 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 string); - INSERT INTO t VALUES (1, "a"); - INSERT INTO t VALUES (2, "b"); -COMMIT; -SELECT c1, none, c2 FROM t; -||unknown - --- 28 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int32, c2 string); - INSERT INTO t VALUES (2, "b"); - INSERT INTO t VALUES (1, "a"); -COMMIT; -SELECT 3*c1 AS v FROM t; -|"v" -[3] -[6] - --- 29 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 string); - INSERT INTO t VALUES (2, "b"); - INSERT INTO t VALUES (1, "a"); -COMMIT; -SELECT c2 FROM t; -|"c2" -[a] -[b] - --- 30 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 string); - INSERT INTO t VALUES (2, "b"); - INSERT INTO t VALUES (1, "a"); -COMMIT; -SELECT c1 AS X, c2 FROM t; -|"X", "c2" -[1 a] -[2 b] - --- 31 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 string); - INSERT INTO t VALUES (2, "b"); - INSERT INTO t VALUES (1, "a"); -COMMIT; -SELECT c2, c1 AS Y FROM t; -|"c2", "Y" -[a 1] -[b 2] - --- 32 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 string); - INSERT INTO t VALUES (1, "a"); - INSERT INTO t VALUES (2, "b"); -COMMIT; -SELECT * FROM t WHERE c3 == 1; -||unknown - --- 33 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 string); - INSERT INTO t VALUES (1, "a"); - INSERT INTO t VALUES (2, "b"); -COMMIT; -SELECT * FROM t WHERE c1 == 1; -|"c1", "c2" -[1 a] - --- 34 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 string); - INSERT INTO t VALUES (1, "a"); - INSERT INTO t VALUES (2, "b"); -COMMIT; -SELECT * FROM t ORDER BY c3; -||unknown - --- 35 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int32, c2 string); - INSERT INTO t VALUES (22, "bc"); - INSERT INTO t VALUES (11, "ab"); - INSERT INTO t VALUES (33, "cd"); -COMMIT; -SELECT * FROM t ORDER BY c1; -|"c1", "c2" -[11 ab] -[22 bc] -[33 cd] - --- 36 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 string); - INSERT INTO t VALUES (1, "a"); - INSERT INTO t VALUES (2, "b"); -COMMIT; -SELECT * FROM t ORDER BY c1 ASC; -|"c1", "c2" -[1 a] -[2 b] - --- 37 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 string); - INSERT INTO t VALUES (1, "a"); - INSERT INTO t VALUES (2, "b"); -COMMIT; -SELECT * FROM t ORDER BY c1 DESC; -|"c1", "c2" -[2 b] -[1 a] - --- 38 -BEGIN TRANSACTION; -CREATE TABLE t (c1 int, c2 string); - INSERT INTO t VALUES (1, "a"); - INSERT INTO t VALUES (2, "b"); - INSERT INTO t VALUES (3, "c"); - INSERT INTO t VALUES (4, "d"); - INSERT INTO t VALUES (5, "e"); - INSERT INTO t VALUES (6, "f"); - INSERT INTO t VALUES (7, "g"); -COMMIT; -SELECT * FROM t -WHERE c1 % 2 == 0 -ORDER BY c2 DESC; -|"c1", "c2" -[6 f] -[4 d] -[2 b] - --- 39 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 string); - INSERT INTO t VALUES (1, "a"); - INSERT INTO t VALUES (2, "a"); - INSERT INTO t VALUES (3, "b"); - INSERT INTO t VALUES (4, "b"); - INSERT INTO t VALUES (5, "c"); - INSERT INTO t VALUES (6, "c"); - INSERT INTO t VALUES (7, "d"); -COMMIT; -SELECT * FROM t -ORDER BY c1, c2; -|"c1", "c2" -[1 a] -[2 a] -[3 b] -[4 b] -[5 c] -[6 c] -[7 d] - --- 40 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int, c2 string); - INSERT INTO t VALUES (1, "d"); - INSERT INTO t VALUES (2, "c"); - INSERT INTO t VALUES (3, "c"); - INSERT INTO t VALUES (4, "b"); - INSERT INTO t VALUES (5, "b"); - INSERT INTO t VALUES (6, "a"); - INSERT INTO t VALUES (7, "a"); -COMMIT; -SELECT * FROM t -ORDER BY c2, c1 -|"c1", "c2" -[6 a] -[7 a] -[4 b] -[5 b] -[2 c] -[3 c] -[1 d] - --- S 41 -SELECT * FROM employee, none; -||table .* not exist - --- S 42 -SELECT employee.LastName FROM employee, none; -||table .* not exist - --- S 43 -SELECT none FROM employee, department; -||unknown - --- S 44 -SELECT employee.LastName FROM employee, department; -|"employee.LastName" -[Williams] -[Williams] -[Williams] -[Williams] -[Smith] -[Smith] -[Smith] -[Smith] -[Robinson] -[Robinson] -[Robinson] -[Robinson] -[Heisenberg] -[Heisenberg] -[Heisenberg] -[Heisenberg] -[Jones] -[Jones] -[Jones] -[Jones] -[Rafferty] -[Rafferty] -[Rafferty] -[Rafferty] - --- S 45 -SELECT * FROM employee, department -ORDER by employee.LastName; -|"employee.LastName", "employee.DepartmentID", "department.DepartmentID", "department.DepartmentName" -[Heisenberg 33 35 Marketing] -[Heisenberg 33 34 Clerical] -[Heisenberg 33 33 Engineering] -[Heisenberg 33 31 Sales] -[Jones 33 35 Marketing] -[Jones 33 34 Clerical] -[Jones 33 33 Engineering] -[Jones 33 31 Sales] -[Rafferty 31 35 Marketing] -[Rafferty 31 34 Clerical] -[Rafferty 31 33 Engineering] -[Rafferty 31 31 Sales] -[Robinson 34 35 Marketing] -[Robinson 34 34 Clerical] -[Robinson 34 33 Engineering] -[Robinson 34 31 Sales] -[Smith 34 35 Marketing] -[Smith 34 34 Clerical] -[Smith 34 33 Engineering] -[Smith 34 31 Sales] -[Williams 35 Marketing] -[Williams 34 Clerical] -[Williams 33 Engineering] -[Williams 31 Sales] - --- S 46 -SELECT * -FROM employee, department -WHERE employee.DepartmentID == department.DepartmentID; -|"employee.LastName", "employee.DepartmentID", "department.DepartmentID", "department.DepartmentName" -[Smith 34 34 Clerical] -[Robinson 34 34 Clerical] -[Heisenberg 33 33 Engineering] -[Jones 33 33 Engineering] -[Rafferty 31 31 Sales] - --- S 47 -SELECT department.DepartmentName, department.DepartmentID, employee.LastName, employee.DepartmentID -FROM employee, department -WHERE employee.DepartmentID == department.DepartmentID -ORDER BY department.DepartmentName, employee.LastName; -|"department.DepartmentName", "department.DepartmentID", "employee.LastName", "employee.DepartmentID" -[Clerical 34 Robinson 34] -[Clerical 34 Smith 34] -[Engineering 33 Heisenberg 33] -[Engineering 33 Jones 33] -[Sales 31 Rafferty 31] - --- S 48 -SELECT department.DepartmentName, department.DepartmentID, employee.LastName, employee.DepartmentID -FROM employee, department -WHERE department.DepartmentName IN ("Sales", "Engineering", "HR", "Clerical") -ORDER BY employee.LastName; -|"department.DepartmentName", "department.DepartmentID", "employee.LastName", "employee.DepartmentID" -[Clerical 34 Heisenberg 33] -[Engineering 33 Heisenberg 33] -[Sales 31 Heisenberg 33] -[Clerical 34 Jones 33] -[Engineering 33 Jones 33] -[Sales 31 Jones 33] -[Clerical 34 Rafferty 31] -[Engineering 33 Rafferty 31] -[Sales 31 Rafferty 31] -[Clerical 34 Robinson 34] -[Engineering 33 Robinson 34] -[Sales 31 Robinson 34] -[Clerical 34 Smith 34] -[Engineering 33 Smith 34] -[Sales 31 Smith 34] -[Clerical 34 Williams ] -[Engineering 33 Williams ] -[Sales 31 Williams ] - --- S 49 -SELECT department.DepartmentName, department.DepartmentID, employee.LastName, employee.DepartmentID -FROM employee, department -WHERE (department.DepartmentID+1000) IN (1031, 1035, 1036) -ORDER BY employee.LastName; -|"department.DepartmentName", "department.DepartmentID", "employee.LastName", "employee.DepartmentID" -[Marketing 35 Heisenberg 33] -[Sales 31 Heisenberg 33] -[Marketing 35 Jones 33] -[Sales 31 Jones 33] -[Marketing 35 Rafferty 31] -[Sales 31 Rafferty 31] -[Marketing 35 Robinson 34] -[Sales 31 Robinson 34] -[Marketing 35 Smith 34] -[Sales 31 Smith 34] -[Marketing 35 Williams ] -[Sales 31 Williams ] - --- S 50 -SELECT department.DepartmentName, department.DepartmentID, employee.LastName, employee.DepartmentID -FROM employee, department -WHERE department.DepartmentName NOT IN ("Engineering", "HR", "Clerical"); -|"department.DepartmentName", "department.DepartmentID", "employee.LastName", "employee.DepartmentID" -[Marketing 35 Williams ] -[Sales 31 Williams ] -[Marketing 35 Smith 34] -[Sales 31 Smith 34] -[Marketing 35 Robinson 34] -[Sales 31 Robinson 34] -[Marketing 35 Heisenberg 33] -[Sales 31 Heisenberg 33] -[Marketing 35 Jones 33] -[Sales 31 Jones 33] -[Marketing 35 Rafferty 31] -[Sales 31 Rafferty 31] - --- S 51 -SELECT department.DepartmentName, department.DepartmentID, employee.LastName, employee.DepartmentID -FROM employee, department -WHERE department.DepartmentID BETWEEN 34 AND 36 -ORDER BY employee.LastName; -|"department.DepartmentName", "department.DepartmentID", "employee.LastName", "employee.DepartmentID" -[Marketing 35 Heisenberg 33] -[Clerical 34 Heisenberg 33] -[Marketing 35 Jones 33] -[Clerical 34 Jones 33] -[Marketing 35 Rafferty 31] -[Clerical 34 Rafferty 31] -[Marketing 35 Robinson 34] -[Clerical 34 Robinson 34] -[Marketing 35 Smith 34] -[Clerical 34 Smith 34] -[Marketing 35 Williams ] -[Clerical 34 Williams ] - --- S 52 -SELECT department.DepartmentName, department.DepartmentID, employee.LastName, employee.DepartmentID -FROM employee, department -WHERE department.DepartmentID BETWEEN int64(34) AND int64(36) -ORDER BY employee.LastName; -|"department.DepartmentName", "department.DepartmentID", "employee.LastName", "employee.DepartmentID" -[Marketing 35 Heisenberg 33] -[Clerical 34 Heisenberg 33] -[Marketing 35 Jones 33] -[Clerical 34 Jones 33] -[Marketing 35 Rafferty 31] -[Clerical 34 Rafferty 31] -[Marketing 35 Robinson 34] -[Clerical 34 Robinson 34] -[Marketing 35 Smith 34] -[Clerical 34 Smith 34] -[Marketing 35 Williams ] -[Clerical 34 Williams ] - --- S 53 -SELECT department.DepartmentName, department.DepartmentID, employee.LastName, employee.DepartmentID -FROM employee, department -WHERE department.DepartmentID NOT BETWEEN 33 AND 34 //TODO plan for 'or' in this case is possible. -ORDER BY employee.LastName; -|"department.DepartmentName", "department.DepartmentID", "employee.LastName", "employee.DepartmentID" -[Marketing 35 Heisenberg 33] -[Sales 31 Heisenberg 33] -[Marketing 35 Jones 33] -[Sales 31 Jones 33] -[Marketing 35 Rafferty 31] -[Sales 31 Rafferty 31] -[Marketing 35 Robinson 34] -[Sales 31 Robinson 34] -[Marketing 35 Smith 34] -[Sales 31 Smith 34] -[Marketing 35 Williams ] -[Sales 31 Williams ] - --- S 54 -SELECT LastName, LastName FROM employee; -||duplicate - --- S 55 -SELECT LastName+", " AS a, LastName AS a FROM employee; -||duplicate - --- S 56 -SELECT LastName AS a, LastName AS b FROM employee -ORDER by a, b; -|"a", "b" -[Heisenberg Heisenberg] -[Jones Jones] -[Rafferty Rafferty] -[Robinson Robinson] -[Smith Smith] -[Williams Williams] - --- S 57 -SELECT employee.LastName AS name, employee.DepartmentID AS id, department.DepartmentName AS department, department.DepartmentID AS id2 -FROM employee, department -WHERE employee.DepartmentID == department.DepartmentID -ORDER BY name, id, department, id2; -|"name", "id", "department", "id2" -[Heisenberg 33 Engineering 33] -[Jones 33 Engineering 33] -[Rafferty 31 Sales 31] -[Robinson 34 Clerical 34] -[Smith 34 Clerical 34] - --- S 58 -SELECT * FROM; -||expected .*RecordSetList - --- S 59 -SELECT * FROM employee -ORDER BY LastName; -|"LastName", "DepartmentID" -[Heisenberg 33] -[Jones 33] -[Rafferty 31] -[Robinson 34] -[Smith 34] -[Williams ] - --- S 60 -SELECT * FROM employee AS e -ORDER BY LastName; -|"LastName", "DepartmentID" -[Heisenberg 33] -[Jones 33] -[Rafferty 31] -[Robinson 34] -[Smith 34] -[Williams ] - --- S 61 -SELECT none FROM ( - SELECT * FROM employee; - SELECT * FROM department; -); -||expected .*'\)' - --- S 62 -SELECT none FROM ( - SELECT * FROM employee; -); -||unknown - --- S 63 -SELECT noneCol FROM ( - SELECT * FROM noneTab -); -||not exist - --- S 64 -SELECT noneCol FROM ( - SELECT * FROM employee -); -||unknown - --- S 65 -SELECT * FROM ( - SELECT * FROM employee -) -ORDER BY LastName; -|"LastName", "DepartmentID" -[Heisenberg 33] -[Jones 33] -[Rafferty 31] -[Robinson 34] -[Smith 34] -[Williams ] - --- S 66 -SELECT * FROM ( - SELECT LastName AS Name FROM employee -) -ORDER BY Name; -|"Name" -[Heisenberg] -[Jones] -[Rafferty] -[Robinson] -[Smith] -[Williams] - --- S 67 -SELECT Name FROM ( - SELECT LastName AS name FROM employee -); -||unknown - --- S 68 -SELECT name AS Name FROM ( - SELECT LastName AS name - FROM employee AS e -) -ORDER BY Name; -|"Name" -[Heisenberg] -[Jones] -[Rafferty] -[Robinson] -[Smith] -[Williams] - --- S 69 -SELECT name AS Name FROM ( - SELECT LastName AS name FROM employee -) -ORDER BY Name; -|"Name" -[Heisenberg] -[Jones] -[Rafferty] -[Robinson] -[Smith] -[Williams] - --- S 70 -SELECT employee.LastName, department.DepartmentName, department.DepartmentID FROM ( - SELECT * - FROM employee, department - WHERE employee.DepartmentID == department.DepartmentID -) -ORDER BY department.DepartmentName, employee.LastName -|"employee.LastName", "department.DepartmentName", "department.DepartmentID" -[Robinson Clerical 34] -[Smith Clerical 34] -[Heisenberg Engineering 33] -[Jones Engineering 33] -[Rafferty Sales 31] - --- S 71 -SELECT e.LastName, d.DepartmentName, d.DepartmentID FROM ( - SELECT * - FROM employee AS e, department AS d - WHERE e.DepartmentID == d.DepartmentID -) -ORDER by d.DepartmentName, e.LastName; -|"e.LastName", "d.DepartmentName", "d.DepartmentID" -[Robinson Clerical 34] -[Smith Clerical 34] -[Heisenberg Engineering 33] -[Jones Engineering 33] -[Rafferty Sales 31] - --- S 72 -SELECT e.LastName AS name, d.DepartmentName AS department, d.DepartmentID AS id FROM ( - SELECT * - FROM employee AS e, department AS d - WHERE e.DepartmentID == d.DepartmentID -) -ORDER by department, name -|"name", "department", "id" -[Robinson Clerical 34] -[Smith Clerical 34] -[Heisenberg Engineering 33] -[Jones Engineering 33] -[Rafferty Sales 31] - --- S 73 -SELECT name, department, id FROM ( - SELECT e.LastName AS name, e.DepartmentID AS id, d.DepartmentName AS department, d.DepartmentID AS fid - FROM employee AS e, department AS d - WHERE e.DepartmentID == d.DepartmentID -) -ORDER by department, name; -|"name", "department", "id" -[Robinson Clerical 34] -[Smith Clerical 34] -[Heisenberg Engineering 33] -[Jones Engineering 33] -[Rafferty Sales 31] - --- S 74 -SELECT * -FROM -( - SELECT * - FROM employee -), -( - SELECT * - FROM department -); -|"", "", "", "" -[Williams 35 Marketing] -[Williams 34 Clerical] -[Williams 33 Engineering] -[Williams 31 Sales] -[Smith 34 35 Marketing] -[Smith 34 34 Clerical] -[Smith 34 33 Engineering] -[Smith 34 31 Sales] -[Robinson 34 35 Marketing] -[Robinson 34 34 Clerical] -[Robinson 34 33 Engineering] -[Robinson 34 31 Sales] -[Heisenberg 33 35 Marketing] -[Heisenberg 33 34 Clerical] -[Heisenberg 33 33 Engineering] -[Heisenberg 33 31 Sales] -[Jones 33 35 Marketing] -[Jones 33 34 Clerical] -[Jones 33 33 Engineering] -[Jones 33 31 Sales] -[Rafferty 31 35 Marketing] -[Rafferty 31 34 Clerical] -[Rafferty 31 33 Engineering] -[Rafferty 31 31 Sales] - --- S 75 -SELECT * -FROM -( - SELECT * - FROM employee -) AS e, -( - SELECT * - FROM department -) -ORDER BY e.LastName, e.DepartmentID; -|"e.LastName", "e.DepartmentID", "", "" -[Heisenberg 33 35 Marketing] -[Heisenberg 33 34 Clerical] -[Heisenberg 33 33 Engineering] -[Heisenberg 33 31 Sales] -[Jones 33 35 Marketing] -[Jones 33 34 Clerical] -[Jones 33 33 Engineering] -[Jones 33 31 Sales] -[Rafferty 31 35 Marketing] -[Rafferty 31 34 Clerical] -[Rafferty 31 33 Engineering] -[Rafferty 31 31 Sales] -[Robinson 34 35 Marketing] -[Robinson 34 34 Clerical] -[Robinson 34 33 Engineering] -[Robinson 34 31 Sales] -[Smith 34 35 Marketing] -[Smith 34 34 Clerical] -[Smith 34 33 Engineering] -[Smith 34 31 Sales] -[Williams 35 Marketing] -[Williams 34 Clerical] -[Williams 33 Engineering] -[Williams 31 Sales] - --- S 76 -SELECT * -FROM -( - SELECT * - FROM employee -), -( - SELECT * - FROM department -) AS d -ORDER BY d.DepartmentID DESC; -|"", "", "d.DepartmentID", "d.DepartmentName" -[Rafferty 31 35 Marketing] -[Jones 33 35 Marketing] -[Heisenberg 33 35 Marketing] -[Robinson 34 35 Marketing] -[Smith 34 35 Marketing] -[Williams 35 Marketing] -[Rafferty 31 34 Clerical] -[Jones 33 34 Clerical] -[Heisenberg 33 34 Clerical] -[Robinson 34 34 Clerical] -[Smith 34 34 Clerical] -[Williams 34 Clerical] -[Rafferty 31 33 Engineering] -[Jones 33 33 Engineering] -[Heisenberg 33 33 Engineering] -[Robinson 34 33 Engineering] -[Smith 34 33 Engineering] -[Williams 33 Engineering] -[Rafferty 31 31 Sales] -[Jones 33 31 Sales] -[Heisenberg 33 31 Sales] -[Robinson 34 31 Sales] -[Smith 34 31 Sales] -[Williams 31 Sales] - --- S 77 -SELECT * -FROM - employee, - ( - SELECT * - FROM department - ) -ORDER BY employee.LastName; -|"employee.LastName", "employee.DepartmentID", "", "" -[Heisenberg 33 35 Marketing] -[Heisenberg 33 34 Clerical] -[Heisenberg 33 33 Engineering] -[Heisenberg 33 31 Sales] -[Jones 33 35 Marketing] -[Jones 33 34 Clerical] -[Jones 33 33 Engineering] -[Jones 33 31 Sales] -[Rafferty 31 35 Marketing] -[Rafferty 31 34 Clerical] -[Rafferty 31 33 Engineering] -[Rafferty 31 31 Sales] -[Robinson 34 35 Marketing] -[Robinson 34 34 Clerical] -[Robinson 34 33 Engineering] -[Robinson 34 31 Sales] -[Smith 34 35 Marketing] -[Smith 34 34 Clerical] -[Smith 34 33 Engineering] -[Smith 34 31 Sales] -[Williams 35 Marketing] -[Williams 34 Clerical] -[Williams 33 Engineering] -[Williams 31 Sales] - --- S 78 -SELECT * -FROM -( - SELECT * - FROM employee -) AS e, -( - SELECT * - FROM department -) AS d -WHERE e.DepartmentID == d.DepartmentID -ORDER BY d.DepartmentName, e.LastName; -|"e.LastName", "e.DepartmentID", "d.DepartmentID", "d.DepartmentName" -[Robinson 34 34 Clerical] -[Smith 34 34 Clerical] -[Heisenberg 33 33 Engineering] -[Jones 33 33 Engineering] -[Rafferty 31 31 Sales] - --- S 79 -SELECT * -FROM - employee, - ( - SELECT * - FROM department - ) AS d -WHERE employee.DepartmentID == d.DepartmentID -ORDER BY d.DepartmentName, employee.LastName; -|"employee.LastName", "employee.DepartmentID", "d.DepartmentID", "d.DepartmentName" -[Robinson 34 34 Clerical] -[Smith 34 34 Clerical] -[Heisenberg 33 33 Engineering] -[Jones 33 33 Engineering] -[Rafferty 31 31 Sales] - --- S 80 -SELECT * -FROM - employee AS e, - ( - SELECT * - FROM department - ) AS d -WHERE e.DepartmentID == d.DepartmentID -ORDER BY d.DepartmentName, e.LastName; -|"e.LastName", "e.DepartmentID", "d.DepartmentID", "d.DepartmentName" -[Robinson 34 34 Clerical] -[Smith 34 34 Clerical] -[Heisenberg 33 33 Engineering] -[Jones 33 33 Engineering] -[Rafferty 31 31 Sales] - --- S 81 -SELECT * -FROM - employee AS e, - ( - SELECT * - FROM department - ) AS d -WHERE e.DepartmentID == d.DepartmentID == true -ORDER BY e.DepartmentID, e.LastName; -|"e.LastName", "e.DepartmentID", "d.DepartmentID", "d.DepartmentName" -[Rafferty 31 31 Sales] -[Heisenberg 33 33 Engineering] -[Jones 33 33 Engineering] -[Robinson 34 34 Clerical] -[Smith 34 34 Clerical] - --- S 82 -SELECT * -FROM - employee AS e, - ( - SELECT * - FROM department - ) AS d -WHERE e.DepartmentID != d.DepartmentID == false -ORDER BY e.DepartmentID, e.LastName; -|"e.LastName", "e.DepartmentID", "d.DepartmentID", "d.DepartmentName" -[Rafferty 31 31 Sales] -[Heisenberg 33 33 Engineering] -[Jones 33 33 Engineering] -[Robinson 34 34 Clerical] -[Smith 34 34 Clerical] - --- 83 -BEGIN TRANSACTION; - CREATE TABLE t (c1 bool); - INSERT INTO t VALUES (1); -COMMIT; -||type int64.*type bool - --- 84 -BEGIN TRANSACTION; - CREATE TABLE t (c1 bool); - INSERT INTO t VALUES (true); -COMMIT; -SELECT * from t; -|"c1" -[true] - --- 85 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int8); - INSERT INTO t VALUES ("foo"); -COMMIT; -||type string.*type int8 - --- 86 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int8); - INSERT INTO t VALUES (0x1234); -COMMIT; -SELECT * from t; -||overflow - --- 87 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int16); - INSERT INTO t VALUES (87); -COMMIT; -SELECT * from t; -|"c1" -[87] - --- 88 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int16); - INSERT INTO t VALUES (int16(0x12345678)); -COMMIT; -SELECT * from t; -|"c1" -[22136] - --- 89 -BEGIN TRANSACTION; -CREATE TABLE t (c1 int32); - INSERT INTO t VALUES (uint32(1)); -COMMIT; -||type uint32.*type int32 - --- 90 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int32); - INSERT INTO t VALUES (0xabcd12345678); -COMMIT; -SELECT * from t; -||overflow - --- 91 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int64); - INSERT INTO t VALUES (int8(1)); -COMMIT; -||type int8.*type int64 - --- 92 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int64); - INSERT INTO t VALUES (1); -COMMIT; -SELECT * from t; -|"c1" -[1] - --- 93 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int); - INSERT INTO t VALUES (int8(1)); -COMMIT; -||type int8.*type int64 - --- 94 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int); - INSERT INTO t VALUES (94); -COMMIT; -SELECT * from t; -|"c1" -[94] - --- 95 -BEGIN TRANSACTION; - CREATE TABLE t (c1 uint8); - INSERT INTO t VALUES (95); -COMMIT; -SELECT * from t; -|"c1" -[95] - --- 96 -BEGIN TRANSACTION; - CREATE TABLE t (c1 uint8); - INSERT INTO t VALUES (uint8(0x1234)); -COMMIT; -SELECT * from t; -|"c1" -[52] - --- 97 -BEGIN TRANSACTION; - CREATE TABLE t (c1 byte); - INSERT INTO t VALUES (int8(1)); -COMMIT; -||type int8.*type uint8 - --- 98 -BEGIN TRANSACTION; - CREATE TABLE t (c1 uint8); - INSERT INTO t VALUES (byte(0x1234)); -COMMIT; -SELECT * from t; -|"c1" -[52] - --- 99 -BEGIN TRANSACTION; - CREATE TABLE t (c1 uint16); - INSERT INTO t VALUES (int(1)); -COMMIT; -||type int64.*uint16 - --- 100 -BEGIN TRANSACTION; - CREATE TABLE t (c1 uint16); - INSERT INTO t VALUES (0x12345678); -COMMIT; -SELECT * from t; -||overflow - --- 101 -BEGIN TRANSACTION; - CREATE TABLE t (c1 uint32); - INSERT INTO t VALUES (int32(1)); -COMMIT; -||type int32.*type uint32 - --- 102 -BEGIN TRANSACTION; - CREATE TABLE t (c1 uint32); - INSERT INTO t VALUES (uint32(0xabcd12345678)); -COMMIT; -SELECT * from t; -|"c1" -[305419896] - --- 103 -BEGIN TRANSACTION; - CREATE TABLE t (c1 uint64); - INSERT INTO t VALUES (int(1)); -COMMIT; -||type int64.*type uint64 - --- 104 -BEGIN TRANSACTION; - CREATE TABLE t (c1 uint64); - INSERT INTO t VALUES (uint64(1)); -COMMIT; -SELECT * from t; -|"c1" -[1] - --- 105 -BEGIN TRANSACTION; - CREATE TABLE t (c1 uint); - INSERT INTO t VALUES (int(1)); -COMMIT; -||type int64.*type uint64 - --- 106 -BEGIN TRANSACTION; - CREATE TABLE t (c1 uint); - INSERT INTO t VALUES (1); -COMMIT; -SELECT * from t; -|"c1" -[1] - --- 107 -BEGIN TRANSACTION; - CREATE TABLE t (c1 float32); - INSERT INTO t VALUES (107); -COMMIT; -SELECT * from t; -|"c1" -[107] - --- 108 -BEGIN TRANSACTION; - CREATE TABLE t (c1 float32); - INSERT INTO t VALUES (float64(1)); -COMMIT; -SELECT * from t; -||type float64.*type float32 - --- 109 -BEGIN TRANSACTION; - CREATE TABLE t (c1 float32); - INSERT INTO t VALUES (1.2); -COMMIT; -SELECT * from t; -|"c1" -[1.2] - --- 110 -BEGIN TRANSACTION; - CREATE TABLE t (c1 float64); - INSERT INTO t VALUES (1.2); -COMMIT; -SELECT * from t; -|"c1" -[1.2] - --- 111 -BEGIN TRANSACTION; - CREATE TABLE t (c1 float); - INSERT INTO t VALUES (111.1); -COMMIT; -SELECT * from t; -|"c1" -[111.1] - --- 112 -BEGIN TRANSACTION; - CREATE TABLE t (c1 float); - INSERT INTO t VALUES (-112.1); -COMMIT; -SELECT * from t; -|"c1" -[-112.1] - --- 113 -BEGIN TRANSACTION; - CREATE TABLE t (c1 complex64); - INSERT INTO t VALUES (complex(1, 0.5)); -COMMIT; -SELECT * from t; -|"c1" -[(1+0.5i)] - --- 114 -BEGIN TRANSACTION; - CREATE TABLE t (c1 complex64); - INSERT INTO t VALUES (complex128(complex(1, 0.5))); -COMMIT; -SELECT * from t; -||type complex128.*type complex64 - --- 115 -BEGIN TRANSACTION; - CREATE TABLE t (c1 complex128); - INSERT INTO t VALUES (1); -COMMIT; -SELECT * from t; -|"c1" -[(1+0i)] - --- 116 -BEGIN TRANSACTION; - CREATE TABLE t (c1 complex128); - INSERT INTO t VALUES (complex(1, 0.5)); -COMMIT; -SELECT * from t; -|"c1" -[(1+0.5i)] - --- 117 -BEGIN TRANSACTION; - CREATE TABLE t (c1 string); - INSERT INTO t VALUES (1); -COMMIT; -||type int64.*type string - --- 118 -BEGIN TRANSACTION; - CREATE TABLE t (c1 string); - INSERT INTO t VALUES ("a"+"b"); -COMMIT; -SELECT * from t; -|"c1" -[ab] - --- 119 -BEGIN TRANSACTION; - CREATE TABLE t (c1 bool); - INSERT INTO t VALUES (true); -COMMIT; -SELECT * from t -WHERE c1 > 3; -||operator .* not defined .* bool - --- 120 -BEGIN TRANSACTION; - CREATE TABLE t (c1 bool); - INSERT INTO t VALUES (true); -COMMIT; -SELECT * from t -WHERE c1; -|"c1" -[true] - --- 121 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int8); - INSERT INTO t VALUES (float(1)); -COMMIT; -SELECT * from t -WHERE c1 == 8; -||type float64.*type int8 - --- 122 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int8); - INSERT INTO t VALUES (1); -COMMIT; -SELECT * from t -WHERE c1 == int8(1); -|"c1" -[1] - --- 123 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int16); - INSERT INTO t VALUES (1); -COMMIT; -SELECT * from t -WHERE c1 == int(8); -||mismatched .* int16 .* int64 - --- 124 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int16); - INSERT INTO t VALUES (1); -COMMIT; -SELECT * from t -WHERE c1 == 1; -|"c1" -[1] - --- 125 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int32); - INSERT INTO t VALUES (1); -COMMIT; -SELECT * from t -WHERE c1 == int(8); -||mismatched .* int32 .* int64 - --- 126 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int32); - INSERT INTO t VALUES (1); -COMMIT; -SELECT * from t -WHERE c1 == 1; -|"c1" -[1] - --- 127 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int64); - INSERT INTO t VALUES (1); -COMMIT; -SELECT * from t -WHERE c1 == byte(8); -||mismatched .* int64 .* uint8 - --- 128 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int64); - INSERT INTO t VALUES (int64(1)); -COMMIT; -SELECT * from t -WHERE c1 == 1; -|"c1" -[1] - --- 129 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int); - INSERT INTO t VALUES (1); -COMMIT; -SELECT * from t -WHERE c1 == 1; -|"c1" -[1] - --- 130 -BEGIN TRANSACTION; - CREATE TABLE t (c1 uint8); - INSERT INTO t VALUES (byte(1)); -COMMIT; -SELECT * from t -WHERE c1 == int8(8); -||mismatched .* uint8 .* int8 - --- 131 -BEGIN TRANSACTION; - CREATE TABLE t (c1 uint8); - INSERT INTO t VALUES (byte(1)); -COMMIT; -SELECT * from t -WHERE c1 == 1; -|"c1" -[1] - --- 132 -BEGIN TRANSACTION; - CREATE TABLE t (c1 uint16); - INSERT INTO t VALUES (1); -COMMIT; -SELECT * from t -WHERE c1 == byte(8); -||mismatched .* uint16 .* uint8 - --- 133 -BEGIN TRANSACTION; - CREATE TABLE t (c1 uint16); - INSERT INTO t VALUES (1); -COMMIT; -SELECT * from t -WHERE c1 == 1; -|"c1" -[1] - --- 134 -BEGIN TRANSACTION; - CREATE TABLE t (c1 uint32); - INSERT INTO t VALUES (1); -COMMIT; -SELECT * from t -WHERE c1 == 1; -|"c1" -[1] - --- 135 -BEGIN TRANSACTION; - CREATE TABLE t (c1 uint64); - INSERT INTO t VALUES (1); -COMMIT; -SELECT * from t -WHERE c1 == int(8); -||mismatched .* uint64 .* int64 - --- 136 -BEGIN TRANSACTION; - CREATE TABLE t (c1 uint64); - INSERT INTO t VALUES (1); -COMMIT; -SELECT * from t -WHERE c1 == 1; -|"c1" -[1] - --- 137 -BEGIN TRANSACTION; - CREATE TABLE t (c1 uint); - INSERT INTO t VALUES (1); -COMMIT; -SELECT * from t -WHERE c1 == 1; -|"c1" -[1] - --- 138 -BEGIN TRANSACTION; - CREATE TABLE t (c1 float32); - INSERT INTO t VALUES (8); -COMMIT; -SELECT * from t -WHERE c1 == byte(8); -||mismatched .* float32 .* uint8 - --- 139 -BEGIN TRANSACTION; - CREATE TABLE t (c1 float32); - INSERT INTO t VALUES (8); -COMMIT; -SELECT * from t -WHERE c1 == 8; -|"c1" -[8] - --- 140 -BEGIN TRANSACTION; - CREATE TABLE t (c1 float64); - INSERT INTO t VALUES (2); -COMMIT; -SELECT * from t -WHERE c1 == byte(2); -||mismatched .* float64 .* uint8 - --- 141 -BEGIN TRANSACTION; - CREATE TABLE t (c1 float64); - INSERT INTO t VALUES (2); -COMMIT; -SELECT * from t -WHERE c1 == 2; -|"c1" -[2] - --- 142 -BEGIN TRANSACTION; - CREATE TABLE t (c1 float); - INSERT INTO t VALUES (2.); -COMMIT; -SELECT * from t -WHERE c1 == 2; -|"c1" -[2] - --- 143 -BEGIN TRANSACTION; - CREATE TABLE t (c1 complex64); - INSERT INTO t VALUES (complex(2., 5.)); -COMMIT; -SELECT * from t -WHERE c1 == "foo"; -||mismatched .* complex64 .* string - --- 144 -BEGIN TRANSACTION; - CREATE TABLE t (c1 complex64); - INSERT INTO t VALUES (complex(2, 5.)); -COMMIT; -SELECT * from t -WHERE c1 == 2+5i; -|"c1" -[(2+5i)] - --- 145 -BEGIN TRANSACTION; - CREATE TABLE t (c1 complex128); - INSERT INTO t VALUES (2+5i); -COMMIT; -SELECT * from t -WHERE c1 == "2"; -||mismatched .* complex128 .* string - --- 146 -BEGIN TRANSACTION; - CREATE TABLE t (c1 complex128); - INSERT INTO t VALUES (2+5i); -COMMIT; -SELECT * from t -WHERE c1 == complex(2, 5); -|"c1" -[(2+5i)] - --- 147 -BEGIN TRANSACTION; - CREATE TABLE t (c1 string); - INSERT INTO t VALUES ("foo"); -COMMIT; -SELECT * from t -WHERE c1 == 2; -||mismatched .* string .* int64 - --- 148 -BEGIN TRANSACTION; - CREATE TABLE t (c1 string); - INSERT INTO t VALUES ("f"+"oo"); -COMMIT; -SELECT * from t -WHERE c1 == "fo"+"o"; -|"c1" -[foo] - --- 149 -SELECT 2/(3*5-15) AS foo FROM bar; -||division by zero - --- 150 -SELECT 2.0/(2.0-2.0) AS foo FROM bar; -||division by zero - --- 151 -SELECT 2i/(2i-2i) AS foo FROM bar; -||division by zero - --- 152 -SELECT 2/(3*5-x) AS foo FROM bar; -||table .* not exist - --- S 153 -SELECT 314, 42 AS AUQLUE, DepartmentID, DepartmentID+1000, LastName AS Name -FROM employee -ORDER BY Name; -|"", "AUQLUE", "DepartmentID", "", "Name" -[314 42 33 1033 Heisenberg] -[314 42 33 1033 Jones] -[314 42 31 1031 Rafferty] -[314 42 34 1034 Robinson] -[314 42 34 1034 Smith] -[314 42 Williams] - --- S 154 -SELECT * -FROM - employee AS e, - ( SELECT * FROM department) -ORDER BY e.LastName; -|"e.LastName", "e.DepartmentID", "", "" -[Heisenberg 33 35 Marketing] -[Heisenberg 33 34 Clerical] -[Heisenberg 33 33 Engineering] -[Heisenberg 33 31 Sales] -[Jones 33 35 Marketing] -[Jones 33 34 Clerical] -[Jones 33 33 Engineering] -[Jones 33 31 Sales] -[Rafferty 31 35 Marketing] -[Rafferty 31 34 Clerical] -[Rafferty 31 33 Engineering] -[Rafferty 31 31 Sales] -[Robinson 34 35 Marketing] -[Robinson 34 34 Clerical] -[Robinson 34 33 Engineering] -[Robinson 34 31 Sales] -[Smith 34 35 Marketing] -[Smith 34 34 Clerical] -[Smith 34 33 Engineering] -[Smith 34 31 Sales] -[Williams 35 Marketing] -[Williams 34 Clerical] -[Williams 33 Engineering] -[Williams 31 Sales] - --- S 155 -SELECT * FROM employee AS e, ( SELECT * FROM department) AS d -ORDER BY e.LastName; -|"e.LastName", "e.DepartmentID", "d.DepartmentID", "d.DepartmentName" -[Heisenberg 33 35 Marketing] -[Heisenberg 33 34 Clerical] -[Heisenberg 33 33 Engineering] -[Heisenberg 33 31 Sales] -[Jones 33 35 Marketing] -[Jones 33 34 Clerical] -[Jones 33 33 Engineering] -[Jones 33 31 Sales] -[Rafferty 31 35 Marketing] -[Rafferty 31 34 Clerical] -[Rafferty 31 33 Engineering] -[Rafferty 31 31 Sales] -[Robinson 34 35 Marketing] -[Robinson 34 34 Clerical] -[Robinson 34 33 Engineering] -[Robinson 34 31 Sales] -[Smith 34 35 Marketing] -[Smith 34 34 Clerical] -[Smith 34 33 Engineering] -[Smith 34 31 Sales] -[Williams 35 Marketing] -[Williams 34 Clerical] -[Williams 33 Engineering] -[Williams 31 Sales] - --- 156 -BEGIN TRANSACTION; - CREATE TABLE t (c1 int32, c2 string); - INSERT INTO t VALUES (1, "a"); - INSERT INTO t VALUES (int64(2), "b"); -COMMIT; -SELECT c2 FROM t; -||type int64.*type int32 - --- 157 -BEGIN TRANSACTION; - CREATE TABLE t (c1 complex64); - INSERT INTO t VALUES(1); -COMMIT; -SELECT * FROM t; -|"c1" -[(1+0i)] - --- 158 -BEGIN TRANSACTION; - CREATE TABLE p (p bool); - INSERT INTO p VALUES (NULL), (false), (true); -COMMIT; -SELECT * FROM p; -|"p" -[true] -[false] -[] - --- 159 -BEGIN TRANSACTION; - CREATE TABLE p (p bool); - INSERT INTO p VALUES (NULL), (false), (true); -COMMIT; -SELECT p.p AS p, q.p AS q, p.p OR q.p AS p_or_q, p.p && q.p aS p_and_q FROM p, p AS q; -|"p", "q", "p_or_q", "p_and_q" -[true true true true] -[true false true false] -[true true ] -[false true true false] -[false false false false] -[false false] -[ true true ] -[ false false] -[ ] - --- 160 -BEGIN TRANSACTION; - CREATE TABLE p (p bool); - INSERT INTO p VALUES (NULL), (false), (true); -COMMIT; -SELECT p, !p AS not_p FROM p; -|"p", "not_p" -[true false] -[false true] -[ ] - --- S 161 -SELECT * FROM department WHERE DepartmentID >= 33 -ORDER BY DepartmentID; -|"DepartmentID", "DepartmentName" -[33 Engineering] -[34 Clerical] -[35 Marketing] - --- S 162 -SELECT * FROM department WHERE DepartmentID <= 34 -ORDER BY DepartmentID; -|"DepartmentID", "DepartmentName" -[31 Sales] -[33 Engineering] -[34 Clerical] - --- S 163 -SELECT * FROM department WHERE DepartmentID < 34 -ORDER BY DepartmentID; -|"DepartmentID", "DepartmentName" -[31 Sales] -[33 Engineering] - --- S 164 -SELECT +DepartmentID FROM employee; -|"" -[] -[34] -[34] -[33] -[33] -[31] - --- S 165 -SELECT * FROM employee -ORDER BY LastName; -|"LastName", "DepartmentID" -[Heisenberg 33] -[Jones 33] -[Rafferty 31] -[Robinson 34] -[Smith 34] -[Williams ] - --- S 166 -SELECT * -FROM employee -ORDER BY LastName DESC; -|"LastName", "DepartmentID" -[Williams ] -[Smith 34] -[Robinson 34] -[Rafferty 31] -[Jones 33] -[Heisenberg 33] - --- S 167 -SELECT 1023+DepartmentID AS y FROM employee -ORDER BY y DESC; -|"y" -[1057] -[1057] -[1056] -[1056] -[1054] -[] - --- S 168 -SELECT +DepartmentID AS y FROM employee -ORDER BY y DESC; -|"y" -[34] -[34] -[33] -[33] -[31] -[] - --- S 169 -SELECT * FROM employee ORDER BY DepartmentID, LastName DESC; -|"LastName", "DepartmentID" -[Smith 34] -[Robinson 34] -[Jones 33] -[Heisenberg 33] -[Rafferty 31] -[Williams ] - --- S 170 -SELECT * FROM employee ORDER BY 0+DepartmentID DESC; -|"LastName", "DepartmentID" -[Robinson 34] -[Smith 34] -[Jones 33] -[Heisenberg 33] -[Rafferty 31] -[Williams ] - --- S 171 -SELECT * FROM employee ORDER BY +DepartmentID DESC; -|"LastName", "DepartmentID" -[Robinson 34] -[Smith 34] -[Jones 33] -[Heisenberg 33] -[Rafferty 31] -[Williams ] - --- S 172 -SELECT ^DepartmentID AS y FROM employee -ORDER BY y DESC; -|"y" -[-32] -[-34] -[-34] -[-35] -[-35] -[] - --- S 173 -SELECT ^byte(DepartmentID) AS y FROM employee ORDER BY y DESC; -|"y" -[224] -[222] -[222] -[221] -[221] -[] - --- 174 -BEGIN TRANSACTION; - CREATE TABLE t (r RUNE); - INSERT INTO t VALUES (1), ('A'), (rune(int(0x21))); -COMMIT; -SELECT * FROM t -ORDER BY r; -|"r" -[1] -[33] -[65] - --- 175 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES (-2), (-1), (0), (1), (2); -COMMIT; -SELECT i^1 AS y FROM t -ORDER by y; -|"y" -[-2] -[-1] -[0] -[1] -[3] - --- 176 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES (-2), (-1), (0), (1), (2); -COMMIT; -SELECT i∨1 AS y FROM t -ORDER BY y; -|"y" -[-1] -[-1] -[1] -[1] -[3] - --- 177 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES (-2), (-1), (0), (1), (2); -COMMIT; -SELECT i&1 FROM t; -|"" -[0] -[1] -[0] -[1] -[0] - --- 178 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES (-2), (-1), (0), (1), (2); -COMMIT; -SELECT i&^1 AS y FROM t -ORDER BY y; -|"y" -[-2] -[-2] -[0] -[0] -[2] - --- S 179 -SELECT * from employee WHERE LastName == "Jones" OR DepartmentID IS NULL -ORDER by LastName DESC; -|"LastName", "DepartmentID" -[Williams ] -[Jones 33] - --- S 180 -SELECT * from employee WHERE LastName != "Jones" && DepartmentID IS NOT NULL -ORDER BY LastName; -|"LastName", "DepartmentID" -[Heisenberg 33] -[Rafferty 31] -[Robinson 34] -[Smith 34] - --- 181 -SELECT 42[0] FROM foo; -||invalid operation.*index of type - --- 182 -SELECT "foo"[-1] FROM foo; -||invalid string index.*index .* non.*negative - --- 183 -SELECT "foo"[3] FROM foo; -||invalid string index.*out of bounds - --- 184 -BEGIN TRANSACTION; - CREATE TABLE foo(i int); -COMMIT; -SELECT "foo"["bar">true] FROM foo; -||mismatched types - --- S 185 -SELECT DepartmentID[0] FROM employee; -||run.time error.*invalid operation.*index of type - --- S 186 -SELECT "foo"[-DepartmentID] FROM employee; -||run.time error.*invalid string index.*index .* non.*negative - --- S 187 -SELECT LastName[100] FROM employee; -||run.time.error.*invalid string index.*out of bounds - --- S 188 -SELECT LastName[0], LastName FROM employee ORDER BY LastName; -|"", "LastName" -[72 Heisenberg] -[74 Jones] -[82 Rafferty] -[82 Robinson] -[83 Smith] -[87 Williams] - --- S 189 -SELECT LastName, string(LastName[0]), string(LastName[1]), string(LastName[2]), string(LastName[3]) -FROM employee -ORDER BY LastName; -|"LastName", "", "", "", "" -[Heisenberg H e i s] -[Jones J o n e] -[Rafferty R a f f] -[Robinson R o b i] -[Smith S m i t] -[Williams W i l l] - --- S 190 -SELECT LastName, LastName[:], LastName[:2], LastName[2:], LastName[1:3] -FROM employee -ORDER by LastName; -|"LastName", "", "", "", "" -[Heisenberg Heisenberg He isenberg ei] -[Jones Jones Jo nes on] -[Rafferty Rafferty Ra fferty af] -[Robinson Robinson Ro binson ob] -[Smith Smith Sm ith mi] -[Williams Williams Wi lliams il] - --- S 191 -SELECT LastName -FROM employee -WHERE department IS NULL; -||unknown field department - --- S 192 -SELECT - DepartmentID, - LastName, - LastName[:4], - LastName[:0*DepartmentID], - LastName[0*DepartmentID:0], - LastName[0*DepartmentID:0*DepartmentID], -FROM - employee, -ORDER BY LastName DESC; -|"DepartmentID", "LastName", "", "", "", "" -[ Williams Will ] -[34 Smith Smit ] -[34 Robinson Robi ] -[31 Rafferty Raff ] -[33 Jones Jone ] -[33 Heisenberg Heis ] - --- S 193 -SELECT - DepartmentID AS x, - DepartmentID<<1 AS a, - 1<>1 AS a, - uint(1)<<63>>uint(DepartmentID) AS b, -FROM - employee, -WHERE DepartmentID IS NOT NULL -ORDER BY x; -|"x", "a", "b" -[31 15 4294967296] -[33 16 1073741824] -[33 16 1073741824] -[34 17 536870912] -[34 17 536870912] - --- S 195 -SELECT DISTINCT DepartmentID -FROM employee -WHERE DepartmentID IS NOT NULL; -|"DepartmentID" -[31] -[33] -[34] - --- S 196 -SELECT DISTINCT e.DepartmentID, d.DepartmentID, e.LastName -FROM employee AS e, department AS d -WHERE e.DepartmentID == d.DepartmentID; -|"e.DepartmentID", "d.DepartmentID", "e.LastName" -[31 31 Rafferty] -[33 33 Heisenberg] -[33 33 Jones] -[34 34 Robinson] -[34 34 Smith] - --- S 197 -SELECT DISTINCT e.DepartmentID, d.DepartmentID, e.LastName -FROM employee AS e, department AS d -WHERE e.DepartmentID == d.DepartmentID -ORDER BY e.LastName; -|"e.DepartmentID", "d.DepartmentID", "e.LastName" -[33 33 Heisenberg] -[33 33 Jones] -[31 31 Rafferty] -[34 34 Robinson] -[34 34 Smith] - --- S 198, http://en.wikipedia.org/wiki/Join_(SQL)#Cross_join -SELECT * -FROM employee, department -ORDER BY employee.LastName, department.DepartmentID; -|"employee.LastName", "employee.DepartmentID", "department.DepartmentID", "department.DepartmentName" -[Heisenberg 33 31 Sales] -[Heisenberg 33 33 Engineering] -[Heisenberg 33 34 Clerical] -[Heisenberg 33 35 Marketing] -[Jones 33 31 Sales] -[Jones 33 33 Engineering] -[Jones 33 34 Clerical] -[Jones 33 35 Marketing] -[Rafferty 31 31 Sales] -[Rafferty 31 33 Engineering] -[Rafferty 31 34 Clerical] -[Rafferty 31 35 Marketing] -[Robinson 34 31 Sales] -[Robinson 34 33 Engineering] -[Robinson 34 34 Clerical] -[Robinson 34 35 Marketing] -[Smith 34 31 Sales] -[Smith 34 33 Engineering] -[Smith 34 34 Clerical] -[Smith 34 35 Marketing] -[Williams 31 Sales] -[Williams 33 Engineering] -[Williams 34 Clerical] -[Williams 35 Marketing] - --- S 199, http://en.wikipedia.org/wiki/Join_(SQL)#Inner_join -SELECT * -FROM employee, department -WHERE employee.DepartmentID == department.DepartmentID -ORDER BY employee.LastName, department.DepartmentID; -|"employee.LastName", "employee.DepartmentID", "department.DepartmentID", "department.DepartmentName" -[Heisenberg 33 33 Engineering] -[Jones 33 33 Engineering] -[Rafferty 31 31 Sales] -[Robinson 34 34 Clerical] -[Smith 34 34 Clerical] - --- S 200 -BEGIN TRANSACTION; - INSERT INTO department (DepartmentID, DepartmentName) - SELECT DepartmentID+1000, DepartmentName+"/headquarters" - FROM department; -COMMIT; -SELECT * FROM department -ORDER BY DepartmentID; -|"DepartmentID", "DepartmentName" -[31 Sales] -[33 Engineering] -[34 Clerical] -[35 Marketing] -[1031 Sales/headquarters] -[1033 Engineering/headquarters] -[1034 Clerical/headquarters] -[1035 Marketing/headquarters] - --- S 201` -BEGIN TRANSACTION; - INSERT INTO department (DepartmentName, DepartmentID) - SELECT DepartmentName+"/headquarters", DepartmentID+1000 - FROM department; -COMMIT; -SELECT * FROM department -ORDER BY DepartmentID; -|"DepartmentID", "DepartmentName" -[31 Sales] -[33 Engineering] -[34 Clerical] -[35 Marketing] -[1031 Sales/headquarters] -[1033 Engineering/headquarters] -[1034 Clerical/headquarters] -[1035 Marketing/headquarters] - --- S 202 -BEGIN TRANSACTION; - DELETE FROM department; -COMMIT; -SELECT * FROM department -|"DepartmentID", "DepartmentName" - --- S 203 -BEGIN TRANSACTION; - DELETE FROM department - WHERE DepartmentID == 35 OR DepartmentName != "" && DepartmentName[0] == 'C'; -COMMIT; -SELECT * FROM department -ORDER BY DepartmentID; -|"DepartmentID", "DepartmentName" -[31 Sales] -[33 Engineering] - --- S 204 -SELECT id(), LastName -FROM employee -ORDER BY id(); -|"", "LastName" -[5 Rafferty] -[6 Jones] -[7 Heisenberg] -[8 Robinson] -[9 Smith] -[10 Williams] - --- S 205 //TODO investigate plan, add variant w/ DESC, check plan. -BEGIN TRANSACTION; - DELETE FROM employee - WHERE LastName == "Jones"; -COMMIT; -SELECT id(), LastName -FROM employee -ORDER BY id(); -|"", "LastName" -[5 Rafferty] -[7 Heisenberg] -[8 Robinson] -[9 Smith] -[10 Williams] - --- S 206 -BEGIN TRANSACTION; - DELETE FROM employee - WHERE LastName == "Jones"; - INSERT INTO employee (LastName) VALUES ("Jones"); -COMMIT; -SELECT id(), LastName -FROM employee -ORDER BY id(); -|"", "LastName" -[5 Rafferty] -[7 Heisenberg] -[8 Robinson] -[9 Smith] -[10 Williams] -[11 Jones] - --- S 207 -SELECT id(), e.LastName, e.DepartmentID, d.DepartmentID -FROM - employee AS e, - department AS d, -WHERE e.DepartmentID == d.DepartmentID -ORDER BY e.LastName; -|"", "e.LastName", "e.DepartmentID", "d.DepartmentID" -[ Heisenberg 33 33] -[ Jones 33 33] -[ Rafferty 31 31] -[ Robinson 34 34] -[ Smith 34 34] - --- S 208 -SELECT e.ID, e.LastName, e.DepartmentID, d.DepartmentID -FROM - (SELECT id() AS ID, LastName, DepartmentID FROM employee;) AS e, - department AS d, -WHERE e.DepartmentID == d.DepartmentID -ORDER BY e.ID; -|"e.ID", "e.LastName", "e.DepartmentID", "d.DepartmentID" -[5 Rafferty 31 31] -[6 Jones 33 33] -[7 Heisenberg 33 33] -[8 Robinson 34 34] -[9 Smith 34 34] - --- S 209 -BEGIN TRANSACTION; - UPDATE none - DepartmentID = DepartmentID+1000, - WHERE DepartmentID == 33; -COMMIT; -SELECT * FROM employee; -||table.*not.*exist - --- S 210 -BEGIN TRANSACTION; - UPDATE employee - FirstName = "Williams" - WHERE DepartmentID == 33; -COMMIT; -SELECT * FROM employee; -||unknown.*FirstName - --- S 211 -BEGIN TRANSACTION; - UPDATE employee - DepartmentID = DepartmentID+1000, - WHERE DepartmentID == 33; -COMMIT; -SELECT * FROM employee -ORDER BY LastName; -|"LastName", "DepartmentID" -[Heisenberg 1033] -[Jones 1033] -[Rafferty 31] -[Robinson 34] -[Smith 34] -[Williams ] - --- S 212 -BEGIN TRANSACTION; - UPDATE employee - DepartmentID = DepartmentID+1000, - LastName = "Mr. "+LastName - WHERE id() == 7; -COMMIT; -SELECT * FROM employee -ORDER BY LastName DESC; -|"LastName", "DepartmentID" -[Williams ] -[Smith 34] -[Robinson 34] -[Rafferty 31] -[Mr. Heisenberg 1033] -[Jones 33] - --- S 213 -BEGIN TRANSACTION; - UPDATE employee - LastName = "Mr. "+LastName, - DepartmentID = DepartmentID+1000, - WHERE id() == 7; -COMMIT; -SELECT * FROM employee -ORDER BY LastName DESC; -|"LastName", "DepartmentID" -[Williams ] -[Smith 34] -[Robinson 34] -[Rafferty 31] -[Mr. Heisenberg 1033] -[Jones 33] - --- S 214 -BEGIN TRANSACTION; - UPDATE employee - DepartmentID = DepartmentID+1000; -COMMIT; -SELECT * FROM employee -ORDER BY LastName; -|"LastName", "DepartmentID" -[Heisenberg 1033] -[Jones 1033] -[Rafferty 1031] -[Robinson 1034] -[Smith 1034] -[Williams ] - --- S 215 -BEGIN TRANSACTION; - UPDATE employee - DepartmentId = DepartmentID+1000; -COMMIT; -SELECT * FROM employee; -||unknown - --- S 216 -BEGIN TRANSACTION; - UPDATE employee - DepartmentID = DepartmentId+1000; -COMMIT; -SELECT * FROM employee; -||unknown - --- S 217 -BEGIN TRANSACTION; - UPDATE employee - DepartmentID = "foo"; -COMMIT; -SELECT * FROM employee; -||type string.*type int64 - --- S 218 -SELECT foo[len()] FROM bar; -||missing argument - --- S 219 -SELECT foo[len(42)] FROM bar; -||invalid argument - --- S 220 -SELECT foo[len(42, 24)] FROM bar; -||too many - --- S 221 -SELECT foo[len("baz")] FROM bar; -||table - --- S 222 -SELECT LastName[len("baz")-4] FROM employee; -||invalid string index - --- S 223 -SELECT LastName[:len(LastName)-3] AS y FROM employee -ORDER BY y; -|"y" -[Heisenb] -[Jo] -[Raffe] -[Robin] -[Sm] -[Willi] - --- S 224 -SELECT complex(float32(DepartmentID+int(id())), 0) AS x, complex(DepartmentID+int(id()), 0) -FROM employee -ORDER by real(x) DESC; -|"x", "" -[(43+0i) (43+0i)] -[(42+0i) (42+0i)] -[(40+0i) (40+0i)] -[(39+0i) (39+0i)] -[(36+0i) (36+0i)] -[ ] - --- S 225 -SELECT real(complex(float32(DepartmentID+int(id())), 0)) AS x, real(complex(DepartmentID+int(id()), 0)) -FROM employee -ORDER BY x DESC; -|"x", "" -[43 43] -[42 42] -[40 40] -[39 39] -[36 36] -[ ] - --- S 226 -SELECT imag(complex(0, float32(DepartmentID+int(id())))) AS x, imag(complex(0, DepartmentID+int(id()))) -FROM employee -ORDER BY x DESC; -|"x", "" -[43 43] -[42 42] -[40 40] -[39 39] -[36 36] -[ ] - --- 227 -BEGIN TRANSACTION; - CREATE TABLE t (c string); - INSERT INTO t VALUES("foo"), ("bar"); - DELETE FROM t WHERE c == "foo"; -COMMIT; -SELECT 100*id(), c FROM t; -|"", "c" -[200 bar] - --- 228 -BEGIN TRANSACTION; - CREATE TABLE a (a int); - CREATE TABLE b (b int); - CREATE TABLE c (c int); - DROP TABLE a; -COMMIT; -SELECT * FROM a; -||table a does not exist - --- 229 -BEGIN TRANSACTION; - CREATE TABLE a (a int); - CREATE TABLE b (b int); - CREATE TABLE c (c int); - DROP TABLE a; -COMMIT; -SELECT * FROM b; -|"b" - --- 230 -BEGIN TRANSACTION; - CREATE TABLE a (a int); - CREATE TABLE b (b int); - CREATE TABLE c (c int); - DROP TABLE a; -COMMIT; -SELECT * FROM c; -|"c" - --- 231 -BEGIN TRANSACTION; - CREATE TABLE a (a int); - CREATE TABLE b (b int); - CREATE TABLE c (c int); - DROP TABLE b; -COMMIT; -SELECT * FROM a; -|"a" - --- 232 -BEGIN TRANSACTION; - CREATE TABLE a (a int); - CREATE TABLE b (b int); - CREATE TABLE c (c int); - DROP TABLE b; -COMMIT; -SELECT * FROM b; -||table b does not exist - --- 233 -BEGIN TRANSACTION; - CREATE TABLE a (a int); - CREATE TABLE b (b int); - CREATE TABLE c (c int); - DROP TABLE b; -COMMIT; -SELECT * FROM c; -|"c" - --- 234 -BEGIN TRANSACTION; - CREATE TABLE a (a int); - CREATE TABLE b (b int); - CREATE TABLE c (c int); - DROP TABLE c; -COMMIT; -SELECT * FROM a; -|"a" - --- 235 -BEGIN TRANSACTION; - CREATE TABLE a (a int); - CREATE TABLE b (b int); - CREATE TABLE c (c int); - DROP TABLE c; -COMMIT; -SELECT * FROM b; -|"b" - --- 236 -BEGIN TRANSACTION; - CREATE TABLE a (a int); - CREATE TABLE b (b int); - CREATE TABLE c (c int); - DROP TABLE c; -COMMIT; -SELECT * FROM c; -||table c does not exist - --- 237 -BEGIN TRANSACTION; - CREATE TABLE a (c int); - INSERT INTO a VALUES (10), (11), (12); - CREATE TABLE b (d int); - INSERT INTO b VALUES (20), (21), (22), (23); -COMMIT; -SELECT * FROM a, b; -|"a.c", "b.d" -[12 23] -[12 22] -[12 21] -[12 20] -[11 23] -[11 22] -[11 21] -[11 20] -[10 23] -[10 22] -[10 21] -[10 20] - --- 238 -BEGIN TRANSACTION; - CREATE TABLE a (c int); - INSERT INTO a VALUES (0), (1), (2); -COMMIT; -SELECT - 9*x2.c AS x2, - 3*x1.c AS x1, - 1*x0.c AS x0, - 9*x2.c + 3*x1.c + x0.c AS y, -FROM - a AS x2, - a AS x1, - a AS x0, -ORDER BY y; -|"x2", "x1", "x0", "y" -[0 0 0 0] -[0 0 1 1] -[0 0 2 2] -[0 3 0 3] -[0 3 1 4] -[0 3 2 5] -[0 6 0 6] -[0 6 1 7] -[0 6 2 8] -[9 0 0 9] -[9 0 1 10] -[9 0 2 11] -[9 3 0 12] -[9 3 1 13] -[9 3 2 14] -[9 6 0 15] -[9 6 1 16] -[9 6 2 17] -[18 0 0 18] -[18 0 1 19] -[18 0 2 20] -[18 3 0 21] -[18 3 1 22] -[18 3 2 23] -[18 6 0 24] -[18 6 1 25] -[18 6 2 26] - --- 239 -BEGIN TRANSACTION; - CREATE TABLE t (c int); - INSERT INTO t VALUES (242); - DELETE FROM t WHERE c != 0; -COMMIT; -SELECT * FROM t -|"c" - --- 240 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES (242), (12, 24); -COMMIT; -||expect - --- 241 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES (24, 2), (1224); -COMMIT; -||expect - --- 242 -BEGIN TRANSACTION; - CREATE TABLE t (i int); -ROLLBACK; -SELECT * from t; -||does not exist - --- 243 -BEGIN TRANSACTION; - CREATE TABLE t (i int); -COMMIT; -BEGIN TRANSACTION; - DROP TABLE T; -COMMIT; -SELECT * from t; -||does not exist - --- 244 -BEGIN TRANSACTION; - CREATE TABLE t (i int); -COMMIT; -BEGIN TRANSACTION; - DROP TABLE t; -ROLLBACK; -SELECT * from t; -|"i" - --- 245 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES (int(1.2)); -COMMIT; -SELECT * FROM t; -||truncated - --- 246 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES (string(65.0)); -COMMIT; -SELECT * FROM t; -||cannot convert - --- 247 -BEGIN TRANSACTION; - CREATE TABLE t (s string); - INSERT INTO t VALUES (string(65)); -COMMIT; -SELECT * FROM t; -|"s" -[A] - --- 248 -BEGIN TRANSACTION; - CREATE TABLE t (i uint32); - INSERT INTO t VALUES (uint32(int8(uint16(0x10F0)))); -COMMIT; -SELECT i == 0xFFFFFFF0 FROM t; -|"" -[true] - --- 249 -BEGIN TRANSACTION; - CREATE TABLE t (s string); - INSERT INTO t VALUES - (string('a')), // "a" - (string(-1)), // "\ufffd" == "\xef\xbf\xbd" - (string(0xf8)), // "\u00f8" == "ø" == "\xc3\xb8" - (string(0x65e5)), // "\u65e5" == "日" == "\xe6\x97\xa5" - ; -COMMIT; -SELECT - id() == 1 && s == "a" OR - id() == 2 && s == "\ufffd" && s == "\xef\xbf\xbd" OR - id() == 3 && s == "\u00f8" && s == "ø" && s == "\xc3\xb8" OR - id() == 4 && s == "\u65e5" && s == "日" && s == "\xe6\x97\xa5" -FROM t; -|"" -[true] -[true] -[true] -[true] - --- 250 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES (0); -COMMIT; -SELECT 2.3+1, 1+2.3 FROM t; -|"", "" -[3.3 3.3] - --- 251 -BEGIN TRANSACTION; - CREATE TABLE t (i byte); - INSERT INTO t VALUES (-1+byte(2)); -COMMIT; -SELECT * FROM t; -||mismatched - --- 252 -BEGIN TRANSACTION; - CREATE TABLE t (i byte); - INSERT INTO t VALUES (1+byte(2)); -COMMIT; -SELECT * FROM t; -|"i" -[3] - --- 253 -BEGIN TRANSACTION; - CREATE TABLE t (i byte); - INSERT INTO t VALUES (255+byte(2)); -COMMIT; -SELECT * FROM t; -|"i" -[1] - --- 254 -BEGIN TRANSACTION; - CREATE TABLE t (i byte); - INSERT INTO t VALUES (256+byte(2)); -COMMIT; -SELECT * FROM t; -||mismatched - --- 255 -BEGIN TRANSACTION; - CREATE TABLE t (i int8); - INSERT INTO t VALUES (127+int8(2)); -COMMIT; -SELECT * FROM t; -|"i" -[-127] - --- 256 -BEGIN TRANSACTION; - CREATE TABLE t (i int8); - INSERT INTO t VALUES (-129+int8(2)); -COMMIT; -SELECT * FROM t; -||mismatched - --- 257 -BEGIN TRANSACTION; - CREATE TABLE t (i int8); - INSERT INTO t VALUES (-128+int8(2)); -COMMIT; -SELECT * FROM t; -|"i" -[-126] - --- 258 -BEGIN TRANSACTION; - CREATE TABLE t (i int8); - INSERT INTO t VALUES (128+int8(2)); -COMMIT; -SELECT * FROM t; -||mismatched - --- S 259 -SELECT count(none) FROM employee; -||unknown - --- S 260 -SELECT count() FROM employee; -|"" -[6] - --- S 261 -SELECT count() AS y FROM employee; -|"y" -[6] - --- S 262 -SELECT 3*count() AS y FROM employee; -|"y" -[18] - --- S 263 -SELECT count(LastName) FROM employee; -|"" -[6] - --- S 264 -SELECT count(DepartmentID) FROM employee; -|"" -[5] - --- S 265 -SELECT count() - count(DepartmentID) FROM employee; -|"" -[1] - --- S 266 -SELECT min(LastName), min(DepartmentID) FROM employee; -|"", "" -[Heisenberg 31] - --- S 267 -SELECT max(LastName), max(DepartmentID) FROM employee; -|"", "" -[Williams 34] - --- S 268 -SELECT sum(LastName), sum(DepartmentID) FROM employee; -||cannot - --- S 269 -SELECT sum(DepartmentID) FROM employee; -|"" -[165] - --- S 270 -SELECT avg(DepartmentID) FROM employee; -|"" -[33] - --- S 271 -SELECT DepartmentID FROM employee GROUP BY none; -||unknown - --- S 272 -SELECT DepartmentID, sum(DepartmentID) AS s FROM employee GROUP BY DepartmentID ORDER BY s DESC; -|"DepartmentID", "s" -[34 68] -[33 66] -[31 31] -[ ] - --- S 273 -SELECT DepartmentID, count(LastName+string(DepartmentID)) AS y FROM employee GROUP BY DepartmentID ORDER BY y DESC ; -|"DepartmentID", "y" -[34 2] -[33 2] -[31 1] -[ 0] - --- S 274 -SELECT DepartmentID, sum(2*DepartmentID) AS s FROM employee GROUP BY DepartmentID ORDER BY s DESC; -|"DepartmentID", "s" -[34 136] -[33 132] -[31 62] -[ ] - --- S 275 -SELECT min(2*DepartmentID) FROM employee; -|"" -[62] - --- S 276 -SELECT max(2*DepartmentID) FROM employee; -|"" -[68] - --- S 277 -SELECT avg(2*DepartmentID) FROM employee; -|"" -[66] - --- S 278 -SELECT * FROM employee GROUP BY DepartmentID; -|"LastName", "DepartmentID" -[Williams ] -[Rafferty 31] -[Heisenberg 33] -[Smith 34] - --- S 279 -SELECT * FROM employee GROUP BY DepartmentID ORDER BY LastName DESC; -|"LastName", "DepartmentID" -[Williams ] -[Smith 34] -[Rafferty 31] -[Heisenberg 33] - --- S 280 -SELECT * FROM employee GROUP BY DepartmentID, LastName ORDER BY LastName DESC; -|"LastName", "DepartmentID" -[Williams ] -[Smith 34] -[Robinson 34] -[Rafferty 31] -[Jones 33] -[Heisenberg 33] - --- S 281 -SELECT * FROM employee GROUP BY LastName, DepartmentID ORDER BY LastName DESC; -|"LastName", "DepartmentID" -[Williams ] -[Smith 34] -[Robinson 34] -[Rafferty 31] -[Jones 33] -[Heisenberg 33] - --- 282 -BEGIN TRANSACTION; - CREATE TABLE s (i int); - CREATE TABLE t (i int); -COMMIT; -BEGIN TRANSACTION; - DROP TABLE s; -COMMIT; -SELECT * FROM t; -|"i" - --- 283 -BEGIN TRANSACTION; - CREATE TABLE t (n int); -COMMIT; -SELECT count() FROM t; -|"" -[0] - --- 284 -BEGIN TRANSACTION; - CREATE TABLE t (n int); - INSERT INTO t VALUES (0), (1); -COMMIT; -SELECT count() FROM t; -|"" -[2] - --- 285 -BEGIN TRANSACTION; - CREATE TABLE t (n int); - INSERT INTO t VALUES (0), (1); -COMMIT; -SELECT count() FROM t WHERE n < 2; -|"" -[2] - --- 286 -BEGIN TRANSACTION; - CREATE TABLE t (n int); - INSERT INTO t VALUES (0), (1); -COMMIT; -SELECT count() FROM t WHERE n < 1; -|"" -[1] - --- 287 -BEGIN TRANSACTION; - CREATE TABLE t (n int); - INSERT INTO t VALUES (0), (1); -COMMIT; -SELECT count() FROM t WHERE n < 0; -|"" -[0] - --- 288 -BEGIN TRANSACTION; - CREATE TABLE t (n int); - INSERT INTO t VALUES (0), (1); -COMMIT; -SELECT s+10 FROM (SELECT sum(n) AS s FROM t WHERE n < 2); -|"" -[11] - --- 289 -BEGIN TRANSACTION; - CREATE TABLE t (n int); - INSERT INTO t VALUES (0), (1); -COMMIT; -SELECT s+10 FROM (SELECT sum(n) AS s FROM t WHERE n < 1); -|"" -[10] - --- 290 -BEGIN TRANSACTION; - CREATE TABLE t (n int); - INSERT INTO t VALUES (0), (1); -COMMIT; -SELECT s+10 FROM (SELECT sum(n) AS s FROM t WHERE n < 0); -|"" -[] - --- 291 -BEGIN TRANSACTION; - CREATE TABLE t (n int); - INSERT INTO t VALUES (0), (1); -COMMIT; -SELECT sum(n) AS s FROM t WHERE n < 2; -|"s" -[1] - --- 292 -BEGIN TRANSACTION; - CREATE TABLE t (n int); - INSERT INTO t VALUES (0), (1); -COMMIT; -SELECT sum(n) AS s FROM t WHERE n < 1; -|"s" -[0] - --- 293 -BEGIN TRANSACTION; - CREATE TABLE t (n int); - INSERT INTO t VALUES (0), (1); -COMMIT; -SELECT sum(n) AS s FROM t WHERE n < 0; -|"s" -[] - --- 294 -BEGIN TRANSACTION; - CREATE TABLE t (n int); - INSERT INTO t SELECT count() FROM t; - INSERT INTO t SELECT count() FROM t; - INSERT INTO t SELECT count() FROM t; -COMMIT; -SELECT count() FROM t; -|"" -[3] - --- 295 -BEGIN TRANSACTION; - CREATE TABLE t (n int); - INSERT INTO t SELECT count() FROM t; - INSERT INTO t SELECT count() FROM t; - INSERT INTO t SELECT count() FROM t; - INSERT INTO t SELECT * FROM t; -COMMIT; -SELECT count() FROM t; -|"" -[6] - --- 296 -BEGIN TRANSACTION; - CREATE TABLE t (n int); - INSERT INTO t VALUES (0), (1), (2); - INSERT INTO t SELECT * FROM t; -COMMIT; -SELECT count() FROM t; -|"" -[6] - --- 297 -BEGIN TRANSACTION; - CREATE TABLE t(S string); - INSERT INTO t SELECT "perfect!" FROM (SELECT count() AS cnt FROM t WHERE S == "perfect!") WHERE cnt == 0; -COMMIT; -SELECT count() FROM t; -|"" -[1] - --- 298 -BEGIN TRANSACTION; - CREATE TABLE t(S string); - INSERT INTO t SELECT "perfect!" FROM (SELECT count() AS cnt FROM t WHERE S == "perfect!") WHERE cnt == 0; - INSERT INTO t SELECT "perfect!" FROM (SELECT count() AS cnt FROM t WHERE S == "perfect!") WHERE cnt == 0; -COMMIT; -SELECT count() FROM t; -|"" -[1] - --- 299 -BEGIN TRANSACTION; - CREATE TABLE t(c blob); - INSERT INTO t VALUES (blob("a")); -COMMIT; -SELECT * FROM t; -|"c" -[[97]] - --- 300 -BEGIN TRANSACTION; - CREATE TABLE t(c blob); - INSERT INTO t VALUES (blob(` -0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef -`)); -COMMIT; -SELECT * FROM t; -|"c" -[[10 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 10]] - --- 301 -BEGIN TRANSACTION; - CREATE TABLE t(c blob); - INSERT INTO t VALUES (blob( -"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ -"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ -"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ -"0123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF")); -COMMIT; -SELECT * FROM t; -|"c" -[[48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 65 66 67 68 69 70]] - --- 302 -BEGIN TRANSACTION; - CREATE TABLE t(c blob); - INSERT INTO t VALUES (blob( -"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ -"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ -"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ -"0123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF"+ -"!")); -COMMIT; -SELECT * FROM t; -|"c" -[[48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 65 66 67 68 69 70 33]] - --- 303 -BEGIN TRANSACTION; - CREATE TABLE t(c blob); - INSERT INTO t VALUES (blob("hell\xc3\xb8")); -COMMIT; -SELECT string(c) FROM t; -|"" -[hellø] - --- 304 -BEGIN TRANSACTION; - CREATE TABLE t(c blob); - INSERT INTO t VALUES (blob( -"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ -"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ -"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ -"0123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF"+ -"!")); -COMMIT; -SELECT string(c) FROM t; -|"" -[0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!] - --- 305 -BEGIN TRANSACTION; - CREATE TABLE t(c blob); - INSERT INTO t VALUES (blob("")); -COMMIT; -SELECT string(c) FROM t; -|"" -[] - --- 306 -BEGIN TRANSACTION; - CREATE TABLE t(c blob); - INSERT INTO t VALUES (blob("hellø")); -COMMIT; -SELECT * FROM t; -|"c" -[[104 101 108 108 195 184]] - --- 307 -BEGIN TRANSACTION; - CREATE TABLE t(c blob); - INSERT INTO t VALUES (blob("")); -COMMIT; -SELECT * FROM t; -|"c" -[[]] - --- 308 -BEGIN TRANSACTION; - CREATE TABLE t(i int, b blob); - INSERT INTO t VALUES - (0, blob("0")), - ; -COMMIT; -SELECT * FROM t; -|"i", "b" -[0 [48]] - --- 309 -BEGIN TRANSACTION; - CREATE TABLE t(i int, b blob); - INSERT INTO t VALUES - (0, blob("0")), - (1, blob("1")), - ; -COMMIT; -SELECT * FROM t; -|"i", "b" -[1 [49]] -[0 [48]] - --- 310 -BEGIN TRANSACTION; - CREATE TABLE t(i int, b blob); - INSERT INTO t VALUES - (0, blob("0")), - (1, blob("1")), - (2, blob("2")), - ; -COMMIT; -SELECT * FROM t; -|"i", "b" -[2 [50]] -[1 [49]] -[0 [48]] - --- 311 -BEGIN TRANSACTION; - CREATE TABLE t(i int, b blob); - INSERT INTO t VALUES - (0, blob("0")), - ; - DELETE FROM t WHERE i == 0; -COMMIT; -SELECT * FROM t; -|"i", "b" - --- 312 -BEGIN TRANSACTION; - CREATE TABLE t(i int, b blob); - INSERT INTO t VALUES - (0, blob("0")), - (1, blob("1")), - ; - DELETE FROM t WHERE i == 0; -COMMIT; -SELECT * FROM t; -|"i", "b" -[1 [49]] - --- 313 -BEGIN TRANSACTION; - CREATE TABLE t(i int, b blob); - INSERT INTO t VALUES - (0, blob("0")), - (1, blob("1")), - ; - DELETE FROM t WHERE i == 1; -COMMIT; -SELECT * FROM t; -|"i", "b" -[0 [48]] - --- 314 -BEGIN TRANSACTION; - CREATE TABLE t(i int, b blob); - INSERT INTO t VALUES - (0, blob("0")), - (1, blob("1")), - (2, blob("2")), - ; - DELETE FROM t WHERE i == 0; -COMMIT; -SELECT * FROM t; -|"i", "b" -[2 [50]] -[1 [49]] - --- 315 -BEGIN TRANSACTION; - CREATE TABLE t(i int, b blob); - INSERT INTO t VALUES - (0, blob("0")), - (1, blob("1")), - (2, blob("2")), - ; - DELETE FROM t WHERE i == 1; -COMMIT; -SELECT * FROM t; -|"i", "b" -[2 [50]] -[0 [48]] - --- 316 -BEGIN TRANSACTION; - CREATE TABLE t(i int, b blob); - INSERT INTO t VALUES - (0, blob("0")), - (1, blob("1")), - (2, blob("2")), - ; - DELETE FROM t WHERE i == 2; -COMMIT; -SELECT * FROM t; -|"i", "b" -[1 [49]] -[0 [48]] - --- 317 -BEGIN TRANSACTION; - CREATE TABLE t(i int, b blob); - INSERT INTO t VALUES - (0, blob( - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!")), - ; - DELETE FROM t WHERE i == 0; -COMMIT; -SELECT i, string(b) FROM t; -|"i", "" - --- 318 -BEGIN TRANSACTION; - CREATE TABLE t(i int, b blob); - INSERT INTO t VALUES - (0, blob( - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!")), - (1, blob( - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!")), - ; - DELETE FROM t WHERE i == 0; -COMMIT; -SELECT i, string(b) FROM t; -|"i", "" -[1 1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef1123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!] - --- 319 -BEGIN TRANSACTION; - CREATE TABLE t(i int, b blob); - INSERT INTO t VALUES - (0, blob( - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!")), - (1, blob( - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!")), - ; - DELETE FROM t WHERE i == 1; -COMMIT; -SELECT i, string(b) FROM t; -|"i", "" -[0 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!] - --- 320 -BEGIN TRANSACTION; - CREATE TABLE t(i int, b blob); - INSERT INTO t VALUES - (0, blob( - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!")), - (1, blob( - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!")), - (2, blob( - "2123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "2123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "2123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "2123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!")), - ; - DELETE FROM t WHERE i == 0; -COMMIT; -SELECT i, string(b) FROM t; -|"i", "" -[2 2123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef2123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef2123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef2123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!] -[1 1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef1123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!] - --- 321 -BEGIN TRANSACTION; - CREATE TABLE t(i int, b blob); - INSERT INTO t VALUES - (0, blob( - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!")), - (1, blob( - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!")), - (2, blob( - "2123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "2123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "2123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "2123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!")), - ; - DELETE FROM t WHERE i == 1; -COMMIT; -SELECT i, string(b) FROM t; -|"i", "" -[2 2123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef2123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef2123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef2123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!] -[0 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!] - --- 322 -BEGIN TRANSACTION; - CREATE TABLE t(i int, b blob); - INSERT INTO t VALUES - (0, blob( - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!")), - (1, blob( - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!")), - (2, blob( - "2123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "2123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "2123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "2123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!")), - ; - DELETE FROM t WHERE i == 2; -COMMIT; -SELECT i, string(b) FROM t; -|"i", "" -[1 1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef1123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!] -[0 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!] - --- 323 -BEGIN TRANSACTION; - CREATE TABLE t (c bool); - INSERT INTO t VALUES (false), (true); -COMMIT; -SELECT * FROM t ORDER BY true, c, false; -||cannot .* bool - --- 324 -BEGIN TRANSACTION; - CREATE TABLE t (c bool, i int); - INSERT INTO t VALUES (false, 1), (true, 2), (false, 10), (true, 20); -COMMIT; -SELECT c, sum(i) FROM t GROUP BY c; -|"c", "" -[false 11] -[true 22] - --- 325 -BEGIN TRANSACTION; - CREATE TABLE t (c int8); - INSERT INTO t VALUES (1), (2); -COMMIT; -SELECT * FROM t ORDER BY 42, c, 24; -|"c" -[1] -[2] - --- 326 -BEGIN TRANSACTION; - CREATE TABLE t (c int8, i int); - INSERT INTO t VALUES (99, 1), (100, 2), (99, 10), (100, 20); -COMMIT; -SELECT c, sum(i) FROM t GROUP BY c; -|"c", "" -[99 11] -[100 22] - --- 327 -BEGIN TRANSACTION; - CREATE TABLE t (c blob); - INSERT INTO t VALUES (blob("A")), (blob("B")); -COMMIT; -SELECT * FROM t ORDER BY 42, c, 24; -||cannot .* \[\]uint8 - --- 328 -BEGIN TRANSACTION; - CREATE TABLE t (c blob, i int); - INSERT INTO t VALUES (blob("A"), 1), (blob("B"), 2); -COMMIT; -SELECT c, sum(i) FROM t GROUP BY c; -|"c", "" -[[65] 1] -[[66] 2] - --- 329 -BEGIN TRANSACTION; - CREATE TABLE t (c blob, i int); - INSERT INTO t VALUES (blob("A"), 10), (blob("B"), 20); -COMMIT; -SELECT c, sum(i) FROM t GROUP BY c; -|"c", "" -[[65] 10] -[[66] 20] - --- 330 -BEGIN TRANSACTION; - CREATE TABLE t (c blob, i int); - INSERT INTO t VALUES (blob("A"), 1), (blob("B"), 2), (blob("A"), 10), (blob("B"), 20); -COMMIT; -SELECT * FROM t; -|"c", "i" -[[66] 20] -[[65] 10] -[[66] 2] -[[65] 1] - --- 331 -BEGIN TRANSACTION; - CREATE TABLE t (c string, i int); - INSERT INTO t VALUES ("A", 1), ("B", 2), ("A", 10), ("B", 20); -COMMIT; -SELECT c, sum(i) FROM t GROUP BY c; -|"c", "" -[A 11] -[B 22] - --- 332 -BEGIN TRANSACTION; - CREATE TABLE t (c blob, i int); - INSERT INTO t VALUES (blob("A"), 1), (blob("B"), 2), (blob("A"), 10), (blob("B"), 20); -COMMIT; -SELECT c, sum(i) FROM t GROUP BY c; -|"c", "" -[[65] 11] -[[66] 22] - --- 333 -BEGIN TRANSACTION; - CREATE TABLE t (c byte); - INSERT INTO t VALUES (42), (314); -COMMIT; -SELECT * FROM t ORDER BY 15, c, 16; -||overflow - --- 334 -BEGIN TRANSACTION; - CREATE TABLE t (c byte); - INSERT INTO t VALUES (42), (114); -COMMIT; -SELECT * FROM t ORDER BY 15, c, 16; -|"c" -[42] -[114] - --- 335 -BEGIN TRANSACTION; - CREATE TABLE t (c byte, i int); - INSERT INTO t VALUES (100, 1), (101, 2), (100, 10), (101, 20); -COMMIT; -SELECT c, sum(i) FROM t GROUP BY c; -|"c", "" -[100 11] -[101 22] - --- 336 -BEGIN TRANSACTION; - CREATE TABLE t (c byte); - INSERT INTO t VALUES (42), (3.14); -COMMIT; -SELECT * FROM t ORDER BY 15, c, 16; -||truncated - --- 337 -BEGIN TRANSACTION; - CREATE TABLE t (c complex64); - INSERT INTO t VALUES (42), (114); -COMMIT; -SELECT * FROM t ORDER BY 15, c, 16; -||cannot order by - --- 338 -BEGIN TRANSACTION; - CREATE TABLE t (c complex64, i int); - INSERT INTO t VALUES (100, 1), (101, 2), (100, 10), (101, 20); -COMMIT; -SELECT c, sum(i) FROM t GROUP BY c; -|"c", "" -[(100+0i) 11] -[(101+0i) 22] - --- 339 -BEGIN TRANSACTION; - CREATE TABLE t (c complex128); - INSERT INTO t VALUES (42), (114); -COMMIT; -SELECT * FROM t ORDER BY 15, c, 16; -||cannot order by - --- 340 -BEGIN TRANSACTION; - CREATE TABLE t (c complex128, i int); - INSERT INTO t VALUES (100, 1), (101, 2), (100, 10), (101, 20); -COMMIT; -SELECT c, sum(i) FROM t GROUP BY c; -|"c", "" -[(100+0i) 11] -[(101+0i) 22] - --- 341 -BEGIN TRANSACTION; - CREATE TABLE t (c float); - INSERT INTO t VALUES (42), (114); -COMMIT; -SELECT * FROM t ORDER BY 15, c, 16; -|"c" -[42] -[114] - --- 342 -BEGIN TRANSACTION; - CREATE TABLE t (c float, i int); - INSERT INTO t VALUES (100, 1), (101, 2), (100, 10), (101, 20); -COMMIT; -SELECT c, sum(i) FROM t GROUP BY c; -|"c", "" -[100 11] -[101 22] - --- 343 -BEGIN TRANSACTION; - CREATE TABLE t (c float64); - INSERT INTO t VALUES (42), (114); -COMMIT; -SELECT * FROM t ORDER BY 15, c, 16; -|"c" -[42] -[114] - --- 344 -BEGIN TRANSACTION; - CREATE TABLE t (c float64, i int); - INSERT INTO t VALUES (100, 1), (101, 2), (100, 10), (101, 20); -COMMIT; -SELECT c, sum(i) FROM t GROUP BY c; -|"c", "" -[100 11] -[101 22] - --- 345 -BEGIN TRANSACTION; - CREATE TABLE t (c float32); - INSERT INTO t VALUES (42), (114); -COMMIT; -SELECT * FROM t ORDER BY 15, c, 16; -|"c" -[42] -[114] - --- 346 -BEGIN TRANSACTION; - CREATE TABLE t (c float32, i int); - INSERT INTO t VALUES (100, 1), (101, 2), (100, 10), (101, 20); -COMMIT; -SELECT c, sum(i) FROM t GROUP BY c; -|"c", "" -[100 11] -[101 22] - --- 347 -BEGIN TRANSACTION; - CREATE TABLE t (c int); - INSERT INTO t VALUES (42), (114); -COMMIT; -SELECT * FROM t ORDER BY 15, c, 16; -|"c" -[42] -[114] - --- 348 -BEGIN TRANSACTION; - CREATE TABLE t (c int, i int); - INSERT INTO t VALUES (100, 1), (101, 2), (100, 10), (101, 20); -COMMIT; -SELECT c, sum(i) FROM t GROUP BY c; -|"c", "" -[100 11] -[101 22] - --- 349 -BEGIN TRANSACTION; - CREATE TABLE t (c int64); - INSERT INTO t VALUES (42), (114); -COMMIT; -SELECT * FROM t ORDER BY 15, c, 16; -|"c" -[42] -[114] - --- 350 -BEGIN TRANSACTION; - CREATE TABLE t (c int64, i int); - INSERT INTO t VALUES (100, 1), (101, 2), (100, 10), (101, 20); -COMMIT; -SELECT c, sum(i) FROM t GROUP BY c; -|"c", "" -[100 11] -[101 22] - --- 351 -BEGIN TRANSACTION; - CREATE TABLE t (c int8); - INSERT INTO t VALUES (42), (114); -COMMIT; -SELECT * FROM t ORDER BY 15, c, 16; -|"c" -[42] -[114] - --- 352 -BEGIN TRANSACTION; - CREATE TABLE t (c int8, i int); - INSERT INTO t VALUES (100, 1), (101, 2), (100, 10), (101, 20); -COMMIT; -SELECT c, sum(i) FROM t GROUP BY c; -|"c", "" -[100 11] -[101 22] - --- 353 -BEGIN TRANSACTION; - CREATE TABLE t (c int16); - INSERT INTO t VALUES (42), (114); -COMMIT; -SELECT * FROM t ORDER BY 15, c, 16; -|"c" -[42] -[114] - --- 354 -BEGIN TRANSACTION; - CREATE TABLE t (c int16, i int); - INSERT INTO t VALUES (100, 1), (101, 2), (100, 10), (101, 20); -COMMIT; -SELECT c, sum(i) FROM t GROUP BY c; -|"c", "" -[100 11] -[101 22] - --- 355 -BEGIN TRANSACTION; - CREATE TABLE t (c int32); - INSERT INTO t VALUES (42), (114); -COMMIT; -SELECT * FROM t ORDER BY 15, c, 16; -|"c" -[42] -[114] - --- 356 -BEGIN TRANSACTION; - CREATE TABLE t (c int32, i int); - INSERT INTO t VALUES (100, 1), (101, 2), (100, 10), (101, 20); -COMMIT; -SELECT c, sum(i) FROM t GROUP BY c; -|"c", "" -[100 11] -[101 22] - --- 357 -BEGIN TRANSACTION; - CREATE TABLE t (c uint); - INSERT INTO t VALUES (42), (114); -COMMIT; -SELECT * FROM t ORDER BY 15, c, 16; -|"c" -[42] -[114] - --- 358 -BEGIN TRANSACTION; - CREATE TABLE t (c uint, i int); - INSERT INTO t VALUES (100, 1), (101, 2), (100, 10), (101, 20); -COMMIT; -SELECT c, sum(i) FROM t GROUP BY c; -|"c", "" -[100 11] -[101 22] - --- 359 -BEGIN TRANSACTION; - CREATE TABLE t (c uint64); - INSERT INTO t VALUES (42), (114); -COMMIT; -SELECT * FROM t ORDER BY 15, c, 16; -|"c" -[42] -[114] - --- 360 -BEGIN TRANSACTION; - CREATE TABLE t (c uint64, i int); - INSERT INTO t VALUES (100, 1), (101, 2), (100, 10), (101, 20); -COMMIT; -SELECT c, sum(i) FROM t GROUP BY c; -|"c", "" -[100 11] -[101 22] - --- 361 -BEGIN TRANSACTION; - CREATE TABLE t (c uint8); - INSERT INTO t VALUES (42), (114); -COMMIT; -SELECT * FROM t ORDER BY 15, c, 16; -|"c" -[42] -[114] - --- 362 -BEGIN TRANSACTION; - CREATE TABLE t (c uint8, i int); - INSERT INTO t VALUES (100, 1), (101, 2), (100, 10), (101, 20); -COMMIT; -SELECT c, sum(i) FROM t GROUP BY c; -|"c", "" -[100 11] -[101 22] - --- 363 -BEGIN TRANSACTION; - CREATE TABLE t (c uint16); - INSERT INTO t VALUES (42), (114); -COMMIT; -SELECT * FROM t ORDER BY 15, c, 16; -|"c" -[42] -[114] - --- 364 -BEGIN TRANSACTION; - CREATE TABLE t (c uint16, i int); - INSERT INTO t VALUES (100, 1), (101, 2), (100, 10), (101, 20); -COMMIT; -SELECT c, sum(i) FROM t GROUP BY c; -|"c", "" -[100 11] -[101 22] - --- 365 -BEGIN TRANSACTION; - CREATE TABLE t (c uint32); - INSERT INTO t VALUES (42), (114); -COMMIT; -SELECT * FROM t ORDER BY 15, c, 16; -|"c" -[42] -[114] - --- 366 -BEGIN TRANSACTION; - CREATE TABLE t (c uint32, i int); - INSERT INTO t VALUES (100, 1), (101, 2), (100, 10), (101, 20); -COMMIT; -SELECT c, sum(i) FROM t GROUP BY c; -|"c", "" -[100 11] -[101 22] - --- 367 -BEGIN TRANSACTION; - CREATE TABLE t (c blob, i int); - INSERT INTO t VALUES (blob("A"), 1), (blob("B"), 2); - UPDATE t c = blob("C") WHERE i == 2; -COMMIT; -SELECT * FROM t; -|"c", "i" -[[67] 2] -[[65] 1] - --- 368 -BEGIN TRANSACTION; - CREATE TABLE t (c blob, i int); - INSERT INTO t VALUES - (blob( - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!" - ), 1), - (blob( - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!" - ), 2); - UPDATE t c = blob( - "2123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "2123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "2123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "2123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!" - ) WHERE i == 2; -COMMIT; -SELECT * FROM t; -|"c", "i" -[[50 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 50 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 50 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 50 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 65 66 67 68 69 70 33] 2] -[[48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 65 66 67 68 69 70 33] 1] - --- 369 -BEGIN TRANSACTION; - CREATE TABLE t (c blob, i int); - INSERT INTO t VALUES - (blob( - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!" - ), 1), - (blob( - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "1123456789abcdef0123456789abcdef0123456789abcdef0123456789ABCDEF!" - ), 2); - UPDATE t i = 42 WHERE i == 2; -COMMIT; -SELECT * FROM t; -|"c", "i" -[[49 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 49 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 49 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 49 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 65 66 67 68 69 70 33] 42] -[[48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 97 98 99 100 101 102 48 49 50 51 52 53 54 55 56 57 65 66 67 68 69 70 33] 1] - --- 370 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - INSERT INTO t VALUES (1); -COMMIT; -SELECT * FROM t; -|"i" -[1] - --- 371 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - INSERT INTO t VALUES (bigint("1")); -COMMIT; -SELECT * FROM t; -|"i" -[1] - --- 372 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - INSERT INTO t VALUES (bigint("12345678901234567890123456789")); -COMMIT; -SELECT * FROM t; -|"i" -[12345678901234567890123456789] - --- 373 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - INSERT INTO t VALUES (bigint(2e10)); -COMMIT; -SELECT * FROM t; -|"i" -[20000000000] - --- 374 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - INSERT INTO t VALUES (bigint(2e18)); -COMMIT; -SELECT * FROM t; -|"i" -[2000000000000000000] - --- 375 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - INSERT INTO t VALUES (bigint(2e19)); -COMMIT; -SELECT * FROM t; -|"i" -[20000000000000000000] - --- 376 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - INSERT INTO t VALUES (bigint(2e20)); -COMMIT; -SELECT * FROM t; -|"i" -[200000000000000000000] - --- 377 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - INSERT INTO t VALUES (bigint("0x1fffffffffffffff")); -COMMIT; -SELECT * FROM t; -|"i" -[2305843009213693951] - --- 378 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - INSERT INTO t VALUES (bigint("0x1ffffffffffffffffffffff")); -COMMIT; -SELECT * FROM t; -|"i" -[618970019642690137449562111] - --- 379 -BEGIN TRANSACTION; - CREATE TABLE t (c bigint); - INSERT INTO t VALUES (42), (114); -COMMIT; -SELECT * FROM t ORDER BY 15, c, 16; -|"c" -[42] -[114] - --- 380 -BEGIN TRANSACTION; - CREATE TABLE t (c bigint, i int); - INSERT INTO t VALUES (100, 1), (101, 2), (100, 10), (101, 20); -COMMIT; -SELECT c, sum(i) FROM t GROUP BY c; -|"c", "" -[100 11] -[101 22] - --- 381 -BEGIN TRANSACTION; - CREATE TABLE t (c bigint); - INSERT INTO t VALUES (100), (101), (110), (111); -COMMIT; -SELECT * FROM t WHERE c > 100 ORDER BY c DESC; -|"c" -[111] -[110] -[101] - --- 382 -BEGIN TRANSACTION; - CREATE TABLE t (c bigint); - INSERT INTO t VALUES (100), (101), (110), (111); -COMMIT; -SELECT * FROM t WHERE c < 110 ORDER BY c; -|"c" -[100] -[101] - --- 383 -BEGIN TRANSACTION; - CREATE TABLE t (c bigint); - INSERT INTO t VALUES (100), (101), (110), (111); -COMMIT; -SELECT * FROM t WHERE c <= 110 ORDER BY c; -|"c" -[100] -[101] -[110] - --- 384 -BEGIN TRANSACTION; - CREATE TABLE t (c bigint); - INSERT INTO t VALUES (100), (101), (110), (111); -COMMIT; -SELECT * FROM t WHERE c >= 110 ORDER BY c; -|"c" -[110] -[111] - --- 385 -BEGIN TRANSACTION; - CREATE TABLE t (c bigint); - INSERT INTO t VALUES (100), (101), (110), (111); -COMMIT; -SELECT * FROM t WHERE c != 110 ORDER BY c; -|"c" -[100] -[101] -[111] - --- 386 -BEGIN TRANSACTION; - CREATE TABLE t (c bigint); - INSERT INTO t VALUES (100), (101), (110), (111); -COMMIT; -SELECT * FROM t WHERE c == 110 ORDER BY c; -|"c" -[110] - --- 387 -BEGIN TRANSACTION; - CREATE TABLE t (c bigint); - INSERT INTO t VALUES (100), (101), (110), (111); -COMMIT; -SELECT (c+1000) as s FROM t ORDER BY s; -|"s" -[1100] -[1101] -[1110] -[1111] - --- 388 -BEGIN TRANSACTION; - CREATE TABLE t (c bigint); - INSERT INTO t VALUES (100), (101), (110), (111); -COMMIT; -SELECT (1000-c) as s FROM t ORDER BY s; -|"s" -[889] -[890] -[899] -[900] - --- 389 -BEGIN TRANSACTION; - CREATE TABLE t (c bigint); - INSERT INTO t VALUES (100), (101), (110), (111); -COMMIT; -SELECT (c>>1) as s FROM t ORDER BY s; -|"s" -[50] -[50] -[55] -[55] - --- 390 -BEGIN TRANSACTION; - CREATE TABLE t (c bigint); - INSERT INTO t VALUES (100), (101), (110), (111); -COMMIT; -SELECT (c<<1) as s FROM t ORDER BY s; -|"s" -[200] -[202] -[220] -[222] - --- 391 -BEGIN TRANSACTION; - CREATE TABLE t (c bigint); - INSERT INTO t VALUES (0x137f0); -COMMIT; -SELECT * FROM t WHERE c&0x55555 == 0x11550; -|"c" -[79856] - --- 392 -BEGIN TRANSACTION; - CREATE TABLE t (c bigint); - INSERT INTO t VALUES (0x137f0); -COMMIT; -SELECT * FROM t WHERE c∨0x55555 == 0x577f5; -|"c" -[79856] - --- 393 -BEGIN TRANSACTION; - CREATE TABLE t (c bigint); - INSERT INTO t VALUES (0x137f0); -COMMIT; -SELECT * FROM t WHERE c&^0x55555 == 0x022a0; -|"c" -[79856] - --- 394 -BEGIN TRANSACTION; - CREATE TABLE t (c bigint); - INSERT INTO t VALUES (0x137f0); -COMMIT; -SELECT * FROM t WHERE c^0x55555 == 0x462a5; -|"c" -[79856] - --- 395 -BEGIN TRANSACTION; - CREATE TABLE t (c bigint); - INSERT INTO t VALUES (0x137f0); -COMMIT; -SELECT * FROM t WHERE c%256 == 0xf0; -|"c" -[79856] - --- 396 -BEGIN TRANSACTION; - CREATE TABLE t (c bigint); - INSERT INTO t VALUES (0x137f0); -COMMIT; -SELECT * FROM t WHERE c*16 == 0x137f00; -|"c" -[79856] - --- 397 -BEGIN TRANSACTION; - CREATE TABLE t (c bigint); - INSERT INTO t VALUES (0x137f0); -COMMIT; -SELECT * FROM t WHERE ^c == -(0x137f0+1); -|"c" -[79856] - --- 398 -BEGIN TRANSACTION; - CREATE TABLE t (c bigint); - INSERT INTO t VALUES (0x137f0); -COMMIT; -SELECT * FROM t WHERE +c == 0x137f0; -|"c" -[79856] - --- 399 -BEGIN TRANSACTION; - CREATE TABLE t (c bigint); - INSERT INTO t VALUES (0x137f0); -COMMIT; -SELECT * FROM t WHERE -c == -79856; -|"c" -[79856] - --- 400 -BEGIN TRANSACTION; - CREATE TABLE t (c bigrat); - INSERT INTO t VALUES (42), (114); -COMMIT; -SELECT * FROM t ORDER BY 15, c, 16; -|"c" -[42/1] -[114/1] - --- 401 -BEGIN TRANSACTION; - CREATE TABLE t (c bigrat, i int); - INSERT INTO t VALUES (100, 1), (101, 2), (100, 10), (101, 20); -COMMIT; -SELECT c, sum(i) FROM t GROUP BY c; -|"c", "" -[100/1 11] -[101/1 22] - --- 402 -BEGIN TRANSACTION; - CREATE TABLE t (c bigrat); - INSERT INTO t VALUES (42.24), (114e3); -COMMIT; -SELECT * FROM t ORDER BY 15, c, 16; -|"c" -[5944751508129055/140737488355328] -[114000/1] - --- 403 -BEGIN TRANSACTION; - CREATE TABLE t (c bigrat); - INSERT INTO t VALUES ('A'), ('B'); -COMMIT; -SELECT * FROM t ORDER BY 15, c, 16; -|"c" -[65/1] -[66/1] - --- 404 -BEGIN TRANSACTION; - CREATE TABLE t (c bigrat); - INSERT INTO t VALUES (bigrat("2/3")+bigrat("5/7")); -COMMIT; -SELECT * FROM t; -|"c" -[29/21] - --- 405 -BEGIN TRANSACTION; - CREATE TABLE t (c bigrat); - INSERT INTO t VALUES (bigrat("2/3")-bigrat("5/7")); -COMMIT; -SELECT * FROM t; -|"c" -[-1/21] - --- 406 -BEGIN TRANSACTION; - CREATE TABLE t (c bigrat); - INSERT INTO t VALUES (bigrat("2/3")*bigrat("5/7")); -COMMIT; -SELECT * FROM t; -|"c" -[10/21] - --- 407 -BEGIN TRANSACTION; - CREATE TABLE t (c bigint, d bigint); - INSERT INTO t VALUES (1, 0); -COMMIT; -SELECT c/d FROM t; -||division .* zero - --- 408 -BEGIN TRANSACTION; - CREATE TABLE t (c bigint, d bigint); - INSERT INTO t VALUES (1, 0); -COMMIT; -SELECT c%d FROM t; -||division .* zero - --- 409 -BEGIN TRANSACTION; - CREATE TABLE t (c bigrat, d bigrat); - INSERT INTO t VALUES (bigrat("2/3"), bigrat("5/7")); -COMMIT; -SELECT c == d FROM t; -|"" -[false] - --- 410 -BEGIN TRANSACTION; - CREATE TABLE t (c bigrat, d bigrat); - INSERT INTO t VALUES (bigrat("2/3"), bigrat("4/6")); -COMMIT; -SELECT c == d FROM t; -|"" -[true] - --- 411 -BEGIN TRANSACTION; - CREATE TABLE t (c bigrat, d bigrat); - INSERT INTO t VALUES (bigrat("2/3"), bigrat("5/7")); -COMMIT; -SELECT c != d FROM t; -|"" -[true] - --- 412 -BEGIN TRANSACTION; - CREATE TABLE t (c bigrat, d bigrat); - INSERT INTO t VALUES (bigrat("2/3"), bigrat("4/6")); -COMMIT; -SELECT c != d FROM t; -|"" -[false] - --- 413 -BEGIN TRANSACTION; - CREATE TABLE t (c bigrat, d bigrat); - INSERT INTO t VALUES (bigrat("2/3"), bigrat("5/7")); -COMMIT; -SELECT c < d FROM t; -|"" -[true] - --- 414 -BEGIN TRANSACTION; - CREATE TABLE t (c bigrat, d bigrat); - INSERT INTO t VALUES (bigrat("2/3"), bigrat("4/6")); -COMMIT; -SELECT c < d FROM t; -|"" -[false] - --- 415 -BEGIN TRANSACTION; - CREATE TABLE t (c bigrat, d bigrat); - INSERT INTO t VALUES (bigrat("2/3"), bigrat("5/7")); -COMMIT; -SELECT c <= d FROM t; -|"" -[true] - --- 416 -BEGIN TRANSACTION; - CREATE TABLE t (c bigrat, d bigrat); - INSERT INTO t VALUES (bigrat("2/3"), bigrat("4/6")); -COMMIT; -SELECT c <= d FROM t; -|"" -[true] - --- 417 -BEGIN TRANSACTION; - CREATE TABLE t (c bigrat, d bigrat); - INSERT INTO t VALUES (bigrat("2/3"), bigrat("5/7")); -COMMIT; -SELECT c > d FROM t; -|"" -[false] - --- 418 -BEGIN TRANSACTION; - CREATE TABLE t (c bigrat, d bigrat); - INSERT INTO t VALUES (bigrat("2/3"), bigrat("4/6")); -COMMIT; -SELECT c > d FROM t; -|"" -[false] - --- 419 -BEGIN TRANSACTION; - CREATE TABLE t (c bigrat, d bigrat); - INSERT INTO t VALUES (bigrat("2/3"), bigrat("5/7")); -COMMIT; -SELECT c >= d FROM t; -|"" -[false] - --- 420 -BEGIN TRANSACTION; - CREATE TABLE t (c bigrat, d bigrat); - INSERT INTO t VALUES (bigrat("2/3"), bigrat("4/6")); -COMMIT; -SELECT c >= d FROM t; -|"" -[true] - --- 421 -BEGIN TRANSACTION; - CREATE TABLE t (c bigrat, d bigrat); - INSERT INTO t VALUES (bigrat("2/3"), bigrat("5/7")); -COMMIT; -SELECT c / d FROM t; -|"" -[14/15] - --- 422 -BEGIN TRANSACTION; - CREATE TABLE t (c bigrat, d bigrat); - INSERT INTO t VALUES (bigrat("2/3"), bigrat("0")); -COMMIT; -SELECT c / d FROM t; -||division .* zero - --- 423 -BEGIN TRANSACTION; - CREATE TABLE t (c bigrat, d bigrat); - INSERT INTO t VALUES (bigrat("2/3"), bigrat("0")); -COMMIT; -SELECT c / (6-2*3) FROM t; -||division .* zero - --- 424 -BEGIN TRANSACTION; - CREATE TABLE t (c bigrat, d bigrat); - INSERT INTO t VALUES (bigrat("2/3"), bigrat("5/7")); -COMMIT; -SELECT +c, -d FROM t; -|"", "" -[2/3 -5/7] - --- 425 -BEGIN TRANSACTION; - CREATE TABLE t (c bigrat, d bigrat); - INSERT INTO t VALUES (bigrat("2/3"), bigrat("5/7")); -COMMIT; -SELECT 1+c, d+1, 1.5+c, d+1.5 FROM t; -|"", "", "", "" -[5/3 12/7 13/6 31/14] - --- 426 -BEGIN TRANSACTION; - CREATE TABLE t (c bigrat); - INSERT INTO t VALUES (bigrat("355/113")); -COMMIT; -SELECT float(c) FROM t; -|"" -[3.1415929203539825] - --- 427 -BEGIN TRANSACTION; - CREATE TABLE t (c time); - INSERT INTO t VALUES (date(2006, 1, 2, 15, 4, 5, 999999999, "CET")); -COMMIT; -SELECT formatTime(timeIn(c, "UTC"), "2006-01-02 15:04:05.999999999 -0700") FROM t; -|"" -[2006-01-02 14:04:05.999999999 +0000] - --- 428 -BEGIN TRANSACTION; - CREATE TABLE t (c duration); - INSERT INTO t VALUES (duration("1s")), (duration("1m")), (duration("1h")); -COMMIT; -SELECT c, string(c) FROM t ORDER BY c; -|"c", "" -[1s 1s] -[1m0s 1m0s] -[1h0m0s 1h0m0s] - --- 429 -BEGIN TRANSACTION; - CREATE TABLE t (c time); - INSERT INTO t VALUES (date(2013, 11, 26, 10, 18, 5, 999999999, "CET")); -COMMIT; -SELECT since(c) > duration("24h") FROM t; -|"" -[true] - --- 430 -BEGIN TRANSACTION; - CREATE TABLE t (c time); - INSERT INTO t VALUES (date(2013, 11, 26, 10, 32, 5, 999999999, "CET")); -COMMIT; -SELECT !(since(c) < duration("24h")) FROM t; -|"" -[true] - --- 431 -BEGIN TRANSACTION; - CREATE TABLE t (a duration, b duration, c duration); - INSERT INTO t VALUES ( - duration("42h21m11.999999994s"), - duration("42h21m11.999999995s"), - duration("42h21m11.999999996s"), - ), - ; -COMMIT; -SELECT a > a, a > b, a > c, b > a, b > b, b > c, c > a, c > b, c > c FROM t; -|"", "", "", "", "", "", "", "", "" -[false false false true false false true true false] - --- 432 -BEGIN TRANSACTION; - CREATE TABLE t (a duration, b duration, c duration); - INSERT INTO t VALUES ( - duration("42h21m11.999999994s"), - duration("42h21m11.999999995s"), - duration("42h21m11.999999996s"), - ), - ; -COMMIT; -SELECT a < a, a < b, a < c, b < a, b < b, b < c, c < a, c < b, c < c FROM t; -|"", "", "", "", "", "", "", "", "" -[false true true false false true false false false] - --- 433 -BEGIN TRANSACTION; - CREATE TABLE t (a duration, b duration, c duration); - INSERT INTO t VALUES ( - duration("42h21m11.999999994s"), - duration("42h21m11.999999995s"), - duration("42h21m11.999999996s"), - ), - ; -COMMIT; -SELECT a <= a, a <= b, a <= c, b <= a, b <= b, b <= c, c <= a, c <= b, c <= c FROM t; -|"", "", "", "", "", "", "", "", "" -[true true true false true true false false true] - --- 434 -BEGIN TRANSACTION; - CREATE TABLE t (a duration, b duration, c duration); - INSERT INTO t VALUES ( - duration("42h21m11.999999994s"), - duration("42h21m11.999999995s"), - duration("42h21m11.999999996s"), - ), - ; -COMMIT; -SELECT a >= a, a >= b, a >= c, b >= a, b >= b, b >= c, c >= a, c >= b, c >= c FROM t; -|"", "", "", "", "", "", "", "", "" -[true false false true true false true true true] - --- 435 -BEGIN TRANSACTION; - CREATE TABLE t (a duration, b duration, c duration); - INSERT INTO t VALUES ( - duration("42h21m11.999999994s"), - duration("42h21m11.999999995s"), - duration("42h21m11.999999996s"), - ), - ; -COMMIT; -SELECT a != a, a != b, a != c, b != a, b != b, b != c, c != a, c != b, c != c FROM t; -|"", "", "", "", "", "", "", "", "" -[false true true true false true true true false] - --- 436 -BEGIN TRANSACTION; - CREATE TABLE t (a duration, b duration, c duration); - INSERT INTO t VALUES ( - duration("42h21m11.999999994s"), - duration("42h21m11.999999995s"), - duration("42h21m11.999999996s"), - ), - ; -COMMIT; -SELECT a == a, a == b, a == c, b == a, b == b, b == c, c == a, c == b, c == c FROM t; -|"", "", "", "", "", "", "", "", "" -[true false false false true false false false true] - --- 437 -BEGIN TRANSACTION; - CREATE TABLE t (a duration, b duration, c duration); - INSERT INTO t VALUES ( - duration("5h"), - duration("3m"), - duration("2s"), - ), - ; -COMMIT; -SELECT b+c, a+c, a+b, a+b+c FROM t; -|"", "", "", "" -[3m2s 5h0m2s 5h3m0s 5h3m2s] - --- 438 -BEGIN TRANSACTION; - CREATE TABLE t (a duration, b duration, c duration); - INSERT INTO t VALUES ( - duration("5h"), - duration("3m"), - duration("2s"), - ), - ; -COMMIT; -SELECT b-c, a-c, a-b, a-b-c FROM t; -|"", "", "", "" -[2m58s 4h59m58s 4h57m0s 4h56m58s] - --- 439 -BEGIN TRANSACTION; - CREATE TABLE t (a duration, b duration, c duration); - INSERT INTO t VALUES ( - duration("5h"), - duration("3m"), - duration("2s"), - ), - ; -COMMIT; -SELECT a>>1, b>>1, c>>1 FROM t; -|"", "", "" -[2h30m0s 1m30s 1s] - --- 440 -BEGIN TRANSACTION; - CREATE TABLE t (a duration, b duration, c duration); - INSERT INTO t VALUES ( - duration("5h"), - duration("3m"), - duration("2s"), - ), - ; -COMMIT; -SELECT a<<1, b<<1, c<<1 FROM t; -|"", "", "" -[10h0m0s 6m0s 4s] - --- 441 -BEGIN TRANSACTION; - CREATE TABLE t (a duration); - INSERT INTO t VALUES ( - duration("257ns"), - ), - ; -COMMIT; -SELECT a & 255 FROM t; -|"" -[1ns] - --- 442 -BEGIN TRANSACTION; - CREATE TABLE t (a duration); - INSERT INTO t VALUES ( - duration("1ns"), - ), - ; -COMMIT; -SELECT a ∨ 256 FROM t; -|"" -[257ns] - --- 443 -BEGIN TRANSACTION; - CREATE TABLE t (a duration); - INSERT INTO t VALUES ( - duration(0x731), - ), - ; -COMMIT; -SELECT a &^ 0xd30 FROM t; -|"" -[513ns] - --- 444 -BEGIN TRANSACTION; - CREATE TABLE t (a duration); - INSERT INTO t VALUES ( - duration("3h2m1s"), - ), - ; -COMMIT; -SELECT a % duration("2h"), a % duration("1m") FROM t; -|"", "" -[1h2m1s 1s] - --- 445 -BEGIN TRANSACTION; - CREATE TABLE t (a duration, b duration, c duration); - INSERT INTO t VALUES ( - duration("5h"), - duration("3m"), - duration("2s"), - ), - ; -COMMIT; -SELECT a/2, b/2, c/2 FROM t; -|"", "", "" -[2h30m0s 1m30s 1s] - --- 446 -BEGIN TRANSACTION; - CREATE TABLE t (a duration, b duration, c duration); - INSERT INTO t VALUES ( - duration("5h"), - duration("3m"), - duration("2s"), - ), - ; -COMMIT; -SELECT a*2, 2*b, c*2 FROM t; -|"", "", "" -[10h0m0s 6m0s 4s] - --- 447 -BEGIN TRANSACTION; - CREATE TABLE t (a duration, b duration, c duration); - INSERT INTO t VALUES ( - duration("1ns"), - duration("3ns"), - duration("5ns"), - ), - ; -COMMIT; -SELECT ^a, ^b, ^c FROM t; -|"", "", "" -[-2ns -4ns -6ns] - --- 448 -BEGIN TRANSACTION; - CREATE TABLE t (a duration, b duration, c duration); - INSERT INTO t VALUES ( - duration("1ns"), - duration("3ns"), - duration("5ns"), - ), - ; -COMMIT; -SELECT +a, +b, +c FROM t; -|"", "", "" -[1ns 3ns 5ns] - --- 449 -BEGIN TRANSACTION; - CREATE TABLE t (a duration, b duration, c duration); - INSERT INTO t VALUES ( - duration("1ns"), - duration("3ns"), - duration("5ns"), - ), - ; -COMMIT; -SELECT -a, -b, -c FROM t; -|"", "", "" -[-1ns -3ns -5ns] - --- 450 -BEGIN TRANSACTION; - CREATE TABLE t (a time, b time, c time); - INSERT INTO t VALUES ( - date(2013, 11, 27, 12, 1, 2, 999999994, "CET"), - date(2013, 11, 27, 12, 1, 2, 999999995, "CET"), - date(2013, 11, 27, 12, 1, 2, 999999996, "CET"), - ), - ; -COMMIT; -SELECT a > a, a > b, a > c, b > a, b > b, b > c, c > a, c > b, c > c FROM t; -|"", "", "", "", "", "", "", "", "" -[false false false true false false true true false] - --- 451 -BEGIN TRANSACTION; - CREATE TABLE t (a time, b time, c time); - INSERT INTO t VALUES ( - date(2013, 11, 27, 12, 1, 2, 999999994, "CET"), - date(2013, 11, 27, 12, 1, 2, 999999995, "CET"), - date(2013, 11, 27, 12, 1, 2, 999999996, "CET"), - ), - ; -COMMIT; -SELECT a < a, a < b, a < c, b < a, b < b, b < c, c < a, c < b, c < c FROM t; -|"", "", "", "", "", "", "", "", "" -[false true true false false true false false false] - --- 452 -BEGIN TRANSACTION; - CREATE TABLE t (a time, b time, c time); - INSERT INTO t VALUES ( - date(2013, 11, 27, 12, 1, 2, 999999994, "CET"), - date(2013, 11, 27, 12, 1, 2, 999999995, "CET"), - date(2013, 11, 27, 12, 1, 2, 999999996, "CET"), - ), - ; -COMMIT; -SELECT a <= a, a <= b, a <= c, b <= a, b <= b, b <= c, c <= a, c <= b, c <= c FROM t; -|"", "", "", "", "", "", "", "", "" -[true true true false true true false false true] - --- 453 -BEGIN TRANSACTION; - CREATE TABLE t (a time, b time, c time); - INSERT INTO t VALUES ( - date(2013, 11, 27, 12, 1, 2, 999999994, "CET"), - date(2013, 11, 27, 12, 1, 2, 999999995, "CET"), - date(2013, 11, 27, 12, 1, 2, 999999996, "CET"), - ), - ; -COMMIT; -SELECT a >= a, a >= b, a >= c, b >= a, b >= b, b >= c, c >= a, c >= b, c >= c FROM t; -|"", "", "", "", "", "", "", "", "" -[true false false true true false true true true] - --- 454 -BEGIN TRANSACTION; - CREATE TABLE t (a time, b time, c time); - INSERT INTO t VALUES ( - date(2013, 11, 27, 12, 1, 2, 999999994, "CET"), - date(2013, 11, 27, 12, 1, 2, 999999995, "CET"), - date(2013, 11, 27, 12, 1, 2, 999999996, "CET"), - ), - ; -COMMIT; -SELECT a != a, a != b, a != c, b != a, b != b, b != c, c != a, c != b, c != c FROM t; -|"", "", "", "", "", "", "", "", "" -[false true true true false true true true false] - --- 455 -BEGIN TRANSACTION; - CREATE TABLE t (a time, b time, c time); - INSERT INTO t VALUES ( - date(2013, 11, 27, 12, 1, 2, 999999994, "CET"), - date(2013, 11, 27, 12, 1, 2, 999999995, "CET"), - date(2013, 11, 27, 12, 1, 2, 999999996, "CET"), - ), - ; -COMMIT; -SELECT a == a, a == b, a == c, b == a, b == b, b == c, c == a, c == b, c == c FROM t; -|"", "", "", "", "", "", "", "", "" -[true false false false true false false false true] - --- 456 -BEGIN TRANSACTION; - CREATE TABLE t (a time, b duration); - INSERT INTO t VALUES ( - date(2013, 11, 27, 12, 1, 2, 999999999, "CET"), - duration("3h2m1s"), - ), - ; -COMMIT; -SELECT formatTime(timeIn(a+b, "UTC"), "2006-01-02 15:04:05.999999999 -0700") FROM t; -|"" -[2013-11-27 14:03:03.999999999 +0000] - --- 457 -BEGIN TRANSACTION; - CREATE TABLE t (a time, b duration); - INSERT INTO t VALUES ( - date(2013, 11, 27, 12, 1, 2, 999999999, "CET"), - duration("3h2m1s"), - ), - ; -COMMIT; -SELECT formatTime(timeIn(b+a, "UTC"), "2006-01-02 15:04:05.999999999 -0700") FROM t; -|"" -[2013-11-27 14:03:03.999999999 +0000] - --- 458 -BEGIN TRANSACTION; - CREATE TABLE t (a time, b duration); - INSERT INTO t VALUES ( - date(2013, 11, 27, 12, 1, 2, 999999999, "CET"), - duration("3h2m1s"), - ), - ; -COMMIT; -SELECT a+a FROM t; -||invalid operation - --- 459 -BEGIN TRANSACTION; - CREATE TABLE t (a time, b time); - INSERT INTO t VALUES ( - date(2013, 11, 27, 13, 2, 3, 999999999, "CET"), - date(2013, 11, 27, 12, 1, 2, 999999999, "CET"), - ), - ; -COMMIT; -SELECT a-b FROM t; -|"" -[1h1m1s] - --- 460 -BEGIN TRANSACTION; - CREATE TABLE t (a time, b duration); - INSERT INTO t VALUES ( - date(2013, 11, 27, 12, 1, 2, 999999999, "CET"), - duration("3h2m1s"), - ), - ; -COMMIT; -SELECT formatTime(timeIn(a-b, "UTC"), "2006-01-02 15:04:05.999999999 -0700") FROM t; -|"" -[2013-11-27 07:59:01.999999999 +0000] - --- 461 -BEGIN TRANSACTION; - CREATE TABLE t (a time, b duration); - INSERT INTO t VALUES ( - date(2013, 11, 27, 12, 1, 2, 999999999, "CET"), - duration("3h2m1s"), - ), - ; -COMMIT; -SELECT b-a FROM t; -||invalid operation - --- 462 -BEGIN TRANSACTION; - CREATE TABLE t (a duration); - INSERT INTO t VALUES ( - duration("3h2m1.5s"), - ), - ; -COMMIT; -SELECT hours(a), minutes(a), seconds(a), nanoseconds(a) FROM t; -|"", "", "", "" -[3.03375 182.025 10921.5 10921500000000] - --- 463 -BEGIN TRANSACTION; - CREATE TABLE t (a time); - INSERT INTO t VALUES (now()-duration("1s")); -COMMIT; -SELECT a < now(), now() > a, a >= now(), now() <= a FROM t; -|"", "", "", "" -[true true false false] - --- 464 -BEGIN TRANSACTION; - CREATE TABLE t (a time); - INSERT INTO t VALUES - (parseTime("Jan 2, 2006 at 3:04pm (MST)", "Nov 27, 2013 at 2:07pm (CET)")), - (parseTime("2006-Jan-02", "2013-Nov-27")), - ; -COMMIT; -SELECT formatTime(timeIn(a, "UTC"), "2006-01-02 15:04:05.999999999 -0700") as a FROM t ORDER BY a; -|"a" -[2013-11-27 00:00:00 +0000] -[2013-11-27 13:07:00 +0000] - --- 465 -BEGIN TRANSACTION; - CREATE TABLE t (a time); - INSERT INTO t VALUES - (parseTime("Jan 2, 2006 at 3:04pm (MST)", "Nov 27, 2013 at 2:07pm (CET)")), - (parseTime("2006-Jan-02", "2013-Nov-27")), - ; -COMMIT; -SELECT hour(timeIn(a, "UTC")) AS y FROM t ORDER BY y; -|"y" -[0] -[13] - --- 466 -BEGIN TRANSACTION; - CREATE TABLE t (a time); - INSERT INTO t VALUES - (parseTime("Jan 2, 2006 at 3:04pm (MST)", "Nov 27, 2013 at 2:07pm (CET)")), - (parseTime("2006-Jan-02", "2013-Nov-27")), - ; -COMMIT; -SELECT minute(a) AS y FROM t ORDER BY y; -|"y" -[0] -[7] - --- 467 -BEGIN TRANSACTION; - CREATE TABLE t (a time); - INSERT INTO t VALUES - (parseTime("Jan 2, 2006 at 3:04:05pm (MST)", "Nov 27, 2013 at 2:07:31pm (CET)")), - (parseTime("2006-Jan-02", "2013-Nov-27")), - ; -COMMIT; -SELECT second(a) AS y FROM t ORDER BY y; -|"y" -[0] -[31] - --- 468 -BEGIN TRANSACTION; - CREATE TABLE t (a time); - INSERT INTO t VALUES - (parseTime("Jan 2, 2006 at 3:04:05pm (MST)", "Nov 27, 2013 at 2:07:31.123456789pm (CET)")), - (parseTime("2006-Jan-02", "2013-Nov-27")), - ; -COMMIT; -SELECT nanosecond(a) AS y FROM t ORDER BY y; -|"y" -[0] -[123456789] - --- 469 -BEGIN TRANSACTION; - CREATE TABLE t (a time); - INSERT INTO t VALUES - (parseTime("Jan 2, 2006 at 3:04:05pm (MST)", "Nov 27, 2013 at 2:07:31.123456789pm (CET)")), - (parseTime("2006-Jan-02", "2014-Nov-28")), - ; -COMMIT; -SELECT year(a) AS y FROM t ORDER BY y; -|"y" -[2013] -[2014] - --- 470 -BEGIN TRANSACTION; - CREATE TABLE t (a time); - INSERT INTO t VALUES - (parseTime("Jan 2, 2006 at 3:04:05pm (MST)", "Nov 27, 2013 at 2:07:31.123456789pm (CET)")), - (parseTime("2006-Jan-02", "2014-Nov-28")), - ; -COMMIT; -SELECT day(a) AS y FROM t ORDER BY y; -|"y" -[27] -[28] - --- 471 -BEGIN TRANSACTION; - CREATE TABLE t (a time); - INSERT INTO t VALUES - (parseTime("Jan 2, 2006 at 3:04:05pm (MST)", "Nov 27, 2013 at 2:07:31.123456789pm (CET)")), - (parseTime("2006-Jan-02", "2014-Dec-28")), - ; -COMMIT; -SELECT month(a) AS y FROM t ORDER BY y; -|"y" -[11] -[12] - --- 472 -BEGIN TRANSACTION; - CREATE TABLE t (a time); - INSERT INTO t VALUES - (parseTime("Jan 2, 2006 at 3:04:05pm (MST)", "Nov 27, 2013 at 2:07:31.123456789pm (CET)")), - (parseTime("2006-Jan-02", "2013-Sep-08")), - ; -COMMIT; -SELECT weekday(a) AS y FROM t ORDER BY y; -|"y" -[0] -[3] - --- 473 -BEGIN TRANSACTION; - CREATE TABLE t (a time); - INSERT INTO t VALUES - (parseTime("Jan 2, 2006 at 3:04:05pm (MST)", "Feb 1, 2013 at 2:07:31.123456789pm (CET)")), - (parseTime("2006-Jan-02", "2014-Feb-02")), - ; -COMMIT; -SELECT yearDay(a) AS y FROM t ORDER BY y; -|"y" -[32] -[33] - --- 474 -BEGIN TRANSACTION; - CREATE TABLE t (a time); - INSERT INTO t VALUES - (parseTime("Jan 2, 2006 at 3:04pm (MST)", "Feb 1, 2013 at 2:07pm (CET)")), - (parseTime("2006-Jan-02", "2014-Feb-02")), - ; -COMMIT; -SELECT timeIn(a, ""), timeIn(a, "UTC") AS y FROM t ORDER BY y; -|"", "y" -[2013-02-01 13:07:00 +0000 UTC 2013-02-01 13:07:00 +0000 UTC] -[2014-02-02 00:00:00 +0000 UTC 2014-02-02 00:00:00 +0000 UTC] - --- 475 -BEGIN TRANSACTION; - CREATE TABLE t (a time); - INSERT INTO t VALUES - (parseTime("Jan 2, 2006 at 3:04pm (MST)", "Feb 1, 2013 at 2:07pm (CET)")), - (parseTime("2006-Jan-02", "2014-Feb-02")), - ; -COMMIT; -SELECT formatTime(timeIn(a, "UTC"), "Jan 2, 2006 at 3:04pm (UTC)") AS y FROM t ORDER BY y; -|"y" -[Feb 1, 2013 at 1:07pm (UTC)] -[Feb 2, 2014 at 12:00am (UTC)] - --- 476 -BEGIN TRANSACTION; - BEGIN TRANSACTION; - COMMIT; -COMMIT; -SELECT * FROM t; -||does not exist - --- 477 -BEGIN TRANSACTION; - BEGIN TRANSACTION; - ROLLBACK; -COMMIT; -SELECT * FROM t; -||does not exist - --- 478 // https://github.com/cznic/ql/issues/23 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b string, t time); - INSERT INTO t VALUES (1, "a", parseTime("Jan 2, 2006 at 3:04pm (MST)", "Jan 12, 2014 at 6:26pm (CET)")); - INSERT INTO t VALUES (2, "b", parseTime("Jan 2, 2006 at 3:04pm (MST)", "Jan 12, 2014 at 6:27pm (CET)")); - UPDATE t b = "hello" WHERE a == 1; -COMMIT; -SELECT a, b, formatTime(timeIn(t, "UTC"), "2006-01-02 15:04:05.999999999 -0700") as t FROM t; -|"a", "b", "t" -[2 b 2014-01-12 17:27:00 +0000] -[1 hello 2014-01-12 17:26:00 +0000] - --- 479 // https://github.com/cznic/ql/issues/23 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b string, t time); - INSERT INTO t VALUES (1, "a", parseTime("Jan 2, 2006 at 3:04pm (MST)", "Jan 12, 2014 at 6:26pm (CET)")); - INSERT INTO t VALUES (2, "b", parseTime("Jan 2, 2006 at 3:04pm (MST)", "Jan 12, 2014 at 6:27pm (CET)")); - UPDATE t - b = "hello", - t = parseTime("Jan 2, 2006 at 3:04pm (MST)", "Jan 12, 2014 at 6:28pm (CET)"), - WHERE a == 1; -COMMIT; -SELECT a, b, formatTime(timeIn(t, "UTC"), "2006-01-02 15:04:05.999999999 -0700") as t FROM t; -|"a", "b", "t" -[2 b 2014-01-12 17:27:00 +0000] -[1 hello 2014-01-12 17:28:00 +0000] - --- 480 // https://github.com/cznic/ql/issues/23 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b string, d duration); - INSERT INTO t VALUES (1, "a", duration("1m")); - INSERT INTO t VALUES (2, "b", duration("2m")); - UPDATE t b = "hello" WHERE a == 1; -COMMIT; -SELECT * FROM t; -|"a", "b", "d" -[2 b 2m0s] -[1 hello 1m0s] - --- 481 // https://github.com/cznic/ql/issues/23 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b string, d duration); - INSERT INTO t VALUES (1, "a", duration("1m")); - INSERT INTO t VALUES (2, "b", duration("2m")); - UPDATE t - b = "hello", - d = duration("3m"), - WHERE a == 1; -COMMIT; -SELECT * FROM t; -|"a", "b", "d" -[2 b 2m0s] -[1 hello 3m0s] - --- 482 // https://github.com/cznic/ql/issues/24 -BEGIN TRANSACTION; - CREATE TABLE t (c complex128); - INSERT INTO t VALUES - (2+complex128(1)), - (22+complex(0, 1)), - ; -COMMIT; -SELECT * FROM t ORDER BY real(c); -|"c" -[(3+0i)] -[(22+1i)] - --- 483 -BEGIN TRANSACTION; - CREATE TABLE t (s string, substr string); - INSERT INTO t VALUES - ("seafood", "foo"), - ("seafood", "bar"), - ("seafood", ""), - ("", ""), - ; -COMMIT; -SELECT id() as i, contains(42, substr) FROM t ORDER BY i; -||invalid .* 42 - --- 484 -BEGIN TRANSACTION; - CREATE TABLE t (s string, substr string); - INSERT INTO t VALUES - ("seafood", "foo"), - ("seafood", "bar"), - ("seafood", ""), - ("", ""), - ; -COMMIT; -SELECT id() as i, contains(s, true) FROM t ORDER BY i; -||invalid .* true - --- 485 -BEGIN TRANSACTION; - CREATE TABLE t (s string, substr string); - INSERT INTO t VALUES - ("seafood", "foo"), - ("seafood", "bar"), - ("seafood", ""), - ("", ""), - ("", NULL), - ("foo", NULL), - (NULL, ""), - (NULL, "foo"), - (NULL, NULL), - ; -COMMIT; -SELECT id() as i, contains(s, substr) FROM t ORDER BY i; -|"i", "" -[1 true] -[2 false] -[3 true] -[4 true] -[5 ] -[6 ] -[7 ] -[8 ] -[9 ] - --- 486 -BEGIN TRANSACTION; - CREATE TABLE t (s string, prefix string); - INSERT INTO t VALUES - ("", ""), - ("f", ""), - ("", "foo"), - ("f", "foo"), - ("fo", "foo"), - ("foo", "foo"), - ("fooo", "foo"), - ; -COMMIT; -SELECT id() as i, hasPrefix(42, prefix) FROM t ORDER BY i; -||invalid .* 42 - --- 487 -BEGIN TRANSACTION; - CREATE TABLE t (s string, prefix string); - INSERT INTO t VALUES - ("", ""), - ("f", ""), - ("", "foo"), - ("f", "foo"), - ("fo", "foo"), - ("foo", "foo"), - ("fooo", "foo"), - ; -COMMIT; -SELECT id() as i, hasPrefix(s, false) FROM t ORDER BY i; -||invalid .* false - --- 488 -BEGIN TRANSACTION; - CREATE TABLE t (s string, prefix string); - INSERT INTO t VALUES - ("", ""), - ("f", ""), - ("", "foo"), - ("f", "foo"), - ("fo", "foo"), - ("foo", "foo"), - ("fooo", "foo"), - ("", NULL), - ("foo", NULL), - (NULL, ""), - (NULL, "foo"), - (NULL, NULL), - ; -COMMIT; -SELECT id() as i, hasPrefix(s, prefix) FROM t ORDER BY i; -|"i", "" -[1 true] -[2 true] -[3 false] -[4 false] -[5 false] -[6 true] -[7 true] -[8 ] -[9 ] -[10 ] -[11 ] -[12 ] - --- 489 -BEGIN TRANSACTION; - CREATE TABLE t (s string, suffix string); - INSERT INTO t VALUES - ("", ""), - ("f", ""), - ("x", "foo"), - ("xf", "foo"), - ("xfo", "foo"), - ("xfoo", "foo"), - ("xfooo", "foo"), - ; -COMMIT; -SELECT id() as i, hasSuffix(42, suffix) FROM t ORDER BY i; -||invalid .* 42 - --- 490 -BEGIN TRANSACTION; - CREATE TABLE t (s string, suffix string); - INSERT INTO t VALUES - ("", ""), - ("f", ""), - ("x", "foo"), - ("xf", "foo"), - ("xfo", "foo"), - ("xfoo", "foo"), - ("xfooo", "foo"), - ; -COMMIT; -SELECT id() as i, hasSuffix(s, true) FROM t ORDER BY i; -||invalid .* true - --- 491 -BEGIN TRANSACTION; - CREATE TABLE t (s string, suffix string); - INSERT INTO t VALUES - ("", ""), - ("f", ""), - ("x", "foo"), - ("xf", "foo"), - ("xfo", "foo"), - ("xfoo", "foo"), - ("xfooo", "foo"), - ("", NULL), - ("foo", NULL), - (NULL, ""), - (NULL, "foo"), - (NULL, NULL), - ; -COMMIT; -SELECT id() as i, hasSuffix(s, suffix) FROM t ORDER BY i; -|"i", "" -[1 true] -[2 true] -[3 false] -[4 false] -[5 false] -[6 true] -[7 false] -[8 ] -[9 ] -[10 ] -[11 ] -[12 ] - --- 492 // issue #27 -BEGIN TRANSACTION; - DROP TABLE nonexistent; -COMMIT; -||does not exist - --- 493 // issue #27 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - DROP TABLE IF EXISTS nonexistent; -COMMIT; -SELECT * FROM t; -|"i" - --- 494 // issue #27 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE TABLE t (i int); -COMMIT; -||exist - --- 495 // issue #27 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE TABLE IF NOT EXISTS t (s string); -COMMIT; -SELECT * FROM t; -|"i" - --- 496 // issue #28 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42); - ALTER TABLE t ADD s string; -COMMIT; -SELECT * FROM t; -|"i", "s" -[42 ] - --- 497 -BEGIN TRANSACTION; - CREATE TABLE t (i int); -COMMIT; -BEGIN TRANSACTION; - INSERT INTO t VALUES(1000); - BEGIN TRANSACTION; - INSERT INTO t VALUES(2000); - COMMIT; - INSERT INTO t VALUES(3000); -COMMIT; -SELECT * FROM t; -|"i" -[3000] -[2000] -[1000] - --- 498 -BEGIN TRANSACTION; - CREATE TABLE t (i int); -COMMIT; -BEGIN TRANSACTION; - INSERT INTO t VALUES(1000); - BEGIN TRANSACTION; - INSERT INTO t VALUES(2000); - ROLLBACK; - INSERT INTO t VALUES(3000); -COMMIT; -SELECT * FROM t; -|"i" -[3000] -[1000] - --- 499 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - INSERT INTO t VALUES(42, "foo"); - ALTER TABLE t DROP COLUMN i; -COMMIT; -SELECT * FROM t; -|"s" -[foo] - --- 500 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - INSERT INTO t VALUES(42, "foo"); - ALTER TABLE t DROP COLUMN s; -COMMIT; -SELECT * FROM t; -|"i" -[42] - --- 501 // new spec rule: table must have at least 1 column -BEGIN TRANSACTION; - CREATE TABLE t (c int); -COMMIT; -BEGIN TRANSACTION; - ALTER TABLE t DROP COLUMN c; -COMMIT; -SELECT * FROM t; -||cannot drop.*column - --- 502 // fixed bug -BEGIN TRANSACTION; - CREATE TABLE t (c int, s string); -COMMIT; -BEGIN TRANSACTION; - ALTER TABLE t DROP COLUMN s; -ROLLBACK; -SELECT * FROM t; -|"c", "s" - --- 503 // fixed bug -BEGIN TRANSACTION; - CREATE TABLE t (c int, s string); -COMMIT; -BEGIN TRANSACTION; - ALTER TABLE t ADD b bool; -ROLLBACK; -SELECT * FROM t; -|"c", "s" - --- 504 // fixed bug -BEGIN TRANSACTION; - CREATE TABLE t (c int, s string); -COMMIT; -BEGIN TRANSACTION; - DROP TABLE t; -ROLLBACK; -SELECT * FROM t; -|"c", "s" - --- 505 // fixed bug -BEGIN TRANSACTION; - CREATE INDEX x ON t (qty()); -COMMIT; -||undefined.* qty - --- 506 -BEGIN TRANSACTION; - CREATE INDEX x ON t (qty); -COMMIT; -||table.*not exist - --- 507 -BEGIN TRANSACTION; - CREATE TABLE t (c int); - CREATE INDEX x ON t (qty); -COMMIT; -||column.*not exist - --- 508 -BEGIN TRANSACTION; - CREATE TABLE t (c int); - CREATE INDEX x ON t (id()); -COMMIT; -SELECT * FROM t; -|"c" - --- 509 -BEGIN TRANSACTION; - CREATE TABLE t (c int); - CREATE INDEX y ON t (c); -COMMIT; -SELECT * FROM t; -|"c" - --- 510 -BEGIN TRANSACTION; - CREATE TABLE t (c int); - CREATE INDEX x ON t (id()); - CREATE INDEX y ON t (id()); -COMMIT; -SELECT * FROM t; -||already - --- 511 -BEGIN TRANSACTION; - CREATE TABLE t (c int); - CREATE INDEX x ON t (id()); - CREATE INDEX x ON t (c); -COMMIT; -SELECT * FROM t; -||already - --- 512 -BEGIN TRANSACTION; - CREATE TABLE t (c int); - CREATE INDEX x ON t (id()); - CREATE INDEX y ON t (c); -COMMIT; -SELECT * FROM t; -|"c" - --- 513 -BEGIN TRANSACTION; - CREATE TABLE t (c int); - CREATE INDEX y ON t (c); - CREATE INDEX x ON t (id()); -COMMIT; -SELECT * FROM t; -|"c" - --- 514 -BEGIN TRANSACTION; - CREATE TABLE t (c int); - CREATE INDEX x ON t (id()); - INSERT INTO t VALUES(42); -COMMIT; -SELECT * FROM t; -|"c" -[42] - --- 515 -BEGIN TRANSACTION; - CREATE TABLE t (c int); - INSERT INTO t VALUES(42); - CREATE INDEX x ON t (id()); -COMMIT; -SELECT * FROM t; -|"c" -[42] - --- 516 -BEGIN TRANSACTION; - CREATE TABLE t (c int); - INSERT INTO t VALUES(42); - INSERT INTO t VALUES(24); - CREATE INDEX x ON t (id()); - INSERT INTO t VALUES(1); - CREATE INDEX i ON t (c); - INSERT INTO t VALUES(999); -COMMIT; -SELECT * FROM t ORDER BY id(); -|"c" -[42] -[24] -[1] -[999] - --- 517 -BEGIN TRANSACTION; - CREATE TABLE t (c int); - INSERT INTO t VALUES(42); - INSERT INTO t VALUES(24); - CREATE INDEX x ON t (id()); - INSERT INTO t VALUES(1); - CREATE INDEX i ON t (c); - INSERT INTO t VALUES(999); -COMMIT; -SELECT * FROM t ORDER BY c; -|"c" -[1] -[24] -[42] -[999] - --- 518 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX xid ON t (id()); - INSERT INTO t VALUES(42); - INSERT INTO t VALUES(24); - CREATE INDEX ii ON t (i); - INSERT INTO t VALUES(1); - INSERT INTO t VALUES(999); - UPDATE t i = 240 WHERE i == 24; - DELETE FROM t WHERE i == 240; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[1] -[42] -[999] - --- 519 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX i ON t (i); -COMMIT; -||collision: i - --- 520 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX t ON t (i); -COMMIT; -||collision: t - --- 521 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE TABLE u (s string); - CREATE INDEX u ON t (i); -COMMIT; -||collision.*: u - --- 522 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE TABLE u (s string); - CREATE INDEX z ON t (i); - CREATE INDEX z ON u (s); -COMMIT; -||already - --- 523 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX u ON u (s); -COMMIT; -||collision: u - --- 524 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX v ON u (v); -COMMIT; -||collision: v - --- 525 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE INDEX s ON t (i); -COMMIT; -||collision.*: s - --- 526 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX id ON t (i); -COMMIT; -SELECT * FROM t; -|"i" - --- 527 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - CREATE TABLE x (s string); -COMMIT; -||table t.*index x - --- 528 -BEGIN TRANSACTION; - CREATE TABLE t (i int); -COMMIT; -BEGIN TRANSACTION; - INSERT INTO t VALUES(1000); - BEGIN TRANSACTION; - INSERT INTO t VALUES(2000); - ROLLBACK; - INSERT INTO t VALUES(3000); -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[1000] -[3000] - --- 529 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (42); - TRUNCATE TABLE t; -COMMIT; -SELECT * FROM t; -|"i" - --- 530 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (42); - DELETE FROM t; -COMMIT; -SELECT * FROM t; -|"i" - --- 531 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE INDEX xi ON t (i); - INSERT INTO t VALUES (42, "foo"); - ALTER TABLE t DROP COLUMN i; - INSERT INTO t VALUES ("bar"); -COMMIT; -SELECT * FROM t ORDER BY s; -|"s" -[bar] -[foo] - --- 532 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE INDEX xs ON t (s); - INSERT INTO t VALUES (42, "foo"); - ALTER TABLE t DROP COLUMN i; - INSERT INTO t VALUES ("bar"); -COMMIT; -SELECT * FROM t ORDER BY s; -|"s" -[bar] -[foo] - --- 533 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE INDEX xi ON t (i); - CREATE INDEX xs ON t (s); - INSERT INTO t VALUES (42, "foo"); - ALTER TABLE t DROP COLUMN i; - INSERT INTO t VALUES ("bar"); -COMMIT; -SELECT * FROM t ORDER BY s; -|"s" -[bar] -[foo] - --- 534 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE INDEX xi ON t (i); - INSERT INTO t VALUES (42, "foo"); - ALTER TABLE t DROP COLUMN s; - INSERT INTO t VALUES (24); -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[24] -[42] - --- 535 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE INDEX xs ON t (s); - INSERT INTO t VALUES (42, "foo"); - ALTER TABLE t DROP COLUMN s; - INSERT INTO t VALUES (24); -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[24] -[42] - --- 536 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE INDEX xi ON t (i); - CREATE INDEX xs ON t (s); - INSERT INTO t VALUES (42, "foo"); - ALTER TABLE t DROP COLUMN s; - INSERT INTO t VALUES (24); -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[24] -[42] - --- 537 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - INSERT INTO t VALUES (42, "foo"); - ALTER TABLE t DROP COLUMN i; -COMMIT; -SELECT * FROM t; -|"s" -[foo] - --- 538 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - INSERT INTO t VALUES (42, "foo"); - ALTER TABLE t DROP COLUMN s; -COMMIT; -SELECT * FROM t; -|"i" -[42] - --- 539 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - INSERT INTO t VALUES (42, "foo"); -COMMIT; -BEGIN TRANSACTION; - ALTER TABLE t DROP COLUMN i; -COMMIT; -SELECT * FROM t; -|"s" -[foo] - --- 540 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - INSERT INTO t VALUES (42, "foo"); -COMMIT; -BEGIN TRANSACTION; - ALTER TABLE t DROP COLUMN s; -COMMIT; -SELECT * FROM t; -|"i" -[42] - --- 541 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (42, "foo"); -COMMIT; -BEGIN TRANSACTION; - ALTER TABLE t DROP COLUMN s; -COMMIT; -BEGIN TRANSACTION; - INSERT INTO t VALUES (24); -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[24] -[42] - --- 542 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (42, "foo"); -COMMIT; -BEGIN TRANSACTION; - ALTER TABLE t DROP COLUMN i; -COMMIT; -BEGIN TRANSACTION; - INSERT INTO t VALUES ("bar"); -COMMIT; -SELECT * FROM t ORDER BY s; -|"s" -[bar] -[foo] - --- 543 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (42); - INSERT INTO t SELECT 10*i FROM t; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[42] -[420] - --- 544 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (42); - INSERT INTO t SELECT 10*i FROM t; - DROP INDEX none; -COMMIT; -||index none does not exist - --- 545 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (42); - INSERT INTO t SELECT 10*i FROM t; - DROP INDEX x; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[42] -[420] - --- 546 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (42); - INSERT INTO t SELECT 10*i FROM t; -COMMIT; -BEGIN TRANSACTION; - DROP INDEX x; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[42] -[420] - --- 547 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - ALTER TABLE t ADD s string; -COMMIT; -SELECT * FROM t; -|"i", "s" - --- 548 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - ALTER TABLE t ADD s string; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i", "s" - --- 549 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); -COMMIT; -BEGIN TRANSACTION; - ALTER TABLE t ADD s string; -COMMIT; -SELECT * FROM t ORDER BY s; -|"i", "s" - --- 550 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (42); -COMMIT; -SELECT * FROM x; -|"x" -[42] - --- 551 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (42); - INSERT INTO t VALUES (420); -COMMIT; -SELECT * FROM x; -|"x" -[42] -[420] - --- 552 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (420); - INSERT INTO t VALUES (42); -COMMIT; -SELECT * FROM x; -|"x" -[42] -[420] - --- 553 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (420); - INSERT INTO t VALUES (42); - INSERT INTO t VALUES (100); -COMMIT; -SELECT * FROM x; -|"x" -[42] -[100] -[420] - --- 554 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (420); - INSERT INTO t VALUES (42); - INSERT INTO t VALUES (100); - DELETE FROM t WHERE i == 100; -COMMIT; -SELECT * FROM x; -|"x" -[42] -[420] - --- 555 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (420); - INSERT INTO t VALUES (42); - INSERT INTO t VALUES (100); -COMMIT; -BEGIN TRANSACTION; - DELETE FROM t WHERE i == 100; -COMMIT; -SELECT * FROM x; -|"x" -[42] -[420] - --- 556 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (1); - INSERT INTO t VALUES (2); - INSERT INTO t VALUES (3); -COMMIT; -SELECT * FROM x; -|"x" -[1] -[2] -[3] - --- 557 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (1); - INSERT INTO t VALUES (3); - INSERT INTO t VALUES (2); -COMMIT; -SELECT * FROM x; -|"x" -[1] -[2] -[3] - --- 558 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (2); - INSERT INTO t VALUES (1); - INSERT INTO t VALUES (3); -COMMIT; -SELECT * FROM x; -|"x" -[1] -[2] -[3] - --- 559 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (2); - INSERT INTO t VALUES (3); - INSERT INTO t VALUES (1); -COMMIT; -SELECT * FROM x; -|"x" -[1] -[2] -[3] - --- 560 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (3); - INSERT INTO t VALUES (1); - INSERT INTO t VALUES (2); -COMMIT; -SELECT * FROM x; -|"x" -[1] -[2] -[3] - --- 561 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (3); - INSERT INTO t VALUES (2); - INSERT INTO t VALUES (1); -COMMIT; -SELECT * FROM x; -|"x" -[1] -[2] -[3] - --- 562 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (bigint(1) << 100); - INSERT INTO t VALUES (bigint(1) << 100 - 1); - INSERT INTO t VALUES (bigint(1) << (256*8)); - INSERT INTO t VALUES (bigint(1) << 100 + 1); - INSERT INTO t VALUES (bigint(1) << 10); -COMMIT; -SELECT * FROM x; -|"x" -[1024] -[1267650600228229401496703205375] -[1267650600228229401496703205376] -[1267650600228229401496703205377] -[32317006071311007300714876688669951960444102669715484032130345427524655138867890893197201411522913463688717960921898019494119559150490921095088152386448283120630877367300996091750197750389652106796057638384067568276792218642619756161838094338476170470581645852036305042887575891541065808607552399123930385521914333389668342420684974786564569494856176035326322058077805659331026192708460314150258592864177116725943603718461857357598351152301645904403697613233287231227125684710820209725157101726931323469678542580656697935045997268352998638215525166389437335543602135433229604645318478604952148193555853611059596230656] - --- 563 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (bigint(1) << 100); - INSERT INTO t VALUES (bigint(1) << 100 - 1); - INSERT INTO t VALUES (bigint(1) << (256*8)); - INSERT INTO t VALUES (bigint(1) << 100 + 1); - INSERT INTO t VALUES (bigint(1) << 10); -COMMIT; -BEGIN TRANSACTION; - DELETE FROM t WHERE i == (bigint(1) << (256*8)); -COMMIT; -SELECT * FROM x; -|"x" -[1024] -[1267650600228229401496703205375] -[1267650600228229401496703205376] -[1267650600228229401496703205377] - --- 564 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (bigint(1) << 100); - INSERT INTO t VALUES (bigint(1) << 100 - 1); - INSERT INTO t VALUES (bigint(1) << 100 + 1); - INSERT INTO t VALUES (bigint(1) << 10); -COMMIT; -BEGIN TRANSACTION; - UPDATE t - i = i+10, - WHERE i == bigint(1) << 100; -COMMIT; -SELECT * FROM x; -|"x" -[1024] -[1267650600228229401496703205375] -[1267650600228229401496703205377] -[1267650600228229401496703205386] - --- 565 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (bigint(1) << 100); - INSERT INTO t VALUES (bigint(1) << 100 - 1); - INSERT INTO t VALUES (bigint(1) << (256*8)); - INSERT INTO t VALUES (bigint(1) << 100 + 1); - INSERT INTO t VALUES (bigint(1) << 10); -COMMIT; -BEGIN TRANSACTION; - UPDATE t - i = 42, - WHERE i == bigint(1) << (256*8); -COMMIT; -SELECT * FROM x; -|"x" -[42] -[1024] -[1267650600228229401496703205375] -[1267650600228229401496703205376] -[1267650600228229401496703205377] - --- 566 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (bigint(1) << 100); - INSERT INTO t VALUES (bigint(1) << 100 - 1); - INSERT INTO t VALUES (bigint(42)); - INSERT INTO t VALUES (bigint(1) << 100 + 1); - INSERT INTO t VALUES (bigint(1) << 10); -COMMIT; -BEGIN TRANSACTION; - UPDATE t - i = bigint(1) << (256*8), - WHERE i == 42; -COMMIT; -SELECT * FROM x; -|"x" -[1024] -[1267650600228229401496703205375] -[1267650600228229401496703205376] -[1267650600228229401496703205377] -[32317006071311007300714876688669951960444102669715484032130345427524655138867890893197201411522913463688717960921898019494119559150490921095088152386448283120630877367300996091750197750389652106796057638384067568276792218642619756161838094338476170470581645852036305042887575891541065808607552399123930385521914333389668342420684974786564569494856176035326322058077805659331026192708460314150258592864177116725943603718461857357598351152301645904403697613233287231227125684710820209725157101726931323469678542580656697935045997268352998638215525166389437335543602135433229604645318478604952148193555853611059596230656] - --- 567 -BEGIN TRANSACTION; - CREATE TABLE t (b blob); - CREATE INDEX x ON t (b); - INSERT INTO t VALUES (blob( - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" // > shortBlob - )); - DROP TABLE t; -COMMIT; -SELECT * FROM t; -||does not exist - --- 568 -BEGIN TRANSACTION; - CREATE TABLE t (b blob); - CREATE INDEX x ON t (b); - INSERT INTO t VALUES (blob( - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" // > shortBlob - )); - DROP TABLE t; -COMMIT; -BEGIN TRANSACTION; - DROP TABLE t; -COMMIT; -SELECT * FROM t; -||does not exist - --- 569 -BEGIN TRANSACTION; - CREATE TABLE t (b blob); - CREATE INDEX x ON t (b); - INSERT INTO t VALUES (blob( - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" // > shortBlob - )); - DROP INDEX x; -COMMIT; -SELECT len(string(b)) AS n FROM t; -|"n" -[320] - --- 570 -BEGIN TRANSACTION; - CREATE TABLE t (b blob); - CREATE INDEX x ON t (b); - INSERT INTO t VALUES (blob( - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"+ - "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" // > shortBlob - )); -COMMIT; -BEGIN TRANSACTION; - DROP INDEX x; -COMMIT; -SELECT len(string(b)) AS n FROM t; -|"n" -[320] - --- 571 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42); - ALTER TABLE t ADD s string; -COMMIT; -SELECT * FROM t; -|"i", "s" -[42 ] - --- 572 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42); -COMMIT; -BEGIN TRANSACTION; - ALTER TABLE t ADD s string; -COMMIT; -SELECT * FROM t; -|"i", "s" -[42 ] - --- 573 -BEGIN TRANSACTION; - CREATE TABLE t (i int); -COMMIT; -SELECT * FROM q.t; -||expected .*where - --- 574 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42); -COMMIT; -SELECT * FROM t AS u; -|"i" -[42] - --- 575 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42); -COMMIT; -SELECT u.x FROM t AS u; -||unknown field u.x - --- 576 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42); -COMMIT; -SELECT u.i FROM t AS u; -||unknown field u.i - --- 577 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42); -COMMIT; -SELECT i FROM t AS u; -|"i" -[42] - --- 578 -BEGIN TRANSACTION; - CREATE TABLE t (i int, b bool); - CREATE INDEX x ON t (b); - INSERT INTO t VALUES(24, false); - INSERT INTO t VALUES(333, NULL); - INSERT INTO t VALUES(42, true); - INSERT INTO t VALUES(240, false); - INSERT INTO t VALUES(420, true); -COMMIT; -SELECT i FROM t WHERE b ORDER BY i; -|"i" -[42] -[420] - --- 579 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES(10, "foo"); -COMMIT; -SELECT * FROM t WHERE i < "30"; -||type string.*type int64 - --- 580 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT * FROM x; -|"x" -[] -[] -[10] -[10] -[20] -[20] -[30] -[30] -[40] -[40] -[50] -[50] - --- 581 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT i FROM t WHERE i < 30; -|"i" -[10] -[20] -[20] -[10] - --- 582 // ordered -> index is used -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT i FROM t WHERE i < 30; -|"i" -[10] -[10] -[20] -[20] - --- 583 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT * FROM t WHERE i <= 30; -|"i" -[10] -[20] -[30] -[30] -[20] -[10] - --- 584 // ordered -> index is used -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT * FROM t WHERE i <= 30; -|"i" -[10] -[10] -[20] -[20] -[30] -[30] - --- 585 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT i FROM t WHERE i == 30; -|"i" -[30] -[30] - --- 586 // index is used -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT i FROM t WHERE i == 30; -|"i" -[30] -[30] - --- 587 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT * FROM t WHERE i >= 30; -|"i" -[50] -[40] -[30] -[30] -[40] -[50] - --- 588 // ordered -> index is used -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT * FROM t WHERE i >= 30; -|"i" -[30] -[30] -[40] -[40] -[50] -[50] - --- 589 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT * FROM t WHERE i > 30; -|"i" -[50] -[40] -[40] -[50] - --- 590 // ordered -> index is used -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT * FROM t WHERE i > 30; -|"i" -[40] -[40] -[50] -[50] - --- 591 -BEGIN TRANSACTION; - CREATE TABLE t (i int, b bool); - INSERT INTO t VALUES(24, false); - INSERT INTO t VALUES(333, NULL); - INSERT INTO t VALUES(42, true); - INSERT INTO t VALUES(240, false); - INSERT INTO t VALUES(420, true); -COMMIT; -SELECT i FROM t WHERE !b ORDER BY i; -|"i" -[24] -[240] - --- 592 -BEGIN TRANSACTION; - CREATE TABLE t (i int, b bool); - CREATE INDEX x ON t (b); - INSERT INTO t VALUES(24, false); - INSERT INTO t VALUES(333, NULL); - INSERT INTO t VALUES(42, true); - INSERT INTO t VALUES(240, false); - INSERT INTO t VALUES(420, true); -COMMIT; -SELECT i FROM t WHERE !b ORDER BY i; -|"i" -[24] -[240] - --- 593 // ordered -> index is used -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT i FROM t WHERE i < $1; // 30 -|"i" -[10] -[10] -[20] -[20] - --- 594 // ordered -> index is used -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT * FROM t WHERE i <= $1; // 30 -|"i" -[10] -[10] -[20] -[20] -[30] -[30] - --- 595 // index is used -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT i FROM t WHERE i == $1; // 30 -|"i" -[30] -[30] - --- 596 // ordered -> index is used -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT * FROM t WHERE i >= $1; // 30 -|"i" -[30] -[30] -[40] -[40] -[50] -[50] - --- 597 // ordered -> index is used -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT * FROM t WHERE i > $1; // 30 -|"i" -[40] -[40] -[50] -[50] - --- 598 // ordered -> index is used -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT i FROM t WHERE $1 > i; // 30 -|"i" -[10] -[10] -[20] -[20] - --- 599 // ordered -> index is used -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT * FROM t WHERE $1 >= i; // 30 -|"i" -[10] -[10] -[20] -[20] -[30] -[30] - --- 600 // index is used -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT i FROM t WHERE $1 == i; // 30 -|"i" -[30] -[30] - --- 601 // ordered -> index is used -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT * FROM t WHERE $1 <= i; // 30 -|"i" -[30] -[30] -[40] -[40] -[50] -[50] - --- 602 // ordered -> index is used -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT * FROM t WHERE $1 < i; // 30 -|"i" -[40] -[40] -[50] -[50] - --- 603 // ordered -> index is used -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT i FROM t WHERE 30 > i; -|"i" -[10] -[10] -[20] -[20] - --- 604 // ordered -> index is used -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT * FROM t WHERE 30 >= i; -|"i" -[10] -[10] -[20] -[20] -[30] -[30] - --- 605 // index is used -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT i FROM t WHERE 30 == i; -|"i" -[30] -[30] - --- 606 // ordered -> index is used -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT * FROM t WHERE 30 <= i; -|"i" -[30] -[30] -[40] -[40] -[50] -[50] - --- 607 // ordered -> index is used -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT * FROM t WHERE 30 < i; -|"i" -[40] -[40] -[50] -[50] - --- 608 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT * FROM t WHERE i < 30; -|"i" -[20] -[10] - --- 609 // ordered -> index is used -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE UNIQUE INDEX x ON t (i); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT * FROM t WHERE i < 30; -|"i" -[10] -[20] - --- 610 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE UNIQUE INDEX x ON t (i); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT * FROM t WHERE i < 30; -||duplicate - --- 611 // Issue #34 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42); -COMMIT; -SELECT * FROM t WHERE i == $0; -||parameter.*non zero - --- 612 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE TABLE __Table (i int); -COMMIT; -SELECT * FROM t; -||system table - --- 613 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE TABLE __Column (i int); -COMMIT; -SELECT * FROM t; -||system table - --- 614 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE TABLE __Index (i int); -COMMIT; -SELECT * FROM t; -||system table - --- 615 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - DROP TABLE __Table; -COMMIT; -SELECT * FROM t; -||system table - --- 616 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - DROP TABLE __Column; -COMMIT; -SELECT * FROM t; -||system table - --- 617 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - DROP TABLE __Index; -COMMIT; -SELECT * FROM t; -||system table - --- 618 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX __Table ON t (i); -COMMIT; -SELECT * FROM t; -||system table - --- 619 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX __Column ON t (i); -COMMIT; -SELECT * FROM t; -||system table - --- 620 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX __Index ON t (i); -COMMIT; -SELECT * FROM t; -||system table - --- 621 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON __Table (Name); -COMMIT; -SELECT * FROM t; -||system table - --- 622 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON __Column (Name); -COMMIT; -SELECT * FROM t; -||system table - --- 623 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON __Index (Name); -COMMIT; -SELECT * FROM t; -||system table - --- 624 -SELECT * FROM __Table; -|"Name", "Schema" - --- 625 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); -COMMIT; -SELECT * FROM __Table ORDER BY Name; -|"Name", "Schema" -[t CREATE TABLE t (i int64, s string);] - --- 626 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE TABLE u (b bool, i bigint, t time, d duration); -COMMIT; -SELECT * FROM __Table ORDER BY Name; -|"Name", "Schema" -[t CREATE TABLE t (i int64, s string);] -[u CREATE TABLE u (b bool, i bigint, t time, d duration);] - --- 627 -SELECT * FROM __Column; -|"TableName", "Ordinal", "Name", "Type" - --- 628 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); -COMMIT; -SELECT * FROM __Column ORDER BY TableName, Name; -|"TableName", "Ordinal", "Name", "Type" -[t 1 i int64] -[t 2 s string] - --- 629 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE TABLE u (b bool, i bigint, t time, d duration); -COMMIT; -SELECT * FROM __Column ORDER BY TableName, Ordinal; -|"TableName", "Ordinal", "Name", "Type" -[t 1 i int64] -[t 2 s string] -[u 1 b bool] -[u 2 i bigint] -[u 3 t time] -[u 4 d duration] - --- 630 -SELECT * FROM __Index; -|"TableName", "ColumnName", "Name", "IsUnique" - --- 631 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); -COMMIT; -SELECT * FROM __Index ORDER BY TableName, Name; -|"TableName", "ColumnName", "Name", "IsUnique" - --- 632 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE INDEX x ON t (i); -COMMIT; -SELECT * FROM __Index WHERE !hasPrefix(TableName, "__") ORDER BY TableName, ColumnName, Name; -|"TableName", "ColumnName", "Name", "IsUnique" -[t i x false] - --- 633 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE INDEX x ON t (i); - CREATE INDEX id ON t (id()); - CREATE TABLE u (b bool, i bigint, t time, d duration); -COMMIT; -SELECT * FROM __Index WHERE !hasPrefix(TableName, "__") ORDER BY TableName, ColumnName, Name; -|"TableName", "ColumnName", "Name", "IsUnique" -[t i x false] -[t id() id false] - --- 634 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE INDEX x ON t (i); - CREATE INDEX id ON t (id()); - CREATE TABLE u (b bool, i bigint, t time, d duration); - CREATE INDEX z ON u (t); - CREATE UNIQUE INDEX y ON u (i); -COMMIT; -SELECT * FROM __Index WHERE !hasPrefix(TableName, "__") ORDER BY TableName, ColumnName, Name; -|"TableName", "ColumnName", "Name", "IsUnique" -[t i x false] -[t id() id false] -[u i y true] -[u t z false] - --- 635 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE INDEX x ON t (i); - CREATE INDEX id ON t (id()); - CREATE TABLE u (b bool, i bigint, t time, d duration); - CREATE INDEX z ON u (t); - CREATE UNIQUE INDEX y ON u (i); -COMMIT; -SELECT c.TableName, c.Ordinal, c.Name -FROM __Table AS t, __Column AS c -WHERE t.Name == "u" && t.Name == c.TableName -ORDER BY c.Ordinal; -|"c.TableName", "c.Ordinal", "c.Name" -[u 1 b] -[u 2 i] -[u 3 t] -[u 4 d] - --- 636 // https://github.com/cznic/ql/issues/36 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - INSERT INTO t VALUES (1, "test"); -COMMIT; -SELECT * FROM t WHERE s == "test"; -|"i", "s" -[1 test] - --- 637 // https://github.com/cznic/ql/issues/36 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - INSERT INTO t VALUES (1, "test"); - CREATE INDEX idx_s ON t (s); -COMMIT; -SELECT * FROM t WHERE s == "test"; -|"i", "s" -[1 test] - --- 638 // https://github.com/cznic/ql/issues/37 -BEGIN TRANSACTION; - CREATE TABLE artist (id int64, name string); - CREATE TABLE data_types (id int64, _uint int64, _uint8 int64, _uint16 - int64, _uint32 int64, _uint64 int64, _int int64, _int8 int64, - _int16 int64, _int32 int64, _int64 int64, _float32 float32, - _float64 float64, _bool bool, _string string, _date time, _time - time); -COMMIT; -SELECT * FROM __Table ORDER BY Name; // Must sort, map range is not deterministic. -|"Name", "Schema" -[artist CREATE TABLE artist (id int64, name string);] -[data_types CREATE TABLE data_types (id int64, _uint int64, _uint8 int64, _uint16 int64, _uint32 int64, _uint64 int64, _int int64, _int8 int64, _int16 int64, _int32 int64, _int64 int64, _float32 float32, _float64 float64, _bool bool, _string string, _date time, _time time);] - --- 639 // https://github.com/cznic/ql/issues/37 -BEGIN TRANSACTION; - CREATE TABLE artist (id int64, name string); - CREATE TABLE data_types (id int64, _uint int64, _uint8 int64, _uint16 - int64, _uint32 int64, _uint64 int64, _int int64, _int8 int64, - _int16 int64, _int32 int64, _int64 int64, _float32 float32, - _float64 float64, _bool bool, _string string, _date time, _time - time); -COMMIT; -SELECT * FROM __Table WHERE Name == "artist"; -|"Name", "Schema" -[artist CREATE TABLE artist (id int64, name string);] - --- 640 // https://github.com/cznic/ql/issues/37 -BEGIN TRANSACTION; - CREATE TABLE artist (id int64, name string); - CREATE TABLE data_types (id int64, _uint int64, _uint8 int64, _uint16 - int64, _uint32 int64, _uint64 int64, _int int64, _int8 int64, - _int16 int64, _int32 int64, _int64 int64, _float32 float32, - _float64 float64, _bool bool, _string string, _date time, _time - time); -COMMIT; -SELECT * FROM __Column ORDER BY TableName, Ordinal; -|"TableName", "Ordinal", "Name", "Type" -[artist 1 id int64] -[artist 2 name string] -[data_types 1 id int64] -[data_types 2 _uint int64] -[data_types 3 _uint8 int64] -[data_types 4 _uint16 int64] -[data_types 5 _uint32 int64] -[data_types 6 _uint64 int64] -[data_types 7 _int int64] -[data_types 8 _int8 int64] -[data_types 9 _int16 int64] -[data_types 10 _int32 int64] -[data_types 11 _int64 int64] -[data_types 12 _float32 float32] -[data_types 13 _float64 float64] -[data_types 14 _bool bool] -[data_types 15 _string string] -[data_types 16 _date time] -[data_types 17 _time time] - --- 641 // https://github.com/cznic/ql/issues/37 -BEGIN TRANSACTION; - CREATE TABLE artist (id int64, name string); - CREATE TABLE data_types (id int64, _uint int64, _uint8 int64, _uint16 - int64, _uint32 int64, _uint64 int64, _int int64, _int8 int64, - _int16 int64, _int32 int64, _int64 int64, _float32 float32, - _float64 float64, _bool bool, _string string, _date time, _time - time); -COMMIT; -SELECT * FROM __Column WHERE TableName == "artist" ORDER BY TableName, Ordinal; -|"TableName", "Ordinal", "Name", "Type" -[artist 1 id int64] -[artist 2 name string] - --- 642 -BEGIN TRANSACTION; - CREATE TABLE t (i int, j int, k int); - INSERT INTO t VALUES - (1, 2, 3), - (4, 5, 6); - CREATE TABLE u (x int, y int, z int); - INSERT INTO u VALUES - (10, 20, 30), - (40, 50, 60); -COMMIT; -SELECT * FROM t, u WHERE u.y < 60 && t.k < 7; -|"t.i", "t.j", "t.k", "u.x", "u.y", "u.z" -[4 5 6 40 50 60] -[4 5 6 10 20 30] -[1 2 3 40 50 60] -[1 2 3 10 20 30] - --- 643 // order -> xk used -BEGIN TRANSACTION; - CREATE TABLE t (i int, j int, k int); - CREATE INDEX xk ON t (k); - INSERT INTO t VALUES - (1, 2, 3), - (4, 5, 6); - CREATE TABLE u (x int, y int, z int); - INSERT INTO u VALUES - (10, 20, 30), - (40, 50, 60); -COMMIT; -SELECT * FROM t, u WHERE u.y < 60 && t.k < 7; -|"t.i", "t.j", "t.k", "u.x", "u.y", "u.z" -[1 2 3 40 50 60] -[1 2 3 10 20 30] -[4 5 6 40 50 60] -[4 5 6 10 20 30] - --- 644 // order -> xy used -BEGIN TRANSACTION; - CREATE TABLE t (i int, j int, k int); - INSERT INTO t VALUES - (1, 2, 3), - (4, 5, 6); - CREATE TABLE u (x int, y int, z int); - CREATE INDEX xy ON u (y); - INSERT INTO u VALUES - (10, 20, 30), - (40, 50, 60); -COMMIT; -SELECT * FROM t, u WHERE u.y < 60 && t.k < 7; -|"t.i", "t.j", "t.k", "u.x", "u.y", "u.z" -[4 5 6 10 20 30] -[4 5 6 40 50 60] -[1 2 3 10 20 30] -[1 2 3 40 50 60] - --- 645 // order -> both xk and xy used -BEGIN TRANSACTION; - CREATE TABLE t (i int, j int, k int); - CREATE INDEX xk ON t (k); - INSERT INTO t VALUES - (1, 2, 3), - (4, 5, 6); - CREATE TABLE u (x int, y int, z int); - CREATE INDEX xy ON u (y); - INSERT INTO u VALUES - (10, 20, 30), - (40, 50, 60); -COMMIT; -SELECT * FROM t, u WHERE u.y < 60 && t.k < 7; -|"t.i", "t.j", "t.k", "u.x", "u.y", "u.z" -[1 2 3 10 20 30] -[1 2 3 40 50 60] -[4 5 6 10 20 30] -[4 5 6 40 50 60] - --- 646 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); -COMMIT; -SELECT * FROM t OFFSET -1; // no rows -> not evaluated -|"i" - --- 647 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); -COMMIT; -SELECT * FROM t OFFSET 0; // no rows -> not evaluated -|"i" - --- 648 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); -COMMIT; -SELECT * FROM t OFFSET 1; // no rows -> not evaluated -|"i" - --- 649 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42), (24); -COMMIT; -SELECT * FROM t ORDER BY id() OFFSET -1; -||invalid .* -1 .*must.* non-negative - --- 650 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42), (24); -COMMIT; -SELECT * FROM t ORDER BY id() OFFSET 0; -|"i" -[42] -[24] - --- 651 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42), (24); -COMMIT; -SELECT * FROM t ORDER BY id() OFFSET 1; -|"i" -[24] - --- 652 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42), (24); -COMMIT; -SELECT * FROM t ORDER BY id() OFFSET 2; -|"i" - --- 653 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); -COMMIT; -SELECT * FROM t ORDER BY id() LIMIT -1; // no rows -> not evaluated -|"i" - --- 654 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); -COMMIT; -SELECT * FROM t ORDER BY id() LIMIT 0; // no rows -> not evaluated -|"i" - --- 655 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); -COMMIT; -SELECT * FROM t ORDER BY id() LIMIT 1; // no rows -> not evaluated -|"i" - --- 656 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42), (24); -COMMIT; -SELECT * FROM t ORDER BY id() LIMIT -1; -||invalid .* -1 .*must.* non-negative - --- 657 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42), (24); -COMMIT; -SELECT * FROM t ORDER BY id() LIMIT 0; -|"i" - --- 658 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42), (24); -COMMIT; -SELECT * FROM t ORDER BY id() LIMIT 1; -|"i" -[42] - --- 659 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42), (24); -COMMIT; -SELECT * FROM t ORDER BY id() LIMIT 2; -|"i" -[42] -[24] - --- 660 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42), (24); -COMMIT; -SELECT * FROM t ORDER BY id() LIMIT 3; -|"i" -[42] -[24] - --- 661 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42), (24); -COMMIT; -SELECT * FROM t ORDER BY id() LIMIT 0 OFFSET 0; -|"i" - --- 662 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42), (24); -COMMIT; -SELECT * FROM t ORDER BY id() LIMIT 0 OFFSET 1; -|"i" - --- 663 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42), (24); -COMMIT; -SELECT * FROM t ORDER BY id() LIMIT 0 OFFSET 2; -|"i" - --- 664 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42), (24); -COMMIT; -SELECT * FROM t ORDER BY id() LIMIT 0 OFFSET 3; -|"i" - --- 665 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42), (24); -COMMIT; -SELECT * FROM t ORDER BY id() LIMIT 1 OFFSET 0; -|"i" -[42] - --- 666 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42), (24); -COMMIT; -SELECT * FROM t ORDER BY id() LIMIT 1 OFFSET 1; -|"i" -[24] - --- 667 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42), (24); -COMMIT; -SELECT * FROM t ORDER BY id() LIMIT 1 OFFSET 2; -|"i" - --- 668 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42), (24); -COMMIT; -SELECT * FROM t ORDER BY id() LIMIT 1 OFFSET 3; -|"i" - --- 669 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42), (24); -COMMIT; -SELECT * FROM t ORDER BY id() LIMIT 2 OFFSET 0; -|"i" -[42] -[24] - --- 670 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42), (24); -COMMIT; -SELECT * FROM t ORDER BY id() LIMIT 2 OFFSET 1; -|"i" -[24] - --- 671 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42), (24); -COMMIT; -SELECT * FROM t ORDER BY id() LIMIT 2 OFFSET 2; -|"i" - --- 672 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42), (24); -COMMIT; -SELECT * FROM t ORDER BY id() LIMIT 2 OFFSET 3; -|"i" - --- 673 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42), (24); -COMMIT; -SELECT * FROM t ORDER BY id() LIMIT 3 OFFSET 0; -|"i" -[42] -[24] - --- 674 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42), (24); -COMMIT; -SELECT * FROM t ORDER BY id() LIMIT 3 OFFSET 1; -|"i" -[24] - --- 675 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42), (24); -COMMIT; -SELECT * FROM t ORDER BY id() LIMIT 3 OFFSET 2; -|"i" - --- 676 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42), (24); -COMMIT; -SELECT * FROM t ORDER BY id() LIMIT 3 OFFSET 3; -|"i" - --- 677 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1), (2), (3); - CREATE TABLE u (i int); - INSERT INTO u VALUES(10), (20), (30); -COMMIT; -SELECT * FROM - (SELECT * FROM t ORDER BY i LIMIT 2 OFFSET 1;) AS a, - (SELECT * FROM u ORDER BY i) AS b, -ORDER BY a.i, b.i; -|"a.i", "b.i" -[2 10] -[2 20] -[2 30] -[3 10] -[3 20] -[3 30] - --- 678 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1), (2), (3); - CREATE TABLE u (i int); - INSERT INTO u VALUES(10), (20), (30); -COMMIT; -SELECT * FROM - (SELECT * FROM t ORDER BY i LIMIT 2 OFFSET 1;) AS a, - (SELECT * FROM u ORDER BY i OFFSET 1) AS b, -ORDER BY a.i, b.i; -|"a.i", "b.i" -[2 20] -[2 30] -[3 20] -[3 30] - --- 679 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1), (2), (3); - CREATE TABLE u (i int); - INSERT INTO u VALUES(10), (20), (30); -COMMIT; -SELECT * FROM - (SELECT * FROM t ORDER BY i LIMIT 2 OFFSET 1;) AS a, - (SELECT * FROM u ORDER BY i LIMIT 1) AS b, -ORDER BY a.i, b.i; -|"a.i", "b.i" -[2 10] -[3 10] - --- 680 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1), (2), (3); - CREATE TABLE u (i int); - INSERT INTO u VALUES(10), (20), (30); -COMMIT; -SELECT * FROM - (SELECT * FROM t ORDER BY i LIMIT 2 OFFSET 1;) AS a, - (SELECT * FROM u ORDER BY i LIMIT 1 OFFSET 1) AS b, -ORDER BY a.i, b.i; -|"a.i", "b.i" -[2 20] -[3 20] - --- 681 // https://github.com/cznic/ql/issues/41 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1), (2), (3); - CREATE TABLE u (i int); - INSERT INTO u VALUES(10), (20), (30); -COMMIT; -SELECT * FROM - (SELECT * FROM t ORDER BY i LIMIT 2 OFFSET 1;) AS a, - (SELECT * FROM u ORDER BY i LIMIT 1 OFFSET 1) AS b, -ORDER BY a.i, b.i -LIMIT 1; -|"a.i", "b.i" -[2 20] - --- 682 // https://github.com/cznic/ql/issues/42 -BEGIN TRANSACTION; - DROP TABLE IF EXISTS fibonacci; - CREATE TABLE fibonacci( - input int, - output int - ); -COMMIT; - -BEGIN TRANSACTION; - INSERT INTO fibonacci (input, output) VALUES (0, 0); - INSERT INTO fibonacci (input, output) VALUES (1, 1); - INSERT INTO fibonacci (input, output) VALUES (2, 1); - INSERT INTO fibonacci (input, output) VALUES (3, 2); - INSERT INTO fibonacci (input, output) VALUES (4, 3); - INSERT INTO fibonacci (input, output) VALUES (5, 5); - INSERT INTO fibonacci (input, output) VALUES (6, 8); - INSERT INTO fibonacci (input, output) VALUES (7, 13); - INSERT INTO fibonacci (input, output) VALUES (8, 21); - INSERT INTO fibonacci (input, output) VALUES (9, 34); -COMMIT; - ---' Should print 4. -SELECT count(1) AS total FROM fibonacci WHERE input >= 5 && input <= 7 OR input == 3; -|"total" -[4] - --- 683 // https://github.com/cznic/ql/issues/42 -BEGIN TRANSACTION; - DROP TABLE IF EXISTS fibonacci; - CREATE TABLE fibonacci( - input int, - output int - ); -COMMIT; - -BEGIN TRANSACTION; - INSERT INTO fibonacci (input, output) VALUES (0, 0); - INSERT INTO fibonacci (input, output) VALUES (1, 1); - INSERT INTO fibonacci (input, output) VALUES (2, 1); - INSERT INTO fibonacci (input, output) VALUES (3, 2); - INSERT INTO fibonacci (input, output) VALUES (4, 3); - INSERT INTO fibonacci (input, output) VALUES (5, 5); - INSERT INTO fibonacci (input, output) VALUES (6, 8); - INSERT INTO fibonacci (input, output) VALUES (7, 13); - INSERT INTO fibonacci (input, output) VALUES (8, 21); - INSERT INTO fibonacci (input, output) VALUES (9, 34); -COMMIT; - ---' Should output (6, 8) (5, 5). -SELECT * FROM fibonacci WHERE input >= 5 && input <= 7 OR input == 3 ORDER BY input DESC LIMIT 2 OFFSET 1; -|"input", "output" -[6 8] -[5 5] - --- 684 // https://github.com/cznic/ql/issues/42 -BEGIN TRANSACTION; - DROP TABLE IF EXISTS fibonacci; - CREATE TABLE fibonacci( - input int, - output int - ); -COMMIT; - -BEGIN TRANSACTION; - INSERT INTO fibonacci (input, output) VALUES (0, 0); - INSERT INTO fibonacci (input, output) VALUES (1, 1); - INSERT INTO fibonacci (input, output) VALUES (2, 1); - INSERT INTO fibonacci (input, output) VALUES (3, 2); - INSERT INTO fibonacci (input, output) VALUES (4, 3); - INSERT INTO fibonacci (input, output) VALUES (5, 5); - INSERT INTO fibonacci (input, output) VALUES (6, 8); - INSERT INTO fibonacci (input, output) VALUES (7, 13); - INSERT INTO fibonacci (input, output) VALUES (8, 21); - INSERT INTO fibonacci (input, output) VALUES (9, 34); - --' Let's delete 4 rows. - // Delete where input == 5, input == 6, input == 7 or input == 3 - DELETE FROM fibonacci WHERE input >= 5 && input <= 7 OR input == 3; -COMMIT; -SELECT * FROM fibonacci ORDER BY input; -|"input", "output" -[0 0] -[1 1] -[2 1] -[4 3] -[8 21] -[9 34] - --- 685 // https://github.com/cznic/ql/issues/42 -BEGIN TRANSACTION; - DROP TABLE IF EXISTS fibonacci; - CREATE TABLE fibonacci( - input int, - output int - ); -COMMIT; - -BEGIN TRANSACTION; - INSERT INTO fibonacci (input, output) VALUES (0, 0); - INSERT INTO fibonacci (input, output) VALUES (1, 1); - INSERT INTO fibonacci (input, output) VALUES (2, 1); - INSERT INTO fibonacci (input, output) VALUES (3, 2); - INSERT INTO fibonacci (input, output) VALUES (4, 3); - INSERT INTO fibonacci (input, output) VALUES (5, 5); - INSERT INTO fibonacci (input, output) VALUES (6, 8); - INSERT INTO fibonacci (input, output) VALUES (7, 13); - INSERT INTO fibonacci (input, output) VALUES (8, 21); - INSERT INTO fibonacci (input, output) VALUES (9, 34); -COMMIT; ---' Let's delete 4 rows. -BEGIN TRANSACTION; - // Delete where input == 5, input == 6, input == 7 or input == 3 - DELETE FROM fibonacci WHERE input >= 5 && input <= 7 OR input == 3; -COMMIT; -SELECT * FROM fibonacci ORDER BY input; -|"input", "output" -[0 0] -[1 1] -[2 1] -[4 3] -[8 21] -[9 34] - --- 686 // https://github.com/cznic/ql/issues/42 -BEGIN TRANSACTION; - DROP TABLE IF EXISTS fibonacci; - CREATE TABLE fibonacci( - input int, - output int - ); -COMMIT; - -BEGIN TRANSACTION; - INSERT INTO fibonacci (input, output) VALUES (0, 0); - INSERT INTO fibonacci (input, output) VALUES (1, 1); - INSERT INTO fibonacci (input, output) VALUES (2, 1); - INSERT INTO fibonacci (input, output) VALUES (3, 2); - INSERT INTO fibonacci (input, output) VALUES (4, 3); - INSERT INTO fibonacci (input, output) VALUES (5, 5); - INSERT INTO fibonacci (input, output) VALUES (6, 8); - INSERT INTO fibonacci (input, output) VALUES (7, 13); - INSERT INTO fibonacci (input, output) VALUES (8, 21); - INSERT INTO fibonacci (input, output) VALUES (9, 34); - --' Let's delete 4 rows. - // Delete where input == 5, input == 6, input == 7 or input == 3 - DELETE FROM fibonacci WHERE input >= 5 && input <= 7 OR input == 3; -COMMIT; ---' Try to count the rows we've just deleted, using the very same condition. Result is 1, should be 0. -SELECT count() AS total FROM fibonacci WHERE input >= 5 && input <= 7 OR input == 3; -|"total" -[0] - --- 687 // https://github.com/cznic/ql/issues/42 -BEGIN TRANSACTION; - DROP TABLE IF EXISTS fibonacci; - CREATE TABLE fibonacci( - input int, - output int - ); -COMMIT; - -BEGIN TRANSACTION; - INSERT INTO fibonacci (input, output) VALUES (0, 0); - INSERT INTO fibonacci (input, output) VALUES (1, 1); - INSERT INTO fibonacci (input, output) VALUES (2, 1); - INSERT INTO fibonacci (input, output) VALUES (3, 2); - INSERT INTO fibonacci (input, output) VALUES (4, 3); - INSERT INTO fibonacci (input, output) VALUES (5, 5); - INSERT INTO fibonacci (input, output) VALUES (6, 8); - INSERT INTO fibonacci (input, output) VALUES (7, 13); - INSERT INTO fibonacci (input, output) VALUES (8, 21); - INSERT INTO fibonacci (input, output) VALUES (9, 34); -COMMIT; -BEGIN TRANSACTION; - --' Let's delete 4 rows. - // Delete where input == 5, input == 6, input == 7 or input == 3 - DELETE FROM fibonacci WHERE input >= 5 && input <= 7 OR input == 3; -COMMIT; ---' Try to count the rows we've just deleted, using the very same condition. Result is 1, should be 0. -SELECT count() AS total FROM fibonacci WHERE input >= 5 && input <= 7 OR input == 3; -|"total" -[0] - --- 688 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1); - DELETE FROM t WHERE i == 1; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" - --- 689 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1), (2); - DELETE FROM t WHERE i == 1; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[2] - --- 690 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1), (2); - DELETE FROM t WHERE i == 2; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[1] - --- 691 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1), (2), (3); - DELETE FROM t WHERE i == 1; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[2] -[3] - --- 692 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1), (2), (3); - DELETE FROM t WHERE i == 2; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[1] -[3] - --- 693 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1), (2), (3); - DELETE FROM t WHERE i == 3; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[1] -[2] - --- 694 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1), (2), (3), (4); - DELETE FROM t WHERE i == 1; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[2] -[3] -[4] - --- 695 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1), (2), (3), (4); - DELETE FROM t WHERE i == 2; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[1] -[3] -[4] - --- 696 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1), (2), (3), (4); - DELETE FROM t WHERE i == 3; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[1] -[2] -[4] - --- 697 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1), (2), (3), (4); - DELETE FROM t WHERE i == 4; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[1] -[2] -[3] - --- 698 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1), (2), (3), (4); - DELETE FROM t WHERE i == 1; - DELETE FROM t WHERE i == 2; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[3] -[4] - --- 699 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1), (2), (3), (4); - DELETE FROM t WHERE i == 2; - DELETE FROM t WHERE i == 1; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[3] -[4] - --- 700 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1), (2), (3), (4); - DELETE FROM t WHERE i == 2; - DELETE FROM t WHERE i == 3; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[1] -[4] - --- 701 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1), (2), (3), (4); - DELETE FROM t WHERE i == 3; - DELETE FROM t WHERE i == 2; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[1] -[4] - --- 702 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1), (2), (3), (4); - DELETE FROM t WHERE i == 3; - DELETE FROM t WHERE i == 4; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[1] -[2] - --- 703 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1), (2), (3), (4); - DELETE FROM t WHERE i == 4; - DELETE FROM t WHERE i == 3; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[1] -[2] - --- 704 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1), (2), (3), (4); - DELETE FROM t WHERE i == 1; - DELETE FROM t WHERE i == 3; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[2] -[4] - --- 705 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1), (2), (3), (4); - DELETE FROM t WHERE i == 3; - DELETE FROM t WHERE i == 1; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[2] -[4] - --- 706 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1), (2), (3), (4); - DELETE FROM t WHERE i == 1; - DELETE FROM t WHERE i == 4; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[2] -[3] - --- 707 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1), (2), (3), (4); - DELETE FROM t WHERE i == 4; - DELETE FROM t WHERE i == 1; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[2] -[3] - --- 708 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1), (2), (3), (4); - DELETE FROM t WHERE i == 2; - DELETE FROM t WHERE i == 4; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[1] -[3] - --- 709 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(1), (2), (3), (4); - DELETE FROM t WHERE i == 4; - DELETE FROM t WHERE i == 2; -COMMIT; -SELECT * FROM t ORDER BY i; -|"i" -[1] -[3] - --- 710 // https://github.com/cznic/ql/issues/43 -SELECT Name, Unique FROM __Index; -||expected .*Field - --- 711 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE INDEX x ON t (s); - INSERT INTO t VALUES (1, "bar"), (2, "foo"); -COMMIT; -SELECT s FROM t; -|"s" -[foo] -[bar] - --- 712 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE INDEX x ON t (s); - INSERT INTO t VALUES (1, "bar"), (2, "foo"); -COMMIT; -SELECT * FROM x; -|"x" -[bar] -[foo] - --- 713 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE INDEX x ON t (s); - CREATE INDEX x ON t (s); - INSERT INTO t VALUES (1, "bar"), (2, "foo"); -COMMIT; -SELECT * FROM x; -||already - --- 714 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE INDEX IF NOT EXISTS x ON t (s); - INSERT INTO t VALUES (1, "bar"), (2, "foo"); -COMMIT; -SELECT * FROM x; -|"x" -[bar] -[foo] - --- 715 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE INDEX x ON t (s); - CREATE INDEX IF NOT EXISTS x ON t (s); - INSERT INTO t VALUES (1, "bar"), (2, "foo"); -COMMIT; -SELECT * FROM x; -|"x" -[bar] -[foo] - --- 716 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE INDEX IF NOT EXISTS x ON t (s); - CREATE INDEX IF NOT EXISTS x ON t (s); - INSERT INTO t VALUES (1, "bar"), (2, "foo"); -COMMIT; -SELECT s FROM t WHERE s != "z"; -|"s" -[bar] -[foo] - --- 717 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE INDEX IF NOT EXISTS x ON t (s); - INSERT INTO t VALUES (1, "bar"), (2, "foo"); -COMMIT; -SELECT s FROM t WHERE s < "z"; // ordered -> index is used -|"s" -[bar] -[foo] - --- 718 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE INDEX IF NOT EXISTS x ON t (s); - INSERT INTO t VALUES (1, "bar"), (2, "foo"); - DROP INDEX x; -COMMIT; -SELECT s FROM t WHERE s < "z"; -|"s" -[foo] -[bar] - --- 719 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE INDEX IF NOT EXISTS x ON t (s); - INSERT INTO t VALUES (1, "bar"), (2, "foo"); - DROP INDEX x; - DROP INDEX x; -COMMIT; -SELECT s FROM t WHERE s < "z"; -||does not exist - --- 720 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE INDEX IF NOT EXISTS x ON t (s); - INSERT INTO t VALUES (1, "bar"), (2, "foo"); - DROP INDEX IF EXISTS x; - DROP INDEX x; -COMMIT; -SELECT s FROM t WHERE s < "z"; -||does not exist - --- 721 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE INDEX IF NOT EXISTS x ON t (s); - INSERT INTO t VALUES (1, "bar"), (2, "foo"); - DROP INDEX x; - DROP INDEX IF EXISTS x; -COMMIT; -SELECT s FROM t WHERE s < "z"; -|"s" -[foo] -[bar] - --- 722 -BEGIN TRANSACTION; - CREATE TABLE t (p string, c blob); - CREATE UNIQUE INDEX x ON t (p); - INSERT INTO t VALUES - ("empty", blob("")), - ; -COMMIT; -SELECT p, string(c) FROM t; -|"p", "" -[empty ] - --- 723 -BEGIN TRANSACTION; - CREATE TABLE t (p string, c blob); - CREATE INDEX x ON t (p); - INSERT INTO t VALUES - ("empty", blob("")), - ; -COMMIT; -BEGIN TRANSACTION; - DELETE FROM t WHERE p == "empty"; -COMMIT; -SELECT p, string(c) FROM t; -|"p", "" - --- 724 -BEGIN TRANSACTION; - CREATE TABLE t (p string, c blob); - CREATE UNIQUE INDEX x ON t (p); - INSERT INTO t VALUES - ("empty", blob("")), - ; -COMMIT; -BEGIN TRANSACTION; - DELETE FROM t WHERE p == "empty"; -COMMIT; -SELECT p, string(c) FROM t; -|"p", "" - --- S 725 -BEGIN TRANSACTION; - UPDATE none SET - DepartmentID = DepartmentID+1000, - WHERE DepartmentID == 33; -COMMIT; -SELECT * FROM employee; -||table.*not.*exist - --- S 726 -BEGIN TRANSACTION; - UPDATE employee SET - FirstName = "Williams" - WHERE DepartmentID == 33; -COMMIT; -SELECT * FROM employee; -||unknown.*FirstName - --- S 727 -BEGIN TRANSACTION; - UPDATE employee SET - DepartmentID = DepartmentID+1000, - WHERE DepartmentID == 33; -COMMIT; -SELECT * FROM employee -ORDER BY LastName; -|"LastName", "DepartmentID" -[Heisenberg 1033] -[Jones 1033] -[Rafferty 31] -[Robinson 34] -[Smith 34] -[Williams ] - --- 728 // https://github.com/cznic/ql/issues/49 -BEGIN TRANSACTION; - CREATE TABLE IF NOT EXISTS t (username string, departname string, created time, detail_id int, height float64, avatar blob, is_man bool); - CREATE UNIQUE INDEX UQE_userinfo_username ON t (username); - INSERT INTO t (username, departname, created, detail_id, height, avatar, is_man) VALUES ( - "xiaolunwen", - "dev", - now(), - 1, - 1.78, - blob("012"), - true, - ); - DELETE FROM t WHERE id() IN (SELECT id() FROM t); -COMMIT; -SELECT * FROM t; -|"username", "departname", "created", "detail_id", "height", "avatar", "is_man" - --- 729 // https://github.com/cznic/ql/issues/49 -BEGIN TRANSACTION; - CREATE TABLE IF NOT EXISTS t (username string, departname string, created time, detail_id int, height float64, avatar blob, is_man bool); - CREATE UNIQUE INDEX UQE_userinfo_username ON t (username); - INSERT INTO t (username, departname, created, detail_id, height, avatar, is_man) VALUES ( - "xiaolunwen", - "dev", - now(), - 1, - 1.78, - __testBlob(256), - true, - ); - DELETE FROM t WHERE id() IN (SELECT id() FROM t); -COMMIT; -SELECT * FROM t; -|"username", "departname", "created", "detail_id", "height", "avatar", "is_man" - --- 730 // https://github.com/cznic/ql/issues/49 -BEGIN TRANSACTION; - CREATE TABLE IF NOT EXISTS t (username string, departname string, created time, detail_id int, height float64, avatar blob, is_man bool); - CREATE UNIQUE INDEX UQE_userinfo_username ON t (username); - INSERT INTO t (username, departname, created, detail_id, height, avatar, is_man) VALUES ( - "xiaolunwen", - "dev", - now(), - 1, - 1.78, - __testBlob(1<<16), - true, - ); - DELETE FROM t WHERE id() IN (SELECT id() FROM t); -COMMIT; -SELECT * FROM t; -|"username", "departname", "created", "detail_id", "height", "avatar", "is_man" - --- 731 // https://github.com/cznic/ql/issues/49 -BEGIN TRANSACTION; - CREATE TABLE IF NOT EXISTS t (username string, departname string, created time, detail_id int, height float64, avatar blob, is_man bool); - CREATE UNIQUE INDEX UQE_userinfo_username ON t (username); - INSERT INTO t (username, departname, created, detail_id, height, avatar, is_man) VALUES ( - "xiaolunwen", - "dev", - now(), - 1, - 1.78, - __testBlob(1<<20), - true, - ); - DELETE FROM t WHERE id() IN (SELECT id() FROM t); -COMMIT; -SELECT * FROM t; -|"username", "departname", "created", "detail_id", "height", "avatar", "is_man" - --- 732 // https://github.com/cznic/ql/issues/49 -BEGIN TRANSACTION; - CREATE TABLE IF NOT EXISTS t (username string, departname string, created time, detail_id int, height float64, avatar blob, is_man bool); - CREATE UNIQUE INDEX UQE_userinfo_username ON t (username); - INSERT INTO t (username, departname, created, detail_id, height, avatar, is_man) VALUES ( - "xiaolunwen", - "dev", - now(), - 1, - 1.78, - __testBlob(1<<20), - true, - ), ( - "2xiaolunwen", - "2dev", - now(), - 2, - 2.78, - __testBlob(1<<21), - true, - ); - DELETE FROM t WHERE id() IN (SELECT id() FROM t WHERE username == "xiaolunwen"); //TODO simplify, also everywhere else -COMMIT; -SELECT id() IN (SELECT id() FROM t WHERE username == "2xiaolunwen"), username == "2xiaolunwen", len(string(avatar)) == 1<<21 FROM t; -|"", "", "" -[true true true] - --- 733 // https://github.com/cznic/ql/issues/49 -BEGIN TRANSACTION; - CREATE TABLE IF NOT EXISTS t (username string, departname string, created time, detail_id int, height float64, avatar blob, is_man bool); - CREATE UNIQUE INDEX UQE_userinfo_username ON t (username); - INSERT INTO t (username, departname, created, detail_id, height, avatar, is_man) VALUES ( - "xiaolunwen", - "dev", - now(), - 1, - 1.78, - __testBlob(1<<20), - true, - ), ( - "2xiaolunwen", - "2dev", - now(), - 2, - 2.78, - __testBlob(1<<21), - true, - ); - DELETE FROM t WHERE id() IN (SELECT id() FROM t WHERE username == "2xiaolunwen"); -COMMIT; -SELECT id() IN (SELECT id() FROM t WHERE username == "xiaolunwen"), username == "xiaolunwen", len(string(avatar)) == 1<<20 FROM t; -|"", "", "" -[true true true] - --- 734 // https://github.com/cznic/ql/issues/51 -BEGIN TRANSACTION; - CREATE TABLE IF NOT EXISTS no_id_user (user string, remain int, total int); - CREATE UNIQUE INDEX UQE_no_id_user_user ON no_id_user (user); - DELETE FROM no_id_user WHERE user == "xlw"; - INSERT INTO no_id_user (user, remain, total) VALUES ("xlw", 20, 100); -COMMIT; -SELECT user, remain, total FROM no_id_user WHERE user == "xlw" LIMIT 1; -|"user", "remain", "total" -[xlw 20 100] - --- 735 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES (1), (2), (3), (4), (5), (6); -COMMIT; -SELECT * FROM t WHERE id() < 4; // reverse order -> no index used -|"i" -[3] -[2] -[1] - --- 736 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (1), (2), (3), (4), (5), (6); -COMMIT; -SELECT * FROM t WHERE i < 4 ; // ordered -> index is used -|"i" -[1] -[2] -[3] - --- 737 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (1), (2), (3), (4), (5), (6); -COMMIT; -SELECT * FROM t WHERE i <= 4; // ordered -> index is used -|"i" -[1] -[2] -[3] -[4] - --- 738 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (1), (2), (3), (4), (5), (6); -COMMIT; -SELECT * FROM t WHERE i == 4; -|"i" -[4] - --- 739 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (1), (2), (3), (4), (5), (6); -COMMIT; -SELECT * FROM t WHERE i >= 4; // ordered -> index is used -|"i" -[4] -[5] -[6] - --- 740 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - INSERT INTO t VALUES (1), (2), (3), (4), (5), (6); -COMMIT; -SELECT * FROM t WHERE i > 4; -|"i" -[5] -[6] - --- 741 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i); - CREATE TABLE u (i int); - CREATE INDEX y ON u (i); - INSERT INTO t VALUES (1), (2), (3), (4), (5), (6); - INSERT INTO u VALUES (10), (20), (30), (40), (50), (60); -COMMIT; -SELECT * FROM - (SELECT i FROM t WHERE i < 4) AS t, - (SELECT * FROM u WHERE i < 40) AS u; // ordered -> both indices are used -|"t.i", "u.i" -[1 10] -[1 20] -[1 30] -[2 10] -[2 20] -[2 30] -[3 10] -[3 20] -[3 30] - --- 742 // https://github.com/cznic/ql/pull/65 -BEGIN TRANSACTION; - CREATE TABLE t (t time); - INSERT INTO t VALUES - (NULL), - ; -COMMIT; -SELECT max(t) as T FROM t; -|"T" -[] - --- 743 // https://github.com/cznic/ql/pull/65 -BEGIN TRANSACTION; - CREATE TABLE t (t time); - INSERT INTO t VALUES - (NULL), - (NULL), - ; -COMMIT; -SELECT max(t) as T FROM t; -|"T" -[] - --- 744 // https://github.com/cznic/ql/pull/65 -BEGIN TRANSACTION; - CREATE TABLE t (t time); - INSERT INTO t VALUES - (NULL), - (parseTime("2006-01-02 15:04:05", "2014-08-08 14:05:11")), - ; -COMMIT; -SELECT max(t) as T FROM t; -|"T" -[2014-08-08 14:05:11 +0000 UTC] - --- 745 // https://github.com/cznic/ql/pull/65 -BEGIN TRANSACTION; - CREATE TABLE t (t time); - INSERT INTO t VALUES - (parseTime("2006-01-02 15:04:05", "2014-08-08 14:05:11")), - (NULL), - ; -COMMIT; -SELECT max(t) as T FROM t; -|"T" -[2014-08-08 14:05:11 +0000 UTC] - --- 746 // https://github.com/cznic/ql/pull/65 -BEGIN TRANSACTION; - CREATE TABLE t (t time); - INSERT INTO t VALUES - (parseTime("2006-01-02 15:04:05", "2014-08-08 14:05:11")), - (parseTime("2006-01-02 15:04:05", "2014-08-08 14:05:12")), - ; -COMMIT; -SELECT max(t) as T FROM t; -|"T" -[2014-08-08 14:05:12 +0000 UTC] - --- 747 // https://github.com/cznic/ql/pull/65 -BEGIN TRANSACTION; - CREATE TABLE t (t time); - INSERT INTO t VALUES - (parseTime("2006-01-02 15:04:05", "2014-08-08 14:05:12")), - (parseTime("2006-01-02 15:04:05", "2014-08-08 14:05:11")), - ; -COMMIT; -SELECT max(t) as T FROM t; -|"T" -[2014-08-08 14:05:12 +0000 UTC] - --- 748 // https://github.com/cznic/ql/pull/65 -BEGIN TRANSACTION; - CREATE TABLE t (t time); - INSERT INTO t VALUES - (NULL), - ; -COMMIT; -SELECT min(t) as T FROM t; -|"T" -[] - --- 749 // https://github.com/cznic/ql/pull/65 -BEGIN TRANSACTION; - CREATE TABLE t (t time); - INSERT INTO t VALUES - (NULL), - (NULL), - ; -COMMIT; -SELECT min(t) as T FROM t; -|"T" -[] - --- 750 // https://github.com/cznic/ql/pull/65 -BEGIN TRANSACTION; - CREATE TABLE t (t time); - INSERT INTO t VALUES - (NULL), - (parseTime("2006-01-02 15:04:05", "2014-08-08 14:05:11")), - ; -COMMIT; -SELECT min(t) as T FROM t; -|"T" -[2014-08-08 14:05:11 +0000 UTC] - --- 751 // https://github.com/cznic/ql/pull/65 -BEGIN TRANSACTION; - CREATE TABLE t (t time); - INSERT INTO t VALUES - (parseTime("2006-01-02 15:04:05", "2014-08-08 14:05:11")), - (NULL), - ; -COMMIT; -SELECT min(t) as T FROM t; -|"T" -[2014-08-08 14:05:11 +0000 UTC] - --- 752 // https://github.com/cznic/ql/pull/65 -BEGIN TRANSACTION; - CREATE TABLE t (t time); - INSERT INTO t VALUES - (parseTime("2006-01-02 15:04:05", "2014-08-08 14:05:11")), - (parseTime("2006-01-02 15:04:05", "2014-08-08 14:05:12")), - ; -COMMIT; -SELECT min(t) as T FROM t; -|"T" -[2014-08-08 14:05:11 +0000 UTC] - --- 753 // https://github.com/cznic/ql/pull/65 -BEGIN TRANSACTION; - CREATE TABLE t (t time); - INSERT INTO t VALUES - (parseTime("2006-01-02 15:04:05", "2014-08-08 14:05:12")), - (parseTime("2006-01-02 15:04:05", "2014-08-08 14:05:11")), - ; -COMMIT; -SELECT min(t) as T FROM t; -|"T" -[2014-08-08 14:05:11 +0000 UTC] - --- 754 // https://github.com/cznic/ql/issues/68 -BEGIN TRANSACTION; - CREATE TABLE department (Name string); - INSERT INTO department (Name) VALUES ("small"), ("large"), ("medium"); - SELECT * FROM department; - ALTER TABLE department ADD score float; - SELECT * from department; - UPDATE department SET score=0 WHERE Name=="small"; -COMMIT; -SELECT * FROM department ORDER BY Name; -|"Name", "score" -[large ] -[medium ] -[small 0] - --- 755 -BEGIN TRANSACTION; - CREATE TABLE t (s string); - INSERT INTO t VALUES - ("seafood"), - ("A fool on the hill"), - (NULL), - ("barbaz"), - ("foobar"), - ; -COMMIT; -SELECT id(), s -FROM t -WHERE s LIKE "foo" -ORDER BY id(); -|"", "s" -[1 seafood] -[2 A fool on the hill] -[5 foobar] - --- 756 -BEGIN TRANSACTION; - CREATE TABLE t (s string); - INSERT INTO t VALUES - ("seafood"), - ("A fool on the hill"), - (NULL), - ("barbaz"), - ("foobar"), - ; -COMMIT; -SELECT id(), s -FROM t -WHERE !(s LIKE "foo") -ORDER BY id(); -|"", "s" -[4 barbaz] - --- 757 -BEGIN TRANSACTION; - CREATE TABLE t (s string); - INSERT INTO t VALUES - ("seafood"), - ("A fool on the hill"), - (NULL), - ("barbaz"), - ("foobar"), - ; -COMMIT; -SELECT id(), s -FROM t -WHERE s LIKE "foo" IS NULL -ORDER BY id(); -|"", "s" -[3 ] - --- 758 -BEGIN TRANSACTION; - CREATE TABLE t (s string); - INSERT INTO t VALUES - ("seafood"), - ("A fool on the hill"), - (NULL), - ("barbaz"), - ("foobar"), - ; -COMMIT; -SELECT id(), s -FROM t -WHERE s LIKE "foo" IS NOT NULL -ORDER BY id(); -|"", "s" -[1 seafood] -[2 A fool on the hill] -[4 barbaz] -[5 foobar] - --- 759 -BEGIN TRANSACTION; - CREATE TABLE t (s string); - INSERT INTO t VALUES - ("seafood"), - ("A fool on the hill"), - (NULL), - ("barbaz"), - ("foobar"), - ; -COMMIT; -SELECT id(), s -FROM t -WHERE s LIKE "bar" -ORDER BY id(); -|"", "s" -[4 barbaz] -[5 foobar] - --- 760 -BEGIN TRANSACTION; - CREATE TABLE t (s string); - INSERT INTO t VALUES - ("seafood"), - ("A fool on the hill"), - (NULL), - ("barbaz"), - ("foobar"), - ; -COMMIT; -SELECT id(), s -FROM t -WHERE s LIKE "^bar" -ORDER BY id(); -|"", "s" -[4 barbaz] - --- 761 -BEGIN TRANSACTION; - CREATE TABLE t (s string); - INSERT INTO t VALUES - ("seafood"), - ("A fool on the hill"), - (NULL), - ("barbaz"), - ("foobar"), - ; -COMMIT; -SELECT id(), s -FROM t -WHERE s LIKE "bar$" -ORDER BY id(); -|"", "s" -[5 foobar] - --- 762 -BEGIN TRANSACTION; - CREATE TABLE t (s string); - INSERT INTO t VALUES - ("seafood"), - ("A fool on the hill"), - (NULL), - ("barbaz"), - ("foobar"), - ; -COMMIT; -SELECT id(), s -FROM t -WHERE s LIKE "bar"+"$" -ORDER BY id(); -|"", "s" -[5 foobar] - --- 763 -BEGIN TRANSACTION; - CREATE TABLE t (s string); - INSERT INTO t VALUES - ("seafood"), - ("A fool on the hill"), - (NULL), - ("barbaz"), - ("foobar"), - ; -COMMIT; -SELECT id(), s -FROM t -WHERE s+"qux" LIKE "qux"+"$" -ORDER BY id(); -|"", "s" -[1 seafood] -[2 A fool on the hill] -[4 barbaz] -[5 foobar] - --- 764 -BEGIN TRANSACTION; - CREATE TABLE t (s string); - INSERT INTO t VALUES - ("seafood"), - ("A fool on the hill"), - (NULL), - ("barbaz"), - ("foobar"), - ; -COMMIT; -SELECT id(), s -FROM t -WHERE s+"quxx" LIKE "qux"+"$" -ORDER BY id(); -|"", "s" - --- 765 // https://github.com/cznic/ql/issues/75 -BEGIN TRANSACTION; - CREATE TABLE foo (i int); - INSERT INTO foo VALUES (10), (20); - CREATE TABLE bar (fooID int, s string); - INSERT INTO bar SELECT id(), "ten" FROM foo WHERE i == 10; - INSERT INTO bar SELECT id(), "twenty" FROM foo WHERE i == 20; -COMMIT; -SELECT * -FROM - (SELECT id() AS ID, i FROM foo) AS foo, - bar -WHERE bar.fooID == foo.ID -ORDER BY foo.ID; -|"foo.ID", "foo.i", "bar.fooID", "bar.s" -[1 10 1 ten] -[2 20 2 twenty] - --- 766 // https://github.com/cznic/ql/issues/75 -BEGIN TRANSACTION; - CREATE TABLE foo (i int); - INSERT INTO foo VALUES (10), (20); - CREATE TABLE bar (fooID int, s string); - INSERT INTO bar SELECT id(), "ten" FROM foo WHERE i == 10; - INSERT INTO bar SELECT id(), "twenty" FROM foo WHERE i == 20; -COMMIT; -SELECT * -FROM foo, bar -WHERE bar.fooID == id(foo) -ORDER BY id(foo); -|"foo.i", "bar.fooID", "bar.s" -[10 1 ten] -[20 2 twenty] - --- 767 // https://github.com/cznic/ql/issues/81 -BEGIN TRANSACTION; - CREATE TABLE t (name string, mail string); - INSERT INTO t VALUES - ("a", "foo@example.com"), - ("b", "bar@example.com"), - ("c", "baz@example.com"), - ("d", "foo@example.com"), - ("e", "bar@example.com"), - ("f", "baz@example.com"), - ; -COMMIT; -SELECT * -FROM t -WHERE name == "b" AND mail == "bar@example.com"; -|"name", "mail" -[b bar@example.com] - --- 768 // https://github.com/cznic/ql/issues/81 -BEGIN TRANSACTION; - CREATE TABLE t (name string, mail string); - INSERT INTO t VALUES - ("a", "foo@example.com"), - ("b", "bar@example.com"), - ("c", "baz@example.com"), - ("d", "foo@example.com"), - ("e", "bar@example.com"), - ("f", "baz@example.com"), - ; -COMMIT; -SELECT * -FROM t -WHERE name == "b" and mail == "bar@example.com"; -|"name", "mail" -[b bar@example.com] - --- 769 // https://github.com/cznic/ql/issues/81 -BEGIN TRANSACTION; - CREATE TABLE t (name string, mail string); - INSERT INTO t VALUES - ("a", "foo@example.com"), - ("b", "bar@example.com"), - ("c", "baz@example.com"), - ("d", "foo@example.com"), - ("e", "bar@example.com"), - ("f", "baz@example.com"), - ; -COMMIT; -SELECT * -FROM t -WHERE name == "b" OR mail == "bar@example.com" -ORDER BY name; -|"name", "mail" -[b bar@example.com] -[e bar@example.com] - --- 770 // https://github.com/cznic/ql/issues/81 -BEGIN TRANSACTION; - CREATE TABLE t (name string, mail string); - INSERT INTO t VALUES - ("a", "foo@example.com"), - ("b", "bar@example.com"), - ("c", "baz@example.com"), - ("d", "foo@example.com"), - ("e", "bar@example.com"), - ("f", "baz@example.com"), - ; -COMMIT; -SELECT * -FROM t -WHERE name == "b" or mail == "bar@example.com" -ORDER BY name; -|"name", "mail" -[b bar@example.com] -[e bar@example.com] - --- 771 // https://github.com/cznic/ql/issues/72 -BEGIN TRANSACTION; - CREATE TABLE tableA (i int); - INSERT INTO tableA VALUES - (11), - (12), - (13), - (14), - (15), - (16), - ; - CREATE TABLE tableB (idA int); - INSERT INTO tableB - SELECT id() FROM tableA WHERE i&1 == 0; -COMMIT; -SELECT id(), i FROM tableA WHERE id() IN (SELECT idA FROM tableB) ORDER BY id(); -|"", "i" -[2 12] -[4 14] -[6 16] - --- 772 // https://github.com/cznic/ql/issues/72 -BEGIN TRANSACTION; - CREATE TABLE tableA (i int); - INSERT INTO tableA VALUES - (11), - (12), - (13), - (14), - (15), - (16), - ; - CREATE TABLE tableB (idA int); - INSERT INTO tableB - SELECT id() FROM tableA WHERE i&1 == 0; -COMMIT; -SELECT id(), i FROM tableA WHERE id() NOT IN (SELECT idA FROM tableB) ORDER BY id(); -|"", "i" -[1 11] -[3 13] -[5 15] - --- 773 // https://github.com/cznic/ql/issues/72 -BEGIN TRANSACTION; - CREATE TABLE tableA (i int); - INSERT INTO tableA VALUES - (11), - (12), - (13), - (14), - (15), - (16), - ; - CREATE TABLE tableB (idA int); - INSERT INTO tableB - SELECT id() FROM tableA WHERE i&1 == 0; - DELETE FROM tableA WHERE id() IN (SELECT idA FROM tableB); -COMMIT; -SELECT id(), i FROM tableA ORDER BY id(); -|"", "i" -[1 11] -[3 13] -[5 15] - --- 774 // https://github.com/cznic/ql/issues/72 -BEGIN TRANSACTION; - CREATE TABLE tableA (i int); - INSERT INTO tableA VALUES - (11), - (12), - (13), - (14), - (15), - (16), - ; - CREATE TABLE tableB (idA int); - INSERT INTO tableB - SELECT id() FROM tableA WHERE i&1 == 0; - DELETE FROM tableA WHERE id() NOT IN (SELECT idA FROM tableB); -COMMIT; -SELECT id(), i FROM tableA ORDER BY id(); -|"", "i" -[2 12] -[4 14] -[6 16] - --- 775 // https://github.com/cznic/ql/issues/72, coerce -BEGIN TRANSACTION; - CREATE TABLE tableA (i int); - INSERT INTO tableA VALUES - (11), - (12), - (13), - (14), - (15), - (16), - ; - CREATE TABLE tableB (idA int); - INSERT INTO tableB - SELECT id() FROM tableA WHERE i&1 == 0; - DELETE FROM tableA WHERE 2 IN (SELECT idA FROM tableB); -COMMIT; -SELECT id(), i FROM tableA ORDER BY id(); -|"", "i" - --- 776 // https://github.com/cznic/ql/issues/72, coerce -BEGIN TRANSACTION; - CREATE TABLE tableA (i int); - INSERT INTO tableA VALUES - (11), - (12), - (13), - (14), - (15), - (16), - ; - CREATE TABLE tableB (idA int); - INSERT INTO tableB - SELECT id() FROM tableA WHERE i&1 == 0; - DELETE FROM tableA WHERE 2 NOT IN (SELECT idA FROM tableB); -COMMIT; -SELECT id(), i FROM tableA ORDER BY id(); -|"", "i" -[1 11] -[2 12] -[3 13] -[4 14] -[5 15] -[6 16] - --- 777 // https://github.com/cznic/ql/issues/72, different types have zero set intersetion. -BEGIN TRANSACTION; - CREATE TABLE tableA (i int); - INSERT INTO tableA VALUES - (11), - (12), - (13), - (14), - (15), - (16), - ; - CREATE TABLE tableB (idA int); - INSERT INTO tableB - SELECT id() FROM tableA WHERE i&1 == 0; - DELETE FROM tableA WHERE 3.14 IN (SELECT idA FROM tableB); -COMMIT; -SELECT id(), i FROM tableA ORDER BY id(); -|"", "i" -[1 11] -[2 12] -[3 13] -[4 14] -[5 15] -[6 16] - --- 778 // https://github.com/cznic/ql/issues/72, different have zero set intersection but NOT makes the result true. -BEGIN TRANSACTION; - CREATE TABLE tableA (i int); - INSERT INTO tableA VALUES - (11), - (12), - (13), - (14), - (15), - (16), - ; - CREATE TABLE tableB (idA int); - INSERT INTO tableB - SELECT id() FROM tableA WHERE i&1 == 0; - DELETE FROM tableA WHERE 3.14 NOT IN (SELECT idA FROM tableB); -COMMIT; -SELECT id(), i FROM tableA ORDER BY id(); -|"", "i" - --- 779 // https://github.com/cznic/ql/issues/72, invalid field type -BEGIN TRANSACTION; - CREATE TABLE tableA (i int); - INSERT INTO tableA VALUES - (11), - (12), - (13), - (14), - (15), - (16), - ; - CREATE TABLE tableB (idA time); - INSERT INTO tableB - SELECT now() FROM tableA WHERE i&1 == 0; - DELETE FROM tableA WHERE 3.14 NOT IN (SELECT idA FROM tableB); -COMMIT; -SELECT id(), i FROM tableA ORDER BY id(); -||invalid field type - --- 780 // https://github.com/cznic/ql/issues/72, too many fields -BEGIN TRANSACTION; - CREATE TABLE tableA (i int); - INSERT INTO tableA VALUES - (11), - (12), - (13), - (14), - (15), - (16), - ; - CREATE TABLE tableB (idA int, name string); - INSERT INTO tableB - SELECT id(), "foo" FROM tableA WHERE i&1 == 0; - DELETE FROM tableA WHERE id() NOT IN (SELECT * FROM tableB); -COMMIT; -SELECT id(), i FROM tableA ORDER BY id(); -||mismatched field count - --- 781 // https://github.com/cznic/ql/issues/72, some NULL -BEGIN TRANSACTION; - DROP TABLE IF EXISTS tableA; - DROP TABLE IF EXISTS tableB; -COMMIT; -BEGIN TRANSACTION; - CREATE TABLE tableA (i int); - INSERT INTO tableA VALUES - (11), - (12), - (13), - (14), - (15), - (16), - ; - CREATE TABLE tableB (idA int); - INSERT INTO tableB VALUES(NULL); - INSERT INTO tableB - SELECT id() FROM tableA WHERE i&1 == 0; -COMMIT; -SELECT i FROM tableA WHERE id() IN (SELECT idA from tableB) ORDER BY id(); -|"i" -[12] -[14] -[16] - --- 782 // https://github.com/cznic/ql/issues/72, all NULL -BEGIN TRANSACTION; - DROP TABLE IF EXISTS tableA; - DROP TABLE IF EXISTS tableB; -COMMIT; -BEGIN TRANSACTION; - CREATE TABLE tableA (i int); - INSERT INTO tableA VALUES - (11), - (12), - (13), - (14), - (15), - (16), - ; - CREATE TABLE tableB (idA int); - INSERT INTO tableB VALUES(NULL); -COMMIT; -SELECT i FROM tableA WHERE id() IN (SELECT idA from tableB) ORDER BY id(); -|"i" - --- 783 // https://github.com/cznic/ql/issues/84 -BEGIN TRANSACTION; - CREATE TABLE testA ( - comment string, - data blob, - ); -INSERT INTO testA (comment) VALUES ("c1"); -UPDATE testA SET data = blob("newVal"); -COMMIT; -SELECT * FROM testA; -|"comment", "data" -[c1 [110 101 119 86 97 108]] - --- 784 // https://github.com/cznic/ql/issues/84 -BEGIN TRANSACTION; - CREATE TABLE testA ( - comment string, - data blob, - ); -INSERT INTO testA (comment) VALUES ("c1"); -UPDATE testA SET data = __testBlob(257); -COMMIT; -SELECT * FROM testA; -|"comment", "data" -[c1 [209 231 244 253 191 74 169 85 3 88 111 250 130 24 50 218 91 40 161 60 32 53 58 129 75 81 71 109 70 211 146 67 107 65 150 142 179 2 173 53 73 229 68 154 46 108 47 91 179 98 107 202 157 189 137 4 47 39 93 235 58 112 186 143 68 85 217 33 155 218 180 143 27 76 155 226 205 31 187 12 68 33 75 110 208 42 99 61 223 170 228 184 243 241 64 39 174 64 19 129 203 84 254 78 102 59 16 104 151 21 201 4 117 20 99 125 162 19 201 211 171 71 26 173 37 52 16 115 143 113 128 206 85 192 126 252 146 224 184 146 101 35 198 231 35 236 189 114 184 92 58 124 128 162 106 95 241 186 172 196 31 138 44 178 168 127 69 116 225 27 53 171 157 185 48 205 167 150 77 69 129 86 72 117 129 121 62 224 186 31 116 4 196 103 206 63 185 236 75 172 217 51 223 26 195 127 79 72 199 160 103 92 192 202 67 17 99 200 111 174 71 24 64 119 113 178 105 44 12 25 70 6 69 173 90 100 171 122 155 220 185 99 41 101 190 142 44 217 102 93 63 225 218 239 167 40 254]] - --- 785 // https://github.com/cznic/ql/issues/84 -BEGIN TRANSACTION; - CREATE TABLE testA ( - comment string, - data blob, - ); -INSERT INTO testA (comment) VALUES ("c1"), ("c2"); -UPDATE testA SET data = blob("newVal") WHERE comment == "c1"; -COMMIT; -SELECT * FROM testA ORDER BY comment; -|"comment", "data" -[c1 [110 101 119 86 97 108]] -[c2 ] - --- 786 // https://github.com/cznic/ql/issues/84 -BEGIN TRANSACTION; - CREATE TABLE testA ( - comment string, - data blob, - ); -INSERT INTO testA (comment) VALUES ("c1"), ("c2"); -UPDATE testA SET data = blob("newVal") WHERE comment == "c2"; -COMMIT; -SELECT * FROM testA ORDER BY comment; -|"comment", "data" -[c1 ] -[c2 [110 101 119 86 97 108]] - --- 787 // https://github.com/cznic/ql/issues/84 -BEGIN TRANSACTION; - CREATE TABLE testA ( - comment string, - data blob, - ); -INSERT INTO testA (comment) VALUES ("c1"), ("c2"); -UPDATE testA SET data = blob("newVal"); -COMMIT; -SELECT * FROM testA ORDER BY comment; -|"comment", "data" -[c1 [110 101 119 86 97 108]] -[c2 [110 101 119 86 97 108]] - --- 788 // https://github.com/cznic/ql/issues/84 -BEGIN TRANSACTION; - CREATE TABLE testA ( - comment string, - data blob, - ); -INSERT INTO testA (comment) VALUES ("c1"), ("c2"); -UPDATE testA SET data = __testBlob(257) WHERE comment == "c1"; -COMMIT; -SELECT * FROM testA ORDER BY comment; -|"comment", "data" -[c1 [209 231 244 253 191 74 169 85 3 88 111 250 130 24 50 218 91 40 161 60 32 53 58 129 75 81 71 109 70 211 146 67 107 65 150 142 179 2 173 53 73 229 68 154 46 108 47 91 179 98 107 202 157 189 137 4 47 39 93 235 58 112 186 143 68 85 217 33 155 218 180 143 27 76 155 226 205 31 187 12 68 33 75 110 208 42 99 61 223 170 228 184 243 241 64 39 174 64 19 129 203 84 254 78 102 59 16 104 151 21 201 4 117 20 99 125 162 19 201 211 171 71 26 173 37 52 16 115 143 113 128 206 85 192 126 252 146 224 184 146 101 35 198 231 35 236 189 114 184 92 58 124 128 162 106 95 241 186 172 196 31 138 44 178 168 127 69 116 225 27 53 171 157 185 48 205 167 150 77 69 129 86 72 117 129 121 62 224 186 31 116 4 196 103 206 63 185 236 75 172 217 51 223 26 195 127 79 72 199 160 103 92 192 202 67 17 99 200 111 174 71 24 64 119 113 178 105 44 12 25 70 6 69 173 90 100 171 122 155 220 185 99 41 101 190 142 44 217 102 93 63 225 218 239 167 40 254]] -[c2 ] - --- 789 // https://github.com/cznic/ql/issues/84 -BEGIN TRANSACTION; - CREATE TABLE testA ( - comment string, - data blob, - ); -INSERT INTO testA (comment) VALUES ("c1"), ("c2"); -UPDATE testA SET data = __testBlob(257) WHERE comment == "c2"; -COMMIT; -SELECT * FROM testA ORDER BY comment; -|"comment", "data" -[c1 ] -[c2 [209 231 244 253 191 74 169 85 3 88 111 250 130 24 50 218 91 40 161 60 32 53 58 129 75 81 71 109 70 211 146 67 107 65 150 142 179 2 173 53 73 229 68 154 46 108 47 91 179 98 107 202 157 189 137 4 47 39 93 235 58 112 186 143 68 85 217 33 155 218 180 143 27 76 155 226 205 31 187 12 68 33 75 110 208 42 99 61 223 170 228 184 243 241 64 39 174 64 19 129 203 84 254 78 102 59 16 104 151 21 201 4 117 20 99 125 162 19 201 211 171 71 26 173 37 52 16 115 143 113 128 206 85 192 126 252 146 224 184 146 101 35 198 231 35 236 189 114 184 92 58 124 128 162 106 95 241 186 172 196 31 138 44 178 168 127 69 116 225 27 53 171 157 185 48 205 167 150 77 69 129 86 72 117 129 121 62 224 186 31 116 4 196 103 206 63 185 236 75 172 217 51 223 26 195 127 79 72 199 160 103 92 192 202 67 17 99 200 111 174 71 24 64 119 113 178 105 44 12 25 70 6 69 173 90 100 171 122 155 220 185 99 41 101 190 142 44 217 102 93 63 225 218 239 167 40 254]] - --- 790 // https://github.com/cznic/ql/issues/84 -BEGIN TRANSACTION; - CREATE TABLE testA ( - comment string, - data blob, - ); -INSERT INTO testA (comment) VALUES ("c1"), ("c2"); -UPDATE testA SET data = __testBlob(257); -COMMIT; -SELECT * FROM testA ORDER BY comment; -|"comment", "data" -[c1 [209 231 244 253 191 74 169 85 3 88 111 250 130 24 50 218 91 40 161 60 32 53 58 129 75 81 71 109 70 211 146 67 107 65 150 142 179 2 173 53 73 229 68 154 46 108 47 91 179 98 107 202 157 189 137 4 47 39 93 235 58 112 186 143 68 85 217 33 155 218 180 143 27 76 155 226 205 31 187 12 68 33 75 110 208 42 99 61 223 170 228 184 243 241 64 39 174 64 19 129 203 84 254 78 102 59 16 104 151 21 201 4 117 20 99 125 162 19 201 211 171 71 26 173 37 52 16 115 143 113 128 206 85 192 126 252 146 224 184 146 101 35 198 231 35 236 189 114 184 92 58 124 128 162 106 95 241 186 172 196 31 138 44 178 168 127 69 116 225 27 53 171 157 185 48 205 167 150 77 69 129 86 72 117 129 121 62 224 186 31 116 4 196 103 206 63 185 236 75 172 217 51 223 26 195 127 79 72 199 160 103 92 192 202 67 17 99 200 111 174 71 24 64 119 113 178 105 44 12 25 70 6 69 173 90 100 171 122 155 220 185 99 41 101 190 142 44 217 102 93 63 225 218 239 167 40 254]] -[c2 [209 231 244 253 191 74 169 85 3 88 111 250 130 24 50 218 91 40 161 60 32 53 58 129 75 81 71 109 70 211 146 67 107 65 150 142 179 2 173 53 73 229 68 154 46 108 47 91 179 98 107 202 157 189 137 4 47 39 93 235 58 112 186 143 68 85 217 33 155 218 180 143 27 76 155 226 205 31 187 12 68 33 75 110 208 42 99 61 223 170 228 184 243 241 64 39 174 64 19 129 203 84 254 78 102 59 16 104 151 21 201 4 117 20 99 125 162 19 201 211 171 71 26 173 37 52 16 115 143 113 128 206 85 192 126 252 146 224 184 146 101 35 198 231 35 236 189 114 184 92 58 124 128 162 106 95 241 186 172 196 31 138 44 178 168 127 69 116 225 27 53 171 157 185 48 205 167 150 77 69 129 86 72 117 129 121 62 224 186 31 116 4 196 103 206 63 185 236 75 172 217 51 223 26 195 127 79 72 199 160 103 92 192 202 67 17 99 200 111 174 71 24 64 119 113 178 105 44 12 25 70 6 69 173 90 100 171 122 155 220 185 99 41 101 190 142 44 217 102 93 63 225 218 239 167 40 254]] - --- 791 -BEGIN TRANSACTION; - CREATE TABLE t (c float32); - INSERT INTO t VALUES (43.2); -COMMIT; -SELECT formatFloat(c) FROM t; -|"" -[43.2] - --- 792 -BEGIN TRANSACTION; - CREATE TABLE t (c float64); - INSERT INTO t VALUES (43.2); -COMMIT; -SELECT formatFloat(c) FROM t; -|"" -[43.2] - --- 793 -BEGIN TRANSACTION; - CREATE TABLE t (c float64); - INSERT INTO t VALUES (43.2); -COMMIT; -SELECT formatFloat(c, 'b') FROM t; -|"" -[6079859496950170p-47] - --- 794 -BEGIN TRANSACTION; - CREATE TABLE t (c float64); - INSERT INTO t VALUES (43.2); -COMMIT; -SELECT formatFloat(c, 'e', 5) FROM t; -|"" -[4.32000e+01] - --- 795 -BEGIN TRANSACTION; - CREATE TABLE t (c float64); - INSERT INTO t VALUES (43.2); -COMMIT; -SELECT formatFloat(c, 'b', 7, 32) FROM t; -|"" -[11324621p-18] - --- 796 -BEGIN TRANSACTION; - CREATE TABLE t (c int32); - INSERT INTO t VALUES (-42); -COMMIT; -SELECT formatInt(c) FROM t; -|"" -[-42] - --- 797 -BEGIN TRANSACTION; - CREATE TABLE t (c int64); - INSERT INTO t VALUES (-42); -COMMIT; -SELECT formatInt(c) FROM t; -|"" -[-42] - --- 798 -BEGIN TRANSACTION; - CREATE TABLE t (c int64); - INSERT INTO t VALUES (-42); -COMMIT; -SELECT formatInt(c, 18) FROM t; -|"" -[-26] - --- 799 -BEGIN TRANSACTION; - CREATE TABLE t (c uint32); - INSERT INTO t VALUES (42); -COMMIT; -SELECT formatInt(c) FROM t; -|"" -[42] - --- 800 -BEGIN TRANSACTION; - CREATE TABLE t (c uint64); - INSERT INTO t VALUES (42); -COMMIT; -SELECT formatInt(c) FROM t; -|"" -[42] - --- 801 -BEGIN TRANSACTION; - CREATE TABLE t (c uint64); - INSERT INTO t VALUES (42); -COMMIT; -SELECT formatInt(c, 18) FROM t; -|"" -[26] - --- 802 -BEGIN TRANSACTION; - CREATE TABLE t (c int); - INSERT INTO t VALUES (-42); -COMMIT; -SELECT formatInt(c, 18) FROM t; -|"" -[-26] - --- 803 -BEGIN TRANSACTION; - CREATE TABLE t (c uint); - INSERT INTO t VALUES (42); -COMMIT; -SELECT formatInt(c, 18) FROM t; -|"" -[26] - --- 804 -BEGIN TRANSACTION; - CREATE TABLE t (c int8); - INSERT INTO t VALUES (-42); -COMMIT; -SELECT formatInt(c, 18) FROM t; -|"" -[-26] - --- 805 -BEGIN TRANSACTION; - CREATE TABLE t (c uint8); - INSERT INTO t VALUES (42); -COMMIT; -SELECT formatInt(c, 18) FROM t; -|"" -[26] - --- 806 -BEGIN TRANSACTION; - CREATE TABLE t (c int16); - INSERT INTO t VALUES (-42); -COMMIT; -SELECT formatInt(c, 18) FROM t; -|"" -[-26] - --- 807 -BEGIN TRANSACTION; - CREATE TABLE t (c uint16); - INSERT INTO t VALUES (42); -COMMIT; -SELECT formatInt(c, 18) FROM t; -|"" -[26] - --- 808 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42); - ALTER TABLE t ADD b blob; -COMMIT; -SELECT * FROM t; -|"i", "b" -[42 ] - --- 809 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42); - ALTER TABLE t ADD b blob; - UPDATE t b = blob("a"); -COMMIT; -SELECT * FROM t; -|"i", "b" -[42 [97]] - --- 810 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - DROP TABLE __Column2; -COMMIT; -||system table - --- 811 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE __Column2 (i int); -COMMIT; -||system table - --- 812 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - UPDATE __Column2 SET i = 42; -COMMIT; -||system table - --- 813 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE INDEX __Column2Default ON __Column2(DefaultExpr); -COMMIT; -||system table - --- 814 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (i int); -COMMIT; -SELECT * FROM __Column2; -||does not exist - --- 815 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (i int DEFAULT 42); -COMMIT; -SELECT * FROM __Column2; -|"TableName", "Name", "NotNull", "ConstraintExpr", "DefaultExpr" -[t i false 42] - --- 816 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (i int NOT NULL); -COMMIT; -SELECT * FROM __Column2; -|"TableName", "Name", "NotNull", "ConstraintExpr", "DefaultExpr" -[t i true ] - --- 817 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (i int NOT NULL DEFAULT 43); -COMMIT; -SELECT * FROM __Column2; -|"TableName", "Name", "NotNull", "ConstraintExpr", "DefaultExpr" -[t i true 43] - --- 818 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (i int i > 44); -COMMIT; -SELECT * FROM __Column2; -|"TableName", "Name", "NotNull", "ConstraintExpr", "DefaultExpr" -[t i false i > 44 ] - --- 819 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (i int i > 45 DEFAULT 46); -COMMIT; -SELECT * FROM __Column2; -|"TableName", "Name", "NotNull", "ConstraintExpr", "DefaultExpr" -[t i false i > 45 46] - --- 820 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - ALTER TABLE t ADD s string; -COMMIT; -SELECT * FROM __Column2; -||does not exist - --- 821 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (i int); -COMMIT; -BEGIN TRANSACTION; - ALTER TABLE t ADD s string; -COMMIT; -SELECT * FROM __Column2; -||does not exist - --- 822 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - ALTER TABLE t ADD s string DEFAULT "foo"; -COMMIT; -SELECT * FROM __Column2; -|"TableName", "Name", "NotNull", "ConstraintExpr", "DefaultExpr" -[t s false "foo"] - --- 823 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (i int); -COMMIT; -BEGIN TRANSACTION; - ALTER TABLE t ADD s string DEFAULT "foo"; -COMMIT; -SELECT * FROM __Column2; -|"TableName", "Name", "NotNull", "ConstraintExpr", "DefaultExpr" -[t s false "foo"] - --- 824 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - ALTER TABLE t ADD s string NOT NULL; -COMMIT; -SELECT * FROM __Column2; -|"TableName", "Name", "NotNull", "ConstraintExpr", "DefaultExpr" -[t s true ] - --- 825 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (i int); -COMMIT; -BEGIN TRANSACTION; - ALTER TABLE t ADD s string NOT NULL; -COMMIT; -SELECT * FROM __Column2; -|"TableName", "Name", "NotNull", "ConstraintExpr", "DefaultExpr" -[t s true ] - --- 826 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42); - ALTER TABLE t ADD s string NOT NULL; -COMMIT; -SELECT * FROM __Column2; -||existing data - --- 827 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42); -COMMIT; -BEGIN TRANSACTION; - ALTER TABLE t ADD s string NOT NULL; -COMMIT; -SELECT * FROM __Column2; -||existing data - --- 828 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42); - ALTER TABLE t ADD s string s > ""; -COMMIT; -SELECT * FROM __Column2; -||existing data - --- 829 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES(42); - ALTER TABLE t ADD s string s > ""; -COMMIT; -BEGIN TRANSACTION; - ALTER TABLE t ADD s string s > ""; -COMMIT; -SELECT * FROM __Column2; -||existing data - --- 830 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (i int DEFAULT 42, s string DEFAULT 43); -COMMIT; -SELECT * FROM __Column2 ORDER BY Name; -|"TableName", "Name", "NotNull", "ConstraintExpr", "DefaultExpr" -[t i false 42] -[t s false 43] - --- 831 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (i int DEFAULT 42, s string DEFAULT 43); - ALTER TABLE t DROP COLUMN s; -COMMIT; -SELECT * FROM __Column2 ORDER BY Name; -|"TableName", "Name", "NotNull", "ConstraintExpr", "DefaultExpr" -[t i false 42] - --- 832 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (i int DEFAULT 42, s string DEFAULT 43); -COMMIT; -BEGIN TRANSACTION; - ALTER TABLE t DROP COLUMN s; -COMMIT; -SELECT * FROM __Column2 ORDER BY Name; -|"TableName", "Name", "NotNull", "ConstraintExpr", "DefaultExpr" -[t i false 42] - --- 833 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (i int DEFAULT 42, s string DEFAULT 43); - ALTER TABLE t DROP COLUMN i; -COMMIT; -SELECT * FROM __Column2 ORDER BY Name; -|"TableName", "Name", "NotNull", "ConstraintExpr", "DefaultExpr" -[t s false 43] - --- 834 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (i int DEFAULT 42, s string DEFAULT 43); -COMMIT; -BEGIN TRANSACTION; - ALTER TABLE t DROP COLUMN i; -COMMIT; -SELECT * FROM __Column2 ORDER BY Name; -|"TableName", "Name", "NotNull", "ConstraintExpr", "DefaultExpr" -[t s false 43] - --- 835 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (i int NOT NULL); - INSERT INTO t VALUES(42); -COMMIT; -SELECT * FROM __Column2 ORDER BY Name; -|"TableName", "Name", "NotNull", "ConstraintExpr", "DefaultExpr" -[t i true ] - --- 836 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b int, c int); - INSERT INTO t VALUES(NULL, NULL, NULL); -COMMIT; -SELECT * FROM t; -|"a", "b", "c" -[ ] - --- 837 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b int NOT NULL, c int); - INSERT INTO t VALUES(NULL, 42, NULL); -COMMIT; -SELECT * FROM t; -|"a", "b", "c" -[ 42 ] - --- 838 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b int NOT NULL, c int); - INSERT INTO t VALUES(NULL, NULL, NULL); -COMMIT; -SELECT * FROM t; -||NOT NULL - --- 839 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b int DEFAULT 42, c int); - INSERT INTO t VALUES(NULL, NULL, NULL); -COMMIT; -SELECT * FROM t; -|"a", "b", "c" -[ 42 ] - --- 840 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b int b > 42, c int); - INSERT INTO t VALUES(NULL, NULL, NULL); -COMMIT; -SELECT * FROM t; -||constraint violation - --- 841 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b int b > 42, c int); - INSERT INTO t VALUES(NULL, 42, NULL); -COMMIT; -SELECT * FROM t; -||constraint violation - --- 842 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b int b > 42, c int); - INSERT INTO t VALUES(NULL, 43, NULL); -COMMIT; -SELECT * FROM t; -|"a", "b", "c" -[ 43 ] - --- 843 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b int b > 42 DEFAULT 42, c int); - INSERT INTO t VALUES(NULL, NULL, NULL); -COMMIT; -SELECT * FROM t; -||constraint violation - --- 844 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b int b > 42 DEFAULT 43, c int); - INSERT INTO t VALUES(NULL, NULL, NULL); -COMMIT; -SELECT * FROM t; -|"a", "b", "c" -[ 43 ] - --- 845 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b int b > 42 DEFAULT 43, c int); - INSERT INTO t VALUES(NULL, 42, NULL); -COMMIT; -SELECT * FROM t; -||constraint violation - --- 846 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b int b > 42 DEFAULT 430, c int); - INSERT INTO t VALUES(NULL, 43, NULL); -COMMIT; -SELECT * FROM t; -|"a", "b", "c" -[ 43 ] - --- 847 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b int b > a && b < c, c int); - INSERT INTO t VALUES(1, 2, 3); -COMMIT; -SELECT * FROM t; -|"a", "b", "c" -[1 2 3] - --- 848 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b int b > a && b < c, c int); - INSERT INTO t VALUES(1, 1, 3); -COMMIT; -SELECT * FROM t; -||constraint violation - --- 849 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b int b > a && b < c, c int); - INSERT INTO t VALUES(1, 3, 3); -COMMIT; -SELECT * FROM t; -||constraint violation - --- 850 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b int b > a && b < c DEFAULT (a+c)/2, c int); - INSERT INTO t VALUES(1, NULL, 3); -COMMIT; -SELECT * FROM t; -|"a", "b", "c" -[1 2 3] - --- 851 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b int b > a && b < c DEFAULT (a+c)/2, c int); - INSERT INTO t VALUES(1, 1, 3); -COMMIT; -SELECT * FROM t; -||constraint violation - --- 852 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b int b > a && b < c DEFAULT (a+c)/2, c int); - INSERT INTO t VALUES(1, 3, 3); -COMMIT; -SELECT * FROM t; -||constraint violation - --- 853 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE department ( - DepartmentName string DepartmentName IN ("HQ", "R/D", "Lab", "HR") - DEFAULT "HQ", - ); - INSERT INTO department VALUES ("foo"); -COMMIT; -SELECT * FROM department; -||constraint violation - --- 854 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE department ( - DepartmentName string DepartmentName IN ("HQ", "R/D", "Lab", "HR") - DEFAULT "HQ", - ); - INSERT INTO department VALUES ("HQ"); -COMMIT; -SELECT * FROM department; -|"DepartmentName" -[HQ] - --- 855 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE department ( - DepartmentName string DepartmentName IN ("HQ", "R/D", "Lab", "HR") - DEFAULT "HQ", - ); - INSERT INTO department VALUES (NULL); -COMMIT; -SELECT * FROM department; -|"DepartmentName" -[HQ] - --- 856 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE department ( - DepartmentName string DepartmentName IN ("HQ", "R/D", "Lab", "HR") - DEFAULT "HQ", - ); - INSERT INTO department VALUES ("R&D"); -COMMIT; -SELECT * FROM department; -||constraint violation - --- 857 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE department ( - DepartmentName string DepartmentName IN ("HQ", "R/D", "Lab", "HR") - DEFAULT "HQ", - ); - INSERT INTO department VALUES ("R/D"); -COMMIT; -SELECT * FROM department; -|"DepartmentName" -[R/D] - --- 858 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t ( - TimeStamp time TimeStamp <= now() && since(TimeStamp) < duration("10s") DEFAULT now(), - ); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT TimeStamp IS NOT NULL FROM t; -|"" -[true] - --- 859 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t ( - TimeStamp time TimeStamp <= now() && since(TimeStamp) < duration("10s") DEFAULT now(), - ); - INSERT INTO t VALUES(now()-duration("11s")); -COMMIT; -SELECT TimeStamp IS NOT NULL FROM t; -||constraint violation - --- 860 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t ( - TimeStamp time TimeStamp <= now() && since(TimeStamp) < duration("10s") DEFAULT now(), - ); - INSERT INTO t VALUES(now()+duration("1s")); -COMMIT; -SELECT TimeStamp IS NOT NULL FROM t; -||constraint violation - --- 861 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t ( - TimeStamp time TimeStamp <= now() && since(TimeStamp) < duration("10s") DEFAULT now(), - ); - INSERT INTO t VALUES(now()-duration("1s")); -COMMIT; -SELECT TimeStamp IS NOT NULL FROM t; -|"" -[true] - --- 862 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t ( - TimeStamp time TimeStamp <= now() && since(TimeStamp) < duration("10s") DEFAULT now(), - ); - INSERT INTO t VALUES(now()); -COMMIT; -SELECT TimeStamp IS NOT NULL FROM t; -|"" -[true] - --- 863 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t ( - Event string Event != "" && Event LIKE "[0-9]+:[ \t]+.*", - ); - INSERT INTO t VALUES("123 foo"); -COMMIT; -SELECT Event FROM t; -||constraint violation - --- 864 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t ( - Event string Event != "" && Event LIKE "[0-9]+:[ \t]+.*", - ); - INSERT INTO t VALUES("123: foo"); -COMMIT; -SELECT Event FROM t; -|"Event" -[123: foo] - --- 865 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b int, c int); - CREATE TABLE s (i int); - INSERT INTO s VALUES (1), (2), (NULL), (3), (4); - INSERT INTO t(b) SELECT * FROM s; -COMMIT; -SELECT b FROM t ORDER BY b DESC; -|"b" -[4] -[3] -[2] -[1] -[] - --- 866 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b int NOT NULL, c int); - CREATE TABLE s (i int); - INSERT INTO s VALUES (1), (2), (NULL), (3), (4); - INSERT INTO t(b) SELECT * FROM s WHERE i IS NOT NULL; -COMMIT; -SELECT b FROM t ORDER BY b DESC; -|"b" -[4] -[3] -[2] -[1] - --- 867 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b int NOT NULL, c int); - CREATE TABLE s (i int); - INSERT INTO s VALUES (1), (2), (NULL), (3), (4); - INSERT INTO t(b) SELECT * FROM s; -COMMIT; -SELECT i FROM t ORDER BY b DESC; -||NOT NULL - --- 868 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b int, c int); - INSERT INTO t(b) VALUES (10), (20), (30); - UPDATE t b = NULL WHERE b == 20; -COMMIT; -SELECT b FROM t ORDER BY b DESC; -|"b" -[30] -[10] -[] - --- 869 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b int NOT NULL, c int); - INSERT INTO t(b) VALUES (10), (20), (30); - UPDATE t b = NULL WHERE b == 20; -COMMIT; -SELECT b FROM t ORDER BY b DESC; -||NOT NULL - --- 870 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t (a int, b int NOT NULL DEFAULT 42, c int); - INSERT INTO t(b) VALUES (10), (20), (30); - UPDATE t b = NULL WHERE b == 20; -COMMIT; -SELECT b FROM t ORDER BY b DESC; -|"b" -[42] -[30] -[10] - --- S 871 // https://github.com/cznic/ql/issues/91 -SELECT * -FROM employee -LEFT OUTER JOIN department -ON employee.DepartmentID == department.DepartmentID -ORDER BY employee.LastName; -|"employee.LastName", "employee.DepartmentID", "department.DepartmentID", "department.DepartmentName" -[Heisenberg 33 33 Engineering] -[Jones 33 33 Engineering] -[Rafferty 31 31 Sales] -[Robinson 34 34 Clerical] -[Smith 34 34 Clerical] -[Williams ] - --- S 872 // https://github.com/cznic/ql/issues/91 -SELECT * -FROM employee -LEFT JOIN department -ON employee.DepartmentID == department.DepartmentID -ORDER BY employee.LastName; -|"employee.LastName", "employee.DepartmentID", "department.DepartmentID", "department.DepartmentName" -[Heisenberg 33 33 Engineering] -[Jones 33 33 Engineering] -[Rafferty 31 31 Sales] -[Robinson 34 34 Clerical] -[Smith 34 34 Clerical] -[Williams ] - --- S 873 // https://github.com/cznic/ql/issues/91 -SELECT * -FROM employee -RIGHT OUTER JOIN department -ON employee.DepartmentID == department.DepartmentID -ORDER BY employee.LastName; -|"employee.LastName", "employee.DepartmentID", "department.DepartmentID", "department.DepartmentName" -[ 35 Marketing] -[Heisenberg 33 33 Engineering] -[Jones 33 33 Engineering] -[Rafferty 31 31 Sales] -[Robinson 34 34 Clerical] -[Smith 34 34 Clerical] - --- S 874 // https://github.com/cznic/ql/issues/91 -SELECT * -FROM employee -RIGHT JOIN department -ON employee.DepartmentID == department.DepartmentID -ORDER BY employee.LastName; -|"employee.LastName", "employee.DepartmentID", "department.DepartmentID", "department.DepartmentName" -[ 35 Marketing] -[Heisenberg 33 33 Engineering] -[Jones 33 33 Engineering] -[Rafferty 31 31 Sales] -[Robinson 34 34 Clerical] -[Smith 34 34 Clerical] - --- S 875 // https://github.com/cznic/ql/issues/91 -SELECT * -FROM employee -FULL OUTER JOIN department -ON employee.DepartmentID == none; -||unknown - --- S 876 // https://github.com/cznic/ql/issues/91 -SELECT * -FROM employee -FULL JOIN department -ON employee.DepartmentID == none; -||unknown - --- 877 // https://dev.mysql.com/worklog/task/?id=1604 -BEGIN TRANSACTION; - CREATE TABLE t1 (s1 int); - CREATE TABLE t2 (s1 int); - INSERT INTO t1 VALUES (1); - INSERT INTO t1 VALUES (1); -COMMIT; -SELECT * FROM t1 LEFT JOIN t2 ON t1.s1 == t2.s1; -|"t1.s1", "t2.s1" -[1 ] -[1 ] - --- 878 // https://github.com/cznic/ql/issues/91 -BEGIN TRANSACTION; - CREATE TABLE a (i int, s string); - INSERT INTO a VALUES (1, "a"), (3, "a"), (NULL, "an1"), (NULL, "an2"); - CREATE TABLE b (i int, s string); - INSERT INTO b VALUES (2, "b"), (3, "b"), (NULL, "bn1"), (NULL, "bn2"); -COMMIT; -SELECT * FROM a LEFT JOIN b ON a.i == b.i -ORDER BY a.s, a.i, b.s, b.i; -|"a.i", "a.s", "b.i", "b.s" -[1 a ] -[3 a 3 b] -[ an1 ] -[ an2 ] - --- 879 // https://github.com/cznic/ql/issues/91 -BEGIN TRANSACTION; - CREATE TABLE a (i int, s string); - INSERT INTO a VALUES (1, "a"), (3, "a"), (NULL, "an1"), (NULL, "an2"); - CREATE TABLE b (i int, s string); - INSERT INTO b VALUES (2, "b"), (3, "b"), (NULL, "bn1"), (NULL, "bn2"); -COMMIT; -SELECT * FROM a RIGHT JOIN b ON a.i == b.i -ORDER BY a.s, a.i, b.s, b.i; -|"a.i", "a.s", "b.i", "b.s" -[ 2 b] -[ bn1] -[ bn2] -[3 a 3 b] - --- 880 // https://github.com/cznic/ql/issues/91 -BEGIN TRANSACTION; - CREATE TABLE a (i int, s string); - INSERT INTO a VALUES (1, "a"), (3, "a"), (NULL, "an1"), (NULL, "an2"); - CREATE TABLE b (i int, s string); - INSERT INTO b VALUES (2, "b"), (3, "b"), (NULL, "bn1"), (NULL, "bn2"); -COMMIT; -SELECT * FROM b LEFT JOIN a ON a.i == b.i -ORDER BY a.s, a.i, b.s, b.i; -|"b.i", "b.s", "a.i", "a.s" -[2 b ] -[ bn1 ] -[ bn2 ] -[3 b 3 a] - --- 881 // https://github.com/cznic/ql/issues/91 -BEGIN TRANSACTION; - CREATE TABLE a (i int, s string); - INSERT INTO a VALUES (1, "a"), (3, "a"), (NULL, "an1"), (NULL, "an2"); - CREATE TABLE b (i int, s string); - INSERT INTO b VALUES (2, "b"), (3, "b"), (NULL, "bn1"), (NULL, "bn2"); -COMMIT; -SELECT * FROM b RIGHT JOIN a ON a.i == b.i -ORDER BY a.s, a.i, b.s, b.i; -|"b.i", "b.s", "a.i", "a.s" -[ 1 a] -[3 b 3 a] -[ an1] -[ an2] - --- 882 // https://github.com/cznic/ql/issues/91 -BEGIN TRANSACTION; - CREATE TABLE a (i int, s string); - INSERT INTO a VALUES (1, "a"), (3, "a"); - CREATE TABLE b (i int, s string); - INSERT INTO b VALUES (2, "b"), (3, "b"); -COMMIT; -SELECT * FROM a FULL JOIN b ON a.i == b.i -ORDER BY a.s, a.i, b.s, b.i; -|"a.i", "a.s", "b.i", "b.s" -[ 2 b] -[1 a ] -[3 a 3 b] - --- 883 // https://github.com/cznic/ql/issues/91 -BEGIN TRANSACTION; - CREATE TABLE a (i int, s string); - INSERT INTO a VALUES (1, "a"), (3, "a"); - CREATE TABLE b (i int, s string); - INSERT INTO b VALUES (2, "b"), (3, "b"); -COMMIT; -SELECT * FROM a FULL OUTER JOIN b ON a.i == b.i -ORDER BY a.s, a.i, b.s, b.i; -|"a.i", "a.s", "b.i", "b.s" -[ 2 b] -[1 a ] -[3 a 3 b] - --- S 884 // https://github.com/cznic/ql/issues/91 -SELECT * -FROM employee -FULL JOIN department -ON employee.DepartmentID == department.DepartmentID -ORDER BY employee.LastName; -|"employee.LastName", "employee.DepartmentID", "department.DepartmentID", "department.DepartmentName" -[ 35 Marketing] -[Heisenberg 33 33 Engineering] -[Jones 33 33 Engineering] -[Rafferty 31 31 Sales] -[Robinson 34 34 Clerical] -[Smith 34 34 Clerical] -[Williams ] - --- S 885 // https://github.com/cznic/ql/issues/91 -SELECT * -FROM employee -FULL OUTER JOIN department -ON employee.DepartmentID == department.DepartmentID -ORDER BY employee.LastName; -|"employee.LastName", "employee.DepartmentID", "department.DepartmentID", "department.DepartmentName" -[ 35 Marketing] -[Heisenberg 33 33 Engineering] -[Jones 33 33 Engineering] -[Rafferty 31 31 Sales] -[Robinson 34 34 Clerical] -[Smith 34 34 Clerical] -[Williams ] - --- S 886 // https://github.com/cznic/ql/issues/91 -BEGIN TRANSACTION; - CREATE TABLE t (s string); - INSERT INTO t VALUES ("A"), ("B"); -COMMIT; -SELECT * -FROM t, employee -LEFT JOIN department -ON employee.DepartmentID == department.DepartmentID -ORDER BY t.s, employee.LastName; -|"t.s", "employee.LastName", "employee.DepartmentID", "department.DepartmentID", "department.DepartmentName" -[A Heisenberg 33 33 Engineering] -[A Jones 33 33 Engineering] -[A Rafferty 31 31 Sales] -[A Robinson 34 34 Clerical] -[A Smith 34 34 Clerical] -[A Williams ] -[B Heisenberg 33 33 Engineering] -[B Jones 33 33 Engineering] -[B Rafferty 31 31 Sales] -[B Robinson 34 34 Clerical] -[B Smith 34 34 Clerical] -[B Williams ] - --- S 887 // https://github.com/cznic/ql/issues/91 -BEGIN TRANSACTION; - CREATE TABLE t (s string); - INSERT INTO t VALUES ("A"), ("B"); -COMMIT; -SELECT * -FROM t, employee -RIGHT JOIN department -ON employee.DepartmentID == department.DepartmentID -ORDER BY t.s, employee.LastName; -|"t.s", "employee.LastName", "employee.DepartmentID", "department.DepartmentID", "department.DepartmentName" -[ 35 Marketing] -[A Heisenberg 33 33 Engineering] -[A Jones 33 33 Engineering] -[A Rafferty 31 31 Sales] -[A Robinson 34 34 Clerical] -[A Smith 34 34 Clerical] -[B Heisenberg 33 33 Engineering] -[B Jones 33 33 Engineering] -[B Rafferty 31 31 Sales] -[B Robinson 34 34 Clerical] -[B Smith 34 34 Clerical] - --- S 888 // https://github.com/cznic/ql/issues/91 -BEGIN TRANSACTION; - CREATE TABLE t (s string); - INSERT INTO t VALUES ("A"), ("B"); -COMMIT; -SELECT * -FROM t, employee -FULL JOIN department -ON employee.DepartmentID == department.DepartmentID -ORDER BY t.s, employee.LastName; -|"t.s", "employee.LastName", "employee.DepartmentID", "department.DepartmentID", "department.DepartmentName" -[ 35 Marketing] -[A Heisenberg 33 33 Engineering] -[A Jones 33 33 Engineering] -[A Rafferty 31 31 Sales] -[A Robinson 34 34 Clerical] -[A Smith 34 34 Clerical] -[A Williams ] -[B Heisenberg 33 33 Engineering] -[B Jones 33 33 Engineering] -[B Rafferty 31 31 Sales] -[B Robinson 34 34 Clerical] -[B Smith 34 34 Clerical] -[B Williams ] - --- 889 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t1 (a int, b int, c int); - CREATE TABLE t2 (a int, b int NOT NULL, c int); - CREATE TABLE t3 (a int, b int a < b && b < c, c int); - CREATE TABLE t4 (a int, b int a < b && b < c DEFAULT (a+c)/2, c int); - CREATE TABLE t5 (a int, b int NOT NULL DEFAULT (a+c)/2, c int); - CREATE TABLE t6 (a int, b int DEFAULT (a+c)/2, c int); -COMMIT; -SELECT * FROM __Table WHERE !hasPrefix(Name, "__") ORDER BY Name; -|"Name", "Schema" -[t1 CREATE TABLE t1 (a int64, b int64, c int64);] -[t2 CREATE TABLE t2 (a int64, b int64 NOT NULL, c int64);] -[t3 CREATE TABLE t3 (a int64, b int64 a < b && b < c, c int64);] -[t4 CREATE TABLE t4 (a int64, b int64 a < b && b < c DEFAULT (a + c) / 2, c int64);] -[t5 CREATE TABLE t5 (a int64, b int64 NOT NULL DEFAULT (a + c) / 2, c int64);] -[t6 CREATE TABLE t6 (a int64, b int64 DEFAULT (a + c) / 2, c int64);] - --- 890 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t1 (a int, b int, c int); - CREATE TABLE t2 (a int, b int NOT NULL, c int); - CREATE TABLE t3 (a int, b int a < b && b < c, c int); - CREATE TABLE t4 (a int, b int a < b && b < c DEFAULT (a+c)/2, c int); - CREATE TABLE t5 (a int, b int NOT NULL DEFAULT (a+c)/2, c int); - CREATE TABLE t6 (a int, b int DEFAULT (a+c)/2, c int); -COMMIT; -SELECT * FROM __Column2 ORDER BY TableName, Name; -|"TableName", "Name", "NotNull", "ConstraintExpr", "DefaultExpr" -[t2 b true ] -[t3 b false a < b && b < c ] -[t4 b false a < b && b < c (a + c) / 2] -[t5 b true (a + c) / 2] -[t6 b false (a + c) / 2] - --- 891 // https://github.com/cznic/ql/issues/85 -BEGIN TRANSACTION; - CREATE TABLE t1 (a int, b int, c int); - CREATE TABLE t2 (a int, b int NOT NULL, c int); - CREATE TABLE t3 (a int, b int a < b && b < c, c int); - CREATE TABLE t4 (a int, b int a < b && b < c DEFAULT (a+c)/2, c int); - CREATE TABLE t5 (a int, b int NOT NULL DEFAULT (a+c)/2, c int); - CREATE TABLE t6 (a int, b int DEFAULT (a+c)/2, c int); -COMMIT; -SELECT - __Column.TableName, __Column.Ordinal, __Column.Name, __Column.Type, - __Column2.NotNull, __Column2.ConstraintExpr, __Column2.DefaultExpr, -FROM __Column -LEFT JOIN __Column2 -ON __Column.TableName == __Column2.TableName && __Column.Name == __Column2.Name -WHERE !hasPrefix(__Column.TableName, "__") -ORDER BY __Column.TableName, __Column.Ordinal; -|"__Column.TableName", "__Column.Ordinal", "__Column.Name", "__Column.Type", "__Column2.NotNull", "__Column2.ConstraintExpr", "__Column2.DefaultExpr" -[t1 1 a int64 ] -[t1 2 b int64 ] -[t1 3 c int64 ] -[t2 1 a int64 ] -[t2 2 b int64 true ] -[t2 3 c int64 ] -[t3 1 a int64 ] -[t3 2 b int64 false a < b && b < c ] -[t3 3 c int64 ] -[t4 1 a int64 ] -[t4 2 b int64 false a < b && b < c (a + c) / 2] -[t4 3 c int64 ] -[t5 1 a int64 ] -[t5 2 b int64 true (a + c) / 2] -[t5 3 c int64 ] -[t6 1 a int64 ] -[t6 2 b int64 false (a + c) / 2] -[t6 3 c int64 ] - --- 892 -BEGIN TRANSACTION; - DROP TABLE __Index2; -COMMIT; -||system table - --- 893 -BEGIN TRANSACTION; - CREATE TABLE __Index2 (i int); -COMMIT; -||system table - --- 894 -BEGIN TRANSACTION; - UPDATE __Index2 SET i = 42; -COMMIT; -||system table - --- 895 -BEGIN TRANSACTION; - CREATE INDEX __Index2X ON __Index2(x); -COMMIT; -||system table - --- 896 -BEGIN TRANSACTION; - CREATE TABLE t (i int); -COMMIT; -SELECT * FROM __Index2; -||does not exist - --- 897 -BEGIN TRANSACTION; - DROP TABLE __Index2_Expr; -COMMIT; -||system table - --- 898 -BEGIN TRANSACTION; - CREATE TABLE __Index2_Expr (i int); -COMMIT; -||system table - --- 899 -BEGIN TRANSACTION; - UPDATE __Index2_Expr SET i = 42; -COMMIT; -||system table - --- 900 -BEGIN TRANSACTION; - CREATE INDEX __Index2X ON __Index2_Expr(x); -COMMIT; -||system table - --- 901 -BEGIN TRANSACTION; - CREATE TABLE t (i int); -COMMIT; -SELECT * FROM __Index2_Expr; -||does not exist - --- 902 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); -COMMIT; -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 OR Root == -1 // -1: memory DB -FROM __Index2 -WHERE !hasPrefix(TableName, "__"); -|"TableName", "IndexName", "IsUnique", "IsSimple", "" -[t x false true true] - --- 903 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); -COMMIT; -SELECT Expr -FROM __Index2_Expr -WHERE Index2_ID IN ( - SELECT id() - FROM __Index2 - WHERE IndexName == "x" -); -|"Expr" -[i] - --- 904 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(id()); -COMMIT; -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 OR Root == -1 // -1: memory DB -FROM __Index2 -WHERE !hasPrefix(TableName, "__"); -|"TableName", "IndexName", "IsUnique", "IsSimple", "" -[t x false true true] - --- 905 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(id()); -COMMIT; -SELECT Expr -FROM __Index2_Expr -WHERE Index2_ID IN ( - SELECT id() - FROM __Index2 - WHERE IndexName == "x" -); -|"Expr" -[id()] - --- 906 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE unique INDEX x ON t(i); - CREATE INDEX y ON t(id()); -COMMIT; -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 OR Root == -1 // -1: memory DB -FROM __Index2 -WHERE !hasPrefix(TableName, "__") -ORDER BY IndexName; -|"TableName", "IndexName", "IsUnique", "IsSimple", "" -[t x true true true] -[t y false true true] - --- 907 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - CREATE INDEX y ON t(id()); -COMMIT; -SELECT Expr -FROM __Index2_Expr -WHERE Index2_ID IN ( - SELECT id() - FROM __Index2 - WHERE IndexName == "x" OR IndexName == "y" -) -ORDER BY Expr; -|"Expr" -[i] -[id()] - --- 908 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - CREATE INDEX y ON t(id()); - DROP INDEX x; -COMMIT; -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 OR Root == -1 // -1: memory DB -FROM __Index2 -WHERE !hasPrefix(TableName, "__") -ORDER BY IndexName; -|"TableName", "IndexName", "IsUnique", "IsSimple", "" -[t y false true true] - --- 909 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - CREATE INDEX y ON t(id()); - DROP INDEX y; -COMMIT; -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 OR Root == -1 // -1: memory DB -FROM __Index2 -WHERE !hasPrefix(TableName, "__") -ORDER BY IndexName; -|"TableName", "IndexName", "IsUnique", "IsSimple", "" -[t x false true true] - --- 910 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - CREATE INDEX y ON t(id()); - DROP INDEX x; - DROP INDEX y; -COMMIT; -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 OR Root == -1 // -1: memory DB -FROM __Index2 -WHERE !hasPrefix(TableName, "__") -ORDER BY IndexName; -|"TableName", "IndexName", "IsUnique", "IsSimple", "" - --- 911 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - CREATE INDEX y ON t(id()); - DROP INDEX x; -COMMIT; -SELECT Expr -FROM __Index2_Expr -WHERE Index2_ID IN ( - SELECT id() - FROM __Index2 - WHERE IndexName == "x" OR IndexName == "y" -) -ORDER BY Expr; -|"Expr" -[id()] - --- 912 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - CREATE INDEX y ON t(id()); - DROP INDEX y; -COMMIT; -SELECT Expr -FROM __Index2_Expr -WHERE Index2_ID IN ( - SELECT id() - FROM __Index2 - WHERE IndexName == "x" OR IndexName == "y" -) -ORDER BY Expr; -|"Expr" -[i] - --- 913 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - CREATE INDEX y ON t(id()); - DROP INDEX x; - DROP INDEX y; -COMMIT; -SELECT Expr -FROM __Index2_Expr -WHERE Index2_ID IN ( - SELECT id() - FROM __Index2 - WHERE IndexName == "x" OR IndexName == "y" -) -ORDER BY Expr; -|"Expr" - --- 914 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE TABLE u (j int); - CREATE INDEX x ON t(i); - CREATE INDEX y ON u(j); -COMMIT; -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 OR Root == -1 // -1: memory DB -FROM __Index2 -WHERE !hasPrefix(TableName, "__") -ORDER BY IndexName; -|"TableName", "IndexName", "IsUnique", "IsSimple", "" -[t x false true true] -[u y false true true] - --- 915 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE TABLE u (j int); - CREATE INDEX x ON t(i); - CREATE INDEX y ON u(j); - DROP TABLE t; -COMMIT; -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 OR Root == -1 // -1: memory DB -FROM __Index2 -WHERE !hasPrefix(TableName, "__") -ORDER BY IndexName; -|"TableName", "IndexName", "IsUnique", "IsSimple", "" -[u y false true true] - --- 916 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE TABLE u (j int); - CREATE INDEX x ON t(i); - CREATE INDEX y ON u(j); - DROP TABLE u; -COMMIT; -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 OR Root == -1 // -1: memory DB -FROM __Index2 -WHERE !hasPrefix(TableName, "__") -ORDER BY IndexName; -|"TableName", "IndexName", "IsUnique", "IsSimple", "" -[t x false true true] - --- 917 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE TABLE u (j int); - CREATE INDEX x ON t(i); - CREATE INDEX y ON u(j); - DROP TABLE t; - DROP TABLE u; -COMMIT; -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 OR Root == -1 // -1: memory DB -FROM __Index2 -WHERE !hasPrefix(TableName, "__") -ORDER BY IndexName; -|"TableName", "IndexName", "IsUnique", "IsSimple", "" - --- 918 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE TABLE u (j int); - CREATE INDEX x ON t(i); - CREATE INDEX y ON u(j); - DROP TABLE u; - DROP TABLE t; -COMMIT; -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 OR Root == -1 // -1: memory DB -FROM __Index2 -WHERE !hasPrefix(TableName, "__") -ORDER BY IndexName; -|"TableName", "IndexName", "IsUnique", "IsSimple", "" - --- 919 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE TABLE u (j int); - CREATE INDEX x ON t(i); - CREATE INDEX y ON u(j); -COMMIT; -SELECT Expr -FROM __Index2_Expr -WHERE Index2_ID IN ( - SELECT id() - FROM __Index2 - WHERE IndexName == "x" OR IndexName == "y" -) -ORDER BY Expr; -|"Expr" -[i] -[j] - --- 920 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE TABLE u (j int); - CREATE INDEX x ON t(i); - CREATE INDEX y ON u(j); - DROP TABLE t; -COMMIT; -SELECT Expr -FROM __Index2_Expr -WHERE Index2_ID IN ( - SELECT id() - FROM __Index2 - WHERE IndexName == "x" OR IndexName == "y" -) -ORDER BY Expr; -|"Expr" -[j] - --- 921 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE TABLE u (j int); - CREATE INDEX x ON t(i); - CREATE INDEX y ON u(j); - DROP TABLE u; -COMMIT; -SELECT Expr -FROM __Index2_Expr -WHERE Index2_ID IN ( - SELECT id() - FROM __Index2 - WHERE IndexName == "x" OR IndexName == "y" -) -ORDER BY Expr; -|"Expr" -[i] - --- 922 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE TABLE u (j int); - CREATE INDEX x ON t(i); - CREATE INDEX y ON u(j); - DROP TABLE t; - DROP TABLE u; -COMMIT; -SELECT Expr -FROM __Index2_Expr -WHERE Index2_ID IN ( - SELECT id() - FROM __Index2 - WHERE IndexName == "x" OR IndexName == "y" -) -ORDER BY Expr; -|"Expr" - --- 923 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE TABLE u (j int); - CREATE INDEX x ON t(i); - CREATE INDEX y ON u(j); - DROP TABLE u; - DROP TABLE t; -COMMIT; -SELECT Expr -FROM __Index2_Expr -WHERE Index2_ID IN ( - SELECT id() - FROM __Index2 - WHERE IndexName == "x" OR IndexName == "y" -) -ORDER BY Expr; -|"Expr" - --- 924 -BEGIN TRANSACTION; - CREATE TABLE t (i int, a string); - CREATE TABLE u (j int, b string); - CREATE INDEX x ON t(i); - CREATE INDEX y ON u(j); -COMMIT; -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 OR Root == -1 // -1: memory DB -FROM __Index2 -WHERE !hasPrefix(TableName, "__") -ORDER BY IndexName; -|"TableName", "IndexName", "IsUnique", "IsSimple", "" -[t x false true true] -[u y false true true] - --- 925 -BEGIN TRANSACTION; - CREATE TABLE t (i int, a string); - CREATE TABLE u (j int, b string); - CREATE INDEX x ON t(i); - CREATE INDEX y ON u(j); - ALTER TABLE t DROP COLUMN i; -COMMIT; -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 OR Root == -1 // -1: memory DB -FROM __Index2 -WHERE !hasPrefix(TableName, "__") -ORDER BY IndexName; -|"TableName", "IndexName", "IsUnique", "IsSimple", "" -[u y false true true] - --- 926 -BEGIN TRANSACTION; - CREATE TABLE t (i int, a string); - CREATE TABLE u (j int, b string); - CREATE INDEX x ON t(i); - CREATE INDEX y ON u(j); - ALTER TABLE t DROP COLUMN a; -COMMIT; -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 OR Root == -1 // -1: memory DB -FROM __Index2 -WHERE !hasPrefix(TableName, "__") -ORDER BY IndexName; -|"TableName", "IndexName", "IsUnique", "IsSimple", "" -[t x false true true] -[u y false true true] - --- 927 -BEGIN TRANSACTION; - CREATE TABLE t (i int, a string); - CREATE TABLE u (j int, b string); - CREATE INDEX x ON t(i); - CREATE INDEX y ON u(j); - ALTER TABLE u DROP COLUMN j; -COMMIT; -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 OR Root == -1 // -1: memory DB -FROM __Index2 -WHERE !hasPrefix(TableName, "__") -ORDER BY IndexName; -|"TableName", "IndexName", "IsUnique", "IsSimple", "" -[t x false true true] - --- 928 -BEGIN TRANSACTION; - CREATE TABLE t (i int, a string); - CREATE TABLE u (j int, b string); - CREATE INDEX x ON t(i); - CREATE INDEX y ON u(j); - ALTER TABLE u DROP COLUMN b; -COMMIT; -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 OR Root == -1 // -1: memory DB -FROM __Index2 -WHERE !hasPrefix(TableName, "__") -ORDER BY IndexName; -|"TableName", "IndexName", "IsUnique", "IsSimple", "" -[t x false true true] -[u y false true true] - --- 929 -BEGIN TRANSACTION; - CREATE TABLE t (i int, a string); - CREATE TABLE u (j int, b string); - CREATE INDEX x ON t(i); - CREATE INDEX y ON u(j); - ALTER TABLE t DROP COLUMN i; - ALTER TABLE u DROP COLUMN j; -COMMIT; -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 OR Root == -1 // -1: memory DB -FROM __Index2 -WHERE !hasPrefix(TableName, "__") -ORDER BY IndexName; -|"TableName", "IndexName", "IsUnique", "IsSimple", "" - --- 930 -BEGIN TRANSACTION; - CREATE TABLE t (i int, a string); - CREATE TABLE u (j int, b string); - CREATE INDEX x ON t(i); - CREATE INDEX y ON u(j); - ALTER TABLE u DROP COLUMN j; - ALTER TABLE t DROP COLUMN i; -COMMIT; -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 OR Root == -1 // -1: memory DB -FROM __Index2 -WHERE !hasPrefix(TableName, "__") -ORDER BY IndexName; -|"TableName", "IndexName", "IsUnique", "IsSimple", "" - --- 931 -BEGIN TRANSACTION; - CREATE TABLE t (i int, a string); - CREATE TABLE u (j int, b string); - CREATE INDEX x ON t(i); - CREATE INDEX y ON u(j); -COMMIT; -SELECT Expr -FROM __Index2_Expr -WHERE Index2_ID IN ( - SELECT id() - FROM __Index2 - WHERE IndexName == "x" OR IndexName == "y" -) -ORDER BY Expr; -|"Expr" -[i] -[j] - --- 932 -BEGIN TRANSACTION; - CREATE TABLE t (i int, a string); - CREATE TABLE u (j int, b string); - CREATE INDEX x ON t(i); - CREATE INDEX y ON u(j); - ALTER TABLE t DROP COLUMN i; -COMMIT; -SELECT Expr -FROM __Index2_Expr -WHERE Index2_ID IN ( - SELECT id() - FROM __Index2 - WHERE IndexName == "x" OR IndexName == "y" -) -ORDER BY Expr; -|"Expr" -[j] - --- 933 -BEGIN TRANSACTION; - CREATE TABLE t (i int, a string); - CREATE TABLE u (j int, b string); - CREATE INDEX x ON t(i); - CREATE INDEX y ON u(j); - ALTER TABLE t DROP COLUMN a; -COMMIT; -SELECT Expr -FROM __Index2_Expr -WHERE Index2_ID IN ( - SELECT id() - FROM __Index2 - WHERE IndexName == "x" OR IndexName == "y" -) -ORDER BY Expr; -|"Expr" -[i] -[j] - --- 934 -BEGIN TRANSACTION; - CREATE TABLE t (i int, a string); - CREATE TABLE u (j int, b string); - CREATE INDEX x ON t(i); - CREATE INDEX y ON u(j); - ALTER TABLE u DROP COLUMN j; -COMMIT; -SELECT Expr -FROM __Index2_Expr -WHERE Index2_ID IN ( - SELECT id() - FROM __Index2 - WHERE IndexName == "x" OR IndexName == "y" -) -ORDER BY Expr; -|"Expr" -[i] - --- 935 -BEGIN TRANSACTION; - CREATE TABLE t (i int, a string); - CREATE TABLE u (j int, b string); - CREATE INDEX x ON t(i); - CREATE INDEX y ON u(j); - ALTER TABLE u DROP COLUMN b; -COMMIT; -SELECT Expr -FROM __Index2_Expr -WHERE Index2_ID IN ( - SELECT id() - FROM __Index2 - WHERE IndexName == "x" OR IndexName == "y" -) -ORDER BY Expr; -|"Expr" -[i] -[j] - --- 936 -BEGIN TRANSACTION; - CREATE TABLE t (i int, a string); - CREATE TABLE u (j int, b string); - CREATE INDEX x ON t(i); - CREATE INDEX y ON u(j); - ALTER TABLE t DROP COLUMN i; - ALTER TABLE u DROP COLUMN j; -COMMIT; -SELECT Expr -FROM __Index2_Expr -WHERE Index2_ID IN ( - SELECT id() - FROM __Index2 - WHERE IndexName == "x" OR IndexName == "y" -) -ORDER BY Expr; -|"Expr" - --- 937 -BEGIN TRANSACTION; - CREATE TABLE t (i int, a string); - CREATE TABLE u (j int, b string); - CREATE INDEX x ON t(i); - CREATE INDEX y ON u(j); - ALTER TABLE u DROP COLUMN j; - ALTER TABLE t DROP COLUMN i; -COMMIT; -SELECT Expr -FROM __Index2_Expr -WHERE Index2_ID IN ( - SELECT id() - FROM __Index2 - WHERE IndexName == "x" OR IndexName == "y" -) -ORDER BY Expr; -|"Expr" - --- 938 -BEGIN TRANSACTION; - CREATE TABLE t(a int, b int, c int); - CREATE INDEX x ON t(a + c, c - b); -COMMIT; -SELECT TableName, IndexName, IsUnique, IsSimple, Root > 0 OR Root == -1 // -1: mem DB -FROM __Index2 -WHERE TableName == "t"; -|"TableName", "IndexName", "IsUnique", "IsSimple", "" -[t x false false true] - --- 939 -BEGIN TRANSACTION; - CREATE TABLE t(a int, b int, c int); - CREATE INDEX x ON t(a + c, c - b); -COMMIT; -SELECT Expr FROM __Index2_Expr -WHERE Index2_ID IN ( - SELECT id() - FROM __Index2 - WHERE IndexName == "x" -) -ORDER BY Expr; -|"Expr" -[a + c] -[c - b] - --- 940 -BEGIN TRANSACTION; - CREATE TABLE t(a int, b int, c int); - INSERT INTO t VALUES(1, 2, 3); - CREATE INDEX x ON t(a + c, c - b); -COMMIT; -SELECT * FROM t; -|"a", "b", "c" -[1 2 3] - --- 941 -BEGIN TRANSACTION; - CREATE TABLE t(a int, b int, c int); - INSERT INTO t VALUES(1, 2, 3); - CREATE INDEX x ON t(a + c, c - b); -COMMIT; -SELECT * FROM x; -|"x" -[4 1] - --- 942 -BEGIN TRANSACTION; - CREATE TABLE t(a int, b int, c int); - CREATE INDEX x ON t(a + c, c - b); - INSERT INTO t VALUES(1, 2, 3); -COMMIT; -SELECT * FROM t; -|"a", "b", "c" -[1 2 3] - --- 943 -BEGIN TRANSACTION; - CREATE TABLE t(a int, b int, c int); - CREATE INDEX x ON t(a + c, c - b); - INSERT INTO t VALUES(1, 2, 3); -COMMIT; -SELECT * FROM x; -|"x" -[4 1] - --- 944 -BEGIN TRANSACTION; - CREATE TABLE t(a int, b int, c int); - CREATE INDEX x ON t(a + c, c - b); - DROP INDEX x; -COMMIT; -SELECT * FROM x; -||x does not exist - --- 945 -BEGIN TRANSACTION; - CREATE TABLE t(a int, b int, c int); - CREATE INDEX x ON t(a + c, c - b); - DROP TABLE t; -COMMIT; -SELECT * FROM x; -||x does not exist - --- 946 -BEGIN TRANSACTION; - CREATE TABLE t(a int, b int, c int); - CREATE INDEX x ON t(a + c, c - b); - ALTER TABLE t DROP COLUMN a; -COMMIT; -SELECT * FROM x; -||x does not exist - --- 947 -BEGIN TRANSACTION; - CREATE TABLE t(a int, b int, c int); - CREATE INDEX x ON t(a + c, c - b); - ALTER TABLE t DROP COLUMN b; -COMMIT; -SELECT * FROM x; -||x does not exist - --- 948 -BEGIN TRANSACTION; - CREATE TABLE t(a int, b int, c int); - CREATE INDEX x ON t(a + c, c - b); - ALTER TABLE t DROP COLUMN c; -COMMIT; -SELECT * FROM x; -||x does not exist - --- 949 -BEGIN TRANSACTION; - CREATE TABLE t(a int, b int, c int); - CREATE INDEX x ON t(a, c); - ALTER TABLE t DROP COLUMN a; -COMMIT; -SELECT * FROM x; -||x does not exist - --- 950 -BEGIN TRANSACTION; - CREATE TABLE t(a int, b int, c int); - CREATE INDEX x ON t(a, c); - ALTER TABLE t DROP COLUMN b; -COMMIT; -SELECT * FROM x; -|"x" - --- 951 -BEGIN TRANSACTION; - CREATE TABLE t(a int, b int, c int); - CREATE INDEX x ON t(a, c); - ALTER TABLE t DROP COLUMN a; -COMMIT; -SELECT * FROM x; -||x does not exist - --- 952 -BEGIN TRANSACTION; - CREATE TABLE t(a int, b int, c int); - CREATE INDEX x ON t(a, c); - INSERT INTO t VALUES(1, 2, 3); - ALTER TABLE t DROP COLUMN b; -COMMIT; -SELECT * FROM x; -|"x" -[1 3] - --- 953 -BEGIN TRANSACTION; - CREATE TABLE t(a int, b int, c int); - CREATE INDEX x ON t(a, c); - INSERT INTO t VALUES(10, 20, 30); - ALTER TABLE t DROP COLUMN b; - INSERT INTO t VALUES(1, 3); - ALTER TABLE t ADD b string; - INSERT INTO t VALUES(5, 15, "foo"); -COMMIT; -SELECT * FROM x; -|"x" -[1 3] -[5 15] -[10 30] - --- 954 -BEGIN TRANSACTION; - CREATE TABLE t(a int, b int, c int); - CREATE INDEX x ON t(b, c); - INSERT INTO t VALUES (100, 200, 300), (1, 2, 3), (10, 20, 30); -COMMIT; -SELECT * FROM x; -|"x" -[2 3] -[20 30] -[200 300] - --- 955 -BEGIN TRANSACTION; - CREATE TABLE t(a int, b int, c int); - CREATE INDEX x ON t(b); - INSERT INTO t VALUES (100, 200, 300), (1, 2, 3), (10, 20, 30); - INSERT INTO t VALUES (NULL, 200, 300), (1, NULL, 3), (10, NULL, 30), (NULL, NULL, NULL); -COMMIT; -SELECT * FROM x; -|"x" -[] -[] -[] -[2] -[20] -[200] -[200] - --- 956 -BEGIN TRANSACTION; - CREATE TABLE t(a int, b int, c int); - CREATE INDEX x ON t(b, c); - INSERT INTO t VALUES - (100, 200, 300), (1, 2, 3), (10, 20, 30), - (NULL, 200, 300), (1, NULL, 3), (10, NULL, 30), - (NULL, NULL, NULL); -COMMIT; -SELECT * FROM x; -|"x" -[ ] -[ 3] -[ 30] -[2 3] -[20 30] -[200 300] -[200 300] - --- 957 -BEGIN TRANSACTION; - CREATE TABLE t(a int, b int, c int); - CREATE INDEX x ON t(b, c); - INSERT INTO t VALUES - (100, 200, 300), (1, 2, 3), (10, 20, 30), - (NULL, 200, 300), (1, NULL, 3), (10, NULL, 30), - (NULL, NULL, NULL), (NULL, NULL, NULL); -COMMIT; -SELECT * FROM x; -|"x" -[ ] -[ ] -[ 3] -[ 30] -[2 3] -[20 30] -[200 300] -[200 300] - --- 958 -BEGIN TRANSACTION; - CREATE TABLE t(a int, b int, c int); - CREATE UNIQUE INDEX x ON t(b, c); - INSERT INTO t VALUES - (100, 200, 300), (1, 2, 3), (10, 20, 30), - (NULL, 200, 300), (1, NULL, 3), (10, NULL, 30), - (NULL, NULL, NULL), (NULL, NULL, NULL); -COMMIT; -SELECT * FROM x; -||duplicate .* [200 300] - --- 959 -BEGIN TRANSACTION; - CREATE TABLE t(a int, b int, c int); - CREATE INDEX x ON t(b, c); - INSERT INTO t VALUES - (100, 200, 300), (1, 2, 3), (10, 20, 30), - (NULL, 200, 301), (1, NULL, 3), (10, NULL, 30), - (NULL, NULL, NULL), (NULL, NULL, NULL); -COMMIT; -SELECT * FROM x; -|"x" -[ ] -[ ] -[ 3] -[ 30] -[2 3] -[20 30] -[200 300] -[200 301] - --- 960 -BEGIN TRANSACTION; - CREATE INDEX x ON t (qty()+1); -COMMIT; -||undefined.* qty - --- 961 -BEGIN TRANSACTION; - CREATE INDEX x ON t (qty+1); -COMMIT; -||table.*not exist - --- 962 -BEGIN TRANSACTION; - CREATE TABLE t (c int); - CREATE INDEX x ON t (qty+1); -COMMIT; -||column.*not exist - --- 963 -BEGIN TRANSACTION; - CREATE TABLE t (c int); - CREATE INDEX x ON t (id()+1); -COMMIT; -SELECT * FROM t; -|"c" - --- 964 -BEGIN TRANSACTION; - CREATE TABLE t (c int); - CREATE INDEX x ON t (id()+1); - CREATE INDEX y ON t (id()+1); -COMMIT; -SELECT * FROM t; -|"c" - --- 965 -BEGIN TRANSACTION; - CREATE TABLE t (c int); - CREATE INDEX x ON t (id()+1); - CREATE INDEX x ON t (c+1); -COMMIT; -SELECT * FROM t; -||already - --- 966 -BEGIN TRANSACTION; - CREATE TABLE t (c int); - CREATE INDEX x ON t (c+1); - INSERT INTO t VALUES(42); -COMMIT; -SELECT * FROM x; -|"x" -[43] - --- 967 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i+1000); - INSERT INTO t VALUES(42); - INSERT INTO t VALUES(24); - CREATE INDEX y ON t (i+2000); - INSERT INTO t VALUES(1); - INSERT INTO t VALUES(999); - UPDATE t i = 240 WHERE i == 24; - DELETE FROM t WHERE i == 240; -COMMIT; -SELECT * FROM x; -|"x" -[1001] -[1042] -[1999] - --- 968 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i+1000); - INSERT INTO t VALUES(42); - INSERT INTO t VALUES(24); - CREATE INDEX y ON t (i+2000); - INSERT INTO t VALUES(1); - INSERT INTO t VALUES(999); - UPDATE t i = 240 WHERE i == 24; - DELETE FROM t WHERE i == 240; -COMMIT; -SELECT * FROM y; -|"y" -[2001] -[2042] -[2999] - --- 969 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX i ON t (i+1); -COMMIT; -||collision .*: i - - --- 970 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i+1); -COMMIT; -BEGIN TRANSACTION; - INSERT INTO t VALUES(1000); - BEGIN TRANSACTION; - INSERT INTO t VALUES(2000); - ROLLBACK; - INSERT INTO t VALUES(3000); -COMMIT; -SELECT * FROM x; -|"x" -[1001] -[3001] - --- 971 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i+1); - INSERT INTO t VALUES (42); - TRUNCATE TABLE t; -COMMIT; -SELECT * FROM x; -|"x" - --- 972 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i+1); - INSERT INTO t VALUES (42); - DELETE FROM t; -COMMIT; -SELECT * FROM x; -|"x" - --- 973 -BEGIN TRANSACTION; - CREATE TABLE t (i int, s string); - CREATE INDEX x ON t (i+1); - INSERT INTO t VALUES (42, "foo"); - ALTER TABLE t DROP COLUMN i; - INSERT INTO t VALUES ("bar"); -COMMIT; -SELECT * FROM x; -||x does not exist - --- 974 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t (i+1); - INSERT INTO t VALUES(NULL); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(30); - INSERT INTO t VALUES(20); - INSERT INTO t VALUES(40); - INSERT INTO t VALUES(10); - INSERT INTO t VALUES(50); - INSERT INTO t VALUES(NULL); -COMMIT; -SELECT * FROM x; -|"x" -[] -[] -[11] -[11] -[21] -[21] -[31] -[31] -[41] -[41] -[51] -[51] - --- 975 -BEGIN TRANSACTION; - CREATE TABLE t (i blob); - CREATE INDEX x ON t (blob(string(i))); -COMMIT; -SELECT * FROM x; -|"x" - --- 976 -BEGIN TRANSACTION; - CREATE TABLE t (i blob); - CREATE INDEX x ON t (blob(string(i))); - INSERT INTO t VALUES (blob("foo")); -COMMIT; -SELECT * FROM x; -||blob-like - --- 977 -BEGIN TRANSACTION; - CREATE TABLE t (i bigint); - CREATE INDEX x ON t (i+1); - INSERT INTO t VALUES (42); -COMMIT; -SELECT * FROM x; -||blob-like - --- 978 -BEGIN TRANSACTION; - CREATE TABLE t (i bigrat); - CREATE INDEX x ON t (i+1); - INSERT INTO t VALUES (42); -COMMIT; -SELECT * FROM x; -||blob-like - --- 979 -BEGIN TRANSACTION; - CREATE TABLE t (i time); - CREATE INDEX x ON t (timeIn(i, "local")); - INSERT INTO t VALUES (now()); -COMMIT; -SELECT * FROM x; -||blob-like - --- 980 -BEGIN TRANSACTION; - CREATE TABLE t (i duration); - CREATE INDEX x ON t (since(now())); - INSERT INTO t VALUES (duration("3s")); -COMMIT; -SELECT * FROM x; -||blob-like - --- 981 -BEGIN TRANSACTION; - CREATE TABLE t (i int); -COMMIT; -EXPLAIN SELECT * FROM t; -|"" -[┌Iterate all rows of table "t"] -[└Output field names ["i"]] - --- 982 -BEGIN TRANSACTION; - CREATE TABLE t (i int); -COMMIT; -EXPLAIN EXPLAIN SELECT * FROM t; -|"" -[┌Iterate all rows of table "t"] -[└Output field names ["i"]] - --- 983 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES (314), (0), (NULL), (42), (-1), (278); -COMMIT; -SELECT * FROM t WHERE i != 42; -|"i" -[278] -[-1] -[0] -[314] - --- 984 // order -> index is used -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (314), (0), (NULL), (42), (-1), (278); -COMMIT; -SELECT * FROM t WHERE i != 42; -|"i" -[-1] -[0] -[278] -[314] - --- 985 // order -> index is used -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (314), (0), (NULL), (-1), (278); -COMMIT; -SELECT * FROM t WHERE i != 42; -|"i" -[-1] -[0] -[278] -[314] - --- 986 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES (314), (0), (NULL), (-1), (278); -COMMIT; -SELECT * FROM t WHERE id() > 0; -|"i" -[278] -[-1] -[] -[0] -[314] - --- 987 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(id()); - INSERT INTO t VALUES (314), (0), (NULL), (-1), (278); -COMMIT; -SELECT * FROM t WHERE id() > 0; -|"i" -[278] -[-1] -[] -[0] -[314] - --- 988 -BEGIN TRANSACTION; - CREATE TABLE t (i int, j int); - INSERT INTO t VALUES (314, 100), (0, 200), (NULL, 300), (-1, 400), (278, 500); -COMMIT; -SELECT * FROM t WHERE i IS NULL; -|"i", "j" -[ 300] - --- 989 -BEGIN TRANSACTION; - CREATE TABLE t (i int, j int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (314, 100), (0, 200), (NULL, 300), (-1, 400), (278, 500); -COMMIT; -SELECT * FROM t WHERE i IS NULL; -|"i", "j" -[ 300] - --- 990 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES (314), (0), (NULL), (-1), (278); -COMMIT; -SELECT * FROM t WHERE i IS NOT NULL; -|"i" -[278] -[-1] -[0] -[314] - --- 991 // order -> index is used -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES (314), (0), (NULL), (-1), (278); - CREATE INDEX x ON t(i); -COMMIT; -SELECT * FROM t WHERE i IS NOT NULL; -|"i" -[-1] -[0] -[278] -[314] - --- 992 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(id()); - INSERT INTO t VALUES (314), (0), (NULL), (-1), (278); -COMMIT; -SELECT * FROM t WHERE id() IS NULL; -|"i" - --- 993 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(id()); - INSERT INTO t VALUES (314), (0), (NULL), (-1), (278); -COMMIT; -SELECT * FROM t WHERE id() IS NOT NULL; -|"i" -[278] -[-1] -[] -[0] -[314] - --- 994 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES (314), (0), (NULL), (-1), (278); -COMMIT; -SELECT * FROM t WHERE id() IS NULL; -|"i" - --- 995 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES (314), (0), (NULL), (-1), (278); -COMMIT; -SELECT * FROM t WHERE id() IS NOT NULL; -|"i" -[278] -[-1] -[] -[0] -[314] - --- 996 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES (314), (0), (NULL), (-1), (278); -COMMIT; -SELECT * FROM t WHERE id() == 0; -|"i" - --- 997 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(id()); - INSERT INTO t VALUES (314), (0), (NULL), (-1), (278); -COMMIT; -SELECT * FROM t WHERE id() == 0; -|"i" - --- 998 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES (314), (0), (NULL), (-1), (278); -COMMIT; -SELECT * FROM t WHERE id() < 1; -|"i" - --- 999 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(id()); - INSERT INTO t VALUES (314), (0), (NULL), (-1), (278); -COMMIT; -SELECT * FROM t WHERE id() < 1; -|"i" - --- 1000 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES (314), (0), (NULL), (-1), (278); -COMMIT; -SELECT * FROM t WHERE id() <= 0; -|"i" - --- 1001 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(id()); - INSERT INTO t VALUES (314), (0), (NULL), (-1), (278); -COMMIT; -SELECT * FROM t WHERE id() <= 0; -|"i" - --- 1002 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES (314), (0), (NULL), (-1), (278); -COMMIT; -SELECT * FROM t WHERE id() > 0; -|"i" -[278] -[-1] -[] -[0] -[314] - --- 1003 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(id()); - INSERT INTO t VALUES (314), (0), (NULL), (-1), (278); -COMMIT; -SELECT * FROM t WHERE id() > 0; -|"i" -[278] -[-1] -[] -[0] -[314] - --- 1004 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES (314), (0), (NULL), (-1), (278); -COMMIT; -SELECT * FROM t WHERE id() >= 1; -|"i" -[278] -[-1] -[] -[0] -[314] - --- 1005 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(id()); - INSERT INTO t VALUES (314), (0), (NULL), (-1), (278); -COMMIT; -SELECT * FROM t WHERE id() >= 1; -|"i" -[278] -[-1] -[] -[0] -[314] - --- 1006 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES (314), (0), (NULL), (-1), (278); -COMMIT; -SELECT * FROM t WHERE id() != 0; -|"i" -[278] -[-1] -[] -[0] -[314] - --- 1007 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(id()); - INSERT INTO t VALUES (314), (0), (NULL), (-1), (278); -COMMIT; -SELECT * FROM t WHERE id() != 0; -|"i" -[278] -[-1] -[] -[0] -[314] - --- 1008 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (314), (0), (NULL), (-1), (278); -COMMIT; -SELECT * FROM t WHERE -1 < i && 314 > i OR i > 1000 && i < 2000; //MAYBE use ORed intervals -|"i" -[278] -[0] - --- 1009 -BEGIN TRANSACTION; - CREATE TABLE t (i int, b bool); - CREATE INDEX x ON t (b); - INSERT INTO t VALUES(24, false); - INSERT INTO t VALUES(333, NULL); - INSERT INTO t VALUES(42, true); - INSERT INTO t VALUES(240, false); - INSERT INTO t VALUES(420, true); -COMMIT; -SELECT i FROM t WHERE !b ORDER BY i; -|"i" -[24] -[240] - --- 1010 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i == -2; -|"i" - --- 1011 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i == -1; -|"i" - --- 1012 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i == 0; -|"i" -[0] - --- 1013 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i == 1; -|"i" - --- 1014 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i == 2; -|"i" - --- 1015 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i >= -2; -|"i" -[0] - --- 1016 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i >= -1; -|"i" -[0] - --- 1017 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i >= 0; -|"i" -[0] - --- 1018 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i >= 1; -|"i" - --- 1019 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i >= 2; -|"i" - --- 1020 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i > -2; -|"i" -[0] - --- 1021 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i > -1; -|"i" -[0] - --- 1022 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i > 0; -|"i" - --- 1023 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i > 1; -|"i" - --- 1024 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i > 2; -|"i" - --- 1025 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i <= -2; -|"i" - --- 1026 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i <= -1; -|"i" - --- 1027 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i <= 0; -|"i" -[0] - --- 1028 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i <= 1; -|"i" -[0] - --- 1029 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i <= 2; -|"i" -[0] - --- 1030 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i < -2; -|"i" - --- 1031 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i < -1; -|"i" - --- 1032 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i < 0; -|"i" - --- 1033 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i < 1; -|"i" -[0] - --- 1034 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i < 2; -|"i" -[0] - --- 1035 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i != -2; -|"i" -[0] - --- 1036 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i != -1; -|"i" -[0] - --- 1037 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i != 0; -|"i" - --- 1038 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i != 1; -|"i" -[0] - --- 1039 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i == 0 && i != 2; -|"i" -[0] - --- 1040 -BEGIN TRANSACTION; - CREATE TABLE t (i int, b bool); - CREATE INDEX x ON t(b); - INSERT INTO t VALUES (1, false), (NULL, NULL), (-2, false), (0, true), (2, false), (-1, true); -COMMIT; -SELECT * FROM t WHERE !b && b ORDER BY i; -|"i", "b" - --- 1041 -BEGIN TRANSACTION; - CREATE TABLE t (i int, b bool); - CREATE INDEX x ON t(b); - INSERT INTO t VALUES (1, false), (NULL, NULL), (-2, false), (0, true), (2, false), (-1, true); -COMMIT; -SELECT * FROM t WHERE !b && !b ORDER BY i; -|"i", "b" -[-2 false] -[1 false] -[2 false] - --- 1042 -BEGIN TRANSACTION; - CREATE TABLE t (i int, b bool); - CREATE INDEX x ON t(b); - INSERT INTO t VALUES (1, false), (NULL, NULL), (-2, false), (0, true), (2, false), (-1, true); -COMMIT; -SELECT * FROM t WHERE b && !b ORDER BY i; -|"i", "b" - --- 1043 -BEGIN TRANSACTION; - CREATE TABLE t (i int, b bool); - CREATE INDEX x ON t(b); - INSERT INTO t VALUES (1, false), (NULL, NULL), (-2, false), (0, true), (2, false), (-1, true); -COMMIT; -SELECT * FROM t WHERE b && b ORDER BY i; -|"i", "b" -[-1 true] -[0 true] - --- 1044 -SELECT * FROM nothing; // align 5 -||. - --- 1045 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i == -2; -|"i" - --- 1046 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i == -1; -|"i" - --- 1047 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i == 0; -|"i" -[0] - --- 1048 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i == 1; -|"i" -[1] - --- 1049 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i == 2; -|"i" -[2] - --- 1050 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i >= -2; -|"i" -[0] -[1] -[2] - --- 1051 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i >= -1; -|"i" -[0] -[1] -[2] - --- 1052 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i >= 0; -|"i" -[0] -[1] -[2] - --- 1053 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i >= 1; -|"i" -[1] -[2] - --- 1054 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i >= 2; -|"i" -[2] - --- 1055 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i > -2; -|"i" -[0] -[1] -[2] - --- 1056 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i > -1; -|"i" -[0] -[1] -[2] - --- 1057 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i > 0; -|"i" -[1] -[2] - --- 1058 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i > 1; -|"i" -[2] - --- 1059 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i > 2; -|"i" - --- 1060 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i <= -2; -|"i" - --- 1061 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i <= -1; -|"i" - --- 1062 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i <= 0; -|"i" -[0] - --- 1063 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i <= 1; -|"i" -[0] -[1] - --- 1064 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i <= 2; -|"i" -[0] -[1] -[2] - --- 1065 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i < -2; -|"i" - --- 1066 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i < -1; -|"i" - --- 1067 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i < 0; -|"i" - --- 1068 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i < 1; -|"i" -[0] - --- 1069 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i < 2; -|"i" -[0] -[1] - --- 1070 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i != -2; -|"i" -[0] -[1] -[2] - --- 1071 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i != -1; -|"i" -[0] -[1] -[2] - --- 1072 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i != 0; -|"i" -[1] -[2] - --- 1073 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i != 1; -|"i" -[0] -[2] - --- 1074 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= 0 && i != 2; -|"i" -[0] -[1] - --- 1075 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i == -2; -|"i" - --- 1076 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i == -1; -|"i" - --- 1077 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i == 0; -|"i" - --- 1078 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i == 1; -|"i" -[1] - --- 1079 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i == 2; -|"i" -[2] - --- 1080 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i >= -2; -|"i" -[1] -[2] - --- 1081 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i >= -1; -|"i" -[1] -[2] - --- 1082 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i >= 0; -|"i" -[1] -[2] - --- 1083 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i >= 1; -|"i" -[1] -[2] - --- 1084 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i >= 2; -|"i" -[2] - --- 1085 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i > -2; -|"i" -[1] -[2] - --- 1086 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i > -1; -|"i" -[1] -[2] - --- 1087 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i > 0; -|"i" -[1] -[2] - --- 1088 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i > 1; -|"i" -[2] - --- 1089 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i > 2; -|"i" - --- 1090 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i <= -2; -|"i" - --- 1091 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i <= -1; -|"i" - --- 1092 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i <= 0; -|"i" - --- 1093 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i <= 1; -|"i" -[1] - --- 1094 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i <= 2; -|"i" -[1] -[2] - --- 1095 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i < -2; -|"i" - --- 1096 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i < -1; -|"i" - --- 1097 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i < 0; -|"i" - --- 1098 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i < 1; -|"i" - --- 1099 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i < 2; -|"i" -[1] - --- 1100 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i != -2; -|"i" -[1] -[2] - --- 1101 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i != -1; -|"i" -[1] -[2] - --- 1102 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i != 0; -|"i" -[1] -[2] - --- 1103 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i != 1; -|"i" -[2] - --- 1104 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > 0 && i != 2; -|"i" -[1] - --- 1105 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i == -2; -|"i" -[-2] - --- 1106 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i == -1; -|"i" -[-1] - --- 1107 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i == 0; -|"i" -[0] - --- 1108 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i == 1; -|"i" - --- 1109 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i == 2; -|"i" - --- 1110 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i >= -2; -|"i" -[-2] -[-1] -[0] - --- 1111 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i >= -1; -|"i" -[-1] -[0] - --- 1112 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i >= 0; -|"i" -[0] - --- 1113 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i >= 1; -|"i" - --- 1114 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i >= 2; -|"i" - --- 1115 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i > -2; -|"i" -[-1] -[0] - --- 1116 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i > -1; -|"i" -[0] - --- 1117 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i > 0; -|"i" - --- 1118 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i > 1; -|"i" - --- 1119 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i > 2; -|"i" - --- 1120 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i <= -2; -|"i" -[-2] - --- 1121 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i <= -1; -|"i" -[-2] -[-1] - --- 1122 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i <= 0; -|"i" -[-2] -[-1] -[0] - --- 1123 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i <= 1; -|"i" -[-2] -[-1] -[0] - --- 1124 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i <= 2; -|"i" -[-2] -[-1] -[0] - --- 1125 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i < -2; -|"i" - --- 1126 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i < -1; -|"i" -[-2] - --- 1127 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i < 0; -|"i" -[-2] -[-1] - --- 1128 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i < 1; -|"i" -[-2] -[-1] -[0] - --- 1129 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i < 2; -|"i" -[-2] -[-1] -[0] - --- 1130 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i != -2; -|"i" -[-1] -[0] - --- 1131 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i != -1; -|"i" -[-2] -[0] - --- 1132 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i != 0; -|"i" -[-2] -[-1] - --- 1133 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i != 1; -|"i" -[-2] -[-1] -[0] - --- 1134 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i <= 0 && i != 2; -|"i" -[-2] -[-1] -[0] - --- 1135 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i == -2; -|"i" -[-2] - --- 1136 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i == -1; -|"i" -[-1] - --- 1137 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i == 0; -|"i" - --- 1138 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i == 1; -|"i" - --- 1139 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i == 2; -|"i" - --- 1140 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i >= -2; -|"i" -[-2] -[-1] - --- 1141 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i >= -1; -|"i" -[-1] - --- 1142 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i >= 0; -|"i" - --- 1143 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i >= 1; -|"i" - --- 1144 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i >= 2; -|"i" - --- 1145 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i > -2; -|"i" -[-1] - --- 1146 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i > -1; -|"i" - --- 1147 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i > 0; -|"i" - --- 1148 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i > 1; -|"i" - --- 1149 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i > 2; -|"i" - --- 1150 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i <= -2; -|"i" -[-2] - --- 1151 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i <= -1; -|"i" -[-2] -[-1] - --- 1152 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i <= 0; -|"i" -[-2] -[-1] - --- 1153 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i <= 1; -|"i" -[-2] -[-1] - --- 1154 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i <= 2; -|"i" -[-2] -[-1] - --- 1155 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i < -2; -|"i" - --- 1156 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i < -1; -|"i" -[-2] - --- 1157 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i < 0; -|"i" -[-2] -[-1] - --- 1158 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i < 1; -|"i" -[-2] -[-1] - --- 1159 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i < 2; -|"i" -[-2] -[-1] - --- 1160 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i != -2; -|"i" -[-1] --- 1161 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i != -1; -|"i" -[-2] - --- 1162 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i != 0; -|"i" -[-2] -[-1] - --- 1163 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i != 1; -|"i" -[-2] -[-1] - --- 1164 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i < 0 && i != 2; -|"i" -[-2] -[-1] - --- 1165 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i == -2; -|"i" - --- 1166 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i == -1; -|"i" -[-1] - --- 1167 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i == 0; -|"i" -[0] - --- 1168 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i == 1; -|"i" -[1] - --- 1169 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i == 2; -|"i" - --- 1170 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i >= -2; -|"i" -[-1] -[0] -[1] - --- 1171 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i >= -1; -|"i" -[-1] -[0] -[1] - --- 1172 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i >= 0; -|"i" -[0] -[1] - --- 1173 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i >= 1; -|"i" -[1] - --- 1174 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i >= 2; -|"i" - --- 1175 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i > -2; -|"i" -[-1] -[0] -[1] - --- 1176 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i > -1; -|"i" -[0] -[1] - --- 1177 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i > 0; -|"i" -[1] - --- 1178 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i > 1; -|"i" - --- 1179 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i > 2; -|"i" - --- 1180 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i <= -2; -|"i" - --- 1181 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i <= -1; -|"i" -[-1] - --- 1182 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i <= 0; -|"i" -[-1] -[0] - --- 1183 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i <= 1; -|"i" -[-1] -[0] -[1] - --- 1184 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i <= 2; -|"i" -[-1] -[0] -[1] - --- 1185 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i < -2; -|"i" - --- 1186 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i < -1; -|"i" - --- 1187 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i < 0; -|"i" -[-1] - --- 1188 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i < 1; -|"i" -[-1] -[0] - --- 1189 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i < 2; -|"i" -[-1] -[0] -[1] - --- 1190 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i != -2; -|"i" -[-1] -[0] -[1] - --- 1191 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i != -1; -|"i" -[0] -[1] - --- 1192 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i != 0; -|"i" -[-1] -[1] - --- 1193 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i != 1; -|"i" -[-1] -[0] - --- 1194 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i <= 1 && i != 2; -|"i" -[-1] -[0] -[1] - --- 1195 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i == -2; -|"i" - --- 1196 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i == -1; -|"i" - --- 1197 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i == 0; -|"i" -[0] - --- 1198 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i == 1; -|"i" -[1] - --- 1199 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i == 2; -|"i" - --- 1200 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i >= -2; -|"i" -[0] -[1] - --- 1201 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i >= -1; -|"i" -[0] -[1] - --- 1202 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i >= 0; -|"i" -[0] -[1] - --- 1203 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i >= 1; -|"i" -[1] - --- 1204 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i >= 2; -|"i" - --- 1205 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i > -2; -|"i" -[0] -[1] - --- 1206 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i > -1; -|"i" -[0] -[1] - --- 1207 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i > 0; -|"i" -[1] - --- 1208 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i > 1; -|"i" - --- 1209 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i > 2; -|"i" - --- 1210 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i <= -2; -|"i" - --- 1211 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i <= -1; -|"i" - --- 1212 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i <= 0; -|"i" -[0] - --- 1213 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i <= 1; -|"i" -[0] -[1] - --- 1214 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i <= 2; -|"i" -[0] -[1] - --- 1215 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i < -2; -|"i" - --- 1216 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i < -1; -|"i" - --- 1217 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i < 0; -|"i" - --- 1218 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i < 1; -|"i" -[0] - --- 1219 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i < 2; -|"i" -[0] -[1] - --- 1220 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i != -2; -|"i" -[0] -[1] - --- 1221 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i != -1; -|"i" -[0] -[1] - --- 1222 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i != 0; -|"i" -[1] - --- 1223 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i != 1; -|"i" -[0] - --- 1224 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i <= 1 && i != 2; -|"i" -[0] -[1] - --- 1225 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i == -2; -|"i" - --- 1226 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i == -1; -|"i" - --- 1227 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i == 0; -|"i" -[0] - --- 1228 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i == 1; -|"i" - --- 1229 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i == 2; -|"i" - --- 1230 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i >= -2; -|"i" -[0] - --- 1231 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i >= -1; -|"i" -[0] - --- 1232 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i >= 0; -|"i" -[0] - --- 1233 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i >= 1; -|"i" - --- 1234 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i >= 2; -|"i" - --- 1235 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i > -2; -|"i" -[0] - --- 1236 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i > -1; -|"i" -[0] - --- 1237 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i > 0; -|"i" - --- 1238 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i > 1; -|"i" - --- 1239 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i > 2; -|"i" - --- 1240 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i <= -2; -|"i" - --- 1241 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i <= -1; -|"i" - --- 1242 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i <= 0; -|"i" -[0] - --- 1243 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i <= 1; -|"i" -[0] - --- 1244 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i <= 2; -|"i" -[0] - --- 1245 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i < -2; -|"i" - --- 1246 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i < -1; -|"i" - --- 1247 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i < 0; -|"i" - --- 1248 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i < 1; -|"i" -[0] - --- 1249 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i < 2; -|"i" -[0] - --- 1250 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i != -2; -|"i" -[0] - --- 1251 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i != -1; -|"i" -[0] - --- 1252 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i != 0; -|"i" - --- 1253 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i != 1; -|"i" -[0] - --- 1254 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i > -1 && i < 1 && i != 2; -|"i" -[0] - --- 1255 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i == -2; -|"i" - --- 1256 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i == -1; -|"i" -[-1] - --- 1257 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i == 0; -|"i" -[0] - --- 1258 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i == 1; -|"i" - --- 1259 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i == 2; -|"i" - --- 1260 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i == -2; -|"i" - --- 1261 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i == -1; -|"i" -[-1] - --- 1262 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i == 0; -|"i" -[0] - --- 1263 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i == 1; -|"i" - --- 1264 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i == 2; -|"i" - --- 1265 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i >= -2; -|"i" -[-1] -[0] - --- 1266 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i >= -1; -|"i" -[-1] -[0] - --- 1267 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i >= 0; -|"i" -[0] - --- 1268 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i >= 1; -|"i" - --- 1269 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i >= 2; -|"i" - --- 1270 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i > -2; -|"i" -[-1] -[0] - --- 1271 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i > -1; -|"i" -[0] - --- 1272 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i > 0; -|"i" - --- 1273 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i > 1; -|"i" - --- 1274 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i > 2; -|"i" - --- 1275 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i <= -2; -|"i" - --- 1276 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i <= -1; -|"i" -[-1] - --- 1277 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i <= 0; -|"i" -[-1] -[0] - - --- 1278 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i <= 1; -|"i" -[-1] -[0] - --- 1279 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i <= 2; -|"i" -[-1] -[0] - --- 1280 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i < -2; -|"i" - --- 1281 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i < -1; -|"i" - --- 1282 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i < 0; -|"i" -[-1] - - --- 1283 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i < 1; -|"i" -[-1] -[0] - --- 1284 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i < 2; -|"i" -[-1] -[0] - --- 1285 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i != -2; -|"i" -[-1] -[0] - --- 1286 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i != -1; -|"i" -[0] - --- 1287 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i != 0; -|"i" -[-1] - - --- 1288 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i != 1; -|"i" -[-1] -[0] - --- 1289 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i >= -1 && i < 1 && i != 2; -|"i" -[-1] -[0] - --- 1290 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i == -2; -|"i" -[-2] - --- 1291 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i == -1; -|"i" -[-1] - --- 1292 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i == 0; -|"i" - - --- 1293 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i == 1; -|"i" -[1] - --- 1294 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i == 2; -|"i" -[2] - --- 1295 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i >= -2; -|"i" -[-2] -[-1] -[1] -[2] - --- 1296 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i >= -1; -|"i" -[-1] -[1] -[2] - --- 1297 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i >= 0; -|"i" -[1] -[2] - - --- 1298 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i >= 1; -|"i" -[1] -[2] - --- 1299 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i >= 2; -|"i" -[2] - --- 1300 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i > -2; -|"i" -[-1] -[1] -[2] - --- 1301 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i > -1; -|"i" -[1] -[2] - --- 1302 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i > 0; -|"i" -[1] -[2] - - --- 1303 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i > 1; -|"i" -[2] - --- 1304 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i > 2; -|"i" - --- 1305 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i <= -2; -|"i" -[-2] - --- 1306 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i <= -1; -|"i" -[-2] -[-1] - --- 1307 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i <= 0; -|"i" -[-2] -[-1] - - --- 1308 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i <= 1; -|"i" -[-2] -[-1] -[1] - --- 1309 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i <= 2; -|"i" -[-2] -[-1] -[1] -[2] - --- 1310 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i < -2; -|"i" - --- 1311 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i < -1; -|"i" -[-2] - --- 1312 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i < 0; -|"i" -[-2] -[-1] - - --- 1313 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i < 1; -|"i" -[-2] -[-1] - --- 1314 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i < 2; -|"i" -[-2] -[-1] -[1] - --- 1315 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i != -2; -|"i" -[-1] -[1] -[2] - --- 1316 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i != -1; -|"i" -[-2] -[1] -[2] - --- 1317 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i != 0; -|"i" -[-2] -[-1] -[1] -[2] - - --- 1318 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i != 1; -|"i" -[-2] -[-1] -[2] - --- 1319 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX x ON t(i); - INSERT INTO t VALUES (1), (NULL), (-2), (0), (2), (-1); -COMMIT; -SELECT i FROM t WHERE i != 0 && i != 2; -|"i" -[-2] -[-1] -[1] - --- 1320 -BEGIN TRANSACTION; - CREATE TABLE t (i int, j int, k int); - INSERT INTO t VALUES - (1, 2, 3), - (4, 5, -6), - (7, -8, 9), - (10, -11, -12), - (-13, 14, 15), - (-16, 17, -18), - (-19, -20, 21), - (-22, -23, -24); -COMMIT; -SELECT * FROM t WHERE i > 0 && j > 0 ORDER BY i, j; -|"i", "j", "k" -[1 2 3] -[4 5 -6] - --- 1321 -BEGIN TRANSACTION; - CREATE TABLE t (i int, j int, k int); - CREATE INDEX xi ON t(i); - INSERT INTO t VALUES - (1, 2, 3), - (4, 5, -6), - (7, -8, 9), - (10, -11, -12), - (-13, 14, 15), - (-16, 17, -18), - (-19, -20, 21), - (-22, -23, -24); -COMMIT; -SELECT * FROM t WHERE i > 0 && j > 0 ORDER BY i, j; -|"i", "j", "k" -[1 2 3] -[4 5 -6] - --- 1322 -BEGIN TRANSACTION; - CREATE TABLE t (i int, j int, k int); - CREATE INDEX xj ON t(j); - INSERT INTO t VALUES - (1, 2, 3), - (4, 5, -6), - (7, -8, 9), - (10, -11, -12), - (-13, 14, 15), - (-16, 17, -18), - (-19, -20, 21), - (-22, -23, -24); -COMMIT; -SELECT * FROM t WHERE i > 0 && j > 0 ORDER BY i, j; -|"i", "j", "k" -[1 2 3] -[4 5 -6] - --- 1323 -BEGIN TRANSACTION; - CREATE TABLE t (i int, j int, k int); - CREATE INDEX xi ON t(i); - CREATE INDEX xj ON t(j); - INSERT INTO t VALUES - (1, 2, 3), - (4, 5, -6), - (7, -8, 9), - (10, -11, -12), - (-13, 14, 15), - (-16, 17, -18), - (-19, -20, 21), - (-22, -23, -24); -COMMIT; -SELECT * FROM t WHERE i > 0 && j > 0 ORDER BY i, j; -|"i", "j", "k" -[1 2 3] -[4 5 -6] - --- 1324 -BEGIN TRANSACTION; - CREATE TABLE t (i int, j int, k int); - CREATE INDEX xi ON t(i); - CREATE INDEX xj ON t(j); - INSERT INTO t VALUES - (1, 2, 3), - (4, 5, -6), - (7, -8, 9), - (10, -11, -12), - (-13, 14, 15), - (-16, 17, -18), - (-19, -20, 21), - (-22, -23, -24); -COMMIT; -SELECT * FROM t WHERE j > 0 && i > 0 ORDER BY i, j; -|"i", "j", "k" -[1 2 3] -[4 5 -6] - --- 1325 -BEGIN TRANSACTION; - CREATE TABLE t (i int, j int, k int); - INSERT INTO t VALUES - (1, 2, 3), - (4, 5, -6), - (7, -8, 9), - (10, -11, -12), - (-13, 14, 15), - (-16, 17, -18), - (-19, -20, 21), - (-22, -23, -24); -COMMIT; -SELECT * FROM t WHERE i > 0 && j > 0 && k > 0; -|"i", "j", "k" -[1 2 3] - --- 1326 -BEGIN TRANSACTION; - CREATE TABLE t (i int, j int, k int); - CREATE INDEX xi ON t(i); - INSERT INTO t VALUES - (1, 2, 3), - (4, 5, -6), - (7, -8, 9), - (10, -11, -12), - (-13, 14, 15), - (-16, 17, -18), - (-19, -20, 21), - (-22, -23, -24); -COMMIT; -SELECT * FROM t WHERE i > 0 && j > 0 && k > 0; -|"i", "j", "k" -[1 2 3] - --- 1327 -BEGIN TRANSACTION; - CREATE TABLE t (i int, j int, k int); - CREATE INDEX xj ON t(j); - INSERT INTO t VALUES - (1, 2, 3), - (4, 5, -6), - (7, -8, 9), - (10, -11, -12), - (-13, 14, 15), - (-16, 17, -18), - (-19, -20, 21), - (-22, -23, -24); -COMMIT; -SELECT * FROM t WHERE i > 0 && j > 0 && k > 0; -|"i", "j", "k" -[1 2 3] - --- 1328 -BEGIN TRANSACTION; - CREATE TABLE t (i int, j int, k int); - CREATE INDEX xk ON t(k); - INSERT INTO t VALUES - (1, 2, 3), - (4, 5, -6), - (7, -8, 9), - (10, -11, -12), - (-13, 14, 15), - (-16, 17, -18), - (-19, -20, 21), - (-22, -23, -24); -COMMIT; -SELECT * FROM t WHERE i > 0 && j > 0 && k > 0; -|"i", "j", "k" -[1 2 3] - --- 1329 -BEGIN TRANSACTION; - CREATE TABLE t (i int, j int, k int, l int); - INSERT INTO t VALUES - (1, 2, 3, 25), - (4, 5, -6, -26), - (7, -8, 9, 27), - (10, -11, -12, -28), - (-13, 14, 15, 29), - (-16, 17, -18, -30), - (-19, -20, 21, 31), - (-22, -23, -24, -32); -COMMIT; -SELECT * FROM t WHERE i > 0 && j > 0 && k > 0 && l > 0; -|"i", "j", "k", "l" -[1 2 3 25] - --- 1330 -BEGIN TRANSACTION; - CREATE TABLE t (i int, j int, k int, l int); - CREATE INDEX xi ON t(i); - INSERT INTO t VALUES - (1, 2, 3, 25), - (4, 5, -6, -26), - (7, -8, 9, 27), - (10, -11, -12, -28), - (-13, 14, 15, 29), - (-16, 17, -18, -30), - (-19, -20, 21, 31), - (-22, -23, -24, -32); -COMMIT; -SELECT * FROM t WHERE i > 0 && j > 0 && k > 0 && l > 0; -|"i", "j", "k", "l" -[1 2 3 25] - --- 1331 -BEGIN TRANSACTION; - CREATE TABLE t (i int, j int, k int, l int); - CREATE INDEX xj ON t(j); - INSERT INTO t VALUES - (1, 2, 3, 25), - (4, 5, -6, -26), - (7, -8, 9, 27), - (10, -11, -12, -28), - (-13, 14, 15, 29), - (-16, 17, -18, -30), - (-19, -20, 21, 31), - (-22, -23, -24, -32); -COMMIT; -SELECT * FROM t WHERE i > 0 && j > 0 && k > 0 && l > 0; -|"i", "j", "k", "l" -[1 2 3 25] - --- 1332 -BEGIN TRANSACTION; - CREATE TABLE t (i int, j int, k int, l int); - CREATE INDEX xk ON t(k); - INSERT INTO t VALUES - (1, 2, 3, 25), - (4, 5, -6, -26), - (7, -8, 9, 27), - (10, -11, -12, -28), - (-13, 14, 15, 29), - (-16, 17, -18, -30), - (-19, -20, 21, 31), - (-22, -23, -24, -32); -COMMIT; -SELECT * FROM t WHERE i > 0 && j > 0 && k > 0 && l > 0; -|"i", "j", "k", "l" -[1 2 3 25] - --- 1333 -BEGIN TRANSACTION; - CREATE TABLE t (i int, j int, k int, l int); - CREATE INDEX xl ON t(l); - INSERT INTO t VALUES - (1, 2, 3, 25), - (4, 5, -6, -26), - (7, -8, 9, 27), - (10, -11, -12, -28), - (-13, 14, 15, 29), - (-16, 17, -18, -30), - (-19, -20, 21, 31), - (-22, -23, -24, -32); -COMMIT; -SELECT * FROM t WHERE i > 0 && j > 0 && k > 0 && l > 0; -|"i", "j", "k", "l" -[1 2 3 25] - --- 1334 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES (13), (15), (11), (16), (12), (14); -COMMIT; -SELECT * FROM t WHERE i > 12 && i BETWEEN 10 AND 20 AND i < 15 ORDER BY i; -|"i" -[13] -[14] - --- 1335 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - CREATE INDEX xt_i ON t(i); - INSERT INTO t VALUES (13), (15), (11), (16), (12), (14); -COMMIT; -SELECT * FROM t WHERE i > 12 && i BETWEEN 10 AND 20 AND i < 42; -|"i" -[13] -[14] -[15] -[16] - --- 1336 // https://github.com/cznic/ql/issues/102 -BEGIN TRANSACTION; - CREATE TABLE t (i byte); - INSERT INTO t VALUES (NULL); -COMMIT; -SELECT * FROM t; -|"i" -[] - --- 1337 // https://github.com/cznic/ql/issues/103 -BEGIN TRANSACTION; - CREATE TABLE t (t time); - INSERT INTO t VALUES (date(2015, 6, 11, 11, 7, 50, 0, "UTC")); - CREATE INDEX x ON t(t); -COMMIT; -SELECT * FROM t; -|"t" -[2015-06-11 11:07:50 +0000 UTC] - --- 1338 -BEGIN TRANSACTION; - CREATE TABLE t (t time); -COMMIT; -SELECT len(*) FROM t; -||invalid expression - --- 1339 -BEGIN TRANSACTION; - CREATE TABLE t (t time); -COMMIT; -SELECT t.count(*) FROM t; -||invalid expression - --- 1339 -BEGIN TRANSACTION; - CREATE TABLE t (t time); -COMMIT; -SELECT count(*) FROM t; -|"" -[0] - --- 1340 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES (1), (NULL), (3); -COMMIT; -SELECT count(*) FROM t; -|"" -[3] - --- 1341 -BEGIN TRANSACTION; - CREATE TABLE t (i int); - INSERT INTO t VALUES (1), (NULL), (3); -COMMIT; -SELECT count() FROM t; -|"" -[3] diff --git a/Godeps/_workspace/src/github.com/cznic/sortutil/AUTHORS b/Godeps/_workspace/src/github.com/cznic/sortutil/AUTHORS deleted file mode 100644 index 0078f5f5b6..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/sortutil/AUTHORS +++ /dev/null @@ -1,11 +0,0 @@ -# This file lists authors for copyright purposes. This file is distinct from -# the CONTRIBUTORS files. See the latter for an explanation. -# -# Names should be added to this file as: -# Name or Organization -# -# The email address is not required for organizations. -# -# Please keep the list sorted. - -Jan Mercl <0xjnml@gmail.com> diff --git a/Godeps/_workspace/src/github.com/cznic/sortutil/CONTRIBUTORS b/Godeps/_workspace/src/github.com/cznic/sortutil/CONTRIBUTORS deleted file mode 100644 index 9c9a5dd84c..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/sortutil/CONTRIBUTORS +++ /dev/null @@ -1,10 +0,0 @@ -# This file lists people who contributed code to this repository. The AUTHORS -# file lists the copyright holders; this file lists people. -# -# Names should be added to this file like so: -# Name -# -# Please keep the list sorted. - -Gary Burd -Jan Mercl <0xjnml@gmail.com> diff --git a/Godeps/_workspace/src/github.com/cznic/sortutil/LICENSE b/Godeps/_workspace/src/github.com/cznic/sortutil/LICENSE deleted file mode 100644 index 67983e0e61..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/sortutil/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2014 The sortutil 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 names of the authors nor the names of the -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. diff --git a/Godeps/_workspace/src/github.com/cznic/sortutil/Makefile b/Godeps/_workspace/src/github.com/cznic/sortutil/Makefile deleted file mode 100644 index b77748de93..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/sortutil/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2014 The sortutil Authors. All rights reserved. -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file. - -.PHONY: all clean editor later nuke todo - -grep=--include=*.go - -all: editor - go vet - golint . - make todo - -clean: - go clean - rm -f *~ - -editor: - go fmt - go test -i - go test - go build - -later: - @grep -n $(grep) LATER * || true - @grep -n $(grep) MAYBE * || true - -nuke: clean - go clean -i - -todo: - @grep -nr $(grep) ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* * || true - @grep -nr $(grep) TODO * || true - @grep -nr $(grep) BUG * || true - @grep -nr $(grep) println * || true diff --git a/Godeps/_workspace/src/github.com/cznic/sortutil/README b/Godeps/_workspace/src/github.com/cznic/sortutil/README deleted file mode 100644 index 84ef92ccd0..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/sortutil/README +++ /dev/null @@ -1,4 +0,0 @@ -Packages in this repository: - -Install: $ go get github.com/cznic/sortutil -Godocs: http://godoc.org/github.com/cznic/sortutil diff --git a/Godeps/_workspace/src/github.com/cznic/sortutil/sortutil.go b/Godeps/_workspace/src/github.com/cznic/sortutil/sortutil.go deleted file mode 100644 index c0ced542d3..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/sortutil/sortutil.go +++ /dev/null @@ -1,227 +0,0 @@ -// Copyright 2014 The sortutil 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 sortutil provides utilities supplementing the standard 'sort' package. -package sortutil - -import "sort" - -// ByteSlice attaches the methods of sort.Interface to []byte, sorting in increasing order. -type ByteSlice []byte - -func (s ByteSlice) Len() int { return len(s) } -func (s ByteSlice) Less(i, j int) bool { return s[i] < s[j] } -func (s ByteSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } - -// Sort is a convenience method. -func (s ByteSlice) Sort() { - sort.Sort(s) -} - -// SearchBytes searches for x in a sorted slice of bytes and returns the index -// as specified by sort.Search. The slice must be sorted in ascending order. -func SearchBytes(a []byte, x byte) int { - return sort.Search(len(a), func(i int) bool { return a[i] >= x }) -} - -// Float32Slice attaches the methods of sort.Interface to []float32, sorting in increasing order. -type Float32Slice []float32 - -func (s Float32Slice) Len() int { return len(s) } -func (s Float32Slice) Less(i, j int) bool { return s[i] < s[j] } -func (s Float32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } - -// Sort is a convenience method. -func (s Float32Slice) Sort() { - sort.Sort(s) -} - -// SearchFloat32s searches for x in a sorted slice of float32 and returns the index -// as specified by sort.Search. The slice must be sorted in ascending order. -func SearchFloat32s(a []float32, x float32) int { - return sort.Search(len(a), func(i int) bool { return a[i] >= x }) -} - -// Int8Slice attaches the methods of sort.Interface to []int8, sorting in increasing order. -type Int8Slice []int8 - -func (s Int8Slice) Len() int { return len(s) } -func (s Int8Slice) Less(i, j int) bool { return s[i] < s[j] } -func (s Int8Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } - -// Sort is a convenience method. -func (s Int8Slice) Sort() { - sort.Sort(s) -} - -// SearchInt8s searches for x in a sorted slice of int8 and returns the index -// as specified by sort.Search. The slice must be sorted in ascending order. -func SearchInt8s(a []int8, x int8) int { - return sort.Search(len(a), func(i int) bool { return a[i] >= x }) -} - -// Int16Slice attaches the methods of sort.Interface to []int16, sorting in increasing order. -type Int16Slice []int16 - -func (s Int16Slice) Len() int { return len(s) } -func (s Int16Slice) Less(i, j int) bool { return s[i] < s[j] } -func (s Int16Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } - -// Sort is a convenience method. -func (s Int16Slice) Sort() { - sort.Sort(s) -} - -// SearchInt16s searches for x in a sorted slice of int16 and returns the index -// as specified by sort.Search. The slice must be sorted in ascending order. -func SearchInt16s(a []int16, x int16) int { - return sort.Search(len(a), func(i int) bool { return a[i] >= x }) -} - -// Int32Slice attaches the methods of sort.Interface to []int32, sorting in increasing order. -type Int32Slice []int32 - -func (s Int32Slice) Len() int { return len(s) } -func (s Int32Slice) Less(i, j int) bool { return s[i] < s[j] } -func (s Int32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } - -// Sort is a convenience method. -func (s Int32Slice) Sort() { - sort.Sort(s) -} - -// SearchInt32s searches for x in a sorted slice of int32 and returns the index -// as specified by sort.Search. The slice must be sorted in ascending order. -func SearchInt32s(a []int32, x int32) int { - return sort.Search(len(a), func(i int) bool { return a[i] >= x }) -} - -// Int64Slice attaches the methods of sort.Interface to []int64, sorting in increasing order. -type Int64Slice []int64 - -func (s Int64Slice) Len() int { return len(s) } -func (s Int64Slice) Less(i, j int) bool { return s[i] < s[j] } -func (s Int64Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } - -// Sort is a convenience method. -func (s Int64Slice) Sort() { - sort.Sort(s) -} - -// SearchInt64s searches for x in a sorted slice of int64 and returns the index -// as specified by sort.Search. The slice must be sorted in ascending order. -func SearchInt64s(a []int64, x int64) int { - return sort.Search(len(a), func(i int) bool { return a[i] >= x }) -} - -// UintSlice attaches the methods of sort.Interface to []uint, sorting in increasing order. -type UintSlice []uint - -func (s UintSlice) Len() int { return len(s) } -func (s UintSlice) Less(i, j int) bool { return s[i] < s[j] } -func (s UintSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } - -// Sort is a convenience method. -func (s UintSlice) Sort() { - sort.Sort(s) -} - -// SearchUints searches for x in a sorted slice of uints and returns the index -// as specified by sort.Search. The slice must be sorted in ascending order. -func SearchUints(a []uint, x uint) int { - return sort.Search(len(a), func(i int) bool { return a[i] >= x }) -} - -// Uint16Slice attaches the methods of sort.Interface to []uint16, sorting in increasing order. -type Uint16Slice []uint16 - -func (s Uint16Slice) Len() int { return len(s) } -func (s Uint16Slice) Less(i, j int) bool { return s[i] < s[j] } -func (s Uint16Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } - -// Sort is a convenience method. -func (s Uint16Slice) Sort() { - sort.Sort(s) -} - -// SearchUint16s searches for x in a sorted slice of uint16 and returns the index -// as specified by sort.Search. The slice must be sorted in ascending order. -func SearchUint16s(a []uint16, x uint16) int { - return sort.Search(len(a), func(i int) bool { return a[i] >= x }) -} - -// Uint32Slice attaches the methods of sort.Interface to []uint32, sorting in increasing order. -type Uint32Slice []uint32 - -func (s Uint32Slice) Len() int { return len(s) } -func (s Uint32Slice) Less(i, j int) bool { return s[i] < s[j] } -func (s Uint32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } - -// Sort is a convenience method. -func (s Uint32Slice) Sort() { - sort.Sort(s) -} - -// SearchUint32s searches for x in a sorted slice of uint32 and returns the index -// as specified by sort.Search. The slice must be sorted in ascending order. -func SearchUint32s(a []uint32, x uint32) int { - return sort.Search(len(a), func(i int) bool { return a[i] >= x }) -} - -// Uint64Slice attaches the methods of sort.Interface to []uint64, sorting in increasing order. -type Uint64Slice []uint64 - -func (s Uint64Slice) Len() int { return len(s) } -func (s Uint64Slice) Less(i, j int) bool { return s[i] < s[j] } -func (s Uint64Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } - -// Sort is a convenience method. -func (s Uint64Slice) Sort() { - sort.Sort(s) -} - -// SearchUint64s searches for x in a sorted slice of uint64 and returns the index -// as specified by sort.Search. The slice must be sorted in ascending order. -func SearchUint64s(a []uint64, x uint64) int { - return sort.Search(len(a), func(i int) bool { return a[i] >= x }) -} - -// RuneSlice attaches the methods of sort.Interface to []rune, sorting in increasing order. -type RuneSlice []rune - -func (s RuneSlice) Len() int { return len(s) } -func (s RuneSlice) Less(i, j int) bool { return s[i] < s[j] } -func (s RuneSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } - -// Sort is a convenience method. -func (s RuneSlice) Sort() { - sort.Sort(s) -} - -// SearchRunes searches for x in a sorted slice of uint64 and returns the index -// as specified by sort.Search. The slice must be sorted in ascending order. -func SearchRunes(a []rune, x rune) int { - return sort.Search(len(a), func(i int) bool { return a[i] >= x }) -} - -// Dedupe returns n, the number of distinct elements in data. The resulting -// elements are sorted in elements [0, n) or data[:n] for a slice. -func Dedupe(data sort.Interface) (n int) { - if n = data.Len(); n < 2 { - return n - } - - sort.Sort(data) - a, b := 0, 1 - for b < n { - if data.Less(a, b) { - a++ - if a != b { - data.Swap(a, b) - } - } - b++ - } - return a + 1 -} diff --git a/Godeps/_workspace/src/github.com/cznic/strutil/AUTHORS b/Godeps/_workspace/src/github.com/cznic/strutil/AUTHORS deleted file mode 100644 index d04c450118..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/strutil/AUTHORS +++ /dev/null @@ -1,12 +0,0 @@ -# This file lists authors for copyright purposes. This file is distinct from -# the CONTRIBUTORS files. See the latter for an explanation. -# -# Names should be added to this file as: -# Name or Organization -# -# The email address is not required for organizations. -# -# Please keep the list sorted. - -CZ.NIC z.s.p.o. -Jan Mercl <0xjnml@gmail.com> diff --git a/Godeps/_workspace/src/github.com/cznic/strutil/CONTRIBUTORS b/Godeps/_workspace/src/github.com/cznic/strutil/CONTRIBUTORS deleted file mode 100644 index 5e86f0607c..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/strutil/CONTRIBUTORS +++ /dev/null @@ -1,9 +0,0 @@ -# This file lists people who contributed code to this repository. The AUTHORS -# file lists the copyright holders; this file lists people. -# -# Names should be added to this file like so: -# Name -# -# Please keep the list sorted. - -Jan Mercl <0xjnml@gmail.com> diff --git a/Godeps/_workspace/src/github.com/cznic/strutil/LICENSE b/Godeps/_workspace/src/github.com/cznic/strutil/LICENSE deleted file mode 100644 index 2fdd92cf71..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/strutil/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2014 The strutil 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 names of the authors nor the names of the -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. diff --git a/Godeps/_workspace/src/github.com/cznic/strutil/Makefile b/Godeps/_workspace/src/github.com/cznic/strutil/Makefile deleted file mode 100644 index 0cdf1cf885..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/strutil/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -.PHONY: all clean editor later nuke todo cover cpu - -grep=--include=*.go -target=foo.test - -all: editor - make todo - -clean: - go clean - rm -f *~ - -cover: - t=$(shell tempfile) ; go test -coverprofile $$t && go tool cover -html $$t && unlink $$t - -cpu: $(target) - ./$< -noerr -test.cpuprofile cpu.out - go tool pprof --lines $< cpu.out - -editor: - go fmt - go test -i - go test - go build - -later: - @grep -n $(grep) LATER * || true - @grep -n $(grep) MAYBE * || true - -nuke: clean - go clean -i - -todo: - @grep -nr $(grep) ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* * || true - @grep -nr $(grep) TODO * || true - @grep -nr $(grep) BUG * || true - @grep -nr $(grep) [^[:alpha:]]println * || true diff --git a/Godeps/_workspace/src/github.com/cznic/strutil/README b/Godeps/_workspace/src/github.com/cznic/strutil/README deleted file mode 100644 index a8652a3dc0..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/strutil/README +++ /dev/null @@ -1,8 +0,0 @@ -This is a goinstall-able mirror of modified code already published at: -http://git.nic.cz/redmine/projects/gostrutil/repository - -Online godoc documentation for this package (should be) available at: -http://gopkgdoc.appspot.com/pkg/github.com/cznic/strutil - -Installation: -$ go get github.com/cznic/strutil diff --git a/Godeps/_workspace/src/github.com/cznic/strutil/strutil.go b/Godeps/_workspace/src/github.com/cznic/strutil/strutil.go deleted file mode 100644 index ba83489df7..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/strutil/strutil.go +++ /dev/null @@ -1,428 +0,0 @@ -// Copyright (c) 2014 The sortutil 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 strutil collects utils supplemental to the standard strings package. -package strutil - -import ( - "bytes" - "encoding/base32" - "encoding/base64" - "fmt" - "io" - "strings" - "sync" -) - -// Base32ExtDecode decodes base32 extended (RFC 4648) text to binary data. -func Base32ExtDecode(text []byte) (data []byte, err error) { - n := base32.HexEncoding.DecodedLen(len(text)) - data = make([]byte, n) - decoder := base32.NewDecoder(base32.HexEncoding, bytes.NewBuffer(text)) - if n, err = decoder.Read(data); err != nil { - n = 0 - } - data = data[:n] - return -} - -// Base32ExtEncode encodes binary data to base32 extended (RFC 4648) encoded text. -func Base32ExtEncode(data []byte) (text []byte) { - n := base32.HexEncoding.EncodedLen(len(data)) - buf := bytes.NewBuffer(make([]byte, 0, n)) - encoder := base32.NewEncoder(base32.HexEncoding, buf) - encoder.Write(data) - encoder.Close() - if buf.Len() != n { - panic("internal error") - } - return buf.Bytes() -} - -// Base64Decode decodes base64 text to binary data. -func Base64Decode(text []byte) (data []byte, err error) { - n := base64.StdEncoding.DecodedLen(len(text)) - data = make([]byte, n) - decoder := base64.NewDecoder(base64.StdEncoding, bytes.NewBuffer(text)) - if n, err = decoder.Read(data); err != nil { - n = 0 - } - data = data[:n] - return -} - -// Base64Encode encodes binary data to base64 encoded text. -func Base64Encode(data []byte) (text []byte) { - n := base64.StdEncoding.EncodedLen(len(data)) - buf := bytes.NewBuffer(make([]byte, 0, n)) - encoder := base64.NewEncoder(base64.StdEncoding, buf) - encoder.Write(data) - encoder.Close() - if buf.Len() != n { - panic("internal error") - } - return buf.Bytes() -} - -// Formatter is an io.Writer extended by a fmt.Printf like function Format -type Formatter interface { - io.Writer - Format(format string, args ...interface{}) (n int, errno error) -} - -type indentFormatter struct { - io.Writer - indent []byte - indentLevel int - state int -} - -const ( - st0 = iota - stBOL - stPERC - stBOL_PERC -) - -// IndentFormatter returns a new Formatter which interprets %i and %u in the -// Format() format string as indent and undent commands. The commands can -// nest. The Formatter writes to io.Writer 'w' and inserts one 'indent' -// string per current indent level value. -// Behaviour of commands reaching negative indent levels is undefined. -// IndentFormatter(os.Stdout, "\t").Format("abc%d%%e%i\nx\ny\n%uz\n", 3) -// output: -// abc3%e -// x -// y -// z -// The Go quoted string literal form of the above is: -// "abc%%e\n\tx\n\tx\nz\n" -// The commands can be scattered between separate invocations of Format(), -// i.e. the formatter keeps track of the indent level and knows if it is -// positioned on start of a line and should emit indentation(s). -// The same output as above can be produced by e.g.: -// f := IndentFormatter(os.Stdout, " ") -// f.Format("abc%d%%e%i\nx\n", 3) -// f.Format("y\n%uz\n") -func IndentFormatter(w io.Writer, indent string) Formatter { - return &indentFormatter{w, []byte(indent), 0, stBOL} -} - -func (f *indentFormatter) format(flat bool, format string, args ...interface{}) (n int, errno error) { - buf := []byte{} - for i := 0; i < len(format); i++ { - c := format[i] - switch f.state { - case st0: - switch c { - case '\n': - cc := c - if flat && f.indentLevel != 0 { - cc = ' ' - } - buf = append(buf, cc) - f.state = stBOL - case '%': - f.state = stPERC - default: - buf = append(buf, c) - } - case stBOL: - switch c { - case '\n': - cc := c - if flat && f.indentLevel != 0 { - cc = ' ' - } - buf = append(buf, cc) - case '%': - f.state = stBOL_PERC - default: - if !flat { - for i := 0; i < f.indentLevel; i++ { - buf = append(buf, f.indent...) - } - } - buf = append(buf, c) - f.state = st0 - } - case stBOL_PERC: - switch c { - case 'i': - f.indentLevel++ - f.state = stBOL - case 'u': - f.indentLevel-- - f.state = stBOL - default: - if !flat { - for i := 0; i < f.indentLevel; i++ { - buf = append(buf, f.indent...) - } - } - buf = append(buf, '%', c) - f.state = st0 - } - case stPERC: - switch c { - case 'i': - f.indentLevel++ - f.state = st0 - case 'u': - f.indentLevel-- - f.state = st0 - default: - buf = append(buf, '%', c) - f.state = st0 - } - default: - panic("unexpected state") - } - } - switch f.state { - case stPERC, stBOL_PERC: - buf = append(buf, '%') - } - return f.Write([]byte(fmt.Sprintf(string(buf), args...))) -} - -func (f *indentFormatter) Format(format string, args ...interface{}) (n int, errno error) { - return f.format(false, format, args...) -} - -type flatFormatter indentFormatter - -// FlatFormatter returns a newly created Formatter with the same functionality as the one returned -// by IndentFormatter except it allows a newline in the 'format' string argument of Format -// to pass through iff indent level is currently zero. -// -// If indent level is non-zero then such new lines are changed to a space character. -// There is no indent string, the %i and %u format verbs are used solely to determine the indent level. -// -// The FlatFormatter is intended for flattening of normally nested structure textual representation to -// a one top level structure per line form. -// FlatFormatter(os.Stdout, " ").Format("abc%d%%e%i\nx\ny\n%uz\n", 3) -// output in the form of a Go quoted string literal: -// "abc3%%e x y z\n" -func FlatFormatter(w io.Writer) Formatter { - return (*flatFormatter)(IndentFormatter(w, "").(*indentFormatter)) -} - -func (f *flatFormatter) Format(format string, args ...interface{}) (n int, errno error) { - return (*indentFormatter)(f).format(true, format, args...) -} - -// Pool handles aligning of strings having equal values to the same string instance. -// Intended use is to conserve some memory e.g. where a large number of identically valued strings -// with non identical backing arrays may exists in several semantically distinct instances of some structs. -// Pool is *not* concurrent access safe. It doesn't handle common prefix/suffix aligning, -// e.g. having s1 == "abc" and s2 == "bc", s2 is not automatically aligned as s1[1:]. -type Pool struct { - pool map[string]string -} - -// NewPool returns a newly created Pool. -func NewPool() *Pool { - return &Pool{map[string]string{}} -} - -// Align returns a string with the same value as its argument. It guarantees that -// all aligned strings share a single instance in memory. -func (p *Pool) Align(s string) string { - if a, ok := p.pool[s]; ok { - return a - } - - s = StrPack(s) - p.pool[s] = s - return s -} - -// Count returns the number of items in the pool. -func (p *Pool) Count() int { - return len(p.pool) -} - -// GoPool is a concurrent access safe version of Pool. -type GoPool struct { - pool map[string]string - rwm *sync.RWMutex -} - -// NewGoPool returns a newly created GoPool. -func NewGoPool() (p *GoPool) { - return &GoPool{map[string]string{}, &sync.RWMutex{}} -} - -// Align returns a string with the same value as its argument. It guarantees that -// all aligned strings share a single instance in memory. -func (p *GoPool) Align(s string) (y string) { - if s != "" { - p.rwm.RLock() // R++ - if a, ok := p.pool[s]; ok { // found - p.rwm.RUnlock() // R-- - return a - } - - p.rwm.RUnlock() // R-- - // not found but with a race condition, retry within a write lock - p.rwm.Lock() // W++ - defer p.rwm.Unlock() // W-- - if a, ok := p.pool[s]; ok { // done in a race - return a - } - - // we won - s = StrPack(s) - p.pool[s] = s - return s - } - - return -} - -// Count returns the number of items in the pool. -func (p *GoPool) Count() int { - return len(p.pool) -} - -// Dict is a string <-> id bijection. Dict is *not* concurrent access safe for assigning new ids -// to strings not yet contained in the bijection. -// Id for an empty string is guaranteed to be 0, -// thus Id for any non empty string is guaranteed to be non zero. -type Dict struct { - si map[string]int - is []string -} - -// NewDict returns a newly created Dict. -func NewDict() (d *Dict) { - d = &Dict{map[string]int{}, []string{}} - d.Id("") - return -} - -// Count returns the number of items in the dict. -func (d *Dict) Count() int { - return len(d.is) -} - -// Id maps string s to its numeric identificator. -func (d *Dict) Id(s string) (y int) { - if y, ok := d.si[s]; ok { - return y - } - - s = StrPack(s) - y = len(d.is) - d.si[s] = y - d.is = append(d.is, s) - return -} - -// S maps an id to its string value and ok == true. Id values not contained in the bijection -// return "", false. -func (d *Dict) S(id int) (s string, ok bool) { - if id >= len(d.is) { - return "", false - } - return d.is[id], true -} - -// GoDict is a concurrent access safe version of Dict. -type GoDict struct { - si map[string]int - is []string - rwm *sync.RWMutex -} - -// NewGoDict returns a newly created GoDict. -func NewGoDict() (d *GoDict) { - d = &GoDict{map[string]int{}, []string{}, &sync.RWMutex{}} - d.Id("") - return -} - -// Count returns the number of items in the dict. -func (d *GoDict) Count() int { - return len(d.is) -} - -// Id maps string s to its numeric identificator. The implementation honors getting -// an existing id at the cost of assigning a new one. -func (d *GoDict) Id(s string) (y int) { - d.rwm.RLock() // R++ - if y, ok := d.si[s]; ok { // found - d.rwm.RUnlock() // R-- - return y - } - - d.rwm.RUnlock() // R-- - - // not found but with a race condition - d.rwm.Lock() // W++ recheck with write lock - defer d.rwm.Unlock() // W-- - if y, ok := d.si[s]; ok { // some other goroutine won already - return y - } - - // a race free not found state => insert the string - s = StrPack(s) - y = len(d.is) - d.si[s] = y - d.is = append(d.is, s) - return -} - -// S maps an id to its string value and ok == true. Id values not contained in the bijection -// return "", false. -func (d *GoDict) S(id int) (s string, ok bool) { - d.rwm.RLock() // R++ - defer d.rwm.RUnlock() // R-- - if id >= len(d.is) { - return "", false - } - return d.is[id], true -} - -// StrPack returns a new instance of s which is tightly packed in memory. -// It is intended for avoiding the situation where having a live reference -// to a string slice over an unreferenced biger underlying string keeps the biger one -// in memory anyway - it can't be GCed. -func StrPack(s string) string { - return string([]byte(s)) -} - -// JoinFields returns strings in flds joined by sep. Flds may contain arbitrary -// bytes, including the sep as they are safely escaped. JoinFields panics if -// sep is the backslash character or if len(sep) != 1. -func JoinFields(flds []string, sep string) string { - if len(sep) != 1 || sep == "\\" { - panic("invalid separator") - } - - a := make([]string, len(flds)) - for i, v := range flds { - v = strings.Replace(v, "\\", "\\0", -1) - a[i] = strings.Replace(v, sep, "\\1", -1) - } - return strings.Join(a, sep) -} - -// SplitFields splits s, which must be produced by JoinFields using the same -// sep, into flds. SplitFields panics if sep is the backslash character or if -// len(sep) != 1. -func SplitFields(s, sep string) (flds []string) { - if len(sep) != 1 || sep == "\\" { - panic("invalid separator") - } - - a := strings.Split(s, sep) - r := make([]string, len(a)) - for i, v := range a { - v = strings.Replace(v, "\\1", sep, -1) - r[i] = strings.Replace(v, "\\0", "\\", -1) - } - return r -} diff --git a/Godeps/_workspace/src/github.com/cznic/zappy/AUTHORS b/Godeps/_workspace/src/github.com/cznic/zappy/AUTHORS deleted file mode 100644 index 22c8397d5f..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/zappy/AUTHORS +++ /dev/null @@ -1,12 +0,0 @@ -# This file lists authors for copyright purposes. This file is distinct from -# the CONTRIBUTORS files. See the latter for an explanation. -# -# Names should be added to this file as: -# Name or Organization -# -# The email address is not required for organizations. -# -# Please keep the list sorted. - -Jan Mercl <0xjnml@gmail.com> -The Snappy-Go Authors diff --git a/Godeps/_workspace/src/github.com/cznic/zappy/CONTRIBUTORS b/Godeps/_workspace/src/github.com/cznic/zappy/CONTRIBUTORS deleted file mode 100644 index 7693bdab74..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/zappy/CONTRIBUTORS +++ /dev/null @@ -1,10 +0,0 @@ -# This file lists people who contributed code to this repository. The AUTHORS -# file lists the copyright holders; this file lists people. -# -# Names should be added to this file like so: -# Name -# -# Please keep the list sorted. - -Jan Mercl <0xjnml@gmail.com> -Mathieu Lonjaret diff --git a/Godeps/_workspace/src/github.com/cznic/zappy/LICENSE b/Godeps/_workspace/src/github.com/cznic/zappy/LICENSE deleted file mode 100644 index bc67059c52..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/zappy/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2014 The zappy 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 names of the authors nor the names of the -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. diff --git a/Godeps/_workspace/src/github.com/cznic/zappy/Makefile b/Godeps/_workspace/src/github.com/cznic/zappy/Makefile deleted file mode 100644 index c6726d13e0..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/zappy/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2014 The zappy Authors. All rights reserved. -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file. - -all: editor - go tool vet -printfuncs Log:0,Logf:0 . - golint . - go install - make todo - -editor: - go fmt - go test -i - @#go test - ./purego.sh - -todo: - @grep -n ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alnum:]] *.go || true - @grep -n TODO *.go || true - @grep -n BUG *.go || true - @grep -n println *.go || true - -clean: - rm -f *~ cov cov.html - -gocov: - gocov test $(COV) | gocov-html > cov.html - -bench: - go test -run NONE -bench B diff --git a/Godeps/_workspace/src/github.com/cznic/zappy/README.md b/Godeps/_workspace/src/github.com/cznic/zappy/README.md deleted file mode 100644 index 6fc6f68a70..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/zappy/README.md +++ /dev/null @@ -1,9 +0,0 @@ -zappy -===== - -Package zappy implements the zappy block-based compression format. It aims for -a combination of good speed and reasonable compression. - -Installation: $ go get github.com/cznic/zappy - -Documentation: [godoc.org/github.com/cznic/zappy](http://godoc.org/github.com/cznic/zappy) diff --git a/Godeps/_workspace/src/github.com/cznic/zappy/SNAPPY-GO-LICENSE b/Godeps/_workspace/src/github.com/cznic/zappy/SNAPPY-GO-LICENSE deleted file mode 100644 index 6050c10f4c..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/zappy/SNAPPY-GO-LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2011 The Snappy-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. diff --git a/Godeps/_workspace/src/github.com/cznic/zappy/decode.go b/Godeps/_workspace/src/github.com/cznic/zappy/decode.go deleted file mode 100644 index 867c8deea5..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/zappy/decode.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2014 The zappy Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Copyright 2011 The Snappy-Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the SNAPPY-GO-LICENSE file. - -package zappy - -import ( - "encoding/binary" - "errors" -) - -// ErrCorrupt reports that the input is invalid. -var ErrCorrupt = errors.New("zappy: corrupt input") - -// DecodedLen returns the length of the decoded block. -func DecodedLen(src []byte) (int, error) { - v, _, err := decodedLen(src) - return v, err -} - -// decodedLen returns the length of the decoded block and the number of bytes -// that the length header occupied. -func decodedLen(src []byte) (blockLen, headerLen int, err error) { - v, n := binary.Uvarint(src) - if n == 0 { - return 0, 0, ErrCorrupt - } - - if uint64(int(v)) != v { - return 0, 0, errors.New("zappy: decoded block is too large") - } - - return int(v), n, nil -} diff --git a/Godeps/_workspace/src/github.com/cznic/zappy/decode_cgo.go b/Godeps/_workspace/src/github.com/cznic/zappy/decode_cgo.go deleted file mode 100644 index 993c99242b..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/zappy/decode_cgo.go +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2014 The zappy Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Copyright 2011 The Snappy-Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the SNAPPY-GO-LICENSE file. - -// +build cgo,!purego - -package zappy - -/* - -#include -#include - -// supports only uint32 encoded values -int uvarint(unsigned int* n, uint8_t* src, int len) { - int r = 0; - unsigned int v = 0; - unsigned int s = 0; - while ((len-- != 0) && (++r <= 5)) { - uint8_t b = *src++; - v = v | ((b&0x7f)<>1; - if ((u&1) != 0) - x = ~x; - *n = x; - return i; -} - -int decode(int s, int len_src, uint8_t* src, int len_dst, uint8_t* dst) { - int d = 0; - int length; - while (s < len_src) { - int n, i = varint(&n, src+s, len_src-s); - if (i <= 0) { - return -1; - } - - s += i; - if (n >= 0) { - length = n+1; - if ((length > len_dst-d) || (length > len_src-s)) - return -1; - - memcpy(dst+d, src+s, length); - d += length; - s += length; - continue; - } - - - length = -n; - int offset; - i = uvarint((unsigned int*)(&offset), src+s, len_src-s); - if (i <= 0) - return -1; - - s += i; - if (s > len_src) - return -1; - - int end = d+length; - if ((offset > d) || (end > len_dst)) - return -1; - - for( ; d < end; d++) - *(dst+d) = *(dst+d-offset); - } - return d; -} - -*/ -import "C" - -func puregoDecode() bool { return false } - -// Decode returns the decoded form of src. The returned slice may be a sub- -// slice of buf if buf was large enough to hold the entire decoded block. -// Otherwise, a newly allocated slice will be returned. -// It is valid to pass a nil buf. -func Decode(buf, src []byte) ([]byte, error) { - dLen, s, err := decodedLen(src) - if err != nil { - return nil, err - } - - if dLen == 0 { - if len(src) == 1 { - return nil, nil - } - - return nil, ErrCorrupt - } - - if len(buf) < dLen { - buf = make([]byte, dLen) - } - - d := int(C.decode(C.int(s), C.int(len(src)), (*C.uint8_t)(&src[0]), C.int(len(buf)), (*C.uint8_t)(&buf[0]))) - if d != dLen { - return nil, ErrCorrupt - } - - return buf[:d], nil -} diff --git a/Godeps/_workspace/src/github.com/cznic/zappy/decode_nocgo.go b/Godeps/_workspace/src/github.com/cznic/zappy/decode_nocgo.go deleted file mode 100644 index 75b782f8fa..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/zappy/decode_nocgo.go +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2014 The zappy Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Copyright 2011 The Snappy-Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the SNAPPY-GO-LICENSE file. - -// +build !cgo purego - -package zappy - -import ( - "encoding/binary" -) - -func puregoDecode() bool { return true } - -// Decode returns the decoded form of src. The returned slice may be a sub- -// slice of buf if buf was large enough to hold the entire decoded block. -// Otherwise, a newly allocated slice will be returned. -// It is valid to pass a nil buf. -func Decode(buf, src []byte) ([]byte, error) { - dLen, s, err := decodedLen(src) - if err != nil { - return nil, err - } - - if dLen == 0 { - if len(src) == 1 { - return nil, nil - } - - return nil, ErrCorrupt - } - - if len(buf) < dLen { - buf = make([]byte, dLen) - } - - var d, offset, length int - for s < len(src) { - n, i := binary.Varint(src[s:]) - if i <= 0 { - return nil, ErrCorrupt - } - - s += i - if n >= 0 { - length = int(n + 1) - if length > len(buf)-d || length > len(src)-s { - return nil, ErrCorrupt - } - - copy(buf[d:], src[s:s+length]) - d += length - s += length - continue - } - - length = int(-n) - off64, i := binary.Uvarint(src[s:]) - if i <= 0 { - return nil, ErrCorrupt - } - - offset = int(off64) - s += i - if s > len(src) { - return nil, ErrCorrupt - } - - end := d + length - if offset > d || end > len(buf) { - return nil, ErrCorrupt - } - - for s, v := range buf[d-offset : end-offset] { - buf[d+s] = v - } - d = end - - } - if d != dLen { - return nil, ErrCorrupt - } - - return buf[:d], nil -} diff --git a/Godeps/_workspace/src/github.com/cznic/zappy/encode.go b/Godeps/_workspace/src/github.com/cznic/zappy/encode.go deleted file mode 100644 index 27ceba03b8..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/zappy/encode.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 The zappy Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Copyright 2011 The Snappy-Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the SNAPPY-GO-LICENSE file. - -package zappy - -import ( - "encoding/binary" -) - -// We limit how far copy back-references can go, the same as the snappy C++ -// code. -const maxOffset = 1 << 20 - -// emitCopy writes a copy chunk and returns the number of bytes written. -func emitCopy(dst []byte, offset, length int) (n int) { - n = binary.PutVarint(dst, int64(-length)) - n += binary.PutUvarint(dst[n:], uint64(offset)) - return -} - -// emitLiteral writes a literal chunk and returns the number of bytes written. -func emitLiteral(dst, lit []byte) (n int) { - n = binary.PutVarint(dst, int64(len(lit)-1)) - n += copy(dst[n:], lit) - return -} - -// MaxEncodedLen returns the maximum length of a zappy block, given its -// uncompressed length. -func MaxEncodedLen(srcLen int) int { - return 10 + srcLen -} diff --git a/Godeps/_workspace/src/github.com/cznic/zappy/encode_cgo.go b/Godeps/_workspace/src/github.com/cznic/zappy/encode_cgo.go deleted file mode 100644 index 6c343f58eb..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/zappy/encode_cgo.go +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright 2014 The zappy Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Copyright 2011 The Snappy-Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the SNAPPY-GO-LICENSE file. - -// +build cgo,!purego - -package zappy - -/* - -#include -#include - -#define MAXOFFSET 1<<20 - -int putUvarint(uint8_t* buf, unsigned int x) { - int i = 1; - for (; x >= 0x80; i++) { - *buf++ = x|0x80; - x >>= 7; - } - *buf = x; - return i; -} - -int putVarint(uint8_t* buf, int x) { - unsigned int ux = x << 1; - if (x < 0) - ux = ~ux; - return putUvarint(buf, ux); -} - -int emitLiteral(uint8_t* dst, uint8_t* lit, int len_lit) { - int n = putVarint(dst, len_lit-1); - memcpy(dst+n, lit, len_lit); - return n+len_lit; -} - -int emitCopy(uint8_t* dst, int off, int len) { - int n = putVarint(dst, -len); - return n+putUvarint(dst+n, (unsigned int)off); -} - -int encode(int d, uint8_t* dst, uint8_t* src, int len_src) { - int table[1<<12]; - int s = 0; - int t = 0; - int lit = 0; - int lim = 0; - memset(table, 0, sizeof(table)); - for (lim = len_src-3; s < lim; ) { - // Update the hash table. - uint32_t b0 = src[s]; - uint32_t b1 = src[s+1]; - uint32_t b2 = src[s+2]; - uint32_t b3 = src[s+3]; - uint32_t h = b0 | (b1<<8) | (b2<<16) | (b3<<24); - uint32_t i; -more: - i = (h*0x1e35a7bd)>>20; - t = table[i]; - table[i] = s; - // If t is invalid or src[s:s+4] differs from src[t:t+4], accumulate a literal byte. - if ((t == 0) || (s-t >= MAXOFFSET) || (b0 != src[t]) || (b1 != src[t+1]) || (b2 != src[t+2]) || (b3 != src[t+3])) { - s++; - if (s >= lim) - break; - - b0 = b1; - b1 = b2; - b2 = b3; - b3 = src[s+3]; - h = (h>>8) | ((b3)<<24); - goto more; - } - - // Otherwise, we have a match. First, emit any pending literal bytes. - if (lit != s) { - d += emitLiteral(dst+d, src+lit, s-lit); - } - // Extend the match to be as long as possible. - int s0 = s; - s += 4; - t += 4; - while ((s < len_src) && (src[s] == src[t])) { - s++; - t++; - } - d += emitCopy(dst+d, s-t, s-s0); - lit = s; - } - // Emit any final pending literal bytes and return. - if (lit != len_src) { - d += emitLiteral(dst+d, src+lit, len_src-lit); - } - return d; -} - -*/ -import "C" - -import ( - "encoding/binary" - "fmt" - "math" -) - -func puregoEncode() bool { return false } - -// Encode returns the encoded form of src. The returned slice may be a sub- -// slice of buf if buf was large enough to hold the entire encoded block. -// Otherwise, a newly allocated slice will be returned. -// It is valid to pass a nil buf. -func Encode(buf, src []byte) ([]byte, error) { - if n := MaxEncodedLen(len(src)); len(buf) < n { - buf = make([]byte, n) - } - - if len(src) > math.MaxInt32 { - return nil, fmt.Errorf("zappy.Encode: too long data: %d bytes", len(src)) - } - - // The block starts with the varint-encoded length of the decompressed bytes. - d := binary.PutUvarint(buf, uint64(len(src))) - - // Return early if src is short. - if len(src) <= 4 { - if len(src) != 0 { - d += emitLiteral(buf[d:], src) - } - return buf[:d], nil - } - - d = int(C.encode(C.int(d), (*C.uint8_t)(&buf[0]), (*C.uint8_t)(&src[0]), C.int(len(src)))) - return buf[:d], nil -} diff --git a/Godeps/_workspace/src/github.com/cznic/zappy/encode_nocgo.go b/Godeps/_workspace/src/github.com/cznic/zappy/encode_nocgo.go deleted file mode 100644 index 1d1df44395..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/zappy/encode_nocgo.go +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2014 The zappy Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Copyright 2011 The Snappy-Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the SNAPPY-GO-LICENSE file. - -// +build !cgo purego - -package zappy - -import ( - "encoding/binary" - "fmt" - "math" -) - -func puregoEncode() bool { return true } - -// Encode returns the encoded form of src. The returned slice may be a sub- -// slice of buf if buf was large enough to hold the entire encoded block. -// Otherwise, a newly allocated slice will be returned. -// It is valid to pass a nil buf. -func Encode(buf, src []byte) ([]byte, error) { - if n := MaxEncodedLen(len(src)); len(buf) < n { - buf = make([]byte, n) - } - - if len(src) > math.MaxInt32 { - return nil, fmt.Errorf("zappy.Encode: too long data: %d bytes", len(src)) - } - - // The block starts with the varint-encoded length of the decompressed bytes. - d := binary.PutUvarint(buf, uint64(len(src))) - - // Return early if src is short. - if len(src) <= 4 { - if len(src) != 0 { - d += emitLiteral(buf[d:], src) - } - return buf[:d], nil - } - - // Iterate over the source bytes. - var ( - table [1 << 12]int // Hash table - s int // The iterator position. - t int // The last position with the same hash as s. - lit int // The start position of any pending literal bytes. - ) - for lim := len(src) - 3; s < lim; { - // Update the hash table. - b0, b1, b2, b3 := src[s], src[s+1], src[s+2], src[s+3] - h := uint32(b0) | uint32(b1)<<8 | uint32(b2)<<16 | uint32(b3)<<24 - more: - p := &table[(h*0x1e35a7bd)>>20] - t, *p = *p, s - // If t is invalid or src[s:s+4] differs from src[t:t+4], accumulate a literal byte. - if t == 0 || s-t >= maxOffset || b0 != src[t] || b1 != src[t+1] || b2 != src[t+2] || b3 != src[t+3] { - s++ - if s >= lim { - break - } - - b0, b1, b2, b3 = b1, b2, b3, src[s+3] - h = h>>8 | uint32(b3)<<24 - goto more - } - - // Otherwise, we have a match. First, emit any pending literal bytes. - if lit != s { - d += emitLiteral(buf[d:], src[lit:s]) - } - // Extend the match to be as long as possible. - s0 := s - s, t = s+4, t+4 - for s < len(src) && src[s] == src[t] { - s++ - t++ - } - // Emit the copied bytes. - d += emitCopy(buf[d:], s-t, s-s0) - lit = s - } - - // Emit any final pending literal bytes and return. - if lit != len(src) { - d += emitLiteral(buf[d:], src[lit:]) - } - return buf[:d], nil -} diff --git a/Godeps/_workspace/src/github.com/cznic/zappy/purego.sh b/Godeps/_workspace/src/github.com/cznic/zappy/purego.sh deleted file mode 100644 index e2fec14e63..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/zappy/purego.sh +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright 2014 The zappy Authors. All rights reserved. -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file. - -set -e -set -v - -CGO_ENABLED=0 go test -purego true -CGO_ENABLED=0 go test -purego true -tags purego -CGO_ENABLED=1 go test -purego false -CGO_ENABLED=1 go test -purego true -tags purego diff --git a/Godeps/_workspace/src/github.com/cznic/zappy/zappy.go b/Godeps/_workspace/src/github.com/cznic/zappy/zappy.go deleted file mode 100644 index 760df34a15..0000000000 --- a/Godeps/_workspace/src/github.com/cznic/zappy/zappy.go +++ /dev/null @@ -1,241 +0,0 @@ -// Copyright 2014 The zappy Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Copyright 2011 The Snappy-Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the SNAPPY-GO-LICENSE file. - -/* -Package zappy implements the zappy block-based compression format. It aims for -a combination of good speed and reasonable compression. - -Zappy is a format incompatible, API compatible fork of snappy-go[1]. The C++ -snappy implementation is at [2]. - -Reasons for the fork - -The snappy compression is pretty good. Yet it has one problem built into its -format definition[3] - the maximum length of a copy "instruction" is 64 bytes. -For some specific usage patterns with long runs of repeated data, it turns out -the compression is suboptimal. For example a 1:1000 "sparseness" 64kB bit index -with only few set bits is compressed to about 3kB (about 1000 of 64B copy, 3 -byte "instructions"). - -Format description - -Zappy uses much less complicated format than snappy. Each encoded block begins -with the uvarint-encoded[4] length of the decoded data, followed by a sequence -of chunks. Chunks begin and end on byte boundaries. The chunk starts with a -varint encoded number N: - - N >= 0: N+1 literal bytes follow. - - N < 0: copy -N bytes, starting at offset M (in the following uvarint). - -Performance issues - -Compression rate is roughly the same as of snappy for the reference data set: - - testdata/html: snappy 23320, zappy 22943, 0.984, orig 102400 - testdata/urls.10K: snappy 334437, zappy 355163, 1.062, orig 702087 - testdata/house.jpg: snappy 126711, zappy 126694, 1.000, orig 126958 - testdata/mapreduce-osdi-1.pdf: snappy 77227, zappy 77646, 1.005, orig 94330 - testdata/html_x_4: snappy 92350, zappy 22956, 0.249, orig 409600 - testdata/cp.html: snappy 11938, zappy 12961, 1.086, orig 24603 - testdata/fields.c: snappy 4825, zappy 5395, 1.118, orig 11150 - testdata/grammar.lsp: snappy 1814, zappy 1933, 1.066, orig 3721 - testdata/kennedy.xls: snappy 423518, zappy 440597, 1.040, orig 1029744 - testdata/alice29.txt: snappy 89550, zappy 104016, 1.162, orig 152089 - testdata/asyoulik.txt: snappy 79583, zappy 91345, 1.148, orig 125179 - testdata/lcet10.txt: snappy 238761, zappy 275488, 1.154, orig 426754 - testdata/plrabn12.txt: snappy 324567, zappy 376885, 1.161, orig 481861 - testdata/ptt5: snappy 96350, zappy 91465, 0.949, orig 513216 - testdata/sum: snappy 18927, zappy 20015, 1.057, orig 38240 - testdata/xargs.1: snappy 2532, zappy 2793, 1.103, orig 4227 - testdata/geo.protodata: snappy 23362, zappy 20759, 0.889, orig 118588 - testdata/kppkn.gtb: snappy 73962, zappy 87200, 1.179, orig 184320 - TOTAL: snappy 2043734, zappy 2136254, 1.045, orig 4549067 - -Zappy has better RLE handling (1/1000+1 non zero bytes in each index): - - Sparse bit index 16 B: snappy 9, zappy 9, 1.000 - Sparse bit index 32 B: snappy 10, zappy 10, 1.000 - Sparse bit index 64 B: snappy 11, zappy 10, 0.909 - Sparse bit index 128 B: snappy 16, zappy 14, 0.875 - Sparse bit index 256 B: snappy 22, zappy 14, 0.636 - Sparse bit index 512 B: snappy 36, zappy 16, 0.444 - Sparse bit index 1024 B: snappy 57, zappy 18, 0.316 - Sparse bit index 2048 B: snappy 111, zappy 32, 0.288 - Sparse bit index 4096 B: snappy 210, zappy 31, 0.148 - Sparse bit index 8192 B: snappy 419, zappy 75, 0.179 - Sparse bit index 16384 B: snappy 821, zappy 138, 0.168 - Sparse bit index 32768 B: snappy 1627, zappy 232, 0.143 - Sparse bit index 65536 B: snappy 3243, zappy 451, 0.139 - -When compiled with CGO_ENABLED=1, zappy is now faster than snappy-go. -Old=snappy-go, new=zappy: - - benchmark old MB/s new MB/s speedup - BenchmarkWordsDecode1e3 148.98 189.04 1.27x - BenchmarkWordsDecode1e4 150.29 182.51 1.21x - BenchmarkWordsDecode1e5 145.79 182.95 1.25x - BenchmarkWordsDecode1e6 167.43 187.69 1.12x - BenchmarkWordsEncode1e3 47.11 145.69 3.09x - BenchmarkWordsEncode1e4 81.47 136.50 1.68x - BenchmarkWordsEncode1e5 78.86 127.93 1.62x - BenchmarkWordsEncode1e6 96.81 142.95 1.48x - Benchmark_UFlat0 316.87 463.19 1.46x - Benchmark_UFlat1 231.56 350.32 1.51x - Benchmark_UFlat2 3656.68 8258.39 2.26x - Benchmark_UFlat3 892.56 1270.09 1.42x - Benchmark_UFlat4 315.84 959.08 3.04x - Benchmark_UFlat5 211.70 301.55 1.42x - Benchmark_UFlat6 211.59 258.29 1.22x - Benchmark_UFlat7 209.80 272.21 1.30x - Benchmark_UFlat8 254.59 301.70 1.19x - Benchmark_UFlat9 163.39 192.66 1.18x - Benchmark_UFlat10 155.46 189.70 1.22x - Benchmark_UFlat11 170.11 198.95 1.17x - Benchmark_UFlat12 148.32 178.78 1.21x - Benchmark_UFlat13 359.25 579.99 1.61x - Benchmark_UFlat14 197.27 291.33 1.48x - Benchmark_UFlat15 185.75 248.07 1.34x - Benchmark_UFlat16 362.74 582.66 1.61x - Benchmark_UFlat17 222.95 240.01 1.08x - Benchmark_ZFlat0 188.66 311.89 1.65x - Benchmark_ZFlat1 101.46 201.34 1.98x - Benchmark_ZFlat2 93.62 244.50 2.61x - Benchmark_ZFlat3 102.79 243.34 2.37x - Benchmark_ZFlat4 191.64 625.32 3.26x - Benchmark_ZFlat5 103.09 169.39 1.64x - Benchmark_ZFlat6 110.35 182.57 1.65x - Benchmark_ZFlat7 89.56 190.53 2.13x - Benchmark_ZFlat8 154.05 235.68 1.53x - Benchmark_ZFlat9 87.58 133.51 1.52x - Benchmark_ZFlat10 82.08 127.51 1.55x - Benchmark_ZFlat11 91.36 138.91 1.52x - Benchmark_ZFlat12 79.24 123.02 1.55x - Benchmark_ZFlat13 217.04 374.26 1.72x - Benchmark_ZFlat14 100.33 168.03 1.67x - Benchmark_ZFlat15 80.79 160.46 1.99x - Benchmark_ZFlat16 213.32 375.79 1.76x - Benchmark_ZFlat17 135.37 197.13 1.46x - -The package builds with CGO_ENABLED=0 as well, but the performance is worse. - - - $ CGO_ENABLED=0 go test -test.run=NONE -test.bench=. > old.benchcmp - $ CGO_ENABLED=1 go test -test.run=NONE -test.bench=. > new.benchcmp - $ benchcmp old.benchcmp new.benchcmp - benchmark old ns/op new ns/op delta - BenchmarkWordsDecode1e3 9735 5288 -45.68% - BenchmarkWordsDecode1e4 100229 55369 -44.76% - BenchmarkWordsDecode1e5 1037611 546420 -47.34% - BenchmarkWordsDecode1e6 9559352 5335307 -44.19% - BenchmarkWordsEncode1e3 16206 6629 -59.10% - BenchmarkWordsEncode1e4 140283 73161 -47.85% - BenchmarkWordsEncode1e5 1476657 781756 -47.06% - BenchmarkWordsEncode1e6 12702229 6997656 -44.91% - Benchmark_UFlat0 397307 221198 -44.33% - Benchmark_UFlat1 3890483 2008341 -48.38% - Benchmark_UFlat2 35810 15398 -57.00% - Benchmark_UFlat3 140850 74194 -47.32% - Benchmark_UFlat4 814575 426783 -47.61% - Benchmark_UFlat5 156995 81473 -48.10% - Benchmark_UFlat6 77645 43161 -44.41% - Benchmark_UFlat7 25415 13579 -46.57% - Benchmark_UFlat8 6372440 3412916 -46.44% - Benchmark_UFlat9 1453679 789956 -45.66% - Benchmark_UFlat10 1243146 660747 -46.85% - Benchmark_UFlat11 3903493 2146334 -45.02% - Benchmark_UFlat12 5106250 2696144 -47.20% - Benchmark_UFlat13 1641394 884969 -46.08% - Benchmark_UFlat14 262206 131174 -49.97% - Benchmark_UFlat15 32325 17047 -47.26% - Benchmark_UFlat16 366991 204877 -44.17% - Benchmark_UFlat17 1343988 770907 -42.64% - Benchmark_ZFlat0 579954 329812 -43.13% - Benchmark_ZFlat1 6564692 3504867 -46.61% - Benchmark_ZFlat2 902029 513700 -43.05% - Benchmark_ZFlat3 678722 384312 -43.38% - Benchmark_ZFlat4 1197389 654361 -45.35% - Benchmark_ZFlat5 262677 144939 -44.82% - Benchmark_ZFlat6 111249 60876 -45.28% - Benchmark_ZFlat7 39024 19420 -50.24% - Benchmark_ZFlat8 8046106 4387928 -45.47% - Benchmark_ZFlat9 2043167 1143139 -44.05% - Benchmark_ZFlat10 1781604 980528 -44.96% - Benchmark_ZFlat11 5478647 3078585 -43.81% - Benchmark_ZFlat12 7245995 3929863 -45.77% - Benchmark_ZFlat13 2432529 1371606 -43.61% - Benchmark_ZFlat14 420315 227494 -45.88% - Benchmark_ZFlat15 52378 26564 -49.28% - Benchmark_ZFlat16 567047 316196 -44.24% - Benchmark_ZFlat17 1630820 937310 -42.53% - - benchmark old MB/s new MB/s speedup - BenchmarkWordsDecode1e3 102.71 189.08 1.84x - BenchmarkWordsDecode1e4 99.77 180.60 1.81x - BenchmarkWordsDecode1e5 96.38 183.01 1.90x - BenchmarkWordsDecode1e6 104.61 187.43 1.79x - BenchmarkWordsEncode1e3 61.70 150.85 2.44x - BenchmarkWordsEncode1e4 71.28 136.68 1.92x - BenchmarkWordsEncode1e5 67.72 127.92 1.89x - BenchmarkWordsEncode1e6 78.73 142.90 1.82x - Benchmark_UFlat0 257.73 462.93 1.80x - Benchmark_UFlat1 180.46 349.59 1.94x - Benchmark_UFlat2 3545.30 8244.61 2.33x - Benchmark_UFlat3 669.72 1271.39 1.90x - Benchmark_UFlat4 502.84 959.74 1.91x - Benchmark_UFlat5 156.71 301.98 1.93x - Benchmark_UFlat6 143.60 258.33 1.80x - Benchmark_UFlat7 146.41 274.01 1.87x - Benchmark_UFlat8 161.59 301.72 1.87x - Benchmark_UFlat9 104.62 192.53 1.84x - Benchmark_UFlat10 100.70 189.45 1.88x - Benchmark_UFlat11 109.33 198.83 1.82x - Benchmark_UFlat12 94.37 178.72 1.89x - Benchmark_UFlat13 312.67 579.93 1.85x - Benchmark_UFlat14 145.84 291.52 2.00x - Benchmark_UFlat15 130.77 247.95 1.90x - Benchmark_UFlat16 323.14 578.82 1.79x - Benchmark_UFlat17 137.14 239.09 1.74x - Benchmark_ZFlat0 176.57 310.48 1.76x - Benchmark_ZFlat1 106.95 200.32 1.87x - Benchmark_ZFlat2 140.75 247.14 1.76x - Benchmark_ZFlat3 138.98 245.45 1.77x - Benchmark_ZFlat4 342.08 625.95 1.83x - Benchmark_ZFlat5 93.66 169.75 1.81x - Benchmark_ZFlat6 100.23 183.16 1.83x - Benchmark_ZFlat7 95.35 191.60 2.01x - Benchmark_ZFlat8 127.98 234.68 1.83x - Benchmark_ZFlat9 74.44 133.04 1.79x - Benchmark_ZFlat10 70.26 127.66 1.82x - Benchmark_ZFlat11 77.89 138.62 1.78x - Benchmark_ZFlat12 66.50 122.62 1.84x - Benchmark_ZFlat13 210.98 374.17 1.77x - Benchmark_ZFlat14 90.98 168.09 1.85x - Benchmark_ZFlat15 80.70 159.12 1.97x - Benchmark_ZFlat16 209.13 375.04 1.79x - Benchmark_ZFlat17 113.02 196.65 1.74x - $ - -Build tags - -If a constraint 'purego' appears in the build constraints [5] then a pure Go -version is built regardless of the $CGO_ENABLED value. - - $ touch zappy.go ; go install -tags purego github.com/cznic/zappy # for example - -Information sources - -... referenced from the above documentation. - - [1]: http://code.google.com/p/snappy-go/ - [2]: http://code.google.com/p/snappy/ - [3]: http://code.google.com/p/snappy/source/browse/trunk/format_description.txt - [4]: http://golang.org/pkg/encoding/binary/ - [5]: http://golang.org/pkg/go/build/#hdr-Build_Constraints -*/ -package zappy diff --git a/Godeps/_workspace/src/github.com/d2g/dhcp4/LICENSE b/Godeps/_workspace/src/github.com/d2g/dhcp4/LICENSE deleted file mode 100644 index f7d058a358..0000000000 --- a/Godeps/_workspace/src/github.com/d2g/dhcp4/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2013 Skagerrak Software Limited. 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 Skagerrak Software Limited 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. \ No newline at end of file diff --git a/Godeps/_workspace/src/github.com/d2g/dhcp4/README.md b/Godeps/_workspace/src/github.com/d2g/dhcp4/README.md deleted file mode 100644 index 6752dc71a2..0000000000 --- a/Godeps/_workspace/src/github.com/d2g/dhcp4/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# DHCP4 - A DHCP library written in Go. - -Warning: This library is still being developed. Function calls will change. - -I've removed Server Functionality, for me this project supports the underlying DHCP format not the implementation. diff --git a/Godeps/_workspace/src/github.com/d2g/dhcp4/constants.go b/Godeps/_workspace/src/github.com/d2g/dhcp4/constants.go deleted file mode 100644 index 183a778371..0000000000 --- a/Godeps/_workspace/src/github.com/d2g/dhcp4/constants.go +++ /dev/null @@ -1,121 +0,0 @@ -package dhcp4 - -// OpCodes -const ( - BootRequest OpCode = 1 // From Client - BootReply OpCode = 2 // From Server -) - -// DHCP Message Type 53 -const ( - Discover MessageType = 1 // Broadcast Packet From Client - Can I have an IP? - Offer MessageType = 2 // Broadcast From Server - Here's an IP - Request MessageType = 3 // Broadcast From Client - I'll take that IP (Also start for renewals) - Decline MessageType = 4 // Broadcast From Client - Sorry I can't use that IP - ACK MessageType = 5 // From Server, Yes you can have that IP - NAK MessageType = 6 // From Server, No you cannot have that IP - Release MessageType = 7 // From Client, I don't need that IP anymore - Inform MessageType = 8 // From Client, I have this IP and there's nothing you can do about it -) - -// DHCP Options -const ( - End OptionCode = 255 - Pad OptionCode = 0 - OptionSubnetMask OptionCode = 1 - OptionTimeOffset OptionCode = 2 - OptionRouter OptionCode = 3 - OptionTimeServer OptionCode = 4 - OptionNameServer OptionCode = 5 - OptionDomainNameServer OptionCode = 6 - OptionLogServer OptionCode = 7 - OptionCookieServer OptionCode = 8 - OptionLPRServer OptionCode = 9 - OptionImpressServer OptionCode = 10 - OptionResourceLocationServer OptionCode = 11 - OptionHostName OptionCode = 12 - OptionBootFileSize OptionCode = 13 - OptionMeritDumpFile OptionCode = 14 - OptionDomainName OptionCode = 15 - OptionSwapServer OptionCode = 16 - OptionRootPath OptionCode = 17 - OptionExtensionsPath OptionCode = 18 - - // IP Layer Parameters per Host - OptionIPForwardingEnableDisable OptionCode = 19 - OptionNonLocalSourceRoutingEnableDisable OptionCode = 20 - OptionPolicyFilter OptionCode = 21 - OptionMaximumDatagramReassemblySize OptionCode = 22 - OptionDefaultIPTimeToLive OptionCode = 23 - OptionPathMTUAgingTimeout OptionCode = 24 - OptionPathMTUPlateauTable OptionCode = 25 - - // IP Layer Parameters per Interface - OptionInterfaceMTU OptionCode = 26 - OptionAllSubnetsAreLocal OptionCode = 27 - OptionBroadcastAddress OptionCode = 28 - OptionPerformMaskDiscovery OptionCode = 29 - OptionMaskSupplier OptionCode = 30 - OptionPerformRouterDiscovery OptionCode = 31 - OptionRouterSolicitationAddress OptionCode = 32 - OptionStaticRoute OptionCode = 33 - - // Link Layer Parameters per Interface - OptionTrailerEncapsulation OptionCode = 34 - OptionARPCacheTimeout OptionCode = 35 - OptionEthernetEncapsulation OptionCode = 36 - - // TCP Parameters - OptionTCPDefaultTTL OptionCode = 37 - OptionTCPKeepaliveInterval OptionCode = 38 - OptionTCPKeepaliveGarbage OptionCode = 39 - - // Application and Service Parameters - OptionNetworkInformationServiceDomain OptionCode = 40 - OptionNetworkInformationServers OptionCode = 41 - OptionNetworkTimeProtocolServers OptionCode = 42 - OptionVendorSpecificInformation OptionCode = 43 - OptionNetBIOSOverTCPIPNameServer OptionCode = 44 - OptionNetBIOSOverTCPIPDatagramDistributionServer OptionCode = 45 - OptionNetBIOSOverTCPIPNodeType OptionCode = 46 - OptionNetBIOSOverTCPIPScope OptionCode = 47 - OptionXWindowSystemFontServer OptionCode = 48 - OptionXWindowSystemDisplayManager OptionCode = 49 - OptionNetworkInformationServicePlusDomain OptionCode = 64 - OptionNetworkInformationServicePlusServers OptionCode = 65 - OptionMobileIPHomeAgent OptionCode = 68 - OptionSimpleMailTransportProtocol OptionCode = 69 - OptionPostOfficeProtocolServer OptionCode = 70 - OptionNetworkNewsTransportProtocol OptionCode = 71 - OptionDefaultWorldWideWebServer OptionCode = 72 - OptionDefaultFingerServer OptionCode = 73 - OptionDefaultInternetRelayChatServer OptionCode = 74 - OptionStreetTalkServer OptionCode = 75 - OptionStreetTalkDirectoryAssistance OptionCode = 76 - - // DHCP Extensions - OptionRequestedIPAddress OptionCode = 50 - OptionIPAddressLeaseTime OptionCode = 51 - OptionOverload OptionCode = 52 - OptionDHCPMessageType OptionCode = 53 - OptionServerIdentifier OptionCode = 54 - OptionParameterRequestList OptionCode = 55 - OptionMessage OptionCode = 56 - OptionMaximumDHCPMessageSize OptionCode = 57 - OptionRenewalTimeValue OptionCode = 58 - OptionRebindingTimeValue OptionCode = 59 - OptionVendorClassIdentifier OptionCode = 60 - OptionClientIdentifier OptionCode = 61 - - OptionTFTPServerName OptionCode = 66 - OptionBootFileName OptionCode = 67 - - OptionUserClass OptionCode = 77 - - OptionClientArchitecture OptionCode = 93 - - OptionTZPOSIXString OptionCode = 100 - OptionTZDatabaseString OptionCode = 101 - - OptionClasslessRouteFormat OptionCode = 121 -) diff --git a/Godeps/_workspace/src/github.com/d2g/dhcp4/helpers.go b/Godeps/_workspace/src/github.com/d2g/dhcp4/helpers.go deleted file mode 100644 index 4b1463869f..0000000000 --- a/Godeps/_workspace/src/github.com/d2g/dhcp4/helpers.go +++ /dev/null @@ -1,58 +0,0 @@ -package dhcp4 - -import ( - "encoding/binary" - "net" - "time" -) - -// IPRange returns how many ips in the ip range from start to stop (inclusive) -func IPRange(start, stop net.IP) int { - //return int(Uint([]byte(stop))-Uint([]byte(start))) + 1 - return int(binary.BigEndian.Uint32(stop.To4())) - int(binary.BigEndian.Uint32(start.To4())) + 1 -} - -// IPAdd returns a copy of start + add. -// IPAdd(net.IP{192,168,1,1},30) returns net.IP{192.168.1.31} -func IPAdd(start net.IP, add int) net.IP { // IPv4 only - start = start.To4() - //v := Uvarint([]byte(start)) - result := make(net.IP, 4) - binary.BigEndian.PutUint32(result, binary.BigEndian.Uint32(start)+uint32(add)) - //PutUint([]byte(result), v+uint64(add)) - return result -} - -// IPLess returns where IP a is less than IP b. -func IPLess(a, b net.IP) bool { - b = b.To4() - for i, ai := range a.To4() { - if ai != b[i] { - return ai < b[i] - } - } - return false -} - -// IPInRange returns true if ip is between (inclusive) start and stop. -func IPInRange(start, stop, ip net.IP) bool { - return !(IPLess(ip, start) || IPLess(stop, ip)) -} - -// OptionsLeaseTime - converts a time.Duration to a 4 byte slice, compatible -// with OptionIPAddressLeaseTime. -func OptionsLeaseTime(d time.Duration) []byte { - leaseBytes := make([]byte, 4) - binary.BigEndian.PutUint32(leaseBytes, uint32(d/time.Second)) - //PutUvarint(leaseBytes, uint64(d/time.Second)) - return leaseBytes -} - -// JoinIPs returns a byte slice of IP addresses, one immediately after the other -// This may be useful for creating multiple IP options such as OptionRouter. -func JoinIPs(ips []net.IP) (b []byte) { - for _, v := range ips { - b = append(b, v.To4()...) - } - return -} diff --git a/Godeps/_workspace/src/github.com/d2g/dhcp4/option.go b/Godeps/_workspace/src/github.com/d2g/dhcp4/option.go deleted file mode 100644 index f3239e1980..0000000000 --- a/Godeps/_workspace/src/github.com/d2g/dhcp4/option.go +++ /dev/null @@ -1,40 +0,0 @@ -package dhcp4 - -type OptionCode byte - -type Option struct { - Code OptionCode - Value []byte -} - -// Map of DHCP options -type Options map[OptionCode][]byte - -// SelectOrderOrAll has same functionality as SelectOrder, except if the order -// param is nil, whereby all options are added (in arbitary order). -func (o Options) SelectOrderOrAll(order []byte) []Option { - if order == nil { - opts := make([]Option, 0, len(o)) - for i, v := range o { - opts = append(opts, Option{Code: i, Value: v}) - } - return opts - } - return o.SelectOrder(order) -} - -// SelectOrder returns a slice of options ordered and selected by a byte array -// usually defined by OptionParameterRequestList. This result is expected to be -// used in ReplyPacket()'s []Option parameter. -func (o Options) SelectOrder(order []byte) []Option { - opts := make([]Option, 0, len(order)) - for _, v := range order { - if data, ok := o[OptionCode(v)]; ok { - opts = append(opts, Option{Code: OptionCode(v), Value: data}) - } - } - return opts -} - -type OpCode byte -type MessageType byte // Option 53 diff --git a/Godeps/_workspace/src/github.com/d2g/dhcp4/packet.go b/Godeps/_workspace/src/github.com/d2g/dhcp4/packet.go deleted file mode 100644 index 5e547c86fa..0000000000 --- a/Godeps/_workspace/src/github.com/d2g/dhcp4/packet.go +++ /dev/null @@ -1,149 +0,0 @@ -package dhcp4 - -import ( - "net" - "time" -) - -// A DHCP packet -type Packet []byte - -func (p Packet) OpCode() OpCode { return OpCode(p[0]) } -func (p Packet) HType() byte { return p[1] } -func (p Packet) HLen() byte { return p[2] } -func (p Packet) Hops() byte { return p[3] } -func (p Packet) XId() []byte { return p[4:8] } -func (p Packet) Secs() []byte { return p[8:10] } // Never Used? -func (p Packet) Flags() []byte { return p[10:12] } -func (p Packet) CIAddr() net.IP { return net.IP(p[12:16]) } -func (p Packet) YIAddr() net.IP { return net.IP(p[16:20]) } -func (p Packet) SIAddr() net.IP { return net.IP(p[20:24]) } -func (p Packet) GIAddr() net.IP { return net.IP(p[24:28]) } -func (p Packet) CHAddr() net.HardwareAddr { - hLen := p.HLen() - if hLen > 16 { // Prevent chaddr exceeding p boundary - hLen = 16 - } - return net.HardwareAddr(p[28 : 28+hLen]) // max endPos 44 -} - -// 192 bytes of zeros BOOTP legacy -func (p Packet) Cookie() []byte { return p[236:240] } -func (p Packet) Options() []byte { - if len(p) > 240 { - return p[240:] - } - return nil -} - -func (p Packet) Broadcast() bool { return p.Flags()[0] > 127 } - -func (p Packet) SetBroadcast(broadcast bool) { - if p.Broadcast() != broadcast { - p.Flags()[0] ^= 128 - } -} - -func (p Packet) SetOpCode(c OpCode) { p[0] = byte(c) } -func (p Packet) SetCHAddr(a net.HardwareAddr) { - copy(p[28:44], a) - p[2] = byte(len(a)) -} -func (p Packet) SetHType(hType byte) { p[1] = hType } -func (p Packet) SetCookie(cookie []byte) { copy(p.Cookie(), cookie) } -func (p Packet) SetHops(hops byte) { p[3] = hops } -func (p Packet) SetXId(xId []byte) { copy(p.XId(), xId) } -func (p Packet) SetSecs(secs []byte) { copy(p.Secs(), secs) } -func (p Packet) SetFlags(flags []byte) { copy(p.Flags(), flags) } -func (p Packet) SetCIAddr(ip net.IP) { copy(p.CIAddr(), ip.To4()) } -func (p Packet) SetYIAddr(ip net.IP) { copy(p.YIAddr(), ip.To4()) } -func (p Packet) SetSIAddr(ip net.IP) { copy(p.SIAddr(), ip.To4()) } -func (p Packet) SetGIAddr(ip net.IP) { copy(p.GIAddr(), ip.To4()) } - -// Parses the packet's options into an Options map -func (p Packet) ParseOptions() Options { - opts := p.Options() - options := make(Options, 10) - for len(opts) >= 2 && OptionCode(opts[0]) != End { - if OptionCode(opts[0]) == Pad { - opts = opts[1:] - continue - } - size := int(opts[1]) - if len(opts) < 2+size { - break - } - options[OptionCode(opts[0])] = opts[2 : 2+size] - opts = opts[2+size:] - } - return options -} - -func NewPacket(opCode OpCode) Packet { - p := make(Packet, 241) - p.SetOpCode(opCode) - p.SetHType(1) // Ethernet - p.SetCookie([]byte{99, 130, 83, 99}) - p[240] = byte(End) - return p -} - -// Appends a DHCP option to the end of a packet -func (p *Packet) AddOption(o OptionCode, value []byte) { - *p = append((*p)[:len(*p)-1], []byte{byte(o), byte(len(value))}...) // Strip off End, Add OptionCode and Length - *p = append(*p, value...) // Add Option Value - *p = append(*p, byte(End)) // Add on new End -} - -// Removes all options from packet. -func (p *Packet) StripOptions() { - *p = append((*p)[:240], byte(End)) -} - -// Creates a request packet that a Client would send to a server. -func RequestPacket(mt MessageType, chAddr net.HardwareAddr, cIAddr net.IP, xId []byte, broadcast bool, options []Option) Packet { - p := NewPacket(BootRequest) - p.SetCHAddr(chAddr) - p.SetXId(xId) - if cIAddr != nil { - p.SetCIAddr(cIAddr) - } - p.SetBroadcast(broadcast) - p.AddOption(OptionDHCPMessageType, []byte{byte(mt)}) - for _, o := range options { - p.AddOption(o.Code, o.Value) - } - p.PadToMinSize() - return p -} - -// ReplyPacket creates a reply packet that a Server would send to a client. -// It uses the req Packet param to copy across common/necessary fields to -// associate the reply the request. -func ReplyPacket(req Packet, mt MessageType, serverId, yIAddr net.IP, leaseDuration time.Duration, options []Option) Packet { - p := NewPacket(BootReply) - p.SetXId(req.XId()) - p.SetFlags(req.Flags()) - p.SetYIAddr(yIAddr) - p.SetGIAddr(req.GIAddr()) - p.SetCHAddr(req.CHAddr()) - p.SetSecs(req.Secs()) - p.AddOption(OptionDHCPMessageType, []byte{byte(mt)}) - p.AddOption(OptionServerIdentifier, []byte(serverId)) - p.AddOption(OptionIPAddressLeaseTime, OptionsLeaseTime(leaseDuration)) - for _, o := range options { - p.AddOption(o.Code, o.Value) - } - p.PadToMinSize() - return p -} - -// PadToMinSize pads a packet so that when sent over UDP, the entire packet, -// is 300 bytes (BOOTP min), to be compatible with really old devices. -var padder [272]byte - -func (p *Packet) PadToMinSize() { - if n := len(*p); n < 272 { - *p = append(*p, padder[:272-n]...) - } -} diff --git a/Godeps/_workspace/src/github.com/d2g/dhcp4client/LICENSE b/Godeps/_workspace/src/github.com/d2g/dhcp4client/LICENSE deleted file mode 100644 index c33dcc7c92..0000000000 --- a/Godeps/_workspace/src/github.com/d2g/dhcp4client/LICENSE +++ /dev/null @@ -1,354 +0,0 @@ -Mozilla Public License, version 2.0 - -1. Definitions - -1.1. “Contributor” - - means each individual or legal entity that creates, contributes to the - creation of, or owns Covered Software. - -1.2. “Contributor Version” - - means the combination of the Contributions of others (if any) used by a - Contributor and that particular Contributor’s Contribution. - -1.3. “Contribution” - - means Covered Software of a particular Contributor. - -1.4. “Covered Software” - - means Source Code Form to which the initial Contributor has attached the - notice in Exhibit A, the Executable Form of such Source Code Form, and - Modifications of such Source Code Form, in each case including portions - thereof. - -1.5. “Incompatible With Secondary Licenses” - means - - a. that the initial Contributor has attached the notice described in - Exhibit B to the Covered Software; or - - b. that the Covered Software was made available under the terms of version - 1.1 or earlier of the License, but not also under the terms of a - Secondary License. - -1.6. “Executable Form” - - means any form of the work other than Source Code Form. - -1.7. “Larger Work” - - means a work that combines Covered Software with other material, in a separate - file or files, that is not Covered Software. - -1.8. “License” - - means this document. - -1.9. “Licensable” - - means having the right to grant, to the maximum extent possible, whether at the - time of the initial grant or subsequently, any and all of the rights conveyed by - this License. - -1.10. “Modifications” - - means any of the following: - - a. any file in Source Code Form that results from an addition to, deletion - from, or modification of the contents of Covered Software; or - - b. any new file in Source Code Form that contains any Covered Software. - -1.11. “Patent Claims” of a Contributor - - means any patent claim(s), including without limitation, method, process, - and apparatus claims, in any patent Licensable by such Contributor that - would be infringed, but for the grant of the License, by the making, - using, selling, offering for sale, having made, import, or transfer of - either its Contributions or its Contributor Version. - -1.12. “Secondary License” - - means either the GNU General Public License, Version 2.0, the GNU Lesser - General Public License, Version 2.1, the GNU Affero General Public - License, Version 3.0, or any later versions of those licenses. - -1.13. “Source Code Form” - - means the form of the work preferred for making modifications. - -1.14. “You” (or “Your”) - - means an individual or a legal entity exercising rights under this - License. For legal entities, “You” includes any entity that controls, is - controlled by, or is under common control with You. For purposes of this - definition, “control” means (a) the power, direct or indirect, to cause - the direction or management of such entity, whether by contract or - otherwise, or (b) ownership of more than fifty percent (50%) of the - outstanding shares or beneficial ownership of such entity. - - -2. License Grants and Conditions - -2.1. Grants - - Each Contributor hereby grants You a world-wide, royalty-free, - non-exclusive license: - - a. under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or as - part of a Larger Work; and - - b. under Patent Claims of such Contributor to make, use, sell, offer for - sale, have made, import, and otherwise transfer either its Contributions - or its Contributor Version. - -2.2. Effective Date - - The licenses granted in Section 2.1 with respect to any Contribution become - effective for each Contribution on the date the Contributor first distributes - such Contribution. - -2.3. Limitations on Grant Scope - - The licenses granted in this Section 2 are the only rights granted under this - License. No additional rights or licenses will be implied from the distribution - or licensing of Covered Software under this License. Notwithstanding Section - 2.1(b) above, no patent license is granted by a Contributor: - - a. for any code that a Contributor has removed from Covered Software; or - - b. for infringements caused by: (i) Your and any other third party’s - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - - c. under Patent Claims infringed by Covered Software in the absence of its - Contributions. - - This License does not grant any rights in the trademarks, service marks, or - logos of any Contributor (except as may be necessary to comply with the - notice requirements in Section 3.4). - -2.4. Subsequent Licenses - - No Contributor makes additional grants as a result of Your choice to - distribute the Covered Software under a subsequent version of this License - (see Section 10.2) or under the terms of a Secondary License (if permitted - under the terms of Section 3.3). - -2.5. Representation - - Each Contributor represents that the Contributor believes its Contributions - are its original creation(s) or it has sufficient rights to grant the - rights to its Contributions conveyed by this License. - -2.6. Fair Use - - This License is not intended to limit any rights You have under applicable - copyright doctrines of fair use, fair dealing, or other equivalents. - -2.7. Conditions - - Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in - Section 2.1. - - -3. Responsibilities - -3.1. Distribution of Source Form - - All distribution of Covered Software in Source Code Form, including any - Modifications that You create or to which You contribute, must be under the - terms of this License. You must inform recipients that the Source Code Form - of the Covered Software is governed by the terms of this License, and how - they can obtain a copy of this License. You may not attempt to alter or - restrict the recipients’ rights in the Source Code Form. - -3.2. Distribution of Executable Form - - If You distribute Covered Software in Executable Form then: - - a. such Covered Software must also be made available in Source Code Form, - as described in Section 3.1, and You must inform recipients of the - Executable Form how they can obtain a copy of such Source Code Form by - reasonable means in a timely manner, at a charge no more than the cost - of distribution to the recipient; and - - b. You may distribute such Executable Form under the terms of this License, - or sublicense it under different terms, provided that the license for - the Executable Form does not attempt to limit or alter the recipients’ - rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - - You may create and distribute a Larger Work under terms of Your choice, - provided that You also comply with the requirements of this License for the - Covered Software. If the Larger Work is a combination of Covered Software - with a work governed by one or more Secondary Licenses, and the Covered - Software is not Incompatible With Secondary Licenses, this License permits - You to additionally distribute such Covered Software under the terms of - such Secondary License(s), so that the recipient of the Larger Work may, at - their option, further distribute the Covered Software under the terms of - either this License or such Secondary License(s). - -3.4. Notices - - You may not remove or alter the substance of any license notices (including - copyright notices, patent notices, disclaimers of warranty, or limitations - of liability) contained within the Source Code Form of the Covered - Software, except that You may alter any license notices to the extent - required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - - You may choose to offer, and to charge a fee for, warranty, support, - indemnity or liability obligations to one or more recipients of Covered - Software. However, You may do so only on Your own behalf, and not on behalf - of any Contributor. You must make it absolutely clear that any such - warranty, support, indemnity, or liability obligation is offered by You - alone, and You hereby agree to indemnify every Contributor for any - liability incurred by such Contributor as a result of warranty, support, - indemnity or liability terms You offer. You may include additional - disclaimers of warranty and limitations of liability specific to any - jurisdiction. - -4. Inability to Comply Due to Statute or Regulation - - If it is impossible for You to comply with any of the terms of this License - with respect to some or all of the Covered Software due to statute, judicial - order, or regulation then You must: (a) comply with the terms of this License - to the maximum extent possible; and (b) describe the limitations and the code - they affect. Such description must be placed in a text file included with all - distributions of the Covered Software under this License. Except to the - extent prohibited by statute or regulation, such description must be - sufficiently detailed for a recipient of ordinary skill to be able to - understand it. - -5. Termination - -5.1. The rights granted under this License will terminate automatically if You - fail to comply with any of its terms. However, if You become compliant, - then the rights granted under this License from a particular Contributor - are reinstated (a) provisionally, unless and until such Contributor - explicitly and finally terminates Your grants, and (b) on an ongoing basis, - if such Contributor fails to notify You of the non-compliance by some - reasonable means prior to 60 days after You have come back into compliance. - Moreover, Your grants from a particular Contributor are reinstated on an - ongoing basis if such Contributor notifies You of the non-compliance by - some reasonable means, this is the first time You have received notice of - non-compliance with this License from such Contributor, and You become - compliant prior to 30 days after Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent - infringement claim (excluding declaratory judgment actions, counter-claims, - and cross-claims) alleging that a Contributor Version directly or - indirectly infringes any patent, then the rights granted to You by any and - all Contributors for the Covered Software under Section 2.1 of this License - shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user - license agreements (excluding distributors and resellers) which have been - validly granted by You or Your distributors under this License prior to - termination shall survive termination. - -6. Disclaimer of Warranty - - Covered Software is provided under this License on an “as is” basis, without - warranty of any kind, either expressed, implied, or statutory, including, - without limitation, warranties that the Covered Software is free of defects, - merchantable, fit for a particular purpose or non-infringing. The entire - risk as to the quality and performance of the Covered Software is with You. - Should any Covered Software prove defective in any respect, You (not any - Contributor) assume the cost of any necessary servicing, repair, or - correction. This disclaimer of warranty constitutes an essential part of this - License. No use of any Covered Software is authorized under this License - except under this disclaimer. - -7. Limitation of Liability - - Under no circumstances and under no legal theory, whether tort (including - negligence), contract, or otherwise, shall any Contributor, or anyone who - distributes Covered Software as permitted above, be liable to You for any - direct, indirect, special, incidental, or consequential damages of any - character including, without limitation, damages for lost profits, loss of - goodwill, work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses, even if such party shall have been - informed of the possibility of such damages. This limitation of liability - shall not apply to liability for death or personal injury resulting from such - party’s negligence to the extent applicable law prohibits such limitation. - Some jurisdictions do not allow the exclusion or limitation of incidental or - consequential damages, so this exclusion and limitation may not apply to You. - -8. Litigation - - Any litigation relating to this License may be brought only in the courts of - a jurisdiction where the defendant maintains its principal place of business - and such litigation shall be governed by laws of that jurisdiction, without - reference to its conflict-of-law provisions. Nothing in this Section shall - prevent a party’s ability to bring cross-claims or counter-claims. - -9. Miscellaneous - - This License represents the complete agreement concerning the subject matter - hereof. If any provision of this License is held to be unenforceable, such - provision shall be reformed only to the extent necessary to make it - enforceable. Any law or regulation which provides that the language of a - contract shall be construed against the drafter shall not be used to construe - this License against a Contributor. - - -10. Versions of the License - -10.1. New Versions - - Mozilla Foundation is the license steward. Except as provided in Section - 10.3, no one other than the license steward has the right to modify or - publish new versions of this License. Each version will be given a - distinguishing version number. - -10.2. Effect of New Versions - - You may distribute the Covered Software under the terms of the version of - the License under which You originally received the Covered Software, or - under the terms of any subsequent version published by the license - steward. - -10.3. Modified Versions - - If you create software not governed by this License, and you want to - create a new license for such software, you may create and use a modified - version of this License if you rename the license and remove any - references to the name of the license steward (except to note that such - modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses - If You choose to distribute Source Code Form that is Incompatible With - Secondary Licenses under the terms of this version of the License, the - notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice - - This Source Code Form is subject to the - terms of the Mozilla Public License, v. - 2.0. If a copy of the MPL was not - distributed with this file, You can - obtain one at - http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular file, then -You may include the notice in a location (such as a LICENSE file in a relevant -directory) where a recipient would be likely to look for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - “Incompatible With Secondary Licenses” Notice - - This Source Code Form is “Incompatible - With Secondary Licenses”, as defined by - the Mozilla Public License, v. 2.0. - diff --git a/Godeps/_workspace/src/github.com/d2g/dhcp4client/README.md b/Godeps/_workspace/src/github.com/d2g/dhcp4client/README.md deleted file mode 100644 index 785ac2c1df..0000000000 --- a/Godeps/_workspace/src/github.com/d2g/dhcp4client/README.md +++ /dev/null @@ -1,8 +0,0 @@ -dhcp4client [![GoDoc](https://godoc.org/github.com/d2g/dhcp4client?status.svg)](http://godoc.org/github.com/d2g/dhcp4client) [![Coverage Status](https://coveralls.io/repos/d2g/dhcp4client/badge.svg?branch=HEAD)](https://coveralls.io/r/d2g/dhcp4client?branch=HEAD) [![Codeship Status for d2g/dhcp4client](https://codeship.com/projects/d75d9860-b364-0132-bc79-7e1d8cf367b9/status?branch=master)](https://codeship.com/projects/70187) -=========== - -DHCP Client - - -###### Thanks to: -@eyakubovich For AF_PACKET support. diff --git a/Godeps/_workspace/src/github.com/d2g/dhcp4client/client.go b/Godeps/_workspace/src/github.com/d2g/dhcp4client/client.go deleted file mode 100644 index ab852c650e..0000000000 --- a/Godeps/_workspace/src/github.com/d2g/dhcp4client/client.go +++ /dev/null @@ -1,366 +0,0 @@ -package dhcp4client - -import ( - "bytes" - "crypto/rand" - "net" - "time" - - "github.com/d2g/dhcp4" -) - -const ( - MaxDHCPLen = 576 -) - -type Client struct { - hardwareAddr net.HardwareAddr //The HardwareAddr to send in the request. - ignoreServers []net.IP //List of Servers to Ignore requests from. - timeout time.Duration //Time before we timeout. - broadcast bool //Set the Bcast flag in BOOTP Flags - connection connection //The Connection Method to use -} - -/* - * Abstracts the type of underlying socket used - */ -type connection interface { - Close() error - Write(packet []byte) error - ReadFrom() ([]byte, net.IP, error) - SetReadTimeout(t time.Duration) error -} - -func New(options ...func(*Client) error) (*Client, error) { - c := Client{ - timeout: time.Second * 10, - broadcast: true, - } - - err := c.SetOption(options...) - if err != nil { - return nil, err - } - - //if connection hasn't been set as an option create the default. - if c.connection == nil { - conn, err := NewInetSock() - if err != nil { - return nil, err - } - c.connection = conn - } - - return &c, nil -} - -func (c *Client) SetOption(options ...func(*Client) error) error { - for _, opt := range options { - if err := opt(c); err != nil { - return err - } - } - return nil -} - -func Timeout(t time.Duration) func(*Client) error { - return func(c *Client) error { - c.timeout = t - return nil - } -} - -func IgnoreServers(s []net.IP) func(*Client) error { - return func(c *Client) error { - c.ignoreServers = s - return nil - } -} - -func HardwareAddr(h net.HardwareAddr) func(*Client) error { - return func(c *Client) error { - c.hardwareAddr = h - return nil - } -} - -func Broadcast(b bool) func(*Client) error { - return func(c *Client) error { - c.broadcast = b - return nil - } -} - -func Connection(conn connection) func(*Client) error { - return func(c *Client) error { - c.connection = conn - return nil - } -} - -/* - * Close Connections - */ -func (c *Client) Close() error { - if c.connection != nil { - return c.connection.Close() - } - return nil -} - -/* - * Send the Discovery Packet to the Broadcast Channel - */ -func (c *Client) SendDiscoverPacket() (dhcp4.Packet, error) { - discoveryPacket := c.DiscoverPacket() - discoveryPacket.PadToMinSize() - - return discoveryPacket, c.SendPacket(discoveryPacket) -} - -/* - * Retreive Offer... - * Wait for the offer for a specific Discovery Packet. - */ -func (c *Client) GetOffer(discoverPacket *dhcp4.Packet) (dhcp4.Packet, error) { - for { - c.connection.SetReadTimeout(c.timeout) - readBuffer, source, err := c.connection.ReadFrom() - if err != nil { - return dhcp4.Packet{}, err - } - - offerPacket := dhcp4.Packet(readBuffer) - offerPacketOptions := offerPacket.ParseOptions() - - // Ignore Servers in my Ignore list - for _, ignoreServer := range c.ignoreServers { - if source.Equal(ignoreServer) { - continue - } - - if offerPacket.SIAddr().Equal(ignoreServer) { - continue - } - } - - if len(offerPacketOptions[dhcp4.OptionDHCPMessageType]) < 1 || dhcp4.MessageType(offerPacketOptions[dhcp4.OptionDHCPMessageType][0]) != dhcp4.Offer || !bytes.Equal(discoverPacket.XId(), offerPacket.XId()) { - continue - } - - return offerPacket, nil - } - -} - -/* - * Send Request Based On the offer Received. - */ -func (c *Client) SendRequest(offerPacket *dhcp4.Packet) (dhcp4.Packet, error) { - requestPacket := c.RequestPacket(offerPacket) - requestPacket.PadToMinSize() - - return requestPacket, c.SendPacket(requestPacket) -} - -/* - * Retreive Acknowledgement - * Wait for the offer for a specific Request Packet. - */ -func (c *Client) GetAcknowledgement(requestPacket *dhcp4.Packet) (dhcp4.Packet, error) { - for { - c.connection.SetReadTimeout(c.timeout) - readBuffer, source, err := c.connection.ReadFrom() - if err != nil { - return dhcp4.Packet{}, err - } - - acknowledgementPacket := dhcp4.Packet(readBuffer) - acknowledgementPacketOptions := acknowledgementPacket.ParseOptions() - - // Ignore Servers in my Ignore list - for _, ignoreServer := range c.ignoreServers { - if source.Equal(ignoreServer) { - continue - } - - if acknowledgementPacket.SIAddr().Equal(ignoreServer) { - continue - } - } - - if !bytes.Equal(requestPacket.XId(), acknowledgementPacket.XId()) || len(acknowledgementPacketOptions[dhcp4.OptionDHCPMessageType]) < 1 || (dhcp4.MessageType(acknowledgementPacketOptions[dhcp4.OptionDHCPMessageType][0]) != dhcp4.ACK && dhcp4.MessageType(acknowledgementPacketOptions[dhcp4.OptionDHCPMessageType][0]) != dhcp4.NAK) { - continue - } - - return acknowledgementPacket, nil - } -} - -/* - * Send a DHCP Packet. - */ -func (c *Client) SendPacket(packet dhcp4.Packet) error { - return c.connection.Write(packet) -} - -/* - * Create Discover Packet - */ -func (c *Client) DiscoverPacket() dhcp4.Packet { - messageid := make([]byte, 4) - if _, err := rand.Read(messageid); err != nil { - panic(err) - } - - packet := dhcp4.NewPacket(dhcp4.BootRequest) - packet.SetCHAddr(c.hardwareAddr) - packet.SetXId(messageid) - packet.SetBroadcast(c.broadcast) - - packet.AddOption(dhcp4.OptionDHCPMessageType, []byte{byte(dhcp4.Discover)}) - //packet.PadToMinSize() - return packet -} - -/* - * Create Request Packet - */ -func (c *Client) RequestPacket(offerPacket *dhcp4.Packet) dhcp4.Packet { - offerOptions := offerPacket.ParseOptions() - - packet := dhcp4.NewPacket(dhcp4.BootRequest) - packet.SetCHAddr(c.hardwareAddr) - - packet.SetXId(offerPacket.XId()) - packet.SetCIAddr(offerPacket.CIAddr()) - packet.SetSIAddr(offerPacket.SIAddr()) - - packet.SetBroadcast(c.broadcast) - packet.AddOption(dhcp4.OptionDHCPMessageType, []byte{byte(dhcp4.Request)}) - packet.AddOption(dhcp4.OptionRequestedIPAddress, (offerPacket.YIAddr()).To4()) - packet.AddOption(dhcp4.OptionServerIdentifier, offerOptions[dhcp4.OptionServerIdentifier]) - - //packet.PadToMinSize() - return packet -} - -/* - * Create Request Packet For a Renew - */ -func (c *Client) RenewalRequestPacket(acknowledgement *dhcp4.Packet) dhcp4.Packet { - messageid := make([]byte, 4) - if _, err := rand.Read(messageid); err != nil { - panic(err) - } - - acknowledgementOptions := acknowledgement.ParseOptions() - - packet := dhcp4.NewPacket(dhcp4.BootRequest) - packet.SetCHAddr(acknowledgement.CHAddr()) - - packet.SetXId(messageid) - packet.SetCIAddr(acknowledgement.YIAddr()) - packet.SetSIAddr(acknowledgement.SIAddr()) - - packet.SetBroadcast(c.broadcast) - packet.AddOption(dhcp4.OptionDHCPMessageType, []byte{byte(dhcp4.Request)}) - packet.AddOption(dhcp4.OptionRequestedIPAddress, (acknowledgement.YIAddr()).To4()) - packet.AddOption(dhcp4.OptionServerIdentifier, acknowledgementOptions[dhcp4.OptionServerIdentifier]) - - //packet.PadToMinSize() - return packet -} - -/* - * Create Release Packet For a Release - */ -func (c *Client) ReleasePacket(acknowledgement *dhcp4.Packet) dhcp4.Packet { - messageid := make([]byte, 4) - if _, err := rand.Read(messageid); err != nil { - panic(err) - } - - acknowledgementOptions := acknowledgement.ParseOptions() - - packet := dhcp4.NewPacket(dhcp4.BootRequest) - packet.SetCHAddr(acknowledgement.CHAddr()) - - packet.SetXId(messageid) - packet.SetCIAddr(acknowledgement.YIAddr()) - - packet.AddOption(dhcp4.OptionDHCPMessageType, []byte{byte(dhcp4.Release)}) - packet.AddOption(dhcp4.OptionServerIdentifier, acknowledgementOptions[dhcp4.OptionServerIdentifier]) - - //packet.PadToMinSize() - return packet -} - -/* - * Lets do a Full DHCP Request. - */ -func (c *Client) Request() (bool, dhcp4.Packet, error) { - discoveryPacket, err := c.SendDiscoverPacket() - if err != nil { - return false, discoveryPacket, err - } - - offerPacket, err := c.GetOffer(&discoveryPacket) - if err != nil { - return false, offerPacket, err - } - - requestPacket, err := c.SendRequest(&offerPacket) - if err != nil { - return false, requestPacket, err - } - - acknowledgement, err := c.GetAcknowledgement(&requestPacket) - if err != nil { - return false, acknowledgement, err - } - - acknowledgementOptions := acknowledgement.ParseOptions() - if dhcp4.MessageType(acknowledgementOptions[dhcp4.OptionDHCPMessageType][0]) != dhcp4.ACK { - return false, acknowledgement, nil - } - - return true, acknowledgement, nil -} - -/* - * Renew a lease backed on the Acknowledgement Packet. - * Returns Sucessfull, The AcknoledgementPacket, Any Errors - */ -func (c *Client) Renew(acknowledgement dhcp4.Packet) (bool, dhcp4.Packet, error) { - renewRequest := c.RenewalRequestPacket(&acknowledgement) - renewRequest.PadToMinSize() - - err := c.SendPacket(renewRequest) - if err != nil { - return false, renewRequest, err - } - - newAcknowledgement, err := c.GetAcknowledgement(&renewRequest) - if err != nil { - return false, newAcknowledgement, err - } - - newAcknowledgementOptions := newAcknowledgement.ParseOptions() - if dhcp4.MessageType(newAcknowledgementOptions[dhcp4.OptionDHCPMessageType][0]) != dhcp4.ACK { - return false, newAcknowledgement, nil - } - - return true, newAcknowledgement, nil -} - -/* - * Release a lease backed on the Acknowledgement Packet. - * Returns Any Errors - */ -func (c *Client) Release(acknowledgement dhcp4.Packet) error { - release := c.ReleasePacket(&acknowledgement) - release.PadToMinSize() - - return c.SendPacket(release) -} diff --git a/Godeps/_workspace/src/github.com/d2g/dhcp4client/inetsock.go b/Godeps/_workspace/src/github.com/d2g/dhcp4client/inetsock.go deleted file mode 100644 index 293f186538..0000000000 --- a/Godeps/_workspace/src/github.com/d2g/dhcp4client/inetsock.go +++ /dev/null @@ -1,75 +0,0 @@ -package dhcp4client - -import ( - "net" - "time" -) - -type inetSock struct { - *net.UDPConn - - laddr net.UDPAddr - raddr net.UDPAddr -} - -func NewInetSock(options ...func(*inetSock) error) (*inetSock, error) { - c := &inetSock{ - laddr: net.UDPAddr{IP: net.IPv4(0, 0, 0, 0), Port: 68}, - raddr: net.UDPAddr{IP: net.IPv4bcast, Port: 67}, - } - - err := c.setOption(options...) - if err != nil { - return nil, err - } - - conn, err := net.ListenUDP("udp4", &c.laddr) - if err != nil { - return nil, err - } - - c.UDPConn = conn - return c, err -} - -func (c *inetSock) setOption(options ...func(*inetSock) error) error { - for _, opt := range options { - if err := opt(c); err != nil { - return err - } - } - return nil -} - -func SetLocalAddr(l net.UDPAddr) func(*inetSock) error { - return func(c *inetSock) error { - c.laddr = l - return nil - } -} - -func SetRemoteAddr(r net.UDPAddr) func(*inetSock) error { - return func(c *inetSock) error { - c.raddr = r - return nil - } -} - -func (c *inetSock) Write(packet []byte) error { - _, err := c.WriteToUDP(packet, &c.raddr) - return err -} - -func (c *inetSock) ReadFrom() ([]byte, net.IP, error) { - readBuffer := make([]byte, MaxDHCPLen) - n, source, err := c.ReadFromUDP(readBuffer) - if source != nil { - return readBuffer[:n], source.IP, err - } else { - return readBuffer[:n], net.IP{}, err - } -} - -func (c *inetSock) SetReadTimeout(t time.Duration) error { - return c.SetReadDeadline(time.Now().Add(t)) -} diff --git a/Godeps/_workspace/src/github.com/d2g/dhcp4client/init.go b/Godeps/_workspace/src/github.com/d2g/dhcp4client/init.go deleted file mode 100644 index 67ae8a3a13..0000000000 --- a/Godeps/_workspace/src/github.com/d2g/dhcp4client/init.go +++ /dev/null @@ -1,10 +0,0 @@ -package dhcp4client - -import ( - "math/rand" - "time" -) - -func init() { - rand.Seed(time.Now().Unix()) -} diff --git a/Godeps/_workspace/src/github.com/d2g/dhcp4client/pktsock_linux.go b/Godeps/_workspace/src/github.com/d2g/dhcp4client/pktsock_linux.go deleted file mode 100644 index a21c265fb4..0000000000 --- a/Godeps/_workspace/src/github.com/d2g/dhcp4client/pktsock_linux.go +++ /dev/null @@ -1,147 +0,0 @@ -package dhcp4client - -import ( - "crypto/rand" - "encoding/binary" - "net" - "time" - - "golang.org/x/sys/unix" -) - -const ( - minIPHdrLen = 20 - maxIPHdrLen = 60 - udpHdrLen = 8 - ip4Ver = 0x40 - ttl = 16 - srcPort = 68 - dstPort = 67 -) - -var ( - bcastMAC = []byte{255, 255, 255, 255, 255, 255} -) - -// abstracts AF_PACKET -type packetSock struct { - fd int - ifindex int -} - -func NewPacketSock(ifindex int) (*packetSock, error) { - fd, err := unix.Socket(unix.AF_PACKET, unix.SOCK_DGRAM, int(swap16(unix.ETH_P_IP))) - if err != nil { - return nil, err - } - - addr := unix.SockaddrLinklayer{ - Ifindex: ifindex, - Protocol: swap16(unix.ETH_P_IP), - } - - if err = unix.Bind(fd, &addr); err != nil { - return nil, err - } - - return &packetSock{ - fd: fd, - ifindex: ifindex, - }, nil -} - -func (pc *packetSock) Close() error { - return unix.Close(pc.fd) -} - -func (pc *packetSock) Write(packet []byte) error { - lladdr := unix.SockaddrLinklayer{ - Ifindex: pc.ifindex, - Protocol: swap16(unix.ETH_P_IP), - Halen: uint8(len(bcastMAC)), - } - copy(lladdr.Addr[:], bcastMAC) - - pkt := make([]byte, minIPHdrLen+udpHdrLen+len(packet)) - - fillIPHdr(pkt[0:minIPHdrLen], udpHdrLen+uint16(len(packet))) - fillUDPHdr(pkt[minIPHdrLen:minIPHdrLen+udpHdrLen], uint16(len(packet))) - - // payload - copy(pkt[minIPHdrLen+udpHdrLen:len(pkt)], packet) - - return unix.Sendto(pc.fd, pkt, 0, &lladdr) -} - -func (pc *packetSock) ReadFrom() ([]byte, net.IP, error) { - pkt := make([]byte, maxIPHdrLen+udpHdrLen+MaxDHCPLen) - n, _, err := unix.Recvfrom(pc.fd, pkt, 0) - if err != nil { - return nil, nil, err - } - - // IP hdr len - ihl := int(pkt[0]&0x0F) * 4 - // Source IP address - src := net.IP(pkt[12:16]) - - return pkt[ihl+udpHdrLen : n], src, nil -} - -func (pc *packetSock) SetReadTimeout(t time.Duration) error { - - tv := unix.NsecToTimeval(t.Nanoseconds()) - return unix.SetsockoptTimeval(pc.fd, unix.SOL_SOCKET, unix.SO_RCVTIMEO, &tv) -} - -// compute's 1's complement checksum -func chksum(p []byte, csum []byte) { - cklen := len(p) - s := uint32(0) - for i := 0; i < (cklen - 1); i += 2 { - s += uint32(p[i+1])<<8 | uint32(p[i]) - } - if cklen&1 == 1 { - s += uint32(p[cklen-1]) - } - s = (s >> 16) + (s & 0xffff) - s = s + (s >> 16) - s = ^s - - csum[0] = uint8(s & 0xff) - csum[1] = uint8(s >> 8) -} - -func fillIPHdr(hdr []byte, payloadLen uint16) { - // version + IHL - hdr[0] = ip4Ver | (minIPHdrLen / 4) - // total length - binary.BigEndian.PutUint16(hdr[2:4], uint16(len(hdr))+payloadLen) - // identification - if _, err := rand.Read(hdr[4:5]); err != nil { - panic(err) - } - // TTL - hdr[8] = 16 - // Protocol - hdr[9] = unix.IPPROTO_UDP - // dst IP - copy(hdr[16:20], net.IPv4bcast.To4()) - // compute IP hdr checksum - chksum(hdr[0:len(hdr)], hdr[10:12]) -} - -func fillUDPHdr(hdr []byte, payloadLen uint16) { - // src port - binary.BigEndian.PutUint16(hdr[0:2], srcPort) - // dest port - binary.BigEndian.PutUint16(hdr[2:4], dstPort) - // length - binary.BigEndian.PutUint16(hdr[4:6], udpHdrLen+payloadLen) -} - -func swap16(x uint16) uint16 { - var b [2]byte - binary.BigEndian.PutUint16(b[:], x) - return binary.LittleEndian.Uint16(b[:]) -} diff --git a/Godeps/_workspace/src/github.com/docker/distribution/LICENSE b/Godeps/_workspace/src/github.com/docker/distribution/LICENSE deleted file mode 100644 index e06d208186..0000000000 --- a/Godeps/_workspace/src/github.com/docker/distribution/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor 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, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - diff --git a/Godeps/_workspace/src/github.com/docker/distribution/digest/digest.go b/Godeps/_workspace/src/github.com/docker/distribution/digest/digest.go deleted file mode 100644 index 31d821bba7..0000000000 --- a/Godeps/_workspace/src/github.com/docker/distribution/digest/digest.go +++ /dev/null @@ -1,139 +0,0 @@ -package digest - -import ( - "fmt" - "hash" - "io" - "regexp" - "strings" -) - -const ( - // DigestSha256EmptyTar is the canonical sha256 digest of empty data - DigestSha256EmptyTar = "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" -) - -// Digest allows simple protection of hex formatted digest strings, prefixed -// by their algorithm. Strings of type Digest have some guarantee of being in -// the correct format and it provides quick access to the components of a -// digest string. -// -// The following is an example of the contents of Digest types: -// -// sha256:7173b809ca12ec5dee4506cd86be934c4596dd234ee82c0662eac04a8c2c71dc -// -// This allows to abstract the digest behind this type and work only in those -// terms. -type Digest string - -// NewDigest returns a Digest from alg and a hash.Hash object. -func NewDigest(alg Algorithm, h hash.Hash) Digest { - return NewDigestFromBytes(alg, h.Sum(nil)) -} - -// NewDigestFromBytes returns a new digest from the byte contents of p. -// Typically, this can come from hash.Hash.Sum(...) or xxx.SumXXX(...) -// functions. This is also useful for rebuilding digests from binary -// serializations. -func NewDigestFromBytes(alg Algorithm, p []byte) Digest { - return Digest(fmt.Sprintf("%s:%x", alg, p)) -} - -// NewDigestFromHex returns a Digest from alg and a the hex encoded digest. -func NewDigestFromHex(alg, hex string) Digest { - return Digest(fmt.Sprintf("%s:%s", alg, hex)) -} - -// DigestRegexp matches valid digest types. -var DigestRegexp = regexp.MustCompile(`[a-zA-Z0-9-_+.]+:[a-fA-F0-9]+`) - -// DigestRegexpAnchored matches valid digest types, anchored to the start and end of the match. -var DigestRegexpAnchored = regexp.MustCompile(`^` + DigestRegexp.String() + `$`) - -var ( - // ErrDigestInvalidFormat returned when digest format invalid. - ErrDigestInvalidFormat = fmt.Errorf("invalid checksum digest format") - - // ErrDigestInvalidLength returned when digest has invalid length. - ErrDigestInvalidLength = fmt.Errorf("invalid checksum digest length") - - // ErrDigestUnsupported returned when the digest algorithm is unsupported. - ErrDigestUnsupported = fmt.Errorf("unsupported digest algorithm") -) - -// ParseDigest parses s and returns the validated digest object. An error will -// be returned if the format is invalid. -func ParseDigest(s string) (Digest, error) { - d := Digest(s) - - return d, d.Validate() -} - -// FromReader returns the most valid digest for the underlying content using -// the canonical digest algorithm. -func FromReader(rd io.Reader) (Digest, error) { - return Canonical.FromReader(rd) -} - -// FromBytes digests the input and returns a Digest. -func FromBytes(p []byte) Digest { - return Canonical.FromBytes(p) -} - -// Validate checks that the contents of d is a valid digest, returning an -// error if not. -func (d Digest) Validate() error { - s := string(d) - - if !DigestRegexpAnchored.MatchString(s) { - return ErrDigestInvalidFormat - } - - i := strings.Index(s, ":") - if i < 0 { - return ErrDigestInvalidFormat - } - - // case: "sha256:" with no hex. - if i+1 == len(s) { - return ErrDigestInvalidFormat - } - - switch algorithm := Algorithm(s[:i]); algorithm { - case SHA256, SHA384, SHA512: - if algorithm.Size()*2 != len(s[i+1:]) { - return ErrDigestInvalidLength - } - break - default: - return ErrDigestUnsupported - } - - return nil -} - -// Algorithm returns the algorithm portion of the digest. This will panic if -// the underlying digest is not in a valid format. -func (d Digest) Algorithm() Algorithm { - return Algorithm(d[:d.sepIndex()]) -} - -// Hex returns the hex digest portion of the digest. This will panic if the -// underlying digest is not in a valid format. -func (d Digest) Hex() string { - return string(d[d.sepIndex()+1:]) -} - -func (d Digest) String() string { - return string(d) -} - -func (d Digest) sepIndex() int { - i := strings.Index(string(d), ":") - - if i < 0 { - panic("could not find ':' in digest: " + d) - } - - return i -} diff --git a/Godeps/_workspace/src/github.com/docker/distribution/digest/digester.go b/Godeps/_workspace/src/github.com/docker/distribution/digest/digester.go deleted file mode 100644 index f3105a45b6..0000000000 --- a/Godeps/_workspace/src/github.com/docker/distribution/digest/digester.go +++ /dev/null @@ -1,155 +0,0 @@ -package digest - -import ( - "crypto" - "fmt" - "hash" - "io" -) - -// Algorithm identifies and implementation of a digester by an identifier. -// Note the that this defines both the hash algorithm used and the string -// encoding. -type Algorithm string - -// supported digest types -const ( - SHA256 Algorithm = "sha256" // sha256 with hex encoding - SHA384 Algorithm = "sha384" // sha384 with hex encoding - SHA512 Algorithm = "sha512" // sha512 with hex encoding - - // Canonical is the primary digest algorithm used with the distribution - // project. Other digests may be used but this one is the primary storage - // digest. - Canonical = SHA256 -) - -var ( - // TODO(stevvooe): Follow the pattern of the standard crypto package for - // registration of digests. Effectively, we are a registerable set and - // common symbol access. - - // algorithms maps values to hash.Hash implementations. Other algorithms - // may be available but they cannot be calculated by the digest package. - algorithms = map[Algorithm]crypto.Hash{ - SHA256: crypto.SHA256, - SHA384: crypto.SHA384, - SHA512: crypto.SHA512, - } -) - -// Available returns true if the digest type is available for use. If this -// returns false, New and Hash will return nil. -func (a Algorithm) Available() bool { - h, ok := algorithms[a] - if !ok { - return false - } - - // check availability of the hash, as well - return h.Available() -} - -func (a Algorithm) String() string { - return string(a) -} - -// Size returns number of bytes returned by the hash. -func (a Algorithm) Size() int { - h, ok := algorithms[a] - if !ok { - return 0 - } - return h.Size() -} - -// Set implemented to allow use of Algorithm as a command line flag. -func (a *Algorithm) Set(value string) error { - if value == "" { - *a = Canonical - } else { - // just do a type conversion, support is queried with Available. - *a = Algorithm(value) - } - - return nil -} - -// New returns a new digester for the specified algorithm. If the algorithm -// does not have a digester implementation, nil will be returned. This can be -// checked by calling Available before calling New. -func (a Algorithm) New() Digester { - return &digester{ - alg: a, - hash: a.Hash(), - } -} - -// Hash returns a new hash as used by the algorithm. If not available, the -// method will panic. Check Algorithm.Available() before calling. -func (a Algorithm) Hash() hash.Hash { - if !a.Available() { - // NOTE(stevvooe): A missing hash is usually a programming error that - // must be resolved at compile time. We don't import in the digest - // package to allow users to choose their hash implementation (such as - // when using stevvooe/resumable or a hardware accelerated package). - // - // Applications that may want to resolve the hash at runtime should - // call Algorithm.Available before call Algorithm.Hash(). - panic(fmt.Sprintf("%v not available (make sure it is imported)", a)) - } - - return algorithms[a].New() -} - -// FromReader returns the digest of the reader using the algorithm. -func (a Algorithm) FromReader(rd io.Reader) (Digest, error) { - digester := a.New() - - if _, err := io.Copy(digester.Hash(), rd); err != nil { - return "", err - } - - return digester.Digest(), nil -} - -// FromBytes digests the input and returns a Digest. -func (a Algorithm) FromBytes(p []byte) Digest { - digester := a.New() - - if _, err := digester.Hash().Write(p); err != nil { - // Writes to a Hash should never fail. None of the existing - // hash implementations in the stdlib or hashes vendored - // here can return errors from Write. Having a panic in this - // condition instead of having FromBytes return an error value - // avoids unnecessary error handling paths in all callers. - panic("write to hash function returned error: " + err.Error()) - } - - return digester.Digest() -} - -// TODO(stevvooe): Allow resolution of verifiers using the digest type and -// this registration system. - -// Digester calculates the digest of written data. Writes should go directly -// to the return value of Hash, while calling Digest will return the current -// value of the digest. -type Digester interface { - Hash() hash.Hash // provides direct access to underlying hash instance. - Digest() Digest -} - -// digester provides a simple digester definition that embeds a hasher. -type digester struct { - alg Algorithm - hash hash.Hash -} - -func (d *digester) Hash() hash.Hash { - return d.hash -} - -func (d *digester) Digest() Digest { - return NewDigest(d.alg, d.hash) -} diff --git a/Godeps/_workspace/src/github.com/docker/distribution/digest/doc.go b/Godeps/_workspace/src/github.com/docker/distribution/digest/doc.go deleted file mode 100644 index f64b0db32b..0000000000 --- a/Godeps/_workspace/src/github.com/docker/distribution/digest/doc.go +++ /dev/null @@ -1,42 +0,0 @@ -// Package digest provides a generalized type to opaquely represent message -// digests and their operations within the registry. The Digest type is -// designed to serve as a flexible identifier in a content-addressable system. -// More importantly, it provides tools and wrappers to work with -// hash.Hash-based digests with little effort. -// -// Basics -// -// The format of a digest is simply a string with two parts, dubbed the -// "algorithm" and the "digest", separated by a colon: -// -// : -// -// An example of a sha256 digest representation follows: -// -// sha256:7173b809ca12ec5dee4506cd86be934c4596dd234ee82c0662eac04a8c2c71dc -// -// In this case, the string "sha256" is the algorithm and the hex bytes are -// the "digest". -// -// Because the Digest type is simply a string, once a valid Digest is -// obtained, comparisons are cheap, quick and simple to express with the -// standard equality operator. -// -// Verification -// -// The main benefit of using the Digest type is simple verification against a -// given digest. The Verifier interface, modeled after the stdlib hash.Hash -// interface, provides a common write sink for digest verification. After -// writing is complete, calling the Verifier.Verified method will indicate -// whether or not the stream of bytes matches the target digest. -// -// Missing Features -// -// In addition to the above, we intend to add the following features to this -// package: -// -// 1. A Digester type that supports write sink digest calculation. -// -// 2. Suspend and resume of ongoing digest calculations to support efficient digest verification in the registry. -// -package digest diff --git a/Godeps/_workspace/src/github.com/docker/distribution/digest/set.go b/Godeps/_workspace/src/github.com/docker/distribution/digest/set.go deleted file mode 100644 index 3fac41b40f..0000000000 --- a/Godeps/_workspace/src/github.com/docker/distribution/digest/set.go +++ /dev/null @@ -1,245 +0,0 @@ -package digest - -import ( - "errors" - "sort" - "strings" - "sync" -) - -var ( - // ErrDigestNotFound is used when a matching digest - // could not be found in a set. - ErrDigestNotFound = errors.New("digest not found") - - // ErrDigestAmbiguous is used when multiple digests - // are found in a set. None of the matching digests - // should be considered valid matches. - ErrDigestAmbiguous = errors.New("ambiguous digest string") -) - -// Set is used to hold a unique set of digests which -// may be easily referenced by easily referenced by a string -// representation of the digest as well as short representation. -// The uniqueness of the short representation is based on other -// digests in the set. If digests are ommited from this set, -// collisions in a larger set may not be detected, therefore it -// is important to always do short representation lookups on -// the complete set of digests. To mitigate collisions, an -// appropriately long short code should be used. -type Set struct { - mutex sync.RWMutex - entries digestEntries -} - -// NewSet creates an empty set of digests -// which may have digests added. -func NewSet() *Set { - return &Set{ - entries: digestEntries{}, - } -} - -// checkShortMatch checks whether two digests match as either whole -// values or short values. This function does not test equality, -// rather whether the second value could match against the first -// value. -func checkShortMatch(alg Algorithm, hex, shortAlg, shortHex string) bool { - if len(hex) == len(shortHex) { - if hex != shortHex { - return false - } - if len(shortAlg) > 0 && string(alg) != shortAlg { - return false - } - } else if !strings.HasPrefix(hex, shortHex) { - return false - } else if len(shortAlg) > 0 && string(alg) != shortAlg { - return false - } - return true -} - -// Lookup looks for a digest matching the given string representation. -// If no digests could be found ErrDigestNotFound will be returned -// with an empty digest value. If multiple matches are found -// ErrDigestAmbiguous will be returned with an empty digest value. -func (dst *Set) Lookup(d string) (Digest, error) { - dst.mutex.RLock() - defer dst.mutex.RUnlock() - if len(dst.entries) == 0 { - return "", ErrDigestNotFound - } - var ( - searchFunc func(int) bool - alg Algorithm - hex string - ) - dgst, err := ParseDigest(d) - if err == ErrDigestInvalidFormat { - hex = d - searchFunc = func(i int) bool { - return dst.entries[i].val >= d - } - } else { - hex = dgst.Hex() - alg = dgst.Algorithm() - searchFunc = func(i int) bool { - if dst.entries[i].val == hex { - return dst.entries[i].alg >= alg - } - return dst.entries[i].val >= hex - } - } - idx := sort.Search(len(dst.entries), searchFunc) - if idx == len(dst.entries) || !checkShortMatch(dst.entries[idx].alg, dst.entries[idx].val, string(alg), hex) { - return "", ErrDigestNotFound - } - if dst.entries[idx].alg == alg && dst.entries[idx].val == hex { - return dst.entries[idx].digest, nil - } - if idx+1 < len(dst.entries) && checkShortMatch(dst.entries[idx+1].alg, dst.entries[idx+1].val, string(alg), hex) { - return "", ErrDigestAmbiguous - } - - return dst.entries[idx].digest, nil -} - -// Add adds the given digest to the set. An error will be returned -// if the given digest is invalid. If the digest already exists in the -// set, this operation will be a no-op. -func (dst *Set) Add(d Digest) error { - if err := d.Validate(); err != nil { - return err - } - dst.mutex.Lock() - defer dst.mutex.Unlock() - entry := &digestEntry{alg: d.Algorithm(), val: d.Hex(), digest: d} - searchFunc := func(i int) bool { - if dst.entries[i].val == entry.val { - return dst.entries[i].alg >= entry.alg - } - return dst.entries[i].val >= entry.val - } - idx := sort.Search(len(dst.entries), searchFunc) - if idx == len(dst.entries) { - dst.entries = append(dst.entries, entry) - return nil - } else if dst.entries[idx].digest == d { - return nil - } - - entries := append(dst.entries, nil) - copy(entries[idx+1:], entries[idx:len(entries)-1]) - entries[idx] = entry - dst.entries = entries - return nil -} - -// Remove removes the given digest from the set. An err will be -// returned if the given digest is invalid. If the digest does -// not exist in the set, this operation will be a no-op. -func (dst *Set) Remove(d Digest) error { - if err := d.Validate(); err != nil { - return err - } - dst.mutex.Lock() - defer dst.mutex.Unlock() - entry := &digestEntry{alg: d.Algorithm(), val: d.Hex(), digest: d} - searchFunc := func(i int) bool { - if dst.entries[i].val == entry.val { - return dst.entries[i].alg >= entry.alg - } - return dst.entries[i].val >= entry.val - } - idx := sort.Search(len(dst.entries), searchFunc) - // Not found if idx is after or value at idx is not digest - if idx == len(dst.entries) || dst.entries[idx].digest != d { - return nil - } - - entries := dst.entries - copy(entries[idx:], entries[idx+1:]) - entries = entries[:len(entries)-1] - dst.entries = entries - - return nil -} - -// All returns all the digests in the set -func (dst *Set) All() []Digest { - dst.mutex.RLock() - defer dst.mutex.RUnlock() - retValues := make([]Digest, len(dst.entries)) - for i := range dst.entries { - retValues[i] = dst.entries[i].digest - } - - return retValues -} - -// ShortCodeTable returns a map of Digest to unique short codes. The -// length represents the minimum value, the maximum length may be the -// entire value of digest if uniqueness cannot be achieved without the -// full value. This function will attempt to make short codes as short -// as possible to be unique. -func ShortCodeTable(dst *Set, length int) map[Digest]string { - dst.mutex.RLock() - defer dst.mutex.RUnlock() - m := make(map[Digest]string, len(dst.entries)) - l := length - resetIdx := 0 - for i := 0; i < len(dst.entries); i++ { - var short string - extended := true - for extended { - extended = false - if len(dst.entries[i].val) <= l { - short = dst.entries[i].digest.String() - } else { - short = dst.entries[i].val[:l] - for j := i + 1; j < len(dst.entries); j++ { - if checkShortMatch(dst.entries[j].alg, dst.entries[j].val, "", short) { - if j > resetIdx { - resetIdx = j - } - extended = true - } else { - break - } - } - if extended { - l++ - } - } - } - m[dst.entries[i].digest] = short - if i >= resetIdx { - l = length - } - } - return m -} - -type digestEntry struct { - alg Algorithm - val string - digest Digest -} - -type digestEntries []*digestEntry - -func (d digestEntries) Len() int { - return len(d) -} - -func (d digestEntries) Less(i, j int) bool { - if d[i].val != d[j].val { - return d[i].val < d[j].val - } - return d[i].alg < d[j].alg -} - -func (d digestEntries) Swap(i, j int) { - d[i], d[j] = d[j], d[i] -} diff --git a/Godeps/_workspace/src/github.com/docker/distribution/digest/verifiers.go b/Godeps/_workspace/src/github.com/docker/distribution/digest/verifiers.go deleted file mode 100644 index 9af3be1341..0000000000 --- a/Godeps/_workspace/src/github.com/docker/distribution/digest/verifiers.go +++ /dev/null @@ -1,44 +0,0 @@ -package digest - -import ( - "hash" - "io" -) - -// Verifier presents a general verification interface to be used with message -// digests and other byte stream verifications. Users instantiate a Verifier -// from one of the various methods, write the data under test to it then check -// the result with the Verified method. -type Verifier interface { - io.Writer - - // Verified will return true if the content written to Verifier matches - // the digest. - Verified() bool -} - -// NewDigestVerifier returns a verifier that compares the written bytes -// against a passed in digest. -func NewDigestVerifier(d Digest) (Verifier, error) { - if err := d.Validate(); err != nil { - return nil, err - } - - return hashVerifier{ - hash: d.Algorithm().Hash(), - digest: d, - }, nil -} - -type hashVerifier struct { - digest Digest - hash hash.Hash -} - -func (hv hashVerifier) Write(p []byte) (n int, err error) { - return hv.hash.Write(p) -} - -func (hv hashVerifier) Verified() bool { - return hv.digest == NewDigest(hv.digest.Algorithm(), hv.hash) -} diff --git a/Godeps/_workspace/src/github.com/docker/distribution/reference/reference.go b/Godeps/_workspace/src/github.com/docker/distribution/reference/reference.go deleted file mode 100644 index c188472a40..0000000000 --- a/Godeps/_workspace/src/github.com/docker/distribution/reference/reference.go +++ /dev/null @@ -1,334 +0,0 @@ -// Package reference provides a general type to represent any way of referencing images within the registry. -// Its main purpose is to abstract tags and digests (content-addressable hash). -// -// Grammar -// -// reference := repository [ ":" tag ] [ "@" digest ] -// name := [hostname '/'] component ['/' component]* -// hostname := hostcomponent ['.' hostcomponent]* [':' port-number] -// hostcomponent := /([a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])/ -// port-number := /[0-9]+/ -// component := alpha-numeric [separator alpha-numeric]* -// alpha-numeric := /[a-z0-9]+/ -// separator := /[_.]|__|[-]*/ -// -// tag := /[\w][\w.-]{0,127}/ -// -// digest := digest-algorithm ":" digest-hex -// digest-algorithm := digest-algorithm-component [ digest-algorithm-separator digest-algorithm-component ] -// digest-algorithm-separator := /[+.-_]/ -// digest-algorithm-component := /[A-Za-z][A-Za-z0-9]*/ -// digest-hex := /[0-9a-fA-F]{32,}/ ; At least 128 bit digest value -package reference - -import ( - "errors" - "fmt" - - "github.com/docker/distribution/digest" -) - -const ( - // NameTotalLengthMax is the maximum total number of characters in a repository name. - NameTotalLengthMax = 255 -) - -var ( - // ErrReferenceInvalidFormat represents an error while trying to parse a string as a reference. - ErrReferenceInvalidFormat = errors.New("invalid reference format") - - // ErrTagInvalidFormat represents an error while trying to parse a string as a tag. - ErrTagInvalidFormat = errors.New("invalid tag format") - - // ErrDigestInvalidFormat represents an error while trying to parse a string as a tag. - ErrDigestInvalidFormat = errors.New("invalid digest format") - - // ErrNameEmpty is returned for empty, invalid repository names. - ErrNameEmpty = errors.New("repository name must have at least one component") - - // ErrNameTooLong is returned when a repository name is longer than NameTotalLengthMax. - ErrNameTooLong = fmt.Errorf("repository name must not be more than %v characters", NameTotalLengthMax) -) - -// Reference is an opaque object reference identifier that may include -// modifiers such as a hostname, name, tag, and digest. -type Reference interface { - // String returns the full reference - String() string -} - -// Field provides a wrapper type for resolving correct reference types when -// working with encoding. -type Field struct { - reference Reference -} - -// AsField wraps a reference in a Field for encoding. -func AsField(reference Reference) Field { - return Field{reference} -} - -// Reference unwraps the reference type from the field to -// return the Reference object. This object should be -// of the appropriate type to further check for different -// reference types. -func (f Field) Reference() Reference { - return f.reference -} - -// MarshalText serializes the field to byte text which -// is the string of the reference. -func (f Field) MarshalText() (p []byte, err error) { - return []byte(f.reference.String()), nil -} - -// UnmarshalText parses text bytes by invoking the -// reference parser to ensure the appropriately -// typed reference object is wrapped by field. -func (f *Field) UnmarshalText(p []byte) error { - r, err := Parse(string(p)) - if err != nil { - return err - } - - f.reference = r - return nil -} - -// Named is an object with a full name -type Named interface { - Reference - Name() string -} - -// Tagged is an object which has a tag -type Tagged interface { - Reference - Tag() string -} - -// NamedTagged is an object including a name and tag. -type NamedTagged interface { - Named - Tag() string -} - -// Digested is an object which has a digest -// in which it can be referenced by -type Digested interface { - Reference - Digest() digest.Digest -} - -// Canonical reference is an object with a fully unique -// name including a name with hostname and digest -type Canonical interface { - Named - Digest() digest.Digest -} - -// SplitHostname splits a named reference into a -// hostname and name string. If no valid hostname is -// found, the hostname is empty and the full value -// is returned as name -func SplitHostname(named Named) (string, string) { - name := named.Name() - match := anchoredNameRegexp.FindStringSubmatch(name) - if match == nil || len(match) != 3 { - return "", name - } - return match[1], match[2] -} - -// Parse parses s and returns a syntactically valid Reference. -// If an error was encountered it is returned, along with a nil Reference. -// NOTE: Parse will not handle short digests. -func Parse(s string) (Reference, error) { - matches := ReferenceRegexp.FindStringSubmatch(s) - if matches == nil { - if s == "" { - return nil, ErrNameEmpty - } - // TODO(dmcgowan): Provide more specific and helpful error - return nil, ErrReferenceInvalidFormat - } - - if len(matches[1]) > NameTotalLengthMax { - return nil, ErrNameTooLong - } - - ref := reference{ - name: matches[1], - tag: matches[2], - } - if matches[3] != "" { - var err error - ref.digest, err = digest.ParseDigest(matches[3]) - if err != nil { - return nil, err - } - } - - r := getBestReferenceType(ref) - if r == nil { - return nil, ErrNameEmpty - } - - return r, nil -} - -// ParseNamed parses s and returns a syntactically valid reference implementing -// the Named interface. The reference must have a name, otherwise an error is -// returned. -// If an error was encountered it is returned, along with a nil Reference. -// NOTE: ParseNamed will not handle short digests. -func ParseNamed(s string) (Named, error) { - ref, err := Parse(s) - if err != nil { - return nil, err - } - named, isNamed := ref.(Named) - if !isNamed { - return nil, fmt.Errorf("reference %s has no name", ref.String()) - } - return named, nil -} - -// WithName returns a named object representing the given string. If the input -// is invalid ErrReferenceInvalidFormat will be returned. -func WithName(name string) (Named, error) { - if len(name) > NameTotalLengthMax { - return nil, ErrNameTooLong - } - if !anchoredNameRegexp.MatchString(name) { - return nil, ErrReferenceInvalidFormat - } - return repository(name), nil -} - -// WithTag combines the name from "name" and the tag from "tag" to form a -// reference incorporating both the name and the tag. -func WithTag(name Named, tag string) (NamedTagged, error) { - if !anchoredTagRegexp.MatchString(tag) { - return nil, ErrTagInvalidFormat - } - return taggedReference{ - name: name.Name(), - tag: tag, - }, nil -} - -// WithDigest combines the name from "name" and the digest from "digest" to form -// a reference incorporating both the name and the digest. -func WithDigest(name Named, digest digest.Digest) (Canonical, error) { - if !anchoredDigestRegexp.MatchString(digest.String()) { - return nil, ErrDigestInvalidFormat - } - return canonicalReference{ - name: name.Name(), - digest: digest, - }, nil -} - -func getBestReferenceType(ref reference) Reference { - if ref.name == "" { - // Allow digest only references - if ref.digest != "" { - return digestReference(ref.digest) - } - return nil - } - if ref.tag == "" { - if ref.digest != "" { - return canonicalReference{ - name: ref.name, - digest: ref.digest, - } - } - return repository(ref.name) - } - if ref.digest == "" { - return taggedReference{ - name: ref.name, - tag: ref.tag, - } - } - - return ref -} - -type reference struct { - name string - tag string - digest digest.Digest -} - -func (r reference) String() string { - return r.name + ":" + r.tag + "@" + r.digest.String() -} - -func (r reference) Name() string { - return r.name -} - -func (r reference) Tag() string { - return r.tag -} - -func (r reference) Digest() digest.Digest { - return r.digest -} - -type repository string - -func (r repository) String() string { - return string(r) -} - -func (r repository) Name() string { - return string(r) -} - -type digestReference digest.Digest - -func (d digestReference) String() string { - return d.String() -} - -func (d digestReference) Digest() digest.Digest { - return digest.Digest(d) -} - -type taggedReference struct { - name string - tag string -} - -func (t taggedReference) String() string { - return t.name + ":" + t.tag -} - -func (t taggedReference) Name() string { - return t.name -} - -func (t taggedReference) Tag() string { - return t.tag -} - -type canonicalReference struct { - name string - digest digest.Digest -} - -func (c canonicalReference) String() string { - return c.name + "@" + c.digest.String() -} - -func (c canonicalReference) Name() string { - return c.name -} - -func (c canonicalReference) Digest() digest.Digest { - return c.digest -} diff --git a/Godeps/_workspace/src/github.com/docker/distribution/reference/regexp.go b/Godeps/_workspace/src/github.com/docker/distribution/reference/regexp.go deleted file mode 100644 index a4ffe5b642..0000000000 --- a/Godeps/_workspace/src/github.com/docker/distribution/reference/regexp.go +++ /dev/null @@ -1,124 +0,0 @@ -package reference - -import "regexp" - -var ( - // alphaNumericRegexp defines the alpha numeric atom, typically a - // component of names. This only allows lower case characters and digits. - alphaNumericRegexp = match(`[a-z0-9]+`) - - // separatorRegexp defines the separators allowed to be embedded in name - // components. This allow one period, one or two underscore and multiple - // dashes. - separatorRegexp = match(`(?:[._]|__|[-]*)`) - - // nameComponentRegexp restricts registry path component names to start - // with at least one letter or number, with following parts able to be - // separated by one period, one or two underscore and multiple dashes. - nameComponentRegexp = expression( - alphaNumericRegexp, - optional(repeated(separatorRegexp, alphaNumericRegexp))) - - // hostnameComponentRegexp restricts the registry hostname component of a - // repository name to start with a component as defined by hostnameRegexp - // and followed by an optional port. - hostnameComponentRegexp = match(`(?:[a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])`) - - // hostnameRegexp defines the structure of potential hostname components - // that may be part of image names. This is purposely a subset of what is - // allowed by DNS to ensure backwards compatibility with Docker image - // names. - hostnameRegexp = expression( - hostnameComponentRegexp, - optional(repeated(literal(`.`), hostnameComponentRegexp)), - optional(literal(`:`), match(`[0-9]+`))) - - // TagRegexp matches valid tag names. From docker/docker:graph/tags.go. - TagRegexp = match(`[\w][\w.-]{0,127}`) - - // anchoredTagRegexp matches valid tag names, anchored at the start and - // end of the matched string. - anchoredTagRegexp = anchored(TagRegexp) - - // DigestRegexp matches valid digests. - DigestRegexp = match(`[A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*[:][[:xdigit:]]{32,}`) - - // anchoredDigestRegexp matches valid digests, anchored at the start and - // end of the matched string. - anchoredDigestRegexp = anchored(DigestRegexp) - - // NameRegexp is the format for the name component of references. The - // regexp has capturing groups for the hostname and name part omitting - // the seperating forward slash from either. - NameRegexp = expression( - optional(hostnameRegexp, literal(`/`)), - nameComponentRegexp, - optional(repeated(literal(`/`), nameComponentRegexp))) - - // anchoredNameRegexp is used to parse a name value, capturing the - // hostname and trailing components. - anchoredNameRegexp = anchored( - optional(capture(hostnameRegexp), literal(`/`)), - capture(nameComponentRegexp, - optional(repeated(literal(`/`), nameComponentRegexp)))) - - // ReferenceRegexp is the full supported format of a reference. The regexp - // is anchored and has capturing groups for name, tag, and digest - // components. - ReferenceRegexp = anchored(capture(NameRegexp), - optional(literal(":"), capture(TagRegexp)), - optional(literal("@"), capture(DigestRegexp))) -) - -// match compiles the string to a regular expression. -var match = regexp.MustCompile - -// literal compiles s into a literal regular expression, escaping any regexp -// reserved characters. -func literal(s string) *regexp.Regexp { - re := match(regexp.QuoteMeta(s)) - - if _, complete := re.LiteralPrefix(); !complete { - panic("must be a literal") - } - - return re -} - -// expression defines a full expression, where each regular expression must -// follow the previous. -func expression(res ...*regexp.Regexp) *regexp.Regexp { - var s string - for _, re := range res { - s += re.String() - } - - return match(s) -} - -// optional wraps the expression in a non-capturing group and makes the -// production optional. -func optional(res ...*regexp.Regexp) *regexp.Regexp { - return match(group(expression(res...)).String() + `?`) -} - -// repeated wraps the regexp in a non-capturing group to get one or more -// matches. -func repeated(res ...*regexp.Regexp) *regexp.Regexp { - return match(group(expression(res...)).String() + `+`) -} - -// group wraps the regexp in a non-capturing group. -func group(res ...*regexp.Regexp) *regexp.Regexp { - return match(`(?:` + expression(res...).String() + `)`) -} - -// capture wraps the expression in a capturing group. -func capture(res ...*regexp.Regexp) *regexp.Regexp { - return match(`(` + expression(res...).String() + `)`) -} - -// anchored anchors the regular expression by adding start and end delimiters. -func anchored(res ...*regexp.Regexp) *regexp.Regexp { - return match(`^` + expression(res...).String() + `$`) -} diff --git a/Godeps/_workspace/src/github.com/dustin/go-humanize/.gitignore b/Godeps/_workspace/src/github.com/dustin/go-humanize/.gitignore deleted file mode 100644 index 05b40514a7..0000000000 --- a/Godeps/_workspace/src/github.com/dustin/go-humanize/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -#* -*.[568] -*.a -*~ -[568].out -_* diff --git a/Godeps/_workspace/src/github.com/dustin/go-humanize/LICENSE b/Godeps/_workspace/src/github.com/dustin/go-humanize/LICENSE deleted file mode 100644 index 8d9a94a906..0000000000 --- a/Godeps/_workspace/src/github.com/dustin/go-humanize/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -Copyright (c) 2005-2008 Dustin Sallings - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - - diff --git a/Godeps/_workspace/src/github.com/dustin/go-humanize/README.markdown b/Godeps/_workspace/src/github.com/dustin/go-humanize/README.markdown deleted file mode 100644 index f94e8154f6..0000000000 --- a/Godeps/_workspace/src/github.com/dustin/go-humanize/README.markdown +++ /dev/null @@ -1,81 +0,0 @@ -# Humane Units - -Just a few functions for helping humanize times and sizes. - -`go get` it as `github.com/dustin/go-humanize`, import it as -`"github.com/dustin/go-humanize"`, use it as `humanize` - -See [godoc](https://godoc.org/github.com/dustin/go-humanize) for -complete documentation. - -## Sizes - -This lets you take numbers like `82854982` and convert them to useful -strings like, `83MB` or `79MiB` (whichever you prefer). - -Example: - - fmt.Printf("That file is %s.", humanize.Bytes(82854982)) - -## Times - -This lets you take a `time.Time` and spit it out in relative terms. -For example, `12 seconds ago` or `3 days from now`. - -Example: - - fmt.Printf("This was touched %s", humanize.Time(someTimeInstance)) - -Thanks to Kyle Lemons for the time implementation from an IRC -conversation one day. It's pretty neat. - -## Ordinals - -From a [mailing list discussion][odisc] where a user wanted to be able -to label ordinals. - - 0 -> 0th - 1 -> 1st - 2 -> 2nd - 3 -> 3rd - 4 -> 4th - [...] - -Example: - - fmt.Printf("You're my %s best friend.", humanize.Ordinal(193)) - -## Commas - -Want to shove commas into numbers? Be my guest. - - 0 -> 0 - 100 -> 100 - 1000 -> 1,000 - 1000000000 -> 1,000,000,000 - -100000 -> -100,000 - -Example: - - fmt.Printf("You owe $%s.\n", humanize.Comma(6582491)) - -## Ftoa - -Nicer float64 formatter that removes trailing zeros. - - fmt.Printf("%f", 2.24) // 2.240000 - fmt.Printf("%s", humanize.Ftoa(2.24)) // 2.24 - fmt.Printf("%f", 2.0) // 2.000000 - fmt.Printf("%s", humanize.Ftoa(2.0)) // 2 - -## SI notation - -Format numbers with [SI notation][sinotation]. - -Example: - - humanize.SI(0.00000000223, "M") // 2.23nM - - -[odisc]: https://groups.google.com/d/topic/golang-nuts/l8NhI74jl-4/discussion -[sinotation]: http://en.wikipedia.org/wiki/Metric_prefix diff --git a/Godeps/_workspace/src/github.com/dustin/go-humanize/big.go b/Godeps/_workspace/src/github.com/dustin/go-humanize/big.go deleted file mode 100644 index f49dc337dc..0000000000 --- a/Godeps/_workspace/src/github.com/dustin/go-humanize/big.go +++ /dev/null @@ -1,31 +0,0 @@ -package humanize - -import ( - "math/big" -) - -// order of magnitude (to a max order) -func oomm(n, b *big.Int, maxmag int) (float64, int) { - mag := 0 - m := &big.Int{} - for n.Cmp(b) >= 0 { - n.DivMod(n, b, m) - mag++ - if mag == maxmag && maxmag >= 0 { - break - } - } - return float64(n.Int64()) + (float64(m.Int64()) / float64(b.Int64())), mag -} - -// total order of magnitude -// (same as above, but with no upper limit) -func oom(n, b *big.Int) (float64, int) { - mag := 0 - m := &big.Int{} - for n.Cmp(b) >= 0 { - n.DivMod(n, b, m) - mag++ - } - return float64(n.Int64()) + (float64(m.Int64()) / float64(b.Int64())), mag -} diff --git a/Godeps/_workspace/src/github.com/dustin/go-humanize/bigbytes.go b/Godeps/_workspace/src/github.com/dustin/go-humanize/bigbytes.go deleted file mode 100644 index e4a814a904..0000000000 --- a/Godeps/_workspace/src/github.com/dustin/go-humanize/bigbytes.go +++ /dev/null @@ -1,164 +0,0 @@ -package humanize - -import ( - "fmt" - "math/big" - "strings" - "unicode" -) - -var ( - bigIECExp = big.NewInt(1024) - - // BigByte is one byte in bit.Ints - BigByte = big.NewInt(1) - // BigKiByte is 1,024 bytes in bit.Ints - BigKiByte = (&big.Int{}).Mul(BigByte, bigIECExp) - // BigMiByte is 1,024 k bytes in bit.Ints - BigMiByte = (&big.Int{}).Mul(BigKiByte, bigIECExp) - // BigGiByte is 1,024 m bytes in bit.Ints - BigGiByte = (&big.Int{}).Mul(BigMiByte, bigIECExp) - // BigTiByte is 1,024 g bytes in bit.Ints - BigTiByte = (&big.Int{}).Mul(BigGiByte, bigIECExp) - // BigPiByte is 1,024 t bytes in bit.Ints - BigPiByte = (&big.Int{}).Mul(BigTiByte, bigIECExp) - // BigEiByte is 1,024 p bytes in bit.Ints - BigEiByte = (&big.Int{}).Mul(BigPiByte, bigIECExp) - // BigZiByte is 1,024 e bytes in bit.Ints - BigZiByte = (&big.Int{}).Mul(BigEiByte, bigIECExp) - // BigYiByte is 1,024 z bytes in bit.Ints - BigYiByte = (&big.Int{}).Mul(BigZiByte, bigIECExp) -) - -var ( - bigSIExp = big.NewInt(1000) - - // BigSIByte is one SI byte in big.Ints - BigSIByte = big.NewInt(1) - // BigKByte is 1,000 SI bytes in big.Ints - BigKByte = (&big.Int{}).Mul(BigSIByte, bigSIExp) - // BigMByte is 1,000 SI k bytes in big.Ints - BigMByte = (&big.Int{}).Mul(BigKByte, bigSIExp) - // BigGByte is 1,000 SI m bytes in big.Ints - BigGByte = (&big.Int{}).Mul(BigMByte, bigSIExp) - // BigTByte is 1,000 SI g bytes in big.Ints - BigTByte = (&big.Int{}).Mul(BigGByte, bigSIExp) - // BigPByte is 1,000 SI t bytes in big.Ints - BigPByte = (&big.Int{}).Mul(BigTByte, bigSIExp) - // BigEByte is 1,000 SI p bytes in big.Ints - BigEByte = (&big.Int{}).Mul(BigPByte, bigSIExp) - // BigZByte is 1,000 SI e bytes in big.Ints - BigZByte = (&big.Int{}).Mul(BigEByte, bigSIExp) - // BigYByte is 1,000 SI z bytes in big.Ints - BigYByte = (&big.Int{}).Mul(BigZByte, bigSIExp) -) - -var bigBytesSizeTable = map[string]*big.Int{ - "b": BigByte, - "kib": BigKiByte, - "kb": BigKByte, - "mib": BigMiByte, - "mb": BigMByte, - "gib": BigGiByte, - "gb": BigGByte, - "tib": BigTiByte, - "tb": BigTByte, - "pib": BigPiByte, - "pb": BigPByte, - "eib": BigEiByte, - "eb": BigEByte, - "zib": BigZiByte, - "zb": BigZByte, - "yib": BigYiByte, - "yb": BigYByte, - // Without suffix - "": BigByte, - "ki": BigKiByte, - "k": BigKByte, - "mi": BigMiByte, - "m": BigMByte, - "gi": BigGiByte, - "g": BigGByte, - "ti": BigTiByte, - "t": BigTByte, - "pi": BigPiByte, - "p": BigPByte, - "ei": BigEiByte, - "e": BigEByte, - "z": BigZByte, - "zi": BigZiByte, - "y": BigYByte, - "yi": BigYiByte, -} - -var ten = big.NewInt(10) - -func humanateBigBytes(s, base *big.Int, sizes []string) string { - if s.Cmp(ten) < 0 { - return fmt.Sprintf("%dB", s) - } - c := (&big.Int{}).Set(s) - val, mag := oomm(c, base, len(sizes)-1) - suffix := sizes[mag] - f := "%.0f%s" - if val < 10 { - f = "%.1f%s" - } - - return fmt.Sprintf(f, val, suffix) - -} - -// BigBytes produces a human readable representation of an SI size. -// -// See also: ParseBigBytes. -// -// BigBytes(82854982) -> 83MB -func BigBytes(s *big.Int) string { - sizes := []string{"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"} - return humanateBigBytes(s, bigSIExp, sizes) -} - -// BigIBytes produces a human readable representation of an IEC size. -// -// See also: ParseBigBytes. -// -// BigIBytes(82854982) -> 79MiB -func BigIBytes(s *big.Int) string { - sizes := []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"} - return humanateBigBytes(s, bigIECExp, sizes) -} - -// ParseBigBytes parses a string representation of bytes into the number -// of bytes it represents. -// -// See also: BigBytes, BigIBytes. -// -// ParseBigBytes("42MB") -> 42000000, nil -// ParseBigBytes("42mib") -> 44040192, nil -func ParseBigBytes(s string) (*big.Int, error) { - lastDigit := 0 - for _, r := range s { - if !(unicode.IsDigit(r) || r == '.') { - break - } - lastDigit++ - } - - val := &big.Rat{} - _, err := fmt.Sscanf(s[:lastDigit], "%f", val) - if err != nil { - return nil, err - } - - extra := strings.ToLower(strings.TrimSpace(s[lastDigit:])) - if m, ok := bigBytesSizeTable[extra]; ok { - mv := (&big.Rat{}).SetInt(m) - val.Mul(val, mv) - rv := &big.Int{} - rv.Div(val.Num(), val.Denom()) - return rv, nil - } - - return nil, fmt.Errorf("unhandled size name: %v", extra) -} diff --git a/Godeps/_workspace/src/github.com/dustin/go-humanize/bytes.go b/Godeps/_workspace/src/github.com/dustin/go-humanize/bytes.go deleted file mode 100644 index b7a77b5296..0000000000 --- a/Godeps/_workspace/src/github.com/dustin/go-humanize/bytes.go +++ /dev/null @@ -1,134 +0,0 @@ -package humanize - -import ( - "fmt" - "math" - "strconv" - "strings" - "unicode" -) - -// IEC Sizes. -// kibis of bits -const ( - Byte = 1 << (iota * 10) - KiByte - MiByte - GiByte - TiByte - PiByte - EiByte -) - -// SI Sizes. -const ( - IByte = 1 - KByte = IByte * 1000 - MByte = KByte * 1000 - GByte = MByte * 1000 - TByte = GByte * 1000 - PByte = TByte * 1000 - EByte = PByte * 1000 -) - -var bytesSizeTable = map[string]uint64{ - "b": Byte, - "kib": KiByte, - "kb": KByte, - "mib": MiByte, - "mb": MByte, - "gib": GiByte, - "gb": GByte, - "tib": TiByte, - "tb": TByte, - "pib": PiByte, - "pb": PByte, - "eib": EiByte, - "eb": EByte, - // Without suffix - "": Byte, - "ki": KiByte, - "k": KByte, - "mi": MiByte, - "m": MByte, - "gi": GiByte, - "g": GByte, - "ti": TiByte, - "t": TByte, - "pi": PiByte, - "p": PByte, - "ei": EiByte, - "e": EByte, -} - -func logn(n, b float64) float64 { - return math.Log(n) / math.Log(b) -} - -func humanateBytes(s uint64, base float64, sizes []string) string { - if s < 10 { - return fmt.Sprintf("%dB", s) - } - e := math.Floor(logn(float64(s), base)) - suffix := sizes[int(e)] - val := math.Floor(float64(s)/math.Pow(base, e)*10+0.5) / 10 - f := "%.0f%s" - if val < 10 { - f = "%.1f%s" - } - - return fmt.Sprintf(f, val, suffix) -} - -// Bytes produces a human readable representation of an SI size. -// -// See also: ParseBytes. -// -// Bytes(82854982) -> 83MB -func Bytes(s uint64) string { - sizes := []string{"B", "kB", "MB", "GB", "TB", "PB", "EB"} - return humanateBytes(s, 1000, sizes) -} - -// IBytes produces a human readable representation of an IEC size. -// -// See also: ParseBytes. -// -// IBytes(82854982) -> 79MiB -func IBytes(s uint64) string { - sizes := []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"} - return humanateBytes(s, 1024, sizes) -} - -// ParseBytes parses a string representation of bytes into the number -// of bytes it represents. -// -// See Also: Bytes, IBytes. -// -// ParseBytes("42MB") -> 42000000, nil -// ParseBytes("42mib") -> 44040192, nil -func ParseBytes(s string) (uint64, error) { - lastDigit := 0 - for _, r := range s { - if !(unicode.IsDigit(r) || r == '.') { - break - } - lastDigit++ - } - - f, err := strconv.ParseFloat(s[:lastDigit], 64) - if err != nil { - return 0, err - } - - extra := strings.ToLower(strings.TrimSpace(s[lastDigit:])) - if m, ok := bytesSizeTable[extra]; ok { - f *= float64(m) - if f >= math.MaxUint64 { - return 0, fmt.Errorf("too large: %v", s) - } - return uint64(f), nil - } - - return 0, fmt.Errorf("unhandled size name: %v", extra) -} diff --git a/Godeps/_workspace/src/github.com/dustin/go-humanize/comma.go b/Godeps/_workspace/src/github.com/dustin/go-humanize/comma.go deleted file mode 100644 index b65ea6fa78..0000000000 --- a/Godeps/_workspace/src/github.com/dustin/go-humanize/comma.go +++ /dev/null @@ -1,101 +0,0 @@ -package humanize - -import ( - "bytes" - "math/big" - "strconv" - "strings" -) - -// Comma produces a string form of the given number in base 10 with -// commas after every three orders of magnitude. -// -// e.g. Comma(834142) -> 834,142 -func Comma(v int64) string { - sign := "" - if v < 0 { - sign = "-" - v = 0 - v - } - - parts := []string{"", "", "", "", "", "", ""} - j := len(parts) - 1 - - for v > 999 { - parts[j] = strconv.FormatInt(v%1000, 10) - switch len(parts[j]) { - case 2: - parts[j] = "0" + parts[j] - case 1: - parts[j] = "00" + parts[j] - } - v = v / 1000 - j-- - } - parts[j] = strconv.Itoa(int(v)) - return sign + strings.Join(parts[j:], ",") -} - -// Commaf produces a string form of the given number in base 10 with -// commas after every three orders of magnitude. -// -// e.g. Comma(834142.32) -> 834,142.32 -func Commaf(v float64) string { - buf := &bytes.Buffer{} - if v < 0 { - buf.Write([]byte{'-'}) - v = 0 - v - } - - comma := []byte{','} - - parts := strings.Split(strconv.FormatFloat(v, 'f', -1, 64), ".") - pos := 0 - if len(parts[0])%3 != 0 { - pos += len(parts[0]) % 3 - buf.WriteString(parts[0][:pos]) - buf.Write(comma) - } - for ; pos < len(parts[0]); pos += 3 { - buf.WriteString(parts[0][pos : pos+3]) - buf.Write(comma) - } - buf.Truncate(buf.Len() - 1) - - if len(parts) > 1 { - buf.Write([]byte{'.'}) - buf.WriteString(parts[1]) - } - return buf.String() -} - -// BigComma produces a string form of the given big.Int in base 10 -// with commas after every three orders of magnitude. -func BigComma(b *big.Int) string { - sign := "" - if b.Sign() < 0 { - sign = "-" - b.Abs(b) - } - - athousand := big.NewInt(1000) - c := (&big.Int{}).Set(b) - _, m := oom(c, athousand) - parts := make([]string, m+1) - j := len(parts) - 1 - - mod := &big.Int{} - for b.Cmp(athousand) >= 0 { - b.DivMod(b, athousand, mod) - parts[j] = strconv.FormatInt(mod.Int64(), 10) - switch len(parts[j]) { - case 2: - parts[j] = "0" + parts[j] - case 1: - parts[j] = "00" + parts[j] - } - j-- - } - parts[j] = strconv.Itoa(int(b.Int64())) - return sign + strings.Join(parts[j:], ",") -} diff --git a/Godeps/_workspace/src/github.com/dustin/go-humanize/ftoa.go b/Godeps/_workspace/src/github.com/dustin/go-humanize/ftoa.go deleted file mode 100644 index c76190b106..0000000000 --- a/Godeps/_workspace/src/github.com/dustin/go-humanize/ftoa.go +++ /dev/null @@ -1,23 +0,0 @@ -package humanize - -import "strconv" - -func stripTrailingZeros(s string) string { - offset := len(s) - 1 - for offset > 0 { - if s[offset] == '.' { - offset-- - break - } - if s[offset] != '0' { - break - } - offset-- - } - return s[:offset+1] -} - -// Ftoa converts a float to a string with no trailing zeros. -func Ftoa(num float64) string { - return stripTrailingZeros(strconv.FormatFloat(num, 'f', 6, 64)) -} diff --git a/Godeps/_workspace/src/github.com/dustin/go-humanize/humanize.go b/Godeps/_workspace/src/github.com/dustin/go-humanize/humanize.go deleted file mode 100644 index a69540a06b..0000000000 --- a/Godeps/_workspace/src/github.com/dustin/go-humanize/humanize.go +++ /dev/null @@ -1,8 +0,0 @@ -/* -Package humanize converts boring ugly numbers to human-friendly strings and back. - -Durations can be turned into strings such as "3 days ago", numbers -representing sizes like 82854982 into useful strings like, "83MB" or -"79MiB" (whichever you prefer). -*/ -package humanize diff --git a/Godeps/_workspace/src/github.com/dustin/go-humanize/number.go b/Godeps/_workspace/src/github.com/dustin/go-humanize/number.go deleted file mode 100644 index 32141348c8..0000000000 --- a/Godeps/_workspace/src/github.com/dustin/go-humanize/number.go +++ /dev/null @@ -1,192 +0,0 @@ -package humanize - -/* -Slightly adapted from the source to fit go-humanize. - -Author: https://github.com/gorhill -Source: https://gist.github.com/gorhill/5285193 - -*/ - -import ( - "math" - "strconv" -) - -var ( - renderFloatPrecisionMultipliers = [...]float64{ - 1, - 10, - 100, - 1000, - 10000, - 100000, - 1000000, - 10000000, - 100000000, - 1000000000, - } - - renderFloatPrecisionRounders = [...]float64{ - 0.5, - 0.05, - 0.005, - 0.0005, - 0.00005, - 0.000005, - 0.0000005, - 0.00000005, - 0.000000005, - 0.0000000005, - } -) - -// FormatFloat produces a formatted number as string based on the following user-specified criteria: -// * thousands separator -// * decimal separator -// * decimal precision -// -// Usage: s := RenderFloat(format, n) -// The format parameter tells how to render the number n. -// -// See examples: http://play.golang.org/p/LXc1Ddm1lJ -// -// Examples of format strings, given n = 12345.6789: -// "#,###.##" => "12,345.67" -// "#,###." => "12,345" -// "#,###" => "12345,678" -// "#\u202F###,##" => "12 345,68" -// "#.###,###### => 12.345,678900 -// "" (aka default format) => 12,345.67 -// -// The highest precision allowed is 9 digits after the decimal symbol. -// There is also a version for integer number, FormatInteger(), -// which is convenient for calls within template. -func FormatFloat(format string, n float64) string { - // Special cases: - // NaN = "NaN" - // +Inf = "+Infinity" - // -Inf = "-Infinity" - if math.IsNaN(n) { - return "NaN" - } - if n > math.MaxFloat64 { - return "Infinity" - } - if n < -math.MaxFloat64 { - return "-Infinity" - } - - // default format - precision := 2 - decimalStr := "." - thousandStr := "," - positiveStr := "" - negativeStr := "-" - - if len(format) > 0 { - format := []rune(format) - - // If there is an explicit format directive, - // then default values are these: - precision = 9 - thousandStr = "" - - // collect indices of meaningful formatting directives - formatIndx := []int{} - for i, char := range format { - if char != '#' && char != '0' { - formatIndx = append(formatIndx, i) - } - } - - if len(formatIndx) > 0 { - // Directive at index 0: - // Must be a '+' - // Raise an error if not the case - // index: 0123456789 - // +0.000,000 - // +000,000.0 - // +0000.00 - // +0000 - if formatIndx[0] == 0 { - if format[formatIndx[0]] != '+' { - panic("RenderFloat(): invalid positive sign directive") - } - positiveStr = "+" - formatIndx = formatIndx[1:] - } - - // Two directives: - // First is thousands separator - // Raise an error if not followed by 3-digit - // 0123456789 - // 0.000,000 - // 000,000.00 - if len(formatIndx) == 2 { - if (formatIndx[1] - formatIndx[0]) != 4 { - panic("RenderFloat(): thousands separator directive must be followed by 3 digit-specifiers") - } - thousandStr = string(format[formatIndx[0]]) - formatIndx = formatIndx[1:] - } - - // One directive: - // Directive is decimal separator - // The number of digit-specifier following the separator indicates wanted precision - // 0123456789 - // 0.00 - // 000,0000 - if len(formatIndx) == 1 { - decimalStr = string(format[formatIndx[0]]) - precision = len(format) - formatIndx[0] - 1 - } - } - } - - // generate sign part - var signStr string - if n >= 0.000000001 { - signStr = positiveStr - } else if n <= -0.000000001 { - signStr = negativeStr - n = -n - } else { - signStr = "" - n = 0.0 - } - - // split number into integer and fractional parts - intf, fracf := math.Modf(n + renderFloatPrecisionRounders[precision]) - - // generate integer part string - intStr := strconv.Itoa(int(intf)) - - // add thousand separator if required - if len(thousandStr) > 0 { - for i := len(intStr); i > 3; { - i -= 3 - intStr = intStr[:i] + thousandStr + intStr[i:] - } - } - - // no fractional part, we can leave now - if precision == 0 { - return signStr + intStr - } - - // generate fractional part - fracStr := strconv.Itoa(int(fracf * renderFloatPrecisionMultipliers[precision])) - // may need padding - if len(fracStr) < precision { - fracStr = "000000000000000"[:precision-len(fracStr)] + fracStr - } - - return signStr + intStr + decimalStr + fracStr -} - -// FormatInteger produces a formatted number as string. -// See FormatFloat. -func FormatInteger(format string, n int) string { - return FormatFloat(format, float64(n)) -} diff --git a/Godeps/_workspace/src/github.com/dustin/go-humanize/ordinals.go b/Godeps/_workspace/src/github.com/dustin/go-humanize/ordinals.go deleted file mode 100644 index 43d88a8619..0000000000 --- a/Godeps/_workspace/src/github.com/dustin/go-humanize/ordinals.go +++ /dev/null @@ -1,25 +0,0 @@ -package humanize - -import "strconv" - -// Ordinal gives you the input number in a rank/ordinal format. -// -// Ordinal(3) -> 3rd -func Ordinal(x int) string { - suffix := "th" - switch x % 10 { - case 1: - if x%100 != 11 { - suffix = "st" - } - case 2: - if x%100 != 12 { - suffix = "nd" - } - case 3: - if x%100 != 13 { - suffix = "rd" - } - } - return strconv.Itoa(x) + suffix -} diff --git a/Godeps/_workspace/src/github.com/dustin/go-humanize/si.go b/Godeps/_workspace/src/github.com/dustin/go-humanize/si.go deleted file mode 100644 index dee8b765a0..0000000000 --- a/Godeps/_workspace/src/github.com/dustin/go-humanize/si.go +++ /dev/null @@ -1,110 +0,0 @@ -package humanize - -import ( - "errors" - "math" - "regexp" - "strconv" -) - -var siPrefixTable = map[float64]string{ - -24: "y", // yocto - -21: "z", // zepto - -18: "a", // atto - -15: "f", // femto - -12: "p", // pico - -9: "n", // nano - -6: "µ", // micro - -3: "m", // milli - 0: "", - 3: "k", // kilo - 6: "M", // mega - 9: "G", // giga - 12: "T", // tera - 15: "P", // peta - 18: "E", // exa - 21: "Z", // zetta - 24: "Y", // yotta -} - -var revSIPrefixTable = revfmap(siPrefixTable) - -// revfmap reverses the map and precomputes the power multiplier -func revfmap(in map[float64]string) map[string]float64 { - rv := map[string]float64{} - for k, v := range in { - rv[v] = math.Pow(10, k) - } - return rv -} - -var riParseRegex *regexp.Regexp - -func init() { - ri := `^([0-9.]+)([` - for _, v := range siPrefixTable { - ri += v - } - ri += `]?)(.*)` - - riParseRegex = regexp.MustCompile(ri) -} - -// ComputeSI finds the most appropriate SI prefix for the given number -// and returns the prefix along with the value adjusted to be within -// that prefix. -// -// See also: SI, ParseSI. -// -// e.g. ComputeSI(2.2345e-12) -> (2.2345, "p") -func ComputeSI(input float64) (float64, string) { - if input == 0 { - return 0, "" - } - exponent := math.Floor(logn(input, 10)) - exponent = math.Floor(exponent/3) * 3 - - value := input / math.Pow(10, exponent) - - // Handle special case where value is exactly 1000.0 - // Should return 1M instead of 1000k - if value == 1000.0 { - exponent += 3 - value = input / math.Pow(10, exponent) - } - - prefix := siPrefixTable[exponent] - return value, prefix -} - -// SI returns a string with default formatting. -// -// SI uses Ftoa to format float value, removing trailing zeros. -// -// See also: ComputeSI, ParseSI. -// -// e.g. SI(1000000, B) -> 1MB -// e.g. SI(2.2345e-12, "F") -> 2.2345pF -func SI(input float64, unit string) string { - value, prefix := ComputeSI(input) - return Ftoa(value) + prefix + unit -} - -var errInvalid = errors.New("invalid input") - -// ParseSI parses an SI string back into the number and unit. -// -// See also: SI, ComputeSI. -// -// e.g. ParseSI(2.2345pF) -> (2.2345e-12, "F", nil) -func ParseSI(input string) (float64, string, error) { - found := riParseRegex.FindStringSubmatch(input) - if len(found) != 4 { - return 0, "", errInvalid - } - mag := revSIPrefixTable[found[2]] - unit := found[3] - - base, err := strconv.ParseFloat(found[1], 64) - return base * mag, unit, err -} diff --git a/Godeps/_workspace/src/github.com/dustin/go-humanize/times.go b/Godeps/_workspace/src/github.com/dustin/go-humanize/times.go deleted file mode 100644 index 592ebe1d62..0000000000 --- a/Godeps/_workspace/src/github.com/dustin/go-humanize/times.go +++ /dev/null @@ -1,91 +0,0 @@ -package humanize - -import ( - "fmt" - "math" - "sort" - "time" -) - -// Seconds-based time units -const ( - Minute = 60 - Hour = 60 * Minute - Day = 24 * Hour - Week = 7 * Day - Month = 30 * Day - Year = 12 * Month - LongTime = 37 * Year -) - -// Time formats a time into a relative string. -// -// Time(someT) -> "3 weeks ago" -func Time(then time.Time) string { - return RelTime(then, time.Now(), "ago", "from now") -} - -var magnitudes = []struct { - d int64 - format string - divby int64 -}{ - {1, "now", 1}, - {2, "1 second %s", 1}, - {Minute, "%d seconds %s", 1}, - {2 * Minute, "1 minute %s", 1}, - {Hour, "%d minutes %s", Minute}, - {2 * Hour, "1 hour %s", 1}, - {Day, "%d hours %s", Hour}, - {2 * Day, "1 day %s", 1}, - {Week, "%d days %s", Day}, - {2 * Week, "1 week %s", 1}, - {Month, "%d weeks %s", Week}, - {2 * Month, "1 month %s", 1}, - {Year, "%d months %s", Month}, - {18 * Month, "1 year %s", 1}, - {2 * Year, "2 years %s", 1}, - {LongTime, "%d years %s", Year}, - {math.MaxInt64, "a long while %s", 1}, -} - -// RelTime formats a time into a relative string. -// -// It takes two times and two labels. In addition to the generic time -// delta string (e.g. 5 minutes), the labels are used applied so that -// the label corresponding to the smaller time is applied. -// -// RelTime(timeInPast, timeInFuture, "earlier", "later") -> "3 weeks earlier" -func RelTime(a, b time.Time, albl, blbl string) string { - lbl := albl - diff := b.Unix() - a.Unix() - - after := a.After(b) - if after { - lbl = blbl - diff = a.Unix() - b.Unix() - } - - n := sort.Search(len(magnitudes), func(i int) bool { - return magnitudes[i].d > diff - }) - - mag := magnitudes[n] - args := []interface{}{} - escaped := false - for _, ch := range mag.format { - if escaped { - switch ch { - case '%': - case 's': - args = append(args, lbl) - case 'd': - args = append(args, diff/mag.divby) - } - escaped = false - } else { - escaped = ch == '%' - } - } - return fmt.Sprintf(mag.format, args...) -} diff --git a/Godeps/_workspace/src/github.com/go-ini/ini/.gitignore b/Godeps/_workspace/src/github.com/go-ini/ini/.gitignore deleted file mode 100644 index 7adca9439c..0000000000 --- a/Godeps/_workspace/src/github.com/go-ini/ini/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -testdata/conf_out.ini -ini.sublime-project -ini.sublime-workspace -testdata/conf_reflect.ini diff --git a/Godeps/_workspace/src/github.com/go-ini/ini/LICENSE b/Godeps/_workspace/src/github.com/go-ini/ini/LICENSE deleted file mode 100644 index 37ec93a14f..0000000000 --- a/Godeps/_workspace/src/github.com/go-ini/ini/LICENSE +++ /dev/null @@ -1,191 +0,0 @@ -Apache License -Version 2.0, January 2004 -http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, and -distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by the copyright -owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and all other entities -that control, are controlled by, or are under common control with that entity. -For the purposes of this definition, "control" means (i) the power, direct or -indirect, to cause the direction or management of such entity, whether by -contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the -outstanding shares, or (iii) beneficial ownership of such entity. - -"You" (or "Your") shall mean an individual or Legal Entity exercising -permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, including -but not limited to software source code, documentation source, and configuration -files. - -"Object" form shall mean any form resulting from mechanical transformation or -translation of a Source form, including but not limited to compiled object code, -generated documentation, and conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object form, made -available under the License, as indicated by a copyright notice that is included -in or attached to the work (an example is provided in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object form, that -is based on (or derived from) the Work and for which the editorial revisions, -annotations, elaborations, or other modifications represent, as a whole, an -original work of authorship. For the purposes of this License, Derivative Works -shall not include works that remain separable from, or merely link (or bind by -name) to the interfaces of, the Work and Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original version -of the Work and any modifications or additions to that Work or Derivative Works -thereof, that is intentionally submitted to Licensor for inclusion in the Work -by the copyright owner or by an individual or Legal Entity authorized to submit -on behalf of the copyright owner. For the purposes of this definition, -"submitted" means any form of electronic, verbal, or written communication sent -to the Licensor or its representatives, including but not limited to -communication on electronic mailing lists, source code control systems, and -issue tracking systems that are managed by, or on behalf of, the Licensor for -the purpose of discussing and improving the Work, but excluding communication -that is conspicuously marked or otherwise designated in writing by the copyright -owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf -of whom a Contribution has been received by Licensor and subsequently -incorporated within the Work. - -2. Grant of Copyright License. - -Subject to the terms and conditions of this License, each Contributor hereby -grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, -irrevocable copyright license to reproduce, prepare Derivative Works of, -publicly display, publicly perform, sublicense, and distribute the Work and such -Derivative Works in Source or Object form. - -3. Grant of Patent License. - -Subject to the terms and conditions of this License, each Contributor 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, and otherwise transfer the Work, where -such license applies only to those patent claims licensable by such Contributor -that are necessarily infringed by their Contribution(s) alone or by combination -of their Contribution(s) with the Work to which such Contribution(s) was -submitted. If You institute patent litigation against any entity (including a -cross-claim or counterclaim in a lawsuit) alleging that the Work or a -Contribution incorporated within the Work constitutes direct or contributory -patent infringement, then any patent licenses granted to You under this License -for that Work shall terminate as of the date such litigation is filed. - -4. Redistribution. - -You may reproduce and distribute copies of the Work or Derivative Works thereof -in any medium, with or without modifications, and in Source or Object form, -provided that You meet the following conditions: - -You must give any other recipients of the Work or Derivative Works a copy of -this License; and -You must cause any modified files to carry prominent notices stating that You -changed the files; and -You must retain, in the Source form of any Derivative Works that You distribute, -all copyright, patent, trademark, and attribution notices from the Source form -of the Work, excluding those notices that do not pertain to any part of the -Derivative Works; and -If the Work includes a "NOTICE" text file as part of its distribution, then any -Derivative Works that You distribute must include a readable copy of the -attribution notices contained within such NOTICE file, excluding those notices -that do not pertain to any part of the Derivative Works, in at least one of the -following places: within a NOTICE text file distributed as part of the -Derivative Works; within the Source form or documentation, if provided along -with the Derivative Works; or, within a display generated by the Derivative -Works, if and wherever such third-party notices normally appear. The contents of -the NOTICE file are for informational purposes only and do not modify the -License. You may add Your own attribution notices within Derivative Works that -You distribute, alongside or as an addendum to the NOTICE text from the Work, -provided that such additional attribution notices cannot be construed as -modifying the License. -You may add Your own copyright statement to Your modifications and may provide -additional or different license terms and conditions for use, reproduction, or -distribution of Your modifications, or for any such Derivative Works as a whole, -provided Your use, reproduction, and distribution of the Work otherwise complies -with the conditions stated in this License. - -5. Submission of Contributions. - -Unless You explicitly state otherwise, any Contribution intentionally submitted -for inclusion in the Work by You to the Licensor shall be under the terms and -conditions of this License, without any additional terms or conditions. -Notwithstanding the above, nothing herein shall supersede or modify the terms of -any separate license agreement you may have executed with Licensor regarding -such Contributions. - -6. Trademarks. - -This License does not grant permission to use the trade names, trademarks, -service marks, or product names of the Licensor, except as required for -reasonable and customary use in describing the origin of the Work and -reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. - -Unless required by applicable law or agreed to in writing, Licensor provides the -Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, -including, without limitation, any warranties or conditions of TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are -solely responsible for determining the appropriateness of using or -redistributing the Work and assume any risks associated with Your exercise of -permissions under this License. - -8. Limitation of Liability. - -In no event and under no legal theory, whether in tort (including negligence), -contract, or otherwise, unless required by applicable law (such as deliberate -and grossly negligent acts) or agreed to in writing, shall any Contributor be -liable to You for damages, including any direct, indirect, special, incidental, -or consequential damages of any character arising as a result of this License or -out of the use or inability to use the Work (including but not limited to -damages for loss of goodwill, work stoppage, computer failure or malfunction, or -any and all other commercial damages or losses), even if such Contributor has -been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. - -While redistributing the Work or Derivative Works thereof, You may choose to -offer, and charge a fee for, acceptance of support, warranty, indemnity, or -other liability obligations and/or rights consistent with this License. However, -in accepting such obligations, You may act only on Your own behalf and on Your -sole responsibility, not on behalf of any other Contributor, and only if You -agree to indemnify, defend, and hold each Contributor harmless for any liability -incurred by, or claims asserted against, such Contributor by reason of your -accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work - -To apply the Apache License to your work, attach the following boilerplate -notice, with the fields enclosed by brackets "[]" replaced with your own -identifying information. (Don't include the brackets!) The text should be -enclosed in the appropriate comment syntax for the file format. We also -recommend that a file or class name and description of purpose be included on -the same "printed page" as the copyright notice for easier identification within -third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/Godeps/_workspace/src/github.com/go-ini/ini/Makefile b/Godeps/_workspace/src/github.com/go-ini/ini/Makefile deleted file mode 100644 index ac034e5258..0000000000 --- a/Godeps/_workspace/src/github.com/go-ini/ini/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -.PHONY: build test bench vet - -build: vet bench - -test: - go test -v -cover -race - -bench: - go test -v -cover -race -test.bench=. -test.benchmem - -vet: - go vet diff --git a/Godeps/_workspace/src/github.com/go-ini/ini/README.md b/Godeps/_workspace/src/github.com/go-ini/ini/README.md deleted file mode 100644 index a87cca2328..0000000000 --- a/Godeps/_workspace/src/github.com/go-ini/ini/README.md +++ /dev/null @@ -1,632 +0,0 @@ -ini [![Build Status](https://drone.io/github.com/go-ini/ini/status.png)](https://drone.io/github.com/go-ini/ini/latest) [![](http://gocover.io/_badge/github.com/go-ini/ini)](http://gocover.io/github.com/go-ini/ini) -=== - -![](https://avatars0.githubusercontent.com/u/10216035?v=3&s=200) - -Package ini provides INI file read and write functionality in Go. - -[简体中文](README_ZH.md) - -## Feature - -- Load multiple data sources(`[]byte` or file) with overwrites. -- Read with recursion values. -- Read with parent-child sections. -- Read with auto-increment key names. -- Read with multiple-line values. -- Read with tons of helper methods. -- Read and convert values to Go types. -- Read and **WRITE** comments of sections and keys. -- Manipulate sections, keys and comments with ease. -- Keep sections and keys in order as you parse and save. - -## Installation - -To use a tagged revision: - - go get gopkg.in/ini.v1 - -To use with latest changes: - - go get github.com/go-ini/ini - -Please add `-u` flag to update in the future. - -### Testing - -If you want to test on your machine, please apply `-t` flag: - - go get -t gopkg.in/ini.v1 - -Please add `-u` flag to update in the future. - -## Getting Started - -### Loading from data sources - -A **Data Source** is either raw data in type `[]byte` or a file name with type `string` and you can load **as many as** data sources you want. Passing other types will simply return an error. - -```go -cfg, err := ini.Load([]byte("raw data"), "filename") -``` - -Or start with an empty object: - -```go -cfg := ini.Empty() -``` - -When you cannot decide how many data sources to load at the beginning, you still able to **Append()** them later. - -```go -err := cfg.Append("other file", []byte("other raw data")) -``` - -If you have a list of files with possibilities that some of them may not available at the time, and you don't know exactly which ones, you can use `LooseLoad` to ignore nonexistent files without returning error. - -```go -cfg, err := ini.LooseLoad("filename", "filename_404") -``` - -The cool thing is, whenever the file is available to load while you're calling `Reload` method, it will be counted as usual. - -### Working with sections - -To get a section, you would need to: - -```go -section, err := cfg.GetSection("section name") -``` - -For a shortcut for default section, just give an empty string as name: - -```go -section, err := cfg.GetSection("") -``` - -When you're pretty sure the section exists, following code could make your life easier: - -```go -section := cfg.Section("") -``` - -What happens when the section somehow does not exist? Don't panic, it automatically creates and returns a new section to you. - -To create a new section: - -```go -err := cfg.NewSection("new section") -``` - -To get a list of sections or section names: - -```go -sections := cfg.Sections() -names := cfg.SectionStrings() -``` - -### Working with keys - -To get a key under a section: - -```go -key, err := cfg.Section("").GetKey("key name") -``` - -Same rule applies to key operations: - -```go -key := cfg.Section("").Key("key name") -``` - -To check if a key exists: - -```go -yes := cfg.Section("").HasKey("key name") -``` - -To create a new key: - -```go -err := cfg.Section("").NewKey("name", "value") -``` - -To get a list of keys or key names: - -```go -keys := cfg.Section("").Keys() -names := cfg.Section("").KeyStrings() -``` - -To get a clone hash of keys and corresponding values: - -```go -hash := cfg.GetSection("").KeysHash() -``` - -### Working with values - -To get a string value: - -```go -val := cfg.Section("").Key("key name").String() -``` - -To validate key value on the fly: - -```go -val := cfg.Section("").Key("key name").Validate(func(in string) string { - if len(in) == 0 { - return "default" - } - return in -}) -``` - -If you do not want any auto-transformation (such as recursive read) for the values, you can get raw value directly (this way you get much better performance): - -```go -val := cfg.Section("").Key("key name").Value() -``` - -To check if raw value exists: - -```go -yes := cfg.Section("").HasValue("test value") -``` - -To get value with types: - -```go -// For boolean values: -// true when value is: 1, t, T, TRUE, true, True, YES, yes, Yes, y, ON, on, On -// false when value is: 0, f, F, FALSE, false, False, NO, no, No, n, OFF, off, Off -v, err = cfg.Section("").Key("BOOL").Bool() -v, err = cfg.Section("").Key("FLOAT64").Float64() -v, err = cfg.Section("").Key("INT").Int() -v, err = cfg.Section("").Key("INT64").Int64() -v, err = cfg.Section("").Key("UINT").Uint() -v, err = cfg.Section("").Key("UINT64").Uint64() -v, err = cfg.Section("").Key("TIME").TimeFormat(time.RFC3339) -v, err = cfg.Section("").Key("TIME").Time() // RFC3339 - -v = cfg.Section("").Key("BOOL").MustBool() -v = cfg.Section("").Key("FLOAT64").MustFloat64() -v = cfg.Section("").Key("INT").MustInt() -v = cfg.Section("").Key("INT64").MustInt64() -v = cfg.Section("").Key("UINT").MustUint() -v = cfg.Section("").Key("UINT64").MustUint64() -v = cfg.Section("").Key("TIME").MustTimeFormat(time.RFC3339) -v = cfg.Section("").Key("TIME").MustTime() // RFC3339 - -// Methods start with Must also accept one argument for default value -// when key not found or fail to parse value to given type. -// Except method MustString, which you have to pass a default value. - -v = cfg.Section("").Key("String").MustString("default") -v = cfg.Section("").Key("BOOL").MustBool(true) -v = cfg.Section("").Key("FLOAT64").MustFloat64(1.25) -v = cfg.Section("").Key("INT").MustInt(10) -v = cfg.Section("").Key("INT64").MustInt64(99) -v = cfg.Section("").Key("UINT").MustUint(3) -v = cfg.Section("").Key("UINT64").MustUint64(6) -v = cfg.Section("").Key("TIME").MustTimeFormat(time.RFC3339, time.Now()) -v = cfg.Section("").Key("TIME").MustTime(time.Now()) // RFC3339 -``` - -What if my value is three-line long? - -```ini -[advance] -ADDRESS = """404 road, -NotFound, State, 5000 -Earth""" -``` - -Not a problem! - -```go -cfg.Section("advance").Key("ADDRESS").String() - -/* --- start --- -404 road, -NotFound, State, 5000 -Earth ------- end --- */ -``` - -That's cool, how about continuation lines? - -```ini -[advance] -two_lines = how about \ - continuation lines? -lots_of_lines = 1 \ - 2 \ - 3 \ - 4 -``` - -Piece of cake! - -```go -cfg.Section("advance").Key("two_lines").String() // how about continuation lines? -cfg.Section("advance").Key("lots_of_lines").String() // 1 2 3 4 -``` - -Note that single quotes around values will be stripped: - -```ini -foo = "some value" // foo: some value -bar = 'some value' // bar: some value -``` - -That's all? Hmm, no. - -#### Helper methods of working with values - -To get value with given candidates: - -```go -v = cfg.Section("").Key("STRING").In("default", []string{"str", "arr", "types"}) -v = cfg.Section("").Key("FLOAT64").InFloat64(1.1, []float64{1.25, 2.5, 3.75}) -v = cfg.Section("").Key("INT").InInt(5, []int{10, 20, 30}) -v = cfg.Section("").Key("INT64").InInt64(10, []int64{10, 20, 30}) -v = cfg.Section("").Key("UINT").InUint(4, []int{3, 6, 9}) -v = cfg.Section("").Key("UINT64").InUint64(8, []int64{3, 6, 9}) -v = cfg.Section("").Key("TIME").InTimeFormat(time.RFC3339, time.Now(), []time.Time{time1, time2, time3}) -v = cfg.Section("").Key("TIME").InTime(time.Now(), []time.Time{time1, time2, time3}) // RFC3339 -``` - -Default value will be presented if value of key is not in candidates you given, and default value does not need be one of candidates. - -To validate value in a given range: - -```go -vals = cfg.Section("").Key("FLOAT64").RangeFloat64(0.0, 1.1, 2.2) -vals = cfg.Section("").Key("INT").RangeInt(0, 10, 20) -vals = cfg.Section("").Key("INT64").RangeInt64(0, 10, 20) -vals = cfg.Section("").Key("UINT").RangeUint(0, 3, 9) -vals = cfg.Section("").Key("UINT64").RangeUint64(0, 3, 9) -vals = cfg.Section("").Key("TIME").RangeTimeFormat(time.RFC3339, time.Now(), minTime, maxTime) -vals = cfg.Section("").Key("TIME").RangeTime(time.Now(), minTime, maxTime) // RFC3339 -``` - -##### Auto-split values into a slice - -To use zero value of type for invalid inputs: - -```go -// Input: 1.1, 2.2, 3.3, 4.4 -> [1.1 2.2 3.3 4.4] -// Input: how, 2.2, are, you -> [0.0 2.2 0.0 0.0] -vals = cfg.Section("").Key("STRINGS").Strings(",") -vals = cfg.Section("").Key("FLOAT64S").Float64s(",") -vals = cfg.Section("").Key("INTS").Ints(",") -vals = cfg.Section("").Key("INT64S").Int64s(",") -vals = cfg.Section("").Key("UINTS").Uints(",") -vals = cfg.Section("").Key("UINT64S").Uint64s(",") -vals = cfg.Section("").Key("TIMES").Times(",") -``` - -To exclude invalid values out of result slice: - -```go -// Input: 1.1, 2.2, 3.3, 4.4 -> [1.1 2.2 3.3 4.4] -// Input: how, 2.2, are, you -> [2.2] -vals = cfg.Section("").Key("FLOAT64S").ValidFloat64s(",") -vals = cfg.Section("").Key("INTS").ValidInts(",") -vals = cfg.Section("").Key("INT64S").ValidInt64s(",") -vals = cfg.Section("").Key("UINTS").ValidUints(",") -vals = cfg.Section("").Key("UINT64S").ValidUint64s(",") -vals = cfg.Section("").Key("TIMES").ValidTimes(",") -``` - -Or to return nothing but error when have invalid inputs: - -```go -// Input: 1.1, 2.2, 3.3, 4.4 -> [1.1 2.2 3.3 4.4] -// Input: how, 2.2, are, you -> error -vals = cfg.Section("").Key("FLOAT64S").StrictFloat64s(",") -vals = cfg.Section("").Key("INTS").StrictInts(",") -vals = cfg.Section("").Key("INT64S").StrictInt64s(",") -vals = cfg.Section("").Key("UINTS").StrictUints(",") -vals = cfg.Section("").Key("UINT64S").StrictUint64s(",") -vals = cfg.Section("").Key("TIMES").StrictTimes(",") -``` - -### Save your configuration - -Finally, it's time to save your configuration to somewhere. - -A typical way to save configuration is writing it to a file: - -```go -// ... -err = cfg.SaveTo("my.ini") -err = cfg.SaveToIndent("my.ini", "\t") -``` - -Another way to save is writing to a `io.Writer` interface: - -```go -// ... -cfg.WriteTo(writer) -cfg.WriteToIndent(writer, "\t") -``` - -## Advanced Usage - -### Recursive Values - -For all value of keys, there is a special syntax `%()s`, where `` is the key name in same section or default section, and `%()s` will be replaced by corresponding value(empty string if key not found). You can use this syntax at most 99 level of recursions. - -```ini -NAME = ini - -[author] -NAME = Unknwon -GITHUB = https://github.com/%(NAME)s - -[package] -FULL_NAME = github.com/go-ini/%(NAME)s -``` - -```go -cfg.Section("author").Key("GITHUB").String() // https://github.com/Unknwon -cfg.Section("package").Key("FULL_NAME").String() // github.com/go-ini/ini -``` - -### Parent-child Sections - -You can use `.` in section name to indicate parent-child relationship between two or more sections. If the key not found in the child section, library will try again on its parent section until there is no parent section. - -```ini -NAME = ini -VERSION = v1 -IMPORT_PATH = gopkg.in/%(NAME)s.%(VERSION)s - -[package] -CLONE_URL = https://%(IMPORT_PATH)s - -[package.sub] -``` - -```go -cfg.Section("package.sub").Key("CLONE_URL").String() // https://gopkg.in/ini.v1 -``` - -### Auto-increment Key Names - -If key name is `-` in data source, then it would be seen as special syntax for auto-increment key name start from 1, and every section is independent on counter. - -```ini -[features] --: Support read/write comments of keys and sections --: Support auto-increment of key names --: Support load multiple files to overwrite key values -``` - -```go -cfg.Section("features").KeyStrings() // []{"#1", "#2", "#3"} -``` - -### Map To Struct - -Want more objective way to play with INI? Cool. - -```ini -Name = Unknwon -age = 21 -Male = true -Born = 1993-01-01T20:17:05Z - -[Note] -Content = Hi is a good man! -Cities = HangZhou, Boston -``` - -```go -type Note struct { - Content string - Cities []string -} - -type Person struct { - Name string - Age int `ini:"age"` - Male bool - Born time.Time - Note - Created time.Time `ini:"-"` -} - -func main() { - cfg, err := ini.Load("path/to/ini") - // ... - p := new(Person) - err = cfg.MapTo(p) - // ... - - // Things can be simpler. - err = ini.MapTo(p, "path/to/ini") - // ... - - // Just map a section? Fine. - n := new(Note) - err = cfg.Section("Note").MapTo(n) - // ... -} -``` - -Can I have default value for field? Absolutely. - -Assign it before you map to struct. It will keep the value as it is if the key is not presented or got wrong type. - -```go -// ... -p := &Person{ - Name: "Joe", -} -// ... -``` - -It's really cool, but what's the point if you can't give me my file back from struct? - -### Reflect From Struct - -Why not? - -```go -type Embeded struct { - Dates []time.Time `delim:"|"` - Places []string - None []int -} - -type Author struct { - Name string `ini:"NAME"` - Male bool - Age int - GPA float64 - NeverMind string `ini:"-"` - *Embeded -} - -func main() { - a := &Author{"Unknwon", true, 21, 2.8, "", - &Embeded{ - []time.Time{time.Now(), time.Now()}, - []string{"HangZhou", "Boston"}, - []int{}, - }} - cfg := ini.Empty() - err = ini.ReflectFrom(cfg, a) - // ... -} -``` - -So, what do I get? - -```ini -NAME = Unknwon -Male = true -Age = 21 -GPA = 2.8 - -[Embeded] -Dates = 2015-08-07T22:14:22+08:00|2015-08-07T22:14:22+08:00 -Places = HangZhou,Boston -None = -``` - -#### Name Mapper - -To save your time and make your code cleaner, this library supports [`NameMapper`](https://gowalker.org/gopkg.in/ini.v1#NameMapper) between struct field and actual section and key name. - -There are 2 built-in name mappers: - -- `AllCapsUnderscore`: it converts to format `ALL_CAPS_UNDERSCORE` then match section or key. -- `TitleUnderscore`: it converts to format `title_underscore` then match section or key. - -To use them: - -```go -type Info struct { - PackageName string -} - -func main() { - err = ini.MapToWithMapper(&Info{}, ini.TitleUnderscore, []byte("package_name=ini")) - // ... - - cfg, err := ini.Load([]byte("PACKAGE_NAME=ini")) - // ... - info := new(Info) - cfg.NameMapper = ini.AllCapsUnderscore - err = cfg.MapTo(info) - // ... -} -``` - -Same rules of name mapper apply to `ini.ReflectFromWithMapper` function. - -#### Other Notes On Map/Reflect - -Any embedded struct is treated as a section by default, and there is no automatic parent-child relations in map/reflect feature: - -```go -type Child struct { - Age string -} - -type Parent struct { - Name string - Child -} - -type Config struct { - City string - Parent -} -``` - -Example configuration: - -```ini -City = Boston - -[Parent] -Name = Unknwon - -[Child] -Age = 21 -``` - -What if, yes, I'm paranoid, I want embedded struct to be in the same section. Well, all roads lead to Rome. - -```go -type Child struct { - Age string -} - -type Parent struct { - Name string - Child `ini:"Parent"` -} - -type Config struct { - City string - Parent -} -``` - -Example configuration: - -```ini -City = Boston - -[Parent] -Name = Unknwon -Age = 21 -``` - -## Getting Help - -- [API Documentation](https://gowalker.org/gopkg.in/ini.v1) -- [File An Issue](https://github.com/go-ini/ini/issues/new) - -## FAQs - -### What does `BlockMode` field do? - -By default, library lets you read and write values so we need a locker to make sure your data is safe. But in cases that you are very sure about only reading data through the library, you can set `cfg.BlockMode = false` to speed up read operations about **50-70%** faster. - -### Why another INI library? - -Many people are using my another INI library [goconfig](https://github.com/Unknwon/goconfig), so the reason for this one is I would like to make more Go style code. Also when you set `cfg.BlockMode = false`, this one is about **10-30%** faster. - -To make those changes I have to confirm API broken, so it's safer to keep it in another place and start using `gopkg.in` to version my package at this time.(PS: shorter import path) - -## License - -This project is under Apache v2 License. See the [LICENSE](LICENSE) file for the full license text. diff --git a/Godeps/_workspace/src/github.com/go-ini/ini/README_ZH.md b/Godeps/_workspace/src/github.com/go-ini/ini/README_ZH.md deleted file mode 100644 index 75c10051a1..0000000000 --- a/Godeps/_workspace/src/github.com/go-ini/ini/README_ZH.md +++ /dev/null @@ -1,619 +0,0 @@ -本包提供了 Go 语言中读写 INI 文件的功能。 - -## 功能特性 - -- 支持覆盖加载多个数据源(`[]byte` 或文件) -- 支持递归读取键值 -- 支持读取父子分区 -- 支持读取自增键名 -- 支持读取多行的键值 -- 支持大量辅助方法 -- 支持在读取时直接转换为 Go 语言类型 -- 支持读取和 **写入** 分区和键的注释 -- 轻松操作分区、键值和注释 -- 在保存文件时分区和键值会保持原有的顺序 - -## 下载安装 - -使用一个特定版本: - - go get gopkg.in/ini.v1 - -使用最新版: - - go get github.com/go-ini/ini - -如需更新请添加 `-u` 选项。 - -### 测试安装 - -如果您想要在自己的机器上运行测试,请使用 `-t` 标记: - - go get -t gopkg.in/ini.v1 - -如需更新请添加 `-u` 选项。 - -## 开始使用 - -### 从数据源加载 - -一个 **数据源** 可以是 `[]byte` 类型的原始数据,或 `string` 类型的文件路径。您可以加载 **任意多个** 数据源。如果您传递其它类型的数据源,则会直接返回错误。 - -```go -cfg, err := ini.Load([]byte("raw data"), "filename") -``` - -或者从一个空白的文件开始: - -```go -cfg := ini.Empty() -``` - -当您在一开始无法决定需要加载哪些数据源时,仍可以使用 **Append()** 在需要的时候加载它们。 - -```go -err := cfg.Append("other file", []byte("other raw data")) -``` - -当您想要加载一系列文件,但是不能够确定其中哪些文件是不存在的,可以通过调用函数 `LooseLoad` 来忽略它们(`Load` 会因为文件不存在而返回错误): - -```go -cfg, err := ini.LooseLoad("filename", "filename_404") -``` - -更牛逼的是,当那些之前不存在的文件在重新调用 `Reload` 方法的时候突然出现了,那么它们会被正常加载。 - -### 操作分区(Section) - -获取指定分区: - -```go -section, err := cfg.GetSection("section name") -``` - -如果您想要获取默认分区,则可以用空字符串代替分区名: - -```go -section, err := cfg.GetSection("") -``` - -当您非常确定某个分区是存在的,可以使用以下简便方法: - -```go -section := cfg.Section("") -``` - -如果不小心判断错了,要获取的分区其实是不存在的,那会发生什么呢?没事的,它会自动创建并返回一个对应的分区对象给您。 - -创建一个分区: - -```go -err := cfg.NewSection("new section") -``` - -获取所有分区对象或名称: - -```go -sections := cfg.Sections() -names := cfg.SectionStrings() -``` - -### 操作键(Key) - -获取某个分区下的键: - -```go -key, err := cfg.Section("").GetKey("key name") -``` - -和分区一样,您也可以直接获取键而忽略错误处理: - -```go -key := cfg.Section("").Key("key name") -``` - -判断某个键是否存在: - -```go -yes := cfg.Section("").HasKey("key name") -``` - -创建一个新的键: - -```go -err := cfg.Section("").NewKey("name", "value") -``` - -获取分区下的所有键或键名: - -```go -keys := cfg.Section("").Keys() -names := cfg.Section("").KeyStrings() -``` - -获取分区下的所有键值对的克隆: - -```go -hash := cfg.GetSection("").KeysHash() -``` - -### 操作键值(Value) - -获取一个类型为字符串(string)的值: - -```go -val := cfg.Section("").Key("key name").String() -``` - -获取值的同时通过自定义函数进行处理验证: - -```go -val := cfg.Section("").Key("key name").Validate(func(in string) string { - if len(in) == 0 { - return "default" - } - return in -}) -``` - -如果您不需要任何对值的自动转变功能(例如递归读取),可以直接获取原值(这种方式性能最佳): - -```go -val := cfg.Section("").Key("key name").Value() -``` - -判断某个原值是否存在: - -```go -yes := cfg.Section("").HasValue("test value") -``` - -获取其它类型的值: - -```go -// 布尔值的规则: -// true 当值为:1, t, T, TRUE, true, True, YES, yes, Yes, y, ON, on, On -// false 当值为:0, f, F, FALSE, false, False, NO, no, No, n, OFF, off, Off -v, err = cfg.Section("").Key("BOOL").Bool() -v, err = cfg.Section("").Key("FLOAT64").Float64() -v, err = cfg.Section("").Key("INT").Int() -v, err = cfg.Section("").Key("INT64").Int64() -v, err = cfg.Section("").Key("UINT").Uint() -v, err = cfg.Section("").Key("UINT64").Uint64() -v, err = cfg.Section("").Key("TIME").TimeFormat(time.RFC3339) -v, err = cfg.Section("").Key("TIME").Time() // RFC3339 - -v = cfg.Section("").Key("BOOL").MustBool() -v = cfg.Section("").Key("FLOAT64").MustFloat64() -v = cfg.Section("").Key("INT").MustInt() -v = cfg.Section("").Key("INT64").MustInt64() -v = cfg.Section("").Key("UINT").MustUint() -v = cfg.Section("").Key("UINT64").MustUint64() -v = cfg.Section("").Key("TIME").MustTimeFormat(time.RFC3339) -v = cfg.Section("").Key("TIME").MustTime() // RFC3339 - -// 由 Must 开头的方法名允许接收一个相同类型的参数来作为默认值, -// 当键不存在或者转换失败时,则会直接返回该默认值。 -// 但是,MustString 方法必须传递一个默认值。 - -v = cfg.Seciont("").Key("String").MustString("default") -v = cfg.Section("").Key("BOOL").MustBool(true) -v = cfg.Section("").Key("FLOAT64").MustFloat64(1.25) -v = cfg.Section("").Key("INT").MustInt(10) -v = cfg.Section("").Key("INT64").MustInt64(99) -v = cfg.Section("").Key("UINT").MustUint(3) -v = cfg.Section("").Key("UINT64").MustUint64(6) -v = cfg.Section("").Key("TIME").MustTimeFormat(time.RFC3339, time.Now()) -v = cfg.Section("").Key("TIME").MustTime(time.Now()) // RFC3339 -``` - -如果我的值有好多行怎么办? - -```ini -[advance] -ADDRESS = """404 road, -NotFound, State, 5000 -Earth""" -``` - -嗯哼?小 case! - -```go -cfg.Section("advance").Key("ADDRESS").String() - -/* --- start --- -404 road, -NotFound, State, 5000 -Earth ------- end --- */ -``` - -赞爆了!那要是我属于一行的内容写不下想要写到第二行怎么办? - -```ini -[advance] -two_lines = how about \ - continuation lines? -lots_of_lines = 1 \ - 2 \ - 3 \ - 4 -``` - -简直是小菜一碟! - -```go -cfg.Section("advance").Key("two_lines").String() // how about continuation lines? -cfg.Section("advance").Key("lots_of_lines").String() // 1 2 3 4 -``` - -需要注意的是,值两侧的单引号会被自动剔除: - -```ini -foo = "some value" // foo: some value -bar = 'some value' // bar: some value -``` - -这就是全部了?哈哈,当然不是。 - -#### 操作键值的辅助方法 - -获取键值时设定候选值: - -```go -v = cfg.Section("").Key("STRING").In("default", []string{"str", "arr", "types"}) -v = cfg.Section("").Key("FLOAT64").InFloat64(1.1, []float64{1.25, 2.5, 3.75}) -v = cfg.Section("").Key("INT").InInt(5, []int{10, 20, 30}) -v = cfg.Section("").Key("INT64").InInt64(10, []int64{10, 20, 30}) -v = cfg.Section("").Key("UINT").InUint(4, []int{3, 6, 9}) -v = cfg.Section("").Key("UINT64").InUint64(8, []int64{3, 6, 9}) -v = cfg.Section("").Key("TIME").InTimeFormat(time.RFC3339, time.Now(), []time.Time{time1, time2, time3}) -v = cfg.Section("").Key("TIME").InTime(time.Now(), []time.Time{time1, time2, time3}) // RFC3339 -``` - -如果获取到的值不是候选值的任意一个,则会返回默认值,而默认值不需要是候选值中的一员。 - -验证获取的值是否在指定范围内: - -```go -vals = cfg.Section("").Key("FLOAT64").RangeFloat64(0.0, 1.1, 2.2) -vals = cfg.Section("").Key("INT").RangeInt(0, 10, 20) -vals = cfg.Section("").Key("INT64").RangeInt64(0, 10, 20) -vals = cfg.Section("").Key("UINT").RangeUint(0, 3, 9) -vals = cfg.Section("").Key("UINT64").RangeUint64(0, 3, 9) -vals = cfg.Section("").Key("TIME").RangeTimeFormat(time.RFC3339, time.Now(), minTime, maxTime) -vals = cfg.Section("").Key("TIME").RangeTime(time.Now(), minTime, maxTime) // RFC3339 -``` - -##### 自动分割键值到切片(slice) - -当存在无效输入时,使用零值代替: - -```go -// Input: 1.1, 2.2, 3.3, 4.4 -> [1.1 2.2 3.3 4.4] -// Input: how, 2.2, are, you -> [0.0 2.2 0.0 0.0] -vals = cfg.Section("").Key("STRINGS").Strings(",") -vals = cfg.Section("").Key("FLOAT64S").Float64s(",") -vals = cfg.Section("").Key("INTS").Ints(",") -vals = cfg.Section("").Key("INT64S").Int64s(",") -vals = cfg.Section("").Key("UINTS").Uints(",") -vals = cfg.Section("").Key("UINT64S").Uint64s(",") -vals = cfg.Section("").Key("TIMES").Times(",") -``` - -从结果切片中剔除无效输入: - -```go -// Input: 1.1, 2.2, 3.3, 4.4 -> [1.1 2.2 3.3 4.4] -// Input: how, 2.2, are, you -> [2.2] -vals = cfg.Section("").Key("FLOAT64S").ValidFloat64s(",") -vals = cfg.Section("").Key("INTS").ValidInts(",") -vals = cfg.Section("").Key("INT64S").ValidInt64s(",") -vals = cfg.Section("").Key("UINTS").ValidUints(",") -vals = cfg.Section("").Key("UINT64S").ValidUint64s(",") -vals = cfg.Section("").Key("TIMES").ValidTimes(",") -``` - -当存在无效输入时,直接返回错误: - -```go -// Input: 1.1, 2.2, 3.3, 4.4 -> [1.1 2.2 3.3 4.4] -// Input: how, 2.2, are, you -> error -vals = cfg.Section("").Key("FLOAT64S").StrictFloat64s(",") -vals = cfg.Section("").Key("INTS").StrictInts(",") -vals = cfg.Section("").Key("INT64S").StrictInt64s(",") -vals = cfg.Section("").Key("UINTS").StrictUints(",") -vals = cfg.Section("").Key("UINT64S").StrictUint64s(",") -vals = cfg.Section("").Key("TIMES").StrictTimes(",") -``` - -### 保存配置 - -终于到了这个时刻,是时候保存一下配置了。 - -比较原始的做法是输出配置到某个文件: - -```go -// ... -err = cfg.SaveTo("my.ini") -err = cfg.SaveToIndent("my.ini", "\t") -``` - -另一个比较高级的做法是写入到任何实现 `io.Writer` 接口的对象中: - -```go -// ... -cfg.WriteTo(writer) -cfg.WriteToIndent(writer, "\t") -``` - -### 高级用法 - -#### 递归读取键值 - -在获取所有键值的过程中,特殊语法 `%()s` 会被应用,其中 `` 可以是相同分区或者默认分区下的键名。字符串 `%()s` 会被相应的键值所替代,如果指定的键不存在,则会用空字符串替代。您可以最多使用 99 层的递归嵌套。 - -```ini -NAME = ini - -[author] -NAME = Unknwon -GITHUB = https://github.com/%(NAME)s - -[package] -FULL_NAME = github.com/go-ini/%(NAME)s -``` - -```go -cfg.Section("author").Key("GITHUB").String() // https://github.com/Unknwon -cfg.Section("package").Key("FULL_NAME").String() // github.com/go-ini/ini -``` - -#### 读取父子分区 - -您可以在分区名称中使用 `.` 来表示两个或多个分区之间的父子关系。如果某个键在子分区中不存在,则会去它的父分区中再次寻找,直到没有父分区为止。 - -```ini -NAME = ini -VERSION = v1 -IMPORT_PATH = gopkg.in/%(NAME)s.%(VERSION)s - -[package] -CLONE_URL = https://%(IMPORT_PATH)s - -[package.sub] -``` - -```go -cfg.Section("package.sub").Key("CLONE_URL").String() // https://gopkg.in/ini.v1 -``` - -#### 读取自增键名 - -如果数据源中的键名为 `-`,则认为该键使用了自增键名的特殊语法。计数器从 1 开始,并且分区之间是相互独立的。 - -```ini -[features] --: Support read/write comments of keys and sections --: Support auto-increment of key names --: Support load multiple files to overwrite key values -``` - -```go -cfg.Section("features").KeyStrings() // []{"#1", "#2", "#3"} -``` - -### 映射到结构 - -想要使用更加面向对象的方式玩转 INI 吗?好主意。 - -```ini -Name = Unknwon -age = 21 -Male = true -Born = 1993-01-01T20:17:05Z - -[Note] -Content = Hi is a good man! -Cities = HangZhou, Boston -``` - -```go -type Note struct { - Content string - Cities []string -} - -type Person struct { - Name string - Age int `ini:"age"` - Male bool - Born time.Time - Note - Created time.Time `ini:"-"` -} - -func main() { - cfg, err := ini.Load("path/to/ini") - // ... - p := new(Person) - err = cfg.MapTo(p) - // ... - - // 一切竟可以如此的简单。 - err = ini.MapTo(p, "path/to/ini") - // ... - - // 嗯哼?只需要映射一个分区吗? - n := new(Note) - err = cfg.Section("Note").MapTo(n) - // ... -} -``` - -结构的字段怎么设置默认值呢?很简单,只要在映射之前对指定字段进行赋值就可以了。如果键未找到或者类型错误,该值不会发生改变。 - -```go -// ... -p := &Person{ - Name: "Joe", -} -// ... -``` - -这样玩 INI 真的好酷啊!然而,如果不能还给我原来的配置文件,有什么卵用? - -### 从结构反射 - -可是,我有说不能吗? - -```go -type Embeded struct { - Dates []time.Time `delim:"|"` - Places []string - None []int -} - -type Author struct { - Name string `ini:"NAME"` - Male bool - Age int - GPA float64 - NeverMind string `ini:"-"` - *Embeded -} - -func main() { - a := &Author{"Unknwon", true, 21, 2.8, "", - &Embeded{ - []time.Time{time.Now(), time.Now()}, - []string{"HangZhou", "Boston"}, - []int{}, - }} - cfg := ini.Empty() - err = ini.ReflectFrom(cfg, a) - // ... -} -``` - -瞧瞧,奇迹发生了。 - -```ini -NAME = Unknwon -Male = true -Age = 21 -GPA = 2.8 - -[Embeded] -Dates = 2015-08-07T22:14:22+08:00|2015-08-07T22:14:22+08:00 -Places = HangZhou,Boston -None = -``` - -#### 名称映射器(Name Mapper) - -为了节省您的时间并简化代码,本库支持类型为 [`NameMapper`](https://gowalker.org/gopkg.in/ini.v1#NameMapper) 的名称映射器,该映射器负责结构字段名与分区名和键名之间的映射。 - -目前有 2 款内置的映射器: - -- `AllCapsUnderscore`:该映射器将字段名转换至格式 `ALL_CAPS_UNDERSCORE` 后再去匹配分区名和键名。 -- `TitleUnderscore`:该映射器将字段名转换至格式 `title_underscore` 后再去匹配分区名和键名。 - -使用方法: - -```go -type Info struct{ - PackageName string -} - -func main() { - err = ini.MapToWithMapper(&Info{}, ini.TitleUnderscore, []byte("package_name=ini")) - // ... - - cfg, err := ini.Load([]byte("PACKAGE_NAME=ini")) - // ... - info := new(Info) - cfg.NameMapper = ini.AllCapsUnderscore - err = cfg.MapTo(info) - // ... -} -``` - -使用函数 `ini.ReflectFromWithMapper` 时也可应用相同的规则。 - -#### 映射/反射的其它说明 - -任何嵌入的结构都会被默认认作一个不同的分区,并且不会自动产生所谓的父子分区关联: - -```go -type Child struct { - Age string -} - -type Parent struct { - Name string - Child -} - -type Config struct { - City string - Parent -} -``` - -示例配置文件: - -```ini -City = Boston - -[Parent] -Name = Unknwon - -[Child] -Age = 21 -``` - -很好,但是,我就是要嵌入结构也在同一个分区。好吧,你爹是李刚! - -```go -type Child struct { - Age string -} - -type Parent struct { - Name string - Child `ini:"Parent"` -} - -type Config struct { - City string - Parent -} -``` - -示例配置文件: - -```ini -City = Boston - -[Parent] -Name = Unknwon -Age = 21 -``` - -## 获取帮助 - -- [API 文档](https://gowalker.org/gopkg.in/ini.v1) -- [创建工单](https://github.com/go-ini/ini/issues/new) - -## 常见问题 - -### 字段 `BlockMode` 是什么? - -默认情况下,本库会在您进行读写操作时采用锁机制来确保数据时间。但在某些情况下,您非常确定只进行读操作。此时,您可以通过设置 `cfg.BlockMode = false` 来将读操作提升大约 **50-70%** 的性能。 - -### 为什么要写另一个 INI 解析库? - -许多人都在使用我的 [goconfig](https://github.com/Unknwon/goconfig) 来完成对 INI 文件的操作,但我希望使用更加 Go 风格的代码。并且当您设置 `cfg.BlockMode = false` 时,会有大约 **10-30%** 的性能提升。 - -为了做出这些改变,我必须对 API 进行破坏,所以新开一个仓库是最安全的做法。除此之外,本库直接使用 `gopkg.in` 来进行版本化发布。(其实真相是导入路径更短了) diff --git a/Godeps/_workspace/src/github.com/go-ini/ini/ini.go b/Godeps/_workspace/src/github.com/go-ini/ini/ini.go deleted file mode 100644 index f186148aad..0000000000 --- a/Godeps/_workspace/src/github.com/go-ini/ini/ini.go +++ /dev/null @@ -1,465 +0,0 @@ -// Copyright 2014 Unknwon -// -// Licensed under the Apache License, Version 2.0 (the "License"): you may -// not use this file except in compliance with the License. You may obtain -// a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -// License for the specific language governing permissions and limitations -// under the License. - -// Package ini provides INI file read and write functionality in Go. -package ini - -import ( - "bytes" - "errors" - "fmt" - "io" - "os" - "regexp" - "runtime" - "strconv" - "strings" - "sync" - "time" -) - -const ( - // Name for default section. You can use this constant or the string literal. - // In most of cases, an empty string is all you need to access the section. - DEFAULT_SECTION = "DEFAULT" - - // Maximum allowed depth when recursively substituing variable names. - _DEPTH_VALUES = 99 - _VERSION = "1.11.0" -) - -// Version returns current package version literal. -func Version() string { - return _VERSION -} - -var ( - // Delimiter to determine or compose a new line. - // This variable will be changed to "\r\n" automatically on Windows - // at package init time. - LineBreak = "\n" - - // Variable regexp pattern: %(variable)s - varPattern = regexp.MustCompile(`%\(([^\)]+)\)s`) - - // Indicate whether to align "=" sign with spaces to produce pretty output - // or reduce all possible spaces for compact format. - PrettyFormat = true - - // Explicitly write DEFAULT section header - DefaultHeader = false -) - -func init() { - if runtime.GOOS == "windows" { - LineBreak = "\r\n" - } -} - -func inSlice(str string, s []string) bool { - for _, v := range s { - if str == v { - return true - } - } - return false -} - -// dataSource is an interface that returns object which can be read and closed. -type dataSource interface { - ReadCloser() (io.ReadCloser, error) -} - -// sourceFile represents an object that contains content on the local file system. -type sourceFile struct { - name string -} - -func (s sourceFile) ReadCloser() (_ io.ReadCloser, err error) { - return os.Open(s.name) -} - -type bytesReadCloser struct { - reader io.Reader -} - -func (rc *bytesReadCloser) Read(p []byte) (n int, err error) { - return rc.reader.Read(p) -} - -func (rc *bytesReadCloser) Close() error { - return nil -} - -// sourceData represents an object that contains content in memory. -type sourceData struct { - data []byte -} - -func (s *sourceData) ReadCloser() (io.ReadCloser, error) { - return &bytesReadCloser{bytes.NewReader(s.data)}, nil -} - -// File represents a combination of a or more INI file(s) in memory. -type File struct { - // Should make things safe, but sometimes doesn't matter. - BlockMode bool - // Make sure data is safe in multiple goroutines. - lock sync.RWMutex - - // Allow combination of multiple data sources. - dataSources []dataSource - // Actual data is stored here. - sections map[string]*Section - - // To keep data in order. - sectionList []string - - // Whether the parser should ignore nonexistent files or return error. - looseMode bool - - NameMapper -} - -// newFile initializes File object with given data sources. -func newFile(dataSources []dataSource, looseMode bool) *File { - return &File{ - BlockMode: true, - dataSources: dataSources, - sections: make(map[string]*Section), - sectionList: make([]string, 0, 10), - looseMode: looseMode, - } -} - -func parseDataSource(source interface{}) (dataSource, error) { - switch s := source.(type) { - case string: - return sourceFile{s}, nil - case []byte: - return &sourceData{s}, nil - default: - return nil, fmt.Errorf("error parsing data source: unknown type '%s'", s) - } -} - -func loadSources(looseMode bool, source interface{}, others ...interface{}) (_ *File, err error) { - sources := make([]dataSource, len(others)+1) - sources[0], err = parseDataSource(source) - if err != nil { - return nil, err - } - for i := range others { - sources[i+1], err = parseDataSource(others[i]) - if err != nil { - return nil, err - } - } - f := newFile(sources, looseMode) - if err = f.Reload(); err != nil { - return nil, err - } - return f, nil -} - -// Load loads and parses from INI data sources. -// Arguments can be mixed of file name with string type, or raw data in []byte. -// It will return error if list contains nonexistent files. -func Load(source interface{}, others ...interface{}) (*File, error) { - return loadSources(false, source, others...) -} - -// LooseLoad has exactly same functionality as Load function -// except it ignores nonexistent files instead of returning error. -func LooseLoad(source interface{}, others ...interface{}) (*File, error) { - return loadSources(true, source, others...) -} - -// Empty returns an empty file object. -func Empty() *File { - // Ignore error here, we sure our data is good. - f, _ := Load([]byte("")) - return f -} - -// NewSection creates a new section. -func (f *File) NewSection(name string) (*Section, error) { - if len(name) == 0 { - return nil, errors.New("error creating new section: empty section name") - } - - if f.BlockMode { - f.lock.Lock() - defer f.lock.Unlock() - } - - if inSlice(name, f.sectionList) { - return f.sections[name], nil - } - - f.sectionList = append(f.sectionList, name) - f.sections[name] = newSection(f, name) - return f.sections[name], nil -} - -// NewSections creates a list of sections. -func (f *File) NewSections(names ...string) (err error) { - for _, name := range names { - if _, err = f.NewSection(name); err != nil { - return err - } - } - return nil -} - -// GetSection returns section by given name. -func (f *File) GetSection(name string) (*Section, error) { - if len(name) == 0 { - name = DEFAULT_SECTION - } - - if f.BlockMode { - f.lock.RLock() - defer f.lock.RUnlock() - } - - sec := f.sections[name] - if sec == nil { - return nil, fmt.Errorf("section '%s' does not exist", name) - } - return sec, nil -} - -// Section assumes named section exists and returns a zero-value when not. -func (f *File) Section(name string) *Section { - sec, err := f.GetSection(name) - if err != nil { - // Note: It's OK here because the only possible error is empty section name, - // but if it's empty, this piece of code won't be executed. - sec, _ = f.NewSection(name) - return sec - } - return sec -} - -// Section returns list of Section. -func (f *File) Sections() []*Section { - sections := make([]*Section, len(f.sectionList)) - for i := range f.sectionList { - sections[i] = f.Section(f.sectionList[i]) - } - return sections -} - -// SectionStrings returns list of section names. -func (f *File) SectionStrings() []string { - list := make([]string, len(f.sectionList)) - copy(list, f.sectionList) - return list -} - -// DeleteSection deletes a section. -func (f *File) DeleteSection(name string) { - if f.BlockMode { - f.lock.Lock() - defer f.lock.Unlock() - } - - if len(name) == 0 { - name = DEFAULT_SECTION - } - - for i, s := range f.sectionList { - if s == name { - f.sectionList = append(f.sectionList[:i], f.sectionList[i+1:]...) - delete(f.sections, name) - return - } - } -} - -func (f *File) reload(s dataSource) error { - r, err := s.ReadCloser() - if err != nil { - return err - } - defer r.Close() - - return f.parse(r) -} - -// Reload reloads and parses all data sources. -func (f *File) Reload() (err error) { - for _, s := range f.dataSources { - if err = f.reload(s); err != nil { - // In loose mode, we create an empty default section for nonexistent files. - if os.IsNotExist(err) && f.looseMode { - f.parse(bytes.NewBuffer(nil)) - continue - } - return err - } - } - return nil -} - -// Append appends one or more data sources and reloads automatically. -func (f *File) Append(source interface{}, others ...interface{}) error { - ds, err := parseDataSource(source) - if err != nil { - return err - } - f.dataSources = append(f.dataSources, ds) - for _, s := range others { - ds, err = parseDataSource(s) - if err != nil { - return err - } - f.dataSources = append(f.dataSources, ds) - } - return f.Reload() -} - -// WriteToIndent writes content into io.Writer with given indention. -// If PrettyFormat has been set to be true, -// it will align "=" sign with spaces under each section. -func (f *File) WriteToIndent(w io.Writer, indent string) (n int64, err error) { - equalSign := "=" - if PrettyFormat { - equalSign = " = " - } - - // Use buffer to make sure target is safe until finish encoding. - buf := bytes.NewBuffer(nil) - for i, sname := range f.sectionList { - sec := f.Section(sname) - if len(sec.Comment) > 0 { - if sec.Comment[0] != '#' && sec.Comment[0] != ';' { - sec.Comment = "; " + sec.Comment - } - if _, err = buf.WriteString(sec.Comment + LineBreak); err != nil { - return 0, err - } - } - - if i > 0 || DefaultHeader { - if _, err = buf.WriteString("[" + sname + "]" + LineBreak); err != nil { - return 0, err - } - } else { - // Write nothing if default section is empty - if len(sec.keyList) == 0 { - continue - } - } - - // Count and generate alignment length and buffer spaces - alignLength := 0 - if PrettyFormat { - for i := 0; i < len(sec.keyList); i++ { - if len(sec.keyList[i]) > alignLength { - alignLength = len(sec.keyList[i]) - } - } - } - alignSpaces := bytes.Repeat([]byte(" "), alignLength) - - for _, kname := range sec.keyList { - key := sec.Key(kname) - if len(key.Comment) > 0 { - if len(indent) > 0 && sname != DEFAULT_SECTION { - buf.WriteString(indent) - } - if key.Comment[0] != '#' && key.Comment[0] != ';' { - key.Comment = "; " + key.Comment - } - if _, err = buf.WriteString(key.Comment + LineBreak); err != nil { - return 0, err - } - } - - if len(indent) > 0 && sname != DEFAULT_SECTION { - buf.WriteString(indent) - } - - switch { - case key.isAutoIncr: - kname = "-" - case strings.ContainsAny(kname, "\"=:"): - kname = "`" + kname + "`" - case strings.Contains(kname, "`"): - kname = `"""` + kname + `"""` - } - if _, err = buf.WriteString(kname); err != nil { - return 0, err - } - - // Write out alignment spaces before "=" sign - if PrettyFormat { - buf.Write(alignSpaces[:alignLength-len(kname)]) - } - - val := key.value - // In case key value contains "\n", "`", "\"", "#" or ";" - if strings.ContainsAny(val, "\n`") { - val = `"""` + val + `"""` - } else if strings.ContainsAny(val, "#;") { - val = "`" + val + "`" - } - if _, err = buf.WriteString(equalSign + val + LineBreak); err != nil { - return 0, err - } - } - - // Put a line between sections - if _, err = buf.WriteString(LineBreak); err != nil { - return 0, err - } - } - - return buf.WriteTo(w) -} - -// WriteTo writes file content into io.Writer. -func (f *File) WriteTo(w io.Writer) (int64, error) { - return f.WriteToIndent(w, "") -} - -// SaveToIndent writes content to file system with given value indention. -func (f *File) SaveToIndent(filename, indent string) error { - // Note: Because we are truncating with os.Create, - // so it's safer to save to a temporary file location and rename afte done. - tmpPath := filename + "." + strconv.Itoa(time.Now().Nanosecond()) + ".tmp" - defer os.Remove(tmpPath) - - fw, err := os.Create(tmpPath) - if err != nil { - return err - } - - if _, err = f.WriteToIndent(fw, indent); err != nil { - fw.Close() - return err - } - fw.Close() - - // Remove old file and rename the new one. - os.Remove(filename) - return os.Rename(tmpPath, filename) -} - -// SaveTo writes content to file system. -func (f *File) SaveTo(filename string) error { - return f.SaveToIndent(filename, "") -} diff --git a/Godeps/_workspace/src/github.com/go-ini/ini/key.go b/Godeps/_workspace/src/github.com/go-ini/ini/key.go deleted file mode 100644 index 7cbccd38e6..0000000000 --- a/Godeps/_workspace/src/github.com/go-ini/ini/key.go +++ /dev/null @@ -1,616 +0,0 @@ -// Copyright 2014 Unknwon -// -// Licensed under the Apache License, Version 2.0 (the "License"): you may -// not use this file except in compliance with the License. You may obtain -// a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -// License for the specific language governing permissions and limitations -// under the License. - -package ini - -import ( - "fmt" - "strconv" - "strings" - "time" -) - -// Key represents a key under a section. -type Key struct { - s *Section - Comment string - name string - value string - isAutoIncr bool -} - -// Name returns name of key. -func (k *Key) Name() string { - return k.name -} - -// Value returns raw value of key for performance purpose. -func (k *Key) Value() string { - return k.value -} - -// String returns string representation of value. -func (k *Key) String() string { - val := k.value - if strings.Index(val, "%") == -1 { - return val - } - - for i := 0; i < _DEPTH_VALUES; i++ { - vr := varPattern.FindString(val) - if len(vr) == 0 { - break - } - - // Take off leading '%(' and trailing ')s'. - noption := strings.TrimLeft(vr, "%(") - noption = strings.TrimRight(noption, ")s") - - // Search in the same section. - nk, err := k.s.GetKey(noption) - if err != nil { - // Search again in default section. - nk, _ = k.s.f.Section("").GetKey(noption) - } - - // Substitute by new value and take off leading '%(' and trailing ')s'. - val = strings.Replace(val, vr, nk.value, -1) - } - return val -} - -// Validate accepts a validate function which can -// return modifed result as key value. -func (k *Key) Validate(fn func(string) string) string { - return fn(k.String()) -} - -// parseBool returns the boolean value represented by the string. -// -// It accepts 1, t, T, TRUE, true, True, YES, yes, Yes, y, ON, on, On, -// 0, f, F, FALSE, false, False, NO, no, No, n, OFF, off, Off. -// Any other value returns an error. -func parseBool(str string) (value bool, err error) { - switch str { - case "1", "t", "T", "true", "TRUE", "True", "YES", "yes", "Yes", "y", "ON", "on", "On": - return true, nil - case "0", "f", "F", "false", "FALSE", "False", "NO", "no", "No", "n", "OFF", "off", "Off": - return false, nil - } - return false, fmt.Errorf("parsing \"%s\": invalid syntax", str) -} - -// Bool returns bool type value. -func (k *Key) Bool() (bool, error) { - return parseBool(k.String()) -} - -// Float64 returns float64 type value. -func (k *Key) Float64() (float64, error) { - return strconv.ParseFloat(k.String(), 64) -} - -// Int returns int type value. -func (k *Key) Int() (int, error) { - return strconv.Atoi(k.String()) -} - -// Int64 returns int64 type value. -func (k *Key) Int64() (int64, error) { - return strconv.ParseInt(k.String(), 10, 64) -} - -// Uint returns uint type valued. -func (k *Key) Uint() (uint, error) { - u, e := strconv.ParseUint(k.String(), 10, 64) - return uint(u), e -} - -// Uint64 returns uint64 type value. -func (k *Key) Uint64() (uint64, error) { - return strconv.ParseUint(k.String(), 10, 64) -} - -// Duration returns time.Duration type value. -func (k *Key) Duration() (time.Duration, error) { - return time.ParseDuration(k.String()) -} - -// TimeFormat parses with given format and returns time.Time type value. -func (k *Key) TimeFormat(format string) (time.Time, error) { - return time.Parse(format, k.String()) -} - -// Time parses with RFC3339 format and returns time.Time type value. -func (k *Key) Time() (time.Time, error) { - return k.TimeFormat(time.RFC3339) -} - -// MustString returns default value if key value is empty. -func (k *Key) MustString(defaultVal string) string { - val := k.String() - if len(val) == 0 { - return defaultVal - } - return val -} - -// MustBool always returns value without error, -// it returns false if error occurs. -func (k *Key) MustBool(defaultVal ...bool) bool { - val, err := k.Bool() - if len(defaultVal) > 0 && err != nil { - return defaultVal[0] - } - return val -} - -// MustFloat64 always returns value without error, -// it returns 0.0 if error occurs. -func (k *Key) MustFloat64(defaultVal ...float64) float64 { - val, err := k.Float64() - if len(defaultVal) > 0 && err != nil { - return defaultVal[0] - } - return val -} - -// MustInt always returns value without error, -// it returns 0 if error occurs. -func (k *Key) MustInt(defaultVal ...int) int { - val, err := k.Int() - if len(defaultVal) > 0 && err != nil { - return defaultVal[0] - } - return val -} - -// MustInt64 always returns value without error, -// it returns 0 if error occurs. -func (k *Key) MustInt64(defaultVal ...int64) int64 { - val, err := k.Int64() - if len(defaultVal) > 0 && err != nil { - return defaultVal[0] - } - return val -} - -// MustUint always returns value without error, -// it returns 0 if error occurs. -func (k *Key) MustUint(defaultVal ...uint) uint { - val, err := k.Uint() - if len(defaultVal) > 0 && err != nil { - return defaultVal[0] - } - return val -} - -// MustUint64 always returns value without error, -// it returns 0 if error occurs. -func (k *Key) MustUint64(defaultVal ...uint64) uint64 { - val, err := k.Uint64() - if len(defaultVal) > 0 && err != nil { - return defaultVal[0] - } - return val -} - -// MustDuration always returns value without error, -// it returns zero value if error occurs. -func (k *Key) MustDuration(defaultVal ...time.Duration) time.Duration { - val, err := k.Duration() - if len(defaultVal) > 0 && err != nil { - return defaultVal[0] - } - return val -} - -// MustTimeFormat always parses with given format and returns value without error, -// it returns zero value if error occurs. -func (k *Key) MustTimeFormat(format string, defaultVal ...time.Time) time.Time { - val, err := k.TimeFormat(format) - if len(defaultVal) > 0 && err != nil { - return defaultVal[0] - } - return val -} - -// MustTime always parses with RFC3339 format and returns value without error, -// it returns zero value if error occurs. -func (k *Key) MustTime(defaultVal ...time.Time) time.Time { - return k.MustTimeFormat(time.RFC3339, defaultVal...) -} - -// In always returns value without error, -// it returns default value if error occurs or doesn't fit into candidates. -func (k *Key) In(defaultVal string, candidates []string) string { - val := k.String() - for _, cand := range candidates { - if val == cand { - return val - } - } - return defaultVal -} - -// InFloat64 always returns value without error, -// it returns default value if error occurs or doesn't fit into candidates. -func (k *Key) InFloat64(defaultVal float64, candidates []float64) float64 { - val := k.MustFloat64() - for _, cand := range candidates { - if val == cand { - return val - } - } - return defaultVal -} - -// InInt always returns value without error, -// it returns default value if error occurs or doesn't fit into candidates. -func (k *Key) InInt(defaultVal int, candidates []int) int { - val := k.MustInt() - for _, cand := range candidates { - if val == cand { - return val - } - } - return defaultVal -} - -// InInt64 always returns value without error, -// it returns default value if error occurs or doesn't fit into candidates. -func (k *Key) InInt64(defaultVal int64, candidates []int64) int64 { - val := k.MustInt64() - for _, cand := range candidates { - if val == cand { - return val - } - } - return defaultVal -} - -// InUint always returns value without error, -// it returns default value if error occurs or doesn't fit into candidates. -func (k *Key) InUint(defaultVal uint, candidates []uint) uint { - val := k.MustUint() - for _, cand := range candidates { - if val == cand { - return val - } - } - return defaultVal -} - -// InUint64 always returns value without error, -// it returns default value if error occurs or doesn't fit into candidates. -func (k *Key) InUint64(defaultVal uint64, candidates []uint64) uint64 { - val := k.MustUint64() - for _, cand := range candidates { - if val == cand { - return val - } - } - return defaultVal -} - -// InTimeFormat always parses with given format and returns value without error, -// it returns default value if error occurs or doesn't fit into candidates. -func (k *Key) InTimeFormat(format string, defaultVal time.Time, candidates []time.Time) time.Time { - val := k.MustTimeFormat(format) - for _, cand := range candidates { - if val == cand { - return val - } - } - return defaultVal -} - -// InTime always parses with RFC3339 format and returns value without error, -// it returns default value if error occurs or doesn't fit into candidates. -func (k *Key) InTime(defaultVal time.Time, candidates []time.Time) time.Time { - return k.InTimeFormat(time.RFC3339, defaultVal, candidates) -} - -// RangeFloat64 checks if value is in given range inclusively, -// and returns default value if it's not. -func (k *Key) RangeFloat64(defaultVal, min, max float64) float64 { - val := k.MustFloat64() - if val < min || val > max { - return defaultVal - } - return val -} - -// RangeInt checks if value is in given range inclusively, -// and returns default value if it's not. -func (k *Key) RangeInt(defaultVal, min, max int) int { - val := k.MustInt() - if val < min || val > max { - return defaultVal - } - return val -} - -// RangeInt64 checks if value is in given range inclusively, -// and returns default value if it's not. -func (k *Key) RangeInt64(defaultVal, min, max int64) int64 { - val := k.MustInt64() - if val < min || val > max { - return defaultVal - } - return val -} - -// RangeTimeFormat checks if value with given format is in given range inclusively, -// and returns default value if it's not. -func (k *Key) RangeTimeFormat(format string, defaultVal, min, max time.Time) time.Time { - val := k.MustTimeFormat(format) - if val.Unix() < min.Unix() || val.Unix() > max.Unix() { - return defaultVal - } - return val -} - -// RangeTime checks if value with RFC3339 format is in given range inclusively, -// and returns default value if it's not. -func (k *Key) RangeTime(defaultVal, min, max time.Time) time.Time { - return k.RangeTimeFormat(time.RFC3339, defaultVal, min, max) -} - -// Strings returns list of string divided by given delimiter. -func (k *Key) Strings(delim string) []string { - str := k.String() - if len(str) == 0 { - return []string{} - } - - vals := strings.Split(str, delim) - for i := range vals { - vals[i] = strings.TrimSpace(vals[i]) - } - return vals -} - -// Float64s returns list of float64 divided by given delimiter. Any invalid input will be treated as zero value. -func (k *Key) Float64s(delim string) []float64 { - vals, _ := k.getFloat64s(delim, true, false) - return vals -} - -// Ints returns list of int divided by given delimiter. Any invalid input will be treated as zero value. -func (k *Key) Ints(delim string) []int { - vals, _ := k.getInts(delim, true, false) - return vals -} - -// Int64s returns list of int64 divided by given delimiter. Any invalid input will be treated as zero value. -func (k *Key) Int64s(delim string) []int64 { - vals, _ := k.getInt64s(delim, true, false) - return vals -} - -// Uints returns list of uint divided by given delimiter. Any invalid input will be treated as zero value. -func (k *Key) Uints(delim string) []uint { - vals, _ := k.getUints(delim, true, false) - return vals -} - -// Uint64s returns list of uint64 divided by given delimiter. Any invalid input will be treated as zero value. -func (k *Key) Uint64s(delim string) []uint64 { - vals, _ := k.getUint64s(delim, true, false) - return vals -} - -// TimesFormat parses with given format and returns list of time.Time divided by given delimiter. -// Any invalid input will be treated as zero value (0001-01-01 00:00:00 +0000 UTC). -func (k *Key) TimesFormat(format, delim string) []time.Time { - vals, _ := k.getTimesFormat(format, delim, true, false) - return vals -} - -// Times parses with RFC3339 format and returns list of time.Time divided by given delimiter. -// Any invalid input will be treated as zero value (0001-01-01 00:00:00 +0000 UTC). -func (k *Key) Times(delim string) []time.Time { - return k.TimesFormat(time.RFC3339, delim) -} - -// ValidFloat64s returns list of float64 divided by given delimiter. If some value is not float, then -// it will not be included to result list. -func (k *Key) ValidFloat64s(delim string) []float64 { - vals, _ := k.getFloat64s(delim, false, false) - return vals -} - -// ValidInts returns list of int divided by given delimiter. If some value is not integer, then it will -// not be included to result list. -func (k *Key) ValidInts(delim string) []int { - vals, _ := k.getInts(delim, false, false) - return vals -} - -// ValidInt64s returns list of int64 divided by given delimiter. If some value is not 64-bit integer, -// then it will not be included to result list. -func (k *Key) ValidInt64s(delim string) []int64 { - vals, _ := k.getInt64s(delim, false, false) - return vals -} - -// ValidUints returns list of uint divided by given delimiter. If some value is not unsigned integer, -// then it will not be included to result list. -func (k *Key) ValidUints(delim string) []uint { - vals, _ := k.getUints(delim, false, false) - return vals -} - -// ValidUint64s returns list of uint64 divided by given delimiter. If some value is not 64-bit unsigned -// integer, then it will not be included to result list. -func (k *Key) ValidUint64s(delim string) []uint64 { - vals, _ := k.getUint64s(delim, false, false) - return vals -} - -// ValidTimesFormat parses with given format and returns list of time.Time divided by given delimiter. -func (k *Key) ValidTimesFormat(format, delim string) []time.Time { - vals, _ := k.getTimesFormat(format, delim, false, false) - return vals -} - -// ValidTimes parses with RFC3339 format and returns list of time.Time divided by given delimiter. -func (k *Key) ValidTimes(delim string) []time.Time { - return k.ValidTimesFormat(time.RFC3339, delim) -} - -// StrictFloat64s returns list of float64 divided by given delimiter or error on first invalid input. -func (k *Key) StrictFloat64s(delim string) ([]float64, error) { - return k.getFloat64s(delim, false, true) -} - -// StrictInts returns list of int divided by given delimiter or error on first invalid input. -func (k *Key) StrictInts(delim string) ([]int, error) { - return k.getInts(delim, false, true) -} - -// StrictInt64s returns list of int64 divided by given delimiter or error on first invalid input. -func (k *Key) StrictInt64s(delim string) ([]int64, error) { - return k.getInt64s(delim, false, true) -} - -// StrictUints returns list of uint divided by given delimiter or error on first invalid input. -func (k *Key) StrictUints(delim string) ([]uint, error) { - return k.getUints(delim, false, true) -} - -// StrictUint64s returns list of uint64 divided by given delimiter or error on first invalid input. -func (k *Key) StrictUint64s(delim string) ([]uint64, error) { - return k.getUint64s(delim, false, true) -} - -// StrictTimesFormat parses with given format and returns list of time.Time divided by given delimiter -// or error on first invalid input. -func (k *Key) StrictTimesFormat(format, delim string) ([]time.Time, error) { - return k.getTimesFormat(format, delim, false, true) -} - -// StrictTimes parses with RFC3339 format and returns list of time.Time divided by given delimiter -// or error on first invalid input. -func (k *Key) StrictTimes(delim string) ([]time.Time, error) { - return k.StrictTimesFormat(time.RFC3339, delim) -} - -// getFloat64s returns list of float64 divided by given delimiter. -func (k *Key) getFloat64s(delim string, addInvalid, returnOnInvalid bool) ([]float64, error) { - strs := k.Strings(delim) - vals := make([]float64, 0, len(strs)) - for _, str := range strs { - val, err := strconv.ParseFloat(str, 64) - if err != nil && returnOnInvalid { - return nil, err - } - if err == nil || addInvalid { - vals = append(vals, val) - } - } - return vals, nil -} - -// getInts returns list of int divided by given delimiter. -func (k *Key) getInts(delim string, addInvalid, returnOnInvalid bool) ([]int, error) { - strs := k.Strings(delim) - vals := make([]int, 0, len(strs)) - for _, str := range strs { - val, err := strconv.Atoi(str) - if err != nil && returnOnInvalid { - return nil, err - } - if err == nil || addInvalid { - vals = append(vals, val) - } - } - return vals, nil -} - -// getInt64s returns list of int64 divided by given delimiter. -func (k *Key) getInt64s(delim string, addInvalid, returnOnInvalid bool) ([]int64, error) { - strs := k.Strings(delim) - vals := make([]int64, 0, len(strs)) - for _, str := range strs { - val, err := strconv.ParseInt(str, 10, 64) - if err != nil && returnOnInvalid { - return nil, err - } - if err == nil || addInvalid { - vals = append(vals, val) - } - } - return vals, nil -} - -// getUints returns list of uint divided by given delimiter. -func (k *Key) getUints(delim string, addInvalid, returnOnInvalid bool) ([]uint, error) { - strs := k.Strings(delim) - vals := make([]uint, 0, len(strs)) - for _, str := range strs { - val, err := strconv.ParseUint(str, 10, 0) - if err != nil && returnOnInvalid { - return nil, err - } - if err == nil || addInvalid { - vals = append(vals, uint(val)) - } - } - return vals, nil -} - -// getUint64s returns list of uint64 divided by given delimiter. -func (k *Key) getUint64s(delim string, addInvalid, returnOnInvalid bool) ([]uint64, error) { - strs := k.Strings(delim) - vals := make([]uint64, 0, len(strs)) - for _, str := range strs { - val, err := strconv.ParseUint(str, 10, 64) - if err != nil && returnOnInvalid { - return nil, err - } - if err == nil || addInvalid { - vals = append(vals, val) - } - } - return vals, nil -} - -// getTimesFormat parses with given format and returns list of time.Time divided by given delimiter. -func (k *Key) getTimesFormat(format, delim string, addInvalid, returnOnInvalid bool) ([]time.Time, error) { - strs := k.Strings(delim) - vals := make([]time.Time, 0, len(strs)) - for _, str := range strs { - val, err := time.Parse(format, str) - if err != nil && returnOnInvalid { - return nil, err - } - if err == nil || addInvalid { - vals = append(vals, val) - } - } - return vals, nil -} - -// SetValue changes key value. -func (k *Key) SetValue(v string) { - if k.s.f.BlockMode { - k.s.f.lock.Lock() - defer k.s.f.lock.Unlock() - } - - k.value = v - k.s.keysHash[k.name] = v -} diff --git a/Godeps/_workspace/src/github.com/go-ini/ini/parser.go b/Godeps/_workspace/src/github.com/go-ini/ini/parser.go deleted file mode 100644 index 1c1bf91f0e..0000000000 --- a/Godeps/_workspace/src/github.com/go-ini/ini/parser.go +++ /dev/null @@ -1,312 +0,0 @@ -// Copyright 2015 Unknwon -// -// Licensed under the Apache License, Version 2.0 (the "License"): you may -// not use this file except in compliance with the License. You may obtain -// a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -// License for the specific language governing permissions and limitations -// under the License. - -package ini - -import ( - "bufio" - "bytes" - "fmt" - "io" - "strconv" - "strings" - "unicode" -) - -type tokenType int - -const ( - _TOKEN_INVALID tokenType = iota - _TOKEN_COMMENT - _TOKEN_SECTION - _TOKEN_KEY -) - -type parser struct { - buf *bufio.Reader - isEOF bool - count int - comment *bytes.Buffer -} - -func newParser(r io.Reader) *parser { - return &parser{ - buf: bufio.NewReader(r), - count: 1, - comment: &bytes.Buffer{}, - } -} - -// BOM handles header of BOM-UTF8 format. -// http://en.wikipedia.org/wiki/Byte_order_mark#Representations_of_byte_order_marks_by_encoding -func (p *parser) BOM() error { - mask, err := p.buf.Peek(3) - if err != nil && err != io.EOF { - return err - } else if len(mask) < 3 { - return nil - } else if mask[0] == 239 && mask[1] == 187 && mask[2] == 191 { - p.buf.Read(mask) - } - return nil -} - -func (p *parser) readUntil(delim byte) ([]byte, error) { - data, err := p.buf.ReadBytes(delim) - if err != nil { - if err == io.EOF { - p.isEOF = true - } else { - return nil, err - } - } - return data, nil -} - -func cleanComment(in []byte) ([]byte, bool) { - i := bytes.IndexAny(in, "#;") - if i == -1 { - return nil, false - } - return in[i:], true -} - -func readKeyName(in []byte) (string, int, error) { - line := string(in) - - // Check if key name surrounded by quotes. - var keyQuote string - if line[0] == '"' { - if len(line) > 6 && string(line[0:3]) == `"""` { - keyQuote = `"""` - } else { - keyQuote = `"` - } - } else if line[0] == '`' { - keyQuote = "`" - } - - // Get out key name - endIdx := -1 - if len(keyQuote) > 0 { - startIdx := len(keyQuote) - // FIXME: fail case -> """"""name"""=value - pos := strings.Index(line[startIdx:], keyQuote) - if pos == -1 { - return "", -1, fmt.Errorf("missing closing key quote: %s", line) - } - pos += startIdx - - // Find key-value delimiter - i := strings.IndexAny(line[pos+startIdx:], "=:") - if i < 0 { - return "", -1, fmt.Errorf("key-value delimiter not found: %s", line) - } - endIdx = pos + i - return strings.TrimSpace(line[startIdx:pos]), endIdx + startIdx + 1, nil - } - - endIdx = strings.IndexAny(line, "=:") - if endIdx < 0 { - return "", -1, fmt.Errorf("key-value delimiter not found: %s", line) - } - return strings.TrimSpace(line[0:endIdx]), endIdx + 1, nil -} - -func (p *parser) readMultilines(line, val, valQuote string) (string, error) { - for { - data, err := p.readUntil('\n') - if err != nil { - return "", err - } - next := string(data) - - pos := strings.LastIndex(next, valQuote) - if pos > -1 { - val += next[:pos] - - comment, has := cleanComment([]byte(next[pos:])) - if has { - p.comment.Write(bytes.TrimSpace(comment)) - } - break - } - val += next - if p.isEOF { - return "", fmt.Errorf("missing closing key quote from '%s' to '%s'", line, next) - } - } - return val, nil -} - -func (p *parser) readContinuationLines(val string) (string, error) { - for { - data, err := p.readUntil('\n') - if err != nil { - return "", err - } - next := strings.TrimSpace(string(data)) - - if len(next) == 0 { - break - } - val += next - if val[len(val)-1] != '\\' { - break - } - val = val[:len(val)-1] - } - return val, nil -} - -// hasSurroundedQuote check if and only if the first and last characters -// are quotes \" or \'. -// It returns false if any other parts also contain same kind of quotes. -func hasSurroundedQuote(in string, quote byte) bool { - return len(in) > 2 && in[0] == quote && in[len(in)-1] == quote && - strings.IndexByte(in[1:], quote) == len(in)-2 -} - -func (p *parser) readValue(in []byte) (string, error) { - line := strings.TrimLeftFunc(string(in), unicode.IsSpace) - if len(line) == 0 { - return "", nil - } - - var valQuote string - if len(line) > 3 && string(line[0:3]) == `"""` { - valQuote = `"""` - } else if line[0] == '`' { - valQuote = "`" - } - - if len(valQuote) > 0 { - startIdx := len(valQuote) - pos := strings.LastIndex(line[startIdx:], valQuote) - // Check for multi-line value - if pos == -1 { - return p.readMultilines(line, line[startIdx:], valQuote) - } - - return line[startIdx : pos+startIdx], nil - } - - // Won't be able to reach here if value only contains whitespace. - line = strings.TrimSpace(line) - - // Check continuation lines - if line[len(line)-1] == '\\' { - return p.readContinuationLines(line[:len(line)-1]) - } - - i := strings.IndexAny(line, "#;") - if i > -1 { - p.comment.WriteString(line[i:]) - line = strings.TrimSpace(line[:i]) - } - - // Trim single quotes - if hasSurroundedQuote(line, '\'') || - hasSurroundedQuote(line, '"') { - line = line[1 : len(line)-1] - } - return line, nil -} - -// parse parses data through an io.Reader. -func (f *File) parse(reader io.Reader) (err error) { - p := newParser(reader) - if err = p.BOM(); err != nil { - return fmt.Errorf("BOM: %v", err) - } - - // Ignore error because default section name is never empty string. - section, _ := f.NewSection(DEFAULT_SECTION) - - var line []byte - for !p.isEOF { - line, err = p.readUntil('\n') - if err != nil { - return err - } - - line = bytes.TrimLeftFunc(line, unicode.IsSpace) - if len(line) == 0 { - continue - } - - // Comments - if line[0] == '#' || line[0] == ';' { - // Note: we do not care ending line break, - // it is needed for adding second line, - // so just clean it once at the end when set to value. - p.comment.Write(line) - continue - } - - // Section - if line[0] == '[' { - // Read to the next ']' (TODO: support quoted strings) - closeIdx := bytes.IndexByte(line, ']') - if closeIdx == -1 { - return fmt.Errorf("unclosed section: %s", line) - } - - section, err = f.NewSection(string(line[1:closeIdx])) - if err != nil { - return err - } - - comment, has := cleanComment(line[closeIdx+1:]) - if has { - p.comment.Write(comment) - } - - section.Comment = strings.TrimSpace(p.comment.String()) - - // Reset aotu-counter and comments - p.comment.Reset() - p.count = 1 - continue - } - - kname, offset, err := readKeyName(line) - if err != nil { - return err - } - - // Auto increment. - isAutoIncr := false - if kname == "-" { - isAutoIncr = true - kname = "#" + strconv.Itoa(p.count) - p.count++ - } - - key, err := section.NewKey(kname, "") - if err != nil { - return err - } - key.isAutoIncr = isAutoIncr - - value, err := p.readValue(line[offset:]) - if err != nil { - return err - } - key.SetValue(value) - key.Comment = strings.TrimSpace(p.comment.String()) - p.comment.Reset() - } - return nil -} diff --git a/Godeps/_workspace/src/github.com/go-ini/ini/section.go b/Godeps/_workspace/src/github.com/go-ini/ini/section.go deleted file mode 100644 index ed8cbdb54a..0000000000 --- a/Godeps/_workspace/src/github.com/go-ini/ini/section.go +++ /dev/null @@ -1,177 +0,0 @@ -// Copyright 2014 Unknwon -// -// Licensed under the Apache License, Version 2.0 (the "License"): you may -// not use this file except in compliance with the License. You may obtain -// a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -// License for the specific language governing permissions and limitations -// under the License. - -package ini - -import ( - "errors" - "fmt" - "strings" -) - -// Section represents a config section. -type Section struct { - f *File - Comment string - name string - keys map[string]*Key - keyList []string - keysHash map[string]string -} - -func newSection(f *File, name string) *Section { - return &Section{f, "", name, make(map[string]*Key), make([]string, 0, 10), make(map[string]string)} -} - -// Name returns name of Section. -func (s *Section) Name() string { - return s.name -} - -// NewKey creates a new key to given section. -func (s *Section) NewKey(name, val string) (*Key, error) { - if len(name) == 0 { - return nil, errors.New("error creating new key: empty key name") - } - - if s.f.BlockMode { - s.f.lock.Lock() - defer s.f.lock.Unlock() - } - - if inSlice(name, s.keyList) { - s.keys[name].value = val - return s.keys[name], nil - } - - s.keyList = append(s.keyList, name) - s.keys[name] = &Key{s, "", name, val, false} - s.keysHash[name] = val - return s.keys[name], nil -} - -// GetKey returns key in section by given name. -func (s *Section) GetKey(name string) (*Key, error) { - // FIXME: change to section level lock? - if s.f.BlockMode { - s.f.lock.RLock() - } - key := s.keys[name] - if s.f.BlockMode { - s.f.lock.RUnlock() - } - - if key == nil { - // Check if it is a child-section. - sname := s.name - for { - if i := strings.LastIndex(sname, "."); i > -1 { - sname = sname[:i] - sec, err := s.f.GetSection(sname) - if err != nil { - continue - } - return sec.GetKey(name) - } else { - break - } - } - return nil, fmt.Errorf("error when getting key of section '%s': key '%s' not exists", s.name, name) - } - return key, nil -} - -// HasKey returns true if section contains a key with given name. -func (s *Section) HasKey(name string) bool { - key, _ := s.GetKey(name) - return key != nil -} - -// Haskey is a backwards-compatible name for HasKey. -func (s *Section) Haskey(name string) bool { - return s.HasKey(name) -} - -// HasValue returns true if section contains given raw value. -func (s *Section) HasValue(value string) bool { - if s.f.BlockMode { - s.f.lock.RLock() - defer s.f.lock.RUnlock() - } - - for _, k := range s.keys { - if value == k.value { - return true - } - } - return false -} - -// Key assumes named Key exists in section and returns a zero-value when not. -func (s *Section) Key(name string) *Key { - key, err := s.GetKey(name) - if err != nil { - // It's OK here because the only possible error is empty key name, - // but if it's empty, this piece of code won't be executed. - key, _ = s.NewKey(name, "") - return key - } - return key -} - -// Keys returns list of keys of section. -func (s *Section) Keys() []*Key { - keys := make([]*Key, len(s.keyList)) - for i := range s.keyList { - keys[i] = s.Key(s.keyList[i]) - } - return keys -} - -// KeyStrings returns list of key names of section. -func (s *Section) KeyStrings() []string { - list := make([]string, len(s.keyList)) - copy(list, s.keyList) - return list -} - -// KeysHash returns keys hash consisting of names and values. -func (s *Section) KeysHash() map[string]string { - if s.f.BlockMode { - s.f.lock.RLock() - defer s.f.lock.RUnlock() - } - - hash := map[string]string{} - for key, value := range s.keysHash { - hash[key] = value - } - return hash -} - -// DeleteKey deletes a key from section. -func (s *Section) DeleteKey(name string) { - if s.f.BlockMode { - s.f.lock.Lock() - defer s.f.lock.Unlock() - } - - for i, k := range s.keyList { - if k == name { - s.keyList = append(s.keyList[:i], s.keyList[i+1:]...) - delete(s.keys, name) - return - } - } -} diff --git a/Godeps/_workspace/src/github.com/go-ini/ini/struct.go b/Godeps/_workspace/src/github.com/go-ini/ini/struct.go deleted file mode 100644 index 3fb92c3962..0000000000 --- a/Godeps/_workspace/src/github.com/go-ini/ini/struct.go +++ /dev/null @@ -1,351 +0,0 @@ -// Copyright 2014 Unknwon -// -// Licensed under the Apache License, Version 2.0 (the "License"): you may -// not use this file except in compliance with the License. You may obtain -// a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -// License for the specific language governing permissions and limitations -// under the License. - -package ini - -import ( - "bytes" - "errors" - "fmt" - "reflect" - "time" - "unicode" -) - -// NameMapper represents a ini tag name mapper. -type NameMapper func(string) string - -// Built-in name getters. -var ( - // AllCapsUnderscore converts to format ALL_CAPS_UNDERSCORE. - AllCapsUnderscore NameMapper = func(raw string) string { - newstr := make([]rune, 0, len(raw)) - for i, chr := range raw { - if isUpper := 'A' <= chr && chr <= 'Z'; isUpper { - if i > 0 { - newstr = append(newstr, '_') - } - } - newstr = append(newstr, unicode.ToUpper(chr)) - } - return string(newstr) - } - // TitleUnderscore converts to format title_underscore. - TitleUnderscore NameMapper = func(raw string) string { - newstr := make([]rune, 0, len(raw)) - for i, chr := range raw { - if isUpper := 'A' <= chr && chr <= 'Z'; isUpper { - if i > 0 { - newstr = append(newstr, '_') - } - chr -= ('A' - 'a') - } - newstr = append(newstr, chr) - } - return string(newstr) - } -) - -func (s *Section) parseFieldName(raw, actual string) string { - if len(actual) > 0 { - return actual - } - if s.f.NameMapper != nil { - return s.f.NameMapper(raw) - } - return raw -} - -func parseDelim(actual string) string { - if len(actual) > 0 { - return actual - } - return "," -} - -var reflectTime = reflect.TypeOf(time.Now()).Kind() - -// setWithProperType sets proper value to field based on its type, -// but it does not return error for failing parsing, -// because we want to use default value that is already assigned to strcut. -func setWithProperType(t reflect.Type, key *Key, field reflect.Value, delim string) error { - switch t.Kind() { - case reflect.String: - if len(key.String()) == 0 { - return nil - } - field.SetString(key.String()) - case reflect.Bool: - boolVal, err := key.Bool() - if err != nil { - return nil - } - field.SetBool(boolVal) - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - durationVal, err := key.Duration() - // Skip zero value - if err == nil && int(durationVal) > 0 { - field.Set(reflect.ValueOf(durationVal)) - return nil - } - - intVal, err := key.Int64() - if err != nil || intVal == 0 { - return nil - } - field.SetInt(intVal) - // byte is an alias for uint8, so supporting uint8 breaks support for byte - case reflect.Uint, reflect.Uint16, reflect.Uint32, reflect.Uint64: - durationVal, err := key.Duration() - if err == nil { - field.Set(reflect.ValueOf(durationVal)) - return nil - } - - uintVal, err := key.Uint64() - if err != nil { - return nil - } - field.SetUint(uintVal) - - case reflect.Float64: - floatVal, err := key.Float64() - if err != nil { - return nil - } - field.SetFloat(floatVal) - case reflectTime: - timeVal, err := key.Time() - if err != nil { - return nil - } - field.Set(reflect.ValueOf(timeVal)) - case reflect.Slice: - vals := key.Strings(delim) - numVals := len(vals) - if numVals == 0 { - return nil - } - - sliceOf := field.Type().Elem().Kind() - - var times []time.Time - if sliceOf == reflectTime { - times = key.Times(delim) - } - - slice := reflect.MakeSlice(field.Type(), numVals, numVals) - for i := 0; i < numVals; i++ { - switch sliceOf { - case reflectTime: - slice.Index(i).Set(reflect.ValueOf(times[i])) - default: - slice.Index(i).Set(reflect.ValueOf(vals[i])) - } - } - field.Set(slice) - default: - return fmt.Errorf("unsupported type '%s'", t) - } - return nil -} - -func (s *Section) mapTo(val reflect.Value) error { - if val.Kind() == reflect.Ptr { - val = val.Elem() - } - typ := val.Type() - - for i := 0; i < typ.NumField(); i++ { - field := val.Field(i) - tpField := typ.Field(i) - - tag := tpField.Tag.Get("ini") - if tag == "-" { - continue - } - - fieldName := s.parseFieldName(tpField.Name, tag) - if len(fieldName) == 0 || !field.CanSet() { - continue - } - - isAnonymous := tpField.Type.Kind() == reflect.Ptr && tpField.Anonymous - isStruct := tpField.Type.Kind() == reflect.Struct - if isAnonymous { - field.Set(reflect.New(tpField.Type.Elem())) - } - - if isAnonymous || isStruct { - if sec, err := s.f.GetSection(fieldName); err == nil { - if err = sec.mapTo(field); err != nil { - return fmt.Errorf("error mapping field(%s): %v", fieldName, err) - } - continue - } - } - - if key, err := s.GetKey(fieldName); err == nil { - if err = setWithProperType(tpField.Type, key, field, parseDelim(tpField.Tag.Get("delim"))); err != nil { - return fmt.Errorf("error mapping field(%s): %v", fieldName, err) - } - } - } - return nil -} - -// MapTo maps section to given struct. -func (s *Section) MapTo(v interface{}) error { - typ := reflect.TypeOf(v) - val := reflect.ValueOf(v) - if typ.Kind() == reflect.Ptr { - typ = typ.Elem() - val = val.Elem() - } else { - return errors.New("cannot map to non-pointer struct") - } - - return s.mapTo(val) -} - -// MapTo maps file to given struct. -func (f *File) MapTo(v interface{}) error { - return f.Section("").MapTo(v) -} - -// MapTo maps data sources to given struct with name mapper. -func MapToWithMapper(v interface{}, mapper NameMapper, source interface{}, others ...interface{}) error { - cfg, err := Load(source, others...) - if err != nil { - return err - } - cfg.NameMapper = mapper - return cfg.MapTo(v) -} - -// MapTo maps data sources to given struct. -func MapTo(v, source interface{}, others ...interface{}) error { - return MapToWithMapper(v, nil, source, others...) -} - -// reflectWithProperType does the opposite thing with setWithProperType. -func reflectWithProperType(t reflect.Type, key *Key, field reflect.Value, delim string) error { - switch t.Kind() { - case reflect.String: - key.SetValue(field.String()) - case reflect.Bool, - reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, - reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, - reflect.Float64, - reflectTime: - key.SetValue(fmt.Sprint(field)) - case reflect.Slice: - vals := field.Slice(0, field.Len()) - if field.Len() == 0 { - return nil - } - - var buf bytes.Buffer - isTime := fmt.Sprint(field.Type()) == "[]time.Time" - for i := 0; i < field.Len(); i++ { - if isTime { - buf.WriteString(vals.Index(i).Interface().(time.Time).Format(time.RFC3339)) - } else { - buf.WriteString(fmt.Sprint(vals.Index(i))) - } - buf.WriteString(delim) - } - key.SetValue(buf.String()[:buf.Len()-1]) - default: - return fmt.Errorf("unsupported type '%s'", t) - } - return nil -} - -func (s *Section) reflectFrom(val reflect.Value) error { - if val.Kind() == reflect.Ptr { - val = val.Elem() - } - typ := val.Type() - - for i := 0; i < typ.NumField(); i++ { - field := val.Field(i) - tpField := typ.Field(i) - - tag := tpField.Tag.Get("ini") - if tag == "-" { - continue - } - - fieldName := s.parseFieldName(tpField.Name, tag) - if len(fieldName) == 0 || !field.CanSet() { - continue - } - - if (tpField.Type.Kind() == reflect.Ptr && tpField.Anonymous) || - (tpField.Type.Kind() == reflect.Struct) { - // Note: The only error here is section doesn't exist. - sec, err := s.f.GetSection(fieldName) - if err != nil { - // Note: fieldName can never be empty here, ignore error. - sec, _ = s.f.NewSection(fieldName) - } - if err = sec.reflectFrom(field); err != nil { - return fmt.Errorf("error reflecting field(%s): %v", fieldName, err) - } - continue - } - - // Note: Same reason as secion. - key, err := s.GetKey(fieldName) - if err != nil { - key, _ = s.NewKey(fieldName, "") - } - if err = reflectWithProperType(tpField.Type, key, field, parseDelim(tpField.Tag.Get("delim"))); err != nil { - return fmt.Errorf("error reflecting field(%s): %v", fieldName, err) - } - - } - return nil -} - -// ReflectFrom reflects secion from given struct. -func (s *Section) ReflectFrom(v interface{}) error { - typ := reflect.TypeOf(v) - val := reflect.ValueOf(v) - if typ.Kind() == reflect.Ptr { - typ = typ.Elem() - val = val.Elem() - } else { - return errors.New("cannot reflect from non-pointer struct") - } - - return s.reflectFrom(val) -} - -// ReflectFrom reflects file from given struct. -func (f *File) ReflectFrom(v interface{}) error { - return f.Section("").ReflectFrom(v) -} - -// ReflectFrom reflects data sources from given struct with name mapper. -func ReflectFromWithMapper(cfg *File, v interface{}, mapper NameMapper) error { - cfg.NameMapper = mapper - return cfg.ReflectFrom(v) -} - -// ReflectFrom reflects data sources from given struct. -func ReflectFrom(cfg *File, v interface{}) error { - return ReflectFromWithMapper(cfg, v, nil) -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/.travis.yml b/Godeps/_workspace/src/github.com/go-ole/go-ole/.travis.yml deleted file mode 100644 index 0c2c02bdf2..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: go -sudo: false - -go: - - 1.1 - - 1.2 - - 1.3 - - 1.4 - - tip diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/ChangeLog.md b/Godeps/_workspace/src/github.com/go-ole/go-ole/ChangeLog.md deleted file mode 100644 index 4ba6a8c64d..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/ChangeLog.md +++ /dev/null @@ -1,49 +0,0 @@ -# Version 1.x.x - -* **Add more test cases and reference new test COM server project.** (Placeholder for future additions) - -# Version 1.2.0-alphaX - -**Minimum supported version is now Go 1.4. Go 1.1 support is deprecated, but should still build.** - - * Added CI configuration for Travis-CI and AppVeyor. - * Added test InterfaceID and ClassID for the COM Test Server project. - * Added more inline documentation (#83). - * Added IEnumVARIANT implementation (#88). - * Added IEnumVARIANT test cases (#99, #100, #101). - * Added support for retrieving `time.Time` from VARIANT (#92). - * Added test case for IUnknown (#64). - * Added test case for IDispatch (#64). - * Added test cases for scalar variants (#64, #76). - -# Version 1.1.1 - - * Fixes for Linux build. - * Fixes for Windows build. - -# Version 1.1.0 - -The change to provide building on all platforms is a new feature. The increase in minor version reflects that and allows those who wish to stay on 1.0.x to continue to do so. Support for 1.0.x will be limited to bug fixes. - - * Move GUID out of variables.go into its own file to make new documentation available. - * Move OleError out of ole.go into its own file to make new documentation available. - * Add documentation to utility functions. - * Add documentation to variant receiver functions. - * Add documentation to ole structures. - * Make variant available to other systems outside of Windows. - * Make OLE structures available to other systems outside of Windows. - -## New Features - - * Library should now be built on all platforms supported by Go. Library will NOOP on any platform that is not Windows. - * More functions are now documented and available on godoc.org. - -# Version 1.0.1 - - 1. Fix package references from repository location change. - -# Version 1.0.0 - -This version is stable enough for use. The COM API is still incomplete, but provides enough functionality for accessing COM servers using IDispatch interface. - -There is no changelog for this version. Check commits for history. diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/README.md b/Godeps/_workspace/src/github.com/go-ole/go-ole/README.md deleted file mode 100644 index 0ea9db33c7..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/README.md +++ /dev/null @@ -1,46 +0,0 @@ -#Go OLE - -[![Build status](https://ci.appveyor.com/api/projects/status/qr0u2sf7q43us9fj?svg=true)](https://ci.appveyor.com/project/jacobsantos/go-ole-jgs28) -[![Build Status](https://travis-ci.org/go-ole/go-ole.svg?branch=master)](https://travis-ci.org/go-ole/go-ole) -[![GoDoc](https://godoc.org/github.com/go-ole/go-ole?status.svg)](https://godoc.org/github.com/go-ole/go-ole) - -Go bindings for Windows COM using shared libraries instead of cgo. - -By Yasuhiro Matsumoto. - -## Install - -To experiment with go-ole, you can just compile and run the example program: - -``` -go get github.com/go-ole/go-ole -cd /path/to/go-ole/ -go test - -cd /path/to/go-ole/example/excel -go run excel.go -``` - -## Continuous Integration - -Continuous integration configuration has been added for both Travis-CI and AppVeyor. You will have to add these to your own account for your fork in order for it to run. - -**Travis-CI** - -Travis-CI was added to check builds on Linux to ensure that `go get` works when cross building. Currently, Travis-CI is not used to test cross-building, but this may be changed in the future. It is also not currently possible to test the library on Linux, since COM API is specific to Windows and it is not currently possible to run a COM server on Linux or even connect to a remote COM server. - -**AppVeyor** - -AppVeyor is used to build on Windows using the (in-development) test COM server. It is currently only used to test the build and ensure that the code works on Windows. It will be used to register a COM server and then run the test cases based on the test COM server. - -The tests currently do run and do pass and this should be maintained with commits. - -##Versioning - -Go OLE uses [semantic versioning](http://semver.org) for version numbers, which is similar to the version contract of the Go language. Which means that the major version will always maintain backwards compatibility with minor versions. Minor versions will only add new additions and changes. Fixes will always be in patch. - -This contract should allow you to upgrade to new minor and patch versions without breakage or modifications to your existing code. Leave a ticket, if there is breakage, so that it could be fixed. - -##LICENSE - -Under the MIT License: http://mattn.mit-license.org/2013 diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/appveyor.yml b/Godeps/_workspace/src/github.com/go-ole/go-ole/appveyor.yml deleted file mode 100644 index e66dd31a1d..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/appveyor.yml +++ /dev/null @@ -1,63 +0,0 @@ -# Notes: -# - Minimal appveyor.yml file is an empty file. All sections are optional. -# - Indent each level of configuration with 2 spaces. Do not use tabs! -# - All section names are case-sensitive. -# - Section names should be unique on each level. - -version: "1.3.0.{build}-alpha-{branch}" - -os: Windows Server 2012 R2 - -branches: - only: - - master - - v1.2 - - v1.1 - - v1.0 - -skip_tags: true - -clone_folder: c:\gopath\src\github.com\go-ole\go-ole - -environment: - GOPATH: c:\gopath - matrix: - - GOARCH: amd64 - GOVERSION: 1.4 - GOROOT: c:\go - DOWNLOADPLATFORM: "x64" - -install: - - choco install mingw - - SET PATH=c:\tools\mingw64\bin;%PATH% - # - Download COM Server - - ps: Start-FileDownload "https://github.com/go-ole/test-com-server/releases/download/v1.0.2/test-com-server-${env:DOWNLOADPLATFORM}.zip" - - 7z e test-com-server-%DOWNLOADPLATFORM%.zip -oc:\gopath\src\github.com\go-ole\go-ole > NUL - - c:\gopath\src\github.com\go-ole\go-ole\build\register-assembly.bat - # - set - - go version - - go env - - c:\gopath\src\github.com\go-ole\go-ole\build\compile-go.bat - - go tool dist install -v cmd/8a - - go tool dist install -v cmd/8c - - go tool dist install -v cmd/8g - - go tool dist install -v cmd/8l - - go tool dist install -v cmd/6a - - go tool dist install -v cmd/6c - - go tool dist install -v cmd/6g - - go tool dist install -v cmd/6l - - go get -u golang.org/x/tools/cmd/cover - - go get -u golang.org/x/tools/cmd/godoc - - go get -u golang.org/x/tools/cmd/stringer - -build_script: - - cd c:\gopath\src\github.com\go-ole\go-ole - - go get -v -t ./... - - go build - - go test -v -cover ./... - -# disable automatic tests -test: off - -# disable deployment -deploy: off diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/com.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/com.go deleted file mode 100644 index f224fa069a..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/com.go +++ /dev/null @@ -1,329 +0,0 @@ -// +build windows - -package ole - -import ( - "errors" - "syscall" - "time" - "unicode/utf16" - "unsafe" -) - -var ( - procCoInitialize, _ = modole32.FindProc("CoInitialize") - procCoInitializeEx, _ = modole32.FindProc("CoInitializeEx") - procCoUninitialize, _ = modole32.FindProc("CoUninitialize") - procCoCreateInstance, _ = modole32.FindProc("CoCreateInstance") - procCoTaskMemFree, _ = modole32.FindProc("CoTaskMemFree") - procCLSIDFromProgID, _ = modole32.FindProc("CLSIDFromProgID") - procCLSIDFromString, _ = modole32.FindProc("CLSIDFromString") - procStringFromCLSID, _ = modole32.FindProc("StringFromCLSID") - procStringFromIID, _ = modole32.FindProc("StringFromIID") - procIIDFromString, _ = modole32.FindProc("IIDFromString") - procGetUserDefaultLCID, _ = modkernel32.FindProc("GetUserDefaultLCID") - procCopyMemory, _ = modkernel32.FindProc("RtlMoveMemory") - procVariantInit, _ = modoleaut32.FindProc("VariantInit") - procVariantClear, _ = modoleaut32.FindProc("VariantClear") - procVariantTimeToSystemTime, _ = modoleaut32.FindProc("VariantTimeToSystemTime") - procSysAllocString, _ = modoleaut32.FindProc("SysAllocString") - procSysAllocStringLen, _ = modoleaut32.FindProc("SysAllocStringLen") - procSysFreeString, _ = modoleaut32.FindProc("SysFreeString") - procSysStringLen, _ = modoleaut32.FindProc("SysStringLen") - procCreateDispTypeInfo, _ = modoleaut32.FindProc("CreateDispTypeInfo") - procCreateStdDispatch, _ = modoleaut32.FindProc("CreateStdDispatch") - procGetActiveObject, _ = modoleaut32.FindProc("GetActiveObject") - - procGetMessageW, _ = moduser32.FindProc("GetMessageW") - procDispatchMessageW, _ = moduser32.FindProc("DispatchMessageW") -) - -// coInitialize initializes COM library on current thread. -// -// MSDN documentation suggests that this function should not be called. Call -// CoInitializeEx() instead. The reason has to do with threading and this -// function is only for single-threaded apartments. -// -// That said, most users of the library have gotten away with just this -// function. If you are experiencing threading issues, then use -// CoInitializeEx(). -func coInitialize() (err error) { - // http://msdn.microsoft.com/en-us/library/windows/desktop/ms678543(v=vs.85).aspx - // Suggests that no value should be passed to CoInitialized. - // Could just be Call() since the parameter is optional. <-- Needs testing to be sure. - hr, _, _ := procCoInitialize.Call(uintptr(0)) - if hr != 0 { - err = NewError(hr) - } - return -} - -// coInitializeEx initializes COM library with concurrency model. -func coInitializeEx(coinit uint32) (err error) { - // http://msdn.microsoft.com/en-us/library/windows/desktop/ms695279(v=vs.85).aspx - // Suggests that the first parameter is not only optional but should always be NULL. - hr, _, _ := procCoInitializeEx.Call(uintptr(0), uintptr(coinit)) - if hr != 0 { - err = NewError(hr) - } - return -} - -// CoInitialize initializes COM library on current thread. -// -// MSDN documentation suggests that this function should not be called. Call -// CoInitializeEx() instead. The reason has to do with threading and this -// function is only for single-threaded apartments. -// -// That said, most users of the library have gotten away with just this -// function. If you are experiencing threading issues, then use -// CoInitializeEx(). -func CoInitialize(p uintptr) (err error) { - // p is ignored and won't be used. - // Avoid any variable not used errors. - p = uintptr(0) - return coInitialize() -} - -// CoInitializeEx initializes COM library with concurrency model. -func CoInitializeEx(p uintptr, coinit uint32) (err error) { - // Avoid any variable not used errors. - p = uintptr(0) - return coInitializeEx(coinit) -} - -// CoUninitialize uninitializes COM Library. -func CoUninitialize() { - procCoUninitialize.Call() -} - -// CoTaskMemFree frees memory pointer. -func CoTaskMemFree(memptr uintptr) { - procCoTaskMemFree.Call(memptr) -} - -// CLSIDFromProgID retrieves Class Identifier with the given Program Identifier. -// -// The Programmatic Identifier must be registered, because it will be looked up -// in the Windows Registry. The registry entry has the following keys: CLSID, -// Insertable, Protocol and Shell -// (https://msdn.microsoft.com/en-us/library/dd542719(v=vs.85).aspx). -// -// programID identifies the class id with less precision and is not guaranteed -// to be unique. These are usually found in the registry under -// HKEY_LOCAL_MACHINE\SOFTWARE\Classes, usually with the format of -// "Program.Component.Version" with version being optional. -// -// CLSIDFromProgID in Windows API. -func CLSIDFromProgID(progId string) (clsid *GUID, err error) { - var guid GUID - lpszProgID := uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(progId))) - hr, _, _ := procCLSIDFromProgID.Call(lpszProgID, uintptr(unsafe.Pointer(&guid))) - if hr != 0 { - err = NewError(hr) - } - clsid = &guid - return -} - -// CLSIDFromString retrieves Class ID from string representation. -// -// This is technically the string version of the GUID and will convert the -// string to object. -// -// CLSIDFromString in Windows API. -func CLSIDFromString(str string) (clsid *GUID, err error) { - var guid GUID - lpsz := uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(str))) - hr, _, _ := procCLSIDFromString.Call(lpsz, uintptr(unsafe.Pointer(&guid))) - if hr != 0 { - err = NewError(hr) - } - clsid = &guid - return -} - -// StringFromCLSID returns GUID formated string from GUID object. -func StringFromCLSID(clsid *GUID) (str string, err error) { - var p *uint16 - hr, _, _ := procStringFromCLSID.Call(uintptr(unsafe.Pointer(clsid)), uintptr(unsafe.Pointer(&p))) - if hr != 0 { - err = NewError(hr) - } - str = LpOleStrToString(p) - return -} - -// IIDFromString returns GUID from program ID. -func IIDFromString(progId string) (clsid *GUID, err error) { - var guid GUID - lpsz := uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(progId))) - hr, _, _ := procIIDFromString.Call(lpsz, uintptr(unsafe.Pointer(&guid))) - if hr != 0 { - err = NewError(hr) - } - clsid = &guid - return -} - -// StringFromIID returns GUID formatted string from GUID object. -func StringFromIID(iid *GUID) (str string, err error) { - var p *uint16 - hr, _, _ := procStringFromIID.Call(uintptr(unsafe.Pointer(iid)), uintptr(unsafe.Pointer(&p))) - if hr != 0 { - err = NewError(hr) - } - str = LpOleStrToString(p) - return -} - -// CreateInstance of single uninitialized object with GUID. -func CreateInstance(clsid *GUID, iid *GUID) (unk *IUnknown, err error) { - if iid == nil { - iid = IID_IUnknown - } - hr, _, _ := procCoCreateInstance.Call( - uintptr(unsafe.Pointer(clsid)), - 0, - CLSCTX_SERVER, - uintptr(unsafe.Pointer(iid)), - uintptr(unsafe.Pointer(&unk))) - if hr != 0 { - err = NewError(hr) - } - return -} - -// GetActiveObject retrieves pointer to active object. -func GetActiveObject(clsid *GUID, iid *GUID) (unk *IUnknown, err error) { - if iid == nil { - iid = IID_IUnknown - } - hr, _, _ := procGetActiveObject.Call( - uintptr(unsafe.Pointer(clsid)), - uintptr(unsafe.Pointer(iid)), - uintptr(unsafe.Pointer(&unk))) - if hr != 0 { - err = NewError(hr) - } - return -} - -// VariantInit initializes variant. -func VariantInit(v *VARIANT) (err error) { - hr, _, _ := procVariantInit.Call(uintptr(unsafe.Pointer(v))) - if hr != 0 { - err = NewError(hr) - } - return -} - -// VariantClear clears value in Variant settings to VT_EMPTY. -func VariantClear(v *VARIANT) (err error) { - hr, _, _ := procVariantClear.Call(uintptr(unsafe.Pointer(v))) - if hr != 0 { - err = NewError(hr) - } - return -} - -// SysAllocString allocates memory for string and copies string into memory. -func SysAllocString(v string) (ss *int16) { - pss, _, _ := procSysAllocString.Call(uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(v)))) - ss = (*int16)(unsafe.Pointer(pss)) - return -} - -// SysAllocStringLen copies up to length of given string returning pointer. -func SysAllocStringLen(v string) (ss *int16) { - utf16 := utf16.Encode([]rune(v + "\x00")) - ptr := &utf16[0] - - pss, _, _ := procSysAllocStringLen.Call(uintptr(unsafe.Pointer(ptr)), uintptr(len(utf16)-1)) - ss = (*int16)(unsafe.Pointer(pss)) - return -} - -// SysFreeString frees string system memory. This must be called with SysAllocString. -func SysFreeString(v *int16) (err error) { - hr, _, _ := procSysFreeString.Call(uintptr(unsafe.Pointer(v))) - if hr != 0 { - err = NewError(hr) - } - return -} - -// SysStringLen is the length of the system allocated string. -func SysStringLen(v *int16) uint32 { - l, _, _ := procSysStringLen.Call(uintptr(unsafe.Pointer(v))) - return uint32(l) -} - -// CreateStdDispatch provides default IDispatch implementation for IUnknown. -// -// This handles default IDispatch implementation for objects. It haves a few -// limitations with only supporting one language. It will also only return -// default exception codes. -func CreateStdDispatch(unk *IUnknown, v uintptr, ptinfo *IUnknown) (disp *IDispatch, err error) { - hr, _, _ := procCreateStdDispatch.Call( - uintptr(unsafe.Pointer(unk)), - v, - uintptr(unsafe.Pointer(ptinfo)), - uintptr(unsafe.Pointer(&disp))) - if hr != 0 { - err = NewError(hr) - } - return -} - -// CreateDispTypeInfo provides default ITypeInfo implementation for IDispatch. -// -// This will not handle the full implementation of the interface. -func CreateDispTypeInfo(idata *INTERFACEDATA) (pptinfo *IUnknown, err error) { - hr, _, _ := procCreateDispTypeInfo.Call( - uintptr(unsafe.Pointer(idata)), - uintptr(GetUserDefaultLCID()), - uintptr(unsafe.Pointer(&pptinfo))) - if hr != 0 { - err = NewError(hr) - } - return -} - -// copyMemory moves location of a block of memory. -func copyMemory(dest unsafe.Pointer, src unsafe.Pointer, length uint32) { - procCopyMemory.Call(uintptr(dest), uintptr(src), uintptr(length)) -} - -// GetUserDefaultLCID retrieves current user default locale. -func GetUserDefaultLCID() (lcid uint32) { - ret, _, _ := procGetUserDefaultLCID.Call() - lcid = uint32(ret) - return -} - -// GetMessage in message queue from runtime. -// -// This function appears to block. PeekMessage does not block. -func GetMessage(msg *Msg, hwnd uint32, MsgFilterMin uint32, MsgFilterMax uint32) (ret int32, err error) { - r0, _, err := procGetMessageW.Call(uintptr(unsafe.Pointer(msg)), uintptr(hwnd), uintptr(MsgFilterMin), uintptr(MsgFilterMax)) - ret = int32(r0) - return -} - -// DispatchMessage to window procedure. -func DispatchMessage(msg *Msg) (ret int32) { - r0, _, _ := procDispatchMessageW.Call(uintptr(unsafe.Pointer(msg))) - ret = int32(r0) - return -} - -// GetVariantDate converts COM Variant Time value to Go time.Time. -func GetVariantDate(value float64) (time.Time, error) { - var st syscall.Systemtime - r, _, _ := procVariantTimeToSystemTime.Call(uintptr(unsafe.Pointer(&value)), uintptr(unsafe.Pointer(&st))) - if r != 0 { - return time.Date(int(st.Year), time.Month(st.Month), int(st.Day), int(st.Hour), int(st.Minute), int(st.Second), int(st.Milliseconds/1000), nil), nil - } - return time.Now(), errors.New("Could not convert to time, passing current time.") -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/com_func.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/com_func.go deleted file mode 100644 index 425aad3233..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/com_func.go +++ /dev/null @@ -1,174 +0,0 @@ -// +build !windows - -package ole - -import ( - "time" - "unsafe" -) - -// coInitialize initializes COM library on current thread. -// -// MSDN documentation suggests that this function should not be called. Call -// CoInitializeEx() instead. The reason has to do with threading and this -// function is only for single-threaded apartments. -// -// That said, most users of the library have gotten away with just this -// function. If you are experiencing threading issues, then use -// CoInitializeEx(). -func coInitialize() error { - return NewError(E_NOTIMPL) -} - -// coInitializeEx initializes COM library with concurrency model. -func coInitializeEx(coinit uint32) error { - return NewError(E_NOTIMPL) -} - -// CoInitialize initializes COM library on current thread. -// -// MSDN documentation suggests that this function should not be called. Call -// CoInitializeEx() instead. The reason has to do with threading and this -// function is only for single-threaded apartments. -// -// That said, most users of the library have gotten away with just this -// function. If you are experiencing threading issues, then use -// CoInitializeEx(). -func CoInitialize(p uintptr) error { - return NewError(E_NOTIMPL) -} - -// CoInitializeEx initializes COM library with concurrency model. -func CoInitializeEx(p uintptr, coinit uint32) error { - return NewError(E_NOTIMPL) -} - -// CoUninitialize uninitializes COM Library. -func CoUninitialize() {} - -// CoTaskMemFree frees memory pointer. -func CoTaskMemFree(memptr uintptr) {} - -// CLSIDFromProgID retrieves Class Identifier with the given Program Identifier. -// -// The Programmatic Identifier must be registered, because it will be looked up -// in the Windows Registry. The registry entry has the following keys: CLSID, -// Insertable, Protocol and Shell -// (https://msdn.microsoft.com/en-us/library/dd542719(v=vs.85).aspx). -// -// programID identifies the class id with less precision and is not guaranteed -// to be unique. These are usually found in the registry under -// HKEY_LOCAL_MACHINE\SOFTWARE\Classes, usually with the format of -// "Program.Component.Version" with version being optional. -// -// CLSIDFromProgID in Windows API. -func CLSIDFromProgID(progId string) (*GUID, error) { - return nil, NewError(E_NOTIMPL) -} - -// CLSIDFromString retrieves Class ID from string representation. -// -// This is technically the string version of the GUID and will convert the -// string to object. -// -// CLSIDFromString in Windows API. -func CLSIDFromString(str string) (*GUID, error) { - return nil, NewError(E_NOTIMPL) -} - -// StringFromCLSID returns GUID formated string from GUID object. -func StringFromCLSID(clsid *GUID) (string, error) { - return "", NewError(E_NOTIMPL) -} - -// IIDFromString returns GUID from program ID. -func IIDFromString(progId string) (*GUID, error) { - return nil, NewError(E_NOTIMPL) -} - -// StringFromIID returns GUID formatted string from GUID object. -func StringFromIID(iid *GUID) (string, error) { - return "", NewError(E_NOTIMPL) -} - -// CreateInstance of single uninitialized object with GUID. -func CreateInstance(clsid *GUID, iid *GUID) (*IUnknown, error) { - return nil, NewError(E_NOTIMPL) -} - -// GetActiveObject retrieves pointer to active object. -func GetActiveObject(clsid *GUID, iid *GUID) (*IUnknown, error) { - return nil, NewError(E_NOTIMPL) -} - -// VariantInit initializes variant. -func VariantInit(v *VARIANT) error { - return NewError(E_NOTIMPL) -} - -// VariantClear clears value in Variant settings to VT_EMPTY. -func VariantClear(v *VARIANT) error { - return NewError(E_NOTIMPL) -} - -// SysAllocString allocates memory for string and copies string into memory. -func SysAllocString(v string) *int16 { - u := int16(0) - return &u -} - -// SysAllocStringLen copies up to length of given string returning pointer. -func SysAllocStringLen(v string) *int16 { - u := int16(0) - return &u -} - -// SysFreeString frees string system memory. This must be called with SysAllocString. -func SysFreeString(v *int16) error { - return NewError(E_NOTIMPL) -} - -// SysStringLen is the length of the system allocated string. -func SysStringLen(v *int16) uint32 { - return uint32(0) -} - -// CreateStdDispatch provides default IDispatch implementation for IUnknown. -// -// This handles default IDispatch implementation for objects. It haves a few -// limitations with only supporting one language. It will also only return -// default exception codes. -func CreateStdDispatch(unk *IUnknown, v uintptr, ptinfo *IUnknown) (*IDispatch, error) { - return nil, NewError(E_NOTIMPL) -} - -// CreateDispTypeInfo provides default ITypeInfo implementation for IDispatch. -// -// This will not handle the full implementation of the interface. -func CreateDispTypeInfo(idata *INTERFACEDATA) (*IUnknown, error) { - return nil, NewError(E_NOTIMPL) -} - -// copyMemory moves location of a block of memory. -func copyMemory(dest unsafe.Pointer, src unsafe.Pointer, length uint32) {} - -// GetUserDefaultLCID retrieves current user default locale. -func GetUserDefaultLCID() uint32 { - return uint32(0) -} - -// GetMessage in message queue from runtime. -// -// This function appears to block. PeekMessage does not block. -func GetMessage(msg *Msg, hwnd uint32, MsgFilterMin uint32, MsgFilterMax uint32) (int32, error) { - return int32(0), NewError(E_NOTIMPL) -} - -// DispatchMessage to window procedure. -func DispatchMessage(msg *Msg) int32 { - return int32(0) -} - -func GetVariantDate(value float64) (time.Time, error) { - return time.Now(), NewError(E_NOTIMPL) -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/connect.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/connect.go deleted file mode 100644 index b2ac2ec67a..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/connect.go +++ /dev/null @@ -1,192 +0,0 @@ -package ole - -// Connection contains IUnknown for fluent interface interaction. -// -// Deprecated. Use oleutil package instead. -type Connection struct { - Object *IUnknown // Access COM -} - -// Initialize COM. -func (*Connection) Initialize() (err error) { - return coInitialize() -} - -// Uninitialize COM. -func (*Connection) Uninitialize() { - CoUninitialize() -} - -// Create IUnknown object based first on ProgId and then from String. -func (c *Connection) Create(progId string) (err error) { - var clsid *GUID - clsid, err = CLSIDFromProgID(progId) - if err != nil { - clsid, err = CLSIDFromString(progId) - if err != nil { - return - } - } - - unknown, err := CreateInstance(clsid, IID_IUnknown) - if err != nil { - return - } - c.Object = unknown - - return -} - -// Release IUnknown object. -func (c *Connection) Release() { - c.Object.Release() -} - -// Load COM object from list of programIDs or strings. -func (c *Connection) Load(names ...string) (errors []error) { - var tempErrors []error = make([]error, len(names)) - var numErrors int = 0 - for _, name := range names { - err := c.Create(name) - if err != nil { - tempErrors = append(tempErrors, err) - numErrors += 1 - continue - } - break - } - - copy(errors, tempErrors[0:numErrors]) - return -} - -// Dispatch returns Dispatch object. -func (c *Connection) Dispatch() (object *Dispatch, err error) { - dispatch, err := c.Object.QueryInterface(IID_IDispatch) - if err != nil { - return - } - object = &Dispatch{dispatch} - return -} - -// Dispatch stores IDispatch object. -type Dispatch struct { - Object *IDispatch // Dispatch object. -} - -// Call method on IDispatch with parameters. -func (d *Dispatch) Call(method string, params ...interface{}) (result *VARIANT, err error) { - id, err := d.GetId(method) - if err != nil { - return - } - - result, err = d.Invoke(id, DISPATCH_METHOD, params) - return -} - -// MustCall method on IDispatch with parameters. -func (d *Dispatch) MustCall(method string, params ...interface{}) (result *VARIANT) { - id, err := d.GetId(method) - if err != nil { - panic(err) - } - - result, err = d.Invoke(id, DISPATCH_METHOD, params) - if err != nil { - panic(err) - } - - return -} - -// Get property on IDispatch with parameters. -func (d *Dispatch) Get(name string, params ...interface{}) (result *VARIANT, err error) { - id, err := d.GetId(name) - if err != nil { - return - } - result, err = d.Invoke(id, DISPATCH_PROPERTYGET, params) - return -} - -// MustGet property on IDispatch with parameters. -func (d *Dispatch) MustGet(name string, params ...interface{}) (result *VARIANT) { - id, err := d.GetId(name) - if err != nil { - panic(err) - } - - result, err = d.Invoke(id, DISPATCH_PROPERTYGET, params) - if err != nil { - panic(err) - } - return -} - -// Set property on IDispatch with parameters. -func (d *Dispatch) Set(name string, params ...interface{}) (result *VARIANT, err error) { - id, err := d.GetId(name) - if err != nil { - return - } - result, err = d.Invoke(id, DISPATCH_PROPERTYPUT, params) - return -} - -// MustSet property on IDispatch with parameters. -func (d *Dispatch) MustSet(name string, params ...interface{}) (result *VARIANT) { - id, err := d.GetId(name) - if err != nil { - panic(err) - } - - result, err = d.Invoke(id, DISPATCH_PROPERTYPUT, params) - if err != nil { - panic(err) - } - return -} - -// GetId retrieves ID of name on IDispatch. -func (d *Dispatch) GetId(name string) (id int32, err error) { - var dispid []int32 - dispid, err = d.Object.GetIDsOfName([]string{name}) - if err != nil { - return - } - id = dispid[0] - return -} - -// GetIds retrieves all IDs of names on IDispatch. -func (d *Dispatch) GetIds(names ...string) (dispid []int32, err error) { - dispid, err = d.Object.GetIDsOfName(names) - return -} - -// Invoke IDispatch on DisplayID of dispatch type with parameters. -// -// There have been problems where if send cascading params..., it would error -// out because the parameters would be empty. -func (d *Dispatch) Invoke(id int32, dispatch int16, params []interface{}) (result *VARIANT, err error) { - if len(params) < 1 { - result, err = d.Object.Invoke(id, dispatch) - } else { - result, err = d.Object.Invoke(id, dispatch, params...) - } - return -} - -// Release IDispatch object. -func (d *Dispatch) Release() { - d.Object.Release() -} - -// Connect initializes COM and attempts to load IUnknown based on given names. -func Connect(names ...string) (connection *Connection) { - connection.Initialize() - connection.Load(names...) - return -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/constants.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/constants.go deleted file mode 100644 index fd0c6d74b0..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/constants.go +++ /dev/null @@ -1,153 +0,0 @@ -package ole - -const ( - CLSCTX_INPROC_SERVER = 1 - CLSCTX_INPROC_HANDLER = 2 - CLSCTX_LOCAL_SERVER = 4 - CLSCTX_INPROC_SERVER16 = 8 - CLSCTX_REMOTE_SERVER = 16 - CLSCTX_ALL = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER - CLSCTX_INPROC = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER - CLSCTX_SERVER = CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER -) - -const ( - COINIT_APARTMENTTHREADED = 0x2 - COINIT_MULTITHREADED = 0x0 - COINIT_DISABLE_OLE1DDE = 0x4 - COINIT_SPEED_OVER_MEMORY = 0x8 -) - -const ( - DISPATCH_METHOD = 1 - DISPATCH_PROPERTYGET = 2 - DISPATCH_PROPERTYPUT = 4 - DISPATCH_PROPERTYPUTREF = 8 -) - -const ( - S_OK = 0x00000000 - E_UNEXPECTED = 0x8000FFFF - E_NOTIMPL = 0x80004001 - E_OUTOFMEMORY = 0x8007000E - E_INVALIDARG = 0x80070057 - E_NOINTERFACE = 0x80004002 - E_POINTER = 0x80004003 - E_HANDLE = 0x80070006 - E_ABORT = 0x80004004 - E_FAIL = 0x80004005 - E_ACCESSDENIED = 0x80070005 - E_PENDING = 0x8000000A - - CO_E_CLASSSTRING = 0x800401F3 -) - -const ( - CC_FASTCALL = iota - CC_CDECL - CC_MSCPASCAL - CC_PASCAL = CC_MSCPASCAL - CC_MACPASCAL - CC_STDCALL - CC_FPFASTCALL - CC_SYSCALL - CC_MPWCDECL - CC_MPWPASCAL - CC_MAX = CC_MPWPASCAL -) - -type VT uint16 - -const ( - VT_EMPTY VT = 0x0 - VT_NULL VT = 0x1 - VT_I2 VT = 0x2 - VT_I4 VT = 0x3 - VT_R4 VT = 0x4 - VT_R8 VT = 0x5 - VT_CY VT = 0x6 - VT_DATE VT = 0x7 - VT_BSTR VT = 0x8 - VT_DISPATCH VT = 0x9 - VT_ERROR VT = 0xa - VT_BOOL VT = 0xb - VT_VARIANT VT = 0xc - VT_UNKNOWN VT = 0xd - VT_DECIMAL VT = 0xe - VT_I1 VT = 0x10 - VT_UI1 VT = 0x11 - VT_UI2 VT = 0x12 - VT_UI4 VT = 0x13 - VT_I8 VT = 0x14 - VT_UI8 VT = 0x15 - VT_INT VT = 0x16 - VT_UINT VT = 0x17 - VT_VOID VT = 0x18 - VT_HRESULT VT = 0x19 - VT_PTR VT = 0x1a - VT_SAFEARRAY VT = 0x1b - VT_CARRAY VT = 0x1c - VT_USERDEFINED VT = 0x1d - VT_LPSTR VT = 0x1e - VT_LPWSTR VT = 0x1f - VT_RECORD VT = 0x24 - VT_INT_PTR VT = 0x25 - VT_UINT_PTR VT = 0x26 - VT_FILETIME VT = 0x40 - VT_BLOB VT = 0x41 - VT_STREAM VT = 0x42 - VT_STORAGE VT = 0x43 - VT_STREAMED_OBJECT VT = 0x44 - VT_STORED_OBJECT VT = 0x45 - VT_BLOB_OBJECT VT = 0x46 - VT_CF VT = 0x47 - VT_CLSID VT = 0x48 - VT_BSTR_BLOB VT = 0xfff - VT_VECTOR VT = 0x1000 - VT_ARRAY VT = 0x2000 - VT_BYREF VT = 0x4000 - VT_RESERVED VT = 0x8000 - VT_ILLEGAL VT = 0xffff - VT_ILLEGALMASKED VT = 0xfff - VT_TYPEMASK VT = 0xfff -) - -const ( - DISPID_UNKNOWN = -1 - DISPID_VALUE = 0 - DISPID_PROPERTYPUT = -3 - DISPID_NEWENUM = -4 - DISPID_EVALUATE = -5 - DISPID_CONSTRUCTOR = -6 - DISPID_DESTRUCTOR = -7 - DISPID_COLLECT = -8 -) - -const ( - TKIND_ENUM = 1 - TKIND_RECORD = 2 - TKIND_MODULE = 3 - TKIND_INTERFACE = 4 - TKIND_DISPATCH = 5 - TKIND_COCLASS = 6 - TKIND_ALIAS = 7 - TKIND_UNION = 8 - TKIND_MAX = 9 -) - -// Safe Array Feature Flags - -const ( - FADF_AUTO = 0x0001 - FADF_STATIC = 0x0002 - FADF_EMBEDDED = 0x0004 - FADF_FIXEDSIZE = 0x0010 - FADF_RECORD = 0x0020 - FADF_HAVEIID = 0x0040 - FADF_HAVEVARTYPE = 0x0080 - FADF_BSTR = 0x0100 - FADF_UNKNOWN = 0x0200 - FADF_DISPATCH = 0x0400 - FADF_VARIANT = 0x0800 - FADF_RESERVED = 0xF008 -) diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/error.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/error.go deleted file mode 100644 index 096b456d3a..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/error.go +++ /dev/null @@ -1,51 +0,0 @@ -package ole - -// OleError stores COM errors. -type OleError struct { - hr uintptr - description string - subError error -} - -// NewError creates new error with HResult. -func NewError(hr uintptr) *OleError { - return &OleError{hr: hr} -} - -// NewErrorWithDescription creates new COM error with HResult and description. -func NewErrorWithDescription(hr uintptr, description string) *OleError { - return &OleError{hr: hr, description: description} -} - -// NewErrorWithSubError creates new COM error with parent error. -func NewErrorWithSubError(hr uintptr, description string, err error) *OleError { - return &OleError{hr: hr, description: description, subError: err} -} - -// Code is the HResult. -func (v *OleError) Code() uintptr { - return uintptr(v.hr) -} - -// String description, either manually set or format message with error code. -func (v *OleError) String() string { - if v.description != "" { - return errstr(int(v.hr)) + " (" + v.description + ")" - } - return errstr(int(v.hr)) -} - -// Error implements error interface. -func (v *OleError) Error() string { - return v.String() -} - -// Description retrieves error summary, if there is one. -func (v *OleError) Description() string { - return v.description -} - -// SubError returns parent error, if there is one. -func (v *OleError) SubError() error { - return v.subError -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/error_func.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/error_func.go deleted file mode 100644 index 8a2ffaa272..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/error_func.go +++ /dev/null @@ -1,8 +0,0 @@ -// +build !windows - -package ole - -// errstr converts error code to string. -func errstr(errno int) string { - return "" -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/error_windows.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/error_windows.go deleted file mode 100644 index d0e8e68595..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/error_windows.go +++ /dev/null @@ -1,24 +0,0 @@ -// +build windows - -package ole - -import ( - "fmt" - "syscall" - "unicode/utf16" -) - -// errstr converts error code to string. -func errstr(errno int) string { - // ask windows for the remaining errors - var flags uint32 = syscall.FORMAT_MESSAGE_FROM_SYSTEM | syscall.FORMAT_MESSAGE_ARGUMENT_ARRAY | syscall.FORMAT_MESSAGE_IGNORE_INSERTS - b := make([]uint16, 300) - n, err := syscall.FormatMessage(flags, 0, uint32(errno), 0, b, nil) - if err != nil { - return fmt.Sprintf("error %d (FormatMessage failed with: %v)", errno, err) - } - // trim terminating \r and \n - for ; n > 0 && (b[n-1] == '\n' || b[n-1] == '\r'); n-- { - } - return string(utf16.Decode(b[:n])) -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/guid.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/guid.go deleted file mode 100644 index 609ef0bfe3..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/guid.go +++ /dev/null @@ -1,118 +0,0 @@ -package ole - -var ( - // IID_NULL is null Interface ID, used when no other Interface ID is known. - IID_NULL = &GUID{0x00000000, 0x0000, 0x0000, [8]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}} - - // IID_IUnknown is for IUnknown interfaces. - IID_IUnknown = &GUID{0x00000000, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} - - // IID_IDispatch is for IDispatch interfaces. - IID_IDispatch = &GUID{0x00020400, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} - - // IID_IEnumVariant is for IEnumVariant interfaces - IID_IEnumVariant = &GUID{0x00020404, 0x0000, 0x0000, [8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}} - - // IID_IConnectionPointContainer is for IConnectionPointContainer interfaces. - IID_IConnectionPointContainer = &GUID{0xB196B284, 0xBAB4, 0x101A, [8]byte{0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07}} - - // IID_IConnectionPoint is for IConnectionPoint interfaces. - IID_IConnectionPoint = &GUID{0xB196B286, 0xBAB4, 0x101A, [8]byte{0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07}} - - // IID_IInspectable is for IInspectable interfaces. - IID_IInspectable = &GUID{0xaf86e2e0, 0xb12d, 0x4c6a, [8]byte{0x9c, 0x5a, 0xd7, 0xaa, 0x65, 0x10, 0x1e, 0x90}} - - // IID_IProvideClassInfo is for IProvideClassInfo interfaces. - IID_IProvideClassInfo = &GUID{0xb196b283, 0xbab4, 0x101a, [8]byte{0xB6, 0x9C, 0x00, 0xAA, 0x00, 0x34, 0x1D, 0x07}} -) - -// These are for testing and not part of any library. -var ( - // IID_ICOMTestString is for ICOMTestString interfaces. - // - // {E0133EB4-C36F-469A-9D3D-C66B84BE19ED} - IID_ICOMTestString = &GUID{0xe0133eb4, 0xc36f, 0x469a, [8]byte{0x9d, 0x3d, 0xc6, 0x6b, 0x84, 0xbe, 0x19, 0xed}} - - // IID_ICOMTestInt8 is for ICOMTestInt8 interfaces. - // - // {BEB06610-EB84-4155-AF58-E2BFF53608B4} - IID_ICOMTestInt8 = &GUID{0xbeb06610, 0xeb84, 0x4155, [8]byte{0xaf, 0x58, 0xe2, 0xbf, 0xf5, 0x36, 0x80, 0xb4}} - - // IID_ICOMTestInt16 is for ICOMTestInt16 interfaces. - // - // {DAA3F9FA-761E-4976-A860-8364CE55F6FC} - IID_ICOMTestInt16 = &GUID{0xdaa3f9fa, 0x761e, 0x4976, [8]byte{0xa8, 0x60, 0x83, 0x64, 0xce, 0x55, 0xf6, 0xfc}} - - // IID_ICOMTestInt32 is for ICOMTestInt32 interfaces. - // - // {E3DEDEE7-38A2-4540-91D1-2EEF1D8891B0} - IID_ICOMTestInt32 = &GUID{0xe3dedee7, 0x38a2, 0x4540, [8]byte{0x91, 0xd1, 0x2e, 0xef, 0x1d, 0x88, 0x91, 0xb0}} - - // IID_ICOMTestInt64 is for ICOMTestInt64 interfaces. - // - // {8D437CBC-B3ED-485C-BC32-C336432A1623} - IID_ICOMTestInt64 = &GUID{0x8d437cbc, 0xb3ed, 0x485c, [8]byte{0xbc, 0x32, 0xc3, 0x36, 0x43, 0x2a, 0x16, 0x23}} - - // IID_ICOMTestFloat is for ICOMTestFloat interfaces. - // - // {BF1ED004-EA02-456A-AA55-2AC8AC6B054C} - IID_ICOMTestFloat = &GUID{0xbf1ed004, 0xea02, 0x456a, [8]byte{0xaa, 0x55, 0x2a, 0xc8, 0xac, 0x6b, 0x5, 0x4c}} - - // IID_ICOMTestDouble is for ICOMTestDouble interfaces. - // - // {BF908A81-8687-4E93-999F-D86FAB284BA0} - IID_ICOMTestDouble = &GUID{0xbf908a81, 0x8687, 0x4e93, [8]byte{0x99, 0x9f, 0xd8, 0x6f, 0xab, 0x28, 0x4b, 0xa0}} - - // IID_ICOMTestBoolean is for ICOMTestBoolean interfaces. - // - // {D530E7A6-4EE8-40D1-8931-3D63B8605001} - IID_ICOMTestBoolean = &GUID{0xd530e7a6, 0x4ee8, 0x40d1, [8]byte{0x89, 0x31, 0x3d, 0x63, 0xb8, 0x60, 0x50, 0x10}} - - // IID_ICOMEchoTestObject is for ICOMEchoTestObject interfaces. - // - // {6485B1EF-D780-4834-A4FE-1EBB51746CA3} - IID_ICOMEchoTestObject = &GUID{0x6485b1ef, 0xd780, 0x4834, [8]byte{0xa4, 0xfe, 0x1e, 0xbb, 0x51, 0x74, 0x6c, 0xa3}} - - // IID_ICOMTestTypes is for ICOMTestTypes interfaces. - // - // {CCA8D7AE-91C0-4277-A8B3-FF4EDF28D3C0} - IID_ICOMTestTypes = &GUID{0xcca8d7ae, 0x91c0, 0x4277, [8]byte{0xa8, 0xb3, 0xff, 0x4e, 0xdf, 0x28, 0xd3, 0xc0}} - - // CLSID_COMEchoTestObject is for COMEchoTestObject class. - // - // {3C24506A-AE9E-4D50-9157-EF317281F1B0} - CLSID_COMEchoTestObject = &GUID{0x3c24506a, 0xae9e, 0x4d50, [8]byte{0x91, 0x57, 0xef, 0x31, 0x72, 0x81, 0xf1, 0xb0}} - - // CLSID_COMTestScalarClass is for COMTestScalarClass class. - // - // {865B85C5-0334-4AC6-9EF6-AACEC8FC5E86} - CLSID_COMTestScalarClass = &GUID{0x865b85c5, 0x0334, 0x4ac6, [8]byte{0x9e, 0xf6, 0xaa, 0xce, 0xc8, 0xfc, 0x5e, 0x86}} -) - -// GUID is Windows API specific GUID type. -// -// This exists to match Windows GUID type for direct passing for COM. -// Format is in xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx. -type GUID struct { - Data1 uint32 - Data2 uint16 - Data3 uint16 - Data4 [8]byte -} - -// IsEqualGUID compares two GUID. -// -// Not constant time comparison. -func IsEqualGUID(guid1 *GUID, guid2 *GUID) bool { - return guid1.Data1 == guid2.Data1 && - guid1.Data2 == guid2.Data2 && - guid1.Data3 == guid2.Data3 && - guid1.Data4[0] == guid2.Data4[0] && - guid1.Data4[1] == guid2.Data4[1] && - guid1.Data4[2] == guid2.Data4[2] && - guid1.Data4[3] == guid2.Data4[3] && - guid1.Data4[4] == guid2.Data4[4] && - guid1.Data4[5] == guid2.Data4[5] && - guid1.Data4[6] == guid2.Data4[6] && - guid1.Data4[7] == guid2.Data4[7] -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpoint.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpoint.go deleted file mode 100644 index 9e6c49f41f..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpoint.go +++ /dev/null @@ -1,20 +0,0 @@ -package ole - -import "unsafe" - -type IConnectionPoint struct { - IUnknown -} - -type IConnectionPointVtbl struct { - IUnknownVtbl - GetConnectionInterface uintptr - GetConnectionPointContainer uintptr - Advise uintptr - Unadvise uintptr - EnumConnections uintptr -} - -func (v *IConnectionPoint) VTable() *IConnectionPointVtbl { - return (*IConnectionPointVtbl)(unsafe.Pointer(v.RawVTable)) -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpoint_func.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpoint_func.go deleted file mode 100644 index 5414dc3cd3..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpoint_func.go +++ /dev/null @@ -1,21 +0,0 @@ -// +build !windows - -package ole - -import "unsafe" - -func (v *IConnectionPoint) GetConnectionInterface(piid **GUID) int32 { - return int32(0) -} - -func (v *IConnectionPoint) Advise(unknown *IUnknown) (uint32, error) { - return uint32(0), NewError(E_NOTIMPL) -} - -func (v *IConnectionPoint) Unadvise(cookie uint32) error { - return NewError(E_NOTIMPL) -} - -func (v *IConnectionPoint) EnumConnections(p *unsafe.Pointer) (err error) { - return NewError(E_NOTIMPL) -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpoint_windows.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpoint_windows.go deleted file mode 100644 index 32bc183248..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpoint_windows.go +++ /dev/null @@ -1,43 +0,0 @@ -// +build windows - -package ole - -import ( - "syscall" - "unsafe" -) - -func (v *IConnectionPoint) GetConnectionInterface(piid **GUID) int32 { - // XXX: This doesn't look like it does what it's supposed to - return release((*IUnknown)(unsafe.Pointer(v))) -} - -func (v *IConnectionPoint) Advise(unknown *IUnknown) (cookie uint32, err error) { - hr, _, _ := syscall.Syscall( - v.VTable().Advise, - 3, - uintptr(unsafe.Pointer(v)), - uintptr(unsafe.Pointer(unknown)), - uintptr(unsafe.Pointer(&cookie))) - if hr != 0 { - err = NewError(hr) - } - return -} - -func (v *IConnectionPoint) Unadvise(cookie uint32) (err error) { - hr, _, _ := syscall.Syscall( - v.VTable().Unadvise, - 2, - uintptr(unsafe.Pointer(v)), - uintptr(cookie), - 0) - if hr != 0 { - err = NewError(hr) - } - return -} - -func (v *IConnectionPoint) EnumConnections(p *unsafe.Pointer) error { - return NewError(E_NOTIMPL) -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpointcontainer.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpointcontainer.go deleted file mode 100644 index 165860d199..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpointcontainer.go +++ /dev/null @@ -1,17 +0,0 @@ -package ole - -import "unsafe" - -type IConnectionPointContainer struct { - IUnknown -} - -type IConnectionPointContainerVtbl struct { - IUnknownVtbl - EnumConnectionPoints uintptr - FindConnectionPoint uintptr -} - -func (v *IConnectionPointContainer) VTable() *IConnectionPointContainerVtbl { - return (*IConnectionPointContainerVtbl)(unsafe.Pointer(v.RawVTable)) -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpointcontainer_func.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpointcontainer_func.go deleted file mode 100644 index 5dfa42aaeb..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpointcontainer_func.go +++ /dev/null @@ -1,11 +0,0 @@ -// +build !windows - -package ole - -func (v *IConnectionPointContainer) EnumConnectionPoints(points interface{}) error { - return NewError(E_NOTIMPL) -} - -func (v *IConnectionPointContainer) FindConnectionPoint(iid *GUID, point **IConnectionPoint) error { - return NewError(E_NOTIMPL) -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpointcontainer_windows.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpointcontainer_windows.go deleted file mode 100644 index ad30d79efc..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/iconnectionpointcontainer_windows.go +++ /dev/null @@ -1,25 +0,0 @@ -// +build windows - -package ole - -import ( - "syscall" - "unsafe" -) - -func (v *IConnectionPointContainer) EnumConnectionPoints(points interface{}) error { - return NewError(E_NOTIMPL) -} - -func (v *IConnectionPointContainer) FindConnectionPoint(iid *GUID, point **IConnectionPoint) (err error) { - hr, _, _ := syscall.Syscall( - v.VTable().FindConnectionPoint, - 3, - uintptr(unsafe.Pointer(v)), - uintptr(unsafe.Pointer(iid)), - uintptr(unsafe.Pointer(point))) - if hr != 0 { - err = NewError(hr) - } - return -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/idispatch.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/idispatch.go deleted file mode 100644 index d4af124092..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/idispatch.go +++ /dev/null @@ -1,94 +0,0 @@ -package ole - -import "unsafe" - -type IDispatch struct { - IUnknown -} - -type IDispatchVtbl struct { - IUnknownVtbl - GetTypeInfoCount uintptr - GetTypeInfo uintptr - GetIDsOfNames uintptr - Invoke uintptr -} - -func (v *IDispatch) VTable() *IDispatchVtbl { - return (*IDispatchVtbl)(unsafe.Pointer(v.RawVTable)) -} - -func (v *IDispatch) GetIDsOfName(names []string) (dispid []int32, err error) { - dispid, err = getIDsOfName(v, names) - return -} - -func (v *IDispatch) Invoke(dispid int32, dispatch int16, params ...interface{}) (result *VARIANT, err error) { - result, err = invoke(v, dispid, dispatch, params...) - return -} - -func (v *IDispatch) GetTypeInfoCount() (c uint32, err error) { - c, err = getTypeInfoCount(v) - return -} - -func (v *IDispatch) GetTypeInfo() (tinfo *ITypeInfo, err error) { - tinfo, err = getTypeInfo(v) - return -} - -// GetSingleIDOfName is a helper that returns single display ID for IDispatch name. -// -// This replaces the common pattern of attempting to get a single name from the list of available -// IDs. It gives the first ID, if it is available. -func (v *IDispatch) GetSingleIDOfName(name string) (displayID int32, err error) { - var displayIDs []int32 - displayIDs, err = v.GetIDsOfName([]string{name}) - if err != nil { - return - } - displayID = displayIDs[0] - return -} - -// InvokeWithOptionalArgs accepts arguments as an array, works like Invoke. -// -// Accepts name and will attempt to retrieve Display ID to pass to Invoke. -// -// Passing params as an array is a workaround that could be fixed in later versions of Go that -// prevent passing empty params. During testing it was discovered that this is an acceptable way of -// getting around not being able to pass params normally. -func (v *IDispatch) InvokeWithOptionalArgs(name string, dispatch int16, params []interface{}) (result *VARIANT, err error) { - displayID, err := v.GetSingleIDOfName(name) - if err != nil { - return - } - - if len(params) < 1 { - result, err = v.Invoke(displayID, dispatch) - } else { - result, err = v.Invoke(displayID, dispatch, params...) - } - - return -} - -// CallMethod invokes named function with arguments on object. -func (v *IDispatch) CallMethod(name string, params ...interface{}) (*VARIANT, error) { - return v.InvokeWithOptionalArgs(name, DISPATCH_METHOD, params) -} - -// GetProperty retrieves the property with the name with the ability to pass arguments. -// -// Most of the time you will not need to pass arguments as most objects do not allow for this -// feature. Or at least, should not allow for this feature. Some servers don't follow best practices -// and this is provided for those edge cases. -func (v *IDispatch) GetProperty(name string, params ...interface{}) (*VARIANT, error) { - return v.InvokeWithOptionalArgs(name, DISPATCH_PROPERTYGET, params) -} - -// PutProperty attempts to mutate a property in the object. -func (v *IDispatch) PutProperty(name string, params ...interface{}) (*VARIANT, error) { - return v.InvokeWithOptionalArgs(name, DISPATCH_PROPERTYPUT, params) -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/idispatch_func.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/idispatch_func.go deleted file mode 100644 index b8fbbe319f..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/idispatch_func.go +++ /dev/null @@ -1,19 +0,0 @@ -// +build !windows - -package ole - -func getIDsOfName(disp *IDispatch, names []string) ([]int32, error) { - return []int32{}, NewError(E_NOTIMPL) -} - -func getTypeInfoCount(disp *IDispatch) (uint32, error) { - return uint32(0), NewError(E_NOTIMPL) -} - -func getTypeInfo(disp *IDispatch) (*ITypeInfo, error) { - return nil, NewError(E_NOTIMPL) -} - -func invoke(disp *IDispatch, dispid int32, dispatch int16, params ...interface{}) (*VARIANT, error) { - return nil, NewError(E_NOTIMPL) -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/idispatch_windows.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/idispatch_windows.go deleted file mode 100644 index bb73690382..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/idispatch_windows.go +++ /dev/null @@ -1,193 +0,0 @@ -// +build windows - -package ole - -import ( - "syscall" - "time" - "unsafe" -) - -func getIDsOfName(disp *IDispatch, names []string) (dispid []int32, err error) { - wnames := make([]*uint16, len(names)) - for i := 0; i < len(names); i++ { - wnames[i] = syscall.StringToUTF16Ptr(names[i]) - } - dispid = make([]int32, len(names)) - namelen := uint32(len(names)) - hr, _, _ := syscall.Syscall6( - disp.VTable().GetIDsOfNames, - 6, - uintptr(unsafe.Pointer(disp)), - uintptr(unsafe.Pointer(IID_NULL)), - uintptr(unsafe.Pointer(&wnames[0])), - uintptr(namelen), - uintptr(GetUserDefaultLCID()), - uintptr(unsafe.Pointer(&dispid[0]))) - if hr != 0 { - err = NewError(hr) - } - return -} - -func getTypeInfoCount(disp *IDispatch) (c uint32, err error) { - hr, _, _ := syscall.Syscall( - disp.VTable().GetTypeInfoCount, - 2, - uintptr(unsafe.Pointer(disp)), - uintptr(unsafe.Pointer(&c)), - 0) - if hr != 0 { - err = NewError(hr) - } - return -} - -func getTypeInfo(disp *IDispatch) (tinfo *ITypeInfo, err error) { - hr, _, _ := syscall.Syscall( - disp.VTable().GetTypeInfo, - 3, - uintptr(unsafe.Pointer(disp)), - uintptr(GetUserDefaultLCID()), - uintptr(unsafe.Pointer(&tinfo))) - if hr != 0 { - err = NewError(hr) - } - return -} - -func invoke(disp *IDispatch, dispid int32, dispatch int16, params ...interface{}) (result *VARIANT, err error) { - var dispparams DISPPARAMS - - if dispatch&DISPATCH_PROPERTYPUT != 0 { - dispnames := [1]int32{DISPID_PROPERTYPUT} - dispparams.rgdispidNamedArgs = uintptr(unsafe.Pointer(&dispnames[0])) - dispparams.cNamedArgs = 1 - } - var vargs []VARIANT - if len(params) > 0 { - vargs = make([]VARIANT, len(params)) - for i, v := range params { - //n := len(params)-i-1 - n := len(params) - i - 1 - VariantInit(&vargs[n]) - switch vv := v.(type) { - case bool: - if vv { - vargs[n] = NewVariant(VT_BOOL, 0xffff) - } else { - vargs[n] = NewVariant(VT_BOOL, 0) - } - case *bool: - vargs[n] = NewVariant(VT_BOOL|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*bool))))) - case uint8: - vargs[n] = NewVariant(VT_I1, int64(v.(uint8))) - case *uint8: - vargs[n] = NewVariant(VT_I1|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*uint8))))) - case int8: - vargs[n] = NewVariant(VT_I1, int64(v.(int8))) - case *int8: - vargs[n] = NewVariant(VT_I1|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*uint8))))) - case int16: - vargs[n] = NewVariant(VT_I2, int64(v.(int16))) - case *int16: - vargs[n] = NewVariant(VT_I2|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*int16))))) - case uint16: - vargs[n] = NewVariant(VT_UI2, int64(v.(uint16))) - case *uint16: - vargs[n] = NewVariant(VT_UI2|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*uint16))))) - case int32: - vargs[n] = NewVariant(VT_I4, int64(v.(int32))) - case *int32: - vargs[n] = NewVariant(VT_I4|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*int32))))) - case uint32: - vargs[n] = NewVariant(VT_UI4, int64(v.(uint32))) - case *uint32: - vargs[n] = NewVariant(VT_UI4|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*uint32))))) - case int64: - vargs[n] = NewVariant(VT_I8, int64(v.(int64))) - case *int64: - vargs[n] = NewVariant(VT_I8|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*int64))))) - case uint64: - vargs[n] = NewVariant(VT_UI8, int64(uintptr(v.(uint64)))) - case *uint64: - vargs[n] = NewVariant(VT_UI8|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*uint64))))) - case int: - vargs[n] = NewVariant(VT_I4, int64(v.(int))) - case *int: - vargs[n] = NewVariant(VT_I4|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*int))))) - case uint: - vargs[n] = NewVariant(VT_UI4, int64(v.(uint))) - case *uint: - vargs[n] = NewVariant(VT_UI4|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*uint))))) - case float32: - vargs[n] = NewVariant(VT_R4, *(*int64)(unsafe.Pointer(&vv))) - case *float32: - vargs[n] = NewVariant(VT_R4|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*float32))))) - case float64: - vargs[n] = NewVariant(VT_R8, *(*int64)(unsafe.Pointer(&vv))) - case *float64: - vargs[n] = NewVariant(VT_R8|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*float64))))) - case string: - vargs[n] = NewVariant(VT_BSTR, int64(uintptr(unsafe.Pointer(SysAllocStringLen(v.(string)))))) - case *string: - vargs[n] = NewVariant(VT_BSTR|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*string))))) - case time.Time: - s := vv.Format("2006-01-02 15:04:05") - vargs[n] = NewVariant(VT_BSTR, int64(uintptr(unsafe.Pointer(SysAllocStringLen(s))))) - case *time.Time: - s := vv.Format("2006-01-02 15:04:05") - vargs[n] = NewVariant(VT_BSTR|VT_BYREF, int64(uintptr(unsafe.Pointer(&s)))) - case *IDispatch: - vargs[n] = NewVariant(VT_DISPATCH, int64(uintptr(unsafe.Pointer(v.(*IDispatch))))) - case **IDispatch: - vargs[n] = NewVariant(VT_DISPATCH|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(**IDispatch))))) - case nil: - vargs[n] = NewVariant(VT_NULL, 0) - case *VARIANT: - vargs[n] = NewVariant(VT_VARIANT|VT_BYREF, int64(uintptr(unsafe.Pointer(v.(*VARIANT))))) - case []byte: - safeByteArray := safeArrayFromByteSlice(v.([]byte)) - vargs[n] = NewVariant(VT_ARRAY|VT_UI1, int64(uintptr(unsafe.Pointer(safeByteArray)))) - defer VariantClear(&vargs[n]) - case []string: - safeByteArray := safeArrayFromStringSlice(v.([]string)) - vargs[n] = NewVariant(VT_ARRAY|VT_BSTR, int64(uintptr(unsafe.Pointer(safeByteArray)))) - defer VariantClear(&vargs[n]) - default: - panic("unknown type") - } - } - dispparams.rgvarg = uintptr(unsafe.Pointer(&vargs[0])) - dispparams.cArgs = uint32(len(params)) - } - - result = new(VARIANT) - var excepInfo EXCEPINFO - VariantInit(result) - hr, _, _ := syscall.Syscall9( - disp.VTable().Invoke, - 9, - uintptr(unsafe.Pointer(disp)), - uintptr(dispid), - uintptr(unsafe.Pointer(IID_NULL)), - uintptr(GetUserDefaultLCID()), - uintptr(dispatch), - uintptr(unsafe.Pointer(&dispparams)), - uintptr(unsafe.Pointer(result)), - uintptr(unsafe.Pointer(&excepInfo)), - 0) - if hr != 0 { - err = NewErrorWithSubError(hr, BstrToString(excepInfo.bstrDescription), excepInfo) - } - for i, varg := range vargs { - n := len(params) - i - 1 - if varg.VT == VT_BSTR && varg.Val != 0 { - SysFreeString(((*int16)(unsafe.Pointer(uintptr(varg.Val))))) - } - if varg.VT == (VT_BSTR|VT_BYREF) && varg.Val != 0 { - *(params[n].(*string)) = LpOleStrToString(*(**uint16)(unsafe.Pointer(uintptr(varg.Val)))) - } - } - return -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/ienumvariant.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/ienumvariant.go deleted file mode 100644 index 2433897544..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/ienumvariant.go +++ /dev/null @@ -1,19 +0,0 @@ -package ole - -import "unsafe" - -type IEnumVARIANT struct { - IUnknown -} - -type IEnumVARIANTVtbl struct { - IUnknownVtbl - Next uintptr - Skip uintptr - Reset uintptr - Clone uintptr -} - -func (v *IEnumVARIANT) VTable() *IEnumVARIANTVtbl { - return (*IEnumVARIANTVtbl)(unsafe.Pointer(v.RawVTable)) -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/ienumvariant_func.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/ienumvariant_func.go deleted file mode 100644 index c14848199c..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/ienumvariant_func.go +++ /dev/null @@ -1,19 +0,0 @@ -// +build !windows - -package ole - -func (enum *IEnumVARIANT) Clone() (*IEnumVARIANT, error) { - return nil, NewError(E_NOTIMPL) -} - -func (enum *IEnumVARIANT) Reset() error { - return NewError(E_NOTIMPL) -} - -func (enum *IEnumVARIANT) Skip(celt uint) error { - return NewError(E_NOTIMPL) -} - -func (enum *IEnumVARIANT) Next(celt uint) (VARIANT, uint, error) { - return NewVariant(VT_NULL, int64(0)), 0, NewError(E_NOTIMPL) -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/ienumvariant_windows.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/ienumvariant_windows.go deleted file mode 100644 index 4781f3b8b0..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/ienumvariant_windows.go +++ /dev/null @@ -1,63 +0,0 @@ -// +build windows - -package ole - -import ( - "syscall" - "unsafe" -) - -func (enum *IEnumVARIANT) Clone() (cloned *IEnumVARIANT, err error) { - hr, _, _ := syscall.Syscall( - enum.VTable().Clone, - 2, - uintptr(unsafe.Pointer(enum)), - uintptr(unsafe.Pointer(&cloned)), - 0) - if hr != 0 { - err = NewError(hr) - } - return -} - -func (enum *IEnumVARIANT) Reset() (err error) { - hr, _, _ := syscall.Syscall( - enum.VTable().Reset, - 1, - uintptr(unsafe.Pointer(enum)), - 0, - 0) - if hr != 0 { - err = NewError(hr) - } - return -} - -func (enum *IEnumVARIANT) Skip(celt uint) (err error) { - hr, _, _ := syscall.Syscall( - enum.VTable().Skip, - 2, - uintptr(unsafe.Pointer(enum)), - uintptr(celt), - 0) - if hr != 0 { - err = NewError(hr) - } - return -} - -func (enum *IEnumVARIANT) Next(celt uint) (array VARIANT, length uint, err error) { - hr, _, _ := syscall.Syscall6( - enum.VTable().Next, - 4, - uintptr(unsafe.Pointer(enum)), - uintptr(celt), - uintptr(unsafe.Pointer(&array)), - uintptr(unsafe.Pointer(&length)), - 0, - 0) - if hr != 0 { - err = NewError(hr) - } - return -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iinspectable.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iinspectable.go deleted file mode 100644 index f4a19e253a..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/iinspectable.go +++ /dev/null @@ -1,18 +0,0 @@ -package ole - -import "unsafe" - -type IInspectable struct { - IUnknown -} - -type IInspectableVtbl struct { - IUnknownVtbl - GetIIds uintptr - GetRuntimeClassName uintptr - GetTrustLevel uintptr -} - -func (v *IInspectable) VTable() *IInspectableVtbl { - return (*IInspectableVtbl)(unsafe.Pointer(v.RawVTable)) -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iinspectable_func.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iinspectable_func.go deleted file mode 100644 index 348829bf06..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/iinspectable_func.go +++ /dev/null @@ -1,15 +0,0 @@ -// +build !windows - -package ole - -func (v *IInspectable) GetIids() ([]*GUID, error) { - return []*GUID{}, NewError(E_NOTIMPL) -} - -func (v *IInspectable) GetRuntimeClassName() (string, error) { - return "", NewError(E_NOTIMPL) -} - -func (v *IInspectable) GetTrustLevel() (uint32, error) { - return uint32(0), NewError(E_NOTIMPL) -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iinspectable_windows.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iinspectable_windows.go deleted file mode 100644 index 4519a4aa44..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/iinspectable_windows.go +++ /dev/null @@ -1,72 +0,0 @@ -// +build windows - -package ole - -import ( - "bytes" - "encoding/binary" - "reflect" - "syscall" - "unsafe" -) - -func (v *IInspectable) GetIids() (iids []*GUID, err error) { - var count uint32 - var array uintptr - hr, _, _ := syscall.Syscall( - v.VTable().GetIIds, - 3, - uintptr(unsafe.Pointer(v)), - uintptr(unsafe.Pointer(&count)), - uintptr(unsafe.Pointer(&array))) - if hr != 0 { - err = NewError(hr) - return - } - defer CoTaskMemFree(array) - - iids = make([]*GUID, count) - byteCount := count * uint32(unsafe.Sizeof(GUID{})) - slicehdr := reflect.SliceHeader{Data: array, Len: int(byteCount), Cap: int(byteCount)} - byteSlice := *(*[]byte)(unsafe.Pointer(&slicehdr)) - reader := bytes.NewReader(byteSlice) - for i := range iids { - guid := GUID{} - err = binary.Read(reader, binary.LittleEndian, &guid) - if err != nil { - return - } - iids[i] = &guid - } - return -} - -func (v *IInspectable) GetRuntimeClassName() (s string, err error) { - var hstring HString - hr, _, _ := syscall.Syscall( - v.VTable().GetRuntimeClassName, - 2, - uintptr(unsafe.Pointer(v)), - uintptr(unsafe.Pointer(&hstring)), - 0) - if hr != 0 { - err = NewError(hr) - return - } - s = hstring.String() - DeleteHString(hstring) - return -} - -func (v *IInspectable) GetTrustLevel() (level uint32, err error) { - hr, _, _ := syscall.Syscall( - v.VTable().GetTrustLevel, - 2, - uintptr(unsafe.Pointer(v)), - uintptr(unsafe.Pointer(&level)), - 0) - if hr != 0 { - err = NewError(hr) - } - return -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iprovideclassinfo.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iprovideclassinfo.go deleted file mode 100644 index 25f3a6f24a..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/iprovideclassinfo.go +++ /dev/null @@ -1,21 +0,0 @@ -package ole - -import "unsafe" - -type IProvideClassInfo struct { - IUnknown -} - -type IProvideClassInfoVtbl struct { - IUnknownVtbl - GetClassInfo uintptr -} - -func (v *IProvideClassInfo) VTable() *IProvideClassInfoVtbl { - return (*IProvideClassInfoVtbl)(unsafe.Pointer(v.RawVTable)) -} - -func (v *IProvideClassInfo) GetClassInfo() (cinfo *ITypeInfo, err error) { - cinfo, err = getClassInfo(v) - return -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iprovideclassinfo_func.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iprovideclassinfo_func.go deleted file mode 100644 index 7e3cb63ea7..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/iprovideclassinfo_func.go +++ /dev/null @@ -1,7 +0,0 @@ -// +build !windows - -package ole - -func getClassInfo(disp *IProvideClassInfo) (tinfo *ITypeInfo, err error) { - return nil, NewError(E_NOTIMPL) -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iprovideclassinfo_windows.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iprovideclassinfo_windows.go deleted file mode 100644 index 2ad0163949..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/iprovideclassinfo_windows.go +++ /dev/null @@ -1,21 +0,0 @@ -// +build windows - -package ole - -import ( - "syscall" - "unsafe" -) - -func getClassInfo(disp *IProvideClassInfo) (tinfo *ITypeInfo, err error) { - hr, _, _ := syscall.Syscall( - disp.VTable().GetClassInfo, - 2, - uintptr(unsafe.Pointer(disp)), - uintptr(unsafe.Pointer(&tinfo)), - 0) - if hr != 0 { - err = NewError(hr) - } - return -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/itypeinfo.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/itypeinfo.go deleted file mode 100644 index dd3c5e21bb..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/itypeinfo.go +++ /dev/null @@ -1,34 +0,0 @@ -package ole - -import "unsafe" - -type ITypeInfo struct { - IUnknown -} - -type ITypeInfoVtbl struct { - IUnknownVtbl - GetTypeAttr uintptr - GetTypeComp uintptr - GetFuncDesc uintptr - GetVarDesc uintptr - GetNames uintptr - GetRefTypeOfImplType uintptr - GetImplTypeFlags uintptr - GetIDsOfNames uintptr - Invoke uintptr - GetDocumentation uintptr - GetDllEntry uintptr - GetRefTypeInfo uintptr - AddressOfMember uintptr - CreateInstance uintptr - GetMops uintptr - GetContainingTypeLib uintptr - ReleaseTypeAttr uintptr - ReleaseFuncDesc uintptr - ReleaseVarDesc uintptr -} - -func (v *ITypeInfo) VTable() *ITypeInfoVtbl { - return (*ITypeInfoVtbl)(unsafe.Pointer(v.RawVTable)) -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/itypeinfo_func.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/itypeinfo_func.go deleted file mode 100644 index 8364a659ba..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/itypeinfo_func.go +++ /dev/null @@ -1,7 +0,0 @@ -// +build !windows - -package ole - -func (v *ITypeInfo) GetTypeAttr() (*TYPEATTR, error) { - return nil, NewError(E_NOTIMPL) -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/itypeinfo_windows.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/itypeinfo_windows.go deleted file mode 100644 index 54782b3da5..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/itypeinfo_windows.go +++ /dev/null @@ -1,21 +0,0 @@ -// +build windows - -package ole - -import ( - "syscall" - "unsafe" -) - -func (v *ITypeInfo) GetTypeAttr() (tattr *TYPEATTR, err error) { - hr, _, _ := syscall.Syscall( - uintptr(v.VTable().GetTypeAttr), - 2, - uintptr(unsafe.Pointer(v)), - uintptr(unsafe.Pointer(&tattr)), - 0) - if hr != 0 { - err = NewError(hr) - } - return -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iunknown.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iunknown.go deleted file mode 100644 index 108f28ea61..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/iunknown.go +++ /dev/null @@ -1,57 +0,0 @@ -package ole - -import "unsafe" - -type IUnknown struct { - RawVTable *interface{} -} - -type IUnknownVtbl struct { - QueryInterface uintptr - AddRef uintptr - Release uintptr -} - -type UnknownLike interface { - QueryInterface(iid *GUID) (disp *IDispatch, err error) - AddRef() int32 - Release() int32 -} - -func (v *IUnknown) VTable() *IUnknownVtbl { - return (*IUnknownVtbl)(unsafe.Pointer(v.RawVTable)) -} - -func (v *IUnknown) PutQueryInterface(interfaceID *GUID, obj interface{}) error { - return reflectQueryInterface(v, v.VTable().QueryInterface, interfaceID, obj) -} - -func (v *IUnknown) IDispatch(interfaceID *GUID) (dispatch *IDispatch, err error) { - err = v.PutQueryInterface(interfaceID, &dispatch) - return -} - -func (v *IUnknown) IEnumVARIANT(interfaceID *GUID) (enum *IEnumVARIANT, err error) { - err = v.PutQueryInterface(interfaceID, &enum) - return -} - -func (v *IUnknown) QueryInterface(iid *GUID) (*IDispatch, error) { - return queryInterface(v, iid) -} - -func (v *IUnknown) MustQueryInterface(iid *GUID) (disp *IDispatch) { - unk, err := queryInterface(v, iid) - if err != nil { - panic(err) - } - return unk -} - -func (v *IUnknown) AddRef() int32 { - return addRef(v) -} - -func (v *IUnknown) Release() int32 { - return release(v) -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iunknown_func.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iunknown_func.go deleted file mode 100644 index d0a62cfd73..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/iunknown_func.go +++ /dev/null @@ -1,19 +0,0 @@ -// +build !windows - -package ole - -func reflectQueryInterface(self interface{}, method uintptr, interfaceID *GUID, obj interface{}) (err error) { - return NewError(E_NOTIMPL) -} - -func queryInterface(unk *IUnknown, iid *GUID) (disp *IDispatch, err error) { - return nil, NewError(E_NOTIMPL) -} - -func addRef(unk *IUnknown) int32 { - return 0 -} - -func release(unk *IUnknown) int32 { - return 0 -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/iunknown_windows.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/iunknown_windows.go deleted file mode 100644 index ede5bb8c17..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/iunknown_windows.go +++ /dev/null @@ -1,58 +0,0 @@ -// +build windows - -package ole - -import ( - "reflect" - "syscall" - "unsafe" -) - -func reflectQueryInterface(self interface{}, method uintptr, interfaceID *GUID, obj interface{}) (err error) { - selfValue := reflect.ValueOf(self).Elem() - objValue := reflect.ValueOf(obj).Elem() - - hr, _, _ := syscall.Syscall( - method, - 3, - selfValue.UnsafeAddr(), - uintptr(unsafe.Pointer(interfaceID)), - objValue.Addr().Pointer()) - if hr != 0 { - err = NewError(hr) - } - return -} - -func queryInterface(unk *IUnknown, iid *GUID) (disp *IDispatch, err error) { - hr, _, _ := syscall.Syscall( - unk.VTable().QueryInterface, - 3, - uintptr(unsafe.Pointer(unk)), - uintptr(unsafe.Pointer(iid)), - uintptr(unsafe.Pointer(&disp))) - if hr != 0 { - err = NewError(hr) - } - return -} - -func addRef(unk *IUnknown) int32 { - ret, _, _ := syscall.Syscall( - unk.VTable().AddRef, - 1, - uintptr(unsafe.Pointer(unk)), - 0, - 0) - return int32(ret) -} - -func release(unk *IUnknown) int32 { - ret, _, _ := syscall.Syscall( - unk.VTable().Release, - 1, - uintptr(unsafe.Pointer(unk)), - 0, - 0) - return int32(ret) -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/ole.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/ole.go deleted file mode 100644 index b92b4ea189..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/ole.go +++ /dev/null @@ -1,147 +0,0 @@ -package ole - -import ( - "fmt" - "strings" -) - -// DISPPARAMS are the arguments that passed to methods or property. -type DISPPARAMS struct { - rgvarg uintptr - rgdispidNamedArgs uintptr - cArgs uint32 - cNamedArgs uint32 -} - -// EXCEPINFO defines exception info. -type EXCEPINFO struct { - wCode uint16 - wReserved uint16 - bstrSource *uint16 - bstrDescription *uint16 - bstrHelpFile *uint16 - dwHelpContext uint32 - pvReserved uintptr - pfnDeferredFillIn uintptr - scode uint32 -} - -// String convert EXCEPINFO to string. -func (e EXCEPINFO) String() string { - var src, desc, hlp string - if e.bstrSource == nil { - src = "" - } else { - src = BstrToString(e.bstrSource) - } - - if e.bstrDescription == nil { - desc = "" - } else { - desc = BstrToString(e.bstrDescription) - } - - if e.bstrHelpFile == nil { - hlp = "" - } else { - hlp = BstrToString(e.bstrHelpFile) - } - - return fmt.Sprintf( - "wCode: %#x, bstrSource: %v, bstrDescription: %v, bstrHelpFile: %v, dwHelpContext: %#x, scode: %#x", - e.wCode, src, desc, hlp, e.dwHelpContext, e.scode, - ) -} - -// Error implements error interface and returns error string. -func (e EXCEPINFO) Error() string { - if e.bstrDescription != nil { - return strings.TrimSpace(BstrToString(e.bstrDescription)) - } - - src := "Unknown" - if e.bstrSource != nil { - src = BstrToString(e.bstrSource) - } - - code := e.scode - if e.wCode != 0 { - code = uint32(e.wCode) - } - - return fmt.Sprintf("%v: %#x", src, code) -} - -// PARAMDATA defines parameter data type. -type PARAMDATA struct { - Name *int16 - Vt uint16 -} - -// METHODDATA defines method info. -type METHODDATA struct { - Name *uint16 - Data *PARAMDATA - Dispid int32 - Meth uint32 - CC int32 - CArgs uint32 - Flags uint16 - VtReturn uint32 -} - -// INTERFACEDATA defines interface info. -type INTERFACEDATA struct { - MethodData *METHODDATA - CMembers uint32 -} - -// Point is 2D vector type. -type Point struct { - X int32 - Y int32 -} - -// Msg is message between processes. -type Msg struct { - Hwnd uint32 - Message uint32 - Wparam int32 - Lparam int32 - Time uint32 - Pt Point -} - -// TYPEDESC defines data type. -type TYPEDESC struct { - Hreftype uint32 - VT uint16 -} - -// IDLDESC defines IDL info. -type IDLDESC struct { - DwReserved uint32 - WIDLFlags uint16 -} - -// TYPEATTR defines type info. -type TYPEATTR struct { - Guid GUID - Lcid uint32 - dwReserved uint32 - MemidConstructor int32 - MemidDestructor int32 - LpstrSchema *uint16 - CbSizeInstance uint32 - Typekind int32 - CFuncs uint16 - CVars uint16 - CImplTypes uint16 - CbSizeVft uint16 - CbAlignment uint16 - WTypeFlags uint16 - WMajorVerNum uint16 - WMinorVerNum uint16 - TdescAlias TYPEDESC - IdldescType IDLDESC -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/connection.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/connection.go deleted file mode 100644 index 60df73cda0..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/connection.go +++ /dev/null @@ -1,100 +0,0 @@ -// +build windows - -package oleutil - -import ( - "reflect" - "unsafe" - - ole "github.com/go-ole/go-ole" -) - -type stdDispatch struct { - lpVtbl *stdDispatchVtbl - ref int32 - iid *ole.GUID - iface interface{} - funcMap map[string]int32 -} - -type stdDispatchVtbl struct { - pQueryInterface uintptr - pAddRef uintptr - pRelease uintptr - pGetTypeInfoCount uintptr - pGetTypeInfo uintptr - pGetIDsOfNames uintptr - pInvoke uintptr -} - -func dispQueryInterface(this *ole.IUnknown, iid *ole.GUID, punk **ole.IUnknown) uint32 { - pthis := (*stdDispatch)(unsafe.Pointer(this)) - *punk = nil - if ole.IsEqualGUID(iid, ole.IID_IUnknown) || - ole.IsEqualGUID(iid, ole.IID_IDispatch) { - dispAddRef(this) - *punk = this - return ole.S_OK - } - if ole.IsEqualGUID(iid, pthis.iid) { - dispAddRef(this) - *punk = this - return ole.S_OK - } - return ole.E_NOINTERFACE -} - -func dispAddRef(this *ole.IUnknown) int32 { - pthis := (*stdDispatch)(unsafe.Pointer(this)) - pthis.ref++ - return pthis.ref -} - -func dispRelease(this *ole.IUnknown) int32 { - pthis := (*stdDispatch)(unsafe.Pointer(this)) - pthis.ref-- - return pthis.ref -} - -func dispGetIDsOfNames(this *ole.IUnknown, iid *ole.GUID, wnames []*uint16, namelen int, lcid int, pdisp []int32) uintptr { - pthis := (*stdDispatch)(unsafe.Pointer(this)) - names := make([]string, len(wnames)) - for i := 0; i < len(names); i++ { - names[i] = ole.LpOleStrToString(wnames[i]) - } - for n := 0; n < namelen; n++ { - if id, ok := pthis.funcMap[names[n]]; ok { - pdisp[n] = id - } - } - return ole.S_OK -} - -func dispGetTypeInfoCount(pcount *int) uintptr { - if pcount != nil { - *pcount = 0 - } - return ole.S_OK -} - -func dispGetTypeInfo(ptypeif *uintptr) uintptr { - return ole.E_NOTIMPL -} - -func dispInvoke(this *ole.IDispatch, dispid int32, riid *ole.GUID, lcid int, flags int16, dispparams *ole.DISPPARAMS, result *ole.VARIANT, pexcepinfo *ole.EXCEPINFO, nerr *uint) uintptr { - pthis := (*stdDispatch)(unsafe.Pointer(this)) - found := "" - for name, id := range pthis.funcMap { - if id == dispid { - found = name - } - } - if found != "" { - rv := reflect.ValueOf(pthis.iface).Elem() - rm := rv.MethodByName(found) - rr := rm.Call([]reflect.Value{}) - println(len(rr)) - return ole.S_OK - } - return ole.E_NOTIMPL -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/connection_func.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/connection_func.go deleted file mode 100644 index 8818fb8275..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/connection_func.go +++ /dev/null @@ -1,10 +0,0 @@ -// +build !windows - -package oleutil - -import ole "github.com/go-ole/go-ole" - -// ConnectObject creates a connection point between two services for communication. -func ConnectObject(disp *ole.IDispatch, iid *ole.GUID, idisp interface{}) (uint32, error) { - return 0, ole.NewError(ole.E_NOTIMPL) -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/connection_windows.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/connection_windows.go deleted file mode 100644 index 6b5c059993..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/connection_windows.go +++ /dev/null @@ -1,57 +0,0 @@ -// +build windows - -package oleutil - -import ( - "reflect" - "syscall" - "unsafe" - - ole "github.com/go-ole/go-ole" -) - -// ConnectObject creates a connection point between two services for communication. -func ConnectObject(disp *ole.IDispatch, iid *ole.GUID, idisp interface{}) (cookie uint32, err error) { - unknown, err := disp.QueryInterface(ole.IID_IConnectionPointContainer) - if err != nil { - return - } - - container := (*ole.IConnectionPointContainer)(unsafe.Pointer(unknown)) - var point *ole.IConnectionPoint - err = container.FindConnectionPoint(iid, &point) - if err != nil { - return - } - if edisp, ok := idisp.(*ole.IUnknown); ok { - cookie, err = point.Advise(edisp) - container.Release() - if err != nil { - return - } - } - rv := reflect.ValueOf(disp).Elem() - if rv.Type().Kind() == reflect.Struct { - dest := &stdDispatch{} - dest.lpVtbl = &stdDispatchVtbl{} - dest.lpVtbl.pQueryInterface = syscall.NewCallback(dispQueryInterface) - dest.lpVtbl.pAddRef = syscall.NewCallback(dispAddRef) - dest.lpVtbl.pRelease = syscall.NewCallback(dispRelease) - dest.lpVtbl.pGetTypeInfoCount = syscall.NewCallback(dispGetTypeInfoCount) - dest.lpVtbl.pGetTypeInfo = syscall.NewCallback(dispGetTypeInfo) - dest.lpVtbl.pGetIDsOfNames = syscall.NewCallback(dispGetIDsOfNames) - dest.lpVtbl.pInvoke = syscall.NewCallback(dispInvoke) - dest.iface = disp - dest.iid = iid - cookie, err = point.Advise((*ole.IUnknown)(unsafe.Pointer(dest))) - container.Release() - if err != nil { - point.Release() - return - } - } - - container.Release() - - return 0, ole.NewError(ole.E_INVALIDARG) -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/go-get.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/go-get.go deleted file mode 100644 index 58347628f2..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/go-get.go +++ /dev/null @@ -1,6 +0,0 @@ -// This file is here so go get succeeds as without it errors with: -// no buildable Go source files in ... -// -// +build !windows - -package oleutil diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/oleutil.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/oleutil.go deleted file mode 100644 index 55e072a636..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/oleutil/oleutil.go +++ /dev/null @@ -1,89 +0,0 @@ -package oleutil - -import ole "github.com/go-ole/go-ole" - -// ClassIDFrom retrieves class ID whether given is program ID or application string. -func ClassIDFrom(programID string) (classID *ole.GUID, err error) { - return ole.ClassIDFrom(programID) -} - -// CreateObject creates object from programID based on interface type. -// -// Only supports IUnknown. -// -// Program ID can be either program ID or application string. -func CreateObject(programID string) (unknown *ole.IUnknown, err error) { - classID, err := ole.ClassIDFrom(programID) - if err != nil { - return - } - - unknown, err = ole.CreateInstance(classID, ole.IID_IUnknown) - if err != nil { - return - } - - return -} - -// GetActiveObject retrieves active object for program ID and interface ID based -// on interface type. -// -// Only supports IUnknown. -// -// Program ID can be either program ID or application string. -func GetActiveObject(programID string) (unknown *ole.IUnknown, err error) { - classID, err := ole.ClassIDFrom(programID) - if err != nil { - return - } - - unknown, err = ole.GetActiveObject(classID, ole.IID_IUnknown) - if err != nil { - return - } - - return -} - -// CallMethod calls method on IDispatch with parameters. -func CallMethod(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT, err error) { - return disp.InvokeWithOptionalArgs(name, ole.DISPATCH_METHOD, params) -} - -// MustCallMethod calls method on IDispatch with parameters or panics. -func MustCallMethod(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT) { - r, err := CallMethod(disp, name, params...) - if err != nil { - panic(err.Error()) - } - return r -} - -// GetProperty retrieves property from IDispatch. -func GetProperty(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT, err error) { - return disp.InvokeWithOptionalArgs(name, ole.DISPATCH_PROPERTYGET, params) -} - -// MustGetProperty retrieves property from IDispatch or panics. -func MustGetProperty(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT) { - r, err := GetProperty(disp, name, params...) - if err != nil { - panic(err.Error()) - } - return r -} - -// PutProperty mutates property. -func PutProperty(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT, err error) { - return disp.InvokeWithOptionalArgs(name, ole.DISPATCH_PROPERTYPUT, params) -} - -// MustPutProperty mutates property or panics. -func MustPutProperty(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT) { - r, err := PutProperty(disp, name, params...) - if err != nil { - panic(err.Error()) - } - return r -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/safearray.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/safearray.go deleted file mode 100644 index a5201b56c3..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/safearray.go +++ /dev/null @@ -1,27 +0,0 @@ -// Package is meant to retrieve and process safe array data returned from COM. - -package ole - -// SafeArrayBound defines the SafeArray boundaries. -type SafeArrayBound struct { - Elements uint32 - LowerBound int32 -} - -// SafeArray is how COM handles arrays. -type SafeArray struct { - Dimensions uint16 - FeaturesFlag uint16 - ElementsSize uint32 - LocksAmount uint32 - Data uint32 - Bounds [16]byte -} - -// SAFEARRAY is obsolete, exists for backwards compatibility. -// Use SafeArray -type SAFEARRAY SafeArray - -// SAFEARRAYBOUND is obsolete, exists for backwards compatibility. -// Use SafeArrayBound -type SAFEARRAYBOUND SafeArrayBound diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/safearray_func.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/safearray_func.go deleted file mode 100644 index 8ff0baa41d..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/safearray_func.go +++ /dev/null @@ -1,211 +0,0 @@ -// +build !windows - -package ole - -import ( - "unsafe" -) - -// safeArrayAccessData returns raw array pointer. -// -// AKA: SafeArrayAccessData in Windows API. -func safeArrayAccessData(safearray *SafeArray) (uintptr, error) { - return uintptr(0), NewError(E_NOTIMPL) -} - -// safeArrayUnaccessData releases raw array. -// -// AKA: SafeArrayUnaccessData in Windows API. -func safeArrayUnaccessData(safearray *SafeArray) error { - return NewError(E_NOTIMPL) -} - -// safeArrayAllocData allocates SafeArray. -// -// AKA: SafeArrayAllocData in Windows API. -func safeArrayAllocData(safearray *SafeArray) error { - return NewError(E_NOTIMPL) -} - -// safeArrayAllocDescriptor allocates SafeArray. -// -// AKA: SafeArrayAllocDescriptor in Windows API. -func safeArrayAllocDescriptor(dimensions uint32) (*SafeArray, error) { - return nil, NewError(E_NOTIMPL) -} - -// safeArrayAllocDescriptorEx allocates SafeArray. -// -// AKA: SafeArrayAllocDescriptorEx in Windows API. -func safeArrayAllocDescriptorEx(variantType VT, dimensions uint32) (*SafeArray, error) { - return nil, NewError(E_NOTIMPL) -} - -// safeArrayCopy returns copy of SafeArray. -// -// AKA: SafeArrayCopy in Windows API. -func safeArrayCopy(original *SafeArray) (*SafeArray, error) { - return nil, NewError(E_NOTIMPL) -} - -// safeArrayCopyData duplicates SafeArray into another SafeArray object. -// -// AKA: SafeArrayCopyData in Windows API. -func safeArrayCopyData(original *SafeArray, duplicate *SafeArray) error { - return NewError(E_NOTIMPL) -} - -// safeArrayCreate creates SafeArray. -// -// AKA: SafeArrayCreate in Windows API. -func safeArrayCreate(variantType VT, dimensions uint32, bounds *SafeArrayBound) (*SafeArray, error) { - return nil, NewError(E_NOTIMPL) -} - -// safeArrayCreateEx creates SafeArray. -// -// AKA: SafeArrayCreateEx in Windows API. -func safeArrayCreateEx(variantType VT, dimensions uint32, bounds *SafeArrayBound, extra uintptr) (*SafeArray, error) { - return nil, NewError(E_NOTIMPL) -} - -// safeArrayCreateVector creates SafeArray. -// -// AKA: SafeArrayCreateVector in Windows API. -func safeArrayCreateVector(variantType VT, lowerBound int32, length uint32) (*SafeArray, error) { - return nil, NewError(E_NOTIMPL) -} - -// safeArrayCreateVectorEx creates SafeArray. -// -// AKA: SafeArrayCreateVectorEx in Windows API. -func safeArrayCreateVectorEx(variantType VT, lowerBound int32, length uint32, extra uintptr) (*SafeArray, error) { - return nil, NewError(E_NOTIMPL) -} - -// safeArrayDestroy destroys SafeArray object. -// -// AKA: SafeArrayDestroy in Windows API. -func safeArrayDestroy(safearray *SafeArray) error { - return NewError(E_NOTIMPL) -} - -// safeArrayDestroyData destroys SafeArray object. -// -// AKA: SafeArrayDestroyData in Windows API. -func safeArrayDestroyData(safearray *SafeArray) error { - return NewError(E_NOTIMPL) -} - -// safeArrayDestroyDescriptor destroys SafeArray object. -// -// AKA: SafeArrayDestroyDescriptor in Windows API. -func safeArrayDestroyDescriptor(safearray *SafeArray) error { - return NewError(E_NOTIMPL) -} - -// safeArrayGetDim is the amount of dimensions in the SafeArray. -// -// SafeArrays may have multiple dimensions. Meaning, it could be -// multidimensional array. -// -// AKA: SafeArrayGetDim in Windows API. -func safeArrayGetDim(safearray *SafeArray) (*uint32, error) { - u := uint32(0) - return &u, NewError(E_NOTIMPL) -} - -// safeArrayGetElementSize is the element size in bytes. -// -// AKA: SafeArrayGetElemsize in Windows API. -func safeArrayGetElementSize(safearray *SafeArray) (*uint32, error) { - u := uint32(0) - return &u, NewError(E_NOTIMPL) -} - -// safeArrayGetElement retrieves element at given index. -func safeArrayGetElement(safearray *SafeArray, index int64, pv unsafe.Pointer) error { - return NewError(E_NOTIMPL) -} - -// safeArrayGetElement retrieves element at given index and converts to string. -func safeArrayGetElementString(safearray *SafeArray, index int64) (string, error) { - return "", NewError(E_NOTIMPL) -} - -// safeArrayGetIID is the InterfaceID of the elements in the SafeArray. -// -// AKA: SafeArrayGetIID in Windows API. -func safeArrayGetIID(safearray *SafeArray) (*GUID, error) { - return nil, NewError(E_NOTIMPL) -} - -// safeArrayGetLBound returns lower bounds of SafeArray. -// -// SafeArrays may have multiple dimensions. Meaning, it could be -// multidimensional array. -// -// AKA: SafeArrayGetLBound in Windows API. -func safeArrayGetLBound(safearray *SafeArray, dimension uint32) (int64, error) { - return int64(0), NewError(E_NOTIMPL) -} - -// safeArrayGetUBound returns upper bounds of SafeArray. -// -// SafeArrays may have multiple dimensions. Meaning, it could be -// multidimensional array. -// -// AKA: SafeArrayGetUBound in Windows API. -func safeArrayGetUBound(safearray *SafeArray, dimension uint32) (int64, error) { - return int64(0), NewError(E_NOTIMPL) -} - -// safeArrayGetVartype returns data type of SafeArray. -// -// AKA: SafeArrayGetVartype in Windows API. -func safeArrayGetVartype(safearray *SafeArray) (uint16, error) { - return uint16(0), NewError(E_NOTIMPL) -} - -// safeArrayLock locks SafeArray for reading to modify SafeArray. -// -// This must be called during some calls to ensure that another process does not -// read or write to the SafeArray during editing. -// -// AKA: SafeArrayLock in Windows API. -func safeArrayLock(safearray *SafeArray) error { - return NewError(E_NOTIMPL) -} - -// safeArrayUnlock unlocks SafeArray for reading. -// -// AKA: SafeArrayUnlock in Windows API. -func safeArrayUnlock(safearray *SafeArray) error { - return NewError(E_NOTIMPL) -} - -// safeArrayPutElement stores the data element at the specified location in the -// array. -// -// AKA: SafeArrayPutElement in Windows API. -func safeArrayPutElement(safearray *SafeArray, index int64, element uintptr) error { - return NewError(E_NOTIMPL) -} - -// safeArrayGetRecordInfo accesses IRecordInfo info for custom types. -// -// AKA: SafeArrayGetRecordInfo in Windows API. -// -// XXX: Must implement IRecordInfo interface for this to return. -func safeArrayGetRecordInfo(safearray *SafeArray) (interface{}, error) { - return nil, NewError(E_NOTIMPL) -} - -// safeArraySetRecordInfo mutates IRecordInfo info for custom types. -// -// AKA: SafeArraySetRecordInfo in Windows API. -// -// XXX: Must implement IRecordInfo interface for this to return. -func safeArraySetRecordInfo(safearray *SafeArray, recordInfo interface{}) error { - return NewError(E_NOTIMPL) -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/safearray_windows.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/safearray_windows.go deleted file mode 100644 index b27936e24e..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/safearray_windows.go +++ /dev/null @@ -1,337 +0,0 @@ -// +build windows - -package ole - -import ( - "unsafe" -) - -var ( - procSafeArrayAccessData, _ = modoleaut32.FindProc("SafeArrayAccessData") - procSafeArrayAllocData, _ = modoleaut32.FindProc("SafeArrayAllocData") - procSafeArrayAllocDescriptor, _ = modoleaut32.FindProc("SafeArrayAllocDescriptor") - procSafeArrayAllocDescriptorEx, _ = modoleaut32.FindProc("SafeArrayAllocDescriptorEx") - procSafeArrayCopy, _ = modoleaut32.FindProc("SafeArrayCopy") - procSafeArrayCopyData, _ = modoleaut32.FindProc("SafeArrayCopyData") - procSafeArrayCreate, _ = modoleaut32.FindProc("SafeArrayCreate") - procSafeArrayCreateEx, _ = modoleaut32.FindProc("SafeArrayCreateEx") - procSafeArrayCreateVector, _ = modoleaut32.FindProc("SafeArrayCreateVector") - procSafeArrayCreateVectorEx, _ = modoleaut32.FindProc("SafeArrayCreateVectorEx") - procSafeArrayDestroy, _ = modoleaut32.FindProc("SafeArrayDestroy") - procSafeArrayDestroyData, _ = modoleaut32.FindProc("SafeArrayDestroyData") - procSafeArrayDestroyDescriptor, _ = modoleaut32.FindProc("SafeArrayDestroyDescriptor") - procSafeArrayGetDim, _ = modoleaut32.FindProc("SafeArrayGetDim") - procSafeArrayGetElement, _ = modoleaut32.FindProc("SafeArrayGetElement") - procSafeArrayGetElemsize, _ = modoleaut32.FindProc("SafeArrayGetElemsize") - procSafeArrayGetIID, _ = modoleaut32.FindProc("SafeArrayGetIID") - procSafeArrayGetLBound, _ = modoleaut32.FindProc("SafeArrayGetLBound") - procSafeArrayGetUBound, _ = modoleaut32.FindProc("SafeArrayGetUBound") - procSafeArrayGetVartype, _ = modoleaut32.FindProc("SafeArrayGetVartype") - procSafeArrayLock, _ = modoleaut32.FindProc("SafeArrayLock") - procSafeArrayPtrOfIndex, _ = modoleaut32.FindProc("SafeArrayPtrOfIndex") - procSafeArrayUnaccessData, _ = modoleaut32.FindProc("SafeArrayUnaccessData") - procSafeArrayUnlock, _ = modoleaut32.FindProc("SafeArrayUnlock") - procSafeArrayPutElement, _ = modoleaut32.FindProc("SafeArrayPutElement") - //procSafeArrayRedim, _ = modoleaut32.FindProc("SafeArrayRedim") // TODO - //procSafeArraySetIID, _ = modoleaut32.FindProc("SafeArraySetIID") // TODO - procSafeArrayGetRecordInfo, _ = modoleaut32.FindProc("SafeArrayGetRecordInfo") - procSafeArraySetRecordInfo, _ = modoleaut32.FindProc("SafeArraySetRecordInfo") -) - -// safeArrayAccessData returns raw array pointer. -// -// AKA: SafeArrayAccessData in Windows API. -// Todo: Test -func safeArrayAccessData(safearray *SafeArray) (element uintptr, err error) { - err = convertHresultToError( - procSafeArrayAccessData.Call( - uintptr(unsafe.Pointer(safearray)), - uintptr(unsafe.Pointer(&element)))) - return -} - -// safeArrayUnaccessData releases raw array. -// -// AKA: SafeArrayUnaccessData in Windows API. -func safeArrayUnaccessData(safearray *SafeArray) (err error) { - err = convertHresultToError(procSafeArrayUnaccessData.Call(uintptr(unsafe.Pointer(safearray)))) - return -} - -// safeArrayAllocData allocates SafeArray. -// -// AKA: SafeArrayAllocData in Windows API. -func safeArrayAllocData(safearray *SafeArray) (err error) { - err = convertHresultToError(procSafeArrayAllocData.Call(uintptr(unsafe.Pointer(safearray)))) - return -} - -// safeArrayAllocDescriptor allocates SafeArray. -// -// AKA: SafeArrayAllocDescriptor in Windows API. -func safeArrayAllocDescriptor(dimensions uint32) (safearray *SafeArray, err error) { - err = convertHresultToError( - procSafeArrayAllocDescriptor.Call(uintptr(dimensions), uintptr(unsafe.Pointer(&safearray)))) - return -} - -// safeArrayAllocDescriptorEx allocates SafeArray. -// -// AKA: SafeArrayAllocDescriptorEx in Windows API. -func safeArrayAllocDescriptorEx(variantType VT, dimensions uint32) (safearray *SafeArray, err error) { - err = convertHresultToError( - procSafeArrayAllocDescriptorEx.Call( - uintptr(variantType), - uintptr(dimensions), - uintptr(unsafe.Pointer(&safearray)))) - return -} - -// safeArrayCopy returns copy of SafeArray. -// -// AKA: SafeArrayCopy in Windows API. -func safeArrayCopy(original *SafeArray) (safearray *SafeArray, err error) { - err = convertHresultToError( - procSafeArrayCopy.Call( - uintptr(unsafe.Pointer(original)), - uintptr(unsafe.Pointer(&safearray)))) - return -} - -// safeArrayCopyData duplicates SafeArray into another SafeArray object. -// -// AKA: SafeArrayCopyData in Windows API. -func safeArrayCopyData(original *SafeArray, duplicate *SafeArray) (err error) { - err = convertHresultToError( - procSafeArrayCopyData.Call( - uintptr(unsafe.Pointer(original)), - uintptr(unsafe.Pointer(duplicate)))) - return -} - -// safeArrayCreate creates SafeArray. -// -// AKA: SafeArrayCreate in Windows API. -func safeArrayCreate(variantType VT, dimensions uint32, bounds *SafeArrayBound) (safearray *SafeArray, err error) { - sa, _, err := procSafeArrayCreate.Call( - uintptr(variantType), - uintptr(dimensions), - uintptr(unsafe.Pointer(bounds))) - safearray = (*SafeArray)(unsafe.Pointer(&sa)) - return -} - -// safeArrayCreateEx creates SafeArray. -// -// AKA: SafeArrayCreateEx in Windows API. -func safeArrayCreateEx(variantType VT, dimensions uint32, bounds *SafeArrayBound, extra uintptr) (safearray *SafeArray, err error) { - sa, _, err := procSafeArrayCreateEx.Call( - uintptr(variantType), - uintptr(dimensions), - uintptr(unsafe.Pointer(bounds)), - extra) - safearray = (*SafeArray)(unsafe.Pointer(sa)) - return -} - -// safeArrayCreateVector creates SafeArray. -// -// AKA: SafeArrayCreateVector in Windows API. -func safeArrayCreateVector(variantType VT, lowerBound int32, length uint32) (safearray *SafeArray, err error) { - sa, _, err := procSafeArrayCreateVector.Call( - uintptr(variantType), - uintptr(lowerBound), - uintptr(length)) - safearray = (*SafeArray)(unsafe.Pointer(sa)) - return -} - -// safeArrayCreateVectorEx creates SafeArray. -// -// AKA: SafeArrayCreateVectorEx in Windows API. -func safeArrayCreateVectorEx(variantType VT, lowerBound int32, length uint32, extra uintptr) (safearray *SafeArray, err error) { - sa, _, err := procSafeArrayCreateVectorEx.Call( - uintptr(variantType), - uintptr(lowerBound), - uintptr(length), - extra) - safearray = (*SafeArray)(unsafe.Pointer(sa)) - return -} - -// safeArrayDestroy destroys SafeArray object. -// -// AKA: SafeArrayDestroy in Windows API. -func safeArrayDestroy(safearray *SafeArray) (err error) { - err = convertHresultToError(procSafeArrayDestroy.Call(uintptr(unsafe.Pointer(safearray)))) - return -} - -// safeArrayDestroyData destroys SafeArray object. -// -// AKA: SafeArrayDestroyData in Windows API. -func safeArrayDestroyData(safearray *SafeArray) (err error) { - err = convertHresultToError(procSafeArrayDestroyData.Call(uintptr(unsafe.Pointer(safearray)))) - return -} - -// safeArrayDestroyDescriptor destroys SafeArray object. -// -// AKA: SafeArrayDestroyDescriptor in Windows API. -func safeArrayDestroyDescriptor(safearray *SafeArray) (err error) { - err = convertHresultToError(procSafeArrayDestroyDescriptor.Call(uintptr(unsafe.Pointer(safearray)))) - return -} - -// safeArrayGetDim is the amount of dimensions in the SafeArray. -// -// SafeArrays may have multiple dimensions. Meaning, it could be -// multidimensional array. -// -// AKA: SafeArrayGetDim in Windows API. -func safeArrayGetDim(safearray *SafeArray) (dimensions *uint32, err error) { - l, _, err := procSafeArrayGetDim.Call(uintptr(unsafe.Pointer(safearray))) - dimensions = (*uint32)(unsafe.Pointer(l)) - return -} - -// safeArrayGetElementSize is the element size in bytes. -// -// AKA: SafeArrayGetElemsize in Windows API. -func safeArrayGetElementSize(safearray *SafeArray) (length *uint32, err error) { - l, _, err := procSafeArrayGetElemsize.Call(uintptr(unsafe.Pointer(safearray))) - length = (*uint32)(unsafe.Pointer(l)) - return -} - -// safeArrayGetElement retrieves element at given index. -func safeArrayGetElement(safearray *SafeArray, index int64, pv unsafe.Pointer) error { - return convertHresultToError( - procSafeArrayGetElement.Call( - uintptr(unsafe.Pointer(safearray)), - uintptr(unsafe.Pointer(&index)), - uintptr(pv))) -} - -// safeArrayGetElementString retrieves element at given index and converts to string. -func safeArrayGetElementString(safearray *SafeArray, index int64) (str string, err error) { - var element *int16 - err = convertHresultToError( - procSafeArrayGetElement.Call( - uintptr(unsafe.Pointer(safearray)), - uintptr(unsafe.Pointer(&index)), - uintptr(unsafe.Pointer(&element)))) - str = BstrToString(*(**uint16)(unsafe.Pointer(&element))) - SysFreeString(element) - return -} - -// safeArrayGetIID is the InterfaceID of the elements in the SafeArray. -// -// AKA: SafeArrayGetIID in Windows API. -func safeArrayGetIID(safearray *SafeArray) (guid *GUID, err error) { - err = convertHresultToError( - procSafeArrayGetIID.Call( - uintptr(unsafe.Pointer(safearray)), - uintptr(unsafe.Pointer(&guid)))) - return -} - -// safeArrayGetLBound returns lower bounds of SafeArray. -// -// SafeArrays may have multiple dimensions. Meaning, it could be -// multidimensional array. -// -// AKA: SafeArrayGetLBound in Windows API. -func safeArrayGetLBound(safearray *SafeArray, dimension uint32) (lowerBound int64, err error) { - err = convertHresultToError( - procSafeArrayGetLBound.Call( - uintptr(unsafe.Pointer(safearray)), - uintptr(dimension), - uintptr(unsafe.Pointer(&lowerBound)))) - return -} - -// safeArrayGetUBound returns upper bounds of SafeArray. -// -// SafeArrays may have multiple dimensions. Meaning, it could be -// multidimensional array. -// -// AKA: SafeArrayGetUBound in Windows API. -func safeArrayGetUBound(safearray *SafeArray, dimension uint32) (upperBound int64, err error) { - err = convertHresultToError( - procSafeArrayGetUBound.Call( - uintptr(unsafe.Pointer(safearray)), - uintptr(dimension), - uintptr(unsafe.Pointer(&upperBound)))) - return -} - -// safeArrayGetVartype returns data type of SafeArray. -// -// AKA: SafeArrayGetVartype in Windows API. -func safeArrayGetVartype(safearray *SafeArray) (varType uint16, err error) { - err = convertHresultToError( - procSafeArrayGetVartype.Call( - uintptr(unsafe.Pointer(safearray)), - uintptr(unsafe.Pointer(&varType)))) - return -} - -// safeArrayLock locks SafeArray for reading to modify SafeArray. -// -// This must be called during some calls to ensure that another process does not -// read or write to the SafeArray during editing. -// -// AKA: SafeArrayLock in Windows API. -func safeArrayLock(safearray *SafeArray) (err error) { - err = convertHresultToError(procSafeArrayLock.Call(uintptr(unsafe.Pointer(safearray)))) - return -} - -// safeArrayUnlock unlocks SafeArray for reading. -// -// AKA: SafeArrayUnlock in Windows API. -func safeArrayUnlock(safearray *SafeArray) (err error) { - err = convertHresultToError(procSafeArrayUnlock.Call(uintptr(unsafe.Pointer(safearray)))) - return -} - -// safeArrayPutElement stores the data element at the specified location in the -// array. -// -// AKA: SafeArrayPutElement in Windows API. -func safeArrayPutElement(safearray *SafeArray, index int64, element uintptr) (err error) { - err = convertHresultToError( - procSafeArrayPutElement.Call( - uintptr(unsafe.Pointer(safearray)), - uintptr(unsafe.Pointer(&index)), - uintptr(unsafe.Pointer(element)))) - return -} - -// safeArrayGetRecordInfo accesses IRecordInfo info for custom types. -// -// AKA: SafeArrayGetRecordInfo in Windows API. -// -// XXX: Must implement IRecordInfo interface for this to return. -func safeArrayGetRecordInfo(safearray *SafeArray) (recordInfo interface{}, err error) { - err = convertHresultToError( - procSafeArrayGetRecordInfo.Call( - uintptr(unsafe.Pointer(safearray)), - uintptr(unsafe.Pointer(&recordInfo)))) - return -} - -// safeArraySetRecordInfo mutates IRecordInfo info for custom types. -// -// AKA: SafeArraySetRecordInfo in Windows API. -// -// XXX: Must implement IRecordInfo interface for this to return. -func safeArraySetRecordInfo(safearray *SafeArray, recordInfo interface{}) (err error) { - err = convertHresultToError( - procSafeArraySetRecordInfo.Call( - uintptr(unsafe.Pointer(safearray)), - uintptr(unsafe.Pointer(&recordInfo)))) - return -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/safearrayconversion.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/safearrayconversion.go deleted file mode 100644 index ffeb2b97b0..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/safearrayconversion.go +++ /dev/null @@ -1,140 +0,0 @@ -// Helper for converting SafeArray to array of objects. - -package ole - -import ( - "unsafe" -) - -type SafeArrayConversion struct { - Array *SafeArray -} - -func (sac *SafeArrayConversion) ToStringArray() (strings []string) { - totalElements, _ := sac.TotalElements(0) - strings = make([]string, totalElements) - - for i := int64(0); i < totalElements; i++ { - strings[int32(i)], _ = safeArrayGetElementString(sac.Array, i) - } - - return -} - -func (sac *SafeArrayConversion) ToByteArray() (bytes []byte) { - totalElements, _ := sac.TotalElements(0) - bytes = make([]byte, totalElements) - - for i := int64(0); i < totalElements; i++ { - safeArrayGetElement(sac.Array, i, unsafe.Pointer(&bytes[int32(i)])) - } - - return -} - -func (sac *SafeArrayConversion) ToValueArray() (values []interface{}) { - totalElements, _ := sac.TotalElements(0) - values = make([]interface{}, totalElements) - vt, _ := safeArrayGetVartype(sac.Array) - - for i := 0; i < int(totalElements); i++ { - switch VT(vt) { - case VT_BOOL: - var v bool - safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) - values[i] = v - case VT_I1: - var v int8 - safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) - values[i] = v - case VT_I2: - var v int16 - safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) - values[i] = v - case VT_I4: - var v int32 - safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) - values[i] = v - case VT_I8: - var v int64 - safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) - values[i] = v - case VT_UI1: - var v uint8 - safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) - values[i] = v - case VT_UI2: - var v uint16 - safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) - values[i] = v - case VT_UI4: - var v uint32 - safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) - values[i] = v - case VT_UI8: - var v uint64 - safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) - values[i] = v - case VT_R4: - var v float32 - safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) - values[i] = v - case VT_R8: - var v float64 - safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) - values[i] = v - case VT_BSTR: - var v string - safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) - values[i] = v - case VT_VARIANT: - var v VARIANT - safeArrayGetElement(sac.Array, int64(i), unsafe.Pointer(&v)) - values[i] = v.Value() - default: - // TODO - } - } - - return -} - -func (sac *SafeArrayConversion) GetType() (varType uint16, err error) { - return safeArrayGetVartype(sac.Array) -} - -func (sac *SafeArrayConversion) GetDimensions() (dimensions *uint32, err error) { - return safeArrayGetDim(sac.Array) -} - -func (sac *SafeArrayConversion) GetSize() (length *uint32, err error) { - return safeArrayGetElementSize(sac.Array) -} - -func (sac *SafeArrayConversion) TotalElements(index uint32) (totalElements int64, err error) { - if index < 1 { - index = 1 - } - - // Get array bounds - var LowerBounds int64 - var UpperBounds int64 - - LowerBounds, err = safeArrayGetLBound(sac.Array, index) - if err != nil { - return - } - - UpperBounds, err = safeArrayGetUBound(sac.Array, index) - if err != nil { - return - } - - totalElements = UpperBounds - LowerBounds + 1 - return -} - -// Release Safe Array memory -func (sac *SafeArrayConversion) Release() { - safeArrayDestroy(sac.Array) -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/safearrayslices.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/safearrayslices.go deleted file mode 100644 index a9fa885f1d..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/safearrayslices.go +++ /dev/null @@ -1,33 +0,0 @@ -// +build windows - -package ole - -import ( - "unsafe" -) - -func safeArrayFromByteSlice(slice []byte) *SafeArray { - array, _ := safeArrayCreateVector(VT_UI1, 0, uint32(len(slice))) - - if array == nil { - panic("Could not convert []byte to SAFEARRAY") - } - - for i, v := range slice { - safeArrayPutElement(array, int64(i), uintptr(unsafe.Pointer(&v))) - } - return array -} - -func safeArrayFromStringSlice(slice []string) *SafeArray { - array, _ := safeArrayCreateVector(VT_BSTR, 0, uint32(len(slice))) - - if array == nil { - panic("Could not convert []string to SAFEARRAY") - } - // SysAllocStringLen(s) - for i, v := range slice { - safeArrayPutElement(array, int64(i), uintptr(unsafe.Pointer(SysAllocStringLen(v)))) - } - return array -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/utility.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/utility.go deleted file mode 100644 index 99ee82dc34..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/utility.go +++ /dev/null @@ -1,101 +0,0 @@ -package ole - -import ( - "unicode/utf16" - "unsafe" -) - -// ClassIDFrom retrieves class ID whether given is program ID or application string. -// -// Helper that provides check against both Class ID from Program ID and Class ID from string. It is -// faster, if you know which you are using, to use the individual functions, but this will check -// against available functions for you. -func ClassIDFrom(programID string) (classID *GUID, err error) { - classID, err = CLSIDFromProgID(programID) - if err != nil { - classID, err = CLSIDFromString(programID) - if err != nil { - return - } - } - return -} - -// BytePtrToString converts byte pointer to a Go string. -func BytePtrToString(p *byte) string { - a := (*[10000]uint8)(unsafe.Pointer(p)) - i := 0 - for a[i] != 0 { - i++ - } - return string(a[:i]) -} - -// UTF16PtrToString is alias for LpOleStrToString. -// -// Kept for compatibility reasons. -func UTF16PtrToString(p *uint16) string { - return LpOleStrToString(p) -} - -// LpOleStrToString converts COM Unicode to Go string. -func LpOleStrToString(p *uint16) string { - if p == nil { - return "" - } - - length := lpOleStrLen(p) - a := make([]uint16, length) - - ptr := unsafe.Pointer(p) - - for i := 0; i < int(length); i++ { - a[i] = *(*uint16)(ptr) - ptr = unsafe.Pointer(uintptr(ptr) + 2) - } - - return string(utf16.Decode(a)) -} - -// BstrToString converts COM binary string to Go string. -func BstrToString(p *uint16) string { - if p == nil { - return "" - } - length := SysStringLen((*int16)(unsafe.Pointer(p))) - a := make([]uint16, length) - - ptr := unsafe.Pointer(p) - - for i := 0; i < int(length); i++ { - a[i] = *(*uint16)(ptr) - ptr = unsafe.Pointer(uintptr(ptr) + 2) - } - return string(utf16.Decode(a)) -} - -// lpOleStrLen returns the length of Unicode string. -func lpOleStrLen(p *uint16) (length int64) { - if p == nil { - return 0 - } - - ptr := unsafe.Pointer(p) - - for i := 0; ; i++ { - if 0 == *(*uint16)(ptr) { - length = int64(i) - break - } - ptr = unsafe.Pointer(uintptr(ptr) + 2) - } - return -} - -// convertHresultToError converts syscall to error, if call is unsuccessful. -func convertHresultToError(hr uintptr, r2 uintptr, ignore error) (err error) { - if hr != 0 { - err = NewError(hr) - } - return -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/variables.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/variables.go deleted file mode 100644 index ebe00f1cfc..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/variables.go +++ /dev/null @@ -1,16 +0,0 @@ -// +build windows - -package ole - -import ( - "syscall" -) - -var ( - modcombase = syscall.NewLazyDLL("combase.dll") - modkernel32, _ = syscall.LoadDLL("kernel32.dll") - modole32, _ = syscall.LoadDLL("ole32.dll") - modoleaut32, _ = syscall.LoadDLL("oleaut32.dll") - modmsvcrt, _ = syscall.LoadDLL("msvcrt.dll") - moduser32, _ = syscall.LoadDLL("user32.dll") -) diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/variant.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/variant.go deleted file mode 100644 index 36969725eb..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/variant.go +++ /dev/null @@ -1,105 +0,0 @@ -package ole - -import "unsafe" - -// NewVariant returns new variant based on type and value. -func NewVariant(vt VT, val int64) VARIANT { - return VARIANT{VT: vt, Val: val} -} - -// ToIUnknown converts Variant to Unknown object. -func (v *VARIANT) ToIUnknown() *IUnknown { - if v.VT != VT_UNKNOWN { - return nil - } - return (*IUnknown)(unsafe.Pointer(uintptr(v.Val))) -} - -// ToIDispatch converts variant to dispatch object. -func (v *VARIANT) ToIDispatch() *IDispatch { - if v.VT != VT_DISPATCH { - return nil - } - return (*IDispatch)(unsafe.Pointer(uintptr(v.Val))) -} - -// ToArray converts variant to SafeArray helper. -func (v *VARIANT) ToArray() *SafeArrayConversion { - if v.VT != VT_SAFEARRAY { - if v.VT&VT_ARRAY == 0 { - return nil - } - } - var safeArray *SafeArray = (*SafeArray)(unsafe.Pointer(uintptr(v.Val))) - return &SafeArrayConversion{safeArray} -} - -// ToString converts variant to Go string. -func (v *VARIANT) ToString() string { - if v.VT != VT_BSTR { - return "" - } - return BstrToString(*(**uint16)(unsafe.Pointer(&v.Val))) -} - -// Clear the memory of variant object. -func (v *VARIANT) Clear() error { - return VariantClear(v) -} - -// Value returns variant value based on its type. -// -// Currently supported types: 2- and 4-byte integers, strings, bools. -// Note that 64-bit integers, datetimes, and other types are stored as strings -// and will be returned as strings. -// -// Needs to be further converted, because this returns an interface{}. -func (v *VARIANT) Value() interface{} { - switch v.VT { - case VT_I1: - return int8(v.Val) - case VT_UI1: - return uint8(v.Val) - case VT_I2: - return int16(v.Val) - case VT_UI2: - return uint16(v.Val) - case VT_I4: - return int32(v.Val) - case VT_UI4: - return uint32(v.Val) - case VT_I8: - return int64(v.Val) - case VT_UI8: - return uint64(v.Val) - case VT_INT: - return int(v.Val) - case VT_UINT: - return uint(v.Val) - case VT_INT_PTR: - return uintptr(v.Val) // TODO - case VT_UINT_PTR: - return uintptr(v.Val) - case VT_R4: - return *(*float32)(unsafe.Pointer(&v.Val)) - case VT_R8: - return *(*float64)(unsafe.Pointer(&v.Val)) - case VT_BSTR: - return v.ToString() - case VT_DATE: - // VT_DATE type will either return float64 or time.Time. - d := float64(v.Val) - date, err := GetVariantDate(d) - if err != nil { - return d - } - return date - case VT_UNKNOWN: - return v.ToIUnknown() - case VT_DISPATCH: - return v.ToIDispatch() - case VT_BOOL: - return v.Val != 0 - } - return nil -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/variant_386.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/variant_386.go deleted file mode 100644 index e73736bf39..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/variant_386.go +++ /dev/null @@ -1,11 +0,0 @@ -// +build 386 - -package ole - -type VARIANT struct { - VT VT // 2 - wReserved1 uint16 // 4 - wReserved2 uint16 // 6 - wReserved3 uint16 // 8 - Val int64 // 16 -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/variant_amd64.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/variant_amd64.go deleted file mode 100644 index dccdde1323..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/variant_amd64.go +++ /dev/null @@ -1,12 +0,0 @@ -// +build amd64 - -package ole - -type VARIANT struct { - VT VT // 2 - wReserved1 uint16 // 4 - wReserved2 uint16 // 6 - wReserved3 uint16 // 8 - Val int64 // 16 - _ [8]byte // 24 -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/vt_string.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/vt_string.go deleted file mode 100644 index 729b4a04dd..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/vt_string.go +++ /dev/null @@ -1,58 +0,0 @@ -// generated by stringer -output vt_string.go -type VT; DO NOT EDIT - -package ole - -import "fmt" - -const ( - _VT_name_0 = "VT_EMPTYVT_NULLVT_I2VT_I4VT_R4VT_R8VT_CYVT_DATEVT_BSTRVT_DISPATCHVT_ERRORVT_BOOLVT_VARIANTVT_UNKNOWNVT_DECIMAL" - _VT_name_1 = "VT_I1VT_UI1VT_UI2VT_UI4VT_I8VT_UI8VT_INTVT_UINTVT_VOIDVT_HRESULTVT_PTRVT_SAFEARRAYVT_CARRAYVT_USERDEFINEDVT_LPSTRVT_LPWSTR" - _VT_name_2 = "VT_RECORDVT_INT_PTRVT_UINT_PTR" - _VT_name_3 = "VT_FILETIMEVT_BLOBVT_STREAMVT_STORAGEVT_STREAMED_OBJECTVT_STORED_OBJECTVT_BLOB_OBJECTVT_CFVT_CLSID" - _VT_name_4 = "VT_BSTR_BLOBVT_VECTOR" - _VT_name_5 = "VT_ARRAY" - _VT_name_6 = "VT_BYREF" - _VT_name_7 = "VT_RESERVED" - _VT_name_8 = "VT_ILLEGAL" -) - -var ( - _VT_index_0 = [...]uint8{0, 8, 15, 20, 25, 30, 35, 40, 47, 54, 65, 73, 80, 90, 100, 110} - _VT_index_1 = [...]uint8{0, 5, 11, 17, 23, 28, 34, 40, 47, 54, 64, 70, 82, 91, 105, 113, 122} - _VT_index_2 = [...]uint8{0, 9, 19, 30} - _VT_index_3 = [...]uint8{0, 11, 18, 27, 37, 55, 71, 85, 90, 98} - _VT_index_4 = [...]uint8{0, 12, 21} - _VT_index_5 = [...]uint8{0, 8} - _VT_index_6 = [...]uint8{0, 8} - _VT_index_7 = [...]uint8{0, 11} - _VT_index_8 = [...]uint8{0, 10} -) - -func (i VT) String() string { - switch { - case 0 <= i && i <= 14: - return _VT_name_0[_VT_index_0[i]:_VT_index_0[i+1]] - case 16 <= i && i <= 31: - i -= 16 - return _VT_name_1[_VT_index_1[i]:_VT_index_1[i+1]] - case 36 <= i && i <= 38: - i -= 36 - return _VT_name_2[_VT_index_2[i]:_VT_index_2[i+1]] - case 64 <= i && i <= 72: - i -= 64 - return _VT_name_3[_VT_index_3[i]:_VT_index_3[i+1]] - case 4095 <= i && i <= 4096: - i -= 4095 - return _VT_name_4[_VT_index_4[i]:_VT_index_4[i+1]] - case i == 8192: - return _VT_name_5 - case i == 16384: - return _VT_name_6 - case i == 32768: - return _VT_name_7 - case i == 65535: - return _VT_name_8 - default: - return fmt.Sprintf("VT(%d)", i) - } -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/winrt.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/winrt.go deleted file mode 100644 index 4e9eca7324..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/winrt.go +++ /dev/null @@ -1,99 +0,0 @@ -// +build windows - -package ole - -import ( - "reflect" - "syscall" - "unicode/utf8" - "unsafe" -) - -var ( - procRoInitialize = modcombase.NewProc("RoInitialize") - procRoActivateInstance = modcombase.NewProc("RoActivateInstance") - procRoGetActivationFactory = modcombase.NewProc("RoGetActivationFactory") - procWindowsCreateString = modcombase.NewProc("WindowsCreateString") - procWindowsDeleteString = modcombase.NewProc("WindowsDeleteString") - procWindowsGetStringRawBuffer = modcombase.NewProc("WindowsGetStringRawBuffer") -) - -func RoInitialize(thread_type uint32) (err error) { - hr, _, _ := procRoInitialize.Call(uintptr(thread_type)) - if hr != 0 { - err = NewError(hr) - } - return -} - -func RoActivateInstance(clsid string) (ins *IInspectable, err error) { - hClsid, err := NewHString(clsid) - if err != nil { - return nil, err - } - defer DeleteHString(hClsid) - - hr, _, _ := procRoActivateInstance.Call( - uintptr(unsafe.Pointer(hClsid)), - uintptr(unsafe.Pointer(&ins))) - if hr != 0 { - err = NewError(hr) - } - return -} - -func RoGetActivationFactory(clsid string, iid *GUID) (ins *IInspectable, err error) { - hClsid, err := NewHString(clsid) - if err != nil { - return nil, err - } - defer DeleteHString(hClsid) - - hr, _, _ := procRoGetActivationFactory.Call( - uintptr(unsafe.Pointer(hClsid)), - uintptr(unsafe.Pointer(iid)), - uintptr(unsafe.Pointer(&ins))) - if hr != 0 { - err = NewError(hr) - } - return -} - -// HString is handle string for pointers. -type HString uintptr - -// NewHString returns a new HString for Go string. -func NewHString(s string) (hstring HString, err error) { - u16 := syscall.StringToUTF16Ptr(s) - len := uint32(utf8.RuneCountInString(s)) - hr, _, _ := procWindowsCreateString.Call( - uintptr(unsafe.Pointer(u16)), - uintptr(len), - uintptr(unsafe.Pointer(&hstring))) - if hr != 0 { - err = NewError(hr) - } - return -} - -// DeleteHString deletes HString. -func DeleteHString(hstring HString) (err error) { - hr, _, _ := procWindowsDeleteString.Call(uintptr(hstring)) - if hr != 0 { - err = NewError(hr) - } - return -} - -// String returns Go string value of HString. -func (h HString) String() string { - var u16buf uintptr - var u16len uint32 - u16buf, _, _ = procWindowsGetStringRawBuffer.Call( - uintptr(h), - uintptr(unsafe.Pointer(&u16len))) - - u16hdr := reflect.SliceHeader{Data: u16buf, Len: int(u16len), Cap: int(u16len)} - u16 := *(*[]uint16)(unsafe.Pointer(&u16hdr)) - return syscall.UTF16ToString(u16) -} diff --git a/Godeps/_workspace/src/github.com/go-ole/go-ole/winrt_doc.go b/Godeps/_workspace/src/github.com/go-ole/go-ole/winrt_doc.go deleted file mode 100644 index 52e6d74c9a..0000000000 --- a/Godeps/_workspace/src/github.com/go-ole/go-ole/winrt_doc.go +++ /dev/null @@ -1,36 +0,0 @@ -// +build !windows - -package ole - -// RoInitialize -func RoInitialize(thread_type uint32) (err error) { - return NewError(E_NOTIMPL) -} - -// RoActivateInstance -func RoActivateInstance(clsid string) (ins *IInspectable, err error) { - return nil, NewError(E_NOTIMPL) -} - -// RoGetActivationFactory -func RoGetActivationFactory(clsid string, iid *GUID) (ins *IInspectable, err error) { - return nil, NewError(E_NOTIMPL) -} - -// HString is handle string for pointers. -type HString uintptr - -// NewHString returns a new HString for Go string. -func NewHString(s string) (hstring HString, err error) { - return HString(uintptr(0)), NewError(E_NOTIMPL) -} - -// DeleteHString deletes HString. -func DeleteHString(hstring HString) (err error) { - return NewError(E_NOTIMPL) -} - -// String returns Go string value of HString. -func (h HString) String() string { - return "" -} diff --git a/Godeps/_workspace/src/github.com/godbus/dbus/CONTRIBUTING.md b/Godeps/_workspace/src/github.com/godbus/dbus/CONTRIBUTING.md deleted file mode 100644 index c88f9b2bdd..0000000000 --- a/Godeps/_workspace/src/github.com/godbus/dbus/CONTRIBUTING.md +++ /dev/null @@ -1,50 +0,0 @@ -# How to Contribute - -## Getting Started - -- Fork the repository on GitHub -- Read the [README](README.markdown) for build and test instructions -- Play with the project, submit bugs, submit patches! - -## Contribution Flow - -This is a rough outline of what a contributor's workflow looks like: - -- Create a topic branch from where you want to base your work (usually master). -- Make commits of logical units. -- Make sure your commit messages are in the proper format (see below). -- Push your changes to a topic branch in your fork of the repository. -- Make sure the tests pass, and add any new tests as appropriate. -- Submit a pull request to the original repository. - -Thanks for your contributions! - -### Format of the Commit Message - -We follow a rough convention for commit messages that is designed to answer two -questions: what changed and why. The subject line should feature the what and -the body of the commit should describe the why. - -``` -scripts: add the test-cluster command - -this uses tmux to setup a test cluster that you can easily kill and -start for debugging. - -Fixes #38 -``` - -The format can be described more formally as follows: - -``` -: - - - -